aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-10-30 07:35:11 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-10-30 07:35:11 -0400
commit67577927e8d7a1f4b09b4992df640eadc6aacb36 (patch)
tree2e9efe6b5745965faf0dcc084d4613d9356263f9 /arch
parent6fe4c590313133ebd5dadb769031489ff178ece1 (diff)
parent51f00a471ce8f359627dd99aeac322947a0e491b (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Conflicts: drivers/mtd/mtd_blkdevs.c Merge Grant's device-tree bits so that we can apply the subsequent fixes. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/alpha/include/asm/irqflags.h67
-rw-r--r--arch/alpha/include/asm/perf_event.h5
-rw-r--r--arch/alpha/include/asm/system.h28
-rw-r--r--arch/alpha/kernel/perf_event.c128
-rw-r--r--arch/alpha/kernel/signal.c2
-rw-r--r--arch/alpha/kernel/time.c30
-rw-r--r--arch/arm/Kconfig93
-rw-r--r--arch/arm/Kconfig.debug19
-rw-r--r--arch/arm/Makefile11
-rw-r--r--arch/arm/common/gic.c14
-rw-r--r--arch/arm/common/icst.c2
-rw-r--r--arch/arm/common/pl330.c7
-rw-r--r--arch/arm/common/sa1111.c2
-rw-r--r--arch/arm/common/scoop.c12
-rw-r--r--arch/arm/common/uengine.c18
-rw-r--r--arch/arm/configs/at91sam9g20ek_defconfig1
-rw-r--r--arch/arm/configs/kirkwood_defconfig1
-rw-r--r--arch/arm/configs/mx27_defconfig15
-rw-r--r--arch/arm/configs/mx31pdk_defconfig44
-rw-r--r--arch/arm/configs/mx3_defconfig2
-rw-r--r--arch/arm/configs/mx51_defconfig9
-rw-r--r--arch/arm/configs/realview-smp_defconfig15
-rw-r--r--arch/arm/configs/realview_defconfig15
-rw-r--r--arch/arm/configs/s5p64x0_defconfig (renamed from arch/arm/configs/s5p6440_defconfig)3
-rw-r--r--arch/arm/configs/u300_defconfig37
-rw-r--r--arch/arm/include/asm/assembler.h27
-rw-r--r--arch/arm/include/asm/cacheflush.h65
-rw-r--r--arch/arm/include/asm/cachetype.h8
-rw-r--r--arch/arm/include/asm/elf.h4
-rw-r--r--arch/arm/include/asm/ftrace.h20
-rw-r--r--arch/arm/include/asm/hardware/coresight.h34
-rw-r--r--arch/arm/include/asm/hardware/icst.h2
-rw-r--r--arch/arm/include/asm/hw_breakpoint.h133
-rw-r--r--arch/arm/include/asm/hw_irq.h2
-rw-r--r--arch/arm/include/asm/io.h1
-rw-r--r--arch/arm/include/asm/ioctls.h83
-rw-r--r--arch/arm/include/asm/irqflags.h145
-rw-r--r--arch/arm/include/asm/mach/arch.h9
-rw-r--r--arch/arm/include/asm/mmu_context.h29
-rw-r--r--arch/arm/include/asm/module.h31
-rw-r--r--arch/arm/include/asm/perf_event.h12
-rw-r--r--arch/arm/include/asm/pgtable.h26
-rw-r--r--arch/arm/include/asm/processor.h4
-rw-r--r--arch/arm/include/asm/ptrace.h2
-rw-r--r--arch/arm/include/asm/seccomp.h11
-rw-r--r--arch/arm/include/asm/smp_mpidr.h17
-rw-r--r--arch/arm/include/asm/smp_plat.h25
-rw-r--r--arch/arm/include/asm/system.h6
-rw-r--r--arch/arm/include/asm/thread_info.h2
-rw-r--r--arch/arm/include/asm/tlbflush.h36
-rw-r--r--arch/arm/kernel/Makefile1
-rw-r--r--arch/arm/kernel/armksyms.c2
-rw-r--r--arch/arm/kernel/asm-offsets.c2
-rw-r--r--arch/arm/kernel/debug.S35
-rw-r--r--arch/arm/kernel/entry-armv.S11
-rw-r--r--arch/arm/kernel/entry-common.S78
-rw-r--r--arch/arm/kernel/etm.c16
-rw-r--r--arch/arm/kernel/ftrace.c188
-rw-r--r--arch/arm/kernel/head-common.S305
-rw-r--r--arch/arm/kernel/head-nommu.S5
-rw-r--r--arch/arm/kernel/head.S323
-rw-r--r--arch/arm/kernel/hw_breakpoint.c849
-rw-r--r--arch/arm/kernel/irq.c10
-rw-r--r--arch/arm/kernel/kprobes-decode.c7
-rw-r--r--arch/arm/kernel/module.c68
-rw-r--r--arch/arm/kernel/perf_event.c212
-rw-r--r--arch/arm/kernel/process.c45
-rw-r--r--arch/arm/kernel/ptrace.c239
-rw-r--r--arch/arm/kernel/setup.c46
-rw-r--r--arch/arm/kernel/smp.c66
-rw-r--r--arch/arm/kernel/unwind.c2
-rw-r--r--arch/arm/kernel/vmlinux.lds.S39
-rw-r--r--arch/arm/mach-aaec2000/aaed2000.c2
-rw-r--r--arch/arm/mach-aaec2000/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-aaec2000/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-at91/Kconfig21
-rw-r--r--arch/arm/mach-at91/Makefile4
-rw-r--r--arch/arm/mach-at91/board-1arm.c2
-rw-r--r--arch/arm/mach-at91/board-afeb-9260v1.c2
-rw-r--r--arch/arm/mach-at91/board-at572d940hf_ek.c4
-rw-r--r--arch/arm/mach-at91/board-cam60.c2
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c2
-rw-r--r--arch/arm/mach-at91/board-carmeva.c2
-rw-r--r--arch/arm/mach-at91/board-cpu9krea.c2
-rw-r--r--arch/arm/mach-at91/board-cpuat91.c2
-rw-r--r--arch/arm/mach-at91/board-csb337.c2
-rw-r--r--arch/arm/mach-at91/board-csb637.c2
-rw-r--r--arch/arm/mach-at91/board-dk.c2
-rw-r--r--arch/arm/mach-at91/board-eb9200.c2
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c2
-rw-r--r--arch/arm/mach-at91/board-eco920.c2
-rw-r--r--arch/arm/mach-at91/board-ek.c2
-rw-r--r--arch/arm/mach-at91/board-flexibity.c162
-rw-r--r--arch/arm/mach-at91/board-kafa.c2
-rw-r--r--arch/arm/mach-at91/board-kb9202.c2
-rw-r--r--arch/arm/mach-at91/board-neocore926.c2
-rw-r--r--arch/arm/mach-at91/board-picotux200.c2
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c2
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c2
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c329
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c74
-rw-r--r--arch/arm/mach-at91/board-sam9m10g45ek.c6
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c2
-rw-r--r--arch/arm/mach-at91/board-snapper9260.c2
-rw-r--r--arch/arm/mach-at91/board-stamp9g20.c4
-rw-r--r--arch/arm/mach-at91/board-usb-a9260.c2
-rw-r--r--arch/arm/mach-at91/board-usb-a9263.c2
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c2
-rw-r--r--arch/arm/mach-at91/include/mach/at91x40.h6
-rw-r--r--arch/arm/mach-at91/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-at91/include/mach/system.h11
-rw-r--r--arch/arm/mach-bcmring/arch.c2
-rw-r--r--arch/arm/mach-bcmring/dma.c4
-rw-r--r--arch/arm/mach-bcmring/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-bcmring/irq.c6
-rw-r--r--arch/arm/mach-clps711x/autcpu12.c2
-rw-r--r--arch/arm/mach-clps711x/cdb89712.c2
-rw-r--r--arch/arm/mach-clps711x/ceiva.c2
-rw-r--r--arch/arm/mach-clps711x/clep7312.c2
-rw-r--r--arch/arm/mach-clps711x/edb7211-arch.c2
-rw-r--r--arch/arm/mach-clps711x/fortunet.c2
-rw-r--r--arch/arm/mach-clps711x/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-clps711x/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-clps711x/p720t.c2
-rw-r--r--arch/arm/mach-cns3xxx/cns3420vb.c2
-rw-r--r--arch/arm/mach-cns3xxx/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-davinci/board-da830-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm355-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm355-leopard.c2
-rw-r--r--arch/arm/mach-davinci/board-dm365-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c2
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c4
-rw-r--r--arch/arm/mach-davinci/board-neuros-osd2.c2
-rw-r--r--arch/arm/mach-davinci/board-sffsdr.c2
-rw-r--r--arch/arm/mach-davinci/board-tnetv107x-evm.c2
-rw-r--r--arch/arm/mach-davinci/include/mach/debug-macro.S46
-rw-r--r--arch/arm/mach-dove/dove-db-setup.c2
-rw-r--r--arch/arm/mach-dove/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-ebsa110/core.c2
-rw-r--r--arch/arm/mach-ebsa110/include/mach/debug-macro.S7
-rw-r--r--arch/arm/mach-ebsa110/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-ep93xx/adssphere.c2
-rw-r--r--arch/arm/mach-ep93xx/dma-m2p.c2
-rw-r--r--arch/arm/mach-ep93xx/edb93xx.c16
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c2
-rw-r--r--arch/arm/mach-ep93xx/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-ep93xx/micro9.c8
-rw-r--r--arch/arm/mach-ep93xx/simone.c2
-rw-r--r--arch/arm/mach-ep93xx/snappercl15.c2
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c2
-rw-r--r--arch/arm/mach-footbridge/cats-hw.c2
-rw-r--r--arch/arm/mach-footbridge/ebsa285.c2
-rw-r--r--arch/arm/mach-footbridge/include/mach/debug-macro.S22
-rw-r--r--arch/arm/mach-footbridge/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-footbridge/netwinder-hw.c2
-rw-r--r--arch/arm/mach-footbridge/personal.c2
-rw-r--r--arch/arm/mach-gemini/board-nas4220b.c2
-rw-r--r--arch/arm/mach-gemini/board-rut1xx.c2
-rw-r--r--arch/arm/mach-gemini/board-wbd111.c2
-rw-r--r--arch/arm/mach-gemini/board-wbd222.c2
-rw-r--r--arch/arm/mach-gemini/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-h720x/h7201-eval.c2
-rw-r--r--arch/arm/mach-h720x/h7202-eval.c2
-rw-r--r--arch/arm/mach-h720x/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-h720x/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-imx/Kconfig15
-rw-r--r--arch/arm/mach-imx/Makefile1
-rw-r--r--arch/arm/mach-imx/clock-imx1.c2
-rw-r--r--arch/arm/mach-imx/clock-imx21.c6
-rw-r--r--arch/arm/mach-imx/clock-imx27.c48
-rw-r--r--arch/arm/mach-imx/devices-imx1.h14
-rw-r--r--arch/arm/mach-imx/devices-imx21.h36
-rw-r--r--arch/arm/mach-imx/devices-imx27.h51
-rw-r--r--arch/arm/mach-imx/devices.c56
-rw-r--r--arch/arm/mach-imx/devices.h3
-rw-r--r--arch/arm/mach-imx/eukrea_mbimx27-baseboard.c8
-rw-r--r--arch/arm/mach-imx/mach-cpuimx27.c8
-rw-r--r--arch/arm/mach-imx/mach-imx27_visstrim_m10.c261
-rw-r--r--arch/arm/mach-imx/mach-imx27lite.c10
-rw-r--r--arch/arm/mach-imx/mach-mx1ads.c8
-rw-r--r--arch/arm/mach-imx/mach-mx21ads.c4
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c10
-rw-r--r--arch/arm/mach-imx/mach-mx27ads.c8
-rw-r--r--arch/arm/mach-imx/mach-mxt_td60.c15
-rw-r--r--arch/arm/mach-imx/mach-pca100.c17
-rw-r--r--arch/arm/mach-imx/mach-pcm038.c10
-rw-r--r--arch/arm/mach-imx/mach-scb9328.c4
-rw-r--r--arch/arm/mach-imx/pcm970-baseboard.c4
-rw-r--r--arch/arm/mach-integrator/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-integrator/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c2
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c2
-rw-r--r--arch/arm/mach-iop13xx/include/mach/debug-macro.S16
-rw-r--r--arch/arm/mach-iop13xx/iq81340mc.c2
-rw-r--r--arch/arm/mach-iop13xx/iq81340sc.c2
-rw-r--r--arch/arm/mach-iop13xx/msi.c8
-rw-r--r--arch/arm/mach-iop32x/em7210.c2
-rw-r--r--arch/arm/mach-iop32x/glantank.c2
-rw-r--r--arch/arm/mach-iop32x/include/mach/debug-macro.S7
-rw-r--r--arch/arm/mach-iop32x/iq31244.c4
-rw-r--r--arch/arm/mach-iop32x/iq80321.c2
-rw-r--r--arch/arm/mach-iop32x/n2100.c2
-rw-r--r--arch/arm/mach-iop33x/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-iop33x/iq80331.c2
-rw-r--r--arch/arm/mach-iop33x/iq80332.c2
-rw-r--r--arch/arm/mach-ixp2000/enp2611.c2
-rw-r--r--arch/arm/mach-ixp2000/include/mach/debug-macro.S14
-rw-r--r--arch/arm/mach-ixp2000/ixdp2400.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x01.c6
-rw-r--r--arch/arm/mach-ixp23xx/espresso.c2
-rw-r--r--arch/arm/mach-ixp23xx/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-ixp23xx/ixdp2351.c2
-rw-r--r--arch/arm/mach-ixp23xx/roadrunner.c2
-rw-r--r--arch/arm/mach-ixp4xx/avila-setup.c4
-rw-r--r--arch/arm/mach-ixp4xx/coyote-setup.c4
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/fsg-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/gateway7001-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/goramo_mlr.c2
-rw-r--r--arch/arm/mach-ixp4xx/gtwx5715-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/debug-macro.S16
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c8
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/vulcan-setup.c2
-rw-r--r--arch/arm/mach-ixp4xx/wg302v2-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/Kconfig12
-rw-r--r--arch/arm/mach-kirkwood/Makefile12
-rw-r--r--arch/arm/mach-kirkwood/d2net_v2-setup.c229
-rw-r--r--arch/arm/mach-kirkwood/db88f6281-bp-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/dockstar-setup.c110
-rw-r--r--arch/arm/mach-kirkwood/guruplug-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-kirkwood/include/mach/leds-netxbig.h55
-rw-r--r--arch/arm/mach-kirkwood/lacie_v2-common.c127
-rw-r--r--arch/arm/mach-kirkwood/lacie_v2-common.h18
-rw-r--r--arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/netspace_v2-setup.c128
-rw-r--r--arch/arm/mach-kirkwood/netxbig_v2-setup.c273
-rw-r--r--arch/arm/mach-kirkwood/openrd-setup.c107
-rw-r--r--arch/arm/mach-kirkwood/rd88f6192-nas-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/rd88f6281-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/sheevaplug-setup.c4
-rw-r--r--arch/arm/mach-kirkwood/t5325-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/ts219-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/ts41x-setup.c2
-rw-r--r--arch/arm/mach-ks8695/board-acs5k.c2
-rw-r--r--arch/arm/mach-ks8695/board-dsm320.c2
-rw-r--r--arch/arm/mach-ks8695/board-micrel.c2
-rw-r--r--arch/arm/mach-ks8695/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-l7200/include/mach/debug-macro.S38
-rw-r--r--arch/arm/mach-lh7a40x/arch-kev7a400.c2
-rw-r--r--arch/arm/mach-lh7a40x/arch-lpd7a40x.c4
-rw-r--r--arch/arm/mach-lh7a40x/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-loki/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-loki/lb88rc8480-setup.c2
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-lpc32xx/phy3250.c9
-rw-r--r--arch/arm/mach-mmp/Kconfig7
-rw-r--r--arch/arm/mach-mmp/Makefile1
-rw-r--r--arch/arm/mach-mmp/aspenite.c94
-rw-r--r--arch/arm/mach-mmp/avengers_lite.c2
-rw-r--r--arch/arm/mach-mmp/common.c10
-rw-r--r--arch/arm/mach-mmp/flint.c6
-rw-r--r--arch/arm/mach-mmp/include/mach/cputype.h49
-rw-r--r--arch/arm/mach-mmp/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-mmp/include/mach/irqs.h4
-rw-r--r--arch/arm/mach-mmp/include/mach/mfp-pxa168.h7
-rw-r--r--arch/arm/mach-mmp/include/mach/pxa168.h20
-rw-r--r--arch/arm/mach-mmp/include/mach/regs-apmu.h12
-rw-r--r--arch/arm/mach-mmp/include/mach/teton_bga.h27
-rw-r--r--arch/arm/mach-mmp/jasper.c7
-rw-r--r--arch/arm/mach-mmp/pxa168.c16
-rw-r--r--arch/arm/mach-mmp/tavorevb.c2
-rw-r--r--arch/arm/mach-mmp/teton_bga.c89
-rw-r--r--arch/arm/mach-mmp/ttc_dkb.c6
-rw-r--r--arch/arm/mach-msm/Kconfig55
-rw-r--r--arch/arm/mach-msm/Makefile21
-rw-r--r--arch/arm/mach-msm/board-halibut.c2
-rw-r--r--arch/arm/mach-msm/board-mahimahi.c2
-rw-r--r--arch/arm/mach-msm/board-msm7x27.c8
-rw-r--r--arch/arm/mach-msm/board-msm7x30.c28
-rw-r--r--arch/arm/mach-msm/board-msm8x60.c100
-rw-r--r--arch/arm/mach-msm/board-qsd8x50.c50
-rw-r--r--arch/arm/mach-msm/board-sapphire.c2
-rw-r--r--arch/arm/mach-msm/board-trout.c2
-rw-r--r--arch/arm/mach-msm/clock-dummy.c54
-rw-r--r--arch/arm/mach-msm/devices-msm7x30.c5
-rw-r--r--arch/arm/mach-msm/devices-msm8x60-iommu.c883
-rw-r--r--arch/arm/mach-msm/devices-qsd8x50.c5
-rw-r--r--arch/arm/mach-msm/gpio.c409
-rw-r--r--arch/arm/mach-msm/gpio_hw.h278
-rw-r--r--arch/arm/mach-msm/gpiomux-7x30.c38
-rw-r--r--arch/arm/mach-msm/gpiomux-8x50.c28
-rw-r--r--arch/arm/mach-msm/gpiomux-8x60.c19
-rw-r--r--arch/arm/mach-msm/gpiomux-v1.c33
-rw-r--r--arch/arm/mach-msm/gpiomux-v1.h67
-rw-r--r--arch/arm/mach-msm/gpiomux-v2.c25
-rw-r--r--arch/arm/mach-msm/gpiomux-v2.h61
-rw-r--r--arch/arm/mach-msm/gpiomux.c96
-rw-r--r--arch/arm/mach-msm/gpiomux.h114
-rw-r--r--arch/arm/mach-msm/include/mach/board.h2
-rw-r--r--arch/arm/mach-msm/include/mach/debug-macro.S22
-rw-r--r--arch/arm/mach-msm/include/mach/dma.h10
-rw-r--r--arch/arm/mach-msm/include/mach/entry-macro-qgic.S88
-rw-r--r--arch/arm/mach-msm/include/mach/entry-macro-vic.S37
-rw-r--r--arch/arm/mach-msm/include/mach/entry-macro.S43
-rw-r--r--arch/arm/mach-msm/include/mach/gpio.h123
-rw-r--r--arch/arm/mach-msm/include/mach/io.h1
-rw-r--r--arch/arm/mach-msm/include/mach/iommu.h103
-rw-r--r--arch/arm/mach-msm/include/mach/iommu_hw-8xxx.h1871
-rw-r--r--arch/arm/mach-msm/include/mach/irqs-8x60.h253
-rw-r--r--arch/arm/mach-msm/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-msm/include/mach/memory.h2
-rw-r--r--arch/arm/mach-msm/include/mach/msm_iomap-8x60.h101
-rw-r--r--arch/arm/mach-msm/include/mach/msm_iomap.h4
-rw-r--r--arch/arm/mach-msm/include/mach/smp.h39
-rw-r--r--arch/arm/mach-msm/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-msm/io.c15
-rw-r--r--arch/arm/mach-msm/iommu.c597
-rw-r--r--arch/arm/mach-msm/iommu_dev.c374
-rw-r--r--arch/arm/mach-msm/last_radio_log.c3
-rw-r--r--arch/arm/mach-msm/smd_debug.c1
-rw-r--r--arch/arm/mach-msm/timer.c23
-rw-r--r--arch/arm/mach-mv78xx0/buffalo-wxl-setup.c2
-rw-r--r--arch/arm/mach-mv78xx0/db78x00-bp-setup.c2
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-mv78xx0/rd78x00-masa-setup.c2
-rw-r--r--arch/arm/mach-mx25/Kconfig6
-rw-r--r--arch/arm/mach-mx25/clock.c34
-rw-r--r--arch/arm/mach-mx25/devices-imx25.h61
-rw-r--r--arch/arm/mach-mx25/devices.c58
-rw-r--r--arch/arm/mach-mx25/devices.h3
-rw-r--r--arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c44
-rw-r--r--arch/arm/mach-mx25/mach-cpuimx25.c21
-rw-r--r--arch/arm/mach-mx25/mach-mx25_3ds.c7
-rw-r--r--arch/arm/mach-mx3/Kconfig11
-rw-r--r--arch/arm/mach-mx3/Makefile1
-rw-r--r--arch/arm/mach-mx3/clock-imx31.c10
-rw-r--r--arch/arm/mach-mx3/clock-imx35.c28
-rw-r--r--arch/arm/mach-mx3/cpu.c47
-rw-r--r--arch/arm/mach-mx3/devices-imx31.h49
-rw-r--r--arch/arm/mach-mx3/devices-imx35.h48
-rw-r--r--arch/arm/mach-mx3/devices.c63
-rw-r--r--arch/arm/mach-mx3/devices.h4
-rw-r--r--arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c59
-rw-r--r--arch/arm/mach-mx3/mach-armadillo5x0.c2
-rw-r--r--arch/arm/mach-mx3/mach-cpuimx35.c55
-rw-r--r--arch/arm/mach-mx3/mach-kzm_arm11_01.c2
-rw-r--r--arch/arm/mach-mx3/mach-mx31_3ds.c2
-rw-r--r--arch/arm/mach-mx3/mach-mx31ads.c11
-rw-r--r--arch/arm/mach-mx3/mach-mx31lilly.c2
-rw-r--r--arch/arm/mach-mx3/mach-mx31lite.c2
-rw-r--r--arch/arm/mach-mx3/mach-mx31moboard.c2
-rw-r--r--arch/arm/mach-mx3/mach-mx35_3ds.c53
-rw-r--r--arch/arm/mach-mx3/mach-pcm037.c2
-rw-r--r--arch/arm/mach-mx3/mach-pcm037_eet.c3
-rw-r--r--arch/arm/mach-mx3/mach-pcm043.c17
-rw-r--r--arch/arm/mach-mx3/mach-qong.c2
-rw-r--r--arch/arm/mach-mx3/mm.c18
-rw-r--r--arch/arm/mach-mx5/Kconfig42
-rw-r--r--arch/arm/mach-mx5/Makefile3
-rw-r--r--arch/arm/mach-mx5/board-cpuimx51.c25
-rw-r--r--arch/arm/mach-mx5/board-cpuimx51sd.c331
-rw-r--r--arch/arm/mach-mx5/board-mx51_3ds.c44
-rw-r--r--arch/arm/mach-mx5/board-mx51_babbage.c74
-rw-r--r--arch/arm/mach-mx5/board-mx51_efikamx.c119
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c391
-rw-r--r--arch/arm/mach-mx5/cpu.c19
-rw-r--r--arch/arm/mach-mx5/devices-imx51.h42
-rw-r--r--arch/arm/mach-mx5/devices.c114
-rw-r--r--arch/arm/mach-mx5/devices.h6
-rw-r--r--arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c30
-rw-r--r--arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c166
-rw-r--r--arch/arm/mach-mxc91231/magx-zn5.c2
-rw-r--r--arch/arm/mach-netx/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-netx/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-netx/nxdb500.c2
-rw-r--r--arch/arm/mach-netx/nxdkn.c2
-rw-r--r--arch/arm/mach-netx/nxeb500hmi.c2
-rw-r--r--arch/arm/mach-nomadik/board-nhk8815.c2
-rw-r--r--arch/arm/mach-nomadik/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-ns9xxx/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-nuc93x/mach-nuc932evb.c2
-rw-r--r--arch/arm/mach-omap1/Kconfig2
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c2
-rw-r--r--arch/arm/mach-omap1/board-fsample.c2
-rw-r--r--arch/arm/mach-omap1/board-generic.c2
-rw-r--r--arch/arm/mach-omap1/board-h2.c2
-rw-r--r--arch/arm/mach-omap1/board-h3.c2
-rw-r--r--arch/arm/mach-omap1/board-htcherald.c2
-rw-r--r--arch/arm/mach-omap1/board-innovator.c2
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c2
-rw-r--r--arch/arm/mach-omap1/board-osk.c2
-rw-r--r--arch/arm/mach-omap1/board-palmte.c2
-rw-r--r--arch/arm/mach-omap1/board-palmtt.c2
-rw-r--r--arch/arm/mach-omap1/board-palmz71.c2
-rw-r--r--arch/arm/mach-omap1/board-perseus2.c2
-rw-r--r--arch/arm/mach-omap1/board-sx1.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c2
-rw-r--r--arch/arm/mach-omap1/include/mach/debug-macro.S68
-rw-r--r--arch/arm/mach-omap1/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3630sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-am3517evm.c32
-rw-r--r--arch/arm/mach-omap2/board-apollon.c2
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c2
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c2
-rw-r--r--arch/arm/mach-omap2/board-generic.c2
-rw-r--r--arch/arm/mach-omap2/board-h4.c2
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c2
-rw-r--r--arch/arm/mach-omap2/board-ldp.c2
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c6
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c4
-rw-r--r--arch/arm/mach-omap2/board-omap3stalker.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c2
-rw-r--r--arch/arm/mach-omap2/board-omap4panda.c2
-rw-r--r--arch/arm/mach-omap2/board-overo.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51.c2
-rw-r--r--arch/arm/mach-omap2/board-zoom-peripherals.c54
-rw-r--r--arch/arm/mach-omap2/board-zoom2.c2
-rw-r--r--arch/arm/mach-omap2/board-zoom3.c2
-rw-r--r--arch/arm/mach-omap2/clock2420_data.c2
-rw-r--r--arch/arm/mach-omap2/clock2430_data.c2
-rw-r--r--arch/arm/mach-omap2/clock3xxx_data.c2
-rw-r--r--arch/arm/mach-omap2/devices.c71
-rw-r--r--arch/arm/mach-omap2/hsmmc.h2
-rw-r--r--arch/arm/mach-omap2/include/mach/debug-macro.S127
-rw-r--r--arch/arm/mach-omap2/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-omap2/usb-musb.c4
-rw-r--r--arch/arm/mach-orion5x/d2net-setup.c4
-rw-r--r--arch/arm/mach-orion5x/db88f5281-setup.c2
-rw-r--r--arch/arm/mach-orion5x/dns323-setup.c2
-rw-r--r--arch/arm/mach-orion5x/edmini_v2-setup.c2
-rw-r--r--arch/arm/mach-orion5x/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-orion5x/kurobox_pro-setup.c4
-rw-r--r--arch/arm/mach-orion5x/ls_hgl-setup.c2
-rw-r--r--arch/arm/mach-orion5x/lsmini-setup.c2
-rw-r--r--arch/arm/mach-orion5x/mss2-setup.c2
-rw-r--r--arch/arm/mach-orion5x/mv2120-setup.c2
-rw-r--r--arch/arm/mach-orion5x/net2big-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5181l-ge-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f5182-setup.c2
-rw-r--r--arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c2
-rw-r--r--arch/arm/mach-orion5x/terastation_pro2-setup.c2
-rw-r--r--arch/arm/mach-orion5x/ts209-setup.c2
-rw-r--r--arch/arm/mach-orion5x/ts409-setup.c2
-rw-r--r--arch/arm/mach-orion5x/ts78xx-setup.c2
-rw-r--r--arch/arm/mach-orion5x/wnr854t-setup.c2
-rw-r--r--arch/arm/mach-orion5x/wrt350n-v2-setup.c2
-rw-r--r--arch/arm/mach-pnx4008/core.c2
-rw-r--r--arch/arm/mach-pnx4008/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-pnx4008/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-pxa/Kconfig27
-rw-r--r--arch/arm/mach-pxa/Makefile3
-rw-r--r--arch/arm/mach-pxa/balloon3.c107
-rw-r--r--arch/arm/mach-pxa/capc7117.c2
-rw-r--r--arch/arm/mach-pxa/cm-x2xx.c6
-rw-r--r--arch/arm/mach-pxa/cm-x300.c79
-rw-r--r--arch/arm/mach-pxa/colibri-pxa270.c4
-rw-r--r--arch/arm/mach-pxa/colibri-pxa300.c2
-rw-r--r--arch/arm/mach-pxa/colibri-pxa320.c2
-rw-r--r--arch/arm/mach-pxa/corgi.c6
-rw-r--r--arch/arm/mach-pxa/cpufreq-pxa3xx.c5
-rw-r--r--arch/arm/mach-pxa/csb726.c2
-rw-r--r--arch/arm/mach-pxa/devices.c30
-rw-r--r--arch/arm/mach-pxa/devices.h1
-rw-r--r--arch/arm/mach-pxa/em-x270.c6
-rw-r--r--arch/arm/mach-pxa/eseries.c19
-rw-r--r--arch/arm/mach-pxa/ezx.c22
-rw-r--r--arch/arm/mach-pxa/generic.c6
-rw-r--r--arch/arm/mach-pxa/generic.h2
-rw-r--r--arch/arm/mach-pxa/gumstix.c2
-rw-r--r--arch/arm/mach-pxa/h5000.c2
-rw-r--r--arch/arm/mach-pxa/himalaya.c2
-rw-r--r--arch/arm/mach-pxa/hx4700.c3
-rw-r--r--arch/arm/mach-pxa/icontrol.c2
-rw-r--r--arch/arm/mach-pxa/idp.c2
-rw-r--r--arch/arm/mach-pxa/include/mach/balloon3.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-pxa/include/mach/eseries-irq.h1
-rw-r--r--arch/arm/mach-pxa/include/mach/hx4700.h1
-rw-r--r--arch/arm/mach-pxa/include/mach/irqs.h42
-rw-r--r--arch/arm/mach-pxa/include/mach/littleton.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/lpd270.h1
-rw-r--r--arch/arm/mach-pxa/include/mach/lubbock.h3
-rw-r--r--arch/arm/mach-pxa/include/mach/magician.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/mainstone.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/mfp-pxa930.h7
-rw-r--r--arch/arm/mach-pxa/include/mach/pcm027.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/poodle.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h35
-rw-r--r--arch/arm/mach-pxa/include/mach/tosa.h1
-rw-r--r--arch/arm/mach-pxa/include/mach/zeus.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/zylonite.h2
-rw-r--r--arch/arm/mach-pxa/littleton.c5
-rw-r--r--arch/arm/mach-pxa/lpd270.c3
-rw-r--r--arch/arm/mach-pxa/lubbock.c5
-rw-r--r--arch/arm/mach-pxa/magician.c3
-rw-r--r--arch/arm/mach-pxa/mainstone.c5
-rw-r--r--arch/arm/mach-pxa/mioa701.c4
-rw-r--r--arch/arm/mach-pxa/mp900.c2
-rw-r--r--arch/arm/mach-pxa/palmld.c4
-rw-r--r--arch/arm/mach-pxa/palmt5.c4
-rw-r--r--arch/arm/mach-pxa/palmtc.c2
-rw-r--r--arch/arm/mach-pxa/palmte2.c2
-rw-r--r--arch/arm/mach-pxa/palmtreo.c6
-rw-r--r--arch/arm/mach-pxa/palmtx.c4
-rw-r--r--arch/arm/mach-pxa/palmz72.c4
-rw-r--r--arch/arm/mach-pxa/pcm027.c3
-rw-r--r--arch/arm/mach-pxa/poodle.c3
-rw-r--r--arch/arm/mach-pxa/pxa3xx-ulpi.c400
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c19
-rw-r--r--arch/arm/mach-pxa/pxa930.c2
-rw-r--r--arch/arm/mach-pxa/raumfeld.c6
-rw-r--r--arch/arm/mach-pxa/saar.c2
-rw-r--r--arch/arm/mach-pxa/spitz.c6
-rw-r--r--arch/arm/mach-pxa/stargate2.c7
-rw-r--r--arch/arm/mach-pxa/tavorevb.c4
-rw-r--r--arch/arm/mach-pxa/tavorevb3.c135
-rw-r--r--arch/arm/mach-pxa/tosa.c3
-rw-r--r--arch/arm/mach-pxa/trizeps4.c4
-rw-r--r--arch/arm/mach-pxa/viper.c2
-rw-r--r--arch/arm/mach-pxa/vpac270.c2
-rw-r--r--arch/arm/mach-pxa/xcep.c2
-rw-r--r--arch/arm/mach-pxa/z2.c4
-rw-r--r--arch/arm/mach-pxa/zeus.c3
-rw-r--r--arch/arm/mach-pxa/zylonite.c5
-rw-r--r--arch/arm/mach-realview/core.c2
-rw-r--r--arch/arm/mach-realview/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-realview/include/mach/smp.h10
-rw-r--r--arch/arm/mach-realview/realview_eb.c2
-rw-r--r--arch/arm/mach-realview/realview_pb1176.c2
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c2
-rw-r--r--arch/arm/mach-realview/realview_pba8.c2
-rw-r--r--arch/arm/mach-realview/realview_pbx.c2
-rw-r--r--arch/arm/mach-rpc/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-rpc/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-rpc/riscpc.c2
-rw-r--r--arch/arm/mach-s3c2410/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s3c2410/mach-amlm5900.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-n30.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-otom.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-qt2410.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-tct_hammer.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c2
-rw-r--r--arch/arm/mach-s3c2412/mach-jive.c2
-rw-r--r--arch/arm/mach-s3c2412/mach-smdk2413.c6
-rw-r--r--arch/arm/mach-s3c2412/mach-vstms.c2
-rw-r--r--arch/arm/mach-s3c2416/mach-smdk2416.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-anubis.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-at2440evb.c4
-rw-r--r--arch/arm/mach-s3c2440/mach-gta02.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-mini2440.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-nexcoder.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-osiris.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-rx1950.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-rx3715.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-smdk2440.c2
-rw-r--r--arch/arm/mach-s3c2443/mach-smdk2443.c2
-rw-r--r--arch/arm/mach-s3c24a0/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s3c64xx/mach-anw6410.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-hmt.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-ncp.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-real6410.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq5.c4
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq7.c4
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6400.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c2
-rw-r--r--arch/arm/mach-s5p6440/Kconfig33
-rw-r--r--arch/arm/mach-s5p6440/Makefile25
-rw-r--r--arch/arm/mach-s5p6440/clock.c846
-rw-r--r--arch/arm/mach-s5p6440/cpu.c116
-rw-r--r--arch/arm/mach-s5p6440/dev-audio.c127
-rw-r--r--arch/arm/mach-s5p6440/dev-spi.c176
-rw-r--r--arch/arm/mach-s5p6440/include/mach/debug-macro.S37
-rw-r--r--arch/arm/mach-s5p6440/include/mach/gpio.h80
-rw-r--r--arch/arm/mach-s5p6440/include/mach/io.h18
-rw-r--r--arch/arm/mach-s5p6440/include/mach/map.h86
-rw-r--r--arch/arm/mach-s5p6440/include/mach/regs-clock.h130
-rw-r--r--arch/arm/mach-s5p6440/include/mach/spi-clocks.h17
-rw-r--r--arch/arm/mach-s5p6440/include/mach/uncompress.h24
-rw-r--r--arch/arm/mach-s5p6440/init.c52
-rw-r--r--arch/arm/mach-s5p6442/cpu.c28
-rw-r--r--arch/arm/mach-s5p6442/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s5p6442/include/mach/map.h6
-rw-r--r--arch/arm/mach-s5p6442/mach-smdk6442.c2
-rw-r--r--arch/arm/mach-s5p64x0/Kconfig57
-rw-r--r--arch/arm/mach-s5p64x0/Makefile30
-rw-r--r--arch/arm/mach-s5p64x0/Makefile.boot (renamed from arch/arm/mach-s5p6440/Makefile.boot)0
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6440.c626
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6450.c655
-rw-r--r--arch/arm/mach-s5p64x0/clock.c253
-rw-r--r--arch/arm/mach-s5p64x0/cpu.c209
-rw-r--r--arch/arm/mach-s5p64x0/dev-audio.c164
-rw-r--r--arch/arm/mach-s5p64x0/dev-spi.c232
-rw-r--r--arch/arm/mach-s5p64x0/dma.c (renamed from arch/arm/mach-s5p6440/dma.c)86
-rw-r--r--arch/arm/mach-s5p64x0/gpio.c (renamed from arch/arm/mach-s5p6440/gpio.c)104
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/debug-macro.S33
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/dma.h (renamed from arch/arm/mach-s5p6440/include/mach/dma.h)0
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/entry-macro.S (renamed from arch/arm/mach-s5p6440/include/mach/entry-macro.S)8
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/gpio.h139
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/hardware.h (renamed from arch/arm/mach-s5p6440/include/mach/hardware.h)8
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/i2c.h17
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/io.h25
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/irqs.h (renamed from arch/arm/mach-s5p6440/include/mach/irqs.h)48
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/map.h83
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/memory.h (renamed from arch/arm/mach-s5p6440/include/mach/memory.h)12
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/pwm-clock.h (renamed from arch/arm/mach-s5p6440/include/mach/pwm-clock.h)10
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/regs-clock.h63
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/regs-gpio.h (renamed from arch/arm/mach-s5p6440/include/mach/regs-gpio.h)28
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/regs-irq.h (renamed from arch/arm/mach-s5p6440/include/mach/regs-irq.h)8
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h46
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/spi-clocks.h20
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/system.h (renamed from arch/arm/mach-s5p6440/include/mach/system.h)8
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/tick.h (renamed from arch/arm/mach-s5p6440/include/mach/tick.h)13
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/timex.h (renamed from arch/arm/mach-s5p6440/include/mach/timex.h)7
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/uncompress.h212
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/vmalloc.h (renamed from arch/arm/mach-s5p6440/include/mach/vmalloc.h)5
-rw-r--r--arch/arm/mach-s5p64x0/init.c73
-rw-r--r--arch/arm/mach-s5p64x0/mach-smdk6440.c (renamed from arch/arm/mach-s5p6440/mach-smdk6440.c)87
-rw-r--r--arch/arm/mach-s5p64x0/mach-smdk6450.c180
-rw-r--r--arch/arm/mach-s5p64x0/setup-i2c0.c (renamed from arch/arm/mach-s5p6440/setup-i2c0.c)24
-rw-r--r--arch/arm/mach-s5p64x0/setup-i2c1.c (renamed from arch/arm/mach-s5p6440/setup-i2c1.c)20
-rw-r--r--arch/arm/mach-s5pc100/cpu.c26
-rw-r--r--arch/arm/mach-s5pc100/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s5pc100/include/mach/map.h11
-rw-r--r--arch/arm/mach-s5pc100/mach-smdkc100.c2
-rw-r--r--arch/arm/mach-s5pv210/Kconfig9
-rw-r--r--arch/arm/mach-s5pv210/Makefile1
-rw-r--r--arch/arm/mach-s5pv210/clock.c5
-rw-r--r--arch/arm/mach-s5pv210/cpu.c23
-rw-r--r--arch/arm/mach-s5pv210/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s5pv210/include/mach/map.h11
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c4
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c4
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkc110.c2
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c2
-rw-r--r--arch/arm/mach-s5pv310/cpu.c26
-rw-r--r--arch/arm/mach-s5pv310/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-s5pv310/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-s5pv310/include/mach/map.h7
-rw-r--r--arch/arm/mach-s5pv310/include/mach/smp.h9
-rw-r--r--arch/arm/mach-s5pv310/mach-smdkv310.c2
-rw-r--r--arch/arm/mach-s5pv310/mach-universal_c210.c2
-rw-r--r--arch/arm/mach-sa1100/Kconfig6
-rw-r--r--arch/arm/mach-sa1100/assabet.c2
-rw-r--r--arch/arm/mach-sa1100/badge4.c2
-rw-r--r--arch/arm/mach-sa1100/cerf.c2
-rw-r--r--arch/arm/mach-sa1100/collie.c2
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c2
-rw-r--r--arch/arm/mach-sa1100/h3100.c2
-rw-r--r--arch/arm/mach-sa1100/h3600.c2
-rw-r--r--arch/arm/mach-sa1100/hackkit.c2
-rw-r--r--arch/arm/mach-sa1100/include/mach/debug-macro.S36
-rw-r--r--arch/arm/mach-sa1100/jornada720.c2
-rw-r--r--arch/arm/mach-sa1100/lart.c2
-rw-r--r--arch/arm/mach-sa1100/pleb.c2
-rw-r--r--arch/arm/mach-sa1100/shannon.c2
-rw-r--r--arch/arm/mach-sa1100/simpad.c2
-rw-r--r--arch/arm/mach-shark/core.c2
-rw-r--r--arch/arm/mach-shark/include/mach/debug-macro.S7
-rw-r--r--arch/arm/mach-shark/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c2
-rw-r--r--arch/arm/mach-shmobile/board-g3evm.c2
-rw-r--r--arch/arm/mach-shmobile/board-g4evm.c2
-rw-r--r--arch/arm/mach-stmp378x/stmp378x_devb.c2
-rw-r--r--arch/arm/mach-stmp37xx/stmp37xx_devb.c2
-rw-r--r--arch/arm/mach-tcc8k/Kconfig11
-rw-r--r--arch/arm/mach-tcc8k/Makefile9
-rw-r--r--arch/arm/mach-tcc8k/Makefile.boot3
-rw-r--r--arch/arm/mach-tcc8k/board-tcc8000-sdk.c62
-rw-r--r--arch/arm/mach-tcc8k/clock.c567
-rw-r--r--arch/arm/mach-tcc8k/common.h15
-rw-r--r--arch/arm/mach-tcc8k/devices.c239
-rw-r--r--arch/arm/mach-tcc8k/io.c62
-rw-r--r--arch/arm/mach-tcc8k/irq.c111
-rw-r--r--arch/arm/mach-tcc8k/time.c149
-rw-r--r--arch/arm/mach-tegra/board-harmony.c2
-rw-r--r--arch/arm/mach-tegra/include/mach/debug-macro.S26
-rw-r--r--arch/arm/mach-tegra/include/mach/smp.h10
-rw-r--r--arch/arm/mach-u300/dummyspichip.c5
-rw-r--r--arch/arm/mach-u300/include/mach/debug-macro.S11
-rw-r--r--arch/arm/mach-u300/spi.c10
-rw-r--r--arch/arm/mach-u300/u300.c2
-rw-r--r--arch/arm/mach-ux500/Kconfig18
-rw-r--r--arch/arm/mach-ux500/Makefile8
-rw-r--r--arch/arm/mach-ux500/board-mop500-regulators.c101
-rw-r--r--arch/arm/mach-ux500/board-mop500-sdi.c91
-rw-r--r--arch/arm/mach-ux500/board-mop500.c173
-rw-r--r--arch/arm/mach-ux500/board-mop500.h12
-rw-r--r--arch/arm/mach-ux500/board-u5500.c2
-rw-r--r--arch/arm/mach-ux500/clock.c1
-rw-r--r--arch/arm/mach-ux500/cpu-db5500.c88
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c82
-rw-r--r--arch/arm/mach-ux500/devices-db8500.c114
-rw-r--r--arch/arm/mach-ux500/hotplug.c75
-rw-r--r--arch/arm/mach-ux500/include/mach/db5500-regs.h14
-rw-r--r--arch/arm/mach-ux500/include/mach/db8500-regs.h2
-rw-r--r--arch/arm/mach-ux500/include/mach/debug-macro.S8
-rw-r--r--arch/arm/mach-ux500/include/mach/devices.h8
-rw-r--r--arch/arm/mach-ux500/include/mach/hardware.h23
-rw-r--r--arch/arm/mach-ux500/include/mach/irqs-db5500.h1
-rw-r--r--arch/arm/mach-ux500/include/mach/irqs.h18
-rw-r--r--arch/arm/mach-ux500/include/mach/mbox.h88
-rw-r--r--arch/arm/mach-ux500/include/mach/prcmu-regs.h91
-rw-r--r--arch/arm/mach-ux500/include/mach/prcmu.h15
-rw-r--r--arch/arm/mach-ux500/include/mach/setup.h7
-rw-r--r--arch/arm/mach-ux500/include/mach/smp.h9
-rw-r--r--arch/arm/mach-ux500/mbox.c567
-rw-r--r--arch/arm/mach-ux500/modem_irq.c139
-rw-r--r--arch/arm/mach-ux500/pins-db5500.h620
-rw-r--r--arch/arm/mach-ux500/pins-db8500.h98
-rw-r--r--arch/arm/mach-ux500/platsmp.c2
-rw-r--r--arch/arm/mach-ux500/prcmu.c231
-rw-r--r--arch/arm/mach-ux500/ste-dma40-db5500.h135
-rw-r--r--arch/arm/mach-ux500/ste-dma40-db8500.h258
-rw-r--r--arch/arm/mach-versatile/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-versatile/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-versatile/versatile_ab.c2
-rw-r--r--arch/arm/mach-versatile/versatile_pb.c2
-rw-r--r--arch/arm/mach-vexpress/ct-ca9x4.c6
-rw-r--r--arch/arm/mach-vexpress/include/mach/debug-macro.S10
-rw-r--r--arch/arm/mach-vexpress/include/mach/smp.h9
-rw-r--r--arch/arm/mach-vexpress/v2m.c2
-rw-r--r--arch/arm/mach-w90x900/mach-nuc910evb.c2
-rw-r--r--arch/arm/mach-w90x900/mach-nuc950evb.c2
-rw-r--r--arch/arm/mach-w90x900/mach-nuc960evb.c2
-rw-r--r--arch/arm/mm/cache-v6.S30
-rw-r--r--arch/arm/mm/cache-v7.S30
-rw-r--r--arch/arm/mm/copypage-v4mc.c2
-rw-r--r--arch/arm/mm/copypage-v6.c2
-rw-r--r--arch/arm/mm/copypage-xscale.c2
-rw-r--r--arch/arm/mm/dma-mapping.c6
-rw-r--r--arch/arm/mm/fault-armv.c8
-rw-r--r--arch/arm/mm/fault.c13
-rw-r--r--arch/arm/mm/flush.c69
-rw-r--r--arch/arm/mm/init.c41
-rw-r--r--arch/arm/mm/ioremap.c8
-rw-r--r--arch/arm/mm/mmap.c22
-rw-r--r--arch/arm/mm/mmu.c50
-rw-r--r--arch/arm/mm/proc-arm1020.S2
-rw-r--r--arch/arm/mm/proc-arm1020e.S2
-rw-r--r--arch/arm/mm/proc-arm1022.S2
-rw-r--r--arch/arm/mm/proc-arm1026.S2
-rw-r--r--arch/arm/mm/proc-arm6_7.S2
-rw-r--r--arch/arm/mm/proc-arm720.S2
-rw-r--r--arch/arm/mm/proc-arm740.S2
-rw-r--r--arch/arm/mm/proc-arm7tdmi.S2
-rw-r--r--arch/arm/mm/proc-arm920.S2
-rw-r--r--arch/arm/mm/proc-arm922.S2
-rw-r--r--arch/arm/mm/proc-arm925.S2
-rw-r--r--arch/arm/mm/proc-arm926.S2
-rw-r--r--arch/arm/mm/proc-arm940.S2
-rw-r--r--arch/arm/mm/proc-arm946.S2
-rw-r--r--arch/arm/mm/proc-arm9tdmi.S2
-rw-r--r--arch/arm/mm/proc-fa526.S2
-rw-r--r--arch/arm/mm/proc-feroceon.S2
-rw-r--r--arch/arm/mm/proc-mohawk.S2
-rw-r--r--arch/arm/mm/proc-sa110.S2
-rw-r--r--arch/arm/mm/proc-sa1100.S2
-rw-r--r--arch/arm/mm/proc-v6.S49
-rw-r--r--arch/arm/mm/proc-v7.S57
-rw-r--r--arch/arm/mm/proc-xsc3.S2
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/arm/mm/tlb-v7.S33
-rw-r--r--arch/arm/nwfpe/milieu.h4
-rw-r--r--arch/arm/nwfpe/softfloat-macros4
-rw-r--r--arch/arm/nwfpe/softfloat-specialize4
-rw-r--r--arch/arm/nwfpe/softfloat.c4
-rw-r--r--arch/arm/nwfpe/softfloat.h4
-rw-r--r--arch/arm/oprofile/Makefile4
-rw-r--r--arch/arm/oprofile/common.c308
-rw-r--r--arch/arm/plat-mxc/Kconfig16
-rw-r--r--arch/arm/plat-mxc/Makefile2
-rw-r--r--arch/arm/plat-mxc/audmux-v2.c9
-rw-r--r--arch/arm/plat-mxc/devices/Kconfig10
-rw-r--r--arch/arm/plat-mxc/devices/Makefile9
-rw-r--r--arch/arm/plat-mxc/devices/platform-esdhc.c71
-rw-r--r--arch/arm/plat-mxc/devices/platform-fec.c58
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-dma.c129
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-i2c.c85
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-ssi.c107
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-uart.c137
-rw-r--r--arch/arm/plat-mxc/devices/platform-mxc_nand.c85
-rw-r--r--arch/arm/plat-mxc/devices/platform-spi_imx.c89
-rw-r--r--arch/arm/plat-mxc/ehci.c4
-rw-r--r--arch/arm/plat-mxc/epit.c242
-rw-r--r--arch/arm/plat-mxc/gpio.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx31ads.h33
-rw-r--r--arch/arm/plat-mxc/include/mach/common.h1
-rw-r--r--arch/arm/plat-mxc/include/mach/debug-macro.S8
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h112
-rw-r--r--arch/arm/plat-mxc/include/mach/esdhc.h16
-rw-r--r--arch/arm/plat-mxc/include/mach/eukrea-baseboards.h5
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx51.h120
-rw-r--r--arch/arm/plat-mxc/include/mach/iram.h41
-rw-r--r--arch/arm/plat-mxc/include/mach/mx21.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/mx25.h17
-rw-r--r--arch/arm/plat-mxc/include/mach/mx27.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/mx31.h11
-rw-r--r--arch/arm/plat-mxc/include/mach/mx35.h38
-rw-r--r--arch/arm/plat-mxc/include/mach/mx3x.h23
-rw-r--r--arch/arm/plat-mxc/include/mach/mx51.h657
-rw-r--r--arch/arm/plat-mxc/include/mach/system.h32
-rw-r--r--arch/arm/plat-mxc/include/mach/uncompress.h1
-rw-r--r--arch/arm/plat-mxc/iram_alloc.c73
-rw-r--r--arch/arm/plat-nomadik/gpio.c74
-rw-r--r--arch/arm/plat-nomadik/include/plat/gpio.h2
-rw-r--r--arch/arm/plat-nomadik/include/plat/pincfg.h36
-rw-r--r--arch/arm/plat-nomadik/include/plat/ske.h50
-rw-r--r--arch/arm/plat-omap/Kconfig2
-rw-r--r--arch/arm/plat-omap/fb.c6
-rw-r--r--arch/arm/plat-omap/include/plat/omap4-keypad.h14
-rw-r--r--arch/arm/plat-omap/include/plat/smp.h12
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h21
-rw-r--r--arch/arm/plat-omap/iommu-debug.c2
-rw-r--r--arch/arm/plat-omap/iommu.c1
-rw-r--r--arch/arm/plat-omap/mcbsp.c2
-rw-r--r--arch/arm/plat-pxa/include/plat/pxa27x_keypad.h (renamed from arch/arm/mach-pxa/include/mach/pxa27x_keypad.h)10
-rw-r--r--arch/arm/plat-s5p/Kconfig9
-rw-r--r--arch/arm/plat-s5p/Makefile1
-rw-r--r--arch/arm/plat-s5p/clock.c19
-rw-r--r--arch/arm/plat-s5p/cpu.c34
-rw-r--r--arch/arm/plat-s5p/dev-onenand.c (renamed from arch/arm/mach-s5pv210/dev-onenand.c)28
-rw-r--r--arch/arm/plat-s5p/dev-uart.c58
-rw-r--r--arch/arm/plat-s5p/include/plat/pll.h7
-rw-r--r--arch/arm/plat-s5p/include/plat/s5p-clock.h8
-rw-r--r--arch/arm/plat-s5p/include/plat/s5p6440.h7
-rw-r--r--arch/arm/plat-s5p/include/plat/s5p6450.h36
-rw-r--r--arch/arm/plat-samsung/adc.c1
-rw-r--r--arch/arm/plat-samsung/clock.c27
-rw-r--r--arch/arm/plat-samsung/include/plat/adc.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/cpu.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/devs.h7
-rw-r--r--arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h20
-rw-r--r--arch/arm/plat-samsung/include/plat/s3c64xx-spi.h5
-rw-r--r--arch/arm/plat-spear/include/plat/debug-macro.S8
-rw-r--r--arch/arm/plat-stmp3xxx/include/mach/debug-macro.S11
-rw-r--r--arch/arm/plat-tcc/Kconfig20
-rw-r--r--arch/arm/plat-tcc/Makefile3
-rw-r--r--arch/arm/plat-tcc/clock.c179
-rw-r--r--arch/arm/plat-tcc/include/mach/clkdev.h7
-rw-r--r--arch/arm/plat-tcc/include/mach/clock.h48
-rw-r--r--arch/arm/plat-tcc/include/mach/debug-macro.S32
-rw-r--r--arch/arm/plat-tcc/include/mach/entry-macro.S68
-rw-r--r--arch/arm/plat-tcc/include/mach/hardware.h43
-rw-r--r--arch/arm/plat-tcc/include/mach/io.h23
-rw-r--r--arch/arm/plat-tcc/include/mach/irqs.h83
-rw-r--r--arch/arm/plat-tcc/include/mach/memory.h18
-rw-r--r--arch/arm/plat-tcc/include/mach/system.h31
-rw-r--r--arch/arm/plat-tcc/include/mach/tcc8k-regs.h807
-rw-r--r--arch/arm/plat-tcc/include/mach/timex.h5
-rw-r--r--arch/arm/plat-tcc/include/mach/uncompress.h34
-rw-r--r--arch/arm/plat-tcc/include/mach/vmalloc.h10
-rw-r--r--arch/arm/plat-tcc/system.c25
-rw-r--r--arch/avr32/Kconfig3
-rw-r--r--arch/avr32/boards/mimc200/fram.c1
-rw-r--r--arch/avr32/include/asm/ioctls.h86
-rw-r--r--arch/avr32/include/asm/irqflags.h29
-rw-r--r--arch/avr32/kernel/module.c3
-rw-r--r--arch/blackfin/Kconfig12
-rw-r--r--arch/blackfin/Makefile3
-rw-r--r--arch/blackfin/configs/BF527-AD7160-EVAL_defconfig105
-rw-r--r--arch/blackfin/configs/BF527-TLL6527M_defconfig180
-rw-r--r--arch/blackfin/include/asm/Kbuild1
-rw-r--r--arch/blackfin/include/asm/bfin5xx_spi.h96
-rw-r--r--arch/blackfin/include/asm/bfin_can.h9
-rw-r--r--arch/blackfin/include/asm/bfin_ppi.h51
-rw-r--r--arch/blackfin/include/asm/cachectl.h20
-rw-r--r--arch/blackfin/include/asm/cdef_LPBlackfin.h9
-rw-r--r--arch/blackfin/include/asm/ipipe.h8
-rw-r--r--arch/blackfin/include/asm/irqflags.h273
-rw-r--r--arch/blackfin/include/asm/mmu_context.h8
-rw-r--r--arch/blackfin/include/asm/ptrace.h3
-rw-r--r--arch/blackfin/include/asm/serial.h1
-rw-r--r--arch/blackfin/include/asm/system.h4
-rw-r--r--arch/blackfin/include/asm/unistd.h3
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c287
-rw-r--r--arch/blackfin/kernel/cplb-mpu/cplbmgr.c8
-rw-r--r--arch/blackfin/kernel/ipipe.c38
-rw-r--r--arch/blackfin/kernel/kgdb_test.c1
-rw-r--r--arch/blackfin/kernel/process.c9
-rw-r--r--arch/blackfin/kernel/ptrace.c12
-rw-r--r--arch/blackfin/kernel/sys_bfin.c15
-rw-r--r--arch/blackfin/kernel/trace.c1
-rw-r--r--arch/blackfin/mach-bf518/boards/ezbrd.c21
-rw-r--r--arch/blackfin/mach-bf518/boards/tcm-bf518.c2
-rw-r--r--arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h82
-rw-r--r--arch/blackfin/mach-bf518/include/mach/defBF51x_base.h45
-rw-r--r--arch/blackfin/mach-bf518/include/mach/pll.h63
-rw-r--r--arch/blackfin/mach-bf527/boards/Kconfig10
-rw-r--r--arch/blackfin/mach-bf527/boards/Makefile2
-rw-r--r--arch/blackfin/mach-bf527/boards/ad7160eval.c870
-rw-r--r--arch/blackfin/mach-bf527/boards/cm_bf527.c12
-rw-r--r--arch/blackfin/mach-bf527/boards/ezbrd.c6
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c25
-rw-r--r--arch/blackfin/mach-bf527/boards/tll6527m.c986
-rw-r--r--arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h82
-rw-r--r--arch/blackfin/mach-bf527/include/mach/defBF52x_base.h45
-rw-r--r--arch/blackfin/mach-bf527/include/mach/pll.h63
-rw-r--r--arch/blackfin/mach-bf533/boards/H8606.c10
-rw-r--r--arch/blackfin/mach-bf533/boards/blackstamp.c5
-rw-r--r--arch/blackfin/mach-bf533/boards/cm_bf533.c10
-rw-r--r--arch/blackfin/mach-bf533/boards/ezkit.c12
-rw-r--r--arch/blackfin/mach-bf533/boards/ip0x.c3
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c20
-rw-r--r--arch/blackfin/mach-bf533/include/mach/cdefBF532.h91
-rw-r--r--arch/blackfin/mach-bf533/include/mach/defBF532.h70
-rw-r--r--arch/blackfin/mach-bf533/include/mach/fio_flag.h55
-rw-r--r--arch/blackfin/mach-bf533/include/mach/pll.h57
-rw-r--r--arch/blackfin/mach-bf537/Kconfig4
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537e.c10
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537u.c10
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c12
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c599
-rw-r--r--arch/blackfin/mach-bf537/boards/tcm_bf537.c10
-rw-r--r--arch/blackfin/mach-bf537/include/mach/cdefBF534.h44
-rw-r--r--arch/blackfin/mach-bf537/include/mach/defBF534.h44
-rw-r--r--arch/blackfin/mach-bf537/include/mach/pll.h57
-rw-r--r--arch/blackfin/mach-bf538/boards/ezkit.c4
-rw-r--r--arch/blackfin/mach-bf538/include/mach/cdefBF538.h50
-rw-r--r--arch/blackfin/mach-bf538/include/mach/defBF539.h73
-rw-r--r--arch/blackfin/mach-bf538/include/mach/pll.h63
-rw-r--r--arch/blackfin/mach-bf548/boards/cm_bf548.c47
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c31
-rw-r--r--arch/blackfin/mach-bf548/dma.c1
-rw-r--r--arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h58
-rw-r--r--arch/blackfin/mach-bf548/include/mach/defBF54x_base.h51
-rw-r--r--arch/blackfin/mach-bf548/include/mach/pll.h69
-rw-r--r--arch/blackfin/mach-bf561/boards/acvilon.c2
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c10
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c68
-rw-r--r--arch/blackfin/mach-bf561/coreb.c12
-rw-r--r--arch/blackfin/mach-bf561/include/mach/blackfin.h33
-rw-r--r--arch/blackfin/mach-bf561/include/mach/cdefBF561.h126
-rw-r--r--arch/blackfin/mach-bf561/include/mach/defBF561.h94
-rw-r--r--arch/blackfin/mach-bf561/include/mach/pll.h63
-rw-r--r--arch/blackfin/mach-bf561/ints-priority.c16
-rw-r--r--arch/blackfin/mach-bf561/smp.c24
-rw-r--r--arch/blackfin/mach-common/cpufreq.c4
-rw-r--r--arch/blackfin/mach-common/dpmc_modes.S50
-rw-r--r--arch/blackfin/mach-common/entry.S113
-rw-r--r--arch/blackfin/mach-common/interrupt.S17
-rw-r--r--arch/blackfin/mach-common/ints-priority.c35
-rw-r--r--arch/blackfin/mach-common/pm.c10
-rw-r--r--arch/blackfin/mm/init.c3
-rw-r--r--arch/cris/arch-v10/drivers/ds1302.c8
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c1
-rw-r--r--arch/cris/arch-v10/drivers/i2c.c1
-rw-r--r--arch/cris/arch-v10/drivers/pcf8563.c7
-rw-r--r--arch/cris/arch-v10/drivers/sync_serial.c14
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c7
-rw-r--r--arch/cris/arch-v32/drivers/i2c.c1
-rw-r--r--arch/cris/arch-v32/drivers/mach-a3/gpio.c12
-rw-r--r--arch/cris/arch-v32/drivers/mach-fs/gpio.c12
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c7
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c14
-rw-r--r--arch/cris/include/arch-v10/arch/irqflags.h45
-rw-r--r--arch/cris/include/arch-v10/arch/system.h16
-rw-r--r--arch/cris/include/arch-v32/arch/irqflags.h46
-rw-r--r--arch/cris/include/arch-v32/arch/system.h22
-rw-r--r--arch/cris/include/asm/ioctls.h84
-rw-r--r--arch/cris/include/asm/irqflags.h1
-rw-r--r--arch/cris/include/asm/system.h1
-rw-r--r--arch/cris/kernel/profile.c1
-rw-r--r--arch/frv/Kconfig1
-rw-r--r--arch/frv/include/asm/ioctls.h80
-rw-r--r--arch/frv/include/asm/irqflags.h158
-rw-r--r--arch/frv/include/asm/system.h136
-rw-r--r--arch/frv/lib/Makefile2
-rw-r--r--arch/frv/lib/perf_event.c19
-rw-r--r--arch/h8300/Kconfig.cpu8
-rw-r--r--arch/h8300/README1
-rw-r--r--arch/h8300/include/asm/ioctls.h81
-rw-r--r--arch/h8300/include/asm/irqflags.h43
-rw-r--r--arch/h8300/include/asm/system.h24
-rw-r--r--arch/h8300/kernel/module.c3
-rw-r--r--arch/ia64/Kconfig12
-rw-r--r--arch/ia64/hp/sim/simserial.c12
-rw-r--r--arch/ia64/include/asm/compat.h208
-rw-r--r--arch/ia64/include/asm/hardirq.h11
-rw-r--r--arch/ia64/include/asm/ioctls.h89
-rw-r--r--arch/ia64/include/asm/iommu_table.h6
-rw-r--r--arch/ia64/include/asm/irqflags.h94
-rw-r--r--arch/ia64/include/asm/system.h80
-rw-r--r--arch/ia64/kernel/Makefile1
-rw-r--r--arch/ia64/kernel/cyclone.c2
-rw-r--r--arch/ia64/kernel/iosapic.c60
-rw-r--r--arch/ia64/kernel/irq_ia64.c5
-rw-r--r--arch/ia64/kernel/mca.c38
-rw-r--r--arch/ia64/kernel/msi_ia64.c8
-rw-r--r--arch/ia64/kernel/palinfo.c2
-rw-r--r--arch/ia64/kernel/perfmon.c12
-rw-r--r--arch/ia64/kernel/salinfo.c4
-rw-r--r--arch/ia64/kernel/setup.c4
-rw-r--r--arch/ia64/kernel/stacktrace.c39
-rw-r--r--arch/ia64/kernel/unwind.c23
-rw-r--r--arch/ia64/kvm/lapic.h1
-rw-r--r--arch/ia64/sn/kernel/msi_sn.c4
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c1
-rw-r--r--arch/ia64/xen/xen_pv_ops.c5
-rw-r--r--arch/m32r/Kconfig2
-rw-r--r--arch/m32r/include/asm/elf.h4
-rw-r--r--arch/m32r/include/asm/ioctls.h83
-rw-r--r--arch/m32r/include/asm/irqflags.h104
-rw-r--r--arch/m32r/include/asm/system.h66
-rw-r--r--arch/m32r/kernel/.gitignore1
-rw-r--r--arch/m32r/kernel/irq.c2
-rw-r--r--arch/m32r/kernel/signal.c4
-rw-r--r--arch/m32r/platforms/m32104ut/setup.c2
-rw-r--r--arch/m32r/platforms/m32700ut/setup.c8
-rw-r--r--arch/m32r/platforms/mappi/setup.c2
-rw-r--r--arch/m32r/platforms/mappi2/setup.c2
-rw-r--r--arch/m32r/platforms/mappi3/setup.c2
-rw-r--r--arch/m32r/platforms/oaks32r/setup.c2
-rw-r--r--arch/m32r/platforms/opsput/setup.c6
-rw-r--r--arch/m32r/platforms/usrv/setup.c4
-rw-r--r--arch/m68k/Kconfig4
-rw-r--r--arch/m68k/bvme6000/rtc.c1
-rw-r--r--arch/m68k/include/asm/amigahw.h1
-rw-r--r--arch/m68k/include/asm/atomic.h210
-rw-r--r--arch/m68k/include/asm/atomic_mm.h200
-rw-r--r--arch/m68k/include/asm/atomic_no.h155
-rw-r--r--arch/m68k/include/asm/cacheflush_no.h2
-rw-r--r--arch/m68k/include/asm/coldfire.h4
-rw-r--r--arch/m68k/include/asm/entry_mm.h3
-rw-r--r--arch/m68k/include/asm/entry_no.h2
-rw-r--r--arch/m68k/include/asm/gpio.h7
-rw-r--r--arch/m68k/include/asm/io_mm.h43
-rw-r--r--arch/m68k/include/asm/ioctls.h80
-rw-r--r--arch/m68k/include/asm/irqflags.h76
-rw-r--r--arch/m68k/include/asm/m548xgpt.h88
-rw-r--r--arch/m68k/include/asm/m548xsim.h55
-rw-r--r--arch/m68k/include/asm/machdep.h49
-rw-r--r--arch/m68k/include/asm/machdep_mm.h35
-rw-r--r--arch/m68k/include/asm/machdep_no.h26
-rw-r--r--arch/m68k/include/asm/mcfcache.h2
-rw-r--r--arch/m68k/include/asm/mcfsim.h2
-rw-r--r--arch/m68k/include/asm/mcfslt.h44
-rw-r--r--arch/m68k/include/asm/mcfuart.h9
-rw-r--r--arch/m68k/include/asm/page.h48
-rw-r--r--arch/m68k/include/asm/page_mm.h57
-rw-r--r--arch/m68k/include/asm/page_no.h51
-rw-r--r--arch/m68k/include/asm/string.h134
-rw-r--r--arch/m68k/include/asm/string_mm.h131
-rw-r--r--arch/m68k/include/asm/string_no.h126
-rw-r--r--arch/m68k/include/asm/system_mm.h27
-rw-r--r--arch/m68k/include/asm/system_no.h66
-rw-r--r--arch/m68k/include/asm/thread_info.h109
-rw-r--r--arch/m68k/include/asm/thread_info_mm.h71
-rw-r--r--arch/m68k/include/asm/thread_info_no.h102
-rw-r--r--arch/m68k/include/asm/traps.h275
-rw-r--r--arch/m68k/include/asm/traps_mm.h272
-rw-r--r--arch/m68k/include/asm/traps_no.h154
-rw-r--r--arch/m68k/kernel/asm-offsets.c12
-rw-r--r--arch/m68k/kernel/setup.c6
-rw-r--r--arch/m68k/kernel/sys_m68k.c3
-rw-r--r--arch/m68k/kernel/time.c2
-rw-r--r--arch/m68k/mac/macboing.c9
-rw-r--r--arch/m68k/mvme16x/rtc.c1
-rw-r--r--arch/m68k/q40/README2
-rw-r--r--arch/m68k/sun3/sun3ints.c2
-rw-r--r--arch/m68knommu/Kconfig11
-rw-r--r--arch/m68knommu/Makefile3
-rw-r--r--arch/m68knommu/kernel/.gitignore1
-rw-r--r--arch/m68knommu/kernel/asm-offsets.c13
-rw-r--r--arch/m68knommu/kernel/ptrace.c47
-rw-r--r--arch/m68knommu/kernel/setup.c3
-rw-r--r--arch/m68knommu/kernel/time.c16
-rw-r--r--arch/m68knommu/kernel/traps.c26
-rw-r--r--arch/m68knommu/platform/5206/Makefile4
-rw-r--r--arch/m68knommu/platform/5206e/Makefile4
-rw-r--r--arch/m68knommu/platform/520x/Makefile4
-rw-r--r--arch/m68knommu/platform/523x/Makefile4
-rw-r--r--arch/m68knommu/platform/5249/Makefile4
-rw-r--r--arch/m68knommu/platform/5272/Makefile4
-rw-r--r--arch/m68knommu/platform/5272/config.c16
-rw-r--r--arch/m68knommu/platform/5272/intc.c60
-rw-r--r--arch/m68knommu/platform/527x/Makefile4
-rw-r--r--arch/m68knommu/platform/528x/Makefile4
-rw-r--r--arch/m68knommu/platform/5307/Makefile4
-rw-r--r--arch/m68knommu/platform/532x/Makefile4
-rw-r--r--arch/m68knommu/platform/5407/Makefile4
-rw-r--r--arch/m68knommu/platform/548x/Makefile18
-rw-r--r--arch/m68knommu/platform/548x/config.c115
-rw-r--r--arch/m68knommu/platform/68328/entry.S36
-rw-r--r--arch/m68knommu/platform/68328/head-de2.S6
-rw-r--r--arch/m68knommu/platform/68328/head-ram.S27
-rw-r--r--arch/m68knommu/platform/68328/ints.c6
-rw-r--r--arch/m68knommu/platform/68360/entry.S13
-rw-r--r--arch/m68knommu/platform/68360/ints.c6
-rw-r--r--arch/m68knommu/platform/68VZ328/config.c5
-rw-r--r--arch/m68knommu/platform/coldfire/Makefile5
-rw-r--r--arch/m68knommu/platform/coldfire/entry.S8
-rw-r--r--arch/m68knommu/platform/coldfire/head.S1
-rw-r--r--arch/m68knommu/platform/coldfire/intc-2.c53
-rw-r--r--arch/m68knommu/platform/coldfire/intc-simr.c10
-rw-r--r--arch/m68knommu/platform/coldfire/intc.c8
-rw-r--r--arch/m68knommu/platform/coldfire/sltimers.c145
-rw-r--r--arch/microblaze/include/asm/irqflags.h193
-rw-r--r--arch/microblaze/include/asm/memblock.h3
-rw-r--r--arch/microblaze/kernel/prom.c5
-rw-r--r--arch/microblaze/mm/init.c30
-rw-r--r--arch/mips/Kbuild4
-rw-r--r--arch/mips/Kconfig44
-rw-r--r--arch/mips/alchemy/common/platform.c28
-rw-r--r--arch/mips/alchemy/common/power.c35
-rw-r--r--arch/mips/alchemy/common/prom.c5
-rw-r--r--arch/mips/alchemy/devboards/bcsr.c1
-rw-r--r--arch/mips/ar7/irq.c1
-rw-r--r--arch/mips/bcm63xx/irq.c1
-rw-r--r--arch/mips/boot/compressed/Makefile4
-rw-r--r--arch/mips/cavium-octeon/Kconfig4
-rw-r--r--arch/mips/cavium-octeon/cpu.c2
-rw-r--r--arch/mips/cavium-octeon/executive/Makefile2
-rw-r--r--arch/mips/cavium-octeon/serial.c1
-rw-r--r--arch/mips/dec/Platform2
-rw-r--r--arch/mips/dec/setup.c1
-rw-r--r--arch/mips/include/asm/atomic.h4
-rw-r--r--arch/mips/include/asm/cop2.h2
-rw-r--r--arch/mips/include/asm/fcntl.h1
-rw-r--r--arch/mips/include/asm/gic.h1
-rw-r--r--arch/mips/include/asm/irq.h5
-rw-r--r--arch/mips/include/asm/irqflags.h53
-rw-r--r--arch/mips/include/asm/mach-loongson/loongson.h1
-rw-r--r--arch/mips/include/asm/mach-tx49xx/kmalloc.h2
-rw-r--r--arch/mips/include/asm/mips-boards/maltaint.h3
-rw-r--r--arch/mips/include/asm/page.h14
-rw-r--r--arch/mips/include/asm/prom.h31
-rw-r--r--arch/mips/include/asm/siginfo.h1
-rw-r--r--arch/mips/include/asm/thread_info.h3
-rw-r--r--arch/mips/include/asm/unistd.h21
-rw-r--r--arch/mips/jazz/irq.c1
-rw-r--r--arch/mips/jz4740/Platform2
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/branch.c1
-rw-r--r--arch/mips/kernel/cevt-bcm1480.c1
-rw-r--r--arch/mips/kernel/cevt-ds1287.c1
-rw-r--r--arch/mips/kernel/cevt-gt641xx.c1
-rw-r--r--arch/mips/kernel/cevt-r4k.c1
-rw-r--r--arch/mips/kernel/cevt-sb1250.c1
-rw-r--r--arch/mips/kernel/cevt-smtc.c1
-rw-r--r--arch/mips/kernel/cevt-txx9.c1
-rw-r--r--arch/mips/kernel/i8253.c1
-rw-r--r--arch/mips/kernel/i8259.c1
-rw-r--r--arch/mips/kernel/irq-gic.c7
-rw-r--r--arch/mips/kernel/irq-rm7000.c1
-rw-r--r--arch/mips/kernel/irq-rm9000.c1
-rw-r--r--arch/mips/kernel/irq_cpu.c1
-rw-r--r--arch/mips/kernel/irq_txx9.c1
-rw-r--r--arch/mips/kernel/kgdb.c2
-rw-r--r--arch/mips/kernel/kspd.c2
-rw-r--r--arch/mips/kernel/linux32.c7
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c2
-rw-r--r--arch/mips/kernel/prom.c112
-rw-r--r--arch/mips/kernel/ptrace.c4
-rw-r--r--arch/mips/kernel/rtlx.c3
-rw-r--r--arch/mips/kernel/scall32-o32.S16
-rw-r--r--arch/mips/kernel/scall64-64.S14
-rw-r--r--arch/mips/kernel/scall64-n32.S17
-rw-r--r--arch/mips/kernel/scall64-o32.S20
-rw-r--r--arch/mips/kernel/setup.c2
-rw-r--r--arch/mips/kernel/signal.c45
-rw-r--r--arch/mips/kernel/signal_n32.c5
-rw-r--r--arch/mips/kernel/smtc.c4
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/unaligned.c2
-rw-r--r--arch/mips/kernel/vpe.c3
-rw-r--r--arch/mips/math-emu/cp1emu.c1
-rw-r--r--arch/mips/math-emu/dp_add.c1
-rw-r--r--arch/mips/math-emu/dp_cmp.c1
-rw-r--r--arch/mips/math-emu/dp_div.c1
-rw-r--r--arch/mips/math-emu/dp_fint.c1
-rw-r--r--arch/mips/math-emu/dp_flong.c1
-rw-r--r--arch/mips/math-emu/dp_frexp.c1
-rw-r--r--arch/mips/math-emu/dp_fsp.c1
-rw-r--r--arch/mips/math-emu/dp_logb.c1
-rw-r--r--arch/mips/math-emu/dp_modf.c1
-rw-r--r--arch/mips/math-emu/dp_mul.c1
-rw-r--r--arch/mips/math-emu/dp_scalb.c1
-rw-r--r--arch/mips/math-emu/dp_simple.c1
-rw-r--r--arch/mips/math-emu/dp_sqrt.c1
-rw-r--r--arch/mips/math-emu/dp_sub.c1
-rw-r--r--arch/mips/math-emu/dp_tint.c1
-rw-r--r--arch/mips/math-emu/dp_tlong.c1
-rw-r--r--arch/mips/math-emu/ieee754.c1
-rw-r--r--arch/mips/math-emu/ieee754.h1
-rw-r--r--arch/mips/math-emu/ieee754d.c1
-rw-r--r--arch/mips/math-emu/ieee754dp.c1
-rw-r--r--arch/mips/math-emu/ieee754dp.h1
-rw-r--r--arch/mips/math-emu/ieee754int.h1
-rw-r--r--arch/mips/math-emu/ieee754m.c1
-rw-r--r--arch/mips/math-emu/ieee754sp.c1
-rw-r--r--arch/mips/math-emu/ieee754sp.h1
-rw-r--r--arch/mips/math-emu/ieee754xcpt.c1
-rw-r--r--arch/mips/math-emu/sp_add.c1
-rw-r--r--arch/mips/math-emu/sp_cmp.c1
-rw-r--r--arch/mips/math-emu/sp_div.c1
-rw-r--r--arch/mips/math-emu/sp_fdp.c1
-rw-r--r--arch/mips/math-emu/sp_fint.c1
-rw-r--r--arch/mips/math-emu/sp_flong.c1
-rw-r--r--arch/mips/math-emu/sp_frexp.c1
-rw-r--r--arch/mips/math-emu/sp_logb.c1
-rw-r--r--arch/mips/math-emu/sp_modf.c1
-rw-r--r--arch/mips/math-emu/sp_mul.c1
-rw-r--r--arch/mips/math-emu/sp_scalb.c1
-rw-r--r--arch/mips/math-emu/sp_simple.c1
-rw-r--r--arch/mips/math-emu/sp_sqrt.c1
-rw-r--r--arch/mips/math-emu/sp_sub.c1
-rw-r--r--arch/mips/math-emu/sp_tint.c1
-rw-r--r--arch/mips/math-emu/sp_tlong.c1
-rw-r--r--arch/mips/mm/dma-default.c28
-rw-r--r--arch/mips/mm/sc-rm7k.c2
-rw-r--r--arch/mips/mti-malta/malta-int.c3
-rw-r--r--arch/mips/mti-malta/malta-platform.c1
-rw-r--r--arch/mips/pci/fixup-fuloong2e.c2
-rw-r--r--arch/mips/pci/ops-tx3927.c1
-rw-r--r--arch/mips/pci/ops-tx4927.c1
-rw-r--r--arch/mips/pci/pci-rc32434.c2
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_irq_cic.c1
-rw-r--r--arch/mips/pnx8550/common/reset.c20
-rw-r--r--arch/mips/pnx8550/common/setup.c3
-rw-r--r--arch/mips/powertv/asic/irq_asic.c1
-rw-r--r--arch/mips/rb532/serial.c1
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c3
-rw-r--r--arch/mips/sni/a20r.c1
-rw-r--r--arch/mips/sni/pcimt.c1
-rw-r--r--arch/mips/sni/pcit.c1
-rw-r--r--arch/mips/sni/rm200.c1
-rw-r--r--arch/mips/sni/time.c1
-rw-r--r--arch/mips/txx9/generic/irq_tx4927.c1
-rw-r--r--arch/mips/txx9/generic/irq_tx4938.c1
-rw-r--r--arch/mips/txx9/generic/irq_tx4939.c1
-rw-r--r--arch/mips/txx9/generic/setup.c1
-rw-r--r--arch/mips/txx9/jmr3927/irq.c1
-rw-r--r--arch/mips/txx9/rbtx4927/irq.c1
-rw-r--r--arch/mips/txx9/rbtx4938/irq.c1
-rw-r--r--arch/mips/txx9/rbtx4939/irq.c1
-rw-r--r--arch/mips/vr41xx/common/irq.c1
-rw-r--r--arch/mips/vr41xx/common/siu.c1
-rw-r--r--arch/mn10300/include/asm/ioctls.h84
-rw-r--r--arch/mn10300/include/asm/irqflags.h123
-rw-r--r--arch/mn10300/include/asm/system.h109
-rw-r--r--arch/mn10300/kernel/entry.S1
-rw-r--r--arch/mn10300/kernel/module.c3
-rw-r--r--arch/mn10300/mm/cache.c20
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/include/asm/irqflags.h46
-rw-r--r--arch/parisc/include/asm/perf_event.h3
-rw-r--r--arch/parisc/include/asm/system.h19
-rw-r--r--arch/parisc/kernel/module.c3
-rw-r--r--arch/parisc/kernel/perf.c4
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/boot/addnote.c4
-rw-r--r--arch/powerpc/boot/dts/bluestone.dts254
-rw-r--r--arch/powerpc/boot/dts/mpc8308_p1m.dts332
-rw-r--r--arch/powerpc/boot/dts/mpc8536ds.dts52
-rw-r--r--arch/powerpc/boot/dts/p1022ds.dts11
-rw-r--r--arch/powerpc/boot/dts/p4080ds.dts11
-rw-r--r--arch/powerpc/configs/44x/bluestone_defconfig68
-rw-r--r--arch/powerpc/configs/e55xx_smp_defconfig84
-rw-r--r--arch/powerpc/configs/ppc44x_defconfig9
-rw-r--r--arch/powerpc/configs/ppc64e_defconfig4
-rw-r--r--arch/powerpc/include/asm/checksum.h10
-rw-r--r--arch/powerpc/include/asm/compat.h4
-rw-r--r--arch/powerpc/include/asm/cputable.h14
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h14
-rw-r--r--arch/powerpc/include/asm/elf.h2
-rw-r--r--arch/powerpc/include/asm/exception-64s.h3
-rw-r--r--arch/powerpc/include/asm/fsl_85xx_cache_sram.h48
-rw-r--r--arch/powerpc/include/asm/hw_irq.h113
-rw-r--r--arch/powerpc/include/asm/hydra.h2
-rw-r--r--arch/powerpc/include/asm/irqflags.h2
-rw-r--r--arch/powerpc/include/asm/kexec.h1
-rw-r--r--arch/powerpc/include/asm/kvm.h1
-rw-r--r--arch/powerpc/include/asm/kvm_asm.h4
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h31
-rw-r--r--arch/powerpc/include/asm/kvm_fpu.h4
-rw-r--r--arch/powerpc/include/asm/kvm_host.h21
-rw-r--r--arch/powerpc/include/asm/kvm_para.h139
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h1
-rw-r--r--arch/powerpc/include/asm/lppaca.h29
-rw-r--r--arch/powerpc/include/asm/machdep.h3
-rw-r--r--arch/powerpc/include/asm/memblock.h7
-rw-r--r--arch/powerpc/include/asm/mmu-book3e.h15
-rw-r--r--arch/powerpc/include/asm/mmu.h12
-rw-r--r--arch/powerpc/include/asm/paca.h12
-rw-r--r--arch/powerpc/include/asm/page_64.h4
-rw-r--r--arch/powerpc/include/asm/ppc-pci.h4
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h50
-rw-r--r--arch/powerpc/include/asm/processor.h4
-rw-r--r--arch/powerpc/include/asm/pte-common.h7
-rw-r--r--arch/powerpc/include/asm/rtas.h1
-rw-r--r--arch/powerpc/include/asm/systbl.h19
-rw-r--r--arch/powerpc/include/asm/system.h8
-rw-r--r--arch/powerpc/include/asm/time.h5
-rw-r--r--arch/powerpc/include/asm/unistd.h21
-rw-r--r--arch/powerpc/kernel/Makefile6
-rw-r--r--arch/powerpc/kernel/align.c4
-rw-r--r--arch/powerpc/kernel/asm-offsets.c37
-rw-r--r--arch/powerpc/kernel/cpu_setup_44x.S1
-rw-r--r--arch/powerpc/kernel/cpu_setup_fsl_booke.S15
-rw-r--r--arch/powerpc/kernel/cputable.c43
-rw-r--r--arch/powerpc/kernel/crash.c13
-rw-r--r--arch/powerpc/kernel/dma-iommu.c21
-rw-r--r--arch/powerpc/kernel/dma.c20
-rw-r--r--arch/powerpc/kernel/entry_64.S40
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S10
-rw-r--r--arch/powerpc/kernel/fpu.S10
-rw-r--r--arch/powerpc/kernel/head_40x.S6
-rw-r--r--arch/powerpc/kernel/head_64.S6
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S10
-rw-r--r--arch/powerpc/kernel/ibmebus.c11
-rw-r--r--arch/powerpc/kernel/irq.c10
-rw-r--r--arch/powerpc/kernel/kvm.c596
-rw-r--r--arch/powerpc/kernel/kvm_emul.S302
-rw-r--r--arch/powerpc/kernel/legacy_serial.c22
-rw-r--r--arch/powerpc/kernel/lparcfg.c15
-rw-r--r--arch/powerpc/kernel/machine_kexec.c24
-rw-r--r--arch/powerpc/kernel/machine_kexec_32.c4
-rw-r--r--arch/powerpc/kernel/module.c6
-rw-r--r--arch/powerpc/kernel/paca.c72
-rw-r--r--arch/powerpc/kernel/pci-common.c4
-rw-r--r--arch/powerpc/kernel/perf_callchain.c86
-rw-r--r--arch/powerpc/kernel/perf_event.c166
-rw-r--r--arch/powerpc/kernel/perf_event_fsl_emb.c148
-rw-r--r--arch/powerpc/kernel/ppc970-pmu.c2
-rw-r--r--arch/powerpc/kernel/process.c12
-rw-r--r--arch/powerpc/kernel/prom.c27
-rw-r--r--arch/powerpc/kernel/ptrace.c2
-rw-r--r--arch/powerpc/kernel/rtas.c6
-rw-r--r--arch/powerpc/kernel/rtas_flash.c3
-rw-r--r--arch/powerpc/kernel/rtasd.c1
-rw-r--r--arch/powerpc/kernel/setup_32.c4
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/smp.c14
-rw-r--r--arch/powerpc/kernel/time.c317
-rw-r--r--arch/powerpc/kernel/traps.c5
-rw-r--r--arch/powerpc/kernel/vdso.c6
-rw-r--r--arch/powerpc/kernel/vdso32/Makefile6
-rw-r--r--arch/powerpc/kernel/vdso64/Makefile6
-rw-r--r--arch/powerpc/kernel/vio.c10
-rw-r--r--arch/powerpc/kvm/44x.c10
-rw-r--r--arch/powerpc/kvm/44x_tlb.c9
-rw-r--r--arch/powerpc/kvm/Makefile2
-rw-r--r--arch/powerpc/kvm/book3s.c272
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu.c111
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c75
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu.c42
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_host.c74
-rw-r--r--arch/powerpc/kvm/book3s_emulate.c73
-rw-r--r--arch/powerpc/kvm/book3s_mmu_hpte.c140
-rw-r--r--arch/powerpc/kvm/book3s_paired_singles.c55
-rw-r--r--arch/powerpc/kvm/book3s_rmhandlers.S32
-rw-r--r--arch/powerpc/kvm/booke.c108
-rw-r--r--arch/powerpc/kvm/booke.h10
-rw-r--r--arch/powerpc/kvm/booke_emulate.c14
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S3
-rw-r--r--arch/powerpc/kvm/e500.c7
-rw-r--r--arch/powerpc/kvm/e500_tlb.c18
-rw-r--r--arch/powerpc/kvm/e500_tlb.h2
-rw-r--r--arch/powerpc/kvm/emulate.c40
-rw-r--r--arch/powerpc/kvm/fpu.S8
-rw-r--r--arch/powerpc/kvm/powerpc.c88
-rw-r--r--arch/powerpc/kvm/trace.h239
-rw-r--r--arch/powerpc/lib/Makefile7
-rw-r--r--arch/powerpc/lib/checksum_64.S482
-rw-r--r--arch/powerpc/lib/checksum_wrappers_64.c102
-rw-r--r--arch/powerpc/lib/copy_32.S2
-rw-r--r--arch/powerpc/lib/ldstfp.S36
-rw-r--r--arch/powerpc/lib/locks.c4
-rw-r--r--arch/powerpc/lib/sstep.c8
-rw-r--r--arch/powerpc/math-emu/Makefile2
-rw-r--r--arch/powerpc/mm/40x_mmu.c17
-rw-r--r--arch/powerpc/mm/44x_mmu.c14
-rw-r--r--arch/powerpc/mm/Makefile6
-rw-r--r--arch/powerpc/mm/fault.c6
-rw-r--r--arch/powerpc/mm/fsl_booke_mmu.c27
-rw-r--r--arch/powerpc/mm/hash_utils_64.c35
-rw-r--r--arch/powerpc/mm/init_32.c43
-rw-r--r--arch/powerpc/mm/init_64.c1
-rw-r--r--arch/powerpc/mm/mem.c94
-rw-r--r--arch/powerpc/mm/mmu_context_nohash.c6
-rw-r--r--arch/powerpc/mm/mmu_decl.h5
-rw-r--r--arch/powerpc/mm/numa.c17
-rw-r--r--arch/powerpc/mm/ppc_mmu_32.c18
-rw-r--r--arch/powerpc/mm/tlb_nohash.c72
-rw-r--r--arch/powerpc/mm/tlb_nohash_low.S2
-rw-r--r--arch/powerpc/oprofile/Makefile4
-rw-r--r--arch/powerpc/oprofile/backtrace.c2
-rw-r--r--arch/powerpc/oprofile/op_model_fsl_emb.c15
-rw-r--r--arch/powerpc/platforms/44x/Kconfig16
-rw-r--r--arch/powerpc/platforms/44x/ppc44x_simple.c1
-rw-r--r--arch/powerpc/platforms/512x/clock.c2
-rw-r--r--arch/powerpc/platforms/52xx/efika.c9
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_common.c8
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig4
-rw-r--r--arch/powerpc/platforms/83xx/mpc830x_rdb.c3
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig28
-rw-r--r--arch/powerpc/platforms/85xx/Makefile2
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c2
-rw-r--r--arch/powerpc/platforms/85xx/p3041_ds.c64
-rw-r--r--arch/powerpc/platforms/85xx/p5020_ds.c69
-rw-r--r--arch/powerpc/platforms/85xx/smp.c83
-rw-r--r--arch/powerpc/platforms/Kconfig10
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype8
-rw-r--r--arch/powerpc/platforms/cell/axon_msi.c6
-rw-r--r--arch/powerpc/platforms/cell/ras.c4
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c18
-rw-r--r--arch/powerpc/platforms/chrp/nvram.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/wii.c2
-rw-r--r--arch/powerpc/platforms/iseries/Makefile2
-rw-r--r--arch/powerpc/platforms/iseries/dt.c4
-rw-r--r--arch/powerpc/platforms/iseries/mf.c1
-rw-r--r--arch/powerpc/platforms/iseries/smp.c2
-rw-r--r--arch/powerpc/platforms/maple/setup.c1
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_core.c9
-rw-r--r--arch/powerpc/platforms/pseries/Makefile13
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c7
-rw-r--r--arch/powerpc/platforms/pseries/dtl.c224
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c25
-rw-r--r--arch/powerpc/platforms/pseries/mobility.c362
-rw-r--r--arch/powerpc/platforms/pseries/pseries.h9
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c3
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c1
-rw-r--r--arch/powerpc/platforms/pseries/setup.c52
-rw-r--r--arch/powerpc/platforms/pseries/xics.c4
-rw-r--r--arch/powerpc/sysdev/Makefile5
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c74
-rw-r--r--arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h101
-rw-r--r--arch/powerpc/sysdev/fsl_85xx_cache_sram.c159
-rw-r--r--arch/powerpc/sysdev/fsl_85xx_l2ctlr.c231
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c13
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c60
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h1
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c65
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c181
-rw-r--r--arch/powerpc/sysdev/mpc8xxx_gpio.c3
-rw-r--r--arch/powerpc/sysdev/mpic_pasemi_msi.c22
-rw-r--r--arch/powerpc/sysdev/mpic_u3msi.c18
-rw-r--r--arch/powerpc/sysdev/pmi.c2
-rw-r--r--arch/powerpc/xmon/Makefile4
-rw-r--r--arch/s390/Kconfig8
-rw-r--r--arch/s390/crypto/prng.c1
-rw-r--r--arch/s390/hypfs/hypfs_diag.c1
-rw-r--r--arch/s390/hypfs/hypfs_vm.c1
-rw-r--r--arch/s390/hypfs/inode.c1
-rw-r--r--arch/s390/include/asm/Kbuild1
-rw-r--r--arch/s390/include/asm/hardirq.h4
-rw-r--r--arch/s390/include/asm/ioctls.h88
-rw-r--r--arch/s390/include/asm/irqflags.h51
-rw-r--r--arch/s390/include/asm/kvm_virtio.h7
-rw-r--r--arch/s390/include/asm/perf_event.h3
-rw-r--r--arch/s390/include/asm/qdio.h13
-rw-r--r--arch/s390/include/asm/system.h3
-rw-r--r--arch/s390/include/asm/topology.h27
-rw-r--r--arch/s390/kernel/debug.c1
-rw-r--r--arch/s390/kernel/mem_detect.c4
-rw-r--r--arch/s390/kernel/module.c3
-rw-r--r--arch/s390/kernel/topology.c150
-rw-r--r--arch/s390/mm/init.c3
-rw-r--r--arch/s390/mm/maccess.c4
-rw-r--r--arch/score/include/asm/irqflags.h187
-rw-r--r--arch/sh/Kconfig20
-rw-r--r--arch/sh/boards/Kconfig18
-rw-r--r--arch/sh/boards/Makefile2
-rw-r--r--arch/sh/boards/board-sh2007.c133
-rw-r--r--arch/sh/boards/board-sh7757lcr.c374
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c6
-rw-r--r--arch/sh/boards/mach-landisk/gio.c1
-rw-r--r--arch/sh/boards/mach-sdk7786/Makefile5
-rw-r--r--arch/sh/boards/mach-sdk7786/gpio.c49
-rw-r--r--arch/sh/boards/mach-sdk7786/setup.c54
-rw-r--r--arch/sh/boards/mach-sdk7786/sram.c72
-rw-r--r--arch/sh/boards/mach-x3proto/Makefile2
-rw-r--r--arch/sh/boards/mach-x3proto/gpio.c135
-rw-r--r--arch/sh/boards/mach-x3proto/ilsel.c18
-rw-r--r--arch/sh/boards/mach-x3proto/setup.c132
-rw-r--r--arch/sh/boot/compressed/head_32.S4
-rw-r--r--arch/sh/cchips/hd6446x/Makefile2
-rw-r--r--arch/sh/configs/ap325rxa_defconfig1
-rw-r--r--arch/sh/configs/cayman_defconfig1
-rw-r--r--arch/sh/configs/dreamcast_defconfig1
-rw-r--r--arch/sh/configs/ecovec24-romimage_defconfig1
-rw-r--r--arch/sh/configs/edosk7760_defconfig1
-rw-r--r--arch/sh/configs/espt_defconfig1
-rw-r--r--arch/sh/configs/hp6xx_defconfig1
-rw-r--r--arch/sh/configs/kfr2r09-romimage_defconfig1
-rw-r--r--arch/sh/configs/kfr2r09_defconfig1
-rw-r--r--arch/sh/configs/landisk_defconfig1
-rw-r--r--arch/sh/configs/lboxre2_defconfig1
-rw-r--r--arch/sh/configs/magicpanelr2_defconfig1
-rw-r--r--arch/sh/configs/microdev_defconfig1
-rw-r--r--arch/sh/configs/migor_defconfig1
-rw-r--r--arch/sh/configs/polaris_defconfig1
-rw-r--r--arch/sh/configs/r7780mp_defconfig1
-rw-r--r--arch/sh/configs/r7785rp_defconfig1
-rw-r--r--arch/sh/configs/rts7751r2d1_defconfig1
-rw-r--r--arch/sh/configs/rts7751r2dplus_defconfig1
-rw-r--r--arch/sh/configs/sdk7780_defconfig1
-rw-r--r--arch/sh/configs/se7343_defconfig1
-rw-r--r--arch/sh/configs/se7712_defconfig1
-rw-r--r--arch/sh/configs/se7721_defconfig1
-rw-r--r--arch/sh/configs/se7722_defconfig1
-rw-r--r--arch/sh/configs/se7724_defconfig1
-rw-r--r--arch/sh/configs/se7750_defconfig1
-rw-r--r--arch/sh/configs/se7751_defconfig1
-rw-r--r--arch/sh/configs/se7780_defconfig1
-rw-r--r--arch/sh/configs/sh03_defconfig1
-rw-r--r--arch/sh/configs/sh2007_defconfig212
-rw-r--r--arch/sh/configs/sh7710voipgw_defconfig1
-rw-r--r--arch/sh/configs/sh7757lcr_defconfig85
-rw-r--r--arch/sh/configs/sh7763rdp_defconfig1
-rw-r--r--arch/sh/configs/sh7785lcr_defconfig1
-rw-r--r--arch/sh/configs/shx3_defconfig1
-rw-r--r--arch/sh/configs/snapgear_defconfig1
-rw-r--r--arch/sh/configs/systemh_defconfig1
-rw-r--r--arch/sh/configs/titan_defconfig1
-rw-r--r--arch/sh/configs/ul2_defconfig1
-rw-r--r--arch/sh/drivers/dma/dma-api.c4
-rw-r--r--arch/sh/drivers/pci/Makefile1
-rw-r--r--arch/sh/drivers/pci/fixups-sdk7786.c67
-rw-r--r--arch/sh/drivers/pci/ops-sh4.c11
-rw-r--r--arch/sh/drivers/pci/ops-sh7786.c69
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.c2
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c2
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.h6
-rw-r--r--arch/sh/drivers/pci/pci.c43
-rw-r--r--arch/sh/drivers/pci/pcie-sh7786.c251
-rw-r--r--arch/sh/drivers/pci/pcie-sh7786.h56
-rw-r--r--arch/sh/include/asm/Kbuild2
-rw-r--r--arch/sh/include/asm/elf.h27
-rw-r--r--arch/sh/include/asm/fixmap.h4
-rw-r--r--arch/sh/include/asm/gpio.h6
-rw-r--r--arch/sh/include/asm/irq.h2
-rw-r--r--arch/sh/include/asm/irqflags.h4
-rw-r--r--arch/sh/include/asm/kprobes.h1
-rw-r--r--arch/sh/include/asm/memblock.h2
-rw-r--r--arch/sh/include/asm/pci.h2
-rw-r--r--arch/sh/include/asm/perf_event.h7
-rw-r--r--arch/sh/include/asm/processor_32.h3
-rw-r--r--arch/sh/include/asm/processor_64.h3
-rw-r--r--arch/sh/include/asm/ptrace.h169
-rw-r--r--arch/sh/include/asm/ptrace_32.h83
-rw-r--r--arch/sh/include/asm/ptrace_64.h20
-rw-r--r--arch/sh/include/asm/sizes.h1
-rw-r--r--arch/sh/include/asm/sram.h38
-rw-r--r--arch/sh/include/asm/syscalls_32.h7
-rw-r--r--arch/sh/include/asm/system.h2
-rw-r--r--arch/sh/include/asm/system_32.h15
-rw-r--r--arch/sh/include/asm/tlbflush.h2
-rw-r--r--arch/sh/include/asm/unistd_32.h27
-rw-r--r--arch/sh/include/asm/unistd_64.h5
-rw-r--r--arch/sh/include/cpu-sh3/cpu/mmu_context.h1
-rw-r--r--arch/sh/include/cpu-sh4/cpu/freq.h4
-rw-r--r--arch/sh/include/cpu-sh4/cpu/sh7757.h301
-rw-r--r--arch/sh/include/cpu-sh4/cpu/shx3.h64
-rw-r--r--arch/sh/include/mach-common/mach/sh2007.h117
-rw-r--r--arch/sh/include/mach-sdk7786/mach/fpga.h26
-rw-r--r--arch/sh/include/mach-x3proto/mach/hardware.h12
-rw-r--r--arch/sh/include/mach-x3proto/mach/ilsel.h (renamed from arch/sh/include/asm/ilsel.h)0
-rw-r--r--arch/sh/kernel/Makefile8
-rw-r--r--arch/sh/kernel/clkdev.c4
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/Makefile5
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7757.c199
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-shx3.c225
-rw-r--r--arch/sh/kernel/cpu/sh4a/intc-shx3.c34
-rw-r--r--arch/sh/kernel/cpu/sh4a/perf_event.c20
-rw-r--r--arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c1582
-rw-r--r--arch/sh/kernel/cpu/sh4a/pinmux-shx3.c587
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7724.c66
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7757.c222
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7786.c126
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-shx3.c42
-rw-r--r--arch/sh/kernel/head_32.S2
-rw-r--r--arch/sh/kernel/io_trapped.c2
-rw-r--r--arch/sh/kernel/irq.c4
-rw-r--r--arch/sh/kernel/irq_32.c12
-rw-r--r--arch/sh/kernel/kdebugfs.c16
-rw-r--r--arch/sh/kernel/kprobes.c100
-rw-r--r--arch/sh/kernel/module.c2
-rw-r--r--arch/sh/kernel/perf_callchain.c50
-rw-r--r--arch/sh/kernel/perf_event.c159
-rw-r--r--arch/sh/kernel/ptrace.c33
-rw-r--r--arch/sh/kernel/ptrace_32.c27
-rw-r--r--arch/sh/kernel/ptrace_64.c88
-rw-r--r--arch/sh/kernel/reboot.c4
-rw-r--r--arch/sh/kernel/setup.c22
-rw-r--r--arch/sh/kernel/syscalls_32.S22
-rw-r--r--arch/sh/kernel/syscalls_64.S3
-rw-r--r--arch/sh/kernel/traps_32.c29
-rw-r--r--arch/sh/kernel/traps_64.c11
-rw-r--r--arch/sh/lib/Makefile2
-rw-r--r--arch/sh/math-emu/math.c3
-rw-r--r--arch/sh/mm/Kconfig4
-rw-r--r--arch/sh/mm/Makefile3
-rw-r--r--arch/sh/mm/asids-debugfs.c2
-rw-r--r--arch/sh/mm/cache-debugfs.c10
-rw-r--r--arch/sh/mm/consistent.c3
-rw-r--r--arch/sh/mm/init.c69
-rw-r--r--arch/sh/mm/nommu.c4
-rw-r--r--arch/sh/mm/pmb.c35
-rw-r--r--arch/sh/mm/sram.c34
-rw-r--r--arch/sh/mm/tlb-debugfs.c11
-rw-r--r--arch/sh/mm/tlbflush_32.c16
-rw-r--r--arch/sh/mm/tlbflush_64.c5
-rw-r--r--arch/sh/oprofile/Makefile4
-rw-r--r--arch/sh/oprofile/common.c115
-rw-r--r--arch/sh/oprofile/op_impl.h33
-rw-r--r--arch/sh/tools/mach-types2
-rw-r--r--arch/sparc/Kconfig4
-rw-r--r--arch/sparc/include/asm/Kbuild1
-rw-r--r--arch/sparc/include/asm/floppy_32.h3
-rw-r--r--arch/sparc/include/asm/irqflags_32.h35
-rw-r--r--arch/sparc/include/asm/irqflags_64.h29
-rw-r--r--arch/sparc/include/asm/jump_label.h32
-rw-r--r--arch/sparc/include/asm/memblock.h2
-rw-r--r--arch/sparc/include/asm/openprom.h16
-rw-r--r--arch/sparc/include/asm/oplib_32.h44
-rw-r--r--arch/sparc/include/asm/oplib_64.h39
-rw-r--r--arch/sparc/include/asm/perf_event.h4
-rw-r--r--arch/sparc/include/asm/prom.h5
-rw-r--r--arch/sparc/kernel/Makefile2
-rw-r--r--arch/sparc/kernel/apc.c1
-rw-r--r--arch/sparc/kernel/auxio_32.c4
-rw-r--r--arch/sparc/kernel/btext.c4
-rw-r--r--arch/sparc/kernel/devices.c23
-rw-r--r--arch/sparc/kernel/irq_32.c13
-rw-r--r--arch/sparc/kernel/jump_label.c47
-rw-r--r--arch/sparc/kernel/leon_kernel.c2
-rw-r--r--arch/sparc/kernel/mdesc.c1
-rw-r--r--arch/sparc/kernel/module.c6
-rw-r--r--arch/sparc/kernel/pci_msi.c8
-rw-r--r--arch/sparc/kernel/pcic.c4
-rw-r--r--arch/sparc/kernel/pcr.c8
-rw-r--r--arch/sparc/kernel/perf_event.c240
-rw-r--r--arch/sparc/kernel/prom.h6
-rw-r--r--arch/sparc/kernel/prom_common.c202
-rw-r--r--arch/sparc/kernel/setup_64.c2
-rw-r--r--arch/sparc/kernel/starfire.c2
-rw-r--r--arch/sparc/kernel/tadpole.c2
-rw-r--r--arch/sparc/mm/init_64.c48
-rw-r--r--arch/sparc/mm/srmmu.c8
-rw-r--r--arch/sparc/mm/sun4c.c2
-rw-r--r--arch/sparc/prom/init_32.c2
-rw-r--r--arch/sparc/prom/init_64.c4
-rw-r--r--arch/sparc/prom/memory.c3
-rw-r--r--arch/sparc/prom/misc_64.c6
-rw-r--r--arch/sparc/prom/p1275.c2
-rw-r--r--arch/sparc/prom/ranges.c6
-rw-r--r--arch/sparc/prom/tree_32.c58
-rw-r--r--arch/sparc/prom/tree_64.c62
-rw-r--r--arch/tile/include/asm/bitops.h1
-rw-r--r--arch/tile/include/asm/irqflags.h36
-rw-r--r--arch/tile/kernel/hardwall.c1
-rw-r--r--arch/tile/kernel/irq.c4
-rw-r--r--arch/um/drivers/harddog_kern.c14
-rw-r--r--arch/um/drivers/hostaudio_kern.c26
-rw-r--r--arch/um/drivers/mconsole_kern.c1
-rw-r--r--arch/um/drivers/mmapper_kern.c1
-rw-r--r--arch/um/drivers/net_kern.c17
-rw-r--r--arch/um/drivers/random.c1
-rw-r--r--arch/um/drivers/ubd_kern.c20
-rw-r--r--arch/um/kernel/exec.c2
-rw-r--r--arch/um/kernel/irq.c6
-rw-r--r--arch/x86/Kconfig145
-rw-r--r--arch/x86/Kconfig.debug14
-rw-r--r--arch/x86/Makefile8
-rw-r--r--arch/x86/boot/compressed/misc.c29
-rw-r--r--arch/x86/ia32/ia32_aout.c22
-rw-r--r--arch/x86/include/asm/alternative.h11
-rw-r--r--arch/x86/include/asm/amd_iommu.h6
-rw-r--r--arch/x86/include/asm/amd_iommu_proto.h2
-rw-r--r--arch/x86/include/asm/amd_iommu_types.h23
-rw-r--r--arch/x86/include/asm/amd_nb.h (renamed from arch/x86/include/asm/k8.h)21
-rw-r--r--arch/x86/include/asm/apb_timer.h1
-rw-r--r--arch/x86/include/asm/apic.h4
-rw-r--r--arch/x86/include/asm/apicdef.h1
-rw-r--r--arch/x86/include/asm/bitops.h2
-rw-r--r--arch/x86/include/asm/calgary.h4
-rw-r--r--arch/x86/include/asm/calling.h52
-rw-r--r--arch/x86/include/asm/cpu.h1
-rw-r--r--arch/x86/include/asm/cpufeature.h13
-rw-r--r--arch/x86/include/asm/dwarf2.h20
-rw-r--r--arch/x86/include/asm/e820.h20
-rw-r--r--arch/x86/include/asm/efi.h2
-rw-r--r--arch/x86/include/asm/entry_arch.h23
-rw-r--r--arch/x86/include/asm/fixmap.h15
-rw-r--r--arch/x86/include/asm/gart.h20
-rw-r--r--arch/x86/include/asm/hardirq.h2
-rw-r--r--arch/x86/include/asm/hpet.h10
-rw-r--r--arch/x86/include/asm/hw_irq.h19
-rw-r--r--arch/x86/include/asm/i387.h185
-rw-r--r--arch/x86/include/asm/i8259.h2
-rw-r--r--arch/x86/include/asm/io.h2
-rw-r--r--arch/x86/include/asm/io_apic.h6
-rw-r--r--arch/x86/include/asm/iommu_table.h100
-rw-r--r--arch/x86/include/asm/irq.h12
-rw-r--r--arch/x86/include/asm/irq_remapping.h35
-rw-r--r--arch/x86/include/asm/irq_vectors.h4
-rw-r--r--arch/x86/include/asm/irqflags.h32
-rw-r--r--arch/x86/include/asm/jump_label.h37
-rw-r--r--arch/x86/include/asm/kvm_emulate.h30
-rw-r--r--arch/x86/include/asm/kvm_host.h105
-rw-r--r--arch/x86/include/asm/kvm_para.h6
-rw-r--r--arch/x86/include/asm/memblock.h23
-rw-r--r--arch/x86/include/asm/module.h7
-rw-r--r--arch/x86/include/asm/mrst.h10
-rw-r--r--arch/x86/include/asm/msr-index.h1
-rw-r--r--arch/x86/include/asm/mwait.h15
-rw-r--r--arch/x86/include/asm/olpc_ofw.h4
-rw-r--r--arch/x86/include/asm/page_32_types.h4
-rw-r--r--arch/x86/include/asm/page_types.h2
-rw-r--r--arch/x86/include/asm/paravirt.h21
-rw-r--r--arch/x86/include/asm/paravirt_types.h1
-rw-r--r--arch/x86/include/asm/percpu.h14
-rw-r--r--arch/x86/include/asm/perf_event_p4.h52
-rw-r--r--arch/x86/include/asm/pgtable.h4
-rw-r--r--arch/x86/include/asm/pgtable_32.h2
-rw-r--r--arch/x86/include/asm/pgtable_64.h2
-rw-r--r--arch/x86/include/asm/processor.h29
-rw-r--r--arch/x86/include/asm/pvclock.h38
-rw-r--r--arch/x86/include/asm/segment.h32
-rw-r--r--arch/x86/include/asm/setup.h5
-rw-r--r--arch/x86/include/asm/swiotlb.h13
-rw-r--r--arch/x86/include/asm/tlbflush.h2
-rw-r--r--arch/x86/include/asm/trampoline.h3
-rw-r--r--arch/x86/include/asm/vmi.h269
-rw-r--r--arch/x86/include/asm/vmi_time.h98
-rw-r--r--arch/x86/kernel/Makefile10
-rw-r--r--arch/x86/kernel/acpi/cstate.c13
-rw-r--r--arch/x86/kernel/acpi/sleep.c16
-rw-r--r--arch/x86/kernel/alternative.c71
-rw-r--r--arch/x86/kernel/amd_iommu.c2
-rw-r--r--arch/x86/kernel/amd_iommu_init.c139
-rw-r--r--arch/x86/kernel/amd_nb.c (renamed from arch/x86/kernel/k8.c)56
-rw-r--r--arch/x86/kernel/apb_timer.c60
-rw-r--r--arch/x86/kernel/aperture_64.c31
-rw-r--r--arch/x86/kernel/apic/apic.c91
-rw-r--r--arch/x86/kernel/apic/io_apic.c877
-rw-r--r--arch/x86/kernel/apic/nmi.c2
-rw-r--r--arch/x86/kernel/apic/numaq_32.c3
-rw-r--r--arch/x86/kernel/apic/probe_64.c3
-rw-r--r--arch/x86/kernel/apm_32.c5
-rw-r--r--arch/x86/kernel/asm-offsets_32.c4
-rw-r--r--arch/x86/kernel/check.c16
-rw-r--r--arch/x86/kernel/cpu/amd.c77
-rw-r--r--arch/x86/kernel/cpu/common.c26
-rw-r--r--arch/x86/kernel/cpu/cpu.h2
-rw-r--r--arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c18
-rw-r--r--arch/x86/kernel/cpu/intel.c7
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c14
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-severity.c1
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c1
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c36
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c5
-rw-r--r--arch/x86/kernel/cpu/mtrr/cleanup.c2
-rw-r--r--arch/x86/kernel/cpu/mtrr/generic.c128
-rw-r--r--arch/x86/kernel/cpu/perf_event.c280
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c8
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c13
-rw-r--r--arch/x86/kernel/cpu/perf_event_p4.c298
-rw-r--r--arch/x86/kernel/cpu/perfctr-watchdog.c9
-rw-r--r--arch/x86/kernel/cpu/scattered.c6
-rw-r--r--arch/x86/kernel/crash_dump_64.c3
-rw-r--r--arch/x86/kernel/e820.c191
-rw-r--r--arch/x86/kernel/early-quirks.c2
-rw-r--r--arch/x86/kernel/early_printk.c13
-rw-r--r--arch/x86/kernel/early_printk_mrst.c319
-rw-r--r--arch/x86/kernel/efi.c5
-rw-r--r--arch/x86/kernel/entry_32.S310
-rw-r--r--arch/x86/kernel/entry_64.S134
-rw-r--r--arch/x86/kernel/ftrace.c63
-rw-r--r--arch/x86/kernel/head.c3
-rw-r--r--arch/x86/kernel/head32.c11
-rw-r--r--arch/x86/kernel/head64.c9
-rw-r--r--arch/x86/kernel/head_32.S55
-rw-r--r--arch/x86/kernel/hpet.c69
-rw-r--r--arch/x86/kernel/i387.c58
-rw-r--r--arch/x86/kernel/i8259.c63
-rw-r--r--arch/x86/kernel/irq.c32
-rw-r--r--arch/x86/kernel/irq_32.c12
-rw-r--r--arch/x86/kernel/irq_work.c30
-rw-r--r--arch/x86/kernel/irqinit.c23
-rw-r--r--arch/x86/kernel/jump_label.c50
-rw-r--r--arch/x86/kernel/kdebugfs.c1
-rw-r--r--arch/x86/kernel/kgdb.c11
-rw-r--r--arch/x86/kernel/kprobes.c14
-rw-r--r--arch/x86/kernel/kvmclock.c6
-rw-r--r--arch/x86/kernel/machine_kexec_64.c4
-rw-r--r--arch/x86/kernel/microcode_core.c3
-rw-r--r--arch/x86/kernel/microcode_intel.c2
-rw-r--r--arch/x86/kernel/module.c6
-rw-r--r--arch/x86/kernel/mpparse.c5
-rw-r--r--arch/x86/kernel/olpc-xo1.c140
-rw-r--r--arch/x86/kernel/olpc.c89
-rw-r--r--arch/x86/kernel/olpc_ofw.c6
-rw-r--r--arch/x86/kernel/paravirt.c1
-rw-r--r--arch/x86/kernel/pci-calgary_64.c18
-rw-r--r--arch/x86/kernel/pci-dma.c44
-rw-r--r--arch/x86/kernel/pci-gart_64.c33
-rw-r--r--arch/x86/kernel/pci-iommu_table.c89
-rw-r--r--arch/x86/kernel/pci-swiotlb.c44
-rw-r--r--arch/x86/kernel/pmtimer_64.c69
-rw-r--r--arch/x86/kernel/process_64.c2
-rw-r--r--arch/x86/kernel/pvclock.c3
-rw-r--r--arch/x86/kernel/quirks.c2
-rw-r--r--arch/x86/kernel/reboot.c12
-rw-r--r--arch/x86/kernel/setup.c233
-rw-r--r--arch/x86/kernel/setup_percpu.c8
-rw-r--r--arch/x86/kernel/sfi.c4
-rw-r--r--arch/x86/kernel/smpboot.c134
-rw-r--r--arch/x86/kernel/sys_i386_32.c4
-rw-r--r--arch/x86/kernel/tlb_uv.c12
-rw-r--r--arch/x86/kernel/trampoline.c26
-rw-r--r--arch/x86/kernel/traps.c36
-rw-r--r--arch/x86/kernel/tsc.c66
-rw-r--r--arch/x86/kernel/uv_irq.c55
-rw-r--r--arch/x86/kernel/visws_quirks.c140
-rw-r--r--arch/x86/kernel/vm86_32.c10
-rw-r--r--arch/x86/kernel/vmi_32.c893
-rw-r--r--arch/x86/kernel/vmiclock_32.c317
-rw-r--r--arch/x86/kernel/vmlinux.lds.S30
-rw-r--r--arch/x86/kvm/Kconfig7
-rw-r--r--arch/x86/kvm/emulate.c2262
-rw-r--r--arch/x86/kvm/i8254.c11
-rw-r--r--arch/x86/kvm/i8259.c25
-rw-r--r--arch/x86/kvm/irq.c9
-rw-r--r--arch/x86/kvm/irq.h2
-rw-r--r--arch/x86/kvm/kvm_cache_regs.h9
-rw-r--r--arch/x86/kvm/lapic.c18
-rw-r--r--arch/x86/kvm/mmu.c918
-rw-r--r--arch/x86/kvm/mmu.h9
-rw-r--r--arch/x86/kvm/mmu_audit.c299
-rw-r--r--arch/x86/kvm/mmutrace.h19
-rw-r--r--arch/x86/kvm/paging_tmpl.h202
-rw-r--r--arch/x86/kvm/svm.c298
-rw-r--r--arch/x86/kvm/timer.c2
-rw-r--r--arch/x86/kvm/vmx.c243
-rw-r--r--arch/x86/kvm/x86.c787
-rw-r--r--arch/x86/kvm/x86.h8
-rw-r--r--arch/x86/lguest/boot.c18
-rw-r--r--arch/x86/lib/memcpy_32.c199
-rw-r--r--arch/x86/lib/memcpy_64.S158
-rw-r--r--arch/x86/lib/memmove_64.c189
-rw-r--r--arch/x86/mm/Makefile2
-rw-r--r--arch/x86/mm/fault.c47
-rw-r--r--arch/x86/mm/init.c10
-rw-r--r--arch/x86/mm/init_32.c166
-rw-r--r--arch/x86/mm/init_64.c116
-rw-r--r--arch/x86/mm/ioremap.c5
-rw-r--r--arch/x86/mm/k8topology_64.c12
-rw-r--r--arch/x86/mm/kmemcheck/kmemcheck.c2
-rw-r--r--arch/x86/mm/kmemcheck/opcode.c2
-rw-r--r--arch/x86/mm/memblock.c348
-rw-r--r--arch/x86/mm/memtest.c7
-rw-r--r--arch/x86/mm/numa_32.c30
-rw-r--r--arch/x86/mm/numa_64.c86
-rw-r--r--arch/x86/mm/pgtable.c24
-rw-r--r--arch/x86/mm/srat_32.c3
-rw-r--r--arch/x86/mm/srat_64.c17
-rw-r--r--arch/x86/mm/tlb.c48
-rw-r--r--arch/x86/oprofile/backtrace.c70
-rw-r--r--arch/x86/oprofile/nmi_int.c10
-rw-r--r--arch/x86/oprofile/op_model_amd.c145
-rw-r--r--arch/x86/pci/olpc.c2
-rw-r--r--arch/x86/xen/debugfs.c1
-rw-r--r--arch/x86/xen/enlighten.c3
-rw-r--r--arch/x86/xen/mmu.c32
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c5
-rw-r--r--arch/x86/xen/setup.c3
-rw-r--r--arch/x86/xen/spinlock.c2
-rw-r--r--arch/x86/xen/time.c5
-rw-r--r--arch/xtensa/include/asm/irqflags.h58
-rw-r--r--arch/xtensa/include/asm/system.h33
-rw-r--r--arch/xtensa/include/asm/uaccess.h2
-rw-r--r--arch/xtensa/kernel/irq.c2
1899 files changed, 52868 insertions, 23696 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index fe48fc7a3eba..53d7f619a1b9 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -158,4 +158,7 @@ config HAVE_PERF_EVENTS_NMI
158 subsystem. Also has support for calculating CPU cycle events 158 subsystem. Also has support for calculating CPU cycle events
159 to determine how many clock cycles in a given period. 159 to determine how many clock cycles in a given period.
160 160
161config HAVE_ARCH_JUMP_LABEL
162 bool
163
161source "kernel/gcov/Kconfig" 164source "kernel/gcov/Kconfig"
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index b9647bb66d13..d04ccd73af45 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -9,6 +9,7 @@ config ALPHA
9 select HAVE_IDE 9 select HAVE_IDE
10 select HAVE_OPROFILE 10 select HAVE_OPROFILE
11 select HAVE_SYSCALL_WRAPPERS 11 select HAVE_SYSCALL_WRAPPERS
12 select HAVE_IRQ_WORK
12 select HAVE_PERF_EVENTS 13 select HAVE_PERF_EVENTS
13 select HAVE_DMA_ATTRS 14 select HAVE_DMA_ATTRS
14 help 15 help
diff --git a/arch/alpha/include/asm/irqflags.h b/arch/alpha/include/asm/irqflags.h
new file mode 100644
index 000000000000..299bbc7e9d71
--- /dev/null
+++ b/arch/alpha/include/asm/irqflags.h
@@ -0,0 +1,67 @@
1#ifndef __ALPHA_IRQFLAGS_H
2#define __ALPHA_IRQFLAGS_H
3
4#include <asm/system.h>
5
6#define IPL_MIN 0
7#define IPL_SW0 1
8#define IPL_SW1 2
9#define IPL_DEV0 3
10#define IPL_DEV1 4
11#define IPL_TIMER 5
12#define IPL_PERF 6
13#define IPL_POWERFAIL 6
14#define IPL_MCHECK 7
15#define IPL_MAX 7
16
17#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
18#undef IPL_MIN
19#define IPL_MIN __min_ipl
20extern int __min_ipl;
21#endif
22
23#define getipl() (rdps() & 7)
24#define setipl(ipl) ((void) swpipl(ipl))
25
26static inline unsigned long arch_local_save_flags(void)
27{
28 return rdps();
29}
30
31static inline void arch_local_irq_disable(void)
32{
33 setipl(IPL_MAX);
34 barrier();
35}
36
37static inline unsigned long arch_local_irq_save(void)
38{
39 unsigned long flags = swpipl(IPL_MAX);
40 barrier();
41 return flags;
42}
43
44static inline void arch_local_irq_enable(void)
45{
46 barrier();
47 setipl(IPL_MIN);
48}
49
50static inline void arch_local_irq_restore(unsigned long flags)
51{
52 barrier();
53 setipl(flags);
54 barrier();
55}
56
57static inline bool arch_irqs_disabled_flags(unsigned long flags)
58{
59 return flags == IPL_MAX;
60}
61
62static inline bool arch_irqs_disabled(void)
63{
64 return arch_irqs_disabled_flags(getipl());
65}
66
67#endif /* __ALPHA_IRQFLAGS_H */
diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
index 4157cd3c44a9..fe792ca818f6 100644
--- a/arch/alpha/include/asm/perf_event.h
+++ b/arch/alpha/include/asm/perf_event.h
@@ -1,11 +1,6 @@
1#ifndef __ASM_ALPHA_PERF_EVENT_H 1#ifndef __ASM_ALPHA_PERF_EVENT_H
2#define __ASM_ALPHA_PERF_EVENT_H 2#define __ASM_ALPHA_PERF_EVENT_H
3 3
4/* Alpha only supports software events through this interface. */
5extern void set_perf_event_pending(void);
6
7#define PERF_EVENT_INDEX_OFFSET 0
8
9#ifdef CONFIG_PERF_EVENTS 4#ifdef CONFIG_PERF_EVENTS
10extern void init_hw_perf_events(void); 5extern void init_hw_perf_events(void);
11#else 6#else
diff --git a/arch/alpha/include/asm/system.h b/arch/alpha/include/asm/system.h
index 5aa40cca4f23..9f78e6934637 100644
--- a/arch/alpha/include/asm/system.h
+++ b/arch/alpha/include/asm/system.h
@@ -259,34 +259,6 @@ __CALL_PAL_RW2(wrperfmon, unsigned long, unsigned long, unsigned long);
259__CALL_PAL_W1(wrusp, unsigned long); 259__CALL_PAL_W1(wrusp, unsigned long);
260__CALL_PAL_W1(wrvptptr, unsigned long); 260__CALL_PAL_W1(wrvptptr, unsigned long);
261 261
262#define IPL_MIN 0
263#define IPL_SW0 1
264#define IPL_SW1 2
265#define IPL_DEV0 3
266#define IPL_DEV1 4
267#define IPL_TIMER 5
268#define IPL_PERF 6
269#define IPL_POWERFAIL 6
270#define IPL_MCHECK 7
271#define IPL_MAX 7
272
273#ifdef CONFIG_ALPHA_BROKEN_IRQ_MASK
274#undef IPL_MIN
275#define IPL_MIN __min_ipl
276extern int __min_ipl;
277#endif
278
279#define getipl() (rdps() & 7)
280#define setipl(ipl) ((void) swpipl(ipl))
281
282#define local_irq_disable() do { setipl(IPL_MAX); barrier(); } while(0)
283#define local_irq_enable() do { barrier(); setipl(IPL_MIN); } while(0)
284#define local_save_flags(flags) ((flags) = rdps())
285#define local_irq_save(flags) do { (flags) = swpipl(IPL_MAX); barrier(); } while(0)
286#define local_irq_restore(flags) do { barrier(); setipl(flags); barrier(); } while(0)
287
288#define irqs_disabled() (getipl() == IPL_MAX)
289
290/* 262/*
291 * TB routines.. 263 * TB routines..
292 */ 264 */
diff --git a/arch/alpha/kernel/perf_event.c b/arch/alpha/kernel/perf_event.c
index 85d8e4f58c83..1cc49683fb69 100644
--- a/arch/alpha/kernel/perf_event.c
+++ b/arch/alpha/kernel/perf_event.c
@@ -307,7 +307,7 @@ again:
307 new_raw_count) != prev_raw_count) 307 new_raw_count) != prev_raw_count)
308 goto again; 308 goto again;
309 309
310 delta = (new_raw_count - (prev_raw_count & alpha_pmu->pmc_count_mask[idx])) + ovf; 310 delta = (new_raw_count - (prev_raw_count & alpha_pmu->pmc_count_mask[idx])) + ovf;
311 311
312 /* It is possible on very rare occasions that the PMC has overflowed 312 /* It is possible on very rare occasions that the PMC has overflowed
313 * but the interrupt is yet to come. Detect and fix this situation. 313 * but the interrupt is yet to come. Detect and fix this situation.
@@ -402,14 +402,13 @@ static void maybe_change_configuration(struct cpu_hw_events *cpuc)
402 struct hw_perf_event *hwc = &pe->hw; 402 struct hw_perf_event *hwc = &pe->hw;
403 int idx = hwc->idx; 403 int idx = hwc->idx;
404 404
405 if (cpuc->current_idx[j] != PMC_NO_INDEX) { 405 if (cpuc->current_idx[j] == PMC_NO_INDEX) {
406 cpuc->idx_mask |= (1<<cpuc->current_idx[j]); 406 alpha_perf_event_set_period(pe, hwc, idx);
407 continue; 407 cpuc->current_idx[j] = idx;
408 } 408 }
409 409
410 alpha_perf_event_set_period(pe, hwc, idx); 410 if (!(hwc->state & PERF_HES_STOPPED))
411 cpuc->current_idx[j] = idx; 411 cpuc->idx_mask |= (1<<cpuc->current_idx[j]);
412 cpuc->idx_mask |= (1<<cpuc->current_idx[j]);
413 } 412 }
414 cpuc->config = cpuc->event[0]->hw.config_base; 413 cpuc->config = cpuc->event[0]->hw.config_base;
415} 414}
@@ -420,12 +419,13 @@ static void maybe_change_configuration(struct cpu_hw_events *cpuc)
420 * - this function is called from outside this module via the pmu struct 419 * - this function is called from outside this module via the pmu struct
421 * returned from perf event initialisation. 420 * returned from perf event initialisation.
422 */ 421 */
423static int alpha_pmu_enable(struct perf_event *event) 422static int alpha_pmu_add(struct perf_event *event, int flags)
424{ 423{
425 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 424 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
425 struct hw_perf_event *hwc = &event->hw;
426 int n0; 426 int n0;
427 int ret; 427 int ret;
428 unsigned long flags; 428 unsigned long irq_flags;
429 429
430 /* 430 /*
431 * The Sparc code has the IRQ disable first followed by the perf 431 * The Sparc code has the IRQ disable first followed by the perf
@@ -435,8 +435,8 @@ static int alpha_pmu_enable(struct perf_event *event)
435 * nevertheless we disable the PMCs first to enable a potential 435 * nevertheless we disable the PMCs first to enable a potential
436 * final PMI to occur before we disable interrupts. 436 * final PMI to occur before we disable interrupts.
437 */ 437 */
438 perf_disable(); 438 perf_pmu_disable(event->pmu);
439 local_irq_save(flags); 439 local_irq_save(irq_flags);
440 440
441 /* Default to error to be returned */ 441 /* Default to error to be returned */
442 ret = -EAGAIN; 442 ret = -EAGAIN;
@@ -455,8 +455,12 @@ static int alpha_pmu_enable(struct perf_event *event)
455 } 455 }
456 } 456 }
457 457
458 local_irq_restore(flags); 458 hwc->state = PERF_HES_UPTODATE;
459 perf_enable(); 459 if (!(flags & PERF_EF_START))
460 hwc->state |= PERF_HES_STOPPED;
461
462 local_irq_restore(irq_flags);
463 perf_pmu_enable(event->pmu);
460 464
461 return ret; 465 return ret;
462} 466}
@@ -467,15 +471,15 @@ static int alpha_pmu_enable(struct perf_event *event)
467 * - this function is called from outside this module via the pmu struct 471 * - this function is called from outside this module via the pmu struct
468 * returned from perf event initialisation. 472 * returned from perf event initialisation.
469 */ 473 */
470static void alpha_pmu_disable(struct perf_event *event) 474static void alpha_pmu_del(struct perf_event *event, int flags)
471{ 475{
472 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 476 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
473 struct hw_perf_event *hwc = &event->hw; 477 struct hw_perf_event *hwc = &event->hw;
474 unsigned long flags; 478 unsigned long irq_flags;
475 int j; 479 int j;
476 480
477 perf_disable(); 481 perf_pmu_disable(event->pmu);
478 local_irq_save(flags); 482 local_irq_save(irq_flags);
479 483
480 for (j = 0; j < cpuc->n_events; j++) { 484 for (j = 0; j < cpuc->n_events; j++) {
481 if (event == cpuc->event[j]) { 485 if (event == cpuc->event[j]) {
@@ -501,8 +505,8 @@ static void alpha_pmu_disable(struct perf_event *event)
501 } 505 }
502 } 506 }
503 507
504 local_irq_restore(flags); 508 local_irq_restore(irq_flags);
505 perf_enable(); 509 perf_pmu_enable(event->pmu);
506} 510}
507 511
508 512
@@ -514,13 +518,44 @@ static void alpha_pmu_read(struct perf_event *event)
514} 518}
515 519
516 520
517static void alpha_pmu_unthrottle(struct perf_event *event) 521static void alpha_pmu_stop(struct perf_event *event, int flags)
522{
523 struct hw_perf_event *hwc = &event->hw;
524 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
525
526 if (!(hwc->state & PERF_HES_STOPPED)) {
527 cpuc->idx_mask &= ~(1UL<<hwc->idx);
528 hwc->state |= PERF_HES_STOPPED;
529 }
530
531 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
532 alpha_perf_event_update(event, hwc, hwc->idx, 0);
533 hwc->state |= PERF_HES_UPTODATE;
534 }
535
536 if (cpuc->enabled)
537 wrperfmon(PERFMON_CMD_DISABLE, (1UL<<hwc->idx));
538}
539
540
541static void alpha_pmu_start(struct perf_event *event, int flags)
518{ 542{
519 struct hw_perf_event *hwc = &event->hw; 543 struct hw_perf_event *hwc = &event->hw;
520 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 544 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
521 545
546 if (WARN_ON_ONCE(!(hwc->state & PERF_HES_STOPPED)))
547 return;
548
549 if (flags & PERF_EF_RELOAD) {
550 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
551 alpha_perf_event_set_period(event, hwc, hwc->idx);
552 }
553
554 hwc->state = 0;
555
522 cpuc->idx_mask |= 1UL<<hwc->idx; 556 cpuc->idx_mask |= 1UL<<hwc->idx;
523 wrperfmon(PERFMON_CMD_ENABLE, (1UL<<hwc->idx)); 557 if (cpuc->enabled)
558 wrperfmon(PERFMON_CMD_ENABLE, (1UL<<hwc->idx));
524} 559}
525 560
526 561
@@ -642,39 +677,36 @@ static int __hw_perf_event_init(struct perf_event *event)
642 return 0; 677 return 0;
643} 678}
644 679
645static const struct pmu pmu = {
646 .enable = alpha_pmu_enable,
647 .disable = alpha_pmu_disable,
648 .read = alpha_pmu_read,
649 .unthrottle = alpha_pmu_unthrottle,
650};
651
652
653/* 680/*
654 * Main entry point to initialise a HW performance event. 681 * Main entry point to initialise a HW performance event.
655 */ 682 */
656const struct pmu *hw_perf_event_init(struct perf_event *event) 683static int alpha_pmu_event_init(struct perf_event *event)
657{ 684{
658 int err; 685 int err;
659 686
687 switch (event->attr.type) {
688 case PERF_TYPE_RAW:
689 case PERF_TYPE_HARDWARE:
690 case PERF_TYPE_HW_CACHE:
691 break;
692
693 default:
694 return -ENOENT;
695 }
696
660 if (!alpha_pmu) 697 if (!alpha_pmu)
661 return ERR_PTR(-ENODEV); 698 return -ENODEV;
662 699
663 /* Do the real initialisation work. */ 700 /* Do the real initialisation work. */
664 err = __hw_perf_event_init(event); 701 err = __hw_perf_event_init(event);
665 702
666 if (err) 703 return err;
667 return ERR_PTR(err);
668
669 return &pmu;
670} 704}
671 705
672
673
674/* 706/*
675 * Main entry point - enable HW performance counters. 707 * Main entry point - enable HW performance counters.
676 */ 708 */
677void hw_perf_enable(void) 709static void alpha_pmu_enable(struct pmu *pmu)
678{ 710{
679 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 711 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
680 712
@@ -700,7 +732,7 @@ void hw_perf_enable(void)
700 * Main entry point - disable HW performance counters. 732 * Main entry point - disable HW performance counters.
701 */ 733 */
702 734
703void hw_perf_disable(void) 735static void alpha_pmu_disable(struct pmu *pmu)
704{ 736{
705 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 737 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
706 738
@@ -713,6 +745,17 @@ void hw_perf_disable(void)
713 wrperfmon(PERFMON_CMD_DISABLE, cpuc->idx_mask); 745 wrperfmon(PERFMON_CMD_DISABLE, cpuc->idx_mask);
714} 746}
715 747
748static struct pmu pmu = {
749 .pmu_enable = alpha_pmu_enable,
750 .pmu_disable = alpha_pmu_disable,
751 .event_init = alpha_pmu_event_init,
752 .add = alpha_pmu_add,
753 .del = alpha_pmu_del,
754 .start = alpha_pmu_start,
755 .stop = alpha_pmu_stop,
756 .read = alpha_pmu_read,
757};
758
716 759
717/* 760/*
718 * Main entry point - don't know when this is called but it 761 * Main entry point - don't know when this is called but it
@@ -766,7 +809,7 @@ static void alpha_perf_event_irq_handler(unsigned long la_ptr,
766 wrperfmon(PERFMON_CMD_DISABLE, cpuc->idx_mask); 809 wrperfmon(PERFMON_CMD_DISABLE, cpuc->idx_mask);
767 810
768 /* la_ptr is the counter that overflowed. */ 811 /* la_ptr is the counter that overflowed. */
769 if (unlikely(la_ptr >= perf_max_events)) { 812 if (unlikely(la_ptr >= alpha_pmu->num_pmcs)) {
770 /* This should never occur! */ 813 /* This should never occur! */
771 irq_err_count++; 814 irq_err_count++;
772 pr_warning("PMI: silly index %ld\n", la_ptr); 815 pr_warning("PMI: silly index %ld\n", la_ptr);
@@ -807,7 +850,7 @@ static void alpha_perf_event_irq_handler(unsigned long la_ptr,
807 /* Interrupts coming too quickly; "throttle" the 850 /* Interrupts coming too quickly; "throttle" the
808 * counter, i.e., disable it for a little while. 851 * counter, i.e., disable it for a little while.
809 */ 852 */
810 cpuc->idx_mask &= ~(1UL<<idx); 853 alpha_pmu_stop(event, 0);
811 } 854 }
812 } 855 }
813 wrperfmon(PERFMON_CMD_ENABLE, cpuc->idx_mask); 856 wrperfmon(PERFMON_CMD_ENABLE, cpuc->idx_mask);
@@ -837,6 +880,7 @@ void __init init_hw_perf_events(void)
837 880
838 /* And set up PMU specification */ 881 /* And set up PMU specification */
839 alpha_pmu = &ev67_pmu; 882 alpha_pmu = &ev67_pmu;
840 perf_max_events = alpha_pmu->num_pmcs; 883
884 perf_pmu_register(&pmu);
841} 885}
842 886
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index d290845aef59..6f7feb5db271 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -48,7 +48,7 @@ SYSCALL_DEFINE2(osf_sigprocmask, int, how, unsigned long, newmask)
48 sigset_t mask; 48 sigset_t mask;
49 unsigned long res; 49 unsigned long res;
50 50
51 siginitset(&mask, newmask & ~_BLOCKABLE); 51 siginitset(&mask, newmask & _BLOCKABLE);
52 res = sigprocmask(how, &mask, &oldmask); 52 res = sigprocmask(how, &mask, &oldmask);
53 if (!res) { 53 if (!res) {
54 force_successful_syscall_return(); 54 force_successful_syscall_return();
diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
index 396af1799ea4..0f1d8493cfca 100644
--- a/arch/alpha/kernel/time.c
+++ b/arch/alpha/kernel/time.c
@@ -41,7 +41,7 @@
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/bcd.h> 42#include <linux/bcd.h>
43#include <linux/profile.h> 43#include <linux/profile.h>
44#include <linux/perf_event.h> 44#include <linux/irq_work.h>
45 45
46#include <asm/uaccess.h> 46#include <asm/uaccess.h>
47#include <asm/io.h> 47#include <asm/io.h>
@@ -83,25 +83,25 @@ static struct {
83 83
84unsigned long est_cycle_freq; 84unsigned long est_cycle_freq;
85 85
86#ifdef CONFIG_PERF_EVENTS 86#ifdef CONFIG_IRQ_WORK
87 87
88DEFINE_PER_CPU(u8, perf_event_pending); 88DEFINE_PER_CPU(u8, irq_work_pending);
89 89
90#define set_perf_event_pending_flag() __get_cpu_var(perf_event_pending) = 1 90#define set_irq_work_pending_flag() __get_cpu_var(irq_work_pending) = 1
91#define test_perf_event_pending() __get_cpu_var(perf_event_pending) 91#define test_irq_work_pending() __get_cpu_var(irq_work_pending)
92#define clear_perf_event_pending() __get_cpu_var(perf_event_pending) = 0 92#define clear_irq_work_pending() __get_cpu_var(irq_work_pending) = 0
93 93
94void set_perf_event_pending(void) 94void set_irq_work_pending(void)
95{ 95{
96 set_perf_event_pending_flag(); 96 set_irq_work_pending_flag();
97} 97}
98 98
99#else /* CONFIG_PERF_EVENTS */ 99#else /* CONFIG_IRQ_WORK */
100 100
101#define test_perf_event_pending() 0 101#define test_irq_work_pending() 0
102#define clear_perf_event_pending() 102#define clear_irq_work_pending()
103 103
104#endif /* CONFIG_PERF_EVENTS */ 104#endif /* CONFIG_IRQ_WORK */
105 105
106 106
107static inline __u32 rpcc(void) 107static inline __u32 rpcc(void)
@@ -191,9 +191,9 @@ irqreturn_t timer_interrupt(int irq, void *dev)
191 191
192 write_sequnlock(&xtime_lock); 192 write_sequnlock(&xtime_lock);
193 193
194 if (test_perf_event_pending()) { 194 if (test_irq_work_pending()) {
195 clear_perf_event_pending(); 195 clear_irq_work_pending();
196 perf_event_do_pending(); 196 irq_work_run();
197 } 197 }
198 198
199#ifndef CONFIG_SMP 199#ifndef CONFIG_SMP
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 88c97bc7a6f5..b64e465ac49c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -19,13 +19,17 @@ config ARM
19 select HAVE_KPROBES if (!XIP_KERNEL) 19 select HAVE_KPROBES if (!XIP_KERNEL)
20 select HAVE_KRETPROBES if (HAVE_KPROBES) 20 select HAVE_KRETPROBES if (HAVE_KPROBES)
21 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL) 21 select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)
22 select HAVE_FTRACE_MCOUNT_RECORD if (!XIP_KERNEL)
23 select HAVE_DYNAMIC_FTRACE if (!XIP_KERNEL)
22 select HAVE_GENERIC_DMA_COHERENT 24 select HAVE_GENERIC_DMA_COHERENT
23 select HAVE_KERNEL_GZIP 25 select HAVE_KERNEL_GZIP
24 select HAVE_KERNEL_LZO 26 select HAVE_KERNEL_LZO
25 select HAVE_KERNEL_LZMA 27 select HAVE_KERNEL_LZMA
28 select HAVE_IRQ_WORK
26 select HAVE_PERF_EVENTS 29 select HAVE_PERF_EVENTS
27 select PERF_USE_VMALLOC 30 select PERF_USE_VMALLOC
28 select HAVE_REGS_AND_STACK_ACCESS_API 31 select HAVE_REGS_AND_STACK_ACCESS_API
32 select HAVE_HW_BREAKPOINT if (PERF_EVENTS && (CPU_V6 || CPU_V7))
29 help 33 help
30 The ARM series is a line of low-power-consumption RISC chip designs 34 The ARM series is a line of low-power-consumption RISC chip designs
31 licensed by ARM Ltd and targeted at embedded applications and 35 licensed by ARM Ltd and targeted at embedded applications and
@@ -145,6 +149,9 @@ config ARCH_HAS_CPUFREQ
145 and that the relevant menu configurations are displayed for 149 and that the relevant menu configurations are displayed for
146 it. 150 it.
147 151
152config ARCH_HAS_CPU_IDLE_WAIT
153 def_bool y
154
148config GENERIC_HWEIGHT 155config GENERIC_HWEIGHT
149 bool 156 bool
150 default y 157 default y
@@ -510,6 +517,7 @@ config ARCH_MMP
510 select GENERIC_CLOCKEVENTS 517 select GENERIC_CLOCKEVENTS
511 select TICK_ONESHOT 518 select TICK_ONESHOT
512 select PLAT_PXA 519 select PLAT_PXA
520 select SPARSE_IRQ
513 help 521 help
514 Support for Marvell's PXA168/PXA910(MMP) and MMP2 processor line. 522 Support for Marvell's PXA168/PXA910(MMP) and MMP2 processor line.
515 523
@@ -587,6 +595,7 @@ config ARCH_PXA
587 select GENERIC_CLOCKEVENTS 595 select GENERIC_CLOCKEVENTS
588 select TICK_ONESHOT 596 select TICK_ONESHOT
589 select PLAT_PXA 597 select PLAT_PXA
598 select SPARSE_IRQ
590 help 599 help
591 Support for Intel/Marvell's PXA2xx/PXA3xx processor line. 600 Support for Intel/Marvell's PXA2xx/PXA3xx processor line.
592 601
@@ -678,8 +687,8 @@ config ARCH_S3C64XX
678 help 687 help
679 Samsung S3C64XX series based systems 688 Samsung S3C64XX series based systems
680 689
681config ARCH_S5P6440 690config ARCH_S5P64X0
682 bool "Samsung S5P6440" 691 bool "Samsung S5P6440 S5P6450"
683 select CPU_V6 692 select CPU_V6
684 select GENERIC_GPIO 693 select GENERIC_GPIO
685 select HAVE_CLK 694 select HAVE_CLK
@@ -688,7 +697,8 @@ config ARCH_S5P6440
688 select HAVE_S3C2410_I2C 697 select HAVE_S3C2410_I2C
689 select HAVE_S3C_RTC 698 select HAVE_S3C_RTC
690 help 699 help
691 Samsung S5P6440 CPU based systems 700 Samsung S5P64X0 CPU based systems, such as the Samsung SMDK6440,
701 SMDK6450.
692 702
693config ARCH_S5P6442 703config ARCH_S5P6442
694 bool "Samsung S5P6442" 704 bool "Samsung S5P6442"
@@ -747,6 +757,15 @@ config ARCH_SHARK
747 Support for the StrongARM based Digital DNARD machine, also known 757 Support for the StrongARM based Digital DNARD machine, also known
748 as "Shark" (<http://www.shark-linux.de/shark.html>). 758 as "Shark" (<http://www.shark-linux.de/shark.html>).
749 759
760config ARCH_TCC_926
761 bool "Telechips TCC ARM926-based systems"
762 select CPU_ARM926T
763 select HAVE_CLK
764 select COMMON_CLKDEV
765 select GENERIC_CLOCKEVENTS
766 help
767 Support for Telechips TCC ARM926-based systems.
768
750config ARCH_LH7A40X 769config ARCH_LH7A40X
751 bool "Sharp LH7A40X" 770 bool "Sharp LH7A40X"
752 select CPU_ARM922T 771 select CPU_ARM922T
@@ -915,6 +934,8 @@ source "arch/arm/plat-s5p/Kconfig"
915 934
916source "arch/arm/plat-spear/Kconfig" 935source "arch/arm/plat-spear/Kconfig"
917 936
937source "arch/arm/plat-tcc/Kconfig"
938
918if ARCH_S3C2410 939if ARCH_S3C2410
919source "arch/arm/mach-s3c2400/Kconfig" 940source "arch/arm/mach-s3c2400/Kconfig"
920source "arch/arm/mach-s3c2410/Kconfig" 941source "arch/arm/mach-s3c2410/Kconfig"
@@ -928,7 +949,7 @@ if ARCH_S3C64XX
928source "arch/arm/mach-s3c64xx/Kconfig" 949source "arch/arm/mach-s3c64xx/Kconfig"
929endif 950endif
930 951
931source "arch/arm/mach-s5p6440/Kconfig" 952source "arch/arm/mach-s5p64x0/Kconfig"
932 953
933source "arch/arm/mach-s5p6442/Kconfig" 954source "arch/arm/mach-s5p6442/Kconfig"
934 955
@@ -1002,7 +1023,7 @@ endif
1002 1023
1003config ARM_ERRATA_411920 1024config ARM_ERRATA_411920
1004 bool "ARM errata: Invalidation of the Instruction Cache operation can fail" 1025 bool "ARM errata: Invalidation of the Instruction Cache operation can fail"
1005 depends on CPU_V6 && !SMP 1026 depends on CPU_V6
1006 help 1027 help
1007 Invalidation of the Instruction Cache operation can 1028 Invalidation of the Instruction Cache operation can
1008 fail. This erratum is present in 1136 (before r1p4), 1156 and 1176. 1029 fail. This erratum is present in 1136 (before r1p4), 1156 and 1176.
@@ -1101,6 +1122,20 @@ config ARM_ERRATA_720789
1101 invalidated are not, resulting in an incoherency in the system page 1122 invalidated are not, resulting in an incoherency in the system page
1102 tables. The workaround changes the TLB flushing routines to invalidate 1123 tables. The workaround changes the TLB flushing routines to invalidate
1103 entries regardless of the ASID. 1124 entries regardless of the ASID.
1125
1126config ARM_ERRATA_743622
1127 bool "ARM errata: Faulty hazard checking in the Store Buffer may lead to data corruption"
1128 depends on CPU_V7
1129 help
1130 This option enables the workaround for the 743622 Cortex-A9
1131 (r2p0..r2p2) erratum. Under very rare conditions, a faulty
1132 optimisation in the Cortex-A9 Store Buffer may lead to data
1133 corruption. This workaround sets a specific bit in the diagnostic
1134 register of the Cortex-A9 which disables the Store Buffer
1135 optimisation, preventing the defect from occurring. This has no
1136 visible impact on the overall performance or power consumption of the
1137 processor.
1138
1104endmenu 1139endmenu
1105 1140
1106source "arch/arm/common/Kconfig" 1141source "arch/arm/common/Kconfig"
@@ -1167,13 +1202,13 @@ source "kernel/time/Kconfig"
1167 1202
1168config SMP 1203config SMP
1169 bool "Symmetric Multi-Processing (EXPERIMENTAL)" 1204 bool "Symmetric Multi-Processing (EXPERIMENTAL)"
1170 depends on EXPERIMENTAL && (REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP ||\ 1205 depends on EXPERIMENTAL
1171 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 ||\
1172 ARCH_S5PV310 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4)
1173 depends on GENERIC_CLOCKEVENTS 1206 depends on GENERIC_CLOCKEVENTS
1207 depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
1208 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 ||\
1209 ARCH_S5PV310 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4
1174 select USE_GENERIC_SMP_HELPERS 1210 select USE_GENERIC_SMP_HELPERS
1175 select HAVE_ARM_SCU if ARCH_REALVIEW || ARCH_OMAP4 || ARCH_S5PV310 ||\ 1211 select HAVE_ARM_SCU
1176 ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4
1177 help 1212 help
1178 This enables support for systems with more than one CPU. If you have 1213 This enables support for systems with more than one CPU. If you have
1179 a system with only one CPU, like most personal computers, say N. If 1214 a system with only one CPU, like most personal computers, say N. If
@@ -1187,10 +1222,23 @@ config SMP
1187 1222
1188 See also <file:Documentation/i386/IO-APIC.txt>, 1223 See also <file:Documentation/i386/IO-APIC.txt>,
1189 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at 1224 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
1190 <http://www.linuxdoc.org/docs.html#howto>. 1225 <http://tldp.org/HOWTO/SMP-HOWTO.html>.
1191 1226
1192 If you don't know what to do here, say N. 1227 If you don't know what to do here, say N.
1193 1228
1229config SMP_ON_UP
1230 bool "Allow booting SMP kernel on uniprocessor systems (EXPERIMENTAL)"
1231 depends on EXPERIMENTAL
1232 depends on SMP && !XIP && !THUMB2_KERNEL
1233 default y
1234 help
1235 SMP kernels contain instructions which fail on non-SMP processors.
1236 Enabling this option allows the kernel to modify itself to make
1237 these instructions safe. Disabling it allows about 1K of space
1238 savings.
1239
1240 If you don't know what to do here, say Y.
1241
1194config HAVE_ARM_SCU 1242config HAVE_ARM_SCU
1195 bool 1243 bool
1196 depends on SMP 1244 depends on SMP
@@ -1241,12 +1289,9 @@ config HOTPLUG_CPU
1241 1289
1242config LOCAL_TIMERS 1290config LOCAL_TIMERS
1243 bool "Use local timer interrupts" 1291 bool "Use local timer interrupts"
1244 depends on SMP && (REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || \ 1292 depends on SMP
1245 REALVIEW_EB_A9MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
1246 ARCH_S5PV310 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4)
1247 default y 1293 default y
1248 select HAVE_ARM_TWD if ARCH_REALVIEW || ARCH_OMAP4 || ARCH_S5PV310 || \ 1294 select HAVE_ARM_TWD
1249 ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS
1250 help 1295 help
1251 Enable support for local timers on SMP platforms, rather then the 1296 Enable support for local timers on SMP platforms, rather then the
1252 legacy IPI broadcast method. Local timers allows the system 1297 legacy IPI broadcast method. Local timers allows the system
@@ -1257,7 +1302,7 @@ source kernel/Kconfig.preempt
1257 1302
1258config HZ 1303config HZ
1259 int 1304 int
1260 default 200 if ARCH_EBSA110 || ARCH_S3C2410 || ARCH_S5P6440 || \ 1305 default 200 if ARCH_EBSA110 || ARCH_S3C2410 || ARCH_S5P64X0 || \
1261 ARCH_S5P6442 || ARCH_S5PV210 || ARCH_S5PV310 1306 ARCH_S5P6442 || ARCH_S5PV210 || ARCH_S5PV310
1262 default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER 1307 default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER
1263 default AT91_TIMER_HZ if ARCH_AT91 1308 default AT91_TIMER_HZ if ARCH_AT91
@@ -1463,6 +1508,20 @@ config UACCESS_WITH_MEMCPY
1463 However, if the CPU data cache is using a write-allocate mode, 1508 However, if the CPU data cache is using a write-allocate mode,
1464 this option is unlikely to provide any performance gain. 1509 this option is unlikely to provide any performance gain.
1465 1510
1511config SECCOMP
1512 bool
1513 prompt "Enable seccomp to safely compute untrusted bytecode"
1514 ---help---
1515 This kernel feature is useful for number crunching applications
1516 that may need to compute untrusted bytecode during their
1517 execution. By using pipes or other transports made available to
1518 the process as file descriptors supporting the read/write
1519 syscalls, it's possible to isolate those applications in
1520 their own address space using seccomp. Once seccomp is
1521 enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1522 and the task is only allowed to execute a few safe syscalls
1523 defined by each seccomp mode.
1524
1466config CC_STACKPROTECTOR 1525config CC_STACKPROTECTOR
1467 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" 1526 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
1468 help 1527 help
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 91344af75f39..2fd0b99afc4b 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -2,6 +2,20 @@ menu "Kernel hacking"
2 2
3source "lib/Kconfig.debug" 3source "lib/Kconfig.debug"
4 4
5config STRICT_DEVMEM
6 bool "Filter access to /dev/mem"
7 depends on MMU
8 ---help---
9 If this option is disabled, you allow userspace (root) access to all
10 of memory, including kernel and userspace memory. Accidental
11 access to this is obviously disastrous, but specific access can
12 be used by people debugging the kernel.
13
14 If this option is switched on, the /dev/mem file only allows
15 userspace access to memory mapped peripherals.
16
17 If in doubt, say Y.
18
5# RMK wants arm kernels compiled with frame pointers or stack unwinding. 19# RMK wants arm kernels compiled with frame pointers or stack unwinding.
6# If you know what you are doing and are willing to live without stack 20# If you know what you are doing and are willing to live without stack
7# traces, you can get a slightly smaller kernel by setting this option to 21# traces, you can get a slightly smaller kernel by setting this option to
@@ -27,6 +41,11 @@ config ARM_UNWIND
27 the performance is not affected. Currently, this feature 41 the performance is not affected. Currently, this feature
28 only works with EABI compilers. If unsure say Y. 42 only works with EABI compilers. If unsure say Y.
29 43
44config OLD_MCOUNT
45 bool
46 depends on FUNCTION_TRACER && FRAME_POINTER
47 default y
48
30config DEBUG_USER 49config DEBUG_USER
31 bool "Verbose user fault messages" 50 bool "Verbose user fault messages"
32 help 51 help
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 59c1ce858fc8..b87aed028eef 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -173,7 +173,7 @@ machine-$(CONFIG_ARCH_RPC) := rpc
173machine-$(CONFIG_ARCH_S3C2410) := s3c2410 s3c2400 s3c2412 s3c2416 s3c2440 s3c2443 173machine-$(CONFIG_ARCH_S3C2410) := s3c2410 s3c2400 s3c2412 s3c2416 s3c2440 s3c2443
174machine-$(CONFIG_ARCH_S3C24A0) := s3c24a0 174machine-$(CONFIG_ARCH_S3C24A0) := s3c24a0
175machine-$(CONFIG_ARCH_S3C64XX) := s3c64xx 175machine-$(CONFIG_ARCH_S3C64XX) := s3c64xx
176machine-$(CONFIG_ARCH_S5P6440) := s5p6440 176machine-$(CONFIG_ARCH_S5P64X0) := s5p64x0
177machine-$(CONFIG_ARCH_S5P6442) := s5p6442 177machine-$(CONFIG_ARCH_S5P6442) := s5p6442
178machine-$(CONFIG_ARCH_S5PC100) := s5pc100 178machine-$(CONFIG_ARCH_S5PC100) := s5pc100
179machine-$(CONFIG_ARCH_S5PV210) := s5pv210 179machine-$(CONFIG_ARCH_S5PV210) := s5pv210
@@ -183,6 +183,7 @@ machine-$(CONFIG_ARCH_SHARK) := shark
183machine-$(CONFIG_ARCH_SHMOBILE) := shmobile 183machine-$(CONFIG_ARCH_SHMOBILE) := shmobile
184machine-$(CONFIG_ARCH_STMP378X) := stmp378x 184machine-$(CONFIG_ARCH_STMP378X) := stmp378x
185machine-$(CONFIG_ARCH_STMP37XX) := stmp37xx 185machine-$(CONFIG_ARCH_STMP37XX) := stmp37xx
186machine-$(CONFIG_ARCH_TCC8K) := tcc8k
186machine-$(CONFIG_ARCH_TEGRA) := tegra 187machine-$(CONFIG_ARCH_TEGRA) := tegra
187machine-$(CONFIG_ARCH_U300) := u300 188machine-$(CONFIG_ARCH_U300) := u300
188machine-$(CONFIG_ARCH_U8500) := ux500 189machine-$(CONFIG_ARCH_U8500) := ux500
@@ -202,6 +203,7 @@ plat-$(CONFIG_ARCH_MXC) := mxc
202plat-$(CONFIG_ARCH_OMAP) := omap 203plat-$(CONFIG_ARCH_OMAP) := omap
203plat-$(CONFIG_ARCH_S3C64XX) := samsung 204plat-$(CONFIG_ARCH_S3C64XX) := samsung
204plat-$(CONFIG_ARCH_STMP3XXX) := stmp3xxx 205plat-$(CONFIG_ARCH_STMP3XXX) := stmp3xxx
206plat-$(CONFIG_ARCH_TCC_926) := tcc
205plat-$(CONFIG_PLAT_IOP) := iop 207plat-$(CONFIG_PLAT_IOP) := iop
206plat-$(CONFIG_PLAT_NOMADIK) := nomadik 208plat-$(CONFIG_PLAT_NOMADIK) := nomadik
207plat-$(CONFIG_PLAT_ORION) := orion 209plat-$(CONFIG_PLAT_ORION) := orion
@@ -245,13 +247,14 @@ ifeq ($(FASTFPE),$(wildcard $(FASTFPE)))
245FASTFPE_OBJ :=$(FASTFPE)/ 247FASTFPE_OBJ :=$(FASTFPE)/
246endif 248endif
247 249
248# If we have a machine-specific directory, then include it in the build.
249core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
250core-y += $(machdirs) $(platdirs)
251core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/ 250core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/
252core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ) 251core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ)
253core-$(CONFIG_VFP) += arch/arm/vfp/ 252core-$(CONFIG_VFP) += arch/arm/vfp/
254 253
254# If we have a machine-specific directory, then include it in the build.
255core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
256core-y += $(machdirs) $(platdirs)
257
255drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ 258drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/
256 259
257libs-y := arch/arm/lib/ $(libs-y) 260libs-y := arch/arm/lib/ $(libs-y)
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 7dfa9a85bc0c..ada6359160eb 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -67,25 +67,11 @@ static inline unsigned int gic_irq(unsigned int irq)
67 67
68/* 68/*
69 * Routines to acknowledge, disable and enable interrupts 69 * Routines to acknowledge, disable and enable interrupts
70 *
71 * Linux assumes that when we're done with an interrupt we need to
72 * unmask it, in the same way we need to unmask an interrupt when
73 * we first enable it.
74 *
75 * The GIC has a separate notion of "end of interrupt" to re-enable
76 * an interrupt after handling, in order to support hardware
77 * prioritisation.
78 *
79 * We can make the GIC behave in the way that Linux expects by making
80 * our "acknowledge" routine disable the interrupt, then mark it as
81 * complete.
82 */ 70 */
83static void gic_ack_irq(unsigned int irq) 71static void gic_ack_irq(unsigned int irq)
84{ 72{
85 u32 mask = 1 << (irq % 32);
86 73
87 spin_lock(&irq_controller_lock); 74 spin_lock(&irq_controller_lock);
88 writel(mask, gic_dist_base(irq) + GIC_DIST_ENABLE_CLEAR + (gic_irq(irq) / 32) * 4);
89 writel(gic_irq(irq), gic_cpu_base(irq) + GIC_CPU_EOI); 75 writel(gic_irq(irq), gic_cpu_base(irq) + GIC_CPU_EOI);
90 spin_unlock(&irq_controller_lock); 76 spin_unlock(&irq_controller_lock);
91} 77}
diff --git a/arch/arm/common/icst.c b/arch/arm/common/icst.c
index 9a7f09cff300..2dc6da70ae59 100644
--- a/arch/arm/common/icst.c
+++ b/arch/arm/common/icst.c
@@ -8,7 +8,7 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * Support functions for calculating clocks/divisors for the ICST307 10 * Support functions for calculating clocks/divisors for the ICST307
11 * clock generators. See http://www.icst.com/ for more information 11 * clock generators. See http://www.idt.com/ for more information
12 * on these devices. 12 * on these devices.
13 * 13 *
14 * This is an almost identical implementation to the ICST525 clock generator. 14 * This is an almost identical implementation to the ICST525 clock generator.
diff --git a/arch/arm/common/pl330.c b/arch/arm/common/pl330.c
index 5ebbab6242a7..8f0f86db3602 100644
--- a/arch/arm/common/pl330.c
+++ b/arch/arm/common/pl330.c
@@ -146,8 +146,7 @@
146#define DESIGNER 0x41 146#define DESIGNER 0x41
147#define REVISION 0x0 147#define REVISION 0x0
148#define INTEG_CFG 0x0 148#define INTEG_CFG 0x0
149#define PERIPH_ID_VAL ((PART << 0) | (DESIGNER << 12) \ 149#define PERIPH_ID_VAL ((PART << 0) | (DESIGNER << 12))
150 | (REVISION << 20) | (INTEG_CFG << 24))
151 150
152#define PCELL_ID_VAL 0xb105f00d 151#define PCELL_ID_VAL 0xb105f00d
153 152
@@ -1859,10 +1858,10 @@ int pl330_add(struct pl330_info *pi)
1859 regs = pi->base; 1858 regs = pi->base;
1860 1859
1861 /* Check if we can handle this DMAC */ 1860 /* Check if we can handle this DMAC */
1862 if (get_id(pi, PERIPH_ID) != PERIPH_ID_VAL 1861 if ((get_id(pi, PERIPH_ID) & 0xfffff) != PERIPH_ID_VAL
1863 || get_id(pi, PCELL_ID) != PCELL_ID_VAL) { 1862 || get_id(pi, PCELL_ID) != PCELL_ID_VAL) {
1864 dev_err(pi->dev, "PERIPH_ID 0x%x, PCELL_ID 0x%x !\n", 1863 dev_err(pi->dev, "PERIPH_ID 0x%x, PCELL_ID 0x%x !\n",
1865 readl(regs + PERIPH_ID), readl(regs + PCELL_ID)); 1864 get_id(pi, PERIPH_ID), get_id(pi, PCELL_ID));
1866 return -EINVAL; 1865 return -EINVAL;
1867 } 1866 }
1868 1867
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 517d50ddbeb3..c0258a8c103b 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -678,7 +678,7 @@ out:
678 * %-EBUSY physical address already marked in-use. 678 * %-EBUSY physical address already marked in-use.
679 * %0 successful. 679 * %0 successful.
680 */ 680 */
681static int 681static int __devinit
682__sa1111_probe(struct device *me, struct resource *mem, int irq) 682__sa1111_probe(struct device *me, struct resource *mem, int irq)
683{ 683{
684 struct sa1111 *sachip; 684 struct sa1111 *sachip;
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index 9012004321dd..c11af1e4bad3 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -44,12 +44,12 @@ void reset_scoop(struct device *dev)
44{ 44{
45 struct scoop_dev *sdev = dev_get_drvdata(dev); 45 struct scoop_dev *sdev = dev_get_drvdata(dev);
46 46
47 iowrite16(0x0100, sdev->base + SCOOP_MCR); // 00 47 iowrite16(0x0100, sdev->base + SCOOP_MCR); /* 00 */
48 iowrite16(0x0000, sdev->base + SCOOP_CDR); // 04 48 iowrite16(0x0000, sdev->base + SCOOP_CDR); /* 04 */
49 iowrite16(0x0000, sdev->base + SCOOP_CCR); // 10 49 iowrite16(0x0000, sdev->base + SCOOP_CCR); /* 10 */
50 iowrite16(0x0000, sdev->base + SCOOP_IMR); // 18 50 iowrite16(0x0000, sdev->base + SCOOP_IMR); /* 18 */
51 iowrite16(0x00FF, sdev->base + SCOOP_IRM); // 14 51 iowrite16(0x00FF, sdev->base + SCOOP_IRM); /* 14 */
52 iowrite16(0x0000, sdev->base + SCOOP_ISR); // 1C 52 iowrite16(0x0000, sdev->base + SCOOP_ISR); /* 1C */
53 iowrite16(0x0000, sdev->base + SCOOP_IRM); 53 iowrite16(0x0000, sdev->base + SCOOP_IRM);
54} 54}
55 55
diff --git a/arch/arm/common/uengine.c b/arch/arm/common/uengine.c
index b520e56216a9..bef408f3d76c 100644
--- a/arch/arm/common/uengine.c
+++ b/arch/arm/common/uengine.c
@@ -312,16 +312,16 @@ static void generate_ucode(u8 *ucode, u32 *gpr_a, u32 *gpr_b)
312 b1 = (gpr_a[i] >> 8) & 0xff; 312 b1 = (gpr_a[i] >> 8) & 0xff;
313 b0 = gpr_a[i] & 0xff; 313 b0 = gpr_a[i] & 0xff;
314 314
315 // immed[@ai, (b1 << 8) | b0] 315 /* immed[@ai, (b1 << 8) | b0] */
316 // 11110000 0000VVVV VVVV11VV VVVVVV00 1IIIIIII 316 /* 11110000 0000VVVV VVVV11VV VVVVVV00 1IIIIIII */
317 ucode[offset++] = 0xf0; 317 ucode[offset++] = 0xf0;
318 ucode[offset++] = (b1 >> 4); 318 ucode[offset++] = (b1 >> 4);
319 ucode[offset++] = (b1 << 4) | 0x0c | (b0 >> 6); 319 ucode[offset++] = (b1 << 4) | 0x0c | (b0 >> 6);
320 ucode[offset++] = (b0 << 2); 320 ucode[offset++] = (b0 << 2);
321 ucode[offset++] = 0x80 | i; 321 ucode[offset++] = 0x80 | i;
322 322
323 // immed_w1[@ai, (b3 << 8) | b2] 323 /* immed_w1[@ai, (b3 << 8) | b2] */
324 // 11110100 0100VVVV VVVV11VV VVVVVV00 1IIIIIII 324 /* 11110100 0100VVVV VVVV11VV VVVVVV00 1IIIIIII */
325 ucode[offset++] = 0xf4; 325 ucode[offset++] = 0xf4;
326 ucode[offset++] = 0x40 | (b3 >> 4); 326 ucode[offset++] = 0x40 | (b3 >> 4);
327 ucode[offset++] = (b3 << 4) | 0x0c | (b2 >> 6); 327 ucode[offset++] = (b3 << 4) | 0x0c | (b2 >> 6);
@@ -340,16 +340,16 @@ static void generate_ucode(u8 *ucode, u32 *gpr_a, u32 *gpr_b)
340 b1 = (gpr_b[i] >> 8) & 0xff; 340 b1 = (gpr_b[i] >> 8) & 0xff;
341 b0 = gpr_b[i] & 0xff; 341 b0 = gpr_b[i] & 0xff;
342 342
343 // immed[@bi, (b1 << 8) | b0] 343 /* immed[@bi, (b1 << 8) | b0] */
344 // 11110000 0000VVVV VVVV001I IIIIII11 VVVVVVVV 344 /* 11110000 0000VVVV VVVV001I IIIIII11 VVVVVVVV */
345 ucode[offset++] = 0xf0; 345 ucode[offset++] = 0xf0;
346 ucode[offset++] = (b1 >> 4); 346 ucode[offset++] = (b1 >> 4);
347 ucode[offset++] = (b1 << 4) | 0x02 | (i >> 6); 347 ucode[offset++] = (b1 << 4) | 0x02 | (i >> 6);
348 ucode[offset++] = (i << 2) | 0x03; 348 ucode[offset++] = (i << 2) | 0x03;
349 ucode[offset++] = b0; 349 ucode[offset++] = b0;
350 350
351 // immed_w1[@bi, (b3 << 8) | b2] 351 /* immed_w1[@bi, (b3 << 8) | b2] */
352 // 11110100 0100VVVV VVVV001I IIIIII11 VVVVVVVV 352 /* 11110100 0100VVVV VVVV001I IIIIII11 VVVVVVVV */
353 ucode[offset++] = 0xf4; 353 ucode[offset++] = 0xf4;
354 ucode[offset++] = 0x40 | (b3 >> 4); 354 ucode[offset++] = 0x40 | (b3 >> 4);
355 ucode[offset++] = (b3 << 4) | 0x02 | (i >> 6); 355 ucode[offset++] = (b3 << 4) | 0x02 | (i >> 6);
@@ -357,7 +357,7 @@ static void generate_ucode(u8 *ucode, u32 *gpr_a, u32 *gpr_b)
357 ucode[offset++] = b2; 357 ucode[offset++] = b2;
358 } 358 }
359 359
360 // ctx_arb[kill] 360 /* ctx_arb[kill] */
361 ucode[offset++] = 0xe0; 361 ucode[offset++] = 0xe0;
362 ucode[offset++] = 0x00; 362 ucode[offset++] = 0x00;
363 ucode[offset++] = 0x01; 363 ucode[offset++] = 0x01;
diff --git a/arch/arm/configs/at91sam9g20ek_defconfig b/arch/arm/configs/at91sam9g20ek_defconfig
index f1bac70d6ce9..9e90e6d79297 100644
--- a/arch/arm/configs/at91sam9g20ek_defconfig
+++ b/arch/arm/configs/at91sam9g20ek_defconfig
@@ -13,6 +13,7 @@ CONFIG_MODULE_UNLOAD=y
13CONFIG_ARCH_AT91=y 13CONFIG_ARCH_AT91=y
14CONFIG_ARCH_AT91SAM9G20=y 14CONFIG_ARCH_AT91SAM9G20=y
15CONFIG_MACH_AT91SAM9G20EK=y 15CONFIG_MACH_AT91SAM9G20EK=y
16CONFIG_MACH_AT91SAM9G20EK_2MMC=y
16CONFIG_AT91_PROGRAMMABLE_CLOCKS=y 17CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
17# CONFIG_ARM_THUMB is not set 18# CONFIG_ARM_THUMB is not set
18CONFIG_AEABI=y 19CONFIG_AEABI=y
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index ccc9c9959b82..2f7042813765 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -15,6 +15,7 @@ CONFIG_MACH_MV88F6281GTW_GE=y
15CONFIG_MACH_SHEEVAPLUG=y 15CONFIG_MACH_SHEEVAPLUG=y
16CONFIG_MACH_ESATA_SHEEVAPLUG=y 16CONFIG_MACH_ESATA_SHEEVAPLUG=y
17CONFIG_MACH_GURUPLUG=y 17CONFIG_MACH_GURUPLUG=y
18CONFIG_MACH_DOCKSTAR=y
18CONFIG_MACH_TS219=y 19CONFIG_MACH_TS219=y
19CONFIG_MACH_TS41X=y 20CONFIG_MACH_TS41X=y
20CONFIG_MACH_OPENRD_BASE=y 21CONFIG_MACH_OPENRD_BASE=y
diff --git a/arch/arm/configs/mx27_defconfig b/arch/arm/configs/mx27_defconfig
index b2038b0e266f..813cfb366c18 100644
--- a/arch/arm/configs/mx27_defconfig
+++ b/arch/arm/configs/mx27_defconfig
@@ -21,8 +21,14 @@ CONFIG_ARCH_MX2=y
21CONFIG_MACH_MX27=y 21CONFIG_MACH_MX27=y
22CONFIG_MACH_MX27ADS=y 22CONFIG_MACH_MX27ADS=y
23CONFIG_MACH_PCM038=y 23CONFIG_MACH_PCM038=y
24CONFIG_MACH_CPUIMX27=y
25CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2=y
26CONFIG_MACH_EUKREA_CPUIMX27_USEUART4=y
24CONFIG_MACH_MX27_3DS=y 27CONFIG_MACH_MX27_3DS=y
28CONFIG_MACH_IMX27_VISSTRIM_M10=y
25CONFIG_MACH_IMX27LITE=y 29CONFIG_MACH_IMX27LITE=y
30CONFIG_MACH_PCA100=y
31CONFIG_MACH_MXT_TD60=y
26CONFIG_MXC_IRQ_PRIOR=y 32CONFIG_MXC_IRQ_PRIOR=y
27CONFIG_MXC_PWM=y 33CONFIG_MXC_PWM=y
28CONFIG_NO_HZ=y 34CONFIG_NO_HZ=y
@@ -76,7 +82,9 @@ CONFIG_INPUT_EVDEV=y
76# CONFIG_INPUT_KEYBOARD is not set 82# CONFIG_INPUT_KEYBOARD is not set
77# CONFIG_INPUT_MOUSE is not set 83# CONFIG_INPUT_MOUSE is not set
78CONFIG_INPUT_TOUCHSCREEN=y 84CONFIG_INPUT_TOUCHSCREEN=y
85CONFIG_TOUCHSCREEN_ADS7846=m
79# CONFIG_SERIO is not set 86# CONFIG_SERIO is not set
87CONFIG_SERIAL_8250=m
80CONFIG_SERIAL_IMX=y 88CONFIG_SERIAL_IMX=y
81CONFIG_SERIAL_IMX_CONSOLE=y 89CONFIG_SERIAL_IMX_CONSOLE=y
82# CONFIG_LEGACY_PTYS is not set 90# CONFIG_LEGACY_PTYS is not set
@@ -85,19 +93,20 @@ CONFIG_I2C=y
85CONFIG_I2C_CHARDEV=y 93CONFIG_I2C_CHARDEV=y
86CONFIG_I2C_IMX=y 94CONFIG_I2C_IMX=y
87CONFIG_SPI=y 95CONFIG_SPI=y
88CONFIG_SPI_BITBANG=y 96CONFIG_SPI_IMX=y
89CONFIG_W1=y 97CONFIG_W1=y
90CONFIG_W1_MASTER_MXC=y 98CONFIG_W1_MASTER_MXC=y
91CONFIG_W1_SLAVE_THERM=y 99CONFIG_W1_SLAVE_THERM=y
92# CONFIG_HWMON is not set 100# CONFIG_HWMON is not set
93CONFIG_FB=y 101CONFIG_FB=y
94CONFIG_FB_IMX=y 102CONFIG_FB_IMX=y
95# CONFIG_VGA_CONSOLE is not set
96CONFIG_FRAMEBUFFER_CONSOLE=y 103CONFIG_FRAMEBUFFER_CONSOLE=y
97CONFIG_FONTS=y 104CONFIG_FONTS=y
98CONFIG_FONT_8x8=y 105CONFIG_FONT_8x8=y
99# CONFIG_HID_SUPPORT is not set 106# CONFIG_HID_SUPPORT is not set
100# CONFIG_USB_SUPPORT is not set 107CONFIG_USB=m
108# CONFIG_USB_DEVICE_CLASS is not set
109CONFIG_USB_ULPI=y
101CONFIG_MMC=y 110CONFIG_MMC=y
102CONFIG_MMC_MXC=y 111CONFIG_MMC_MXC=y
103CONFIG_RTC_CLASS=y 112CONFIG_RTC_CLASS=y
diff --git a/arch/arm/configs/mx31pdk_defconfig b/arch/arm/configs/mx31pdk_defconfig
deleted file mode 100644
index 2d29329749e4..000000000000
--- a/arch/arm/configs/mx31pdk_defconfig
+++ /dev/null
@@ -1,44 +0,0 @@
1# CONFIG_LOCALVERSION_AUTO is not set
2# CONFIG_SWAP is not set
3# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
4# CONFIG_COMPAT_BRK is not set
5# CONFIG_IOSCHED_DEADLINE is not set
6# CONFIG_IOSCHED_CFQ is not set
7CONFIG_ARCH_MXC=y
8# CONFIG_MACH_MX31ADS is not set
9CONFIG_MACH_MX31_3DS=y
10CONFIG_AEABI=y
11CONFIG_NET=y
12CONFIG_PACKET=y
13CONFIG_UNIX=y
14CONFIG_NET_KEY=y
15CONFIG_INET=y
16CONFIG_IP_PNP=y
17CONFIG_IP_PNP_DHCP=y
18# CONFIG_INET_LRO is not set
19CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
20# CONFIG_PREVENT_FIRMWARE_BUILD is not set
21# CONFIG_FIRMWARE_IN_KERNEL is not set
22# CONFIG_BLK_DEV is not set
23# CONFIG_MISC_DEVICES is not set
24CONFIG_NETDEVICES=y
25CONFIG_NET_ETHERNET=y
26# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
27# CONFIG_INPUT_KEYBOARD is not set
28# CONFIG_INPUT_MOUSE is not set
29# CONFIG_SERIO is not set
30# CONFIG_DEVKMEM is not set
31CONFIG_SERIAL_IMX=y
32CONFIG_SERIAL_IMX_CONSOLE=y
33# CONFIG_LEGACY_PTYS is not set
34# CONFIG_HW_RANDOM is not set
35# CONFIG_HWMON is not set
36# CONFIG_VGA_CONSOLE is not set
37# CONFIG_HID_SUPPORT is not set
38# CONFIG_USB_SUPPORT is not set
39# CONFIG_DNOTIFY is not set
40# CONFIG_ENABLE_WARN_DEPRECATED is not set
41# CONFIG_ENABLE_MUST_CHECK is not set
42# CONFIG_RCU_CPU_STALL_DETECTOR is not set
43# CONFIG_CRYPTO_ANSI_CPRNG is not set
44# CONFIG_CRC32 is not set
diff --git a/arch/arm/configs/mx3_defconfig b/arch/arm/configs/mx3_defconfig
index 161f907b611f..f0c339fd5d21 100644
--- a/arch/arm/configs/mx3_defconfig
+++ b/arch/arm/configs/mx3_defconfig
@@ -24,6 +24,7 @@ CONFIG_MACH_PCM043=y
24CONFIG_MACH_ARMADILLO5X0=y 24CONFIG_MACH_ARMADILLO5X0=y
25CONFIG_MACH_MX35_3DS=y 25CONFIG_MACH_MX35_3DS=y
26CONFIG_MACH_KZM_ARM11_01=y 26CONFIG_MACH_KZM_ARM11_01=y
27CONFIG_MACH_EUKREA_CPUIMX35=y
27CONFIG_MXC_IRQ_PRIOR=y 28CONFIG_MXC_IRQ_PRIOR=y
28CONFIG_MXC_PWM=y 29CONFIG_MXC_PWM=y
29CONFIG_NO_HZ=y 30CONFIG_NO_HZ=y
@@ -108,7 +109,6 @@ CONFIG_MMC=y
108CONFIG_MMC_MXC=y 109CONFIG_MMC_MXC=y
109CONFIG_DMADEVICES=y 110CONFIG_DMADEVICES=y
110# CONFIG_DNOTIFY is not set 111# CONFIG_DNOTIFY is not set
111CONFIG_INOTIFY=y
112CONFIG_TMPFS=y 112CONFIG_TMPFS=y
113CONFIG_JFFS2_FS=y 113CONFIG_JFFS2_FS=y
114CONFIG_UBIFS_FS=y 114CONFIG_UBIFS_FS=y
diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
index a665ecbbe2bc..163cfee7644c 100644
--- a/arch/arm/configs/mx51_defconfig
+++ b/arch/arm/configs/mx51_defconfig
@@ -15,6 +15,8 @@ CONFIG_MODULE_SRCVERSION_ALL=y
15CONFIG_ARCH_MXC=y 15CONFIG_ARCH_MXC=y
16CONFIG_ARCH_MX5=y 16CONFIG_ARCH_MX5=y
17CONFIG_MACH_MX51_BABBAGE=y 17CONFIG_MACH_MX51_BABBAGE=y
18CONFIG_MACH_MX51_3DS=y
19CONFIG_MACH_EUKREA_CPUIMX51=y
18CONFIG_NO_HZ=y 20CONFIG_NO_HZ=y
19CONFIG_HIGH_RES_TIMERS=y 21CONFIG_HIGH_RES_TIMERS=y
20CONFIG_PREEMPT_VOLUNTARY=y 22CONFIG_PREEMPT_VOLUNTARY=y
@@ -69,7 +71,6 @@ CONFIG_REALTEK_PHY=y
69CONFIG_NATIONAL_PHY=y 71CONFIG_NATIONAL_PHY=y
70CONFIG_STE10XP=y 72CONFIG_STE10XP=y
71CONFIG_LSI_ET1011C_PHY=y 73CONFIG_LSI_ET1011C_PHY=y
72CONFIG_FIXED_PHY=y
73CONFIG_MDIO_BITBANG=y 74CONFIG_MDIO_BITBANG=y
74CONFIG_MDIO_GPIO=y 75CONFIG_MDIO_GPIO=y
75CONFIG_NET_ETHERNET=y 76CONFIG_NET_ETHERNET=y
@@ -100,7 +101,6 @@ CONFIG_I2C_ALGOPCF=m
100CONFIG_I2C_ALGOPCA=m 101CONFIG_I2C_ALGOPCA=m
101CONFIG_GPIO_SYSFS=y 102CONFIG_GPIO_SYSFS=y
102# CONFIG_HWMON is not set 103# CONFIG_HWMON is not set
103# CONFIG_VGA_CONSOLE is not set
104# CONFIG_HID_SUPPORT is not set 104# CONFIG_HID_SUPPORT is not set
105CONFIG_USB=y 105CONFIG_USB=y
106CONFIG_USB_EHCI_HCD=y 106CONFIG_USB_EHCI_HCD=y
@@ -117,13 +117,11 @@ CONFIG_EXT2_FS_XATTR=y
117CONFIG_EXT2_FS_POSIX_ACL=y 117CONFIG_EXT2_FS_POSIX_ACL=y
118CONFIG_EXT2_FS_SECURITY=y 118CONFIG_EXT2_FS_SECURITY=y
119CONFIG_EXT3_FS=y 119CONFIG_EXT3_FS=y
120CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
121CONFIG_EXT3_FS_POSIX_ACL=y 120CONFIG_EXT3_FS_POSIX_ACL=y
122CONFIG_EXT3_FS_SECURITY=y 121CONFIG_EXT3_FS_SECURITY=y
123CONFIG_EXT4_FS=y 122CONFIG_EXT4_FS=y
124CONFIG_EXT4_FS_POSIX_ACL=y 123CONFIG_EXT4_FS_POSIX_ACL=y
125CONFIG_EXT4_FS_SECURITY=y 124CONFIG_EXT4_FS_SECURITY=y
126CONFIG_INOTIFY=y
127CONFIG_QUOTA=y 125CONFIG_QUOTA=y
128CONFIG_QUOTA_NETLINK_INTERFACE=y 126CONFIG_QUOTA_NETLINK_INTERFACE=y
129# CONFIG_PRINT_QUOTA_WARNING is not set 127# CONFIG_PRINT_QUOTA_WARNING is not set
@@ -136,6 +134,7 @@ CONFIG_ZISOFS=y
136CONFIG_UDF_FS=m 134CONFIG_UDF_FS=m
137CONFIG_MSDOS_FS=m 135CONFIG_MSDOS_FS=m
138CONFIG_VFAT_FS=y 136CONFIG_VFAT_FS=y
137CONFIG_TMPFS=y
139CONFIG_CONFIGFS_FS=m 138CONFIG_CONFIGFS_FS=m
140CONFIG_NFS_FS=y 139CONFIG_NFS_FS=y
141CONFIG_NFS_V3=y 140CONFIG_NFS_V3=y
@@ -151,7 +150,6 @@ CONFIG_NLS_UTF8=y
151CONFIG_MAGIC_SYSRQ=y 150CONFIG_MAGIC_SYSRQ=y
152CONFIG_DEBUG_FS=y 151CONFIG_DEBUG_FS=y
153CONFIG_DEBUG_KERNEL=y 152CONFIG_DEBUG_KERNEL=y
154# CONFIG_DETECT_SOFTLOCKUP is not set
155# CONFIG_SCHED_DEBUG is not set 153# CONFIG_SCHED_DEBUG is not set
156# CONFIG_DEBUG_BUGVERBOSE is not set 154# CONFIG_DEBUG_BUGVERBOSE is not set
157# CONFIG_RCU_CPU_STALL_DETECTOR is not set 155# CONFIG_RCU_CPU_STALL_DETECTOR is not set
@@ -159,7 +157,6 @@ CONFIG_DEBUG_KERNEL=y
159# CONFIG_ARM_UNWIND is not set 157# CONFIG_ARM_UNWIND is not set
160CONFIG_DEBUG_LL=y 158CONFIG_DEBUG_LL=y
161CONFIG_EARLY_PRINTK=y 159CONFIG_EARLY_PRINTK=y
162CONFIG_KEYS=y
163CONFIG_SECURITYFS=y 160CONFIG_SECURITYFS=y
164CONFIG_CRYPTO_DEFLATE=y 161CONFIG_CRYPTO_DEFLATE=y
165CONFIG_CRYPTO_LZO=y 162CONFIG_CRYPTO_LZO=y
diff --git a/arch/arm/configs/realview-smp_defconfig b/arch/arm/configs/realview-smp_defconfig
index 9312ef9f9bf4..5ca7a61f7c01 100644
--- a/arch/arm/configs/realview-smp_defconfig
+++ b/arch/arm/configs/realview-smp_defconfig
@@ -39,6 +39,7 @@ CONFIG_MTD_CFI=y
39CONFIG_MTD_CFI_INTELEXT=y 39CONFIG_MTD_CFI_INTELEXT=y
40CONFIG_MTD_CFI_AMDSTD=y 40CONFIG_MTD_CFI_AMDSTD=y
41CONFIG_MTD_ARM_INTEGRATOR=y 41CONFIG_MTD_ARM_INTEGRATOR=y
42CONFIG_ARM_CHARLCD=y
42CONFIG_NETDEVICES=y 43CONFIG_NETDEVICES=y
43CONFIG_SMSC_PHY=y 44CONFIG_SMSC_PHY=y
44CONFIG_NET_ETHERNET=y 45CONFIG_NET_ETHERNET=y
@@ -52,10 +53,13 @@ CONFIG_SERIAL_AMBA_PL011=y
52CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 53CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
53CONFIG_LEGACY_PTY_COUNT=16 54CONFIG_LEGACY_PTY_COUNT=16
54# CONFIG_HW_RANDOM is not set 55# CONFIG_HW_RANDOM is not set
56CONFIG_I2C=y
57CONFIG_I2C_VERSATILE=y
58CONFIG_SPI=y
59CONFIG_GPIOLIB=y
55# CONFIG_HWMON is not set 60# CONFIG_HWMON is not set
56CONFIG_FB=y 61CONFIG_FB=y
57CONFIG_FB_ARMCLCD=y 62CONFIG_FB_ARMCLCD=y
58# CONFIG_VGA_CONSOLE is not set
59CONFIG_FRAMEBUFFER_CONSOLE=y 63CONFIG_FRAMEBUFFER_CONSOLE=y
60CONFIG_LOGO=y 64CONFIG_LOGO=y
61# CONFIG_LOGO_LINUX_MONO is not set 65# CONFIG_LOGO_LINUX_MONO is not set
@@ -70,7 +74,13 @@ CONFIG_SND_ARMAACI=y
70# CONFIG_USB_SUPPORT is not set 74# CONFIG_USB_SUPPORT is not set
71CONFIG_MMC=y 75CONFIG_MMC=y
72CONFIG_MMC_ARMMMCI=y 76CONFIG_MMC_ARMMMCI=y
73CONFIG_INOTIFY=y 77CONFIG_NEW_LEDS=y
78CONFIG_LEDS_CLASS=y
79CONFIG_LEDS_TRIGGERS=y
80CONFIG_LEDS_TRIGGER_HEARTBEAT=y
81CONFIG_RTC_CLASS=y
82CONFIG_RTC_DRV_DS1307=y
83CONFIG_RTC_DRV_PL031=y
74CONFIG_VFAT_FS=y 84CONFIG_VFAT_FS=y
75CONFIG_TMPFS=y 85CONFIG_TMPFS=y
76CONFIG_CRAMFS=y 86CONFIG_CRAMFS=y
@@ -80,6 +90,7 @@ CONFIG_ROOT_NFS=y
80CONFIG_NLS_CODEPAGE_437=y 90CONFIG_NLS_CODEPAGE_437=y
81CONFIG_NLS_ISO8859_1=y 91CONFIG_NLS_ISO8859_1=y
82CONFIG_MAGIC_SYSRQ=y 92CONFIG_MAGIC_SYSRQ=y
93CONFIG_DEBUG_FS=y
83CONFIG_DEBUG_KERNEL=y 94CONFIG_DEBUG_KERNEL=y
84# CONFIG_SCHED_DEBUG is not set 95# CONFIG_SCHED_DEBUG is not set
85# CONFIG_RCU_CPU_STALL_DETECTOR is not set 96# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/arm/configs/realview_defconfig b/arch/arm/configs/realview_defconfig
index fb75192ee7e5..fcaa60328051 100644
--- a/arch/arm/configs/realview_defconfig
+++ b/arch/arm/configs/realview_defconfig
@@ -38,6 +38,7 @@ CONFIG_MTD_CFI=y
38CONFIG_MTD_CFI_INTELEXT=y 38CONFIG_MTD_CFI_INTELEXT=y
39CONFIG_MTD_CFI_AMDSTD=y 39CONFIG_MTD_CFI_AMDSTD=y
40CONFIG_MTD_ARM_INTEGRATOR=y 40CONFIG_MTD_ARM_INTEGRATOR=y
41CONFIG_ARM_CHARLCD=y
41CONFIG_NETDEVICES=y 42CONFIG_NETDEVICES=y
42CONFIG_SMSC_PHY=y 43CONFIG_SMSC_PHY=y
43CONFIG_NET_ETHERNET=y 44CONFIG_NET_ETHERNET=y
@@ -51,10 +52,13 @@ CONFIG_SERIAL_AMBA_PL011=y
51CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 52CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
52CONFIG_LEGACY_PTY_COUNT=16 53CONFIG_LEGACY_PTY_COUNT=16
53# CONFIG_HW_RANDOM is not set 54# CONFIG_HW_RANDOM is not set
55CONFIG_I2C=y
56CONFIG_I2C_VERSATILE=y
57CONFIG_SPI=y
58CONFIG_GPIOLIB=y
54# CONFIG_HWMON is not set 59# CONFIG_HWMON is not set
55CONFIG_FB=y 60CONFIG_FB=y
56CONFIG_FB_ARMCLCD=y 61CONFIG_FB_ARMCLCD=y
57# CONFIG_VGA_CONSOLE is not set
58CONFIG_FRAMEBUFFER_CONSOLE=y 62CONFIG_FRAMEBUFFER_CONSOLE=y
59CONFIG_LOGO=y 63CONFIG_LOGO=y
60# CONFIG_LOGO_LINUX_MONO is not set 64# CONFIG_LOGO_LINUX_MONO is not set
@@ -69,7 +73,13 @@ CONFIG_SND_ARMAACI=y
69# CONFIG_USB_SUPPORT is not set 73# CONFIG_USB_SUPPORT is not set
70CONFIG_MMC=y 74CONFIG_MMC=y
71CONFIG_MMC_ARMMMCI=y 75CONFIG_MMC_ARMMMCI=y
72CONFIG_INOTIFY=y 76CONFIG_NEW_LEDS=y
77CONFIG_LEDS_CLASS=y
78CONFIG_LEDS_TRIGGERS=y
79CONFIG_LEDS_TRIGGER_HEARTBEAT=y
80CONFIG_RTC_CLASS=y
81CONFIG_RTC_DRV_DS1307=y
82CONFIG_RTC_DRV_PL031=y
73CONFIG_VFAT_FS=y 83CONFIG_VFAT_FS=y
74CONFIG_TMPFS=y 84CONFIG_TMPFS=y
75CONFIG_CRAMFS=y 85CONFIG_CRAMFS=y
@@ -79,6 +89,7 @@ CONFIG_ROOT_NFS=y
79CONFIG_NLS_CODEPAGE_437=y 89CONFIG_NLS_CODEPAGE_437=y
80CONFIG_NLS_ISO8859_1=y 90CONFIG_NLS_ISO8859_1=y
81CONFIG_MAGIC_SYSRQ=y 91CONFIG_MAGIC_SYSRQ=y
92CONFIG_DEBUG_FS=y
82CONFIG_DEBUG_KERNEL=y 93CONFIG_DEBUG_KERNEL=y
83# CONFIG_SCHED_DEBUG is not set 94# CONFIG_SCHED_DEBUG is not set
84# CONFIG_RCU_CPU_STALL_DETECTOR is not set 95# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/arm/configs/s5p6440_defconfig b/arch/arm/configs/s5p64x0_defconfig
index 0b0266c6d326..2993ecd35145 100644
--- a/arch/arm/configs/s5p6440_defconfig
+++ b/arch/arm/configs/s5p64x0_defconfig
@@ -5,10 +5,11 @@ CONFIG_KALLSYMS_ALL=y
5CONFIG_MODULES=y 5CONFIG_MODULES=y
6CONFIG_MODULE_UNLOAD=y 6CONFIG_MODULE_UNLOAD=y
7# CONFIG_BLK_DEV_BSG is not set 7# CONFIG_BLK_DEV_BSG is not set
8CONFIG_ARCH_S5P6440=y 8CONFIG_ARCH_S5P64X0=y
9CONFIG_S3C_BOOT_ERROR_RESET=y 9CONFIG_S3C_BOOT_ERROR_RESET=y
10CONFIG_S3C_LOWLEVEL_UART_PORT=1 10CONFIG_S3C_LOWLEVEL_UART_PORT=1
11CONFIG_MACH_SMDK6440=y 11CONFIG_MACH_SMDK6440=y
12CONFIG_MACH_SMDK6450=y
12CONFIG_CPU_32v6K=y 13CONFIG_CPU_32v6K=y
13CONFIG_AEABI=y 14CONFIG_AEABI=y
14CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x20800000,8M console=ttySAC1,115200 init=/linuxrc" 15CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x20800000,8M console=ttySAC1,115200 init=/linuxrc"
diff --git a/arch/arm/configs/u300_defconfig b/arch/arm/configs/u300_defconfig
index 46e5e0747269..c1c252cdca60 100644
--- a/arch/arm/configs/u300_defconfig
+++ b/arch/arm/configs/u300_defconfig
@@ -28,26 +28,9 @@ CONFIG_CPU_IDLE=y
28CONFIG_FPE_NWFPE=y 28CONFIG_FPE_NWFPE=y
29CONFIG_PM=y 29CONFIG_PM=y
30# CONFIG_SUSPEND is not set 30# CONFIG_SUSPEND is not set
31CONFIG_NET=y
32CONFIG_PACKET=y
33CONFIG_UNIX=y
34CONFIG_INET=y
35# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
36# CONFIG_INET_XFRM_MODE_TUNNEL is not set
37# CONFIG_INET_XFRM_MODE_BEET is not set
38# CONFIG_INET_LRO is not set
39# CONFIG_INET_DIAG is not set
40# CONFIG_IPV6 is not set
41# CONFIG_WIRELESS is not set
42CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 31CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
43# CONFIG_PREVENT_FIRMWARE_BUILD is not set 32# CONFIG_PREVENT_FIRMWARE_BUILD is not set
44CONFIG_MTD=y 33# CONFIG_MISC_DEVICES is not set
45CONFIG_MTD_PARTITIONS=y
46CONFIG_MTD_CMDLINE_PARTS=y
47CONFIG_MTD_CHAR=y
48CONFIG_MTD_BLOCK=y
49CONFIG_MTD_NAND=y
50CONFIG_MTD_NAND_ECC_SMC=y
51# CONFIG_INPUT_MOUSEDEV is not set 34# CONFIG_INPUT_MOUSEDEV is not set
52CONFIG_INPUT_EVDEV=y 35CONFIG_INPUT_EVDEV=y
53# CONFIG_KEYBOARD_ATKBD is not set 36# CONFIG_KEYBOARD_ATKBD is not set
@@ -58,7 +41,6 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
58CONFIG_LEGACY_PTY_COUNT=16 41CONFIG_LEGACY_PTY_COUNT=16
59# CONFIG_HW_RANDOM is not set 42# CONFIG_HW_RANDOM is not set
60CONFIG_I2C=y 43CONFIG_I2C=y
61CONFIG_POWER_SUPPLY=y
62# CONFIG_HWMON is not set 44# CONFIG_HWMON is not set
63CONFIG_WATCHDOG=y 45CONFIG_WATCHDOG=y
64CONFIG_REGULATOR=y 46CONFIG_REGULATOR=y
@@ -66,24 +48,10 @@ CONFIG_FB=y
66CONFIG_BACKLIGHT_LCD_SUPPORT=y 48CONFIG_BACKLIGHT_LCD_SUPPORT=y
67# CONFIG_LCD_CLASS_DEVICE is not set 49# CONFIG_LCD_CLASS_DEVICE is not set
68CONFIG_BACKLIGHT_CLASS_DEVICE=y 50CONFIG_BACKLIGHT_CLASS_DEVICE=y
69# CONFIG_VGA_CONSOLE is not set
70CONFIG_SOUND=y
71CONFIG_SND=y
72# CONFIG_SND_SUPPORT_OLD_API is not set
73# CONFIG_SND_VERBOSE_PROCFS is not set
74# CONFIG_SND_DRIVERS is not set
75# CONFIG_SND_ARM is not set
76# CONFIG_SND_SPI is not set
77CONFIG_SND_SOC=y
78# CONFIG_HID_SUPPORT is not set 51# CONFIG_HID_SUPPORT is not set
79# CONFIG_USB_SUPPORT is not set 52# CONFIG_USB_SUPPORT is not set
80CONFIG_MMC=y 53CONFIG_MMC=y
81CONFIG_MMC_DEBUG=y
82CONFIG_MMC_ARMMMCI=y 54CONFIG_MMC_ARMMMCI=y
83CONFIG_NEW_LEDS=y
84CONFIG_LEDS_CLASS=y
85CONFIG_LEDS_TRIGGERS=y
86CONFIG_LEDS_TRIGGER_BACKLIGHT=y
87CONFIG_RTC_CLASS=y 55CONFIG_RTC_CLASS=y
88# CONFIG_RTC_HCTOSYS is not set 56# CONFIG_RTC_HCTOSYS is not set
89CONFIG_RTC_DRV_COH901331=y 57CONFIG_RTC_DRV_COH901331=y
@@ -93,12 +61,11 @@ CONFIG_COH901318=y
93CONFIG_FUSE_FS=y 61CONFIG_FUSE_FS=y
94CONFIG_VFAT_FS=y 62CONFIG_VFAT_FS=y
95CONFIG_TMPFS=y 63CONFIG_TMPFS=y
96# CONFIG_NETWORK_FILESYSTEMS is not set
97CONFIG_NLS_CODEPAGE_437=y 64CONFIG_NLS_CODEPAGE_437=y
98CONFIG_NLS_ISO8859_1=y 65CONFIG_NLS_ISO8859_1=y
99CONFIG_PRINTK_TIME=y 66CONFIG_PRINTK_TIME=y
67CONFIG_DEBUG_FS=y
100CONFIG_DEBUG_KERNEL=y 68CONFIG_DEBUG_KERNEL=y
101# CONFIG_DETECT_SOFTLOCKUP is not set
102# CONFIG_SCHED_DEBUG is not set 69# CONFIG_SCHED_DEBUG is not set
103CONFIG_TIMER_STATS=y 70CONFIG_TIMER_STATS=y
104# CONFIG_DEBUG_PREEMPT is not set 71# CONFIG_DEBUG_PREEMPT is not set
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 6e8f05c8a1c8..062b58c029ab 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -154,16 +154,39 @@
154 .long 9999b,9001f; \ 154 .long 9999b,9001f; \
155 .popsection 155 .popsection
156 156
157#ifdef CONFIG_SMP
158#define ALT_SMP(instr...) \
1599998: instr
160#define ALT_UP(instr...) \
161 .pushsection ".alt.smp.init", "a" ;\
162 .long 9998b ;\
163 instr ;\
164 .popsection
165#define ALT_UP_B(label) \
166 .equ up_b_offset, label - 9998b ;\
167 .pushsection ".alt.smp.init", "a" ;\
168 .long 9998b ;\
169 b . + up_b_offset ;\
170 .popsection
171#else
172#define ALT_SMP(instr...)
173#define ALT_UP(instr...) instr
174#define ALT_UP_B(label) b label
175#endif
176
157/* 177/*
158 * SMP data memory barrier 178 * SMP data memory barrier
159 */ 179 */
160 .macro smp_dmb 180 .macro smp_dmb
161#ifdef CONFIG_SMP 181#ifdef CONFIG_SMP
162#if __LINUX_ARM_ARCH__ >= 7 182#if __LINUX_ARM_ARCH__ >= 7
163 dmb 183 ALT_SMP(dmb)
164#elif __LINUX_ARM_ARCH__ == 6 184#elif __LINUX_ARM_ARCH__ == 6
165 mcr p15, 0, r0, c7, c10, 5 @ dmb 185 ALT_SMP(mcr p15, 0, r0, c7, c10, 5) @ dmb
186#else
187#error Incompatible SMP platform
166#endif 188#endif
189 ALT_UP(nop)
167#endif 190#endif
168 .endm 191 .endm
169 192
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 4656a24058d2..3acd8fa25e34 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -137,10 +137,10 @@
137#endif 137#endif
138 138
139/* 139/*
140 * This flag is used to indicate that the page pointed to by a pte 140 * This flag is used to indicate that the page pointed to by a pte is clean
141 * is dirty and requires cleaning before returning it to the user. 141 * and does not require cleaning before returning it to the user.
142 */ 142 */
143#define PG_dcache_dirty PG_arch_1 143#define PG_dcache_clean PG_arch_1
144 144
145/* 145/*
146 * MM Cache Management 146 * MM Cache Management
@@ -156,6 +156,12 @@
156 * Please note that the implementation of these, and the required 156 * Please note that the implementation of these, and the required
157 * effects are cache-type (VIVT/VIPT/PIPT) specific. 157 * effects are cache-type (VIVT/VIPT/PIPT) specific.
158 * 158 *
159 * flush_icache_all()
160 *
161 * Unconditionally clean and invalidate the entire icache.
162 * Currently only needed for cache-v6.S and cache-v7.S, see
163 * __flush_icache_all for the generic implementation.
164 *
159 * flush_kern_all() 165 * flush_kern_all()
160 * 166 *
161 * Unconditionally clean and invalidate the entire cache. 167 * Unconditionally clean and invalidate the entire cache.
@@ -206,6 +212,7 @@
206 */ 212 */
207 213
208struct cpu_cache_fns { 214struct cpu_cache_fns {
215 void (*flush_icache_all)(void);
209 void (*flush_kern_all)(void); 216 void (*flush_kern_all)(void);
210 void (*flush_user_all)(void); 217 void (*flush_user_all)(void);
211 void (*flush_user_range)(unsigned long, unsigned long, unsigned int); 218 void (*flush_user_range)(unsigned long, unsigned long, unsigned int);
@@ -227,6 +234,7 @@ struct cpu_cache_fns {
227 234
228extern struct cpu_cache_fns cpu_cache; 235extern struct cpu_cache_fns cpu_cache;
229 236
237#define __cpuc_flush_icache_all cpu_cache.flush_icache_all
230#define __cpuc_flush_kern_all cpu_cache.flush_kern_all 238#define __cpuc_flush_kern_all cpu_cache.flush_kern_all
231#define __cpuc_flush_user_all cpu_cache.flush_user_all 239#define __cpuc_flush_user_all cpu_cache.flush_user_all
232#define __cpuc_flush_user_range cpu_cache.flush_user_range 240#define __cpuc_flush_user_range cpu_cache.flush_user_range
@@ -246,6 +254,7 @@ extern struct cpu_cache_fns cpu_cache;
246 254
247#else 255#else
248 256
257#define __cpuc_flush_icache_all __glue(_CACHE,_flush_icache_all)
249#define __cpuc_flush_kern_all __glue(_CACHE,_flush_kern_cache_all) 258#define __cpuc_flush_kern_all __glue(_CACHE,_flush_kern_cache_all)
250#define __cpuc_flush_user_all __glue(_CACHE,_flush_user_cache_all) 259#define __cpuc_flush_user_all __glue(_CACHE,_flush_user_cache_all)
251#define __cpuc_flush_user_range __glue(_CACHE,_flush_user_cache_range) 260#define __cpuc_flush_user_range __glue(_CACHE,_flush_user_cache_range)
@@ -253,6 +262,7 @@ extern struct cpu_cache_fns cpu_cache;
253#define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range) 262#define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range)
254#define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area) 263#define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area)
255 264
265extern void __cpuc_flush_icache_all(void);
256extern void __cpuc_flush_kern_all(void); 266extern void __cpuc_flush_kern_all(void);
257extern void __cpuc_flush_user_all(void); 267extern void __cpuc_flush_user_all(void);
258extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int); 268extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);
@@ -291,6 +301,37 @@ extern void copy_to_user_page(struct vm_area_struct *, struct page *,
291/* 301/*
292 * Convert calls to our calling convention. 302 * Convert calls to our calling convention.
293 */ 303 */
304
305/* Invalidate I-cache */
306#define __flush_icache_all_generic() \
307 asm("mcr p15, 0, %0, c7, c5, 0" \
308 : : "r" (0));
309
310/* Invalidate I-cache inner shareable */
311#define __flush_icache_all_v7_smp() \
312 asm("mcr p15, 0, %0, c7, c1, 0" \
313 : : "r" (0));
314
315/*
316 * Optimized __flush_icache_all for the common cases. Note that UP ARMv7
317 * will fall through to use __flush_icache_all_generic.
318 */
319#if (defined(CONFIG_CPU_V7) && defined(CONFIG_CPU_V6)) || \
320 defined(CONFIG_SMP_ON_UP)
321#define __flush_icache_preferred __cpuc_flush_icache_all
322#elif __LINUX_ARM_ARCH__ >= 7 && defined(CONFIG_SMP)
323#define __flush_icache_preferred __flush_icache_all_v7_smp
324#elif __LINUX_ARM_ARCH__ == 6 && defined(CONFIG_ARM_ERRATA_411920)
325#define __flush_icache_preferred __cpuc_flush_icache_all
326#else
327#define __flush_icache_preferred __flush_icache_all_generic
328#endif
329
330static inline void __flush_icache_all(void)
331{
332 __flush_icache_preferred();
333}
334
294#define flush_cache_all() __cpuc_flush_kern_all() 335#define flush_cache_all() __cpuc_flush_kern_all()
295 336
296static inline void vivt_flush_cache_mm(struct mm_struct *mm) 337static inline void vivt_flush_cache_mm(struct mm_struct *mm)
@@ -366,21 +407,6 @@ extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr
366#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 407#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
367extern void flush_dcache_page(struct page *); 408extern void flush_dcache_page(struct page *);
368 409
369static inline void __flush_icache_all(void)
370{
371#ifdef CONFIG_ARM_ERRATA_411920
372 extern void v6_icache_inval_all(void);
373 v6_icache_inval_all();
374#elif defined(CONFIG_SMP) && __LINUX_ARM_ARCH__ >= 7
375 asm("mcr p15, 0, %0, c7, c1, 0 @ invalidate I-cache inner shareable\n"
376 :
377 : "r" (0));
378#else
379 asm("mcr p15, 0, %0, c7, c5, 0 @ invalidate I-cache\n"
380 :
381 : "r" (0));
382#endif
383}
384static inline void flush_kernel_vmap_range(void *addr, int size) 410static inline void flush_kernel_vmap_range(void *addr, int size)
385{ 411{
386 if ((cache_is_vivt() || cache_is_vipt_aliasing())) 412 if ((cache_is_vivt() || cache_is_vipt_aliasing()))
@@ -405,9 +431,6 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
405#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 431#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
406static inline void flush_kernel_dcache_page(struct page *page) 432static inline void flush_kernel_dcache_page(struct page *page)
407{ 433{
408 /* highmem pages are always flushed upon kunmap already */
409 if ((cache_is_vivt() || cache_is_vipt_aliasing()) && !PageHighMem(page))
410 __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
411} 434}
412 435
413#define flush_dcache_mmap_lock(mapping) \ 436#define flush_dcache_mmap_lock(mapping) \
diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
index d3a4c2cb9f2f..c023db09fcc1 100644
--- a/arch/arm/include/asm/cachetype.h
+++ b/arch/arm/include/asm/cachetype.h
@@ -6,6 +6,7 @@
6#define CACHEID_VIPT_ALIASING (1 << 2) 6#define CACHEID_VIPT_ALIASING (1 << 2)
7#define CACHEID_VIPT (CACHEID_VIPT_ALIASING|CACHEID_VIPT_NONALIASING) 7#define CACHEID_VIPT (CACHEID_VIPT_ALIASING|CACHEID_VIPT_NONALIASING)
8#define CACHEID_ASID_TAGGED (1 << 3) 8#define CACHEID_ASID_TAGGED (1 << 3)
9#define CACHEID_VIPT_I_ALIASING (1 << 4)
9 10
10extern unsigned int cacheid; 11extern unsigned int cacheid;
11 12
@@ -14,15 +15,18 @@ extern unsigned int cacheid;
14#define cache_is_vipt_nonaliasing() cacheid_is(CACHEID_VIPT_NONALIASING) 15#define cache_is_vipt_nonaliasing() cacheid_is(CACHEID_VIPT_NONALIASING)
15#define cache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_ALIASING) 16#define cache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_ALIASING)
16#define icache_is_vivt_asid_tagged() cacheid_is(CACHEID_ASID_TAGGED) 17#define icache_is_vivt_asid_tagged() cacheid_is(CACHEID_ASID_TAGGED)
18#define icache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_I_ALIASING)
17 19
18/* 20/*
19 * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture 21 * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture
20 * Mask out support which will never be present on newer CPUs. 22 * Mask out support which will never be present on newer CPUs.
21 * - v6+ is never VIVT 23 * - v6+ is never VIVT
22 * - v7+ VIPT never aliases 24 * - v7+ VIPT never aliases on D-side
23 */ 25 */
24#if __LINUX_ARM_ARCH__ >= 7 26#if __LINUX_ARM_ARCH__ >= 7
25#define __CACHEID_ARCH_MIN (CACHEID_VIPT_NONALIASING | CACHEID_ASID_TAGGED) 27#define __CACHEID_ARCH_MIN (CACHEID_VIPT_NONALIASING |\
28 CACHEID_ASID_TAGGED |\
29 CACHEID_VIPT_I_ALIASING)
26#elif __LINUX_ARM_ARCH__ >= 6 30#elif __LINUX_ARM_ARCH__ >= 6
27#define __CACHEID_ARCH_MIN (~CACHEID_VIVT) 31#define __CACHEID_ARCH_MIN (~CACHEID_VIVT)
28#else 32#else
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 5747a8baa413..8bb66bca2e3e 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -127,4 +127,8 @@ struct mm_struct;
127extern unsigned long arch_randomize_brk(struct mm_struct *mm); 127extern unsigned long arch_randomize_brk(struct mm_struct *mm);
128#define arch_randomize_brk arch_randomize_brk 128#define arch_randomize_brk arch_randomize_brk
129 129
130extern int vectors_user_mapping(void);
131#define arch_setup_additional_pages(bprm, uses_interp) vectors_user_mapping()
132#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
133
130#endif 134#endif
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
index 103f7ee97313..f89515adac60 100644
--- a/arch/arm/include/asm/ftrace.h
+++ b/arch/arm/include/asm/ftrace.h
@@ -2,12 +2,30 @@
2#define _ASM_ARM_FTRACE 2#define _ASM_ARM_FTRACE
3 3
4#ifdef CONFIG_FUNCTION_TRACER 4#ifdef CONFIG_FUNCTION_TRACER
5#define MCOUNT_ADDR ((long)(mcount)) 5#define MCOUNT_ADDR ((unsigned long)(__gnu_mcount_nc))
6#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ 6#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
7 7
8#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
9extern void mcount(void); 9extern void mcount(void);
10extern void __gnu_mcount_nc(void); 10extern void __gnu_mcount_nc(void);
11
12#ifdef CONFIG_DYNAMIC_FTRACE
13struct dyn_arch_ftrace {
14#ifdef CONFIG_OLD_MCOUNT
15 bool old_mcount;
16#endif
17};
18
19static inline unsigned long ftrace_call_adjust(unsigned long addr)
20{
21 /* With Thumb-2, the recorded addresses have the lsb set */
22 return addr & ~1;
23}
24
25extern void ftrace_caller_old(void);
26extern void ftrace_call_old(void);
27#endif
28
11#endif 29#endif
12 30
13#endif 31#endif
diff --git a/arch/arm/include/asm/hardware/coresight.h b/arch/arm/include/asm/hardware/coresight.h
index 212e47828c79..7ecd793b8f5a 100644
--- a/arch/arm/include/asm/hardware/coresight.h
+++ b/arch/arm/include/asm/hardware/coresight.h
@@ -21,18 +21,6 @@
21#define TRACER_RUNNING BIT(TRACER_RUNNING_BIT) 21#define TRACER_RUNNING BIT(TRACER_RUNNING_BIT)
22#define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT) 22#define TRACER_CYCLE_ACC BIT(TRACER_CYCLE_ACC_BIT)
23 23
24struct tracectx {
25 unsigned int etb_bufsz;
26 void __iomem *etb_regs;
27 void __iomem *etm_regs;
28 unsigned long flags;
29 int ncmppairs;
30 int etm_portsz;
31 struct device *dev;
32 struct clk *emu_clk;
33 struct mutex mutex;
34};
35
36#define TRACER_TIMEOUT 10000 24#define TRACER_TIMEOUT 10000
37 25
38#define etm_writel(t, v, x) \ 26#define etm_writel(t, v, x) \
@@ -112,10 +100,10 @@ struct tracectx {
112 100
113/* ETM status register, "ETM Architecture", 3.3.2 */ 101/* ETM status register, "ETM Architecture", 3.3.2 */
114#define ETMR_STATUS (0x10) 102#define ETMR_STATUS (0x10)
115#define ETMST_OVERFLOW (1 << 0) 103#define ETMST_OVERFLOW BIT(0)
116#define ETMST_PROGBIT (1 << 1) 104#define ETMST_PROGBIT BIT(1)
117#define ETMST_STARTSTOP (1 << 2) 105#define ETMST_STARTSTOP BIT(2)
118#define ETMST_TRIGGER (1 << 3) 106#define ETMST_TRIGGER BIT(3)
119 107
120#define etm_progbit(t) (etm_readl((t), ETMR_STATUS) & ETMST_PROGBIT) 108#define etm_progbit(t) (etm_readl((t), ETMR_STATUS) & ETMST_PROGBIT)
121#define etm_started(t) (etm_readl((t), ETMR_STATUS) & ETMST_STARTSTOP) 109#define etm_started(t) (etm_readl((t), ETMR_STATUS) & ETMST_STARTSTOP)
@@ -123,7 +111,7 @@ struct tracectx {
123 111
124#define ETMR_TRACEENCTRL2 0x1c 112#define ETMR_TRACEENCTRL2 0x1c
125#define ETMR_TRACEENCTRL 0x24 113#define ETMR_TRACEENCTRL 0x24
126#define ETMTE_INCLEXCL (1 << 24) 114#define ETMTE_INCLEXCL BIT(24)
127#define ETMR_TRACEENEVT 0x20 115#define ETMR_TRACEENEVT 0x20
128#define ETMCTRL_OPTS (ETMCTRL_DO_CPRT | \ 116#define ETMCTRL_OPTS (ETMCTRL_DO_CPRT | \
129 ETMCTRL_DATA_DO_ADDR | \ 117 ETMCTRL_DATA_DO_ADDR | \
@@ -146,12 +134,12 @@ struct tracectx {
146#define ETBR_CTRL 0x20 134#define ETBR_CTRL 0x20
147#define ETBR_FORMATTERCTRL 0x304 135#define ETBR_FORMATTERCTRL 0x304
148#define ETBFF_ENFTC 1 136#define ETBFF_ENFTC 1
149#define ETBFF_ENFCONT (1 << 1) 137#define ETBFF_ENFCONT BIT(1)
150#define ETBFF_FONFLIN (1 << 4) 138#define ETBFF_FONFLIN BIT(4)
151#define ETBFF_MANUAL_FLUSH (1 << 6) 139#define ETBFF_MANUAL_FLUSH BIT(6)
152#define ETBFF_TRIGIN (1 << 8) 140#define ETBFF_TRIGIN BIT(8)
153#define ETBFF_TRIGEVT (1 << 9) 141#define ETBFF_TRIGEVT BIT(9)
154#define ETBFF_TRIGFL (1 << 10) 142#define ETBFF_TRIGFL BIT(10)
155 143
156#define etb_writel(t, v, x) \ 144#define etb_writel(t, v, x) \
157 (__raw_writel((v), (t)->etb_regs + (x))) 145 (__raw_writel((v), (t)->etb_regs + (x)))
diff --git a/arch/arm/include/asm/hardware/icst.h b/arch/arm/include/asm/hardware/icst.h
index 10382a3dcec9..794220b087d2 100644
--- a/arch/arm/include/asm/hardware/icst.h
+++ b/arch/arm/include/asm/hardware/icst.h
@@ -8,7 +8,7 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * Support functions for calculating clocks/divisors for the ICST 10 * Support functions for calculating clocks/divisors for the ICST
11 * clock generators. See http://www.icst.com/ for more information 11 * clock generators. See http://www.idt.com/ for more information
12 * on these devices. 12 * on these devices.
13 */ 13 */
14#ifndef ASMARM_HARDWARE_ICST_H 14#ifndef ASMARM_HARDWARE_ICST_H
diff --git a/arch/arm/include/asm/hw_breakpoint.h b/arch/arm/include/asm/hw_breakpoint.h
new file mode 100644
index 000000000000..4d8ae9d67abe
--- /dev/null
+++ b/arch/arm/include/asm/hw_breakpoint.h
@@ -0,0 +1,133 @@
1#ifndef _ARM_HW_BREAKPOINT_H
2#define _ARM_HW_BREAKPOINT_H
3
4#ifdef __KERNEL__
5
6struct task_struct;
7
8#ifdef CONFIG_HAVE_HW_BREAKPOINT
9
10struct arch_hw_breakpoint_ctrl {
11 u32 __reserved : 9,
12 mismatch : 1,
13 : 9,
14 len : 8,
15 type : 2,
16 privilege : 2,
17 enabled : 1;
18};
19
20struct arch_hw_breakpoint {
21 u32 address;
22 u32 trigger;
23 struct perf_event *suspended_wp;
24 struct arch_hw_breakpoint_ctrl ctrl;
25};
26
27static inline u32 encode_ctrl_reg(struct arch_hw_breakpoint_ctrl ctrl)
28{
29 return (ctrl.mismatch << 22) | (ctrl.len << 5) | (ctrl.type << 3) |
30 (ctrl.privilege << 1) | ctrl.enabled;
31}
32
33static inline void decode_ctrl_reg(u32 reg,
34 struct arch_hw_breakpoint_ctrl *ctrl)
35{
36 ctrl->enabled = reg & 0x1;
37 reg >>= 1;
38 ctrl->privilege = reg & 0x3;
39 reg >>= 2;
40 ctrl->type = reg & 0x3;
41 reg >>= 2;
42 ctrl->len = reg & 0xff;
43 reg >>= 17;
44 ctrl->mismatch = reg & 0x1;
45}
46
47/* Debug architecture numbers. */
48#define ARM_DEBUG_ARCH_RESERVED 0 /* In case of ptrace ABI updates. */
49#define ARM_DEBUG_ARCH_V6 1
50#define ARM_DEBUG_ARCH_V6_1 2
51#define ARM_DEBUG_ARCH_V7_ECP14 3
52#define ARM_DEBUG_ARCH_V7_MM 4
53
54/* Breakpoint */
55#define ARM_BREAKPOINT_EXECUTE 0
56
57/* Watchpoints */
58#define ARM_BREAKPOINT_LOAD 1
59#define ARM_BREAKPOINT_STORE 2
60
61/* Privilege Levels */
62#define ARM_BREAKPOINT_PRIV 1
63#define ARM_BREAKPOINT_USER 2
64
65/* Lengths */
66#define ARM_BREAKPOINT_LEN_1 0x1
67#define ARM_BREAKPOINT_LEN_2 0x3
68#define ARM_BREAKPOINT_LEN_4 0xf
69#define ARM_BREAKPOINT_LEN_8 0xff
70
71/* Limits */
72#define ARM_MAX_BRP 16
73#define ARM_MAX_WRP 16
74#define ARM_MAX_HBP_SLOTS (ARM_MAX_BRP + ARM_MAX_WRP)
75
76/* DSCR method of entry bits. */
77#define ARM_DSCR_MOE(x) ((x >> 2) & 0xf)
78#define ARM_ENTRY_BREAKPOINT 0x1
79#define ARM_ENTRY_ASYNC_WATCHPOINT 0x2
80#define ARM_ENTRY_SYNC_WATCHPOINT 0xa
81
82/* DSCR monitor/halting bits. */
83#define ARM_DSCR_HDBGEN (1 << 14)
84#define ARM_DSCR_MDBGEN (1 << 15)
85
86/* opcode2 numbers for the co-processor instructions. */
87#define ARM_OP2_BVR 4
88#define ARM_OP2_BCR 5
89#define ARM_OP2_WVR 6
90#define ARM_OP2_WCR 7
91
92/* Base register numbers for the debug registers. */
93#define ARM_BASE_BVR 64
94#define ARM_BASE_BCR 80
95#define ARM_BASE_WVR 96
96#define ARM_BASE_WCR 112
97
98/* Accessor macros for the debug registers. */
99#define ARM_DBG_READ(M, OP2, VAL) do {\
100 asm volatile("mrc p14, 0, %0, c0," #M ", " #OP2 : "=r" (VAL));\
101} while (0)
102
103#define ARM_DBG_WRITE(M, OP2, VAL) do {\
104 asm volatile("mcr p14, 0, %0, c0," #M ", " #OP2 : : "r" (VAL));\
105} while (0)
106
107struct notifier_block;
108struct perf_event;
109struct pmu;
110
111extern struct pmu perf_ops_bp;
112extern int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
113 int *gen_len, int *gen_type);
114extern int arch_check_bp_in_kernelspace(struct perf_event *bp);
115extern int arch_validate_hwbkpt_settings(struct perf_event *bp);
116extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
117 unsigned long val, void *data);
118
119extern u8 arch_get_debug_arch(void);
120extern u8 arch_get_max_wp_len(void);
121extern void clear_ptrace_hw_breakpoint(struct task_struct *tsk);
122
123int arch_install_hw_breakpoint(struct perf_event *bp);
124void arch_uninstall_hw_breakpoint(struct perf_event *bp);
125void hw_breakpoint_pmu_read(struct perf_event *bp);
126int hw_breakpoint_slots(int type);
127
128#else
129static inline void clear_ptrace_hw_breakpoint(struct task_struct *tsk) {}
130
131#endif /* CONFIG_HAVE_HW_BREAKPOINT */
132#endif /* __KERNEL__ */
133#endif /* _ARM_HW_BREAKPOINT_H */
diff --git a/arch/arm/include/asm/hw_irq.h b/arch/arm/include/asm/hw_irq.h
index 90831f6f5f5c..5586b7c8ef6f 100644
--- a/arch/arm/include/asm/hw_irq.h
+++ b/arch/arm/include/asm/hw_irq.h
@@ -24,4 +24,6 @@ void set_irq_flags(unsigned int irq, unsigned int flags);
24#define IRQF_PROBE (1 << 1) 24#define IRQF_PROBE (1 << 1)
25#define IRQF_NOAUTOEN (1 << 2) 25#define IRQF_NOAUTOEN (1 << 2)
26 26
27#define ARCH_IRQ_INIT_FLAGS (IRQ_NOREQUEST | IRQ_NOPROBE)
28
27#endif 29#endif
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 1261b1f928d9..815efa2d4e07 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -294,6 +294,7 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
294#define ARCH_HAS_VALID_PHYS_ADDR_RANGE 294#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
295extern int valid_phys_addr_range(unsigned long addr, size_t size); 295extern int valid_phys_addr_range(unsigned long addr, size_t size);
296extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); 296extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
297extern int devmem_is_allowed(unsigned long pfn);
297#endif 298#endif
298 299
299/* 300/*
diff --git a/arch/arm/include/asm/ioctls.h b/arch/arm/include/asm/ioctls.h
index 0b30894b5482..9c9629816128 100644
--- a/arch/arm/include/asm/ioctls.h
+++ b/arch/arm/include/asm/ioctls.h
@@ -1,89 +1,8 @@
1#ifndef __ASM_ARM_IOCTLS_H 1#ifndef __ASM_ARM_IOCTLS_H
2#define __ASM_ARM_IOCTLS_H 2#define __ASM_ARM_IOCTLS_H
3 3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCSBRK 0x5427 /* BSD compatibility */
47#define TIOCCBRK 0x5428 /* BSD compatibility */
48#define TIOCGSID 0x5429 /* Return the session ID of FD */
49#define TCGETS2 _IOR('T',0x2A, struct termios2)
50#define TCSETS2 _IOW('T',0x2B, struct termios2)
51#define TCSETSW2 _IOW('T',0x2C, struct termios2)
52#define TCSETSF2 _IOW('T',0x2D, struct termios2)
53#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
54#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
55#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
56
57#define TIOCGRS485 0x542E
58#define TIOCSRS485 0x542F
59
60#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
61#define FIOCLEX 0x5451
62#define FIOASYNC 0x5452
63#define TIOCSERCONFIG 0x5453
64#define TIOCSERGWILD 0x5454
65#define TIOCSERSWILD 0x5455
66#define TIOCGLCKTRMIOS 0x5456
67#define TIOCSLCKTRMIOS 0x5457
68#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
69#define TIOCSERGETLSR 0x5459 /* Get line status register */
70#define TIOCSERGETMULTI 0x545A /* Get multiport config */
71#define TIOCSERSETMULTI 0x545B /* Set multiport config */
72
73#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
74#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
75#define FIOQSIZE 0x545E 4#define FIOQSIZE 0x545E
76 5
77/* Used for packet mode */ 6#include <asm-generic/ioctls.h>
78#define TIOCPKT_DATA 0
79#define TIOCPKT_FLUSHREAD 1
80#define TIOCPKT_FLUSHWRITE 2
81#define TIOCPKT_STOP 4
82#define TIOCPKT_START 8
83#define TIOCPKT_NOSTOP 16
84#define TIOCPKT_DOSTOP 32
85#define TIOCPKT_IOCTL 64
86
87#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
88 7
89#endif 8#endif
diff --git a/arch/arm/include/asm/irqflags.h b/arch/arm/include/asm/irqflags.h
index 6d09974e6646..1e6cca55c750 100644
--- a/arch/arm/include/asm/irqflags.h
+++ b/arch/arm/include/asm/irqflags.h
@@ -10,66 +10,85 @@
10 */ 10 */
11#if __LINUX_ARM_ARCH__ >= 6 11#if __LINUX_ARM_ARCH__ >= 6
12 12
13#define raw_local_irq_save(x) \ 13static inline unsigned long arch_local_irq_save(void)
14 ({ \ 14{
15 __asm__ __volatile__( \ 15 unsigned long flags;
16 "mrs %0, cpsr @ local_irq_save\n" \ 16
17 "cpsid i" \ 17 asm volatile(
18 : "=r" (x) : : "memory", "cc"); \ 18 " mrs %0, cpsr @ arch_local_irq_save\n"
19 }) 19 " cpsid i"
20 : "=r" (flags) : : "memory", "cc");
21 return flags;
22}
23
24static inline void arch_local_irq_enable(void)
25{
26 asm volatile(
27 " cpsie i @ arch_local_irq_enable"
28 :
29 :
30 : "memory", "cc");
31}
32
33static inline void arch_local_irq_disable(void)
34{
35 asm volatile(
36 " cpsid i @ arch_local_irq_disable"
37 :
38 :
39 : "memory", "cc");
40}
20 41
21#define raw_local_irq_enable() __asm__("cpsie i @ __sti" : : : "memory", "cc")
22#define raw_local_irq_disable() __asm__("cpsid i @ __cli" : : : "memory", "cc")
23#define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc") 42#define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc")
24#define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc") 43#define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc")
25
26#else 44#else
27 45
28/* 46/*
29 * Save the current interrupt enable state & disable IRQs 47 * Save the current interrupt enable state & disable IRQs
30 */ 48 */
31#define raw_local_irq_save(x) \ 49static inline unsigned long arch_local_irq_save(void)
32 ({ \ 50{
33 unsigned long temp; \ 51 unsigned long flags, temp;
34 (void) (&temp == &x); \ 52
35 __asm__ __volatile__( \ 53 asm volatile(
36 "mrs %0, cpsr @ local_irq_save\n" \ 54 " mrs %0, cpsr @ arch_local_irq_save\n"
37" orr %1, %0, #128\n" \ 55 " orr %1, %0, #128\n"
38" msr cpsr_c, %1" \ 56 " msr cpsr_c, %1"
39 : "=r" (x), "=r" (temp) \ 57 : "=r" (flags), "=r" (temp)
40 : \ 58 :
41 : "memory", "cc"); \ 59 : "memory", "cc");
42 }) 60 return flags;
43 61}
62
44/* 63/*
45 * Enable IRQs 64 * Enable IRQs
46 */ 65 */
47#define raw_local_irq_enable() \ 66static inline void arch_local_irq_enable(void)
48 ({ \ 67{
49 unsigned long temp; \ 68 unsigned long temp;
50 __asm__ __volatile__( \ 69 asm volatile(
51 "mrs %0, cpsr @ local_irq_enable\n" \ 70 " mrs %0, cpsr @ arch_local_irq_enable\n"
52" bic %0, %0, #128\n" \ 71 " bic %0, %0, #128\n"
53" msr cpsr_c, %0" \ 72 " msr cpsr_c, %0"
54 : "=r" (temp) \ 73 : "=r" (temp)
55 : \ 74 :
56 : "memory", "cc"); \ 75 : "memory", "cc");
57 }) 76}
58 77
59/* 78/*
60 * Disable IRQs 79 * Disable IRQs
61 */ 80 */
62#define raw_local_irq_disable() \ 81static inline void arch_local_irq_disable(void)
63 ({ \ 82{
64 unsigned long temp; \ 83 unsigned long temp;
65 __asm__ __volatile__( \ 84 asm volatile(
66 "mrs %0, cpsr @ local_irq_disable\n" \ 85 " mrs %0, cpsr @ arch_local_irq_disable\n"
67" orr %0, %0, #128\n" \ 86 " orr %0, %0, #128\n"
68" msr cpsr_c, %0" \ 87 " msr cpsr_c, %0"
69 : "=r" (temp) \ 88 : "=r" (temp)
70 : \ 89 :
71 : "memory", "cc"); \ 90 : "memory", "cc");
72 }) 91}
73 92
74/* 93/*
75 * Enable FIQs 94 * Enable FIQs
@@ -106,27 +125,31 @@
106/* 125/*
107 * Save the current interrupt enable state. 126 * Save the current interrupt enable state.
108 */ 127 */
109#define raw_local_save_flags(x) \ 128static inline unsigned long arch_local_save_flags(void)
110 ({ \ 129{
111 __asm__ __volatile__( \ 130 unsigned long flags;
112 "mrs %0, cpsr @ local_save_flags" \ 131 asm volatile(
113 : "=r" (x) : : "memory", "cc"); \ 132 " mrs %0, cpsr @ local_save_flags"
114 }) 133 : "=r" (flags) : : "memory", "cc");
134 return flags;
135}
115 136
116/* 137/*
117 * restore saved IRQ & FIQ state 138 * restore saved IRQ & FIQ state
118 */ 139 */
119#define raw_local_irq_restore(x) \ 140static inline void arch_local_irq_restore(unsigned long flags)
120 __asm__ __volatile__( \ 141{
121 "msr cpsr_c, %0 @ local_irq_restore\n" \ 142 asm volatile(
122 : \ 143 " msr cpsr_c, %0 @ local_irq_restore"
123 : "r" (x) \ 144 :
124 : "memory", "cc") 145 : "r" (flags)
146 : "memory", "cc");
147}
125 148
126#define raw_irqs_disabled_flags(flags) \ 149static inline int arch_irqs_disabled_flags(unsigned long flags)
127({ \ 150{
128 (int)((flags) & PSR_I_BIT); \ 151 return flags & PSR_I_BIT;
129}) 152}
130 153
131#endif 154#endif
132#endif 155#endif
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h
index 8a0dd18ba642..d97a964207fa 100644
--- a/arch/arm/include/asm/mach/arch.h
+++ b/arch/arm/include/asm/mach/arch.h
@@ -16,18 +16,15 @@ struct sys_timer;
16 16
17struct machine_desc { 17struct machine_desc {
18 /* 18 /*
19 * Note! The first four elements are used 19 * Note! The first two elements are used
20 * by assembler code in head.S, head-common.S 20 * by assembler code in head.S, head-common.S
21 */ 21 */
22 unsigned int nr; /* architecture number */ 22 unsigned int nr; /* architecture number */
23 unsigned int nr_irqs; /* number of IRQs */
24 unsigned int phys_io; /* start of physical io */
25 unsigned int io_pg_offst; /* byte offset for io
26 * page tabe entry */
27
28 const char *name; /* architecture name */ 23 const char *name; /* architecture name */
29 unsigned long boot_params; /* tagged list */ 24 unsigned long boot_params; /* tagged list */
30 25
26 unsigned int nr_irqs; /* number of IRQs */
27
31 unsigned int video_start; /* start of video RAM */ 28 unsigned int video_start; /* start of video RAM */
32 unsigned int video_end; /* end of video RAM */ 29 unsigned int video_end; /* end of video RAM */
33 30
diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
index a0b3cac0547c..71605d9f8e42 100644
--- a/arch/arm/include/asm/mmu_context.h
+++ b/arch/arm/include/asm/mmu_context.h
@@ -18,7 +18,6 @@
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/cachetype.h> 19#include <asm/cachetype.h>
20#include <asm/proc-fns.h> 20#include <asm/proc-fns.h>
21#include <asm-generic/mm_hooks.h>
22 21
23void __check_kvm_seq(struct mm_struct *mm); 22void __check_kvm_seq(struct mm_struct *mm);
24 23
@@ -134,4 +133,32 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
134#define deactivate_mm(tsk,mm) do { } while (0) 133#define deactivate_mm(tsk,mm) do { } while (0)
135#define activate_mm(prev,next) switch_mm(prev, next, NULL) 134#define activate_mm(prev,next) switch_mm(prev, next, NULL)
136 135
136/*
137 * We are inserting a "fake" vma for the user-accessible vector page so
138 * gdb and friends can get to it through ptrace and /proc/<pid>/mem.
139 * But we also want to remove it before the generic code gets to see it
140 * during process exit or the unmapping of it would cause total havoc.
141 * (the macro is used as remove_vma() is static to mm/mmap.c)
142 */
143#define arch_exit_mmap(mm) \
144do { \
145 struct vm_area_struct *high_vma = find_vma(mm, 0xffff0000); \
146 if (high_vma) { \
147 BUG_ON(high_vma->vm_next); /* it should be last */ \
148 if (high_vma->vm_prev) \
149 high_vma->vm_prev->vm_next = NULL; \
150 else \
151 mm->mmap = NULL; \
152 rb_erase(&high_vma->vm_rb, &mm->mm_rb); \
153 mm->mmap_cache = NULL; \
154 mm->map_count--; \
155 remove_vma(high_vma); \
156 } \
157} while (0)
158
159static inline void arch_dup_mmap(struct mm_struct *oldmm,
160 struct mm_struct *mm)
161{
162}
163
137#endif 164#endif
diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h
index e4dfa69abb68..cbb0bc295d2b 100644
--- a/arch/arm/include/asm/module.h
+++ b/arch/arm/include/asm/module.h
@@ -7,20 +7,27 @@
7 7
8struct unwind_table; 8struct unwind_table;
9 9
10struct mod_arch_specific
11{
12#ifdef CONFIG_ARM_UNWIND 10#ifdef CONFIG_ARM_UNWIND
13 Elf_Shdr *unw_sec_init; 11struct arm_unwind_mapping {
14 Elf_Shdr *unw_sec_devinit; 12 Elf_Shdr *unw_sec;
15 Elf_Shdr *unw_sec_core; 13 Elf_Shdr *sec_text;
16 Elf_Shdr *sec_init_text; 14 struct unwind_table *unwind;
17 Elf_Shdr *sec_devinit_text; 15};
18 Elf_Shdr *sec_core_text; 16enum {
19 struct unwind_table *unwind_init; 17 ARM_SEC_INIT,
20 struct unwind_table *unwind_devinit; 18 ARM_SEC_DEVINIT,
21 struct unwind_table *unwind_core; 19 ARM_SEC_CORE,
22#endif 20 ARM_SEC_EXIT,
21 ARM_SEC_DEVEXIT,
22 ARM_SEC_MAX,
23};
24struct mod_arch_specific {
25 struct arm_unwind_mapping map[ARM_SEC_MAX];
23}; 26};
27#else
28struct mod_arch_specific {
29};
30#endif
24 31
25/* 32/*
26 * Include the ARM architecture version. 33 * Include the ARM architecture version.
diff --git a/arch/arm/include/asm/perf_event.h b/arch/arm/include/asm/perf_event.h
index b5799a3b7117..c4aa4e8c6af9 100644
--- a/arch/arm/include/asm/perf_event.h
+++ b/arch/arm/include/asm/perf_event.h
@@ -12,18 +12,6 @@
12#ifndef __ARM_PERF_EVENT_H__ 12#ifndef __ARM_PERF_EVENT_H__
13#define __ARM_PERF_EVENT_H__ 13#define __ARM_PERF_EVENT_H__
14 14
15/*
16 * NOP: on *most* (read: all supported) ARM platforms, the performance
17 * counter interrupts are regular interrupts and not an NMI. This
18 * means that when we receive the interrupt we can call
19 * perf_event_do_pending() that handles all of the work with
20 * interrupts disabled.
21 */
22static inline void
23set_perf_event_pending(void)
24{
25}
26
27/* ARM performance counters start from 1 (in the cp15 accesses) so use the 15/* ARM performance counters start from 1 (in the cp15 accesses) so use the
28 * same indexes here for consistency. */ 16 * same indexes here for consistency. */
29#define PERF_EVENT_INDEX_OFFSET 1 17#define PERF_EVENT_INDEX_OFFSET 1
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index e90b167ea848..a9672e8406a3 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -278,9 +278,24 @@ extern struct page *empty_zero_page;
278 278
279#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext) 279#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
280 280
281#define set_pte_at(mm,addr,ptep,pteval) do { \ 281#if __LINUX_ARM_ARCH__ < 6
282 set_pte_ext(ptep, pteval, (addr) >= TASK_SIZE ? 0 : PTE_EXT_NG); \ 282static inline void __sync_icache_dcache(pte_t pteval)
283 } while (0) 283{
284}
285#else
286extern void __sync_icache_dcache(pte_t pteval);
287#endif
288
289static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
290 pte_t *ptep, pte_t pteval)
291{
292 if (addr >= TASK_SIZE)
293 set_pte_ext(ptep, pteval, 0);
294 else {
295 __sync_icache_dcache(pteval);
296 set_pte_ext(ptep, pteval, PTE_EXT_NG);
297 }
298}
284 299
285/* 300/*
286 * The following only work if pte_present() is true. 301 * The following only work if pte_present() is true.
@@ -290,8 +305,13 @@ extern struct page *empty_zero_page;
290#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE) 305#define pte_write(pte) (pte_val(pte) & L_PTE_WRITE)
291#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY) 306#define pte_dirty(pte) (pte_val(pte) & L_PTE_DIRTY)
292#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG) 307#define pte_young(pte) (pte_val(pte) & L_PTE_YOUNG)
308#define pte_exec(pte) (pte_val(pte) & L_PTE_EXEC)
293#define pte_special(pte) (0) 309#define pte_special(pte) (0)
294 310
311#define pte_present_user(pte) \
312 ((pte_val(pte) & (L_PTE_PRESENT | L_PTE_USER)) == \
313 (L_PTE_PRESENT | L_PTE_USER))
314
295#define PTE_BIT_FUNC(fn,op) \ 315#define PTE_BIT_FUNC(fn,op) \
296static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; } 316static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
297 317
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 7bed3daf83b8..67357baaeeeb 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -19,6 +19,7 @@
19 19
20#ifdef __KERNEL__ 20#ifdef __KERNEL__
21 21
22#include <asm/hw_breakpoint.h>
22#include <asm/ptrace.h> 23#include <asm/ptrace.h>
23#include <asm/types.h> 24#include <asm/types.h>
24 25
@@ -41,6 +42,9 @@ struct debug_entry {
41struct debug_info { 42struct debug_info {
42 int nsaved; 43 int nsaved;
43 struct debug_entry bp[2]; 44 struct debug_entry bp[2];
45#ifdef CONFIG_HAVE_HW_BREAKPOINT
46 struct perf_event *hbp[ARM_MAX_HBP_SLOTS];
47#endif
44}; 48};
45 49
46struct thread_struct { 50struct thread_struct {
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 7ce15eb15f72..783d50f32618 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -29,6 +29,8 @@
29#define PTRACE_SETCRUNCHREGS 26 29#define PTRACE_SETCRUNCHREGS 26
30#define PTRACE_GETVFPREGS 27 30#define PTRACE_GETVFPREGS 27
31#define PTRACE_SETVFPREGS 28 31#define PTRACE_SETVFPREGS 28
32#define PTRACE_GETHBPREGS 29
33#define PTRACE_SETHBPREGS 30
32 34
33/* 35/*
34 * PSR bits 36 * PSR bits
diff --git a/arch/arm/include/asm/seccomp.h b/arch/arm/include/asm/seccomp.h
new file mode 100644
index 000000000000..52b156b341f5
--- /dev/null
+++ b/arch/arm/include/asm/seccomp.h
@@ -0,0 +1,11 @@
1#ifndef _ASM_ARM_SECCOMP_H
2#define _ASM_ARM_SECCOMP_H
3
4#include <linux/unistd.h>
5
6#define __NR_seccomp_read __NR_read
7#define __NR_seccomp_write __NR_write
8#define __NR_seccomp_exit __NR_exit
9#define __NR_seccomp_sigreturn __NR_rt_sigreturn
10
11#endif /* _ASM_ARM_SECCOMP_H */
diff --git a/arch/arm/include/asm/smp_mpidr.h b/arch/arm/include/asm/smp_mpidr.h
new file mode 100644
index 000000000000..6a9307d64900
--- /dev/null
+++ b/arch/arm/include/asm/smp_mpidr.h
@@ -0,0 +1,17 @@
1#ifndef ASMARM_SMP_MIDR_H
2#define ASMARM_SMP_MIDR_H
3
4#define hard_smp_processor_id() \
5 ({ \
6 unsigned int cpunum; \
7 __asm__("\n" \
8 "1: mrc p15, 0, %0, c0, c0, 5\n" \
9 " .pushsection \".alt.smp.init\", \"a\"\n"\
10 " .long 1b\n" \
11 " mov %0, #0\n" \
12 " .popsection" \
13 : "=r" (cpunum)); \
14 cpunum &= 0x0F; \
15 })
16
17#endif
diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
index e6215305544a..f24c1b9e211d 100644
--- a/arch/arm/include/asm/smp_plat.h
+++ b/arch/arm/include/asm/smp_plat.h
@@ -7,15 +7,40 @@
7 7
8#include <asm/cputype.h> 8#include <asm/cputype.h>
9 9
10/*
11 * Return true if we are running on a SMP platform
12 */
13static inline bool is_smp(void)
14{
15#ifndef CONFIG_SMP
16 return false;
17#elif defined(CONFIG_SMP_ON_UP)
18 extern unsigned int smp_on_up;
19 return !!smp_on_up;
20#else
21 return true;
22#endif
23}
24
10/* all SMP configurations have the extended CPUID registers */ 25/* all SMP configurations have the extended CPUID registers */
11static inline int tlb_ops_need_broadcast(void) 26static inline int tlb_ops_need_broadcast(void)
12{ 27{
28 if (!is_smp())
29 return 0;
30
13 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2; 31 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
14} 32}
15 33
34#if !defined(CONFIG_SMP) || __LINUX_ARM_ARCH__ >= 7
35#define cache_ops_need_broadcast() 0
36#else
16static inline int cache_ops_need_broadcast(void) 37static inline int cache_ops_need_broadcast(void)
17{ 38{
39 if (!is_smp())
40 return 0;
41
18 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1; 42 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 1;
19} 43}
44#endif
20 45
21#endif 46#endif
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 8ba1ccf82a02..1120f18a6b17 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -85,6 +85,10 @@ void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
85 struct pt_regs *), 85 struct pt_regs *),
86 int sig, int code, const char *name); 86 int sig, int code, const char *name);
87 87
88void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int,
89 struct pt_regs *),
90 int sig, int code, const char *name);
91
88#define xchg(ptr,x) \ 92#define xchg(ptr,x) \
89 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 93 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
90 94
@@ -325,6 +329,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
325extern void disable_hlt(void); 329extern void disable_hlt(void);
326extern void enable_hlt(void); 330extern void enable_hlt(void);
327 331
332void cpu_idle_wait(void);
333
328#include <asm-generic/cmpxchg-local.h> 334#include <asm-generic/cmpxchg-local.h>
329 335
330#if __LINUX_ARM_ARCH__ < 6 336#if __LINUX_ARM_ARCH__ < 6
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index 763e29fa8530..7b5cc8dae06e 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -144,6 +144,7 @@ extern void vfp_flush_hwstate(struct thread_info *);
144#define TIF_MEMDIE 18 /* is terminating due to OOM killer */ 144#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
145#define TIF_FREEZE 19 145#define TIF_FREEZE 19
146#define TIF_RESTORE_SIGMASK 20 146#define TIF_RESTORE_SIGMASK 20
147#define TIF_SECCOMP 21
147 148
148#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 149#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
149#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 150#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
@@ -153,6 +154,7 @@ extern void vfp_flush_hwstate(struct thread_info *);
153#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) 154#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
154#define _TIF_FREEZE (1 << TIF_FREEZE) 155#define _TIF_FREEZE (1 << TIF_FREEZE)
155#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 156#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
157#define _TIF_SECCOMP (1 << TIF_SECCOMP)
156 158
157/* 159/*
158 * Change these and you break ASM code in entry-common.S 160 * Change these and you break ASM code in entry-common.S
diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
index 33b546ae72d4..ce7378ea15a2 100644
--- a/arch/arm/include/asm/tlbflush.h
+++ b/arch/arm/include/asm/tlbflush.h
@@ -70,6 +70,10 @@
70#undef _TLB 70#undef _TLB
71#undef MULTI_TLB 71#undef MULTI_TLB
72 72
73#ifdef CONFIG_SMP_ON_UP
74#define MULTI_TLB 1
75#endif
76
73#define v3_tlb_flags (TLB_V3_FULL | TLB_V3_PAGE) 77#define v3_tlb_flags (TLB_V3_FULL | TLB_V3_PAGE)
74 78
75#ifdef CONFIG_CPU_TLB_V3 79#ifdef CONFIG_CPU_TLB_V3
@@ -185,17 +189,23 @@
185# define v6wbi_always_flags (-1UL) 189# define v6wbi_always_flags (-1UL)
186#endif 190#endif
187 191
188#ifdef CONFIG_SMP 192#define v7wbi_tlb_flags_smp (TLB_WB | TLB_DCLEAN | TLB_V7_IS_BTB | \
189#define v7wbi_tlb_flags (TLB_WB | TLB_DCLEAN | TLB_V7_IS_BTB | \
190 TLB_V7_UIS_FULL | TLB_V7_UIS_PAGE | TLB_V7_UIS_ASID) 193 TLB_V7_UIS_FULL | TLB_V7_UIS_PAGE | TLB_V7_UIS_ASID)
191#else 194#define v7wbi_tlb_flags_up (TLB_WB | TLB_DCLEAN | TLB_BTB | \
192#define v7wbi_tlb_flags (TLB_WB | TLB_DCLEAN | TLB_BTB | \
193 TLB_V6_U_FULL | TLB_V6_U_PAGE | TLB_V6_U_ASID) 195 TLB_V6_U_FULL | TLB_V6_U_PAGE | TLB_V6_U_ASID)
194#endif
195 196
196#ifdef CONFIG_CPU_TLB_V7 197#ifdef CONFIG_CPU_TLB_V7
197# define v7wbi_possible_flags v7wbi_tlb_flags 198
198# define v7wbi_always_flags v7wbi_tlb_flags 199# ifdef CONFIG_SMP_ON_UP
200# define v7wbi_possible_flags (v7wbi_tlb_flags_smp | v7wbi_tlb_flags_up)
201# define v7wbi_always_flags (v7wbi_tlb_flags_smp & v7wbi_tlb_flags_up)
202# elif defined(CONFIG_SMP)
203# define v7wbi_possible_flags v7wbi_tlb_flags_smp
204# define v7wbi_always_flags v7wbi_tlb_flags_smp
205# else
206# define v7wbi_possible_flags v7wbi_tlb_flags_up
207# define v7wbi_always_flags v7wbi_tlb_flags_up
208# endif
199# ifdef _TLB 209# ifdef _TLB
200# define MULTI_TLB 1 210# define MULTI_TLB 1
201# else 211# else
@@ -560,12 +570,20 @@ extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
560#endif 570#endif
561 571
562/* 572/*
563 * if PG_dcache_dirty is set for the page, we need to ensure that any 573 * If PG_dcache_clean is not set for the page, we need to ensure that any
564 * cache entries for the kernels virtual memory range are written 574 * cache entries for the kernels virtual memory range are written
565 * back to the page. 575 * back to the page. On ARMv6 and later, the cache coherency is handled via
576 * the set_pte_at() function.
566 */ 577 */
578#if __LINUX_ARM_ARCH__ < 6
567extern void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, 579extern void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
568 pte_t *ptep); 580 pte_t *ptep);
581#else
582static inline void update_mmu_cache(struct vm_area_struct *vma,
583 unsigned long addr, pte_t *ptep)
584{
585}
586#endif
569 587
570#endif 588#endif
571 589
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 980b78e31328..5b9b268f4fbb 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_KGDB) += kgdb.o
42obj-$(CONFIG_ARM_UNWIND) += unwind.o 42obj-$(CONFIG_ARM_UNWIND) += unwind.o
43obj-$(CONFIG_HAVE_TCM) += tcm.o 43obj-$(CONFIG_HAVE_TCM) += tcm.o
44obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 44obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
45obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
45 46
46obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o 47obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o
47AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 48AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 8214bfebfaca..e5e1e5387678 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -165,6 +165,8 @@ EXPORT_SYMBOL(_find_next_bit_be);
165#endif 165#endif
166 166
167#ifdef CONFIG_FUNCTION_TRACER 167#ifdef CONFIG_FUNCTION_TRACER
168#ifdef CONFIG_OLD_MCOUNT
168EXPORT_SYMBOL(mcount); 169EXPORT_SYMBOL(mcount);
170#endif
169EXPORT_SYMBOL(__gnu_mcount_nc); 171EXPORT_SYMBOL(__gnu_mcount_nc);
170#endif 172#endif
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 85f2a019f77b..82da66172132 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -102,8 +102,6 @@ int main(void)
102 DEFINE(SIZEOF_MACHINE_DESC, sizeof(struct machine_desc)); 102 DEFINE(SIZEOF_MACHINE_DESC, sizeof(struct machine_desc));
103 DEFINE(MACHINFO_TYPE, offsetof(struct machine_desc, nr)); 103 DEFINE(MACHINFO_TYPE, offsetof(struct machine_desc, nr));
104 DEFINE(MACHINFO_NAME, offsetof(struct machine_desc, name)); 104 DEFINE(MACHINFO_NAME, offsetof(struct machine_desc, name));
105 DEFINE(MACHINFO_PHYSIO, offsetof(struct machine_desc, phys_io));
106 DEFINE(MACHINFO_PGOFFIO, offsetof(struct machine_desc, io_pg_offst));
107 BLANK(); 105 BLANK();
108 DEFINE(PROC_INFO_SZ, sizeof(struct proc_info_list)); 106 DEFINE(PROC_INFO_SZ, sizeof(struct proc_info_list));
109 DEFINE(PROCINFO_INITFUNC, offsetof(struct proc_info_list, __cpu_flush)); 107 DEFINE(PROCINFO_INITFUNC, offsetof(struct proc_info_list, __cpu_flush));
diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
index a38b4879441d..a0f07521ca8a 100644
--- a/arch/arm/kernel/debug.S
+++ b/arch/arm/kernel/debug.S
@@ -22,11 +22,11 @@
22#if defined(CONFIG_DEBUG_ICEDCC) 22#if defined(CONFIG_DEBUG_ICEDCC)
23 @@ debug using ARM EmbeddedICE DCC channel 23 @@ debug using ARM EmbeddedICE DCC channel
24 24
25#if defined(CONFIG_CPU_V6) 25 .macro addruart, rp, rv
26
27 .macro addruart, rx, tmp
28 .endm 26 .endm
29 27
28#if defined(CONFIG_CPU_V6)
29
30 .macro senduart, rd, rx 30 .macro senduart, rd, rx
31 mcr p14, 0, \rd, c0, c5, 0 31 mcr p14, 0, \rd, c0, c5, 0
32 .endm 32 .endm
@@ -51,9 +51,6 @@
51 51
52#elif defined(CONFIG_CPU_V7) 52#elif defined(CONFIG_CPU_V7)
53 53
54 .macro addruart, rx, tmp
55 .endm
56
57 .macro senduart, rd, rx 54 .macro senduart, rd, rx
58 mcr p14, 0, \rd, c0, c5, 0 55 mcr p14, 0, \rd, c0, c5, 0
59 .endm 56 .endm
@@ -71,9 +68,6 @@ wait: mrc p14, 0, pc, c0, c1, 0
71 68
72#elif defined(CONFIG_CPU_XSCALE) 69#elif defined(CONFIG_CPU_XSCALE)
73 70
74 .macro addruart, rx, tmp
75 .endm
76
77 .macro senduart, rd, rx 71 .macro senduart, rd, rx
78 mcr p14, 0, \rd, c8, c0, 0 72 mcr p14, 0, \rd, c8, c0, 0
79 .endm 73 .endm
@@ -98,9 +92,6 @@ wait: mrc p14, 0, pc, c0, c1, 0
98 92
99#else 93#else
100 94
101 .macro addruart, rx, tmp
102 .endm
103
104 .macro senduart, rd, rx 95 .macro senduart, rd, rx
105 mcr p14, 0, \rd, c1, c0, 0 96 mcr p14, 0, \rd, c1, c0, 0
106 .endm 97 .endm
@@ -130,6 +121,22 @@ wait: mrc p14, 0, pc, c0, c1, 0
130#include <mach/debug-macro.S> 121#include <mach/debug-macro.S>
131#endif /* CONFIG_DEBUG_ICEDCC */ 122#endif /* CONFIG_DEBUG_ICEDCC */
132 123
124#ifdef CONFIG_MMU
125 .macro addruart_current, rx, tmp1, tmp2
126 addruart \tmp1, \tmp2
127 mrc p15, 0, \rx, c1, c0
128 tst \rx, #1
129 moveq \rx, \tmp1
130 movne \rx, \tmp2
131 .endm
132
133#else /* !CONFIG_MMU */
134 .macro addruart_current, rx, tmp1, tmp2
135 addruart \rx, \tmp1
136 .endm
137
138#endif /* CONFIG_MMU */
139
133/* 140/*
134 * Useful debugging routines 141 * Useful debugging routines
135 */ 142 */
@@ -164,7 +171,7 @@ ENDPROC(printhex2)
164 .ltorg 171 .ltorg
165 172
166ENTRY(printascii) 173ENTRY(printascii)
167 addruart r3, r1 174 addruart_current r3, r1, r2
168 b 2f 175 b 2f
1691: waituart r2, r3 1761: waituart r2, r3
170 senduart r1, r3 177 senduart r1, r3
@@ -180,7 +187,7 @@ ENTRY(printascii)
180ENDPROC(printascii) 187ENDPROC(printascii)
181 188
182ENTRY(printch) 189ENTRY(printch)
183 addruart r3, r1 190 addruart_current r3, r1, r2
184 mov r1, r0 191 mov r1, r0
185 mov r0, #0 192 mov r0, #0
186 b 1b 193 b 1b
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index bb8e93a76407..c09e3573c5de 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -46,7 +46,8 @@
46 * this macro assumes that irqstat (r6) and base (r5) are 46 * this macro assumes that irqstat (r6) and base (r5) are
47 * preserved from get_irqnr_and_base above 47 * preserved from get_irqnr_and_base above
48 */ 48 */
49 test_for_ipi r0, r6, r5, lr 49 ALT_SMP(test_for_ipi r0, r6, r5, lr)
50 ALT_UP_B(9997f)
50 movne r0, sp 51 movne r0, sp
51 adrne lr, BSYM(1b) 52 adrne lr, BSYM(1b)
52 bne do_IPI 53 bne do_IPI
@@ -57,6 +58,7 @@
57 adrne lr, BSYM(1b) 58 adrne lr, BSYM(1b)
58 bne do_local_timer 59 bne do_local_timer
59#endif 60#endif
619997:
60#endif 62#endif
61 63
62 .endm 64 .endm
@@ -965,11 +967,8 @@ kuser_cmpxchg_fixup:
965 beq 1b 967 beq 1b
966 rsbs r0, r3, #0 968 rsbs r0, r3, #0
967 /* beware -- each __kuser slot must be 8 instructions max */ 969 /* beware -- each __kuser slot must be 8 instructions max */
968#ifdef CONFIG_SMP 970 ALT_SMP(b __kuser_memory_barrier)
969 b __kuser_memory_barrier 971 ALT_UP(usr_ret lr)
970#else
971 usr_ret lr
972#endif
973 972
974#endif 973#endif
975 974
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 7885722bdf4e..8bfa98757cd2 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -129,30 +129,58 @@ ENDPROC(ret_from_fork)
129 * clobber the ip register. This is OK because the ARM calling convention 129 * clobber the ip register. This is OK because the ARM calling convention
130 * allows it to be clobbered in subroutines and doesn't use it to hold 130 * allows it to be clobbered in subroutines and doesn't use it to hold
131 * parameters.) 131 * parameters.)
132 *
133 * When using dynamic ftrace, we patch out the mcount call by a "mov r0, r0"
134 * for the mcount case, and a "pop {lr}" for the __gnu_mcount_nc case (see
135 * arch/arm/kernel/ftrace.c).
132 */ 136 */
137
138#ifndef CONFIG_OLD_MCOUNT
139#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
140#error Ftrace requires CONFIG_FRAME_POINTER=y with GCC older than 4.4.0.
141#endif
142#endif
143
133#ifdef CONFIG_DYNAMIC_FTRACE 144#ifdef CONFIG_DYNAMIC_FTRACE
134ENTRY(mcount) 145ENTRY(__gnu_mcount_nc)
146 mov ip, lr
147 ldmia sp!, {lr}
148 mov pc, ip
149ENDPROC(__gnu_mcount_nc)
150
151ENTRY(ftrace_caller)
135 stmdb sp!, {r0-r3, lr} 152 stmdb sp!, {r0-r3, lr}
136 mov r0, lr 153 mov r0, lr
137 sub r0, r0, #MCOUNT_INSN_SIZE 154 sub r0, r0, #MCOUNT_INSN_SIZE
155 ldr r1, [sp, #20]
138 156
139 .globl mcount_call 157 .global ftrace_call
140mcount_call: 158ftrace_call:
141 bl ftrace_stub 159 bl ftrace_stub
142 ldr lr, [fp, #-4] @ restore lr 160 ldmia sp!, {r0-r3, ip, lr}
143 ldmia sp!, {r0-r3, pc} 161 mov pc, ip
162ENDPROC(ftrace_caller)
144 163
145ENTRY(ftrace_caller) 164#ifdef CONFIG_OLD_MCOUNT
165ENTRY(mcount)
166 stmdb sp!, {lr}
167 ldr lr, [fp, #-4]
168 ldmia sp!, {pc}
169ENDPROC(mcount)
170
171ENTRY(ftrace_caller_old)
146 stmdb sp!, {r0-r3, lr} 172 stmdb sp!, {r0-r3, lr}
147 ldr r1, [fp, #-4] 173 ldr r1, [fp, #-4]
148 mov r0, lr 174 mov r0, lr
149 sub r0, r0, #MCOUNT_INSN_SIZE 175 sub r0, r0, #MCOUNT_INSN_SIZE
150 176
151 .globl ftrace_call 177 .globl ftrace_call_old
152ftrace_call: 178ftrace_call_old:
153 bl ftrace_stub 179 bl ftrace_stub
154 ldr lr, [fp, #-4] @ restore lr 180 ldr lr, [fp, #-4] @ restore lr
155 ldmia sp!, {r0-r3, pc} 181 ldmia sp!, {r0-r3, pc}
182ENDPROC(ftrace_caller_old)
183#endif
156 184
157#else 185#else
158 186
@@ -160,7 +188,7 @@ ENTRY(__gnu_mcount_nc)
160 stmdb sp!, {r0-r3, lr} 188 stmdb sp!, {r0-r3, lr}
161 ldr r0, =ftrace_trace_function 189 ldr r0, =ftrace_trace_function
162 ldr r2, [r0] 190 ldr r2, [r0]
163 adr r0, ftrace_stub 191 adr r0, .Lftrace_stub
164 cmp r0, r2 192 cmp r0, r2
165 bne gnu_trace 193 bne gnu_trace
166 ldmia sp!, {r0-r3, ip, lr} 194 ldmia sp!, {r0-r3, ip, lr}
@@ -170,11 +198,19 @@ gnu_trace:
170 ldr r1, [sp, #20] @ lr of instrumented routine 198 ldr r1, [sp, #20] @ lr of instrumented routine
171 mov r0, lr 199 mov r0, lr
172 sub r0, r0, #MCOUNT_INSN_SIZE 200 sub r0, r0, #MCOUNT_INSN_SIZE
173 mov lr, pc 201 adr lr, BSYM(1f)
174 mov pc, r2 202 mov pc, r2
2031:
175 ldmia sp!, {r0-r3, ip, lr} 204 ldmia sp!, {r0-r3, ip, lr}
176 mov pc, ip 205 mov pc, ip
206ENDPROC(__gnu_mcount_nc)
177 207
208#ifdef CONFIG_OLD_MCOUNT
209/*
210 * This is under an ifdef in order to force link-time errors for people trying
211 * to build with !FRAME_POINTER with a GCC which doesn't use the new-style
212 * mcount.
213 */
178ENTRY(mcount) 214ENTRY(mcount)
179 stmdb sp!, {r0-r3, lr} 215 stmdb sp!, {r0-r3, lr}
180 ldr r0, =ftrace_trace_function 216 ldr r0, =ftrace_trace_function
@@ -193,12 +229,15 @@ trace:
193 mov pc, r2 229 mov pc, r2
194 ldr lr, [fp, #-4] @ restore lr 230 ldr lr, [fp, #-4] @ restore lr
195 ldmia sp!, {r0-r3, pc} 231 ldmia sp!, {r0-r3, pc}
232ENDPROC(mcount)
233#endif
196 234
197#endif /* CONFIG_DYNAMIC_FTRACE */ 235#endif /* CONFIG_DYNAMIC_FTRACE */
198 236
199 .globl ftrace_stub 237ENTRY(ftrace_stub)
200ftrace_stub: 238.Lftrace_stub:
201 mov pc, lr 239 mov pc, lr
240ENDPROC(ftrace_stub)
202 241
203#endif /* CONFIG_FUNCTION_TRACER */ 242#endif /* CONFIG_FUNCTION_TRACER */
204 243
@@ -295,7 +334,6 @@ ENTRY(vector_swi)
295 334
296 get_thread_info tsk 335 get_thread_info tsk
297 adr tbl, sys_call_table @ load syscall table pointer 336 adr tbl, sys_call_table @ load syscall table pointer
298 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
299 337
300#if defined(CONFIG_OABI_COMPAT) 338#if defined(CONFIG_OABI_COMPAT)
301 /* 339 /*
@@ -312,8 +350,20 @@ ENTRY(vector_swi)
312 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number 350 eor scno, scno, #__NR_SYSCALL_BASE @ check OS number
313#endif 351#endif
314 352
353 ldr r10, [tsk, #TI_FLAGS] @ check for syscall tracing
315 stmdb sp!, {r4, r5} @ push fifth and sixth args 354 stmdb sp!, {r4, r5} @ push fifth and sixth args
316 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls? 355
356#ifdef CONFIG_SECCOMP
357 tst r10, #_TIF_SECCOMP
358 beq 1f
359 mov r0, scno
360 bl __secure_computing
361 add r0, sp, #S_R0 + S_OFF @ pointer to regs
362 ldmia r0, {r0 - r3} @ have to reload r0 - r3
3631:
364#endif
365
366 tst r10, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
317 bne __sys_trace 367 bne __sys_trace
318 368
319 cmp scno, #NR_syscalls @ check upper syscall limit 369 cmp scno, #NR_syscalls @ check upper syscall limit
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index 33c7077174db..11db62806a1a 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -30,6 +30,21 @@
30MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
31MODULE_AUTHOR("Alexander Shishkin"); 31MODULE_AUTHOR("Alexander Shishkin");
32 32
33/*
34 * ETM tracer state
35 */
36struct tracectx {
37 unsigned int etb_bufsz;
38 void __iomem *etb_regs;
39 void __iomem *etm_regs;
40 unsigned long flags;
41 int ncmppairs;
42 int etm_portsz;
43 struct device *dev;
44 struct clk *emu_clk;
45 struct mutex mutex;
46};
47
33static struct tracectx tracer; 48static struct tracectx tracer;
34 49
35static inline bool trace_isrunning(struct tracectx *t) 50static inline bool trace_isrunning(struct tracectx *t)
@@ -314,6 +329,7 @@ static const struct file_operations etb_fops = {
314 .read = etb_read, 329 .read = etb_read,
315 .open = etb_open, 330 .open = etb_open,
316 .release = etb_release, 331 .release = etb_release,
332 .llseek = no_llseek,
317}; 333};
318 334
319static struct miscdevice etb_miscdev = { 335static struct miscdevice etb_miscdev = {
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 0298286ad4ad..971ac8c36ea7 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -2,102 +2,194 @@
2 * Dynamic function tracing support. 2 * Dynamic function tracing support.
3 * 3 *
4 * Copyright (C) 2008 Abhishek Sagar <sagar.abhishek@gmail.com> 4 * Copyright (C) 2008 Abhishek Sagar <sagar.abhishek@gmail.com>
5 * Copyright (C) 2010 Rabin Vincent <rabin@rab.in>
5 * 6 *
6 * For licencing details, see COPYING. 7 * For licencing details, see COPYING.
7 * 8 *
8 * Defines low-level handling of mcount calls when the kernel 9 * Defines low-level handling of mcount calls when the kernel
9 * is compiled with the -pg flag. When using dynamic ftrace, the 10 * is compiled with the -pg flag. When using dynamic ftrace, the
10 * mcount call-sites get patched lazily with NOP till they are 11 * mcount call-sites get patched with NOP till they are enabled.
11 * enabled. All code mutation routines here take effect atomically. 12 * All code mutation routines here are called under stop_machine().
12 */ 13 */
13 14
14#include <linux/ftrace.h> 15#include <linux/ftrace.h>
16#include <linux/uaccess.h>
15 17
16#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
17#include <asm/ftrace.h> 19#include <asm/ftrace.h>
18 20
19#define PC_OFFSET 8 21#ifdef CONFIG_THUMB2_KERNEL
20#define BL_OPCODE 0xeb000000 22#define NOP 0xeb04f85d /* pop.w {lr} */
21#define BL_OFFSET_MASK 0x00ffffff 23#else
24#define NOP 0xe8bd4000 /* pop {lr} */
25#endif
22 26
23static unsigned long bl_insn; 27#ifdef CONFIG_OLD_MCOUNT
24static const unsigned long NOP = 0xe1a00000; /* mov r0, r0 */ 28#define OLD_MCOUNT_ADDR ((unsigned long) mcount)
29#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old)
25 30
26unsigned char *ftrace_nop_replace(void) 31#define OLD_NOP 0xe1a00000 /* mov r0, r0 */
32
33static unsigned long ftrace_nop_replace(struct dyn_ftrace *rec)
27{ 34{
28 return (char *)&NOP; 35 return rec->arch.old_mcount ? OLD_NOP : NOP;
29} 36}
30 37
38static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
39{
40 if (!rec->arch.old_mcount)
41 return addr;
42
43 if (addr == MCOUNT_ADDR)
44 addr = OLD_MCOUNT_ADDR;
45 else if (addr == FTRACE_ADDR)
46 addr = OLD_FTRACE_ADDR;
47
48 return addr;
49}
50#else
51static unsigned long ftrace_nop_replace(struct dyn_ftrace *rec)
52{
53 return NOP;
54}
55
56static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
57{
58 return addr;
59}
60#endif
61
31/* construct a branch (BL) instruction to addr */ 62/* construct a branch (BL) instruction to addr */
32unsigned char *ftrace_call_replace(unsigned long pc, unsigned long addr) 63#ifdef CONFIG_THUMB2_KERNEL
64static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
33{ 65{
66 unsigned long s, j1, j2, i1, i2, imm10, imm11;
67 unsigned long first, second;
34 long offset; 68 long offset;
35 69
36 offset = (long)addr - (long)(pc + PC_OFFSET); 70 offset = (long)addr - (long)(pc + 4);
71 if (offset < -16777216 || offset > 16777214) {
72 WARN_ON_ONCE(1);
73 return 0;
74 }
75
76 s = (offset >> 24) & 0x1;
77 i1 = (offset >> 23) & 0x1;
78 i2 = (offset >> 22) & 0x1;
79 imm10 = (offset >> 12) & 0x3ff;
80 imm11 = (offset >> 1) & 0x7ff;
81
82 j1 = (!i1) ^ s;
83 j2 = (!i2) ^ s;
84
85 first = 0xf000 | (s << 10) | imm10;
86 second = 0xd000 | (j1 << 13) | (j2 << 11) | imm11;
87
88 return (second << 16) | first;
89}
90#else
91static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
92{
93 long offset;
94
95 offset = (long)addr - (long)(pc + 8);
37 if (unlikely(offset < -33554432 || offset > 33554428)) { 96 if (unlikely(offset < -33554432 || offset > 33554428)) {
38 /* Can't generate branches that far (from ARM ARM). Ftrace 97 /* Can't generate branches that far (from ARM ARM). Ftrace
39 * doesn't generate branches outside of kernel text. 98 * doesn't generate branches outside of kernel text.
40 */ 99 */
41 WARN_ON_ONCE(1); 100 WARN_ON_ONCE(1);
42 return NULL; 101 return 0;
43 } 102 }
44 offset = (offset >> 2) & BL_OFFSET_MASK;
45 bl_insn = BL_OPCODE | offset;
46 return (unsigned char *)&bl_insn;
47}
48 103
49int ftrace_modify_code(unsigned long pc, unsigned char *old_code, 104 offset = (offset >> 2) & 0x00ffffff;
50 unsigned char *new_code)
51{
52 unsigned long err = 0, replaced = 0, old, new;
53 105
54 old = *(unsigned long *)old_code; 106 return 0xeb000000 | offset;
55 new = *(unsigned long *)new_code; 107}
108#endif
56 109
57 __asm__ __volatile__ ( 110static int ftrace_modify_code(unsigned long pc, unsigned long old,
58 "1: ldr %1, [%2] \n" 111 unsigned long new)
59 " cmp %1, %4 \n" 112{
60 "2: streq %3, [%2] \n" 113 unsigned long replaced;
61 " cmpne %1, %3 \n"
62 " movne %0, #2 \n"
63 "3:\n"
64 114
65 ".pushsection .fixup, \"ax\"\n" 115 if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
66 "4: mov %0, #1 \n" 116 return -EFAULT;
67 " b 3b \n"
68 ".popsection\n"
69 117
70 ".pushsection __ex_table, \"a\"\n" 118 if (replaced != old)
71 " .long 1b, 4b \n" 119 return -EINVAL;
72 " .long 2b, 4b \n"
73 ".popsection\n"
74 120
75 : "=r"(err), "=r"(replaced) 121 if (probe_kernel_write((void *)pc, &new, MCOUNT_INSN_SIZE))
76 : "r"(pc), "r"(new), "r"(old), "0"(err), "1"(replaced) 122 return -EPERM;
77 : "memory");
78 123
79 if (!err && (replaced == old)) 124 flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
80 flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
81 125
82 return err; 126 return 0;
83} 127}
84 128
85int ftrace_update_ftrace_func(ftrace_func_t func) 129int ftrace_update_ftrace_func(ftrace_func_t func)
86{ 130{
87 int ret;
88 unsigned long pc, old; 131 unsigned long pc, old;
89 unsigned char *new; 132 unsigned long new;
133 int ret;
90 134
91 pc = (unsigned long)&ftrace_call; 135 pc = (unsigned long)&ftrace_call;
92 memcpy(&old, &ftrace_call, MCOUNT_INSN_SIZE); 136 memcpy(&old, &ftrace_call, MCOUNT_INSN_SIZE);
93 new = ftrace_call_replace(pc, (unsigned long)func); 137 new = ftrace_call_replace(pc, (unsigned long)func);
94 ret = ftrace_modify_code(pc, (unsigned char *)&old, new); 138
139 ret = ftrace_modify_code(pc, old, new);
140
141#ifdef CONFIG_OLD_MCOUNT
142 if (!ret) {
143 pc = (unsigned long)&ftrace_call_old;
144 memcpy(&old, &ftrace_call_old, MCOUNT_INSN_SIZE);
145 new = ftrace_call_replace(pc, (unsigned long)func);
146
147 ret = ftrace_modify_code(pc, old, new);
148 }
149#endif
150
151 return ret;
152}
153
154int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
155{
156 unsigned long new, old;
157 unsigned long ip = rec->ip;
158
159 old = ftrace_nop_replace(rec);
160 new = ftrace_call_replace(ip, adjust_address(rec, addr));
161
162 return ftrace_modify_code(rec->ip, old, new);
163}
164
165int ftrace_make_nop(struct module *mod,
166 struct dyn_ftrace *rec, unsigned long addr)
167{
168 unsigned long ip = rec->ip;
169 unsigned long old;
170 unsigned long new;
171 int ret;
172
173 old = ftrace_call_replace(ip, adjust_address(rec, addr));
174 new = ftrace_nop_replace(rec);
175 ret = ftrace_modify_code(ip, old, new);
176
177#ifdef CONFIG_OLD_MCOUNT
178 if (ret == -EINVAL && addr == MCOUNT_ADDR) {
179 rec->arch.old_mcount = true;
180
181 old = ftrace_call_replace(ip, adjust_address(rec, addr));
182 new = ftrace_nop_replace(rec);
183 ret = ftrace_modify_code(ip, old, new);
184 }
185#endif
186
95 return ret; 187 return ret;
96} 188}
97 189
98/* run from ftrace_init with irqs disabled */
99int __init ftrace_dyn_arch_init(void *data) 190int __init ftrace_dyn_arch_init(void *data)
100{ 191{
101 ftrace_mcount_set(data); 192 *(unsigned long *)data = 0;
193
102 return 0; 194 return 0;
103} 195}
diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S
index b9505aa267c0..bbecaac1e013 100644
--- a/arch/arm/kernel/head-common.S
+++ b/arch/arm/kernel/head-common.S
@@ -15,55 +15,6 @@
15#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2) 15#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
16#define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2) 16#define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)
17 17
18 .align 2
19 .type __switch_data, %object
20__switch_data:
21 .long __mmap_switched
22 .long __data_loc @ r4
23 .long _data @ r5
24 .long __bss_start @ r6
25 .long _end @ r7
26 .long processor_id @ r4
27 .long __machine_arch_type @ r5
28 .long __atags_pointer @ r6
29 .long cr_alignment @ r7
30 .long init_thread_union + THREAD_START_SP @ sp
31
32/*
33 * The following fragment of code is executed with the MMU on in MMU mode,
34 * and uses absolute addresses; this is not position independent.
35 *
36 * r0 = cp#15 control register
37 * r1 = machine ID
38 * r2 = atags pointer
39 * r9 = processor ID
40 */
41__mmap_switched:
42 adr r3, __switch_data + 4
43
44 ldmia r3!, {r4, r5, r6, r7}
45 cmp r4, r5 @ Copy data segment if needed
461: cmpne r5, r6
47 ldrne fp, [r4], #4
48 strne fp, [r5], #4
49 bne 1b
50
51 mov fp, #0 @ Clear BSS (and zero fp)
521: cmp r6, r7
53 strcc fp, [r6],#4
54 bcc 1b
55
56 ARM( ldmia r3, {r4, r5, r6, r7, sp})
57 THUMB( ldmia r3, {r4, r5, r6, r7} )
58 THUMB( ldr sp, [r3, #16] )
59 str r9, [r4] @ Save processor ID
60 str r1, [r5] @ Save machine type
61 str r2, [r6] @ Save atags pointer
62 bic r4, r0, #CR_A @ Clear 'A' bit
63 stmia r7, {r0, r4} @ Save control register values
64 b start_kernel
65ENDPROC(__mmap_switched)
66
67/* 18/*
68 * Exception handling. Something went wrong and we can't proceed. We 19 * Exception handling. Something went wrong and we can't proceed. We
69 * ought to tell the user, but since we don't have any guarantee that 20 * ought to tell the user, but since we don't have any guarantee that
@@ -73,21 +24,7 @@ ENDPROC(__mmap_switched)
73 * and hope for the best (useful if bootloader fails to pass a proper 24 * and hope for the best (useful if bootloader fails to pass a proper
74 * machine ID for example). 25 * machine ID for example).
75 */ 26 */
76__error_p: 27 __HEAD
77#ifdef CONFIG_DEBUG_LL
78 adr r0, str_p1
79 bl printascii
80 mov r0, r9
81 bl printhex8
82 adr r0, str_p2
83 bl printascii
84 b __error
85str_p1: .asciz "\nError: unrecognized/unsupported processor variant (0x"
86str_p2: .asciz ").\n"
87 .align
88#endif
89ENDPROC(__error_p)
90
91__error_a: 28__error_a:
92#ifdef CONFIG_DEBUG_LL 29#ifdef CONFIG_DEBUG_LL
93 mov r4, r1 @ preserve machine ID 30 mov r4, r1 @ preserve machine ID
@@ -97,7 +34,7 @@ __error_a:
97 bl printhex8 34 bl printhex8
98 adr r0, str_a2 35 adr r0, str_a2
99 bl printascii 36 bl printascii
100 adr r3, 4f 37 adr r3, __lookup_machine_type_data
101 ldmia r3, {r4, r5, r6} @ get machine desc list 38 ldmia r3, {r4, r5, r6} @ get machine desc list
102 sub r4, r3, r4 @ get offset between virt&phys 39 sub r4, r3, r4 @ get offset between virt&phys
103 add r5, r5, r4 @ convert virt addresses to 40 add r5, r5, r4 @ convert virt addresses to
@@ -125,78 +62,6 @@ str_a3: .asciz "\nPlease check your kernel config and/or bootloader.\n"
125 .align 62 .align
126#endif 63#endif
127 64
128__error:
129#ifdef CONFIG_ARCH_RPC
130/*
131 * Turn the screen red on a error - RiscPC only.
132 */
133 mov r0, #0x02000000
134 mov r3, #0x11
135 orr r3, r3, r3, lsl #8
136 orr r3, r3, r3, lsl #16
137 str r3, [r0], #4
138 str r3, [r0], #4
139 str r3, [r0], #4
140 str r3, [r0], #4
141#endif
1421: mov r0, r0
143 b 1b
144ENDPROC(__error)
145
146
147/*
148 * Read processor ID register (CP#15, CR0), and look up in the linker-built
149 * supported processor list. Note that we can't use the absolute addresses
150 * for the __proc_info lists since we aren't running with the MMU on
151 * (and therefore, we are not in the correct address space). We have to
152 * calculate the offset.
153 *
154 * r9 = cpuid
155 * Returns:
156 * r3, r4, r6 corrupted
157 * r5 = proc_info pointer in physical address space
158 * r9 = cpuid (preserved)
159 */
160__lookup_processor_type:
161 adr r3, 3f
162 ldmia r3, {r5 - r7}
163 add r3, r3, #8
164 sub r3, r3, r7 @ get offset between virt&phys
165 add r5, r5, r3 @ convert virt addresses to
166 add r6, r6, r3 @ physical address space
1671: ldmia r5, {r3, r4} @ value, mask
168 and r4, r4, r9 @ mask wanted bits
169 teq r3, r4
170 beq 2f
171 add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)
172 cmp r5, r6
173 blo 1b
174 mov r5, #0 @ unknown processor
1752: mov pc, lr
176ENDPROC(__lookup_processor_type)
177
178/*
179 * This provides a C-API version of the above function.
180 */
181ENTRY(lookup_processor_type)
182 stmfd sp!, {r4 - r7, r9, lr}
183 mov r9, r0
184 bl __lookup_processor_type
185 mov r0, r5
186 ldmfd sp!, {r4 - r7, r9, pc}
187ENDPROC(lookup_processor_type)
188
189/*
190 * Look in <asm/procinfo.h> and arch/arm/kernel/arch.[ch] for
191 * more information about the __proc_info and __arch_info structures.
192 */
193 .align 2
1943: .long __proc_info_begin
195 .long __proc_info_end
1964: .long .
197 .long __arch_info_begin
198 .long __arch_info_end
199
200/* 65/*
201 * Lookup machine architecture in the linker-build list of architectures. 66 * Lookup machine architecture in the linker-build list of architectures.
202 * Note that we can't use the absolute addresses for the __arch_info 67 * Note that we can't use the absolute addresses for the __arch_info
@@ -209,7 +74,7 @@ ENDPROC(lookup_processor_type)
209 * r5 = mach_info pointer in physical address space 74 * r5 = mach_info pointer in physical address space
210 */ 75 */
211__lookup_machine_type: 76__lookup_machine_type:
212 adr r3, 4b 77 adr r3, __lookup_machine_type_data
213 ldmia r3, {r4, r5, r6} 78 ldmia r3, {r4, r5, r6}
214 sub r3, r3, r4 @ get offset between virt&phys 79 sub r3, r3, r4 @ get offset between virt&phys
215 add r5, r5, r3 @ convert virt addresses to 80 add r5, r5, r3 @ convert virt addresses to
@@ -225,15 +90,16 @@ __lookup_machine_type:
225ENDPROC(__lookup_machine_type) 90ENDPROC(__lookup_machine_type)
226 91
227/* 92/*
228 * This provides a C-API version of the above function. 93 * Look in arch/arm/kernel/arch.[ch] for information about the
94 * __arch_info structures.
229 */ 95 */
230ENTRY(lookup_machine_type) 96 .align 2
231 stmfd sp!, {r4 - r6, lr} 97 .type __lookup_machine_type_data, %object
232 mov r1, r0 98__lookup_machine_type_data:
233 bl __lookup_machine_type 99 .long .
234 mov r0, r5 100 .long __arch_info_begin
235 ldmfd sp!, {r4 - r6, pc} 101 .long __arch_info_end
236ENDPROC(lookup_machine_type) 102 .size __lookup_machine_type_data, . - __lookup_machine_type_data
237 103
238/* Determine validity of the r2 atags pointer. The heuristic requires 104/* Determine validity of the r2 atags pointer. The heuristic requires
239 * that the pointer be aligned, in the first 16k of physical RAM and 105 * that the pointer be aligned, in the first 16k of physical RAM and
@@ -265,3 +131,150 @@ __vet_atags:
2651: mov r2, #0 1311: mov r2, #0
266 mov pc, lr 132 mov pc, lr
267ENDPROC(__vet_atags) 133ENDPROC(__vet_atags)
134
135/*
136 * The following fragment of code is executed with the MMU on in MMU mode,
137 * and uses absolute addresses; this is not position independent.
138 *
139 * r0 = cp#15 control register
140 * r1 = machine ID
141 * r2 = atags pointer
142 * r9 = processor ID
143 */
144 __INIT
145__mmap_switched:
146 adr r3, __mmap_switched_data
147
148 ldmia r3!, {r4, r5, r6, r7}
149 cmp r4, r5 @ Copy data segment if needed
1501: cmpne r5, r6
151 ldrne fp, [r4], #4
152 strne fp, [r5], #4
153 bne 1b
154
155 mov fp, #0 @ Clear BSS (and zero fp)
1561: cmp r6, r7
157 strcc fp, [r6],#4
158 bcc 1b
159
160 ARM( ldmia r3, {r4, r5, r6, r7, sp})
161 THUMB( ldmia r3, {r4, r5, r6, r7} )
162 THUMB( ldr sp, [r3, #16] )
163 str r9, [r4] @ Save processor ID
164 str r1, [r5] @ Save machine type
165 str r2, [r6] @ Save atags pointer
166 bic r4, r0, #CR_A @ Clear 'A' bit
167 stmia r7, {r0, r4} @ Save control register values
168 b start_kernel
169ENDPROC(__mmap_switched)
170
171 .align 2
172 .type __mmap_switched_data, %object
173__mmap_switched_data:
174 .long __data_loc @ r4
175 .long _sdata @ r5
176 .long __bss_start @ r6
177 .long _end @ r7
178 .long processor_id @ r4
179 .long __machine_arch_type @ r5
180 .long __atags_pointer @ r6
181 .long cr_alignment @ r7
182 .long init_thread_union + THREAD_START_SP @ sp
183 .size __mmap_switched_data, . - __mmap_switched_data
184
185/*
186 * This provides a C-API version of __lookup_machine_type
187 */
188ENTRY(lookup_machine_type)
189 stmfd sp!, {r4 - r6, lr}
190 mov r1, r0
191 bl __lookup_machine_type
192 mov r0, r5
193 ldmfd sp!, {r4 - r6, pc}
194ENDPROC(lookup_machine_type)
195
196/*
197 * This provides a C-API version of __lookup_processor_type
198 */
199ENTRY(lookup_processor_type)
200 stmfd sp!, {r4 - r6, r9, lr}
201 mov r9, r0
202 bl __lookup_processor_type
203 mov r0, r5
204 ldmfd sp!, {r4 - r6, r9, pc}
205ENDPROC(lookup_processor_type)
206
207/*
208 * Read processor ID register (CP#15, CR0), and look up in the linker-built
209 * supported processor list. Note that we can't use the absolute addresses
210 * for the __proc_info lists since we aren't running with the MMU on
211 * (and therefore, we are not in the correct address space). We have to
212 * calculate the offset.
213 *
214 * r9 = cpuid
215 * Returns:
216 * r3, r4, r6 corrupted
217 * r5 = proc_info pointer in physical address space
218 * r9 = cpuid (preserved)
219 */
220 __CPUINIT
221__lookup_processor_type:
222 adr r3, __lookup_processor_type_data
223 ldmia r3, {r4 - r6}
224 sub r3, r3, r4 @ get offset between virt&phys
225 add r5, r5, r3 @ convert virt addresses to
226 add r6, r6, r3 @ physical address space
2271: ldmia r5, {r3, r4} @ value, mask
228 and r4, r4, r9 @ mask wanted bits
229 teq r3, r4
230 beq 2f
231 add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)
232 cmp r5, r6
233 blo 1b
234 mov r5, #0 @ unknown processor
2352: mov pc, lr
236ENDPROC(__lookup_processor_type)
237
238/*
239 * Look in <asm/procinfo.h> for information about the __proc_info structure.
240 */
241 .align 2
242 .type __lookup_processor_type_data, %object
243__lookup_processor_type_data:
244 .long .
245 .long __proc_info_begin
246 .long __proc_info_end
247 .size __lookup_processor_type_data, . - __lookup_processor_type_data
248
249__error_p:
250#ifdef CONFIG_DEBUG_LL
251 adr r0, str_p1
252 bl printascii
253 mov r0, r9
254 bl printhex8
255 adr r0, str_p2
256 bl printascii
257 b __error
258str_p1: .asciz "\nError: unrecognized/unsupported processor variant (0x"
259str_p2: .asciz ").\n"
260 .align
261#endif
262ENDPROC(__error_p)
263
264__error:
265#ifdef CONFIG_ARCH_RPC
266/*
267 * Turn the screen red on a error - RiscPC only.
268 */
269 mov r0, #0x02000000
270 mov r3, #0x11
271 orr r3, r3, r3, lsl #8
272 orr r3, r3, r3, lsl #16
273 str r3, [r0], #4
274 str r3, [r0], #4
275 str r3, [r0], #4
276 str r3, [r0], #4
277#endif
2781: mov r0, r0
279 b 1b
280ENDPROC(__error)
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 573b803dc6bf..814ce1a73270 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -48,8 +48,6 @@ ENTRY(stext)
48 movs r8, r5 @ invalid machine (r5=0)? 48 movs r8, r5 @ invalid machine (r5=0)?
49 beq __error_a @ yes, error 'a' 49 beq __error_a @ yes, error 'a'
50 50
51 ldr r13, __switch_data @ address to jump to after
52 @ the initialization is done
53 adr lr, BSYM(__after_proc_init) @ return (PIC) address 51 adr lr, BSYM(__after_proc_init) @ return (PIC) address
54 ARM( add pc, r10, #PROCINFO_INITFUNC ) 52 ARM( add pc, r10, #PROCINFO_INITFUNC )
55 THUMB( add r12, r10, #PROCINFO_INITFUNC ) 53 THUMB( add r12, r10, #PROCINFO_INITFUNC )
@@ -87,8 +85,7 @@ __after_proc_init:
87 mcr p15, 0, r0, c1, c0, 0 @ write control reg 85 mcr p15, 0, r0, c1, c0, 0 @ write control reg
88#endif /* CONFIG_CPU_CP15 */ 86#endif /* CONFIG_CPU_CP15 */
89 87
90 mov r3, r13 88 b __mmap_switched @ clear the BSS and jump
91 mov pc, r3 @ clear the BSS and jump
92 @ to start_kernel 89 @ to start_kernel
93ENDPROC(__after_proc_init) 90ENDPROC(__after_proc_init)
94 .ltorg 91 .ltorg
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index eb62bf947212..dd6b369ac69c 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -22,6 +22,10 @@
22#include <asm/thread_info.h> 22#include <asm/thread_info.h>
23#include <asm/system.h> 23#include <asm/system.h>
24 24
25#ifdef CONFIG_DEBUG_LL
26#include <mach/debug-macro.S>
27#endif
28
25#if (PHYS_OFFSET & 0x001fffff) 29#if (PHYS_OFFSET & 0x001fffff)
26#error "PHYS_OFFSET must be at an even 2MiB boundary!" 30#error "PHYS_OFFSET must be at an even 2MiB boundary!"
27#endif 31#endif
@@ -86,6 +90,9 @@ ENTRY(stext)
86 movs r8, r5 @ invalid machine (r5=0)? 90 movs r8, r5 @ invalid machine (r5=0)?
87 beq __error_a @ yes, error 'a' 91 beq __error_a @ yes, error 'a'
88 bl __vet_atags 92 bl __vet_atags
93#ifdef CONFIG_SMP_ON_UP
94 bl __fixup_smp
95#endif
89 bl __create_page_tables 96 bl __create_page_tables
90 97
91 /* 98 /*
@@ -95,113 +102,15 @@ ENTRY(stext)
95 * above. On return, the CPU will be ready for the MMU to be 102 * above. On return, the CPU will be ready for the MMU to be
96 * turned on, and r0 will hold the CPU control register value. 103 * turned on, and r0 will hold the CPU control register value.
97 */ 104 */
98 ldr r13, __switch_data @ address to jump to after 105 ldr r13, =__mmap_switched @ address to jump to after
99 @ mmu has been enabled 106 @ mmu has been enabled
100 adr lr, BSYM(__enable_mmu) @ return (PIC) address 107 adr lr, BSYM(1f) @ return (PIC) address
101 ARM( add pc, r10, #PROCINFO_INITFUNC ) 108 ARM( add pc, r10, #PROCINFO_INITFUNC )
102 THUMB( add r12, r10, #PROCINFO_INITFUNC ) 109 THUMB( add r12, r10, #PROCINFO_INITFUNC )
103 THUMB( mov pc, r12 ) 110 THUMB( mov pc, r12 )
1111: b __enable_mmu
104ENDPROC(stext) 112ENDPROC(stext)
105 113 .ltorg
106#if defined(CONFIG_SMP)
107ENTRY(secondary_startup)
108 /*
109 * Common entry point for secondary CPUs.
110 *
111 * Ensure that we're in SVC mode, and IRQs are disabled. Lookup
112 * the processor type - there is no need to check the machine type
113 * as it has already been validated by the primary processor.
114 */
115 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9
116 mrc p15, 0, r9, c0, c0 @ get processor id
117 bl __lookup_processor_type
118 movs r10, r5 @ invalid processor?
119 moveq r0, #'p' @ yes, error 'p'
120 beq __error
121
122 /*
123 * Use the page tables supplied from __cpu_up.
124 */
125 adr r4, __secondary_data
126 ldmia r4, {r5, r7, r12} @ address to jump to after
127 sub r4, r4, r5 @ mmu has been enabled
128 ldr r4, [r7, r4] @ get secondary_data.pgdir
129 adr lr, BSYM(__enable_mmu) @ return address
130 mov r13, r12 @ __secondary_switched address
131 ARM( add pc, r10, #PROCINFO_INITFUNC ) @ initialise processor
132 @ (return control reg)
133 THUMB( add r12, r10, #PROCINFO_INITFUNC )
134 THUMB( mov pc, r12 )
135ENDPROC(secondary_startup)
136
137 /*
138 * r6 = &secondary_data
139 */
140ENTRY(__secondary_switched)
141 ldr sp, [r7, #4] @ get secondary_data.stack
142 mov fp, #0
143 b secondary_start_kernel
144ENDPROC(__secondary_switched)
145
146 .type __secondary_data, %object
147__secondary_data:
148 .long .
149 .long secondary_data
150 .long __secondary_switched
151#endif /* defined(CONFIG_SMP) */
152
153
154
155/*
156 * Setup common bits before finally enabling the MMU. Essentially
157 * this is just loading the page table pointer and domain access
158 * registers.
159 */
160__enable_mmu:
161#ifdef CONFIG_ALIGNMENT_TRAP
162 orr r0, r0, #CR_A
163#else
164 bic r0, r0, #CR_A
165#endif
166#ifdef CONFIG_CPU_DCACHE_DISABLE
167 bic r0, r0, #CR_C
168#endif
169#ifdef CONFIG_CPU_BPREDICT_DISABLE
170 bic r0, r0, #CR_Z
171#endif
172#ifdef CONFIG_CPU_ICACHE_DISABLE
173 bic r0, r0, #CR_I
174#endif
175 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
176 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
177 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
178 domain_val(DOMAIN_IO, DOMAIN_CLIENT))
179 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
180 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
181 b __turn_mmu_on
182ENDPROC(__enable_mmu)
183
184/*
185 * Enable the MMU. This completely changes the structure of the visible
186 * memory space. You will not be able to trace execution through this.
187 * If you have an enquiry about this, *please* check the linux-arm-kernel
188 * mailing list archives BEFORE sending another post to the list.
189 *
190 * r0 = cp#15 control register
191 * r13 = *virtual* address to jump to upon completion
192 *
193 * other registers depend on the function called upon completion
194 */
195 .align 5
196__turn_mmu_on:
197 mov r0, r0
198 mcr p15, 0, r0, c1, c0, 0 @ write control reg
199 mrc p15, 0, r3, c0, c0, 0 @ read id reg
200 mov r3, r3
201 mov r3, r13
202 mov pc, r3
203ENDPROC(__turn_mmu_on)
204
205 114
206/* 115/*
207 * Setup the initial page tables. We only setup the barest 116 * Setup the initial page tables. We only setup the barest
@@ -213,7 +122,7 @@ ENDPROC(__turn_mmu_on)
213 * r10 = procinfo 122 * r10 = procinfo
214 * 123 *
215 * Returns: 124 * Returns:
216 * r0, r3, r6, r7 corrupted 125 * r0, r3, r5-r7 corrupted
217 * r4 = physical page table address 126 * r4 = physical page table address
218 */ 127 */
219__create_page_tables: 128__create_page_tables:
@@ -235,20 +144,30 @@ __create_page_tables:
235 ldr r7, [r10, #PROCINFO_MM_MMUFLAGS] @ mm_mmuflags 144 ldr r7, [r10, #PROCINFO_MM_MMUFLAGS] @ mm_mmuflags
236 145
237 /* 146 /*
238 * Create identity mapping for first MB of kernel to 147 * Create identity mapping to cater for __enable_mmu.
239 * cater for the MMU enable. This identity mapping 148 * This identity mapping will be removed by paging_init().
240 * will be removed by paging_init(). We use our current program
241 * counter to determine corresponding section base address.
242 */ 149 */
243 mov r6, pc 150 adr r0, __enable_mmu_loc
244 mov r6, r6, lsr #20 @ start of kernel section 151 ldmia r0, {r3, r5, r6}
245 orr r3, r7, r6, lsl #20 @ flags + kernel base 152 sub r0, r0, r3 @ virt->phys offset
246 str r3, [r4, r6, lsl #2] @ identity mapping 153 add r5, r5, r0 @ phys __enable_mmu
154 add r6, r6, r0 @ phys __enable_mmu_end
155 mov r5, r5, lsr #20
156 mov r6, r6, lsr #20
157
1581: orr r3, r7, r5, lsl #20 @ flags + kernel base
159 str r3, [r4, r5, lsl #2] @ identity mapping
160 teq r5, r6
161 addne r5, r5, #1 @ next section
162 bne 1b
247 163
248 /* 164 /*
249 * Now setup the pagetables for our kernel direct 165 * Now setup the pagetables for our kernel direct
250 * mapped region. 166 * mapped region.
251 */ 167 */
168 mov r3, pc
169 mov r3, r3, lsr #20
170 orr r3, r7, r3, lsl #20
252 add r0, r4, #(KERNEL_START & 0xff000000) >> 18 171 add r0, r4, #(KERNEL_START & 0xff000000) >> 18
253 str r3, [r0, #(KERNEL_START & 0x00f00000) >> 18]! 172 str r3, [r0, #(KERNEL_START & 0x00f00000) >> 18]!
254 ldr r6, =(KERNEL_END - 1) 173 ldr r6, =(KERNEL_END - 1)
@@ -289,24 +208,35 @@ __create_page_tables:
289 str r6, [r0] 208 str r6, [r0]
290 209
291#ifdef CONFIG_DEBUG_LL 210#ifdef CONFIG_DEBUG_LL
292 ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags 211#ifndef CONFIG_DEBUG_ICEDCC
293 /* 212 /*
294 * Map in IO space for serial debugging. 213 * Map in IO space for serial debugging.
295 * This allows debug messages to be output 214 * This allows debug messages to be output
296 * via a serial console before paging_init. 215 * via a serial console before paging_init.
297 */ 216 */
298 ldr r3, [r8, #MACHINFO_PGOFFIO] 217 addruart r7, r3
218
219 mov r3, r3, lsr #20
220 mov r3, r3, lsl #2
221
299 add r0, r4, r3 222 add r0, r4, r3
300 rsb r3, r3, #0x4000 @ PTRS_PER_PGD*sizeof(long) 223 rsb r3, r3, #0x4000 @ PTRS_PER_PGD*sizeof(long)
301 cmp r3, #0x0800 @ limit to 512MB 224 cmp r3, #0x0800 @ limit to 512MB
302 movhi r3, #0x0800 225 movhi r3, #0x0800
303 add r6, r0, r3 226 add r6, r0, r3
304 ldr r3, [r8, #MACHINFO_PHYSIO] 227 mov r3, r7, lsr #20
305 orr r3, r3, r7 228 ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
229 orr r3, r7, r3, lsl #20
3061: str r3, [r0], #4 2301: str r3, [r0], #4
307 add r3, r3, #1 << 20 231 add r3, r3, #1 << 20
308 teq r0, r6 232 teq r0, r6
309 bne 1b 233 bne 1b
234
235#else /* CONFIG_DEBUG_ICEDCC */
236 /* we don't need any serial debugging mappings for ICEDCC */
237 ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
238#endif /* !CONFIG_DEBUG_ICEDCC */
239
310#if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS) 240#if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
311 /* 241 /*
312 * If we're using the NetWinder or CATS, we also need to map 242 * If we're using the NetWinder or CATS, we also need to map
@@ -332,5 +262,168 @@ __create_page_tables:
332 mov pc, lr 262 mov pc, lr
333ENDPROC(__create_page_tables) 263ENDPROC(__create_page_tables)
334 .ltorg 264 .ltorg
265__enable_mmu_loc:
266 .long .
267 .long __enable_mmu
268 .long __enable_mmu_end
269
270#if defined(CONFIG_SMP)
271 __CPUINIT
272ENTRY(secondary_startup)
273 /*
274 * Common entry point for secondary CPUs.
275 *
276 * Ensure that we're in SVC mode, and IRQs are disabled. Lookup
277 * the processor type - there is no need to check the machine type
278 * as it has already been validated by the primary processor.
279 */
280 setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9
281 mrc p15, 0, r9, c0, c0 @ get processor id
282 bl __lookup_processor_type
283 movs r10, r5 @ invalid processor?
284 moveq r0, #'p' @ yes, error 'p'
285 beq __error_p
286
287 /*
288 * Use the page tables supplied from __cpu_up.
289 */
290 adr r4, __secondary_data
291 ldmia r4, {r5, r7, r12} @ address to jump to after
292 sub r4, r4, r5 @ mmu has been enabled
293 ldr r4, [r7, r4] @ get secondary_data.pgdir
294 adr lr, BSYM(__enable_mmu) @ return address
295 mov r13, r12 @ __secondary_switched address
296 ARM( add pc, r10, #PROCINFO_INITFUNC ) @ initialise processor
297 @ (return control reg)
298 THUMB( add r12, r10, #PROCINFO_INITFUNC )
299 THUMB( mov pc, r12 )
300ENDPROC(secondary_startup)
301
302 /*
303 * r6 = &secondary_data
304 */
305ENTRY(__secondary_switched)
306 ldr sp, [r7, #4] @ get secondary_data.stack
307 mov fp, #0
308 b secondary_start_kernel
309ENDPROC(__secondary_switched)
310
311 .type __secondary_data, %object
312__secondary_data:
313 .long .
314 .long secondary_data
315 .long __secondary_switched
316#endif /* defined(CONFIG_SMP) */
317
318
319
320/*
321 * Setup common bits before finally enabling the MMU. Essentially
322 * this is just loading the page table pointer and domain access
323 * registers.
324 *
325 * r0 = cp#15 control register
326 * r1 = machine ID
327 * r2 = atags pointer
328 * r4 = page table pointer
329 * r9 = processor ID
330 * r13 = *virtual* address to jump to upon completion
331 */
332__enable_mmu:
333#ifdef CONFIG_ALIGNMENT_TRAP
334 orr r0, r0, #CR_A
335#else
336 bic r0, r0, #CR_A
337#endif
338#ifdef CONFIG_CPU_DCACHE_DISABLE
339 bic r0, r0, #CR_C
340#endif
341#ifdef CONFIG_CPU_BPREDICT_DISABLE
342 bic r0, r0, #CR_Z
343#endif
344#ifdef CONFIG_CPU_ICACHE_DISABLE
345 bic r0, r0, #CR_I
346#endif
347 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
348 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
349 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
350 domain_val(DOMAIN_IO, DOMAIN_CLIENT))
351 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
352 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
353 b __turn_mmu_on
354ENDPROC(__enable_mmu)
355
356/*
357 * Enable the MMU. This completely changes the structure of the visible
358 * memory space. You will not be able to trace execution through this.
359 * If you have an enquiry about this, *please* check the linux-arm-kernel
360 * mailing list archives BEFORE sending another post to the list.
361 *
362 * r0 = cp#15 control register
363 * r1 = machine ID
364 * r2 = atags pointer
365 * r9 = processor ID
366 * r13 = *virtual* address to jump to upon completion
367 *
368 * other registers depend on the function called upon completion
369 */
370 .align 5
371__turn_mmu_on:
372 mov r0, r0
373 mcr p15, 0, r0, c1, c0, 0 @ write control reg
374 mrc p15, 0, r3, c0, c0, 0 @ read id reg
375 mov r3, r3
376 mov r3, r13
377 mov pc, r3
378__enable_mmu_end:
379ENDPROC(__turn_mmu_on)
380
381
382#ifdef CONFIG_SMP_ON_UP
383__fixup_smp:
384 mov r7, #0x00070000
385 orr r6, r7, #0xff000000 @ mask 0xff070000
386 orr r7, r7, #0x41000000 @ val 0x41070000
387 and r0, r9, r6
388 teq r0, r7 @ ARM CPU and ARMv6/v7?
389 bne __fixup_smp_on_up @ no, assume UP
390
391 orr r6, r6, #0x0000ff00
392 orr r6, r6, #0x000000f0 @ mask 0xff07fff0
393 orr r7, r7, #0x0000b000
394 orr r7, r7, #0x00000020 @ val 0x4107b020
395 and r0, r9, r6
396 teq r0, r7 @ ARM 11MPCore?
397 moveq pc, lr @ yes, assume SMP
398
399 mrc p15, 0, r0, c0, c0, 5 @ read MPIDR
400 tst r0, #1 << 31
401 movne pc, lr @ bit 31 => SMP
402
403__fixup_smp_on_up:
404 adr r0, 1f
405 ldmia r0, {r3, r6, r7}
406 sub r3, r0, r3
407 add r6, r6, r3
408 add r7, r7, r3
4092: cmp r6, r7
410 ldmia r6!, {r0, r4}
411 strlo r4, [r0, r3]
412 blo 2b
413 mov pc, lr
414ENDPROC(__fixup_smp)
415
4161: .word .
417 .word __smpalt_begin
418 .word __smpalt_end
419
420 .pushsection .data
421 .globl smp_on_up
422smp_on_up:
423 ALT_SMP(.long 1)
424 ALT_UP(.long 0)
425 .popsection
426
427#endif
335 428
336#include "head-common.S" 429#include "head-common.S"
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
new file mode 100644
index 000000000000..54593b0c241b
--- /dev/null
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -0,0 +1,849 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14 *
15 * Copyright (C) 2009, 2010 ARM Limited
16 *
17 * Author: Will Deacon <will.deacon@arm.com>
18 */
19
20/*
21 * HW_breakpoint: a unified kernel/user-space hardware breakpoint facility,
22 * using the CPU's debug registers.
23 */
24#define pr_fmt(fmt) "hw-breakpoint: " fmt
25
26#include <linux/errno.h>
27#include <linux/perf_event.h>
28#include <linux/hw_breakpoint.h>
29#include <linux/smp.h>
30
31#include <asm/cacheflush.h>
32#include <asm/cputype.h>
33#include <asm/current.h>
34#include <asm/hw_breakpoint.h>
35#include <asm/kdebug.h>
36#include <asm/system.h>
37#include <asm/traps.h>
38
39/* Breakpoint currently in use for each BRP. */
40static DEFINE_PER_CPU(struct perf_event *, bp_on_reg[ARM_MAX_BRP]);
41
42/* Watchpoint currently in use for each WRP. */
43static DEFINE_PER_CPU(struct perf_event *, wp_on_reg[ARM_MAX_WRP]);
44
45/* Number of BRP/WRP registers on this CPU. */
46static int core_num_brps;
47static int core_num_wrps;
48
49/* Debug architecture version. */
50static u8 debug_arch;
51
52/* Maximum supported watchpoint length. */
53static u8 max_watchpoint_len;
54
55/* Determine number of BRP registers available. */
56static int get_num_brps(void)
57{
58 u32 didr;
59 ARM_DBG_READ(c0, 0, didr);
60 return ((didr >> 24) & 0xf) + 1;
61}
62
63/* Determine number of WRP registers available. */
64static int get_num_wrps(void)
65{
66 /*
67 * FIXME: When a watchpoint fires, the only way to work out which
68 * watchpoint it was is by disassembling the faulting instruction
69 * and working out the address of the memory access.
70 *
71 * Furthermore, we can only do this if the watchpoint was precise
72 * since imprecise watchpoints prevent us from calculating register
73 * based addresses.
74 *
75 * For the time being, we only report 1 watchpoint register so we
76 * always know which watchpoint fired. In the future we can either
77 * add a disassembler and address generation emulator, or we can
78 * insert a check to see if the DFAR is set on watchpoint exception
79 * entry [the ARM ARM states that the DFAR is UNKNOWN, but
80 * experience shows that it is set on some implementations].
81 */
82
83#if 0
84 u32 didr, wrps;
85 ARM_DBG_READ(c0, 0, didr);
86 return ((didr >> 28) & 0xf) + 1;
87#endif
88
89 return 1;
90}
91
92int hw_breakpoint_slots(int type)
93{
94 /*
95 * We can be called early, so don't rely on
96 * our static variables being initialised.
97 */
98 switch (type) {
99 case TYPE_INST:
100 return get_num_brps();
101 case TYPE_DATA:
102 return get_num_wrps();
103 default:
104 pr_warning("unknown slot type: %d\n", type);
105 return 0;
106 }
107}
108
109/* Determine debug architecture. */
110static u8 get_debug_arch(void)
111{
112 u32 didr;
113
114 /* Do we implement the extended CPUID interface? */
115 if (((read_cpuid_id() >> 16) & 0xf) != 0xf) {
116 pr_warning("CPUID feature registers not supported. "
117 "Assuming v6 debug is present.\n");
118 return ARM_DEBUG_ARCH_V6;
119 }
120
121 ARM_DBG_READ(c0, 0, didr);
122 return (didr >> 16) & 0xf;
123}
124
125/* Does this core support mismatch breakpoints? */
126static int core_has_mismatch_bps(void)
127{
128 return debug_arch >= ARM_DEBUG_ARCH_V7_ECP14 && core_num_brps > 1;
129}
130
131u8 arch_get_debug_arch(void)
132{
133 return debug_arch;
134}
135
136#define READ_WB_REG_CASE(OP2, M, VAL) \
137 case ((OP2 << 4) + M): \
138 ARM_DBG_READ(c ## M, OP2, VAL); \
139 break
140
141#define WRITE_WB_REG_CASE(OP2, M, VAL) \
142 case ((OP2 << 4) + M): \
143 ARM_DBG_WRITE(c ## M, OP2, VAL);\
144 break
145
146#define GEN_READ_WB_REG_CASES(OP2, VAL) \
147 READ_WB_REG_CASE(OP2, 0, VAL); \
148 READ_WB_REG_CASE(OP2, 1, VAL); \
149 READ_WB_REG_CASE(OP2, 2, VAL); \
150 READ_WB_REG_CASE(OP2, 3, VAL); \
151 READ_WB_REG_CASE(OP2, 4, VAL); \
152 READ_WB_REG_CASE(OP2, 5, VAL); \
153 READ_WB_REG_CASE(OP2, 6, VAL); \
154 READ_WB_REG_CASE(OP2, 7, VAL); \
155 READ_WB_REG_CASE(OP2, 8, VAL); \
156 READ_WB_REG_CASE(OP2, 9, VAL); \
157 READ_WB_REG_CASE(OP2, 10, VAL); \
158 READ_WB_REG_CASE(OP2, 11, VAL); \
159 READ_WB_REG_CASE(OP2, 12, VAL); \
160 READ_WB_REG_CASE(OP2, 13, VAL); \
161 READ_WB_REG_CASE(OP2, 14, VAL); \
162 READ_WB_REG_CASE(OP2, 15, VAL)
163
164#define GEN_WRITE_WB_REG_CASES(OP2, VAL) \
165 WRITE_WB_REG_CASE(OP2, 0, VAL); \
166 WRITE_WB_REG_CASE(OP2, 1, VAL); \
167 WRITE_WB_REG_CASE(OP2, 2, VAL); \
168 WRITE_WB_REG_CASE(OP2, 3, VAL); \
169 WRITE_WB_REG_CASE(OP2, 4, VAL); \
170 WRITE_WB_REG_CASE(OP2, 5, VAL); \
171 WRITE_WB_REG_CASE(OP2, 6, VAL); \
172 WRITE_WB_REG_CASE(OP2, 7, VAL); \
173 WRITE_WB_REG_CASE(OP2, 8, VAL); \
174 WRITE_WB_REG_CASE(OP2, 9, VAL); \
175 WRITE_WB_REG_CASE(OP2, 10, VAL); \
176 WRITE_WB_REG_CASE(OP2, 11, VAL); \
177 WRITE_WB_REG_CASE(OP2, 12, VAL); \
178 WRITE_WB_REG_CASE(OP2, 13, VAL); \
179 WRITE_WB_REG_CASE(OP2, 14, VAL); \
180 WRITE_WB_REG_CASE(OP2, 15, VAL)
181
182static u32 read_wb_reg(int n)
183{
184 u32 val = 0;
185
186 switch (n) {
187 GEN_READ_WB_REG_CASES(ARM_OP2_BVR, val);
188 GEN_READ_WB_REG_CASES(ARM_OP2_BCR, val);
189 GEN_READ_WB_REG_CASES(ARM_OP2_WVR, val);
190 GEN_READ_WB_REG_CASES(ARM_OP2_WCR, val);
191 default:
192 pr_warning("attempt to read from unknown breakpoint "
193 "register %d\n", n);
194 }
195
196 return val;
197}
198
199static void write_wb_reg(int n, u32 val)
200{
201 switch (n) {
202 GEN_WRITE_WB_REG_CASES(ARM_OP2_BVR, val);
203 GEN_WRITE_WB_REG_CASES(ARM_OP2_BCR, val);
204 GEN_WRITE_WB_REG_CASES(ARM_OP2_WVR, val);
205 GEN_WRITE_WB_REG_CASES(ARM_OP2_WCR, val);
206 default:
207 pr_warning("attempt to write to unknown breakpoint "
208 "register %d\n", n);
209 }
210 isb();
211}
212
213/*
214 * In order to access the breakpoint/watchpoint control registers,
215 * we must be running in debug monitor mode. Unfortunately, we can
216 * be put into halting debug mode at any time by an external debugger
217 * but there is nothing we can do to prevent that.
218 */
219static int enable_monitor_mode(void)
220{
221 u32 dscr;
222 int ret = 0;
223
224 ARM_DBG_READ(c1, 0, dscr);
225
226 /* Ensure that halting mode is disabled. */
227 if (WARN_ONCE(dscr & ARM_DSCR_HDBGEN, "halting debug mode enabled."
228 "Unable to access hardware resources.")) {
229 ret = -EPERM;
230 goto out;
231 }
232
233 /* Write to the corresponding DSCR. */
234 switch (debug_arch) {
235 case ARM_DEBUG_ARCH_V6:
236 case ARM_DEBUG_ARCH_V6_1:
237 ARM_DBG_WRITE(c1, 0, (dscr | ARM_DSCR_MDBGEN));
238 break;
239 case ARM_DEBUG_ARCH_V7_ECP14:
240 ARM_DBG_WRITE(c2, 2, (dscr | ARM_DSCR_MDBGEN));
241 break;
242 default:
243 ret = -ENODEV;
244 goto out;
245 }
246
247 /* Check that the write made it through. */
248 ARM_DBG_READ(c1, 0, dscr);
249 if (WARN_ONCE(!(dscr & ARM_DSCR_MDBGEN),
250 "failed to enable monitor mode.")) {
251 ret = -EPERM;
252 }
253
254out:
255 return ret;
256}
257
258/*
259 * Check if 8-bit byte-address select is available.
260 * This clobbers WRP 0.
261 */
262static u8 get_max_wp_len(void)
263{
264 u32 ctrl_reg;
265 struct arch_hw_breakpoint_ctrl ctrl;
266 u8 size = 4;
267
268 if (debug_arch < ARM_DEBUG_ARCH_V7_ECP14)
269 goto out;
270
271 if (enable_monitor_mode())
272 goto out;
273
274 memset(&ctrl, 0, sizeof(ctrl));
275 ctrl.len = ARM_BREAKPOINT_LEN_8;
276 ctrl_reg = encode_ctrl_reg(ctrl);
277
278 write_wb_reg(ARM_BASE_WVR, 0);
279 write_wb_reg(ARM_BASE_WCR, ctrl_reg);
280 if ((read_wb_reg(ARM_BASE_WCR) & ctrl_reg) == ctrl_reg)
281 size = 8;
282
283out:
284 return size;
285}
286
287u8 arch_get_max_wp_len(void)
288{
289 return max_watchpoint_len;
290}
291
292/*
293 * Handler for reactivating a suspended watchpoint when the single
294 * step `mismatch' breakpoint is triggered.
295 */
296static void wp_single_step_handler(struct perf_event *bp, int unused,
297 struct perf_sample_data *data,
298 struct pt_regs *regs)
299{
300 perf_event_enable(counter_arch_bp(bp)->suspended_wp);
301 unregister_hw_breakpoint(bp);
302}
303
304static int bp_is_single_step(struct perf_event *bp)
305{
306 return bp->overflow_handler == wp_single_step_handler;
307}
308
309/*
310 * Install a perf counter breakpoint.
311 */
312int arch_install_hw_breakpoint(struct perf_event *bp)
313{
314 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
315 struct perf_event **slot, **slots;
316 int i, max_slots, ctrl_base, val_base, ret = 0;
317
318 /* Ensure that we are in monitor mode and halting mode is disabled. */
319 ret = enable_monitor_mode();
320 if (ret)
321 goto out;
322
323 if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) {
324 /* Breakpoint */
325 ctrl_base = ARM_BASE_BCR;
326 val_base = ARM_BASE_BVR;
327 slots = __get_cpu_var(bp_on_reg);
328 max_slots = core_num_brps - 1;
329
330 if (bp_is_single_step(bp)) {
331 info->ctrl.mismatch = 1;
332 i = max_slots;
333 slots[i] = bp;
334 goto setup;
335 }
336 } else {
337 /* Watchpoint */
338 ctrl_base = ARM_BASE_WCR;
339 val_base = ARM_BASE_WVR;
340 slots = __get_cpu_var(wp_on_reg);
341 max_slots = core_num_wrps;
342 }
343
344 for (i = 0; i < max_slots; ++i) {
345 slot = &slots[i];
346
347 if (!*slot) {
348 *slot = bp;
349 break;
350 }
351 }
352
353 if (WARN_ONCE(i == max_slots, "Can't find any breakpoint slot")) {
354 ret = -EBUSY;
355 goto out;
356 }
357
358setup:
359 /* Setup the address register. */
360 write_wb_reg(val_base + i, info->address);
361
362 /* Setup the control register. */
363 write_wb_reg(ctrl_base + i, encode_ctrl_reg(info->ctrl) | 0x1);
364
365out:
366 return ret;
367}
368
369void arch_uninstall_hw_breakpoint(struct perf_event *bp)
370{
371 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
372 struct perf_event **slot, **slots;
373 int i, max_slots, base;
374
375 if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) {
376 /* Breakpoint */
377 base = ARM_BASE_BCR;
378 slots = __get_cpu_var(bp_on_reg);
379 max_slots = core_num_brps - 1;
380
381 if (bp_is_single_step(bp)) {
382 i = max_slots;
383 slots[i] = NULL;
384 goto reset;
385 }
386 } else {
387 /* Watchpoint */
388 base = ARM_BASE_WCR;
389 slots = __get_cpu_var(wp_on_reg);
390 max_slots = core_num_wrps;
391 }
392
393 /* Remove the breakpoint. */
394 for (i = 0; i < max_slots; ++i) {
395 slot = &slots[i];
396
397 if (*slot == bp) {
398 *slot = NULL;
399 break;
400 }
401 }
402
403 if (WARN_ONCE(i == max_slots, "Can't find any breakpoint slot"))
404 return;
405
406reset:
407 /* Reset the control register. */
408 write_wb_reg(base + i, 0);
409}
410
411static int get_hbp_len(u8 hbp_len)
412{
413 unsigned int len_in_bytes = 0;
414
415 switch (hbp_len) {
416 case ARM_BREAKPOINT_LEN_1:
417 len_in_bytes = 1;
418 break;
419 case ARM_BREAKPOINT_LEN_2:
420 len_in_bytes = 2;
421 break;
422 case ARM_BREAKPOINT_LEN_4:
423 len_in_bytes = 4;
424 break;
425 case ARM_BREAKPOINT_LEN_8:
426 len_in_bytes = 8;
427 break;
428 }
429
430 return len_in_bytes;
431}
432
433/*
434 * Check whether bp virtual address is in kernel space.
435 */
436int arch_check_bp_in_kernelspace(struct perf_event *bp)
437{
438 unsigned int len;
439 unsigned long va;
440 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
441
442 va = info->address;
443 len = get_hbp_len(info->ctrl.len);
444
445 return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);
446}
447
448/*
449 * Extract generic type and length encodings from an arch_hw_breakpoint_ctrl.
450 * Hopefully this will disappear when ptrace can bypass the conversion
451 * to generic breakpoint descriptions.
452 */
453int arch_bp_generic_fields(struct arch_hw_breakpoint_ctrl ctrl,
454 int *gen_len, int *gen_type)
455{
456 /* Type */
457 switch (ctrl.type) {
458 case ARM_BREAKPOINT_EXECUTE:
459 *gen_type = HW_BREAKPOINT_X;
460 break;
461 case ARM_BREAKPOINT_LOAD:
462 *gen_type = HW_BREAKPOINT_R;
463 break;
464 case ARM_BREAKPOINT_STORE:
465 *gen_type = HW_BREAKPOINT_W;
466 break;
467 case ARM_BREAKPOINT_LOAD | ARM_BREAKPOINT_STORE:
468 *gen_type = HW_BREAKPOINT_RW;
469 break;
470 default:
471 return -EINVAL;
472 }
473
474 /* Len */
475 switch (ctrl.len) {
476 case ARM_BREAKPOINT_LEN_1:
477 *gen_len = HW_BREAKPOINT_LEN_1;
478 break;
479 case ARM_BREAKPOINT_LEN_2:
480 *gen_len = HW_BREAKPOINT_LEN_2;
481 break;
482 case ARM_BREAKPOINT_LEN_4:
483 *gen_len = HW_BREAKPOINT_LEN_4;
484 break;
485 case ARM_BREAKPOINT_LEN_8:
486 *gen_len = HW_BREAKPOINT_LEN_8;
487 break;
488 default:
489 return -EINVAL;
490 }
491
492 return 0;
493}
494
495/*
496 * Construct an arch_hw_breakpoint from a perf_event.
497 */
498static int arch_build_bp_info(struct perf_event *bp)
499{
500 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
501
502 /* Type */
503 switch (bp->attr.bp_type) {
504 case HW_BREAKPOINT_X:
505 info->ctrl.type = ARM_BREAKPOINT_EXECUTE;
506 break;
507 case HW_BREAKPOINT_R:
508 info->ctrl.type = ARM_BREAKPOINT_LOAD;
509 break;
510 case HW_BREAKPOINT_W:
511 info->ctrl.type = ARM_BREAKPOINT_STORE;
512 break;
513 case HW_BREAKPOINT_RW:
514 info->ctrl.type = ARM_BREAKPOINT_LOAD | ARM_BREAKPOINT_STORE;
515 break;
516 default:
517 return -EINVAL;
518 }
519
520 /* Len */
521 switch (bp->attr.bp_len) {
522 case HW_BREAKPOINT_LEN_1:
523 info->ctrl.len = ARM_BREAKPOINT_LEN_1;
524 break;
525 case HW_BREAKPOINT_LEN_2:
526 info->ctrl.len = ARM_BREAKPOINT_LEN_2;
527 break;
528 case HW_BREAKPOINT_LEN_4:
529 info->ctrl.len = ARM_BREAKPOINT_LEN_4;
530 break;
531 case HW_BREAKPOINT_LEN_8:
532 info->ctrl.len = ARM_BREAKPOINT_LEN_8;
533 if ((info->ctrl.type != ARM_BREAKPOINT_EXECUTE)
534 && max_watchpoint_len >= 8)
535 break;
536 default:
537 return -EINVAL;
538 }
539
540 /* Address */
541 info->address = bp->attr.bp_addr;
542
543 /* Privilege */
544 info->ctrl.privilege = ARM_BREAKPOINT_USER;
545 if (arch_check_bp_in_kernelspace(bp) && !bp_is_single_step(bp))
546 info->ctrl.privilege |= ARM_BREAKPOINT_PRIV;
547
548 /* Enabled? */
549 info->ctrl.enabled = !bp->attr.disabled;
550
551 /* Mismatch */
552 info->ctrl.mismatch = 0;
553
554 return 0;
555}
556
557/*
558 * Validate the arch-specific HW Breakpoint register settings.
559 */
560int arch_validate_hwbkpt_settings(struct perf_event *bp)
561{
562 struct arch_hw_breakpoint *info = counter_arch_bp(bp);
563 int ret = 0;
564 u32 bytelen, max_len, offset, alignment_mask = 0x3;
565
566 /* Build the arch_hw_breakpoint. */
567 ret = arch_build_bp_info(bp);
568 if (ret)
569 goto out;
570
571 /* Check address alignment. */
572 if (info->ctrl.len == ARM_BREAKPOINT_LEN_8)
573 alignment_mask = 0x7;
574 if (info->address & alignment_mask) {
575 /*
576 * Try to fix the alignment. This may result in a length
577 * that is too large, so we must check for that.
578 */
579 bytelen = get_hbp_len(info->ctrl.len);
580 max_len = info->ctrl.type == ARM_BREAKPOINT_EXECUTE ? 4 :
581 max_watchpoint_len;
582
583 if (max_len >= 8)
584 offset = info->address & 0x7;
585 else
586 offset = info->address & 0x3;
587
588 if (bytelen > (1 << ((max_len - (offset + 1)) >> 1))) {
589 ret = -EFBIG;
590 goto out;
591 }
592
593 info->ctrl.len <<= offset;
594 info->address &= ~offset;
595
596 pr_debug("breakpoint alignment fixup: length = 0x%x, "
597 "address = 0x%x\n", info->ctrl.len, info->address);
598 }
599
600 /*
601 * Currently we rely on an overflow handler to take
602 * care of single-stepping the breakpoint when it fires.
603 * In the case of userspace breakpoints on a core with V7 debug,
604 * we can use the mismatch feature as a poor-man's hardware single-step.
605 */
606 if (WARN_ONCE(!bp->overflow_handler &&
607 (arch_check_bp_in_kernelspace(bp) || !core_has_mismatch_bps()),
608 "overflow handler required but none found")) {
609 ret = -EINVAL;
610 goto out;
611 }
612out:
613 return ret;
614}
615
616static void update_mismatch_flag(int idx, int flag)
617{
618 struct perf_event *bp = __get_cpu_var(bp_on_reg[idx]);
619 struct arch_hw_breakpoint *info;
620
621 if (bp == NULL)
622 return;
623
624 info = counter_arch_bp(bp);
625
626 /* Update the mismatch field to enter/exit `single-step' mode */
627 if (!bp->overflow_handler && info->ctrl.mismatch != flag) {
628 info->ctrl.mismatch = flag;
629 write_wb_reg(ARM_BASE_BCR + idx, encode_ctrl_reg(info->ctrl) | 0x1);
630 }
631}
632
633static void watchpoint_handler(unsigned long unknown, struct pt_regs *regs)
634{
635 int i;
636 struct perf_event *bp, **slots = __get_cpu_var(wp_on_reg);
637 struct arch_hw_breakpoint *info;
638 struct perf_event_attr attr;
639
640 /* Without a disassembler, we can only handle 1 watchpoint. */
641 BUG_ON(core_num_wrps > 1);
642
643 hw_breakpoint_init(&attr);
644 attr.bp_addr = regs->ARM_pc & ~0x3;
645 attr.bp_len = HW_BREAKPOINT_LEN_4;
646 attr.bp_type = HW_BREAKPOINT_X;
647
648 for (i = 0; i < core_num_wrps; ++i) {
649 rcu_read_lock();
650
651 if (slots[i] == NULL) {
652 rcu_read_unlock();
653 continue;
654 }
655
656 /*
657 * The DFAR is an unknown value. Since we only allow a
658 * single watchpoint, we can set the trigger to the lowest
659 * possible faulting address.
660 */
661 info = counter_arch_bp(slots[i]);
662 info->trigger = slots[i]->attr.bp_addr;
663 pr_debug("watchpoint fired: address = 0x%x\n", info->trigger);
664 perf_bp_event(slots[i], regs);
665
666 /*
667 * If no overflow handler is present, insert a temporary
668 * mismatch breakpoint so we can single-step over the
669 * watchpoint trigger.
670 */
671 if (!slots[i]->overflow_handler) {
672 bp = register_user_hw_breakpoint(&attr,
673 wp_single_step_handler,
674 current);
675 counter_arch_bp(bp)->suspended_wp = slots[i];
676 perf_event_disable(slots[i]);
677 }
678
679 rcu_read_unlock();
680 }
681}
682
683static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
684{
685 int i;
686 int mismatch;
687 u32 ctrl_reg, val, addr;
688 struct perf_event *bp, **slots = __get_cpu_var(bp_on_reg);
689 struct arch_hw_breakpoint *info;
690 struct arch_hw_breakpoint_ctrl ctrl;
691
692 /* The exception entry code places the amended lr in the PC. */
693 addr = regs->ARM_pc;
694
695 for (i = 0; i < core_num_brps; ++i) {
696 rcu_read_lock();
697
698 bp = slots[i];
699
700 if (bp == NULL) {
701 rcu_read_unlock();
702 continue;
703 }
704
705 mismatch = 0;
706
707 /* Check if the breakpoint value matches. */
708 val = read_wb_reg(ARM_BASE_BVR + i);
709 if (val != (addr & ~0x3))
710 goto unlock;
711
712 /* Possible match, check the byte address select to confirm. */
713 ctrl_reg = read_wb_reg(ARM_BASE_BCR + i);
714 decode_ctrl_reg(ctrl_reg, &ctrl);
715 if ((1 << (addr & 0x3)) & ctrl.len) {
716 mismatch = 1;
717 info = counter_arch_bp(bp);
718 info->trigger = addr;
719 }
720
721unlock:
722 if ((mismatch && !info->ctrl.mismatch) || bp_is_single_step(bp)) {
723 pr_debug("breakpoint fired: address = 0x%x\n", addr);
724 perf_bp_event(bp, regs);
725 }
726
727 update_mismatch_flag(i, mismatch);
728 rcu_read_unlock();
729 }
730}
731
732/*
733 * Called from either the Data Abort Handler [watchpoint] or the
734 * Prefetch Abort Handler [breakpoint].
735 */
736static int hw_breakpoint_pending(unsigned long addr, unsigned int fsr,
737 struct pt_regs *regs)
738{
739 int ret = 1; /* Unhandled fault. */
740 u32 dscr;
741
742 /* We only handle watchpoints and hardware breakpoints. */
743 ARM_DBG_READ(c1, 0, dscr);
744
745 /* Perform perf callbacks. */
746 switch (ARM_DSCR_MOE(dscr)) {
747 case ARM_ENTRY_BREAKPOINT:
748 breakpoint_handler(addr, regs);
749 break;
750 case ARM_ENTRY_ASYNC_WATCHPOINT:
751 WARN_ON("Asynchronous watchpoint exception taken. "
752 "Debugging results may be unreliable");
753 case ARM_ENTRY_SYNC_WATCHPOINT:
754 watchpoint_handler(addr, regs);
755 break;
756 default:
757 goto out;
758 }
759
760 ret = 0;
761out:
762 return ret;
763}
764
765/*
766 * One-time initialisation.
767 */
768static void __init reset_ctrl_regs(void *unused)
769{
770 int i;
771
772 if (enable_monitor_mode())
773 return;
774
775 for (i = 0; i < core_num_brps; ++i) {
776 write_wb_reg(ARM_BASE_BCR + i, 0UL);
777 write_wb_reg(ARM_BASE_BVR + i, 0UL);
778 }
779
780 for (i = 0; i < core_num_wrps; ++i) {
781 write_wb_reg(ARM_BASE_WCR + i, 0UL);
782 write_wb_reg(ARM_BASE_WVR + i, 0UL);
783 }
784}
785
786static int __init arch_hw_breakpoint_init(void)
787{
788 int ret = 0;
789 u32 dscr;
790
791 debug_arch = get_debug_arch();
792
793 if (debug_arch > ARM_DEBUG_ARCH_V7_ECP14) {
794 pr_info("debug architecture 0x%x unsupported.\n", debug_arch);
795 ret = -ENODEV;
796 goto out;
797 }
798
799 /* Determine how many BRPs/WRPs are available. */
800 core_num_brps = get_num_brps();
801 core_num_wrps = get_num_wrps();
802
803 pr_info("found %d breakpoint and %d watchpoint registers.\n",
804 core_num_brps, core_num_wrps);
805
806 if (core_has_mismatch_bps())
807 pr_info("1 breakpoint reserved for watchpoint single-step.\n");
808
809 ARM_DBG_READ(c1, 0, dscr);
810 if (dscr & ARM_DSCR_HDBGEN) {
811 pr_warning("halting debug mode enabled. Assuming maximum "
812 "watchpoint size of 4 bytes.");
813 } else {
814 /* Work out the maximum supported watchpoint length. */
815 max_watchpoint_len = get_max_wp_len();
816 pr_info("maximum watchpoint size is %u bytes.\n",
817 max_watchpoint_len);
818
819 /*
820 * Reset the breakpoint resources. We assume that a halting
821 * debugger will leave the world in a nice state for us.
822 */
823 smp_call_function(reset_ctrl_regs, NULL, 1);
824 reset_ctrl_regs(NULL);
825 }
826
827 /* Register debug fault handler. */
828 hook_fault_code(2, hw_breakpoint_pending, SIGTRAP, TRAP_HWBKPT,
829 "watchpoint debug exception");
830 hook_ifault_code(2, hw_breakpoint_pending, SIGTRAP, TRAP_HWBKPT,
831 "breakpoint debug exception");
832
833out:
834 return ret;
835}
836arch_initcall(arch_hw_breakpoint_init);
837
838void hw_breakpoint_pmu_read(struct perf_event *bp)
839{
840}
841
842/*
843 * Dummy function to register with die_notifier.
844 */
845int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
846 unsigned long val, void *data)
847{
848 return NOTIFY_DONE;
849}
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index c0d5c3b3a760..36ad3be4692a 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -154,14 +154,6 @@ void set_irq_flags(unsigned int irq, unsigned int iflags)
154 154
155void __init init_IRQ(void) 155void __init init_IRQ(void)
156{ 156{
157 struct irq_desc *desc;
158 int irq;
159
160 for (irq = 0; irq < nr_irqs; irq++) {
161 desc = irq_to_desc_alloc_node(irq, 0);
162 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
163 }
164
165 init_arch_irq(); 157 init_arch_irq();
166} 158}
167 159
@@ -169,7 +161,7 @@ void __init init_IRQ(void)
169int __init arch_probe_nr_irqs(void) 161int __init arch_probe_nr_irqs(void)
170{ 162{
171 nr_irqs = arch_nr_irqs ? arch_nr_irqs : NR_IRQS; 163 nr_irqs = arch_nr_irqs ? arch_nr_irqs : NR_IRQS;
172 return 0; 164 return nr_irqs;
173} 165}
174#endif 166#endif
175 167
diff --git a/arch/arm/kernel/kprobes-decode.c b/arch/arm/kernel/kprobes-decode.c
index 8bccbfa693ff..2c1f0050c9c4 100644
--- a/arch/arm/kernel/kprobes-decode.c
+++ b/arch/arm/kernel/kprobes-decode.c
@@ -1162,11 +1162,12 @@ space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi)
1162{ 1162{
1163 /* 1163 /*
1164 * MSR : cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx 1164 * MSR : cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx
1165 * Undef : cccc 0011 0x00 xxxx xxxx xxxx xxxx xxxx 1165 * Undef : cccc 0011 0100 xxxx xxxx xxxx xxxx xxxx
1166 * ALU op with S bit and Rd == 15 : 1166 * ALU op with S bit and Rd == 15 :
1167 * cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx 1167 * cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx
1168 */ 1168 */
1169 if ((insn & 0x0f900000) == 0x03200000 || /* MSR & Undef */ 1169 if ((insn & 0x0fb00000) == 0x03200000 || /* MSR */
1170 (insn & 0x0ff00000) == 0x03400000 || /* Undef */
1170 (insn & 0x0e10f000) == 0x0210f000) /* ALU s-bit, R15 */ 1171 (insn & 0x0e10f000) == 0x0210f000) /* ALU s-bit, R15 */
1171 return INSN_REJECTED; 1172 return INSN_REJECTED;
1172 1173
@@ -1177,7 +1178,7 @@ space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi)
1177 * *S (bit 20) updates condition codes 1178 * *S (bit 20) updates condition codes
1178 * ADC/SBC/RSC reads the C flag 1179 * ADC/SBC/RSC reads the C flag
1179 */ 1180 */
1180 insn &= 0xfff00fff; /* Rn = r0, Rd = r0 */ 1181 insn &= 0xffff0fff; /* Rd = r0 */
1181 asi->insn[0] = insn; 1182 asi->insn[0] = insn;
1182 asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ 1183 asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */
1183 emulate_alu_imm_rwflags : emulate_alu_imm_rflags; 1184 emulate_alu_imm_rwflags : emulate_alu_imm_rflags;
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 6b4605893f1e..d9bd786ce23d 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -69,20 +69,31 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
69{ 69{
70#ifdef CONFIG_ARM_UNWIND 70#ifdef CONFIG_ARM_UNWIND
71 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum; 71 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
72 struct arm_unwind_mapping *maps = mod->arch.map;
72 73
73 for (s = sechdrs; s < sechdrs_end; s++) { 74 for (s = sechdrs; s < sechdrs_end; s++) {
74 if (strcmp(".ARM.exidx.init.text", secstrings + s->sh_name) == 0) 75 char const *secname = secstrings + s->sh_name;
75 mod->arch.unw_sec_init = s; 76
76 else if (strcmp(".ARM.exidx.devinit.text", secstrings + s->sh_name) == 0) 77 if (strcmp(".ARM.exidx.init.text", secname) == 0)
77 mod->arch.unw_sec_devinit = s; 78 maps[ARM_SEC_INIT].unw_sec = s;
78 else if (strcmp(".ARM.exidx", secstrings + s->sh_name) == 0) 79 else if (strcmp(".ARM.exidx.devinit.text", secname) == 0)
79 mod->arch.unw_sec_core = s; 80 maps[ARM_SEC_DEVINIT].unw_sec = s;
80 else if (strcmp(".init.text", secstrings + s->sh_name) == 0) 81 else if (strcmp(".ARM.exidx", secname) == 0)
81 mod->arch.sec_init_text = s; 82 maps[ARM_SEC_CORE].unw_sec = s;
82 else if (strcmp(".devinit.text", secstrings + s->sh_name) == 0) 83 else if (strcmp(".ARM.exidx.exit.text", secname) == 0)
83 mod->arch.sec_devinit_text = s; 84 maps[ARM_SEC_EXIT].unw_sec = s;
84 else if (strcmp(".text", secstrings + s->sh_name) == 0) 85 else if (strcmp(".ARM.exidx.devexit.text", secname) == 0)
85 mod->arch.sec_core_text = s; 86 maps[ARM_SEC_DEVEXIT].unw_sec = s;
87 else if (strcmp(".init.text", secname) == 0)
88 maps[ARM_SEC_INIT].sec_text = s;
89 else if (strcmp(".devinit.text", secname) == 0)
90 maps[ARM_SEC_DEVINIT].sec_text = s;
91 else if (strcmp(".text", secname) == 0)
92 maps[ARM_SEC_CORE].sec_text = s;
93 else if (strcmp(".exit.text", secname) == 0)
94 maps[ARM_SEC_EXIT].sec_text = s;
95 else if (strcmp(".devexit.text", secname) == 0)
96 maps[ARM_SEC_DEVEXIT].sec_text = s;
86 } 97 }
87#endif 98#endif
88 return 0; 99 return 0;
@@ -292,31 +303,22 @@ apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
292#ifdef CONFIG_ARM_UNWIND 303#ifdef CONFIG_ARM_UNWIND
293static void register_unwind_tables(struct module *mod) 304static void register_unwind_tables(struct module *mod)
294{ 305{
295 if (mod->arch.unw_sec_init && mod->arch.sec_init_text) 306 int i;
296 mod->arch.unwind_init = 307 for (i = 0; i < ARM_SEC_MAX; ++i) {
297 unwind_table_add(mod->arch.unw_sec_init->sh_addr, 308 struct arm_unwind_mapping *map = &mod->arch.map[i];
298 mod->arch.unw_sec_init->sh_size, 309 if (map->unw_sec && map->sec_text)
299 mod->arch.sec_init_text->sh_addr, 310 map->unwind = unwind_table_add(map->unw_sec->sh_addr,
300 mod->arch.sec_init_text->sh_size); 311 map->unw_sec->sh_size,
301 if (mod->arch.unw_sec_devinit && mod->arch.sec_devinit_text) 312 map->sec_text->sh_addr,
302 mod->arch.unwind_devinit = 313 map->sec_text->sh_size);
303 unwind_table_add(mod->arch.unw_sec_devinit->sh_addr, 314 }
304 mod->arch.unw_sec_devinit->sh_size,
305 mod->arch.sec_devinit_text->sh_addr,
306 mod->arch.sec_devinit_text->sh_size);
307 if (mod->arch.unw_sec_core && mod->arch.sec_core_text)
308 mod->arch.unwind_core =
309 unwind_table_add(mod->arch.unw_sec_core->sh_addr,
310 mod->arch.unw_sec_core->sh_size,
311 mod->arch.sec_core_text->sh_addr,
312 mod->arch.sec_core_text->sh_size);
313} 315}
314 316
315static void unregister_unwind_tables(struct module *mod) 317static void unregister_unwind_tables(struct module *mod)
316{ 318{
317 unwind_table_del(mod->arch.unwind_init); 319 int i = ARM_SEC_MAX;
318 unwind_table_del(mod->arch.unwind_devinit); 320 while (--i >= 0)
319 unwind_table_del(mod->arch.unwind_core); 321 unwind_table_del(mod->arch.map[i].unwind);
320} 322}
321#else 323#else
322static inline void register_unwind_tables(struct module *mod) { } 324static inline void register_unwind_tables(struct module *mod) { }
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index ecbb0288e5dd..49643b1467e6 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -123,6 +123,12 @@ armpmu_get_max_events(void)
123} 123}
124EXPORT_SYMBOL_GPL(armpmu_get_max_events); 124EXPORT_SYMBOL_GPL(armpmu_get_max_events);
125 125
126int perf_num_counters(void)
127{
128 return armpmu_get_max_events();
129}
130EXPORT_SYMBOL_GPL(perf_num_counters);
131
126#define HW_OP_UNSUPPORTED 0xFFFF 132#define HW_OP_UNSUPPORTED 0xFFFF
127 133
128#define C(_x) \ 134#define C(_x) \
@@ -221,46 +227,56 @@ again:
221} 227}
222 228
223static void 229static void
224armpmu_disable(struct perf_event *event) 230armpmu_read(struct perf_event *event)
225{ 231{
226 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
227 struct hw_perf_event *hwc = &event->hw; 232 struct hw_perf_event *hwc = &event->hw;
228 int idx = hwc->idx;
229
230 WARN_ON(idx < 0);
231
232 clear_bit(idx, cpuc->active_mask);
233 armpmu->disable(hwc, idx);
234
235 barrier();
236 233
237 armpmu_event_update(event, hwc, idx); 234 /* Don't read disabled counters! */
238 cpuc->events[idx] = NULL; 235 if (hwc->idx < 0)
239 clear_bit(idx, cpuc->used_mask); 236 return;
240 237
241 perf_event_update_userpage(event); 238 armpmu_event_update(event, hwc, hwc->idx);
242} 239}
243 240
244static void 241static void
245armpmu_read(struct perf_event *event) 242armpmu_stop(struct perf_event *event, int flags)
246{ 243{
247 struct hw_perf_event *hwc = &event->hw; 244 struct hw_perf_event *hwc = &event->hw;
248 245
249 /* Don't read disabled counters! */ 246 if (!armpmu)
250 if (hwc->idx < 0)
251 return; 247 return;
252 248
253 armpmu_event_update(event, hwc, hwc->idx); 249 /*
250 * ARM pmu always has to update the counter, so ignore
251 * PERF_EF_UPDATE, see comments in armpmu_start().
252 */
253 if (!(hwc->state & PERF_HES_STOPPED)) {
254 armpmu->disable(hwc, hwc->idx);
255 barrier(); /* why? */
256 armpmu_event_update(event, hwc, hwc->idx);
257 hwc->state |= PERF_HES_STOPPED | PERF_HES_UPTODATE;
258 }
254} 259}
255 260
256static void 261static void
257armpmu_unthrottle(struct perf_event *event) 262armpmu_start(struct perf_event *event, int flags)
258{ 263{
259 struct hw_perf_event *hwc = &event->hw; 264 struct hw_perf_event *hwc = &event->hw;
260 265
266 if (!armpmu)
267 return;
268
269 /*
270 * ARM pmu always has to reprogram the period, so ignore
271 * PERF_EF_RELOAD, see the comment below.
272 */
273 if (flags & PERF_EF_RELOAD)
274 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
275
276 hwc->state = 0;
261 /* 277 /*
262 * Set the period again. Some counters can't be stopped, so when we 278 * Set the period again. Some counters can't be stopped, so when we
263 * were throttled we simply disabled the IRQ source and the counter 279 * were stopped we simply disabled the IRQ source and the counter
264 * may have been left counting. If we don't do this step then we may 280 * may have been left counting. If we don't do this step then we may
265 * get an interrupt too soon or *way* too late if the overflow has 281 * get an interrupt too soon or *way* too late if the overflow has
266 * happened since disabling. 282 * happened since disabling.
@@ -269,14 +285,33 @@ armpmu_unthrottle(struct perf_event *event)
269 armpmu->enable(hwc, hwc->idx); 285 armpmu->enable(hwc, hwc->idx);
270} 286}
271 287
288static void
289armpmu_del(struct perf_event *event, int flags)
290{
291 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
292 struct hw_perf_event *hwc = &event->hw;
293 int idx = hwc->idx;
294
295 WARN_ON(idx < 0);
296
297 clear_bit(idx, cpuc->active_mask);
298 armpmu_stop(event, PERF_EF_UPDATE);
299 cpuc->events[idx] = NULL;
300 clear_bit(idx, cpuc->used_mask);
301
302 perf_event_update_userpage(event);
303}
304
272static int 305static int
273armpmu_enable(struct perf_event *event) 306armpmu_add(struct perf_event *event, int flags)
274{ 307{
275 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 308 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
276 struct hw_perf_event *hwc = &event->hw; 309 struct hw_perf_event *hwc = &event->hw;
277 int idx; 310 int idx;
278 int err = 0; 311 int err = 0;
279 312
313 perf_pmu_disable(event->pmu);
314
280 /* If we don't have a space for the counter then finish early. */ 315 /* If we don't have a space for the counter then finish early. */
281 idx = armpmu->get_event_idx(cpuc, hwc); 316 idx = armpmu->get_event_idx(cpuc, hwc);
282 if (idx < 0) { 317 if (idx < 0) {
@@ -293,25 +328,19 @@ armpmu_enable(struct perf_event *event)
293 cpuc->events[idx] = event; 328 cpuc->events[idx] = event;
294 set_bit(idx, cpuc->active_mask); 329 set_bit(idx, cpuc->active_mask);
295 330
296 /* Set the period for the event. */ 331 hwc->state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
297 armpmu_event_set_period(event, hwc, idx); 332 if (flags & PERF_EF_START)
298 333 armpmu_start(event, PERF_EF_RELOAD);
299 /* Enable the event. */
300 armpmu->enable(hwc, idx);
301 334
302 /* Propagate our changes to the userspace mapping. */ 335 /* Propagate our changes to the userspace mapping. */
303 perf_event_update_userpage(event); 336 perf_event_update_userpage(event);
304 337
305out: 338out:
339 perf_pmu_enable(event->pmu);
306 return err; 340 return err;
307} 341}
308 342
309static struct pmu pmu = { 343static struct pmu pmu;
310 .enable = armpmu_enable,
311 .disable = armpmu_disable,
312 .unthrottle = armpmu_unthrottle,
313 .read = armpmu_read,
314};
315 344
316static int 345static int
317validate_event(struct cpu_hw_events *cpuc, 346validate_event(struct cpu_hw_events *cpuc,
@@ -491,20 +520,29 @@ __hw_perf_event_init(struct perf_event *event)
491 return err; 520 return err;
492} 521}
493 522
494const struct pmu * 523static int armpmu_event_init(struct perf_event *event)
495hw_perf_event_init(struct perf_event *event)
496{ 524{
497 int err = 0; 525 int err = 0;
498 526
527 switch (event->attr.type) {
528 case PERF_TYPE_RAW:
529 case PERF_TYPE_HARDWARE:
530 case PERF_TYPE_HW_CACHE:
531 break;
532
533 default:
534 return -ENOENT;
535 }
536
499 if (!armpmu) 537 if (!armpmu)
500 return ERR_PTR(-ENODEV); 538 return -ENODEV;
501 539
502 event->destroy = hw_perf_event_destroy; 540 event->destroy = hw_perf_event_destroy;
503 541
504 if (!atomic_inc_not_zero(&active_events)) { 542 if (!atomic_inc_not_zero(&active_events)) {
505 if (atomic_read(&active_events) > perf_max_events) { 543 if (atomic_read(&active_events) > armpmu->num_events) {
506 atomic_dec(&active_events); 544 atomic_dec(&active_events);
507 return ERR_PTR(-ENOSPC); 545 return -ENOSPC;
508 } 546 }
509 547
510 mutex_lock(&pmu_reserve_mutex); 548 mutex_lock(&pmu_reserve_mutex);
@@ -518,17 +556,16 @@ hw_perf_event_init(struct perf_event *event)
518 } 556 }
519 557
520 if (err) 558 if (err)
521 return ERR_PTR(err); 559 return err;
522 560
523 err = __hw_perf_event_init(event); 561 err = __hw_perf_event_init(event);
524 if (err) 562 if (err)
525 hw_perf_event_destroy(event); 563 hw_perf_event_destroy(event);
526 564
527 return err ? ERR_PTR(err) : &pmu; 565 return err;
528} 566}
529 567
530void 568static void armpmu_enable(struct pmu *pmu)
531hw_perf_enable(void)
532{ 569{
533 /* Enable all of the perf events on hardware. */ 570 /* Enable all of the perf events on hardware. */
534 int idx; 571 int idx;
@@ -549,13 +586,23 @@ hw_perf_enable(void)
549 armpmu->start(); 586 armpmu->start();
550} 587}
551 588
552void 589static void armpmu_disable(struct pmu *pmu)
553hw_perf_disable(void)
554{ 590{
555 if (armpmu) 591 if (armpmu)
556 armpmu->stop(); 592 armpmu->stop();
557} 593}
558 594
595static struct pmu pmu = {
596 .pmu_enable = armpmu_enable,
597 .pmu_disable = armpmu_disable,
598 .event_init = armpmu_event_init,
599 .add = armpmu_add,
600 .del = armpmu_del,
601 .start = armpmu_start,
602 .stop = armpmu_stop,
603 .read = armpmu_read,
604};
605
559/* 606/*
560 * ARMv6 Performance counter handling code. 607 * ARMv6 Performance counter handling code.
561 * 608 *
@@ -1045,7 +1092,7 @@ armv6pmu_handle_irq(int irq_num,
1045 * platforms that can have the PMU interrupts raised as an NMI, this 1092 * platforms that can have the PMU interrupts raised as an NMI, this
1046 * will not work. 1093 * will not work.
1047 */ 1094 */
1048 perf_event_do_pending(); 1095 irq_work_run();
1049 1096
1050 return IRQ_HANDLED; 1097 return IRQ_HANDLED;
1051} 1098}
@@ -2021,7 +2068,7 @@ static irqreturn_t armv7pmu_handle_irq(int irq_num, void *dev)
2021 * platforms that can have the PMU interrupts raised as an NMI, this 2068 * platforms that can have the PMU interrupts raised as an NMI, this
2022 * will not work. 2069 * will not work.
2023 */ 2070 */
2024 perf_event_do_pending(); 2071 irq_work_run();
2025 2072
2026 return IRQ_HANDLED; 2073 return IRQ_HANDLED;
2027} 2074}
@@ -2389,7 +2436,7 @@ xscale1pmu_handle_irq(int irq_num, void *dev)
2389 armpmu->disable(hwc, idx); 2436 armpmu->disable(hwc, idx);
2390 } 2437 }
2391 2438
2392 perf_event_do_pending(); 2439 irq_work_run();
2393 2440
2394 /* 2441 /*
2395 * Re-enable the PMU. 2442 * Re-enable the PMU.
@@ -2716,7 +2763,7 @@ xscale2pmu_handle_irq(int irq_num, void *dev)
2716 armpmu->disable(hwc, idx); 2763 armpmu->disable(hwc, idx);
2717 } 2764 }
2718 2765
2719 perf_event_do_pending(); 2766 irq_work_run();
2720 2767
2721 /* 2768 /*
2722 * Re-enable the PMU. 2769 * Re-enable the PMU.
@@ -2933,14 +2980,12 @@ init_hw_perf_events(void)
2933 armpmu = &armv6pmu; 2980 armpmu = &armv6pmu;
2934 memcpy(armpmu_perf_cache_map, armv6_perf_cache_map, 2981 memcpy(armpmu_perf_cache_map, armv6_perf_cache_map,
2935 sizeof(armv6_perf_cache_map)); 2982 sizeof(armv6_perf_cache_map));
2936 perf_max_events = armv6pmu.num_events;
2937 break; 2983 break;
2938 case 0xB020: /* ARM11mpcore */ 2984 case 0xB020: /* ARM11mpcore */
2939 armpmu = &armv6mpcore_pmu; 2985 armpmu = &armv6mpcore_pmu;
2940 memcpy(armpmu_perf_cache_map, 2986 memcpy(armpmu_perf_cache_map,
2941 armv6mpcore_perf_cache_map, 2987 armv6mpcore_perf_cache_map,
2942 sizeof(armv6mpcore_perf_cache_map)); 2988 sizeof(armv6mpcore_perf_cache_map));
2943 perf_max_events = armv6mpcore_pmu.num_events;
2944 break; 2989 break;
2945 case 0xC080: /* Cortex-A8 */ 2990 case 0xC080: /* Cortex-A8 */
2946 armv7pmu.id = ARM_PERF_PMU_ID_CA8; 2991 armv7pmu.id = ARM_PERF_PMU_ID_CA8;
@@ -2952,7 +2997,6 @@ init_hw_perf_events(void)
2952 /* Reset PMNC and read the nb of CNTx counters 2997 /* Reset PMNC and read the nb of CNTx counters
2953 supported */ 2998 supported */
2954 armv7pmu.num_events = armv7_reset_read_pmnc(); 2999 armv7pmu.num_events = armv7_reset_read_pmnc();
2955 perf_max_events = armv7pmu.num_events;
2956 break; 3000 break;
2957 case 0xC090: /* Cortex-A9 */ 3001 case 0xC090: /* Cortex-A9 */
2958 armv7pmu.id = ARM_PERF_PMU_ID_CA9; 3002 armv7pmu.id = ARM_PERF_PMU_ID_CA9;
@@ -2964,7 +3008,6 @@ init_hw_perf_events(void)
2964 /* Reset PMNC and read the nb of CNTx counters 3008 /* Reset PMNC and read the nb of CNTx counters
2965 supported */ 3009 supported */
2966 armv7pmu.num_events = armv7_reset_read_pmnc(); 3010 armv7pmu.num_events = armv7_reset_read_pmnc();
2967 perf_max_events = armv7pmu.num_events;
2968 break; 3011 break;
2969 } 3012 }
2970 /* Intel CPUs [xscale]. */ 3013 /* Intel CPUs [xscale]. */
@@ -2975,13 +3018,11 @@ init_hw_perf_events(void)
2975 armpmu = &xscale1pmu; 3018 armpmu = &xscale1pmu;
2976 memcpy(armpmu_perf_cache_map, xscale_perf_cache_map, 3019 memcpy(armpmu_perf_cache_map, xscale_perf_cache_map,
2977 sizeof(xscale_perf_cache_map)); 3020 sizeof(xscale_perf_cache_map));
2978 perf_max_events = xscale1pmu.num_events;
2979 break; 3021 break;
2980 case 2: 3022 case 2:
2981 armpmu = &xscale2pmu; 3023 armpmu = &xscale2pmu;
2982 memcpy(armpmu_perf_cache_map, xscale_perf_cache_map, 3024 memcpy(armpmu_perf_cache_map, xscale_perf_cache_map,
2983 sizeof(xscale_perf_cache_map)); 3025 sizeof(xscale_perf_cache_map));
2984 perf_max_events = xscale2pmu.num_events;
2985 break; 3026 break;
2986 } 3027 }
2987 } 3028 }
@@ -2991,9 +3032,10 @@ init_hw_perf_events(void)
2991 arm_pmu_names[armpmu->id], armpmu->num_events); 3032 arm_pmu_names[armpmu->id], armpmu->num_events);
2992 } else { 3033 } else {
2993 pr_info("no hardware support available\n"); 3034 pr_info("no hardware support available\n");
2994 perf_max_events = -1;
2995 } 3035 }
2996 3036
3037 perf_pmu_register(&pmu);
3038
2997 return 0; 3039 return 0;
2998} 3040}
2999arch_initcall(init_hw_perf_events); 3041arch_initcall(init_hw_perf_events);
@@ -3001,13 +3043,6 @@ arch_initcall(init_hw_perf_events);
3001/* 3043/*
3002 * Callchain handling code. 3044 * Callchain handling code.
3003 */ 3045 */
3004static inline void
3005callchain_store(struct perf_callchain_entry *entry,
3006 u64 ip)
3007{
3008 if (entry->nr < PERF_MAX_STACK_DEPTH)
3009 entry->ip[entry->nr++] = ip;
3010}
3011 3046
3012/* 3047/*
3013 * The registers we're interested in are at the end of the variable 3048 * The registers we're interested in are at the end of the variable
@@ -3039,7 +3074,7 @@ user_backtrace(struct frame_tail *tail,
3039 if (__copy_from_user_inatomic(&buftail, tail, sizeof(buftail))) 3074 if (__copy_from_user_inatomic(&buftail, tail, sizeof(buftail)))
3040 return NULL; 3075 return NULL;
3041 3076
3042 callchain_store(entry, buftail.lr); 3077 perf_callchain_store(entry, buftail.lr);
3043 3078
3044 /* 3079 /*
3045 * Frame pointers should strictly progress back up the stack 3080 * Frame pointers should strictly progress back up the stack
@@ -3051,16 +3086,11 @@ user_backtrace(struct frame_tail *tail,
3051 return buftail.fp - 1; 3086 return buftail.fp - 1;
3052} 3087}
3053 3088
3054static void 3089void
3055perf_callchain_user(struct pt_regs *regs, 3090perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
3056 struct perf_callchain_entry *entry)
3057{ 3091{
3058 struct frame_tail *tail; 3092 struct frame_tail *tail;
3059 3093
3060 callchain_store(entry, PERF_CONTEXT_USER);
3061
3062 if (!user_mode(regs))
3063 regs = task_pt_regs(current);
3064 3094
3065 tail = (struct frame_tail *)regs->ARM_fp - 1; 3095 tail = (struct frame_tail *)regs->ARM_fp - 1;
3066 3096
@@ -3078,56 +3108,18 @@ callchain_trace(struct stackframe *fr,
3078 void *data) 3108 void *data)
3079{ 3109{
3080 struct perf_callchain_entry *entry = data; 3110 struct perf_callchain_entry *entry = data;
3081 callchain_store(entry, fr->pc); 3111 perf_callchain_store(entry, fr->pc);
3082 return 0; 3112 return 0;
3083} 3113}
3084 3114
3085static void 3115void
3086perf_callchain_kernel(struct pt_regs *regs, 3116perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
3087 struct perf_callchain_entry *entry)
3088{ 3117{
3089 struct stackframe fr; 3118 struct stackframe fr;
3090 3119
3091 callchain_store(entry, PERF_CONTEXT_KERNEL);
3092 fr.fp = regs->ARM_fp; 3120 fr.fp = regs->ARM_fp;
3093 fr.sp = regs->ARM_sp; 3121 fr.sp = regs->ARM_sp;
3094 fr.lr = regs->ARM_lr; 3122 fr.lr = regs->ARM_lr;
3095 fr.pc = regs->ARM_pc; 3123 fr.pc = regs->ARM_pc;
3096 walk_stackframe(&fr, callchain_trace, entry); 3124 walk_stackframe(&fr, callchain_trace, entry);
3097} 3125}
3098
3099static void
3100perf_do_callchain(struct pt_regs *regs,
3101 struct perf_callchain_entry *entry)
3102{
3103 int is_user;
3104
3105 if (!regs)
3106 return;
3107
3108 is_user = user_mode(regs);
3109
3110 if (!current || !current->pid)
3111 return;
3112
3113 if (is_user && current->state != TASK_RUNNING)
3114 return;
3115
3116 if (!is_user)
3117 perf_callchain_kernel(regs, entry);
3118
3119 if (current->mm)
3120 perf_callchain_user(regs, entry);
3121}
3122
3123static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_irq_entry);
3124
3125struct perf_callchain_entry *
3126perf_callchain(struct pt_regs *regs)
3127{
3128 struct perf_callchain_entry *entry = &__get_cpu_var(pmc_irq_entry);
3129
3130 entry->nr = 0;
3131 perf_do_callchain(regs, entry);
3132 return entry;
3133}
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 401e38be1f78..e76fcaadce03 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -29,6 +29,7 @@
29#include <linux/utsname.h> 29#include <linux/utsname.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/random.h> 31#include <linux/random.h>
32#include <linux/hw_breakpoint.h>
32 33
33#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>
34#include <asm/leds.h> 35#include <asm/leds.h>
@@ -135,6 +136,25 @@ EXPORT_SYMBOL(pm_power_off);
135void (*arm_pm_restart)(char str, const char *cmd) = arm_machine_restart; 136void (*arm_pm_restart)(char str, const char *cmd) = arm_machine_restart;
136EXPORT_SYMBOL_GPL(arm_pm_restart); 137EXPORT_SYMBOL_GPL(arm_pm_restart);
137 138
139static void do_nothing(void *unused)
140{
141}
142
143/*
144 * cpu_idle_wait - Used to ensure that all the CPUs discard old value of
145 * pm_idle and update to new pm_idle value. Required while changing pm_idle
146 * handler on SMP systems.
147 *
148 * Caller must have changed pm_idle to the new value before the call. Old
149 * pm_idle value will not be used by any CPU after the return of this function.
150 */
151void cpu_idle_wait(void)
152{
153 smp_mb();
154 /* kick all the CPUs so that they exit out of pm_idle */
155 smp_call_function(do_nothing, NULL, 1);
156}
157EXPORT_SYMBOL_GPL(cpu_idle_wait);
138 158
139/* 159/*
140 * This is our default idle handler. We need to disable 160 * This is our default idle handler. We need to disable
@@ -317,6 +337,8 @@ void flush_thread(void)
317 struct thread_info *thread = current_thread_info(); 337 struct thread_info *thread = current_thread_info();
318 struct task_struct *tsk = current; 338 struct task_struct *tsk = current;
319 339
340 flush_ptrace_hw_breakpoint(tsk);
341
320 memset(thread->used_cp, 0, sizeof(thread->used_cp)); 342 memset(thread->used_cp, 0, sizeof(thread->used_cp));
321 memset(&tsk->thread.debug, 0, sizeof(struct debug_info)); 343 memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
322 memset(&thread->fpstate, 0, sizeof(union fp_state)); 344 memset(&thread->fpstate, 0, sizeof(union fp_state));
@@ -345,6 +367,8 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start,
345 thread->cpu_context.sp = (unsigned long)childregs; 367 thread->cpu_context.sp = (unsigned long)childregs;
346 thread->cpu_context.pc = (unsigned long)ret_from_fork; 368 thread->cpu_context.pc = (unsigned long)ret_from_fork;
347 369
370 clear_ptrace_hw_breakpoint(p);
371
348 if (clone_flags & CLONE_SETTLS) 372 if (clone_flags & CLONE_SETTLS)
349 thread->tp_value = regs->ARM_r3; 373 thread->tp_value = regs->ARM_r3;
350 374
@@ -458,3 +482,24 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
458 unsigned long range_end = mm->brk + 0x02000000; 482 unsigned long range_end = mm->brk + 0x02000000;
459 return randomize_range(mm->brk, range_end, 0) ? : mm->brk; 483 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
460} 484}
485
486/*
487 * The vectors page is always readable from user space for the
488 * atomic helpers and the signal restart code. Let's declare a mapping
489 * for it so it is visible through ptrace and /proc/<pid>/mem.
490 */
491
492int vectors_user_mapping(void)
493{
494 struct mm_struct *mm = current->mm;
495 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE,
496 VM_READ | VM_EXEC |
497 VM_MAYREAD | VM_MAYEXEC |
498 VM_ALWAYSDUMP | VM_RESERVED,
499 NULL);
500}
501
502const char *arch_vma_name(struct vm_area_struct *vma)
503{
504 return (vma->vm_start == 0xffff0000) ? "[vectors]" : NULL;
505}
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index f99d489822d5..e0cb6370ed14 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -19,6 +19,8 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/signal.h> 20#include <linux/signal.h>
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/perf_event.h>
23#include <linux/hw_breakpoint.h>
22 24
23#include <asm/pgtable.h> 25#include <asm/pgtable.h>
24#include <asm/system.h> 26#include <asm/system.h>
@@ -847,6 +849,232 @@ static int ptrace_setvfpregs(struct task_struct *tsk, void __user *data)
847} 849}
848#endif 850#endif
849 851
852#ifdef CONFIG_HAVE_HW_BREAKPOINT
853/*
854 * Convert a virtual register number into an index for a thread_info
855 * breakpoint array. Breakpoints are identified using positive numbers
856 * whilst watchpoints are negative. The registers are laid out as pairs
857 * of (address, control), each pair mapping to a unique hw_breakpoint struct.
858 * Register 0 is reserved for describing resource information.
859 */
860static int ptrace_hbp_num_to_idx(long num)
861{
862 if (num < 0)
863 num = (ARM_MAX_BRP << 1) - num;
864 return (num - 1) >> 1;
865}
866
867/*
868 * Returns the virtual register number for the address of the
869 * breakpoint at index idx.
870 */
871static long ptrace_hbp_idx_to_num(int idx)
872{
873 long mid = ARM_MAX_BRP << 1;
874 long num = (idx << 1) + 1;
875 return num > mid ? mid - num : num;
876}
877
878/*
879 * Handle hitting a HW-breakpoint.
880 */
881static void ptrace_hbptriggered(struct perf_event *bp, int unused,
882 struct perf_sample_data *data,
883 struct pt_regs *regs)
884{
885 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
886 long num;
887 int i;
888 siginfo_t info;
889
890 for (i = 0; i < ARM_MAX_HBP_SLOTS; ++i)
891 if (current->thread.debug.hbp[i] == bp)
892 break;
893
894 num = (i == ARM_MAX_HBP_SLOTS) ? 0 : ptrace_hbp_idx_to_num(i);
895
896 info.si_signo = SIGTRAP;
897 info.si_errno = (int)num;
898 info.si_code = TRAP_HWBKPT;
899 info.si_addr = (void __user *)(bkpt->trigger);
900
901 force_sig_info(SIGTRAP, &info, current);
902}
903
904/*
905 * Set ptrace breakpoint pointers to zero for this task.
906 * This is required in order to prevent child processes from unregistering
907 * breakpoints held by their parent.
908 */
909void clear_ptrace_hw_breakpoint(struct task_struct *tsk)
910{
911 memset(tsk->thread.debug.hbp, 0, sizeof(tsk->thread.debug.hbp));
912}
913
914/*
915 * Unregister breakpoints from this task and reset the pointers in
916 * the thread_struct.
917 */
918void flush_ptrace_hw_breakpoint(struct task_struct *tsk)
919{
920 int i;
921 struct thread_struct *t = &tsk->thread;
922
923 for (i = 0; i < ARM_MAX_HBP_SLOTS; i++) {
924 if (t->debug.hbp[i]) {
925 unregister_hw_breakpoint(t->debug.hbp[i]);
926 t->debug.hbp[i] = NULL;
927 }
928 }
929}
930
931static u32 ptrace_get_hbp_resource_info(void)
932{
933 u8 num_brps, num_wrps, debug_arch, wp_len;
934 u32 reg = 0;
935
936 num_brps = hw_breakpoint_slots(TYPE_INST);
937 num_wrps = hw_breakpoint_slots(TYPE_DATA);
938 debug_arch = arch_get_debug_arch();
939 wp_len = arch_get_max_wp_len();
940
941 reg |= debug_arch;
942 reg <<= 8;
943 reg |= wp_len;
944 reg <<= 8;
945 reg |= num_wrps;
946 reg <<= 8;
947 reg |= num_brps;
948
949 return reg;
950}
951
952static struct perf_event *ptrace_hbp_create(struct task_struct *tsk, int type)
953{
954 struct perf_event_attr attr;
955
956 ptrace_breakpoint_init(&attr);
957
958 /* Initialise fields to sane defaults. */
959 attr.bp_addr = 0;
960 attr.bp_len = HW_BREAKPOINT_LEN_4;
961 attr.bp_type = type;
962 attr.disabled = 1;
963
964 return register_user_hw_breakpoint(&attr, ptrace_hbptriggered, tsk);
965}
966
967static int ptrace_gethbpregs(struct task_struct *tsk, long num,
968 unsigned long __user *data)
969{
970 u32 reg;
971 int idx, ret = 0;
972 struct perf_event *bp;
973 struct arch_hw_breakpoint_ctrl arch_ctrl;
974
975 if (num == 0) {
976 reg = ptrace_get_hbp_resource_info();
977 } else {
978 idx = ptrace_hbp_num_to_idx(num);
979 if (idx < 0 || idx >= ARM_MAX_HBP_SLOTS) {
980 ret = -EINVAL;
981 goto out;
982 }
983
984 bp = tsk->thread.debug.hbp[idx];
985 if (!bp) {
986 reg = 0;
987 goto put;
988 }
989
990 arch_ctrl = counter_arch_bp(bp)->ctrl;
991
992 /*
993 * Fix up the len because we may have adjusted it
994 * to compensate for an unaligned address.
995 */
996 while (!(arch_ctrl.len & 0x1))
997 arch_ctrl.len >>= 1;
998
999 if (idx & 0x1)
1000 reg = encode_ctrl_reg(arch_ctrl);
1001 else
1002 reg = bp->attr.bp_addr;
1003 }
1004
1005put:
1006 if (put_user(reg, data))
1007 ret = -EFAULT;
1008
1009out:
1010 return ret;
1011}
1012
1013static int ptrace_sethbpregs(struct task_struct *tsk, long num,
1014 unsigned long __user *data)
1015{
1016 int idx, gen_len, gen_type, implied_type, ret = 0;
1017 u32 user_val;
1018 struct perf_event *bp;
1019 struct arch_hw_breakpoint_ctrl ctrl;
1020 struct perf_event_attr attr;
1021
1022 if (num == 0)
1023 goto out;
1024 else if (num < 0)
1025 implied_type = HW_BREAKPOINT_RW;
1026 else
1027 implied_type = HW_BREAKPOINT_X;
1028
1029 idx = ptrace_hbp_num_to_idx(num);
1030 if (idx < 0 || idx >= ARM_MAX_HBP_SLOTS) {
1031 ret = -EINVAL;
1032 goto out;
1033 }
1034
1035 if (get_user(user_val, data)) {
1036 ret = -EFAULT;
1037 goto out;
1038 }
1039
1040 bp = tsk->thread.debug.hbp[idx];
1041 if (!bp) {
1042 bp = ptrace_hbp_create(tsk, implied_type);
1043 if (IS_ERR(bp)) {
1044 ret = PTR_ERR(bp);
1045 goto out;
1046 }
1047 tsk->thread.debug.hbp[idx] = bp;
1048 }
1049
1050 attr = bp->attr;
1051
1052 if (num & 0x1) {
1053 /* Address */
1054 attr.bp_addr = user_val;
1055 } else {
1056 /* Control */
1057 decode_ctrl_reg(user_val, &ctrl);
1058 ret = arch_bp_generic_fields(ctrl, &gen_len, &gen_type);
1059 if (ret)
1060 goto out;
1061
1062 if ((gen_type & implied_type) != gen_type) {
1063 ret = -EINVAL;
1064 goto out;
1065 }
1066
1067 attr.bp_len = gen_len;
1068 attr.bp_type = gen_type;
1069 attr.disabled = !ctrl.enabled;
1070 }
1071
1072 ret = modify_user_hw_breakpoint(bp, &attr);
1073out:
1074 return ret;
1075}
1076#endif
1077
850long arch_ptrace(struct task_struct *child, long request, long addr, long data) 1078long arch_ptrace(struct task_struct *child, long request, long addr, long data)
851{ 1079{
852 int ret; 1080 int ret;
@@ -916,6 +1144,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
916 break; 1144 break;
917#endif 1145#endif
918 1146
1147#ifdef CONFIG_HAVE_HW_BREAKPOINT
1148 case PTRACE_GETHBPREGS:
1149 ret = ptrace_gethbpregs(child, addr,
1150 (unsigned long __user *)data);
1151 break;
1152 case PTRACE_SETHBPREGS:
1153 ret = ptrace_sethbpregs(child, addr,
1154 (unsigned long __user *)data);
1155 break;
1156#endif
1157
919 default: 1158 default:
920 ret = ptrace_request(child, request, addr, data); 1159 ret = ptrace_request(child, request, addr, data);
921 break; 1160 break;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index d5231ae7355a..336f14e0e5c2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -36,6 +36,7 @@
36#include <asm/procinfo.h> 36#include <asm/procinfo.h>
37#include <asm/sections.h> 37#include <asm/sections.h>
38#include <asm/setup.h> 38#include <asm/setup.h>
39#include <asm/smp_plat.h>
39#include <asm/mach-types.h> 40#include <asm/mach-types.h>
40#include <asm/cacheflush.h> 41#include <asm/cacheflush.h>
41#include <asm/cachetype.h> 42#include <asm/cachetype.h>
@@ -238,6 +239,35 @@ int cpu_architecture(void)
238 return cpu_arch; 239 return cpu_arch;
239} 240}
240 241
242static int cpu_has_aliasing_icache(unsigned int arch)
243{
244 int aliasing_icache;
245 unsigned int id_reg, num_sets, line_size;
246
247 /* arch specifies the register format */
248 switch (arch) {
249 case CPU_ARCH_ARMv7:
250 asm("mcr p15, 2, %0, c0, c0, 0 @ set CSSELR"
251 : /* No output operands */
252 : "r" (1));
253 isb();
254 asm("mrc p15, 1, %0, c0, c0, 0 @ read CCSIDR"
255 : "=r" (id_reg));
256 line_size = 4 << ((id_reg & 0x7) + 2);
257 num_sets = ((id_reg >> 13) & 0x7fff) + 1;
258 aliasing_icache = (line_size * num_sets) > PAGE_SIZE;
259 break;
260 case CPU_ARCH_ARMv6:
261 aliasing_icache = read_cpuid_cachetype() & (1 << 11);
262 break;
263 default:
264 /* I-cache aliases will be handled by D-cache aliasing code */
265 aliasing_icache = 0;
266 }
267
268 return aliasing_icache;
269}
270
241static void __init cacheid_init(void) 271static void __init cacheid_init(void)
242{ 272{
243 unsigned int cachetype = read_cpuid_cachetype(); 273 unsigned int cachetype = read_cpuid_cachetype();
@@ -249,10 +279,15 @@ static void __init cacheid_init(void)
249 cacheid = CACHEID_VIPT_NONALIASING; 279 cacheid = CACHEID_VIPT_NONALIASING;
250 if ((cachetype & (3 << 14)) == 1 << 14) 280 if ((cachetype & (3 << 14)) == 1 << 14)
251 cacheid |= CACHEID_ASID_TAGGED; 281 cacheid |= CACHEID_ASID_TAGGED;
252 } else if (cachetype & (1 << 23)) 282 else if (cpu_has_aliasing_icache(CPU_ARCH_ARMv7))
283 cacheid |= CACHEID_VIPT_I_ALIASING;
284 } else if (cachetype & (1 << 23)) {
253 cacheid = CACHEID_VIPT_ALIASING; 285 cacheid = CACHEID_VIPT_ALIASING;
254 else 286 } else {
255 cacheid = CACHEID_VIPT_NONALIASING; 287 cacheid = CACHEID_VIPT_NONALIASING;
288 if (cpu_has_aliasing_icache(CPU_ARCH_ARMv6))
289 cacheid |= CACHEID_VIPT_I_ALIASING;
290 }
256 } else { 291 } else {
257 cacheid = CACHEID_VIVT; 292 cacheid = CACHEID_VIVT;
258 } 293 }
@@ -263,7 +298,7 @@ static void __init cacheid_init(void)
263 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown", 298 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown",
264 cache_is_vivt() ? "VIVT" : 299 cache_is_vivt() ? "VIVT" :
265 icache_is_vivt_asid_tagged() ? "VIVT ASID tagged" : 300 icache_is_vivt_asid_tagged() ? "VIVT ASID tagged" :
266 cache_is_vipt_aliasing() ? "VIPT aliasing" : 301 icache_is_vipt_aliasing() ? "VIPT aliasing" :
267 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown"); 302 cache_is_vipt_nonaliasing() ? "VIPT nonaliasing" : "unknown");
268} 303}
269 304
@@ -490,7 +525,7 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
490 525
491 kernel_code.start = virt_to_phys(_text); 526 kernel_code.start = virt_to_phys(_text);
492 kernel_code.end = virt_to_phys(_etext - 1); 527 kernel_code.end = virt_to_phys(_etext - 1);
493 kernel_data.start = virt_to_phys(_data); 528 kernel_data.start = virt_to_phys(_sdata);
494 kernel_data.end = virt_to_phys(_end - 1); 529 kernel_data.end = virt_to_phys(_end - 1);
495 530
496 for (i = 0; i < mi->nr_banks; i++) { 531 for (i = 0; i < mi->nr_banks; i++) {
@@ -825,7 +860,8 @@ void __init setup_arch(char **cmdline_p)
825 request_standard_resources(&meminfo, mdesc); 860 request_standard_resources(&meminfo, mdesc);
826 861
827#ifdef CONFIG_SMP 862#ifdef CONFIG_SMP
828 smp_init_cpus(); 863 if (is_smp())
864 smp_init_cpus();
829#endif 865#endif
830 reserve_crashkernel(); 866 reserve_crashkernel();
831 867
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 40dc74f2b27f..8c1959590252 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -33,6 +33,7 @@
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
35#include <asm/processor.h> 35#include <asm/processor.h>
36#include <asm/sections.h>
36#include <asm/tlbflush.h> 37#include <asm/tlbflush.h>
37#include <asm/ptrace.h> 38#include <asm/ptrace.h>
38#include <asm/localtimer.h> 39#include <asm/localtimer.h>
@@ -67,12 +68,47 @@ enum ipi_msg_type {
67 IPI_CPU_STOP, 68 IPI_CPU_STOP,
68}; 69};
69 70
71static inline void identity_mapping_add(pgd_t *pgd, unsigned long start,
72 unsigned long end)
73{
74 unsigned long addr, prot;
75 pmd_t *pmd;
76
77 prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE;
78 if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
79 prot |= PMD_BIT4;
80
81 for (addr = start & PGDIR_MASK; addr < end;) {
82 pmd = pmd_offset(pgd + pgd_index(addr), addr);
83 pmd[0] = __pmd(addr | prot);
84 addr += SECTION_SIZE;
85 pmd[1] = __pmd(addr | prot);
86 addr += SECTION_SIZE;
87 flush_pmd_entry(pmd);
88 outer_clean_range(__pa(pmd), __pa(pmd + 1));
89 }
90}
91
92static inline void identity_mapping_del(pgd_t *pgd, unsigned long start,
93 unsigned long end)
94{
95 unsigned long addr;
96 pmd_t *pmd;
97
98 for (addr = start & PGDIR_MASK; addr < end; addr += PGDIR_SIZE) {
99 pmd = pmd_offset(pgd + pgd_index(addr), addr);
100 pmd[0] = __pmd(0);
101 pmd[1] = __pmd(0);
102 clean_pmd_entry(pmd);
103 outer_clean_range(__pa(pmd), __pa(pmd + 1));
104 }
105}
106
70int __cpuinit __cpu_up(unsigned int cpu) 107int __cpuinit __cpu_up(unsigned int cpu)
71{ 108{
72 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu); 109 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
73 struct task_struct *idle = ci->idle; 110 struct task_struct *idle = ci->idle;
74 pgd_t *pgd; 111 pgd_t *pgd;
75 pmd_t *pmd;
76 int ret; 112 int ret;
77 113
78 /* 114 /*
@@ -101,11 +137,16 @@ int __cpuinit __cpu_up(unsigned int cpu)
101 * a 1:1 mapping for the physical address of the kernel. 137 * a 1:1 mapping for the physical address of the kernel.
102 */ 138 */
103 pgd = pgd_alloc(&init_mm); 139 pgd = pgd_alloc(&init_mm);
104 pmd = pmd_offset(pgd + pgd_index(PHYS_OFFSET), PHYS_OFFSET); 140 if (!pgd)
105 *pmd = __pmd((PHYS_OFFSET & PGDIR_MASK) | 141 return -ENOMEM;
106 PMD_TYPE_SECT | PMD_SECT_AP_WRITE); 142
107 flush_pmd_entry(pmd); 143 if (PHYS_OFFSET != PAGE_OFFSET) {
108 outer_clean_range(__pa(pmd), __pa(pmd + 1)); 144#ifndef CONFIG_HOTPLUG_CPU
145 identity_mapping_add(pgd, __pa(__init_begin), __pa(__init_end));
146#endif
147 identity_mapping_add(pgd, __pa(_stext), __pa(_etext));
148 identity_mapping_add(pgd, __pa(_sdata), __pa(_edata));
149 }
109 150
110 /* 151 /*
111 * We need to tell the secondary core where to find 152 * We need to tell the secondary core where to find
@@ -143,8 +184,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
143 secondary_data.stack = NULL; 184 secondary_data.stack = NULL;
144 secondary_data.pgdir = 0; 185 secondary_data.pgdir = 0;
145 186
146 *pmd = __pmd(0); 187 if (PHYS_OFFSET != PAGE_OFFSET) {
147 clean_pmd_entry(pmd); 188#ifndef CONFIG_HOTPLUG_CPU
189 identity_mapping_del(pgd, __pa(__init_begin), __pa(__init_end));
190#endif
191 identity_mapping_del(pgd, __pa(_stext), __pa(_etext));
192 identity_mapping_del(pgd, __pa(_sdata), __pa(_edata));
193 }
194
148 pgd_free(&init_mm, pgd); 195 pgd_free(&init_mm, pgd);
149 196
150 if (ret) { 197 if (ret) {
@@ -567,7 +614,8 @@ void smp_send_stop(void)
567{ 614{
568 cpumask_t mask = cpu_online_map; 615 cpumask_t mask = cpu_online_map;
569 cpu_clear(smp_processor_id(), mask); 616 cpu_clear(smp_processor_id(), mask);
570 send_ipi_message(&mask, IPI_CPU_STOP); 617 if (!cpus_empty(mask))
618 send_ipi_message(&mask, IPI_CPU_STOP);
571} 619}
572 620
573/* 621/*
diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c
index dd81a918c106..2a161765f6d5 100644
--- a/arch/arm/kernel/unwind.c
+++ b/arch/arm/kernel/unwind.c
@@ -146,6 +146,8 @@ static struct unwind_idx *unwind_find_idx(unsigned long addr)
146 addr < table->end_addr) { 146 addr < table->end_addr) {
147 idx = search_index(addr, table->start, 147 idx = search_index(addr, table->start,
148 table->stop - 1); 148 table->stop - 1);
149 /* Move-to-front to exploit common traces */
150 list_move(&table->list, &unwind_tables);
149 break; 151 break;
150 } 152 }
151 } 153 }
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index b16c07914b55..1953e3d21abf 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -8,6 +8,19 @@
8#include <asm/memory.h> 8#include <asm/memory.h>
9#include <asm/page.h> 9#include <asm/page.h>
10 10
11#define PROC_INFO \
12 VMLINUX_SYMBOL(__proc_info_begin) = .; \
13 *(.proc.info.init) \
14 VMLINUX_SYMBOL(__proc_info_end) = .;
15
16#ifdef CONFIG_HOTPLUG_CPU
17#define ARM_CPU_DISCARD(x)
18#define ARM_CPU_KEEP(x) x
19#else
20#define ARM_CPU_DISCARD(x) x
21#define ARM_CPU_KEEP(x)
22#endif
23
11OUTPUT_ARCH(arm) 24OUTPUT_ARCH(arm)
12ENTRY(stext) 25ENTRY(stext)
13 26
@@ -31,15 +44,18 @@ SECTIONS
31 HEAD_TEXT 44 HEAD_TEXT
32 INIT_TEXT 45 INIT_TEXT
33 _einittext = .; 46 _einittext = .;
34 __proc_info_begin = .; 47 ARM_CPU_DISCARD(PROC_INFO)
35 *(.proc.info.init)
36 __proc_info_end = .;
37 __arch_info_begin = .; 48 __arch_info_begin = .;
38 *(.arch.info.init) 49 *(.arch.info.init)
39 __arch_info_end = .; 50 __arch_info_end = .;
40 __tagtable_begin = .; 51 __tagtable_begin = .;
41 *(.taglist.init) 52 *(.taglist.init)
42 __tagtable_end = .; 53 __tagtable_end = .;
54#ifdef CONFIG_SMP_ON_UP
55 __smpalt_begin = .;
56 *(.alt.smp.init)
57 __smpalt_end = .;
58#endif
43 59
44 INIT_SETUP(16) 60 INIT_SETUP(16)
45 61
@@ -68,10 +84,8 @@ SECTIONS
68 /DISCARD/ : { 84 /DISCARD/ : {
69 *(.ARM.exidx.exit.text) 85 *(.ARM.exidx.exit.text)
70 *(.ARM.extab.exit.text) 86 *(.ARM.extab.exit.text)
71#ifndef CONFIG_HOTPLUG_CPU 87 ARM_CPU_DISCARD(*(.ARM.exidx.cpuexit.text))
72 *(.ARM.exidx.cpuexit.text) 88 ARM_CPU_DISCARD(*(.ARM.extab.cpuexit.text))
73 *(.ARM.extab.cpuexit.text)
74#endif
75#ifndef CONFIG_HOTPLUG 89#ifndef CONFIG_HOTPLUG
76 *(.ARM.exidx.devexit.text) 90 *(.ARM.exidx.devexit.text)
77 *(.ARM.extab.devexit.text) 91 *(.ARM.extab.devexit.text)
@@ -100,12 +114,11 @@ SECTIONS
100 *(.glue_7) 114 *(.glue_7)
101 *(.glue_7t) 115 *(.glue_7t)
102 *(.got) /* Global offset table */ 116 *(.got) /* Global offset table */
117 ARM_CPU_KEEP(PROC_INFO)
103 } 118 }
104 119
105 RO_DATA(PAGE_SIZE) 120 RO_DATA(PAGE_SIZE)
106 121
107 _etext = .; /* End of text and rodata section */
108
109#ifdef CONFIG_ARM_UNWIND 122#ifdef CONFIG_ARM_UNWIND
110 /* 123 /*
111 * Stack unwinding tables 124 * Stack unwinding tables
@@ -123,6 +136,8 @@ SECTIONS
123 } 136 }
124#endif 137#endif
125 138
139 _etext = .; /* End of text and rodata section */
140
126#ifdef CONFIG_XIP_KERNEL 141#ifdef CONFIG_XIP_KERNEL
127 __data_loc = ALIGN(4); /* location in binary */ 142 __data_loc = ALIGN(4); /* location in binary */
128 . = PAGE_OFFSET + TEXT_OFFSET; 143 . = PAGE_OFFSET + TEXT_OFFSET;
@@ -237,6 +252,12 @@ SECTIONS
237 252
238 /* Default discards */ 253 /* Default discards */
239 DISCARDS 254 DISCARDS
255
256#ifndef CONFIG_SMP_ON_UP
257 /DISCARD/ : {
258 *(.alt.smp.init)
259 }
260#endif
240} 261}
241 262
242/* 263/*
diff --git a/arch/arm/mach-aaec2000/aaed2000.c b/arch/arm/mach-aaec2000/aaed2000.c
index 81a3ecc0d104..0eb3e3e5b2d1 100644
--- a/arch/arm/mach-aaec2000/aaed2000.c
+++ b/arch/arm/mach-aaec2000/aaed2000.c
@@ -95,8 +95,6 @@ static void __init aaed2000_map_io(void)
95 95
96MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform") 96MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform")
97 /* Maintainer: Nicolas Bellido Y Ortega */ 97 /* Maintainer: Nicolas Bellido Y Ortega */
98 .phys_io = PIO_BASE,
99 .io_pg_offst = ((VIO_BASE) >> 18) & 0xfffc,
100 .map_io = aaed2000_map_io, 98 .map_io = aaed2000_map_io,
101 .init_irq = aaed2000_init_irq, 99 .init_irq = aaed2000_init_irq,
102 .timer = &aaec2000_timer, 100 .timer = &aaec2000_timer,
diff --git a/arch/arm/mach-aaec2000/include/mach/debug-macro.S b/arch/arm/mach-aaec2000/include/mach/debug-macro.S
index a9cac368bfe6..bc7ad5561c4c 100644
--- a/arch/arm/mach-aaec2000/include/mach/debug-macro.S
+++ b/arch/arm/mach-aaec2000/include/mach/debug-macro.S
@@ -10,12 +10,10 @@
10 */ 10 */
11 11
12#include "hardware.h" 12#include "hardware.h"
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 mrc p15, 0, \rx, c1, c0 14 mov \rp, 0x00000800
15 tst \rx, #1 @ MMU enabled? 15 orr \rv, \rp, #io_p2v(0x80000000) @ virtual
16 moveq \rx, #0x80000000 @ physical 16 orr \rp, \rp, #0x80000000 @ physical
17 movne \rx, #io_p2v(0x80000000) @ virtual
18 orr \rx, \rx, #0x00000800
19 .endm 17 .endm
20 18
21 .macro senduart,rd,rx 19 .macro senduart,rd,rx
diff --git a/arch/arm/mach-aaec2000/include/mach/vmalloc.h b/arch/arm/mach-aaec2000/include/mach/vmalloc.h
index 551f68f666bf..cff4e0a996ce 100644
--- a/arch/arm/mach-aaec2000/include/mach/vmalloc.h
+++ b/arch/arm/mach-aaec2000/include/mach/vmalloc.h
@@ -11,6 +11,6 @@
11#ifndef __ASM_ARCH_VMALLOC_H 11#ifndef __ASM_ARCH_VMALLOC_H
12#define __ASM_ARCH_VMALLOC_H 12#define __ASM_ARCH_VMALLOC_H
13 13
14#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 14#define VMALLOC_END 0xd0000000
15 15
16#endif /* __ASM_ARCH_VMALLOC_H */ 16#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 939bccd70569..abed4d15a7fd 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -33,6 +33,7 @@ config ARCH_AT91SAM9260
33 select HAVE_AT91_USART3 33 select HAVE_AT91_USART3
34 select HAVE_AT91_USART4 34 select HAVE_AT91_USART4
35 select HAVE_AT91_USART5 35 select HAVE_AT91_USART5
36 select HAVE_NET_MACB
36 37
37config ARCH_AT91SAM9261 38config ARCH_AT91SAM9261
38 bool "AT91SAM9261" 39 bool "AT91SAM9261"
@@ -51,6 +52,7 @@ config ARCH_AT91SAM9263
51 select CPU_ARM926T 52 select CPU_ARM926T
52 select GENERIC_CLOCKEVENTS 53 select GENERIC_CLOCKEVENTS
53 select HAVE_FB_ATMEL 54 select HAVE_FB_ATMEL
55 select HAVE_NET_MACB
54 56
55config ARCH_AT91SAM9RL 57config ARCH_AT91SAM9RL
56 bool "AT91SAM9RL" 58 bool "AT91SAM9RL"
@@ -66,6 +68,7 @@ config ARCH_AT91SAM9G20
66 select HAVE_AT91_USART3 68 select HAVE_AT91_USART3
67 select HAVE_AT91_USART4 69 select HAVE_AT91_USART4
68 select HAVE_AT91_USART5 70 select HAVE_AT91_USART5
71 select HAVE_NET_MACB
69 72
70config ARCH_AT91SAM9G45 73config ARCH_AT91SAM9G45
71 bool "AT91SAM9G45" 74 bool "AT91SAM9G45"
@@ -73,6 +76,7 @@ config ARCH_AT91SAM9G45
73 select GENERIC_CLOCKEVENTS 76 select GENERIC_CLOCKEVENTS
74 select HAVE_AT91_USART3 77 select HAVE_AT91_USART3
75 select HAVE_FB_ATMEL 78 select HAVE_FB_ATMEL
79 select HAVE_NET_MACB
76 80
77config ARCH_AT91CAP9 81config ARCH_AT91CAP9
78 bool "AT91CAP9" 82 bool "AT91CAP9"
@@ -105,7 +109,7 @@ config MACH_ONEARM
105 bool "Ajeco 1ARM Single Board Computer" 109 bool "Ajeco 1ARM Single Board Computer"
106 help 110 help
107 Select this if you are using Ajeco's 1ARM Single Board Computer. 111 Select this if you are using Ajeco's 1ARM Single Board Computer.
108 <http://www.ajeco.fi/products.htm> 112 <http://www.ajeco.fi/>
109 113
110config ARCH_AT91RM9200DK 114config ARCH_AT91RM9200DK
111 bool "Atmel AT91RM9200-DK Development board" 115 bool "Atmel AT91RM9200-DK Development board"
@@ -137,7 +141,7 @@ config MACH_CARMEVA
137 bool "Conitec ARM&EVA" 141 bool "Conitec ARM&EVA"
138 help 142 help
139 Select this if you are using Conitec's AT91RM9200-MCU-Module. 143 Select this if you are using Conitec's AT91RM9200-MCU-Module.
140 <http://www.conitec.net/english/linuxboard.htm> 144 <http://www.conitec.net/english/linuxboard.php>
141 145
142config MACH_ATEB9200 146config MACH_ATEB9200
143 bool "Embest ATEB9200" 147 bool "Embest ATEB9200"
@@ -149,7 +153,7 @@ config MACH_KB9200
149 bool "KwikByte KB920x" 153 bool "KwikByte KB920x"
150 help 154 help
151 Select this if you are using KwikByte's KB920x board. 155 Select this if you are using KwikByte's KB920x board.
152 <http://kwikbyte.com/KB9202_description_new.htm> 156 <http://www.kwikbyte.com/KB9202.html>
153 157
154config MACH_PICOTUX2XX 158config MACH_PICOTUX2XX
155 bool "picotux 200" 159 bool "picotux 200"
@@ -248,6 +252,12 @@ config MACH_CPU9260
248 Select this if you are using a Eukrea Electromatique's 252 Select this if you are using a Eukrea Electromatique's
249 CPU9260 Board <http://www.eukrea.com/> 253 CPU9260 Board <http://www.eukrea.com/>
250 254
255config MACH_FLEXIBITY
256 bool "Flexibity Connect board"
257 help
258 Select this if you are using Flexibity Connect board
259 <http://www.flexibity.com>
260
251endif 261endif
252 262
253# ---------------------------------------------------------- 263# ----------------------------------------------------------
@@ -338,6 +348,7 @@ config MACH_AT91SAM9G20EK
338 that embeds only one SD/MMC slot. 348 that embeds only one SD/MMC slot.
339 349
340config MACH_AT91SAM9G20EK_2MMC 350config MACH_AT91SAM9G20EK_2MMC
351 depends on MACH_AT91SAM9G20EK
341 bool "Atmel AT91SAM9G20-EK Evaluation Kit with 2 SD/MMC Slots" 352 bool "Atmel AT91SAM9G20-EK Evaluation Kit with 2 SD/MMC Slots"
342 select HAVE_NAND_ATMEL_BUSWIDTH_16 353 select HAVE_NAND_ATMEL_BUSWIDTH_16
343 help 354 help
@@ -383,8 +394,8 @@ if ARCH_AT91SAM9G45
383 394
384comment "AT91SAM9G45 Board Type" 395comment "AT91SAM9G45 Board Type"
385 396
386config MACH_AT91SAM9G45EKES 397config MACH_AT91SAM9M10G45EK
387 bool "Atmel AT91SAM9G45-EKES Evaluation Kit" 398 bool "Atmel AT91SAM9M10G45-EK Evaluation Kits"
388 select HAVE_NAND_ATMEL_BUSWIDTH_16 399 select HAVE_NAND_ATMEL_BUSWIDTH_16
389 help 400 help
390 Select this if you are using Atmel's AT91SAM9G45-EKES Evaluation Kit. 401 Select this if you are using Atmel's AT91SAM9G45-EKES Evaluation Kit.
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index ca2ac003f41f..412b3a471a4b 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o
46obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o 46obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o
47obj-$(CONFIG_MACH_AFEB9260) += board-afeb-9260v1.o 47obj-$(CONFIG_MACH_AFEB9260) += board-afeb-9260v1.o
48obj-$(CONFIG_MACH_CPU9260) += board-cpu9krea.o 48obj-$(CONFIG_MACH_CPU9260) += board-cpu9krea.o
49obj-$(CONFIG_MACH_FLEXIBITY) += board-flexibity.o
49 50
50# AT91SAM9261 board-specific support 51# AT91SAM9261 board-specific support
51obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o 52obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
@@ -61,7 +62,6 @@ obj-$(CONFIG_MACH_AT91SAM9RLEK) += board-sam9rlek.o
61 62
62# AT91SAM9G20 board-specific support 63# AT91SAM9G20 board-specific support
63obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o 64obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
64obj-$(CONFIG_MACH_AT91SAM9G20EK_2MMC) += board-sam9g20ek-2slot-mmc.o
65obj-$(CONFIG_MACH_CPU9G20) += board-cpu9krea.o 65obj-$(CONFIG_MACH_CPU9G20) += board-cpu9krea.o
66obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o 66obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o
67obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o 67obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o
@@ -70,7 +70,7 @@ obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o
70obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o 70obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o
71 71
72# AT91SAM9G45 board-specific support 72# AT91SAM9G45 board-specific support
73obj-$(CONFIG_MACH_AT91SAM9G45EKES) += board-sam9m10g45ek.o 73obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o
74 74
75# AT91CAP9 board-specific support 75# AT91CAP9 board-specific support
76obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o 76obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o
diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c
index 9b27d167bff0..46bdc82d3fbf 100644
--- a/arch/arm/mach-at91/board-1arm.c
+++ b/arch/arm/mach-at91/board-1arm.c
@@ -92,8 +92,6 @@ static void __init onearm_board_init(void)
92 92
93MACHINE_START(ONEARM, "Ajeco 1ARM single board computer") 93MACHINE_START(ONEARM, "Ajeco 1ARM single board computer")
94 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 94 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
95 .phys_io = AT91_BASE_SYS,
96 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
97 .boot_params = AT91_SDRAM_BASE + 0x100, 95 .boot_params = AT91_SDRAM_BASE + 0x100,
98 .timer = &at91rm9200_timer, 96 .timer = &at91rm9200_timer,
99 .map_io = onearm_map_io, 97 .map_io = onearm_map_io,
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index 50667bed7cc9..cba7f7771fee 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -218,8 +218,6 @@ static void __init afeb9260_board_init(void)
218 218
219MACHINE_START(AFEB9260, "Custom afeb9260 board") 219MACHINE_START(AFEB9260, "Custom afeb9260 board")
220 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */ 220 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */
221 .phys_io = AT91_BASE_SYS,
222 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
223 .boot_params = AT91_SDRAM_BASE + 0x100, 221 .boot_params = AT91_SDRAM_BASE + 0x100,
224 .timer = &at91sam926x_timer, 222 .timer = &at91sam926x_timer,
225 .map_io = afeb9260_map_io, 223 .map_io = afeb9260_map_io,
diff --git a/arch/arm/mach-at91/board-at572d940hf_ek.c b/arch/arm/mach-at91/board-at572d940hf_ek.c
index 5daff277f53e..3929f1c9e4e5 100644
--- a/arch/arm/mach-at91/board-at572d940hf_ek.c
+++ b/arch/arm/mach-at91/board-at572d940hf_ek.c
@@ -216,7 +216,7 @@ static struct atmel_nand_data __initdata eb_nand_data = {
216/* .rdy_pin = AT91_PIN_PC16, */ 216/* .rdy_pin = AT91_PIN_PC16, */
217 .enable_pin = AT91_PIN_PA15, 217 .enable_pin = AT91_PIN_PA15,
218 .partition_info = nand_partitions, 218 .partition_info = nand_partitions,
219#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16) 219#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
220 .bus_width_16 = 1, 220 .bus_width_16 = 1,
221#else 221#else
222 .bus_width_16 = 0, 222 .bus_width_16 = 0,
@@ -318,8 +318,6 @@ static void __init eb_board_init(void)
318 318
319MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB") 319MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB")
320 /* Maintainer: Atmel <costa.antonior@gmail.com> */ 320 /* Maintainer: Atmel <costa.antonior@gmail.com> */
321 .phys_io = AT91_BASE_SYS,
322 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
323 .boot_params = AT91_SDRAM_BASE + 0x100, 321 .boot_params = AT91_SDRAM_BASE + 0x100,
324 .timer = &at91sam926x_timer, 322 .timer = &at91sam926x_timer,
325 .map_io = eb_map_io, 323 .map_io = eb_map_io,
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index 44eb9f764938..b54e3e6fceb6 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -198,8 +198,6 @@ static void __init cam60_board_init(void)
198 198
199MACHINE_START(CAM60, "KwikByte CAM60") 199MACHINE_START(CAM60, "KwikByte CAM60")
200 /* Maintainer: KwikByte */ 200 /* Maintainer: KwikByte */
201 .phys_io = AT91_BASE_SYS,
202 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
203 .boot_params = AT91_SDRAM_BASE + 0x100, 201 .boot_params = AT91_SDRAM_BASE + 0x100,
204 .timer = &at91sam926x_timer, 202 .timer = &at91sam926x_timer,
205 .map_io = cam60_map_io, 203 .map_io = cam60_map_io,
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
index d6940870e403..e7274440ead9 100644
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -399,8 +399,6 @@ static void __init cap9adk_board_init(void)
399 399
400MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK") 400MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK")
401 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */ 401 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */
402 .phys_io = AT91_BASE_SYS,
403 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
404 .boot_params = AT91_SDRAM_BASE + 0x100, 402 .boot_params = AT91_SDRAM_BASE + 0x100,
405 .timer = &at91sam926x_timer, 403 .timer = &at91sam926x_timer,
406 .map_io = cap9adk_map_io, 404 .map_io = cap9adk_map_io,
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index db1f9544d2e0..2e74a19874d1 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -162,8 +162,6 @@ static void __init carmeva_board_init(void)
162 162
163MACHINE_START(CARMEVA, "Carmeva") 163MACHINE_START(CARMEVA, "Carmeva")
164 /* Maintainer: Conitec Datasystems */ 164 /* Maintainer: Conitec Datasystems */
165 .phys_io = AT91_BASE_SYS,
166 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
167 .boot_params = AT91_SDRAM_BASE + 0x100, 165 .boot_params = AT91_SDRAM_BASE + 0x100,
168 .timer = &at91rm9200_timer, 166 .timer = &at91rm9200_timer,
169 .map_io = carmeva_map_io, 167 .map_io = carmeva_map_io,
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 4bc2e9f6ebb5..3838594578f3 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -375,8 +375,6 @@ MACHINE_START(CPUAT9260, "Eukrea CPU9260")
375MACHINE_START(CPUAT9G20, "Eukrea CPU9G20") 375MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
376#endif 376#endif
377 /* Maintainer: Eric Benard - EUKREA Electromatique */ 377 /* Maintainer: Eric Benard - EUKREA Electromatique */
378 .phys_io = AT91_BASE_SYS,
379 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
380 .boot_params = AT91_SDRAM_BASE + 0x100, 378 .boot_params = AT91_SDRAM_BASE + 0x100,
381 .timer = &at91sam926x_timer, 379 .timer = &at91sam926x_timer,
382 .map_io = cpu9krea_map_io, 380 .map_io = cpu9krea_map_io,
diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c
index a28d99656190..2f4dd8cdd484 100644
--- a/arch/arm/mach-at91/board-cpuat91.c
+++ b/arch/arm/mach-at91/board-cpuat91.c
@@ -175,8 +175,6 @@ static void __init cpuat91_board_init(void)
175 175
176MACHINE_START(CPUAT91, "Eukrea") 176MACHINE_START(CPUAT91, "Eukrea")
177 /* Maintainer: Eric Benard - EUKREA Electromatique */ 177 /* Maintainer: Eric Benard - EUKREA Electromatique */
178 .phys_io = AT91_BASE_SYS,
179 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
180 .boot_params = AT91_SDRAM_BASE + 0x100, 178 .boot_params = AT91_SDRAM_BASE + 0x100,
181 .timer = &at91rm9200_timer, 179 .timer = &at91rm9200_timer,
182 .map_io = cpuat91_map_io, 180 .map_io = cpuat91_map_io,
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index fea2529ebcf9..464839dc39bd 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -257,8 +257,6 @@ static void __init csb337_board_init(void)
257 257
258MACHINE_START(CSB337, "Cogent CSB337") 258MACHINE_START(CSB337, "Cogent CSB337")
259 /* Maintainer: Bill Gatliff */ 259 /* Maintainer: Bill Gatliff */
260 .phys_io = AT91_BASE_SYS,
261 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
262 .boot_params = AT91_SDRAM_BASE + 0x100, 260 .boot_params = AT91_SDRAM_BASE + 0x100,
263 .timer = &at91rm9200_timer, 261 .timer = &at91rm9200_timer,
264 .map_io = csb337_map_io, 262 .map_io = csb337_map_io,
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index cfa3f04b2205..431688c61412 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -138,8 +138,6 @@ static void __init csb637_board_init(void)
138 138
139MACHINE_START(CSB637, "Cogent CSB637") 139MACHINE_START(CSB637, "Cogent CSB637")
140 /* Maintainer: Bill Gatliff */ 140 /* Maintainer: Bill Gatliff */
141 .phys_io = AT91_BASE_SYS,
142 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
143 .boot_params = AT91_SDRAM_BASE + 0x100, 141 .boot_params = AT91_SDRAM_BASE + 0x100,
144 .timer = &at91rm9200_timer, 142 .timer = &at91rm9200_timer,
145 .map_io = csb637_map_io, 143 .map_io = csb637_map_io,
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c
index 0fd0f5bc77ea..e14f0e165680 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-dk.c
@@ -225,8 +225,6 @@ static void __init dk_board_init(void)
225 225
226MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK") 226MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK")
227 /* Maintainer: SAN People/Atmel */ 227 /* Maintainer: SAN People/Atmel */
228 .phys_io = AT91_BASE_SYS,
229 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
230 .boot_params = AT91_SDRAM_BASE + 0x100, 228 .boot_params = AT91_SDRAM_BASE + 0x100,
231 .timer = &at91rm9200_timer, 229 .timer = &at91rm9200_timer,
232 .map_io = dk_map_io, 230 .map_io = dk_map_io,
diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c
index 528656761ff7..6cf6566ae346 100644
--- a/arch/arm/mach-at91/board-eb9200.c
+++ b/arch/arm/mach-at91/board-eb9200.c
@@ -120,8 +120,6 @@ static void __init eb9200_board_init(void)
120} 120}
121 121
122MACHINE_START(ATEB9200, "Embest ATEB9200") 122MACHINE_START(ATEB9200, "Embest ATEB9200")
123 .phys_io = AT91_BASE_SYS,
124 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
125 .boot_params = AT91_SDRAM_BASE + 0x100, 123 .boot_params = AT91_SDRAM_BASE + 0x100,
126 .timer = &at91rm9200_timer, 124 .timer = &at91rm9200_timer,
127 .map_io = eb9200_map_io, 125 .map_io = eb9200_map_io,
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index 1d69908617f0..7b58c948a957 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -168,8 +168,6 @@ static void __init ecb_at91board_init(void)
168 168
169MACHINE_START(ECBAT91, "emQbit's ECB_AT91") 169MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
170 /* Maintainer: emQbit.com */ 170 /* Maintainer: emQbit.com */
171 .phys_io = AT91_BASE_SYS,
172 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
173 .boot_params = AT91_SDRAM_BASE + 0x100, 171 .boot_params = AT91_SDRAM_BASE + 0x100,
174 .timer = &at91rm9200_timer, 172 .timer = &at91rm9200_timer,
175 .map_io = ecb_at91map_io, 173 .map_io = ecb_at91map_io,
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 295a96609e71..a158a0ce458f 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -148,8 +148,6 @@ static void __init eco920_board_init(void)
148 148
149MACHINE_START(ECO920, "eco920") 149MACHINE_START(ECO920, "eco920")
150 /* Maintainer: Sascha Hauer */ 150 /* Maintainer: Sascha Hauer */
151 .phys_io = AT91_BASE_SYS,
152 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
153 .boot_params = AT91_SDRAM_BASE + 0x100, 151 .boot_params = AT91_SDRAM_BASE + 0x100,
154 .timer = &at91rm9200_timer, 152 .timer = &at91rm9200_timer,
155 .map_io = eco920_map_io, 153 .map_io = eco920_map_io,
diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-ek.c
index 4cdfaac8e590..56e92c4bbc2a 100644
--- a/arch/arm/mach-at91/board-ek.c
+++ b/arch/arm/mach-at91/board-ek.c
@@ -191,8 +191,6 @@ static void __init ek_board_init(void)
191 191
192MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK") 192MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK")
193 /* Maintainer: SAN People/Atmel */ 193 /* Maintainer: SAN People/Atmel */
194 .phys_io = AT91_BASE_SYS,
195 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
196 .boot_params = AT91_SDRAM_BASE + 0x100, 194 .boot_params = AT91_SDRAM_BASE + 0x100,
197 .timer = &at91rm9200_timer, 195 .timer = &at91rm9200_timer,
198 .map_io = ek_map_io, 196 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c
new file mode 100644
index 000000000000..c8a62dc8fa65
--- /dev/null
+++ b/arch/arm/mach-at91/board-flexibity.c
@@ -0,0 +1,162 @@
1/*
2 * linux/arch/arm/mach-at91/board-flexibity.c
3 *
4 * Copyright (C) 2010 Flexibity
5 * Copyright (C) 2005 SAN People
6 * Copyright (C) 2006 Atmel
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/init.h>
24#include <linux/platform_device.h>
25#include <linux/spi/spi.h>
26#include <linux/input.h>
27#include <linux/gpio.h>
28
29#include <asm/mach-types.h>
30
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
35#include <mach/hardware.h>
36#include <mach/board.h>
37
38#include "generic.h"
39
40static void __init flexibity_map_io(void)
41{
42 /* Initialize processor: 18.432 MHz crystal */
43 at91sam9260_initialize(18432000);
44
45 /* DBGU on ttyS0. (Rx & Tx only) */
46 at91_register_uart(0, 0, 0);
47
48 /* set serial console to ttyS0 (ie, DBGU) */
49 at91_set_serial_console(0);
50}
51
52static void __init flexibity_init_irq(void)
53{
54 at91sam9260_init_interrupts(NULL);
55}
56
57/* USB Host port */
58static struct at91_usbh_data __initdata flexibity_usbh_data = {
59 .ports = 2,
60};
61
62/* USB Device port */
63static struct at91_udc_data __initdata flexibity_udc_data = {
64 .vbus_pin = AT91_PIN_PC5,
65 .pullup_pin = 0, /* pull-up driven by UDC */
66};
67
68/* SPI devices */
69static struct spi_board_info flexibity_spi_devices[] = {
70 { /* DataFlash chip */
71 .modalias = "mtd_dataflash",
72 .chip_select = 1,
73 .max_speed_hz = 15 * 1000 * 1000,
74 .bus_num = 0,
75 },
76};
77
78/* MCI (SD/MMC) */
79static struct at91_mmc_data __initdata flexibity_mmc_data = {
80 .slot_b = 0,
81 .wire4 = 1,
82 .det_pin = AT91_PIN_PC9,
83 .wp_pin = AT91_PIN_PC4,
84};
85
86/* LEDs */
87static struct gpio_led flexibity_leds[] = {
88 {
89 .name = "usb1:green",
90 .gpio = AT91_PIN_PA12,
91 .active_low = 1,
92 .default_trigger = "default-on",
93 },
94 {
95 .name = "usb1:red",
96 .gpio = AT91_PIN_PA13,
97 .active_low = 1,
98 .default_trigger = "default-on",
99 },
100 {
101 .name = "usb2:green",
102 .gpio = AT91_PIN_PB26,
103 .active_low = 1,
104 .default_trigger = "default-on",
105 },
106 {
107 .name = "usb2:red",
108 .gpio = AT91_PIN_PB27,
109 .active_low = 1,
110 .default_trigger = "default-on",
111 },
112 {
113 .name = "usb3:green",
114 .gpio = AT91_PIN_PC8,
115 .active_low = 1,
116 .default_trigger = "default-on",
117 },
118 {
119 .name = "usb3:red",
120 .gpio = AT91_PIN_PC6,
121 .active_low = 1,
122 .default_trigger = "default-on",
123 },
124 {
125 .name = "usb4:green",
126 .gpio = AT91_PIN_PB4,
127 .active_low = 1,
128 .default_trigger = "default-on",
129 },
130 {
131 .name = "usb4:red",
132 .gpio = AT91_PIN_PB5,
133 .active_low = 1,
134 .default_trigger = "default-on",
135 }
136};
137
138static void __init flexibity_board_init(void)
139{
140 /* Serial */
141 at91_add_device_serial();
142 /* USB Host */
143 at91_add_device_usbh(&flexibity_usbh_data);
144 /* USB Device */
145 at91_add_device_udc(&flexibity_udc_data);
146 /* SPI */
147 at91_add_device_spi(flexibity_spi_devices,
148 ARRAY_SIZE(flexibity_spi_devices));
149 /* MMC */
150 at91_add_device_mmc(0, &flexibity_mmc_data);
151 /* LEDs */
152 at91_gpio_leds(flexibity_leds, ARRAY_SIZE(flexibity_leds));
153}
154
155MACHINE_START(FLEXIBITY, "Flexibity Connect")
156 /* Maintainer: Maxim Osipov */
157 .boot_params = AT91_SDRAM_BASE + 0x100,
158 .timer = &at91sam926x_timer,
159 .map_io = flexibity_map_io,
160 .init_irq = flexibity_init_irq,
161 .init_machine = flexibity_board_init,
162MACHINE_END
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index a87956c0a74f..c0ce79d431a0 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -99,8 +99,6 @@ static void __init kafa_board_init(void)
99 99
100MACHINE_START(KAFA, "Sperry-Sun KAFA") 100MACHINE_START(KAFA, "Sperry-Sun KAFA")
101 /* Maintainer: Sergei Sharonov */ 101 /* Maintainer: Sergei Sharonov */
102 .phys_io = AT91_BASE_SYS,
103 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
104 .boot_params = AT91_SDRAM_BASE + 0x100, 102 .boot_params = AT91_SDRAM_BASE + 0x100,
105 .timer = &at91rm9200_timer, 103 .timer = &at91rm9200_timer,
106 .map_io = kafa_map_io, 104 .map_io = kafa_map_io,
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index fe9b9913fa3c..a13d2063faff 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -136,8 +136,6 @@ static void __init kb9202_board_init(void)
136 136
137MACHINE_START(KB9200, "KB920x") 137MACHINE_START(KB9200, "KB920x")
138 /* Maintainer: KwikByte, Inc. */ 138 /* Maintainer: KwikByte, Inc. */
139 .phys_io = AT91_BASE_SYS,
140 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
141 .boot_params = AT91_SDRAM_BASE + 0x100, 139 .boot_params = AT91_SDRAM_BASE + 0x100,
142 .timer = &at91rm9200_timer, 140 .timer = &at91rm9200_timer,
143 .map_io = kb9202_map_io, 141 .map_io = kb9202_map_io,
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index 7c1e382330fb..fe5f1d47e6e2 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -387,8 +387,6 @@ static void __init neocore926_board_init(void)
387 387
388MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926") 388MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926")
389 /* Maintainer: ADENEO */ 389 /* Maintainer: ADENEO */
390 .phys_io = AT91_BASE_SYS,
391 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
392 .boot_params = AT91_SDRAM_BASE + 0x100, 390 .boot_params = AT91_SDRAM_BASE + 0x100,
393 .timer = &at91sam926x_timer, 391 .timer = &at91sam926x_timer,
394 .map_io = neocore926_map_io, 392 .map_io = neocore926_map_io,
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index 859727e7ea30..9d833bbc592d 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -156,8 +156,6 @@ static void __init picotux200_board_init(void)
156 156
157MACHINE_START(PICOTUX2XX, "picotux 200") 157MACHINE_START(PICOTUX2XX, "picotux 200")
158 /* Maintainer: Kleinhenz Elektronik GmbH */ 158 /* Maintainer: Kleinhenz Elektronik GmbH */
159 .phys_io = AT91_BASE_SYS,
160 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
161 .boot_params = AT91_SDRAM_BASE + 0x100, 159 .boot_params = AT91_SDRAM_BASE + 0x100,
162 .timer = &at91rm9200_timer, 160 .timer = &at91rm9200_timer,
163 .map_io = picotux200_map_io, 161 .map_io = picotux200_map_io,
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index 664938e8f661..69d15a875b66 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -268,8 +268,6 @@ static void __init ek_board_init(void)
268 268
269MACHINE_START(QIL_A9260, "CALAO QIL_A9260") 269MACHINE_START(QIL_A9260, "CALAO QIL_A9260")
270 /* Maintainer: calao-systems */ 270 /* Maintainer: calao-systems */
271 .phys_io = AT91_BASE_SYS,
272 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
273 .boot_params = AT91_SDRAM_BASE + 0x100, 271 .boot_params = AT91_SDRAM_BASE + 0x100,
274 .timer = &at91sam926x_timer, 272 .timer = &at91sam926x_timer,
275 .map_io = ek_map_io, 273 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index b48346977534..25a26beaa728 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -212,8 +212,6 @@ static void __init ek_board_init(void)
212 212
213MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260") 213MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
214 /* Maintainer: Olimex */ 214 /* Maintainer: Olimex */
215 .phys_io = AT91_BASE_SYS,
216 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
217 .boot_params = AT91_SDRAM_BASE + 0x100, 215 .boot_params = AT91_SDRAM_BASE + 0x100,
218 .timer = &at91sam926x_timer, 216 .timer = &at91sam926x_timer,
219 .map_io = ek_map_io, 217 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index ba9d501b5c50..de1816e0e1d9 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -356,8 +356,6 @@ static void __init ek_board_init(void)
356 356
357MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK") 357MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
358 /* Maintainer: Atmel */ 358 /* Maintainer: Atmel */
359 .phys_io = AT91_BASE_SYS,
360 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
361 .boot_params = AT91_SDRAM_BASE + 0x100, 359 .boot_params = AT91_SDRAM_BASE + 0x100,
362 .timer = &at91sam926x_timer, 360 .timer = &at91sam926x_timer,
363 .map_io = ek_map_io, 361 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 65eb0943194f..14acc901e24c 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -623,8 +623,6 @@ MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
623MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK") 623MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
624#endif 624#endif
625 /* Maintainer: Atmel */ 625 /* Maintainer: Atmel */
626 .phys_io = AT91_BASE_SYS,
627 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
628 .boot_params = AT91_SDRAM_BASE + 0x100, 626 .boot_params = AT91_SDRAM_BASE + 0x100,
629 .timer = &at91sam926x_timer, 627 .timer = &at91sam926x_timer,
630 .map_io = ek_map_io, 628 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index 2d867fb0630f..bfe490df58be 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -454,8 +454,6 @@ static void __init ek_board_init(void)
454 454
455MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK") 455MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
456 /* Maintainer: Atmel */ 456 /* Maintainer: Atmel */
457 .phys_io = AT91_BASE_SYS,
458 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
459 .boot_params = AT91_SDRAM_BASE + 0x100, 457 .boot_params = AT91_SDRAM_BASE + 0x100,
460 .timer = &at91sam926x_timer, 458 .timer = &at91sam926x_timer,
461 .map_io = ek_map_io, 459 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c b/arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
deleted file mode 100644
index c49f5c003ee1..000000000000
--- a/arch/arm/mach-at91/board-sam9g20ek-2slot-mmc.c
+++ /dev/null
@@ -1,329 +0,0 @@
1/*
2 * Copyright (C) 2005 SAN People
3 * Copyright (C) 2008 Atmel
4 * Copyright (C) 2009 Rob Emanuele
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/types.h>
22#include <linux/init.h>
23#include <linux/mm.h>
24#include <linux/module.h>
25#include <linux/platform_device.h>
26#include <linux/spi/spi.h>
27#include <linux/spi/at73c213.h>
28#include <linux/clk.h>
29#include <linux/regulator/machine.h>
30#include <linux/regulator/fixed.h>
31#include <linux/regulator/consumer.h>
32
33#include <mach/hardware.h>
34#include <asm/setup.h>
35#include <asm/mach-types.h>
36#include <asm/irq.h>
37
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41
42#include <mach/board.h>
43#include <mach/gpio.h>
44#include <mach/at91sam9_smc.h>
45
46#include "sam9_smc.h"
47#include "generic.h"
48
49
50static void __init ek_map_io(void)
51{
52 /* Initialize processor: 18.432 MHz crystal */
53 at91sam9260_initialize(18432000);
54
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
59 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
60 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
61 | ATMEL_UART_RI);
62
63 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
64 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
65
66 /* set serial console to ttyS0 (ie, DBGU) */
67 at91_set_serial_console(0);
68}
69
70static void __init ek_init_irq(void)
71{
72 at91sam9260_init_interrupts(NULL);
73}
74
75
76/*
77 * USB Host port
78 */
79static struct at91_usbh_data __initdata ek_usbh_data = {
80 .ports = 2,
81};
82
83/*
84 * USB Device port
85 */
86static struct at91_udc_data __initdata ek_udc_data = {
87 .vbus_pin = AT91_PIN_PC5,
88 .pullup_pin = 0, /* pull-up driven by UDC */
89};
90
91
92/*
93 * SPI devices.
94 */
95static struct spi_board_info ek_spi_devices[] = {
96#if !(defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_AT91))
97 { /* DataFlash chip */
98 .modalias = "mtd_dataflash",
99 .chip_select = 1,
100 .max_speed_hz = 15 * 1000 * 1000,
101 .bus_num = 0,
102 },
103#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
104 { /* DataFlash card */
105 .modalias = "mtd_dataflash",
106 .chip_select = 0,
107 .max_speed_hz = 15 * 1000 * 1000,
108 .bus_num = 0,
109 },
110#endif
111#endif
112};
113
114
115/*
116 * MACB Ethernet device
117 */
118static struct at91_eth_data __initdata ek_macb_data = {
119 .phy_irq_pin = AT91_PIN_PB0,
120 .is_rmii = 1,
121};
122
123
124/*
125 * NAND flash
126 */
127static struct mtd_partition __initdata ek_nand_partition[] = {
128 {
129 .name = "Bootstrap",
130 .offset = 0,
131 .size = 4 * SZ_1M,
132 },
133 {
134 .name = "Partition 1",
135 .offset = MTDPART_OFS_NXTBLK,
136 .size = 60 * SZ_1M,
137 },
138 {
139 .name = "Partition 2",
140 .offset = MTDPART_OFS_NXTBLK,
141 .size = MTDPART_SIZ_FULL,
142 },
143};
144
145static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
146{
147 *num_partitions = ARRAY_SIZE(ek_nand_partition);
148 return ek_nand_partition;
149}
150
151/* det_pin is not connected */
152static struct atmel_nand_data __initdata ek_nand_data = {
153 .ale = 21,
154 .cle = 22,
155 .rdy_pin = AT91_PIN_PC13,
156 .enable_pin = AT91_PIN_PC14,
157 .partition_info = nand_partitions,
158#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
159 .bus_width_16 = 1,
160#else
161 .bus_width_16 = 0,
162#endif
163};
164
165static struct sam9_smc_config __initdata ek_nand_smc_config = {
166 .ncs_read_setup = 0,
167 .nrd_setup = 2,
168 .ncs_write_setup = 0,
169 .nwe_setup = 2,
170
171 .ncs_read_pulse = 4,
172 .nrd_pulse = 4,
173 .ncs_write_pulse = 4,
174 .nwe_pulse = 4,
175
176 .read_cycle = 7,
177 .write_cycle = 7,
178
179 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
180 .tdf_cycles = 3,
181};
182
183static void __init ek_add_device_nand(void)
184{
185 /* setup bus-width (8 or 16) */
186 if (ek_nand_data.bus_width_16)
187 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
188 else
189 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
190
191 /* configure chip-select 3 (NAND) */
192 sam9_smc_configure(3, &ek_nand_smc_config);
193
194 at91_add_device_nand(&ek_nand_data);
195}
196
197
198/*
199 * MCI (SD/MMC)
200 * wp_pin is not connected
201 */
202#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
203static struct mci_platform_data __initdata ek_mmc_data = {
204 .slot[0] = {
205 .bus_width = 4,
206 .detect_pin = AT91_PIN_PC2,
207 .wp_pin = -ENODEV,
208 },
209 .slot[1] = {
210 .bus_width = 4,
211 .detect_pin = AT91_PIN_PC9,
212 .wp_pin = -ENODEV,
213 },
214
215};
216#else
217static struct at91_mmc_data __initdata ek_mmc_data = {
218 .slot_b = 1, /* Only one slot so use slot B */
219 .wire4 = 1,
220 .det_pin = AT91_PIN_PC9,
221};
222#endif
223
224/*
225 * LEDs
226 */
227static struct gpio_led ek_leds[] = {
228 { /* "bottom" led, green, userled1 to be defined */
229 .name = "ds5",
230 .gpio = AT91_PIN_PB8,
231 .active_low = 1,
232 .default_trigger = "none",
233 },
234 { /* "power" led, yellow */
235 .name = "ds1",
236 .gpio = AT91_PIN_PB9,
237 .default_trigger = "heartbeat",
238 }
239};
240
241#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
242static struct regulator_consumer_supply ek_audio_consumer_supplies[] = {
243 REGULATOR_SUPPLY("AVDD", "0-001b"),
244 REGULATOR_SUPPLY("HPVDD", "0-001b"),
245 REGULATOR_SUPPLY("DBVDD", "0-001b"),
246 REGULATOR_SUPPLY("DCVDD", "0-001b"),
247};
248
249static struct regulator_init_data ek_avdd_reg_init_data = {
250 .constraints = {
251 .name = "3V3",
252 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
253 },
254 .consumer_supplies = ek_audio_consumer_supplies,
255 .num_consumer_supplies = ARRAY_SIZE(ek_audio_consumer_supplies),
256};
257
258static struct fixed_voltage_config ek_vdd_pdata = {
259 .supply_name = "board-3V3",
260 .microvolts = 3300000,
261 .gpio = -EINVAL,
262 .enabled_at_boot = 0,
263 .init_data = &ek_avdd_reg_init_data,
264};
265static struct platform_device ek_voltage_regulator = {
266 .name = "reg-fixed-voltage",
267 .id = -1,
268 .num_resources = 0,
269 .dev = {
270 .platform_data = &ek_vdd_pdata,
271 },
272};
273static void __init ek_add_regulators(void)
274{
275 platform_device_register(&ek_voltage_regulator);
276}
277#else
278static void __init ek_add_regulators(void) {}
279#endif
280
281static struct i2c_board_info __initdata ek_i2c_devices[] = {
282 {
283 I2C_BOARD_INFO("24c512", 0x50),
284 },
285};
286
287
288static void __init ek_board_init(void)
289{
290 /* Serial */
291 at91_add_device_serial();
292 /* USB Host */
293 at91_add_device_usbh(&ek_usbh_data);
294 /* USB Device */
295 at91_add_device_udc(&ek_udc_data);
296 /* SPI */
297 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
298 /* NAND */
299 ek_add_device_nand();
300 /* Ethernet */
301 at91_add_device_eth(&ek_macb_data);
302 /* Regulators */
303 ek_add_regulators();
304 /* MMC */
305#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
306 at91_add_device_mci(0, &ek_mmc_data);
307#else
308 at91_add_device_mmc(0, &ek_mmc_data);
309#endif
310 /* I2C */
311 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
312 /* LEDs */
313 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
314 /* PCK0 provides MCLK to the WM8731 */
315 at91_set_B_periph(AT91_PIN_PC1, 0);
316 /* SSC (for WM8731) */
317 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
318}
319
320MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")
321 /* Maintainer: Rob Emanuele */
322 .phys_io = AT91_BASE_SYS,
323 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
324 .boot_params = AT91_SDRAM_BASE + 0x100,
325 .timer = &at91sam926x_timer,
326 .map_io = ek_map_io,
327 .init_irq = ek_init_irq,
328 .init_machine = ek_board_init,
329MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index 6ea9808b8868..ca8198b3c168 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -47,6 +47,18 @@
47#include "sam9_smc.h" 47#include "sam9_smc.h"
48#include "generic.h" 48#include "generic.h"
49 49
50/*
51 * board revision encoding
52 * bit 0:
53 * 0 => 1 sd/mmc slot
54 * 1 => 2 sd/mmc slots connectors (board from revision C)
55 */
56#define HAVE_2MMC (1 << 0)
57static int inline ek_have_2mmc(void)
58{
59 return machine_is_at91sam9g20ek_2mmc() || (system_rev & HAVE_2MMC);
60}
61
50 62
51static void __init ek_map_io(void) 63static void __init ek_map_io(void)
52{ 64{
@@ -94,7 +106,7 @@ static struct at91_udc_data __initdata ek_udc_data = {
94 * SPI devices. 106 * SPI devices.
95 */ 107 */
96static struct spi_board_info ek_spi_devices[] = { 108static struct spi_board_info ek_spi_devices[] = {
97#if !defined(CONFIG_MMC_AT91) 109#if !(defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_AT91))
98 { /* DataFlash chip */ 110 { /* DataFlash chip */
99 .modalias = "mtd_dataflash", 111 .modalias = "mtd_dataflash",
100 .chip_select = 1, 112 .chip_select = 1,
@@ -121,6 +133,13 @@ static struct at91_eth_data __initdata ek_macb_data = {
121 .is_rmii = 1, 133 .is_rmii = 1,
122}; 134};
123 135
136static void __init ek_add_device_macb(void)
137{
138 if (ek_have_2mmc())
139 ek_macb_data.phy_irq_pin = AT91_PIN_PB0;
140
141 at91_add_device_eth(&ek_macb_data);
142}
124 143
125/* 144/*
126 * NAND flash 145 * NAND flash
@@ -198,13 +217,36 @@ static void __init ek_add_device_nand(void)
198 217
199/* 218/*
200 * MCI (SD/MMC) 219 * MCI (SD/MMC)
201 * det_pin, wp_pin and vcc_pin are not connected 220 * wp_pin and vcc_pin are not connected
202 */ 221 */
222#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
223static struct mci_platform_data __initdata ek_mmc_data = {
224 .slot[1] = {
225 .bus_width = 4,
226 .detect_pin = AT91_PIN_PC9,
227 },
228
229};
230#else
203static struct at91_mmc_data __initdata ek_mmc_data = { 231static struct at91_mmc_data __initdata ek_mmc_data = {
204 .slot_b = 1, 232 .slot_b = 1, /* Only one slot so use slot B */
205 .wire4 = 1, 233 .wire4 = 1,
234 .det_pin = AT91_PIN_PC9,
206}; 235};
236#endif
207 237
238static void __init ek_add_device_mmc(void)
239{
240#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
241 if (ek_have_2mmc()) {
242 ek_mmc_data.slot[0].bus_width = 4;
243 ek_mmc_data.slot[0].detect_pin = AT91_PIN_PC2;
244 }
245 at91_add_device_mci(0, &ek_mmc_data);
246#else
247 at91_add_device_mmc(0, &ek_mmc_data);
248#endif
249}
208 250
209/* 251/*
210 * LEDs 252 * LEDs
@@ -223,6 +265,15 @@ static struct gpio_led ek_leds[] = {
223 } 265 }
224}; 266};
225 267
268static void __init ek_add_device_gpio_leds(void)
269{
270 if (ek_have_2mmc()) {
271 ek_leds[0].gpio = AT91_PIN_PB8;
272 ek_leds[1].gpio = AT91_PIN_PB9;
273 }
274
275 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
276}
226 277
227/* 278/*
228 * GPIO Buttons 279 * GPIO Buttons
@@ -336,15 +387,15 @@ static void __init ek_board_init(void)
336 /* NAND */ 387 /* NAND */
337 ek_add_device_nand(); 388 ek_add_device_nand();
338 /* Ethernet */ 389 /* Ethernet */
339 at91_add_device_eth(&ek_macb_data); 390 ek_add_device_macb();
340 /* Regulators */ 391 /* Regulators */
341 ek_add_regulators(); 392 ek_add_regulators();
342 /* MMC */ 393 /* MMC */
343 at91_add_device_mmc(0, &ek_mmc_data); 394 ek_add_device_mmc();
344 /* I2C */ 395 /* I2C */
345 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices)); 396 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
346 /* LEDs */ 397 /* LEDs */
347 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 398 ek_add_device_gpio_leds();
348 /* Push Buttons */ 399 /* Push Buttons */
349 ek_add_device_buttons(); 400 ek_add_device_buttons();
350 /* PCK0 provides MCLK to the WM8731 */ 401 /* PCK0 provides MCLK to the WM8731 */
@@ -355,8 +406,15 @@ static void __init ek_board_init(void)
355 406
356MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK") 407MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
357 /* Maintainer: Atmel */ 408 /* Maintainer: Atmel */
358 .phys_io = AT91_BASE_SYS, 409 .boot_params = AT91_SDRAM_BASE + 0x100,
359 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc, 410 .timer = &at91sam926x_timer,
411 .map_io = ek_map_io,
412 .init_irq = ek_init_irq,
413 .init_machine = ek_board_init,
414MACHINE_END
415
416MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")
417 /* Maintainer: Atmel */
360 .boot_params = AT91_SDRAM_BASE + 0x100, 418 .boot_params = AT91_SDRAM_BASE + 0x100,
361 .timer = &at91sam926x_timer, 419 .timer = &at91sam926x_timer,
362 .map_io = ek_map_io, 420 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index ee800595594d..7913984f6de9 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -135,7 +135,7 @@ static struct atmel_nand_data __initdata ek_nand_data = {
135 .rdy_pin = AT91_PIN_PC8, 135 .rdy_pin = AT91_PIN_PC8,
136 .enable_pin = AT91_PIN_PC14, 136 .enable_pin = AT91_PIN_PC14,
137 .partition_info = nand_partitions, 137 .partition_info = nand_partitions,
138#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16) 138#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
139 .bus_width_16 = 1, 139 .bus_width_16 = 1,
140#else 140#else
141 .bus_width_16 = 0, 141 .bus_width_16 = 0,
@@ -399,10 +399,8 @@ static void __init ek_board_init(void)
399 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); 399 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
400} 400}
401 401
402MACHINE_START(AT91SAM9G45EKES, "Atmel AT91SAM9G45-EKES") 402MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
403 /* Maintainer: Atmel */ 403 /* Maintainer: Atmel */
404 .phys_io = AT91_BASE_SYS,
405 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
406 .boot_params = AT91_SDRAM_BASE + 0x100, 404 .boot_params = AT91_SDRAM_BASE + 0x100,
407 .timer = &at91sam926x_timer, 405 .timer = &at91sam926x_timer,
408 .map_io = ek_map_io, 406 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index 7ac20f3a2067..3bf3408e94c1 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -329,8 +329,6 @@ static void __init ek_board_init(void)
329 329
330MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK") 330MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
331 /* Maintainer: Atmel */ 331 /* Maintainer: Atmel */
332 .phys_io = AT91_BASE_SYS,
333 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
334 .boot_params = AT91_SDRAM_BASE + 0x100, 332 .boot_params = AT91_SDRAM_BASE + 0x100,
335 .timer = &at91sam926x_timer, 333 .timer = &at91sam926x_timer,
336 .map_io = ek_map_io, 334 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 2c08ae4ad3a1..0a99b3cedd7a 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -177,8 +177,6 @@ static void __init snapper9260_board_init(void)
177} 177}
178 178
179MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module") 179MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module")
180 .phys_io = AT91_BASE_SYS,
181 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
182 .boot_params = AT91_SDRAM_BASE + 0x100, 180 .boot_params = AT91_SDRAM_BASE + 0x100,
183 .timer = &at91sam926x_timer, 181 .timer = &at91sam926x_timer,
184 .map_io = snapper9260_map_io, 182 .map_io = snapper9260_map_io,
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index 87958274290f..5206eef4a67e 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -294,8 +294,6 @@ static void __init stamp9g20_board_init(void)
294 294
295MACHINE_START(PORTUXG20, "taskit PortuxG20") 295MACHINE_START(PORTUXG20, "taskit PortuxG20")
296 /* Maintainer: taskit GmbH */ 296 /* Maintainer: taskit GmbH */
297 .phys_io = AT91_BASE_SYS,
298 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
299 .boot_params = AT91_SDRAM_BASE + 0x100, 297 .boot_params = AT91_SDRAM_BASE + 0x100,
300 .timer = &at91sam926x_timer, 298 .timer = &at91sam926x_timer,
301 .map_io = portuxg20_map_io, 299 .map_io = portuxg20_map_io,
@@ -305,8 +303,6 @@ MACHINE_END
305 303
306MACHINE_START(STAMP9G20, "taskit Stamp9G20") 304MACHINE_START(STAMP9G20, "taskit Stamp9G20")
307 /* Maintainer: taskit GmbH */ 305 /* Maintainer: taskit GmbH */
308 .phys_io = AT91_BASE_SYS,
309 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
310 .boot_params = AT91_SDRAM_BASE + 0x100, 306 .boot_params = AT91_SDRAM_BASE + 0x100,
311 .timer = &at91sam926x_timer, 307 .timer = &at91sam926x_timer,
312 .map_io = stamp9g20_map_io, 308 .map_io = stamp9g20_map_io,
diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c
index 905d6ef76807..07784baeae84 100644
--- a/arch/arm/mach-at91/board-usb-a9260.c
+++ b/arch/arm/mach-at91/board-usb-a9260.c
@@ -228,8 +228,6 @@ static void __init ek_board_init(void)
228 228
229MACHINE_START(USB_A9260, "CALAO USB_A9260") 229MACHINE_START(USB_A9260, "CALAO USB_A9260")
230 /* Maintainer: calao-systems */ 230 /* Maintainer: calao-systems */
231 .phys_io = AT91_BASE_SYS,
232 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
233 .boot_params = AT91_SDRAM_BASE + 0x100, 231 .boot_params = AT91_SDRAM_BASE + 0x100,
234 .timer = &at91sam926x_timer, 232 .timer = &at91sam926x_timer,
235 .map_io = ek_map_io, 233 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c
index b6a3480383e5..b614508931fd 100644
--- a/arch/arm/mach-at91/board-usb-a9263.c
+++ b/arch/arm/mach-at91/board-usb-a9263.c
@@ -244,8 +244,6 @@ static void __init ek_board_init(void)
244 244
245MACHINE_START(USB_A9263, "CALAO USB_A9263") 245MACHINE_START(USB_A9263, "CALAO USB_A9263")
246 /* Maintainer: calao-systems */ 246 /* Maintainer: calao-systems */
247 .phys_io = AT91_BASE_SYS,
248 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
249 .boot_params = AT91_SDRAM_BASE + 0x100, 247 .boot_params = AT91_SDRAM_BASE + 0x100,
250 .timer = &at91sam926x_timer, 248 .timer = &at91sam926x_timer,
251 .map_io = ek_map_io, 249 .map_io = ek_map_io,
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index e22bf051f835..89df00a9d2f7 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -594,8 +594,6 @@ static void __init yl9200_board_init(void)
594 594
595MACHINE_START(YL9200, "uCdragon YL-9200") 595MACHINE_START(YL9200, "uCdragon YL-9200")
596 /* Maintainer: S.Birtles */ 596 /* Maintainer: S.Birtles */
597 .phys_io = AT91_BASE_SYS,
598 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
599 .boot_params = AT91_SDRAM_BASE + 0x100, 597 .boot_params = AT91_SDRAM_BASE + 0x100,
600 .timer = &at91rm9200_timer, 598 .timer = &at91rm9200_timer,
601 .map_io = yl9200_map_io, 599 .map_io = yl9200_map_io,
diff --git a/arch/arm/mach-at91/include/mach/at91x40.h b/arch/arm/mach-at91/include/mach/at91x40.h
index d34cdb8abdca..063ac44a0204 100644
--- a/arch/arm/mach-at91/include/mach/at91x40.h
+++ b/arch/arm/mach-at91/include/mach/at91x40.h
@@ -52,4 +52,10 @@
52#define AT91_DBGU_CIDR (AT91_SF + 0) /* CIDR in PS segment */ 52#define AT91_DBGU_CIDR (AT91_SF + 0) /* CIDR in PS segment */
53#define AT91_DBGU_EXID (AT91_SF + 4) /* EXID in PS segment */ 53#define AT91_DBGU_EXID (AT91_SF + 4) /* EXID in PS segment */
54 54
55/*
56 * Support defines for the simple Power Controller module.
57 */
58#define AT91_PS_CR (AT91_PS + 0) /* PS Control register */
59#define AT91_PS_CR_CPU (1 << 0) /* CPU clock disable bit */
60
55#endif /* AT91X40_H */ 61#endif /* AT91X40_H */
diff --git a/arch/arm/mach-at91/include/mach/debug-macro.S b/arch/arm/mach-at91/include/mach/debug-macro.S
index 9e750a1c1b5a..0f959faf74a9 100644
--- a/arch/arm/mach-at91/include/mach/debug-macro.S
+++ b/arch/arm/mach-at91/include/mach/debug-macro.S
@@ -14,11 +14,9 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/at91_dbgu.h> 15#include <mach/at91_dbgu.h>
16 16
17 .macro addruart, rx, tmp 17 .macro addruart, rp, rv
18 mrc p15, 0, \rx, c1, c0 18 ldr \rp, =(AT91_BASE_SYS + AT91_DBGU) @ System peripherals (phys address)
19 tst \rx, #1 @ MMU enabled? 19 ldr \rv, =(AT91_VA_BASE_SYS + AT91_DBGU) @ System peripherals (virt address)
20 ldreq \rx, =(AT91_BASE_SYS + AT91_DBGU) @ System peripherals (phys address)
21 ldrne \rx, =(AT91_VA_BASE_SYS + AT91_DBGU) @ System peripherals (virt address)
22 .endm 20 .endm
23 21
24 .macro senduart,rd,rx 22 .macro senduart,rd,rx
diff --git a/arch/arm/mach-at91/include/mach/system.h b/arch/arm/mach-at91/include/mach/system.h
index c80e090b3670..36af14bc13bb 100644
--- a/arch/arm/mach-at91/include/mach/system.h
+++ b/arch/arm/mach-at91/include/mach/system.h
@@ -28,17 +28,20 @@
28 28
29static inline void arch_idle(void) 29static inline void arch_idle(void)
30{ 30{
31#ifndef CONFIG_DEBUG_KERNEL
32 /* 31 /*
33 * Disable the processor clock. The processor will be automatically 32 * Disable the processor clock. The processor will be automatically
34 * re-enabled by an interrupt or by a reset. 33 * re-enabled by an interrupt or by a reset.
35 */ 34 */
36 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK); 35#ifdef AT91_PS
36 at91_sys_write(AT91_PS_CR, AT91_PS_CR_CPU);
37#else 37#else
38 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK);
39#endif
40#ifndef CONFIG_CPU_ARM920T
38 /* 41 /*
39 * Set the processor (CP15) into 'Wait for Interrupt' mode. 42 * Set the processor (CP15) into 'Wait for Interrupt' mode.
40 * Unlike disabling the processor clock via the PMC (above) 43 * Post-RM9200 processors need this in conjunction with the above
41 * this allows the processor to be woken via JTAG. 44 * to save power when idle.
42 */ 45 */
43 cpu_do_idle(); 46 cpu_do_idle();
44#endif 47#endif
diff --git a/arch/arm/mach-bcmring/arch.c b/arch/arm/mach-bcmring/arch.c
index 2f139196d63d..73eb066d2329 100644
--- a/arch/arm/mach-bcmring/arch.c
+++ b/arch/arm/mach-bcmring/arch.c
@@ -167,8 +167,6 @@ static void __init bcmring_fixup(struct machine_desc *desc,
167 167
168MACHINE_START(BCMRING, "BCMRING") 168MACHINE_START(BCMRING, "BCMRING")
169 /* Maintainer: Broadcom Corporation */ 169 /* Maintainer: Broadcom Corporation */
170 .phys_io = MM_IO_START,
171 .io_pg_offst = (MM_IO_BASE >> 18) & 0xfffc,
172 .fixup = bcmring_fixup, 170 .fixup = bcmring_fixup,
173 .map_io = bcmring_map_io, 171 .map_io = bcmring_map_io,
174 .init_irq = bcmring_init_irq, 172 .init_irq = bcmring_init_irq,
diff --git a/arch/arm/mach-bcmring/dma.c b/arch/arm/mach-bcmring/dma.c
index 29c0a911df26..77eb35c89cd0 100644
--- a/arch/arm/mach-bcmring/dma.c
+++ b/arch/arm/mach-bcmring/dma.c
@@ -691,7 +691,7 @@ int dma_init(void)
691 691
692 memset(&gDMA, 0, sizeof(gDMA)); 692 memset(&gDMA, 0, sizeof(gDMA));
693 693
694 init_MUTEX_LOCKED(&gDMA.lock); 694 sema_init(&gDMA.lock, 0);
695 init_waitqueue_head(&gDMA.freeChannelQ); 695 init_waitqueue_head(&gDMA.freeChannelQ);
696 696
697 /* Initialize the Hardware */ 697 /* Initialize the Hardware */
@@ -1574,7 +1574,7 @@ int dma_init_mem_map(DMA_MemMap_t *memMap)
1574{ 1574{
1575 memset(memMap, 0, sizeof(*memMap)); 1575 memset(memMap, 0, sizeof(*memMap));
1576 1576
1577 init_MUTEX(&memMap->lock); 1577 sema_init(&memMap->lock, 1);
1578 1578
1579 return 0; 1579 return 0;
1580} 1580}
diff --git a/arch/arm/mach-bcmring/include/mach/vmalloc.h b/arch/arm/mach-bcmring/include/mach/vmalloc.h
index 35e2ead8395c..3db3a09fd398 100644
--- a/arch/arm/mach-bcmring/include/mach/vmalloc.h
+++ b/arch/arm/mach-bcmring/include/mach/vmalloc.h
@@ -22,4 +22,4 @@
22 * 0xe0000000 to 0xefffffff. This gives us 256 MB of vm space and handles 22 * 0xe0000000 to 0xefffffff. This gives us 256 MB of vm space and handles
23 * larger physical memory designs better. 23 * larger physical memory designs better.
24 */ 24 */
25#define VMALLOC_END (PAGE_OFFSET + 0x30000000) 25#define VMALLOC_END 0xf0000000
diff --git a/arch/arm/mach-bcmring/irq.c b/arch/arm/mach-bcmring/irq.c
index dc1c4939b0ce..e3152631eb37 100644
--- a/arch/arm/mach-bcmring/irq.c
+++ b/arch/arm/mach-bcmring/irq.c
@@ -67,21 +67,21 @@ static void bcmring_unmask_irq2(unsigned int irq)
67} 67}
68 68
69static struct irq_chip bcmring_irq0_chip = { 69static struct irq_chip bcmring_irq0_chip = {
70 .typename = "ARM-INTC0", 70 .name = "ARM-INTC0",
71 .ack = bcmring_mask_irq0, 71 .ack = bcmring_mask_irq0,
72 .mask = bcmring_mask_irq0, /* mask a specific interrupt, blocking its delivery. */ 72 .mask = bcmring_mask_irq0, /* mask a specific interrupt, blocking its delivery. */
73 .unmask = bcmring_unmask_irq0, /* unmaks an interrupt */ 73 .unmask = bcmring_unmask_irq0, /* unmaks an interrupt */
74}; 74};
75 75
76static struct irq_chip bcmring_irq1_chip = { 76static struct irq_chip bcmring_irq1_chip = {
77 .typename = "ARM-INTC1", 77 .name = "ARM-INTC1",
78 .ack = bcmring_mask_irq1, 78 .ack = bcmring_mask_irq1,
79 .mask = bcmring_mask_irq1, 79 .mask = bcmring_mask_irq1,
80 .unmask = bcmring_unmask_irq1, 80 .unmask = bcmring_unmask_irq1,
81}; 81};
82 82
83static struct irq_chip bcmring_irq2_chip = { 83static struct irq_chip bcmring_irq2_chip = {
84 .typename = "ARM-SINTC", 84 .name = "ARM-SINTC",
85 .ack = bcmring_mask_irq2, 85 .ack = bcmring_mask_irq2,
86 .mask = bcmring_mask_irq2, 86 .mask = bcmring_mask_irq2,
87 .unmask = bcmring_unmask_irq2, 87 .unmask = bcmring_unmask_irq2,
diff --git a/arch/arm/mach-clps711x/autcpu12.c b/arch/arm/mach-clps711x/autcpu12.c
index 5f18eccdc725..4a74b2c959bd 100644
--- a/arch/arm/mach-clps711x/autcpu12.c
+++ b/arch/arm/mach-clps711x/autcpu12.c
@@ -64,8 +64,6 @@ void __init autcpu12_map_io(void)
64 64
65MACHINE_START(AUTCPU12, "autronix autcpu12") 65MACHINE_START(AUTCPU12, "autronix autcpu12")
66 /* Maintainer: Thomas Gleixner */ 66 /* Maintainer: Thomas Gleixner */
67 .phys_io = 0x80000000,
68 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
69 .boot_params = 0xc0020000, 67 .boot_params = 0xc0020000,
70 .map_io = autcpu12_map_io, 68 .map_io = autcpu12_map_io,
71 .init_irq = clps711x_init_irq, 69 .init_irq = clps711x_init_irq,
diff --git a/arch/arm/mach-clps711x/cdb89712.c b/arch/arm/mach-clps711x/cdb89712.c
index 71a80b5b8ad6..5a1689d48793 100644
--- a/arch/arm/mach-clps711x/cdb89712.c
+++ b/arch/arm/mach-clps711x/cdb89712.c
@@ -55,8 +55,6 @@ static void __init cdb89712_map_io(void)
55 55
56MACHINE_START(CDB89712, "Cirrus-CDB89712") 56MACHINE_START(CDB89712, "Cirrus-CDB89712")
57 /* Maintainer: Ray Lehtiniemi */ 57 /* Maintainer: Ray Lehtiniemi */
58 .phys_io = 0x80000000,
59 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
60 .boot_params = 0xc0000100, 58 .boot_params = 0xc0000100,
61 .map_io = cdb89712_map_io, 59 .map_io = cdb89712_map_io,
62 .init_irq = clps711x_init_irq, 60 .init_irq = clps711x_init_irq,
diff --git a/arch/arm/mach-clps711x/ceiva.c b/arch/arm/mach-clps711x/ceiva.c
index 8ada20184978..16481cf3e931 100644
--- a/arch/arm/mach-clps711x/ceiva.c
+++ b/arch/arm/mach-clps711x/ceiva.c
@@ -56,8 +56,6 @@ static void __init ceiva_map_io(void)
56 56
57MACHINE_START(CEIVA, "CEIVA/Polaroid Photo MAX Digital Picture Frame") 57MACHINE_START(CEIVA, "CEIVA/Polaroid Photo MAX Digital Picture Frame")
58 /* Maintainer: Rob Scott */ 58 /* Maintainer: Rob Scott */
59 .phys_io = 0x80000000,
60 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
61 .boot_params = 0xc0000100, 59 .boot_params = 0xc0000100,
62 .map_io = ceiva_map_io, 60 .map_io = ceiva_map_io,
63 .init_irq = clps711x_init_irq, 61 .init_irq = clps711x_init_irq,
diff --git a/arch/arm/mach-clps711x/clep7312.c b/arch/arm/mach-clps711x/clep7312.c
index 3c3bf45039ff..67b5abb4a60a 100644
--- a/arch/arm/mach-clps711x/clep7312.c
+++ b/arch/arm/mach-clps711x/clep7312.c
@@ -37,8 +37,6 @@ fixup_clep7312(struct machine_desc *desc, struct tag *tags,
37 37
38MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312") 38MACHINE_START(CLEP7212, "Cirrus Logic 7212/7312")
39 /* Maintainer: Nobody */ 39 /* Maintainer: Nobody */
40 .phys_io = 0x80000000,
41 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
42 .boot_params = 0xc0000100, 40 .boot_params = 0xc0000100,
43 .fixup = fixup_clep7312, 41 .fixup = fixup_clep7312,
44 .map_io = clps711x_map_io, 42 .map_io = clps711x_map_io,
diff --git a/arch/arm/mach-clps711x/edb7211-arch.c b/arch/arm/mach-clps711x/edb7211-arch.c
index 4a7a2322979a..98ca5b2e940d 100644
--- a/arch/arm/mach-clps711x/edb7211-arch.c
+++ b/arch/arm/mach-clps711x/edb7211-arch.c
@@ -57,8 +57,6 @@ fixup_edb7211(struct machine_desc *desc, struct tag *tags,
57 57
58MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)") 58MACHINE_START(EDB7211, "CL-EDB7211 (EP7211 eval board)")
59 /* Maintainer: Jon McClintock */ 59 /* Maintainer: Jon McClintock */
60 .phys_io = 0x80000000,
61 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
62 .boot_params = 0xc0020100, /* 0xc0000000 - 0xc001ffff can be video RAM */ 60 .boot_params = 0xc0020100, /* 0xc0000000 - 0xc001ffff can be video RAM */
63 .fixup = fixup_edb7211, 61 .fixup = fixup_edb7211,
64 .map_io = edb7211_map_io, 62 .map_io = edb7211_map_io,
diff --git a/arch/arm/mach-clps711x/fortunet.c b/arch/arm/mach-clps711x/fortunet.c
index a696099aa4f8..b1cb479e71e9 100644
--- a/arch/arm/mach-clps711x/fortunet.c
+++ b/arch/arm/mach-clps711x/fortunet.c
@@ -75,8 +75,6 @@ fortunet_fixup(struct machine_desc *desc, struct tag *tags,
75 75
76MACHINE_START(FORTUNET, "ARM-FortuNet") 76MACHINE_START(FORTUNET, "ARM-FortuNet")
77 /* Maintainer: FortuNet Inc. */ 77 /* Maintainer: FortuNet Inc. */
78 .phys_io = 0x80000000,
79 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
80 .boot_params = 0x00000000, 78 .boot_params = 0x00000000,
81 .fixup = fortunet_fixup, 79 .fixup = fortunet_fixup,
82 .map_io = clps711x_map_io, 80 .map_io = clps711x_map_io,
diff --git a/arch/arm/mach-clps711x/include/mach/debug-macro.S b/arch/arm/mach-clps711x/include/mach/debug-macro.S
index 072cc6b61ba3..507c6873b7ee 100644
--- a/arch/arm/mach-clps711x/include/mach/debug-macro.S
+++ b/arch/arm/mach-clps711x/include/mach/debug-macro.S
@@ -14,16 +14,14 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <asm/hardware/clps7111.h> 15#include <asm/hardware/clps7111.h>
16 16
17 .macro addruart, rx, tmp 17 .macro addruart, rp, rv
18 mrc p15, 0, \rx, c1, c0
19 tst \rx, #1 @ MMU enabled?
20 moveq \rx, #CLPS7111_PHYS_BASE
21 movne \rx, #CLPS7111_VIRT_BASE
22#ifndef CONFIG_DEBUG_CLPS711X_UART2 18#ifndef CONFIG_DEBUG_CLPS711X_UART2
23 add \rx, \rx, #0x0000 @ UART1 19 mov \rp, #0x0000 @ UART1
24#else 20#else
25 add \rx, \rx, #0x1000 @ UART2 21 mov \rp, #0x1000 @ UART2
26#endif 22#endif
23 orr \rv, \rp, #CLPS7111_VIRT_BASE
24 orr \rp, \rp, #CLPS7111_PHYS_BASE
27 .endm 25 .endm
28 26
29 .macro senduart,rd,rx 27 .macro senduart,rd,rx
diff --git a/arch/arm/mach-clps711x/include/mach/vmalloc.h b/arch/arm/mach-clps711x/include/mach/vmalloc.h
index ea6cc7beff28..30b3a287ed88 100644
--- a/arch/arm/mach-clps711x/include/mach/vmalloc.h
+++ b/arch/arm/mach-clps711x/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END 0xd0000000
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index 0d94a30fd6fc..cefbce0480b9 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -89,8 +89,6 @@ static void __init p720t_map_io(void)
89 89
90MACHINE_START(P720T, "ARM-Prospector720T") 90MACHINE_START(P720T, "ARM-Prospector720T")
91 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 91 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
92 .phys_io = 0x80000000,
93 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
94 .boot_params = 0xc0000100, 92 .boot_params = 0xc0000100,
95 .fixup = fixup_p720t, 93 .fixup = fixup_p720t,
96 .map_io = p720t_map_io, 94 .map_io = p720t_map_io,
diff --git a/arch/arm/mach-cns3xxx/cns3420vb.c b/arch/arm/mach-cns3xxx/cns3420vb.c
index 9df8391fd78a..90fe9ab8591d 100644
--- a/arch/arm/mach-cns3xxx/cns3420vb.c
+++ b/arch/arm/mach-cns3xxx/cns3420vb.c
@@ -142,8 +142,6 @@ static void __init cns3420_map_io(void)
142} 142}
143 143
144MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board") 144MACHINE_START(CNS3420VB, "Cavium Networks CNS3420 Validation Board")
145 .phys_io = CNS3XXX_UART0_BASE,
146 .io_pg_offst = (CNS3XXX_UART0_BASE_VIRT >> 18) & 0xfffc,
147 .boot_params = 0x00000100, 145 .boot_params = 0x00000100,
148 .map_io = cns3420_map_io, 146 .map_io = cns3420_map_io,
149 .init_irq = cns3xxx_init_irq, 147 .init_irq = cns3xxx_init_irq,
diff --git a/arch/arm/mach-cns3xxx/include/mach/debug-macro.S b/arch/arm/mach-cns3xxx/include/mach/debug-macro.S
index d16ce7eb00e9..56d828634db5 100644
--- a/arch/arm/mach-cns3xxx/include/mach/debug-macro.S
+++ b/arch/arm/mach-cns3xxx/include/mach/debug-macro.S
@@ -10,12 +10,10 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13 .macro addruart,rx 13 .macro addruart,rp,rv
14 mrc p15, 0, \rx, c1, c0 14 mov \rp, #0x00009000
15 tst \rx, #1 @ MMU enabled? 15 orr \rv, \rp, #0xf0000000 @ virtual base
16 moveq \rx, #0x10000000 16 orr \rp, \rp, #0x10000000
17 movne \rx, #0xf0000000 @ virtual base
18 orr \rx, \rx, #0x00009000
19 .endm 17 .endm
20 18
21#include <asm/hardware/debug-pl01x.S> 19#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index c3994f341e49..7f3cdbfc0fbb 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -597,8 +597,6 @@ static void __init da830_evm_map_io(void)
597} 597}
598 598
599MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137 EVM") 599MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137 EVM")
600 .phys_io = IO_PHYS,
601 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
602 .boot_params = (DA8XX_DDR_BASE + 0x100), 600 .boot_params = (DA8XX_DDR_BASE + 0x100),
603 .map_io = da830_evm_map_io, 601 .map_io = da830_evm_map_io,
604 .init_irq = cp_intc_init, 602 .init_irq = cp_intc_init,
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index fdc2cc500fc6..b26f5cbfce3e 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -817,8 +817,6 @@ static void __init da850_evm_map_io(void)
817} 817}
818 818
819MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM") 819MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
820 .phys_io = IO_PHYS,
821 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
822 .boot_params = (DA8XX_DDR_BASE + 0x100), 820 .boot_params = (DA8XX_DDR_BASE + 0x100),
823 .map_io = da850_evm_map_io, 821 .map_io = da850_evm_map_io,
824 .init_irq = cp_intc_init, 822 .init_irq = cp_intc_init,
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index a3191015efee..6e7cad13352c 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -351,8 +351,6 @@ static __init void dm355_evm_init(void)
351} 351}
352 352
353MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM") 353MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM")
354 .phys_io = IO_PHYS,
355 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
356 .boot_params = (0x80000100), 354 .boot_params = (0x80000100),
357 .map_io = dm355_evm_map_io, 355 .map_io = dm355_evm_map_io,
358 .init_irq = davinci_irq_init, 356 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index f1d8132cf0c3..543f9911b281 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -270,8 +270,6 @@ static __init void dm355_leopard_init(void)
270} 270}
271 271
272MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard") 272MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard")
273 .phys_io = IO_PHYS,
274 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
275 .boot_params = (0x80000100), 273 .boot_params = (0x80000100),
276 .map_io = dm355_leopard_map_io, 274 .map_io = dm355_leopard_map_io,
277 .init_irq = davinci_irq_init, 275 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 84acef1d0b3d..944a0cbaf5cb 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -613,8 +613,6 @@ static __init void dm365_evm_init(void)
613} 613}
614 614
615MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM") 615MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
616 .phys_io = IO_PHYS,
617 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
618 .boot_params = (0x80000100), 616 .boot_params = (0x80000100),
619 .map_io = dm365_evm_map_io, 617 .map_io = dm365_evm_map_io,
620 .init_irq = davinci_irq_init, 618 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 34c8b418cd72..d59fba15ba8d 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -706,8 +706,6 @@ static __init void davinci_evm_init(void)
706 706
707MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM") 707MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
708 /* Maintainer: MontaVista Software <source@mvista.com> */ 708 /* Maintainer: MontaVista Software <source@mvista.com> */
709 .phys_io = IO_PHYS,
710 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
711 .boot_params = (DAVINCI_DDR_BASE + 0x100), 709 .boot_params = (DAVINCI_DDR_BASE + 0x100),
712 .map_io = davinci_evm_map_io, 710 .map_io = davinci_evm_map_io,
713 .init_irq = davinci_irq_init, 711 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 4502f346b2b0..6890488fb92b 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -786,8 +786,6 @@ void __init dm646x_board_setup_refclk(struct clk *clk)
786} 786}
787 787
788MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM") 788MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
789 .phys_io = IO_PHYS,
790 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
791 .boot_params = (0x80000100), 789 .boot_params = (0x80000100),
792 .map_io = davinci_map_io, 790 .map_io = davinci_map_io,
793 .init_irq = davinci_irq_init, 791 .init_irq = davinci_irq_init,
@@ -796,8 +794,6 @@ MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
796MACHINE_END 794MACHINE_END
797 795
798MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM") 796MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM")
799 .phys_io = IO_PHYS,
800 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
801 .boot_params = (0x80000100), 797 .boot_params = (0x80000100),
802 .map_io = davinci_map_io, 798 .map_io = davinci_map_io,
803 .init_irq = davinci_irq_init, 799 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 4c30e929bbf9..a4def889275c 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -275,8 +275,6 @@ static __init void davinci_ntosd2_init(void)
275 275
276MACHINE_START(NEUROS_OSD2, "Neuros OSD2") 276MACHINE_START(NEUROS_OSD2, "Neuros OSD2")
277 /* Maintainer: Neuros Technologies <neuros@groups.google.com> */ 277 /* Maintainer: Neuros Technologies <neuros@groups.google.com> */
278 .phys_io = IO_PHYS,
279 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
280 .boot_params = (DAVINCI_DDR_BASE + 0x100), 278 .boot_params = (DAVINCI_DDR_BASE + 0x100),
281 .map_io = davinci_ntosd2_map_io, 279 .map_io = davinci_ntosd2_map_io,
282 .init_irq = davinci_irq_init, 280 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index 23e664a1a802..9bdf8aafcc84 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -154,8 +154,6 @@ static __init void davinci_sffsdr_init(void)
154 154
155MACHINE_START(SFFSDR, "Lyrtech SFFSDR") 155MACHINE_START(SFFSDR, "Lyrtech SFFSDR")
156 /* Maintainer: Hugo Villeneuve hugo.villeneuve@lyrtech.com */ 156 /* Maintainer: Hugo Villeneuve hugo.villeneuve@lyrtech.com */
157 .phys_io = IO_PHYS,
158 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
159 .boot_params = (DAVINCI_DDR_BASE + 0x100), 157 .boot_params = (DAVINCI_DDR_BASE + 0x100),
160 .map_io = davinci_sffsdr_map_io, 158 .map_io = davinci_sffsdr_map_io,
161 .init_irq = davinci_irq_init, 159 .init_irq = davinci_irq_init,
diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index fe2a9d9c8bb7..b4de35b78904 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -164,8 +164,6 @@ console_initcall(tnetv107x_evm_console_init);
164#endif 164#endif
165 165
166MACHINE_START(TNETV107X, "TNETV107X EVM") 166MACHINE_START(TNETV107X, "TNETV107X EVM")
167 .phys_io = TNETV107X_IO_BASE,
168 .io_pg_offst = (TNETV107X_IO_VIRT >> 18) & 0xfffc,
169 .boot_params = (TNETV107X_DDR_BASE + 0x100), 167 .boot_params = (TNETV107X_DDR_BASE + 0x100),
170 .map_io = tnetv107x_init, 168 .map_io = tnetv107x_init,
171 .init_irq = cp_intc_init, 169 .init_irq = cp_intc_init,
diff --git a/arch/arm/mach-davinci/include/mach/debug-macro.S b/arch/arm/mach-davinci/include/mach/debug-macro.S
index f761dfdb8689..9f1befc5ac38 100644
--- a/arch/arm/mach-davinci/include/mach/debug-macro.S
+++ b/arch/arm/mach-davinci/include/mach/debug-macro.S
@@ -29,35 +29,39 @@ davinci_uart_phys: .word 0
29davinci_uart_virt: .word 0 29davinci_uart_virt: .word 0
30 .popsection 30 .popsection
31 31
32 .macro addruart, rx, tmp 32 .macro addruart, rp, rv
33 33
34 /* Use davinci_uart_phys/virt if already configured */ 34 /* Use davinci_uart_phys/virt if already configured */
3510: mrc p15, 0, \rx, c1, c0 3510: mrc p15, 0, \rp, c1, c0
36 tst \rx, #1 @ MMU enabled? 36 tst \rp, #1 @ MMU enabled?
37 ldreq \rx, =__virt_to_phys(davinci_uart_phys) 37 ldreq \rp, =__virt_to_phys(davinci_uart_phys)
38 ldrne \rx, =davinci_uart_virt 38 ldrne \rp, =davinci_uart_phys
39 ldr \rx, [\rx] 39 add \rv, \rp, #4 @ davinci_uart_virt
40 cmp \rx, #0 @ is port configured? 40 ldr \rp, [\rp, #0]
41 ldr \rv, [\rv, #0]
42 cmp \rp, #0 @ is port configured?
43 cmpne \rv, #0
41 bne 99f @ already configured 44 bne 99f @ already configured
42 45
43 mrc p15, 0, \rx, c1, c0 46 /* Check the debug UART address set in uncompress.h */
44 tst \rx, #1 @ MMU enabled? 47 mrc p15, 0, \rp, c1, c0
48 tst \rp, #1 @ MMU enabled?
45 49
46 /* Copy uart phys address from decompressor uart info */ 50 /* Copy uart phys address from decompressor uart info */
47 ldreq \tmp, =__virt_to_phys(davinci_uart_phys) 51 ldreq \rv, =__virt_to_phys(davinci_uart_phys)
48 ldrne \tmp, =davinci_uart_phys 52 ldrne \rv, =davinci_uart_phys
49 ldreq \rx, =DAVINCI_UART_INFO 53 ldreq \rp, =DAVINCI_UART_INFO
50 ldrne \rx, =__phys_to_virt(DAVINCI_UART_INFO) 54 ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
51 ldr \rx, [\rx, #0] 55 ldr \rp, [\rp, #0]
52 str \rx, [\tmp] 56 str \rp, [\rv]
53 57
54 /* Copy uart virt address from decompressor uart info */ 58 /* Copy uart virt address from decompressor uart info */
55 ldreq \tmp, =__virt_to_phys(davinci_uart_virt) 59 ldreq \rv, =__virt_to_phys(davinci_uart_virt)
56 ldrne \tmp, =davinci_uart_virt 60 ldrne \rv, =davinci_uart_virt
57 ldreq \rx, =DAVINCI_UART_INFO 61 ldreq \rp, =DAVINCI_UART_INFO
58 ldrne \rx, =__phys_to_virt(DAVINCI_UART_INFO) 62 ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
59 ldr \rx, [\rx, #4] 63 ldr \rp, [\rp, #4]
60 str \rx, [\tmp] 64 str \rp, [\rv]
61 65
62 b 10b 66 b 10b
6399: 6799:
diff --git a/arch/arm/mach-dove/dove-db-setup.c b/arch/arm/mach-dove/dove-db-setup.c
index bef70460fbc6..95925aa76dd9 100644
--- a/arch/arm/mach-dove/dove-db-setup.c
+++ b/arch/arm/mach-dove/dove-db-setup.c
@@ -94,8 +94,6 @@ static void __init dove_db_init(void)
94} 94}
95 95
96MACHINE_START(DOVE_DB, "Marvell DB-MV88AP510-BP Development Board") 96MACHINE_START(DOVE_DB, "Marvell DB-MV88AP510-BP Development Board")
97 .phys_io = DOVE_SB_REGS_PHYS_BASE,
98 .io_pg_offst = ((DOVE_SB_REGS_VIRT_BASE) >> 18) & 0xfffc,
99 .boot_params = 0x00000100, 97 .boot_params = 0x00000100,
100 .init_machine = dove_db_init, 98 .init_machine = dove_db_init,
101 .map_io = dove_map_io, 99 .map_io = dove_map_io,
diff --git a/arch/arm/mach-dove/include/mach/debug-macro.S b/arch/arm/mach-dove/include/mach/debug-macro.S
index 1521d13f1d14..da8bf2bad3b1 100644
--- a/arch/arm/mach-dove/include/mach/debug-macro.S
+++ b/arch/arm/mach-dove/include/mach/debug-macro.S
@@ -8,12 +8,11 @@
8 8
9#include <mach/bridge-regs.h> 9#include <mach/bridge-regs.h>
10 10
11 .macro addruart, rx, tmp 11 .macro addruart, rp, rv
12 mrc p15, 0, \rx, c1, c0 12 ldr \rp, =DOVE_SB_REGS_PHYS_BASE
13 tst \rx, #1 @ MMU enabled? 13 ldr \rv, =DOVE_SB_REGS_VIRT_BASE
14 ldreq \rx, =DOVE_SB_REGS_PHYS_BASE 14 orr \rp, \rp, #0x00012000
15 ldrne \rx, =DOVE_SB_REGS_VIRT_BASE 15 orr \rv, \rv, #0x00012000
16 orr \rx, \rx, #0x00012000
17 .endm 16 .endm
18 17
19#define UART_SHIFT 2 18#define UART_SHIFT 2
diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
index c7bc7fbb11a6..5df4099fc14f 100644
--- a/arch/arm/mach-ebsa110/core.c
+++ b/arch/arm/mach-ebsa110/core.c
@@ -280,8 +280,6 @@ arch_initcall(ebsa110_init);
280 280
281MACHINE_START(EBSA110, "EBSA110") 281MACHINE_START(EBSA110, "EBSA110")
282 /* Maintainer: Russell King */ 282 /* Maintainer: Russell King */
283 .phys_io = 0xe0000000,
284 .io_pg_offst = ((0xe0000000) >> 18) & 0xfffc,
285 .boot_params = 0x00000400, 283 .boot_params = 0x00000400,
286 .reserve_lp0 = 1, 284 .reserve_lp0 = 1,
287 .reserve_lp2 = 1, 285 .reserve_lp2 = 1,
diff --git a/arch/arm/mach-ebsa110/include/mach/debug-macro.S b/arch/arm/mach-ebsa110/include/mach/debug-macro.S
index ebbd89f0e6c0..7ef5690fd08c 100644
--- a/arch/arm/mach-ebsa110/include/mach/debug-macro.S
+++ b/arch/arm/mach-ebsa110/include/mach/debug-macro.S
@@ -11,9 +11,10 @@
11 * 11 *
12**/ 12**/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mov \rx, #0xf0000000 15 mov \rp, #0xf0000000
16 orr \rx, \rx, #0x00000be0 16 orr \rp, \rp, #0x00000be0
17 mov \rp, \rv
17 .endm 18 .endm
18 19
19#define UART_SHIFT 2 20#define UART_SHIFT 2
diff --git a/arch/arm/mach-ebsa110/include/mach/vmalloc.h b/arch/arm/mach-ebsa110/include/mach/vmalloc.h
index 9b44c19e95ec..60bde56fba4c 100644
--- a/arch/arm/mach-ebsa110/include/mach/vmalloc.h
+++ b/arch/arm/mach-ebsa110/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define VMALLOC_END (PAGE_OFFSET + 0x1f000000) 10#define VMALLOC_END 0xdf000000
diff --git a/arch/arm/mach-ep93xx/adssphere.c b/arch/arm/mach-ep93xx/adssphere.c
index f744f676783f..61b98ce4b673 100644
--- a/arch/arm/mach-ep93xx/adssphere.c
+++ b/arch/arm/mach-ep93xx/adssphere.c
@@ -33,8 +33,6 @@ static void __init adssphere_init_machine(void)
33 33
34MACHINE_START(ADSSPHERE, "ADS Sphere board") 34MACHINE_START(ADSSPHERE, "ADS Sphere board")
35 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 35 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
36 .phys_io = EP93XX_APB_PHYS_BASE,
37 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
38 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 36 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
39 .map_io = ep93xx_map_io, 37 .map_io = ep93xx_map_io,
40 .init_irq = ep93xx_init_irq, 38 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/dma-m2p.c b/arch/arm/mach-ep93xx/dma-m2p.c
index 8904ca4e2e24..a696d354b1f8 100644
--- a/arch/arm/mach-ep93xx/dma-m2p.c
+++ b/arch/arm/mach-ep93xx/dma-m2p.c
@@ -276,7 +276,7 @@ static void channel_disable(struct m2p_channel *ch)
276 v &= ~(M2P_CONTROL_STALL_IRQ_EN | M2P_CONTROL_NFB_IRQ_EN); 276 v &= ~(M2P_CONTROL_STALL_IRQ_EN | M2P_CONTROL_NFB_IRQ_EN);
277 m2p_set_control(ch, v); 277 m2p_set_control(ch, v);
278 278
279 while (m2p_channel_state(ch) == STATE_ON) 279 while (m2p_channel_state(ch) >= STATE_ON)
280 cpu_relax(); 280 cpu_relax();
281 281
282 m2p_set_control(ch, 0x0); 282 m2p_set_control(ch, 0x0);
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index c2ce9034ba87..4b0431652131 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -124,8 +124,6 @@ static void __init edb93xx_init_machine(void)
124#ifdef CONFIG_MACH_EDB9301 124#ifdef CONFIG_MACH_EDB9301
125MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board") 125MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
126 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */ 126 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
127 .phys_io = EP93XX_APB_PHYS_BASE,
128 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
129 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 127 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
130 .map_io = ep93xx_map_io, 128 .map_io = ep93xx_map_io,
131 .init_irq = ep93xx_init_irq, 129 .init_irq = ep93xx_init_irq,
@@ -137,8 +135,6 @@ MACHINE_END
137#ifdef CONFIG_MACH_EDB9302 135#ifdef CONFIG_MACH_EDB9302
138MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board") 136MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
139 /* Maintainer: George Kashperko <george@chas.com.ua> */ 137 /* Maintainer: George Kashperko <george@chas.com.ua> */
140 .phys_io = EP93XX_APB_PHYS_BASE,
141 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
142 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 138 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
143 .map_io = ep93xx_map_io, 139 .map_io = ep93xx_map_io,
144 .init_irq = ep93xx_init_irq, 140 .init_irq = ep93xx_init_irq,
@@ -150,8 +146,6 @@ MACHINE_END
150#ifdef CONFIG_MACH_EDB9302A 146#ifdef CONFIG_MACH_EDB9302A
151MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board") 147MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
152 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 148 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
153 .phys_io = EP93XX_APB_PHYS_BASE,
154 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
155 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, 149 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
156 .map_io = ep93xx_map_io, 150 .map_io = ep93xx_map_io,
157 .init_irq = ep93xx_init_irq, 151 .init_irq = ep93xx_init_irq,
@@ -163,8 +157,6 @@ MACHINE_END
163#ifdef CONFIG_MACH_EDB9307 157#ifdef CONFIG_MACH_EDB9307
164MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board") 158MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
165 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */ 159 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
166 .phys_io = EP93XX_APB_PHYS_BASE,
167 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
168 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 160 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
169 .map_io = ep93xx_map_io, 161 .map_io = ep93xx_map_io,
170 .init_irq = ep93xx_init_irq, 162 .init_irq = ep93xx_init_irq,
@@ -176,8 +168,6 @@ MACHINE_END
176#ifdef CONFIG_MACH_EDB9307A 168#ifdef CONFIG_MACH_EDB9307A
177MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board") 169MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
178 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */ 170 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
179 .phys_io = EP93XX_APB_PHYS_BASE,
180 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
181 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, 171 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
182 .map_io = ep93xx_map_io, 172 .map_io = ep93xx_map_io,
183 .init_irq = ep93xx_init_irq, 173 .init_irq = ep93xx_init_irq,
@@ -189,8 +179,6 @@ MACHINE_END
189#ifdef CONFIG_MACH_EDB9312 179#ifdef CONFIG_MACH_EDB9312
190MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board") 180MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
191 /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */ 181 /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
192 .phys_io = EP93XX_APB_PHYS_BASE,
193 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
194 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 182 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
195 .map_io = ep93xx_map_io, 183 .map_io = ep93xx_map_io,
196 .init_irq = ep93xx_init_irq, 184 .init_irq = ep93xx_init_irq,
@@ -202,8 +190,6 @@ MACHINE_END
202#ifdef CONFIG_MACH_EDB9315 190#ifdef CONFIG_MACH_EDB9315
203MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board") 191MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
204 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 192 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
205 .phys_io = EP93XX_APB_PHYS_BASE,
206 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
207 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 193 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
208 .map_io = ep93xx_map_io, 194 .map_io = ep93xx_map_io,
209 .init_irq = ep93xx_init_irq, 195 .init_irq = ep93xx_init_irq,
@@ -215,8 +201,6 @@ MACHINE_END
215#ifdef CONFIG_MACH_EDB9315A 201#ifdef CONFIG_MACH_EDB9315A
216MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board") 202MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
217 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 203 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
218 .phys_io = EP93XX_APB_PHYS_BASE,
219 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
220 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, 204 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
221 .map_io = ep93xx_map_io, 205 .map_io = ep93xx_map_io,
222 .init_irq = ep93xx_init_irq, 206 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
index d97168c0ba33..9bd3152bff9a 100644
--- a/arch/arm/mach-ep93xx/gesbc9312.c
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -33,8 +33,6 @@ static void __init gesbc9312_init_machine(void)
33 33
34MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx") 34MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx")
35 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 35 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
36 .phys_io = EP93XX_APB_PHYS_BASE,
37 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
38 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 36 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
39 .map_io = ep93xx_map_io, 37 .map_io = ep93xx_map_io,
40 .init_irq = ep93xx_init_irq, 38 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/include/mach/debug-macro.S b/arch/arm/mach-ep93xx/include/mach/debug-macro.S
index 5cd22444e223..b25bc9076367 100644
--- a/arch/arm/mach-ep93xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-ep93xx/include/mach/debug-macro.S
@@ -11,12 +11,11 @@
11 */ 11 */
12#include <mach/ep93xx-regs.h> 12#include <mach/ep93xx-regs.h>
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 ldr \rp, =EP93XX_APB_PHYS_BASE @ Physical base
16 tst \rx, #1 @ MMU enabled? 16 ldr \rv, =EP93XX_APB_VIRT_BASE @ virtual base
17 ldreq \rx, =EP93XX_APB_PHYS_BASE @ Physical base 17 orr \rp, \rp, #0x000c0000
18 ldrne \rx, =EP93XX_APB_VIRT_BASE @ virtual base 18 orr \rv, \rv, #0x000c0000
19 orr \rx, \rx, #0x000c0000
20 .endm 19 .endm
21 20
22#include <asm/hardware/debug-pl01x.S> 21#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-ep93xx/micro9.c b/arch/arm/mach-ep93xx/micro9.c
index 2ba776320a82..7adea6258efe 100644
--- a/arch/arm/mach-ep93xx/micro9.c
+++ b/arch/arm/mach-ep93xx/micro9.c
@@ -77,8 +77,6 @@ static void __init micro9_init_machine(void)
77#ifdef CONFIG_MACH_MICRO9H 77#ifdef CONFIG_MACH_MICRO9H
78MACHINE_START(MICRO9, "Contec Micro9-High") 78MACHINE_START(MICRO9, "Contec Micro9-High")
79 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */ 79 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
80 .phys_io = EP93XX_APB_PHYS_BASE,
81 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
82 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 80 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
83 .map_io = ep93xx_map_io, 81 .map_io = ep93xx_map_io,
84 .init_irq = ep93xx_init_irq, 82 .init_irq = ep93xx_init_irq,
@@ -90,8 +88,6 @@ MACHINE_END
90#ifdef CONFIG_MACH_MICRO9M 88#ifdef CONFIG_MACH_MICRO9M
91MACHINE_START(MICRO9M, "Contec Micro9-Mid") 89MACHINE_START(MICRO9M, "Contec Micro9-Mid")
92 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */ 90 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
93 .phys_io = EP93XX_APB_PHYS_BASE,
94 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
95 .boot_params = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100, 91 .boot_params = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100,
96 .map_io = ep93xx_map_io, 92 .map_io = ep93xx_map_io,
97 .init_irq = ep93xx_init_irq, 93 .init_irq = ep93xx_init_irq,
@@ -103,8 +99,6 @@ MACHINE_END
103#ifdef CONFIG_MACH_MICRO9L 99#ifdef CONFIG_MACH_MICRO9L
104MACHINE_START(MICRO9L, "Contec Micro9-Lite") 100MACHINE_START(MICRO9L, "Contec Micro9-Lite")
105 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */ 101 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
106 .phys_io = EP93XX_APB_PHYS_BASE,
107 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
108 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 102 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
109 .map_io = ep93xx_map_io, 103 .map_io = ep93xx_map_io,
110 .init_irq = ep93xx_init_irq, 104 .init_irq = ep93xx_init_irq,
@@ -116,8 +110,6 @@ MACHINE_END
116#ifdef CONFIG_MACH_MICRO9S 110#ifdef CONFIG_MACH_MICRO9S
117MACHINE_START(MICRO9S, "Contec Micro9-Slim") 111MACHINE_START(MICRO9S, "Contec Micro9-Slim")
118 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */ 112 /* Maintainer: Hubert Feurstein <hubert.feurstein@contec.at> */
119 .phys_io = EP93XX_APB_PHYS_BASE,
120 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
121 .boot_params = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100, 113 .boot_params = EP93XX_SDCE3_PHYS_BASE_ASYNC + 0x100,
122 .map_io = ep93xx_map_io, 114 .map_io = ep93xx_map_io,
123 .init_irq = ep93xx_init_irq, 115 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index 5dded5884133..f22ce8db7947 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -65,8 +65,6 @@ static void __init simone_init_machine(void)
65 65
66MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board") 66MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board")
67/* Maintainer: Ryan Mallon <ryan@bluewatersys.com> */ 67/* Maintainer: Ryan Mallon <ryan@bluewatersys.com> */
68 .phys_io = EP93XX_APB_PHYS_BASE,
69 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
70 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, 68 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
71 .map_io = ep93xx_map_io, 69 .map_io = ep93xx_map_io,
72 .init_irq = ep93xx_init_irq, 70 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/snappercl15.c b/arch/arm/mach-ep93xx/snappercl15.c
index a12c89301297..ac601fe2b448 100644
--- a/arch/arm/mach-ep93xx/snappercl15.c
+++ b/arch/arm/mach-ep93xx/snappercl15.c
@@ -163,8 +163,6 @@ static void __init snappercl15_init_machine(void)
163 163
164MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15") 164MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")
165 /* Maintainer: Ryan Mallon <ryan@bluewatersys.com> */ 165 /* Maintainer: Ryan Mallon <ryan@bluewatersys.com> */
166 .phys_io = EP93XX_APB_PHYS_BASE,
167 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
168 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100, 166 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
169 .map_io = ep93xx_map_io, 167 .map_io = ep93xx_map_io,
170 .init_irq = ep93xx_init_irq, 168 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 93aeab8af705..c2d2cf40ead9 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -257,8 +257,6 @@ static void __init ts72xx_init_machine(void)
257 257
258MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC") 258MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
259 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 259 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
260 .phys_io = EP93XX_APB_PHYS_BASE,
261 .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
262 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100, 260 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
263 .map_io = ts72xx_map_io, 261 .map_io = ts72xx_map_io,
264 .init_irq = ep93xx_init_irq, 262 .init_irq = ep93xx_init_irq,
diff --git a/arch/arm/mach-footbridge/cats-hw.c b/arch/arm/mach-footbridge/cats-hw.c
index 1b996b26d2e0..5b1a8db779be 100644
--- a/arch/arm/mach-footbridge/cats-hw.c
+++ b/arch/arm/mach-footbridge/cats-hw.c
@@ -86,8 +86,6 @@ fixup_cats(struct machine_desc *desc, struct tag *tags,
86 86
87MACHINE_START(CATS, "Chalice-CATS") 87MACHINE_START(CATS, "Chalice-CATS")
88 /* Maintainer: Philip Blundell */ 88 /* Maintainer: Philip Blundell */
89 .phys_io = DC21285_ARMCSR_BASE,
90 .io_pg_offst = ((0xfe000000) >> 18) & 0xfffc,
91 .boot_params = 0x00000100, 89 .boot_params = 0x00000100,
92 .soft_reboot = 1, 90 .soft_reboot = 1,
93 .fixup = fixup_cats, 91 .fixup = fixup_cats,
diff --git a/arch/arm/mach-footbridge/ebsa285.c b/arch/arm/mach-footbridge/ebsa285.c
index 30040fd588cc..2ef69ff44ba8 100644
--- a/arch/arm/mach-footbridge/ebsa285.c
+++ b/arch/arm/mach-footbridge/ebsa285.c
@@ -15,8 +15,6 @@
15 15
16MACHINE_START(EBSA285, "EBSA285") 16MACHINE_START(EBSA285, "EBSA285")
17 /* Maintainer: Russell King */ 17 /* Maintainer: Russell King */
18 .phys_io = DC21285_ARMCSR_BASE,
19 .io_pg_offst = ((0xfe000000) >> 18) & 0xfffc,
20 .boot_params = 0x00000100, 18 .boot_params = 0x00000100,
21 .video_start = 0x000a0000, 19 .video_start = 0x000a0000,
22 .video_end = 0x000bffff, 20 .video_end = 0x000bffff,
diff --git a/arch/arm/mach-footbridge/include/mach/debug-macro.S b/arch/arm/mach-footbridge/include/mach/debug-macro.S
index 60dda1318f22..3c9e0c40c679 100644
--- a/arch/arm/mach-footbridge/include/mach/debug-macro.S
+++ b/arch/arm/mach-footbridge/include/mach/debug-macro.S
@@ -15,12 +15,10 @@
15 15
16#ifndef CONFIG_DEBUG_DC21285_PORT 16#ifndef CONFIG_DEBUG_DC21285_PORT
17 /* For NetWinder debugging */ 17 /* For NetWinder debugging */
18 .macro addruart, rx, tmp 18 .macro addruart, rp, rv
19 mrc p15, 0, \rx, c1, c0 19 mov \rp, #0x000003f8
20 tst \rx, #1 @ MMU enabled? 20 orr \rv, \rp, #0x7c000000 @ physical
21 moveq \rx, #0x7c000000 @ physical 21 orr \rp, \rp, #0xff000000 @ virtual
22 movne \rx, #0xff000000 @ virtual
23 orr \rx, \rx, #0x000003f8
24 .endm 22 .endm
25 23
26#define UART_SHIFT 0 24#define UART_SHIFT 0
@@ -32,14 +30,14 @@
32 .equ dc21285_high, ARMCSR_BASE & 0xff000000 30 .equ dc21285_high, ARMCSR_BASE & 0xff000000
33 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff 31 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff
34 32
35 .macro addruart, rx, tmp 33 .macro addruart, rp, rv
36 mrc p15, 0, \rx, c1, c0
37 tst \rx, #1 @ MMU enabled?
38 moveq \rx, #0x42000000
39 movne \rx, #dc21285_high
40 .if dc21285_low 34 .if dc21285_low
41 orrne \rx, \rx, #dc21285_low 35 mov \rp, #dc21285_low
36 .else
37 mov \rp, #0
42 .endif 38 .endif
39 orr \rv, \rp, #0x42000000
40 orr \rp, \rp, #dc21285_high
43 .endm 41 .endm
44 42
45 .macro senduart,rd,rx 43 .macro senduart,rd,rx
diff --git a/arch/arm/mach-footbridge/include/mach/vmalloc.h b/arch/arm/mach-footbridge/include/mach/vmalloc.h
index d0958d860a3c..0ffbb7c85e59 100644
--- a/arch/arm/mach-footbridge/include/mach/vmalloc.h
+++ b/arch/arm/mach-footbridge/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 */ 7 */
8 8
9 9
10#define VMALLOC_END (PAGE_OFFSET + 0x30000000) 10#define VMALLOC_END 0xf0000000
diff --git a/arch/arm/mach-footbridge/netwinder-hw.c b/arch/arm/mach-footbridge/netwinder-hw.c
index ac7ffa6fc413..06e514f372d0 100644
--- a/arch/arm/mach-footbridge/netwinder-hw.c
+++ b/arch/arm/mach-footbridge/netwinder-hw.c
@@ -648,8 +648,6 @@ fixup_netwinder(struct machine_desc *desc, struct tag *tags,
648 648
649MACHINE_START(NETWINDER, "Rebel-NetWinder") 649MACHINE_START(NETWINDER, "Rebel-NetWinder")
650 /* Maintainer: Russell King/Rebel.com */ 650 /* Maintainer: Russell King/Rebel.com */
651 .phys_io = DC21285_ARMCSR_BASE,
652 .io_pg_offst = ((0xfe000000) >> 18) & 0xfffc,
653 .boot_params = 0x00000100, 651 .boot_params = 0x00000100,
654 .video_start = 0x000a0000, 652 .video_start = 0x000a0000,
655 .video_end = 0x000bffff, 653 .video_end = 0x000bffff,
diff --git a/arch/arm/mach-footbridge/personal.c b/arch/arm/mach-footbridge/personal.c
index e2c9f0690b16..3285e91ca8c1 100644
--- a/arch/arm/mach-footbridge/personal.c
+++ b/arch/arm/mach-footbridge/personal.c
@@ -15,8 +15,6 @@
15 15
16MACHINE_START(PERSONAL_SERVER, "Compaq-PersonalServer") 16MACHINE_START(PERSONAL_SERVER, "Compaq-PersonalServer")
17 /* Maintainer: Jamey Hicks / George France */ 17 /* Maintainer: Jamey Hicks / George France */
18 .phys_io = DC21285_ARMCSR_BASE,
19 .io_pg_offst = ((0xfe000000) >> 18) & 0xfffc,
20 .boot_params = 0x00000100, 18 .boot_params = 0x00000100,
21 .map_io = footbridge_map_io, 19 .map_io = footbridge_map_io,
22 .init_irq = footbridge_init_irq, 20 .init_irq = footbridge_init_irq,
diff --git a/arch/arm/mach-gemini/board-nas4220b.c b/arch/arm/mach-gemini/board-nas4220b.c
index 01f1d6daab44..2ba096de0034 100644
--- a/arch/arm/mach-gemini/board-nas4220b.c
+++ b/arch/arm/mach-gemini/board-nas4220b.c
@@ -101,8 +101,6 @@ static void __init ib4220b_init(void)
101} 101}
102 102
103MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B") 103MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")
104 .phys_io = 0x7fffc000,
105 .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
106 .boot_params = 0x100, 104 .boot_params = 0x100,
107 .map_io = gemini_map_io, 105 .map_io = gemini_map_io,
108 .init_irq = gemini_init_irq, 106 .init_irq = gemini_init_irq,
diff --git a/arch/arm/mach-gemini/board-rut1xx.c b/arch/arm/mach-gemini/board-rut1xx.c
index e0de968e32a6..a9a0d8b01942 100644
--- a/arch/arm/mach-gemini/board-rut1xx.c
+++ b/arch/arm/mach-gemini/board-rut1xx.c
@@ -85,8 +85,6 @@ static void __init rut1xx_init(void)
85} 85}
86 86
87MACHINE_START(RUT100, "Teltonika RUT100") 87MACHINE_START(RUT100, "Teltonika RUT100")
88 .phys_io = 0x7fffc000,
89 .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
90 .boot_params = 0x100, 88 .boot_params = 0x100,
91 .map_io = gemini_map_io, 89 .map_io = gemini_map_io,
92 .init_irq = gemini_init_irq, 90 .init_irq = gemini_init_irq,
diff --git a/arch/arm/mach-gemini/board-wbd111.c b/arch/arm/mach-gemini/board-wbd111.c
index 36538c15b3c4..8b88d50d4337 100644
--- a/arch/arm/mach-gemini/board-wbd111.c
+++ b/arch/arm/mach-gemini/board-wbd111.c
@@ -133,8 +133,6 @@ static void __init wbd111_init(void)
133} 133}
134 134
135MACHINE_START(WBD111, "Wiliboard WBD-111") 135MACHINE_START(WBD111, "Wiliboard WBD-111")
136 .phys_io = 0x7fffc000,
137 .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
138 .boot_params = 0x100, 136 .boot_params = 0x100,
139 .map_io = gemini_map_io, 137 .map_io = gemini_map_io,
140 .init_irq = gemini_init_irq, 138 .init_irq = gemini_init_irq,
diff --git a/arch/arm/mach-gemini/board-wbd222.c b/arch/arm/mach-gemini/board-wbd222.c
index ece8b4c65110..1eebcecd1c33 100644
--- a/arch/arm/mach-gemini/board-wbd222.c
+++ b/arch/arm/mach-gemini/board-wbd222.c
@@ -133,8 +133,6 @@ static void __init wbd222_init(void)
133} 133}
134 134
135MACHINE_START(WBD222, "Wiliboard WBD-222") 135MACHINE_START(WBD222, "Wiliboard WBD-222")
136 .phys_io = 0x7fffc000,
137 .io_pg_offst = ((0xffffc000) >> 18) & 0xfffc,
138 .boot_params = 0x100, 136 .boot_params = 0x100,
139 .map_io = gemini_map_io, 137 .map_io = gemini_map_io,
140 .init_irq = gemini_init_irq, 138 .init_irq = gemini_init_irq,
diff --git a/arch/arm/mach-gemini/include/mach/debug-macro.S b/arch/arm/mach-gemini/include/mach/debug-macro.S
index ad477047069d..f40e006d296e 100644
--- a/arch/arm/mach-gemini/include/mach/debug-macro.S
+++ b/arch/arm/mach-gemini/include/mach/debug-macro.S
@@ -11,11 +11,9 @@
11 */ 11 */
12#include <mach/hardware.h> 12#include <mach/hardware.h>
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 ldr \rp, =GEMINI_UART_BASE @ physical
16 tst \rx, #1 @ MMU enabled? 16 ldr \rv, =IO_ADDRESS(GEMINI_UART_BASE) @ virtual
17 ldreq \rx, =GEMINI_UART_BASE @ physical
18 ldrne \rx, =IO_ADDRESS(GEMINI_UART_BASE) @ virtual
19 .endm 17 .endm
20 18
21#define UART_SHIFT 2 19#define UART_SHIFT 2
diff --git a/arch/arm/mach-h720x/h7201-eval.c b/arch/arm/mach-h720x/h7201-eval.c
index 78be457dc324..79f0b896e446 100644
--- a/arch/arm/mach-h720x/h7201-eval.c
+++ b/arch/arm/mach-h720x/h7201-eval.c
@@ -30,8 +30,6 @@
30 30
31MACHINE_START(H7201, "Hynix GMS30C7201") 31MACHINE_START(H7201, "Hynix GMS30C7201")
32 /* Maintainer: Robert Schwebel, Pengutronix */ 32 /* Maintainer: Robert Schwebel, Pengutronix */
33 .phys_io = 0x80000000,
34 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
35 .boot_params = 0xc0001000, 33 .boot_params = 0xc0001000,
36 .map_io = h720x_map_io, 34 .map_io = h720x_map_io,
37 .init_irq = h720x_init_irq, 35 .init_irq = h720x_init_irq,
diff --git a/arch/arm/mach-h720x/h7202-eval.c b/arch/arm/mach-h720x/h7202-eval.c
index 8c0ba99d683f..cc28b1efe047 100644
--- a/arch/arm/mach-h720x/h7202-eval.c
+++ b/arch/arm/mach-h720x/h7202-eval.c
@@ -72,8 +72,6 @@ static void __init init_eval_h7202(void)
72 72
73MACHINE_START(H7202, "Hynix HMS30C7202") 73MACHINE_START(H7202, "Hynix HMS30C7202")
74 /* Maintainer: Robert Schwebel, Pengutronix */ 74 /* Maintainer: Robert Schwebel, Pengutronix */
75 .phys_io = 0x80000000,
76 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
77 .boot_params = 0x40000100, 75 .boot_params = 0x40000100,
78 .map_io = h720x_map_io, 76 .map_io = h720x_map_io,
79 .init_irq = h7202_init_irq, 77 .init_irq = h7202_init_irq,
diff --git a/arch/arm/mach-h720x/include/mach/debug-macro.S b/arch/arm/mach-h720x/include/mach/debug-macro.S
index 27cafd12f033..c2093e835720 100644
--- a/arch/arm/mach-h720x/include/mach/debug-macro.S
+++ b/arch/arm/mach-h720x/include/mach/debug-macro.S
@@ -16,12 +16,10 @@
16 .equ io_virt, IO_VIRT 16 .equ io_virt, IO_VIRT
17 .equ io_phys, IO_PHYS 17 .equ io_phys, IO_PHYS
18 18
19 .macro addruart, rx, tmp 19 .macro addruart, rp, rv
20 mrc p15, 0, \rx, c1, c0 20 mov \rp, #0x00020000 @ UART1
21 tst \rx, #1 @ MMU enabled? 21 add \rv, \rp, #io_virt @ virtual address
22 moveq \rx, #io_phys @ physical base address 22 add \rp, \rp, #io_phys @ physical base address
23 movne \rx, #io_virt @ virtual address
24 add \rx, \rx, #0x00020000 @ UART1
25 .endm 23 .endm
26 24
27 .macro senduart,rd,rx 25 .macro senduart,rd,rx
diff --git a/arch/arm/mach-h720x/include/mach/vmalloc.h b/arch/arm/mach-h720x/include/mach/vmalloc.h
index ff1460d6841b..a45915b88756 100644
--- a/arch/arm/mach-h720x/include/mach/vmalloc.h
+++ b/arch/arm/mach-h720x/include/mach/vmalloc.h
@@ -5,6 +5,6 @@
5#ifndef __ARCH_ARM_VMALLOC_H 5#ifndef __ARCH_ARM_VMALLOC_H
6#define __ARCH_ARM_VMALLOC_H 6#define __ARCH_ARM_VMALLOC_H
7 7
8#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 8#define VMALLOC_END 0xd0000000
9 9
10#endif 10#endif
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index c5c0369bb481..197f9e241cff 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -122,6 +122,7 @@ config MACH_CPUIMX27
122 select IMX_HAVE_PLATFORM_IMX_I2C 122 select IMX_HAVE_PLATFORM_IMX_I2C
123 select IMX_HAVE_PLATFORM_IMX_UART 123 select IMX_HAVE_PLATFORM_IMX_UART
124 select IMX_HAVE_PLATFORM_MXC_NAND 124 select IMX_HAVE_PLATFORM_MXC_NAND
125 select MXC_ULPI if USB_ULPI
125 help 126 help
126 Include support for Eukrea CPUIMX27 platform. This includes 127 Include support for Eukrea CPUIMX27 platform. This includes
127 specific configurations for the module and its peripherals. 128 specific configurations for the module and its peripherals.
@@ -146,8 +147,8 @@ choice
146 default MACH_EUKREA_MBIMX27_BASEBOARD 147 default MACH_EUKREA_MBIMX27_BASEBOARD
147 148
148config MACH_EUKREA_MBIMX27_BASEBOARD 149config MACH_EUKREA_MBIMX27_BASEBOARD
149 prompt "Eukrea MBIMX27 development board" 150 bool "Eukrea MBIMX27 development board"
150 bool 151 select IMX_HAVE_PLATFORM_IMX_SSI
151 select IMX_HAVE_PLATFORM_IMX_UART 152 select IMX_HAVE_PLATFORM_IMX_UART
152 select IMX_HAVE_PLATFORM_SPI_IMX 153 select IMX_HAVE_PLATFORM_SPI_IMX
153 help 154 help
@@ -163,6 +164,15 @@ config MACH_MX27_3DS
163 Include support for MX27PDK platform. This includes specific 164 Include support for MX27PDK platform. This includes specific
164 configurations for the board and its peripherals. 165 configurations for the board and its peripherals.
165 166
167config MACH_IMX27_VISSTRIM_M10
168 bool "Vista Silicon i.MX27 Visstrim_m10"
169 select IMX_HAVE_PLATFORM_IMX_I2C
170 select IMX_HAVE_PLATFORM_IMX_UART
171 help
172 Include support for Visstrim_m10 platform and its different variants.
173 This includes specific configurations for the board and its
174 peripherals.
175
166config MACH_IMX27LITE 176config MACH_IMX27LITE
167 bool "LogicPD MX27 LITEKIT platform" 177 bool "LogicPD MX27 LITEKIT platform"
168 select IMX_HAVE_PLATFORM_IMX_UART 178 select IMX_HAVE_PLATFORM_IMX_UART
@@ -173,6 +183,7 @@ config MACH_IMX27LITE
173config MACH_PCA100 183config MACH_PCA100
174 bool "Phytec phyCARD-s (pca100)" 184 bool "Phytec phyCARD-s (pca100)"
175 select IMX_HAVE_PLATFORM_IMX_I2C 185 select IMX_HAVE_PLATFORM_IMX_I2C
186 select IMX_HAVE_PLATFORM_IMX_SSI
176 select IMX_HAVE_PLATFORM_IMX_UART 187 select IMX_HAVE_PLATFORM_IMX_UART
177 select IMX_HAVE_PLATFORM_MXC_NAND 188 select IMX_HAVE_PLATFORM_MXC_NAND
178 select IMX_HAVE_PLATFORM_SPI_IMX 189 select IMX_HAVE_PLATFORM_SPI_IMX
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 46a9fdfbbd15..5582692bb176 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_MACH_PCM038) += mach-pcm038.o
27obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970-baseboard.o 27obj-$(CONFIG_MACH_PCM970_BASEBOARD) += pcm970-baseboard.o
28obj-$(CONFIG_MACH_MX27_3DS) += mach-mx27_3ds.o 28obj-$(CONFIG_MACH_MX27_3DS) += mach-mx27_3ds.o
29obj-$(CONFIG_MACH_IMX27LITE) += mach-imx27lite.o 29obj-$(CONFIG_MACH_IMX27LITE) += mach-imx27lite.o
30obj-$(CONFIG_MACH_IMX27_VISSTRIM_M10) += mach-imx27_visstrim_m10.o
30obj-$(CONFIG_MACH_CPUIMX27) += mach-cpuimx27.o 31obj-$(CONFIG_MACH_CPUIMX27) += mach-cpuimx27.o
31obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o 32obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o
32obj-$(CONFIG_MACH_PCA100) += mach-pca100.o 33obj-$(CONFIG_MACH_PCA100) += mach-pca100.o
diff --git a/arch/arm/mach-imx/clock-imx1.c b/arch/arm/mach-imx/clock-imx1.c
index c05096c38301..daca30b2d5b1 100644
--- a/arch/arm/mach-imx/clock-imx1.c
+++ b/arch/arm/mach-imx/clock-imx1.c
@@ -592,7 +592,7 @@ static struct clk_lookup lookups[] __initdata = {
592 _REGISTER_CLOCK("imx-uart.1", NULL, uart_clk) 592 _REGISTER_CLOCK("imx-uart.1", NULL, uart_clk)
593 _REGISTER_CLOCK("imx-uart.2", NULL, uart_clk) 593 _REGISTER_CLOCK("imx-uart.2", NULL, uart_clk)
594 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk) 594 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c_clk)
595 _REGISTER_CLOCK("spi_imx.0", NULL, spi_clk) 595 _REGISTER_CLOCK("imx1-cspi.0", NULL, spi_clk)
596 _REGISTER_CLOCK("imx-mmc.0", NULL, sdhc_clk) 596 _REGISTER_CLOCK("imx-mmc.0", NULL, sdhc_clk)
597 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) 597 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
598 _REGISTER_CLOCK(NULL, "mshc", mshc_clk) 598 _REGISTER_CLOCK(NULL, "mshc", mshc_clk)
diff --git a/arch/arm/mach-imx/clock-imx21.c b/arch/arm/mach-imx/clock-imx21.c
index bb419ef4d133..cf15ea516a72 100644
--- a/arch/arm/mach-imx/clock-imx21.c
+++ b/arch/arm/mach-imx/clock-imx21.c
@@ -1172,9 +1172,9 @@ static struct clk_lookup lookups[] = {
1172 _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0]) 1172 _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0])
1173 _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0]) 1173 _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0])
1174 _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1]) 1174 _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1])
1175 _REGISTER_CLOCK(NULL, "cspi1", cspi_clk[0]) 1175 _REGISTER_CLOCK("imx21-cspi.0", NULL, cspi_clk[0])
1176 _REGISTER_CLOCK(NULL, "cspi2", cspi_clk[1]) 1176 _REGISTER_CLOCK("imx21-cspi.1", NULL, cspi_clk[1])
1177 _REGISTER_CLOCK(NULL, "cspi3", cspi_clk[2]) 1177 _REGISTER_CLOCK("imx21-cspi.2", NULL, cspi_clk[2])
1178 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk[0]) 1178 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk[0])
1179 _REGISTER_CLOCK(NULL, "csi", csi_clk[0]) 1179 _REGISTER_CLOCK(NULL, "csi", csi_clk[0])
1180 _REGISTER_CLOCK("imx21-hcd.0", NULL, usb_clk[0]) 1180 _REGISTER_CLOCK("imx21-hcd.0", NULL, usb_clk[0])
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 5a1aa15c8a16..98a25bada783 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -594,27 +594,27 @@ DEFINE_CLOCK(uart2_clk1, 0, PCCR1, 30, NULL, NULL, &ipg_clk);
594DEFINE_CLOCK(uart1_clk1, 0, PCCR1, 31, NULL, NULL, &ipg_clk); 594DEFINE_CLOCK(uart1_clk1, 0, PCCR1, 31, NULL, NULL, &ipg_clk);
595 595
596/* Clocks we cannot directly gate, but drivers need their rates */ 596/* Clocks we cannot directly gate, but drivers need their rates */
597DEFINE_CLOCK(cspi1_clk, 0, 0, 0, NULL, &cspi1_clk1, &per2_clk); 597DEFINE_CLOCK(cspi1_clk, 0, NULL, 0, NULL, &cspi1_clk1, &per2_clk);
598DEFINE_CLOCK(cspi2_clk, 1, 0, 0, NULL, &cspi2_clk1, &per2_clk); 598DEFINE_CLOCK(cspi2_clk, 1, NULL, 0, NULL, &cspi2_clk1, &per2_clk);
599DEFINE_CLOCK(cspi3_clk, 2, 0, 0, NULL, &cspi13_clk1, &per2_clk); 599DEFINE_CLOCK(cspi3_clk, 2, NULL, 0, NULL, &cspi13_clk1, &per2_clk);
600DEFINE_CLOCK(sdhc1_clk, 0, 0, 0, NULL, &sdhc1_clk1, &per2_clk); 600DEFINE_CLOCK(sdhc1_clk, 0, NULL, 0, NULL, &sdhc1_clk1, &per2_clk);
601DEFINE_CLOCK(sdhc2_clk, 1, 0, 0, NULL, &sdhc2_clk1, &per2_clk); 601DEFINE_CLOCK(sdhc2_clk, 1, NULL, 0, NULL, &sdhc2_clk1, &per2_clk);
602DEFINE_CLOCK(sdhc3_clk, 2, 0, 0, NULL, &sdhc3_clk1, &per2_clk); 602DEFINE_CLOCK(sdhc3_clk, 2, NULL, 0, NULL, &sdhc3_clk1, &per2_clk);
603DEFINE_CLOCK(pwm_clk, 0, 0, 0, NULL, &pwm_clk1, &per1_clk); 603DEFINE_CLOCK(pwm_clk, 0, NULL, 0, NULL, &pwm_clk1, &per1_clk);
604DEFINE_CLOCK(gpt1_clk, 0, 0, 0, NULL, &gpt1_clk1, &per1_clk); 604DEFINE_CLOCK(gpt1_clk, 0, NULL, 0, NULL, &gpt1_clk1, &per1_clk);
605DEFINE_CLOCK(gpt2_clk, 1, 0, 0, NULL, &gpt2_clk1, &per1_clk); 605DEFINE_CLOCK(gpt2_clk, 1, NULL, 0, NULL, &gpt2_clk1, &per1_clk);
606DEFINE_CLOCK(gpt3_clk, 2, 0, 0, NULL, &gpt3_clk1, &per1_clk); 606DEFINE_CLOCK(gpt3_clk, 2, NULL, 0, NULL, &gpt3_clk1, &per1_clk);
607DEFINE_CLOCK(gpt4_clk, 3, 0, 0, NULL, &gpt4_clk1, &per1_clk); 607DEFINE_CLOCK(gpt4_clk, 3, NULL, 0, NULL, &gpt4_clk1, &per1_clk);
608DEFINE_CLOCK(gpt5_clk, 4, 0, 0, NULL, &gpt5_clk1, &per1_clk); 608DEFINE_CLOCK(gpt5_clk, 4, NULL, 0, NULL, &gpt5_clk1, &per1_clk);
609DEFINE_CLOCK(gpt6_clk, 5, 0, 0, NULL, &gpt6_clk1, &per1_clk); 609DEFINE_CLOCK(gpt6_clk, 5, NULL, 0, NULL, &gpt6_clk1, &per1_clk);
610DEFINE_CLOCK(uart1_clk, 0, 0, 0, NULL, &uart1_clk1, &per1_clk); 610DEFINE_CLOCK(uart1_clk, 0, NULL, 0, NULL, &uart1_clk1, &per1_clk);
611DEFINE_CLOCK(uart2_clk, 1, 0, 0, NULL, &uart2_clk1, &per1_clk); 611DEFINE_CLOCK(uart2_clk, 1, NULL, 0, NULL, &uart2_clk1, &per1_clk);
612DEFINE_CLOCK(uart3_clk, 2, 0, 0, NULL, &uart3_clk1, &per1_clk); 612DEFINE_CLOCK(uart3_clk, 2, NULL, 0, NULL, &uart3_clk1, &per1_clk);
613DEFINE_CLOCK(uart4_clk, 3, 0, 0, NULL, &uart4_clk1, &per1_clk); 613DEFINE_CLOCK(uart4_clk, 3, NULL, 0, NULL, &uart4_clk1, &per1_clk);
614DEFINE_CLOCK(uart5_clk, 4, 0, 0, NULL, &uart5_clk1, &per1_clk); 614DEFINE_CLOCK(uart5_clk, 4, NULL, 0, NULL, &uart5_clk1, &per1_clk);
615DEFINE_CLOCK(uart6_clk, 5, 0, 0, NULL, &uart6_clk1, &per1_clk); 615DEFINE_CLOCK(uart6_clk, 5, NULL, 0, NULL, &uart6_clk1, &per1_clk);
616DEFINE_CLOCK1(lcdc_clk, 0, 0, 0, parent, &lcdc_clk1, &per3_clk); 616DEFINE_CLOCK1(lcdc_clk, 0, NULL, 0, parent, &lcdc_clk1, &per3_clk);
617DEFINE_CLOCK1(csi_clk, 0, 0, 0, parent, &csi_clk1, &per4_clk); 617DEFINE_CLOCK1(csi_clk, 0, NULL, 0, parent, &csi_clk1, &per4_clk);
618 618
619#define _REGISTER_CLOCK(d, n, c) \ 619#define _REGISTER_CLOCK(d, n, c) \
620 { \ 620 { \
@@ -640,9 +640,9 @@ static struct clk_lookup lookups[] = {
640 _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk) 640 _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
641 _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk) 641 _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
642 _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk) 642 _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk)
643 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk) 643 _REGISTER_CLOCK("imx27-cspi.0", NULL, cspi1_clk)
644 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk) 644 _REGISTER_CLOCK("imx27-cspi.1", NULL, cspi2_clk)
645 _REGISTER_CLOCK("spi_imx.2", NULL, cspi3_clk) 645 _REGISTER_CLOCK("imx27-cspi.2", NULL, cspi3_clk)
646 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk) 646 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
647 _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) 647 _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
648 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk) 648 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk)
diff --git a/arch/arm/mach-imx/devices-imx1.h b/arch/arm/mach-imx/devices-imx1.h
index a8d94f078196..81979486218e 100644
--- a/arch/arm/mach-imx/devices-imx1.h
+++ b/arch/arm/mach-imx/devices-imx1.h
@@ -9,10 +9,12 @@
9#include <mach/mx1.h> 9#include <mach/mx1.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12#define imx1_add_i2c_imx(pdata) \ 12extern const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst;
13 imx_add_imx_i2c(0, MX1_I2C_BASE_ADDR, SZ_4K, MX1_INT_I2C, pdata) 13#define imx1_add_imx_i2c(pdata) \
14 imx_add_imx_i2c(&imx1_imx_i2c_data, pdata)
14 15
15#define imx1_add_imx_uart0(pdata) \ 16extern const struct imx_imx_uart_3irq_data imx1_imx_uart_data[] __initconst;
16 imx_add_imx_uart_3irq(0, MX1_UART1_BASE_ADDR, 0xd0, MX1_INT_UART1RX, MX1_INT_UART1TX, MX1_INT_UART1RTS, pdata) 17#define imx1_add_imx_uart(id, pdata) \
17#define imx1_add_imx_uart1(pdata) \ 18 imx_add_imx_uart_3irq(&imx1_imx_uart_data[id], pdata)
18 imx_add_imx_uart_3irq(0, MX1_UART2_BASE_ADDR, 0xd0, MX1_INT_UART2RX, MX1_INT_UART2TX, MX1_INT_UART2RTS, pdata) 19#define imx1_add_imx_uart0(pdata) imx1_add_imx_uart(0, pdata)
20#define imx1_add_imx_uart1(pdata) imx1_add_imx_uart(1, pdata)
diff --git a/arch/arm/mach-imx/devices-imx21.h b/arch/arm/mach-imx/devices-imx21.h
index 42788e99d127..d189039749b0 100644
--- a/arch/arm/mach-imx/devices-imx21.h
+++ b/arch/arm/mach-imx/devices-imx21.h
@@ -9,22 +9,28 @@
9#include <mach/mx21.h> 9#include <mach/mx21.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12#define imx21_add_i2c_imx(pdata) \ 12extern const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst;
13 imx_add_imx_i2c(0, MX2x_I2C_BASE_ADDR, SZ_4K, MX2x_INT_I2C, pdata) 13#define imx21_add_imx_i2c(pdata) \
14 imx_add_imx_i2c(&imx21_imx_i2c_data, pdata)
14 15
15#define imx21_add_imx_uart0(pdata) \ 16extern const struct imx_imx_ssi_data imx21_imx_ssi_data[] __initconst;
16 imx_add_imx_uart_1irq(0, MX21_UART1_BASE_ADDR, SZ_4K, MX21_INT_UART1, pdata) 17#define imx21_add_imx_ssi(id, pdata) \
17#define imx21_add_imx_uart1(pdata) \ 18 imx_add_imx_ssi(&imx21_imx_ssi_data[id], pdata)
18 imx_add_imx_uart_1irq(1, MX21_UART2_BASE_ADDR, SZ_4K, MX21_INT_UART2, pdata)
19#define imx21_add_imx_uart2(pdata) \
20 imx_add_imx_uart_1irq(2, MX21_UART3_BASE_ADDR, SZ_4K, MX21_INT_UART3, pdata)
21#define imx21_add_imx_uart3(pdata) \
22 imx_add_imx_uart_1irq(3, MX21_UART4_BASE_ADDR, SZ_4K, MX21_INT_UART4, pdata)
23 19
20extern const struct imx_imx_uart_1irq_data imx21_imx_uart_data[] __initconst;
21#define imx21_add_imx_uart(id, pdata) \
22 imx_add_imx_uart_1irq(&imx21_imx_uart_data[id], pdata)
23#define imx21_add_imx_uart0(pdata) imx21_add_imx_uart(0, pdata)
24#define imx21_add_imx_uart1(pdata) imx21_add_imx_uart(1, pdata)
25#define imx21_add_imx_uart2(pdata) imx21_add_imx_uart(2, pdata)
26#define imx21_add_imx_uart3(pdata) imx21_add_imx_uart(3, pdata)
27
28extern const struct imx_mxc_nand_data imx21_mxc_nand_data __initconst;
24#define imx21_add_mxc_nand(pdata) \ 29#define imx21_add_mxc_nand(pdata) \
25 imx_add_mxc_nand_v1(MX21_NFC_BASE_ADDR, MX21_INT_NANDFC, pdata) 30 imx_add_mxc_nand(&imx21_mxc_nand_data, pdata)
26 31
27#define imx21_add_spi_imx0(pdata) \ 32extern const struct imx_spi_imx_data imx21_cspi_data[] __initconst;
28 imx_add_spi_imx(0, MX21_CSPI1_BASE_ADDR, SZ_4K, MX21_INT_CSPI1, pdata) 33#define imx21_add_cspi(id, pdata) \
29#define imx21_add_spi_imx1(pdata) \ 34 imx_add_spi_imx(&imx21_cspi_data[id], pdata)
30 imx_add_spi_imx(1, MX21_CSPI2_BASE_ADDR, SZ_4K, MX21_INT_CSPI2, pdata) 35#define imx21_add_spi_imx0(pdata) imx21_add_cspi(0, pdata)
36#define imx21_add_spi_imx1(pdata) imx21_add_cspi(1, pdata)
diff --git a/arch/arm/mach-imx/devices-imx27.h b/arch/arm/mach-imx/devices-imx27.h
index 65e7bb7ec2e8..7011690364f2 100644
--- a/arch/arm/mach-imx/devices-imx27.h
+++ b/arch/arm/mach-imx/devices-imx27.h
@@ -9,30 +9,35 @@
9#include <mach/mx27.h> 9#include <mach/mx27.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12#define imx27_add_i2c_imx0(pdata) \ 12extern const struct imx_fec_data imx27_fec_data __initconst;
13 imx_add_imx_i2c(0, MX27_I2C1_BASE_ADDR, SZ_4K, MX27_INT_I2C1, pdata) 13#define imx27_add_fec(pdata) \
14#define imx27_add_i2c_imx1(pdata) \ 14 imx_add_fec(&imx27_fec_data, pdata)
15 imx_add_imx_i2c(1, MX27_I2C2_BASE_ADDR, SZ_4K, MX27_INT_I2C2, pdata)
16 15
17#define imx27_add_imx_uart0(pdata) \ 16extern const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst;
18 imx_add_imx_uart_1irq(0, MX27_UART1_BASE_ADDR, SZ_4K, MX27_INT_UART1, pdata) 17#define imx27_add_imx_i2c(id, pdata) \
19#define imx27_add_imx_uart1(pdata) \ 18 imx_add_imx_i2c(&imx27_imx_i2c_data[id], pdata)
20 imx_add_imx_uart_1irq(1, MX27_UART2_BASE_ADDR, SZ_4K, MX27_INT_UART2, pdata)
21#define imx27_add_imx_uart2(pdata) \
22 imx_add_imx_uart_1irq(2, MX27_UART3_BASE_ADDR, SZ_4K, MX27_INT_UART3, pdata)
23#define imx27_add_imx_uart3(pdata) \
24 imx_add_imx_uart_1irq(3, MX27_UART4_BASE_ADDR, SZ_4K, MX27_INT_UART4, pdata)
25#define imx27_add_imx_uart4(pdata) \
26 imx_add_imx_uart_1irq(4, MX27_UART5_BASE_ADDR, SZ_4K, MX27_INT_UART5, pdata)
27#define imx27_add_imx_uart5(pdata) \
28 imx_add_imx_uart_1irq(5, MX27_UART6_BASE_ADDR, SZ_4K, MX27_INT_UART6, pdata)
29 19
20extern const struct imx_imx_ssi_data imx27_imx_ssi_data[] __initconst;
21#define imx27_add_imx_ssi(id, pdata) \
22 imx_add_imx_ssi(&imx27_imx_ssi_data[id], pdata)
23
24extern const struct imx_imx_uart_1irq_data imx27_imx_uart_data[] __initconst;
25#define imx27_add_imx_uart(id, pdata) \
26 imx_add_imx_uart_1irq(&imx27_imx_uart_data[id], pdata)
27#define imx27_add_imx_uart0(pdata) imx27_add_imx_uart(0, pdata)
28#define imx27_add_imx_uart1(pdata) imx27_add_imx_uart(1, pdata)
29#define imx27_add_imx_uart2(pdata) imx27_add_imx_uart(2, pdata)
30#define imx27_add_imx_uart3(pdata) imx27_add_imx_uart(3, pdata)
31#define imx27_add_imx_uart4(pdata) imx27_add_imx_uart(4, pdata)
32#define imx27_add_imx_uart5(pdata) imx27_add_imx_uart(5, pdata)
33
34extern const struct imx_mxc_nand_data imx27_mxc_nand_data __initconst;
30#define imx27_add_mxc_nand(pdata) \ 35#define imx27_add_mxc_nand(pdata) \
31 imx_add_mxc_nand_v1(MX27_NFC_BASE_ADDR, MX27_INT_NANDFC, pdata) 36 imx_add_mxc_nand(&imx27_mxc_nand_data, pdata)
32 37
33#define imx27_add_spi_imx0(pdata) \ 38extern const struct imx_spi_imx_data imx27_cspi_data[] __initconst;
34 imx_add_spi_imx(0, MX27_CSPI1_BASE_ADDR, SZ_4K, MX27_INT_CSPI1, pdata) 39#define imx27_add_cspi(id, pdata) \
35#define imx27_add_spi_imx1(pdata) \ 40 imx_add_spi_imx(&imx27_cspi_data[id], pdata)
36 imx_add_spi_imx(1, MX27_CSPI2_BASE_ADDR, SZ_4K, MX27_INT_CSPI2, pdata) 41#define imx27_add_spi_imx0(pdata) imx27_add_cspi(0, pdata)
37#define imx27_add_spi_imx2(pdata) \ 42#define imx27_add_spi_imx1(pdata) imx27_add_cspi(1, pdata)
38 imx_add_spi_imx(2, MX27_CSPI3_BASE_ADDR, SZ_4K, MX27_INT_CSPI3, pdata) 43#define imx27_add_spi_imx2(pdata) imx27_add_cspi(2, pdata)
diff --git a/arch/arm/mach-imx/devices.c b/arch/arm/mach-imx/devices.c
index 9c271a752b84..fba5047de8b1 100644
--- a/arch/arm/mach-imx/devices.c
+++ b/arch/arm/mach-imx/devices.c
@@ -314,27 +314,6 @@ struct platform_device mxc_fb_device = {
314 }, 314 },
315}; 315};
316 316
317#ifdef CONFIG_MACH_MX27
318static struct resource mxc_fec_resources[] = {
319 {
320 .start = MX27_FEC_BASE_ADDR,
321 .end = MX27_FEC_BASE_ADDR + SZ_4K - 1,
322 .flags = IORESOURCE_MEM,
323 }, {
324 .start = MX27_INT_FEC,
325 .end = MX27_INT_FEC,
326 .flags = IORESOURCE_IRQ,
327 },
328};
329
330struct platform_device mxc_fec_device = {
331 .name = "fec",
332 .id = 0,
333 .num_resources = ARRAY_SIZE(mxc_fec_resources),
334 .resource = mxc_fec_resources,
335};
336#endif
337
338static struct resource mxc_pwm_resources[] = { 317static struct resource mxc_pwm_resources[] = {
339 { 318 {
340 .start = MX2x_PWM_BASE_ADDR, 319 .start = MX2x_PWM_BASE_ADDR,
@@ -480,41 +459,6 @@ struct platform_device mxc_usbh2 = {
480}; 459};
481#endif 460#endif
482 461
483#define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix) \
484 { \
485 .name = _name, \
486 .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
487 .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
488 .flags = IORESOURCE_DMA, \
489 }
490
491#define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq) \
492 static struct resource imx_ssi_resources ## n[] = { \
493 { \
494 .start = MX2x_SSI ## ssin ## _BASE_ADDR, \
495 .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f, \
496 .flags = IORESOURCE_MEM, \
497 }, { \
498 .start = MX2x_INT_SSI1, \
499 .end = MX2x_INT_SSI1, \
500 .flags = IORESOURCE_IRQ, \
501 }, \
502 DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0), \
503 DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0), \
504 DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1), \
505 DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1), \
506 }; \
507 \
508 struct platform_device imx_ssi_device ## n = { \
509 .name = "imx-ssi", \
510 .id = n, \
511 .num_resources = ARRAY_SIZE(imx_ssi_resources ## n), \
512 .resource = imx_ssi_resources ## n, \
513 }
514
515DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
516DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
517
518/* GPIO port description */ 462/* GPIO port description */
519#define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \ 463#define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
520 { \ 464 { \
diff --git a/arch/arm/mach-imx/devices.h b/arch/arm/mach-imx/devices.h
index efd4527506a5..807f02a031c9 100644
--- a/arch/arm/mach-imx/devices.h
+++ b/arch/arm/mach-imx/devices.h
@@ -16,7 +16,6 @@ extern struct platform_device mxc_gpt5;
16extern struct platform_device mxc_wdt; 16extern struct platform_device mxc_wdt;
17extern struct platform_device mxc_w1_master_device; 17extern struct platform_device mxc_w1_master_device;
18extern struct platform_device mxc_fb_device; 18extern struct platform_device mxc_fb_device;
19extern struct platform_device mxc_fec_device;
20extern struct platform_device mxc_pwm_device; 19extern struct platform_device mxc_pwm_device;
21extern struct platform_device mxc_sdhc_device0; 20extern struct platform_device mxc_sdhc_device0;
22extern struct platform_device mxc_sdhc_device1; 21extern struct platform_device mxc_sdhc_device1;
@@ -26,7 +25,5 @@ extern struct platform_device mxc_otg_host;
26extern struct platform_device mxc_usbh1; 25extern struct platform_device mxc_usbh1;
27extern struct platform_device mxc_usbh2; 26extern struct platform_device mxc_usbh2;
28extern struct platform_device mx21_usbhc_device; 27extern struct platform_device mx21_usbhc_device;
29extern struct platform_device imx_ssi_device0;
30extern struct platform_device imx_ssi_device1;
31extern struct platform_device imx_kpp_device; 28extern struct platform_device imx_kpp_device;
32#endif 29#endif
diff --git a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
index 4edc5f439201..026263c665ca 100644
--- a/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
+++ b/arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
@@ -36,13 +36,12 @@
36#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <mach/mmc.h> 37#include <mach/mmc.h>
38#include <mach/spi.h> 38#include <mach/spi.h>
39#include <mach/ssi.h>
40#include <mach/audmux.h> 39#include <mach/audmux.h>
41 40
42#include "devices-imx27.h" 41#include "devices-imx27.h"
43#include "devices.h" 42#include "devices.h"
44 43
45static int eukrea_mbimx27_pins[] = { 44static const int eukrea_mbimx27_pins[] __initconst = {
46 /* UART2 */ 45 /* UART2 */
47 PE3_PF_UART2_CTS, 46 PE3_PF_UART2_CTS,
48 PE4_PF_UART2_RTS, 47 PE4_PF_UART2_RTS,
@@ -311,7 +310,8 @@ static struct imxmmc_platform_data sdhc_pdata = {
311 .dat3_card_detect = 1, 310 .dat3_card_detect = 1,
312}; 311};
313 312
314struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata = { 313static const
314struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata __initconst = {
315 .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE, 315 .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
316}; 316};
317 317
@@ -357,7 +357,7 @@ void __init eukrea_mbimx27_baseboard_init(void)
357 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices, 357 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
358 ARRAY_SIZE(eukrea_mbimx27_i2c_devices)); 358 ARRAY_SIZE(eukrea_mbimx27_i2c_devices));
359 359
360 mxc_register_device(&imx_ssi_device0, &eukrea_mbimx27_ssi_pdata); 360 imx27_add_imx_ssi(0, &eukrea_mbimx27_ssi_pdata);
361 361
362#if defined(CONFIG_TOUCHSCREEN_ADS7846) \ 362#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
363 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 363 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
diff --git a/arch/arm/mach-imx/mach-cpuimx27.c b/arch/arm/mach-imx/mach-cpuimx27.c
index 339150ab0ea5..745ee60fb068 100644
--- a/arch/arm/mach-imx/mach-cpuimx27.c
+++ b/arch/arm/mach-imx/mach-cpuimx27.c
@@ -46,7 +46,7 @@
46#include "devices-imx27.h" 46#include "devices-imx27.h"
47#include "devices.h" 47#include "devices.h"
48 48
49static int eukrea_cpuimx27_pins[] = { 49static const int eukrea_cpuimx27_pins[] __initconst = {
50 /* UART1 */ 50 /* UART1 */
51 PE12_PF_UART1_TXD, 51 PE12_PF_UART1_TXD,
52 PE13_PF_UART1_RXD, 52 PE13_PF_UART1_RXD,
@@ -157,7 +157,6 @@ cpuimx27_nand_board_info __initconst = {
157 157
158static struct platform_device *platform_devices[] __initdata = { 158static struct platform_device *platform_devices[] __initdata = {
159 &eukrea_cpuimx27_nor_mtd_device, 159 &eukrea_cpuimx27_nor_mtd_device,
160 &mxc_fec_device,
161 &mxc_wdt, 160 &mxc_wdt,
162 &mxc_w1_master_device, 161 &mxc_w1_master_device,
163}; 162};
@@ -259,8 +258,9 @@ static void __init eukrea_cpuimx27_init(void)
259 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices, 258 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
260 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices)); 259 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
261 260
262 imx27_add_i2c_imx1(&cpuimx27_i2c1_data); 261 imx27_add_imx_i2c(0, &cpuimx27_i2c1_data);
263 262
263 imx27_add_fec(NULL);
264 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 264 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
265 265
266#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) 266#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
@@ -307,8 +307,6 @@ static struct sys_timer eukrea_cpuimx27_timer = {
307}; 307};
308 308
309MACHINE_START(CPUIMX27, "EUKREA CPUIMX27") 309MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
310 .phys_io = MX27_AIPI_BASE_ADDR,
311 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
312 .boot_params = MX27_PHYS_OFFSET + 0x100, 310 .boot_params = MX27_PHYS_OFFSET + 0x100,
313 .map_io = mx27_map_io, 311 .map_io = mx27_map_io,
314 .init_irq = mx27_init_irq, 312 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
new file mode 100644
index 000000000000..59716fab586d
--- /dev/null
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -0,0 +1,261 @@
1/*
2 * mach-imx27_visstrim_m10.c
3 *
4 * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com>
5 *
6 * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
26#include <linux/platform_device.h>
27#include <linux/mtd/physmap.h>
28#include <linux/i2c.h>
29#include <linux/i2c/pca953x.h>
30#include <linux/gpio_keys.h>
31#include <linux/input.h>
32#include <linux/gpio.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/time.h>
36#include <mach/common.h>
37#include <mach/mmc.h>
38#include <mach/iomux.h>
39#include <mach/mxc_ehci.h>
40
41#include "devices-imx27.h"
42#include "devices.h"
43
44#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
45#define SDHC1_IRQ IRQ_GPIOB(25)
46
47static const int visstrim_m10_pins[] __initconst = {
48 /* UART1 (console) */
49 PE12_PF_UART1_TXD,
50 PE13_PF_UART1_RXD,
51 PE14_PF_UART1_CTS,
52 PE15_PF_UART1_RTS,
53 /* FEC */
54 PD0_AIN_FEC_TXD0,
55 PD1_AIN_FEC_TXD1,
56 PD2_AIN_FEC_TXD2,
57 PD3_AIN_FEC_TXD3,
58 PD4_AOUT_FEC_RX_ER,
59 PD5_AOUT_FEC_RXD1,
60 PD6_AOUT_FEC_RXD2,
61 PD7_AOUT_FEC_RXD3,
62 PD8_AF_FEC_MDIO,
63 PD9_AIN_FEC_MDC,
64 PD10_AOUT_FEC_CRS,
65 PD11_AOUT_FEC_TX_CLK,
66 PD12_AOUT_FEC_RXD0,
67 PD13_AOUT_FEC_RX_DV,
68 PD14_AOUT_FEC_RX_CLK,
69 PD15_AOUT_FEC_COL,
70 PD16_AIN_FEC_TX_ER,
71 PF23_AIN_FEC_TX_EN,
72 /* SDHC1 */
73 PE18_PF_SD1_D0,
74 PE19_PF_SD1_D1,
75 PE20_PF_SD1_D2,
76 PE21_PF_SD1_D3,
77 PE22_PF_SD1_CMD,
78 PE23_PF_SD1_CLK,
79 /* Both I2Cs */
80 PD17_PF_I2C_DATA,
81 PD18_PF_I2C_CLK,
82 PC5_PF_I2C2_SDA,
83 PC6_PF_I2C2_SCL,
84 /* USB OTG */
85 OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
86 PC9_PF_USBOTG_DATA0,
87 PC11_PF_USBOTG_DATA1,
88 PC10_PF_USBOTG_DATA2,
89 PC13_PF_USBOTG_DATA3,
90 PC12_PF_USBOTG_DATA4,
91 PC7_PF_USBOTG_DATA5,
92 PC8_PF_USBOTG_DATA6,
93 PE25_PF_USBOTG_DATA7,
94 PE24_PF_USBOTG_CLK,
95 PE2_PF_USBOTG_DIR,
96 PE0_PF_USBOTG_NXT,
97 PE1_PF_USBOTG_STP,
98 PB23_PF_USB_PWR,
99 PB24_PF_USB_OC,
100};
101
102/* GPIOs used as events for applications */
103static struct gpio_keys_button visstrim_gpio_keys[] = {
104 {
105 .type = EV_KEY,
106 .code = KEY_RESTART,
107 .gpio = (GPIO_PORTC + 15),
108 .desc = "Default config",
109 .active_low = 0,
110 .wakeup = 1,
111 },
112 {
113 .type = EV_KEY,
114 .code = KEY_RECORD,
115 .gpio = (GPIO_PORTF + 14),
116 .desc = "Record",
117 .active_low = 0,
118 .wakeup = 1,
119 },
120 {
121 .type = EV_KEY,
122 .code = KEY_STOP,
123 .gpio = (GPIO_PORTF + 13),
124 .desc = "Stop",
125 .active_low = 0,
126 .wakeup = 1,
127 }
128};
129
130static struct gpio_keys_platform_data visstrim_gpio_keys_platform_data = {
131 .buttons = visstrim_gpio_keys,
132 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
133};
134
135static struct platform_device visstrim_gpio_keys_device = {
136 .name = "gpio-keys",
137 .id = -1,
138 .dev = {
139 .platform_data = &visstrim_gpio_keys_platform_data,
140 },
141};
142
143/* Visstrim_SM10 has a microSD slot connected to sdhc1 */
144static int visstrim_m10_sdhc1_init(struct device *dev,
145 irq_handler_t detect_irq, void *data)
146{
147 int ret;
148
149 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
150 "mmc-detect", data);
151 return ret;
152}
153
154static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
155{
156 free_irq(SDHC1_IRQ, data);
157}
158
159static struct imxmmc_platform_data visstrim_m10_sdhc_pdata = {
160 .init = visstrim_m10_sdhc1_init,
161 .exit = visstrim_m10_sdhc1_exit,
162};
163
164/* Visstrim_SM10 NOR flash */
165static struct physmap_flash_data visstrim_m10_flash_data = {
166 .width = 2,
167};
168
169static struct resource visstrim_m10_flash_resource = {
170 .start = 0xc0000000,
171 .end = 0xc0000000 + SZ_64M - 1,
172 .flags = IORESOURCE_MEM,
173};
174
175static struct platform_device visstrim_m10_nor_mtd_device = {
176 .name = "physmap-flash",
177 .id = 0,
178 .dev = {
179 .platform_data = &visstrim_m10_flash_data,
180 },
181 .num_resources = 1,
182 .resource = &visstrim_m10_flash_resource,
183};
184
185static struct platform_device *platform_devices[] __initdata = {
186 &visstrim_gpio_keys_device,
187 &visstrim_m10_nor_mtd_device,
188};
189
190/* Visstrim_M10 uses UART0 as console */
191static const struct imxuart_platform_data uart_pdata __initconst = {
192 .flags = IMXUART_HAVE_RTSCTS,
193};
194
195/* I2C */
196static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
197 .bitrate = 100000,
198};
199
200static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
201 .gpio_base = 240, /* After MX27 internal GPIOs */
202 .invert = 0,
203};
204
205static struct i2c_board_info visstrim_m10_i2c_devices[] = {
206 {
207 I2C_BOARD_INFO("pca9555", 0x20),
208 .platform_data = &visstrim_m10_pca9555_pdata,
209 },
210};
211
212/* USB OTG */
213static int otg_phy_init(struct platform_device *pdev)
214{
215 gpio_set_value(OTG_PHY_CS_GPIO, 0);
216 return 0;
217}
218
219static struct mxc_usbh_platform_data visstrim_m10_usbotg_pdata = {
220 .init = otg_phy_init,
221 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
222 .flags = MXC_EHCI_POWER_PINS_ENABLED,
223};
224
225static void __init visstrim_m10_board_init(void)
226{
227 int ret;
228
229 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
230 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
231 if (ret)
232 pr_err("Failed to setup pins (%d)\n", ret);
233
234 imx27_add_imx_uart0(&uart_pdata);
235
236 i2c_register_board_info(0, visstrim_m10_i2c_devices,
237 ARRAY_SIZE(visstrim_m10_i2c_devices));
238 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
239 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
240 mxc_register_device(&mxc_sdhc_device0, &visstrim_m10_sdhc_pdata);
241 mxc_register_device(&mxc_otg_host, &visstrim_m10_usbotg_pdata);
242 imx27_add_fec(NULL);
243 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
244}
245
246static void __init visstrim_m10_timer_init(void)
247{
248 mx27_clocks_init((unsigned long)25000000);
249}
250
251static struct sys_timer visstrim_m10_timer = {
252 .init = visstrim_m10_timer_init,
253};
254
255MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
256 .boot_params = MX27_PHYS_OFFSET + 0x100,
257 .map_io = mx27_map_io,
258 .init_irq = mx27_init_irq,
259 .init_machine = visstrim_m10_board_init,
260 .timer = &visstrim_m10_timer,
261MACHINE_END
diff --git a/arch/arm/mach-imx/mach-imx27lite.c b/arch/arm/mach-imx/mach-imx27lite.c
index 22a2b5d91213..bbdbc75127d3 100644
--- a/arch/arm/mach-imx/mach-imx27lite.c
+++ b/arch/arm/mach-imx/mach-imx27lite.c
@@ -27,7 +27,7 @@
27#include "devices-imx27.h" 27#include "devices-imx27.h"
28#include "devices.h" 28#include "devices.h"
29 29
30static unsigned int mx27lite_pins[] = { 30static const int mx27lite_pins[] __initconst = {
31 /* UART1 */ 31 /* UART1 */
32 PE12_PF_UART1_TXD, 32 PE12_PF_UART1_TXD,
33 PE13_PF_UART1_RXD, 33 PE13_PF_UART1_RXD,
@@ -58,16 +58,12 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
58 .flags = IMXUART_HAVE_RTSCTS, 58 .flags = IMXUART_HAVE_RTSCTS,
59}; 59};
60 60
61static struct platform_device *platform_devices[] __initdata = {
62 &mxc_fec_device,
63};
64
65static void __init mx27lite_init(void) 61static void __init mx27lite_init(void)
66{ 62{
67 mxc_gpio_setup_multiple_pins(mx27lite_pins, ARRAY_SIZE(mx27lite_pins), 63 mxc_gpio_setup_multiple_pins(mx27lite_pins, ARRAY_SIZE(mx27lite_pins),
68 "imx27lite"); 64 "imx27lite");
69 imx27_add_imx_uart0(&uart_pdata); 65 imx27_add_imx_uart0(&uart_pdata);
70 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 66 imx27_add_fec(NULL);
71} 67}
72 68
73static void __init mx27lite_timer_init(void) 69static void __init mx27lite_timer_init(void)
@@ -80,8 +76,6 @@ static struct sys_timer mx27lite_timer = {
80}; 76};
81 77
82MACHINE_START(IMX27LITE, "LogicPD i.MX27LITE") 78MACHINE_START(IMX27LITE, "LogicPD i.MX27LITE")
83 .phys_io = MX27_AIPI_BASE_ADDR,
84 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
85 .boot_params = MX27_PHYS_OFFSET + 0x100, 79 .boot_params = MX27_PHYS_OFFSET + 0x100,
86 .map_io = mx27_map_io, 80 .map_io = mx27_map_io,
87 .init_irq = mx27_init_irq, 81 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-mx1ads.c b/arch/arm/mach-imx/mach-mx1ads.c
index 77a760cfadc0..6187ce9ba7d5 100644
--- a/arch/arm/mach-imx/mach-mx1ads.c
+++ b/arch/arm/mach-imx/mach-mx1ads.c
@@ -32,7 +32,7 @@
32#include "devices-imx1.h" 32#include "devices-imx1.h"
33#include "devices.h" 33#include "devices.h"
34 34
35static int mx1ads_pins[] = { 35static const int mx1ads_pins[] __initconst = {
36 /* UART1 */ 36 /* UART1 */
37 PC9_PF_UART1_CTS, 37 PC9_PF_UART1_CTS,
38 PC10_PF_UART1_RTS, 38 PC10_PF_UART1_RTS,
@@ -131,7 +131,7 @@ static void __init mx1ads_init(void)
131 i2c_register_board_info(0, mx1ads_i2c_devices, 131 i2c_register_board_info(0, mx1ads_i2c_devices,
132 ARRAY_SIZE(mx1ads_i2c_devices)); 132 ARRAY_SIZE(mx1ads_i2c_devices));
133 133
134 imx1_add_i2c_imx(&mx1ads_i2c_data); 134 imx1_add_imx_i2c(&mx1ads_i2c_data);
135} 135}
136 136
137static void __init mx1ads_timer_init(void) 137static void __init mx1ads_timer_init(void)
@@ -145,8 +145,6 @@ struct sys_timer mx1ads_timer = {
145 145
146MACHINE_START(MX1ADS, "Freescale MX1ADS") 146MACHINE_START(MX1ADS, "Freescale MX1ADS")
147 /* Maintainer: Sascha Hauer, Pengutronix */ 147 /* Maintainer: Sascha Hauer, Pengutronix */
148 .phys_io = MX1_IO_BASE_ADDR,
149 .io_pg_offst = (MX1_IO_BASE_ADDR_VIRT >> 18) & 0xfffc,
150 .boot_params = MX1_PHYS_OFFSET + 0x100, 148 .boot_params = MX1_PHYS_OFFSET + 0x100,
151 .map_io = mx1_map_io, 149 .map_io = mx1_map_io,
152 .init_irq = mx1_init_irq, 150 .init_irq = mx1_init_irq,
@@ -155,8 +153,6 @@ MACHINE_START(MX1ADS, "Freescale MX1ADS")
155MACHINE_END 153MACHINE_END
156 154
157MACHINE_START(MXLADS, "Freescale MXLADS") 155MACHINE_START(MXLADS, "Freescale MXLADS")
158 .phys_io = MX1_IO_BASE_ADDR,
159 .io_pg_offst = (MX1_IO_BASE_ADDR_VIRT >> 18) & 0xfffc,
160 .boot_params = MX1_PHYS_OFFSET + 0x100, 156 .boot_params = MX1_PHYS_OFFSET + 0x100,
161 .map_io = mx1_map_io, 157 .map_io = mx1_map_io,
162 .init_irq = mx1_init_irq, 158 .init_irq = mx1_init_irq,
diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c
index 96d7f8189f32..e1282e9f50ff 100644
--- a/arch/arm/mach-imx/mach-mx21ads.c
+++ b/arch/arm/mach-imx/mach-mx21ads.c
@@ -67,7 +67,7 @@
67#define MX21ADS_IO_LED4_ON 0x4000 67#define MX21ADS_IO_LED4_ON 0x4000
68#define MX21ADS_IO_LED3_ON 0x8000 68#define MX21ADS_IO_LED3_ON 0x8000
69 69
70static unsigned int mx21ads_pins[] = { 70static const int mx21ads_pins[] __initconst = {
71 71
72 /* CS8900A */ 72 /* CS8900A */
73 (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11), 73 (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),
@@ -314,8 +314,6 @@ static struct sys_timer mx21ads_timer = {
314 314
315MACHINE_START(MX21ADS, "Freescale i.MX21ADS") 315MACHINE_START(MX21ADS, "Freescale i.MX21ADS")
316 /* maintainer: Freescale Semiconductor, Inc. */ 316 /* maintainer: Freescale Semiconductor, Inc. */
317 .phys_io = MX21_AIPI_BASE_ADDR,
318 .io_pg_offst = ((MX21_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
319 .boot_params = MX21_PHYS_OFFSET + 0x100, 317 .boot_params = MX21_PHYS_OFFSET + 0x100,
320 .map_io = mx21ads_map_io, 318 .map_io = mx21ads_map_io,
321 .init_irq = mx21_init_irq, 319 .init_irq = mx21_init_irq,
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index e66ffaa1c26c..b8bbd31aa850 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -33,7 +33,7 @@
33#include "devices-imx27.h" 33#include "devices-imx27.h"
34#include "devices.h" 34#include "devices.h"
35 35
36static unsigned int mx27pdk_pins[] = { 36static const int mx27pdk_pins[] __initconst = {
37 /* UART1 */ 37 /* UART1 */
38 PE12_PF_UART1_TXD, 38 PE12_PF_UART1_TXD,
39 PE13_PF_UART1_RXD, 39 PE13_PF_UART1_RXD,
@@ -64,10 +64,6 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
64 .flags = IMXUART_HAVE_RTSCTS, 64 .flags = IMXUART_HAVE_RTSCTS,
65}; 65};
66 66
67static struct platform_device *platform_devices[] __initdata = {
68 &mxc_fec_device,
69};
70
71/* 67/*
72 * Matrix keyboard 68 * Matrix keyboard
73 */ 69 */
@@ -94,7 +90,7 @@ static void __init mx27pdk_init(void)
94 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), 90 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
95 "mx27pdk"); 91 "mx27pdk");
96 imx27_add_imx_uart0(&uart_pdata); 92 imx27_add_imx_uart0(&uart_pdata);
97 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 93 imx27_add_fec(NULL);
98 mxc_register_device(&imx_kpp_device, &mx27_3ds_keymap_data); 94 mxc_register_device(&imx_kpp_device, &mx27_3ds_keymap_data);
99} 95}
100 96
@@ -109,8 +105,6 @@ static struct sys_timer mx27pdk_timer = {
109 105
110MACHINE_START(MX27_3DS, "Freescale MX27PDK") 106MACHINE_START(MX27_3DS, "Freescale MX27PDK")
111 /* maintainer: Freescale Semiconductor, Inc. */ 107 /* maintainer: Freescale Semiconductor, Inc. */
112 .phys_io = MX27_AIPI_BASE_ADDR,
113 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
114 .boot_params = MX27_PHYS_OFFSET + 0x100, 108 .boot_params = MX27_PHYS_OFFSET + 0x100,
115 .map_io = mx27_map_io, 109 .map_io = mx27_map_io,
116 .init_irq = mx27_init_irq, 110 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-mx27ads.c b/arch/arm/mach-imx/mach-mx27ads.c
index 9c77da98a10e..a1e4bc573afc 100644
--- a/arch/arm/mach-imx/mach-mx27ads.c
+++ b/arch/arm/mach-imx/mach-mx27ads.c
@@ -66,7 +66,7 @@
66/* to determine the correct external crystal reference */ 66/* to determine the correct external crystal reference */
67#define CKIH_27MHZ_BIT_SET (1 << 3) 67#define CKIH_27MHZ_BIT_SET (1 << 3)
68 68
69static unsigned int mx27ads_pins[] = { 69static const int mx27ads_pins[] __initconst = {
70 /* UART0 */ 70 /* UART0 */
71 PE12_PF_UART1_TXD, 71 PE12_PF_UART1_TXD,
72 PE13_PF_UART1_RXD, 72 PE13_PF_UART1_RXD,
@@ -284,7 +284,6 @@ static struct imxmmc_platform_data sdhc2_pdata = {
284 284
285static struct platform_device *platform_devices[] __initdata = { 285static struct platform_device *platform_devices[] __initdata = {
286 &mx27ads_nor_mtd_device, 286 &mx27ads_nor_mtd_device,
287 &mxc_fec_device,
288 &mxc_w1_master_device, 287 &mxc_w1_master_device,
289}; 288};
290 289
@@ -308,11 +307,12 @@ static void __init mx27ads_board_init(void)
308 /* only the i2c master 1 is used on this CPU card */ 307 /* only the i2c master 1 is used on this CPU card */
309 i2c_register_board_info(1, mx27ads_i2c_devices, 308 i2c_register_board_info(1, mx27ads_i2c_devices,
310 ARRAY_SIZE(mx27ads_i2c_devices)); 309 ARRAY_SIZE(mx27ads_i2c_devices));
311 imx27_add_i2c_imx1(&mx27ads_i2c1_data); 310 imx27_add_imx_i2c(1, &mx27ads_i2c1_data);
312 mxc_register_device(&mxc_fb_device, &mx27ads_fb_data); 311 mxc_register_device(&mxc_fb_device, &mx27ads_fb_data);
313 mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata); 312 mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
314 mxc_register_device(&mxc_sdhc_device1, &sdhc2_pdata); 313 mxc_register_device(&mxc_sdhc_device1, &sdhc2_pdata);
315 314
315 imx27_add_fec(NULL);
316 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 316 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
317} 317}
318 318
@@ -347,8 +347,6 @@ static void __init mx27ads_map_io(void)
347 347
348MACHINE_START(MX27ADS, "Freescale i.MX27ADS") 348MACHINE_START(MX27ADS, "Freescale i.MX27ADS")
349 /* maintainer: Freescale Semiconductor, Inc. */ 349 /* maintainer: Freescale Semiconductor, Inc. */
350 .phys_io = MX27_AIPI_BASE_ADDR,
351 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
352 .boot_params = MX27_PHYS_OFFSET + 0x100, 350 .boot_params = MX27_PHYS_OFFSET + 0x100,
353 .map_io = mx27ads_map_io, 351 .map_io = mx27ads_map_io,
354 .init_irq = mx27_init_irq, 352 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-mxt_td60.c b/arch/arm/mach-imx/mach-mxt_td60.c
index a3a1e452d4c5..38d3a4ae17c7 100644
--- a/arch/arm/mach-imx/mach-mxt_td60.c
+++ b/arch/arm/mach-imx/mach-mxt_td60.c
@@ -37,7 +37,7 @@
37#include "devices-imx27.h" 37#include "devices-imx27.h"
38#include "devices.h" 38#include "devices.h"
39 39
40static unsigned int mxt_td60_pins[] __initdata = { 40static const int mxt_td60_pins[] __initconst = {
41 /* UART0 */ 41 /* UART0 */
42 PE12_PF_UART1_TXD, 42 PE12_PF_UART1_TXD,
43 PE13_PF_UART1_RXD, 43 PE13_PF_UART1_RXD,
@@ -231,10 +231,6 @@ static struct imxmmc_platform_data sdhc1_pdata = {
231 .exit = mxt_td60_sdhc1_exit, 231 .exit = mxt_td60_sdhc1_exit,
232}; 232};
233 233
234static struct platform_device *platform_devices[] __initdata = {
235 &mxc_fec_device,
236};
237
238static const struct imxuart_platform_data uart_pdata __initconst = { 234static const struct imxuart_platform_data uart_pdata __initconst = {
239 .flags = IMXUART_HAVE_RTSCTS, 235 .flags = IMXUART_HAVE_RTSCTS,
240}; 236};
@@ -255,12 +251,11 @@ static void __init mxt_td60_board_init(void)
255 i2c_register_board_info(1, mxt_td60_i2c2_devices, 251 i2c_register_board_info(1, mxt_td60_i2c2_devices,
256 ARRAY_SIZE(mxt_td60_i2c2_devices)); 252 ARRAY_SIZE(mxt_td60_i2c2_devices));
257 253
258 imx27_add_i2c_imx0(&mxt_td60_i2c0_data); 254 imx27_add_imx_i2c(0, &mxt_td60_i2c0_data);
259 imx27_add_i2c_imx1(&mxt_td60_i2c1_data); 255 imx27_add_imx_i2c(1, &mxt_td60_i2c1_data);
260 mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data); 256 mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data);
261 mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata); 257 mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
262 258 imx27_add_fec(NULL);
263 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
264} 259}
265 260
266static void __init mxt_td60_timer_init(void) 261static void __init mxt_td60_timer_init(void)
@@ -274,8 +269,6 @@ static struct sys_timer mxt_td60_timer = {
274 269
275MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60") 270MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60")
276 /* maintainer: Maxtrack Industrial */ 271 /* maintainer: Maxtrack Industrial */
277 .phys_io = MX27_AIPI_BASE_ADDR,
278 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
279 .boot_params = MX27_PHYS_OFFSET + 0x100, 272 .boot_params = MX27_PHYS_OFFSET + 0x100,
280 .map_io = mx27_map_io, 273 .map_io = mx27_map_io,
281 .init_irq = mx27_init_irq, 274 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-pca100.c b/arch/arm/mach-imx/mach-pca100.c
index 23c9e1f37b9c..8c720d44602a 100644
--- a/arch/arm/mach-imx/mach-pca100.c
+++ b/arch/arm/mach-imx/mach-pca100.c
@@ -38,7 +38,6 @@
38#include <mach/iomux-mx27.h> 38#include <mach/iomux-mx27.h>
39#include <asm/mach/time.h> 39#include <asm/mach/time.h>
40#include <mach/audmux.h> 40#include <mach/audmux.h>
41#include <mach/ssi.h>
42#include <mach/mxc_nand.h> 41#include <mach/mxc_nand.h>
43#include <mach/irqs.h> 42#include <mach/irqs.h>
44#include <mach/mmc.h> 43#include <mach/mmc.h>
@@ -55,7 +54,7 @@
55#define SPI1_SS1 (GPIO_PORTD + 27) 54#define SPI1_SS1 (GPIO_PORTD + 27)
56#define SD2_CD (GPIO_PORTC + 29) 55#define SD2_CD (GPIO_PORTC + 29)
57 56
58static int pca100_pins[] = { 57static const int pca100_pins[] __initconst = {
59 /* UART1 */ 58 /* UART1 */
60 PE12_PF_UART1_TXD, 59 PE12_PF_UART1_TXD,
61 PE13_PF_UART1_RXD, 60 PE13_PF_UART1_RXD,
@@ -174,7 +173,6 @@ pca100_nand_board_info __initconst = {
174 173
175static struct platform_device *platform_devices[] __initdata = { 174static struct platform_device *platform_devices[] __initdata = {
176 &mxc_w1_master_device, 175 &mxc_w1_master_device,
177 &mxc_fec_device,
178 &mxc_wdt, 176 &mxc_wdt,
179}; 177};
180 178
@@ -193,11 +191,9 @@ static struct i2c_board_info pca100_i2c_devices[] = {
193 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */ 191 I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
194 .platform_data = &board_eeprom, 192 .platform_data = &board_eeprom,
195 }, { 193 }, {
196 I2C_BOARD_INFO("rtc-pcf8563", 0x51), 194 I2C_BOARD_INFO("pcf8563", 0x51),
197 .type = "pcf8563"
198 }, { 195 }, {
199 I2C_BOARD_INFO("lm75", 0x4a), 196 I2C_BOARD_INFO("lm75", 0x4a),
200 .type = "lm75"
201 } 197 }
202}; 198};
203 199
@@ -252,7 +248,7 @@ static void pca100_ac97_cold_reset(struct snd_ac97 *ac97)
252 msleep(2); 248 msleep(2);
253} 249}
254 250
255static struct imx_ssi_platform_data pca100_ssi_pdata = { 251static const struct imx_ssi_platform_data pca100_ssi_pdata __initconst = {
256 .ac97_reset = pca100_ac97_cold_reset, 252 .ac97_reset = pca100_ac97_cold_reset,
257 .ac97_warm_reset = pca100_ac97_warm_reset, 253 .ac97_warm_reset = pca100_ac97_warm_reset,
258 .flags = IMX_SSI_USE_AC97, 254 .flags = IMX_SSI_USE_AC97,
@@ -389,7 +385,7 @@ static void __init pca100_init(void)
389 if (ret) 385 if (ret)
390 printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret); 386 printk(KERN_ERR "pca100: Failed to setup pins (%d)\n", ret);
391 387
392 mxc_register_device(&imx_ssi_device0, &pca100_ssi_pdata); 388 imx27_add_imx_ssi(0, &pca100_ssi_pdata);
393 389
394 imx27_add_imx_uart0(&uart_pdata); 390 imx27_add_imx_uart0(&uart_pdata);
395 391
@@ -401,7 +397,7 @@ static void __init pca100_init(void)
401 i2c_register_board_info(1, pca100_i2c_devices, 397 i2c_register_board_info(1, pca100_i2c_devices,
402 ARRAY_SIZE(pca100_i2c_devices)); 398 ARRAY_SIZE(pca100_i2c_devices));
403 399
404 imx27_add_i2c_imx1(&pca100_i2c1_data); 400 imx27_add_imx_i2c(1, &pca100_i2c1_data);
405 401
406#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) 402#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
407 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_IN); 403 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_IN);
@@ -436,6 +432,7 @@ static void __init pca100_init(void)
436 432
437 mxc_register_device(&mxc_fb_device, &pca100_fb_data); 433 mxc_register_device(&mxc_fb_device, &pca100_fb_data);
438 434
435 imx27_add_fec(NULL);
439 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 436 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
440} 437}
441 438
@@ -449,8 +446,6 @@ static struct sys_timer pca100_timer = {
449}; 446};
450 447
451MACHINE_START(PCA100, "phyCARD-i.MX27") 448MACHINE_START(PCA100, "phyCARD-i.MX27")
452 .phys_io = MX27_AIPI_BASE_ADDR,
453 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
454 .boot_params = MX27_PHYS_OFFSET + 0x100, 449 .boot_params = MX27_PHYS_OFFSET + 0x100,
455 .map_io = mx27_map_io, 450 .map_io = mx27_map_io,
456 .init_irq = mx27_init_irq, 451 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-pcm038.c b/arch/arm/mach-imx/mach-pcm038.c
index 9212e8f37001..49a97ce07426 100644
--- a/arch/arm/mach-imx/mach-pcm038.c
+++ b/arch/arm/mach-imx/mach-pcm038.c
@@ -43,7 +43,7 @@
43#include "devices-imx27.h" 43#include "devices-imx27.h"
44#include "devices.h" 44#include "devices.h"
45 45
46static int pcm038_pins[] = { 46static const int pcm038_pins[] __initconst = {
47 /* UART1 */ 47 /* UART1 */
48 PE12_PF_UART1_TXD, 48 PE12_PF_UART1_TXD,
49 PE13_PF_UART1_RXD, 49 PE13_PF_UART1_RXD,
@@ -173,7 +173,6 @@ pcm038_nand_board_info __initconst = {
173static struct platform_device *platform_devices[] __initdata = { 173static struct platform_device *platform_devices[] __initdata = {
174 &pcm038_nor_mtd_device, 174 &pcm038_nor_mtd_device,
175 &mxc_w1_master_device, 175 &mxc_w1_master_device,
176 &mxc_fec_device,
177 &pcm038_sram_mtd_device, 176 &pcm038_sram_mtd_device,
178 &mxc_wdt, 177 &mxc_wdt,
179}; 178};
@@ -257,7 +256,7 @@ static struct regulator_init_data cam_data = {
257 .consumer_supplies = cam_consumers, 256 .consumer_supplies = cam_consumers,
258}; 257};
259 258
260struct mc13783_regulator_init_data pcm038_regulators[] = { 259static struct mc13783_regulator_init_data pcm038_regulators[] = {
261 { 260 {
262 .id = MC13783_REGU_VCAM, 261 .id = MC13783_REGU_VCAM,
263 .init_data = &cam_data, 262 .init_data = &cam_data,
@@ -309,7 +308,7 @@ static void __init pcm038_init(void)
309 i2c_register_board_info(1, pcm038_i2c_devices, 308 i2c_register_board_info(1, pcm038_i2c_devices,
310 ARRAY_SIZE(pcm038_i2c_devices)); 309 ARRAY_SIZE(pcm038_i2c_devices));
311 310
312 imx27_add_i2c_imx1(&pcm038_i2c1_data); 311 imx27_add_imx_i2c(1, &pcm038_i2c1_data);
313 312
314 /* PE18 for user-LED D40 */ 313 /* PE18 for user-LED D40 */
315 mxc_gpio_mode(GPIO_PORTE | 18 | GPIO_GPIO | GPIO_OUT); 314 mxc_gpio_mode(GPIO_PORTE | 18 | GPIO_GPIO | GPIO_OUT);
@@ -325,6 +324,7 @@ static void __init pcm038_init(void)
325 324
326 mxc_register_device(&mxc_usbh2, &usbh2_pdata); 325 mxc_register_device(&mxc_usbh2, &usbh2_pdata);
327 326
327 imx27_add_fec(NULL);
328 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 328 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
329 329
330#ifdef CONFIG_MACH_PCM970_BASEBOARD 330#ifdef CONFIG_MACH_PCM970_BASEBOARD
@@ -342,8 +342,6 @@ static struct sys_timer pcm038_timer = {
342}; 342};
343 343
344MACHINE_START(PCM038, "phyCORE-i.MX27") 344MACHINE_START(PCM038, "phyCORE-i.MX27")
345 .phys_io = MX27_AIPI_BASE_ADDR,
346 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
347 .boot_params = MX27_PHYS_OFFSET + 0x100, 345 .boot_params = MX27_PHYS_OFFSET + 0x100,
348 .map_io = mx27_map_io, 346 .map_io = mx27_map_io,
349 .init_irq = mx27_init_irq, 347 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-scb9328.c b/arch/arm/mach-imx/mach-scb9328.c
index 88bf0d1e26e6..1fbdd3faa7ab 100644
--- a/arch/arm/mach-imx/mach-scb9328.c
+++ b/arch/arm/mach-imx/mach-scb9328.c
@@ -95,7 +95,7 @@ static struct platform_device dm9000x_device = {
95 } 95 }
96}; 96};
97 97
98static int mxc_uart1_pins[] = { 98static const int mxc_uart1_pins[] = {
99 PC9_PF_UART1_CTS, 99 PC9_PF_UART1_CTS,
100 PC10_PF_UART1_RTS, 100 PC10_PF_UART1_RTS,
101 PC11_PF_UART1_TXD, 101 PC11_PF_UART1_TXD,
@@ -147,8 +147,6 @@ static struct sys_timer scb9328_timer = {
147 147
148MACHINE_START(SCB9328, "Synertronixx scb9328") 148MACHINE_START(SCB9328, "Synertronixx scb9328")
149 /* Sascha Hauer */ 149 /* Sascha Hauer */
150 .phys_io = 0x00200000,
151 .io_pg_offst = ((0xe0200000) >> 18) & 0xfffc,
152 .boot_params = 0x08000100, 150 .boot_params = 0x08000100,
153 .map_io = mx1_map_io, 151 .map_io = mx1_map_io,
154 .init_irq = mx1_init_irq, 152 .init_irq = mx1_init_irq,
diff --git a/arch/arm/mach-imx/pcm970-baseboard.c b/arch/arm/mach-imx/pcm970-baseboard.c
index f490a406d57e..9110d9cca7a2 100644
--- a/arch/arm/mach-imx/pcm970-baseboard.c
+++ b/arch/arm/mach-imx/pcm970-baseboard.c
@@ -31,7 +31,7 @@
31 31
32#include "devices.h" 32#include "devices.h"
33 33
34static int pcm970_pins[] = { 34static const int pcm970_pins[] __initconst = {
35 /* SDHC */ 35 /* SDHC */
36 PB4_PF_SD2_D0, 36 PB4_PF_SD2_D0,
37 PB5_PF_SD2_D1, 37 PB5_PF_SD2_D1,
@@ -200,7 +200,7 @@ static struct resource pcm970_sja1000_resources[] = {
200 }, 200 },
201}; 201};
202 202
203struct sja1000_platform_data pcm970_sja1000_platform_data = { 203static struct sja1000_platform_data pcm970_sja1000_platform_data = {
204 .osc_freq = 16000000, 204 .osc_freq = 16000000,
205 .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL, 205 .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
206 .cdr = CDR_CBP, 206 .cdr = CDR_CBP,
diff --git a/arch/arm/mach-integrator/include/mach/debug-macro.S b/arch/arm/mach-integrator/include/mach/debug-macro.S
index 87a6888ae011..a1f598fd3a56 100644
--- a/arch/arm/mach-integrator/include/mach/debug-macro.S
+++ b/arch/arm/mach-integrator/include/mach/debug-macro.S
@@ -11,12 +11,10 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x16000000 @ physical base address
16 tst \rx, #1 @ MMU enabled? 16 mov \rv, #0xf0000000 @ virtual base
17 moveq \rx, #0x16000000 @ physical base address 17 add \rv, \rv, #0x16000000 >> 4
18 movne \rx, #0xf0000000 @ virtual base
19 addne \rx, \rx, #0x16000000 >> 4
20 .endm 18 .endm
21 19
22#include <asm/hardware/debug-pl01x.S> 20#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-integrator/include/mach/vmalloc.h b/arch/arm/mach-integrator/include/mach/vmalloc.h
index e87ab0b37bdd..e056e7cf5645 100644
--- a/arch/arm/mach-integrator/include/mach/vmalloc.h
+++ b/arch/arm/mach-integrator/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END 0xd0000000
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 6ab5a03ab9d8..548208f11179 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -500,8 +500,6 @@ static struct sys_timer ap_timer = {
500 500
501MACHINE_START(INTEGRATOR, "ARM-Integrator") 501MACHINE_START(INTEGRATOR, "ARM-Integrator")
502 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 502 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
503 .phys_io = 0x16000000,
504 .io_pg_offst = ((0xf1600000) >> 18) & 0xfffc,
505 .boot_params = 0x00000100, 503 .boot_params = 0x00000100,
506 .map_io = ap_map_io, 504 .map_io = ap_map_io,
507 .reserve = integrator_reserve, 505 .reserve = integrator_reserve,
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 05db40e3c4f7..6258c90d020c 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -599,8 +599,6 @@ static struct sys_timer cp_timer = {
599 599
600MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") 600MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
601 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 601 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
602 .phys_io = 0x16000000,
603 .io_pg_offst = ((0xf1600000) >> 18) & 0xfffc,
604 .boot_params = 0x00000100, 602 .boot_params = 0x00000100,
605 .map_io = intcp_map_io, 603 .map_io = intcp_map_io,
606 .reserve = integrator_reserve, 604 .reserve = integrator_reserve,
diff --git a/arch/arm/mach-iop13xx/include/mach/debug-macro.S b/arch/arm/mach-iop13xx/include/mach/debug-macro.S
index c9d6ba46963d..e664466d51bf 100644
--- a/arch/arm/mach-iop13xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-iop13xx/include/mach/debug-macro.S
@@ -11,15 +11,13 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x00002300
16 tst \rx, #1 @ mmu enabled? 16 orr \rp, \rp, #0x00000040
17 moveq \rx, #0xff000000 @ physical 17 orr \rv, \rp, #0xfe000000 @ virtual
18 orreq \rx, \rx, #0x00d80000 18 orr \rv, \rv, #0x00e80000
19 movne \rx, #0xfe000000 @ virtual 19 orr \rp, \rp, #0xff000000 @ physical
20 orrne \rx, \rx, #0x00e80000 20 orr \rp, \rp, #0x00d80000
21 orr \rx, \rx, #0x00002300
22 orr \rx, \rx, #0x00000040
23 .endm 21 .endm
24 22
25#define UART_SHIFT 2 23#define UART_SHIFT 2
diff --git a/arch/arm/mach-iop13xx/iq81340mc.c b/arch/arm/mach-iop13xx/iq81340mc.c
index f91f3154577d..9b5a63f5d07d 100644
--- a/arch/arm/mach-iop13xx/iq81340mc.c
+++ b/arch/arm/mach-iop13xx/iq81340mc.c
@@ -91,8 +91,6 @@ static struct sys_timer iq81340mc_timer = {
91 91
92MACHINE_START(IQ81340MC, "Intel IQ81340MC") 92MACHINE_START(IQ81340MC, "Intel IQ81340MC")
93 /* Maintainer: Dan Williams <dan.j.williams@intel.com> */ 93 /* Maintainer: Dan Williams <dan.j.williams@intel.com> */
94 .phys_io = IOP13XX_PMMR_PHYS_MEM_BASE,
95 .io_pg_offst = (IOP13XX_PMMR_VIRT_MEM_BASE >> 18) & 0xfffc,
96 .boot_params = 0x00000100, 94 .boot_params = 0x00000100,
97 .map_io = iop13xx_map_io, 95 .map_io = iop13xx_map_io,
98 .init_irq = iop13xx_init_irq, 96 .init_irq = iop13xx_init_irq,
diff --git a/arch/arm/mach-iop13xx/iq81340sc.c b/arch/arm/mach-iop13xx/iq81340sc.c
index ddb7a3435de9..df3492a9c280 100644
--- a/arch/arm/mach-iop13xx/iq81340sc.c
+++ b/arch/arm/mach-iop13xx/iq81340sc.c
@@ -93,8 +93,6 @@ static struct sys_timer iq81340sc_timer = {
93 93
94MACHINE_START(IQ81340SC, "Intel IQ81340SC") 94MACHINE_START(IQ81340SC, "Intel IQ81340SC")
95 /* Maintainer: Dan Williams <dan.j.williams@intel.com> */ 95 /* Maintainer: Dan Williams <dan.j.williams@intel.com> */
96 .phys_io = IOP13XX_PMMR_PHYS_MEM_BASE,
97 .io_pg_offst = (IOP13XX_PMMR_VIRT_MEM_BASE >> 18) & 0xfffc,
98 .boot_params = 0x00000100, 96 .boot_params = 0x00000100,
99 .map_io = iop13xx_map_io, 97 .map_io = iop13xx_map_io,
100 .init_irq = iop13xx_init_irq, 98 .init_irq = iop13xx_init_irq,
diff --git a/arch/arm/mach-iop13xx/msi.c b/arch/arm/mach-iop13xx/msi.c
index f34b0ed80630..7149fcc16c8a 100644
--- a/arch/arm/mach-iop13xx/msi.c
+++ b/arch/arm/mach-iop13xx/msi.c
@@ -164,10 +164,10 @@ static void iop13xx_msi_nop(unsigned int irq)
164static struct irq_chip iop13xx_msi_chip = { 164static struct irq_chip iop13xx_msi_chip = {
165 .name = "PCI-MSI", 165 .name = "PCI-MSI",
166 .ack = iop13xx_msi_nop, 166 .ack = iop13xx_msi_nop,
167 .enable = unmask_msi_irq, 167 .irq_enable = unmask_msi_irq,
168 .disable = mask_msi_irq, 168 .irq_disable = mask_msi_irq,
169 .mask = mask_msi_irq, 169 .irq_mask = mask_msi_irq,
170 .unmask = unmask_msi_irq, 170 .irq_unmask = unmask_msi_irq,
171}; 171};
172 172
173int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) 173int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
diff --git a/arch/arm/mach-iop32x/em7210.c b/arch/arm/mach-iop32x/em7210.c
index 2bef9b6e1cc9..779f924af302 100644
--- a/arch/arm/mach-iop32x/em7210.c
+++ b/arch/arm/mach-iop32x/em7210.c
@@ -203,8 +203,6 @@ static void __init em7210_init_machine(void)
203} 203}
204 204
205MACHINE_START(EM7210, "Lanner EM7210") 205MACHINE_START(EM7210, "Lanner EM7210")
206 .phys_io = IQ31244_UART,
207 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
208 .boot_params = 0xa0000100, 206 .boot_params = 0xa0000100,
209 .map_io = em7210_map_io, 207 .map_io = em7210_map_io,
210 .init_irq = iop32x_init_irq, 208 .init_irq = iop32x_init_irq,
diff --git a/arch/arm/mach-iop32x/glantank.c b/arch/arm/mach-iop32x/glantank.c
index 10384fc37cb2..c6b6f9c5650d 100644
--- a/arch/arm/mach-iop32x/glantank.c
+++ b/arch/arm/mach-iop32x/glantank.c
@@ -207,8 +207,6 @@ static void __init glantank_init_machine(void)
207 207
208MACHINE_START(GLANTANK, "GLAN Tank") 208MACHINE_START(GLANTANK, "GLAN Tank")
209 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 209 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
210 .phys_io = GLANTANK_UART,
211 .io_pg_offst = ((GLANTANK_UART) >> 18) & 0xfffc,
212 .boot_params = 0xa0000100, 210 .boot_params = 0xa0000100,
213 .map_io = glantank_map_io, 211 .map_io = glantank_map_io,
214 .init_irq = iop32x_init_irq, 212 .init_irq = iop32x_init_irq,
diff --git a/arch/arm/mach-iop32x/include/mach/debug-macro.S b/arch/arm/mach-iop32x/include/mach/debug-macro.S
index 736afe1edd1f..ff9e76c09f35 100644
--- a/arch/arm/mach-iop32x/include/mach/debug-macro.S
+++ b/arch/arm/mach-iop32x/include/mach/debug-macro.S
@@ -11,9 +11,10 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mov \rx, #0xfe000000 @ physical as well as virtual 15 mov \rp, #0xfe000000 @ physical as well as virtual
16 orr \rx, \rx, #0x00800000 @ location of the UART 16 orr \rp, \rp, #0x00800000 @ location of the UART
17 mov \rv, \rp
17 .endm 18 .endm
18 19
19#define UART_SHIFT 0 20#define UART_SHIFT 0
diff --git a/arch/arm/mach-iop32x/iq31244.c b/arch/arm/mach-iop32x/iq31244.c
index d6ac85ff109d..fde962c057f0 100644
--- a/arch/arm/mach-iop32x/iq31244.c
+++ b/arch/arm/mach-iop32x/iq31244.c
@@ -313,8 +313,6 @@ __setup("force_ep80219", force_ep80219_setup);
313 313
314MACHINE_START(IQ31244, "Intel IQ31244") 314MACHINE_START(IQ31244, "Intel IQ31244")
315 /* Maintainer: Intel Corp. */ 315 /* Maintainer: Intel Corp. */
316 .phys_io = IQ31244_UART,
317 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
318 .boot_params = 0xa0000100, 316 .boot_params = 0xa0000100,
319 .map_io = iq31244_map_io, 317 .map_io = iq31244_map_io,
320 .init_irq = iop32x_init_irq, 318 .init_irq = iop32x_init_irq,
@@ -329,8 +327,6 @@ MACHINE_END
329 */ 327 */
330MACHINE_START(EP80219, "Intel EP80219") 328MACHINE_START(EP80219, "Intel EP80219")
331 /* Maintainer: Intel Corp. */ 329 /* Maintainer: Intel Corp. */
332 .phys_io = IQ31244_UART,
333 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
334 .boot_params = 0xa0000100, 330 .boot_params = 0xa0000100,
335 .map_io = iq31244_map_io, 331 .map_io = iq31244_map_io,
336 .init_irq = iop32x_init_irq, 332 .init_irq = iop32x_init_irq,
diff --git a/arch/arm/mach-iop32x/iq80321.c b/arch/arm/mach-iop32x/iq80321.c
index c6a0e4ee9d91..3a95950e8737 100644
--- a/arch/arm/mach-iop32x/iq80321.c
+++ b/arch/arm/mach-iop32x/iq80321.c
@@ -186,8 +186,6 @@ static void __init iq80321_init_machine(void)
186 186
187MACHINE_START(IQ80321, "Intel IQ80321") 187MACHINE_START(IQ80321, "Intel IQ80321")
188 /* Maintainer: Intel Corp. */ 188 /* Maintainer: Intel Corp. */
189 .phys_io = IQ80321_UART,
190 .io_pg_offst = ((IQ80321_UART) >> 18) & 0xfffc,
191 .boot_params = 0xa0000100, 189 .boot_params = 0xa0000100,
192 .map_io = iq80321_map_io, 190 .map_io = iq80321_map_io,
193 .init_irq = iop32x_init_irq, 191 .init_irq = iop32x_init_irq,
diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c
index f108a31afc2b..626aa375915d 100644
--- a/arch/arm/mach-iop32x/n2100.c
+++ b/arch/arm/mach-iop32x/n2100.c
@@ -327,8 +327,6 @@ static void __init n2100_init_machine(void)
327 327
328MACHINE_START(N2100, "Thecus N2100") 328MACHINE_START(N2100, "Thecus N2100")
329 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 329 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
330 .phys_io = N2100_UART,
331 .io_pg_offst = ((N2100_UART) >> 18) & 0xfffc,
332 .boot_params = 0xa0000100, 330 .boot_params = 0xa0000100,
333 .map_io = n2100_map_io, 331 .map_io = n2100_map_io,
334 .init_irq = iop32x_init_irq, 332 .init_irq = iop32x_init_irq,
diff --git a/arch/arm/mach-iop33x/include/mach/debug-macro.S b/arch/arm/mach-iop33x/include/mach/debug-macro.S
index addb2da78422..40c500dd1fac 100644
--- a/arch/arm/mach-iop33x/include/mach/debug-macro.S
+++ b/arch/arm/mach-iop33x/include/mach/debug-macro.S
@@ -11,13 +11,11 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x00ff0000
16 tst \rx, #1 @ mmu enabled? 16 orr \rp, \rp, #0x0000f700
17 moveq \rx, #0xff000000 @ physical 17 orr \rv, #0xfe000000 @ virtual
18 movne \rx, #0xfe000000 @ virtual 18 orr \rp, #0xff000000 @ physical
19 orr \rx, \rx, #0x00ff0000
20 orr \rx, \rx, #0x0000f700
21 .endm 19 .endm
22 20
23#define UART_SHIFT 2 21#define UART_SHIFT 2
diff --git a/arch/arm/mach-iop33x/iq80331.c b/arch/arm/mach-iop33x/iq80331.c
index c6ff5523b380..c565f8d1e3a4 100644
--- a/arch/arm/mach-iop33x/iq80331.c
+++ b/arch/arm/mach-iop33x/iq80331.c
@@ -141,8 +141,6 @@ static void __init iq80331_init_machine(void)
141 141
142MACHINE_START(IQ80331, "Intel IQ80331") 142MACHINE_START(IQ80331, "Intel IQ80331")
143 /* Maintainer: Intel Corp. */ 143 /* Maintainer: Intel Corp. */
144 .phys_io = 0xfefff000,
145 .io_pg_offst = ((0xfffff000) >> 18) & 0xfffc,
146 .boot_params = 0x00000100, 144 .boot_params = 0x00000100,
147 .map_io = iop3xx_map_io, 145 .map_io = iop3xx_map_io,
148 .init_irq = iop33x_init_irq, 146 .init_irq = iop33x_init_irq,
diff --git a/arch/arm/mach-iop33x/iq80332.c b/arch/arm/mach-iop33x/iq80332.c
index fbf551409394..36a9efb254c2 100644
--- a/arch/arm/mach-iop33x/iq80332.c
+++ b/arch/arm/mach-iop33x/iq80332.c
@@ -141,8 +141,6 @@ static void __init iq80332_init_machine(void)
141 141
142MACHINE_START(IQ80332, "Intel IQ80332") 142MACHINE_START(IQ80332, "Intel IQ80332")
143 /* Maintainer: Intel Corp. */ 143 /* Maintainer: Intel Corp. */
144 .phys_io = 0xfefff000,
145 .io_pg_offst = ((0xfffff000) >> 18) & 0xfffc,
146 .boot_params = 0x00000100, 144 .boot_params = 0x00000100,
147 .map_io = iop3xx_map_io, 145 .map_io = iop3xx_map_io,
148 .init_irq = iop33x_init_irq, 146 .init_irq = iop33x_init_irq,
diff --git a/arch/arm/mach-ixp2000/enp2611.c b/arch/arm/mach-ixp2000/enp2611.c
index 1a557e0d055b..88663ab1d2ad 100644
--- a/arch/arm/mach-ixp2000/enp2611.c
+++ b/arch/arm/mach-ixp2000/enp2611.c
@@ -253,8 +253,6 @@ static void __init enp2611_init_machine(void)
253 253
254MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board") 254MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board")
255 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 255 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
256 .phys_io = IXP2000_UART_PHYS_BASE,
257 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
258 .boot_params = 0x00000100, 256 .boot_params = 0x00000100,
259 .map_io = enp2611_map_io, 257 .map_io = enp2611_map_io,
260 .init_irq = ixp2000_init_irq, 258 .init_irq = ixp2000_init_irq,
diff --git a/arch/arm/mach-ixp2000/include/mach/debug-macro.S b/arch/arm/mach-ixp2000/include/mach/debug-macro.S
index 6a827681680f..0ef533b20972 100644
--- a/arch/arm/mach-ixp2000/include/mach/debug-macro.S
+++ b/arch/arm/mach-ixp2000/include/mach/debug-macro.S
@@ -11,16 +11,14 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x00030000
16 tst \rx, #1 @ MMU enabled?
17 moveq \rx, #0xc0000000 @ Physical base
18 movne \rx, #0xfe000000 @ virtual base
19 orrne \rx, \rx, #0x00f00000
20 orr \rx, \rx, #0x00030000
21#ifdef __ARMEB__ 16#ifdef __ARMEB__
22 orr \rx, \rx, #0x00000003 17 orr \rp, \rp, #0x00000003
23#endif 18#endif
19 orr \rv, \rp, #0xfe000000 @ virtual base
20 orr \rv, \rv, #0x00f00000
21 orr \rp, \rp, #0xc0000000 @ Physical base
24 .endm 22 .endm
25 23
26#define UART_SHIFT 2 24#define UART_SHIFT 2
diff --git a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
index 55e5c69352ad..dfffc1e817fa 100644
--- a/arch/arm/mach-ixp2000/ixdp2400.c
+++ b/arch/arm/mach-ixp2000/ixdp2400.c
@@ -170,8 +170,6 @@ void __init ixdp2400_init_irq(void)
170 170
171MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform") 171MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform")
172 /* Maintainer: MontaVista Software, Inc. */ 172 /* Maintainer: MontaVista Software, Inc. */
173 .phys_io = IXP2000_UART_PHYS_BASE,
174 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
175 .boot_params = 0x00000100, 173 .boot_params = 0x00000100,
176 .map_io = ixdp2x00_map_io, 174 .map_io = ixdp2x00_map_io,
177 .init_irq = ixdp2400_init_irq, 175 .init_irq = ixdp2400_init_irq,
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index 237b61a85e9a..cd4c9bcff2b5 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -285,8 +285,6 @@ void __init ixdp2800_init_irq(void)
285 285
286MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform") 286MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform")
287 /* Maintainer: MontaVista Software, Inc. */ 287 /* Maintainer: MontaVista Software, Inc. */
288 .phys_io = IXP2000_UART_PHYS_BASE,
289 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
290 .boot_params = 0x00000100, 288 .boot_params = 0x00000100,
291 .map_io = ixdp2x00_map_io, 289 .map_io = ixdp2x00_map_io,
292 .init_irq = ixdp2800_init_irq, 290 .init_irq = ixdp2800_init_irq,
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
index 0369ec4242a6..6c121bdbe311 100644
--- a/arch/arm/mach-ixp2000/ixdp2x01.c
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c
@@ -416,8 +416,6 @@ static void __init ixdp2x01_init_machine(void)
416#ifdef CONFIG_ARCH_IXDP2401 416#ifdef CONFIG_ARCH_IXDP2401
417MACHINE_START(IXDP2401, "Intel IXDP2401 Development Platform") 417MACHINE_START(IXDP2401, "Intel IXDP2401 Development Platform")
418 /* Maintainer: MontaVista Software, Inc. */ 418 /* Maintainer: MontaVista Software, Inc. */
419 .phys_io = IXP2000_UART_PHYS_BASE,
420 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
421 .boot_params = 0x00000100, 419 .boot_params = 0x00000100,
422 .map_io = ixdp2x01_map_io, 420 .map_io = ixdp2x01_map_io,
423 .init_irq = ixdp2x01_init_irq, 421 .init_irq = ixdp2x01_init_irq,
@@ -429,8 +427,6 @@ MACHINE_END
429#ifdef CONFIG_ARCH_IXDP2801 427#ifdef CONFIG_ARCH_IXDP2801
430MACHINE_START(IXDP2801, "Intel IXDP2801 Development Platform") 428MACHINE_START(IXDP2801, "Intel IXDP2801 Development Platform")
431 /* Maintainer: MontaVista Software, Inc. */ 429 /* Maintainer: MontaVista Software, Inc. */
432 .phys_io = IXP2000_UART_PHYS_BASE,
433 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
434 .boot_params = 0x00000100, 430 .boot_params = 0x00000100,
435 .map_io = ixdp2x01_map_io, 431 .map_io = ixdp2x01_map_io,
436 .init_irq = ixdp2x01_init_irq, 432 .init_irq = ixdp2x01_init_irq,
@@ -444,8 +440,6 @@ MACHINE_END
444 */ 440 */
445MACHINE_START(IXDP28X5, "Intel IXDP2805/2855 Development Platform") 441MACHINE_START(IXDP28X5, "Intel IXDP2805/2855 Development Platform")
446 /* Maintainer: MontaVista Software, Inc. */ 442 /* Maintainer: MontaVista Software, Inc. */
447 .phys_io = IXP2000_UART_PHYS_BASE,
448 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
449 .boot_params = 0x00000100, 443 .boot_params = 0x00000100,
450 .map_io = ixdp2x01_map_io, 444 .map_io = ixdp2x01_map_io,
451 .init_irq = ixdp2x01_init_irq, 445 .init_irq = ixdp2x01_init_irq,
diff --git a/arch/arm/mach-ixp23xx/espresso.c b/arch/arm/mach-ixp23xx/espresso.c
index 1c06bfc5a7ef..e25e5fe183ba 100644
--- a/arch/arm/mach-ixp23xx/espresso.c
+++ b/arch/arm/mach-ixp23xx/espresso.c
@@ -85,8 +85,6 @@ static void __init espresso_init(void)
85 85
86MACHINE_START(ESPRESSO, "IP Fabrics Double Espresso") 86MACHINE_START(ESPRESSO, "IP Fabrics Double Espresso")
87 /* Maintainer: Lennert Buytenhek */ 87 /* Maintainer: Lennert Buytenhek */
88 .phys_io = IXP23XX_PERIPHERAL_PHYS,
89 .io_pg_offst = ((IXP23XX_PERIPHERAL_VIRT >> 18)) & 0xfffc,
90 .map_io = ixp23xx_map_io, 88 .map_io = ixp23xx_map_io,
91 .init_irq = ixp23xx_init_irq, 89 .init_irq = ixp23xx_init_irq,
92 .timer = &ixp23xx_timer, 90 .timer = &ixp23xx_timer,
diff --git a/arch/arm/mach-ixp23xx/include/mach/debug-macro.S b/arch/arm/mach-ixp23xx/include/mach/debug-macro.S
index a82e375465e2..f7c6eef7fa22 100644
--- a/arch/arm/mach-ixp23xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-ixp23xx/include/mach/debug-macro.S
@@ -12,13 +12,12 @@
12 */ 12 */
13#include <mach/ixp23xx.h> 13#include <mach/ixp23xx.h>
14 14
15 .macro addruart, rx, tmp 15 .macro addruart, rp, rv
16 mrc p15, 0, \rx, c1, c0 16 ldr \rp, =IXP23XX_PERIPHERAL_PHYS @ physical
17 tst \rx, #1 @ mmu enabled? 17 ldr \rv, =IXP23XX_PERIPHERAL_VIRT @ virtual
18 ldreq \rx, =IXP23XX_PERIPHERAL_PHYS @ physical
19 ldrne \rx, =IXP23XX_PERIPHERAL_VIRT @ virtual
20#ifdef __ARMEB__ 18#ifdef __ARMEB__
21 orr \rx, \rx, #0x00000003 19 orr \rp, \rp, #0x00000003
20 orr \rv, \rv, #0x00000003
22#endif 21#endif
23 .endm 22 .endm
24 23
diff --git a/arch/arm/mach-ixp23xx/ixdp2351.c b/arch/arm/mach-ixp23xx/ixdp2351.c
index f1b124a709ab..664e39c2a903 100644
--- a/arch/arm/mach-ixp23xx/ixdp2351.c
+++ b/arch/arm/mach-ixp23xx/ixdp2351.c
@@ -328,8 +328,6 @@ static void __init ixdp2351_init(void)
328 328
329MACHINE_START(IXDP2351, "Intel IXDP2351 Development Platform") 329MACHINE_START(IXDP2351, "Intel IXDP2351 Development Platform")
330 /* Maintainer: MontaVista Software, Inc. */ 330 /* Maintainer: MontaVista Software, Inc. */
331 .phys_io = IXP23XX_PERIPHERAL_PHYS,
332 .io_pg_offst = ((IXP23XX_PERIPHERAL_VIRT >> 18)) & 0xfffc,
333 .map_io = ixdp2351_map_io, 331 .map_io = ixdp2351_map_io,
334 .init_irq = ixdp2351_init_irq, 332 .init_irq = ixdp2351_init_irq,
335 .timer = &ixp23xx_timer, 333 .timer = &ixp23xx_timer,
diff --git a/arch/arm/mach-ixp23xx/roadrunner.c b/arch/arm/mach-ixp23xx/roadrunner.c
index 6d38d769761c..76c61ba73218 100644
--- a/arch/arm/mach-ixp23xx/roadrunner.c
+++ b/arch/arm/mach-ixp23xx/roadrunner.c
@@ -171,8 +171,6 @@ static void __init roadrunner_init(void)
171 171
172MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform") 172MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform")
173 /* Maintainer: Deepak Saxena */ 173 /* Maintainer: Deepak Saxena */
174 .phys_io = IXP23XX_PERIPHERAL_PHYS,
175 .io_pg_offst = ((IXP23XX_PERIPHERAL_VIRT >> 18)) & 0xfffc,
176 .map_io = ixp23xx_map_io, 174 .map_io = ixp23xx_map_io,
177 .init_irq = ixp23xx_init_irq, 175 .init_irq = ixp23xx_init_irq,
178 .timer = &ixp23xx_timer, 176 .timer = &ixp23xx_timer,
diff --git a/arch/arm/mach-ixp4xx/avila-setup.c b/arch/arm/mach-ixp4xx/avila-setup.c
index d8bc86d76f1d..73745ff102d5 100644
--- a/arch/arm/mach-ixp4xx/avila-setup.c
+++ b/arch/arm/mach-ixp4xx/avila-setup.c
@@ -164,8 +164,6 @@ static void __init avila_init(void)
164 164
165MACHINE_START(AVILA, "Gateworks Avila Network Platform") 165MACHINE_START(AVILA, "Gateworks Avila Network Platform")
166 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */ 166 /* Maintainer: Deepak Saxena <dsaxena@plexity.net> */
167 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
168 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
169 .map_io = ixp4xx_map_io, 167 .map_io = ixp4xx_map_io,
170 .init_irq = ixp4xx_init_irq, 168 .init_irq = ixp4xx_init_irq,
171 .timer = &ixp4xx_timer, 169 .timer = &ixp4xx_timer,
@@ -181,8 +179,6 @@ MACHINE_END
181#ifdef CONFIG_MACH_LOFT 179#ifdef CONFIG_MACH_LOFT
182MACHINE_START(LOFT, "Giant Shoulder Inc Loft board") 180MACHINE_START(LOFT, "Giant Shoulder Inc Loft board")
183 /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */ 181 /* Maintainer: Tom Billman <kernel@giantshoulderinc.com> */
184 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
185 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
186 .map_io = ixp4xx_map_io, 182 .map_io = ixp4xx_map_io,
187 .init_irq = ixp4xx_init_irq, 183 .init_irq = ixp4xx_init_irq,
188 .timer = &ixp4xx_timer, 184 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c
index 31a47f6a8939..355e3de38733 100644
--- a/arch/arm/mach-ixp4xx/coyote-setup.c
+++ b/arch/arm/mach-ixp4xx/coyote-setup.c
@@ -109,8 +109,6 @@ static void __init coyote_init(void)
109#ifdef CONFIG_ARCH_ADI_COYOTE 109#ifdef CONFIG_ARCH_ADI_COYOTE
110MACHINE_START(ADI_COYOTE, "ADI Engineering Coyote") 110MACHINE_START(ADI_COYOTE, "ADI Engineering Coyote")
111 /* Maintainer: MontaVista Software, Inc. */ 111 /* Maintainer: MontaVista Software, Inc. */
112 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
113 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
114 .map_io = ixp4xx_map_io, 112 .map_io = ixp4xx_map_io,
115 .init_irq = ixp4xx_init_irq, 113 .init_irq = ixp4xx_init_irq,
116 .timer = &ixp4xx_timer, 114 .timer = &ixp4xx_timer,
@@ -126,8 +124,6 @@ MACHINE_END
126#ifdef CONFIG_MACH_IXDPG425 124#ifdef CONFIG_MACH_IXDPG425
127MACHINE_START(IXDPG425, "Intel IXDPG425") 125MACHINE_START(IXDPG425, "Intel IXDPG425")
128 /* Maintainer: MontaVista Software, Inc. */ 126 /* Maintainer: MontaVista Software, Inc. */
129 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
130 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
131 .map_io = ixp4xx_map_io, 127 .map_io = ixp4xx_map_io,
132 .init_irq = ixp4xx_init_irq, 128 .init_irq = ixp4xx_init_irq,
133 .timer = &ixp4xx_timer, 129 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
index 7c1fa54a6145..d398229cfaa5 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
@@ -279,8 +279,6 @@ static void __init dsmg600_init(void)
279 279
280MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") 280MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
281 /* Maintainer: www.nslu2-linux.org */ 281 /* Maintainer: www.nslu2-linux.org */
282 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
283 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
284 .boot_params = 0x00000100, 282 .boot_params = 0x00000100,
285 .map_io = ixp4xx_map_io, 283 .map_io = ixp4xx_map_io,
286 .init_irq = ixp4xx_init_irq, 284 .init_irq = ixp4xx_init_irq,
diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c
index e7f4befba422..727ee39ce11c 100644
--- a/arch/arm/mach-ixp4xx/fsg-setup.c
+++ b/arch/arm/mach-ixp4xx/fsg-setup.c
@@ -270,8 +270,6 @@ static void __init fsg_init(void)
270 270
271MACHINE_START(FSG, "Freecom FSG-3") 271MACHINE_START(FSG, "Freecom FSG-3")
272 /* Maintainer: www.nslu2-linux.org */ 272 /* Maintainer: www.nslu2-linux.org */
273 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
274 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
275 .map_io = ixp4xx_map_io, 273 .map_io = ixp4xx_map_io,
276 .init_irq = ixp4xx_init_irq, 274 .init_irq = ixp4xx_init_irq,
277 .timer = &ixp4xx_timer, 275 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/gateway7001-setup.c b/arch/arm/mach-ixp4xx/gateway7001-setup.c
index 2583b2a13174..9dc0b4eaa65a 100644
--- a/arch/arm/mach-ixp4xx/gateway7001-setup.c
+++ b/arch/arm/mach-ixp4xx/gateway7001-setup.c
@@ -96,8 +96,6 @@ static void __init gateway7001_init(void)
96#ifdef CONFIG_MACH_GATEWAY7001 96#ifdef CONFIG_MACH_GATEWAY7001
97MACHINE_START(GATEWAY7001, "Gateway 7001 AP") 97MACHINE_START(GATEWAY7001, "Gateway 7001 AP")
98 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */ 98 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
99 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
100 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
101 .map_io = ixp4xx_map_io, 99 .map_io = ixp4xx_map_io,
102 .init_irq = ixp4xx_init_irq, 100 .init_irq = ixp4xx_init_irq,
103 .timer = &ixp4xx_timer, 101 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/goramo_mlr.c b/arch/arm/mach-ixp4xx/goramo_mlr.c
index 1c28048209c1..d0e4861ac03d 100644
--- a/arch/arm/mach-ixp4xx/goramo_mlr.c
+++ b/arch/arm/mach-ixp4xx/goramo_mlr.c
@@ -496,8 +496,6 @@ subsys_initcall(gmlr_pci_init);
496 496
497MACHINE_START(GORAMO_MLR, "MultiLink") 497MACHINE_START(GORAMO_MLR, "MultiLink")
498 /* Maintainer: Krzysztof Halasa */ 498 /* Maintainer: Krzysztof Halasa */
499 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
500 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
501 .map_io = ixp4xx_map_io, 499 .map_io = ixp4xx_map_io,
502 .init_irq = ixp4xx_init_irq, 500 .init_irq = ixp4xx_init_irq,
503 .timer = &ixp4xx_timer, 501 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/gtwx5715-setup.c b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
index c67586b79400..77abead36227 100644
--- a/arch/arm/mach-ixp4xx/gtwx5715-setup.c
+++ b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
@@ -164,8 +164,6 @@ static void __init gtwx5715_init(void)
164 164
165MACHINE_START(GTWX5715, "Gemtek GTWX5715 (Linksys WRV54G)") 165MACHINE_START(GTWX5715, "Gemtek GTWX5715 (Linksys WRV54G)")
166 /* Maintainer: George Joseph */ 166 /* Maintainer: George Joseph */
167 .phys_io = IXP4XX_UART2_BASE_PHYS,
168 .io_pg_offst = ((IXP4XX_UART2_BASE_VIRT) >> 18) & 0xfffc,
169 .map_io = ixp4xx_map_io, 167 .map_io = ixp4xx_map_io,
170 .init_irq = ixp4xx_init_irq, 168 .init_irq = ixp4xx_init_irq,
171 .timer = &ixp4xx_timer, 169 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/include/mach/debug-macro.S b/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
index 3fc66d6d00a0..b974a49c0aff 100644
--- a/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-ixp4xx/include/mach/debug-macro.S
@@ -10,16 +10,16 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11*/ 11*/
12 12
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 mrc p15, 0, \rx, c1, c0
15 tst \rx, #1 @ MMU enabled?
16 moveq \rx, #0xc8000000
17 movne \rx, #0xff000000
18 orrne \rx, \rx, #0x00b00000
19#ifdef __ARMEB__ 14#ifdef __ARMEB__
20 add \rx,\rx,#3 @ Uart regs are at off set of 3 if 15 mov \rp, #3 @ Uart regs are at off set of 3 if
21 @ byte writes used - Big Endian. 16 @ byte writes used - Big Endian.
17#else
18 mov \rp, #0
22#endif 19#endif
20 orr \rv, \rp, #0xff000000 @ virtual
21 orr \rv, \rv, #0x00b00000
22 orr \rp, \rp, #0xc8000000 @ physical
23 .endm 23 .endm
24 24
25#define UART_SHIFT 2 25#define UART_SHIFT 2
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index ea9ee4ed0a3e..140783386785 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -257,8 +257,6 @@ static void __init ixdp425_init(void)
257#ifdef CONFIG_ARCH_IXDP425 257#ifdef CONFIG_ARCH_IXDP425
258MACHINE_START(IXDP425, "Intel IXDP425 Development Platform") 258MACHINE_START(IXDP425, "Intel IXDP425 Development Platform")
259 /* Maintainer: MontaVista Software, Inc. */ 259 /* Maintainer: MontaVista Software, Inc. */
260 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
261 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
262 .map_io = ixp4xx_map_io, 260 .map_io = ixp4xx_map_io,
263 .init_irq = ixp4xx_init_irq, 261 .init_irq = ixp4xx_init_irq,
264 .timer = &ixp4xx_timer, 262 .timer = &ixp4xx_timer,
@@ -270,8 +268,6 @@ MACHINE_END
270#ifdef CONFIG_MACH_IXDP465 268#ifdef CONFIG_MACH_IXDP465
271MACHINE_START(IXDP465, "Intel IXDP465 Development Platform") 269MACHINE_START(IXDP465, "Intel IXDP465 Development Platform")
272 /* Maintainer: MontaVista Software, Inc. */ 270 /* Maintainer: MontaVista Software, Inc. */
273 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
274 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
275 .map_io = ixp4xx_map_io, 271 .map_io = ixp4xx_map_io,
276 .init_irq = ixp4xx_init_irq, 272 .init_irq = ixp4xx_init_irq,
277 .timer = &ixp4xx_timer, 273 .timer = &ixp4xx_timer,
@@ -283,8 +279,6 @@ MACHINE_END
283#ifdef CONFIG_ARCH_PRPMC1100 279#ifdef CONFIG_ARCH_PRPMC1100
284MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform") 280MACHINE_START(IXCDP1100, "Intel IXCDP1100 Development Platform")
285 /* Maintainer: MontaVista Software, Inc. */ 281 /* Maintainer: MontaVista Software, Inc. */
286 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
287 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
288 .map_io = ixp4xx_map_io, 282 .map_io = ixp4xx_map_io,
289 .init_irq = ixp4xx_init_irq, 283 .init_irq = ixp4xx_init_irq,
290 .timer = &ixp4xx_timer, 284 .timer = &ixp4xx_timer,
@@ -296,8 +290,6 @@ MACHINE_END
296#ifdef CONFIG_MACH_KIXRP435 290#ifdef CONFIG_MACH_KIXRP435
297MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform") 291MACHINE_START(KIXRP435, "Intel KIXRP435 Reference Platform")
298 /* Maintainer: MontaVista Software, Inc. */ 292 /* Maintainer: MontaVista Software, Inc. */
299 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
300 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
301 .map_io = ixp4xx_map_io, 293 .map_io = ixp4xx_map_io,
302 .init_irq = ixp4xx_init_irq, 294 .init_irq = ixp4xx_init_irq,
303 .timer = &ixp4xx_timer, 295 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index e3ee880aa1e6..f18fee748878 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -314,8 +314,6 @@ static void __init nas100d_init(void)
314 314
315MACHINE_START(NAS100D, "Iomega NAS 100d") 315MACHINE_START(NAS100D, "Iomega NAS 100d")
316 /* Maintainer: www.nslu2-linux.org */ 316 /* Maintainer: www.nslu2-linux.org */
317 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
318 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
319 .boot_params = 0x00000100, 317 .boot_params = 0x00000100,
320 .map_io = ixp4xx_map_io, 318 .map_io = ixp4xx_map_io,
321 .init_irq = ixp4xx_init_irq, 319 .init_irq = ixp4xx_init_irq,
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index c14e0034be4b..f79b62eb7614 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -300,8 +300,6 @@ static void __init nslu2_init(void)
300 300
301MACHINE_START(NSLU2, "Linksys NSLU2") 301MACHINE_START(NSLU2, "Linksys NSLU2")
302 /* Maintainer: www.nslu2-linux.org */ 302 /* Maintainer: www.nslu2-linux.org */
303 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
304 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
305 .boot_params = 0x00000100, 303 .boot_params = 0x00000100,
306 .map_io = ixp4xx_map_io, 304 .map_io = ixp4xx_map_io,
307 .init_irq = ixp4xx_init_irq, 305 .init_irq = ixp4xx_init_irq,
diff --git a/arch/arm/mach-ixp4xx/vulcan-setup.c b/arch/arm/mach-ixp4xx/vulcan-setup.c
index 465cc5cce687..4e72cfdd3c46 100644
--- a/arch/arm/mach-ixp4xx/vulcan-setup.c
+++ b/arch/arm/mach-ixp4xx/vulcan-setup.c
@@ -236,8 +236,6 @@ static void __init vulcan_init(void)
236 236
237MACHINE_START(ARCOM_VULCAN, "Arcom/Eurotech Vulcan") 237MACHINE_START(ARCOM_VULCAN, "Arcom/Eurotech Vulcan")
238 /* Maintainer: Marc Zyngier <maz@misterjones.org> */ 238 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
239 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
240 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
241 .map_io = ixp4xx_map_io, 239 .map_io = ixp4xx_map_io,
242 .init_irq = ixp4xx_init_irq, 240 .init_irq = ixp4xx_init_irq,
243 .timer = &ixp4xx_timer, 241 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-ixp4xx/wg302v2-setup.c b/arch/arm/mach-ixp4xx/wg302v2-setup.c
index 4dd74863daa9..5d148c7bc4fb 100644
--- a/arch/arm/mach-ixp4xx/wg302v2-setup.c
+++ b/arch/arm/mach-ixp4xx/wg302v2-setup.c
@@ -97,8 +97,6 @@ static void __init wg302v2_init(void)
97#ifdef CONFIG_MACH_WG302V2 97#ifdef CONFIG_MACH_WG302V2
98MACHINE_START(WG302V2, "Netgear WG302 v2 / WAG302 v2") 98MACHINE_START(WG302V2, "Netgear WG302 v2 / WAG302 v2")
99 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */ 99 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
100 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
101 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
102 .map_io = ixp4xx_map_io, 100 .map_io = ixp4xx_map_io,
103 .init_irq = ixp4xx_init_irq, 101 .init_irq = ixp4xx_init_irq,
104 .timer = &ixp4xx_timer, 102 .timer = &ixp4xx_timer,
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index cc25501b57fa..34106335c728 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -58,6 +58,12 @@ config MACH_TS41X
58 QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS 58 QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS
59 devices. 59 devices.
60 60
61config MACH_DOCKSTAR
62 bool "Seagate FreeAgent DockStar"
63 help
64 Say 'Y' here if you want your kernel to support the
65 Seagate FreeAgent DockStar.
66
61config MACH_OPENRD 67config MACH_OPENRD
62 bool 68 bool
63 69
@@ -100,6 +106,12 @@ config MACH_NETSPACE_MAX_V2
100 Say 'Y' here if you want your kernel to support the 106 Say 'Y' here if you want your kernel to support the
101 LaCie Network Space Max v2 NAS. 107 LaCie Network Space Max v2 NAS.
102 108
109config MACH_D2NET_V2
110 bool "LaCie d2 Network v2 NAS Board"
111 help
112 Say 'Y' here if you want your kernel to support the
113 LaCie d2 Network v2 NAS.
114
103config MACH_NET2BIG_V2 115config MACH_NET2BIG_V2
104 bool "LaCie 2Big Network v2 NAS Board" 116 bool "LaCie 2Big Network v2 NAS Board"
105 help 117 help
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 295d7baa6ae1..5dcaa81a2ec3 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -7,14 +7,16 @@ obj-$(CONFIG_MACH_MV88F6281GTW_GE) += mv88f6281gtw_ge-setup.o
7obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o 7obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o
8obj-$(CONFIG_MACH_ESATA_SHEEVAPLUG) += sheevaplug-setup.o 8obj-$(CONFIG_MACH_ESATA_SHEEVAPLUG) += sheevaplug-setup.o
9obj-$(CONFIG_MACH_GURUPLUG) += guruplug-setup.o 9obj-$(CONFIG_MACH_GURUPLUG) += guruplug-setup.o
10obj-$(CONFIG_MACH_DOCKSTAR) += dockstar-setup.o
10obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o 11obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o
11obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o 12obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o
12obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o 13obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o
13obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o 14obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o lacie_v2-common.o
14obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o 15obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o lacie_v2-common.o
15obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o 16obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o lacie_v2-common.o
16obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o 17obj-$(CONFIG_MACH_D2NET_V2) += d2net_v2-setup.o lacie_v2-common.o
17obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o 18obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
19obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
18obj-$(CONFIG_MACH_T5325) += t5325-setup.o 20obj-$(CONFIG_MACH_T5325) += t5325-setup.o
19 21
20obj-$(CONFIG_CPU_IDLE) += cpuidle.o 22obj-$(CONFIG_CPU_IDLE) += cpuidle.o
diff --git a/arch/arm/mach-kirkwood/d2net_v2-setup.c b/arch/arm/mach-kirkwood/d2net_v2-setup.c
new file mode 100644
index 000000000000..4aa86e4a152c
--- /dev/null
+++ b/arch/arm/mach-kirkwood/d2net_v2-setup.c
@@ -0,0 +1,229 @@
1/*
2 * arch/arm/mach-kirkwood/d2net_v2-setup.c
3 *
4 * LaCie d2 Network Space v2 Board Setup
5 *
6 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.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 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/platform_device.h>
26#include <linux/ata_platform.h>
27#include <linux/mv643xx_eth.h>
28#include <linux/input.h>
29#include <linux/gpio.h>
30#include <linux/gpio_keys.h>
31#include <linux/leds.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <mach/kirkwood.h>
35#include <mach/leds-ns2.h>
36#include "common.h"
37#include "mpp.h"
38#include "lacie_v2-common.h"
39
40/*****************************************************************************
41 * Ethernet
42 ****************************************************************************/
43
44static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {
45 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
46};
47
48/*****************************************************************************
49 * SATA
50 ****************************************************************************/
51
52static struct mv_sata_platform_data d2net_v2_sata_data = {
53 .n_ports = 2,
54};
55
56/*****************************************************************************
57 * GPIO keys
58 ****************************************************************************/
59
60#define D2NET_V2_GPIO_PUSH_BUTTON 34
61#define D2NET_V2_GPIO_POWER_SWITCH_ON 13
62#define D2NET_V2_GPIO_POWER_SWITCH_OFF 15
63
64#define D2NET_V2_SWITCH_POWER_ON 0x1
65#define D2NET_V2_SWITCH_POWER_OFF 0x2
66
67static struct gpio_keys_button d2net_v2_buttons[] = {
68 [0] = {
69 .type = EV_SW,
70 .code = D2NET_V2_SWITCH_POWER_ON,
71 .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,
72 .desc = "Back power switch (on|auto)",
73 .active_low = 0,
74 },
75 [1] = {
76 .type = EV_SW,
77 .code = D2NET_V2_SWITCH_POWER_OFF,
78 .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,
79 .desc = "Back power switch (auto|off)",
80 .active_low = 0,
81 },
82 [2] = {
83 .code = KEY_POWER,
84 .gpio = D2NET_V2_GPIO_PUSH_BUTTON,
85 .desc = "Front Push Button",
86 .active_low = 1,
87 },
88};
89
90static struct gpio_keys_platform_data d2net_v2_button_data = {
91 .buttons = d2net_v2_buttons,
92 .nbuttons = ARRAY_SIZE(d2net_v2_buttons),
93};
94
95static struct platform_device d2net_v2_gpio_buttons = {
96 .name = "gpio-keys",
97 .id = -1,
98 .dev = {
99 .platform_data = &d2net_v2_button_data,
100 },
101};
102
103/*****************************************************************************
104 * GPIO LEDs
105 ****************************************************************************/
106
107#define D2NET_V2_GPIO_RED_LED 12
108
109static struct gpio_led d2net_v2_gpio_led_pins[] = {
110 {
111 .name = "d2net_v2:red:fail",
112 .gpio = D2NET_V2_GPIO_RED_LED,
113 },
114};
115
116static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {
117 .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),
118 .leds = d2net_v2_gpio_led_pins,
119};
120
121static struct platform_device d2net_v2_gpio_leds = {
122 .name = "leds-gpio",
123 .id = -1,
124 .dev = {
125 .platform_data = &d2net_v2_gpio_leds_data,
126 },
127};
128
129/*****************************************************************************
130 * Dual-GPIO CPLD LEDs
131 ****************************************************************************/
132
133#define D2NET_V2_GPIO_BLUE_LED_SLOW 29
134#define D2NET_V2_GPIO_BLUE_LED_CMD 30
135
136static struct ns2_led d2net_v2_led_pins[] = {
137 {
138 .name = "d2net_v2:blue:sata",
139 .cmd = D2NET_V2_GPIO_BLUE_LED_CMD,
140 .slow = D2NET_V2_GPIO_BLUE_LED_SLOW,
141 },
142};
143
144static struct ns2_led_platform_data d2net_v2_leds_data = {
145 .num_leds = ARRAY_SIZE(d2net_v2_led_pins),
146 .leds = d2net_v2_led_pins,
147};
148
149static struct platform_device d2net_v2_leds = {
150 .name = "leds-ns2",
151 .id = -1,
152 .dev = {
153 .platform_data = &d2net_v2_leds_data,
154 },
155};
156
157/*****************************************************************************
158 * General Setup
159 ****************************************************************************/
160
161static unsigned int d2net_v2_mpp_config[] __initdata = {
162 MPP0_SPI_SCn,
163 MPP1_SPI_MOSI,
164 MPP2_SPI_SCK,
165 MPP3_SPI_MISO,
166 MPP6_SYSRST_OUTn,
167 MPP7_GPO, /* Request power-off */
168 MPP8_TW0_SDA,
169 MPP9_TW0_SCK,
170 MPP10_UART0_TXD,
171 MPP11_UART0_RXD,
172 MPP12_GPO, /* Red led */
173 MPP13_GPIO, /* Rear power switch (on|auto) */
174 MPP14_GPIO, /* USB fuse */
175 MPP15_GPIO, /* Rear power switch (auto|off) */
176 MPP16_GPIO, /* SATA 0 power */
177 MPP21_SATA0_ACTn,
178 MPP24_GPIO, /* USB mode select */
179 MPP26_GPIO, /* USB device vbus */
180 MPP28_GPIO, /* USB enable host vbus */
181 MPP29_GPIO, /* Blue led (slow register) */
182 MPP30_GPIO, /* Blue led (command register) */
183 MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */
184 MPP35_GPIO, /* Inhibit power-off */
185 0
186};
187
188#define D2NET_V2_GPIO_POWER_OFF 7
189
190static void d2net_v2_power_off(void)
191{
192 gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);
193}
194
195static void __init d2net_v2_init(void)
196{
197 /*
198 * Basic setup. Needs to be called early.
199 */
200 kirkwood_init();
201 kirkwood_mpp_conf(d2net_v2_mpp_config);
202
203 lacie_v2_hdd_power_init(1);
204
205 kirkwood_ehci_init();
206 kirkwood_ge00_init(&d2net_v2_ge00_data);
207 kirkwood_sata_init(&d2net_v2_sata_data);
208 kirkwood_uart0_init();
209 lacie_v2_register_flash();
210 lacie_v2_register_i2c_devices();
211
212 platform_device_register(&d2net_v2_leds);
213 platform_device_register(&d2net_v2_gpio_leds);
214 platform_device_register(&d2net_v2_gpio_buttons);
215
216 if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&
217 gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0)
218 pm_power_off = d2net_v2_power_off;
219 else
220 pr_err("d2net_v2: failed to configure power-off GPIO\n");
221}
222
223MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
224 .boot_params = 0x00000100,
225 .init_machine = d2net_v2_init,
226 .map_io = kirkwood_map_io,
227 .init_irq = kirkwood_init_irq,
228 .timer = &lacie_v2_timer,
229MACHINE_END
diff --git a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
index 16f6691e7c68..9ea71182d31a 100644
--- a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
+++ b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c
@@ -97,8 +97,6 @@ subsys_initcall(db88f6281_pci_init);
97 97
98MACHINE_START(DB88F6281_BP, "Marvell DB-88F6281-BP Development Board") 98MACHINE_START(DB88F6281_BP, "Marvell DB-88F6281-BP Development Board")
99 /* Maintainer: Saeed Bishara <saeed@marvell.com> */ 99 /* Maintainer: Saeed Bishara <saeed@marvell.com> */
100 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
101 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
102 .boot_params = 0x00000100, 100 .boot_params = 0x00000100,
103 .init_machine = db88f6281_init, 101 .init_machine = db88f6281_init,
104 .map_io = kirkwood_map_io, 102 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/dockstar-setup.c b/arch/arm/mach-kirkwood/dockstar-setup.c
new file mode 100644
index 000000000000..433ea368c060
--- /dev/null
+++ b/arch/arm/mach-kirkwood/dockstar-setup.c
@@ -0,0 +1,110 @@
1/*
2 * arch/arm/mach-kirkwood/dockstar-setup.c
3 *
4 * Seagate FreeAgent DockStar Setup
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
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <linux/ata_platform.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mv643xx_eth.h>
17#include <linux/gpio.h>
18#include <linux/leds.h>
19#include <asm/mach-types.h>
20#include <asm/mach/arch.h>
21#include <mach/kirkwood.h>
22#include <plat/mvsdio.h>
23#include "common.h"
24#include "mpp.h"
25
26static struct mtd_partition dockstar_nand_parts[] = {
27 {
28 .name = "u-boot",
29 .offset = 0,
30 .size = SZ_1M
31 }, {
32 .name = "uImage",
33 .offset = MTDPART_OFS_NXTBLK,
34 .size = SZ_4M
35 }, {
36 .name = "root",
37 .offset = MTDPART_OFS_NXTBLK,
38 .size = MTDPART_SIZ_FULL
39 },
40};
41
42static struct mv643xx_eth_platform_data dockstar_ge00_data = {
43 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
44};
45
46static struct gpio_led dockstar_led_pins[] = {
47 {
48 .name = "dockstar:green:health",
49 .default_trigger = "default-on",
50 .gpio = 46,
51 .active_low = 1,
52 },
53 {
54 .name = "dockstar:orange:misc",
55 .default_trigger = "none",
56 .gpio = 47,
57 .active_low = 1,
58 },
59};
60
61static struct gpio_led_platform_data dockstar_led_data = {
62 .leds = dockstar_led_pins,
63 .num_leds = ARRAY_SIZE(dockstar_led_pins),
64};
65
66static struct platform_device dockstar_leds = {
67 .name = "leds-gpio",
68 .id = -1,
69 .dev = {
70 .platform_data = &dockstar_led_data,
71 }
72};
73
74static unsigned int dockstar_mpp_config[] __initdata = {
75 MPP29_GPIO, /* USB Power Enable */
76 MPP46_GPIO, /* LED green */
77 MPP47_GPIO, /* LED orange */
78 0
79};
80
81static void __init dockstar_init(void)
82{
83 /*
84 * Basic setup. Needs to be called early.
85 */
86 kirkwood_init();
87
88 /* setup gpio pin select */
89 kirkwood_mpp_conf(dockstar_mpp_config);
90
91 kirkwood_uart0_init();
92 kirkwood_nand_init(ARRAY_AND_SIZE(dockstar_nand_parts), 25);
93
94 if (gpio_request(29, "USB Power Enable") != 0 ||
95 gpio_direction_output(29, 1) != 0)
96 printk(KERN_ERR "can't set up GPIO 29 (USB Power Enable)\n");
97 kirkwood_ehci_init();
98
99 kirkwood_ge00_init(&dockstar_ge00_data);
100
101 platform_device_register(&dockstar_leds);
102}
103
104MACHINE_START(DOCKSTAR, "Seagate FreeAgent DockStar")
105 .boot_params = 0x00000100,
106 .init_machine = dockstar_init,
107 .map_io = kirkwood_map_io,
108 .init_irq = kirkwood_init_irq,
109 .timer = &kirkwood_timer,
110MACHINE_END
diff --git a/arch/arm/mach-kirkwood/guruplug-setup.c b/arch/arm/mach-kirkwood/guruplug-setup.c
index 54d07c89d4ff..8f47dc0a2fef 100644
--- a/arch/arm/mach-kirkwood/guruplug-setup.c
+++ b/arch/arm/mach-kirkwood/guruplug-setup.c
@@ -121,8 +121,6 @@ static void __init guruplug_init(void)
121 121
122MACHINE_START(GURUPLUG, "Marvell GuruPlug Reference Board") 122MACHINE_START(GURUPLUG, "Marvell GuruPlug Reference Board")
123 /* Maintainer: Siddarth Gore <gores@marvell.com> */ 123 /* Maintainer: Siddarth Gore <gores@marvell.com> */
124 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
125 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
126 .boot_params = 0x00000100, 124 .boot_params = 0x00000100,
127 .init_machine = guruplug_init, 125 .init_machine = guruplug_init,
128 .map_io = kirkwood_map_io, 126 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/include/mach/debug-macro.S b/arch/arm/mach-kirkwood/include/mach/debug-macro.S
index d0606774dea7..db06ae437d08 100644
--- a/arch/arm/mach-kirkwood/include/mach/debug-macro.S
+++ b/arch/arm/mach-kirkwood/include/mach/debug-macro.S
@@ -8,12 +8,11 @@
8 8
9#include <mach/bridge-regs.h> 9#include <mach/bridge-regs.h>
10 10
11 .macro addruart, rx, tmp 11 .macro addruart, rp, rv
12 mrc p15, 0, \rx, c1, c0 12 ldr \rp, =KIRKWOOD_REGS_PHYS_BASE
13 tst \rx, #1 @ MMU enabled? 13 ldr \rv, =KIRKWOOD_REGS_VIRT_BASE
14 ldreq \rx, =KIRKWOOD_REGS_PHYS_BASE 14 orr \rp, \rp, #0x00012000
15 ldrne \rx, =KIRKWOOD_REGS_VIRT_BASE 15 orr \rv, \rv, #0x00012000
16 orr \rx, \rx, #0x00012000
17 .endm 16 .endm
18 17
19#define UART_SHIFT 2 18#define UART_SHIFT 2
diff --git a/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h b/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h
new file mode 100644
index 000000000000..24b536ebdf13
--- /dev/null
+++ b/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h
@@ -0,0 +1,55 @@
1/*
2 * arch/arm/mach-kirkwood/include/mach/leds-netxbig.h
3 *
4 * Platform data structure for netxbig LED driver
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
11#ifndef __MACH_LEDS_NETXBIG_H
12#define __MACH_LEDS_NETXBIG_H
13
14struct netxbig_gpio_ext {
15 unsigned *addr;
16 int num_addr;
17 unsigned *data;
18 int num_data;
19 unsigned enable;
20};
21
22enum netxbig_led_mode {
23 NETXBIG_LED_OFF,
24 NETXBIG_LED_ON,
25 NETXBIG_LED_SATA,
26 NETXBIG_LED_TIMER1,
27 NETXBIG_LED_TIMER2,
28 NETXBIG_LED_MODE_NUM,
29};
30
31#define NETXBIG_LED_INVALID_MODE NETXBIG_LED_MODE_NUM
32
33struct netxbig_led_timer {
34 unsigned long delay_on;
35 unsigned long delay_off;
36 enum netxbig_led_mode mode;
37};
38
39struct netxbig_led {
40 const char *name;
41 const char *default_trigger;
42 int mode_addr;
43 int *mode_val;
44 int bright_addr;
45};
46
47struct netxbig_led_platform_data {
48 struct netxbig_gpio_ext *gpio_ext;
49 struct netxbig_led_timer *timer;
50 int num_timer;
51 struct netxbig_led *leds;
52 int num_leds;
53};
54
55#endif /* __MACH_LEDS_NETXBIG_H */
diff --git a/arch/arm/mach-kirkwood/lacie_v2-common.c b/arch/arm/mach-kirkwood/lacie_v2-common.c
new file mode 100644
index 000000000000..d3ea1b6c8a02
--- /dev/null
+++ b/arch/arm/mach-kirkwood/lacie_v2-common.c
@@ -0,0 +1,127 @@
1/*
2 * arch/arm/mach-kirkwood/lacie_v2-common.c
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#include <linux/kernel.h>
10#include <linux/init.h>
11#include <linux/mtd/physmap.h>
12#include <linux/spi/flash.h>
13#include <linux/spi/spi.h>
14#include <linux/i2c.h>
15#include <linux/i2c/at24.h>
16#include <linux/gpio.h>
17#include <asm/mach/time.h>
18#include <mach/kirkwood.h>
19#include <mach/irqs.h>
20#include <plat/time.h>
21#include "common.h"
22
23/*****************************************************************************
24 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
25 ****************************************************************************/
26
27static struct mtd_partition lacie_v2_flash_parts[] = {
28 {
29 .name = "u-boot",
30 .size = MTDPART_SIZ_FULL,
31 .offset = 0,
32 .mask_flags = MTD_WRITEABLE, /* force read-only */
33 },
34};
35
36static const struct flash_platform_data lacie_v2_flash = {
37 .type = "mx25l4005a",
38 .name = "spi_flash",
39 .parts = lacie_v2_flash_parts,
40 .nr_parts = ARRAY_SIZE(lacie_v2_flash_parts),
41};
42
43static struct spi_board_info __initdata lacie_v2_spi_slave_info[] = {
44 {
45 .modalias = "m25p80",
46 .platform_data = &lacie_v2_flash,
47 .irq = -1,
48 .max_speed_hz = 20000000,
49 .bus_num = 0,
50 .chip_select = 0,
51 },
52};
53
54void __init lacie_v2_register_flash(void)
55{
56 spi_register_board_info(lacie_v2_spi_slave_info,
57 ARRAY_SIZE(lacie_v2_spi_slave_info));
58 kirkwood_spi_init();
59}
60
61/*****************************************************************************
62 * I2C devices
63 ****************************************************************************/
64
65static struct at24_platform_data at24c04 = {
66 .byte_len = SZ_4K / 8,
67 .page_size = 16,
68};
69
70/*
71 * i2c addr | chip | description
72 * 0x50 | HT24LC04 | eeprom (512B)
73 */
74
75static struct i2c_board_info __initdata lacie_v2_i2c_info[] = {
76 {
77 I2C_BOARD_INFO("24c04", 0x50),
78 .platform_data = &at24c04,
79 }
80};
81
82void __init lacie_v2_register_i2c_devices(void)
83{
84 kirkwood_i2c_init();
85 i2c_register_board_info(0, lacie_v2_i2c_info,
86 ARRAY_SIZE(lacie_v2_i2c_info));
87}
88
89/*****************************************************************************
90 * Hard Disk power
91 ****************************************************************************/
92
93static int __initdata lacie_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
94
95void __init lacie_v2_hdd_power_init(int hdd_num)
96{
97 int i;
98 int err;
99
100 /* Power up all hard disks. */
101 for (i = 0; i < hdd_num; i++) {
102 err = gpio_request(lacie_v2_gpio_hdd_power[i], NULL);
103 if (err == 0) {
104 err = gpio_direction_output(
105 lacie_v2_gpio_hdd_power[i], 1);
106 /* Free the HDD power GPIOs. This allow user-space to
107 * configure them via the gpiolib sysfs interface. */
108 gpio_free(lacie_v2_gpio_hdd_power[i]);
109 }
110 if (err)
111 pr_err("Failed to power up HDD%d\n", i + 1);
112 }
113}
114
115/*****************************************************************************
116 * Timer
117 ****************************************************************************/
118
119static void lacie_v2_timer_init(void)
120{
121 kirkwood_tclk = 166666667;
122 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
123}
124
125struct sys_timer lacie_v2_timer = {
126 .init = lacie_v2_timer_init,
127};
diff --git a/arch/arm/mach-kirkwood/lacie_v2-common.h b/arch/arm/mach-kirkwood/lacie_v2-common.h
new file mode 100644
index 000000000000..af521315b87b
--- /dev/null
+++ b/arch/arm/mach-kirkwood/lacie_v2-common.h
@@ -0,0 +1,18 @@
1/*
2 * arch/arm/mach-kirkwood/lacie_v2-common.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#ifndef __ARCH_KIRKWOOD_LACIE_V2_COMMON_H
10#define __ARCH_KIRKWOOD_LACIE_V2_COMMON_H
11
12void lacie_v2_register_flash(void);
13void lacie_v2_register_i2c_devices(void);
14void lacie_v2_hdd_power_init(int hdd_num);
15
16extern struct sys_timer lacie_v2_timer;
17
18#endif
diff --git a/arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c b/arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c
index c6b92b42eb4e..1e5266f57e2a 100644
--- a/arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c
+++ b/arch/arm/mach-kirkwood/mv88f6281gtw_ge-setup.c
@@ -163,8 +163,6 @@ subsys_initcall(mv88f6281gtw_ge_pci_init);
163 163
164MACHINE_START(MV88F6281GTW_GE, "Marvell 88F6281 GTW GE Board") 164MACHINE_START(MV88F6281GTW_GE, "Marvell 88F6281 GTW GE Board")
165 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 165 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
166 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
167 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
168 .boot_params = 0x00000100, 166 .boot_params = 0x00000100,
169 .init_machine = mv88f6281gtw_ge_init, 167 .init_machine = mv88f6281gtw_ge_init,
170 .map_io = kirkwood_map_io, 168 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/netspace_v2-setup.c b/arch/arm/mach-kirkwood/netspace_v2-setup.c
index d26bf324738b..5e286441b8f4 100644
--- a/arch/arm/mach-kirkwood/netspace_v2-setup.c
+++ b/arch/arm/mach-kirkwood/netspace_v2-setup.c
@@ -24,56 +24,19 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/mtd/physmap.h>
28#include <linux/spi/flash.h>
29#include <linux/spi/spi.h>
30#include <linux/ata_platform.h> 27#include <linux/ata_platform.h>
31#include <linux/mv643xx_eth.h> 28#include <linux/mv643xx_eth.h>
32#include <linux/i2c.h>
33#include <linux/i2c/at24.h>
34#include <linux/input.h> 29#include <linux/input.h>
35#include <linux/gpio.h> 30#include <linux/gpio.h>
36#include <linux/gpio_keys.h> 31#include <linux/gpio_keys.h>
37#include <linux/leds.h> 32#include <linux/leds.h>
38#include <asm/mach-types.h> 33#include <asm/mach-types.h>
39#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
40#include <asm/mach/time.h>
41#include <mach/kirkwood.h> 35#include <mach/kirkwood.h>
42#include <mach/leds-ns2.h> 36#include <mach/leds-ns2.h>
43#include <plat/time.h>
44#include "common.h" 37#include "common.h"
45#include "mpp.h" 38#include "mpp.h"
46 39#include "lacie_v2-common.h"
47/*****************************************************************************
48 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
49 ****************************************************************************/
50
51static struct mtd_partition netspace_v2_flash_parts[] = {
52 {
53 .name = "u-boot",
54 .size = MTDPART_SIZ_FULL,
55 .offset = 0,
56 .mask_flags = MTD_WRITEABLE, /* force read-only */
57 },
58};
59
60static const struct flash_platform_data netspace_v2_flash = {
61 .type = "mx25l4005a",
62 .name = "spi_flash",
63 .parts = netspace_v2_flash_parts,
64 .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts),
65};
66
67static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = {
68 {
69 .modalias = "m25p80",
70 .platform_data = &netspace_v2_flash,
71 .irq = -1,
72 .max_speed_hz = 20000000,
73 .bus_num = 0,
74 .chip_select = 0,
75 },
76};
77 40
78/***************************************************************************** 41/*****************************************************************************
79 * Ethernet 42 * Ethernet
@@ -84,27 +47,6 @@ static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
84}; 47};
85 48
86/***************************************************************************** 49/*****************************************************************************
87 * I2C devices
88 ****************************************************************************/
89
90static struct at24_platform_data at24c04 = {
91 .byte_len = SZ_4K / 8,
92 .page_size = 16,
93};
94
95/*
96 * i2c addr | chip | description
97 * 0x50 | HT24LC04 | eeprom (512B)
98 */
99
100static struct i2c_board_info __initdata netspace_v2_i2c_info[] = {
101 {
102 I2C_BOARD_INFO("24c04", 0x50),
103 .platform_data = &at24c04,
104 }
105};
106
107/*****************************************************************************
108 * SATA 50 * SATA
109 ****************************************************************************/ 51 ****************************************************************************/
110 52
@@ -112,35 +54,6 @@ static struct mv_sata_platform_data netspace_v2_sata_data = {
112 .n_ports = 2, 54 .n_ports = 2,
113}; 55};
114 56
115#define NETSPACE_V2_GPIO_SATA0_POWER 16
116#define NETSPACE_V2_GPIO_SATA1_POWER 17
117
118static void __init netspace_v2_sata_power_init(void)
119{
120 int err;
121
122 err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power");
123 if (err == 0) {
124 err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1);
125 if (err)
126 gpio_free(NETSPACE_V2_GPIO_SATA0_POWER);
127 }
128 if (err)
129 pr_err("netspace_v2: failed to setup SATA0 power\n");
130
131 if (machine_is_netspace_max_v2()) {
132 err = gpio_request(NETSPACE_V2_GPIO_SATA1_POWER, "SATA1 power");
133 if (err == 0) {
134 err = gpio_direction_output(
135 NETSPACE_V2_GPIO_SATA1_POWER, 1);
136 if (err)
137 gpio_free(NETSPACE_V2_GPIO_SATA1_POWER);
138 }
139 if (err)
140 pr_err("netspace_v2: failed to setup SATA1 power\n");
141 }
142}
143
144/***************************************************************************** 57/*****************************************************************************
145 * GPIO keys 58 * GPIO keys
146 ****************************************************************************/ 59 ****************************************************************************/
@@ -224,20 +137,6 @@ static struct platform_device netspace_v2_leds = {
224}; 137};
225 138
226/***************************************************************************** 139/*****************************************************************************
227 * Timer
228 ****************************************************************************/
229
230static void netspace_v2_timer_init(void)
231{
232 kirkwood_tclk = 166666667;
233 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
234}
235
236struct sys_timer netspace_v2_timer = {
237 .init = netspace_v2_timer_init,
238};
239
240/*****************************************************************************
241 * General Setup 140 * General Setup
242 ****************************************************************************/ 141 ****************************************************************************/
243 142
@@ -291,18 +190,17 @@ static void __init netspace_v2_init(void)
291 kirkwood_init(); 190 kirkwood_init();
292 kirkwood_mpp_conf(netspace_v2_mpp_config); 191 kirkwood_mpp_conf(netspace_v2_mpp_config);
293 192
294 netspace_v2_sata_power_init(); 193 if (machine_is_netspace_max_v2())
194 lacie_v2_hdd_power_init(2);
195 else
196 lacie_v2_hdd_power_init(1);
295 197
296 kirkwood_ehci_init(); 198 kirkwood_ehci_init();
297 kirkwood_ge00_init(&netspace_v2_ge00_data); 199 kirkwood_ge00_init(&netspace_v2_ge00_data);
298 kirkwood_sata_init(&netspace_v2_sata_data); 200 kirkwood_sata_init(&netspace_v2_sata_data);
299 kirkwood_uart0_init(); 201 kirkwood_uart0_init();
300 spi_register_board_info(netspace_v2_spi_slave_info, 202 lacie_v2_register_flash();
301 ARRAY_SIZE(netspace_v2_spi_slave_info)); 203 lacie_v2_register_i2c_devices();
302 kirkwood_spi_init();
303 kirkwood_i2c_init();
304 i2c_register_board_info(0, netspace_v2_i2c_info,
305 ARRAY_SIZE(netspace_v2_i2c_info));
306 204
307 platform_device_register(&netspace_v2_leds); 205 platform_device_register(&netspace_v2_leds);
308 platform_device_register(&netspace_v2_gpio_leds); 206 platform_device_register(&netspace_v2_gpio_leds);
@@ -317,36 +215,30 @@ static void __init netspace_v2_init(void)
317 215
318#ifdef CONFIG_MACH_NETSPACE_V2 216#ifdef CONFIG_MACH_NETSPACE_V2
319MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") 217MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
320 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
321 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
322 .boot_params = 0x00000100, 218 .boot_params = 0x00000100,
323 .init_machine = netspace_v2_init, 219 .init_machine = netspace_v2_init,
324 .map_io = kirkwood_map_io, 220 .map_io = kirkwood_map_io,
325 .init_irq = kirkwood_init_irq, 221 .init_irq = kirkwood_init_irq,
326 .timer = &netspace_v2_timer, 222 .timer = &lacie_v2_timer,
327MACHINE_END 223MACHINE_END
328#endif 224#endif
329 225
330#ifdef CONFIG_MACH_INETSPACE_V2 226#ifdef CONFIG_MACH_INETSPACE_V2
331MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") 227MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
332 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
333 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
334 .boot_params = 0x00000100, 228 .boot_params = 0x00000100,
335 .init_machine = netspace_v2_init, 229 .init_machine = netspace_v2_init,
336 .map_io = kirkwood_map_io, 230 .map_io = kirkwood_map_io,
337 .init_irq = kirkwood_init_irq, 231 .init_irq = kirkwood_init_irq,
338 .timer = &netspace_v2_timer, 232 .timer = &lacie_v2_timer,
339MACHINE_END 233MACHINE_END
340#endif 234#endif
341 235
342#ifdef CONFIG_MACH_NETSPACE_MAX_V2 236#ifdef CONFIG_MACH_NETSPACE_MAX_V2
343MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2") 237MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
344 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
345 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
346 .boot_params = 0x00000100, 238 .boot_params = 0x00000100,
347 .init_machine = netspace_v2_init, 239 .init_machine = netspace_v2_init,
348 .map_io = kirkwood_map_io, 240 .map_io = kirkwood_map_io,
349 .init_irq = kirkwood_init_irq, 241 .init_irq = kirkwood_init_irq,
350 .timer = &netspace_v2_timer, 242 .timer = &lacie_v2_timer,
351MACHINE_END 243MACHINE_END
352#endif 244#endif
diff --git a/arch/arm/mach-kirkwood/netxbig_v2-setup.c b/arch/arm/mach-kirkwood/netxbig_v2-setup.c
index 2bd14c5079de..a1b45d501aef 100644
--- a/arch/arm/mach-kirkwood/netxbig_v2-setup.c
+++ b/arch/arm/mach-kirkwood/netxbig_v2-setup.c
@@ -23,55 +23,19 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/mtd/physmap.h>
27#include <linux/spi/flash.h>
28#include <linux/spi/spi.h>
29#include <linux/ata_platform.h> 26#include <linux/ata_platform.h>
30#include <linux/mv643xx_eth.h> 27#include <linux/mv643xx_eth.h>
31#include <linux/i2c.h>
32#include <linux/i2c/at24.h>
33#include <linux/input.h> 28#include <linux/input.h>
34#include <linux/gpio.h> 29#include <linux/gpio.h>
35#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
36#include <linux/leds.h> 31#include <linux/leds.h>
37#include <asm/mach-types.h> 32#include <asm/mach-types.h>
38#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
39#include <asm/mach/time.h>
40#include <mach/kirkwood.h> 34#include <mach/kirkwood.h>
41#include <plat/time.h> 35#include <mach/leds-netxbig.h>
42#include "common.h" 36#include "common.h"
43#include "mpp.h" 37#include "mpp.h"
44 38#include "lacie_v2-common.h"
45/*****************************************************************************
46 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
47 ****************************************************************************/
48
49static struct mtd_partition netxbig_v2_flash_parts[] = {
50 {
51 .name = "u-boot",
52 .size = MTDPART_SIZ_FULL,
53 .offset = 0,
54 .mask_flags = MTD_WRITEABLE, /* force read-only */
55 },
56};
57
58static const struct flash_platform_data netxbig_v2_flash = {
59 .type = "mx25l4005a",
60 .name = "spi_flash",
61 .parts = netxbig_v2_flash_parts,
62 .nr_parts = ARRAY_SIZE(netxbig_v2_flash_parts),
63};
64
65static struct spi_board_info __initdata netxbig_v2_spi_slave_info[] = {
66 {
67 .modalias = "m25p80",
68 .platform_data = &netxbig_v2_flash,
69 .irq = -1,
70 .max_speed_hz = 20000000,
71 .bus_num = 0,
72 .chip_select = 0,
73 },
74};
75 39
76/***************************************************************************** 40/*****************************************************************************
77 * Ethernet 41 * Ethernet
@@ -86,27 +50,6 @@ static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {
86}; 50};
87 51
88/***************************************************************************** 52/*****************************************************************************
89 * I2C devices
90 ****************************************************************************/
91
92static struct at24_platform_data at24c04 = {
93 .byte_len = SZ_4K / 8,
94 .page_size = 16,
95};
96
97/*
98 * i2c addr | chip | description
99 * 0x50 | HT24LC04 | eeprom (512B)
100 */
101
102static struct i2c_board_info __initdata netxbig_v2_i2c_info[] = {
103 {
104 I2C_BOARD_INFO("24c04", 0x50),
105 .platform_data = &at24c04,
106 }
107};
108
109/*****************************************************************************
110 * SATA 53 * SATA
111 ****************************************************************************/ 54 ****************************************************************************/
112 55
@@ -114,34 +57,6 @@ static struct mv_sata_platform_data netxbig_v2_sata_data = {
114 .n_ports = 2, 57 .n_ports = 2,
115}; 58};
116 59
117static int __initdata netxbig_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
118
119static void __init netxbig_v2_sata_power_init(void)
120{
121 int i;
122 int err;
123 int hdd_nb;
124
125 if (machine_is_net2big_v2())
126 hdd_nb = 2;
127 else
128 hdd_nb = 5;
129
130 /* Power up all hard disks. */
131 for (i = 0; i < hdd_nb; i++) {
132 err = gpio_request(netxbig_v2_gpio_hdd_power[i], NULL);
133 if (err == 0) {
134 err = gpio_direction_output(
135 netxbig_v2_gpio_hdd_power[i], 1);
136 /* Free the HDD power GPIOs. This allow user-space to
137 * configure them via the gpiolib sysfs interface. */
138 gpio_free(netxbig_v2_gpio_hdd_power[i]);
139 }
140 if (err)
141 pr_err("netxbig_v2: failed to power up HDD%d\n", i + 1);
142 }
143}
144
145/***************************************************************************** 60/*****************************************************************************
146 * GPIO keys 61 * GPIO keys
147 ****************************************************************************/ 62 ****************************************************************************/
@@ -190,7 +105,7 @@ static struct platform_device netxbig_v2_gpio_buttons = {
190}; 105};
191 106
192/***************************************************************************** 107/*****************************************************************************
193 * GPIO LEDs 108 * GPIO extension LEDs
194 ****************************************************************************/ 109 ****************************************************************************/
195 110
196/* 111/*
@@ -200,19 +115,32 @@ static struct platform_device netxbig_v2_gpio_buttons = {
200 * - address register : bit [0-2] -> GPIO [47-49] 115 * - address register : bit [0-2] -> GPIO [47-49]
201 * - data register : bit [0-2] -> GPIO [44-46] 116 * - data register : bit [0-2] -> GPIO [44-46]
202 * - enable register : GPIO 29 117 * - enable register : GPIO 29
203 * 118 */
119
120static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 };
121static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 };
122
123static struct netxbig_gpio_ext netxbig_v2_gpio_ext = {
124 .addr = netxbig_v2_gpio_ext_addr,
125 .num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr),
126 .data = netxbig_v2_gpio_ext_data,
127 .num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data),
128 .enable = 29,
129};
130
131/*
204 * Address register selection: 132 * Address register selection:
205 * 133 *
206 * addr | register 134 * addr | register
207 * ---------------------------- 135 * ----------------------------
208 * 0 | front LED 136 * 0 | front LED
209 * 1 | front LED brightness 137 * 1 | front LED brightness
210 * 2 | HDD LED brightness 138 * 2 | SATA LED brightness
211 * 3 | HDD1 LED 139 * 3 | SATA0 LED
212 * 4 | HDD2 LED 140 * 4 | SATA1 LED
213 * 5 | HDD3 LED 141 * 5 | SATA2 LED
214 * 6 | HDD4 LED 142 * 6 | SATA3 LED
215 * 7 | HDD5 LED 143 * 7 | SATA4 LED
216 * 144 *
217 * Data register configuration: 145 * Data register configuration:
218 * 146 *
@@ -233,30 +161,107 @@ static struct platform_device netxbig_v2_gpio_buttons = {
233 * 6 | blink blue on=1 sec and red on=1 sec 161 * 6 | blink blue on=1 sec and red on=1 sec
234 * 7 | blink blue on=0.5 sec and blue off=2.5 sec 162 * 7 | blink blue on=0.5 sec and blue off=2.5 sec
235 * 163 *
236 * data | HDD LED mode 164 * data | SATA LED mode
237 * ------------------------------------------------- 165 * -------------------------------------------------
238 * 0 | fix blue on 166 * 0 | fix off
239 * 1 | SATA activity blink 167 * 1 | SATA activity blink
240 * 2 | fix red on 168 * 2 | fix red on
241 * 3 | blink blue on=1 sec and blue off=1 sec 169 * 3 | blink blue on=1 sec and blue off=1 sec
242 * 4 | blink red on=1 sec and red off=1 sec 170 * 4 | blink red on=1 sec and red off=1 sec
243 * 5 | blink blue on=2.5 sec and red on=0.5 sec 171 * 5 | blink blue on=2.5 sec and red on=0.5 sec
244 * 6 | blink blue on=1 sec and red on=1 sec 172 * 6 | blink blue on=1 sec and red on=1 sec
245 * 7 | blink blue on=0.5 sec and blue off=2.5 sec 173 * 7 | fix blue on
246 */ 174 */
247 175
248/***************************************************************************** 176static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = {
249 * Timer 177 [NETXBIG_LED_OFF] = 0,
250 ****************************************************************************/ 178 [NETXBIG_LED_ON] = 2,
179 [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
180 [NETXBIG_LED_TIMER1] = 4,
181 [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
182};
251 183
252static void netxbig_v2_timer_init(void) 184static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = {
253{ 185 [NETXBIG_LED_OFF] = 0,
254 kirkwood_tclk = 166666667; 186 [NETXBIG_LED_ON] = 1,
255 orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); 187 [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
256} 188 [NETXBIG_LED_TIMER1] = 3,
189 [NETXBIG_LED_TIMER2] = 7,
190};
191
192static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = {
193 [NETXBIG_LED_OFF] = 0,
194 [NETXBIG_LED_ON] = 7,
195 [NETXBIG_LED_SATA] = 1,
196 [NETXBIG_LED_TIMER1] = 3,
197 [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
198};
199
200static struct netxbig_led_timer netxbig_v2_led_timer[] = {
201 [0] = {
202 .delay_on = 500,
203 .delay_off = 500,
204 .mode = NETXBIG_LED_TIMER1,
205 },
206 [1] = {
207 .delay_on = 500,
208 .delay_off = 1000,
209 .mode = NETXBIG_LED_TIMER2,
210 },
211};
212
213#define NETXBIG_LED(_name, maddr, mval, baddr) \
214 { .name = _name, \
215 .mode_addr = maddr, \
216 .mode_val = mval, \
217 .bright_addr = baddr }
218
219static struct netxbig_led net2big_v2_leds_ctrl[] = {
220 NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
221 NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1),
222 NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
223 NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
224 NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
225 NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
226};
227
228static struct netxbig_led_platform_data net2big_v2_leds_data = {
229 .gpio_ext = &netxbig_v2_gpio_ext,
230 .timer = netxbig_v2_led_timer,
231 .num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
232 .leds = net2big_v2_leds_ctrl,
233 .num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl),
234};
235
236static struct netxbig_led net5big_v2_leds_ctrl[] = {
237 NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
238 NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1),
239 NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
240 NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
241 NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
242 NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
243 NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2),
244 NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2),
245 NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2),
246 NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2),
247 NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2),
248 NETXBIG_LED("net5big-v2:red:sata5", 7, netxbig_v2_red_mled, 2),
249};
257 250
258struct sys_timer netxbig_v2_timer = { 251static struct netxbig_led_platform_data net5big_v2_leds_data = {
259 .init = netxbig_v2_timer_init, 252 .gpio_ext = &netxbig_v2_gpio_ext,
253 .timer = netxbig_v2_led_timer,
254 .num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
255 .leds = net5big_v2_leds_ctrl,
256 .num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl),
257};
258
259static struct platform_device netxbig_v2_leds = {
260 .name = "leds-netxbig",
261 .id = -1,
262 .dev = {
263 .platform_data = &net2big_v2_leds_data,
264 },
260}; 265};
261 266
262/***************************************************************************** 267/*****************************************************************************
@@ -284,18 +289,18 @@ static unsigned int net2big_v2_mpp_config[] __initdata = {
284 MPP24_GPIO, /* USB mode select */ 289 MPP24_GPIO, /* USB mode select */
285 MPP26_GPIO, /* USB device vbus */ 290 MPP26_GPIO, /* USB device vbus */
286 MPP28_GPIO, /* USB enable host vbus */ 291 MPP28_GPIO, /* USB enable host vbus */
287 MPP29_GPIO, /* CPLD extension ALE */ 292 MPP29_GPIO, /* GPIO extension ALE */
288 MPP34_GPIO, /* Rear Push button */ 293 MPP34_GPIO, /* Rear Push button */
289 MPP35_GPIO, /* Inhibit switch power-off */ 294 MPP35_GPIO, /* Inhibit switch power-off */
290 MPP36_GPIO, /* SATA HDD1 presence */ 295 MPP36_GPIO, /* SATA HDD1 presence */
291 MPP37_GPIO, /* SATA HDD2 presence */ 296 MPP37_GPIO, /* SATA HDD2 presence */
292 MPP40_GPIO, /* eSATA presence */ 297 MPP40_GPIO, /* eSATA presence */
293 MPP44_GPIO, /* CPLD extension (data 0) */ 298 MPP44_GPIO, /* GPIO extension (data 0) */
294 MPP45_GPIO, /* CPLD extension (data 1) */ 299 MPP45_GPIO, /* GPIO extension (data 1) */
295 MPP46_GPIO, /* CPLD extension (data 2) */ 300 MPP46_GPIO, /* GPIO extension (data 2) */
296 MPP47_GPIO, /* CPLD extension (addr 0) */ 301 MPP47_GPIO, /* GPIO extension (addr 0) */
297 MPP48_GPIO, /* CPLD extension (addr 1) */ 302 MPP48_GPIO, /* GPIO extension (addr 1) */
298 MPP49_GPIO, /* CPLD extension (addr 2) */ 303 MPP49_GPIO, /* GPIO extension (addr 2) */
299 0 304 0
300}; 305};
301 306
@@ -324,7 +329,7 @@ static unsigned int net5big_v2_mpp_config[] __initdata = {
324 MPP26_GE1_RXD2, 329 MPP26_GE1_RXD2,
325 MPP27_GE1_RXD3, 330 MPP27_GE1_RXD3,
326 MPP28_GPIO, /* USB enable host vbus */ 331 MPP28_GPIO, /* USB enable host vbus */
327 MPP29_GPIO, /* CPLD extension ALE */ 332 MPP29_GPIO, /* GPIO extension ALE */
328 MPP30_GE1_RXCTL, 333 MPP30_GE1_RXCTL,
329 MPP31_GE1_RXCLK, 334 MPP31_GE1_RXCLK,
330 MPP32_GE1_TCLKOUT, 335 MPP32_GE1_TCLKOUT,
@@ -339,12 +344,12 @@ static unsigned int net5big_v2_mpp_config[] __initdata = {
339 MPP41_GPIO, /* SATA HDD3 power */ 344 MPP41_GPIO, /* SATA HDD3 power */
340 MPP42_GPIO, /* SATA HDD4 power */ 345 MPP42_GPIO, /* SATA HDD4 power */
341 MPP43_GPIO, /* SATA HDD5 power */ 346 MPP43_GPIO, /* SATA HDD5 power */
342 MPP44_GPIO, /* CPLD extension (data 0) */ 347 MPP44_GPIO, /* GPIO extension (data 0) */
343 MPP45_GPIO, /* CPLD extension (data 1) */ 348 MPP45_GPIO, /* GPIO extension (data 1) */
344 MPP46_GPIO, /* CPLD extension (data 2) */ 349 MPP46_GPIO, /* GPIO extension (data 2) */
345 MPP47_GPIO, /* CPLD extension (addr 0) */ 350 MPP47_GPIO, /* GPIO extension (addr 0) */
346 MPP48_GPIO, /* CPLD extension (addr 1) */ 351 MPP48_GPIO, /* GPIO extension (addr 1) */
347 MPP49_GPIO, /* CPLD extension (addr 2) */ 352 MPP49_GPIO, /* GPIO extension (addr 2) */
348 0 353 0
349}; 354};
350 355
@@ -366,7 +371,10 @@ static void __init netxbig_v2_init(void)
366 else 371 else
367 kirkwood_mpp_conf(net5big_v2_mpp_config); 372 kirkwood_mpp_conf(net5big_v2_mpp_config);
368 373
369 netxbig_v2_sata_power_init(); 374 if (machine_is_net2big_v2())
375 lacie_v2_hdd_power_init(2);
376 else
377 lacie_v2_hdd_power_init(5);
370 378
371 kirkwood_ehci_init(); 379 kirkwood_ehci_init();
372 kirkwood_ge00_init(&netxbig_v2_ge00_data); 380 kirkwood_ge00_init(&netxbig_v2_ge00_data);
@@ -374,13 +382,12 @@ static void __init netxbig_v2_init(void)
374 kirkwood_ge01_init(&netxbig_v2_ge01_data); 382 kirkwood_ge01_init(&netxbig_v2_ge01_data);
375 kirkwood_sata_init(&netxbig_v2_sata_data); 383 kirkwood_sata_init(&netxbig_v2_sata_data);
376 kirkwood_uart0_init(); 384 kirkwood_uart0_init();
377 spi_register_board_info(netxbig_v2_spi_slave_info, 385 lacie_v2_register_flash();
378 ARRAY_SIZE(netxbig_v2_spi_slave_info)); 386 lacie_v2_register_i2c_devices();
379 kirkwood_spi_init();
380 kirkwood_i2c_init();
381 i2c_register_board_info(0, netxbig_v2_i2c_info,
382 ARRAY_SIZE(netxbig_v2_i2c_info));
383 387
388 if (machine_is_net5big_v2())
389 netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data;
390 platform_device_register(&netxbig_v2_leds);
384 platform_device_register(&netxbig_v2_gpio_buttons); 391 platform_device_register(&netxbig_v2_gpio_buttons);
385 392
386 if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 && 393 if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
@@ -392,24 +399,20 @@ static void __init netxbig_v2_init(void)
392 399
393#ifdef CONFIG_MACH_NET2BIG_V2 400#ifdef CONFIG_MACH_NET2BIG_V2
394MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2") 401MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
395 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
396 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
397 .boot_params = 0x00000100, 402 .boot_params = 0x00000100,
398 .init_machine = netxbig_v2_init, 403 .init_machine = netxbig_v2_init,
399 .map_io = kirkwood_map_io, 404 .map_io = kirkwood_map_io,
400 .init_irq = kirkwood_init_irq, 405 .init_irq = kirkwood_init_irq,
401 .timer = &netxbig_v2_timer, 406 .timer = &lacie_v2_timer,
402MACHINE_END 407MACHINE_END
403#endif 408#endif
404 409
405#ifdef CONFIG_MACH_NET5BIG_V2 410#ifdef CONFIG_MACH_NET5BIG_V2
406MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2") 411MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
407 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
408 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
409 .boot_params = 0x00000100, 412 .boot_params = 0x00000100,
410 .init_machine = netxbig_v2_init, 413 .init_machine = netxbig_v2_init,
411 .map_io = kirkwood_map_io, 414 .map_io = kirkwood_map_io,
412 .init_irq = kirkwood_init_irq, 415 .init_irq = kirkwood_init_irq,
413 .timer = &netxbig_v2_timer, 416 .timer = &lacie_v2_timer,
414MACHINE_END 417MACHINE_END
415#endif 418#endif
diff --git a/arch/arm/mach-kirkwood/openrd-setup.c b/arch/arm/mach-kirkwood/openrd-setup.c
index fd06be618815..c9d77fad10ab 100644
--- a/arch/arm/mach-kirkwood/openrd-setup.c
+++ b/arch/arm/mach-kirkwood/openrd-setup.c
@@ -16,6 +16,7 @@
16#include <linux/ata_platform.h> 16#include <linux/ata_platform.h>
17#include <linux/mv643xx_eth.h> 17#include <linux/mv643xx_eth.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/gpio.h>
19#include <asm/mach-types.h> 20#include <asm/mach-types.h>
20#include <asm/mach/arch.h> 21#include <asm/mach/arch.h>
21#include <mach/kirkwood.h> 22#include <mach/kirkwood.h>
@@ -57,7 +58,22 @@ static struct mvsdio_platform_data openrd_mvsdio_data = {
57}; 58};
58 59
59static unsigned int openrd_mpp_config[] __initdata = { 60static unsigned int openrd_mpp_config[] __initdata = {
61 MPP12_SD_CLK,
62 MPP13_SD_CMD,
63 MPP14_SD_D0,
64 MPP15_SD_D1,
65 MPP16_SD_D2,
66 MPP17_SD_D3,
67 MPP28_GPIO,
60 MPP29_GPIO, 68 MPP29_GPIO,
69 MPP34_GPIO,
70 0
71};
72
73/* Configure MPP for UART1 */
74static unsigned int openrd_uart1_mpp_config[] __initdata = {
75 MPP13_UART1_TXD,
76 MPP14_UART1_RXD,
61 0 77 0
62}; 78};
63 79
@@ -67,6 +83,68 @@ static struct i2c_board_info i2c_board_info[] __initdata = {
67 }, 83 },
68}; 84};
69 85
86static int __initdata uart1;
87
88static int __init sd_uart_selection(char *str)
89{
90 uart1 = -EINVAL;
91
92 /* Default is SD. Change if required, for UART */
93 if (!str)
94 return 0;
95
96 if (!strncmp(str, "232", 3)) {
97 uart1 = 232;
98 } else if (!strncmp(str, "485", 3)) {
99 /* OpenRD-Base doesn't have RS485. Treat is as an
100 * unknown argument & just have default setting -
101 * which is SD */
102 if (machine_is_openrd_base()) {
103 uart1 = -ENODEV;
104 return 1;
105 }
106
107 uart1 = 485;
108 }
109 return 1;
110}
111/* Parse boot_command_line string kw_openrd_init_uart1=232/485 */
112__setup("kw_openrd_init_uart1=", sd_uart_selection);
113
114static int __init uart1_mpp_config(void)
115{
116 kirkwood_mpp_conf(openrd_uart1_mpp_config);
117
118 if (gpio_request(34, "SD_UART1_SEL")) {
119 printk(KERN_ERR "GPIO request failed for SD/UART1 selection"
120 ", gpio: 34\n");
121 return -EIO;
122 }
123
124 if (gpio_request(28, "RS232_RS485_SEL")) {
125 printk(KERN_ERR "GPIO request failed for RS232/RS485 selection"
126 ", gpio# 28\n");
127 gpio_free(34);
128 return -EIO;
129 }
130
131 /* Select UART1
132 * Pin # 34: 0 => UART1, 1 => SD */
133 gpio_direction_output(34, 0);
134
135 /* Select RS232 OR RS485
136 * Pin # 28: 0 => RS232, 1 => RS485 */
137 if (uart1 == 232)
138 gpio_direction_output(28, 0);
139 else
140 gpio_direction_output(28, 1);
141
142 gpio_free(34);
143 gpio_free(28);
144
145 return 0;
146}
147
70static void __init openrd_init(void) 148static void __init openrd_init(void)
71{ 149{
72 /* 150 /*
@@ -90,7 +168,6 @@ static void __init openrd_init(void)
90 kirkwood_ge01_init(&openrd_ge01_data); 168 kirkwood_ge01_init(&openrd_ge01_data);
91 169
92 kirkwood_sata_init(&openrd_sata_data); 170 kirkwood_sata_init(&openrd_sata_data);
93 kirkwood_sdio_init(&openrd_mvsdio_data);
94 171
95 kirkwood_i2c_init(); 172 kirkwood_i2c_init();
96 173
@@ -99,6 +176,28 @@ static void __init openrd_init(void)
99 ARRAY_SIZE(i2c_board_info)); 176 ARRAY_SIZE(i2c_board_info));
100 kirkwood_audio_init(); 177 kirkwood_audio_init();
101 } 178 }
179
180 if (uart1 <= 0) {
181 if (uart1 < 0)
182 printk(KERN_ERR "Invalid kernel parameter to select "
183 "UART1. Defaulting to SD. ERROR CODE: %d\n",
184 uart1);
185
186 /* Select SD
187 * Pin # 34: 0 => UART1, 1 => SD */
188 if (gpio_request(34, "SD_UART1_SEL")) {
189 printk(KERN_ERR "GPIO request failed for SD/UART1 "
190 "selection, gpio: 34\n");
191 } else {
192
193 gpio_direction_output(34, 1);
194 gpio_free(34);
195 kirkwood_sdio_init(&openrd_mvsdio_data);
196 }
197 } else {
198 if (!uart1_mpp_config())
199 kirkwood_uart1_init();
200 }
102} 201}
103 202
104static int __init openrd_pci_init(void) 203static int __init openrd_pci_init(void)
@@ -115,8 +214,6 @@ subsys_initcall(openrd_pci_init);
115#ifdef CONFIG_MACH_OPENRD_BASE 214#ifdef CONFIG_MACH_OPENRD_BASE
116MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board") 215MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board")
117 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ 216 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
118 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
119 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
120 .boot_params = 0x00000100, 217 .boot_params = 0x00000100,
121 .init_machine = openrd_init, 218 .init_machine = openrd_init,
122 .map_io = kirkwood_map_io, 219 .map_io = kirkwood_map_io,
@@ -128,8 +225,6 @@ MACHINE_END
128#ifdef CONFIG_MACH_OPENRD_CLIENT 225#ifdef CONFIG_MACH_OPENRD_CLIENT
129MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board") 226MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board")
130 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ 227 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
131 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
132 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
133 .boot_params = 0x00000100, 228 .boot_params = 0x00000100,
134 .init_machine = openrd_init, 229 .init_machine = openrd_init,
135 .map_io = kirkwood_map_io, 230 .map_io = kirkwood_map_io,
@@ -141,8 +236,6 @@ MACHINE_END
141#ifdef CONFIG_MACH_OPENRD_ULTIMATE 236#ifdef CONFIG_MACH_OPENRD_ULTIMATE
142MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board") 237MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board")
143 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ 238 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
144 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
145 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
146 .boot_params = 0x00000100, 239 .boot_params = 0x00000100,
147 .init_machine = openrd_init, 240 .init_machine = openrd_init,
148 .map_io = kirkwood_map_io, 241 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c b/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
index c34718c2cfe5..0049614cd324 100644
--- a/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
+++ b/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
@@ -79,8 +79,6 @@ subsys_initcall(rd88f6192_pci_init);
79 79
80MACHINE_START(RD88F6192_NAS, "Marvell RD-88F6192-NAS Development Board") 80MACHINE_START(RD88F6192_NAS, "Marvell RD-88F6192-NAS Development Board")
81 /* Maintainer: Saeed Bishara <saeed@marvell.com> */ 81 /* Maintainer: Saeed Bishara <saeed@marvell.com> */
82 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
83 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
84 .boot_params = 0x00000100, 82 .boot_params = 0x00000100,
85 .init_machine = rd88f6192_init, 83 .init_machine = rd88f6192_init,
86 .map_io = kirkwood_map_io, 84 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/rd88f6281-setup.c b/arch/arm/mach-kirkwood/rd88f6281-setup.c
index 3d1477135e12..0998a08cf42d 100644
--- a/arch/arm/mach-kirkwood/rd88f6281-setup.c
+++ b/arch/arm/mach-kirkwood/rd88f6281-setup.c
@@ -115,8 +115,6 @@ subsys_initcall(rd88f6281_pci_init);
115 115
116MACHINE_START(RD88F6281, "Marvell RD-88F6281 Reference Board") 116MACHINE_START(RD88F6281, "Marvell RD-88F6281 Reference Board")
117 /* Maintainer: Saeed Bishara <saeed@marvell.com> */ 117 /* Maintainer: Saeed Bishara <saeed@marvell.com> */
118 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
119 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
120 .boot_params = 0x00000100, 118 .boot_params = 0x00000100,
121 .init_machine = rd88f6281_init, 119 .init_machine = rd88f6281_init,
122 .map_io = kirkwood_map_io, 120 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/sheevaplug-setup.c b/arch/arm/mach-kirkwood/sheevaplug-setup.c
index a00879d34d54..d2eec35dfe0f 100644
--- a/arch/arm/mach-kirkwood/sheevaplug-setup.c
+++ b/arch/arm/mach-kirkwood/sheevaplug-setup.c
@@ -131,8 +131,6 @@ static void __init sheevaplug_init(void)
131#ifdef CONFIG_MACH_SHEEVAPLUG 131#ifdef CONFIG_MACH_SHEEVAPLUG
132MACHINE_START(SHEEVAPLUG, "Marvell SheevaPlug Reference Board") 132MACHINE_START(SHEEVAPLUG, "Marvell SheevaPlug Reference Board")
133 /* Maintainer: shadi Ammouri <shadi@marvell.com> */ 133 /* Maintainer: shadi Ammouri <shadi@marvell.com> */
134 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
135 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
136 .boot_params = 0x00000100, 134 .boot_params = 0x00000100,
137 .init_machine = sheevaplug_init, 135 .init_machine = sheevaplug_init,
138 .map_io = kirkwood_map_io, 136 .map_io = kirkwood_map_io,
@@ -143,8 +141,6 @@ MACHINE_END
143 141
144#ifdef CONFIG_MACH_ESATA_SHEEVAPLUG 142#ifdef CONFIG_MACH_ESATA_SHEEVAPLUG
145MACHINE_START(ESATA_SHEEVAPLUG, "Marvell eSATA SheevaPlug Reference Board") 143MACHINE_START(ESATA_SHEEVAPLUG, "Marvell eSATA SheevaPlug Reference Board")
146 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
147 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
148 .boot_params = 0x00000100, 144 .boot_params = 0x00000100,
149 .init_machine = sheevaplug_init, 145 .init_machine = sheevaplug_init,
150 .map_io = kirkwood_map_io, 146 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/t5325-setup.c b/arch/arm/mach-kirkwood/t5325-setup.c
index d01bf89cedbe..ce50e61aac9f 100644
--- a/arch/arm/mach-kirkwood/t5325-setup.c
+++ b/arch/arm/mach-kirkwood/t5325-setup.c
@@ -184,8 +184,6 @@ subsys_initcall(hp_t5325_pci_init);
184 184
185MACHINE_START(T5325, "HP t5325 Thin Client") 185MACHINE_START(T5325, "HP t5325 Thin Client")
186 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ 186 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
187 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
188 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
189 .boot_params = 0x00000100, 187 .boot_params = 0x00000100,
190 .init_machine = hp_t5325_init, 188 .init_machine = hp_t5325_init,
191 .map_io = kirkwood_map_io, 189 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/ts219-setup.c b/arch/arm/mach-kirkwood/ts219-setup.c
index a5bd7fde04a9..6710bd7773b8 100644
--- a/arch/arm/mach-kirkwood/ts219-setup.c
+++ b/arch/arm/mach-kirkwood/ts219-setup.c
@@ -120,8 +120,6 @@ subsys_initcall(ts219_pci_init);
120 120
121MACHINE_START(TS219, "QNAP TS-119/TS-219") 121MACHINE_START(TS219, "QNAP TS-119/TS-219")
122 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ 122 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
123 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
124 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
125 .boot_params = 0x00000100, 123 .boot_params = 0x00000100,
126 .init_machine = qnap_ts219_init, 124 .init_machine = qnap_ts219_init,
127 .map_io = kirkwood_map_io, 125 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-kirkwood/ts41x-setup.c b/arch/arm/mach-kirkwood/ts41x-setup.c
index 2e14afef07a2..8be09a0ce4ac 100644
--- a/arch/arm/mach-kirkwood/ts41x-setup.c
+++ b/arch/arm/mach-kirkwood/ts41x-setup.c
@@ -149,8 +149,6 @@ subsys_initcall(ts41x_pci_init);
149 149
150MACHINE_START(TS41X, "QNAP TS-41x") 150MACHINE_START(TS41X, "QNAP TS-41x")
151 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ 151 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
152 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
153 .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
154 .boot_params = 0x00000100, 152 .boot_params = 0x00000100,
155 .init_machine = qnap_ts41x_init, 153 .init_machine = qnap_ts41x_init,
156 .map_io = kirkwood_map_io, 154 .map_io = kirkwood_map_io,
diff --git a/arch/arm/mach-ks8695/board-acs5k.c b/arch/arm/mach-ks8695/board-acs5k.c
index 9e3e5a640ad2..3ca4f8e6f54f 100644
--- a/arch/arm/mach-ks8695/board-acs5k.c
+++ b/arch/arm/mach-ks8695/board-acs5k.c
@@ -223,8 +223,6 @@ static void __init acs5k_init(void)
223 223
224MACHINE_START(ACS5K, "Brivo Systems LLC ACS-5000 Master board") 224MACHINE_START(ACS5K, "Brivo Systems LLC ACS-5000 Master board")
225 /* Maintainer: Simtec Electronics. */ 225 /* Maintainer: Simtec Electronics. */
226 .phys_io = KS8695_IO_PA,
227 .io_pg_offst = (KS8695_IO_VA >> 18) & 0xfffc,
228 .boot_params = KS8695_SDRAM_PA + 0x100, 226 .boot_params = KS8695_SDRAM_PA + 0x100,
229 .map_io = ks8695_map_io, 227 .map_io = ks8695_map_io,
230 .init_irq = ks8695_init_irq, 228 .init_irq = ks8695_init_irq,
diff --git a/arch/arm/mach-ks8695/board-dsm320.c b/arch/arm/mach-ks8695/board-dsm320.c
index 521ff0789f39..ada92b6bed24 100644
--- a/arch/arm/mach-ks8695/board-dsm320.c
+++ b/arch/arm/mach-ks8695/board-dsm320.c
@@ -121,8 +121,6 @@ static void __init dsm320_init(void)
121 121
122MACHINE_START(DSM320, "D-Link DSM-320 Wireless Media Player") 122MACHINE_START(DSM320, "D-Link DSM-320 Wireless Media Player")
123 /* Maintainer: Simtec Electronics. */ 123 /* Maintainer: Simtec Electronics. */
124 .phys_io = KS8695_IO_PA,
125 .io_pg_offst = (KS8695_IO_VA >> 18) & 0xfffc,
126 .boot_params = KS8695_SDRAM_PA + 0x100, 124 .boot_params = KS8695_SDRAM_PA + 0x100,
127 .map_io = ks8695_map_io, 125 .map_io = ks8695_map_io,
128 .init_irq = ks8695_init_irq, 126 .init_irq = ks8695_init_irq,
diff --git a/arch/arm/mach-ks8695/board-micrel.c b/arch/arm/mach-ks8695/board-micrel.c
index 8ceaf5ac6e2c..c7ad09bd6ea2 100644
--- a/arch/arm/mach-ks8695/board-micrel.c
+++ b/arch/arm/mach-ks8695/board-micrel.c
@@ -53,8 +53,6 @@ static void __init micrel_init(void)
53 53
54MACHINE_START(KS8695, "KS8695 Centaur Development Board") 54MACHINE_START(KS8695, "KS8695 Centaur Development Board")
55 /* Maintainer: Micrel Semiconductor Inc. */ 55 /* Maintainer: Micrel Semiconductor Inc. */
56 .phys_io = KS8695_IO_PA,
57 .io_pg_offst = (KS8695_IO_VA >> 18) & 0xfffc,
58 .boot_params = KS8695_SDRAM_PA + 0x100, 56 .boot_params = KS8695_SDRAM_PA + 0x100,
59 .map_io = ks8695_map_io, 57 .map_io = ks8695_map_io,
60 .init_irq = ks8695_init_irq, 58 .init_irq = ks8695_init_irq,
diff --git a/arch/arm/mach-ks8695/include/mach/debug-macro.S b/arch/arm/mach-ks8695/include/mach/debug-macro.S
index cf2095da2372..bf516adf1925 100644
--- a/arch/arm/mach-ks8695/include/mach/debug-macro.S
+++ b/arch/arm/mach-ks8695/include/mach/debug-macro.S
@@ -14,11 +14,9 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/regs-uart.h> 15#include <mach/regs-uart.h>
16 16
17 .macro addruart, rx, tmp 17 .macro addruart, rp, rv
18 mrc p15, 0, \rx, c1, c0 18 ldr \rp, =KS8695_UART_PA @ physical base address
19 tst \rx, #1 @ MMU enabled? 19 ldr \rv, =KS8695_UART_VA @ virtual base address
20 ldreq \rx, =KS8695_UART_PA @ physical base address
21 ldrne \rx, =KS8695_UART_VA @ virtual base address
22 .endm 20 .endm
23 21
24 .macro senduart, rd, rx 22 .macro senduart, rd, rx
diff --git a/arch/arm/mach-l7200/include/mach/debug-macro.S b/arch/arm/mach-l7200/include/mach/debug-macro.S
new file mode 100644
index 000000000000..b0a2db77d392
--- /dev/null
+++ b/arch/arm/mach-l7200/include/mach/debug-macro.S
@@ -0,0 +1,38 @@
1/* arch/arm/mach-l7200/include/mach/debug-macro.S
2 *
3 * Debugging macro include header
4 *
5 * Copyright (C) 1994-1999 Russell King
6 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12*/
13
14 .equ io_virt, IO_BASE
15 .equ io_phys, IO_START
16
17 .macro addruart, rp, rv
18 mov \rp, #0x00044000 @ UART1
19@ mov \rp, #0x00045000 @ UART2
20 add \rv, \rp, #io_virt @ virtual address
21 add \rp, \rp, #io_phys @ physical base address
22 .endm
23
24 .macro senduart,rd,rx
25 str \rd, [\rx, #0x0] @ UARTDR
26 .endm
27
28 .macro waituart,rd,rx
291001: ldr \rd, [\rx, #0x18] @ UARTFLG
30 tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
31 bne 1001b
32 .endm
33
34 .macro busyuart,rd,rx
351001: ldr \rd, [\rx, #0x18] @ UARTFLG
36 tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
37 bne 1001b
38 .endm
diff --git a/arch/arm/mach-lh7a40x/arch-kev7a400.c b/arch/arm/mach-lh7a40x/arch-kev7a400.c
index 3d7bd50b9095..9088c16662e8 100644
--- a/arch/arm/mach-lh7a40x/arch-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/arch-kev7a400.c
@@ -111,8 +111,6 @@ void __init lh7a40x_init_board_irq (void)
111 111
112MACHINE_START (KEV7A400, "Sharp KEV7a400") 112MACHINE_START (KEV7A400, "Sharp KEV7a400")
113 /* Maintainer: Marc Singer */ 113 /* Maintainer: Marc Singer */
114 .phys_io = 0x80000000,
115 .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
116 .boot_params = 0xc0000100, 114 .boot_params = 0xc0000100,
117 .map_io = kev7a400_map_io, 115 .map_io = kev7a400_map_io,
118 .init_irq = lh7a400_init_irq, 116 .init_irq = lh7a400_init_irq,
diff --git a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
index cb15e5d32120..7315a569aea1 100644
--- a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
@@ -398,8 +398,6 @@ lpd7a40x_map_io(void)
398 398
399MACHINE_START (LPD7A400, "Logic Product Development LPD7A400-10") 399MACHINE_START (LPD7A400, "Logic Product Development LPD7A400-10")
400 /* Maintainer: Marc Singer */ 400 /* Maintainer: Marc Singer */
401 .phys_io = 0x80000000,
402 .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
403 .boot_params = 0xc0000100, 401 .boot_params = 0xc0000100,
404 .map_io = lpd7a40x_map_io, 402 .map_io = lpd7a40x_map_io,
405 .init_irq = lh7a400_init_irq, 403 .init_irq = lh7a400_init_irq,
@@ -413,8 +411,6 @@ MACHINE_END
413 411
414MACHINE_START (LPD7A404, "Logic Product Development LPD7A404-10") 412MACHINE_START (LPD7A404, "Logic Product Development LPD7A404-10")
415 /* Maintainer: Marc Singer */ 413 /* Maintainer: Marc Singer */
416 .phys_io = 0x80000000,
417 .io_pg_offst = ((io_p2v (0x80000000))>>18) & 0xfffc,
418 .boot_params = 0xc0000100, 414 .boot_params = 0xc0000100,
419 .map_io = lpd7a40x_map_io, 415 .map_io = lpd7a40x_map_io,
420 .init_irq = lh7a404_init_irq, 416 .init_irq = lh7a404_init_irq,
diff --git a/arch/arm/mach-lh7a40x/include/mach/debug-macro.S b/arch/arm/mach-lh7a40x/include/mach/debug-macro.S
index c0dcbbba22ba..cff33625276f 100644
--- a/arch/arm/mach-lh7a40x/include/mach/debug-macro.S
+++ b/arch/arm/mach-lh7a40x/include/mach/debug-macro.S
@@ -14,12 +14,10 @@
14 @ It is not known if this will be appropriate for every 40x 14 @ It is not known if this will be appropriate for every 40x
15 @ board. 15 @ board.
16 16
17 .macro addruart, rx, tmp 17 .macro addruart, rp, rv
18 mrc p15, 0, \rx, c1, c0 18 mov \rp, #0x00000700 @ offset from base
19 tst \rx, #1 @ MMU enabled? 19 orr \rv, \rp, #0xf8000000 @ virtual base
20 mov \rx, #0x00000700 @ offset from base 20 orr \rp, \rp, #0x80000000 @ physical base
21 orreq \rx, \rx, #0x80000000 @ physical base
22 orrne \rx, \rx, #0xf8000000 @ virtual base
23 .endm 21 .endm
24 22
25 .macro senduart,rd,rx 23 .macro senduart,rd,rx
diff --git a/arch/arm/mach-loki/include/mach/debug-macro.S b/arch/arm/mach-loki/include/mach/debug-macro.S
index 3136c913a92c..cc90d99ac76c 100644
--- a/arch/arm/mach-loki/include/mach/debug-macro.S
+++ b/arch/arm/mach-loki/include/mach/debug-macro.S
@@ -8,12 +8,11 @@
8 8
9#include <mach/loki.h> 9#include <mach/loki.h>
10 10
11 .macro addruart, rx, tmp 11 .macro addruart, rp, rv
12 mrc p15, 0, \rx, c1, c0 12 ldr \rp, =LOKI_REGS_PHYS_BASE
13 tst \rx, #1 @ MMU enabled? 13 ldr \rv, =LOKI_REGS_VIRT_BASE
14 ldreq \rx, =LOKI_REGS_PHYS_BASE 14 orr \rp, \rp, #0x00012000
15 ldrne \rx, =LOKI_REGS_VIRT_BASE 15 orr \rv, \rv, #0x00012000
16 orr \rx, \rx, #0x00012000
17 .endm 16 .endm
18 17
19#define UART_SHIFT 2 18#define UART_SHIFT 2
diff --git a/arch/arm/mach-loki/lb88rc8480-setup.c b/arch/arm/mach-loki/lb88rc8480-setup.c
index 85f9c1296aa0..a1e75e7fc500 100644
--- a/arch/arm/mach-loki/lb88rc8480-setup.c
+++ b/arch/arm/mach-loki/lb88rc8480-setup.c
@@ -90,8 +90,6 @@ static void __init lb88rc8480_init(void)
90 90
91MACHINE_START(LB88RC8480, "Marvell LB88RC8480 Development Board") 91MACHINE_START(LB88RC8480, "Marvell LB88RC8480 Development Board")
92 /* Maintainer: Ke Wei <kewei@marvell.com> */ 92 /* Maintainer: Ke Wei <kewei@marvell.com> */
93 .phys_io = LOKI_REGS_PHYS_BASE,
94 .io_pg_offst = ((LOKI_REGS_VIRT_BASE) >> 18) & 0xfffc,
95 .boot_params = 0x00000100, 93 .boot_params = 0x00000100,
96 .init_machine = lb88rc8480_init, 94 .init_machine = lb88rc8480_init,
97 .map_io = loki_map_io, 95 .map_io = loki_map_io,
diff --git a/arch/arm/mach-lpc32xx/include/mach/debug-macro.S b/arch/arm/mach-lpc32xx/include/mach/debug-macro.S
index 621744d6b152..629e744aeb9e 100644
--- a/arch/arm/mach-lpc32xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-lpc32xx/include/mach/debug-macro.S
@@ -20,11 +20,9 @@
20 * Debug output is hardcoded to standard UART 5 20 * Debug output is hardcoded to standard UART 5
21*/ 21*/
22 22
23 .macro addruart,rx, tmp 23 .macro addruart, rp, rv
24 mrc p15, 0, \rx, c1, c0 24 ldreq \rp, =0x40090000
25 tst \rx, #1 @ MMU enabled? 25 ldrne \rv, =0xF4090000
26 ldreq \rx, =0x40090000
27 ldrne \rx, =0xF4090000
28 .endm 26 .endm
29 27
30#define UART_SHIFT 2 28#define UART_SHIFT 2
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index bc9a42da2145..7993b096778e 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -172,18 +172,12 @@ static void phy3250_spi_cs_set(u32 control)
172} 172}
173 173
174static struct pl022_config_chip spi0_chip_info = { 174static struct pl022_config_chip spi0_chip_info = {
175 .lbm = LOOPBACK_DISABLED,
176 .com_mode = INTERRUPT_TRANSFER, 175 .com_mode = INTERRUPT_TRANSFER,
177 .iface = SSP_INTERFACE_MOTOROLA_SPI, 176 .iface = SSP_INTERFACE_MOTOROLA_SPI,
178 .hierarchy = SSP_MASTER, 177 .hierarchy = SSP_MASTER,
179 .slave_tx_disable = 0, 178 .slave_tx_disable = 0,
180 .endian_tx = SSP_TX_LSB,
181 .endian_rx = SSP_RX_LSB,
182 .data_size = SSP_DATA_BITS_8,
183 .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM, 179 .rx_lev_trig = SSP_RX_4_OR_MORE_ELEM,
184 .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC, 180 .tx_lev_trig = SSP_TX_4_OR_MORE_EMPTY_LOC,
185 .clk_phase = SSP_CLK_FIRST_EDGE,
186 .clk_pol = SSP_CLK_POL_IDLE_LOW,
187 .ctrl_len = SSP_BITS_8, 181 .ctrl_len = SSP_BITS_8,
188 .wait_state = SSP_MWIRE_WAIT_ZERO, 182 .wait_state = SSP_MWIRE_WAIT_ZERO,
189 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, 183 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
@@ -239,6 +233,7 @@ static int __init phy3250_spi_board_register(void)
239 .max_speed_hz = 5000000, 233 .max_speed_hz = 5000000,
240 .bus_num = 0, 234 .bus_num = 0,
241 .chip_select = 0, 235 .chip_select = 0,
236 .mode = SPI_MODE_0,
242 .platform_data = &eeprom, 237 .platform_data = &eeprom,
243 .controller_data = &spi0_chip_info, 238 .controller_data = &spi0_chip_info,
244 }, 239 },
@@ -387,8 +382,6 @@ arch_initcall(lpc32xx_display_uid);
387 382
388MACHINE_START(PHY3250, "Phytec 3250 board with the LPC3250 Microcontroller") 383MACHINE_START(PHY3250, "Phytec 3250 board with the LPC3250 Microcontroller")
389 /* Maintainer: Kevin Wells, NXP Semiconductors */ 384 /* Maintainer: Kevin Wells, NXP Semiconductors */
390 .phys_io = LPC32XX_UART5_BASE,
391 .io_pg_offst = ((IO_ADDRESS(LPC32XX_UART5_BASE))>>18) & 0xfffc,
392 .boot_params = 0x80000100, 385 .boot_params = 0x80000100,
393 .map_io = lpc32xx_map_io, 386 .map_io = lpc32xx_map_io,
394 .init_irq = lpc32xx_init_irq, 387 .init_irq = lpc32xx_init_irq,
diff --git a/arch/arm/mach-mmp/Kconfig b/arch/arm/mach-mmp/Kconfig
index 6ab843eaa35b..0711d3b620ad 100644
--- a/arch/arm/mach-mmp/Kconfig
+++ b/arch/arm/mach-mmp/Kconfig
@@ -57,6 +57,13 @@ config MACH_MARVELL_JASPER
57 PXA910-based development board. Since MMP2 is compatible to 57 PXA910-based development board. Since MMP2 is compatible to
58 ARMv6 architecture. 58 ARMv6 architecture.
59 59
60config MACH_TETON_BGA
61 bool "Marvell's PXA168 Teton BGA Development Board"
62 select CPU_PXA168
63 help
64 Say 'Y' here if you want to support the Marvell PXA168-based
65 Teton BGA Development Board.
66
60endmenu 67endmenu
61 68
62config CPU_PXA168 69config CPU_PXA168
diff --git a/arch/arm/mach-mmp/Makefile b/arch/arm/mach-mmp/Makefile
index 8b66d06739c4..751cdbf733c8 100644
--- a/arch/arm/mach-mmp/Makefile
+++ b/arch/arm/mach-mmp/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_MACH_TAVOREVB) += tavorevb.o
17obj-$(CONFIG_MACH_TTC_DKB) += ttc_dkb.o 17obj-$(CONFIG_MACH_TTC_DKB) += ttc_dkb.o
18obj-$(CONFIG_MACH_FLINT) += flint.o 18obj-$(CONFIG_MACH_FLINT) += flint.o
19obj-$(CONFIG_MACH_MARVELL_JASPER) += jasper.o 19obj-$(CONFIG_MACH_MARVELL_JASPER) += jasper.o
20obj-$(CONFIG_MACH_TETON_BGA) += teton_bga.o
diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 0629394a5fb9..06b5fa853c93 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -16,6 +16,7 @@
16#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h> 17#include <linux/mtd/partitions.h>
18#include <linux/mtd/nand.h> 18#include <linux/mtd/nand.h>
19#include <linux/interrupt.h>
19 20
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
@@ -23,6 +24,9 @@
23#include <mach/mfp-pxa168.h> 24#include <mach/mfp-pxa168.h>
24#include <mach/pxa168.h> 25#include <mach/pxa168.h>
25#include <mach/gpio.h> 26#include <mach/gpio.h>
27#include <video/pxa168fb.h>
28#include <linux/input.h>
29#include <plat/pxa27x_keypad.h>
26 30
27#include "common.h" 31#include "common.h"
28 32
@@ -66,6 +70,43 @@ static unsigned long common_pin_config[] __initdata = {
66 GPIO115_I2S_BCLK, 70 GPIO115_I2S_BCLK,
67 GPIO116_I2S_RXD, 71 GPIO116_I2S_RXD,
68 GPIO117_I2S_TXD, 72 GPIO117_I2S_TXD,
73
74 /* LCD */
75 GPIO56_LCD_FCLK_RD,
76 GPIO57_LCD_LCLK_A0,
77 GPIO58_LCD_PCLK_WR,
78 GPIO59_LCD_DENA_BIAS,
79 GPIO60_LCD_DD0,
80 GPIO61_LCD_DD1,
81 GPIO62_LCD_DD2,
82 GPIO63_LCD_DD3,
83 GPIO64_LCD_DD4,
84 GPIO65_LCD_DD5,
85 GPIO66_LCD_DD6,
86 GPIO67_LCD_DD7,
87 GPIO68_LCD_DD8,
88 GPIO69_LCD_DD9,
89 GPIO70_LCD_DD10,
90 GPIO71_LCD_DD11,
91 GPIO72_LCD_DD12,
92 GPIO73_LCD_DD13,
93 GPIO74_LCD_DD14,
94 GPIO75_LCD_DD15,
95 GPIO76_LCD_DD16,
96 GPIO77_LCD_DD17,
97 GPIO78_LCD_DD18,
98 GPIO79_LCD_DD19,
99 GPIO80_LCD_DD20,
100 GPIO81_LCD_DD21,
101 GPIO82_LCD_DD22,
102 GPIO83_LCD_DD23,
103
104 /* Keypad */
105 GPIO109_KP_MKIN1,
106 GPIO110_KP_MKIN0,
107 GPIO111_KP_MKOUT7,
108 GPIO112_KP_MKOUT6,
109 GPIO121_KP_MKIN4,
69}; 110};
70 111
71static struct smc91x_platdata smc91x_info = { 112static struct smc91x_platdata smc91x_info = {
@@ -134,6 +175,51 @@ static struct i2c_board_info aspenite_i2c_info[] __initdata = {
134 { I2C_BOARD_INFO("wm8753", 0x1b), }, 175 { I2C_BOARD_INFO("wm8753", 0x1b), },
135}; 176};
136 177
178static struct fb_videomode video_modes[] = {
179 [0] = {
180 .pixclock = 30120,
181 .refresh = 60,
182 .xres = 800,
183 .yres = 480,
184 .hsync_len = 1,
185 .left_margin = 215,
186 .right_margin = 40,
187 .vsync_len = 1,
188 .upper_margin = 34,
189 .lower_margin = 10,
190 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
191 },
192};
193
194struct pxa168fb_mach_info aspenite_lcd_info = {
195 .id = "Graphic Frame",
196 .modes = video_modes,
197 .num_modes = ARRAY_SIZE(video_modes),
198 .pix_fmt = PIX_FMT_RGB565,
199 .io_pin_allocation_mode = PIN_MODE_DUMB_24,
200 .dumb_mode = DUMB_MODE_RGB888,
201 .active = 1,
202 .panel_rbswap = 0,
203 .invert_pixclock = 0,
204};
205
206static unsigned int aspenite_matrix_key_map[] = {
207 KEY(0, 6, KEY_UP), /* SW 4 */
208 KEY(0, 7, KEY_DOWN), /* SW 5 */
209 KEY(1, 6, KEY_LEFT), /* SW 6 */
210 KEY(1, 7, KEY_RIGHT), /* SW 7 */
211 KEY(4, 6, KEY_ENTER), /* SW 8 */
212 KEY(4, 7, KEY_ESC), /* SW 9 */
213};
214
215static struct pxa27x_keypad_platform_data aspenite_keypad_info __initdata = {
216 .matrix_key_rows = 5,
217 .matrix_key_cols = 8,
218 .matrix_key_map = aspenite_matrix_key_map,
219 .matrix_key_map_size = ARRAY_SIZE(aspenite_matrix_key_map),
220 .debounce_interval = 30,
221};
222
137static void __init common_init(void) 223static void __init common_init(void)
138{ 224{
139 mfp_config(ARRAY_AND_SIZE(common_pin_config)); 225 mfp_config(ARRAY_AND_SIZE(common_pin_config));
@@ -143,24 +229,24 @@ static void __init common_init(void)
143 pxa168_add_twsi(1, NULL, ARRAY_AND_SIZE(aspenite_i2c_info)); 229 pxa168_add_twsi(1, NULL, ARRAY_AND_SIZE(aspenite_i2c_info));
144 pxa168_add_ssp(1); 230 pxa168_add_ssp(1);
145 pxa168_add_nand(&aspenite_nand_info); 231 pxa168_add_nand(&aspenite_nand_info);
232 pxa168_add_fb(&aspenite_lcd_info);
233 pxa168_add_keypad(&aspenite_keypad_info);
146 234
147 /* off-chip devices */ 235 /* off-chip devices */
148 platform_device_register(&smc91x_device); 236 platform_device_register(&smc91x_device);
149} 237}
150 238
151MACHINE_START(ASPENITE, "PXA168-based Aspenite Development Platform") 239MACHINE_START(ASPENITE, "PXA168-based Aspenite Development Platform")
152 .phys_io = APB_PHYS_BASE,
153 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
154 .map_io = mmp_map_io, 240 .map_io = mmp_map_io,
241 .nr_irqs = IRQ_BOARD_START,
155 .init_irq = pxa168_init_irq, 242 .init_irq = pxa168_init_irq,
156 .timer = &pxa168_timer, 243 .timer = &pxa168_timer,
157 .init_machine = common_init, 244 .init_machine = common_init,
158MACHINE_END 245MACHINE_END
159 246
160MACHINE_START(ZYLONITE2, "PXA168-based Zylonite2 Development Platform") 247MACHINE_START(ZYLONITE2, "PXA168-based Zylonite2 Development Platform")
161 .phys_io = APB_PHYS_BASE,
162 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
163 .map_io = mmp_map_io, 248 .map_io = mmp_map_io,
249 .nr_irqs = IRQ_BOARD_START,
164 .init_irq = pxa168_init_irq, 250 .init_irq = pxa168_init_irq,
165 .timer = &pxa168_timer, 251 .timer = &pxa168_timer,
166 .init_machine = common_init, 252 .init_machine = common_init,
diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c
index 69bcba11f53f..39f0878d64a0 100644
--- a/arch/arm/mach-mmp/avengers_lite.c
+++ b/arch/arm/mach-mmp/avengers_lite.c
@@ -41,8 +41,6 @@ static void __init avengers_lite_init(void)
41} 41}
42 42
43MACHINE_START(AVENGERS_LITE, "PXA168 Avengers lite Development Platform") 43MACHINE_START(AVENGERS_LITE, "PXA168 Avengers lite Development Platform")
44 .phys_io = APB_PHYS_BASE,
45 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
46 .map_io = mmp_map_io, 44 .map_io = mmp_map_io,
47 .init_irq = pxa168_init_irq, 45 .init_irq = pxa168_init_irq,
48 .timer = &pxa168_timer, 46 .timer = &pxa168_timer,
diff --git a/arch/arm/mach-mmp/common.c b/arch/arm/mach-mmp/common.c
index 3b29fa7e9b08..0ec0ca80bb3e 100644
--- a/arch/arm/mach-mmp/common.c
+++ b/arch/arm/mach-mmp/common.c
@@ -10,13 +10,20 @@
10 10
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h>
13 14
14#include <asm/page.h> 15#include <asm/page.h>
15#include <asm/mach/map.h> 16#include <asm/mach/map.h>
16#include <mach/addr-map.h> 17#include <mach/addr-map.h>
18#include <mach/cputype.h>
17 19
18#include "common.h" 20#include "common.h"
19 21
22#define MMP_CHIPID (AXI_VIRT_BASE + 0x82c00)
23
24unsigned int mmp_chip_id;
25EXPORT_SYMBOL(mmp_chip_id);
26
20static struct map_desc standard_io_desc[] __initdata = { 27static struct map_desc standard_io_desc[] __initdata = {
21 { 28 {
22 .pfn = __phys_to_pfn(APB_PHYS_BASE), 29 .pfn = __phys_to_pfn(APB_PHYS_BASE),
@@ -34,4 +41,7 @@ static struct map_desc standard_io_desc[] __initdata = {
34void __init mmp_map_io(void) 41void __init mmp_map_io(void)
35{ 42{
36 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); 43 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
44
45 /* this is early, initialize mmp_chip_id here */
46 mmp_chip_id = __raw_readl(MMP_CHIPID);
37} 47}
diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c
index e4312d238eae..bdeb6db4d49a 100644
--- a/arch/arm/mach-mmp/flint.c
+++ b/arch/arm/mach-mmp/flint.c
@@ -16,6 +16,7 @@
16#include <linux/smc91x.h> 16#include <linux/smc91x.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/interrupt.h>
19 20
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
@@ -25,6 +26,8 @@
25 26
26#include "common.h" 27#include "common.h"
27 28
29#define FLINT_NR_IRQS (IRQ_BOARD_START + 48)
30
28static unsigned long flint_pin_config[] __initdata = { 31static unsigned long flint_pin_config[] __initdata = {
29 /* UART1 */ 32 /* UART1 */
30 GPIO45_UART1_RXD, 33 GPIO45_UART1_RXD,
@@ -113,9 +116,8 @@ static void __init flint_init(void)
113} 116}
114 117
115MACHINE_START(FLINT, "Flint Development Platform") 118MACHINE_START(FLINT, "Flint Development Platform")
116 .phys_io = APB_PHYS_BASE,
117 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
118 .map_io = mmp_map_io, 119 .map_io = mmp_map_io,
120 .nr_irqs = FLINT_NR_IRQS,
119 .init_irq = mmp2_init_irq, 121 .init_irq = mmp2_init_irq,
120 .timer = &mmp2_timer, 122 .timer = &mmp2_timer,
121 .init_machine = flint_init, 123 .init_machine = flint_init,
diff --git a/arch/arm/mach-mmp/include/mach/cputype.h b/arch/arm/mach-mmp/include/mach/cputype.h
index 83b18721d933..f43a68b213f1 100644
--- a/arch/arm/mach-mmp/include/mach/cputype.h
+++ b/arch/arm/mach-mmp/include/mach/cputype.h
@@ -4,36 +4,51 @@
4#include <asm/cputype.h> 4#include <asm/cputype.h>
5 5
6/* 6/*
7 * CPU Stepping OLD_ID CPU_ID CHIP_ID 7 * CPU Stepping CPU_ID CHIP_ID
8 * 8 *
9 * PXA168 A0 0x41159263 0x56158400 0x00A0A333 9 * PXA168 S0 0x56158400 0x0000C910
10 * PXA910 Y0 0x41159262 0x56158000 0x00F0C910 10 * PXA168 A0 0x56158400 0x00A0A168
11 * MMP2 Z0 0x560f5811 11 * PXA910 Y1 0x56158400 0x00F2C920
12 * PXA910 A0 0x56158400 0x00F2C910
13 * PXA910 A1 0x56158400 0x00A0C910
14 * PXA920 Y0 0x56158400 0x00F2C920
15 * PXA920 A0 0x56158400 0x00A0C920
16 * PXA920 A1 0x56158400 0x00A1C920
17 * MMP2 Z0 0x560f5811 0x00F00410
18 * MMP2 Z1 0x560f5811 0x00E00410
19 * MMP2 A0 0x560f5811 0x00A0A610
12 */ 20 */
13 21
22extern unsigned int mmp_chip_id;
23
14#ifdef CONFIG_CPU_PXA168 24#ifdef CONFIG_CPU_PXA168
15# define __cpu_is_pxa168(id) \ 25static inline int cpu_is_pxa168(void)
16 ({ unsigned int _id = ((id) >> 8) & 0xff; _id == 0x84; }) 26{
27 return (((read_cpuid_id() >> 8) & 0xff) == 0x84) &&
28 ((mmp_chip_id & 0xfff) == 0x168);
29}
17#else 30#else
18# define __cpu_is_pxa168(id) (0) 31#define cpu_is_pxa168() (0)
19#endif 32#endif
20 33
34/* cpu_is_pxa910() is shared on both pxa910 and pxa920 */
21#ifdef CONFIG_CPU_PXA910 35#ifdef CONFIG_CPU_PXA910
22# define __cpu_is_pxa910(id) \ 36static inline int cpu_is_pxa910(void)
23 ({ unsigned int _id = ((id) >> 8) & 0xff; _id == 0x80; }) 37{
38 return (((read_cpuid_id() >> 8) & 0xff) == 0x84) &&
39 (((mmp_chip_id & 0xfff) == 0x910) ||
40 ((mmp_chip_id & 0xfff) == 0x920));
41}
24#else 42#else
25# define __cpu_is_pxa910(id) (0) 43#define cpu_is_pxa910() (0)
26#endif 44#endif
27 45
28#ifdef CONFIG_CPU_MMP2 46#ifdef CONFIG_CPU_MMP2
29# define __cpu_is_mmp2(id) \ 47static inline int cpu_is_mmp2(void)
30 ({ unsigned int _id = ((id) >> 8) & 0xff; _id == 0x58; }) 48{
49 return (((cpu_readid_id() >> 8) & 0xff) == 0x58);
31#else 50#else
32# define __cpu_is_mmp2(id) (0) 51#define cpu_is_mmp2() (0)
33#endif 52#endif
34 53
35#define cpu_is_pxa168() ({ __cpu_is_pxa168(read_cpuid_id()); })
36#define cpu_is_pxa910() ({ __cpu_is_pxa910(read_cpuid_id()); })
37#define cpu_is_mmp2() ({ __cpu_is_mmp2(read_cpuid_id()); })
38
39#endif /* __ASM_MACH_CPUTYPE_H */ 54#endif /* __ASM_MACH_CPUTYPE_H */
diff --git a/arch/arm/mach-mmp/include/mach/debug-macro.S b/arch/arm/mach-mmp/include/mach/debug-macro.S
index 76deff238e1c..7e2ebd3efc7c 100644
--- a/arch/arm/mach-mmp/include/mach/debug-macro.S
+++ b/arch/arm/mach-mmp/include/mach/debug-macro.S
@@ -11,12 +11,11 @@
11 11
12#include <mach/addr-map.h> 12#include <mach/addr-map.h>
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 ldr \rp, =APB_PHYS_BASE @ physical
16 tst \rx, #1 @ MMU enabled? 16 ldr \rv, =APB_VIRT_BASE @ virtual
17 ldreq \rx, =APB_PHYS_BASE @ physical 17 orr \rp, \rp, #0x00017000
18 ldrne \rx, =APB_VIRT_BASE @ virtual 18 orr \rv, \rv, #0x00017000
19 orr \rx, \rx, #0x00017000
20 .endm 19 .endm
21 20
22#define UART_SHIFT 2 21#define UART_SHIFT 2
diff --git a/arch/arm/mach-mmp/include/mach/irqs.h b/arch/arm/mach-mmp/include/mach/irqs.h
index b379cdec4d38..a09d328e2ddd 100644
--- a/arch/arm/mach-mmp/include/mach/irqs.h
+++ b/arch/arm/mach-mmp/include/mach/irqs.h
@@ -222,10 +222,8 @@
222#define IRQ_GPIO_NUM 192 222#define IRQ_GPIO_NUM 192
223#define IRQ_GPIO(x) (IRQ_GPIO_START + (x)) 223#define IRQ_GPIO(x) (IRQ_GPIO_START + (x))
224 224
225/* Board IRQ - 64 by default, increase if not enough */
226#define IRQ_BOARD_START (IRQ_GPIO_START + IRQ_GPIO_NUM) 225#define IRQ_BOARD_START (IRQ_GPIO_START + IRQ_GPIO_NUM)
227#define IRQ_BOARD_END (IRQ_BOARD_START + 64)
228 226
229#define NR_IRQS (IRQ_BOARD_END) 227#define NR_IRQS (IRQ_BOARD_START)
230 228
231#endif /* __ASM_MACH_IRQS_H */ 229#endif /* __ASM_MACH_IRQS_H */
diff --git a/arch/arm/mach-mmp/include/mach/mfp-pxa168.h b/arch/arm/mach-mmp/include/mach/mfp-pxa168.h
index ded43c455ec3..4621067c7720 100644
--- a/arch/arm/mach-mmp/include/mach/mfp-pxa168.h
+++ b/arch/arm/mach-mmp/include/mach/mfp-pxa168.h
@@ -289,4 +289,11 @@
289#define GPIO86_PWM1_OUT MFP_CFG(GPIO86, AF2) 289#define GPIO86_PWM1_OUT MFP_CFG(GPIO86, AF2)
290#define GPIO86_PWM2_OUT MFP_CFG(GPIO86, AF3) 290#define GPIO86_PWM2_OUT MFP_CFG(GPIO86, AF3)
291 291
292/* Keypad */
293#define GPIO109_KP_MKIN1 MFP_CFG(GPIO109, AF7)
294#define GPIO110_KP_MKIN0 MFP_CFG(GPIO110, AF7)
295#define GPIO111_KP_MKOUT7 MFP_CFG(GPIO111, AF7)
296#define GPIO112_KP_MKOUT6 MFP_CFG(GPIO112, AF7)
297#define GPIO121_KP_MKIN4 MFP_CFG(GPIO121, AF7)
298
292#endif /* __ASM_MACH_MFP_PXA168_H */ 299#endif /* __ASM_MACH_MFP_PXA168_H */
diff --git a/arch/arm/mach-mmp/include/mach/pxa168.h b/arch/arm/mach-mmp/include/mach/pxa168.h
index 27e1bc758623..1801e4206232 100644
--- a/arch/arm/mach-mmp/include/mach/pxa168.h
+++ b/arch/arm/mach-mmp/include/mach/pxa168.h
@@ -5,11 +5,15 @@ struct sys_timer;
5 5
6extern struct sys_timer pxa168_timer; 6extern struct sys_timer pxa168_timer;
7extern void __init pxa168_init_irq(void); 7extern void __init pxa168_init_irq(void);
8extern void pxa168_clear_keypad_wakeup(void);
8 9
9#include <linux/i2c.h> 10#include <linux/i2c.h>
10#include <mach/devices.h> 11#include <mach/devices.h>
11#include <plat/i2c.h> 12#include <plat/i2c.h>
12#include <plat/pxa3xx_nand.h> 13#include <plat/pxa3xx_nand.h>
14#include <video/pxa168fb.h>
15#include <plat/pxa27x_keypad.h>
16#include <mach/cputype.h>
13 17
14extern struct pxa_device_desc pxa168_device_uart1; 18extern struct pxa_device_desc pxa168_device_uart1;
15extern struct pxa_device_desc pxa168_device_uart2; 19extern struct pxa_device_desc pxa168_device_uart2;
@@ -25,6 +29,8 @@ extern struct pxa_device_desc pxa168_device_ssp3;
25extern struct pxa_device_desc pxa168_device_ssp4; 29extern struct pxa_device_desc pxa168_device_ssp4;
26extern struct pxa_device_desc pxa168_device_ssp5; 30extern struct pxa_device_desc pxa168_device_ssp5;
27extern struct pxa_device_desc pxa168_device_nand; 31extern struct pxa_device_desc pxa168_device_nand;
32extern struct pxa_device_desc pxa168_device_fb;
33extern struct pxa_device_desc pxa168_device_keypad;
28 34
29static inline int pxa168_add_uart(int id) 35static inline int pxa168_add_uart(int id)
30{ 36{
@@ -97,4 +103,18 @@ static inline int pxa168_add_nand(struct pxa3xx_nand_platform_data *info)
97{ 103{
98 return pxa_register_device(&pxa168_device_nand, info, sizeof(*info)); 104 return pxa_register_device(&pxa168_device_nand, info, sizeof(*info));
99} 105}
106
107static inline int pxa168_add_fb(struct pxa168fb_mach_info *mi)
108{
109 return pxa_register_device(&pxa168_device_fb, mi, sizeof(*mi));
110}
111
112static inline int pxa168_add_keypad(struct pxa27x_keypad_platform_data *data)
113{
114 if (cpu_is_pxa168())
115 data->clear_wakeup_event = pxa168_clear_keypad_wakeup;
116
117 return pxa_register_device(&pxa168_device_keypad, data, sizeof(*data));
118}
119
100#endif /* __ASM_MACH_PXA168_H */ 120#endif /* __ASM_MACH_PXA168_H */
diff --git a/arch/arm/mach-mmp/include/mach/regs-apmu.h b/arch/arm/mach-mmp/include/mach/regs-apmu.h
index 919030514120..ac4702357a6e 100644
--- a/arch/arm/mach-mmp/include/mach/regs-apmu.h
+++ b/arch/arm/mach-mmp/include/mach/regs-apmu.h
@@ -33,4 +33,16 @@
33#define APMU_FNRST_DIS (1 << 1) 33#define APMU_FNRST_DIS (1 << 1)
34#define APMU_AXIRST_DIS (1 << 0) 34#define APMU_AXIRST_DIS (1 << 0)
35 35
36/* Wake Clear Register */
37#define APMU_WAKE_CLR APMU_REG(0x07c)
38
39#define APMU_PXA168_KP_WAKE_CLR (1 << 7)
40#define APMU_PXA168_CFI_WAKE_CLR (1 << 6)
41#define APMU_PXA168_XD_WAKE_CLR (1 << 5)
42#define APMU_PXA168_MSP_WAKE_CLR (1 << 4)
43#define APMU_PXA168_SD4_WAKE_CLR (1 << 3)
44#define APMU_PXA168_SD3_WAKE_CLR (1 << 2)
45#define APMU_PXA168_SD2_WAKE_CLR (1 << 1)
46#define APMU_PXA168_SD1_WAKE_CLR (1 << 0)
47
36#endif /* __ASM_MACH_REGS_APMU_H */ 48#endif /* __ASM_MACH_REGS_APMU_H */
diff --git a/arch/arm/mach-mmp/include/mach/teton_bga.h b/arch/arm/mach-mmp/include/mach/teton_bga.h
new file mode 100644
index 000000000000..61a539b2cc98
--- /dev/null
+++ b/arch/arm/mach-mmp/include/mach/teton_bga.h
@@ -0,0 +1,27 @@
1/*
2 * linux/arch/arm/mach-mmp/include/mach/teton_bga.h
3 *
4 * Support for the Marvell PXA168 Teton BGA Development Platform.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * publishhed by the Free Software Foundation.
9 */
10#ifndef __ASM_MACH_TETON_BGA_H
11#define __ASM_MACH_TETON_BGA_H
12
13/* GPIOs */
14#define MMC_PWENA_GPIO 27
15#define USBHPENB_GPIO 55
16#define RTC_INT_GPIO 78
17#define LCD_VBLK_EN_GPIO 79
18#define LCD_DVDD_EN_GPIO 80
19#define RST_WIFI_GPIO 81
20#define CF_PWEN_GPIO 82
21#define USB_OC_GPIO 83
22#define PWM_GPIO 84
23#define USBHPENA_GPIO 85
24#define TS_INT_GPIO 86
25#define CIR_GPIO 108
26
27#endif /* __ASM_MACH_TETON_BGA_H */
diff --git a/arch/arm/mach-mmp/jasper.c b/arch/arm/mach-mmp/jasper.c
index 80c3e7ab1e17..2a684fa50773 100644
--- a/arch/arm/mach-mmp/jasper.c
+++ b/arch/arm/mach-mmp/jasper.c
@@ -18,16 +18,18 @@
18#include <linux/regulator/machine.h> 18#include <linux/regulator/machine.h>
19#include <linux/regulator/max8649.h> 19#include <linux/regulator/max8649.h>
20#include <linux/mfd/max8925.h> 20#include <linux/mfd/max8925.h>
21#include <linux/interrupt.h>
21 22
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <mach/addr-map.h> 25#include <mach/addr-map.h>
25#include <mach/mfp-mmp2.h> 26#include <mach/mfp-mmp2.h>
26#include <mach/mmp2.h> 27#include <mach/mmp2.h>
27#include <mach/irqs.h>
28 28
29#include "common.h" 29#include "common.h"
30 30
31#define JASPER_NR_IRQS (IRQ_BOARD_START + 48)
32
31static unsigned long jasper_pin_config[] __initdata = { 33static unsigned long jasper_pin_config[] __initdata = {
32 /* UART1 */ 34 /* UART1 */
33 GPIO29_UART1_RXD, 35 GPIO29_UART1_RXD,
@@ -134,9 +136,8 @@ static void __init jasper_init(void)
134} 136}
135 137
136MACHINE_START(MARVELL_JASPER, "Jasper Development Platform") 138MACHINE_START(MARVELL_JASPER, "Jasper Development Platform")
137 .phys_io = APB_PHYS_BASE,
138 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
139 .map_io = mmp_map_io, 139 .map_io = mmp_map_io,
140 .nr_irqs = JASPER_NR_IRQS,
140 .init_irq = mmp2_init_irq, 141 .init_irq = mmp2_init_irq,
141 .timer = &mmp2_timer, 142 .timer = &mmp2_timer,
142 .init_machine = jasper_init, 143 .init_machine = jasper_init,
diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
index 652ae660634c..72b4e7631583 100644
--- a/arch/arm/mach-mmp/pxa168.c
+++ b/arch/arm/mach-mmp/pxa168.c
@@ -77,8 +77,10 @@ static APBC_CLK(ssp2, PXA168_SSP2, 4, 0);
77static APBC_CLK(ssp3, PXA168_SSP3, 4, 0); 77static APBC_CLK(ssp3, PXA168_SSP3, 4, 0);
78static APBC_CLK(ssp4, PXA168_SSP4, 4, 0); 78static APBC_CLK(ssp4, PXA168_SSP4, 4, 0);
79static APBC_CLK(ssp5, PXA168_SSP5, 4, 0); 79static APBC_CLK(ssp5, PXA168_SSP5, 4, 0);
80static APBC_CLK(keypad, PXA168_KPC, 0, 32000);
80 81
81static APMU_CLK(nand, NAND, 0x01db, 208000000); 82static APMU_CLK(nand, NAND, 0x01db, 208000000);
83static APMU_CLK(lcd, LCD, 0x7f, 312000000);
82 84
83/* device and clock bindings */ 85/* device and clock bindings */
84static struct clk_lookup pxa168_clkregs[] = { 86static struct clk_lookup pxa168_clkregs[] = {
@@ -96,6 +98,8 @@ static struct clk_lookup pxa168_clkregs[] = {
96 INIT_CLKREG(&clk_ssp4, "pxa168-ssp.3", NULL), 98 INIT_CLKREG(&clk_ssp4, "pxa168-ssp.3", NULL),
97 INIT_CLKREG(&clk_ssp5, "pxa168-ssp.4", NULL), 99 INIT_CLKREG(&clk_ssp5, "pxa168-ssp.4", NULL),
98 INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL), 100 INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
101 INIT_CLKREG(&clk_lcd, "pxa168-fb", NULL),
102 INIT_CLKREG(&clk_keypad, "pxa27x-keypad", NULL),
99}; 103};
100 104
101static int __init pxa168_init(void) 105static int __init pxa168_init(void)
@@ -132,6 +136,16 @@ struct sys_timer pxa168_timer = {
132 .init = pxa168_timer_init, 136 .init = pxa168_timer_init,
133}; 137};
134 138
139void pxa168_clear_keypad_wakeup(void)
140{
141 uint32_t val;
142 uint32_t mask = APMU_PXA168_KP_WAKE_CLR;
143
144 /* wake event clear is needed in order to clear keypad interrupt */
145 val = __raw_readl(APMU_WAKE_CLR);
146 __raw_writel(val | mask, APMU_WAKE_CLR);
147}
148
135/* on-chip devices */ 149/* on-chip devices */
136PXA168_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4017000, 0x30, 21, 22); 150PXA168_DEVICE(uart1, "pxa2xx-uart", 0, UART1, 0xd4017000, 0x30, 21, 22);
137PXA168_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4018000, 0x30, 23, 24); 151PXA168_DEVICE(uart2, "pxa2xx-uart", 1, UART2, 0xd4018000, 0x30, 23, 24);
@@ -147,3 +161,5 @@ PXA168_DEVICE(ssp2, "pxa168-ssp", 1, SSP2, 0xd401c000, 0x40, 54, 55);
147PXA168_DEVICE(ssp3, "pxa168-ssp", 2, SSP3, 0xd401f000, 0x40, 56, 57); 161PXA168_DEVICE(ssp3, "pxa168-ssp", 2, SSP3, 0xd401f000, 0x40, 56, 57);
148PXA168_DEVICE(ssp4, "pxa168-ssp", 3, SSP4, 0xd4020000, 0x40, 58, 59); 162PXA168_DEVICE(ssp4, "pxa168-ssp", 3, SSP4, 0xd4020000, 0x40, 58, 59);
149PXA168_DEVICE(ssp5, "pxa168-ssp", 4, SSP5, 0xd4021000, 0x40, 60, 61); 163PXA168_DEVICE(ssp5, "pxa168-ssp", 4, SSP5, 0xd4021000, 0x40, 60, 61);
164PXA168_DEVICE(fb, "pxa168-fb", -1, LCD, 0xd420b000, 0x1c8);
165PXA168_DEVICE(keypad, "pxa27x-keypad", -1, KEYPAD, 0xd4012000, 0x4c);
diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c
index e81db7428215..c296b75c4453 100644
--- a/arch/arm/mach-mmp/tavorevb.c
+++ b/arch/arm/mach-mmp/tavorevb.c
@@ -99,8 +99,6 @@ static void __init tavorevb_init(void)
99} 99}
100 100
101MACHINE_START(TAVOREVB, "PXA910 Evaluation Board (aka TavorEVB)") 101MACHINE_START(TAVOREVB, "PXA910 Evaluation Board (aka TavorEVB)")
102 .phys_io = APB_PHYS_BASE,
103 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
104 .map_io = mmp_map_io, 102 .map_io = mmp_map_io,
105 .init_irq = pxa910_init_irq, 103 .init_irq = pxa910_init_irq,
106 .timer = &pxa910_timer, 104 .timer = &pxa910_timer,
diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c
new file mode 100644
index 000000000000..bbe4727b96cc
--- /dev/null
+++ b/arch/arm/mach-mmp/teton_bga.c
@@ -0,0 +1,89 @@
1/*
2 * linux/arch/arm/mach-mmp/teton_bga.c
3 *
4 * Support for the Marvell PXA168 Teton BGA Development Platform.
5 *
6 * Author: Mark F. Brown <mark.brown314@gmail.com>
7 *
8 * This code is based on aspenite.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 * publishhed by the Free Software Foundation.
13 */
14
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/platform_device.h>
18#include <linux/gpio.h>
19#include <linux/input.h>
20#include <plat/pxa27x_keypad.h>
21#include <linux/i2c.h>
22
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <mach/addr-map.h>
26#include <mach/mfp-pxa168.h>
27#include <mach/pxa168.h>
28#include <mach/teton_bga.h>
29
30#include "common.h"
31
32static unsigned long teton_bga_pin_config[] __initdata = {
33 /* UART1 */
34 GPIO107_UART1_TXD,
35 GPIO108_UART1_RXD,
36
37 /* Keypad */
38 GPIO109_KP_MKIN1,
39 GPIO110_KP_MKIN0,
40 GPIO111_KP_MKOUT7,
41 GPIO112_KP_MKOUT6,
42
43 /* I2C Bus */
44 GPIO105_CI2C_SDA,
45 GPIO106_CI2C_SCL,
46
47 /* RTC */
48 GPIO78_GPIO,
49};
50
51static unsigned int teton_bga_matrix_key_map[] = {
52 KEY(0, 6, KEY_ESC),
53 KEY(0, 7, KEY_ENTER),
54 KEY(1, 6, KEY_LEFT),
55 KEY(1, 7, KEY_RIGHT),
56};
57
58static struct pxa27x_keypad_platform_data teton_bga_keypad_info __initdata = {
59 .matrix_key_rows = 2,
60 .matrix_key_cols = 8,
61 .matrix_key_map = teton_bga_matrix_key_map,
62 .matrix_key_map_size = ARRAY_SIZE(teton_bga_matrix_key_map),
63 .debounce_interval = 30,
64};
65
66static struct i2c_board_info teton_bga_i2c_info[] __initdata = {
67 {
68 I2C_BOARD_INFO("ds1337", 0x68),
69 .irq = gpio_to_irq(RTC_INT_GPIO)
70 },
71};
72
73static void __init teton_bga_init(void)
74{
75 mfp_config(ARRAY_AND_SIZE(teton_bga_pin_config));
76
77 /* on-chip devices */
78 pxa168_add_uart(1);
79 pxa168_add_keypad(&teton_bga_keypad_info);
80 pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(teton_bga_i2c_info));
81}
82
83MACHINE_START(TETON_BGA, "PXA168-based Teton BGA Development Platform")
84 .map_io = mmp_map_io,
85 .nr_irqs = IRQ_BOARD_START,
86 .init_irq = pxa168_init_irq,
87 .timer = &pxa168_timer,
88 .init_machine = teton_bga_init,
89MACHINE_END
diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index ee65e05f0cf1..e411039ea59e 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -14,6 +14,7 @@
14#include <linux/mtd/mtd.h> 14#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h> 15#include <linux/mtd/partitions.h>
16#include <linux/mtd/onenand.h> 16#include <linux/mtd/onenand.h>
17#include <linux/interrupt.h>
17 18
18#include <asm/mach-types.h> 19#include <asm/mach-types.h>
19#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
@@ -24,6 +25,8 @@
24 25
25#include "common.h" 26#include "common.h"
26 27
28#define TTCDKB_NR_IRQS (IRQ_BOARD_START + 24)
29
27static unsigned long ttc_dkb_pin_config[] __initdata = { 30static unsigned long ttc_dkb_pin_config[] __initdata = {
28 /* UART2 */ 31 /* UART2 */
29 GPIO47_UART2_RXD, 32 GPIO47_UART2_RXD,
@@ -122,9 +125,8 @@ static void __init ttc_dkb_init(void)
122} 125}
123 126
124MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform") 127MACHINE_START(TTC_DKB, "PXA910-based TTC_DKB Development Platform")
125 .phys_io = APB_PHYS_BASE,
126 .io_pg_offst = (APB_VIRT_BASE >> 18) & 0xfffc,
127 .map_io = mmp_map_io, 128 .map_io = mmp_map_io,
129 .nr_irqs = TTCDKB_NR_IRQS,
128 .init_irq = pxa910_init_irq, 130 .init_irq = pxa910_init_irq,
129 .timer = &pxa910_timer, 131 .timer = &pxa910_timer,
130 .init_machine = ttc_dkb_init, 132 .init_machine = ttc_dkb_init,
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 47264a76eeb3..3115a29dec4e 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -10,6 +10,8 @@ config ARCH_MSM7X00A
10 select MSM_SMD 10 select MSM_SMD
11 select MSM_SMD_PKG3 11 select MSM_SMD_PKG3
12 select CPU_V6 12 select CPU_V6
13 select MSM_PROC_COMM
14 select HAS_MSM_DEBUG_UART_PHYS
13 15
14config ARCH_MSM7X30 16config ARCH_MSM7X30
15 bool "MSM7x30" 17 bool "MSM7x30"
@@ -18,6 +20,9 @@ config ARCH_MSM7X30
18 select MSM_VIC 20 select MSM_VIC
19 select CPU_V7 21 select CPU_V7
20 select MSM_REMOTE_SPINLOCK_DEKKERS 22 select MSM_REMOTE_SPINLOCK_DEKKERS
23 select MSM_GPIOMUX
24 select MSM_PROC_COMM
25 select HAS_MSM_DEBUG_UART_PHYS
21 26
22config ARCH_QSD8X50 27config ARCH_QSD8X50
23 bool "QSD8X50" 28 bool "QSD8X50"
@@ -26,6 +31,19 @@ config ARCH_QSD8X50
26 select MSM_VIC 31 select MSM_VIC
27 select CPU_V7 32 select CPU_V7
28 select MSM_REMOTE_SPINLOCK_LDREX 33 select MSM_REMOTE_SPINLOCK_LDREX
34 select MSM_GPIOMUX
35 select MSM_PROC_COMM
36 select HAS_MSM_DEBUG_UART_PHYS
37
38config ARCH_MSM8X60
39 bool "MSM8X60"
40 select ARM_GIC
41 select CPU_V7
42 select MSM_V2_TLMM
43 select MSM_GPIOMUX
44 select MACH_MSM8X60_SURF if (!MACH_MSM8X60_RUMI3 && !MACH_MSM8X60_SIM \
45 && !MACH_MSM8X60_FFA)
46
29endchoice 47endchoice
30 48
31config MSM_SOC_REV_A 49config MSM_SOC_REV_A
@@ -36,6 +54,9 @@ config ARCH_MSM_ARM11
36config ARCH_MSM_SCORPION 54config ARCH_MSM_SCORPION
37 bool 55 bool
38 56
57config HAS_MSM_DEBUG_UART_PHYS
58 bool
59
39config MSM_VIC 60config MSM_VIC
40 bool 61 bool
41 62
@@ -74,6 +95,30 @@ config MACH_QSD8X50A_ST1_5
74 help 95 help
75 Support for the Qualcomm ST1.5. 96 Support for the Qualcomm ST1.5.
76 97
98config MACH_MSM8X60_RUMI3
99 depends on ARCH_MSM8X60
100 bool "MSM8x60 RUMI3"
101 help
102 Support for the Qualcomm MSM8x60 RUMI3 emulator.
103
104config MACH_MSM8X60_SURF
105 depends on ARCH_MSM8X60
106 bool "MSM8x60 SURF"
107 help
108 Support for the Qualcomm MSM8x60 SURF eval board.
109
110config MACH_MSM8X60_SIM
111 depends on ARCH_MSM8X60
112 bool "MSM8x60 Simulator"
113 help
114 Support for the Qualcomm MSM8x60 simulator.
115
116config MACH_MSM8X60_FFA
117 depends on ARCH_MSM8X60
118 bool "MSM8x60 FFA"
119 help
120 Support for the Qualcomm MSM8x60 FFA eval board.
121
77endmenu 122endmenu
78 123
79config MSM_DEBUG_UART 124config MSM_DEBUG_UART
@@ -82,6 +127,7 @@ config MSM_DEBUG_UART
82 default 2 if MSM_DEBUG_UART2 127 default 2 if MSM_DEBUG_UART2
83 default 3 if MSM_DEBUG_UART3 128 default 3 if MSM_DEBUG_UART3
84 129
130if HAS_MSM_DEBUG_UART_PHYS
85choice 131choice
86 prompt "Debug UART" 132 prompt "Debug UART"
87 133
@@ -99,11 +145,20 @@ choice
99 config MSM_DEBUG_UART3 145 config MSM_DEBUG_UART3
100 bool "UART3" 146 bool "UART3"
101endchoice 147endchoice
148endif
102 149
103config MSM_SMD_PKG3 150config MSM_SMD_PKG3
104 bool 151 bool
105 152
153config MSM_PROC_COMM
154 bool
155
106config MSM_SMD 156config MSM_SMD
107 bool 157 bool
108 158
159config MSM_GPIOMUX
160 bool
161
162config MSM_V2_TLMM
163 bool
109endif 164endif
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 704610648a25..b5a7b07a44f5 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -1,16 +1,20 @@
1obj-y += proc_comm.o 1obj-y += io.o idle.o timer.o
2obj-y += io.o idle.o timer.o dma.o 2ifndef CONFIG_ARCH_MSM8X60
3obj-y += vreg.o
4obj-y += acpuclock-arm11.o 3obj-y += acpuclock-arm11.o
5obj-y += clock.o clock-pcom.o 4obj-y += dma.o
6obj-y += gpio.o 5endif
7 6
8ifdef CONFIG_MSM_VIC 7ifdef CONFIG_MSM_VIC
9obj-y += irq-vic.o 8obj-y += irq-vic.o
10else 9else
10ifndef CONFIG_ARCH_MSM8X60
11obj-y += irq.o 11obj-y += irq.o
12endif 12endif
13endif
13 14
15obj-$(CONFIG_ARCH_MSM8X60) += clock-dummy.o iommu.o iommu_dev.o devices-msm8x60-iommu.o
16obj-$(CONFIG_MSM_PROC_COMM) += proc_comm.o clock-pcom.o vreg.o
17obj-$(CONFIG_MSM_PROC_COMM) += clock.o
14obj-$(CONFIG_ARCH_QSD8X50) += sirc.o 18obj-$(CONFIG_ARCH_QSD8X50) += sirc.o
15obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o 19obj-$(CONFIG_MSM_SMD) += smd.o smd_debug.o
16obj-$(CONFIG_MSM_SMD) += last_radio_log.o 20obj-$(CONFIG_MSM_SMD) += last_radio_log.o
@@ -19,4 +23,11 @@ obj-$(CONFIG_MACH_TROUT) += board-trout.o board-trout-gpio.o board-trout-mmc.o d
19obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o 23obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o
20obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o 24obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o
21obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o 25obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o
26obj-$(CONFIG_ARCH_MSM8X60) += board-msm8x60.o
22 27
28obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-v1.o gpiomux.o
29obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o
30obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o
31ifndef CONFIG_MSM_V2_TLMM
32obj-y += gpio.o
33endif
diff --git a/arch/arm/mach-msm/board-halibut.c b/arch/arm/mach-msm/board-halibut.c
index 7bd72e8f127e..59edecbe126c 100644
--- a/arch/arm/mach-msm/board-halibut.c
+++ b/arch/arm/mach-msm/board-halibut.c
@@ -95,8 +95,6 @@ static void __init halibut_map_io(void)
95 95
96MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)") 96MACHINE_START(HALIBUT, "Halibut Board (QCT SURF7200A)")
97#ifdef CONFIG_MSM_DEBUG_UART 97#ifdef CONFIG_MSM_DEBUG_UART
98 .phys_io = MSM_DEBUG_UART_PHYS,
99 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
100#endif 98#endif
101 .boot_params = 0x10000100, 99 .boot_params = 0x10000100,
102 .fixup = halibut_fixup, 100 .fixup = halibut_fixup,
diff --git a/arch/arm/mach-msm/board-mahimahi.c b/arch/arm/mach-msm/board-mahimahi.c
index bcbefdfe7b5e..ef3ebf2f763b 100644
--- a/arch/arm/mach-msm/board-mahimahi.c
+++ b/arch/arm/mach-msm/board-mahimahi.c
@@ -75,8 +75,6 @@ extern struct sys_timer msm_timer;
75 75
76MACHINE_START(MAHIMAHI, "mahimahi") 76MACHINE_START(MAHIMAHI, "mahimahi")
77#ifdef CONFIG_MSM_DEBUG_UART 77#ifdef CONFIG_MSM_DEBUG_UART
78 .phys_io = MSM_DEBUG_UART_PHYS,
79 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
80#endif 78#endif
81 .boot_params = 0x20000100, 79 .boot_params = 0x20000100,
82 .fixup = mahimahi_fixup, 80 .fixup = mahimahi_fixup,
diff --git a/arch/arm/mach-msm/board-msm7x27.c b/arch/arm/mach-msm/board-msm7x27.c
index db9381b85bf0..e7a76eff57d9 100644
--- a/arch/arm/mach-msm/board-msm7x27.c
+++ b/arch/arm/mach-msm/board-msm7x27.c
@@ -131,8 +131,6 @@ static void __init msm7x2x_map_io(void)
131 131
132MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF") 132MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
133#ifdef CONFIG_MSM_DEBUG_UART 133#ifdef CONFIG_MSM_DEBUG_UART
134 .phys_io = MSM_DEBUG_UART_PHYS,
135 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
136#endif 134#endif
137 .boot_params = PHYS_OFFSET + 0x100, 135 .boot_params = PHYS_OFFSET + 0x100,
138 .map_io = msm7x2x_map_io, 136 .map_io = msm7x2x_map_io,
@@ -143,8 +141,6 @@ MACHINE_END
143 141
144MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA") 142MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
145#ifdef CONFIG_MSM_DEBUG_UART 143#ifdef CONFIG_MSM_DEBUG_UART
146 .phys_io = MSM_DEBUG_UART_PHYS,
147 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
148#endif 144#endif
149 .boot_params = PHYS_OFFSET + 0x100, 145 .boot_params = PHYS_OFFSET + 0x100,
150 .map_io = msm7x2x_map_io, 146 .map_io = msm7x2x_map_io,
@@ -155,8 +151,6 @@ MACHINE_END
155 151
156MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF") 152MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
157#ifdef CONFIG_MSM_DEBUG_UART 153#ifdef CONFIG_MSM_DEBUG_UART
158 .phys_io = MSM_DEBUG_UART_PHYS,
159 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
160#endif 154#endif
161 .boot_params = PHYS_OFFSET + 0x100, 155 .boot_params = PHYS_OFFSET + 0x100,
162 .map_io = msm7x2x_map_io, 156 .map_io = msm7x2x_map_io,
@@ -167,8 +161,6 @@ MACHINE_END
167 161
168MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA") 162MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
169#ifdef CONFIG_MSM_DEBUG_UART 163#ifdef CONFIG_MSM_DEBUG_UART
170 .phys_io = MSM_DEBUG_UART_PHYS,
171 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
172#endif 164#endif
173 .boot_params = PHYS_OFFSET + 0x100, 165 .boot_params = PHYS_OFFSET + 0x100,
174 .map_io = msm7x2x_map_io, 166 .map_io = msm7x2x_map_io,
diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index e32981928c77..05241df3f9b6 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -39,27 +39,11 @@
39 39
40extern struct sys_timer msm_timer; 40extern struct sys_timer msm_timer;
41 41
42#ifdef CONFIG_SERIAL_MSM_CONSOLE
43static struct msm_gpio uart2_config_data[] = {
44 { GPIO_CFG(49, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_RFR"},
45 { GPIO_CFG(50, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_CTS"},
46 { GPIO_CFG(51, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_Rx"},
47 { GPIO_CFG(52, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_Tx"},
48};
49
50static void msm7x30_init_uart2(void)
51{
52 msm_gpios_request_enable(uart2_config_data,
53 ARRAY_SIZE(uart2_config_data));
54
55}
56#endif
57
58static struct platform_device *devices[] __initdata = { 42static struct platform_device *devices[] __initdata = {
59#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER) 43#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
60 &msm_device_uart2, 44 &msm_device_uart2,
61#endif 45#endif
62 46 &msm_device_smd,
63}; 47};
64 48
65static void __init msm7x30_init_irq(void) 49static void __init msm7x30_init_irq(void)
@@ -70,10 +54,6 @@ static void __init msm7x30_init_irq(void)
70static void __init msm7x30_init(void) 54static void __init msm7x30_init(void)
71{ 55{
72 platform_add_devices(devices, ARRAY_SIZE(devices)); 56 platform_add_devices(devices, ARRAY_SIZE(devices));
73#ifdef CONFIG_SERIAL_MSM_CONSOLE
74 msm7x30_init_uart2();
75#endif
76
77} 57}
78 58
79static void __init msm7x30_map_io(void) 59static void __init msm7x30_map_io(void)
@@ -84,8 +64,6 @@ static void __init msm7x30_map_io(void)
84 64
85MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF") 65MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
86#ifdef CONFIG_MSM_DEBUG_UART 66#ifdef CONFIG_MSM_DEBUG_UART
87 .phys_io = MSM_DEBUG_UART_PHYS,
88 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
89#endif 67#endif
90 .boot_params = PHYS_OFFSET + 0x100, 68 .boot_params = PHYS_OFFSET + 0x100,
91 .map_io = msm7x30_map_io, 69 .map_io = msm7x30_map_io,
@@ -96,8 +74,6 @@ MACHINE_END
96 74
97MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA") 75MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
98#ifdef CONFIG_MSM_DEBUG_UART 76#ifdef CONFIG_MSM_DEBUG_UART
99 .phys_io = MSM_DEBUG_UART_PHYS,
100 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
101#endif 77#endif
102 .boot_params = PHYS_OFFSET + 0x100, 78 .boot_params = PHYS_OFFSET + 0x100,
103 .map_io = msm7x30_map_io, 79 .map_io = msm7x30_map_io,
@@ -108,8 +84,6 @@ MACHINE_END
108 84
109MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID") 85MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
110#ifdef CONFIG_MSM_DEBUG_UART 86#ifdef CONFIG_MSM_DEBUG_UART
111 .phys_io = MSM_DEBUG_UART_PHYS,
112 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
113#endif 87#endif
114 .boot_params = PHYS_OFFSET + 0x100, 88 .boot_params = PHYS_OFFSET + 0x100,
115 .map_io = msm7x30_map_io, 89 .map_io = msm7x30_map_io,
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c
new file mode 100644
index 000000000000..7486a681cc71
--- /dev/null
+++ b/arch/arm/mach-msm/board-msm8x60.c
@@ -0,0 +1,100 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 *
17 */
18
19#include <linux/kernel.h>
20#include <linux/platform_device.h>
21#include <linux/io.h>
22#include <linux/irq.h>
23
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26#include <asm/hardware/gic.h>
27
28#include <mach/board.h>
29#include <mach/msm_iomap.h>
30
31void __iomem *gic_cpu_base_addr;
32
33unsigned long clk_get_max_axi_khz(void)
34{
35 return 0;
36}
37
38static void __init msm8x60_map_io(void)
39{
40 msm_map_msm8x60_io();
41}
42
43static void __init msm8x60_init_irq(void)
44{
45 unsigned int i;
46
47 gic_dist_init(0, MSM_QGIC_DIST_BASE, GIC_PPI_START);
48 gic_cpu_base_addr = (void *)MSM_QGIC_CPU_BASE;
49 gic_cpu_init(0, MSM_QGIC_CPU_BASE);
50
51 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
52 writel(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
53
54 /* RUMI does not adhere to GIC spec by enabling STIs by default.
55 * Enable/clear is supposed to be RO for STIs, but is RW on RUMI.
56 */
57 if (!machine_is_msm8x60_sim())
58 writel(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
59
60 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
61 * as they are configured as level, which does not play nice with
62 * handle_percpu_irq.
63 */
64 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
65 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
66 set_irq_handler(i, handle_percpu_irq);
67 }
68}
69
70static void __init msm8x60_init(void)
71{
72}
73
74MACHINE_START(MSM8X60_RUMI3, "QCT MSM8X60 RUMI3")
75 .map_io = msm8x60_map_io,
76 .init_irq = msm8x60_init_irq,
77 .init_machine = msm8x60_init,
78 .timer = &msm_timer,
79MACHINE_END
80
81MACHINE_START(MSM8X60_SURF, "QCT MSM8X60 SURF")
82 .map_io = msm8x60_map_io,
83 .init_irq = msm8x60_init_irq,
84 .init_machine = msm8x60_init,
85 .timer = &msm_timer,
86MACHINE_END
87
88MACHINE_START(MSM8X60_SIM, "QCT MSM8X60 SIMULATOR")
89 .map_io = msm8x60_map_io,
90 .init_irq = msm8x60_init_irq,
91 .init_machine = msm8x60_init,
92 .timer = &msm_timer,
93MACHINE_END
94
95MACHINE_START(MSM8X60_FFA, "QCT MSM8X60 FFA")
96 .map_io = msm8x60_map_io,
97 .init_irq = msm8x60_init_irq,
98 .init_machine = msm8x60_init,
99 .timer = &msm_timer,
100MACHINE_END
diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c
index e3cc80792d6c..ed2af4ad97ed 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -35,20 +35,49 @@
35 35
36extern struct sys_timer msm_timer; 36extern struct sys_timer msm_timer;
37 37
38static struct msm_gpio uart3_config_data[] = { 38static const resource_size_t qsd8x50_surf_smc91x_base __initdata = 0x70000300;
39 { GPIO_CFG(86, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_Rx"}, 39static const unsigned qsd8x50_surf_smc91x_gpio __initdata = 156;
40 { GPIO_CFG(87, 1, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), "UART2_Tx"}, 40
41/* Leave smc91x resources empty here, as we'll fill them in
42 * at run-time: they vary from board to board, and the true
43 * configuration won't be known until boot.
44 */
45static struct resource smc91x_resources[] __initdata = {
46 [0] = {
47 .flags = IORESOURCE_MEM,
48 },
49 [1] = {
50 .flags = IORESOURCE_IRQ,
51 },
41}; 52};
42 53
43static struct platform_device *devices[] __initdata = { 54static struct platform_device smc91x_device __initdata = {
44 &msm_device_uart3, 55 .name = "smc91x",
56 .id = 0,
57 .num_resources = ARRAY_SIZE(smc91x_resources),
58 .resource = smc91x_resources,
45}; 59};
46 60
47static void msm8x50_init_uart3(void) 61static int __init msm_init_smc91x(void)
48{ 62{
49 msm_gpios_request_enable(uart3_config_data, 63 if (machine_is_qsd8x50_surf()) {
50 ARRAY_SIZE(uart3_config_data)); 64 smc91x_resources[0].start = qsd8x50_surf_smc91x_base;
65 smc91x_resources[0].end = qsd8x50_surf_smc91x_base + 0xff;
66 smc91x_resources[1].start =
67 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
68 smc91x_resources[1].end =
69 gpio_to_irq(qsd8x50_surf_smc91x_gpio);
70 platform_device_register(&smc91x_device);
71 }
72
73 return 0;
51} 74}
75module_init(msm_init_smc91x);
76
77static struct platform_device *devices[] __initdata = {
78 &msm_device_uart3,
79 &msm_device_smd,
80};
52 81
53static void __init qsd8x50_map_io(void) 82static void __init qsd8x50_map_io(void)
54{ 83{
@@ -64,14 +93,11 @@ static void __init qsd8x50_init_irq(void)
64 93
65static void __init qsd8x50_init(void) 94static void __init qsd8x50_init(void)
66{ 95{
67 msm8x50_init_uart3();
68 platform_add_devices(devices, ARRAY_SIZE(devices)); 96 platform_add_devices(devices, ARRAY_SIZE(devices));
69} 97}
70 98
71MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF") 99MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
72#ifdef CONFIG_MSM_DEBUG_UART 100#ifdef CONFIG_MSM_DEBUG_UART
73 .phys_io = MSM_DEBUG_UART_PHYS,
74 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
75#endif 101#endif
76 .boot_params = PHYS_OFFSET + 0x100, 102 .boot_params = PHYS_OFFSET + 0x100,
77 .map_io = qsd8x50_map_io, 103 .map_io = qsd8x50_map_io,
@@ -82,8 +108,6 @@ MACHINE_END
82 108
83MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5") 109MACHINE_START(QSD8X50A_ST1_5, "QCT QSD8X50A ST1.5")
84#ifdef CONFIG_MSM_DEBUG_UART 110#ifdef CONFIG_MSM_DEBUG_UART
85 .phys_io = MSM_DEBUG_UART_PHYS,
86 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
87#endif 111#endif
88 .boot_params = PHYS_OFFSET + 0x100, 112 .boot_params = PHYS_OFFSET + 0x100,
89 .map_io = qsd8x50_map_io, 113 .map_io = qsd8x50_map_io,
diff --git a/arch/arm/mach-msm/board-sapphire.c b/arch/arm/mach-msm/board-sapphire.c
index 2bc1b9d5623e..8919ffb17196 100644
--- a/arch/arm/mach-msm/board-sapphire.c
+++ b/arch/arm/mach-msm/board-sapphire.c
@@ -106,8 +106,6 @@ static void __init sapphire_map_io(void)
106MACHINE_START(SAPPHIRE, "sapphire") 106MACHINE_START(SAPPHIRE, "sapphire")
107/* Maintainer: Brian Swetland <swetland@google.com> */ 107/* Maintainer: Brian Swetland <swetland@google.com> */
108#ifdef CONFIG_MSM_DEBUG_UART 108#ifdef CONFIG_MSM_DEBUG_UART
109 .phys_io = MSM_DEBUG_UART_PHYS,
110 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
111#endif 109#endif
112 .boot_params = PHYS_OFFSET + 0x100, 110 .boot_params = PHYS_OFFSET + 0x100,
113 .fixup = sapphire_fixup, 111 .fixup = sapphire_fixup,
diff --git a/arch/arm/mach-msm/board-trout.c b/arch/arm/mach-msm/board-trout.c
index 469e0be3499d..73f146066542 100644
--- a/arch/arm/mach-msm/board-trout.c
+++ b/arch/arm/mach-msm/board-trout.c
@@ -93,8 +93,6 @@ static void __init trout_map_io(void)
93 93
94MACHINE_START(TROUT, "HTC Dream") 94MACHINE_START(TROUT, "HTC Dream")
95#ifdef CONFIG_MSM_DEBUG_UART 95#ifdef CONFIG_MSM_DEBUG_UART
96 .phys_io = MSM_DEBUG_UART_PHYS,
97 .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
98#endif 96#endif
99 .boot_params = 0x10000100, 97 .boot_params = 0x10000100,
100 .fixup = trout_fixup, 98 .fixup = trout_fixup,
diff --git a/arch/arm/mach-msm/clock-dummy.c b/arch/arm/mach-msm/clock-dummy.c
new file mode 100644
index 000000000000..1250d22082ee
--- /dev/null
+++ b/arch/arm/mach-msm/clock-dummy.c
@@ -0,0 +1,54 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 *
17 */
18#include <linux/clk.h>
19#include <linux/err.h>
20#include <linux/module.h>
21
22struct clk *clk_get(struct device *dev, const char *id)
23{
24 return ERR_PTR(-ENOENT);
25}
26EXPORT_SYMBOL(clk_get);
27
28int clk_enable(struct clk *clk)
29{
30 return -ENOENT;
31}
32EXPORT_SYMBOL(clk_enable);
33
34void clk_disable(struct clk *clk)
35{
36}
37EXPORT_SYMBOL(clk_disable);
38
39unsigned long clk_get_rate(struct clk *clk)
40{
41 return 0;
42}
43EXPORT_SYMBOL(clk_get_rate);
44
45int clk_set_rate(struct clk *clk, unsigned long rate)
46{
47 return -ENOENT;
48}
49EXPORT_SYMBOL(clk_set_rate);
50
51void clk_put(struct clk *clk)
52{
53}
54EXPORT_SYMBOL(clk_put);
diff --git a/arch/arm/mach-msm/devices-msm7x30.c b/arch/arm/mach-msm/devices-msm7x30.c
index b449e8ad2904..7fcf2e3b7698 100644
--- a/arch/arm/mach-msm/devices-msm7x30.c
+++ b/arch/arm/mach-msm/devices-msm7x30.c
@@ -51,6 +51,11 @@ struct platform_device msm_device_uart2 = {
51 .resource = resources_uart2, 51 .resource = resources_uart2,
52}; 52};
53 53
54struct platform_device msm_device_smd = {
55 .name = "msm_smd",
56 .id = -1,
57};
58
54struct clk msm_clocks_7x30[] = { 59struct clk msm_clocks_7x30[] = {
55 CLK_PCOM("adm_clk", ADM_CLK, NULL, 0), 60 CLK_PCOM("adm_clk", ADM_CLK, NULL, 0),
56 CLK_PCOM("adsp_clk", ADSP_CLK, NULL, 0), 61 CLK_PCOM("adsp_clk", ADSP_CLK, NULL, 0),
diff --git a/arch/arm/mach-msm/devices-msm8x60-iommu.c b/arch/arm/mach-msm/devices-msm8x60-iommu.c
new file mode 100644
index 000000000000..89b9d4437e92
--- /dev/null
+++ b/arch/arm/mach-msm/devices-msm8x60-iommu.c
@@ -0,0 +1,883 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#include <linux/kernel.h>
19#include <linux/platform_device.h>
20#include <linux/bootmem.h>
21
22#include <mach/msm_iomap-8x60.h>
23#include <mach/irqs-8x60.h>
24#include <mach/iommu.h>
25
26static struct resource msm_iommu_jpegd_resources[] = {
27 {
28 .start = MSM_IOMMU_JPEGD_PHYS,
29 .end = MSM_IOMMU_JPEGD_PHYS + MSM_IOMMU_JPEGD_SIZE - 1,
30 .name = "physbase",
31 .flags = IORESOURCE_MEM,
32 },
33 {
34 .name = "nonsecure_irq",
35 .start = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
36 .end = SMMU_JPEGD_CB_SC_NON_SECURE_IRQ,
37 .flags = IORESOURCE_IRQ,
38 },
39 {
40 .name = "secure_irq",
41 .start = SMMU_JPEGD_CB_SC_SECURE_IRQ,
42 .end = SMMU_JPEGD_CB_SC_SECURE_IRQ,
43 .flags = IORESOURCE_IRQ,
44 },
45};
46
47static struct resource msm_iommu_vpe_resources[] = {
48 {
49 .start = MSM_IOMMU_VPE_PHYS,
50 .end = MSM_IOMMU_VPE_PHYS + MSM_IOMMU_VPE_SIZE - 1,
51 .name = "physbase",
52 .flags = IORESOURCE_MEM,
53 },
54 {
55 .name = "nonsecure_irq",
56 .start = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
57 .end = SMMU_VPE_CB_SC_NON_SECURE_IRQ,
58 .flags = IORESOURCE_IRQ,
59 },
60 {
61 .name = "secure_irq",
62 .start = SMMU_VPE_CB_SC_SECURE_IRQ,
63 .end = SMMU_VPE_CB_SC_SECURE_IRQ,
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct resource msm_iommu_mdp0_resources[] = {
69 {
70 .start = MSM_IOMMU_MDP0_PHYS,
71 .end = MSM_IOMMU_MDP0_PHYS + MSM_IOMMU_MDP0_SIZE - 1,
72 .name = "physbase",
73 .flags = IORESOURCE_MEM,
74 },
75 {
76 .name = "nonsecure_irq",
77 .start = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
78 .end = SMMU_MDP0_CB_SC_NON_SECURE_IRQ,
79 .flags = IORESOURCE_IRQ,
80 },
81 {
82 .name = "secure_irq",
83 .start = SMMU_MDP0_CB_SC_SECURE_IRQ,
84 .end = SMMU_MDP0_CB_SC_SECURE_IRQ,
85 .flags = IORESOURCE_IRQ,
86 },
87};
88
89static struct resource msm_iommu_mdp1_resources[] = {
90 {
91 .start = MSM_IOMMU_MDP1_PHYS,
92 .end = MSM_IOMMU_MDP1_PHYS + MSM_IOMMU_MDP1_SIZE - 1,
93 .name = "physbase",
94 .flags = IORESOURCE_MEM,
95 },
96 {
97 .name = "nonsecure_irq",
98 .start = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
99 .end = SMMU_MDP1_CB_SC_NON_SECURE_IRQ,
100 .flags = IORESOURCE_IRQ,
101 },
102 {
103 .name = "secure_irq",
104 .start = SMMU_MDP1_CB_SC_SECURE_IRQ,
105 .end = SMMU_MDP1_CB_SC_SECURE_IRQ,
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110static struct resource msm_iommu_rot_resources[] = {
111 {
112 .start = MSM_IOMMU_ROT_PHYS,
113 .end = MSM_IOMMU_ROT_PHYS + MSM_IOMMU_ROT_SIZE - 1,
114 .name = "physbase",
115 .flags = IORESOURCE_MEM,
116 },
117 {
118 .name = "nonsecure_irq",
119 .start = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
120 .end = SMMU_ROT_CB_SC_NON_SECURE_IRQ,
121 .flags = IORESOURCE_IRQ,
122 },
123 {
124 .name = "secure_irq",
125 .start = SMMU_ROT_CB_SC_SECURE_IRQ,
126 .end = SMMU_ROT_CB_SC_SECURE_IRQ,
127 .flags = IORESOURCE_IRQ,
128 },
129};
130
131static struct resource msm_iommu_ijpeg_resources[] = {
132 {
133 .start = MSM_IOMMU_IJPEG_PHYS,
134 .end = MSM_IOMMU_IJPEG_PHYS + MSM_IOMMU_IJPEG_SIZE - 1,
135 .name = "physbase",
136 .flags = IORESOURCE_MEM,
137 },
138 {
139 .name = "nonsecure_irq",
140 .start = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
141 .end = SMMU_IJPEG_CB_SC_NON_SECURE_IRQ,
142 .flags = IORESOURCE_IRQ,
143 },
144 {
145 .name = "secure_irq",
146 .start = SMMU_IJPEG_CB_SC_SECURE_IRQ,
147 .end = SMMU_IJPEG_CB_SC_SECURE_IRQ,
148 .flags = IORESOURCE_IRQ,
149 },
150};
151
152static struct resource msm_iommu_vfe_resources[] = {
153 {
154 .start = MSM_IOMMU_VFE_PHYS,
155 .end = MSM_IOMMU_VFE_PHYS + MSM_IOMMU_VFE_SIZE - 1,
156 .name = "physbase",
157 .flags = IORESOURCE_MEM,
158 },
159 {
160 .name = "nonsecure_irq",
161 .start = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
162 .end = SMMU_VFE_CB_SC_NON_SECURE_IRQ,
163 .flags = IORESOURCE_IRQ,
164 },
165 {
166 .name = "secure_irq",
167 .start = SMMU_VFE_CB_SC_SECURE_IRQ,
168 .end = SMMU_VFE_CB_SC_SECURE_IRQ,
169 .flags = IORESOURCE_IRQ,
170 },
171};
172
173static struct resource msm_iommu_vcodec_a_resources[] = {
174 {
175 .start = MSM_IOMMU_VCODEC_A_PHYS,
176 .end = MSM_IOMMU_VCODEC_A_PHYS + MSM_IOMMU_VCODEC_A_SIZE - 1,
177 .name = "physbase",
178 .flags = IORESOURCE_MEM,
179 },
180 {
181 .name = "nonsecure_irq",
182 .start = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
183 .end = SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ,
184 .flags = IORESOURCE_IRQ,
185 },
186 {
187 .name = "secure_irq",
188 .start = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
189 .end = SMMU_VCODEC_A_CB_SC_SECURE_IRQ,
190 .flags = IORESOURCE_IRQ,
191 },
192};
193
194static struct resource msm_iommu_vcodec_b_resources[] = {
195 {
196 .start = MSM_IOMMU_VCODEC_B_PHYS,
197 .end = MSM_IOMMU_VCODEC_B_PHYS + MSM_IOMMU_VCODEC_B_SIZE - 1,
198 .name = "physbase",
199 .flags = IORESOURCE_MEM,
200 },
201 {
202 .name = "nonsecure_irq",
203 .start = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
204 .end = SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ,
205 .flags = IORESOURCE_IRQ,
206 },
207 {
208 .name = "secure_irq",
209 .start = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
210 .end = SMMU_VCODEC_B_CB_SC_SECURE_IRQ,
211 .flags = IORESOURCE_IRQ,
212 },
213};
214
215static struct resource msm_iommu_gfx3d_resources[] = {
216 {
217 .start = MSM_IOMMU_GFX3D_PHYS,
218 .end = MSM_IOMMU_GFX3D_PHYS + MSM_IOMMU_GFX3D_SIZE - 1,
219 .name = "physbase",
220 .flags = IORESOURCE_MEM,
221 },
222 {
223 .name = "nonsecure_irq",
224 .start = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
225 .end = SMMU_GFX3D_CB_SC_NON_SECURE_IRQ,
226 .flags = IORESOURCE_IRQ,
227 },
228 {
229 .name = "secure_irq",
230 .start = SMMU_GFX3D_CB_SC_SECURE_IRQ,
231 .end = SMMU_GFX3D_CB_SC_SECURE_IRQ,
232 .flags = IORESOURCE_IRQ,
233 },
234};
235
236static struct resource msm_iommu_gfx2d0_resources[] = {
237 {
238 .start = MSM_IOMMU_GFX2D0_PHYS,
239 .end = MSM_IOMMU_GFX2D0_PHYS + MSM_IOMMU_GFX2D0_SIZE - 1,
240 .name = "physbase",
241 .flags = IORESOURCE_MEM,
242 },
243 {
244 .name = "nonsecure_irq",
245 .start = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
246 .end = SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ,
247 .flags = IORESOURCE_IRQ,
248 },
249 {
250 .name = "secure_irq",
251 .start = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
252 .end = SMMU_GFX2D0_CB_SC_SECURE_IRQ,
253 .flags = IORESOURCE_IRQ,
254 },
255};
256
257static struct platform_device msm_root_iommu_dev = {
258 .name = "msm_iommu",
259 .id = -1,
260};
261
262static struct msm_iommu_dev jpegd_smmu = {
263 .name = "jpegd",
264 .clk_rate = -1
265};
266
267static struct msm_iommu_dev vpe_smmu = {
268 .name = "vpe"
269};
270
271static struct msm_iommu_dev mdp0_smmu = {
272 .name = "mdp0"
273};
274
275static struct msm_iommu_dev mdp1_smmu = {
276 .name = "mdp1"
277};
278
279static struct msm_iommu_dev rot_smmu = {
280 .name = "rot"
281};
282
283static struct msm_iommu_dev ijpeg_smmu = {
284 .name = "ijpeg"
285};
286
287static struct msm_iommu_dev vfe_smmu = {
288 .name = "vfe",
289 .clk_rate = -1
290};
291
292static struct msm_iommu_dev vcodec_a_smmu = {
293 .name = "vcodec_a"
294};
295
296static struct msm_iommu_dev vcodec_b_smmu = {
297 .name = "vcodec_b"
298};
299
300static struct msm_iommu_dev gfx3d_smmu = {
301 .name = "gfx3d",
302 .clk_rate = 27000000
303};
304
305static struct msm_iommu_dev gfx2d0_smmu = {
306 .name = "gfx2d0",
307 .clk_rate = 27000000
308};
309
310static struct platform_device msm_device_smmu_jpegd = {
311 .name = "msm_iommu",
312 .id = 0,
313 .dev = {
314 .parent = &msm_root_iommu_dev.dev,
315 },
316 .num_resources = ARRAY_SIZE(msm_iommu_jpegd_resources),
317 .resource = msm_iommu_jpegd_resources,
318};
319
320static struct platform_device msm_device_smmu_vpe = {
321 .name = "msm_iommu",
322 .id = 1,
323 .dev = {
324 .parent = &msm_root_iommu_dev.dev,
325 },
326 .num_resources = ARRAY_SIZE(msm_iommu_vpe_resources),
327 .resource = msm_iommu_vpe_resources,
328};
329
330static struct platform_device msm_device_smmu_mdp0 = {
331 .name = "msm_iommu",
332 .id = 2,
333 .dev = {
334 .parent = &msm_root_iommu_dev.dev,
335 },
336 .num_resources = ARRAY_SIZE(msm_iommu_mdp0_resources),
337 .resource = msm_iommu_mdp0_resources,
338};
339
340static struct platform_device msm_device_smmu_mdp1 = {
341 .name = "msm_iommu",
342 .id = 3,
343 .dev = {
344 .parent = &msm_root_iommu_dev.dev,
345 },
346 .num_resources = ARRAY_SIZE(msm_iommu_mdp1_resources),
347 .resource = msm_iommu_mdp1_resources,
348};
349
350static struct platform_device msm_device_smmu_rot = {
351 .name = "msm_iommu",
352 .id = 4,
353 .dev = {
354 .parent = &msm_root_iommu_dev.dev,
355 },
356 .num_resources = ARRAY_SIZE(msm_iommu_rot_resources),
357 .resource = msm_iommu_rot_resources,
358};
359
360static struct platform_device msm_device_smmu_ijpeg = {
361 .name = "msm_iommu",
362 .id = 5,
363 .dev = {
364 .parent = &msm_root_iommu_dev.dev,
365 },
366 .num_resources = ARRAY_SIZE(msm_iommu_ijpeg_resources),
367 .resource = msm_iommu_ijpeg_resources,
368};
369
370static struct platform_device msm_device_smmu_vfe = {
371 .name = "msm_iommu",
372 .id = 6,
373 .dev = {
374 .parent = &msm_root_iommu_dev.dev,
375 },
376 .num_resources = ARRAY_SIZE(msm_iommu_vfe_resources),
377 .resource = msm_iommu_vfe_resources,
378};
379
380static struct platform_device msm_device_smmu_vcodec_a = {
381 .name = "msm_iommu",
382 .id = 7,
383 .dev = {
384 .parent = &msm_root_iommu_dev.dev,
385 },
386 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_a_resources),
387 .resource = msm_iommu_vcodec_a_resources,
388};
389
390static struct platform_device msm_device_smmu_vcodec_b = {
391 .name = "msm_iommu",
392 .id = 8,
393 .dev = {
394 .parent = &msm_root_iommu_dev.dev,
395 },
396 .num_resources = ARRAY_SIZE(msm_iommu_vcodec_b_resources),
397 .resource = msm_iommu_vcodec_b_resources,
398};
399
400static struct platform_device msm_device_smmu_gfx3d = {
401 .name = "msm_iommu",
402 .id = 9,
403 .dev = {
404 .parent = &msm_root_iommu_dev.dev,
405 },
406 .num_resources = ARRAY_SIZE(msm_iommu_gfx3d_resources),
407 .resource = msm_iommu_gfx3d_resources,
408};
409
410static struct platform_device msm_device_smmu_gfx2d0 = {
411 .name = "msm_iommu",
412 .id = 10,
413 .dev = {
414 .parent = &msm_root_iommu_dev.dev,
415 },
416 .num_resources = ARRAY_SIZE(msm_iommu_gfx2d0_resources),
417 .resource = msm_iommu_gfx2d0_resources,
418};
419
420static struct msm_iommu_ctx_dev jpegd_src_ctx = {
421 .name = "jpegd_src",
422 .num = 0,
423 .mids = {0, -1}
424};
425
426static struct msm_iommu_ctx_dev jpegd_dst_ctx = {
427 .name = "jpegd_dst",
428 .num = 1,
429 .mids = {1, -1}
430};
431
432static struct msm_iommu_ctx_dev vpe_src_ctx = {
433 .name = "vpe_src",
434 .num = 0,
435 .mids = {0, -1}
436};
437
438static struct msm_iommu_ctx_dev vpe_dst_ctx = {
439 .name = "vpe_dst",
440 .num = 1,
441 .mids = {1, -1}
442};
443
444static struct msm_iommu_ctx_dev mdp_vg1_ctx = {
445 .name = "mdp_vg1",
446 .num = 0,
447 .mids = {0, 2, -1}
448};
449
450static struct msm_iommu_ctx_dev mdp_rgb1_ctx = {
451 .name = "mdp_rgb1",
452 .num = 1,
453 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
454};
455
456static struct msm_iommu_ctx_dev mdp_vg2_ctx = {
457 .name = "mdp_vg2",
458 .num = 0,
459 .mids = {0, 2, -1}
460};
461
462static struct msm_iommu_ctx_dev mdp_rgb2_ctx = {
463 .name = "mdp_rgb2",
464 .num = 1,
465 .mids = {1, 3, 4, 5, 6, 7, 8, 9, 10, -1}
466};
467
468static struct msm_iommu_ctx_dev rot_src_ctx = {
469 .name = "rot_src",
470 .num = 0,
471 .mids = {0, -1}
472};
473
474static struct msm_iommu_ctx_dev rot_dst_ctx = {
475 .name = "rot_dst",
476 .num = 1,
477 .mids = {1, -1}
478};
479
480static struct msm_iommu_ctx_dev ijpeg_src_ctx = {
481 .name = "ijpeg_src",
482 .num = 0,
483 .mids = {0, -1}
484};
485
486static struct msm_iommu_ctx_dev ijpeg_dst_ctx = {
487 .name = "ijpeg_dst",
488 .num = 1,
489 .mids = {1, -1}
490};
491
492static struct msm_iommu_ctx_dev vfe_imgwr_ctx = {
493 .name = "vfe_imgwr",
494 .num = 0,
495 .mids = {2, 3, 4, 5, 6, 7, 8, -1}
496};
497
498static struct msm_iommu_ctx_dev vfe_misc_ctx = {
499 .name = "vfe_misc",
500 .num = 1,
501 .mids = {0, 1, 9, -1}
502};
503
504static struct msm_iommu_ctx_dev vcodec_a_stream_ctx = {
505 .name = "vcodec_a_stream",
506 .num = 0,
507 .mids = {2, 5, -1}
508};
509
510static struct msm_iommu_ctx_dev vcodec_a_mm1_ctx = {
511 .name = "vcodec_a_mm1",
512 .num = 1,
513 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
514};
515
516static struct msm_iommu_ctx_dev vcodec_b_mm2_ctx = {
517 .name = "vcodec_b_mm2",
518 .num = 0,
519 .mids = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1}
520};
521
522static struct msm_iommu_ctx_dev gfx3d_rbpa_ctx = {
523 .name = "gfx3d_rbpa",
524 .num = 0,
525 .mids = {-1}
526};
527
528static struct msm_iommu_ctx_dev gfx3d_cpvgttc_ctx = {
529 .name = "gfx3d_cpvgttc",
530 .num = 1,
531 .mids = {0, 1, 2, 3, 4, 5, 6, 7, -1}
532};
533
534static struct msm_iommu_ctx_dev gfx3d_smmu_ctx = {
535 .name = "gfx3d_smmu",
536 .num = 2,
537 .mids = {8, 9, 10, 11, 12, -1}
538};
539
540static struct msm_iommu_ctx_dev gfx2d0_pixv1_ctx = {
541 .name = "gfx2d0_pixv1_smmu",
542 .num = 0,
543 .mids = {0, 3, 4, -1}
544};
545
546static struct msm_iommu_ctx_dev gfx2d0_texv3_ctx = {
547 .name = "gfx2d0_texv3_smmu",
548 .num = 1,
549 .mids = {1, 6, 7, -1}
550};
551
552static struct platform_device msm_device_jpegd_src_ctx = {
553 .name = "msm_iommu_ctx",
554 .id = 0,
555 .dev = {
556 .parent = &msm_device_smmu_jpegd.dev,
557 },
558};
559
560static struct platform_device msm_device_jpegd_dst_ctx = {
561 .name = "msm_iommu_ctx",
562 .id = 1,
563 .dev = {
564 .parent = &msm_device_smmu_jpegd.dev,
565 },
566};
567
568static struct platform_device msm_device_vpe_src_ctx = {
569 .name = "msm_iommu_ctx",
570 .id = 2,
571 .dev = {
572 .parent = &msm_device_smmu_vpe.dev,
573 },
574};
575
576static struct platform_device msm_device_vpe_dst_ctx = {
577 .name = "msm_iommu_ctx",
578 .id = 3,
579 .dev = {
580 .parent = &msm_device_smmu_vpe.dev,
581 },
582};
583
584static struct platform_device msm_device_mdp_vg1_ctx = {
585 .name = "msm_iommu_ctx",
586 .id = 4,
587 .dev = {
588 .parent = &msm_device_smmu_mdp0.dev,
589 },
590};
591
592static struct platform_device msm_device_mdp_rgb1_ctx = {
593 .name = "msm_iommu_ctx",
594 .id = 5,
595 .dev = {
596 .parent = &msm_device_smmu_mdp0.dev,
597 },
598};
599
600static struct platform_device msm_device_mdp_vg2_ctx = {
601 .name = "msm_iommu_ctx",
602 .id = 6,
603 .dev = {
604 .parent = &msm_device_smmu_mdp1.dev,
605 },
606};
607
608static struct platform_device msm_device_mdp_rgb2_ctx = {
609 .name = "msm_iommu_ctx",
610 .id = 7,
611 .dev = {
612 .parent = &msm_device_smmu_mdp1.dev,
613 },
614};
615
616static struct platform_device msm_device_rot_src_ctx = {
617 .name = "msm_iommu_ctx",
618 .id = 8,
619 .dev = {
620 .parent = &msm_device_smmu_rot.dev,
621 },
622};
623
624static struct platform_device msm_device_rot_dst_ctx = {
625 .name = "msm_iommu_ctx",
626 .id = 9,
627 .dev = {
628 .parent = &msm_device_smmu_rot.dev,
629 },
630};
631
632static struct platform_device msm_device_ijpeg_src_ctx = {
633 .name = "msm_iommu_ctx",
634 .id = 10,
635 .dev = {
636 .parent = &msm_device_smmu_ijpeg.dev,
637 },
638};
639
640static struct platform_device msm_device_ijpeg_dst_ctx = {
641 .name = "msm_iommu_ctx",
642 .id = 11,
643 .dev = {
644 .parent = &msm_device_smmu_ijpeg.dev,
645 },
646};
647
648static struct platform_device msm_device_vfe_imgwr_ctx = {
649 .name = "msm_iommu_ctx",
650 .id = 12,
651 .dev = {
652 .parent = &msm_device_smmu_vfe.dev,
653 },
654};
655
656static struct platform_device msm_device_vfe_misc_ctx = {
657 .name = "msm_iommu_ctx",
658 .id = 13,
659 .dev = {
660 .parent = &msm_device_smmu_vfe.dev,
661 },
662};
663
664static struct platform_device msm_device_vcodec_a_stream_ctx = {
665 .name = "msm_iommu_ctx",
666 .id = 14,
667 .dev = {
668 .parent = &msm_device_smmu_vcodec_a.dev,
669 },
670};
671
672static struct platform_device msm_device_vcodec_a_mm1_ctx = {
673 .name = "msm_iommu_ctx",
674 .id = 15,
675 .dev = {
676 .parent = &msm_device_smmu_vcodec_a.dev,
677 },
678};
679
680static struct platform_device msm_device_vcodec_b_mm2_ctx = {
681 .name = "msm_iommu_ctx",
682 .id = 16,
683 .dev = {
684 .parent = &msm_device_smmu_vcodec_b.dev,
685 },
686};
687
688static struct platform_device msm_device_gfx3d_rbpa_ctx = {
689 .name = "msm_iommu_ctx",
690 .id = 17,
691 .dev = {
692 .parent = &msm_device_smmu_gfx3d.dev,
693 },
694};
695
696static struct platform_device msm_device_gfx3d_cpvgttc_ctx = {
697 .name = "msm_iommu_ctx",
698 .id = 18,
699 .dev = {
700 .parent = &msm_device_smmu_gfx3d.dev,
701 },
702};
703
704static struct platform_device msm_device_gfx3d_smmu_ctx = {
705 .name = "msm_iommu_ctx",
706 .id = 19,
707 .dev = {
708 .parent = &msm_device_smmu_gfx3d.dev,
709 },
710};
711
712static struct platform_device msm_device_gfx2d0_pixv1_ctx = {
713 .name = "msm_iommu_ctx",
714 .id = 20,
715 .dev = {
716 .parent = &msm_device_smmu_gfx2d0.dev,
717 },
718};
719
720static struct platform_device msm_device_gfx2d0_texv3_ctx = {
721 .name = "msm_iommu_ctx",
722 .id = 21,
723 .dev = {
724 .parent = &msm_device_smmu_gfx2d0.dev,
725 },
726};
727
728static struct platform_device *msm_iommu_devs[] = {
729 &msm_device_smmu_jpegd,
730 &msm_device_smmu_vpe,
731 &msm_device_smmu_mdp0,
732 &msm_device_smmu_mdp1,
733 &msm_device_smmu_rot,
734 &msm_device_smmu_ijpeg,
735 &msm_device_smmu_vfe,
736 &msm_device_smmu_vcodec_a,
737 &msm_device_smmu_vcodec_b,
738 &msm_device_smmu_gfx3d,
739 &msm_device_smmu_gfx2d0,
740};
741
742static struct msm_iommu_dev *msm_iommu_data[] = {
743 &jpegd_smmu,
744 &vpe_smmu,
745 &mdp0_smmu,
746 &mdp1_smmu,
747 &rot_smmu,
748 &ijpeg_smmu,
749 &vfe_smmu,
750 &vcodec_a_smmu,
751 &vcodec_b_smmu,
752 &gfx3d_smmu,
753 &gfx2d0_smmu,
754};
755
756static struct platform_device *msm_iommu_ctx_devs[] = {
757 &msm_device_jpegd_src_ctx,
758 &msm_device_jpegd_dst_ctx,
759 &msm_device_vpe_src_ctx,
760 &msm_device_vpe_dst_ctx,
761 &msm_device_mdp_vg1_ctx,
762 &msm_device_mdp_rgb1_ctx,
763 &msm_device_mdp_vg2_ctx,
764 &msm_device_mdp_rgb2_ctx,
765 &msm_device_rot_src_ctx,
766 &msm_device_rot_dst_ctx,
767 &msm_device_ijpeg_src_ctx,
768 &msm_device_ijpeg_dst_ctx,
769 &msm_device_vfe_imgwr_ctx,
770 &msm_device_vfe_misc_ctx,
771 &msm_device_vcodec_a_stream_ctx,
772 &msm_device_vcodec_a_mm1_ctx,
773 &msm_device_vcodec_b_mm2_ctx,
774 &msm_device_gfx3d_rbpa_ctx,
775 &msm_device_gfx3d_cpvgttc_ctx,
776 &msm_device_gfx3d_smmu_ctx,
777 &msm_device_gfx2d0_pixv1_ctx,
778 &msm_device_gfx2d0_texv3_ctx,
779};
780
781static struct msm_iommu_ctx_dev *msm_iommu_ctx_data[] = {
782 &jpegd_src_ctx,
783 &jpegd_dst_ctx,
784 &vpe_src_ctx,
785 &vpe_dst_ctx,
786 &mdp_vg1_ctx,
787 &mdp_rgb1_ctx,
788 &mdp_vg2_ctx,
789 &mdp_rgb2_ctx,
790 &rot_src_ctx,
791 &rot_dst_ctx,
792 &ijpeg_src_ctx,
793 &ijpeg_dst_ctx,
794 &vfe_imgwr_ctx,
795 &vfe_misc_ctx,
796 &vcodec_a_stream_ctx,
797 &vcodec_a_mm1_ctx,
798 &vcodec_b_mm2_ctx,
799 &gfx3d_rbpa_ctx,
800 &gfx3d_cpvgttc_ctx,
801 &gfx3d_smmu_ctx,
802 &gfx2d0_pixv1_ctx,
803 &gfx2d0_texv3_ctx,
804};
805
806static int msm8x60_iommu_init(void)
807{
808 int ret, i;
809
810 ret = platform_device_register(&msm_root_iommu_dev);
811 if (ret != 0) {
812 pr_err("Failed to register root IOMMU device!\n");
813 goto failure;
814 }
815
816 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); i++) {
817 ret = platform_device_add_data(msm_iommu_devs[i],
818 msm_iommu_data[i],
819 sizeof(struct msm_iommu_dev));
820 if (ret != 0) {
821 pr_err("platform_device_add_data failed, "
822 "i = %d\n", i);
823 goto failure_unwind;
824 }
825
826 ret = platform_device_register(msm_iommu_devs[i]);
827
828 if (ret != 0) {
829 pr_err("platform_device_register smmu failed, "
830 "i = %d\n", i);
831 goto failure_unwind;
832 }
833 }
834
835 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++) {
836 ret = platform_device_add_data(msm_iommu_ctx_devs[i],
837 msm_iommu_ctx_data[i],
838 sizeof(*msm_iommu_ctx_devs[i]));
839 if (ret != 0) {
840 pr_err("platform_device_add_data smmu failed, "
841 "i = %d\n", i);
842 goto failure_unwind2;
843 }
844
845 ret = platform_device_register(msm_iommu_ctx_devs[i]);
846 if (ret != 0) {
847 pr_err("platform_device_register ctx failed, "
848 "i = %d\n", i);
849 goto failure_unwind2;
850 }
851 }
852 return 0;
853
854failure_unwind2:
855 while (--i >= 0)
856 platform_device_unregister(msm_iommu_ctx_devs[i]);
857failure_unwind:
858 while (--i >= 0)
859 platform_device_unregister(msm_iommu_devs[i]);
860
861 platform_device_unregister(&msm_root_iommu_dev);
862failure:
863 return ret;
864}
865
866static void msm8x60_iommu_exit(void)
867{
868 int i;
869
870 for (i = 0; i < ARRAY_SIZE(msm_iommu_ctx_devs); i++)
871 platform_device_unregister(msm_iommu_ctx_devs[i]);
872
873 for (i = 0; i < ARRAY_SIZE(msm_iommu_devs); ++i)
874 platform_device_unregister(msm_iommu_devs[i]);
875
876 platform_device_unregister(&msm_root_iommu_dev);
877}
878
879subsys_initcall(msm8x60_iommu_init);
880module_exit(msm8x60_iommu_exit);
881
882MODULE_LICENSE("GPL v2");
883MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");
diff --git a/arch/arm/mach-msm/devices-qsd8x50.c b/arch/arm/mach-msm/devices-qsd8x50.c
index 4d4a50785e34..6fe67c5d1ae0 100644
--- a/arch/arm/mach-msm/devices-qsd8x50.c
+++ b/arch/arm/mach-msm/devices-qsd8x50.c
@@ -48,6 +48,11 @@ struct platform_device msm_device_uart3 = {
48 .resource = resources_uart3, 48 .resource = resources_uart3,
49}; 49};
50 50
51struct platform_device msm_device_smd = {
52 .name = "msm_smd",
53 .id = -1,
54};
55
51struct clk msm_clocks_8x50[] = { 56struct clk msm_clocks_8x50[] = {
52 CLK_PCOM("adm_clk", ADM_CLK, NULL, 0), 57 CLK_PCOM("adm_clk", ADM_CLK, NULL, 0),
53 CLK_PCOM("ebi1_clk", EBI1_CLK, NULL, CLK_MIN), 58 CLK_PCOM("ebi1_clk", EBI1_CLK, NULL, CLK_MIN),
diff --git a/arch/arm/mach-msm/gpio.c b/arch/arm/mach-msm/gpio.c
index bc32c845c7b0..33051b509e88 100644
--- a/arch/arm/mach-msm/gpio.c
+++ b/arch/arm/mach-msm/gpio.c
@@ -1,7 +1,7 @@
1/* linux/arch/arm/mach-msm/gpio.c 1/* linux/arch/arm/mach-msm/gpio.c
2 * 2 *
3 * Copyright (C) 2007 Google, Inc. 3 * Copyright (C) 2007 Google, Inc.
4 * Copyright (c) 2009, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
5 * 5 *
6 * This software is licensed under the terms of the GNU General Public 6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and 7 * License version 2, as published by the Free Software Foundation, and
@@ -14,72 +14,363 @@
14 * 14 *
15 */ 15 */
16 16
17#include <linux/bitops.h>
18#include <linux/gpio.h>
19#include <linux/interrupt.h>
20#include <linux/io.h>
21#include <linux/irq.h>
17#include <linux/module.h> 22#include <linux/module.h>
18#include <mach/gpio.h> 23#include "gpio_hw.h"
19#include "proc_comm.h" 24#include "gpiomux.h"
20 25
21int gpio_tlmm_config(unsigned config, unsigned disable) 26#define FIRST_GPIO_IRQ MSM_GPIO_TO_INT(0)
22{ 27
23 return msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, &disable); 28#define MSM_GPIO_BANK(bank, first, last) \
24} 29 { \
25EXPORT_SYMBOL(gpio_tlmm_config); 30 .regs = { \
26 31 .out = MSM_GPIO_OUT_##bank, \
27int msm_gpios_enable(const struct msm_gpio *table, int size) 32 .in = MSM_GPIO_IN_##bank, \
28{ 33 .int_status = MSM_GPIO_INT_STATUS_##bank, \
29 int rc; 34 .int_clear = MSM_GPIO_INT_CLEAR_##bank, \
30 int i; 35 .int_en = MSM_GPIO_INT_EN_##bank, \
31 const struct msm_gpio *g; 36 .int_edge = MSM_GPIO_INT_EDGE_##bank, \
32 for (i = 0; i < size; i++) { 37 .int_pos = MSM_GPIO_INT_POS_##bank, \
33 g = table + i; 38 .oe = MSM_GPIO_OE_##bank, \
34 rc = gpio_tlmm_config(g->gpio_cfg, GPIO_ENABLE); 39 }, \
35 if (rc) { 40 .chip = { \
36 pr_err("gpio_tlmm_config(0x%08x, GPIO_ENABLE)" 41 .base = (first), \
37 " <%s> failed: %d\n", 42 .ngpio = (last) - (first) + 1, \
38 g->gpio_cfg, g->label ?: "?", rc); 43 .get = msm_gpio_get, \
39 pr_err("pin %d func %d dir %d pull %d drvstr %d\n", 44 .set = msm_gpio_set, \
40 GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), 45 .direction_input = msm_gpio_direction_input, \
41 GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), 46 .direction_output = msm_gpio_direction_output, \
42 GPIO_DRVSTR(g->gpio_cfg)); 47 .to_irq = msm_gpio_to_irq, \
43 goto err; 48 .request = msm_gpio_request, \
44 } 49 .free = msm_gpio_free, \
50 } \
45 } 51 }
52
53#define MSM_GPIO_BROKEN_INT_CLEAR 1
54
55struct msm_gpio_regs {
56 void __iomem *out;
57 void __iomem *in;
58 void __iomem *int_status;
59 void __iomem *int_clear;
60 void __iomem *int_en;
61 void __iomem *int_edge;
62 void __iomem *int_pos;
63 void __iomem *oe;
64};
65
66struct msm_gpio_chip {
67 spinlock_t lock;
68 struct gpio_chip chip;
69 struct msm_gpio_regs regs;
70#if MSM_GPIO_BROKEN_INT_CLEAR
71 unsigned int_status_copy;
72#endif
73 unsigned int both_edge_detect;
74 unsigned int int_enable[2]; /* 0: awake, 1: sleep */
75};
76
77static int msm_gpio_write(struct msm_gpio_chip *msm_chip,
78 unsigned offset, unsigned on)
79{
80 unsigned mask = BIT(offset);
81 unsigned val;
82
83 val = readl(msm_chip->regs.out);
84 if (on)
85 writel(val | mask, msm_chip->regs.out);
86 else
87 writel(val & ~mask, msm_chip->regs.out);
46 return 0; 88 return 0;
47err: 89}
48 msm_gpios_disable(table, i); 90
49 return rc; 91static void msm_gpio_update_both_edge_detect(struct msm_gpio_chip *msm_chip)
50} 92{
51EXPORT_SYMBOL(msm_gpios_enable); 93 int loop_limit = 100;
52 94 unsigned pol, val, val2, intstat;
53void msm_gpios_disable(const struct msm_gpio *table, int size) 95 do {
54{ 96 val = readl(msm_chip->regs.in);
55 int rc; 97 pol = readl(msm_chip->regs.int_pos);
56 int i; 98 pol = (pol & ~msm_chip->both_edge_detect) |
57 const struct msm_gpio *g; 99 (~val & msm_chip->both_edge_detect);
58 for (i = size-1; i >= 0; i--) { 100 writel(pol, msm_chip->regs.int_pos);
59 g = table + i; 101 intstat = readl(msm_chip->regs.int_status);
60 rc = gpio_tlmm_config(g->gpio_cfg, GPIO_DISABLE); 102 val2 = readl(msm_chip->regs.in);
61 if (rc) { 103 if (((val ^ val2) & msm_chip->both_edge_detect & ~intstat) == 0)
62 pr_err("gpio_tlmm_config(0x%08x, GPIO_DISABLE)" 104 return;
63 " <%s> failed: %d\n", 105 } while (loop_limit-- > 0);
64 g->gpio_cfg, g->label ?: "?", rc); 106 printk(KERN_ERR "msm_gpio_update_both_edge_detect, "
65 pr_err("pin %d func %d dir %d pull %d drvstr %d\n", 107 "failed to reach stable state %x != %x\n", val, val2);
66 GPIO_PIN(g->gpio_cfg), GPIO_FUNC(g->gpio_cfg), 108}
67 GPIO_DIR(g->gpio_cfg), GPIO_PULL(g->gpio_cfg), 109
68 GPIO_DRVSTR(g->gpio_cfg)); 110static int msm_gpio_clear_detect_status(struct msm_gpio_chip *msm_chip,
69 } 111 unsigned offset)
112{
113 unsigned bit = BIT(offset);
114
115#if MSM_GPIO_BROKEN_INT_CLEAR
116 /* Save interrupts that already triggered before we loose them. */
117 /* Any interrupt that triggers between the read of int_status */
118 /* and the write to int_clear will still be lost though. */
119 msm_chip->int_status_copy |= readl(msm_chip->regs.int_status);
120 msm_chip->int_status_copy &= ~bit;
121#endif
122 writel(bit, msm_chip->regs.int_clear);
123 msm_gpio_update_both_edge_detect(msm_chip);
124 return 0;
125}
126
127static int msm_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
128{
129 struct msm_gpio_chip *msm_chip;
130 unsigned long irq_flags;
131
132 msm_chip = container_of(chip, struct msm_gpio_chip, chip);
133 spin_lock_irqsave(&msm_chip->lock, irq_flags);
134 writel(readl(msm_chip->regs.oe) & ~BIT(offset), msm_chip->regs.oe);
135 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
136 return 0;
137}
138
139static int
140msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value)
141{
142 struct msm_gpio_chip *msm_chip;
143 unsigned long irq_flags;
144
145 msm_chip = container_of(chip, struct msm_gpio_chip, chip);
146 spin_lock_irqsave(&msm_chip->lock, irq_flags);
147 msm_gpio_write(msm_chip, offset, value);
148 writel(readl(msm_chip->regs.oe) | BIT(offset), msm_chip->regs.oe);
149 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
150 return 0;
151}
152
153static int msm_gpio_get(struct gpio_chip *chip, unsigned offset)
154{
155 struct msm_gpio_chip *msm_chip;
156
157 msm_chip = container_of(chip, struct msm_gpio_chip, chip);
158 return (readl(msm_chip->regs.in) & (1U << offset)) ? 1 : 0;
159}
160
161static void msm_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
162{
163 struct msm_gpio_chip *msm_chip;
164 unsigned long irq_flags;
165
166 msm_chip = container_of(chip, struct msm_gpio_chip, chip);
167 spin_lock_irqsave(&msm_chip->lock, irq_flags);
168 msm_gpio_write(msm_chip, offset, value);
169 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
170}
171
172static int msm_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
173{
174 return MSM_GPIO_TO_INT(chip->base + offset);
175}
176
177#ifdef CONFIG_MSM_GPIOMUX
178static int msm_gpio_request(struct gpio_chip *chip, unsigned offset)
179{
180 return msm_gpiomux_get(chip->base + offset);
181}
182
183static void msm_gpio_free(struct gpio_chip *chip, unsigned offset)
184{
185 msm_gpiomux_put(chip->base + offset);
186}
187#else
188#define msm_gpio_request NULL
189#define msm_gpio_free NULL
190#endif
191
192struct msm_gpio_chip msm_gpio_chips[] = {
193#if defined(CONFIG_ARCH_MSM7X00A)
194 MSM_GPIO_BANK(0, 0, 15),
195 MSM_GPIO_BANK(1, 16, 42),
196 MSM_GPIO_BANK(2, 43, 67),
197 MSM_GPIO_BANK(3, 68, 94),
198 MSM_GPIO_BANK(4, 95, 106),
199 MSM_GPIO_BANK(5, 107, 121),
200#elif defined(CONFIG_ARCH_MSM7X25) || defined(CONFIG_ARCH_MSM7X27)
201 MSM_GPIO_BANK(0, 0, 15),
202 MSM_GPIO_BANK(1, 16, 42),
203 MSM_GPIO_BANK(2, 43, 67),
204 MSM_GPIO_BANK(3, 68, 94),
205 MSM_GPIO_BANK(4, 95, 106),
206 MSM_GPIO_BANK(5, 107, 132),
207#elif defined(CONFIG_ARCH_MSM7X30)
208 MSM_GPIO_BANK(0, 0, 15),
209 MSM_GPIO_BANK(1, 16, 43),
210 MSM_GPIO_BANK(2, 44, 67),
211 MSM_GPIO_BANK(3, 68, 94),
212 MSM_GPIO_BANK(4, 95, 106),
213 MSM_GPIO_BANK(5, 107, 133),
214 MSM_GPIO_BANK(6, 134, 150),
215 MSM_GPIO_BANK(7, 151, 181),
216#elif defined(CONFIG_ARCH_QSD8X50)
217 MSM_GPIO_BANK(0, 0, 15),
218 MSM_GPIO_BANK(1, 16, 42),
219 MSM_GPIO_BANK(2, 43, 67),
220 MSM_GPIO_BANK(3, 68, 94),
221 MSM_GPIO_BANK(4, 95, 103),
222 MSM_GPIO_BANK(5, 104, 121),
223 MSM_GPIO_BANK(6, 122, 152),
224 MSM_GPIO_BANK(7, 153, 164),
225#endif
226};
227
228static void msm_gpio_irq_ack(unsigned int irq)
229{
230 unsigned long irq_flags;
231 struct msm_gpio_chip *msm_chip = get_irq_chip_data(irq);
232 spin_lock_irqsave(&msm_chip->lock, irq_flags);
233 msm_gpio_clear_detect_status(msm_chip,
234 irq - gpio_to_irq(msm_chip->chip.base));
235 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
236}
237
238static void msm_gpio_irq_mask(unsigned int irq)
239{
240 unsigned long irq_flags;
241 struct msm_gpio_chip *msm_chip = get_irq_chip_data(irq);
242 unsigned offset = irq - gpio_to_irq(msm_chip->chip.base);
243
244 spin_lock_irqsave(&msm_chip->lock, irq_flags);
245 /* level triggered interrupts are also latched */
246 if (!(readl(msm_chip->regs.int_edge) & BIT(offset)))
247 msm_gpio_clear_detect_status(msm_chip, offset);
248 msm_chip->int_enable[0] &= ~BIT(offset);
249 writel(msm_chip->int_enable[0], msm_chip->regs.int_en);
250 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
251}
252
253static void msm_gpio_irq_unmask(unsigned int irq)
254{
255 unsigned long irq_flags;
256 struct msm_gpio_chip *msm_chip = get_irq_chip_data(irq);
257 unsigned offset = irq - gpio_to_irq(msm_chip->chip.base);
258
259 spin_lock_irqsave(&msm_chip->lock, irq_flags);
260 /* level triggered interrupts are also latched */
261 if (!(readl(msm_chip->regs.int_edge) & BIT(offset)))
262 msm_gpio_clear_detect_status(msm_chip, offset);
263 msm_chip->int_enable[0] |= BIT(offset);
264 writel(msm_chip->int_enable[0], msm_chip->regs.int_en);
265 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
266}
267
268static int msm_gpio_irq_set_wake(unsigned int irq, unsigned int on)
269{
270 unsigned long irq_flags;
271 struct msm_gpio_chip *msm_chip = get_irq_chip_data(irq);
272 unsigned offset = irq - gpio_to_irq(msm_chip->chip.base);
273
274 spin_lock_irqsave(&msm_chip->lock, irq_flags);
275
276 if (on)
277 msm_chip->int_enable[1] |= BIT(offset);
278 else
279 msm_chip->int_enable[1] &= ~BIT(offset);
280
281 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
282 return 0;
283}
284
285static int msm_gpio_irq_set_type(unsigned int irq, unsigned int flow_type)
286{
287 unsigned long irq_flags;
288 struct msm_gpio_chip *msm_chip = get_irq_chip_data(irq);
289 unsigned offset = irq - gpio_to_irq(msm_chip->chip.base);
290 unsigned val, mask = BIT(offset);
291
292 spin_lock_irqsave(&msm_chip->lock, irq_flags);
293 val = readl(msm_chip->regs.int_edge);
294 if (flow_type & IRQ_TYPE_EDGE_BOTH) {
295 writel(val | mask, msm_chip->regs.int_edge);
296 irq_desc[irq].handle_irq = handle_edge_irq;
297 } else {
298 writel(val & ~mask, msm_chip->regs.int_edge);
299 irq_desc[irq].handle_irq = handle_level_irq;
300 }
301 if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
302 msm_chip->both_edge_detect |= mask;
303 msm_gpio_update_both_edge_detect(msm_chip);
304 } else {
305 msm_chip->both_edge_detect &= ~mask;
306 val = readl(msm_chip->regs.int_pos);
307 if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_HIGH))
308 writel(val | mask, msm_chip->regs.int_pos);
309 else
310 writel(val & ~mask, msm_chip->regs.int_pos);
70 } 311 }
312 spin_unlock_irqrestore(&msm_chip->lock, irq_flags);
313 return 0;
71} 314}
72EXPORT_SYMBOL(msm_gpios_disable);
73 315
74int msm_gpios_request_enable(const struct msm_gpio *table, int size) 316static void msm_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
75{ 317{
76 int rc = msm_gpios_enable(table, size); 318 int i, j, mask;
77 return rc; 319 unsigned val;
320
321 for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) {
322 struct msm_gpio_chip *msm_chip = &msm_gpio_chips[i];
323 val = readl(msm_chip->regs.int_status);
324 val &= msm_chip->int_enable[0];
325 while (val) {
326 mask = val & -val;
327 j = fls(mask) - 1;
328 /* printk("%s %08x %08x bit %d gpio %d irq %d\n",
329 __func__, v, m, j, msm_chip->chip.start + j,
330 FIRST_GPIO_IRQ + msm_chip->chip.start + j); */
331 val &= ~mask;
332 generic_handle_irq(FIRST_GPIO_IRQ +
333 msm_chip->chip.base + j);
334 }
335 }
336 desc->chip->ack(irq);
78} 337}
79EXPORT_SYMBOL(msm_gpios_request_enable);
80 338
81void msm_gpios_disable_free(const struct msm_gpio *table, int size) 339static struct irq_chip msm_gpio_irq_chip = {
340 .name = "msmgpio",
341 .ack = msm_gpio_irq_ack,
342 .mask = msm_gpio_irq_mask,
343 .unmask = msm_gpio_irq_unmask,
344 .set_wake = msm_gpio_irq_set_wake,
345 .set_type = msm_gpio_irq_set_type,
346};
347
348static int __init msm_init_gpio(void)
82{ 349{
83 msm_gpios_disable(table, size); 350 int i, j = 0;
351
352 for (i = FIRST_GPIO_IRQ; i < FIRST_GPIO_IRQ + NR_GPIO_IRQS; i++) {
353 if (i - FIRST_GPIO_IRQ >=
354 msm_gpio_chips[j].chip.base +
355 msm_gpio_chips[j].chip.ngpio)
356 j++;
357 set_irq_chip_data(i, &msm_gpio_chips[j]);
358 set_irq_chip(i, &msm_gpio_irq_chip);
359 set_irq_handler(i, handle_edge_irq);
360 set_irq_flags(i, IRQF_VALID);
361 }
362
363 for (i = 0; i < ARRAY_SIZE(msm_gpio_chips); i++) {
364 spin_lock_init(&msm_gpio_chips[i].lock);
365 writel(0, msm_gpio_chips[i].regs.int_en);
366 gpiochip_add(&msm_gpio_chips[i].chip);
367 }
368
369 set_irq_chained_handler(INT_GPIO_GROUP1, msm_gpio_irq_handler);
370 set_irq_chained_handler(INT_GPIO_GROUP2, msm_gpio_irq_handler);
371 set_irq_wake(INT_GPIO_GROUP1, 1);
372 set_irq_wake(INT_GPIO_GROUP2, 2);
373 return 0;
84} 374}
85EXPORT_SYMBOL(msm_gpios_disable_free); 375
376postcore_initcall(msm_init_gpio);
diff --git a/arch/arm/mach-msm/gpio_hw.h b/arch/arm/mach-msm/gpio_hw.h
new file mode 100644
index 000000000000..6b5066038baa
--- /dev/null
+++ b/arch/arm/mach-msm/gpio_hw.h
@@ -0,0 +1,278 @@
1/* arch/arm/mach-msm/gpio_hw.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __ARCH_ARM_MACH_MSM_GPIO_HW_H
19#define __ARCH_ARM_MACH_MSM_GPIO_HW_H
20
21#include <mach/msm_iomap.h>
22
23/* see 80-VA736-2 Rev C pp 695-751
24**
25** These are actually the *shadow* gpio registers, since the
26** real ones (which allow full access) are only available to the
27** ARM9 side of the world.
28**
29** Since the _BASE need to be page-aligned when we're mapping them
30** to virtual addresses, adjust for the additional offset in these
31** macros.
32*/
33
34#if defined(CONFIG_ARCH_MSM7X30)
35#define MSM_GPIO1_REG(off) (MSM_GPIO1_BASE + (off))
36#define MSM_GPIO2_REG(off) (MSM_GPIO2_BASE + 0x400 + (off))
37#else
38#define MSM_GPIO1_REG(off) (MSM_GPIO1_BASE + 0x800 + (off))
39#define MSM_GPIO2_REG(off) (MSM_GPIO2_BASE + 0xC00 + (off))
40#endif
41
42#if defined(CONFIG_ARCH_MSM7X00A) || defined(CONFIG_ARCH_MSM7X25) ||\
43 defined(CONFIG_ARCH_MSM7X27)
44
45/* output value */
46#define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */
47#define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 42-16 */
48#define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-43 */
49#define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */
50#define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 106-95 */
51#define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50) /* gpio 107-121 */
52
53/* same pin map as above, output enable */
54#define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10)
55#define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08)
56#define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14)
57#define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18)
58#define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C)
59#define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54)
60
61/* same pin map as above, input read */
62#define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x34)
63#define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20)
64#define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x38)
65#define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x3C)
66#define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x40)
67#define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x44)
68
69/* same pin map as above, 1=edge 0=level interrup */
70#define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x60)
71#define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50)
72#define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x64)
73#define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x68)
74#define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x6C)
75#define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0xC0)
76
77/* same pin map as above, 1=positive 0=negative */
78#define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x70)
79#define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58)
80#define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x74)
81#define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x78)
82#define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x7C)
83#define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xBC)
84
85/* same pin map as above, interrupt enable */
86#define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0x80)
87#define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60)
88#define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0x84)
89#define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0x88)
90#define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0x8C)
91#define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xB8)
92
93/* same pin map as above, write 1 to clear interrupt */
94#define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0x90)
95#define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68)
96#define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0x94)
97#define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0x98)
98#define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0x9C)
99#define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xB4)
100
101/* same pin map as above, 1=interrupt pending */
102#define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xA0)
103#define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70)
104#define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xA4)
105#define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xA8)
106#define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xAC)
107#define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0xB0)
108
109#endif
110
111#if defined(CONFIG_ARCH_QSD8X50)
112/* output value */
113#define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */
114#define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 42-16 */
115#define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-43 */
116#define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */
117#define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 103-95 */
118#define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x10) /* gpio 121-104 */
119#define MSM_GPIO_OUT_6 MSM_GPIO1_REG(0x14) /* gpio 152-122 */
120#define MSM_GPIO_OUT_7 MSM_GPIO1_REG(0x18) /* gpio 164-153 */
121
122/* same pin map as above, output enable */
123#define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x20)
124#define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08)
125#define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x24)
126#define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x28)
127#define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x2C)
128#define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x30)
129#define MSM_GPIO_OE_6 MSM_GPIO1_REG(0x34)
130#define MSM_GPIO_OE_7 MSM_GPIO1_REG(0x38)
131
132/* same pin map as above, input read */
133#define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x50)
134#define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20)
135#define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x54)
136#define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x58)
137#define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x5C)
138#define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x60)
139#define MSM_GPIO_IN_6 MSM_GPIO1_REG(0x64)
140#define MSM_GPIO_IN_7 MSM_GPIO1_REG(0x68)
141
142/* same pin map as above, 1=edge 0=level interrup */
143#define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x70)
144#define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50)
145#define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x74)
146#define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x78)
147#define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x7C)
148#define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0x80)
149#define MSM_GPIO_INT_EDGE_6 MSM_GPIO1_REG(0x84)
150#define MSM_GPIO_INT_EDGE_7 MSM_GPIO1_REG(0x88)
151
152/* same pin map as above, 1=positive 0=negative */
153#define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x90)
154#define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58)
155#define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x94)
156#define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x98)
157#define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x9C)
158#define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xA0)
159#define MSM_GPIO_INT_POS_6 MSM_GPIO1_REG(0xA4)
160#define MSM_GPIO_INT_POS_7 MSM_GPIO1_REG(0xA8)
161
162/* same pin map as above, interrupt enable */
163#define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0xB0)
164#define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60)
165#define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0xB4)
166#define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0xB8)
167#define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0xBC)
168#define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xC0)
169#define MSM_GPIO_INT_EN_6 MSM_GPIO1_REG(0xC4)
170#define MSM_GPIO_INT_EN_7 MSM_GPIO1_REG(0xC8)
171
172/* same pin map as above, write 1 to clear interrupt */
173#define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0xD0)
174#define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68)
175#define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0xD4)
176#define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0xD8)
177#define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0xDC)
178#define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xE0)
179#define MSM_GPIO_INT_CLEAR_6 MSM_GPIO1_REG(0xE4)
180#define MSM_GPIO_INT_CLEAR_7 MSM_GPIO1_REG(0xE8)
181
182/* same pin map as above, 1=interrupt pending */
183#define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xF0)
184#define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70)
185#define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xF4)
186#define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xF8)
187#define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xFC)
188#define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0x100)
189#define MSM_GPIO_INT_STATUS_6 MSM_GPIO1_REG(0x104)
190#define MSM_GPIO_INT_STATUS_7 MSM_GPIO1_REG(0x108)
191
192#endif
193
194#if defined(CONFIG_ARCH_MSM7X30)
195
196/* output value */
197#define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00) /* gpio 15-0 */
198#define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00) /* gpio 43-16 */
199#define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04) /* gpio 67-44 */
200#define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08) /* gpio 94-68 */
201#define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C) /* gpio 106-95 */
202#define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50) /* gpio 133-107 */
203#define MSM_GPIO_OUT_6 MSM_GPIO1_REG(0xC4) /* gpio 150-134 */
204#define MSM_GPIO_OUT_7 MSM_GPIO1_REG(0x214) /* gpio 181-151 */
205
206/* same pin map as above, output enable */
207#define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10)
208#define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08)
209#define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14)
210#define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18)
211#define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C)
212#define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54)
213#define MSM_GPIO_OE_6 MSM_GPIO1_REG(0xC8)
214#define MSM_GPIO_OE_7 MSM_GPIO1_REG(0x218)
215
216/* same pin map as above, input read */
217#define MSM_GPIO_IN_0 MSM_GPIO1_REG(0x34)
218#define MSM_GPIO_IN_1 MSM_GPIO2_REG(0x20)
219#define MSM_GPIO_IN_2 MSM_GPIO1_REG(0x38)
220#define MSM_GPIO_IN_3 MSM_GPIO1_REG(0x3C)
221#define MSM_GPIO_IN_4 MSM_GPIO1_REG(0x40)
222#define MSM_GPIO_IN_5 MSM_GPIO1_REG(0x44)
223#define MSM_GPIO_IN_6 MSM_GPIO1_REG(0xCC)
224#define MSM_GPIO_IN_7 MSM_GPIO1_REG(0x21C)
225
226/* same pin map as above, 1=edge 0=level interrup */
227#define MSM_GPIO_INT_EDGE_0 MSM_GPIO1_REG(0x60)
228#define MSM_GPIO_INT_EDGE_1 MSM_GPIO2_REG(0x50)
229#define MSM_GPIO_INT_EDGE_2 MSM_GPIO1_REG(0x64)
230#define MSM_GPIO_INT_EDGE_3 MSM_GPIO1_REG(0x68)
231#define MSM_GPIO_INT_EDGE_4 MSM_GPIO1_REG(0x6C)
232#define MSM_GPIO_INT_EDGE_5 MSM_GPIO1_REG(0xC0)
233#define MSM_GPIO_INT_EDGE_6 MSM_GPIO1_REG(0xD0)
234#define MSM_GPIO_INT_EDGE_7 MSM_GPIO1_REG(0x240)
235
236/* same pin map as above, 1=positive 0=negative */
237#define MSM_GPIO_INT_POS_0 MSM_GPIO1_REG(0x70)
238#define MSM_GPIO_INT_POS_1 MSM_GPIO2_REG(0x58)
239#define MSM_GPIO_INT_POS_2 MSM_GPIO1_REG(0x74)
240#define MSM_GPIO_INT_POS_3 MSM_GPIO1_REG(0x78)
241#define MSM_GPIO_INT_POS_4 MSM_GPIO1_REG(0x7C)
242#define MSM_GPIO_INT_POS_5 MSM_GPIO1_REG(0xBC)
243#define MSM_GPIO_INT_POS_6 MSM_GPIO1_REG(0xD4)
244#define MSM_GPIO_INT_POS_7 MSM_GPIO1_REG(0x228)
245
246/* same pin map as above, interrupt enable */
247#define MSM_GPIO_INT_EN_0 MSM_GPIO1_REG(0x80)
248#define MSM_GPIO_INT_EN_1 MSM_GPIO2_REG(0x60)
249#define MSM_GPIO_INT_EN_2 MSM_GPIO1_REG(0x84)
250#define MSM_GPIO_INT_EN_3 MSM_GPIO1_REG(0x88)
251#define MSM_GPIO_INT_EN_4 MSM_GPIO1_REG(0x8C)
252#define MSM_GPIO_INT_EN_5 MSM_GPIO1_REG(0xB8)
253#define MSM_GPIO_INT_EN_6 MSM_GPIO1_REG(0xD8)
254#define MSM_GPIO_INT_EN_7 MSM_GPIO1_REG(0x22C)
255
256/* same pin map as above, write 1 to clear interrupt */
257#define MSM_GPIO_INT_CLEAR_0 MSM_GPIO1_REG(0x90)
258#define MSM_GPIO_INT_CLEAR_1 MSM_GPIO2_REG(0x68)
259#define MSM_GPIO_INT_CLEAR_2 MSM_GPIO1_REG(0x94)
260#define MSM_GPIO_INT_CLEAR_3 MSM_GPIO1_REG(0x98)
261#define MSM_GPIO_INT_CLEAR_4 MSM_GPIO1_REG(0x9C)
262#define MSM_GPIO_INT_CLEAR_5 MSM_GPIO1_REG(0xB4)
263#define MSM_GPIO_INT_CLEAR_6 MSM_GPIO1_REG(0xDC)
264#define MSM_GPIO_INT_CLEAR_7 MSM_GPIO1_REG(0x230)
265
266/* same pin map as above, 1=interrupt pending */
267#define MSM_GPIO_INT_STATUS_0 MSM_GPIO1_REG(0xA0)
268#define MSM_GPIO_INT_STATUS_1 MSM_GPIO2_REG(0x70)
269#define MSM_GPIO_INT_STATUS_2 MSM_GPIO1_REG(0xA4)
270#define MSM_GPIO_INT_STATUS_3 MSM_GPIO1_REG(0xA8)
271#define MSM_GPIO_INT_STATUS_4 MSM_GPIO1_REG(0xAC)
272#define MSM_GPIO_INT_STATUS_5 MSM_GPIO1_REG(0xB0)
273#define MSM_GPIO_INT_STATUS_6 MSM_GPIO1_REG(0xE0)
274#define MSM_GPIO_INT_STATUS_7 MSM_GPIO1_REG(0x234)
275
276#endif
277
278#endif
diff --git a/arch/arm/mach-msm/gpiomux-7x30.c b/arch/arm/mach-msm/gpiomux-7x30.c
new file mode 100644
index 000000000000..6ce41c5241a5
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-7x30.c
@@ -0,0 +1,38 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include "gpiomux.h"
18
19struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {
20#ifdef CONFIG_SERIAL_MSM_CONSOLE
21 [49] = { /* UART2 RFR */
22 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
23 GPIOMUX_FUNC_2 | GPIOMUX_VALID,
24 },
25 [50] = { /* UART2 CTS */
26 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
27 GPIOMUX_FUNC_2 | GPIOMUX_VALID,
28 },
29 [51] = { /* UART2 RX */
30 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
31 GPIOMUX_FUNC_2 | GPIOMUX_VALID,
32 },
33 [52] = { /* UART2 TX */
34 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
35 GPIOMUX_FUNC_2 | GPIOMUX_VALID,
36 },
37#endif
38};
diff --git a/arch/arm/mach-msm/gpiomux-8x50.c b/arch/arm/mach-msm/gpiomux-8x50.c
new file mode 100644
index 000000000000..4406e0f4ae95
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-8x50.c
@@ -0,0 +1,28 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include "gpiomux.h"
18
19struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {
20 [86] = { /* UART3 RX */
21 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
22 GPIOMUX_FUNC_1 | GPIOMUX_VALID,
23 },
24 [87] = { /* UART3 TX */
25 .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
26 GPIOMUX_FUNC_1 | GPIOMUX_VALID,
27 },
28};
diff --git a/arch/arm/mach-msm/gpiomux-8x60.c b/arch/arm/mach-msm/gpiomux-8x60.c
new file mode 100644
index 000000000000..7b380b31bd0e
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-8x60.c
@@ -0,0 +1,19 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include "gpiomux.h"
18
19struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {};
diff --git a/arch/arm/mach-msm/gpiomux-v1.c b/arch/arm/mach-msm/gpiomux-v1.c
new file mode 100644
index 000000000000..27de2abd7144
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-v1.c
@@ -0,0 +1,33 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include <linux/kernel.h>
18#include "gpiomux.h"
19#include "proc_comm.h"
20
21void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val)
22{
23 unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK) |
24 ((gpio & 0x3ff) << 4);
25 unsigned tlmm_disable = 0;
26 int rc;
27
28 rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX,
29 &tlmm_config, &tlmm_disable);
30 if (rc)
31 pr_err("%s: unexpected proc_comm failure %d: %08x %08x\n",
32 __func__, rc, tlmm_config, tlmm_disable);
33}
diff --git a/arch/arm/mach-msm/gpiomux-v1.h b/arch/arm/mach-msm/gpiomux-v1.h
new file mode 100644
index 000000000000..71d86feba450
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-v1.h
@@ -0,0 +1,67 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_V1_H
18#define __ARCH_ARM_MACH_MSM_GPIOMUX_V1_H
19
20#if defined(CONFIG_ARCH_MSM7X30)
21#define GPIOMUX_NGPIOS 182
22#elif defined(CONFIG_ARCH_QSD8X50)
23#define GPIOMUX_NGPIOS 165
24#else
25#define GPIOMUX_NGPIOS 133
26#endif
27
28typedef u32 gpiomux_config_t;
29
30enum {
31 GPIOMUX_DRV_2MA = 0UL << 17,
32 GPIOMUX_DRV_4MA = 1UL << 17,
33 GPIOMUX_DRV_6MA = 2UL << 17,
34 GPIOMUX_DRV_8MA = 3UL << 17,
35 GPIOMUX_DRV_10MA = 4UL << 17,
36 GPIOMUX_DRV_12MA = 5UL << 17,
37 GPIOMUX_DRV_14MA = 6UL << 17,
38 GPIOMUX_DRV_16MA = 7UL << 17,
39};
40
41enum {
42 GPIOMUX_FUNC_GPIO = 0UL,
43 GPIOMUX_FUNC_1 = 1UL,
44 GPIOMUX_FUNC_2 = 2UL,
45 GPIOMUX_FUNC_3 = 3UL,
46 GPIOMUX_FUNC_4 = 4UL,
47 GPIOMUX_FUNC_5 = 5UL,
48 GPIOMUX_FUNC_6 = 6UL,
49 GPIOMUX_FUNC_7 = 7UL,
50 GPIOMUX_FUNC_8 = 8UL,
51 GPIOMUX_FUNC_9 = 9UL,
52 GPIOMUX_FUNC_A = 10UL,
53 GPIOMUX_FUNC_B = 11UL,
54 GPIOMUX_FUNC_C = 12UL,
55 GPIOMUX_FUNC_D = 13UL,
56 GPIOMUX_FUNC_E = 14UL,
57 GPIOMUX_FUNC_F = 15UL,
58};
59
60enum {
61 GPIOMUX_PULL_NONE = 0UL << 15,
62 GPIOMUX_PULL_DOWN = 1UL << 15,
63 GPIOMUX_PULL_KEEPER = 2UL << 15,
64 GPIOMUX_PULL_UP = 3UL << 15,
65};
66
67#endif
diff --git a/arch/arm/mach-msm/gpiomux-v2.c b/arch/arm/mach-msm/gpiomux-v2.c
new file mode 100644
index 000000000000..273396d2b127
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-v2.c
@@ -0,0 +1,25 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include <linux/io.h>
18#include <mach/msm_iomap.h>
19#include "gpiomux.h"
20
21void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val)
22{
23 writel(val & ~GPIOMUX_CTL_MASK,
24 MSM_TLMM_BASE + 0x1000 + (0x10 * gpio));
25}
diff --git a/arch/arm/mach-msm/gpiomux-v2.h b/arch/arm/mach-msm/gpiomux-v2.h
new file mode 100644
index 000000000000..3bf10e7f0381
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux-v2.h
@@ -0,0 +1,61 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_V2_H
18#define __ARCH_ARM_MACH_MSM_GPIOMUX_V2_H
19
20#define GPIOMUX_NGPIOS 173
21
22typedef u16 gpiomux_config_t;
23
24enum {
25 GPIOMUX_DRV_2MA = 0UL << 6,
26 GPIOMUX_DRV_4MA = 1UL << 6,
27 GPIOMUX_DRV_6MA = 2UL << 6,
28 GPIOMUX_DRV_8MA = 3UL << 6,
29 GPIOMUX_DRV_10MA = 4UL << 6,
30 GPIOMUX_DRV_12MA = 5UL << 6,
31 GPIOMUX_DRV_14MA = 6UL << 6,
32 GPIOMUX_DRV_16MA = 7UL << 6,
33};
34
35enum {
36 GPIOMUX_FUNC_GPIO = 0UL << 2,
37 GPIOMUX_FUNC_1 = 1UL << 2,
38 GPIOMUX_FUNC_2 = 2UL << 2,
39 GPIOMUX_FUNC_3 = 3UL << 2,
40 GPIOMUX_FUNC_4 = 4UL << 2,
41 GPIOMUX_FUNC_5 = 5UL << 2,
42 GPIOMUX_FUNC_6 = 6UL << 2,
43 GPIOMUX_FUNC_7 = 7UL << 2,
44 GPIOMUX_FUNC_8 = 8UL << 2,
45 GPIOMUX_FUNC_9 = 9UL << 2,
46 GPIOMUX_FUNC_A = 10UL << 2,
47 GPIOMUX_FUNC_B = 11UL << 2,
48 GPIOMUX_FUNC_C = 12UL << 2,
49 GPIOMUX_FUNC_D = 13UL << 2,
50 GPIOMUX_FUNC_E = 14UL << 2,
51 GPIOMUX_FUNC_F = 15UL << 2,
52};
53
54enum {
55 GPIOMUX_PULL_NONE = 0UL,
56 GPIOMUX_PULL_DOWN = 1UL,
57 GPIOMUX_PULL_KEEPER = 2UL,
58 GPIOMUX_PULL_UP = 3UL,
59};
60
61#endif
diff --git a/arch/arm/mach-msm/gpiomux.c b/arch/arm/mach-msm/gpiomux.c
new file mode 100644
index 000000000000..53af21abd155
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux.c
@@ -0,0 +1,96 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include <linux/module.h>
18#include <linux/spinlock.h>
19#include "gpiomux.h"
20
21static DEFINE_SPINLOCK(gpiomux_lock);
22
23int msm_gpiomux_write(unsigned gpio,
24 gpiomux_config_t active,
25 gpiomux_config_t suspended)
26{
27 struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio;
28 unsigned long irq_flags;
29 gpiomux_config_t setting;
30
31 if (gpio >= GPIOMUX_NGPIOS)
32 return -EINVAL;
33
34 spin_lock_irqsave(&gpiomux_lock, irq_flags);
35
36 if (active & GPIOMUX_VALID)
37 cfg->active = active;
38
39 if (suspended & GPIOMUX_VALID)
40 cfg->suspended = suspended;
41
42 setting = cfg->ref ? active : suspended;
43 if (setting & GPIOMUX_VALID)
44 __msm_gpiomux_write(gpio, setting);
45
46 spin_unlock_irqrestore(&gpiomux_lock, irq_flags);
47 return 0;
48}
49EXPORT_SYMBOL(msm_gpiomux_write);
50
51int msm_gpiomux_get(unsigned gpio)
52{
53 struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio;
54 unsigned long irq_flags;
55
56 if (gpio >= GPIOMUX_NGPIOS)
57 return -EINVAL;
58
59 spin_lock_irqsave(&gpiomux_lock, irq_flags);
60 if (cfg->ref++ == 0 && cfg->active & GPIOMUX_VALID)
61 __msm_gpiomux_write(gpio, cfg->active);
62 spin_unlock_irqrestore(&gpiomux_lock, irq_flags);
63 return 0;
64}
65EXPORT_SYMBOL(msm_gpiomux_get);
66
67int msm_gpiomux_put(unsigned gpio)
68{
69 struct msm_gpiomux_config *cfg = msm_gpiomux_configs + gpio;
70 unsigned long irq_flags;
71
72 if (gpio >= GPIOMUX_NGPIOS)
73 return -EINVAL;
74
75 spin_lock_irqsave(&gpiomux_lock, irq_flags);
76 BUG_ON(cfg->ref == 0);
77 if (--cfg->ref == 0 && cfg->suspended & GPIOMUX_VALID)
78 __msm_gpiomux_write(gpio, cfg->suspended);
79 spin_unlock_irqrestore(&gpiomux_lock, irq_flags);
80 return 0;
81}
82EXPORT_SYMBOL(msm_gpiomux_put);
83
84static int __init gpiomux_init(void)
85{
86 unsigned n;
87
88 for (n = 0; n < GPIOMUX_NGPIOS; ++n) {
89 msm_gpiomux_configs[n].ref = 0;
90 if (!(msm_gpiomux_configs[n].suspended & GPIOMUX_VALID))
91 continue;
92 __msm_gpiomux_write(n, msm_gpiomux_configs[n].suspended);
93 }
94 return 0;
95}
96postcore_initcall(gpiomux_init);
diff --git a/arch/arm/mach-msm/gpiomux.h b/arch/arm/mach-msm/gpiomux.h
new file mode 100644
index 000000000000..b178d9cb742f
--- /dev/null
+++ b/arch/arm/mach-msm/gpiomux.h
@@ -0,0 +1,114 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#ifndef __ARCH_ARM_MACH_MSM_GPIOMUX_H
18#define __ARCH_ARM_MACH_MSM_GPIOMUX_H
19
20#include <linux/bitops.h>
21#include <linux/errno.h>
22
23#if defined(CONFIG_MSM_V2_TLMM)
24#include "gpiomux-v2.h"
25#else
26#include "gpiomux-v1.h"
27#endif
28
29/**
30 * struct msm_gpiomux_config: gpiomux settings for one gpio line.
31 *
32 * A complete gpiomux config is the bitwise-or of a drive-strength,
33 * function, and pull. For functions other than GPIO, the OE
34 * is hard-wired according to the function. For GPIO mode,
35 * OE is controlled by gpiolib.
36 *
37 * Available settings differ by target; see the gpiomux header
38 * specific to your target arch for available configurations.
39 *
40 * @active: The configuration to be installed when the line is
41 * active, or its reference count is > 0.
42 * @suspended: The configuration to be installed when the line
43 * is suspended, or its reference count is 0.
44 * @ref: The reference count of the line. For internal use of
45 * the gpiomux framework only.
46 */
47struct msm_gpiomux_config {
48 gpiomux_config_t active;
49 gpiomux_config_t suspended;
50 unsigned ref;
51};
52
53/**
54 * @GPIOMUX_VALID: If set, the config field contains 'good data'.
55 * The absence of this bit will prevent the gpiomux
56 * system from applying the configuration under all
57 * circumstances.
58 */
59enum {
60 GPIOMUX_VALID = BIT(sizeof(gpiomux_config_t) * BITS_PER_BYTE - 1),
61 GPIOMUX_CTL_MASK = GPIOMUX_VALID,
62};
63
64#ifdef CONFIG_MSM_GPIOMUX
65
66/* Each architecture must provide its own instance of this table.
67 * To avoid having gpiomux manage any given gpio, one or both of
68 * the entries can avoid setting GPIOMUX_VALID - the absence
69 * of that flag will prevent the configuration from being applied
70 * during state transitions.
71 */
72extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
73
74/* Increment a gpio's reference count, possibly activating the line. */
75int __must_check msm_gpiomux_get(unsigned gpio);
76
77/* Decrement a gpio's reference count, possibly suspending the line. */
78int msm_gpiomux_put(unsigned gpio);
79
80/* Install a new configuration to the gpio line. To avoid overwriting
81 * a configuration, leave the VALID bit out.
82 */
83int msm_gpiomux_write(unsigned gpio,
84 gpiomux_config_t active,
85 gpiomux_config_t suspended);
86
87/* Architecture-internal function for use by the framework only.
88 * This function can assume the following:
89 * - the gpio value has passed a bounds-check
90 * - the gpiomux spinlock has been obtained
91 *
92 * This function is not for public consumption. External users
93 * should use msm_gpiomux_write.
94 */
95void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
96#else
97static inline int __must_check msm_gpiomux_get(unsigned gpio)
98{
99 return -ENOSYS;
100}
101
102static inline int msm_gpiomux_put(unsigned gpio)
103{
104 return -ENOSYS;
105}
106
107static inline int msm_gpiomux_write(unsigned gpio,
108 gpiomux_config_t active,
109 gpiomux_config_t suspended)
110{
111 return -ENOSYS;
112}
113#endif
114#endif
diff --git a/arch/arm/mach-msm/include/mach/board.h b/arch/arm/mach-msm/include/mach/board.h
index 5a79bcf50413..6abf4a6eadc1 100644
--- a/arch/arm/mach-msm/include/mach/board.h
+++ b/arch/arm/mach-msm/include/mach/board.h
@@ -33,6 +33,8 @@ struct msm_acpu_clock_platform_data
33 33
34struct clk; 34struct clk;
35 35
36extern struct sys_timer msm_timer;
37
36/* common init routines for use by arch/arm/mach-msm/board-*.c */ 38/* common init routines for use by arch/arm/mach-msm/board-*.c */
37 39
38void __init msm_add_devices(void); 40void __init msm_add_devices(void);
diff --git a/arch/arm/mach-msm/include/mach/debug-macro.S b/arch/arm/mach-msm/include/mach/debug-macro.S
index 528750f307e9..fbd5d90dcc8c 100644
--- a/arch/arm/mach-msm/include/mach/debug-macro.S
+++ b/arch/arm/mach-msm/include/mach/debug-macro.S
@@ -19,13 +19,10 @@
19#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <mach/msm_iomap.h> 20#include <mach/msm_iomap.h>
21 21
22#ifdef CONFIG_MSM_DEBUG_UART 22#ifdef CONFIG_HAS_MSM_DEBUG_UART_PHYS
23 .macro addruart, rx, tmp 23 .macro addruart, rp, rv
24 @ see if the MMU is enabled and select appropriate base address 24 ldr \rp, =MSM_DEBUG_UART_PHYS
25 mrc p15, 0, \rx, c1, c0 25 ldr \rv, =MSM_DEBUG_UART_BASE
26 tst \rx, #1
27 ldreq \rx, =MSM_DEBUG_UART_PHYS
28 ldrne \rx, =MSM_DEBUG_UART_BASE
29 .endm 26 .endm
30 27
31 .macro senduart,rd,rx 28 .macro senduart,rd,rx
@@ -39,16 +36,7 @@
39 tst \rd, #0x04 36 tst \rd, #0x04
40 beq 1001b 37 beq 1001b
41 .endm 38 .endm
42#else
43 .macro addruart, rx, tmp
44 .endm
45
46 .macro senduart,rd,rx
47 .endm
48
49 .macro waituart,rd,rx
50 .endm
51#endif
52 39
53 .macro busyuart,rd,rx 40 .macro busyuart,rd,rx
54 .endm 41 .endm
42#endif
diff --git a/arch/arm/mach-msm/include/mach/dma.h b/arch/arm/mach-msm/include/mach/dma.h
index 00f9bbfadbe6..05583f569524 100644
--- a/arch/arm/mach-msm/include/mach/dma.h
+++ b/arch/arm/mach-msm/include/mach/dma.h
@@ -32,10 +32,18 @@ struct msm_dmov_cmd {
32 void *data; 32 void *data;
33}; 33};
34 34
35#ifndef CONFIG_ARCH_MSM8X60
35void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd); 36void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd);
36void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful); 37void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful);
37int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr); 38int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);
38 39#else
40static inline
41void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd) { }
42static inline
43void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd, int graceful) { }
44static inline
45int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr) { return -EIO; }
46#endif
39 47
40 48
41#define DMOV_SD0(off, ch) (MSM_DMOV_BASE + 0x0000 + (off) + ((ch) << 2)) 49#define DMOV_SD0(off, ch) (MSM_DMOV_BASE + 0x0000 + (off) + ((ch) << 2))
diff --git a/arch/arm/mach-msm/include/mach/entry-macro-qgic.S b/arch/arm/mach-msm/include/mach/entry-macro-qgic.S
new file mode 100644
index 000000000000..4dc99aa65d07
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/entry-macro-qgic.S
@@ -0,0 +1,88 @@
1/*
2 * Low-level IRQ helper macros
3 *
4 * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
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
11#include <mach/hardware.h>
12#include <asm/hardware/gic.h>
13
14 .macro disable_fiq
15 .endm
16
17 .macro get_irqnr_preamble, base, tmp
18 ldr \base, =gic_cpu_base_addr
19 ldr \base, [\base]
20 .endm
21
22 .macro arch_ret_to_user, tmp1, tmp2
23 .endm
24
25 /*
26 * The interrupt numbering scheme is defined in the
27 * interrupt controller spec. To wit:
28 *
29 * Migrated the code from ARM MP port to be more consistant
30 * with interrupt processing , the following still holds true
31 * however, all interrupts are treated the same regardless of
32 * if they are local IPI or PPI
33 *
34 * Interrupts 0-15 are IPI
35 * 16-31 are PPI
36 * (16-18 are the timers)
37 * 32-1020 are global
38 * 1021-1022 are reserved
39 * 1023 is "spurious" (no interrupt)
40 *
41 * A simple read from the controller will tell us the number of the
42 * highest priority enabled interrupt. We then just need to check
43 * whether it is in the valid range for an IRQ (0-1020 inclusive).
44 *
45 * Base ARM code assumes that the local (private) peripheral interrupts
46 * are not valid, we treat them differently, in that the privates are
47 * handled like normal shared interrupts with the exception that only
48 * one processor can register the interrupt and the handler must be
49 * the same for all processors.
50 */
51
52 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
53
54 ldr \irqstat, [\base, #GIC_CPU_INTACK] /* bits 12-10 =srcCPU,
55 9-0 =int # */
56
57 bic \irqnr, \irqstat, #0x1c00 @mask src
58 cmp \irqnr, #15
59 ldr \tmp, =1021
60 cmpcc \irqnr, \irqnr
61 cmpne \irqnr, \tmp
62 cmpcs \irqnr, \irqnr
63
64 .endm
65
66 /* We assume that irqstat (the raw value of the IRQ acknowledge
67 * register) is preserved from the macro above.
68 * If there is an IPI, we immediately signal end of interrupt on the
69 * controller, since this requires the original irqstat value which
70 * we won't easily be able to recreate later.
71 */
72 .macro test_for_ipi, irqnr, irqstat, base, tmp
73 bic \irqnr, \irqstat, #0x1c00
74 cmp \irqnr, #16
75 strcc \irqstat, [\base, #GIC_CPU_EOI]
76 cmpcs \irqnr, \irqnr
77 .endm
78
79 /* As above, this assumes that irqstat and base are preserved.. */
80
81 .macro test_for_ltirq, irqnr, irqstat, base, tmp
82 bic \irqnr, \irqstat, #0x1c00
83 mov \tmp, #0
84 cmp \irqnr, #16
85 moveq \tmp, #1
86 streq \irqstat, [\base, #GIC_CPU_EOI]
87 cmp \tmp, #0
88 .endm
diff --git a/arch/arm/mach-msm/include/mach/entry-macro-vic.S b/arch/arm/mach-msm/include/mach/entry-macro-vic.S
new file mode 100644
index 000000000000..70563ed11b36
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/entry-macro-vic.S
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2007 Google, Inc.
3 * Author: Brian Swetland <swetland@google.com>
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#include <mach/msm_iomap.h>
17
18 .macro disable_fiq
19 .endm
20
21 .macro get_irqnr_preamble, base, tmp
22 @ enable imprecise aborts
23 cpsie a
24 mov \base, #MSM_VIC_BASE
25 .endm
26
27 .macro arch_ret_to_user, tmp1, tmp2
28 .endm
29
30 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
31 @ 0xD0 has irq# or old irq# if the irq has been handled
32 @ 0xD4 has irq# or -1 if none pending *but* if you just
33 @ read 0xD4 you never get the first irq for some reason
34 ldr \irqnr, [\base, #0xD0]
35 ldr \irqnr, [\base, #0xD4]
36 cmp \irqnr, #0xffffffff
37 .endm
diff --git a/arch/arm/mach-msm/include/mach/entry-macro.S b/arch/arm/mach-msm/include/mach/entry-macro.S
index d2259486bcb1..b16f082eeb6f 100644
--- a/arch/arm/mach-msm/include/mach/entry-macro.S
+++ b/arch/arm/mach-msm/include/mach/entry-macro.S
@@ -1,38 +1,23 @@
1/* arch/arm/mach-msm7200/include/mach/entry-macro.S 1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 * 2 *
3 * Copyright (C) 2007 Google, Inc. 3 * This program is free software; you can redistribute it and/or modify
4 * Author: Brian Swetland <swetland@google.com> 4 * it under the terms of the GNU General Public License version 2 and
5 * 5 * only version 2 as published by the Free Software Foundation.
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 * 6 *
10 * This program is distributed in the hope that it will be useful, 7 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 10 * GNU General Public License for more details.
14 * 11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 *
15 */ 17 */
16 18
17#include <mach/msm_iomap.h> 19#if defined(CONFIG_ARM_GIC)
18 20#include <mach/entry-macro-qgic.S>
19 .macro disable_fiq 21#else
20 .endm 22#include <mach/entry-macro-vic.S>
21 23#endif
22 .macro get_irqnr_preamble, base, tmp
23 @ enable imprecise aborts
24 cpsie a
25 mov \base, #MSM_VIC_BASE
26 .endm
27
28 .macro arch_ret_to_user, tmp1, tmp2
29 .endm
30
31 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
32 @ 0xD0 has irq# or old irq# if the irq has been handled
33 @ 0xD4 has irq# or -1 if none pending *but* if you just
34 @ read 0xD4 you never get the first irq for some reason
35 ldr \irqnr, [\base, #0xD0]
36 ldr \irqnr, [\base, #0xD4]
37 cmp \irqnr, #0xffffffff
38 .endm
diff --git a/arch/arm/mach-msm/include/mach/gpio.h b/arch/arm/mach-msm/include/mach/gpio.h
index 83e47c0d5c2e..36ad50d3bfaa 100644
--- a/arch/arm/mach-msm/include/mach/gpio.h
+++ b/arch/arm/mach-msm/include/mach/gpio.h
@@ -23,127 +23,4 @@
23#define gpio_cansleep __gpio_cansleep 23#define gpio_cansleep __gpio_cansleep
24#define gpio_to_irq __gpio_to_irq 24#define gpio_to_irq __gpio_to_irq
25 25
26/**
27 * struct msm_gpio - GPIO pin description
28 * @gpio_cfg - configuration bitmap, as per gpio_tlmm_config()
29 * @label - textual label
30 *
31 * Usually, GPIO's are operated by sets.
32 * This struct accumulate all GPIO information in single source
33 * and facilitete group operations provided by msm_gpios_xxx()
34 */
35struct msm_gpio {
36 u32 gpio_cfg;
37 const char *label;
38};
39
40/**
41 * msm_gpios_request_enable() - request and enable set of GPIOs
42 *
43 * Request and configure set of GPIO's
44 * In case of error, all operations rolled back.
45 * Return error code.
46 *
47 * @table: GPIO table
48 * @size: number of entries in @table
49 */
50int msm_gpios_request_enable(const struct msm_gpio *table, int size);
51
52/**
53 * msm_gpios_disable_free() - disable and free set of GPIOs
54 *
55 * @table: GPIO table
56 * @size: number of entries in @table
57 */
58void msm_gpios_disable_free(const struct msm_gpio *table, int size);
59
60/**
61 * msm_gpios_request() - request set of GPIOs
62 * In case of error, all operations rolled back.
63 * Return error code.
64 *
65 * @table: GPIO table
66 * @size: number of entries in @table
67 */
68int msm_gpios_request(const struct msm_gpio *table, int size);
69
70/**
71 * msm_gpios_free() - free set of GPIOs
72 *
73 * @table: GPIO table
74 * @size: number of entries in @table
75 */
76void msm_gpios_free(const struct msm_gpio *table, int size);
77
78/**
79 * msm_gpios_enable() - enable set of GPIOs
80 * In case of error, all operations rolled back.
81 * Return error code.
82 *
83 * @table: GPIO table
84 * @size: number of entries in @table
85 */
86int msm_gpios_enable(const struct msm_gpio *table, int size);
87
88/**
89 * msm_gpios_disable() - disable set of GPIOs
90 *
91 * @table: GPIO table
92 * @size: number of entries in @table
93 */
94void msm_gpios_disable(const struct msm_gpio *table, int size);
95
96/* GPIO TLMM (Top Level Multiplexing) Definitions */
97
98/* GPIO TLMM: Function -- GPIO specific */
99
100/* GPIO TLMM: Direction */
101enum {
102 GPIO_INPUT,
103 GPIO_OUTPUT,
104};
105
106/* GPIO TLMM: Pullup/Pulldown */
107enum {
108 GPIO_NO_PULL,
109 GPIO_PULL_DOWN,
110 GPIO_KEEPER,
111 GPIO_PULL_UP,
112};
113
114/* GPIO TLMM: Drive Strength */
115enum {
116 GPIO_2MA,
117 GPIO_4MA,
118 GPIO_6MA,
119 GPIO_8MA,
120 GPIO_10MA,
121 GPIO_12MA,
122 GPIO_14MA,
123 GPIO_16MA,
124};
125
126enum {
127 GPIO_ENABLE,
128 GPIO_DISABLE,
129};
130
131#define GPIO_CFG(gpio, func, dir, pull, drvstr) \
132 ((((gpio) & 0x3FF) << 4) | \
133 ((func) & 0xf) | \
134 (((dir) & 0x1) << 14) | \
135 (((pull) & 0x3) << 15) | \
136 (((drvstr) & 0xF) << 17))
137
138/**
139 * extract GPIO pin from bit-field used for gpio_tlmm_config
140 */
141#define GPIO_PIN(gpio_cfg) (((gpio_cfg) >> 4) & 0x3ff)
142#define GPIO_FUNC(gpio_cfg) (((gpio_cfg) >> 0) & 0xf)
143#define GPIO_DIR(gpio_cfg) (((gpio_cfg) >> 14) & 0x1)
144#define GPIO_PULL(gpio_cfg) (((gpio_cfg) >> 15) & 0x3)
145#define GPIO_DRVSTR(gpio_cfg) (((gpio_cfg) >> 17) & 0xf)
146
147int gpio_tlmm_config(unsigned config, unsigned disable);
148
149#endif /* __ASM_ARCH_MSM_GPIO_H */ 26#endif /* __ASM_ARCH_MSM_GPIO_H */
diff --git a/arch/arm/mach-msm/include/mach/io.h b/arch/arm/mach-msm/include/mach/io.h
index c35b29f9ac0f..7386e732baad 100644
--- a/arch/arm/mach-msm/include/mach/io.h
+++ b/arch/arm/mach-msm/include/mach/io.h
@@ -28,6 +28,7 @@ void __iomem *__msm_ioremap(unsigned long phys_addr, size_t size, unsigned int m
28 28
29void msm_map_qsd8x50_io(void); 29void msm_map_qsd8x50_io(void);
30void msm_map_msm7x30_io(void); 30void msm_map_msm7x30_io(void);
31void msm_map_msm8x60_io(void);
31 32
32extern unsigned int msm_shared_ram_phys; 33extern unsigned int msm_shared_ram_phys;
33 34
diff --git a/arch/arm/mach-msm/include/mach/iommu.h b/arch/arm/mach-msm/include/mach/iommu.h
new file mode 100644
index 000000000000..218ef5732a24
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/iommu.h
@@ -0,0 +1,103 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#ifndef MSM_IOMMU_H
19#define MSM_IOMMU_H
20
21#include <linux/interrupt.h>
22
23/* Maximum number of Machine IDs that we are allowing to be mapped to the same
24 * context bank. The number of MIDs mapped to the same CB does not affect
25 * performance, but there is a practical limit on how many distinct MIDs may
26 * be present. These mappings are typically determined at design time and are
27 * not expected to change at run time.
28 */
29#define MAX_NUM_MIDS 16
30
31/**
32 * struct msm_iommu_dev - a single IOMMU hardware instance
33 * name Human-readable name given to this IOMMU HW instance
34 * clk_rate Rate to set for this IOMMU's clock, if applicable to this
35 * particular IOMMU. 0 means don't set a rate.
36 * -1 means it is an AXI clock with no valid rate
37 *
38 */
39struct msm_iommu_dev {
40 const char *name;
41 int clk_rate;
42};
43
44/**
45 * struct msm_iommu_ctx_dev - an IOMMU context bank instance
46 * name Human-readable name given to this context bank
47 * num Index of this context bank within the hardware
48 * mids List of Machine IDs that are to be mapped into this context
49 * bank, terminated by -1. The MID is a set of signals on the
50 * AXI bus that identifies the function associated with a specific
51 * memory request. (See ARM spec).
52 */
53struct msm_iommu_ctx_dev {
54 const char *name;
55 int num;
56 int mids[MAX_NUM_MIDS];
57};
58
59
60/**
61 * struct msm_iommu_drvdata - A single IOMMU hardware instance
62 * @base: IOMMU config port base address (VA)
63 * @irq: Interrupt number
64 *
65 * A msm_iommu_drvdata holds the global driver data about a single piece
66 * of an IOMMU hardware instance.
67 */
68struct msm_iommu_drvdata {
69 void __iomem *base;
70 int irq;
71};
72
73/**
74 * struct msm_iommu_ctx_drvdata - an IOMMU context bank instance
75 * @num: Hardware context number of this context
76 * @pdev: Platform device associated wit this HW instance
77 * @attached_elm: List element for domains to track which devices are
78 * attached to them
79 *
80 * A msm_iommu_ctx_drvdata holds the driver data for a single context bank
81 * within each IOMMU hardware instance
82 */
83struct msm_iommu_ctx_drvdata {
84 int num;
85 struct platform_device *pdev;
86 struct list_head attached_elm;
87};
88
89/*
90 * Look up an IOMMU context device by its context name. NULL if none found.
91 * Useful for testing and drivers that do not yet fully have IOMMU stuff in
92 * their platform devices.
93 */
94struct device *msm_iommu_get_ctx(const char *ctx_name);
95
96/*
97 * Interrupt handler for the IOMMU context fault interrupt. Hooking the
98 * interrupt is not supported in the API yet, but this will print an error
99 * message and dump useful IOMMU registers.
100 */
101irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id);
102
103#endif
diff --git a/arch/arm/mach-msm/include/mach/iommu_hw-8xxx.h b/arch/arm/mach-msm/include/mach/iommu_hw-8xxx.h
new file mode 100644
index 000000000000..f9386d3a2f77
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/iommu_hw-8xxx.h
@@ -0,0 +1,1871 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#ifndef __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
19#define __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
20
21#define CTX_SHIFT 12
22
23#define GET_GLOBAL_REG(reg, base) (readl((base) + (reg)))
24#define GET_CTX_REG(reg, base, ctx) \
25 (readl((base) + (reg) + ((ctx) << CTX_SHIFT)))
26
27#define SET_GLOBAL_REG(reg, base, val) writel((val), ((base) + (reg)))
28
29#define SET_CTX_REG(reg, base, ctx, val) \
30 writel((val), ((base) + (reg) + ((ctx) << CTX_SHIFT)))
31
32/* Wrappers for numbered registers */
33#define SET_GLOBAL_REG_N(b, n, r, v) SET_GLOBAL_REG(b, ((r) + (n << 2)), (v))
34#define GET_GLOBAL_REG_N(b, n, r) GET_GLOBAL_REG(b, ((r) + (n << 2)))
35
36/* Field wrappers */
37#define GET_GLOBAL_FIELD(b, r, F) GET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT)
38#define GET_CONTEXT_FIELD(b, c, r, F) \
39 GET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT)
40
41#define SET_GLOBAL_FIELD(b, r, F, v) \
42 SET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT, (v))
43#define SET_CONTEXT_FIELD(b, c, r, F, v) \
44 SET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT, (v))
45
46#define GET_FIELD(addr, mask, shift) ((readl(addr) >> (shift)) & (mask))
47
48#define SET_FIELD(addr, mask, shift, v) \
49do { \
50 int t = readl(addr); \
51 writel((t & ~((mask) << (shift))) + (((v) & (mask)) << (shift)), addr);\
52} while (0)
53
54
55#define NUM_FL_PTE 4096
56#define NUM_SL_PTE 256
57
58/* First-level page table bits */
59#define FL_BASE_MASK 0xFFFFFC00
60#define FL_TYPE_TABLE (1 << 0)
61#define FL_TYPE_SECT (2 << 0)
62#define FL_SUPERSECTION (1 << 18)
63#define FL_AP_WRITE (1 << 10)
64#define FL_AP_READ (1 << 11)
65#define FL_SHARED (1 << 16)
66#define FL_OFFSET(va) (((va) & 0xFFF00000) >> 20)
67
68/* Second-level page table bits */
69#define SL_BASE_MASK_LARGE 0xFFFF0000
70#define SL_BASE_MASK_SMALL 0xFFFFF000
71#define SL_TYPE_LARGE (1 << 0)
72#define SL_TYPE_SMALL (2 << 0)
73#define SL_AP0 (1 << 4)
74#define SL_AP1 (2 << 4)
75#define SL_SHARED (1 << 10)
76#define SL_OFFSET(va) (((va) & 0xFF000) >> 12)
77
78/* Global register setters / getters */
79#define SET_M2VCBR_N(b, N, v) SET_GLOBAL_REG_N(M2VCBR_N, N, (b), (v))
80#define SET_CBACR_N(b, N, v) SET_GLOBAL_REG_N(CBACR_N, N, (b), (v))
81#define SET_TLBRSW(b, v) SET_GLOBAL_REG(TLBRSW, (b), (v))
82#define SET_TLBTR0(b, v) SET_GLOBAL_REG(TLBTR0, (b), (v))
83#define SET_TLBTR1(b, v) SET_GLOBAL_REG(TLBTR1, (b), (v))
84#define SET_TLBTR2(b, v) SET_GLOBAL_REG(TLBTR2, (b), (v))
85#define SET_TESTBUSCR(b, v) SET_GLOBAL_REG(TESTBUSCR, (b), (v))
86#define SET_GLOBAL_TLBIALL(b, v) SET_GLOBAL_REG(GLOBAL_TLBIALL, (b), (v))
87#define SET_TLBIVMID(b, v) SET_GLOBAL_REG(TLBIVMID, (b), (v))
88#define SET_CR(b, v) SET_GLOBAL_REG(CR, (b), (v))
89#define SET_EAR(b, v) SET_GLOBAL_REG(EAR, (b), (v))
90#define SET_ESR(b, v) SET_GLOBAL_REG(ESR, (b), (v))
91#define SET_ESRRESTORE(b, v) SET_GLOBAL_REG(ESRRESTORE, (b), (v))
92#define SET_ESYNR0(b, v) SET_GLOBAL_REG(ESYNR0, (b), (v))
93#define SET_ESYNR1(b, v) SET_GLOBAL_REG(ESYNR1, (b), (v))
94#define SET_RPU_ACR(b, v) SET_GLOBAL_REG(RPU_ACR, (b), (v))
95
96#define GET_M2VCBR_N(b, N) GET_GLOBAL_REG_N(M2VCBR_N, N, (b))
97#define GET_CBACR_N(b, N) GET_GLOBAL_REG_N(CBACR_N, N, (b))
98#define GET_TLBTR0(b) GET_GLOBAL_REG(TLBTR0, (b))
99#define GET_TLBTR1(b) GET_GLOBAL_REG(TLBTR1, (b))
100#define GET_TLBTR2(b) GET_GLOBAL_REG(TLBTR2, (b))
101#define GET_TESTBUSCR(b) GET_GLOBAL_REG(TESTBUSCR, (b))
102#define GET_GLOBAL_TLBIALL(b) GET_GLOBAL_REG(GLOBAL_TLBIALL, (b))
103#define GET_TLBIVMID(b) GET_GLOBAL_REG(TLBIVMID, (b))
104#define GET_CR(b) GET_GLOBAL_REG(CR, (b))
105#define GET_EAR(b) GET_GLOBAL_REG(EAR, (b))
106#define GET_ESR(b) GET_GLOBAL_REG(ESR, (b))
107#define GET_ESRRESTORE(b) GET_GLOBAL_REG(ESRRESTORE, (b))
108#define GET_ESYNR0(b) GET_GLOBAL_REG(ESYNR0, (b))
109#define GET_ESYNR1(b) GET_GLOBAL_REG(ESYNR1, (b))
110#define GET_REV(b) GET_GLOBAL_REG(REV, (b))
111#define GET_IDR(b) GET_GLOBAL_REG(IDR, (b))
112#define GET_RPU_ACR(b) GET_GLOBAL_REG(RPU_ACR, (b))
113
114
115/* Context register setters/getters */
116#define SET_SCTLR(b, c, v) SET_CTX_REG(SCTLR, (b), (c), (v))
117#define SET_ACTLR(b, c, v) SET_CTX_REG(ACTLR, (b), (c), (v))
118#define SET_CONTEXTIDR(b, c, v) SET_CTX_REG(CONTEXTIDR, (b), (c), (v))
119#define SET_TTBR0(b, c, v) SET_CTX_REG(TTBR0, (b), (c), (v))
120#define SET_TTBR1(b, c, v) SET_CTX_REG(TTBR1, (b), (c), (v))
121#define SET_TTBCR(b, c, v) SET_CTX_REG(TTBCR, (b), (c), (v))
122#define SET_PAR(b, c, v) SET_CTX_REG(PAR, (b), (c), (v))
123#define SET_FSR(b, c, v) SET_CTX_REG(FSR, (b), (c), (v))
124#define SET_FSRRESTORE(b, c, v) SET_CTX_REG(FSRRESTORE, (b), (c), (v))
125#define SET_FAR(b, c, v) SET_CTX_REG(FAR, (b), (c), (v))
126#define SET_FSYNR0(b, c, v) SET_CTX_REG(FSYNR0, (b), (c), (v))
127#define SET_FSYNR1(b, c, v) SET_CTX_REG(FSYNR1, (b), (c), (v))
128#define SET_PRRR(b, c, v) SET_CTX_REG(PRRR, (b), (c), (v))
129#define SET_NMRR(b, c, v) SET_CTX_REG(NMRR, (b), (c), (v))
130#define SET_TLBLKCR(b, c, v) SET_CTX_REG(TLBLCKR, (b), (c), (v))
131#define SET_V2PSR(b, c, v) SET_CTX_REG(V2PSR, (b), (c), (v))
132#define SET_TLBFLPTER(b, c, v) SET_CTX_REG(TLBFLPTER, (b), (c), (v))
133#define SET_TLBSLPTER(b, c, v) SET_CTX_REG(TLBSLPTER, (b), (c), (v))
134#define SET_BFBCR(b, c, v) SET_CTX_REG(BFBCR, (b), (c), (v))
135#define SET_CTX_TLBIALL(b, c, v) SET_CTX_REG(CTX_TLBIALL, (b), (c), (v))
136#define SET_TLBIASID(b, c, v) SET_CTX_REG(TLBIASID, (b), (c), (v))
137#define SET_TLBIVA(b, c, v) SET_CTX_REG(TLBIVA, (b), (c), (v))
138#define SET_TLBIVAA(b, c, v) SET_CTX_REG(TLBIVAA, (b), (c), (v))
139#define SET_V2PPR(b, c, v) SET_CTX_REG(V2PPR, (b), (c), (v))
140#define SET_V2PPW(b, c, v) SET_CTX_REG(V2PPW, (b), (c), (v))
141#define SET_V2PUR(b, c, v) SET_CTX_REG(V2PUR, (b), (c), (v))
142#define SET_V2PUW(b, c, v) SET_CTX_REG(V2PUW, (b), (c), (v))
143#define SET_RESUME(b, c, v) SET_CTX_REG(RESUME, (b), (c), (v))
144
145#define GET_SCTLR(b, c) GET_CTX_REG(SCTLR, (b), (c))
146#define GET_ACTLR(b, c) GET_CTX_REG(ACTLR, (b), (c))
147#define GET_CONTEXTIDR(b, c) GET_CTX_REG(CONTEXTIDR, (b), (c))
148#define GET_TTBR0(b, c) GET_CTX_REG(TTBR0, (b), (c))
149#define GET_TTBR1(b, c) GET_CTX_REG(TTBR1, (b), (c))
150#define GET_TTBCR(b, c) GET_CTX_REG(TTBCR, (b), (c))
151#define GET_PAR(b, c) GET_CTX_REG(PAR, (b), (c))
152#define GET_FSR(b, c) GET_CTX_REG(FSR, (b), (c))
153#define GET_FSRRESTORE(b, c) GET_CTX_REG(FSRRESTORE, (b), (c))
154#define GET_FAR(b, c) GET_CTX_REG(FAR, (b), (c))
155#define GET_FSYNR0(b, c) GET_CTX_REG(FSYNR0, (b), (c))
156#define GET_FSYNR1(b, c) GET_CTX_REG(FSYNR1, (b), (c))
157#define GET_PRRR(b, c) GET_CTX_REG(PRRR, (b), (c))
158#define GET_NMRR(b, c) GET_CTX_REG(NMRR, (b), (c))
159#define GET_TLBLCKR(b, c) GET_CTX_REG(TLBLCKR, (b), (c))
160#define GET_V2PSR(b, c) GET_CTX_REG(V2PSR, (b), (c))
161#define GET_TLBFLPTER(b, c) GET_CTX_REG(TLBFLPTER, (b), (c))
162#define GET_TLBSLPTER(b, c) GET_CTX_REG(TLBSLPTER, (b), (c))
163#define GET_BFBCR(b, c) GET_CTX_REG(BFBCR, (b), (c))
164#define GET_CTX_TLBIALL(b, c) GET_CTX_REG(CTX_TLBIALL, (b), (c))
165#define GET_TLBIASID(b, c) GET_CTX_REG(TLBIASID, (b), (c))
166#define GET_TLBIVA(b, c) GET_CTX_REG(TLBIVA, (b), (c))
167#define GET_TLBIVAA(b, c) GET_CTX_REG(TLBIVAA, (b), (c))
168#define GET_V2PPR(b, c) GET_CTX_REG(V2PPR, (b), (c))
169#define GET_V2PPW(b, c) GET_CTX_REG(V2PPW, (b), (c))
170#define GET_V2PUR(b, c) GET_CTX_REG(V2PUR, (b), (c))
171#define GET_V2PUW(b, c) GET_CTX_REG(V2PUW, (b), (c))
172#define GET_RESUME(b, c) GET_CTX_REG(RESUME, (b), (c))
173
174
175/* Global field setters / getters */
176/* Global Field Setters: */
177/* CBACR_N */
178#define SET_RWVMID(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWVMID, v)
179#define SET_RWE(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWE, v)
180#define SET_RWGE(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWGE, v)
181#define SET_CBVMID(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), CBVMID, v)
182#define SET_IRPTNDX(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), IRPTNDX, v)
183
184
185/* M2VCBR_N */
186#define SET_VMID(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), VMID, v)
187#define SET_CBNDX(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), CBNDX, v)
188#define SET_BYPASSD(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BYPASSD, v)
189#define SET_BPRCOSH(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCOSH, v)
190#define SET_BPRCISH(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCISH, v)
191#define SET_BPRCNSH(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCNSH, v)
192#define SET_BPSHCFG(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPSHCFG, v)
193#define SET_NSCFG(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), NSCFG, v)
194#define SET_BPMTCFG(b, n, v) SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPMTCFG, v)
195#define SET_BPMEMTYPE(b, n, v) \
196 SET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPMEMTYPE, v)
197
198
199/* CR */
200#define SET_RPUE(b, v) SET_GLOBAL_FIELD(b, CR, RPUE, v)
201#define SET_RPUERE(b, v) SET_GLOBAL_FIELD(b, CR, RPUERE, v)
202#define SET_RPUEIE(b, v) SET_GLOBAL_FIELD(b, CR, RPUEIE, v)
203#define SET_DCDEE(b, v) SET_GLOBAL_FIELD(b, CR, DCDEE, v)
204#define SET_CLIENTPD(b, v) SET_GLOBAL_FIELD(b, CR, CLIENTPD, v)
205#define SET_STALLD(b, v) SET_GLOBAL_FIELD(b, CR, STALLD, v)
206#define SET_TLBLKCRWE(b, v) SET_GLOBAL_FIELD(b, CR, TLBLKCRWE, v)
207#define SET_CR_TLBIALLCFG(b, v) SET_GLOBAL_FIELD(b, CR, CR_TLBIALLCFG, v)
208#define SET_TLBIVMIDCFG(b, v) SET_GLOBAL_FIELD(b, CR, TLBIVMIDCFG, v)
209#define SET_CR_HUME(b, v) SET_GLOBAL_FIELD(b, CR, CR_HUME, v)
210
211
212/* ESR */
213#define SET_CFG(b, v) SET_GLOBAL_FIELD(b, ESR, CFG, v)
214#define SET_BYPASS(b, v) SET_GLOBAL_FIELD(b, ESR, BYPASS, v)
215#define SET_ESR_MULTI(b, v) SET_GLOBAL_FIELD(b, ESR, ESR_MULTI, v)
216
217
218/* ESYNR0 */
219#define SET_ESYNR0_AMID(b, v) SET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_AMID, v)
220#define SET_ESYNR0_APID(b, v) SET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_APID, v)
221#define SET_ESYNR0_ABID(b, v) SET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_ABID, v)
222#define SET_ESYNR0_AVMID(b, v) SET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_AVMID, v)
223#define SET_ESYNR0_ATID(b, v) SET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_ATID, v)
224
225
226/* ESYNR1 */
227#define SET_ESYNR1_AMEMTYPE(b, v) \
228 SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AMEMTYPE, v)
229#define SET_ESYNR1_ASHARED(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ASHARED, v)
230#define SET_ESYNR1_AINNERSHARED(b, v) \
231 SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AINNERSHARED, v)
232#define SET_ESYNR1_APRIV(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_APRIV, v)
233#define SET_ESYNR1_APROTNS(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_APROTNS, v)
234#define SET_ESYNR1_AINST(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AINST, v)
235#define SET_ESYNR1_AWRITE(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AWRITE, v)
236#define SET_ESYNR1_ABURST(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ABURST, v)
237#define SET_ESYNR1_ALEN(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ALEN, v)
238#define SET_ESYNR1_ASIZE(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ASIZE, v)
239#define SET_ESYNR1_ALOCK(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ALOCK, v)
240#define SET_ESYNR1_AOOO(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AOOO, v)
241#define SET_ESYNR1_AFULL(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AFULL, v)
242#define SET_ESYNR1_AC(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AC, v)
243#define SET_ESYNR1_DCD(b, v) SET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_DCD, v)
244
245
246/* TESTBUSCR */
247#define SET_TBE(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, TBE, v)
248#define SET_SPDMBE(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, SPDMBE, v)
249#define SET_WGSEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, WGSEL, v)
250#define SET_TBLSEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, TBLSEL, v)
251#define SET_TBHSEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, TBHSEL, v)
252#define SET_SPDM0SEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, SPDM0SEL, v)
253#define SET_SPDM1SEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, SPDM1SEL, v)
254#define SET_SPDM2SEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, SPDM2SEL, v)
255#define SET_SPDM3SEL(b, v) SET_GLOBAL_FIELD(b, TESTBUSCR, SPDM3SEL, v)
256
257
258/* TLBIVMID */
259#define SET_TLBIVMID_VMID(b, v) SET_GLOBAL_FIELD(b, TLBIVMID, TLBIVMID_VMID, v)
260
261
262/* TLBRSW */
263#define SET_TLBRSW_INDEX(b, v) SET_GLOBAL_FIELD(b, TLBRSW, TLBRSW_INDEX, v)
264#define SET_TLBBFBS(b, v) SET_GLOBAL_FIELD(b, TLBRSW, TLBBFBS, v)
265
266
267/* TLBTR0 */
268#define SET_PR(b, v) SET_GLOBAL_FIELD(b, TLBTR0, PR, v)
269#define SET_PW(b, v) SET_GLOBAL_FIELD(b, TLBTR0, PW, v)
270#define SET_UR(b, v) SET_GLOBAL_FIELD(b, TLBTR0, UR, v)
271#define SET_UW(b, v) SET_GLOBAL_FIELD(b, TLBTR0, UW, v)
272#define SET_XN(b, v) SET_GLOBAL_FIELD(b, TLBTR0, XN, v)
273#define SET_NSDESC(b, v) SET_GLOBAL_FIELD(b, TLBTR0, NSDESC, v)
274#define SET_ISH(b, v) SET_GLOBAL_FIELD(b, TLBTR0, ISH, v)
275#define SET_SH(b, v) SET_GLOBAL_FIELD(b, TLBTR0, SH, v)
276#define SET_MT(b, v) SET_GLOBAL_FIELD(b, TLBTR0, MT, v)
277#define SET_DPSIZR(b, v) SET_GLOBAL_FIELD(b, TLBTR0, DPSIZR, v)
278#define SET_DPSIZC(b, v) SET_GLOBAL_FIELD(b, TLBTR0, DPSIZC, v)
279
280
281/* TLBTR1 */
282#define SET_TLBTR1_VMID(b, v) SET_GLOBAL_FIELD(b, TLBTR1, TLBTR1_VMID, v)
283#define SET_TLBTR1_PA(b, v) SET_GLOBAL_FIELD(b, TLBTR1, TLBTR1_PA, v)
284
285
286/* TLBTR2 */
287#define SET_TLBTR2_ASID(b, v) SET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_ASID, v)
288#define SET_TLBTR2_V(b, v) SET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_V, v)
289#define SET_TLBTR2_NSTID(b, v) SET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_NSTID, v)
290#define SET_TLBTR2_NV(b, v) SET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_NV, v)
291#define SET_TLBTR2_VA(b, v) SET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_VA, v)
292
293
294/* Global Field Getters */
295/* CBACR_N */
296#define GET_RWVMID(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWVMID)
297#define GET_RWE(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWE)
298#define GET_RWGE(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), RWGE)
299#define GET_CBVMID(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), CBVMID)
300#define GET_IRPTNDX(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(CBACR_N), IRPTNDX)
301
302
303/* M2VCBR_N */
304#define GET_VMID(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), VMID)
305#define GET_CBNDX(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), CBNDX)
306#define GET_BYPASSD(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BYPASSD)
307#define GET_BPRCOSH(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCOSH)
308#define GET_BPRCISH(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCISH)
309#define GET_BPRCNSH(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPRCNSH)
310#define GET_BPSHCFG(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPSHCFG)
311#define GET_NSCFG(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), NSCFG)
312#define GET_BPMTCFG(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPMTCFG)
313#define GET_BPMEMTYPE(b, n) GET_GLOBAL_FIELD(b, (n<<2)|(M2VCBR_N), BPMEMTYPE)
314
315
316/* CR */
317#define GET_RPUE(b) GET_GLOBAL_FIELD(b, CR, RPUE)
318#define GET_RPUERE(b) GET_GLOBAL_FIELD(b, CR, RPUERE)
319#define GET_RPUEIE(b) GET_GLOBAL_FIELD(b, CR, RPUEIE)
320#define GET_DCDEE(b) GET_GLOBAL_FIELD(b, CR, DCDEE)
321#define GET_CLIENTPD(b) GET_GLOBAL_FIELD(b, CR, CLIENTPD)
322#define GET_STALLD(b) GET_GLOBAL_FIELD(b, CR, STALLD)
323#define GET_TLBLKCRWE(b) GET_GLOBAL_FIELD(b, CR, TLBLKCRWE)
324#define GET_CR_TLBIALLCFG(b) GET_GLOBAL_FIELD(b, CR, CR_TLBIALLCFG)
325#define GET_TLBIVMIDCFG(b) GET_GLOBAL_FIELD(b, CR, TLBIVMIDCFG)
326#define GET_CR_HUME(b) GET_GLOBAL_FIELD(b, CR, CR_HUME)
327
328
329/* ESR */
330#define GET_CFG(b) GET_GLOBAL_FIELD(b, ESR, CFG)
331#define GET_BYPASS(b) GET_GLOBAL_FIELD(b, ESR, BYPASS)
332#define GET_ESR_MULTI(b) GET_GLOBAL_FIELD(b, ESR, ESR_MULTI)
333
334
335/* ESYNR0 */
336#define GET_ESYNR0_AMID(b) GET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_AMID)
337#define GET_ESYNR0_APID(b) GET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_APID)
338#define GET_ESYNR0_ABID(b) GET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_ABID)
339#define GET_ESYNR0_AVMID(b) GET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_AVMID)
340#define GET_ESYNR0_ATID(b) GET_GLOBAL_FIELD(b, ESYNR0, ESYNR0_ATID)
341
342
343/* ESYNR1 */
344#define GET_ESYNR1_AMEMTYPE(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AMEMTYPE)
345#define GET_ESYNR1_ASHARED(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ASHARED)
346#define GET_ESYNR1_AINNERSHARED(b) \
347 GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AINNERSHARED)
348#define GET_ESYNR1_APRIV(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_APRIV)
349#define GET_ESYNR1_APROTNS(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_APROTNS)
350#define GET_ESYNR1_AINST(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AINST)
351#define GET_ESYNR1_AWRITE(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AWRITE)
352#define GET_ESYNR1_ABURST(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ABURST)
353#define GET_ESYNR1_ALEN(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ALEN)
354#define GET_ESYNR1_ASIZE(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ASIZE)
355#define GET_ESYNR1_ALOCK(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_ALOCK)
356#define GET_ESYNR1_AOOO(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AOOO)
357#define GET_ESYNR1_AFULL(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AFULL)
358#define GET_ESYNR1_AC(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_AC)
359#define GET_ESYNR1_DCD(b) GET_GLOBAL_FIELD(b, ESYNR1, ESYNR1_DCD)
360
361
362/* IDR */
363#define GET_NM2VCBMT(b) GET_GLOBAL_FIELD(b, IDR, NM2VCBMT)
364#define GET_HTW(b) GET_GLOBAL_FIELD(b, IDR, HTW)
365#define GET_HUM(b) GET_GLOBAL_FIELD(b, IDR, HUM)
366#define GET_TLBSIZE(b) GET_GLOBAL_FIELD(b, IDR, TLBSIZE)
367#define GET_NCB(b) GET_GLOBAL_FIELD(b, IDR, NCB)
368#define GET_NIRPT(b) GET_GLOBAL_FIELD(b, IDR, NIRPT)
369
370
371/* REV */
372#define GET_MAJOR(b) GET_GLOBAL_FIELD(b, REV, MAJOR)
373#define GET_MINOR(b) GET_GLOBAL_FIELD(b, REV, MINOR)
374
375
376/* TESTBUSCR */
377#define GET_TBE(b) GET_GLOBAL_FIELD(b, TESTBUSCR, TBE)
378#define GET_SPDMBE(b) GET_GLOBAL_FIELD(b, TESTBUSCR, SPDMBE)
379#define GET_WGSEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, WGSEL)
380#define GET_TBLSEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, TBLSEL)
381#define GET_TBHSEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, TBHSEL)
382#define GET_SPDM0SEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, SPDM0SEL)
383#define GET_SPDM1SEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, SPDM1SEL)
384#define GET_SPDM2SEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, SPDM2SEL)
385#define GET_SPDM3SEL(b) GET_GLOBAL_FIELD(b, TESTBUSCR, SPDM3SEL)
386
387
388/* TLBIVMID */
389#define GET_TLBIVMID_VMID(b) GET_GLOBAL_FIELD(b, TLBIVMID, TLBIVMID_VMID)
390
391
392/* TLBTR0 */
393#define GET_PR(b) GET_GLOBAL_FIELD(b, TLBTR0, PR)
394#define GET_PW(b) GET_GLOBAL_FIELD(b, TLBTR0, PW)
395#define GET_UR(b) GET_GLOBAL_FIELD(b, TLBTR0, UR)
396#define GET_UW(b) GET_GLOBAL_FIELD(b, TLBTR0, UW)
397#define GET_XN(b) GET_GLOBAL_FIELD(b, TLBTR0, XN)
398#define GET_NSDESC(b) GET_GLOBAL_FIELD(b, TLBTR0, NSDESC)
399#define GET_ISH(b) GET_GLOBAL_FIELD(b, TLBTR0, ISH)
400#define GET_SH(b) GET_GLOBAL_FIELD(b, TLBTR0, SH)
401#define GET_MT(b) GET_GLOBAL_FIELD(b, TLBTR0, MT)
402#define GET_DPSIZR(b) GET_GLOBAL_FIELD(b, TLBTR0, DPSIZR)
403#define GET_DPSIZC(b) GET_GLOBAL_FIELD(b, TLBTR0, DPSIZC)
404
405
406/* TLBTR1 */
407#define GET_TLBTR1_VMID(b) GET_GLOBAL_FIELD(b, TLBTR1, TLBTR1_VMID)
408#define GET_TLBTR1_PA(b) GET_GLOBAL_FIELD(b, TLBTR1, TLBTR1_PA)
409
410
411/* TLBTR2 */
412#define GET_TLBTR2_ASID(b) GET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_ASID)
413#define GET_TLBTR2_V(b) GET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_V)
414#define GET_TLBTR2_NSTID(b) GET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_NSTID)
415#define GET_TLBTR2_NV(b) GET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_NV)
416#define GET_TLBTR2_VA(b) GET_GLOBAL_FIELD(b, TLBTR2, TLBTR2_VA)
417
418
419/* Context Register setters / getters */
420/* Context Register setters */
421/* ACTLR */
422#define SET_CFERE(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, CFERE, v)
423#define SET_CFEIE(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, CFEIE, v)
424#define SET_PTSHCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, PTSHCFG, v)
425#define SET_RCOSH(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, RCOSH, v)
426#define SET_RCISH(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, RCISH, v)
427#define SET_RCNSH(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, RCNSH, v)
428#define SET_PRIVCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, PRIVCFG, v)
429#define SET_DNA(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, DNA, v)
430#define SET_DNLV2PA(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, DNLV2PA, v)
431#define SET_TLBMCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, TLBMCFG, v)
432#define SET_CFCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, CFCFG, v)
433#define SET_TIPCF(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, TIPCF, v)
434#define SET_V2PCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, V2PCFG, v)
435#define SET_HUME(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, HUME, v)
436#define SET_PTMTCFG(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, PTMTCFG, v)
437#define SET_PTMEMTYPE(b, c, v) SET_CONTEXT_FIELD(b, c, ACTLR, PTMEMTYPE, v)
438
439
440/* BFBCR */
441#define SET_BFBDFE(b, c, v) SET_CONTEXT_FIELD(b, c, BFBCR, BFBDFE, v)
442#define SET_BFBSFE(b, c, v) SET_CONTEXT_FIELD(b, c, BFBCR, BFBSFE, v)
443#define SET_SFVS(b, c, v) SET_CONTEXT_FIELD(b, c, BFBCR, SFVS, v)
444#define SET_FLVIC(b, c, v) SET_CONTEXT_FIELD(b, c, BFBCR, FLVIC, v)
445#define SET_SLVIC(b, c, v) SET_CONTEXT_FIELD(b, c, BFBCR, SLVIC, v)
446
447
448/* CONTEXTIDR */
449#define SET_CONTEXTIDR_ASID(b, c, v) \
450 SET_CONTEXT_FIELD(b, c, CONTEXTIDR, CONTEXTIDR_ASID, v)
451#define SET_CONTEXTIDR_PROCID(b, c, v) \
452 SET_CONTEXT_FIELD(b, c, CONTEXTIDR, PROCID, v)
453
454
455/* FSR */
456#define SET_TF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, TF, v)
457#define SET_AFF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, AFF, v)
458#define SET_APF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, APF, v)
459#define SET_TLBMF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, TLBMF, v)
460#define SET_HTWDEEF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, HTWDEEF, v)
461#define SET_HTWSEEF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, HTWSEEF, v)
462#define SET_MHF(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, MHF, v)
463#define SET_SL(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, SL, v)
464#define SET_SS(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, SS, v)
465#define SET_MULTI(b, c, v) SET_CONTEXT_FIELD(b, c, FSR, MULTI, v)
466
467
468/* FSYNR0 */
469#define SET_AMID(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR0, AMID, v)
470#define SET_APID(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR0, APID, v)
471#define SET_ABID(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR0, ABID, v)
472#define SET_ATID(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR0, ATID, v)
473
474
475/* FSYNR1 */
476#define SET_AMEMTYPE(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, AMEMTYPE, v)
477#define SET_ASHARED(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, ASHARED, v)
478#define SET_AINNERSHARED(b, c, v) \
479 SET_CONTEXT_FIELD(b, c, FSYNR1, AINNERSHARED, v)
480#define SET_APRIV(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, APRIV, v)
481#define SET_APROTNS(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, APROTNS, v)
482#define SET_AINST(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, AINST, v)
483#define SET_AWRITE(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, AWRITE, v)
484#define SET_ABURST(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, ABURST, v)
485#define SET_ALEN(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, ALEN, v)
486#define SET_FSYNR1_ASIZE(b, c, v) \
487 SET_CONTEXT_FIELD(b, c, FSYNR1, FSYNR1_ASIZE, v)
488#define SET_ALOCK(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, ALOCK, v)
489#define SET_AFULL(b, c, v) SET_CONTEXT_FIELD(b, c, FSYNR1, AFULL, v)
490
491
492/* NMRR */
493#define SET_ICPC0(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC0, v)
494#define SET_ICPC1(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC1, v)
495#define SET_ICPC2(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC2, v)
496#define SET_ICPC3(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC3, v)
497#define SET_ICPC4(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC4, v)
498#define SET_ICPC5(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC5, v)
499#define SET_ICPC6(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC6, v)
500#define SET_ICPC7(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, ICPC7, v)
501#define SET_OCPC0(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC0, v)
502#define SET_OCPC1(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC1, v)
503#define SET_OCPC2(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC2, v)
504#define SET_OCPC3(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC3, v)
505#define SET_OCPC4(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC4, v)
506#define SET_OCPC5(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC5, v)
507#define SET_OCPC6(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC6, v)
508#define SET_OCPC7(b, c, v) SET_CONTEXT_FIELD(b, c, NMRR, OCPC7, v)
509
510
511/* PAR */
512#define SET_FAULT(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT, v)
513
514#define SET_FAULT_TF(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_TF, v)
515#define SET_FAULT_AFF(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_AFF, v)
516#define SET_FAULT_APF(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_APF, v)
517#define SET_FAULT_TLBMF(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_TLBMF, v)
518#define SET_FAULT_HTWDEEF(b, c, v) \
519 SET_CONTEXT_FIELD(b, c, PAR, FAULT_HTWDEEF, v)
520#define SET_FAULT_HTWSEEF(b, c, v) \
521 SET_CONTEXT_FIELD(b, c, PAR, FAULT_HTWSEEF, v)
522#define SET_FAULT_MHF(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_MHF, v)
523#define SET_FAULT_SL(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_SL, v)
524#define SET_FAULT_SS(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, FAULT_SS, v)
525
526#define SET_NOFAULT_SS(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NOFAULT_SS, v)
527#define SET_NOFAULT_MT(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NOFAULT_MT, v)
528#define SET_NOFAULT_SH(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NOFAULT_SH, v)
529#define SET_NOFAULT_NS(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NOFAULT_NS, v)
530#define SET_NOFAULT_NOS(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NOFAULT_NOS, v)
531#define SET_NPFAULT_PA(b, c, v) SET_CONTEXT_FIELD(b, c, PAR, NPFAULT_PA, v)
532
533
534/* PRRR */
535#define SET_MTC0(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC0, v)
536#define SET_MTC1(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC1, v)
537#define SET_MTC2(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC2, v)
538#define SET_MTC3(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC3, v)
539#define SET_MTC4(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC4, v)
540#define SET_MTC5(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC5, v)
541#define SET_MTC6(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC6, v)
542#define SET_MTC7(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, MTC7, v)
543#define SET_SHDSH0(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, SHDSH0, v)
544#define SET_SHDSH1(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, SHDSH1, v)
545#define SET_SHNMSH0(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, SHNMSH0, v)
546#define SET_SHNMSH1(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, SHNMSH1, v)
547#define SET_NOS0(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS0, v)
548#define SET_NOS1(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS1, v)
549#define SET_NOS2(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS2, v)
550#define SET_NOS3(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS3, v)
551#define SET_NOS4(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS4, v)
552#define SET_NOS5(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS5, v)
553#define SET_NOS6(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS6, v)
554#define SET_NOS7(b, c, v) SET_CONTEXT_FIELD(b, c, PRRR, NOS7, v)
555
556
557/* RESUME */
558#define SET_TNR(b, c, v) SET_CONTEXT_FIELD(b, c, RESUME, TNR, v)
559
560
561/* SCTLR */
562#define SET_M(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, M, v)
563#define SET_TRE(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, TRE, v)
564#define SET_AFE(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, AFE, v)
565#define SET_HAF(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, HAF, v)
566#define SET_BE(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, BE, v)
567#define SET_AFFD(b, c, v) SET_CONTEXT_FIELD(b, c, SCTLR, AFFD, v)
568
569
570/* TLBLKCR */
571#define SET_LKE(b, c, v) SET_CONTEXT_FIELD(b, c, TLBLKCR, LKE, v)
572#define SET_TLBLKCR_TLBIALLCFG(b, c, v) \
573 SET_CONTEXT_FIELD(b, c, TLBLKCR, TLBLCKR_TLBIALLCFG, v)
574#define SET_TLBIASIDCFG(b, c, v) \
575 SET_CONTEXT_FIELD(b, c, TLBLKCR, TLBIASIDCFG, v)
576#define SET_TLBIVAACFG(b, c, v) SET_CONTEXT_FIELD(b, c, TLBLKCR, TLBIVAACFG, v)
577#define SET_FLOOR(b, c, v) SET_CONTEXT_FIELD(b, c, TLBLKCR, FLOOR, v)
578#define SET_VICTIM(b, c, v) SET_CONTEXT_FIELD(b, c, TLBLKCR, VICTIM, v)
579
580
581/* TTBCR */
582#define SET_N(b, c, v) SET_CONTEXT_FIELD(b, c, TTBCR, N, v)
583#define SET_PD0(b, c, v) SET_CONTEXT_FIELD(b, c, TTBCR, PD0, v)
584#define SET_PD1(b, c, v) SET_CONTEXT_FIELD(b, c, TTBCR, PD1, v)
585
586
587/* TTBR0 */
588#define SET_TTBR0_IRGNH(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_IRGNH, v)
589#define SET_TTBR0_SH(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_SH, v)
590#define SET_TTBR0_ORGN(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_ORGN, v)
591#define SET_TTBR0_NOS(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_NOS, v)
592#define SET_TTBR0_IRGNL(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_IRGNL, v)
593#define SET_TTBR0_PA(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_PA, v)
594
595
596/* TTBR1 */
597#define SET_TTBR1_IRGNH(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_IRGNH, v)
598#define SET_TTBR1_SH(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_SH, v)
599#define SET_TTBR1_ORGN(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_ORGN, v)
600#define SET_TTBR1_NOS(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_NOS, v)
601#define SET_TTBR1_IRGNL(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_IRGNL, v)
602#define SET_TTBR1_PA(b, c, v) SET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_PA, v)
603
604
605/* V2PSR */
606#define SET_HIT(b, c, v) SET_CONTEXT_FIELD(b, c, V2PSR, HIT, v)
607#define SET_INDEX(b, c, v) SET_CONTEXT_FIELD(b, c, V2PSR, INDEX, v)
608
609
610/* V2Pxx UW UR PW PR */
611#define SET_V2PUW_INDEX(b, c, v) SET_CONTEXT_FIELD(b, c, V2PUW, V2Pxx_INDEX, v)
612#define SET_V2PUW_VA(b, c, v) SET_CONTEXT_FIELD(b, c, V2PUW, V2Pxx_VA, v)
613
614#define SET_V2PUR_INDEX(b, c, v) SET_CONTEXT_FIELD(b, c, V2PUR, V2Pxx_INDEX, v)
615#define SET_V2PUR_VA(b, c, v) SET_CONTEXT_FIELD(b, c, V2PUR, V2Pxx_VA, v)
616
617#define SET_V2PPW_INDEX(b, c, v) SET_CONTEXT_FIELD(b, c, V2PPW, V2Pxx_INDEX, v)
618#define SET_V2PPW_VA(b, c, v) SET_CONTEXT_FIELD(b, c, V2PPW, V2Pxx_VA, v)
619
620#define SET_V2PPR_INDEX(b, c, v) SET_CONTEXT_FIELD(b, c, V2PPR, V2Pxx_INDEX, v)
621#define SET_V2PPR_VA(b, c, v) SET_CONTEXT_FIELD(b, c, V2PPR, V2Pxx_VA, v)
622
623
624/* Context Register getters */
625/* ACTLR */
626#define GET_CFERE(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, CFERE)
627#define GET_CFEIE(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, CFEIE)
628#define GET_PTSHCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, PTSHCFG)
629#define GET_RCOSH(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, RCOSH)
630#define GET_RCISH(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, RCISH)
631#define GET_RCNSH(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, RCNSH)
632#define GET_PRIVCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, PRIVCFG)
633#define GET_DNA(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, DNA)
634#define GET_DNLV2PA(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, DNLV2PA)
635#define GET_TLBMCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, TLBMCFG)
636#define GET_CFCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, CFCFG)
637#define GET_TIPCF(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, TIPCF)
638#define GET_V2PCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, V2PCFG)
639#define GET_HUME(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, HUME)
640#define GET_PTMTCFG(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, PTMTCFG)
641#define GET_PTMEMTYPE(b, c) GET_CONTEXT_FIELD(b, c, ACTLR, PTMEMTYPE)
642
643/* BFBCR */
644#define GET_BFBDFE(b, c) GET_CONTEXT_FIELD(b, c, BFBCR, BFBDFE)
645#define GET_BFBSFE(b, c) GET_CONTEXT_FIELD(b, c, BFBCR, BFBSFE)
646#define GET_SFVS(b, c) GET_CONTEXT_FIELD(b, c, BFBCR, SFVS)
647#define GET_FLVIC(b, c) GET_CONTEXT_FIELD(b, c, BFBCR, FLVIC)
648#define GET_SLVIC(b, c) GET_CONTEXT_FIELD(b, c, BFBCR, SLVIC)
649
650
651/* CONTEXTIDR */
652#define GET_CONTEXTIDR_ASID(b, c) \
653 GET_CONTEXT_FIELD(b, c, CONTEXTIDR, CONTEXTIDR_ASID)
654#define GET_CONTEXTIDR_PROCID(b, c) GET_CONTEXT_FIELD(b, c, CONTEXTIDR, PROCID)
655
656
657/* FSR */
658#define GET_TF(b, c) GET_CONTEXT_FIELD(b, c, FSR, TF)
659#define GET_AFF(b, c) GET_CONTEXT_FIELD(b, c, FSR, AFF)
660#define GET_APF(b, c) GET_CONTEXT_FIELD(b, c, FSR, APF)
661#define GET_TLBMF(b, c) GET_CONTEXT_FIELD(b, c, FSR, TLBMF)
662#define GET_HTWDEEF(b, c) GET_CONTEXT_FIELD(b, c, FSR, HTWDEEF)
663#define GET_HTWSEEF(b, c) GET_CONTEXT_FIELD(b, c, FSR, HTWSEEF)
664#define GET_MHF(b, c) GET_CONTEXT_FIELD(b, c, FSR, MHF)
665#define GET_SL(b, c) GET_CONTEXT_FIELD(b, c, FSR, SL)
666#define GET_SS(b, c) GET_CONTEXT_FIELD(b, c, FSR, SS)
667#define GET_MULTI(b, c) GET_CONTEXT_FIELD(b, c, FSR, MULTI)
668
669
670/* FSYNR0 */
671#define GET_AMID(b, c) GET_CONTEXT_FIELD(b, c, FSYNR0, AMID)
672#define GET_APID(b, c) GET_CONTEXT_FIELD(b, c, FSYNR0, APID)
673#define GET_ABID(b, c) GET_CONTEXT_FIELD(b, c, FSYNR0, ABID)
674#define GET_ATID(b, c) GET_CONTEXT_FIELD(b, c, FSYNR0, ATID)
675
676
677/* FSYNR1 */
678#define GET_AMEMTYPE(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, AMEMTYPE)
679#define GET_ASHARED(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, ASHARED)
680#define GET_AINNERSHARED(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, AINNERSHARED)
681#define GET_APRIV(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, APRIV)
682#define GET_APROTNS(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, APROTNS)
683#define GET_AINST(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, AINST)
684#define GET_AWRITE(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, AWRITE)
685#define GET_ABURST(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, ABURST)
686#define GET_ALEN(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, ALEN)
687#define GET_FSYNR1_ASIZE(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, FSYNR1_ASIZE)
688#define GET_ALOCK(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, ALOCK)
689#define GET_AFULL(b, c) GET_CONTEXT_FIELD(b, c, FSYNR1, AFULL)
690
691
692/* NMRR */
693#define GET_ICPC0(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC0)
694#define GET_ICPC1(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC1)
695#define GET_ICPC2(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC2)
696#define GET_ICPC3(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC3)
697#define GET_ICPC4(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC4)
698#define GET_ICPC5(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC5)
699#define GET_ICPC6(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC6)
700#define GET_ICPC7(b, c) GET_CONTEXT_FIELD(b, c, NMRR, ICPC7)
701#define GET_OCPC0(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC0)
702#define GET_OCPC1(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC1)
703#define GET_OCPC2(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC2)
704#define GET_OCPC3(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC3)
705#define GET_OCPC4(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC4)
706#define GET_OCPC5(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC5)
707#define GET_OCPC6(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC6)
708#define GET_OCPC7(b, c) GET_CONTEXT_FIELD(b, c, NMRR, OCPC7)
709
710
711/* PAR */
712#define GET_FAULT(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT)
713
714#define GET_FAULT_TF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_TF)
715#define GET_FAULT_AFF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_AFF)
716#define GET_FAULT_APF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_APF)
717#define GET_FAULT_TLBMF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_TLBMF)
718#define GET_FAULT_HTWDEEF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_HTWDEEF)
719#define GET_FAULT_HTWSEEF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_HTWSEEF)
720#define GET_FAULT_MHF(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_MHF)
721#define GET_FAULT_SL(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_SL)
722#define GET_FAULT_SS(b, c) GET_CONTEXT_FIELD(b, c, PAR, FAULT_SS)
723
724#define GET_NOFAULT_SS(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NOFAULT_SS)
725#define GET_NOFAULT_MT(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NOFAULT_MT)
726#define GET_NOFAULT_SH(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NOFAULT_SH)
727#define GET_NOFAULT_NS(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NOFAULT_NS)
728#define GET_NOFAULT_NOS(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NOFAULT_NOS)
729#define GET_NPFAULT_PA(b, c) GET_CONTEXT_FIELD(b, c, PAR, PAR_NPFAULT_PA)
730
731
732/* PRRR */
733#define GET_MTC0(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC0)
734#define GET_MTC1(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC1)
735#define GET_MTC2(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC2)
736#define GET_MTC3(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC3)
737#define GET_MTC4(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC4)
738#define GET_MTC5(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC5)
739#define GET_MTC6(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC6)
740#define GET_MTC7(b, c) GET_CONTEXT_FIELD(b, c, PRRR, MTC7)
741#define GET_SHDSH0(b, c) GET_CONTEXT_FIELD(b, c, PRRR, SHDSH0)
742#define GET_SHDSH1(b, c) GET_CONTEXT_FIELD(b, c, PRRR, SHDSH1)
743#define GET_SHNMSH0(b, c) GET_CONTEXT_FIELD(b, c, PRRR, SHNMSH0)
744#define GET_SHNMSH1(b, c) GET_CONTEXT_FIELD(b, c, PRRR, SHNMSH1)
745#define GET_NOS0(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS0)
746#define GET_NOS1(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS1)
747#define GET_NOS2(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS2)
748#define GET_NOS3(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS3)
749#define GET_NOS4(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS4)
750#define GET_NOS5(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS5)
751#define GET_NOS6(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS6)
752#define GET_NOS7(b, c) GET_CONTEXT_FIELD(b, c, PRRR, NOS7)
753
754
755/* RESUME */
756#define GET_TNR(b, c) GET_CONTEXT_FIELD(b, c, RESUME, TNR)
757
758
759/* SCTLR */
760#define GET_M(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, M)
761#define GET_TRE(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, TRE)
762#define GET_AFE(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, AFE)
763#define GET_HAF(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, HAF)
764#define GET_BE(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, BE)
765#define GET_AFFD(b, c) GET_CONTEXT_FIELD(b, c, SCTLR, AFFD)
766
767
768/* TLBLKCR */
769#define GET_LKE(b, c) GET_CONTEXT_FIELD(b, c, TLBLKCR, LKE)
770#define GET_TLBLCKR_TLBIALLCFG(b, c) \
771 GET_CONTEXT_FIELD(b, c, TLBLKCR, TLBLCKR_TLBIALLCFG)
772#define GET_TLBIASIDCFG(b, c) GET_CONTEXT_FIELD(b, c, TLBLKCR, TLBIASIDCFG)
773#define GET_TLBIVAACFG(b, c) GET_CONTEXT_FIELD(b, c, TLBLKCR, TLBIVAACFG)
774#define GET_FLOOR(b, c) GET_CONTEXT_FIELD(b, c, TLBLKCR, FLOOR)
775#define GET_VICTIM(b, c) GET_CONTEXT_FIELD(b, c, TLBLKCR, VICTIM)
776
777
778/* TTBCR */
779#define GET_N(b, c) GET_CONTEXT_FIELD(b, c, TTBCR, N)
780#define GET_PD0(b, c) GET_CONTEXT_FIELD(b, c, TTBCR, PD0)
781#define GET_PD1(b, c) GET_CONTEXT_FIELD(b, c, TTBCR, PD1)
782
783
784/* TTBR0 */
785#define GET_TTBR0_IRGNH(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_IRGNH)
786#define GET_TTBR0_SH(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_SH)
787#define GET_TTBR0_ORGN(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_ORGN)
788#define GET_TTBR0_NOS(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_NOS)
789#define GET_TTBR0_IRGNL(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_IRGNL)
790#define GET_TTBR0_PA(b, c) GET_CONTEXT_FIELD(b, c, TTBR0, TTBR0_PA)
791
792
793/* TTBR1 */
794#define GET_TTBR1_IRGNH(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_IRGNH)
795#define GET_TTBR1_SH(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_SH)
796#define GET_TTBR1_ORGN(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_ORGN)
797#define GET_TTBR1_NOS(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_NOS)
798#define GET_TTBR1_IRGNL(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_IRGNL)
799#define GET_TTBR1_PA(b, c) GET_CONTEXT_FIELD(b, c, TTBR1, TTBR1_PA)
800
801
802/* V2PSR */
803#define GET_HIT(b, c) GET_CONTEXT_FIELD(b, c, V2PSR, HIT)
804#define GET_INDEX(b, c) GET_CONTEXT_FIELD(b, c, V2PSR, INDEX)
805
806
807/* V2Pxx UW UR PW PR */
808#define GET_V2PUW_INDEX(b, c) GET_CONTEXT_FIELD(b, c, V2PUW, V2Pxx_INDEX)
809#define GET_V2PUW_VA(b, c) GET_CONTEXT_FIELD(b, c, V2PUW, V2Pxx_VA)
810
811#define GET_V2PUR_INDEX(b, c) GET_CONTEXT_FIELD(b, c, V2PUR, V2Pxx_INDEX)
812#define GET_V2PUR_VA(b, c) GET_CONTEXT_FIELD(b, c, V2PUR, V2Pxx_VA)
813
814#define GET_V2PPW_INDEX(b, c) GET_CONTEXT_FIELD(b, c, V2PPW, V2Pxx_INDEX)
815#define GET_V2PPW_VA(b, c) GET_CONTEXT_FIELD(b, c, V2PPW, V2Pxx_VA)
816
817#define GET_V2PPR_INDEX(b, c) GET_CONTEXT_FIELD(b, c, V2PPR, V2Pxx_INDEX)
818#define GET_V2PPR_VA(b, c) GET_CONTEXT_FIELD(b, c, V2PPR, V2Pxx_VA)
819
820
821/* Global Registers */
822#define M2VCBR_N (0xFF000)
823#define CBACR_N (0xFF800)
824#define TLBRSW (0xFFE00)
825#define TLBTR0 (0xFFE80)
826#define TLBTR1 (0xFFE84)
827#define TLBTR2 (0xFFE88)
828#define TESTBUSCR (0xFFE8C)
829#define GLOBAL_TLBIALL (0xFFF00)
830#define TLBIVMID (0xFFF04)
831#define CR (0xFFF80)
832#define EAR (0xFFF84)
833#define ESR (0xFFF88)
834#define ESRRESTORE (0xFFF8C)
835#define ESYNR0 (0xFFF90)
836#define ESYNR1 (0xFFF94)
837#define REV (0xFFFF4)
838#define IDR (0xFFFF8)
839#define RPU_ACR (0xFFFFC)
840
841
842/* Context Bank Registers */
843#define SCTLR (0x000)
844#define ACTLR (0x004)
845#define CONTEXTIDR (0x008)
846#define TTBR0 (0x010)
847#define TTBR1 (0x014)
848#define TTBCR (0x018)
849#define PAR (0x01C)
850#define FSR (0x020)
851#define FSRRESTORE (0x024)
852#define FAR (0x028)
853#define FSYNR0 (0x02C)
854#define FSYNR1 (0x030)
855#define PRRR (0x034)
856#define NMRR (0x038)
857#define TLBLCKR (0x03C)
858#define V2PSR (0x040)
859#define TLBFLPTER (0x044)
860#define TLBSLPTER (0x048)
861#define BFBCR (0x04C)
862#define CTX_TLBIALL (0x800)
863#define TLBIASID (0x804)
864#define TLBIVA (0x808)
865#define TLBIVAA (0x80C)
866#define V2PPR (0x810)
867#define V2PPW (0x814)
868#define V2PUR (0x818)
869#define V2PUW (0x81C)
870#define RESUME (0x820)
871
872
873/* Global Register Fields */
874/* CBACRn */
875#define RWVMID (RWVMID_MASK << RWVMID_SHIFT)
876#define RWE (RWE_MASK << RWE_SHIFT)
877#define RWGE (RWGE_MASK << RWGE_SHIFT)
878#define CBVMID (CBVMID_MASK << CBVMID_SHIFT)
879#define IRPTNDX (IRPTNDX_MASK << IRPTNDX_SHIFT)
880
881
882/* CR */
883#define RPUE (RPUE_MASK << RPUE_SHIFT)
884#define RPUERE (RPUERE_MASK << RPUERE_SHIFT)
885#define RPUEIE (RPUEIE_MASK << RPUEIE_SHIFT)
886#define DCDEE (DCDEE_MASK << DCDEE_SHIFT)
887#define CLIENTPD (CLIENTPD_MASK << CLIENTPD_SHIFT)
888#define STALLD (STALLD_MASK << STALLD_SHIFT)
889#define TLBLKCRWE (TLBLKCRWE_MASK << TLBLKCRWE_SHIFT)
890#define CR_TLBIALLCFG (CR_TLBIALLCFG_MASK << CR_TLBIALLCFG_SHIFT)
891#define TLBIVMIDCFG (TLBIVMIDCFG_MASK << TLBIVMIDCFG_SHIFT)
892#define CR_HUME (CR_HUME_MASK << CR_HUME_SHIFT)
893
894
895/* ESR */
896#define CFG (CFG_MASK << CFG_SHIFT)
897#define BYPASS (BYPASS_MASK << BYPASS_SHIFT)
898#define ESR_MULTI (ESR_MULTI_MASK << ESR_MULTI_SHIFT)
899
900
901/* ESYNR0 */
902#define ESYNR0_AMID (ESYNR0_AMID_MASK << ESYNR0_AMID_SHIFT)
903#define ESYNR0_APID (ESYNR0_APID_MASK << ESYNR0_APID_SHIFT)
904#define ESYNR0_ABID (ESYNR0_ABID_MASK << ESYNR0_ABID_SHIFT)
905#define ESYNR0_AVMID (ESYNR0_AVMID_MASK << ESYNR0_AVMID_SHIFT)
906#define ESYNR0_ATID (ESYNR0_ATID_MASK << ESYNR0_ATID_SHIFT)
907
908
909/* ESYNR1 */
910#define ESYNR1_AMEMTYPE (ESYNR1_AMEMTYPE_MASK << ESYNR1_AMEMTYPE_SHIFT)
911#define ESYNR1_ASHARED (ESYNR1_ASHARED_MASK << ESYNR1_ASHARED_SHIFT)
912#define ESYNR1_AINNERSHARED (ESYNR1_AINNERSHARED_MASK<< \
913 ESYNR1_AINNERSHARED_SHIFT)
914#define ESYNR1_APRIV (ESYNR1_APRIV_MASK << ESYNR1_APRIV_SHIFT)
915#define ESYNR1_APROTNS (ESYNR1_APROTNS_MASK << ESYNR1_APROTNS_SHIFT)
916#define ESYNR1_AINST (ESYNR1_AINST_MASK << ESYNR1_AINST_SHIFT)
917#define ESYNR1_AWRITE (ESYNR1_AWRITE_MASK << ESYNR1_AWRITE_SHIFT)
918#define ESYNR1_ABURST (ESYNR1_ABURST_MASK << ESYNR1_ABURST_SHIFT)
919#define ESYNR1_ALEN (ESYNR1_ALEN_MASK << ESYNR1_ALEN_SHIFT)
920#define ESYNR1_ASIZE (ESYNR1_ASIZE_MASK << ESYNR1_ASIZE_SHIFT)
921#define ESYNR1_ALOCK (ESYNR1_ALOCK_MASK << ESYNR1_ALOCK_SHIFT)
922#define ESYNR1_AOOO (ESYNR1_AOOO_MASK << ESYNR1_AOOO_SHIFT)
923#define ESYNR1_AFULL (ESYNR1_AFULL_MASK << ESYNR1_AFULL_SHIFT)
924#define ESYNR1_AC (ESYNR1_AC_MASK << ESYNR1_AC_SHIFT)
925#define ESYNR1_DCD (ESYNR1_DCD_MASK << ESYNR1_DCD_SHIFT)
926
927
928/* IDR */
929#define NM2VCBMT (NM2VCBMT_MASK << NM2VCBMT_SHIFT)
930#define HTW (HTW_MASK << HTW_SHIFT)
931#define HUM (HUM_MASK << HUM_SHIFT)
932#define TLBSIZE (TLBSIZE_MASK << TLBSIZE_SHIFT)
933#define NCB (NCB_MASK << NCB_SHIFT)
934#define NIRPT (NIRPT_MASK << NIRPT_SHIFT)
935
936
937/* M2VCBRn */
938#define VMID (VMID_MASK << VMID_SHIFT)
939#define CBNDX (CBNDX_MASK << CBNDX_SHIFT)
940#define BYPASSD (BYPASSD_MASK << BYPASSD_SHIFT)
941#define BPRCOSH (BPRCOSH_MASK << BPRCOSH_SHIFT)
942#define BPRCISH (BPRCISH_MASK << BPRCISH_SHIFT)
943#define BPRCNSH (BPRCNSH_MASK << BPRCNSH_SHIFT)
944#define BPSHCFG (BPSHCFG_MASK << BPSHCFG_SHIFT)
945#define NSCFG (NSCFG_MASK << NSCFG_SHIFT)
946#define BPMTCFG (BPMTCFG_MASK << BPMTCFG_SHIFT)
947#define BPMEMTYPE (BPMEMTYPE_MASK << BPMEMTYPE_SHIFT)
948
949
950/* REV */
951#define IDR_MINOR (MINOR_MASK << MINOR_SHIFT)
952#define IDR_MAJOR (MAJOR_MASK << MAJOR_SHIFT)
953
954
955/* TESTBUSCR */
956#define TBE (TBE_MASK << TBE_SHIFT)
957#define SPDMBE (SPDMBE_MASK << SPDMBE_SHIFT)
958#define WGSEL (WGSEL_MASK << WGSEL_SHIFT)
959#define TBLSEL (TBLSEL_MASK << TBLSEL_SHIFT)
960#define TBHSEL (TBHSEL_MASK << TBHSEL_SHIFT)
961#define SPDM0SEL (SPDM0SEL_MASK << SPDM0SEL_SHIFT)
962#define SPDM1SEL (SPDM1SEL_MASK << SPDM1SEL_SHIFT)
963#define SPDM2SEL (SPDM2SEL_MASK << SPDM2SEL_SHIFT)
964#define SPDM3SEL (SPDM3SEL_MASK << SPDM3SEL_SHIFT)
965
966
967/* TLBIVMID */
968#define TLBIVMID_VMID (TLBIVMID_VMID_MASK << TLBIVMID_VMID_SHIFT)
969
970
971/* TLBRSW */
972#define TLBRSW_INDEX (TLBRSW_INDEX_MASK << TLBRSW_INDEX_SHIFT)
973#define TLBBFBS (TLBBFBS_MASK << TLBBFBS_SHIFT)
974
975
976/* TLBTR0 */
977#define PR (PR_MASK << PR_SHIFT)
978#define PW (PW_MASK << PW_SHIFT)
979#define UR (UR_MASK << UR_SHIFT)
980#define UW (UW_MASK << UW_SHIFT)
981#define XN (XN_MASK << XN_SHIFT)
982#define NSDESC (NSDESC_MASK << NSDESC_SHIFT)
983#define ISH (ISH_MASK << ISH_SHIFT)
984#define SH (SH_MASK << SH_SHIFT)
985#define MT (MT_MASK << MT_SHIFT)
986#define DPSIZR (DPSIZR_MASK << DPSIZR_SHIFT)
987#define DPSIZC (DPSIZC_MASK << DPSIZC_SHIFT)
988
989
990/* TLBTR1 */
991#define TLBTR1_VMID (TLBTR1_VMID_MASK << TLBTR1_VMID_SHIFT)
992#define TLBTR1_PA (TLBTR1_PA_MASK << TLBTR1_PA_SHIFT)
993
994
995/* TLBTR2 */
996#define TLBTR2_ASID (TLBTR2_ASID_MASK << TLBTR2_ASID_SHIFT)
997#define TLBTR2_V (TLBTR2_V_MASK << TLBTR2_V_SHIFT)
998#define TLBTR2_NSTID (TLBTR2_NSTID_MASK << TLBTR2_NSTID_SHIFT)
999#define TLBTR2_NV (TLBTR2_NV_MASK << TLBTR2_NV_SHIFT)
1000#define TLBTR2_VA (TLBTR2_VA_MASK << TLBTR2_VA_SHIFT)
1001
1002
1003/* Context Register Fields */
1004/* ACTLR */
1005#define CFERE (CFERE_MASK << CFERE_SHIFT)
1006#define CFEIE (CFEIE_MASK << CFEIE_SHIFT)
1007#define PTSHCFG (PTSHCFG_MASK << PTSHCFG_SHIFT)
1008#define RCOSH (RCOSH_MASK << RCOSH_SHIFT)
1009#define RCISH (RCISH_MASK << RCISH_SHIFT)
1010#define RCNSH (RCNSH_MASK << RCNSH_SHIFT)
1011#define PRIVCFG (PRIVCFG_MASK << PRIVCFG_SHIFT)
1012#define DNA (DNA_MASK << DNA_SHIFT)
1013#define DNLV2PA (DNLV2PA_MASK << DNLV2PA_SHIFT)
1014#define TLBMCFG (TLBMCFG_MASK << TLBMCFG_SHIFT)
1015#define CFCFG (CFCFG_MASK << CFCFG_SHIFT)
1016#define TIPCF (TIPCF_MASK << TIPCF_SHIFT)
1017#define V2PCFG (V2PCFG_MASK << V2PCFG_SHIFT)
1018#define HUME (HUME_MASK << HUME_SHIFT)
1019#define PTMTCFG (PTMTCFG_MASK << PTMTCFG_SHIFT)
1020#define PTMEMTYPE (PTMEMTYPE_MASK << PTMEMTYPE_SHIFT)
1021
1022
1023/* BFBCR */
1024#define BFBDFE (BFBDFE_MASK << BFBDFE_SHIFT)
1025#define BFBSFE (BFBSFE_MASK << BFBSFE_SHIFT)
1026#define SFVS (SFVS_MASK << SFVS_SHIFT)
1027#define FLVIC (FLVIC_MASK << FLVIC_SHIFT)
1028#define SLVIC (SLVIC_MASK << SLVIC_SHIFT)
1029
1030
1031/* CONTEXTIDR */
1032#define CONTEXTIDR_ASID (CONTEXTIDR_ASID_MASK << CONTEXTIDR_ASID_SHIFT)
1033#define PROCID (PROCID_MASK << PROCID_SHIFT)
1034
1035
1036/* FSR */
1037#define TF (TF_MASK << TF_SHIFT)
1038#define AFF (AFF_MASK << AFF_SHIFT)
1039#define APF (APF_MASK << APF_SHIFT)
1040#define TLBMF (TLBMF_MASK << TLBMF_SHIFT)
1041#define HTWDEEF (HTWDEEF_MASK << HTWDEEF_SHIFT)
1042#define HTWSEEF (HTWSEEF_MASK << HTWSEEF_SHIFT)
1043#define MHF (MHF_MASK << MHF_SHIFT)
1044#define SL (SL_MASK << SL_SHIFT)
1045#define SS (SS_MASK << SS_SHIFT)
1046#define MULTI (MULTI_MASK << MULTI_SHIFT)
1047
1048
1049/* FSYNR0 */
1050#define AMID (AMID_MASK << AMID_SHIFT)
1051#define APID (APID_MASK << APID_SHIFT)
1052#define ABID (ABID_MASK << ABID_SHIFT)
1053#define ATID (ATID_MASK << ATID_SHIFT)
1054
1055
1056/* FSYNR1 */
1057#define AMEMTYPE (AMEMTYPE_MASK << AMEMTYPE_SHIFT)
1058#define ASHARED (ASHARED_MASK << ASHARED_SHIFT)
1059#define AINNERSHARED (AINNERSHARED_MASK << AINNERSHARED_SHIFT)
1060#define APRIV (APRIV_MASK << APRIV_SHIFT)
1061#define APROTNS (APROTNS_MASK << APROTNS_SHIFT)
1062#define AINST (AINST_MASK << AINST_SHIFT)
1063#define AWRITE (AWRITE_MASK << AWRITE_SHIFT)
1064#define ABURST (ABURST_MASK << ABURST_SHIFT)
1065#define ALEN (ALEN_MASK << ALEN_SHIFT)
1066#define FSYNR1_ASIZE (FSYNR1_ASIZE_MASK << FSYNR1_ASIZE_SHIFT)
1067#define ALOCK (ALOCK_MASK << ALOCK_SHIFT)
1068#define AFULL (AFULL_MASK << AFULL_SHIFT)
1069
1070
1071/* NMRR */
1072#define ICPC0 (ICPC0_MASK << ICPC0_SHIFT)
1073#define ICPC1 (ICPC1_MASK << ICPC1_SHIFT)
1074#define ICPC2 (ICPC2_MASK << ICPC2_SHIFT)
1075#define ICPC3 (ICPC3_MASK << ICPC3_SHIFT)
1076#define ICPC4 (ICPC4_MASK << ICPC4_SHIFT)
1077#define ICPC5 (ICPC5_MASK << ICPC5_SHIFT)
1078#define ICPC6 (ICPC6_MASK << ICPC6_SHIFT)
1079#define ICPC7 (ICPC7_MASK << ICPC7_SHIFT)
1080#define OCPC0 (OCPC0_MASK << OCPC0_SHIFT)
1081#define OCPC1 (OCPC1_MASK << OCPC1_SHIFT)
1082#define OCPC2 (OCPC2_MASK << OCPC2_SHIFT)
1083#define OCPC3 (OCPC3_MASK << OCPC3_SHIFT)
1084#define OCPC4 (OCPC4_MASK << OCPC4_SHIFT)
1085#define OCPC5 (OCPC5_MASK << OCPC5_SHIFT)
1086#define OCPC6 (OCPC6_MASK << OCPC6_SHIFT)
1087#define OCPC7 (OCPC7_MASK << OCPC7_SHIFT)
1088
1089
1090/* PAR */
1091#define FAULT (FAULT_MASK << FAULT_SHIFT)
1092/* If a fault is present, these are the
1093same as the fault fields in the FAR */
1094#define FAULT_TF (FAULT_TF_MASK << FAULT_TF_SHIFT)
1095#define FAULT_AFF (FAULT_AFF_MASK << FAULT_AFF_SHIFT)
1096#define FAULT_APF (FAULT_APF_MASK << FAULT_APF_SHIFT)
1097#define FAULT_TLBMF (FAULT_TLBMF_MASK << FAULT_TLBMF_SHIFT)
1098#define FAULT_HTWDEEF (FAULT_HTWDEEF_MASK << FAULT_HTWDEEF_SHIFT)
1099#define FAULT_HTWSEEF (FAULT_HTWSEEF_MASK << FAULT_HTWSEEF_SHIFT)
1100#define FAULT_MHF (FAULT_MHF_MASK << FAULT_MHF_SHIFT)
1101#define FAULT_SL (FAULT_SL_MASK << FAULT_SL_SHIFT)
1102#define FAULT_SS (FAULT_SS_MASK << FAULT_SS_SHIFT)
1103
1104/* If NO fault is present, the following fields are in effect */
1105/* (FAULT remains as before) */
1106#define PAR_NOFAULT_SS (PAR_NOFAULT_SS_MASK << PAR_NOFAULT_SS_SHIFT)
1107#define PAR_NOFAULT_MT (PAR_NOFAULT_MT_MASK << PAR_NOFAULT_MT_SHIFT)
1108#define PAR_NOFAULT_SH (PAR_NOFAULT_SH_MASK << PAR_NOFAULT_SH_SHIFT)
1109#define PAR_NOFAULT_NS (PAR_NOFAULT_NS_MASK << PAR_NOFAULT_NS_SHIFT)
1110#define PAR_NOFAULT_NOS (PAR_NOFAULT_NOS_MASK << PAR_NOFAULT_NOS_SHIFT)
1111#define PAR_NPFAULT_PA (PAR_NPFAULT_PA_MASK << PAR_NPFAULT_PA_SHIFT)
1112
1113
1114/* PRRR */
1115#define MTC0 (MTC0_MASK << MTC0_SHIFT)
1116#define MTC1 (MTC1_MASK << MTC1_SHIFT)
1117#define MTC2 (MTC2_MASK << MTC2_SHIFT)
1118#define MTC3 (MTC3_MASK << MTC3_SHIFT)
1119#define MTC4 (MTC4_MASK << MTC4_SHIFT)
1120#define MTC5 (MTC5_MASK << MTC5_SHIFT)
1121#define MTC6 (MTC6_MASK << MTC6_SHIFT)
1122#define MTC7 (MTC7_MASK << MTC7_SHIFT)
1123#define SHDSH0 (SHDSH0_MASK << SHDSH0_SHIFT)
1124#define SHDSH1 (SHDSH1_MASK << SHDSH1_SHIFT)
1125#define SHNMSH0 (SHNMSH0_MASK << SHNMSH0_SHIFT)
1126#define SHNMSH1 (SHNMSH1_MASK << SHNMSH1_SHIFT)
1127#define NOS0 (NOS0_MASK << NOS0_SHIFT)
1128#define NOS1 (NOS1_MASK << NOS1_SHIFT)
1129#define NOS2 (NOS2_MASK << NOS2_SHIFT)
1130#define NOS3 (NOS3_MASK << NOS3_SHIFT)
1131#define NOS4 (NOS4_MASK << NOS4_SHIFT)
1132#define NOS5 (NOS5_MASK << NOS5_SHIFT)
1133#define NOS6 (NOS6_MASK << NOS6_SHIFT)
1134#define NOS7 (NOS7_MASK << NOS7_SHIFT)
1135
1136
1137/* RESUME */
1138#define TNR (TNR_MASK << TNR_SHIFT)
1139
1140
1141/* SCTLR */
1142#define M (M_MASK << M_SHIFT)
1143#define TRE (TRE_MASK << TRE_SHIFT)
1144#define AFE (AFE_MASK << AFE_SHIFT)
1145#define HAF (HAF_MASK << HAF_SHIFT)
1146#define BE (BE_MASK << BE_SHIFT)
1147#define AFFD (AFFD_MASK << AFFD_SHIFT)
1148
1149
1150/* TLBIASID */
1151#define TLBIASID_ASID (TLBIASID_ASID_MASK << TLBIASID_ASID_SHIFT)
1152
1153
1154/* TLBIVA */
1155#define TLBIVA_ASID (TLBIVA_ASID_MASK << TLBIVA_ASID_SHIFT)
1156#define TLBIVA_VA (TLBIVA_VA_MASK << TLBIVA_VA_SHIFT)
1157
1158
1159/* TLBIVAA */
1160#define TLBIVAA_VA (TLBIVAA_VA_MASK << TLBIVAA_VA_SHIFT)
1161
1162
1163/* TLBLCKR */
1164#define LKE (LKE_MASK << LKE_SHIFT)
1165#define TLBLCKR_TLBIALLCFG (TLBLCKR_TLBIALLCFG_MASK<<TLBLCKR_TLBIALLCFG_SHIFT)
1166#define TLBIASIDCFG (TLBIASIDCFG_MASK << TLBIASIDCFG_SHIFT)
1167#define TLBIVAACFG (TLBIVAACFG_MASK << TLBIVAACFG_SHIFT)
1168#define FLOOR (FLOOR_MASK << FLOOR_SHIFT)
1169#define VICTIM (VICTIM_MASK << VICTIM_SHIFT)
1170
1171
1172/* TTBCR */
1173#define N (N_MASK << N_SHIFT)
1174#define PD0 (PD0_MASK << PD0_SHIFT)
1175#define PD1 (PD1_MASK << PD1_SHIFT)
1176
1177
1178/* TTBR0 */
1179#define TTBR0_IRGNH (TTBR0_IRGNH_MASK << TTBR0_IRGNH_SHIFT)
1180#define TTBR0_SH (TTBR0_SH_MASK << TTBR0_SH_SHIFT)
1181#define TTBR0_ORGN (TTBR0_ORGN_MASK << TTBR0_ORGN_SHIFT)
1182#define TTBR0_NOS (TTBR0_NOS_MASK << TTBR0_NOS_SHIFT)
1183#define TTBR0_IRGNL (TTBR0_IRGNL_MASK << TTBR0_IRGNL_SHIFT)
1184#define TTBR0_PA (TTBR0_PA_MASK << TTBR0_PA_SHIFT)
1185
1186
1187/* TTBR1 */
1188#define TTBR1_IRGNH (TTBR1_IRGNH_MASK << TTBR1_IRGNH_SHIFT)
1189#define TTBR1_SH (TTBR1_SH_MASK << TTBR1_SH_SHIFT)
1190#define TTBR1_ORGN (TTBR1_ORGN_MASK << TTBR1_ORGN_SHIFT)
1191#define TTBR1_NOS (TTBR1_NOS_MASK << TTBR1_NOS_SHIFT)
1192#define TTBR1_IRGNL (TTBR1_IRGNL_MASK << TTBR1_IRGNL_SHIFT)
1193#define TTBR1_PA (TTBR1_PA_MASK << TTBR1_PA_SHIFT)
1194
1195
1196/* V2PSR */
1197#define HIT (HIT_MASK << HIT_SHIFT)
1198#define INDEX (INDEX_MASK << INDEX_SHIFT)
1199
1200
1201/* V2Pxx */
1202#define V2Pxx_INDEX (V2Pxx_INDEX_MASK << V2Pxx_INDEX_SHIFT)
1203#define V2Pxx_VA (V2Pxx_VA_MASK << V2Pxx_VA_SHIFT)
1204
1205
1206/* Global Register Masks */
1207/* CBACRn */
1208#define RWVMID_MASK 0x1F
1209#define RWE_MASK 0x01
1210#define RWGE_MASK 0x01
1211#define CBVMID_MASK 0x1F
1212#define IRPTNDX_MASK 0xFF
1213
1214
1215/* CR */
1216#define RPUE_MASK 0x01
1217#define RPUERE_MASK 0x01
1218#define RPUEIE_MASK 0x01
1219#define DCDEE_MASK 0x01
1220#define CLIENTPD_MASK 0x01
1221#define STALLD_MASK 0x01
1222#define TLBLKCRWE_MASK 0x01
1223#define CR_TLBIALLCFG_MASK 0x01
1224#define TLBIVMIDCFG_MASK 0x01
1225#define CR_HUME_MASK 0x01
1226
1227
1228/* ESR */
1229#define CFG_MASK 0x01
1230#define BYPASS_MASK 0x01
1231#define ESR_MULTI_MASK 0x01
1232
1233
1234/* ESYNR0 */
1235#define ESYNR0_AMID_MASK 0xFF
1236#define ESYNR0_APID_MASK 0x1F
1237#define ESYNR0_ABID_MASK 0x07
1238#define ESYNR0_AVMID_MASK 0x1F
1239#define ESYNR0_ATID_MASK 0xFF
1240
1241
1242/* ESYNR1 */
1243#define ESYNR1_AMEMTYPE_MASK 0x07
1244#define ESYNR1_ASHARED_MASK 0x01
1245#define ESYNR1_AINNERSHARED_MASK 0x01
1246#define ESYNR1_APRIV_MASK 0x01
1247#define ESYNR1_APROTNS_MASK 0x01
1248#define ESYNR1_AINST_MASK 0x01
1249#define ESYNR1_AWRITE_MASK 0x01
1250#define ESYNR1_ABURST_MASK 0x01
1251#define ESYNR1_ALEN_MASK 0x0F
1252#define ESYNR1_ASIZE_MASK 0x01
1253#define ESYNR1_ALOCK_MASK 0x03
1254#define ESYNR1_AOOO_MASK 0x01
1255#define ESYNR1_AFULL_MASK 0x01
1256#define ESYNR1_AC_MASK 0x01
1257#define ESYNR1_DCD_MASK 0x01
1258
1259
1260/* IDR */
1261#define NM2VCBMT_MASK 0x1FF
1262#define HTW_MASK 0x01
1263#define HUM_MASK 0x01
1264#define TLBSIZE_MASK 0x0F
1265#define NCB_MASK 0xFF
1266#define NIRPT_MASK 0xFF
1267
1268
1269/* M2VCBRn */
1270#define VMID_MASK 0x1F
1271#define CBNDX_MASK 0xFF
1272#define BYPASSD_MASK 0x01
1273#define BPRCOSH_MASK 0x01
1274#define BPRCISH_MASK 0x01
1275#define BPRCNSH_MASK 0x01
1276#define BPSHCFG_MASK 0x03
1277#define NSCFG_MASK 0x03
1278#define BPMTCFG_MASK 0x01
1279#define BPMEMTYPE_MASK 0x07
1280
1281
1282/* REV */
1283#define MINOR_MASK 0x0F
1284#define MAJOR_MASK 0x0F
1285
1286
1287/* TESTBUSCR */
1288#define TBE_MASK 0x01
1289#define SPDMBE_MASK 0x01
1290#define WGSEL_MASK 0x03
1291#define TBLSEL_MASK 0x03
1292#define TBHSEL_MASK 0x03
1293#define SPDM0SEL_MASK 0x0F
1294#define SPDM1SEL_MASK 0x0F
1295#define SPDM2SEL_MASK 0x0F
1296#define SPDM3SEL_MASK 0x0F
1297
1298
1299/* TLBIMID */
1300#define TLBIVMID_VMID_MASK 0x1F
1301
1302
1303/* TLBRSW */
1304#define TLBRSW_INDEX_MASK 0xFF
1305#define TLBBFBS_MASK 0x03
1306
1307
1308/* TLBTR0 */
1309#define PR_MASK 0x01
1310#define PW_MASK 0x01
1311#define UR_MASK 0x01
1312#define UW_MASK 0x01
1313#define XN_MASK 0x01
1314#define NSDESC_MASK 0x01
1315#define ISH_MASK 0x01
1316#define SH_MASK 0x01
1317#define MT_MASK 0x07
1318#define DPSIZR_MASK 0x07
1319#define DPSIZC_MASK 0x07
1320
1321
1322/* TLBTR1 */
1323#define TLBTR1_VMID_MASK 0x1F
1324#define TLBTR1_PA_MASK 0x000FFFFF
1325
1326
1327/* TLBTR2 */
1328#define TLBTR2_ASID_MASK 0xFF
1329#define TLBTR2_V_MASK 0x01
1330#define TLBTR2_NSTID_MASK 0x01
1331#define TLBTR2_NV_MASK 0x01
1332#define TLBTR2_VA_MASK 0x000FFFFF
1333
1334
1335/* Global Register Shifts */
1336/* CBACRn */
1337#define RWVMID_SHIFT 0
1338#define RWE_SHIFT 8
1339#define RWGE_SHIFT 9
1340#define CBVMID_SHIFT 16
1341#define IRPTNDX_SHIFT 24
1342
1343
1344/* CR */
1345#define RPUE_SHIFT 0
1346#define RPUERE_SHIFT 1
1347#define RPUEIE_SHIFT 2
1348#define DCDEE_SHIFT 3
1349#define CLIENTPD_SHIFT 4
1350#define STALLD_SHIFT 5
1351#define TLBLKCRWE_SHIFT 6
1352#define CR_TLBIALLCFG_SHIFT 7
1353#define TLBIVMIDCFG_SHIFT 8
1354#define CR_HUME_SHIFT 9
1355
1356
1357/* ESR */
1358#define CFG_SHIFT 0
1359#define BYPASS_SHIFT 1
1360#define ESR_MULTI_SHIFT 31
1361
1362
1363/* ESYNR0 */
1364#define ESYNR0_AMID_SHIFT 0
1365#define ESYNR0_APID_SHIFT 8
1366#define ESYNR0_ABID_SHIFT 13
1367#define ESYNR0_AVMID_SHIFT 16
1368#define ESYNR0_ATID_SHIFT 24
1369
1370
1371/* ESYNR1 */
1372#define ESYNR1_AMEMTYPE_SHIFT 0
1373#define ESYNR1_ASHARED_SHIFT 3
1374#define ESYNR1_AINNERSHARED_SHIFT 4
1375#define ESYNR1_APRIV_SHIFT 5
1376#define ESYNR1_APROTNS_SHIFT 6
1377#define ESYNR1_AINST_SHIFT 7
1378#define ESYNR1_AWRITE_SHIFT 8
1379#define ESYNR1_ABURST_SHIFT 10
1380#define ESYNR1_ALEN_SHIFT 12
1381#define ESYNR1_ASIZE_SHIFT 16
1382#define ESYNR1_ALOCK_SHIFT 20
1383#define ESYNR1_AOOO_SHIFT 22
1384#define ESYNR1_AFULL_SHIFT 24
1385#define ESYNR1_AC_SHIFT 30
1386#define ESYNR1_DCD_SHIFT 31
1387
1388
1389/* IDR */
1390#define NM2VCBMT_SHIFT 0
1391#define HTW_SHIFT 9
1392#define HUM_SHIFT 10
1393#define TLBSIZE_SHIFT 12
1394#define NCB_SHIFT 16
1395#define NIRPT_SHIFT 24
1396
1397
1398/* M2VCBRn */
1399#define VMID_SHIFT 0
1400#define CBNDX_SHIFT 8
1401#define BYPASSD_SHIFT 16
1402#define BPRCOSH_SHIFT 17
1403#define BPRCISH_SHIFT 18
1404#define BPRCNSH_SHIFT 19
1405#define BPSHCFG_SHIFT 20
1406#define NSCFG_SHIFT 22
1407#define BPMTCFG_SHIFT 24
1408#define BPMEMTYPE_SHIFT 25
1409
1410
1411/* REV */
1412#define MINOR_SHIFT 0
1413#define MAJOR_SHIFT 4
1414
1415
1416/* TESTBUSCR */
1417#define TBE_SHIFT 0
1418#define SPDMBE_SHIFT 1
1419#define WGSEL_SHIFT 8
1420#define TBLSEL_SHIFT 12
1421#define TBHSEL_SHIFT 14
1422#define SPDM0SEL_SHIFT 16
1423#define SPDM1SEL_SHIFT 20
1424#define SPDM2SEL_SHIFT 24
1425#define SPDM3SEL_SHIFT 28
1426
1427
1428/* TLBIMID */
1429#define TLBIVMID_VMID_SHIFT 0
1430
1431
1432/* TLBRSW */
1433#define TLBRSW_INDEX_SHIFT 0
1434#define TLBBFBS_SHIFT 8
1435
1436
1437/* TLBTR0 */
1438#define PR_SHIFT 0
1439#define PW_SHIFT 1
1440#define UR_SHIFT 2
1441#define UW_SHIFT 3
1442#define XN_SHIFT 4
1443#define NSDESC_SHIFT 6
1444#define ISH_SHIFT 7
1445#define SH_SHIFT 8
1446#define MT_SHIFT 9
1447#define DPSIZR_SHIFT 16
1448#define DPSIZC_SHIFT 20
1449
1450
1451/* TLBTR1 */
1452#define TLBTR1_VMID_SHIFT 0
1453#define TLBTR1_PA_SHIFT 12
1454
1455
1456/* TLBTR2 */
1457#define TLBTR2_ASID_SHIFT 0
1458#define TLBTR2_V_SHIFT 8
1459#define TLBTR2_NSTID_SHIFT 9
1460#define TLBTR2_NV_SHIFT 10
1461#define TLBTR2_VA_SHIFT 12
1462
1463
1464/* Context Register Masks */
1465/* ACTLR */
1466#define CFERE_MASK 0x01
1467#define CFEIE_MASK 0x01
1468#define PTSHCFG_MASK 0x03
1469#define RCOSH_MASK 0x01
1470#define RCISH_MASK 0x01
1471#define RCNSH_MASK 0x01
1472#define PRIVCFG_MASK 0x03
1473#define DNA_MASK 0x01
1474#define DNLV2PA_MASK 0x01
1475#define TLBMCFG_MASK 0x03
1476#define CFCFG_MASK 0x01
1477#define TIPCF_MASK 0x01
1478#define V2PCFG_MASK 0x03
1479#define HUME_MASK 0x01
1480#define PTMTCFG_MASK 0x01
1481#define PTMEMTYPE_MASK 0x07
1482
1483
1484/* BFBCR */
1485#define BFBDFE_MASK 0x01
1486#define BFBSFE_MASK 0x01
1487#define SFVS_MASK 0x01
1488#define FLVIC_MASK 0x0F
1489#define SLVIC_MASK 0x0F
1490
1491
1492/* CONTEXTIDR */
1493#define CONTEXTIDR_ASID_MASK 0xFF
1494#define PROCID_MASK 0x00FFFFFF
1495
1496
1497/* FSR */
1498#define TF_MASK 0x01
1499#define AFF_MASK 0x01
1500#define APF_MASK 0x01
1501#define TLBMF_MASK 0x01
1502#define HTWDEEF_MASK 0x01
1503#define HTWSEEF_MASK 0x01
1504#define MHF_MASK 0x01
1505#define SL_MASK 0x01
1506#define SS_MASK 0x01
1507#define MULTI_MASK 0x01
1508
1509
1510/* FSYNR0 */
1511#define AMID_MASK 0xFF
1512#define APID_MASK 0x1F
1513#define ABID_MASK 0x07
1514#define ATID_MASK 0xFF
1515
1516
1517/* FSYNR1 */
1518#define AMEMTYPE_MASK 0x07
1519#define ASHARED_MASK 0x01
1520#define AINNERSHARED_MASK 0x01
1521#define APRIV_MASK 0x01
1522#define APROTNS_MASK 0x01
1523#define AINST_MASK 0x01
1524#define AWRITE_MASK 0x01
1525#define ABURST_MASK 0x01
1526#define ALEN_MASK 0x0F
1527#define FSYNR1_ASIZE_MASK 0x07
1528#define ALOCK_MASK 0x03
1529#define AFULL_MASK 0x01
1530
1531
1532/* NMRR */
1533#define ICPC0_MASK 0x03
1534#define ICPC1_MASK 0x03
1535#define ICPC2_MASK 0x03
1536#define ICPC3_MASK 0x03
1537#define ICPC4_MASK 0x03
1538#define ICPC5_MASK 0x03
1539#define ICPC6_MASK 0x03
1540#define ICPC7_MASK 0x03
1541#define OCPC0_MASK 0x03
1542#define OCPC1_MASK 0x03
1543#define OCPC2_MASK 0x03
1544#define OCPC3_MASK 0x03
1545#define OCPC4_MASK 0x03
1546#define OCPC5_MASK 0x03
1547#define OCPC6_MASK 0x03
1548#define OCPC7_MASK 0x03
1549
1550
1551/* PAR */
1552#define FAULT_MASK 0x01
1553/* If a fault is present, these are the
1554same as the fault fields in the FAR */
1555#define FAULT_TF_MASK 0x01
1556#define FAULT_AFF_MASK 0x01
1557#define FAULT_APF_MASK 0x01
1558#define FAULT_TLBMF_MASK 0x01
1559#define FAULT_HTWDEEF_MASK 0x01
1560#define FAULT_HTWSEEF_MASK 0x01
1561#define FAULT_MHF_MASK 0x01
1562#define FAULT_SL_MASK 0x01
1563#define FAULT_SS_MASK 0x01
1564
1565/* If NO fault is present, the following
1566 * fields are in effect
1567 * (FAULT remains as before) */
1568#define PAR_NOFAULT_SS_MASK 0x01
1569#define PAR_NOFAULT_MT_MASK 0x07
1570#define PAR_NOFAULT_SH_MASK 0x01
1571#define PAR_NOFAULT_NS_MASK 0x01
1572#define PAR_NOFAULT_NOS_MASK 0x01
1573#define PAR_NPFAULT_PA_MASK 0x000FFFFF
1574
1575
1576/* PRRR */
1577#define MTC0_MASK 0x03
1578#define MTC1_MASK 0x03
1579#define MTC2_MASK 0x03
1580#define MTC3_MASK 0x03
1581#define MTC4_MASK 0x03
1582#define MTC5_MASK 0x03
1583#define MTC6_MASK 0x03
1584#define MTC7_MASK 0x03
1585#define SHDSH0_MASK 0x01
1586#define SHDSH1_MASK 0x01
1587#define SHNMSH0_MASK 0x01
1588#define SHNMSH1_MASK 0x01
1589#define NOS0_MASK 0x01
1590#define NOS1_MASK 0x01
1591#define NOS2_MASK 0x01
1592#define NOS3_MASK 0x01
1593#define NOS4_MASK 0x01
1594#define NOS5_MASK 0x01
1595#define NOS6_MASK 0x01
1596#define NOS7_MASK 0x01
1597
1598
1599/* RESUME */
1600#define TNR_MASK 0x01
1601
1602
1603/* SCTLR */
1604#define M_MASK 0x01
1605#define TRE_MASK 0x01
1606#define AFE_MASK 0x01
1607#define HAF_MASK 0x01
1608#define BE_MASK 0x01
1609#define AFFD_MASK 0x01
1610
1611
1612/* TLBIASID */
1613#define TLBIASID_ASID_MASK 0xFF
1614
1615
1616/* TLBIVA */
1617#define TLBIVA_ASID_MASK 0xFF
1618#define TLBIVA_VA_MASK 0x000FFFFF
1619
1620
1621/* TLBIVAA */
1622#define TLBIVAA_VA_MASK 0x000FFFFF
1623
1624
1625/* TLBLCKR */
1626#define LKE_MASK 0x01
1627#define TLBLCKR_TLBIALLCFG_MASK 0x01
1628#define TLBIASIDCFG_MASK 0x01
1629#define TLBIVAACFG_MASK 0x01
1630#define FLOOR_MASK 0xFF
1631#define VICTIM_MASK 0xFF
1632
1633
1634/* TTBCR */
1635#define N_MASK 0x07
1636#define PD0_MASK 0x01
1637#define PD1_MASK 0x01
1638
1639
1640/* TTBR0 */
1641#define TTBR0_IRGNH_MASK 0x01
1642#define TTBR0_SH_MASK 0x01
1643#define TTBR0_ORGN_MASK 0x03
1644#define TTBR0_NOS_MASK 0x01
1645#define TTBR0_IRGNL_MASK 0x01
1646#define TTBR0_PA_MASK 0x0003FFFF
1647
1648
1649/* TTBR1 */
1650#define TTBR1_IRGNH_MASK 0x01
1651#define TTBR1_SH_MASK 0x01
1652#define TTBR1_ORGN_MASK 0x03
1653#define TTBR1_NOS_MASK 0x01
1654#define TTBR1_IRGNL_MASK 0x01
1655#define TTBR1_PA_MASK 0x0003FFFF
1656
1657
1658/* V2PSR */
1659#define HIT_MASK 0x01
1660#define INDEX_MASK 0xFF
1661
1662
1663/* V2Pxx */
1664#define V2Pxx_INDEX_MASK 0xFF
1665#define V2Pxx_VA_MASK 0x000FFFFF
1666
1667
1668/* Context Register Shifts */
1669/* ACTLR */
1670#define CFERE_SHIFT 0
1671#define CFEIE_SHIFT 1
1672#define PTSHCFG_SHIFT 2
1673#define RCOSH_SHIFT 4
1674#define RCISH_SHIFT 5
1675#define RCNSH_SHIFT 6
1676#define PRIVCFG_SHIFT 8
1677#define DNA_SHIFT 10
1678#define DNLV2PA_SHIFT 11
1679#define TLBMCFG_SHIFT 12
1680#define CFCFG_SHIFT 14
1681#define TIPCF_SHIFT 15
1682#define V2PCFG_SHIFT 16
1683#define HUME_SHIFT 18
1684#define PTMTCFG_SHIFT 20
1685#define PTMEMTYPE_SHIFT 21
1686
1687
1688/* BFBCR */
1689#define BFBDFE_SHIFT 0
1690#define BFBSFE_SHIFT 1
1691#define SFVS_SHIFT 2
1692#define FLVIC_SHIFT 4
1693#define SLVIC_SHIFT 8
1694
1695
1696/* CONTEXTIDR */
1697#define CONTEXTIDR_ASID_SHIFT 0
1698#define PROCID_SHIFT 8
1699
1700
1701/* FSR */
1702#define TF_SHIFT 1
1703#define AFF_SHIFT 2
1704#define APF_SHIFT 3
1705#define TLBMF_SHIFT 4
1706#define HTWDEEF_SHIFT 5
1707#define HTWSEEF_SHIFT 6
1708#define MHF_SHIFT 7
1709#define SL_SHIFT 16
1710#define SS_SHIFT 30
1711#define MULTI_SHIFT 31
1712
1713
1714/* FSYNR0 */
1715#define AMID_SHIFT 0
1716#define APID_SHIFT 8
1717#define ABID_SHIFT 13
1718#define ATID_SHIFT 24
1719
1720
1721/* FSYNR1 */
1722#define AMEMTYPE_SHIFT 0
1723#define ASHARED_SHIFT 3
1724#define AINNERSHARED_SHIFT 4
1725#define APRIV_SHIFT 5
1726#define APROTNS_SHIFT 6
1727#define AINST_SHIFT 7
1728#define AWRITE_SHIFT 8
1729#define ABURST_SHIFT 10
1730#define ALEN_SHIFT 12
1731#define FSYNR1_ASIZE_SHIFT 16
1732#define ALOCK_SHIFT 20
1733#define AFULL_SHIFT 24
1734
1735
1736/* NMRR */
1737#define ICPC0_SHIFT 0
1738#define ICPC1_SHIFT 2
1739#define ICPC2_SHIFT 4
1740#define ICPC3_SHIFT 6
1741#define ICPC4_SHIFT 8
1742#define ICPC5_SHIFT 10
1743#define ICPC6_SHIFT 12
1744#define ICPC7_SHIFT 14
1745#define OCPC0_SHIFT 16
1746#define OCPC1_SHIFT 18
1747#define OCPC2_SHIFT 20
1748#define OCPC3_SHIFT 22
1749#define OCPC4_SHIFT 24
1750#define OCPC5_SHIFT 26
1751#define OCPC6_SHIFT 28
1752#define OCPC7_SHIFT 30
1753
1754
1755/* PAR */
1756#define FAULT_SHIFT 0
1757/* If a fault is present, these are the
1758same as the fault fields in the FAR */
1759#define FAULT_TF_SHIFT 1
1760#define FAULT_AFF_SHIFT 2
1761#define FAULT_APF_SHIFT 3
1762#define FAULT_TLBMF_SHIFT 4
1763#define FAULT_HTWDEEF_SHIFT 5
1764#define FAULT_HTWSEEF_SHIFT 6
1765#define FAULT_MHF_SHIFT 7
1766#define FAULT_SL_SHIFT 16
1767#define FAULT_SS_SHIFT 30
1768
1769/* If NO fault is present, the following
1770 * fields are in effect
1771 * (FAULT remains as before) */
1772#define PAR_NOFAULT_SS_SHIFT 1
1773#define PAR_NOFAULT_MT_SHIFT 4
1774#define PAR_NOFAULT_SH_SHIFT 7
1775#define PAR_NOFAULT_NS_SHIFT 9
1776#define PAR_NOFAULT_NOS_SHIFT 10
1777#define PAR_NPFAULT_PA_SHIFT 12
1778
1779
1780/* PRRR */
1781#define MTC0_SHIFT 0
1782#define MTC1_SHIFT 2
1783#define MTC2_SHIFT 4
1784#define MTC3_SHIFT 6
1785#define MTC4_SHIFT 8
1786#define MTC5_SHIFT 10
1787#define MTC6_SHIFT 12
1788#define MTC7_SHIFT 14
1789#define SHDSH0_SHIFT 16
1790#define SHDSH1_SHIFT 17
1791#define SHNMSH0_SHIFT 18
1792#define SHNMSH1_SHIFT 19
1793#define NOS0_SHIFT 24
1794#define NOS1_SHIFT 25
1795#define NOS2_SHIFT 26
1796#define NOS3_SHIFT 27
1797#define NOS4_SHIFT 28
1798#define NOS5_SHIFT 29
1799#define NOS6_SHIFT 30
1800#define NOS7_SHIFT 31
1801
1802
1803/* RESUME */
1804#define TNR_SHIFT 0
1805
1806
1807/* SCTLR */
1808#define M_SHIFT 0
1809#define TRE_SHIFT 1
1810#define AFE_SHIFT 2
1811#define HAF_SHIFT 3
1812#define BE_SHIFT 4
1813#define AFFD_SHIFT 5
1814
1815
1816/* TLBIASID */
1817#define TLBIASID_ASID_SHIFT 0
1818
1819
1820/* TLBIVA */
1821#define TLBIVA_ASID_SHIFT 0
1822#define TLBIVA_VA_SHIFT 12
1823
1824
1825/* TLBIVAA */
1826#define TLBIVAA_VA_SHIFT 12
1827
1828
1829/* TLBLCKR */
1830#define LKE_SHIFT 0
1831#define TLBLCKR_TLBIALLCFG_SHIFT 1
1832#define TLBIASIDCFG_SHIFT 2
1833#define TLBIVAACFG_SHIFT 3
1834#define FLOOR_SHIFT 8
1835#define VICTIM_SHIFT 8
1836
1837
1838/* TTBCR */
1839#define N_SHIFT 3
1840#define PD0_SHIFT 4
1841#define PD1_SHIFT 5
1842
1843
1844/* TTBR0 */
1845#define TTBR0_IRGNH_SHIFT 0
1846#define TTBR0_SH_SHIFT 1
1847#define TTBR0_ORGN_SHIFT 3
1848#define TTBR0_NOS_SHIFT 5
1849#define TTBR0_IRGNL_SHIFT 6
1850#define TTBR0_PA_SHIFT 14
1851
1852
1853/* TTBR1 */
1854#define TTBR1_IRGNH_SHIFT 0
1855#define TTBR1_SH_SHIFT 1
1856#define TTBR1_ORGN_SHIFT 3
1857#define TTBR1_NOS_SHIFT 5
1858#define TTBR1_IRGNL_SHIFT 6
1859#define TTBR1_PA_SHIFT 14
1860
1861
1862/* V2PSR */
1863#define HIT_SHIFT 0
1864#define INDEX_SHIFT 8
1865
1866
1867/* V2Pxx */
1868#define V2Pxx_INDEX_SHIFT 0
1869#define V2Pxx_VA_SHIFT 12
1870
1871#endif
diff --git a/arch/arm/mach-msm/include/mach/irqs-8x60.h b/arch/arm/mach-msm/include/mach/irqs-8x60.h
new file mode 100644
index 000000000000..36074cfc9ad2
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/irqs-8x60.h
@@ -0,0 +1,253 @@
1/* Copyright (c) 2010 Code Aurora Forum. All rights reserved.
2 *
3 * This software is licensed under the terms of the GNU General Public
4 * License version 2, as published by the Free Software Foundation, and
5 * may be copied, distributed, and modified under those terms.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef __ASM_ARCH_MSM_IRQS_8X60_H
15#define __ASM_ARCH_MSM_IRQS_8X60_H
16
17/* MSM ACPU Interrupt Numbers */
18
19/* 0-15: STI/SGI (software triggered/generated interrupts)
20 * 16-31: PPI (private peripheral interrupts)
21 * 32+: SPI (shared peripheral interrupts)
22 */
23
24#define GIC_PPI_START 16
25#define GIC_SPI_START 32
26
27#define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 0)
28#define INT_GP_TIMER_EXP (GIC_PPI_START + 1)
29#define INT_GP_TIMER2_EXP (GIC_PPI_START + 2)
30#define WDT0_ACCSCSSNBARK_INT (GIC_PPI_START + 3)
31#define WDT1_ACCSCSSNBARK_INT (GIC_PPI_START + 4)
32#define AVS_SVICINT (GIC_PPI_START + 5)
33#define AVS_SVICINTSWDONE (GIC_PPI_START + 6)
34#define CPU_DBGCPUXCOMMRXFULL (GIC_PPI_START + 7)
35#define CPU_DBGCPUXCOMMTXEMPTY (GIC_PPI_START + 8)
36#define CPU_SICCPUXPERFMONIRPTREQ (GIC_PPI_START + 9)
37#define SC_AVSCPUXDOWN (GIC_PPI_START + 10)
38#define SC_AVSCPUXUP (GIC_PPI_START + 11)
39#define SC_SICCPUXACGIRPTREQ (GIC_PPI_START + 12)
40/* PPI 13 to 15 are unused */
41
42
43#define SC_SICMPUIRPTREQ (GIC_SPI_START + 0)
44#define SC_SICL2IRPTREQ (GIC_SPI_START + 1)
45#define SC_SICL2ACGIRPTREQ (GIC_SPI_START + 2)
46#define NC (GIC_SPI_START + 3)
47#define TLMM_SCSS_DIR_CONN_IRQ_0 (GIC_SPI_START + 4)
48#define TLMM_SCSS_DIR_CONN_IRQ_1 (GIC_SPI_START + 5)
49#define TLMM_SCSS_DIR_CONN_IRQ_2 (GIC_SPI_START + 6)
50#define TLMM_SCSS_DIR_CONN_IRQ_3 (GIC_SPI_START + 7)
51#define TLMM_SCSS_DIR_CONN_IRQ_4 (GIC_SPI_START + 8)
52#define TLMM_SCSS_DIR_CONN_IRQ_5 (GIC_SPI_START + 9)
53#define TLMM_SCSS_DIR_CONN_IRQ_6 (GIC_SPI_START + 10)
54#define TLMM_SCSS_DIR_CONN_IRQ_7 (GIC_SPI_START + 11)
55#define TLMM_SCSS_DIR_CONN_IRQ_8 (GIC_SPI_START + 12)
56#define TLMM_SCSS_DIR_CONN_IRQ_9 (GIC_SPI_START + 13)
57#define PM8058_SEC_IRQ_N (GIC_SPI_START + 14)
58#define PM8901_SEC_IRQ_N (GIC_SPI_START + 15)
59#define TLMM_SCSS_SUMMARY_IRQ (GIC_SPI_START + 16)
60#define SPDM_RT_1_IRQ (GIC_SPI_START + 17)
61#define SPDM_DIAG_IRQ (GIC_SPI_START + 18)
62#define RPM_SCSS_CPU0_GP_HIGH_IRQ (GIC_SPI_START + 19)
63#define RPM_SCSS_CPU0_GP_MEDIUM_IRQ (GIC_SPI_START + 20)
64#define RPM_SCSS_CPU0_GP_LOW_IRQ (GIC_SPI_START + 21)
65#define RPM_SCSS_CPU0_WAKE_UP_IRQ (GIC_SPI_START + 22)
66#define RPM_SCSS_CPU1_GP_HIGH_IRQ (GIC_SPI_START + 23)
67#define RPM_SCSS_CPU1_GP_MEDIUM_IRQ (GIC_SPI_START + 24)
68#define RPM_SCSS_CPU1_GP_LOW_IRQ (GIC_SPI_START + 25)
69#define RPM_SCSS_CPU1_WAKE_UP_IRQ (GIC_SPI_START + 26)
70#define SSBI2_2_SC_CPU0_SECURE_INT (GIC_SPI_START + 27)
71#define SSBI2_2_SC_CPU0_NON_SECURE_INT (GIC_SPI_START + 28)
72#define SSBI2_1_SC_CPU0_SECURE_INT (GIC_SPI_START + 29)
73#define SSBI2_1_SC_CPU0_NON_SECURE_INT (GIC_SPI_START + 30)
74#define MSMC_SC_SEC_CE_IRQ (GIC_SPI_START + 31)
75#define MSMC_SC_PRI_CE_IRQ (GIC_SPI_START + 32)
76#define MARM_FIQ (GIC_SPI_START + 33)
77#define MARM_IRQ (GIC_SPI_START + 34)
78#define MARM_L2CC_IRQ (GIC_SPI_START + 35)
79#define MARM_WDOG_EXPIRED (GIC_SPI_START + 36)
80#define MARM_SCSS_GP_IRQ_0 (GIC_SPI_START + 37)
81#define MARM_SCSS_GP_IRQ_1 (GIC_SPI_START + 38)
82#define MARM_SCSS_GP_IRQ_2 (GIC_SPI_START + 39)
83#define MARM_SCSS_GP_IRQ_3 (GIC_SPI_START + 40)
84#define MARM_SCSS_GP_IRQ_4 (GIC_SPI_START + 41)
85#define MARM_SCSS_GP_IRQ_5 (GIC_SPI_START + 42)
86#define MARM_SCSS_GP_IRQ_6 (GIC_SPI_START + 43)
87#define MARM_SCSS_GP_IRQ_7 (GIC_SPI_START + 44)
88#define MARM_SCSS_GP_IRQ_8 (GIC_SPI_START + 45)
89#define MARM_SCSS_GP_IRQ_9 (GIC_SPI_START + 46)
90#define VPE_IRQ (GIC_SPI_START + 47)
91#define VFE_IRQ (GIC_SPI_START + 48)
92#define VCODEC_IRQ (GIC_SPI_START + 49)
93#define TV_ENC_IRQ (GIC_SPI_START + 50)
94#define SMMU_VPE_CB_SC_SECURE_IRQ (GIC_SPI_START + 51)
95#define SMMU_VPE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 52)
96#define SMMU_VFE_CB_SC_SECURE_IRQ (GIC_SPI_START + 53)
97#define SMMU_VFE_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 54)
98#define SMMU_VCODEC_B_CB_SC_SECURE_IRQ (GIC_SPI_START + 55)
99#define SMMU_VCODEC_B_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 56)
100#define SMMU_VCODEC_A_CB_SC_SECURE_IRQ (GIC_SPI_START + 57)
101#define SMMU_VCODEC_A_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 58)
102#define SMMU_ROT_CB_SC_SECURE_IRQ (GIC_SPI_START + 59)
103#define SMMU_ROT_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 60)
104#define SMMU_MDP1_CB_SC_SECURE_IRQ (GIC_SPI_START + 61)
105#define SMMU_MDP1_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 62)
106#define SMMU_MDP0_CB_SC_SECURE_IRQ (GIC_SPI_START + 63)
107#define SMMU_MDP0_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 64)
108#define SMMU_JPEGD_CB_SC_SECURE_IRQ (GIC_SPI_START + 65)
109#define SMMU_JPEGD_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 66)
110#define SMMU_IJPEG_CB_SC_SECURE_IRQ (GIC_SPI_START + 67)
111#define SMMU_IJPEG_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 68)
112#define SMMU_GFX3D_CB_SC_SECURE_IRQ (GIC_SPI_START + 69)
113#define SMMU_GFX3D_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 70)
114#define SMMU_GFX2D0_CB_SC_SECURE_IRQ (GIC_SPI_START + 71)
115#define SMMU_GFX2D0_CB_SC_NON_SECURE_IRQ (GIC_SPI_START + 72)
116#define ROT_IRQ (GIC_SPI_START + 73)
117#define MMSS_FABRIC_IRQ (GIC_SPI_START + 74)
118#define MDP_IRQ (GIC_SPI_START + 75)
119#define JPEGD_IRQ (GIC_SPI_START + 76)
120#define JPEG_IRQ (GIC_SPI_START + 77)
121#define MMSS_IMEM_IRQ (GIC_SPI_START + 78)
122#define HDMI_IRQ (GIC_SPI_START + 79)
123#define GFX3D_IRQ (GIC_SPI_START + 80)
124#define GFX2D0_IRQ (GIC_SPI_START + 81)
125#define DSI_IRQ (GIC_SPI_START + 82)
126#define CSI_1_IRQ (GIC_SPI_START + 83)
127#define CSI_0_IRQ (GIC_SPI_START + 84)
128#define LPASS_SCSS_AUDIO_IF_OUT0_IRQ (GIC_SPI_START + 85)
129#define LPASS_SCSS_MIDI_IRQ (GIC_SPI_START + 86)
130#define LPASS_Q6SS_WDOG_EXPIRED (GIC_SPI_START + 87)
131#define LPASS_SCSS_GP_LOW_IRQ (GIC_SPI_START + 88)
132#define LPASS_SCSS_GP_MEDIUM_IRQ (GIC_SPI_START + 89)
133#define LPASS_SCSS_GP_HIGH_IRQ (GIC_SPI_START + 90)
134#define TOP_IMEM_IRQ (GIC_SPI_START + 91)
135#define FABRIC_SYS_IRQ (GIC_SPI_START + 92)
136#define FABRIC_APPS_IRQ (GIC_SPI_START + 93)
137#define USB1_HS_BAM_IRQ (GIC_SPI_START + 94)
138#define SDC4_BAM_IRQ (GIC_SPI_START + 95)
139#define SDC3_BAM_IRQ (GIC_SPI_START + 96)
140#define SDC2_BAM_IRQ (GIC_SPI_START + 97)
141#define SDC1_BAM_IRQ (GIC_SPI_START + 98)
142#define FABRIC_SPS_IRQ (GIC_SPI_START + 99)
143#define USB1_HS_IRQ (GIC_SPI_START + 100)
144#define SDC4_IRQ_0 (GIC_SPI_START + 101)
145#define SDC3_IRQ_0 (GIC_SPI_START + 102)
146#define SDC2_IRQ_0 (GIC_SPI_START + 103)
147#define SDC1_IRQ_0 (GIC_SPI_START + 104)
148#define SPS_BAM_DMA_IRQ (GIC_SPI_START + 105)
149#define SPS_SEC_VIOL_IRQ (GIC_SPI_START + 106)
150#define SPS_MTI_0 (GIC_SPI_START + 107)
151#define SPS_MTI_1 (GIC_SPI_START + 108)
152#define SPS_MTI_2 (GIC_SPI_START + 109)
153#define SPS_MTI_3 (GIC_SPI_START + 110)
154#define SPS_MTI_4 (GIC_SPI_START + 111)
155#define SPS_MTI_5 (GIC_SPI_START + 112)
156#define SPS_MTI_6 (GIC_SPI_START + 113)
157#define SPS_MTI_7 (GIC_SPI_START + 114)
158#define SPS_MTI_8 (GIC_SPI_START + 115)
159#define SPS_MTI_9 (GIC_SPI_START + 116)
160#define SPS_MTI_10 (GIC_SPI_START + 117)
161#define SPS_MTI_11 (GIC_SPI_START + 118)
162#define SPS_MTI_12 (GIC_SPI_START + 119)
163#define SPS_MTI_13 (GIC_SPI_START + 120)
164#define SPS_MTI_14 (GIC_SPI_START + 121)
165#define SPS_MTI_15 (GIC_SPI_START + 122)
166#define SPS_MTI_16 (GIC_SPI_START + 123)
167#define SPS_MTI_17 (GIC_SPI_START + 124)
168#define SPS_MTI_18 (GIC_SPI_START + 125)
169#define SPS_MTI_19 (GIC_SPI_START + 126)
170#define SPS_MTI_20 (GIC_SPI_START + 127)
171#define SPS_MTI_21 (GIC_SPI_START + 128)
172#define SPS_MTI_22 (GIC_SPI_START + 129)
173#define SPS_MTI_23 (GIC_SPI_START + 130)
174#define SPS_MTI_24 (GIC_SPI_START + 131)
175#define SPS_MTI_25 (GIC_SPI_START + 132)
176#define SPS_MTI_26 (GIC_SPI_START + 133)
177#define SPS_MTI_27 (GIC_SPI_START + 134)
178#define SPS_MTI_28 (GIC_SPI_START + 135)
179#define SPS_MTI_29 (GIC_SPI_START + 136)
180#define SPS_MTI_30 (GIC_SPI_START + 137)
181#define SPS_MTI_31 (GIC_SPI_START + 138)
182#define UXMC_EBI2_WR_ER_DONE_IRQ (GIC_SPI_START + 139)
183#define UXMC_EBI2_OP_DONE_IRQ (GIC_SPI_START + 140)
184#define USB2_IRQ (GIC_SPI_START + 141)
185#define USB1_IRQ (GIC_SPI_START + 142)
186#define TSSC_SSBI_IRQ (GIC_SPI_START + 143)
187#define TSSC_SAMPLE_IRQ (GIC_SPI_START + 144)
188#define TSSC_PENUP_IRQ (GIC_SPI_START + 145)
189#define INT_UART1DM_IRQ (GIC_SPI_START + 146)
190#define GSBI1_QUP_IRQ (GIC_SPI_START + 147)
191#define INT_UART2DM_IRQ (GIC_SPI_START + 148)
192#define GSBI2_QUP_IRQ (GIC_SPI_START + 149)
193#define INT_UART3DM_IRQ (GIC_SPI_START + 150)
194#define GSBI3_QUP_IRQ (GIC_SPI_START + 151)
195#define INT_UART4DM_IRQ (GIC_SPI_START + 152)
196#define GSBI4_QUP_IRQ (GIC_SPI_START + 153)
197#define INT_UART5DM_IRQ (GIC_SPI_START + 154)
198#define GSBI5_QUP_IRQ (GIC_SPI_START + 155)
199#define INT_UART6DM_IRQ (GIC_SPI_START + 156)
200#define GSBI6_QUP_IRQ (GIC_SPI_START + 157)
201#define INT_UART7DM_IRQ (GIC_SPI_START + 158)
202#define GSBI7_QUP_IRQ (GIC_SPI_START + 159)
203#define INT_UART8DM_IRQ (GIC_SPI_START + 160)
204#define GSBI8_QUP_IRQ (GIC_SPI_START + 161)
205#define TSIF_TSPP_IRQ (GIC_SPI_START + 162)
206#define TSIF_BAM_IRQ (GIC_SPI_START + 163)
207#define TSIF2_IRQ (GIC_SPI_START + 164)
208#define TSIF1_IRQ (GIC_SPI_START + 165)
209#define INT_ADM1_MASTER (GIC_SPI_START + 166)
210#define INT_ADM1_AARM (GIC_SPI_START + 167)
211#define INT_ADM1_SD2 (GIC_SPI_START + 168)
212#define INT_ADM1_SD3 (GIC_SPI_START + 169)
213#define INT_ADM0_MASTER (GIC_SPI_START + 170)
214#define INT_ADM0_AARM (GIC_SPI_START + 171)
215#define INT_ADM0_SD2 (GIC_SPI_START + 172)
216#define INT_ADM0_SD3 (GIC_SPI_START + 173)
217#define CC_SCSS_WDT1CPU1BITEEXPIRED (GIC_SPI_START + 174)
218#define CC_SCSS_WDT1CPU0BITEEXPIRED (GIC_SPI_START + 175)
219#define CC_SCSS_WDT0CPU1BITEEXPIRED (GIC_SPI_START + 176)
220#define CC_SCSS_WDT0CPU0BITEEXPIRED (GIC_SPI_START + 177)
221#define TSENS_UPPER_LOWER_INT (GIC_SPI_START + 178)
222#define SSBI2_2_SC_CPU1_SECURE_INT (GIC_SPI_START + 179)
223#define SSBI2_2_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 180)
224#define SSBI2_1_SC_CPU1_SECURE_INT (GIC_SPI_START + 181)
225#define SSBI2_1_SC_CPU1_NON_SECURE_INT (GIC_SPI_START + 182)
226#define XPU_SUMMARY_IRQ (GIC_SPI_START + 183)
227#define BUS_EXCEPTION_SUMMARY_IRQ (GIC_SPI_START + 184)
228#define HSDDRX_SMICH0_IRQ (GIC_SPI_START + 185)
229#define HSDDRX_EBI1_IRQ (GIC_SPI_START + 186)
230#define SDC5_BAM_IRQ (GIC_SPI_START + 187)
231#define SDC5_IRQ_0 (GIC_SPI_START + 188)
232#define INT_UART9DM_IRQ (GIC_SPI_START + 189)
233#define GSBI9_QUP_IRQ (GIC_SPI_START + 190)
234#define INT_UART10DM_IRQ (GIC_SPI_START + 191)
235#define GSBI10_QUP_IRQ (GIC_SPI_START + 192)
236#define INT_UART11DM_IRQ (GIC_SPI_START + 193)
237#define GSBI11_QUP_IRQ (GIC_SPI_START + 194)
238#define INT_UART12DM_IRQ (GIC_SPI_START + 195)
239#define GSBI12_QUP_IRQ (GIC_SPI_START + 196)
240/*SPI 197 to 216 arent used in 8x60*/
241#define SMPSS_SPARE_1 (GIC_SPI_START + 217)
242#define SMPSS_SPARE_2 (GIC_SPI_START + 218)
243#define SMPSS_SPARE_3 (GIC_SPI_START + 219)
244#define SMPSS_SPARE_4 (GIC_SPI_START + 220)
245#define SMPSS_SPARE_5 (GIC_SPI_START + 221)
246#define SMPSS_SPARE_6 (GIC_SPI_START + 222)
247#define SMPSS_SPARE_7 (GIC_SPI_START + 223)
248
249#define NR_GPIO_IRQS 173
250#define NR_MSM_IRQS 256
251#define NR_BOARD_IRQS 0
252
253#endif
diff --git a/arch/arm/mach-msm/include/mach/irqs.h b/arch/arm/mach-msm/include/mach/irqs.h
index 164d355c96ea..8679a4564744 100644
--- a/arch/arm/mach-msm/include/mach/irqs.h
+++ b/arch/arm/mach-msm/include/mach/irqs.h
@@ -24,6 +24,8 @@
24#elif defined(CONFIG_ARCH_QSD8X50) 24#elif defined(CONFIG_ARCH_QSD8X50)
25#include "irqs-8x50.h" 25#include "irqs-8x50.h"
26#include "sirc.h" 26#include "sirc.h"
27#elif defined(CONFIG_ARCH_MSM8X60)
28#include "irqs-8x60.h"
27#elif defined(CONFIG_ARCH_MSM_ARM11) 29#elif defined(CONFIG_ARCH_MSM_ARM11)
28#include "irqs-7x00.h" 30#include "irqs-7x00.h"
29#else 31#else
diff --git a/arch/arm/mach-msm/include/mach/memory.h b/arch/arm/mach-msm/include/mach/memory.h
index 50c7847e6002..070e17d237f1 100644
--- a/arch/arm/mach-msm/include/mach/memory.h
+++ b/arch/arm/mach-msm/include/mach/memory.h
@@ -23,6 +23,8 @@
23#define PHYS_OFFSET UL(0x20000000) 23#define PHYS_OFFSET UL(0x20000000)
24#elif defined(CONFIG_ARCH_MSM7X30) 24#elif defined(CONFIG_ARCH_MSM7X30)
25#define PHYS_OFFSET UL(0x00200000) 25#define PHYS_OFFSET UL(0x00200000)
26#elif defined(CONFIG_ARCH_MSM8X60)
27#define PHYS_OFFSET UL(0x40200000)
26#else 28#else
27#define PHYS_OFFSET UL(0x10000000) 29#define PHYS_OFFSET UL(0x10000000)
28#endif 30#endif
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h b/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h
new file mode 100644
index 000000000000..45bab50e3ee6
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/msm_iomap-8x60.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) 2007 Google, Inc.
3 * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 *
16 * The MSM peripherals are spread all over across 768MB of physical
17 * space, which makes just having a simple IO_ADDRESS macro to slide
18 * them into the right virtual location rough. Instead, we will
19 * provide a master phys->virt mapping for peripherals here.
20 *
21 */
22
23#ifndef __ASM_ARCH_MSM_IOMAP_8X60_H
24#define __ASM_ARCH_MSM_IOMAP_8X60_H
25
26/* Physical base address and size of peripherals.
27 * Ordered by the virtual base addresses they will be mapped at.
28 *
29 * MSM_VIC_BASE must be an value that can be loaded via a "mov"
30 * instruction, otherwise entry-macro.S will not compile.
31 *
32 * If you add or remove entries here, you'll want to edit the
33 * msm_io_desc array in arch/arm/mach-msm/io.c to reflect your
34 * changes.
35 *
36 */
37
38#define MSM_QGIC_DIST_BASE IOMEM(0xF0000000)
39#define MSM_QGIC_DIST_PHYS 0x02080000
40#define MSM_QGIC_DIST_SIZE SZ_4K
41
42#define MSM_QGIC_CPU_BASE IOMEM(0xF0001000)
43#define MSM_QGIC_CPU_PHYS 0x02081000
44#define MSM_QGIC_CPU_SIZE SZ_4K
45
46#define MSM_ACC_BASE IOMEM(0xF0002000)
47#define MSM_ACC_PHYS 0x02001000
48#define MSM_ACC_SIZE SZ_4K
49
50#define MSM_GCC_BASE IOMEM(0xF0003000)
51#define MSM_GCC_PHYS 0x02082000
52#define MSM_GCC_SIZE SZ_4K
53
54#define MSM_TLMM_BASE IOMEM(0xF0004000)
55#define MSM_TLMM_PHYS 0x00800000
56#define MSM_TLMM_SIZE SZ_16K
57
58#define MSM_SHARED_RAM_BASE IOMEM(0xF0100000)
59#define MSM_SHARED_RAM_SIZE SZ_1M
60
61#define MSM_TMR_BASE IOMEM(0xF0200000)
62#define MSM_TMR_PHYS 0x02000000
63#define MSM_TMR_SIZE (SZ_1M)
64
65#define MSM_GPT_BASE (MSM_TMR_BASE + 0x4)
66#define MSM_DGT_BASE (MSM_TMR_BASE + 0x24)
67
68#define MSM_IOMMU_JPEGD_PHYS 0x07300000
69#define MSM_IOMMU_JPEGD_SIZE SZ_1M
70
71#define MSM_IOMMU_VPE_PHYS 0x07400000
72#define MSM_IOMMU_VPE_SIZE SZ_1M
73
74#define MSM_IOMMU_MDP0_PHYS 0x07500000
75#define MSM_IOMMU_MDP0_SIZE SZ_1M
76
77#define MSM_IOMMU_MDP1_PHYS 0x07600000
78#define MSM_IOMMU_MDP1_SIZE SZ_1M
79
80#define MSM_IOMMU_ROT_PHYS 0x07700000
81#define MSM_IOMMU_ROT_SIZE SZ_1M
82
83#define MSM_IOMMU_IJPEG_PHYS 0x07800000
84#define MSM_IOMMU_IJPEG_SIZE SZ_1M
85
86#define MSM_IOMMU_VFE_PHYS 0x07900000
87#define MSM_IOMMU_VFE_SIZE SZ_1M
88
89#define MSM_IOMMU_VCODEC_A_PHYS 0x07A00000
90#define MSM_IOMMU_VCODEC_A_SIZE SZ_1M
91
92#define MSM_IOMMU_VCODEC_B_PHYS 0x07B00000
93#define MSM_IOMMU_VCODEC_B_SIZE SZ_1M
94
95#define MSM_IOMMU_GFX3D_PHYS 0x07C00000
96#define MSM_IOMMU_GFX3D_SIZE SZ_1M
97
98#define MSM_IOMMU_GFX2D0_PHYS 0x07D00000
99#define MSM_IOMMU_GFX2D0_SIZE SZ_1M
100
101#endif
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap.h b/arch/arm/mach-msm/include/mach/msm_iomap.h
index e6b1821cc4ea..8e24dd812139 100644
--- a/arch/arm/mach-msm/include/mach/msm_iomap.h
+++ b/arch/arm/mach-msm/include/mach/msm_iomap.h
@@ -47,8 +47,12 @@
47#include "msm_iomap-7x30.h" 47#include "msm_iomap-7x30.h"
48#elif defined(CONFIG_ARCH_QSD8X50) 48#elif defined(CONFIG_ARCH_QSD8X50)
49#include "msm_iomap-8x50.h" 49#include "msm_iomap-8x50.h"
50#elif defined(CONFIG_ARCH_MSM8X60)
51#include "msm_iomap-8x60.h"
50#else 52#else
51#include "msm_iomap-7x00.h" 53#include "msm_iomap-7x00.h"
52#endif 54#endif
53 55
56
57
54#endif 58#endif
diff --git a/arch/arm/mach-msm/include/mach/smp.h b/arch/arm/mach-msm/include/mach/smp.h
new file mode 100644
index 000000000000..3ff7bf5e679e
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/smp.h
@@ -0,0 +1,39 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of Code Aurora nor
11 * the names of its contributors may be used to endorse or promote
12 * products derived from this software without specific prior written
13 * permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29#ifndef __ASM_ARCH_MSM_SMP_H
30#define __ASM_ARCH_MSM_SMP_H
31
32#include <asm/hardware/gic.h>
33
34static inline void smp_cross_call(const struct cpumask *mask)
35{
36 gic_raise_softirq(mask, 1);
37}
38
39#endif
diff --git a/arch/arm/mach-msm/include/mach/vmalloc.h b/arch/arm/mach-msm/include/mach/vmalloc.h
index 05f81fd8623c..31a32ad062dc 100644
--- a/arch/arm/mach-msm/include/mach/vmalloc.h
+++ b/arch/arm/mach-msm/include/mach/vmalloc.h
@@ -16,7 +16,7 @@
16#ifndef __ASM_ARCH_MSM_VMALLOC_H 16#ifndef __ASM_ARCH_MSM_VMALLOC_H
17#define __ASM_ARCH_MSM_VMALLOC_H 17#define __ASM_ARCH_MSM_VMALLOC_H
18 18
19#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 19#define VMALLOC_END 0xd0000000
20 20
21#endif 21#endif
22 22
diff --git a/arch/arm/mach-msm/io.c b/arch/arm/mach-msm/io.c
index 1c05060b5f3b..d36b61074146 100644
--- a/arch/arm/mach-msm/io.c
+++ b/arch/arm/mach-msm/io.c
@@ -100,6 +100,21 @@ void __init msm_map_qsd8x50_io(void)
100} 100}
101#endif /* CONFIG_ARCH_QSD8X50 */ 101#endif /* CONFIG_ARCH_QSD8X50 */
102 102
103#ifdef CONFIG_ARCH_MSM8X60
104static struct map_desc msm8x60_io_desc[] __initdata = {
105 MSM_DEVICE(QGIC_DIST),
106 MSM_DEVICE(QGIC_CPU),
107 MSM_DEVICE(TMR),
108 MSM_DEVICE(ACC),
109 MSM_DEVICE(GCC),
110};
111
112void __init msm_map_msm8x60_io(void)
113{
114 iotable_init(msm8x60_io_desc, ARRAY_SIZE(msm8x60_io_desc));
115}
116#endif /* CONFIG_ARCH_MSM8X60 */
117
103#ifdef CONFIG_ARCH_MSM7X30 118#ifdef CONFIG_ARCH_MSM7X30
104static struct map_desc msm7x30_io_desc[] __initdata = { 119static struct map_desc msm7x30_io_desc[] __initdata = {
105 MSM_DEVICE(VIC), 120 MSM_DEVICE(VIC),
diff --git a/arch/arm/mach-msm/iommu.c b/arch/arm/mach-msm/iommu.c
new file mode 100644
index 000000000000..f71747db3bee
--- /dev/null
+++ b/arch/arm/mach-msm/iommu.c
@@ -0,0 +1,597 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/platform_device.h>
22#include <linux/errno.h>
23#include <linux/io.h>
24#include <linux/interrupt.h>
25#include <linux/list.h>
26#include <linux/spinlock.h>
27#include <linux/slab.h>
28#include <linux/iommu.h>
29
30#include <asm/cacheflush.h>
31#include <asm/sizes.h>
32
33#include <mach/iommu_hw-8xxx.h>
34#include <mach/iommu.h>
35
36DEFINE_SPINLOCK(msm_iommu_lock);
37
38struct msm_priv {
39 unsigned long *pgtable;
40 struct list_head list_attached;
41};
42
43static void __flush_iotlb(struct iommu_domain *domain)
44{
45 struct msm_priv *priv = domain->priv;
46 struct msm_iommu_drvdata *iommu_drvdata;
47 struct msm_iommu_ctx_drvdata *ctx_drvdata;
48
49#ifndef CONFIG_IOMMU_PGTABLES_L2
50 unsigned long *fl_table = priv->pgtable;
51 int i;
52
53 dmac_flush_range(fl_table, fl_table + SZ_16K);
54
55 for (i = 0; i < NUM_FL_PTE; i++)
56 if ((fl_table[i] & 0x03) == FL_TYPE_TABLE) {
57 void *sl_table = __va(fl_table[i] & FL_BASE_MASK);
58 dmac_flush_range(sl_table, sl_table + SZ_4K);
59 }
60#endif
61
62 list_for_each_entry(ctx_drvdata, &priv->list_attached, attached_elm) {
63 if (!ctx_drvdata->pdev || !ctx_drvdata->pdev->dev.parent)
64 BUG();
65
66 iommu_drvdata = dev_get_drvdata(ctx_drvdata->pdev->dev.parent);
67 SET_CTX_TLBIALL(iommu_drvdata->base, ctx_drvdata->num, 0);
68 }
69}
70
71static void __reset_context(void __iomem *base, int ctx)
72{
73 SET_BPRCOSH(base, ctx, 0);
74 SET_BPRCISH(base, ctx, 0);
75 SET_BPRCNSH(base, ctx, 0);
76 SET_BPSHCFG(base, ctx, 0);
77 SET_BPMTCFG(base, ctx, 0);
78 SET_ACTLR(base, ctx, 0);
79 SET_SCTLR(base, ctx, 0);
80 SET_FSRRESTORE(base, ctx, 0);
81 SET_TTBR0(base, ctx, 0);
82 SET_TTBR1(base, ctx, 0);
83 SET_TTBCR(base, ctx, 0);
84 SET_BFBCR(base, ctx, 0);
85 SET_PAR(base, ctx, 0);
86 SET_FAR(base, ctx, 0);
87 SET_CTX_TLBIALL(base, ctx, 0);
88 SET_TLBFLPTER(base, ctx, 0);
89 SET_TLBSLPTER(base, ctx, 0);
90 SET_TLBLKCR(base, ctx, 0);
91 SET_PRRR(base, ctx, 0);
92 SET_NMRR(base, ctx, 0);
93 SET_CONTEXTIDR(base, ctx, 0);
94}
95
96static void __program_context(void __iomem *base, int ctx, phys_addr_t pgtable)
97{
98 __reset_context(base, ctx);
99
100 /* Set up HTW mode */
101 /* TLB miss configuration: perform HTW on miss */
102 SET_TLBMCFG(base, ctx, 0x3);
103
104 /* V2P configuration: HTW for access */
105 SET_V2PCFG(base, ctx, 0x3);
106
107 SET_TTBCR(base, ctx, 0);
108 SET_TTBR0_PA(base, ctx, (pgtable >> 14));
109
110 /* Invalidate the TLB for this context */
111 SET_CTX_TLBIALL(base, ctx, 0);
112
113 /* Set interrupt number to "secure" interrupt */
114 SET_IRPTNDX(base, ctx, 0);
115
116 /* Enable context fault interrupt */
117 SET_CFEIE(base, ctx, 1);
118
119 /* Stall access on a context fault and let the handler deal with it */
120 SET_CFCFG(base, ctx, 1);
121
122 /* Redirect all cacheable requests to L2 slave port. */
123 SET_RCISH(base, ctx, 1);
124 SET_RCOSH(base, ctx, 1);
125 SET_RCNSH(base, ctx, 1);
126
127 /* Turn on TEX Remap */
128 SET_TRE(base, ctx, 1);
129
130 /* Do not configure PRRR / NMRR on the IOMMU for now. We will assume
131 * TEX class 0 for everything until attributes are properly worked out
132 */
133 SET_PRRR(base, ctx, 0);
134 SET_NMRR(base, ctx, 0);
135
136 /* Turn on BFB prefetch */
137 SET_BFBDFE(base, ctx, 1);
138
139#ifdef CONFIG_IOMMU_PGTABLES_L2
140 /* Configure page tables as inner-cacheable and shareable to reduce
141 * the TLB miss penalty.
142 */
143 SET_TTBR0_SH(base, ctx, 1);
144 SET_TTBR1_SH(base, ctx, 1);
145
146 SET_TTBR0_NOS(base, ctx, 1);
147 SET_TTBR1_NOS(base, ctx, 1);
148
149 SET_TTBR0_IRGNH(base, ctx, 0); /* WB, WA */
150 SET_TTBR0_IRGNL(base, ctx, 1);
151
152 SET_TTBR1_IRGNH(base, ctx, 0); /* WB, WA */
153 SET_TTBR1_IRGNL(base, ctx, 1);
154
155 SET_TTBR0_ORGN(base, ctx, 1); /* WB, WA */
156 SET_TTBR1_ORGN(base, ctx, 1); /* WB, WA */
157#endif
158
159 /* Enable the MMU */
160 SET_M(base, ctx, 1);
161}
162
163static int msm_iommu_domain_init(struct iommu_domain *domain)
164{
165 struct msm_priv *priv = kzalloc(sizeof(*priv), GFP_KERNEL);
166
167 if (!priv)
168 goto fail_nomem;
169
170 INIT_LIST_HEAD(&priv->list_attached);
171 priv->pgtable = (unsigned long *)__get_free_pages(GFP_KERNEL,
172 get_order(SZ_16K));
173
174 if (!priv->pgtable)
175 goto fail_nomem;
176
177 memset(priv->pgtable, 0, SZ_16K);
178 domain->priv = priv;
179 return 0;
180
181fail_nomem:
182 kfree(priv);
183 return -ENOMEM;
184}
185
186static void msm_iommu_domain_destroy(struct iommu_domain *domain)
187{
188 struct msm_priv *priv;
189 unsigned long flags;
190 unsigned long *fl_table;
191 int i;
192
193 spin_lock_irqsave(&msm_iommu_lock, flags);
194 priv = domain->priv;
195 domain->priv = NULL;
196
197 if (priv) {
198 fl_table = priv->pgtable;
199
200 for (i = 0; i < NUM_FL_PTE; i++)
201 if ((fl_table[i] & 0x03) == FL_TYPE_TABLE)
202 free_page((unsigned long) __va(((fl_table[i]) &
203 FL_BASE_MASK)));
204
205 free_pages((unsigned long)priv->pgtable, get_order(SZ_16K));
206 priv->pgtable = NULL;
207 }
208
209 kfree(priv);
210 spin_unlock_irqrestore(&msm_iommu_lock, flags);
211}
212
213static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
214{
215 struct msm_priv *priv;
216 struct msm_iommu_ctx_dev *ctx_dev;
217 struct msm_iommu_drvdata *iommu_drvdata;
218 struct msm_iommu_ctx_drvdata *ctx_drvdata;
219 struct msm_iommu_ctx_drvdata *tmp_drvdata;
220 int ret = 0;
221 unsigned long flags;
222
223 spin_lock_irqsave(&msm_iommu_lock, flags);
224
225 priv = domain->priv;
226
227 if (!priv || !dev) {
228 ret = -EINVAL;
229 goto fail;
230 }
231
232 iommu_drvdata = dev_get_drvdata(dev->parent);
233 ctx_drvdata = dev_get_drvdata(dev);
234 ctx_dev = dev->platform_data;
235
236 if (!iommu_drvdata || !ctx_drvdata || !ctx_dev) {
237 ret = -EINVAL;
238 goto fail;
239 }
240
241 list_for_each_entry(tmp_drvdata, &priv->list_attached, attached_elm)
242 if (tmp_drvdata == ctx_drvdata) {
243 ret = -EBUSY;
244 goto fail;
245 }
246
247 __program_context(iommu_drvdata->base, ctx_dev->num,
248 __pa(priv->pgtable));
249
250 list_add(&(ctx_drvdata->attached_elm), &priv->list_attached);
251 __flush_iotlb(domain);
252
253fail:
254 spin_unlock_irqrestore(&msm_iommu_lock, flags);
255 return ret;
256}
257
258static void msm_iommu_detach_dev(struct iommu_domain *domain,
259 struct device *dev)
260{
261 struct msm_priv *priv;
262 struct msm_iommu_ctx_dev *ctx_dev;
263 struct msm_iommu_drvdata *iommu_drvdata;
264 struct msm_iommu_ctx_drvdata *ctx_drvdata;
265 unsigned long flags;
266
267 spin_lock_irqsave(&msm_iommu_lock, flags);
268 priv = domain->priv;
269
270 if (!priv || !dev)
271 goto fail;
272
273 iommu_drvdata = dev_get_drvdata(dev->parent);
274 ctx_drvdata = dev_get_drvdata(dev);
275 ctx_dev = dev->platform_data;
276
277 if (!iommu_drvdata || !ctx_drvdata || !ctx_dev)
278 goto fail;
279
280 __flush_iotlb(domain);
281 __reset_context(iommu_drvdata->base, ctx_dev->num);
282 list_del_init(&ctx_drvdata->attached_elm);
283
284fail:
285 spin_unlock_irqrestore(&msm_iommu_lock, flags);
286}
287
288static int msm_iommu_map(struct iommu_domain *domain, unsigned long va,
289 phys_addr_t pa, int order, int prot)
290{
291 struct msm_priv *priv;
292 unsigned long flags;
293 unsigned long *fl_table;
294 unsigned long *fl_pte;
295 unsigned long fl_offset;
296 unsigned long *sl_table;
297 unsigned long *sl_pte;
298 unsigned long sl_offset;
299 size_t len = 0x1000UL << order;
300 int ret = 0;
301
302 spin_lock_irqsave(&msm_iommu_lock, flags);
303 priv = domain->priv;
304
305 if (!priv) {
306 ret = -EINVAL;
307 goto fail;
308 }
309
310 fl_table = priv->pgtable;
311
312 if (len != SZ_16M && len != SZ_1M &&
313 len != SZ_64K && len != SZ_4K) {
314 pr_debug("Bad size: %d\n", len);
315 ret = -EINVAL;
316 goto fail;
317 }
318
319 if (!fl_table) {
320 pr_debug("Null page table\n");
321 ret = -EINVAL;
322 goto fail;
323 }
324
325 fl_offset = FL_OFFSET(va); /* Upper 12 bits */
326 fl_pte = fl_table + fl_offset; /* int pointers, 4 bytes */
327
328 if (len == SZ_16M) {
329 int i = 0;
330 for (i = 0; i < 16; i++)
331 *(fl_pte+i) = (pa & 0xFF000000) | FL_SUPERSECTION |
332 FL_AP_READ | FL_AP_WRITE | FL_TYPE_SECT |
333 FL_SHARED;
334 }
335
336 if (len == SZ_1M)
337 *fl_pte = (pa & 0xFFF00000) | FL_AP_READ | FL_AP_WRITE |
338 FL_TYPE_SECT | FL_SHARED;
339
340 /* Need a 2nd level table */
341 if ((len == SZ_4K || len == SZ_64K) && (*fl_pte) == 0) {
342 unsigned long *sl;
343 sl = (unsigned long *) __get_free_pages(GFP_KERNEL,
344 get_order(SZ_4K));
345
346 if (!sl) {
347 pr_debug("Could not allocate second level table\n");
348 ret = -ENOMEM;
349 goto fail;
350 }
351
352 memset(sl, 0, SZ_4K);
353 *fl_pte = ((((int)__pa(sl)) & FL_BASE_MASK) | FL_TYPE_TABLE);
354 }
355
356 sl_table = (unsigned long *) __va(((*fl_pte) & FL_BASE_MASK));
357 sl_offset = SL_OFFSET(va);
358 sl_pte = sl_table + sl_offset;
359
360
361 if (len == SZ_4K)
362 *sl_pte = (pa & SL_BASE_MASK_SMALL) | SL_AP0 | SL_AP1 |
363 SL_SHARED | SL_TYPE_SMALL;
364
365 if (len == SZ_64K) {
366 int i;
367
368 for (i = 0; i < 16; i++)
369 *(sl_pte+i) = (pa & SL_BASE_MASK_LARGE) | SL_AP0 |
370 SL_AP1 | SL_SHARED | SL_TYPE_LARGE;
371 }
372
373 __flush_iotlb(domain);
374fail:
375 spin_unlock_irqrestore(&msm_iommu_lock, flags);
376 return ret;
377}
378
379static int msm_iommu_unmap(struct iommu_domain *domain, unsigned long va,
380 int order)
381{
382 struct msm_priv *priv;
383 unsigned long flags;
384 unsigned long *fl_table;
385 unsigned long *fl_pte;
386 unsigned long fl_offset;
387 unsigned long *sl_table;
388 unsigned long *sl_pte;
389 unsigned long sl_offset;
390 size_t len = 0x1000UL << order;
391 int i, ret = 0;
392
393 spin_lock_irqsave(&msm_iommu_lock, flags);
394
395 priv = domain->priv;
396
397 if (!priv) {
398 ret = -ENODEV;
399 goto fail;
400 }
401
402 fl_table = priv->pgtable;
403
404 if (len != SZ_16M && len != SZ_1M &&
405 len != SZ_64K && len != SZ_4K) {
406 pr_debug("Bad length: %d\n", len);
407 ret = -EINVAL;
408 goto fail;
409 }
410
411 if (!fl_table) {
412 pr_debug("Null page table\n");
413 ret = -EINVAL;
414 goto fail;
415 }
416
417 fl_offset = FL_OFFSET(va); /* Upper 12 bits */
418 fl_pte = fl_table + fl_offset; /* int pointers, 4 bytes */
419
420 if (*fl_pte == 0) {
421 pr_debug("First level PTE is 0\n");
422 ret = -ENODEV;
423 goto fail;
424 }
425
426 /* Unmap supersection */
427 if (len == SZ_16M)
428 for (i = 0; i < 16; i++)
429 *(fl_pte+i) = 0;
430
431 if (len == SZ_1M)
432 *fl_pte = 0;
433
434 sl_table = (unsigned long *) __va(((*fl_pte) & FL_BASE_MASK));
435 sl_offset = SL_OFFSET(va);
436 sl_pte = sl_table + sl_offset;
437
438 if (len == SZ_64K) {
439 for (i = 0; i < 16; i++)
440 *(sl_pte+i) = 0;
441 }
442
443 if (len == SZ_4K)
444 *sl_pte = 0;
445
446 if (len == SZ_4K || len == SZ_64K) {
447 int used = 0;
448
449 for (i = 0; i < NUM_SL_PTE; i++)
450 if (sl_table[i])
451 used = 1;
452 if (!used) {
453 free_page((unsigned long)sl_table);
454 *fl_pte = 0;
455 }
456 }
457
458 __flush_iotlb(domain);
459fail:
460 spin_unlock_irqrestore(&msm_iommu_lock, flags);
461 return ret;
462}
463
464static phys_addr_t msm_iommu_iova_to_phys(struct iommu_domain *domain,
465 unsigned long va)
466{
467 struct msm_priv *priv;
468 struct msm_iommu_drvdata *iommu_drvdata;
469 struct msm_iommu_ctx_drvdata *ctx_drvdata;
470 unsigned int par;
471 unsigned long flags;
472 void __iomem *base;
473 phys_addr_t ret = 0;
474 int ctx;
475
476 spin_lock_irqsave(&msm_iommu_lock, flags);
477
478 priv = domain->priv;
479 if (list_empty(&priv->list_attached))
480 goto fail;
481
482 ctx_drvdata = list_entry(priv->list_attached.next,
483 struct msm_iommu_ctx_drvdata, attached_elm);
484 iommu_drvdata = dev_get_drvdata(ctx_drvdata->pdev->dev.parent);
485
486 base = iommu_drvdata->base;
487 ctx = ctx_drvdata->num;
488
489 /* Invalidate context TLB */
490 SET_CTX_TLBIALL(base, ctx, 0);
491 SET_V2PPR_VA(base, ctx, va >> V2Pxx_VA_SHIFT);
492
493 if (GET_FAULT(base, ctx))
494 goto fail;
495
496 par = GET_PAR(base, ctx);
497
498 /* We are dealing with a supersection */
499 if (GET_NOFAULT_SS(base, ctx))
500 ret = (par & 0xFF000000) | (va & 0x00FFFFFF);
501 else /* Upper 20 bits from PAR, lower 12 from VA */
502 ret = (par & 0xFFFFF000) | (va & 0x00000FFF);
503
504fail:
505 spin_unlock_irqrestore(&msm_iommu_lock, flags);
506 return ret;
507}
508
509static int msm_iommu_domain_has_cap(struct iommu_domain *domain,
510 unsigned long cap)
511{
512 return 0;
513}
514
515static void print_ctx_regs(void __iomem *base, int ctx)
516{
517 unsigned int fsr = GET_FSR(base, ctx);
518 pr_err("FAR = %08x PAR = %08x\n",
519 GET_FAR(base, ctx), GET_PAR(base, ctx));
520 pr_err("FSR = %08x [%s%s%s%s%s%s%s%s%s%s]\n", fsr,
521 (fsr & 0x02) ? "TF " : "",
522 (fsr & 0x04) ? "AFF " : "",
523 (fsr & 0x08) ? "APF " : "",
524 (fsr & 0x10) ? "TLBMF " : "",
525 (fsr & 0x20) ? "HTWDEEF " : "",
526 (fsr & 0x40) ? "HTWSEEF " : "",
527 (fsr & 0x80) ? "MHF " : "",
528 (fsr & 0x10000) ? "SL " : "",
529 (fsr & 0x40000000) ? "SS " : "",
530 (fsr & 0x80000000) ? "MULTI " : "");
531
532 pr_err("FSYNR0 = %08x FSYNR1 = %08x\n",
533 GET_FSYNR0(base, ctx), GET_FSYNR1(base, ctx));
534 pr_err("TTBR0 = %08x TTBR1 = %08x\n",
535 GET_TTBR0(base, ctx), GET_TTBR1(base, ctx));
536 pr_err("SCTLR = %08x ACTLR = %08x\n",
537 GET_SCTLR(base, ctx), GET_ACTLR(base, ctx));
538 pr_err("PRRR = %08x NMRR = %08x\n",
539 GET_PRRR(base, ctx), GET_NMRR(base, ctx));
540}
541
542irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id)
543{
544 struct msm_iommu_drvdata *drvdata = dev_id;
545 void __iomem *base;
546 unsigned int fsr = 0;
547 int ncb = 0, i = 0;
548
549 spin_lock(&msm_iommu_lock);
550
551 if (!drvdata) {
552 pr_err("Invalid device ID in context interrupt handler\n");
553 goto fail;
554 }
555
556 base = drvdata->base;
557
558 pr_err("===== WOAH! =====\n");
559 pr_err("Unexpected IOMMU page fault!\n");
560 pr_err("base = %08x\n", (unsigned int) base);
561
562 ncb = GET_NCB(base)+1;
563 for (i = 0; i < ncb; i++) {
564 fsr = GET_FSR(base, i);
565 if (fsr) {
566 pr_err("Fault occurred in context %d.\n", i);
567 pr_err("Interesting registers:\n");
568 print_ctx_regs(base, i);
569 SET_FSR(base, i, 0x4000000F);
570 }
571 }
572fail:
573 spin_unlock(&msm_iommu_lock);
574 return 0;
575}
576
577static struct iommu_ops msm_iommu_ops = {
578 .domain_init = msm_iommu_domain_init,
579 .domain_destroy = msm_iommu_domain_destroy,
580 .attach_dev = msm_iommu_attach_dev,
581 .detach_dev = msm_iommu_detach_dev,
582 .map = msm_iommu_map,
583 .unmap = msm_iommu_unmap,
584 .iova_to_phys = msm_iommu_iova_to_phys,
585 .domain_has_cap = msm_iommu_domain_has_cap
586};
587
588static int msm_iommu_init(void)
589{
590 register_iommu(&msm_iommu_ops);
591 return 0;
592}
593
594subsys_initcall(msm_iommu_init);
595
596MODULE_LICENSE("GPL v2");
597MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");
diff --git a/arch/arm/mach-msm/iommu_dev.c b/arch/arm/mach-msm/iommu_dev.c
new file mode 100644
index 000000000000..c33ae786c41f
--- /dev/null
+++ b/arch/arm/mach-msm/iommu_dev.c
@@ -0,0 +1,374 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/io.h>
24#include <linux/clk.h>
25#include <linux/iommu.h>
26#include <linux/interrupt.h>
27#include <linux/err.h>
28#include <linux/slab.h>
29
30#include <mach/iommu_hw-8xxx.h>
31#include <mach/iommu.h>
32
33struct iommu_ctx_iter_data {
34 /* input */
35 const char *name;
36
37 /* output */
38 struct device *dev;
39};
40
41static struct platform_device *msm_iommu_root_dev;
42
43static int each_iommu_ctx(struct device *dev, void *data)
44{
45 struct iommu_ctx_iter_data *res = data;
46 struct msm_iommu_ctx_dev *c = dev->platform_data;
47
48 if (!res || !c || !c->name || !res->name)
49 return -EINVAL;
50
51 if (!strcmp(res->name, c->name)) {
52 res->dev = dev;
53 return 1;
54 }
55 return 0;
56}
57
58static int each_iommu(struct device *dev, void *data)
59{
60 return device_for_each_child(dev, data, each_iommu_ctx);
61}
62
63struct device *msm_iommu_get_ctx(const char *ctx_name)
64{
65 struct iommu_ctx_iter_data r;
66 int found;
67
68 if (!msm_iommu_root_dev) {
69 pr_err("No root IOMMU device.\n");
70 goto fail;
71 }
72
73 r.name = ctx_name;
74 found = device_for_each_child(&msm_iommu_root_dev->dev, &r, each_iommu);
75
76 if (!found) {
77 pr_err("Could not find context <%s>\n", ctx_name);
78 goto fail;
79 }
80
81 return r.dev;
82fail:
83 return NULL;
84}
85EXPORT_SYMBOL(msm_iommu_get_ctx);
86
87static void msm_iommu_reset(void __iomem *base)
88{
89 int ctx, ncb;
90
91 SET_RPUE(base, 0);
92 SET_RPUEIE(base, 0);
93 SET_ESRRESTORE(base, 0);
94 SET_TBE(base, 0);
95 SET_CR(base, 0);
96 SET_SPDMBE(base, 0);
97 SET_TESTBUSCR(base, 0);
98 SET_TLBRSW(base, 0);
99 SET_GLOBAL_TLBIALL(base, 0);
100 SET_RPU_ACR(base, 0);
101 SET_TLBLKCRWE(base, 1);
102 ncb = GET_NCB(base)+1;
103
104 for (ctx = 0; ctx < ncb; ctx++) {
105 SET_BPRCOSH(base, ctx, 0);
106 SET_BPRCISH(base, ctx, 0);
107 SET_BPRCNSH(base, ctx, 0);
108 SET_BPSHCFG(base, ctx, 0);
109 SET_BPMTCFG(base, ctx, 0);
110 SET_ACTLR(base, ctx, 0);
111 SET_SCTLR(base, ctx, 0);
112 SET_FSRRESTORE(base, ctx, 0);
113 SET_TTBR0(base, ctx, 0);
114 SET_TTBR1(base, ctx, 0);
115 SET_TTBCR(base, ctx, 0);
116 SET_BFBCR(base, ctx, 0);
117 SET_PAR(base, ctx, 0);
118 SET_FAR(base, ctx, 0);
119 SET_CTX_TLBIALL(base, ctx, 0);
120 SET_TLBFLPTER(base, ctx, 0);
121 SET_TLBSLPTER(base, ctx, 0);
122 SET_TLBLKCR(base, ctx, 0);
123 SET_PRRR(base, ctx, 0);
124 SET_NMRR(base, ctx, 0);
125 SET_CONTEXTIDR(base, ctx, 0);
126 }
127}
128
129static int msm_iommu_probe(struct platform_device *pdev)
130{
131 struct resource *r;
132 struct clk *iommu_clk;
133 struct msm_iommu_drvdata *drvdata;
134 struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data;
135 void __iomem *regs_base;
136 resource_size_t len;
137 int ret = 0, ncb, nm2v, irq;
138
139 if (pdev->id != -1) {
140 drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
141
142 if (!drvdata) {
143 ret = -ENOMEM;
144 goto fail;
145 }
146
147 if (!iommu_dev) {
148 ret = -ENODEV;
149 goto fail;
150 }
151
152 if (iommu_dev->clk_rate != 0) {
153 iommu_clk = clk_get(&pdev->dev, "iommu_clk");
154
155 if (IS_ERR(iommu_clk)) {
156 ret = -ENODEV;
157 goto fail;
158 }
159
160 if (iommu_dev->clk_rate > 0) {
161 ret = clk_set_rate(iommu_clk,
162 iommu_dev->clk_rate);
163 if (ret) {
164 clk_put(iommu_clk);
165 goto fail;
166 }
167 }
168
169 ret = clk_enable(iommu_clk);
170 if (ret) {
171 clk_put(iommu_clk);
172 goto fail;
173 }
174 clk_put(iommu_clk);
175 }
176
177 r = platform_get_resource_byname(pdev, IORESOURCE_MEM,
178 "physbase");
179 if (!r) {
180 ret = -ENODEV;
181 goto fail;
182 }
183
184 len = r->end - r->start + 1;
185
186 r = request_mem_region(r->start, len, r->name);
187 if (!r) {
188 pr_err("Could not request memory region: "
189 "start=%p, len=%d\n", (void *) r->start, len);
190 ret = -EBUSY;
191 goto fail;
192 }
193
194 regs_base = ioremap(r->start, len);
195
196 if (!regs_base) {
197 pr_err("Could not ioremap: start=%p, len=%d\n",
198 (void *) r->start, len);
199 ret = -EBUSY;
200 goto fail;
201 }
202
203 irq = platform_get_irq_byname(pdev, "secure_irq");
204 if (irq < 0) {
205 ret = -ENODEV;
206 goto fail;
207 }
208
209 mb();
210
211 if (GET_IDR(regs_base) == 0) {
212 pr_err("Invalid IDR value detected\n");
213 ret = -ENODEV;
214 goto fail;
215 }
216
217 ret = request_irq(irq, msm_iommu_fault_handler, 0,
218 "msm_iommu_secure_irpt_handler", drvdata);
219 if (ret) {
220 pr_err("Request IRQ %d failed with ret=%d\n", irq, ret);
221 goto fail;
222 }
223
224 msm_iommu_reset(regs_base);
225 drvdata->base = regs_base;
226 drvdata->irq = irq;
227
228 nm2v = GET_NM2VCBMT((unsigned long) regs_base);
229 ncb = GET_NCB((unsigned long) regs_base);
230
231 pr_info("device %s mapped at %p, irq %d with %d ctx banks\n",
232 iommu_dev->name, regs_base, irq, ncb+1);
233
234 platform_set_drvdata(pdev, drvdata);
235 } else
236 msm_iommu_root_dev = pdev;
237
238 return 0;
239
240fail:
241 kfree(drvdata);
242 return ret;
243}
244
245static int msm_iommu_remove(struct platform_device *pdev)
246{
247 struct msm_iommu_drvdata *drv = NULL;
248
249 drv = platform_get_drvdata(pdev);
250 if (drv) {
251 memset(drv, 0, sizeof(struct msm_iommu_drvdata));
252 kfree(drv);
253 platform_set_drvdata(pdev, NULL);
254 }
255 return 0;
256}
257
258static int msm_iommu_ctx_probe(struct platform_device *pdev)
259{
260 struct msm_iommu_ctx_dev *c = pdev->dev.platform_data;
261 struct msm_iommu_drvdata *drvdata;
262 struct msm_iommu_ctx_drvdata *ctx_drvdata = NULL;
263 int i, ret = 0;
264 if (!c || !pdev->dev.parent) {
265 ret = -EINVAL;
266 goto fail;
267 }
268
269 drvdata = dev_get_drvdata(pdev->dev.parent);
270
271 if (!drvdata) {
272 ret = -ENODEV;
273 goto fail;
274 }
275
276 ctx_drvdata = kzalloc(sizeof(*ctx_drvdata), GFP_KERNEL);
277 if (!ctx_drvdata) {
278 ret = -ENOMEM;
279 goto fail;
280 }
281 ctx_drvdata->num = c->num;
282 ctx_drvdata->pdev = pdev;
283
284 INIT_LIST_HEAD(&ctx_drvdata->attached_elm);
285 platform_set_drvdata(pdev, ctx_drvdata);
286
287 /* Program the M2V tables for this context */
288 for (i = 0; i < MAX_NUM_MIDS; i++) {
289 int mid = c->mids[i];
290 if (mid == -1)
291 break;
292
293 SET_M2VCBR_N(drvdata->base, mid, 0);
294 SET_CBACR_N(drvdata->base, c->num, 0);
295
296 /* Set VMID = MID */
297 SET_VMID(drvdata->base, mid, mid);
298
299 /* Set the context number for that MID to this context */
300 SET_CBNDX(drvdata->base, mid, c->num);
301
302 /* Set MID associated with this context bank */
303 SET_CBVMID(drvdata->base, c->num, mid);
304
305 /* Set security bit override to be Non-secure */
306 SET_NSCFG(drvdata->base, mid, 3);
307 }
308
309 pr_info("context device %s with bank index %d\n", c->name, c->num);
310
311 return 0;
312fail:
313 kfree(ctx_drvdata);
314 return ret;
315}
316
317static int msm_iommu_ctx_remove(struct platform_device *pdev)
318{
319 struct msm_iommu_ctx_drvdata *drv = NULL;
320 drv = platform_get_drvdata(pdev);
321 if (drv) {
322 memset(drv, 0, sizeof(struct msm_iommu_ctx_drvdata));
323 kfree(drv);
324 platform_set_drvdata(pdev, NULL);
325 }
326 return 0;
327}
328
329static struct platform_driver msm_iommu_driver = {
330 .driver = {
331 .name = "msm_iommu",
332 },
333 .probe = msm_iommu_probe,
334 .remove = msm_iommu_remove,
335};
336
337static struct platform_driver msm_iommu_ctx_driver = {
338 .driver = {
339 .name = "msm_iommu_ctx",
340 },
341 .probe = msm_iommu_ctx_probe,
342 .remove = msm_iommu_ctx_remove,
343};
344
345static int msm_iommu_driver_init(void)
346{
347 int ret;
348 ret = platform_driver_register(&msm_iommu_driver);
349 if (ret != 0) {
350 pr_err("Failed to register IOMMU driver\n");
351 goto error;
352 }
353
354 ret = platform_driver_register(&msm_iommu_ctx_driver);
355 if (ret != 0) {
356 pr_err("Failed to register IOMMU context driver\n");
357 goto error;
358 }
359
360error:
361 return ret;
362}
363
364static void msm_iommu_driver_exit(void)
365{
366 platform_driver_unregister(&msm_iommu_ctx_driver);
367 platform_driver_unregister(&msm_iommu_driver);
368}
369
370subsys_initcall(msm_iommu_driver_init);
371module_exit(msm_iommu_driver_exit);
372
373MODULE_LICENSE("GPL v2");
374MODULE_AUTHOR("Stepan Moskovchenko <stepanm@codeaurora.org>");
diff --git a/arch/arm/mach-msm/last_radio_log.c b/arch/arm/mach-msm/last_radio_log.c
index b64ba5a98686..1e243f46a969 100644
--- a/arch/arm/mach-msm/last_radio_log.c
+++ b/arch/arm/mach-msm/last_radio_log.c
@@ -48,7 +48,8 @@ static ssize_t last_radio_log_read(struct file *file, char __user *buf,
48} 48}
49 49
50static struct file_operations last_radio_log_fops = { 50static struct file_operations last_radio_log_fops = {
51 .read = last_radio_log_read 51 .read = last_radio_log_read,
52 .llseek = default_llseek,
52}; 53};
53 54
54void msm_init_last_radio_log(struct module *owner) 55void msm_init_last_radio_log(struct module *owner)
diff --git a/arch/arm/mach-msm/smd_debug.c b/arch/arm/mach-msm/smd_debug.c
index 3b2dd717b788..f91c3b7bc655 100644
--- a/arch/arm/mach-msm/smd_debug.c
+++ b/arch/arm/mach-msm/smd_debug.c
@@ -212,6 +212,7 @@ static int debug_open(struct inode *inode, struct file *file)
212static const struct file_operations debug_ops = { 212static const struct file_operations debug_ops = {
213 .read = debug_read, 213 .read = debug_read,
214 .open = debug_open, 214 .open = debug_open,
215 .llseek = default_llseek,
215}; 216};
216 217
217static void debug_create(const char *name, mode_t mode, 218static void debug_create(const char *name, mode_t mode,
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index dec5ca622d7d..7689848ec680 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -28,7 +28,6 @@
28#ifndef MSM_DGT_BASE 28#ifndef MSM_DGT_BASE
29#define MSM_DGT_BASE (MSM_GPT_BASE + 0x10) 29#define MSM_DGT_BASE (MSM_GPT_BASE + 0x10)
30#endif 30#endif
31#define MSM_DGT_SHIFT (5)
32 31
33#define TIMER_MATCH_VAL 0x0000 32#define TIMER_MATCH_VAL 0x0000
34#define TIMER_COUNT_VAL 0x0004 33#define TIMER_COUNT_VAL 0x0004
@@ -36,12 +35,28 @@
36#define TIMER_ENABLE_CLR_ON_MATCH_EN 2 35#define TIMER_ENABLE_CLR_ON_MATCH_EN 2
37#define TIMER_ENABLE_EN 1 36#define TIMER_ENABLE_EN 1
38#define TIMER_CLEAR 0x000C 37#define TIMER_CLEAR 0x000C
39 38#define DGT_CLK_CTL 0x0034
39enum {
40 DGT_CLK_CTL_DIV_1 = 0,
41 DGT_CLK_CTL_DIV_2 = 1,
42 DGT_CLK_CTL_DIV_3 = 2,
43 DGT_CLK_CTL_DIV_4 = 3,
44};
40#define CSR_PROTECTION 0x0020 45#define CSR_PROTECTION 0x0020
41#define CSR_PROTECTION_EN 1 46#define CSR_PROTECTION_EN 1
42 47
43#define GPT_HZ 32768 48#define GPT_HZ 32768
49
50#if defined(CONFIG_ARCH_QSD8X50)
51#define DGT_HZ (19200000 / 4) /* 19.2 MHz / 4 by default */
52#define MSM_DGT_SHIFT (0)
53#elif defined(CONFIG_ARCH_MSM7X30) || defined(CONFIG_ARCH_MSM8X60)
54#define DGT_HZ (24576000 / 4) /* 24.576 MHz (LPXO) / 4 by default */
55#define MSM_DGT_SHIFT (0)
56#else
44#define DGT_HZ 19200000 /* 19.2 MHz or 600 KHz after shift */ 57#define DGT_HZ 19200000 /* 19.2 MHz or 600 KHz after shift */
58#define MSM_DGT_SHIFT (5)
59#endif
45 60
46struct msm_clock { 61struct msm_clock {
47 struct clock_event_device clockevent; 62 struct clock_event_device clockevent;
@@ -170,6 +185,10 @@ static void __init msm_timer_init(void)
170 int i; 185 int i;
171 int res; 186 int res;
172 187
188#ifdef CONFIG_ARCH_MSM8X60
189 writel(DGT_CLK_CTL_DIV_4, MSM_TMR_BASE + DGT_CLK_CTL);
190#endif
191
173 for (i = 0; i < ARRAY_SIZE(msm_clocks); i++) { 192 for (i = 0; i < ARRAY_SIZE(msm_clocks); i++) {
174 struct msm_clock *clock = &msm_clocks[i]; 193 struct msm_clock *clock = &msm_clocks[i];
175 struct clock_event_device *ce = &clock->clockevent; 194 struct clock_event_device *ce = &clock->clockevent;
diff --git a/arch/arm/mach-mv78xx0/buffalo-wxl-setup.c b/arch/arm/mach-mv78xx0/buffalo-wxl-setup.c
index 61e5e583603b..29e390e89ff4 100644
--- a/arch/arm/mach-mv78xx0/buffalo-wxl-setup.c
+++ b/arch/arm/mach-mv78xx0/buffalo-wxl-setup.c
@@ -145,8 +145,6 @@ subsys_initcall(wxl_pci_init);
145 145
146MACHINE_START(TERASTATION_WXL, "Buffalo Nas WXL") 146MACHINE_START(TERASTATION_WXL, "Buffalo Nas WXL")
147 /* Maintainer: Sebastien Requiem <sebastien@requiem.fr> */ 147 /* Maintainer: Sebastien Requiem <sebastien@requiem.fr> */
148 .phys_io = MV78XX0_REGS_PHYS_BASE,
149 .io_pg_offst = ((MV78XX0_REGS_VIRT_BASE) >> 18) & 0xfffc,
150 .boot_params = 0x00000100, 148 .boot_params = 0x00000100,
151 .init_machine = wxl_init, 149 .init_machine = wxl_init,
152 .map_io = mv78xx0_map_io, 150 .map_io = mv78xx0_map_io,
diff --git a/arch/arm/mach-mv78xx0/db78x00-bp-setup.c b/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
index efdabe04c69e..207c95e403b9 100644
--- a/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
+++ b/arch/arm/mach-mv78xx0/db78x00-bp-setup.c
@@ -93,8 +93,6 @@ subsys_initcall(db78x00_pci_init);
93 93
94MACHINE_START(DB78X00_BP, "Marvell DB-78x00-BP Development Board") 94MACHINE_START(DB78X00_BP, "Marvell DB-78x00-BP Development Board")
95 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 95 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
96 .phys_io = MV78XX0_REGS_PHYS_BASE,
97 .io_pg_offst = ((MV78XX0_REGS_VIRT_BASE) >> 18) & 0xfffc,
98 .boot_params = 0x00000100, 96 .boot_params = 0x00000100,
99 .init_machine = db78x00_init, 97 .init_machine = db78x00_init,
100 .map_io = mv78xx0_map_io, 98 .map_io = mv78xx0_map_io,
diff --git a/arch/arm/mach-mv78xx0/include/mach/debug-macro.S b/arch/arm/mach-mv78xx0/include/mach/debug-macro.S
index cd81689c4621..04891428e48b 100644
--- a/arch/arm/mach-mv78xx0/include/mach/debug-macro.S
+++ b/arch/arm/mach-mv78xx0/include/mach/debug-macro.S
@@ -8,12 +8,11 @@
8 8
9#include <mach/mv78xx0.h> 9#include <mach/mv78xx0.h>
10 10
11 .macro addruart, rx, tmp 11 .macro addruart, rp, rv
12 mrc p15, 0, \rx, c1, c0 12 ldr \rp, =MV78XX0_REGS_PHYS_BASE
13 tst \rx, #1 @ MMU enabled? 13 ldr \rv, =MV78XX0_REGS_VIRT_BASE
14 ldreq \rx, =MV78XX0_REGS_PHYS_BASE 14 orr \rp, \rp, #0x00012000
15 ldrne \rx, =MV78XX0_REGS_VIRT_BASE 15 orr \rv, \rv, #0x00012000
16 orr \rx, \rx, #0x00012000
17 .endm 16 .endm
18 17
19#define UART_SHIFT 2 18#define UART_SHIFT 2
diff --git a/arch/arm/mach-mv78xx0/rd78x00-masa-setup.c b/arch/arm/mach-mv78xx0/rd78x00-masa-setup.c
index e136b7a03355..3511ad4d973b 100644
--- a/arch/arm/mach-mv78xx0/rd78x00-masa-setup.c
+++ b/arch/arm/mach-mv78xx0/rd78x00-masa-setup.c
@@ -78,8 +78,6 @@ subsys_initcall(rd78x00_pci_init);
78 78
79MACHINE_START(RD78X00_MASA, "Marvell RD-78x00-MASA Development Board") 79MACHINE_START(RD78X00_MASA, "Marvell RD-78x00-MASA Development Board")
80 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 80 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
81 .phys_io = MV78XX0_REGS_PHYS_BASE,
82 .io_pg_offst = ((MV78XX0_REGS_VIRT_BASE) >> 18) & 0xfffc,
83 .boot_params = 0x00000100, 81 .boot_params = 0x00000100,
84 .init_machine = rd78x00_masa_init, 82 .init_machine = rd78x00_masa_init,
85 .map_io = mv78xx0_map_io, 83 .map_io = mv78xx0_map_io,
diff --git a/arch/arm/mach-mx25/Kconfig b/arch/arm/mach-mx25/Kconfig
index c71a7bc19284..aa57e35ce3cd 100644
--- a/arch/arm/mach-mx25/Kconfig
+++ b/arch/arm/mach-mx25/Kconfig
@@ -12,6 +12,8 @@ config MACH_EUKREA_CPUIMX25
12 select IMX_HAVE_PLATFORM_IMX_I2C 12 select IMX_HAVE_PLATFORM_IMX_I2C
13 select IMX_HAVE_PLATFORM_IMX_UART 13 select IMX_HAVE_PLATFORM_IMX_UART
14 select IMX_HAVE_PLATFORM_MXC_NAND 14 select IMX_HAVE_PLATFORM_MXC_NAND
15 select IMX_HAVE_PLATFORM_FLEXCAN
16 select IMX_HAVE_PLATFORM_ESDHC
15 select MXC_ULPI if USB_ULPI 17 select MXC_ULPI if USB_ULPI
16 18
17choice 19choice
@@ -20,8 +22,8 @@ choice
20 default MACH_EUKREA_MBIMXSD25_BASEBOARD 22 default MACH_EUKREA_MBIMXSD25_BASEBOARD
21 23
22config MACH_EUKREA_MBIMXSD25_BASEBOARD 24config MACH_EUKREA_MBIMXSD25_BASEBOARD
23 prompt "Eukrea MBIMXSD development board" 25 bool "Eukrea MBIMXSD development board"
24 bool 26 select IMX_HAVE_PLATFORM_IMX_SSI
25 help 27 help
26 This adds board specific devices that can be found on Eukrea's 28 This adds board specific devices that can be found on Eukrea's
27 MBIMXSD evaluation board. 29 MBIMXSD evaluation board.
diff --git a/arch/arm/mach-mx25/clock.c b/arch/arm/mach-mx25/clock.c
index 40c7cc41cee3..9e4a5578c2fb 100644
--- a/arch/arm/mach-mx25/clock.c
+++ b/arch/arm/mach-mx25/clock.c
@@ -72,7 +72,7 @@ unsigned long get_rate_arm(struct clk *clk)
72 unsigned long rate = get_rate_mpll(); 72 unsigned long rate = get_rate_mpll();
73 73
74 if (cctl & (1 << 14)) 74 if (cctl & (1 << 14))
75 rate = (rate * 3) >> 1; 75 rate = (rate * 3) >> 2;
76 76
77 return rate / ((cctl >> 30) + 1); 77 return rate / ((cctl >> 30) + 1);
78} 78}
@@ -99,7 +99,7 @@ static unsigned long get_rate_per(int per)
99 if (readl(CRM_BASE + 0x64) & (1 << per)) 99 if (readl(CRM_BASE + 0x64) & (1 << per))
100 fref = get_rate_upll(); 100 fref = get_rate_upll();
101 else 101 else
102 fref = get_rate_ipg(NULL); 102 fref = get_rate_ahb(NULL);
103 103
104 return fref / (val + 1); 104 return fref / (val + 1);
105} 105}
@@ -139,6 +139,16 @@ static unsigned long get_rate_lcdc(struct clk *clk)
139 return get_rate_per(7); 139 return get_rate_per(7);
140} 140}
141 141
142static unsigned long get_rate_esdhc1(struct clk *clk)
143{
144 return get_rate_per(3);
145}
146
147static unsigned long get_rate_esdhc2(struct clk *clk)
148{
149 return get_rate_per(4);
150}
151
142static unsigned long get_rate_csi(struct clk *clk) 152static unsigned long get_rate_csi(struct clk *clk)
143{ 153{
144 return get_rate_per(0); 154 return get_rate_per(0);
@@ -213,6 +223,12 @@ DEFINE_CLOCK(ssi2_per_clk, 0, CCM_CGCR0, 14, get_rate_ipg, NULL, NULL);
213DEFINE_CLOCK(cspi1_clk, 0, CCM_CGCR1, 5, get_rate_ipg, NULL, NULL); 223DEFINE_CLOCK(cspi1_clk, 0, CCM_CGCR1, 5, get_rate_ipg, NULL, NULL);
214DEFINE_CLOCK(cspi2_clk, 0, CCM_CGCR1, 6, get_rate_ipg, NULL, NULL); 224DEFINE_CLOCK(cspi2_clk, 0, CCM_CGCR1, 6, get_rate_ipg, NULL, NULL);
215DEFINE_CLOCK(cspi3_clk, 0, CCM_CGCR1, 7, get_rate_ipg, NULL, NULL); 225DEFINE_CLOCK(cspi3_clk, 0, CCM_CGCR1, 7, get_rate_ipg, NULL, NULL);
226DEFINE_CLOCK(esdhc1_ahb_clk, 0, CCM_CGCR0, 21, get_rate_esdhc1, NULL, NULL);
227DEFINE_CLOCK(esdhc1_per_clk, 0, CCM_CGCR0, 3, get_rate_esdhc1, NULL,
228 &esdhc1_ahb_clk);
229DEFINE_CLOCK(esdhc2_ahb_clk, 0, CCM_CGCR0, 22, get_rate_esdhc2, NULL, NULL);
230DEFINE_CLOCK(esdhc2_per_clk, 0, CCM_CGCR0, 4, get_rate_esdhc2, NULL,
231 &esdhc2_ahb_clk);
216DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL, NULL, NULL); 232DEFINE_CLOCK(fec_ahb_clk, 0, CCM_CGCR0, 23, NULL, NULL, NULL);
217DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL, NULL, NULL); 233DEFINE_CLOCK(lcdc_ahb_clk, 0, CCM_CGCR0, 24, NULL, NULL, NULL);
218DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0, 7, NULL, NULL, &lcdc_ahb_clk); 234DEFINE_CLOCK(lcdc_per_clk, 0, CCM_CGCR0, 7, NULL, NULL, &lcdc_ahb_clk);
@@ -238,10 +254,14 @@ DEFINE_CLOCK(lcdc_clk, 0, CCM_CGCR1, 29, get_rate_lcdc, NULL, &lcdc_per_clk);
238DEFINE_CLOCK(wdt_clk, 0, CCM_CGCR2, 19, get_rate_ipg, NULL, NULL); 254DEFINE_CLOCK(wdt_clk, 0, CCM_CGCR2, 19, get_rate_ipg, NULL, NULL);
239DEFINE_CLOCK(ssi1_clk, 0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk); 255DEFINE_CLOCK(ssi1_clk, 0, CCM_CGCR2, 11, get_rate_ssi1, NULL, &ssi1_per_clk);
240DEFINE_CLOCK(ssi2_clk, 1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk); 256DEFINE_CLOCK(ssi2_clk, 1, CCM_CGCR2, 12, get_rate_ssi2, NULL, &ssi2_per_clk);
257DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGCR1, 13, get_rate_esdhc1, NULL,
258 &esdhc1_per_clk);
259DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGCR1, 14, get_rate_esdhc2, NULL,
260 &esdhc2_per_clk);
241DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL); 261DEFINE_CLOCK(audmux_clk, 0, CCM_CGCR1, 0, NULL, NULL, NULL);
242DEFINE_CLOCK(csi_clk, 0, CCM_CGCR1, 4, get_rate_csi, NULL, &csi_per_clk); 262DEFINE_CLOCK(csi_clk, 0, CCM_CGCR1, 4, get_rate_csi, NULL, &csi_per_clk);
243DEFINE_CLOCK(can1_clk, 0, CCM_CGCR1, 2, get_rate_ipg, NULL, NULL); 263DEFINE_CLOCK(can1_clk, 0, CCM_CGCR1, 2, get_rate_ipg, NULL, NULL);
244DEFINE_CLOCK(can2_clk, 0, CCM_CGCR1, 3, get_rate_ipg, NULL, NULL); 264DEFINE_CLOCK(can2_clk, 1, CCM_CGCR1, 3, get_rate_ipg, NULL, NULL);
245 265
246#define _REGISTER_CLOCK(d, n, c) \ 266#define _REGISTER_CLOCK(d, n, c) \
247 { \ 267 { \
@@ -261,9 +281,9 @@ static struct clk_lookup lookups[] = {
261 _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk) 281 _REGISTER_CLOCK("mxc-ehci.2", "usb", usbotg_clk)
262 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk) 282 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usbotg_clk)
263 _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk) 283 _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
264 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk) 284 _REGISTER_CLOCK("imx25-cspi.0", NULL, cspi1_clk)
265 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk) 285 _REGISTER_CLOCK("imx25-cspi.1", NULL, cspi2_clk)
266 _REGISTER_CLOCK("spi_imx.2", NULL, cspi3_clk) 286 _REGISTER_CLOCK("imx25-cspi.2", NULL, cspi3_clk)
267 _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm1_clk) 287 _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm1_clk)
268 _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk) 288 _REGISTER_CLOCK("mxc_pwm.1", NULL, pwm2_clk)
269 _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk) 289 _REGISTER_CLOCK("mxc_pwm.2", NULL, pwm3_clk)
@@ -279,6 +299,8 @@ static struct clk_lookup lookups[] = {
279 _REGISTER_CLOCK("imx-wdt.0", NULL, wdt_clk) 299 _REGISTER_CLOCK("imx-wdt.0", NULL, wdt_clk)
280 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) 300 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
281 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) 301 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
302 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
303 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
282 _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk) 304 _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
283 _REGISTER_CLOCK(NULL, "audmux", audmux_clk) 305 _REGISTER_CLOCK(NULL, "audmux", audmux_clk)
284 _REGISTER_CLOCK("flexcan.0", NULL, can1_clk) 306 _REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
diff --git a/arch/arm/mach-mx25/devices-imx25.h b/arch/arm/mach-mx25/devices-imx25.h
index d86a7c3ca8b0..93afa10b13cf 100644
--- a/arch/arm/mach-mx25/devices-imx25.h
+++ b/arch/arm/mach-mx25/devices-imx25.h
@@ -9,35 +9,46 @@
9#include <mach/mx25.h> 9#include <mach/mx25.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12extern const struct imx_fec_data imx25_fec_data __initconst;
13#define imx25_add_fec(pdata) \
14 imx_add_fec(&imx25_fec_data, pdata)
15
12#define imx25_add_flexcan0(pdata) \ 16#define imx25_add_flexcan0(pdata) \
13 imx_add_flexcan(0, MX25_CAN1_BASE_ADDR, SZ_16K, MX25_INT_CAN1, pdata) 17 imx_add_flexcan(0, MX25_CAN1_BASE_ADDR, SZ_16K, MX25_INT_CAN1, pdata)
14#define imx25_add_flexcan1(pdata) \ 18#define imx25_add_flexcan1(pdata) \
15 imx_add_flexcan(1, MX25_CAN2_BASE_ADDR, SZ_16K, MX25_INT_CAN2, pdata) 19 imx_add_flexcan(1, MX25_CAN2_BASE_ADDR, SZ_16K, MX25_INT_CAN2, pdata)
16 20
17#define imx25_add_imx_i2c0(pdata) \ 21extern const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst;
18 imx_add_imx_i2c(0, MX25_I2C1_BASE_ADDR, SZ_16K, MX25_INT_I2C1, pdata) 22#define imx25_add_imx_i2c(id, pdata) \
19#define imx25_add_imx_i2c1(pdata) \ 23 imx_add_imx_i2c(&imx25_imx_i2c_data[id], pdata)
20 imx_add_imx_i2c(1, MX25_I2C2_BASE_ADDR, SZ_16K, MX25_INT_I2C2, pdata) 24#define imx25_add_imx_i2c0(pdata) imx25_add_imx_i2c(0, pdata)
21#define imx25_add_imx_i2c2(pdata) \ 25#define imx25_add_imx_i2c1(pdata) imx25_add_imx_i2c(1, pdata)
22 imx_add_imx_i2c(2, MX25_I2C3_BASE_ADDR, SZ_16K, MX25_INT_I2C3, pdata) 26#define imx25_add_imx_i2c2(pdata) imx25_add_imx_i2c(2, pdata)
23 27
24#define imx25_add_imx_uart0(pdata) \ 28extern const struct imx_imx_ssi_data imx25_imx_ssi_data[] __initconst;
25 imx_add_imx_uart_1irq(0, MX25_UART1_BASE_ADDR, SZ_16K, MX25_INT_UART1, pdata) 29#define imx25_add_imx_ssi(id, pdata) \
26#define imx25_add_imx_uart1(pdata) \ 30 imx_add_imx_ssi(&imx25_imx_ssi_data[id], pdata)
27 imx_add_imx_uart_1irq(1, MX25_UART2_BASE_ADDR, SZ_16K, MX25_INT_UART2, pdata) 31
28#define imx25_add_imx_uart2(pdata) \ 32extern const struct imx_imx_uart_1irq_data imx25_imx_uart_data[] __initconst;
29 imx_add_imx_uart_1irq(2, MX25_UART3_BASE_ADDR, SZ_16K, MX25_INT_UART3, pdata) 33#define imx25_add_imx_uart(id, pdata) \
30#define imx25_add_imx_uart3(pdata) \ 34 imx_add_imx_uart_1irq(&imx25_imx_uart_data[id], pdata)
31 imx_add_imx_uart_1irq(3, MX25_UART4_BASE_ADDR, SZ_16K, MX25_INT_UART4, pdata) 35#define imx25_add_imx_uart0(pdata) imx25_add_imx_uart(0, pdata)
32#define imx25_add_imx_uart4(pdata) \ 36#define imx25_add_imx_uart1(pdata) imx25_add_imx_uart(1, pdata)
33 imx_add_imx_uart_1irq(4, MX25_UART5_BASE_ADDR, SZ_16K, MX25_INT_UART5, pdata) 37#define imx25_add_imx_uart2(pdata) imx25_add_imx_uart(2, pdata)
38#define imx25_add_imx_uart3(pdata) imx25_add_imx_uart(3, pdata)
39#define imx25_add_imx_uart4(pdata) imx25_add_imx_uart(4, pdata)
34 40
41extern const struct imx_mxc_nand_data imx25_mxc_nand_data __initconst;
35#define imx25_add_mxc_nand(pdata) \ 42#define imx25_add_mxc_nand(pdata) \
36 imx_add_mxc_nand_v21(MX25_NFC_BASE_ADDR, MX25_INT_NANDFC, pdata) 43 imx_add_mxc_nand(&imx25_mxc_nand_data, pdata)
37 44
38#define imx25_add_spi_imx0(pdata) \ 45extern const struct imx_spi_imx_data imx25_spi_imx_data[] __initconst;
39 imx_add_spi_imx(0, MX25_CSPI1_BASE_ADDR, SZ_16K, MX25_INT_CSPI1, pdata) 46#define imx25_add_spi_imx(id, pdata) \
40#define imx25_add_spi_imx1(pdata) \ 47 imx_add_spi_imx(&imx25_spi_imx_data[id], pdata)
41 imx_add_spi_imx(1, MX25_CSPI2_BASE_ADDR, SZ_16K, MX25_INT_CSPI2, pdata) 48#define imx25_add_spi_imx0(pdata) imx25_add_spi_imx(0, pdata)
42#define imx25_add_spi_imx2(pdata) \ 49#define imx25_add_spi_imx1(pdata) imx25_add_spi_imx(1, pdata)
43 imx_add_spi_imx(2, MX25_CSPI3_BASE_ADDR, SZ_16K, MX25_INT_CSPI3, pdata) 50#define imx25_add_spi_imx2(pdata) imx25_add_spi_imx(2, pdata)
51
52extern const struct imx_esdhc_imx_data imx25_esdhc_data[] __initconst;
53#define imx25_add_esdhc(id, pdata) \
54 imx_add_esdhc(&imx25_esdhc_data[id], pdata)
diff --git a/arch/arm/mach-mx25/devices.c b/arch/arm/mach-mx25/devices.c
index 3468eb15b236..1d0eb3e85941 100644
--- a/arch/arm/mach-mx25/devices.c
+++ b/arch/arm/mach-mx25/devices.c
@@ -208,26 +208,6 @@ int __init imx25_register_gpios(void)
208 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); 208 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
209} 209}
210 210
211static struct resource mx25_fec_resources[] = {
212 {
213 .start = MX25_FEC_BASE_ADDR,
214 .end = MX25_FEC_BASE_ADDR + 0xfff,
215 .flags = IORESOURCE_MEM,
216 },
217 {
218 .start = MX25_INT_FEC,
219 .end = MX25_INT_FEC,
220 .flags = IORESOURCE_IRQ,
221 },
222};
223
224struct platform_device mx25_fec_device = {
225 .name = "fec",
226 .id = 0,
227 .num_resources = ARRAY_SIZE(mx25_fec_resources),
228 .resource = mx25_fec_resources,
229};
230
231static struct resource mx25_rtc_resources[] = { 211static struct resource mx25_rtc_resources[] = {
232 { 212 {
233 .start = MX25_DRYICE_BASE_ADDR, 213 .start = MX25_DRYICE_BASE_ADDR,
@@ -305,44 +285,6 @@ struct platform_device mx25_kpp_device = {
305 .resource = mx25_kpp_resources, 285 .resource = mx25_kpp_resources,
306}; 286};
307 287
308static struct resource imx_ssi_resources0[] = {
309 {
310 .start = MX25_SSI1_BASE_ADDR,
311 .end = MX25_SSI1_BASE_ADDR + 0x3fff,
312 .flags = IORESOURCE_MEM,
313 }, {
314 .start = MX25_INT_SSI1,
315 .end = MX25_INT_SSI1,
316 .flags = IORESOURCE_IRQ,
317 },
318};
319
320static struct resource imx_ssi_resources1[] = {
321 {
322 .start = MX25_SSI2_BASE_ADDR,
323 .end = MX25_SSI2_BASE_ADDR + 0x3fff,
324 .flags = IORESOURCE_MEM
325 }, {
326 .start = MX25_INT_SSI2,
327 .end = MX25_INT_SSI2,
328 .flags = IORESOURCE_IRQ,
329 },
330};
331
332struct platform_device imx_ssi_device0 = {
333 .name = "imx-ssi",
334 .id = 0,
335 .num_resources = ARRAY_SIZE(imx_ssi_resources0),
336 .resource = imx_ssi_resources0,
337};
338
339struct platform_device imx_ssi_device1 = {
340 .name = "imx-ssi",
341 .id = 1,
342 .num_resources = ARRAY_SIZE(imx_ssi_resources1),
343 .resource = imx_ssi_resources1,
344};
345
346static struct resource mx25_csi_resources[] = { 288static struct resource mx25_csi_resources[] = {
347 { 289 {
348 .start = MX25_CSI_BASE_ADDR, 290 .start = MX25_CSI_BASE_ADDR,
diff --git a/arch/arm/mach-mx25/devices.h b/arch/arm/mach-mx25/devices.h
index 4aceb68e35a7..7b70a43c3a4b 100644
--- a/arch/arm/mach-mx25/devices.h
+++ b/arch/arm/mach-mx25/devices.h
@@ -6,11 +6,8 @@ extern struct platform_device mxc_pwm_device1;
6extern struct platform_device mxc_pwm_device2; 6extern struct platform_device mxc_pwm_device2;
7extern struct platform_device mxc_pwm_device3; 7extern struct platform_device mxc_pwm_device3;
8extern struct platform_device mxc_keypad_device; 8extern struct platform_device mxc_keypad_device;
9extern struct platform_device mx25_fec_device;
10extern struct platform_device mx25_rtc_device; 9extern struct platform_device mx25_rtc_device;
11extern struct platform_device mx25_fb_device; 10extern struct platform_device mx25_fb_device;
12extern struct platform_device mxc_wdt; 11extern struct platform_device mxc_wdt;
13extern struct platform_device mx25_kpp_device; 12extern struct platform_device mx25_kpp_device;
14extern struct platform_device imx_ssi_device0;
15extern struct platform_device imx_ssi_device1;
16extern struct platform_device mx25_csi_device; 13extern struct platform_device mx25_csi_device;
diff --git a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
index 4aaadc753d3e..e765ac5d9a08 100644
--- a/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx25/eukrea_mbimxsd-baseboard.c
@@ -34,7 +34,6 @@
34#include <mach/mx25.h> 34#include <mach/mx25.h>
35#include <mach/imx-uart.h> 35#include <mach/imx-uart.h>
36#include <mach/imxfb.h> 36#include <mach/imxfb.h>
37#include <mach/ssi.h>
38#include <mach/audmux.h> 37#include <mach/audmux.h>
39 38
40#include "devices-imx25.h" 39#include "devices-imx25.h"
@@ -90,6 +89,9 @@ static struct pad_desc eukrea_mbimxsd_pads[] = {
90 MX25_PAD_KPP_COL2__AUD5_TXC, 89 MX25_PAD_KPP_COL2__AUD5_TXC,
91 MX25_PAD_KPP_COL1__AUD5_RXD, 90 MX25_PAD_KPP_COL1__AUD5_RXD,
92 MX25_PAD_KPP_COL0__AUD5_TXD, 91 MX25_PAD_KPP_COL0__AUD5_TXD,
92 /* CAN */
93 MX25_PAD_GPIO_D__CAN2_RX,
94 MX25_PAD_GPIO_C__CAN2_TX,
93}; 95};
94 96
95#define GPIO_LED1 83 97#define GPIO_LED1 83
@@ -114,6 +116,38 @@ static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
114 }, 116 },
115 .bpp = 16, 117 .bpp = 16,
116 .pcr = 0xCAD08B80, 118 .pcr = 0xCAD08B80,
119 }, {
120 .mode = {
121 .name = "DVI-VGA",
122 .refresh = 60,
123 .xres = 640,
124 .yres = 480,
125 .pixclock = 32000,
126 .hsync_len = 7,
127 .left_margin = 100,
128 .right_margin = 100,
129 .vsync_len = 7,
130 .upper_margin = 7,
131 .lower_margin = 100,
132 },
133 .pcr = 0xFA208B80,
134 .bpp = 16,
135 }, {
136 .mode = {
137 .name = "DVI-SVGA",
138 .refresh = 60,
139 .xres = 800,
140 .yres = 600,
141 .pixclock = 25000,
142 .hsync_len = 7,
143 .left_margin = 75,
144 .right_margin = 75,
145 .vsync_len = 7,
146 .upper_margin = 7,
147 .lower_margin = 75,
148 },
149 .pcr = 0xFA208B80,
150 .bpp = 16,
117 }, 151 },
118}; 152};
119 153
@@ -205,7 +239,8 @@ static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
205 }, 239 },
206}; 240};
207 241
208struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata = { 242static const
243struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
209 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE, 244 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
210}; 245};
211 246
@@ -239,7 +274,10 @@ void __init eukrea_mbimxsd25_baseboard_init(void)
239 274
240 imx25_add_imx_uart1(&uart_pdata); 275 imx25_add_imx_uart1(&uart_pdata);
241 mxc_register_device(&mx25_fb_device, &eukrea_mximxsd_fb_pdata); 276 mxc_register_device(&mx25_fb_device, &eukrea_mximxsd_fb_pdata);
242 mxc_register_device(&imx_ssi_device0, &eukrea_mbimxsd_ssi_pdata); 277 imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
278
279 imx25_add_flexcan1(NULL);
280 imx25_add_esdhc(0, NULL);
243 281
244 gpio_request(GPIO_LED1, "LED1"); 282 gpio_request(GPIO_LED1, "LED1");
245 gpio_direction_output(GPIO_LED1, 1); 283 gpio_direction_output(GPIO_LED1, 1);
diff --git a/arch/arm/mach-mx25/mach-cpuimx25.c b/arch/arm/mach-mx25/mach-cpuimx25.c
index e064bb3d6919..f6f9ad60c25e 100644
--- a/arch/arm/mach-mx25/mach-cpuimx25.c
+++ b/arch/arm/mach-mx25/mach-cpuimx25.c
@@ -23,7 +23,6 @@
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/fec.h>
27#include <linux/platform_device.h> 26#include <linux/platform_device.h>
28#include <linux/usb/otg.h> 27#include <linux/usb/otg.h>
29#include <linux/usb/ulpi.h> 28#include <linux/usb/ulpi.h>
@@ -41,7 +40,6 @@
41#include <mach/mxc_nand.h> 40#include <mach/mxc_nand.h>
42#include <mach/imxfb.h> 41#include <mach/imxfb.h>
43#include <mach/mxc_ehci.h> 42#include <mach/mxc_ehci.h>
44#include <mach/ulpi.h>
45#include <mach/iomux-mx25.h> 43#include <mach/iomux-mx25.h>
46 44
47#include "devices-imx25.h" 45#include "devices-imx25.h"
@@ -67,7 +65,7 @@ static struct pad_desc eukrea_cpuimx25_pads[] = {
67 MX25_PAD_I2C1_DAT__I2C1_DAT, 65 MX25_PAD_I2C1_DAT__I2C1_DAT,
68}; 66};
69 67
70static struct fec_platform_data mx25_fec_pdata = { 68static const struct fec_platform_data mx25_fec_pdata __initconst = {
71 .phy = PHY_INTERFACE_MODE_RMII, 69 .phy = PHY_INTERFACE_MODE_RMII,
72}; 70};
73 71
@@ -129,24 +127,19 @@ static void __init eukrea_cpuimx25_init(void)
129 imx25_add_imx_uart0(&uart_pdata); 127 imx25_add_imx_uart0(&uart_pdata);
130 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info); 128 imx25_add_mxc_nand(&eukrea_cpuimx25_nand_board_info);
131 mxc_register_device(&mx25_rtc_device, NULL); 129 mxc_register_device(&mx25_rtc_device, NULL);
132 mxc_register_device(&mx25_fec_device, &mx25_fec_pdata); 130 imx25_add_fec(&mx25_fec_pdata);
133 131
134 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices, 132 i2c_register_board_info(0, eukrea_cpuimx25_i2c_devices,
135 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices)); 133 ARRAY_SIZE(eukrea_cpuimx25_i2c_devices));
136 imx25_add_imx_i2c0(&eukrea_cpuimx25_i2c0_data); 134 imx25_add_imx_i2c0(&eukrea_cpuimx25_i2c0_data);
137 135
138#if defined(CONFIG_USB_ULPI) 136 if (otg_mode_host)
139 if (otg_mode_host) {
140 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
141 ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
142
143 mxc_register_device(&mxc_otg, &otg_pdata); 137 mxc_register_device(&mxc_otg, &otg_pdata);
144 } 138 else
145 mxc_register_device(&mxc_usbh2, &usbh2_pdata);
146#endif
147 if (!otg_mode_host)
148 mxc_register_device(&otg_udc_device, &otg_device_pdata); 139 mxc_register_device(&otg_udc_device, &otg_device_pdata);
149 140
141 mxc_register_device(&mxc_usbh2, &usbh2_pdata);
142
150#ifdef CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD 143#ifdef CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD
151 eukrea_mbimxsd25_baseboard_init(); 144 eukrea_mbimxsd25_baseboard_init();
152#endif 145#endif
@@ -163,8 +156,6 @@ static struct sys_timer eukrea_cpuimx25_timer = {
163 156
164MACHINE_START(EUKREA_CPUIMX25, "Eukrea CPUIMX25") 157MACHINE_START(EUKREA_CPUIMX25, "Eukrea CPUIMX25")
165 /* Maintainer: Eukrea Electromatique */ 158 /* Maintainer: Eukrea Electromatique */
166 .phys_io = MX25_AIPS1_BASE_ADDR,
167 .io_pg_offst = ((MX25_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
168 .boot_params = MX25_PHYS_OFFSET + 0x100, 159 .boot_params = MX25_PHYS_OFFSET + 0x100,
169 .map_io = mx25_map_io, 160 .map_io = mx25_map_io,
170 .init_irq = mx25_init_irq, 161 .init_irq = mx25_init_irq,
diff --git a/arch/arm/mach-mx25/mach-mx25_3ds.c b/arch/arm/mach-mx25/mach-mx25_3ds.c
index 62bc21f11a71..80805107a73e 100644
--- a/arch/arm/mach-mx25/mach-mx25_3ds.c
+++ b/arch/arm/mach-mx25/mach-mx25_3ds.c
@@ -28,7 +28,6 @@
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/gpio.h> 30#include <linux/gpio.h>
31#include <linux/fec.h>
32#include <linux/platform_device.h> 31#include <linux/platform_device.h>
33#include <linux/input/matrix_keypad.h> 32#include <linux/input/matrix_keypad.h>
34 33
@@ -99,7 +98,7 @@ static struct pad_desc mx25pdk_pads[] = {
99 MX25_PAD_KPP_COL3__KPP_COL3, 98 MX25_PAD_KPP_COL3__KPP_COL3,
100}; 99};
101 100
102static struct fec_platform_data mx25_fec_pdata = { 101static const struct fec_platform_data mx25_fec_pdata __initconst = {
103 .phy = PHY_INTERFACE_MODE_RMII, 102 .phy = PHY_INTERFACE_MODE_RMII,
104}; 103};
105 104
@@ -192,7 +191,7 @@ static void __init mx25pdk_init(void)
192 mxc_register_device(&mxc_wdt, NULL); 191 mxc_register_device(&mxc_wdt, NULL);
193 192
194 mx25pdk_fec_reset(); 193 mx25pdk_fec_reset();
195 mxc_register_device(&mx25_fec_device, &mx25_fec_pdata); 194 imx25_add_fec(&mx25_fec_pdata);
196 mxc_register_device(&mx25_kpp_device, &mx25pdk_keymap_data); 195 mxc_register_device(&mx25_kpp_device, &mx25pdk_keymap_data);
197} 196}
198 197
@@ -207,8 +206,6 @@ static struct sys_timer mx25pdk_timer = {
207 206
208MACHINE_START(MX25_3DS, "Freescale MX25PDK (3DS)") 207MACHINE_START(MX25_3DS, "Freescale MX25PDK (3DS)")
209 /* Maintainer: Freescale Semiconductor, Inc. */ 208 /* Maintainer: Freescale Semiconductor, Inc. */
210 .phys_io = MX25_AIPS1_BASE_ADDR,
211 .io_pg_offst = ((MX25_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
212 .boot_params = MX25_PHYS_OFFSET + 0x100, 209 .boot_params = MX25_PHYS_OFFSET + 0x100,
213 .map_io = mx25_map_io, 210 .map_io = mx25_map_io,
214 .init_irq = mx25_init_irq, 211 .init_irq = mx25_init_irq,
diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
index 85beece802aa..096fd33f8ab9 100644
--- a/arch/arm/mach-mx3/Kconfig
+++ b/arch/arm/mach-mx3/Kconfig
@@ -9,6 +9,7 @@ config ARCH_MX35
9 bool 9 bool
10 select ARCH_MXC_IOMUX_V3 10 select ARCH_MXC_IOMUX_V3
11 select ARCH_MXC_AUDMUX_V2 11 select ARCH_MXC_AUDMUX_V2
12 select HAVE_EPIT
12 13
13comment "MX3 platforms:" 14comment "MX3 platforms:"
14 15
@@ -16,6 +17,7 @@ config MACH_MX31ADS
16 bool "Support MX31ADS platforms" 17 bool "Support MX31ADS platforms"
17 select ARCH_MX31 18 select ARCH_MX31
18 select IMX_HAVE_PLATFORM_IMX_I2C 19 select IMX_HAVE_PLATFORM_IMX_I2C
20 select IMX_HAVE_PLATFORM_IMX_SSI
19 select IMX_HAVE_PLATFORM_IMX_UART 21 select IMX_HAVE_PLATFORM_IMX_UART
20 default y 22 default y
21 help 23 help
@@ -117,9 +119,11 @@ config MACH_PCM043
117 bool "Support Phytec pcm043 (i.MX35) platforms" 119 bool "Support Phytec pcm043 (i.MX35) platforms"
118 select ARCH_MX35 120 select ARCH_MX35
119 select IMX_HAVE_PLATFORM_IMX_I2C 121 select IMX_HAVE_PLATFORM_IMX_I2C
122 select IMX_HAVE_PLATFORM_IMX_SSI
120 select IMX_HAVE_PLATFORM_IMX_UART 123 select IMX_HAVE_PLATFORM_IMX_UART
121 select IMX_HAVE_PLATFORM_MXC_NAND 124 select IMX_HAVE_PLATFORM_MXC_NAND
122 select IMX_HAVE_PLATFORM_FLEXCAN 125 select IMX_HAVE_PLATFORM_FLEXCAN
126 select IMX_HAVE_PLATFORM_ESDHC
123 select MXC_ULPI if USB_ULPI 127 select MXC_ULPI if USB_ULPI
124 help 128 help
125 Include support for Phytec pcm043 platform. This includes 129 Include support for Phytec pcm043 platform. This includes
@@ -140,6 +144,7 @@ config MACH_MX35_3DS
140 bool "Support MX35PDK platform" 144 bool "Support MX35PDK platform"
141 select ARCH_MX35 145 select ARCH_MX35
142 select IMX_HAVE_PLATFORM_IMX_UART 146 select IMX_HAVE_PLATFORM_IMX_UART
147 select IMX_HAVE_PLATFORM_MXC_NAND
143 default n 148 default n
144 help 149 help
145 Include support for MX35PDK platform. This includes specific 150 Include support for MX35PDK platform. This includes specific
@@ -159,6 +164,8 @@ config MACH_EUKREA_CPUIMX35
159 select IMX_HAVE_PLATFORM_IMX_UART 164 select IMX_HAVE_PLATFORM_IMX_UART
160 select IMX_HAVE_PLATFORM_IMX_I2C 165 select IMX_HAVE_PLATFORM_IMX_I2C
161 select IMX_HAVE_PLATFORM_MXC_NAND 166 select IMX_HAVE_PLATFORM_MXC_NAND
167 select IMX_HAVE_PLATFORM_FLEXCAN
168 select IMX_HAVE_PLATFORM_ESDHC
162 select MXC_ULPI if USB_ULPI 169 select MXC_ULPI if USB_ULPI
163 help 170 help
164 Include support for Eukrea CPUIMX35 platform. This includes 171 Include support for Eukrea CPUIMX35 platform. This includes
@@ -170,8 +177,8 @@ choice
170 default MACH_EUKREA_MBIMXSD35_BASEBOARD 177 default MACH_EUKREA_MBIMXSD35_BASEBOARD
171 178
172config MACH_EUKREA_MBIMXSD35_BASEBOARD 179config MACH_EUKREA_MBIMXSD35_BASEBOARD
173 prompt "Eukrea MBIMXSD development board" 180 bool "Eukrea MBIMXSD development board"
174 bool 181 select IMX_HAVE_PLATFORM_IMX_SSI
175 help 182 help
176 This adds board specific devices that can be found on Eukrea's 183 This adds board specific devices that can be found on Eukrea's
177 MBIMXSD evaluation board. 184 MBIMXSD evaluation board.
diff --git a/arch/arm/mach-mx3/Makefile b/arch/arm/mach-mx3/Makefile
index 2bd7beceb991..8a182d0a3fcf 100644
--- a/arch/arm/mach-mx3/Makefile
+++ b/arch/arm/mach-mx3/Makefile
@@ -7,7 +7,6 @@
7obj-y := mm.o devices.o cpu.o 7obj-y := mm.o devices.o cpu.o
8CFLAGS_mm.o = -DIMX_NEEDS_DEPRECATED_SYMBOLS 8CFLAGS_mm.o = -DIMX_NEEDS_DEPRECATED_SYMBOLS
9CFLAGS_devices.o = -DIMX_NEEDS_DEPRECATED_SYMBOLS 9CFLAGS_devices.o = -DIMX_NEEDS_DEPRECATED_SYMBOLS
10CFLAGS_cpu.o = -DIMX_NEEDS_DEPRECATED_SYMBOLS
11obj-$(CONFIG_ARCH_MX31) += clock-imx31.o iomux-imx31.o 10obj-$(CONFIG_ARCH_MX31) += clock-imx31.o iomux-imx31.o
12obj-$(CONFIG_ARCH_MX35) += clock-imx35.o 11obj-$(CONFIG_ARCH_MX35) += clock-imx35.o
13obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o 12obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o
diff --git a/arch/arm/mach-mx3/clock-imx31.c b/arch/arm/mach-mx3/clock-imx31.c
index 9a9eb6de6127..109e98f323e0 100644
--- a/arch/arm/mach-mx3/clock-imx31.c
+++ b/arch/arm/mach-mx3/clock-imx31.c
@@ -477,7 +477,7 @@ DEFINE_CLOCK(epit1_clk, 0, MXC_CCM_CGR0, 6, NULL, NULL, &perclk_clk);
477DEFINE_CLOCK(epit2_clk, 1, MXC_CCM_CGR0, 8, NULL, NULL, &perclk_clk); 477DEFINE_CLOCK(epit2_clk, 1, MXC_CCM_CGR0, 8, NULL, NULL, &perclk_clk);
478DEFINE_CLOCK(iim_clk, 0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk); 478DEFINE_CLOCK(iim_clk, 0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk);
479DEFINE_CLOCK(ata_clk, 0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk); 479DEFINE_CLOCK(ata_clk, 0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk);
480DEFINE_CLOCK(sdma_clk1, 0, MXC_CCM_CGR0, 14, NULL, &sdma_clk1, &ahb_clk); 480DEFINE_CLOCK(sdma_clk1, 0, MXC_CCM_CGR0, 14, NULL, NULL, &ahb_clk);
481DEFINE_CLOCK(cspi3_clk, 2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk); 481DEFINE_CLOCK(cspi3_clk, 2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk);
482DEFINE_CLOCK(rng_clk, 0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk); 482DEFINE_CLOCK(rng_clk, 0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk);
483DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk); 483DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk);
@@ -525,9 +525,9 @@ DEFINE_CLOCK(ipg_clk, 0, NULL, 0, ipg_get_rate, NULL, &ahb_clk);
525 525
526static struct clk_lookup lookups[] = { 526static struct clk_lookup lookups[] = {
527 _REGISTER_CLOCK(NULL, "emi", emi_clk) 527 _REGISTER_CLOCK(NULL, "emi", emi_clk)
528 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk) 528 _REGISTER_CLOCK("imx31-cspi.0", NULL, cspi1_clk)
529 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk) 529 _REGISTER_CLOCK("imx31-cspi.1", NULL, cspi2_clk)
530 _REGISTER_CLOCK("spi_imx.2", NULL, cspi3_clk) 530 _REGISTER_CLOCK("imx31-cspi.2", NULL, cspi3_clk)
531 _REGISTER_CLOCK(NULL, "gpt", gpt_clk) 531 _REGISTER_CLOCK(NULL, "gpt", gpt_clk)
532 _REGISTER_CLOCK(NULL, "pwm", pwm_clk) 532 _REGISTER_CLOCK(NULL, "pwm", pwm_clk)
533 _REGISTER_CLOCK("imx-wdt.0", NULL, wdog_clk) 533 _REGISTER_CLOCK("imx-wdt.0", NULL, wdog_clk)
@@ -564,7 +564,7 @@ static struct clk_lookup lookups[] = {
564 _REGISTER_CLOCK(NULL, "ata", ata_clk) 564 _REGISTER_CLOCK(NULL, "ata", ata_clk)
565 _REGISTER_CLOCK(NULL, "rtic", rtic_clk) 565 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
566 _REGISTER_CLOCK(NULL, "rng", rng_clk) 566 _REGISTER_CLOCK(NULL, "rng", rng_clk)
567 _REGISTER_CLOCK(NULL, "sdma_ahb", sdma_clk1) 567 _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk1)
568 _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2) 568 _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2)
569 _REGISTER_CLOCK(NULL, "mstick", mstick1_clk) 569 _REGISTER_CLOCK(NULL, "mstick", mstick1_clk)
570 _REGISTER_CLOCK(NULL, "mstick", mstick2_clk) 570 _REGISTER_CLOCK(NULL, "mstick", mstick2_clk)
diff --git a/arch/arm/mach-mx3/clock-imx35.c b/arch/arm/mach-mx3/clock-imx35.c
index 7a62e744a8b0..61e4a318980a 100644
--- a/arch/arm/mach-mx3/clock-imx35.c
+++ b/arch/arm/mach-mx3/clock-imx35.c
@@ -364,8 +364,8 @@ DEFINE_CLOCK(cspi2_clk, 1, CCM_CGR0, 12, get_rate_ipg, NULL);
364DEFINE_CLOCK(ect_clk, 0, CCM_CGR0, 14, get_rate_ipg, NULL); 364DEFINE_CLOCK(ect_clk, 0, CCM_CGR0, 14, get_rate_ipg, NULL);
365DEFINE_CLOCK(edio_clk, 0, CCM_CGR0, 16, NULL, NULL); 365DEFINE_CLOCK(edio_clk, 0, CCM_CGR0, 16, NULL, NULL);
366DEFINE_CLOCK(emi_clk, 0, CCM_CGR0, 18, get_rate_ipg, NULL); 366DEFINE_CLOCK(emi_clk, 0, CCM_CGR0, 18, get_rate_ipg, NULL);
367DEFINE_CLOCK(epit1_clk, 0, CCM_CGR0, 20, get_rate_ipg_per, NULL); 367DEFINE_CLOCK(epit1_clk, 0, CCM_CGR0, 20, get_rate_ipg, NULL);
368DEFINE_CLOCK(epit2_clk, 1, CCM_CGR0, 22, get_rate_ipg_per, NULL); 368DEFINE_CLOCK(epit2_clk, 1, CCM_CGR0, 22, get_rate_ipg, NULL);
369DEFINE_CLOCK(esai_clk, 0, CCM_CGR0, 24, NULL, NULL); 369DEFINE_CLOCK(esai_clk, 0, CCM_CGR0, 24, NULL, NULL);
370DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGR0, 26, get_rate_sdhc, NULL); 370DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGR0, 26, get_rate_sdhc, NULL);
371DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGR0, 28, get_rate_sdhc, NULL); 371DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGR0, 28, get_rate_sdhc, NULL);
@@ -451,17 +451,17 @@ static struct clk_lookup lookups[] = {
451 _REGISTER_CLOCK(NULL, "ata", ata_clk) 451 _REGISTER_CLOCK(NULL, "ata", ata_clk)
452 _REGISTER_CLOCK("flexcan.0", NULL, can1_clk) 452 _REGISTER_CLOCK("flexcan.0", NULL, can1_clk)
453 _REGISTER_CLOCK("flexcan.1", NULL, can2_clk) 453 _REGISTER_CLOCK("flexcan.1", NULL, can2_clk)
454 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk) 454 _REGISTER_CLOCK("imx35-cspi.0", NULL, cspi1_clk)
455 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk) 455 _REGISTER_CLOCK("imx35-cspi.1", NULL, cspi2_clk)
456 _REGISTER_CLOCK(NULL, "ect", ect_clk) 456 _REGISTER_CLOCK(NULL, "ect", ect_clk)
457 _REGISTER_CLOCK(NULL, "edio", edio_clk) 457 _REGISTER_CLOCK(NULL, "edio", edio_clk)
458 _REGISTER_CLOCK(NULL, "emi", emi_clk) 458 _REGISTER_CLOCK(NULL, "emi", emi_clk)
459 _REGISTER_CLOCK(NULL, "epit", epit1_clk) 459 _REGISTER_CLOCK("imx-epit.0", NULL, epit1_clk)
460 _REGISTER_CLOCK(NULL, "epit", epit2_clk) 460 _REGISTER_CLOCK("imx-epit.1", NULL, epit2_clk)
461 _REGISTER_CLOCK(NULL, "esai", esai_clk) 461 _REGISTER_CLOCK(NULL, "esai", esai_clk)
462 _REGISTER_CLOCK(NULL, "sdhc", esdhc1_clk) 462 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
463 _REGISTER_CLOCK(NULL, "sdhc", esdhc2_clk) 463 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
464 _REGISTER_CLOCK(NULL, "sdhc", esdhc3_clk) 464 _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk)
465 _REGISTER_CLOCK("fec.0", NULL, fec_clk) 465 _REGISTER_CLOCK("fec.0", NULL, fec_clk)
466 _REGISTER_CLOCK(NULL, "gpio", gpio1_clk) 466 _REGISTER_CLOCK(NULL, "gpio", gpio1_clk)
467 _REGISTER_CLOCK(NULL, "gpio", gpio2_clk) 467 _REGISTER_CLOCK(NULL, "gpio", gpio2_clk)
@@ -482,7 +482,7 @@ static struct clk_lookup lookups[] = {
482 _REGISTER_CLOCK(NULL, "rtc", rtc_clk) 482 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
483 _REGISTER_CLOCK(NULL, "rtic", rtic_clk) 483 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
484 _REGISTER_CLOCK(NULL, "scc", scc_clk) 484 _REGISTER_CLOCK(NULL, "scc", scc_clk)
485 _REGISTER_CLOCK(NULL, "sdma", sdma_clk) 485 _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk)
486 _REGISTER_CLOCK(NULL, "spba", spba_clk) 486 _REGISTER_CLOCK(NULL, "spba", spba_clk)
487 _REGISTER_CLOCK(NULL, "spdif", spdif_clk) 487 _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
488 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) 488 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
@@ -535,8 +535,16 @@ int __init mx35_clocks_init()
535 __raw_writel(cgr2, CCM_BASE + CCM_CGR2); 535 __raw_writel(cgr2, CCM_BASE + CCM_CGR2);
536 __raw_writel(cgr3, CCM_BASE + CCM_CGR3); 536 __raw_writel(cgr3, CCM_BASE + CCM_CGR3);
537 537
538 clk_enable(&iim_clk);
539 mx35_read_cpu_rev();
540
541#ifdef CONFIG_MXC_USE_EPIT
542 epit_timer_init(&epit1_clk,
543 MX35_IO_ADDRESS(MX35_EPIT1_BASE_ADDR), MX35_INT_EPIT1);
544#else
538 mxc_timer_init(&gpt_clk, 545 mxc_timer_init(&gpt_clk,
539 MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), MX35_INT_GPT); 546 MX35_IO_ADDRESS(MX35_GPT1_BASE_ADDR), MX35_INT_GPT);
547#endif
540 548
541 return 0; 549 return 0;
542} 550}
diff --git a/arch/arm/mach-mx3/cpu.c b/arch/arm/mach-mx3/cpu.c
index 861afe0fe3ad..d00a75457812 100644
--- a/arch/arm/mach-mx3/cpu.c
+++ b/arch/arm/mach-mx3/cpu.c
@@ -25,15 +25,15 @@ struct mx3_cpu_type {
25}; 25};
26 26
27static struct mx3_cpu_type mx31_cpu_type[] __initdata = { 27static struct mx3_cpu_type mx31_cpu_type[] __initdata = {
28 { .srev = 0x00, .name = "i.MX31(L)", .v = "1.0", .rev = CHIP_REV_1_0 }, 28 { .srev = 0x00, .name = "i.MX31(L)", .v = "1.0", .rev = MX3x_CHIP_REV_1_0 },
29 { .srev = 0x10, .name = "i.MX31", .v = "1.1", .rev = CHIP_REV_1_1 }, 29 { .srev = 0x10, .name = "i.MX31", .v = "1.1", .rev = MX3x_CHIP_REV_1_1 },
30 { .srev = 0x11, .name = "i.MX31L", .v = "1.1", .rev = CHIP_REV_1_1 }, 30 { .srev = 0x11, .name = "i.MX31L", .v = "1.1", .rev = MX3x_CHIP_REV_1_1 },
31 { .srev = 0x12, .name = "i.MX31", .v = "1.15", .rev = CHIP_REV_1_1 }, 31 { .srev = 0x12, .name = "i.MX31", .v = "1.15", .rev = MX3x_CHIP_REV_1_1 },
32 { .srev = 0x13, .name = "i.MX31L", .v = "1.15", .rev = CHIP_REV_1_1 }, 32 { .srev = 0x13, .name = "i.MX31L", .v = "1.15", .rev = MX3x_CHIP_REV_1_1 },
33 { .srev = 0x14, .name = "i.MX31", .v = "1.2", .rev = CHIP_REV_1_2 }, 33 { .srev = 0x14, .name = "i.MX31", .v = "1.2", .rev = MX3x_CHIP_REV_1_2 },
34 { .srev = 0x15, .name = "i.MX31L", .v = "1.2", .rev = CHIP_REV_1_2 }, 34 { .srev = 0x15, .name = "i.MX31L", .v = "1.2", .rev = MX3x_CHIP_REV_1_2 },
35 { .srev = 0x28, .name = "i.MX31", .v = "2.0", .rev = CHIP_REV_2_0 }, 35 { .srev = 0x28, .name = "i.MX31", .v = "2.0", .rev = MX3x_CHIP_REV_2_0 },
36 { .srev = 0x29, .name = "i.MX31L", .v = "2.0", .rev = CHIP_REV_2_0 }, 36 { .srev = 0x29, .name = "i.MX31L", .v = "2.0", .rev = MX3x_CHIP_REV_2_0 },
37}; 37};
38 38
39void __init mx31_read_cpu_rev(void) 39void __init mx31_read_cpu_rev(void)
@@ -41,7 +41,7 @@ void __init mx31_read_cpu_rev(void)
41 u32 i, srev; 41 u32 i, srev;
42 42
43 /* read SREV register from IIM module */ 43 /* read SREV register from IIM module */
44 srev = __raw_readl(IO_ADDRESS(IIM_BASE_ADDR + MXC_IIMSREV)); 44 srev = __raw_readl(MX31_IO_ADDRESS(MX31_IIM_BASE_ADDR + MXC_IIMSREV));
45 45
46 for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++) 46 for (i = 0; i < ARRAY_SIZE(mx31_cpu_type); i++)
47 if (srev == mx31_cpu_type[i].srev) { 47 if (srev == mx31_cpu_type[i].srev) {
@@ -55,3 +55,30 @@ void __init mx31_read_cpu_rev(void)
55 55
56 printk(KERN_WARNING "Unknown CPU identifier. srev = %02x\n", srev); 56 printk(KERN_WARNING "Unknown CPU identifier. srev = %02x\n", srev);
57} 57}
58
59unsigned int mx35_cpu_rev;
60EXPORT_SYMBOL(mx35_cpu_rev);
61
62void __init mx35_read_cpu_rev(void)
63{
64 u32 rev;
65 char *srev = "unknown";
66
67 rev = __raw_readl(MX35_IO_ADDRESS(MX35_IIM_BASE_ADDR + MXC_IIMSREV));
68 switch (rev) {
69 case 0x00:
70 mx35_cpu_rev = MX3x_CHIP_REV_1_0;
71 srev = "1.0";
72 break;
73 case 0x10:
74 mx35_cpu_rev = MX3x_CHIP_REV_2_0;
75 srev = "2.0";
76 break;
77 case 0x11:
78 mx35_cpu_rev = MX3x_CHIP_REV_2_1;
79 srev = "2.1";
80 break;
81 }
82
83 printk(KERN_INFO "CPU identified as i.MX35, silicon rev %s\n", srev);
84}
diff --git a/arch/arm/mach-mx3/devices-imx31.h b/arch/arm/mach-mx3/devices-imx31.h
index 3b1a44a20585..de9598590eba 100644
--- a/arch/arm/mach-mx3/devices-imx31.h
+++ b/arch/arm/mach-mx3/devices-imx31.h
@@ -9,30 +9,33 @@
9#include <mach/mx31.h> 9#include <mach/mx31.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12#define imx31_add_imx_i2c0(pdata) \ 12extern const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst;
13 imx_add_imx_i2c(0, MX31_I2C1_BASE_ADDR, SZ_4K, MX31_INT_I2C1, pdata) 13#define imx31_add_imx_i2c(id, pdata) \
14#define imx31_add_imx_i2c1(pdata) \ 14 imx_add_imx_i2c(&imx31_imx_i2c_data[id], pdata)
15 imx_add_imx_i2c(1, MX31_I2C2_BASE_ADDR, SZ_4K, MX31_INT_I2C2, pdata) 15#define imx31_add_imx_i2c0(pdata) imx31_add_imx_i2c(0, pdata)
16#define imx31_add_imx_i2c2(pdata) \ 16#define imx31_add_imx_i2c1(pdata) imx31_add_imx_i2c(1, pdata)
17 imx_add_imx_i2c(2, MX31_I2C3_BASE_ADDR, SZ_4K, MX31_INT_I2C3, pdata) 17#define imx31_add_imx_i2c2(pdata) imx31_add_imx_i2c(2, pdata)
18 18
19#define imx31_add_imx_uart0(pdata) \ 19extern const struct imx_imx_ssi_data imx31_imx_ssi_data[] __initconst;
20 imx_add_imx_uart_1irq(0, MX31_UART1_BASE_ADDR, SZ_16K, MX31_INT_UART1, pdata) 20#define imx31_add_imx_ssi(id, pdata) \
21#define imx31_add_imx_uart1(pdata) \ 21 imx_add_imx_ssi(&imx31_imx_ssi_data[id], pdata)
22 imx_add_imx_uart_1irq(1, MX31_UART2_BASE_ADDR, SZ_16K, MX31_INT_UART2, pdata)
23#define imx31_add_imx_uart2(pdata) \
24 imx_add_imx_uart_1irq(2, MX31_UART3_BASE_ADDR, SZ_16K, MX31_INT_UART3, pdata)
25#define imx31_add_imx_uart3(pdata) \
26 imx_add_imx_uart_1irq(3, MX31_UART4_BASE_ADDR, SZ_16K, MX31_INT_UART4, pdata)
27#define imx31_add_imx_uart4(pdata) \
28 imx_add_imx_uart_1irq(4, MX31_UART5_BASE_ADDR, SZ_16K, MX31_INT_UART5, pdata)
29 22
23extern const struct imx_imx_uart_1irq_data imx31_imx_uart_data[] __initconst;
24#define imx31_add_imx_uart(id, pdata) \
25 imx_add_imx_uart_1irq(&imx31_imx_uart_data[id], pdata)
26#define imx31_add_imx_uart0(pdata) imx31_add_imx_uart(0, pdata)
27#define imx31_add_imx_uart1(pdata) imx31_add_imx_uart(1, pdata)
28#define imx31_add_imx_uart2(pdata) imx31_add_imx_uart(2, pdata)
29#define imx31_add_imx_uart3(pdata) imx31_add_imx_uart(3, pdata)
30#define imx31_add_imx_uart4(pdata) imx31_add_imx_uart(4, pdata)
31
32extern const struct imx_mxc_nand_data imx31_mxc_nand_data __initconst;
30#define imx31_add_mxc_nand(pdata) \ 33#define imx31_add_mxc_nand(pdata) \
31 imx_add_mxc_nand_v1(MX31_NFC_BASE_ADDR, MX31_INT_NANDFC, pdata) 34 imx_add_mxc_nand(&imx31_mxc_nand_data, pdata)
32 35
33#define imx31_add_spi_imx0(pdata) \ 36extern const struct imx_spi_imx_data imx31_cspi_data[] __initconst;
34 imx_add_spi_imx(0, MX31_CSPI1_BASE_ADDR, SZ_4K, MX31_INT_CSPI1, pdata) 37#define imx31_add_cspi(id, pdata) \
35#define imx31_add_spi_imx1(pdata) \ 38 imx_add_spi_imx(&imx31_cspi_data[id], pdata)
36 imx_add_spi_imx(1, MX31_CSPI2_BASE_ADDR, SZ_4K, MX31_INT_CSPI2, pdata) 39#define imx31_add_spi_imx0(pdata) imx31_add_cspi(0, pdata)
37#define imx31_add_spi_imx2(pdata) \ 40#define imx31_add_spi_imx1(pdata) imx31_add_cspi(1, pdata)
38 imx_add_spi_imx(2, MX31_CSPI3_BASE_ADDR, SZ_4K, MX31_INT_CSPI3, pdata) 41#define imx31_add_spi_imx2(pdata) imx31_add_cspi(2, pdata)
diff --git a/arch/arm/mach-mx3/devices-imx35.h b/arch/arm/mach-mx3/devices-imx35.h
index f6a431a4c3d2..5eb917b638d0 100644
--- a/arch/arm/mach-mx3/devices-imx35.h
+++ b/arch/arm/mach-mx3/devices-imx35.h
@@ -9,29 +9,43 @@
9#include <mach/mx35.h> 9#include <mach/mx35.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12extern const struct imx_fec_data imx35_fec_data __initconst;
13#define imx35_add_fec(pdata) \
14 imx_add_fec(&imx35_fec_data, pdata)
15
12#define imx35_add_flexcan0(pdata) \ 16#define imx35_add_flexcan0(pdata) \
13 imx_add_flexcan(0, MX35_CAN1_BASE_ADDR, SZ_16K, MX35_INT_CAN1, pdata) 17 imx_add_flexcan(0, MX35_CAN1_BASE_ADDR, SZ_16K, MX35_INT_CAN1, pdata)
14#define imx35_add_flexcan1(pdata) \ 18#define imx35_add_flexcan1(pdata) \
15 imx_add_flexcan(1, MX35_CAN2_BASE_ADDR, SZ_16K, MX35_INT_CAN2, pdata) 19 imx_add_flexcan(1, MX35_CAN2_BASE_ADDR, SZ_16K, MX35_INT_CAN2, pdata)
16 20
17#define imx35_add_imx_i2c0(pdata) \ 21extern const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst;
18 imx_add_imx_i2c(0, MX35_I2C1_BASE_ADDR, SZ_4K, MX35_INT_I2C1, pdata) 22#define imx35_add_imx_i2c(id, pdata) \
19#define imx35_add_imx_i2c1(pdata) \ 23 imx_add_imx_i2c(&imx35_imx_i2c_data[id], pdata)
20 imx_add_imx_i2c(1, MX35_I2C2_BASE_ADDR, SZ_4K, MX35_INT_I2C2, pdata) 24#define imx35_add_imx_i2c0(pdata) imx35_add_imx_i2c(0, pdata)
21#define imx35_add_imx_i2c2(pdata) \ 25#define imx35_add_imx_i2c1(pdata) imx35_add_imx_i2c(1, pdata)
22 imx_add_imx_i2c(2, MX35_I2C3_BASE_ADDR, SZ_4K, MX35_INT_I2C3, pdata) 26#define imx35_add_imx_i2c2(pdata) imx35_add_imx_i2c(2, pdata)
27
28extern const struct imx_imx_ssi_data imx35_imx_ssi_data[] __initconst;
29#define imx35_add_imx_ssi(id, pdata) \
30 imx_add_imx_ssi(&imx35_imx_ssi_data[id], pdata)
23 31
24#define imx35_add_imx_uart0(pdata) \ 32extern const struct imx_imx_uart_1irq_data imx35_imx_uart_data[] __initconst;
25 imx_add_imx_uart_1irq(0, MX35_UART1_BASE_ADDR, SZ_16K, MX35_INT_UART1, pdata) 33#define imx35_add_imx_uart(id, pdata) \
26#define imx35_add_imx_uart1(pdata) \ 34 imx_add_imx_uart_1irq(&imx35_imx_uart_data[id], pdata)
27 imx_add_imx_uart_1irq(1, MX35_UART2_BASE_ADDR, SZ_16K, MX35_INT_UART2, pdata) 35#define imx35_add_imx_uart0(pdata) imx35_add_imx_uart(0, pdata)
28#define imx35_add_imx_uart2(pdata) \ 36#define imx35_add_imx_uart1(pdata) imx35_add_imx_uart(1, pdata)
29 imx_add_imx_uart_1irq(2, MX35_UART3_BASE_ADDR, SZ_16K, MX35_INT_UART3, pdata) 37#define imx35_add_imx_uart2(pdata) imx35_add_imx_uart(2, pdata)
30 38
39extern const struct imx_mxc_nand_data imx35_mxc_nand_data __initconst;
31#define imx35_add_mxc_nand(pdata) \ 40#define imx35_add_mxc_nand(pdata) \
32 imx_add_mxc_nand_v21(MX35_NFC_BASE_ADDR, MX35_INT_NANDFC, pdata) 41 imx_add_mxc_nand(&imx35_mxc_nand_data, pdata)
42
43extern const struct imx_spi_imx_data imx35_cspi_data[] __initconst;
44#define imx35_add_cspi(id, pdata) \
45 imx_add_spi_imx(&imx35_cspi_data[id], pdata)
46#define imx35_add_spi_imx0(pdata) imx35_add_cspi(0, pdata)
47#define imx35_add_spi_imx1(pdata) imx35_add_cspi(1, pdata)
33 48
34#define imx35_add_spi_imx0(pdata) \ 49extern const struct imx_esdhc_imx_data imx35_esdhc_data[] __initconst;
35 imx_add_spi_imx(0, MX35_CSPI1_BASE_ADDR, SZ_4K, MX35_INT_CSPI1, pdata) 50#define imx35_add_esdhc(id, pdata) \
36#define imx35_add_spi_imx1(pdata) \ 51 imx_add_esdhc(&imx35_esdhc_data[id], pdata)
37 imx_add_spi_imx(1, MX35_CSPI2_BASE_ADDR, SZ_4K, MX35_INT_CSPI2, pdata)
diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c
index a4fd1a26fc91..f4dff11aaee7 100644
--- a/arch/arm/mach-mx3/devices.c
+++ b/arch/arm/mach-mx3/devices.c
@@ -281,65 +281,6 @@ struct platform_device mxc_usbh2 = {
281 .num_resources = ARRAY_SIZE(mxc_usbh2_resources), 281 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
282}; 282};
283 283
284#if defined(CONFIG_ARCH_MX35)
285static struct resource mxc_fec_resources[] = {
286 {
287 .start = MXC_FEC_BASE_ADDR,
288 .end = MXC_FEC_BASE_ADDR + 0xfff,
289 .flags = IORESOURCE_MEM,
290 }, {
291 .start = MXC_INT_FEC,
292 .end = MXC_INT_FEC,
293 .flags = IORESOURCE_IRQ,
294 },
295};
296
297struct platform_device mxc_fec_device = {
298 .name = "fec",
299 .id = 0,
300 .num_resources = ARRAY_SIZE(mxc_fec_resources),
301 .resource = mxc_fec_resources,
302};
303#endif
304
305static struct resource imx_ssi_resources0[] = {
306 {
307 .start = SSI1_BASE_ADDR,
308 .end = SSI1_BASE_ADDR + 0xfff,
309 .flags = IORESOURCE_MEM,
310 }, {
311 .start = MX31_INT_SSI1,
312 .end = MX31_INT_SSI1,
313 .flags = IORESOURCE_IRQ,
314 },
315};
316
317static struct resource imx_ssi_resources1[] = {
318 {
319 .start = SSI2_BASE_ADDR,
320 .end = SSI2_BASE_ADDR + 0xfff,
321 .flags = IORESOURCE_MEM
322 }, {
323 .start = MX31_INT_SSI2,
324 .end = MX31_INT_SSI2,
325 .flags = IORESOURCE_IRQ,
326 },
327};
328
329struct platform_device imx_ssi_device0 = {
330 .name = "imx-ssi",
331 .id = 0,
332 .num_resources = ARRAY_SIZE(imx_ssi_resources0),
333 .resource = imx_ssi_resources0,
334};
335
336struct platform_device imx_ssi_device1 = {
337 .name = "imx-ssi",
338 .id = 1,
339 .num_resources = ARRAY_SIZE(imx_ssi_resources1),
340 .resource = imx_ssi_resources1,
341};
342
343static struct resource imx_wdt_resources[] = { 284static struct resource imx_wdt_resources[] = {
344 { 285 {
345 .flags = IORESOURCE_MEM, 286 .flags = IORESOURCE_MEM,
@@ -410,10 +351,6 @@ static int __init mx3_devices_init(void)
410 mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff; 351 mxc_usbh1_resources[0].end = MX35_OTG_BASE_ADDR + 0x5ff;
411 mxc_usbh1_resources[1].start = MXC_INT_USBHS; 352 mxc_usbh1_resources[1].start = MXC_INT_USBHS;
412 mxc_usbh1_resources[1].end = MXC_INT_USBHS; 353 mxc_usbh1_resources[1].end = MXC_INT_USBHS;
413 imx_ssi_resources0[1].start = MX35_INT_SSI1;
414 imx_ssi_resources0[1].end = MX35_INT_SSI1;
415 imx_ssi_resources1[1].start = MX35_INT_SSI2;
416 imx_ssi_resources1[1].end = MX35_INT_SSI2;
417 imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR; 354 imx_wdt_resources[0].start = MX35_WDOG_BASE_ADDR;
418 imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff; 355 imx_wdt_resources[0].end = MX35_WDOG_BASE_ADDR + 0x3fff;
419 } 356 }
diff --git a/arch/arm/mach-mx3/devices.h b/arch/arm/mach-mx3/devices.h
index e5535234839f..585f814473d5 100644
--- a/arch/arm/mach-mx3/devices.h
+++ b/arch/arm/mach-mx3/devices.h
@@ -2,7 +2,6 @@ extern struct platform_device mxc_w1_master_device;
2extern struct platform_device mx3_ipu; 2extern struct platform_device mx3_ipu;
3extern struct platform_device mx3_fb; 3extern struct platform_device mx3_fb;
4extern struct platform_device mx3_camera; 4extern struct platform_device mx3_camera;
5extern struct platform_device mxc_fec_device;
6extern struct platform_device mxcsdhc_device0; 5extern struct platform_device mxcsdhc_device0;
7extern struct platform_device mxcsdhc_device1; 6extern struct platform_device mxcsdhc_device1;
8extern struct platform_device mxc_otg_udc_device; 7extern struct platform_device mxc_otg_udc_device;
@@ -10,9 +9,6 @@ extern struct platform_device mxc_otg_host;
10extern struct platform_device mxc_usbh1; 9extern struct platform_device mxc_usbh1;
11extern struct platform_device mxc_usbh2; 10extern struct platform_device mxc_usbh2;
12extern struct platform_device mxc_rnga_device; 11extern struct platform_device mxc_rnga_device;
13extern struct platform_device imx_ssi_device0;
14extern struct platform_device imx_ssi_device1;
15extern struct platform_device imx_ssi_device1;
16extern struct platform_device imx_wdt_device0; 12extern struct platform_device imx_wdt_device0;
17extern struct platform_device imx_rtc_device0; 13extern struct platform_device imx_rtc_device0;
18extern struct platform_device imx_kpp_device; 14extern struct platform_device imx_kpp_device;
diff --git a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
index f8f15e3ac7a0..1abc10d52922 100644
--- a/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
+++ b/arch/arm/mach-mx3/eukrea_mbimxsd-baseboard.c
@@ -43,14 +43,13 @@
43#include <mach/ipu.h> 43#include <mach/ipu.h>
44#include <mach/mx3fb.h> 44#include <mach/mx3fb.h>
45#include <mach/audmux.h> 45#include <mach/audmux.h>
46#include <mach/ssi.h>
47 46
48#include "devices-imx35.h" 47#include "devices-imx35.h"
49#include "devices.h" 48#include "devices.h"
50 49
51static const struct fb_videomode fb_modedb[] = { 50static const struct fb_videomode fb_modedb[] = {
52 { 51 {
53 .name = "CMO_QVGA", 52 .name = "CMO-QVGA",
54 .refresh = 60, 53 .refresh = 60,
55 .xres = 320, 54 .xres = 320,
56 .yres = 240, 55 .yres = 240,
@@ -65,6 +64,40 @@ static const struct fb_videomode fb_modedb[] = {
65 .vmode = FB_VMODE_NONINTERLACED, 64 .vmode = FB_VMODE_NONINTERLACED,
66 .flag = 0, 65 .flag = 0,
67 }, 66 },
67 {
68 .name = "DVI-VGA",
69 .refresh = 60,
70 .xres = 640,
71 .yres = 480,
72 .pixclock = 32000,
73 .left_margin = 100,
74 .right_margin = 100,
75 .upper_margin = 7,
76 .lower_margin = 100,
77 .hsync_len = 7,
78 .vsync_len = 7,
79 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT |
80 FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
81 .vmode = FB_VMODE_NONINTERLACED,
82 .flag = 0,
83 },
84 {
85 .name = "DVI-SVGA",
86 .refresh = 60,
87 .xres = 800,
88 .yres = 600,
89 .pixclock = 25000,
90 .left_margin = 75,
91 .right_margin = 75,
92 .upper_margin = 7,
93 .lower_margin = 75,
94 .hsync_len = 7,
95 .vsync_len = 7,
96 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT |
97 FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT,
98 .vmode = FB_VMODE_NONINTERLACED,
99 .flag = 0,
100 },
68}; 101};
69 102
70static struct ipu_platform_data mx3_ipu_data = { 103static struct ipu_platform_data mx3_ipu_data = {
@@ -73,7 +106,7 @@ static struct ipu_platform_data mx3_ipu_data = {
73 106
74static struct mx3fb_platform_data mx3fb_pdata = { 107static struct mx3fb_platform_data mx3fb_pdata = {
75 .dma_dev = &mx3_ipu.dev, 108 .dma_dev = &mx3_ipu.dev,
76 .name = "CMO_QVGA", 109 .name = "CMO-QVGA",
77 .mode = fb_modedb, 110 .mode = fb_modedb,
78 .num_modes = ARRAY_SIZE(fb_modedb), 111 .num_modes = ARRAY_SIZE(fb_modedb),
79}; 112};
@@ -120,6 +153,16 @@ static struct pad_desc eukrea_mbimxsd_pads[] = {
120 MX35_PAD_STXD4__AUDMUX_AUD4_TXD, 153 MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
121 MX35_PAD_SRXD4__AUDMUX_AUD4_RXD, 154 MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
122 MX35_PAD_SCK4__AUDMUX_AUD4_TXC, 155 MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
156 /* CAN2 */
157 MX35_PAD_TX5_RX0__CAN2_TXCAN,
158 MX35_PAD_TX4_RX1__CAN2_RXCAN,
159 /* SDCARD */
160 MX35_PAD_SD1_CMD__ESDHC1_CMD,
161 MX35_PAD_SD1_CLK__ESDHC1_CLK,
162 MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
163 MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
164 MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
165 MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
123}; 166};
124 167
125#define GPIO_LED1 (2 * 32 + 29) 168#define GPIO_LED1 (2 * 32 + 29)
@@ -206,7 +249,8 @@ static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
206 }, 249 },
207}; 250};
208 251
209struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata = { 252static const
253struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
210 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE, 254 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
211}; 255};
212 256
@@ -242,7 +286,10 @@ void __init eukrea_mbimxsd35_baseboard_init(void)
242 mxc_register_device(&mx3_ipu, &mx3_ipu_data); 286 mxc_register_device(&mx3_ipu, &mx3_ipu_data);
243 mxc_register_device(&mx3_fb, &mx3fb_pdata); 287 mxc_register_device(&mx3_fb, &mx3fb_pdata);
244 288
245 mxc_register_device(&imx_ssi_device0, &eukrea_mbimxsd_ssi_pdata); 289 imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
290
291 imx35_add_flexcan1(NULL);
292 imx35_add_esdhc(0, NULL);
246 293
247 gpio_request(GPIO_LED1, "LED1"); 294 gpio_request(GPIO_LED1, "LED1");
248 gpio_direction_output(GPIO_LED1, 1); 295 gpio_direction_output(GPIO_LED1, 1);
@@ -254,7 +301,7 @@ void __init eukrea_mbimxsd35_baseboard_init(void)
254 301
255 gpio_request(GPIO_LCDPWR, "LCDPWR"); 302 gpio_request(GPIO_LCDPWR, "LCDPWR");
256 gpio_direction_output(GPIO_LCDPWR, 1); 303 gpio_direction_output(GPIO_LCDPWR, 1);
257 gpio_free(GPIO_SWITCH1); 304 gpio_free(GPIO_LCDPWR);
258 305
259 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices, 306 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
260 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices)); 307 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
diff --git a/arch/arm/mach-mx3/mach-armadillo5x0.c b/arch/arm/mach-mx3/mach-armadillo5x0.c
index 68879c996a55..aaa30fe18f85 100644
--- a/arch/arm/mach-mx3/mach-armadillo5x0.c
+++ b/arch/arm/mach-mx3/mach-armadillo5x0.c
@@ -571,8 +571,6 @@ static struct sys_timer armadillo5x0_timer = {
571 571
572MACHINE_START(ARMADILLO5X0, "Armadillo-500") 572MACHINE_START(ARMADILLO5X0, "Armadillo-500")
573 /* Maintainer: Alberto Panizzo */ 573 /* Maintainer: Alberto Panizzo */
574 .phys_io = MX31_AIPS1_BASE_ADDR,
575 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
576 .boot_params = MX3x_PHYS_OFFSET + 0x100, 574 .boot_params = MX3x_PHYS_OFFSET + 0x100,
577 .map_io = mx31_map_io, 575 .map_io = mx31_map_io,
578 .init_irq = mx31_init_irq, 576 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index 2a4f8b781ba4..9fde873f5889 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -31,6 +31,7 @@
31#include <linux/usb/otg.h> 31#include <linux/usb/otg.h>
32#include <linux/usb/ulpi.h> 32#include <linux/usb/ulpi.h>
33#include <linux/fsl_devices.h> 33#include <linux/fsl_devices.h>
34#include <linux/i2c-gpio.h>
34 35
35#include <asm/mach-types.h> 36#include <asm/mach-types.h>
36#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
@@ -43,7 +44,6 @@
43#include <mach/iomux-mx35.h> 44#include <mach/iomux-mx35.h>
44#include <mach/mxc_nand.h> 45#include <mach/mxc_nand.h>
45#include <mach/mxc_ehci.h> 46#include <mach/mxc_ehci.h>
46#include <mach/ulpi.h>
47 47
48#include "devices-imx35.h" 48#include "devices-imx35.h"
49#include "devices.h" 49#include "devices.h"
@@ -53,39 +53,16 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
53}; 53};
54 54
55static const struct imxi2c_platform_data 55static const struct imxi2c_platform_data
56eukrea_cpuimx35_i2c0_data __initconst = { 56 eukrea_cpuimx35_i2c0_data __initconst = {
57 .bitrate = 50000, 57 .bitrate = 100000,
58}; 58};
59 59
60#define TSC2007_IRQGPIO (2 * 32 + 2)
61static int ts_get_pendown_state(void)
62{
63 int val = 0;
64 gpio_free(TSC2007_IRQGPIO);
65 gpio_request(TSC2007_IRQGPIO, NULL);
66 gpio_direction_input(TSC2007_IRQGPIO);
67
68 val = gpio_get_value(TSC2007_IRQGPIO);
69
70 gpio_free(TSC2007_IRQGPIO);
71 gpio_request(TSC2007_IRQGPIO, NULL);
72
73 return val ? 0 : 1;
74}
75
76static int ts_init(void)
77{
78 gpio_request(TSC2007_IRQGPIO, NULL);
79 return 0;
80}
81
82static struct tsc2007_platform_data tsc2007_info = { 60static struct tsc2007_platform_data tsc2007_info = {
83 .model = 2007, 61 .model = 2007,
84 .x_plate_ohms = 180, 62 .x_plate_ohms = 180,
85 .get_pendown_state = ts_get_pendown_state,
86 .init_platform_hw = ts_init,
87}; 63};
88 64
65#define TSC2007_IRQGPIO (2 * 32 + 2)
89static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = { 66static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
90 { 67 {
91 I2C_BOARD_INFO("pcf8563", 0x51), 68 I2C_BOARD_INFO("pcf8563", 0x51),
@@ -98,7 +75,6 @@ static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = {
98}; 75};
99 76
100static struct platform_device *devices[] __initdata = { 77static struct platform_device *devices[] __initdata = {
101 &mxc_fec_device,
102 &imx_wdt_device0, 78 &imx_wdt_device0,
103}; 79};
104 80
@@ -135,18 +111,18 @@ static struct pad_desc eukrea_cpuimx35_pads[] = {
135}; 111};
136 112
137static const struct mxc_nand_platform_data 113static const struct mxc_nand_platform_data
138eukrea_cpuimx35_nand_board_info __initconst = { 114 eukrea_cpuimx35_nand_board_info __initconst = {
139 .width = 1, 115 .width = 1,
140 .hw_ecc = 1, 116 .hw_ecc = 1,
141 .flash_bbt = 1, 117 .flash_bbt = 1,
142}; 118};
143 119
144static struct mxc_usbh_platform_data otg_pdata = { 120static struct mxc_usbh_platform_data __maybe_unused otg_pdata = {
145 .portsc = MXC_EHCI_MODE_UTMI, 121 .portsc = MXC_EHCI_MODE_UTMI,
146 .flags = MXC_EHCI_INTERFACE_DIFF_UNI, 122 .flags = MXC_EHCI_INTERFACE_DIFF_UNI,
147}; 123};
148 124
149static struct mxc_usbh_platform_data usbh1_pdata = { 125static struct mxc_usbh_platform_data __maybe_unused usbh1_pdata = {
150 .portsc = MXC_EHCI_MODE_SERIAL, 126 .portsc = MXC_EHCI_MODE_SERIAL,
151 .flags = MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY | 127 .flags = MXC_EHCI_INTERFACE_SINGLE_UNI | MXC_EHCI_INTERNAL_PHY |
152 MXC_EHCI_IPPUE_DOWN, 128 MXC_EHCI_IPPUE_DOWN,
@@ -155,6 +131,7 @@ static struct mxc_usbh_platform_data usbh1_pdata = {
155static struct fsl_usb2_platform_data otg_device_pdata = { 131static struct fsl_usb2_platform_data otg_device_pdata = {
156 .operating_mode = FSL_USB2_DR_DEVICE, 132 .operating_mode = FSL_USB2_DR_DEVICE,
157 .phy_mode = FSL_USB2_PHY_UTMI, 133 .phy_mode = FSL_USB2_PHY_UTMI,
134 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
158}; 135};
159 136
160static int otg_mode_host; 137static int otg_mode_host;
@@ -180,6 +157,7 @@ static void __init mxc_board_init(void)
180 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads, 157 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads,
181 ARRAY_SIZE(eukrea_cpuimx35_pads)); 158 ARRAY_SIZE(eukrea_cpuimx35_pads));
182 159
160 imx35_add_fec(NULL);
183 platform_add_devices(devices, ARRAY_SIZE(devices)); 161 platform_add_devices(devices, ARRAY_SIZE(devices));
184 162
185 imx35_add_imx_uart0(&uart_pdata); 163 imx35_add_imx_uart0(&uart_pdata);
@@ -189,18 +167,13 @@ static void __init mxc_board_init(void)
189 ARRAY_SIZE(eukrea_cpuimx35_i2c_devices)); 167 ARRAY_SIZE(eukrea_cpuimx35_i2c_devices));
190 imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data); 168 imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data);
191 169
192#if defined(CONFIG_USB_ULPI) 170 if (otg_mode_host)
193 if (otg_mode_host) {
194 otg_pdata.otg = otg_ulpi_create(&mxc_ulpi_access_ops,
195 ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT);
196
197 mxc_register_device(&mxc_otg_host, &otg_pdata); 171 mxc_register_device(&mxc_otg_host, &otg_pdata);
198 } 172 else
199 mxc_register_device(&mxc_usbh1, &usbh1_pdata);
200#endif
201 if (!otg_mode_host)
202 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata); 173 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
203 174
175 mxc_register_device(&mxc_usbh1, &usbh1_pdata);
176
204#ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD 177#ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD
205 eukrea_mbimxsd35_baseboard_init(); 178 eukrea_mbimxsd35_baseboard_init();
206#endif 179#endif
@@ -217,8 +190,6 @@ struct sys_timer eukrea_cpuimx35_timer = {
217 190
218MACHINE_START(EUKREA_CPUIMX35, "Eukrea CPUIMX35") 191MACHINE_START(EUKREA_CPUIMX35, "Eukrea CPUIMX35")
219 /* Maintainer: Eukrea Electromatique */ 192 /* Maintainer: Eukrea Electromatique */
220 .phys_io = MX35_AIPS1_BASE_ADDR,
221 .io_pg_offst = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
222 .boot_params = MX3x_PHYS_OFFSET + 0x100, 193 .boot_params = MX3x_PHYS_OFFSET + 0x100,
223 .map_io = mx35_map_io, 194 .map_io = mx35_map_io,
224 .init_irq = mx35_init_irq, 195 .init_irq = mx35_init_irq,
diff --git a/arch/arm/mach-mx3/mach-kzm_arm11_01.c b/arch/arm/mach-mx3/mach-kzm_arm11_01.c
index 5b23e416d6c7..042cd5655e17 100644
--- a/arch/arm/mach-mx3/mach-kzm_arm11_01.c
+++ b/arch/arm/mach-mx3/mach-kzm_arm11_01.c
@@ -274,8 +274,6 @@ static struct sys_timer kzm_timer = {
274 * initialize __mach_desc_KZM_ARM11_01 data structure. 274 * initialize __mach_desc_KZM_ARM11_01 data structure.
275 */ 275 */
276MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01") 276MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01")
277 .phys_io = MX31_AIPS1_BASE_ADDR,
278 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
279 .boot_params = MX3x_PHYS_OFFSET + 0x100, 277 .boot_params = MX3x_PHYS_OFFSET + 0x100,
280 .map_io = kzm_map_io, 278 .map_io = kzm_map_io,
281 .init_irq = mx31_init_irq, 279 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c
index 6fe69e124d30..5c1d0e86c91e 100644
--- a/arch/arm/mach-mx3/mach-mx31_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx31_3ds.c
@@ -301,8 +301,6 @@ static struct sys_timer mx31_3ds_timer = {
301 */ 301 */
302MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)") 302MACHINE_START(MX31_3DS, "Freescale MX31PDK (3DS)")
303 /* Maintainer: Freescale Semiconductor, Inc. */ 303 /* Maintainer: Freescale Semiconductor, Inc. */
304 .phys_io = MX31_AIPS1_BASE_ADDR,
305 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
306 .boot_params = MX3x_PHYS_OFFSET + 0x100, 304 .boot_params = MX3x_PHYS_OFFSET + 0x100,
307 .map_io = mx31_3ds_map_io, 305 .map_io = mx31_3ds_map_io,
308 .init_irq = mx31_init_irq, 306 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx31ads.c b/arch/arm/mach-mx3/mach-mx31ads.c
index 94b3e7c42404..b993b9bf6179 100644
--- a/arch/arm/mach-mx3/mach-mx31ads.c
+++ b/arch/arm/mach-mx3/mach-mx31ads.c
@@ -22,13 +22,13 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24 24
25#include <mach/hardware.h>
26#include <asm/mach-types.h> 25#include <asm/mach-types.h>
27#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
28#include <asm/mach/time.h> 27#include <asm/mach/time.h>
29#include <asm/memory.h> 28#include <asm/memory.h>
30#include <asm/mach/map.h> 29#include <asm/mach/map.h>
31#include <mach/common.h> 30#include <mach/common.h>
31#include <mach/board-mx31ads.h>
32#include <mach/iomux-mx3.h> 32#include <mach/iomux-mx3.h>
33 33
34#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1 34#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
@@ -40,10 +40,6 @@
40#include "devices-imx31.h" 40#include "devices-imx31.h"
41#include "devices.h" 41#include "devices.h"
42 42
43/* Base address of PBC controller */
44#define PBC_BASE_ADDRESS MX31_CS4_BASE_ADDR_VIRT
45/* Offsets for the PBC Controller register */
46
47/* PBC Board interrupt status register */ 43/* PBC Board interrupt status register */
48#define PBC_INTSTATUS 0x000016 44#define PBC_INTSTATUS 0x000016
49 45
@@ -67,7 +63,6 @@
67#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS) 63#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
68#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4) 64#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
69 65
70#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START)
71#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) 66#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
72 67
73#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10) 68#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10)
@@ -517,7 +512,7 @@ static unsigned int ssi_pins[] = {
517 512
518static void mxc_init_audio(void) 513static void mxc_init_audio(void)
519{ 514{
520 mxc_register_device(&imx_ssi_device0, NULL); 515 imx31_add_imx_ssi(0, NULL);
521 mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi"); 516 mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi");
522} 517}
523 518
@@ -574,8 +569,6 @@ static struct sys_timer mx31ads_timer = {
574 */ 569 */
575MACHINE_START(MX31ADS, "Freescale MX31ADS") 570MACHINE_START(MX31ADS, "Freescale MX31ADS")
576 /* Maintainer: Freescale Semiconductor, Inc. */ 571 /* Maintainer: Freescale Semiconductor, Inc. */
577 .phys_io = MX31_AIPS1_BASE_ADDR,
578 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
579 .boot_params = MX3x_PHYS_OFFSET + 0x100, 572 .boot_params = MX3x_PHYS_OFFSET + 0x100,
580 .map_io = mx31ads_map_io, 573 .map_io = mx31ads_map_io,
581 .init_irq = mx31ads_init_irq, 574 .init_irq = mx31ads_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx31lilly.c b/arch/arm/mach-mx3/mach-mx31lilly.c
index 7c37daabb757..42f47faa6fd6 100644
--- a/arch/arm/mach-mx3/mach-mx31lilly.c
+++ b/arch/arm/mach-mx3/mach-mx31lilly.c
@@ -348,8 +348,6 @@ static struct sys_timer mx31lilly_timer = {
348}; 348};
349 349
350MACHINE_START(LILLY1131, "INCO startec LILLY-1131") 350MACHINE_START(LILLY1131, "INCO startec LILLY-1131")
351 .phys_io = MX31_AIPS1_BASE_ADDR,
352 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
353 .boot_params = MX3x_PHYS_OFFSET + 0x100, 351 .boot_params = MX3x_PHYS_OFFSET + 0x100,
354 .map_io = mx31_map_io, 352 .map_io = mx31_map_io,
355 .init_irq = mx31_init_irq, 353 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx31lite.c b/arch/arm/mach-mx3/mach-mx31lite.c
index f66a9576d8c2..b93895814cdf 100644
--- a/arch/arm/mach-mx3/mach-mx31lite.c
+++ b/arch/arm/mach-mx3/mach-mx31lite.c
@@ -282,8 +282,6 @@ struct sys_timer mx31lite_timer = {
282 282
283MACHINE_START(MX31LITE, "LogicPD i.MX31 SOM") 283MACHINE_START(MX31LITE, "LogicPD i.MX31 SOM")
284 /* Maintainer: Freescale Semiconductor, Inc. */ 284 /* Maintainer: Freescale Semiconductor, Inc. */
285 .phys_io = MX31_AIPS1_BASE_ADDR,
286 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
287 .boot_params = MX3x_PHYS_OFFSET + 0x100, 285 .boot_params = MX3x_PHYS_OFFSET + 0x100,
288 .map_io = mx31lite_map_io, 286 .map_io = mx31lite_map_io,
289 .init_irq = mx31_init_irq, 287 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx31moboard.c b/arch/arm/mach-mx3/mach-mx31moboard.c
index 7a075e8bf2d4..eb5f426df224 100644
--- a/arch/arm/mach-mx3/mach-mx31moboard.c
+++ b/arch/arm/mach-mx3/mach-mx31moboard.c
@@ -560,8 +560,6 @@ struct sys_timer mx31moboard_timer = {
560 560
561MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard") 561MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard")
562 /* Maintainer: Valentin Longchamp, EPFL Mobots group */ 562 /* Maintainer: Valentin Longchamp, EPFL Mobots group */
563 .phys_io = MX31_AIPS1_BASE_ADDR,
564 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
565 .boot_params = MX3x_PHYS_OFFSET + 0x100, 563 .boot_params = MX3x_PHYS_OFFSET + 0x100,
566 .map_io = mx31_map_io, 564 .map_io = mx31_map_io,
567 .init_irq = mx31_init_irq, 565 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-mx35_3ds.c b/arch/arm/mach-mx3/mach-mx35_3ds.c
index 1c30d7212f17..05f628d90725 100644
--- a/arch/arm/mach-mx3/mach-mx35_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx35_3ds.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2009 Marc Kleine-Budde, Pengutronix
3 * 4 *
4 * Author: Fabio Estevam <fabio.estevam@freescale.com> 5 * Author: Fabio Estevam <fabio.estevam@freescale.com>
5 * 6 *
@@ -27,6 +28,8 @@
27#include <linux/gpio.h> 28#include <linux/gpio.h>
28#include <linux/fsl_devices.h> 29#include <linux/fsl_devices.h>
29 30
31#include <linux/mtd/physmap.h>
32
30#include <asm/mach-types.h> 33#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
32#include <asm/mach/time.h> 35#include <asm/mach/time.h>
@@ -35,6 +38,7 @@
35#include <mach/hardware.h> 38#include <mach/hardware.h>
36#include <mach/common.h> 39#include <mach/common.h>
37#include <mach/iomux-mx35.h> 40#include <mach/iomux-mx35.h>
41#include <mach/mxc_ehci.h>
38 42
39#include "devices-imx35.h" 43#include "devices-imx35.h"
40#include "devices.h" 44#include "devices.h"
@@ -43,8 +47,34 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
43 .flags = IMXUART_HAVE_RTSCTS, 47 .flags = IMXUART_HAVE_RTSCTS,
44}; 48};
45 49
50static struct physmap_flash_data mx35pdk_flash_data = {
51 .width = 2,
52};
53
54static struct resource mx35pdk_flash_resource = {
55 .start = MX35_CS0_BASE_ADDR,
56 .end = MX35_CS0_BASE_ADDR + SZ_64M - 1,
57 .flags = IORESOURCE_MEM,
58};
59
60static struct platform_device mx35pdk_flash = {
61 .name = "physmap-flash",
62 .id = 0,
63 .dev = {
64 .platform_data = &mx35pdk_flash_data,
65 },
66 .resource = &mx35pdk_flash_resource,
67 .num_resources = 1,
68};
69
70static const struct mxc_nand_platform_data mx35pdk_nand_board_info __initconst = {
71 .width = 1,
72 .hw_ecc = 1,
73 .flash_bbt = 1,
74};
75
46static struct platform_device *devices[] __initdata = { 76static struct platform_device *devices[] __initdata = {
47 &mxc_fec_device, 77 &mx35pdk_flash,
48}; 78};
49 79
50static struct pad_desc mx35pdk_pads[] = { 80static struct pad_desc mx35pdk_pads[] = {
@@ -75,14 +105,24 @@ static struct pad_desc mx35pdk_pads[] = {
75 /* USBOTG */ 105 /* USBOTG */
76 MX35_PAD_USBOTG_PWR__USB_TOP_USBOTG_PWR, 106 MX35_PAD_USBOTG_PWR__USB_TOP_USBOTG_PWR,
77 MX35_PAD_USBOTG_OC__USB_TOP_USBOTG_OC, 107 MX35_PAD_USBOTG_OC__USB_TOP_USBOTG_OC,
108 /* USBH1 */
109 MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR,
110 MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC,
78}; 111};
79 112
80/* OTG config */ 113/* OTG config */
81static struct fsl_usb2_platform_data usb_pdata = { 114static struct fsl_usb2_platform_data usb_otg_pdata = {
82 .operating_mode = FSL_USB2_DR_DEVICE, 115 .operating_mode = FSL_USB2_DR_DEVICE,
83 .phy_mode = FSL_USB2_PHY_UTMI_WIDE, 116 .phy_mode = FSL_USB2_PHY_UTMI_WIDE,
84}; 117};
85 118
119/* USB HOST config */
120static struct mxc_usbh_platform_data usb_host_pdata = {
121 .portsc = MXC_EHCI_MODE_SERIAL,
122 .flags = MXC_EHCI_INTERFACE_SINGLE_UNI |
123 MXC_EHCI_INTERNAL_PHY,
124};
125
86/* 126/*
87 * Board specific initialization. 127 * Board specific initialization.
88 */ 128 */
@@ -90,11 +130,16 @@ static void __init mxc_board_init(void)
90{ 130{
91 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads)); 131 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads));
92 132
133 imx35_add_fec(NULL);
93 platform_add_devices(devices, ARRAY_SIZE(devices)); 134 platform_add_devices(devices, ARRAY_SIZE(devices));
94 135
95 imx35_add_imx_uart0(&uart_pdata); 136 imx35_add_imx_uart0(&uart_pdata);
96 137
97 mxc_register_device(&mxc_otg_udc_device, &usb_pdata); 138 mxc_register_device(&mxc_otg_udc_device, &usb_otg_pdata);
139
140 mxc_register_device(&mxc_usbh1, &usb_host_pdata);
141
142 imx35_add_mxc_nand(&mx35pdk_nand_board_info);
98} 143}
99 144
100static void __init mx35pdk_timer_init(void) 145static void __init mx35pdk_timer_init(void)
@@ -108,8 +153,6 @@ struct sys_timer mx35pdk_timer = {
108 153
109MACHINE_START(MX35_3DS, "Freescale MX35PDK") 154MACHINE_START(MX35_3DS, "Freescale MX35PDK")
110 /* Maintainer: Freescale Semiconductor, Inc */ 155 /* Maintainer: Freescale Semiconductor, Inc */
111 .phys_io = MX35_AIPS1_BASE_ADDR,
112 .io_pg_offst = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
113 .boot_params = MX3x_PHYS_OFFSET + 0x100, 156 .boot_params = MX3x_PHYS_OFFSET + 0x100,
114 .map_io = mx35_map_io, 157 .map_io = mx35_map_io,
115 .init_irq = mx35_init_irq, 158 .init_irq = mx35_init_irq,
diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c
index 214de11b20b9..86e86c1300d5 100644
--- a/arch/arm/mach-mx3/mach-pcm037.c
+++ b/arch/arm/mach-mx3/mach-pcm037.c
@@ -680,8 +680,6 @@ struct sys_timer pcm037_timer = {
680 680
681MACHINE_START(PCM037, "Phytec Phycore pcm037") 681MACHINE_START(PCM037, "Phytec Phycore pcm037")
682 /* Maintainer: Pengutronix */ 682 /* Maintainer: Pengutronix */
683 .phys_io = MX31_AIPS1_BASE_ADDR,
684 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
685 .boot_params = MX3x_PHYS_OFFSET + 0x100, 683 .boot_params = MX3x_PHYS_OFFSET + 0x100,
686 .map_io = mx31_map_io, 684 .map_io = mx31_map_io,
687 .init_irq = mx31_init_irq, 685 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mach-pcm037_eet.c b/arch/arm/mach-mx3/mach-pcm037_eet.c
index c8b98218efee..99e0894e07db 100644
--- a/arch/arm/mach-mx3/mach-pcm037_eet.c
+++ b/arch/arm/mach-mx3/mach-pcm037_eet.c
@@ -19,6 +19,7 @@
19 19
20#include "pcm037.h" 20#include "pcm037.h"
21#include "devices.h" 21#include "devices.h"
22#include "devices-imx31.h"
22 23
23static unsigned int pcm037_eet_pins[] = { 24static unsigned int pcm037_eet_pins[] = {
24 /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */ 25 /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */
@@ -181,7 +182,7 @@ static int eet_init_devices(void)
181 /* SPI */ 182 /* SPI */
182 spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev)); 183 spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev));
183#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) 184#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
184 imx35_add_spi_imx0(&pcm037_spi1_pdata); 185 imx31_add_spi_imx0(&pcm037_spi1_pdata);
185#endif 186#endif
186 187
187 platform_device_register(&pcm037_gpio_keys_device); 188 platform_device_register(&pcm037_gpio_keys_device);
diff --git a/arch/arm/mach-mx3/mach-pcm043.c b/arch/arm/mach-mx3/mach-pcm043.c
index 28886f0e62f9..4e1de87995d4 100644
--- a/arch/arm/mach-mx3/mach-pcm043.c
+++ b/arch/arm/mach-mx3/mach-pcm043.c
@@ -42,7 +42,6 @@
42#include <mach/mxc_ehci.h> 42#include <mach/mxc_ehci.h>
43#include <mach/ulpi.h> 43#include <mach/ulpi.h>
44#include <mach/audmux.h> 44#include <mach/audmux.h>
45#include <mach/ssi.h>
46 45
47#include "devices-imx35.h" 46#include "devices-imx35.h"
48#include "devices.h" 47#include "devices.h"
@@ -141,7 +140,6 @@ static struct i2c_board_info pcm043_i2c_devices[] = {
141 140
142static struct platform_device *devices[] __initdata = { 141static struct platform_device *devices[] __initdata = {
143 &pcm043_flash, 142 &pcm043_flash,
144 &mxc_fec_device,
145 &imx_wdt_device0, 143 &imx_wdt_device0,
146}; 144};
147 145
@@ -217,6 +215,13 @@ static struct pad_desc pcm043_pads[] = {
217 /* CAN2 */ 215 /* CAN2 */
218 MX35_PAD_TX5_RX0__CAN2_TXCAN, 216 MX35_PAD_TX5_RX0__CAN2_TXCAN,
219 MX35_PAD_TX4_RX1__CAN2_RXCAN, 217 MX35_PAD_TX4_RX1__CAN2_RXCAN,
218 /* esdhc */
219 MX35_PAD_SD1_CMD__ESDHC1_CMD,
220 MX35_PAD_SD1_CLK__ESDHC1_CLK,
221 MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
222 MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
223 MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
224 MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
220}; 225};
221 226
222#define AC97_GPIO_TXFS (1 * 32 + 31) 227#define AC97_GPIO_TXFS (1 * 32 + 31)
@@ -293,7 +298,7 @@ err1:
293 mdelay(1); 298 mdelay(1);
294} 299}
295 300
296static struct imx_ssi_platform_data pcm043_ssi_pdata = { 301static const struct imx_ssi_platform_data pcm043_ssi_pdata __initconst = {
297 .ac97_reset = pcm043_ac97_cold_reset, 302 .ac97_reset = pcm043_ac97_cold_reset,
298 .ac97_warm_reset = pcm043_ac97_warm_reset, 303 .ac97_warm_reset = pcm043_ac97_warm_reset,
299 .flags = IMX_SSI_USE_AC97, 304 .flags = IMX_SSI_USE_AC97,
@@ -357,11 +362,12 @@ static void __init mxc_board_init(void)
357 MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */ 362 MXC_AUDMUX_V2_PTCR_TCLKDIR, /* clock is output */
358 MXC_AUDMUX_V2_PDCR_RXDSEL(3)); 363 MXC_AUDMUX_V2_PDCR_RXDSEL(3));
359 364
365 imx35_add_fec(NULL);
360 platform_add_devices(devices, ARRAY_SIZE(devices)); 366 platform_add_devices(devices, ARRAY_SIZE(devices));
361 367
362 imx35_add_imx_uart0(&uart_pdata); 368 imx35_add_imx_uart0(&uart_pdata);
363 imx35_add_mxc_nand(&pcm037_nand_board_info); 369 imx35_add_mxc_nand(&pcm037_nand_board_info);
364 mxc_register_device(&imx_ssi_device0, &pcm043_ssi_pdata); 370 imx35_add_imx_ssi(0, &pcm043_ssi_pdata);
365 371
366 imx35_add_imx_uart1(&uart_pdata); 372 imx35_add_imx_uart1(&uart_pdata);
367 373
@@ -389,6 +395,7 @@ static void __init mxc_board_init(void)
389 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata); 395 mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
390 396
391 imx35_add_flexcan1(NULL); 397 imx35_add_flexcan1(NULL);
398 imx35_add_esdhc(0, NULL);
392} 399}
393 400
394static void __init pcm043_timer_init(void) 401static void __init pcm043_timer_init(void)
@@ -402,8 +409,6 @@ struct sys_timer pcm043_timer = {
402 409
403MACHINE_START(PCM043, "Phytec Phycore pcm043") 410MACHINE_START(PCM043, "Phytec Phycore pcm043")
404 /* Maintainer: Pengutronix */ 411 /* Maintainer: Pengutronix */
405 .phys_io = MX35_AIPS1_BASE_ADDR,
406 .io_pg_offst = ((MX35_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
407 .boot_params = MX3x_PHYS_OFFSET + 0x100, 412 .boot_params = MX3x_PHYS_OFFSET + 0x100,
408 .map_io = mx35_map_io, 413 .map_io = mx35_map_io,
409 .init_irq = mx35_init_irq, 414 .init_irq = mx35_init_irq,
diff --git a/arch/arm/mach-mx3/mach-qong.c b/arch/arm/mach-mx3/mach-qong.c
index c8c380eef74c..fd1050c40964 100644
--- a/arch/arm/mach-mx3/mach-qong.c
+++ b/arch/arm/mach-mx3/mach-qong.c
@@ -270,8 +270,6 @@ static struct sys_timer qong_timer = {
270 270
271MACHINE_START(QONG, "Dave/DENX QongEVB-LITE") 271MACHINE_START(QONG, "Dave/DENX QongEVB-LITE")
272 /* Maintainer: DENX Software Engineering GmbH */ 272 /* Maintainer: DENX Software Engineering GmbH */
273 .phys_io = MX31_AIPS1_BASE_ADDR,
274 .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
275 .boot_params = MX3x_PHYS_OFFSET + 0x100, 273 .boot_params = MX3x_PHYS_OFFSET + 0x100,
276 .map_io = mx31_map_io, 274 .map_io = mx31_map_io,
277 .init_irq = mx31_init_irq, 275 .init_irq = mx31_init_irq,
diff --git a/arch/arm/mach-mx3/mm.c b/arch/arm/mach-mx3/mm.c
index 20e48c0195c4..b4ffc531a82c 100644
--- a/arch/arm/mach-mx3/mm.c
+++ b/arch/arm/mach-mx3/mm.c
@@ -110,6 +110,24 @@ void __init mx35_init_irq(void)
110static int mxc_init_l2x0(void) 110static int mxc_init_l2x0(void)
111{ 111{
112 void __iomem *l2x0_base; 112 void __iomem *l2x0_base;
113 void __iomem *clkctl_base;
114/*
115 * First of all, we must repair broken chip settings. There are some
116 * i.MX35 CPUs in the wild, comming with bogus L2 cache settings. These
117 * misconfigured CPUs will run amok immediately when the L2 cache gets enabled.
118 * Workaraound is to setup the correct register setting prior enabling the
119 * L2 cache. This should not hurt already working CPUs, as they are using the
120 * same value
121 */
122#define L2_MEM_VAL 0x10
123
124 clkctl_base = ioremap(MX35_CLKCTL_BASE_ADDR, 4096);
125 if (clkctl_base != NULL) {
126 writel(0x00000515, clkctl_base + L2_MEM_VAL);
127 iounmap(clkctl_base);
128 } else {
129 pr_err("L2 cache: Cannot fix timing. Trying to continue without\n");
130 }
113 131
114 l2x0_base = ioremap(L2CC_BASE_ADDR, 4096); 132 l2x0_base = ioremap(L2CC_BASE_ADDR, 4096);
115 if (IS_ERR(l2x0_base)) { 133 if (IS_ERR(l2x0_base)) {
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
index 0848db5dd364..a2df9ac37996 100644
--- a/arch/arm/mach-mx5/Kconfig
+++ b/arch/arm/mach-mx5/Kconfig
@@ -5,11 +5,14 @@ config ARCH_MX51
5 default y 5 default y
6 select MXC_TZIC 6 select MXC_TZIC
7 select ARCH_MXC_IOMUX_V3 7 select ARCH_MXC_IOMUX_V3
8 select ARCH_MXC_AUDMUX_V2
8 9
9comment "MX5 platforms:" 10comment "MX5 platforms:"
10 11
11config MACH_MX51_BABBAGE 12config MACH_MX51_BABBAGE
12 bool "Support MX51 BABBAGE platforms" 13 bool "Support MX51 BABBAGE platforms"
14 select IMX_HAVE_PLATFORM_IMX_I2C
15 select IMX_HAVE_PLATFORM_IMX_UART
13 help 16 help
14 Include support for MX51 Babbage platform, also known as MX51EVK in 17 Include support for MX51 Babbage platform, also known as MX51EVK in
15 u-boot. This includes specific configurations for the board and its 18 u-boot. This includes specific configurations for the board and its
@@ -17,6 +20,8 @@ config MACH_MX51_BABBAGE
17 20
18config MACH_MX51_3DS 21config MACH_MX51_3DS
19 bool "Support MX51PDK (3DS)" 22 bool "Support MX51PDK (3DS)"
23 select IMX_HAVE_PLATFORM_IMX_UART
24 select IMX_HAVE_PLATFORM_SPI_IMX
20 select MXC_DEBUG_BOARD 25 select MXC_DEBUG_BOARD
21 help 26 help
22 Include support for MX51PDK (3DS) platform. This includes specific 27 Include support for MX51PDK (3DS) platform. This includes specific
@@ -24,6 +29,10 @@ config MACH_MX51_3DS
24 29
25config MACH_EUKREA_CPUIMX51 30config MACH_EUKREA_CPUIMX51
26 bool "Support Eukrea CPUIMX51 module" 31 bool "Support Eukrea CPUIMX51 module"
32 select IMX_HAVE_PLATFORM_IMX_I2C
33 select IMX_HAVE_PLATFORM_IMX_UART
34 select IMX_HAVE_PLATFORM_MXC_NAND
35 select IMX_HAVE_PLATFORM_SPI_IMX
27 help 36 help
28 Include support for Eukrea CPUIMX51 platform. This includes 37 Include support for Eukrea CPUIMX51 platform. This includes
29 specific configurations for the module and its peripherals. 38 specific configurations for the module and its peripherals.
@@ -36,10 +45,43 @@ choice
36config MACH_EUKREA_MBIMX51_BASEBOARD 45config MACH_EUKREA_MBIMX51_BASEBOARD
37 prompt "Eukrea MBIMX51 development board" 46 prompt "Eukrea MBIMX51 development board"
38 bool 47 bool
48 select IMX_HAVE_PLATFORM_ESDHC
39 help 49 help
40 This adds board specific devices that can be found on Eukrea's 50 This adds board specific devices that can be found on Eukrea's
41 MBIMX51 evaluation board. 51 MBIMX51 evaluation board.
42 52
43endchoice 53endchoice
44 54
55config MACH_EUKREA_CPUIMX51SD
56 bool "Support Eukrea CPUIMX51SD module"
57 select IMX_HAVE_PLATFORM_IMX_I2C
58 select IMX_HAVE_PLATFORM_SPI_IMX
59 select IMX_HAVE_PLATFORM_IMX_UART
60 select IMX_HAVE_PLATFORM_MXC_NAND
61 help
62 Include support for Eukrea CPUIMX51SD platform. This includes
63 specific configurations for the module and its peripherals.
64
65choice
66 prompt "Baseboard"
67 depends on MACH_EUKREA_CPUIMX51SD
68 default MACH_EUKREA_MBIMXSD51_BASEBOARD
69
70config MACH_EUKREA_MBIMXSD51_BASEBOARD
71 prompt "Eukrea MBIMXSD development board"
72 bool
73 select IMX_HAVE_PLATFORM_ESDHC
74 help
75 This adds board specific devices that can be found on Eukrea's
76 MBIMXSD evaluation board.
77
78endchoice
79
80config MACH_MX51_EFIKAMX
81 bool "Support MX51 Genesi Efika MX nettop"
82 select IMX_HAVE_PLATFORM_IMX_UART
83 help
84 Include support for Genesi Efika MX nettop. This includes specific
85 configurations for the board and its peripherals.
86
45endif 87endif
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
index 86c66e7f52f3..1769c161a60d 100644
--- a/arch/arm/mach-mx5/Makefile
+++ b/arch/arm/mach-mx5/Makefile
@@ -9,3 +9,6 @@ obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o
9obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o 9obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o
10obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o 10obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o
11obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o 11obj-$(CONFIG_MACH_EUKREA_MBIMX51_BASEBOARD) += eukrea_mbimx51-baseboard.o
12obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o
13obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o
14obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o
diff --git a/arch/arm/mach-mx5/board-cpuimx51.c b/arch/arm/mach-mx5/board-cpuimx51.c
index 623607a20f57..6a9792fd0a76 100644
--- a/arch/arm/mach-mx5/board-cpuimx51.c
+++ b/arch/arm/mach-mx5/board-cpuimx51.c
@@ -28,9 +28,7 @@
28#include <mach/eukrea-baseboards.h> 28#include <mach/eukrea-baseboards.h>
29#include <mach/common.h> 29#include <mach/common.h>
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <mach/imx-uart.h>
32#include <mach/iomux-mx51.h> 31#include <mach/iomux-mx51.h>
33#include <mach/i2c.h>
34#include <mach/mxc_ehci.h> 32#include <mach/mxc_ehci.h>
35 33
36#include <asm/irq.h> 34#include <asm/irq.h>
@@ -39,6 +37,7 @@
39#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
40#include <asm/mach/time.h> 38#include <asm/mach/time.h>
41 39
40#include "devices-imx51.h"
42#include "devices.h" 41#include "devices.h"
43 42
44#define CPUIMX51_USBH1_STP (0*32 + 27) 43#define CPUIMX51_USBH1_STP (0*32 + 27)
@@ -109,7 +108,6 @@ static struct platform_device serial_device = {
109#endif 108#endif
110 109
111static struct platform_device *devices[] __initdata = { 110static struct platform_device *devices[] __initdata = {
112 &mxc_fec_device,
113#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 111#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
114 &serial_device, 112 &serial_device,
115#endif 113#endif
@@ -148,11 +146,19 @@ static struct pad_desc eukrea_cpuimx51_pads[] = {
148 MX51_PAD_USBH1_STP__USBH1_STP, 146 MX51_PAD_USBH1_STP__USBH1_STP,
149}; 147};
150 148
151static struct imxuart_platform_data uart_pdata = { 149static const struct mxc_nand_platform_data
150 eukrea_cpuimx51_nand_board_info __initconst = {
151 .width = 1,
152 .hw_ecc = 1,
153 .flash_bbt = 1,
154};
155
156static const struct imxuart_platform_data uart_pdata __initconst = {
152 .flags = IMXUART_HAVE_RTSCTS, 157 .flags = IMXUART_HAVE_RTSCTS,
153}; 158};
154 159
155static struct imxi2c_platform_data eukrea_cpuimx51_i2c_data = { 160static const
161struct imxi2c_platform_data eukrea_cpuimx51_i2c_data __initconst = {
156 .bitrate = 100000, 162 .bitrate = 100000,
157}; 163};
158 164
@@ -239,7 +245,9 @@ static void __init eukrea_cpuimx51_init(void)
239 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx51_pads, 245 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx51_pads,
240 ARRAY_SIZE(eukrea_cpuimx51_pads)); 246 ARRAY_SIZE(eukrea_cpuimx51_pads));
241 247
242 mxc_register_device(&mxc_uart_device0, &uart_pdata); 248 imx51_add_imx_uart(0, &uart_pdata);
249 imx51_add_mxc_nand(&eukrea_cpuimx51_nand_board_info);
250
243 gpio_request(CPUIMX51_QUARTA_GPIO, "quarta_irq"); 251 gpio_request(CPUIMX51_QUARTA_GPIO, "quarta_irq");
244 gpio_direction_input(CPUIMX51_QUARTA_GPIO); 252 gpio_direction_input(CPUIMX51_QUARTA_GPIO);
245 gpio_free(CPUIMX51_QUARTA_GPIO); 253 gpio_free(CPUIMX51_QUARTA_GPIO);
@@ -253,9 +261,10 @@ static void __init eukrea_cpuimx51_init(void)
253 gpio_direction_input(CPUIMX51_QUARTD_GPIO); 261 gpio_direction_input(CPUIMX51_QUARTD_GPIO);
254 gpio_free(CPUIMX51_QUARTD_GPIO); 262 gpio_free(CPUIMX51_QUARTD_GPIO);
255 263
264 imx51_add_fec(NULL);
256 platform_add_devices(devices, ARRAY_SIZE(devices)); 265 platform_add_devices(devices, ARRAY_SIZE(devices));
257 266
258 mxc_register_device(&mxc_i2c_device1, &eukrea_cpuimx51_i2c_data); 267 imx51_add_imx_i2c(1, &eukrea_cpuimx51_i2c_data);
259 i2c_register_board_info(1, eukrea_cpuimx51_i2c_devices, 268 i2c_register_board_info(1, eukrea_cpuimx51_i2c_devices,
260 ARRAY_SIZE(eukrea_cpuimx51_i2c_devices)); 269 ARRAY_SIZE(eukrea_cpuimx51_i2c_devices));
261 270
@@ -283,8 +292,6 @@ static struct sys_timer mxc_timer = {
283 292
284MACHINE_START(EUKREA_CPUIMX51, "Eukrea CPUIMX51 Module") 293MACHINE_START(EUKREA_CPUIMX51, "Eukrea CPUIMX51 Module")
285 /* Maintainer: Eric Bénard <eric@eukrea.com> */ 294 /* Maintainer: Eric Bénard <eric@eukrea.com> */
286 .phys_io = MX51_AIPS1_BASE_ADDR,
287 .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
288 .boot_params = PHYS_OFFSET + 0x100, 295 .boot_params = PHYS_OFFSET + 0x100,
289 .map_io = mx51_map_io, 296 .map_io = mx51_map_io,
290 .init_irq = mx51_init_irq, 297 .init_irq = mx51_init_irq,
diff --git a/arch/arm/mach-mx5/board-cpuimx51sd.c b/arch/arm/mach-mx5/board-cpuimx51sd.c
new file mode 100644
index 000000000000..4b3a6119c5fb
--- /dev/null
+++ b/arch/arm/mach-mx5/board-cpuimx51sd.c
@@ -0,0 +1,331 @@
1/*
2 *
3 * Copyright (C) 2010 Eric Bénard <eric@eukrea.com>
4 *
5 * based on board-mx51_babbage.c which is
6 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com>
8 *
9 * The code contained herein is licensed under the GNU General Public
10 * License. You may obtain a copy of the GNU General Public License
11 * Version 2 or later at the following locations:
12 *
13 * http://www.opensource.org/licenses/gpl-license.html
14 * http://www.gnu.org/copyleft/gpl.html
15 */
16
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/i2c.h>
20#include <linux/i2c/tsc2007.h>
21#include <linux/gpio.h>
22#include <linux/delay.h>
23#include <linux/io.h>
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/fsl_devices.h>
27#include <linux/i2c-gpio.h>
28#include <linux/spi/spi.h>
29#include <linux/can/platform/mcp251x.h>
30
31#include <mach/eukrea-baseboards.h>
32#include <mach/common.h>
33#include <mach/hardware.h>
34#include <mach/iomux-mx51.h>
35#include <mach/mxc_ehci.h>
36
37#include <asm/irq.h>
38#include <asm/setup.h>
39#include <asm/mach-types.h>
40#include <asm/mach/arch.h>
41#include <asm/mach/time.h>
42
43#include "devices-imx51.h"
44#include "devices.h"
45
46#define USBH1_RST (1*32 + 28)
47#define ETH_RST (1*32 + 31)
48#define TSC2007_IRQGPIO (2*32 + 12)
49#define CAN_IRQGPIO (0*32 + 1)
50#define CAN_RST (3*32 + 15)
51#define CAN_NCS (3*32 + 24)
52#define CAN_RXOBF (0*32 + 4)
53#define CAN_RX1BF (0*32 + 6)
54#define CAN_TXORTS (0*32 + 7)
55#define CAN_TX1RTS (0*32 + 8)
56#define CAN_TX2RTS (0*32 + 9)
57#define I2C_SCL (3*32 + 16)
58#define I2C_SDA (3*32 + 17)
59
60/* USB_CTRL_1 */
61#define MX51_USB_CTRL_1_OFFSET 0x10
62#define MX51_USB_CTRL_UH1_EXT_CLK_EN (1 << 25)
63
64#define MX51_USB_PLLDIV_12_MHZ 0x00
65#define MX51_USB_PLL_DIV_19_2_MHZ 0x01
66#define MX51_USB_PLL_DIV_24_MHZ 0x02
67
68#define CPUIMX51SD_GPIO_3_12 IOMUX_PAD(0x57C, 0x194, 3, 0x0, 0, \
69 MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
70
71static struct pad_desc eukrea_cpuimx51sd_pads[] = {
72 /* UART1 */
73 MX51_PAD_UART1_RXD__UART1_RXD,
74 MX51_PAD_UART1_TXD__UART1_TXD,
75 MX51_PAD_UART1_RTS__UART1_RTS,
76 MX51_PAD_UART1_CTS__UART1_CTS,
77
78 /* USB HOST1 */
79 MX51_PAD_USBH1_CLK__USBH1_CLK,
80 MX51_PAD_USBH1_DIR__USBH1_DIR,
81 MX51_PAD_USBH1_NXT__USBH1_NXT,
82 MX51_PAD_USBH1_DATA0__USBH1_DATA0,
83 MX51_PAD_USBH1_DATA1__USBH1_DATA1,
84 MX51_PAD_USBH1_DATA2__USBH1_DATA2,
85 MX51_PAD_USBH1_DATA3__USBH1_DATA3,
86 MX51_PAD_USBH1_DATA4__USBH1_DATA4,
87 MX51_PAD_USBH1_DATA5__USBH1_DATA5,
88 MX51_PAD_USBH1_DATA6__USBH1_DATA6,
89 MX51_PAD_USBH1_DATA7__USBH1_DATA7,
90 MX51_PAD_USBH1_STP__USBH1_STP,
91 MX51_PAD_EIM_CS3__GPIO_2_28, /* PHY nRESET */
92
93 /* FEC */
94 MX51_PAD_EIM_DTACK__GPIO_2_31, /* PHY nRESET */
95
96 /* HSI2C */
97 MX51_PAD_I2C1_CLK__GPIO_4_16,
98 MX51_PAD_I2C1_DAT__GPIO_4_17,
99
100 /* CAN */
101 MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI,
102 MX51_PAD_CSPI1_MISO__ECSPI1_MISO,
103 MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK,
104 MX51_PAD_CSPI1_SS0__GPIO_4_24, /* nCS */
105 MX51_PAD_CSI2_PIXCLK__GPIO_4_15, /* nReset */
106 MX51_PAD_GPIO_1_1__GPIO_1_1, /* IRQ */
107 MX51_PAD_GPIO_1_4__GPIO_1_4, /* Control signals */
108 MX51_PAD_GPIO_1_6__GPIO_1_6,
109 MX51_PAD_GPIO_1_7__GPIO_1_7,
110 MX51_PAD_GPIO_1_8__GPIO_1_8,
111 MX51_PAD_GPIO_1_9__GPIO_1_9,
112
113 /* Touchscreen */
114 CPUIMX51SD_GPIO_3_12, /* IRQ */
115};
116
117static const struct imxuart_platform_data uart_pdata __initconst = {
118 .flags = IMXUART_HAVE_RTSCTS,
119};
120
121static int ts_get_pendown_state(void)
122{
123 return gpio_get_value(TSC2007_IRQGPIO) ? 0 : 1;
124}
125
126static struct tsc2007_platform_data tsc2007_info = {
127 .model = 2007,
128 .x_plate_ohms = 180,
129 .get_pendown_state = ts_get_pendown_state,
130};
131
132static struct i2c_board_info eukrea_cpuimx51sd_i2c_devices[] = {
133 {
134 I2C_BOARD_INFO("pcf8563", 0x51),
135 }, {
136 I2C_BOARD_INFO("tsc2007", 0x49),
137 .type = "tsc2007",
138 .platform_data = &tsc2007_info,
139 .irq = gpio_to_irq(TSC2007_IRQGPIO),
140 },
141};
142
143static const struct mxc_nand_platform_data
144 eukrea_cpuimx51sd_nand_board_info __initconst = {
145 .width = 1,
146 .hw_ecc = 1,
147 .flash_bbt = 1,
148};
149
150/* This function is board specific as the bit mask for the plldiv will also
151be different for other Freescale SoCs, thus a common bitmask is not
152possible and cannot get place in /plat-mxc/ehci.c.*/
153static int initialize_otg_port(struct platform_device *pdev)
154{
155 u32 v;
156 void __iomem *usb_base;
157 void __iomem *usbother_base;
158
159 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
160 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
161
162 /* Set the PHY clock to 19.2MHz */
163 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
164 v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
165 v |= MX51_USB_PLL_DIV_19_2_MHZ;
166 __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
167 iounmap(usb_base);
168 return 0;
169}
170
171static int initialize_usbh1_port(struct platform_device *pdev)
172{
173 u32 v;
174 void __iomem *usb_base;
175 void __iomem *usbother_base;
176
177 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
178 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
179
180 /* The clock for the USBH1 ULPI port will come from the PHY. */
181 v = __raw_readl(usbother_base + MX51_USB_CTRL_1_OFFSET);
182 __raw_writel(v | MX51_USB_CTRL_UH1_EXT_CLK_EN,
183 usbother_base + MX51_USB_CTRL_1_OFFSET);
184 iounmap(usb_base);
185 return 0;
186}
187
188static struct mxc_usbh_platform_data dr_utmi_config = {
189 .init = initialize_otg_port,
190 .portsc = MXC_EHCI_UTMI_16BIT,
191 .flags = MXC_EHCI_INTERNAL_PHY,
192};
193
194static struct fsl_usb2_platform_data usb_pdata = {
195 .operating_mode = FSL_USB2_DR_DEVICE,
196 .phy_mode = FSL_USB2_PHY_UTMI_WIDE,
197};
198
199static struct mxc_usbh_platform_data usbh1_config = {
200 .init = initialize_usbh1_port,
201 .portsc = MXC_EHCI_MODE_ULPI,
202 .flags = (MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_ITC_NO_THRESHOLD),
203};
204
205static int otg_mode_host;
206
207static int __init eukrea_cpuimx51sd_otg_mode(char *options)
208{
209 if (!strcmp(options, "host"))
210 otg_mode_host = 1;
211 else if (!strcmp(options, "device"))
212 otg_mode_host = 0;
213 else
214 pr_info("otg_mode neither \"host\" nor \"device\". "
215 "Defaulting to device\n");
216 return 0;
217}
218__setup("otg_mode=", eukrea_cpuimx51sd_otg_mode);
219
220static struct i2c_gpio_platform_data pdata = {
221 .sda_pin = I2C_SDA,
222 .sda_is_open_drain = 0,
223 .scl_pin = I2C_SCL,
224 .scl_is_open_drain = 0,
225 .udelay = 2,
226};
227
228static struct platform_device hsi2c_gpio_device = {
229 .name = "i2c-gpio",
230 .id = 0,
231 .dev.platform_data = &pdata,
232};
233
234static struct mcp251x_platform_data mcp251x_info = {
235 .oscillator_frequency = 24E6,
236};
237
238static struct spi_board_info cpuimx51sd_spi_device[] = {
239 {
240 .modalias = "mcp2515",
241 .max_speed_hz = 6500000,
242 .bus_num = 0,
243 .mode = SPI_MODE_0,
244 .chip_select = 0,
245 .platform_data = &mcp251x_info,
246 .irq = gpio_to_irq(0 * 32 + 1)
247 },
248};
249
250static int cpuimx51sd_spi1_cs[] = {
251 CAN_NCS,
252};
253
254static const struct spi_imx_master cpuimx51sd_ecspi1_pdata __initconst = {
255 .chipselect = cpuimx51sd_spi1_cs,
256 .num_chipselect = ARRAY_SIZE(cpuimx51sd_spi1_cs),
257};
258
259static struct platform_device *platform_devices[] __initdata = {
260 &hsi2c_gpio_device,
261};
262
263static void __init eukrea_cpuimx51sd_init(void)
264{
265 mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx51sd_pads,
266 ARRAY_SIZE(eukrea_cpuimx51sd_pads));
267
268 imx51_add_imx_uart(0, &uart_pdata);
269 imx51_add_mxc_nand(&eukrea_cpuimx51sd_nand_board_info);
270
271 gpio_request(ETH_RST, "eth_rst");
272 gpio_set_value(ETH_RST, 1);
273 imx51_add_fec(NULL);
274
275 gpio_request(CAN_IRQGPIO, "can_irq");
276 gpio_direction_input(CAN_IRQGPIO);
277 gpio_free(CAN_IRQGPIO);
278 gpio_request(CAN_NCS, "can_ncs");
279 gpio_direction_output(CAN_NCS, 1);
280 gpio_free(CAN_NCS);
281 gpio_request(CAN_RST, "can_rst");
282 gpio_direction_output(CAN_RST, 0);
283 msleep(20);
284 gpio_set_value(CAN_RST, 1);
285 imx51_add_ecspi(0, &cpuimx51sd_ecspi1_pdata);
286 spi_register_board_info(cpuimx51sd_spi_device,
287 ARRAY_SIZE(cpuimx51sd_spi_device));
288
289 gpio_request(TSC2007_IRQGPIO, "tsc2007_irq");
290 gpio_direction_input(TSC2007_IRQGPIO);
291 gpio_free(TSC2007_IRQGPIO);
292
293 i2c_register_board_info(0, eukrea_cpuimx51sd_i2c_devices,
294 ARRAY_SIZE(eukrea_cpuimx51sd_i2c_devices));
295 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
296
297 if (otg_mode_host)
298 mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
299 else {
300 initialize_otg_port(NULL);
301 mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata);
302 }
303
304 gpio_request(USBH1_RST, "usb_rst");
305 gpio_direction_output(USBH1_RST, 0);
306 msleep(20);
307 gpio_set_value(USBH1_RST, 1);
308 mxc_register_device(&mxc_usbh1_device, &usbh1_config);
309
310#ifdef CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD
311 eukrea_mbimxsd51_baseboard_init();
312#endif
313}
314
315static void __init eukrea_cpuimx51sd_timer_init(void)
316{
317 mx51_clocks_init(32768, 24000000, 22579200, 0);
318}
319
320static struct sys_timer mxc_timer = {
321 .init = eukrea_cpuimx51sd_timer_init,
322};
323
324MACHINE_START(EUKREA_CPUIMX51SD, "Eukrea CPUIMX51SD")
325 /* Maintainer: Eric Bénard <eric@eukrea.com> */
326 .boot_params = PHYS_OFFSET + 0x100,
327 .map_io = mx51_map_io,
328 .init_irq = mx51_init_irq,
329 .init_machine = eukrea_cpuimx51sd_init,
330 .timer = &mxc_timer,
331MACHINE_END
diff --git a/arch/arm/mach-mx5/board-mx51_3ds.c b/arch/arm/mach-mx5/board-mx51_3ds.c
index f95c2fd94667..79ce8dcf3cda 100644
--- a/arch/arm/mach-mx5/board-mx51_3ds.c
+++ b/arch/arm/mach-mx5/board-mx51_3ds.c
@@ -13,6 +13,7 @@
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/input/matrix_keypad.h> 15#include <linux/input/matrix_keypad.h>
16#include <linux/spi/spi.h>
16 17
17#include <asm/mach-types.h> 18#include <asm/mach-types.h>
18#include <asm/mach/arch.h> 19#include <asm/mach/arch.h>
@@ -21,12 +22,13 @@
21#include <mach/hardware.h> 22#include <mach/hardware.h>
22#include <mach/common.h> 23#include <mach/common.h>
23#include <mach/iomux-mx51.h> 24#include <mach/iomux-mx51.h>
24#include <mach/imx-uart.h>
25#include <mach/3ds_debugboard.h> 25#include <mach/3ds_debugboard.h>
26 26
27#include "devices-imx51.h"
27#include "devices.h" 28#include "devices.h"
28 29
29#define EXPIO_PARENT_INT (MXC_INTERNAL_IRQS + GPIO_PORTA + 6) 30#define EXPIO_PARENT_INT (MXC_INTERNAL_IRQS + GPIO_PORTA + 6)
31#define MX51_3DS_ECSPI2_CS (GPIO_PORTC + 28)
30 32
31static struct pad_desc mx51_3ds_pads[] = { 33static struct pad_desc mx51_3ds_pads[] = {
32 /* UART1 */ 34 /* UART1 */
@@ -61,19 +63,25 @@ static struct pad_desc mx51_3ds_pads[] = {
61 MX51_PAD_KEY_COL3__KEY_COL3, 63 MX51_PAD_KEY_COL3__KEY_COL3,
62 MX51_PAD_KEY_COL4__KEY_COL4, 64 MX51_PAD_KEY_COL4__KEY_COL4,
63 MX51_PAD_KEY_COL5__KEY_COL5, 65 MX51_PAD_KEY_COL5__KEY_COL5,
66
67 /* eCSPI2 */
68 MX51_PAD_NANDF_RB2__ECSPI2_SCLK,
69 MX51_PAD_NANDF_RB3__ECSPI2_MISO,
70 MX51_PAD_NANDF_D15__ECSPI2_MOSI,
71 MX51_PAD_NANDF_D12__GPIO_3_28,
64}; 72};
65 73
66/* Serial ports */ 74/* Serial ports */
67#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) 75#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
68static struct imxuart_platform_data uart_pdata = { 76static const struct imxuart_platform_data uart_pdata __initconst = {
69 .flags = IMXUART_HAVE_RTSCTS, 77 .flags = IMXUART_HAVE_RTSCTS,
70}; 78};
71 79
72static inline void mxc_init_imx_uart(void) 80static inline void mxc_init_imx_uart(void)
73{ 81{
74 mxc_register_device(&mxc_uart_device0, &uart_pdata); 82 imx51_add_imx_uart(0, &uart_pdata);
75 mxc_register_device(&mxc_uart_device1, &uart_pdata); 83 imx51_add_imx_uart(1, &uart_pdata);
76 mxc_register_device(&mxc_uart_device2, &uart_pdata); 84 imx51_add_imx_uart(2, &uart_pdata);
77} 85}
78#else /* !SERIAL_IMX */ 86#else /* !SERIAL_IMX */
79static inline void mxc_init_imx_uart(void) 87static inline void mxc_init_imx_uart(void)
@@ -127,6 +135,26 @@ static inline void mxc_init_keypad(void)
127} 135}
128#endif 136#endif
129 137
138static int mx51_3ds_spi2_cs[] = {
139 MXC_SPI_CS(0),
140 MX51_3DS_ECSPI2_CS,
141};
142
143static const struct spi_imx_master mx51_3ds_ecspi2_pdata __initconst = {
144 .chipselect = mx51_3ds_spi2_cs,
145 .num_chipselect = ARRAY_SIZE(mx51_3ds_spi2_cs),
146};
147
148static struct spi_board_info mx51_3ds_spi_nor_device[] = {
149 {
150 .modalias = "m25p80",
151 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
152 .bus_num = 1,
153 .chip_select = 1,
154 .mode = SPI_MODE_0,
155 .platform_data = NULL,},
156};
157
130/* 158/*
131 * Board specific initialization. 159 * Board specific initialization.
132 */ 160 */
@@ -136,6 +164,10 @@ static void __init mxc_board_init(void)
136 ARRAY_SIZE(mx51_3ds_pads)); 164 ARRAY_SIZE(mx51_3ds_pads));
137 mxc_init_imx_uart(); 165 mxc_init_imx_uart();
138 166
167 imx51_add_ecspi(1, &mx51_3ds_ecspi2_pdata);
168 spi_register_board_info(mx51_3ds_spi_nor_device,
169 ARRAY_SIZE(mx51_3ds_spi_nor_device));
170
139 if (mxc_expio_init(MX51_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 171 if (mxc_expio_init(MX51_CS5_BASE_ADDR, EXPIO_PARENT_INT))
140 printk(KERN_WARNING "Init of the debugboard failed, all " 172 printk(KERN_WARNING "Init of the debugboard failed, all "
141 "devices on the board are unusable.\n"); 173 "devices on the board are unusable.\n");
@@ -154,8 +186,6 @@ static struct sys_timer mxc_timer = {
154 186
155MACHINE_START(MX51_3DS, "Freescale MX51 3-Stack Board") 187MACHINE_START(MX51_3DS, "Freescale MX51 3-Stack Board")
156 /* Maintainer: Freescale Semiconductor, Inc. */ 188 /* Maintainer: Freescale Semiconductor, Inc. */
157 .phys_io = MX51_AIPS1_BASE_ADDR,
158 .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
159 .boot_params = PHYS_OFFSET + 0x100, 189 .boot_params = PHYS_OFFSET + 0x100,
160 .map_io = mx51_map_io, 190 .map_io = mx51_map_io,
161 .init_irq = mx51_init_irq, 191 .init_irq = mx51_init_irq,
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 6e384d92e625..0821fe9b3b27 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -17,12 +17,11 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/fsl_devices.h> 19#include <linux/fsl_devices.h>
20#include <linux/fec.h>
20 21
21#include <mach/common.h> 22#include <mach/common.h>
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/imx-uart.h>
24#include <mach/iomux-mx51.h> 24#include <mach/iomux-mx51.h>
25#include <mach/i2c.h>
26#include <mach/mxc_ehci.h> 25#include <mach/mxc_ehci.h>
27 26
28#include <asm/irq.h> 27#include <asm/irq.h>
@@ -31,11 +30,13 @@
31#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
32#include <asm/mach/time.h> 31#include <asm/mach/time.h>
33 32
33#include "devices-imx51.h"
34#include "devices.h" 34#include "devices.h"
35 35
36#define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */ 36#define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */
37#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */ 37#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
38#define BABBAGE_PHY_RESET (1*32 +5) /* GPIO_2_5 */ 38#define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */
39#define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */
39 40
40/* USB_CTRL_1 */ 41/* USB_CTRL_1 */
41#define MX51_USB_CTRL_1_OFFSET 0x10 42#define MX51_USB_CTRL_1_OFFSET 0x10
@@ -45,10 +46,6 @@
45#define MX51_USB_PLL_DIV_19_2_MHZ 0x01 46#define MX51_USB_PLL_DIV_19_2_MHZ 0x01
46#define MX51_USB_PLL_DIV_24_MHZ 0x02 47#define MX51_USB_PLL_DIV_24_MHZ 0x02
47 48
48static struct platform_device *devices[] __initdata = {
49 &mxc_fec_device,
50};
51
52static struct pad_desc mx51babbage_pads[] = { 49static struct pad_desc mx51babbage_pads[] = {
53 /* UART1 */ 50 /* UART1 */
54 MX51_PAD_UART1_RXD__UART1_RXD, 51 MX51_PAD_UART1_RXD__UART1_RXD,
@@ -93,19 +90,41 @@ static struct pad_desc mx51babbage_pads[] = {
93 90
94 /* USB HUB reset line*/ 91 /* USB HUB reset line*/
95 MX51_PAD_GPIO_1_7__GPIO_1_7, 92 MX51_PAD_GPIO_1_7__GPIO_1_7,
93
94 /* FEC */
95 MX51_PAD_EIM_EB2__FEC_MDIO,
96 MX51_PAD_EIM_EB3__FEC_RDAT1,
97 MX51_PAD_EIM_CS2__FEC_RDAT2,
98 MX51_PAD_EIM_CS3__FEC_RDAT3,
99 MX51_PAD_EIM_CS4__FEC_RX_ER,
100 MX51_PAD_EIM_CS5__FEC_CRS,
101 MX51_PAD_NANDF_RB2__FEC_COL,
102 MX51_PAD_NANDF_RB3__FEC_RXCLK,
103 MX51_PAD_NANDF_RB6__FEC_RDAT0,
104 MX51_PAD_NANDF_RB7__FEC_TDAT0,
105 MX51_PAD_NANDF_CS2__FEC_TX_ER,
106 MX51_PAD_NANDF_CS3__FEC_MDC,
107 MX51_PAD_NANDF_CS4__FEC_TDAT1,
108 MX51_PAD_NANDF_CS5__FEC_TDAT2,
109 MX51_PAD_NANDF_CS6__FEC_TDAT3,
110 MX51_PAD_NANDF_CS7__FEC_TX_EN,
111 MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK,
112
113 /* FEC PHY reset line */
114 MX51_PAD_EIM_A20__GPIO_2_14,
96}; 115};
97 116
98/* Serial ports */ 117/* Serial ports */
99#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) 118#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
100static struct imxuart_platform_data uart_pdata = { 119static const struct imxuart_platform_data uart_pdata __initconst = {
101 .flags = IMXUART_HAVE_RTSCTS, 120 .flags = IMXUART_HAVE_RTSCTS,
102}; 121};
103 122
104static inline void mxc_init_imx_uart(void) 123static inline void mxc_init_imx_uart(void)
105{ 124{
106 mxc_register_device(&mxc_uart_device0, &uart_pdata); 125 imx51_add_imx_uart(0, &uart_pdata);
107 mxc_register_device(&mxc_uart_device1, &uart_pdata); 126 imx51_add_imx_uart(1, &uart_pdata);
108 mxc_register_device(&mxc_uart_device2, &uart_pdata); 127 imx51_add_imx_uart(2, &uart_pdata);
109} 128}
110#else /* !SERIAL_IMX */ 129#else /* !SERIAL_IMX */
111static inline void mxc_init_imx_uart(void) 130static inline void mxc_init_imx_uart(void)
@@ -113,7 +132,7 @@ static inline void mxc_init_imx_uart(void)
113} 132}
114#endif /* SERIAL_IMX */ 133#endif /* SERIAL_IMX */
115 134
116static struct imxi2c_platform_data babbage_i2c_data = { 135static const struct imxi2c_platform_data babbage_i2c_data __initconst = {
117 .bitrate = 100000, 136 .bitrate = 100000,
118}; 137};
119 138
@@ -171,6 +190,22 @@ static inline void babbage_usbhub_reset(void)
171 gpio_set_value(BABBAGE_USB_HUB_RESET, 1); 190 gpio_set_value(BABBAGE_USB_HUB_RESET, 1);
172} 191}
173 192
193static inline void babbage_fec_reset(void)
194{
195 int ret;
196
197 /* reset FEC PHY */
198 ret = gpio_request(BABBAGE_FEC_PHY_RESET, "fec-phy-reset");
199 if (ret) {
200 printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret);
201 return;
202 }
203 gpio_direction_output(BABBAGE_FEC_PHY_RESET, 0);
204 gpio_set_value(BABBAGE_FEC_PHY_RESET, 0);
205 msleep(1);
206 gpio_set_value(BABBAGE_FEC_PHY_RESET, 1);
207}
208
174/* This function is board specific as the bit mask for the plldiv will also 209/* This function is board specific as the bit mask for the plldiv will also
175be different for other Freescale SoCs, thus a common bitmask is not 210be different for other Freescale SoCs, thus a common bitmask is not
176possible and cannot get place in /plat-mxc/ehci.c.*/ 211possible and cannot get place in /plat-mxc/ehci.c.*/
@@ -178,7 +213,7 @@ static int initialize_otg_port(struct platform_device *pdev)
178{ 213{
179 u32 v; 214 u32 v;
180 void __iomem *usb_base; 215 void __iomem *usb_base;
181 u32 usbother_base; 216 void __iomem *usbother_base;
182 217
183 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); 218 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
184 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET; 219 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
@@ -196,7 +231,7 @@ static int initialize_usbh1_port(struct platform_device *pdev)
196{ 231{
197 u32 v; 232 u32 v;
198 void __iomem *usb_base; 233 void __iomem *usb_base;
199 u32 usbother_base; 234 void __iomem *usbother_base;
200 235
201 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); 236 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
202 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET; 237 usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET;
@@ -250,10 +285,11 @@ static void __init mxc_board_init(void)
250 mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, 285 mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
251 ARRAY_SIZE(mx51babbage_pads)); 286 ARRAY_SIZE(mx51babbage_pads));
252 mxc_init_imx_uart(); 287 mxc_init_imx_uart();
253 platform_add_devices(devices, ARRAY_SIZE(devices)); 288 babbage_fec_reset();
289 imx51_add_fec(NULL);
254 290
255 mxc_register_device(&mxc_i2c_device0, &babbage_i2c_data); 291 imx51_add_imx_i2c(0, &babbage_i2c_data);
256 mxc_register_device(&mxc_i2c_device1, &babbage_i2c_data); 292 imx51_add_imx_i2c(1, &babbage_i2c_data);
257 mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data); 293 mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data);
258 294
259 if (otg_mode_host) 295 if (otg_mode_host)
@@ -281,9 +317,7 @@ static struct sys_timer mxc_timer = {
281 317
282MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board") 318MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board")
283 /* Maintainer: Amit Kucheria <amit.kucheria@canonical.com> */ 319 /* Maintainer: Amit Kucheria <amit.kucheria@canonical.com> */
284 .phys_io = MX51_AIPS1_BASE_ADDR, 320 .boot_params = MX51_PHYS_OFFSET + 0x100,
285 .io_pg_offst = ((MX51_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
286 .boot_params = PHYS_OFFSET + 0x100,
287 .map_io = mx51_map_io, 321 .map_io = mx51_map_io,
288 .init_irq = mx51_init_irq, 322 .init_irq = mx51_init_irq,
289 .init_machine = mxc_board_init, 323 .init_machine = mxc_board_init,
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c
new file mode 100644
index 000000000000..6e623bda3ee7
--- /dev/null
+++ b/arch/arm/mach-mx5/board-mx51_efikamx.c
@@ -0,0 +1,119 @@
1/*
2 * Copyright (C) 2010 Linaro Limited
3 *
4 * based on code from the following
5 * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
6 * Copyright 2009-2010 Pegatron Corporation. All Rights Reserved.
7 * Copyright 2009-2010 Genesi USA, Inc. All Rights Reserved.
8 *
9 * The code contained herein is licensed under the GNU General Public
10 * License. You may obtain a copy of the GNU General Public License
11 * Version 2 or later at the following locations:
12 *
13 * http://www.opensource.org/licenses/gpl-license.html
14 * http://www.gnu.org/copyleft/gpl.html
15 */
16
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/i2c.h>
20#include <linux/gpio.h>
21#include <linux/delay.h>
22#include <linux/io.h>
23#include <linux/fsl_devices.h>
24
25#include <mach/common.h>
26#include <mach/hardware.h>
27#include <mach/iomux-mx51.h>
28#include <mach/i2c.h>
29#include <mach/mxc_ehci.h>
30
31#include <asm/irq.h>
32#include <asm/setup.h>
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/time.h>
36
37#include "devices-imx51.h"
38#include "devices.h"
39
40#define MX51_USB_PLL_DIV_24_MHZ 0x01
41
42static struct pad_desc mx51efikamx_pads[] = {
43 /* UART1 */
44 MX51_PAD_UART1_RXD__UART1_RXD,
45 MX51_PAD_UART1_TXD__UART1_TXD,
46 MX51_PAD_UART1_RTS__UART1_RTS,
47 MX51_PAD_UART1_CTS__UART1_CTS,
48};
49
50/* Serial ports */
51#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
52static const struct imxuart_platform_data uart_pdata = {
53 .flags = IMXUART_HAVE_RTSCTS,
54};
55
56static inline void mxc_init_imx_uart(void)
57{
58 imx51_add_imx_uart(0, &uart_pdata);
59 imx51_add_imx_uart(1, &uart_pdata);
60 imx51_add_imx_uart(2, &uart_pdata);
61}
62#else /* !SERIAL_IMX */
63static inline void mxc_init_imx_uart(void)
64{
65}
66#endif /* SERIAL_IMX */
67
68/* This function is board specific as the bit mask for the plldiv will also
69 * be different for other Freescale SoCs, thus a common bitmask is not
70 * possible and cannot get place in /plat-mxc/ehci.c.
71 */
72static int initialize_otg_port(struct platform_device *pdev)
73{
74 u32 v;
75 void __iomem *usb_base;
76 void __iomem *usbother_base;
77 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
78 usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET);
79
80 /* Set the PHY clock to 19.2MHz */
81 v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
82 v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK;
83 v |= MX51_USB_PLL_DIV_24_MHZ;
84 __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET);
85 iounmap(usb_base);
86 return 0;
87}
88
89static struct mxc_usbh_platform_data dr_utmi_config = {
90 .init = initialize_otg_port,
91 .portsc = MXC_EHCI_UTMI_16BIT,
92 .flags = MXC_EHCI_INTERNAL_PHY,
93};
94
95static void __init mxc_board_init(void)
96{
97 mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads,
98 ARRAY_SIZE(mx51efikamx_pads));
99 mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
100 mxc_init_imx_uart();
101}
102
103static void __init mx51_efikamx_timer_init(void)
104{
105 mx51_clocks_init(32768, 24000000, 22579200, 24576000);
106}
107
108static struct sys_timer mxc_timer = {
109 .init = mx51_efikamx_timer_init,
110};
111
112MACHINE_START(MX51_EFIKAMX, "Genesi EfikaMX nettop")
113 /* Maintainer: Amit Kucheria <amit.kucheria@linaro.org> */
114 .boot_params = MX51_PHYS_OFFSET + 0x100,
115 .map_io = mx51_map_io,
116 .init_irq = mx51_init_irq,
117 .init_machine = mxc_board_init,
118 .timer = &mxc_timer,
119MACHINE_END
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 57c10a9926cc..f2aae92cf0e2 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -41,34 +41,66 @@ static struct clk usboh3_clk;
41 41
42#define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ 42#define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */
43 43
44static int _clk_ccgr_enable(struct clk *clk) 44/* calculate best pre and post dividers to get the required divider */
45static void __calc_pre_post_dividers(u32 div, u32 *pre, u32 *post,
46 u32 max_pre, u32 max_post)
45{ 47{
46 u32 reg; 48 if (div >= max_pre * max_post) {
49 *pre = max_pre;
50 *post = max_post;
51 } else if (div >= max_pre) {
52 u32 min_pre, temp_pre, old_err, err;
53 min_pre = DIV_ROUND_UP(div, max_post);
54 old_err = max_pre;
55 for (temp_pre = max_pre; temp_pre >= min_pre; temp_pre--) {
56 err = div % temp_pre;
57 if (err == 0) {
58 *pre = temp_pre;
59 break;
60 }
61 err = temp_pre - err;
62 if (err < old_err) {
63 old_err = err;
64 *pre = temp_pre;
65 }
66 }
67 *post = DIV_ROUND_UP(div, *pre);
68 } else {
69 *pre = div;
70 *post = 1;
71 }
72}
73
74static void _clk_ccgr_setclk(struct clk *clk, unsigned mode)
75{
76 u32 reg = __raw_readl(clk->enable_reg);
77
78 reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
79 reg |= mode << clk->enable_shift;
47 80
48 reg = __raw_readl(clk->enable_reg);
49 reg |= MXC_CCM_CCGRx_MOD_ON << clk->enable_shift;
50 __raw_writel(reg, clk->enable_reg); 81 __raw_writel(reg, clk->enable_reg);
82}
51 83
84static int _clk_ccgr_enable(struct clk *clk)
85{
86 _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_ON);
52 return 0; 87 return 0;
53} 88}
54 89
55static void _clk_ccgr_disable(struct clk *clk) 90static void _clk_ccgr_disable(struct clk *clk)
56{ 91{
57 u32 reg; 92 _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_OFF);
58 reg = __raw_readl(clk->enable_reg); 93}
59 reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
60 __raw_writel(reg, clk->enable_reg);
61 94
95static int _clk_ccgr_enable_inrun(struct clk *clk)
96{
97 _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE);
98 return 0;
62} 99}
63 100
64static void _clk_ccgr_disable_inwait(struct clk *clk) 101static void _clk_ccgr_disable_inwait(struct clk *clk)
65{ 102{
66 u32 reg; 103 _clk_ccgr_setclk(clk, MXC_CCM_CCGRx_MOD_IDLE);
67
68 reg = __raw_readl(clk->enable_reg);
69 reg &= ~(MXC_CCM_CCGRx_CG_MASK << clk->enable_shift);
70 reg |= MXC_CCM_CCGRx_MOD_IDLE << clk->enable_shift;
71 __raw_writel(reg, clk->enable_reg);
72} 104}
73 105
74/* 106/*
@@ -542,60 +574,60 @@ static int _clk_ipg_per_set_parent(struct clk *clk, struct clk *parent)
542 return 0; 574 return 0;
543} 575}
544 576
545static unsigned long clk_uart_get_rate(struct clk *clk) 577#define clk_nfc_set_parent NULL
546{
547 u32 reg, prediv, podf;
548 unsigned long parent_rate;
549 578
550 parent_rate = clk_get_rate(clk->parent); 579static unsigned long clk_nfc_get_rate(struct clk *clk)
551 580{
552 reg = __raw_readl(MXC_CCM_CSCDR1); 581 unsigned long rate;
553 prediv = ((reg & MXC_CCM_CSCDR1_UART_CLK_PRED_MASK) >> 582 u32 reg, div;
554 MXC_CCM_CSCDR1_UART_CLK_PRED_OFFSET) + 1;
555 podf = ((reg & MXC_CCM_CSCDR1_UART_CLK_PODF_MASK) >>
556 MXC_CCM_CSCDR1_UART_CLK_PODF_OFFSET) + 1;
557 583
558 return parent_rate / (prediv * podf); 584 reg = __raw_readl(MXC_CCM_CBCDR);
585 div = ((reg & MXC_CCM_CBCDR_NFC_PODF_MASK) >>
586 MXC_CCM_CBCDR_NFC_PODF_OFFSET) + 1;
587 rate = clk_get_rate(clk->parent) / div;
588 WARN_ON(rate == 0);
589 return rate;
559} 590}
560 591
561static int _clk_uart_set_parent(struct clk *clk, struct clk *parent) 592static unsigned long clk_nfc_round_rate(struct clk *clk,
593 unsigned long rate)
562{ 594{
563 u32 reg, mux; 595 u32 div;
596 unsigned long parent_rate = clk_get_rate(clk->parent);
564 597
565 mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, 598 if (!rate)
566 &lp_apm_clk); 599 return -EINVAL;
567 reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_UART_CLK_SEL_MASK;
568 reg |= mux << MXC_CCM_CSCMR1_UART_CLK_SEL_OFFSET;
569 __raw_writel(reg, MXC_CCM_CSCMR1);
570 600
571 return 0; 601 div = parent_rate / rate;
572}
573 602
574static unsigned long clk_usboh3_get_rate(struct clk *clk) 603 if (parent_rate % rate)
575{ 604 div++;
576 u32 reg, prediv, podf;
577 unsigned long parent_rate;
578 605
579 parent_rate = clk_get_rate(clk->parent); 606 if (div > 8)
607 return -EINVAL;
580 608
581 reg = __raw_readl(MXC_CCM_CSCDR1); 609 return parent_rate / div;
582 prediv = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PRED_MASK) >>
583 MXC_CCM_CSCDR1_USBOH3_CLK_PRED_OFFSET) + 1;
584 podf = ((reg & MXC_CCM_CSCDR1_USBOH3_CLK_PODF_MASK) >>
585 MXC_CCM_CSCDR1_USBOH3_CLK_PODF_OFFSET) + 1;
586 610
587 return parent_rate / (prediv * podf);
588} 611}
589 612
590static int _clk_usboh3_set_parent(struct clk *clk, struct clk *parent) 613static int clk_nfc_set_rate(struct clk *clk, unsigned long rate)
591{ 614{
592 u32 reg, mux; 615 u32 reg, div;
616
617 div = clk_get_rate(clk->parent) / rate;
618 if (div == 0)
619 div++;
620 if (((clk_get_rate(clk->parent) / div) != rate) || (div > 8))
621 return -EINVAL;
622
623 reg = __raw_readl(MXC_CCM_CBCDR);
624 reg &= ~MXC_CCM_CBCDR_NFC_PODF_MASK;
625 reg |= (div - 1) << MXC_CCM_CBCDR_NFC_PODF_OFFSET;
626 __raw_writel(reg, MXC_CCM_CBCDR);
593 627
594 mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk, 628 while (__raw_readl(MXC_CCM_CDHIPR) &
595 &lp_apm_clk); 629 MXC_CCM_CDHIPR_NFC_IPG_INT_MEM_PODF_BUSY){
596 reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_USBOH3_CLK_SEL_MASK; 630 }
597 reg |= mux << MXC_CCM_CSCMR1_USBOH3_CLK_SEL_OFFSET;
598 __raw_writel(reg, MXC_CCM_CSCMR1);
599 631
600 return 0; 632 return 0;
601} 633}
@@ -620,6 +652,17 @@ static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
620 return ckih2_reference; 652 return ckih2_reference;
621} 653}
622 654
655static unsigned long clk_emi_slow_get_rate(struct clk *clk)
656{
657 u32 reg, div;
658
659 reg = __raw_readl(MXC_CCM_CBCDR);
660 div = ((reg & MXC_CCM_CBCDR_EMI_PODF_MASK) >>
661 MXC_CCM_CBCDR_EMI_PODF_OFFSET) + 1;
662
663 return clk_get_rate(clk->parent) / div;
664}
665
623/* External high frequency clock */ 666/* External high frequency clock */
624static struct clk ckih_clk = { 667static struct clk ckih_clk = {
625 .get_rate = get_high_reference_clock_rate, 668 .get_rate = get_high_reference_clock_rate,
@@ -715,18 +758,6 @@ static struct clk ipg_perclk = {
715 .set_parent = _clk_ipg_per_set_parent, 758 .set_parent = _clk_ipg_per_set_parent,
716}; 759};
717 760
718static struct clk uart_root_clk = {
719 .parent = &pll2_sw_clk,
720 .get_rate = clk_uart_get_rate,
721 .set_parent = _clk_uart_set_parent,
722};
723
724static struct clk usboh3_clk = {
725 .parent = &pll2_sw_clk,
726 .get_rate = clk_usboh3_get_rate,
727 .set_parent = _clk_usboh3_set_parent,
728};
729
730static struct clk ahb_max_clk = { 761static struct clk ahb_max_clk = {
731 .parent = &ahb_clk, 762 .parent = &ahb_clk,
732 .enable_reg = MXC_CCM_CCGR0, 763 .enable_reg = MXC_CCM_CCGR0,
@@ -762,45 +793,183 @@ static struct clk kpp_clk = {
762 .id = 0, 793 .id = 0,
763}; 794};
764 795
765#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s) \ 796static struct clk emi_slow_clk = {
797 .parent = &pll2_sw_clk,
798 .enable_reg = MXC_CCM_CCGR5,
799 .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET,
800 .enable = _clk_ccgr_enable,
801 .disable = _clk_ccgr_disable_inwait,
802 .get_rate = clk_emi_slow_get_rate,
803};
804
805#define DEFINE_CLOCK_CCGR(name, i, er, es, pfx, p, s) \
766 static struct clk name = { \ 806 static struct clk name = { \
767 .id = i, \ 807 .id = i, \
768 .enable_reg = er, \ 808 .enable_reg = er, \
769 .enable_shift = es, \ 809 .enable_shift = es, \
770 .get_rate = gr, \ 810 .get_rate = pfx##_get_rate, \
771 .set_rate = sr, \ 811 .set_rate = pfx##_set_rate, \
812 .round_rate = pfx##_round_rate, \
813 .set_parent = pfx##_set_parent, \
772 .enable = _clk_ccgr_enable, \ 814 .enable = _clk_ccgr_enable, \
773 .disable = _clk_ccgr_disable, \ 815 .disable = _clk_ccgr_disable, \
774 .parent = p, \ 816 .parent = p, \
775 .secondary = s, \ 817 .secondary = s, \
776 } 818 }
777 819
778/* DEFINE_CLOCK(name, id, enable_reg, enable_shift, 820#define DEFINE_CLOCK_MAX(name, i, er, es, pfx, p, s) \
779 get_rate, set_rate, parent, secondary); */ 821 static struct clk name = { \
822 .id = i, \
823 .enable_reg = er, \
824 .enable_shift = es, \
825 .get_rate = pfx##_get_rate, \
826 .set_rate = pfx##_set_rate, \
827 .set_parent = pfx##_set_parent, \
828 .enable = _clk_max_enable, \
829 .disable = _clk_max_disable, \
830 .parent = p, \
831 .secondary = s, \
832 }
833
834#define CLK_GET_RATE(name, nr, bitsname) \
835static unsigned long clk_##name##_get_rate(struct clk *clk) \
836{ \
837 u32 reg, pred, podf; \
838 \
839 reg = __raw_readl(MXC_CCM_CSCDR##nr); \
840 pred = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK) \
841 >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET; \
842 podf = (reg & MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK) \
843 >> MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET; \
844 \
845 return DIV_ROUND_CLOSEST(clk_get_rate(clk->parent), \
846 (pred + 1) * (podf + 1)); \
847}
848
849#define CLK_SET_PARENT(name, nr, bitsname) \
850static int clk_##name##_set_parent(struct clk *clk, struct clk *parent) \
851{ \
852 u32 reg, mux; \
853 \
854 mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, \
855 &pll3_sw_clk, &lp_apm_clk); \
856 reg = __raw_readl(MXC_CCM_CSCMR##nr) & \
857 ~MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_MASK; \
858 reg |= mux << MXC_CCM_CSCMR##nr##_##bitsname##_CLK_SEL_OFFSET; \
859 __raw_writel(reg, MXC_CCM_CSCMR##nr); \
860 \
861 return 0; \
862}
863
864#define CLK_SET_RATE(name, nr, bitsname) \
865static int clk_##name##_set_rate(struct clk *clk, unsigned long rate) \
866{ \
867 u32 reg, div, parent_rate; \
868 u32 pre = 0, post = 0; \
869 \
870 parent_rate = clk_get_rate(clk->parent); \
871 div = parent_rate / rate; \
872 \
873 if ((parent_rate / div) != rate) \
874 return -EINVAL; \
875 \
876 __calc_pre_post_dividers(div, &pre, &post, \
877 (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK >> \
878 MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET) + 1, \
879 (MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK >> \
880 MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET) + 1);\
881 \
882 /* Set sdhc1 clock divider */ \
883 reg = __raw_readl(MXC_CCM_CSCDR##nr) & \
884 ~(MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_MASK \
885 | MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_MASK); \
886 reg |= (post - 1) << \
887 MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PODF_OFFSET; \
888 reg |= (pre - 1) << \
889 MXC_CCM_CSCDR##nr##_##bitsname##_CLK_PRED_OFFSET; \
890 __raw_writel(reg, MXC_CCM_CSCDR##nr); \
891 \
892 return 0; \
893}
894
895/* UART */
896CLK_GET_RATE(uart, 1, UART)
897CLK_SET_PARENT(uart, 1, UART)
898
899static struct clk uart_root_clk = {
900 .parent = &pll2_sw_clk,
901 .get_rate = clk_uart_get_rate,
902 .set_parent = clk_uart_set_parent,
903};
904
905/* USBOH3 */
906CLK_GET_RATE(usboh3, 1, USBOH3)
907CLK_SET_PARENT(usboh3, 1, USBOH3)
908
909static struct clk usboh3_clk = {
910 .parent = &pll2_sw_clk,
911 .get_rate = clk_usboh3_get_rate,
912 .set_parent = clk_usboh3_set_parent,
913};
914
915/* eCSPI */
916CLK_GET_RATE(ecspi, 2, CSPI)
917CLK_SET_PARENT(ecspi, 1, CSPI)
918
919static struct clk ecspi_main_clk = {
920 .parent = &pll3_sw_clk,
921 .get_rate = clk_ecspi_get_rate,
922 .set_parent = clk_ecspi_set_parent,
923};
924
925/* eSDHC */
926CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1)
927CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1)
928CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1)
929
930CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2)
931CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2)
932CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2)
933
934#define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \
935 static struct clk name = { \
936 .id = i, \
937 .enable_reg = er, \
938 .enable_shift = es, \
939 .get_rate = gr, \
940 .set_rate = sr, \
941 .enable = e, \
942 .disable = d, \
943 .parent = p, \
944 .secondary = s, \
945 }
946
947#define DEFINE_CLOCK(name, i, er, es, gr, sr, p, s) \
948 DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, _clk_ccgr_enable, _clk_ccgr_disable, p, s)
780 949
781/* Shared peripheral bus arbiter */ 950/* Shared peripheral bus arbiter */
782DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET, 951DEFINE_CLOCK(spba_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG0_OFFSET,
783 NULL, NULL, &ipg_clk, NULL); 952 NULL, NULL, &ipg_clk, NULL);
784 953
785/* UART */ 954/* UART */
786DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
787 NULL, NULL, &uart_root_clk, NULL);
788DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
789 NULL, NULL, &uart_root_clk, NULL);
790DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
791 NULL, NULL, &uart_root_clk, NULL);
792DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET, 955DEFINE_CLOCK(uart1_ipg_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG3_OFFSET,
793 NULL, NULL, &ipg_clk, &aips_tz1_clk); 956 NULL, NULL, &ipg_clk, &aips_tz1_clk);
794DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET, 957DEFINE_CLOCK(uart2_ipg_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG5_OFFSET,
795 NULL, NULL, &ipg_clk, &aips_tz1_clk); 958 NULL, NULL, &ipg_clk, &aips_tz1_clk);
796DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET, 959DEFINE_CLOCK(uart3_ipg_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG7_OFFSET,
797 NULL, NULL, &ipg_clk, &spba_clk); 960 NULL, NULL, &ipg_clk, &spba_clk);
961DEFINE_CLOCK(uart1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG4_OFFSET,
962 NULL, NULL, &uart_root_clk, &uart1_ipg_clk);
963DEFINE_CLOCK(uart2_clk, 1, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG6_OFFSET,
964 NULL, NULL, &uart_root_clk, &uart2_ipg_clk);
965DEFINE_CLOCK(uart3_clk, 2, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG8_OFFSET,
966 NULL, NULL, &uart_root_clk, &uart3_ipg_clk);
798 967
799/* GPT */ 968/* GPT */
800DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
801 NULL, NULL, &ipg_clk, NULL);
802DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET, 969DEFINE_CLOCK(gpt_ipg_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG10_OFFSET,
803 NULL, NULL, &ipg_clk, NULL); 970 NULL, NULL, &ipg_clk, NULL);
971DEFINE_CLOCK(gpt_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG9_OFFSET,
972 NULL, NULL, &ipg_clk, &gpt_ipg_clk);
804 973
805/* I2C */ 974/* I2C */
806DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG9_OFFSET, 975DEFINE_CLOCK(i2c1_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG9_OFFSET,
@@ -814,6 +983,52 @@ DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
814DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET, 983DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
815 NULL, NULL, &ipg_clk, NULL); 984 NULL, NULL, &ipg_clk, NULL);
816 985
986/* NFC */
987DEFINE_CLOCK_CCGR(nfc_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG10_OFFSET,
988 clk_nfc, &emi_slow_clk, NULL);
989
990/* SSI */
991DEFINE_CLOCK(ssi1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG8_OFFSET,
992 NULL, NULL, &ipg_clk, NULL);
993DEFINE_CLOCK(ssi1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG9_OFFSET,
994 NULL, NULL, &pll3_sw_clk, &ssi1_ipg_clk);
995DEFINE_CLOCK(ssi2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG10_OFFSET,
996 NULL, NULL, &ipg_clk, NULL);
997DEFINE_CLOCK(ssi2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG11_OFFSET,
998 NULL, NULL, &pll3_sw_clk, &ssi2_ipg_clk);
999
1000/* eCSPI */
1001DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
1002 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
1003 &ipg_clk, &spba_clk);
1004DEFINE_CLOCK(ecspi1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG10_OFFSET,
1005 NULL, NULL, &ecspi_main_clk, &ecspi1_ipg_clk);
1006DEFINE_CLOCK_FULL(ecspi2_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG11_OFFSET,
1007 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
1008 &ipg_clk, &aips_tz2_clk);
1009DEFINE_CLOCK(ecspi2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG12_OFFSET,
1010 NULL, NULL, &ecspi_main_clk, &ecspi2_ipg_clk);
1011
1012/* CSPI */
1013DEFINE_CLOCK(cspi_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
1014 NULL, NULL, &ipg_clk, &aips_tz2_clk);
1015DEFINE_CLOCK(cspi_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET,
1016 NULL, NULL, &ipg_clk, &cspi_ipg_clk);
1017
1018/* SDMA */
1019DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET,
1020 NULL, NULL, &ahb_clk, NULL);
1021
1022/* eSDHC */
1023DEFINE_CLOCK_FULL(esdhc1_ipg_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG0_OFFSET,
1024 NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
1025DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
1026 clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk);
1027DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET,
1028 NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
1029DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
1030 clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk);
1031
817#define _REGISTER_CLOCK(d, n, c) \ 1032#define _REGISTER_CLOCK(d, n, c) \
818 { \ 1033 { \
819 .dev_id = d, \ 1034 .dev_id = d, \
@@ -837,6 +1052,18 @@ static struct clk_lookup lookups[] = {
837 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk) 1052 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
838 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk) 1053 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
839 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk) 1054 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk)
1055 _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk)
1056 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
1057 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
1058 _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk)
1059 _REGISTER_CLOCK(NULL, "ckih", ckih_clk)
1060 _REGISTER_CLOCK(NULL, "ckih2", ckih2_clk)
1061 _REGISTER_CLOCK(NULL, "gpt_32k", gpt_32k_clk)
1062 _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk)
1063 _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk)
1064 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)
1065 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
1066 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
840}; 1067};
841 1068
842static void clk_tree_init(void) 1069static void clk_tree_init(void)
@@ -880,6 +1107,14 @@ int __init mx51_clocks_init(unsigned long ckil, unsigned long osc,
880 /* set the usboh3_clk parent to pll2_sw_clk */ 1107 /* set the usboh3_clk parent to pll2_sw_clk */
881 clk_set_parent(&usboh3_clk, &pll2_sw_clk); 1108 clk_set_parent(&usboh3_clk, &pll2_sw_clk);
882 1109
1110 /* Set SDHC parents to be PLL2 */
1111 clk_set_parent(&esdhc1_clk, &pll2_sw_clk);
1112 clk_set_parent(&esdhc2_clk, &pll2_sw_clk);
1113
1114 /* set SDHC root clock as 166.25MHZ*/
1115 clk_set_rate(&esdhc1_clk, 166250000);
1116 clk_set_rate(&esdhc2_clk, 166250000);
1117
883 /* System timer */ 1118 /* System timer */
884 mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR), 1119 mxc_timer_init(&gpt_clk, MX51_IO_ADDRESS(MX51_GPT1_BASE_ADDR),
885 MX51_MXC_INT_GPT); 1120 MX51_MXC_INT_GPT);
diff --git a/arch/arm/mach-mx5/cpu.c b/arch/arm/mach-mx5/cpu.c
index 2d37785e3857..eaacb6e9b5d0 100644
--- a/arch/arm/mach-mx5/cpu.c
+++ b/arch/arm/mach-mx5/cpu.c
@@ -70,6 +70,25 @@ int mx51_revision(void)
70} 70}
71EXPORT_SYMBOL(mx51_revision); 71EXPORT_SYMBOL(mx51_revision);
72 72
73#ifdef CONFIG_NEON
74
75/*
76 * All versions of the silicon before Rev. 3 have broken NEON implementations.
77 * Dependent on link order - so the assumption is that vfp_init is called
78 * before us.
79 */
80static int __init mx51_neon_fixup(void)
81{
82 if (mx51_revision() < MX51_CHIP_REV_3_0 && (elf_hwcap & HWCAP_NEON)) {
83 elf_hwcap &= ~HWCAP_NEON;
84 pr_info("Turning off NEON support, detected broken NEON implementation\n");
85 }
86 return 0;
87}
88
89late_initcall(mx51_neon_fixup);
90#endif
91
73static int __init post_cpu_init(void) 92static int __init post_cpu_init(void)
74{ 93{
75 unsigned int reg; 94 unsigned int reg;
diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
new file mode 100644
index 000000000000..5cc910e60538
--- /dev/null
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include <mach/mx51.h>
10#include <mach/devices-common.h>
11
12extern const struct imx_fec_data imx51_fec_data __initconst;
13#define imx51_add_fec(pdata) \
14 imx_add_fec(&imx51_fec_data, pdata)
15
16extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
17#define imx51_add_imx_i2c(id, pdata) \
18 imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
19
20extern const struct imx_imx_ssi_data imx51_imx_ssi_data[] __initconst;
21#define imx51_add_imx_ssi(id, pdata) \
22 imx_add_imx_ssi(&imx51_imx_ssi_data[id], pdata)
23
24extern const struct imx_imx_uart_1irq_data imx51_imx_uart_data[] __initconst;
25#define imx51_add_imx_uart(id, pdata) \
26 imx_add_imx_uart_1irq(&imx51_imx_uart_data[id], pdata)
27
28extern const struct imx_mxc_nand_data imx51_mxc_nand_data __initconst;
29#define imx51_add_mxc_nand(pdata) \
30 imx_add_mxc_nand(&imx51_mxc_nand_data, pdata)
31
32extern const struct imx_spi_imx_data imx51_cspi_data __initconst;
33#define imx51_add_cspi(pdata) \
34 imx_add_spi_imx(&imx51_cspi_data, pdata)
35
36extern const struct imx_spi_imx_data imx51_ecspi_data[] __initconst;
37#define imx51_add_ecspi(id, pdata) \
38 imx_add_spi_imx(&imx51_ecspi_data[id], pdata)
39
40extern const struct imx_esdhc_imx_data imx51_esdhc_data[] __initconst;
41#define imx51_add_esdhc(id, pdata) \
42 imx_add_esdhc(&imx51_esdhc_data[id], pdata)
diff --git a/arch/arm/mach-mx5/devices.c b/arch/arm/mach-mx5/devices.c
index 1920ff4963b2..4c7be87a7c9d 100644
--- a/arch/arm/mach-mx5/devices.c
+++ b/arch/arm/mach-mx5/devices.c
@@ -17,120 +17,6 @@
17#include <mach/imx-uart.h> 17#include <mach/imx-uart.h>
18#include <mach/irqs.h> 18#include <mach/irqs.h>
19 19
20static struct resource uart0[] = {
21 {
22 .start = MX51_UART1_BASE_ADDR,
23 .end = MX51_UART1_BASE_ADDR + 0xfff,
24 .flags = IORESOURCE_MEM,
25 }, {
26 .start = MX51_MXC_INT_UART1,
27 .end = MX51_MXC_INT_UART1,
28 .flags = IORESOURCE_IRQ,
29 },
30};
31
32struct platform_device mxc_uart_device0 = {
33 .name = "imx-uart",
34 .id = 0,
35 .resource = uart0,
36 .num_resources = ARRAY_SIZE(uart0),
37};
38
39static struct resource uart1[] = {
40 {
41 .start = MX51_UART2_BASE_ADDR,
42 .end = MX51_UART2_BASE_ADDR + 0xfff,
43 .flags = IORESOURCE_MEM,
44 }, {
45 .start = MX51_MXC_INT_UART2,
46 .end = MX51_MXC_INT_UART2,
47 .flags = IORESOURCE_IRQ,
48 },
49};
50
51struct platform_device mxc_uart_device1 = {
52 .name = "imx-uart",
53 .id = 1,
54 .resource = uart1,
55 .num_resources = ARRAY_SIZE(uart1),
56};
57
58static struct resource uart2[] = {
59 {
60 .start = MX51_UART3_BASE_ADDR,
61 .end = MX51_UART3_BASE_ADDR + 0xfff,
62 .flags = IORESOURCE_MEM,
63 }, {
64 .start = MX51_MXC_INT_UART3,
65 .end = MX51_MXC_INT_UART3,
66 .flags = IORESOURCE_IRQ,
67 },
68};
69
70struct platform_device mxc_uart_device2 = {
71 .name = "imx-uart",
72 .id = 2,
73 .resource = uart2,
74 .num_resources = ARRAY_SIZE(uart2),
75};
76
77static struct resource mxc_fec_resources[] = {
78 {
79 .start = MX51_MXC_FEC_BASE_ADDR,
80 .end = MX51_MXC_FEC_BASE_ADDR + 0xfff,
81 .flags = IORESOURCE_MEM,
82 }, {
83 .start = MX51_MXC_INT_FEC,
84 .end = MX51_MXC_INT_FEC,
85 .flags = IORESOURCE_IRQ,
86 },
87};
88
89struct platform_device mxc_fec_device = {
90 .name = "fec",
91 .id = 0,
92 .num_resources = ARRAY_SIZE(mxc_fec_resources),
93 .resource = mxc_fec_resources,
94};
95
96static struct resource mxc_i2c0_resources[] = {
97 {
98 .start = MX51_I2C1_BASE_ADDR,
99 .end = MX51_I2C1_BASE_ADDR + SZ_4K - 1,
100 .flags = IORESOURCE_MEM,
101 }, {
102 .start = MX51_MXC_INT_I2C1,
103 .end = MX51_MXC_INT_I2C1,
104 .flags = IORESOURCE_IRQ,
105 },
106};
107
108struct platform_device mxc_i2c_device0 = {
109 .name = "imx-i2c",
110 .id = 0,
111 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
112 .resource = mxc_i2c0_resources,
113};
114
115static struct resource mxc_i2c1_resources[] = {
116 {
117 .start = MX51_I2C2_BASE_ADDR,
118 .end = MX51_I2C2_BASE_ADDR + SZ_4K - 1,
119 .flags = IORESOURCE_MEM,
120 }, {
121 .start = MX51_MXC_INT_I2C2,
122 .end = MX51_MXC_INT_I2C2,
123 .flags = IORESOURCE_IRQ,
124 },
125};
126
127struct platform_device mxc_i2c_device1 = {
128 .name = "imx-i2c",
129 .id = 1,
130 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
131 .resource = mxc_i2c1_resources,
132};
133
134static struct resource mxc_hsi2c_resources[] = { 20static struct resource mxc_hsi2c_resources[] = {
135 { 21 {
136 .start = MX51_HSI2C_DMA_BASE_ADDR, 22 .start = MX51_HSI2C_DMA_BASE_ADDR,
diff --git a/arch/arm/mach-mx5/devices.h b/arch/arm/mach-mx5/devices.h
index e509cfaad1d4..af1d07c0bbc1 100644
--- a/arch/arm/mach-mx5/devices.h
+++ b/arch/arm/mach-mx5/devices.h
@@ -1,12 +1,6 @@
1extern struct platform_device mxc_uart_device0;
2extern struct platform_device mxc_uart_device1;
3extern struct platform_device mxc_uart_device2;
4extern struct platform_device mxc_fec_device;
5extern struct platform_device mxc_usbdr_host_device; 1extern struct platform_device mxc_usbdr_host_device;
6extern struct platform_device mxc_usbh1_device; 2extern struct platform_device mxc_usbh1_device;
7extern struct platform_device mxc_usbdr_udc_device; 3extern struct platform_device mxc_usbdr_udc_device;
8extern struct platform_device mxc_wdt; 4extern struct platform_device mxc_wdt;
9extern struct platform_device mxc_i2c_device0;
10extern struct platform_device mxc_i2c_device1;
11extern struct platform_device mxc_hsi2c_device; 5extern struct platform_device mxc_hsi2c_device;
12extern struct platform_device mxc_keypad_device; 6extern struct platform_device mxc_keypad_device;
diff --git a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
index ffa93d1d6ef8..a2e6e8c39d25 100644
--- a/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
+++ b/arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
@@ -30,6 +30,7 @@
30 30
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32 32
33#include "devices-imx51.h"
33#include "devices.h" 34#include "devices.h"
34 35
35#define MBIMX51_TSC2007_GPIO (2*32 + 30) 36#define MBIMX51_TSC2007_GPIO (2*32 + 30)
@@ -112,9 +113,25 @@ static struct pad_desc mbimx51_pads[] = {
112 MX51_PAD_KEY_COL1__KEY_COL1, 113 MX51_PAD_KEY_COL1__KEY_COL1,
113 MX51_PAD_KEY_COL2__KEY_COL2, 114 MX51_PAD_KEY_COL2__KEY_COL2,
114 MX51_PAD_KEY_COL3__KEY_COL3, 115 MX51_PAD_KEY_COL3__KEY_COL3,
116
117 /* SD 1 */
118 MX51_PAD_SD1_CMD__SD1_CMD,
119 MX51_PAD_SD1_CLK__SD1_CLK,
120 MX51_PAD_SD1_DATA0__SD1_DATA0,
121 MX51_PAD_SD1_DATA1__SD1_DATA1,
122 MX51_PAD_SD1_DATA2__SD1_DATA2,
123 MX51_PAD_SD1_DATA3__SD1_DATA3,
124
125 /* SD 2 */
126 MX51_PAD_SD2_CMD__SD2_CMD,
127 MX51_PAD_SD2_CLK__SD2_CLK,
128 MX51_PAD_SD2_DATA0__SD2_DATA0,
129 MX51_PAD_SD2_DATA1__SD2_DATA1,
130 MX51_PAD_SD2_DATA2__SD2_DATA2,
131 MX51_PAD_SD2_DATA3__SD2_DATA3,
115}; 132};
116 133
117static struct imxuart_platform_data uart_pdata = { 134static const struct imxuart_platform_data uart_pdata __initconst = {
118 .flags = IMXUART_HAVE_RTSCTS, 135 .flags = IMXUART_HAVE_RTSCTS,
119}; 136};
120 137
@@ -158,9 +175,11 @@ struct tsc2007_platform_data tsc2007_data = {
158 175
159static struct i2c_board_info mbimx51_i2c_devices[] = { 176static struct i2c_board_info mbimx51_i2c_devices[] = {
160 { 177 {
161 I2C_BOARD_INFO("tsc2007", 0x48), 178 I2C_BOARD_INFO("tsc2007", 0x49),
162 .irq = MBIMX51_TSC2007_IRQ, 179 .irq = MBIMX51_TSC2007_IRQ,
163 .platform_data = &tsc2007_data, 180 .platform_data = &tsc2007_data,
181 }, {
182 I2C_BOARD_INFO("tlv320aic23", 0x1a),
164 }, 183 },
165}; 184};
166 185
@@ -172,8 +191,8 @@ void __init eukrea_mbimx51_baseboard_init(void)
172 mxc_iomux_v3_setup_multiple_pads(mbimx51_pads, 191 mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
173 ARRAY_SIZE(mbimx51_pads)); 192 ARRAY_SIZE(mbimx51_pads));
174 193
175 mxc_register_device(&mxc_uart_device1, NULL); 194 imx51_add_imx_uart(1, NULL);
176 mxc_register_device(&mxc_uart_device2, &uart_pdata); 195 imx51_add_imx_uart(2, &uart_pdata);
177 196
178 gpio_request(MBIMX51_LED0, "LED0"); 197 gpio_request(MBIMX51_LED0, "LED0");
179 gpio_direction_output(MBIMX51_LED0, 1); 198 gpio_direction_output(MBIMX51_LED0, 1);
@@ -197,4 +216,7 @@ void __init eukrea_mbimx51_baseboard_init(void)
197 set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING); 216 set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
198 i2c_register_board_info(1, mbimx51_i2c_devices, 217 i2c_register_board_info(1, mbimx51_i2c_devices,
199 ARRAY_SIZE(mbimx51_i2c_devices)); 218 ARRAY_SIZE(mbimx51_i2c_devices));
219
220 imx51_add_esdhc(0, NULL);
221 imx51_add_esdhc(1, NULL);
200} 222}
diff --git a/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
new file mode 100644
index 000000000000..2b48f5190830
--- /dev/null
+++ b/arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
@@ -0,0 +1,166 @@
1/*
2 * Copyright (C) 2010 Eric Benard - eric@eukrea.com
3 *
4 * Based on pcm970-baseboard.c which is :
5 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22#include <linux/types.h>
23#include <linux/init.h>
24
25#include <linux/gpio.h>
26#include <linux/interrupt.h>
27#include <linux/irq.h>
28#include <linux/leds.h>
29#include <linux/platform_device.h>
30#include <linux/gpio_keys.h>
31#include <linux/input.h>
32#include <linux/i2c.h>
33
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/time.h>
37#include <asm/mach/map.h>
38
39#include <mach/hardware.h>
40#include <mach/common.h>
41#include <mach/imx-uart.h>
42#include <mach/iomux-mx51.h>
43#include <mach/audmux.h>
44
45#include "devices-imx51.h"
46#include "devices.h"
47
48#define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \
49 MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
50
51static struct pad_desc eukrea_mbimxsd_pads[] = {
52 /* LED */
53 MX51_PAD_NANDF_D10__GPIO_3_30,
54 /* SWITCH */
55 MBIMXSD_GPIO_3_31,
56 /* UART2 */
57 MX51_PAD_UART2_RXD__UART2_RXD,
58 MX51_PAD_UART2_TXD__UART2_TXD,
59 /* UART 3 */
60 MX51_PAD_UART3_RXD__UART3_RXD,
61 MX51_PAD_UART3_TXD__UART3_TXD,
62 MX51_PAD_KEY_COL4__UART3_RTS,
63 MX51_PAD_KEY_COL5__UART3_CTS,
64 /* SD */
65 MX51_PAD_SD1_CMD__SD1_CMD,
66 MX51_PAD_SD1_CLK__SD1_CLK,
67 MX51_PAD_SD1_DATA0__SD1_DATA0,
68 MX51_PAD_SD1_DATA1__SD1_DATA1,
69 MX51_PAD_SD1_DATA2__SD1_DATA2,
70 MX51_PAD_SD1_DATA3__SD1_DATA3,
71};
72
73#define GPIO_LED1 (2 * 32 + 30)
74#define GPIO_SWITCH1 (2 * 32 + 31)
75
76static struct gpio_led eukrea_mbimxsd_leds[] = {
77 {
78 .name = "led1",
79 .default_trigger = "heartbeat",
80 .active_low = 1,
81 .gpio = GPIO_LED1,
82 },
83};
84
85static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
86 .leds = eukrea_mbimxsd_leds,
87 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
88};
89
90static struct platform_device eukrea_mbimxsd_leds_gpio = {
91 .name = "leds-gpio",
92 .id = -1,
93 .dev = {
94 .platform_data = &eukrea_mbimxsd_led_info,
95 },
96};
97
98static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
99 {
100 .gpio = GPIO_SWITCH1,
101 .code = BTN_0,
102 .desc = "BP1",
103 .active_low = 1,
104 .wakeup = 1,
105 },
106};
107
108static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = {
109 .buttons = eukrea_mbimxsd_gpio_buttons,
110 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
111};
112
113static struct platform_device eukrea_mbimxsd_button_device = {
114 .name = "gpio-keys",
115 .id = -1,
116 .num_resources = 0,
117 .dev = {
118 .platform_data = &eukrea_mbimxsd_button_data,
119 }
120};
121
122static struct platform_device *platform_devices[] __initdata = {
123 &eukrea_mbimxsd_leds_gpio,
124 &eukrea_mbimxsd_button_device,
125};
126
127static const struct imxuart_platform_data uart_pdata __initconst = {
128 .flags = IMXUART_HAVE_RTSCTS,
129};
130
131static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
132 {
133 I2C_BOARD_INFO("tlv320aic23", 0x1a),
134 },
135};
136
137/*
138 * system init for baseboard usage. Will be called by cpuimx51sd init.
139 *
140 * Add platform devices present on this baseboard and init
141 * them from CPU side as far as required to use them later on
142 */
143void __init eukrea_mbimxsd51_baseboard_init(void)
144{
145 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
146 ARRAY_SIZE(eukrea_mbimxsd_pads)))
147 printk(KERN_ERR "error setting mbimxsd pads !\n");
148
149 imx51_add_imx_uart(1, NULL);
150 imx51_add_imx_uart(2, &uart_pdata);
151
152 imx51_add_esdhc(0, NULL);
153
154 gpio_request(GPIO_LED1, "LED1");
155 gpio_direction_output(GPIO_LED1, 1);
156 gpio_free(GPIO_LED1);
157
158 gpio_request(GPIO_SWITCH1, "SWITCH1");
159 gpio_direction_input(GPIO_SWITCH1);
160 gpio_free(GPIO_SWITCH1);
161
162 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
163 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
164
165 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
166}
diff --git a/arch/arm/mach-mxc91231/magx-zn5.c b/arch/arm/mach-mxc91231/magx-zn5.c
index 69816ba82930..395d83be8c98 100644
--- a/arch/arm/mach-mxc91231/magx-zn5.c
+++ b/arch/arm/mach-mxc91231/magx-zn5.c
@@ -53,8 +53,6 @@ struct sys_timer zn5_timer = {
53}; 53};
54 54
55MACHINE_START(MAGX_ZN5, "Motorola Zn5") 55MACHINE_START(MAGX_ZN5, "Motorola Zn5")
56 .phys_io = MXC91231_AIPS1_BASE_ADDR,
57 .io_pg_offst = ((MXC91231_AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
58 .boot_params = MXC91231_PHYS_OFFSET + 0x100, 56 .boot_params = MXC91231_PHYS_OFFSET + 0x100,
59 .map_io = mxc91231_map_io, 57 .map_io = mxc91231_map_io,
60 .init_irq = mxc91231_init_irq, 58 .init_irq = mxc91231_init_irq,
diff --git a/arch/arm/mach-netx/include/mach/debug-macro.S b/arch/arm/mach-netx/include/mach/debug-macro.S
index e96339e71d88..56a915228180 100644
--- a/arch/arm/mach-netx/include/mach/debug-macro.S
+++ b/arch/arm/mach-netx/include/mach/debug-macro.S
@@ -13,12 +13,10 @@
13 13
14#include "hardware.h" 14#include "hardware.h"
15 15
16 .macro addruart, rx, tmp 16 .macro addruart, rp, rv
17 mrc p15, 0, \rx, c1, c0 17 mov \rp, #0x00000a00
18 tst \rx, #1 @ MMU enabled? 18 orr \rv, \rp, #io_p2v(0x00100000) @ virtual
19 moveq \rx, #0x00100000 @ physical 19 orr \rp, \rp, #0x00100000 @ physical
20 movne \rx, #io_p2v(0x00100000) @ virtual
21 orr \rx, \rx, #0x00000a00
22 .endm 20 .endm
23 21
24 .macro senduart,rd,rx 22 .macro senduart,rd,rx
diff --git a/arch/arm/mach-netx/include/mach/vmalloc.h b/arch/arm/mach-netx/include/mach/vmalloc.h
index 25d5cc676e0f..7cca3574308f 100644
--- a/arch/arm/mach-netx/include/mach/vmalloc.h
+++ b/arch/arm/mach-netx/include/mach/vmalloc.h
@@ -16,4 +16,4 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 19#define VMALLOC_END 0xd0000000
diff --git a/arch/arm/mach-netx/nxdb500.c b/arch/arm/mach-netx/nxdb500.c
index c9b174bc8ccf..ca8b203a3c99 100644
--- a/arch/arm/mach-netx/nxdb500.c
+++ b/arch/arm/mach-netx/nxdb500.c
@@ -200,8 +200,6 @@ static void __init nxdb500_init(void)
200} 200}
201 201
202MACHINE_START(NXDB500, "Hilscher nxdb500") 202MACHINE_START(NXDB500, "Hilscher nxdb500")
203 .phys_io = 0x00100000,
204 .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc,
205 .boot_params = 0x80000100, 203 .boot_params = 0x80000100,
206 .map_io = netx_map_io, 204 .map_io = netx_map_io,
207 .init_irq = netx_init_irq, 205 .init_irq = netx_init_irq,
diff --git a/arch/arm/mach-netx/nxdkn.c b/arch/arm/mach-netx/nxdkn.c
index 15b54c62d60f..d775cbe07278 100644
--- a/arch/arm/mach-netx/nxdkn.c
+++ b/arch/arm/mach-netx/nxdkn.c
@@ -93,8 +93,6 @@ static void __init nxdkn_init(void)
93} 93}
94 94
95MACHINE_START(NXDKN, "Hilscher nxdkn") 95MACHINE_START(NXDKN, "Hilscher nxdkn")
96 .phys_io = 0x00100000,
97 .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc,
98 .boot_params = 0x80000100, 96 .boot_params = 0x80000100,
99 .map_io = netx_map_io, 97 .map_io = netx_map_io,
100 .init_irq = netx_init_irq, 98 .init_irq = netx_init_irq,
diff --git a/arch/arm/mach-netx/nxeb500hmi.c b/arch/arm/mach-netx/nxeb500hmi.c
index 1061c01ff679..de369cd1dcbe 100644
--- a/arch/arm/mach-netx/nxeb500hmi.c
+++ b/arch/arm/mach-netx/nxeb500hmi.c
@@ -177,8 +177,6 @@ static void __init nxeb500hmi_init(void)
177} 177}
178 178
179MACHINE_START(NXEB500HMI, "Hilscher nxeb500hmi") 179MACHINE_START(NXEB500HMI, "Hilscher nxeb500hmi")
180 .phys_io = 0x00100000,
181 .io_pg_offst = (io_p2v(0x00100000) >> 18) & 0xfffc,
182 .boot_params = 0x80000100, 180 .boot_params = 0x80000100,
183 .map_io = netx_map_io, 181 .map_io = netx_map_io,
184 .init_irq = netx_init_irq, 182 .init_irq = netx_init_irq,
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c
index 841d459ad59d..139930350d93 100644
--- a/arch/arm/mach-nomadik/board-nhk8815.c
+++ b/arch/arm/mach-nomadik/board-nhk8815.c
@@ -276,8 +276,6 @@ static void __init nhk8815_platform_init(void)
276 276
277MACHINE_START(NOMADIK, "NHK8815") 277MACHINE_START(NOMADIK, "NHK8815")
278 /* Maintainer: ST MicroElectronics */ 278 /* Maintainer: ST MicroElectronics */
279 .phys_io = NOMADIK_UART0_BASE,
280 .io_pg_offst = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc,
281 .boot_params = 0x100, 279 .boot_params = 0x100,
282 .map_io = cpu8815_map_io, 280 .map_io = cpu8815_map_io,
283 .init_irq = cpu8815_init_irq, 281 .init_irq = cpu8815_init_irq,
diff --git a/arch/arm/mach-nomadik/include/mach/debug-macro.S b/arch/arm/mach-nomadik/include/mach/debug-macro.S
index 4f92acfba954..e7151b4b8889 100644
--- a/arch/arm/mach-nomadik/include/mach/debug-macro.S
+++ b/arch/arm/mach-nomadik/include/mach/debug-macro.S
@@ -10,13 +10,11 @@
10 * 10 *
11*/ 11*/
12 12
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 mrc p15, 0, \rx, c1, c0 14 mov \rp, #0x00100000
15 tst \rx, #1 @ MMU enabled? 15 add \rp, \rp, #0x000fb000
16 moveq \rx, #0x10000000 @ physical base address 16 add \rv, \rp, #0xf0000000 @ virtual base
17 movne \rx, #0xf0000000 @ virtual base 17 add \rp, \rp, #0x10000000 @ physical base address
18 add \rx, \rx, #0x00100000
19 add \rx, \rx, #0x000fb000
20 .endm 18 .endm
21 19
22#include <asm/hardware/debug-pl01x.S> 20#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-ns9xxx/include/mach/debug-macro.S b/arch/arm/mach-ns9xxx/include/mach/debug-macro.S
index 5c934bdb7158..5a2acbdc3d67 100644
--- a/arch/arm/mach-ns9xxx/include/mach/debug-macro.S
+++ b/arch/arm/mach-ns9xxx/include/mach/debug-macro.S
@@ -12,11 +12,9 @@
12 12
13#include <mach/regs-board-a9m9750dev.h> 13#include <mach/regs-board-a9m9750dev.h>
14 14
15 .macro addruart, rx, tmp 15 .macro addruart, rp, rv
16 mrc p15, 0, \rx, c1, c0 16 ldr \rp, =NS9XXX_CSxSTAT_PHYS(0)
17 tst \rx, #1 17 ldr \rv, =io_p2v(NS9XXX_CSxSTAT_PHYS(0))
18 ldreq \rx, =NS9XXX_CSxSTAT_PHYS(0)
19 ldrne \rx, =io_p2v(NS9XXX_CSxSTAT_PHYS(0))
20 .endm 18 .endm
21 19
22#define UART_SHIFT 2 20#define UART_SHIFT 2
diff --git a/arch/arm/mach-nuc93x/mach-nuc932evb.c b/arch/arm/mach-nuc93x/mach-nuc932evb.c
index 9f79266f08e2..d70257042480 100644
--- a/arch/arm/mach-nuc93x/mach-nuc932evb.c
+++ b/arch/arm/mach-nuc93x/mach-nuc932evb.c
@@ -35,8 +35,6 @@ static void __init nuc932evb_init(void)
35 35
36MACHINE_START(NUC932EVB, "NUC932EVB") 36MACHINE_START(NUC932EVB, "NUC932EVB")
37 /* Maintainer: Wan ZongShun */ 37 /* Maintainer: Wan ZongShun */
38 .phys_io = NUC93X_PA_UART,
39 .io_pg_offst = (((u32)NUC93X_VA_UART) >> 18) & 0xfffc,
40 .boot_params = 0, 38 .boot_params = 0,
41 .map_io = nuc932evb_map_io, 39 .map_io = nuc932evb_map_io,
42 .init_irq = nuc93x_init_irq, 40 .init_irq = nuc93x_init_irq,
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 3b02d3b944af..5f6496375404 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -128,7 +128,7 @@ config MACH_OMAP_PALMTT
128 help 128 help
129 Support for the Palm Tungsten|T PDA. To boot the kernel, you'll 129 Support for the Palm Tungsten|T PDA. To boot the kernel, you'll
130 need a PalmOS compatible bootloader (Garux); check out 130 need a PalmOS compatible bootloader (Garux); check out
131 http://www.hackndev.com/palm/tt/ for more information. 131 http://garux.sourceforge.net/ for more information.
132 Say Y here if you have this PDA model, say N otherwise. 132 Say Y here if you have this PDA model, say N otherwise.
133 133
134config MACH_SX1 134config MACH_SX1
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 41992ab71961..73c86392fcd3 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -297,8 +297,6 @@ static void __init ams_delta_map_io(void)
297 297
298MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)") 298MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
299 /* Maintainer: Jonathan McDowell <noodles@earth.li> */ 299 /* Maintainer: Jonathan McDowell <noodles@earth.li> */
300 .phys_io = 0xfff00000,
301 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
302 .boot_params = 0x10000100, 300 .boot_params = 0x10000100,
303 .map_io = ams_delta_map_io, 301 .map_io = ams_delta_map_io,
304 .reserve = omap_reserve, 302 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index 180ce79e5eac..149fdd32e127 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -386,8 +386,6 @@ static void __init omap_fsample_map_io(void)
386 386
387MACHINE_START(OMAP_FSAMPLE, "OMAP730 F-Sample") 387MACHINE_START(OMAP_FSAMPLE, "OMAP730 F-Sample")
388/* Maintainer: Brian Swetland <swetland@google.com> */ 388/* Maintainer: Brian Swetland <swetland@google.com> */
389 .phys_io = 0xfff00000,
390 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
391 .boot_params = 0x10000100, 389 .boot_params = 0x10000100,
392 .map_io = omap_fsample_map_io, 390 .map_io = omap_fsample_map_io,
393 .reserve = omap_reserve, 391 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c
index 93b9ab8fc3be..23f4ab9e2651 100644
--- a/arch/arm/mach-omap1/board-generic.c
+++ b/arch/arm/mach-omap1/board-generic.c
@@ -94,8 +94,6 @@ static void __init omap_generic_map_io(void)
94 94
95MACHINE_START(OMAP_GENERIC, "Generic OMAP1510/1610/1710") 95MACHINE_START(OMAP_GENERIC, "Generic OMAP1510/1610/1710")
96 /* Maintainer: Tony Lindgren <tony@atomide.com> */ 96 /* Maintainer: Tony Lindgren <tony@atomide.com> */
97 .phys_io = 0xfff00000,
98 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
99 .boot_params = 0x10000100, 97 .boot_params = 0x10000100,
100 .map_io = omap_generic_map_io, 98 .map_io = omap_generic_map_io,
101 .reserve = omap_reserve, 99 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index d2cda58bcc48..197adb49dc5a 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -458,8 +458,6 @@ static void __init h2_map_io(void)
458 458
459MACHINE_START(OMAP_H2, "TI-H2") 459MACHINE_START(OMAP_H2, "TI-H2")
460 /* Maintainer: Imre Deak <imre.deak@nokia.com> */ 460 /* Maintainer: Imre Deak <imre.deak@nokia.com> */
461 .phys_io = 0xfff00000,
462 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
463 .boot_params = 0x10000100, 461 .boot_params = 0x10000100,
464 .map_io = h2_map_io, 462 .map_io = h2_map_io,
465 .reserve = omap_reserve, 463 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index c2ef4ff846c7..9126e3e37b4a 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -446,8 +446,6 @@ static void __init h3_map_io(void)
446 446
447MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board") 447MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
448 /* Maintainer: Texas Instruments, Inc. */ 448 /* Maintainer: Texas Instruments, Inc. */
449 .phys_io = 0xfff00000,
450 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
451 .boot_params = 0x10000100, 449 .boot_params = 0x10000100,
452 .map_io = h3_map_io, 450 .map_io = h3_map_io,
453 .reserve = omap_reserve, 451 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c
index 311899ff5ffc..86afb2952225 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -300,8 +300,6 @@ static void __init htcherald_init_irq(void)
300MACHINE_START(HERALD, "HTC Herald") 300MACHINE_START(HERALD, "HTC Herald")
301 /* Maintainer: Cory Maccarrone <darkstar6262@gmail.com> */ 301 /* Maintainer: Cory Maccarrone <darkstar6262@gmail.com> */
302 /* Maintainer: wing-linux.sourceforge.net */ 302 /* Maintainer: wing-linux.sourceforge.net */
303 .phys_io = 0xfff00000,
304 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
305 .boot_params = 0x10000100, 303 .boot_params = 0x10000100,
306 .map_io = htcherald_map_io, 304 .map_io = htcherald_map_io,
307 .reserve = omap_reserve, 305 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index 3daf87ad2576..dc2b86fd66c1 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -459,8 +459,6 @@ static void __init innovator_map_io(void)
459 459
460MACHINE_START(OMAP_INNOVATOR, "TI-Innovator") 460MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
461 /* Maintainer: MontaVista Software, Inc. */ 461 /* Maintainer: MontaVista Software, Inc. */
462 .phys_io = 0xfff00000,
463 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
464 .boot_params = 0x10000100, 462 .boot_params = 0x10000100,
465 .map_io = innovator_map_io, 463 .map_io = innovator_map_io,
466 .reserve = omap_reserve, 464 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 51a4539aecf5..aa8375b2a0a3 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -262,8 +262,6 @@ static void __init omap_nokia770_map_io(void)
262} 262}
263 263
264MACHINE_START(NOKIA770, "Nokia 770") 264MACHINE_START(NOKIA770, "Nokia 770")
265 .phys_io = 0xfff00000,
266 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
267 .boot_params = 0x10000100, 265 .boot_params = 0x10000100,
268 .map_io = omap_nokia770_map_io, 266 .map_io = omap_nokia770_map_io,
269 .reserve = omap_reserve, 267 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 679740cc1e90..e9dd79149a8e 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -580,8 +580,6 @@ static void __init osk_map_io(void)
580 580
581MACHINE_START(OMAP_OSK, "TI-OSK") 581MACHINE_START(OMAP_OSK, "TI-OSK")
582 /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ 582 /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
583 .phys_io = 0xfff00000,
584 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
585 .boot_params = 0x10000100, 583 .boot_params = 0x10000100,
586 .map_io = osk_map_io, 584 .map_io = osk_map_io,
587 .reserve = omap_reserve, 585 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index 782bb257a85d..f32738b1eb6b 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -285,8 +285,6 @@ static void __init omap_palmte_map_io(void)
285} 285}
286 286
287MACHINE_START(OMAP_PALMTE, "OMAP310 based Palm Tungsten E") 287MACHINE_START(OMAP_PALMTE, "OMAP310 based Palm Tungsten E")
288 .phys_io = 0xfff00000,
289 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
290 .boot_params = 0x10000100, 288 .boot_params = 0x10000100,
291 .map_io = omap_palmte_map_io, 289 .map_io = omap_palmte_map_io,
292 .reserve = omap_reserve, 290 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-palmtt.c b/arch/arm/mach-omap1/board-palmtt.c
index 0b35ef54a64f..ed1400a67f75 100644
--- a/arch/arm/mach-omap1/board-palmtt.c
+++ b/arch/arm/mach-omap1/board-palmtt.c
@@ -317,8 +317,6 @@ static void __init omap_palmtt_map_io(void)
317} 317}
318 318
319MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T") 319MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
320 .phys_io = 0xfff00000,
321 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
322 .boot_params = 0x10000100, 320 .boot_params = 0x10000100,
323 .map_io = omap_palmtt_map_io, 321 .map_io = omap_palmtt_map_io,
324 .reserve = omap_reserve, 322 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index 66362903b6e2..d7a245cef9a4 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -338,8 +338,6 @@ omap_palmz71_map_io(void)
338} 338}
339 339
340MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71") 340MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
341 .phys_io = 0xfff00000,
342 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
343 .boot_params = 0x10000100, 341 .boot_params = 0x10000100,
344 .map_io = omap_palmz71_map_io, 342 .map_io = omap_palmz71_map_io,
345 .reserve = omap_reserve, 343 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index 34ab354758b0..a8d16a255c18 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -347,8 +347,6 @@ static void __init omap_perseus2_map_io(void)
347 347
348MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2") 348MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
349 /* Maintainer: Kevin Hilman <kjh@hilman.org> */ 349 /* Maintainer: Kevin Hilman <kjh@hilman.org> */
350 .phys_io = 0xfff00000,
351 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
352 .boot_params = 0x10000100, 350 .boot_params = 0x10000100,
353 .map_io = omap_perseus2_map_io, 351 .map_io = omap_perseus2_map_io,
354 .reserve = omap_reserve, 352 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 2eb148b8de93..d25f59e5a773 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -419,8 +419,6 @@ static void __init omap_sx1_map_io(void)
419} 419}
420 420
421MACHINE_START(SX1, "OMAP310 based Siemens SX1") 421MACHINE_START(SX1, "OMAP310 based Siemens SX1")
422 .phys_io = 0xfff00000,
423 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
424 .boot_params = 0x10000100, 422 .boot_params = 0x10000100,
425 .map_io = omap_sx1_map_io, 423 .map_io = omap_sx1_map_io,
426 .reserve = omap_reserve, 424 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 6b3cf14bc757..f5992c239bcd 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -283,8 +283,6 @@ EXPORT_SYMBOL(voiceblue_wdt_ping);
283 283
284MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910") 284MACHINE_START(VOICEBLUE, "VoiceBlue OMAP5910")
285 /* Maintainer: Ladislav Michl <michl@2n.cz> */ 285 /* Maintainer: Ladislav Michl <michl@2n.cz> */
286 .phys_io = 0xfff00000,
287 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
288 .boot_params = 0x10000100, 286 .boot_params = 0x10000100,
289 .map_io = voiceblue_map_io, 287 .map_io = voiceblue_map_io,
290 .reserve = omap_reserve, 288 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap1/include/mach/debug-macro.S b/arch/arm/mach-omap1/include/mach/debug-macro.S
index 671408eb4ab4..6a0fa0462365 100644
--- a/arch/arm/mach-omap1/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap1/include/mach/debug-macro.S
@@ -28,56 +28,58 @@ omap_uart_virt: .word 0x0
28 * the desired UART phys and virt addresses temporarily into 28 * the desired UART phys and virt addresses temporarily into
29 * the omap_uart_phys and omap_uart_virt above. 29 * the omap_uart_phys and omap_uart_virt above.
30 */ 30 */
31 .macro addruart, rx, tmp 31 .macro addruart, rp, rv
32 32
33 /* Use omap_uart_phys/virt if already configured */ 33 /* Use omap_uart_phys/virt if already configured */
349: mrc p15, 0, \rx, c1, c0 349: mrc p15, 0, \rp, c1, c0
35 tst \rx, #1 @ MMU enabled? 35 tst \rp, #1 @ MMU enabled?
36 ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address 36 ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
37 ldrne \rx, =omap_uart_virt @ virtual base 37 ldrne \rp, =omap_uart_phys @ MMU enabled
38 ldr \rx, [\rx, #0] 38 add \rv, \rp, #4 @ omap_uart_virt
39 cmp \rx, #0 @ is port configured? 39 ldr \rp, [\rp, #0]
40 ldr \rv, [\rv, #0]
41 cmp \rp, #0 @ is port configured?
42 cmpne \rv, #0
40 bne 99f @ already configured 43 bne 99f @ already configured
41 44
42 /* Check the debug UART configuration set in uncompress.h */ 45 /* Check the debug UART configuration set in uncompress.h */
43 mrc p15, 0, \rx, c1, c0 46 mrc p15, 0, \rp, c1, c0
44 tst \rx, #1 @ MMU enabled? 47 tst \rp, #1 @ MMU enabled?
45 ldreq \rx, =OMAP_UART_INFO 48 ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
46 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO) 49 ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled
47 ldr \rx, [\rx, #0] 50 ldr \rp, [\rp, #0]
48 51
49 /* Select the UART to use based on the UART1 scratchpad value */ 52 /* Select the UART to use based on the UART1 scratchpad value */
5010: cmp \rx, #0 @ no port configured? 5310: cmp \rp, #0 @ no port configured?
51 beq 11f @ if none, try to use UART1 54 beq 11f @ if none, try to use UART1
52 cmp \rx, #OMAP1UART1 55 cmp \rp, #OMAP1UART1
53 beq 11f @ configure OMAP1UART1 56 beq 11f @ configure OMAP1UART1
54 cmp \rx, #OMAP1UART2 57 cmp \rp, #OMAP1UART2
55 beq 12f @ configure OMAP1UART2 58 beq 12f @ configure OMAP1UART2
56 cmp \rx, #OMAP1UART3 59 cmp \rp, #OMAP1UART3
57 beq 13f @ configure OMAP2UART3 60 beq 13f @ configure OMAP2UART3
58 61
59 /* Configure the UART offset from the phys/virt base */ 62 /* Configure the UART offset from the phys/virt base */
6011: mov \rx, #0x00fb0000 @ OMAP1UART1 6311: mov \rp, #0x00fb0000 @ OMAP1UART1
61 b 98f 64 b 98f
6212: mov \rx, #0x00fb0000 @ OMAP1UART1 6512: mov \rp, #0x00fb0000 @ OMAP1UART1
63 orr \rx, \rx, #0x00000800 @ OMAP1UART2 66 orr \rp, \rp, #0x00000800 @ OMAP1UART2
64 b 98f 67 b 98f
6513: mov \rx, #0x00fb0000 @ OMAP1UART1 6813: mov \rp, #0x00fb0000 @ OMAP1UART1
66 orr \rx, \rx, #0x00000800 @ OMAP1UART2 69 orr \rp, \rp, #0x00000800 @ OMAP1UART2
67 orr \rx, \rx, #0x00009000 @ OMAP1UART3 70 orr \rp, \rp, #0x00009000 @ OMAP1UART3
68 71
69 /* Store both phys and virt address for the uart */ 72 /* Store both phys and virt address for the uart */
7098: add \rx, \rx, #0xff000000 @ phys base 7398: add \rp, \rp, #0xff000000 @ phys base
71 mrc p15, 0, \tmp, c1, c0 74 mrc p15, 0, \rv, c1, c0
72 tst \tmp, #1 @ MMU enabled? 75 tst \rv, #1 @ MMU enabled?
73 ldreq \tmp, =__virt_to_phys(omap_uart_phys) 76 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
74 ldrne \tmp, =omap_uart_phys 77 ldrne \rv, =omap_uart_phys @ MMU enabled
75 str \rx, [\tmp, #0] 78 str \rp, [\rv, #0]
76 sub \rx, \rx, #0xff000000 @ phys base 79 sub \rp, \rp, #0xff000000 @ phys base
77 add \rx, \rx, #0xfe000000 @ virt base 80 add \rp, \rp, #0xfe000000 @ virt base
78 ldreq \tmp, =__virt_to_phys(omap_uart_virt) 81 add \rv, \rv, #4 @ omap_uart_lsr
79 ldrne \tmp, =omap_uart_virt 82 str \rp, [\rv, #0]
80 str \rx, [\tmp, #0]
81 b 9b 83 b 9b
8299: 8499:
83 .endm 85 .endm
diff --git a/arch/arm/mach-omap1/include/mach/vmalloc.h b/arch/arm/mach-omap1/include/mach/vmalloc.h
index 1b2af14df151..b001f67d695b 100644
--- a/arch/arm/mach-omap1/include/mach/vmalloc.h
+++ b/arch/arm/mach-omap1/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END (PAGE_OFFSET + 0x18000000) 20#define VMALLOC_END 0xd8000000
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 8538e4131d27..b857ce484510 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -253,8 +253,6 @@ static void __init omap_2430sdp_map_io(void)
253 253
254MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board") 254MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
255 /* Maintainer: Syed Khasim - Texas Instruments Inc */ 255 /* Maintainer: Syed Khasim - Texas Instruments Inc */
256 .phys_io = 0x48000000,
257 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
258 .boot_params = 0x80000100, 256 .boot_params = 0x80000100,
259 .map_io = omap_2430sdp_map_io, 257 .map_io = omap_2430sdp_map_io,
260 .reserve = omap_reserve, 258 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 67b95b5f1a2f..a5b095cf2adc 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -817,8 +817,6 @@ static void __init omap_3430sdp_init(void)
817 817
818MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board") 818MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
819 /* Maintainer: Syed Khasim - Texas Instruments Inc */ 819 /* Maintainer: Syed Khasim - Texas Instruments Inc */
820 .phys_io = 0x48000000,
821 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
822 .boot_params = 0x80000100, 820 .boot_params = 0x80000100,
823 .map_io = omap3_map_io, 821 .map_io = omap3_map_io,
824 .reserve = omap_reserve, 822 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-3630sdp.c b/arch/arm/mach-omap2/board-3630sdp.c
index b359c3f7bb39..fd27ac0860b0 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -217,8 +217,6 @@ static void __init omap_sdp_init(void)
217} 217}
218 218
219MACHINE_START(OMAP_3630SDP, "OMAP 3630SDP board") 219MACHINE_START(OMAP_3630SDP, "OMAP 3630SDP board")
220 .phys_io = 0x48000000,
221 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
222 .boot_params = 0x80000100, 220 .boot_params = 0x80000100,
223 .map_io = omap3_map_io, 221 .map_io = omap3_map_io,
224 .reserve = omap_reserve, 222 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 9447644774c2..0b6a65f3a10a 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -458,8 +458,6 @@ static void __init omap_4430sdp_map_io(void)
458 458
459MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board") 459MACHINE_START(OMAP_4430SDP, "OMAP4430 4430SDP board")
460 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */ 460 /* Maintainer: Santosh Shilimkar - Texas Instruments Inc */
461 .phys_io = 0x48000000,
462 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
463 .boot_params = 0x80000100, 461 .boot_params = 0x80000100,
464 .map_io = omap_4430sdp_map_io, 462 .map_io = omap_4430sdp_map_io,
465 .reserve = omap_reserve, 463 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index 4d0f58592864..d547036aff3f 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -375,6 +375,31 @@ static void __init am3517_evm_init_irq(void)
375 omap_gpio_init(); 375 omap_gpio_init();
376} 376}
377 377
378static struct omap_musb_board_data musb_board_data = {
379 .interface_type = MUSB_INTERFACE_ULPI,
380 .mode = MUSB_OTG,
381 .power = 500,
382};
383
384static __init void am3517_evm_musb_init(void)
385{
386 u32 devconf2;
387
388 /*
389 * Set up USB clock/mode in the DEVCONF2 register.
390 */
391 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
392
393 /* USB2.0 PHY reference clock is 13 MHz */
394 devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
395 devconf2 |= CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
396 | CONF2_DATPOL;
397
398 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
399
400 usb_musb_init(&musb_board_data);
401}
402
378static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { 403static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
379 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, 404 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
380#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \ 405#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
@@ -393,6 +418,8 @@ static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
393 418
394#ifdef CONFIG_OMAP_MUX 419#ifdef CONFIG_OMAP_MUX
395static struct omap_board_mux board_mux[] __initdata = { 420static struct omap_board_mux board_mux[] __initdata = {
421 /* USB OTG DRVVBUS offset = 0x212 */
422 OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
396 { .reg_offset = OMAP_MUX_TERMINATOR }, 423 { .reg_offset = OMAP_MUX_TERMINATOR },
397}; 424};
398#else 425#else
@@ -459,11 +486,12 @@ static void __init am3517_evm_init(void)
459 ARRAY_SIZE(am3517evm_i2c1_boardinfo)); 486 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
460 /*Ethernet*/ 487 /*Ethernet*/
461 am3517_evm_ethernet_init(&am3517_evm_emac_pdata); 488 am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
489
490 /* MUSB */
491 am3517_evm_musb_init();
462} 492}
463 493
464MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") 494MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
465 .phys_io = 0x48000000,
466 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
467 .boot_params = 0x80000100, 495 .boot_params = 0x80000100,
468 .map_io = omap3_map_io, 496 .map_io = omap3_map_io,
469 .reserve = omap_reserve, 497 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index c6421a72514a..68f07f5f441a 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -356,8 +356,6 @@ static void __init omap_apollon_map_io(void)
356 356
357MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") 357MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
358 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ 358 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
359 .phys_io = 0x48000000,
360 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
361 .boot_params = 0x80000100, 359 .boot_params = 0x80000100,
362 .map_io = omap_apollon_map_io, 360 .map_io = omap_apollon_map_io,
363 .reserve = omap_reserve, 361 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index e10bc109415c..934d9380c372 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -809,8 +809,6 @@ static void __init cm_t35_init(void)
809} 809}
810 810
811MACHINE_START(CM_T35, "Compulab CM-T35") 811MACHINE_START(CM_T35, "Compulab CM-T35")
812 .phys_io = 0x48000000,
813 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
814 .boot_params = 0x80000100, 812 .boot_params = 0x80000100,
815 .map_io = omap3_map_io, 813 .map_io = omap3_map_io,
816 .reserve = omap_reserve, 814 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index a07086d6a0b2..2205c20a4cdb 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -800,8 +800,6 @@ static void __init devkit8000_init(void)
800} 800}
801 801
802MACHINE_START(DEVKIT8000, "OMAP3 Devkit8000") 802MACHINE_START(DEVKIT8000, "OMAP3 Devkit8000")
803 .phys_io = 0x48000000,
804 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
805 .boot_params = 0x80000100, 803 .boot_params = 0x80000100,
806 .map_io = omap3_map_io, 804 .map_io = omap3_map_io,
807 .reserve = omap_reserve, 805 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 3482b99e8c86..69064b1c6a75 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -54,8 +54,6 @@ static void __init omap_generic_map_io(void)
54 54
55MACHINE_START(OMAP_GENERIC, "Generic OMAP24xx") 55MACHINE_START(OMAP_GENERIC, "Generic OMAP24xx")
56 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ 56 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
57 .phys_io = 0x48000000,
58 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
59 .boot_params = 0x80000100, 57 .boot_params = 0x80000100,
60 .map_io = omap_generic_map_io, 58 .map_io = omap_generic_map_io,
61 .reserve = omap_reserve, 59 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index e09bd686389f..cc39fc866524 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -376,8 +376,6 @@ static void __init omap_h4_map_io(void)
376 376
377MACHINE_START(OMAP_H4, "OMAP2420 H4 board") 377MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
378 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ 378 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
379 .phys_io = 0x48000000,
380 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
381 .boot_params = 0x80000100, 379 .boot_params = 0x80000100,
382 .map_io = omap_h4_map_io, 380 .map_io = omap_h4_map_io,
383 .reserve = omap_reserve, 381 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 175f04339761..b62a68ba069b 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -533,8 +533,6 @@ static void __init igep2_init(void)
533} 533}
534 534
535MACHINE_START(IGEP0020, "IGEP v2 board") 535MACHINE_START(IGEP0020, "IGEP v2 board")
536 .phys_io = 0x48000000,
537 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
538 .boot_params = 0x80000100, 536 .boot_params = 0x80000100,
539 .map_io = omap3_map_io, 537 .map_io = omap3_map_io,
540 .reserve = omap_reserve, 538 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 00d9b13b01c5..f28fd77bceb3 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -442,8 +442,6 @@ static void __init omap_ldp_init(void)
442} 442}
443 443
444MACHINE_START(OMAP_LDP, "OMAP LDP board") 444MACHINE_START(OMAP_LDP, "OMAP LDP board")
445 .phys_io = 0x48000000,
446 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
447 .boot_params = 0x80000100, 445 .boot_params = 0x80000100,
448 .map_io = omap3_map_io, 446 .map_io = omap3_map_io,
449 .reserve = omap_reserve, 447 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index a3e2b49aa39f..3f7966873507 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -674,8 +674,6 @@ static void __init n8x0_init_machine(void)
674} 674}
675 675
676MACHINE_START(NOKIA_N800, "Nokia N800") 676MACHINE_START(NOKIA_N800, "Nokia N800")
677 .phys_io = 0x48000000,
678 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
679 .boot_params = 0x80000100, 677 .boot_params = 0x80000100,
680 .map_io = n8x0_map_io, 678 .map_io = n8x0_map_io,
681 .reserve = omap_reserve, 679 .reserve = omap_reserve,
@@ -685,8 +683,6 @@ MACHINE_START(NOKIA_N800, "Nokia N800")
685MACHINE_END 683MACHINE_END
686 684
687MACHINE_START(NOKIA_N810, "Nokia N810") 685MACHINE_START(NOKIA_N810, "Nokia N810")
688 .phys_io = 0x48000000,
689 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
690 .boot_params = 0x80000100, 686 .boot_params = 0x80000100,
691 .map_io = n8x0_map_io, 687 .map_io = n8x0_map_io,
692 .reserve = omap_reserve, 688 .reserve = omap_reserve,
@@ -696,8 +692,6 @@ MACHINE_START(NOKIA_N810, "Nokia N810")
696MACHINE_END 692MACHINE_END
697 693
698MACHINE_START(NOKIA_N810_WIMAX, "Nokia N810 WiMAX") 694MACHINE_START(NOKIA_N810_WIMAX, "Nokia N810 WiMAX")
699 .phys_io = 0x48000000,
700 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
701 .boot_params = 0x80000100, 695 .boot_params = 0x80000100,
702 .map_io = n8x0_map_io, 696 .map_io = n8x0_map_io,
703 .reserve = omap_reserve, 697 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 87969c7df652..9d9f5b881ee8 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -487,8 +487,6 @@ static void __init omap3_beagle_init(void)
487 487
488MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board") 488MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
489 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */ 489 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
490 .phys_io = 0x48000000,
491 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
492 .boot_params = 0x80000100, 490 .boot_params = 0x80000100,
493 .map_io = omap3_map_io, 491 .map_io = omap3_map_io,
494 .reserve = omap_reserve, 492 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index f76d9c0a47a1..8936e4fba334 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -714,8 +714,6 @@ static void __init omap3_evm_init(void)
714 714
715MACHINE_START(OMAP3EVM, "OMAP3 EVM") 715MACHINE_START(OMAP3EVM, "OMAP3 EVM")
716 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */ 716 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
717 .phys_io = 0x48000000,
718 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
719 .boot_params = 0x80000100, 717 .boot_params = 0x80000100,
720 .map_io = omap3_map_io, 718 .map_io = omap3_map_io,
721 .reserve = omap_reserve, 719 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index dd3af2be13be..41d6f549070c 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -25,7 +25,7 @@
25#include <linux/spi/ads7846.h> 25#include <linux/spi/ads7846.h>
26#include <linux/regulator/machine.h> 26#include <linux/regulator/machine.h>
27#include <linux/i2c/twl.h> 27#include <linux/i2c/twl.h>
28#include <linux/spi/wl12xx.h> 28#include <linux/wl12xx.h>
29#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
30#include <linux/mtd/nand.h> 30#include <linux/mtd/nand.h>
31#include <linux/leds.h> 31#include <linux/leds.h>
@@ -717,8 +717,6 @@ static void __init omap3pandora_init(void)
717} 717}
718 718
719MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console") 719MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
720 .phys_io = 0x48000000,
721 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
722 .boot_params = 0x80000100, 720 .boot_params = 0x80000100,
723 .map_io = omap3_map_io, 721 .map_io = omap3_map_io,
724 .reserve = omap_reserve, 722 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index bcd01d278c65..bc5ac83bd4cf 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -654,8 +654,6 @@ static void __init omap3_stalker_init(void)
654 654
655MACHINE_START(SBC3530, "OMAP3 STALKER") 655MACHINE_START(SBC3530, "OMAP3 STALKER")
656 /* Maintainer: Jason Lam -lzg@ema-tech.com */ 656 /* Maintainer: Jason Lam -lzg@ema-tech.com */
657 .phys_io = 0x48000000,
658 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
659 .boot_params = 0x80000100, 657 .boot_params = 0x80000100,
660 .map_io = omap3_map_io, 658 .map_io = omap3_map_io,
661 .init_irq = omap3_stalker_init_irq, 659 .init_irq = omap3_stalker_init_irq,
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 663c62d271e8..0e99ce584dbf 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -538,8 +538,6 @@ static void __init omap3_touchbook_init(void)
538 538
539MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board") 539MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board")
540 /* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */ 540 /* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */
541 .phys_io = 0x48000000,
542 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
543 .boot_params = 0x80000100, 541 .boot_params = 0x80000100,
544 .map_io = omap3_map_io, 542 .map_io = omap3_map_io,
545 .reserve = omap_reserve, 543 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index c03d1d56db56..db69bcadf4c7 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -294,8 +294,6 @@ static void __init omap4_panda_map_io(void)
294 294
295MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board") 295MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board")
296 /* Maintainer: David Anders - Texas Instruments Inc */ 296 /* Maintainer: David Anders - Texas Instruments Inc */
297 .phys_io = 0x48000000,
298 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
299 .boot_params = 0x80000100, 297 .boot_params = 0x80000100,
300 .map_io = omap4_panda_map_io, 298 .map_io = omap4_panda_map_io,
301 .init_irq = omap4_panda_init_irq, 299 .init_irq = omap4_panda_init_irq,
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 4c4843618350..5e528ca015a1 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -501,8 +501,6 @@ static void __init overo_init(void)
501} 501}
502 502
503MACHINE_START(OVERO, "Gumstix Overo") 503MACHINE_START(OVERO, "Gumstix Overo")
504 .phys_io = 0x48000000,
505 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
506 .boot_params = 0x80000100, 504 .boot_params = 0x80000100,
507 .map_io = omap3_map_io, 505 .map_io = omap3_map_io,
508 .reserve = omap_reserve, 506 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 9a5eb87425fc..ce28a851dcd3 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -14,7 +14,7 @@
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/input/matrix_keypad.h> 15#include <linux/input/matrix_keypad.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/spi/wl12xx.h> 17#include <linux/wl12xx.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/i2c/twl.h> 19#include <linux/i2c/twl.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index a58e8cb1a7fc..36f2cf4efd57 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -150,8 +150,6 @@ static void __init rx51_map_io(void)
150 150
151MACHINE_START(NOKIA_RX51, "Nokia RX-51 board") 151MACHINE_START(NOKIA_RX51, "Nokia RX-51 board")
152 /* Maintainer: Lauri Leukkunen <lauri.leukkunen@nokia.com> */ 152 /* Maintainer: Lauri Leukkunen <lauri.leukkunen@nokia.com> */
153 .phys_io = 0x48000000,
154 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
155 .boot_params = 0x80000100, 153 .boot_params = 0x80000100,
156 .map_io = rx51_map_io, 154 .map_io = rx51_map_io,
157 .reserve = omap_reserve, 155 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 6b3984964cc5..189a6d1600b2 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -16,6 +16,8 @@
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/i2c/twl.h> 17#include <linux/i2c/twl.h>
18#include <linux/regulator/machine.h> 18#include <linux/regulator/machine.h>
19#include <linux/regulator/fixed.h>
20#include <linux/wl12xx.h>
19 21
20#include <asm/mach-types.h> 22#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
@@ -27,6 +29,9 @@
27#include "mux.h" 29#include "mux.h"
28#include "hsmmc.h" 30#include "hsmmc.h"
29 31
32#define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
33#define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
34
30/* Zoom2 has Qwerty keyboard*/ 35/* Zoom2 has Qwerty keyboard*/
31static int board_keymap[] = { 36static int board_keymap[] = {
32 KEY(0, 0, KEY_E), 37 KEY(0, 0, KEY_E),
@@ -106,6 +111,11 @@ static struct regulator_consumer_supply zoom_vmmc2_supply = {
106 .supply = "vmmc", 111 .supply = "vmmc",
107}; 112};
108 113
114static struct regulator_consumer_supply zoom_vmmc3_supply = {
115 .supply = "vmmc",
116 .dev_name = "mmci-omap-hs.2",
117};
118
109/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */ 119/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
110static struct regulator_init_data zoom_vmmc1 = { 120static struct regulator_init_data zoom_vmmc1 = {
111 .constraints = { 121 .constraints = {
@@ -151,6 +161,38 @@ static struct regulator_init_data zoom_vsim = {
151 .consumer_supplies = &zoom_vsim_supply, 161 .consumer_supplies = &zoom_vsim_supply,
152}; 162};
153 163
164static struct regulator_init_data zoom_vmmc3 = {
165 .constraints = {
166 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
167 },
168 .num_consumer_supplies = 1,
169 .consumer_supplies = &zoom_vmmc3_supply,
170};
171
172static struct fixed_voltage_config zoom_vwlan = {
173 .supply_name = "vwl1271",
174 .microvolts = 1800000, /* 1.8V */
175 .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
176 .startup_delay = 70000, /* 70msec */
177 .enable_high = 1,
178 .enabled_at_boot = 0,
179 .init_data = &zoom_vmmc3,
180};
181
182static struct platform_device omap_vwlan_device = {
183 .name = "reg-fixed-voltage",
184 .id = 1,
185 .dev = {
186 .platform_data = &zoom_vwlan,
187 },
188};
189
190struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
191 .irq = OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO),
192 /* ZOOM ref clock is 26 MHz */
193 .board_ref_clock = 1,
194};
195
154static struct omap2_hsmmc_info mmc[] __initdata = { 196static struct omap2_hsmmc_info mmc[] __initdata = {
155 { 197 {
156 .name = "external", 198 .name = "external",
@@ -168,6 +210,14 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
168 .nonremovable = true, 210 .nonremovable = true,
169 .power_saving = true, 211 .power_saving = true,
170 }, 212 },
213 {
214 .name = "wl1271",
215 .mmc = 3,
216 .caps = MMC_CAP_4_BIT_DATA,
217 .gpio_wp = -EINVAL,
218 .gpio_cd = -EINVAL,
219 .nonremovable = true,
220 },
171 {} /* Terminator */ 221 {} /* Terminator */
172}; 222};
173 223
@@ -279,7 +329,11 @@ static void enable_board_wakeup_source(void)
279 329
280void __init zoom_peripherals_init(void) 330void __init zoom_peripherals_init(void)
281{ 331{
332 if (wl12xx_set_platform_data(&omap_zoom_wlan_data))
333 pr_err("error setting wl12xx data\n");
334
282 omap_i2c_init(); 335 omap_i2c_init();
336 platform_device_register(&omap_vwlan_device);
283 usb_musb_init(&musb_board_data); 337 usb_musb_init(&musb_board_data);
284 enable_board_wakeup_source(); 338 enable_board_wakeup_source();
285} 339}
diff --git a/arch/arm/mach-omap2/board-zoom2.c b/arch/arm/mach-omap2/board-zoom2.c
index 3ad9ecf7f5e2..24bbd0def64f 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -141,8 +141,6 @@ static void __init omap_zoom2_init(void)
141} 141}
142 142
143MACHINE_START(OMAP_ZOOM2, "OMAP Zoom2 board") 143MACHINE_START(OMAP_ZOOM2, "OMAP Zoom2 board")
144 .phys_io = ZOOM_UART_BASE,
145 .io_pg_offst = (ZOOM_UART_VIRT >> 18) & 0xfffc,
146 .boot_params = 0x80000100, 144 .boot_params = 0x80000100,
147 .map_io = omap3_map_io, 145 .map_io = omap3_map_io,
148 .reserve = omap_reserve, 146 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/board-zoom3.c b/arch/arm/mach-omap2/board-zoom3.c
index 6ca0b8341615..b2bb3ff971ac 100644
--- a/arch/arm/mach-omap2/board-zoom3.c
+++ b/arch/arm/mach-omap2/board-zoom3.c
@@ -123,8 +123,6 @@ static void __init omap_zoom_init(void)
123} 123}
124 124
125MACHINE_START(OMAP_ZOOM3, "OMAP Zoom3 board") 125MACHINE_START(OMAP_ZOOM3, "OMAP Zoom3 board")
126 .phys_io = ZOOM_UART_BASE,
127 .io_pg_offst = (ZOOM_UART_VIRT >> 18) & 0xfffc,
128 .boot_params = 0x80000100, 126 .boot_params = 0x80000100,
129 .map_io = omap3_map_io, 127 .map_io = omap3_map_io,
130 .reserve = omap_reserve, 128 .reserve = omap_reserve,
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index 37d65d62ed8f..5f2066a6ba74 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -1838,7 +1838,7 @@ static struct omap_clk omap2420_clks[] = {
1838 CLK(NULL, "des_ick", &des_ick, CK_242X), 1838 CLK(NULL, "des_ick", &des_ick, CK_242X),
1839 CLK("omap-sham", "ick", &sha_ick, CK_242X), 1839 CLK("omap-sham", "ick", &sha_ick, CK_242X),
1840 CLK("omap_rng", "ick", &rng_ick, CK_242X), 1840 CLK("omap_rng", "ick", &rng_ick, CK_242X),
1841 CLK(NULL, "aes_ick", &aes_ick, CK_242X), 1841 CLK("omap-aes", "ick", &aes_ick, CK_242X),
1842 CLK(NULL, "pka_ick", &pka_ick, CK_242X), 1842 CLK(NULL, "pka_ick", &pka_ick, CK_242X),
1843 CLK(NULL, "usb_fck", &usb_fck, CK_242X), 1843 CLK(NULL, "usb_fck", &usb_fck, CK_242X),
1844 CLK("musb_hdrc", "fck", &osc_ck, CK_242X), 1844 CLK("musb_hdrc", "fck", &osc_ck, CK_242X),
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index b33118fb6a87..701a1716019e 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -1926,7 +1926,7 @@ static struct omap_clk omap2430_clks[] = {
1926 CLK(NULL, "des_ick", &des_ick, CK_243X), 1926 CLK(NULL, "des_ick", &des_ick, CK_243X),
1927 CLK("omap-sham", "ick", &sha_ick, CK_243X), 1927 CLK("omap-sham", "ick", &sha_ick, CK_243X),
1928 CLK("omap_rng", "ick", &rng_ick, CK_243X), 1928 CLK("omap_rng", "ick", &rng_ick, CK_243X),
1929 CLK(NULL, "aes_ick", &aes_ick, CK_243X), 1929 CLK("omap-aes", "ick", &aes_ick, CK_243X),
1930 CLK(NULL, "pka_ick", &pka_ick, CK_243X), 1930 CLK(NULL, "pka_ick", &pka_ick, CK_243X),
1931 CLK(NULL, "usb_fck", &usb_fck, CK_243X), 1931 CLK(NULL, "usb_fck", &usb_fck, CK_243X),
1932 CLK("musb_hdrc", "ick", &usbhs_ick, CK_243X), 1932 CLK("musb_hdrc", "ick", &usbhs_ick, CK_243X),
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index dfdce2d82779..c73906d17458 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -3288,7 +3288,7 @@ static struct omap_clk omap3xxx_clks[] = {
3288 CLK(NULL, "usbtll_ick", &usbtll_ick, CK_3430ES2 | CK_AM35XX), 3288 CLK(NULL, "usbtll_ick", &usbtll_ick, CK_3430ES2 | CK_AM35XX),
3289 CLK("mmci-omap-hs.2", "ick", &mmchs3_ick, CK_3430ES2 | CK_AM35XX), 3289 CLK("mmci-omap-hs.2", "ick", &mmchs3_ick, CK_3430ES2 | CK_AM35XX),
3290 CLK(NULL, "icr_ick", &icr_ick, CK_343X), 3290 CLK(NULL, "icr_ick", &icr_ick, CK_343X),
3291 CLK(NULL, "aes2_ick", &aes2_ick, CK_343X), 3291 CLK("omap-aes", "ick", &aes2_ick, CK_343X),
3292 CLK("omap-sham", "ick", &sha12_ick, CK_343X), 3292 CLK("omap-sham", "ick", &sha12_ick, CK_343X),
3293 CLK(NULL, "des2_ick", &des2_ick, CK_343X), 3293 CLK(NULL, "des2_ick", &des2_ick, CK_343X),
3294 CLK("mmci-omap-hs.1", "ick", &mmchs2_ick, CK_3XXX), 3294 CLK("mmci-omap-hs.1", "ick", &mmchs2_ick, CK_3XXX),
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 2dbb265bedd4..b27e7cbb3f29 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -498,6 +498,76 @@ static void omap_init_sham(void)
498static inline void omap_init_sham(void) { } 498static inline void omap_init_sham(void) { }
499#endif 499#endif
500 500
501#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
502
503#ifdef CONFIG_ARCH_OMAP24XX
504static struct resource omap2_aes_resources[] = {
505 {
506 .start = OMAP24XX_SEC_AES_BASE,
507 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
508 .flags = IORESOURCE_MEM,
509 },
510 {
511 .start = OMAP24XX_DMA_AES_TX,
512 .flags = IORESOURCE_DMA,
513 },
514 {
515 .start = OMAP24XX_DMA_AES_RX,
516 .flags = IORESOURCE_DMA,
517 }
518};
519static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
520#else
521#define omap2_aes_resources NULL
522#define omap2_aes_resources_sz 0
523#endif
524
525#ifdef CONFIG_ARCH_OMAP34XX
526static struct resource omap3_aes_resources[] = {
527 {
528 .start = OMAP34XX_SEC_AES_BASE,
529 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
530 .flags = IORESOURCE_MEM,
531 },
532 {
533 .start = OMAP34XX_DMA_AES2_TX,
534 .flags = IORESOURCE_DMA,
535 },
536 {
537 .start = OMAP34XX_DMA_AES2_RX,
538 .flags = IORESOURCE_DMA,
539 }
540};
541static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
542#else
543#define omap3_aes_resources NULL
544#define omap3_aes_resources_sz 0
545#endif
546
547static struct platform_device aes_device = {
548 .name = "omap-aes",
549 .id = -1,
550};
551
552static void omap_init_aes(void)
553{
554 if (cpu_is_omap24xx()) {
555 aes_device.resource = omap2_aes_resources;
556 aes_device.num_resources = omap2_aes_resources_sz;
557 } else if (cpu_is_omap34xx()) {
558 aes_device.resource = omap3_aes_resources;
559 aes_device.num_resources = omap3_aes_resources_sz;
560 } else {
561 pr_err("%s: platform not supported\n", __func__);
562 return;
563 }
564 platform_device_register(&aes_device);
565}
566
567#else
568static inline void omap_init_aes(void) { }
569#endif
570
501/*-------------------------------------------------------------------------*/ 571/*-------------------------------------------------------------------------*/
502 572
503#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) 573#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
@@ -854,6 +924,7 @@ static int __init omap2_init_devices(void)
854 omap_hdq_init(); 924 omap_hdq_init();
855 omap_init_sti(); 925 omap_init_sti();
856 omap_init_sham(); 926 omap_init_sham();
927 omap_init_aes();
857 omap_init_vout(); 928 omap_init_vout();
858 929
859 return 0; 930 return 0;
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index 1fe6f0187177..0f8a2e6ee284 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -23,7 +23,7 @@ struct omap2_hsmmc_info {
23 char *name; /* or NULL for default */ 23 char *name; /* or NULL for default */
24 struct device *dev; /* returned: pointer to mmc adapter */ 24 struct device *dev; /* returned: pointer to mmc adapter */
25 int ocr_mask; /* temporary HACK */ 25 int ocr_mask; /* temporary HACK */
26 /* Remux (pad configuation) when powering on/off */ 26 /* Remux (pad configuration) when powering on/off */
27 void (*remux)(struct device *dev, int slot, int power_on); 27 void (*remux)(struct device *dev, int slot, int power_on);
28 /* init some special card */ 28 /* init some special card */
29 void (*init_card)(struct mmc_card *card); 29 void (*init_card)(struct mmc_card *card);
diff --git a/arch/arm/mach-omap2/include/mach/debug-macro.S b/arch/arm/mach-omap2/include/mach/debug-macro.S
index 09331bbbda52..6a4d4136002e 100644
--- a/arch/arm/mach-omap2/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap2/include/mach/debug-macro.S
@@ -31,95 +31,94 @@ omap_uart_lsr: .word 0
31 * the desired UART phys and virt addresses temporarily into 31 * the desired UART phys and virt addresses temporarily into
32 * the omap_uart_phys and omap_uart_virt above. 32 * the omap_uart_phys and omap_uart_virt above.
33 */ 33 */
34 .macro addruart, rx, tmp 34 .macro addruart, rp, rv
35 35
36 /* Use omap_uart_phys/virt if already configured */ 36 /* Use omap_uart_phys/virt if already configured */
3710: mrc p15, 0, \rx, c1, c0 3710: mrc p15, 0, \rp, c1, c0
38 tst \rx, #1 @ MMU enabled? 38 tst \rp, #1 @ MMU enabled?
39 ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address 39 ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
40 ldrne \rx, =omap_uart_virt @ virtual base address 40 ldrne \rp, =omap_uart_phys @ MMU enabled
41 ldr \rx, [\rx, #0] 41 add \rv, \rp, #4 @ omap_uart_virt
42 cmp \rx, #0 @ is port configured? 42 ldr \rp, [\rp, #0]
43 ldr \rv, [\rv, #0]
44 cmp \rp, #0 @ is port configured?
45 cmpne \rv, #0
43 bne 99f @ already configured 46 bne 99f @ already configured
44 47
45 /* Check the debug UART configuration set in uncompress.h */ 48 /* Check the debug UART configuration set in uncompress.h */
46 mrc p15, 0, \rx, c1, c0 49 mrc p15, 0, \rp, c1, c0
47 tst \rx, #1 @ MMU enabled? 50 tst \rp, #1 @ MMU enabled?
48 ldreq \rx, =OMAP_UART_INFO 51 ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
49 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO) 52 ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled
50 ldr \rx, [\rx, #0] 53 ldr \rp, [\rp, #0]
51 54
52 /* Select the UART to use based on the UART1 scratchpad value */ 55 /* Select the UART to use based on the UART1 scratchpad value */
53 cmp \rx, #0 @ no port configured? 56 cmp \rp, #0 @ no port configured?
54 beq 21f @ if none, try to use UART1 57 beq 21f @ if none, try to use UART1
55 cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1 58 cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
56 beq 21f @ configure OMAP2/3/4UART1 59 beq 21f @ configure OMAP2/3/4UART1
57 cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2 60 cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
58 beq 22f @ configure OMAP2/3/4UART2 61 beq 22f @ configure OMAP2/3/4UART2
59 cmp \rx, #OMAP2UART3 @ only on 24xx 62 cmp \rp, #OMAP2UART3 @ only on 24xx
60 beq 23f @ configure OMAP2UART3 63 beq 23f @ configure OMAP2UART3
61 cmp \rx, #OMAP3UART3 @ only on 34xx 64 cmp \rp, #OMAP3UART3 @ only on 34xx
62 beq 33f @ configure OMAP3UART3 65 beq 33f @ configure OMAP3UART3
63 cmp \rx, #OMAP4UART3 @ only on 44xx 66 cmp \rp, #OMAP4UART3 @ only on 44xx
64 beq 43f @ configure OMAP4UART3 67 beq 43f @ configure OMAP4UART3
65 cmp \rx, #OMAP3UART4 @ only on 36xx 68 cmp \rp, #OMAP3UART4 @ only on 36xx
66 beq 34f @ configure OMAP3UART4 69 beq 34f @ configure OMAP3UART4
67 cmp \rx, #OMAP4UART4 @ only on 44xx 70 cmp \rp, #OMAP4UART4 @ only on 44xx
68 beq 44f @ configure OMAP4UART4 71 beq 44f @ configure OMAP4UART4
69 cmp \rx, #ZOOM_UART @ only on zoom2/3 72 cmp \rp, #ZOOM_UART @ only on zoom2/3
70 beq 95f @ configure ZOOM_UART 73 beq 95f @ configure ZOOM_UART
71 74
72 /* Configure the UART offset from the phys/virt base */ 75 /* Configure the UART offset from the phys/virt base */
7321: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4 7621: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
74 b 98f 77 b 98f
7522: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4 7822: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
76 b 98f 79 b 98f
7723: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE) 8023: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
78 b 98f 81 b 98f
7933: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE) 8233: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
80 add \rx, \rx, #0x00fb0000 83 add \rp, \rp, #0x00fb0000
81 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE 84 add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
82 b 98f 85 b 98f
8334: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE) 8634: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
84 add \rx, \rx, #0x00fb0000 87 add \rp, \rp, #0x00fb0000
85 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE 88 add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
86 b 98f 89 b 98f
8743: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE) 9043: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
88 b 98f 91 b 98f
8944: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE) 9244: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
90 b 98f 93 b 98f
9195: ldr \rx, =ZOOM_UART_BASE 9495: ldr \rp, =ZOOM_UART_BASE
92 mrc p15, 0, \tmp, c1, c0 95 mrc p15, 0, \rv, c1, c0
93 tst \tmp, #1 @ MMU enabled? 96 tst \rv, #1 @ MMU enabled?
94 ldreq \tmp, =__virt_to_phys(omap_uart_phys) 97 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
95 ldrne \tmp, =omap_uart_phys 98 ldrne \rv, =omap_uart_phys @ MMU enabled
96 str \rx, [\tmp, #0] 99 str \rp, [\rv, #0]
97 ldr \rx, =ZOOM_UART_VIRT 100 ldr \rp, =ZOOM_UART_VIRT
98 ldreq \tmp, =__virt_to_phys(omap_uart_virt) 101 add \rv, \rv, #4 @ omap_uart_virt
99 ldrne \tmp, =omap_uart_virt 102 str \rp, [\rv, #0]
100 str \rx, [\tmp, #0] 103 mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
101 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT) 104 add \rv, \rv, #4 @ omap_uart_lsr
102 ldreq \tmp, =__virt_to_phys(omap_uart_lsr) 105 str \rp, [\rv, #0]
103 ldrne \tmp, =omap_uart_lsr
104 str \rx, [\tmp, #0]
105 b 10b 106 b 10b
106 107
107 /* Store both phys and virt address for the uart */ 108 /* Store both phys and virt address for the uart */
10898: add \rx, \rx, #0x48000000 @ phys base 10998: add \rp, \rp, #0x48000000 @ phys base
109 mrc p15, 0, \tmp, c1, c0 110 mrc p15, 0, \rv, c1, c0
110 tst \tmp, #1 @ MMU enabled? 111 tst \rv, #1 @ MMU enabled?
111 ldreq \tmp, =__virt_to_phys(omap_uart_phys) 112 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
112 ldrne \tmp, =omap_uart_phys 113 ldrne \rv, =omap_uart_phys @ MMU enabled
113 str \rx, [\tmp, #0] 114 str \rp, [\rv, #0]
114 sub \rx, \rx, #0x48000000 @ phys base 115 sub \rp, \rp, #0x48000000 @ phys base
115 add \rx, \rx, #0xfa000000 @ virt base 116 add \rp, \rp, #0xfa000000 @ virt base
116 ldreq \tmp, =__virt_to_phys(omap_uart_virt) 117 add \rv, \rv, #4 @ omap_uart_virt
117 ldrne \tmp, =omap_uart_virt 118 str \rp, [\rv, #0]
118 str \rx, [\tmp, #0] 119 mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
119 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT) 120 add \rv, \rv, #4 @ omap_uart_lsr
120 ldreq \tmp, =__virt_to_phys(omap_uart_lsr) 121 str \rp, [\rv, #0]
121 ldrne \tmp, =omap_uart_lsr
122 str \rx, [\tmp, #0]
123 122
124 b 10b 123 b 10b
12599: 12499:
@@ -131,9 +130,9 @@ omap_uart_lsr: .word 0
131 130
132 .macro busyuart,rd,rx 131 .macro busyuart,rd,rx
1331001: mrc p15, 0, \rd, c1, c0 1321001: mrc p15, 0, \rd, c1, c0
134 tst \rd, #1 @ MMU enabled? 133 tst \rd, #1 @ MMU enabled?
135 ldreq \rd, =__virt_to_phys(omap_uart_lsr) 134 ldreq \rd, =__virt_to_phys(omap_uart_lsr) @ MMU not enabled
136 ldrne \rd, =omap_uart_lsr 135 ldrne \rd, =omap_uart_lsr @ MMU enabled
137 ldr \rd, [\rd, #0] 136 ldr \rd, [\rd, #0]
138 ldrb \rd, [\rx, \rd] 137 ldrb \rd, [\rx, \rd]
139 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE) 138 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
diff --git a/arch/arm/mach-omap2/include/mach/vmalloc.h b/arch/arm/mach-omap2/include/mach/vmalloc.h
index 9ce9b6e8ad23..4da31e997efe 100644
--- a/arch/arm/mach-omap2/include/mach/vmalloc.h
+++ b/arch/arm/mach-omap2/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#define VMALLOC_END (PAGE_OFFSET + 0x38000000) 20#define VMALLOC_END 0xf8000000
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 33a5cde1c227..72605584bfff 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -28,6 +28,7 @@
28 28
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/irqs.h> 30#include <mach/irqs.h>
31#include <mach/am35xx.h>
31#include <plat/usb.h> 32#include <plat/usb.h>
32 33
33#ifdef CONFIG_USB_MUSB_SOC 34#ifdef CONFIG_USB_MUSB_SOC
@@ -89,6 +90,9 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
89{ 90{
90 if (cpu_is_omap243x()) { 91 if (cpu_is_omap243x()) {
91 musb_resources[0].start = OMAP243X_HS_BASE; 92 musb_resources[0].start = OMAP243X_HS_BASE;
93 } else if (cpu_is_omap3517() || cpu_is_omap3505()) {
94 musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE;
95 musb_resources[1].start = INT_35XX_USBOTG_IRQ;
92 } else if (cpu_is_omap34xx()) { 96 } else if (cpu_is_omap34xx()) {
93 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE; 97 musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
94 } else if (cpu_is_omap44xx()) { 98 } else if (cpu_is_omap44xx()) {
diff --git a/arch/arm/mach-orion5x/d2net-setup.c b/arch/arm/mach-orion5x/d2net-setup.c
index 7130904ad999..b1c451f5ee27 100644
--- a/arch/arm/mach-orion5x/d2net-setup.c
+++ b/arch/arm/mach-orion5x/d2net-setup.c
@@ -336,8 +336,6 @@ static void __init d2net_init(void)
336 336
337#ifdef CONFIG_MACH_D2NET 337#ifdef CONFIG_MACH_D2NET
338MACHINE_START(D2NET, "LaCie d2 Network") 338MACHINE_START(D2NET, "LaCie d2 Network")
339 .phys_io = ORION5X_REGS_PHYS_BASE,
340 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
341 .boot_params = 0x00000100, 339 .boot_params = 0x00000100,
342 .init_machine = d2net_init, 340 .init_machine = d2net_init,
343 .map_io = orion5x_map_io, 341 .map_io = orion5x_map_io,
@@ -349,8 +347,6 @@ MACHINE_END
349 347
350#ifdef CONFIG_MACH_BIGDISK 348#ifdef CONFIG_MACH_BIGDISK
351MACHINE_START(BIGDISK, "LaCie Big Disk Network") 349MACHINE_START(BIGDISK, "LaCie Big Disk Network")
352 .phys_io = ORION5X_REGS_PHYS_BASE,
353 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
354 .boot_params = 0x00000100, 350 .boot_params = 0x00000100,
355 .init_machine = d2net_init, 351 .init_machine = d2net_init,
356 .map_io = orion5x_map_io, 352 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/db88f5281-setup.c b/arch/arm/mach-orion5x/db88f5281-setup.c
index d318bea2af91..df1083f5b6eb 100644
--- a/arch/arm/mach-orion5x/db88f5281-setup.c
+++ b/arch/arm/mach-orion5x/db88f5281-setup.c
@@ -358,8 +358,6 @@ static void __init db88f5281_init(void)
358 358
359MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board") 359MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board")
360 /* Maintainer: Tzachi Perelstein <tzachi@marvell.com> */ 360 /* Maintainer: Tzachi Perelstein <tzachi@marvell.com> */
361 .phys_io = ORION5X_REGS_PHYS_BASE,
362 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xfffc,
363 .boot_params = 0x00000100, 361 .boot_params = 0x00000100,
364 .init_machine = db88f5281_init, 362 .init_machine = db88f5281_init,
365 .map_io = orion5x_map_io, 363 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c
index a47100d46a4e..3a7bc0e36982 100644
--- a/arch/arm/mach-orion5x/dns323-setup.c
+++ b/arch/arm/mach-orion5x/dns323-setup.c
@@ -730,8 +730,6 @@ static void __init dns323_init(void)
730/* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */ 730/* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
731MACHINE_START(DNS323, "D-Link DNS-323") 731MACHINE_START(DNS323, "D-Link DNS-323")
732 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */ 732 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
733 .phys_io = ORION5X_REGS_PHYS_BASE,
734 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
735 .boot_params = 0x00000100, 733 .boot_params = 0x00000100,
736 .init_machine = dns323_init, 734 .init_machine = dns323_init,
737 .map_io = orion5x_map_io, 735 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/edmini_v2-setup.c b/arch/arm/mach-orion5x/edmini_v2-setup.c
index b24ee0c2cd61..ba98459f44b0 100644
--- a/arch/arm/mach-orion5x/edmini_v2-setup.c
+++ b/arch/arm/mach-orion5x/edmini_v2-setup.c
@@ -251,8 +251,6 @@ static void __init edmini_v2_init(void)
251/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */ 251/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
252MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2") 252MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2")
253 /* Maintainer: Christopher Moore <moore@free.fr> */ 253 /* Maintainer: Christopher Moore <moore@free.fr> */
254 .phys_io = ORION5X_REGS_PHYS_BASE,
255 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
256 .boot_params = 0x00000100, 254 .boot_params = 0x00000100,
257 .init_machine = edmini_v2_init, 255 .init_machine = edmini_v2_init,
258 .map_io = orion5x_map_io, 256 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/include/mach/debug-macro.S b/arch/arm/mach-orion5x/include/mach/debug-macro.S
index 91e0e39bb23f..5e3bf5b68aec 100644
--- a/arch/arm/mach-orion5x/include/mach/debug-macro.S
+++ b/arch/arm/mach-orion5x/include/mach/debug-macro.S
@@ -10,12 +10,11 @@
10 10
11#include <mach/orion5x.h> 11#include <mach/orion5x.h>
12 12
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 mrc p15, 0, \rx, c1, c0 14 ldr \rp, =ORION5X_REGS_PHYS_BASE
15 tst \rx, #1 @ MMU enabled? 15 ldr \rv, =ORION5X_REGS_VIRT_BASE
16 ldreq \rx, =ORION5X_REGS_PHYS_BASE 16 orr \rp, \rp, #0x00012000
17 ldrne \rx, =ORION5X_REGS_VIRT_BASE 17 orr \rv, \rv, #0x00012000
18 orr \rx, \rx, #0x00012000
19 .endm 18 .endm
20 19
21#define UART_SHIFT 2 20#define UART_SHIFT 2
diff --git a/arch/arm/mach-orion5x/kurobox_pro-setup.c b/arch/arm/mach-orion5x/kurobox_pro-setup.c
index dfbb68df7b09..4be9aa08de69 100644
--- a/arch/arm/mach-orion5x/kurobox_pro-setup.c
+++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c
@@ -379,8 +379,6 @@ static void __init kurobox_pro_init(void)
379#ifdef CONFIG_MACH_KUROBOX_PRO 379#ifdef CONFIG_MACH_KUROBOX_PRO
380MACHINE_START(KUROBOX_PRO, "Buffalo/Revogear Kurobox Pro") 380MACHINE_START(KUROBOX_PRO, "Buffalo/Revogear Kurobox Pro")
381 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */ 381 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
382 .phys_io = ORION5X_REGS_PHYS_BASE,
383 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
384 .boot_params = 0x00000100, 382 .boot_params = 0x00000100,
385 .init_machine = kurobox_pro_init, 383 .init_machine = kurobox_pro_init,
386 .map_io = orion5x_map_io, 384 .map_io = orion5x_map_io,
@@ -393,8 +391,6 @@ MACHINE_END
393#ifdef CONFIG_MACH_LINKSTATION_PRO 391#ifdef CONFIG_MACH_LINKSTATION_PRO
394MACHINE_START(LINKSTATION_PRO, "Buffalo Linkstation Pro/Live") 392MACHINE_START(LINKSTATION_PRO, "Buffalo Linkstation Pro/Live")
395 /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */ 393 /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */
396 .phys_io = ORION5X_REGS_PHYS_BASE,
397 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
398 .boot_params = 0x00000100, 394 .boot_params = 0x00000100,
399 .init_machine = kurobox_pro_init, 395 .init_machine = kurobox_pro_init,
400 .map_io = orion5x_map_io, 396 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/ls_hgl-setup.c b/arch/arm/mach-orion5x/ls_hgl-setup.c
index 8e569be6e2c7..437364b7168e 100644
--- a/arch/arm/mach-orion5x/ls_hgl-setup.c
+++ b/arch/arm/mach-orion5x/ls_hgl-setup.c
@@ -265,8 +265,6 @@ static void __init ls_hgl_init(void)
265 265
266MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL") 266MACHINE_START(LINKSTATION_LS_HGL, "Buffalo Linkstation LS-HGL")
267 /* Maintainer: Zhu Qingsen <zhuqs@cn.fujistu.com> */ 267 /* Maintainer: Zhu Qingsen <zhuqs@cn.fujistu.com> */
268 .phys_io = ORION5X_REGS_PHYS_BASE,
269 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
270 .boot_params = 0x00000100, 268 .boot_params = 0x00000100,
271 .init_machine = ls_hgl_init, 269 .init_machine = ls_hgl_init,
272 .map_io = orion5x_map_io, 270 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/lsmini-setup.c b/arch/arm/mach-orion5x/lsmini-setup.c
index c704f056de1e..ab9b0cf0a90b 100644
--- a/arch/arm/mach-orion5x/lsmini-setup.c
+++ b/arch/arm/mach-orion5x/lsmini-setup.c
@@ -267,8 +267,6 @@ static void __init lsmini_init(void)
267#ifdef CONFIG_MACH_LINKSTATION_MINI 267#ifdef CONFIG_MACH_LINKSTATION_MINI
268MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini") 268MACHINE_START(LINKSTATION_MINI, "Buffalo Linkstation Mini")
269 /* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */ 269 /* Maintainer: Alexey Kopytko <alexey@kopytko.ru> */
270 .phys_io = ORION5X_REGS_PHYS_BASE,
271 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
272 .boot_params = 0x00000100, 270 .boot_params = 0x00000100,
273 .init_machine = lsmini_init, 271 .init_machine = lsmini_init,
274 .map_io = orion5x_map_io, 272 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/mss2-setup.c b/arch/arm/mach-orion5x/mss2-setup.c
index 61c086b66723..2f0e16cd7e81 100644
--- a/arch/arm/mach-orion5x/mss2-setup.c
+++ b/arch/arm/mach-orion5x/mss2-setup.c
@@ -261,8 +261,6 @@ static void __init mss2_init(void)
261 261
262MACHINE_START(MSS2, "Maxtor Shared Storage II") 262MACHINE_START(MSS2, "Maxtor Shared Storage II")
263 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */ 263 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
264 .phys_io = ORION5X_REGS_PHYS_BASE,
265 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
266 .boot_params = 0x00000100, 264 .boot_params = 0x00000100,
267 .init_machine = mss2_init, 265 .init_machine = mss2_init,
268 .map_io = orion5x_map_io, 266 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/mv2120-setup.c b/arch/arm/mach-orion5x/mv2120-setup.c
index 97c9ccb2ac60..b3d90f25de9f 100644
--- a/arch/arm/mach-orion5x/mv2120-setup.c
+++ b/arch/arm/mach-orion5x/mv2120-setup.c
@@ -229,8 +229,6 @@ static void __init mv2120_init(void)
229/* Warning: HP uses a wrong mach-type (=526) in their bootloader */ 229/* Warning: HP uses a wrong mach-type (=526) in their bootloader */
230MACHINE_START(MV2120, "HP Media Vault mv2120") 230MACHINE_START(MV2120, "HP Media Vault mv2120")
231 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ 231 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
232 .phys_io = ORION5X_REGS_PHYS_BASE,
233 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
234 .boot_params = 0x00000100, 232 .boot_params = 0x00000100,
235 .init_machine = mv2120_init, 233 .init_machine = mv2120_init,
236 .map_io = orion5x_map_io, 234 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/net2big-setup.c b/arch/arm/mach-orion5x/net2big-setup.c
index 7bd6283476f9..d6665b31665f 100644
--- a/arch/arm/mach-orion5x/net2big-setup.c
+++ b/arch/arm/mach-orion5x/net2big-setup.c
@@ -419,8 +419,6 @@ static void __init net2big_init(void)
419 419
420/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */ 420/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
421MACHINE_START(NET2BIG, "LaCie 2Big Network") 421MACHINE_START(NET2BIG, "LaCie 2Big Network")
422 .phys_io = ORION5X_REGS_PHYS_BASE,
423 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
424 .boot_params = 0x00000100, 422 .boot_params = 0x00000100,
425 .init_machine = net2big_init, 423 .init_machine = net2big_init,
426 .map_io = orion5x_map_io, 424 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
index 9c1ca41730ba..f4c26fd731f4 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
@@ -169,8 +169,6 @@ subsys_initcall(rd88f5181l_fxo_pci_init);
169 169
170MACHINE_START(RD88F5181L_FXO, "Marvell Orion-VoIP FXO Reference Design") 170MACHINE_START(RD88F5181L_FXO, "Marvell Orion-VoIP FXO Reference Design")
171 /* Maintainer: Nicolas Pitre <nico@marvell.com> */ 171 /* Maintainer: Nicolas Pitre <nico@marvell.com> */
172 .phys_io = ORION5X_REGS_PHYS_BASE,
173 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
174 .boot_params = 0x00000100, 172 .boot_params = 0x00000100,
175 .init_machine = rd88f5181l_fxo_init, 173 .init_machine = rd88f5181l_fxo_init,
176 .map_io = orion5x_map_io, 174 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
index ee1399ff0ced..b5942909bab0 100644
--- a/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
@@ -181,8 +181,6 @@ subsys_initcall(rd88f5181l_ge_pci_init);
181 181
182MACHINE_START(RD88F5181L_GE, "Marvell Orion-VoIP GE Reference Design") 182MACHINE_START(RD88F5181L_GE, "Marvell Orion-VoIP GE Reference Design")
183 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 183 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
184 .phys_io = ORION5X_REGS_PHYS_BASE,
185 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
186 .boot_params = 0x00000100, 184 .boot_params = 0x00000100,
187 .init_machine = rd88f5181l_ge_init, 185 .init_machine = rd88f5181l_ge_init,
188 .map_io = orion5x_map_io, 186 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/rd88f5182-setup.c b/arch/arm/mach-orion5x/rd88f5182-setup.c
index a04f9e4b633a..165ed87029b2 100644
--- a/arch/arm/mach-orion5x/rd88f5182-setup.c
+++ b/arch/arm/mach-orion5x/rd88f5182-setup.c
@@ -305,8 +305,6 @@ static void __init rd88f5182_init(void)
305 305
306MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design") 306MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
307 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */ 307 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
308 .phys_io = ORION5X_REGS_PHYS_BASE,
309 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
310 .boot_params = 0x00000100, 308 .boot_params = 0x00000100,
311 .init_machine = rd88f5182_init, 309 .init_machine = rd88f5182_init,
312 .map_io = orion5x_map_io, 310 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
index 7737cf9a8f50..02ff45f3e2e3 100644
--- a/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
+++ b/arch/arm/mach-orion5x/rd88f6183ap-ge-setup.c
@@ -123,8 +123,6 @@ subsys_initcall(rd88f6183ap_ge_pci_init);
123 123
124MACHINE_START(RD88F6183AP_GE, "Marvell Orion-1-90 AP GE Reference Design") 124MACHINE_START(RD88F6183AP_GE, "Marvell Orion-1-90 AP GE Reference Design")
125 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 125 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
126 .phys_io = ORION5X_REGS_PHYS_BASE,
127 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
128 .boot_params = 0x00000100, 126 .boot_params = 0x00000100,
129 .init_machine = rd88f6183ap_ge_init, 127 .init_machine = rd88f6183ap_ge_init,
130 .map_io = orion5x_map_io, 128 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/terastation_pro2-setup.c b/arch/arm/mach-orion5x/terastation_pro2-setup.c
index 0b101d7d41c2..4403fae5ab0e 100644
--- a/arch/arm/mach-orion5x/terastation_pro2-setup.c
+++ b/arch/arm/mach-orion5x/terastation_pro2-setup.c
@@ -358,8 +358,6 @@ static void __init tsp2_init(void)
358 358
359MACHINE_START(TERASTATION_PRO2, "Buffalo Terastation Pro II/Live") 359MACHINE_START(TERASTATION_PRO2, "Buffalo Terastation Pro II/Live")
360 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */ 360 /* Maintainer: Sylver Bruneau <sylver.bruneau@googlemail.com> */
361 .phys_io = ORION5X_REGS_PHYS_BASE,
362 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
363 .boot_params = 0x00000100, 361 .boot_params = 0x00000100,
364 .init_machine = tsp2_init, 362 .init_machine = tsp2_init,
365 .map_io = orion5x_map_io, 363 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c
index 9d6890514199..1e196129d763 100644
--- a/arch/arm/mach-orion5x/ts209-setup.c
+++ b/arch/arm/mach-orion5x/ts209-setup.c
@@ -322,8 +322,6 @@ static void __init qnap_ts209_init(void)
322 322
323MACHINE_START(TS209, "QNAP TS-109/TS-209") 323MACHINE_START(TS209, "QNAP TS-109/TS-209")
324 /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */ 324 /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */
325 .phys_io = ORION5X_REGS_PHYS_BASE,
326 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
327 .boot_params = 0x00000100, 325 .boot_params = 0x00000100,
328 .init_machine = qnap_ts209_init, 326 .init_machine = qnap_ts209_init,
329 .map_io = orion5x_map_io, 327 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/ts409-setup.c b/arch/arm/mach-orion5x/ts409-setup.c
index d85588ac7ef8..428af2046e36 100644
--- a/arch/arm/mach-orion5x/ts409-setup.c
+++ b/arch/arm/mach-orion5x/ts409-setup.c
@@ -311,8 +311,6 @@ static void __init qnap_ts409_init(void)
311 311
312MACHINE_START(TS409, "QNAP TS-409") 312MACHINE_START(TS409, "QNAP TS-409")
313 /* Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com> */ 313 /* Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com> */
314 .phys_io = ORION5X_REGS_PHYS_BASE,
315 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
316 .boot_params = 0x00000100, 314 .boot_params = 0x00000100,
317 .init_machine = qnap_ts409_init, 315 .init_machine = qnap_ts409_init,
318 .map_io = orion5x_map_io, 316 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c
index 696b1a97f9e2..16f1bd5324be 100644
--- a/arch/arm/mach-orion5x/ts78xx-setup.c
+++ b/arch/arm/mach-orion5x/ts78xx-setup.c
@@ -550,8 +550,6 @@ static void __init ts78xx_init(void)
550 550
551MACHINE_START(TS78XX, "Technologic Systems TS-78xx SBC") 551MACHINE_START(TS78XX, "Technologic Systems TS-78xx SBC")
552 /* Maintainer: Alexander Clouter <alex@digriz.org.uk> */ 552 /* Maintainer: Alexander Clouter <alex@digriz.org.uk> */
553 .phys_io = ORION5X_REGS_PHYS_BASE,
554 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
555 .boot_params = 0x00000100, 553 .boot_params = 0x00000100,
556 .init_machine = ts78xx_init, 554 .init_machine = ts78xx_init,
557 .map_io = ts78xx_map_io, 555 .map_io = ts78xx_map_io,
diff --git a/arch/arm/mach-orion5x/wnr854t-setup.c b/arch/arm/mach-orion5x/wnr854t-setup.c
index 69208217b220..7994d6ec08a8 100644
--- a/arch/arm/mach-orion5x/wnr854t-setup.c
+++ b/arch/arm/mach-orion5x/wnr854t-setup.c
@@ -172,8 +172,6 @@ subsys_initcall(wnr854t_pci_init);
172 172
173MACHINE_START(WNR854T, "Netgear WNR854T") 173MACHINE_START(WNR854T, "Netgear WNR854T")
174 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */ 174 /* Maintainer: Imre Kaloz <kaloz@openwrt.org> */
175 .phys_io = ORION5X_REGS_PHYS_BASE,
176 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
177 .boot_params = 0x00000100, 175 .boot_params = 0x00000100,
178 .init_machine = wnr854t_init, 176 .init_machine = wnr854t_init,
179 .map_io = orion5x_map_io, 177 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-orion5x/wrt350n-v2-setup.c b/arch/arm/mach-orion5x/wrt350n-v2-setup.c
index f9f222ebb7ed..a5989b7eb53e 100644
--- a/arch/arm/mach-orion5x/wrt350n-v2-setup.c
+++ b/arch/arm/mach-orion5x/wrt350n-v2-setup.c
@@ -260,8 +260,6 @@ subsys_initcall(wrt350n_v2_pci_init);
260 260
261MACHINE_START(WRT350N_V2, "Linksys WRT350N v2") 261MACHINE_START(WRT350N_V2, "Linksys WRT350N v2")
262 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */ 262 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
263 .phys_io = ORION5X_REGS_PHYS_BASE,
264 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
265 .boot_params = 0x00000100, 263 .boot_params = 0x00000100,
266 .init_machine = wrt350n_v2_init, 264 .init_machine = wrt350n_v2_init,
267 .map_io = orion5x_map_io, 265 .map_io = orion5x_map_io,
diff --git a/arch/arm/mach-pnx4008/core.c b/arch/arm/mach-pnx4008/core.c
index 45734bb880a8..63399755f199 100644
--- a/arch/arm/mach-pnx4008/core.c
+++ b/arch/arm/mach-pnx4008/core.c
@@ -264,8 +264,6 @@ extern struct sys_timer pnx4008_timer;
264 264
265MACHINE_START(PNX4008, "Philips PNX4008") 265MACHINE_START(PNX4008, "Philips PNX4008")
266 /* Maintainer: MontaVista Software Inc. */ 266 /* Maintainer: MontaVista Software Inc. */
267 .phys_io = 0x40090000,
268 .io_pg_offst = (0xf4090000 >> 18) & 0xfffc,
269 .boot_params = 0x80000100, 267 .boot_params = 0x80000100,
270 .map_io = pnx4008_map_io, 268 .map_io = pnx4008_map_io,
271 .init_irq = pnx4008_init_irq, 269 .init_irq = pnx4008_init_irq,
diff --git a/arch/arm/mach-pnx4008/include/mach/debug-macro.S b/arch/arm/mach-pnx4008/include/mach/debug-macro.S
index 6ca8bd30bf46..931afebaf064 100644
--- a/arch/arm/mach-pnx4008/include/mach/debug-macro.S
+++ b/arch/arm/mach-pnx4008/include/mach/debug-macro.S
@@ -11,12 +11,10 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x00090000
16 tst \rx, #1 @ MMU enabled? 16 add \rv, \rp, #0xf4000000 @ virtual
17 mov \rx, #0x00090000 17 add \rp, \rp, #0x40000000 @ physical
18 addeq \rx, \rx, #0x40000000
19 addne \rx, \rx, #0xf4000000
20 .endm 18 .endm
21 19
22#define UART_SHIFT 2 20#define UART_SHIFT 2
diff --git a/arch/arm/mach-pnx4008/include/mach/vmalloc.h b/arch/arm/mach-pnx4008/include/mach/vmalloc.h
index 2ad398378aed..31b65ee07b0b 100644
--- a/arch/arm/mach-pnx4008/include/mach/vmalloc.h
+++ b/arch/arm/mach-pnx4008/include/mach/vmalloc.h
@@ -17,4 +17,4 @@
17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 17 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
18 * area for the same reason. ;) 18 * area for the same reason. ;)
19 */ 19 */
20#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 20#define VMALLOC_END 0xd0000000
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 7aefb9074852..dd235ecc9d6c 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -8,19 +8,16 @@ config ARCH_LUBBOCK
8 bool "Intel DBPXA250 Development Platform (aka Lubbock)" 8 bool "Intel DBPXA250 Development Platform (aka Lubbock)"
9 select PXA25x 9 select PXA25x
10 select SA1111 10 select SA1111
11 select PXA_HAVE_BOARD_IRQS
12 11
13config MACH_MAINSTONE 12config MACH_MAINSTONE
14 bool "Intel HCDDBBVA0 Development Platform (aka Mainstone)" 13 bool "Intel HCDDBBVA0 Development Platform (aka Mainstone)"
15 select PXA27x 14 select PXA27x
16 select HAVE_PWM 15 select HAVE_PWM
17 select PXA_HAVE_BOARD_IRQS
18 16
19config MACH_ZYLONITE 17config MACH_ZYLONITE
20 bool 18 bool
21 select PXA3xx 19 select PXA3xx
22 select HAVE_PWM 20 select HAVE_PWM
23 select PXA_HAVE_BOARD_IRQS
24 21
25config MACH_ZYLONITE300 22config MACH_ZYLONITE300
26 bool "PXA3xx Development Platform (aka Zylonite) PXA300/310" 23 bool "PXA3xx Development Platform (aka Zylonite) PXA300/310"
@@ -44,6 +41,10 @@ config MACH_TAVOREVB
44 select PXA3xx 41 select PXA3xx
45 select CPU_PXA930 42 select CPU_PXA930
46 43
44config MACH_TAVOREVB3
45 bool "PXA95x Development Platform (aka TavorEVB III)"
46 select CPU_PXA950
47
47config MACH_SAAR 48config MACH_SAAR
48 bool "PXA930 Handheld Platform (aka SAAR)" 49 bool "PXA930 Handheld Platform (aka SAAR)"
49 select PXA3xx 50 select PXA3xx
@@ -61,7 +62,6 @@ config ARCH_VIPER
61 select ISA 62 select ISA
62 select I2C_GPIO 63 select I2C_GPIO
63 select HAVE_PWM 64 select HAVE_PWM
64 select PXA_HAVE_BOARD_IRQS
65 select PXA_HAVE_ISA_IRQS 65 select PXA_HAVE_ISA_IRQS
66 select ARCOM_PCMCIA 66 select ARCOM_PCMCIA
67 67
@@ -69,7 +69,6 @@ config MACH_ARCOM_ZEUS
69 bool "Arcom/Eurotech ZEUS SBC" 69 bool "Arcom/Eurotech ZEUS SBC"
70 select PXA27x 70 select PXA27x
71 select ISA 71 select ISA
72 select PXA_HAVE_BOARD_IRQS
73 select PXA_HAVE_ISA_IRQS 72 select PXA_HAVE_ISA_IRQS
74 select ARCOM_PCMCIA 73 select ARCOM_PCMCIA
75 74
@@ -77,7 +76,6 @@ config MACH_BALLOON3
77 bool "Balloon 3 board" 76 bool "Balloon 3 board"
78 select PXA27x 77 select PXA27x
79 select IWMMXT 78 select IWMMXT
80 select PXA_HAVE_BOARD_IRQS
81 79
82config MACH_CSB726 80config MACH_CSB726
83 bool "Enable Cogent CSB726 System On a Module" 81 bool "Enable Cogent CSB726 System On a Module"
@@ -140,13 +138,11 @@ config MACH_INTELMOTE2
140 bool "Intel Mote 2 Platform" 138 bool "Intel Mote 2 Platform"
141 select PXA27x 139 select PXA27x
142 select IWMMXT 140 select IWMMXT
143 select PXA_HAVE_BOARD_IRQS
144 141
145config MACH_STARGATE2 142config MACH_STARGATE2
146 bool "Intel Stargate 2 Platform" 143 bool "Intel Stargate 2 Platform"
147 select PXA27x 144 select PXA27x
148 select IWMMXT 145 select IWMMXT
149 select PXA_HAVE_BOARD_IRQS
150 146
151config MACH_XCEP 147config MACH_XCEP
152 bool "Iskratel Electronics XCEP" 148 bool "Iskratel Electronics XCEP"
@@ -206,13 +202,11 @@ config MACH_LOGICPD_PXA270
206 bool "LogicPD PXA270 Card Engine Development Platform" 202 bool "LogicPD PXA270 Card Engine Development Platform"
207 select PXA27x 203 select PXA27x
208 select HAVE_PWM 204 select HAVE_PWM
209 select PXA_HAVE_BOARD_IRQS
210 205
211config MACH_PCM027 206config MACH_PCM027
212 bool "Phytec phyCORE-PXA270 CPU module (PCM-027)" 207 bool "Phytec phyCORE-PXA270 CPU module (PCM-027)"
213 select PXA27x 208 select PXA27x
214 select IWMMXT 209 select IWMMXT
215 select PXA_HAVE_BOARD_IRQS
216 210
217config MACH_PCM990_BASEBOARD 211config MACH_PCM990_BASEBOARD
218 bool "PHYTEC PCM-990 development board" 212 bool "PHYTEC PCM-990 development board"
@@ -247,7 +241,6 @@ config MACH_COLIBRI_PXA270_INCOME
247 depends on MACH_COLIBRI 241 depends on MACH_COLIBRI
248 select PXA27x 242 select PXA27x
249 select HAVE_PWM 243 select HAVE_PWM
250 select PXA_HAVE_BOARD_IRQS
251 244
252config MACH_COLIBRI300 245config MACH_COLIBRI300
253 bool "Toradex Colibri PXA300/310" 246 bool "Toradex Colibri PXA300/310"
@@ -274,7 +267,6 @@ config MACH_H4700
274 select PXA27x 267 select PXA27x
275 select IWMMXT 268 select IWMMXT
276 select HAVE_PWM 269 select HAVE_PWM
277 select PXA_HAVE_BOARD_IRQS
278 270
279config MACH_H5000 271config MACH_H5000
280 bool "HP iPAQ h5000" 272 bool "HP iPAQ h5000"
@@ -289,7 +281,6 @@ config MACH_MAGICIAN
289 select PXA27x 281 select PXA27x
290 select IWMMXT 282 select IWMMXT
291 select HAVE_PWM 283 select HAVE_PWM
292 select PXA_HAVE_BOARD_IRQS
293 284
294config MACH_MIOA701 285config MACH_MIOA701
295 bool "Mitac Mio A701 Support" 286 bool "Mitac Mio A701 Support"
@@ -307,7 +298,6 @@ config PXA_EZX
307 select PXA27x 298 select PXA27x
308 select IWMMXT 299 select IWMMXT
309 select HAVE_PWM 300 select HAVE_PWM
310 select PXA_HAVE_BOARD_IRQS
311 301
312config MACH_EZX_A780 302config MACH_EZX_A780
313 bool "Motorola EZX A780" 303 bool "Motorola EZX A780"
@@ -478,7 +468,6 @@ config MACH_POODLE
478 depends on PXA_SHARPSL 468 depends on PXA_SHARPSL
479 select PXA25x 469 select PXA25x
480 select SHARP_LOCOMO 470 select SHARP_LOCOMO
481 select PXA_HAVE_BOARD_IRQS
482 471
483config MACH_CORGI 472config MACH_CORGI
484 bool "Enable Sharp SL-C700 (Corgi) Support" 473 bool "Enable Sharp SL-C700 (Corgi) Support"
@@ -523,7 +512,6 @@ config MACH_TOSA
523 bool "Enable Sharp SL-6000x (Tosa) Support" 512 bool "Enable Sharp SL-6000x (Tosa) Support"
524 depends on PXA_SHARPSL 513 depends on PXA_SHARPSL
525 select PXA25x 514 select PXA25x
526 select PXA_HAVE_BOARD_IRQS
527 515
528config TOSA_BT 516config TOSA_BT
529 tristate "Control the state of built-in bluetooth chip on Sharp SL-6000" 517 tristate "Control the state of built-in bluetooth chip on Sharp SL-6000"
@@ -552,7 +540,6 @@ config MACH_ICONTROL
552config ARCH_PXA_ESERIES 540config ARCH_PXA_ESERIES
553 bool "PXA based Toshiba e-series PDAs" 541 bool "PXA based Toshiba e-series PDAs"
554 select PXA25x 542 select PXA25x
555 select PXA_HAVE_BOARD_IRQS
556 543
557config MACH_E330 544config MACH_E330
558 bool "Toshiba e330" 545 bool "Toshiba e330"
@@ -606,7 +593,6 @@ config MACH_ZIPIT2
606 bool "Zipit Z2 Handheld" 593 bool "Zipit Z2 Handheld"
607 select PXA27x 594 select PXA27x
608 select HAVE_PWM 595 select HAVE_PWM
609 select PXA_HAVE_BOARD_IRQS
610 596
611endmenu 597endmenu
612 598
@@ -643,6 +629,7 @@ config CPU_PXA300
643config CPU_PXA310 629config CPU_PXA310
644 bool 630 bool
645 select CPU_PXA300 631 select CPU_PXA300
632 select PXA310_ULPI if USB_ULPI
646 help 633 help
647 PXA310 (codename Monahans-LV) 634 PXA310 (codename Monahans-LV)
648 635
@@ -692,10 +679,10 @@ config SHARPSL_PM_MAX1111
692 select HWMON 679 select HWMON
693 select SENSORS_MAX1111 680 select SENSORS_MAX1111
694 681
695config PXA_HAVE_BOARD_IRQS 682config PXA_HAVE_ISA_IRQS
696 bool 683 bool
697 684
698config PXA_HAVE_ISA_IRQS 685config PXA310_ULPI
699 bool 686 bool
700 687
701endif 688endif
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 85c7fb324dbb..e2f89c2c6f49 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -18,7 +18,7 @@ endif
18# SoC-specific code 18# SoC-specific code
19obj-$(CONFIG_PXA25x) += mfp-pxa2xx.o pxa2xx.o pxa25x.o 19obj-$(CONFIG_PXA25x) += mfp-pxa2xx.o pxa2xx.o pxa25x.o
20obj-$(CONFIG_PXA27x) += mfp-pxa2xx.o pxa2xx.o pxa27x.o 20obj-$(CONFIG_PXA27x) += mfp-pxa2xx.o pxa2xx.o pxa27x.o
21obj-$(CONFIG_PXA3xx) += mfp-pxa3xx.o pxa3xx.o smemc.o 21obj-$(CONFIG_PXA3xx) += mfp-pxa3xx.o pxa3xx.o smemc.o pxa3xx-ulpi.o
22obj-$(CONFIG_CPU_PXA300) += pxa300.o 22obj-$(CONFIG_CPU_PXA300) += pxa300.o
23obj-$(CONFIG_CPU_PXA320) += pxa320.o 23obj-$(CONFIG_CPU_PXA320) += pxa320.o
24obj-$(CONFIG_CPU_PXA930) += pxa930.o 24obj-$(CONFIG_CPU_PXA930) += pxa930.o
@@ -32,6 +32,7 @@ obj-$(CONFIG_MACH_ZYLONITE300) += zylonite.o zylonite_pxa300.o
32obj-$(CONFIG_MACH_ZYLONITE320) += zylonite.o zylonite_pxa320.o 32obj-$(CONFIG_MACH_ZYLONITE320) += zylonite.o zylonite_pxa320.o
33obj-$(CONFIG_MACH_LITTLETON) += littleton.o 33obj-$(CONFIG_MACH_LITTLETON) += littleton.o
34obj-$(CONFIG_MACH_TAVOREVB) += tavorevb.o 34obj-$(CONFIG_MACH_TAVOREVB) += tavorevb.o
35obj-$(CONFIG_MACH_TAVOREVB3) += tavorevb3.o
35obj-$(CONFIG_MACH_SAAR) += saar.o 36obj-$(CONFIG_MACH_SAAR) += saar.o
36 37
37# 3rd Party Dev Platforms 38# 3rd Party Dev Platforms
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c
index 9041340fee1d..21e188901935 100644
--- a/arch/arm/mach-pxa/balloon3.c
+++ b/arch/arm/mach-pxa/balloon3.c
@@ -68,42 +68,6 @@ static unsigned long balloon3_pin_config[] __initdata = {
68 68
69 /* Reset, configured as GPIO wakeup source */ 69 /* Reset, configured as GPIO wakeup source */
70 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, 70 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
71
72 /* LEDs */
73 GPIO9_GPIO, /* NAND activity LED */
74 GPIO10_GPIO, /* Heartbeat LED */
75
76 /* AC97 */
77 GPIO28_AC97_BITCLK,
78 GPIO29_AC97_SDATA_IN_0,
79 GPIO30_AC97_SDATA_OUT,
80 GPIO31_AC97_SYNC,
81 GPIO113_AC97_nRESET,
82 GPIO95_GPIO,
83
84 /* MMC */
85 GPIO32_MMC_CLK,
86 GPIO92_MMC_DAT_0,
87 GPIO109_MMC_DAT_1,
88 GPIO110_MMC_DAT_2,
89 GPIO111_MMC_DAT_3,
90 GPIO112_MMC_CMD,
91
92 /* USB Host */
93 GPIO88_USBH1_PWR,
94 GPIO89_USBH1_PEN,
95
96 /* PC Card */
97 GPIO48_nPOE,
98 GPIO49_nPWE,
99 GPIO50_nPIOR,
100 GPIO51_nPIOW,
101 GPIO85_nPCE_1,
102 GPIO54_nPCE_2,
103 GPIO79_PSKTSEL,
104 GPIO55_nPREG,
105 GPIO56_nPWAIT,
106 GPIO57_nIOIS16,
107}; 71};
108 72
109/****************************************************************************** 73/******************************************************************************
@@ -132,6 +96,34 @@ int __init parse_balloon3_features(char *arg)
132early_param("balloon3_features", parse_balloon3_features); 96early_param("balloon3_features", parse_balloon3_features);
133 97
134/****************************************************************************** 98/******************************************************************************
99 * Compact Flash slot
100 ******************************************************************************/
101#if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
102static unsigned long balloon3_cf_pin_config[] __initdata = {
103 GPIO48_nPOE,
104 GPIO49_nPWE,
105 GPIO50_nPIOR,
106 GPIO51_nPIOW,
107 GPIO85_nPCE_1,
108 GPIO54_nPCE_2,
109 GPIO79_PSKTSEL,
110 GPIO55_nPREG,
111 GPIO56_nPWAIT,
112 GPIO57_nIOIS16,
113};
114
115static void __init balloon3_cf_init(void)
116{
117 if (!balloon3_has(BALLOON3_FEATURE_CF))
118 return;
119
120 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_cf_pin_config));
121}
122#else
123static inline void balloon3_cf_init(void) {}
124#endif
125
126/******************************************************************************
135 * NOR Flash 127 * NOR Flash
136 ******************************************************************************/ 128 ******************************************************************************/
137#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 129#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
@@ -179,6 +171,15 @@ static inline void balloon3_nor_init(void) {}
179 ******************************************************************************/ 171 ******************************************************************************/
180#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \ 172#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
181 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE) 173 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
174static unsigned long balloon3_ac97_pin_config[] __initdata = {
175 GPIO28_AC97_BITCLK,
176 GPIO29_AC97_SDATA_IN_0,
177 GPIO30_AC97_SDATA_OUT,
178 GPIO31_AC97_SYNC,
179 GPIO113_AC97_nRESET,
180 GPIO95_GPIO,
181};
182
182static struct ucb1400_pdata vpac270_ucb1400_pdata = { 183static struct ucb1400_pdata vpac270_ucb1400_pdata = {
183 .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ), 184 .irq = IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ),
184}; 185};
@@ -197,6 +198,7 @@ static void __init balloon3_ts_init(void)
197 if (!balloon3_has(BALLOON3_FEATURE_AUDIO)) 198 if (!balloon3_has(BALLOON3_FEATURE_AUDIO))
198 return; 199 return;
199 200
201 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_ac97_pin_config));
200 pxa_set_ac97_info(NULL); 202 pxa_set_ac97_info(NULL);
201 platform_device_register(&balloon3_ucb1400_device); 203 platform_device_register(&balloon3_ucb1400_device);
202} 204}
@@ -208,6 +210,11 @@ static inline void balloon3_ts_init(void) {}
208 * Framebuffer 210 * Framebuffer
209 ******************************************************************************/ 211 ******************************************************************************/
210#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 212#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
213static unsigned long balloon3_lcd_pin_config[] __initdata = {
214 GPIOxx_LCD_TFT_16BPP,
215 GPIO99_GPIO,
216};
217
211static struct pxafb_mode_info balloon3_lcd_modes[] = { 218static struct pxafb_mode_info balloon3_lcd_modes[] = {
212 { 219 {
213 .pixclock = 38000, 220 .pixclock = 38000,
@@ -242,6 +249,8 @@ static void __init balloon3_lcd_init(void)
242 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY)) 249 if (!balloon3_has(BALLOON3_FEATURE_TOPPOLY))
243 return; 250 return;
244 251
252 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_lcd_pin_config));
253
245 ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON"); 254 ret = gpio_request(BALLOON3_GPIO_RUN_BACKLIGHT, "BKL-ON");
246 if (ret) { 255 if (ret) {
247 pr_err("Requesting BKL-ON GPIO failed!\n"); 256 pr_err("Requesting BKL-ON GPIO failed!\n");
@@ -271,6 +280,15 @@ static inline void balloon3_lcd_init(void) {}
271 * SD/MMC card controller 280 * SD/MMC card controller
272 ******************************************************************************/ 281 ******************************************************************************/
273#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 282#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
283static unsigned long balloon3_mmc_pin_config[] __initdata = {
284 GPIO32_MMC_CLK,
285 GPIO92_MMC_DAT_0,
286 GPIO109_MMC_DAT_1,
287 GPIO110_MMC_DAT_2,
288 GPIO111_MMC_DAT_3,
289 GPIO112_MMC_CMD,
290};
291
274static struct pxamci_platform_data balloon3_mci_platform_data = { 292static struct pxamci_platform_data balloon3_mci_platform_data = {
275 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 293 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
276 .gpio_card_detect = -1, 294 .gpio_card_detect = -1,
@@ -281,6 +299,7 @@ static struct pxamci_platform_data balloon3_mci_platform_data = {
281 299
282static void __init balloon3_mmc_init(void) 300static void __init balloon3_mmc_init(void)
283{ 301{
302 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_mmc_pin_config));
284 pxa_set_mci_info(&balloon3_mci_platform_data); 303 pxa_set_mci_info(&balloon3_mci_platform_data);
285} 304}
286#else 305#else
@@ -339,6 +358,11 @@ static inline void balloon3_irda_init(void) {}
339 * USB Host 358 * USB Host
340 ******************************************************************************/ 359 ******************************************************************************/
341#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 360#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
361static unsigned long balloon3_uhc_pin_config[] __initdata = {
362 GPIO88_USBH1_PWR,
363 GPIO89_USBH1_PEN,
364};
365
342static struct pxaohci_platform_data balloon3_ohci_info = { 366static struct pxaohci_platform_data balloon3_ohci_info = {
343 .port_mode = PMM_PERPORT_MODE, 367 .port_mode = PMM_PERPORT_MODE,
344 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW, 368 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
@@ -348,6 +372,7 @@ static void __init balloon3_uhc_init(void)
348{ 372{
349 if (!balloon3_has(BALLOON3_FEATURE_OHCI)) 373 if (!balloon3_has(BALLOON3_FEATURE_OHCI))
350 return; 374 return;
375 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_uhc_pin_config));
351 pxa_set_ohci_info(&balloon3_ohci_info); 376 pxa_set_ohci_info(&balloon3_ohci_info);
352} 377}
353#else 378#else
@@ -358,6 +383,11 @@ static inline void balloon3_uhc_init(void) {}
358 * LEDs 383 * LEDs
359 ******************************************************************************/ 384 ******************************************************************************/
360#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 385#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
386static unsigned long balloon3_led_pin_config[] __initdata = {
387 GPIO9_GPIO, /* NAND activity LED */
388 GPIO10_GPIO, /* Heartbeat LED */
389};
390
361struct gpio_led balloon3_gpio_leds[] = { 391struct gpio_led balloon3_gpio_leds[] = {
362 { 392 {
363 .name = "balloon3:green:idle", 393 .name = "balloon3:green:idle",
@@ -436,6 +466,7 @@ static struct platform_device balloon3_pcf_leds = {
436 466
437static void __init balloon3_leds_init(void) 467static void __init balloon3_leds_init(void)
438{ 468{
469 pxa2xx_mfp_config(ARRAY_AND_SIZE(balloon3_led_pin_config));
439 platform_device_register(&balloon3_leds); 470 platform_device_register(&balloon3_leds);
440 platform_device_register(&balloon3_pcf_leds); 471 platform_device_register(&balloon3_pcf_leds);
441} 472}
@@ -757,6 +788,7 @@ static void __init balloon3_init(void)
757 balloon3_ts_init(); 788 balloon3_ts_init();
758 balloon3_udc_init(); 789 balloon3_udc_init();
759 balloon3_uhc_init(); 790 balloon3_uhc_init();
791 balloon3_cf_init();
760} 792}
761 793
762static struct map_desc balloon3_io_desc[] __initdata = { 794static struct map_desc balloon3_io_desc[] __initdata = {
@@ -776,9 +808,8 @@ static void __init balloon3_map_io(void)
776 808
777MACHINE_START(BALLOON3, "Balloon3") 809MACHINE_START(BALLOON3, "Balloon3")
778 /* Maintainer: Nick Bane. */ 810 /* Maintainer: Nick Bane. */
779 .phys_io = 0x40000000,
780 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
781 .map_io = balloon3_map_io, 811 .map_io = balloon3_map_io,
812 .nr_irqs = BALLOON3_NR_IRQS,
782 .init_irq = balloon3_init_irq, 813 .init_irq = balloon3_init_irq,
783 .timer = &pxa_timer, 814 .timer = &pxa_timer,
784 .init_machine = balloon3_init, 815 .init_machine = balloon3_init,
diff --git a/arch/arm/mach-pxa/capc7117.c b/arch/arm/mach-pxa/capc7117.c
index aae544631a8b..4bd7a3cda48c 100644
--- a/arch/arm/mach-pxa/capc7117.c
+++ b/arch/arm/mach-pxa/capc7117.c
@@ -148,9 +148,7 @@ static void __init capc7117_init(void)
148 148
149MACHINE_START(CAPC7117, 149MACHINE_START(CAPC7117,
150 "Embedian CAPC-7117 evaluation kit based on the MXM-8x10 CoM") 150 "Embedian CAPC-7117 evaluation kit based on the MXM-8x10 CoM")
151 .phys_io = 0x40000000,
152 .boot_params = 0xa0000100, 151 .boot_params = 0xa0000100,
153 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
154 .map_io = pxa_map_io, 152 .map_io = pxa_map_io,
155 .init_irq = pxa3xx_init_irq, 153 .init_irq = pxa3xx_init_irq,
156 .timer = &pxa_timer, 154 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/cm-x2xx.c b/arch/arm/mach-pxa/cm-x2xx.c
index bff6e78f033d..ac5598ce9724 100644
--- a/arch/arm/mach-pxa/cm-x2xx.c
+++ b/arch/arm/mach-pxa/cm-x2xx.c
@@ -33,6 +33,9 @@
33extern void cmx255_init(void); 33extern void cmx255_init(void);
34extern void cmx270_init(void); 34extern void cmx270_init(void);
35 35
36/* reserve IRQs for IT8152 */
37#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
38
36/* virtual addresses for statically mapped regions */ 39/* virtual addresses for statically mapped regions */
37#define CMX2XX_VIRT_BASE (0xe8000000) 40#define CMX2XX_VIRT_BASE (0xe8000000)
38#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE) 41#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
@@ -511,9 +514,8 @@ static void __init cmx2xx_map_io(void)
511 514
512MACHINE_START(ARMCORE, "Compulab CM-X2XX") 515MACHINE_START(ARMCORE, "Compulab CM-X2XX")
513 .boot_params = 0xa0000100, 516 .boot_params = 0xa0000100,
514 .phys_io = 0x40000000,
515 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
516 .map_io = cmx2xx_map_io, 517 .map_io = cmx2xx_map_io,
518 .nr_irqs = CMX2XX_NR_IRQS,
517 .init_irq = cmx2xx_init_irq, 519 .init_irq = cmx2xx_init_irq,
518 .timer = &pxa_timer, 520 .timer = &pxa_timer,
519 .init_machine = cmx2xx_init, 521 .init_machine = cmx2xx_init,
diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
index c70e6c2f4e7c..922b1075b9de 100644
--- a/arch/arm/mach-pxa/cm-x300.c
+++ b/arch/arm/mach-pxa/cm-x300.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/clk.h>
22 23
23#include <linux/gpio.h> 24#include <linux/gpio.h>
24#include <linux/dm9000.h> 25#include <linux/dm9000.h>
@@ -50,6 +51,7 @@
50#include <plat/i2c.h> 51#include <plat/i2c.h>
51#include <plat/pxa3xx_nand.h> 52#include <plat/pxa3xx_nand.h>
52#include <mach/audio.h> 53#include <mach/audio.h>
54#include <mach/pxa3xx-u2d.h>
53 55
54#include <asm/mach/map.h> 56#include <asm/mach/map.h>
55 57
@@ -68,6 +70,8 @@
68#define GPIO97_RTC_RD (97) 70#define GPIO97_RTC_RD (97)
69#define GPIO98_RTC_IO (98) 71#define GPIO98_RTC_IO (98)
70 72
73#define GPIO_ULPI_PHY_RST (127)
74
71static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = { 75static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
72 /* LCD */ 76 /* LCD */
73 GPIO54_LCD_LDD_0, 77 GPIO54_LCD_LDD_0,
@@ -472,6 +476,78 @@ static void __init cm_x300_init_mmc(void)
472static inline void cm_x300_init_mmc(void) {} 476static inline void cm_x300_init_mmc(void) {}
473#endif 477#endif
474 478
479#if defined(CONFIG_PXA310_ULPI)
480static struct clk *pout_clk;
481
482static int cm_x300_ulpi_phy_reset(void)
483{
484 int err;
485
486 /* reset the PHY */
487 err = gpio_request(GPIO_ULPI_PHY_RST, "ulpi reset");
488 if (err) {
489 pr_err("%s: failed to request ULPI reset GPIO: %d\n",
490 __func__, err);
491 return err;
492 }
493
494 gpio_direction_output(GPIO_ULPI_PHY_RST, 0);
495 msleep(10);
496 gpio_set_value(GPIO_ULPI_PHY_RST, 1);
497 msleep(10);
498
499 gpio_free(GPIO_ULPI_PHY_RST);
500
501 return 0;
502}
503
504static inline int cm_x300_u2d_init(struct device *dev)
505{
506 int err = 0;
507
508 if (cpu_is_pxa310()) {
509 /* CLK_POUT is connected to the ULPI PHY */
510 pout_clk = clk_get(NULL, "CLK_POUT");
511 if (IS_ERR(pout_clk)) {
512 err = PTR_ERR(pout_clk);
513 pr_err("%s: failed to get CLK_POUT: %d\n",
514 __func__, err);
515 return err;
516 }
517 clk_enable(pout_clk);
518
519 err = cm_x300_ulpi_phy_reset();
520 if (err) {
521 clk_disable(pout_clk);
522 clk_put(pout_clk);
523 }
524 }
525
526 return err;
527}
528
529static void cm_x300_u2d_exit(struct device *dev)
530{
531 if (cpu_is_pxa310()) {
532 clk_disable(pout_clk);
533 clk_put(pout_clk);
534 }
535}
536
537static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
538 .ulpi_mode = ULPI_SER_6PIN,
539 .init = cm_x300_u2d_init,
540 .exit = cm_x300_u2d_exit,
541};
542
543static void cm_x300_init_u2d(void)
544{
545 pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
546}
547#else
548static inline void cm_x300_init_u2d(void) {}
549#endif
550
475#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 551#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
476static int cm_x300_ohci_init(struct device *dev) 552static int cm_x300_ohci_init(struct device *dev)
477{ 553{
@@ -754,6 +830,7 @@ static void __init cm_x300_init(void)
754 cm_x300_init_da9030(); 830 cm_x300_init_da9030();
755 cm_x300_init_dm9000(); 831 cm_x300_init_dm9000();
756 cm_x300_init_lcd(); 832 cm_x300_init_lcd();
833 cm_x300_init_u2d();
757 cm_x300_init_ohci(); 834 cm_x300_init_ohci();
758 cm_x300_init_mmc(); 835 cm_x300_init_mmc();
759 cm_x300_init_nand(); 836 cm_x300_init_nand();
@@ -779,9 +856,7 @@ static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
779} 856}
780 857
781MACHINE_START(CM_X300, "CM-X300 module") 858MACHINE_START(CM_X300, "CM-X300 module")
782 .phys_io = 0x40000000,
783 .boot_params = 0xa0000100, 859 .boot_params = 0xa0000100,
784 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
785 .map_io = pxa_map_io, 860 .map_io = pxa_map_io,
786 .init_irq = pxa3xx_init_irq, 861 .init_irq = pxa3xx_init_irq,
787 .timer = &pxa_timer, 862 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/colibri-pxa270.c b/arch/arm/mach-pxa/colibri-pxa270.c
index 98673ac6efd0..bc045100ec15 100644
--- a/arch/arm/mach-pxa/colibri-pxa270.c
+++ b/arch/arm/mach-pxa/colibri-pxa270.c
@@ -207,8 +207,6 @@ static void __init colibri_pxa270_income_init(void)
207} 207}
208 208
209MACHINE_START(COLIBRI, "Toradex Colibri PXA270") 209MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
210 .phys_io = 0x40000000,
211 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
212 .boot_params = COLIBRI_SDRAM_BASE + 0x100, 210 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
213 .init_machine = colibri_pxa270_init, 211 .init_machine = colibri_pxa270_init,
214 .map_io = pxa_map_io, 212 .map_io = pxa_map_io,
@@ -217,8 +215,6 @@ MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
217MACHINE_END 215MACHINE_END
218 216
219MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC") 217MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC")
220 .phys_io = 0x40000000,
221 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
222 .boot_params = 0xa0000100, 218 .boot_params = 0xa0000100,
223 .init_machine = colibri_pxa270_income_init, 219 .init_machine = colibri_pxa270_income_init,
224 .map_io = pxa_map_io, 220 .map_io = pxa_map_io,
diff --git a/arch/arm/mach-pxa/colibri-pxa300.c b/arch/arm/mach-pxa/colibri-pxa300.c
index 40b6ac2de876..a70b256591e6 100644
--- a/arch/arm/mach-pxa/colibri-pxa300.c
+++ b/arch/arm/mach-pxa/colibri-pxa300.c
@@ -186,8 +186,6 @@ void __init colibri_pxa300_init(void)
186} 186}
187 187
188MACHINE_START(COLIBRI300, "Toradex Colibri PXA300") 188MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
189 .phys_io = 0x40000000,
190 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
191 .boot_params = COLIBRI_SDRAM_BASE + 0x100, 189 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
192 .init_machine = colibri_pxa300_init, 190 .init_machine = colibri_pxa300_init,
193 .map_io = pxa_map_io, 191 .map_io = pxa_map_io,
diff --git a/arch/arm/mach-pxa/colibri-pxa320.c b/arch/arm/mach-pxa/colibri-pxa320.c
index 99e850d84710..ca5f29e2e9cd 100644
--- a/arch/arm/mach-pxa/colibri-pxa320.c
+++ b/arch/arm/mach-pxa/colibri-pxa320.c
@@ -255,8 +255,6 @@ void __init colibri_pxa320_init(void)
255} 255}
256 256
257MACHINE_START(COLIBRI320, "Toradex Colibri PXA320") 257MACHINE_START(COLIBRI320, "Toradex Colibri PXA320")
258 .phys_io = 0x40000000,
259 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
260 .boot_params = COLIBRI_SDRAM_BASE + 0x100, 258 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
261 .init_machine = colibri_pxa320_init, 259 .init_machine = colibri_pxa320_init,
262 .map_io = pxa_map_io, 260 .map_io = pxa_map_io,
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 3fb0fc099080..821229acabe6 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -720,8 +720,6 @@ static void __init fixup_corgi(struct machine_desc *desc,
720 720
721#ifdef CONFIG_MACH_CORGI 721#ifdef CONFIG_MACH_CORGI
722MACHINE_START(CORGI, "SHARP Corgi") 722MACHINE_START(CORGI, "SHARP Corgi")
723 .phys_io = 0x40000000,
724 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
725 .fixup = fixup_corgi, 723 .fixup = fixup_corgi,
726 .map_io = pxa_map_io, 724 .map_io = pxa_map_io,
727 .init_irq = pxa25x_init_irq, 725 .init_irq = pxa25x_init_irq,
@@ -732,8 +730,6 @@ MACHINE_END
732 730
733#ifdef CONFIG_MACH_SHEPHERD 731#ifdef CONFIG_MACH_SHEPHERD
734MACHINE_START(SHEPHERD, "SHARP Shepherd") 732MACHINE_START(SHEPHERD, "SHARP Shepherd")
735 .phys_io = 0x40000000,
736 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
737 .fixup = fixup_corgi, 733 .fixup = fixup_corgi,
738 .map_io = pxa_map_io, 734 .map_io = pxa_map_io,
739 .init_irq = pxa25x_init_irq, 735 .init_irq = pxa25x_init_irq,
@@ -744,8 +740,6 @@ MACHINE_END
744 740
745#ifdef CONFIG_MACH_HUSKY 741#ifdef CONFIG_MACH_HUSKY
746MACHINE_START(HUSKY, "SHARP Husky") 742MACHINE_START(HUSKY, "SHARP Husky")
747 .phys_io = 0x40000000,
748 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
749 .fixup = fixup_corgi, 743 .fixup = fixup_corgi,
750 .map_io = pxa_map_io, 744 .map_io = pxa_map_io,
751 .init_irq = pxa25x_init_irq, 745 .init_irq = pxa25x_init_irq,
diff --git a/arch/arm/mach-pxa/cpufreq-pxa3xx.c b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
index 0a0d0fe99220..88fbec05ec50 100644
--- a/arch/arm/mach-pxa/cpufreq-pxa3xx.c
+++ b/arch/arm/mach-pxa/cpufreq-pxa3xx.c
@@ -159,7 +159,7 @@ static int pxa3xx_cpufreq_verify(struct cpufreq_policy *policy)
159 159
160static unsigned int pxa3xx_cpufreq_get(unsigned int cpu) 160static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)
161{ 161{
162 return get_clk_frequency_khz(0); 162 return pxa3xx_get_clk_frequency_khz(0);
163} 163}
164 164
165static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, 165static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy,
@@ -212,7 +212,8 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
212 policy->cpuinfo.min_freq = 104000; 212 policy->cpuinfo.min_freq = 104000;
213 policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000; 213 policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000;
214 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ 214 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
215 policy->cur = policy->min = policy->max = get_clk_frequency_khz(0); 215 policy->max = pxa3xx_get_clk_frequency_khz(0);
216 policy->cur = policy->min = policy->max;
216 217
217 if (cpu_is_pxa300() || cpu_is_pxa310()) 218 if (cpu_is_pxa300() || cpu_is_pxa310())
218 ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa300_freqs)); 219 ret = setup_freqs_table(policy, ARRAY_AND_SIZE(pxa300_freqs));
diff --git a/arch/arm/mach-pxa/csb726.c b/arch/arm/mach-pxa/csb726.c
index 91fd4fea6a54..57cacaff194d 100644
--- a/arch/arm/mach-pxa/csb726.c
+++ b/arch/arm/mach-pxa/csb726.c
@@ -272,9 +272,7 @@ static void __init csb726_init(void)
272} 272}
273 273
274MACHINE_START(CSB726, "Cogent CSB726") 274MACHINE_START(CSB726, "Cogent CSB726")
275 .phys_io = 0x40000000,
276 .boot_params = 0xa0000100, 275 .boot_params = 0xa0000100,
277 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
278 .map_io = pxa_map_io, 276 .map_io = pxa_map_io,
279 .init_irq = pxa27x_init_irq, 277 .init_irq = pxa27x_init_irq,
280 .init_machine = csb726_init, 278 .init_machine = csb726_init,
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 65447dc736c2..08b410343870 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -6,11 +6,12 @@
6 6
7#include <asm/pmu.h> 7#include <asm/pmu.h>
8#include <mach/udc.h> 8#include <mach/udc.h>
9#include <mach/pxa3xx-u2d.h>
9#include <mach/pxafb.h> 10#include <mach/pxafb.h>
10#include <mach/mmc.h> 11#include <mach/mmc.h>
11#include <mach/irda.h> 12#include <mach/irda.h>
12#include <mach/ohci.h> 13#include <mach/ohci.h>
13#include <mach/pxa27x_keypad.h> 14#include <plat/pxa27x_keypad.h>
14#include <mach/pxa2xx_spi.h> 15#include <mach/pxa2xx_spi.h>
15#include <mach/camera.h> 16#include <mach/camera.h>
16#include <mach/audio.h> 17#include <mach/audio.h>
@@ -134,6 +135,33 @@ struct platform_device pxa27x_device_udc = {
134 } 135 }
135}; 136};
136 137
138#ifdef CONFIG_PXA3xx
139static struct resource pxa3xx_u2d_resources[] = {
140 [0] = {
141 .start = 0x54100000,
142 .end = 0x54100fff,
143 .flags = IORESOURCE_MEM,
144 },
145 [1] = {
146 .start = IRQ_USB2,
147 .end = IRQ_USB2,
148 .flags = IORESOURCE_IRQ,
149 },
150};
151
152struct platform_device pxa3xx_device_u2d = {
153 .name = "pxa3xx-u2d",
154 .id = -1,
155 .resource = pxa3xx_u2d_resources,
156 .num_resources = ARRAY_SIZE(pxa3xx_u2d_resources),
157};
158
159void __init pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info)
160{
161 pxa_register_device(&pxa3xx_device_u2d, info);
162}
163#endif /* CONFIG_PXA3xx */
164
137static struct resource pxafb_resources[] = { 165static struct resource pxafb_resources[] = {
138 [0] = { 166 [0] = {
139 .start = 0x44000000, 167 .start = 0x44000000,
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 50353ea49ba4..715e8bd02e24 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -4,6 +4,7 @@ extern struct platform_device pxa3xx_device_mci2;
4extern struct platform_device pxa3xx_device_mci3; 4extern struct platform_device pxa3xx_device_mci3;
5extern struct platform_device pxa25x_device_udc; 5extern struct platform_device pxa25x_device_udc;
6extern struct platform_device pxa27x_device_udc; 6extern struct platform_device pxa27x_device_udc;
7extern struct platform_device pxa3xx_device_u2d;
7extern struct platform_device pxa_device_fb; 8extern struct platform_device pxa_device_fb;
8extern struct platform_device pxa_device_ffuart; 9extern struct platform_device pxa_device_ffuart;
9extern struct platform_device pxa_device_btuart; 10extern struct platform_device pxa_device_btuart;
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 0517c17978f3..ab48bb81b570 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -43,7 +43,7 @@
43#include <mach/pxafb.h> 43#include <mach/pxafb.h>
44#include <mach/ohci.h> 44#include <mach/ohci.h>
45#include <mach/mmc.h> 45#include <mach/mmc.h>
46#include <mach/pxa27x_keypad.h> 46#include <plat/pxa27x_keypad.h>
47#include <plat/i2c.h> 47#include <plat/i2c.h>
48#include <mach/camera.h> 48#include <mach/camera.h>
49#include <mach/pxa2xx_spi.h> 49#include <mach/pxa2xx_spi.h>
@@ -1301,8 +1301,6 @@ static void __init em_x270_init(void)
1301 1301
1302MACHINE_START(EM_X270, "Compulab EM-X270") 1302MACHINE_START(EM_X270, "Compulab EM-X270")
1303 .boot_params = 0xa0000100, 1303 .boot_params = 0xa0000100,
1304 .phys_io = 0x40000000,
1305 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1306 .map_io = pxa_map_io, 1304 .map_io = pxa_map_io,
1307 .init_irq = pxa27x_init_irq, 1305 .init_irq = pxa27x_init_irq,
1308 .timer = &pxa_timer, 1306 .timer = &pxa_timer,
@@ -1311,8 +1309,6 @@ MACHINE_END
1311 1309
1312MACHINE_START(EXEDA, "Compulab eXeda") 1310MACHINE_START(EXEDA, "Compulab eXeda")
1313 .boot_params = 0xa0000100, 1311 .boot_params = 0xa0000100,
1314 .phys_io = 0x40000000,
1315 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1316 .map_io = pxa_map_io, 1312 .map_io = pxa_map_io,
1317 .init_irq = pxa27x_init_irq, 1313 .init_irq = pxa27x_init_irq,
1318 .timer = &pxa_timer, 1314 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/eseries.c b/arch/arm/mach-pxa/eseries.c
index 349212a1cbd3..b25690ccadc4 100644
--- a/arch/arm/mach-pxa/eseries.c
+++ b/arch/arm/mach-pxa/eseries.c
@@ -29,6 +29,7 @@
29 29
30#include <mach/pxa25x.h> 30#include <mach/pxa25x.h>
31#include <mach/eseries-gpio.h> 31#include <mach/eseries-gpio.h>
32#include <mach/eseries-irq.h>
32#include <mach/audio.h> 33#include <mach/audio.h>
33#include <mach/pxafb.h> 34#include <mach/pxafb.h>
34#include <mach/udc.h> 35#include <mach/udc.h>
@@ -179,10 +180,9 @@ static void __init e330_init(void)
179 180
180MACHINE_START(E330, "Toshiba e330") 181MACHINE_START(E330, "Toshiba e330")
181 /* Maintainer: Ian Molton (spyro@f2s.com) */ 182 /* Maintainer: Ian Molton (spyro@f2s.com) */
182 .phys_io = 0x40000000,
183 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
184 .boot_params = 0xa0000100, 183 .boot_params = 0xa0000100,
185 .map_io = pxa_map_io, 184 .map_io = pxa_map_io,
185 .nr_irqs = ESERIES_NR_IRQS,
186 .init_irq = pxa25x_init_irq, 186 .init_irq = pxa25x_init_irq,
187 .fixup = eseries_fixup, 187 .fixup = eseries_fixup,
188 .init_machine = e330_init, 188 .init_machine = e330_init,
@@ -229,10 +229,9 @@ static void __init e350_init(void)
229 229
230MACHINE_START(E350, "Toshiba e350") 230MACHINE_START(E350, "Toshiba e350")
231 /* Maintainer: Ian Molton (spyro@f2s.com) */ 231 /* Maintainer: Ian Molton (spyro@f2s.com) */
232 .phys_io = 0x40000000,
233 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
234 .boot_params = 0xa0000100, 232 .boot_params = 0xa0000100,
235 .map_io = pxa_map_io, 233 .map_io = pxa_map_io,
234 .nr_irqs = ESERIES_NR_IRQS,
236 .init_irq = pxa25x_init_irq, 235 .init_irq = pxa25x_init_irq,
237 .fixup = eseries_fixup, 236 .fixup = eseries_fixup,
238 .init_machine = e350_init, 237 .init_machine = e350_init,
@@ -352,10 +351,9 @@ static void __init e400_init(void)
352 351
353MACHINE_START(E400, "Toshiba e400") 352MACHINE_START(E400, "Toshiba e400")
354 /* Maintainer: Ian Molton (spyro@f2s.com) */ 353 /* Maintainer: Ian Molton (spyro@f2s.com) */
355 .phys_io = 0x40000000,
356 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
357 .boot_params = 0xa0000100, 354 .boot_params = 0xa0000100,
358 .map_io = pxa_map_io, 355 .map_io = pxa_map_io,
356 .nr_irqs = ESERIES_NR_IRQS,
359 .init_irq = pxa25x_init_irq, 357 .init_irq = pxa25x_init_irq,
360 .fixup = eseries_fixup, 358 .fixup = eseries_fixup,
361 .init_machine = e400_init, 359 .init_machine = e400_init,
@@ -541,10 +539,9 @@ static void __init e740_init(void)
541 539
542MACHINE_START(E740, "Toshiba e740") 540MACHINE_START(E740, "Toshiba e740")
543 /* Maintainer: Ian Molton (spyro@f2s.com) */ 541 /* Maintainer: Ian Molton (spyro@f2s.com) */
544 .phys_io = 0x40000000,
545 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
546 .boot_params = 0xa0000100, 542 .boot_params = 0xa0000100,
547 .map_io = pxa_map_io, 543 .map_io = pxa_map_io,
544 .nr_irqs = ESERIES_NR_IRQS,
548 .init_irq = pxa25x_init_irq, 545 .init_irq = pxa25x_init_irq,
549 .fixup = eseries_fixup, 546 .fixup = eseries_fixup,
550 .init_machine = e740_init, 547 .init_machine = e740_init,
@@ -733,10 +730,9 @@ static void __init e750_init(void)
733 730
734MACHINE_START(E750, "Toshiba e750") 731MACHINE_START(E750, "Toshiba e750")
735 /* Maintainer: Ian Molton (spyro@f2s.com) */ 732 /* Maintainer: Ian Molton (spyro@f2s.com) */
736 .phys_io = 0x40000000,
737 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
738 .boot_params = 0xa0000100, 733 .boot_params = 0xa0000100,
739 .map_io = pxa_map_io, 734 .map_io = pxa_map_io,
735 .nr_irqs = ESERIES_NR_IRQS,
740 .init_irq = pxa25x_init_irq, 736 .init_irq = pxa25x_init_irq,
741 .fixup = eseries_fixup, 737 .fixup = eseries_fixup,
742 .init_machine = e750_init, 738 .init_machine = e750_init,
@@ -929,10 +925,9 @@ static void __init e800_init(void)
929 925
930MACHINE_START(E800, "Toshiba e800") 926MACHINE_START(E800, "Toshiba e800")
931 /* Maintainer: Ian Molton (spyro@f2s.com) */ 927 /* Maintainer: Ian Molton (spyro@f2s.com) */
932 .phys_io = 0x40000000,
933 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
934 .boot_params = 0xa0000100, 928 .boot_params = 0xa0000100,
935 .map_io = pxa_map_io, 929 .map_io = pxa_map_io,
930 .nr_irqs = ESERIES_NR_IRQS,
936 .init_irq = pxa25x_init_irq, 931 .init_irq = pxa25x_init_irq,
937 .fixup = eseries_fixup, 932 .fixup = eseries_fixup,
938 .init_machine = e800_init, 933 .init_machine = e800_init,
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 626c82b13970..80a9352d43f3 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -32,12 +32,14 @@
32#include <mach/ohci.h> 32#include <mach/ohci.h>
33#include <plat/i2c.h> 33#include <plat/i2c.h>
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/pxa27x_keypad.h> 35#include <plat/pxa27x_keypad.h>
36#include <mach/camera.h> 36#include <mach/camera.h>
37 37
38#include "devices.h" 38#include "devices.h"
39#include "generic.h" 39#include "generic.h"
40 40
41#define EZX_NR_IRQS (IRQ_BOARD_START + 24)
42
41#define GPIO12_A780_FLIP_LID 12 43#define GPIO12_A780_FLIP_LID 12
42#define GPIO15_A1200_FLIP_LID 15 44#define GPIO15_A1200_FLIP_LID 15
43#define GPIO15_A910_FLIP_LID 15 45#define GPIO15_A910_FLIP_LID 15
@@ -796,10 +798,9 @@ static void __init a780_init(void)
796} 798}
797 799
798MACHINE_START(EZX_A780, "Motorola EZX A780") 800MACHINE_START(EZX_A780, "Motorola EZX A780")
799 .phys_io = 0x40000000,
800 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
801 .boot_params = 0xa0000100, 801 .boot_params = 0xa0000100,
802 .map_io = pxa_map_io, 802 .map_io = pxa_map_io,
803 .nr_irqs = EZX_NR_IRQS,
803 .init_irq = pxa27x_init_irq, 804 .init_irq = pxa27x_init_irq,
804 .timer = &pxa_timer, 805 .timer = &pxa_timer,
805 .init_machine = a780_init, 806 .init_machine = a780_init,
@@ -862,10 +863,9 @@ static void __init e680_init(void)
862} 863}
863 864
864MACHINE_START(EZX_E680, "Motorola EZX E680") 865MACHINE_START(EZX_E680, "Motorola EZX E680")
865 .phys_io = 0x40000000,
866 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
867 .boot_params = 0xa0000100, 866 .boot_params = 0xa0000100,
868 .map_io = pxa_map_io, 867 .map_io = pxa_map_io,
868 .nr_irqs = EZX_NR_IRQS,
869 .init_irq = pxa27x_init_irq, 869 .init_irq = pxa27x_init_irq,
870 .timer = &pxa_timer, 870 .timer = &pxa_timer,
871 .init_machine = e680_init, 871 .init_machine = e680_init,
@@ -928,10 +928,9 @@ static void __init a1200_init(void)
928} 928}
929 929
930MACHINE_START(EZX_A1200, "Motorola EZX A1200") 930MACHINE_START(EZX_A1200, "Motorola EZX A1200")
931 .phys_io = 0x40000000,
932 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
933 .boot_params = 0xa0000100, 931 .boot_params = 0xa0000100,
934 .map_io = pxa_map_io, 932 .map_io = pxa_map_io,
933 .nr_irqs = EZX_NR_IRQS,
935 .init_irq = pxa27x_init_irq, 934 .init_irq = pxa27x_init_irq,
936 .timer = &pxa_timer, 935 .timer = &pxa_timer,
937 .init_machine = a1200_init, 936 .init_machine = a1200_init,
@@ -1120,10 +1119,9 @@ static void __init a910_init(void)
1120} 1119}
1121 1120
1122MACHINE_START(EZX_A910, "Motorola EZX A910") 1121MACHINE_START(EZX_A910, "Motorola EZX A910")
1123 .phys_io = 0x40000000,
1124 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1125 .boot_params = 0xa0000100, 1122 .boot_params = 0xa0000100,
1126 .map_io = pxa_map_io, 1123 .map_io = pxa_map_io,
1124 .nr_irqs = EZX_NR_IRQS,
1127 .init_irq = pxa27x_init_irq, 1125 .init_irq = pxa27x_init_irq,
1128 .timer = &pxa_timer, 1126 .timer = &pxa_timer,
1129 .init_machine = a910_init, 1127 .init_machine = a910_init,
@@ -1186,10 +1184,9 @@ static void __init e6_init(void)
1186} 1184}
1187 1185
1188MACHINE_START(EZX_E6, "Motorola EZX E6") 1186MACHINE_START(EZX_E6, "Motorola EZX E6")
1189 .phys_io = 0x40000000,
1190 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1191 .boot_params = 0xa0000100, 1187 .boot_params = 0xa0000100,
1192 .map_io = pxa_map_io, 1188 .map_io = pxa_map_io,
1189 .nr_irqs = EZX_NR_IRQS,
1193 .init_irq = pxa27x_init_irq, 1190 .init_irq = pxa27x_init_irq,
1194 .timer = &pxa_timer, 1191 .timer = &pxa_timer,
1195 .init_machine = e6_init, 1192 .init_machine = e6_init,
@@ -1226,10 +1223,9 @@ static void __init e2_init(void)
1226} 1223}
1227 1224
1228MACHINE_START(EZX_E2, "Motorola EZX E2") 1225MACHINE_START(EZX_E2, "Motorola EZX E2")
1229 .phys_io = 0x40000000,
1230 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1231 .boot_params = 0xa0000100, 1226 .boot_params = 0xa0000100,
1232 .map_io = pxa_map_io, 1227 .map_io = pxa_map_io,
1228 .nr_irqs = EZX_NR_IRQS,
1233 .init_irq = pxa27x_init_irq, 1229 .init_irq = pxa27x_init_irq,
1234 .timer = &pxa_timer, 1230 .timer = &pxa_timer,
1235 .init_machine = e2_init, 1231 .init_machine = e2_init,
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index baabb3ce088e..6451e9c3a93f 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -66,8 +66,7 @@ unsigned int get_clk_frequency_khz(int info)
66 return pxa25x_get_clk_frequency_khz(info); 66 return pxa25x_get_clk_frequency_khz(info);
67 else if (cpu_is_pxa27x()) 67 else if (cpu_is_pxa27x())
68 return pxa27x_get_clk_frequency_khz(info); 68 return pxa27x_get_clk_frequency_khz(info);
69 else 69 return 0;
70 return pxa3xx_get_clk_frequency_khz(info);
71} 70}
72EXPORT_SYMBOL(get_clk_frequency_khz); 71EXPORT_SYMBOL(get_clk_frequency_khz);
73 72
@@ -80,8 +79,7 @@ unsigned int get_memclk_frequency_10khz(void)
80 return pxa25x_get_memclk_frequency_10khz(); 79 return pxa25x_get_memclk_frequency_10khz();
81 else if (cpu_is_pxa27x()) 80 else if (cpu_is_pxa27x())
82 return pxa27x_get_memclk_frequency_10khz(); 81 return pxa27x_get_memclk_frequency_10khz();
83 else 82 return 0;
84 return pxa3xx_get_memclk_frequency_10khz();
85} 83}
86EXPORT_SYMBOL(get_memclk_frequency_10khz); 84EXPORT_SYMBOL(get_memclk_frequency_10khz);
87 85
diff --git a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h
index c6305c5b8a72..4b1ad2769ed7 100644
--- a/arch/arm/mach-pxa/generic.h
+++ b/arch/arm/mach-pxa/generic.h
@@ -54,11 +54,9 @@ static inline void pxa2xx_clear_reset_status(unsigned int mask) {}
54 54
55#ifdef CONFIG_PXA3xx 55#ifdef CONFIG_PXA3xx
56extern unsigned pxa3xx_get_clk_frequency_khz(int); 56extern unsigned pxa3xx_get_clk_frequency_khz(int);
57extern unsigned pxa3xx_get_memclk_frequency_10khz(void);
58extern void pxa3xx_clear_reset_status(unsigned int); 57extern void pxa3xx_clear_reset_status(unsigned int);
59#else 58#else
60#define pxa3xx_get_clk_frequency_khz(x) (0) 59#define pxa3xx_get_clk_frequency_khz(x) (0)
61#define pxa3xx_get_memclk_frequency_10khz() (0)
62static inline void pxa3xx_clear_reset_status(unsigned int mask) {} 60static inline void pxa3xx_clear_reset_status(unsigned int mask) {}
63#endif 61#endif
64 62
diff --git a/arch/arm/mach-pxa/gumstix.c b/arch/arm/mach-pxa/gumstix.c
index 96c345129135..1e2a9a13aec1 100644
--- a/arch/arm/mach-pxa/gumstix.c
+++ b/arch/arm/mach-pxa/gumstix.c
@@ -224,9 +224,7 @@ static void __init gumstix_init(void)
224} 224}
225 225
226MACHINE_START(GUMSTIX, "Gumstix") 226MACHINE_START(GUMSTIX, "Gumstix")
227 .phys_io = 0x40000000,
228 .boot_params = 0xa0000100, /* match u-boot bi_boot_params */ 227 .boot_params = 0xa0000100, /* match u-boot bi_boot_params */
229 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
230 .map_io = pxa_map_io, 228 .map_io = pxa_map_io,
231 .init_irq = pxa25x_init_irq, 229 .init_irq = pxa25x_init_irq,
232 .timer = &pxa_timer, 230 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/h5000.c b/arch/arm/mach-pxa/h5000.c
index c1cab0871c99..7057a1f46db4 100644
--- a/arch/arm/mach-pxa/h5000.c
+++ b/arch/arm/mach-pxa/h5000.c
@@ -201,8 +201,6 @@ static void __init h5000_init(void)
201} 201}
202 202
203MACHINE_START(H5400, "HP iPAQ H5000") 203MACHINE_START(H5400, "HP iPAQ H5000")
204 .phys_io = 0x40000000,
205 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
206 .boot_params = 0xa0000100, 204 .boot_params = 0xa0000100,
207 .map_io = pxa_map_io, 205 .map_io = pxa_map_io,
208 .init_irq = pxa25x_init_irq, 206 .init_irq = pxa25x_init_irq,
diff --git a/arch/arm/mach-pxa/himalaya.c b/arch/arm/mach-pxa/himalaya.c
index f9a2e4b0f090..01b7f07ebad2 100644
--- a/arch/arm/mach-pxa/himalaya.c
+++ b/arch/arm/mach-pxa/himalaya.c
@@ -159,8 +159,6 @@ static void __init himalaya_init(void)
159 159
160 160
161MACHINE_START(HIMALAYA, "HTC Himalaya") 161MACHINE_START(HIMALAYA, "HTC Himalaya")
162 .phys_io = 0x40000000,
163 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
164 .boot_params = 0xa0000100, 162 .boot_params = 0xa0000100,
165 .map_io = pxa_map_io, 163 .map_io = pxa_map_io,
166 .init_irq = pxa25x_init_irq, 164 .init_irq = pxa25x_init_irq,
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 848c861dd23f..76d93a25bab6 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -870,10 +870,9 @@ static void __init hx4700_init(void)
870} 870}
871 871
872MACHINE_START(H4700, "HP iPAQ HX4700") 872MACHINE_START(H4700, "HP iPAQ HX4700")
873 .phys_io = 0x40000000,
874 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
875 .boot_params = 0xa0000100, 873 .boot_params = 0xa0000100,
876 .map_io = pxa_map_io, 874 .map_io = pxa_map_io,
875 .nr_irqs = HX4700_NR_IRQS,
877 .init_irq = pxa27x_init_irq, 876 .init_irq = pxa27x_init_irq,
878 .init_machine = hx4700_init, 877 .init_machine = hx4700_init,
879 .timer = &pxa_timer, 878 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c
index 5ccb0ceff6c4..d51ee3d25e70 100644
--- a/arch/arm/mach-pxa/icontrol.c
+++ b/arch/arm/mach-pxa/icontrol.c
@@ -191,9 +191,7 @@ static void __init icontrol_init(void)
191} 191}
192 192
193MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM") 193MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
194 .phys_io = 0x40000000,
195 .boot_params = 0xa0000100, 194 .boot_params = 0xa0000100,
196 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
197 .map_io = pxa_map_io, 195 .map_io = pxa_map_io,
198 .init_irq = pxa3xx_init_irq, 196 .init_irq = pxa3xx_init_irq,
199 .timer = &pxa_timer, 197 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index bc78c4dc0c66..e773dceeabc6 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -194,8 +194,6 @@ static void __init idp_map_io(void)
194 194
195MACHINE_START(PXA_IDP, "Vibren PXA255 IDP") 195MACHINE_START(PXA_IDP, "Vibren PXA255 IDP")
196 /* Maintainer: Vibren Technologies */ 196 /* Maintainer: Vibren Technologies */
197 .phys_io = 0x40000000,
198 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
199 .map_io = idp_map_io, 197 .map_io = idp_map_io,
200 .init_irq = pxa25x_init_irq, 198 .init_irq = pxa25x_init_irq,
201 .timer = &pxa_timer, 199 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/include/mach/balloon3.h b/arch/arm/mach-pxa/include/mach/balloon3.h
index eec92e6fd7cf..561562b4360b 100644
--- a/arch/arm/mach-pxa/include/mach/balloon3.h
+++ b/arch/arm/mach-pxa/include/mach/balloon3.h
@@ -174,6 +174,8 @@ enum balloon3_features {
174#define BALLOON3_CODEC_IRQ IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ) 174#define BALLOON3_CODEC_IRQ IRQ_GPIO(BALLOON3_GPIO_CODEC_IRQ)
175#define BALLOON3_S0_CD_IRQ IRQ_GPIO(BALLOON3_GPIO_S0_CD) 175#define BALLOON3_S0_CD_IRQ IRQ_GPIO(BALLOON3_GPIO_S0_CD)
176 176
177#define BALLOON3_NR_IRQS (IRQ_BOARD_START + 4)
178
177extern int balloon3_has(enum balloon3_features feature); 179extern int balloon3_has(enum balloon3_features feature);
178 180
179#endif 181#endif
diff --git a/arch/arm/mach-pxa/include/mach/debug-macro.S b/arch/arm/mach-pxa/include/mach/debug-macro.S
index 01cf81393fe2..7d5c75125d65 100644
--- a/arch/arm/mach-pxa/include/mach/debug-macro.S
+++ b/arch/arm/mach-pxa/include/mach/debug-macro.S
@@ -13,12 +13,10 @@
13 13
14#include "hardware.h" 14#include "hardware.h"
15 15
16 .macro addruart, rx, tmp 16 .macro addruart, rp, rv
17 mrc p15, 0, \rx, c1, c0 17 mov \rp, #0x00100000
18 tst \rx, #1 @ MMU enabled? 18 orr \rv, \rp, #io_p2v(0x40000000) @ virtual
19 moveq \rx, #0x40000000 @ physical 19 orr \rp, \rp, #0x40000000 @ physical
20 movne \rx, #io_p2v(0x40000000) @ virtual
21 orr \rx, \rx, #0x00100000
22 .endm 20 .endm
23 21
24#define UART_SHIFT 2 22#define UART_SHIFT 2
diff --git a/arch/arm/mach-pxa/include/mach/eseries-irq.h b/arch/arm/mach-pxa/include/mach/eseries-irq.h
index f2a93d5e31d3..de292b269c63 100644
--- a/arch/arm/mach-pxa/include/mach/eseries-irq.h
+++ b/arch/arm/mach-pxa/include/mach/eseries-irq.h
@@ -25,3 +25,4 @@
25#define TMIO_SD_IRQ IRQ_TMIO(1) 25#define TMIO_SD_IRQ IRQ_TMIO(1)
26#define TMIO_USB_IRQ IRQ_TMIO(2) 26#define TMIO_USB_IRQ IRQ_TMIO(2)
27 27
28#define ESERIES_NR_IRQS (IRQ_BOARD_START + 16)
diff --git a/arch/arm/mach-pxa/include/mach/hx4700.h b/arch/arm/mach-pxa/include/mach/hx4700.h
index 9eaeed1f87f1..37408449ec25 100644
--- a/arch/arm/mach-pxa/include/mach/hx4700.h
+++ b/arch/arm/mach-pxa/include/mach/hx4700.h
@@ -17,6 +17,7 @@
17 17
18#define HX4700_ASIC3_GPIO_BASE NR_BUILTIN_GPIO 18#define HX4700_ASIC3_GPIO_BASE NR_BUILTIN_GPIO
19#define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS) 19#define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS)
20#define HX4700_NR_IRQS (IRQ_BOARD_START + 70)
20 21
21/* 22/*
22 * PXA GPIOs 23 * PXA GPIOs
diff --git a/arch/arm/mach-pxa/include/mach/irqs.h b/arch/arm/mach-pxa/include/mach/irqs.h
index ffc8314520f2..d372caa75dc7 100644
--- a/arch/arm/mach-pxa/include/mach/irqs.h
+++ b/arch/arm/mach-pxa/include/mach/irqs.h
@@ -117,48 +117,12 @@
117/* 117/*
118 * The following interrupts are for board specific purposes. Since 118 * The following interrupts are for board specific purposes. Since
119 * the kernel can only run on one machine at a time, we can re-use 119 * the kernel can only run on one machine at a time, we can re-use
120 * these. There will be 16 IRQs by default. If it is not enough, 120 * these.
121 * IRQ_BOARD_END is allowed be customized for each board, but keep 121 * By default, no board IRQ is reserved. It should be finished in
122 * the numbers within sensible limits and in descending order, so 122 * custom board since sparse IRQ is already enabled.
123 * when multiple config options are selected, the maximum will be
124 * used.
125 */ 123 */
126#define IRQ_BOARD_START (PXA_GPIO_IRQ_BASE + PXA_GPIO_IRQ_NUM) 124#define IRQ_BOARD_START (PXA_GPIO_IRQ_BASE + PXA_GPIO_IRQ_NUM)
127 125
128#if defined(CONFIG_MACH_H4700)
129#define IRQ_BOARD_END (IRQ_BOARD_START + 70)
130#elif defined(CONFIG_MACH_ZYLONITE)
131#define IRQ_BOARD_END (IRQ_BOARD_START + 32)
132#elif defined(CONFIG_PXA_EZX)
133#define IRQ_BOARD_END (IRQ_BOARD_START + 23)
134#else
135#define IRQ_BOARD_END (IRQ_BOARD_START + 16)
136#endif
137
138/*
139 * Figure out the MAX IRQ number.
140 *
141 * If we have an SA1111, the max IRQ is S1_BVD1_STSCHG+1.
142 * If we have an LoCoMo, the max IRQ is IRQ_LOCOMO_SPI_TEND+1
143 * Otherwise, we have the standard IRQs only.
144 */
145#ifdef CONFIG_SA1111
146#define NR_IRQS (IRQ_BOARD_END + 55)
147#elif defined(CONFIG_PXA_HAVE_BOARD_IRQS)
148#define NR_IRQS (IRQ_BOARD_END)
149#else
150#define NR_IRQS (IRQ_BOARD_START) 126#define NR_IRQS (IRQ_BOARD_START)
151#endif
152
153/* add IT8152 IRQs beyond BOARD_END */
154#ifdef CONFIG_PCI_HOST_ITE8152
155#define IT8152_LAST_IRQ (IRQ_BOARD_END + 40)
156
157#if NR_IRQS < (IT8152_LAST_IRQ+1)
158#undef NR_IRQS
159#define NR_IRQS (IT8152_LAST_IRQ+1)
160#endif
161
162#endif /* CONFIG_PCI_HOST_ITE8152 */
163 127
164#endif /* __ASM_MACH_IRQS_H */ 128#endif /* __ASM_MACH_IRQS_H */
diff --git a/arch/arm/mach-pxa/include/mach/littleton.h b/arch/arm/mach-pxa/include/mach/littleton.h
index 6c9b21c51322..2a5726c15e0e 100644
--- a/arch/arm/mach-pxa/include/mach/littleton.h
+++ b/arch/arm/mach-pxa/include/mach/littleton.h
@@ -10,4 +10,6 @@
10#define EXT0_GPIO_BASE (NR_BUILTIN_GPIO) 10#define EXT0_GPIO_BASE (NR_BUILTIN_GPIO)
11#define EXT0_GPIO(x) (EXT0_GPIO_BASE + (x)) 11#define EXT0_GPIO(x) (EXT0_GPIO_BASE + (x))
12 12
13#define LITTLETON_NR_IRQS (IRQ_BOARD_START + 8)
14
13#endif /* __ASM_ARCH_LITTLETON_H */ 15#endif /* __ASM_ARCH_LITTLETON_H */
diff --git a/arch/arm/mach-pxa/include/mach/lpd270.h b/arch/arm/mach-pxa/include/mach/lpd270.h
index 0e6440c81683..cd070092b6eb 100644
--- a/arch/arm/mach-pxa/include/mach/lpd270.h
+++ b/arch/arm/mach-pxa/include/mach/lpd270.h
@@ -38,5 +38,6 @@
38#define LPD270_USBC_IRQ LPD270_IRQ(2) 38#define LPD270_USBC_IRQ LPD270_IRQ(2)
39#define LPD270_ETHERNET_IRQ LPD270_IRQ(3) 39#define LPD270_ETHERNET_IRQ LPD270_IRQ(3)
40#define LPD270_AC97_IRQ LPD270_IRQ(4) 40#define LPD270_AC97_IRQ LPD270_IRQ(4)
41#define LPD270_NR_IRQS (IRQ_BOARD_START + 5)
41 42
42#endif 43#endif
diff --git a/arch/arm/mach-pxa/include/mach/lubbock.h b/arch/arm/mach-pxa/include/mach/lubbock.h
index a0d4247f08fc..2a086e8373eb 100644
--- a/arch/arm/mach-pxa/include/mach/lubbock.h
+++ b/arch/arm/mach-pxa/include/mach/lubbock.h
@@ -45,6 +45,9 @@
45#define LUBBOCK_USB_DISC_IRQ LUBBOCK_IRQ(6) /* usb disconnect */ 45#define LUBBOCK_USB_DISC_IRQ LUBBOCK_IRQ(6) /* usb disconnect */
46#define LUBBOCK_LAST_IRQ LUBBOCK_IRQ(6) 46#define LUBBOCK_LAST_IRQ LUBBOCK_IRQ(6)
47 47
48#define LUBBOCK_SA1111_IRQ_BASE (IRQ_BOARD_START + 16)
49#define LUBBOCK_NR_IRQS (IRQ_BOARD_START + 16 + 55)
50
48#ifndef __ASSEMBLY__ 51#ifndef __ASSEMBLY__
49extern void lubbock_set_misc_wr(unsigned int mask, unsigned int set); 52extern void lubbock_set_misc_wr(unsigned int mask, unsigned int set);
50#endif 53#endif
diff --git a/arch/arm/mach-pxa/include/mach/magician.h b/arch/arm/mach-pxa/include/mach/magician.h
index 20ef37d4a9a7..0a2efcf7947c 100644
--- a/arch/arm/mach-pxa/include/mach/magician.h
+++ b/arch/arm/mach-pxa/include/mach/magician.h
@@ -71,6 +71,8 @@
71#define IRQ_MAGICIAN_BT (IRQ_BOARD_START + 2) 71#define IRQ_MAGICIAN_BT (IRQ_BOARD_START + 2)
72#define IRQ_MAGICIAN_VBUS (IRQ_BOARD_START + 3) 72#define IRQ_MAGICIAN_VBUS (IRQ_BOARD_START + 3)
73 73
74#define MAGICIAN_NR_IRQS (IRQ_BOARD_START + 8)
75
74/* 76/*
75 * CPLD EGPIOs 77 * CPLD EGPIOs
76 */ 78 */
diff --git a/arch/arm/mach-pxa/include/mach/mainstone.h b/arch/arm/mach-pxa/include/mach/mainstone.h
index 86e623abd64d..4c2d11cd824d 100644
--- a/arch/arm/mach-pxa/include/mach/mainstone.h
+++ b/arch/arm/mach-pxa/include/mach/mainstone.h
@@ -134,4 +134,6 @@
134#define MAINSTONE_S1_STSCHG_IRQ MAINSTONE_IRQ(14) 134#define MAINSTONE_S1_STSCHG_IRQ MAINSTONE_IRQ(14)
135#define MAINSTONE_S1_IRQ MAINSTONE_IRQ(15) 135#define MAINSTONE_S1_IRQ MAINSTONE_IRQ(15)
136 136
137#define MAINSTONE_NR_IRQS (IRQ_BOARD_START + 16)
138
137#endif 139#endif
diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa930.h b/arch/arm/mach-pxa/include/mach/mfp-pxa930.h
index 0d119d3b9221..04f7c97044f3 100644
--- a/arch/arm/mach-pxa/include/mach/mfp-pxa930.h
+++ b/arch/arm/mach-pxa/include/mach/mfp-pxa930.h
@@ -69,6 +69,7 @@
69#define nBE0_GPIO_60 MFP_CFG(nBE0, AF0) 69#define nBE0_GPIO_60 MFP_CFG(nBE0, AF0)
70#define nBE1_GPIO_61 MFP_CFG(nBE1, AF0) 70#define nBE1_GPIO_61 MFP_CFG(nBE1, AF0)
71#define RDY_GPIO_62 MFP_CFG(RDY, AF0) 71#define RDY_GPIO_62 MFP_CFG(RDY, AF0)
72#define PMIC_INT_GPIO83 MFP_CFG_LPM(PMIC_INT, AF0, PULL_HIGH)
72 73
73/* Chip Select */ 74/* Chip Select */
74#define DF_nCS0_nCS2 MFP_CFG_LPM(DF_nCS0, AF3, PULL_HIGH) 75#define DF_nCS0_nCS2 MFP_CFG_LPM(DF_nCS0, AF3, PULL_HIGH)
@@ -92,6 +93,9 @@
92#define GPIO63_CI2C_SCL MFP_CFG_LPM(GPIO63, AF4, PULL_HIGH) 93#define GPIO63_CI2C_SCL MFP_CFG_LPM(GPIO63, AF4, PULL_HIGH)
93#define GPIO64_CI2C_SDA MFP_CFG_LPM(GPIO64, AF4, PULL_HIGH) 94#define GPIO64_CI2C_SDA MFP_CFG_LPM(GPIO64, AF4, PULL_HIGH)
94 95
96#define GPIO73_CI2C_SCL MFP_CFG_LPM(GPIO73, AF1, PULL_HIGH)
97#define GPIO74_CI2C_SDA MFP_CFG_LPM(GPIO74, AF1, PULL_HIGH)
98
95#define GPIO77_CI2C_SCL MFP_CFG_LPM(GPIO77, AF2, PULL_HIGH) 99#define GPIO77_CI2C_SCL MFP_CFG_LPM(GPIO77, AF2, PULL_HIGH)
96#define GPIO78_CI2C_SDA MFP_CFG_LPM(GPIO78, AF2, PULL_HIGH) 100#define GPIO78_CI2C_SDA MFP_CFG_LPM(GPIO78, AF2, PULL_HIGH)
97 101
@@ -345,6 +349,9 @@
345#define GPIO69_UART1_CTS MFP_CFG(GPIO69, AF2) 349#define GPIO69_UART1_CTS MFP_CFG(GPIO69, AF2)
346#define GPIO70_UART1_RTS MFP_CFG(GPIO70, AF2) 350#define GPIO70_UART1_RTS MFP_CFG(GPIO70, AF2)
347 351
352#define GPIO53_UART1_TXD MFP_CFG(GPIO53, AF2)
353#define GPIO54_UART1_RXD MFP_CFG(GPIO54, AF2)
354
348/* UART2 - BTUART */ 355/* UART2 - BTUART */
349#define GPIO91_UART2_RXD MFP_CFG(GPIO91, AF1) 356#define GPIO91_UART2_RXD MFP_CFG(GPIO91, AF1)
350#define GPIO92_UART2_TXD MFP_CFG(GPIO92, AF1) 357#define GPIO92_UART2_TXD MFP_CFG(GPIO92, AF1)
diff --git a/arch/arm/mach-pxa/include/mach/pcm027.h b/arch/arm/mach-pxa/include/mach/pcm027.h
index 04083263167e..4bac588478a8 100644
--- a/arch/arm/mach-pxa/include/mach/pcm027.h
+++ b/arch/arm/mach-pxa/include/mach/pcm027.h
@@ -30,6 +30,8 @@
30#define PCM027_MMCDET_IRQ PCM027_IRQ(2) 30#define PCM027_MMCDET_IRQ PCM027_IRQ(2)
31#define PCM027_PM_5V_IRQ PCM027_IRQ(3) 31#define PCM027_PM_5V_IRQ PCM027_IRQ(3)
32 32
33#define PCM027_NR_IRQS (IRQ_BOARD_START + 32)
34
33/* I2C RTC */ 35/* I2C RTC */
34#define PCM027_RTC_IRQ_GPIO 0 36#define PCM027_RTC_IRQ_GPIO 0
35#define PCM027_RTC_IRQ IRQ_GPIO(PCM027_RTC_IRQ_GPIO) 37#define PCM027_RTC_IRQ IRQ_GPIO(PCM027_RTC_IRQ_GPIO)
diff --git a/arch/arm/mach-pxa/include/mach/poodle.h b/arch/arm/mach-pxa/include/mach/poodle.h
index 0b3e6d051c64..83d1cfd00fc9 100644
--- a/arch/arm/mach-pxa/include/mach/poodle.h
+++ b/arch/arm/mach-pxa/include/mach/poodle.h
@@ -85,6 +85,8 @@
85#define POODLE_LOCOMO_GPIO_232VCC_ON LOCOMO_GPIO(12) 85#define POODLE_LOCOMO_GPIO_232VCC_ON LOCOMO_GPIO(12)
86#define POODLE_LOCOMO_GPIO_JK_B LOCOMO_GPIO(13) 86#define POODLE_LOCOMO_GPIO_JK_B LOCOMO_GPIO(13)
87 87
88#define POODLE_NR_IRQS (IRQ_BOARD_START + 4) /* 4 for LoCoMo */
89
88extern struct platform_device poodle_locomo_device; 90extern struct platform_device poodle_locomo_device;
89 91
90#endif /* __ASM_ARCH_POODLE_H */ 92#endif /* __ASM_ARCH_POODLE_H */
diff --git a/arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h b/arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
new file mode 100644
index 000000000000..9d82cb65ea56
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/pxa3xx-u2d.h
@@ -0,0 +1,35 @@
1/*
2 * PXA3xx U2D header
3 *
4 * Copyright (C) 2010 CompuLab Ltd.
5 *
6 * Igor Grinberg <grinberg@compulab.co.il>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef __PXA310_U2D__
13#define __PXA310_U2D__
14
15#include <linux/usb/ulpi.h>
16
17struct pxa3xx_u2d_platform_data {
18
19#define ULPI_SER_6PIN (1 << 0)
20#define ULPI_SER_3PIN (1 << 1)
21 unsigned int ulpi_mode;
22
23 int (*init)(struct device *);
24 void (*exit)(struct device *);
25};
26
27
28/* Start PXA3xx U2D host */
29int pxa3xx_u2d_start_hc(struct usb_bus *host);
30/* Stop PXA3xx U2D host */
31void pxa3xx_u2d_stop_hc(struct usb_bus *host);
32
33extern void pxa3xx_set_u2d_info(struct pxa3xx_u2d_platform_data *info);
34
35#endif /* __PXA310_U2D__ */
diff --git a/arch/arm/mach-pxa/include/mach/tosa.h b/arch/arm/mach-pxa/include/mach/tosa.h
index 1bbd1f2e4beb..1272c4b56ceb 100644
--- a/arch/arm/mach-pxa/include/mach/tosa.h
+++ b/arch/arm/mach-pxa/include/mach/tosa.h
@@ -20,6 +20,7 @@
20/* Jacket Scoop */ 20/* Jacket Scoop */
21#define TOSA_SCOOP_PHYS (PXA_CS5_PHYS + 0x00800000) 21#define TOSA_SCOOP_PHYS (PXA_CS5_PHYS + 0x00800000)
22 22
23#define TOSA_NR_IRQS (IRQ_BOARD_START + TC6393XB_NR_IRQS)
23/* 24/*
24 * SCOOP2 internal GPIOs 25 * SCOOP2 internal GPIOs
25 */ 26 */
diff --git a/arch/arm/mach-pxa/include/mach/zeus.h b/arch/arm/mach-pxa/include/mach/zeus.h
index 6e119976003e..faa408ab7ad7 100644
--- a/arch/arm/mach-pxa/include/mach/zeus.h
+++ b/arch/arm/mach-pxa/include/mach/zeus.h
@@ -15,6 +15,8 @@
15#ifndef _MACH_ZEUS_H 15#ifndef _MACH_ZEUS_H
16#define _MACH_ZEUS_H 16#define _MACH_ZEUS_H
17 17
18#define ZEUS_NR_IRQS (IRQ_BOARD_START + 48)
19
18/* Physical addresses */ 20/* Physical addresses */
19#define ZEUS_FLASH_PHYS PXA_CS0_PHYS 21#define ZEUS_FLASH_PHYS PXA_CS0_PHYS
20#define ZEUS_ETH0_PHYS PXA_CS1_PHYS 22#define ZEUS_ETH0_PHYS PXA_CS1_PHYS
diff --git a/arch/arm/mach-pxa/include/mach/zylonite.h b/arch/arm/mach-pxa/include/mach/zylonite.h
index 9edf645368d6..ea24998b923c 100644
--- a/arch/arm/mach-pxa/include/mach/zylonite.h
+++ b/arch/arm/mach-pxa/include/mach/zylonite.h
@@ -5,6 +5,8 @@
5 5
6#define EXT_GPIO(x) (128 + (x)) 6#define EXT_GPIO(x) (128 + (x))
7 7
8#define ZYLONITE_NR_IRQS (IRQ_BOARD_START + 32)
9
8/* the following variables are processor specific and initialized 10/* the following variables are processor specific and initialized
9 * by the corresponding zylonite_pxa3xx_init() 11 * by the corresponding zylonite_pxa3xx_init()
10 */ 12 */
diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
index 9b9046185b00..41aa89e35772 100644
--- a/arch/arm/mach-pxa/littleton.c
+++ b/arch/arm/mach-pxa/littleton.c
@@ -43,7 +43,7 @@
43#include <mach/pxafb.h> 43#include <mach/pxafb.h>
44#include <mach/mmc.h> 44#include <mach/mmc.h>
45#include <mach/pxa2xx_spi.h> 45#include <mach/pxa2xx_spi.h>
46#include <mach/pxa27x_keypad.h> 46#include <plat/pxa27x_keypad.h>
47#include <mach/littleton.h> 47#include <mach/littleton.h>
48#include <plat/i2c.h> 48#include <plat/i2c.h>
49#include <plat/pxa3xx_nand.h> 49#include <plat/pxa3xx_nand.h>
@@ -437,10 +437,9 @@ static void __init littleton_init(void)
437} 437}
438 438
439MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)") 439MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
440 .phys_io = 0x40000000,
441 .boot_params = 0xa0000100, 440 .boot_params = 0xa0000100,
442 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
443 .map_io = pxa_map_io, 441 .map_io = pxa_map_io,
442 .nr_irqs = LITTLETON_NR_IRQS,
444 .init_irq = pxa3xx_init_irq, 443 .init_irq = pxa3xx_init_irq,
445 .timer = &pxa_timer, 444 .timer = &pxa_timer,
446 .init_machine = littleton_init, 445 .init_machine = littleton_init,
diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c
index d279507fc748..623af0232a54 100644
--- a/arch/arm/mach-pxa/lpd270.c
+++ b/arch/arm/mach-pxa/lpd270.c
@@ -505,10 +505,9 @@ static void __init lpd270_map_io(void)
505 505
506MACHINE_START(LOGICPD_PXA270, "LogicPD PXA270 Card Engine") 506MACHINE_START(LOGICPD_PXA270, "LogicPD PXA270 Card Engine")
507 /* Maintainer: Peter Barada */ 507 /* Maintainer: Peter Barada */
508 .phys_io = 0x40000000,
509 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
510 .boot_params = 0xa0000100, 508 .boot_params = 0xa0000100,
511 .map_io = lpd270_map_io, 509 .map_io = lpd270_map_io,
510 .nr_irqs = LPD270_NR_IRQS,
512 .init_irq = lpd270_init_irq, 511 .init_irq = lpd270_init_irq,
513 .timer = &pxa_timer, 512 .timer = &pxa_timer,
514 .init_machine = lpd270_init, 513 .init_machine = lpd270_init,
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 330c3282856e..1499493cd070 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -229,7 +229,7 @@ static struct resource sa1111_resources[] = {
229}; 229};
230 230
231static struct sa1111_platform_data sa1111_info = { 231static struct sa1111_platform_data sa1111_info = {
232 .irq_base = IRQ_BOARD_END, 232 .irq_base = LUBBOCK_SA1111_IRQ_BASE,
233}; 233};
234 234
235static struct platform_device sa1111_device = { 235static struct platform_device sa1111_device = {
@@ -557,9 +557,8 @@ static void __init lubbock_map_io(void)
557 557
558MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)") 558MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
559 /* Maintainer: MontaVista Software Inc. */ 559 /* Maintainer: MontaVista Software Inc. */
560 .phys_io = 0x40000000,
561 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
562 .map_io = lubbock_map_io, 560 .map_io = lubbock_map_io,
561 .nr_irqs = LUBBOCK_NR_IRQS,
563 .init_irq = lubbock_init_irq, 562 .init_irq = lubbock_init_irq,
564 .timer = &pxa_timer, 563 .timer = &pxa_timer,
565 .init_machine = lubbock_init, 564 .init_machine = lubbock_init,
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index e81dd0c8e40d..90663760307a 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -764,10 +764,9 @@ static void __init magician_init(void)
764 764
765 765
766MACHINE_START(MAGICIAN, "HTC Magician") 766MACHINE_START(MAGICIAN, "HTC Magician")
767 .phys_io = 0x40000000,
768 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
769 .boot_params = 0xa0000100, 767 .boot_params = 0xa0000100,
770 .map_io = pxa_map_io, 768 .map_io = pxa_map_io,
769 .nr_irqs = MAGICIAN_NR_IRQS,
771 .init_irq = pxa27x_init_irq, 770 .init_irq = pxa27x_init_irq,
772 .init_machine = magician_init, 771 .init_machine = magician_init,
773 .timer = &pxa_timer, 772 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 5543c64da9ef..a980a5c93e49 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -50,7 +50,7 @@
50#include <mach/mmc.h> 50#include <mach/mmc.h>
51#include <mach/irda.h> 51#include <mach/irda.h>
52#include <mach/ohci.h> 52#include <mach/ohci.h>
53#include <mach/pxa27x_keypad.h> 53#include <plat/pxa27x_keypad.h>
54 54
55#include "generic.h" 55#include "generic.h"
56#include "devices.h" 56#include "devices.h"
@@ -624,10 +624,9 @@ static void __init mainstone_map_io(void)
624 624
625MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)") 625MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
626 /* Maintainer: MontaVista Software Inc. */ 626 /* Maintainer: MontaVista Software Inc. */
627 .phys_io = 0x40000000,
628 .boot_params = 0xa0000100, /* BLOB boot parameter setting */ 627 .boot_params = 0xa0000100, /* BLOB boot parameter setting */
629 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
630 .map_io = mainstone_map_io, 628 .map_io = mainstone_map_io,
629 .nr_irqs = MAINSTONE_NR_IRQS,
631 .init_irq = mainstone_init_irq, 630 .init_irq = mainstone_init_irq,
632 .timer = &pxa_timer, 631 .timer = &pxa_timer,
633 .init_machine = mainstone_init, 632 .init_machine = mainstone_init,
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index dc66942ef9ab..0c31fabfc7fd 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -45,7 +45,7 @@
45 45
46#include <mach/pxa27x.h> 46#include <mach/pxa27x.h>
47#include <mach/regs-rtc.h> 47#include <mach/regs-rtc.h>
48#include <mach/pxa27x_keypad.h> 48#include <plat/pxa27x_keypad.h>
49#include <mach/pxafb.h> 49#include <mach/pxafb.h>
50#include <mach/mmc.h> 50#include <mach/mmc.h>
51#include <mach/udc.h> 51#include <mach/udc.h>
@@ -819,8 +819,6 @@ static void mioa701_machine_exit(void)
819} 819}
820 820
821MACHINE_START(MIOA701, "MIO A701") 821MACHINE_START(MIOA701, "MIO A701")
822 .phys_io = 0x40000000,
823 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
824 .boot_params = 0xa0000100, 822 .boot_params = 0xa0000100,
825 .map_io = &pxa_map_io, 823 .map_io = &pxa_map_io,
826 .init_irq = &pxa27x_init_irq, 824 .init_irq = &pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/mp900.c b/arch/arm/mach-pxa/mp900.c
index 6d4503927a76..116167aaba68 100644
--- a/arch/arm/mach-pxa/mp900.c
+++ b/arch/arm/mach-pxa/mp900.c
@@ -92,9 +92,7 @@ static void __init mp900c_init(void)
92 92
93/* Maintainer - Michael Petchkovsky <mkpetch@internode.on.net> */ 93/* Maintainer - Michael Petchkovsky <mkpetch@internode.on.net> */
94MACHINE_START(NEC_MP900, "MobilePro900/C") 94MACHINE_START(NEC_MP900, "MobilePro900/C")
95 .phys_io = 0x40000000,
96 .boot_params = 0xa0220100, 95 .boot_params = 0xa0220100,
97 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
98 .timer = &pxa_timer, 96 .timer = &pxa_timer,
99 .map_io = pxa_map_io, 97 .map_io = pxa_map_io,
100 .init_irq = pxa25x_init_irq, 98 .init_irq = pxa25x_init_irq,
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 91038eeafe44..ce092c521e6d 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -39,7 +39,7 @@
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/pxafb.h> 40#include <mach/pxafb.h>
41#include <mach/irda.h> 41#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h> 42#include <plat/pxa27x_keypad.h>
43#include <mach/palmasoc.h> 43#include <mach/palmasoc.h>
44#include <mach/palm27x.h> 44#include <mach/palm27x.h>
45 45
@@ -343,8 +343,6 @@ static void __init palmld_init(void)
343} 343}
344 344
345MACHINE_START(PALMLD, "Palm LifeDrive") 345MACHINE_START(PALMLD, "Palm LifeDrive")
346 .phys_io = PALMLD_PHYS_IO_START,
347 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
348 .boot_params = 0xa0000100, 346 .boot_params = 0xa0000100,
349 .map_io = palmld_map_io, 347 .map_io = palmld_map_io,
350 .init_irq = pxa27x_init_irq, 348 .init_irq = pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 1c281995f658..862da812cd10 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -39,7 +39,7 @@
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/pxafb.h> 40#include <mach/pxafb.h>
41#include <mach/irda.h> 41#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h> 42#include <plat/pxa27x_keypad.h>
43#include <mach/udc.h> 43#include <mach/udc.h>
44#include <mach/palmasoc.h> 44#include <mach/palmasoc.h>
45#include <mach/palm27x.h> 45#include <mach/palm27x.h>
@@ -202,8 +202,6 @@ static void __init palmt5_init(void)
202} 202}
203 203
204MACHINE_START(PALMT5, "Palm Tungsten|T5") 204MACHINE_START(PALMT5, "Palm Tungsten|T5")
205 .phys_io = PALMT5_PHYS_IO_START,
206 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
207 .boot_params = 0xa0000100, 205 .boot_params = 0xa0000100,
208 .map_io = pxa_map_io, 206 .map_io = pxa_map_io,
209 .reserve = palmt5_reserve, 207 .reserve = palmt5_reserve,
diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c
index ce1104d1bc17..2131d5860919 100644
--- a/arch/arm/mach-pxa/palmtc.c
+++ b/arch/arm/mach-pxa/palmtc.c
@@ -412,9 +412,7 @@ static void __init palmtc_init(void)
412}; 412};
413 413
414MACHINE_START(PALMTC, "Palm Tungsten|C") 414MACHINE_START(PALMTC, "Palm Tungsten|C")
415 .phys_io = 0x40000000,
416 .boot_params = 0xa0000100, 415 .boot_params = 0xa0000100,
417 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
418 .map_io = pxa_map_io, 416 .map_io = pxa_map_io,
419 .init_irq = pxa25x_init_irq, 417 .init_irq = pxa25x_init_irq,
420 .timer = &pxa_timer, 418 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 93c11a0438d5..a9dae7bc35d9 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -373,8 +373,6 @@ static void __init palmte2_init(void)
373} 373}
374 374
375MACHINE_START(PALMTE2, "Palm Tungsten|E2") 375MACHINE_START(PALMTE2, "Palm Tungsten|E2")
376 .phys_io = 0x40000000,
377 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
378 .boot_params = 0xa0000100, 376 .boot_params = 0xa0000100,
379 .map_io = pxa_map_io, 377 .map_io = pxa_map_io,
380 .init_irq = pxa25x_init_irq, 378 .init_irq = pxa25x_init_irq,
diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c
index 52defd5e42e5..00e2d7ba84ed 100644
--- a/arch/arm/mach-pxa/palmtreo.c
+++ b/arch/arm/mach-pxa/palmtreo.c
@@ -39,7 +39,7 @@
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/pxafb.h> 40#include <mach/pxafb.h>
41#include <mach/irda.h> 41#include <mach/irda.h>
42#include <mach/pxa27x_keypad.h> 42#include <plat/pxa27x_keypad.h>
43#include <mach/udc.h> 43#include <mach/udc.h>
44#include <mach/ohci.h> 44#include <mach/ohci.h>
45#include <mach/pxa2xx-regs.h> 45#include <mach/pxa2xx-regs.h>
@@ -441,8 +441,6 @@ static void __init centro_init(void)
441} 441}
442 442
443MACHINE_START(TREO680, "Palm Treo 680") 443MACHINE_START(TREO680, "Palm Treo 680")
444 .phys_io = TREO_PHYS_IO_START,
445 .io_pg_offst = io_p2v(0x40000000),
446 .boot_params = 0xa0000100, 444 .boot_params = 0xa0000100,
447 .map_io = pxa_map_io, 445 .map_io = pxa_map_io,
448 .reserve = treo_reserve, 446 .reserve = treo_reserve,
@@ -452,8 +450,6 @@ MACHINE_START(TREO680, "Palm Treo 680")
452MACHINE_END 450MACHINE_END
453 451
454MACHINE_START(CENTRO, "Palm Centro 685") 452MACHINE_START(CENTRO, "Palm Centro 685")
455 .phys_io = TREO_PHYS_IO_START,
456 .io_pg_offst = io_p2v(0x40000000),
457 .boot_params = 0xa0000100, 453 .boot_params = 0xa0000100,
458 .map_io = pxa_map_io, 454 .map_io = pxa_map_io,
459 .reserve = treo_reserve, 455 .reserve = treo_reserve,
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 144dc2b6911f..d2060a1d1d68 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -43,7 +43,7 @@
43#include <mach/mmc.h> 43#include <mach/mmc.h>
44#include <mach/pxafb.h> 44#include <mach/pxafb.h>
45#include <mach/irda.h> 45#include <mach/irda.h>
46#include <mach/pxa27x_keypad.h> 46#include <plat/pxa27x_keypad.h>
47#include <mach/udc.h> 47#include <mach/udc.h>
48#include <mach/palmasoc.h> 48#include <mach/palmasoc.h>
49#include <mach/palm27x.h> 49#include <mach/palm27x.h>
@@ -363,8 +363,6 @@ static void __init palmtx_init(void)
363} 363}
364 364
365MACHINE_START(PALMTX, "Palm T|X") 365MACHINE_START(PALMTX, "Palm T|X")
366 .phys_io = PALMTX_PHYS_IO_START,
367 .io_pg_offst = io_p2v(0x40000000),
368 .boot_params = 0xa0000100, 366 .boot_params = 0xa0000100,
369 .map_io = palmtx_map_io, 367 .map_io = palmtx_map_io,
370 .init_irq = pxa27x_init_irq, 368 .init_irq = pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index 87e4b1044e0b..af6203fbca9c 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -41,7 +41,7 @@
41#include <mach/mmc.h> 41#include <mach/mmc.h>
42#include <mach/pxafb.h> 42#include <mach/pxafb.h>
43#include <mach/irda.h> 43#include <mach/irda.h>
44#include <mach/pxa27x_keypad.h> 44#include <plat/pxa27x_keypad.h>
45#include <mach/udc.h> 45#include <mach/udc.h>
46#include <mach/palmasoc.h> 46#include <mach/palmasoc.h>
47#include <mach/palm27x.h> 47#include <mach/palm27x.h>
@@ -279,8 +279,6 @@ static void __init palmz72_init(void)
279} 279}
280 280
281MACHINE_START(PALMZ72, "Palm Zire72") 281MACHINE_START(PALMZ72, "Palm Zire72")
282 .phys_io = 0x40000000,
283 .io_pg_offst = io_p2v(0x40000000),
284 .boot_params = 0xa0000100, 282 .boot_params = 0xa0000100,
285 .map_io = pxa_map_io, 283 .map_io = pxa_map_io,
286 .init_irq = pxa27x_init_irq, 284 .init_irq = pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/pcm027.c b/arch/arm/mach-pxa/pcm027.c
index 2190af066470..c77e8f30a439 100644
--- a/arch/arm/mach-pxa/pcm027.c
+++ b/arch/arm/mach-pxa/pcm027.c
@@ -259,9 +259,8 @@ static void __init pcm027_map_io(void)
259MACHINE_START(PCM027, "Phytec Messtechnik GmbH phyCORE-PXA270") 259MACHINE_START(PCM027, "Phytec Messtechnik GmbH phyCORE-PXA270")
260 /* Maintainer: Pengutronix */ 260 /* Maintainer: Pengutronix */
261 .boot_params = 0xa0000100, 261 .boot_params = 0xa0000100,
262 .phys_io = 0x40000000,
263 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
264 .map_io = pcm027_map_io, 262 .map_io = pcm027_map_io,
263 .nr_irqs = PCM027_NR_IRQS,
265 .init_irq = pxa27x_init_irq, 264 .init_irq = pxa27x_init_irq,
266 .timer = &pxa_timer, 265 .timer = &pxa_timer,
267 .init_machine = pcm027_init, 266 .init_machine = pcm027_init,
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 55e8fcde0141..93a191c889df 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -465,10 +465,9 @@ static void __init fixup_poodle(struct machine_desc *desc,
465} 465}
466 466
467MACHINE_START(POODLE, "SHARP Poodle") 467MACHINE_START(POODLE, "SHARP Poodle")
468 .phys_io = 0x40000000,
469 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
470 .fixup = fixup_poodle, 468 .fixup = fixup_poodle,
471 .map_io = pxa_map_io, 469 .map_io = pxa_map_io,
470 .nr_irqs = POODLE_NR_IRQS, /* 4 for LoCoMo */
472 .init_irq = pxa25x_init_irq, 471 .init_irq = pxa25x_init_irq,
473 .timer = &pxa_timer, 472 .timer = &pxa_timer,
474 .init_machine = poodle_init, 473 .init_machine = poodle_init,
diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c
new file mode 100644
index 000000000000..ce7168b233e2
--- /dev/null
+++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c
@@ -0,0 +1,400 @@
1/*
2 * linux/arch/arm/mach-pxa/pxa3xx-ulpi.c
3 *
4 * code specific to pxa3xx aka Monahans
5 *
6 * Copyright (C) 2010 CompuLab Ltd.
7 *
8 * 2010-13-07: Igor Grinberg <grinberg@compulab.co.il>
9 * initial version: pxa310 USB Host mode support
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19#include <linux/device.h>
20#include <linux/platform_device.h>
21#include <linux/err.h>
22#include <linux/io.h>
23#include <linux/delay.h>
24#include <linux/clk.h>
25#include <linux/usb.h>
26#include <linux/usb/otg.h>
27
28#include <mach/hardware.h>
29#include <mach/regs-u2d.h>
30#include <mach/pxa3xx-u2d.h>
31
32struct pxa3xx_u2d_ulpi {
33 struct clk *clk;
34 void __iomem *mmio_base;
35
36 struct otg_transceiver *otg;
37 unsigned int ulpi_mode;
38};
39
40static struct pxa3xx_u2d_ulpi *u2d;
41
42static inline u32 u2d_readl(u32 reg)
43{
44 return __raw_readl(u2d->mmio_base + reg);
45}
46
47static inline void u2d_writel(u32 reg, u32 val)
48{
49 __raw_writel(val, u2d->mmio_base + reg);
50}
51
52#if defined(CONFIG_PXA310_ULPI)
53enum u2d_ulpi_phy_mode {
54 SYNCH = 0,
55 CARKIT = (1 << 0),
56 SER_3PIN = (1 << 1),
57 SER_6PIN = (1 << 2),
58 LOWPOWER = (1 << 3),
59};
60
61static inline enum u2d_ulpi_phy_mode pxa310_ulpi_get_phymode(void)
62{
63 return (u2d_readl(U2DOTGUSR) >> 28) & 0xF;
64}
65
66static int pxa310_ulpi_poll(void)
67{
68 int timeout = 50000;
69
70 while (timeout--) {
71 if (!(u2d_readl(U2DOTGUCR) & U2DOTGUCR_RUN))
72 return 0;
73
74 cpu_relax();
75 }
76
77 pr_warning("%s: ULPI access timed out!\n", __func__);
78
79 return -ETIMEDOUT;
80}
81
82static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg)
83{
84 int err;
85
86 if (pxa310_ulpi_get_phymode() != SYNCH) {
87 pr_warning("%s: PHY is not in SYNCH mode!\n", __func__);
88 return -EBUSY;
89 }
90
91 u2d_writel(U2DOTGUCR, U2DOTGUCR_RUN | U2DOTGUCR_RNW | (reg << 16));
92 msleep(5);
93
94 err = pxa310_ulpi_poll();
95 if (err)
96 return err;
97
98 return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA;
99}
100
101static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg)
102{
103 if (pxa310_ulpi_get_phymode() != SYNCH) {
104 pr_warning("%s: PHY is not in SYNCH mode!\n", __func__);
105 return -EBUSY;
106 }
107
108 u2d_writel(U2DOTGUCR, U2DOTGUCR_RUN | (reg << 16) | (val << 8));
109 msleep(5);
110
111 return pxa310_ulpi_poll();
112}
113
114struct otg_io_access_ops pxa310_ulpi_access_ops = {
115 .read = pxa310_ulpi_read,
116 .write = pxa310_ulpi_write,
117};
118
119static void pxa310_otg_transceiver_rtsm(void)
120{
121 u32 u2dotgcr;
122
123 /* put PHY to sync mode */
124 u2dotgcr = u2d_readl(U2DOTGCR);
125 u2dotgcr |= U2DOTGCR_RTSM | U2DOTGCR_UTMID;
126 u2d_writel(U2DOTGCR, u2dotgcr);
127 msleep(10);
128
129 /* setup OTG sync mode */
130 u2dotgcr = u2d_readl(U2DOTGCR);
131 u2dotgcr |= U2DOTGCR_ULAF;
132 u2dotgcr &= ~(U2DOTGCR_SMAF | U2DOTGCR_CKAF);
133 u2d_writel(U2DOTGCR, u2dotgcr);
134}
135
136static int pxa310_start_otg_host_transcvr(struct usb_bus *host)
137{
138 int err;
139
140 pxa310_otg_transceiver_rtsm();
141
142 err = otg_init(u2d->otg);
143 if (err) {
144 pr_err("OTG transceiver init failed");
145 return err;
146 }
147
148 err = otg_set_vbus(u2d->otg, 1);
149 if (err) {
150 pr_err("OTG transceiver VBUS set failed");
151 return err;
152 }
153
154 err = otg_set_host(u2d->otg, host);
155 if (err)
156 pr_err("OTG transceiver Host mode set failed");
157
158 return err;
159}
160
161static int pxa310_start_otg_hc(struct usb_bus *host)
162{
163 u32 u2dotgcr;
164 int err;
165
166 /* disable USB device controller */
167 u2d_writel(U2DCR, u2d_readl(U2DCR) & ~U2DCR_UDE);
168 u2d_writel(U2DOTGCR, u2d_readl(U2DOTGCR) | U2DOTGCR_UTMID);
169 u2d_writel(U2DOTGICR, u2d_readl(U2DOTGICR) & ~0x37F7F);
170
171 err = pxa310_start_otg_host_transcvr(host);
172 if (err)
173 return err;
174
175 /* set xceiver mode */
176 if (u2d->ulpi_mode & ULPI_IC_6PIN_SERIAL)
177 u2d_writel(U2DP3CR, u2d_readl(U2DP3CR) & ~U2DP3CR_P2SS);
178 else if (u2d->ulpi_mode & ULPI_IC_3PIN_SERIAL)
179 u2d_writel(U2DP3CR, u2d_readl(U2DP3CR) | U2DP3CR_P2SS);
180
181 /* start OTG host controller */
182 u2dotgcr = u2d_readl(U2DOTGCR) | U2DOTGCR_SMAF;
183 u2d_writel(U2DOTGCR, u2dotgcr & ~(U2DOTGCR_ULAF | U2DOTGCR_CKAF));
184
185 return 0;
186}
187
188static void pxa310_stop_otg_hc(void)
189{
190 pxa310_otg_transceiver_rtsm();
191
192 otg_set_host(u2d->otg, NULL);
193 otg_set_vbus(u2d->otg, 0);
194 otg_shutdown(u2d->otg);
195}
196
197static void pxa310_u2d_setup_otg_hc(void)
198{
199 u32 u2dotgcr;
200
201 u2dotgcr = u2d_readl(U2DOTGCR);
202 u2dotgcr |= U2DOTGCR_ULAF | U2DOTGCR_UTMID;
203 u2dotgcr &= ~(U2DOTGCR_SMAF | U2DOTGCR_CKAF);
204 u2d_writel(U2DOTGCR, u2dotgcr);
205 msleep(5);
206 u2d_writel(U2DOTGCR, u2dotgcr | U2DOTGCR_ULE);
207 msleep(5);
208 u2d_writel(U2DOTGICR, u2d_readl(U2DOTGICR) & ~0x37F7F);
209}
210
211static int pxa310_otg_init(struct pxa3xx_u2d_platform_data *pdata)
212{
213 unsigned int ulpi_mode = ULPI_OTG_DRVVBUS;
214
215 if (pdata) {
216 if (pdata->ulpi_mode & ULPI_SER_6PIN)
217 ulpi_mode |= ULPI_IC_6PIN_SERIAL;
218 else if (pdata->ulpi_mode & ULPI_SER_3PIN)
219 ulpi_mode |= ULPI_IC_3PIN_SERIAL;
220 }
221
222 u2d->ulpi_mode = ulpi_mode;
223
224 u2d->otg = otg_ulpi_create(&pxa310_ulpi_access_ops, ulpi_mode);
225 if (!u2d->otg)
226 return -ENOMEM;
227
228 u2d->otg->io_priv = u2d->mmio_base;
229
230 return 0;
231}
232
233static void pxa310_otg_exit(void)
234{
235 kfree(u2d->otg);
236}
237#else
238static inline void pxa310_u2d_setup_otg_hc(void) {}
239static inline int pxa310_start_otg_hc(struct usb_bus *host)
240{
241 return 0;
242}
243static inline void pxa310_stop_otg_hc(void) {}
244static inline int pxa310_otg_init(struct pxa3xx_u2d_platform_data *pdata)
245{
246 return 0;
247}
248static inline void pxa310_otg_exit(void) {}
249#endif /* CONFIG_PXA310_ULPI */
250
251int pxa3xx_u2d_start_hc(struct usb_bus *host)
252{
253 int err = 0;
254
255 /* In case the PXA3xx ULPI isn't used, do nothing. */
256 if (!u2d)
257 return 0;
258
259 clk_enable(u2d->clk);
260
261 if (cpu_is_pxa310()) {
262 pxa310_u2d_setup_otg_hc();
263 err = pxa310_start_otg_hc(host);
264 }
265
266 return err;
267}
268
269void pxa3xx_u2d_stop_hc(struct usb_bus *host)
270{
271 /* In case the PXA3xx ULPI isn't used, do nothing. */
272 if (!u2d)
273 return;
274
275 if (cpu_is_pxa310())
276 pxa310_stop_otg_hc();
277
278 clk_disable(u2d->clk);
279}
280
281static int pxa3xx_u2d_probe(struct platform_device *pdev)
282{
283 struct pxa3xx_u2d_platform_data *pdata = pdev->dev.platform_data;
284 struct resource *r;
285 int err;
286
287 u2d = kzalloc(sizeof(struct pxa3xx_u2d_ulpi), GFP_KERNEL);
288 if (!u2d) {
289 dev_err(&pdev->dev, "failed to allocate memory\n");
290 return -ENOMEM;
291 }
292
293 u2d->clk = clk_get(&pdev->dev, NULL);
294 if (IS_ERR(u2d->clk)) {
295 dev_err(&pdev->dev, "failed to get u2d clock\n");
296 err = PTR_ERR(u2d->clk);
297 goto err_free_mem;
298 }
299
300 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
301 if (!r) {
302 dev_err(&pdev->dev, "no IO memory resource defined\n");
303 err = -ENODEV;
304 goto err_put_clk;
305 }
306
307 r = request_mem_region(r->start, resource_size(r), pdev->name);
308 if (!r) {
309 dev_err(&pdev->dev, "failed to request memory resource\n");
310 err = -EBUSY;
311 goto err_put_clk;
312 }
313
314 u2d->mmio_base = ioremap(r->start, resource_size(r));
315 if (!u2d->mmio_base) {
316 dev_err(&pdev->dev, "ioremap() failed\n");
317 err = -ENODEV;
318 goto err_free_res;
319 }
320
321 if (pdata->init) {
322 err = pdata->init(&pdev->dev);
323 if (err)
324 goto err_free_io;
325 }
326
327 /* Only PXA310 U2D has OTG functionality */
328 if (cpu_is_pxa310()) {
329 err = pxa310_otg_init(pdata);
330 if (err)
331 goto err_free_plat;
332 }
333
334 platform_set_drvdata(pdev, &u2d);
335
336 return 0;
337
338err_free_plat:
339 if (pdata->exit)
340 pdata->exit(&pdev->dev);
341err_free_io:
342 iounmap(u2d->mmio_base);
343err_free_res:
344 release_mem_region(r->start, resource_size(r));
345err_put_clk:
346 clk_put(u2d->clk);
347err_free_mem:
348 kfree(u2d);
349 return err;
350}
351
352static int pxa3xx_u2d_remove(struct platform_device *pdev)
353{
354 struct pxa3xx_u2d_platform_data *pdata = pdev->dev.platform_data;
355 struct resource *r;
356
357 if (cpu_is_pxa310()) {
358 pxa310_stop_otg_hc();
359 pxa310_otg_exit();
360 }
361
362 if (pdata->exit)
363 pdata->exit(&pdev->dev);
364
365 platform_set_drvdata(pdev, NULL);
366 iounmap(u2d->mmio_base);
367 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
368 release_mem_region(r->start, resource_size(r));
369
370 clk_put(u2d->clk);
371
372 kfree(u2d);
373
374 return 0;
375}
376
377static struct platform_driver pxa3xx_u2d_ulpi_driver = {
378 .driver = {
379 .name = "pxa3xx-u2d",
380 .owner = THIS_MODULE,
381 },
382 .probe = pxa3xx_u2d_probe,
383 .remove = pxa3xx_u2d_remove,
384};
385
386static int pxa3xx_u2d_ulpi_init(void)
387{
388 return platform_driver_register(&pxa3xx_u2d_ulpi_driver);
389}
390module_init(pxa3xx_u2d_ulpi_init);
391
392static void __exit pxa3xx_u2d_ulpi_exit(void)
393{
394 platform_driver_unregister(&pxa3xx_u2d_ulpi_driver);
395}
396module_exit(pxa3xx_u2d_ulpi_exit);
397
398MODULE_DESCRIPTION("PXA3xx U2D ULPI driver");
399MODULE_AUTHOR("Igor Grinberg");
400MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index fa0014847c71..c85c3a7abd31 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -98,23 +98,6 @@ unsigned int pxa3xx_get_clk_frequency_khz(int info)
98 return CLK / 1000; 98 return CLK / 1000;
99} 99}
100 100
101/*
102 * Return the current static memory controller clock frequency
103 * in units of 10kHz
104 */
105unsigned int pxa3xx_get_memclk_frequency_10khz(void)
106{
107 unsigned long acsr;
108 unsigned int smcfs, clk = 0;
109
110 acsr = ACSR;
111
112 smcfs = (acsr >> 23) & 0x7;
113 clk = (acsr & ACCR_D0CS) ? RO_CLK : smcfs_mult[smcfs] * BASE_CLK;
114
115 return (clk / 10000);
116}
117
118void pxa3xx_clear_reset_status(unsigned int mask) 101void pxa3xx_clear_reset_status(unsigned int mask)
119{ 102{
120 /* RESET_STATUS_* has a 1:1 mapping with ARSR */ 103 /* RESET_STATUS_* has a 1:1 mapping with ARSR */
@@ -265,7 +248,7 @@ static struct clk_lookup pxa3xx_clkregs[] = {
265 INIT_CLKREG(&clk_pxa3xx_i2c, "pxa2xx-i2c.0", NULL), 248 INIT_CLKREG(&clk_pxa3xx_i2c, "pxa2xx-i2c.0", NULL),
266 INIT_CLKREG(&clk_pxa3xx_udc, "pxa27x-udc", NULL), 249 INIT_CLKREG(&clk_pxa3xx_udc, "pxa27x-udc", NULL),
267 INIT_CLKREG(&clk_pxa3xx_usbh, "pxa27x-ohci", NULL), 250 INIT_CLKREG(&clk_pxa3xx_usbh, "pxa27x-ohci", NULL),
268 INIT_CLKREG(&clk_pxa3xx_u2d, NULL, "U2DCLK"), 251 INIT_CLKREG(&clk_pxa3xx_u2d, "pxa3xx-u2d", NULL),
269 INIT_CLKREG(&clk_pxa3xx_keypad, "pxa27x-keypad", NULL), 252 INIT_CLKREG(&clk_pxa3xx_keypad, "pxa27x-keypad", NULL),
270 INIT_CLKREG(&clk_pxa3xx_ssp1, "pxa27x-ssp.0", NULL), 253 INIT_CLKREG(&clk_pxa3xx_ssp1, "pxa27x-ssp.0", NULL),
271 INIT_CLKREG(&clk_pxa3xx_ssp2, "pxa27x-ssp.1", NULL), 254 INIT_CLKREG(&clk_pxa3xx_ssp2, "pxa27x-ssp.1", NULL),
diff --git a/arch/arm/mach-pxa/pxa930.c b/arch/arm/mach-pxa/pxa930.c
index 064292008288..7d29dd3af79d 100644
--- a/arch/arm/mach-pxa/pxa930.c
+++ b/arch/arm/mach-pxa/pxa930.c
@@ -192,7 +192,7 @@ static struct mfp_addr_map pxa935_mfp_addr_map[] __initdata = {
192 192
193static int __init pxa930_init(void) 193static int __init pxa930_init(void)
194{ 194{
195 if (cpu_is_pxa930() || cpu_is_pxa935()) { 195 if (cpu_is_pxa930() || cpu_is_pxa935() || cpu_is_pxa950()) {
196 mfp_init_base(io_p2v(MFPR_BASE)); 196 mfp_init_base(io_p2v(MFPR_BASE));
197 mfp_init_addr(pxa930_mfp_addr_map); 197 mfp_init_addr(pxa930_mfp_addr_map);
198 } 198 }
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 67e04f4e07c1..4121d03ea2c3 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -1083,8 +1083,6 @@ static void __init raumfeld_speaker_init(void)
1083 1083
1084#ifdef CONFIG_MACH_RAUMFELD_RC 1084#ifdef CONFIG_MACH_RAUMFELD_RC
1085MACHINE_START(RAUMFELD_RC, "Raumfeld Controller") 1085MACHINE_START(RAUMFELD_RC, "Raumfeld Controller")
1086 .phys_io = 0x40000000,
1087 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1088 .boot_params = RAUMFELD_SDRAM_BASE + 0x100, 1086 .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
1089 .init_machine = raumfeld_controller_init, 1087 .init_machine = raumfeld_controller_init,
1090 .map_io = pxa_map_io, 1088 .map_io = pxa_map_io,
@@ -1095,8 +1093,6 @@ MACHINE_END
1095 1093
1096#ifdef CONFIG_MACH_RAUMFELD_CONNECTOR 1094#ifdef CONFIG_MACH_RAUMFELD_CONNECTOR
1097MACHINE_START(RAUMFELD_CONNECTOR, "Raumfeld Connector") 1095MACHINE_START(RAUMFELD_CONNECTOR, "Raumfeld Connector")
1098 .phys_io = 0x40000000,
1099 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1100 .boot_params = RAUMFELD_SDRAM_BASE + 0x100, 1096 .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
1101 .init_machine = raumfeld_connector_init, 1097 .init_machine = raumfeld_connector_init,
1102 .map_io = pxa_map_io, 1098 .map_io = pxa_map_io,
@@ -1107,8 +1103,6 @@ MACHINE_END
1107 1103
1108#ifdef CONFIG_MACH_RAUMFELD_SPEAKER 1104#ifdef CONFIG_MACH_RAUMFELD_SPEAKER
1109MACHINE_START(RAUMFELD_SPEAKER, "Raumfeld Speaker") 1105MACHINE_START(RAUMFELD_SPEAKER, "Raumfeld Speaker")
1110 .phys_io = 0x40000000,
1111 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1112 .boot_params = RAUMFELD_SDRAM_BASE + 0x100, 1106 .boot_params = RAUMFELD_SDRAM_BASE + 0x100,
1113 .init_machine = raumfeld_speaker_init, 1107 .init_machine = raumfeld_speaker_init,
1114 .map_io = pxa_map_io, 1108 .map_io = pxa_map_io,
diff --git a/arch/arm/mach-pxa/saar.c b/arch/arm/mach-pxa/saar.c
index 115b6f234bdd..4b521e045d75 100644
--- a/arch/arm/mach-pxa/saar.c
+++ b/arch/arm/mach-pxa/saar.c
@@ -596,9 +596,7 @@ static void __init saar_init(void)
596 596
597MACHINE_START(SAAR, "PXA930 Handheld Platform (aka SAAR)") 597MACHINE_START(SAAR, "PXA930 Handheld Platform (aka SAAR)")
598 /* Maintainer: Eric Miao <eric.miao@marvell.com> */ 598 /* Maintainer: Eric Miao <eric.miao@marvell.com> */
599 .phys_io = 0x40000000,
600 .boot_params = 0xa0000100, 599 .boot_params = 0xa0000100,
601 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
602 .map_io = pxa_map_io, 600 .map_io = pxa_map_io,
603 .init_irq = pxa3xx_init_irq, 601 .init_irq = pxa3xx_init_irq,
604 .timer = &pxa_timer, 602 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 1cd99cb87bb1..f736119f1ebf 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -979,8 +979,6 @@ static void __init spitz_fixup(struct machine_desc *desc,
979 979
980#ifdef CONFIG_MACH_SPITZ 980#ifdef CONFIG_MACH_SPITZ
981MACHINE_START(SPITZ, "SHARP Spitz") 981MACHINE_START(SPITZ, "SHARP Spitz")
982 .phys_io = 0x40000000,
983 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
984 .fixup = spitz_fixup, 982 .fixup = spitz_fixup,
985 .map_io = pxa_map_io, 983 .map_io = pxa_map_io,
986 .init_irq = pxa27x_init_irq, 984 .init_irq = pxa27x_init_irq,
@@ -991,8 +989,6 @@ MACHINE_END
991 989
992#ifdef CONFIG_MACH_BORZOI 990#ifdef CONFIG_MACH_BORZOI
993MACHINE_START(BORZOI, "SHARP Borzoi") 991MACHINE_START(BORZOI, "SHARP Borzoi")
994 .phys_io = 0x40000000,
995 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
996 .fixup = spitz_fixup, 992 .fixup = spitz_fixup,
997 .map_io = pxa_map_io, 993 .map_io = pxa_map_io,
998 .init_irq = pxa27x_init_irq, 994 .init_irq = pxa27x_init_irq,
@@ -1003,8 +999,6 @@ MACHINE_END
1003 999
1004#ifdef CONFIG_MACH_AKITA 1000#ifdef CONFIG_MACH_AKITA
1005MACHINE_START(AKITA, "SHARP Akita") 1001MACHINE_START(AKITA, "SHARP Akita")
1006 .phys_io = 0x40000000,
1007 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1008 .fixup = spitz_fixup, 1002 .fixup = spitz_fixup,
1009 .map_io = pxa_map_io, 1003 .map_io = pxa_map_io,
1010 .init_irq = pxa27x_init_irq, 1004 .init_irq = pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index a654d1e6b38a..738adc1773fd 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -56,6 +56,8 @@
56#include "devices.h" 56#include "devices.h"
57#include "generic.h" 57#include "generic.h"
58 58
59#define STARGATE_NR_IRQS (IRQ_BOARD_START + 8)
60
59/* Bluetooth */ 61/* Bluetooth */
60#define SG2_BT_RESET 81 62#define SG2_BT_RESET 81
61 63
@@ -996,8 +998,6 @@ static void __init stargate2_init(void)
996 998
997#ifdef CONFIG_MACH_INTELMOTE2 999#ifdef CONFIG_MACH_INTELMOTE2
998MACHINE_START(INTELMOTE2, "IMOTE 2") 1000MACHINE_START(INTELMOTE2, "IMOTE 2")
999 .phys_io = 0x40000000,
1000 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1001 .map_io = pxa_map_io, 1001 .map_io = pxa_map_io,
1002 .init_irq = pxa27x_init_irq, 1002 .init_irq = pxa27x_init_irq,
1003 .timer = &pxa_timer, 1003 .timer = &pxa_timer,
@@ -1008,9 +1008,8 @@ MACHINE_END
1008 1008
1009#ifdef CONFIG_MACH_STARGATE2 1009#ifdef CONFIG_MACH_STARGATE2
1010MACHINE_START(STARGATE2, "Stargate 2") 1010MACHINE_START(STARGATE2, "Stargate 2")
1011 .phys_io = 0x40000000,
1012 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1013 .map_io = pxa_map_io, 1011 .map_io = pxa_map_io,
1012 .nr_irqs = STARGATE_NR_IRQS,
1014 .init_irq = pxa27x_init_irq, 1013 .init_irq = pxa27x_init_irq,
1015 .timer = &pxa_timer, 1014 .timer = &pxa_timer,
1016 .init_machine = stargate2_init, 1015 .init_machine = stargate2_init,
diff --git a/arch/arm/mach-pxa/tavorevb.c b/arch/arm/mach-pxa/tavorevb.c
index f02dcb5b4e97..2ea7545273ad 100644
--- a/arch/arm/mach-pxa/tavorevb.c
+++ b/arch/arm/mach-pxa/tavorevb.c
@@ -25,7 +25,7 @@
25 25
26#include <mach/pxa930.h> 26#include <mach/pxa930.h>
27#include <mach/pxafb.h> 27#include <mach/pxafb.h>
28#include <mach/pxa27x_keypad.h> 28#include <plat/pxa27x_keypad.h>
29 29
30#include "devices.h" 30#include "devices.h"
31#include "generic.h" 31#include "generic.h"
@@ -489,9 +489,7 @@ static void __init tavorevb_init(void)
489 489
490MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)") 490MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)")
491 /* Maintainer: Eric Miao <eric.miao@marvell.com> */ 491 /* Maintainer: Eric Miao <eric.miao@marvell.com> */
492 .phys_io = 0x40000000,
493 .boot_params = 0xa0000100, 492 .boot_params = 0xa0000100,
494 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
495 .map_io = pxa_map_io, 493 .map_io = pxa_map_io,
496 .init_irq = pxa3xx_init_irq, 494 .init_irq = pxa3xx_init_irq,
497 .timer = &pxa_timer, 495 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/tavorevb3.c b/arch/arm/mach-pxa/tavorevb3.c
new file mode 100644
index 000000000000..dc3011697bbf
--- /dev/null
+++ b/arch/arm/mach-pxa/tavorevb3.c
@@ -0,0 +1,135 @@
1/*
2 * linux/arch/arm/mach-pxa/tavorevb3.c
3 *
4 * Support for the Marvell EVB3 Development Platform.
5 *
6 * Copyright: (C) Copyright 2008-2010 Marvell International Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * publishhed by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/interrupt.h>
17#include <linux/i2c.h>
18#include <linux/gpio.h>
19#include <linux/mfd/88pm860x.h>
20
21#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23
24#include <mach/pxa930.h>
25
26#include <plat/i2c.h>
27
28#include "devices.h"
29#include "generic.h"
30
31#define TAVOREVB3_NR_IRQS (IRQ_BOARD_START + 24)
32
33static mfp_cfg_t evb3_mfp_cfg[] __initdata = {
34 /* UART */
35 GPIO53_UART1_TXD,
36 GPIO54_UART1_RXD,
37
38 /* PMIC */
39 PMIC_INT_GPIO83,
40};
41
42#if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
43static struct pm860x_touch_pdata evb3_touch = {
44 .gpadc_prebias = 1,
45 .slot_cycle = 1,
46 .tsi_prebias = 6,
47 .pen_prebias = 16,
48 .pen_prechg = 2,
49 .res_x = 300,
50};
51
52static struct pm860x_backlight_pdata evb3_backlight[] = {
53 {
54 .id = PM8606_ID_BACKLIGHT,
55 .iset = PM8606_WLED_CURRENT(24),
56 .flags = PM8606_BACKLIGHT1,
57 },
58 {},
59};
60
61static struct pm860x_led_pdata evb3_led[] = {
62 {
63 .id = PM8606_ID_LED,
64 .iset = PM8606_LED_CURRENT(12),
65 .flags = PM8606_LED1_RED,
66 }, {
67 .id = PM8606_ID_LED,
68 .iset = PM8606_LED_CURRENT(12),
69 .flags = PM8606_LED1_GREEN,
70 }, {
71 .id = PM8606_ID_LED,
72 .iset = PM8606_LED_CURRENT(12),
73 .flags = PM8606_LED1_BLUE,
74 }, {
75 .id = PM8606_ID_LED,
76 .iset = PM8606_LED_CURRENT(12),
77 .flags = PM8606_LED2_RED,
78 }, {
79 .id = PM8606_ID_LED,
80 .iset = PM8606_LED_CURRENT(12),
81 .flags = PM8606_LED2_GREEN,
82 }, {
83 .id = PM8606_ID_LED,
84 .iset = PM8606_LED_CURRENT(12),
85 .flags = PM8606_LED2_BLUE,
86 },
87};
88
89static struct pm860x_platform_data evb3_pm8607_info = {
90 .touch = &evb3_touch,
91 .backlight = &evb3_backlight[0],
92 .led = &evb3_led[0],
93 .companion_addr = 0x10,
94 .irq_mode = 0,
95 .irq_base = IRQ_BOARD_START,
96
97 .i2c_port = GI2C_PORT,
98};
99
100static struct i2c_board_info evb3_i2c_info[] = {
101 {
102 .type = "88PM860x",
103 .addr = 0x34,
104 .platform_data = &evb3_pm8607_info,
105 .irq = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO83)),
106 },
107};
108
109static void __init evb3_init_i2c(void)
110{
111 pxa_set_i2c_info(NULL);
112 i2c_register_board_info(0, ARRAY_AND_SIZE(evb3_i2c_info));
113}
114#else
115static inline void evb3_init_i2c(void) {}
116#endif
117
118static void __init evb3_init(void)
119{
120 /* initialize MFP configurations */
121 pxa3xx_mfp_config(ARRAY_AND_SIZE(evb3_mfp_cfg));
122
123 pxa_set_ffuart_info(NULL);
124
125 evb3_init_i2c();
126}
127
128MACHINE_START(TAVOREVB3, "PXA950 Evaluation Board (aka TavorEVB3)")
129 .boot_params = 0xa0000100,
130 .map_io = pxa_map_io,
131 .nr_irqs = TAVOREVB3_NR_IRQS,
132 .init_irq = pxa3xx_init_irq,
133 .timer = &pxa_timer,
134 .init_machine = evb3_init,
135MACHINE_END
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 83cc3a18c2e9..0ee1df49606d 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -952,10 +952,9 @@ static void __init fixup_tosa(struct machine_desc *desc,
952} 952}
953 953
954MACHINE_START(TOSA, "SHARP Tosa") 954MACHINE_START(TOSA, "SHARP Tosa")
955 .phys_io = 0x40000000,
956 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
957 .fixup = fixup_tosa, 955 .fixup = fixup_tosa,
958 .map_io = pxa_map_io, 956 .map_io = pxa_map_io,
957 .nr_irqs = TOSA_NR_IRQS,
959 .init_irq = pxa25x_init_irq, 958 .init_irq = pxa25x_init_irq,
960 .init_machine = tosa_init, 959 .init_machine = tosa_init,
961 .timer = &pxa_timer, 960 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index 0acff172ef22..565d062f51d5 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -555,8 +555,6 @@ static void __init trizeps4_map_io(void)
555 555
556MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module") 556MACHINE_START(TRIZEPS4, "Keith und Koep Trizeps IV module")
557 /* MAINTAINER("Jürgen Schindele") */ 557 /* MAINTAINER("Jürgen Schindele") */
558 .phys_io = 0x40000000,
559 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
560 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100, 558 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
561 .init_machine = trizeps4_init, 559 .init_machine = trizeps4_init,
562 .map_io = trizeps4_map_io, 560 .map_io = trizeps4_map_io,
@@ -566,8 +564,6 @@ MACHINE_END
566 564
567MACHINE_START(TRIZEPS4WL, "Keith und Koep Trizeps IV-WL module") 565MACHINE_START(TRIZEPS4WL, "Keith und Koep Trizeps IV-WL module")
568 /* MAINTAINER("Jürgen Schindele") */ 566 /* MAINTAINER("Jürgen Schindele") */
569 .phys_io = 0x40000000,
570 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
571 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100, 567 .boot_params = TRIZEPS4_SDRAM_BASE + 0x100,
572 .init_machine = trizeps4_init, 568 .init_machine = trizeps4_init,
573 .map_io = trizeps4_map_io, 569 .map_io = trizeps4_map_io,
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index e90114a7e246..438fc9a5ed59 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -992,8 +992,6 @@ static void __init viper_map_io(void)
992 992
993MACHINE_START(VIPER, "Arcom/Eurotech VIPER SBC") 993MACHINE_START(VIPER, "Arcom/Eurotech VIPER SBC")
994 /* Maintainer: Marc Zyngier <maz@misterjones.org> */ 994 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
995 .phys_io = 0x40000000,
996 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
997 .boot_params = 0xa0000100, 995 .boot_params = 0xa0000100,
998 .map_io = viper_map_io, 996 .map_io = viper_map_io,
999 .init_irq = viper_init_irq, 997 .init_irq = viper_init_irq,
diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c
index 37d6173bbb66..f45ac0961778 100644
--- a/arch/arm/mach-pxa/vpac270.c
+++ b/arch/arm/mach-pxa/vpac270.c
@@ -718,8 +718,6 @@ static void __init vpac270_init(void)
718} 718}
719 719
720MACHINE_START(VPAC270, "Voipac PXA270") 720MACHINE_START(VPAC270, "Voipac PXA270")
721 .phys_io = 0x40000000,
722 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
723 .boot_params = 0xa0000100, 721 .boot_params = 0xa0000100,
724 .map_io = pxa_map_io, 722 .map_io = pxa_map_io,
725 .init_irq = pxa27x_init_irq, 723 .init_irq = pxa27x_init_irq,
diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c
index d3b4e3f2e033..3260ce73d327 100644
--- a/arch/arm/mach-pxa/xcep.c
+++ b/arch/arm/mach-pxa/xcep.c
@@ -181,8 +181,6 @@ static void __init xcep_init(void)
181} 181}
182 182
183MACHINE_START(XCEP, "Iskratel XCEP") 183MACHINE_START(XCEP, "Iskratel XCEP")
184 .phys_io = 0x40000000,
185 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
186 .boot_params = 0xa0000100, 184 .boot_params = 0xa0000100,
187 .init_machine = xcep_init, 185 .init_machine = xcep_init,
188 .map_io = pxa_map_io, 186 .map_io = pxa_map_io,
diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index f0d02288b4ca..fefde9848d82 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -37,7 +37,7 @@
37#include <mach/z2.h> 37#include <mach/z2.h>
38#include <mach/pxafb.h> 38#include <mach/pxafb.h>
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/pxa27x_keypad.h> 40#include <plat/pxa27x_keypad.h>
41#include <mach/pxa2xx_spi.h> 41#include <mach/pxa2xx_spi.h>
42 42
43#include <plat/i2c.h> 43#include <plat/i2c.h>
@@ -703,9 +703,7 @@ static void __init z2_init(void)
703} 703}
704 704
705MACHINE_START(ZIPIT2, "Zipit Z2") 705MACHINE_START(ZIPIT2, "Zipit Z2")
706 .phys_io = 0x40000000,
707 .boot_params = 0xa0000100, 706 .boot_params = 0xa0000100,
708 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
709 .map_io = pxa_map_io, 707 .map_io = pxa_map_io,
710 .init_irq = pxa27x_init_irq, 708 .init_irq = pxa27x_init_irq,
711 .timer = &pxa_timer, 709 .timer = &pxa_timer,
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index 03b9cb910e08..dea46a2d089b 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -900,10 +900,9 @@ static void __init zeus_map_io(void)
900 900
901MACHINE_START(ARCOM_ZEUS, "Arcom/Eurotech ZEUS") 901MACHINE_START(ARCOM_ZEUS, "Arcom/Eurotech ZEUS")
902 /* Maintainer: Marc Zyngier <maz@misterjones.org> */ 902 /* Maintainer: Marc Zyngier <maz@misterjones.org> */
903 .phys_io = 0x40000000,
904 .io_pg_offst = ((io_p2v(0x40000000) >> 18) & 0xfffc),
905 .boot_params = 0xa0000100, 903 .boot_params = 0xa0000100,
906 .map_io = zeus_map_io, 904 .map_io = zeus_map_io,
905 .nr_irqs = ZEUS_NR_IRQS,
907 .init_irq = zeus_init_irq, 906 .init_irq = zeus_init_irq,
908 .timer = &pxa_timer, 907 .timer = &pxa_timer,
909 .init_machine = zeus_init, 908 .init_machine = zeus_init,
diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index c479cbecf784..f25fb6245bd7 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -30,7 +30,7 @@
30#include <mach/zylonite.h> 30#include <mach/zylonite.h>
31#include <mach/mmc.h> 31#include <mach/mmc.h>
32#include <mach/ohci.h> 32#include <mach/ohci.h>
33#include <mach/pxa27x_keypad.h> 33#include <plat/pxa27x_keypad.h>
34#include <plat/pxa3xx_nand.h> 34#include <plat/pxa3xx_nand.h>
35 35
36#include "devices.h" 36#include "devices.h"
@@ -411,10 +411,9 @@ static void __init zylonite_init(void)
411} 411}
412 412
413MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)") 413MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
414 .phys_io = 0x40000000,
415 .boot_params = 0xa0000100, 414 .boot_params = 0xa0000100,
416 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
417 .map_io = pxa_map_io, 415 .map_io = pxa_map_io,
416 .nr_irqs = ZYLONITE_NR_IRQS,
418 .init_irq = pxa3xx_init_irq, 417 .init_irq = pxa3xx_init_irq,
419 .timer = &pxa_timer, 418 .timer = &pxa_timer,
420 .init_machine = zylonite_init, 419 .init_machine = zylonite_init,
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 2fa38df28414..07c08151dfe6 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -259,6 +259,7 @@ struct mmci_platform_data realview_mmc0_plat_data = {
259 .status = realview_mmc_status, 259 .status = realview_mmc_status,
260 .gpio_wp = 17, 260 .gpio_wp = 17,
261 .gpio_cd = 16, 261 .gpio_cd = 16,
262 .cd_invert = true,
262}; 263};
263 264
264struct mmci_platform_data realview_mmc1_plat_data = { 265struct mmci_platform_data realview_mmc1_plat_data = {
@@ -266,6 +267,7 @@ struct mmci_platform_data realview_mmc1_plat_data = {
266 .status = realview_mmc_status, 267 .status = realview_mmc_status,
267 .gpio_wp = 19, 268 .gpio_wp = 19,
268 .gpio_cd = 18, 269 .gpio_cd = 18,
270 .cd_invert = true,
269}; 271};
270 272
271/* 273/*
diff --git a/arch/arm/mach-realview/include/mach/debug-macro.S b/arch/arm/mach-realview/include/mach/debug-macro.S
index 86622289b74e..90b687cbe04e 100644
--- a/arch/arm/mach-realview/include/mach/debug-macro.S
+++ b/arch/arm/mach-realview/include/mach/debug-macro.S
@@ -33,12 +33,10 @@
33#error "Unknown RealView platform" 33#error "Unknown RealView platform"
34#endif 34#endif
35 35
36 .macro addruart, rx, tmp 36 .macro addruart, rp, rv
37 mrc p15, 0, \rx, c1, c0 37 mov \rp, #DEBUG_LL_UART_OFFSET
38 tst \rx, #1 @ MMU enabled? 38 orr \rv, \rp, #0xfb000000 @ virtual base
39 moveq \rx, #0x10000000 39 orr \rp, \rp, #0x10000000 @ physical base
40 movne \rx, #0xfb000000 @ virtual base
41 orr \rx, \rx, #DEBUG_LL_UART_OFFSET
42 .endm 40 .endm
43 41
44#include <asm/hardware/debug-pl01x.S> 42#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-realview/include/mach/smp.h b/arch/arm/mach-realview/include/mach/smp.h
index dd53892d44a7..d3cd265cb058 100644
--- a/arch/arm/mach-realview/include/mach/smp.h
+++ b/arch/arm/mach-realview/include/mach/smp.h
@@ -1,16 +1,8 @@
1#ifndef ASMARM_ARCH_SMP_H 1#ifndef ASMARM_ARCH_SMP_H
2#define ASMARM_ARCH_SMP_H 2#define ASMARM_ARCH_SMP_H
3 3
4
5#include <asm/hardware/gic.h> 4#include <asm/hardware/gic.h>
6 5#include <asm/smp_mpidr.h>
7#define hard_smp_processor_id() \
8 ({ \
9 unsigned int cpunum; \
10 __asm__("mrc p15, 0, %0, c0, c0, 5" \
11 : "=r" (cpunum)); \
12 cpunum &= 0x0F; \
13 })
14 6
15/* 7/*
16 * We use IRQ1 as the IPI 8 * We use IRQ1 as the IPI
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 991c1f8390e2..f2697106f809 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -486,8 +486,6 @@ static void __init realview_eb_init(void)
486 486
487MACHINE_START(REALVIEW_EB, "ARM-RealView EB") 487MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
488 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 488 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
489 .phys_io = REALVIEW_EB_UART0_BASE & SECTION_MASK,
490 .io_pg_offst = (IO_ADDRESS(REALVIEW_EB_UART0_BASE) >> 18) & 0xfffc,
491 .boot_params = PHYS_OFFSET + 0x00000100, 489 .boot_params = PHYS_OFFSET + 0x00000100,
492 .fixup = realview_fixup, 490 .fixup = realview_fixup,
493 .map_io = realview_eb_map_io, 491 .map_io = realview_eb_map_io,
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index d2be12eb829e..a4125619d71b 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -378,8 +378,6 @@ static void __init realview_pb1176_init(void)
378 378
379MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176") 379MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
380 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 380 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
381 .phys_io = REALVIEW_PB1176_UART0_BASE & SECTION_MASK,
382 .io_pg_offst = (IO_ADDRESS(REALVIEW_PB1176_UART0_BASE) >> 18) & 0xfffc,
383 .boot_params = PHYS_OFFSET + 0x00000100, 381 .boot_params = PHYS_OFFSET + 0x00000100,
384 .fixup = realview_pb1176_fixup, 382 .fixup = realview_pb1176_fixup,
385 .map_io = realview_pb1176_map_io, 383 .map_io = realview_pb1176_map_io,
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index d591bc00b86e..117b95b2ca15 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -381,8 +381,6 @@ static void __init realview_pb11mp_init(void)
381 381
382MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore") 382MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore")
383 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 383 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
384 .phys_io = REALVIEW_PB11MP_UART0_BASE & SECTION_MASK,
385 .io_pg_offst = (IO_ADDRESS(REALVIEW_PB11MP_UART0_BASE) >> 18) & 0xfffc,
386 .boot_params = PHYS_OFFSET + 0x00000100, 384 .boot_params = PHYS_OFFSET + 0x00000100,
387 .fixup = realview_fixup, 385 .fixup = realview_fixup,
388 .map_io = realview_pb11mp_map_io, 386 .map_io = realview_pb11mp_map_io,
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c
index 6c37621217bc..929b8dc12e81 100644
--- a/arch/arm/mach-realview/realview_pba8.c
+++ b/arch/arm/mach-realview/realview_pba8.c
@@ -331,8 +331,6 @@ static void __init realview_pba8_init(void)
331 331
332MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8") 332MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8")
333 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 333 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
334 .phys_io = REALVIEW_PBA8_UART0_BASE & SECTION_MASK,
335 .io_pg_offst = (IO_ADDRESS(REALVIEW_PBA8_UART0_BASE) >> 18) & 0xfffc,
336 .boot_params = PHYS_OFFSET + 0x00000100, 334 .boot_params = PHYS_OFFSET + 0x00000100,
337 .fixup = realview_fixup, 335 .fixup = realview_fixup,
338 .map_io = realview_pba8_map_io, 336 .map_io = realview_pba8_map_io,
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 9428eff0b116..b9f9e20031a7 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -417,8 +417,6 @@ static void __init realview_pbx_init(void)
417 417
418MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX") 418MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
419 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 419 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
420 .phys_io = REALVIEW_PBX_UART0_BASE & SECTION_MASK,
421 .io_pg_offst = (IO_ADDRESS(REALVIEW_PBX_UART0_BASE) >> 18) & 0xfffc,
422 .boot_params = PHYS_OFFSET + 0x00000100, 420 .boot_params = PHYS_OFFSET + 0x00000100,
423 .fixup = realview_pbx_fixup, 421 .fixup = realview_pbx_fixup,
424 .map_io = realview_pbx_map_io, 422 .map_io = realview_pbx_map_io,
diff --git a/arch/arm/mach-rpc/include/mach/debug-macro.S b/arch/arm/mach-rpc/include/mach/debug-macro.S
index 6fc8d66395dc..85effffdc2b2 100644
--- a/arch/arm/mach-rpc/include/mach/debug-macro.S
+++ b/arch/arm/mach-rpc/include/mach/debug-macro.S
@@ -11,13 +11,11 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x00010000
16 tst \rx, #1 @ MMU enabled? 16 orr \rp, \rp, #0x00000fe0
17 moveq \rx, #0x03000000 17 orr \rv, \rp, #0xe0000000 @ virtual
18 movne \rx, #0xe0000000 18 orr \rp, \rp, #0x03000000 @ physical
19 orr \rx, \rx, #0x00010000
20 orr \rx, \rx, #0x00000fe0
21 .endm 19 .endm
22 20
23#define UART_SHIFT 2 21#define UART_SHIFT 2
diff --git a/arch/arm/mach-rpc/include/mach/vmalloc.h b/arch/arm/mach-rpc/include/mach/vmalloc.h
index 9a96fd69e705..3bcd86fadb81 100644
--- a/arch/arm/mach-rpc/include/mach/vmalloc.h
+++ b/arch/arm/mach-rpc/include/mach/vmalloc.h
@@ -7,4 +7,4 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#define VMALLOC_END (PAGE_OFFSET + 0x1c000000) 10#define VMALLOC_END 0xdc000000
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index c7fc01e9d1f6..580b3c73d2c7 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -218,8 +218,6 @@ extern struct sys_timer ioc_timer;
218 218
219MACHINE_START(RISCPC, "Acorn-RiscPC") 219MACHINE_START(RISCPC, "Acorn-RiscPC")
220 /* Maintainer: Russell King */ 220 /* Maintainer: Russell King */
221 .phys_io = 0x03000000,
222 .io_pg_offst = ((0xe0000000) >> 18) & 0xfffc,
223 .boot_params = 0x10000100, 221 .boot_params = 0x10000100,
224 .reserve_lp0 = 1, 222 .reserve_lp0 = 1,
225 .reserve_lp1 = 1, 223 .reserve_lp1 = 1,
diff --git a/arch/arm/mach-s3c2410/include/mach/debug-macro.S b/arch/arm/mach-s3c2410/include/mach/debug-macro.S
index 0eef78b4a6ed..5882deaa56be 100644
--- a/arch/arm/mach-s3c2410/include/mach/debug-macro.S
+++ b/arch/arm/mach-s3c2410/include/mach/debug-macro.S
@@ -19,13 +19,12 @@
19#define S3C2410_UART1_OFF (0x4000) 19#define S3C2410_UART1_OFF (0x4000)
20#define SHIFT_2440TXF (14-9) 20#define SHIFT_2440TXF (14-9)
21 21
22 .macro addruart, rx, tmp 22 .macro addruart, rp, rv
23 mrc p15, 0, \rx, c1, c0 23 ldr \rp, = S3C24XX_PA_UART
24 tst \rx, #1 24 ldr \rv, = S3C24XX_VA_UART
25 ldreq \rx, = S3C24XX_PA_UART
26 ldrne \rx, = S3C24XX_VA_UART
27#if CONFIG_DEBUG_S3C_UART != 0 25#if CONFIG_DEBUG_S3C_UART != 0
28 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART) 26 add \rp, \rp, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
27 add \rv, \rv, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
29#endif 28#endif
30 .endm 29 .endm
31 30
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c2410/mach-amlm5900.c
index 34fc05a4244b..44440cbd7620 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c2410/mach-amlm5900.c
@@ -241,8 +241,6 @@ static void __init amlm5900_init(void)
241} 241}
242 242
243MACHINE_START(AML_M5900, "AML_M5900") 243MACHINE_START(AML_M5900, "AML_M5900")
244 .phys_io = S3C2410_PA_UART,
245 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
246 .boot_params = S3C2410_SDRAM_PA + 0x100, 244 .boot_params = S3C2410_SDRAM_PA + 0x100,
247 .map_io = amlm5900_map_io, 245 .map_io = amlm5900_map_io,
248 .init_irq = s3c24xx_init_irq, 246 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index c1f90f6fab42..2970ea9f7c2b 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -664,8 +664,6 @@ static void __init bast_init(void)
664 664
665MACHINE_START(BAST, "Simtec-BAST") 665MACHINE_START(BAST, "Simtec-BAST")
666 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ 666 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
667 .phys_io = S3C2410_PA_UART,
668 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
669 .boot_params = S3C2410_SDRAM_PA + 0x100, 667 .boot_params = S3C2410_SDRAM_PA + 0x100,
670 .map_io = bast_map_io, 668 .map_io = bast_map_io,
671 .init_irq = s3c24xx_init_irq, 669 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 3ba3bab139d0..98c5c9e81ee9 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -350,8 +350,6 @@ static void __init h1940_init(void)
350 350
351MACHINE_START(H1940, "IPAQ-H1940") 351MACHINE_START(H1940, "IPAQ-H1940")
352 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 352 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
353 .phys_io = S3C2410_PA_UART,
354 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
355 .boot_params = S3C2410_SDRAM_PA + 0x100, 353 .boot_params = S3C2410_SDRAM_PA + 0x100,
356 .map_io = h1940_map_io, 354 .map_io = h1940_map_io,
357 .reserve = h1940_reserve, 355 .reserve = h1940_reserve,
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 41f299d983eb..271b9aa6d40a 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -605,8 +605,6 @@ MACHINE_START(N30, "Acer-N30")
605 /* Maintainer: Christer Weinigel <christer@weinigel.se>, 605 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
606 Ben Dooks <ben-linux@fluff.org> 606 Ben Dooks <ben-linux@fluff.org>
607 */ 607 */
608 .phys_io = S3C2410_PA_UART,
609 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
610 .boot_params = S3C2410_SDRAM_PA + 0x100, 608 .boot_params = S3C2410_SDRAM_PA + 0x100,
611 .timer = &s3c24xx_timer, 609 .timer = &s3c24xx_timer,
612 .init_machine = n30_init, 610 .init_machine = n30_init,
@@ -617,8 +615,6 @@ MACHINE_END
617MACHINE_START(N35, "Acer-N35") 615MACHINE_START(N35, "Acer-N35")
618 /* Maintainer: Christer Weinigel <christer@weinigel.se> 616 /* Maintainer: Christer Weinigel <christer@weinigel.se>
619 */ 617 */
620 .phys_io = S3C2410_PA_UART,
621 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
622 .boot_params = S3C2410_SDRAM_PA + 0x100, 618 .boot_params = S3C2410_SDRAM_PA + 0x100,
623 .timer = &s3c24xx_timer, 619 .timer = &s3c24xx_timer,
624 .init_machine = n30_init, 620 .init_machine = n30_init,
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c
index d8c7f2efc1a7..0aa16cd5acbc 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c2410/mach-otom.c
@@ -116,8 +116,6 @@ static void __init otom11_init(void)
116 116
117MACHINE_START(OTOM, "Nex Vision - Otom 1.1") 117MACHINE_START(OTOM, "Nex Vision - Otom 1.1")
118 /* Maintainer: Guillaume GOURAT <guillaume.gourat@nexvision.tv> */ 118 /* Maintainer: Guillaume GOURAT <guillaume.gourat@nexvision.tv> */
119 .phys_io = S3C2410_PA_UART,
120 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
121 .boot_params = S3C2410_SDRAM_PA + 0x100, 119 .boot_params = S3C2410_SDRAM_PA + 0x100,
122 .map_io = otom11_map_io, 120 .map_io = otom11_map_io,
123 .init_machine = otom11_init, 121 .init_machine = otom11_init,
diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c2410/mach-qt2410.c
index d0e87b6e2e0f..e8f49feef28c 100644
--- a/arch/arm/mach-s3c2410/mach-qt2410.c
+++ b/arch/arm/mach-s3c2410/mach-qt2410.c
@@ -362,8 +362,6 @@ static void __init qt2410_machine_init(void)
362} 362}
363 363
364MACHINE_START(QT2410, "QT2410") 364MACHINE_START(QT2410, "QT2410")
365 .phys_io = S3C2410_PA_UART,
366 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
367 .boot_params = S3C2410_SDRAM_PA + 0x100, 365 .boot_params = S3C2410_SDRAM_PA + 0x100,
368 .map_io = qt2410_map_io, 366 .map_io = qt2410_map_io,
369 .init_irq = s3c24xx_init_irq, 367 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index 452223042201..e17f03387aba 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -111,8 +111,6 @@ static void __init smdk2410_init(void)
111MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch 111MACHINE_START(SMDK2410, "SMDK2410") /* @TODO: request a new identifier and switch
112 * to SMDK2410 */ 112 * to SMDK2410 */
113 /* Maintainer: Jonas Dietsche */ 113 /* Maintainer: Jonas Dietsche */
114 .phys_io = S3C2410_PA_UART,
115 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
116 .boot_params = S3C2410_SDRAM_PA + 0x100, 114 .boot_params = S3C2410_SDRAM_PA + 0x100,
117 .map_io = smdk2410_map_io, 115 .map_io = smdk2410_map_io,
118 .init_irq = s3c24xx_init_irq, 116 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2410/mach-tct_hammer.c b/arch/arm/mach-s3c2410/mach-tct_hammer.c
index 929164a8e9b1..a15d0621c22f 100644
--- a/arch/arm/mach-s3c2410/mach-tct_hammer.c
+++ b/arch/arm/mach-s3c2410/mach-tct_hammer.c
@@ -152,8 +152,6 @@ static void __init tct_hammer_init(void)
152} 152}
153 153
154MACHINE_START(TCT_HAMMER, "TCT_HAMMER") 154MACHINE_START(TCT_HAMMER, "TCT_HAMMER")
155 .phys_io = S3C2410_PA_UART,
156 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
157 .boot_params = S3C2410_SDRAM_PA + 0x100, 155 .boot_params = S3C2410_SDRAM_PA + 0x100,
158 .map_io = tct_hammer_map_io, 156 .map_io = tct_hammer_map_io,
159 .init_irq = s3c24xx_init_irq, 157 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index d540d79dd264..6ccce5a761b4 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -400,8 +400,6 @@ static void __init vr1000_init(void)
400 400
401MACHINE_START(VR1000, "Thorcom-VR1000") 401MACHINE_START(VR1000, "Thorcom-VR1000")
402 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ 402 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
403 .phys_io = S3C2410_PA_UART,
404 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
405 .boot_params = S3C2410_SDRAM_PA + 0x100, 403 .boot_params = S3C2410_SDRAM_PA + 0x100,
406 .map_io = vr1000_map_io, 404 .map_io = vr1000_map_io,
407 .init_machine = vr1000_init, 405 .init_machine = vr1000_init,
diff --git a/arch/arm/mach-s3c2412/mach-jive.c b/arch/arm/mach-s3c2412/mach-jive.c
index 478f4b4606c2..923e01bdf017 100644
--- a/arch/arm/mach-s3c2412/mach-jive.c
+++ b/arch/arm/mach-s3c2412/mach-jive.c
@@ -675,8 +675,6 @@ static void __init jive_machine_init(void)
675 675
676MACHINE_START(JIVE, "JIVE") 676MACHINE_START(JIVE, "JIVE")
677 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 677 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
678 .phys_io = S3C2410_PA_UART,
679 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
680 .boot_params = S3C2410_SDRAM_PA + 0x100, 678 .boot_params = S3C2410_SDRAM_PA + 0x100,
681 679
682 .init_irq = s3c24xx_init_irq, 680 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c
index 054c9f92232a..8e5758bdd666 100644
--- a/arch/arm/mach-s3c2412/mach-smdk2413.c
+++ b/arch/arm/mach-s3c2412/mach-smdk2413.c
@@ -150,8 +150,6 @@ static void __init smdk2413_machine_init(void)
150 150
151MACHINE_START(S3C2413, "S3C2413") 151MACHINE_START(S3C2413, "S3C2413")
152 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 152 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
153 .phys_io = S3C2410_PA_UART,
154 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
155 .boot_params = S3C2410_SDRAM_PA + 0x100, 153 .boot_params = S3C2410_SDRAM_PA + 0x100,
156 154
157 .fixup = smdk2413_fixup, 155 .fixup = smdk2413_fixup,
@@ -163,8 +161,6 @@ MACHINE_END
163 161
164MACHINE_START(SMDK2412, "SMDK2412") 162MACHINE_START(SMDK2412, "SMDK2412")
165 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 163 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
166 .phys_io = S3C2410_PA_UART,
167 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
168 .boot_params = S3C2410_SDRAM_PA + 0x100, 164 .boot_params = S3C2410_SDRAM_PA + 0x100,
169 165
170 .fixup = smdk2413_fixup, 166 .fixup = smdk2413_fixup,
@@ -176,8 +172,6 @@ MACHINE_END
176 172
177MACHINE_START(SMDK2413, "SMDK2413") 173MACHINE_START(SMDK2413, "SMDK2413")
178 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 174 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
179 .phys_io = S3C2410_PA_UART,
180 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
181 .boot_params = S3C2410_SDRAM_PA + 0x100, 175 .boot_params = S3C2410_SDRAM_PA + 0x100,
182 176
183 .fixup = smdk2413_fixup, 177 .fixup = smdk2413_fixup,
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c2412/mach-vstms.c
index f291ac25d312..83544ebe20ac 100644
--- a/arch/arm/mach-s3c2412/mach-vstms.c
+++ b/arch/arm/mach-s3c2412/mach-vstms.c
@@ -156,8 +156,6 @@ static void __init vstms_init(void)
156} 156}
157 157
158MACHINE_START(VSTMS, "VSTMS") 158MACHINE_START(VSTMS, "VSTMS")
159 .phys_io = S3C2410_PA_UART,
160 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
161 .boot_params = S3C2410_SDRAM_PA + 0x100, 159 .boot_params = S3C2410_SDRAM_PA + 0x100,
162 160
163 .fixup = vstms_fixup, 161 .fixup = vstms_fixup,
diff --git a/arch/arm/mach-s3c2416/mach-smdk2416.c b/arch/arm/mach-s3c2416/mach-smdk2416.c
index 5fc3f67ef265..7fc366476d7e 100644
--- a/arch/arm/mach-s3c2416/mach-smdk2416.c
+++ b/arch/arm/mach-s3c2416/mach-smdk2416.c
@@ -195,8 +195,6 @@ static void __init smdk2416_machine_init(void)
195 195
196MACHINE_START(SMDK2416, "SMDK2416") 196MACHINE_START(SMDK2416, "SMDK2416")
197 /* Maintainer: Yauhen Kharuzhy <jekhor@gmail.com> */ 197 /* Maintainer: Yauhen Kharuzhy <jekhor@gmail.com> */
198 .phys_io = S3C2410_PA_UART,
199 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
200 .boot_params = S3C2410_SDRAM_PA + 0x100, 198 .boot_params = S3C2410_SDRAM_PA + 0x100,
201 199
202 .init_irq = s3c24xx_init_irq, 200 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2440/mach-anubis.c b/arch/arm/mach-s3c2440/mach-anubis.c
index b73f78a9da5c..d7086788b1ff 100644
--- a/arch/arm/mach-s3c2440/mach-anubis.c
+++ b/arch/arm/mach-s3c2440/mach-anubis.c
@@ -498,8 +498,6 @@ static void __init anubis_init(void)
498 498
499MACHINE_START(ANUBIS, "Simtec-Anubis") 499MACHINE_START(ANUBIS, "Simtec-Anubis")
500 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ 500 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
501 .phys_io = S3C2410_PA_UART,
502 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
503 .boot_params = S3C2410_SDRAM_PA + 0x100, 501 .boot_params = S3C2410_SDRAM_PA + 0x100,
504 .map_io = anubis_map_io, 502 .map_io = anubis_map_io,
505 .init_machine = anubis_init, 503 .init_machine = anubis_init,
diff --git a/arch/arm/mach-s3c2440/mach-at2440evb.c b/arch/arm/mach-s3c2440/mach-at2440evb.c
index 84725791e6bf..6c98b789b8c6 100644
--- a/arch/arm/mach-s3c2440/mach-at2440evb.c
+++ b/arch/arm/mach-s3c2440/mach-at2440evb.c
@@ -5,7 +5,7 @@
5 * and modifications by SBZ <sbz@spgui.org> and 5 * and modifications by SBZ <sbz@spgui.org> and
6 * Weibing <http://weibing.blogbus.com> 6 * Weibing <http://weibing.blogbus.com>
7 * 7 *
8 * For product information, visit http://www.arm9e.com/ 8 * For product information, visit http://www.arm.com/
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of the GNU General Public License version 2 as
@@ -233,8 +233,6 @@ static void __init at2440evb_init(void)
233 233
234 234
235MACHINE_START(AT2440EVB, "AT2440EVB") 235MACHINE_START(AT2440EVB, "AT2440EVB")
236 .phys_io = S3C2410_PA_UART,
237 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
238 .boot_params = S3C2410_SDRAM_PA + 0x100, 236 .boot_params = S3C2410_SDRAM_PA + 0x100,
239 .map_io = at2440evb_map_io, 237 .map_io = at2440evb_map_io,
240 .init_machine = at2440evb_init, 238 .init_machine = at2440evb_init,
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index deaabe86741d..9f2c14ec7181 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -572,8 +572,6 @@ static void __init gta02_machine_init(void)
572 572
573MACHINE_START(NEO1973_GTA02, "GTA02") 573MACHINE_START(NEO1973_GTA02, "GTA02")
574 /* Maintainer: Nelson Castillo <arhuaco@freaks-unidos.net> */ 574 /* Maintainer: Nelson Castillo <arhuaco@freaks-unidos.net> */
575 .phys_io = S3C2410_PA_UART,
576 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
577 .boot_params = S3C2410_SDRAM_PA + 0x100, 575 .boot_params = S3C2410_SDRAM_PA + 0x100,
578 .map_io = gta02_map_io, 576 .map_io = gta02_map_io,
579 .init_irq = s3c24xx_init_irq, 577 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c2440/mach-mini2440.c
index a76bcda210ad..f62bb4c793bd 100644
--- a/arch/arm/mach-s3c2440/mach-mini2440.c
+++ b/arch/arm/mach-s3c2440/mach-mini2440.c
@@ -691,8 +691,6 @@ static void __init mini2440_init(void)
691 691
692MACHINE_START(MINI2440, "MINI2440") 692MACHINE_START(MINI2440, "MINI2440")
693 /* Maintainer: Michel Pollet <buserror@gmail.com> */ 693 /* Maintainer: Michel Pollet <buserror@gmail.com> */
694 .phys_io = S3C2410_PA_UART,
695 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
696 .boot_params = S3C2410_SDRAM_PA + 0x100, 694 .boot_params = S3C2410_SDRAM_PA + 0x100,
697 .map_io = mini2440_map_io, 695 .map_io = mini2440_map_io,
698 .init_machine = mini2440_init, 696 .init_machine = mini2440_init,
diff --git a/arch/arm/mach-s3c2440/mach-nexcoder.c b/arch/arm/mach-s3c2440/mach-nexcoder.c
index 3ff62de45fde..37dd306fb7dc 100644
--- a/arch/arm/mach-s3c2440/mach-nexcoder.c
+++ b/arch/arm/mach-s3c2440/mach-nexcoder.c
@@ -151,8 +151,6 @@ static void __init nexcoder_init(void)
151 151
152MACHINE_START(NEXCODER_2440, "NexVision - Nexcoder 2440") 152MACHINE_START(NEXCODER_2440, "NexVision - Nexcoder 2440")
153 /* Maintainer: Guillaume GOURAT <guillaume.gourat@nexvision.tv> */ 153 /* Maintainer: Guillaume GOURAT <guillaume.gourat@nexvision.tv> */
154 .phys_io = S3C2410_PA_UART,
155 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
156 .boot_params = S3C2410_SDRAM_PA + 0x100, 154 .boot_params = S3C2410_SDRAM_PA + 0x100,
157 .map_io = nexcoder_map_io, 155 .map_io = nexcoder_map_io,
158 .init_machine = nexcoder_init, 156 .init_machine = nexcoder_init,
diff --git a/arch/arm/mach-s3c2440/mach-osiris.c b/arch/arm/mach-s3c2440/mach-osiris.c
index 319458da71a0..14dc67897757 100644
--- a/arch/arm/mach-s3c2440/mach-osiris.c
+++ b/arch/arm/mach-s3c2440/mach-osiris.c
@@ -455,8 +455,6 @@ static void __init osiris_init(void)
455 455
456MACHINE_START(OSIRIS, "Simtec-OSIRIS") 456MACHINE_START(OSIRIS, "Simtec-OSIRIS")
457 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ 457 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
458 .phys_io = S3C2410_PA_UART,
459 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
460 .boot_params = S3C2410_SDRAM_PA + 0x100, 458 .boot_params = S3C2410_SDRAM_PA + 0x100,
461 .map_io = osiris_map_io, 459 .map_io = osiris_map_io,
462 .init_irq = s3c24xx_init_irq, 460 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 142d1f921176..32019bd9db3b 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -580,8 +580,6 @@ static void __init rx1950_reserve(void)
580 580
581MACHINE_START(RX1950, "HP iPAQ RX1950") 581MACHINE_START(RX1950, "HP iPAQ RX1950")
582 /* Maintainers: Vasily Khoruzhick */ 582 /* Maintainers: Vasily Khoruzhick */
583 .phys_io = S3C2410_PA_UART,
584 .io_pg_offst = (((u32) S3C24XX_VA_UART) >> 18) & 0xfffc,
585 .boot_params = S3C2410_SDRAM_PA + 0x100, 583 .boot_params = S3C2410_SDRAM_PA + 0x100,
586 .map_io = rx1950_map_io, 584 .map_io = rx1950_map_io,
587 .reserve = rx1950_reserve, 585 .reserve = rx1950_reserve,
diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c
index 6bb44f75a9ce..1472b1a5b2fb 100644
--- a/arch/arm/mach-s3c2440/mach-rx3715.c
+++ b/arch/arm/mach-s3c2440/mach-rx3715.c
@@ -218,8 +218,6 @@ static void __init rx3715_init_machine(void)
218 218
219MACHINE_START(RX3715, "IPAQ-RX3715") 219MACHINE_START(RX3715, "IPAQ-RX3715")
220 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 220 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
221 .phys_io = S3C2410_PA_UART,
222 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
223 .boot_params = S3C2410_SDRAM_PA + 0x100, 221 .boot_params = S3C2410_SDRAM_PA + 0x100,
224 .map_io = rx3715_map_io, 222 .map_io = rx3715_map_io,
225 .reserve = rx3715_reserve, 223 .reserve = rx3715_reserve,
diff --git a/arch/arm/mach-s3c2440/mach-smdk2440.c b/arch/arm/mach-s3c2440/mach-smdk2440.c
index df83276d85ae..eedfe0f11643 100644
--- a/arch/arm/mach-s3c2440/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2440/mach-smdk2440.c
@@ -175,8 +175,6 @@ static void __init smdk2440_machine_init(void)
175 175
176MACHINE_START(S3C2440, "SMDK2440") 176MACHINE_START(S3C2440, "SMDK2440")
177 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 177 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
178 .phys_io = S3C2410_PA_UART,
179 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
180 .boot_params = S3C2410_SDRAM_PA + 0x100, 178 .boot_params = S3C2410_SDRAM_PA + 0x100,
181 179
182 .init_irq = s3c24xx_init_irq, 180 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c2443/mach-smdk2443.c b/arch/arm/mach-s3c2443/mach-smdk2443.c
index 4c863d3a52f4..4337f0a9960d 100644
--- a/arch/arm/mach-s3c2443/mach-smdk2443.c
+++ b/arch/arm/mach-s3c2443/mach-smdk2443.c
@@ -132,8 +132,6 @@ static void __init smdk2443_machine_init(void)
132 132
133MACHINE_START(SMDK2443, "SMDK2443") 133MACHINE_START(SMDK2443, "SMDK2443")
134 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 134 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
135 .phys_io = S3C2410_PA_UART,
136 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
137 .boot_params = S3C2410_SDRAM_PA + 0x100, 135 .boot_params = S3C2410_SDRAM_PA + 0x100,
138 136
139 .init_irq = s3c24xx_init_irq, 137 .init_irq = s3c24xx_init_irq,
diff --git a/arch/arm/mach-s3c24a0/include/mach/debug-macro.S b/arch/arm/mach-s3c24a0/include/mach/debug-macro.S
index 239476b81f3b..0c5a73805560 100644
--- a/arch/arm/mach-s3c24a0/include/mach/debug-macro.S
+++ b/arch/arm/mach-s3c24a0/include/mach/debug-macro.S
@@ -10,13 +10,12 @@
10#include <mach/map.h> 10#include <mach/map.h>
11#include <plat/regs-serial.h> 11#include <plat/regs-serial.h>
12 12
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 mrc p15, 0, \rx, c1, c0 14 ldr \rp, = S3C24XX_PA_UART
15 tst \rx, #1 15 ldr \rv, = S3C24XX_VA_UART
16 ldreq \rx, = S3C24XX_PA_UART
17 ldrne \rx, = S3C24XX_VA_UART
18#if CONFIG_DEBUG_S3C_UART != 0 16#if CONFIG_DEBUG_S3C_UART != 0
19 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART) 17 add \rp, \rp, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
18 add \rv, \rv, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
20#endif 19#endif
21 .endm 20 .endm
22 21
diff --git a/arch/arm/mach-s3c64xx/include/mach/debug-macro.S b/arch/arm/mach-s3c64xx/include/mach/debug-macro.S
index f9ab5d26052a..a29e70550c70 100644
--- a/arch/arm/mach-s3c64xx/include/mach/debug-macro.S
+++ b/arch/arm/mach-s3c64xx/include/mach/debug-macro.S
@@ -21,13 +21,12 @@
21 * aligned and add in the offset when we load the value here. 21 * aligned and add in the offset when we load the value here.
22 */ 22 */
23 23
24 .macro addruart, rx, rtmp 24 .macro addruart, rp, rv
25 mrc p15, 0, \rx, c1, c0 25 ldr \rp, = S3C_PA_UART
26 tst \rx, #1 26 ldr \rv, = (S3C_VA_UART + S3C_PA_UART & 0xfffff)
27 ldreq \rx, = S3C_PA_UART
28 ldrne \rx, = (S3C_VA_UART + S3C_PA_UART & 0xfffff)
29#if CONFIG_DEBUG_S3C_UART != 0 27#if CONFIG_DEBUG_S3C_UART != 0
30 add \rx, \rx, #(0x400 * CONFIG_DEBUG_S3C_UART) 28 add \rp, \rp, #(0x400 * CONFIG_DEBUG_S3C_UART)
29 add \rv, \rv, #(0x400 * CONFIG_DEBUG_S3C_UART)
31#endif 30#endif
32 .endm 31 .endm
33 32
diff --git a/arch/arm/mach-s3c64xx/mach-anw6410.c b/arch/arm/mach-s3c64xx/mach-anw6410.c
index 742dc87bd9c1..a53cf149476e 100644
--- a/arch/arm/mach-s3c64xx/mach-anw6410.c
+++ b/arch/arm/mach-s3c64xx/mach-anw6410.c
@@ -233,8 +233,6 @@ static void __init anw6410_machine_init(void)
233 233
234MACHINE_START(ANW6410, "A&W6410") 234MACHINE_START(ANW6410, "A&W6410")
235 /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */ 235 /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */
236 .phys_io = S3C_PA_UART & 0xfff00000,
237 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
238 .boot_params = S3C64XX_PA_SDRAM + 0x100, 236 .boot_params = S3C64XX_PA_SDRAM + 0x100,
239 237
240 .init_irq = s3c6410_init_irq, 238 .init_irq = s3c6410_init_irq,
diff --git a/arch/arm/mach-s3c64xx/mach-hmt.c b/arch/arm/mach-s3c64xx/mach-hmt.c
index fba90229f0df..b2639582caca 100644
--- a/arch/arm/mach-s3c64xx/mach-hmt.c
+++ b/arch/arm/mach-s3c64xx/mach-hmt.c
@@ -265,8 +265,6 @@ static void __init hmt_machine_init(void)
265 265
266MACHINE_START(HMT, "Airgoo-HMT") 266MACHINE_START(HMT, "Airgoo-HMT")
267 /* Maintainer: Peter Korsgaard <jacmet@sunsite.dk> */ 267 /* Maintainer: Peter Korsgaard <jacmet@sunsite.dk> */
268 .phys_io = S3C_PA_UART & 0xfff00000,
269 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
270 .boot_params = S3C64XX_PA_SDRAM + 0x100, 268 .boot_params = S3C64XX_PA_SDRAM + 0x100,
271 .init_irq = s3c6410_init_irq, 269 .init_irq = s3c6410_init_irq,
272 .map_io = hmt_map_io, 270 .map_io = hmt_map_io,
diff --git a/arch/arm/mach-s3c64xx/mach-ncp.c b/arch/arm/mach-s3c64xx/mach-ncp.c
index bf65747ea68e..c4986498cd12 100644
--- a/arch/arm/mach-s3c64xx/mach-ncp.c
+++ b/arch/arm/mach-s3c64xx/mach-ncp.c
@@ -97,8 +97,6 @@ static void __init ncp_machine_init(void)
97 97
98MACHINE_START(NCP, "NCP") 98MACHINE_START(NCP, "NCP")
99 /* Maintainer: Samsung Electronics */ 99 /* Maintainer: Samsung Electronics */
100 .phys_io = S3C_PA_UART & 0xfff00000,
101 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
102 .boot_params = S3C64XX_PA_SDRAM + 0x100, 100 .boot_params = S3C64XX_PA_SDRAM + 0x100,
103 .init_irq = s3c6410_init_irq, 101 .init_irq = s3c6410_init_irq,
104 .map_io = ncp_map_io, 102 .map_io = ncp_map_io,
diff --git a/arch/arm/mach-s3c64xx/mach-real6410.c b/arch/arm/mach-s3c64xx/mach-real6410.c
index e130379ba0e8..4b4475da8ec6 100644
--- a/arch/arm/mach-s3c64xx/mach-real6410.c
+++ b/arch/arm/mach-s3c64xx/mach-real6410.c
@@ -141,8 +141,6 @@ static void __init real6410_machine_init(void)
141 141
142MACHINE_START(REAL6410, "REAL6410") 142MACHINE_START(REAL6410, "REAL6410")
143 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */ 143 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
144 .phys_io = S3C_PA_UART & 0xfff00000,
145 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
146 .boot_params = S3C64XX_PA_SDRAM + 0x100, 144 .boot_params = S3C64XX_PA_SDRAM + 0x100,
147 145
148 .init_irq = s3c6410_init_irq, 146 .init_irq = s3c6410_init_irq,
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c
index 3a9639bc3d9b..cb1ebeb08763 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -136,7 +136,7 @@ static struct platform_device smartq_usb_otg_vbus_dev = {
136 .dev.platform_data = &smartq_usb_otg_vbus_pdata, 136 .dev.platform_data = &smartq_usb_otg_vbus_pdata,
137}; 137};
138 138
139static int __init smartq_bl_init(struct device *dev) 139static int smartq_bl_init(struct device *dev)
140{ 140{
141 s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_SFN(2)); 141 s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_SFN(2));
142 142
diff --git a/arch/arm/mach-s3c64xx/mach-smartq5.c b/arch/arm/mach-s3c64xx/mach-smartq5.c
index a4d59b076e3d..3a3e5acde523 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq5.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq5.c
@@ -32,7 +32,7 @@
32 32
33#include "mach-smartq.h" 33#include "mach-smartq.h"
34 34
35static struct gpio_led smartq5_leds[] __initdata = { 35static struct gpio_led smartq5_leds[] = {
36 { 36 {
37 .name = "smartq5:green", 37 .name = "smartq5:green",
38 .active_low = 1, 38 .active_low = 1,
@@ -146,8 +146,6 @@ static void __init smartq5_machine_init(void)
146 146
147MACHINE_START(SMARTQ5, "SmartQ 5") 147MACHINE_START(SMARTQ5, "SmartQ 5")
148 /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */ 148 /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */
149 .phys_io = S3C_PA_UART & 0xfff00000,
150 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
151 .boot_params = S3C64XX_PA_SDRAM + 0x100, 149 .boot_params = S3C64XX_PA_SDRAM + 0x100,
152 .init_irq = s3c6410_init_irq, 150 .init_irq = s3c6410_init_irq,
153 .map_io = smartq_map_io, 151 .map_io = smartq_map_io,
diff --git a/arch/arm/mach-s3c64xx/mach-smartq7.c b/arch/arm/mach-s3c64xx/mach-smartq7.c
index e50a7d781732..e65375877d53 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq7.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq7.c
@@ -32,7 +32,7 @@
32 32
33#include "mach-smartq.h" 33#include "mach-smartq.h"
34 34
35static struct gpio_led smartq7_leds[] __initdata = { 35static struct gpio_led smartq7_leds[] = {
36 { 36 {
37 .name = "smartq7:red", 37 .name = "smartq7:red",
38 .active_low = 1, 38 .active_low = 1,
@@ -162,8 +162,6 @@ static void __init smartq7_machine_init(void)
162 162
163MACHINE_START(SMARTQ7, "SmartQ 7") 163MACHINE_START(SMARTQ7, "SmartQ 7")
164 /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */ 164 /* Maintainer: Maurus Cuelenaere <mcuelenaere AT gmail DOT com> */
165 .phys_io = S3C_PA_UART & 0xfff00000,
166 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
167 .boot_params = S3C64XX_PA_SDRAM + 0x100, 165 .boot_params = S3C64XX_PA_SDRAM + 0x100,
168 .init_irq = s3c6410_init_irq, 166 .init_irq = s3c6410_init_irq,
169 .map_io = smartq_map_io, 167 .map_io = smartq_map_io,
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6400.c b/arch/arm/mach-s3c64xx/mach-smdk6400.c
index 59916676d8d2..3cca642f1e6d 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6400.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6400.c
@@ -85,8 +85,6 @@ static void __init smdk6400_machine_init(void)
85 85
86MACHINE_START(SMDK6400, "SMDK6400") 86MACHINE_START(SMDK6400, "SMDK6400")
87 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 87 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
88 .phys_io = S3C_PA_UART & 0xfff00000,
89 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
90 .boot_params = S3C64XX_PA_SDRAM + 0x100, 88 .boot_params = S3C64XX_PA_SDRAM + 0x100,
91 89
92 .init_irq = s3c6400_init_irq, 90 .init_irq = s3c6400_init_irq,
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index d498219fff1b..ec8865c03a19 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -704,8 +704,6 @@ static void __init smdk6410_machine_init(void)
704 704
705MACHINE_START(SMDK6410, "SMDK6410") 705MACHINE_START(SMDK6410, "SMDK6410")
706 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ 706 /* Maintainer: Ben Dooks <ben-linux@fluff.org> */
707 .phys_io = S3C_PA_UART & 0xfff00000,
708 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
709 .boot_params = S3C64XX_PA_SDRAM + 0x100, 707 .boot_params = S3C64XX_PA_SDRAM + 0x100,
710 708
711 .init_irq = s3c6410_init_irq, 709 .init_irq = s3c6410_init_irq,
diff --git a/arch/arm/mach-s5p6440/Kconfig b/arch/arm/mach-s5p6440/Kconfig
deleted file mode 100644
index 6a4af7f57584..000000000000
--- a/arch/arm/mach-s5p6440/Kconfig
+++ /dev/null
@@ -1,33 +0,0 @@
1# arch/arm/mach-s5p6440/Kconfig
2#
3# Copyright (c) 2009 Samsung Electronics Co., Ltd.
4# http://www.samsung.com/
5#
6# Licensed under GPLv2
7
8if ARCH_S5P6440
9
10config CPU_S5P6440
11 bool
12 select S3C_PL330_DMA
13 help
14 Enable S5P6440 CPU support
15
16config S5P6440_SETUP_I2C1
17 bool
18 help
19 Common setup code for i2c bus 1.
20
21config MACH_SMDK6440
22 bool "SMDK6440"
23 select CPU_S5P6440
24 select S3C_DEV_I2C1
25 select S3C_DEV_RTC
26 select S3C_DEV_WDT
27 select SAMSUNG_DEV_ADC
28 select SAMSUNG_DEV_TS
29 select S5P6440_SETUP_I2C1
30 help
31 Machine support for the Samsung SMDK6440
32
33endif
diff --git a/arch/arm/mach-s5p6440/Makefile b/arch/arm/mach-s5p6440/Makefile
deleted file mode 100644
index c3fe4d3662a9..000000000000
--- a/arch/arm/mach-s5p6440/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
1# arch/arm/mach-s5p6440/Makefile
2#
3# Copyright (c) 2009 Samsung Electronics Co., Ltd.
4# http://www.samsung.com/
5#
6# Licensed under GPLv2
7
8obj-y :=
9obj-m :=
10obj-n :=
11obj- :=
12
13# Core support for S5P6440 system
14
15obj-$(CONFIG_CPU_S5P6440) += cpu.o init.o clock.o gpio.o dma.o
16obj-$(CONFIG_CPU_S5P6440) += setup-i2c0.o
17
18# machine support
19
20obj-$(CONFIG_MACH_SMDK6440) += mach-smdk6440.o
21
22# device support
23obj-y += dev-audio.o
24obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o
25obj-$(CONFIG_S5P6440_SETUP_I2C1) += setup-i2c1.o
diff --git a/arch/arm/mach-s5p6440/clock.c b/arch/arm/mach-s5p6440/clock.c
deleted file mode 100644
index ca6e48dce777..000000000000
--- a/arch/arm/mach-s5p6440/clock.c
+++ /dev/null
@@ -1,846 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/clock.c
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - Clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22
23#include <mach/hardware.h>
24#include <mach/map.h>
25
26#include <plat/cpu-freq.h>
27#include <mach/regs-clock.h>
28#include <plat/clock.h>
29#include <plat/cpu.h>
30#include <plat/clock-clksrc.h>
31#include <plat/s5p-clock.h>
32#include <plat/pll.h>
33#include <plat/s5p6440.h>
34
35/* APLL Mux output clock */
36static struct clksrc_clk clk_mout_apll = {
37 .clk = {
38 .name = "mout_apll",
39 .id = -1,
40 },
41 .sources = &clk_src_apll,
42 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 0, .size = 1 },
43};
44
45static int s5p6440_epll_enable(struct clk *clk, int enable)
46{
47 unsigned int ctrlbit = clk->ctrlbit;
48 unsigned int epll_con = __raw_readl(S5P_EPLL_CON) & ~ctrlbit;
49
50 if (enable)
51 __raw_writel(epll_con | ctrlbit, S5P_EPLL_CON);
52 else
53 __raw_writel(epll_con, S5P_EPLL_CON);
54
55 return 0;
56}
57
58static unsigned long s5p6440_epll_get_rate(struct clk *clk)
59{
60 return clk->rate;
61}
62
63static u32 epll_div[][5] = {
64 { 36000000, 0, 48, 1, 4 },
65 { 48000000, 0, 32, 1, 3 },
66 { 60000000, 0, 40, 1, 3 },
67 { 72000000, 0, 48, 1, 3 },
68 { 84000000, 0, 28, 1, 2 },
69 { 96000000, 0, 32, 1, 2 },
70 { 32768000, 45264, 43, 1, 4 },
71 { 45158000, 6903, 30, 1, 3 },
72 { 49152000, 50332, 32, 1, 3 },
73 { 67738000, 10398, 45, 1, 3 },
74 { 73728000, 9961, 49, 1, 3 }
75};
76
77static int s5p6440_epll_set_rate(struct clk *clk, unsigned long rate)
78{
79 unsigned int epll_con, epll_con_k;
80 unsigned int i;
81
82 if (clk->rate == rate) /* Return if nothing changed */
83 return 0;
84
85 epll_con = __raw_readl(S5P_EPLL_CON);
86 epll_con_k = __raw_readl(S5P_EPLL_CON_K);
87
88 epll_con_k &= ~(PLL90XX_KDIV_MASK);
89 epll_con &= ~(PLL90XX_MDIV_MASK | PLL90XX_PDIV_MASK | PLL90XX_SDIV_MASK);
90
91 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
92 if (epll_div[i][0] == rate) {
93 epll_con_k |= (epll_div[i][1] << PLL90XX_KDIV_SHIFT);
94 epll_con |= (epll_div[i][2] << PLL90XX_MDIV_SHIFT) |
95 (epll_div[i][3] << PLL90XX_PDIV_SHIFT) |
96 (epll_div[i][4] << PLL90XX_SDIV_SHIFT);
97 break;
98 }
99 }
100
101 if (i == ARRAY_SIZE(epll_div)) {
102 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n", __func__);
103 return -EINVAL;
104 }
105
106 __raw_writel(epll_con, S5P_EPLL_CON);
107 __raw_writel(epll_con_k, S5P_EPLL_CON_K);
108
109 clk->rate = rate;
110
111 return 0;
112}
113
114static struct clk_ops s5p6440_epll_ops = {
115 .get_rate = s5p6440_epll_get_rate,
116 .set_rate = s5p6440_epll_set_rate,
117};
118
119static struct clksrc_clk clk_mout_epll = {
120 .clk = {
121 .name = "mout_epll",
122 .id = -1,
123 },
124 .sources = &clk_src_epll,
125 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 2, .size = 1 },
126};
127
128static struct clksrc_clk clk_mout_mpll = {
129 .clk = {
130 .name = "mout_mpll",
131 .id = -1,
132 },
133 .sources = &clk_src_mpll,
134 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 1, .size = 1 },
135};
136
137enum perf_level {
138 L0 = 532*1000,
139 L1 = 266*1000,
140 L2 = 133*1000,
141};
142
143static const u32 clock_table[][3] = {
144 /*{ARM_CLK, DIVarm, DIVhclk}*/
145 {L0 * 1000, (0 << ARM_DIV_RATIO_SHIFT), (3 << S5P_CLKDIV0_HCLK_SHIFT)},
146 {L1 * 1000, (1 << ARM_DIV_RATIO_SHIFT), (1 << S5P_CLKDIV0_HCLK_SHIFT)},
147 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P_CLKDIV0_HCLK_SHIFT)},
148};
149
150static unsigned long s5p6440_armclk_get_rate(struct clk *clk)
151{
152 unsigned long rate = clk_get_rate(clk->parent);
153 u32 clkdiv;
154
155 /* divisor mask starts at bit0, so no need to shift */
156 clkdiv = __raw_readl(ARM_CLK_DIV) & ARM_DIV_MASK;
157
158 return rate / (clkdiv + 1);
159}
160
161static unsigned long s5p6440_armclk_round_rate(struct clk *clk,
162 unsigned long rate)
163{
164 u32 iter;
165
166 for (iter = 1 ; iter < ARRAY_SIZE(clock_table) ; iter++) {
167 if (rate > clock_table[iter][0])
168 return clock_table[iter-1][0];
169 }
170
171 return clock_table[ARRAY_SIZE(clock_table) - 1][0];
172}
173
174static int s5p6440_armclk_set_rate(struct clk *clk, unsigned long rate)
175{
176 u32 round_tmp;
177 u32 iter;
178 u32 clk_div0_tmp;
179 u32 cur_rate = clk->ops->get_rate(clk);
180 unsigned long flags;
181
182 round_tmp = clk->ops->round_rate(clk, rate);
183 if (round_tmp == cur_rate)
184 return 0;
185
186
187 for (iter = 0 ; iter < ARRAY_SIZE(clock_table) ; iter++) {
188 if (round_tmp == clock_table[iter][0])
189 break;
190 }
191
192 if (iter >= ARRAY_SIZE(clock_table))
193 iter = ARRAY_SIZE(clock_table) - 1;
194
195 local_irq_save(flags);
196 if (cur_rate > round_tmp) {
197 /* Frequency Down */
198 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) & ~(ARM_DIV_MASK);
199 clk_div0_tmp |= clock_table[iter][1];
200 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
201
202 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) &
203 ~(S5P_CLKDIV0_HCLK_MASK);
204 clk_div0_tmp |= clock_table[iter][2];
205 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
206
207
208 } else {
209 /* Frequency Up */
210 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) &
211 ~(S5P_CLKDIV0_HCLK_MASK);
212 clk_div0_tmp |= clock_table[iter][2];
213 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
214
215 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) & ~(ARM_DIV_MASK);
216 clk_div0_tmp |= clock_table[iter][1];
217 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
218 }
219 local_irq_restore(flags);
220
221 clk->rate = clock_table[iter][0];
222
223 return 0;
224}
225
226static struct clk_ops s5p6440_clkarm_ops = {
227 .get_rate = s5p6440_armclk_get_rate,
228 .set_rate = s5p6440_armclk_set_rate,
229 .round_rate = s5p6440_armclk_round_rate,
230};
231
232static struct clksrc_clk clk_armclk = {
233 .clk = {
234 .name = "armclk",
235 .id = 1,
236 .parent = &clk_mout_apll.clk,
237 .ops = &s5p6440_clkarm_ops,
238 },
239 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 0, .size = 4 },
240};
241
242static struct clksrc_clk clk_dout_mpll = {
243 .clk = {
244 .name = "dout_mpll",
245 .id = -1,
246 .parent = &clk_mout_mpll.clk,
247 },
248 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 4, .size = 1 },
249};
250
251static struct clksrc_clk clk_hclk = {
252 .clk = {
253 .name = "clk_hclk",
254 .id = -1,
255 .parent = &clk_armclk.clk,
256 },
257 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 8, .size = 4 },
258};
259
260static struct clksrc_clk clk_pclk = {
261 .clk = {
262 .name = "clk_pclk",
263 .id = -1,
264 .parent = &clk_hclk.clk,
265 },
266 .reg_div = { .reg = S5P_CLK_DIV0, .shift = 12, .size = 4 },
267};
268
269static struct clk *clkset_hclklow_list[] = {
270 &clk_mout_apll.clk,
271 &clk_mout_mpll.clk,
272};
273
274static struct clksrc_sources clkset_hclklow = {
275 .sources = clkset_hclklow_list,
276 .nr_sources = ARRAY_SIZE(clkset_hclklow_list),
277};
278
279static struct clksrc_clk clk_hclk_low = {
280 .clk = {
281 .name = "hclk_low",
282 .id = -1,
283 },
284 .sources = &clkset_hclklow,
285 .reg_src = { .reg = S5P_SYS_OTHERS, .shift = 6, .size = 1 },
286 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 8, .size = 4 },
287};
288
289static struct clksrc_clk clk_pclk_low = {
290 .clk = {
291 .name = "pclk_low",
292 .id = -1,
293 .parent = &clk_hclk_low.clk,
294 },
295 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 12, .size = 4 },
296};
297
298int s5p6440_clk48m_ctrl(struct clk *clk, int enable)
299{
300 unsigned long flags;
301 u32 val;
302
303 /* can't rely on clock lock, this register has other usages */
304 local_irq_save(flags);
305
306 val = __raw_readl(S5P_OTHERS);
307 if (enable)
308 val |= S5P_OTHERS_USB_SIG_MASK;
309 else
310 val &= ~S5P_OTHERS_USB_SIG_MASK;
311
312 __raw_writel(val, S5P_OTHERS);
313
314 local_irq_restore(flags);
315
316 return 0;
317}
318
319static int s5p6440_pclk_ctrl(struct clk *clk, int enable)
320{
321 return s5p_gatectrl(S5P_CLK_GATE_PCLK, clk, enable);
322}
323
324static int s5p6440_hclk0_ctrl(struct clk *clk, int enable)
325{
326 return s5p_gatectrl(S5P_CLK_GATE_HCLK0, clk, enable);
327}
328
329static int s5p6440_hclk1_ctrl(struct clk *clk, int enable)
330{
331 return s5p_gatectrl(S5P_CLK_GATE_HCLK1, clk, enable);
332}
333
334static int s5p6440_sclk_ctrl(struct clk *clk, int enable)
335{
336 return s5p_gatectrl(S5P_CLK_GATE_SCLK0, clk, enable);
337}
338
339static int s5p6440_sclk1_ctrl(struct clk *clk, int enable)
340{
341 return s5p_gatectrl(S5P_CLK_GATE_SCLK1, clk, enable);
342}
343
344static int s5p6440_mem_ctrl(struct clk *clk, int enable)
345{
346 return s5p_gatectrl(S5P_CLK_GATE_MEM0, clk, enable);
347}
348
349/*
350 * The following clocks will be disabled during clock initialization. It is
351 * recommended to keep the following clocks disabled until the driver requests
352 * for enabling the clock.
353 */
354static struct clk init_clocks_disable[] = {
355 {
356 .name = "nand",
357 .id = -1,
358 .parent = &clk_hclk.clk,
359 .enable = s5p6440_mem_ctrl,
360 .ctrlbit = S5P_CLKCON_MEM0_HCLK_NFCON,
361 }, {
362 .name = "adc",
363 .id = -1,
364 .parent = &clk_pclk_low.clk,
365 .enable = s5p6440_pclk_ctrl,
366 .ctrlbit = S5P_CLKCON_PCLK_TSADC,
367 }, {
368 .name = "i2c",
369 .id = -1,
370 .parent = &clk_pclk_low.clk,
371 .enable = s5p6440_pclk_ctrl,
372 .ctrlbit = S5P_CLKCON_PCLK_IIC0,
373 }, {
374 .name = "i2s_v40",
375 .id = 0,
376 .parent = &clk_pclk_low.clk,
377 .enable = s5p6440_pclk_ctrl,
378 .ctrlbit = S5P_CLKCON_PCLK_IIS2,
379 }, {
380 .name = "spi",
381 .id = 0,
382 .parent = &clk_pclk_low.clk,
383 .enable = s5p6440_pclk_ctrl,
384 .ctrlbit = S5P_CLKCON_PCLK_SPI0,
385 }, {
386 .name = "spi",
387 .id = 1,
388 .parent = &clk_pclk_low.clk,
389 .enable = s5p6440_pclk_ctrl,
390 .ctrlbit = S5P_CLKCON_PCLK_SPI1,
391 }, {
392 .name = "sclk_spi_48",
393 .id = 0,
394 .parent = &clk_48m,
395 .enable = s5p6440_sclk_ctrl,
396 .ctrlbit = S5P_CLKCON_SCLK0_SPI0_48,
397 }, {
398 .name = "sclk_spi_48",
399 .id = 1,
400 .parent = &clk_48m,
401 .enable = s5p6440_sclk_ctrl,
402 .ctrlbit = S5P_CLKCON_SCLK0_SPI1_48,
403 }, {
404 .name = "mmc_48m",
405 .id = 0,
406 .parent = &clk_48m,
407 .enable = s5p6440_sclk_ctrl,
408 .ctrlbit = S5P_CLKCON_SCLK0_MMC0_48,
409 }, {
410 .name = "mmc_48m",
411 .id = 1,
412 .parent = &clk_48m,
413 .enable = s5p6440_sclk_ctrl,
414 .ctrlbit = S5P_CLKCON_SCLK0_MMC1_48,
415 }, {
416 .name = "mmc_48m",
417 .id = 2,
418 .parent = &clk_48m,
419 .enable = s5p6440_sclk_ctrl,
420 .ctrlbit = S5P_CLKCON_SCLK0_MMC2_48,
421 }, {
422 .name = "otg",
423 .id = -1,
424 .parent = &clk_hclk_low.clk,
425 .enable = s5p6440_hclk0_ctrl,
426 .ctrlbit = S5P_CLKCON_HCLK0_USB
427 }, {
428 .name = "post",
429 .id = -1,
430 .parent = &clk_hclk_low.clk,
431 .enable = s5p6440_hclk0_ctrl,
432 .ctrlbit = S5P_CLKCON_HCLK0_POST0
433 }, {
434 .name = "lcd",
435 .id = -1,
436 .parent = &clk_hclk_low.clk,
437 .enable = s5p6440_hclk1_ctrl,
438 .ctrlbit = S5P_CLKCON_HCLK1_DISPCON,
439 }, {
440 .name = "hsmmc",
441 .id = 0,
442 .parent = &clk_hclk_low.clk,
443 .enable = s5p6440_hclk0_ctrl,
444 .ctrlbit = S5P_CLKCON_HCLK0_HSMMC0,
445 }, {
446 .name = "hsmmc",
447 .id = 1,
448 .parent = &clk_hclk_low.clk,
449 .enable = s5p6440_hclk0_ctrl,
450 .ctrlbit = S5P_CLKCON_HCLK0_HSMMC1,
451 }, {
452 .name = "hsmmc",
453 .id = 2,
454 .parent = &clk_hclk_low.clk,
455 .enable = s5p6440_hclk0_ctrl,
456 .ctrlbit = S5P_CLKCON_HCLK0_HSMMC2,
457 }, {
458 .name = "rtc",
459 .id = -1,
460 .parent = &clk_pclk_low.clk,
461 .enable = s5p6440_pclk_ctrl,
462 .ctrlbit = S5P_CLKCON_PCLK_RTC,
463 }, {
464 .name = "watchdog",
465 .id = -1,
466 .parent = &clk_pclk_low.clk,
467 .enable = s5p6440_pclk_ctrl,
468 .ctrlbit = S5P_CLKCON_PCLK_WDT,
469 }, {
470 .name = "timers",
471 .id = -1,
472 .parent = &clk_pclk_low.clk,
473 .enable = s5p6440_pclk_ctrl,
474 .ctrlbit = S5P_CLKCON_PCLK_PWM,
475 }, {
476 .name = "hclk_fimgvg",
477 .id = -1,
478 .parent = &clk_hclk.clk,
479 .enable = s5p6440_hclk1_ctrl,
480 .ctrlbit = (1 << 2),
481 }, {
482 .name = "tsi",
483 .id = -1,
484 .parent = &clk_hclk_low.clk,
485 .enable = s5p6440_hclk1_ctrl,
486 .ctrlbit = (1 << 0),
487 }, {
488 .name = "pclk_fimgvg",
489 .id = -1,
490 .parent = &clk_pclk.clk,
491 .enable = s5p6440_pclk_ctrl,
492 .ctrlbit = (1 << 31),
493 }, {
494 .name = "dmc0",
495 .id = -1,
496 .parent = &clk_pclk.clk,
497 .enable = s5p6440_pclk_ctrl,
498 .ctrlbit = (1 << 30),
499 }, {
500 .name = "etm",
501 .id = -1,
502 .parent = &clk_pclk.clk,
503 .enable = s5p6440_pclk_ctrl,
504 .ctrlbit = (1 << 29),
505 }, {
506 .name = "dsim",
507 .id = -1,
508 .parent = &clk_pclk_low.clk,
509 .enable = s5p6440_pclk_ctrl,
510 .ctrlbit = (1 << 28),
511 }, {
512 .name = "gps",
513 .id = -1,
514 .parent = &clk_pclk_low.clk,
515 .enable = s5p6440_pclk_ctrl,
516 .ctrlbit = (1 << 25),
517 }, {
518 .name = "pcm",
519 .id = -1,
520 .parent = &clk_pclk_low.clk,
521 .enable = s5p6440_pclk_ctrl,
522 .ctrlbit = (1 << 8),
523 }, {
524 .name = "irom",
525 .id = -1,
526 .parent = &clk_hclk.clk,
527 .enable = s5p6440_hclk0_ctrl,
528 .ctrlbit = (1 << 25),
529 }, {
530 .name = "dma",
531 .id = -1,
532 .parent = &clk_hclk_low.clk,
533 .enable = s5p6440_hclk0_ctrl,
534 .ctrlbit = (1 << 12),
535 }, {
536 .name = "2d",
537 .id = -1,
538 .parent = &clk_hclk.clk,
539 .enable = s5p6440_hclk0_ctrl,
540 .ctrlbit = (1 << 8),
541 },
542};
543
544/*
545 * The following clocks will be enabled during clock initialization.
546 */
547static struct clk init_clocks[] = {
548 {
549 .name = "gpio",
550 .id = -1,
551 .parent = &clk_pclk_low.clk,
552 .enable = s5p6440_pclk_ctrl,
553 .ctrlbit = S5P_CLKCON_PCLK_GPIO,
554 }, {
555 .name = "uart",
556 .id = 0,
557 .parent = &clk_pclk_low.clk,
558 .enable = s5p6440_pclk_ctrl,
559 .ctrlbit = S5P_CLKCON_PCLK_UART0,
560 }, {
561 .name = "uart",
562 .id = 1,
563 .parent = &clk_pclk_low.clk,
564 .enable = s5p6440_pclk_ctrl,
565 .ctrlbit = S5P_CLKCON_PCLK_UART1,
566 }, {
567 .name = "uart",
568 .id = 2,
569 .parent = &clk_pclk_low.clk,
570 .enable = s5p6440_pclk_ctrl,
571 .ctrlbit = S5P_CLKCON_PCLK_UART2,
572 }, {
573 .name = "uart",
574 .id = 3,
575 .parent = &clk_pclk_low.clk,
576 .enable = s5p6440_pclk_ctrl,
577 .ctrlbit = S5P_CLKCON_PCLK_UART3,
578 }, {
579 .name = "mem",
580 .id = -1,
581 .parent = &clk_hclk.clk,
582 .enable = s5p6440_hclk0_ctrl,
583 .ctrlbit = (1 << 21),
584 }, {
585 .name = "intc",
586 .id = -1,
587 .parent = &clk_hclk.clk,
588 .enable = s5p6440_hclk0_ctrl,
589 .ctrlbit = (1 << 1),
590 },
591};
592
593static struct clk clk_iis_cd_v40 = {
594 .name = "iis_cdclk_v40",
595 .id = -1,
596};
597
598static struct clk clk_pcm_cd = {
599 .name = "pcm_cdclk",
600 .id = -1,
601};
602
603static struct clk *clkset_group1_list[] = {
604 &clk_mout_epll.clk,
605 &clk_dout_mpll.clk,
606 &clk_fin_epll,
607};
608
609static struct clksrc_sources clkset_group1 = {
610 .sources = clkset_group1_list,
611 .nr_sources = ARRAY_SIZE(clkset_group1_list),
612};
613
614static struct clk *clkset_uart_list[] = {
615 &clk_mout_epll.clk,
616 &clk_dout_mpll.clk,
617};
618
619static struct clksrc_sources clkset_uart = {
620 .sources = clkset_uart_list,
621 .nr_sources = ARRAY_SIZE(clkset_uart_list),
622};
623
624static struct clk *clkset_audio_list[] = {
625 &clk_mout_epll.clk,
626 &clk_dout_mpll.clk,
627 &clk_fin_epll,
628 &clk_iis_cd_v40,
629 &clk_pcm_cd,
630};
631
632static struct clksrc_sources clkset_audio = {
633 .sources = clkset_audio_list,
634 .nr_sources = ARRAY_SIZE(clkset_audio_list),
635};
636
637static struct clksrc_clk clksrcs[] = {
638 {
639 .clk = {
640 .name = "mmc_bus",
641 .id = 0,
642 .ctrlbit = S5P_CLKCON_SCLK0_MMC0,
643 .enable = s5p6440_sclk_ctrl,
644 },
645 .sources = &clkset_group1,
646 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 18, .size = 2 },
647 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 0, .size = 4 },
648 }, {
649 .clk = {
650 .name = "mmc_bus",
651 .id = 1,
652 .ctrlbit = S5P_CLKCON_SCLK0_MMC1,
653 .enable = s5p6440_sclk_ctrl,
654 },
655 .sources = &clkset_group1,
656 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 20, .size = 2 },
657 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 4, .size = 4 },
658 }, {
659 .clk = {
660 .name = "mmc_bus",
661 .id = 2,
662 .ctrlbit = S5P_CLKCON_SCLK0_MMC2,
663 .enable = s5p6440_sclk_ctrl,
664 },
665 .sources = &clkset_group1,
666 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 22, .size = 2 },
667 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 8, .size = 4 },
668 }, {
669 .clk = {
670 .name = "uclk1",
671 .id = -1,
672 .ctrlbit = S5P_CLKCON_SCLK0_UART,
673 .enable = s5p6440_sclk_ctrl,
674 },
675 .sources = &clkset_uart,
676 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 13, .size = 1 },
677 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 16, .size = 4 },
678 }, {
679 .clk = {
680 .name = "spi_epll",
681 .id = 0,
682 .ctrlbit = S5P_CLKCON_SCLK0_SPI0,
683 .enable = s5p6440_sclk_ctrl,
684 },
685 .sources = &clkset_group1,
686 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 14, .size = 2 },
687 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 0, .size = 4 },
688 }, {
689 .clk = {
690 .name = "spi_epll",
691 .id = 1,
692 .ctrlbit = S5P_CLKCON_SCLK0_SPI1,
693 .enable = s5p6440_sclk_ctrl,
694 },
695 .sources = &clkset_group1,
696 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 16, .size = 2 },
697 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 4, .size = 4 },
698 }, {
699 .clk = {
700 .name = "sclk_post",
701 .id = -1,
702 .ctrlbit = (1 << 10),
703 .enable = s5p6440_sclk_ctrl,
704 },
705 .sources = &clkset_group1,
706 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 26, .size = 2 },
707 .reg_div = { .reg = S5P_CLK_DIV1, .shift = 12, .size = 4 },
708 }, {
709 .clk = {
710 .name = "sclk_dispcon",
711 .id = -1,
712 .ctrlbit = (1 << 1),
713 .enable = s5p6440_sclk1_ctrl,
714 },
715 .sources = &clkset_group1,
716 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 2 },
717 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 0, .size = 4 },
718 }, {
719 .clk = {
720 .name = "sclk_fimgvg",
721 .id = -1,
722 .ctrlbit = (1 << 2),
723 .enable = s5p6440_sclk1_ctrl,
724 },
725 .sources = &clkset_group1,
726 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 8, .size = 2 },
727 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 4, .size = 4 },
728 }, {
729 .clk = {
730 .name = "sclk_audio2",
731 .id = -1,
732 .ctrlbit = (1 << 11),
733 .enable = s5p6440_sclk_ctrl,
734 },
735 .sources = &clkset_audio,
736 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 0, .size = 3 },
737 .reg_div = { .reg = S5P_CLK_DIV2, .shift = 24, .size = 4 },
738 },
739};
740
741/* Clock initialisation code */
742static struct clksrc_clk *sysclks[] = {
743 &clk_mout_apll,
744 &clk_mout_epll,
745 &clk_mout_mpll,
746 &clk_dout_mpll,
747 &clk_armclk,
748 &clk_hclk,
749 &clk_pclk,
750 &clk_hclk_low,
751 &clk_pclk_low,
752};
753
754void __init_or_cpufreq s5p6440_setup_clocks(void)
755{
756 struct clk *xtal_clk;
757 unsigned long xtal;
758 unsigned long fclk;
759 unsigned long hclk;
760 unsigned long hclk_low;
761 unsigned long pclk;
762 unsigned long pclk_low;
763 unsigned long epll;
764 unsigned long apll;
765 unsigned long mpll;
766 unsigned int ptr;
767
768 /* Set S5P6440 functions for clk_fout_epll */
769 clk_fout_epll.enable = s5p6440_epll_enable;
770 clk_fout_epll.ops = &s5p6440_epll_ops;
771
772 clk_48m.enable = s5p6440_clk48m_ctrl;
773
774 xtal_clk = clk_get(NULL, "ext_xtal");
775 BUG_ON(IS_ERR(xtal_clk));
776
777 xtal = clk_get_rate(xtal_clk);
778 clk_put(xtal_clk);
779
780 epll = s5p_get_pll90xx(xtal, __raw_readl(S5P_EPLL_CON),
781 __raw_readl(S5P_EPLL_CON_K));
782 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
783 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4502);
784
785 clk_fout_mpll.rate = mpll;
786 clk_fout_epll.rate = epll;
787 clk_fout_apll.rate = apll;
788
789 printk(KERN_INFO "S5P6440: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
790 " E=%ld.%ldMHz\n",
791 print_mhz(apll), print_mhz(mpll), print_mhz(epll));
792
793 fclk = clk_get_rate(&clk_armclk.clk);
794 hclk = clk_get_rate(&clk_hclk.clk);
795 pclk = clk_get_rate(&clk_pclk.clk);
796 hclk_low = clk_get_rate(&clk_hclk_low.clk);
797 pclk_low = clk_get_rate(&clk_pclk_low.clk);
798
799 printk(KERN_INFO "S5P6440: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
800 " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
801 print_mhz(hclk), print_mhz(hclk_low),
802 print_mhz(pclk), print_mhz(pclk_low));
803
804 clk_f.rate = fclk;
805 clk_h.rate = hclk;
806 clk_p.rate = pclk;
807
808 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
809 s3c_set_clksrc(&clksrcs[ptr], true);
810}
811
812static struct clk *clks[] __initdata = {
813 &clk_ext,
814 &clk_iis_cd_v40,
815 &clk_pcm_cd,
816};
817
818void __init s5p6440_register_clocks(void)
819{
820 struct clk *clkp;
821 int ret;
822 int ptr;
823
824 ret = s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
825 if (ret > 0)
826 printk(KERN_ERR "Failed to register %u clocks\n", ret);
827
828 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
829 s3c_register_clksrc(sysclks[ptr], 1);
830
831 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
832 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
833
834 clkp = init_clocks_disable;
835 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
836
837 ret = s3c24xx_register_clock(clkp);
838 if (ret < 0) {
839 printk(KERN_ERR "Failed to register clock %s (%d)\n",
840 clkp->name, ret);
841 }
842 (clkp->enable)(clkp, 0);
843 }
844
845 s3c_pwmclk_init();
846}
diff --git a/arch/arm/mach-s5p6440/cpu.c b/arch/arm/mach-s5p6440/cpu.c
deleted file mode 100644
index 526f33adb31d..000000000000
--- a/arch/arm/mach-s5p6440/cpu.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/cpu.c
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/interrupt.h>
14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/init.h>
17#include <linux/clk.h>
18#include <linux/io.h>
19#include <linux/sysdev.h>
20#include <linux/serial_core.h>
21#include <linux/platform_device.h>
22
23#include <asm/mach/arch.h>
24#include <asm/mach/map.h>
25#include <asm/mach/irq.h>
26
27#include <asm/proc-fns.h>
28
29#include <mach/hardware.h>
30#include <mach/map.h>
31#include <asm/irq.h>
32
33#include <plat/regs-serial.h>
34#include <mach/regs-clock.h>
35
36#include <plat/cpu.h>
37#include <plat/devs.h>
38#include <plat/clock.h>
39#include <plat/s5p6440.h>
40#include <plat/adc-core.h>
41
42static void s5p6440_idle(void)
43{
44 unsigned long val;
45
46 if (!need_resched()) {
47 val = __raw_readl(S5P_PWR_CFG);
48 val &= ~(0x3<<5);
49 val |= (0x1<<5);
50 __raw_writel(val, S5P_PWR_CFG);
51
52 cpu_do_idle();
53 }
54 local_irq_enable();
55}
56
57/* s5p6440_map_io
58 *
59 * register the standard cpu IO areas
60*/
61
62void __init s5p6440_map_io(void)
63{
64 /* initialize any device information early */
65 s3c_adc_setname("s3c64xx-adc");
66}
67
68void __init s5p6440_init_clocks(int xtal)
69{
70 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
71
72 s3c24xx_register_baseclocks(xtal);
73 s5p_register_clocks(xtal);
74 s5p6440_register_clocks();
75 s5p6440_setup_clocks();
76}
77
78void __init s5p6440_init_irq(void)
79{
80 /* S5P6440 supports only 2 VIC */
81 u32 vic[2];
82
83 /*
84 * VIC0 is missing IRQ_VIC0[3, 4, 8, 10, (12-22)]
85 * VIC1 is missing IRQ VIC1[1, 3, 4, 10, 11, 12, 14, 15, 22]
86 */
87 vic[0] = 0xff800ae7;
88 vic[1] = 0xffbf23e5;
89
90 s5p_init_irq(vic, ARRAY_SIZE(vic));
91}
92
93struct sysdev_class s5p6440_sysclass = {
94 .name = "s5p6440-core",
95};
96
97static struct sys_device s5p6440_sysdev = {
98 .cls = &s5p6440_sysclass,
99};
100
101static int __init s5p6440_core_init(void)
102{
103 return sysdev_class_register(&s5p6440_sysclass);
104}
105
106core_initcall(s5p6440_core_init);
107
108int __init s5p6440_init(void)
109{
110 printk(KERN_INFO "S5P6440: Initializing architecture\n");
111
112 /* set idle function */
113 pm_idle = s5p6440_idle;
114
115 return sysdev_register(&s5p6440_sysdev);
116}
diff --git a/arch/arm/mach-s5p6440/dev-audio.c b/arch/arm/mach-s5p6440/dev-audio.c
deleted file mode 100644
index 3ca0d2b8275d..000000000000
--- a/arch/arm/mach-s5p6440/dev-audio.c
+++ /dev/null
@@ -1,127 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/dev-audio.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/dma-mapping.h>
13#include <linux/gpio.h>
14
15#include <plat/gpio-cfg.h>
16#include <plat/audio.h>
17
18#include <mach/map.h>
19#include <mach/dma.h>
20#include <mach/irqs.h>
21
22static int s5p6440_cfg_i2s(struct platform_device *pdev)
23{
24 /* configure GPIO for i2s port */
25 switch (pdev->id) {
26 case -1:
27 s3c_gpio_cfgpin(S5P6440_GPR(4), S3C_GPIO_SFN(5));
28 s3c_gpio_cfgpin(S5P6440_GPR(5), S3C_GPIO_SFN(5));
29 s3c_gpio_cfgpin(S5P6440_GPR(6), S3C_GPIO_SFN(5));
30 s3c_gpio_cfgpin(S5P6440_GPR(7), S3C_GPIO_SFN(5));
31 s3c_gpio_cfgpin(S5P6440_GPR(8), S3C_GPIO_SFN(5));
32 s3c_gpio_cfgpin(S5P6440_GPR(13), S3C_GPIO_SFN(5));
33 s3c_gpio_cfgpin(S5P6440_GPR(14), S3C_GPIO_SFN(5));
34 break;
35
36 default:
37 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
38 return -EINVAL;
39 }
40
41 return 0;
42}
43
44static struct s3c_audio_pdata s3c_i2s_pdata = {
45 .cfg_gpio = s5p6440_cfg_i2s,
46};
47
48static struct resource s5p6440_iis0_resource[] = {
49 [0] = {
50 .start = S5P6440_PA_I2S,
51 .end = S5P6440_PA_I2S + 0x100 - 1,
52 .flags = IORESOURCE_MEM,
53 },
54 [1] = {
55 .start = DMACH_I2S0_TX,
56 .end = DMACH_I2S0_TX,
57 .flags = IORESOURCE_DMA,
58 },
59 [2] = {
60 .start = DMACH_I2S0_RX,
61 .end = DMACH_I2S0_RX,
62 .flags = IORESOURCE_DMA,
63 },
64};
65
66struct platform_device s5p6440_device_iis = {
67 .name = "s3c64xx-iis-v4",
68 .id = -1,
69 .num_resources = ARRAY_SIZE(s5p6440_iis0_resource),
70 .resource = s5p6440_iis0_resource,
71 .dev = {
72 .platform_data = &s3c_i2s_pdata,
73 },
74};
75
76/* PCM Controller platform_devices */
77
78static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
79{
80 switch (pdev->id) {
81 case 0:
82 s3c_gpio_cfgpin(S5P6440_GPR(7), S3C_GPIO_SFN(2));
83 s3c_gpio_cfgpin(S5P6440_GPR(13), S3C_GPIO_SFN(2));
84 s3c_gpio_cfgpin(S5P6440_GPR(14), S3C_GPIO_SFN(2));
85 s3c_gpio_cfgpin(S5P6440_GPR(8), S3C_GPIO_SFN(2));
86 s3c_gpio_cfgpin(S5P6440_GPR(6), S3C_GPIO_SFN(2));
87 break;
88
89 default:
90 printk(KERN_DEBUG "Invalid PCM Controller number!");
91 return -EINVAL;
92 }
93
94 return 0;
95}
96
97static struct s3c_audio_pdata s3c_pcm_pdata = {
98 .cfg_gpio = s5p6440_pcm_cfg_gpio,
99};
100
101static struct resource s5p6440_pcm0_resource[] = {
102 [0] = {
103 .start = S5P6440_PA_PCM,
104 .end = S5P6440_PA_PCM + 0x100 - 1,
105 .flags = IORESOURCE_MEM,
106 },
107 [1] = {
108 .start = DMACH_PCM0_TX,
109 .end = DMACH_PCM0_TX,
110 .flags = IORESOURCE_DMA,
111 },
112 [2] = {
113 .start = DMACH_PCM0_RX,
114 .end = DMACH_PCM0_RX,
115 .flags = IORESOURCE_DMA,
116 },
117};
118
119struct platform_device s5p6440_device_pcm = {
120 .name = "samsung-pcm",
121 .id = 0,
122 .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
123 .resource = s5p6440_pcm0_resource,
124 .dev = {
125 .platform_data = &s3c_pcm_pdata,
126 },
127};
diff --git a/arch/arm/mach-s5p6440/dev-spi.c b/arch/arm/mach-s5p6440/dev-spi.c
deleted file mode 100644
index 510af44d180c..000000000000
--- a/arch/arm/mach-s5p6440/dev-spi.c
+++ /dev/null
@@ -1,176 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/dev-spi.c
2 *
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/dma-mapping.h>
13#include <linux/gpio.h>
14
15#include <mach/dma.h>
16#include <mach/map.h>
17#include <mach/irqs.h>
18#include <mach/spi-clocks.h>
19
20#include <plat/s3c64xx-spi.h>
21#include <plat/gpio-cfg.h>
22
23static char *spi_src_clks[] = {
24 [S5P6440_SPI_SRCCLK_PCLK] = "pclk",
25 [S5P6440_SPI_SRCCLK_SCLK] = "spi_epll",
26};
27
28/* SPI Controller platform_devices */
29
30/* Since we emulate multi-cs capability, we do not touch the CS.
31 * The emulated CS is toggled by board specific mechanism, as it can
32 * be either some immediate GPIO or some signal out of some other
33 * chip in between ... or some yet another way.
34 * We simply do not assume anything about CS.
35 */
36static int s5p6440_spi_cfg_gpio(struct platform_device *pdev)
37{
38 switch (pdev->id) {
39 case 0:
40 s3c_gpio_cfgpin(S5P6440_GPC(0), S3C_GPIO_SFN(2));
41 s3c_gpio_cfgpin(S5P6440_GPC(1), S3C_GPIO_SFN(2));
42 s3c_gpio_cfgpin(S5P6440_GPC(2), S3C_GPIO_SFN(2));
43 s3c_gpio_setpull(S5P6440_GPC(0), S3C_GPIO_PULL_UP);
44 s3c_gpio_setpull(S5P6440_GPC(1), S3C_GPIO_PULL_UP);
45 s3c_gpio_setpull(S5P6440_GPC(2), S3C_GPIO_PULL_UP);
46 break;
47
48 case 1:
49 s3c_gpio_cfgpin(S5P6440_GPC(4), S3C_GPIO_SFN(2));
50 s3c_gpio_cfgpin(S5P6440_GPC(5), S3C_GPIO_SFN(2));
51 s3c_gpio_cfgpin(S5P6440_GPC(6), S3C_GPIO_SFN(2));
52 s3c_gpio_setpull(S5P6440_GPC(4), S3C_GPIO_PULL_UP);
53 s3c_gpio_setpull(S5P6440_GPC(5), S3C_GPIO_PULL_UP);
54 s3c_gpio_setpull(S5P6440_GPC(6), S3C_GPIO_PULL_UP);
55 break;
56
57 default:
58 dev_err(&pdev->dev, "Invalid SPI Controller number!");
59 return -EINVAL;
60 }
61
62 return 0;
63}
64
65static struct resource s5p6440_spi0_resource[] = {
66 [0] = {
67 .start = S5P6440_PA_SPI0,
68 .end = S5P6440_PA_SPI0 + 0x100 - 1,
69 .flags = IORESOURCE_MEM,
70 },
71 [1] = {
72 .start = DMACH_SPI0_TX,
73 .end = DMACH_SPI0_TX,
74 .flags = IORESOURCE_DMA,
75 },
76 [2] = {
77 .start = DMACH_SPI0_RX,
78 .end = DMACH_SPI0_RX,
79 .flags = IORESOURCE_DMA,
80 },
81 [3] = {
82 .start = IRQ_SPI0,
83 .end = IRQ_SPI0,
84 .flags = IORESOURCE_IRQ,
85 },
86};
87
88static struct s3c64xx_spi_info s5p6440_spi0_pdata = {
89 .cfg_gpio = s5p6440_spi_cfg_gpio,
90 .fifo_lvl_mask = 0x1ff,
91 .rx_lvl_offset = 15,
92};
93
94static u64 spi_dmamask = DMA_BIT_MASK(32);
95
96struct platform_device s5p6440_device_spi0 = {
97 .name = "s3c64xx-spi",
98 .id = 0,
99 .num_resources = ARRAY_SIZE(s5p6440_spi0_resource),
100 .resource = s5p6440_spi0_resource,
101 .dev = {
102 .dma_mask = &spi_dmamask,
103 .coherent_dma_mask = DMA_BIT_MASK(32),
104 .platform_data = &s5p6440_spi0_pdata,
105 },
106};
107
108static struct resource s5p6440_spi1_resource[] = {
109 [0] = {
110 .start = S5P6440_PA_SPI1,
111 .end = S5P6440_PA_SPI1 + 0x100 - 1,
112 .flags = IORESOURCE_MEM,
113 },
114 [1] = {
115 .start = DMACH_SPI1_TX,
116 .end = DMACH_SPI1_TX,
117 .flags = IORESOURCE_DMA,
118 },
119 [2] = {
120 .start = DMACH_SPI1_RX,
121 .end = DMACH_SPI1_RX,
122 .flags = IORESOURCE_DMA,
123 },
124 [3] = {
125 .start = IRQ_SPI1,
126 .end = IRQ_SPI1,
127 .flags = IORESOURCE_IRQ,
128 },
129};
130
131static struct s3c64xx_spi_info s5p6440_spi1_pdata = {
132 .cfg_gpio = s5p6440_spi_cfg_gpio,
133 .fifo_lvl_mask = 0x7f,
134 .rx_lvl_offset = 15,
135};
136
137struct platform_device s5p6440_device_spi1 = {
138 .name = "s3c64xx-spi",
139 .id = 1,
140 .num_resources = ARRAY_SIZE(s5p6440_spi1_resource),
141 .resource = s5p6440_spi1_resource,
142 .dev = {
143 .dma_mask = &spi_dmamask,
144 .coherent_dma_mask = DMA_BIT_MASK(32),
145 .platform_data = &s5p6440_spi1_pdata,
146 },
147};
148
149void __init s5p6440_spi_set_info(int cntrlr, int src_clk_nr, int num_cs)
150{
151 struct s3c64xx_spi_info *pd;
152
153 /* Reject invalid configuration */
154 if (!num_cs || src_clk_nr < 0
155 || src_clk_nr > S5P6440_SPI_SRCCLK_SCLK) {
156 printk(KERN_ERR "%s: Invalid SPI configuration\n", __func__);
157 return;
158 }
159
160 switch (cntrlr) {
161 case 0:
162 pd = &s5p6440_spi0_pdata;
163 break;
164 case 1:
165 pd = &s5p6440_spi1_pdata;
166 break;
167 default:
168 printk(KERN_ERR "%s: Invalid SPI controller(%d)\n",
169 __func__, cntrlr);
170 return;
171 }
172
173 pd->num_cs = num_cs;
174 pd->src_clk_nr = src_clk_nr;
175 pd->src_clk_name = spi_src_clks[src_clk_nr];
176}
diff --git a/arch/arm/mach-s5p6440/include/mach/debug-macro.S b/arch/arm/mach-s5p6440/include/mach/debug-macro.S
deleted file mode 100644
index 1347d7f99079..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/debug-macro.S
+++ /dev/null
@@ -1,37 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/debug-macro.S
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11/* pull in the relevant register and map files. */
12
13#include <mach/map.h>
14#include <plat/regs-serial.h>
15
16 /* note, for the boot process to work we have to keep the UART
17 * virtual address aligned to an 1MiB boundary for the L1
18 * mapping the head code makes. We keep the UART virtual address
19 * aligned and add in the offset when we load the value here.
20 */
21
22 .macro addruart, rx, rtmp
23 mrc p15, 0, \rx, c1, c0
24 tst \rx, #1
25 ldreq \rx, = S3C_PA_UART
26 ldrne \rx, = S3C_VA_UART
27#if CONFIG_DEBUG_S3C_UART != 0
28 add \rx, \rx, #(0x400 * CONFIG_DEBUG_S3C_UART)
29#endif
30 .endm
31
32/* include the reset of the code which will do the work, we're only
33 * compiling for a single cpu processor type so the default of s3c2440
34 * will be fine with us.
35 */
36
37#include <plat/debug-macro.S>
diff --git a/arch/arm/mach-s5p6440/include/mach/gpio.h b/arch/arm/mach-s5p6440/include/mach/gpio.h
deleted file mode 100644
index 21783834f2a2..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/gpio.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/gpio.h
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - GPIO lib support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_GPIO_H
14#define __ASM_ARCH_GPIO_H __FILE__
15
16#define gpio_get_value __gpio_get_value
17#define gpio_set_value __gpio_set_value
18#define gpio_cansleep __gpio_cansleep
19#define gpio_to_irq __gpio_to_irq
20
21/* GPIO bank sizes */
22#define S5P6440_GPIO_A_NR (6)
23#define S5P6440_GPIO_B_NR (7)
24#define S5P6440_GPIO_C_NR (8)
25#define S5P6440_GPIO_F_NR (2)
26#define S5P6440_GPIO_G_NR (7)
27#define S5P6440_GPIO_H_NR (10)
28#define S5P6440_GPIO_I_NR (16)
29#define S5P6440_GPIO_J_NR (12)
30#define S5P6440_GPIO_N_NR (16)
31#define S5P6440_GPIO_P_NR (8)
32#define S5P6440_GPIO_R_NR (15)
33
34/* GPIO bank numbers */
35
36/* CONFIG_S3C_GPIO_SPACE allows the user to select extra
37 * space for debugging purposes so that any accidental
38 * change from one gpio bank to another can be caught.
39*/
40#define S5P6440_GPIO_NEXT(__gpio) \
41 ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
42
43enum s5p_gpio_number {
44 S5P6440_GPIO_A_START = 0,
45 S5P6440_GPIO_B_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_A),
46 S5P6440_GPIO_C_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_B),
47 S5P6440_GPIO_F_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_C),
48 S5P6440_GPIO_G_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_F),
49 S5P6440_GPIO_H_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_G),
50 S5P6440_GPIO_I_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_H),
51 S5P6440_GPIO_J_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_I),
52 S5P6440_GPIO_N_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_J),
53 S5P6440_GPIO_P_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_N),
54 S5P6440_GPIO_R_START = S5P6440_GPIO_NEXT(S5P6440_GPIO_P),
55};
56
57/* S5P6440 GPIO number definitions. */
58#define S5P6440_GPA(_nr) (S5P6440_GPIO_A_START + (_nr))
59#define S5P6440_GPB(_nr) (S5P6440_GPIO_B_START + (_nr))
60#define S5P6440_GPC(_nr) (S5P6440_GPIO_C_START + (_nr))
61#define S5P6440_GPF(_nr) (S5P6440_GPIO_F_START + (_nr))
62#define S5P6440_GPG(_nr) (S5P6440_GPIO_G_START + (_nr))
63#define S5P6440_GPH(_nr) (S5P6440_GPIO_H_START + (_nr))
64#define S5P6440_GPI(_nr) (S5P6440_GPIO_I_START + (_nr))
65#define S5P6440_GPJ(_nr) (S5P6440_GPIO_J_START + (_nr))
66#define S5P6440_GPN(_nr) (S5P6440_GPIO_N_START + (_nr))
67#define S5P6440_GPP(_nr) (S5P6440_GPIO_P_START + (_nr))
68#define S5P6440_GPR(_nr) (S5P6440_GPIO_R_START + (_nr))
69
70/* the end of the S5P6440 specific gpios */
71#define S5P6440_GPIO_END (S5P6440_GPR(S5P6440_GPIO_R_NR) + 1)
72#define S3C_GPIO_END S5P6440_GPIO_END
73
74/* define the number of gpios we need to the one after the GPR() range */
75#define ARCH_NR_GPIOS (S5P6440_GPR(S5P6440_GPIO_R_NR) + \
76 CONFIG_SAMSUNG_GPIO_EXTRA + 1)
77
78#include <asm-generic/gpio.h>
79
80#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/io.h b/arch/arm/mach-s5p6440/include/mach/io.h
deleted file mode 100644
index fa2d69cb1ad7..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/io.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/* arch/arm/mach-s5p6440/include/mach/io.h
2 *
3 * Copyright 2008 Simtec Electronics
4 * Ben Dooks <ben-linux@fluff.org>
5 *
6 * Default IO routines for S3C64XX based
7 */
8
9#ifndef __ASM_ARM_ARCH_IO_H
10#define __ASM_ARM_ARCH_IO_H
11
12/* No current ISA/PCI bus support. */
13#define __io(a) __typesafe_io(a)
14#define __mem_pci(a) (a)
15
16#define IO_SPACE_LIMIT (0xFFFFFFFF)
17
18#endif
diff --git a/arch/arm/mach-s5p6440/include/mach/map.h b/arch/arm/mach-s5p6440/include/mach/map.h
deleted file mode 100644
index 6cc5cbc88ffb..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/map.h
+++ /dev/null
@@ -1,86 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/map.h
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - Memory map definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_MAP_H
14#define __ASM_ARCH_MAP_H __FILE__
15
16#include <plat/map-base.h>
17#include <plat/map-s5p.h>
18
19#define S5P6440_PA_CHIPID (0xE0000000)
20#define S5P_PA_CHIPID S5P6440_PA_CHIPID
21
22#define S5P6440_PA_SYSCON (0xE0100000)
23#define S5P6440_PA_CLK (S5P6440_PA_SYSCON + 0x0)
24#define S5P_PA_SYSCON S5P6440_PA_SYSCON
25
26#define S5P6440_PA_GPIO (0xE0308000)
27#define S5P_PA_GPIO S5P6440_PA_GPIO
28
29#define S5P6440_PA_VIC0 (0xE4000000)
30#define S5P_PA_VIC0 S5P6440_PA_VIC0
31
32#define S5P6440_PA_PDMA 0xE9000000
33
34#define S5P6440_PA_VIC1 (0xE4100000)
35#define S5P_PA_VIC1 S5P6440_PA_VIC1
36
37#define S5P6440_PA_TIMER (0xEA000000)
38#define S5P_PA_TIMER S5P6440_PA_TIMER
39
40#define S5P6440_PA_RTC (0xEA100000)
41
42#define S5P6440_PA_WDT (0xEA200000)
43#define S5P_PA_WDT S5P6440_PA_WDT
44
45#define S5P6440_PA_UART (0xEC000000)
46
47#define S5P_PA_UART0 (S5P6440_PA_UART + 0x0)
48#define S5P_PA_UART1 (S5P6440_PA_UART + 0x400)
49#define S5P_PA_UART2 (S5P6440_PA_UART + 0x800)
50#define S5P_PA_UART3 (S5P6440_PA_UART + 0xC00)
51
52#define S5P_SZ_UART SZ_256
53
54#define S5P6440_PA_IIC0 (0xEC104000)
55#define S5P6440_PA_IIC1 (0xEC20F000)
56
57#define S5P6440_PA_SPI0 0xEC400000
58#define S5P6440_PA_SPI1 0xEC500000
59
60#define S5P6440_PA_HSOTG (0xED100000)
61
62#define S5P6440_PA_HSMMC0 (0xED800000)
63#define S5P6440_PA_HSMMC1 (0xED900000)
64#define S5P6440_PA_HSMMC2 (0xEDA00000)
65
66#define S5P6440_PA_SDRAM (0x20000000)
67#define S5P_PA_SDRAM S5P6440_PA_SDRAM
68
69/* I2S */
70#define S5P6440_PA_I2S 0xF2000000
71
72/* PCM */
73#define S5P6440_PA_PCM 0xF2100000
74
75#define S5P6440_PA_ADC (0xF3000000)
76
77/* compatibiltiy defines. */
78#define S3C_PA_UART S5P6440_PA_UART
79#define S3C_PA_IIC S5P6440_PA_IIC0
80#define S3C_PA_RTC S5P6440_PA_RTC
81#define S3C_PA_IIC1 S5P6440_PA_IIC1
82#define S3C_PA_WDT S5P6440_PA_WDT
83
84#define SAMSUNG_PA_ADC S5P6440_PA_ADC
85
86#endif /* __ASM_ARCH_MAP_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/regs-clock.h b/arch/arm/mach-s5p6440/include/mach/regs-clock.h
deleted file mode 100644
index c783ecc9f193..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/regs-clock.h
+++ /dev/null
@@ -1,130 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/regs-clock.h
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - Clock register definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_REGS_CLOCK_H
14#define __ASM_ARCH_REGS_CLOCK_H __FILE__
15
16#include <mach/map.h>
17
18#define S5P_CLKREG(x) (S3C_VA_SYS + (x))
19
20#define S5P_APLL_LOCK S5P_CLKREG(0x00)
21#define S5P_MPLL_LOCK S5P_CLKREG(0x04)
22#define S5P_EPLL_LOCK S5P_CLKREG(0x08)
23#define S5P_APLL_CON S5P_CLKREG(0x0C)
24#define S5P_MPLL_CON S5P_CLKREG(0x10)
25#define S5P_EPLL_CON S5P_CLKREG(0x14)
26#define S5P_EPLL_CON_K S5P_CLKREG(0x18)
27#define S5P_CLK_SRC0 S5P_CLKREG(0x1C)
28#define S5P_CLK_DIV0 S5P_CLKREG(0x20)
29#define S5P_CLK_DIV1 S5P_CLKREG(0x24)
30#define S5P_CLK_DIV2 S5P_CLKREG(0x28)
31#define S5P_CLK_OUT S5P_CLKREG(0x2C)
32#define S5P_CLK_GATE_HCLK0 S5P_CLKREG(0x30)
33#define S5P_CLK_GATE_PCLK S5P_CLKREG(0x34)
34#define S5P_CLK_GATE_SCLK0 S5P_CLKREG(0x38)
35#define S5P_CLK_GATE_MEM0 S5P_CLKREG(0x3C)
36#define S5P_CLK_DIV3 S5P_CLKREG(0x40)
37#define S5P_CLK_GATE_HCLK1 S5P_CLKREG(0x44)
38#define S5P_CLK_GATE_SCLK1 S5P_CLKREG(0x48)
39#define S5P_AHB_CON0 S5P_CLKREG(0x100)
40#define S5P_CLK_SRC1 S5P_CLKREG(0x10C)
41#define S5P_SWRESET S5P_CLKREG(0x114)
42#define S5P_SYS_ID S5P_CLKREG(0x118)
43#define S5P_SYS_OTHERS S5P_CLKREG(0x11C)
44#define S5P_MEM_CFG_STAT S5P_CLKREG(0x12C)
45#define S5P_PWR_CFG S5P_CLKREG(0x804)
46#define S5P_EINT_WAKEUP_MASK S5P_CLKREG(0x808)
47#define S5P_NORMAL_CFG S5P_CLKREG(0x810)
48#define S5P_STOP_CFG S5P_CLKREG(0x814)
49#define S5P_SLEEP_CFG S5P_CLKREG(0x818)
50#define S5P_OSC_FREQ S5P_CLKREG(0x820)
51#define S5P_OSC_STABLE S5P_CLKREG(0x824)
52#define S5P_PWR_STABLE S5P_CLKREG(0x828)
53#define S5P_MTC_STABLE S5P_CLKREG(0x830)
54#define S5P_OTHERS S5P_CLKREG(0x900)
55#define S5P_RST_STAT S5P_CLKREG(0x904)
56#define S5P_WAKEUP_STAT S5P_CLKREG(0x908)
57#define S5P_SLPEN S5P_CLKREG(0x930)
58#define S5P_INFORM0 S5P_CLKREG(0xA00)
59#define S5P_INFORM1 S5P_CLKREG(0xA04)
60#define S5P_INFORM2 S5P_CLKREG(0xA08)
61#define S5P_INFORM3 S5P_CLKREG(0xA0C)
62
63/* CLKDIV0 */
64#define S5P_CLKDIV0_PCLK_MASK (0xf << 12)
65#define S5P_CLKDIV0_PCLK_SHIFT (12)
66#define S5P_CLKDIV0_HCLK_MASK (0xf << 8)
67#define S5P_CLKDIV0_HCLK_SHIFT (8)
68#define S5P_CLKDIV0_MPLL_MASK (0x1 << 4)
69#define S5P_CLKDIV0_ARM_MASK (0xf << 0)
70#define S5P_CLKDIV0_ARM_SHIFT (0)
71
72/* CLKDIV3 */
73#define S5P_CLKDIV3_PCLK_LOW_MASK (0xf << 12)
74#define S5P_CLKDIV3_PCLK_LOW_SHIFT (12)
75#define S5P_CLKDIV3_HCLK_LOW_MASK (0xf << 8)
76#define S5P_CLKDIV3_HCLK_LOW_SHIFT (8)
77
78/* HCLK0 GATE Registers */
79#define S5P_CLKCON_HCLK0_USB (1<<20)
80#define S5P_CLKCON_HCLK0_HSMMC2 (1<<19)
81#define S5P_CLKCON_HCLK0_HSMMC1 (1<<18)
82#define S5P_CLKCON_HCLK0_HSMMC0 (1<<17)
83#define S5P_CLKCON_HCLK0_POST0 (1<<5)
84
85/* HCLK1 GATE Registers */
86#define S5P_CLKCON_HCLK1_DISPCON (1<<1)
87
88/* PCLK GATE Registers */
89#define S5P_CLKCON_PCLK_IIS2 (1<<26)
90#define S5P_CLKCON_PCLK_SPI1 (1<<22)
91#define S5P_CLKCON_PCLK_SPI0 (1<<21)
92#define S5P_CLKCON_PCLK_GPIO (1<<18)
93#define S5P_CLKCON_PCLK_IIC0 (1<<17)
94#define S5P_CLKCON_PCLK_TSADC (1<<12)
95#define S5P_CLKCON_PCLK_PWM (1<<7)
96#define S5P_CLKCON_PCLK_RTC (1<<6)
97#define S5P_CLKCON_PCLK_WDT (1<<5)
98#define S5P_CLKCON_PCLK_UART3 (1<<4)
99#define S5P_CLKCON_PCLK_UART2 (1<<3)
100#define S5P_CLKCON_PCLK_UART1 (1<<2)
101#define S5P_CLKCON_PCLK_UART0 (1<<1)
102
103/* SCLK0 GATE Registers */
104#define S5P_CLKCON_SCLK0_MMC2_48 (1<<29)
105#define S5P_CLKCON_SCLK0_MMC1_48 (1<<28)
106#define S5P_CLKCON_SCLK0_MMC0_48 (1<<27)
107#define S5P_CLKCON_SCLK0_MMC2 (1<<26)
108#define S5P_CLKCON_SCLK0_MMC1 (1<<25)
109#define S5P_CLKCON_SCLK0_MMC0 (1<<24)
110#define S5P_CLKCON_SCLK0_SPI1_48 (1<<23)
111#define S5P_CLKCON_SCLK0_SPI0_48 (1<<22)
112#define S5P_CLKCON_SCLK0_SPI1 (1<<21)
113#define S5P_CLKCON_SCLK0_SPI0 (1<<20)
114#define S5P_CLKCON_SCLK0_UART (1<<5)
115
116/* SCLK1 GATE Registers */
117
118/* MEM0 GATE Registers */
119#define S5P_CLKCON_MEM0_HCLK_NFCON (1<<2)
120
121/*OTHERS Resgister */
122#define S5P_OTHERS_USB_SIG_MASK (1<<16)
123#define S5P_OTHERS_HCLK_LOW_SEL_MPLL (1<<6)
124
125/* Compatibility defines */
126#define ARM_CLK_DIV S5P_CLK_DIV0
127#define ARM_DIV_RATIO_SHIFT 0
128#define ARM_DIV_MASK (0xf << ARM_DIV_RATIO_SHIFT)
129
130#endif /* __ASM_ARCH_REGS_CLOCK_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/spi-clocks.h b/arch/arm/mach-s5p6440/include/mach/spi-clocks.h
deleted file mode 100644
index 5fbca50d1cfb..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/spi-clocks.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/spi-clocks.h
2 *
3 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __S5P6440_PLAT_SPI_CLKS_H
12#define __S5P6440_PLAT_SPI_CLKS_H __FILE__
13
14#define S5P6440_SPI_SRCCLK_PCLK 0
15#define S5P6440_SPI_SRCCLK_SCLK 1
16
17#endif /* __S5P6440_PLAT_SPI_CLKS_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/uncompress.h b/arch/arm/mach-s5p6440/include/mach/uncompress.h
deleted file mode 100644
index 7c1f600d65c0..000000000000
--- a/arch/arm/mach-s5p6440/include/mach/uncompress.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/uncompress.h
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - uncompress code
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_UNCOMPRESS_H
14#define __ASM_ARCH_UNCOMPRESS_H
15
16#include <mach/map.h>
17#include <plat/uncompress.h>
18
19static void arch_detect_cpu(void)
20{
21 /* we do not need to do any cpu detection here at the moment. */
22}
23
24#endif /* __ASM_ARCH_UNCOMPRESS_H */
diff --git a/arch/arm/mach-s5p6440/init.c b/arch/arm/mach-s5p6440/init.c
deleted file mode 100644
index a1f3727e4021..000000000000
--- a/arch/arm/mach-s5p6440/init.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* linux/arch/arm/mach-s5p6440/init.c
2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P6440 - Init support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/init.h>
16#include <linux/serial_core.h>
17
18#include <plat/cpu.h>
19#include <plat/devs.h>
20#include <plat/s5p6440.h>
21#include <plat/regs-serial.h>
22
23static struct s3c24xx_uart_clksrc s5p6440_serial_clocks[] = {
24 [0] = {
25 .name = "pclk_low",
26 .divisor = 1,
27 .min_baud = 0,
28 .max_baud = 0,
29 },
30 [1] = {
31 .name = "uclk1",
32 .divisor = 1,
33 .min_baud = 0,
34 .max_baud = 0,
35 },
36};
37
38/* uart registration process */
39void __init s5p6440_common_init_uarts(struct s3c2410_uartcfg *cfg, int no)
40{
41 struct s3c2410_uartcfg *tcfg = cfg;
42 u32 ucnt;
43
44 for (ucnt = 0; ucnt < no; ucnt++, tcfg++) {
45 if (!tcfg->clocks) {
46 tcfg->clocks = s5p6440_serial_clocks;
47 tcfg->clocks_size = ARRAY_SIZE(s5p6440_serial_clocks);
48 }
49 }
50
51 s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
52}
diff --git a/arch/arm/mach-s5p6442/cpu.c b/arch/arm/mach-s5p6442/cpu.c
index a48fb553fd01..842af86bda6d 100644
--- a/arch/arm/mach-s5p6442/cpu.c
+++ b/arch/arm/mach-s5p6442/cpu.c
@@ -1,7 +1,7 @@
1/* linux/arch/arm/mach-s5p6442/cpu.c 1/* linux/arch/arm/mach-s5p6442/cpu.c
2 * 2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -19,6 +19,7 @@
19#include <linux/sysdev.h> 19#include <linux/sysdev.h>
20#include <linux/serial_core.h> 20#include <linux/serial_core.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/sched.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
@@ -47,10 +48,30 @@ static struct map_desc s5p6442_iodesc[] __initdata = {
47 .length = SZ_16K, 48 .length = SZ_16K,
48 .type = MT_DEVICE, 49 .type = MT_DEVICE,
49 }, { 50 }, {
51 .virtual = (unsigned long)S5P_VA_GPIO,
52 .pfn = __phys_to_pfn(S5P6442_PA_GPIO),
53 .length = SZ_4K,
54 .type = MT_DEVICE,
55 }, {
56 .virtual = (unsigned long)VA_VIC0,
57 .pfn = __phys_to_pfn(S5P6442_PA_VIC0),
58 .length = SZ_16K,
59 .type = MT_DEVICE,
60 }, {
61 .virtual = (unsigned long)VA_VIC1,
62 .pfn = __phys_to_pfn(S5P6442_PA_VIC1),
63 .length = SZ_16K,
64 .type = MT_DEVICE,
65 }, {
50 .virtual = (unsigned long)VA_VIC2, 66 .virtual = (unsigned long)VA_VIC2,
51 .pfn = __phys_to_pfn(S5P6442_PA_VIC2), 67 .pfn = __phys_to_pfn(S5P6442_PA_VIC2),
52 .length = SZ_16K, 68 .length = SZ_16K,
53 .type = MT_DEVICE, 69 .type = MT_DEVICE,
70 }, {
71 .virtual = (unsigned long)S3C_VA_UART,
72 .pfn = __phys_to_pfn(S3C_PA_UART),
73 .length = SZ_512K,
74 .type = MT_DEVICE,
54 } 75 }
55}; 76};
56 77
@@ -62,10 +83,11 @@ static void s5p6442_idle(void)
62 local_irq_enable(); 83 local_irq_enable();
63} 84}
64 85
65/* s5p6442_map_io 86/*
87 * s5p6442_map_io
66 * 88 *
67 * register the standard cpu IO areas 89 * register the standard cpu IO areas
68*/ 90 */
69 91
70void __init s5p6442_map_io(void) 92void __init s5p6442_map_io(void)
71{ 93{
diff --git a/arch/arm/mach-s5p6442/include/mach/debug-macro.S b/arch/arm/mach-s5p6442/include/mach/debug-macro.S
index bb6536147ffb..e2213205d780 100644
--- a/arch/arm/mach-s5p6442/include/mach/debug-macro.S
+++ b/arch/arm/mach-s5p6442/include/mach/debug-macro.S
@@ -15,13 +15,12 @@
15#include <mach/map.h> 15#include <mach/map.h>
16#include <plat/regs-serial.h> 16#include <plat/regs-serial.h>
17 17
18 .macro addruart, rx, rtmp 18 .macro addruart, rp, rv
19 mrc p15, 0, \rx, c1, c0 19 ldr \rp, = S3C_PA_UART
20 tst \rx, #1 20 ldr \rv, = S3C_VA_UART
21 ldreq \rx, = S3C_PA_UART
22 ldrne \rx, = S3C_VA_UART
23#if CONFIG_DEBUG_S3C_UART != 0 21#if CONFIG_DEBUG_S3C_UART != 0
24 add \rx, \rx, #(0x400 * CONFIG_DEBUG_S3C_UART) 22 add \rp, \rp, #(0x400 * CONFIG_DEBUG_S3C_UART)
23 add \rv, \rv, #(0x400 * CONFIG_DEBUG_S3C_UART)
25#endif 24#endif
26 .endm 25 .endm
27 26
diff --git a/arch/arm/mach-s5p6442/include/mach/map.h b/arch/arm/mach-s5p6442/include/mach/map.h
index 281d256faafb..31fb2e68d527 100644
--- a/arch/arm/mach-s5p6442/include/mach/map.h
+++ b/arch/arm/mach-s5p6442/include/mach/map.h
@@ -23,16 +23,10 @@
23#define S5P_PA_SYSCON S5P6442_PA_SYSCON 23#define S5P_PA_SYSCON S5P6442_PA_SYSCON
24 24
25#define S5P6442_PA_GPIO (0xE0200000) 25#define S5P6442_PA_GPIO (0xE0200000)
26#define S5P_PA_GPIO S5P6442_PA_GPIO
27 26
28#define S5P6442_PA_VIC0 (0xE4000000) 27#define S5P6442_PA_VIC0 (0xE4000000)
29#define S5P_PA_VIC0 S5P6442_PA_VIC0
30
31#define S5P6442_PA_VIC1 (0xE4100000) 28#define S5P6442_PA_VIC1 (0xE4100000)
32#define S5P_PA_VIC1 S5P6442_PA_VIC1
33
34#define S5P6442_PA_VIC2 (0xE4200000) 29#define S5P6442_PA_VIC2 (0xE4200000)
35#define S5P_PA_VIC2 S5P6442_PA_VIC2
36 30
37#define S5P6442_PA_MDMA 0xE8000000 31#define S5P6442_PA_MDMA 0xE8000000
38#define S5P6442_PA_PDMA 0xE9000000 32#define S5P6442_PA_PDMA 0xE9000000
diff --git a/arch/arm/mach-s5p6442/mach-smdk6442.c b/arch/arm/mach-s5p6442/mach-smdk6442.c
index 8d8d04272f85..819fd80d00af 100644
--- a/arch/arm/mach-s5p6442/mach-smdk6442.c
+++ b/arch/arm/mach-s5p6442/mach-smdk6442.c
@@ -83,8 +83,6 @@ static void __init smdk6442_machine_init(void)
83 83
84MACHINE_START(SMDK6442, "SMDK6442") 84MACHINE_START(SMDK6442, "SMDK6442")
85 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 85 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
86 .phys_io = S3C_PA_UART & 0xfff00000,
87 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
88 .boot_params = S5P_PA_SDRAM + 0x100, 86 .boot_params = S5P_PA_SDRAM + 0x100,
89 .init_irq = s5p6442_init_irq, 87 .init_irq = s5p6442_init_irq,
90 .map_io = smdk6442_map_io, 88 .map_io = smdk6442_map_io,
diff --git a/arch/arm/mach-s5p64x0/Kconfig b/arch/arm/mach-s5p64x0/Kconfig
new file mode 100644
index 000000000000..fbcae9352022
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/Kconfig
@@ -0,0 +1,57 @@
1# arch/arm/mach-s5p64x0/Kconfig
2#
3# Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4# http://www.samsung.com/
5#
6# Licensed under GPLv2
7
8if ARCH_S5P64X0
9
10config CPU_S5P6440
11 bool
12 select PLAT_S5P
13 select S3C_PL330_DMA
14 help
15 Enable S5P6440 CPU support
16
17config CPU_S5P6450
18 bool
19 select PLAT_S5P
20 select S3C_PL330_DMA
21 help
22 Enable S5P6450 CPU support
23
24config S5P64X0_SETUP_I2C1
25 bool
26 help
27 Common setup code for i2c bus 1.
28
29# machine support
30
31config MACH_SMDK6440
32 bool "SMDK6440"
33 select CPU_S5P6440
34 select S3C_DEV_I2C1
35 select S3C_DEV_RTC
36 select S3C_DEV_WDT
37 select S3C64XX_DEV_SPI
38 select SAMSUNG_DEV_ADC
39 select SAMSUNG_DEV_TS
40 select S5P64X0_SETUP_I2C1
41 help
42 Machine support for the Samsung SMDK6440
43
44config MACH_SMDK6450
45 bool "SMDK6450"
46 select CPU_S5P6450
47 select S3C_DEV_I2C1
48 select S3C_DEV_RTC
49 select S3C_DEV_WDT
50 select S3C64XX_DEV_SPI
51 select SAMSUNG_DEV_ADC
52 select SAMSUNG_DEV_TS
53 select S5P64X0_SETUP_I2C1
54 help
55 Machine support for the Samsung SMDK6450
56
57endif
diff --git a/arch/arm/mach-s5p64x0/Makefile b/arch/arm/mach-s5p64x0/Makefile
new file mode 100644
index 000000000000..2655829e6bf8
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/Makefile
@@ -0,0 +1,30 @@
1# arch/arm/mach-s5p64x0/Makefile
2#
3# Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4# http://www.samsung.com
5#
6# Licensed under GPLv2
7
8obj-y :=
9obj-m :=
10obj-n :=
11obj- :=
12
13# Core support for S5P64X0 system
14
15obj-$(CONFIG_ARCH_S5P64X0) += cpu.o init.o clock.o dma.o
16obj-$(CONFIG_ARCH_S5P64X0) += setup-i2c0.o
17obj-$(CONFIG_CPU_S5P6440) += clock-s5p6440.o gpio.o
18obj-$(CONFIG_CPU_S5P6450) += clock-s5p6450.o
19
20# machine support
21
22obj-$(CONFIG_MACH_SMDK6440) += mach-smdk6440.o
23obj-$(CONFIG_MACH_SMDK6450) += mach-smdk6450.o
24
25# device support
26
27obj-y += dev-audio.o
28obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o
29
30obj-$(CONFIG_S5P64X0_SETUP_I2C1) += setup-i2c1.o
diff --git a/arch/arm/mach-s5p6440/Makefile.boot b/arch/arm/mach-s5p64x0/Makefile.boot
index ff90aa13bd67..ff90aa13bd67 100644
--- a/arch/arm/mach-s5p6440/Makefile.boot
+++ b/arch/arm/mach-s5p64x0/Makefile.boot
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c
new file mode 100644
index 000000000000..f93dcd8b4d6a
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
@@ -0,0 +1,626 @@
1/* linux/arch/arm/mach-s5p64x0/clock-s5p6440.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P6440 - Clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22
23#include <mach/hardware.h>
24#include <mach/map.h>
25#include <mach/regs-clock.h>
26#include <mach/s5p64x0-clock.h>
27
28#include <plat/cpu-freq.h>
29#include <plat/clock.h>
30#include <plat/cpu.h>
31#include <plat/pll.h>
32#include <plat/s5p-clock.h>
33#include <plat/clock-clksrc.h>
34#include <plat/s5p6440.h>
35
36static u32 epll_div[][5] = {
37 { 36000000, 0, 48, 1, 4 },
38 { 48000000, 0, 32, 1, 3 },
39 { 60000000, 0, 40, 1, 3 },
40 { 72000000, 0, 48, 1, 3 },
41 { 84000000, 0, 28, 1, 2 },
42 { 96000000, 0, 32, 1, 2 },
43 { 32768000, 45264, 43, 1, 4 },
44 { 45158000, 6903, 30, 1, 3 },
45 { 49152000, 50332, 32, 1, 3 },
46 { 67738000, 10398, 45, 1, 3 },
47 { 73728000, 9961, 49, 1, 3 }
48};
49
50static int s5p6440_epll_set_rate(struct clk *clk, unsigned long rate)
51{
52 unsigned int epll_con, epll_con_k;
53 unsigned int i;
54
55 if (clk->rate == rate) /* Return if nothing changed */
56 return 0;
57
58 epll_con = __raw_readl(S5P64X0_EPLL_CON);
59 epll_con_k = __raw_readl(S5P64X0_EPLL_CON_K);
60
61 epll_con_k &= ~(PLL90XX_KDIV_MASK);
62 epll_con &= ~(PLL90XX_MDIV_MASK | PLL90XX_PDIV_MASK | PLL90XX_SDIV_MASK);
63
64 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
65 if (epll_div[i][0] == rate) {
66 epll_con_k |= (epll_div[i][1] << PLL90XX_KDIV_SHIFT);
67 epll_con |= (epll_div[i][2] << PLL90XX_MDIV_SHIFT) |
68 (epll_div[i][3] << PLL90XX_PDIV_SHIFT) |
69 (epll_div[i][4] << PLL90XX_SDIV_SHIFT);
70 break;
71 }
72 }
73
74 if (i == ARRAY_SIZE(epll_div)) {
75 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n", __func__);
76 return -EINVAL;
77 }
78
79 __raw_writel(epll_con, S5P64X0_EPLL_CON);
80 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
81
82 clk->rate = rate;
83
84 return 0;
85}
86
87static struct clk_ops s5p6440_epll_ops = {
88 .get_rate = s5p64x0_epll_get_rate,
89 .set_rate = s5p6440_epll_set_rate,
90};
91
92static struct clksrc_clk clk_hclk = {
93 .clk = {
94 .name = "clk_hclk",
95 .id = -1,
96 .parent = &clk_armclk.clk,
97 },
98 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 8, .size = 4 },
99};
100
101static struct clksrc_clk clk_pclk = {
102 .clk = {
103 .name = "clk_pclk",
104 .id = -1,
105 .parent = &clk_hclk.clk,
106 },
107 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 12, .size = 4 },
108};
109static struct clksrc_clk clk_hclk_low = {
110 .clk = {
111 .name = "clk_hclk_low",
112 .id = -1,
113 },
114 .sources = &clkset_hclk_low,
115 .reg_src = { .reg = S5P64X0_SYS_OTHERS, .shift = 6, .size = 1 },
116 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 8, .size = 4 },
117};
118
119static struct clksrc_clk clk_pclk_low = {
120 .clk = {
121 .name = "clk_pclk_low",
122 .id = -1,
123 .parent = &clk_hclk_low.clk,
124 },
125 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 12, .size = 4 },
126};
127
128/*
129 * The following clocks will be disabled during clock initialization. It is
130 * recommended to keep the following clocks disabled until the driver requests
131 * for enabling the clock.
132 */
133static struct clk init_clocks_disable[] = {
134 {
135 .name = "nand",
136 .id = -1,
137 .parent = &clk_hclk.clk,
138 .enable = s5p64x0_mem_ctrl,
139 .ctrlbit = (1 << 2),
140 }, {
141 .name = "post",
142 .id = -1,
143 .parent = &clk_hclk_low.clk,
144 .enable = s5p64x0_hclk0_ctrl,
145 .ctrlbit = (1 << 5)
146 }, {
147 .name = "2d",
148 .id = -1,
149 .parent = &clk_hclk.clk,
150 .enable = s5p64x0_hclk0_ctrl,
151 .ctrlbit = (1 << 8),
152 }, {
153 .name = "hsmmc",
154 .id = 0,
155 .parent = &clk_hclk_low.clk,
156 .enable = s5p64x0_hclk0_ctrl,
157 .ctrlbit = (1 << 17),
158 }, {
159 .name = "hsmmc",
160 .id = 1,
161 .parent = &clk_hclk_low.clk,
162 .enable = s5p64x0_hclk0_ctrl,
163 .ctrlbit = (1 << 18),
164 }, {
165 .name = "hsmmc",
166 .id = 2,
167 .parent = &clk_hclk_low.clk,
168 .enable = s5p64x0_hclk0_ctrl,
169 .ctrlbit = (1 << 19),
170 }, {
171 .name = "otg",
172 .id = -1,
173 .parent = &clk_hclk_low.clk,
174 .enable = s5p64x0_hclk0_ctrl,
175 .ctrlbit = (1 << 20)
176 }, {
177 .name = "irom",
178 .id = -1,
179 .parent = &clk_hclk.clk,
180 .enable = s5p64x0_hclk0_ctrl,
181 .ctrlbit = (1 << 25),
182 }, {
183 .name = "lcd",
184 .id = -1,
185 .parent = &clk_hclk_low.clk,
186 .enable = s5p64x0_hclk1_ctrl,
187 .ctrlbit = (1 << 1),
188 }, {
189 .name = "hclk_fimgvg",
190 .id = -1,
191 .parent = &clk_hclk.clk,
192 .enable = s5p64x0_hclk1_ctrl,
193 .ctrlbit = (1 << 2),
194 }, {
195 .name = "tsi",
196 .id = -1,
197 .parent = &clk_hclk_low.clk,
198 .enable = s5p64x0_hclk1_ctrl,
199 .ctrlbit = (1 << 0),
200 }, {
201 .name = "watchdog",
202 .id = -1,
203 .parent = &clk_pclk_low.clk,
204 .enable = s5p64x0_pclk_ctrl,
205 .ctrlbit = (1 << 5),
206 }, {
207 .name = "rtc",
208 .id = -1,
209 .parent = &clk_pclk_low.clk,
210 .enable = s5p64x0_pclk_ctrl,
211 .ctrlbit = (1 << 6),
212 }, {
213 .name = "timers",
214 .id = -1,
215 .parent = &clk_pclk_low.clk,
216 .enable = s5p64x0_pclk_ctrl,
217 .ctrlbit = (1 << 7),
218 }, {
219 .name = "pcm",
220 .id = -1,
221 .parent = &clk_pclk_low.clk,
222 .enable = s5p64x0_pclk_ctrl,
223 .ctrlbit = (1 << 8),
224 }, {
225 .name = "adc",
226 .id = -1,
227 .parent = &clk_pclk_low.clk,
228 .enable = s5p64x0_pclk_ctrl,
229 .ctrlbit = (1 << 12),
230 }, {
231 .name = "i2c",
232 .id = -1,
233 .parent = &clk_pclk_low.clk,
234 .enable = s5p64x0_pclk_ctrl,
235 .ctrlbit = (1 << 17),
236 }, {
237 .name = "spi",
238 .id = 0,
239 .parent = &clk_pclk_low.clk,
240 .enable = s5p64x0_pclk_ctrl,
241 .ctrlbit = (1 << 21),
242 }, {
243 .name = "spi",
244 .id = 1,
245 .parent = &clk_pclk_low.clk,
246 .enable = s5p64x0_pclk_ctrl,
247 .ctrlbit = (1 << 22),
248 }, {
249 .name = "gps",
250 .id = -1,
251 .parent = &clk_pclk_low.clk,
252 .enable = s5p64x0_pclk_ctrl,
253 .ctrlbit = (1 << 25),
254 }, {
255 .name = "i2s_v40",
256 .id = 0,
257 .parent = &clk_pclk_low.clk,
258 .enable = s5p64x0_pclk_ctrl,
259 .ctrlbit = (1 << 26),
260 }, {
261 .name = "dsim",
262 .id = -1,
263 .parent = &clk_pclk_low.clk,
264 .enable = s5p64x0_pclk_ctrl,
265 .ctrlbit = (1 << 28),
266 }, {
267 .name = "etm",
268 .id = -1,
269 .parent = &clk_pclk.clk,
270 .enable = s5p64x0_pclk_ctrl,
271 .ctrlbit = (1 << 29),
272 }, {
273 .name = "dmc0",
274 .id = -1,
275 .parent = &clk_pclk.clk,
276 .enable = s5p64x0_pclk_ctrl,
277 .ctrlbit = (1 << 30),
278 }, {
279 .name = "pclk_fimgvg",
280 .id = -1,
281 .parent = &clk_pclk.clk,
282 .enable = s5p64x0_pclk_ctrl,
283 .ctrlbit = (1 << 31),
284 }, {
285 .name = "sclk_spi_48",
286 .id = 0,
287 .parent = &clk_48m,
288 .enable = s5p64x0_sclk_ctrl,
289 .ctrlbit = (1 << 22),
290 }, {
291 .name = "sclk_spi_48",
292 .id = 1,
293 .parent = &clk_48m,
294 .enable = s5p64x0_sclk_ctrl,
295 .ctrlbit = (1 << 23),
296 }, {
297 .name = "mmc_48m",
298 .id = 0,
299 .parent = &clk_48m,
300 .enable = s5p64x0_sclk_ctrl,
301 .ctrlbit = (1 << 27),
302 }, {
303 .name = "mmc_48m",
304 .id = 1,
305 .parent = &clk_48m,
306 .enable = s5p64x0_sclk_ctrl,
307 .ctrlbit = (1 << 28),
308 }, {
309 .name = "mmc_48m",
310 .id = 2,
311 .parent = &clk_48m,
312 .enable = s5p64x0_sclk_ctrl,
313 .ctrlbit = (1 << 29),
314 },
315};
316
317/*
318 * The following clocks will be enabled during clock initialization.
319 */
320static struct clk init_clocks[] = {
321 {
322 .name = "intc",
323 .id = -1,
324 .parent = &clk_hclk.clk,
325 .enable = s5p64x0_hclk0_ctrl,
326 .ctrlbit = (1 << 1),
327 }, {
328 .name = "mem",
329 .id = -1,
330 .parent = &clk_hclk.clk,
331 .enable = s5p64x0_hclk0_ctrl,
332 .ctrlbit = (1 << 21),
333 }, {
334 .name = "dma",
335 .id = -1,
336 .parent = &clk_hclk_low.clk,
337 .enable = s5p64x0_hclk0_ctrl,
338 .ctrlbit = (1 << 12),
339 }, {
340 .name = "uart",
341 .id = 0,
342 .parent = &clk_pclk_low.clk,
343 .enable = s5p64x0_pclk_ctrl,
344 .ctrlbit = (1 << 1),
345 }, {
346 .name = "uart",
347 .id = 1,
348 .parent = &clk_pclk_low.clk,
349 .enable = s5p64x0_pclk_ctrl,
350 .ctrlbit = (1 << 2),
351 }, {
352 .name = "uart",
353 .id = 2,
354 .parent = &clk_pclk_low.clk,
355 .enable = s5p64x0_pclk_ctrl,
356 .ctrlbit = (1 << 3),
357 }, {
358 .name = "uart",
359 .id = 3,
360 .parent = &clk_pclk_low.clk,
361 .enable = s5p64x0_pclk_ctrl,
362 .ctrlbit = (1 << 4),
363 }, {
364 .name = "gpio",
365 .id = -1,
366 .parent = &clk_pclk_low.clk,
367 .enable = s5p64x0_pclk_ctrl,
368 .ctrlbit = (1 << 18),
369 },
370};
371
372static struct clk clk_iis_cd_v40 = {
373 .name = "iis_cdclk_v40",
374 .id = -1,
375};
376
377static struct clk clk_pcm_cd = {
378 .name = "pcm_cdclk",
379 .id = -1,
380};
381
382static struct clk *clkset_group1_list[] = {
383 &clk_mout_epll.clk,
384 &clk_dout_mpll.clk,
385 &clk_fin_epll,
386};
387
388static struct clksrc_sources clkset_group1 = {
389 .sources = clkset_group1_list,
390 .nr_sources = ARRAY_SIZE(clkset_group1_list),
391};
392
393static struct clk *clkset_uart_list[] = {
394 &clk_mout_epll.clk,
395 &clk_dout_mpll.clk,
396};
397
398static struct clksrc_sources clkset_uart = {
399 .sources = clkset_uart_list,
400 .nr_sources = ARRAY_SIZE(clkset_uart_list),
401};
402
403static struct clk *clkset_audio_list[] = {
404 &clk_mout_epll.clk,
405 &clk_dout_mpll.clk,
406 &clk_fin_epll,
407 &clk_iis_cd_v40,
408 &clk_pcm_cd,
409};
410
411static struct clksrc_sources clkset_audio = {
412 .sources = clkset_audio_list,
413 .nr_sources = ARRAY_SIZE(clkset_audio_list),
414};
415
416static struct clksrc_clk clksrcs[] = {
417 {
418 .clk = {
419 .name = "mmc_bus",
420 .id = 0,
421 .ctrlbit = (1 << 24),
422 .enable = s5p64x0_sclk_ctrl,
423 },
424 .sources = &clkset_group1,
425 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 18, .size = 2 },
426 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 0, .size = 4 },
427 }, {
428 .clk = {
429 .name = "mmc_bus",
430 .id = 1,
431 .ctrlbit = (1 << 25),
432 .enable = s5p64x0_sclk_ctrl,
433 },
434 .sources = &clkset_group1,
435 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 20, .size = 2 },
436 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 4, .size = 4 },
437 }, {
438 .clk = {
439 .name = "mmc_bus",
440 .id = 2,
441 .ctrlbit = (1 << 26),
442 .enable = s5p64x0_sclk_ctrl,
443 },
444 .sources = &clkset_group1,
445 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 22, .size = 2 },
446 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 8, .size = 4 },
447 }, {
448 .clk = {
449 .name = "uclk1",
450 .id = -1,
451 .ctrlbit = (1 << 5),
452 .enable = s5p64x0_sclk_ctrl,
453 },
454 .sources = &clkset_uart,
455 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 13, .size = 1 },
456 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
457 }, {
458 .clk = {
459 .name = "sclk_spi",
460 .id = 0,
461 .ctrlbit = (1 << 20),
462 .enable = s5p64x0_sclk_ctrl,
463 },
464 .sources = &clkset_group1,
465 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 14, .size = 2 },
466 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 0, .size = 4 },
467 }, {
468 .clk = {
469 .name = "sclk_spi",
470 .id = 1,
471 .ctrlbit = (1 << 21),
472 .enable = s5p64x0_sclk_ctrl,
473 },
474 .sources = &clkset_group1,
475 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 16, .size = 2 },
476 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
477 }, {
478 .clk = {
479 .name = "sclk_post",
480 .id = -1,
481 .ctrlbit = (1 << 10),
482 .enable = s5p64x0_sclk_ctrl,
483 },
484 .sources = &clkset_group1,
485 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 26, .size = 2 },
486 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 12, .size = 4 },
487 }, {
488 .clk = {
489 .name = "sclk_dispcon",
490 .id = -1,
491 .ctrlbit = (1 << 1),
492 .enable = s5p64x0_sclk1_ctrl,
493 },
494 .sources = &clkset_group1,
495 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 4, .size = 2 },
496 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 0, .size = 4 },
497 }, {
498 .clk = {
499 .name = "sclk_fimgvg",
500 .id = -1,
501 .ctrlbit = (1 << 2),
502 .enable = s5p64x0_sclk1_ctrl,
503 },
504 .sources = &clkset_group1,
505 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
506 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
507 }, {
508 .clk = {
509 .name = "sclk_audio2",
510 .id = -1,
511 .ctrlbit = (1 << 11),
512 .enable = s5p64x0_sclk_ctrl,
513 },
514 .sources = &clkset_audio,
515 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 0, .size = 3 },
516 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 24, .size = 4 },
517 },
518};
519
520/* Clock initialization code */
521static struct clksrc_clk *sysclks[] = {
522 &clk_mout_apll,
523 &clk_mout_epll,
524 &clk_mout_mpll,
525 &clk_dout_mpll,
526 &clk_armclk,
527 &clk_hclk,
528 &clk_pclk,
529 &clk_hclk_low,
530 &clk_pclk_low,
531};
532
533void __init_or_cpufreq s5p6440_setup_clocks(void)
534{
535 struct clk *xtal_clk;
536
537 unsigned long xtal;
538 unsigned long fclk;
539 unsigned long hclk;
540 unsigned long hclk_low;
541 unsigned long pclk;
542 unsigned long pclk_low;
543
544 unsigned long apll;
545 unsigned long mpll;
546 unsigned long epll;
547 unsigned int ptr;
548
549 /* Set S5P6440 functions for clk_fout_epll */
550
551 clk_fout_epll.enable = s5p64x0_epll_enable;
552 clk_fout_epll.ops = &s5p6440_epll_ops;
553
554 clk_48m.enable = s5p64x0_clk48m_ctrl;
555
556 xtal_clk = clk_get(NULL, "ext_xtal");
557 BUG_ON(IS_ERR(xtal_clk));
558
559 xtal = clk_get_rate(xtal_clk);
560 clk_put(xtal_clk);
561
562 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_APLL_CON), pll_4502);
563 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_MPLL_CON), pll_4502);
564 epll = s5p_get_pll90xx(xtal, __raw_readl(S5P64X0_EPLL_CON),
565 __raw_readl(S5P64X0_EPLL_CON_K));
566
567 clk_fout_apll.rate = apll;
568 clk_fout_mpll.rate = mpll;
569 clk_fout_epll.rate = epll;
570
571 printk(KERN_INFO "S5P6440: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
572 " E=%ld.%ldMHz\n",
573 print_mhz(apll), print_mhz(mpll), print_mhz(epll));
574
575 fclk = clk_get_rate(&clk_armclk.clk);
576 hclk = clk_get_rate(&clk_hclk.clk);
577 pclk = clk_get_rate(&clk_pclk.clk);
578 hclk_low = clk_get_rate(&clk_hclk_low.clk);
579 pclk_low = clk_get_rate(&clk_pclk_low.clk);
580
581 printk(KERN_INFO "S5P6440: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
582 " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
583 print_mhz(hclk), print_mhz(hclk_low),
584 print_mhz(pclk), print_mhz(pclk_low));
585
586 clk_f.rate = fclk;
587 clk_h.rate = hclk;
588 clk_p.rate = pclk;
589
590 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
591 s3c_set_clksrc(&clksrcs[ptr], true);
592}
593
594static struct clk *clks[] __initdata = {
595 &clk_ext,
596 &clk_iis_cd_v40,
597 &clk_pcm_cd,
598};
599
600void __init s5p6440_register_clocks(void)
601{
602 struct clk *clkp;
603 int ret;
604 int ptr;
605
606 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
607
608 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
609 s3c_register_clksrc(sysclks[ptr], 1);
610
611 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
612 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
613
614 clkp = init_clocks_disable;
615 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
616
617 ret = s3c24xx_register_clock(clkp);
618 if (ret < 0) {
619 printk(KERN_ERR "Failed to register clock %s (%d)\n",
620 clkp->name, ret);
621 }
622 (clkp->enable)(clkp, 0);
623 }
624
625 s3c_pwmclk_init();
626}
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c
new file mode 100644
index 000000000000..f9afb05b217c
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
@@ -0,0 +1,655 @@
1/* linux/arch/arm/mach-s5p64x0/clock-s5p6450.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P6450 - Clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22
23#include <mach/hardware.h>
24#include <mach/map.h>
25#include <mach/regs-clock.h>
26#include <mach/s5p64x0-clock.h>
27
28#include <plat/cpu-freq.h>
29#include <plat/clock.h>
30#include <plat/cpu.h>
31#include <plat/pll.h>
32#include <plat/s5p-clock.h>
33#include <plat/clock-clksrc.h>
34#include <plat/s5p6450.h>
35
36static struct clksrc_clk clk_mout_dpll = {
37 .clk = {
38 .name = "mout_dpll",
39 .id = -1,
40 },
41 .sources = &clk_src_dpll,
42 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 5, .size = 1 },
43};
44
45static u32 epll_div[][5] = {
46 { 133000000, 27307, 55, 2, 2 },
47 { 100000000, 43691, 41, 2, 2 },
48 { 480000000, 0, 80, 2, 0 },
49};
50
51static int s5p6450_epll_set_rate(struct clk *clk, unsigned long rate)
52{
53 unsigned int epll_con, epll_con_k;
54 unsigned int i;
55
56 if (clk->rate == rate) /* Return if nothing changed */
57 return 0;
58
59 epll_con = __raw_readl(S5P64X0_EPLL_CON);
60 epll_con_k = __raw_readl(S5P64X0_EPLL_CON_K);
61
62 epll_con_k &= ~(PLL90XX_KDIV_MASK);
63 epll_con &= ~(PLL90XX_MDIV_MASK | PLL90XX_PDIV_MASK | PLL90XX_SDIV_MASK);
64
65 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
66 if (epll_div[i][0] == rate) {
67 epll_con_k |= (epll_div[i][1] << PLL90XX_KDIV_SHIFT);
68 epll_con |= (epll_div[i][2] << PLL90XX_MDIV_SHIFT) |
69 (epll_div[i][3] << PLL90XX_PDIV_SHIFT) |
70 (epll_div[i][4] << PLL90XX_SDIV_SHIFT);
71 break;
72 }
73 }
74
75 if (i == ARRAY_SIZE(epll_div)) {
76 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n", __func__);
77 return -EINVAL;
78 }
79
80 __raw_writel(epll_con, S5P64X0_EPLL_CON);
81 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
82
83 clk->rate = rate;
84
85 return 0;
86}
87
88static struct clk_ops s5p6450_epll_ops = {
89 .get_rate = s5p64x0_epll_get_rate,
90 .set_rate = s5p6450_epll_set_rate,
91};
92
93static struct clksrc_clk clk_dout_epll = {
94 .clk = {
95 .name = "dout_epll",
96 .id = -1,
97 .parent = &clk_mout_epll.clk,
98 },
99 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 24, .size = 4 },
100};
101
102static struct clksrc_clk clk_mout_hclk_sel = {
103 .clk = {
104 .name = "mout_hclk_sel",
105 .id = -1,
106 },
107 .sources = &clkset_hclk_low,
108 .reg_src = { .reg = S5P64X0_OTHERS, .shift = 15, .size = 1 },
109};
110
111static struct clk *clkset_hclk_list[] = {
112 &clk_mout_hclk_sel.clk,
113 &clk_armclk.clk,
114};
115
116static struct clksrc_sources clkset_hclk = {
117 .sources = clkset_hclk_list,
118 .nr_sources = ARRAY_SIZE(clkset_hclk_list),
119};
120
121static struct clksrc_clk clk_hclk = {
122 .clk = {
123 .name = "clk_hclk",
124 .id = -1,
125 },
126 .sources = &clkset_hclk,
127 .reg_src = { .reg = S5P64X0_OTHERS, .shift = 14, .size = 1 },
128 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 8, .size = 4 },
129};
130
131static struct clksrc_clk clk_pclk = {
132 .clk = {
133 .name = "clk_pclk",
134 .id = -1,
135 .parent = &clk_hclk.clk,
136 },
137 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 12, .size = 4 },
138};
139static struct clksrc_clk clk_dout_pwm_ratio0 = {
140 .clk = {
141 .name = "clk_dout_pwm_ratio0",
142 .id = -1,
143 .parent = &clk_mout_hclk_sel.clk,
144 },
145 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 16, .size = 4 },
146};
147
148static struct clksrc_clk clk_pclk_to_wdt_pwm = {
149 .clk = {
150 .name = "clk_pclk_to_wdt_pwm",
151 .id = -1,
152 .parent = &clk_dout_pwm_ratio0.clk,
153 },
154 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 20, .size = 4 },
155};
156
157static struct clksrc_clk clk_hclk_low = {
158 .clk = {
159 .name = "clk_hclk_low",
160 .id = -1,
161 },
162 .sources = &clkset_hclk_low,
163 .reg_src = { .reg = S5P64X0_OTHERS, .shift = 6, .size = 1 },
164 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 8, .size = 4 },
165};
166
167static struct clksrc_clk clk_pclk_low = {
168 .clk = {
169 .name = "clk_pclk_low",
170 .id = -1,
171 .parent = &clk_hclk_low.clk,
172 },
173 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 12, .size = 4 },
174};
175
176/*
177 * The following clocks will be disabled during clock initialization. It is
178 * recommended to keep the following clocks disabled until the driver requests
179 * for enabling the clock.
180 */
181static struct clk init_clocks_disable[] = {
182 {
183 .name = "usbhost",
184 .id = -1,
185 .parent = &clk_hclk_low.clk,
186 .enable = s5p64x0_hclk0_ctrl,
187 .ctrlbit = (1 << 3),
188 }, {
189 .name = "hsmmc",
190 .id = 0,
191 .parent = &clk_hclk_low.clk,
192 .enable = s5p64x0_hclk0_ctrl,
193 .ctrlbit = (1 << 17),
194 }, {
195 .name = "hsmmc",
196 .id = 1,
197 .parent = &clk_hclk_low.clk,
198 .enable = s5p64x0_hclk0_ctrl,
199 .ctrlbit = (1 << 18),
200 }, {
201 .name = "hsmmc",
202 .id = 2,
203 .parent = &clk_hclk_low.clk,
204 .enable = s5p64x0_hclk0_ctrl,
205 .ctrlbit = (1 << 19),
206 }, {
207 .name = "usbotg",
208 .id = -1,
209 .parent = &clk_hclk_low.clk,
210 .enable = s5p64x0_hclk0_ctrl,
211 .ctrlbit = (1 << 20),
212 }, {
213 .name = "lcd",
214 .id = -1,
215 .parent = &clk_h,
216 .enable = s5p64x0_hclk1_ctrl,
217 .ctrlbit = (1 << 1),
218 }, {
219 .name = "watchdog",
220 .id = -1,
221 .parent = &clk_pclk_low.clk,
222 .enable = s5p64x0_pclk_ctrl,
223 .ctrlbit = (1 << 5),
224 }, {
225 .name = "adc",
226 .id = -1,
227 .parent = &clk_pclk_low.clk,
228 .enable = s5p64x0_pclk_ctrl,
229 .ctrlbit = (1 << 12),
230 }, {
231 .name = "i2c",
232 .id = 0,
233 .parent = &clk_pclk_low.clk,
234 .enable = s5p64x0_pclk_ctrl,
235 .ctrlbit = (1 << 17),
236 }, {
237 .name = "spi",
238 .id = 0,
239 .parent = &clk_pclk_low.clk,
240 .enable = s5p64x0_pclk_ctrl,
241 .ctrlbit = (1 << 21),
242 }, {
243 .name = "spi",
244 .id = 1,
245 .parent = &clk_pclk_low.clk,
246 .enable = s5p64x0_pclk_ctrl,
247 .ctrlbit = (1 << 22),
248 }, {
249 .name = "iis",
250 .id = -1,
251 .parent = &clk_pclk_low.clk,
252 .enable = s5p64x0_pclk_ctrl,
253 .ctrlbit = (1 << 26),
254 }, {
255 .name = "i2c",
256 .id = 1,
257 .parent = &clk_pclk_low.clk,
258 .enable = s5p64x0_pclk_ctrl,
259 .ctrlbit = (1 << 27),
260 }, {
261 .name = "dmc0",
262 .id = -1,
263 .parent = &clk_pclk.clk,
264 .enable = s5p64x0_pclk_ctrl,
265 .ctrlbit = (1 << 30),
266 }
267};
268
269/*
270 * The following clocks will be enabled during clock initialization.
271 */
272static struct clk init_clocks[] = {
273 {
274 .name = "intc",
275 .id = -1,
276 .parent = &clk_hclk.clk,
277 .enable = s5p64x0_hclk0_ctrl,
278 .ctrlbit = (1 << 1),
279 }, {
280 .name = "mem",
281 .id = -1,
282 .parent = &clk_hclk.clk,
283 .enable = s5p64x0_hclk0_ctrl,
284 .ctrlbit = (1 << 21),
285 }, {
286 .name = "dma",
287 .id = -1,
288 .parent = &clk_hclk_low.clk,
289 .enable = s5p64x0_hclk0_ctrl,
290 .ctrlbit = (1 << 12),
291 }, {
292 .name = "uart",
293 .id = 0,
294 .parent = &clk_pclk_low.clk,
295 .enable = s5p64x0_pclk_ctrl,
296 .ctrlbit = (1 << 1),
297 }, {
298 .name = "uart",
299 .id = 1,
300 .parent = &clk_pclk_low.clk,
301 .enable = s5p64x0_pclk_ctrl,
302 .ctrlbit = (1 << 2),
303 }, {
304 .name = "uart",
305 .id = 2,
306 .parent = &clk_pclk_low.clk,
307 .enable = s5p64x0_pclk_ctrl,
308 .ctrlbit = (1 << 3),
309 }, {
310 .name = "uart",
311 .id = 3,
312 .parent = &clk_pclk_low.clk,
313 .enable = s5p64x0_pclk_ctrl,
314 .ctrlbit = (1 << 4),
315 }, {
316 .name = "timers",
317 .id = -1,
318 .parent = &clk_pclk_to_wdt_pwm.clk,
319 .enable = s5p64x0_pclk_ctrl,
320 .ctrlbit = (1 << 7),
321 }, {
322 .name = "gpio",
323 .id = -1,
324 .parent = &clk_pclk_low.clk,
325 .enable = s5p64x0_pclk_ctrl,
326 .ctrlbit = (1 << 18),
327 },
328};
329
330static struct clk *clkset_uart_list[] = {
331 &clk_dout_epll.clk,
332 &clk_dout_mpll.clk,
333};
334
335static struct clksrc_sources clkset_uart = {
336 .sources = clkset_uart_list,
337 .nr_sources = ARRAY_SIZE(clkset_uart_list),
338};
339
340static struct clk *clkset_mali_list[] = {
341 &clk_mout_epll.clk,
342 &clk_mout_apll.clk,
343 &clk_mout_mpll.clk,
344};
345
346static struct clksrc_sources clkset_mali = {
347 .sources = clkset_mali_list,
348 .nr_sources = ARRAY_SIZE(clkset_mali_list),
349};
350
351static struct clk *clkset_group2_list[] = {
352 &clk_dout_epll.clk,
353 &clk_dout_mpll.clk,
354 &clk_ext_xtal_mux,
355};
356
357static struct clksrc_sources clkset_group2 = {
358 .sources = clkset_group2_list,
359 .nr_sources = ARRAY_SIZE(clkset_group2_list),
360};
361
362static struct clk *clkset_dispcon_list[] = {
363 &clk_dout_epll.clk,
364 &clk_dout_mpll.clk,
365 &clk_ext_xtal_mux,
366 &clk_mout_dpll.clk,
367};
368
369static struct clksrc_sources clkset_dispcon = {
370 .sources = clkset_dispcon_list,
371 .nr_sources = ARRAY_SIZE(clkset_dispcon_list),
372};
373
374static struct clk *clkset_hsmmc44_list[] = {
375 &clk_dout_epll.clk,
376 &clk_dout_mpll.clk,
377 &clk_ext_xtal_mux,
378 &s5p_clk_27m,
379 &clk_48m,
380};
381
382static struct clksrc_sources clkset_hsmmc44 = {
383 .sources = clkset_hsmmc44_list,
384 .nr_sources = ARRAY_SIZE(clkset_hsmmc44_list),
385};
386
387static struct clk *clkset_sclk_audio0_list[] = {
388 [0] = &clk_dout_epll.clk,
389 [1] = &clk_dout_mpll.clk,
390 [2] = &clk_ext_xtal_mux,
391 [3] = NULL,
392 [4] = NULL,
393};
394
395static struct clksrc_sources clkset_sclk_audio0 = {
396 .sources = clkset_sclk_audio0_list,
397 .nr_sources = ARRAY_SIZE(clkset_sclk_audio0_list),
398};
399
400static struct clksrc_clk clk_sclk_audio0 = {
401 .clk = {
402 .name = "audio-bus",
403 .id = -1,
404 .enable = s5p64x0_sclk_ctrl,
405 .ctrlbit = (1 << 8),
406 .parent = &clk_dout_epll.clk,
407 },
408 .sources = &clkset_sclk_audio0,
409 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 10, .size = 3 },
410 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 8, .size = 4 },
411};
412
413static struct clksrc_clk clksrcs[] = {
414 {
415 .clk = {
416 .name = "sclk_mmc",
417 .id = 0,
418 .ctrlbit = (1 << 24),
419 .enable = s5p64x0_sclk_ctrl,
420 },
421 .sources = &clkset_group2,
422 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 18, .size = 2 },
423 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 0, .size = 4 },
424 }, {
425 .clk = {
426 .name = "sclk_mmc",
427 .id = 1,
428 .ctrlbit = (1 << 25),
429 .enable = s5p64x0_sclk_ctrl,
430 },
431 .sources = &clkset_group2,
432 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 20, .size = 2 },
433 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 4, .size = 4 },
434 }, {
435 .clk = {
436 .name = "sclk_mmc",
437 .id = 2,
438 .ctrlbit = (1 << 26),
439 .enable = s5p64x0_sclk_ctrl,
440 },
441 .sources = &clkset_group2,
442 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 22, .size = 2 },
443 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 8, .size = 4 },
444 }, {
445 .clk = {
446 .name = "uclk1",
447 .id = -1,
448 .ctrlbit = (1 << 5),
449 .enable = s5p64x0_sclk_ctrl,
450 },
451 .sources = &clkset_uart,
452 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 13, .size = 1 },
453 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 16, .size = 4 },
454 }, {
455 .clk = {
456 .name = "sclk_spi",
457 .id = 0,
458 .ctrlbit = (1 << 20),
459 .enable = s5p64x0_sclk_ctrl,
460 },
461 .sources = &clkset_group2,
462 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 14, .size = 2 },
463 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 0, .size = 4 },
464 }, {
465 .clk = {
466 .name = "sclk_spi",
467 .id = 1,
468 .ctrlbit = (1 << 21),
469 .enable = s5p64x0_sclk_ctrl,
470 },
471 .sources = &clkset_group2,
472 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 16, .size = 2 },
473 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 4, .size = 4 },
474 }, {
475 .clk = {
476 .name = "sclk_fimc",
477 .id = -1,
478 .ctrlbit = (1 << 10),
479 .enable = s5p64x0_sclk_ctrl,
480 },
481 .sources = &clkset_group2,
482 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 26, .size = 2 },
483 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 12, .size = 4 },
484 }, {
485 .clk = {
486 .name = "aclk_mali",
487 .id = -1,
488 .ctrlbit = (1 << 2),
489 .enable = s5p64x0_sclk1_ctrl,
490 },
491 .sources = &clkset_mali,
492 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 8, .size = 2 },
493 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 4, .size = 4 },
494 }, {
495 .clk = {
496 .name = "sclk_2d",
497 .id = -1,
498 .ctrlbit = (1 << 12),
499 .enable = s5p64x0_sclk_ctrl,
500 },
501 .sources = &clkset_mali,
502 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 30, .size = 2 },
503 .reg_div = { .reg = S5P64X0_CLK_DIV2, .shift = 20, .size = 4 },
504 }, {
505 .clk = {
506 .name = "sclk_usi",
507 .id = -1,
508 .ctrlbit = (1 << 7),
509 .enable = s5p64x0_sclk_ctrl,
510 },
511 .sources = &clkset_group2,
512 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 10, .size = 2 },
513 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 16, .size = 4 },
514 }, {
515 .clk = {
516 .name = "sclk_camif",
517 .id = -1,
518 .ctrlbit = (1 << 6),
519 .enable = s5p64x0_sclk_ctrl,
520 },
521 .sources = &clkset_group2,
522 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 28, .size = 2 },
523 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 20, .size = 4 },
524 }, {
525 .clk = {
526 .name = "sclk_dispcon",
527 .id = -1,
528 .ctrlbit = (1 << 1),
529 .enable = s5p64x0_sclk1_ctrl,
530 },
531 .sources = &clkset_dispcon,
532 .reg_src = { .reg = S5P64X0_CLK_SRC1, .shift = 4, .size = 2 },
533 .reg_div = { .reg = S5P64X0_CLK_DIV3, .shift = 0, .size = 4 },
534 }, {
535 .clk = {
536 .name = "sclk_hsmmc44",
537 .id = -1,
538 .ctrlbit = (1 << 30),
539 .enable = s5p64x0_sclk_ctrl,
540 },
541 .sources = &clkset_hsmmc44,
542 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 6, .size = 3 },
543 .reg_div = { .reg = S5P64X0_CLK_DIV1, .shift = 28, .size = 4 },
544 },
545};
546
547/* Clock initialization code */
548static struct clksrc_clk *sysclks[] = {
549 &clk_mout_apll,
550 &clk_mout_epll,
551 &clk_dout_epll,
552 &clk_mout_mpll,
553 &clk_dout_mpll,
554 &clk_armclk,
555 &clk_mout_hclk_sel,
556 &clk_dout_pwm_ratio0,
557 &clk_pclk_to_wdt_pwm,
558 &clk_hclk,
559 &clk_pclk,
560 &clk_hclk_low,
561 &clk_pclk_low,
562 &clk_sclk_audio0,
563};
564
565void __init_or_cpufreq s5p6450_setup_clocks(void)
566{
567 struct clk *xtal_clk;
568
569 unsigned long xtal;
570 unsigned long fclk;
571 unsigned long hclk;
572 unsigned long hclk_low;
573 unsigned long pclk;
574 unsigned long pclk_low;
575
576 unsigned long apll;
577 unsigned long mpll;
578 unsigned long epll;
579 unsigned long dpll;
580 unsigned int ptr;
581
582 /* Set S5P6450 functions for clk_fout_epll */
583
584 clk_fout_epll.enable = s5p64x0_epll_enable;
585 clk_fout_epll.ops = &s5p6450_epll_ops;
586
587 clk_48m.enable = s5p64x0_clk48m_ctrl;
588
589 xtal_clk = clk_get(NULL, "ext_xtal");
590 BUG_ON(IS_ERR(xtal_clk));
591
592 xtal = clk_get_rate(xtal_clk);
593 clk_put(xtal_clk);
594
595 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_APLL_CON), pll_4502);
596 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P64X0_MPLL_CON), pll_4502);
597 epll = s5p_get_pll90xx(xtal, __raw_readl(S5P64X0_EPLL_CON),
598 __raw_readl(S5P64X0_EPLL_CON_K));
599 dpll = s5p_get_pll46xx(xtal, __raw_readl(S5P6450_DPLL_CON),
600 __raw_readl(S5P6450_DPLL_CON_K), pll_4650c);
601
602 clk_fout_apll.rate = apll;
603 clk_fout_mpll.rate = mpll;
604 clk_fout_epll.rate = epll;
605 clk_fout_dpll.rate = dpll;
606
607 printk(KERN_INFO "S5P6450: PLL settings, A=%ld.%ldMHz, M=%ld.%ldMHz," \
608 " E=%ld.%ldMHz, D=%ld.%ldMHz\n",
609 print_mhz(apll), print_mhz(mpll), print_mhz(epll),
610 print_mhz(dpll));
611
612 fclk = clk_get_rate(&clk_armclk.clk);
613 hclk = clk_get_rate(&clk_hclk.clk);
614 pclk = clk_get_rate(&clk_pclk.clk);
615 hclk_low = clk_get_rate(&clk_hclk_low.clk);
616 pclk_low = clk_get_rate(&clk_pclk_low.clk);
617
618 printk(KERN_INFO "S5P6450: HCLK=%ld.%ldMHz, HCLK_LOW=%ld.%ldMHz," \
619 " PCLK=%ld.%ldMHz, PCLK_LOW=%ld.%ldMHz\n",
620 print_mhz(hclk), print_mhz(hclk_low),
621 print_mhz(pclk), print_mhz(pclk_low));
622
623 clk_f.rate = fclk;
624 clk_h.rate = hclk;
625 clk_p.rate = pclk;
626
627 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
628 s3c_set_clksrc(&clksrcs[ptr], true);
629}
630
631void __init s5p6450_register_clocks(void)
632{
633 struct clk *clkp;
634 int ret;
635 int ptr;
636
637 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
638 s3c_register_clksrc(sysclks[ptr], 1);
639
640 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
641 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
642
643 clkp = init_clocks_disable;
644 for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
645
646 ret = s3c24xx_register_clock(clkp);
647 if (ret < 0) {
648 printk(KERN_ERR "Failed to register clock %s (%d)\n",
649 clkp->name, ret);
650 }
651 (clkp->enable)(clkp, 0);
652 }
653
654 s3c_pwmclk_init();
655}
diff --git a/arch/arm/mach-s5p64x0/clock.c b/arch/arm/mach-s5p64x0/clock.c
new file mode 100644
index 000000000000..523ba8039ac2
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/clock.c
@@ -0,0 +1,253 @@
1/* linux/arch/arm/mach-s5p64x0/clock.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - Clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22
23#include <mach/hardware.h>
24#include <mach/map.h>
25#include <mach/regs-clock.h>
26
27#include <plat/cpu-freq.h>
28#include <plat/clock.h>
29#include <plat/cpu.h>
30#include <plat/pll.h>
31#include <plat/s5p-clock.h>
32#include <plat/clock-clksrc.h>
33#include <plat/s5p6440.h>
34#include <plat/s5p6450.h>
35
36struct clksrc_clk clk_mout_apll = {
37 .clk = {
38 .name = "mout_apll",
39 .id = -1,
40 },
41 .sources = &clk_src_apll,
42 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 0, .size = 1 },
43};
44
45struct clksrc_clk clk_mout_mpll = {
46 .clk = {
47 .name = "mout_mpll",
48 .id = -1,
49 },
50 .sources = &clk_src_mpll,
51 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 1, .size = 1 },
52};
53
54struct clksrc_clk clk_mout_epll = {
55 .clk = {
56 .name = "mout_epll",
57 .id = -1,
58 },
59 .sources = &clk_src_epll,
60 .reg_src = { .reg = S5P64X0_CLK_SRC0, .shift = 2, .size = 1 },
61};
62
63enum perf_level {
64 L0 = 532*1000,
65 L1 = 266*1000,
66 L2 = 133*1000,
67};
68
69static const u32 clock_table[][3] = {
70 /*{ARM_CLK, DIVarm, DIVhclk}*/
71 {L0 * 1000, (0 << ARM_DIV_RATIO_SHIFT), (3 << S5P64X0_CLKDIV0_HCLK_SHIFT)},
72 {L1 * 1000, (1 << ARM_DIV_RATIO_SHIFT), (1 << S5P64X0_CLKDIV0_HCLK_SHIFT)},
73 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)},
74};
75
76int s5p64x0_epll_enable(struct clk *clk, int enable)
77{
78 unsigned int ctrlbit = clk->ctrlbit;
79 unsigned int epll_con = __raw_readl(S5P64X0_EPLL_CON) & ~ctrlbit;
80
81 if (enable)
82 __raw_writel(epll_con | ctrlbit, S5P64X0_EPLL_CON);
83 else
84 __raw_writel(epll_con, S5P64X0_EPLL_CON);
85
86 return 0;
87}
88
89unsigned long s5p64x0_epll_get_rate(struct clk *clk)
90{
91 return clk->rate;
92}
93
94unsigned long s5p64x0_armclk_get_rate(struct clk *clk)
95{
96 unsigned long rate = clk_get_rate(clk->parent);
97 u32 clkdiv;
98
99 /* divisor mask starts at bit0, so no need to shift */
100 clkdiv = __raw_readl(ARM_CLK_DIV) & ARM_DIV_MASK;
101
102 return rate / (clkdiv + 1);
103}
104
105unsigned long s5p64x0_armclk_round_rate(struct clk *clk, unsigned long rate)
106{
107 u32 iter;
108
109 for (iter = 1 ; iter < ARRAY_SIZE(clock_table) ; iter++) {
110 if (rate > clock_table[iter][0])
111 return clock_table[iter-1][0];
112 }
113
114 return clock_table[ARRAY_SIZE(clock_table) - 1][0];
115}
116
117int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate)
118{
119 u32 round_tmp;
120 u32 iter;
121 u32 clk_div0_tmp;
122 u32 cur_rate = clk->ops->get_rate(clk);
123 unsigned long flags;
124
125 round_tmp = clk->ops->round_rate(clk, rate);
126 if (round_tmp == cur_rate)
127 return 0;
128
129
130 for (iter = 0 ; iter < ARRAY_SIZE(clock_table) ; iter++) {
131 if (round_tmp == clock_table[iter][0])
132 break;
133 }
134
135 if (iter >= ARRAY_SIZE(clock_table))
136 iter = ARRAY_SIZE(clock_table) - 1;
137
138 local_irq_save(flags);
139 if (cur_rate > round_tmp) {
140 /* Frequency Down */
141 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) & ~(ARM_DIV_MASK);
142 clk_div0_tmp |= clock_table[iter][1];
143 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
144
145 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) &
146 ~(S5P64X0_CLKDIV0_HCLK_MASK);
147 clk_div0_tmp |= clock_table[iter][2];
148 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
149
150
151 } else {
152 /* Frequency Up */
153 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) &
154 ~(S5P64X0_CLKDIV0_HCLK_MASK);
155 clk_div0_tmp |= clock_table[iter][2];
156 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
157
158 clk_div0_tmp = __raw_readl(ARM_CLK_DIV) & ~(ARM_DIV_MASK);
159 clk_div0_tmp |= clock_table[iter][1];
160 __raw_writel(clk_div0_tmp, ARM_CLK_DIV);
161 }
162 local_irq_restore(flags);
163
164 clk->rate = clock_table[iter][0];
165
166 return 0;
167}
168
169struct clk_ops s5p64x0_clkarm_ops = {
170 .get_rate = s5p64x0_armclk_get_rate,
171 .set_rate = s5p64x0_armclk_set_rate,
172 .round_rate = s5p64x0_armclk_round_rate,
173};
174
175struct clksrc_clk clk_armclk = {
176 .clk = {
177 .name = "armclk",
178 .id = 1,
179 .parent = &clk_mout_apll.clk,
180 .ops = &s5p64x0_clkarm_ops,
181 },
182 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 0, .size = 4 },
183};
184
185struct clksrc_clk clk_dout_mpll = {
186 .clk = {
187 .name = "dout_mpll",
188 .id = -1,
189 .parent = &clk_mout_mpll.clk,
190 },
191 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 4, .size = 1 },
192};
193
194struct clk *clkset_hclk_low_list[] = {
195 &clk_mout_apll.clk,
196 &clk_mout_mpll.clk,
197};
198
199struct clksrc_sources clkset_hclk_low = {
200 .sources = clkset_hclk_low_list,
201 .nr_sources = ARRAY_SIZE(clkset_hclk_low_list),
202};
203
204int s5p64x0_pclk_ctrl(struct clk *clk, int enable)
205{
206 return s5p_gatectrl(S5P64X0_CLK_GATE_PCLK, clk, enable);
207}
208
209int s5p64x0_hclk0_ctrl(struct clk *clk, int enable)
210{
211 return s5p_gatectrl(S5P64X0_CLK_GATE_HCLK0, clk, enable);
212}
213
214int s5p64x0_hclk1_ctrl(struct clk *clk, int enable)
215{
216 return s5p_gatectrl(S5P64X0_CLK_GATE_HCLK1, clk, enable);
217}
218
219int s5p64x0_sclk_ctrl(struct clk *clk, int enable)
220{
221 return s5p_gatectrl(S5P64X0_CLK_GATE_SCLK0, clk, enable);
222}
223
224int s5p64x0_sclk1_ctrl(struct clk *clk, int enable)
225{
226 return s5p_gatectrl(S5P64X0_CLK_GATE_SCLK1, clk, enable);
227}
228
229int s5p64x0_mem_ctrl(struct clk *clk, int enable)
230{
231 return s5p_gatectrl(S5P64X0_CLK_GATE_MEM0, clk, enable);
232}
233
234int s5p64x0_clk48m_ctrl(struct clk *clk, int enable)
235{
236 unsigned long flags;
237 u32 val;
238
239 /* can't rely on clock lock, this register has other usages */
240 local_irq_save(flags);
241
242 val = __raw_readl(S5P64X0_OTHERS);
243 if (enable)
244 val |= S5P64X0_OTHERS_USB_SIG_MASK;
245 else
246 val &= ~S5P64X0_OTHERS_USB_SIG_MASK;
247
248 __raw_writel(val, S5P64X0_OTHERS);
249
250 local_irq_restore(flags);
251
252 return 0;
253}
diff --git a/arch/arm/mach-s5p64x0/cpu.c b/arch/arm/mach-s5p64x0/cpu.c
new file mode 100644
index 000000000000..b8d02eb4cf30
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/cpu.c
@@ -0,0 +1,209 @@
1/* linux/arch/arm/mach-s5p64x0/cpu.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/interrupt.h>
14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/init.h>
17#include <linux/clk.h>
18#include <linux/io.h>
19#include <linux/sysdev.h>
20#include <linux/serial_core.h>
21#include <linux/platform_device.h>
22#include <linux/sched.h>
23
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26#include <asm/mach/irq.h>
27#include <asm/proc-fns.h>
28#include <asm/irq.h>
29
30#include <mach/hardware.h>
31#include <mach/map.h>
32#include <mach/regs-clock.h>
33
34#include <plat/regs-serial.h>
35#include <plat/cpu.h>
36#include <plat/devs.h>
37#include <plat/clock.h>
38#include <plat/s5p6440.h>
39#include <plat/s5p6450.h>
40#include <plat/adc-core.h>
41
42/* Initial IO mappings */
43
44static struct map_desc s5p64x0_iodesc[] __initdata = {
45 {
46 .virtual = (unsigned long)S5P_VA_GPIO,
47 .pfn = __phys_to_pfn(S5P64X0_PA_GPIO),
48 .length = SZ_4K,
49 .type = MT_DEVICE,
50 }, {
51 .virtual = (unsigned long)VA_VIC0,
52 .pfn = __phys_to_pfn(S5P64X0_PA_VIC0),
53 .length = SZ_16K,
54 .type = MT_DEVICE,
55 }, {
56 .virtual = (unsigned long)VA_VIC1,
57 .pfn = __phys_to_pfn(S5P64X0_PA_VIC1),
58 .length = SZ_16K,
59 .type = MT_DEVICE,
60 },
61};
62
63static struct map_desc s5p6440_iodesc[] __initdata = {
64 {
65 .virtual = (unsigned long)S3C_VA_UART,
66 .pfn = __phys_to_pfn(S5P6440_PA_UART(0)),
67 .length = SZ_4K,
68 .type = MT_DEVICE,
69 },
70};
71
72static struct map_desc s5p6450_iodesc[] __initdata = {
73 {
74 .virtual = (unsigned long)S3C_VA_UART,
75 .pfn = __phys_to_pfn(S5P6450_PA_UART(0)),
76 .length = SZ_512K,
77 .type = MT_DEVICE,
78 }, {
79 .virtual = (unsigned long)S3C_VA_UART + SZ_512K,
80 .pfn = __phys_to_pfn(S5P6450_PA_UART(5)),
81 .length = SZ_4K,
82 .type = MT_DEVICE,
83 },
84};
85
86static void s5p64x0_idle(void)
87{
88 unsigned long val;
89
90 if (!need_resched()) {
91 val = __raw_readl(S5P64X0_PWR_CFG);
92 val &= ~(0x3 << 5);
93 val |= (0x1 << 5);
94 __raw_writel(val, S5P64X0_PWR_CFG);
95
96 cpu_do_idle();
97 }
98 local_irq_enable();
99}
100
101/*
102 * s5p64x0_map_io
103 *
104 * register the standard CPU IO areas
105 */
106
107void __init s5p6440_map_io(void)
108{
109 /* initialize any device information early */
110 s3c_adc_setname("s3c64xx-adc");
111
112 iotable_init(s5p64x0_iodesc, ARRAY_SIZE(s5p64x0_iodesc));
113 iotable_init(s5p6440_iodesc, ARRAY_SIZE(s5p6440_iodesc));
114}
115
116void __init s5p6450_map_io(void)
117{
118 /* initialize any device information early */
119 s3c_adc_setname("s3c64xx-adc");
120
121 iotable_init(s5p64x0_iodesc, ARRAY_SIZE(s5p64x0_iodesc));
122 iotable_init(s5p6450_iodesc, ARRAY_SIZE(s5p6440_iodesc));
123}
124
125/*
126 * s5p64x0_init_clocks
127 *
128 * register and setup the CPU clocks
129 */
130
131void __init s5p6440_init_clocks(int xtal)
132{
133 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
134
135 s3c24xx_register_baseclocks(xtal);
136 s5p_register_clocks(xtal);
137 s5p6440_register_clocks();
138 s5p6440_setup_clocks();
139}
140
141void __init s5p6450_init_clocks(int xtal)
142{
143 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
144
145 s3c24xx_register_baseclocks(xtal);
146 s5p_register_clocks(xtal);
147 s5p6450_register_clocks();
148 s5p6450_setup_clocks();
149}
150
151/*
152 * s5p64x0_init_irq
153 *
154 * register the CPU interrupts
155 */
156
157void __init s5p6440_init_irq(void)
158{
159 /* S5P6440 supports 2 VIC */
160 u32 vic[2];
161
162 /*
163 * VIC0 is missing IRQ_VIC0[3, 4, 8, 10, (12-22)]
164 * VIC1 is missing IRQ VIC1[1, 3, 4, 10, 11, 12, 14, 15, 22]
165 */
166 vic[0] = 0xff800ae7;
167 vic[1] = 0xffbf23e5;
168
169 s5p_init_irq(vic, ARRAY_SIZE(vic));
170}
171
172void __init s5p6450_init_irq(void)
173{
174 /* S5P6450 supports only 2 VIC */
175 u32 vic[2];
176
177 /*
178 * VIC0 is missing IRQ_VIC0[(13-15), (21-22)]
179 * VIC1 is missing IRQ VIC1[12, 14, 23]
180 */
181 vic[0] = 0xff9f1fff;
182 vic[1] = 0xff7fafff;
183
184 s5p_init_irq(vic, ARRAY_SIZE(vic));
185}
186
187struct sysdev_class s5p64x0_sysclass = {
188 .name = "s5p64x0-core",
189};
190
191static struct sys_device s5p64x0_sysdev = {
192 .cls = &s5p64x0_sysclass,
193};
194
195static int __init s5p64x0_core_init(void)
196{
197 return sysdev_class_register(&s5p64x0_sysclass);
198}
199core_initcall(s5p64x0_core_init);
200
201int __init s5p64x0_init(void)
202{
203 printk(KERN_INFO "S5P64X0(S5P6440/S5P6450): Initializing architecture\n");
204
205 /* set idle function */
206 pm_idle = s5p64x0_idle;
207
208 return sysdev_register(&s5p64x0_sysdev);
209}
diff --git a/arch/arm/mach-s5p64x0/dev-audio.c b/arch/arm/mach-s5p64x0/dev-audio.c
new file mode 100644
index 000000000000..fa097bd68ca4
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/dev-audio.c
@@ -0,0 +1,164 @@
1/* linux/arch/arm/mach-s5p64x0/dev-audio.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co. Ltd
4 * Jaswinder Singh <jassi.brar@samsung.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#include <linux/platform_device.h>
12#include <linux/dma-mapping.h>
13#include <linux/gpio.h>
14
15#include <plat/gpio-cfg.h>
16#include <plat/audio.h>
17
18#include <mach/map.h>
19#include <mach/dma.h>
20#include <mach/irqs.h>
21
22static int s5p6440_cfg_i2s(struct platform_device *pdev)
23{
24 /* configure GPIO for i2s port */
25 switch (pdev->id) {
26 case -1:
27 s3c_gpio_cfgpin(S5P6440_GPR(4), S3C_GPIO_SFN(5));
28 s3c_gpio_cfgpin(S5P6440_GPR(5), S3C_GPIO_SFN(5));
29 s3c_gpio_cfgpin(S5P6440_GPR(6), S3C_GPIO_SFN(5));
30 s3c_gpio_cfgpin(S5P6440_GPR(7), S3C_GPIO_SFN(5));
31 s3c_gpio_cfgpin(S5P6440_GPR(8), S3C_GPIO_SFN(5));
32 s3c_gpio_cfgpin(S5P6440_GPR(13), S3C_GPIO_SFN(5));
33 s3c_gpio_cfgpin(S5P6440_GPR(14), S3C_GPIO_SFN(5));
34 break;
35
36 default:
37 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
38 return -EINVAL;
39 }
40
41 return 0;
42}
43
44static int s5p6450_cfg_i2s(struct platform_device *pdev)
45{
46 /* configure GPIO for i2s port */
47 switch (pdev->id) {
48 case -1:
49 s3c_gpio_cfgpin(S5P6450_GPB(4), S3C_GPIO_SFN(5));
50 s3c_gpio_cfgpin(S5P6450_GPR(4), S3C_GPIO_SFN(5));
51 s3c_gpio_cfgpin(S5P6450_GPR(5), S3C_GPIO_SFN(5));
52 s3c_gpio_cfgpin(S5P6450_GPR(6), S3C_GPIO_SFN(5));
53 s3c_gpio_cfgpin(S5P6450_GPR(7), S3C_GPIO_SFN(5));
54 s3c_gpio_cfgpin(S5P6450_GPR(8), S3C_GPIO_SFN(5));
55 s3c_gpio_cfgpin(S5P6450_GPR(13), S3C_GPIO_SFN(5));
56 s3c_gpio_cfgpin(S5P6450_GPR(14), S3C_GPIO_SFN(5));
57 break;
58
59 default:
60 printk(KERN_ERR "Invalid Device %d\n", pdev->id);
61 return -EINVAL;
62 }
63
64 return 0;
65}
66
67static struct s3c_audio_pdata s5p6440_i2s_pdata = {
68 .cfg_gpio = s5p6440_cfg_i2s,
69};
70
71static struct s3c_audio_pdata s5p6450_i2s_pdata = {
72 .cfg_gpio = s5p6450_cfg_i2s,
73};
74
75static struct resource s5p64x0_iis0_resource[] = {
76 [0] = {
77 .start = S5P64X0_PA_I2S,
78 .end = S5P64X0_PA_I2S + 0x100 - 1,
79 .flags = IORESOURCE_MEM,
80 },
81 [1] = {
82 .start = DMACH_I2S0_TX,
83 .end = DMACH_I2S0_TX,
84 .flags = IORESOURCE_DMA,
85 },
86 [2] = {
87 .start = DMACH_I2S0_RX,
88 .end = DMACH_I2S0_RX,
89 .flags = IORESOURCE_DMA,
90 },
91};
92
93struct platform_device s5p6440_device_iis = {
94 .name = "s3c64xx-iis-v4",
95 .id = -1,
96 .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource),
97 .resource = s5p64x0_iis0_resource,
98 .dev = {
99 .platform_data = &s5p6440_i2s_pdata,
100 },
101};
102
103struct platform_device s5p6450_device_iis0 = {
104 .name = "s3c64xx-iis-v4",
105 .id = -1,
106 .num_resources = ARRAY_SIZE(s5p64x0_iis0_resource),
107 .resource = s5p64x0_iis0_resource,
108 .dev = {
109 .platform_data = &s5p6450_i2s_pdata,
110 },
111};
112
113/* PCM Controller platform_devices */
114
115static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
116{
117 switch (pdev->id) {
118 case 0:
119 s3c_gpio_cfgpin(S5P6440_GPR(7), S3C_GPIO_SFN(2));
120 s3c_gpio_cfgpin(S5P6440_GPR(13), S3C_GPIO_SFN(2));
121 s3c_gpio_cfgpin(S5P6440_GPR(14), S3C_GPIO_SFN(2));
122 s3c_gpio_cfgpin(S5P6440_GPR(8), S3C_GPIO_SFN(2));
123 s3c_gpio_cfgpin(S5P6440_GPR(6), S3C_GPIO_SFN(2));
124 break;
125
126 default:
127 printk(KERN_DEBUG "Invalid PCM Controller number!");
128 return -EINVAL;
129 }
130
131 return 0;
132}
133
134static struct s3c_audio_pdata s5p6440_pcm_pdata = {
135 .cfg_gpio = s5p6440_pcm_cfg_gpio,
136};
137
138static struct resource s5p6440_pcm0_resource[] = {
139 [0] = {
140 .start = S5P64X0_PA_PCM,
141 .end = S5P64X0_PA_PCM + 0x100 - 1,
142 .flags = IORESOURCE_MEM,
143 },
144 [1] = {
145 .start = DMACH_PCM0_TX,
146 .end = DMACH_PCM0_TX,
147 .flags = IORESOURCE_DMA,
148 },
149 [2] = {
150 .start = DMACH_PCM0_RX,
151 .end = DMACH_PCM0_RX,
152 .flags = IORESOURCE_DMA,
153 },
154};
155
156struct platform_device s5p6440_device_pcm = {
157 .name = "samsung-pcm",
158 .id = 0,
159 .num_resources = ARRAY_SIZE(s5p6440_pcm0_resource),
160 .resource = s5p6440_pcm0_resource,
161 .dev = {
162 .platform_data = &s5p6440_pcm_pdata,
163 },
164};
diff --git a/arch/arm/mach-s5p64x0/dev-spi.c b/arch/arm/mach-s5p64x0/dev-spi.c
new file mode 100644
index 000000000000..5b69ec4c8af3
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/dev-spi.c
@@ -0,0 +1,232 @@
1/* linux/arch/arm/mach-s5p64x0/dev-spi.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
7 * Jaswinder Singh <jassi.brar@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#include <linux/platform_device.h>
15#include <linux/dma-mapping.h>
16#include <linux/gpio.h>
17
18#include <mach/dma.h>
19#include <mach/map.h>
20#include <mach/irqs.h>
21#include <mach/regs-clock.h>
22#include <mach/spi-clocks.h>
23
24#include <plat/s3c64xx-spi.h>
25#include <plat/gpio-cfg.h>
26
27static char *s5p64x0_spi_src_clks[] = {
28 [S5P64X0_SPI_SRCCLK_PCLK] = "pclk",
29 [S5P64X0_SPI_SRCCLK_SCLK] = "sclk_spi",
30};
31
32/* SPI Controller platform_devices */
33
34/* Since we emulate multi-cs capability, we do not touch the CS.
35 * The emulated CS is toggled by board specific mechanism, as it can
36 * be either some immediate GPIO or some signal out of some other
37 * chip in between ... or some yet another way.
38 * We simply do not assume anything about CS.
39 */
40static int s5p6440_spi_cfg_gpio(struct platform_device *pdev)
41{
42 switch (pdev->id) {
43 case 0:
44 s3c_gpio_cfgpin(S5P6440_GPC(0), S3C_GPIO_SFN(2));
45 s3c_gpio_cfgpin(S5P6440_GPC(1), S3C_GPIO_SFN(2));
46 s3c_gpio_cfgpin(S5P6440_GPC(2), S3C_GPIO_SFN(2));
47 s3c_gpio_setpull(S5P6440_GPC(0), S3C_GPIO_PULL_UP);
48 s3c_gpio_setpull(S5P6440_GPC(1), S3C_GPIO_PULL_UP);
49 s3c_gpio_setpull(S5P6440_GPC(2), S3C_GPIO_PULL_UP);
50 break;
51
52 case 1:
53 s3c_gpio_cfgpin(S5P6440_GPC(4), S3C_GPIO_SFN(2));
54 s3c_gpio_cfgpin(S5P6440_GPC(5), S3C_GPIO_SFN(2));
55 s3c_gpio_cfgpin(S5P6440_GPC(6), S3C_GPIO_SFN(2));
56 s3c_gpio_setpull(S5P6440_GPC(4), S3C_GPIO_PULL_UP);
57 s3c_gpio_setpull(S5P6440_GPC(5), S3C_GPIO_PULL_UP);
58 s3c_gpio_setpull(S5P6440_GPC(6), S3C_GPIO_PULL_UP);
59 break;
60
61 default:
62 dev_err(&pdev->dev, "Invalid SPI Controller number!");
63 return -EINVAL;
64 }
65
66 return 0;
67}
68
69static int s5p6450_spi_cfg_gpio(struct platform_device *pdev)
70{
71 switch (pdev->id) {
72 case 0:
73 s3c_gpio_cfgpin(S5P6450_GPC(0), S3C_GPIO_SFN(2));
74 s3c_gpio_cfgpin(S5P6450_GPC(1), S3C_GPIO_SFN(2));
75 s3c_gpio_cfgpin(S5P6450_GPC(2), S3C_GPIO_SFN(2));
76 s3c_gpio_setpull(S5P6450_GPC(0), S3C_GPIO_PULL_UP);
77 s3c_gpio_setpull(S5P6450_GPC(1), S3C_GPIO_PULL_UP);
78 s3c_gpio_setpull(S5P6450_GPC(2), S3C_GPIO_PULL_UP);
79 break;
80
81 case 1:
82 s3c_gpio_cfgpin(S5P6450_GPC(4), S3C_GPIO_SFN(2));
83 s3c_gpio_cfgpin(S5P6450_GPC(5), S3C_GPIO_SFN(2));
84 s3c_gpio_cfgpin(S5P6450_GPC(6), S3C_GPIO_SFN(2));
85 s3c_gpio_setpull(S5P6450_GPC(4), S3C_GPIO_PULL_UP);
86 s3c_gpio_setpull(S5P6450_GPC(5), S3C_GPIO_PULL_UP);
87 s3c_gpio_setpull(S5P6450_GPC(6), S3C_GPIO_PULL_UP);
88 break;
89
90 default:
91 dev_err(&pdev->dev, "Invalid SPI Controller number!");
92 return -EINVAL;
93 }
94
95 return 0;
96}
97
98static struct resource s5p64x0_spi0_resource[] = {
99 [0] = {
100 .start = S5P64X0_PA_SPI0,
101 .end = S5P64X0_PA_SPI0 + 0x100 - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 [1] = {
105 .start = DMACH_SPI0_TX,
106 .end = DMACH_SPI0_TX,
107 .flags = IORESOURCE_DMA,
108 },
109 [2] = {
110 .start = DMACH_SPI0_RX,
111 .end = DMACH_SPI0_RX,
112 .flags = IORESOURCE_DMA,
113 },
114 [3] = {
115 .start = IRQ_SPI0,
116 .end = IRQ_SPI0,
117 .flags = IORESOURCE_IRQ,
118 },
119};
120
121static struct s3c64xx_spi_info s5p6440_spi0_pdata = {
122 .cfg_gpio = s5p6440_spi_cfg_gpio,
123 .fifo_lvl_mask = 0x1ff,
124 .rx_lvl_offset = 15,
125};
126
127static struct s3c64xx_spi_info s5p6450_spi0_pdata = {
128 .cfg_gpio = s5p6450_spi_cfg_gpio,
129 .fifo_lvl_mask = 0x1ff,
130 .rx_lvl_offset = 15,
131};
132
133static u64 spi_dmamask = DMA_BIT_MASK(32);
134
135struct platform_device s5p64x0_device_spi0 = {
136 .name = "s3c64xx-spi",
137 .id = 0,
138 .num_resources = ARRAY_SIZE(s5p64x0_spi0_resource),
139 .resource = s5p64x0_spi0_resource,
140 .dev = {
141 .dma_mask = &spi_dmamask,
142 .coherent_dma_mask = DMA_BIT_MASK(32),
143 },
144};
145
146static struct resource s5p64x0_spi1_resource[] = {
147 [0] = {
148 .start = S5P64X0_PA_SPI1,
149 .end = S5P64X0_PA_SPI1 + 0x100 - 1,
150 .flags = IORESOURCE_MEM,
151 },
152 [1] = {
153 .start = DMACH_SPI1_TX,
154 .end = DMACH_SPI1_TX,
155 .flags = IORESOURCE_DMA,
156 },
157 [2] = {
158 .start = DMACH_SPI1_RX,
159 .end = DMACH_SPI1_RX,
160 .flags = IORESOURCE_DMA,
161 },
162 [3] = {
163 .start = IRQ_SPI1,
164 .end = IRQ_SPI1,
165 .flags = IORESOURCE_IRQ,
166 },
167};
168
169static struct s3c64xx_spi_info s5p6440_spi1_pdata = {
170 .cfg_gpio = s5p6440_spi_cfg_gpio,
171 .fifo_lvl_mask = 0x7f,
172 .rx_lvl_offset = 15,
173};
174
175static struct s3c64xx_spi_info s5p6450_spi1_pdata = {
176 .cfg_gpio = s5p6450_spi_cfg_gpio,
177 .fifo_lvl_mask = 0x7f,
178 .rx_lvl_offset = 15,
179};
180
181struct platform_device s5p64x0_device_spi1 = {
182 .name = "s3c64xx-spi",
183 .id = 1,
184 .num_resources = ARRAY_SIZE(s5p64x0_spi1_resource),
185 .resource = s5p64x0_spi1_resource,
186 .dev = {
187 .dma_mask = &spi_dmamask,
188 .coherent_dma_mask = DMA_BIT_MASK(32),
189 },
190};
191
192void __init s5p64x0_spi_set_info(int cntrlr, int src_clk_nr, int num_cs)
193{
194 unsigned int id;
195 struct s3c64xx_spi_info *pd;
196
197 id = __raw_readl(S5P64X0_SYS_ID) & 0xFF000;
198
199 /* Reject invalid configuration */
200 if (!num_cs || src_clk_nr < 0
201 || src_clk_nr > S5P64X0_SPI_SRCCLK_SCLK) {
202 printk(KERN_ERR "%s: Invalid SPI configuration\n", __func__);
203 return;
204 }
205
206 switch (cntrlr) {
207 case 0:
208 if (id == 0x50000)
209 pd = &s5p6450_spi0_pdata;
210 else
211 pd = &s5p6440_spi0_pdata;
212
213 s5p64x0_device_spi0.dev.platform_data = pd;
214 break;
215 case 1:
216 if (id == 0x50000)
217 pd = &s5p6450_spi1_pdata;
218 else
219 pd = &s5p6440_spi1_pdata;
220
221 s5p64x0_device_spi1.dev.platform_data = pd;
222 break;
223 default:
224 printk(KERN_ERR "%s: Invalid SPI controller(%d)\n",
225 __func__, cntrlr);
226 return;
227 }
228
229 pd->num_cs = num_cs;
230 pd->src_clk_nr = src_clk_nr;
231 pd->src_clk_name = s5p64x0_spi_src_clks[src_clk_nr];
232}
diff --git a/arch/arm/mach-s5p6440/dma.c b/arch/arm/mach-s5p64x0/dma.c
index 07606ad57519..29a8c2410049 100644
--- a/arch/arm/mach-s5p6440/dma.c
+++ b/arch/arm/mach-s5p64x0/dma.c
@@ -1,4 +1,8 @@
1/* 1/* linux/arch/arm/mach-s5p64x0/dma.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
2 * Copyright (C) 2010 Samsung Electronics Co. Ltd. 6 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
3 * Jaswinder Singh <jassi.brar@samsung.com> 7 * Jaswinder Singh <jassi.brar@samsung.com>
4 * 8 *
@@ -15,26 +19,25 @@
15 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 22*/
19 23
20#include <linux/platform_device.h> 24#include <linux/platform_device.h>
21#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
22 26
23#include <plat/devs.h>
24#include <plat/irqs.h>
25
26#include <mach/map.h> 27#include <mach/map.h>
27#include <mach/irqs.h> 28#include <mach/irqs.h>
29#include <mach/regs-clock.h>
28 30
31#include <plat/devs.h>
29#include <plat/s3c-pl330-pdata.h> 32#include <plat/s3c-pl330-pdata.h>
30 33
31static u64 dma_dmamask = DMA_BIT_MASK(32); 34static u64 dma_dmamask = DMA_BIT_MASK(32);
32 35
33static struct resource s5p6440_pdma_resource[] = { 36static struct resource s5p64x0_pdma_resource[] = {
34 [0] = { 37 [0] = {
35 .start = S5P6440_PA_PDMA, 38 .start = S5P64X0_PA_PDMA,
36 .end = S5P6440_PA_PDMA + SZ_4K, 39 .end = S5P64X0_PA_PDMA + SZ_4K,
37 .flags = IORESOURCE_MEM, 40 .flags = IORESOURCE_MEM,
38 }, 41 },
39 [1] = { 42 [1] = {
40 .start = IRQ_DMA0, 43 .start = IRQ_DMA0,
@@ -80,26 +83,67 @@ static struct s3c_pl330_platdata s5p6440_pdma_pdata = {
80 }, 83 },
81}; 84};
82 85
83static struct platform_device s5p6440_device_pdma = { 86static struct s3c_pl330_platdata s5p6450_pdma_pdata = {
87 .peri = {
88 [0] = DMACH_UART0_RX,
89 [1] = DMACH_UART0_TX,
90 [2] = DMACH_UART1_RX,
91 [3] = DMACH_UART1_TX,
92 [4] = DMACH_UART2_RX,
93 [5] = DMACH_UART2_TX,
94 [6] = DMACH_UART3_RX,
95 [7] = DMACH_UART3_TX,
96 [8] = DMACH_UART4_RX,
97 [9] = DMACH_UART4_TX,
98 [10] = DMACH_PCM0_TX,
99 [11] = DMACH_PCM0_RX,
100 [12] = DMACH_I2S0_TX,
101 [13] = DMACH_I2S0_RX,
102 [14] = DMACH_SPI0_TX,
103 [15] = DMACH_SPI0_RX,
104 [16] = DMACH_PCM1_TX,
105 [17] = DMACH_PCM1_RX,
106 [18] = DMACH_PCM2_TX,
107 [19] = DMACH_PCM2_RX,
108 [20] = DMACH_SPI1_TX,
109 [21] = DMACH_SPI1_RX,
110 [22] = DMACH_USI_TX,
111 [23] = DMACH_USI_RX,
112 [24] = DMACH_MAX,
113 [25] = DMACH_I2S1_TX,
114 [26] = DMACH_I2S1_RX,
115 [27] = DMACH_I2S2_TX,
116 [28] = DMACH_I2S2_RX,
117 [29] = DMACH_PWM,
118 [30] = DMACH_UART5_RX,
119 [31] = DMACH_UART5_TX,
120 },
121};
122
123static struct platform_device s5p64x0_device_pdma = {
84 .name = "s3c-pl330", 124 .name = "s3c-pl330",
85 .id = 1, 125 .id = 0,
86 .num_resources = ARRAY_SIZE(s5p6440_pdma_resource), 126 .num_resources = ARRAY_SIZE(s5p64x0_pdma_resource),
87 .resource = s5p6440_pdma_resource, 127 .resource = s5p64x0_pdma_resource,
88 .dev = { 128 .dev = {
89 .dma_mask = &dma_dmamask, 129 .dma_mask = &dma_dmamask,
90 .coherent_dma_mask = DMA_BIT_MASK(32), 130 .coherent_dma_mask = DMA_BIT_MASK(32),
91 .platform_data = &s5p6440_pdma_pdata,
92 }, 131 },
93}; 132};
94 133
95static struct platform_device *s5p6440_dmacs[] __initdata = { 134static int __init s5p64x0_dma_init(void)
96 &s5p6440_device_pdma,
97};
98
99static int __init s5p6440_dma_init(void)
100{ 135{
101 platform_add_devices(s5p6440_dmacs, ARRAY_SIZE(s5p6440_dmacs)); 136 unsigned int id;
137
138 id = __raw_readl(S5P64X0_SYS_ID) & 0xFF000;
139
140 if (id == 0x50000)
141 s5p64x0_device_pdma.dev.platform_data = &s5p6450_pdma_pdata;
142 else
143 s5p64x0_device_pdma.dev.platform_data = &s5p6440_pdma_pdata;
144
145 platform_device_register(&s5p64x0_device_pdma);
102 146
103 return 0; 147 return 0;
104} 148}
105arch_initcall(s5p6440_dma_init); 149arch_initcall(s5p64x0_dma_init);
diff --git a/arch/arm/mach-s5p6440/gpio.c b/arch/arm/mach-s5p64x0/gpio.c
index 8bf6e0ce51c9..39159dd5a29a 100644
--- a/arch/arm/mach-s5p6440/gpio.c
+++ b/arch/arm/mach-s5p64x0/gpio.c
@@ -1,14 +1,14 @@
1/* arch/arm/mach-s5p6440/gpio.c 1/* linux/arch/arm/mach-s5p64x0/gpio.c
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - GPIOlib support 6 * S5P64X0 - GPIOlib support
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11*/
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
@@ -22,26 +22,29 @@
22#include <plat/gpio-cfg.h> 22#include <plat/gpio-cfg.h>
23#include <plat/gpio-cfg-helpers.h> 23#include <plat/gpio-cfg-helpers.h>
24 24
25/* GPIO bank summary: 25/* To be implemented S5P6450 GPIO */
26* 26
27* Bank GPIOs Style SlpCon ExtInt Group 27/*
28* A 6 4Bit Yes 1 28 * S5P6440 GPIO bank summary:
29* B 7 4Bit Yes 1 29 *
30* C 8 4Bit Yes 2 30 * Bank GPIOs Style SlpCon ExtInt Group
31* F 2 2Bit Yes 4 [1] 31 * A 6 4Bit Yes 1
32* G 7 4Bit Yes 5 32 * B 7 4Bit Yes 1
33* H 10 4Bit[2] Yes 6 33 * C 8 4Bit Yes 2
34* I 16 2Bit Yes None 34 * F 2 2Bit Yes 4 [1]
35* J 12 2Bit Yes None 35 * G 7 4Bit Yes 5
36* N 16 2Bit No IRQ_EINT 36 * H 10 4Bit[2] Yes 6
37* P 8 2Bit Yes 8 37 * I 16 2Bit Yes None
38* R 15 4Bit[2] Yes 8 38 * J 12 2Bit Yes None
39* 39 * N 16 2Bit No IRQ_EINT
40* [1] BANKF pins 14,15 do not form part of the external interrupt sources 40 * P 8 2Bit Yes 8
41* [2] BANK has two control registers, GPxCON0 and GPxCON1 41 * R 15 4Bit[2] Yes 8
42*/ 42 *
43 * [1] BANKF pins 14,15 do not form part of the external interrupt sources
44 * [2] BANK has two control registers, GPxCON0 and GPxCON1
45 */
43 46
44static int s5p6440_gpiolib_rbank_4bit2_input(struct gpio_chip *chip, 47static int s5p64x0_gpiolib_rbank_4bit2_input(struct gpio_chip *chip,
45 unsigned int offset) 48 unsigned int offset)
46{ 49{
47 struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); 50 struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip);
@@ -77,7 +80,7 @@ static int s5p6440_gpiolib_rbank_4bit2_input(struct gpio_chip *chip,
77 return 0; 80 return 0;
78} 81}
79 82
80static int s5p6440_gpiolib_rbank_4bit2_output(struct gpio_chip *chip, 83static int s5p64x0_gpiolib_rbank_4bit2_output(struct gpio_chip *chip,
81 unsigned int offset, int value) 84 unsigned int offset, int value)
82{ 85{
83 struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip); 86 struct s3c_gpio_chip *ourchip = to_s3c_gpio(chip);
@@ -124,12 +127,11 @@ static int s5p6440_gpiolib_rbank_4bit2_output(struct gpio_chip *chip,
124 return 0; 127 return 0;
125} 128}
126 129
127int s5p6440_gpio_setcfg_4bit_rbank(struct s3c_gpio_chip *chip, 130int s5p64x0_gpio_setcfg_4bit_rbank(struct s3c_gpio_chip *chip,
128 unsigned int off, unsigned int cfg) 131 unsigned int off, unsigned int cfg)
129{ 132{
130 void __iomem *reg = chip->base; 133 void __iomem *reg = chip->base;
131 unsigned int shift; 134 unsigned int shift;
132 unsigned long flags;
133 u32 con; 135 u32 con;
134 136
135 switch (off) { 137 switch (off) {
@@ -155,26 +157,22 @@ int s5p6440_gpio_setcfg_4bit_rbank(struct s3c_gpio_chip *chip,
155 cfg <<= shift; 157 cfg <<= shift;
156 } 158 }
157 159
158 s3c_gpio_lock(chip, flags);
159
160 con = __raw_readl(reg); 160 con = __raw_readl(reg);
161 con &= ~(0xf << shift); 161 con &= ~(0xf << shift);
162 con |= cfg; 162 con |= cfg;
163 __raw_writel(con, reg); 163 __raw_writel(con, reg);
164 164
165 s3c_gpio_unlock(chip, flags);
166
167 return 0; 165 return 0;
168} 166}
169 167
170static struct s3c_gpio_cfg s5p6440_gpio_cfgs[] = { 168static struct s3c_gpio_cfg s5p64x0_gpio_cfgs[] = {
171 { 169 {
172 .cfg_eint = 0, 170 .cfg_eint = 0,
173 }, { 171 }, {
174 .cfg_eint = 7, 172 .cfg_eint = 7,
175 }, { 173 }, {
176 .cfg_eint = 3, 174 .cfg_eint = 3,
177 .set_config = s5p6440_gpio_setcfg_4bit_rbank, 175 .set_config = s5p64x0_gpio_setcfg_4bit_rbank,
178 }, { 176 }, {
179 .cfg_eint = 0, 177 .cfg_eint = 0,
180 .set_config = s3c_gpio_setcfg_s3c24xx, 178 .set_config = s3c_gpio_setcfg_s3c24xx,
@@ -193,7 +191,7 @@ static struct s3c_gpio_cfg s5p6440_gpio_cfgs[] = {
193static struct s3c_gpio_chip s5p6440_gpio_4bit[] = { 191static struct s3c_gpio_chip s5p6440_gpio_4bit[] = {
194 { 192 {
195 .base = S5P6440_GPA_BASE, 193 .base = S5P6440_GPA_BASE,
196 .config = &s5p6440_gpio_cfgs[1], 194 .config = &s5p64x0_gpio_cfgs[1],
197 .chip = { 195 .chip = {
198 .base = S5P6440_GPA(0), 196 .base = S5P6440_GPA(0),
199 .ngpio = S5P6440_GPIO_A_NR, 197 .ngpio = S5P6440_GPIO_A_NR,
@@ -201,7 +199,7 @@ static struct s3c_gpio_chip s5p6440_gpio_4bit[] = {
201 }, 199 },
202 }, { 200 }, {
203 .base = S5P6440_GPB_BASE, 201 .base = S5P6440_GPB_BASE,
204 .config = &s5p6440_gpio_cfgs[1], 202 .config = &s5p64x0_gpio_cfgs[1],
205 .chip = { 203 .chip = {
206 .base = S5P6440_GPB(0), 204 .base = S5P6440_GPB(0),
207 .ngpio = S5P6440_GPIO_B_NR, 205 .ngpio = S5P6440_GPIO_B_NR,
@@ -209,7 +207,7 @@ static struct s3c_gpio_chip s5p6440_gpio_4bit[] = {
209 }, 207 },
210 }, { 208 }, {
211 .base = S5P6440_GPC_BASE, 209 .base = S5P6440_GPC_BASE,
212 .config = &s5p6440_gpio_cfgs[1], 210 .config = &s5p64x0_gpio_cfgs[1],
213 .chip = { 211 .chip = {
214 .base = S5P6440_GPC(0), 212 .base = S5P6440_GPC(0),
215 .ngpio = S5P6440_GPIO_C_NR, 213 .ngpio = S5P6440_GPIO_C_NR,
@@ -217,7 +215,7 @@ static struct s3c_gpio_chip s5p6440_gpio_4bit[] = {
217 }, 215 },
218 }, { 216 }, {
219 .base = S5P6440_GPG_BASE, 217 .base = S5P6440_GPG_BASE,
220 .config = &s5p6440_gpio_cfgs[1], 218 .config = &s5p64x0_gpio_cfgs[1],
221 .chip = { 219 .chip = {
222 .base = S5P6440_GPG(0), 220 .base = S5P6440_GPG(0),
223 .ngpio = S5P6440_GPIO_G_NR, 221 .ngpio = S5P6440_GPIO_G_NR,
@@ -229,7 +227,7 @@ static struct s3c_gpio_chip s5p6440_gpio_4bit[] = {
229static struct s3c_gpio_chip s5p6440_gpio_4bit2[] = { 227static struct s3c_gpio_chip s5p6440_gpio_4bit2[] = {
230 { 228 {
231 .base = S5P6440_GPH_BASE + 0x4, 229 .base = S5P6440_GPH_BASE + 0x4,
232 .config = &s5p6440_gpio_cfgs[1], 230 .config = &s5p64x0_gpio_cfgs[1],
233 .chip = { 231 .chip = {
234 .base = S5P6440_GPH(0), 232 .base = S5P6440_GPH(0),
235 .ngpio = S5P6440_GPIO_H_NR, 233 .ngpio = S5P6440_GPIO_H_NR,
@@ -238,10 +236,10 @@ static struct s3c_gpio_chip s5p6440_gpio_4bit2[] = {
238 }, 236 },
239}; 237};
240 238
241static struct s3c_gpio_chip gpio_rbank_4bit2[] = { 239static struct s3c_gpio_chip s5p6440_gpio_rbank_4bit2[] = {
242 { 240 {
243 .base = S5P6440_GPR_BASE + 0x4, 241 .base = S5P6440_GPR_BASE + 0x4,
244 .config = &s5p6440_gpio_cfgs[2], 242 .config = &s5p64x0_gpio_cfgs[2],
245 .chip = { 243 .chip = {
246 .base = S5P6440_GPR(0), 244 .base = S5P6440_GPR(0),
247 .ngpio = S5P6440_GPIO_R_NR, 245 .ngpio = S5P6440_GPIO_R_NR,
@@ -253,7 +251,7 @@ static struct s3c_gpio_chip gpio_rbank_4bit2[] = {
253static struct s3c_gpio_chip s5p6440_gpio_2bit[] = { 251static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
254 { 252 {
255 .base = S5P6440_GPF_BASE, 253 .base = S5P6440_GPF_BASE,
256 .config = &s5p6440_gpio_cfgs[5], 254 .config = &s5p64x0_gpio_cfgs[5],
257 .chip = { 255 .chip = {
258 .base = S5P6440_GPF(0), 256 .base = S5P6440_GPF(0),
259 .ngpio = S5P6440_GPIO_F_NR, 257 .ngpio = S5P6440_GPIO_F_NR,
@@ -261,7 +259,7 @@ static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
261 }, 259 },
262 }, { 260 }, {
263 .base = S5P6440_GPI_BASE, 261 .base = S5P6440_GPI_BASE,
264 .config = &s5p6440_gpio_cfgs[3], 262 .config = &s5p64x0_gpio_cfgs[3],
265 .chip = { 263 .chip = {
266 .base = S5P6440_GPI(0), 264 .base = S5P6440_GPI(0),
267 .ngpio = S5P6440_GPIO_I_NR, 265 .ngpio = S5P6440_GPIO_I_NR,
@@ -269,7 +267,7 @@ static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
269 }, 267 },
270 }, { 268 }, {
271 .base = S5P6440_GPJ_BASE, 269 .base = S5P6440_GPJ_BASE,
272 .config = &s5p6440_gpio_cfgs[3], 270 .config = &s5p64x0_gpio_cfgs[3],
273 .chip = { 271 .chip = {
274 .base = S5P6440_GPJ(0), 272 .base = S5P6440_GPJ(0),
275 .ngpio = S5P6440_GPIO_J_NR, 273 .ngpio = S5P6440_GPIO_J_NR,
@@ -277,7 +275,7 @@ static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
277 }, 275 },
278 }, { 276 }, {
279 .base = S5P6440_GPN_BASE, 277 .base = S5P6440_GPN_BASE,
280 .config = &s5p6440_gpio_cfgs[4], 278 .config = &s5p64x0_gpio_cfgs[4],
281 .chip = { 279 .chip = {
282 .base = S5P6440_GPN(0), 280 .base = S5P6440_GPN(0),
283 .ngpio = S5P6440_GPIO_N_NR, 281 .ngpio = S5P6440_GPIO_N_NR,
@@ -285,7 +283,7 @@ static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
285 }, 283 },
286 }, { 284 }, {
287 .base = S5P6440_GPP_BASE, 285 .base = S5P6440_GPP_BASE,
288 .config = &s5p6440_gpio_cfgs[5], 286 .config = &s5p64x0_gpio_cfgs[5],
289 .chip = { 287 .chip = {
290 .base = S5P6440_GPP(0), 288 .base = S5P6440_GPP(0),
291 .ngpio = S5P6440_GPIO_P_NR, 289 .ngpio = S5P6440_GPIO_P_NR,
@@ -294,7 +292,7 @@ static struct s3c_gpio_chip s5p6440_gpio_2bit[] = {
294 }, 292 },
295}; 293};
296 294
297void __init s5p6440_gpiolib_set_cfg(struct s3c_gpio_cfg *chipcfg, int nr_chips) 295void __init s5p64x0_gpiolib_set_cfg(struct s3c_gpio_cfg *chipcfg, int nr_chips)
298{ 296{
299 for (; nr_chips > 0; nr_chips--, chipcfg++) { 297 for (; nr_chips > 0; nr_chips--, chipcfg++) {
300 if (!chipcfg->set_config) 298 if (!chipcfg->set_config)
@@ -308,13 +306,13 @@ void __init s5p6440_gpiolib_set_cfg(struct s3c_gpio_cfg *chipcfg, int nr_chips)
308 } 306 }
309} 307}
310 308
311static void __init s5p6440_gpio_add_rbank_4bit2(struct s3c_gpio_chip *chip, 309static void __init s5p64x0_gpio_add_rbank_4bit2(struct s3c_gpio_chip *chip,
312 int nr_chips) 310 int nr_chips)
313{ 311{
314 for (; nr_chips > 0; nr_chips--, chip++) { 312 for (; nr_chips > 0; nr_chips--, chip++) {
315 chip->chip.direction_input = s5p6440_gpiolib_rbank_4bit2_input; 313 chip->chip.direction_input = s5p64x0_gpiolib_rbank_4bit2_input;
316 chip->chip.direction_output = 314 chip->chip.direction_output =
317 s5p6440_gpiolib_rbank_4bit2_output; 315 s5p64x0_gpiolib_rbank_4bit2_output;
318 s3c_gpiolib_add(chip); 316 s3c_gpiolib_add(chip);
319 } 317 }
320} 318}
@@ -324,8 +322,8 @@ static int __init s5p6440_gpiolib_init(void)
324 struct s3c_gpio_chip *chips = s5p6440_gpio_2bit; 322 struct s3c_gpio_chip *chips = s5p6440_gpio_2bit;
325 int nr_chips = ARRAY_SIZE(s5p6440_gpio_2bit); 323 int nr_chips = ARRAY_SIZE(s5p6440_gpio_2bit);
326 324
327 s5p6440_gpiolib_set_cfg(s5p6440_gpio_cfgs, 325 s5p64x0_gpiolib_set_cfg(s5p64x0_gpio_cfgs,
328 ARRAY_SIZE(s5p6440_gpio_cfgs)); 326 ARRAY_SIZE(s5p64x0_gpio_cfgs));
329 327
330 for (; nr_chips > 0; nr_chips--, chips++) 328 for (; nr_chips > 0; nr_chips--, chips++)
331 s3c_gpiolib_add(chips); 329 s3c_gpiolib_add(chips);
@@ -336,8 +334,8 @@ static int __init s5p6440_gpiolib_init(void)
336 samsung_gpiolib_add_4bit2_chips(s5p6440_gpio_4bit2, 334 samsung_gpiolib_add_4bit2_chips(s5p6440_gpio_4bit2,
337 ARRAY_SIZE(s5p6440_gpio_4bit2)); 335 ARRAY_SIZE(s5p6440_gpio_4bit2));
338 336
339 s5p6440_gpio_add_rbank_4bit2(gpio_rbank_4bit2, 337 s5p64x0_gpio_add_rbank_4bit2(s5p6440_gpio_rbank_4bit2,
340 ARRAY_SIZE(gpio_rbank_4bit2)); 338 ARRAY_SIZE(s5p6440_gpio_rbank_4bit2));
341 339
342 return 0; 340 return 0;
343} 341}
diff --git a/arch/arm/mach-s5p64x0/include/mach/debug-macro.S b/arch/arm/mach-s5p64x0/include/mach/debug-macro.S
new file mode 100644
index 000000000000..79b04e6a6f8e
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/debug-macro.S
@@ -0,0 +1,33 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/debug-macro.S
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11/* pull in the relevant register and map files. */
12
13#include <plat/map-base.h>
14#include <plat/map-s5p.h>
15
16#include <plat/regs-serial.h>
17
18 .macro addruart, rp, rv
19 mov \rp, #0xE0000000
20 orr \rp, \rp, #0x00100000
21 ldr \rp, [\rp, #0x118 ]
22 and \rp, \rp, #0xff000
23 teq \rp, #0x50000 @@ S5P6450
24 ldreq \rp, =0xEC800000
25 movne \rp, #0xEC000000 @@ S5P6440
26 ldrne \rv, = S3C_VA_UART
27#if CONFIG_DEBUG_S3C_UART != 0
28 add \rp, \rp, #(0x400 * CONFIG_DEBUG_S3C_UART)
29 add \rv, \rv, #(0x400 * CONFIG_DEBUG_S3C_UART)
30#endif
31 .endm
32
33#include <plat/debug-macro.S>
diff --git a/arch/arm/mach-s5p6440/include/mach/dma.h b/arch/arm/mach-s5p64x0/include/mach/dma.h
index 81209eb1409b..81209eb1409b 100644
--- a/arch/arm/mach-s5p6440/include/mach/dma.h
+++ b/arch/arm/mach-s5p64x0/include/mach/dma.h
diff --git a/arch/arm/mach-s5p6440/include/mach/entry-macro.S b/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
index e65f1b967262..10b62b4f8211 100644
--- a/arch/arm/mach-s5p6440/include/mach/entry-macro.S
+++ b/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
@@ -1,9 +1,9 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/entry-macro.S 1/* linux/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * Low-level IRQ helper macros for the Samsung S5P6440 6 * Low-level IRQ helper macros for the Samsung S5P64X0
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p64x0/include/mach/gpio.h b/arch/arm/mach-s5p64x0/include/mach/gpio.h
new file mode 100644
index 000000000000..5486c8f01f1d
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/gpio.h
@@ -0,0 +1,139 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/gpio.h
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - GPIO lib support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_GPIO_H
14#define __ASM_ARCH_GPIO_H __FILE__
15
16#define gpio_get_value __gpio_get_value
17#define gpio_set_value __gpio_set_value
18#define gpio_cansleep __gpio_cansleep
19#define gpio_to_irq __gpio_to_irq
20
21/* GPIO bank sizes */
22
23#define S5P6440_GPIO_A_NR (6)
24#define S5P6440_GPIO_B_NR (7)
25#define S5P6440_GPIO_C_NR (8)
26#define S5P6440_GPIO_F_NR (2)
27#define S5P6440_GPIO_G_NR (7)
28#define S5P6440_GPIO_H_NR (10)
29#define S5P6440_GPIO_I_NR (16)
30#define S5P6440_GPIO_J_NR (12)
31#define S5P6440_GPIO_N_NR (16)
32#define S5P6440_GPIO_P_NR (8)
33#define S5P6440_GPIO_R_NR (15)
34
35#define S5P6450_GPIO_A_NR (6)
36#define S5P6450_GPIO_B_NR (7)
37#define S5P6450_GPIO_C_NR (8)
38#define S5P6450_GPIO_D_NR (8)
39#define S5P6450_GPIO_F_NR (2)
40#define S5P6450_GPIO_G_NR (14)
41#define S5P6450_GPIO_H_NR (10)
42#define S5P6450_GPIO_I_NR (16)
43#define S5P6450_GPIO_J_NR (12)
44#define S5P6450_GPIO_K_NR (5)
45#define S5P6450_GPIO_N_NR (16)
46#define S5P6450_GPIO_P_NR (11)
47#define S5P6450_GPIO_Q_NR (14)
48#define S5P6450_GPIO_R_NR (15)
49#define S5P6450_GPIO_S_NR (8)
50
51/* GPIO bank numbers */
52
53/* CONFIG_S3C_GPIO_SPACE allows the user to select extra
54 * space for debugging purposes so that any accidental
55 * change from one gpio bank to another can be caught.
56*/
57
58#define S5P64X0_GPIO_NEXT(__gpio) \
59 ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
60
61enum s5p6440_gpio_number {
62 S5P6440_GPIO_A_START = 0,
63 S5P6440_GPIO_B_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_A),
64 S5P6440_GPIO_C_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_B),
65 S5P6440_GPIO_F_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_C),
66 S5P6440_GPIO_G_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_F),
67 S5P6440_GPIO_H_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_G),
68 S5P6440_GPIO_I_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_H),
69 S5P6440_GPIO_J_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_I),
70 S5P6440_GPIO_N_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_J),
71 S5P6440_GPIO_P_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_N),
72 S5P6440_GPIO_R_START = S5P64X0_GPIO_NEXT(S5P6440_GPIO_P),
73};
74
75enum s5p6450_gpio_number {
76 S5P6450_GPIO_A_START = 0,
77 S5P6450_GPIO_B_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_A),
78 S5P6450_GPIO_C_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_B),
79 S5P6450_GPIO_D_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_C),
80 S5P6450_GPIO_F_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_D),
81 S5P6450_GPIO_G_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_F),
82 S5P6450_GPIO_H_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_G),
83 S5P6450_GPIO_I_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_H),
84 S5P6450_GPIO_J_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_I),
85 S5P6450_GPIO_K_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_J),
86 S5P6450_GPIO_N_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_K),
87 S5P6450_GPIO_P_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_N),
88 S5P6450_GPIO_Q_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_P),
89 S5P6450_GPIO_R_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_Q),
90 S5P6450_GPIO_S_START = S5P64X0_GPIO_NEXT(S5P6450_GPIO_R),
91};
92
93/* GPIO number definitions */
94
95#define S5P6440_GPA(_nr) (S5P6440_GPIO_A_START + (_nr))
96#define S5P6440_GPB(_nr) (S5P6440_GPIO_B_START + (_nr))
97#define S5P6440_GPC(_nr) (S5P6440_GPIO_C_START + (_nr))
98#define S5P6440_GPF(_nr) (S5P6440_GPIO_F_START + (_nr))
99#define S5P6440_GPG(_nr) (S5P6440_GPIO_G_START + (_nr))
100#define S5P6440_GPH(_nr) (S5P6440_GPIO_H_START + (_nr))
101#define S5P6440_GPI(_nr) (S5P6440_GPIO_I_START + (_nr))
102#define S5P6440_GPJ(_nr) (S5P6440_GPIO_J_START + (_nr))
103#define S5P6440_GPN(_nr) (S5P6440_GPIO_N_START + (_nr))
104#define S5P6440_GPP(_nr) (S5P6440_GPIO_P_START + (_nr))
105#define S5P6440_GPR(_nr) (S5P6440_GPIO_R_START + (_nr))
106
107#define S5P6450_GPA(_nr) (S5P6450_GPIO_A_START + (_nr))
108#define S5P6450_GPB(_nr) (S5P6450_GPIO_B_START + (_nr))
109#define S5P6450_GPC(_nr) (S5P6450_GPIO_C_START + (_nr))
110#define S5P6450_GPD(_nr) (S5P6450_GPIO_D_START + (_nr))
111#define S5P6450_GPF(_nr) (S5P6450_GPIO_F_START + (_nr))
112#define S5P6450_GPG(_nr) (S5P6450_GPIO_G_START + (_nr))
113#define S5P6450_GPH(_nr) (S5P6450_GPIO_H_START + (_nr))
114#define S5P6450_GPI(_nr) (S5P6450_GPIO_I_START + (_nr))
115#define S5P6450_GPJ(_nr) (S5P6450_GPIO_J_START + (_nr))
116#define S5P6450_GPK(_nr) (S5P6450_GPIO_K_START + (_nr))
117#define S5P6450_GPN(_nr) (S5P6450_GPIO_N_START + (_nr))
118#define S5P6450_GPP(_nr) (S5P6450_GPIO_P_START + (_nr))
119#define S5P6450_GPQ(_nr) (S5P6450_GPIO_Q_START + (_nr))
120#define S5P6450_GPR(_nr) (S5P6450_GPIO_R_START + (_nr))
121#define S5P6450_GPS(_nr) (S5P6450_GPIO_S_START + (_nr))
122
123/* the end of the S5P64X0 specific gpios */
124
125#define S5P6440_GPIO_END (S5P6440_GPR(S5P6440_GPIO_R_NR) + 1)
126#define S5P6450_GPIO_END (S5P6450_GPS(S5P6450_GPIO_S_NR) + 1)
127
128#define S5P64X0_GPIO_END (S5P6440_GPIO_END > S5P6450_GPIO_END ? \
129 S5P6440_GPIO_END : S5P6450_GPIO_END)
130
131#define S3C_GPIO_END S5P64X0_GPIO_END
132
133/* define the number of gpios we need to the one after the last GPIO range */
134
135#define ARCH_NR_GPIOS (S5P64X0_GPIO_END + CONFIG_SAMSUNG_GPIO_EXTRA)
136
137#include <asm-generic/gpio.h>
138
139#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/hardware.h b/arch/arm/mach-s5p64x0/include/mach/hardware.h
index be8b26e875db..d3e87996dd9a 100644
--- a/arch/arm/mach-s5p6440/include/mach/hardware.h
+++ b/arch/arm/mach-s5p64x0/include/mach/hardware.h
@@ -1,9 +1,9 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/hardware.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/hardware.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - Hardware support 6 * S5P64X0 - Hardware support
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p64x0/include/mach/i2c.h b/arch/arm/mach-s5p64x0/include/mach/i2c.h
new file mode 100644
index 000000000000..887d25209e8e
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/i2c.h
@@ -0,0 +1,17 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/i2c.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 I2C configuration
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13extern void s5p6440_i2c0_cfg_gpio(struct platform_device *dev);
14extern void s5p6440_i2c1_cfg_gpio(struct platform_device *dev);
15
16extern void s5p6450_i2c0_cfg_gpio(struct platform_device *dev);
17extern void s5p6450_i2c1_cfg_gpio(struct platform_device *dev);
diff --git a/arch/arm/mach-s5p64x0/include/mach/io.h b/arch/arm/mach-s5p64x0/include/mach/io.h
new file mode 100644
index 000000000000..a3e095c02fb5
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/io.h
@@ -0,0 +1,25 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/io.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Copyright 2008 Simtec Electronics
7 * Ben Dooks <ben-linux@fluff.org>
8 *
9 * Default IO routines for S5P64X0 based
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14*/
15
16#ifndef __ASM_ARM_ARCH_IO_H
17#define __ASM_ARM_ARCH_IO_H
18
19/* No current ISA/PCI bus support. */
20#define __io(a) __typesafe_io(a)
21#define __mem_pci(a) (a)
22
23#define IO_SPACE_LIMIT (0xFFFFFFFF)
24
25#endif
diff --git a/arch/arm/mach-s5p6440/include/mach/irqs.h b/arch/arm/mach-s5p64x0/include/mach/irqs.h
index 16a761270de1..513abffc7604 100644
--- a/arch/arm/mach-s5p6440/include/mach/irqs.h
+++ b/arch/arm/mach-s5p64x0/include/mach/irqs.h
@@ -1,17 +1,17 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/irqs.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/irqs.h
2 * 2 *
3 * Copyright 2009 Samsung Electronics Co., Ltd. 3 * Copyright 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - IRQ definitions 6 * S5P64X0 - IRQ definitions
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11*/ 11*/
12 12
13#ifndef __ASM_ARCH_S5P_IRQS_H 13#ifndef __ASM_ARCH_IRQS_H
14#define __ASM_ARCH_S5P_IRQS_H __FILE__ 14#define __ASM_ARCH_IRQS_H __FILE__
15 15
16#include <plat/irqs.h> 16#include <plat/irqs.h>
17 17
@@ -20,10 +20,12 @@
20#define IRQ_EINT0_3 S5P_IRQ_VIC0(0) 20#define IRQ_EINT0_3 S5P_IRQ_VIC0(0)
21#define IRQ_EINT4_11 S5P_IRQ_VIC0(1) 21#define IRQ_EINT4_11 S5P_IRQ_VIC0(1)
22#define IRQ_RTC_TIC S5P_IRQ_VIC0(2) 22#define IRQ_RTC_TIC S5P_IRQ_VIC0(2)
23#define IRQ_IIS1 S5P_IRQ_VIC0(3) /* for only S5P6450 */
24#define IRQ_IIS2 S5P_IRQ_VIC0(4) /* for only S5P6450 */
23#define IRQ_IIC1 S5P_IRQ_VIC0(5) 25#define IRQ_IIC1 S5P_IRQ_VIC0(5)
24#define IRQ_I2SV40 S5P_IRQ_VIC0(6) 26#define IRQ_I2SV40 S5P_IRQ_VIC0(6)
25#define IRQ_GPS S5P_IRQ_VIC0(7) 27#define IRQ_GPS S5P_IRQ_VIC0(7) /* for only S5P6450 */
26#define IRQ_POST0 S5P_IRQ_VIC0(9) 28
27#define IRQ_2D S5P_IRQ_VIC0(11) 29#define IRQ_2D S5P_IRQ_VIC0(11)
28#define IRQ_TIMER0_VIC S5P_IRQ_VIC0(23) 30#define IRQ_TIMER0_VIC S5P_IRQ_VIC0(23)
29#define IRQ_TIMER1_VIC S5P_IRQ_VIC0(24) 31#define IRQ_TIMER1_VIC S5P_IRQ_VIC0(24)
@@ -39,22 +41,26 @@
39 41
40#define IRQ_EINT12_15 S5P_IRQ_VIC1(0) 42#define IRQ_EINT12_15 S5P_IRQ_VIC1(0)
41#define IRQ_PCM0 S5P_IRQ_VIC1(2) 43#define IRQ_PCM0 S5P_IRQ_VIC1(2)
44#define IRQ_PCM1 S5P_IRQ_VIC1(3) /* for only S5P6450 */
45#define IRQ_PCM2 S5P_IRQ_VIC1(4) /* for only S5P6450 */
42#define IRQ_UART0 S5P_IRQ_VIC1(5) 46#define IRQ_UART0 S5P_IRQ_VIC1(5)
43#define IRQ_UART1 S5P_IRQ_VIC1(6) 47#define IRQ_UART1 S5P_IRQ_VIC1(6)
44#define IRQ_UART2 S5P_IRQ_VIC1(7) 48#define IRQ_UART2 S5P_IRQ_VIC1(7)
45#define IRQ_UART3 S5P_IRQ_VIC1(8) 49#define IRQ_UART3 S5P_IRQ_VIC1(8)
46#define IRQ_DMA0 S5P_IRQ_VIC1(9) 50#define IRQ_DMA0 S5P_IRQ_VIC1(9)
51#define IRQ_UART4 S5P_IRQ_VIC1(10) /* S5P6450 */
52#define IRQ_UART5 S5P_IRQ_VIC1(11) /* S5P6450 */
47#define IRQ_NFC S5P_IRQ_VIC1(13) 53#define IRQ_NFC S5P_IRQ_VIC1(13)
54#define IRQ_USI S5P_IRQ_VIC1(15) /* S5P6450 */
48#define IRQ_SPI0 S5P_IRQ_VIC1(16) 55#define IRQ_SPI0 S5P_IRQ_VIC1(16)
49#define IRQ_SPI1 S5P_IRQ_VIC1(17) 56#define IRQ_SPI1 S5P_IRQ_VIC1(17)
57#define IRQ_HSMMC2 S5P_IRQ_VIC1(17) /* Shared */
50#define IRQ_IIC S5P_IRQ_VIC1(18) 58#define IRQ_IIC S5P_IRQ_VIC1(18)
51#define IRQ_DISPCON3 S5P_IRQ_VIC1(19) 59#define IRQ_DISPCON3 S5P_IRQ_VIC1(19)
52#define IRQ_FIMGVG S5P_IRQ_VIC1(20)
53#define IRQ_EINT_GROUPS S5P_IRQ_VIC1(21) 60#define IRQ_EINT_GROUPS S5P_IRQ_VIC1(21)
54#define IRQ_PMU S5P_IRQ_VIC1(23) 61#define IRQ_PMU S5P_IRQ_VIC1(23) /* S5P6440 */
55#define IRQ_HSMMC0 S5P_IRQ_VIC1(24) 62#define IRQ_HSMMC0 S5P_IRQ_VIC1(24)
56#define IRQ_HSMMC1 S5P_IRQ_VIC1(25) 63#define IRQ_HSMMC1 S5P_IRQ_VIC1(25)
57#define IRQ_HSMMC2 IRQ_SPI1 /* shared with SPI1 */
58#define IRQ_OTG S5P_IRQ_VIC1(26) 64#define IRQ_OTG S5P_IRQ_VIC1(26)
59#define IRQ_DSI S5P_IRQ_VIC1(27) 65#define IRQ_DSI S5P_IRQ_VIC1(27)
60#define IRQ_RTC_ALARM S5P_IRQ_VIC1(28) 66#define IRQ_RTC_ALARM S5P_IRQ_VIC1(28)
@@ -63,6 +69,24 @@
63#define IRQ_TC IRQ_PENDN 69#define IRQ_TC IRQ_PENDN
64#define IRQ_ADC S5P_IRQ_VIC1(31) 70#define IRQ_ADC S5P_IRQ_VIC1(31)
65 71
72/* UART interrupts, S5P6450 has 5 UARTs */
73#define IRQ_S5P_UART_BASE4 (96)
74#define IRQ_S5P_UART_BASE5 (100)
75
76#define IRQ_S5P_UART_RX4 (IRQ_S5P_UART_BASE4 + UART_IRQ_RXD)
77#define IRQ_S5P_UART_TX4 (IRQ_S5P_UART_BASE4 + UART_IRQ_TXD)
78#define IRQ_S5P_UART_ERR4 (IRQ_S5P_UART_BASE4 + UART_IRQ_ERR)
79
80#define IRQ_S5P_UART_RX5 (IRQ_S5P_UART_BASE5 + UART_IRQ_RXD)
81#define IRQ_S5P_UART_TX5 (IRQ_S5P_UART_BASE5 + UART_IRQ_TXD)
82#define IRQ_S5P_UART_ERR5 (IRQ_S5P_UART_BASE5 + UART_IRQ_ERR)
83
84/* S3C compatibilty defines */
85#define IRQ_S3CUART_RX4 IRQ_S5P_UART_RX4
86#define IRQ_S3CUART_RX5 IRQ_S5P_UART_RX5
87
88/* S5P6450 EINT feature will be added */
89
66/* 90/*
67 * Since the IRQ_EINT(x) are a linear mapping on s5p6440 we just defined 91 * Since the IRQ_EINT(x) are a linear mapping on s5p6440 we just defined
68 * them as an IRQ_EINT(x) macro from S5P_IRQ_EINT_BASE which we place 92 * them as an IRQ_EINT(x) macro from S5P_IRQ_EINT_BASE which we place
@@ -115,4 +139,4 @@
115 139
116#define NR_IRQS (IRQ_EINT_GROUP8_BASE + IRQ_EINT_GROUP8_NR + 1) 140#define NR_IRQS (IRQ_EINT_GROUP8_BASE + IRQ_EINT_GROUP8_NR + 1)
117 141
118#endif /* __ASM_ARCH_S5P_IRQS_H */ 142#endif /* __ASM_ARCH_IRQS_H */
diff --git a/arch/arm/mach-s5p64x0/include/mach/map.h b/arch/arm/mach-s5p64x0/include/mach/map.h
new file mode 100644
index 000000000000..31e534156e06
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/map.h
@@ -0,0 +1,83 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/map.h
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - Memory map definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_MAP_H
14#define __ASM_ARCH_MAP_H __FILE__
15
16#include <plat/map-base.h>
17#include <plat/map-s5p.h>
18
19#define S5P64X0_PA_SDRAM (0x20000000)
20
21#define S5P64X0_PA_CHIPID (0xE0000000)
22#define S5P_PA_CHIPID S5P64X0_PA_CHIPID
23
24#define S5P64X0_PA_SYSCON (0xE0100000)
25#define S5P_PA_SYSCON S5P64X0_PA_SYSCON
26
27#define S5P64X0_PA_GPIO (0xE0308000)
28
29#define S5P64X0_PA_VIC0 (0xE4000000)
30#define S5P64X0_PA_VIC1 (0xE4100000)
31
32#define S5P64X0_PA_PDMA (0xE9000000)
33
34#define S5P64X0_PA_TIMER (0xEA000000)
35#define S5P_PA_TIMER S5P64X0_PA_TIMER
36
37#define S5P64X0_PA_RTC (0xEA100000)
38
39#define S5P64X0_PA_WDT (0xEA200000)
40
41#define S5P6440_PA_UART(x) (0xEC000000 + ((x) * S3C_UART_OFFSET))
42#define S5P6450_PA_UART(x) ((x < 5) ? (0xEC800000 + ((x) * S3C_UART_OFFSET)) : (0xEC000000))
43
44#define S5P_PA_UART0 S5P6450_PA_UART(0)
45#define S5P_PA_UART1 S5P6450_PA_UART(1)
46#define S5P_PA_UART2 S5P6450_PA_UART(2)
47#define S5P_PA_UART3 S5P6450_PA_UART(3)
48#define S5P_PA_UART4 S5P6450_PA_UART(4)
49#define S5P_PA_UART5 S5P6450_PA_UART(5)
50
51#define S5P_SZ_UART SZ_256
52
53#define S5P6440_PA_IIC0 (0xEC104000)
54#define S5P6440_PA_IIC1 (0xEC20F000)
55#define S5P6450_PA_IIC0 (0xEC100000)
56#define S5P6450_PA_IIC1 (0xEC200000)
57
58#define S5P64X0_PA_SPI0 (0xEC400000)
59#define S5P64X0_PA_SPI1 (0xEC500000)
60
61#define S5P64X0_PA_HSOTG (0xED100000)
62
63#define S5P64X0_PA_HSMMC(x) (0xED800000 + ((x) * 0x100000))
64
65#define S5P64X0_PA_I2S (0xF2000000)
66
67#define S5P64X0_PA_PCM (0xF2100000)
68
69#define S5P64X0_PA_ADC (0xF3000000)
70
71/* compatibiltiy defines. */
72
73#define S3C_PA_HSMMC0 S5P64X0_PA_HSMMC(0)
74#define S3C_PA_HSMMC1 S5P64X0_PA_HSMMC(1)
75#define S3C_PA_HSMMC2 S5P64X0_PA_HSMMC(2)
76#define S3C_PA_IIC S5P6440_PA_IIC0
77#define S3C_PA_IIC1 S5P6440_PA_IIC1
78#define S3C_PA_RTC S5P64X0_PA_RTC
79#define S3C_PA_WDT S5P64X0_PA_WDT
80
81#define SAMSUNG_PA_ADC S5P64X0_PA_ADC
82
83#endif /* __ASM_ARCH_MAP_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/memory.h b/arch/arm/mach-s5p64x0/include/mach/memory.h
index d62910c71b56..1b036b0a24ce 100644
--- a/arch/arm/mach-s5p6440/include/mach/memory.h
+++ b/arch/arm/mach-s5p64x0/include/mach/memory.h
@@ -1,9 +1,9 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/memory.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/memory.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - Memory definitions 6 * S5P64X0 - Memory definitions
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -11,9 +11,9 @@
11*/ 11*/
12 12
13#ifndef __ASM_ARCH_MEMORY_H 13#ifndef __ASM_ARCH_MEMORY_H
14#define __ASM_ARCH_MEMORY_H 14#define __ASM_ARCH_MEMORY_H __FILE__
15 15
16#define PHYS_OFFSET UL(0x20000000) 16#define PHYS_OFFSET UL(0x20000000)
17#define CONSISTENT_DMA_SIZE SZ_8M 17#define CONSISTENT_DMA_SIZE SZ_8M
18 18
19#endif /* __ASM_ARCH_MEMORY_H */ 19#endif /* __ASM_ARCH_MEMORY_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/pwm-clock.h b/arch/arm/mach-s5p64x0/include/mach/pwm-clock.h
index 6a2a02fdf12a..19fff8b701c0 100644
--- a/arch/arm/mach-s5p6440/include/mach/pwm-clock.h
+++ b/arch/arm/mach-s5p64x0/include/mach/pwm-clock.h
@@ -1,16 +1,14 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/pwm-clock.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/pwm-clock.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * Copyright 2008 Openmoko, Inc. 6 * Copyright 2008 Openmoko, Inc.
7 * Copyright 2008 Simtec Electronics 7 * Copyright 2008 Simtec Electronics
8 * Ben Dooks <ben@simtec.co.uk> 8 * Ben Dooks <ben@simtec.co.uk>
9 * http://armlinux.simtec.co.uk/ 9 * http://armlinux.simtec.co.uk/
10 * 10 *
11 * Based on arch/arm/mach-s3c64xx/include/mach/pwm-clock.h 11 * S5P64X0 - pwm clock and timer support
12 *
13 * S5P6440 - pwm clock and timer support
14 * 12 *
15 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p64x0/include/mach/regs-clock.h b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
new file mode 100644
index 000000000000..58e1bc813804
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
@@ -0,0 +1,63 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - Clock register definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_REGS_CLOCK_H
14#define __ASM_ARCH_REGS_CLOCK_H __FILE__
15
16#include <mach/map.h>
17
18#define S5P_CLKREG(x) (S3C_VA_SYS + (x))
19
20#define S5P64X0_APLL_CON S5P_CLKREG(0x0C)
21#define S5P64X0_MPLL_CON S5P_CLKREG(0x10)
22#define S5P64X0_EPLL_CON S5P_CLKREG(0x14)
23#define S5P64X0_EPLL_CON_K S5P_CLKREG(0x18)
24
25#define S5P64X0_CLK_SRC0 S5P_CLKREG(0x1C)
26
27#define S5P64X0_CLK_DIV0 S5P_CLKREG(0x20)
28#define S5P64X0_CLK_DIV1 S5P_CLKREG(0x24)
29#define S5P64X0_CLK_DIV2 S5P_CLKREG(0x28)
30
31#define S5P64X0_CLK_GATE_HCLK0 S5P_CLKREG(0x30)
32#define S5P64X0_CLK_GATE_PCLK S5P_CLKREG(0x34)
33#define S5P64X0_CLK_GATE_SCLK0 S5P_CLKREG(0x38)
34#define S5P64X0_CLK_GATE_MEM0 S5P_CLKREG(0x3C)
35
36#define S5P64X0_CLK_DIV3 S5P_CLKREG(0x40)
37
38#define S5P64X0_CLK_GATE_HCLK1 S5P_CLKREG(0x44)
39#define S5P64X0_CLK_GATE_SCLK1 S5P_CLKREG(0x48)
40
41#define S5P6450_DPLL_CON S5P_CLKREG(0x50)
42#define S5P6450_DPLL_CON_K S5P_CLKREG(0x54)
43
44#define S5P64X0_CLK_SRC1 S5P_CLKREG(0x10C)
45
46#define S5P64X0_SYS_ID S5P_CLKREG(0x118)
47#define S5P64X0_SYS_OTHERS S5P_CLKREG(0x11C)
48
49#define S5P64X0_PWR_CFG S5P_CLKREG(0x804)
50#define S5P64X0_OTHERS S5P_CLKREG(0x900)
51
52#define S5P64X0_CLKDIV0_HCLK_SHIFT (8)
53#define S5P64X0_CLKDIV0_HCLK_MASK (0xF << S5P64X0_CLKDIV0_HCLK_SHIFT)
54
55#define S5P64X0_OTHERS_USB_SIG_MASK (1 << 16)
56
57/* Compatibility defines */
58
59#define ARM_CLK_DIV S5P64X0_CLK_DIV0
60#define ARM_DIV_RATIO_SHIFT 0
61#define ARM_DIV_MASK (0xF << ARM_DIV_RATIO_SHIFT)
62
63#endif /* __ASM_ARCH_REGS_CLOCK_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/regs-gpio.h b/arch/arm/mach-s5p64x0/include/mach/regs-gpio.h
index 82ff753913da..85f448e20a8b 100644
--- a/arch/arm/mach-s5p6440/include/mach/regs-gpio.h
+++ b/arch/arm/mach-s5p64x0/include/mach/regs-gpio.h
@@ -1,21 +1,24 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/regs-gpio.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/regs-gpio.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - GPIO register definitions 6 * S5P64X0 - GPIO register definitions
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11*/
12 12
13#ifndef __ASM_ARCH_REGS_GPIO_H 13#ifndef __ASM_ARCH_REGS_GPIO_H
14#define __ASM_ARCH_REGS_GPIO_H __FILE__ 14#define __ASM_ARCH_REGS_GPIO_H __FILE__
15 15
16#include <mach/map.h> 16#include <mach/map.h>
17 17
18/* Will be implemented S5P6442 GPIOlib */
19
18/* Base addresses for each of the banks */ 20/* Base addresses for each of the banks */
21
19#define S5P6440_GPA_BASE (S5P_VA_GPIO + 0x0000) 22#define S5P6440_GPA_BASE (S5P_VA_GPIO + 0x0000)
20#define S5P6440_GPB_BASE (S5P_VA_GPIO + 0x0020) 23#define S5P6440_GPB_BASE (S5P_VA_GPIO + 0x0020)
21#define S5P6440_GPC_BASE (S5P_VA_GPIO + 0x0040) 24#define S5P6440_GPC_BASE (S5P_VA_GPIO + 0x0040)
@@ -27,6 +30,7 @@
27#define S5P6440_GPN_BASE (S5P_VA_GPIO + 0x0830) 30#define S5P6440_GPN_BASE (S5P_VA_GPIO + 0x0830)
28#define S5P6440_GPP_BASE (S5P_VA_GPIO + 0x0160) 31#define S5P6440_GPP_BASE (S5P_VA_GPIO + 0x0160)
29#define S5P6440_GPR_BASE (S5P_VA_GPIO + 0x0290) 32#define S5P6440_GPR_BASE (S5P_VA_GPIO + 0x0290)
33
30#define S5P6440_EINT0CON0 (S5P_VA_GPIO + 0x900) 34#define S5P6440_EINT0CON0 (S5P_VA_GPIO + 0x900)
31#define S5P6440_EINT0FLTCON0 (S5P_VA_GPIO + 0x910) 35#define S5P6440_EINT0FLTCON0 (S5P_VA_GPIO + 0x910)
32#define S5P6440_EINT0FLTCON1 (S5P_VA_GPIO + 0x914) 36#define S5P6440_EINT0FLTCON1 (S5P_VA_GPIO + 0x914)
@@ -34,19 +38,23 @@
34#define S5P6440_EINT0PEND (S5P_VA_GPIO + 0x924) 38#define S5P6440_EINT0PEND (S5P_VA_GPIO + 0x924)
35 39
36/* for LCD */ 40/* for LCD */
41
37#define S5P6440_SPCON_LCD_SEL_RGB (1 << 0) 42#define S5P6440_SPCON_LCD_SEL_RGB (1 << 0)
38#define S5P6440_SPCON_LCD_SEL_MASK (3 << 0) 43#define S5P6440_SPCON_LCD_SEL_MASK (3 << 0)
39 44
40/* These set of macros are not really useful for the 45/*
41 * GPF/GPI/GPJ/GPN/GPP, 46 * These set of macros are not really useful for the
42 * useful for others set of GPIO's (4 bit) 47 * GPF/GPI/GPJ/GPN/GPP, useful for others set of GPIO's (4 bit)
43 */ 48 */
49
44#define S5P6440_GPIO_CONMASK(__gpio) (0xf << ((__gpio) * 4)) 50#define S5P6440_GPIO_CONMASK(__gpio) (0xf << ((__gpio) * 4))
45#define S5P6440_GPIO_INPUT(__gpio) (0x0 << ((__gpio) * 4)) 51#define S5P6440_GPIO_INPUT(__gpio) (0x0 << ((__gpio) * 4))
46#define S5P6440_GPIO_OUTPUT(__gpio) (0x1 << ((__gpio) * 4)) 52#define S5P6440_GPIO_OUTPUT(__gpio) (0x1 << ((__gpio) * 4))
47 53
48/* Use these macros for GPF/GPI/GPJ/GPN/GPP set of GPIO (2 bit) 54/*
49 * */ 55 * Use these macros for GPF/GPI/GPJ/GPN/GPP set of GPIO (2 bit)
56 */
57
50#define S5P6440_GPIO2_CONMASK(__gpio) (0x3 << ((__gpio) * 2)) 58#define S5P6440_GPIO2_CONMASK(__gpio) (0x3 << ((__gpio) * 2))
51#define S5P6440_GPIO2_INPUT(__gpio) (0x0 << ((__gpio) * 2)) 59#define S5P6440_GPIO2_INPUT(__gpio) (0x0 << ((__gpio) * 2))
52#define S5P6440_GPIO2_OUTPUT(__gpio) (0x1 << ((__gpio) * 2)) 60#define S5P6440_GPIO2_OUTPUT(__gpio) (0x1 << ((__gpio) * 2))
diff --git a/arch/arm/mach-s5p6440/include/mach/regs-irq.h b/arch/arm/mach-s5p64x0/include/mach/regs-irq.h
index a961f4beeb0c..4aaebdace55f 100644
--- a/arch/arm/mach-s5p6440/include/mach/regs-irq.h
+++ b/arch/arm/mach-s5p64x0/include/mach/regs-irq.h
@@ -1,9 +1,9 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/regs-irq.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/regs-irq.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - IRQ register definitions 6 * S5P64X0 - IRQ register definitions
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h b/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
new file mode 100644
index 000000000000..ff85b4b6e8d9
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
@@ -0,0 +1,46 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Header file for s5p64x0 clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_CLOCK_H
14#define __ASM_ARCH_CLOCK_H __FILE__
15
16#include <linux/clk.h>
17
18extern struct clksrc_clk clk_mout_apll;
19extern struct clksrc_clk clk_mout_mpll;
20extern struct clksrc_clk clk_mout_epll;
21
22extern int s5p64x0_epll_enable(struct clk *clk, int enable);
23extern unsigned long s5p64x0_epll_get_rate(struct clk *clk);
24
25extern unsigned long s5p64x0_armclk_get_rate(struct clk *clk);
26extern unsigned long s5p64x0_armclk_round_rate(struct clk *clk, unsigned long rate);
27extern int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate);
28
29extern struct clk_ops s5p64x0_clkarm_ops;
30
31extern struct clksrc_clk clk_armclk;
32extern struct clksrc_clk clk_dout_mpll;
33
34extern struct clk *clkset_hclk_low_list[];
35extern struct clksrc_sources clkset_hclk_low;
36
37extern int s5p64x0_pclk_ctrl(struct clk *clk, int enable);
38extern int s5p64x0_hclk0_ctrl(struct clk *clk, int enable);
39extern int s5p64x0_hclk1_ctrl(struct clk *clk, int enable);
40extern int s5p64x0_sclk_ctrl(struct clk *clk, int enable);
41extern int s5p64x0_sclk1_ctrl(struct clk *clk, int enable);
42extern int s5p64x0_mem_ctrl(struct clk *clk, int enable);
43
44extern int s5p64x0_clk48m_ctrl(struct clk *clk, int enable);
45
46#endif /* __ASM_ARCH_CLOCK_H */
diff --git a/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h b/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
new file mode 100644
index 000000000000..170a20a9643a
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
@@ -0,0 +1,20 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/spi-clocks.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Copyright (C) 2010 Samsung Electronics Co. Ltd.
7 * Jaswinder Singh <jassi.brar@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#ifndef __ASM_ARCH_SPI_CLKS_H
15#define __ASM_ARCH_SPI_CLKS_H __FILE__
16
17#define S5P64X0_SPI_SRCCLK_PCLK 0
18#define S5P64X0_SPI_SRCCLK_SCLK 1
19
20#endif /* __ASM_ARCH_SPI_CLKS_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/system.h b/arch/arm/mach-s5p64x0/include/mach/system.h
index a359ee3fa510..60f57532c970 100644
--- a/arch/arm/mach-s5p6440/include/mach/system.h
+++ b/arch/arm/mach-s5p64x0/include/mach/system.h
@@ -1,9 +1,9 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/system.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/system.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - system support header 6 * S5P64X0 - system support header
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p6440/include/mach/tick.h b/arch/arm/mach-s5p64x0/include/mach/tick.h
index 2f25c7f07970..00aa7f1d8e51 100644
--- a/arch/arm/mach-s5p6440/include/mach/tick.h
+++ b/arch/arm/mach-s5p64x0/include/mach/tick.h
@@ -1,9 +1,14 @@
1/* linux/arch/arm/mach-s5p6440/include/mach/tick.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/tick.h
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * S5P6440 - Timer tick support definitions 6 * Copyright 2008 Openmoko, Inc.
7 * Copyright 2008 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
10 *
11 * S5P64X0 - Timer tick support definitions
7 * 12 *
8 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 14 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p6440/include/mach/timex.h b/arch/arm/mach-s5p64x0/include/mach/timex.h
index fb2e8cd40829..4b91faa195a8 100644
--- a/arch/arm/mach-s5p6440/include/mach/timex.h
+++ b/arch/arm/mach-s5p64x0/include/mach/timex.h
@@ -1,9 +1,12 @@
1/* arch/arm/mach-s3c64xx/include/mach/timex.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/timex.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
2 * 5 *
3 * Copyright (c) 2003-2005 Simtec Electronics 6 * Copyright (c) 2003-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 7 * Ben Dooks <ben@simtec.co.uk>
5 * 8 *
6 * S3C6400 - time parameters 9 * S5P64X0 - time parameters
7 * 10 *
8 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
diff --git a/arch/arm/mach-s5p64x0/include/mach/uncompress.h b/arch/arm/mach-s5p64x0/include/mach/uncompress.h
new file mode 100644
index 000000000000..c65b229aab23
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/include/mach/uncompress.h
@@ -0,0 +1,212 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/uncompress.h
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - uncompress code
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_UNCOMPRESS_H
14#define __ASM_ARCH_UNCOMPRESS_H
15
16#include <mach/map.h>
17
18/*
19 * cannot use commonly <plat/uncompress.h>
20 * because uart base of S5P6440 and S5P6450 is different
21 */
22
23typedef unsigned int upf_t; /* cannot include linux/serial_core.h */
24
25/* uart setup */
26
27static unsigned int fifo_mask;
28static unsigned int fifo_max;
29
30/* forward declerations */
31
32static void arch_detect_cpu(void);
33
34/* defines for UART registers */
35
36#include <plat/regs-serial.h>
37#include <plat/regs-watchdog.h>
38
39/* working in physical space... */
40#undef S3C2410_WDOGREG
41#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
42
43/* how many bytes we allow into the FIFO at a time in FIFO mode */
44#define FIFO_MAX (14)
45
46static unsigned long uart_base;
47
48static __inline__ void get_uart_base(void)
49{
50 unsigned int chipid;
51
52 chipid = *(const volatile unsigned int __force *) 0xE0100118;
53
54 uart_base = S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT;
55
56 if ((chipid & 0xff000) == 0x50000)
57 uart_base += 0xEC800000;
58 else
59 uart_base += 0xEC000000;
60}
61
62static __inline__ void uart_wr(unsigned int reg, unsigned int val)
63{
64 volatile unsigned int *ptr;
65
66 get_uart_base();
67 ptr = (volatile unsigned int *)(reg + uart_base);
68 *ptr = val;
69}
70
71static __inline__ unsigned int uart_rd(unsigned int reg)
72{
73 volatile unsigned int *ptr;
74
75 get_uart_base();
76 ptr = (volatile unsigned int *)(reg + uart_base);
77 return *ptr;
78}
79
80/*
81 * we can deal with the case the UARTs are being run
82 * in FIFO mode, so that we don't hold up our execution
83 * waiting for tx to happen...
84 */
85
86static void putc(int ch)
87{
88 if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
89 int level;
90
91 while (1) {
92 level = uart_rd(S3C2410_UFSTAT);
93 level &= fifo_mask;
94
95 if (level < fifo_max)
96 break;
97 }
98
99 } else {
100 /* not using fifos */
101
102 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
103 barrier();
104 }
105
106 /* write byte to transmission register */
107 uart_wr(S3C2410_UTXH, ch);
108}
109
110static inline void flush(void)
111{
112}
113
114#define __raw_writel(d, ad) \
115 do { \
116 *((volatile unsigned int __force *)(ad)) = (d); \
117 } while (0)
118
119/*
120 * CONFIG_S3C_BOOT_WATCHDOG
121 *
122 * Simple boot-time watchdog setup, to reboot the system if there is
123 * any problem with the boot process
124 */
125
126#ifdef CONFIG_S3C_BOOT_WATCHDOG
127
128#define WDOG_COUNT (0xff00)
129
130static inline void arch_decomp_wdog(void)
131{
132 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
133}
134
135static void arch_decomp_wdog_start(void)
136{
137 __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
138 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
139 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
140}
141
142#else
143#define arch_decomp_wdog_start()
144#define arch_decomp_wdog()
145#endif
146
147#ifdef CONFIG_S3C_BOOT_ERROR_RESET
148
149static void arch_decomp_error(const char *x)
150{
151 putstr("\n\n");
152 putstr(x);
153 putstr("\n\n -- System resetting\n");
154
155 __raw_writel(0x4000, S3C2410_WTDAT);
156 __raw_writel(0x4000, S3C2410_WTCNT);
157 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
158
159 while(1);
160}
161
162#define arch_error arch_decomp_error
163#endif
164
165#ifdef CONFIG_S3C_BOOT_UART_FORCE_FIFO
166static inline void arch_enable_uart_fifo(void)
167{
168 u32 fifocon = uart_rd(S3C2410_UFCON);
169
170 if (!(fifocon & S3C2410_UFCON_FIFOMODE)) {
171 fifocon |= S3C2410_UFCON_RESETBOTH;
172 uart_wr(S3C2410_UFCON, fifocon);
173
174 /* wait for fifo reset to complete */
175 while (1) {
176 fifocon = uart_rd(S3C2410_UFCON);
177 if (!(fifocon & S3C2410_UFCON_RESETBOTH))
178 break;
179 }
180 }
181}
182#else
183#define arch_enable_uart_fifo() do { } while(0)
184#endif
185
186static void arch_decomp_setup(void)
187{
188 /*
189 * we may need to setup the uart(s) here if we are not running
190 * on an BAST... the BAST will have left the uarts configured
191 * after calling linux.
192 */
193
194 arch_detect_cpu();
195 arch_decomp_wdog_start();
196
197 /*
198 * Enable the UART FIFOs if they where not enabled and our
199 * configuration says we should turn them on.
200 */
201
202 arch_enable_uart_fifo();
203}
204
205
206
207static void arch_detect_cpu(void)
208{
209 /* we do not need to do any cpu detection here at the moment. */
210}
211
212#endif /* __ASM_ARCH_UNCOMPRESS_H */
diff --git a/arch/arm/mach-s5p6440/include/mach/vmalloc.h b/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
index e3f0eebf5205..97a9df38f1cf 100644
--- a/arch/arm/mach-s5p6440/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
@@ -1,4 +1,7 @@
1/* arch/arm/mach-s5p6440/include/mach/vmalloc.h 1/* linux/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
2 * 5 *
3 * Copyright 2010 Ben Dooks <ben-linux@fluff.org> 6 * Copyright 2010 Ben Dooks <ben-linux@fluff.org>
4 * 7 *
diff --git a/arch/arm/mach-s5p64x0/init.c b/arch/arm/mach-s5p64x0/init.c
new file mode 100644
index 000000000000..79833caf8165
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/init.c
@@ -0,0 +1,73 @@
1/* linux/arch/arm/mach-s5p64x0/init.c
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - Init support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/init.h>
16#include <linux/serial_core.h>
17
18#include <mach/map.h>
19
20#include <plat/cpu.h>
21#include <plat/devs.h>
22#include <plat/s5p6440.h>
23#include <plat/s5p6450.h>
24#include <plat/regs-serial.h>
25
26static struct s3c24xx_uart_clksrc s5p64x0_serial_clocks[] = {
27 [0] = {
28 .name = "pclk_low",
29 .divisor = 1,
30 .min_baud = 0,
31 .max_baud = 0,
32 },
33 [1] = {
34 .name = "uclk1",
35 .divisor = 1,
36 .min_baud = 0,
37 .max_baud = 0,
38 },
39};
40
41/* uart registration process */
42
43void __init s5p64x0_common_init_uarts(struct s3c2410_uartcfg *cfg, int no)
44{
45 struct s3c2410_uartcfg *tcfg = cfg;
46 u32 ucnt;
47
48 for (ucnt = 0; ucnt < no; ucnt++, tcfg++) {
49 if (!tcfg->clocks) {
50 tcfg->clocks = s5p64x0_serial_clocks;
51 tcfg->clocks_size = ARRAY_SIZE(s5p64x0_serial_clocks);
52 }
53 }
54}
55
56void __init s5p6440_init_uarts(struct s3c2410_uartcfg *cfg, int no)
57{
58 int uart;
59
60 for (uart = 0; uart < no; uart++) {
61 s5p_uart_resources[uart].resources->start = S5P6440_PA_UART(uart);
62 s5p_uart_resources[uart].resources->end = S5P6440_PA_UART(uart) + S5P_SZ_UART;
63 }
64
65 s5p64x0_common_init_uarts(cfg, no);
66 s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
67}
68
69void __init s5p6450_init_uarts(struct s3c2410_uartcfg *cfg, int no)
70{
71 s5p64x0_common_init_uarts(cfg, no);
72 s3c24xx_init_uartdevs("s3c6400-uart", s5p_uart_resources, cfg, no);
73}
diff --git a/arch/arm/mach-s5p6440/mach-smdk6440.c b/arch/arm/mach-s5p64x0/mach-smdk6440.c
index 9202aaac3b56..87c3f03c618c 100644
--- a/arch/arm/mach-s5p6440/mach-smdk6440.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6440.c
@@ -1,7 +1,7 @@
1/* linux/arch/arm/mach-s5p6440/mach-smdk6440.c 1/* linux/arch/arm/mach-s5p64x0/mach-smdk6440.c
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -21,21 +21,22 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/gpio.h>
24 25
25#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 27#include <asm/mach/map.h>
28#include <asm/irq.h>
29#include <asm/mach-types.h>
27 30
28#include <mach/hardware.h> 31#include <mach/hardware.h>
29#include <mach/map.h> 32#include <mach/map.h>
30 33#include <mach/regs-clock.h>
31#include <asm/irq.h> 34#include <mach/i2c.h>
32#include <asm/mach-types.h>
33 35
34#include <plat/regs-serial.h> 36#include <plat/regs-serial.h>
35 37#include <plat/gpio-cfg.h>
36#include <plat/s5p6440.h> 38#include <plat/s5p6440.h>
37#include <plat/clock.h> 39#include <plat/clock.h>
38#include <mach/regs-clock.h>
39#include <plat/devs.h> 40#include <plat/devs.h>
40#include <plat/cpu.h> 41#include <plat/cpu.h>
41#include <plat/iic.h> 42#include <plat/iic.h>
@@ -58,43 +59,60 @@
58 59
59static struct s3c2410_uartcfg smdk6440_uartcfgs[] __initdata = { 60static struct s3c2410_uartcfg smdk6440_uartcfgs[] __initdata = {
60 [0] = { 61 [0] = {
61 .hwport = 0, 62 .hwport = 0,
62 .flags = 0, 63 .flags = 0,
63 .ucon = SMDK6440_UCON_DEFAULT, 64 .ucon = SMDK6440_UCON_DEFAULT,
64 .ulcon = SMDK6440_ULCON_DEFAULT, 65 .ulcon = SMDK6440_ULCON_DEFAULT,
65 .ufcon = SMDK6440_UFCON_DEFAULT, 66 .ufcon = SMDK6440_UFCON_DEFAULT,
66 }, 67 },
67 [1] = { 68 [1] = {
68 .hwport = 1, 69 .hwport = 1,
69 .flags = 0, 70 .flags = 0,
70 .ucon = SMDK6440_UCON_DEFAULT, 71 .ucon = SMDK6440_UCON_DEFAULT,
71 .ulcon = SMDK6440_ULCON_DEFAULT, 72 .ulcon = SMDK6440_ULCON_DEFAULT,
72 .ufcon = SMDK6440_UFCON_DEFAULT, 73 .ufcon = SMDK6440_UFCON_DEFAULT,
73 }, 74 },
74 [2] = { 75 [2] = {
75 .hwport = 2, 76 .hwport = 2,
76 .flags = 0, 77 .flags = 0,
77 .ucon = SMDK6440_UCON_DEFAULT, 78 .ucon = SMDK6440_UCON_DEFAULT,
78 .ulcon = SMDK6440_ULCON_DEFAULT, 79 .ulcon = SMDK6440_ULCON_DEFAULT,
79 .ufcon = SMDK6440_UFCON_DEFAULT, 80 .ufcon = SMDK6440_UFCON_DEFAULT,
80 }, 81 },
81 [3] = { 82 [3] = {
82 .hwport = 3, 83 .hwport = 3,
83 .flags = 0, 84 .flags = 0,
84 .ucon = SMDK6440_UCON_DEFAULT, 85 .ucon = SMDK6440_UCON_DEFAULT,
85 .ulcon = SMDK6440_ULCON_DEFAULT, 86 .ulcon = SMDK6440_ULCON_DEFAULT,
86 .ufcon = SMDK6440_UFCON_DEFAULT, 87 .ufcon = SMDK6440_UFCON_DEFAULT,
87 }, 88 },
88}; 89};
89 90
90static struct platform_device *smdk6440_devices[] __initdata = { 91static struct platform_device *smdk6440_devices[] __initdata = {
91 &s5p6440_device_iis,
92 &s3c_device_adc, 92 &s3c_device_adc,
93 &s3c_device_rtc, 93 &s3c_device_rtc,
94 &s3c_device_i2c0, 94 &s3c_device_i2c0,
95 &s3c_device_i2c1, 95 &s3c_device_i2c1,
96 &s3c_device_ts, 96 &s3c_device_ts,
97 &s3c_device_wdt, 97 &s3c_device_wdt,
98 &s5p6440_device_iis,
99};
100
101static struct s3c2410_platform_i2c s5p6440_i2c0_data __initdata = {
102 .flags = 0,
103 .slave_addr = 0x10,
104 .frequency = 100*1000,
105 .sda_delay = 100,
106 .cfg_gpio = s5p6440_i2c0_cfg_gpio,
107};
108
109static struct s3c2410_platform_i2c s5p6440_i2c1_data __initdata = {
110 .flags = 0,
111 .bus_num = 1,
112 .slave_addr = 0x10,
113 .frequency = 100*1000,
114 .sda_delay = 100,
115 .cfg_gpio = s5p6440_i2c1_cfg_gpio,
98}; 116};
99 117
100static struct i2c_board_info smdk6440_i2c_devs0[] __initdata = { 118static struct i2c_board_info smdk6440_i2c_devs0[] __initdata = {
@@ -113,7 +131,7 @@ static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
113 131
114static void __init smdk6440_map_io(void) 132static void __init smdk6440_map_io(void)
115{ 133{
116 s5p_init_io(NULL, 0, S5P_SYS_ID); 134 s5p_init_io(NULL, 0, S5P64X0_SYS_ID);
117 s3c24xx_init_clocks(12000000); 135 s3c24xx_init_clocks(12000000);
118 s3c24xx_init_uarts(smdk6440_uartcfgs, ARRAY_SIZE(smdk6440_uartcfgs)); 136 s3c24xx_init_uarts(smdk6440_uartcfgs, ARRAY_SIZE(smdk6440_uartcfgs));
119} 137}
@@ -122,9 +140,8 @@ static void __init smdk6440_machine_init(void)
122{ 140{
123 s3c24xx_ts_set_platdata(&s3c_ts_platform); 141 s3c24xx_ts_set_platdata(&s3c_ts_platform);
124 142
125 /* I2C */ 143 s3c_i2c0_set_platdata(&s5p6440_i2c0_data);
126 s3c_i2c0_set_platdata(NULL); 144 s3c_i2c1_set_platdata(&s5p6440_i2c1_data);
127 s3c_i2c1_set_platdata(NULL);
128 i2c_register_board_info(0, smdk6440_i2c_devs0, 145 i2c_register_board_info(0, smdk6440_i2c_devs0,
129 ARRAY_SIZE(smdk6440_i2c_devs0)); 146 ARRAY_SIZE(smdk6440_i2c_devs0));
130 i2c_register_board_info(1, smdk6440_i2c_devs1, 147 i2c_register_board_info(1, smdk6440_i2c_devs1,
@@ -135,9 +152,7 @@ static void __init smdk6440_machine_init(void)
135 152
136MACHINE_START(SMDK6440, "SMDK6440") 153MACHINE_START(SMDK6440, "SMDK6440")
137 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 154 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
138 .phys_io = S3C_PA_UART & 0xfff00000, 155 .boot_params = S5P64X0_PA_SDRAM + 0x100,
139 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
140 .boot_params = S5P_PA_SDRAM + 0x100,
141 156
142 .init_irq = s5p6440_init_irq, 157 .init_irq = s5p6440_init_irq,
143 .map_io = smdk6440_map_io, 158 .map_io = smdk6440_map_io,
diff --git a/arch/arm/mach-s5p64x0/mach-smdk6450.c b/arch/arm/mach-s5p64x0/mach-smdk6450.c
new file mode 100644
index 000000000000..d609f5af2b98
--- /dev/null
+++ b/arch/arm/mach-s5p64x0/mach-smdk6450.c
@@ -0,0 +1,180 @@
1/* linux/arch/arm/mach-s5p64x0/mach-smdk6450.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/interrupt.h>
14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/delay.h>
17#include <linux/init.h>
18#include <linux/i2c.h>
19#include <linux/serial_core.h>
20#include <linux/platform_device.h>
21#include <linux/io.h>
22#include <linux/module.h>
23#include <linux/clk.h>
24#include <linux/gpio.h>
25
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/irq.h>
29#include <asm/mach-types.h>
30
31#include <mach/hardware.h>
32#include <mach/map.h>
33#include <mach/regs-clock.h>
34#include <mach/i2c.h>
35
36#include <plat/regs-serial.h>
37#include <plat/gpio-cfg.h>
38#include <plat/s5p6450.h>
39#include <plat/clock.h>
40#include <plat/devs.h>
41#include <plat/cpu.h>
42#include <plat/iic.h>
43#include <plat/pll.h>
44#include <plat/adc.h>
45#include <plat/ts.h>
46
47#define SMDK6450_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
48 S3C2410_UCON_RXILEVEL | \
49 S3C2410_UCON_TXIRQMODE | \
50 S3C2410_UCON_RXIRQMODE | \
51 S3C2410_UCON_RXFIFO_TOI | \
52 S3C2443_UCON_RXERR_IRQEN)
53
54#define SMDK6450_ULCON_DEFAULT S3C2410_LCON_CS8
55
56#define SMDK6450_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
57 S3C2440_UFCON_TXTRIG16 | \
58 S3C2410_UFCON_RXTRIG8)
59
60static struct s3c2410_uartcfg smdk6450_uartcfgs[] __initdata = {
61 [0] = {
62 .hwport = 0,
63 .flags = 0,
64 .ucon = SMDK6450_UCON_DEFAULT,
65 .ulcon = SMDK6450_ULCON_DEFAULT,
66 .ufcon = SMDK6450_UFCON_DEFAULT,
67 },
68 [1] = {
69 .hwport = 1,
70 .flags = 0,
71 .ucon = SMDK6450_UCON_DEFAULT,
72 .ulcon = SMDK6450_ULCON_DEFAULT,
73 .ufcon = SMDK6450_UFCON_DEFAULT,
74 },
75 [2] = {
76 .hwport = 2,
77 .flags = 0,
78 .ucon = SMDK6450_UCON_DEFAULT,
79 .ulcon = SMDK6450_ULCON_DEFAULT,
80 .ufcon = SMDK6450_UFCON_DEFAULT,
81 },
82 [3] = {
83 .hwport = 3,
84 .flags = 0,
85 .ucon = SMDK6450_UCON_DEFAULT,
86 .ulcon = SMDK6450_ULCON_DEFAULT,
87 .ufcon = SMDK6450_UFCON_DEFAULT,
88 },
89#if CONFIG_SERIAL_SAMSUNG_UARTS > 4
90 [4] = {
91 .hwport = 4,
92 .flags = 0,
93 .ucon = SMDK6450_UCON_DEFAULT,
94 .ulcon = SMDK6450_ULCON_DEFAULT,
95 .ufcon = SMDK6450_UFCON_DEFAULT,
96 },
97#endif
98#if CONFIG_SERIAL_SAMSUNG_UARTS > 5
99 [5] = {
100 .hwport = 5,
101 .flags = 0,
102 .ucon = SMDK6450_UCON_DEFAULT,
103 .ulcon = SMDK6450_ULCON_DEFAULT,
104 .ufcon = SMDK6450_UFCON_DEFAULT,
105 },
106#endif
107};
108
109static struct platform_device *smdk6450_devices[] __initdata = {
110 &s3c_device_adc,
111 &s3c_device_rtc,
112 &s3c_device_i2c0,
113 &s3c_device_i2c1,
114 &s3c_device_ts,
115 &s3c_device_wdt,
116 &s5p6450_device_iis0,
117 /* s5p6450_device_spi0 will be added */
118};
119
120static struct s3c2410_platform_i2c s5p6450_i2c0_data __initdata = {
121 .flags = 0,
122 .slave_addr = 0x10,
123 .frequency = 100*1000,
124 .sda_delay = 100,
125 .cfg_gpio = s5p6450_i2c0_cfg_gpio,
126};
127
128static struct s3c2410_platform_i2c s5p6450_i2c1_data __initdata = {
129 .flags = 0,
130 .bus_num = 1,
131 .slave_addr = 0x10,
132 .frequency = 100*1000,
133 .sda_delay = 100,
134 .cfg_gpio = s5p6450_i2c1_cfg_gpio,
135};
136
137static struct i2c_board_info smdk6450_i2c_devs0[] __initdata = {
138 { I2C_BOARD_INFO("24c08", 0x50), }, /* Samsung KS24C080C EEPROM */
139};
140
141static struct i2c_board_info smdk6450_i2c_devs1[] __initdata = {
142 { I2C_BOARD_INFO("24c128", 0x57), },/* Samsung S524AD0XD1 EEPROM */
143};
144
145static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
146 .delay = 10000,
147 .presc = 49,
148 .oversampling_shift = 2,
149};
150
151static void __init smdk6450_map_io(void)
152{
153 s5p_init_io(NULL, 0, S5P64X0_SYS_ID);
154 s3c24xx_init_clocks(19200000);
155 s3c24xx_init_uarts(smdk6450_uartcfgs, ARRAY_SIZE(smdk6450_uartcfgs));
156}
157
158static void __init smdk6450_machine_init(void)
159{
160 s3c24xx_ts_set_platdata(&s3c_ts_platform);
161
162 s3c_i2c0_set_platdata(&s5p6450_i2c0_data);
163 s3c_i2c1_set_platdata(&s5p6450_i2c1_data);
164 i2c_register_board_info(0, smdk6450_i2c_devs0,
165 ARRAY_SIZE(smdk6450_i2c_devs0));
166 i2c_register_board_info(1, smdk6450_i2c_devs1,
167 ARRAY_SIZE(smdk6450_i2c_devs1));
168
169 platform_add_devices(smdk6450_devices, ARRAY_SIZE(smdk6450_devices));
170}
171
172MACHINE_START(SMDK6450, "SMDK6450")
173 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
174 .boot_params = S5P64X0_PA_SDRAM + 0x100,
175
176 .init_irq = s5p6450_init_irq,
177 .map_io = smdk6450_map_io,
178 .init_machine = smdk6450_machine_init,
179 .timer = &s3c24xx_timer,
180MACHINE_END
diff --git a/arch/arm/mach-s5p6440/setup-i2c0.c b/arch/arm/mach-s5p64x0/setup-i2c0.c
index 2c99d14f7ac7..dc4cc65a5019 100644
--- a/arch/arm/mach-s5p6440/setup-i2c0.c
+++ b/arch/arm/mach-s5p64x0/setup-i2c0.c
@@ -1,11 +1,11 @@
1/* linux/arch/arm/mach-s5p6440/setup-i2c0.c 1/* linux/arch/arm/mach-s5p64x0/setup-i2c0.c
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * I2C0 GPIO configuration. 6 * I2C0 GPIO configuration.
7 * 7 *
8 * Based on plat-s3c64xx/setup-i2c0.c 8 * Based on plat-s3c64x0/setup-i2c0.c
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of the GNU General Public License version 2 as
@@ -14,17 +14,29 @@
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/gpio.h>
17 18
18struct platform_device; /* don't need the contents */ 19struct platform_device; /* don't need the contents */
19 20
20#include <linux/gpio.h>
21#include <plat/gpio-cfg.h> 21#include <plat/gpio-cfg.h>
22#include <plat/iic.h> 22#include <plat/iic.h>
23 23
24void s3c_i2c0_cfg_gpio(struct platform_device *dev) 24#include <mach/i2c.h>
25
26void s5p6440_i2c0_cfg_gpio(struct platform_device *dev)
25{ 27{
26 s3c_gpio_cfgpin(S5P6440_GPB(5), S3C_GPIO_SFN(2)); 28 s3c_gpio_cfgpin(S5P6440_GPB(5), S3C_GPIO_SFN(2));
27 s3c_gpio_setpull(S5P6440_GPB(5), S3C_GPIO_PULL_UP); 29 s3c_gpio_setpull(S5P6440_GPB(5), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5P6440_GPB(6), S3C_GPIO_SFN(2)); 30 s3c_gpio_cfgpin(S5P6440_GPB(6), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5P6440_GPB(6), S3C_GPIO_PULL_UP); 31 s3c_gpio_setpull(S5P6440_GPB(6), S3C_GPIO_PULL_UP);
30} 32}
33
34void s5p6450_i2c0_cfg_gpio(struct platform_device *dev)
35{
36 s3c_gpio_cfgpin(S5P6450_GPB(5), S3C_GPIO_SFN(2));
37 s3c_gpio_setpull(S5P6450_GPB(5), S3C_GPIO_PULL_UP);
38 s3c_gpio_cfgpin(S5P6450_GPB(6), S3C_GPIO_SFN(2));
39 s3c_gpio_setpull(S5P6450_GPB(6), S3C_GPIO_PULL_UP);
40}
41
42void s3c_i2c0_cfg_gpio(struct platform_device *dev) { }
diff --git a/arch/arm/mach-s5p6440/setup-i2c1.c b/arch/arm/mach-s5p64x0/setup-i2c1.c
index 9a1537f786e0..2edd7912f8e4 100644
--- a/arch/arm/mach-s5p6440/setup-i2c1.c
+++ b/arch/arm/mach-s5p64x0/setup-i2c1.c
@@ -1,7 +1,7 @@
1/* linux/arch/arm/mach-s5p6440/setup-i2c1.c 1/* linux/arch/arm/mach-s5p64xx/setup-i2c1.c
2 * 2 *
3 * Copyright (c) 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * I2C1 GPIO configuration. 6 * I2C1 GPIO configuration.
7 * 7 *
@@ -21,10 +21,22 @@ struct platform_device; /* don't need the contents */
21#include <plat/gpio-cfg.h> 21#include <plat/gpio-cfg.h>
22#include <plat/iic.h> 22#include <plat/iic.h>
23 23
24void s3c_i2c1_cfg_gpio(struct platform_device *dev) 24#include <mach/i2c.h>
25
26void s5p6440_i2c1_cfg_gpio(struct platform_device *dev)
25{ 27{
26 s3c_gpio_cfgpin(S5P6440_GPR(9), S3C_GPIO_SFN(6)); 28 s3c_gpio_cfgpin(S5P6440_GPR(9), S3C_GPIO_SFN(6));
27 s3c_gpio_setpull(S5P6440_GPR(9), S3C_GPIO_PULL_UP); 29 s3c_gpio_setpull(S5P6440_GPR(9), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5P6440_GPR(10), S3C_GPIO_SFN(6)); 30 s3c_gpio_cfgpin(S5P6440_GPR(10), S3C_GPIO_SFN(6));
29 s3c_gpio_setpull(S5P6440_GPR(10), S3C_GPIO_PULL_UP); 31 s3c_gpio_setpull(S5P6440_GPR(10), S3C_GPIO_PULL_UP);
30} 32}
33
34void s5p6450_i2c1_cfg_gpio(struct platform_device *dev)
35{
36 s3c_gpio_cfgpin(S5P6450_GPR(9), S3C_GPIO_SFN(6));
37 s3c_gpio_setpull(S5P6450_GPR(9), S3C_GPIO_PULL_UP);
38 s3c_gpio_cfgpin(S5P6450_GPR(10), S3C_GPIO_SFN(6));
39 s3c_gpio_setpull(S5P6450_GPR(10), S3C_GPIO_PULL_UP);
40}
41
42void s3c_i2c1_cfg_gpio(struct platform_device *dev) { }
diff --git a/arch/arm/mach-s5pc100/cpu.c b/arch/arm/mach-s5pc100/cpu.c
index 251c92ac5b22..fd2708e7d8a9 100644
--- a/arch/arm/mach-s5pc100/cpu.c
+++ b/arch/arm/mach-s5pc100/cpu.c
@@ -1,5 +1,8 @@
1/* linux/arch/arm/mach-s5pc100/cpu.c 1/* linux/arch/arm/mach-s5pc100/cpu.c
2 * 2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
3 * Copyright 2009 Samsung Electronics Co. 6 * Copyright 2009 Samsung Electronics Co.
4 * Byungho Min <bhmin@samsung.com> 7 * Byungho Min <bhmin@samsung.com>
5 * 8 *
@@ -21,6 +24,7 @@
21#include <linux/sysdev.h> 24#include <linux/sysdev.h>
22#include <linux/serial_core.h> 25#include <linux/serial_core.h>
23#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/sched.h>
24 28
25#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
26#include <asm/mach/map.h> 30#include <asm/mach/map.h>
@@ -56,11 +60,31 @@ static struct map_desc s5pc100_iodesc[] __initdata = {
56 .length = SZ_16K, 60 .length = SZ_16K,
57 .type = MT_DEVICE, 61 .type = MT_DEVICE,
58 }, { 62 }, {
63 .virtual = (unsigned long)S5P_VA_GPIO,
64 .pfn = __phys_to_pfn(S5PC100_PA_GPIO),
65 .length = SZ_4K,
66 .type = MT_DEVICE,
67 }, {
68 .virtual = (unsigned long)VA_VIC0,
69 .pfn = __phys_to_pfn(S5PC100_PA_VIC0),
70 .length = SZ_16K,
71 .type = MT_DEVICE,
72 }, {
73 .virtual = (unsigned long)VA_VIC1,
74 .pfn = __phys_to_pfn(S5PC100_PA_VIC1),
75 .length = SZ_16K,
76 .type = MT_DEVICE,
77 }, {
59 .virtual = (unsigned long)VA_VIC2, 78 .virtual = (unsigned long)VA_VIC2,
60 .pfn = __phys_to_pfn(S5P_PA_VIC2), 79 .pfn = __phys_to_pfn(S5PC100_PA_VIC2),
61 .length = SZ_16K, 80 .length = SZ_16K,
62 .type = MT_DEVICE, 81 .type = MT_DEVICE,
63 }, { 82 }, {
83 .virtual = (unsigned long)S3C_VA_UART,
84 .pfn = __phys_to_pfn(S3C_PA_UART),
85 .length = SZ_512K,
86 .type = MT_DEVICE,
87 }, {
64 .virtual = (unsigned long)S5PC100_VA_OTHERS, 88 .virtual = (unsigned long)S5PC100_VA_OTHERS,
65 .pfn = __phys_to_pfn(S5PC100_PA_OTHERS), 89 .pfn = __phys_to_pfn(S5PC100_PA_OTHERS),
66 .length = SZ_4K, 90 .length = SZ_4K,
diff --git a/arch/arm/mach-s5pc100/include/mach/debug-macro.S b/arch/arm/mach-s5pc100/include/mach/debug-macro.S
index 70e02e91ee3c..b2ba95ddf8e0 100644
--- a/arch/arm/mach-s5pc100/include/mach/debug-macro.S
+++ b/arch/arm/mach-s5pc100/include/mach/debug-macro.S
@@ -22,13 +22,12 @@
22 * aligned and add in the offset when we load the value here. 22 * aligned and add in the offset when we load the value here.
23 */ 23 */
24 24
25 .macro addruart, rx, rtmp 25 .macro addruart, rp, rv
26 mrc p15, 0, \rx, c1, c0 26 ldr \rp, = S3C_PA_UART
27 tst \rx, #1 27 ldr \rv, = S3C_VA_UART
28 ldreq \rx, = S3C_PA_UART
29 ldrne \rx, = S3C_VA_UART
30#if CONFIG_DEBUG_S3C_UART != 0 28#if CONFIG_DEBUG_S3C_UART != 0
31 add \rx, \rx, #(0x400 * CONFIG_DEBUG_S3C_UART) 29 add \rp, \rp, #(0x400 * CONFIG_DEBUG_S3C_UART)
30 add \rv, \rv, #(0x400 * CONFIG_DEBUG_S3C_UART)
32#endif 31#endif
33 .endm 32 .endm
34 33
diff --git a/arch/arm/mach-s5pc100/include/mach/map.h b/arch/arm/mach-s5pc100/include/mach/map.h
index 01b9134feff0..8751ef4a6804 100644
--- a/arch/arm/mach-s5pc100/include/mach/map.h
+++ b/arch/arm/mach-s5pc100/include/mach/map.h
@@ -44,19 +44,16 @@
44#define S5PC100_PA_OTHERS (0xE0200000) 44#define S5PC100_PA_OTHERS (0xE0200000)
45#define S5PC100_VA_OTHERS (S3C_VA_SYS + 0x10000) 45#define S5PC100_VA_OTHERS (S3C_VA_SYS + 0x10000)
46 46
47#define S5P_PA_GPIO (0xE0300000) 47#define S5PC100_PA_GPIO (0xE0300000)
48#define S5PC1XX_VA_GPIO S3C_ADDR(0x00500000) 48#define S5PC1XX_VA_GPIO S3C_ADDR(0x00500000)
49 49
50/* Interrupt */ 50/* Interrupt */
51#define S5PC100_PA_VIC (0xE4000000) 51#define S5PC100_PA_VIC0 (0xE4000000)
52#define S5PC100_PA_VIC1 (0xE4100000)
53#define S5PC100_PA_VIC2 (0xE4200000)
52#define S5PC100_VA_VIC S3C_VA_IRQ 54#define S5PC100_VA_VIC S3C_VA_IRQ
53#define S5PC100_PA_VIC_OFFSET 0x100000
54#define S5PC100_VA_VIC_OFFSET 0x10000 55#define S5PC100_VA_VIC_OFFSET 0x10000
55#define S5PC1XX_PA_VIC(x) (S5PC100_PA_VIC + ((x) * S5PC100_PA_VIC_OFFSET))
56#define S5PC1XX_VA_VIC(x) (S5PC100_VA_VIC + ((x) * S5PC100_VA_VIC_OFFSET)) 56#define S5PC1XX_VA_VIC(x) (S5PC100_VA_VIC + ((x) * S5PC100_VA_VIC_OFFSET))
57#define S5P_PA_VIC0 S5PC1XX_PA_VIC(0)
58#define S5P_PA_VIC1 S5PC1XX_PA_VIC(1)
59#define S5P_PA_VIC2 S5PC1XX_PA_VIC(2)
60 57
61 58
62#define S5PC100_PA_ONENAND (0xE7100000) 59#define S5PC100_PA_ONENAND (0xE7100000)
diff --git a/arch/arm/mach-s5pc100/mach-smdkc100.c b/arch/arm/mach-s5pc100/mach-smdkc100.c
index 020c3f98f81f..880fb075092c 100644
--- a/arch/arm/mach-s5pc100/mach-smdkc100.c
+++ b/arch/arm/mach-s5pc100/mach-smdkc100.c
@@ -235,8 +235,6 @@ static void __init smdkc100_machine_init(void)
235 235
236MACHINE_START(SMDKC100, "SMDKC100") 236MACHINE_START(SMDKC100, "SMDKC100")
237 /* Maintainer: Byungho Min <bhmin@samsung.com> */ 237 /* Maintainer: Byungho Min <bhmin@samsung.com> */
238 .phys_io = S3C_PA_UART & 0xfff00000,
239 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
240 .boot_params = S5P_PA_SDRAM + 0x100, 238 .boot_params = S5P_PA_SDRAM + 0x100,
241 .init_irq = s5pc100_init_irq, 239 .init_irq = s5pc100_init_irq,
242 .map_io = smdkc100_map_io, 240 .map_io = smdkc100_map_io,
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index d3a38955c741..5315fec3db86 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -53,11 +53,6 @@ config S5PV210_SETUP_SDHCI_GPIO
53 help 53 help
54 Common setup code for SDHCI gpio. 54 Common setup code for SDHCI gpio.
55 55
56config S5PC110_DEV_ONENAND
57 bool
58 help
59 Compile in platform device definition for OneNAND1 controller
60
61menu "S5PC110 Machines" 56menu "S5PC110 Machines"
62 57
63config MACH_AQUILA 58config MACH_AQUILA
@@ -71,7 +66,7 @@ config MACH_AQUILA
71 select S3C_DEV_HSMMC 66 select S3C_DEV_HSMMC
72 select S3C_DEV_HSMMC1 67 select S3C_DEV_HSMMC1
73 select S3C_DEV_HSMMC2 68 select S3C_DEV_HSMMC2
74 select S5PC110_DEV_ONENAND 69 select S5P_DEV_ONENAND
75 select S5PV210_SETUP_FB_24BPP 70 select S5PV210_SETUP_FB_24BPP
76 select S5PV210_SETUP_SDHCI 71 select S5PV210_SETUP_SDHCI
77 help 72 help
@@ -88,7 +83,7 @@ config MACH_GONI
88 select S3C_DEV_HSMMC 83 select S3C_DEV_HSMMC
89 select S3C_DEV_HSMMC1 84 select S3C_DEV_HSMMC1
90 select S3C_DEV_HSMMC2 85 select S3C_DEV_HSMMC2
91 select S5PC110_DEV_ONENAND 86 select S5P_DEV_ONENAND
92 select S5PV210_SETUP_FB_24BPP 87 select S5PV210_SETUP_FB_24BPP
93 select S5PV210_SETUP_SDHCI 88 select S5PV210_SETUP_SDHCI
94 help 89 help
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index 05048c5aa4c6..704548912408 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_MACH_GONI) += mach-goni.o
26 26
27obj-y += dev-audio.o 27obj-y += dev-audio.o
28obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o 28obj-$(CONFIG_S3C64XX_DEV_SPI) += dev-spi.o
29obj-$(CONFIG_S5PC110_DEV_ONENAND) += dev-onenand.o
30 29
31obj-$(CONFIG_S5PV210_SETUP_FB_24BPP) += setup-fb-24bpp.o 30obj-$(CONFIG_S5PV210_SETUP_FB_24BPP) += setup-fb-24bpp.o
32obj-$(CONFIG_S5PV210_SETUP_I2C1) += setup-i2c1.o 31obj-$(CONFIG_S5PV210_SETUP_I2C1) += setup-i2c1.o
diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c
index cfecd70657cb..d562670e1b0b 100644
--- a/arch/arm/mach-s5pv210/clock.c
+++ b/arch/arm/mach-s5pv210/clock.c
@@ -173,11 +173,6 @@ static int s5pv210_clk_ip3_ctrl(struct clk *clk, int enable)
173 return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable); 173 return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable);
174} 174}
175 175
176static int s5pv210_clk_ip4_ctrl(struct clk *clk, int enable)
177{
178 return s5p_gatectrl(S5P_CLKGATE_IP4, clk, enable);
179}
180
181static int s5pv210_clk_mask0_ctrl(struct clk *clk, int enable) 176static int s5pv210_clk_mask0_ctrl(struct clk *clk, int enable)
182{ 177{
183 return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable); 178 return s5p_gatectrl(S5P_CLK_SRC_MASK0, clk, enable);
diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 77f456c91ad3..2f16bfc0a116 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -1,7 +1,7 @@
1/* linux/arch/arm/mach-s5pv210/cpu.c 1/* linux/arch/arm/mach-s5pv210/cpu.c
2 * 2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -19,6 +19,7 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/sysdev.h> 20#include <linux/sysdev.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/sched.h>
22 23
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
@@ -50,6 +51,21 @@ static struct map_desc s5pv210_iodesc[] __initdata = {
50 .length = SZ_4K, 51 .length = SZ_4K,
51 .type = MT_DEVICE, 52 .type = MT_DEVICE,
52 }, { 53 }, {
54 .virtual = (unsigned long)S5P_VA_GPIO,
55 .pfn = __phys_to_pfn(S5PV210_PA_GPIO),
56 .length = SZ_4K,
57 .type = MT_DEVICE,
58 }, {
59 .virtual = (unsigned long)VA_VIC0,
60 .pfn = __phys_to_pfn(S5PV210_PA_VIC0),
61 .length = SZ_16K,
62 .type = MT_DEVICE,
63 }, {
64 .virtual = (unsigned long)VA_VIC1,
65 .pfn = __phys_to_pfn(S5PV210_PA_VIC1),
66 .length = SZ_16K,
67 .type = MT_DEVICE,
68 }, {
53 .virtual = (unsigned long)VA_VIC2, 69 .virtual = (unsigned long)VA_VIC2,
54 .pfn = __phys_to_pfn(S5PV210_PA_VIC2), 70 .pfn = __phys_to_pfn(S5PV210_PA_VIC2),
55 .length = SZ_16K, 71 .length = SZ_16K,
@@ -60,6 +76,11 @@ static struct map_desc s5pv210_iodesc[] __initdata = {
60 .length = SZ_16K, 76 .length = SZ_16K,
61 .type = MT_DEVICE, 77 .type = MT_DEVICE,
62 }, { 78 }, {
79 .virtual = (unsigned long)S3C_VA_UART,
80 .pfn = __phys_to_pfn(S3C_PA_UART),
81 .length = SZ_512K,
82 .type = MT_DEVICE,
83 }, {
63 .virtual = (unsigned long)S5P_VA_SROMC, 84 .virtual = (unsigned long)S5P_VA_SROMC,
64 .pfn = __phys_to_pfn(S5PV210_PA_SROMC), 85 .pfn = __phys_to_pfn(S5PV210_PA_SROMC),
65 .length = SZ_4K, 86 .length = SZ_4K,
diff --git a/arch/arm/mach-s5pv210/include/mach/debug-macro.S b/arch/arm/mach-s5pv210/include/mach/debug-macro.S
index 7872f5c3dfc2..169fe654a59e 100644
--- a/arch/arm/mach-s5pv210/include/mach/debug-macro.S
+++ b/arch/arm/mach-s5pv210/include/mach/debug-macro.S
@@ -21,13 +21,12 @@
21 * aligned and add in the offset when we load the value here. 21 * aligned and add in the offset when we load the value here.
22 */ 22 */
23 23
24 .macro addruart, rx, tmp 24 .macro addruart, rp, rv
25 mrc p15, 0, \rx, c1, c0 25 ldr \rp, = S3C_PA_UART
26 tst \rx, #1 26 ldr \rv, = S3C_VA_UART
27 ldreq \rx, = S3C_PA_UART
28 ldrne \rx, = S3C_VA_UART
29#if CONFIG_DEBUG_S3C_UART != 0 27#if CONFIG_DEBUG_S3C_UART != 0
30 add \rx, \rx, #(0x400 * CONFIG_DEBUG_S3C_UART) 28 add \rp, \rp, #(0x400 * CONFIG_DEBUG_S3C_UART)
29 add \rv, \rv, #(0x400 * CONFIG_DEBUG_S3C_UART)
31#endif 30#endif
32 .endm 31 .endm
33 32
diff --git a/arch/arm/mach-s5pv210/include/mach/map.h b/arch/arm/mach-s5pv210/include/mach/map.h
index dd4fb6bf14b5..bd9afd52466a 100644
--- a/arch/arm/mach-s5pv210/include/mach/map.h
+++ b/arch/arm/mach-s5pv210/include/mach/map.h
@@ -17,7 +17,10 @@
17#include <plat/map-s5p.h> 17#include <plat/map-s5p.h>
18 18
19#define S5PC110_PA_ONENAND (0xB0000000) 19#define S5PC110_PA_ONENAND (0xB0000000)
20#define S5P_PA_ONENAND S5PC110_PA_ONENAND
21
20#define S5PC110_PA_ONENAND_DMA (0xB0600000) 22#define S5PC110_PA_ONENAND_DMA (0xB0600000)
23#define S5P_PA_ONENAND_DMA S5PC110_PA_ONENAND_DMA
21 24
22#define S5PV210_PA_CHIPID (0xE0000000) 25#define S5PV210_PA_CHIPID (0xE0000000)
23#define S5P_PA_CHIPID S5PV210_PA_CHIPID 26#define S5P_PA_CHIPID S5PV210_PA_CHIPID
@@ -26,7 +29,6 @@
26#define S5P_PA_SYSCON S5PV210_PA_SYSCON 29#define S5P_PA_SYSCON S5PV210_PA_SYSCON
27 30
28#define S5PV210_PA_GPIO (0xE0200000) 31#define S5PV210_PA_GPIO (0xE0200000)
29#define S5P_PA_GPIO S5PV210_PA_GPIO
30 32
31/* SPI */ 33/* SPI */
32#define S5PV210_PA_SPI0 0xE1300000 34#define S5PV210_PA_SPI0 0xE1300000
@@ -72,16 +74,9 @@
72#define S5PV210_PA_HSMMC(x) (0xEB000000 + ((x) * 0x100000)) 74#define S5PV210_PA_HSMMC(x) (0xEB000000 + ((x) * 0x100000))
73 75
74#define S5PV210_PA_VIC0 (0xF2000000) 76#define S5PV210_PA_VIC0 (0xF2000000)
75#define S5P_PA_VIC0 S5PV210_PA_VIC0
76
77#define S5PV210_PA_VIC1 (0xF2100000) 77#define S5PV210_PA_VIC1 (0xF2100000)
78#define S5P_PA_VIC1 S5PV210_PA_VIC1
79
80#define S5PV210_PA_VIC2 (0xF2200000) 78#define S5PV210_PA_VIC2 (0xF2200000)
81#define S5P_PA_VIC2 S5PV210_PA_VIC2
82
83#define S5PV210_PA_VIC3 (0xF2300000) 79#define S5PV210_PA_VIC3 (0xF2300000)
84#define S5P_PA_VIC3 S5PV210_PA_VIC3
85 80
86#define S5PV210_PA_SDRAM (0x20000000) 81#define S5PV210_PA_SDRAM (0x20000000)
87#define S5P_PA_SDRAM S5PV210_PA_SDRAM 82#define S5P_PA_SDRAM S5PV210_PA_SDRAM
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index 0dda8012d6b2..00883087363c 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -477,7 +477,7 @@ static struct platform_device *aquila_devices[] __initdata = {
477 &aquila_i2c_gpio_pmic, 477 &aquila_i2c_gpio_pmic,
478 &aquila_device_gpiokeys, 478 &aquila_device_gpiokeys,
479 &s3c_device_fb, 479 &s3c_device_fb,
480 &s5pc110_device_onenand, 480 &s5p_device_onenand,
481 &s3c_device_hsmmc0, 481 &s3c_device_hsmmc0,
482 &s3c_device_hsmmc1, 482 &s3c_device_hsmmc1,
483 &s3c_device_hsmmc2, 483 &s3c_device_hsmmc2,
@@ -516,8 +516,6 @@ MACHINE_START(AQUILA, "Aquila")
516 /* Maintainers: 516 /* Maintainers:
517 Marek Szyprowski <m.szyprowski@samsung.com> 517 Marek Szyprowski <m.szyprowski@samsung.com>
518 Kyungmin Park <kyungmin.park@samsung.com> */ 518 Kyungmin Park <kyungmin.park@samsung.com> */
519 .phys_io = S3C_PA_UART & 0xfff00000,
520 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
521 .boot_params = S5P_PA_SDRAM + 0x100, 519 .boot_params = S5P_PA_SDRAM + 0x100,
522 .init_irq = s5pv210_init_irq, 520 .init_irq = s5pv210_init_irq,
523 .map_io = aquila_map_io, 521 .map_io = aquila_map_io,
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index 53754d7d364e..d9ecf57fc2a5 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -456,7 +456,7 @@ static void goni_setup_sdhci(void)
456 456
457static struct platform_device *goni_devices[] __initdata = { 457static struct platform_device *goni_devices[] __initdata = {
458 &s3c_device_fb, 458 &s3c_device_fb,
459 &s5pc110_device_onenand, 459 &s5p_device_onenand,
460 &goni_i2c_gpio_pmic, 460 &goni_i2c_gpio_pmic,
461 &goni_device_gpiokeys, 461 &goni_device_gpiokeys,
462 &s5p_device_fimc0, 462 &s5p_device_fimc0,
@@ -491,8 +491,6 @@ static void __init goni_machine_init(void)
491 491
492MACHINE_START(GONI, "GONI") 492MACHINE_START(GONI, "GONI")
493 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */ 493 /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */
494 .phys_io = S3C_PA_UART & 0xfff00000,
495 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
496 .boot_params = S5P_PA_SDRAM + 0x100, 494 .boot_params = S5P_PA_SDRAM + 0x100,
497 .init_irq = s5pv210_init_irq, 495 .init_irq = s5pv210_init_irq,
498 .map_io = goni_map_io, 496 .map_io = goni_map_io,
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index 8211bb87c54b..cea9bca79d88 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -127,8 +127,6 @@ static void __init smdkc110_machine_init(void)
127 127
128MACHINE_START(SMDKC110, "SMDKC110") 128MACHINE_START(SMDKC110, "SMDKC110")
129 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 129 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
130 .phys_io = S3C_PA_UART & 0xfff00000,
131 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
132 .boot_params = S5P_PA_SDRAM + 0x100, 130 .boot_params = S5P_PA_SDRAM + 0x100,
133 .init_irq = s5pv210_init_irq, 131 .init_irq = s5pv210_init_irq,
134 .map_io = smdkc110_map_io, 132 .map_io = smdkc110_map_io,
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index fbbc0a3c3738..83189ae9da9a 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -165,8 +165,6 @@ static void __init smdkv210_machine_init(void)
165 165
166MACHINE_START(SMDKV210, "SMDKV210") 166MACHINE_START(SMDKV210, "SMDKV210")
167 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 167 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
168 .phys_io = S3C_PA_UART & 0xfff00000,
169 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
170 .boot_params = S5P_PA_SDRAM + 0x100, 168 .boot_params = S5P_PA_SDRAM + 0x100,
171 .init_irq = s5pv210_init_irq, 169 .init_irq = s5pv210_init_irq,
172 .map_io = smdkv210_map_io, 170 .map_io = smdkv210_map_io,
diff --git a/arch/arm/mach-s5pv310/cpu.c b/arch/arm/mach-s5pv310/cpu.c
index e5b261a99ab2..4add39853ff9 100644
--- a/arch/arm/mach-s5pv310/cpu.c
+++ b/arch/arm/mach-s5pv310/cpu.c
@@ -31,9 +31,14 @@ extern void combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq);
31/* Initial IO mappings */ 31/* Initial IO mappings */
32static struct map_desc s5pv310_iodesc[] __initdata = { 32static struct map_desc s5pv310_iodesc[] __initdata = {
33 { 33 {
34 .virtual = (unsigned long)S5P_VA_COREPERI_BASE, 34 .virtual = (unsigned long)S5P_VA_SYSRAM,
35 .pfn = __phys_to_pfn(S5PV310_PA_COREPERI), 35 .pfn = __phys_to_pfn(S5PV310_PA_SYSRAM),
36 .length = SZ_8K, 36 .length = SZ_4K,
37 .type = MT_DEVICE,
38 }, {
39 .virtual = (unsigned long)S5P_VA_CMU,
40 .pfn = __phys_to_pfn(S5PV310_PA_CMU),
41 .length = SZ_128K,
37 .type = MT_DEVICE, 42 .type = MT_DEVICE,
38 }, { 43 }, {
39 .virtual = (unsigned long)S5P_VA_COMBINER_BASE, 44 .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
@@ -41,19 +46,24 @@ static struct map_desc s5pv310_iodesc[] __initdata = {
41 .length = SZ_4K, 46 .length = SZ_4K,
42 .type = MT_DEVICE, 47 .type = MT_DEVICE,
43 }, { 48 }, {
49 .virtual = (unsigned long)S5P_VA_COREPERI_BASE,
50 .pfn = __phys_to_pfn(S5PV310_PA_COREPERI),
51 .length = SZ_8K,
52 .type = MT_DEVICE,
53 }, {
44 .virtual = (unsigned long)S5P_VA_L2CC, 54 .virtual = (unsigned long)S5P_VA_L2CC,
45 .pfn = __phys_to_pfn(S5PV310_PA_L2CC), 55 .pfn = __phys_to_pfn(S5PV310_PA_L2CC),
46 .length = SZ_4K, 56 .length = SZ_4K,
47 .type = MT_DEVICE, 57 .type = MT_DEVICE,
48 }, { 58 }, {
49 .virtual = (unsigned long)S5P_VA_SYSRAM, 59 .virtual = (unsigned long)S5P_VA_GPIO,
50 .pfn = __phys_to_pfn(S5PV310_PA_SYSRAM), 60 .pfn = __phys_to_pfn(S5PV310_PA_GPIO1),
51 .length = SZ_4K, 61 .length = SZ_4K,
52 .type = MT_DEVICE, 62 .type = MT_DEVICE,
53 }, { 63 }, {
54 .virtual = (unsigned long)S5P_VA_CMU, 64 .virtual = (unsigned long)S3C_VA_UART,
55 .pfn = __phys_to_pfn(S5PV310_PA_CMU), 65 .pfn = __phys_to_pfn(S3C_PA_UART),
56 .length = SZ_128K, 66 .length = SZ_512K,
57 .type = MT_DEVICE, 67 .type = MT_DEVICE,
58 }, 68 },
59}; 69};
diff --git a/arch/arm/mach-s5pv310/include/mach/debug-macro.S b/arch/arm/mach-s5pv310/include/mach/debug-macro.S
index 6fb3893486be..b0d920c474d3 100644
--- a/arch/arm/mach-s5pv310/include/mach/debug-macro.S
+++ b/arch/arm/mach-s5pv310/include/mach/debug-macro.S
@@ -20,13 +20,12 @@
20 * aligned and add in the offset when we load the value here. 20 * aligned and add in the offset when we load the value here.
21 */ 21 */
22 22
23 .macro addruart, rx, tmp 23 .macro addruart, rp, rv
24 mrc p15, 0, \rx, c1, c0 24 ldreq \rp, = S3C_PA_UART
25 tst \rx, #1 25 ldrne \rv, = S3C_VA_UART
26 ldreq \rx, = S3C_PA_UART
27 ldrne \rx, = S3C_VA_UART
28#if CONFIG_DEBUG_S3C_UART != 0 26#if CONFIG_DEBUG_S3C_UART != 0
29 add \rx, \rx, #(0x10000 * CONFIG_DEBUG_S3C_UART) 27 add \rp, \rp, #(0x10000 * CONFIG_DEBUG_S3C_UART)
28 add \rv, \rv, #(0x10000 * CONFIG_DEBUG_S3C_UART)
30#endif 29#endif
31 .endm 30 .endm
32 31
diff --git a/arch/arm/mach-s5pv310/include/mach/irqs.h b/arch/arm/mach-s5pv310/include/mach/irqs.h
index 4cdedda6e652..471fc3bb199a 100644
--- a/arch/arm/mach-s5pv310/include/mach/irqs.h
+++ b/arch/arm/mach-s5pv310/include/mach/irqs.h
@@ -68,6 +68,8 @@
68 68
69#define IRQ_IIC COMBINER_IRQ(27, 0) 69#define IRQ_IIC COMBINER_IRQ(27, 0)
70 70
71#define IRQ_ONENAND_AUDI COMBINER_IRQ(34, 0)
72
71/* Set the default NR_IRQS */ 73/* Set the default NR_IRQS */
72 74
73#define NR_IRQS COMBINER_IRQ(MAX_COMBINER_NR, 0) 75#define NR_IRQS COMBINER_IRQ(MAX_COMBINER_NR, 0)
diff --git a/arch/arm/mach-s5pv310/include/mach/map.h b/arch/arm/mach-s5pv310/include/mach/map.h
index 213e1101a3b3..aff6d23624bb 100644
--- a/arch/arm/mach-s5pv310/include/mach/map.h
+++ b/arch/arm/mach-s5pv310/include/mach/map.h
@@ -25,6 +25,12 @@
25 25
26#define S5PV310_PA_SYSRAM (0x02025000) 26#define S5PV310_PA_SYSRAM (0x02025000)
27 27
28#define S5PC210_PA_ONENAND (0x0C000000)
29#define S5P_PA_ONENAND S5PC210_PA_ONENAND
30
31#define S5PC210_PA_ONENAND_DMA (0x0C600000)
32#define S5P_PA_ONENAND_DMA S5PC210_PA_ONENAND_DMA
33
28#define S5PV310_PA_CHIPID (0x10000000) 34#define S5PV310_PA_CHIPID (0x10000000)
29#define S5P_PA_CHIPID S5PV310_PA_CHIPID 35#define S5P_PA_CHIPID S5PV310_PA_CHIPID
30 36
@@ -46,7 +52,6 @@
46#define S5PV310_PA_GPIO1 (0x11400000) 52#define S5PV310_PA_GPIO1 (0x11400000)
47#define S5PV310_PA_GPIO2 (0x11000000) 53#define S5PV310_PA_GPIO2 (0x11000000)
48#define S5PV310_PA_GPIO3 (0x03860000) 54#define S5PV310_PA_GPIO3 (0x03860000)
49#define S5P_PA_GPIO S5PV310_PA_GPIO1
50 55
51#define S5PV310_PA_HSMMC(x) (0x12510000 + ((x) * 0x10000)) 56#define S5PV310_PA_HSMMC(x) (0x12510000 + ((x) * 0x10000))
52 57
diff --git a/arch/arm/mach-s5pv310/include/mach/smp.h b/arch/arm/mach-s5pv310/include/mach/smp.h
index 990f3ba88a1f..b7ec252384f4 100644
--- a/arch/arm/mach-s5pv310/include/mach/smp.h
+++ b/arch/arm/mach-s5pv310/include/mach/smp.h
@@ -7,17 +7,10 @@
7#define ASM_ARCH_SMP_H __FILE__ 7#define ASM_ARCH_SMP_H __FILE__
8 8
9#include <asm/hardware/gic.h> 9#include <asm/hardware/gic.h>
10#include <asm/smp_mpidr.h>
10 11
11extern void __iomem *gic_cpu_base_addr; 12extern void __iomem *gic_cpu_base_addr;
12 13
13#define hard_smp_processor_id() \
14 ({ \
15 unsigned int cpunum; \
16 __asm__("mrc p15, 0, %0, c0, c0, 5" \
17 : "=r" (cpunum)); \
18 cpunum &= 0x03; \
19 })
20
21/* 14/*
22 * We use IRQ1 as the IPI 15 * We use IRQ1 as the IPI
23 */ 16 */
diff --git a/arch/arm/mach-s5pv310/mach-smdkv310.c b/arch/arm/mach-s5pv310/mach-smdkv310.c
index 0d6ab77709d2..46215a14b3bb 100644
--- a/arch/arm/mach-s5pv310/mach-smdkv310.c
+++ b/arch/arm/mach-s5pv310/mach-smdkv310.c
@@ -82,8 +82,6 @@ static void __init smdkv310_machine_init(void)
82MACHINE_START(SMDKV310, "SMDKV310") 82MACHINE_START(SMDKV310, "SMDKV310")
83 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ 83 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
84 /* Maintainer: Changhwan Youn <chaos.youn@samsung.com> */ 84 /* Maintainer: Changhwan Youn <chaos.youn@samsung.com> */
85 .phys_io = S3C_PA_UART & 0xfff00000,
86 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
87 .boot_params = S5P_PA_SDRAM + 0x100, 85 .boot_params = S5P_PA_SDRAM + 0x100,
88 .init_irq = s5pv310_init_irq, 86 .init_irq = s5pv310_init_irq,
89 .map_io = smdkv310_map_io, 87 .map_io = smdkv310_map_io,
diff --git a/arch/arm/mach-s5pv310/mach-universal_c210.c b/arch/arm/mach-s5pv310/mach-universal_c210.c
index 2388cb947936..d7c2ec770f88 100644
--- a/arch/arm/mach-s5pv310/mach-universal_c210.c
+++ b/arch/arm/mach-s5pv310/mach-universal_c210.c
@@ -76,8 +76,6 @@ static void __init universal_machine_init(void)
76 76
77MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210") 77MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
78 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ 78 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
79 .phys_io = S3C_PA_UART & 0xfff00000,
80 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
81 .boot_params = S5P_PA_SDRAM + 0x100, 79 .boot_params = S5P_PA_SDRAM + 0x100,
82 .init_irq = s5pv310_init_irq, 80 .init_irq = s5pv310_init_irq,
83 .map_io = universal_map_io, 81 .map_io = universal_map_io,
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig
index fd4c52b7ccb6..5da8c35aa0de 100644
--- a/arch/arm/mach-sa1100/Kconfig
+++ b/arch/arm/mach-sa1100/Kconfig
@@ -90,8 +90,8 @@ config SA1100_JORNADA720
90 # FIXME: select CPU_FREQ_SA11x0 90 # FIXME: select CPU_FREQ_SA11x0
91 help 91 help
92 Say Y here if you want to build a kernel for the HP Jornada 720 92 Say Y here if you want to build a kernel for the HP Jornada 720
93 handheld computer. See <http://www.hp.com/jornada/products/720> 93 handheld computer. See
94 for details. 94 <http://h10025.www1.hp.com/ewfrf/wc/product?product=61677&cc=us&lc=en&dlc=en&product=61677#>
95 95
96config SA1100_JORNADA720_SSP 96config SA1100_JORNADA720_SSP
97 bool "HP Jornada 720 Extended SSP driver" 97 bool "HP Jornada 720 Extended SSP driver"
@@ -145,7 +145,7 @@ config SA1100_SIMPAD
145 FLASH. The SL4 version got 64 MB RAM and 32 MB FLASH and a 145 FLASH. The SL4 version got 64 MB RAM and 32 MB FLASH and a
146 PCMCIA-Slot. The version for the Germany Telecom (DTAG) is the same 146 PCMCIA-Slot. The version for the Germany Telecom (DTAG) is the same
147 like CL4 in additional it has a PCMCIA-Slot. For more information 147 like CL4 in additional it has a PCMCIA-Slot. For more information
148 visit <http://www.my-siemens.com/> or <http://www.siemens.ch/>. 148 visit <http://www.usa.siemens.com/> or <http://www.siemens.ch/>.
149 149
150config SA1100_SSP 150config SA1100_SSP
151 tristate "Generic PIO SSP" 151 tristate "Generic PIO SSP"
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 169e5b87dbff..5778274a8260 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -447,8 +447,6 @@ static void __init assabet_map_io(void)
447 447
448 448
449MACHINE_START(ASSABET, "Intel-Assabet") 449MACHINE_START(ASSABET, "Intel-Assabet")
450 .phys_io = 0x80000000,
451 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
452 .boot_params = 0xc0000100, 450 .boot_params = 0xc0000100,
453 .fixup = fixup_assabet, 451 .fixup = fixup_assabet,
454 .map_io = assabet_map_io, 452 .map_io = assabet_map_io,
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index 259cb2c15fff..4f19ff868b00 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -302,8 +302,6 @@ static void __init badge4_map_io(void)
302} 302}
303 303
304MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4") 304MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
305 .phys_io = 0x80000000,
306 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
307 .boot_params = 0xc0000100, 305 .boot_params = 0xc0000100,
308 .map_io = badge4_map_io, 306 .map_io = badge4_map_io,
309 .init_irq = sa1100_init_irq, 307 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
index bc950ef418af..98d780608c7e 100644
--- a/arch/arm/mach-sa1100/cerf.c
+++ b/arch/arm/mach-sa1100/cerf.c
@@ -135,8 +135,6 @@ static void __init cerf_init(void)
135 135
136MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube") 136MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
137 /* Maintainer: support@intrinsyc.com */ 137 /* Maintainer: support@intrinsyc.com */
138 .phys_io = 0x80000000,
139 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
140 .map_io = cerf_map_io, 138 .map_io = cerf_map_io,
141 .init_irq = cerf_init_irq, 139 .init_irq = cerf_init_irq,
142 .timer = &sa1100_timer, 140 .timer = &sa1100_timer,
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 16e682d5dbb7..d43c5ef58eb6 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -379,8 +379,6 @@ static void __init collie_map_io(void)
379} 379}
380 380
381MACHINE_START(COLLIE, "Sharp-Collie") 381MACHINE_START(COLLIE, "Sharp-Collie")
382 .phys_io = 0x80000000,
383 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
384 .map_io = collie_map_io, 382 .map_io = collie_map_io,
385 .init_irq = sa1100_init_irq, 383 .init_irq = sa1100_init_irq,
386 .timer = &sa1100_timer, 384 .timer = &sa1100_timer,
diff --git a/arch/arm/mach-sa1100/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index ef817876a5d6..c0a13ef5436f 100644
--- a/arch/arm/mach-sa1100/cpu-sa1100.c
+++ b/arch/arm/mach-sa1100/cpu-sa1100.c
@@ -13,7 +13,7 @@
13 * This software has been developed while working on the LART 13 * This software has been developed while working on the LART
14 * computing board (http://www.lartmaker.nl/), which is 14 * computing board (http://www.lartmaker.nl/), which is
15 * sponsored by the Mobile Multi-media Communications 15 * sponsored by the Mobile Multi-media Communications
16 * (http://www.mmc.tudelft.nl/) and Ubiquitous Communications 16 * (http://www.mobimedia.org/) and Ubiquitous Communications
17 * (http://www.ubicom.tudelft.nl/) projects. 17 * (http://www.ubicom.tudelft.nl/) projects.
18 * 18 *
19 * The authors can be reached at: 19 * The authors can be reached at:
diff --git a/arch/arm/mach-sa1100/h3100.c b/arch/arm/mach-sa1100/h3100.c
index 0c7cea0dc013..03d7376cf8a0 100644
--- a/arch/arm/mach-sa1100/h3100.c
+++ b/arch/arm/mach-sa1100/h3100.c
@@ -84,8 +84,6 @@ static void __init h3100_mach_init(void)
84} 84}
85 85
86MACHINE_START(H3100, "Compaq iPAQ H3100") 86MACHINE_START(H3100, "Compaq iPAQ H3100")
87 .phys_io = 0x80000000,
88 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
89 .boot_params = 0xc0000100, 87 .boot_params = 0xc0000100,
90 .map_io = h3100_map_io, 88 .map_io = h3100_map_io,
91 .init_irq = sa1100_init_irq, 89 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index af3b71459f8d..965f64a836f8 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -125,8 +125,6 @@ static void __init h3600_mach_init(void)
125} 125}
126 126
127MACHINE_START(H3600, "Compaq iPAQ H3600") 127MACHINE_START(H3600, "Compaq iPAQ H3600")
128 .phys_io = 0x80000000,
129 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
130 .boot_params = 0xc0000100, 128 .boot_params = 0xc0000100,
131 .map_io = h3600_map_io, 129 .map_io = h3600_map_io,
132 .init_irq = sa1100_init_irq, 130 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
index 51568dfc8e97..db5e434a17db 100644
--- a/arch/arm/mach-sa1100/hackkit.c
+++ b/arch/arm/mach-sa1100/hackkit.c
@@ -195,8 +195,6 @@ static void __init hackkit_init(void)
195 */ 195 */
196 196
197MACHINE_START(HACKKIT, "HackKit Cpu Board") 197MACHINE_START(HACKKIT, "HackKit Cpu Board")
198 .phys_io = 0x80000000,
199 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
200 .boot_params = 0xc0000100, 198 .boot_params = 0xc0000100,
201 .map_io = hackkit_map_io, 199 .map_io = hackkit_map_io,
202 .init_irq = sa1100_init_irq, 200 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/include/mach/debug-macro.S b/arch/arm/mach-sa1100/include/mach/debug-macro.S
index 336adccea542..0cd0fc9635b6 100644
--- a/arch/arm/mach-sa1100/include/mach/debug-macro.S
+++ b/arch/arm/mach-sa1100/include/mach/debug-macro.S
@@ -12,33 +12,37 @@
12*/ 12*/
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14 14
15 .macro addruart, rx, tmp 15 .macro addruart, rp, rv
16 mrc p15, 0, \rx, c1, c0 16 mrc p15, 0, \rp, c1, c0
17 tst \rx, #1 @ MMU enabled? 17 tst \rp, #1 @ MMU enabled?
18 moveq \rx, #0x80000000 @ physical base address 18 moveq \rp, #0x80000000 @ physical base address
19 movne \rx, #0xf8000000 @ virtual address 19 movne \rp, #0xf8000000 @ virtual address
20 20
21 @ We probe for the active serial port here, coherently with 21 @ We probe for the active serial port here, coherently with
22 @ the comment in arch/arm/mach-sa1100/include/mach/uncompress.h. 22 @ the comment in arch/arm/mach-sa1100/include/mach/uncompress.h.
23 @ We assume r1 can be clobbered. 23 @ We assume r1 can be clobbered.
24 24
25 @ see if Ser3 is active 25 @ see if Ser3 is active
26 add \rx, \rx, #0x00050000 26 add \rp, \rp, #0x00050000
27 ldr r1, [\rx, #UTCR3] 27 ldr \rv, [\rp, #UTCR3]
28 tst r1, #UTCR3_TXE 28 tst \rv, #UTCR3_TXE
29 29
30 @ if Ser3 is inactive, then try Ser1 30 @ if Ser3 is inactive, then try Ser1
31 addeq \rx, \rx, #(0x00010000 - 0x00050000) 31 addeq \rp, \rp, #(0x00010000 - 0x00050000)
32 ldreq r1, [\rx, #UTCR3] 32 ldreq \rv, [\rp, #UTCR3]
33 tsteq r1, #UTCR3_TXE 33 tsteq \rv, #UTCR3_TXE
34 34
35 @ if Ser1 is inactive, then try Ser2 35 @ if Ser1 is inactive, then try Ser2
36 addeq \rx, \rx, #(0x00030000 - 0x00010000) 36 addeq \rp, \rp, #(0x00030000 - 0x00010000)
37 ldreq r1, [\rx, #UTCR3] 37 ldreq \rv, [\rp, #UTCR3]
38 tsteq r1, #UTCR3_TXE 38 tsteq \rv, #UTCR3_TXE
39
40 @ clear top bits, and generate both phys and virt addresses
41 lsl \rp, \rp, #8
42 lsr \rp, \rp, #8
43 orr \rv, \rp, #0xf8000000 @ virtual
44 orr \rp, \rp, #0x80000000 @ physical
39 45
40 @ if all ports are inactive, then there is nothing we can do
41 moveq pc, lr
42 .endm 46 .endm
43 47
44 .macro senduart,rd,rx 48 .macro senduart,rd,rx
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index d3ec620618f1..491ac9f20fb4 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -364,8 +364,6 @@ static void __init jornada720_mach_init(void)
364 364
365MACHINE_START(JORNADA720, "HP Jornada 720") 365MACHINE_START(JORNADA720, "HP Jornada 720")
366 /* Maintainer: Kristoffer Ericson <Kristoffer.Ericson@gmail.com> */ 366 /* Maintainer: Kristoffer Ericson <Kristoffer.Ericson@gmail.com> */
367 .phys_io = 0x80000000,
368 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
369 .boot_params = 0xc0000100, 367 .boot_params = 0xc0000100,
370 .map_io = jornada720_map_io, 368 .map_io = jornada720_map_io,
371 .init_irq = sa1100_init_irq, 369 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c
index 68069d6dc07a..7b9556b59057 100644
--- a/arch/arm/mach-sa1100/lart.c
+++ b/arch/arm/mach-sa1100/lart.c
@@ -61,8 +61,6 @@ static void __init lart_map_io(void)
61} 61}
62 62
63MACHINE_START(LART, "LART") 63MACHINE_START(LART, "LART")
64 .phys_io = 0x80000000,
65 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
66 .boot_params = 0xc0000100, 64 .boot_params = 0xc0000100,
67 .map_io = lart_map_io, 65 .map_io = lart_map_io,
68 .init_irq = sa1100_init_irq, 66 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
index 1ccd6018d3a3..42b80400c100 100644
--- a/arch/arm/mach-sa1100/pleb.c
+++ b/arch/arm/mach-sa1100/pleb.c
@@ -146,8 +146,6 @@ static void __init pleb_map_io(void)
146} 146}
147 147
148MACHINE_START(PLEB, "PLEB") 148MACHINE_START(PLEB, "PLEB")
149 .phys_io = 0x80000000,
150 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
151 .map_io = pleb_map_io, 149 .map_io = pleb_map_io,
152 .init_irq = sa1100_init_irq, 150 .init_irq = sa1100_init_irq,
153 .timer = &sa1100_timer, 151 .timer = &sa1100_timer,
diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c
index 85e82bb73d7e..7917b2405579 100644
--- a/arch/arm/mach-sa1100/shannon.c
+++ b/arch/arm/mach-sa1100/shannon.c
@@ -82,8 +82,6 @@ static void __init shannon_map_io(void)
82} 82}
83 83
84MACHINE_START(SHANNON, "Shannon (AKA: Tuxscreen)") 84MACHINE_START(SHANNON, "Shannon (AKA: Tuxscreen)")
85 .phys_io = 0x80000000,
86 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
87 .boot_params = 0xc0000100, 85 .boot_params = 0xc0000100,
88 .map_io = shannon_map_io, 86 .map_io = shannon_map_io,
89 .init_irq = sa1100_init_irq, 87 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index 49cfd64663ac..27692d0ffbe8 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -228,8 +228,6 @@ arch_initcall(simpad_init);
228 228
229MACHINE_START(SIMPAD, "Simpad") 229MACHINE_START(SIMPAD, "Simpad")
230 /* Maintainer: Holger Freyther */ 230 /* Maintainer: Holger Freyther */
231 .phys_io = 0x80000000,
232 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
233 .boot_params = 0xc0000100, 231 .boot_params = 0xc0000100,
234 .map_io = simpad_map_io, 232 .map_io = simpad_map_io,
235 .init_irq = sa1100_init_irq, 233 .init_irq = sa1100_init_irq,
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index 358d875ace14..5cf7f94c1f31 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -152,8 +152,6 @@ static struct sys_timer shark_timer = {
152 152
153MACHINE_START(SHARK, "Shark") 153MACHINE_START(SHARK, "Shark")
154 /* Maintainer: Alexander Schulz */ 154 /* Maintainer: Alexander Schulz */
155 .phys_io = 0x40000000,
156 .io_pg_offst = ((0xe0000000) >> 18) & 0xfffc,
157 .boot_params = 0x08003000, 155 .boot_params = 0x08003000,
158 .map_io = shark_map_io, 156 .map_io = shark_map_io,
159 .init_irq = shark_init_irq, 157 .init_irq = shark_init_irq,
diff --git a/arch/arm/mach-shark/include/mach/debug-macro.S b/arch/arm/mach-shark/include/mach/debug-macro.S
index 5ea24d4d1ba6..a473f55dc71f 100644
--- a/arch/arm/mach-shark/include/mach/debug-macro.S
+++ b/arch/arm/mach-shark/include/mach/debug-macro.S
@@ -11,9 +11,10 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mov \rx, #0xe0000000 15 mov \rp, #0xe0000000
16 orr \rx, \rx, #0x000003f8 16 orr \rp, \rp, #0x000003f8
17 mov \rv, \rp
17 .endm 18 .endm
18 19
19 .macro senduart,rd,rx 20 .macro senduart,rd,rx
diff --git a/arch/arm/mach-shark/include/mach/vmalloc.h b/arch/arm/mach-shark/include/mach/vmalloc.h
index f6c6837c5451..8e845b6a7cb5 100644
--- a/arch/arm/mach-shark/include/mach/vmalloc.h
+++ b/arch/arm/mach-shark/include/mach/vmalloc.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * arch/arm/mach-shark/include/mach/vmalloc.h 2 * arch/arm/mach-shark/include/mach/vmalloc.h
3 */ 3 */
4#define VMALLOC_END (PAGE_OFFSET + 0x10000000) 4#define VMALLOC_END 0xd0000000
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 95935c83c306..14923989ea05 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -1105,8 +1105,6 @@ static struct sys_timer ap4evb_timer = {
1105}; 1105};
1106 1106
1107MACHINE_START(AP4EVB, "ap4evb") 1107MACHINE_START(AP4EVB, "ap4evb")
1108 .phys_io = 0xe6000000,
1109 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
1110 .map_io = ap4evb_map_io, 1108 .map_io = ap4evb_map_io,
1111 .init_irq = sh7372_init_irq, 1109 .init_irq = sh7372_init_irq,
1112 .init_machine = ap4evb_init, 1110 .init_machine = ap4evb_init,
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index a5525901e91f..3b83d6320bec 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -365,8 +365,6 @@ static struct sys_timer g3evm_timer = {
365}; 365};
366 366
367MACHINE_START(G3EVM, "g3evm") 367MACHINE_START(G3EVM, "g3evm")
368 .phys_io = 0xe6000000,
369 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
370 .map_io = g3evm_map_io, 368 .map_io = g3evm_map_io,
371 .init_irq = sh7367_init_irq, 369 .init_irq = sh7367_init_irq,
372 .init_machine = g3evm_init, 370 .init_machine = g3evm_init,
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index 2c3ff6f7f34c..5b3b582ef3f2 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -392,8 +392,6 @@ static struct sys_timer g4evm_timer = {
392}; 392};
393 393
394MACHINE_START(G4EVM, "g4evm") 394MACHINE_START(G4EVM, "g4evm")
395 .phys_io = 0xe6000000,
396 .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc,
397 .map_io = g4evm_map_io, 395 .map_io = g4evm_map_io,
398 .init_irq = sh7377_init_irq, 396 .init_irq = sh7377_init_irq,
399 .init_machine = g4evm_init, 397 .init_machine = g4evm_init,
diff --git a/arch/arm/mach-stmp378x/stmp378x_devb.c b/arch/arm/mach-stmp378x/stmp378x_devb.c
index 90d8fe6f10fe..06158848afd9 100644
--- a/arch/arm/mach-stmp378x/stmp378x_devb.c
+++ b/arch/arm/mach-stmp378x/stmp378x_devb.c
@@ -324,8 +324,6 @@ static void __init stmp378x_devb_init(void)
324} 324}
325 325
326MACHINE_START(STMP378X, "STMP378X") 326MACHINE_START(STMP378X, "STMP378X")
327 .phys_io = 0x80000000,
328 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
329 .boot_params = 0x40000100, 327 .boot_params = 0x40000100,
330 .map_io = stmp378x_map_io, 328 .map_io = stmp378x_map_io,
331 .init_irq = stmp378x_init_irq, 329 .init_irq = stmp378x_init_irq,
diff --git a/arch/arm/mach-stmp37xx/stmp37xx_devb.c b/arch/arm/mach-stmp37xx/stmp37xx_devb.c
index 394f21ab59e6..311d8552d362 100644
--- a/arch/arm/mach-stmp37xx/stmp37xx_devb.c
+++ b/arch/arm/mach-stmp37xx/stmp37xx_devb.c
@@ -91,8 +91,6 @@ static void __init stmp37xx_devb_init(void)
91} 91}
92 92
93MACHINE_START(STMP37XX, "STMP37XX") 93MACHINE_START(STMP37XX, "STMP37XX")
94 .phys_io = 0x80000000,
95 .io_pg_offst = ((0xf0000000) >> 18) & 0xfffc,
96 .boot_params = 0x40000100, 94 .boot_params = 0x40000100,
97 .map_io = stmp37xx_map_io, 95 .map_io = stmp37xx_map_io,
98 .init_irq = stmp37xx_init_irq, 96 .init_irq = stmp37xx_init_irq,
diff --git a/arch/arm/mach-tcc8k/Kconfig b/arch/arm/mach-tcc8k/Kconfig
new file mode 100644
index 000000000000..ad86415d1577
--- /dev/null
+++ b/arch/arm/mach-tcc8k/Kconfig
@@ -0,0 +1,11 @@
1if ARCH_TCC8K
2
3comment "TCC8000 systems:"
4
5config MACH_TCC8000_SDK
6 bool "Telechips TCC8000-SDK development kit"
7 default y
8 help
9 Support for the Telechips TCC8000-SDK board.
10
11endif
diff --git a/arch/arm/mach-tcc8k/Makefile b/arch/arm/mach-tcc8k/Makefile
new file mode 100644
index 000000000000..9bacf31e49ba
--- /dev/null
+++ b/arch/arm/mach-tcc8k/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for TCC8K boards and common files.
3#
4
5# Common support
6obj-y += clock.o irq.o time.o io.o devices.o
7
8# Board specific support
9obj-$(CONFIG_MACH_TCC8000_SDK) += board-tcc8000-sdk.o
diff --git a/arch/arm/mach-tcc8k/Makefile.boot b/arch/arm/mach-tcc8k/Makefile.boot
new file mode 100644
index 000000000000..f135c9deae10
--- /dev/null
+++ b/arch/arm/mach-tcc8k/Makefile.boot
@@ -0,0 +1,3 @@
1 zreladdr-y := 0x20008000
2params_phys-y := 0x20000100
3initrd_phys-y := 0x20800000
diff --git a/arch/arm/mach-tcc8k/board-tcc8000-sdk.c b/arch/arm/mach-tcc8k/board-tcc8000-sdk.c
new file mode 100644
index 000000000000..7991415e666b
--- /dev/null
+++ b/arch/arm/mach-tcc8k/board-tcc8000-sdk.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/platform_device.h>
12
13#include <asm/mach-types.h>
14
15#include <asm/mach/arch.h>
16#include <asm/mach/map.h>
17#include <asm/mach/time.h>
18
19#include <mach/clock.h>
20
21#include "common.h"
22
23#define XI_FREQUENCY 12000000
24#define XTI_FREQUENCY 32768
25
26#ifdef CONFIG_MTD_NAND_TCC
27/* NAND */
28static struct tcc_nand_platform_data tcc8k_sdk_nand_data = {
29 .width = 1,
30 .hw_ecc = 0,
31};
32#endif
33
34static void __init tcc8k_init(void)
35{
36#ifdef CONFIG_MTD_NAND_TCC
37 tcc_nand_device.dev.platform_data = &tcc8k_sdk_nand_data;
38 platform_device_register(&tcc_nand_device);
39#endif
40}
41
42static void __init tcc8k_init_timer(void)
43{
44 tcc_clocks_init(XI_FREQUENCY, XTI_FREQUENCY);
45}
46
47static struct sys_timer tcc8k_timer = {
48 .init = tcc8k_init_timer,
49};
50
51static void __init tcc8k_map_io(void)
52{
53 tcc8k_map_common_io();
54}
55
56MACHINE_START(TCC8000_SDK, "Telechips TCC8000-SDK Demo Board")
57 .boot_params = PHYS_OFFSET + 0x00000100,
58 .map_io = tcc8k_map_io,
59 .init_irq = tcc8k_init_irq,
60 .init_machine = tcc8k_init,
61 .timer = &tcc8k_timer,
62MACHINE_END
diff --git a/arch/arm/mach-tcc8k/clock.c b/arch/arm/mach-tcc8k/clock.c
new file mode 100644
index 000000000000..ba32a15127ab
--- /dev/null
+++ b/arch/arm/mach-tcc8k/clock.c
@@ -0,0 +1,567 @@
1/*
2 * Lowlevel clock handling for Telechips TCC8xxx SoCs
3 *
4 * Copyright (C) 2010 by Hans J. Koch <hjk@linutronix.de>
5 *
6 * Licensed under the terms of the GPL v2
7 */
8
9#include <linux/clk.h>
10#include <linux/delay.h>
11#include <linux/err.h>
12#include <linux/io.h>
13#include <linux/module.h>
14#include <linux/spinlock.h>
15
16#include <asm/clkdev.h>
17
18#include <mach/clock.h>
19#include <mach/irqs.h>
20#include <mach/tcc8k-regs.h>
21
22#include "common.h"
23
24#define BCLKCTR0 (CKC_BASE + BCLKCTR0_OFFS)
25#define BCLKCTR1 (CKC_BASE + BCLKCTR1_OFFS)
26
27#define ACLKREF (CKC_BASE + ACLKREF_OFFS)
28#define ACLKUART0 (CKC_BASE + ACLKUART0_OFFS)
29#define ACLKUART1 (CKC_BASE + ACLKUART1_OFFS)
30#define ACLKUART2 (CKC_BASE + ACLKUART2_OFFS)
31#define ACLKUART3 (CKC_BASE + ACLKUART3_OFFS)
32#define ACLKUART4 (CKC_BASE + ACLKUART4_OFFS)
33#define ACLKI2C (CKC_BASE + ACLKI2C_OFFS)
34#define ACLKADC (CKC_BASE + ACLKADC_OFFS)
35#define ACLKUSBH (CKC_BASE + ACLKUSBH_OFFS)
36#define ACLKLCD (CKC_BASE + ACLKLCD_OFFS)
37#define ACLKSDH0 (CKC_BASE + ACLKSDH0_OFFS)
38#define ACLKSDH1 (CKC_BASE + ACLKSDH1_OFFS)
39#define ACLKSPI0 (CKC_BASE + ACLKSPI0_OFFS)
40#define ACLKSPI1 (CKC_BASE + ACLKSPI1_OFFS)
41#define ACLKSPDIF (CKC_BASE + ACLKSPDIF_OFFS)
42#define ACLKC3DEC (CKC_BASE + ACLKC3DEC_OFFS)
43#define ACLKCAN0 (CKC_BASE + ACLKCAN0_OFFS)
44#define ACLKCAN1 (CKC_BASE + ACLKCAN1_OFFS)
45#define ACLKGSB0 (CKC_BASE + ACLKGSB0_OFFS)
46#define ACLKGSB1 (CKC_BASE + ACLKGSB1_OFFS)
47#define ACLKGSB2 (CKC_BASE + ACLKGSB2_OFFS)
48#define ACLKGSB3 (CKC_BASE + ACLKGSB3_OFFS)
49#define ACLKUSBH (CKC_BASE + ACLKUSBH_OFFS)
50#define ACLKTCT (CKC_BASE + ACLKTCT_OFFS)
51#define ACLKTCX (CKC_BASE + ACLKTCX_OFFS)
52#define ACLKTCZ (CKC_BASE + ACLKTCZ_OFFS)
53
54/* Crystal frequencies */
55static unsigned long xi_rate, xti_rate;
56
57static void __iomem *pll_cfg_addr(int pll)
58{
59 switch (pll) {
60 case 0: return (CKC_BASE + PLL0CFG_OFFS);
61 case 1: return (CKC_BASE + PLL1CFG_OFFS);
62 case 2: return (CKC_BASE + PLL2CFG_OFFS);
63 default:
64 BUG();
65 }
66}
67
68static int pll_enable(int pll, int enable)
69{
70 u32 reg;
71 void __iomem *addr = pll_cfg_addr(pll);
72
73 reg = __raw_readl(addr);
74 if (enable)
75 reg &= ~PLLxCFG_PD;
76 else
77 reg |= PLLxCFG_PD;
78
79 __raw_writel(reg, addr);
80 return 0;
81}
82
83static int xi_enable(int enable)
84{
85 u32 reg;
86
87 reg = __raw_readl(CKC_BASE + CLKCTRL_OFFS);
88 if (enable)
89 reg |= CLKCTRL_XE;
90 else
91 reg &= ~CLKCTRL_XE;
92
93 __raw_writel(reg, CKC_BASE + CLKCTRL_OFFS);
94 return 0;
95}
96
97static int root_clk_enable(enum root_clks src)
98{
99 switch (src) {
100 case CLK_SRC_PLL0: return pll_enable(0, 1);
101 case CLK_SRC_PLL1: return pll_enable(1, 1);
102 case CLK_SRC_PLL2: return pll_enable(2, 1);
103 case CLK_SRC_XI: return xi_enable(1);
104 default:
105 BUG();
106 }
107 return 0;
108}
109
110static int root_clk_disable(enum root_clks root_src)
111{
112 switch (root_src) {
113 case CLK_SRC_PLL0: return pll_enable(0, 0);
114 case CLK_SRC_PLL1: return pll_enable(1, 0);
115 case CLK_SRC_PLL2: return pll_enable(2, 0);
116 case CLK_SRC_XI: return xi_enable(0);
117 default:
118 BUG();
119 }
120 return 0;
121}
122
123static int enable_clk(struct clk *clk)
124{
125 u32 reg;
126
127 if (clk->root_id != CLK_SRC_NOROOT)
128 return root_clk_enable(clk->root_id);
129
130 if (clk->aclkreg) {
131 reg = __raw_readl(clk->aclkreg);
132 reg |= ACLK_EN;
133 __raw_writel(reg, clk->aclkreg);
134 }
135 if (clk->bclkctr) {
136 reg = __raw_readl(clk->bclkctr);
137 reg |= 1 << clk->bclk_shift;
138 __raw_writel(reg, clk->bclkctr);
139 }
140 return 0;
141}
142
143static void disable_clk(struct clk *clk)
144{
145 u32 reg;
146
147 if (clk->root_id != CLK_SRC_NOROOT) {
148 root_clk_disable(clk->root_id);
149 return;
150 }
151
152 if (clk->bclkctr) {
153 reg = __raw_readl(clk->bclkctr);
154 reg &= ~(1 << clk->bclk_shift);
155 __raw_writel(reg, clk->bclkctr);
156 }
157 if (clk->aclkreg) {
158 reg = __raw_readl(clk->aclkreg);
159 reg &= ~ACLK_EN;
160 __raw_writel(reg, clk->aclkreg);
161 }
162}
163
164static unsigned long get_rate_pll(int pll)
165{
166 u32 reg;
167 unsigned long s, m, p;
168 void __iomem *addr = pll_cfg_addr(pll);
169
170 reg = __raw_readl(addr);
171 s = (reg >> 16) & 0x07;
172 m = (reg >> 8) & 0xff;
173 p = reg & 0x3f;
174
175 return (m * xi_rate) / (p * (1 << s));
176}
177
178static unsigned long get_rate_pll_div(int pll)
179{
180 u32 reg;
181 unsigned long div = 0;
182 void __iomem *addr;
183
184 switch (pll) {
185 case 0:
186 addr = CKC_BASE + CLKDIVC0_OFFS;
187 reg = __raw_readl(addr);
188 if (reg & CLKDIVC0_P0E)
189 div = (reg >> 24) & 0x3f;
190 break;
191 case 1:
192 addr = CKC_BASE + CLKDIVC0_OFFS;
193 reg = __raw_readl(addr);
194 if (reg & CLKDIVC0_P1E)
195 div = (reg >> 16) & 0x3f;
196 break;
197 case 2:
198 addr = CKC_BASE + CLKDIVC1_OFFS;
199 reg = __raw_readl(addr);
200 if (reg & CLKDIVC1_P2E)
201 div = __raw_readl(addr) & 0x3f;
202 break;
203 }
204 return get_rate_pll(pll) / (div + 1);
205}
206
207static unsigned long get_rate_xi_div(void)
208{
209 unsigned long div = 0;
210 u32 reg = __raw_readl(CKC_BASE + CLKDIVC0_OFFS);
211
212 if (reg & CLKDIVC0_XE)
213 div = (reg >> 8) & 0x3f;
214
215 return xi_rate / (div + 1);
216}
217
218static unsigned long get_rate_xti_div(void)
219{
220 unsigned long div = 0;
221 u32 reg = __raw_readl(CKC_BASE + CLKDIVC0_OFFS);
222
223 if (reg & CLKDIVC0_XTE)
224 div = reg & 0x3f;
225
226 return xti_rate / (div + 1);
227}
228
229static unsigned long root_clk_get_rate(enum root_clks src)
230{
231 switch (src) {
232 case CLK_SRC_PLL0: return get_rate_pll(0);
233 case CLK_SRC_PLL1: return get_rate_pll(1);
234 case CLK_SRC_PLL2: return get_rate_pll(2);
235 case CLK_SRC_PLL0DIV: return get_rate_pll_div(0);
236 case CLK_SRC_PLL1DIV: return get_rate_pll_div(1);
237 case CLK_SRC_PLL2DIV: return get_rate_pll_div(2);
238 case CLK_SRC_XI: return xi_rate;
239 case CLK_SRC_XTI: return xti_rate;
240 case CLK_SRC_XIDIV: return get_rate_xi_div();
241 case CLK_SRC_XTIDIV: return get_rate_xti_div();
242 default: return 0;
243 }
244}
245
246static unsigned long aclk_get_rate(struct clk *clk)
247{
248 u32 reg;
249 unsigned long div;
250 unsigned int src;
251
252 reg = __raw_readl(clk->aclkreg);
253 div = reg & 0x0fff;
254 src = (reg >> ACLK_SEL_SHIFT) & CLK_SRC_MASK;
255 return root_clk_get_rate(src) / (div + 1);
256}
257
258static unsigned long aclk_best_div(struct clk *clk, unsigned long rate)
259{
260 unsigned long div, src, freq, r1, r2;
261
262 src = __raw_readl(clk->aclkreg) >> ACLK_SEL_SHIFT;
263 src &= CLK_SRC_MASK;
264 freq = root_clk_get_rate(src);
265 div = freq / rate + 1;
266 r1 = freq / div;
267 r2 = freq / (div + 1);
268 if (r2 >= rate)
269 return div + 1;
270 if ((rate - r2) < (r1 - rate))
271 return div + 1;
272
273 return div;
274}
275
276static unsigned long aclk_round_rate(struct clk *clk, unsigned long rate)
277{
278 unsigned int src;
279
280 src = __raw_readl(clk->aclkreg) >> ACLK_SEL_SHIFT;
281 src &= CLK_SRC_MASK;
282
283 return root_clk_get_rate(src) / aclk_best_div(clk, rate);
284}
285
286static int aclk_set_rate(struct clk *clk, unsigned long rate)
287{
288 u32 reg;
289
290 reg = __raw_readl(clk->aclkreg) & ~ACLK_DIV_MASK;
291 reg |= aclk_best_div(clk, rate);
292 return 0;
293}
294
295static unsigned long get_rate_sys(struct clk *clk)
296{
297 unsigned int src;
298
299 src = __raw_readl(CKC_BASE + CLKCTRL_OFFS) & CLK_SRC_MASK;
300 return root_clk_get_rate(src);
301}
302
303static unsigned long get_rate_bus(struct clk *clk)
304{
305 unsigned int div;
306
307 div = (__raw_readl(CKC_BASE + CLKCTRL_OFFS) >> 4) & 0xff;
308 return get_rate_sys(clk) / (div + 1);
309}
310
311static unsigned long get_rate_cpu(struct clk *clk)
312{
313 unsigned int reg, div, fsys, fbus;
314
315 fbus = get_rate_bus(clk);
316 reg = __raw_readl(CKC_BASE + CLKCTRL_OFFS);
317 if (reg & (1 << 29))
318 return fbus;
319 fsys = get_rate_sys(clk);
320 div = (reg >> 16) & 0x0f;
321 return fbus + ((fsys - fbus) * (div + 1)) / 16;
322}
323
324static unsigned long get_rate_root(struct clk *clk)
325{
326 return root_clk_get_rate(clk->root_id);
327}
328
329static int aclk_set_parent(struct clk *clock, struct clk *parent)
330{
331 u32 reg;
332
333 if (clock->parent == parent)
334 return 0;
335
336 clock->parent = parent;
337
338 if (!parent)
339 return 0;
340
341 if (parent->root_id == CLK_SRC_NOROOT)
342 return 0;
343 reg = __raw_readl(clock->aclkreg);
344 reg &= ~ACLK_SEL_MASK;
345 reg |= (parent->root_id << ACLK_SEL_SHIFT) & ACLK_SEL_MASK;
346 __raw_writel(reg, clock->aclkreg);
347
348 return 0;
349}
350
351#define DEFINE_ROOT_CLOCK(name, ri, p) \
352 static struct clk name = { \
353 .root_id = ri, \
354 .get_rate = get_rate_root, \
355 .enable = enable_clk, \
356 .disable = disable_clk, \
357 .parent = p, \
358 };
359
360#define DEFINE_SPECIAL_CLOCK(name, gr, p) \
361 static struct clk name = { \
362 .root_id = CLK_SRC_NOROOT, \
363 .get_rate = gr, \
364 .parent = p, \
365 };
366
367#define DEFINE_ACLOCK(name, bc, bs, ar) \
368 static struct clk name = { \
369 .root_id = CLK_SRC_NOROOT, \
370 .bclkctr = bc, \
371 .bclk_shift = bs, \
372 .aclkreg = ar, \
373 .get_rate = aclk_get_rate, \
374 .set_rate = aclk_set_rate, \
375 .round_rate = aclk_round_rate, \
376 .enable = enable_clk, \
377 .disable = disable_clk, \
378 .set_parent = aclk_set_parent, \
379 };
380
381#define DEFINE_BCLOCK(name, bc, bs, gr, p) \
382 static struct clk name = { \
383 .root_id = CLK_SRC_NOROOT, \
384 .bclkctr = bc, \
385 .bclk_shift = bs, \
386 .get_rate = gr, \
387 .enable = enable_clk, \
388 .disable = disable_clk, \
389 .parent = p, \
390 };
391
392DEFINE_ROOT_CLOCK(xi, CLK_SRC_XI, NULL)
393DEFINE_ROOT_CLOCK(xti, CLK_SRC_XTI, NULL)
394DEFINE_ROOT_CLOCK(xidiv, CLK_SRC_XIDIV, &xi)
395DEFINE_ROOT_CLOCK(xtidiv, CLK_SRC_XTIDIV, &xti)
396DEFINE_ROOT_CLOCK(pll0, CLK_SRC_PLL0, &xi)
397DEFINE_ROOT_CLOCK(pll1, CLK_SRC_PLL1, &xi)
398DEFINE_ROOT_CLOCK(pll2, CLK_SRC_PLL2, &xi)
399DEFINE_ROOT_CLOCK(pll0div, CLK_SRC_PLL0DIV, &pll0)
400DEFINE_ROOT_CLOCK(pll1div, CLK_SRC_PLL1DIV, &pll1)
401DEFINE_ROOT_CLOCK(pll2div, CLK_SRC_PLL2DIV, &pll2)
402
403/* The following 3 clocks are special and are initialized explicitly later */
404DEFINE_SPECIAL_CLOCK(sys, get_rate_sys, NULL)
405DEFINE_SPECIAL_CLOCK(bus, get_rate_bus, &sys)
406DEFINE_SPECIAL_CLOCK(cpu, get_rate_cpu, &sys)
407
408DEFINE_ACLOCK(tct, NULL, 0, ACLKTCT)
409DEFINE_ACLOCK(tcx, NULL, 0, ACLKTCX)
410DEFINE_ACLOCK(tcz, NULL, 0, ACLKTCZ)
411DEFINE_ACLOCK(ref, NULL, 0, ACLKREF)
412DEFINE_ACLOCK(uart0, BCLKCTR0, 5, ACLKUART0)
413DEFINE_ACLOCK(uart1, BCLKCTR0, 23, ACLKUART1)
414DEFINE_ACLOCK(uart2, BCLKCTR0, 6, ACLKUART2)
415DEFINE_ACLOCK(uart3, BCLKCTR0, 8, ACLKUART3)
416DEFINE_ACLOCK(uart4, BCLKCTR1, 6, ACLKUART4)
417DEFINE_ACLOCK(i2c, BCLKCTR0, 7, ACLKI2C)
418DEFINE_ACLOCK(adc, BCLKCTR0, 10, ACLKADC)
419DEFINE_ACLOCK(usbh0, BCLKCTR0, 11, ACLKUSBH)
420DEFINE_ACLOCK(lcd, BCLKCTR0, 13, ACLKLCD)
421DEFINE_ACLOCK(sd0, BCLKCTR0, 17, ACLKSDH0)
422DEFINE_ACLOCK(sd1, BCLKCTR1, 5, ACLKSDH1)
423DEFINE_ACLOCK(spi0, BCLKCTR0, 24, ACLKSPI0)
424DEFINE_ACLOCK(spi1, BCLKCTR0, 30, ACLKSPI1)
425DEFINE_ACLOCK(spdif, BCLKCTR1, 2, ACLKSPDIF)
426DEFINE_ACLOCK(c3dec, BCLKCTR1, 9, ACLKC3DEC)
427DEFINE_ACLOCK(can0, BCLKCTR1, 10, ACLKCAN0)
428DEFINE_ACLOCK(can1, BCLKCTR1, 11, ACLKCAN1)
429DEFINE_ACLOCK(gsb0, BCLKCTR1, 13, ACLKGSB0)
430DEFINE_ACLOCK(gsb1, BCLKCTR1, 14, ACLKGSB1)
431DEFINE_ACLOCK(gsb2, BCLKCTR1, 15, ACLKGSB2)
432DEFINE_ACLOCK(gsb3, BCLKCTR1, 16, ACLKGSB3)
433DEFINE_ACLOCK(usbh1, BCLKCTR1, 20, ACLKUSBH)
434
435DEFINE_BCLOCK(dai0, BCLKCTR0, 0, NULL, NULL)
436DEFINE_BCLOCK(pic, BCLKCTR0, 1, NULL, NULL)
437DEFINE_BCLOCK(tc, BCLKCTR0, 2, NULL, NULL)
438DEFINE_BCLOCK(gpio, BCLKCTR0, 3, NULL, NULL)
439DEFINE_BCLOCK(usbd, BCLKCTR0, 4, NULL, NULL)
440DEFINE_BCLOCK(ecc, BCLKCTR0, 9, NULL, NULL)
441DEFINE_BCLOCK(gdma0, BCLKCTR0, 12, NULL, NULL)
442DEFINE_BCLOCK(rtc, BCLKCTR0, 15, NULL, NULL)
443DEFINE_BCLOCK(nfc, BCLKCTR0, 16, NULL, NULL)
444DEFINE_BCLOCK(g2d, BCLKCTR0, 18, NULL, NULL)
445DEFINE_BCLOCK(gdma1, BCLKCTR0, 22, NULL, NULL)
446DEFINE_BCLOCK(mscl, BCLKCTR0, 25, NULL, NULL)
447DEFINE_BCLOCK(bdma, BCLKCTR1, 0, NULL, NULL)
448DEFINE_BCLOCK(adma0, BCLKCTR1, 1, NULL, NULL)
449DEFINE_BCLOCK(scfg, BCLKCTR1, 3, NULL, NULL)
450DEFINE_BCLOCK(cid, BCLKCTR1, 4, NULL, NULL)
451DEFINE_BCLOCK(dai1, BCLKCTR1, 7, NULL, NULL)
452DEFINE_BCLOCK(adma1, BCLKCTR1, 8, NULL, NULL)
453DEFINE_BCLOCK(gps, BCLKCTR1, 12, NULL, NULL)
454DEFINE_BCLOCK(gdma2, BCLKCTR1, 17, NULL, NULL)
455DEFINE_BCLOCK(gdma3, BCLKCTR1, 18, NULL, NULL)
456DEFINE_BCLOCK(ddrc, BCLKCTR1, 19, NULL, NULL)
457
458#define _REGISTER_CLOCK(d, n, c) \
459 { \
460 .dev_id = d, \
461 .con_id = n, \
462 .clk = &c, \
463 },
464
465static struct clk_lookup lookups[] = {
466 _REGISTER_CLOCK(NULL, "bus", bus)
467 _REGISTER_CLOCK(NULL, "cpu", cpu)
468 _REGISTER_CLOCK(NULL, "tct", tct)
469 _REGISTER_CLOCK(NULL, "tcx", tcx)
470 _REGISTER_CLOCK(NULL, "tcz", tcz)
471 _REGISTER_CLOCK(NULL, "ref", ref)
472 _REGISTER_CLOCK(NULL, "dai0", dai0)
473 _REGISTER_CLOCK(NULL, "pic", pic)
474 _REGISTER_CLOCK(NULL, "tc", tc)
475 _REGISTER_CLOCK(NULL, "gpio", gpio)
476 _REGISTER_CLOCK(NULL, "usbd", usbd)
477 _REGISTER_CLOCK("tcc-uart.0", NULL, uart0)
478 _REGISTER_CLOCK("tcc-uart.2", NULL, uart2)
479 _REGISTER_CLOCK("tcc-i2c", NULL, i2c)
480 _REGISTER_CLOCK("tcc-uart.3", NULL, uart3)
481 _REGISTER_CLOCK(NULL, "ecc", ecc)
482 _REGISTER_CLOCK(NULL, "adc", adc)
483 _REGISTER_CLOCK("tcc-usbh.0", "usb", usbh0)
484 _REGISTER_CLOCK(NULL, "gdma0", gdma0)
485 _REGISTER_CLOCK(NULL, "lcd", lcd)
486 _REGISTER_CLOCK(NULL, "rtc", rtc)
487 _REGISTER_CLOCK(NULL, "nfc", nfc)
488 _REGISTER_CLOCK("tcc-mmc.0", NULL, sd0)
489 _REGISTER_CLOCK(NULL, "g2d", g2d)
490 _REGISTER_CLOCK(NULL, "gdma1", gdma1)
491 _REGISTER_CLOCK("tcc-uart.1", NULL, uart1)
492 _REGISTER_CLOCK("tcc-spi.0", NULL, spi0)
493 _REGISTER_CLOCK(NULL, "mscl", mscl)
494 _REGISTER_CLOCK("tcc-spi.1", NULL, spi1)
495 _REGISTER_CLOCK(NULL, "bdma", bdma)
496 _REGISTER_CLOCK(NULL, "adma0", adma0)
497 _REGISTER_CLOCK(NULL, "spdif", spdif)
498 _REGISTER_CLOCK(NULL, "scfg", scfg)
499 _REGISTER_CLOCK(NULL, "cid", cid)
500 _REGISTER_CLOCK("tcc-mmc.1", NULL, sd1)
501 _REGISTER_CLOCK("tcc-uart.4", NULL, uart4)
502 _REGISTER_CLOCK(NULL, "dai1", dai1)
503 _REGISTER_CLOCK(NULL, "adma1", adma1)
504 _REGISTER_CLOCK(NULL, "c3dec", c3dec)
505 _REGISTER_CLOCK("tcc-can.0", NULL, can0)
506 _REGISTER_CLOCK("tcc-can.1", NULL, can1)
507 _REGISTER_CLOCK(NULL, "gps", gps)
508 _REGISTER_CLOCK("tcc-gsb.0", NULL, gsb0)
509 _REGISTER_CLOCK("tcc-gsb.1", NULL, gsb1)
510 _REGISTER_CLOCK("tcc-gsb.2", NULL, gsb2)
511 _REGISTER_CLOCK("tcc-gsb.3", NULL, gsb3)
512 _REGISTER_CLOCK(NULL, "gdma2", gdma2)
513 _REGISTER_CLOCK(NULL, "gdma3", gdma3)
514 _REGISTER_CLOCK(NULL, "ddrc", ddrc)
515 _REGISTER_CLOCK("tcc-usbh.1", "usb", usbh1)
516};
517
518static struct clk *root_clk_by_index(enum root_clks src)
519{
520 switch (src) {
521 case CLK_SRC_PLL0: return &pll0;
522 case CLK_SRC_PLL1: return &pll1;
523 case CLK_SRC_PLL2: return &pll2;
524 case CLK_SRC_PLL0DIV: return &pll0div;
525 case CLK_SRC_PLL1DIV: return &pll1div;
526 case CLK_SRC_PLL2DIV: return &pll2div;
527 case CLK_SRC_XI: return &xi;
528 case CLK_SRC_XTI: return &xti;
529 case CLK_SRC_XIDIV: return &xidiv;
530 case CLK_SRC_XTIDIV: return &xtidiv;
531 default: return NULL;
532 }
533}
534
535static void find_aclk_parent(struct clk *clk)
536{
537 unsigned int src;
538 struct clk *clock;
539
540 if (!clk->aclkreg)
541 return;
542
543 src = __raw_readl(clk->aclkreg) >> ACLK_SEL_SHIFT;
544 src &= CLK_SRC_MASK;
545
546 clock = root_clk_by_index(src);
547 if (!clock)
548 return;
549
550 clk->parent = clock;
551 clk->set_parent = aclk_set_parent;
552}
553
554void __init tcc_clocks_init(unsigned long xi_freq, unsigned long xti_freq)
555{
556 int i;
557
558 xi_rate = xi_freq;
559 xti_rate = xti_freq;
560
561 /* fixup parents and add the clock */
562 for (i = 0; i < ARRAY_SIZE(lookups); i++) {
563 find_aclk_parent(lookups[i].clk);
564 clkdev_add(&lookups[i]);
565 }
566 tcc8k_timer_init(&tcz, (void __iomem *)TIMER_BASE, INT_TC32);
567}
diff --git a/arch/arm/mach-tcc8k/common.h b/arch/arm/mach-tcc8k/common.h
new file mode 100644
index 000000000000..705690add395
--- /dev/null
+++ b/arch/arm/mach-tcc8k/common.h
@@ -0,0 +1,15 @@
1#ifndef MACH_TCC8K_COMMON_H
2#define MACH_TCC8K_COMMON_H
3
4#include <linux/platform_device.h>
5
6extern struct platform_device tcc_nand_device;
7
8struct clk;
9
10extern void tcc_clocks_init(unsigned long xi_freq, unsigned long xti_freq);
11extern void tcc8k_timer_init(struct clk *clock, void __iomem *base, int irq);
12extern void tcc8k_init_irq(void);
13extern void tcc8k_map_common_io(void);
14
15#endif
diff --git a/arch/arm/mach-tcc8k/devices.c b/arch/arm/mach-tcc8k/devices.c
new file mode 100644
index 000000000000..6722ad7c2836
--- /dev/null
+++ b/arch/arm/mach-tcc8k/devices.c
@@ -0,0 +1,239 @@
1/*
2 * linux/arch/arm/mach-tcc8k/devices.c
3 *
4 * Copyright (C) Telechips, Inc.
5 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
6 *
7 * Licensed under the terms of GPL v2.
8 *
9 */
10
11#include <linux/dma-mapping.h>
12#include <linux/init.h>
13#include <linux/io.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16
17#include <asm/mach/map.h>
18
19#include <mach/tcc8k-regs.h>
20#include <mach/irqs.h>
21
22#include "common.h"
23
24static u64 tcc8k_dmamask = DMA_BIT_MASK(32);
25
26#ifdef CONFIG_MTD_NAND_TCC
27/* NAND controller */
28static struct resource tcc_nand_resources[] = {
29 {
30 .start = (resource_size_t)NFC_BASE,
31 .end = (resource_size_t)NFC_BASE + 0x7f,
32 .flags = IORESOURCE_MEM,
33 }, {
34 .start = INT_NFC,
35 .end = INT_NFC,
36 .flags = IORESOURCE_IRQ,
37 },
38};
39
40struct platform_device tcc_nand_device = {
41 .name = "tcc_nand",
42 .id = 0,
43 .num_resources = ARRAY_SIZE(tcc_nand_resources),
44 .resource = tcc_nand_resources,
45};
46#endif
47
48#ifdef CONFIG_MMC_TCC8K
49/* MMC controller */
50static struct resource tcc8k_mmc0_resource[] = {
51 {
52 .start = INT_SD0,
53 .end = INT_SD0,
54 .flags = IORESOURCE_IRQ,
55 },
56};
57
58static struct resource tcc8k_mmc1_resource[] = {
59 {
60 .start = INT_SD1,
61 .end = INT_SD1,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66struct platform_device tcc8k_mmc0_device = {
67 .name = "tcc-mmc",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(tcc8k_mmc0_resource),
70 .resource = tcc8k_mmc0_resource,
71 .dev = {
72 .dma_mask = &tcc8k_dmamask,
73 .coherent_dma_mask = DMA_BIT_MASK(32),
74 }
75};
76
77struct platform_device tcc8k_mmc1_device = {
78 .name = "tcc-mmc",
79 .id = 1,
80 .num_resources = ARRAY_SIZE(tcc8k_mmc1_resource),
81 .resource = tcc8k_mmc1_resource,
82 .dev = {
83 .dma_mask = &tcc8k_dmamask,
84 .coherent_dma_mask = DMA_BIT_MASK(32),
85 }
86};
87
88static inline void tcc8k_init_mmc(void)
89{
90 u32 reg = __raw_readl(GPIOPS_BASE + GPIOPS_FS1_OFFS);
91
92 reg |= GPIOPS_FS1_SDH0_BITS | GPIOPS_FS1_SDH1_BITS;
93 __raw_writel(reg, GPIOPS_BASE + GPIOPS_FS1_OFFS);
94
95 platform_device_register(&tcc8k_mmc0_device);
96 platform_device_register(&tcc8k_mmc1_device);
97}
98#else
99static inline void tcc8k_init_mmc(void) { }
100#endif
101
102#ifdef CONFIG_USB_OHCI_HCD
103static int tcc8k_ohci_init(struct device *dev)
104{
105 u32 reg;
106
107 /* Use GPIO PK19 as VBUS control output */
108 reg = __raw_readl(GPIOPK_BASE + GPIOPK_FS0_OFFS);
109 reg &= ~(1 << 19);
110 __raw_writel(reg, GPIOPK_BASE + GPIOPK_FS0_OFFS);
111 reg = __raw_readl(GPIOPK_BASE + GPIOPK_FS1_OFFS);
112 reg &= ~(1 << 19);
113 __raw_writel(reg, GPIOPK_BASE + GPIOPK_FS1_OFFS);
114
115 reg = __raw_readl(GPIOPK_BASE + GPIOPK_DOE_OFFS);
116 reg |= (1 << 19);
117 __raw_writel(reg, GPIOPK_BASE + GPIOPK_DOE_OFFS);
118 /* Turn on VBUS */
119 reg = __raw_readl(GPIOPK_BASE + GPIOPK_DAT_OFFS);
120 reg |= (1 << 19);
121 __raw_writel(reg, GPIOPK_BASE + GPIOPK_DAT_OFFS);
122
123 return 0;
124}
125
126static struct resource tcc8k_ohci0_resources[] = {
127 [0] = {
128 .start = (resource_size_t)USBH0_BASE,
129 .end = (resource_size_t)USBH0_BASE + 0x5c,
130 .flags = IORESOURCE_MEM,
131 },
132 [1] = {
133 .start = INT_USBH0,
134 .end = INT_USBH0,
135 .flags = IORESOURCE_IRQ,
136 }
137};
138
139static struct resource tcc8k_ohci1_resources[] = {
140 [0] = {
141 .start = (resource_size_t)USBH1_BASE,
142 .end = (resource_size_t)USBH1_BASE + 0x5c,
143 .flags = IORESOURCE_MEM,
144 },
145 [1] = {
146 .start = INT_USBH1,
147 .end = INT_USBH1,
148 .flags = IORESOURCE_IRQ,
149 }
150};
151
152static struct tccohci_platform_data tcc8k_ohci0_platform_data = {
153 .controller = 0,
154 .port_mode = PMM_PERPORT_MODE,
155 .init = tcc8k_ohci_init,
156};
157
158static struct tccohci_platform_data tcc8k_ohci1_platform_data = {
159 .controller = 1,
160 .port_mode = PMM_PERPORT_MODE,
161 .init = tcc8k_ohci_init,
162};
163
164static struct platform_device ohci0_device = {
165 .name = "tcc-ohci",
166 .id = 0,
167 .dev = {
168 .dma_mask = &tcc8k_dmamask,
169 .coherent_dma_mask = DMA_BIT_MASK(32),
170 .platform_data = &tcc8k_ohci0_platform_data,
171 },
172 .num_resources = ARRAY_SIZE(tcc8k_ohci0_resources),
173 .resource = tcc8k_ohci0_resources,
174};
175
176static struct platform_device ohci1_device = {
177 .name = "tcc-ohci",
178 .id = 1,
179 .dev = {
180 .dma_mask = &tcc8k_dmamask,
181 .coherent_dma_mask = DMA_BIT_MASK(32),
182 .platform_data = &tcc8k_ohci1_platform_data,
183 },
184 .num_resources = ARRAY_SIZE(tcc8k_ohci1_resources),
185 .resource = tcc8k_ohci1_resources,
186};
187
188static void __init tcc8k_init_usbhost(void)
189{
190 platform_device_register(&ohci0_device);
191 platform_device_register(&ohci1_device);
192}
193#else
194static void __init tcc8k_init_usbhost(void) { }
195#endif
196
197/* USB device controller*/
198#ifdef CONFIG_USB_GADGET_TCC8K
199static struct resource udc_resources[] = {
200 [0] = {
201 .start = INT_USBD,
202 .end = INT_USBD,
203 .flags = IORESOURCE_IRQ,
204 },
205 [1] = {
206 .start = INT_UDMA,
207 .end = INT_UDMA,
208 .flags = IORESOURCE_IRQ,
209 },
210};
211
212static struct platform_device tcc8k_udc_device = {
213 .name = "tcc-udc",
214 .id = 0,
215 .resource = udc_resources,
216 .num_resources = ARRAY_SIZE(udc_resources),
217 .dev = {
218 .dma_mask = &tcc8k_dmamask,
219 .coherent_dma_mask = DMA_BIT_MASK(32),
220 },
221};
222
223static void __init tcc8k_init_usb_gadget(void)
224{
225 platform_device_register(&tcc8k_udc_device);
226}
227#else
228static void __init tcc8k_init_usb_gadget(void) { }
229#endif /* CONFIG_USB_GADGET_TCC83X */
230
231static int __init tcc8k_init_devices(void)
232{
233 tcc8k_init_mmc();
234 tcc8k_init_usbhost();
235 tcc8k_init_usb_gadget();
236 return 0;
237}
238
239arch_initcall(tcc8k_init_devices);
diff --git a/arch/arm/mach-tcc8k/io.c b/arch/arm/mach-tcc8k/io.c
new file mode 100644
index 000000000000..9b39d7fa658f
--- /dev/null
+++ b/arch/arm/mach-tcc8k/io.c
@@ -0,0 +1,62 @@
1/*
2 * linux/arch/arm/mach-tcc8k/io.c
3 *
4 * (C) 2009 Hans J. Koch <hjk@linutronix.de>
5 *
6 * derived from TCC83xx io.c
7 * Copyright (C) Telechips, Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/init.h>
15#include <linux/io.h>
16#include <linux/kernel.h>
17
18#include <asm/mach/map.h>
19
20#include <mach/tcc8k-regs.h>
21
22/*
23 * The machine specific code may provide the extra mapping besides the
24 * default mapping provided here.
25 */
26static struct map_desc tcc8k_io_desc[] __initdata = {
27 {
28 .virtual = (unsigned long)CS1_BASE_VIRT,
29 .pfn = __phys_to_pfn(CS1_BASE),
30 .length = CS1_SIZE,
31 .type = MT_DEVICE,
32 }, {
33 .virtual = (unsigned long)AHB_PERI_BASE_VIRT,
34 .pfn = __phys_to_pfn(AHB_PERI_BASE),
35 .length = AHB_PERI_SIZE,
36 .type = MT_DEVICE,
37 }, {
38 .virtual = (unsigned long)APB0_PERI_BASE_VIRT,
39 .pfn = __phys_to_pfn(APB0_PERI_BASE),
40 .length = APB0_PERI_SIZE,
41 .type = MT_DEVICE,
42 }, {
43 .virtual = (unsigned long)APB1_PERI_BASE_VIRT,
44 .pfn = __phys_to_pfn(APB1_PERI_BASE),
45 .length = APB1_PERI_SIZE,
46 .type = MT_DEVICE,
47 }, {
48 .virtual = (unsigned long)EXT_MEM_CTRL_BASE_VIRT,
49 .pfn = __phys_to_pfn(EXT_MEM_CTRL_BASE),
50 .length = EXT_MEM_CTRL_SIZE,
51 .type = MT_DEVICE,
52 },
53};
54
55/*
56 * Maps common IO regions for tcc8k.
57 *
58 */
59void __init tcc8k_map_common_io(void)
60{
61 iotable_init(tcc8k_io_desc, ARRAY_SIZE(tcc8k_io_desc));
62}
diff --git a/arch/arm/mach-tcc8k/irq.c b/arch/arm/mach-tcc8k/irq.c
new file mode 100644
index 000000000000..34575c4963f0
--- /dev/null
+++ b/arch/arm/mach-tcc8k/irq.c
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) Telechips, Inc.
3 * Copyright (C) 2009-2010 Hans J. Koch <hjk@linutronix.de>
4 *
5 * Licensed under the terms of the GNU GPL version 2.
6 */
7
8#include <linux/init.h>
9#include <linux/interrupt.h>
10#include <linux/io.h>
11
12#include <asm/irq.h>
13#include <asm/mach/irq.h>
14
15#include <mach/tcc8k-regs.h>
16#include <mach/irqs.h>
17
18#include "common.h"
19
20/* Disable IRQ */
21static void tcc8000_mask_ack_irq0(unsigned int irq)
22{
23 PIC0_IEN &= ~(1 << irq);
24 PIC0_CREQ |= (1 << irq);
25}
26
27static void tcc8000_mask_ack_irq1(unsigned int irq)
28{
29 PIC1_IEN &= ~(1 << (irq - 32));
30 PIC1_CREQ |= (1 << (irq - 32));
31}
32
33static void tcc8000_mask_irq0(unsigned int irq)
34{
35 PIC0_IEN &= ~(1 << irq);
36}
37
38static void tcc8000_mask_irq1(unsigned int irq)
39{
40 PIC1_IEN &= ~(1 << (irq - 32));
41}
42
43static void tcc8000_ack_irq0(unsigned int irq)
44{
45 PIC0_CREQ |= (1 << irq);
46}
47
48static void tcc8000_ack_irq1(unsigned int irq)
49{
50 PIC1_CREQ |= (1 << (irq - 32));
51}
52
53/* Enable IRQ */
54static void tcc8000_unmask_irq0(unsigned int irq)
55{
56 PIC0_IEN |= (1 << irq);
57 PIC0_INTOEN |= (1 << irq);
58}
59
60static void tcc8000_unmask_irq1(unsigned int irq)
61{
62 PIC1_IEN |= (1 << (irq - 32));
63 PIC1_INTOEN |= (1 << (irq - 32));
64}
65
66static struct irq_chip tcc8000_irq_chip0 = {
67 .name = "tcc_irq0",
68 .mask = tcc8000_mask_irq0,
69 .ack = tcc8000_ack_irq0,
70 .mask_ack = tcc8000_mask_ack_irq0,
71 .unmask = tcc8000_unmask_irq0,
72};
73
74static struct irq_chip tcc8000_irq_chip1 = {
75 .name = "tcc_irq1",
76 .mask = tcc8000_mask_irq1,
77 .ack = tcc8000_ack_irq1,
78 .mask_ack = tcc8000_mask_ack_irq1,
79 .unmask = tcc8000_unmask_irq1,
80};
81
82void __init tcc8k_init_irq(void)
83{
84 int irqno;
85
86 /* Mask and clear all interrupts */
87 PIC0_IEN = 0x00000000;
88 PIC0_CREQ = 0xffffffff;
89 PIC1_IEN = 0x00000000;
90 PIC1_CREQ = 0xffffffff;
91
92 PIC0_MEN0 = 0x00000003;
93 PIC1_MEN1 = 0x00000003;
94 PIC1_MEN = 0x00000003;
95
96 /* let all IRQs be level triggered */
97 PIC0_TMODE = 0xffffffff;
98 PIC1_TMODE = 0xffffffff;
99 /* all IRQs are IRQs (not FIQs) */
100 PIC0_IRQSEL = 0xffffffff;
101 PIC1_IRQSEL = 0xffffffff;
102
103 for (irqno = 0; irqno < NR_IRQS; irqno++) {
104 if (irqno < 32)
105 set_irq_chip(irqno, &tcc8000_irq_chip0);
106 else
107 set_irq_chip(irqno, &tcc8000_irq_chip1);
108 set_irq_handler(irqno, handle_level_irq);
109 set_irq_flags(irqno, IRQF_VALID);
110 }
111}
diff --git a/arch/arm/mach-tcc8k/time.c b/arch/arm/mach-tcc8k/time.c
new file mode 100644
index 000000000000..78d06008841d
--- /dev/null
+++ b/arch/arm/mach-tcc8k/time.c
@@ -0,0 +1,149 @@
1/*
2 * TCC8000 system timer setup
3 *
4 * (C) 2009 Hans J. Koch <hjk@linutronix.de>
5 *
6 * Licensed under the terms of the GPL version 2.
7 *
8 */
9
10#include <linux/clk.h>
11#include <linux/clockchips.h>
12#include <linux/init.h>
13#include <linux/interrupt.h>
14#include <linux/io.h>
15#include <linux/irq.h>
16#include <linux/kernel.h>
17#include <linux/spinlock.h>
18
19#include <asm/mach/time.h>
20
21#include <mach/tcc8k-regs.h>
22#include <mach/irqs.h>
23
24#include "common.h"
25
26static void __iomem *timer_base;
27
28static cycle_t tcc_get_cycles(struct clocksource *cs)
29{
30 return __raw_readl(timer_base + TC32MCNT_OFFS);
31}
32
33static struct clocksource clocksource_tcc = {
34 .name = "tcc_tc32",
35 .rating = 200,
36 .read = tcc_get_cycles,
37 .mask = CLOCKSOURCE_MASK(32),
38 .shift = 28,
39 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
40};
41
42static int tcc_set_next_event(unsigned long evt,
43 struct clock_event_device *unused)
44{
45 unsigned long reg = __raw_readl(timer_base + TC32MCNT_OFFS);
46
47 __raw_writel(reg + evt, timer_base + TC32CMP0_OFFS);
48 return 0;
49}
50
51static void tcc_set_mode(enum clock_event_mode mode,
52 struct clock_event_device *evt)
53{
54 unsigned long tc32irq;
55
56 switch (mode) {
57 case CLOCK_EVT_MODE_ONESHOT:
58 tc32irq = __raw_readl(timer_base + TC32IRQ_OFFS);
59 tc32irq |= TC32IRQ_IRQEN0;
60 __raw_writel(tc32irq, timer_base + TC32IRQ_OFFS);
61 break;
62 case CLOCK_EVT_MODE_SHUTDOWN:
63 case CLOCK_EVT_MODE_UNUSED:
64 tc32irq = __raw_readl(timer_base + TC32IRQ_OFFS);
65 tc32irq &= ~TC32IRQ_IRQEN0;
66 __raw_writel(tc32irq, timer_base + TC32IRQ_OFFS);
67 break;
68 case CLOCK_EVT_MODE_PERIODIC:
69 case CLOCK_EVT_MODE_RESUME:
70 break;
71 }
72}
73
74static irqreturn_t tcc8k_timer_interrupt(int irq, void *dev_id)
75{
76 struct clock_event_device *evt = dev_id;
77
78 /* Acknowledge TC32 interrupt by reading TC32IRQ */
79 __raw_readl(timer_base + TC32IRQ_OFFS);
80
81 evt->event_handler(evt);
82
83 return IRQ_HANDLED;
84}
85
86static struct clock_event_device clockevent_tcc = {
87 .name = "tcc_timer1",
88 .features = CLOCK_EVT_FEAT_ONESHOT,
89 .shift = 32,
90 .set_mode = tcc_set_mode,
91 .set_next_event = tcc_set_next_event,
92 .rating = 200,
93};
94
95static struct irqaction tcc8k_timer_irq = {
96 .name = "TC32_timer",
97 .flags = IRQF_DISABLED | IRQF_TIMER,
98 .handler = tcc8k_timer_interrupt,
99 .dev_id = &clockevent_tcc,
100};
101
102static int __init tcc_clockevent_init(struct clk *clock)
103{
104 unsigned int c = clk_get_rate(clock);
105
106 clocksource_tcc.mult = clocksource_hz2mult(c,
107 clocksource_tcc.shift);
108 clocksource_register(&clocksource_tcc);
109
110 clockevent_tcc.mult = div_sc(c, NSEC_PER_SEC,
111 clockevent_tcc.shift);
112 clockevent_tcc.max_delta_ns =
113 clockevent_delta2ns(0xfffffffe, &clockevent_tcc);
114 clockevent_tcc.min_delta_ns =
115 clockevent_delta2ns(0xff, &clockevent_tcc);
116
117 clockevent_tcc.cpumask = cpumask_of(0);
118
119 clockevents_register_device(&clockevent_tcc);
120
121 return 0;
122}
123
124void __init tcc8k_timer_init(struct clk *clock, void __iomem *base, int irq)
125{
126 u32 reg;
127
128 timer_base = base;
129 tcc8k_timer_irq.irq = irq;
130
131 /* Enable clocks */
132 clk_enable(clock);
133
134 /* Initialize 32-bit timer */
135 reg = __raw_readl(timer_base + TC32EN_OFFS);
136 reg &= ~TC32EN_ENABLE; /* Disable timer */
137 __raw_writel(reg, timer_base + TC32EN_OFFS);
138 /* Free running timer, counting from 0 to 0xffffffff */
139 __raw_writel(0, timer_base + TC32EN_OFFS);
140 __raw_writel(0, timer_base + TC32LDV_OFFS);
141 reg = __raw_readl(timer_base + TC32IRQ_OFFS);
142 reg |= TC32IRQ_IRQEN0; /* irq at match with CMP0 */
143 __raw_writel(reg, timer_base + TC32IRQ_OFFS);
144
145 __raw_writel(TC32EN_ENABLE, timer_base + TC32EN_OFFS);
146
147 tcc_clockevent_init(clock);
148 setup_irq(irq, &tcc8k_timer_irq);
149}
diff --git a/arch/arm/mach-tegra/board-harmony.c b/arch/arm/mach-tegra/board-harmony.c
index 9e305de56be9..b9dbdb1289d0 100644
--- a/arch/arm/mach-tegra/board-harmony.c
+++ b/arch/arm/mach-tegra/board-harmony.c
@@ -115,8 +115,6 @@ static void __init tegra_harmony_init(void)
115 115
116MACHINE_START(HARMONY, "harmony") 116MACHINE_START(HARMONY, "harmony")
117 .boot_params = 0x00000100, 117 .boot_params = 0x00000100,
118 .phys_io = IO_APB_PHYS,
119 .io_pg_offst = ((IO_APB_VIRT) >> 18) & 0xfffc,
120 .fixup = tegra_harmony_fixup, 118 .fixup = tegra_harmony_fixup,
121 .init_irq = tegra_init_irq, 119 .init_irq = tegra_init_irq,
122 .init_machine = tegra_harmony_init, 120 .init_machine = tegra_harmony_init,
diff --git a/arch/arm/mach-tegra/include/mach/debug-macro.S b/arch/arm/mach-tegra/include/mach/debug-macro.S
index 55a39564b43c..8ea3bffb4e00 100644
--- a/arch/arm/mach-tegra/include/mach/debug-macro.S
+++ b/arch/arm/mach-tegra/include/mach/debug-macro.S
@@ -20,24 +20,28 @@
20 20
21#include <mach/io.h> 21#include <mach/io.h>
22 22
23 .macro addruart,rx, tmp 23 .macro addruart, rp, rv
24 mrc p15, 0, \rx, c1, c0 24 ldreq \rp, =IO_APB_PHYS @ physical
25 tst \rx, #1 @ MMU enabled? 25 ldrne \rv, =IO_APB_VIRT @ virtual
26 ldreq \rx, =IO_APB_PHYS @ physical
27 ldrne \rx, =IO_APB_VIRT @ virtual
28#if defined(CONFIG_TEGRA_DEBUG_UART_NONE) 26#if defined(CONFIG_TEGRA_DEBUG_UART_NONE)
29#error "A debug UART must be selected in the kernel config to use DEBUG_LL" 27#error "A debug UART must be selected in the kernel config to use DEBUG_LL"
30#elif defined(CONFIG_TEGRA_DEBUG_UARTA) 28#elif defined(CONFIG_TEGRA_DEBUG_UARTA)
31 orr \rx, \rx, #0x6000 29 orr \rp, \rp, #0x6000
30 orr \rv, \rv, #0x6000
32#elif defined(CONFIG_TEGRA_DEBUG_UARTB) 31#elif defined(CONFIG_TEGRA_DEBUG_UARTB)
33 ldr \tmp, =0x6040 32 orr \rp, \rp, #0x6000
34 orr \rx, \rx, \tmp 33 orr \rp, \rp, #0x40
34 orr \rv, \rv, #0x6000
35 orr \rv, \rv, #0x40
35#elif defined(CONFIG_TEGRA_DEBUG_UARTC) 36#elif defined(CONFIG_TEGRA_DEBUG_UARTC)
36 orr \rx, \rx, #0x6200 37 orr \rp, \rp, #0x6200
38 orr \rv, \rv, #0x6200
37#elif defined(CONFIG_TEGRA_DEBUG_UARTD) 39#elif defined(CONFIG_TEGRA_DEBUG_UARTD)
38 orr \rx, \rx, #0x6300 40 orr \rp, \rp, #0x6300
41 orr \rv, \rv, #0x6300
39#elif defined(CONFIG_TEGRA_DEBUG_UARTE) 42#elif defined(CONFIG_TEGRA_DEBUG_UARTE)
40 orr \rx, \rx, #0x6400 43 orr \rp, \rp, #0x6400
44 orr \rv, \rv, #0x6400
41#endif 45#endif
42 .endm 46 .endm
43 47
diff --git a/arch/arm/mach-tegra/include/mach/smp.h b/arch/arm/mach-tegra/include/mach/smp.h
index 8b42dab79a70..e4a34a35a544 100644
--- a/arch/arm/mach-tegra/include/mach/smp.h
+++ b/arch/arm/mach-tegra/include/mach/smp.h
@@ -1,16 +1,8 @@
1#ifndef ASMARM_ARCH_SMP_H 1#ifndef ASMARM_ARCH_SMP_H
2#define ASMARM_ARCH_SMP_H 2#define ASMARM_ARCH_SMP_H
3 3
4
5#include <asm/hardware/gic.h> 4#include <asm/hardware/gic.h>
6 5#include <asm/smp_mpidr.h>
7#define hard_smp_processor_id() \
8 ({ \
9 unsigned int cpunum; \
10 __asm__("mrc p15, 0, %0, c0, c0, 5" \
11 : "=r" (cpunum)); \
12 cpunum &= 0x0F; \
13 })
14 6
15/* 7/*
16 * We use IRQ1 as the IPI 8 * We use IRQ1 as the IPI
diff --git a/arch/arm/mach-u300/dummyspichip.c b/arch/arm/mach-u300/dummyspichip.c
index 5f55012b7c9e..03f793612594 100644
--- a/arch/arm/mach-u300/dummyspichip.c
+++ b/arch/arm/mach-u300/dummyspichip.c
@@ -46,7 +46,6 @@ static ssize_t dummy_looptest(struct device *dev,
46 * struct, this is just used here to alter the behaviour of the chip 46 * struct, this is just used here to alter the behaviour of the chip
47 * in order to perform tests. 47 * in order to perform tests.
48 */ 48 */
49 struct pl022_config_chip *chip_info = spi->controller_data;
50 int status; 49 int status;
51 u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD, 50 u8 txbuf[14] = {0xDE, 0xAD, 0xBE, 0xEF, 0x2B, 0xAD,
52 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05, 51 0xCA, 0xFE, 0xBA, 0xBE, 0xB1, 0x05,
@@ -72,7 +71,7 @@ static ssize_t dummy_looptest(struct device *dev,
72 * Force chip to 8 bit mode 71 * Force chip to 8 bit mode
73 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 72 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC!
74 */ 73 */
75 chip_info->data_size = SSP_DATA_BITS_8; 74 spi->bits_per_word = 8;
76 /* You should NOT DO THIS EITHER */ 75 /* You should NOT DO THIS EITHER */
77 spi->master->setup(spi); 76 spi->master->setup(spi);
78 77
@@ -159,7 +158,7 @@ static ssize_t dummy_looptest(struct device *dev,
159 * Force chip to 16 bit mode 158 * Force chip to 16 bit mode
160 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC! 159 * WARNING: NEVER DO THIS IN REAL DRIVER CODE, THIS SHOULD BE STATIC!
161 */ 160 */
162 chip_info->data_size = SSP_DATA_BITS_16; 161 spi->bits_per_word = 16;
163 /* You should NOT DO THIS EITHER */ 162 /* You should NOT DO THIS EITHER */
164 spi->master->setup(spi); 163 spi->master->setup(spi);
165 164
diff --git a/arch/arm/mach-u300/include/mach/debug-macro.S b/arch/arm/mach-u300/include/mach/debug-macro.S
index 92c12420256f..df715707bead 100644
--- a/arch/arm/mach-u300/include/mach/debug-macro.S
+++ b/arch/arm/mach-u300/include/mach/debug-macro.S
@@ -10,13 +10,12 @@
10 */ 10 */
11#include <mach/hardware.h> 11#include <mach/hardware.h>
12 12
13 .macro addruart, rx, tmp 13 .macro addruart, rp, rv
14 /* If we move the address using MMU, use this. */ 14 /* If we move the address using MMU, use this. */
15 mrc p15, 0, \rx, c1, c0 15 ldr \rp, = U300_SLOW_PER_PHYS_BASE @ MMU off, physical address
16 tst \rx, #1 @ MMU enabled? 16 ldr \rv, = U300_SLOW_PER_VIRT_BASE @ MMU on, virtual address
17 ldreq \rx, = U300_SLOW_PER_PHYS_BASE @ MMU off, physical address 17 orr \rp, \rp, #0x00003000
18 ldrne \rx, = U300_SLOW_PER_VIRT_BASE @ MMU on, virtual address 18 orr \rv, \rv, #0x00003000
19 orr \rx, \rx, #0x00003000
20 .endm 19 .endm
21 20
22#include <asm/hardware/debug-pl01x.S> 21#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-u300/spi.c b/arch/arm/mach-u300/spi.c
index f0e887bea30e..edb2c0d255c2 100644
--- a/arch/arm/mach-u300/spi.c
+++ b/arch/arm/mach-u300/spi.c
@@ -30,8 +30,6 @@ static void select_dummy_chip(u32 chipselect)
30} 30}
31 31
32struct pl022_config_chip dummy_chip_info = { 32struct pl022_config_chip dummy_chip_info = {
33 /* Nominally this is LOOPBACK_DISABLED, but this is our dummy chip! */
34 .lbm = LOOPBACK_ENABLED,
35 /* 33 /*
36 * available POLLING_TRANSFER and INTERRUPT_TRANSFER, 34 * available POLLING_TRANSFER and INTERRUPT_TRANSFER,
37 * DMA_TRANSFER does not work 35 * DMA_TRANSFER does not work
@@ -42,14 +40,8 @@ struct pl022_config_chip dummy_chip_info = {
42 .hierarchy = SSP_MASTER, 40 .hierarchy = SSP_MASTER,
43 /* 0 = drive TX even as slave, 1 = do not drive TX as slave */ 41 /* 0 = drive TX even as slave, 1 = do not drive TX as slave */
44 .slave_tx_disable = 0, 42 .slave_tx_disable = 0,
45 /* LSB first */
46 .endian_tx = SSP_TX_LSB,
47 .endian_rx = SSP_RX_LSB,
48 .data_size = SSP_DATA_BITS_8, /* used to be 12 in some default */
49 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 43 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
50 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 44 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
51 .clk_phase = SSP_CLK_SECOND_EDGE,
52 .clk_pol = SSP_CLK_POL_IDLE_LOW,
53 .ctrl_len = SSP_BITS_12, 45 .ctrl_len = SSP_BITS_12,
54 .wait_state = SSP_MWIRE_WAIT_ZERO, 46 .wait_state = SSP_MWIRE_WAIT_ZERO,
55 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, 47 .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX,
@@ -75,7 +67,7 @@ static struct spi_board_info u300_spi_devices[] = {
75 .bus_num = 0, /* Only one bus on this chip */ 67 .bus_num = 0, /* Only one bus on this chip */
76 .chip_select = 0, 68 .chip_select = 0,
77 /* Means SPI_CS_HIGH, change if e.g low CS */ 69 /* Means SPI_CS_HIGH, change if e.g low CS */
78 .mode = 0, 70 .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP,
79 }, 71 },
80#endif 72#endif
81}; 73};
diff --git a/arch/arm/mach-u300/u300.c b/arch/arm/mach-u300/u300.c
index bfcda9820888..07c35a846424 100644
--- a/arch/arm/mach-u300/u300.c
+++ b/arch/arm/mach-u300/u300.c
@@ -61,8 +61,6 @@ static void __init u300_init_machine(void)
61 61
62MACHINE_START(U300, MACH_U300_STRING) 62MACHINE_START(U300, MACH_U300_STRING)
63 /* Maintainer: Linus Walleij <linus.walleij@stericsson.com> */ 63 /* Maintainer: Linus Walleij <linus.walleij@stericsson.com> */
64 .phys_io = U300_AHB_PER_PHYS_BASE,
65 .io_pg_offst = ((U300_AHB_PER_VIRT_BASE) >> 18) & 0xfffc,
66 .boot_params = BOOT_PARAMS_OFFSET, 64 .boot_params = BOOT_PARAMS_OFFSET,
67 .map_io = u300_map_io, 65 .map_io = u300_map_io,
68 .reserve = u300_reserve, 66 .reserve = u300_reserve,
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 6625e5bbf4d6..2dd44a0b4615 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -21,9 +21,7 @@ config MACH_U8500_MOP
21 bool "U8500 Development platform" 21 bool "U8500 Development platform"
22 select UX500_SOC_DB8500 22 select UX500_SOC_DB8500
23 help 23 help
24 Include support for mop500 development platform 24 Include support for the mop500 development platform.
25 based on U8500 architecture. The platform is based
26 on early drop silicon version of 8500.
27 25
28config MACH_U5500 26config MACH_U5500
29 bool "U5500 Development platform" 27 bool "U5500 Development platform"
@@ -39,4 +37,18 @@ config UX500_DEBUG_UART
39 Choose the UART on which kernel low-level debug messages should be 37 Choose the UART on which kernel low-level debug messages should be
40 output. 38 output.
41 39
40config U5500_MODEM_IRQ
41 bool "Modem IRQ support"
42 depends on MACH_U5500
43 default y
44 help
45 Add support for handling IRQ:s from modem side
46
47config U5500_MBOX
48 bool "Mailbox support"
49 depends on MACH_U5500 && U5500_MODEM_IRQ
50 default y
51 help
52 Add support for U5500 mailbox communication with modem side
53
42endif 54endif
diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 4556aea9c3c5..9e27a84433cb 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -4,8 +4,12 @@
4 4
5obj-y := clock.o cpu.o devices.o 5obj-y := clock.o cpu.o devices.o
6obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o devices-db5500.o 6obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o devices-db5500.o
7obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o 7obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o prcmu.o
8obj-$(CONFIG_MACH_U8500_MOP) += board-mop500.o 8obj-$(CONFIG_MACH_U8500_MOP) += board-mop500.o board-mop500-sdi.o
9obj-$(CONFIG_MACH_U5500) += board-u5500.o 9obj-$(CONFIG_MACH_U5500) += board-u5500.o
10obj-$(CONFIG_SMP) += platsmp.o headsmp.o 10obj-$(CONFIG_SMP) += platsmp.o headsmp.o
11obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
11obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o 12obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
13obj-$(CONFIG_REGULATOR_AB8500) += board-mop500-regulators.o
14obj-$(CONFIG_U5500_MODEM_IRQ) += modem_irq.o
15obj-$(CONFIG_U5500_MBOX) += mbox.o
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c
new file mode 100644
index 000000000000..1187f1fc2e53
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500-regulators.c
@@ -0,0 +1,101 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 *
6 * Author: Sundar Iyer <sundar.iyer@stericsson.com>
7 *
8 * MOP500 board specific initialization for regulators
9 */
10#include <linux/kernel.h>
11#include <linux/regulator/machine.h>
12
13/* supplies to the display/camera */
14static struct regulator_init_data ab8500_vaux1_regulator = {
15 .constraints = {
16 .name = "V-DISPLAY",
17 .min_uV = 2500000,
18 .max_uV = 2900000,
19 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
20 REGULATOR_CHANGE_STATUS,
21 },
22};
23
24/* supplies to the on-board eMMC */
25static struct regulator_init_data ab8500_vaux2_regulator = {
26 .constraints = {
27 .name = "V-eMMC1",
28 .min_uV = 1100000,
29 .max_uV = 3300000,
30 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
31 REGULATOR_CHANGE_STATUS,
32 },
33};
34
35/* supply for VAUX3, supplies to SDcard slots */
36static struct regulator_init_data ab8500_vaux3_regulator = {
37 .constraints = {
38 .name = "V-MMC-SD",
39 .min_uV = 1100000,
40 .max_uV = 3300000,
41 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
42 REGULATOR_CHANGE_STATUS,
43 },
44};
45
46/* supply for tvout, gpadc, TVOUT LDO */
47static struct regulator_init_data ab8500_vtvout_init = {
48 .constraints = {
49 .name = "V-TVOUT",
50 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
51 },
52};
53
54/* supply for ab8500-vaudio, VAUDIO LDO */
55static struct regulator_init_data ab8500_vaudio_init = {
56 .constraints = {
57 .name = "V-AUD",
58 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
59 },
60};
61
62/* supply for v-anamic1 VAMic1-LDO */
63static struct regulator_init_data ab8500_vamic1_init = {
64 .constraints = {
65 .name = "V-AMIC1",
66 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
67 },
68};
69
70/* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
71static struct regulator_init_data ab8500_vamic2_init = {
72 .constraints = {
73 .name = "V-AMIC2",
74 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
75 },
76};
77
78/* supply for v-dmic, VDMIC LDO */
79static struct regulator_init_data ab8500_vdmic_init = {
80 .constraints = {
81 .name = "V-DMIC",
82 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
83 },
84};
85
86/* supply for v-intcore12, VINTCORE12 LDO */
87static struct regulator_init_data ab8500_vintcore_init = {
88 .constraints = {
89 .name = "V-INTCORE",
90 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
91 },
92};
93
94/* supply for U8500 CSI/DSI, VANA LDO */
95static struct regulator_init_data ab8500_vana_init = {
96 .constraints = {
97 .name = "V-CSI/DSI",
98 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
99 },
100};
101
diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c b/arch/arm/mach-ux500/board-mop500-sdi.c
new file mode 100644
index 000000000000..bac995665b58
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500-sdi.c
@@ -0,0 +1,91 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Hanumath Prasad <hanumath.prasad@stericsson.com>
5 * License terms: GNU General Public License (GPL) version 2
6 */
7
8#include <linux/kernel.h>
9#include <linux/gpio.h>
10#include <linux/amba/bus.h>
11#include <linux/amba/mmci.h>
12#include <linux/mmc/host.h>
13#include <linux/platform_device.h>
14
15#include <plat/pincfg.h>
16#include <mach/devices.h>
17#include <mach/hardware.h>
18
19#include "pins-db8500.h"
20#include "board-mop500.h"
21
22static pin_cfg_t mop500_sdi_pins[] = {
23 /* SDI4 (on-board eMMC) */
24 GPIO197_MC4_DAT3,
25 GPIO198_MC4_DAT2,
26 GPIO199_MC4_DAT1,
27 GPIO200_MC4_DAT0,
28 GPIO201_MC4_CMD,
29 GPIO202_MC4_FBCLK,
30 GPIO203_MC4_CLK,
31 GPIO204_MC4_DAT7,
32 GPIO205_MC4_DAT6,
33 GPIO206_MC4_DAT5,
34 GPIO207_MC4_DAT4,
35};
36
37static pin_cfg_t mop500_sdi2_pins[] = {
38 /* SDI2 (POP eMMC) */
39 GPIO128_MC2_CLK,
40 GPIO129_MC2_CMD,
41 GPIO130_MC2_FBCLK,
42 GPIO131_MC2_DAT0,
43 GPIO132_MC2_DAT1,
44 GPIO133_MC2_DAT2,
45 GPIO134_MC2_DAT3,
46 GPIO135_MC2_DAT4,
47 GPIO136_MC2_DAT5,
48 GPIO137_MC2_DAT6,
49 GPIO138_MC2_DAT7,
50};
51
52/*
53 * SDI 2 (POP eMMC, not on DB8500ed)
54 */
55
56static struct mmci_platform_data mop500_sdi2_data = {
57 .ocr_mask = MMC_VDD_165_195,
58 .f_max = 100000000,
59 .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
60 .gpio_cd = -1,
61 .gpio_wp = -1,
62};
63
64/*
65 * SDI 4 (on-board eMMC)
66 */
67
68static struct mmci_platform_data mop500_sdi4_data = {
69 .ocr_mask = MMC_VDD_29_30,
70 .f_max = 100000000,
71 .capabilities = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
72 MMC_CAP_MMC_HIGHSPEED,
73 .gpio_cd = -1,
74 .gpio_wp = -1,
75};
76
77void mop500_sdi_init(void)
78{
79 nmk_config_pins(mop500_sdi_pins, ARRAY_SIZE(mop500_sdi_pins));
80
81 u8500_sdi2_device.dev.platform_data = &mop500_sdi2_data;
82 u8500_sdi4_device.dev.platform_data = &mop500_sdi4_data;
83
84 if (!cpu_is_u8500ed()) {
85 nmk_config_pins(mop500_sdi2_pins, ARRAY_SIZE(mop500_sdi2_pins));
86 amba_device_register(&u8500_sdi2_device, &iomem_resource);
87 }
88
89 /* On-board eMMC */
90 amba_device_register(&u8500_sdi4_device, &iomem_resource);
91}
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 0e8fd135a57d..cac83a694880 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -18,18 +18,22 @@
18#include <linux/amba/pl022.h> 18#include <linux/amba/pl022.h>
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/mfd/ab8500.h> 20#include <linux/mfd/ab8500.h>
21#include <linux/input/matrix_keypad.h>
21 22
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
24 25
25#include <plat/pincfg.h> 26#include <plat/pincfg.h>
26#include <plat/i2c.h> 27#include <plat/i2c.h>
28#include <plat/ske.h>
27 29
28#include <mach/hardware.h> 30#include <mach/hardware.h>
29#include <mach/setup.h> 31#include <mach/setup.h>
30#include <mach/devices.h> 32#include <mach/devices.h>
33#include <mach/irqs.h>
31 34
32#include "pins-db8500.h" 35#include "pins-db8500.h"
36#include "board-mop500.h"
33 37
34static pin_cfg_t mop500_pins[] = { 38static pin_cfg_t mop500_pins[] = {
35 /* SSP0 */ 39 /* SSP0 */
@@ -47,6 +51,24 @@ static pin_cfg_t mop500_pins[] = {
47 GPIO11_I2C2_SCL, 51 GPIO11_I2C2_SCL,
48 GPIO229_I2C3_SDA, 52 GPIO229_I2C3_SDA,
49 GPIO230_I2C3_SCL, 53 GPIO230_I2C3_SCL,
54
55 /* SKE keypad */
56 GPIO153_KP_I7,
57 GPIO154_KP_I6,
58 GPIO155_KP_I5,
59 GPIO156_KP_I4,
60 GPIO157_KP_O7,
61 GPIO158_KP_O6,
62 GPIO159_KP_O5,
63 GPIO160_KP_O4,
64 GPIO161_KP_I3,
65 GPIO162_KP_I2,
66 GPIO163_KP_I1,
67 GPIO164_KP_I0,
68 GPIO165_KP_O3,
69 GPIO166_KP_O2,
70 GPIO167_KP_O1,
71 GPIO168_KP_O0,
50}; 72};
51 73
52static void ab4500_spi_cs_control(u32 command) 74static void ab4500_spi_cs_control(u32 command)
@@ -55,19 +77,13 @@ static void ab4500_spi_cs_control(u32 command)
55} 77}
56 78
57struct pl022_config_chip ab4500_chip_info = { 79struct pl022_config_chip ab4500_chip_info = {
58 .lbm = LOOPBACK_DISABLED,
59 .com_mode = INTERRUPT_TRANSFER, 80 .com_mode = INTERRUPT_TRANSFER,
60 .iface = SSP_INTERFACE_MOTOROLA_SPI, 81 .iface = SSP_INTERFACE_MOTOROLA_SPI,
61 /* we can act as master only */ 82 /* we can act as master only */
62 .hierarchy = SSP_MASTER, 83 .hierarchy = SSP_MASTER,
63 .slave_tx_disable = 0, 84 .slave_tx_disable = 0,
64 .endian_rx = SSP_RX_MSB,
65 .endian_tx = SSP_TX_MSB,
66 .data_size = SSP_DATA_BITS_24,
67 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, 85 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
68 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, 86 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
69 .clk_phase = SSP_CLK_SECOND_EDGE,
70 .clk_pol = SSP_CLK_POL_IDLE_HIGH,
71 .cs_control = ab4500_spi_cs_control, 87 .cs_control = ab4500_spi_cs_control,
72}; 88};
73 89
@@ -75,15 +91,33 @@ static struct ab8500_platform_data ab8500_platdata = {
75 .irq_base = MOP500_AB8500_IRQ_BASE, 91 .irq_base = MOP500_AB8500_IRQ_BASE,
76}; 92};
77 93
78static struct spi_board_info u8500_spi_devices[] = { 94static struct resource ab8500_resources[] = {
95 [0] = {
96 .start = IRQ_AB8500,
97 .end = IRQ_AB8500,
98 .flags = IORESOURCE_IRQ
99 }
100};
101
102struct platform_device ab8500_device = {
103 .name = "ab8500-i2c",
104 .id = 0,
105 .dev = {
106 .platform_data = &ab8500_platdata,
107 },
108 .num_resources = 1,
109 .resource = ab8500_resources,
110};
111
112static struct spi_board_info ab8500_spi_devices[] = {
79 { 113 {
80 .modalias = "ab8500", 114 .modalias = "ab8500-spi",
81 .controller_data = &ab4500_chip_info, 115 .controller_data = &ab4500_chip_info,
82 .platform_data = &ab8500_platdata, 116 .platform_data = &ab8500_platdata,
83 .max_speed_hz = 12000000, 117 .max_speed_hz = 12000000,
84 .bus_num = 0, 118 .bus_num = 0,
85 .chip_select = 0, 119 .chip_select = 0,
86 .mode = SPI_MODE_0, 120 .mode = SPI_MODE_3,
87 .irq = IRQ_DB8500_AB8500, 121 .irq = IRQ_DB8500_AB8500,
88 }, 122 },
89}; 123};
@@ -134,12 +168,120 @@ static struct amba_device *amba_devs[] __initdata = {
134 &u8500_ssp0_device, 168 &u8500_ssp0_device,
135}; 169};
136 170
171static const unsigned int ux500_keymap[] = {
172 KEY(2, 5, KEY_END),
173 KEY(4, 1, KEY_POWER),
174 KEY(3, 5, KEY_VOLUMEDOWN),
175 KEY(1, 3, KEY_3),
176 KEY(5, 2, KEY_RIGHT),
177 KEY(5, 0, KEY_9),
178
179 KEY(0, 5, KEY_MENU),
180 KEY(7, 6, KEY_ENTER),
181 KEY(4, 5, KEY_0),
182 KEY(6, 7, KEY_2),
183 KEY(3, 4, KEY_UP),
184 KEY(3, 3, KEY_DOWN),
185
186 KEY(6, 4, KEY_SEND),
187 KEY(6, 2, KEY_BACK),
188 KEY(4, 2, KEY_VOLUMEUP),
189 KEY(5, 5, KEY_1),
190 KEY(4, 3, KEY_LEFT),
191 KEY(3, 2, KEY_7),
192};
193
194static const struct matrix_keymap_data ux500_keymap_data = {
195 .keymap = ux500_keymap,
196 .keymap_size = ARRAY_SIZE(ux500_keymap),
197};
198
199/*
200 * Nomadik SKE keypad
201 */
202#define ROW_PIN_I0 164
203#define ROW_PIN_I1 163
204#define ROW_PIN_I2 162
205#define ROW_PIN_I3 161
206#define ROW_PIN_I4 156
207#define ROW_PIN_I5 155
208#define ROW_PIN_I6 154
209#define ROW_PIN_I7 153
210#define COL_PIN_O0 168
211#define COL_PIN_O1 167
212#define COL_PIN_O2 166
213#define COL_PIN_O3 165
214#define COL_PIN_O4 160
215#define COL_PIN_O5 159
216#define COL_PIN_O6 158
217#define COL_PIN_O7 157
218
219#define SKE_KPD_MAX_ROWS 8
220#define SKE_KPD_MAX_COLS 8
221
222static int ske_kp_rows[] = {
223 ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
224 ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
225};
226
227/*
228 * ske_set_gpio_row: request and set gpio rows
229 */
230static int ske_set_gpio_row(int gpio)
231{
232 int ret;
233
234 ret = gpio_request(gpio, "ske-kp");
235 if (ret < 0) {
236 pr_err("ske_set_gpio_row: gpio request failed\n");
237 return ret;
238 }
239
240 ret = gpio_direction_output(gpio, 1);
241 if (ret < 0) {
242 pr_err("ske_set_gpio_row: gpio direction failed\n");
243 gpio_free(gpio);
244 }
245
246 return ret;
247}
248
249/*
250 * ske_kp_init - enable the gpio configuration
251 */
252static int ske_kp_init(void)
253{
254 int ret, i;
255
256 for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
257 ret = ske_set_gpio_row(ske_kp_rows[i]);
258 if (ret < 0) {
259 pr_err("ske_kp_init: failed init\n");
260 return ret;
261 }
262 }
263
264 return 0;
265}
266
267static struct ske_keypad_platform_data ske_keypad_board = {
268 .init = ske_kp_init,
269 .keymap_data = &ux500_keymap_data,
270 .no_autorepeat = true,
271 .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */
272 .kcol = SKE_KPD_MAX_COLS,
273 .debounce_ms = 40, /* in millsecs */
274};
275
276
277
137/* add any platform devices here - TODO */ 278/* add any platform devices here - TODO */
138static struct platform_device *platform_devs[] __initdata = { 279static struct platform_device *platform_devs[] __initdata = {
139 &u8500_i2c0_device, 280 &u8500_i2c0_device,
140 &ux500_i2c1_device, 281 &ux500_i2c1_device,
141 &ux500_i2c2_device, 282 &ux500_i2c2_device,
142 &ux500_i2c3_device, 283 &ux500_i2c3_device,
284 &ux500_ske_keypad_device,
143}; 285};
144 286
145static void __init u8500_init_machine(void) 287static void __init u8500_init_machine(void)
@@ -154,6 +296,7 @@ static void __init u8500_init_machine(void)
154 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data; 296 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
155 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data; 297 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
156 ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data; 298 ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
299 ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
157 300
158 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data; 301 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
159 302
@@ -163,14 +306,18 @@ static void __init u8500_init_machine(void)
163 306
164 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 307 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
165 308
166 spi_register_board_info(u8500_spi_devices, 309 mop500_sdi_init();
167 ARRAY_SIZE(u8500_spi_devices)); 310
311 /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
312 if (cpu_is_u8500ed() || cpu_is_u8500v10())
313 spi_register_board_info(ab8500_spi_devices,
314 ARRAY_SIZE(ab8500_spi_devices));
315 else /* If HW is v.1.1 or later use I2C to access AB8500 */
316 platform_device_register(&ab8500_device);
168} 317}
169 318
170MACHINE_START(U8500, "ST-Ericsson MOP500 platform") 319MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
171 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ 320 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
172 .phys_io = U8500_UART2_BASE,
173 .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
174 .boot_params = 0x100, 321 .boot_params = 0x100,
175 .map_io = u8500_map_io, 322 .map_io = u8500_map_io,
176 .init_irq = ux500_init_irq, 323 .init_irq = ux500_init_irq,
diff --git a/arch/arm/mach-ux500/board-mop500.h b/arch/arm/mach-ux500/board-mop500.h
new file mode 100644
index 000000000000..2d240322fa6f
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500.h
@@ -0,0 +1,12 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License terms: GNU General Public License (GPL) version 2
5 */
6
7#ifndef __BOARD_MOP500_H
8#define __BOARD_MOP500_H
9
10extern void mop500_sdi_init(void);
11
12#endif
diff --git a/arch/arm/mach-ux500/board-u5500.c b/arch/arm/mach-ux500/board-u5500.c
index 4430e69cf538..1ca094a45e71 100644
--- a/arch/arm/mach-ux500/board-u5500.c
+++ b/arch/arm/mach-ux500/board-u5500.c
@@ -31,8 +31,6 @@ static void __init u5500_init_machine(void)
31} 31}
32 32
33MACHINE_START(U8500, "ST-Ericsson U5500 Platform") 33MACHINE_START(U8500, "ST-Ericsson U5500 Platform")
34 .phys_io = UX500_UART0_BASE,
35 .io_pg_offst = (IO_ADDRESS(UX500_UART0_BASE) >> 18) & 0xfffc,
36 .boot_params = 0x00000100, 34 .boot_params = 0x00000100,
37 .map_io = u5500_map_io, 35 .map_io = u5500_map_io,
38 .init_irq = ux500_init_irq, 36 .init_irq = ux500_init_irq,
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index d8ab7f184fe4..1675047daf20 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -477,6 +477,7 @@ static struct clk_lookup u8500_common_clks[] = {
477 CLK(sdi5, "sdi5", NULL), 477 CLK(sdi5, "sdi5", NULL),
478 CLK(uart2, "uart2", NULL), 478 CLK(uart2, "uart2", NULL),
479 CLK(ske, "ske", NULL), 479 CLK(ske, "ske", NULL),
480 CLK(ske, "nmk-ske-keypad", NULL),
480 CLK(sdi2, "sdi2", NULL), 481 CLK(sdi2, "sdi2", NULL),
481 CLK(i2c0, "nmk-i2c.0", NULL), 482 CLK(i2c0, "nmk-i2c.0", NULL),
482 CLK(fsmc, "fsmc", NULL), 483 CLK(fsmc, "fsmc", NULL),
diff --git a/arch/arm/mach-ux500/cpu-db5500.c b/arch/arm/mach-ux500/cpu-db5500.c
index e9278f6d67aa..2f87075e9d6f 100644
--- a/arch/arm/mach-ux500/cpu-db5500.c
+++ b/arch/arm/mach-ux500/cpu-db5500.c
@@ -14,6 +14,7 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/devices.h> 15#include <mach/devices.h>
16#include <mach/setup.h> 16#include <mach/setup.h>
17#include <mach/irqs.h>
17 18
18static struct map_desc u5500_io_desc[] __initdata = { 19static struct map_desc u5500_io_desc[] __initdata = {
19 __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K), 20 __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
@@ -24,6 +25,90 @@ static struct map_desc u5500_io_desc[] __initdata = {
24 __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K), 25 __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
25}; 26};
26 27
28static struct resource mbox0_resources[] = {
29 {
30 .name = "mbox_peer",
31 .start = U5500_MBOX0_PEER_START,
32 .end = U5500_MBOX0_PEER_END,
33 .flags = IORESOURCE_MEM,
34 },
35 {
36 .name = "mbox_local",
37 .start = U5500_MBOX0_LOCAL_START,
38 .end = U5500_MBOX0_LOCAL_END,
39 .flags = IORESOURCE_MEM,
40 },
41 {
42 .name = "mbox_irq",
43 .start = MBOX_PAIR0_VIRT_IRQ,
44 .end = MBOX_PAIR0_VIRT_IRQ,
45 .flags = IORESOURCE_IRQ,
46 }
47};
48
49static struct resource mbox1_resources[] = {
50 {
51 .name = "mbox_peer",
52 .start = U5500_MBOX1_PEER_START,
53 .end = U5500_MBOX1_PEER_END,
54 .flags = IORESOURCE_MEM,
55 },
56 {
57 .name = "mbox_local",
58 .start = U5500_MBOX1_LOCAL_START,
59 .end = U5500_MBOX1_LOCAL_END,
60 .flags = IORESOURCE_MEM,
61 },
62 {
63 .name = "mbox_irq",
64 .start = MBOX_PAIR1_VIRT_IRQ,
65 .end = MBOX_PAIR1_VIRT_IRQ,
66 .flags = IORESOURCE_IRQ,
67 }
68};
69
70static struct resource mbox2_resources[] = {
71 {
72 .name = "mbox_peer",
73 .start = U5500_MBOX2_PEER_START,
74 .end = U5500_MBOX2_PEER_END,
75 .flags = IORESOURCE_MEM,
76 },
77 {
78 .name = "mbox_local",
79 .start = U5500_MBOX2_LOCAL_START,
80 .end = U5500_MBOX2_LOCAL_END,
81 .flags = IORESOURCE_MEM,
82 },
83 {
84 .name = "mbox_irq",
85 .start = MBOX_PAIR2_VIRT_IRQ,
86 .end = MBOX_PAIR2_VIRT_IRQ,
87 .flags = IORESOURCE_IRQ,
88 }
89};
90
91static struct platform_device mbox0_device = {
92 .id = 0,
93 .name = "mbox",
94 .resource = mbox0_resources,
95 .num_resources = ARRAY_SIZE(mbox0_resources),
96};
97
98static struct platform_device mbox1_device = {
99 .id = 1,
100 .name = "mbox",
101 .resource = mbox1_resources,
102 .num_resources = ARRAY_SIZE(mbox1_resources),
103};
104
105static struct platform_device mbox2_device = {
106 .id = 2,
107 .name = "mbox",
108 .resource = mbox2_resources,
109 .num_resources = ARRAY_SIZE(mbox2_resources),
110};
111
27static struct platform_device *u5500_platform_devs[] __initdata = { 112static struct platform_device *u5500_platform_devs[] __initdata = {
28 &u5500_gpio_devs[0], 113 &u5500_gpio_devs[0],
29 &u5500_gpio_devs[1], 114 &u5500_gpio_devs[1],
@@ -33,6 +118,9 @@ static struct platform_device *u5500_platform_devs[] __initdata = {
33 &u5500_gpio_devs[5], 118 &u5500_gpio_devs[5],
34 &u5500_gpio_devs[6], 119 &u5500_gpio_devs[6],
35 &u5500_gpio_devs[7], 120 &u5500_gpio_devs[7],
121 &mbox0_device,
122 &mbox1_device,
123 &mbox2_device,
36}; 124};
37 125
38void __init u5500_map_io(void) 126void __init u5500_map_io(void)
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index f21c444edd99..4acab7544b3c 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -38,10 +38,12 @@ static struct platform_device *platform_devs[] __initdata = {
38/* minimum static i/o mapping required to boot U8500 platforms */ 38/* minimum static i/o mapping required to boot U8500 platforms */
39static struct map_desc u8500_io_desc[] __initdata = { 39static struct map_desc u8500_io_desc[] __initdata = {
40 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K), 40 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
41 __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE, SZ_4K),
41 __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K), 42 __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
42 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K), 43 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
43 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K), 44 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
44 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K), 45 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
46 __MEM_DEV_DESC(U8500_BOOT_ROM_BASE, SZ_1M),
45}; 47};
46 48
47static struct map_desc u8500ed_io_desc[] __initdata = { 49static struct map_desc u8500ed_io_desc[] __initdata = {
@@ -53,6 +55,69 @@ static struct map_desc u8500v1_io_desc[] __initdata = {
53 __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K), 55 __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
54}; 56};
55 57
58/*
59 * Functions to differentiate between later ASICs
60 * We look into the end of the ROM to locate the hardcoded ASIC ID.
61 * This is only needed to differentiate between minor revisions and
62 * process variants of an ASIC, the major revisions are encoded in
63 * the cpuid.
64 */
65#define U8500_ASIC_ID_LOC_ED_V1 (U8500_BOOT_ROM_BASE + 0x1FFF4)
66#define U8500_ASIC_ID_LOC_V2 (U8500_BOOT_ROM_BASE + 0x1DBF4)
67#define U8500_ASIC_REV_ED 0x01
68#define U8500_ASIC_REV_V10 0xA0
69#define U8500_ASIC_REV_V11 0xA1
70#define U8500_ASIC_REV_V20 0xB0
71
72/**
73 * struct db8500_asic_id - fields of the ASIC ID
74 * @process: the manufacturing process, 0x40 is 40 nm
75 * 0x00 is "standard"
76 * @partnumber: hithereto 0x8500 for DB8500
77 * @revision: version code in the series
78 * This field definion is not formally defined but makes
79 * sense.
80 */
81struct db8500_asic_id {
82 u8 process;
83 u16 partnumber;
84 u8 revision;
85};
86
87/* This isn't going to change at runtime */
88static struct db8500_asic_id db8500_id;
89
90static void __init get_db8500_asic_id(void)
91{
92 u32 asicid;
93
94 if (cpu_is_u8500v1() || cpu_is_u8500ed())
95 asicid = readl(__io_address(U8500_ASIC_ID_LOC_ED_V1));
96 else if (cpu_is_u8500v2())
97 asicid = readl(__io_address(U8500_ASIC_ID_LOC_V2));
98 else
99 BUG();
100
101 db8500_id.process = (asicid >> 24);
102 db8500_id.partnumber = (asicid >> 16) & 0xFFFFU;
103 db8500_id.revision = asicid & 0xFFU;
104}
105
106bool cpu_is_u8500v10(void)
107{
108 return (db8500_id.revision == U8500_ASIC_REV_V10);
109}
110
111bool cpu_is_u8500v11(void)
112{
113 return (db8500_id.revision == U8500_ASIC_REV_V11);
114}
115
116bool cpu_is_u8500v20(void)
117{
118 return (db8500_id.revision == U8500_ASIC_REV_V20);
119}
120
56void __init u8500_map_io(void) 121void __init u8500_map_io(void)
57{ 122{
58 ux500_map_io(); 123 ux500_map_io();
@@ -63,6 +128,9 @@ void __init u8500_map_io(void)
63 iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc)); 128 iotable_init(u8500ed_io_desc, ARRAY_SIZE(u8500ed_io_desc));
64 else 129 else
65 iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc)); 130 iotable_init(u8500v1_io_desc, ARRAY_SIZE(u8500v1_io_desc));
131
132 /* Read out the ASIC ID as early as we can */
133 get_db8500_asic_id();
66} 134}
67 135
68/* 136/*
@@ -70,6 +138,20 @@ void __init u8500_map_io(void)
70 */ 138 */
71void __init u8500_init_devices(void) 139void __init u8500_init_devices(void)
72{ 140{
141 /* Display some ASIC boilerplate */
142 pr_info("DB8500: process: %02x, revision ID: 0x%02x\n",
143 db8500_id.process, db8500_id.revision);
144 if (cpu_is_u8500ed())
145 pr_info("DB8500: Early Drop (ED)\n");
146 else if (cpu_is_u8500v10())
147 pr_info("DB8500: version 1.0\n");
148 else if (cpu_is_u8500v11())
149 pr_info("DB8500: version 1.1\n");
150 else if (cpu_is_u8500v20())
151 pr_info("DB8500: version 2.0\n");
152 else
153 pr_warning("ASIC: UNKNOWN SILICON VERSION!\n");
154
73 ux500_init_devices(); 155 ux500_init_devices();
74 156
75 if (cpu_is_u8500ed()) 157 if (cpu_is_u8500ed())
diff --git a/arch/arm/mach-ux500/devices-db8500.c b/arch/arm/mach-ux500/devices-db8500.c
index 9280d2561111..cbbe69a76a7c 100644
--- a/arch/arm/mach-ux500/devices-db8500.c
+++ b/arch/arm/mach-ux500/devices-db8500.c
@@ -110,6 +110,82 @@ struct platform_device u8500_i2c4_device = {
110 .num_resources = ARRAY_SIZE(u8500_i2c4_resources), 110 .num_resources = ARRAY_SIZE(u8500_i2c4_resources),
111}; 111};
112 112
113/*
114 * SD/MMC
115 */
116
117struct amba_device u8500_sdi0_device = {
118 .dev = {
119 .init_name = "sdi0",
120 },
121 .res = {
122 .start = U8500_SDI0_BASE,
123 .end = U8500_SDI0_BASE + SZ_4K - 1,
124 .flags = IORESOURCE_MEM,
125 },
126 .irq = {IRQ_DB8500_SDMMC0, NO_IRQ},
127};
128
129struct amba_device u8500_sdi1_device = {
130 .dev = {
131 .init_name = "sdi1",
132 },
133 .res = {
134 .start = U8500_SDI1_BASE,
135 .end = U8500_SDI1_BASE + SZ_4K - 1,
136 .flags = IORESOURCE_MEM,
137 },
138 .irq = {IRQ_DB8500_SDMMC1, NO_IRQ},
139};
140
141struct amba_device u8500_sdi2_device = {
142 .dev = {
143 .init_name = "sdi2",
144 },
145 .res = {
146 .start = U8500_SDI2_BASE,
147 .end = U8500_SDI2_BASE + SZ_4K - 1,
148 .flags = IORESOURCE_MEM,
149 },
150 .irq = {IRQ_DB8500_SDMMC2, NO_IRQ},
151};
152
153struct amba_device u8500_sdi3_device = {
154 .dev = {
155 .init_name = "sdi3",
156 },
157 .res = {
158 .start = U8500_SDI3_BASE,
159 .end = U8500_SDI3_BASE + SZ_4K - 1,
160 .flags = IORESOURCE_MEM,
161 },
162 .irq = {IRQ_DB8500_SDMMC3, NO_IRQ},
163};
164
165struct amba_device u8500_sdi4_device = {
166 .dev = {
167 .init_name = "sdi4",
168 },
169 .res = {
170 .start = U8500_SDI4_BASE,
171 .end = U8500_SDI4_BASE + SZ_4K - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 .irq = {IRQ_DB8500_SDMMC4, NO_IRQ},
175};
176
177struct amba_device u8500_sdi5_device = {
178 .dev = {
179 .init_name = "sdi5",
180 },
181 .res = {
182 .start = U8500_SDI5_BASE,
183 .end = U8500_SDI5_BASE + SZ_4K - 1,
184 .flags = IORESOURCE_MEM,
185 },
186 .irq = {IRQ_DB8500_SDMMC5, NO_IRQ},
187};
188
113static struct resource dma40_resources[] = { 189static struct resource dma40_resources[] = {
114 [0] = { 190 [0] = {
115 .start = U8500_DMA_BASE, 191 .start = U8500_DMA_BASE,
@@ -170,23 +246,23 @@ struct stedma40_chan_cfg dma40_memcpy_conf_log = {
170 * Mapping between destination event lines and physical device address. 246 * Mapping between destination event lines and physical device address.
171 * The event line is tied to a device and therefor the address is constant. 247 * The event line is tied to a device and therefor the address is constant.
172 */ 248 */
173static const dma_addr_t dma40_tx_map[STEDMA40_NR_DEV]; 249static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV];
174 250
175/* Mapping between source event lines and physical device address */ 251/* Mapping between source event lines and physical device address */
176static const dma_addr_t dma40_rx_map[STEDMA40_NR_DEV]; 252static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV];
177 253
178/* Reserved event lines for memcpy only */ 254/* Reserved event lines for memcpy only */
179static int dma40_memcpy_event[] = { 255static int dma40_memcpy_event[] = {
180 STEDMA40_MEMCPY_TX_0, 256 DB8500_DMA_MEMCPY_TX_0,
181 STEDMA40_MEMCPY_TX_1, 257 DB8500_DMA_MEMCPY_TX_1,
182 STEDMA40_MEMCPY_TX_2, 258 DB8500_DMA_MEMCPY_TX_2,
183 STEDMA40_MEMCPY_TX_3, 259 DB8500_DMA_MEMCPY_TX_3,
184 STEDMA40_MEMCPY_TX_4, 260 DB8500_DMA_MEMCPY_TX_4,
185 STEDMA40_MEMCPY_TX_5, 261 DB8500_DMA_MEMCPY_TX_5,
186}; 262};
187 263
188static struct stedma40_platform_data dma40_plat_data = { 264static struct stedma40_platform_data dma40_plat_data = {
189 .dev_len = STEDMA40_NR_DEV, 265 .dev_len = DB8500_DMA_NR_DEV,
190 .dev_rx = dma40_rx_map, 266 .dev_rx = dma40_rx_map,
191 .dev_tx = dma40_tx_map, 267 .dev_tx = dma40_tx_map,
192 .memcpy = dma40_memcpy_event, 268 .memcpy = dma40_memcpy_event,
@@ -216,3 +292,23 @@ void dma40_u8500ed_fixup(void)
216 dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED; 292 dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
217 dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1; 293 dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
218} 294}
295
296struct resource keypad_resources[] = {
297 [0] = {
298 .start = U8500_SKE_BASE,
299 .end = U8500_SKE_BASE + SZ_4K - 1,
300 .flags = IORESOURCE_MEM,
301 },
302 [1] = {
303 .start = IRQ_DB8500_KB,
304 .end = IRQ_DB8500_KB,
305 .flags = IORESOURCE_IRQ,
306 },
307};
308
309struct platform_device ux500_ske_keypad_device = {
310 .name = "nmk-ske-keypad",
311 .id = -1,
312 .num_resources = ARRAY_SIZE(keypad_resources),
313 .resource = keypad_resources,
314};
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
new file mode 100644
index 000000000000..b782a03024be
--- /dev/null
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -0,0 +1,75 @@
1/*
2 * Copyright (C) STMicroelectronics 2009
3 * Copyright (C) ST-Ericsson SA 2010
4 *
5 * License Terms: GNU General Public License v2
6 * Based on ARM realview platform
7 *
8 * Author: Sundar Iyer <sundar.iyer@stericsson.com>
9 *
10 */
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/smp.h>
14#include <linux/completion.h>
15
16#include <asm/cacheflush.h>
17
18extern volatile int pen_release;
19
20static DECLARE_COMPLETION(cpu_killed);
21
22static inline void platform_do_lowpower(unsigned int cpu)
23{
24 flush_cache_all();
25
26 /* we put the platform to just WFI */
27 for (;;) {
28 __asm__ __volatile__("dsb\n\t" "wfi\n\t"
29 : : : "memory");
30 if (pen_release == cpu) {
31 /*
32 * OK, proper wakeup, we're done
33 */
34 break;
35 }
36 }
37}
38
39int platform_cpu_kill(unsigned int cpu)
40{
41 return wait_for_completion_timeout(&cpu_killed, 5000);
42}
43
44/*
45 * platform-specific code to shutdown a CPU
46 *
47 * Called with IRQs disabled
48 */
49void platform_cpu_die(unsigned int cpu)
50{
51#ifdef DEBUG
52 unsigned int this_cpu = hard_smp_processor_id();
53
54 if (cpu != this_cpu) {
55 printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
56 this_cpu, cpu);
57 BUG();
58 }
59#endif
60
61 printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
62 complete(&cpu_killed);
63
64 /* directly enter low power state, skipping secure registers */
65 platform_do_lowpower(cpu);
66}
67
68int platform_cpu_disable(unsigned int cpu)
69{
70 /*
71 * we don't allow CPU 0 to be shutdown (it is still too special
72 * e.g. clock tick interrupts)
73 */
74 return cpu == 0 ? -EPERM : 0;
75}
diff --git a/arch/arm/mach-ux500/include/mach/db5500-regs.h b/arch/arm/mach-ux500/include/mach/db5500-regs.h
index 545c80fc8024..3eafc0e24ba5 100644
--- a/arch/arm/mach-ux500/include/mach/db5500-regs.h
+++ b/arch/arm/mach-ux500/include/mach/db5500-regs.h
@@ -100,4 +100,18 @@
100#define U5500_GPIOBANK6_BASE (U5500_GPIO4_BASE + 0x80) 100#define U5500_GPIOBANK6_BASE (U5500_GPIO4_BASE + 0x80)
101#define U5500_GPIOBANK7_BASE (U5500_GPIO4_BASE + 0x100) 101#define U5500_GPIOBANK7_BASE (U5500_GPIO4_BASE + 0x100)
102 102
103#define U5500_MBOX_BASE (U5500_MODEM_BASE + 0xFFD1000)
104#define U5500_MBOX0_PEER_START (U5500_MBOX_BASE + 0x40)
105#define U5500_MBOX0_PEER_END (U5500_MBOX_BASE + 0x5F)
106#define U5500_MBOX0_LOCAL_START (U5500_MBOX_BASE + 0x60)
107#define U5500_MBOX0_LOCAL_END (U5500_MBOX_BASE + 0x7F)
108#define U5500_MBOX1_PEER_START (U5500_MBOX_BASE + 0x80)
109#define U5500_MBOX1_PEER_END (U5500_MBOX_BASE + 0x9F)
110#define U5500_MBOX1_LOCAL_START (U5500_MBOX_BASE + 0xA0)
111#define U5500_MBOX1_LOCAL_END (U5500_MBOX_BASE + 0xBF)
112#define U5500_MBOX2_PEER_START (U5500_MBOX_BASE + 0x00)
113#define U5500_MBOX2_PEER_END (U5500_MBOX_BASE + 0x1F)
114#define U5500_MBOX2_LOCAL_START (U5500_MBOX_BASE + 0x20)
115#define U5500_MBOX2_LOCAL_END (U5500_MBOX_BASE + 0x3F)
116
103#endif 117#endif
diff --git a/arch/arm/mach-ux500/include/mach/db8500-regs.h b/arch/arm/mach-ux500/include/mach/db8500-regs.h
index f000218210c9..f07d0986409d 100644
--- a/arch/arm/mach-ux500/include/mach/db8500-regs.h
+++ b/arch/arm/mach-ux500/include/mach/db8500-regs.h
@@ -30,8 +30,6 @@
30#define U8500_ICN_BASE 0x81000000 30#define U8500_ICN_BASE 0x81000000
31 31
32#define U8500_BOOT_ROM_BASE 0x90000000 32#define U8500_BOOT_ROM_BASE 0x90000000
33/* ASIC ID is at 0xff4 offset within this region */
34#define U8500_ASIC_ID_BASE 0x9001F000
35 33
36#define U8500_PER6_BASE 0xa03c0000 34#define U8500_PER6_BASE 0xa03c0000
37#define U8500_PER5_BASE 0xa03e0000 35#define U8500_PER5_BASE 0xa03e0000
diff --git a/arch/arm/mach-ux500/include/mach/debug-macro.S b/arch/arm/mach-ux500/include/mach/debug-macro.S
index c5203b7ea552..be7c0f14e310 100644
--- a/arch/arm/mach-ux500/include/mach/debug-macro.S
+++ b/arch/arm/mach-ux500/include/mach/debug-macro.S
@@ -18,11 +18,9 @@
18#define UX500_UART(n) __UX500_UART(n) 18#define UX500_UART(n) __UX500_UART(n)
19#define UART_BASE UX500_UART(CONFIG_UX500_DEBUG_UART) 19#define UART_BASE UX500_UART(CONFIG_UX500_DEBUG_UART)
20 20
21 .macro addruart, rx, tmp 21 .macro addruart, rp, rv
22 mrc p15, 0, \rx, c1, c0 22 ldr \rp, =UART_BASE @ no, physical address
23 tst \rx, #1 @ MMU enabled? 23 ldr \rv, =IO_ADDRESS(UART_BASE) @ yes, virtual address
24 ldreq \rx, =UART_BASE @ no, physical address
25 ldrne \rx, =IO_ADDRESS(UART_BASE) @ yes, virtual address
26 .endm 24 .endm
27 25
28#include <asm/hardware/debug-pl01x.S> 26#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-ux500/include/mach/devices.h b/arch/arm/mach-ux500/include/mach/devices.h
index c2b2f2574947..b91a4d1211a2 100644
--- a/arch/arm/mach-ux500/include/mach/devices.h
+++ b/arch/arm/mach-ux500/include/mach/devices.h
@@ -26,6 +26,14 @@ extern struct platform_device ux500_i2c3_device;
26extern struct platform_device u8500_i2c0_device; 26extern struct platform_device u8500_i2c0_device;
27extern struct platform_device u8500_i2c4_device; 27extern struct platform_device u8500_i2c4_device;
28extern struct platform_device u8500_dma40_device; 28extern struct platform_device u8500_dma40_device;
29extern struct platform_device ux500_ske_keypad_device;
30
31extern struct amba_device u8500_sdi0_device;
32extern struct amba_device u8500_sdi1_device;
33extern struct amba_device u8500_sdi2_device;
34extern struct amba_device u8500_sdi3_device;
35extern struct amba_device u8500_sdi4_device;
36extern struct amba_device u8500_sdi5_device;
29 37
30void dma40_u8500ed_fixup(void); 38void dma40_u8500ed_fixup(void);
31 39
diff --git a/arch/arm/mach-ux500/include/mach/hardware.h b/arch/arm/mach-ux500/include/mach/hardware.h
index 8656379a8309..32e883a8f2a2 100644
--- a/arch/arm/mach-ux500/include/mach/hardware.h
+++ b/arch/arm/mach-ux500/include/mach/hardware.h
@@ -104,16 +104,35 @@ static inline bool cpu_is_u8500(void)
104#endif 104#endif
105} 105}
106 106
107#define CPUID_DB8500ED 0x410fc090
108#define CPUID_DB8500V1 0x411fc091
109#define CPUID_DB8500V2 0x412fc091
110
107static inline bool cpu_is_u8500ed(void) 111static inline bool cpu_is_u8500ed(void)
108{ 112{
109 return cpu_is_u8500() && (read_cpuid_id() & 15) == 0; 113 return cpu_is_u8500() && (read_cpuid_id() == CPUID_DB8500ED);
110} 114}
111 115
112static inline bool cpu_is_u8500v1(void) 116static inline bool cpu_is_u8500v1(void)
113{ 117{
114 return cpu_is_u8500() && (read_cpuid_id() & 15) == 1; 118 return cpu_is_u8500() && (read_cpuid_id() == CPUID_DB8500V1);
119}
120
121static inline bool cpu_is_u8500v2(void)
122{
123 return cpu_is_u8500() && (read_cpuid_id() == CPUID_DB8500V2);
115} 124}
116 125
126#ifdef CONFIG_UX500_SOC_DB8500
127bool cpu_is_u8500v10(void);
128bool cpu_is_u8500v11(void);
129bool cpu_is_u8500v20(void);
130#else
131static inline bool cpu_is_u8500v10(void) { return false; }
132static inline bool cpu_is_u8500v11(void) { return false; }
133static inline bool cpu_is_u8500v20(void) { return false; }
134#endif
135
117static inline bool cpu_is_u5500(void) 136static inline bool cpu_is_u5500(void)
118{ 137{
119#ifdef CONFIG_UX500_SOC_DB5500 138#ifdef CONFIG_UX500_SOC_DB5500
diff --git a/arch/arm/mach-ux500/include/mach/irqs-db5500.h b/arch/arm/mach-ux500/include/mach/irqs-db5500.h
index 6fbfe5e2065a..bfa123dbec3b 100644
--- a/arch/arm/mach-ux500/include/mach/irqs-db5500.h
+++ b/arch/arm/mach-ux500/include/mach/irqs-db5500.h
@@ -61,6 +61,7 @@
61#define IRQ_DB5500_SDMMC0 (IRQ_SHPI_START + 60) 61#define IRQ_DB5500_SDMMC0 (IRQ_SHPI_START + 60)
62#define IRQ_DB5500_HSEM (IRQ_SHPI_START + 61) 62#define IRQ_DB5500_HSEM (IRQ_SHPI_START + 61)
63#define IRQ_DB5500_SBAG (IRQ_SHPI_START + 63) 63#define IRQ_DB5500_SBAG (IRQ_SHPI_START + 63)
64#define IRQ_DB5500_MODEM (IRQ_SHPI_START + 65)
64#define IRQ_DB5500_SPI1 (IRQ_SHPI_START + 96) 65#define IRQ_DB5500_SPI1 (IRQ_SHPI_START + 96)
65#define IRQ_DB5500_MSP2 (IRQ_SHPI_START + 98) 66#define IRQ_DB5500_MSP2 (IRQ_SHPI_START + 98)
66#define IRQ_DB5500_SRPTIMER (IRQ_SHPI_START + 101) 67#define IRQ_DB5500_SRPTIMER (IRQ_SHPI_START + 101)
diff --git a/arch/arm/mach-ux500/include/mach/irqs.h b/arch/arm/mach-ux500/include/mach/irqs.h
index 10385bdc2b77..693aa57de88d 100644
--- a/arch/arm/mach-ux500/include/mach/irqs.h
+++ b/arch/arm/mach-ux500/include/mach/irqs.h
@@ -40,7 +40,8 @@
40#define IRQ_HSIR_CH1_OVRRUN (IRQ_SHPI_START + 33) 40#define IRQ_HSIR_CH1_OVRRUN (IRQ_SHPI_START + 33)
41#define IRQ_HSIR_CH2_OVRRUN (IRQ_SHPI_START + 34) 41#define IRQ_HSIR_CH2_OVRRUN (IRQ_SHPI_START + 34)
42#define IRQ_HSIR_CH3_OVRRUN (IRQ_SHPI_START + 35) 42#define IRQ_HSIR_CH3_OVRRUN (IRQ_SHPI_START + 35)
43#define IRQ_AB4500 (IRQ_SHPI_START + 40) 43#define IRQ_AB8500 (IRQ_SHPI_START + 40)
44#define IRQ_PRCMU (IRQ_SHPI_START + 47)
44#define IRQ_DISP (IRQ_SHPI_START + 48) 45#define IRQ_DISP (IRQ_SHPI_START + 48)
45#define IRQ_SiPI3 (IRQ_SHPI_START + 49) 46#define IRQ_SiPI3 (IRQ_SHPI_START + 49)
46#define IRQ_I2C4 (IRQ_SHPI_START + 51) 47#define IRQ_I2C4 (IRQ_SHPI_START + 51)
@@ -83,6 +84,19 @@
83#include <mach/irqs-board-mop500.h> 84#include <mach/irqs-board-mop500.h>
84#endif 85#endif
85 86
86#define NR_IRQS IRQ_BOARD_END 87/*
88 * After the board specific IRQ:s we reserve a range of IRQ:s in which virtual
89 * IRQ:s representing modem IRQ:s can be allocated
90 */
91#define IRQ_MODEM_EVENTS_BASE (IRQ_BOARD_END + 1)
92#define IRQ_MODEM_EVENTS_NBR 72
93#define IRQ_MODEM_EVENTS_END (IRQ_MODEM_EVENTS_BASE + IRQ_MODEM_EVENTS_NBR)
94
95/* List of virtual IRQ:s that are allocated from the range above */
96#define MBOX_PAIR0_VIRT_IRQ (IRQ_MODEM_EVENTS_BASE + 43)
97#define MBOX_PAIR1_VIRT_IRQ (IRQ_MODEM_EVENTS_BASE + 45)
98#define MBOX_PAIR2_VIRT_IRQ (IRQ_MODEM_EVENTS_BASE + 41)
99
100#define NR_IRQS IRQ_MODEM_EVENTS_END
87 101
88#endif /* ASM_ARCH_IRQS_H */ 102#endif /* ASM_ARCH_IRQS_H */
diff --git a/arch/arm/mach-ux500/include/mach/mbox.h b/arch/arm/mach-ux500/include/mach/mbox.h
new file mode 100644
index 000000000000..7f9da4d2fbda
--- /dev/null
+++ b/arch/arm/mach-ux500/include/mach/mbox.h
@@ -0,0 +1,88 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Stefan Nilsson <stefan.xk.nilsson@stericsson.com> for ST-Ericsson.
4 * Author: Martin Persson <martin.persson@stericsson.com> for ST-Ericsson.
5 * License terms: GNU General Public License (GPL), version 2.
6 */
7
8#ifndef __INC_STE_MBOX_H
9#define __INC_STE_MBOX_H
10
11#define MBOX_BUF_SIZE 16
12#define MBOX_NAME_SIZE 8
13
14/**
15 * mbox_recv_cb_t - Definition of the mailbox callback.
16 * @mbox_msg: The mailbox message.
17 * @priv: The clients private data as specified in the call to mbox_setup.
18 *
19 * This function will be called upon reception of new mailbox messages.
20 */
21typedef void mbox_recv_cb_t (u32 mbox_msg, void *priv);
22
23/**
24 * struct mbox - Mailbox instance struct
25 * @list: Linked list head.
26 * @pdev: Pointer to device struct.
27 * @cb: Callback function. Will be called
28 * when new data is received.
29 * @client_data: Clients private data. Will be sent back
30 * in the callback function.
31 * @virtbase_peer: Virtual address for outgoing mailbox.
32 * @virtbase_local: Virtual address for incoming mailbox.
33 * @buffer: Then internal queue for outgoing messages.
34 * @name: Name of this mailbox.
35 * @buffer_available: Completion variable to achieve "blocking send".
36 * This variable will be signaled when there is
37 * internal buffer space available.
38 * @client_blocked: To keep track if any client is currently
39 * blocked.
40 * @lock: Spinlock to protect this mailbox instance.
41 * @write_index: Index in internal buffer to write to.
42 * @read_index: Index in internal buffer to read from.
43 * @allocated: Indicates whether this particular mailbox
44 * id has been allocated by someone.
45 */
46struct mbox {
47 struct list_head list;
48 struct platform_device *pdev;
49 mbox_recv_cb_t *cb;
50 void *client_data;
51 void __iomem *virtbase_peer;
52 void __iomem *virtbase_local;
53 u32 buffer[MBOX_BUF_SIZE];
54 char name[MBOX_NAME_SIZE];
55 struct completion buffer_available;
56 u8 client_blocked;
57 spinlock_t lock;
58 u8 write_index;
59 u8 read_index;
60 bool allocated;
61};
62
63/**
64 * mbox_setup - Set up a mailbox and return its instance.
65 * @mbox_id: The ID number of the mailbox. 0 or 1 for modem CPU,
66 * 2 for modem DSP.
67 * @mbox_cb: Pointer to the callback function to be called when a new message
68 * is received.
69 * @priv: Client user data which will be returned in the callback.
70 *
71 * Returns a mailbox instance to be specified in subsequent calls to mbox_send.
72 */
73struct mbox *mbox_setup(u8 mbox_id, mbox_recv_cb_t *mbox_cb, void *priv);
74
75/**
76 * mbox_send - Send a mailbox message.
77 * @mbox: Mailbox instance (returned by mbox_setup)
78 * @mbox_msg: The mailbox message to send.
79 * @block: Specifies whether this call will block until send is possible,
80 * or return an error if the mailbox buffer is full.
81 *
82 * Returns 0 on success or a negative error code on error. -ENOMEM indicates
83 * that the internal buffer is full and you have to try again later (or
84 * specify "block" in order to block until send is possible).
85 */
86int mbox_send(struct mbox *mbox, u32 mbox_msg, bool block);
87
88#endif /*INC_STE_MBOX_H*/
diff --git a/arch/arm/mach-ux500/include/mach/prcmu-regs.h b/arch/arm/mach-ux500/include/mach/prcmu-regs.h
new file mode 100644
index 000000000000..8885f39a6421
--- /dev/null
+++ b/arch/arm/mach-ux500/include/mach/prcmu-regs.h
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) 2009 ST-Ericsson SA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
7 */
8#ifndef __MACH_PRCMU_REGS_H
9#define __MACH_PRCMU_REGS_H
10
11#include <mach/hardware.h>
12
13#define _PRCMU_BASE IO_ADDRESS(U8500_PRCMU_BASE)
14
15#define PRCM_ARM_PLLDIVPS (_PRCMU_BASE + 0x118)
16#define PRCM_ARM_CHGCLKREQ (_PRCMU_BASE + 0x114)
17#define PRCM_PLLARM_ENABLE (_PRCMU_BASE + 0x98)
18#define PRCM_ARMCLKFIX_MGT (_PRCMU_BASE + 0x0)
19#define PRCM_A9_RESETN_CLR (_PRCMU_BASE + 0x1f4)
20#define PRCM_A9_RESETN_SET (_PRCMU_BASE + 0x1f0)
21#define PRCM_ARM_LS_CLAMP (_PRCMU_BASE + 0x30c)
22#define PRCM_SRAM_A9 (_PRCMU_BASE + 0x308)
23
24/* ARM WFI Standby signal register */
25#define PRCM_ARM_WFI_STANDBY (_PRCMU_BASE + 0x130)
26#define PRCMU_IOCR (_PRCMU_BASE + 0x310)
27
28/* CPU mailbox registers */
29#define PRCM_MBOX_CPU_VAL (_PRCMU_BASE + 0x0fc)
30#define PRCM_MBOX_CPU_SET (_PRCMU_BASE + 0x100)
31#define PRCM_MBOX_CPU_CLR (_PRCMU_BASE + 0x104)
32
33/* Dual A9 core interrupt management unit registers */
34#define PRCM_A9_MASK_REQ (_PRCMU_BASE + 0x328)
35#define PRCM_A9_MASK_ACK (_PRCMU_BASE + 0x32c)
36#define PRCM_ARMITMSK31TO0 (_PRCMU_BASE + 0x11c)
37#define PRCM_ARMITMSK63TO32 (_PRCMU_BASE + 0x120)
38#define PRCM_ARMITMSK95TO64 (_PRCMU_BASE + 0x124)
39#define PRCM_ARMITMSK127TO96 (_PRCMU_BASE + 0x128)
40#define PRCM_POWER_STATE_VAL (_PRCMU_BASE + 0x25C)
41#define PRCM_ARMITVAL31TO0 (_PRCMU_BASE + 0x260)
42#define PRCM_ARMITVAL63TO32 (_PRCMU_BASE + 0x264)
43#define PRCM_ARMITVAL95TO64 (_PRCMU_BASE + 0x268)
44#define PRCM_ARMITVAL127TO96 (_PRCMU_BASE + 0x26C)
45
46#define PRCM_HOSTACCESS_REQ (_PRCMU_BASE + 0x334)
47#define ARM_WAKEUP_MODEM 0x1
48
49#define PRCM_ARM_IT1_CLEAR (_PRCMU_BASE + 0x48C)
50#define PRCM_ARM_IT1_VAL (_PRCMU_BASE + 0x494)
51#define PRCM_HOLD_EVT (_PRCMU_BASE + 0x174)
52
53#define PRCM_ITSTATUS0 (_PRCMU_BASE + 0x148)
54#define PRCM_ITSTATUS1 (_PRCMU_BASE + 0x150)
55#define PRCM_ITSTATUS2 (_PRCMU_BASE + 0x158)
56#define PRCM_ITSTATUS3 (_PRCMU_BASE + 0x160)
57#define PRCM_ITSTATUS4 (_PRCMU_BASE + 0x168)
58#define PRCM_ITSTATUS5 (_PRCMU_BASE + 0x484)
59#define PRCM_ITCLEAR5 (_PRCMU_BASE + 0x488)
60#define PRCM_ARMIT_MASKXP70_IT (_PRCMU_BASE + 0x1018)
61
62/* System reset register */
63#define PRCM_APE_SOFTRST (_PRCMU_BASE + 0x228)
64
65/* Level shifter and clamp control registers */
66#define PRCM_MMIP_LS_CLAMP_SET (_PRCMU_BASE + 0x420)
67#define PRCM_MMIP_LS_CLAMP_CLR (_PRCMU_BASE + 0x424)
68
69/* PRCMU clock/PLL/reset registers */
70#define PRCM_PLLDSI_FREQ (_PRCMU_BASE + 0x500)
71#define PRCM_PLLDSI_ENABLE (_PRCMU_BASE + 0x504)
72#define PRCM_LCDCLK_MGT (_PRCMU_BASE + 0x044)
73#define PRCM_MCDECLK_MGT (_PRCMU_BASE + 0x064)
74#define PRCM_HDMICLK_MGT (_PRCMU_BASE + 0x058)
75#define PRCM_TVCLK_MGT (_PRCMU_BASE + 0x07c)
76#define PRCM_DSI_PLLOUT_SEL (_PRCMU_BASE + 0x530)
77#define PRCM_DSITVCLK_DIV (_PRCMU_BASE + 0x52C)
78#define PRCM_APE_RESETN_SET (_PRCMU_BASE + 0x1E4)
79#define PRCM_APE_RESETN_CLR (_PRCMU_BASE + 0x1E8)
80
81/* ePOD and memory power signal control registers */
82#define PRCM_EPOD_C_SET (_PRCMU_BASE + 0x410)
83#define PRCM_SRAM_LS_SLEEP (_PRCMU_BASE + 0x304)
84
85/* Debug power control unit registers */
86#define PRCM_POWER_STATE_SET (_PRCMU_BASE + 0x254)
87
88/* Miscellaneous unit registers */
89#define PRCM_DSI_SW_RESET (_PRCMU_BASE + 0x324)
90
91#endif /* __MACH_PRCMU__REGS_H */
diff --git a/arch/arm/mach-ux500/include/mach/prcmu.h b/arch/arm/mach-ux500/include/mach/prcmu.h
new file mode 100644
index 000000000000..549843ff6dbe
--- /dev/null
+++ b/arch/arm/mach-ux500/include/mach/prcmu.h
@@ -0,0 +1,15 @@
1/*
2 * Copyright (C) STMicroelectronics 2009
3 * Copyright (C) ST-Ericsson SA 2010
4 *
5 * License Terms: GNU General Public License v2
6 *
7 * PRCMU f/w APIs
8 */
9#ifndef __MACH_PRCMU_H
10#define __MACH_PRCMU_H
11
12int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
13int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
14
15#endif /* __MACH_PRCMU_H */
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
index e978dbd9e210..54bbe648bf58 100644
--- a/arch/arm/mach-ux500/include/mach/setup.h
+++ b/arch/arm/mach-ux500/include/mach/setup.h
@@ -38,4 +38,11 @@ extern struct sys_timer ux500_timer;
38 .type = MT_DEVICE, \ 38 .type = MT_DEVICE, \
39} 39}
40 40
41#define __MEM_DEV_DESC(x, sz) { \
42 .virtual = IO_ADDRESS(x), \
43 .pfn = __phys_to_pfn(x), \
44 .length = sz, \
45 .type = MT_MEMORY, \
46}
47
41#endif /* __ASM_ARCH_SETUP_H */ 48#endif /* __ASM_ARCH_SETUP_H */
diff --git a/arch/arm/mach-ux500/include/mach/smp.h b/arch/arm/mach-ux500/include/mach/smp.h
index b59f7bc9725d..197e8417375e 100644
--- a/arch/arm/mach-ux500/include/mach/smp.h
+++ b/arch/arm/mach-ux500/include/mach/smp.h
@@ -10,18 +10,11 @@
10#define ASMARM_ARCH_SMP_H 10#define ASMARM_ARCH_SMP_H
11 11
12#include <asm/hardware/gic.h> 12#include <asm/hardware/gic.h>
13#include <asm/smp_mpidr.h>
13 14
14/* This is required to wakeup the secondary core */ 15/* This is required to wakeup the secondary core */
15extern void u8500_secondary_startup(void); 16extern void u8500_secondary_startup(void);
16 17
17#define hard_smp_processor_id() \
18 ({ \
19 unsigned int cpunum; \
20 __asm__("mrc p15, 0, %0, c0, c0, 5" \
21 : "=r" (cpunum)); \
22 cpunum &= 0x0F; \
23 })
24
25/* 18/*
26 * We use IRQ1 as the IPI 19 * We use IRQ1 as the IPI
27 */ 20 */
diff --git a/arch/arm/mach-ux500/mbox.c b/arch/arm/mach-ux500/mbox.c
new file mode 100644
index 000000000000..63435389c544
--- /dev/null
+++ b/arch/arm/mach-ux500/mbox.c
@@ -0,0 +1,567 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Stefan Nilsson <stefan.xk.nilsson@stericsson.com> for ST-Ericsson.
4 * Author: Martin Persson <martin.persson@stericsson.com> for ST-Ericsson.
5 * License terms: GNU General Public License (GPL), version 2.
6 */
7
8/*
9 * Mailbox nomenclature:
10 *
11 * APE MODEM
12 * mbox pairX
13 * ..........................
14 * . .
15 * . peer .
16 * . send ---- .
17 * . --> | | .
18 * . | | .
19 * . ---- .
20 * . .
21 * . local .
22 * . rec ---- .
23 * . | | <-- .
24 * . | | .
25 * . ---- .
26 * .........................
27 */
28
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/device.h>
32#include <linux/interrupt.h>
33#include <linux/spinlock.h>
34#include <linux/errno.h>
35#include <linux/io.h>
36#include <linux/irq.h>
37#include <linux/platform_device.h>
38#include <linux/debugfs.h>
39#include <linux/seq_file.h>
40#include <linux/completion.h>
41#include <mach/mbox.h>
42
43#define MBOX_NAME "mbox"
44
45#define MBOX_FIFO_DATA 0x000
46#define MBOX_FIFO_ADD 0x004
47#define MBOX_FIFO_REMOVE 0x008
48#define MBOX_FIFO_THRES_FREE 0x00C
49#define MBOX_FIFO_THRES_OCCUP 0x010
50#define MBOX_FIFO_STATUS 0x014
51
52#define MBOX_DISABLE_IRQ 0x4
53#define MBOX_ENABLE_IRQ 0x0
54#define MBOX_LATCH 1
55
56/* Global list of all mailboxes */
57static struct list_head mboxs = LIST_HEAD_INIT(mboxs);
58
59static struct mbox *get_mbox_with_id(u8 id)
60{
61 u8 i;
62 struct list_head *pos = &mboxs;
63 for (i = 0; i <= id; i++)
64 pos = pos->next;
65
66 return (struct mbox *) list_entry(pos, struct mbox, list);
67}
68
69int mbox_send(struct mbox *mbox, u32 mbox_msg, bool block)
70{
71 int res = 0;
72
73 spin_lock(&mbox->lock);
74
75 dev_dbg(&(mbox->pdev->dev),
76 "About to buffer 0x%X to mailbox 0x%X."
77 " ri = %d, wi = %d\n",
78 mbox_msg, (u32)mbox, mbox->read_index,
79 mbox->write_index);
80
81 /* Check if write buffer is full */
82 while (((mbox->write_index + 1) % MBOX_BUF_SIZE) == mbox->read_index) {
83 if (!block) {
84 dev_dbg(&(mbox->pdev->dev),
85 "Buffer full in non-blocking call! "
86 "Returning -ENOMEM!\n");
87 res = -ENOMEM;
88 goto exit;
89 }
90 spin_unlock(&mbox->lock);
91 dev_dbg(&(mbox->pdev->dev),
92 "Buffer full in blocking call! Sleeping...\n");
93 mbox->client_blocked = 1;
94 wait_for_completion(&mbox->buffer_available);
95 dev_dbg(&(mbox->pdev->dev),
96 "Blocking send was woken up! Trying again...\n");
97 spin_lock(&mbox->lock);
98 }
99
100 mbox->buffer[mbox->write_index] = mbox_msg;
101 mbox->write_index = (mbox->write_index + 1) % MBOX_BUF_SIZE;
102
103 /*
104 * Indicate that we want an IRQ as soon as there is a slot
105 * in the FIFO
106 */
107 writel(MBOX_ENABLE_IRQ, mbox->virtbase_peer + MBOX_FIFO_THRES_FREE);
108
109exit:
110 spin_unlock(&mbox->lock);
111 return res;
112}
113EXPORT_SYMBOL(mbox_send);
114
115#if defined(CONFIG_DEBUG_FS)
116/*
117 * Expected input: <value> <nbr sends>
118 * Example: "echo 0xdeadbeef 4 > mbox-node" sends 0xdeadbeef 4 times
119 */
120static ssize_t mbox_write_fifo(struct device *dev,
121 struct device_attribute *attr,
122 const char *buf,
123 size_t count)
124{
125 unsigned long mbox_mess;
126 unsigned long nbr_sends;
127 unsigned long i;
128 char int_buf[16];
129 char *token;
130 char *val;
131
132 struct mbox *mbox = (struct mbox *) dev->platform_data;
133
134 strncpy((char *) &int_buf, buf, sizeof(int_buf));
135 token = (char *) &int_buf;
136
137 /* Parse message */
138 val = strsep(&token, " ");
139 if ((val == NULL) || (strict_strtoul(val, 16, &mbox_mess) != 0))
140 mbox_mess = 0xDEADBEEF;
141
142 val = strsep(&token, " ");
143 if ((val == NULL) || (strict_strtoul(val, 10, &nbr_sends) != 0))
144 nbr_sends = 1;
145
146 dev_dbg(dev, "Will write 0x%lX %ld times using data struct at 0x%X\n",
147 mbox_mess, nbr_sends, (u32) mbox);
148
149 for (i = 0; i < nbr_sends; i++)
150 mbox_send(mbox, mbox_mess, true);
151
152 return count;
153}
154
155static ssize_t mbox_read_fifo(struct device *dev,
156 struct device_attribute *attr,
157 char *buf)
158{
159 int mbox_value;
160 struct mbox *mbox = (struct mbox *) dev->platform_data;
161
162 if ((readl(mbox->virtbase_local + MBOX_FIFO_STATUS) & 0x7) <= 0)
163 return sprintf(buf, "Mailbox is empty\n");
164
165 mbox_value = readl(mbox->virtbase_local + MBOX_FIFO_DATA);
166 writel(MBOX_LATCH, (mbox->virtbase_local + MBOX_FIFO_REMOVE));
167
168 return sprintf(buf, "0x%X\n", mbox_value);
169}
170
171static DEVICE_ATTR(fifo, S_IWUGO | S_IRUGO, mbox_read_fifo, mbox_write_fifo);
172
173static int mbox_show(struct seq_file *s, void *data)
174{
175 struct list_head *pos;
176 u8 mbox_index = 0;
177
178 list_for_each(pos, &mboxs) {
179 struct mbox *m =
180 (struct mbox *) list_entry(pos, struct mbox, list);
181 if (m == NULL) {
182 seq_printf(s,
183 "Unable to retrieve mailbox %d\n",
184 mbox_index);
185 continue;
186 }
187
188 spin_lock(&m->lock);
189 if ((m->virtbase_peer == NULL) || (m->virtbase_local == NULL)) {
190 seq_printf(s, "MAILBOX %d not setup or corrupt\n",
191 mbox_index);
192 spin_unlock(&m->lock);
193 continue;
194 }
195
196 seq_printf(s,
197 "===========================\n"
198 " MAILBOX %d\n"
199 " PEER MAILBOX DUMP\n"
200 "---------------------------\n"
201 "FIFO: 0x%X (%d)\n"
202 "Free Threshold: 0x%.2X (%d)\n"
203 "Occupied Threshold: 0x%.2X (%d)\n"
204 "Status: 0x%.2X (%d)\n"
205 " Free spaces (ot): %d (%d)\n"
206 " Occup spaces (ot): %d (%d)\n"
207 "===========================\n"
208 " LOCAL MAILBOX DUMP\n"
209 "---------------------------\n"
210 "FIFO: 0x%.X (%d)\n"
211 "Free Threshold: 0x%.2X (%d)\n"
212 "Occupied Threshold: 0x%.2X (%d)\n"
213 "Status: 0x%.2X (%d)\n"
214 " Free spaces (ot): %d (%d)\n"
215 " Occup spaces (ot): %d (%d)\n"
216 "===========================\n"
217 "write_index: %d\n"
218 "read_index : %d\n"
219 "===========================\n"
220 "\n",
221 mbox_index,
222 readl(m->virtbase_peer + MBOX_FIFO_DATA),
223 readl(m->virtbase_peer + MBOX_FIFO_DATA),
224 readl(m->virtbase_peer + MBOX_FIFO_THRES_FREE),
225 readl(m->virtbase_peer + MBOX_FIFO_THRES_FREE),
226 readl(m->virtbase_peer + MBOX_FIFO_THRES_OCCUP),
227 readl(m->virtbase_peer + MBOX_FIFO_THRES_OCCUP),
228 readl(m->virtbase_peer + MBOX_FIFO_STATUS),
229 readl(m->virtbase_peer + MBOX_FIFO_STATUS),
230 (readl(m->virtbase_peer + MBOX_FIFO_STATUS) >> 4) & 0x7,
231 (readl(m->virtbase_peer + MBOX_FIFO_STATUS) >> 7) & 0x1,
232 (readl(m->virtbase_peer + MBOX_FIFO_STATUS) >> 0) & 0x7,
233 (readl(m->virtbase_peer + MBOX_FIFO_STATUS) >> 3) & 0x1,
234 readl(m->virtbase_local + MBOX_FIFO_DATA),
235 readl(m->virtbase_local + MBOX_FIFO_DATA),
236 readl(m->virtbase_local + MBOX_FIFO_THRES_FREE),
237 readl(m->virtbase_local + MBOX_FIFO_THRES_FREE),
238 readl(m->virtbase_local + MBOX_FIFO_THRES_OCCUP),
239 readl(m->virtbase_local + MBOX_FIFO_THRES_OCCUP),
240 readl(m->virtbase_local + MBOX_FIFO_STATUS),
241 readl(m->virtbase_local + MBOX_FIFO_STATUS),
242 (readl(m->virtbase_local + MBOX_FIFO_STATUS) >> 4) & 0x7,
243 (readl(m->virtbase_local + MBOX_FIFO_STATUS) >> 7) & 0x1,
244 (readl(m->virtbase_local + MBOX_FIFO_STATUS) >> 0) & 0x7,
245 (readl(m->virtbase_local + MBOX_FIFO_STATUS) >> 3) & 0x1,
246 m->write_index, m->read_index);
247 mbox_index++;
248 spin_unlock(&m->lock);
249 }
250
251 return 0;
252}
253
254static int mbox_open(struct inode *inode, struct file *file)
255{
256 return single_open(file, mbox_show, NULL);
257}
258
259static const struct file_operations mbox_operations = {
260 .owner = THIS_MODULE,
261 .open = mbox_open,
262 .read = seq_read,
263 .llseek = seq_lseek,
264 .release = single_release,
265};
266#endif
267
268static irqreturn_t mbox_irq(int irq, void *arg)
269{
270 u32 mbox_value;
271 int nbr_occup;
272 int nbr_free;
273 struct mbox *mbox = (struct mbox *) arg;
274
275 spin_lock(&mbox->lock);
276
277 dev_dbg(&(mbox->pdev->dev),
278 "mbox IRQ [%d] received. ri = %d, wi = %d\n",
279 irq, mbox->read_index, mbox->write_index);
280
281 /*
282 * Check if we have any outgoing messages, and if there is space for
283 * them in the FIFO.
284 */
285 if (mbox->read_index != mbox->write_index) {
286 /*
287 * Check by reading FREE for LOCAL since that indicates
288 * OCCUP for PEER
289 */
290 nbr_free = (readl(mbox->virtbase_local + MBOX_FIFO_STATUS)
291 >> 4) & 0x7;
292 dev_dbg(&(mbox->pdev->dev),
293 "Status indicates %d empty spaces in the FIFO!\n",
294 nbr_free);
295
296 while ((nbr_free > 0) &&
297 (mbox->read_index != mbox->write_index)) {
298 /* Write the message and latch it into the FIFO */
299 writel(mbox->buffer[mbox->read_index],
300 (mbox->virtbase_peer + MBOX_FIFO_DATA));
301 writel(MBOX_LATCH,
302 (mbox->virtbase_peer + MBOX_FIFO_ADD));
303 dev_dbg(&(mbox->pdev->dev),
304 "Wrote message 0x%X to addr 0x%X\n",
305 mbox->buffer[mbox->read_index],
306 (u32) (mbox->virtbase_peer + MBOX_FIFO_DATA));
307
308 nbr_free--;
309 mbox->read_index =
310 (mbox->read_index + 1) % MBOX_BUF_SIZE;
311 }
312
313 /*
314 * Check if we still want IRQ:s when there is free
315 * space to send
316 */
317 if (mbox->read_index != mbox->write_index) {
318 dev_dbg(&(mbox->pdev->dev),
319 "Still have messages to send, but FIFO full. "
320 "Request IRQ again!\n");
321 writel(MBOX_ENABLE_IRQ,
322 mbox->virtbase_peer + MBOX_FIFO_THRES_FREE);
323 } else {
324 dev_dbg(&(mbox->pdev->dev),
325 "No more messages to send. "
326 "Do not request IRQ again!\n");
327 writel(MBOX_DISABLE_IRQ,
328 mbox->virtbase_peer + MBOX_FIFO_THRES_FREE);
329 }
330
331 /*
332 * Check if we can signal any blocked clients that it is OK to
333 * start buffering again
334 */
335 if (mbox->client_blocked &&
336 (((mbox->write_index + 1) % MBOX_BUF_SIZE)
337 != mbox->read_index)) {
338 dev_dbg(&(mbox->pdev->dev),
339 "Waking up blocked client\n");
340 complete(&mbox->buffer_available);
341 mbox->client_blocked = 0;
342 }
343 }
344
345 /* Check if we have any incoming messages */
346 nbr_occup = readl(mbox->virtbase_local + MBOX_FIFO_STATUS) & 0x7;
347 if (nbr_occup == 0)
348 goto exit;
349
350 if (mbox->cb == NULL) {
351 dev_dbg(&(mbox->pdev->dev), "No receive callback registered, "
352 "leaving %d incoming messages in fifo!\n", nbr_occup);
353 goto exit;
354 }
355
356 /* Read and acknowledge the message */
357 mbox_value = readl(mbox->virtbase_local + MBOX_FIFO_DATA);
358 writel(MBOX_LATCH, (mbox->virtbase_local + MBOX_FIFO_REMOVE));
359
360 /* Notify consumer of new mailbox message */
361 dev_dbg(&(mbox->pdev->dev), "Calling callback for message 0x%X!\n",
362 mbox_value);
363 mbox->cb(mbox_value, mbox->client_data);
364
365exit:
366 dev_dbg(&(mbox->pdev->dev), "Exit mbox IRQ. ri = %d, wi = %d\n",
367 mbox->read_index, mbox->write_index);
368 spin_unlock(&mbox->lock);
369
370 return IRQ_HANDLED;
371}
372
373/* Setup is executed once for each mbox pair */
374struct mbox *mbox_setup(u8 mbox_id, mbox_recv_cb_t *mbox_cb, void *priv)
375{
376 struct resource *resource;
377 int irq;
378 int res;
379 struct mbox *mbox;
380
381 mbox = get_mbox_with_id(mbox_id);
382 if (mbox == NULL) {
383 dev_err(&(mbox->pdev->dev), "Incorrect mailbox id: %d!\n",
384 mbox_id);
385 goto exit;
386 }
387
388 /*
389 * Check if mailbox has been allocated to someone else,
390 * otherwise allocate it
391 */
392 if (mbox->allocated) {
393 dev_err(&(mbox->pdev->dev), "Mailbox number %d is busy!\n",
394 mbox_id);
395 mbox = NULL;
396 goto exit;
397 }
398 mbox->allocated = true;
399
400 dev_dbg(&(mbox->pdev->dev), "Initiating mailbox number %d: 0x%X...\n",
401 mbox_id, (u32)mbox);
402
403 mbox->client_data = priv;
404 mbox->cb = mbox_cb;
405
406 /* Get addr for peer mailbox and ioremap it */
407 resource = platform_get_resource_byname(mbox->pdev,
408 IORESOURCE_MEM,
409 "mbox_peer");
410 if (resource == NULL) {
411 dev_err(&(mbox->pdev->dev),
412 "Unable to retrieve mbox peer resource\n");
413 mbox = NULL;
414 goto exit;
415 }
416 dev_dbg(&(mbox->pdev->dev),
417 "Resource name: %s start: 0x%X, end: 0x%X\n",
418 resource->name, resource->start, resource->end);
419 mbox->virtbase_peer =
420 ioremap(resource->start, resource->end - resource->start);
421 if (!mbox->virtbase_peer) {
422 dev_err(&(mbox->pdev->dev), "Unable to ioremap peer mbox\n");
423 mbox = NULL;
424 goto exit;
425 }
426 dev_dbg(&(mbox->pdev->dev),
427 "ioremapped peer physical: (0x%X-0x%X) to virtual: 0x%X\n",
428 resource->start, resource->end, (u32) mbox->virtbase_peer);
429
430 /* Get addr for local mailbox and ioremap it */
431 resource = platform_get_resource_byname(mbox->pdev,
432 IORESOURCE_MEM,
433 "mbox_local");
434 if (resource == NULL) {
435 dev_err(&(mbox->pdev->dev),
436 "Unable to retrieve mbox local resource\n");
437 mbox = NULL;
438 goto exit;
439 }
440 dev_dbg(&(mbox->pdev->dev),
441 "Resource name: %s start: 0x%X, end: 0x%X\n",
442 resource->name, resource->start, resource->end);
443 mbox->virtbase_local =
444 ioremap(resource->start, resource->end - resource->start);
445 if (!mbox->virtbase_local) {
446 dev_err(&(mbox->pdev->dev), "Unable to ioremap local mbox\n");
447 mbox = NULL;
448 goto exit;
449 }
450 dev_dbg(&(mbox->pdev->dev),
451 "ioremapped local physical: (0x%X-0x%X) to virtual: 0x%X\n",
452 resource->start, resource->end, (u32) mbox->virtbase_peer);
453
454 init_completion(&mbox->buffer_available);
455 mbox->client_blocked = 0;
456
457 /* Get IRQ for mailbox and allocate it */
458 irq = platform_get_irq_byname(mbox->pdev, "mbox_irq");
459 if (irq < 0) {
460 dev_err(&(mbox->pdev->dev),
461 "Unable to retrieve mbox irq resource\n");
462 mbox = NULL;
463 goto exit;
464 }
465
466 dev_dbg(&(mbox->pdev->dev), "Allocating irq %d...\n", irq);
467 res = request_irq(irq, mbox_irq, 0, mbox->name, (void *) mbox);
468 if (res < 0) {
469 dev_err(&(mbox->pdev->dev),
470 "Unable to allocate mbox irq %d\n", irq);
471 mbox = NULL;
472 goto exit;
473 }
474
475 /* Set up mailbox to not launch IRQ on free space in mailbox */
476 writel(MBOX_DISABLE_IRQ, mbox->virtbase_peer + MBOX_FIFO_THRES_FREE);
477
478 /*
479 * Set up mailbox to launch IRQ on new message if we have
480 * a callback set. If not, do not raise IRQ, but keep message
481 * in FIFO for manual retrieval
482 */
483 if (mbox_cb != NULL)
484 writel(MBOX_ENABLE_IRQ,
485 mbox->virtbase_local + MBOX_FIFO_THRES_OCCUP);
486 else
487 writel(MBOX_DISABLE_IRQ,
488 mbox->virtbase_local + MBOX_FIFO_THRES_OCCUP);
489
490#if defined(CONFIG_DEBUG_FS)
491 res = device_create_file(&(mbox->pdev->dev), &dev_attr_fifo);
492 if (res != 0)
493 dev_warn(&(mbox->pdev->dev),
494 "Unable to create mbox sysfs entry");
495
496 (void) debugfs_create_file("mbox", S_IFREG | S_IRUGO, NULL,
497 NULL, &mbox_operations);
498#endif
499
500 dev_info(&(mbox->pdev->dev),
501 "Mailbox driver with index %d initated!\n", mbox_id);
502
503exit:
504 return mbox;
505}
506EXPORT_SYMBOL(mbox_setup);
507
508
509int __init mbox_probe(struct platform_device *pdev)
510{
511 struct mbox local_mbox;
512 struct mbox *mbox;
513 int res = 0;
514 dev_dbg(&(pdev->dev), "Probing mailbox (pdev = 0x%X)...\n", (u32) pdev);
515
516 memset(&local_mbox, 0x0, sizeof(struct mbox));
517
518 /* Associate our mbox data with the platform device */
519 res = platform_device_add_data(pdev,
520 (void *) &local_mbox,
521 sizeof(struct mbox));
522 if (res != 0) {
523 dev_err(&(pdev->dev),
524 "Unable to allocate driver platform data!\n");
525 goto exit;
526 }
527
528 mbox = (struct mbox *) pdev->dev.platform_data;
529 mbox->pdev = pdev;
530 mbox->write_index = 0;
531 mbox->read_index = 0;
532
533 INIT_LIST_HEAD(&(mbox->list));
534 list_add_tail(&(mbox->list), &mboxs);
535
536 sprintf(mbox->name, "%s", MBOX_NAME);
537 spin_lock_init(&mbox->lock);
538
539 dev_info(&(pdev->dev), "Mailbox driver loaded\n");
540
541exit:
542 return res;
543}
544
545static struct platform_driver mbox_driver = {
546 .driver = {
547 .name = MBOX_NAME,
548 .owner = THIS_MODULE,
549 },
550};
551
552static int __init mbox_init(void)
553{
554 return platform_driver_probe(&mbox_driver, mbox_probe);
555}
556
557module_init(mbox_init);
558
559void __exit mbox_exit(void)
560{
561 platform_driver_unregister(&mbox_driver);
562}
563
564module_exit(mbox_exit);
565
566MODULE_LICENSE("GPL");
567MODULE_DESCRIPTION("MBOX driver");
diff --git a/arch/arm/mach-ux500/modem_irq.c b/arch/arm/mach-ux500/modem_irq.c
new file mode 100644
index 000000000000..3187f8871169
--- /dev/null
+++ b/arch/arm/mach-ux500/modem_irq.c
@@ -0,0 +1,139 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Stefan Nilsson <stefan.xk.nilsson@stericsson.com> for ST-Ericsson.
4 * Author: Martin Persson <martin.persson@stericsson.com> for ST-Ericsson.
5 * License terms: GNU General Public License (GPL), version 2.
6 */
7
8#include <linux/module.h>
9#include <linux/kernel.h>
10#include <linux/irq.h>
11#include <linux/interrupt.h>
12#include <linux/io.h>
13#include <linux/slab.h>
14
15#define MODEM_INTCON_BASE_ADDR 0xBFFD3000
16#define MODEM_INTCON_SIZE 0xFFF
17
18#define DEST_IRQ41_OFFSET 0x2A4
19#define DEST_IRQ43_OFFSET 0x2AC
20#define DEST_IRQ45_OFFSET 0x2B4
21
22#define PRIO_IRQ41_OFFSET 0x6A4
23#define PRIO_IRQ43_OFFSET 0x6AC
24#define PRIO_IRQ45_OFFSET 0x6B4
25
26#define ALLOW_IRQ_OFFSET 0x104
27
28#define MODEM_INTCON_CPU_NBR 0x1
29#define MODEM_INTCON_PRIO_HIGH 0x0
30
31#define MODEM_INTCON_ALLOW_IRQ41 0x0200
32#define MODEM_INTCON_ALLOW_IRQ43 0x0800
33#define MODEM_INTCON_ALLOW_IRQ45 0x2000
34
35#define MODEM_IRQ_REG_OFFSET 0x4
36
37struct modem_irq {
38 void __iomem *modem_intcon_base;
39};
40
41
42static void setup_modem_intcon(void __iomem *modem_intcon_base)
43{
44 /* IC_DESTINATION_BASE_ARRAY - Which CPU to receive the IRQ */
45 writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ41_OFFSET);
46 writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ43_OFFSET);
47 writel(MODEM_INTCON_CPU_NBR, modem_intcon_base + DEST_IRQ45_OFFSET);
48
49 /* IC_PRIORITY_BASE_ARRAY - IRQ priority in modem IRQ controller */
50 writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ41_OFFSET);
51 writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ43_OFFSET);
52 writel(MODEM_INTCON_PRIO_HIGH, modem_intcon_base + PRIO_IRQ45_OFFSET);
53
54 /* IC_ALLOW_ARRAY - IRQ enable */
55 writel(MODEM_INTCON_ALLOW_IRQ41 |
56 MODEM_INTCON_ALLOW_IRQ43 |
57 MODEM_INTCON_ALLOW_IRQ45,
58 modem_intcon_base + ALLOW_IRQ_OFFSET);
59}
60
61static irqreturn_t modem_cpu_irq_handler(int irq, void *data)
62{
63 int real_irq;
64 int virt_irq;
65 struct modem_irq *mi = (struct modem_irq *)data;
66
67 /* Read modem side IRQ number from modem IRQ controller */
68 real_irq = readl(mi->modem_intcon_base + MODEM_IRQ_REG_OFFSET) & 0xFF;
69 virt_irq = IRQ_MODEM_EVENTS_BASE + real_irq;
70
71 pr_debug("modem_irq: Worker read addr 0x%X and got value 0x%X "
72 "which will be 0x%X (%d) which translates to "
73 "virtual IRQ 0x%X (%d)!\n",
74 (u32)mi->modem_intcon_base + MODEM_IRQ_REG_OFFSET,
75 real_irq,
76 real_irq & 0xFF,
77 real_irq & 0xFF,
78 virt_irq,
79 virt_irq);
80
81 if (virt_irq != 0)
82 generic_handle_irq(virt_irq);
83
84 pr_debug("modem_irq: Done handling virtual IRQ %d!\n", virt_irq);
85
86 return IRQ_HANDLED;
87}
88
89static void create_virtual_irq(int irq, struct irq_chip *modem_irq_chip)
90{
91 set_irq_chip(irq, modem_irq_chip);
92 set_irq_handler(irq, handle_simple_irq);
93 set_irq_flags(irq, IRQF_VALID);
94
95 pr_debug("modem_irq: Created virtual IRQ %d\n", irq);
96}
97
98static int modem_irq_init(void)
99{
100 int err;
101 static struct irq_chip modem_irq_chip;
102 struct modem_irq *mi;
103
104 pr_info("modem_irq: Set up IRQ handler for incoming modem IRQ %d\n",
105 IRQ_DB5500_MODEM);
106
107 mi = kmalloc(sizeof(struct modem_irq), GFP_KERNEL);
108 if (!mi) {
109 pr_err("modem_irq: Could not allocate device\n");
110 return -ENOMEM;
111 }
112
113 mi->modem_intcon_base =
114 ioremap(MODEM_INTCON_BASE_ADDR, MODEM_INTCON_SIZE);
115 pr_debug("modem_irq: ioremapped modem_intcon_base from "
116 "phy 0x%x to virt 0x%x\n", MODEM_INTCON_BASE_ADDR,
117 (u32)mi->modem_intcon_base);
118
119 setup_modem_intcon(mi->modem_intcon_base);
120
121 modem_irq_chip = dummy_irq_chip;
122 modem_irq_chip.name = "modem_irq";
123
124 /* Create the virtual IRQ:s needed */
125 create_virtual_irq(MBOX_PAIR0_VIRT_IRQ, &modem_irq_chip);
126 create_virtual_irq(MBOX_PAIR1_VIRT_IRQ, &modem_irq_chip);
127 create_virtual_irq(MBOX_PAIR2_VIRT_IRQ, &modem_irq_chip);
128
129 err = request_threaded_irq(IRQ_DB5500_MODEM, NULL,
130 modem_cpu_irq_handler, IRQF_ONESHOT,
131 "modem_irq", mi);
132 if (err)
133 pr_err("modem_irq: Could not register IRQ %d\n",
134 IRQ_DB5500_MODEM);
135
136 return 0;
137}
138
139arch_initcall(modem_irq_init);
diff --git a/arch/arm/mach-ux500/pins-db5500.h b/arch/arm/mach-ux500/pins-db5500.h
new file mode 100644
index 000000000000..bf50c21fe69d
--- /dev/null
+++ b/arch/arm/mach-ux500/pins-db5500.h
@@ -0,0 +1,620 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License terms: GNU General Public License, version 2
5 * Author: Rabin Vincent <rabin.vincent@stericsson.com>
6 */
7
8#ifndef __MACH_DB5500_PINS_H
9#define __MACH_DB5500_PINS_H
10
11#define GPIO0_GPIO PIN_CFG(0, GPIO)
12#define GPIO0_SM_CS3n PIN_CFG(0, ALT_A)
13
14#define GPIO1_GPIO PIN_CFG(1, GPIO)
15#define GPIO1_SM_A3 PIN_CFG(1, ALT_A)
16
17#define GPIO2_GPIO PIN_CFG(2, GPIO)
18#define GPIO2_SM_A4 PIN_CFG(2, ALT_A)
19#define GPIO2_SM_AVD PIN_CFG(2, ALT_B)
20
21#define GPIO3_GPIO PIN_CFG(3, GPIO)
22#define GPIO3_I2C1_SCL PIN_CFG(3, ALT_A)
23
24#define GPIO4_GPIO PIN_CFG(4, GPIO)
25#define GPIO4_I2C1_SDA PIN_CFG(4, ALT_A)
26
27#define GPIO5_GPIO PIN_CFG(5, GPIO)
28#define GPIO5_MC0_DAT0 PIN_CFG(5, ALT_A)
29#define GPIO5_SM_ADQ8 PIN_CFG(5, ALT_B)
30
31#define GPIO6_GPIO PIN_CFG(6, GPIO)
32#define GPIO6_MC0_DAT1 PIN_CFG(6, ALT_A)
33#define GPIO6_SM_ADQ0 PIN_CFG(6, ALT_B)
34
35#define GPIO7_GPIO PIN_CFG(7, GPIO)
36#define GPIO7_MC0_DAT2 PIN_CFG(7, ALT_A)
37#define GPIO7_SM_ADQ9 PIN_CFG(7, ALT_B)
38
39#define GPIO8_GPIO PIN_CFG(8, GPIO)
40#define GPIO8_MC0_DAT3 PIN_CFG(8, ALT_A)
41#define GPIO8_SM_ADQ1 PIN_CFG(8, ALT_B)
42
43#define GPIO9_GPIO PIN_CFG(9, GPIO)
44#define GPIO9_MC0_DAT4 PIN_CFG(9, ALT_A)
45#define GPIO9_SM_ADQ10 PIN_CFG(9, ALT_B)
46
47#define GPIO10_GPIO PIN_CFG(10, GPIO)
48#define GPIO10_MC0_DAT5 PIN_CFG(10, ALT_A)
49#define GPIO10_SM_ADQ2 PIN_CFG(10, ALT_B)
50
51#define GPIO11_GPIO PIN_CFG(11, GPIO)
52#define GPIO11_MC0_DAT6 PIN_CFG(11, ALT_A)
53#define GPIO11_SM_ADQ11 PIN_CFG(11, ALT_B)
54
55#define GPIO12_GPIO PIN_CFG(12, GPIO)
56#define GPIO12_MC0_DAT7 PIN_CFG(12, ALT_A)
57#define GPIO12_SM_ADQ3 PIN_CFG(12, ALT_B)
58
59#define GPIO13_GPIO PIN_CFG(13, GPIO)
60#define GPIO13_MC0_CMD PIN_CFG(13, ALT_A)
61#define GPIO13_SM_BUSY0n PIN_CFG(13, ALT_B)
62#define GPIO13_SM_WAIT0n PIN_CFG(13, ALT_C)
63
64#define GPIO14_GPIO PIN_CFG(14, GPIO)
65#define GPIO14_MC0_CLK PIN_CFG(14, ALT_A)
66#define GPIO14_SM_CS1n PIN_CFG(14, ALT_B)
67#define GPIO14_SM_CKO PIN_CFG(14, ALT_C)
68
69#define GPIO15_GPIO PIN_CFG(15, GPIO)
70#define GPIO15_SM_A5 PIN_CFG(15, ALT_A)
71#define GPIO15_SM_CLE PIN_CFG(15, ALT_B)
72
73#define GPIO16_GPIO PIN_CFG(16, GPIO)
74#define GPIO16_MC2_CMD PIN_CFG(16, ALT_A)
75#define GPIO16_SM_OEn PIN_CFG(16, ALT_B)
76
77#define GPIO17_GPIO PIN_CFG(17, GPIO)
78#define GPIO17_MC2_CLK PIN_CFG(17, ALT_A)
79#define GPIO17_SM_WEn PIN_CFG(17, ALT_B)
80
81#define GPIO18_GPIO PIN_CFG(18, GPIO)
82#define GPIO18_SM_A6 PIN_CFG(18, ALT_A)
83#define GPIO18_SM_ALE PIN_CFG(18, ALT_B)
84#define GPIO18_SM_AVDn PIN_CFG(18, ALT_C)
85
86#define GPIO19_GPIO PIN_CFG(19, GPIO)
87#define GPIO19_MC2_DAT1 PIN_CFG(19, ALT_A)
88#define GPIO19_SM_ADQ4 PIN_CFG(19, ALT_B)
89
90#define GPIO20_GPIO PIN_CFG(20, GPIO)
91#define GPIO20_MC2_DAT3 PIN_CFG(20, ALT_A)
92#define GPIO20_SM_ADQ5 PIN_CFG(20, ALT_B)
93
94#define GPIO21_GPIO PIN_CFG(21, GPIO)
95#define GPIO21_MC2_DAT5 PIN_CFG(21, ALT_A)
96#define GPIO21_SM_ADQ6 PIN_CFG(21, ALT_B)
97
98#define GPIO22_GPIO PIN_CFG(22, GPIO)
99#define GPIO22_MC2_DAT7 PIN_CFG(22, ALT_A)
100#define GPIO22_SM_ADQ7 PIN_CFG(22, ALT_B)
101
102#define GPIO23_GPIO PIN_CFG(23, GPIO)
103#define GPIO23_MC2_DAT0 PIN_CFG(23, ALT_A)
104#define GPIO23_SM_ADQ12 PIN_CFG(23, ALT_B)
105#define GPIO23_MC0_DAT1 PIN_CFG(23, ALT_C)
106
107#define GPIO24_GPIO PIN_CFG(24, GPIO)
108#define GPIO24_MC2_DAT2 PIN_CFG(24, ALT_A)
109#define GPIO24_SM_ADQ13 PIN_CFG(24, ALT_B)
110#define GPIO24_MC0_DAT3 PIN_CFG(24, ALT_C)
111
112#define GPIO25_GPIO PIN_CFG(25, GPIO)
113#define GPIO25_MC2_DAT4 PIN_CFG(25, ALT_A)
114#define GPIO25_SM_ADQ14 PIN_CFG(25, ALT_B)
115#define GPIO25_MC0_CMD PIN_CFG(25, ALT_C)
116
117#define GPIO26_GPIO PIN_CFG(26, GPIO)
118#define GPIO26_MC2_DAT6 PIN_CFG(26, ALT_A)
119#define GPIO26_SM_ADQ15 PIN_CFG(26, ALT_B)
120
121#define GPIO27_GPIO PIN_CFG(27, GPIO)
122#define GPIO27_SM_CS0n PIN_CFG(27, ALT_A)
123#define GPIO27_SM_PS0n PIN_CFG(27, ALT_B)
124
125#define GPIO28_GPIO PIN_CFG(28, GPIO)
126#define GPIO28_U0_TXD PIN_CFG(28, ALT_A)
127#define GPIO28_SM_A0 PIN_CFG(28, ALT_B)
128
129#define GPIO29_GPIO PIN_CFG(29, GPIO)
130#define GPIO29_U0_RXD PIN_CFG(29, ALT_A)
131#define GPIO29_SM_A1 PIN_CFG(29, ALT_B)
132#define GPIO29_PWM_0 PIN_CFG(29, ALT_C)
133
134#define GPIO30_GPIO PIN_CFG(30, GPIO)
135#define GPIO30_MC0_DAT5 PIN_CFG(30, ALT_A)
136#define GPIO30_SM_A2 PIN_CFG(30, ALT_B)
137#define GPIO30_PWM_1 PIN_CFG(30, ALT_C)
138
139#define GPIO31_GPIO PIN_CFG(31, GPIO)
140#define GPIO31_MC0_DAT7 PIN_CFG(31, ALT_A)
141#define GPIO31_SM_CS2n PIN_CFG(31, ALT_B)
142#define GPIO31_PWM_2 PIN_CFG(31, ALT_C)
143
144#define GPIO32_GPIO PIN_CFG(32, GPIO)
145#define GPIO32_MSP0_TCK PIN_CFG(32, ALT_A)
146#define GPIO32_ACCI2S0_SCK PIN_CFG(32, ALT_B)
147
148#define GPIO33_GPIO PIN_CFG(33, GPIO)
149#define GPIO33_MSP0_TFS PIN_CFG(33, ALT_A)
150#define GPIO33_ACCI2S0_WS PIN_CFG(33, ALT_B)
151
152#define GPIO34_GPIO PIN_CFG(34, GPIO)
153#define GPIO34_MSP0_TXD PIN_CFG(34, ALT_A)
154#define GPIO34_ACCI2S0_DLD PIN_CFG(34, ALT_B)
155
156#define GPIO35_GPIO PIN_CFG(35, GPIO)
157#define GPIO35_MSP0_RXD PIN_CFG(35, ALT_A)
158#define GPIO35_ACCI2S0_ULD PIN_CFG(35, ALT_B)
159
160#define GPIO64_GPIO PIN_CFG(64, GPIO)
161#define GPIO64_USB_DAT0 PIN_CFG(64, ALT_A)
162#define GPIO64_U0_TXD PIN_CFG(64, ALT_B)
163
164#define GPIO65_GPIO PIN_CFG(65, GPIO)
165#define GPIO65_USB_DAT1 PIN_CFG(65, ALT_A)
166#define GPIO65_U0_RXD PIN_CFG(65, ALT_B)
167
168#define GPIO66_GPIO PIN_CFG(66, GPIO)
169#define GPIO66_USB_DAT2 PIN_CFG(66, ALT_A)
170
171#define GPIO67_GPIO PIN_CFG(67, GPIO)
172#define GPIO67_USB_DAT3 PIN_CFG(67, ALT_A)
173
174#define GPIO68_GPIO PIN_CFG(68, GPIO)
175#define GPIO68_USB_DAT4 PIN_CFG(68, ALT_A)
176
177#define GPIO69_GPIO PIN_CFG(69, GPIO)
178#define GPIO69_USB_DAT5 PIN_CFG(69, ALT_A)
179
180#define GPIO70_GPIO PIN_CFG(70, GPIO)
181#define GPIO70_USB_DAT6 PIN_CFG(70, ALT_A)
182
183#define GPIO71_GPIO PIN_CFG(71, GPIO)
184#define GPIO71_USB_DAT7 PIN_CFG(71, ALT_A)
185
186#define GPIO72_GPIO PIN_CFG(72, GPIO)
187#define GPIO72_USB_STP PIN_CFG(72, ALT_A)
188
189#define GPIO73_GPIO PIN_CFG(73, GPIO)
190#define GPIO73_USB_DIR PIN_CFG(73, ALT_A)
191
192#define GPIO74_GPIO PIN_CFG(74, GPIO)
193#define GPIO74_USB_NXT PIN_CFG(74, ALT_A)
194
195#define GPIO75_GPIO PIN_CFG(75, GPIO)
196#define GPIO75_USB_XCLK PIN_CFG(75, ALT_A)
197
198#define GPIO76_GPIO PIN_CFG(76, GPIO)
199
200#define GPIO77_GPIO PIN_CFG(77, GPIO)
201#define GPIO77_ACCTX_ON PIN_CFG(77, ALT_A)
202
203#define GPIO78_GPIO PIN_CFG(78, GPIO)
204#define GPIO78_IRQn PIN_CFG(78, ALT_A)
205
206#define GPIO79_GPIO PIN_CFG(79, GPIO)
207#define GPIO79_ACCSIM_Clk PIN_CFG(79, ALT_A)
208
209#define GPIO80_GPIO PIN_CFG(80, GPIO)
210#define GPIO80_ACCSIM_Da PIN_CFG(80, ALT_A)
211
212#define GPIO81_GPIO PIN_CFG(81, GPIO)
213#define GPIO81_ACCSIM_Reset PIN_CFG(81, ALT_A)
214
215#define GPIO82_GPIO PIN_CFG(82, GPIO)
216#define GPIO82_ACCSIM_DDir PIN_CFG(82, ALT_A)
217
218#define GPIO96_GPIO PIN_CFG(96, GPIO)
219#define GPIO96_MSP1_TCK PIN_CFG(96, ALT_A)
220#define GPIO96_PRCMU_DEBUG3 PIN_CFG(96, ALT_B)
221#define GPIO96_PRCMU_DEBUG7 PIN_CFG(96, ALT_C)
222
223#define GPIO97_GPIO PIN_CFG(97, GPIO)
224#define GPIO97_MSP1_TFS PIN_CFG(97, ALT_A)
225#define GPIO97_PRCMU_DEBUG2 PIN_CFG(97, ALT_B)
226#define GPIO97_PRCMU_DEBUG6 PIN_CFG(97, ALT_C)
227
228#define GPIO98_GPIO PIN_CFG(98, GPIO)
229#define GPIO98_MSP1_TXD PIN_CFG(98, ALT_A)
230#define GPIO98_PRCMU_DEBUG1 PIN_CFG(98, ALT_B)
231#define GPIO98_PRCMU_DEBUG5 PIN_CFG(98, ALT_C)
232
233#define GPIO99_GPIO PIN_CFG(99, GPIO)
234#define GPIO99_MSP1_RXD PIN_CFG(99, ALT_A)
235#define GPIO99_PRCMU_DEBUG0 PIN_CFG(99, ALT_B)
236#define GPIO99_PRCMU_DEBUG4 PIN_CFG(99, ALT_C)
237
238#define GPIO100_GPIO PIN_CFG(100, GPIO)
239#define GPIO100_I2C0_SCL PIN_CFG(100, ALT_A)
240
241#define GPIO101_GPIO PIN_CFG(101, GPIO)
242#define GPIO101_I2C0_SDA PIN_CFG(101, ALT_A)
243
244#define GPIO128_GPIO PIN_CFG(128, GPIO)
245#define GPIO128_KP_I0 PIN_CFG(128, ALT_A)
246#define GPIO128_BUSMON_D0 PIN_CFG(128, ALT_B)
247
248#define GPIO129_GPIO PIN_CFG(129, GPIO)
249#define GPIO129_KP_O0 PIN_CFG(129, ALT_A)
250#define GPIO129_BUSMON_D1 PIN_CFG(129, ALT_B)
251
252#define GPIO130_GPIO PIN_CFG(130, GPIO)
253#define GPIO130_KP_I1 PIN_CFG(130, ALT_A)
254#define GPIO130_BUSMON_D2 PIN_CFG(130, ALT_B)
255
256#define GPIO131_GPIO PIN_CFG(131, GPIO)
257#define GPIO131_KP_O1 PIN_CFG(131, ALT_A)
258#define GPIO131_BUSMON_D3 PIN_CFG(131, ALT_B)
259
260#define GPIO132_GPIO PIN_CFG(132, GPIO)
261#define GPIO132_KP_I2 PIN_CFG(132, ALT_A)
262#define GPIO132_ETM_D15 PIN_CFG(132, ALT_B)
263#define GPIO132_STMAPE_CLK PIN_CFG(132, ALT_C)
264
265#define GPIO133_GPIO PIN_CFG(133, GPIO)
266#define GPIO133_KP_O2 PIN_CFG(133, ALT_A)
267#define GPIO133_ETM_D14 PIN_CFG(133, ALT_B)
268#define GPIO133_U0_RXD PIN_CFG(133, ALT_C)
269
270#define GPIO134_GPIO PIN_CFG(134, GPIO)
271#define GPIO134_KP_I3 PIN_CFG(134, ALT_A)
272#define GPIO134_ETM_D13 PIN_CFG(134, ALT_B)
273#define GPIO134_STMAPE_DAT0 PIN_CFG(134, ALT_C)
274
275#define GPIO135_GPIO PIN_CFG(135, GPIO)
276#define GPIO135_KP_O3 PIN_CFG(135, ALT_A)
277#define GPIO135_ETM_D12 PIN_CFG(135, ALT_B)
278#define GPIO135_STMAPE_DAT1 PIN_CFG(135, ALT_C)
279
280#define GPIO136_GPIO PIN_CFG(136, GPIO)
281#define GPIO136_KP_I4 PIN_CFG(136, ALT_A)
282#define GPIO136_ETM_D11 PIN_CFG(136, ALT_B)
283#define GPIO136_STMAPE_DAT2 PIN_CFG(136, ALT_C)
284
285#define GPIO137_GPIO PIN_CFG(137, GPIO)
286#define GPIO137_KP_O4 PIN_CFG(137, ALT_A)
287#define GPIO137_ETM_D10 PIN_CFG(137, ALT_B)
288#define GPIO137_STMAPE_DAT3 PIN_CFG(137, ALT_C)
289
290#define GPIO138_GPIO PIN_CFG(138, GPIO)
291#define GPIO138_KP_I5 PIN_CFG(138, ALT_A)
292#define GPIO138_ETM_D9 PIN_CFG(138, ALT_B)
293#define GPIO138_U0_TXD PIN_CFG(138, ALT_C)
294
295#define GPIO139_GPIO PIN_CFG(139, GPIO)
296#define GPIO139_KP_O5 PIN_CFG(139, ALT_A)
297#define GPIO139_ETM_D8 PIN_CFG(139, ALT_B)
298#define GPIO139_BUSMON_D11 PIN_CFG(139, ALT_C)
299
300#define GPIO140_GPIO PIN_CFG(140, GPIO)
301#define GPIO140_KP_I6 PIN_CFG(140, ALT_A)
302#define GPIO140_ETM_D7 PIN_CFG(140, ALT_B)
303#define GPIO140_STMAPE_CLK PIN_CFG(140, ALT_C)
304
305#define GPIO141_GPIO PIN_CFG(141, GPIO)
306#define GPIO141_KP_O6 PIN_CFG(141, ALT_A)
307#define GPIO141_ETM_D6 PIN_CFG(141, ALT_B)
308#define GPIO141_U0_RXD PIN_CFG(141, ALT_C)
309
310#define GPIO142_GPIO PIN_CFG(142, GPIO)
311#define GPIO142_KP_I7 PIN_CFG(142, ALT_A)
312#define GPIO142_ETM_D5 PIN_CFG(142, ALT_B)
313#define GPIO142_STMAPE_DAT0 PIN_CFG(142, ALT_C)
314
315#define GPIO143_GPIO PIN_CFG(143, GPIO)
316#define GPIO143_KP_O7 PIN_CFG(143, ALT_A)
317#define GPIO143_ETM_D4 PIN_CFG(143, ALT_B)
318#define GPIO143_STMAPE_DAT1 PIN_CFG(143, ALT_C)
319
320#define GPIO144_GPIO PIN_CFG(144, GPIO)
321#define GPIO144_I2C3_SCL PIN_CFG(144, ALT_A)
322#define GPIO144_ETM_D3 PIN_CFG(144, ALT_B)
323#define GPIO144_STMAPE_DAT2 PIN_CFG(144, ALT_C)
324
325#define GPIO145_GPIO PIN_CFG(145, GPIO)
326#define GPIO145_I2C3_SDA PIN_CFG(145, ALT_A)
327#define GPIO145_ETM_D2 PIN_CFG(145, ALT_B)
328#define GPIO145_STMAPE_DAT3 PIN_CFG(145, ALT_C)
329
330#define GPIO146_GPIO PIN_CFG(146, GPIO)
331#define GPIO146_PWM_0 PIN_CFG(146, ALT_A)
332#define GPIO146_ETM_D1 PIN_CFG(146, ALT_B)
333
334#define GPIO147_GPIO PIN_CFG(147, GPIO)
335#define GPIO147_PWM_1 PIN_CFG(147, ALT_A)
336#define GPIO147_ETM_D0 PIN_CFG(147, ALT_B)
337
338#define GPIO148_GPIO PIN_CFG(148, GPIO)
339#define GPIO148_PWM_2 PIN_CFG(148, ALT_A)
340#define GPIO148_ETM_CLK PIN_CFG(148, ALT_B)
341
342#define GPIO160_GPIO PIN_CFG(160, GPIO)
343#define GPIO160_CLKOUT_REQn PIN_CFG(160, ALT_A)
344
345#define GPIO161_GPIO PIN_CFG(161, GPIO)
346#define GPIO161_CLKOUT_0 PIN_CFG(161, ALT_A)
347
348#define GPIO162_GPIO PIN_CFG(162, GPIO)
349#define GPIO162_CLKOUT_1 PIN_CFG(162, ALT_A)
350
351#define GPIO163_GPIO PIN_CFG(163, GPIO)
352
353#define GPIO164_GPIO PIN_CFG(164, GPIO)
354#define GPIO164_GPS_START PIN_CFG(164, ALT_A)
355
356#define GPIO165_GPIO PIN_CFG(165, GPIO)
357#define GPIO165_SPI1_CS2n PIN_CFG(165, ALT_A)
358#define GPIO165_U3_RXD PIN_CFG(165, ALT_B)
359#define GPIO165_BUSMON_D20 PIN_CFG(165, ALT_C)
360
361#define GPIO166_GPIO PIN_CFG(166, GPIO)
362#define GPIO166_SPI1_CS1n PIN_CFG(166, ALT_A)
363#define GPIO166_U3_TXD PIN_CFG(166, ALT_B)
364#define GPIO166_BUSMON_D21 PIN_CFG(166, ALT_C)
365
366#define GPIO167_GPIO PIN_CFG(167, GPIO)
367#define GPIO167_SPI1_CS0n PIN_CFG(167, ALT_A)
368#define GPIO167_U3_RTSn PIN_CFG(167, ALT_B)
369#define GPIO167_BUSMON_D22 PIN_CFG(167, ALT_C)
370
371#define GPIO168_GPIO PIN_CFG(168, GPIO)
372#define GPIO168_SPI1_RXD PIN_CFG(168, ALT_A)
373#define GPIO168_U3_CTSn PIN_CFG(168, ALT_B)
374#define GPIO168_BUSMON_D23 PIN_CFG(168, ALT_C)
375
376#define GPIO169_GPIO PIN_CFG(169, GPIO)
377#define GPIO169_SPI1_TXD PIN_CFG(169, ALT_A)
378#define GPIO169_DDR_RC PIN_CFG(169, ALT_B)
379#define GPIO169_BUSMON_D24 PIN_CFG(169, ALT_C)
380
381#define GPIO170_GPIO PIN_CFG(170, GPIO)
382#define GPIO170_SPI1_CLK PIN_CFG(170, ALT_A)
383
384#define GPIO171_GPIO PIN_CFG(171, GPIO)
385#define GPIO171_MC3_DAT0 PIN_CFG(171, ALT_A)
386#define GPIO171_SPI3_RXD PIN_CFG(171, ALT_B)
387#define GPIO171_BUSMON_D25 PIN_CFG(171, ALT_C)
388
389#define GPIO172_GPIO PIN_CFG(172, GPIO)
390#define GPIO172_MC3_DAT1 PIN_CFG(172, ALT_A)
391#define GPIO172_SPI3_CS1n PIN_CFG(172, ALT_B)
392#define GPIO172_BUSMON_D26 PIN_CFG(172, ALT_C)
393
394#define GPIO173_GPIO PIN_CFG(173, GPIO)
395#define GPIO173_MC3_DAT2 PIN_CFG(173, ALT_A)
396#define GPIO173_SPI3_CS2n PIN_CFG(173, ALT_B)
397#define GPIO173_BUSMON_D27 PIN_CFG(173, ALT_C)
398
399#define GPIO174_GPIO PIN_CFG(174, GPIO)
400#define GPIO174_MC3_DAT3 PIN_CFG(174, ALT_A)
401#define GPIO174_SPI3_CS0n PIN_CFG(174, ALT_B)
402#define GPIO174_BUSMON_D28 PIN_CFG(174, ALT_C)
403
404#define GPIO175_GPIO PIN_CFG(175, GPIO)
405#define GPIO175_MC3_CMD PIN_CFG(175, ALT_A)
406#define GPIO175_SPI3_TXD PIN_CFG(175, ALT_B)
407#define GPIO175_BUSMON_D29 PIN_CFG(175, ALT_C)
408
409#define GPIO176_GPIO PIN_CFG(176, GPIO)
410#define GPIO176_MC3_CLK PIN_CFG(176, ALT_A)
411#define GPIO176_SPI3_CLK PIN_CFG(176, ALT_B)
412
413#define GPIO177_GPIO PIN_CFG(177, GPIO)
414#define GPIO177_U2_RXD PIN_CFG(177, ALT_A)
415#define GPIO177_I2C3_SCL PIN_CFG(177, ALT_B)
416#define GPIO177_BUSMON_D30 PIN_CFG(177, ALT_C)
417
418#define GPIO178_GPIO PIN_CFG(178, GPIO)
419#define GPIO178_U2_TXD PIN_CFG(178, ALT_A)
420#define GPIO178_I2C3_SDA PIN_CFG(178, ALT_B)
421#define GPIO178_BUSMON_D31 PIN_CFG(178, ALT_C)
422
423#define GPIO179_GPIO PIN_CFG(179, GPIO)
424#define GPIO179_U2_CTSn PIN_CFG(179, ALT_A)
425#define GPIO179_U3_RXD PIN_CFG(179, ALT_B)
426#define GPIO179_BUSMON_D32 PIN_CFG(179, ALT_C)
427
428#define GPIO180_GPIO PIN_CFG(180, GPIO)
429#define GPIO180_U2_RTSn PIN_CFG(180, ALT_A)
430#define GPIO180_U3_TXD PIN_CFG(180, ALT_B)
431#define GPIO180_BUSMON_D33 PIN_CFG(180, ALT_C)
432
433#define GPIO185_GPIO PIN_CFG(185, GPIO)
434#define GPIO185_SPI3_CS2n PIN_CFG(185, ALT_A)
435#define GPIO185_MC4_DAT0 PIN_CFG(185, ALT_B)
436
437#define GPIO186_GPIO PIN_CFG(186, GPIO)
438#define GPIO186_SPI3_CS1n PIN_CFG(186, ALT_A)
439#define GPIO186_MC4_DAT1 PIN_CFG(186, ALT_B)
440
441#define GPIO187_GPIO PIN_CFG(187, GPIO)
442#define GPIO187_SPI3_CS0n PIN_CFG(187, ALT_A)
443#define GPIO187_MC4_DAT2 PIN_CFG(187, ALT_B)
444
445#define GPIO188_GPIO PIN_CFG(188, GPIO)
446#define GPIO188_SPI3_RXD PIN_CFG(188, ALT_A)
447#define GPIO188_MC4_DAT3 PIN_CFG(188, ALT_B)
448
449#define GPIO189_GPIO PIN_CFG(189, GPIO)
450#define GPIO189_SPI3_TXD PIN_CFG(189, ALT_A)
451#define GPIO189_MC4_CMD PIN_CFG(189, ALT_B)
452
453#define GPIO190_GPIO PIN_CFG(190, GPIO)
454#define GPIO190_SPI3_CLK PIN_CFG(190, ALT_A)
455#define GPIO190_MC4_CLK PIN_CFG(190, ALT_B)
456
457#define GPIO191_GPIO PIN_CFG(191, GPIO)
458#define GPIO191_MC1_DAT0 PIN_CFG(191, ALT_A)
459#define GPIO191_MC4_DAT4 PIN_CFG(191, ALT_B)
460#define GPIO191_STMAPE_DAT0 PIN_CFG(191, ALT_C)
461
462#define GPIO192_GPIO PIN_CFG(192, GPIO)
463#define GPIO192_MC1_DAT1 PIN_CFG(192, ALT_A)
464#define GPIO192_MC4_DAT5 PIN_CFG(192, ALT_B)
465#define GPIO192_STMAPE_DAT1 PIN_CFG(192, ALT_C)
466
467#define GPIO193_GPIO PIN_CFG(193, GPIO)
468#define GPIO193_MC1_DAT2 PIN_CFG(193, ALT_A)
469#define GPIO193_MC4_DAT6 PIN_CFG(193, ALT_B)
470#define GPIO193_STMAPE_DAT2 PIN_CFG(193, ALT_C)
471
472#define GPIO194_GPIO PIN_CFG(194, GPIO)
473#define GPIO194_MC1_DAT3 PIN_CFG(194, ALT_A)
474#define GPIO194_MC4_DAT7 PIN_CFG(194, ALT_B)
475#define GPIO194_STMAPE_DAT3 PIN_CFG(194, ALT_C)
476
477#define GPIO195_GPIO PIN_CFG(195, GPIO)
478#define GPIO195_MC1_CLK PIN_CFG(195, ALT_A)
479#define GPIO195_STMAPE_CLK PIN_CFG(195, ALT_B)
480#define GPIO195_BUSMON_CLK PIN_CFG(195, ALT_C)
481
482#define GPIO196_GPIO PIN_CFG(196, GPIO)
483#define GPIO196_MC1_CMD PIN_CFG(196, ALT_A)
484#define GPIO196_U0_RXD PIN_CFG(196, ALT_B)
485#define GPIO196_BUSMON_D38 PIN_CFG(196, ALT_C)
486
487#define GPIO197_GPIO PIN_CFG(197, GPIO)
488#define GPIO197_MC1_CMDDIR PIN_CFG(197, ALT_A)
489#define GPIO197_BUSMON_D39 PIN_CFG(197, ALT_B)
490
491#define GPIO198_GPIO PIN_CFG(198, GPIO)
492#define GPIO198_MC1_FBCLK PIN_CFG(198, ALT_A)
493
494#define GPIO199_GPIO PIN_CFG(199, GPIO)
495#define GPIO199_MC1_DAT0DIR PIN_CFG(199, ALT_A)
496#define GPIO199_BUSMON_D40 PIN_CFG(199, ALT_B)
497
498#define GPIO200_GPIO PIN_CFG(200, GPIO)
499#define GPIO200_U1_TXD PIN_CFG(200, ALT_A)
500#define GPIO200_ACCU0_RTSn PIN_CFG(200, ALT_B)
501
502#define GPIO201_GPIO PIN_CFG(201, GPIO)
503#define GPIO201_U1_RXD PIN_CFG(201, ALT_A)
504#define GPIO201_ACCU0_CTSn PIN_CFG(201, ALT_B)
505
506#define GPIO202_GPIO PIN_CFG(202, GPIO)
507#define GPIO202_U1_CTSn PIN_CFG(202, ALT_A)
508#define GPIO202_ACCU0_RXD PIN_CFG(202, ALT_B)
509
510#define GPIO203_GPIO PIN_CFG(203, GPIO)
511#define GPIO203_U1_RTSn PIN_CFG(203, ALT_A)
512#define GPIO203_ACCU0_TXD PIN_CFG(203, ALT_B)
513
514#define GPIO204_GPIO PIN_CFG(204, GPIO)
515#define GPIO204_SPI0_CS2n PIN_CFG(204, ALT_A)
516#define GPIO204_ACCGPIO_000 PIN_CFG(204, ALT_B)
517#define GPIO204_LCD_VSI1 PIN_CFG(204, ALT_C)
518
519#define GPIO205_GPIO PIN_CFG(205, GPIO)
520#define GPIO205_SPI0_CS1n PIN_CFG(205, ALT_A)
521#define GPIO205_ACCGPIO_001 PIN_CFG(205, ALT_B)
522#define GPIO205_LCD_D3 PIN_CFG(205, ALT_C)
523
524#define GPIO206_GPIO PIN_CFG(206, GPIO)
525#define GPIO206_SPI0_CS0n PIN_CFG(206, ALT_A)
526#define GPIO206_ACCGPIO_002 PIN_CFG(206, ALT_B)
527#define GPIO206_LCD_D2 PIN_CFG(206, ALT_C)
528
529#define GPIO207_GPIO PIN_CFG(207, GPIO)
530#define GPIO207_SPI0_RXD PIN_CFG(207, ALT_A)
531#define GPIO207_ACCGPIO_003 PIN_CFG(207, ALT_B)
532#define GPIO207_LCD_D1 PIN_CFG(207, ALT_C)
533
534#define GPIO208_GPIO PIN_CFG(208, GPIO)
535#define GPIO208_SPI0_TXD PIN_CFG(208, ALT_A)
536#define GPIO208_ACCGPIO_004 PIN_CFG(208, ALT_B)
537#define GPIO208_LCD_D0 PIN_CFG(208, ALT_C)
538
539#define GPIO209_GPIO PIN_CFG(209, GPIO)
540#define GPIO209_SPI0_CLK PIN_CFG(209, ALT_A)
541#define GPIO209_ACCGPIO_005 PIN_CFG(209, ALT_B)
542#define GPIO209_LCD_CLK PIN_CFG(209, ALT_C)
543
544#define GPIO210_GPIO PIN_CFG(210, GPIO)
545#define GPIO210_LCD_VSO PIN_CFG(210, ALT_A)
546#define GPIO210_PRCMU_PWRCTRL1 PIN_CFG(210, ALT_B)
547
548#define GPIO211_GPIO PIN_CFG(211, GPIO)
549#define GPIO211_LCD_VSI0 PIN_CFG(211, ALT_A)
550#define GPIO211_PRCMU_PWRCTRL2 PIN_CFG(211, ALT_B)
551
552#define GPIO212_GPIO PIN_CFG(212, GPIO)
553#define GPIO212_SPI2_CS2n PIN_CFG(212, ALT_A)
554#define GPIO212_LCD_HSO PIN_CFG(212, ALT_B)
555
556#define GPIO213_GPIO PIN_CFG(213, GPIO)
557#define GPIO213_SPI2_CS1n PIN_CFG(213, ALT_A)
558#define GPIO213_LCD_DE PIN_CFG(213, ALT_B)
559#define GPIO213_BUSMON_D16 PIN_CFG(213, ALT_C)
560
561#define GPIO214_GPIO PIN_CFG(214, GPIO)
562#define GPIO214_SPI2_CS0n PIN_CFG(214, ALT_A)
563#define GPIO214_LCD_D7 PIN_CFG(214, ALT_B)
564#define GPIO214_BUSMON_D17 PIN_CFG(214, ALT_C)
565
566#define GPIO215_GPIO PIN_CFG(215, GPIO)
567#define GPIO215_SPI2_RXD PIN_CFG(215, ALT_A)
568#define GPIO215_LCD_D6 PIN_CFG(215, ALT_B)
569#define GPIO215_BUSMON_D18 PIN_CFG(215, ALT_C)
570
571#define GPIO216_GPIO PIN_CFG(216, GPIO)
572#define GPIO216_SPI2_CLK PIN_CFG(216, ALT_A)
573#define GPIO216_LCD_D5 PIN_CFG(216, ALT_B)
574
575#define GPIO217_GPIO PIN_CFG(217, GPIO)
576#define GPIO217_SPI2_TXD PIN_CFG(217, ALT_A)
577#define GPIO217_LCD_D4 PIN_CFG(217, ALT_B)
578#define GPIO217_BUSMON_D19 PIN_CFG(217, ALT_C)
579
580#define GPIO218_GPIO PIN_CFG(218, GPIO)
581#define GPIO218_I2C2_SCL PIN_CFG(218, ALT_A)
582#define GPIO218_LCD_VSO PIN_CFG(218, ALT_B)
583
584#define GPIO219_GPIO PIN_CFG(219, GPIO)
585#define GPIO219_I2C2_SDA PIN_CFG(219, ALT_A)
586#define GPIO219_LCD_D3 PIN_CFG(219, ALT_B)
587
588#define GPIO220_GPIO PIN_CFG(220, GPIO)
589#define GPIO220_MSP2_TCK PIN_CFG(220, ALT_A)
590#define GPIO220_LCD_D2 PIN_CFG(220, ALT_B)
591
592#define GPIO221_GPIO PIN_CFG(221, GPIO)
593#define GPIO221_MSP2_TFS PIN_CFG(221, ALT_A)
594#define GPIO221_LCD_D1 PIN_CFG(221, ALT_B)
595
596#define GPIO222_GPIO PIN_CFG(222, GPIO)
597#define GPIO222_MSP2_TXD PIN_CFG(222, ALT_A)
598#define GPIO222_LCD_D0 PIN_CFG(222, ALT_B)
599
600#define GPIO223_GPIO PIN_CFG(223, GPIO)
601#define GPIO223_MSP2_RXD PIN_CFG(223, ALT_A)
602#define GPIO223_LCD_CLK PIN_CFG(223, ALT_B)
603
604#define GPIO224_GPIO PIN_CFG(224, GPIO)
605#define GPIO224_PRCMU_PWRCTRL0 PIN_CFG(224, ALT_A)
606#define GPIO224_LCD_VSI1 PIN_CFG(224, ALT_B)
607
608#define GPIO225_GPIO PIN_CFG(225, GPIO)
609#define GPIO225_PRCMU_PWRCTRL1 PIN_CFG(225, ALT_A)
610#define GPIO225_IRDA_RXD PIN_CFG(225, ALT_B)
611
612#define GPIO226_GPIO PIN_CFG(226, GPIO)
613#define GPIO226_PRCMU_PWRCTRL2 PIN_CFG(226, ALT_A)
614#define GPIO226_IRRC_DAT PIN_CFG(226, ALT_B)
615
616#define GPIO227_GPIO PIN_CFG(227, GPIO)
617#define GPIO227_IRRC_DAT PIN_CFG(227, ALT_A)
618#define GPIO227_IRDA_TXD PIN_CFG(227, ALT_B)
619
620#endif
diff --git a/arch/arm/mach-ux500/pins-db8500.h b/arch/arm/mach-ux500/pins-db8500.h
index 9055d5d3233c..f923764ee16c 100644
--- a/arch/arm/mach-ux500/pins-db8500.h
+++ b/arch/arm/mach-ux500/pins-db8500.h
@@ -96,57 +96,57 @@
96#define GPIO17_SLIM0_CLK PIN_CFG(17, ALT_C) 96#define GPIO17_SLIM0_CLK PIN_CFG(17, ALT_C)
97 97
98#define GPIO18_GPIO PIN_CFG(18, GPIO) 98#define GPIO18_GPIO PIN_CFG(18, GPIO)
99#define GPIO18_MC0_CMDDIR PIN_CFG(18, ALT_A) 99#define GPIO18_MC0_CMDDIR PIN_CFG_PULL(18, ALT_A, UP)
100#define GPIO18_U2_RXD PIN_CFG(18, ALT_B) 100#define GPIO18_U2_RXD PIN_CFG(18, ALT_B)
101#define GPIO18_MS_IEP PIN_CFG(18, ALT_C) 101#define GPIO18_MS_IEP PIN_CFG(18, ALT_C)
102 102
103#define GPIO19_GPIO PIN_CFG(19, GPIO) 103#define GPIO19_GPIO PIN_CFG(19, GPIO)
104#define GPIO19_MC0_DAT0DIR PIN_CFG(19, ALT_A) 104#define GPIO19_MC0_DAT0DIR PIN_CFG_PULL(19, ALT_A, UP)
105#define GPIO19_U2_TXD PIN_CFG(19, ALT_B) 105#define GPIO19_U2_TXD PIN_CFG(19, ALT_B)
106#define GPIO19_MS_DAT0DIR PIN_CFG(19, ALT_C) 106#define GPIO19_MS_DAT0DIR PIN_CFG(19, ALT_C)
107 107
108#define GPIO20_GPIO PIN_CFG(20, GPIO) 108#define GPIO20_GPIO PIN_CFG(20, GPIO)
109#define GPIO20_MC0_DAT2DIR PIN_CFG(20, ALT_A) 109#define GPIO20_MC0_DAT2DIR PIN_CFG_PULL(20, ALT_A, UP)
110#define GPIO20_UARTMOD_TXD PIN_CFG(20, ALT_B) 110#define GPIO20_UARTMOD_TXD PIN_CFG(20, ALT_B)
111#define GPIO20_IP_TRIGOUT PIN_CFG(20, ALT_C) 111#define GPIO20_IP_TRIGOUT PIN_CFG(20, ALT_C)
112 112
113#define GPIO21_GPIO PIN_CFG(21, GPIO) 113#define GPIO21_GPIO PIN_CFG(21, GPIO)
114#define GPIO21_MC0_DAT31DIR PIN_CFG(21, ALT_A) 114#define GPIO21_MC0_DAT31DIR PIN_CFG_PULL(21, ALT_A, UP)
115#define GPIO21_MSP0_SCK PIN_CFG(21, ALT_B) 115#define GPIO21_MSP0_SCK PIN_CFG(21, ALT_B)
116#define GPIO21_MS_DAT31DIR PIN_CFG(21, ALT_C) 116#define GPIO21_MS_DAT31DIR PIN_CFG(21, ALT_C)
117 117
118#define GPIO22_GPIO PIN_CFG(22, GPIO) 118#define GPIO22_GPIO PIN_CFG(22, GPIO)
119#define GPIO22_MC0_FBCLK PIN_CFG(22, ALT_A) 119#define GPIO22_MC0_FBCLK PIN_CFG_PULL(22, ALT_A, UP)
120#define GPIO22_UARTMOD_RXD PIN_CFG(22, ALT_B) 120#define GPIO22_UARTMOD_RXD PIN_CFG(22, ALT_B)
121#define GPIO22_MS_FBCLK PIN_CFG(22, ALT_C) 121#define GPIO22_MS_FBCLK PIN_CFG(22, ALT_C)
122 122
123#define GPIO23_GPIO PIN_CFG(23, GPIO) 123#define GPIO23_GPIO PIN_CFG(23, GPIO)
124#define GPIO23_MC0_CLK PIN_CFG(23, ALT_A) 124#define GPIO23_MC0_CLK PIN_CFG_PULL(23, ALT_A, UP)
125#define GPIO23_STMMOD_CLK PIN_CFG(23, ALT_B) 125#define GPIO23_STMMOD_CLK PIN_CFG(23, ALT_B)
126#define GPIO23_MS_CLK PIN_CFG(23, ALT_C) 126#define GPIO23_MS_CLK PIN_CFG(23, ALT_C)
127 127
128#define GPIO24_GPIO PIN_CFG(24, GPIO) 128#define GPIO24_GPIO PIN_CFG(24, GPIO)
129#define GPIO24_MC0_CMD PIN_CFG(24, ALT_A) 129#define GPIO24_MC0_CMD PIN_CFG_PULL(24, ALT_A, UP)
130#define GPIO24_UARTMOD_RXD PIN_CFG(24, ALT_B) 130#define GPIO24_UARTMOD_RXD PIN_CFG(24, ALT_B)
131#define GPIO24_MS_BS PIN_CFG(24, ALT_C) 131#define GPIO24_MS_BS PIN_CFG(24, ALT_C)
132 132
133#define GPIO25_GPIO PIN_CFG(25, GPIO) 133#define GPIO25_GPIO PIN_CFG(25, GPIO)
134#define GPIO25_MC0_DAT0 PIN_CFG(25, ALT_A) 134#define GPIO25_MC0_DAT0 PIN_CFG_PULL(25, ALT_A, UP)
135#define GPIO25_STMMOD_DAT0 PIN_CFG(25, ALT_B) 135#define GPIO25_STMMOD_DAT0 PIN_CFG(25, ALT_B)
136#define GPIO25_MS_DAT0 PIN_CFG(25, ALT_C) 136#define GPIO25_MS_DAT0 PIN_CFG(25, ALT_C)
137 137
138#define GPIO26_GPIO PIN_CFG(26, GPIO) 138#define GPIO26_GPIO PIN_CFG(26, GPIO)
139#define GPIO26_MC0_DAT1 PIN_CFG(26, ALT_A) 139#define GPIO26_MC0_DAT1 PIN_CFG_PULL(26, ALT_A, UP)
140#define GPIO26_STMMOD_DAT1 PIN_CFG(26, ALT_B) 140#define GPIO26_STMMOD_DAT1 PIN_CFG(26, ALT_B)
141#define GPIO26_MS_DAT1 PIN_CFG(26, ALT_C) 141#define GPIO26_MS_DAT1 PIN_CFG(26, ALT_C)
142 142
143#define GPIO27_GPIO PIN_CFG(27, GPIO) 143#define GPIO27_GPIO PIN_CFG(27, GPIO)
144#define GPIO27_MC0_DAT2 PIN_CFG(27, ALT_A) 144#define GPIO27_MC0_DAT2 PIN_CFG_PULL(27, ALT_A, UP)
145#define GPIO27_STMMOD_DAT2 PIN_CFG(27, ALT_B) 145#define GPIO27_STMMOD_DAT2 PIN_CFG(27, ALT_B)
146#define GPIO27_MS_DAT2 PIN_CFG(27, ALT_C) 146#define GPIO27_MS_DAT2 PIN_CFG(27, ALT_C)
147 147
148#define GPIO28_GPIO PIN_CFG(28, GPIO) 148#define GPIO28_GPIO PIN_CFG(28, GPIO)
149#define GPIO28_MC0_DAT3 PIN_CFG(28, ALT_A) 149#define GPIO28_MC0_DAT3 PIN_CFG_PULL(28, ALT_A, UP)
150#define GPIO28_STMMOD_DAT3 PIN_CFG(28, ALT_B) 150#define GPIO28_STMMOD_DAT3 PIN_CFG(28, ALT_B)
151#define GPIO28_MS_DAT3 PIN_CFG(28, ALT_C) 151#define GPIO28_MS_DAT3 PIN_CFG(28, ALT_C)
152 152
@@ -357,48 +357,48 @@
357#define GPIO97_MC5_DAT7 PIN_CFG(97, ALT_C) 357#define GPIO97_MC5_DAT7 PIN_CFG(97, ALT_C)
358 358
359#define GPIO128_GPIO PIN_CFG(128, GPIO) 359#define GPIO128_GPIO PIN_CFG(128, GPIO)
360#define GPIO128_MC2_CLK PIN_CFG(128, ALT_A) 360#define GPIO128_MC2_CLK PIN_CFG_PULL(128, ALT_A, UP)
361#define GPIO128_SM_CKO PIN_CFG(128, ALT_B) 361#define GPIO128_SM_CKO PIN_CFG(128, ALT_B)
362 362
363#define GPIO129_GPIO PIN_CFG(129, GPIO) 363#define GPIO129_GPIO PIN_CFG(129, GPIO)
364#define GPIO129_MC2_CMD PIN_CFG(129, ALT_A) 364#define GPIO129_MC2_CMD PIN_CFG_PULL(129, ALT_A, UP)
365#define GPIO129_SM_WAIT0n PIN_CFG(129, ALT_B) 365#define GPIO129_SM_WAIT0n PIN_CFG(129, ALT_B)
366 366
367#define GPIO130_GPIO PIN_CFG(130, GPIO) 367#define GPIO130_GPIO PIN_CFG(130, GPIO)
368#define GPIO130_MC2_FBCLK PIN_CFG(130, ALT_A) 368#define GPIO130_MC2_FBCLK PIN_CFG_PULL(130, ALT_A, UP)
369#define GPIO130_SM_FBCLK PIN_CFG(130, ALT_B) 369#define GPIO130_SM_FBCLK PIN_CFG(130, ALT_B)
370#define GPIO130_MC2_RSTN PIN_CFG(130, ALT_C) 370#define GPIO130_MC2_RSTN PIN_CFG(130, ALT_C)
371 371
372#define GPIO131_GPIO PIN_CFG(131, GPIO) 372#define GPIO131_GPIO PIN_CFG(131, GPIO)
373#define GPIO131_MC2_DAT0 PIN_CFG(131, ALT_A) 373#define GPIO131_MC2_DAT0 PIN_CFG_PULL(131, ALT_A, UP)
374#define GPIO131_SM_ADQ8 PIN_CFG(131, ALT_B) 374#define GPIO131_SM_ADQ8 PIN_CFG(131, ALT_B)
375 375
376#define GPIO132_GPIO PIN_CFG(132, GPIO) 376#define GPIO132_GPIO PIN_CFG(132, GPIO)
377#define GPIO132_MC2_DAT1 PIN_CFG(132, ALT_A) 377#define GPIO132_MC2_DAT1 PIN_CFG_PULL(132, ALT_A, UP)
378#define GPIO132_SM_ADQ9 PIN_CFG(132, ALT_B) 378#define GPIO132_SM_ADQ9 PIN_CFG(132, ALT_B)
379 379
380#define GPIO133_GPIO PIN_CFG(133, GPIO) 380#define GPIO133_GPIO PIN_CFG(133, GPIO)
381#define GPIO133_MC2_DAT2 PIN_CFG(133, ALT_A) 381#define GPIO133_MC2_DAT2 PIN_CFG_PULL(133, ALT_A, UP)
382#define GPIO133_SM_ADQ10 PIN_CFG(133, ALT_B) 382#define GPIO133_SM_ADQ10 PIN_CFG(133, ALT_B)
383 383
384#define GPIO134_GPIO PIN_CFG(134, GPIO) 384#define GPIO134_GPIO PIN_CFG(134, GPIO)
385#define GPIO134_MC2_DAT3 PIN_CFG(134, ALT_A) 385#define GPIO134_MC2_DAT3 PIN_CFG_PULL(134, ALT_A, UP)
386#define GPIO134_SM_ADQ11 PIN_CFG(134, ALT_B) 386#define GPIO134_SM_ADQ11 PIN_CFG(134, ALT_B)
387 387
388#define GPIO135_GPIO PIN_CFG(135, GPIO) 388#define GPIO135_GPIO PIN_CFG(135, GPIO)
389#define GPIO135_MC2_DAT4 PIN_CFG(135, ALT_A) 389#define GPIO135_MC2_DAT4 PIN_CFG_PULL(135, ALT_A, UP)
390#define GPIO135_SM_ADQ12 PIN_CFG(135, ALT_B) 390#define GPIO135_SM_ADQ12 PIN_CFG(135, ALT_B)
391 391
392#define GPIO136_GPIO PIN_CFG(136, GPIO) 392#define GPIO136_GPIO PIN_CFG(136, GPIO)
393#define GPIO136_MC2_DAT5 PIN_CFG(136, ALT_A) 393#define GPIO136_MC2_DAT5 PIN_CFG_PULL(136, ALT_A, UP)
394#define GPIO136_SM_ADQ13 PIN_CFG(136, ALT_B) 394#define GPIO136_SM_ADQ13 PIN_CFG(136, ALT_B)
395 395
396#define GPIO137_GPIO PIN_CFG(137, GPIO) 396#define GPIO137_GPIO PIN_CFG(137, GPIO)
397#define GPIO137_MC2_DAT6 PIN_CFG(137, ALT_A) 397#define GPIO137_MC2_DAT6 PIN_CFG_PULL(137, ALT_A, UP)
398#define GPIO137_SM_ADQ14 PIN_CFG(137, ALT_B) 398#define GPIO137_SM_ADQ14 PIN_CFG(137, ALT_B)
399 399
400#define GPIO138_GPIO PIN_CFG(138, GPIO) 400#define GPIO138_GPIO PIN_CFG(138, GPIO)
401#define GPIO138_MC2_DAT7 PIN_CFG(138, ALT_A) 401#define GPIO138_MC2_DAT7 PIN_CFG_PULL(138, ALT_A, UP)
402#define GPIO138_SM_ADQ15 PIN_CFG(138, ALT_B) 402#define GPIO138_SM_ADQ15 PIN_CFG(138, ALT_B)
403 403
404#define GPIO139_GPIO PIN_CFG(139, GPIO) 404#define GPIO139_GPIO PIN_CFG(139, GPIO)
@@ -459,82 +459,82 @@
459#define GPIO152_KP_O9 PIN_CFG(152, ALT_C) 459#define GPIO152_KP_O9 PIN_CFG(152, ALT_C)
460 460
461#define GPIO153_GPIO PIN_CFG(153, GPIO) 461#define GPIO153_GPIO PIN_CFG(153, GPIO)
462#define GPIO153_KP_I7 PIN_CFG(153, ALT_A) 462#define GPIO153_KP_I7 PIN_CFG_PULL(153, ALT_A, DOWN)
463#define GPIO153_LCD_D24 PIN_CFG(153, ALT_B) 463#define GPIO153_LCD_D24 PIN_CFG(153, ALT_B)
464#define GPIO153_U2_RXD PIN_CFG(153, ALT_C) 464#define GPIO153_U2_RXD PIN_CFG(153, ALT_C)
465 465
466#define GPIO154_GPIO PIN_CFG(154, GPIO) 466#define GPIO154_GPIO PIN_CFG(154, GPIO)
467#define GPIO154_KP_I6 PIN_CFG(154, ALT_A) 467#define GPIO154_KP_I6 PIN_CFG_PULL(154, ALT_A, DOWN)
468#define GPIO154_LCD_D25 PIN_CFG(154, ALT_B) 468#define GPIO154_LCD_D25 PIN_CFG(154, ALT_B)
469#define GPIO154_U2_TXD PIN_CFG(154, ALT_C) 469#define GPIO154_U2_TXD PIN_CFG(154, ALT_C)
470 470
471#define GPIO155_GPIO PIN_CFG(155, GPIO) 471#define GPIO155_GPIO PIN_CFG(155, GPIO)
472#define GPIO155_KP_I5 PIN_CFG(155, ALT_A) 472#define GPIO155_KP_I5 PIN_CFG_PULL(155, ALT_A, DOWN)
473#define GPIO155_LCD_D26 PIN_CFG(155, ALT_B) 473#define GPIO155_LCD_D26 PIN_CFG(155, ALT_B)
474#define GPIO155_STMAPE_CLK PIN_CFG(155, ALT_C) 474#define GPIO155_STMAPE_CLK PIN_CFG(155, ALT_C)
475 475
476#define GPIO156_GPIO PIN_CFG(156, GPIO) 476#define GPIO156_GPIO PIN_CFG(156, GPIO)
477#define GPIO156_KP_I4 PIN_CFG(156, ALT_A) 477#define GPIO156_KP_I4 PIN_CFG_PULL(156, ALT_A, DOWN)
478#define GPIO156_LCD_D27 PIN_CFG(156, ALT_B) 478#define GPIO156_LCD_D27 PIN_CFG(156, ALT_B)
479#define GPIO156_STMAPE_DAT3 PIN_CFG(156, ALT_C) 479#define GPIO156_STMAPE_DAT3 PIN_CFG(156, ALT_C)
480 480
481#define GPIO157_GPIO PIN_CFG(157, GPIO) 481#define GPIO157_GPIO PIN_CFG(157, GPIO)
482#define GPIO157_KP_O7 PIN_CFG(157, ALT_A) 482#define GPIO157_KP_O7 PIN_CFG_PULL(157, ALT_A, UP)
483#define GPIO157_LCD_D28 PIN_CFG(157, ALT_B) 483#define GPIO157_LCD_D28 PIN_CFG(157, ALT_B)
484#define GPIO157_STMAPE_DAT2 PIN_CFG(157, ALT_C) 484#define GPIO157_STMAPE_DAT2 PIN_CFG(157, ALT_C)
485 485
486#define GPIO158_GPIO PIN_CFG(158, GPIO) 486#define GPIO158_GPIO PIN_CFG(158, GPIO)
487#define GPIO158_KP_O6 PIN_CFG(158, ALT_A) 487#define GPIO158_KP_O6 PIN_CFG_PULL(158, ALT_A, UP)
488#define GPIO158_LCD_D29 PIN_CFG(158, ALT_B) 488#define GPIO158_LCD_D29 PIN_CFG(158, ALT_B)
489#define GPIO158_STMAPE_DAT1 PIN_CFG(158, ALT_C) 489#define GPIO158_STMAPE_DAT1 PIN_CFG(158, ALT_C)
490 490
491#define GPIO159_GPIO PIN_CFG(159, GPIO) 491#define GPIO159_GPIO PIN_CFG(159, GPIO)
492#define GPIO159_KP_O5 PIN_CFG(159, ALT_A) 492#define GPIO159_KP_O5 PIN_CFG_PULL(159, ALT_A, UP)
493#define GPIO159_LCD_D30 PIN_CFG(159, ALT_B) 493#define GPIO159_LCD_D30 PIN_CFG(159, ALT_B)
494#define GPIO159_STMAPE_DAT0 PIN_CFG(159, ALT_C) 494#define GPIO159_STMAPE_DAT0 PIN_CFG(159, ALT_C)
495 495
496#define GPIO160_GPIO PIN_CFG(160, GPIO) 496#define GPIO160_GPIO PIN_CFG(160, GPIO)
497#define GPIO160_KP_O4 PIN_CFG(160, ALT_A) 497#define GPIO160_KP_O4 PIN_CFG_PULL(160, ALT_A, UP)
498#define GPIO160_LCD_D31 PIN_CFG(160, ALT_B) 498#define GPIO160_LCD_D31 PIN_CFG(160, ALT_B)
499#define GPIO160_NONE PIN_CFG(160, ALT_C) 499#define GPIO160_NONE PIN_CFG(160, ALT_C)
500 500
501#define GPIO161_GPIO PIN_CFG(161, GPIO) 501#define GPIO161_GPIO PIN_CFG(161, GPIO)
502#define GPIO161_KP_I3 PIN_CFG(161, ALT_A) 502#define GPIO161_KP_I3 PIN_CFG_PULL(161, ALT_A, DOWN)
503#define GPIO161_LCD_D32 PIN_CFG(161, ALT_B) 503#define GPIO161_LCD_D32 PIN_CFG(161, ALT_B)
504#define GPIO161_UARTMOD_RXD PIN_CFG(161, ALT_C) 504#define GPIO161_UARTMOD_RXD PIN_CFG(161, ALT_C)
505 505
506#define GPIO162_GPIO PIN_CFG(162, GPIO) 506#define GPIO162_GPIO PIN_CFG(162, GPIO)
507#define GPIO162_KP_I2 PIN_CFG(162, ALT_A) 507#define GPIO162_KP_I2 PIN_CFG_PULL(162, ALT_A, DOWN)
508#define GPIO162_LCD_D33 PIN_CFG(162, ALT_B) 508#define GPIO162_LCD_D33 PIN_CFG(162, ALT_B)
509#define GPIO162_UARTMOD_TXD PIN_CFG(162, ALT_C) 509#define GPIO162_UARTMOD_TXD PIN_CFG(162, ALT_C)
510 510
511#define GPIO163_GPIO PIN_CFG(163, GPIO) 511#define GPIO163_GPIO PIN_CFG(163, GPIO)
512#define GPIO163_KP_I1 PIN_CFG(163, ALT_A) 512#define GPIO163_KP_I1 PIN_CFG_PULL(163, ALT_A, DOWN)
513#define GPIO163_LCD_D34 PIN_CFG(163, ALT_B) 513#define GPIO163_LCD_D34 PIN_CFG(163, ALT_B)
514#define GPIO163_STMMOD_CLK PIN_CFG(163, ALT_C) 514#define GPIO163_STMMOD_CLK PIN_CFG(163, ALT_C)
515 515
516#define GPIO164_GPIO PIN_CFG(164, GPIO) 516#define GPIO164_GPIO PIN_CFG(164, GPIO)
517#define GPIO164_KP_I0 PIN_CFG(164, ALT_A) 517#define GPIO164_KP_I0 PIN_CFG_PULL(164, ALT_A, UP)
518#define GPIO164_LCD_D35 PIN_CFG(164, ALT_B) 518#define GPIO164_LCD_D35 PIN_CFG(164, ALT_B)
519#define GPIO164_STMMOD_DAT3 PIN_CFG(164, ALT_C) 519#define GPIO164_STMMOD_DAT3 PIN_CFG(164, ALT_C)
520 520
521#define GPIO165_GPIO PIN_CFG(165, GPIO) 521#define GPIO165_GPIO PIN_CFG(165, GPIO)
522#define GPIO165_KP_O3 PIN_CFG(165, ALT_A) 522#define GPIO165_KP_O3 PIN_CFG_PULL(165, ALT_A, UP)
523#define GPIO165_LCD_D36 PIN_CFG(165, ALT_B) 523#define GPIO165_LCD_D36 PIN_CFG(165, ALT_B)
524#define GPIO165_STMMOD_DAT2 PIN_CFG(165, ALT_C) 524#define GPIO165_STMMOD_DAT2 PIN_CFG(165, ALT_C)
525 525
526#define GPIO166_GPIO PIN_CFG(166, GPIO) 526#define GPIO166_GPIO PIN_CFG(166, GPIO)
527#define GPIO166_KP_O2 PIN_CFG(166, ALT_A) 527#define GPIO166_KP_O2 PIN_CFG_PULL(166, ALT_A, UP)
528#define GPIO166_LCD_D37 PIN_CFG(166, ALT_B) 528#define GPIO166_LCD_D37 PIN_CFG(166, ALT_B)
529#define GPIO166_STMMOD_DAT1 PIN_CFG(166, ALT_C) 529#define GPIO166_STMMOD_DAT1 PIN_CFG(166, ALT_C)
530 530
531#define GPIO167_GPIO PIN_CFG(167, GPIO) 531#define GPIO167_GPIO PIN_CFG(167, GPIO)
532#define GPIO167_KP_O1 PIN_CFG(167, ALT_A) 532#define GPIO167_KP_O1 PIN_CFG_PULL(167, ALT_A, UP)
533#define GPIO167_LCD_D38 PIN_CFG(167, ALT_B) 533#define GPIO167_LCD_D38 PIN_CFG(167, ALT_B)
534#define GPIO167_STMMOD_DAT0 PIN_CFG(167, ALT_C) 534#define GPIO167_STMMOD_DAT0 PIN_CFG(167, ALT_C)
535 535
536#define GPIO168_GPIO PIN_CFG(168, GPIO) 536#define GPIO168_GPIO PIN_CFG(168, GPIO)
537#define GPIO168_KP_O0 PIN_CFG(168, ALT_A) 537#define GPIO168_KP_O0 PIN_CFG_PULL(168, ALT_A, UP)
538#define GPIO168_LCD_D39 PIN_CFG(168, ALT_B) 538#define GPIO168_LCD_D39 PIN_CFG(168, ALT_B)
539#define GPIO168_NONE PIN_CFG(168, ALT_C) 539#define GPIO168_NONE PIN_CFG(168, ALT_C)
540 540
@@ -569,39 +569,39 @@
569#define GPIO196_MSP2_RXD PIN_CFG(196, ALT_A) 569#define GPIO196_MSP2_RXD PIN_CFG(196, ALT_A)
570 570
571#define GPIO197_GPIO PIN_CFG(197, GPIO) 571#define GPIO197_GPIO PIN_CFG(197, GPIO)
572#define GPIO197_MC4_DAT3 PIN_CFG(197, ALT_A) 572#define GPIO197_MC4_DAT3 PIN_CFG_PULL(197, ALT_A, UP)
573 573
574#define GPIO198_GPIO PIN_CFG(198, GPIO) 574#define GPIO198_GPIO PIN_CFG(198, GPIO)
575#define GPIO198_MC4_DAT2 PIN_CFG(198, ALT_A) 575#define GPIO198_MC4_DAT2 PIN_CFG_PULL(198, ALT_A, UP)
576 576
577#define GPIO199_GPIO PIN_CFG(199, GPIO) 577#define GPIO199_GPIO PIN_CFG(199, GPIO)
578#define GPIO199_MC4_DAT1 PIN_CFG(199, ALT_A) 578#define GPIO199_MC4_DAT1 PIN_CFG_PULL(199, ALT_A, UP)
579 579
580#define GPIO200_GPIO PIN_CFG(200, GPIO) 580#define GPIO200_GPIO PIN_CFG(200, GPIO)
581#define GPIO200_MC4_DAT0 PIN_CFG(200, ALT_A) 581#define GPIO200_MC4_DAT0 PIN_CFG_PULL(200, ALT_A, UP)
582 582
583#define GPIO201_GPIO PIN_CFG(201, GPIO) 583#define GPIO201_GPIO PIN_CFG(201, GPIO)
584#define GPIO201_MC4_CMD PIN_CFG(201, ALT_A) 584#define GPIO201_MC4_CMD PIN_CFG_PULL(201, ALT_A, UP)
585 585
586#define GPIO202_GPIO PIN_CFG(202, GPIO) 586#define GPIO202_GPIO PIN_CFG(202, GPIO)
587#define GPIO202_MC4_FBCLK PIN_CFG(202, ALT_A) 587#define GPIO202_MC4_FBCLK PIN_CFG_PULL(202, ALT_A, UP)
588#define GPIO202_PWL PIN_CFG(202, ALT_B) 588#define GPIO202_PWL PIN_CFG(202, ALT_B)
589#define GPIO202_MC4_RSTN PIN_CFG(202, ALT_C) 589#define GPIO202_MC4_RSTN PIN_CFG(202, ALT_C)
590 590
591#define GPIO203_GPIO PIN_CFG(203, GPIO) 591#define GPIO203_GPIO PIN_CFG(203, GPIO)
592#define GPIO203_MC4_CLK PIN_CFG(203, ALT_A) 592#define GPIO203_MC4_CLK PIN_CFG_PULL(203, ALT_A, UP)
593 593
594#define GPIO204_GPIO PIN_CFG(204, GPIO) 594#define GPIO204_GPIO PIN_CFG(204, GPIO)
595#define GPIO204_MC4_DAT7 PIN_CFG(204, ALT_A) 595#define GPIO204_MC4_DAT7 PIN_CFG_PULL(204, ALT_A, UP)
596 596
597#define GPIO205_GPIO PIN_CFG(205, GPIO) 597#define GPIO205_GPIO PIN_CFG(205, GPIO)
598#define GPIO205_MC4_DAT6 PIN_CFG(205, ALT_A) 598#define GPIO205_MC4_DAT6 PIN_CFG_PULL(205, ALT_A, UP)
599 599
600#define GPIO206_GPIO PIN_CFG(206, GPIO) 600#define GPIO206_GPIO PIN_CFG(206, GPIO)
601#define GPIO206_MC4_DAT5 PIN_CFG(206, ALT_A) 601#define GPIO206_MC4_DAT5 PIN_CFG_PULL(206, ALT_A, UP)
602 602
603#define GPIO207_GPIO PIN_CFG(207, GPIO) 603#define GPIO207_GPIO PIN_CFG(207, GPIO)
604#define GPIO207_MC4_DAT4 PIN_CFG(207, ALT_A) 604#define GPIO207_MC4_DAT4 PIN_CFG_PULL(207, ALT_A, UP)
605 605
606#define GPIO208_GPIO PIN_CFG(208, GPIO) 606#define GPIO208_GPIO PIN_CFG(208, GPIO)
607#define GPIO208_MC1_CLK PIN_CFG(208, ALT_A) 607#define GPIO208_MC1_CLK PIN_CFG(208, ALT_A)
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index 438ef16aec90..9e4c678de785 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -78,6 +78,8 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
78 __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release)); 78 __cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release));
79 outer_clean_range(__pa(&pen_release), __pa(&pen_release) + 1); 79 outer_clean_range(__pa(&pen_release), __pa(&pen_release) + 1);
80 80
81 smp_cross_call(cpumask_of(cpu));
82
81 timeout = jiffies + (1 * HZ); 83 timeout = jiffies + (1 * HZ);
82 while (time_before(jiffies, timeout)) { 84 while (time_before(jiffies, timeout)) {
83 if (pen_release == -1) 85 if (pen_release == -1)
diff --git a/arch/arm/mach-ux500/prcmu.c b/arch/arm/mach-ux500/prcmu.c
new file mode 100644
index 000000000000..293274d1342a
--- /dev/null
+++ b/arch/arm/mach-ux500/prcmu.c
@@ -0,0 +1,231 @@
1/*
2 * Copyright (C) ST Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com>
6 *
7 * U8500 PRCMU driver.
8 */
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/errno.h>
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/mutex.h>
15#include <linux/completion.h>
16#include <linux/jiffies.h>
17#include <linux/bitops.h>
18#include <linux/interrupt.h>
19
20#include <mach/hardware.h>
21#include <mach/prcmu-regs.h>
22
23#define PRCMU_TCDM_BASE __io_address(U8500_PRCMU_TCDM_BASE)
24
25#define REQ_MB5 (PRCMU_TCDM_BASE + 0xE44)
26#define ACK_MB5 (PRCMU_TCDM_BASE + 0xDF4)
27
28#define REQ_MB5_I2C_SLAVE_OP (REQ_MB5)
29#define REQ_MB5_I2C_HW_BITS (REQ_MB5 + 1)
30#define REQ_MB5_I2C_REG (REQ_MB5 + 2)
31#define REQ_MB5_I2C_VAL (REQ_MB5 + 3)
32
33#define ACK_MB5_I2C_STATUS (ACK_MB5 + 1)
34#define ACK_MB5_I2C_VAL (ACK_MB5 + 3)
35
36#define I2C_WRITE(slave) ((slave) << 1)
37#define I2C_READ(slave) (((slave) << 1) | BIT(0))
38#define I2C_STOP_EN BIT(3)
39
40enum ack_mb5_status {
41 I2C_WR_OK = 0x01,
42 I2C_RD_OK = 0x02,
43};
44
45#define MBOX_BIT BIT
46#define NUM_MBOX 8
47
48static struct {
49 struct mutex lock;
50 struct completion work;
51 bool failed;
52 struct {
53 u8 status;
54 u8 value;
55 } ack;
56} mb5_transfer;
57
58/**
59 * prcmu_abb_read() - Read register value(s) from the ABB.
60 * @slave: The I2C slave address.
61 * @reg: The (start) register address.
62 * @value: The read out value(s).
63 * @size: The number of registers to read.
64 *
65 * Reads register value(s) from the ABB.
66 * @size has to be 1 for the current firmware version.
67 */
68int prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
69{
70 int r;
71
72 if (size != 1)
73 return -EINVAL;
74
75 r = mutex_lock_interruptible(&mb5_transfer.lock);
76 if (r)
77 return r;
78
79 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5))
80 cpu_relax();
81
82 writeb(I2C_READ(slave), REQ_MB5_I2C_SLAVE_OP);
83 writeb(I2C_STOP_EN, REQ_MB5_I2C_HW_BITS);
84 writeb(reg, REQ_MB5_I2C_REG);
85
86 writel(MBOX_BIT(5), PRCM_MBOX_CPU_SET);
87 if (!wait_for_completion_timeout(&mb5_transfer.work,
88 msecs_to_jiffies(500))) {
89 pr_err("prcmu: prcmu_abb_read timed out.\n");
90 r = -EIO;
91 goto unlock_and_return;
92 }
93 r = ((mb5_transfer.ack.status == I2C_RD_OK) ? 0 : -EIO);
94 if (!r)
95 *value = mb5_transfer.ack.value;
96
97unlock_and_return:
98 mutex_unlock(&mb5_transfer.lock);
99 return r;
100}
101EXPORT_SYMBOL(prcmu_abb_read);
102
103/**
104 * prcmu_abb_write() - Write register value(s) to the ABB.
105 * @slave: The I2C slave address.
106 * @reg: The (start) register address.
107 * @value: The value(s) to write.
108 * @size: The number of registers to write.
109 *
110 * Reads register value(s) from the ABB.
111 * @size has to be 1 for the current firmware version.
112 */
113int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
114{
115 int r;
116
117 if (size != 1)
118 return -EINVAL;
119
120 r = mutex_lock_interruptible(&mb5_transfer.lock);
121 if (r)
122 return r;
123
124
125 while (readl(PRCM_MBOX_CPU_VAL) & MBOX_BIT(5))
126 cpu_relax();
127
128 writeb(I2C_WRITE(slave), REQ_MB5_I2C_SLAVE_OP);
129 writeb(I2C_STOP_EN, REQ_MB5_I2C_HW_BITS);
130 writeb(reg, REQ_MB5_I2C_REG);
131 writeb(*value, REQ_MB5_I2C_VAL);
132
133 writel(MBOX_BIT(5), PRCM_MBOX_CPU_SET);
134 if (!wait_for_completion_timeout(&mb5_transfer.work,
135 msecs_to_jiffies(500))) {
136 pr_err("prcmu: prcmu_abb_write timed out.\n");
137 r = -EIO;
138 goto unlock_and_return;
139 }
140 r = ((mb5_transfer.ack.status == I2C_WR_OK) ? 0 : -EIO);
141
142unlock_and_return:
143 mutex_unlock(&mb5_transfer.lock);
144 return r;
145}
146EXPORT_SYMBOL(prcmu_abb_write);
147
148static void read_mailbox_0(void)
149{
150 writel(MBOX_BIT(0), PRCM_ARM_IT1_CLEAR);
151}
152
153static void read_mailbox_1(void)
154{
155 writel(MBOX_BIT(1), PRCM_ARM_IT1_CLEAR);
156}
157
158static void read_mailbox_2(void)
159{
160 writel(MBOX_BIT(2), PRCM_ARM_IT1_CLEAR);
161}
162
163static void read_mailbox_3(void)
164{
165 writel(MBOX_BIT(3), PRCM_ARM_IT1_CLEAR);
166}
167
168static void read_mailbox_4(void)
169{
170 writel(MBOX_BIT(4), PRCM_ARM_IT1_CLEAR);
171}
172
173static void read_mailbox_5(void)
174{
175 mb5_transfer.ack.status = readb(ACK_MB5_I2C_STATUS);
176 mb5_transfer.ack.value = readb(ACK_MB5_I2C_VAL);
177 complete(&mb5_transfer.work);
178 writel(MBOX_BIT(5), PRCM_ARM_IT1_CLEAR);
179}
180
181static void read_mailbox_6(void)
182{
183 writel(MBOX_BIT(6), PRCM_ARM_IT1_CLEAR);
184}
185
186static void read_mailbox_7(void)
187{
188 writel(MBOX_BIT(7), PRCM_ARM_IT1_CLEAR);
189}
190
191static void (* const read_mailbox[NUM_MBOX])(void) = {
192 read_mailbox_0,
193 read_mailbox_1,
194 read_mailbox_2,
195 read_mailbox_3,
196 read_mailbox_4,
197 read_mailbox_5,
198 read_mailbox_6,
199 read_mailbox_7
200};
201
202static irqreturn_t prcmu_irq_handler(int irq, void *data)
203{
204 u32 bits;
205 u8 n;
206
207 bits = (readl(PRCM_ARM_IT1_VAL) & (MBOX_BIT(NUM_MBOX) - 1));
208 if (unlikely(!bits))
209 return IRQ_NONE;
210
211 for (n = 0; bits; n++) {
212 if (bits & MBOX_BIT(n)) {
213 bits -= MBOX_BIT(n);
214 read_mailbox[n]();
215 }
216 }
217 return IRQ_HANDLED;
218}
219
220static int __init prcmu_init(void)
221{
222 mutex_init(&mb5_transfer.lock);
223 init_completion(&mb5_transfer.work);
224
225 /* Clean up the mailbox interrupts after pre-kernel code. */
226 writel((MBOX_BIT(NUM_MBOX) - 1), PRCM_ARM_IT1_CLEAR);
227
228 return request_irq(IRQ_PRCMU, prcmu_irq_handler, 0, "prcmu", NULL);
229}
230
231arch_initcall(prcmu_init);
diff --git a/arch/arm/mach-ux500/ste-dma40-db5500.h b/arch/arm/mach-ux500/ste-dma40-db5500.h
new file mode 100644
index 000000000000..cb2110c32858
--- /dev/null
+++ b/arch/arm/mach-ux500/ste-dma40-db5500.h
@@ -0,0 +1,135 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2
6 *
7 * DB5500-SoC-specific configuration for DMA40
8 */
9
10#ifndef STE_DMA40_DB5500_H
11#define STE_DMA40_DB5500_H
12
13#define DB5500_DMA_NR_DEV 64
14
15enum dma_src_dev_type {
16 DB5500_DMA_DEV0_SPI0_RX = 0,
17 DB5500_DMA_DEV1_SPI1_RX = 1,
18 DB5500_DMA_DEV2_SPI2_RX = 2,
19 DB5500_DMA_DEV3_SPI3_RX = 3,
20 DB5500_DMA_DEV4_USB_OTG_IEP_1_9 = 4,
21 DB5500_DMA_DEV5_USB_OTG_IEP_2_10 = 5,
22 DB5500_DMA_DEV6_USB_OTG_IEP_3_11 = 6,
23 DB5500_DMA_DEV7_IRDA_RFS = 7,
24 DB5500_DMA_DEV8_IRDA_FIFO_RX = 8,
25 DB5500_DMA_DEV9_MSP0_RX = 9,
26 DB5500_DMA_DEV10_MSP1_RX = 10,
27 DB5500_DMA_DEV11_MSP2_RX = 11,
28 DB5500_DMA_DEV12_UART0_RX = 12,
29 DB5500_DMA_DEV13_UART1_RX = 13,
30 DB5500_DMA_DEV14_UART2_RX = 14,
31 DB5500_DMA_DEV15_UART3_RX = 15,
32 DB5500_DMA_DEV16_USB_OTG_IEP_8 = 16,
33 DB5500_DMA_DEV17_USB_OTG_IEP_1_9 = 17,
34 DB5500_DMA_DEV18_USB_OTG_IEP_2_10 = 18,
35 DB5500_DMA_DEV19_USB_OTG_IEP_3_11 = 19,
36 DB5500_DMA_DEV20_USB_OTG_IEP_4_12 = 20,
37 DB5500_DMA_DEV21_USB_OTG_IEP_5_13 = 21,
38 DB5500_DMA_DEV22_USB_OTG_IEP_6_14 = 22,
39 DB5500_DMA_DEV23_USB_OTG_IEP_7_15 = 23,
40 DB5500_DMA_DEV24_SDMMC0_RX = 24,
41 DB5500_DMA_DEV25_SDMMC1_RX = 25,
42 DB5500_DMA_DEV26_SDMMC2_RX = 26,
43 DB5500_DMA_DEV27_SDMMC3_RX = 27,
44 DB5500_DMA_DEV28_SDMMC4_RX = 28,
45 /* 29 - 32 not used */
46 DB5500_DMA_DEV33_SDMMC0_RX = 33,
47 DB5500_DMA_DEV34_SDMMC1_RX = 34,
48 DB5500_DMA_DEV35_SDMMC2_RX = 35,
49 DB5500_DMA_DEV36_SDMMC3_RX = 36,
50 DB5500_DMA_DEV37_SDMMC4_RX = 37,
51 DB5500_DMA_DEV38_USB_OTG_IEP_8 = 38,
52 DB5500_DMA_DEV39_USB_OTG_IEP_1_9 = 39,
53 DB5500_DMA_DEV40_USB_OTG_IEP_2_10 = 40,
54 DB5500_DMA_DEV41_USB_OTG_IEP_3_11 = 41,
55 DB5500_DMA_DEV42_USB_OTG_IEP_4_12 = 42,
56 DB5500_DMA_DEV43_USB_OTG_IEP_5_13 = 43,
57 DB5500_DMA_DEV44_USB_OTG_IEP_6_14 = 44,
58 DB5500_DMA_DEV45_USB_OTG_IEP_7_15 = 45,
59 /* 46 not used */
60 DB5500_DMA_DEV47_MCDE_RX = 47,
61 DB5500_DMA_DEV48_CRYPTO1_RX = 48,
62 /* 49, 50 not used */
63 DB5500_DMA_DEV49_I2C1_RX = 51,
64 DB5500_DMA_DEV50_I2C3_RX = 52,
65 DB5500_DMA_DEV51_I2C2_RX = 53,
66 /* 54 - 60 not used */
67 DB5500_DMA_DEV61_CRYPTO0_RX = 61,
68 /* 62, 63 not used */
69};
70
71enum dma_dest_dev_type {
72 DB5500_DMA_DEV0_SPI0_TX = 0,
73 DB5500_DMA_DEV1_SPI1_TX = 1,
74 DB5500_DMA_DEV2_SPI2_TX = 2,
75 DB5500_DMA_DEV3_SPI3_TX = 3,
76 DB5500_DMA_DEV4_USB_OTG_OEP_1_9 = 4,
77 DB5500_DMA_DEV5_USB_OTG_OEP_2_10 = 5,
78 DB5500_DMA_DEV6_USB_OTG_OEP_3_11 = 6,
79 DB5500_DMA_DEV7_IRRC_TX = 7,
80 DB5500_DMA_DEV8_IRDA_FIFO_TX = 8,
81 DB5500_DMA_DEV9_MSP0_TX = 9,
82 DB5500_DMA_DEV10_MSP1_TX = 10,
83 DB5500_DMA_DEV11_MSP2_TX = 11,
84 DB5500_DMA_DEV12_UART0_TX = 12,
85 DB5500_DMA_DEV13_UART1_TX = 13,
86 DB5500_DMA_DEV14_UART2_TX = 14,
87 DB5500_DMA_DEV15_UART3_TX = 15,
88 DB5500_DMA_DEV16_USB_OTG_OEP_8 = 16,
89 DB5500_DMA_DEV17_USB_OTG_OEP_1_9 = 17,
90 DB5500_DMA_DEV18_USB_OTG_OEP_2_10 = 18,
91 DB5500_DMA_DEV19_USB_OTG_OEP_3_11 = 19,
92 DB5500_DMA_DEV20_USB_OTG_OEP_4_12 = 20,
93 DB5500_DMA_DEV21_USB_OTG_OEP_5_13 = 21,
94 DB5500_DMA_DEV22_USB_OTG_OEP_6_14 = 22,
95 DB5500_DMA_DEV23_USB_OTG_OEP_7_15 = 23,
96 DB5500_DMA_DEV24_SDMMC0_TX = 24,
97 DB5500_DMA_DEV25_SDMMC1_TX = 25,
98 DB5500_DMA_DEV26_SDMMC2_TX = 26,
99 DB5500_DMA_DEV27_SDMMC3_TX = 27,
100 DB5500_DMA_DEV28_SDMMC4_TX = 28,
101 /* 29 - 31 not used */
102 DB5500_DMA_DEV32_FSMC_TX = 32,
103 DB5500_DMA_DEV33_SDMMC0_TX = 33,
104 DB5500_DMA_DEV34_SDMMC1_TX = 34,
105 DB5500_DMA_DEV35_SDMMC2_TX = 35,
106 DB5500_DMA_DEV36_SDMMC3_TX = 36,
107 DB5500_DMA_DEV37_SDMMC4_TX = 37,
108 DB5500_DMA_DEV38_USB_OTG_OEP_8 = 38,
109 DB5500_DMA_DEV39_USB_OTG_OEP_1_9 = 39,
110 DB5500_DMA_DEV40_USB_OTG_OEP_2_10 = 40,
111 DB5500_DMA_DEV41_USB_OTG_OEP_3_11 = 41,
112 DB5500_DMA_DEV42_USB_OTG_OEP_4_12 = 42,
113 DB5500_DMA_DEV43_USB_OTG_OEP_5_13 = 43,
114 DB5500_DMA_DEV44_USB_OTG_OEP_6_14 = 44,
115 DB5500_DMA_DEV45_USB_OTG_OEP_7_15 = 45,
116 /* 46 not used */
117 DB5500_DMA_DEV47_STM_TX = 47,
118 DB5500_DMA_DEV48_CRYPTO1_TX = 48,
119 DB5500_DMA_DEV49_CRYPTO1_TX_HASH1_TX = 49,
120 DB5500_DMA_DEV50_HASH1_TX = 50,
121 DB5500_DMA_DEV51_I2C1_TX = 51,
122 DB5500_DMA_DEV52_I2C3_TX = 52,
123 DB5500_DMA_DEV53_I2C2_TX = 53,
124 /* 54, 55 not used */
125 DB5500_DMA_MEMCPY_TX_1 = 56,
126 DB5500_DMA_MEMCPY_TX_2 = 57,
127 DB5500_DMA_MEMCPY_TX_3 = 58,
128 DB5500_DMA_MEMCPY_TX_4 = 59,
129 DB5500_DMA_MEMCPY_TX_5 = 60,
130 DB5500_DMA_DEV61_CRYPTO0_TX = 61,
131 DB5500_DMA_DEV62_CRYPTO0_TX_HASH0_TX = 62,
132 DB5500_DMA_DEV63_HASH0_TX = 63,
133};
134
135#endif
diff --git a/arch/arm/mach-ux500/ste-dma40-db8500.h b/arch/arm/mach-ux500/ste-dma40-db8500.h
index 9d9d3797b3b0..a616419bea76 100644
--- a/arch/arm/mach-ux500/ste-dma40-db8500.h
+++ b/arch/arm/mach-ux500/ste-dma40-db8500.h
@@ -10,145 +10,135 @@
10#ifndef STE_DMA40_DB8500_H 10#ifndef STE_DMA40_DB8500_H
11#define STE_DMA40_DB8500_H 11#define STE_DMA40_DB8500_H
12 12
13#define STEDMA40_NR_DEV 64 13#define DB8500_DMA_NR_DEV 64
14 14
15enum dma_src_dev_type { 15enum dma_src_dev_type {
16 STEDMA40_DEV_SPI0_RX = 0, 16 DB8500_DMA_DEV0_SPI0_RX = 0,
17 STEDMA40_DEV_SD_MMC0_RX = 1, 17 DB8500_DMA_DEV1_SD_MMC0_RX = 1,
18 STEDMA40_DEV_SD_MMC1_RX = 2, 18 DB8500_DMA_DEV2_SD_MMC1_RX = 2,
19 STEDMA40_DEV_SD_MMC2_RX = 3, 19 DB8500_DMA_DEV3_SD_MMC2_RX = 3,
20 STEDMA40_DEV_I2C1_RX = 4, 20 DB8500_DMA_DEV4_I2C1_RX = 4,
21 STEDMA40_DEV_I2C3_RX = 5, 21 DB8500_DMA_DEV5_I2C3_RX = 5,
22 STEDMA40_DEV_I2C2_RX = 6, 22 DB8500_DMA_DEV6_I2C2_RX = 6,
23 STEDMA40_DEV_I2C4_RX = 7, /* Only on V1 */ 23 DB8500_DMA_DEV7_I2C4_RX = 7, /* Only on V1 and later */
24 STEDMA40_DEV_SSP0_RX = 8, 24 DB8500_DMA_DEV8_SSP0_RX = 8,
25 STEDMA40_DEV_SSP1_RX = 9, 25 DB8500_DMA_DEV9_SSP1_RX = 9,
26 STEDMA40_DEV_MCDE_RX = 10, 26 DB8500_DMA_DEV10_MCDE_RX = 10,
27 STEDMA40_DEV_UART2_RX = 11, 27 DB8500_DMA_DEV11_UART2_RX = 11,
28 STEDMA40_DEV_UART1_RX = 12, 28 DB8500_DMA_DEV12_UART1_RX = 12,
29 STEDMA40_DEV_UART0_RX = 13, 29 DB8500_DMA_DEV13_UART0_RX = 13,
30 STEDMA40_DEV_MSP2_RX = 14, 30 DB8500_DMA_DEV14_MSP2_RX = 14,
31 STEDMA40_DEV_I2C0_RX = 15, 31 DB8500_DMA_DEV15_I2C0_RX = 15,
32 STEDMA40_DEV_USB_OTG_IEP_8 = 16, 32 DB8500_DMA_DEV16_USB_OTG_IEP_7_15 = 16,
33 STEDMA40_DEV_USB_OTG_IEP_1_9 = 17, 33 DB8500_DMA_DEV17_USB_OTG_IEP_6_14 = 17,
34 STEDMA40_DEV_USB_OTG_IEP_2_10 = 18, 34 DB8500_DMA_DEV18_USB_OTG_IEP_5_13 = 18,
35 STEDMA40_DEV_USB_OTG_IEP_3_11 = 19, 35 DB8500_DMA_DEV19_USB_OTG_IEP_4_12 = 19,
36 STEDMA40_DEV_SLIM0_CH0_RX_HSI_RX_CH0 = 20, 36 DB8500_DMA_DEV20_SLIM0_CH0_RX_HSI_RX_CH0 = 20,
37 STEDMA40_DEV_SLIM0_CH1_RX_HSI_RX_CH1 = 21, 37 DB8500_DMA_DEV21_SLIM0_CH1_RX_HSI_RX_CH1 = 21,
38 STEDMA40_DEV_SLIM0_CH2_RX_HSI_RX_CH2 = 22, 38 DB8500_DMA_DEV22_SLIM0_CH2_RX_HSI_RX_CH2 = 22,
39 STEDMA40_DEV_SLIM0_CH3_RX_HSI_RX_CH3 = 23, 39 DB8500_DMA_DEV23_SLIM0_CH3_RX_HSI_RX_CH3 = 23,
40 STEDMA40_DEV_SRC_SXA0_RX_TX = 24, 40 DB8500_DMA_DEV24_SRC_SXA0_RX_TX = 24,
41 STEDMA40_DEV_SRC_SXA1_RX_TX = 25, 41 DB8500_DMA_DEV25_SRC_SXA1_RX_TX = 25,
42 STEDMA40_DEV_SRC_SXA2_RX_TX = 26, 42 DB8500_DMA_DEV26_SRC_SXA2_RX_TX = 26,
43 STEDMA40_DEV_SRC_SXA3_RX_TX = 27, 43 DB8500_DMA_DEV27_SRC_SXA3_RX_TX = 27,
44 STEDMA40_DEV_SD_MM2_RX = 28, 44 DB8500_DMA_DEV28_SD_MM2_RX = 28,
45 STEDMA40_DEV_SD_MM0_RX = 29, 45 DB8500_DMA_DEV29_SD_MM0_RX = 29,
46 STEDMA40_DEV_MSP1_RX = 30, 46 DB8500_DMA_DEV30_MSP1_RX = 30,
47 /* 47 /* On DB8500v2, MSP3 RX replaces MSP1 RX */
48 * This channel is either SlimBus or MSP, 48 DB8500_DMA_DEV30_MSP3_RX = 30,
49 * never both at the same time. 49 DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX = 31,
50 */ 50 DB8500_DMA_DEV32_SD_MM1_RX = 32,
51 STEDMA40_SLIM0_CH0_RX = 31, 51 DB8500_DMA_DEV33_SPI2_RX = 33,
52 STEDMA40_DEV_MSP0_RX = 31, 52 DB8500_DMA_DEV34_I2C3_RX2 = 34,
53 STEDMA40_DEV_SD_MM1_RX = 32, 53 DB8500_DMA_DEV35_SPI1_RX = 35,
54 STEDMA40_DEV_SPI2_RX = 33, 54 DB8500_DMA_DEV36_USB_OTG_IEP_3_11 = 36,
55 STEDMA40_DEV_I2C3_RX2 = 34, 55 DB8500_DMA_DEV37_USB_OTG_IEP_2_10 = 37,
56 STEDMA40_DEV_SPI1_RX = 35, 56 DB8500_DMA_DEV38_USB_OTG_IEP_1_9 = 38,
57 STEDMA40_DEV_USB_OTG_IEP_4_12 = 36, 57 DB8500_DMA_DEV39_USB_OTG_IEP_8 = 39,
58 STEDMA40_DEV_USB_OTG_IEP_5_13 = 37, 58 DB8500_DMA_DEV40_SPI3_RX = 40,
59 STEDMA40_DEV_USB_OTG_IEP_6_14 = 38, 59 DB8500_DMA_DEV41_SD_MM3_RX = 41,
60 STEDMA40_DEV_USB_OTG_IEP_7_15 = 39, 60 DB8500_DMA_DEV42_SD_MM4_RX = 42,
61 STEDMA40_DEV_SPI3_RX = 40, 61 DB8500_DMA_DEV43_SD_MM5_RX = 43,
62 STEDMA40_DEV_SD_MM3_RX = 41, 62 DB8500_DMA_DEV44_SRC_SXA4_RX_TX = 44,
63 STEDMA40_DEV_SD_MM4_RX = 42, 63 DB8500_DMA_DEV45_SRC_SXA5_RX_TX = 45,
64 STEDMA40_DEV_SD_MM5_RX = 43, 64 DB8500_DMA_DEV46_SLIM0_CH8_RX_SRC_SXA6_RX_TX = 46,
65 STEDMA40_DEV_SRC_SXA4_RX_TX = 44, 65 DB8500_DMA_DEV47_SLIM0_CH9_RX_SRC_SXA7_RX_TX = 47,
66 STEDMA40_DEV_SRC_SXA5_RX_TX = 45, 66 DB8500_DMA_DEV48_CAC1_RX = 48,
67 STEDMA40_DEV_SRC_SXA6_RX_TX = 46, 67 /* 49, 50 and 51 are not used */
68 STEDMA40_DEV_SRC_SXA7_RX_TX = 47, 68 DB8500_DMA_DEV52_SLIM0_CH4_RX_HSI_RX_CH4 = 52,
69 STEDMA40_DEV_CAC1_RX = 48, 69 DB8500_DMA_DEV53_SLIM0_CH5_RX_HSI_RX_CH5 = 53,
70 /* RX channels 49 and 50 are unused */ 70 DB8500_DMA_DEV54_SLIM0_CH6_RX_HSI_RX_CH6 = 54,
71 STEDMA40_DEV_MSHC_RX = 51, 71 DB8500_DMA_DEV55_SLIM0_CH7_RX_HSI_RX_CH7 = 55,
72 STEDMA40_DEV_SLIM1_CH0_RX_HSI_RX_CH4 = 52, 72 /* 56, 57, 58, 59 and 60 are not used */
73 STEDMA40_DEV_SLIM1_CH1_RX_HSI_RX_CH5 = 53, 73 DB8500_DMA_DEV61_CAC0_RX = 61,
74 STEDMA40_DEV_SLIM1_CH2_RX_HSI_RX_CH6 = 54, 74 /* 62 and 63 are not used */
75 STEDMA40_DEV_SLIM1_CH3_RX_HSI_RX_CH7 = 55,
76 /* RX channels 56 thru 60 are unused */
77 STEDMA40_DEV_CAC0_RX = 61,
78 /* RX channels 62 and 63 are unused */
79}; 75};
80 76
81enum dma_dest_dev_type { 77enum dma_dest_dev_type {
82 STEDMA40_DEV_SPI0_TX = 0, 78 DB8500_DMA_DEV0_SPI0_TX = 0,
83 STEDMA40_DEV_SD_MMC0_TX = 1, 79 DB8500_DMA_DEV1_SD_MMC0_TX = 1,
84 STEDMA40_DEV_SD_MMC1_TX = 2, 80 DB8500_DMA_DEV2_SD_MMC1_TX = 2,
85 STEDMA40_DEV_SD_MMC2_TX = 3, 81 DB8500_DMA_DEV3_SD_MMC2_TX = 3,
86 STEDMA40_DEV_I2C1_TX = 4, 82 DB8500_DMA_DEV4_I2C1_TX = 4,
87 STEDMA40_DEV_I2C3_TX = 5, 83 DB8500_DMA_DEV5_I2C3_TX = 5,
88 STEDMA40_DEV_I2C2_TX = 6, 84 DB8500_DMA_DEV6_I2C2_TX = 6,
89 STEDMA50_DEV_I2C4_TX = 7, /* Only on V1 */ 85 DB8500_DMA_DEV7_I2C4_TX = 7, /* Only on V1 and later */
90 STEDMA40_DEV_SSP0_TX = 8, 86 DB8500_DMA_DEV8_SSP0_TX = 8,
91 STEDMA40_DEV_SSP1_TX = 9, 87 DB8500_DMA_DEV9_SSP1_TX = 9,
92 /* TX channel 10 is unused */ 88 /* 10 is not used*/
93 STEDMA40_DEV_UART2_TX = 11, 89 DB8500_DMA_DEV11_UART2_TX = 11,
94 STEDMA40_DEV_UART1_TX = 12, 90 DB8500_DMA_DEV12_UART1_TX = 12,
95 STEDMA40_DEV_UART0_TX= 13, 91 DB8500_DMA_DEV13_UART0_TX = 13,
96 STEDMA40_DEV_MSP2_TX = 14, 92 DB8500_DMA_DEV14_MSP2_TX = 14,
97 STEDMA40_DEV_I2C0_TX = 15, 93 DB8500_DMA_DEV15_I2C0_TX = 15,
98 STEDMA40_DEV_USB_OTG_OEP_8 = 16, 94 DB8500_DMA_DEV16_USB_OTG_OEP_7_15 = 16,
99 STEDMA40_DEV_USB_OTG_OEP_1_9 = 17, 95 DB8500_DMA_DEV17_USB_OTG_OEP_6_14 = 17,
100 STEDMA40_DEV_USB_OTG_OEP_2_10= 18, 96 DB8500_DMA_DEV18_USB_OTG_OEP_5_13 = 18,
101 STEDMA40_DEV_USB_OTG_OEP_3_11 = 19, 97 DB8500_DMA_DEV19_USB_OTG_OEP_4_12 = 19,
102 STEDMA40_DEV_SLIM0_CH0_TX_HSI_TX_CH0 = 20, 98 DB8500_DMA_DEV20_SLIM0_CH0_TX_HSI_TX_CH0 = 20,
103 STEDMA40_DEV_SLIM0_CH1_TX_HSI_TX_CH1 = 21, 99 DB8500_DMA_DEV21_SLIM0_CH1_TX_HSI_TX_CH1 = 21,
104 STEDMA40_DEV_SLIM0_CH2_TX_HSI_TX_CH2 = 22, 100 DB8500_DMA_DEV22_SLIM0_CH2_TX_HSI_TX_CH2 = 22,
105 STEDMA40_DEV_SLIM0_CH3_TX_HSI_TX_CH3 = 23, 101 DB8500_DMA_DEV23_SLIM0_CH3_TX_HSI_TX_CH3 = 23,
106 STEDMA40_DEV_DST_SXA0_RX_TX = 24, 102 DB8500_DMA_DEV24_DST_SXA0_RX_TX = 24,
107 STEDMA40_DEV_DST_SXA1_RX_TX = 25, 103 DB8500_DMA_DEV25_DST_SXA1_RX_TX = 25,
108 STEDMA40_DEV_DST_SXA2_RX_TX = 26, 104 DB8500_DMA_DEV26_DST_SXA2_RX_TX = 26,
109 STEDMA40_DEV_DST_SXA3_RX_TX = 27, 105 DB8500_DMA_DEV27_DST_SXA3_RX_TX = 27,
110 STEDMA40_DEV_SD_MM2_TX = 28, 106 DB8500_DMA_DEV28_SD_MM2_TX = 28,
111 STEDMA40_DEV_SD_MM0_TX = 29, 107 DB8500_DMA_DEV29_SD_MM0_TX = 29,
112 STEDMA40_DEV_MSP1_TX = 30, 108 DB8500_DMA_DEV30_MSP1_TX = 30,
113 /* 109 DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX = 31,
114 * This channel is either SlimBus or MSP, 110 DB8500_DMA_DEV32_SD_MM1_TX = 32,
115 * never both at the same time. 111 DB8500_DMA_DEV33_SPI2_TX = 33,
116 */ 112 DB8500_DMA_DEV34_I2C3_TX2 = 34,
117 STEDMA40_SLIM0_CH0_TX = 31, 113 DB8500_DMA_DEV35_SPI1_TX = 35,
118 STEDMA40_DEV_MSP0_TX = 31, 114 DB8500_DMA_DEV36_USB_OTG_OEP_3_11 = 36,
119 STEDMA40_DEV_SD_MM1_TX = 32, 115 DB8500_DMA_DEV37_USB_OTG_OEP_2_10 = 37,
120 STEDMA40_DEV_SPI2_TX = 33, 116 DB8500_DMA_DEV38_USB_OTG_OEP_1_9 = 38,
121 /* Secondary I2C3 channel */ 117 DB8500_DMA_DEV39_USB_OTG_OEP_8 = 39,
122 STEDMA40_DEV_I2C3_TX2 = 34, 118 DB8500_DMA_DEV40_SPI3_TX = 40,
123 STEDMA40_DEV_SPI1_TX = 35, 119 DB8500_DMA_DEV41_SD_MM3_TX = 41,
124 STEDMA40_DEV_USB_OTG_OEP_4_12 = 36, 120 DB8500_DMA_DEV42_SD_MM4_TX = 42,
125 STEDMA40_DEV_USB_OTG_OEP_5_13 = 37, 121 DB8500_DMA_DEV43_SD_MM5_TX = 43,
126 STEDMA40_DEV_USB_OTG_OEP_6_14 = 38, 122 DB8500_DMA_DEV44_DST_SXA4_RX_TX = 44,
127 STEDMA40_DEV_USB_OTG_OEP_7_15 = 39, 123 DB8500_DMA_DEV45_DST_SXA5_RX_TX = 45,
128 STEDMA40_DEV_SPI3_TX = 40, 124 DB8500_DMA_DEV46_SLIM0_CH8_TX_DST_SXA6_RX_TX = 46,
129 STEDMA40_DEV_SD_MM3_TX = 41, 125 DB8500_DMA_DEV47_SLIM0_CH9_TX_DST_SXA7_RX_TX = 47,
130 STEDMA40_DEV_SD_MM4_TX = 42, 126 DB8500_DMA_DEV48_CAC1_TX = 48,
131 STEDMA40_DEV_SD_MM5_TX = 43, 127 DB8500_DMA_DEV49_CAC1_TX_HAC1_TX = 49,
132 STEDMA40_DEV_DST_SXA4_RX_TX = 44, 128 DB8500_DMA_DEV50_HAC1_TX = 50,
133 STEDMA40_DEV_DST_SXA5_RX_TX = 45, 129 DB8500_DMA_MEMCPY_TX_0 = 51,
134 STEDMA40_DEV_DST_SXA6_RX_TX = 46, 130 DB8500_DMA_DEV52_SLIM1_CH4_TX_HSI_TX_CH4 = 52,
135 STEDMA40_DEV_DST_SXA7_RX_TX = 47, 131 DB8500_DMA_DEV53_SLIM1_CH5_TX_HSI_TX_CH5 = 53,
136 STEDMA40_DEV_CAC1_TX = 48, 132 DB8500_DMA_DEV54_SLIM1_CH6_TX_HSI_TX_CH6 = 54,
137 STEDMA40_DEV_CAC1_TX_HAC1_TX = 49, 133 DB8500_DMA_DEV55_SLIM1_CH7_TX_HSI_TX_CH7 = 55,
138 STEDMA40_DEV_HAC1_TX = 50, 134 DB8500_DMA_MEMCPY_TX_1 = 56,
139 STEDMA40_MEMCPY_TX_0 = 51, 135 DB8500_DMA_MEMCPY_TX_2 = 57,
140 STEDMA40_DEV_SLIM1_CH0_TX_HSI_TX_CH4 = 52, 136 DB8500_DMA_MEMCPY_TX_3 = 58,
141 STEDMA40_DEV_SLIM1_CH1_TX_HSI_TX_CH5 = 53, 137 DB8500_DMA_MEMCPY_TX_4 = 59,
142 STEDMA40_DEV_SLIM1_CH2_TX_HSI_TX_CH6 = 54, 138 DB8500_DMA_MEMCPY_TX_5 = 60,
143 STEDMA40_DEV_SLIM1_CH3_TX_HSI_TX_CH7 = 55, 139 DB8500_DMA_DEV61_CAC0_TX = 61,
144 STEDMA40_MEMCPY_TX_1 = 56, 140 DB8500_DMA_DEV62_CAC0_TX_HAC0_TX = 62,
145 STEDMA40_MEMCPY_TX_2 = 57, 141 DB8500_DMA_DEV63_HAC0_TX = 63,
146 STEDMA40_MEMCPY_TX_3 = 58,
147 STEDMA40_MEMCPY_TX_4 = 59,
148 STEDMA40_MEMCPY_TX_5 = 60,
149 STEDMA40_DEV_CAC0_TX = 61,
150 STEDMA40_DEV_CAC0_TX_HAC0_TX = 62,
151 STEDMA40_DEV_HAC0_TX = 63,
152}; 142};
153 143
154#endif 144#endif
diff --git a/arch/arm/mach-versatile/include/mach/debug-macro.S b/arch/arm/mach-versatile/include/mach/debug-macro.S
index 6fea7199c626..eb2cf7dc5c44 100644
--- a/arch/arm/mach-versatile/include/mach/debug-macro.S
+++ b/arch/arm/mach-versatile/include/mach/debug-macro.S
@@ -11,13 +11,11 @@
11 * 11 *
12*/ 12*/
13 13
14 .macro addruart, rx, tmp 14 .macro addruart, rp, rv
15 mrc p15, 0, \rx, c1, c0 15 mov \rp, #0x001F0000
16 tst \rx, #1 @ MMU enabled? 16 orr \rp, \rp, #0x00001000
17 moveq \rx, #0x10000000 17 orr \rv, \rp, #0xf1000000 @ virtual base
18 movne \rx, #0xf1000000 @ virtual base 18 orr \rp, \rp, #0x10000000 @ physical base
19 orr \rx, \rx, #0x001F0000
20 orr \rx, \rx, #0x00001000
21 .endm 19 .endm
22 20
23#include <asm/hardware/debug-pl01x.S> 21#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-versatile/include/mach/vmalloc.h b/arch/arm/mach-versatile/include/mach/vmalloc.h
index 427e3612db5d..ebd8a2543d3b 100644
--- a/arch/arm/mach-versatile/include/mach/vmalloc.h
+++ b/arch/arm/mach-versatile/include/mach/vmalloc.h
@@ -18,4 +18,4 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#define VMALLOC_END (PAGE_OFFSET + 0x18000000) 21#define VMALLOC_END 0xd8000000
diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
index bb8ec7724f79..aa9730fb13bf 100644
--- a/arch/arm/mach-versatile/versatile_ab.c
+++ b/arch/arm/mach-versatile/versatile_ab.c
@@ -35,8 +35,6 @@
35 35
36MACHINE_START(VERSATILE_AB, "ARM-Versatile AB") 36MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
37 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 37 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
38 .phys_io = 0x101f1000,
39 .io_pg_offst = ((0xf11f1000) >> 18) & 0xfffc,
40 .boot_params = 0x00000100, 38 .boot_params = 0x00000100,
41 .map_io = versatile_map_io, 39 .map_io = versatile_map_io,
42 .init_irq = versatile_init_irq, 40 .init_irq = versatile_init_irq,
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index 239cd30fc4f5..bf469642a3f8 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -108,8 +108,6 @@ static void __init versatile_pb_init(void)
108 108
109MACHINE_START(VERSATILE_PB, "ARM-Versatile PB") 109MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
110 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 110 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
111 .phys_io = 0x101f1000,
112 .io_pg_offst = ((0xf11f1000) >> 18) & 0xfffc,
113 .boot_params = 0x00000100, 111 .boot_params = 0x00000100,
114 .map_io = versatile_map_io, 112 .map_io = versatile_map_io,
115 .init_irq = versatile_init_irq, 113 .init_irq = versatile_init_irq,
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index efb127022d42..c2e405a9e025 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -68,7 +68,7 @@ static void __init ct_ca9x4_init_irq(void)
68} 68}
69 69
70#if 0 70#if 0
71static void ct_ca9x4_timer_init(void) 71static void __init ct_ca9x4_timer_init(void)
72{ 72{
73 writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL); 73 writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL);
74 writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL); 74 writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL);
@@ -222,7 +222,7 @@ static struct platform_device pmu_device = {
222 .resource = pmu_resources, 222 .resource = pmu_resources,
223}; 223};
224 224
225static void ct_ca9x4_init(void) 225static void __init ct_ca9x4_init(void)
226{ 226{
227 int i; 227 int i;
228 228
@@ -245,8 +245,6 @@ static void ct_ca9x4_init(void)
245} 245}
246 246
247MACHINE_START(VEXPRESS, "ARM-Versatile Express CA9x4") 247MACHINE_START(VEXPRESS, "ARM-Versatile Express CA9x4")
248 .phys_io = V2M_UART0 & SECTION_MASK,
249 .io_pg_offst = (__MMIO_P2V(V2M_UART0) >> 18) & 0xfffc,
250 .boot_params = PHYS_OFFSET + 0x00000100, 248 .boot_params = PHYS_OFFSET + 0x00000100,
251 .map_io = ct_ca9x4_map_io, 249 .map_io = ct_ca9x4_map_io,
252 .init_irq = ct_ca9x4_init_irq, 250 .init_irq = ct_ca9x4_init_irq,
diff --git a/arch/arm/mach-vexpress/include/mach/debug-macro.S b/arch/arm/mach-vexpress/include/mach/debug-macro.S
index 5167e2aceeba..050d65e02a42 100644
--- a/arch/arm/mach-vexpress/include/mach/debug-macro.S
+++ b/arch/arm/mach-vexpress/include/mach/debug-macro.S
@@ -12,12 +12,10 @@
12 12
13#define DEBUG_LL_UART_OFFSET 0x00009000 13#define DEBUG_LL_UART_OFFSET 0x00009000
14 14
15 .macro addruart,rx,tmp 15 .macro addruart,rp,rv
16 mrc p15, 0, \rx, c1, c0 16 mov \rp, #DEBUG_LL_UART_OFFSET
17 tst \rx, #1 @ MMU enabled? 17 orr \rv, \rp, #0xf8000000 @ virtual base
18 moveq \rx, #0x10000000 18 orr \rp, \rp, #0x10000000 @ physical base
19 movne \rx, #0xf8000000 @ virtual base
20 orr \rx, \rx, #DEBUG_LL_UART_OFFSET
21 .endm 19 .endm
22 20
23#include <asm/hardware/debug-pl01x.S> 21#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-vexpress/include/mach/smp.h b/arch/arm/mach-vexpress/include/mach/smp.h
index 72a9621ed087..5a6da4fd247e 100644
--- a/arch/arm/mach-vexpress/include/mach/smp.h
+++ b/arch/arm/mach-vexpress/include/mach/smp.h
@@ -2,14 +2,7 @@
2#define __MACH_SMP_H 2#define __MACH_SMP_H
3 3
4#include <asm/hardware/gic.h> 4#include <asm/hardware/gic.h>
5 5#include <asm/smp_mpidr.h>
6#define hard_smp_processor_id() \
7 ({ \
8 unsigned int cpunum; \
9 __asm__("mrc p15, 0, %0, c0, c0, 5" \
10 : "=r" (cpunum)); \
11 cpunum &= 0x0F; \
12 })
13 6
14/* 7/*
15 * We use IRQ1 as the IPI 8 * We use IRQ1 as the IPI
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 817f0ad38a0b..7eaa232180a5 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -48,7 +48,7 @@ void __init v2m_map_io(struct map_desc *tile, size_t num)
48} 48}
49 49
50 50
51static void v2m_timer_init(void) 51static void __init v2m_timer_init(void)
52{ 52{
53 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL); 53 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
54 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL); 54 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
diff --git a/arch/arm/mach-w90x900/mach-nuc910evb.c b/arch/arm/mach-w90x900/mach-nuc910evb.c
index ec05bda946f3..30fccde94fb8 100644
--- a/arch/arm/mach-w90x900/mach-nuc910evb.c
+++ b/arch/arm/mach-w90x900/mach-nuc910evb.c
@@ -34,8 +34,6 @@ static void __init nuc910evb_init(void)
34 34
35MACHINE_START(W90P910EVB, "W90P910EVB") 35MACHINE_START(W90P910EVB, "W90P910EVB")
36 /* Maintainer: Wan ZongShun */ 36 /* Maintainer: Wan ZongShun */
37 .phys_io = W90X900_PA_UART,
38 .io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
39 .boot_params = 0, 37 .boot_params = 0,
40 .map_io = nuc910evb_map_io, 38 .map_io = nuc910evb_map_io,
41 .init_irq = nuc900_init_irq, 39 .init_irq = nuc900_init_irq,
diff --git a/arch/arm/mach-w90x900/mach-nuc950evb.c b/arch/arm/mach-w90x900/mach-nuc950evb.c
index 04d295f89eb0..590c99b96dc1 100644
--- a/arch/arm/mach-w90x900/mach-nuc950evb.c
+++ b/arch/arm/mach-w90x900/mach-nuc950evb.c
@@ -37,8 +37,6 @@ static void __init nuc950evb_init(void)
37 37
38MACHINE_START(W90P950EVB, "W90P950EVB") 38MACHINE_START(W90P950EVB, "W90P950EVB")
39 /* Maintainer: Wan ZongShun */ 39 /* Maintainer: Wan ZongShun */
40 .phys_io = W90X900_PA_UART,
41 .io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
42 .boot_params = 0, 40 .boot_params = 0,
43 .map_io = nuc950evb_map_io, 41 .map_io = nuc950evb_map_io,
44 .init_irq = nuc900_init_irq, 42 .init_irq = nuc900_init_irq,
diff --git a/arch/arm/mach-w90x900/mach-nuc960evb.c b/arch/arm/mach-w90x900/mach-nuc960evb.c
index e3a46f19f2bc..e09c645d61b6 100644
--- a/arch/arm/mach-w90x900/mach-nuc960evb.c
+++ b/arch/arm/mach-w90x900/mach-nuc960evb.c
@@ -34,8 +34,6 @@ static void __init nuc960evb_init(void)
34 34
35MACHINE_START(W90N960EVB, "W90N960EVB") 35MACHINE_START(W90N960EVB, "W90N960EVB")
36 /* Maintainer: Wan ZongShun */ 36 /* Maintainer: Wan ZongShun */
37 .phys_io = W90X900_PA_UART,
38 .io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
39 .boot_params = 0, 37 .boot_params = 0,
40 .map_io = nuc960evb_map_io, 38 .map_io = nuc960evb_map_io,
41 .init_irq = nuc900_init_irq, 39 .init_irq = nuc900_init_irq,
diff --git a/arch/arm/mm/cache-v6.S b/arch/arm/mm/cache-v6.S
index 86aa689ef1aa..99fa688dfadd 100644
--- a/arch/arm/mm/cache-v6.S
+++ b/arch/arm/mm/cache-v6.S
@@ -21,18 +21,22 @@
21#define D_CACHE_LINE_SIZE 32 21#define D_CACHE_LINE_SIZE 32
22#define BTB_FLUSH_SIZE 8 22#define BTB_FLUSH_SIZE 8
23 23
24#ifdef CONFIG_ARM_ERRATA_411920
25/* 24/*
26 * Invalidate the entire I cache (this code is a workaround for the ARM1136 25 * v6_flush_icache_all()
27 * erratum 411920 - Invalidate Instruction Cache operation can fail. This 26 *
28 * erratum is present in 1136, 1156 and 1176. It does not affect the MPCore. 27 * Flush the whole I-cache.
29 * 28 *
30 * Registers: 29 * ARM1136 erratum 411920 - Invalidate Instruction Cache operation can fail.
31 * r0 - set to 0 30 * This erratum is present in 1136, 1156 and 1176. It does not affect the
32 * r1 - corrupted 31 * MPCore.
32 *
33 * Registers:
34 * r0 - set to 0
35 * r1 - corrupted
33 */ 36 */
34ENTRY(v6_icache_inval_all) 37ENTRY(v6_flush_icache_all)
35 mov r0, #0 38 mov r0, #0
39#ifdef CONFIG_ARM_ERRATA_411920
36 mrs r1, cpsr 40 mrs r1, cpsr
37 cpsid ifa @ disable interrupts 41 cpsid ifa @ disable interrupts
38 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache 42 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
@@ -43,8 +47,11 @@ ENTRY(v6_icache_inval_all)
43 .rept 11 @ ARM Ltd recommends at least 47 .rept 11 @ ARM Ltd recommends at least
44 nop @ 11 NOPs 48 nop @ 11 NOPs
45 .endr 49 .endr
46 mov pc, lr 50#else
51 mcr p15, 0, r0, c7, c5, 0 @ invalidate I-cache
47#endif 52#endif
53 mov pc, lr
54ENDPROC(v6_flush_icache_all)
48 55
49/* 56/*
50 * v6_flush_cache_all() 57 * v6_flush_cache_all()
@@ -60,7 +67,7 @@ ENTRY(v6_flush_kern_cache_all)
60#ifndef CONFIG_ARM_ERRATA_411920 67#ifndef CONFIG_ARM_ERRATA_411920
61 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate 68 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
62#else 69#else
63 b v6_icache_inval_all 70 b v6_flush_icache_all
64#endif 71#endif
65#else 72#else
66 mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate 73 mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
@@ -138,7 +145,7 @@ ENTRY(v6_coherent_user_range)
138#ifndef CONFIG_ARM_ERRATA_411920 145#ifndef CONFIG_ARM_ERRATA_411920
139 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate 146 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
140#else 147#else
141 b v6_icache_inval_all 148 b v6_flush_icache_all
142#endif 149#endif
143#else 150#else
144 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB 151 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
@@ -312,6 +319,7 @@ ENDPROC(v6_dma_unmap_area)
312 319
313 .type v6_cache_fns, #object 320 .type v6_cache_fns, #object
314ENTRY(v6_cache_fns) 321ENTRY(v6_cache_fns)
322 .long v6_flush_icache_all
315 .long v6_flush_kern_cache_all 323 .long v6_flush_kern_cache_all
316 .long v6_flush_user_cache_all 324 .long v6_flush_user_cache_all
317 .long v6_flush_user_cache_range 325 .long v6_flush_user_cache_range
diff --git a/arch/arm/mm/cache-v7.S b/arch/arm/mm/cache-v7.S
index 37c8157e116e..a3ebf7a4f49b 100644
--- a/arch/arm/mm/cache-v7.S
+++ b/arch/arm/mm/cache-v7.S
@@ -18,6 +18,21 @@
18#include "proc-macros.S" 18#include "proc-macros.S"
19 19
20/* 20/*
21 * v7_flush_icache_all()
22 *
23 * Flush the whole I-cache.
24 *
25 * Registers:
26 * r0 - set to 0
27 */
28ENTRY(v7_flush_icache_all)
29 mov r0, #0
30 ALT_SMP(mcr p15, 0, r0, c7, c1, 0) @ invalidate I-cache inner shareable
31 ALT_UP(mcr p15, 0, r0, c7, c5, 0) @ I+BTB cache invalidate
32 mov pc, lr
33ENDPROC(v7_flush_icache_all)
34
35/*
21 * v7_flush_dcache_all() 36 * v7_flush_dcache_all()
22 * 37 *
23 * Flush the whole D-cache. 38 * Flush the whole D-cache.
@@ -91,11 +106,8 @@ ENTRY(v7_flush_kern_cache_all)
91 THUMB( stmfd sp!, {r4-r7, r9-r11, lr} ) 106 THUMB( stmfd sp!, {r4-r7, r9-r11, lr} )
92 bl v7_flush_dcache_all 107 bl v7_flush_dcache_all
93 mov r0, #0 108 mov r0, #0
94#ifdef CONFIG_SMP 109 ALT_SMP(mcr p15, 0, r0, c7, c1, 0) @ invalidate I-cache inner shareable
95 mcr p15, 0, r0, c7, c1, 0 @ invalidate I-cache inner shareable 110 ALT_UP(mcr p15, 0, r0, c7, c5, 0) @ I+BTB cache invalidate
96#else
97 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
98#endif
99 ARM( ldmfd sp!, {r4-r5, r7, r9-r11, lr} ) 111 ARM( ldmfd sp!, {r4-r5, r7, r9-r11, lr} )
100 THUMB( ldmfd sp!, {r4-r7, r9-r11, lr} ) 112 THUMB( ldmfd sp!, {r4-r7, r9-r11, lr} )
101 mov pc, lr 113 mov pc, lr
@@ -171,11 +183,8 @@ ENTRY(v7_coherent_user_range)
171 cmp r0, r1 183 cmp r0, r1
172 blo 1b 184 blo 1b
173 mov r0, #0 185 mov r0, #0
174#ifdef CONFIG_SMP 186 ALT_SMP(mcr p15, 0, r0, c7, c1, 6) @ invalidate BTB Inner Shareable
175 mcr p15, 0, r0, c7, c1, 6 @ invalidate BTB Inner Shareable 187 ALT_UP(mcr p15, 0, r0, c7, c5, 6) @ invalidate BTB
176#else
177 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
178#endif
179 dsb 188 dsb
180 isb 189 isb
181 mov pc, lr 190 mov pc, lr
@@ -309,6 +318,7 @@ ENDPROC(v7_dma_unmap_area)
309 318
310 .type v7_cache_fns, #object 319 .type v7_cache_fns, #object
311ENTRY(v7_cache_fns) 320ENTRY(v7_cache_fns)
321 .long v7_flush_icache_all
312 .long v7_flush_kern_cache_all 322 .long v7_flush_kern_cache_all
313 .long v7_flush_user_cache_all 323 .long v7_flush_user_cache_all
314 .long v7_flush_user_cache_range 324 .long v7_flush_user_cache_range
diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
index 598c51ad5071..b8061519ce77 100644
--- a/arch/arm/mm/copypage-v4mc.c
+++ b/arch/arm/mm/copypage-v4mc.c
@@ -73,7 +73,7 @@ void v4_mc_copy_user_highpage(struct page *to, struct page *from,
73{ 73{
74 void *kto = kmap_atomic(to, KM_USER1); 74 void *kto = kmap_atomic(to, KM_USER1);
75 75
76 if (test_and_clear_bit(PG_dcache_dirty, &from->flags)) 76 if (!test_and_set_bit(PG_dcache_clean, &from->flags))
77 __flush_dcache_page(page_mapping(from), from); 77 __flush_dcache_page(page_mapping(from), from);
78 78
79 spin_lock(&minicache_lock); 79 spin_lock(&minicache_lock);
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index f55fa1044f72..bdba6c65c901 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -79,7 +79,7 @@ static void v6_copy_user_highpage_aliasing(struct page *to,
79 unsigned int offset = CACHE_COLOUR(vaddr); 79 unsigned int offset = CACHE_COLOUR(vaddr);
80 unsigned long kfrom, kto; 80 unsigned long kfrom, kto;
81 81
82 if (test_and_clear_bit(PG_dcache_dirty, &from->flags)) 82 if (!test_and_set_bit(PG_dcache_clean, &from->flags))
83 __flush_dcache_page(page_mapping(from), from); 83 __flush_dcache_page(page_mapping(from), from);
84 84
85 /* FIXME: not highmem safe */ 85 /* FIXME: not highmem safe */
diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
index 9920c0ae2096..649bbcd325bf 100644
--- a/arch/arm/mm/copypage-xscale.c
+++ b/arch/arm/mm/copypage-xscale.c
@@ -95,7 +95,7 @@ void xscale_mc_copy_user_highpage(struct page *to, struct page *from,
95{ 95{
96 void *kto = kmap_atomic(to, KM_USER1); 96 void *kto = kmap_atomic(to, KM_USER1);
97 97
98 if (test_and_clear_bit(PG_dcache_dirty, &from->flags)) 98 if (!test_and_set_bit(PG_dcache_clean, &from->flags))
99 __flush_dcache_page(page_mapping(from), from); 99 __flush_dcache_page(page_mapping(from), from);
100 100
101 spin_lock(&minicache_lock); 101 spin_lock(&minicache_lock);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 4bc43e535d3b..e4dd0646e859 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -523,6 +523,12 @@ void ___dma_page_dev_to_cpu(struct page *page, unsigned long off,
523 outer_inv_range(paddr, paddr + size); 523 outer_inv_range(paddr, paddr + size);
524 524
525 dma_cache_maint_page(page, off, size, dir, dmac_unmap_area); 525 dma_cache_maint_page(page, off, size, dir, dmac_unmap_area);
526
527 /*
528 * Mark the D-cache clean for this page to avoid extra flushing.
529 */
530 if (dir != DMA_TO_DEVICE && off == 0 && size >= PAGE_SIZE)
531 set_bit(PG_dcache_clean, &page->flags);
526} 532}
527EXPORT_SYMBOL(___dma_page_dev_to_cpu); 533EXPORT_SYMBOL(___dma_page_dev_to_cpu);
528 534
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 9b906dec1ca1..8440d952ba6d 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -28,6 +28,7 @@
28 28
29static unsigned long shared_pte_mask = L_PTE_MT_BUFFERABLE; 29static unsigned long shared_pte_mask = L_PTE_MT_BUFFERABLE;
30 30
31#if __LINUX_ARM_ARCH__ < 6
31/* 32/*
32 * We take the easy way out of this problem - we make the 33 * We take the easy way out of this problem - we make the
33 * PTE uncacheable. However, we leave the write buffer on. 34 * PTE uncacheable. However, we leave the write buffer on.
@@ -141,7 +142,7 @@ make_coherent(struct address_space *mapping, struct vm_area_struct *vma,
141 * a page table, or changing an existing PTE. Basically, there are two 142 * a page table, or changing an existing PTE. Basically, there are two
142 * things that we need to take care of: 143 * things that we need to take care of:
143 * 144 *
144 * 1. If PG_dcache_dirty is set for the page, we need to ensure 145 * 1. If PG_dcache_clean is not set for the page, we need to ensure
145 * that any cache entries for the kernels virtual memory 146 * that any cache entries for the kernels virtual memory
146 * range are written back to the page. 147 * range are written back to the page.
147 * 2. If we have multiple shared mappings of the same space in 148 * 2. If we have multiple shared mappings of the same space in
@@ -168,10 +169,8 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
168 return; 169 return;
169 170
170 mapping = page_mapping(page); 171 mapping = page_mapping(page);
171#ifndef CONFIG_SMP 172 if (!test_and_set_bit(PG_dcache_clean, &page->flags))
172 if (test_and_clear_bit(PG_dcache_dirty, &page->flags))
173 __flush_dcache_page(mapping, page); 173 __flush_dcache_page(mapping, page);
174#endif
175 if (mapping) { 174 if (mapping) {
176 if (cache_is_vivt()) 175 if (cache_is_vivt())
177 make_coherent(mapping, vma, addr, ptep, pfn); 176 make_coherent(mapping, vma, addr, ptep, pfn);
@@ -179,6 +178,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr,
179 __flush_icache_all(); 178 __flush_icache_all();
180 } 179 }
181} 180}
181#endif /* __LINUX_ARM_ARCH__ < 6 */
182 182
183/* 183/*
184 * Check whether the write buffer has physical address aliasing 184 * Check whether the write buffer has physical address aliasing
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 23b0b03af5ea..1e21e125fe3a 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -581,6 +581,19 @@ static struct fsr_info ifsr_info[] = {
581 { do_bad, SIGBUS, 0, "unknown 31" }, 581 { do_bad, SIGBUS, 0, "unknown 31" },
582}; 582};
583 583
584void __init
585hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
586 int sig, int code, const char *name)
587{
588 if (nr < 0 || nr >= ARRAY_SIZE(ifsr_info))
589 BUG();
590
591 ifsr_info[nr].fn = fn;
592 ifsr_info[nr].sig = sig;
593 ifsr_info[nr].code = code;
594 ifsr_info[nr].name = name;
595}
596
584asmlinkage void __exception 597asmlinkage void __exception
585do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs) 598do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
586{ 599{
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index c6844cb9b508..391ffae75098 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -17,6 +17,7 @@
17#include <asm/smp_plat.h> 17#include <asm/smp_plat.h>
18#include <asm/system.h> 18#include <asm/system.h>
19#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
20#include <asm/smp_plat.h>
20 21
21#include "mm.h" 22#include "mm.h"
22 23
@@ -39,6 +40,18 @@ static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
39 : "cc"); 40 : "cc");
40} 41}
41 42
43static void flush_icache_alias(unsigned long pfn, unsigned long vaddr, unsigned long len)
44{
45 unsigned long colour = CACHE_COLOUR(vaddr);
46 unsigned long offset = vaddr & (PAGE_SIZE - 1);
47 unsigned long to;
48
49 set_pte_ext(TOP_PTE(ALIAS_FLUSH_START) + colour, pfn_pte(pfn, PAGE_KERNEL), 0);
50 to = ALIAS_FLUSH_START + (colour << PAGE_SHIFT) + offset;
51 flush_tlb_kernel_page(to);
52 flush_icache_range(to, to + len);
53}
54
42void flush_cache_mm(struct mm_struct *mm) 55void flush_cache_mm(struct mm_struct *mm)
43{ 56{
44 if (cache_is_vivt()) { 57 if (cache_is_vivt()) {
@@ -89,16 +102,16 @@ void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
89 if (vma->vm_flags & VM_EXEC && icache_is_vivt_asid_tagged()) 102 if (vma->vm_flags & VM_EXEC && icache_is_vivt_asid_tagged())
90 __flush_icache_all(); 103 __flush_icache_all();
91} 104}
105
92#else 106#else
93#define flush_pfn_alias(pfn,vaddr) do { } while (0) 107#define flush_pfn_alias(pfn,vaddr) do { } while (0)
108#define flush_icache_alias(pfn,vaddr,len) do { } while (0)
94#endif 109#endif
95 110
96#ifdef CONFIG_SMP
97static void flush_ptrace_access_other(void *args) 111static void flush_ptrace_access_other(void *args)
98{ 112{
99 __flush_icache_all(); 113 __flush_icache_all();
100} 114}
101#endif
102 115
103static 116static
104void flush_ptrace_access(struct vm_area_struct *vma, struct page *page, 117void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
@@ -118,15 +131,16 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
118 return; 131 return;
119 } 132 }
120 133
121 /* VIPT non-aliasing cache */ 134 /* VIPT non-aliasing D-cache */
122 if (vma->vm_flags & VM_EXEC) { 135 if (vma->vm_flags & VM_EXEC) {
123 unsigned long addr = (unsigned long)kaddr; 136 unsigned long addr = (unsigned long)kaddr;
124 __cpuc_coherent_kern_range(addr, addr + len); 137 if (icache_is_vipt_aliasing())
125#ifdef CONFIG_SMP 138 flush_icache_alias(page_to_pfn(page), uaddr, len);
139 else
140 __cpuc_coherent_kern_range(addr, addr + len);
126 if (cache_ops_need_broadcast()) 141 if (cache_ops_need_broadcast())
127 smp_call_function(flush_ptrace_access_other, 142 smp_call_function(flush_ptrace_access_other,
128 NULL, 1); 143 NULL, 1);
129#endif
130 } 144 }
131} 145}
132 146
@@ -215,6 +229,36 @@ static void __flush_dcache_aliases(struct address_space *mapping, struct page *p
215 flush_dcache_mmap_unlock(mapping); 229 flush_dcache_mmap_unlock(mapping);
216} 230}
217 231
232#if __LINUX_ARM_ARCH__ >= 6
233void __sync_icache_dcache(pte_t pteval)
234{
235 unsigned long pfn;
236 struct page *page;
237 struct address_space *mapping;
238
239 if (!pte_present_user(pteval))
240 return;
241 if (cache_is_vipt_nonaliasing() && !pte_exec(pteval))
242 /* only flush non-aliasing VIPT caches for exec mappings */
243 return;
244 pfn = pte_pfn(pteval);
245 if (!pfn_valid(pfn))
246 return;
247
248 page = pfn_to_page(pfn);
249 if (cache_is_vipt_aliasing())
250 mapping = page_mapping(page);
251 else
252 mapping = NULL;
253
254 if (!test_and_set_bit(PG_dcache_clean, &page->flags))
255 __flush_dcache_page(mapping, page);
256 /* pte_exec() already checked above for non-aliasing VIPT cache */
257 if (cache_is_vipt_nonaliasing() || pte_exec(pteval))
258 __flush_icache_all();
259}
260#endif
261
218/* 262/*
219 * Ensure cache coherency between kernel mapping and userspace mapping 263 * Ensure cache coherency between kernel mapping and userspace mapping
220 * of this page. 264 * of this page.
@@ -246,17 +290,16 @@ void flush_dcache_page(struct page *page)
246 290
247 mapping = page_mapping(page); 291 mapping = page_mapping(page);
248 292
249#ifndef CONFIG_SMP 293 if (!cache_ops_need_broadcast() &&
250 if (!PageHighMem(page) && mapping && !mapping_mapped(mapping)) 294 mapping && !mapping_mapped(mapping))
251 set_bit(PG_dcache_dirty, &page->flags); 295 clear_bit(PG_dcache_clean, &page->flags);
252 else 296 else {
253#endif
254 {
255 __flush_dcache_page(mapping, page); 297 __flush_dcache_page(mapping, page);
256 if (mapping && cache_is_vivt()) 298 if (mapping && cache_is_vivt())
257 __flush_dcache_aliases(mapping, page); 299 __flush_dcache_aliases(mapping, page);
258 else if (mapping) 300 else if (mapping)
259 __flush_icache_all(); 301 __flush_icache_all();
302 set_bit(PG_dcache_clean, &page->flags);
260 } 303 }
261} 304}
262EXPORT_SYMBOL(flush_dcache_page); 305EXPORT_SYMBOL(flush_dcache_page);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 7185b00650fe..7fd9b5eb177f 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -150,6 +150,7 @@ static void __init find_limits(struct meminfo *mi,
150static void __init arm_bootmem_init(struct meminfo *mi, 150static void __init arm_bootmem_init(struct meminfo *mi,
151 unsigned long start_pfn, unsigned long end_pfn) 151 unsigned long start_pfn, unsigned long end_pfn)
152{ 152{
153 struct memblock_region *reg;
153 unsigned int boot_pages; 154 unsigned int boot_pages;
154 phys_addr_t bitmap; 155 phys_addr_t bitmap;
155 pg_data_t *pgdat; 156 pg_data_t *pgdat;
@@ -180,13 +181,13 @@ static void __init arm_bootmem_init(struct meminfo *mi,
180 /* 181 /*
181 * Reserve the memblock reserved regions in bootmem. 182 * Reserve the memblock reserved regions in bootmem.
182 */ 183 */
183 for (i = 0; i < memblock.reserved.cnt; i++) { 184 for_each_memblock(reserved, reg) {
184 phys_addr_t start = memblock_start_pfn(&memblock.reserved, i); 185 phys_addr_t start = memblock_region_reserved_base_pfn(reg);
185 if (start >= start_pfn && 186 phys_addr_t end = memblock_region_reserved_end_pfn(reg);
186 memblock_end_pfn(&memblock.reserved, i) <= end_pfn) 187 if (start >= start_pfn && end <= end_pfn)
187 reserve_bootmem_node(pgdat, __pfn_to_phys(start), 188 reserve_bootmem_node(pgdat, __pfn_to_phys(start),
188 memblock_size_bytes(&memblock.reserved, i), 189 (end - start) << PAGE_SHIFT,
189 BOOTMEM_DEFAULT); 190 BOOTMEM_DEFAULT);
190 } 191 }
191} 192}
192 193
@@ -237,20 +238,7 @@ static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min,
237#ifndef CONFIG_SPARSEMEM 238#ifndef CONFIG_SPARSEMEM
238int pfn_valid(unsigned long pfn) 239int pfn_valid(unsigned long pfn)
239{ 240{
240 struct memblock_region *mem = &memblock.memory; 241 return memblock_is_memory(pfn << PAGE_SHIFT);
241 unsigned int left = 0, right = mem->cnt;
242
243 do {
244 unsigned int mid = (right + left) / 2;
245
246 if (pfn < memblock_start_pfn(mem, mid))
247 right = mid;
248 else if (pfn >= memblock_end_pfn(mem, mid))
249 left = mid + 1;
250 else
251 return 1;
252 } while (left < right);
253 return 0;
254} 242}
255EXPORT_SYMBOL(pfn_valid); 243EXPORT_SYMBOL(pfn_valid);
256 244
@@ -260,10 +248,11 @@ static void arm_memory_present(void)
260#else 248#else
261static void arm_memory_present(void) 249static void arm_memory_present(void)
262{ 250{
263 int i; 251 struct memblock_region *reg;
264 for (i = 0; i < memblock.memory.cnt; i++) 252
265 memory_present(0, memblock_start_pfn(&memblock.memory, i), 253 for_each_memblock(memory, reg)
266 memblock_end_pfn(&memblock.memory, i)); 254 memory_present(0, memblock_region_memory_base_pfn(reg),
255 memblock_region_memory_end_pfn(reg));
267} 256}
268#endif 257#endif
269 258
@@ -277,7 +266,7 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
277 266
278 /* Register the kernel text, kernel data and initrd with memblock. */ 267 /* Register the kernel text, kernel data and initrd with memblock. */
279#ifdef CONFIG_XIP_KERNEL 268#ifdef CONFIG_XIP_KERNEL
280 memblock_reserve(__pa(_data), _end - _data); 269 memblock_reserve(__pa(_sdata), _end - _sdata);
281#else 270#else
282 memblock_reserve(__pa(_stext), _end - _stext); 271 memblock_reserve(__pa(_stext), _end - _stext);
283#endif 272#endif
@@ -545,7 +534,7 @@ void __init mem_init(void)
545 534
546 MLK_ROUNDUP(__init_begin, __init_end), 535 MLK_ROUNDUP(__init_begin, __init_end),
547 MLK_ROUNDUP(_text, _etext), 536 MLK_ROUNDUP(_text, _etext),
548 MLK_ROUNDUP(_data, _edata)); 537 MLK_ROUNDUP(_sdata, _edata));
549 538
550#undef MLK 539#undef MLK
551#undef MLM 540#undef MLM
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index ab506272b2d3..17e7b0b57e49 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -204,8 +204,12 @@ void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn,
204 /* 204 /*
205 * Don't allow RAM to be mapped - this causes problems with ARMv6+ 205 * Don't allow RAM to be mapped - this causes problems with ARMv6+
206 */ 206 */
207 if (WARN_ON(pfn_valid(pfn))) 207 if (pfn_valid(pfn)) {
208 return NULL; 208 printk(KERN_WARNING "BUG: Your driver calls ioremap() on system memory. This leads\n"
209 KERN_WARNING "to architecturally unpredictable behaviour on ARMv6+, and ioremap()\n"
210 KERN_WARNING "will fail in the next kernel release. Please fix your driver.\n");
211 WARN_ON(1);
212 }
209 213
210 type = get_mem_type(mtype); 214 type = get_mem_type(mtype);
211 if (!type) 215 if (!type)
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 4f5b39687df5..b0a98305055c 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -144,3 +144,25 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
144{ 144{
145 return !(pfn + (size >> PAGE_SHIFT) > 0x00100000); 145 return !(pfn + (size >> PAGE_SHIFT) > 0x00100000);
146} 146}
147
148#ifdef CONFIG_STRICT_DEVMEM
149
150#include <linux/ioport.h>
151
152/*
153 * devmem_is_allowed() checks to see if /dev/mem access to a certain
154 * address is valid. The argument is a physical page number.
155 * We mimic x86 here by disallowing access to system RAM as well as
156 * device-exclusive MMIO regions. This effectively disable read()/write()
157 * on /dev/mem.
158 */
159int devmem_is_allowed(unsigned long pfn)
160{
161 if (iomem_is_exclusive(pfn << PAGE_SHIFT))
162 return 0;
163 if (!page_is_ram(pfn))
164 return 1;
165 return 0;
166}
167
168#endif
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 6a3a2d0cd6db..c32f731d56d3 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -248,7 +248,7 @@ static struct mem_type mem_types[] = {
248 }, 248 },
249 [MT_MEMORY] = { 249 [MT_MEMORY] = {
250 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | 250 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
251 L_PTE_USER | L_PTE_EXEC, 251 L_PTE_WRITE | L_PTE_EXEC,
252 .prot_l1 = PMD_TYPE_TABLE, 252 .prot_l1 = PMD_TYPE_TABLE,
253 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE, 253 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
254 .domain = DOMAIN_KERNEL, 254 .domain = DOMAIN_KERNEL,
@@ -259,7 +259,7 @@ static struct mem_type mem_types[] = {
259 }, 259 },
260 [MT_MEMORY_NONCACHED] = { 260 [MT_MEMORY_NONCACHED] = {
261 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | 261 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
262 L_PTE_USER | L_PTE_EXEC | L_PTE_MT_BUFFERABLE, 262 L_PTE_WRITE | L_PTE_EXEC | L_PTE_MT_BUFFERABLE,
263 .prot_l1 = PMD_TYPE_TABLE, 263 .prot_l1 = PMD_TYPE_TABLE,
264 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE, 264 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
265 .domain = DOMAIN_KERNEL, 265 .domain = DOMAIN_KERNEL,
@@ -310,9 +310,8 @@ static void __init build_mem_type_table(void)
310 cachepolicy = CPOLICY_WRITEBACK; 310 cachepolicy = CPOLICY_WRITEBACK;
311 ecc_mask = 0; 311 ecc_mask = 0;
312 } 312 }
313#ifdef CONFIG_SMP 313 if (is_smp())
314 cachepolicy = CPOLICY_WRITEALLOC; 314 cachepolicy = CPOLICY_WRITEALLOC;
315#endif
316 315
317 /* 316 /*
318 * Strip out features not present on earlier architectures. 317 * Strip out features not present on earlier architectures.
@@ -406,13 +405,11 @@ static void __init build_mem_type_table(void)
406 cp = &cache_policies[cachepolicy]; 405 cp = &cache_policies[cachepolicy];
407 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte; 406 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
408 407
409#ifndef CONFIG_SMP
410 /* 408 /*
411 * Only use write-through for non-SMP systems 409 * Only use write-through for non-SMP systems
412 */ 410 */
413 if (cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH) 411 if (!is_smp() && cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH)
414 vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte; 412 vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte;
415#endif
416 413
417 /* 414 /*
418 * Enable CPU-specific coherency if supported. 415 * Enable CPU-specific coherency if supported.
@@ -436,22 +433,23 @@ static void __init build_mem_type_table(void)
436 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 433 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
437 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE; 434 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
438 435
439#ifdef CONFIG_SMP 436 if (is_smp()) {
440 /* 437 /*
441 * Mark memory with the "shared" attribute for SMP systems 438 * Mark memory with the "shared" attribute
442 */ 439 * for SMP systems
443 user_pgprot |= L_PTE_SHARED; 440 */
444 kern_pgprot |= L_PTE_SHARED; 441 user_pgprot |= L_PTE_SHARED;
445 vecs_pgprot |= L_PTE_SHARED; 442 kern_pgprot |= L_PTE_SHARED;
446 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_S; 443 vecs_pgprot |= L_PTE_SHARED;
447 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED; 444 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_S;
448 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S; 445 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
449 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED; 446 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
450 mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S; 447 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
451 mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED; 448 mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
452 mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S; 449 mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
453 mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED; 450 mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
454#endif 451 mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
452 }
455 } 453 }
456 454
457 /* 455 /*
@@ -829,8 +827,7 @@ static void __init sanity_check_meminfo(void)
829 * rather difficult. 827 * rather difficult.
830 */ 828 */
831 reason = "with VIPT aliasing cache"; 829 reason = "with VIPT aliasing cache";
832#ifdef CONFIG_SMP 830 } else if (is_smp() && tlb_ops_need_broadcast()) {
833 } else if (tlb_ops_need_broadcast()) {
834 /* 831 /*
835 * kmap_high needs to occasionally flush TLB entries, 832 * kmap_high needs to occasionally flush TLB entries,
836 * however, if the TLB entries need to be broadcast 833 * however, if the TLB entries need to be broadcast
@@ -840,7 +837,6 @@ static void __init sanity_check_meminfo(void)
840 * (must not be called with irqs off) 837 * (must not be called with irqs off)
841 */ 838 */
842 reason = "without hardware TLB ops broadcasting"; 839 reason = "without hardware TLB ops broadcasting";
843#endif
844 } 840 }
845 if (reason) { 841 if (reason) {
846 printk(KERN_CRIT "HIGHMEM is not supported %s, ignoring high memory\n", 842 printk(KERN_CRIT "HIGHMEM is not supported %s, ignoring high memory\n",
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 203a4e944d9e..a6f5f8475b96 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -430,7 +430,7 @@ ENTRY(cpu_arm1020_set_pte_ext)
430#endif /* CONFIG_MMU */ 430#endif /* CONFIG_MMU */
431 mov pc, lr 431 mov pc, lr
432 432
433 __INIT 433 __CPUINIT
434 434
435 .type __arm1020_setup, #function 435 .type __arm1020_setup, #function
436__arm1020_setup: 436__arm1020_setup:
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 1a511e765909..afc06b9c3133 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -412,7 +412,7 @@ ENTRY(cpu_arm1020e_set_pte_ext)
412#endif /* CONFIG_MMU */ 412#endif /* CONFIG_MMU */
413 mov pc, lr 413 mov pc, lr
414 414
415 __INIT 415 __CPUINIT
416 416
417 .type __arm1020e_setup, #function 417 .type __arm1020e_setup, #function
418__arm1020e_setup: 418__arm1020e_setup:
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 1ffa4eb9c34f..8915e0ba3fe5 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -394,7 +394,7 @@ ENTRY(cpu_arm1022_set_pte_ext)
394#endif /* CONFIG_MMU */ 394#endif /* CONFIG_MMU */
395 mov pc, lr 395 mov pc, lr
396 396
397 __INIT 397 __CPUINIT
398 398
399 .type __arm1022_setup, #function 399 .type __arm1022_setup, #function
400__arm1022_setup: 400__arm1022_setup:
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index 5697c34b95b0..ff446c5d476f 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -384,7 +384,7 @@ ENTRY(cpu_arm1026_set_pte_ext)
384 mov pc, lr 384 mov pc, lr
385 385
386 386
387 __INIT 387 __CPUINIT
388 388
389 .type __arm1026_setup, #function 389 .type __arm1026_setup, #function
390__arm1026_setup: 390__arm1026_setup:
diff --git a/arch/arm/mm/proc-arm6_7.S b/arch/arm/mm/proc-arm6_7.S
index 64e0b327c7c5..6a7be1863edd 100644
--- a/arch/arm/mm/proc-arm6_7.S
+++ b/arch/arm/mm/proc-arm6_7.S
@@ -238,7 +238,7 @@ ENTRY(cpu_arm7_reset)
238 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc 238 mcr p15, 0, r1, c1, c0, 0 @ turn off MMU etc
239 mov pc, r0 239 mov pc, r0
240 240
241 __INIT 241 __CPUINIT
242 242
243 .type __arm6_setup, #function 243 .type __arm6_setup, #function
244__arm6_setup: mov r0, #0 244__arm6_setup: mov r0, #0
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index 9d96824134fc..c285395f44b2 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -113,7 +113,7 @@ ENTRY(cpu_arm720_reset)
113 mcr p15, 0, ip, c1, c0, 0 @ ctrl register 113 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
114 mov pc, r0 114 mov pc, r0
115 115
116 __INIT 116 __CPUINIT
117 117
118 .type __arm710_setup, #function 118 .type __arm710_setup, #function
119__arm710_setup: 119__arm710_setup:
diff --git a/arch/arm/mm/proc-arm740.S b/arch/arm/mm/proc-arm740.S
index 6c1a9ab059ae..38b27dcba727 100644
--- a/arch/arm/mm/proc-arm740.S
+++ b/arch/arm/mm/proc-arm740.S
@@ -55,7 +55,7 @@ ENTRY(cpu_arm740_reset)
55 mcr p15, 0, ip, c1, c0, 0 @ ctrl register 55 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
56 mov pc, r0 56 mov pc, r0
57 57
58 __INIT 58 __CPUINIT
59 59
60 .type __arm740_setup, #function 60 .type __arm740_setup, #function
61__arm740_setup: 61__arm740_setup:
diff --git a/arch/arm/mm/proc-arm7tdmi.S b/arch/arm/mm/proc-arm7tdmi.S
index 6a850dbba22e..0c9786de20af 100644
--- a/arch/arm/mm/proc-arm7tdmi.S
+++ b/arch/arm/mm/proc-arm7tdmi.S
@@ -46,7 +46,7 @@ ENTRY(cpu_arm7tdmi_proc_fin)
46ENTRY(cpu_arm7tdmi_reset) 46ENTRY(cpu_arm7tdmi_reset)
47 mov pc, r0 47 mov pc, r0
48 48
49 __INIT 49 __CPUINIT
50 50
51 .type __arm7tdmi_setup, #function 51 .type __arm7tdmi_setup, #function
52__arm7tdmi_setup: 52__arm7tdmi_setup:
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index 86f80aa56216..fecf570939f3 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -375,7 +375,7 @@ ENTRY(cpu_arm920_set_pte_ext)
375#endif 375#endif
376 mov pc, lr 376 mov pc, lr
377 377
378 __INIT 378 __CPUINIT
379 379
380 .type __arm920_setup, #function 380 .type __arm920_setup, #function
381__arm920_setup: 381__arm920_setup:
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index f76ce9b62883..e3cbf87c9480 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -379,7 +379,7 @@ ENTRY(cpu_arm922_set_pte_ext)
379#endif /* CONFIG_MMU */ 379#endif /* CONFIG_MMU */
380 mov pc, lr 380 mov pc, lr
381 381
382 __INIT 382 __CPUINIT
383 383
384 .type __arm922_setup, #function 384 .type __arm922_setup, #function
385__arm922_setup: 385__arm922_setup:
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index 657bd3f7c153..572424c867b5 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -428,7 +428,7 @@ ENTRY(cpu_arm925_set_pte_ext)
428#endif /* CONFIG_MMU */ 428#endif /* CONFIG_MMU */
429 mov pc, lr 429 mov pc, lr
430 430
431 __INIT 431 __CPUINIT
432 432
433 .type __arm925_setup, #function 433 .type __arm925_setup, #function
434__arm925_setup: 434__arm925_setup:
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 73f1f3c68910..63d168b4ebe6 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -389,7 +389,7 @@ ENTRY(cpu_arm926_set_pte_ext)
389#endif 389#endif
390 mov pc, lr 390 mov pc, lr
391 391
392 __INIT 392 __CPUINIT
393 393
394 .type __arm926_setup, #function 394 .type __arm926_setup, #function
395__arm926_setup: 395__arm926_setup:
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S
index fffb061a45a5..f6a62822418e 100644
--- a/arch/arm/mm/proc-arm940.S
+++ b/arch/arm/mm/proc-arm940.S
@@ -264,7 +264,7 @@ ENTRY(arm940_cache_fns)
264 .long arm940_dma_unmap_area 264 .long arm940_dma_unmap_area
265 .long arm940_dma_flush_range 265 .long arm940_dma_flush_range
266 266
267 __INIT 267 __CPUINIT
268 268
269 .type __arm940_setup, #function 269 .type __arm940_setup, #function
270__arm940_setup: 270__arm940_setup:
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S
index 249a6053760a..ea2e7f2eb95b 100644
--- a/arch/arm/mm/proc-arm946.S
+++ b/arch/arm/mm/proc-arm946.S
@@ -317,7 +317,7 @@ ENTRY(cpu_arm946_dcache_clean_area)
317 mcr p15, 0, r0, c7, c10, 4 @ drain WB 317 mcr p15, 0, r0, c7, c10, 4 @ drain WB
318 mov pc, lr 318 mov pc, lr
319 319
320 __INIT 320 __CPUINIT
321 321
322 .type __arm946_setup, #function 322 .type __arm946_setup, #function
323__arm946_setup: 323__arm946_setup:
diff --git a/arch/arm/mm/proc-arm9tdmi.S b/arch/arm/mm/proc-arm9tdmi.S
index db475667fac2..db67e3134d7a 100644
--- a/arch/arm/mm/proc-arm9tdmi.S
+++ b/arch/arm/mm/proc-arm9tdmi.S
@@ -46,7 +46,7 @@ ENTRY(cpu_arm9tdmi_proc_fin)
46ENTRY(cpu_arm9tdmi_reset) 46ENTRY(cpu_arm9tdmi_reset)
47 mov pc, r0 47 mov pc, r0
48 48
49 __INIT 49 __CPUINIT
50 50
51 .type __arm9tdmi_setup, #function 51 .type __arm9tdmi_setup, #function
52__arm9tdmi_setup: 52__arm9tdmi_setup:
diff --git a/arch/arm/mm/proc-fa526.S b/arch/arm/mm/proc-fa526.S
index 7803fdf70029..7c9ad621f0e6 100644
--- a/arch/arm/mm/proc-fa526.S
+++ b/arch/arm/mm/proc-fa526.S
@@ -134,7 +134,7 @@ ENTRY(cpu_fa526_set_pte_ext)
134#endif 134#endif
135 mov pc, lr 135 mov pc, lr
136 136
137 __INIT 137 __CPUINIT
138 138
139 .type __fa526_setup, #function 139 .type __fa526_setup, #function
140__fa526_setup: 140__fa526_setup:
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S
index b304d0104a4e..578da69200cf 100644
--- a/arch/arm/mm/proc-feroceon.S
+++ b/arch/arm/mm/proc-feroceon.S
@@ -494,7 +494,7 @@ ENTRY(cpu_feroceon_set_pte_ext)
494#endif 494#endif
495 mov pc, lr 495 mov pc, lr
496 496
497 __INIT 497 __CPUINIT
498 498
499 .type __feroceon_setup, #function 499 .type __feroceon_setup, #function
500__feroceon_setup: 500__feroceon_setup:
diff --git a/arch/arm/mm/proc-mohawk.S b/arch/arm/mm/proc-mohawk.S
index 5f6892fcc167..4458ee6aa713 100644
--- a/arch/arm/mm/proc-mohawk.S
+++ b/arch/arm/mm/proc-mohawk.S
@@ -338,7 +338,7 @@ ENTRY(cpu_mohawk_set_pte_ext)
338 mcr p15, 0, r0, c7, c10, 4 @ drain WB 338 mcr p15, 0, r0, c7, c10, 4 @ drain WB
339 mov pc, lr 339 mov pc, lr
340 340
341 __INIT 341 __CPUINIT
342 342
343 .type __mohawk_setup, #function 343 .type __mohawk_setup, #function
344__mohawk_setup: 344__mohawk_setup:
diff --git a/arch/arm/mm/proc-sa110.S b/arch/arm/mm/proc-sa110.S
index a201eb04b5e1..5aa8d59c2e85 100644
--- a/arch/arm/mm/proc-sa110.S
+++ b/arch/arm/mm/proc-sa110.S
@@ -156,7 +156,7 @@ ENTRY(cpu_sa110_set_pte_ext)
156#endif 156#endif
157 mov pc, lr 157 mov pc, lr
158 158
159 __INIT 159 __CPUINIT
160 160
161 .type __sa110_setup, #function 161 .type __sa110_setup, #function
162__sa110_setup: 162__sa110_setup:
diff --git a/arch/arm/mm/proc-sa1100.S b/arch/arm/mm/proc-sa1100.S
index 7ddc4805bf97..2ac4e6f10713 100644
--- a/arch/arm/mm/proc-sa1100.S
+++ b/arch/arm/mm/proc-sa1100.S
@@ -169,7 +169,7 @@ ENTRY(cpu_sa1100_set_pte_ext)
169#endif 169#endif
170 mov pc, lr 170 mov pc, lr
171 171
172 __INIT 172 __CPUINIT
173 173
174 .type __sa1100_setup, #function 174 .type __sa1100_setup, #function
175__sa1100_setup: 175__sa1100_setup:
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 22aac8515196..59a7e1ffe7bc 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -30,13 +30,10 @@
30#define TTB_RGN_WT (2 << 3) 30#define TTB_RGN_WT (2 << 3)
31#define TTB_RGN_WB (3 << 3) 31#define TTB_RGN_WB (3 << 3)
32 32
33#ifndef CONFIG_SMP 33#define TTB_FLAGS_UP TTB_RGN_WBWA
34#define TTB_FLAGS TTB_RGN_WBWA 34#define PMD_FLAGS_UP PMD_SECT_WB
35#define PMD_FLAGS PMD_SECT_WB 35#define TTB_FLAGS_SMP TTB_RGN_WBWA|TTB_S
36#else 36#define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S
37#define TTB_FLAGS TTB_RGN_WBWA|TTB_S
38#define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S
39#endif
40 37
41ENTRY(cpu_v6_proc_init) 38ENTRY(cpu_v6_proc_init)
42 mov pc, lr 39 mov pc, lr
@@ -97,7 +94,8 @@ ENTRY(cpu_v6_switch_mm)
97#ifdef CONFIG_MMU 94#ifdef CONFIG_MMU
98 mov r2, #0 95 mov r2, #0
99 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id 96 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
100 orr r0, r0, #TTB_FLAGS 97 ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP)
98 ALT_UP(orr r0, r0, #TTB_FLAGS_UP)
101 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 99 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
102 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer 100 mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
103 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0 101 mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
@@ -137,7 +135,7 @@ cpu_pj4_name:
137 135
138 .align 136 .align
139 137
140 __INIT 138 __CPUINIT
141 139
142/* 140/*
143 * __v6_setup 141 * __v6_setup
@@ -156,9 +154,11 @@ cpu_pj4_name:
156 */ 154 */
157__v6_setup: 155__v6_setup:
158#ifdef CONFIG_SMP 156#ifdef CONFIG_SMP
159 mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode 157 ALT_SMP(mrc p15, 0, r0, c1, c0, 1) @ Enable SMP/nAMP mode
158 ALT_UP(nop)
160 orr r0, r0, #0x20 159 orr r0, r0, #0x20
161 mcr p15, 0, r0, c1, c0, 1 160 ALT_SMP(mcr p15, 0, r0, c1, c0, 1)
161 ALT_UP(nop)
162#endif 162#endif
163 163
164 mov r0, #0 164 mov r0, #0
@@ -169,7 +169,8 @@ __v6_setup:
169#ifdef CONFIG_MMU 169#ifdef CONFIG_MMU
170 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs 170 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
171 mcr p15, 0, r0, c2, c0, 2 @ TTB control register 171 mcr p15, 0, r0, c2, c0, 2 @ TTB control register
172 orr r4, r4, #TTB_FLAGS 172 ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP)
173 ALT_UP(orr r4, r4, #TTB_FLAGS_UP)
173 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 174 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
174#endif /* CONFIG_MMU */ 175#endif /* CONFIG_MMU */
175 adr r5, v6_crval 176 adr r5, v6_crval
@@ -192,6 +193,8 @@ __v6_setup:
192v6_crval: 193v6_crval:
193 crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c 194 crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c
194 195
196 __INITDATA
197
195 .type v6_processor_functions, #object 198 .type v6_processor_functions, #object
196ENTRY(v6_processor_functions) 199ENTRY(v6_processor_functions)
197 .word v6_early_abort 200 .word v6_early_abort
@@ -205,6 +208,8 @@ ENTRY(v6_processor_functions)
205 .word cpu_v6_set_pte_ext 208 .word cpu_v6_set_pte_ext
206 .size v6_processor_functions, . - v6_processor_functions 209 .size v6_processor_functions, . - v6_processor_functions
207 210
211 .section ".rodata"
212
208 .type cpu_arch_name, #object 213 .type cpu_arch_name, #object
209cpu_arch_name: 214cpu_arch_name:
210 .asciz "armv6" 215 .asciz "armv6"
@@ -225,10 +230,16 @@ cpu_elf_name:
225__v6_proc_info: 230__v6_proc_info:
226 .long 0x0007b000 231 .long 0x0007b000
227 .long 0x0007f000 232 .long 0x0007f000
228 .long PMD_TYPE_SECT | \ 233 ALT_SMP(.long \
234 PMD_TYPE_SECT | \
229 PMD_SECT_AP_WRITE | \ 235 PMD_SECT_AP_WRITE | \
230 PMD_SECT_AP_READ | \ 236 PMD_SECT_AP_READ | \
231 PMD_FLAGS 237 PMD_FLAGS_SMP)
238 ALT_UP(.long \
239 PMD_TYPE_SECT | \
240 PMD_SECT_AP_WRITE | \
241 PMD_SECT_AP_READ | \
242 PMD_FLAGS_UP)
232 .long PMD_TYPE_SECT | \ 243 .long PMD_TYPE_SECT | \
233 PMD_SECT_XN | \ 244 PMD_SECT_XN | \
234 PMD_SECT_AP_WRITE | \ 245 PMD_SECT_AP_WRITE | \
@@ -249,10 +260,16 @@ __v6_proc_info:
249__pj4_v6_proc_info: 260__pj4_v6_proc_info:
250 .long 0x560f5810 261 .long 0x560f5810
251 .long 0xff0ffff0 262 .long 0xff0ffff0
252 .long PMD_TYPE_SECT | \ 263 ALT_SMP(.long \
264 PMD_TYPE_SECT | \
265 PMD_SECT_AP_WRITE | \
266 PMD_SECT_AP_READ | \
267 PMD_FLAGS_SMP)
268 ALT_UP(.long \
269 PMD_TYPE_SECT | \
253 PMD_SECT_AP_WRITE | \ 270 PMD_SECT_AP_WRITE | \
254 PMD_SECT_AP_READ | \ 271 PMD_SECT_AP_READ | \
255 PMD_FLAGS 272 PMD_FLAGS_UP)
256 .long PMD_TYPE_SECT | \ 273 .long PMD_TYPE_SECT | \
257 PMD_SECT_XN | \ 274 PMD_SECT_XN | \
258 PMD_SECT_AP_WRITE | \ 275 PMD_SECT_AP_WRITE | \
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 7563ff0141bd..53cbe2225153 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -30,15 +30,13 @@
30#define TTB_IRGN_WT ((1 << 0) | (0 << 6)) 30#define TTB_IRGN_WT ((1 << 0) | (0 << 6))
31#define TTB_IRGN_WB ((1 << 0) | (1 << 6)) 31#define TTB_IRGN_WB ((1 << 0) | (1 << 6))
32 32
33#ifndef CONFIG_SMP
34/* PTWs cacheable, inner WB not shareable, outer WB not shareable */ 33/* PTWs cacheable, inner WB not shareable, outer WB not shareable */
35#define TTB_FLAGS TTB_IRGN_WB|TTB_RGN_OC_WB 34#define TTB_FLAGS_UP TTB_IRGN_WB|TTB_RGN_OC_WB
36#define PMD_FLAGS PMD_SECT_WB 35#define PMD_FLAGS_UP PMD_SECT_WB
37#else 36
38/* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */ 37/* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */
39#define TTB_FLAGS TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA 38#define TTB_FLAGS_SMP TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA
40#define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S 39#define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S
41#endif
42 40
43ENTRY(cpu_v7_proc_init) 41ENTRY(cpu_v7_proc_init)
44 mov pc, lr 42 mov pc, lr
@@ -105,7 +103,8 @@ ENTRY(cpu_v7_switch_mm)
105#ifdef CONFIG_MMU 103#ifdef CONFIG_MMU
106 mov r2, #0 104 mov r2, #0
107 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id 105 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
108 orr r0, r0, #TTB_FLAGS 106 ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP)
107 ALT_UP(orr r0, r0, #TTB_FLAGS_UP)
109#ifdef CONFIG_ARM_ERRATA_430973 108#ifdef CONFIG_ARM_ERRATA_430973
110 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB 109 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
111#endif 110#endif
@@ -169,7 +168,7 @@ cpu_v7_name:
169 .ascii "ARMv7 Processor" 168 .ascii "ARMv7 Processor"
170 .align 169 .align
171 170
172 __INIT 171 __CPUINIT
173 172
174/* 173/*
175 * __v7_setup 174 * __v7_setup
@@ -188,7 +187,8 @@ cpu_v7_name:
188 */ 187 */
189__v7_ca9mp_setup: 188__v7_ca9mp_setup:
190#ifdef CONFIG_SMP 189#ifdef CONFIG_SMP
191 mrc p15, 0, r0, c1, c0, 1 190 ALT_SMP(mrc p15, 0, r0, c1, c0, 1)
191 ALT_UP(mov r0, #(1 << 6)) @ fake it for UP
192 tst r0, #(1 << 6) @ SMP/nAMP mode enabled? 192 tst r0, #(1 << 6) @ SMP/nAMP mode enabled?
193 orreq r0, r0, #(1 << 6) | (1 << 0) @ Enable SMP/nAMP mode and 193 orreq r0, r0, #(1 << 6) | (1 << 0) @ Enable SMP/nAMP mode and
194 mcreq p15, 0, r0, c1, c0, 1 @ TLB ops broadcasting 194 mcreq p15, 0, r0, c1, c0, 1 @ TLB ops broadcasting
@@ -253,6 +253,14 @@ __v7_setup:
253 orreq r10, r10, #1 << 22 @ set bit #22 253 orreq r10, r10, #1 << 22 @ set bit #22
254 mcreq p15, 0, r10, c15, c0, 1 @ write diagnostic register 254 mcreq p15, 0, r10, c15, c0, 1 @ write diagnostic register
255#endif 255#endif
256#ifdef CONFIG_ARM_ERRATA_743622
257 teq r6, #0x20 @ present in r2p0
258 teqne r6, #0x21 @ present in r2p1
259 teqne r6, #0x22 @ present in r2p2
260 mrceq p15, 0, r10, c15, c0, 1 @ read diagnostic register
261 orreq r10, r10, #1 << 6 @ set bit #6
262 mcreq p15, 0, r10, c15, c0, 1 @ write diagnostic register
263#endif
256 264
2573: mov r10, #0 2653: mov r10, #0
258#ifdef HARVARD_CACHE 266#ifdef HARVARD_CACHE
@@ -262,7 +270,8 @@ __v7_setup:
262#ifdef CONFIG_MMU 270#ifdef CONFIG_MMU
263 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs 271 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
264 mcr p15, 0, r10, c2, c0, 2 @ TTB control register 272 mcr p15, 0, r10, c2, c0, 2 @ TTB control register
265 orr r4, r4, #TTB_FLAGS 273 ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP)
274 ALT_UP(orr r4, r4, #TTB_FLAGS_UP)
266 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 275 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
267 mov r10, #0x1f @ domains 0, 1 = manager 276 mov r10, #0x1f @ domains 0, 1 = manager
268 mcr p15, 0, r10, c3, c0, 0 @ load domain access register 277 mcr p15, 0, r10, c3, c0, 0 @ load domain access register
@@ -324,6 +333,8 @@ v7_crval:
324__v7_setup_stack: 333__v7_setup_stack:
325 .space 4 * 11 @ 11 registers 334 .space 4 * 11 @ 11 registers
326 335
336 __INITDATA
337
327 .type v7_processor_functions, #object 338 .type v7_processor_functions, #object
328ENTRY(v7_processor_functions) 339ENTRY(v7_processor_functions)
329 .word v7_early_abort 340 .word v7_early_abort
@@ -337,6 +348,8 @@ ENTRY(v7_processor_functions)
337 .word cpu_v7_set_pte_ext 348 .word cpu_v7_set_pte_ext
338 .size v7_processor_functions, . - v7_processor_functions 349 .size v7_processor_functions, . - v7_processor_functions
339 350
351 .section ".rodata"
352
340 .type cpu_arch_name, #object 353 .type cpu_arch_name, #object
341cpu_arch_name: 354cpu_arch_name:
342 .asciz "armv7" 355 .asciz "armv7"
@@ -354,10 +367,16 @@ cpu_elf_name:
354__v7_ca9mp_proc_info: 367__v7_ca9mp_proc_info:
355 .long 0x410fc090 @ Required ID value 368 .long 0x410fc090 @ Required ID value
356 .long 0xff0ffff0 @ Mask for ID 369 .long 0xff0ffff0 @ Mask for ID
357 .long PMD_TYPE_SECT | \ 370 ALT_SMP(.long \
371 PMD_TYPE_SECT | \
372 PMD_SECT_AP_WRITE | \
373 PMD_SECT_AP_READ | \
374 PMD_FLAGS_SMP)
375 ALT_UP(.long \
376 PMD_TYPE_SECT | \
358 PMD_SECT_AP_WRITE | \ 377 PMD_SECT_AP_WRITE | \
359 PMD_SECT_AP_READ | \ 378 PMD_SECT_AP_READ | \
360 PMD_FLAGS 379 PMD_FLAGS_UP)
361 .long PMD_TYPE_SECT | \ 380 .long PMD_TYPE_SECT | \
362 PMD_SECT_XN | \ 381 PMD_SECT_XN | \
363 PMD_SECT_AP_WRITE | \ 382 PMD_SECT_AP_WRITE | \
@@ -365,7 +384,7 @@ __v7_ca9mp_proc_info:
365 b __v7_ca9mp_setup 384 b __v7_ca9mp_setup
366 .long cpu_arch_name 385 .long cpu_arch_name
367 .long cpu_elf_name 386 .long cpu_elf_name
368 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP 387 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_TLS
369 .long cpu_v7_name 388 .long cpu_v7_name
370 .long v7_processor_functions 389 .long v7_processor_functions
371 .long v7wbi_tlb_fns 390 .long v7wbi_tlb_fns
@@ -380,10 +399,16 @@ __v7_ca9mp_proc_info:
380__v7_proc_info: 399__v7_proc_info:
381 .long 0x000f0000 @ Required ID value 400 .long 0x000f0000 @ Required ID value
382 .long 0x000f0000 @ Mask for ID 401 .long 0x000f0000 @ Mask for ID
383 .long PMD_TYPE_SECT | \ 402 ALT_SMP(.long \
403 PMD_TYPE_SECT | \
404 PMD_SECT_AP_WRITE | \
405 PMD_SECT_AP_READ | \
406 PMD_FLAGS_SMP)
407 ALT_UP(.long \
408 PMD_TYPE_SECT | \
384 PMD_SECT_AP_WRITE | \ 409 PMD_SECT_AP_WRITE | \
385 PMD_SECT_AP_READ | \ 410 PMD_SECT_AP_READ | \
386 PMD_FLAGS 411 PMD_FLAGS_UP)
387 .long PMD_TYPE_SECT | \ 412 .long PMD_TYPE_SECT | \
388 PMD_SECT_XN | \ 413 PMD_SECT_XN | \
389 PMD_SECT_AP_WRITE | \ 414 PMD_SECT_AP_WRITE | \
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index 361a51e49030..cad07e403044 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -404,7 +404,7 @@ ENTRY(cpu_xsc3_set_pte_ext)
404 404
405 .align 405 .align
406 406
407 __INIT 407 __CPUINIT
408 408
409 .type __xsc3_setup, #function 409 .type __xsc3_setup, #function
410__xsc3_setup: 410__xsc3_setup:
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 14075979bcba..cb245edb2c2b 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -506,7 +506,7 @@ ENTRY(cpu_xscale_set_pte_ext)
506 506
507 .align 507 .align
508 508
509 __INIT 509 __CPUINIT
510 510
511 .type __xscale_setup, #function 511 .type __xscale_setup, #function
512__xscale_setup: 512__xscale_setup:
diff --git a/arch/arm/mm/tlb-v7.S b/arch/arm/mm/tlb-v7.S
index f3f288a9546d..53cd5b454673 100644
--- a/arch/arm/mm/tlb-v7.S
+++ b/arch/arm/mm/tlb-v7.S
@@ -13,6 +13,7 @@
13 */ 13 */
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <asm/assembler.h>
16#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
17#include <asm/page.h> 18#include <asm/page.h>
18#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
@@ -41,20 +42,15 @@ ENTRY(v7wbi_flush_user_tlb_range)
41 orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA 42 orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA
42 mov r1, r1, lsl #PAGE_SHIFT 43 mov r1, r1, lsl #PAGE_SHIFT
431: 441:
44#ifdef CONFIG_SMP 45 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
45 mcr p15, 0, r0, c8, c3, 1 @ TLB invalidate U MVA (shareable) 46 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
46#else 47
47 mcr p15, 0, r0, c8, c7, 1 @ TLB invalidate U MVA
48#endif
49 add r0, r0, #PAGE_SZ 48 add r0, r0, #PAGE_SZ
50 cmp r0, r1 49 cmp r0, r1
51 blo 1b 50 blo 1b
52 mov ip, #0 51 mov ip, #0
53#ifdef CONFIG_SMP 52 ALT_SMP(mcr p15, 0, ip, c7, c1, 6) @ flush BTAC/BTB Inner Shareable
54 mcr p15, 0, ip, c7, c1, 6 @ flush BTAC/BTB Inner Shareable 53 ALT_UP(mcr p15, 0, ip, c7, c5, 6) @ flush BTAC/BTB
55#else
56 mcr p15, 0, ip, c7, c5, 6 @ flush BTAC/BTB
57#endif
58 dsb 54 dsb
59 mov pc, lr 55 mov pc, lr
60ENDPROC(v7wbi_flush_user_tlb_range) 56ENDPROC(v7wbi_flush_user_tlb_range)
@@ -74,20 +70,14 @@ ENTRY(v7wbi_flush_kern_tlb_range)
74 mov r0, r0, lsl #PAGE_SHIFT 70 mov r0, r0, lsl #PAGE_SHIFT
75 mov r1, r1, lsl #PAGE_SHIFT 71 mov r1, r1, lsl #PAGE_SHIFT
761: 721:
77#ifdef CONFIG_SMP 73 ALT_SMP(mcr p15, 0, r0, c8, c3, 1) @ TLB invalidate U MVA (shareable)
78 mcr p15, 0, r0, c8, c3, 1 @ TLB invalidate U MVA (shareable) 74 ALT_UP(mcr p15, 0, r0, c8, c7, 1) @ TLB invalidate U MVA
79#else
80 mcr p15, 0, r0, c8, c7, 1 @ TLB invalidate U MVA
81#endif
82 add r0, r0, #PAGE_SZ 75 add r0, r0, #PAGE_SZ
83 cmp r0, r1 76 cmp r0, r1
84 blo 1b 77 blo 1b
85 mov r2, #0 78 mov r2, #0
86#ifdef CONFIG_SMP 79 ALT_SMP(mcr p15, 0, r2, c7, c1, 6) @ flush BTAC/BTB Inner Shareable
87 mcr p15, 0, r2, c7, c1, 6 @ flush BTAC/BTB Inner Shareable 80 ALT_UP(mcr p15, 0, r2, c7, c5, 6) @ flush BTAC/BTB
88#else
89 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
90#endif
91 dsb 81 dsb
92 isb 82 isb
93 mov pc, lr 83 mov pc, lr
@@ -99,5 +89,6 @@ ENDPROC(v7wbi_flush_kern_tlb_range)
99ENTRY(v7wbi_tlb_fns) 89ENTRY(v7wbi_tlb_fns)
100 .long v7wbi_flush_user_tlb_range 90 .long v7wbi_flush_user_tlb_range
101 .long v7wbi_flush_kern_tlb_range 91 .long v7wbi_flush_kern_tlb_range
102 .long v7wbi_tlb_flags 92 ALT_SMP(.long v7wbi_tlb_flags_smp)
93 ALT_UP(.long v7wbi_tlb_flags_up)
103 .size v7wbi_tlb_fns, . - v7wbi_tlb_fns 94 .size v7wbi_tlb_fns, . - v7wbi_tlb_fns
diff --git a/arch/arm/nwfpe/milieu.h b/arch/arm/nwfpe/milieu.h
index a3892ab2dca4..09a4f2ddeb77 100644
--- a/arch/arm/nwfpe/milieu.h
+++ b/arch/arm/nwfpe/milieu.h
@@ -12,8 +12,8 @@ National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector 12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley, 13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information 14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 15is available through the Web page
16arithmetic/softfloat.html'. 16http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
17 17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
diff --git a/arch/arm/nwfpe/softfloat-macros b/arch/arm/nwfpe/softfloat-macros
index 5a060f95a58f..cf2a6173149e 100644
--- a/arch/arm/nwfpe/softfloat-macros
+++ b/arch/arm/nwfpe/softfloat-macros
@@ -12,8 +12,8 @@ National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector 12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley, 13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information 14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 15is available through the web page
16arithmetic/softfloat.html'. 16http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
17 17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
diff --git a/arch/arm/nwfpe/softfloat-specialize b/arch/arm/nwfpe/softfloat-specialize
index d4a4c8e06635..679a0269dd25 100644
--- a/arch/arm/nwfpe/softfloat-specialize
+++ b/arch/arm/nwfpe/softfloat-specialize
@@ -12,8 +12,8 @@ National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector 12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley, 13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information 14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 15is available through the Web page
16arithmetic/softfloat.html'. 16http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
17 17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
diff --git a/arch/arm/nwfpe/softfloat.c b/arch/arm/nwfpe/softfloat.c
index 0f9656e482ba..ffa6b438786b 100644
--- a/arch/arm/nwfpe/softfloat.c
+++ b/arch/arm/nwfpe/softfloat.c
@@ -11,8 +11,8 @@ National Science Foundation under grant MIP-9311980. The original version
11of this code was written as part of a project to build a fixed-point vector 11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley, 12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek. More information 13overseen by Profs. Nelson Morgan and John Wawrzynek. More information
14is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 14is available through the web page
15arithmetic/softfloat.html'. 15http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
16 16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
18has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 18has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
diff --git a/arch/arm/nwfpe/softfloat.h b/arch/arm/nwfpe/softfloat.h
index 13e479c5da57..df4d243a2b7c 100644
--- a/arch/arm/nwfpe/softfloat.h
+++ b/arch/arm/nwfpe/softfloat.h
@@ -12,8 +12,8 @@ National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector 12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley, 13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information 14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ 15is available through the Web page
16arithmetic/softfloat.html'. 16http://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txt
17 17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort 18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT 19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
diff --git a/arch/arm/oprofile/Makefile b/arch/arm/oprofile/Makefile
index e666eafed152..b2215c61cdf0 100644
--- a/arch/arm/oprofile/Makefile
+++ b/arch/arm/oprofile/Makefile
@@ -6,4 +6,8 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
6 oprofilefs.o oprofile_stats.o \ 6 oprofilefs.o oprofile_stats.o \
7 timer_int.o ) 7 timer_int.o )
8 8
9ifeq ($(CONFIG_HW_PERF_EVENTS),y)
10DRIVER_OBJS += $(addprefix ../../../drivers/oprofile/, oprofile_perf.o)
11endif
12
9oprofile-y := $(DRIVER_OBJS) common.o 13oprofile-y := $(DRIVER_OBJS) common.o
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 0691176899ff..8aa974491dfc 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -25,138 +25,10 @@
25#include <asm/ptrace.h> 25#include <asm/ptrace.h>
26 26
27#ifdef CONFIG_HW_PERF_EVENTS 27#ifdef CONFIG_HW_PERF_EVENTS
28/* 28char *op_name_from_perf_id(void)
29 * Per performance monitor configuration as set via oprofilefs.
30 */
31struct op_counter_config {
32 unsigned long count;
33 unsigned long enabled;
34 unsigned long event;
35 unsigned long unit_mask;
36 unsigned long kernel;
37 unsigned long user;
38 struct perf_event_attr attr;
39};
40
41static int op_arm_enabled;
42static DEFINE_MUTEX(op_arm_mutex);
43
44static struct op_counter_config *counter_config;
45static struct perf_event **perf_events[nr_cpumask_bits];
46static int perf_num_counters;
47
48/*
49 * Overflow callback for oprofile.
50 */
51static void op_overflow_handler(struct perf_event *event, int unused,
52 struct perf_sample_data *data, struct pt_regs *regs)
53{
54 int id;
55 u32 cpu = smp_processor_id();
56
57 for (id = 0; id < perf_num_counters; ++id)
58 if (perf_events[cpu][id] == event)
59 break;
60
61 if (id != perf_num_counters)
62 oprofile_add_sample(regs, id);
63 else
64 pr_warning("oprofile: ignoring spurious overflow "
65 "on cpu %u\n", cpu);
66}
67
68/*
69 * Called by op_arm_setup to create perf attributes to mirror the oprofile
70 * settings in counter_config. Attributes are created as `pinned' events and
71 * so are permanently scheduled on the PMU.
72 */
73static void op_perf_setup(void)
74{
75 int i;
76 u32 size = sizeof(struct perf_event_attr);
77 struct perf_event_attr *attr;
78
79 for (i = 0; i < perf_num_counters; ++i) {
80 attr = &counter_config[i].attr;
81 memset(attr, 0, size);
82 attr->type = PERF_TYPE_RAW;
83 attr->size = size;
84 attr->config = counter_config[i].event;
85 attr->sample_period = counter_config[i].count;
86 attr->pinned = 1;
87 }
88}
89
90static int op_create_counter(int cpu, int event)
91{
92 int ret = 0;
93 struct perf_event *pevent;
94
95 if (!counter_config[event].enabled || (perf_events[cpu][event] != NULL))
96 return ret;
97
98 pevent = perf_event_create_kernel_counter(&counter_config[event].attr,
99 cpu, -1,
100 op_overflow_handler);
101
102 if (IS_ERR(pevent)) {
103 ret = PTR_ERR(pevent);
104 } else if (pevent->state != PERF_EVENT_STATE_ACTIVE) {
105 pr_warning("oprofile: failed to enable event %d "
106 "on CPU %d\n", event, cpu);
107 ret = -EBUSY;
108 } else {
109 perf_events[cpu][event] = pevent;
110 }
111
112 return ret;
113}
114
115static void op_destroy_counter(int cpu, int event)
116{
117 struct perf_event *pevent = perf_events[cpu][event];
118
119 if (pevent) {
120 perf_event_release_kernel(pevent);
121 perf_events[cpu][event] = NULL;
122 }
123}
124
125/*
126 * Called by op_arm_start to create active perf events based on the
127 * perviously configured attributes.
128 */
129static int op_perf_start(void)
130{
131 int cpu, event, ret = 0;
132
133 for_each_online_cpu(cpu) {
134 for (event = 0; event < perf_num_counters; ++event) {
135 ret = op_create_counter(cpu, event);
136 if (ret)
137 goto out;
138 }
139 }
140
141out:
142 return ret;
143}
144
145/*
146 * Called by op_arm_stop at the end of a profiling run.
147 */
148static void op_perf_stop(void)
149{ 29{
150 int cpu, event; 30 enum arm_perf_pmu_ids id = armpmu_get_pmu_id();
151 31
152 for_each_online_cpu(cpu)
153 for (event = 0; event < perf_num_counters; ++event)
154 op_destroy_counter(cpu, event);
155}
156
157
158static char *op_name_from_perf_id(enum arm_perf_pmu_ids id)
159{
160 switch (id) { 32 switch (id) {
161 case ARM_PERF_PMU_ID_XSCALE1: 33 case ARM_PERF_PMU_ID_XSCALE1:
162 return "arm/xscale1"; 34 return "arm/xscale1";
@@ -175,116 +47,6 @@ static char *op_name_from_perf_id(enum arm_perf_pmu_ids id)
175 } 47 }
176} 48}
177 49
178static int op_arm_create_files(struct super_block *sb, struct dentry *root)
179{
180 unsigned int i;
181
182 for (i = 0; i < perf_num_counters; i++) {
183 struct dentry *dir;
184 char buf[4];
185
186 snprintf(buf, sizeof buf, "%d", i);
187 dir = oprofilefs_mkdir(sb, root, buf);
188 oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled);
189 oprofilefs_create_ulong(sb, dir, "event", &counter_config[i].event);
190 oprofilefs_create_ulong(sb, dir, "count", &counter_config[i].count);
191 oprofilefs_create_ulong(sb, dir, "unit_mask", &counter_config[i].unit_mask);
192 oprofilefs_create_ulong(sb, dir, "kernel", &counter_config[i].kernel);
193 oprofilefs_create_ulong(sb, dir, "user", &counter_config[i].user);
194 }
195
196 return 0;
197}
198
199static int op_arm_setup(void)
200{
201 spin_lock(&oprofilefs_lock);
202 op_perf_setup();
203 spin_unlock(&oprofilefs_lock);
204 return 0;
205}
206
207static int op_arm_start(void)
208{
209 int ret = -EBUSY;
210
211 mutex_lock(&op_arm_mutex);
212 if (!op_arm_enabled) {
213 ret = 0;
214 op_perf_start();
215 op_arm_enabled = 1;
216 }
217 mutex_unlock(&op_arm_mutex);
218 return ret;
219}
220
221static void op_arm_stop(void)
222{
223 mutex_lock(&op_arm_mutex);
224 if (op_arm_enabled)
225 op_perf_stop();
226 op_arm_enabled = 0;
227 mutex_unlock(&op_arm_mutex);
228}
229
230#ifdef CONFIG_PM
231static int op_arm_suspend(struct platform_device *dev, pm_message_t state)
232{
233 mutex_lock(&op_arm_mutex);
234 if (op_arm_enabled)
235 op_perf_stop();
236 mutex_unlock(&op_arm_mutex);
237 return 0;
238}
239
240static int op_arm_resume(struct platform_device *dev)
241{
242 mutex_lock(&op_arm_mutex);
243 if (op_arm_enabled && op_perf_start())
244 op_arm_enabled = 0;
245 mutex_unlock(&op_arm_mutex);
246 return 0;
247}
248
249static struct platform_driver oprofile_driver = {
250 .driver = {
251 .name = "arm-oprofile",
252 },
253 .resume = op_arm_resume,
254 .suspend = op_arm_suspend,
255};
256
257static struct platform_device *oprofile_pdev;
258
259static int __init init_driverfs(void)
260{
261 int ret;
262
263 ret = platform_driver_register(&oprofile_driver);
264 if (ret)
265 goto out;
266
267 oprofile_pdev = platform_device_register_simple(
268 oprofile_driver.driver.name, 0, NULL, 0);
269 if (IS_ERR(oprofile_pdev)) {
270 ret = PTR_ERR(oprofile_pdev);
271 platform_driver_unregister(&oprofile_driver);
272 }
273
274out:
275 return ret;
276}
277
278static void exit_driverfs(void)
279{
280 platform_device_unregister(oprofile_pdev);
281 platform_driver_unregister(&oprofile_driver);
282}
283#else
284static int __init init_driverfs(void) { return 0; }
285#define exit_driverfs() do { } while (0)
286#endif /* CONFIG_PM */
287
288static int report_trace(struct stackframe *frame, void *d) 50static int report_trace(struct stackframe *frame, void *d)
289{ 51{
290 unsigned int *depth = d; 52 unsigned int *depth = d;
@@ -349,72 +111,14 @@ static void arm_backtrace(struct pt_regs * const regs, unsigned int depth)
349 111
350int __init oprofile_arch_init(struct oprofile_operations *ops) 112int __init oprofile_arch_init(struct oprofile_operations *ops)
351{ 113{
352 int cpu, ret = 0;
353
354 perf_num_counters = armpmu_get_max_events();
355
356 counter_config = kcalloc(perf_num_counters,
357 sizeof(struct op_counter_config), GFP_KERNEL);
358
359 if (!counter_config) {
360 pr_info("oprofile: failed to allocate %d "
361 "counters\n", perf_num_counters);
362 return -ENOMEM;
363 }
364
365 ret = init_driverfs();
366 if (ret) {
367 kfree(counter_config);
368 return ret;
369 }
370
371 for_each_possible_cpu(cpu) {
372 perf_events[cpu] = kcalloc(perf_num_counters,
373 sizeof(struct perf_event *), GFP_KERNEL);
374 if (!perf_events[cpu]) {
375 pr_info("oprofile: failed to allocate %d perf events "
376 "for cpu %d\n", perf_num_counters, cpu);
377 while (--cpu >= 0)
378 kfree(perf_events[cpu]);
379 return -ENOMEM;
380 }
381 }
382
383 ops->backtrace = arm_backtrace; 114 ops->backtrace = arm_backtrace;
384 ops->create_files = op_arm_create_files;
385 ops->setup = op_arm_setup;
386 ops->start = op_arm_start;
387 ops->stop = op_arm_stop;
388 ops->shutdown = op_arm_stop;
389 ops->cpu_type = op_name_from_perf_id(armpmu_get_pmu_id());
390
391 if (!ops->cpu_type)
392 ret = -ENODEV;
393 else
394 pr_info("oprofile: using %s\n", ops->cpu_type);
395 115
396 return ret; 116 return oprofile_perf_init(ops);
397} 117}
398 118
399void oprofile_arch_exit(void) 119void __exit oprofile_arch_exit(void)
400{ 120{
401 int cpu, id; 121 oprofile_perf_exit();
402 struct perf_event *event;
403
404 if (*perf_events) {
405 exit_driverfs();
406 for_each_possible_cpu(cpu) {
407 for (id = 0; id < perf_num_counters; ++id) {
408 event = perf_events[cpu][id];
409 if (event != NULL)
410 perf_event_release_kernel(event);
411 }
412 kfree(perf_events[cpu]);
413 }
414 }
415
416 if (counter_config)
417 kfree(counter_config);
418} 122}
419#else 123#else
420int __init oprofile_arch_init(struct oprofile_operations *ops) 124int __init oprofile_arch_init(struct oprofile_operations *ops)
@@ -422,5 +126,5 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
422 pr_info("oprofile: hardware counters not available\n"); 126 pr_info("oprofile: hardware counters not available\n");
423 return -ENODEV; 127 return -ENODEV;
424} 128}
425void oprofile_arch_exit(void) {} 129void __exit oprofile_arch_exit(void) {}
426#endif /* CONFIG_HW_PERF_EVENTS */ 130#endif /* CONFIG_HW_PERF_EVENTS */
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
index 6785db4179b8..64e3a64520e0 100644
--- a/arch/arm/plat-mxc/Kconfig
+++ b/arch/arm/plat-mxc/Kconfig
@@ -92,6 +92,18 @@ config MXC_DEBUG_BOARD
92 data/address de-multiplexing and decode, signal level shift, 92 data/address de-multiplexing and decode, signal level shift,
93 interrupt control and various board functions. 93 interrupt control and various board functions.
94 94
95config HAVE_EPIT
96 bool
97
98config MXC_USE_EPIT
99 bool "Use EPIT instead of GPT"
100 depends on HAVE_EPIT
101 help
102 Use EPIT as the system timer on systems that have it. Normally you
103 don't have a reason to do so as the EPIT has the same features and
104 uses the same clocks as the GPT. Anyway, on some systems the GPT
105 may be in use for other purposes.
106
95config MXC_ULPI 107config MXC_ULPI
96 bool 108 bool
97 109
@@ -110,4 +122,8 @@ config ARCH_MXC_AUDMUX_V1
110config ARCH_MXC_AUDMUX_V2 122config ARCH_MXC_AUDMUX_V2
111 bool 123 bool
112 124
125config IRAM_ALLOC
126 bool
127 select GENERIC_ALLOCATOR
128
113endif 129endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 78d405ed8616..06875b4dd70f 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -10,9 +10,11 @@ obj-$(CONFIG_MXC_TZIC) += tzic.o
10 10
11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o 11obj-$(CONFIG_IMX_HAVE_IOMUX_V1) += iomux-v1.o
12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o 12obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
13obj-$(CONFIG_IRAM_ALLOC) += iram_alloc.o
13obj-$(CONFIG_MXC_PWM) += pwm.o 14obj-$(CONFIG_MXC_PWM) += pwm.o
14obj-$(CONFIG_USB_EHCI_MXC) += ehci.o 15obj-$(CONFIG_USB_EHCI_MXC) += ehci.o
15obj-$(CONFIG_MXC_ULPI) += ulpi.o 16obj-$(CONFIG_MXC_ULPI) += ulpi.o
17obj-$(CONFIG_MXC_USE_EPIT) += epit.o
16obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o 18obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
17obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o 19obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
18obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o 20obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index f9e7cdbd0005..0be1ac7f421b 100644
--- a/arch/arm/plat-mxc/audmux-v2.c
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -137,6 +137,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
137static const struct file_operations audmux_debugfs_fops = { 137static const struct file_operations audmux_debugfs_fops = {
138 .open = audmux_open_file, 138 .open = audmux_open_file,
139 .read = audmux_read_file, 139 .read = audmux_read_file,
140 .llseek = default_llseek,
140}; 141};
141 142
142static void audmux_debugfs_init(void) 143static void audmux_debugfs_init(void)
@@ -186,7 +187,13 @@ EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port);
186static int mxc_audmux_v2_init(void) 187static int mxc_audmux_v2_init(void)
187{ 188{
188 int ret; 189 int ret;
189 190#if defined(CONFIG_ARCH_MX5)
191 if (cpu_is_mx51()) {
192 audmux_base = MX51_IO_ADDRESS(MX51_AUDMUX_BASE_ADDR);
193 ret = 0;
194 return ret;
195 }
196#endif
190#if defined(CONFIG_ARCH_MX3) 197#if defined(CONFIG_ARCH_MX3)
191 if (cpu_is_mx31()) 198 if (cpu_is_mx31())
192 audmux_base = MX31_IO_ADDRESS(MX31_AUDMUX_BASE_ADDR); 199 audmux_base = MX31_IO_ADDRESS(MX31_AUDMUX_BASE_ADDR);
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 9ab784b776f9..404799487f17 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -1,3 +1,10 @@
1config IMX_HAVE_PLATFORM_ESDHC
2 bool
3
4config IMX_HAVE_PLATFORM_FEC
5 bool
6 default y if ARCH_MX25 || SOC_IMX27 || ARCH_MX35 || ARCH_MX51
7
1config IMX_HAVE_PLATFORM_FLEXCAN 8config IMX_HAVE_PLATFORM_FLEXCAN
2 select HAVE_CAN_FLEXCAN 9 select HAVE_CAN_FLEXCAN
3 bool 10 bool
@@ -5,6 +12,9 @@ config IMX_HAVE_PLATFORM_FLEXCAN
5config IMX_HAVE_PLATFORM_IMX_I2C 12config IMX_HAVE_PLATFORM_IMX_I2C
6 bool 13 bool
7 14
15config IMX_HAVE_PLATFORM_IMX_SSI
16 bool
17
8config IMX_HAVE_PLATFORM_IMX_UART 18config IMX_HAVE_PLATFORM_IMX_UART
9 bool 19 bool
10 20
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 347da5161f7e..0a3c1f089413 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -1,8 +1,9 @@
1ifdef CONFIG_CAN_FLEXCAN 1obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
2# the ifdef can be removed once the flexcan driver has been merged 2obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o
3obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o 3obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
4endif 4obj-y += platform-imx-dma.o
5obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o 5obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
6obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
6obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o 7obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
7obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o 8obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
8obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o 9obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
diff --git a/arch/arm/plat-mxc/devices/platform-esdhc.c b/arch/arm/plat-mxc/devices/platform-esdhc.c
new file mode 100644
index 000000000000..2605bfa0dfb0
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-esdhc.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2010 Pengutronix, Wolfram Sang <w.sang@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License version 2 as published by the
6 * Free Software Foundation.
7 */
8
9#include <mach/hardware.h>
10#include <mach/devices-common.h>
11#include <mach/esdhc.h>
12
13#define imx_esdhc_imx_data_entry_single(soc, _id, hwid) \
14 { \
15 .id = _id, \
16 .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
17 .irq = soc ## _INT_ESDHC ## hwid, \
18 }
19
20#define imx_esdhc_imx_data_entry(soc, id, hwid) \
21 [id] = imx_esdhc_imx_data_entry_single(soc, id, hwid)
22
23#ifdef CONFIG_ARCH_MX25
24const struct imx_esdhc_imx_data imx25_esdhc_data[] __initconst = {
25#define imx25_esdhc_data_entry(_id, _hwid) \
26 imx_esdhc_imx_data_entry(MX25, _id, _hwid)
27 imx25_esdhc_data_entry(0, 1),
28 imx25_esdhc_data_entry(1, 2),
29};
30#endif /* ifdef CONFIG_ARCH_MX25 */
31
32#ifdef CONFIG_ARCH_MX35
33const struct imx_esdhc_imx_data imx35_esdhc_data[] __initconst = {
34#define imx35_esdhc_data_entry(_id, _hwid) \
35 imx_esdhc_imx_data_entry(MX35, _id, _hwid)
36 imx35_esdhc_data_entry(0, 1),
37 imx35_esdhc_data_entry(1, 2),
38 imx35_esdhc_data_entry(2, 3),
39};
40#endif /* ifdef CONFIG_ARCH_MX35 */
41
42#ifdef CONFIG_ARCH_MX51
43const struct imx_esdhc_imx_data imx51_esdhc_data[] __initconst = {
44#define imx51_esdhc_data_entry(_id, _hwid) \
45 imx_esdhc_imx_data_entry(MX51, _id, _hwid)
46 imx51_esdhc_data_entry(0, 1),
47 imx51_esdhc_data_entry(1, 2),
48 imx51_esdhc_data_entry(2, 3),
49 imx51_esdhc_data_entry(3, 4),
50};
51#endif /* ifdef CONFIG_ARCH_MX51 */
52
53struct platform_device *__init imx_add_esdhc(
54 const struct imx_esdhc_imx_data *data,
55 const struct esdhc_platform_data *pdata)
56{
57 struct resource res[] = {
58 {
59 .start = data->iobase,
60 .end = data->iobase + SZ_16K - 1,
61 .flags = IORESOURCE_MEM,
62 }, {
63 .start = data->irq,
64 .end = data->irq,
65 .flags = IORESOURCE_IRQ,
66 },
67 };
68
69 return imx_add_platform_device("sdhci-esdhc-imx", data->id, res,
70 ARRAY_SIZE(res), pdata, sizeof(*pdata));
71}
diff --git a/arch/arm/plat-mxc/devices/platform-fec.c b/arch/arm/plat-mxc/devices/platform-fec.c
new file mode 100644
index 000000000000..11d087f4e219
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-fec.c
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include <asm/sizes.h>
10#include <mach/hardware.h>
11#include <mach/devices-common.h>
12
13#define imx_fec_data_entry_single(soc) \
14 { \
15 .iobase = soc ## _FEC_BASE_ADDR, \
16 .irq = soc ## _INT_FEC, \
17 }
18
19#ifdef CONFIG_ARCH_MX25
20const struct imx_fec_data imx25_fec_data __initconst =
21 imx_fec_data_entry_single(MX25);
22#endif /* ifdef CONFIG_ARCH_MX25 */
23
24#ifdef CONFIG_SOC_IMX27
25const struct imx_fec_data imx27_fec_data __initconst =
26 imx_fec_data_entry_single(MX27);
27#endif /* ifdef CONFIG_SOC_IMX27 */
28
29#ifdef CONFIG_ARCH_MX35
30const struct imx_fec_data imx35_fec_data __initconst =
31 imx_fec_data_entry_single(MX35);
32#endif
33
34#ifdef CONFIG_ARCH_MX51
35const struct imx_fec_data imx51_fec_data __initconst =
36 imx_fec_data_entry_single(MX51);
37#endif
38
39struct platform_device *__init imx_add_fec(
40 const struct imx_fec_data *data,
41 const struct fec_platform_data *pdata)
42{
43 struct resource res[] = {
44 {
45 .start = data->iobase,
46 .end = data->iobase + SZ_4K,
47 .flags = IORESOURCE_MEM,
48 }, {
49 .start = data->irq,
50 .end = data->irq,
51 .flags = IORESOURCE_IRQ,
52 },
53 };
54
55 return imx_add_platform_device("fec", 0 /* -1? */,
56 res, ARRAY_SIZE(res),
57 pdata, sizeof(*pdata));
58}
diff --git a/arch/arm/plat-mxc/devices/platform-imx-dma.c b/arch/arm/plat-mxc/devices/platform-imx-dma.c
new file mode 100644
index 000000000000..02d989018059
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-imx-dma.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright (C) 2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include <linux/compiler.h>
10#include <linux/err.h>
11#include <linux/init.h>
12
13#include <mach/hardware.h>
14#include <mach/devices-common.h>
15#ifdef SDMA_IS_MERGED
16#include <mach/sdma.h>
17#else
18struct sdma_platform_data {
19 int sdma_version;
20 char *cpu_name;
21 int to_version;
22};
23#endif
24
25struct imx_imx_sdma_data {
26 resource_size_t iobase;
27 resource_size_t irq;
28 struct sdma_platform_data pdata;
29};
30
31#define imx_imx_sdma_data_entry_single(soc, _sdma_version, _cpu_name, _to_version)\
32 { \
33 .iobase = soc ## _SDMA ## _BASE_ADDR, \
34 .irq = soc ## _INT_SDMA, \
35 .pdata = { \
36 .sdma_version = _sdma_version, \
37 .cpu_name = _cpu_name, \
38 .to_version = _to_version, \
39 }, \
40 }
41
42#ifdef CONFIG_ARCH_MX25
43const struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
44 imx_imx_sdma_data_entry_single(MX25, 1, "imx25", 0);
45#endif /* ifdef CONFIG_ARCH_MX25 */
46
47#ifdef CONFIG_ARCH_MX31
48struct imx_imx_sdma_data imx31_imx_sdma_data __initdata =
49 imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 0);
50#endif /* ifdef CONFIG_ARCH_MX31 */
51
52#ifdef CONFIG_ARCH_MX35
53struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
54 imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 0);
55#endif /* ifdef CONFIG_ARCH_MX35 */
56
57#ifdef CONFIG_ARCH_MX51
58const struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
59 imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 0);
60#endif /* ifdef CONFIG_ARCH_MX51 */
61
62static struct platform_device __init __maybe_unused *imx_add_imx_sdma(
63 const struct imx_imx_sdma_data *data)
64{
65 struct resource res[] = {
66 {
67 .start = data->iobase,
68 .end = data->iobase + SZ_4K - 1,
69 .flags = IORESOURCE_MEM,
70 }, {
71 .start = data->irq,
72 .end = data->irq,
73 .flags = IORESOURCE_IRQ,
74 },
75 };
76
77 return imx_add_platform_device("imx-sdma", -1,
78 res, ARRAY_SIZE(res),
79 &data->pdata, sizeof(data->pdata));
80}
81
82static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
83{
84 return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
85}
86
87static int __init imxXX_add_imx_dma(void)
88{
89 struct platform_device *ret;
90
91#if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
92 if (cpu_is_mx21() || cpu_is_mx27())
93 ret = imx_add_imx_dma();
94 else
95#endif
96
97#if defined(CONFIG_ARCH_MX25)
98 if (cpu_is_mx25())
99 ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
100 else
101#endif
102
103#if defined(CONFIG_ARCH_MX31)
104 if (cpu_is_mx31()) {
105 imx31_imx_sdma_data.pdata.to_version = mx31_revision() >> 4;
106 ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
107 } else
108#endif
109
110#if defined(CONFIG_ARCH_MX35)
111 if (cpu_is_mx35()) {
112 imx35_imx_sdma_data.pdata.to_version = mx35_revision() >> 4;
113 ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
114 } else
115#endif
116
117#if defined(CONFIG_ARCH_MX51)
118 if (cpu_is_mx51())
119 ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
120 else
121#endif
122 ret = ERR_PTR(-ENODEV);
123
124 if (IS_ERR(ret))
125 return PTR_ERR(ret);
126
127 return 0;
128}
129arch_initcall(imxXX_add_imx_dma);
diff --git a/arch/arm/plat-mxc/devices/platform-imx-i2c.c b/arch/arm/plat-mxc/devices/platform-imx-i2c.c
index d0af9f7d8aed..679588453aad 100644
--- a/arch/arm/plat-mxc/devices/platform-imx-i2c.c
+++ b/arch/arm/plat-mxc/devices/platform-imx-i2c.c
@@ -6,24 +6,95 @@
6 * the terms of the GNU General Public License version 2 as published by the 6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation. 7 * Free Software Foundation.
8 */ 8 */
9#include <mach/hardware.h>
9#include <mach/devices-common.h> 10#include <mach/devices-common.h>
10 11
11struct platform_device *__init imx_add_imx_i2c(int id, 12#define imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size) \
12 resource_size_t iobase, resource_size_t iosize, int irq, 13 { \
14 .id = _id, \
15 .iobase = soc ## _I2C ## _hwid ## _BASE_ADDR, \
16 .iosize = _size, \
17 .irq = soc ## _INT_I2C ## _hwid, \
18 }
19
20#define imx_imx_i2c_data_entry(soc, _id, _hwid, _size) \
21 [_id] = imx_imx_i2c_data_entry_single(soc, _id, _hwid, _size)
22
23#ifdef CONFIG_SOC_IMX1
24const struct imx_imx_i2c_data imx1_imx_i2c_data __initconst =
25 imx_imx_i2c_data_entry_single(MX1, 0, , SZ_4K);
26#endif /* ifdef CONFIG_SOC_IMX1 */
27
28#ifdef CONFIG_SOC_IMX21
29const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst =
30 imx_imx_i2c_data_entry_single(MX21, 0, , SZ_4K);
31#endif /* ifdef CONFIG_SOC_IMX21 */
32
33#ifdef CONFIG_ARCH_MX25
34const struct imx_imx_i2c_data imx25_imx_i2c_data[] __initconst = {
35#define imx25_imx_i2c_data_entry(_id, _hwid) \
36 imx_imx_i2c_data_entry(MX25, _id, _hwid, SZ_16K)
37 imx25_imx_i2c_data_entry(0, 1),
38 imx25_imx_i2c_data_entry(1, 2),
39 imx25_imx_i2c_data_entry(2, 3),
40};
41#endif /* ifdef CONFIG_ARCH_MX25 */
42
43#ifdef CONFIG_SOC_IMX27
44const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst = {
45#define imx27_imx_i2c_data_entry(_id, _hwid) \
46 imx_imx_i2c_data_entry(MX27, _id, _hwid, SZ_4K)
47 imx27_imx_i2c_data_entry(0, 1),
48 imx27_imx_i2c_data_entry(1, 2),
49};
50#endif /* ifdef CONFIG_SOC_IMX27 */
51
52#ifdef CONFIG_ARCH_MX31
53const struct imx_imx_i2c_data imx31_imx_i2c_data[] __initconst = {
54#define imx31_imx_i2c_data_entry(_id, _hwid) \
55 imx_imx_i2c_data_entry(MX31, _id, _hwid, SZ_4K)
56 imx31_imx_i2c_data_entry(0, 1),
57 imx31_imx_i2c_data_entry(1, 2),
58 imx31_imx_i2c_data_entry(2, 3),
59};
60#endif /* ifdef CONFIG_ARCH_MX31 */
61
62#ifdef CONFIG_ARCH_MX35
63const struct imx_imx_i2c_data imx35_imx_i2c_data[] __initconst = {
64#define imx35_imx_i2c_data_entry(_id, _hwid) \
65 imx_imx_i2c_data_entry(MX35, _id, _hwid, SZ_4K)
66 imx35_imx_i2c_data_entry(0, 1),
67 imx35_imx_i2c_data_entry(1, 2),
68 imx35_imx_i2c_data_entry(2, 3),
69};
70#endif /* ifdef CONFIG_ARCH_MX35 */
71
72#ifdef CONFIG_ARCH_MX51
73const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst = {
74#define imx51_imx_i2c_data_entry(_id, _hwid) \
75 imx_imx_i2c_data_entry(MX51, _id, _hwid, SZ_4K)
76 imx51_imx_i2c_data_entry(0, 1),
77 imx51_imx_i2c_data_entry(1, 2),
78};
79#endif /* ifdef CONFIG_ARCH_MX51 */
80
81struct platform_device *__init imx_add_imx_i2c(
82 const struct imx_imx_i2c_data *data,
13 const struct imxi2c_platform_data *pdata) 83 const struct imxi2c_platform_data *pdata)
14{ 84{
15 struct resource res[] = { 85 struct resource res[] = {
16 { 86 {
17 .start = iobase, 87 .start = data->iobase,
18 .end = iobase + iosize - 1, 88 .end = data->iobase + data->iosize - 1,
19 .flags = IORESOURCE_MEM, 89 .flags = IORESOURCE_MEM,
20 }, { 90 }, {
21 .start = irq, 91 .start = data->irq,
22 .end = irq, 92 .end = data->irq,
23 .flags = IORESOURCE_IRQ, 93 .flags = IORESOURCE_IRQ,
24 }, 94 },
25 }; 95 };
26 96
27 return imx_add_platform_device("imx-i2c", id, res, ARRAY_SIZE(res), 97 return imx_add_platform_device("imx-i2c", data->id,
98 res, ARRAY_SIZE(res),
28 pdata, sizeof(*pdata)); 99 pdata, sizeof(*pdata));
29} 100}
diff --git a/arch/arm/plat-mxc/devices/platform-imx-ssi.c b/arch/arm/plat-mxc/devices/platform-imx-ssi.c
new file mode 100644
index 000000000000..38a7a0b8f2f1
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-imx-ssi.c
@@ -0,0 +1,107 @@
1/*
2 * Copyright (C) 2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include <mach/hardware.h>
10#include <mach/devices-common.h>
11
12#define imx_imx_ssi_data_entry(soc, _id, _hwid, _size) \
13 [_id] = { \
14 .id = _id, \
15 .iobase = soc ## _SSI ## _hwid ## _BASE_ADDR, \
16 .iosize = _size, \
17 .irq = soc ## _INT_SSI ## _hwid, \
18 .dmatx0 = soc ## _DMA_REQ_SSI ## _hwid ## _TX0, \
19 .dmarx0 = soc ## _DMA_REQ_SSI ## _hwid ## _RX0, \
20 .dmatx1 = soc ## _DMA_REQ_SSI ## _hwid ## _TX1, \
21 .dmarx1 = soc ## _DMA_REQ_SSI ## _hwid ## _RX1, \
22 }
23
24#ifdef CONFIG_SOC_IMX21
25const struct imx_imx_ssi_data imx21_imx_ssi_data[] __initconst = {
26#define imx21_imx_ssi_data_entry(_id, _hwid) \
27 imx_imx_ssi_data_entry(MX21, _id, _hwid, SZ_4K)
28 imx21_imx_ssi_data_entry(0, 1),
29 imx21_imx_ssi_data_entry(1, 2),
30};
31#endif /* ifdef CONFIG_SOC_IMX21 */
32
33#ifdef CONFIG_ARCH_MX25
34const struct imx_imx_ssi_data imx25_imx_ssi_data[] __initconst = {
35#define imx25_imx_ssi_data_entry(_id, _hwid) \
36 imx_imx_ssi_data_entry(MX25, _id, _hwid, SZ_4K)
37 imx25_imx_ssi_data_entry(0, 1),
38 imx25_imx_ssi_data_entry(1, 2),
39};
40#endif /* ifdef CONFIG_ARCH_MX25 */
41
42#ifdef CONFIG_SOC_IMX27
43const struct imx_imx_ssi_data imx27_imx_ssi_data[] __initconst = {
44#define imx27_imx_ssi_data_entry(_id, _hwid) \
45 imx_imx_ssi_data_entry(MX27, _id, _hwid, SZ_4K)
46 imx27_imx_ssi_data_entry(0, 1),
47 imx27_imx_ssi_data_entry(1, 2),
48};
49#endif /* ifdef CONFIG_SOC_IMX27 */
50
51#ifdef CONFIG_ARCH_MX31
52const struct imx_imx_ssi_data imx31_imx_ssi_data[] __initconst = {
53#define imx31_imx_ssi_data_entry(_id, _hwid) \
54 imx_imx_ssi_data_entry(MX31, _id, _hwid, SZ_4K)
55 imx31_imx_ssi_data_entry(0, 1),
56 imx31_imx_ssi_data_entry(1, 2),
57};
58#endif /* ifdef CONFIG_ARCH_MX31 */
59
60#ifdef CONFIG_ARCH_MX35
61const struct imx_imx_ssi_data imx35_imx_ssi_data[] __initconst = {
62#define imx35_imx_ssi_data_entry(_id, _hwid) \
63 imx_imx_ssi_data_entry(MX35, _id, _hwid, SZ_4K)
64 imx35_imx_ssi_data_entry(0, 1),
65 imx35_imx_ssi_data_entry(1, 2),
66};
67#endif /* ifdef CONFIG_ARCH_MX35 */
68
69#ifdef CONFIG_ARCH_MX51
70const struct imx_imx_ssi_data imx51_imx_ssi_data[] __initconst = {
71#define imx51_imx_ssi_data_entry(_id, _hwid) \
72 imx_imx_ssi_data_entry(MX51, _id, _hwid, SZ_4K)
73 imx51_imx_ssi_data_entry(0, 1),
74 imx51_imx_ssi_data_entry(1, 2),
75};
76#endif /* ifdef CONFIG_ARCH_MX51 */
77
78struct platform_device *__init imx_add_imx_ssi(
79 const struct imx_imx_ssi_data *data,
80 const struct imx_ssi_platform_data *pdata)
81{
82 struct resource res[] = {
83 {
84 .start = data->iobase,
85 .end = data->iobase + data->iosize - 1,
86 .flags = IORESOURCE_MEM,
87 }, {
88 .start = data->irq,
89 .end = data->irq,
90 .flags = IORESOURCE_IRQ,
91 },
92#define DMARES(_name) { \
93 .name = #_name, \
94 .start = data->dma ## _name, \
95 .end = data->dma ## _name, \
96 .flags = IORESOURCE_DMA, \
97}
98 DMARES(tx0),
99 DMARES(rx0),
100 DMARES(tx1),
101 DMARES(rx1),
102 };
103
104 return imx_add_platform_device("imx-ssi", data->id,
105 res, ARRAY_SIZE(res),
106 pdata, sizeof(*pdata));
107}
diff --git a/arch/arm/plat-mxc/devices/platform-imx-uart.c b/arch/arm/plat-mxc/devices/platform-imx-uart.c
index fa3dff1433e8..2039640adf27 100644
--- a/arch/arm/plat-mxc/devices/platform-imx-uart.c
+++ b/arch/arm/plat-mxc/devices/platform-imx-uart.c
@@ -6,55 +6,148 @@
6 * the terms of the GNU General Public License version 2 as published by the 6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation. 7 * Free Software Foundation.
8 */ 8 */
9#include <mach/hardware.h>
9#include <mach/devices-common.h> 10#include <mach/devices-common.h>
10 11
11struct platform_device *__init imx_add_imx_uart_3irq(int id, 12#define imx_imx_uart_3irq_data_entry(soc, _id, _hwid, _size) \
12 resource_size_t iobase, resource_size_t iosize, 13 [_id] = { \
13 resource_size_t irqrx, resource_size_t irqtx, 14 .id = _id, \
14 resource_size_t irqrts, 15 .iobase = soc ## _UART ## _hwid ## _BASE_ADDR, \
16 .iosize = _size, \
17 .irqrx = soc ## _INT_UART ## _hwid ## RX, \
18 .irqtx = soc ## _INT_UART ## _hwid ## TX, \
19 .irqrts = soc ## _INT_UART ## _hwid ## RTS, \
20 }
21
22#define imx_imx_uart_1irq_data_entry(soc, _id, _hwid, _size) \
23 [_id] = { \
24 .id = _id, \
25 .iobase = soc ## _UART ## _hwid ## _BASE_ADDR, \
26 .iosize = _size, \
27 .irq = soc ## _INT_UART ## _hwid, \
28 }
29
30#ifdef CONFIG_SOC_IMX1
31const struct imx_imx_uart_3irq_data imx1_imx_uart_data[] __initconst = {
32#define imx1_imx_uart_data_entry(_id, _hwid) \
33 imx_imx_uart_3irq_data_entry(MX1, _id, _hwid, 0xd0)
34 imx1_imx_uart_data_entry(0, 1),
35 imx1_imx_uart_data_entry(1, 2),
36};
37#endif /* ifdef CONFIG_SOC_IMX1 */
38
39#ifdef CONFIG_SOC_IMX21
40const struct imx_imx_uart_1irq_data imx21_imx_uart_data[] __initconst = {
41#define imx21_imx_uart_data_entry(_id, _hwid) \
42 imx_imx_uart_1irq_data_entry(MX21, _id, _hwid, SZ_4K)
43 imx21_imx_uart_data_entry(0, 1),
44 imx21_imx_uart_data_entry(1, 2),
45 imx21_imx_uart_data_entry(2, 3),
46 imx21_imx_uart_data_entry(3, 4),
47};
48#endif
49
50#ifdef CONFIG_ARCH_MX25
51const struct imx_imx_uart_1irq_data imx25_imx_uart_data[] __initconst = {
52#define imx25_imx_uart_data_entry(_id, _hwid) \
53 imx_imx_uart_1irq_data_entry(MX25, _id, _hwid, SZ_16K)
54 imx25_imx_uart_data_entry(0, 1),
55 imx25_imx_uart_data_entry(1, 2),
56 imx25_imx_uart_data_entry(2, 3),
57 imx25_imx_uart_data_entry(3, 4),
58 imx25_imx_uart_data_entry(4, 5),
59};
60#endif /* ifdef CONFIG_ARCH_MX25 */
61
62#ifdef CONFIG_SOC_IMX27
63const struct imx_imx_uart_1irq_data imx27_imx_uart_data[] __initconst = {
64#define imx27_imx_uart_data_entry(_id, _hwid) \
65 imx_imx_uart_1irq_data_entry(MX27, _id, _hwid, SZ_4K)
66 imx27_imx_uart_data_entry(0, 1),
67 imx27_imx_uart_data_entry(1, 2),
68 imx27_imx_uart_data_entry(2, 3),
69 imx27_imx_uart_data_entry(3, 4),
70 imx27_imx_uart_data_entry(4, 5),
71 imx27_imx_uart_data_entry(5, 6),
72};
73#endif /* ifdef CONFIG_SOC_IMX27 */
74
75#ifdef CONFIG_ARCH_MX31
76const struct imx_imx_uart_1irq_data imx31_imx_uart_data[] __initconst = {
77#define imx31_imx_uart_data_entry(_id, _hwid) \
78 imx_imx_uart_1irq_data_entry(MX31, _id, _hwid, SZ_4K)
79 imx31_imx_uart_data_entry(0, 1),
80 imx31_imx_uart_data_entry(1, 2),
81 imx31_imx_uart_data_entry(2, 3),
82 imx31_imx_uart_data_entry(3, 4),
83 imx31_imx_uart_data_entry(4, 5),
84};
85#endif /* ifdef CONFIG_ARCH_MX31 */
86
87#ifdef CONFIG_ARCH_MX35
88const struct imx_imx_uart_1irq_data imx35_imx_uart_data[] __initconst = {
89#define imx35_imx_uart_data_entry(_id, _hwid) \
90 imx_imx_uart_1irq_data_entry(MX31, _id, _hwid, SZ_16K)
91 imx35_imx_uart_data_entry(0, 1),
92 imx35_imx_uart_data_entry(1, 2),
93 imx35_imx_uart_data_entry(2, 3),
94};
95#endif /* ifdef CONFIG_ARCH_MX35 */
96
97#ifdef CONFIG_ARCH_MX51
98const struct imx_imx_uart_1irq_data imx51_imx_uart_data[] __initconst = {
99#define imx51_imx_uart_data_entry(_id, _hwid) \
100 imx_imx_uart_1irq_data_entry(MX51, _id, _hwid, SZ_4K)
101 imx51_imx_uart_data_entry(0, 1),
102 imx51_imx_uart_data_entry(1, 2),
103 imx51_imx_uart_data_entry(2, 3),
104};
105#endif /* ifdef CONFIG_ARCH_MX51 */
106
107struct platform_device *__init imx_add_imx_uart_3irq(
108 const struct imx_imx_uart_3irq_data *data,
15 const struct imxuart_platform_data *pdata) 109 const struct imxuart_platform_data *pdata)
16{ 110{
17 struct resource res[] = { 111 struct resource res[] = {
18 { 112 {
19 .start = iobase, 113 .start = data->iobase,
20 .end = iobase + iosize - 1, 114 .end = data->iobase + data->iosize - 1,
21 .flags = IORESOURCE_MEM, 115 .flags = IORESOURCE_MEM,
22 }, { 116 }, {
23 .start = irqrx, 117 .start = data->irqrx,
24 .end = irqrx, 118 .end = data->irqrx,
25 .flags = IORESOURCE_IRQ, 119 .flags = IORESOURCE_IRQ,
26 }, { 120 }, {
27 .start = irqtx, 121 .start = data->irqtx,
28 .end = irqtx, 122 .end = data->irqtx,
29 .flags = IORESOURCE_IRQ, 123 .flags = IORESOURCE_IRQ,
30 }, { 124 }, {
31 .start = irqrts, 125 .start = data->irqrts,
32 .end = irqrx, 126 .end = data->irqrx,
33 .flags = IORESOURCE_IRQ, 127 .flags = IORESOURCE_IRQ,
34 }, 128 },
35 }; 129 };
36 130
37 return imx_add_platform_device("imx-uart", id, res, ARRAY_SIZE(res), 131 return imx_add_platform_device("imx-uart", data->id, res,
38 pdata, sizeof(*pdata)); 132 ARRAY_SIZE(res), pdata, sizeof(*pdata));
39} 133}
40 134
41struct platform_device *__init imx_add_imx_uart_1irq(int id, 135struct platform_device *__init imx_add_imx_uart_1irq(
42 resource_size_t iobase, resource_size_t iosize, 136 const struct imx_imx_uart_1irq_data *data,
43 resource_size_t irq,
44 const struct imxuart_platform_data *pdata) 137 const struct imxuart_platform_data *pdata)
45{ 138{
46 struct resource res[] = { 139 struct resource res[] = {
47 { 140 {
48 .start = iobase, 141 .start = data->iobase,
49 .end = iobase + iosize - 1, 142 .end = data->iobase + data->iosize - 1,
50 .flags = IORESOURCE_MEM, 143 .flags = IORESOURCE_MEM,
51 }, { 144 }, {
52 .start = irq, 145 .start = data->irq,
53 .end = irq, 146 .end = data->irq,
54 .flags = IORESOURCE_IRQ, 147 .flags = IORESOURCE_IRQ,
55 }, 148 },
56 }; 149 };
57 150
58 return imx_add_platform_device("imx-uart", id, res, ARRAY_SIZE(res), 151 return imx_add_platform_device("imx-uart", data->id, res, ARRAY_SIZE(res),
59 pdata, sizeof(*pdata)); 152 pdata, sizeof(*pdata));
60} 153}
diff --git a/arch/arm/plat-mxc/devices/platform-mxc_nand.c b/arch/arm/plat-mxc/devices/platform-mxc_nand.c
index 1c286418d123..3fdcc32e3d67 100644
--- a/arch/arm/plat-mxc/devices/platform-mxc_nand.c
+++ b/arch/arm/plat-mxc/devices/platform-mxc_nand.c
@@ -7,38 +7,77 @@
7 * Free Software Foundation. 7 * Free Software Foundation.
8 */ 8 */
9#include <asm/sizes.h> 9#include <asm/sizes.h>
10#include <mach/hardware.h>
10#include <mach/devices-common.h> 11#include <mach/devices-common.h>
11 12
12static struct platform_device *__init imx_add_mxc_nand(resource_size_t iobase, 13#define imx_mxc_nand_data_entry_single(soc, _size) \
13 int irq, const struct mxc_nand_platform_data *pdata, 14 { \
14 resource_size_t iosize) 15 .iobase = soc ## _NFC_BASE_ADDR, \
16 .iosize = _size, \
17 .irq = soc ## _INT_NFC \
18 }
19
20#define imx_mxc_nandv3_data_entry_single(soc, _size) \
21 { \
22 .id = -1, \
23 .iobase = soc ## _NFC_BASE_ADDR, \
24 .iosize = _size, \
25 .axibase = soc ## _NFC_AXI_BASE_ADDR, \
26 .irq = soc ## _INT_NFC \
27 }
28
29#ifdef CONFIG_SOC_IMX21
30const struct imx_mxc_nand_data imx21_mxc_nand_data __initconst =
31 imx_mxc_nand_data_entry_single(MX21, SZ_4K);
32#endif /* ifdef CONFIG_SOC_IMX21 */
33
34#ifdef CONFIG_ARCH_MX25
35const struct imx_mxc_nand_data imx25_mxc_nand_data __initconst =
36 imx_mxc_nand_data_entry_single(MX25, SZ_8K);
37#endif /* ifdef CONFIG_ARCH_MX25 */
38
39#ifdef CONFIG_SOC_IMX27
40const struct imx_mxc_nand_data imx27_mxc_nand_data __initconst =
41 imx_mxc_nand_data_entry_single(MX27, SZ_4K);
42#endif /* ifdef CONFIG_SOC_IMX27 */
43
44#ifdef CONFIG_ARCH_MX31
45const struct imx_mxc_nand_data imx31_mxc_nand_data __initconst =
46 imx_mxc_nand_data_entry_single(MX31, SZ_4K);
47#endif
48
49#ifdef CONFIG_ARCH_MX35
50const struct imx_mxc_nand_data imx35_mxc_nand_data __initconst =
51 imx_mxc_nand_data_entry_single(MX35, SZ_8K);
52#endif
53
54#ifdef CONFIG_ARCH_MX51
55const struct imx_mxc_nand_data imx51_mxc_nand_data __initconst =
56 imx_mxc_nandv3_data_entry_single(MX51, SZ_16K);
57#endif
58
59struct platform_device *__init imx_add_mxc_nand(
60 const struct imx_mxc_nand_data *data,
61 const struct mxc_nand_platform_data *pdata)
15{ 62{
16 static int id = 0; 63 /* AXI has to come first, that's how the mxc_nand driver expect it */
17
18 struct resource res[] = { 64 struct resource res[] = {
19 { 65 {
20 .start = iobase, 66 .start = data->axibase,
21 .end = iobase + iosize - 1, 67 .end = data->axibase + SZ_16K - 1,
22 .flags = IORESOURCE_MEM, 68 .flags = IORESOURCE_MEM,
23 }, { 69 }, {
24 .start = irq, 70 .start = data->iobase,
25 .end = irq, 71 .end = data->iobase + data->iosize - 1,
72 .flags = IORESOURCE_MEM,
73 }, {
74 .start = data->irq,
75 .end = data->irq,
26 .flags = IORESOURCE_IRQ, 76 .flags = IORESOURCE_IRQ,
27 }, 77 },
28 }; 78 };
29 79 return imx_add_platform_device("mxc_nand", data->id,
30 return imx_add_platform_device("mxc_nand", id++, res, ARRAY_SIZE(res), 80 res + !data->axibase,
81 ARRAY_SIZE(res) - !data->axibase,
31 pdata, sizeof(*pdata)); 82 pdata, sizeof(*pdata));
32} 83}
33
34struct platform_device *__init imx_add_mxc_nand_v1(resource_size_t iobase,
35 int irq, const struct mxc_nand_platform_data *pdata)
36{
37 return imx_add_mxc_nand(iobase, irq, pdata, SZ_4K);
38}
39
40struct platform_device *__init imx_add_mxc_nand_v21(resource_size_t iobase,
41 int irq, const struct mxc_nand_platform_data *pdata)
42{
43 return imx_add_mxc_nand(iobase, irq, pdata, SZ_8K);
44}
diff --git a/arch/arm/plat-mxc/devices/platform-spi_imx.c b/arch/arm/plat-mxc/devices/platform-spi_imx.c
index 2831a6d3eb4b..e48340ec331e 100644
--- a/arch/arm/plat-mxc/devices/platform-spi_imx.c
+++ b/arch/arm/plat-mxc/devices/platform-spi_imx.c
@@ -6,25 +6,96 @@
6 * the terms of the GNU General Public License version 2 as published by the 6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation. 7 * Free Software Foundation.
8 */ 8 */
9#include <asm/sizes.h> 9#include <mach/hardware.h>
10#include <mach/devices-common.h> 10#include <mach/devices-common.h>
11 11
12struct platform_device *__init imx_add_spi_imx(int id, 12#define imx_spi_imx_data_entry_single(soc, type, _devid, _id, hwid, _size) \
13 resource_size_t iobase, resource_size_t iosize, int irq, 13 { \
14 .devid = _devid, \
15 .id = _id, \
16 .iobase = soc ## _ ## type ## hwid ## _BASE_ADDR, \
17 .iosize = _size, \
18 .irq = soc ## _INT_ ## type ## hwid, \
19 }
20
21#define imx_spi_imx_data_entry(soc, type, devid, id, hwid, size) \
22 [id] = imx_spi_imx_data_entry_single(soc, type, devid, id, hwid, size)
23
24#ifdef CONFIG_SOC_IMX21
25const struct imx_spi_imx_data imx21_cspi_data[] __initconst = {
26#define imx21_cspi_data_entry(_id, _hwid) \
27 imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K)
28 imx21_cspi_data_entry(0, 1),
29 imx21_cspi_data_entry(1, 2),
30#endif
31
32#ifdef CONFIG_ARCH_MX25
33const struct imx_spi_imx_data imx25_cspi_data[] __initconst = {
34#define imx25_cspi_data_entry(_id, _hwid) \
35 imx_spi_imx_data_entry(MX25, CSPI, "imx25-cspi", _id, _hwid, SZ_16K)
36 imx25_cspi_data_entry(0, 1),
37 imx25_cspi_data_entry(1, 2),
38 imx25_cspi_data_entry(2, 3),
39};
40#endif /* ifdef CONFIG_ARCH_MX25 */
41
42#ifdef CONFIG_SOC_IMX27
43const struct imx_spi_imx_data imx27_cspi_data[] __initconst = {
44#define imx27_cspi_data_entry(_id, _hwid) \
45 imx_spi_imx_data_entry(MX27, CSPI, "imx27-cspi", _id, _hwid, SZ_4K)
46 imx27_cspi_data_entry(0, 1),
47 imx27_cspi_data_entry(1, 2),
48 imx27_cspi_data_entry(2, 3),
49};
50#endif /* ifdef CONFIG_SOC_IMX27 */
51
52#ifdef CONFIG_ARCH_MX31
53const struct imx_spi_imx_data imx31_cspi_data[] __initconst = {
54#define imx31_cspi_data_entry(_id, _hwid) \
55 imx_spi_imx_data_entry(MX31, CSPI, "imx31-cspi", _id, _hwid, SZ_4K)
56 imx31_cspi_data_entry(0, 1),
57 imx31_cspi_data_entry(1, 2),
58 imx31_cspi_data_entry(2, 3),
59};
60#endif /* ifdef CONFIG_ARCH_MX31 */
61
62#ifdef CONFIG_ARCH_MX35
63const struct imx_spi_imx_data imx35_cspi_data[] __initconst = {
64#define imx35_cspi_data_entry(_id, _hwid) \
65 imx_spi_imx_data_entry(MX35, CSPI, "imx35-cspi", _id, _hwid, SZ_4K)
66 imx35_cspi_data_entry(0, 1),
67 imx35_cspi_data_entry(1, 2),
68};
69#endif /* ifdef CONFIG_ARCH_MX35 */
70
71#ifdef CONFIG_ARCH_MX51
72const struct imx_spi_imx_data imx51_cspi_data __initconst =
73 imx_spi_imx_data_entry_single(MX51, CSPI, "imx51-cspi", 0, , SZ_4K);
74
75const struct imx_spi_imx_data imx51_ecspi_data[] __initconst = {
76#define imx51_ecspi_data_entry(_id, _hwid) \
77 imx_spi_imx_data_entry(MX51, ECSPI, "imx51-ecspi", _id, _hwid, SZ_4K)
78 imx51_ecspi_data_entry(0, 1),
79 imx51_ecspi_data_entry(1, 2),
80};
81#endif /* ifdef CONFIG_ARCH_MX51 */
82
83struct platform_device *__init imx_add_spi_imx(
84 const struct imx_spi_imx_data *data,
14 const struct spi_imx_master *pdata) 85 const struct spi_imx_master *pdata)
15{ 86{
16 struct resource res[] = { 87 struct resource res[] = {
17 { 88 {
18 .start = iobase, 89 .start = data->iobase,
19 .end = iobase + iosize - 1, 90 .end = data->iobase + data->iosize - 1,
20 .flags = IORESOURCE_MEM, 91 .flags = IORESOURCE_MEM,
21 }, { 92 }, {
22 .start = irq, 93 .start = data->irq,
23 .end = irq, 94 .end = data->irq,
24 .flags = IORESOURCE_IRQ, 95 .flags = IORESOURCE_IRQ,
25 }, 96 },
26 }; 97 };
27 98
28 return imx_add_platform_device("spi_imx", id, res, ARRAY_SIZE(res), 99 return imx_add_platform_device(data->devid, data->id,
29 pdata, sizeof(*pdata)); 100 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
30} 101}
diff --git a/arch/arm/plat-mxc/ehci.c b/arch/arm/plat-mxc/ehci.c
index 35a064ff02ba..9915607683de 100644
--- a/arch/arm/plat-mxc/ehci.c
+++ b/arch/arm/plat-mxc/ehci.c
@@ -249,8 +249,8 @@ int mxc_initialize_usb_hw(int port, unsigned int flags)
249#ifdef CONFIG_ARCH_MX51 249#ifdef CONFIG_ARCH_MX51
250 if (cpu_is_mx51()) { 250 if (cpu_is_mx51()) {
251 void __iomem *usb_base; 251 void __iomem *usb_base;
252 u32 usbotg_base; 252 void __iomem *usbotg_base;
253 u32 usbother_base; 253 void __iomem *usbother_base;
254 int ret = 0; 254 int ret = 0;
255 255
256 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); 256 usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K);
diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
new file mode 100644
index 000000000000..ee9582f4972e
--- /dev/null
+++ b/arch/arm/plat-mxc/epit.c
@@ -0,0 +1,242 @@
1/*
2 * linux/arch/arm/plat-mxc/epit.c
3 *
4 * Copyright (C) 2010 Sascha Hauer <s.hauer@pengutronix.de>
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 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#define EPITCR 0x00
22#define EPITSR 0x04
23#define EPITLR 0x08
24#define EPITCMPR 0x0c
25#define EPITCNR 0x10
26
27#define EPITCR_EN (1 << 0)
28#define EPITCR_ENMOD (1 << 1)
29#define EPITCR_OCIEN (1 << 2)
30#define EPITCR_RLD (1 << 3)
31#define EPITCR_PRESC(x) (((x) & 0xfff) << 4)
32#define EPITCR_SWR (1 << 16)
33#define EPITCR_IOVW (1 << 17)
34#define EPITCR_DBGEN (1 << 18)
35#define EPITCR_WAITEN (1 << 19)
36#define EPITCR_RES (1 << 20)
37#define EPITCR_STOPEN (1 << 21)
38#define EPITCR_OM_DISCON (0 << 22)
39#define EPITCR_OM_TOGGLE (1 << 22)
40#define EPITCR_OM_CLEAR (2 << 22)
41#define EPITCR_OM_SET (3 << 22)
42#define EPITCR_CLKSRC_OFF (0 << 24)
43#define EPITCR_CLKSRC_PERIPHERAL (1 << 24)
44#define EPITCR_CLKSRC_REF_HIGH (1 << 24)
45#define EPITCR_CLKSRC_REF_LOW (3 << 24)
46
47#define EPITSR_OCIF (1 << 0)
48
49#include <linux/interrupt.h>
50#include <linux/irq.h>
51#include <linux/clockchips.h>
52#include <linux/clk.h>
53
54#include <mach/hardware.h>
55#include <asm/mach/time.h>
56#include <mach/common.h>
57
58static struct clock_event_device clockevent_epit;
59static enum clock_event_mode clockevent_mode = CLOCK_EVT_MODE_UNUSED;
60
61static void __iomem *timer_base;
62
63static inline void epit_irq_disable(void)
64{
65 u32 val;
66
67 val = __raw_readl(timer_base + EPITCR);
68 val &= ~EPITCR_OCIEN;
69 __raw_writel(val, timer_base + EPITCR);
70}
71
72static inline void epit_irq_enable(void)
73{
74 u32 val;
75
76 val = __raw_readl(timer_base + EPITCR);
77 val |= EPITCR_OCIEN;
78 __raw_writel(val, timer_base + EPITCR);
79}
80
81static void epit_irq_acknowledge(void)
82{
83 __raw_writel(EPITSR_OCIF, timer_base + EPITSR);
84}
85
86static cycle_t epit_read(struct clocksource *cs)
87{
88 return 0 - __raw_readl(timer_base + EPITCNR);
89}
90
91static struct clocksource clocksource_epit = {
92 .name = "epit",
93 .rating = 200,
94 .read = epit_read,
95 .mask = CLOCKSOURCE_MASK(32),
96 .shift = 20,
97 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
98};
99
100static int __init epit_clocksource_init(struct clk *timer_clk)
101{
102 unsigned int c = clk_get_rate(timer_clk);
103
104 clocksource_epit.mult = clocksource_hz2mult(c,
105 clocksource_epit.shift);
106 clocksource_register(&clocksource_epit);
107
108 return 0;
109}
110
111/* clock event */
112
113static int epit_set_next_event(unsigned long evt,
114 struct clock_event_device *unused)
115{
116 unsigned long tcmp;
117
118 tcmp = __raw_readl(timer_base + EPITCNR);
119
120 __raw_writel(tcmp - evt, timer_base + EPITCMPR);
121
122 return 0;
123}
124
125static void epit_set_mode(enum clock_event_mode mode,
126 struct clock_event_device *evt)
127{
128 unsigned long flags;
129
130 /*
131 * The timer interrupt generation is disabled at least
132 * for enough time to call epit_set_next_event()
133 */
134 local_irq_save(flags);
135
136 /* Disable interrupt in GPT module */
137 epit_irq_disable();
138
139 if (mode != clockevent_mode) {
140 /* Set event time into far-far future */
141
142 /* Clear pending interrupt */
143 epit_irq_acknowledge();
144 }
145
146 /* Remember timer mode */
147 clockevent_mode = mode;
148 local_irq_restore(flags);
149
150 switch (mode) {
151 case CLOCK_EVT_MODE_PERIODIC:
152 printk(KERN_ERR "epit_set_mode: Periodic mode is not "
153 "supported for i.MX EPIT\n");
154 break;
155 case CLOCK_EVT_MODE_ONESHOT:
156 /*
157 * Do not put overhead of interrupt enable/disable into
158 * epit_set_next_event(), the core has about 4 minutes
159 * to call epit_set_next_event() or shutdown clock after
160 * mode switching
161 */
162 local_irq_save(flags);
163 epit_irq_enable();
164 local_irq_restore(flags);
165 break;
166 case CLOCK_EVT_MODE_SHUTDOWN:
167 case CLOCK_EVT_MODE_UNUSED:
168 case CLOCK_EVT_MODE_RESUME:
169 /* Left event sources disabled, no more interrupts appear */
170 break;
171 }
172}
173
174/*
175 * IRQ handler for the timer
176 */
177static irqreturn_t epit_timer_interrupt(int irq, void *dev_id)
178{
179 struct clock_event_device *evt = &clockevent_epit;
180
181 epit_irq_acknowledge();
182
183 evt->event_handler(evt);
184
185 return IRQ_HANDLED;
186}
187
188static struct irqaction epit_timer_irq = {
189 .name = "i.MX EPIT Timer Tick",
190 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
191 .handler = epit_timer_interrupt,
192};
193
194static struct clock_event_device clockevent_epit = {
195 .name = "epit",
196 .features = CLOCK_EVT_FEAT_ONESHOT,
197 .shift = 32,
198 .set_mode = epit_set_mode,
199 .set_next_event = epit_set_next_event,
200 .rating = 200,
201};
202
203static int __init epit_clockevent_init(struct clk *timer_clk)
204{
205 unsigned int c = clk_get_rate(timer_clk);
206
207 clockevent_epit.mult = div_sc(c, NSEC_PER_SEC,
208 clockevent_epit.shift);
209 clockevent_epit.max_delta_ns =
210 clockevent_delta2ns(0xfffffffe, &clockevent_epit);
211 clockevent_epit.min_delta_ns =
212 clockevent_delta2ns(0x800, &clockevent_epit);
213
214 clockevent_epit.cpumask = cpumask_of(0);
215
216 clockevents_register_device(&clockevent_epit);
217
218 return 0;
219}
220
221void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
222{
223 clk_enable(timer_clk);
224
225 timer_base = base;
226
227 /*
228 * Initialise to a known state (all timers off, and timing reset)
229 */
230 __raw_writel(0x0, timer_base + EPITCR);
231
232 __raw_writel(0xffffffff, timer_base + EPITLR);
233 __raw_writel(EPITCR_EN | EPITCR_CLKSRC_REF_HIGH | EPITCR_WAITEN,
234 timer_base + EPITCR);
235
236 /* init and register the timer to the framework */
237 epit_clocksource_init(timer_clk);
238 epit_clockevent_init(timer_clk);
239
240 /* Make irqs happen */
241 setup_irq(irq, &epit_timer_irq);
242}
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 57ec4a896a5d..9d38da077edb 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -235,7 +235,7 @@ static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
235 unsigned long flags; 235 unsigned long flags;
236 236
237 spin_lock_irqsave(&port->lock, flags); 237 spin_lock_irqsave(&port->lock, flags);
238 l = (__raw_readl(reg) & (~(1 << offset))) | (value << offset); 238 l = (__raw_readl(reg) & (~(1 << offset))) | (!!value << offset);
239 __raw_writel(l, reg); 239 __raw_writel(l, reg);
240 spin_unlock_irqrestore(&port->lock, flags); 240 spin_unlock_irqrestore(&port->lock, flags);
241} 241}
diff --git a/arch/arm/plat-mxc/include/mach/board-mx31ads.h b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
new file mode 100644
index 000000000000..94b60dd47137
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
13
14#include <mach/hardware.h>
15
16/*
17 * These symbols are used by drivers/net/cs89x0.c.
18 * This is ugly as hell, but we have to provide them until
19 * someone fixed the driver.
20 */
21
22/* Base address of PBC controller */
23#define PBC_BASE_ADDRESS MX31_CS4_BASE_ADDR_VIRT
24/* Offsets for the PBC Controller register */
25
26/* Ethernet Controller IO base address */
27#define PBC_CS8900A_IOBASE 0x020000
28
29#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START)
30
31#define EXPIO_INT_ENET_INT (MXC_EXP_IO_BASE + 8)
32
33#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index 2941472582d2..7a1e1f89ff09 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -32,6 +32,7 @@ extern void mx31_init_irq(void);
32extern void mx35_init_irq(void); 32extern void mx35_init_irq(void);
33extern void mx51_init_irq(void); 33extern void mx51_init_irq(void);
34extern void mxc91231_init_irq(void); 34extern void mxc91231_init_irq(void);
35extern void epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq);
35extern void mxc_timer_init(struct clk *timer_clk, void __iomem *, int); 36extern void mxc_timer_init(struct clk *timer_clk, void __iomem *, int);
36extern int mx1_clocks_init(unsigned long fref); 37extern int mx1_clocks_init(unsigned long fref);
37extern int mx21_clocks_init(unsigned long lref, unsigned long fref); 38extern int mx21_clocks_init(unsigned long lref, unsigned long fref);
diff --git a/arch/arm/plat-mxc/include/mach/debug-macro.S b/arch/arm/plat-mxc/include/mach/debug-macro.S
index 25606409aabc..d56213fb901b 100644
--- a/arch/arm/plat-mxc/include/mach/debug-macro.S
+++ b/arch/arm/plat-mxc/include/mach/debug-macro.S
@@ -62,11 +62,9 @@
62#define UART_PADDR MXC91231_UART2_BASE_ADDR 62#define UART_PADDR MXC91231_UART2_BASE_ADDR
63#define UART_VADDR MXC91231_IO_ADDRESS(MXC91231_UART2_BASE_ADDR) 63#define UART_VADDR MXC91231_IO_ADDRESS(MXC91231_UART2_BASE_ADDR)
64#endif 64#endif
65 .macro addruart, rx, tmp 65 .macro addruart, rp, rv
66 mrc p15, 0, \rx, c1, c0 66 ldr \rp, =UART_PADDR @ physical
67 tst \rx, #1 @ MMU enabled? 67 ldr \rv, =UART_VADDR @ virtual
68 ldreq \rx, =UART_PADDR @ physical
69 ldrne \rx, =UART_VADDR @ virtual
70 .endm 68 .endm
71 69
72 .macro senduart,rd,rx 70 .macro senduart,rd,rx
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index c5f68c587309..86d7575a564d 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -14,47 +14,105 @@ struct platform_device *imx_add_platform_device(const char *name, int id,
14 const struct resource *res, unsigned int num_resources, 14 const struct resource *res, unsigned int num_resources,
15 const void *data, size_t size_data); 15 const void *data, size_t size_data);
16 16
17#if defined (CONFIG_CAN_FLEXCAN) || defined (CONFIG_CAN_FLEXCAN_MODULE) 17#include <linux/fec.h>
18struct imx_fec_data {
19 resource_size_t iobase;
20 resource_size_t irq;
21};
22struct platform_device *__init imx_add_fec(
23 const struct imx_fec_data *data,
24 const struct fec_platform_data *pdata);
25
18#include <linux/can/platform/flexcan.h> 26#include <linux/can/platform/flexcan.h>
19struct platform_device *__init imx_add_flexcan(int id, 27struct platform_device *__init imx_add_flexcan(int id,
20 resource_size_t iobase, resource_size_t iosize, 28 resource_size_t iobase, resource_size_t iosize,
21 resource_size_t irq, 29 resource_size_t irq,
22 const struct flexcan_platform_data *pdata); 30 const struct flexcan_platform_data *pdata);
23#else
24/* the ifdef can be removed once the flexcan driver has been merged */
25struct flexcan_platform_data;
26static inline struct platform_device *__init imx_add_flexcan(int id,
27 resource_size_t iobase, resource_size_t iosize,
28 resource_size_t irq,
29 const struct flexcan_platform_data *pdata)
30{
31 return NULL;
32}
33#endif
34 31
35#include <mach/i2c.h> 32#include <mach/i2c.h>
36struct platform_device *__init imx_add_imx_i2c(int id, 33struct imx_imx_i2c_data {
37 resource_size_t iobase, resource_size_t iosize, int irq, 34 int id;
35 resource_size_t iobase;
36 resource_size_t iosize;
37 resource_size_t irq;
38};
39struct platform_device *__init imx_add_imx_i2c(
40 const struct imx_imx_i2c_data *data,
38 const struct imxi2c_platform_data *pdata); 41 const struct imxi2c_platform_data *pdata);
39 42
43#include <mach/ssi.h>
44struct imx_imx_ssi_data {
45 int id;
46 resource_size_t iobase;
47 resource_size_t iosize;
48 resource_size_t irq;
49 resource_size_t dmatx0;
50 resource_size_t dmarx0;
51 resource_size_t dmatx1;
52 resource_size_t dmarx1;
53};
54struct platform_device *__init imx_add_imx_ssi(
55 const struct imx_imx_ssi_data *data,
56 const struct imx_ssi_platform_data *pdata);
57
40#include <mach/imx-uart.h> 58#include <mach/imx-uart.h>
41struct platform_device *__init imx_add_imx_uart_3irq(int id, 59struct imx_imx_uart_3irq_data {
42 resource_size_t iobase, resource_size_t iosize, 60 int id;
43 resource_size_t irqrx, resource_size_t irqtx, 61 resource_size_t iobase;
44 resource_size_t irqrts, 62 resource_size_t iosize;
63 resource_size_t irqrx;
64 resource_size_t irqtx;
65 resource_size_t irqrts;
66};
67struct platform_device *__init imx_add_imx_uart_3irq(
68 const struct imx_imx_uart_3irq_data *data,
45 const struct imxuart_platform_data *pdata); 69 const struct imxuart_platform_data *pdata);
46struct platform_device *__init imx_add_imx_uart_1irq(int id, 70
47 resource_size_t iobase, resource_size_t iosize, 71struct imx_imx_uart_1irq_data {
48 resource_size_t irq, 72 int id;
73 resource_size_t iobase;
74 resource_size_t iosize;
75 resource_size_t irq;
76};
77struct platform_device *__init imx_add_imx_uart_1irq(
78 const struct imx_imx_uart_1irq_data *data,
49 const struct imxuart_platform_data *pdata); 79 const struct imxuart_platform_data *pdata);
50 80
51#include <mach/mxc_nand.h> 81#include <mach/mxc_nand.h>
52struct platform_device *__init imx_add_mxc_nand_v1(resource_size_t iobase, 82struct imx_mxc_nand_data {
53 int irq, const struct mxc_nand_platform_data *pdata); 83 /*
54struct platform_device *__init imx_add_mxc_nand_v21(resource_size_t iobase, 84 * id is traditionally 0, but -1 is more appropriate. We use -1 for new
55 int irq, const struct mxc_nand_platform_data *pdata); 85 * machines but don't change existing devices as the nand device usually
86 * appears in the kernel command line to pass its partitioning.
87 */
88 int id;
89 resource_size_t iobase;
90 resource_size_t iosize;
91 resource_size_t axibase;
92 resource_size_t irq;
93};
94struct platform_device *__init imx_add_mxc_nand(
95 const struct imx_mxc_nand_data *data,
96 const struct mxc_nand_platform_data *pdata);
56 97
57#include <mach/spi.h> 98#include <mach/spi.h>
58struct platform_device *__init imx_add_spi_imx(int id, 99struct imx_spi_imx_data {
59 resource_size_t iobase, resource_size_t iosize, int irq, 100 const char *devid;
101 int id;
102 resource_size_t iobase;
103 resource_size_t iosize;
104 int irq;
105};
106struct platform_device *__init imx_add_spi_imx(
107 const struct imx_spi_imx_data *data,
60 const struct spi_imx_master *pdata); 108 const struct spi_imx_master *pdata);
109
110#include <mach/esdhc.h>
111struct imx_esdhc_imx_data {
112 int id;
113 resource_size_t iobase;
114 resource_size_t irq;
115};
116struct platform_device *__init imx_add_esdhc(
117 const struct imx_esdhc_imx_data *data,
118 const struct esdhc_platform_data *pdata);
diff --git a/arch/arm/plat-mxc/include/mach/esdhc.h b/arch/arm/plat-mxc/include/mach/esdhc.h
new file mode 100644
index 000000000000..a48a9aaa56b1
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/esdhc.h
@@ -0,0 +1,16 @@
1/*
2 * Copyright 2010 Wolfram Sang <w.sang@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; version 2
7 * of the License.
8 */
9
10#ifndef __ASM_ARCH_IMX_ESDHC_H
11#define __ASM_ARCH_IMX_ESDHC_H
12
13struct esdhc_platform_data {
14 unsigned int wp_gpio; /* write protect pin */
15};
16#endif /* __ASM_ARCH_IMX_ESDHC_H */
diff --git a/arch/arm/plat-mxc/include/mach/eukrea-baseboards.h b/arch/arm/plat-mxc/include/mach/eukrea-baseboards.h
index 656acb45d434..a21d3313f994 100644
--- a/arch/arm/plat-mxc/include/mach/eukrea-baseboards.h
+++ b/arch/arm/plat-mxc/include/mach/eukrea-baseboards.h
@@ -28,19 +28,22 @@
28 * its own devices, it calls baseboard's init function. 28 * its own devices, it calls baseboard's init function.
29 * TODO: Add your own baseboard init function and call it from 29 * TODO: Add your own baseboard init function and call it from
30 * inside eukrea_cpuimx25_init() eukrea_cpuimx27_init() 30 * inside eukrea_cpuimx25_init() eukrea_cpuimx27_init()
31 * eukrea_cpuimx35_init() or eukrea_cpuimx51_init(). 31 * eukrea_cpuimx35_init() eukrea_cpuimx51_init()
32 * or eukrea_cpuimx51sd_init().
32 * 33 *
33 * This example here is for the development board. Refer 34 * This example here is for the development board. Refer
34 * mach-mx25/eukrea_mbimxsd-baseboard.c for cpuimx25 35 * mach-mx25/eukrea_mbimxsd-baseboard.c for cpuimx25
35 * mach-imx/eukrea_mbimx27-baseboard.c for cpuimx27 36 * mach-imx/eukrea_mbimx27-baseboard.c for cpuimx27
36 * mach-mx3/eukrea_mbimxsd-baseboard.c for cpuimx35 37 * mach-mx3/eukrea_mbimxsd-baseboard.c for cpuimx35
37 * mach-mx5/eukrea_mbimx51-baseboard.c for cpuimx51 38 * mach-mx5/eukrea_mbimx51-baseboard.c for cpuimx51
39 * mach-mx5/eukrea_mbimxsd-baseboard.c for cpuimx51sd
38 */ 40 */
39 41
40extern void eukrea_mbimxsd25_baseboard_init(void); 42extern void eukrea_mbimxsd25_baseboard_init(void);
41extern void eukrea_mbimx27_baseboard_init(void); 43extern void eukrea_mbimx27_baseboard_init(void);
42extern void eukrea_mbimxsd35_baseboard_init(void); 44extern void eukrea_mbimxsd35_baseboard_init(void);
43extern void eukrea_mbimx51_baseboard_init(void); 45extern void eukrea_mbimx51_baseboard_init(void);
46extern void eukrea_mbimxsd51_baseboard_init(void);
44 47
45#endif 48#endif
46 49
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index 21bfa46785bb..e46b1c2836d4 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -45,6 +45,18 @@ typedef enum iomux_config {
45 PAD_CTL_PKE | PAD_CTL_HYS) 45 PAD_CTL_PKE | PAD_CTL_HYS)
46#define MX51_GPIO_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PKE | \ 46#define MX51_GPIO_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PKE | \
47 PAD_CTL_SRE_FAST) 47 PAD_CTL_SRE_FAST)
48#define MX51_ECSPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \
49 PAD_CTL_SRE_FAST)
50#define MX51_SDHCI_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PUS_47K_UP | \
51 PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_SRE_FAST | \
52 PAD_CTL_DVS)
53
54#define MX51_PAD_CTRL_1 (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
55 PAD_CTL_PUE | PAD_CTL_PKE | PAD_CTL_HYS)
56#define MX51_PAD_CTRL_2 (PAD_CTL_HYS | PAD_CTL_PKE)
57#define MX51_PAD_CTRL_3 (PAD_CTL_PKE | PAD_CTL_PUS_100K_UP)
58#define MX51_PAD_CTRL_4 (PAD_CTL_DVS | PAD_CTL_HYS | PAD_CTL_PKE)
59#define MX51_PAD_CTRL_5 (PAD_CTL_DVS | PAD_CTL_DSE_HIGH)
48 60
49/* 61/*
50 * The naming convention for the pad modes is MX51_PAD_<padname>__<padmode> 62 * The naming convention for the pad modes is MX51_PAD_<padname>__<padmode>
@@ -106,14 +118,20 @@ typedef enum iomux_config {
106#define MX51_PAD_EIM_EB0__EIM_EB0 IOMUX_PAD(0x460, 0x0cc, 0, 0x0, 0, NO_PAD_CTRL) 118#define MX51_PAD_EIM_EB0__EIM_EB0 IOMUX_PAD(0x460, 0x0cc, 0, 0x0, 0, NO_PAD_CTRL)
107#define MX51_PAD_EIM_EB1__EIM_EB1 IOMUX_PAD(0x464, 0x0d0, 0, 0x0, 0, NO_PAD_CTRL) 119#define MX51_PAD_EIM_EB1__EIM_EB1 IOMUX_PAD(0x464, 0x0d0, 0, 0x0, 0, NO_PAD_CTRL)
108#define MX51_PAD_EIM_EB2__GPIO_2_22 IOMUX_PAD(0x468, 0x0d4, 1, 0x0, 0, NO_PAD_CTRL) 120#define MX51_PAD_EIM_EB2__GPIO_2_22 IOMUX_PAD(0x468, 0x0d4, 1, 0x0, 0, NO_PAD_CTRL)
121#define MX51_PAD_EIM_EB2__FEC_MDIO IOMUX_PAD(0x468, 0x0d4, 3, 0x0, 0, MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP)
109#define MX51_PAD_EIM_EB3__GPIO_2_23 IOMUX_PAD(0x46c, 0x0d8, 1, 0x0, 0, NO_PAD_CTRL) 122#define MX51_PAD_EIM_EB3__GPIO_2_23 IOMUX_PAD(0x46c, 0x0d8, 1, 0x0, 0, NO_PAD_CTRL)
123#define MX51_PAD_EIM_EB3__FEC_RDAT1 IOMUX_PAD(0x46c, 0x0d8, 3, 0x0, 0, MX51_PAD_CTRL_2)
110#define MX51_PAD_EIM_OE__GPIO_2_24 IOMUX_PAD(0x470, 0x0dc, 1, 0x0, 0, NO_PAD_CTRL) 124#define MX51_PAD_EIM_OE__GPIO_2_24 IOMUX_PAD(0x470, 0x0dc, 1, 0x0, 0, NO_PAD_CTRL)
111#define MX51_PAD_EIM_CS0__GPIO_2_25 IOMUX_PAD(0x474, 0x0e0, 1, 0x0, 0, NO_PAD_CTRL) 125#define MX51_PAD_EIM_CS0__GPIO_2_25 IOMUX_PAD(0x474, 0x0e0, 1, 0x0, 0, NO_PAD_CTRL)
112#define MX51_PAD_EIM_CS1__GPIO_2_26 IOMUX_PAD(0x478, 0x0e4, 1, 0x0, 0, NO_PAD_CTRL) 126#define MX51_PAD_EIM_CS1__GPIO_2_26 IOMUX_PAD(0x478, 0x0e4, 1, 0x0, 0, NO_PAD_CTRL)
113#define MX51_PAD_EIM_CS2__GPIO_2_27 IOMUX_PAD(0x47c, 0x0e8, 1, 0x0, 0, NO_PAD_CTRL) 127#define MX51_PAD_EIM_CS2__GPIO_2_27 IOMUX_PAD(0x47c, 0x0e8, 1, 0x0, 0, NO_PAD_CTRL)
128#define MX51_PAD_EIM_CS2__FEC_RDAT2 IOMUX_PAD(0x47c, 0x0e8, 3, 0x0, 0, MX51_PAD_CTRL_2)
114#define MX51_PAD_EIM_CS3__GPIO_2_28 IOMUX_PAD(0x480, 0x0ec, 1, 0x0, 0, NO_PAD_CTRL) 129#define MX51_PAD_EIM_CS3__GPIO_2_28 IOMUX_PAD(0x480, 0x0ec, 1, 0x0, 0, NO_PAD_CTRL)
130#define MX51_PAD_EIM_CS3__FEC_RDAT3 IOMUX_PAD(0x480, 0x0ec, 3, 0x0, 0, MX51_PAD_CTRL_2)
115#define MX51_PAD_EIM_CS4__GPIO_2_29 IOMUX_PAD(0x484, 0x0f0, 1, 0x0, 0, NO_PAD_CTRL) 131#define MX51_PAD_EIM_CS4__GPIO_2_29 IOMUX_PAD(0x484, 0x0f0, 1, 0x0, 0, NO_PAD_CTRL)
132#define MX51_PAD_EIM_CS4__FEC_RX_ER IOMUX_PAD(0x484, 0x0f0, 3, 0x0, 0, MX51_PAD_CTRL_2)
116#define MX51_PAD_EIM_CS5__GPIO_2_30 IOMUX_PAD(0x488, 0x0f4, 1, 0x0, 0, NO_PAD_CTRL) 133#define MX51_PAD_EIM_CS5__GPIO_2_30 IOMUX_PAD(0x488, 0x0f4, 1, 0x0, 0, NO_PAD_CTRL)
134#define MX51_PAD_EIM_CS5__FEC_CRS IOMUX_PAD(0x488, 0x0f4, 3, 0x0, 0, MX51_PAD_CTRL_2)
117#define MX51_PAD_EIM_DTACK__GPIO_2_31 IOMUX_PAD(0x48c, 0x0f8, 1, 0x0, 0, NO_PAD_CTRL) 135#define MX51_PAD_EIM_DTACK__GPIO_2_31 IOMUX_PAD(0x48c, 0x0f8, 1, 0x0, 0, NO_PAD_CTRL)
118#define MX51_PAD_EIM_LBA__GPIO_3_1 IOMUX_PAD(0x494, 0x0FC, 1, 0x0, 0, NO_PAD_CTRL) 136#define MX51_PAD_EIM_LBA__GPIO_3_1 IOMUX_PAD(0x494, 0x0FC, 1, 0x0, 0, NO_PAD_CTRL)
119#define MX51_PAD_EIM_CRE__GPIO_3_2 IOMUX_PAD(0x4A0, 0x100, 1, 0x0, 0, NO_PAD_CTRL) 137#define MX51_PAD_EIM_CRE__GPIO_3_2 IOMUX_PAD(0x4A0, 0x100, 1, 0x0, 0, NO_PAD_CTRL)
@@ -126,18 +144,32 @@ typedef enum iomux_config {
126#define MX51_PAD_NANDF_RB0__GPIO_3_8 IOMUX_PAD(0x4F8, 0x11C, 3, 0x0, 0, NO_PAD_CTRL) 144#define MX51_PAD_NANDF_RB0__GPIO_3_8 IOMUX_PAD(0x4F8, 0x11C, 3, 0x0, 0, NO_PAD_CTRL)
127#define MX51_PAD_NANDF_RB1__GPIO_3_9 IOMUX_PAD(0x4FC, 0x120, 3, 0x0, 0, NO_PAD_CTRL) 145#define MX51_PAD_NANDF_RB1__GPIO_3_9 IOMUX_PAD(0x4FC, 0x120, 3, 0x0, 0, NO_PAD_CTRL)
128#define MX51_PAD_NANDF_RB2__GPIO_3_10 IOMUX_PAD(0x500, 0x124, 3, 0x0, 0, NO_PAD_CTRL) 146#define MX51_PAD_NANDF_RB2__GPIO_3_10 IOMUX_PAD(0x500, 0x124, 3, 0x0, 0, NO_PAD_CTRL)
147#define MX51_PAD_NANDF_RB2__ECSPI2_SCLK IOMUX_PAD(0x500, 0x124, 2, 0x0, 0, MX51_ECSPI_PAD_CTRL)
148#define MX51_PAD_NANDF_RB2__FEC_COL IOMUX_PAD(0x500, 0x124, 1, 0x0, 0, MX51_PAD_CTRL_2)
129#define MX51_PAD_NANDF_RB3__GPIO_3_11 IOMUX_PAD(0x504, 0x128, 3, 0x0, 0, NO_PAD_CTRL) 149#define MX51_PAD_NANDF_RB3__GPIO_3_11 IOMUX_PAD(0x504, 0x128, 3, 0x0, 0, NO_PAD_CTRL)
150#define MX51_PAD_NANDF_RB3__ECSPI2_MISO IOMUX_PAD(0x504, 0x128, 2, 0x0, 0, MX51_ECSPI_PAD_CTRL)
151#define MX51_PAD_NANDF_RB3__FEC_RXCLK IOMUX_PAD(0x504, 0x128, 1, 0x0, 0, MX51_PAD_CTRL_2)
152#define MX51_PAD_NANDF_RB6__FEC_RDAT0 IOMUX_PAD(0x5DC, 0x134, 1, 0x0, 0, MX51_PAD_CTRL_4)
153#define MX51_PAD_NANDF_RB7__FEC_TDAT0 IOMUX_PAD(0x5E0, 0x138, 1, 0x0, 0, MX51_PAD_CTRL_5)
130#define MX51_PAD_GPIO_NAND__GPIO_3_12 IOMUX_PAD(0x514, 0x12C, 3, 0x0, 0, NO_PAD_CTRL) 154#define MX51_PAD_GPIO_NAND__GPIO_3_12 IOMUX_PAD(0x514, 0x12C, 3, 0x0, 0, NO_PAD_CTRL)
131#define MX51_PAD_NANDF_CS0__GPIO_3_16 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, NO_PAD_CTRL) 155#define MX51_PAD_NANDF_CS0__GPIO_3_16 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, NO_PAD_CTRL)
132#define MX51_PAD_NANDF_CS1__GPIO_3_17 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, NO_PAD_CTRL) 156#define MX51_PAD_NANDF_CS1__GPIO_3_17 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, NO_PAD_CTRL)
133#define MX51_PAD_NANDF_CS2__GPIO_3_18 IOMUX_PAD(0x520, 0x138, 3, 0x0, 0, NO_PAD_CTRL) 157#define MX51_PAD_NANDF_CS2__GPIO_3_18 IOMUX_PAD(0x520, 0x138, 3, 0x0, 0, NO_PAD_CTRL)
158#define MX51_PAD_NANDF_CS2__FEC_TX_ER IOMUX_PAD(0x520, 0x138, 2, 0x0, 0, MX51_PAD_CTRL_5)
134#define MX51_PAD_NANDF_CS3__GPIO_3_19 IOMUX_PAD(0x524, 0x13C, 3, 0x0, 0, NO_PAD_CTRL) 159#define MX51_PAD_NANDF_CS3__GPIO_3_19 IOMUX_PAD(0x524, 0x13C, 3, 0x0, 0, NO_PAD_CTRL)
160#define MX51_PAD_NANDF_CS3__FEC_MDC IOMUX_PAD(0x524, 0x13C, 2, 0x0, 0, MX51_PAD_CTRL_5)
135#define MX51_PAD_NANDF_CS4__GPIO_3_20 IOMUX_PAD(0x528, 0x140, 3, 0x0, 0, NO_PAD_CTRL) 161#define MX51_PAD_NANDF_CS4__GPIO_3_20 IOMUX_PAD(0x528, 0x140, 3, 0x0, 0, NO_PAD_CTRL)
162#define MX51_PAD_NANDF_CS4__FEC_TDAT1 IOMUX_PAD(0x528, 0x140, 2, 0x0, 0, MX51_PAD_CTRL_5)
136#define MX51_PAD_NANDF_CS5__GPIO_3_21 IOMUX_PAD(0x52C, 0x144, 3, 0x0, 0, NO_PAD_CTRL) 163#define MX51_PAD_NANDF_CS5__GPIO_3_21 IOMUX_PAD(0x52C, 0x144, 3, 0x0, 0, NO_PAD_CTRL)
164#define MX51_PAD_NANDF_CS5__FEC_TDAT2 IOMUX_PAD(0x52C, 0x144, 2, 0x0, 0, MX51_PAD_CTRL_5)
137#define MX51_PAD_NANDF_CS6__GPIO_3_22 IOMUX_PAD(0x530, 0x148, 3, 0x0, 0, NO_PAD_CTRL) 165#define MX51_PAD_NANDF_CS6__GPIO_3_22 IOMUX_PAD(0x530, 0x148, 3, 0x0, 0, NO_PAD_CTRL)
166#define MX51_PAD_NANDF_CS6__FEC_TDAT3 IOMUX_PAD(0x530, 0x148, 2, 0x0, 0, MX51_PAD_CTRL_5)
138#define MX51_PAD_NANDF_CS7__GPIO_3_23 IOMUX_PAD(0x534, 0x14C, 3, 0x0, 0, NO_PAD_CTRL) 167#define MX51_PAD_NANDF_CS7__GPIO_3_23 IOMUX_PAD(0x534, 0x14C, 3, 0x0, 0, NO_PAD_CTRL)
168#define MX51_PAD_NANDF_CS7__FEC_TX_EN IOMUX_PAD(0x534, 0x14C, 1, 0x0, 0, MX51_PAD_CTRL_5)
139#define MX51_PAD_NANDF_RDY_INT__GPIO_3_24 IOMUX_PAD(0x538, 0x150, 3, 0x0, 0, NO_PAD_CTRL) 169#define MX51_PAD_NANDF_RDY_INT__GPIO_3_24 IOMUX_PAD(0x538, 0x150, 3, 0x0, 0, NO_PAD_CTRL)
170#define MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK IOMUX_PAD(0x538, 0x150, 1, 0x0, 0, MX51_PAD_CTRL_4)
140#define MX51_PAD_NANDF_D15__GPIO_3_25 IOMUX_PAD(0x53C, 0x154, 3, 0x0, 0, NO_PAD_CTRL) 171#define MX51_PAD_NANDF_D15__GPIO_3_25 IOMUX_PAD(0x53C, 0x154, 3, 0x0, 0, NO_PAD_CTRL)
172#define MX51_PAD_NANDF_D15__ECSPI2_MOSI IOMUX_PAD(0x53C, 0x154, 2, 0x0, 0, MX51_ECSPI_PAD_CTRL)
141#define MX51_PAD_NANDF_D14__GPIO_3_26 IOMUX_PAD(0x540, 0x158, 3, 0x0, 0, NO_PAD_CTRL) 173#define MX51_PAD_NANDF_D14__GPIO_3_26 IOMUX_PAD(0x540, 0x158, 3, 0x0, 0, NO_PAD_CTRL)
142#define MX51_PAD_NANDF_D13__GPIO_3_27 IOMUX_PAD(0x544, 0x15C, 3, 0x0, 0, NO_PAD_CTRL) 174#define MX51_PAD_NANDF_D13__GPIO_3_27 IOMUX_PAD(0x544, 0x15C, 3, 0x0, 0, NO_PAD_CTRL)
143#define MX51_PAD_NANDF_D12__GPIO_3_28 IOMUX_PAD(0x548, 0x160, 3, 0x0, 0, NO_PAD_CTRL) 175#define MX51_PAD_NANDF_D12__GPIO_3_28 IOMUX_PAD(0x548, 0x160, 3, 0x0, 0, NO_PAD_CTRL)
@@ -185,15 +217,25 @@ typedef enum iomux_config {
185#define MX51_PAD_I2C1_CLK__HSI2C_CLK IOMUX_PAD(0x5E8, 0x1F8, 0, 0x0, 0, NO_PAD_CTRL) 217#define MX51_PAD_I2C1_CLK__HSI2C_CLK IOMUX_PAD(0x5E8, 0x1F8, 0, 0x0, 0, NO_PAD_CTRL)
186#define MX51_PAD_I2C1_DAT__GPIO_4_17 IOMUX_PAD(0x5EC, 0x1FC, 3, 0x0, 0, NO_PAD_CTRL) 218#define MX51_PAD_I2C1_DAT__GPIO_4_17 IOMUX_PAD(0x5EC, 0x1FC, 3, 0x0, 0, NO_PAD_CTRL)
187#define MX51_PAD_I2C1_DAT__HSI2C_DAT IOMUX_PAD(0x5EC, 0x1FC, 0, 0x0, 0, NO_PAD_CTRL) 219#define MX51_PAD_I2C1_DAT__HSI2C_DAT IOMUX_PAD(0x5EC, 0x1FC, 0, 0x0, 0, NO_PAD_CTRL)
220#define MX51_PAD_AUD3_BB_TXD__AUD3_BB_TXD IOMUX_PAD(0x5F0, 0x200, IOMUX_CONFIG_SION, 0x0, 0, NO_PAD_CTRL)
188#define MX51_PAD_AUD3_BB_TXD__GPIO_4_18 IOMUX_PAD(0x5F0, 0x200, 3, 0x0, 0, NO_PAD_CTRL) 221#define MX51_PAD_AUD3_BB_TXD__GPIO_4_18 IOMUX_PAD(0x5F0, 0x200, 3, 0x0, 0, NO_PAD_CTRL)
222#define MX51_PAD_AUD3_BB_RXD__AUD3_BB_RXD IOMUX_PAD(0x5F4, 0x204, IOMUX_CONFIG_SION, 0x0, 0, NO_PAD_CTRL)
189#define MX51_PAD_AUD3_BB_RXD__GPIO_4_19 IOMUX_PAD(0x5F4, 0x204, 3, 0x0, 0, NO_PAD_CTRL) 223#define MX51_PAD_AUD3_BB_RXD__GPIO_4_19 IOMUX_PAD(0x5F4, 0x204, 3, 0x0, 0, NO_PAD_CTRL)
224#define MX51_PAD_AUD3_BB_CK__AUD3_BB_CK IOMUX_PAD(0x5F8, 0x208, IOMUX_CONFIG_SION, 0x0, 0, NO_PAD_CTRL)
190#define MX51_PAD_AUD3_BB_CK__GPIO_4_20 IOMUX_PAD(0x5F8, 0x208, 3, 0x0, 0, NO_PAD_CTRL) 225#define MX51_PAD_AUD3_BB_CK__GPIO_4_20 IOMUX_PAD(0x5F8, 0x208, 3, 0x0, 0, NO_PAD_CTRL)
226#define MX51_PAD_AUD3_BB_FS__AUD3_BB_FS IOMUX_PAD(0x5FC, 0x20C, IOMUX_CONFIG_SION, 0x0, 0, NO_PAD_CTRL)
191#define MX51_PAD_AUD3_BB_FS__GPIO_4_21 IOMUX_PAD(0x5FC, 0x20C, 3, 0x0, 0, NO_PAD_CTRL) 227#define MX51_PAD_AUD3_BB_FS__GPIO_4_21 IOMUX_PAD(0x5FC, 0x20C, 3, 0x0, 0, NO_PAD_CTRL)
228#define MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI IOMUX_PAD(0x600, 0x210, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
192#define MX51_PAD_CSPI1_MOSI__GPIO_4_22 IOMUX_PAD(0x600, 0x210, 3, 0x0, 0, NO_PAD_CTRL) 229#define MX51_PAD_CSPI1_MOSI__GPIO_4_22 IOMUX_PAD(0x600, 0x210, 3, 0x0, 0, NO_PAD_CTRL)
230#define MX51_PAD_CSPI1_MISO__ECSPI1_MISO IOMUX_PAD(0x604, 0x214, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
193#define MX51_PAD_CSPI1_MISO__GPIO_4_23 IOMUX_PAD(0x604, 0x214, 3, 0x0, 0, NO_PAD_CTRL) 231#define MX51_PAD_CSPI1_MISO__GPIO_4_23 IOMUX_PAD(0x604, 0x214, 3, 0x0, 0, NO_PAD_CTRL)
232#define MX51_PAD_CSPI1_SS0__ECSPI1_SS0 IOMUX_PAD(0x608, 0x218, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
194#define MX51_PAD_CSPI1_SS0__GPIO_4_24 IOMUX_PAD(0x608, 0x218, 3, 0x0, 0, NO_PAD_CTRL) 233#define MX51_PAD_CSPI1_SS0__GPIO_4_24 IOMUX_PAD(0x608, 0x218, 3, 0x0, 0, NO_PAD_CTRL)
234#define MX51_PAD_CSPI1_SS1__ECSPI1_SS1 IOMUX_PAD(0x60C, 0x21C, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
195#define MX51_PAD_CSPI1_SS1__GPIO_4_25 IOMUX_PAD(0x60C, 0x21C, 3, 0x0, 0, NO_PAD_CTRL) 235#define MX51_PAD_CSPI1_SS1__GPIO_4_25 IOMUX_PAD(0x60C, 0x21C, 3, 0x0, 0, NO_PAD_CTRL)
236#define MX51_PAD_CSPI1_RDY__ECSPI1_RDY IOMUX_PAD(0x610, 0x220, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
196#define MX51_PAD_CSPI1_RDY__GPIO_4_26 IOMUX_PAD(0x610, 0x220, 3, 0x0, 0, NO_PAD_CTRL) 237#define MX51_PAD_CSPI1_RDY__GPIO_4_26 IOMUX_PAD(0x610, 0x220, 3, 0x0, 0, NO_PAD_CTRL)
238#define MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK IOMUX_PAD(0x614, 0x224, 0, 0x0, 0, MX51_ECSPI_PAD_CTRL)
197#define MX51_PAD_CSPI1_SCLK__GPIO_4_27 IOMUX_PAD(0x614, 0x224, 3, 0x0, 0, NO_PAD_CTRL) 239#define MX51_PAD_CSPI1_SCLK__GPIO_4_27 IOMUX_PAD(0x614, 0x224, 3, 0x0, 0, NO_PAD_CTRL)
198#define MX51_PAD_UART1_RXD__UART1_RXD IOMUX_PAD(0x618, 0x228, 0, 0x9e4, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST) 240#define MX51_PAD_UART1_RXD__UART1_RXD IOMUX_PAD(0x618, 0x228, 0, 0x9e4, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
199#define MX51_PAD_UART1_TXD__UART1_TXD IOMUX_PAD(0x61C, 0x22C, 0, 0x0, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST) 241#define MX51_PAD_UART1_TXD__UART1_TXD IOMUX_PAD(0x61C, 0x22C, 0, 0x0, 0, MX51_UART1_PAD_CTRL | PAD_CTL_SRE_FAST)
@@ -236,14 +278,14 @@ typedef enum iomux_config {
236#define MX51_PAD_USBH1_DATA6__USBH1_DATA6 IOMUX_PAD(0x6A0, 0x2A0, 0, 0x0, 0, MX51_USBH1_PAD_CTRL) 278#define MX51_PAD_USBH1_DATA6__USBH1_DATA6 IOMUX_PAD(0x6A0, 0x2A0, 0, 0x0, 0, MX51_USBH1_PAD_CTRL)
237#define MX51_PAD_USBH1_DATA7__USBH1_DATA7 IOMUX_PAD(0x6A4, 0x2A4, 0, 0x0, 0, MX51_USBH1_PAD_CTRL) 279#define MX51_PAD_USBH1_DATA7__USBH1_DATA7 IOMUX_PAD(0x6A4, 0x2A4, 0, 0x0, 0, MX51_USBH1_PAD_CTRL)
238#define MX51_PAD_DI1_PIN11__GPIO_3_0 IOMUX_PAD(0x6A8, 0x2A8, 4, 0x0, 0, NO_PAD_CTRL) 280#define MX51_PAD_DI1_PIN11__GPIO_3_0 IOMUX_PAD(0x6A8, 0x2A8, 4, 0x0, 0, NO_PAD_CTRL)
239#define MX51_PAD_DI1_PIN12__GPIO_3_1 IOMUX_PAD(0x6AC, 0x2AC, 4, 0x0, 0, NO_PAD_CTRL) 281#define MX51_PAD_DI1_PIN12__GPIO_3_1 IOMUX_PAD(0x6AC, 0x2AC, 4, 0x978, 1, NO_PAD_CTRL)
240#define MX51_PAD_DI1_PIN13__GPIO_3_2 IOMUX_PAD(0x6B0, 0x2B0, 4, 0x0, 0, NO_PAD_CTRL) 282#define MX51_PAD_DI1_PIN13__GPIO_3_2 IOMUX_PAD(0x6B0, 0x2B0, 4, 0x97c, 1, NO_PAD_CTRL)
241#define MX51_PAD_DI1_D0_CS__GPIO_3_3 IOMUX_PAD(0x6B4, 0x2B4, 4, 0x0, 0, NO_PAD_CTRL) 283#define MX51_PAD_DI1_D0_CS__GPIO_3_3 IOMUX_PAD(0x6B4, 0x2B4, 4, 0x980, 1, NO_PAD_CTRL)
242#define MX51_PAD_DI1_D1_CS__GPIO_3_4 IOMUX_PAD(0x6B8, 0x2B8, 4, 0x0, 0, NO_PAD_CTRL) 284#define MX51_PAD_DI1_D1_CS__GPIO_3_4 IOMUX_PAD(0x6B8, 0x2B8, 4, 0x984, 1, NO_PAD_CTRL)
243#define MX51_PAD_DISPB2_SER_DIN__GPIO_3_5 IOMUX_PAD(0x6BC, 0x2BC, 4, 0x0, 0, NO_PAD_CTRL) 285#define MX51_PAD_DISPB2_SER_DIN__GPIO_3_5 IOMUX_PAD(0x6BC, 0x2BC, 4, 0x988, 1, NO_PAD_CTRL)
244#define MX51_PAD_DISPB2_SER_DIO__GPIO_3_6 IOMUX_PAD(0x6C0, 0x2C0, 4, 0x0, 0, NO_PAD_CTRL) 286#define MX51_PAD_DISPB2_SER_DIO__GPIO_3_6 IOMUX_PAD(0x6C0, 0x2C0, 4, 0x98c, 1, NO_PAD_CTRL)
245#define MX51_PAD_DISPB2_SER_CLK__GPIO_3_7 IOMUX_PAD(0x6C4, 0x2C4, 4, 0x0, 0, NO_PAD_CTRL) 287#define MX51_PAD_DISPB2_SER_CLK__GPIO_3_7 IOMUX_PAD(0x6C4, 0x2C4, 4, 0x990, 1, NO_PAD_CTRL)
246#define MX51_PAD_DISPB2_SER_RS__GPIO_3_8 IOMUX_PAD(0x6C8, 0x2C8, 4, 0x0, 0, NO_PAD_CTRL) 288#define MX51_PAD_DISPB2_SER_RS__GPIO_3_8 IOMUX_PAD(0x6C8, 0x2C8, 4, 0x994, 1, NO_PAD_CTRL)
247#define MX51_PAD_DISP1_DAT0__DISP1_DAT0 IOMUX_PAD(0x6CC, 0x2CC, 0, 0x0, 0, NO_PAD_CTRL) 289#define MX51_PAD_DISP1_DAT0__DISP1_DAT0 IOMUX_PAD(0x6CC, 0x2CC, 0, 0x0, 0, NO_PAD_CTRL)
248#define MX51_PAD_DISP1_DAT1__DISP1_DAT1 IOMUX_PAD(0x6D0, 0x2D0, 0, 0x0, 0, NO_PAD_CTRL) 290#define MX51_PAD_DISP1_DAT1__DISP1_DAT1 IOMUX_PAD(0x6D0, 0x2D0, 0, 0x0, 0, NO_PAD_CTRL)
249#define MX51_PAD_DISP1_DAT2__DISP1_DAT2 IOMUX_PAD(0x6D4, 0x2D4, 0, 0x0, 0, NO_PAD_CTRL) 291#define MX51_PAD_DISP1_DAT2__DISP1_DAT2 IOMUX_PAD(0x6D4, 0x2D4, 0, 0x0, 0, NO_PAD_CTRL)
@@ -294,32 +336,50 @@ typedef enum iomux_config {
294#define MX51_PAD_DISP2_DAT13__DISP2_DAT13 IOMUX_PAD(0x790, 0x388, 0, 0x0, 0, NO_PAD_CTRL) 336#define MX51_PAD_DISP2_DAT13__DISP2_DAT13 IOMUX_PAD(0x790, 0x388, 0, 0x0, 0, NO_PAD_CTRL)
295#define MX51_PAD_DISP2_DAT14__DISP2_DAT14 IOMUX_PAD(0x794, 0x38C, 0, 0x0, 0, NO_PAD_CTRL) 337#define MX51_PAD_DISP2_DAT14__DISP2_DAT14 IOMUX_PAD(0x794, 0x38C, 0, 0x0, 0, NO_PAD_CTRL)
296#define MX51_PAD_DISP2_DAT15__DISP2_DAT15 IOMUX_PAD(0x798, 0x390, 0, 0x0, 0, NO_PAD_CTRL) 338#define MX51_PAD_DISP2_DAT15__DISP2_DAT15 IOMUX_PAD(0x798, 0x390, 0, 0x0, 0, NO_PAD_CTRL)
297#define MX51_PAD_SD1_CMD__SD1_CMD IOMUX_PAD(0x79C, 0x394, 0, 0x0, 0, NO_PAD_CTRL) 339#define MX51_PAD_SD1_CMD__SD1_CMD IOMUX_PAD(0x79C, 0x394, IOMUX_CONFIG_SION, 0x0, 0, \
298#define MX51_PAD_SD1_CLK__SD1_CLK IOMUX_PAD(0x7A0, 0x398, 0, 0x0, 0, NO_PAD_CTRL) 340 MX51_SDHCI_PAD_CTRL)
299#define MX51_PAD_SD1_DATA0__SD1_DATA0 IOMUX_PAD(0x7A4, 0x39C, 0, 0x0, 0, NO_PAD_CTRL) 341#define MX51_PAD_SD1_CMD__AUD5_RXFS IOMUX_PAD(0x79C, 0x394, 1, 0x8e0, 1, NO_PAD_CTRL)
300#define MX51_PAD_SD1_DATA1__SD1_DATA1 IOMUX_PAD(0x7A8, 0x3A0, 0, 0x0, 0, NO_PAD_CTRL) 342#define MX51_PAD_SD1_CLK__SD1_CLK IOMUX_PAD(0x7A0, 0x398, IOMUX_CONFIG_SION, 0x0, 0, \
301#define MX51_PAD_SD1_DATA2__SD1_DATA2 IOMUX_PAD(0x7AC, 0x3A4, 0, 0x0, 0, NO_PAD_CTRL) 343 MX51_SDHCI_PAD_CTRL | PAD_CTL_HYS)
302#define MX51_PAD_SD1_DATA3__SD1_DATA3 IOMUX_PAD(0x7B0, 0x3A8, 0, 0x0, 0, NO_PAD_CTRL) 344#define MX51_PAD_SD1_CLK__AUD5_RXC IOMUX_PAD(0x7A0, 0x398, 1, 0x8dc, 1, NO_PAD_CTRL)
303#define MX51_PAD_GPIO_1_0__GPIO_1_0 IOMUX_PAD(0x7B4, 0x3AC, 1, 0x0, 0, NO_PAD_CTRL) 345#define MX51_PAD_SD1_DATA0__SD1_DATA0 IOMUX_PAD(0x7A4, 0x39C, IOMUX_CONFIG_SION, 0x0, 0, \
304#define MX51_PAD_GPIO_1_1__GPIO_1_1 IOMUX_PAD(0x7B8, 0x3B0, 1, 0x0, 0, NO_PAD_CTRL) 346 MX51_SDHCI_PAD_CTRL)
305#define MX51_PAD_SD2_CMD__SD2_CMD IOMUX_PAD(0x7BC, 0x3B4, 0, 0x0, 0, NO_PAD_CTRL) 347#define MX51_PAD_SD1_DATA0__AUD5_TXD IOMUX_PAD(0x7A4, 0x39C, 1, 0x8d8, 2, NO_PAD_CTRL)
306#define MX51_PAD_SD2_CLK__SD2_CLK IOMUX_PAD(0x7C0, 0x3B8, 0, 0x0, 0, NO_PAD_CTRL) 348#define MX51_PAD_SD1_DATA1__SD1_DATA1 IOMUX_PAD(0x7A8, 0x3A0, IOMUX_CONFIG_SION, 0x0, 0, \
307#define MX51_PAD_SD2_DATA0__SD2_DATA0 IOMUX_PAD(0x7C4, 0x3BC, 0, 0x0, 0, NO_PAD_CTRL) 349 MX51_SDHCI_PAD_CTRL)
308#define MX51_PAD_SD2_DATA1__SD2_DATA1 IOMUX_PAD(0x7C8, 0x3C0, 0, 0x0, 0, NO_PAD_CTRL) 350#define MX51_PAD_SD1_DATA1__AUD5_RXD IOMUX_PAD(0x7A8, 0x3A0, 1, 0x8d4, 2, NO_PAD_CTRL)
309#define MX51_PAD_SD2_DATA2__SD2_DATA2 IOMUX_PAD(0x7CC, 0x3C4, 0, 0x0, 0, NO_PAD_CTRL) 351#define MX51_PAD_SD1_DATA2__SD1_DATA2 IOMUX_PAD(0x7AC, 0x3A4, IOMUX_CONFIG_SION, 0x0, 0, \
310#define MX51_PAD_SD2_DATA3__SD2_DATA3 IOMUX_PAD(0x7D0, 0x3C8, 0, 0x0, 0, NO_PAD_CTRL) 352 MX51_SDHCI_PAD_CTRL)
311#define MX51_PAD_GPIO_1_2__GPIO_1_2 IOMUX_PAD(0x7D4, 0x3CC, 0, 0x0, 0, NO_PAD_CTRL) 353#define MX51_PAD_SD1_DATA2__AUD5_TXC IOMUX_PAD(0x7AC, 0x3A4, 1, 0x8e4, 2, NO_PAD_CTRL)
354#define MX51_PAD_SD1_DATA3__SD1_DATA3 IOMUX_PAD(0x7B0, 0x3A8, IOMUX_CONFIG_SION, 0x0, 0, \
355 MX51_SDHCI_PAD_CTRL)
356#define MX51_PAD_SD1_DATA3__AUD5_TXFS IOMUX_PAD(0x7B0, 0x3A8, 1, 0x8e8, 2, NO_PAD_CTRL)
357#define MX51_PAD_SD2_CMD__SD2_CMD IOMUX_PAD(0x7BC, 0x3B4, IOMUX_CONFIG_SION, 0x0, 1, \
358 MX51_SDHCI_PAD_CTRL)
359#define MX51_PAD_SD2_CLK__SD2_CLK IOMUX_PAD(0x7C0, 0x3B8, IOMUX_CONFIG_SION, 0x0, 0, \
360 MX51_SDHCI_PAD_CTRL | PAD_CTL_HYS)
361#define MX51_PAD_SD2_DATA0__SD2_DATA0 IOMUX_PAD(0x7C4, 0x3BC, IOMUX_CONFIG_SION, 0x0, 0, \
362 MX51_SDHCI_PAD_CTRL)
363#define MX51_PAD_SD2_DATA1__SD2_DATA1 IOMUX_PAD(0x7C8, 0x3C0, IOMUX_CONFIG_SION, 0x0, 0, \
364 MX51_SDHCI_PAD_CTRL)
365#define MX51_PAD_SD2_DATA2__SD2_DATA2 IOMUX_PAD(0x7CC, 0x3C4, IOMUX_CONFIG_SION, 0x0, 0, \
366 MX51_SDHCI_PAD_CTRL)
367#define MX51_PAD_SD2_DATA3__SD2_DATA3 IOMUX_PAD(0x7D0, 0x3C8, IOMUX_CONFIG_SION, 0x0, 0, \
368 MX51_SDHCI_PAD_CTRL)
369#define MX51_PAD_GPIO_1_0__GPIO_1_0 IOMUX_PAD(0x7B4, 0x3AC, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
370#define MX51_PAD_GPIO_1_1__GPIO_1_1 IOMUX_PAD(0x7B8, 0x3B0, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
371#define MX51_PAD_GPIO_1_2__GPIO_1_2 IOMUX_PAD(0x7D4, 0x3CC, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
312#define MX51_PAD_GPIO_1_2__I2C2_SCL IOMUX_PAD(0x7D4, 0x3CC, (2 | IOMUX_CONFIG_SION), \ 372#define MX51_PAD_GPIO_1_2__I2C2_SCL IOMUX_PAD(0x7D4, 0x3CC, (2 | IOMUX_CONFIG_SION), \
313 0x9b8, 3, MX51_I2C_PAD_CTRL) 373 0x9b8, 3, MX51_I2C_PAD_CTRL)
314#define MX51_PAD_GPIO_1_3__GPIO_1_3 IOMUX_PAD(0x7D8, 0x3D0, 0, 0x0, 0, NO_PAD_CTRL) 374#define MX51_PAD_GPIO_1_3__GPIO_1_3 IOMUX_PAD(0x7D8, 0x3D0, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
315#define MX51_PAD_GPIO_1_3__I2C2_SDA IOMUX_PAD(0x7D8, 0x3D0, (2 | IOMUX_CONFIG_SION), \ 375#define MX51_PAD_GPIO_1_3__I2C2_SDA IOMUX_PAD(0x7D8, 0x3D0, (2 | IOMUX_CONFIG_SION), \
316 0x9bc, 3, MX51_I2C_PAD_CTRL) 376 0x9bc, 3, MX51_I2C_PAD_CTRL)
317#define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7FC, 0x3D4, 0, 0x0, 0, NO_PAD_CTRL) 377#define MX51_PAD_PMIC_INT_REQ__PMIC_INT_REQ IOMUX_PAD(0x7FC, 0x3D4, 0, 0x0, 0, NO_PAD_CTRL)
318#define MX51_PAD_GPIO_1_4__GPIO_1_4 IOMUX_PAD(0x804, 0x3D8, 0, 0x0, 0, NO_PAD_CTRL) 378#define MX51_PAD_GPIO_1_4__GPIO_1_4 IOMUX_PAD(0x804, 0x3D8, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
319#define MX51_PAD_GPIO_1_5__GPIO_1_5 IOMUX_PAD(0x808, 0x3DC, 0, 0x0, 0, NO_PAD_CTRL) 379#define MX51_PAD_GPIO_1_5__GPIO_1_5 IOMUX_PAD(0x808, 0x3DC, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
320#define MX51_PAD_GPIO_1_6__GPIO_1_6 IOMUX_PAD(0x80C, 0x3E0, 0, 0x0, 0, MX51_GPIO_PAD_CTRL) 380#define MX51_PAD_GPIO_1_6__GPIO_1_6 IOMUX_PAD(0x80C, 0x3E0, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
321#define MX51_PAD_GPIO_1_7__GPIO_1_7 IOMUX_PAD(0x810, 0x3E4, 0, 0x0, 0, MX51_GPIO_PAD_CTRL) 381#define MX51_PAD_GPIO_1_7__GPIO_1_7 IOMUX_PAD(0x810, 0x3E4, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
322#define MX51_PAD_GPIO_1_8__GPIO_1_8 IOMUX_PAD(0x814, 0x3E8, 0, 0x0, 1, MX51_GPIO_PAD_CTRL) 382#define MX51_PAD_GPIO_1_8__GPIO_1_8 IOMUX_PAD(0x814, 0x3E8, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
323#define MX51_PAD_GPIO_1_9__GPIO_1_9 IOMUX_PAD(0x818, 0x3EC, 0, 0x0, 0, NO_PAD_CTRL) 383#define MX51_PAD_GPIO_1_9__GPIO_1_9 IOMUX_PAD(0x818, 0x3EC, 1, 0x0, 0, MX51_GPIO_PAD_CTRL)
324 384
325#endif /* __MACH_IOMUX_MX51_H__ */ 385#endif /* __MACH_IOMUX_MX51_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/iram.h b/arch/arm/plat-mxc/include/mach/iram.h
new file mode 100644
index 000000000000..022690c33702
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/iram.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19#include <linux/errno.h>
20
21#ifdef CONFIG_IRAM_ALLOC
22
23int __init iram_init(unsigned long base, unsigned long size);
24void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr);
25void iram_free(unsigned long dma_addr, unsigned int size);
26
27#else
28
29static inline int __init iram_init(unsigned long base, unsigned long size)
30{
31 return -ENOMEM;
32}
33
34static inline void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
35{
36 return NULL;
37}
38
39static inline void iram_free(unsigned long base, unsigned long size) {}
40
41#endif
diff --git a/arch/arm/plat-mxc/include/mach/mx21.h b/arch/arm/plat-mxc/include/mach/mx21.h
index ed98b9c9f389..8bc59720b6e4 100644
--- a/arch/arm/plat-mxc/include/mach/mx21.h
+++ b/arch/arm/plat-mxc/include/mach/mx21.h
@@ -120,7 +120,7 @@
120#define MX21_INT_GPT1 26 120#define MX21_INT_GPT1 26
121#define MX21_INT_WDOG 27 121#define MX21_INT_WDOG 27
122#define MX21_INT_PCMCIA 28 122#define MX21_INT_PCMCIA 28
123#define MX21_INT_NANDFC 29 123#define MX21_INT_NFC 29
124#define MX21_INT_BMI 30 124#define MX21_INT_BMI 30
125#define MX21_INT_CSI 31 125#define MX21_INT_CSI 31
126#define MX21_INT_DMACH0 32 126#define MX21_INT_DMACH0 32
diff --git a/arch/arm/plat-mxc/include/mach/mx25.h b/arch/arm/plat-mxc/include/mach/mx25.h
index 4a6f800990f8..cf46a45b0d4e 100644
--- a/arch/arm/plat-mxc/include/mach/mx25.h
+++ b/arch/arm/plat-mxc/include/mach/mx25.h
@@ -50,8 +50,11 @@
50#define MX25_SSI1_BASE_ADDR 0x50034000 50#define MX25_SSI1_BASE_ADDR 0x50034000
51#define MX25_NFC_BASE_ADDR 0xbb000000 51#define MX25_NFC_BASE_ADDR 0xbb000000
52#define MX25_DRYICE_BASE_ADDR 0x53ffc000 52#define MX25_DRYICE_BASE_ADDR 0x53ffc000
53#define MX25_ESDHC1_BASE_ADDR 0x53fb4000
54#define MX25_ESDHC2_BASE_ADDR 0x53fb8000
53#define MX25_LCDC_BASE_ADDR 0x53fbc000 55#define MX25_LCDC_BASE_ADDR 0x53fbc000
54#define MX25_KPP_BASE_ADDR 0x43fa8000 56#define MX25_KPP_BASE_ADDR 0x43fa8000
57#define MX25_SDMA_BASE_ADDR 0x53fd4000
55#define MX25_OTG_BASE_ADDR 0x53ff4000 58#define MX25_OTG_BASE_ADDR 0x53ff4000
56#define MX25_CSI_BASE_ADDR 0x53ff8000 59#define MX25_CSI_BASE_ADDR 0x53ff8000
57 60
@@ -59,6 +62,8 @@
59#define MX25_INT_I2C1 3 62#define MX25_INT_I2C1 3
60#define MX25_INT_I2C2 4 63#define MX25_INT_I2C2 4
61#define MX25_INT_UART4 5 64#define MX25_INT_UART4 5
65#define MX25_INT_ESDHC2 8
66#define MX25_INT_ESDHC1 9
62#define MX25_INT_I2C3 10 67#define MX25_INT_I2C3 10
63#define MX25_INT_SSI2 11 68#define MX25_INT_SSI2 11
64#define MX25_INT_SSI1 12 69#define MX25_INT_SSI1 12
@@ -69,7 +74,8 @@
69#define MX25_INT_KPP 24 74#define MX25_INT_KPP 24
70#define MX25_INT_DRYICE 25 75#define MX25_INT_DRYICE 25
71#define MX25_INT_UART2 32 76#define MX25_INT_UART2 32
72#define MX25_INT_NANDFC 33 77#define MX25_INT_NFC 33
78#define MX25_INT_SDMA 34
73#define MX25_INT_LCDC 39 79#define MX25_INT_LCDC 39
74#define MX25_INT_UART5 40 80#define MX25_INT_UART5 40
75#define MX25_INT_CAN1 43 81#define MX25_INT_CAN1 43
@@ -77,4 +83,13 @@
77#define MX25_INT_UART1 45 83#define MX25_INT_UART1 45
78#define MX25_INT_FEC 57 84#define MX25_INT_FEC 57
79 85
86#define MX25_DMA_REQ_SSI2_RX1 22
87#define MX25_DMA_REQ_SSI2_TX1 23
88#define MX25_DMA_REQ_SSI2_RX0 24
89#define MX25_DMA_REQ_SSI2_TX0 25
90#define MX25_DMA_REQ_SSI1_RX1 26
91#define MX25_DMA_REQ_SSI1_TX1 27
92#define MX25_DMA_REQ_SSI1_RX0 28
93#define MX25_DMA_REQ_SSI1_TX0 29
94
80#endif /* ifndef __MACH_MX25_H__ */ 95#endif /* ifndef __MACH_MX25_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx27.h b/arch/arm/plat-mxc/include/mach/mx27.h
index a8ab2e02a8ca..2237ba2e5351 100644
--- a/arch/arm/plat-mxc/include/mach/mx27.h
+++ b/arch/arm/plat-mxc/include/mach/mx27.h
@@ -167,7 +167,7 @@ static inline void mx27_setup_weimcs(size_t cs,
167#define MX27_INT_GPT1 26 167#define MX27_INT_GPT1 26
168#define MX27_INT_WDOG 27 168#define MX27_INT_WDOG 27
169#define MX27_INT_PCMCIA 28 169#define MX27_INT_PCMCIA 28
170#define MX27_INT_NANDFC 29 170#define MX27_INT_NFC 29
171#define MX27_INT_ATA 30 171#define MX27_INT_ATA 30
172#define MX27_INT_CSI 31 172#define MX27_INT_CSI 31
173#define MX27_INT_DMACH0 32 173#define MX27_INT_DMACH0 32
diff --git a/arch/arm/plat-mxc/include/mach/mx31.h b/arch/arm/plat-mxc/include/mach/mx31.h
index afee3ab9d62e..03e2afabc9fc 100644
--- a/arch/arm/plat-mxc/include/mach/mx31.h
+++ b/arch/arm/plat-mxc/include/mach/mx31.h
@@ -168,7 +168,7 @@ static inline void mx31_setup_weimcs(size_t cs,
168#define MX31_INT_POWER_FAIL 30 168#define MX31_INT_POWER_FAIL 30
169#define MX31_INT_CCM_DVFS 31 169#define MX31_INT_CCM_DVFS 31
170#define MX31_INT_UART2 32 170#define MX31_INT_UART2 32
171#define MX31_INT_NANDFC 33 171#define MX31_INT_NFC 33
172#define MX31_INT_SDMA 34 172#define MX31_INT_SDMA 34
173#define MX31_INT_USB1 35 173#define MX31_INT_USB1 35
174#define MX31_INT_USB2 36 174#define MX31_INT_USB2 36
@@ -197,6 +197,15 @@ static inline void mx31_setup_weimcs(size_t cs,
197#define MX31_INT_EXT_WDOG 62 197#define MX31_INT_EXT_WDOG 62
198#define MX31_INT_EXT_TV 63 198#define MX31_INT_EXT_TV 63
199 199
200#define MX31_DMA_REQ_SSI2_RX1 22
201#define MX31_DMA_REQ_SSI2_TX1 23
202#define MX31_DMA_REQ_SSI2_RX0 24
203#define MX31_DMA_REQ_SSI2_TX0 25
204#define MX31_DMA_REQ_SSI1_RX1 26
205#define MX31_DMA_REQ_SSI1_TX1 27
206#define MX31_DMA_REQ_SSI1_RX0 28
207#define MX31_DMA_REQ_SSI1_TX0 29
208
200#define MX31_PROD_SIGNATURE 0x1 /* For MX31 */ 209#define MX31_PROD_SIGNATURE 0x1 /* For MX31 */
201 210
202/* silicon revisions specific to i.MX31 */ 211/* silicon revisions specific to i.MX31 */
diff --git a/arch/arm/plat-mxc/include/mach/mx35.h b/arch/arm/plat-mxc/include/mach/mx35.h
index af3038c12e39..ff905cb32458 100644
--- a/arch/arm/plat-mxc/include/mach/mx35.h
+++ b/arch/arm/plat-mxc/include/mach/mx35.h
@@ -1,5 +1,6 @@
1#ifndef __MACH_MX35_H__ 1#ifndef __MACH_MX35_H__
2#define __MACH_MX35_H__ 2#define __MACH_MX35_H__
3
3/* 4/*
4 * IRAM 5 * IRAM
5 */ 6 */
@@ -52,6 +53,9 @@
52#define MX35_GPIO3_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xa4000) 53#define MX35_GPIO3_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xa4000)
53#define MX35_SCC_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xac000) 54#define MX35_SCC_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xac000)
54#define MX35_RNGA_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xb0000) 55#define MX35_RNGA_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xb0000)
56#define MX35_ESDHC1_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xb4000)
57#define MX35_ESDHC2_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xb8000)
58#define MX35_ESDHC3_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xbc000)
55#define MX35_IPU_CTRL_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xc0000) 59#define MX35_IPU_CTRL_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xc0000)
56#define MX35_AUDMUX_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xc4000) 60#define MX35_AUDMUX_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xc4000)
57#define MX35_GPIO1_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xcc000) 61#define MX35_GPIO1_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xcc000)
@@ -63,6 +67,8 @@
63#define MX35_CAN1_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xe4000) 67#define MX35_CAN1_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xe4000)
64#define MX35_CAN2_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xe8000) 68#define MX35_CAN2_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xe8000)
65#define MX35_RTIC_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xec000) 69#define MX35_RTIC_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xec000)
70#define MX35_IIM_BASE_ADDR (MX35_AIPS2_BASE_ADDR + 0xf0000)
71
66#define MX35_OTG_BASE_ADDR 0x53ff4000 72#define MX35_OTG_BASE_ADDR 0x53ff4000
67 73
68#define MX35_ROMP_BASE_ADDR 0x60000000 74#define MX35_ROMP_BASE_ADDR 0x60000000
@@ -122,9 +128,9 @@
122#define MX35_INT_I2C3 3 128#define MX35_INT_I2C3 3
123#define MX35_INT_I2C2 4 129#define MX35_INT_I2C2 4
124#define MX35_INT_RTIC 6 130#define MX35_INT_RTIC 6
125#define MX35_INT_MMC_SDHC1 7 131#define MX35_INT_ESDHC1 7
126#define MX35_INT_MMC_SDHC2 8 132#define MX35_INT_ESDHC2 8
127#define MX35_INT_MMC_SDHC3 9 133#define MX35_INT_ESDHC3 9
128#define MX35_INT_I2C1 10 134#define MX35_INT_I2C1 10
129#define MX35_INT_SSI1 11 135#define MX35_INT_SSI1 11
130#define MX35_INT_SSI2 12 136#define MX35_INT_SSI2 12
@@ -145,7 +151,7 @@
145#define MX35_INT_GPT 29 151#define MX35_INT_GPT 29
146#define MX35_INT_POWER_FAIL 30 152#define MX35_INT_POWER_FAIL 30
147#define MX35_INT_UART2 32 153#define MX35_INT_UART2 32
148#define MX35_INT_NANDFC 33 154#define MX35_INT_NFC 33
149#define MX35_INT_SDMA 34 155#define MX35_INT_SDMA 34
150#define MX35_INT_USBHS 35 156#define MX35_INT_USBHS 35
151#define MX35_INT_USBOTG 37 157#define MX35_INT_USBOTG 37
@@ -173,22 +179,18 @@
173#define MX35_INT_EXT_WDOG 62 179#define MX35_INT_EXT_WDOG 62
174#define MX35_INT_EXT_TV 63 180#define MX35_INT_EXT_TV 63
175 181
182#define MX35_DMA_REQ_SSI2_RX1 22
183#define MX35_DMA_REQ_SSI2_TX1 23
184#define MX35_DMA_REQ_SSI2_RX0 24
185#define MX35_DMA_REQ_SSI2_TX0 25
186#define MX35_DMA_REQ_SSI1_RX1 26
187#define MX35_DMA_REQ_SSI1_TX1 27
188#define MX35_DMA_REQ_SSI1_RX0 28
189#define MX35_DMA_REQ_SSI1_TX0 29
190
176#define MX35_PROD_SIGNATURE 0x1 /* For MX31 */ 191#define MX35_PROD_SIGNATURE 0x1 /* For MX31 */
177 192
178/* silicon revisions specific to i.MX31 */ 193#define MX35_SYSTEM_REV_MIN MX3x_CHIP_REV_1_0
179#define MX35_CHIP_REV_1_0 0x10
180#define MX35_CHIP_REV_1_1 0x11
181#define MX35_CHIP_REV_1_2 0x12
182#define MX35_CHIP_REV_1_3 0x13
183#define MX35_CHIP_REV_2_0 0x20
184#define MX35_CHIP_REV_2_1 0x21
185#define MX35_CHIP_REV_2_2 0x22
186#define MX35_CHIP_REV_2_3 0x23
187#define MX35_CHIP_REV_3_0 0x30
188#define MX35_CHIP_REV_3_1 0x31
189#define MX35_CHIP_REV_3_2 0x32
190
191#define MX35_SYSTEM_REV_MIN MX35_CHIP_REV_1_0
192#define MX35_SYSTEM_REV_NUM 3 194#define MX35_SYSTEM_REV_NUM 3
193 195
194#ifdef IMX_NEEDS_DEPRECATED_SYMBOLS 196#ifdef IMX_NEEDS_DEPRECATED_SYMBOLS
diff --git a/arch/arm/plat-mxc/include/mach/mx3x.h b/arch/arm/plat-mxc/include/mach/mx3x.h
index 7a356de385f5..d1bd26d7b8a6 100644
--- a/arch/arm/plat-mxc/include/mach/mx3x.h
+++ b/arch/arm/plat-mxc/include/mach/mx3x.h
@@ -240,7 +240,7 @@
240 240
241#define MX3x_PROD_SIGNATURE 0x1 /* For MX31 */ 241#define MX3x_PROD_SIGNATURE 0x1 /* For MX31 */
242 242
243/* silicon revisions specific to i.MX31 */ 243/* silicon revisions specific to i.MX31 and i.MX35 */
244#define MX3x_CHIP_REV_1_0 0x10 244#define MX3x_CHIP_REV_1_0 0x10
245#define MX3x_CHIP_REV_1_1 0x11 245#define MX3x_CHIP_REV_1_1 0x11
246#define MX3x_CHIP_REV_1_2 0x12 246#define MX3x_CHIP_REV_1_2 0x12
@@ -267,6 +267,14 @@ static inline int mx31_revision(void)
267{ 267{
268 return mx31_cpu_rev; 268 return mx31_cpu_rev;
269} 269}
270
271extern unsigned int mx35_cpu_rev;
272extern void mx35_read_cpu_rev(void);
273
274static inline int mx35_revision(void)
275{
276 return mx35_cpu_rev;
277}
270#endif 278#endif
271 279
272#ifdef IMX_NEEDS_DEPRECATED_SYMBOLS 280#ifdef IMX_NEEDS_DEPRECATED_SYMBOLS
@@ -389,19 +397,6 @@ static inline int mx31_revision(void)
389#define MXC_INT_EXT_WDOG MX3x_INT_EXT_WDOG 397#define MXC_INT_EXT_WDOG MX3x_INT_EXT_WDOG
390#define MXC_INT_EXT_TV MX3x_INT_EXT_TV 398#define MXC_INT_EXT_TV MX3x_INT_EXT_TV
391#define PROD_SIGNATURE MX3x_PROD_SIGNATURE 399#define PROD_SIGNATURE MX3x_PROD_SIGNATURE
392#define CHIP_REV_1_0 MX3x_CHIP_REV_1_0
393#define CHIP_REV_1_1 MX3x_CHIP_REV_1_1
394#define CHIP_REV_1_2 MX3x_CHIP_REV_1_2
395#define CHIP_REV_1_3 MX3x_CHIP_REV_1_3
396#define CHIP_REV_2_0 MX3x_CHIP_REV_2_0
397#define CHIP_REV_2_1 MX3x_CHIP_REV_2_1
398#define CHIP_REV_2_2 MX3x_CHIP_REV_2_2
399#define CHIP_REV_2_3 MX3x_CHIP_REV_2_3
400#define CHIP_REV_3_0 MX3x_CHIP_REV_3_0
401#define CHIP_REV_3_1 MX3x_CHIP_REV_3_1
402#define CHIP_REV_3_2 MX3x_CHIP_REV_3_2
403#define SYSTEM_REV_MIN MX3x_SYSTEM_REV_MIN
404#define SYSTEM_REV_NUM MX3x_SYSTEM_REV_NUM
405#endif 400#endif
406 401
407#endif /* ifndef __MACH_MX3x_H__ */ 402#endif /* ifndef __MACH_MX3x_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/mx51.h b/arch/arm/plat-mxc/include/mach/mx51.h
index 5aad344d5651..2af7a1056fc1 100644
--- a/arch/arm/plat-mxc/include/mach/mx51.h
+++ b/arch/arm/plat-mxc/include/mach/mx51.h
@@ -1,5 +1,5 @@
1#ifndef __ASM_ARCH_MXC_MX51_H__ 1#ifndef __MACH_MX51_H__
2#define __ASM_ARCH_MXC_MX51_H__ 2#define __MACH_MX51_H__
3 3
4/* 4/*
5 * MX51 memory map: 5 * MX51 memory map:
@@ -7,24 +7,23 @@
7 * 7 *
8 * Virt Phys Size What 8 * Virt Phys Size What
9 * --------------------------------------------------------------------------- 9 * ---------------------------------------------------------------------------
10 * FA3E0000 1FFE0000 128K IRAM (SCCv2 RAM) 10 * fa3e0000 1ffe0000 128K IRAM (SCCv2 RAM)
11 * 30000000 256M GPU 11 * 30000000 256M GPU
12 * 40000000 512M IPU 12 * 40000000 512M IPU
13 * FA200000 60000000 1M DEBUG 13 * fa200000 60000000 1M DEBUG
14 * FB100000 70000000 1M SPBA 0 14 * fb100000 70000000 1M SPBA 0
15 * FB000000 73F00000 1M AIPS 1 15 * fb000000 73f00000 1M AIPS 1
16 * FB200000 83F00000 1M AIPS 2 16 * fb200000 83f00000 1M AIPS 2
17 * 8FFFC000 16K TZIC (interrupt controller) 17 * 8fffc000 16K TZIC (interrupt controller)
18 * 90000000 256M CSD0 SDRAM/DDR 18 * 90000000 256M CSD0 SDRAM/DDR
19 * A0000000 256M CSD1 SDRAM/DDR 19 * a0000000 256M CSD1 SDRAM/DDR
20 * B0000000 128M CS0 Flash 20 * b0000000 128M CS0 Flash
21 * B8000000 128M CS1 Flash 21 * b8000000 128M CS1 Flash
22 * C0000000 128M CS2 Flash 22 * c0000000 128M CS2 Flash
23 * C8000000 64M CS3 Flash 23 * c8000000 64M CS3 Flash
24 * CC000000 32M CS4 SRAM 24 * cc000000 32M CS4 SRAM
25 * CE000000 32M CS5 SRAM 25 * ce000000 32M CS5 SRAM
26 * CFFF0000 64K NFC (NAND Flash AXI) 26 * cfff0000 64K NFC (NAND Flash AXI)
27 *
28 */ 27 */
29 28
30/* 29/*
@@ -36,65 +35,151 @@
36/* 35/*
37 * IRAM 36 * IRAM
38 */ 37 */
39#define MX51_IRAM_BASE_ADDR 0x1FFE0000 /* internal ram */ 38#define MX51_IRAM_BASE_ADDR 0x1ffe0000 /* internal ram */
40#define MX51_IRAM_BASE_ADDR_VIRT 0xFA3E0000 39#define MX51_IRAM_BASE_ADDR_VIRT 0xfa3e0000
41#define MX51_IRAM_PARTITIONS 16 40#define MX51_IRAM_PARTITIONS 16
42#define MX51_IRAM_PARTITIONS_TO1 12
43#define MX51_IRAM_SIZE (MX51_IRAM_PARTITIONS * SZ_8K) /* 128KB */ 41#define MX51_IRAM_SIZE (MX51_IRAM_PARTITIONS * SZ_8K) /* 128KB */
44 42
43#define MX51_GPU_BASE_ADDR 0x20000000
44#define MX51_GPU_CTRL_BASE_ADDR 0x30000000
45#define MX51_IPU_CTRL_BASE_ADDR 0x40000000
46
47#define MX51_DEBUG_BASE_ADDR 0x60000000
48#define MX51_DEBUG_BASE_ADDR_VIRT 0xfa200000
49#define MX51_DEBUG_SIZE SZ_1M
50
51#define MX51_ETB_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x01000)
52#define MX51_ETM_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x02000)
53#define MX51_TPIU_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x03000)
54#define MX51_CTI0_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x04000)
55#define MX51_CTI1_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x05000)
56#define MX51_CTI2_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x06000)
57#define MX51_CTI3_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x07000)
58#define MX51_CORTEX_DBG_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x08000)
59
45/* 60/*
46 * NFC 61 * SPBA global module enabled #0
47 */ 62 */
48#define MX51_NFC_AXI_BASE_ADDR 0xCFFF0000 /* NAND flash AXI */ 63#define MX51_SPBA0_BASE_ADDR 0x70000000
49#define MX51_NFC_AXI_SIZE SZ_64K 64#define MX51_SPBA0_BASE_ADDR_VIRT 0xfb100000
65#define MX51_SPBA0_SIZE SZ_1M
66
67#define MX51_ESDHC1_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x04000)
68#define MX51_ESDHC2_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x08000)
69#define MX51_UART3_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x0c000)
70#define MX51_ECSPI1_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x10000)
71#define MX51_SSI2_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x14000)
72#define MX51_ESDHC3_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x20000)
73#define MX51_ESDHC4_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x24000)
74#define MX51_SPDIF_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x28000)
75#define MX51_ATA_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x30000)
76#define MX51_SLIM_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x34000)
77#define MX51_HSI2C_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x38000)
78#define MX51_SPBA_CTRL_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x3c000)
50 79
51/* 80/*
52 * Graphics Memory of GPU 81 * AIPS 1
53 */ 82 */
54#define MX51_GPU_BASE_ADDR 0x20000000 83#define MX51_AIPS1_BASE_ADDR 0x73f00000
55#define MX51_GPU2D_BASE_ADDR 0xD0000000 84#define MX51_AIPS1_BASE_ADDR_VIRT 0xfb000000
85#define MX51_AIPS1_SIZE SZ_1M
86
87#define MX51_OTG_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x80000)
88#define MX51_GPIO1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x84000)
89#define MX51_GPIO2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x88000)
90#define MX51_GPIO3_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x8c000)
91#define MX51_GPIO4_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x90000)
92#define MX51_KPP_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x94000)
93#define MX51_WDOG_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x98000)
94#define MX51_WDOG2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x9c000)
95#define MX51_GPT1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xa0000)
96#define MX51_SRTC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xa4000)
97#define MX51_IOMUXC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xa8000)
98#define MX51_EPIT1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xac000)
99#define MX51_EPIT2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xb0000)
100#define MX51_PWM1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xb4000)
101#define MX51_PWM2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xb8000)
102#define MX51_UART1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xbc000)
103#define MX51_UART2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xc0000)
104#define MX51_SRC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xd0000)
105#define MX51_CCM_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xd4000)
106#define MX51_GPC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0xd8000)
56 107
57#define MX51_TZIC_BASE_ADDR_TO1 0x8FFFC000 108/*
58#define MX51_TZIC_BASE_ADDR 0xE0000000 109 * AIPS 2
110 */
111#define MX51_AIPS2_BASE_ADDR 0x83f00000
112#define MX51_AIPS2_BASE_ADDR_VIRT 0xfb200000
113#define MX51_AIPS2_SIZE SZ_1M
59 114
60#define MX51_DEBUG_BASE_ADDR 0x60000000 115#define MX51_PLL1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x80000)
61#define MX51_DEBUG_BASE_ADDR_VIRT 0xFA200000 116#define MX51_PLL2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x84000)
62#define MX51_DEBUG_SIZE SZ_1M 117#define MX51_PLL3_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x88000)
63#define MX51_ETB_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00001000) 118#define MX51_AHBMAX_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x94000)
64#define MX51_ETM_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00002000) 119#define MX51_IIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x98000)
65#define MX51_TPIU_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00003000) 120#define MX51_CSU_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x9c000)
66#define MX51_CTI0_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00004000) 121#define MX51_ARM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xa0000)
67#define MX51_CTI1_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00005000) 122#define MX51_OWIRE_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xa4000)
68#define MX51_CTI2_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00006000) 123#define MX51_FIRI_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xa8000)
69#define MX51_CTI3_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00007000) 124#define MX51_ECSPI2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xac000)
70#define MX51_CORTEX_DBG_BASE_ADDR (MX51_DEBUG_BASE_ADDR + 0x00008000) 125#define MX51_SDMA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xb0000)
126#define MX51_SCC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xb4000)
127#define MX51_ROMCP_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xb8000)
128#define MX51_RTIC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xbc000)
129#define MX51_CSPI_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xc0000)
130#define MX51_I2C2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xc4000)
131#define MX51_I2C1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xc8000)
132#define MX51_SSI1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xcc000)
133#define MX51_AUDMUX_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xd0000)
134#define MX51_M4IF_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xd8000)
135#define MX51_ESDCTL_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xd9000)
136#define MX51_WEIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xda000)
137#define MX51_NFC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xdb000)
138#define MX51_EMI_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xdbf00)
139#define MX51_MIPI_HSC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xdc000)
140#define MX51_ATA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xe0000)
141#define MX51_SIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xe4000)
142#define MX51_SSI3BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xe8000)
143#define MX51_FEC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xec000)
144#define MX51_TVE_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xf0000)
145#define MX51_VPU_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xf4000)
146#define MX51_SAHARA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0xf8000)
147
148#define MX51_CSD0_BASE_ADDR 0x90000000
149#define MX51_CSD1_BASE_ADDR 0xa0000000
150#define MX51_CS0_BASE_ADDR 0xb0000000
151#define MX51_CS1_BASE_ADDR 0xb8000000
152#define MX51_CS2_BASE_ADDR 0xc0000000
153#define MX51_CS3_BASE_ADDR 0xc8000000
154#define MX51_CS4_BASE_ADDR 0xcc000000
155#define MX51_CS5_BASE_ADDR 0xce000000
71 156
72/* 157/*
73 * SPBA global module enabled #0 158 * NFC
74 */ 159 */
75#define MX51_SPBA0_BASE_ADDR 0x70000000 160#define MX51_NFC_AXI_BASE_ADDR 0xcfff0000 /* NAND flash AXI */
76#define MX51_SPBA0_BASE_ADDR_VIRT 0xFB100000 161#define MX51_NFC_AXI_SIZE SZ_64K
77#define MX51_SPBA0_SIZE SZ_1M 162
163#define MX51_GPU2D_BASE_ADDR 0xd0000000
164#define MX51_TZIC_BASE_ADDR 0xe0000000
78 165
79#define MX51_MMC_SDHC1_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00004000) 166#define MX51_IO_ADDRESS(x) ( \
80#define MX51_MMC_SDHC2_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00008000) 167 IMX_IO_ADDRESS(x, MX51_IRAM) ?: \
81#define MX51_UART3_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x0000C000) 168 IMX_IO_ADDRESS(x, MX51_DEBUG) ?: \
82#define MX51_CSPI1_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00010000) 169 IMX_IO_ADDRESS(x, MX51_SPBA0) ?: \
83#define MX51_SSI2_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00014000) 170 IMX_IO_ADDRESS(x, MX51_AIPS1) ?: \
84#define MX51_MMC_SDHC3_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00020000) 171 IMX_IO_ADDRESS(x, MX51_AIPS2))
85#define MX51_MMC_SDHC4_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00024000) 172
86#define MX51_SPDIF_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00028000) 173/* This is currently used in <mach/debug-macro.S>, but should go away */
87#define MX51_ATA_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00030000) 174#define MX51_AIPS1_IO_ADDRESS(x) \
88#define MX51_SLIM_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00034000) 175 (((x) - MX51_AIPS1_BASE_ADDR) + MX51_AIPS1_BASE_ADDR_VIRT)
89#define MX51_HSI2C_DMA_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x00038000)
90#define MX51_SPBA_CTRL_BASE_ADDR (MX51_SPBA0_BASE_ADDR + 0x0003C000)
91 176
92/* 177/*
93 * defines for SPBA modules 178 * defines for SPBA modules
94 */ 179 */
95#define MX51_SPBA_SDHC1 0x04 180#define MX51_SPBA_SDHC1 0x04
96#define MX51_SPBA_SDHC2 0x08 181#define MX51_SPBA_SDHC2 0x08
97#define MX51_SPBA_UART3 0x0C 182#define MX51_SPBA_UART3 0x0c
98#define MX51_SPBA_CSPI1 0x10 183#define MX51_SPBA_CSPI1 0x10
99#define MX51_SPBA_SSI2 0x14 184#define MX51_SPBA_SSI2 0x14
100#define MX51_SPBA_SDHC3 0x20 185#define MX51_SPBA_SDHC3 0x20
@@ -103,35 +188,7 @@
103#define MX51_SPBA_ATA 0x30 188#define MX51_SPBA_ATA 0x30
104#define MX51_SPBA_SLIM 0x34 189#define MX51_SPBA_SLIM 0x34
105#define MX51_SPBA_HSI2C 0x38 190#define MX51_SPBA_HSI2C 0x38
106#define MX51_SPBA_CTRL 0x3C 191#define MX51_SPBA_CTRL 0x3c
107
108/*
109 * AIPS 1
110 */
111#define MX51_AIPS1_BASE_ADDR 0x73F00000
112#define MX51_AIPS1_BASE_ADDR_VIRT 0xFB000000
113#define MX51_AIPS1_SIZE SZ_1M
114
115#define MX51_OTG_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00080000)
116#define MX51_GPIO1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00084000)
117#define MX51_GPIO2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00088000)
118#define MX51_GPIO3_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x0008C000)
119#define MX51_GPIO4_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00090000)
120#define MX51_KPP_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00094000)
121#define MX51_WDOG_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x00098000)
122#define MX51_WDOG2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x0009C000)
123#define MX51_GPT1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000A0000)
124#define MX51_SRTC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000A4000)
125#define MX51_IOMUXC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000A8000)
126#define MX51_EPIT1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000AC000)
127#define MX51_EPIT2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000B0000)
128#define MX51_PWM1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000B4000)
129#define MX51_PWM2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000B8000)
130#define MX51_UART1_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000BC000)
131#define MX51_UART2_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000C0000)
132#define MX51_SRC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000D0000)
133#define MX51_CCM_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000D4000)
134#define MX51_GPC_BASE_ADDR (MX51_AIPS1_BASE_ADDR + 0x000D8000)
135 192
136/* 193/*
137 * Defines for modules using static and dynamic DMA channels 194 * Defines for modules using static and dynamic DMA channels
@@ -164,282 +221,186 @@
164#define MX51_MXC_DMA_CHANNEL_ATA_TX MXC_DMA_DYNAMIC_CHANNEL 221#define MX51_MXC_DMA_CHANNEL_ATA_TX MXC_DMA_DYNAMIC_CHANNEL
165#define MX51_MXC_DMA_CHANNEL_MEMORY MXC_DMA_DYNAMIC_CHANNEL 222#define MX51_MXC_DMA_CHANNEL_MEMORY MXC_DMA_DYNAMIC_CHANNEL
166 223
167/*
168 * AIPS 2
169 */
170#define MX51_AIPS2_BASE_ADDR 0x83F00000
171#define MX51_AIPS2_BASE_ADDR_VIRT 0xFB200000
172#define MX51_AIPS2_SIZE SZ_1M
173
174#define MX51_PLL1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x00080000)
175#define MX51_PLL2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x00084000)
176#define MX51_PLL3_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x00088000)
177#define MX51_AHBMAX_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x00094000)
178#define MX51_IIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x00098000)
179#define MX51_CSU_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x0009C000)
180#define MX51_ARM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000A0000)
181#define MX51_OWIRE_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000A4000)
182#define MX51_FIRI_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000A8000)
183#define MX51_CSPI2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000AC000)
184#define MX51_SDMA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000B0000)
185#define MX51_SCC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000B4000)
186#define MX51_ROMCP_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000B8000)
187#define MX51_RTIC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000BC000)
188#define MX51_CSPI3_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000C0000)
189#define MX51_I2C2_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000C4000)
190#define MX51_I2C1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000C8000)
191#define MX51_SSI1_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000CC000)
192#define MX51_AUDMUX_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000D0000)
193#define MX51_M4IF_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000D8000)
194#define MX51_ESDCTL_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000D9000)
195#define MX51_WEIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000DA000)
196#define MX51_NFC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000DB000)
197#define MX51_EMI_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000DBF00)
198#define MX51_MIPI_HSC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000DC000)
199#define MX51_ATA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000E0000)
200#define MX51_SIM_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000E4000)
201#define MX51_SSI3BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000E8000)
202#define MX51_MXC_FEC_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000EC000)
203#define MX51_TVE_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000F0000)
204#define MX51_VPU_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000F4000)
205#define MX51_SAHARA_BASE_ADDR (MX51_AIPS2_BASE_ADDR + 0x000F8000)
206
207/*
208 * Memory regions and CS
209 */
210#define MX51_GPU_CTRL_BASE_ADDR 0x30000000
211#define MX51_IPU_CTRL_BASE_ADDR 0x40000000
212#define MX51_CSD0_BASE_ADDR 0x90000000
213#define MX51_CSD1_BASE_ADDR 0xA0000000
214#define MX51_CS0_BASE_ADDR 0xB0000000
215#define MX51_CS1_BASE_ADDR 0xB8000000
216#define MX51_CS2_BASE_ADDR 0xC0000000
217#define MX51_CS3_BASE_ADDR 0xC8000000
218#define MX51_CS4_BASE_ADDR 0xCC000000
219#define MX51_CS5_BASE_ADDR 0xCE000000
220
221/* Does given address belongs to the specified memory region? */
222#define ADDRESS_IN_REGION(addr, start, size) \
223 (((addr) >= (start)) && ((addr) < (start)+(size)))
224
225/* Does given address belongs to the specified named `module'? */
226#define MX51_IS_MODULE(addr, module) \
227 ADDRESS_IN_REGION(addr, MX51_ ## module ## _BASE_ADDR, \
228 MX51_ ## module ## _SIZE)
229/*
230 * This macro defines the physical to virtual address mapping for all the
231 * peripheral modules. It is used by passing in the physical address as x
232 * and returning the virtual address. If the physical address is not mapped,
233 * it returns 0xDEADBEEF
234 */
235
236#define MX51_IO_ADDRESS(x) \
237 (void __iomem *) \
238 (MX51_IS_MODULE(x, IRAM) ? MX51_IRAM_IO_ADDRESS(x) : \
239 MX51_IS_MODULE(x, DEBUG) ? MX51_DEBUG_IO_ADDRESS(x) : \
240 MX51_IS_MODULE(x, SPBA0) ? MX51_SPBA0_IO_ADDRESS(x) : \
241 MX51_IS_MODULE(x, AIPS1) ? MX51_AIPS1_IO_ADDRESS(x) : \
242 MX51_IS_MODULE(x, AIPS2) ? MX51_AIPS2_IO_ADDRESS(x) : \
243 0xDEADBEEF)
244
245/*
246 * define the address mapping macros: in physical address order
247 */
248#define MX51_IRAM_IO_ADDRESS(x) \
249 (((x) - MX51_IRAM_BASE_ADDR) + MX51_IRAM_BASE_ADDR_VIRT)
250
251#define MX51_DEBUG_IO_ADDRESS(x) \
252 (((x) - MX51_DEBUG_BASE_ADDR) + MX51_DEBUG_BASE_ADDR_VIRT)
253
254#define MX51_SPBA0_IO_ADDRESS(x) \
255 (((x) - MX51_SPBA0_BASE_ADDR) + MX51_SPBA0_BASE_ADDR_VIRT)
256
257#define MX51_AIPS1_IO_ADDRESS(x) \
258 (((x) - MX51_AIPS1_BASE_ADDR) + MX51_AIPS1_BASE_ADDR_VIRT)
259
260#define MX51_AIPS2_IO_ADDRESS(x) \
261 (((x) - MX51_AIPS2_BASE_ADDR) + MX51_AIPS2_BASE_ADDR_VIRT)
262
263#define MX51_IS_MEM_DEVICE_NONSHARED(x) 0 224#define MX51_IS_MEM_DEVICE_NONSHARED(x) 0
264 225
265/* 226/*
266 * DMA request assignments 227 * DMA request assignments
267 */ 228 */
268#define MX51_DMA_REQ_SSI3_TX1 47 229#define MX51_DMA_REQ_VPU 0
269#define MX51_DMA_REQ_SSI3_RX1 46 230#define MX51_DMA_REQ_GPC 1
270#define MX51_DMA_REQ_SPDIF 45 231#define MX51_DMA_REQ_ATA_RX 2
271#define MX51_DMA_REQ_UART3_TX 44 232#define MX51_DMA_REQ_ATA_TX 3
272#define MX51_DMA_REQ_UART3_RX 43 233#define MX51_DMA_REQ_ATA_TX_END 4
273#define MX51_DMA_REQ_SLIM_B_TX 42 234#define MX51_DMA_REQ_SLIM_B 5
274#define MX51_DMA_REQ_SDHC4 41 235#define MX51_DMA_REQ_CSPI1_RX 6
275#define MX51_DMA_REQ_SDHC3 40 236#define MX51_DMA_REQ_CSPI1_TX 7
276#define MX51_DMA_REQ_CSPI_TX 39 237#define MX51_DMA_REQ_CSPI2_RX 8
277#define MX51_DMA_REQ_CSPI_RX 38 238#define MX51_DMA_REQ_CSPI2_TX 9
278#define MX51_DMA_REQ_SSI3_TX2 37 239#define MX51_DMA_REQ_HS_I2C_TX 10
279#define MX51_DMA_REQ_IPU 36 240#define MX51_DMA_REQ_HS_I2C_RX 11
280#define MX51_DMA_REQ_SSI3_RX2 35 241#define MX51_DMA_REQ_FIRI_RX 12
281#define MX51_DMA_REQ_EPIT2 34 242#define MX51_DMA_REQ_FIRI_TX 13
282#define MX51_DMA_REQ_CTI2_1 33 243#define MX51_DMA_REQ_EXTREQ1 14
283#define MX51_DMA_REQ_EMI_WR 32 244#define MX51_DMA_REQ_GPU 15
284#define MX51_DMA_REQ_CTI2_0 31 245#define MX51_DMA_REQ_UART2_RX 16
285#define MX51_DMA_REQ_EMI_RD 30 246#define MX51_DMA_REQ_UART2_TX 17
286#define MX51_DMA_REQ_SSI1_TX1 29 247#define MX51_DMA_REQ_UART1_RX 18
287#define MX51_DMA_REQ_SSI1_RX1 28 248#define MX51_DMA_REQ_UART1_TX 19
288#define MX51_DMA_REQ_SSI1_TX2 27 249#define MX51_DMA_REQ_SDHC1 20
289#define MX51_DMA_REQ_SSI1_RX2 26 250#define MX51_DMA_REQ_SDHC2 21
290#define MX51_DMA_REQ_SSI2_TX1 25 251#define MX51_DMA_REQ_SSI2_RX1 22
291#define MX51_DMA_REQ_SSI2_RX1 24 252#define MX51_DMA_REQ_SSI2_TX1 23
292#define MX51_DMA_REQ_SSI2_TX2 23 253#define MX51_DMA_REQ_SSI2_RX0 24
293#define MX51_DMA_REQ_SSI2_RX2 22 254#define MX51_DMA_REQ_SSI2_TX0 25
294#define MX51_DMA_REQ_SDHC2 21 255#define MX51_DMA_REQ_SSI1_RX1 26
295#define MX51_DMA_REQ_SDHC1 20 256#define MX51_DMA_REQ_SSI1_TX1 27
296#define MX51_DMA_REQ_UART1_TX 19 257#define MX51_DMA_REQ_SSI1_RX0 28
297#define MX51_DMA_REQ_UART1_RX 18 258#define MX51_DMA_REQ_SSI1_TX0 29
298#define MX51_DMA_REQ_UART2_TX 17 259#define MX51_DMA_REQ_EMI_RD 30
299#define MX51_DMA_REQ_UART2_RX 16 260#define MX51_DMA_REQ_CTI2_0 31
300#define MX51_DMA_REQ_GPU 15 261#define MX51_DMA_REQ_EMI_WR 32
301#define MX51_DMA_REQ_EXTREQ1 14 262#define MX51_DMA_REQ_CTI2_1 33
302#define MX51_DMA_REQ_FIRI_TX 13 263#define MX51_DMA_REQ_EPIT2 34
303#define MX51_DMA_REQ_FIRI_RX 12 264#define MX51_DMA_REQ_SSI3_RX2 35
304#define MX51_DMA_REQ_HS_I2C_RX 11 265#define MX51_DMA_REQ_IPU 36
305#define MX51_DMA_REQ_HS_I2C_TX 10 266#define MX51_DMA_REQ_SSI3_TX2 37
306#define MX51_DMA_REQ_CSPI2_TX 9 267#define MX51_DMA_REQ_CSPI_RX 38
307#define MX51_DMA_REQ_CSPI2_RX 8 268#define MX51_DMA_REQ_CSPI_TX 39
308#define MX51_DMA_REQ_CSPI1_TX 7 269#define MX51_DMA_REQ_SDHC3 40
309#define MX51_DMA_REQ_CSPI1_RX 6 270#define MX51_DMA_REQ_SDHC4 41
310#define MX51_DMA_REQ_SLIM_B 5 271#define MX51_DMA_REQ_SLIM_B_TX 42
311#define MX51_DMA_REQ_ATA_TX_END 4 272#define MX51_DMA_REQ_UART3_RX 43
312#define MX51_DMA_REQ_ATA_TX 3 273#define MX51_DMA_REQ_UART3_TX 44
313#define MX51_DMA_REQ_ATA_RX 2 274#define MX51_DMA_REQ_SPDIF 45
314#define MX51_DMA_REQ_GPC 1 275#define MX51_DMA_REQ_SSI3_RX1 46
315#define MX51_DMA_REQ_VPU 0 276#define MX51_DMA_REQ_SSI3_TX1 47
316 277
317/* 278/*
318 * Interrupt numbers 279 * Interrupt numbers
319 */ 280 */
320#define MX51_MXC_INT_BASE 0 281#define MX51_MXC_INT_BASE 0
321#define MX51_MXC_INT_RESV0 0 282#define MX51_MXC_INT_RESV0 0
322#define MX51_MXC_INT_MMC_SDHC1 1 283#define MX51_INT_ESDHC1 1
323#define MX51_MXC_INT_MMC_SDHC2 2 284#define MX51_INT_ESDHC2 2
324#define MX51_MXC_INT_MMC_SDHC3 3 285#define MX51_INT_ESDHC3 3
325#define MX51_MXC_INT_MMC_SDHC4 4 286#define MX51_INT_ESDHC4 4
326#define MX51_MXC_INT_RESV5 5 287#define MX51_MXC_INT_RESV5 5
327#define MX51_MXC_INT_SDMA 6 288#define MX51_INT_SDMA 6
328#define MX51_MXC_INT_IOMUX 7 289#define MX51_MXC_INT_IOMUX 7
329#define MX51_MXC_INT_NFC 8 290#define MX51_INT_NFC 8
330#define MX51_MXC_INT_VPU 9 291#define MX51_MXC_INT_VPU 9
331#define MX51_MXC_INT_IPU_ERR 10 292#define MX51_MXC_INT_IPU_ERR 10
332#define MX51_MXC_INT_IPU_SYN 11 293#define MX51_MXC_INT_IPU_SYN 11
333#define MX51_MXC_INT_GPU 12 294#define MX51_MXC_INT_GPU 12
334#define MX51_MXC_INT_RESV13 13 295#define MX51_MXC_INT_RESV13 13
335#define MX51_MXC_INT_USB_H1 14 296#define MX51_MXC_INT_USB_H1 14
336#define MX51_MXC_INT_EMI 15 297#define MX51_MXC_INT_EMI 15
337#define MX51_MXC_INT_USB_H2 16 298#define MX51_MXC_INT_USB_H2 16
338#define MX51_MXC_INT_USB_H3 17 299#define MX51_MXC_INT_USB_H3 17
339#define MX51_MXC_INT_USB_OTG 18 300#define MX51_MXC_INT_USB_OTG 18
340#define MX51_MXC_INT_SAHARA_H0 19 301#define MX51_MXC_INT_SAHARA_H0 19
341#define MX51_MXC_INT_SAHARA_H1 20 302#define MX51_MXC_INT_SAHARA_H1 20
342#define MX51_MXC_INT_SCC_SMN 21 303#define MX51_MXC_INT_SCC_SMN 21
343#define MX51_MXC_INT_SCC_STZ 22 304#define MX51_MXC_INT_SCC_STZ 22
344#define MX51_MXC_INT_SCC_SCM 23 305#define MX51_MXC_INT_SCC_SCM 23
345#define MX51_MXC_INT_SRTC_NTZ 24 306#define MX51_MXC_INT_SRTC_NTZ 24
346#define MX51_MXC_INT_SRTC_TZ 25 307#define MX51_MXC_INT_SRTC_TZ 25
347#define MX51_MXC_INT_RTIC 26 308#define MX51_MXC_INT_RTIC 26
348#define MX51_MXC_INT_CSU 27 309#define MX51_MXC_INT_CSU 27
349#define MX51_MXC_INT_SLIM_B 28 310#define MX51_MXC_INT_SLIM_B 28
350#define MX51_MXC_INT_SSI1 29 311#define MX51_INT_SSI1 29
351#define MX51_MXC_INT_SSI2 30 312#define MX51_INT_SSI2 30
352#define MX51_MXC_INT_UART1 31 313#define MX51_INT_UART1 31
353#define MX51_MXC_INT_UART2 32 314#define MX51_INT_UART2 32
354#define MX51_MXC_INT_UART3 33 315#define MX51_INT_UART3 33
355#define MX51_MXC_INT_RESV34 34 316#define MX51_MXC_INT_RESV34 34
356#define MX51_MXC_INT_RESV35 35 317#define MX51_MXC_INT_RESV35 35
357#define MX51_MXC_INT_CSPI1 36 318#define MX51_INT_ECSPI1 36
358#define MX51_MXC_INT_CSPI2 37 319#define MX51_INT_ECSPI2 37
359#define MX51_MXC_INT_CSPI 38 320#define MX51_INT_CSPI 38
360#define MX51_MXC_INT_GPT 39 321#define MX51_MXC_INT_GPT 39
361#define MX51_MXC_INT_EPIT1 40 322#define MX51_MXC_INT_EPIT1 40
362#define MX51_MXC_INT_EPIT2 41 323#define MX51_MXC_INT_EPIT2 41
363#define MX51_MXC_INT_GPIO1_INT7 42 324#define MX51_MXC_INT_GPIO1_INT7 42
364#define MX51_MXC_INT_GPIO1_INT6 43 325#define MX51_MXC_INT_GPIO1_INT6 43
365#define MX51_MXC_INT_GPIO1_INT5 44 326#define MX51_MXC_INT_GPIO1_INT5 44
366#define MX51_MXC_INT_GPIO1_INT4 45 327#define MX51_MXC_INT_GPIO1_INT4 45
367#define MX51_MXC_INT_GPIO1_INT3 46 328#define MX51_MXC_INT_GPIO1_INT3 46
368#define MX51_MXC_INT_GPIO1_INT2 47 329#define MX51_MXC_INT_GPIO1_INT2 47
369#define MX51_MXC_INT_GPIO1_INT1 48 330#define MX51_MXC_INT_GPIO1_INT1 48
370#define MX51_MXC_INT_GPIO1_INT0 49 331#define MX51_MXC_INT_GPIO1_INT0 49
371#define MX51_MXC_INT_GPIO1_LOW 50 332#define MX51_MXC_INT_GPIO1_LOW 50
372#define MX51_MXC_INT_GPIO1_HIGH 51 333#define MX51_MXC_INT_GPIO1_HIGH 51
373#define MX51_MXC_INT_GPIO2_LOW 52 334#define MX51_MXC_INT_GPIO2_LOW 52
374#define MX51_MXC_INT_GPIO2_HIGH 53 335#define MX51_MXC_INT_GPIO2_HIGH 53
375#define MX51_MXC_INT_GPIO3_LOW 54 336#define MX51_MXC_INT_GPIO3_LOW 54
376#define MX51_MXC_INT_GPIO3_HIGH 55 337#define MX51_MXC_INT_GPIO3_HIGH 55
377#define MX51_MXC_INT_GPIO4_LOW 56 338#define MX51_MXC_INT_GPIO4_LOW 56
378#define MX51_MXC_INT_GPIO4_HIGH 57 339#define MX51_MXC_INT_GPIO4_HIGH 57
379#define MX51_MXC_INT_WDOG1 58 340#define MX51_MXC_INT_WDOG1 58
380#define MX51_MXC_INT_WDOG2 59 341#define MX51_MXC_INT_WDOG2 59
381#define MX51_MXC_INT_KPP 60 342#define MX51_MXC_INT_KPP 60
382#define MX51_MXC_INT_PWM1 61 343#define MX51_MXC_INT_PWM1 61
383#define MX51_MXC_INT_I2C1 62 344#define MX51_INT_I2C1 62
384#define MX51_MXC_INT_I2C2 63 345#define MX51_INT_I2C2 63
385#define MX51_MXC_INT_HS_I2C 64 346#define MX51_MXC_INT_HS_I2C 64
386#define MX51_MXC_INT_RESV65 65 347#define MX51_MXC_INT_RESV65 65
387#define MX51_MXC_INT_RESV66 66 348#define MX51_MXC_INT_RESV66 66
388#define MX51_MXC_INT_SIM_IPB 67 349#define MX51_MXC_INT_SIM_IPB 67
389#define MX51_MXC_INT_SIM_DAT 68 350#define MX51_MXC_INT_SIM_DAT 68
390#define MX51_MXC_INT_IIM 69 351#define MX51_MXC_INT_IIM 69
391#define MX51_MXC_INT_ATA 70 352#define MX51_MXC_INT_ATA 70
392#define MX51_MXC_INT_CCM1 71 353#define MX51_MXC_INT_CCM1 71
393#define MX51_MXC_INT_CCM2 72 354#define MX51_MXC_INT_CCM2 72
394#define MX51_MXC_INT_GPC1 73 355#define MX51_MXC_INT_GPC1 73
395#define MX51_MXC_INT_GPC2 74 356#define MX51_MXC_INT_GPC2 74
396#define MX51_MXC_INT_SRC 75 357#define MX51_MXC_INT_SRC 75
397#define MX51_MXC_INT_NM 76 358#define MX51_MXC_INT_NM 76
398#define MX51_MXC_INT_PMU 77 359#define MX51_MXC_INT_PMU 77
399#define MX51_MXC_INT_CTI_IRQ 78 360#define MX51_MXC_INT_CTI_IRQ 78
400#define MX51_MXC_INT_CTI1_TG0 79 361#define MX51_MXC_INT_CTI1_TG0 79
401#define MX51_MXC_INT_CTI1_TG1 80 362#define MX51_MXC_INT_CTI1_TG1 80
402#define MX51_MXC_INT_MCG_ERR 81 363#define MX51_MXC_INT_MCG_ERR 81
403#define MX51_MXC_INT_MCG_TMR 82 364#define MX51_MXC_INT_MCG_TMR 82
404#define MX51_MXC_INT_MCG_FUNC 83 365#define MX51_MXC_INT_MCG_FUNC 83
405#define MX51_MXC_INT_GPU2_IRQ 84 366#define MX51_MXC_INT_GPU2_IRQ 84
406#define MX51_MXC_INT_GPU2_BUSY 85 367#define MX51_MXC_INT_GPU2_BUSY 85
407#define MX51_MXC_INT_RESV86 86 368#define MX51_MXC_INT_RESV86 86
408#define MX51_MXC_INT_FEC 87 369#define MX51_INT_FEC 87
409#define MX51_MXC_INT_OWIRE 88 370#define MX51_MXC_INT_OWIRE 88
410#define MX51_MXC_INT_CTI1_TG2 89 371#define MX51_MXC_INT_CTI1_TG2 89
411#define MX51_MXC_INT_SJC 90 372#define MX51_MXC_INT_SJC 90
412#define MX51_MXC_INT_SPDIF 91 373#define MX51_MXC_INT_SPDIF 91
413#define MX51_MXC_INT_TVE 92 374#define MX51_MXC_INT_TVE 92
414#define MX51_MXC_INT_FIRI 93 375#define MX51_MXC_INT_FIRI 93
415#define MX51_MXC_INT_PWM2 94 376#define MX51_MXC_INT_PWM2 94
416#define MX51_MXC_INT_SLIM_EXP 95 377#define MX51_MXC_INT_SLIM_EXP 95
417#define MX51_MXC_INT_SSI3 96 378#define MX51_MXC_INT_SSI3 96
418#define MX51_MXC_INT_EMI_BOOT 97 379#define MX51_MXC_INT_EMI_BOOT 97
419#define MX51_MXC_INT_CTI1_TG3 98 380#define MX51_MXC_INT_CTI1_TG3 98
420#define MX51_MXC_INT_SMC_RX 99 381#define MX51_MXC_INT_SMC_RX 99
421#define MX51_MXC_INT_VPU_IDLE 100 382#define MX51_MXC_INT_VPU_IDLE 100
422#define MX51_MXC_INT_EMI_NFC 101 383#define MX51_MXC_INT_EMI_NFC 101
423#define MX51_MXC_INT_GPU_IDLE 102 384#define MX51_MXC_INT_GPU_IDLE 102
424 385
425/* silicon revisions specific to i.MX51 */ 386/* silicon revisions specific to i.MX51 */
426#define MX51_CHIP_REV_1_0 0x10 387#define MX51_CHIP_REV_1_0 0x10
427#define MX51_CHIP_REV_1_1 0x11 388#define MX51_CHIP_REV_1_1 0x11
428#define MX51_CHIP_REV_1_2 0x12 389#define MX51_CHIP_REV_1_2 0x12
429#define MX51_CHIP_REV_1_3 0x13 390#define MX51_CHIP_REV_1_3 0x13
430#define MX51_CHIP_REV_2_0 0x20 391#define MX51_CHIP_REV_2_0 0x20
431#define MX51_CHIP_REV_2_1 0x21 392#define MX51_CHIP_REV_2_1 0x21
432#define MX51_CHIP_REV_2_2 0x22 393#define MX51_CHIP_REV_2_2 0x22
433#define MX51_CHIP_REV_2_3 0x23 394#define MX51_CHIP_REV_2_3 0x23
434#define MX51_CHIP_REV_3_0 0x30 395#define MX51_CHIP_REV_3_0 0x30
435#define MX51_CHIP_REV_3_1 0x31 396#define MX51_CHIP_REV_3_1 0x31
436#define MX51_CHIP_REV_3_2 0x32 397#define MX51_CHIP_REV_3_2 0x32
437
438/* Mandatory defines used globally */
439 398
440#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS) 399#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
441
442extern int mx51_revision(void); 400extern int mx51_revision(void);
443#endif 401#endif
444 402
445#endif /* __ASM_ARCH_MXC_MX51_H__ */ 403/* tape-out 1 defines */
404#define MX51_TZIC_BASE_ADDR_TO1 0x8fffc000
405
406#endif /* ifndef __MACH_MX51_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/system.h b/arch/arm/plat-mxc/include/mach/system.h
index 4acd1143a9bd..95be51bfe9a9 100644
--- a/arch/arm/plat-mxc/include/mach/system.h
+++ b/arch/arm/plat-mxc/include/mach/system.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 1999 ARM Limited 2 * Copyright (C) 1999 ARM Limited
3 * Copyright (C) 2000 Deep Blue Solutions Ltd 3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 4 * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -28,8 +28,34 @@ static inline void arch_idle(void)
28 mxc91231_prepare_idle(); 28 mxc91231_prepare_idle();
29 } 29 }
30#endif 30#endif
31 31 /* fix i.MX31 errata TLSbo65953 and i.MX35 errata ENGcm09472 */
32 cpu_do_idle(); 32 if (cpu_is_mx31() || cpu_is_mx35()) {
33 unsigned long reg = 0;
34 __asm__ __volatile__(
35 /* disable I and D cache */
36 "mrc p15, 0, %0, c1, c0, 0\n"
37 "bic %0, %0, #0x00001000\n"
38 "bic %0, %0, #0x00000004\n"
39 "mcr p15, 0, %0, c1, c0, 0\n"
40 /* invalidate I cache */
41 "mov %0, #0\n"
42 "mcr p15, 0, %0, c7, c5, 0\n"
43 /* clear and invalidate D cache */
44 "mov %0, #0\n"
45 "mcr p15, 0, %0, c7, c14, 0\n"
46 /* WFI */
47 "mov %0, #0\n"
48 "mcr p15, 0, %0, c7, c0, 4\n"
49 "nop\n" "nop\n" "nop\n" "nop\n"
50 "nop\n" "nop\n" "nop\n"
51 /* enable I and D cache */
52 "mrc p15, 0, %0, c1, c0, 0\n"
53 "orr %0, %0, #0x00001000\n"
54 "orr %0, %0, #0x00000004\n"
55 "mcr p15, 0, %0, c1, c0, 0\n"
56 : "=r" (reg));
57 } else
58 cpu_do_idle();
33} 59}
34 60
35void arch_reset(char mode, const char *cmd); 61void arch_reset(char mode, const char *cmd);
diff --git a/arch/arm/plat-mxc/include/mach/uncompress.h b/arch/arm/plat-mxc/include/mach/uncompress.h
index d9bd37e4667a..9dd9c2085aad 100644
--- a/arch/arm/plat-mxc/include/mach/uncompress.h
+++ b/arch/arm/plat-mxc/include/mach/uncompress.h
@@ -99,6 +99,7 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)
99 uart_base = MX3X_UART2_BASE_ADDR; 99 uart_base = MX3X_UART2_BASE_ADDR;
100 break; 100 break;
101 case MACH_TYPE_MX51_BABBAGE: 101 case MACH_TYPE_MX51_BABBAGE:
102 case MACH_TYPE_EUKREA_CPUIMX51SD:
102 uart_base = MX51_UART1_BASE_ADDR; 103 uart_base = MX51_UART1_BASE_ADDR;
103 break; 104 break;
104 default: 105 default:
diff --git a/arch/arm/plat-mxc/iram_alloc.c b/arch/arm/plat-mxc/iram_alloc.c
new file mode 100644
index 000000000000..074c3869626a
--- /dev/null
+++ b/arch/arm/plat-mxc/iram_alloc.c
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20#include <linux/kernel.h>
21#include <linux/io.h>
22#include <linux/module.h>
23#include <linux/spinlock.h>
24#include <linux/genalloc.h>
25#include <mach/iram.h>
26
27static unsigned long iram_phys_base;
28static void __iomem *iram_virt_base;
29static struct gen_pool *iram_pool;
30
31static inline void __iomem *iram_phys_to_virt(unsigned long p)
32{
33 return iram_virt_base + (p - iram_phys_base);
34}
35
36void __iomem *iram_alloc(unsigned int size, unsigned long *dma_addr)
37{
38 if (!iram_pool)
39 return NULL;
40
41 *dma_addr = gen_pool_alloc(iram_pool, size);
42 pr_debug("iram alloc - %dB@0x%lX\n", size, *dma_addr);
43 if (!*dma_addr)
44 return NULL;
45 return iram_phys_to_virt(*dma_addr);
46}
47EXPORT_SYMBOL(iram_alloc);
48
49void iram_free(unsigned long addr, unsigned int size)
50{
51 if (!iram_pool)
52 return;
53
54 gen_pool_free(iram_pool, addr, size);
55}
56EXPORT_SYMBOL(iram_free);
57
58int __init iram_init(unsigned long base, unsigned long size)
59{
60 iram_phys_base = base;
61
62 iram_pool = gen_pool_create(PAGE_SHIFT, -1);
63 if (!iram_pool)
64 return -ENOMEM;
65
66 gen_pool_add(iram_pool, base, size, -1);
67 iram_virt_base = ioremap(iram_phys_base, size);
68 if (!iram_virt_base)
69 return -EIO;
70
71 pr_debug("i.MX IRAM pool: %ld KB@0x%p\n", size / 1024, iram_virt_base);
72 return 0;
73}
diff --git a/arch/arm/plat-nomadik/gpio.c b/arch/arm/plat-nomadik/gpio.c
index 977c8f9a07a2..85e6fd212a41 100644
--- a/arch/arm/plat-nomadik/gpio.c
+++ b/arch/arm/plat-nomadik/gpio.c
@@ -102,6 +102,22 @@ static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip,
102 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); 102 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC);
103} 103}
104 104
105static void __nmk_gpio_set_output(struct nmk_gpio_chip *nmk_chip,
106 unsigned offset, int val)
107{
108 if (val)
109 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATS);
110 else
111 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DATC);
112}
113
114static void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip,
115 unsigned offset, int val)
116{
117 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRS);
118 __nmk_gpio_set_output(nmk_chip, offset, val);
119}
120
105static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset, 121static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset,
106 pin_cfg_t cfg) 122 pin_cfg_t cfg)
107{ 123{
@@ -118,20 +134,29 @@ static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset,
118 [3] /* illegal */ = "??" 134 [3] /* illegal */ = "??"
119 }; 135 };
120 static const char *slpmnames[] = { 136 static const char *slpmnames[] = {
121 [NMK_GPIO_SLPM_INPUT] = "input", 137 [NMK_GPIO_SLPM_INPUT] = "input/wakeup",
122 [NMK_GPIO_SLPM_NOCHANGE] = "no-change", 138 [NMK_GPIO_SLPM_NOCHANGE] = "no-change/no-wakeup",
123 }; 139 };
124 140
125 int pin = PIN_NUM(cfg); 141 int pin = PIN_NUM(cfg);
126 int pull = PIN_PULL(cfg); 142 int pull = PIN_PULL(cfg);
127 int af = PIN_ALT(cfg); 143 int af = PIN_ALT(cfg);
128 int slpm = PIN_SLPM(cfg); 144 int slpm = PIN_SLPM(cfg);
145 int output = PIN_DIR(cfg);
146 int val = PIN_VAL(cfg);
129 147
130 dev_dbg(nmk_chip->chip.dev, "pin %d: af %s, pull %s, slpm %s\n", 148 dev_dbg(nmk_chip->chip.dev, "pin %d: af %s, pull %s, slpm %s (%s%s)\n",
131 pin, afnames[af], pullnames[pull], slpmnames[slpm]); 149 pin, afnames[af], pullnames[pull], slpmnames[slpm],
150 output ? "output " : "input",
151 output ? (val ? "high" : "low") : "");
152
153 if (output)
154 __nmk_gpio_make_output(nmk_chip, offset, val);
155 else {
156 __nmk_gpio_make_input(nmk_chip, offset);
157 __nmk_gpio_set_pull(nmk_chip, offset, pull);
158 }
132 159
133 __nmk_gpio_make_input(nmk_chip, offset);
134 __nmk_gpio_set_pull(nmk_chip, offset, pull);
135 __nmk_gpio_set_slpm(nmk_chip, offset, slpm); 160 __nmk_gpio_set_slpm(nmk_chip, offset, slpm);
136 __nmk_gpio_set_mode(nmk_chip, offset, af); 161 __nmk_gpio_set_mode(nmk_chip, offset, af);
137} 162}
@@ -200,6 +225,10 @@ EXPORT_SYMBOL(nmk_config_pins);
200 * changed to an input (with pullup/down enabled) in sleep and deep sleep. If 225 * changed to an input (with pullup/down enabled) in sleep and deep sleep. If
201 * @mode is NMK_GPIO_SLPM_NOCHANGE, the pin remains in the state it was 226 * @mode is NMK_GPIO_SLPM_NOCHANGE, the pin remains in the state it was
202 * configured even when in sleep and deep sleep. 227 * configured even when in sleep and deep sleep.
228 *
229 * On DB8500v2 onwards, this setting loses the previous meaning and instead
230 * indicates if wakeup detection is enabled on the pin. Note that
231 * enable_irq_wake() will automatically enable wakeup detection.
203 */ 232 */
204int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode) 233int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode)
205{ 234{
@@ -367,7 +396,27 @@ static void nmk_gpio_irq_unmask(unsigned int irq)
367 396
368static int nmk_gpio_irq_set_wake(unsigned int irq, unsigned int on) 397static int nmk_gpio_irq_set_wake(unsigned int irq, unsigned int on)
369{ 398{
370 return nmk_gpio_irq_modify(irq, WAKE, on); 399 struct nmk_gpio_chip *nmk_chip;
400 unsigned long flags;
401 int gpio;
402
403 gpio = NOMADIK_IRQ_TO_GPIO(irq);
404 nmk_chip = get_irq_chip_data(irq);
405 if (!nmk_chip)
406 return -EINVAL;
407
408 spin_lock_irqsave(&nmk_chip->lock, flags);
409#ifdef CONFIG_ARCH_U8500
410 if (cpu_is_u8500v2()) {
411 __nmk_gpio_set_slpm(nmk_chip, gpio,
412 on ? NMK_GPIO_SLPM_WAKEUP_ENABLE
413 : NMK_GPIO_SLPM_WAKEUP_DISABLE);
414 }
415#endif
416 __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, on);
417 spin_unlock_irqrestore(&nmk_chip->lock, flags);
418
419 return 0;
371} 420}
372 421
373static int nmk_gpio_irq_set_type(unsigned int irq, unsigned int type) 422static int nmk_gpio_irq_set_type(unsigned int irq, unsigned int type)
@@ -495,12 +544,8 @@ static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset,
495{ 544{
496 struct nmk_gpio_chip *nmk_chip = 545 struct nmk_gpio_chip *nmk_chip =
497 container_of(chip, struct nmk_gpio_chip, chip); 546 container_of(chip, struct nmk_gpio_chip, chip);
498 u32 bit = 1 << offset;
499 547
500 if (val) 548 __nmk_gpio_set_output(nmk_chip, offset, val);
501 writel(bit, nmk_chip->addr + NMK_GPIO_DATS);
502 else
503 writel(bit, nmk_chip->addr + NMK_GPIO_DATC);
504} 549}
505 550
506static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, 551static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset,
@@ -509,8 +554,7 @@ static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset,
509 struct nmk_gpio_chip *nmk_chip = 554 struct nmk_gpio_chip *nmk_chip =
510 container_of(chip, struct nmk_gpio_chip, chip); 555 container_of(chip, struct nmk_gpio_chip, chip);
511 556
512 writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRS); 557 __nmk_gpio_make_output(nmk_chip, offset, val);
513 nmk_gpio_set_output(chip, offset, val);
514 558
515 return 0; 559 return 0;
516} 560}
@@ -534,7 +578,7 @@ static struct gpio_chip nmk_gpio_template = {
534 .can_sleep = 0, 578 .can_sleep = 0,
535}; 579};
536 580
537static int __init nmk_gpio_probe(struct platform_device *dev) 581static int __devinit nmk_gpio_probe(struct platform_device *dev)
538{ 582{
539 struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; 583 struct nmk_gpio_platform_data *pdata = dev->dev.platform_data;
540 struct nmk_gpio_chip *nmk_chip; 584 struct nmk_gpio_chip *nmk_chip;
diff --git a/arch/arm/plat-nomadik/include/plat/gpio.h b/arch/arm/plat-nomadik/include/plat/gpio.h
index aba355101f49..67b113d639d8 100644
--- a/arch/arm/plat-nomadik/include/plat/gpio.h
+++ b/arch/arm/plat-nomadik/include/plat/gpio.h
@@ -65,7 +65,9 @@ enum nmk_gpio_pull {
65/* Sleep mode */ 65/* Sleep mode */
66enum nmk_gpio_slpm { 66enum nmk_gpio_slpm {
67 NMK_GPIO_SLPM_INPUT, 67 NMK_GPIO_SLPM_INPUT,
68 NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT,
68 NMK_GPIO_SLPM_NOCHANGE, 69 NMK_GPIO_SLPM_NOCHANGE,
70 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
69}; 71};
70 72
71extern int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode); 73extern int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode);
diff --git a/arch/arm/plat-nomadik/include/plat/pincfg.h b/arch/arm/plat-nomadik/include/plat/pincfg.h
index 7eed11c1038d..8c5ae3f2acf8 100644
--- a/arch/arm/plat-nomadik/include/plat/pincfg.h
+++ b/arch/arm/plat-nomadik/include/plat/pincfg.h
@@ -19,12 +19,16 @@
19 * bit 9..10 - Alternate Function Selection 19 * bit 9..10 - Alternate Function Selection
20 * bit 11..12 - Pull up/down state 20 * bit 11..12 - Pull up/down state
21 * bit 13 - Sleep mode behaviour 21 * bit 13 - Sleep mode behaviour
22 * bit 14 - (sleep mode) Direction
23 * bit 15 - (sleep mode) Value (if output)
22 * 24 *
23 * to facilitate the definition, the following macros are provided 25 * to facilitate the definition, the following macros are provided
24 * 26 *
25 * PIN_CFG_DEFAULT - default config (0): 27 * PIN_CFG_DEFAULT - default config (0):
26 * pull up/down = disabled 28 * pull up/down = disabled
27 * sleep mode = input 29 * sleep mode = input/wakeup
30 * (sleep mode) direction = input
31 * (sleep mode) value = low
28 * 32 *
29 * PIN_CFG - default config with alternate function 33 * PIN_CFG - default config with alternate function
30 * PIN_CFG_PULL - default config with alternate function and pull up/down 34 * PIN_CFG_PULL - default config with alternate function and pull up/down
@@ -53,8 +57,36 @@ typedef unsigned long pin_cfg_t;
53#define PIN_SLPM_SHIFT 13 57#define PIN_SLPM_SHIFT 13
54#define PIN_SLPM_MASK (0x1 << PIN_SLPM_SHIFT) 58#define PIN_SLPM_MASK (0x1 << PIN_SLPM_SHIFT)
55#define PIN_SLPM(x) (((x) & PIN_SLPM_MASK) >> PIN_SLPM_SHIFT) 59#define PIN_SLPM(x) (((x) & PIN_SLPM_MASK) >> PIN_SLPM_SHIFT)
56#define PIN_SLPM_INPUT (NMK_GPIO_SLPM_INPUT << PIN_SLPM_SHIFT) 60#define PIN_SLPM_MAKE_INPUT (NMK_GPIO_SLPM_INPUT << PIN_SLPM_SHIFT)
57#define PIN_SLPM_NOCHANGE (NMK_GPIO_SLPM_NOCHANGE << PIN_SLPM_SHIFT) 61#define PIN_SLPM_NOCHANGE (NMK_GPIO_SLPM_NOCHANGE << PIN_SLPM_SHIFT)
62/* These two replace the above in DB8500v2+ */
63#define PIN_SLPM_WAKEUP_ENABLE (NMK_GPIO_SLPM_WAKEUP_ENABLE << PIN_SLPM_SHIFT)
64#define PIN_SLPM_WAKEUP_DISABLE (NMK_GPIO_SLPM_WAKEUP_DISABLE << PIN_SLPM_SHIFT)
65
66#define PIN_DIR_SHIFT 14
67#define PIN_DIR_MASK (0x1 << PIN_DIR_SHIFT)
68#define PIN_DIR(x) (((x) & PIN_DIR_MASK) >> PIN_DIR_SHIFT)
69#define PIN_DIR_INPUT (0 << PIN_DIR_SHIFT)
70#define PIN_DIR_OUTPUT (1 << PIN_DIR_SHIFT)
71
72#define PIN_VAL_SHIFT 15
73#define PIN_VAL_MASK (0x1 << PIN_VAL_SHIFT)
74#define PIN_VAL(x) (((x) & PIN_VAL_MASK) >> PIN_VAL_SHIFT)
75#define PIN_VAL_LOW (0 << PIN_VAL_SHIFT)
76#define PIN_VAL_HIGH (1 << PIN_VAL_SHIFT)
77
78/* Shortcuts. Use these instead of separate DIR and VAL. */
79#define PIN_INPUT PIN_DIR_INPUT
80#define PIN_OUTPUT_LOW (PIN_DIR_OUTPUT | PIN_VAL_LOW)
81#define PIN_OUTPUT_HIGH (PIN_DIR_OUTPUT | PIN_VAL_HIGH)
82
83/*
84 * These are the same as the ones above, but should make more sense to the
85 * reader when seen along with a setting a pin to AF mode.
86 */
87#define PIN_SLPM_INPUT PIN_INPUT
88#define PIN_SLPM_OUTPUT_LOW PIN_OUTPUT_LOW
89#define PIN_SLPM_OUTPUT_HIGH PIN_OUTPUT_HIGH
58 90
59#define PIN_CFG_DEFAULT (PIN_PULL_NONE | PIN_SLPM_INPUT) 91#define PIN_CFG_DEFAULT (PIN_PULL_NONE | PIN_SLPM_INPUT)
60 92
diff --git a/arch/arm/plat-nomadik/include/plat/ske.h b/arch/arm/plat-nomadik/include/plat/ske.h
new file mode 100644
index 000000000000..31382fbc07dc
--- /dev/null
+++ b/arch/arm/plat-nomadik/include/plat/ske.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 * Author: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
6 *
7 * ux500 Scroll key and Keypad Encoder (SKE) header
8 */
9
10#ifndef __SKE_H
11#define __SKE_H
12
13#include <linux/input/matrix_keypad.h>
14
15/* register definitions for SKE peripheral */
16#define SKE_CR 0x00
17#define SKE_VAL0 0x04
18#define SKE_VAL1 0x08
19#define SKE_DBCR 0x0C
20#define SKE_IMSC 0x10
21#define SKE_RIS 0x14
22#define SKE_MIS 0x18
23#define SKE_ICR 0x1C
24
25/*
26 * Keypad module
27 */
28
29/**
30 * struct keypad_platform_data - structure for platform specific data
31 * @init: pointer to keypad init function
32 * @exit: pointer to keypad deinitialisation function
33 * @keymap_data: matrix scan code table for keycodes
34 * @krow: maximum number of rows
35 * @kcol: maximum number of columns
36 * @debounce_ms: platform specific debounce time
37 * @no_autorepeat: flag for auto repetition
38 * @wakeup_enable: allow waking up the system
39 */
40struct ske_keypad_platform_data {
41 int (*init)(void);
42 int (*exit)(void);
43 const struct matrix_keymap_data *keymap_data;
44 u8 krow;
45 u8 kcol;
46 u8 debounce_ms;
47 bool no_autorepeat;
48 bool wakeup_enable;
49};
50#endif /*__SKE_KPD_H*/
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e39a417a368d..a92cb499313f 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -33,7 +33,7 @@ config OMAP_DEBUG_DEVICES
33config OMAP_DEBUG_LEDS 33config OMAP_DEBUG_LEDS
34 bool 34 bool
35 depends on OMAP_DEBUG_DEVICES 35 depends on OMAP_DEBUG_DEVICES
36 default y if LEDS 36 default y if LEDS_CLASS
37 37
38config OMAP_RESET_CLOCKS 38config OMAP_RESET_CLOCKS
39 bool "Reset unused clocks during boot" 39 bool "Reset unused clocks during boot"
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 0054b9501a53..71934817e172 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -173,11 +173,7 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,
173 173
174static int valid_sdram(unsigned long addr, unsigned long size) 174static int valid_sdram(unsigned long addr, unsigned long size)
175{ 175{
176 struct memblock_property res; 176 return memblock_is_region_memory(addr, size);
177
178 res.base = addr;
179 res.size = size;
180 return !memblock_find(&res) && res.base == addr && res.size == size;
181} 177}
182 178
183static int reserve_sdram(unsigned long addr, unsigned long size) 179static int reserve_sdram(unsigned long addr, unsigned long size)
diff --git a/arch/arm/plat-omap/include/plat/omap4-keypad.h b/arch/arm/plat-omap/include/plat/omap4-keypad.h
new file mode 100644
index 000000000000..2b1d9bc1eebb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/omap4-keypad.h
@@ -0,0 +1,14 @@
1#ifndef ARCH_ARM_PLAT_OMAP4_KEYPAD_H
2#define ARCH_ARM_PLAT_OMAP4_KEYPAD_H
3
4#include <linux/input/matrix_keypad.h>
5
6struct omap4_keypad_platform_data {
7 const struct matrix_keymap_data *keymap_data;
8
9 u8 rows;
10 u8 cols;
11};
12
13extern int omap4_keyboard_init(struct omap4_keypad_platform_data *);
14#endif
diff --git a/arch/arm/plat-omap/include/plat/smp.h b/arch/arm/plat-omap/include/plat/smp.h
index 5177a9c5a25a..ecd6a488c497 100644
--- a/arch/arm/plat-omap/include/plat/smp.h
+++ b/arch/arm/plat-omap/include/plat/smp.h
@@ -18,6 +18,7 @@
18#define OMAP_ARCH_SMP_H 18#define OMAP_ARCH_SMP_H
19 19
20#include <asm/hardware/gic.h> 20#include <asm/hardware/gic.h>
21#include <asm/smp_mpidr.h>
21 22
22/* Needed for secondary core boot */ 23/* Needed for secondary core boot */
23extern void omap_secondary_startup(void); 24extern void omap_secondary_startup(void);
@@ -33,15 +34,4 @@ static inline void smp_cross_call(const struct cpumask *mask)
33 gic_raise_softirq(mask, 1); 34 gic_raise_softirq(mask, 1);
34} 35}
35 36
36/*
37 * Read MPIDR: Multiprocessor affinity register
38 */
39#define hard_smp_processor_id() \
40 ({ \
41 unsigned int cpunum; \
42 __asm__("mrc p15, 0, %0, c0, c0, 5" \
43 : "=r" (cpunum)); \
44 cpunum &= 0x0F; \
45 })
46
47#endif 37#endif
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 2a9427c8cc48..9feddacfe850 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -218,6 +218,27 @@ static inline omap2_usbfs_init(struct omap_usb_config *pdata)
218# define USBT2TLL5PI (1 << 17) 218# define USBT2TLL5PI (1 << 17)
219# define USB0PUENACTLOI (1 << 16) 219# define USB0PUENACTLOI (1 << 16)
220# define USBSTANDBYCTRL (1 << 15) 220# define USBSTANDBYCTRL (1 << 15)
221/* AM35x */
222/* USB 2.0 PHY Control */
223#define CONF2_PHY_GPIOMODE (1 << 23)
224#define CONF2_OTGMODE (3 << 14)
225#define CONF2_NO_OVERRIDE (0 << 14)
226#define CONF2_FORCE_HOST (1 << 14)
227#define CONF2_FORCE_DEVICE (2 << 14)
228#define CONF2_FORCE_HOST_VBUS_LOW (3 << 14)
229#define CONF2_SESENDEN (1 << 13)
230#define CONF2_VBDTCTEN (1 << 12)
231#define CONF2_REFFREQ_24MHZ (2 << 8)
232#define CONF2_REFFREQ_26MHZ (7 << 8)
233#define CONF2_REFFREQ_13MHZ (6 << 8)
234#define CONF2_REFFREQ (0xf << 8)
235#define CONF2_PHYCLKGD (1 << 7)
236#define CONF2_VBUSSENSE (1 << 6)
237#define CONF2_PHY_PLLON (1 << 5)
238#define CONF2_RESET (1 << 4)
239#define CONF2_PHYPWRDN (1 << 3)
240#define CONF2_OTGPWRDN (1 << 2)
241#define CONF2_DATPOL (1 << 1)
221 242
222#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB) 243#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB)
223u32 omap1_usb0_init(unsigned nwires, unsigned is_device); 244u32 omap1_usb0_init(unsigned nwires, unsigned is_device);
diff --git a/arch/arm/plat-omap/iommu-debug.c b/arch/arm/plat-omap/iommu-debug.c
index e6c0d536899c..f07cf2f08e09 100644
--- a/arch/arm/plat-omap/iommu-debug.c
+++ b/arch/arm/plat-omap/iommu-debug.c
@@ -328,12 +328,14 @@ static int debug_open_generic(struct inode *inode, struct file *file)
328 .open = debug_open_generic, \ 328 .open = debug_open_generic, \
329 .read = debug_read_##name, \ 329 .read = debug_read_##name, \
330 .write = debug_write_##name, \ 330 .write = debug_write_##name, \
331 .llseek = generic_file_llseek, \
331 }; 332 };
332 333
333#define DEBUG_FOPS_RO(name) \ 334#define DEBUG_FOPS_RO(name) \
334 static const struct file_operations debug_##name##_fops = { \ 335 static const struct file_operations debug_##name##_fops = { \
335 .open = debug_open_generic, \ 336 .open = debug_open_generic, \
336 .read = debug_read_##name, \ 337 .read = debug_read_##name, \
338 .llseek = generic_file_llseek, \
337 }; 339 };
338 340
339DEBUG_FOPS_RO(ver); 341DEBUG_FOPS_RO(ver);
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index a202a2ce6e3d..6cd151b31bc5 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -320,6 +320,7 @@ void flush_iotlb_page(struct iommu *obj, u32 da)
320 if ((start <= da) && (da < start + bytes)) { 320 if ((start <= da) && (da < start + bytes)) {
321 dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n", 321 dev_dbg(obj->dev, "%s: %08x<=%08x(%x)\n",
322 __func__, start, da, bytes); 322 __func__, start, da, bytes);
323 iotlb_load_cr(obj, &cr);
323 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY); 324 iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY);
324 } 325 }
325 } 326 }
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index e31496e35b0f..0c8612fd8312 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -156,7 +156,7 @@ static irqreturn_t omap_mcbsp_rx_irq_handler(int irq, void *dev_id)
156 /* Writing zero to RSYNC_ERR clears the IRQ */ 156 /* Writing zero to RSYNC_ERR clears the IRQ */
157 MCBSP_WRITE(mcbsp_rx, SPCR1, MCBSP_READ_CACHE(mcbsp_rx, SPCR1)); 157 MCBSP_WRITE(mcbsp_rx, SPCR1, MCBSP_READ_CACHE(mcbsp_rx, SPCR1));
158 } else { 158 } else {
159 complete(&mcbsp_rx->tx_irq_completion); 159 complete(&mcbsp_rx->rx_irq_completion);
160 } 160 }
161 161
162 return IRQ_HANDLED; 162 return IRQ_HANDLED;
diff --git a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h b/arch/arm/plat-pxa/include/plat/pxa27x_keypad.h
index 7b4eadc6df3a..abcc36eb1242 100644
--- a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
+++ b/arch/arm/plat-pxa/include/plat/pxa27x_keypad.h
@@ -25,6 +25,13 @@
25 * 25 *
26 * 4. matrix key and direct key will use the same debounce_interval by 26 * 4. matrix key and direct key will use the same debounce_interval by
27 * default, which should be sufficient in most cases 27 * default, which should be sufficient in most cases
28 *
29 * pxa168 keypad platform specific parameter
30 *
31 * NOTE:
32 * clear_wakeup_event callback is a workaround required to clear the
33 * keypad interrupt. The keypad wake must be cleared in addition to
34 * reading the MI/DI bits in the KPC register.
28 */ 35 */
29struct pxa27x_keypad_platform_data { 36struct pxa27x_keypad_platform_data {
30 37
@@ -52,6 +59,9 @@ struct pxa27x_keypad_platform_data {
52 59
53 /* key debounce interval */ 60 /* key debounce interval */
54 unsigned int debounce_interval; 61 unsigned int debounce_interval;
62
63 /* clear wakeup event requirement for pxa168 */
64 void (*clear_wakeup_event)(void);
55}; 65};
56 66
57extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info); 67extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
diff --git a/arch/arm/plat-s5p/Kconfig b/arch/arm/plat-s5p/Kconfig
index c6a855db2fb6..25960966af7c 100644
--- a/arch/arm/plat-s5p/Kconfig
+++ b/arch/arm/plat-s5p/Kconfig
@@ -7,7 +7,7 @@
7 7
8config PLAT_S5P 8config PLAT_S5P
9 bool 9 bool
10 depends on (ARCH_S5P6440 || ARCH_S5P6442 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_S5PV310) 10 depends on (ARCH_S5P64X0 || ARCH_S5P6442 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_S5PV310)
11 default y 11 default y
12 select ARM_VIC if !ARCH_S5PV310 12 select ARM_VIC if !ARCH_S5PV310
13 select ARM_GIC if ARCH_S5PV310 13 select ARM_GIC if ARCH_S5PV310
@@ -30,7 +30,7 @@ config S5P_EXT_INT
30 bool 30 bool
31 help 31 help
32 Use the external interrupts (other than GPIO interrupts.) 32 Use the external interrupts (other than GPIO interrupts.)
33 Note: Do not choose this for S5P6440. 33 Note: Do not choose this for S5P6440 and S5P6450.
34 34
35config S5P_DEV_FIMC0 35config S5P_DEV_FIMC0
36 bool 36 bool
@@ -46,3 +46,8 @@ config S5P_DEV_FIMC2
46 bool 46 bool
47 help 47 help
48 Compile in platform device definitions for FIMC controller 2 48 Compile in platform device definitions for FIMC controller 2
49
50config S5P_DEV_ONENAND
51 bool
52 help
53 Compile in platform device definition for OneNAND controller
diff --git a/arch/arm/plat-s5p/Makefile b/arch/arm/plat-s5p/Makefile
index b2e029673950..f3e917e27da8 100644
--- a/arch/arm/plat-s5p/Makefile
+++ b/arch/arm/plat-s5p/Makefile
@@ -24,3 +24,4 @@ obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o
24obj-$(CONFIG_S5P_DEV_FIMC0) += dev-fimc0.o 24obj-$(CONFIG_S5P_DEV_FIMC0) += dev-fimc0.o
25obj-$(CONFIG_S5P_DEV_FIMC1) += dev-fimc1.o 25obj-$(CONFIG_S5P_DEV_FIMC1) += dev-fimc1.o
26obj-$(CONFIG_S5P_DEV_FIMC2) += dev-fimc2.o 26obj-$(CONFIG_S5P_DEV_FIMC2) += dev-fimc2.o
27obj-$(CONFIG_S5P_DEV_ONENAND) += dev-onenand.o
diff --git a/arch/arm/plat-s5p/clock.c b/arch/arm/plat-s5p/clock.c
index b5e255265f20..8aaf4e6b60c3 100644
--- a/arch/arm/plat-s5p/clock.c
+++ b/arch/arm/plat-s5p/clock.c
@@ -74,6 +74,13 @@ struct clk clk_fout_epll = {
74 .ctrlbit = (1 << 31), 74 .ctrlbit = (1 << 31),
75}; 75};
76 76
77/* DPLL clock output */
78struct clk clk_fout_dpll = {
79 .name = "fout_dpll",
80 .id = -1,
81 .ctrlbit = (1 << 31),
82};
83
77/* VPLL clock output */ 84/* VPLL clock output */
78struct clk clk_fout_vpll = { 85struct clk clk_fout_vpll = {
79 .name = "fout_vpll", 86 .name = "fout_vpll",
@@ -122,6 +129,17 @@ struct clksrc_sources clk_src_epll = {
122 .nr_sources = ARRAY_SIZE(clk_src_epll_list), 129 .nr_sources = ARRAY_SIZE(clk_src_epll_list),
123}; 130};
124 131
132/* Possible clock sources for DPLL Mux */
133static struct clk *clk_src_dpll_list[] = {
134 [0] = &clk_fin_dpll,
135 [1] = &clk_fout_dpll,
136};
137
138struct clksrc_sources clk_src_dpll = {
139 .sources = clk_src_dpll_list,
140 .nr_sources = ARRAY_SIZE(clk_src_dpll_list),
141};
142
125struct clk clk_vpll = { 143struct clk clk_vpll = {
126 .name = "vpll", 144 .name = "vpll",
127 .id = -1, 145 .id = -1,
@@ -145,6 +163,7 @@ static struct clk *s5p_clks[] __initdata = {
145 &clk_fout_apll, 163 &clk_fout_apll,
146 &clk_fout_mpll, 164 &clk_fout_mpll,
147 &clk_fout_epll, 165 &clk_fout_epll,
166 &clk_fout_dpll,
148 &clk_fout_vpll, 167 &clk_fout_vpll,
149 &clk_arm, 168 &clk_arm,
150 &clk_vpll, 169 &clk_vpll,
diff --git a/arch/arm/plat-s5p/cpu.c b/arch/arm/plat-s5p/cpu.c
index b07a078fd284..74f7f5a5446c 100644
--- a/arch/arm/plat-s5p/cpu.c
+++ b/arch/arm/plat-s5p/cpu.c
@@ -19,6 +19,7 @@
19#include <plat/cpu.h> 19#include <plat/cpu.h>
20#include <plat/s5p6440.h> 20#include <plat/s5p6440.h>
21#include <plat/s5p6442.h> 21#include <plat/s5p6442.h>
22#include <plat/s5p6450.h>
22#include <plat/s5pc100.h> 23#include <plat/s5pc100.h>
23#include <plat/s5pv210.h> 24#include <plat/s5pv210.h>
24#include <plat/s5pv310.h> 25#include <plat/s5pv310.h>
@@ -27,6 +28,7 @@
27 28
28static const char name_s5p6440[] = "S5P6440"; 29static const char name_s5p6440[] = "S5P6440";
29static const char name_s5p6442[] = "S5P6442"; 30static const char name_s5p6442[] = "S5P6442";
31static const char name_s5p6450[] = "S5P6450";
30static const char name_s5pc100[] = "S5PC100"; 32static const char name_s5pc100[] = "S5PC100";
31static const char name_s5pv210[] = "S5PV210/S5PC110"; 33static const char name_s5pv210[] = "S5PV210/S5PC110";
32static const char name_s5pv310[] = "S5PV310"; 34static const char name_s5pv310[] = "S5PV310";
@@ -38,7 +40,7 @@ static struct cpu_table cpu_ids[] __initdata = {
38 .map_io = s5p6440_map_io, 40 .map_io = s5p6440_map_io,
39 .init_clocks = s5p6440_init_clocks, 41 .init_clocks = s5p6440_init_clocks,
40 .init_uarts = s5p6440_init_uarts, 42 .init_uarts = s5p6440_init_uarts,
41 .init = s5p6440_init, 43 .init = s5p64x0_init,
42 .name = name_s5p6440, 44 .name = name_s5p6440,
43 }, { 45 }, {
44 .idcode = 0x36442000, 46 .idcode = 0x36442000,
@@ -49,6 +51,14 @@ static struct cpu_table cpu_ids[] __initdata = {
49 .init = s5p6442_init, 51 .init = s5p6442_init,
50 .name = name_s5p6442, 52 .name = name_s5p6442,
51 }, { 53 }, {
54 .idcode = 0x36450000,
55 .idmask = 0xffffff00,
56 .map_io = s5p6450_map_io,
57 .init_clocks = s5p6450_init_clocks,
58 .init_uarts = s5p6450_init_uarts,
59 .init = s5p64x0_init,
60 .name = name_s5p6450,
61 }, {
52 .idcode = 0x43100000, 62 .idcode = 0x43100000,
53 .idmask = 0xfffff000, 63 .idmask = 0xfffff000,
54 .map_io = s5pc100_map_io, 64 .map_io = s5pc100_map_io,
@@ -89,33 +99,11 @@ static struct map_desc s5p_iodesc[] __initdata = {
89 .length = SZ_64K, 99 .length = SZ_64K,
90 .type = MT_DEVICE, 100 .type = MT_DEVICE,
91 }, { 101 }, {
92 .virtual = (unsigned long)S3C_VA_UART,
93 .pfn = __phys_to_pfn(S3C_PA_UART),
94 .length = SZ_512K,
95 .type = MT_DEVICE,
96#ifdef CONFIG_ARM_VIC
97 }, {
98 .virtual = (unsigned long)VA_VIC0,
99 .pfn = __phys_to_pfn(S5P_PA_VIC0),
100 .length = SZ_16K,
101 .type = MT_DEVICE,
102 }, {
103 .virtual = (unsigned long)VA_VIC1,
104 .pfn = __phys_to_pfn(S5P_PA_VIC1),
105 .length = SZ_16K,
106 .type = MT_DEVICE,
107#endif
108 }, {
109 .virtual = (unsigned long)S3C_VA_TIMER, 102 .virtual = (unsigned long)S3C_VA_TIMER,
110 .pfn = __phys_to_pfn(S5P_PA_TIMER), 103 .pfn = __phys_to_pfn(S5P_PA_TIMER),
111 .length = SZ_16K, 104 .length = SZ_16K,
112 .type = MT_DEVICE, 105 .type = MT_DEVICE,
113 }, { 106 }, {
114 .virtual = (unsigned long)S5P_VA_GPIO,
115 .pfn = __phys_to_pfn(S5P_PA_GPIO),
116 .length = SZ_4K,
117 .type = MT_DEVICE,
118 }, {
119 .virtual = (unsigned long)S3C_VA_WATCHDOG, 107 .virtual = (unsigned long)S3C_VA_WATCHDOG,
120 .pfn = __phys_to_pfn(S3C_PA_WDT), 108 .pfn = __phys_to_pfn(S3C_PA_WDT),
121 .length = SZ_4K, 109 .length = SZ_4K,
diff --git a/arch/arm/mach-s5pv210/dev-onenand.c b/arch/arm/plat-s5p/dev-onenand.c
index f8ede33ee82b..6db926202caa 100644
--- a/arch/arm/mach-s5pv210/dev-onenand.c
+++ b/arch/arm/plat-s5p/dev-onenand.c
@@ -1,10 +1,12 @@
1/* 1/* linux/arch/arm/plat-s5p/dev-onenand.c
2 * linux/arch/arm/mach-s5pv210/dev-onenand.c 2 *
3 * Copyright 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
3 * 5 *
4 * Copyright (c) 2008-2010 Samsung Electronics 6 * Copyright (c) 2008-2010 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com> 7 * Kyungmin Park <kyungmin.park@samsung.com>
6 * 8 *
7 * S5PC110 series device definition for OneNAND devices 9 * S5P series device definition for OneNAND devices
8 * 10 *
9 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -19,15 +21,15 @@
19#include <mach/irqs.h> 21#include <mach/irqs.h>
20#include <mach/map.h> 22#include <mach/map.h>
21 23
22static struct resource s5pc110_onenand_resources[] = { 24static struct resource s5p_onenand_resources[] = {
23 [0] = { 25 [0] = {
24 .start = S5PC110_PA_ONENAND, 26 .start = S5P_PA_ONENAND,
25 .end = S5PC110_PA_ONENAND + SZ_128K - 1, 27 .end = S5P_PA_ONENAND + SZ_128K - 1,
26 .flags = IORESOURCE_MEM, 28 .flags = IORESOURCE_MEM,
27 }, 29 },
28 [1] = { 30 [1] = {
29 .start = S5PC110_PA_ONENAND_DMA, 31 .start = S5P_PA_ONENAND_DMA,
30 .end = S5PC110_PA_ONENAND_DMA + SZ_8K - 1, 32 .end = S5P_PA_ONENAND_DMA + SZ_8K - 1,
31 .flags = IORESOURCE_MEM, 33 .flags = IORESOURCE_MEM,
32 }, 34 },
33 [2] = { 35 [2] = {
@@ -37,19 +39,19 @@ static struct resource s5pc110_onenand_resources[] = {
37 }, 39 },
38}; 40};
39 41
40struct platform_device s5pc110_device_onenand = { 42struct platform_device s5p_device_onenand = {
41 .name = "s5pc110-onenand", 43 .name = "s5pc110-onenand",
42 .id = -1, 44 .id = -1,
43 .num_resources = ARRAY_SIZE(s5pc110_onenand_resources), 45 .num_resources = ARRAY_SIZE(s5p_onenand_resources),
44 .resource = s5pc110_onenand_resources, 46 .resource = s5p_onenand_resources,
45}; 47};
46 48
47void s5pc110_onenand_set_platdata(struct onenand_platform_data *pdata) 49void s5p_onenand_set_platdata(struct onenand_platform_data *pdata)
48{ 50{
49 struct onenand_platform_data *pd; 51 struct onenand_platform_data *pd;
50 52
51 pd = kmemdup(pdata, sizeof(struct onenand_platform_data), GFP_KERNEL); 53 pd = kmemdup(pdata, sizeof(struct onenand_platform_data), GFP_KERNEL);
52 if (!pd) 54 if (!pd)
53 printk(KERN_ERR "%s: no memory for platform data\n", __func__); 55 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
54 s5pc110_device_onenand.dev.platform_data = pd; 56 s5p_device_onenand.dev.platform_data = pd;
55} 57}
diff --git a/arch/arm/plat-s5p/dev-uart.c b/arch/arm/plat-s5p/dev-uart.c
index a89331ef4ae1..6a7342886171 100644
--- a/arch/arm/plat-s5p/dev-uart.c
+++ b/arch/arm/plat-s5p/dev-uart.c
@@ -119,6 +119,56 @@ static struct resource s5p_uart3_resource[] = {
119#endif 119#endif
120}; 120};
121 121
122static struct resource s5p_uart4_resource[] = {
123#if CONFIG_SERIAL_SAMSUNG_UARTS > 4
124 [0] = {
125 .start = S5P_PA_UART4,
126 .end = S5P_PA_UART4 + S5P_SZ_UART,
127 .flags = IORESOURCE_MEM,
128 },
129 [1] = {
130 .start = IRQ_S5P_UART_RX4,
131 .end = IRQ_S5P_UART_RX4,
132 .flags = IORESOURCE_IRQ,
133 },
134 [2] = {
135 .start = IRQ_S5P_UART_TX4,
136 .end = IRQ_S5P_UART_TX4,
137 .flags = IORESOURCE_IRQ,
138 },
139 [3] = {
140 .start = IRQ_S5P_UART_ERR4,
141 .end = IRQ_S5P_UART_ERR4,
142 .flags = IORESOURCE_IRQ,
143 },
144#endif
145};
146
147static struct resource s5p_uart5_resource[] = {
148#if CONFIG_SERIAL_SAMSUNG_UARTS > 5
149 [0] = {
150 .start = S5P_PA_UART5,
151 .end = S5P_PA_UART5 + S5P_SZ_UART,
152 .flags = IORESOURCE_MEM,
153 },
154 [1] = {
155 .start = IRQ_S5P_UART_RX5,
156 .end = IRQ_S5P_UART_RX5,
157 .flags = IORESOURCE_IRQ,
158 },
159 [2] = {
160 .start = IRQ_S5P_UART_TX5,
161 .end = IRQ_S5P_UART_TX5,
162 .flags = IORESOURCE_IRQ,
163 },
164 [3] = {
165 .start = IRQ_S5P_UART_ERR5,
166 .end = IRQ_S5P_UART_ERR5,
167 .flags = IORESOURCE_IRQ,
168 },
169#endif
170};
171
122struct s3c24xx_uart_resources s5p_uart_resources[] __initdata = { 172struct s3c24xx_uart_resources s5p_uart_resources[] __initdata = {
123 [0] = { 173 [0] = {
124 .resources = s5p_uart0_resource, 174 .resources = s5p_uart0_resource,
@@ -136,4 +186,12 @@ struct s3c24xx_uart_resources s5p_uart_resources[] __initdata = {
136 .resources = s5p_uart3_resource, 186 .resources = s5p_uart3_resource,
137 .nr_resources = ARRAY_SIZE(s5p_uart3_resource), 187 .nr_resources = ARRAY_SIZE(s5p_uart3_resource),
138 }, 188 },
189 [4] = {
190 .resources = s5p_uart4_resource,
191 .nr_resources = ARRAY_SIZE(s5p_uart4_resource),
192 },
193 [5] = {
194 .resources = s5p_uart5_resource,
195 .nr_resources = ARRAY_SIZE(s5p_uart5_resource),
196 },
139}; 197};
diff --git a/arch/arm/plat-s5p/include/plat/pll.h b/arch/arm/plat-s5p/include/plat/pll.h
index 4e8fe08cb70d..bf28fadee7ae 100644
--- a/arch/arm/plat-s5p/include/plat/pll.h
+++ b/arch/arm/plat-s5p/include/plat/pll.h
@@ -47,6 +47,7 @@ static inline unsigned long s5p_get_pll45xx(unsigned long baseclk, u32 pll_con,
47} 47}
48 48
49#define PLL46XX_KDIV_MASK (0xFFFF) 49#define PLL46XX_KDIV_MASK (0xFFFF)
50#define PLL4650C_KDIV_MASK (0xFFF)
50#define PLL46XX_MDIV_MASK (0x1FF) 51#define PLL46XX_MDIV_MASK (0x1FF)
51#define PLL46XX_PDIV_MASK (0x3F) 52#define PLL46XX_PDIV_MASK (0x3F)
52#define PLL46XX_SDIV_MASK (0x7) 53#define PLL46XX_SDIV_MASK (0x7)
@@ -57,6 +58,7 @@ static inline unsigned long s5p_get_pll45xx(unsigned long baseclk, u32 pll_con,
57enum pll46xx_type_t { 58enum pll46xx_type_t {
58 pll_4600, 59 pll_4600,
59 pll_4650, 60 pll_4650,
61 pll_4650c,
60}; 62};
61 63
62static inline unsigned long s5p_get_pll46xx(unsigned long baseclk, 64static inline unsigned long s5p_get_pll46xx(unsigned long baseclk,
@@ -72,6 +74,11 @@ static inline unsigned long s5p_get_pll46xx(unsigned long baseclk,
72 sdiv = (pll_con0 >> PLL46XX_SDIV_SHIFT) & PLL46XX_SDIV_MASK; 74 sdiv = (pll_con0 >> PLL46XX_SDIV_SHIFT) & PLL46XX_SDIV_MASK;
73 kdiv = pll_con1 & PLL46XX_KDIV_MASK; 75 kdiv = pll_con1 & PLL46XX_KDIV_MASK;
74 76
77 if (pll_type == pll_4650c)
78 kdiv = pll_con1 & PLL4650C_KDIV_MASK;
79 else
80 kdiv = pll_con1 & PLL46XX_KDIV_MASK;
81
75 tmp = baseclk; 82 tmp = baseclk;
76 83
77 if (pll_type == pll_4600) { 84 if (pll_type == pll_4600) {
diff --git a/arch/arm/plat-s5p/include/plat/s5p-clock.h b/arch/arm/plat-s5p/include/plat/s5p-clock.h
index 09418b1101fe..17036c898409 100644
--- a/arch/arm/plat-s5p/include/plat/s5p-clock.h
+++ b/arch/arm/plat-s5p/include/plat/s5p-clock.h
@@ -1,7 +1,7 @@
1/* linux/arch/arm/plat-s5p/include/plat/s5p-clock.h 1/* linux/arch/arm/plat-s5p/include/plat/s5p-clock.h
2 * 2 *
3 * Copyright 2009 Samsung Electronics Co., Ltd. 3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/ 4 * http://www.samsung.com
5 * 5 *
6 * Header file for s5p clock support 6 * Header file for s5p clock support
7 * 7 *
@@ -20,6 +20,7 @@
20#define clk_fin_apll clk_ext_xtal_mux 20#define clk_fin_apll clk_ext_xtal_mux
21#define clk_fin_mpll clk_ext_xtal_mux 21#define clk_fin_mpll clk_ext_xtal_mux
22#define clk_fin_epll clk_ext_xtal_mux 22#define clk_fin_epll clk_ext_xtal_mux
23#define clk_fin_dpll clk_ext_xtal_mux
23#define clk_fin_vpll clk_ext_xtal_mux 24#define clk_fin_vpll clk_ext_xtal_mux
24#define clk_fin_hpll clk_ext_xtal_mux 25#define clk_fin_hpll clk_ext_xtal_mux
25 26
@@ -30,6 +31,7 @@ extern struct clk s5p_clk_27m;
30extern struct clk clk_fout_apll; 31extern struct clk clk_fout_apll;
31extern struct clk clk_fout_mpll; 32extern struct clk clk_fout_mpll;
32extern struct clk clk_fout_epll; 33extern struct clk clk_fout_epll;
34extern struct clk clk_fout_dpll;
33extern struct clk clk_fout_vpll; 35extern struct clk clk_fout_vpll;
34extern struct clk clk_arm; 36extern struct clk clk_arm;
35extern struct clk clk_vpll; 37extern struct clk clk_vpll;
@@ -37,8 +39,8 @@ extern struct clk clk_vpll;
37extern struct clksrc_sources clk_src_apll; 39extern struct clksrc_sources clk_src_apll;
38extern struct clksrc_sources clk_src_mpll; 40extern struct clksrc_sources clk_src_mpll;
39extern struct clksrc_sources clk_src_epll; 41extern struct clksrc_sources clk_src_epll;
42extern struct clksrc_sources clk_src_dpll;
40 43
41extern int s5p6440_clk48m_ctrl(struct clk *clk, int enable);
42extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable); 44extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable);
43 45
44#endif /* __ASM_PLAT_S5P_CLOCK_H */ 46#endif /* __ASM_PLAT_S5P_CLOCK_H */
diff --git a/arch/arm/plat-s5p/include/plat/s5p6440.h b/arch/arm/plat-s5p/include/plat/s5p6440.h
index a4cd75afeb3b..528585d2cafc 100644
--- a/arch/arm/plat-s5p/include/plat/s5p6440.h
+++ b/arch/arm/plat-s5p/include/plat/s5p6440.h
@@ -12,24 +12,23 @@
12 12
13 /* Common init code for S5P6440 related SoCs */ 13 /* Common init code for S5P6440 related SoCs */
14 14
15extern void s5p6440_common_init_uarts(struct s3c2410_uartcfg *cfg, int no);
16extern void s5p6440_register_clocks(void); 15extern void s5p6440_register_clocks(void);
17extern void s5p6440_setup_clocks(void); 16extern void s5p6440_setup_clocks(void);
18 17
19#ifdef CONFIG_CPU_S5P6440 18#ifdef CONFIG_CPU_S5P6440
20 19
21extern int s5p6440_init(void); 20extern int s5p64x0_init(void);
22extern void s5p6440_init_irq(void); 21extern void s5p6440_init_irq(void);
23extern void s5p6440_map_io(void); 22extern void s5p6440_map_io(void);
24extern void s5p6440_init_clocks(int xtal); 23extern void s5p6440_init_clocks(int xtal);
25 24
26#define s5p6440_init_uarts s5p6440_common_init_uarts 25extern void s5p6440_init_uarts(struct s3c2410_uartcfg *cfg, int no);
27 26
28#else 27#else
29#define s5p6440_init_clocks NULL 28#define s5p6440_init_clocks NULL
30#define s5p6440_init_uarts NULL 29#define s5p6440_init_uarts NULL
31#define s5p6440_map_io NULL 30#define s5p6440_map_io NULL
32#define s5p6440_init NULL 31#define s5p64x0_init NULL
33#endif 32#endif
34 33
35/* S5P6440 timer */ 34/* S5P6440 timer */
diff --git a/arch/arm/plat-s5p/include/plat/s5p6450.h b/arch/arm/plat-s5p/include/plat/s5p6450.h
new file mode 100644
index 000000000000..640a41c26be3
--- /dev/null
+++ b/arch/arm/plat-s5p/include/plat/s5p6450.h
@@ -0,0 +1,36 @@
1/* arch/arm/plat-s5p/include/plat/s5p6450.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Header file for s5p6450 cpu support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13/* Common init code for S5P6450 related SoCs */
14
15extern void s5p6450_register_clocks(void);
16extern void s5p6450_setup_clocks(void);
17
18#ifdef CONFIG_CPU_S5P6450
19
20extern int s5p64x0_init(void);
21extern void s5p6450_init_irq(void);
22extern void s5p6450_map_io(void);
23extern void s5p6450_init_clocks(int xtal);
24
25extern void s5p6450_init_uarts(struct s3c2410_uartcfg *cfg, int no);
26
27#else
28#define s5p6450_init_clocks NULL
29#define s5p6450_init_uarts NULL
30#define s5p6450_map_io NULL
31#define s5p64x0_init NULL
32#endif
33
34/* S5P6450 timer */
35
36extern struct sys_timer s5p6450_timer;
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c
index 04d9521ddc9f..e8f2be2d67f2 100644
--- a/arch/arm/plat-samsung/adc.c
+++ b/arch/arm/plat-samsung/adc.c
@@ -435,7 +435,6 @@ static int s3c_adc_suspend(struct platform_device *pdev, pm_message_t state)
435static int s3c_adc_resume(struct platform_device *pdev) 435static int s3c_adc_resume(struct platform_device *pdev)
436{ 436{
437 struct adc_device *adc = platform_get_drvdata(pdev); 437 struct adc_device *adc = platform_get_drvdata(pdev);
438 unsigned long flags;
439 438
440 clk_enable(adc->clk); 439 clk_enable(adc->clk);
441 enable_irq(adc->irq); 440 enable_irq(adc->irq);
diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
index 90a20512d68d..e8d20b0bc50e 100644
--- a/arch/arm/plat-samsung/clock.c
+++ b/arch/arm/plat-samsung/clock.c
@@ -48,6 +48,9 @@
48#include <plat/clock.h> 48#include <plat/clock.h>
49#include <plat/cpu.h> 49#include <plat/cpu.h>
50 50
51#include <linux/serial_core.h>
52#include <plat/regs-serial.h> /* for s3c24xx_uart_devs */
53
51/* clock information */ 54/* clock information */
52 55
53static LIST_HEAD(clocks); 56static LIST_HEAD(clocks);
@@ -65,6 +68,28 @@ static int clk_null_enable(struct clk *clk, int enable)
65 return 0; 68 return 0;
66} 69}
67 70
71static int dev_is_s3c_uart(struct device *dev)
72{
73 struct platform_device **pdev = s3c24xx_uart_devs;
74 int i;
75 for (i = 0; i < ARRAY_SIZE(s3c24xx_uart_devs); i++, pdev++)
76 if (*pdev && dev == &(*pdev)->dev)
77 return 1;
78 return 0;
79}
80
81/*
82 * Serial drivers call get_clock() very early, before platform bus
83 * has been set up, this requires a special check to let them get
84 * a proper clock
85 */
86
87static int dev_is_platform_device(struct device *dev)
88{
89 return dev->bus == &platform_bus_type ||
90 (dev->bus == NULL && dev_is_s3c_uart(dev));
91}
92
68/* Clock API calls */ 93/* Clock API calls */
69 94
70struct clk *clk_get(struct device *dev, const char *id) 95struct clk *clk_get(struct device *dev, const char *id)
@@ -73,7 +98,7 @@ struct clk *clk_get(struct device *dev, const char *id)
73 struct clk *clk = ERR_PTR(-ENOENT); 98 struct clk *clk = ERR_PTR(-ENOENT);
74 int idno; 99 int idno;
75 100
76 if (dev == NULL || dev->bus != &platform_bus_type) 101 if (dev == NULL || !dev_is_platform_device(dev))
77 idno = -1; 102 idno = -1;
78 else 103 else
79 idno = to_platform_device(dev)->id; 104 idno = to_platform_device(dev)->id;
diff --git a/arch/arm/plat-samsung/include/plat/adc.h b/arch/arm/plat-samsung/include/plat/adc.h
index e8382c7be10b..b258a08de591 100644
--- a/arch/arm/plat-samsung/include/plat/adc.h
+++ b/arch/arm/plat-samsung/include/plat/adc.h
@@ -1,7 +1,7 @@
1/* arch/arm/plat-samsung/include/plat/adc.h 1/* arch/arm/plat-samsung/include/plat/adc.h
2 * 2 *
3 * Copyright (c) 2008 Simtec Electronics 3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simnte.co.uk/ 4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk> 5 * Ben Dooks <ben@simtec.co.uk>
6 * 6 *
7 * S3C ADC driver information 7 * S3C ADC driver information
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 6412933d6fbb..9addb3dfb4bc 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -79,7 +79,7 @@ extern struct sysdev_class s3c2442_sysclass;
79extern struct sysdev_class s3c2443_sysclass; 79extern struct sysdev_class s3c2443_sysclass;
80extern struct sysdev_class s3c6410_sysclass; 80extern struct sysdev_class s3c6410_sysclass;
81extern struct sysdev_class s3c64xx_sysclass; 81extern struct sysdev_class s3c64xx_sysclass;
82extern struct sysdev_class s5p6440_sysclass; 82extern struct sysdev_class s5p64x0_sysclass;
83extern struct sysdev_class s5p6442_sysclass; 83extern struct sysdev_class s5p6442_sysclass;
84extern struct sysdev_class s5pv210_sysclass; 84extern struct sysdev_class s5pv210_sysclass;
85 85
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 85f6f23a510f..7d448e138792 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -67,13 +67,15 @@ extern struct platform_device s5pv210_device_spi0;
67extern struct platform_device s5pv210_device_spi1; 67extern struct platform_device s5pv210_device_spi1;
68extern struct platform_device s5p6440_device_spi0; 68extern struct platform_device s5p6440_device_spi0;
69extern struct platform_device s5p6440_device_spi1; 69extern struct platform_device s5p6440_device_spi1;
70extern struct platform_device s5p6450_device_spi0;
71extern struct platform_device s5p6450_device_spi1;
70 72
71extern struct platform_device s3c_device_hwmon; 73extern struct platform_device s3c_device_hwmon;
72 74
73extern struct platform_device s3c_device_nand; 75extern struct platform_device s3c_device_nand;
74extern struct platform_device s3c_device_onenand; 76extern struct platform_device s3c_device_onenand;
75extern struct platform_device s3c64xx_device_onenand1; 77extern struct platform_device s3c64xx_device_onenand1;
76extern struct platform_device s5pc110_device_onenand; 78extern struct platform_device s5p_device_onenand;
77 79
78extern struct platform_device s3c_device_usbgadget; 80extern struct platform_device s3c_device_usbgadget;
79extern struct platform_device s3c_device_usb_hsotg; 81extern struct platform_device s3c_device_usb_hsotg;
@@ -95,6 +97,9 @@ extern struct platform_device s5p6442_device_spi;
95extern struct platform_device s5p6440_device_pcm; 97extern struct platform_device s5p6440_device_pcm;
96extern struct platform_device s5p6440_device_iis; 98extern struct platform_device s5p6440_device_iis;
97 99
100extern struct platform_device s5p6450_device_iis0;
101extern struct platform_device s5p6450_device_pcm0;
102
98extern struct platform_device s5pc100_device_ac97; 103extern struct platform_device s5pc100_device_ac97;
99extern struct platform_device s5pc100_device_pcm0; 104extern struct platform_device s5pc100_device_pcm0;
100extern struct platform_device s5pc100_device_pcm1; 105extern struct platform_device s5pc100_device_pcm1;
diff --git a/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h b/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h
index 5fe6721b57f7..810744213120 100644
--- a/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h
+++ b/arch/arm/plat-samsung/include/plat/s3c-dma-pl330.h
@@ -32,6 +32,12 @@ enum dma_ch {
32 DMACH_UART2_TX, 32 DMACH_UART2_TX,
33 DMACH_UART3_RX, 33 DMACH_UART3_RX,
34 DMACH_UART3_TX, 34 DMACH_UART3_TX,
35 DMACH_UART4_RX,
36 DMACH_UART4_TX,
37 DMACH_UART5_RX,
38 DMACH_UART5_TX,
39 DMACH_USI_RX,
40 DMACH_USI_TX,
35 DMACH_IRDA, 41 DMACH_IRDA,
36 DMACH_I2S0_RX, 42 DMACH_I2S0_RX,
37 DMACH_I2S0_TX, 43 DMACH_I2S0_TX,
@@ -64,6 +70,20 @@ enum dma_ch {
64 DMACH_MSM_REQ2, 70 DMACH_MSM_REQ2,
65 DMACH_MSM_REQ1, 71 DMACH_MSM_REQ1,
66 DMACH_MSM_REQ0, 72 DMACH_MSM_REQ0,
73 DMACH_SLIMBUS0_RX,
74 DMACH_SLIMBUS0_TX,
75 DMACH_SLIMBUS0AUX_RX,
76 DMACH_SLIMBUS0AUX_TX,
77 DMACH_SLIMBUS1_RX,
78 DMACH_SLIMBUS1_TX,
79 DMACH_SLIMBUS2_RX,
80 DMACH_SLIMBUS2_TX,
81 DMACH_SLIMBUS3_RX,
82 DMACH_SLIMBUS3_TX,
83 DMACH_SLIMBUS4_RX,
84 DMACH_SLIMBUS4_TX,
85 DMACH_SLIMBUS5_RX,
86 DMACH_SLIMBUS5_TX,
67 /* END Marker, also used to denote a reserved channel */ 87 /* END Marker, also used to denote a reserved channel */
68 DMACH_MAX, 88 DMACH_MAX,
69}; 89};
diff --git a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
index e5aba8f95b79..ff1a561b326e 100644
--- a/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
+++ b/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h
@@ -32,6 +32,8 @@ struct s3c64xx_spi_csinfo {
32 * struct s3c64xx_spi_info - SPI Controller defining structure 32 * struct s3c64xx_spi_info - SPI Controller defining structure
33 * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field. 33 * @src_clk_nr: Clock source index for the CLK_CFG[SPI_CLKSEL] field.
34 * @src_clk_name: Platform name of the corresponding clock. 34 * @src_clk_name: Platform name of the corresponding clock.
35 * @clk_from_cmu: If the SPI clock/prescalar control block is present
36 * by the platform's clock-management-unit and not in SPI controller.
35 * @num_cs: Number of CS this controller emulates. 37 * @num_cs: Number of CS this controller emulates.
36 * @cfg_gpio: Configure pins for this SPI controller. 38 * @cfg_gpio: Configure pins for this SPI controller.
37 * @fifo_lvl_mask: All tx fifo_lvl fields start at offset-6 39 * @fifo_lvl_mask: All tx fifo_lvl fields start at offset-6
@@ -41,6 +43,7 @@ struct s3c64xx_spi_csinfo {
41struct s3c64xx_spi_info { 43struct s3c64xx_spi_info {
42 int src_clk_nr; 44 int src_clk_nr;
43 char *src_clk_name; 45 char *src_clk_name;
46 bool clk_from_cmu;
44 47
45 int num_cs; 48 int num_cs;
46 49
@@ -65,7 +68,7 @@ struct s3c64xx_spi_info {
65extern void s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); 68extern void s3c64xx_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
66extern void s5pc100_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); 69extern void s5pc100_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
67extern void s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); 70extern void s5pv210_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
68extern void s5p6440_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); 71extern void s5p64x0_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
69extern void s5p6442_spi_set_info(int cntrlr, int src_clk_nr, int num_cs); 72extern void s5p6442_spi_set_info(int cntrlr, int src_clk_nr, int num_cs);
70 73
71#endif /* __S3C64XX_PLAT_SPI_H */ 74#endif /* __S3C64XX_PLAT_SPI_H */
diff --git a/arch/arm/plat-spear/include/plat/debug-macro.S b/arch/arm/plat-spear/include/plat/debug-macro.S
index 37fa593884ee..e91270e4f640 100644
--- a/arch/arm/plat-spear/include/plat/debug-macro.S
+++ b/arch/arm/plat-spear/include/plat/debug-macro.S
@@ -14,11 +14,9 @@
14#include <linux/amba/serial.h> 14#include <linux/amba/serial.h>
15#include <mach/spear.h> 15#include <mach/spear.h>
16 16
17 .macro addruart, rx 17 .macro addruart, rp, rv
18 mrc p15, 0, \rx, c1, c0 18 mov \rp, #SPEAR_DBG_UART_BASE @ Physical base
19 tst \rx, #1 @ MMU enabled? 19 mov \rv, #VA_SPEAR_DBG_UART_BASE @ Virtual base
20 moveq \rx, #SPEAR_DBG_UART_BASE @ Physical base
21 movne \rx, #VA_SPEAR_DBG_UART_BASE @ Virtual base
22 .endm 20 .endm
23 21
24 .macro senduart, rd, rx 22 .macro senduart, rd, rx
diff --git a/arch/arm/plat-stmp3xxx/include/mach/debug-macro.S b/arch/arm/plat-stmp3xxx/include/mach/debug-macro.S
index 1b9348bf0e49..d3a0985c9681 100644
--- a/arch/arm/plat-stmp3xxx/include/mach/debug-macro.S
+++ b/arch/arm/plat-stmp3xxx/include/mach/debug-macro.S
@@ -16,13 +16,10 @@
16 * http://www.gnu.org/copyleft/gpl.html 16 * http://www.gnu.org/copyleft/gpl.html
17 */ 17 */
18 18
19 .macro addruart, rx, tmp 19 .macro addruart, rp, rv
20 mrc p15, 0, \rx, c1, c0 20 mov \rp, #0x00070000
21 tst \rx, #1 @ MMU enabled? 21 add \rv, \rp, #0xf0000000 @ virtual base
22 moveq \rx, #0x80000000 @ physical base address 22 add \rp, \rp, #0x80000000 @ physical base
23 addeq \rx, \rx, #0x00070000
24 movne \rx, #0xf0000000 @ virtual base
25 addne \rx, \rx, #0x00070000
26 .endm 23 .endm
27 24
28 .macro senduart,rd,rx 25 .macro senduart,rd,rx
diff --git a/arch/arm/plat-tcc/Kconfig b/arch/arm/plat-tcc/Kconfig
new file mode 100644
index 000000000000..1bf499570f42
--- /dev/null
+++ b/arch/arm/plat-tcc/Kconfig
@@ -0,0 +1,20 @@
1if ARCH_TCC_926
2
3menu "Telechips ARM926-based CPUs"
4
5choice
6 prompt "Telechips CPU type:"
7 default ARCH_TCC8K
8
9config ARCH_TCC8K
10 bool TCC8000
11 select USB_ARCH_HAS_OHCI
12 help
13 Support for Telechips TCC8000 systems
14
15endchoice
16
17source "arch/arm/mach-tcc8k/Kconfig"
18
19endmenu
20endif
diff --git a/arch/arm/plat-tcc/Makefile b/arch/arm/plat-tcc/Makefile
new file mode 100644
index 000000000000..eceabc869b8f
--- /dev/null
+++ b/arch/arm/plat-tcc/Makefile
@@ -0,0 +1,3 @@
1# "Telechips Platform Common Modules"
2
3obj-y := clock.o system.o
diff --git a/arch/arm/plat-tcc/clock.c b/arch/arm/plat-tcc/clock.c
new file mode 100644
index 000000000000..f3ced10d5271
--- /dev/null
+++ b/arch/arm/plat-tcc/clock.c
@@ -0,0 +1,179 @@
1/*
2 * Clock framework for Telechips SoCs
3 * Based on arch/arm/plat-mxc/clock.c
4 *
5 * Copyright (C) 2004 - 2005 Nokia corporation
6 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
7 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
8 * Copyright 2007 Freescale Semiconductor, Inc. All Rights Reserved.
9 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
10 * Copyright 2010 Hans J. Koch, hjk@linutronix.de
11 *
12 * Licensed under the terms of the GPL v2.
13 */
14
15#include <linux/clk.h>
16#include <linux/err.h>
17#include <linux/errno.h>
18#include <linux/module.h>
19#include <linux/mutex.h>
20#include <linux/string.h>
21
22#include <mach/clock.h>
23#include <mach/hardware.h>
24
25static DEFINE_MUTEX(clocks_mutex);
26
27/*-------------------------------------------------------------------------
28 * Standard clock functions defined in include/linux/clk.h
29 *-------------------------------------------------------------------------*/
30
31static void __clk_disable(struct clk *clk)
32{
33 BUG_ON(clk->refcount == 0);
34
35 if (!(--clk->refcount) && clk->disable) {
36 /* Unconditionally disable the clock in hardware */
37 clk->disable(clk);
38 /* recursively disable parents */
39 if (clk->parent)
40 __clk_disable(clk->parent);
41 }
42}
43
44static int __clk_enable(struct clk *clk)
45{
46 int ret = 0;
47
48 if (clk->refcount++ == 0 && clk->enable) {
49 if (clk->parent)
50 ret = __clk_enable(clk->parent);
51 if (ret)
52 return ret;
53 else
54 return clk->enable(clk);
55 }
56
57 return 0;
58}
59
60/* This function increments the reference count on the clock and enables the
61 * clock if not already enabled. The parent clock tree is recursively enabled
62 */
63int clk_enable(struct clk *clk)
64{
65 int ret = 0;
66
67 if (!clk)
68 return -EINVAL;
69
70 mutex_lock(&clocks_mutex);
71 ret = __clk_enable(clk);
72 mutex_unlock(&clocks_mutex);
73
74 return ret;
75}
76EXPORT_SYMBOL_GPL(clk_enable);
77
78/* This function decrements the reference count on the clock and disables
79 * the clock when reference count is 0. The parent clock tree is
80 * recursively disabled
81 */
82void clk_disable(struct clk *clk)
83{
84 if (!clk)
85 return;
86
87 mutex_lock(&clocks_mutex);
88 __clk_disable(clk);
89 mutex_unlock(&clocks_mutex);
90}
91EXPORT_SYMBOL_GPL(clk_disable);
92
93/* Retrieve the *current* clock rate. If the clock itself
94 * does not provide a special calculation routine, ask
95 * its parent and so on, until one is able to return
96 * a valid clock rate
97 */
98unsigned long clk_get_rate(struct clk *clk)
99{
100 if (!clk)
101 return 0UL;
102
103 if (clk->get_rate)
104 return clk->get_rate(clk);
105
106 return clk_get_rate(clk->parent);
107}
108EXPORT_SYMBOL_GPL(clk_get_rate);
109
110/* Round the requested clock rate to the nearest supported
111 * rate that is less than or equal to the requested rate.
112 * This is dependent on the clock's current parent.
113 */
114long clk_round_rate(struct clk *clk, unsigned long rate)
115{
116 if (!clk)
117 return 0;
118 if (!clk->round_rate)
119 return 0;
120
121 return clk->round_rate(clk, rate);
122}
123EXPORT_SYMBOL_GPL(clk_round_rate);
124
125/* Set the clock to the requested clock rate. The rate must
126 * match a supported rate exactly based on what clk_round_rate returns
127 */
128int clk_set_rate(struct clk *clk, unsigned long rate)
129{
130 int ret = -EINVAL;
131
132 if (!clk)
133 return ret;
134 if (!clk->set_rate || !rate)
135 return ret;
136
137 mutex_lock(&clocks_mutex);
138 ret = clk->set_rate(clk, rate);
139 mutex_unlock(&clocks_mutex);
140
141 return ret;
142}
143EXPORT_SYMBOL_GPL(clk_set_rate);
144
145/* Set the clock's parent to another clock source */
146int clk_set_parent(struct clk *clk, struct clk *parent)
147{
148 struct clk *old;
149 int ret = -EINVAL;
150
151 if (!clk)
152 return ret;
153 if (!clk->set_parent || !parent)
154 return ret;
155
156 mutex_lock(&clocks_mutex);
157 old = clk->parent;
158 if (clk->refcount)
159 __clk_enable(parent);
160 ret = clk->set_parent(clk, parent);
161 if (ret)
162 old = parent;
163 if (clk->refcount)
164 __clk_disable(old);
165 mutex_unlock(&clocks_mutex);
166
167 return ret;
168}
169EXPORT_SYMBOL_GPL(clk_set_parent);
170
171/* Retrieve the clock's parent clock source */
172struct clk *clk_get_parent(struct clk *clk)
173{
174 if (!clk)
175 return NULL;
176
177 return clk->parent;
178}
179EXPORT_SYMBOL_GPL(clk_get_parent);
diff --git a/arch/arm/plat-tcc/include/mach/clkdev.h b/arch/arm/plat-tcc/include/mach/clkdev.h
new file mode 100644
index 000000000000..04b37a89801c
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/clkdev.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_MACH_CLKDEV_H
2#define __ASM_MACH_CLKDEV_H
3
4#define __clk_get(clk) ({ 1; })
5#define __clk_put(clk) do { } while (0)
6
7#endif
diff --git a/arch/arm/plat-tcc/include/mach/clock.h b/arch/arm/plat-tcc/include/mach/clock.h
new file mode 100644
index 000000000000..a12f58ad71a8
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/clock.h
@@ -0,0 +1,48 @@
1/*
2 * Low level clock header file for Telechips TCC architecture
3 * (C) 2010 Hans J. Koch <hjk@linutronix.de>
4 *
5 * Licensed under the GPL v2.
6 */
7
8#ifndef __ASM_ARCH_TCC_CLOCK_H__
9#define __ASM_ARCH_TCC_CLOCK_H__
10
11#ifndef __ASSEMBLY__
12
13struct clk {
14 struct clk *parent;
15 /* id number of a root clock, 0 for normal clocks */
16 int root_id;
17 /* Reference count of clock enable/disable */
18 int refcount;
19 /* Address of associated BCLKCTRx register. Must be set. */
20 void __iomem *bclkctr;
21 /* Bit position for BCLKCTRx. Must be set. */
22 int bclk_shift;
23 /* Address of ACLKxxx register, if any. */
24 void __iomem *aclkreg;
25 /* get the current clock rate (always a fresh value) */
26 unsigned long (*get_rate) (struct clk *);
27 /* Function ptr to set the clock to a new rate. The rate must match a
28 supported rate returned from round_rate. Leave blank if clock is not
29 programmable */
30 int (*set_rate) (struct clk *, unsigned long);
31 /* Function ptr to round the requested clock rate to the nearest
32 supported rate that is less than or equal to the requested rate. */
33 unsigned long (*round_rate) (struct clk *, unsigned long);
34 /* Function ptr to enable the clock. Leave blank if clock can not
35 be gated. */
36 int (*enable) (struct clk *);
37 /* Function ptr to disable the clock. Leave blank if clock can not
38 be gated. */
39 void (*disable) (struct clk *);
40 /* Function ptr to set the parent clock of the clock. */
41 int (*set_parent) (struct clk *, struct clk *);
42};
43
44int clk_register(struct clk *clk);
45void clk_unregister(struct clk *clk);
46
47#endif /* __ASSEMBLY__ */
48#endif /* __ASM_ARCH_MXC_CLOCK_H__ */
diff --git a/arch/arm/plat-tcc/include/mach/debug-macro.S b/arch/arm/plat-tcc/include/mach/debug-macro.S
new file mode 100644
index 000000000000..7662f736e42b
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/debug-macro.S
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 1994-1999 Russell King
3 * Copyright (C) 2008-2009 Telechips
4 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12 .macro addruart, rp, rv
13 moveq \rp, #0x90000000 @ physical base address
14 movne \rv, #0xF1000000 @ virtual base
15 orr \rp, \rp, #0x00007000 @ UART0
16 orr \rv, \rv, #0x00007000 @ UART0
17 .endm
18
19 .macro senduart,rd,rx
20 strb \rd, [\rx, #0x44]
21 .endm
22
23 .macro waituart,rd,rx
24 .endm
25
26 .macro busyuart,rd,rx
271001:
28 ldr \rd, [\rx, #0x14]
29 tst \rd, #0x20
30
31 beq 1001b
32 .endm
diff --git a/arch/arm/plat-tcc/include/mach/entry-macro.S b/arch/arm/plat-tcc/include/mach/entry-macro.S
new file mode 100644
index 000000000000..748f401e4b6d
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/entry-macro.S
@@ -0,0 +1,68 @@
1/*
2 * include/asm-arm/arch-tcc83x/entry-macro.S
3 *
4 * Author : <linux@telechips.com>
5 * Created: June 10, 2008
6 * Description: Low-level IRQ helper macros for Telechips-based platforms
7 *
8 * Copyright (C) 2008-2009 Telechips
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
13 */
14
15#include <mach/hardware.h>
16#include <mach/irqs.h>
17
18 .macro disable_fiq
19 .endm
20
21 .macro get_irqnr_preamble, base, tmp
22 .endm
23
24 .macro arch_ret_to_user, tmp1, tmp2
25 .endm
26
27 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
28
29 ldr \base, =0xF2003000 @ base address of PIC registers
30
31 @@ read MREQ register of PIC0
32
33 mov \irqnr, #0
34 ldr \irqstat, [\base, #0x00000014 ] @ lower 32 interrupts
35 cmp \irqstat, #0
36 bne 1001f
37
38 @@ read MREQ register of PIC1
39
40 ldr \irqstat, [\base, #0x00000094] @ upper 32 interrupts
41 cmp \irqstat, #0
42 beq 1002f
43 mov \irqnr, #0x20
44
451001:
46 movs \tmp, \irqstat, lsl #16
47 movne \irqstat, \tmp
48 addeq \irqnr, \irqnr, #16
49
50 movs \tmp, \irqstat, lsl #8
51 movne \irqstat, \tmp
52 addeq \irqnr, \irqnr, #8
53
54 movs \tmp, \irqstat, lsl #4
55 movne \irqstat, \tmp
56 addeq \irqnr, \irqnr, #4
57
58 movs \tmp, \irqstat, lsl #2
59 movne \irqstat, \tmp
60 addeq \irqnr, \irqnr, #2
61
62 movs \tmp, \irqstat, lsl #1
63 addeq \irqnr, \irqnr, #1
64 orrs \base, \base, #1
651002:
66 @@ exit here, Z flag unset if IRQ
67
68 .endm
diff --git a/arch/arm/plat-tcc/include/mach/hardware.h b/arch/arm/plat-tcc/include/mach/hardware.h
new file mode 100644
index 000000000000..e70d126ccaf3
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/hardware.h
@@ -0,0 +1,43 @@
1/*
2 * Author: RidgeRun, Inc. Greg Lonnon <glonnon@ridgerun.com>
3 * Reorganized for Linux-2.6 by Tony Lindgren <tony@atomide.com>
4 * and Dirk Behme <dirk.behme@de.bosch.com>
5 * Rewritten by: <linux@telechips.com>
6 * Description: Hardware definitions for TCC8300 processors and boards
7 *
8 * Copyright (C) 2001 RidgeRun, Inc.
9 * Copyright (C) 2008-2009 Telechips
10 *
11 * Modifications for mainline (C) 2009 Hans J. Koch <hjk@linutronix.de>
12 *
13 * Licensed under the terms of the GNU Pulic License version 2.
14 */
15
16#ifndef __ASM_ARCH_TCC_HARDWARE_H
17#define __ASM_ARCH_TCC_HARDWARE_H
18
19#include <asm/sizes.h>
20#ifndef __ASSEMBLER__
21#include <asm/types.h>
22#endif
23#include <mach/io.h>
24
25/*
26 * ----------------------------------------------------------------------------
27 * Clocks
28 * ----------------------------------------------------------------------------
29 */
30#define CLKGEN_REG_BASE 0xfffece00
31#define ARM_CKCTL (CLKGEN_REG_BASE + 0x0)
32#define ARM_IDLECT1 (CLKGEN_REG_BASE + 0x4)
33#define ARM_IDLECT2 (CLKGEN_REG_BASE + 0x8)
34#define ARM_EWUPCT (CLKGEN_REG_BASE + 0xC)
35#define ARM_RSTCT1 (CLKGEN_REG_BASE + 0x10)
36#define ARM_RSTCT2 (CLKGEN_REG_BASE + 0x14)
37#define ARM_SYSST (CLKGEN_REG_BASE + 0x18)
38#define ARM_IDLECT3 (CLKGEN_REG_BASE + 0x24)
39
40/* DPLL control registers */
41#define DPLL_CTL 0xfffecf00
42
43#endif /* __ASM_ARCH_TCC_HARDWARE_H */
diff --git a/arch/arm/plat-tcc/include/mach/io.h b/arch/arm/plat-tcc/include/mach/io.h
new file mode 100644
index 000000000000..3e911d3ea0f1
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/io.h
@@ -0,0 +1,23 @@
1/*
2 * IO definitions for TCC8000 processors and boards
3 *
4 * Copyright (C) 1997-1999 Russell King
5 * Copyright (C) 2008-2009 Telechips
6 * Copyright (C) 2010 Hans J. Koch <hjk@linutronix.de>
7 *
8 * Licensed under the terms of the GNU Public License version 2.
9 */
10
11#ifndef __ASM_ARM_ARCH_IO_H
12#define __ASM_ARM_ARCH_IO_H
13
14#define IO_SPACE_LIMIT 0xffffffff
15
16/*
17 * We don't actually have real ISA nor PCI buses, but there is so many
18 * drivers out there that might just work if we fake them...
19 */
20#define __io(a) __typesafe_io(a)
21#define __mem_pci(a) (a)
22
23#endif
diff --git a/arch/arm/plat-tcc/include/mach/irqs.h b/arch/arm/plat-tcc/include/mach/irqs.h
new file mode 100644
index 000000000000..da863894d498
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/irqs.h
@@ -0,0 +1,83 @@
1/*
2 * IRQ definitions for TCC8xxx
3 *
4 * Copyright (C) 2008-2009 Telechips
5 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
6 *
7 * Licensed under the terms of the GPL v2.
8 *
9 */
10
11#ifndef __ASM_ARCH_TCC_IRQS_H
12#define __ASM_ARCH_TCC_IRQS_H
13
14#define NR_IRQS 64
15
16/* PIC0 interrupts */
17#define INT_ADMA1 0
18#define INT_BDMA 1
19#define INT_ADMA0 2
20#define INT_GDMA1 3
21#define INT_I2S0RX 4
22#define INT_I2S0TX 5
23#define INT_TC 6
24#define INT_UART0 7
25#define INT_USBD 8
26#define INT_SPI0TX 9
27#define INT_UDMA 10
28#define INT_LIRQ 11
29#define INT_GDMA2 12
30#define INT_GDMA0 13
31#define INT_TC32 14
32#define INT_LCD 15
33#define INT_ADC 16
34#define INT_I2C 17
35#define INT_RTCP 18
36#define INT_RTCA 19
37#define INT_NFC 20
38#define INT_SD0 21
39#define INT_GSB0 22
40#define INT_PK 23
41#define INT_USBH0 24
42#define INT_USBH1 25
43#define INT_G2D 26
44#define INT_ECC 27
45#define INT_SPI0RX 28
46#define INT_UART1 29
47#define INT_MSCL 30
48#define INT_GSB1 31
49/* PIC1 interrupts */
50#define INT_E0 32
51#define INT_E1 33
52#define INT_E2 34
53#define INT_E3 35
54#define INT_E4 36
55#define INT_E5 37
56#define INT_E6 38
57#define INT_E7 39
58#define INT_UART2 40
59#define INT_UART3 41
60#define INT_SPI1TX 42
61#define INT_SPI1RX 43
62#define INT_GSB2 44
63#define INT_SPDIF 45
64#define INT_CDIF 46
65#define INT_VBON 47
66#define INT_VBOFF 48
67#define INT_SD1 49
68#define INT_UART4 50
69#define INT_GDMA3 51
70#define INT_I2S1RX 52
71#define INT_I2S1TX 53
72#define INT_CAN0 54
73#define INT_CAN1 55
74#define INT_GSB3 56
75#define INT_KRST 57
76#define INT_UNUSED 58
77#define INT_SD0D3 59
78#define INT_SD1D3 60
79#define INT_GPS0 61
80#define INT_GPS1 62
81#define INT_GPS2 63
82
83#endif /* ASM_ARCH_TCC_IRQS_H */
diff --git a/arch/arm/plat-tcc/include/mach/memory.h b/arch/arm/plat-tcc/include/mach/memory.h
new file mode 100644
index 000000000000..cd91ba8a670b
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/memory.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright (C) 1999 ARM Limited
3 * Copyright (C) 2000 RidgeRun, Inc.
4 * Copyright (C) 2008-2009 Telechips
5 * Copyright (C) 2010 Hans J. Koch <hjk@linutronix.de>
6 *
7 * Licensed under the terms of the GPL v2.
8 */
9
10#ifndef __ASM_ARCH_MEMORY_H
11#define __ASM_ARCH_MEMORY_H
12
13/*
14 * Physical DRAM offset.
15 */
16#define PHYS_OFFSET UL(0x20000000)
17
18#endif
diff --git a/arch/arm/plat-tcc/include/mach/system.h b/arch/arm/plat-tcc/include/mach/system.h
new file mode 100644
index 000000000000..909e6035d843
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/system.h
@@ -0,0 +1,31 @@
1/*
2 * Author: <linux@telechips.com>
3 * Created: June 10, 2008
4 * Description: LINUX SYSTEM FUNCTIONS for TCC83x
5 *
6 * Copyright (C) 2008-2009 Telechips
7 *
8 * Licensed under the terms of the GPL v2.
9 *
10 */
11
12#ifndef __ASM_ARCH_SYSTEM_H
13#define __ASM_ARCH_SYSTEM_H
14#include <linux/clk.h>
15
16#include <asm/mach-types.h>
17#include <mach/hardware.h>
18
19extern void plat_tcc_reboot(void);
20
21static inline void arch_idle(void)
22{
23 cpu_do_idle();
24}
25
26static inline void arch_reset(char mode, const char *cmd)
27{
28 plat_tcc_reboot();
29}
30
31#endif
diff --git a/arch/arm/plat-tcc/include/mach/tcc8k-regs.h b/arch/arm/plat-tcc/include/mach/tcc8k-regs.h
new file mode 100644
index 000000000000..1d9428295332
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/tcc8k-regs.h
@@ -0,0 +1,807 @@
1/*
2 * Telechips TCC8000 register definitions
3 *
4 * (C) 2009 Hans J. Koch <hjk@linutronix.de>
5 *
6 * Licensed under the terms of the GPLv2.
7 */
8
9#ifndef TCC8K_REGS_H
10#define TCC8K_REGS_H
11
12#include <linux/types.h>
13
14#define EXT_SDRAM_BASE 0x20000000
15#define INT_SRAM_BASE 0x30000000
16#define INT_SRAM_SIZE SZ_32K
17#define CS0_BASE 0x40000000
18#define CS1_BASE 0x50000000
19#define CS1_SIZE SZ_64K
20#define CS2_BASE 0x60000000
21#define CS3_BASE 0x70000000
22#define AHB_PERI_BASE 0x80000000
23#define AHB_PERI_SIZE SZ_64K
24#define APB0_PERI_BASE 0x90000000
25#define APB0_PERI_SIZE SZ_128K
26#define APB1_PERI_BASE 0x98000000
27#define APB1_PERI_SIZE SZ_128K
28#define DATA_TCM_BASE 0xa0000000
29#define DATA_TCM_SIZE SZ_8K
30#define EXT_MEM_CTRL_BASE 0xf0000000
31#define EXT_MEM_CTRL_SIZE SZ_4K
32
33#define CS1_BASE_VIRT (void __iomem *)0xf7000000
34#define AHB_PERI_BASE_VIRT (void __iomem *)0xf4000000
35#define APB0_PERI_BASE_VIRT (void __iomem *)0xf1000000
36#define APB1_PERI_BASE_VIRT (void __iomem *)0xf2000000
37#define EXT_MEM_CTRL_BASE_VIRT (void __iomem *)0xf3000000
38#define INT_SRAM_BASE_VIRT (void __iomem *)0xf5000000
39#define DATA_TCM_BASE_VIRT (void __iomem *)0xf6000000
40
41#define __REG(x) (*((volatile u32 *)(x)))
42
43/* USB Device Controller Registers */
44#define UDC_BASE (AHB_PERI_BASE_VIRT + 0x8000)
45#define UDC_BASE_PHYS (AHB_PERI_BASE + 0x8000)
46
47#define UDC_IR_OFFS 0x00
48#define UDC_EIR_OFFS 0x04
49#define UDC_EIER_OFFS 0x08
50#define UDC_FAR_OFFS 0x0c
51#define UDC_FNR_OFFS 0x10
52#define UDC_EDR_OFFS 0x14
53#define UDC_RT_OFFS 0x18
54#define UDC_SSR_OFFS 0x1c
55#define UDC_SCR_OFFS 0x20
56#define UDC_EP0SR_OFFS 0x24
57#define UDC_EP0CR_OFFS 0x28
58
59#define UDC_ESR_OFFS 0x2c
60#define UDC_ECR_OFFS 0x30
61#define UDC_BRCR_OFFS 0x34
62#define UDC_BWCR_OFFS 0x38
63#define UDC_MPR_OFFS 0x3c
64#define UDC_DCR_OFFS 0x40
65#define UDC_DTCR_OFFS 0x44
66#define UDC_DFCR_OFFS 0x48
67#define UDC_DTTCR1_OFFS 0x4c
68#define UDC_DTTCR2_OFFS 0x50
69#define UDC_ESR2_OFFS 0x54
70
71#define UDC_SCR2_OFFS 0x58
72#define UDC_EP0BUF_OFFS 0x60
73#define UDC_EP1BUF_OFFS 0x64
74#define UDC_EP2BUF_OFFS 0x68
75#define UDC_EP3BUF_OFFS 0x6c
76#define UDC_PLICR_OFFS 0xa0
77#define UDC_PCR_OFFS 0xa4
78
79#define UDC_UPCR0_OFFS 0xc8
80#define UDC_UPCR1_OFFS 0xcc
81#define UDC_UPCR2_OFFS 0xd0
82#define UDC_UPCR3_OFFS 0xd4
83
84/* Bits in UDC_EIR */
85#define UDC_EIR_EP0I (1 << 0)
86#define UDC_EIR_EP1I (1 << 1)
87#define UDC_EIR_EP2I (1 << 2)
88#define UDC_EIR_EP3I (1 << 3)
89#define UDC_EIR_EPI_MASK 0x0f
90
91/* Bits in UDC_EIER */
92#define UDC_EIER_EP0IE (1 << 0)
93#define UDC_EIER_EP1IE (1 << 1)
94#define UDC_EIER_EP2IE (1 << 2)
95#define UDC_EIER_EP3IE (1 << 3)
96
97/* Bits in UDC_FNR */
98#define UDC_FNR_FN_MASK 0x7ff
99#define UDC_FNR_SM (1 << 13)
100#define UDC_FNR_FTL (1 << 14)
101
102/* Bits in UDC_SSR */
103#define UDC_SSR_HFRES (1 << 0)
104#define UDC_SSR_HFSUSP (1 << 1)
105#define UDC_SSR_HFRM (1 << 2)
106#define UDC_SSR_SDE (1 << 3)
107#define UDC_SSR_HSP (1 << 4)
108#define UDC_SSR_DM (1 << 5)
109#define UDC_SSR_DP (1 << 6)
110#define UDC_SSR_TBM (1 << 7)
111#define UDC_SSR_VBON (1 << 8)
112#define UDC_SSR_VBOFF (1 << 9)
113#define UDC_SSR_EOERR (1 << 10)
114#define UDC_SSR_DCERR (1 << 11)
115#define UDC_SSR_TCERR (1 << 12)
116#define UDC_SSR_BSERR (1 << 13)
117#define UDC_SSR_TMERR (1 << 14)
118#define UDC_SSR_BAERR (1 << 15)
119
120/* Bits in UDC_SCR */
121#define UDC_SCR_HRESE (1 << 0)
122#define UDC_SCR_HSSPE (1 << 1)
123#define UDC_SCR_RRDE (1 << 5)
124#define UDC_SCR_SPDEN (1 << 6)
125#define UDC_SCR_DIEN (1 << 12)
126
127/* Bits in UDC_EP0SR */
128#define UDC_EP0SR_RSR (1 << 0)
129#define UDC_EP0SR_TST (1 << 1)
130#define UDC_EP0SR_SHT (1 << 4)
131#define UDC_EP0SR_LWO (1 << 6)
132
133/* Bits in UDC_EP0CR */
134#define UDC_EP0CR_ESS (1 << 1)
135
136/* Bits in UDC_ESR */
137#define UDC_ESR_RPS (1 << 0)
138#define UDC_ESR_TPS (1 << 1)
139#define UDC_ESR_LWO (1 << 4)
140#define UDC_ESR_FFS (1 << 6)
141
142/* Bits in UDC_ECR */
143#define UDC_ECR_ESS (1 << 1)
144#define UDC_ECR_CDP (1 << 2)
145
146#define UDC_ECR_FLUSH (1 << 6)
147#define UDC_ECR_DUEN (1 << 7)
148
149/* Bits in UDC_UPCR0 */
150#define UDC_UPCR0_VBD (1 << 1)
151#define UDC_UPCR0_VBDS (1 << 6)
152#define UDC_UPCR0_RCD_12 (0x0 << 9)
153#define UDC_UPCR0_RCD_24 (0x1 << 9)
154#define UDC_UPCR0_RCD_48 (0x2 << 9)
155#define UDC_UPCR0_RCS_EXT (0x1 << 11)
156#define UDC_UPCR0_RCS_XTAL (0x0 << 11)
157
158/* Bits in UDC_UPCR1 */
159#define UDC_UPCR1_CDT(x) ((x) << 0)
160#define UDC_UPCR1_OTGT(x) ((x) << 3)
161#define UDC_UPCR1_SQRXT(x) ((x) << 8)
162#define UDC_UPCR1_TXFSLST(x) ((x) << 12)
163
164/* Bits in UDC_UPCR2 */
165#define UDC_UPCR2_TP (1 << 0)
166#define UDC_UPCR2_TXRT(x) ((x) << 2)
167#define UDC_UPCR2_TXVRT(x) ((x) << 5)
168#define UDC_UPCR2_OPMODE(x) ((x) << 9)
169#define UDC_UPCR2_XCVRSEL(x) ((x) << 12)
170#define UDC_UPCR2_TM (1 << 14)
171
172/* USB Host Controller registers */
173#define USBH0_BASE (AHB_PERI_BASE_VIRT + 0xb000)
174#define USBH1_BASE (AHB_PERI_BASE_VIRT + 0xb800)
175
176#define OHCI_INT_ENABLE_OFFS 0x10
177
178#define RH_DESCRIPTOR_A_OFFS 0x48
179#define RH_DESCRIPTOR_B_OFFS 0x4c
180
181#define USBHTCFG0_OFFS 0x100
182#define USBHHCFG0_OFFS 0x104
183#define USBHHCFG1_OFFS 0x104
184
185/* DMA controller registers */
186#define DMAC0_BASE (AHB_PERI_BASE + 0x4000)
187#define DMAC1_BASE (AHB_PERI_BASE + 0xa000)
188#define DMAC2_BASE (AHB_PERI_BASE + 0x4800)
189#define DMAC3_BASE (AHB_PERI_BASE + 0xa800)
190
191#define DMAC_CH_OFFSET(ch) (ch * 0x30)
192
193#define ST_SADR_OFFS 0x00
194#define SPARAM_OFFS 0x04
195#define C_SADR_OFFS 0x0c
196#define ST_DADR_OFFS 0x10
197#define DPARAM_OFFS 0x14
198#define C_DADR_OFFS 0x1c
199#define HCOUNT_OFFS 0x20
200#define CHCTRL_OFFS 0x24
201#define RPTCTRL_OFFS 0x28
202#define EXTREQ_A_OFFS 0x2c
203
204/* Bits in CHCTRL register */
205#define CHCTRL_EN (1 << 0)
206
207#define CHCTRL_IEN (1 << 2)
208#define CHCTRL_FLAG (1 << 3)
209#define CHCTRL_WSIZE8 (0 << 4)
210#define CHCTRL_WSIZE16 (1 << 4)
211#define CHCTRL_WSIZE32 (2 << 4)
212
213#define CHCTRL_BSIZE1 (0 << 6)
214#define CHCTRL_BSIZE2 (1 << 6)
215#define CHCTRL_BSIZE4 (2 << 6)
216#define CHCTRL_BSIZE8 (3 << 6)
217
218#define CHCTRL_TYPE_SINGLE_E (0 << 8)
219#define CHCTRL_TYPE_HW (1 << 8)
220#define CHCTRL_TYPE_SW (2 << 8)
221#define CHCTRL_TYPE_SINGLE_L (3 << 8)
222
223#define CHCTRL_BST (1 << 10)
224
225/* Use DMA controller 0, channel 2 for USB */
226#define USB_DMA_BASE (DMAC0_BASE + DMAC_CH_OFFSET(2))
227
228/* NAND flash controller registers */
229#define NFC_BASE (AHB_PERI_BASE_VIRT + 0xd000)
230#define NFC_BASE_PHYS (AHB_PERI_BASE + 0xd000)
231
232#define NFC_CMD_OFFS 0x00
233#define NFC_LADDR_OFFS 0x04
234#define NFC_BADDR_OFFS 0x08
235#define NFC_SADDR_OFFS 0x0c
236#define NFC_WDATA_OFFS 0x10
237#define NFC_LDATA_OFFS 0x20
238#define NFC_SDATA_OFFS 0x40
239#define NFC_CTRL_OFFS 0x50
240#define NFC_PSTART_OFFS 0x54
241#define NFC_RSTART_OFFS 0x58
242#define NFC_DSIZE_OFFS 0x5c
243#define NFC_IREQ_OFFS 0x60
244#define NFC_RST_OFFS 0x64
245#define NFC_CTRL1_OFFS 0x68
246#define NFC_MDATA_OFFS 0x70
247
248#define NFC_WDATA_PHYS_ADDR (NFC_BASE_PHYS + NFC_WDATA_OFFS)
249
250/* Bits in NFC_CTRL */
251#define NFC_CTRL_BHLD_MASK (0xf << 0)
252#define NFC_CTRL_BPW_MASK (0xf << 4)
253#define NFC_CTRL_BSTP_MASK (0xf << 8)
254#define NFC_CTRL_CADDR_MASK (0x7 << 12)
255#define NFC_CTRL_CADDR_1 (0x0 << 12)
256#define NFC_CTRL_CADDR_2 (0x1 << 12)
257#define NFC_CTRL_CADDR_3 (0x2 << 12)
258#define NFC_CTRL_CADDR_4 (0x3 << 12)
259#define NFC_CTRL_CADDR_5 (0x4 << 12)
260#define NFC_CTRL_MSK (1 << 15)
261#define NFC_CTRL_PSIZE256 (0 << 16)
262#define NFC_CTRL_PSIZE512 (1 << 16)
263#define NFC_CTRL_PSIZE1024 (2 << 16)
264#define NFC_CTRL_PSIZE2048 (3 << 16)
265#define NFC_CTRL_PSIZE4096 (4 << 16)
266#define NFC_CTRL_PSIZE_MASK (7 << 16)
267#define NFC_CTRL_BSIZE1 (0 << 19)
268#define NFC_CTRL_BSIZE2 (1 << 19)
269#define NFC_CTRL_BSIZE4 (2 << 19)
270#define NFC_CTRL_BSIZE8 (3 << 19)
271#define NFC_CTRL_BSIZE_MASK (3 << 19)
272#define NFC_CTRL_RDY (1 << 21)
273#define NFC_CTRL_CS0SEL (1 << 22)
274#define NFC_CTRL_CS1SEL (1 << 23)
275#define NFC_CTRL_CS2SEL (1 << 24)
276#define NFC_CTRL_CS3SEL (1 << 25)
277#define NFC_CTRL_CSMASK (0xf << 22)
278#define NFC_CTRL_BW (1 << 26)
279#define NFC_CTRL_FS (1 << 27)
280#define NFC_CTRL_DEN (1 << 28)
281#define NFC_CTRL_READ_IEN (1 << 29)
282#define NFC_CTRL_PROG_IEN (1 << 30)
283#define NFC_CTRL_RDY_IEN (1 << 31)
284
285/* Bits in NFC_IREQ */
286#define NFC_IREQ_IRQ0 (1 << 0)
287#define NFC_IREQ_IRQ1 (1 << 1)
288#define NFC_IREQ_IRQ2 (1 << 2)
289
290#define NFC_IREQ_FLAG0 (1 << 4)
291#define NFC_IREQ_FLAG1 (1 << 5)
292#define NFC_IREQ_FLAG2 (1 << 6)
293
294/* MMC controller registers */
295#define MMC0_BASE (AHB_PERI_BASE_VIRT + 0xe000)
296#define MMC1_BASE (AHB_PERI_BASE_VIRT + 0xe800)
297
298/* UART base addresses */
299
300#define UART0_BASE (APB0_PERI_BASE_VIRT + 0x07000)
301#define UART0_BASE_PHYS (APB0_PERI_BASE + 0x07000)
302#define UART1_BASE (APB0_PERI_BASE_VIRT + 0x08000)
303#define UART1_BASE_PHYS (APB0_PERI_BASE + 0x08000)
304#define UART2_BASE (APB0_PERI_BASE_VIRT + 0x09000)
305#define UART2_BASE_PHYS (APB0_PERI_BASE + 0x09000)
306#define UART3_BASE (APB0_PERI_BASE_VIRT + 0x0a000)
307#define UART3_BASE_PHYS (APB0_PERI_BASE + 0x0a000)
308#define UART4_BASE (APB0_PERI_BASE_VIRT + 0x15000)
309#define UART4_BASE_PHYS (APB0_PERI_BASE + 0x15000)
310
311#define UART_BASE UART0_BASE
312#define UART_BASE_PHYS UART0_BASE_PHYS
313
314/* ECC controller */
315#define ECC_CTR_BASE (APB0_PERI_BASE_VIRT + 0xd000)
316
317#define ECC_CTRL_OFFS 0x00
318#define ECC_BASE_OFFS 0x04
319#define ECC_MASK_OFFS 0x08
320#define ECC_CLEAR_OFFS 0x0c
321#define ECC4_0_OFFS 0x10
322#define ECC4_1_OFFS 0x14
323
324#define ECC_EADDR0_OFFS 0x50
325
326#define ECC_ERRNUM_OFFS 0x90
327#define ECC_IREQ_OFFS 0x94
328
329/* Bits in ECC_CTRL */
330#define ECC_CTRL_ECC4_DIEN (1 << 28)
331#define ECC_CTRL_ECC8_DIEN (1 << 29)
332#define ECC_CTRL_ECC12_DIEN (1 << 30)
333#define ECC_CTRL_ECC_DISABLE 0x0
334#define ECC_CTRL_ECC_SLC_ENC 0x8
335#define ECC_CTRL_ECC_SLC_DEC 0x9
336#define ECC_CTRL_ECC4_ENC 0xa
337#define ECC_CTRL_ECC4_DEC 0xb
338#define ECC_CTRL_ECC8_ENC 0xc
339#define ECC_CTRL_ECC8_DEC 0xd
340#define ECC_CTRL_ECC12_ENC 0xe
341#define ECC_CTRL_ECC12_DEC 0xf
342
343/* Bits in ECC_IREQ */
344#define ECC_IREQ_E4DI (1 << 4)
345
346#define ECC_IREQ_E4DF (1 << 20)
347#define ECC_IREQ_E4EF (1 << 21)
348
349/* Interrupt controller */
350
351#define PIC0_BASE (APB1_PERI_BASE_VIRT + 0x3000)
352#define PIC0_BASE_PHYS (APB1_PERI_BASE + 0x3000)
353
354#define PIC0_IEN_OFFS 0x00
355#define PIC0_CREQ_OFFS 0x04
356#define PIC0_IREQ_OFFS 0x08
357#define PIC0_IRQSEL_OFFS 0x0c
358#define PIC0_SRC_OFFS 0x10
359#define PIC0_MREQ_OFFS 0x14
360#define PIC0_TSTREQ_OFFS 0x18
361#define PIC0_POL_OFFS 0x1c
362#define PIC0_IRQ_OFFS 0x20
363#define PIC0_FIQ_OFFS 0x24
364#define PIC0_MIRQ_OFFS 0x28
365#define PIC0_MFIQ_OFFS 0x2c
366#define PIC0_TMODE_OFFS 0x30
367#define PIC0_SYNC_OFFS 0x34
368#define PIC0_WKUP_OFFS 0x38
369#define PIC0_TMODEA_OFFS 0x3c
370#define PIC0_INTOEN_OFFS 0x40
371#define PIC0_MEN0_OFFS 0x44
372#define PIC0_MEN_OFFS 0x48
373
374#define PIC0_IEN __REG(PIC0_BASE + PIC0_IEN_OFFS)
375#define PIC0_IEN_PHYS __REG(PIC0_BASE_PHYS + PIC0_IEN_OFFS)
376#define PIC0_CREQ __REG(PIC0_BASE + PIC0_CREQ_OFFS)
377#define PIC0_CREQ_PHYS __REG(PIC0_BASE_PHYS + PIC0_CREQ_OFFS)
378#define PIC0_IREQ __REG(PIC0_BASE + PIC0_IREQ_OFFS)
379#define PIC0_IRQSEL __REG(PIC0_BASE + PIC0_IRQSEL_OFFS)
380#define PIC0_IRQSEL_PHYS __REG(PIC0_BASE_PHYS + PIC0_IRQSEL_OFFS)
381#define PIC0_SRC __REG(PIC0_BASE + PIC0_SRC_OFFS)
382#define PIC0_MREQ __REG(PIC0_BASE + PIC0_MREQ_OFFS)
383#define PIC0_TSTREQ __REG(PIC0_BASE + PIC0_TSTREQ_OFFS)
384#define PIC0_POL __REG(PIC0_BASE + PIC0_POL_OFFS)
385#define PIC0_IRQ __REG(PIC0_BASE + PIC0_IRQ_OFFS)
386#define PIC0_FIQ __REG(PIC0_BASE + PIC0_FIQ_OFFS)
387#define PIC0_MIRQ __REG(PIC0_BASE + PIC0_MIRQ_OFFS)
388#define PIC0_MFIQ __REG(PIC0_BASE + PIC0_MFIQ_OFFS)
389#define PIC0_TMODE __REG(PIC0_BASE + PIC0_TMODE_OFFS)
390#define PIC0_TMODE_PHYS __REG(PIC0_BASE_PHYS + PIC0_TMODE_OFFS)
391#define PIC0_SYNC __REG(PIC0_BASE + PIC0_SYNC_OFFS)
392#define PIC0_WKUP __REG(PIC0_BASE + PIC0_WKUP_OFFS)
393#define PIC0_TMODEA __REG(PIC0_BASE + PIC0_TMODEA_OFFS)
394#define PIC0_INTOEN __REG(PIC0_BASE + PIC0_INTOEN_OFFS)
395#define PIC0_MEN0 __REG(PIC0_BASE + PIC0_MEN0_OFFS)
396#define PIC0_MEN __REG(PIC0_BASE + PIC0_MEN_OFFS)
397
398#define PIC1_BASE (APB1_PERI_BASE_VIRT + 0x3080)
399
400#define PIC1_IEN_OFFS 0x00
401#define PIC1_CREQ_OFFS 0x04
402#define PIC1_IREQ_OFFS 0x08
403#define PIC1_IRQSEL_OFFS 0x0c
404#define PIC1_SRC_OFFS 0x10
405#define PIC1_MREQ_OFFS 0x14
406#define PIC1_TSTREQ_OFFS 0x18
407#define PIC1_POL_OFFS 0x1c
408#define PIC1_IRQ_OFFS 0x20
409#define PIC1_FIQ_OFFS 0x24
410#define PIC1_MIRQ_OFFS 0x28
411#define PIC1_MFIQ_OFFS 0x2c
412#define PIC1_TMODE_OFFS 0x30
413#define PIC1_SYNC_OFFS 0x34
414#define PIC1_WKUP_OFFS 0x38
415#define PIC1_TMODEA_OFFS 0x3c
416#define PIC1_INTOEN_OFFS 0x40
417#define PIC1_MEN1_OFFS 0x44
418#define PIC1_MEN_OFFS 0x48
419
420#define PIC1_IEN __REG(PIC1_BASE + PIC1_IEN_OFFS)
421#define PIC1_CREQ __REG(PIC1_BASE + PIC1_CREQ_OFFS)
422#define PIC1_IREQ __REG(PIC1_BASE + PIC1_IREQ_OFFS)
423#define PIC1_IRQSEL __REG(PIC1_BASE + PIC1_IRQSEL_OFFS)
424#define PIC1_SRC __REG(PIC1_BASE + PIC1_SRC_OFFS)
425#define PIC1_MREQ __REG(PIC1_BASE + PIC1_MREQ_OFFS)
426#define PIC1_TSTREQ __REG(PIC1_BASE + PIC1_TSTREQ_OFFS)
427#define PIC1_POL __REG(PIC1_BASE + PIC1_POL_OFFS)
428#define PIC1_IRQ __REG(PIC1_BASE + PIC1_IRQ_OFFS)
429#define PIC1_FIQ __REG(PIC1_BASE + PIC1_FIQ_OFFS)
430#define PIC1_MIRQ __REG(PIC1_BASE + PIC1_MIRQ_OFFS)
431#define PIC1_MFIQ __REG(PIC1_BASE + PIC1_MFIQ_OFFS)
432#define PIC1_TMODE __REG(PIC1_BASE + PIC1_TMODE_OFFS)
433#define PIC1_SYNC __REG(PIC1_BASE + PIC1_SYNC_OFFS)
434#define PIC1_WKUP __REG(PIC1_BASE + PIC1_WKUP_OFFS)
435#define PIC1_TMODEA __REG(PIC1_BASE + PIC1_TMODEA_OFFS)
436#define PIC1_INTOEN __REG(PIC1_BASE + PIC1_INTOEN_OFFS)
437#define PIC1_MEN1 __REG(PIC1_BASE + PIC1_MEN1_OFFS)
438#define PIC1_MEN __REG(PIC1_BASE + PIC1_MEN_OFFS)
439
440/* Timer registers */
441#define TIMER_BASE (APB1_PERI_BASE_VIRT + 0x4000)
442#define TIMER_BASE_PHYS (APB1_PERI_BASE + 0x4000)
443
444#define TWDCFG_OFFS 0x70
445
446#define TC32EN_OFFS 0x80
447#define TC32LDV_OFFS 0x84
448#define TC32CMP0_OFFS 0x88
449#define TC32CMP1_OFFS 0x8c
450#define TC32PCNT_OFFS 0x90
451#define TC32MCNT_OFFS 0x94
452#define TC32IRQ_OFFS 0x98
453
454/* Bits in TC32EN */
455#define TC32EN_PRESCALE_MASK 0x00ffffff
456#define TC32EN_ENABLE (1 << 24)
457#define TC32EN_LOADZERO (1 << 25)
458#define TC32EN_STOPMODE (1 << 26)
459#define TC32EN_LDM0 (1 << 28)
460#define TC32EN_LDM1 (1 << 29)
461
462/* Bits in TC32IRQ */
463#define TC32IRQ_MSTAT_MASK 0x0000001f
464#define TC32IRQ_RSTAT_MASK (0x1f << 8)
465#define TC32IRQ_IRQEN0 (1 << 16)
466#define TC32IRQ_IRQEN1 (1 << 17)
467#define TC32IRQ_IRQEN2 (1 << 18)
468#define TC32IRQ_IRQEN3 (1 << 19)
469#define TC32IRQ_IRQEN4 (1 << 20)
470#define TC32IRQ_RSYNC (1 << 30)
471#define TC32IRQ_IRQCLR (1 << 31)
472
473/* GPIO registers */
474#define GPIOPD_BASE (APB1_PERI_BASE_VIRT + 0x5000)
475
476#define GPIOPD_DAT_OFFS 0x00
477#define GPIOPD_DOE_OFFS 0x04
478#define GPIOPD_FS0_OFFS 0x08
479#define GPIOPD_FS1_OFFS 0x0c
480#define GPIOPD_FS2_OFFS 0x10
481#define GPIOPD_RPU_OFFS 0x30
482#define GPIOPD_RPD_OFFS 0x34
483#define GPIOPD_DV0_OFFS 0x38
484#define GPIOPD_DV1_OFFS 0x3c
485
486#define GPIOPS_BASE (APB1_PERI_BASE_VIRT + 0x5000)
487
488#define GPIOPS_DAT_OFFS 0x40
489#define GPIOPS_DOE_OFFS 0x44
490#define GPIOPS_FS0_OFFS 0x48
491#define GPIOPS_FS1_OFFS 0x4c
492#define GPIOPS_FS2_OFFS 0x50
493#define GPIOPS_FS3_OFFS 0x54
494#define GPIOPS_RPU_OFFS 0x70
495#define GPIOPS_RPD_OFFS 0x74
496#define GPIOPS_DV0_OFFS 0x78
497#define GPIOPS_DV1_OFFS 0x7c
498
499#define GPIOPS_FS1_SDH0_BITS 0x000000ff
500#define GPIOPS_FS1_SDH1_BITS 0x0000ff00
501
502#define GPIOPU_BASE (APB1_PERI_BASE_VIRT + 0x5000)
503
504#define GPIOPU_DAT_OFFS 0x80
505#define GPIOPU_DOE_OFFS 0x84
506#define GPIOPU_FS0_OFFS 0x88
507#define GPIOPU_FS1_OFFS 0x8c
508#define GPIOPU_FS2_OFFS 0x90
509#define GPIOPU_RPU_OFFS 0xb0
510#define GPIOPU_RPD_OFFS 0xb4
511#define GPIOPU_DV0_OFFS 0xb8
512#define GPIOPU_DV1_OFFS 0xbc
513
514#define GPIOPU_FS0_TXD0 (1 << 0)
515#define GPIOPU_FS0_RXD0 (1 << 1)
516#define GPIOPU_FS0_CTS0 (1 << 2)
517#define GPIOPU_FS0_RTS0 (1 << 3)
518#define GPIOPU_FS0_TXD1 (1 << 4)
519#define GPIOPU_FS0_RXD1 (1 << 5)
520#define GPIOPU_FS0_CTS1 (1 << 6)
521#define GPIOPU_FS0_RTS1 (1 << 7)
522#define GPIOPU_FS0_TXD2 (1 << 8)
523#define GPIOPU_FS0_RXD2 (1 << 9)
524#define GPIOPU_FS0_CTS2 (1 << 10)
525#define GPIOPU_FS0_RTS2 (1 << 11)
526#define GPIOPU_FS0_TXD3 (1 << 12)
527#define GPIOPU_FS0_RXD3 (1 << 13)
528#define GPIOPU_FS0_CTS3 (1 << 14)
529#define GPIOPU_FS0_RTS3 (1 << 15)
530#define GPIOPU_FS0_TXD4 (1 << 16)
531#define GPIOPU_FS0_RXD4 (1 << 17)
532#define GPIOPU_FS0_CTS4 (1 << 18)
533#define GPIOPU_FS0_RTS4 (1 << 19)
534
535#define GPIOFC_BASE (APB1_PERI_BASE_VIRT + 0x5000)
536
537#define GPIOFC_DAT_OFFS 0xc0
538#define GPIOFC_DOE_OFFS 0xc4
539#define GPIOFC_FS0_OFFS 0xc8
540#define GPIOFC_FS1_OFFS 0xcc
541#define GPIOFC_FS2_OFFS 0xd0
542#define GPIOFC_FS3_OFFS 0xd4
543#define GPIOFC_RPU_OFFS 0xf0
544#define GPIOFC_RPD_OFFS 0xf4
545#define GPIOFC_DV0_OFFS 0xf8
546#define GPIOFC_DV1_OFFS 0xfc
547
548#define GPIOFD_BASE (APB1_PERI_BASE_VIRT + 0x5000)
549
550#define GPIOFD_DAT_OFFS 0x100
551#define GPIOFD_DOE_OFFS 0x104
552#define GPIOFD_FS0_OFFS 0x108
553#define GPIOFD_FS1_OFFS 0x10c
554#define GPIOFD_FS2_OFFS 0x110
555#define GPIOFD_RPU_OFFS 0x130
556#define GPIOFD_RPD_OFFS 0x134
557#define GPIOFD_DV0_OFFS 0x138
558#define GPIOFD_DV1_OFFS 0x13c
559
560#define GPIOLC_BASE (APB1_PERI_BASE_VIRT + 0x5000)
561
562#define GPIOLC_DAT_OFFS 0x140
563#define GPIOLC_DOE_OFFS 0x144
564#define GPIOLC_FS0_OFFS 0x148
565#define GPIOLC_FS1_OFFS 0x14c
566#define GPIOLC_RPU_OFFS 0x170
567#define GPIOLC_RPD_OFFS 0x174
568#define GPIOLC_DV0_OFFS 0x178
569#define GPIOLC_DV1_OFFS 0x17c
570
571#define GPIOLD_BASE (APB1_PERI_BASE_VIRT + 0x5000)
572
573#define GPIOLD_DAT_OFFS 0x180
574#define GPIOLD_DOE_OFFS 0x184
575#define GPIOLD_FS0_OFFS 0x188
576#define GPIOLD_FS1_OFFS 0x18c
577#define GPIOLD_FS2_OFFS 0x190
578#define GPIOLD_RPU_OFFS 0x1b0
579#define GPIOLD_RPD_OFFS 0x1b4
580#define GPIOLD_DV0_OFFS 0x1b8
581#define GPIOLD_DV1_OFFS 0x1bc
582
583#define GPIOAD_BASE (APB1_PERI_BASE_VIRT + 0x5000)
584
585#define GPIOAD_DAT_OFFS 0x1c0
586#define GPIOAD_DOE_OFFS 0x1c4
587#define GPIOAD_FS0_OFFS 0x1c8
588#define GPIOAD_RPU_OFFS 0x1f0
589#define GPIOAD_RPD_OFFS 0x1f4
590#define GPIOAD_DV0_OFFS 0x1f8
591#define GPIOAD_DV1_OFFS 0x1fc
592
593#define GPIOXC_BASE (APB1_PERI_BASE_VIRT + 0x5000)
594
595#define GPIOXC_DAT_OFFS 0x200
596#define GPIOXC_DOE_OFFS 0x204
597#define GPIOXC_FS0_OFFS 0x208
598#define GPIOXC_RPU_OFFS 0x230
599#define GPIOXC_RPD_OFFS 0x234
600#define GPIOXC_DV0_OFFS 0x238
601#define GPIOXC_DV1_OFFS 0x23c
602
603#define GPIOXC_FS0 __REG(GPIOXC_BASE + GPIOXC_FS0_OFFS)
604
605#define GPIOXC_FS0_CS0 (1 << 26)
606#define GPIOXC_FS0_CS1 (1 << 27)
607
608#define GPIOXD_BASE (APB1_PERI_BASE_VIRT + 0x5000)
609
610#define GPIOXD_DAT_OFFS 0x240
611#define GPIOXD_FS0_OFFS 0x248
612#define GPIOXD_RPU_OFFS 0x270
613#define GPIOXD_RPD_OFFS 0x274
614#define GPIOXD_DV0_OFFS 0x278
615#define GPIOXD_DV1_OFFS 0x27c
616
617#define GPIOPK_BASE (APB1_PERI_BASE_VIRT + 0x1c000)
618
619#define GPIOPK_RST_OFFS 0x008
620#define GPIOPK_DAT_OFFS 0x100
621#define GPIOPK_DOE_OFFS 0x104
622#define GPIOPK_FS0_OFFS 0x108
623#define GPIOPK_FS1_OFFS 0x10c
624#define GPIOPK_FS2_OFFS 0x110
625#define GPIOPK_IRQST_OFFS 0x210
626#define GPIOPK_IRQEN_OFFS 0x214
627#define GPIOPK_IRQPOL_OFFS 0x218
628#define GPIOPK_IRQTM0_OFFS 0x21c
629#define GPIOPK_IRQTM1_OFFS 0x220
630#define GPIOPK_CTL_OFFS 0x22c
631
632#define PMGPIO_BASE (APB1_PERI_BASE_VIRT + 0x10000)
633#define BACKUP_RAM_BASE PMGPIO_BASE
634
635#define PMGPIO_DAT_OFFS 0x800
636#define PMGPIO_DOE_OFFS 0x804
637#define PMGPIO_FS0_OFFS 0x808
638#define PMGPIO_RPU_OFFS 0x810
639#define PMGPIO_RPD_OFFS 0x814
640#define PMGPIO_DV0_OFFS 0x818
641#define PMGPIO_DV1_OFFS 0x81c
642#define PMGPIO_EE0_OFFS 0x820
643#define PMGPIO_EE1_OFFS 0x824
644#define PMGPIO_CTL_OFFS 0x828
645#define PMGPIO_DI_OFFS 0x82c
646#define PMGPIO_STR_OFFS 0x830
647#define PMGPIO_STF_OFFS 0x834
648#define PMGPIO_POL_OFFS 0x838
649#define PMGPIO_APB_OFFS 0x800
650
651/* Clock controller registers */
652#define CKC_BASE ((void __iomem *)(APB1_PERI_BASE_VIRT + 0x6000))
653
654#define CLKCTRL_OFFS 0x00
655#define PLL0CFG_OFFS 0x04
656#define PLL1CFG_OFFS 0x08
657#define CLKDIVC0_OFFS 0x0c
658
659#define BCLKCTR0_OFFS 0x14
660#define SWRESET0_OFFS 0x18
661
662#define BCLKCTR1_OFFS 0x60
663#define SWRESET1_OFFS 0x64
664#define PWDCTL_OFFS 0x68
665#define PLL2CFG_OFFS 0x6c
666#define CLKDIVC1_OFFS 0x70
667
668#define ACLKREF_OFFS 0x80
669#define ACLKI2C_OFFS 0x84
670#define ACLKSPI0_OFFS 0x88
671#define ACLKSPI1_OFFS 0x8c
672#define ACLKUART0_OFFS 0x90
673#define ACLKUART1_OFFS 0x94
674#define ACLKUART2_OFFS 0x98
675#define ACLKUART3_OFFS 0x9c
676#define ACLKUART4_OFFS 0xa0
677#define ACLKTCT_OFFS 0xa4
678#define ACLKTCX_OFFS 0xa8
679#define ACLKTCZ_OFFS 0xac
680#define ACLKADC_OFFS 0xb0
681#define ACLKDAI0_OFFS 0xb4
682#define ACLKDAI1_OFFS 0xb8
683#define ACLKLCD_OFFS 0xbc
684#define ACLKSPDIF_OFFS 0xc0
685#define ACLKUSBH_OFFS 0xc4
686#define ACLKSDH0_OFFS 0xc8
687#define ACLKSDH1_OFFS 0xcc
688#define ACLKC3DEC_OFFS 0xd0
689#define ACLKEXT_OFFS 0xd4
690#define ACLKCAN0_OFFS 0xd8
691#define ACLKCAN1_OFFS 0xdc
692#define ACLKGSB0_OFFS 0xe0
693#define ACLKGSB1_OFFS 0xe4
694#define ACLKGSB2_OFFS 0xe8
695#define ACLKGSB3_OFFS 0xec
696
697#define PLLxCFG_PD (1 << 31)
698
699/* CLKCTRL bits */
700#define CLKCTRL_XE (1 << 31)
701
702/* CLKDIVCx bits */
703#define CLKDIVC0_XTE (1 << 7)
704#define CLKDIVC0_XE (1 << 15)
705#define CLKDIVC0_P1E (1 << 23)
706#define CLKDIVC0_P0E (1 << 31)
707
708#define CLKDIVC1_P2E (1 << 7)
709
710/* BCLKCTR0 clock bits */
711#define BCLKCTR0_USBD (1 << 4)
712#define BCLKCTR0_ECC (1 << 9)
713#define BCLKCTR0_USBH0 (1 << 11)
714#define BCLKCTR0_NFC (1 << 16)
715
716/* BCLKCTR1 clock bits */
717#define BCLKCTR1_USBH1 (1 << 20)
718
719/* SWRESET0 bits */
720#define SWRESET0_USBD (1 << 4)
721#define SWRESET0_USBH0 (1 << 11)
722
723/* SWRESET1 bits */
724#define SWRESET1_USBH1 (1 << 20)
725
726/* System clock sources.
727 * Note: These are the clock sources that serve as parents for
728 * all other clocks. They have no parents themselves.
729 *
730 * These values are used for struct clk->root_id. All clocks
731 * that are not system clock sources have this value set to
732 * CLK_SRC_NOROOT.
733 * The values for system clocks start with CLK_SRC_PLL0 == 0
734 * because this gives us exactly the values needed for the lower
735 * 4 bits of ACLK_* registers. Therefore, CLK_SRC_NOROOT is
736 * defined as -1 to not disturb the order.
737 */
738enum root_clks {
739 CLK_SRC_NOROOT = -1,
740 CLK_SRC_PLL0 = 0,
741 CLK_SRC_PLL1,
742 CLK_SRC_PLL0DIV,
743 CLK_SRC_PLL1DIV,
744 CLK_SRC_XI,
745 CLK_SRC_XIDIV,
746 CLK_SRC_XTI,
747 CLK_SRC_XTIDIV,
748 CLK_SRC_PLL2,
749 CLK_SRC_PLL2DIV,
750 CLK_SRC_PK0,
751 CLK_SRC_PK1,
752 CLK_SRC_PK2,
753 CLK_SRC_PK3,
754 CLK_SRC_PK4,
755 CLK_SRC_48MHZ
756};
757
758#define CLK_SRC_MASK 0xf
759
760/* Bits in ACLK* registers */
761#define ACLK_EN (1 << 28)
762#define ACLK_SEL_SHIFT 24
763#define ACLK_SEL_MASK 0x0f000000
764#define ACLK_DIV_MASK 0x00000fff
765
766/* System configuration registers */
767
768#define SCFG_BASE (APB1_PERI_BASE_VIRT + 0x13000)
769
770#define BMI_OFFS 0x00
771#define AHBCON0_OFFS 0x04
772#define APBPWE_OFFS 0x08
773#define DTCMWAIT_OFFS 0x0c
774#define ECCSEL_OFFS 0x10
775#define AHBCON1_OFFS 0x14
776#define SDHCFG_OFFS 0x18
777#define REMAP_OFFS 0x20
778#define LCDSIAE_OFFS 0x24
779#define XMCCFG_OFFS 0xe0
780#define IMCCFG_OFFS 0xe4
781
782/* Values for ECCSEL */
783#define ECCSEL_EXTMEM 0x0
784#define ECCSEL_DTCM 0x1
785#define ECCSEL_INT_SRAM 0x2
786#define ECCSEL_AHB 0x3
787
788/* Bits in XMCCFG */
789#define XMCCFG_NFCE (1 << 1)
790#define XMCCFG_FDXD (1 << 2)
791
792/* External memory controller registers */
793
794#define EMC_BASE EXT_MEM_CTRL_BASE
795
796#define SDCFG_OFFS 0x00
797#define SDFSM_OFFS 0x04
798#define MCFG_OFFS 0x08
799
800#define CSCFG0_OFFS 0x10
801#define CSCFG1_OFFS 0x14
802#define CSCFG2_OFFS 0x18
803#define CSCFG3_OFFS 0x1c
804
805#define MCFG_SDEN (1 << 4)
806
807#endif /* TCC8K_REGS_H */
diff --git a/arch/arm/plat-tcc/include/mach/timex.h b/arch/arm/plat-tcc/include/mach/timex.h
new file mode 100644
index 000000000000..057acbe651d9
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/timex.h
@@ -0,0 +1,5 @@
1/*
2 * A definition needed by arch core code.
3 *
4 */
5#define CLOCK_TICK_RATE (HZ * 100000UL)
diff --git a/arch/arm/plat-tcc/include/mach/uncompress.h b/arch/arm/plat-tcc/include/mach/uncompress.h
new file mode 100644
index 000000000000..7a3e33a27a30
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/uncompress.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
3 *
4 * This file is licensed under the terms of the GPL version 2.
5 */
6
7#include <linux/serial_reg.h>
8#include <linux/types.h>
9
10#include <mach/tcc8k-regs.h>
11
12unsigned int system_rev;
13
14#define ID_MASK 0x7fff
15
16static void putc(int c)
17{
18 u32 *uart_lsr = (u32 *)(UART_BASE_PHYS + (UART_LSR << 2));
19 u32 *uart_tx = (u32 *)(UART_BASE_PHYS + (UART_TX << 2));
20
21 while (!(*uart_lsr & UART_LSR_THRE))
22 barrier();
23 *uart_tx = c;
24}
25
26static inline void flush(void)
27{
28}
29
30/*
31 * nothing to do
32 */
33#define arch_decomp_setup()
34#define arch_decomp_wdog()
diff --git a/arch/arm/plat-tcc/include/mach/vmalloc.h b/arch/arm/plat-tcc/include/mach/vmalloc.h
new file mode 100644
index 000000000000..99414d9c2b94
--- /dev/null
+++ b/arch/arm/plat-tcc/include/mach/vmalloc.h
@@ -0,0 +1,10 @@
1/*
2 * Author: <linux@telechips.com>
3 * Created: June 10, 2008
4 *
5 * Copyright (C) 2000 Russell King.
6 * Copyright (C) 2008-2009 Telechips
7 *
8 * Licensed under the terms of the GPL v2.
9 */
10#define VMALLOC_END 0xf0000000UL
diff --git a/arch/arm/plat-tcc/system.c b/arch/arm/plat-tcc/system.c
new file mode 100644
index 000000000000..cc208fae3e7a
--- /dev/null
+++ b/arch/arm/plat-tcc/system.c
@@ -0,0 +1,25 @@
1/*
2 * System functions for Telechips TCCxxxx SoCs
3 *
4 * Copyright (C) Hans J. Koch <hjk@linutronix.de>
5 *
6 * Licensed under the terms of the GPL v2.
7 *
8 */
9
10#include <linux/io.h>
11
12#include <mach/tcc8k-regs.h>
13
14/* System reboot */
15void plat_tcc_reboot(void)
16{
17 /* Make sure clocks are on */
18 __raw_writel(0xffffffff, CKC_BASE + BCLKCTR0_OFFS);
19
20 /* Enable watchdog reset */
21 __raw_writel(0x49, TIMER_BASE + TWDCFG_OFFS);
22 /* Wait for reset */
23 while(1)
24 ;
25}
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index f51572772e21..f0dc5b8075a7 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -90,6 +90,7 @@ config PLATFORM_AT32AP
90 select ARCH_REQUIRE_GPIOLIB 90 select ARCH_REQUIRE_GPIOLIB
91 select GENERIC_ALLOCATOR 91 select GENERIC_ALLOCATOR
92 select HAVE_FB_ATMEL 92 select HAVE_FB_ATMEL
93 select HAVE_NET_MACB
93 94
94# 95#
95# CPU types 96# CPU types
@@ -145,7 +146,7 @@ config BOARD_HAMMERHEAD
145 will cover even the most exceptional need of memory bandwidth. Together with the onboard 146 will cover even the most exceptional need of memory bandwidth. Together with the onboard
146 video decoder the board is ready for video processing. 147 video decoder the board is ready for video processing.
147 148
148 For more information see: http://www.miromico.com/hammerhead 149 For more information see: http://www.miromico.ch/index.php/hammerhead.html
149 150
150config BOARD_FAVR_32 151config BOARD_FAVR_32
151 bool "Favr-32 LCD-board" 152 bool "Favr-32 LCD-board"
diff --git a/arch/avr32/boards/mimc200/fram.c b/arch/avr32/boards/mimc200/fram.c
index 54fbd95cee9b..9764a1a1073e 100644
--- a/arch/avr32/boards/mimc200/fram.c
+++ b/arch/avr32/boards/mimc200/fram.c
@@ -41,6 +41,7 @@ static int fram_mmap(struct file *filp, struct vm_area_struct *vma)
41static const struct file_operations fram_fops = { 41static const struct file_operations fram_fops = {
42 .owner = THIS_MODULE, 42 .owner = THIS_MODULE,
43 .mmap = fram_mmap, 43 .mmap = fram_mmap,
44 .llseek = noop_llseek,
44}; 45};
45 46
46#define FRAM_MINOR 0 47#define FRAM_MINOR 0
diff --git a/arch/avr32/include/asm/ioctls.h b/arch/avr32/include/asm/ioctls.h
index b7dd324b46a9..909cf66feaf5 100644
--- a/arch/avr32/include/asm/ioctls.h
+++ b/arch/avr32/include/asm/ioctls.h
@@ -1,90 +1,6 @@
1#ifndef __ASM_AVR32_IOCTLS_H 1#ifndef __ASM_AVR32_IOCTLS_H
2#define __ASM_AVR32_IOCTLS_H 2#define __ASM_AVR32_IOCTLS_H
3 3
4#include <asm/ioctl.h> 4#include <asm-generic/ioctls.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
57
58#define TIOCGRS485 0x542E
59#define TIOCSRS485 0x542F
60
61#define FIONCLEX 0x5450
62#define FIOCLEX 0x5451
63#define FIOASYNC 0x5452
64#define TIOCSERCONFIG 0x5453
65#define TIOCSERGWILD 0x5454
66#define TIOCSERSWILD 0x5455
67#define TIOCGLCKTRMIOS 0x5456
68#define TIOCSLCKTRMIOS 0x5457
69#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
70#define TIOCSERGETLSR 0x5459 /* Get line status register */
71#define TIOCSERGETMULTI 0x545A /* Get multiport config */
72#define TIOCSERSETMULTI 0x545B /* Set multiport config */
73
74#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
75#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
76#define FIOQSIZE 0x5460
77
78/* Used for packet mode */
79#define TIOCPKT_DATA 0
80#define TIOCPKT_FLUSHREAD 1
81#define TIOCPKT_FLUSHWRITE 2
82#define TIOCPKT_STOP 4
83#define TIOCPKT_START 8
84#define TIOCPKT_NOSTOP 16
85#define TIOCPKT_DOSTOP 32
86#define TIOCPKT_IOCTL 64
87
88#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
89 5
90#endif /* __ASM_AVR32_IOCTLS_H */ 6#endif /* __ASM_AVR32_IOCTLS_H */
diff --git a/arch/avr32/include/asm/irqflags.h b/arch/avr32/include/asm/irqflags.h
index 93570daac38a..006e9487372d 100644
--- a/arch/avr32/include/asm/irqflags.h
+++ b/arch/avr32/include/asm/irqflags.h
@@ -8,16 +8,14 @@
8#ifndef __ASM_AVR32_IRQFLAGS_H 8#ifndef __ASM_AVR32_IRQFLAGS_H
9#define __ASM_AVR32_IRQFLAGS_H 9#define __ASM_AVR32_IRQFLAGS_H
10 10
11#include <linux/types.h>
11#include <asm/sysreg.h> 12#include <asm/sysreg.h>
12 13
13static inline unsigned long __raw_local_save_flags(void) 14static inline unsigned long arch_local_save_flags(void)
14{ 15{
15 return sysreg_read(SR); 16 return sysreg_read(SR);
16} 17}
17 18
18#define raw_local_save_flags(x) \
19 do { (x) = __raw_local_save_flags(); } while (0)
20
21/* 19/*
22 * This will restore ALL status register flags, not only the interrupt 20 * This will restore ALL status register flags, not only the interrupt
23 * mask flag. 21 * mask flag.
@@ -25,44 +23,39 @@ static inline unsigned long __raw_local_save_flags(void)
25 * The empty asm statement informs the compiler of this fact while 23 * The empty asm statement informs the compiler of this fact while
26 * also serving as a barrier. 24 * also serving as a barrier.
27 */ 25 */
28static inline void raw_local_irq_restore(unsigned long flags) 26static inline void arch_local_irq_restore(unsigned long flags)
29{ 27{
30 sysreg_write(SR, flags); 28 sysreg_write(SR, flags);
31 asm volatile("" : : : "memory", "cc"); 29 asm volatile("" : : : "memory", "cc");
32} 30}
33 31
34static inline void raw_local_irq_disable(void) 32static inline void arch_local_irq_disable(void)
35{ 33{
36 asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory"); 34 asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
37} 35}
38 36
39static inline void raw_local_irq_enable(void) 37static inline void arch_local_irq_enable(void)
40{ 38{
41 asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory"); 39 asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
42} 40}
43 41
44static inline int raw_irqs_disabled_flags(unsigned long flags) 42static inline bool arch_irqs_disabled_flags(unsigned long flags)
45{ 43{
46 return (flags & SYSREG_BIT(GM)) != 0; 44 return (flags & SYSREG_BIT(GM)) != 0;
47} 45}
48 46
49static inline int raw_irqs_disabled(void) 47static inline bool arch_irqs_disabled(void)
50{ 48{
51 unsigned long flags = __raw_local_save_flags(); 49 return arch_irqs_disabled_flags(arch_local_save_flags());
52
53 return raw_irqs_disabled_flags(flags);
54} 50}
55 51
56static inline unsigned long __raw_local_irq_save(void) 52static inline unsigned long arch_local_irq_save(void)
57{ 53{
58 unsigned long flags = __raw_local_save_flags(); 54 unsigned long flags = arch_local_save_flags();
59 55
60 raw_local_irq_disable(); 56 arch_local_irq_disable();
61 57
62 return flags; 58 return flags;
63} 59}
64 60
65#define raw_local_irq_save(flags) \
66 do { (flags) = __raw_local_irq_save(); } while (0)
67
68#endif /* __ASM_AVR32_IRQFLAGS_H */ 61#endif /* __ASM_AVR32_IRQFLAGS_H */
diff --git a/arch/avr32/kernel/module.c b/arch/avr32/kernel/module.c
index 98f94d041d9c..a727f54d64d6 100644
--- a/arch/avr32/kernel/module.c
+++ b/arch/avr32/kernel/module.c
@@ -314,10 +314,9 @@ int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
314 vfree(module->arch.syminfo); 314 vfree(module->arch.syminfo);
315 module->arch.syminfo = NULL; 315 module->arch.syminfo = NULL;
316 316
317 return module_bug_finalize(hdr, sechdrs, module); 317 return 0;
318} 318}
319 319
320void module_arch_cleanup(struct module *module) 320void module_arch_cleanup(struct module *module)
321{ 321{
322 module_bug_cleanup(module);
323} 322}
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 5a3152b75cdb..d9a1cb7ec30a 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -300,7 +300,7 @@ config BF_REV_0_1
300 300
301config BF_REV_0_2 301config BF_REV_0_2
302 bool "0.2" 302 bool "0.2"
303 depends on (BF52x || BF537 || BF536 || BF534 || (BF54x && !BF54xM)) 303 depends on (BF51x || BF52x || BF537 || BF536 || BF534 || (BF54x && !BF54xM))
304 304
305config BF_REV_0_3 305config BF_REV_0_3
306 bool "0.3" 306 bool "0.3"
@@ -356,7 +356,7 @@ config MEM_MT48LC8M32B2B5_7
356 356
357config MEM_MT48LC32M16A2TG_75 357config MEM_MT48LC32M16A2TG_75
358 bool 358 bool
359 depends on (BFIN527_EZKIT || BFIN527_EZKIT_V2 || BFIN532_IP0X || BLACKSTAMP) 359 depends on (BFIN527_EZKIT || BFIN527_EZKIT_V2 || BFIN532_IP0X || BLACKSTAMP || BFIN527_AD7160EVAL)
360 default y 360 default y
361 361
362config MEM_MT48H32M16LFCJ_75 362config MEM_MT48H32M16LFCJ_75
@@ -426,6 +426,7 @@ config CLKIN_HZ
426 default "25000000" # most people use this 426 default "25000000" # most people use this
427 default "27000000" if BFIN533_EZKIT 427 default "27000000" if BFIN533_EZKIT
428 default "30000000" if BFIN561_EZKIT 428 default "30000000" if BFIN561_EZKIT
429 default "24000000" if BFIN527_AD7160EVAL
429 help 430 help
430 The frequency of CLKIN crystal oscillator on the board in Hz. 431 The frequency of CLKIN crystal oscillator on the board in Hz.
431 Warning: This value should match the crystal on the board. Otherwise, 432 Warning: This value should match the crystal on the board. Otherwise,
@@ -463,6 +464,7 @@ config VCO_MULT
463 default "20" if (BFIN537_BLUETECHNIX_CM_E || BFIN537_BLUETECHNIX_CM_U || BFIN527_BLUETECHNIX_CM || BFIN561_BLUETECHNIX_CM) 464 default "20" if (BFIN537_BLUETECHNIX_CM_E || BFIN537_BLUETECHNIX_CM_U || BFIN527_BLUETECHNIX_CM || BFIN561_BLUETECHNIX_CM)
464 default "20" if BFIN561_EZKIT 465 default "20" if BFIN561_EZKIT
465 default "16" if (H8606_HVSISTEMAS || BLACKSTAMP || BFIN526_EZBRD || BFIN518F_EZBRD) 466 default "16" if (H8606_HVSISTEMAS || BLACKSTAMP || BFIN526_EZBRD || BFIN518F_EZBRD)
467 default "25" if BFIN527_AD7160EVAL
466 help 468 help
467 This controls the frequency of the on-chip PLL. This can be between 1 and 64. 469 This controls the frequency of the on-chip PLL. This can be between 1 and 64.
468 PLL Frequency = (Crystal Frequency) * (this setting) 470 PLL Frequency = (Crystal Frequency) * (this setting)
@@ -926,6 +928,12 @@ config ROMKERNEL
926 928
927endchoice 929endchoice
928 930
931# Common code uses "ROMKERNEL" or "XIP_KERNEL", so define both
932config XIP_KERNEL
933 bool
934 default y
935 depends on ROMKERNEL
936
929source "mm/Kconfig" 937source "mm/Kconfig"
930 938
931config BFIN_GPTIMERS 939config BFIN_GPTIMERS
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 3e65b0ffe084..46738d49b7c8 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -101,9 +101,8 @@ KBUILD_CFLAGS += -mcpu=$(cpu-y)-$(rev-y)
101KBUILD_AFLAGS += -mcpu=$(cpu-y)-$(rev-y) 101KBUILD_AFLAGS += -mcpu=$(cpu-y)-$(rev-y)
102 102
103# - we utilize the silicon rev from the toolchain, so move it over to the checkflags 103# - we utilize the silicon rev from the toolchain, so move it over to the checkflags
104# - the l1_text attribute is Blackfin specific, so fake it out as used to kill warnings
105CHECKFLAGS_SILICON = $(shell echo "" | $(CPP) $(KBUILD_CFLAGS) -dD - 2>/dev/null | awk '$$2 == "__SILICON_REVISION__" { print $$3 }') 104CHECKFLAGS_SILICON = $(shell echo "" | $(CPP) $(KBUILD_CFLAGS) -dD - 2>/dev/null | awk '$$2 == "__SILICON_REVISION__" { print $$3 }')
106CHECKFLAGS += -D__SILICON_REVISION__=$(CHECKFLAGS_SILICON) -Dl1_text=__used__ 105CHECKFLAGS += -D__SILICON_REVISION__=$(CHECKFLAGS_SILICON) -D__bfin__
107 106
108head-y := arch/$(ARCH)/kernel/init_task.o 107head-y := arch/$(ARCH)/kernel/init_task.o
109 108
diff --git a/arch/blackfin/configs/BF527-AD7160-EVAL_defconfig b/arch/blackfin/configs/BF527-AD7160-EVAL_defconfig
new file mode 100644
index 000000000000..08c55f6b8b7a
--- /dev/null
+++ b/arch/blackfin/configs/BF527-AD7160-EVAL_defconfig
@@ -0,0 +1,105 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y
7# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
8CONFIG_EMBEDDED=y
9# CONFIG_ELF_CORE is not set
10# CONFIG_AIO is not set
11CONFIG_SLAB=y
12CONFIG_MODULES=y
13CONFIG_MODULE_UNLOAD=y
14# CONFIG_BLK_DEV_BSG is not set
15# CONFIG_IOSCHED_DEADLINE is not set
16CONFIG_PREEMPT=y
17CONFIG_BF527=y
18CONFIG_BF_REV_0_2=y
19CONFIG_IRQ_TWI=7
20CONFIG_IRQ_PORTH_INTA=7
21CONFIG_IRQ_PORTH_INTB=7
22CONFIG_BFIN527_AD7160EVAL=y
23CONFIG_BF527_SPORT0_PORTF=y
24CONFIG_BF527_UART1_PORTG=y
25CONFIG_IRQ_USB_INT0=11
26CONFIG_IRQ_USB_INT1=11
27CONFIG_IRQ_USB_INT2=11
28CONFIG_IRQ_USB_DMA=11
29CONFIG_CMDLINE_BOOL=y
30CONFIG_CMDLINE="bootargs=root=/dev/mtdblock0 rw clkin_hz=24000000 earlyprintk=serial,uart0,57600 console=tty0 console=ttyBF0,57600"
31CONFIG_CLKIN_HZ=24000000
32CONFIG_HZ_300=y
33# CONFIG_CYCLES_CLOCKSOURCE is not set
34CONFIG_IP_CHECKSUM_L1=y
35CONFIG_SYSCALL_TAB_L1=y
36CONFIG_CPLB_SWITCH_TAB_L1=y
37CONFIG_BFIN_GPTIMERS=y
38CONFIG_C_CDPRIO=y
39CONFIG_BANK_1=0x5554
40CONFIG_BANK_3=0xFFC0
41CONFIG_BINFMT_FLAT=y
42CONFIG_BINFMT_ZFLAT=y
43CONFIG_NET=y
44CONFIG_UNIX=y
45# CONFIG_WIRELESS is not set
46CONFIG_BLK_DEV_LOOP=y
47CONFIG_BLK_DEV_RAM=y
48# CONFIG_MISC_DEVICES is not set
49# CONFIG_INPUT_MOUSEDEV is not set
50CONFIG_INPUT_EVDEV=y
51# CONFIG_INPUT_KEYBOARD is not set
52# CONFIG_INPUT_MOUSE is not set
53CONFIG_INPUT_TOUCHSCREEN=y
54CONFIG_TOUCHSCREEN_AD7160=y
55CONFIG_TOUCHSCREEN_AD7160_FW=y
56# CONFIG_SERIO is not set
57# CONFIG_BFIN_DMA_INTERFACE is not set
58# CONFIG_DEVKMEM is not set
59CONFIG_SERIAL_BFIN=y
60CONFIG_SERIAL_BFIN_CONSOLE=y
61CONFIG_SERIAL_BFIN_UART0=y
62# CONFIG_LEGACY_PTYS is not set
63# CONFIG_BFIN_OTP is not set
64# CONFIG_HW_RANDOM is not set
65CONFIG_I2C=y
66# CONFIG_I2C_HELPER_AUTO is not set
67CONFIG_I2C_ALGOBIT=y
68CONFIG_I2C_BLACKFIN_TWI=y
69CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=400
70CONFIG_SPI=y
71CONFIG_SPI_BFIN=y
72CONFIG_GPIOLIB=y
73CONFIG_GPIO_SYSFS=y
74# CONFIG_HWMON is not set
75CONFIG_FB=y
76CONFIG_FRAMEBUFFER_CONSOLE=y
77CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
78CONFIG_LOGO=y
79# CONFIG_LOGO_LINUX_MONO is not set
80# CONFIG_LOGO_LINUX_VGA16 is not set
81# CONFIG_LOGO_LINUX_CLUT224 is not set
82# CONFIG_LOGO_BLACKFIN_VGA16 is not set
83# CONFIG_HID_SUPPORT is not set
84CONFIG_USB_MUSB_HDRC=y
85CONFIG_USB_GADGET_MUSB_HDRC=y
86CONFIG_USB_GADGET=y
87CONFIG_USB_GADGET_VBUS_DRAW=500
88CONFIG_USB_G_SERIAL=y
89CONFIG_MMC=y
90CONFIG_MMC_SPI=y
91CONFIG_EXT2_FS=y
92# CONFIG_DNOTIFY is not set
93CONFIG_MSDOS_FS=y
94CONFIG_VFAT_FS=y
95CONFIG_NLS_CODEPAGE_437=y
96CONFIG_NLS_ISO8859_1=y
97CONFIG_DEBUG_KERNEL=y
98CONFIG_DETECT_HUNG_TASK=y
99# CONFIG_SCHED_DEBUG is not set
100# CONFIG_DEBUG_BUGVERBOSE is not set
101# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
102CONFIG_EARLY_PRINTK=y
103CONFIG_CPLB_INFO=y
104CONFIG_SECURITY=y
105CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/BF527-TLL6527M_defconfig b/arch/blackfin/configs/BF527-TLL6527M_defconfig
new file mode 100644
index 000000000000..92ded5edc86c
--- /dev/null
+++ b/arch/blackfin/configs/BF527-TLL6527M_defconfig
@@ -0,0 +1,180 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_LOCALVERSION="DEV_0-1_pre2010"
3CONFIG_SYSVIPC=y
4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_BLK_DEV_INITRD=y
8# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
9CONFIG_EMBEDDED=y
10# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_ELF_CORE is not set
12# CONFIG_FUTEX is not set
13# CONFIG_SIGNALFD is not set
14# CONFIG_TIMERFD is not set
15# CONFIG_EVENTFD is not set
16# CONFIG_AIO is not set
17CONFIG_SLAB=y
18CONFIG_MMAP_ALLOW_UNINITIALIZED=y
19CONFIG_MODULES=y
20CONFIG_MODULE_UNLOAD=y
21# CONFIG_LBDAF is not set
22# CONFIG_BLK_DEV_BSG is not set
23# CONFIG_IOSCHED_DEADLINE is not set
24CONFIG_PREEMPT_VOLUNTARY=y
25CONFIG_BF527=y
26CONFIG_BF_REV_0_2=y
27CONFIG_BFIN527_TLL6527M=y
28CONFIG_BF527_UART1_PORTG=y
29CONFIG_IRQ_USB_INT0=11
30CONFIG_IRQ_USB_INT1=11
31CONFIG_IRQ_USB_INT2=11
32CONFIG_IRQ_USB_DMA=11
33CONFIG_BOOT_LOAD=0x400000
34# CONFIG_CYCLES_CLOCKSOURCE is not set
35# CONFIG_SCHEDULE_L1 is not set
36# CONFIG_MEMSET_L1 is not set
37# CONFIG_MEMCPY_L1 is not set
38# CONFIG_SYS_BFIN_SPINLOCK_L1 is not set
39CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
40CONFIG_BFIN_GPTIMERS=y
41CONFIG_DMA_UNCACHED_2M=y
42CONFIG_C_CDPRIO=y
43CONFIG_BANK_0=0xFFC2
44CONFIG_BANK_1=0xFFC2
45CONFIG_BANK_2=0xFFC2
46CONFIG_BANK_3=0xFFC2
47CONFIG_BINFMT_FLAT=y
48CONFIG_BINFMT_ZFLAT=y
49CONFIG_NET=y
50CONFIG_PACKET=y
51CONFIG_UNIX=y
52CONFIG_INET=y
53CONFIG_IP_PNP=y
54# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
55# CONFIG_INET_XFRM_MODE_TUNNEL is not set
56# CONFIG_INET_XFRM_MODE_BEET is not set
57# CONFIG_INET_LRO is not set
58# CONFIG_INET_DIAG is not set
59# CONFIG_IPV6 is not set
60CONFIG_IRDA=m
61CONFIG_IRLAN=m
62CONFIG_IRCOMM=m
63CONFIG_IRTTY_SIR=m
64CONFIG_BFIN_SIR=m
65CONFIG_BFIN_SIR0=y
66# CONFIG_WIRELESS is not set
67CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
68# CONFIG_FW_LOADER is not set
69CONFIG_MTD=y
70CONFIG_MTD_CHAR=y
71CONFIG_MTD_BLOCK=y
72CONFIG_MTD_CFI=y
73CONFIG_MTD_CFI_INTELEXT=y
74CONFIG_MTD_RAM=y
75CONFIG_MTD_ROM=y
76CONFIG_MTD_COMPLEX_MAPPINGS=y
77CONFIG_MTD_GPIO_ADDR=y
78CONFIG_BLK_DEV_RAM=y
79CONFIG_SCSI=y
80# CONFIG_SCSI_PROC_FS is not set
81CONFIG_BLK_DEV_SD=y
82CONFIG_BLK_DEV_SR=m
83# CONFIG_SCSI_LOWLEVEL is not set
84CONFIG_NETDEVICES=y
85CONFIG_NET_ETHERNET=y
86CONFIG_BFIN_MAC=y
87# CONFIG_NETDEV_1000 is not set
88# CONFIG_NETDEV_10000 is not set
89# CONFIG_WLAN is not set
90# CONFIG_INPUT_MOUSEDEV is not set
91CONFIG_INPUT_EVDEV=y
92# CONFIG_INPUT_KEYBOARD is not set
93# CONFIG_INPUT_MOUSE is not set
94CONFIG_INPUT_TOUCHSCREEN=y
95CONFIG_TOUCHSCREEN_AD7879=m
96CONFIG_INPUT_MISC=y
97CONFIG_INPUT_AD714X=y
98CONFIG_INPUT_ADXL34X=y
99# CONFIG_SERIO is not set
100CONFIG_BFIN_PPI=m
101CONFIG_BFIN_SIMPLE_TIMER=m
102CONFIG_BFIN_SPORT=m
103# CONFIG_CONSOLE_TRANSLATIONS is not set
104# CONFIG_DEVKMEM is not set
105CONFIG_BFIN_JTAG_COMM=m
106CONFIG_SERIAL_BFIN=y
107CONFIG_SERIAL_BFIN_CONSOLE=y
108CONFIG_SERIAL_BFIN_UART1=y
109# CONFIG_LEGACY_PTYS is not set
110# CONFIG_HW_RANDOM is not set
111CONFIG_I2C_CHARDEV=y
112# CONFIG_I2C_HELPER_AUTO is not set
113CONFIG_I2C_SMBUS=y
114CONFIG_I2C_BLACKFIN_TWI=y
115CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
116CONFIG_GPIOLIB=y
117CONFIG_GPIO_SYSFS=y
118# CONFIG_HWMON is not set
119CONFIG_WATCHDOG=y
120CONFIG_BFIN_WDT=y
121CONFIG_MEDIA_SUPPORT=y
122CONFIG_VIDEO_DEV=y
123# CONFIG_MEDIA_TUNER_CUSTOMISE is not set
124CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
125CONFIG_VIDEO_BLACKFIN_CAM=m
126CONFIG_OV9655=y
127CONFIG_FB=y
128CONFIG_BACKLIGHT_LCD_SUPPORT=y
129CONFIG_FRAMEBUFFER_CONSOLE=y
130CONFIG_FONTS=y
131CONFIG_FONT_6x11=y
132CONFIG_LOGO=y
133# CONFIG_LOGO_LINUX_MONO is not set
134# CONFIG_LOGO_LINUX_VGA16 is not set
135# CONFIG_LOGO_LINUX_CLUT224 is not set
136# CONFIG_LOGO_BLACKFIN_VGA16 is not set
137CONFIG_SOUND=y
138CONFIG_SND=y
139CONFIG_SND_MIXER_OSS=y
140CONFIG_SND_PCM_OSS=y
141CONFIG_SND_SOC=y
142CONFIG_SND_BF5XX_I2S=y
143CONFIG_SND_BF5XX_SOC_SSM2602=y
144# CONFIG_HID_SUPPORT is not set
145# CONFIG_USB_SUPPORT is not set
146CONFIG_MMC=m
147CONFIG_RTC_CLASS=y
148CONFIG_RTC_DRV_BFIN=y
149CONFIG_EXT2_FS=y
150# CONFIG_DNOTIFY is not set
151CONFIG_ISO9660_FS=m
152CONFIG_JOLIET=y
153CONFIG_UDF_FS=m
154CONFIG_MSDOS_FS=y
155CONFIG_VFAT_FS=y
156CONFIG_JFFS2_FS=y
157CONFIG_NFS_FS=m
158CONFIG_NFS_V3=y
159# CONFIG_RPCSEC_GSS_KRB5 is not set
160CONFIG_NLS_CODEPAGE_437=m
161CONFIG_NLS_CODEPAGE_936=m
162CONFIG_NLS_ISO8859_1=m
163CONFIG_NLS_UTF8=m
164CONFIG_DEBUG_KERNEL=y
165CONFIG_DEBUG_SHIRQ=y
166CONFIG_DETECT_HUNG_TASK=y
167CONFIG_DEBUG_INFO=y
168# CONFIG_RCU_CPU_STALL_DETECTOR is not set
169# CONFIG_FTRACE is not set
170CONFIG_DEBUG_MMRS=y
171CONFIG_DEBUG_HWERR=y
172CONFIG_EXACT_HWERR=y
173CONFIG_DEBUG_DOUBLEFAULT=y
174CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
175CONFIG_EARLY_PRINTK=y
176CONFIG_CPLB_INFO=y
177CONFIG_SECURITY=y
178CONFIG_CRYPTO=y
179# CONFIG_CRYPTO_ANSI_CPRNG is not set
180CONFIG_CRC7=m
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild
index d9eb29e2555c..9e7c5379d3ff 100644
--- a/arch/blackfin/include/asm/Kbuild
+++ b/arch/blackfin/include/asm/Kbuild
@@ -1,4 +1,5 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2 2
3header-y += bfin_sport.h 3header-y += bfin_sport.h
4header-y += cachectl.h
4header-y += fixed_code.h 5header-y += fixed_code.h
diff --git a/arch/blackfin/include/asm/bfin5xx_spi.h b/arch/blackfin/include/asm/bfin5xx_spi.h
index ed4f8c6db0cd..0b5136e334b5 100644
--- a/arch/blackfin/include/asm/bfin5xx_spi.h
+++ b/arch/blackfin/include/asm/bfin5xx_spi.h
@@ -11,26 +11,17 @@
11 11
12#define MIN_SPI_BAUD_VAL 2 12#define MIN_SPI_BAUD_VAL 2
13 13
14#define SPI_READ 0
15#define SPI_WRITE 1
16
17#define SPI_CTRL_OFF 0x0
18#define SPI_FLAG_OFF 0x4
19#define SPI_STAT_OFF 0x8
20#define SPI_TXBUFF_OFF 0xc
21#define SPI_RXBUFF_OFF 0x10
22#define SPI_BAUD_OFF 0x14
23#define SPI_SHAW_OFF 0x18
24
25
26#define BIT_CTL_ENABLE 0x4000 14#define BIT_CTL_ENABLE 0x4000
27#define BIT_CTL_OPENDRAIN 0x2000 15#define BIT_CTL_OPENDRAIN 0x2000
28#define BIT_CTL_MASTER 0x1000 16#define BIT_CTL_MASTER 0x1000
29#define BIT_CTL_POLAR 0x0800 17#define BIT_CTL_CPOL 0x0800
30#define BIT_CTL_PHASE 0x0400 18#define BIT_CTL_CPHA 0x0400
31#define BIT_CTL_BITORDER 0x0200 19#define BIT_CTL_LSBF 0x0200
32#define BIT_CTL_WORDSIZE 0x0100 20#define BIT_CTL_WORDSIZE 0x0100
33#define BIT_CTL_MISOENABLE 0x0020 21#define BIT_CTL_EMISO 0x0020
22#define BIT_CTL_PSSE 0x0010
23#define BIT_CTL_GM 0x0008
24#define BIT_CTL_SZ 0x0004
34#define BIT_CTL_RXMOD 0x0000 25#define BIT_CTL_RXMOD 0x0000
35#define BIT_CTL_TXMOD 0x0001 26#define BIT_CTL_TXMOD 0x0001
36#define BIT_CTL_TIMOD_DMA_TX 0x0003 27#define BIT_CTL_TIMOD_DMA_TX 0x0003
@@ -50,61 +41,26 @@
50#define BIT_STU_SENDOVER 0x0001 41#define BIT_STU_SENDOVER 0x0001
51#define BIT_STU_RECVFULL 0x0020 42#define BIT_STU_RECVFULL 0x0020
52 43
53#define CFG_SPI_ENABLE 1 44/*
54#define CFG_SPI_DISABLE 0 45 * All Blackfin system MMRs are padded to 32bits even if the register
55 46 * itself is only 16bits. So use a helper macro to streamline this.
56#define CFG_SPI_OUTENABLE 1 47 */
57#define CFG_SPI_OUTDISABLE 0 48#define __BFP(m) u16 m; u16 __pad_##m
58
59#define CFG_SPI_ACTLOW 1
60#define CFG_SPI_ACTHIGH 0
61
62#define CFG_SPI_PHASESTART 1
63#define CFG_SPI_PHASEMID 0
64
65#define CFG_SPI_MASTER 1
66#define CFG_SPI_SLAVE 0
67
68#define CFG_SPI_SENELAST 0
69#define CFG_SPI_SENDZERO 1
70
71#define CFG_SPI_RCVFLUSH 1
72#define CFG_SPI_RCVDISCARD 0
73
74#define CFG_SPI_LSBFIRST 1
75#define CFG_SPI_MSBFIRST 0
76
77#define CFG_SPI_WORDSIZE16 1
78#define CFG_SPI_WORDSIZE8 0
79
80#define CFG_SPI_MISOENABLE 1
81#define CFG_SPI_MISODISABLE 0
82
83#define CFG_SPI_READ 0x00
84#define CFG_SPI_WRITE 0x01
85#define CFG_SPI_DMAREAD 0x02
86#define CFG_SPI_DMAWRITE 0x03
87
88#define CFG_SPI_CSCLEARALL 0
89#define CFG_SPI_CHIPSEL1 1
90#define CFG_SPI_CHIPSEL2 2
91#define CFG_SPI_CHIPSEL3 3
92#define CFG_SPI_CHIPSEL4 4
93#define CFG_SPI_CHIPSEL5 5
94#define CFG_SPI_CHIPSEL6 6
95#define CFG_SPI_CHIPSEL7 7
96 49
97#define CFG_SPI_CS1VALUE 1 50/*
98#define CFG_SPI_CS2VALUE 2 51 * bfin spi registers layout
99#define CFG_SPI_CS3VALUE 3 52 */
100#define CFG_SPI_CS4VALUE 4 53struct bfin_spi_regs {
101#define CFG_SPI_CS5VALUE 5 54 __BFP(ctl);
102#define CFG_SPI_CS6VALUE 6 55 __BFP(flg);
103#define CFG_SPI_CS7VALUE 7 56 __BFP(stat);
57 __BFP(tdbr);
58 __BFP(rdbr);
59 __BFP(baud);
60 __BFP(shadow);
61};
104 62
105#define CMD_SPI_SET_BAUDRATE 2 63#define MAX_CTRL_CS 8 /* cs in spi controller */
106#define CMD_SPI_GET_SYSTEMCLOCK 25
107#define CMD_SPI_SET_WRITECONTINUOUS 26
108 64
109/* device.platform_data for SSP controller devices */ 65/* device.platform_data for SSP controller devices */
110struct bfin5xx_spi_master { 66struct bfin5xx_spi_master {
@@ -120,9 +76,7 @@ struct bfin5xx_spi_chip {
120 u16 ctl_reg; 76 u16 ctl_reg;
121 u8 enable_dma; 77 u8 enable_dma;
122 u8 bits_per_word; 78 u8 bits_per_word;
123 u8 cs_change_per_word;
124 u16 cs_chg_udelay; /* Some devices require 16-bit delays */ 79 u16 cs_chg_udelay; /* Some devices require 16-bit delays */
125 u32 cs_gpio;
126 /* Value to send if no TX value is supplied, usually 0x0 or 0xFFFF */ 80 /* Value to send if no TX value is supplied, usually 0x0 or 0xFFFF */
127 u16 idle_tx_val; 81 u16 idle_tx_val;
128 u8 pio_interrupt; /* Enable spi data irq */ 82 u8 pio_interrupt; /* Enable spi data irq */
diff --git a/arch/blackfin/include/asm/bfin_can.h b/arch/blackfin/include/asm/bfin_can.h
index eec0076a385b..b1492e0bcabb 100644
--- a/arch/blackfin/include/asm/bfin_can.h
+++ b/arch/blackfin/include/asm/bfin_can.h
@@ -34,6 +34,7 @@ struct bfin_can_mask_regs {
34}; 34};
35 35
36struct bfin_can_channel_regs { 36struct bfin_can_channel_regs {
37 /* data[0,2,4,6] -> data{0,1,2,3} while data[1,3,5,7] is padding */
37 u16 data[8]; 38 u16 data[8];
38 __BFP(dlc); 39 __BFP(dlc);
39 __BFP(tsv); 40 __BFP(tsv);
@@ -83,16 +84,18 @@ struct bfin_can_regs {
83 __BFP(gif); /* offset 0x9c */ 84 __BFP(gif); /* offset 0x9c */
84 __BFP(control); /* offset 0xa0 */ 85 __BFP(control); /* offset 0xa0 */
85 __BFP(intr); /* offset 0xa4 */ 86 __BFP(intr); /* offset 0xa4 */
86 u32 __pad3[1]; 87 __BFP(version); /* offset 0xa8 */
87 __BFP(mbtd); /* offset 0xac */ 88 __BFP(mbtd); /* offset 0xac */
88 __BFP(ewr); /* offset 0xb0 */ 89 __BFP(ewr); /* offset 0xb0 */
89 __BFP(esr); /* offset 0xb4 */ 90 __BFP(esr); /* offset 0xb4 */
90 u32 __pad4[2]; 91 u32 __pad3[2];
91 __BFP(ucreg); /* offset 0xc0 */ 92 __BFP(ucreg); /* offset 0xc0 */
92 __BFP(uccnt); /* offset 0xc4 */ 93 __BFP(uccnt); /* offset 0xc4 */
93 __BFP(ucrc); /* offset 0xc8 */ 94 __BFP(ucrc); /* offset 0xc8 */
94 __BFP(uccnf); /* offset 0xcc */ 95 __BFP(uccnf); /* offset 0xcc */
95 u32 __pad5[12]; 96 u32 __pad4[1];
97 __BFP(version2); /* offset 0xd4 */
98 u32 __pad5[10];
96 99
97 /* 100 /*
98 * channel(mailbox) mask and message registers 101 * channel(mailbox) mask and message registers
diff --git a/arch/blackfin/include/asm/bfin_ppi.h b/arch/blackfin/include/asm/bfin_ppi.h
new file mode 100644
index 000000000000..003900886f97
--- /dev/null
+++ b/arch/blackfin/include/asm/bfin_ppi.h
@@ -0,0 +1,51 @@
1/*
2 * bfin_ppi.h - interface to Blackfin PPIs
3 *
4 * Copyright 2005-2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __ASM_BFIN_PPI_H__
10#define __ASM_BFIN_PPI_H__
11
12#include <linux/types.h>
13
14/*
15 * All Blackfin system MMRs are padded to 32bits even if the register
16 * itself is only 16bits. So use a helper macro to streamline this.
17 */
18#define __BFP(m) u16 m; u16 __pad_##m
19
20/*
21 * bfin ppi registers layout
22 */
23struct bfin_ppi_regs {
24 __BFP(control);
25 __BFP(status);
26 __BFP(count);
27 __BFP(delay);
28 __BFP(frame);
29};
30
31/*
32 * bfin eppi registers layout
33 */
34struct bfin_eppi_regs {
35 __BFP(status);
36 __BFP(hcount);
37 __BFP(hdelay);
38 __BFP(vcount);
39 __BFP(vdelay);
40 __BFP(frame);
41 __BFP(line);
42 __BFP(clkdiv);
43 u32 control;
44 u32 fs1w_hbl;
45 u32 fs1p_avpl;
46 u32 fs2w_lvb;
47 u32 fs2p_lavf;
48 u32 clip;
49};
50
51#endif
diff --git a/arch/blackfin/include/asm/cachectl.h b/arch/blackfin/include/asm/cachectl.h
new file mode 100644
index 000000000000..03255df6c1ea
--- /dev/null
+++ b/arch/blackfin/include/asm/cachectl.h
@@ -0,0 +1,20 @@
1/*
2 * based on the mips/cachectl.h
3 *
4 * Copyright 2010 Analog Devices Inc.
5 * Copyright (C) 1994, 1995, 1996 by Ralf Baechle
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10#ifndef _ASM_CACHECTL
11#define _ASM_CACHECTL
12
13/*
14 * Options for cacheflush system call
15 */
16#define ICACHE (1<<0) /* flush instruction cache */
17#define DCACHE (1<<1) /* writeback and flush data cache */
18#define BCACHE (ICACHE|DCACHE) /* flush both caches */
19
20#endif /* _ASM_CACHECTL */
diff --git a/arch/blackfin/include/asm/cdef_LPBlackfin.h b/arch/blackfin/include/asm/cdef_LPBlackfin.h
index 6c39d94b44d0..a1f6817687e8 100644
--- a/arch/blackfin/include/asm/cdef_LPBlackfin.h
+++ b/arch/blackfin/include/asm/cdef_LPBlackfin.h
@@ -172,16 +172,19 @@
172#define bfin_write_ICPLB_DATA14(val) bfin_write32(ICPLB_DATA14,val) 172#define bfin_write_ICPLB_DATA14(val) bfin_write32(ICPLB_DATA14,val)
173#define bfin_read_ICPLB_DATA15() bfin_read32(ICPLB_DATA15) 173#define bfin_read_ICPLB_DATA15() bfin_read32(ICPLB_DATA15)
174#define bfin_write_ICPLB_DATA15(val) bfin_write32(ICPLB_DATA15,val) 174#define bfin_write_ICPLB_DATA15(val) bfin_write32(ICPLB_DATA15,val)
175#define bfin_read_ITEST_COMMAND() bfin_read32(ITEST_COMMAND)
176#define bfin_write_ITEST_COMMAND(val) bfin_write32(ITEST_COMMAND,val) 175#define bfin_write_ITEST_COMMAND(val) bfin_write32(ITEST_COMMAND,val)
177#if 0 176#if 0
178#define ITEST_INDEX 0xFFE01304 /* Instruction Test Index Register */ 177#define ITEST_INDEX 0xFFE01304 /* Instruction Test Index Register */
179#endif 178#endif
180#define bfin_read_ITEST_DATA0() bfin_read32(ITEST_DATA0)
181#define bfin_write_ITEST_DATA0(val) bfin_write32(ITEST_DATA0,val) 179#define bfin_write_ITEST_DATA0(val) bfin_write32(ITEST_DATA0,val)
182#define bfin_read_ITEST_DATA1() bfin_read32(ITEST_DATA1)
183#define bfin_write_ITEST_DATA1(val) bfin_write32(ITEST_DATA1,val) 180#define bfin_write_ITEST_DATA1(val) bfin_write32(ITEST_DATA1,val)
184 181
182#if ANOMALY_05000481
183#define bfin_read_ITEST_COMMAND() bfin_read32(ITEST_COMMAND)
184#define bfin_read_ITEST_DATA0() bfin_read32(ITEST_DATA0)
185#define bfin_read_ITEST_DATA1() bfin_read32(ITEST_DATA1)
186#endif
187
185/* Event/Interrupt Registers*/ 188/* Event/Interrupt Registers*/
186 189
187#define bfin_read_EVT0() bfin_read32(EVT0) 190#define bfin_read_EVT0() bfin_read32(EVT0)
diff --git a/arch/blackfin/include/asm/ipipe.h b/arch/blackfin/include/asm/ipipe.h
index d3b40449ca0e..40f94a704c02 100644
--- a/arch/blackfin/include/asm/ipipe.h
+++ b/arch/blackfin/include/asm/ipipe.h
@@ -49,7 +49,7 @@
49#define prepare_arch_switch(next) \ 49#define prepare_arch_switch(next) \
50do { \ 50do { \
51 ipipe_schedule_notify(current, next); \ 51 ipipe_schedule_notify(current, next); \
52 local_irq_disable_hw(); \ 52 hard_local_irq_disable(); \
53} while (0) 53} while (0)
54 54
55#define task_hijacked(p) \ 55#define task_hijacked(p) \
@@ -57,7 +57,7 @@ do { \
57 int __x__ = __ipipe_root_domain_p; \ 57 int __x__ = __ipipe_root_domain_p; \
58 __clear_bit(IPIPE_SYNC_FLAG, &ipipe_root_cpudom_var(status)); \ 58 __clear_bit(IPIPE_SYNC_FLAG, &ipipe_root_cpudom_var(status)); \
59 if (__x__) \ 59 if (__x__) \
60 local_irq_enable_hw(); \ 60 hard_local_irq_enable(); \
61 !__x__; \ 61 !__x__; \
62 }) 62 })
63 63
@@ -167,7 +167,7 @@ static inline unsigned long __ipipe_ffnz(unsigned long ul)
167#define __ipipe_run_isr(ipd, irq) \ 167#define __ipipe_run_isr(ipd, irq) \
168 do { \ 168 do { \
169 if (!__ipipe_pipeline_head_p(ipd)) \ 169 if (!__ipipe_pipeline_head_p(ipd)) \
170 local_irq_enable_hw(); \ 170 hard_local_irq_enable(); \
171 if (ipd == ipipe_root_domain) { \ 171 if (ipd == ipipe_root_domain) { \
172 if (unlikely(ipipe_virtual_irq_p(irq))) { \ 172 if (unlikely(ipipe_virtual_irq_p(irq))) { \
173 irq_enter(); \ 173 irq_enter(); \
@@ -183,7 +183,7 @@ static inline unsigned long __ipipe_ffnz(unsigned long ul)
183 __ipipe_run_irqtail(); \ 183 __ipipe_run_irqtail(); \
184 __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \ 184 __set_bit(IPIPE_SYNC_FLAG, &ipipe_cpudom_var(ipd, status)); \
185 } \ 185 } \
186 local_irq_disable_hw(); \ 186 hard_local_irq_disable(); \
187 } while (0) 187 } while (0)
188 188
189#define __ipipe_syscall_watched_p(p, sc) \ 189#define __ipipe_syscall_watched_p(p, sc) \
diff --git a/arch/blackfin/include/asm/irqflags.h b/arch/blackfin/include/asm/irqflags.h
index 813a1af3e865..41c4d70544ef 100644
--- a/arch/blackfin/include/asm/irqflags.h
+++ b/arch/blackfin/include/asm/irqflags.h
@@ -8,6 +8,8 @@
8#ifndef __ASM_BFIN_IRQFLAGS_H__ 8#ifndef __ASM_BFIN_IRQFLAGS_H__
9#define __ASM_BFIN_IRQFLAGS_H__ 9#define __ASM_BFIN_IRQFLAGS_H__
10 10
11#include <mach/blackfin.h>
12
11#ifdef CONFIG_SMP 13#ifdef CONFIG_SMP
12# include <asm/pda.h> 14# include <asm/pda.h>
13# include <asm/processor.h> 15# include <asm/processor.h>
@@ -31,54 +33,108 @@ static inline unsigned long bfin_cli(void)
31 return flags; 33 return flags;
32} 34}
33 35
34#ifdef CONFIG_IPIPE
35
36#include <linux/compiler.h>
37#include <linux/ipipe_base.h>
38#include <linux/ipipe_trace.h>
39
40#ifdef CONFIG_DEBUG_HWERR 36#ifdef CONFIG_DEBUG_HWERR
41# define bfin_no_irqs 0x3f 37# define bfin_no_irqs 0x3f
42#else 38#else
43# define bfin_no_irqs 0x1f 39# define bfin_no_irqs 0x1f
44#endif 40#endif
45 41
46#define raw_local_irq_disable() \ 42/*****************************************************************************/
47 do { \ 43/*
48 ipipe_check_context(ipipe_root_domain); \ 44 * Hard, untraced CPU interrupt flag manipulation and access.
49 __ipipe_stall_root(); \ 45 */
50 barrier(); \ 46static inline void __hard_local_irq_disable(void)
51 } while (0) 47{
48 bfin_cli();
49}
50
51static inline void __hard_local_irq_enable(void)
52{
53 bfin_sti(bfin_irq_flags);
54}
55
56static inline unsigned long hard_local_save_flags(void)
57{
58 return bfin_read_IMASK();
59}
52 60
53#define raw_local_irq_enable() \ 61static inline unsigned long __hard_local_irq_save(void)
54 do { \ 62{
55 barrier(); \ 63 unsigned long flags;
56 ipipe_check_context(ipipe_root_domain); \ 64 flags = bfin_cli();
57 __ipipe_unstall_root(); \ 65#ifdef CONFIG_DEBUG_HWERR
58 } while (0) 66 bfin_sti(0x3f);
67#endif
68 return flags;
69}
70
71static inline int hard_irqs_disabled_flags(unsigned long flags)
72{
73 return (flags & ~0x3f) == 0;
74}
75
76static inline int hard_irqs_disabled(void)
77{
78 unsigned long flags = hard_local_save_flags();
79 return hard_irqs_disabled_flags(flags);
80}
81
82static inline void __hard_local_irq_restore(unsigned long flags)
83{
84 if (!hard_irqs_disabled_flags(flags))
85 __hard_local_irq_enable();
86}
87
88/*****************************************************************************/
89/*
90 * Interrupt pipe handling.
91 */
92#ifdef CONFIG_IPIPE
93
94#include <linux/compiler.h>
95#include <linux/ipipe_base.h>
96#include <linux/ipipe_trace.h>
97
98/*
99 * Interrupt pipe interface to linux/irqflags.h.
100 */
101static inline void arch_local_irq_disable(void)
102{
103 ipipe_check_context(ipipe_root_domain);
104 __ipipe_stall_root();
105 barrier();
106}
59 107
60#define raw_local_save_flags_ptr(x) \ 108static inline void arch_local_irq_enable(void)
61 do { \ 109{
62 *(x) = __ipipe_test_root() ? bfin_no_irqs : bfin_irq_flags; \ 110 barrier();
63 } while (0) 111 ipipe_check_context(ipipe_root_domain);
112 __ipipe_unstall_root();
113}
64 114
65#define raw_local_save_flags(x) raw_local_save_flags_ptr(&(x)) 115static inline unsigned long arch_local_save_flags(void)
116{
117 return __ipipe_test_root() ? bfin_no_irqs : bfin_irq_flags;
118}
66 119
67#define raw_irqs_disabled_flags(x) ((x) == bfin_no_irqs) 120static inline int arch_irqs_disabled_flags(unsigned long flags)
121{
122 return flags == bfin_no_irqs;
123}
68 124
69#define raw_local_irq_save_ptr(x) \ 125static inline void arch_local_irq_save_ptr(unsigned long *_flags)
70 do { \ 126{
71 *(x) = __ipipe_test_and_stall_root() ? bfin_no_irqs : bfin_irq_flags; \ 127 x = __ipipe_test_and_stall_root() ? bfin_no_irqs : bfin_irq_flags;
72 barrier(); \ 128 barrier();
73 } while (0) 129}
74 130
75#define raw_local_irq_save(x) \ 131static inline unsigned long arch_local_irq_save(void)
76 do { \ 132{
77 ipipe_check_context(ipipe_root_domain); \ 133 ipipe_check_context(ipipe_root_domain);
78 raw_local_irq_save_ptr(&(x)); \ 134 return __hard_local_irq_save();
79 } while (0) 135}
80 136
81static inline unsigned long raw_mangle_irq_bits(int virt, unsigned long real) 137static inline unsigned long arch_mangle_irq_bits(int virt, unsigned long real)
82{ 138{
83 /* 139 /*
84 * Merge virtual and real interrupt mask bits into a single 140 * Merge virtual and real interrupt mask bits into a single
@@ -87,130 +143,79 @@ static inline unsigned long raw_mangle_irq_bits(int virt, unsigned long real)
87 return (real & ~(1 << 31)) | ((virt != 0) << 31); 143 return (real & ~(1 << 31)) | ((virt != 0) << 31);
88} 144}
89 145
90static inline int raw_demangle_irq_bits(unsigned long *x) 146static inline int arch_demangle_irq_bits(unsigned long *x)
91{ 147{
92 int virt = (*x & (1 << 31)) != 0; 148 int virt = (*x & (1 << 31)) != 0;
93 *x &= ~(1L << 31); 149 *x &= ~(1L << 31);
94 return virt; 150 return virt;
95} 151}
96 152
97static inline void local_irq_disable_hw_notrace(void) 153/*
154 * Interface to various arch routines that may be traced.
155 */
156#ifdef CONFIG_IPIPE_TRACE_IRQSOFF
157static inline void hard_local_irq_disable(void)
98{ 158{
99 bfin_cli(); 159 if (!hard_irqs_disabled()) {
160 __hard_local_irq_disable();
161 ipipe_trace_begin(0x80000000);
162 }
100} 163}
101 164
102static inline void local_irq_enable_hw_notrace(void) 165static inline void hard_local_irq_enable(void)
103{ 166{
104 bfin_sti(bfin_irq_flags); 167 if (hard_irqs_disabled()) {
168 ipipe_trace_end(0x80000000);
169 __hard_local_irq_enable();
170 }
105} 171}
106 172
107#define local_save_flags_hw(flags) \ 173static inline unsigned long hard_local_irq_save(void)
108 do { \
109 (flags) = bfin_read_IMASK(); \
110 } while (0)
111
112#define irqs_disabled_flags_hw(flags) (((flags) & ~0x3f) == 0)
113
114#define irqs_disabled_hw() \
115 ({ \
116 unsigned long flags; \
117 local_save_flags_hw(flags); \
118 irqs_disabled_flags_hw(flags); \
119 })
120
121static inline void local_irq_save_ptr_hw(unsigned long *flags)
122{ 174{
123 *flags = bfin_cli(); 175 unsigned long flags = hard_local_save_flags();
124#ifdef CONFIG_DEBUG_HWERR 176 if (!hard_irqs_disabled_flags(flags)) {
125 bfin_sti(0x3f); 177 __hard_local_irq_disable();
126#endif 178 ipipe_trace_begin(0x80000001);
179 }
180 return flags;
127} 181}
128 182
129#define local_irq_save_hw_notrace(flags) \ 183static inline void hard_local_irq_restore(unsigned long flags)
130 do { \
131 local_irq_save_ptr_hw(&(flags)); \
132 } while (0)
133
134static inline void local_irq_restore_hw_notrace(unsigned long flags)
135{ 184{
136 if (!irqs_disabled_flags_hw(flags)) 185 if (!hard_irqs_disabled_flags(flags)) {
137 local_irq_enable_hw_notrace(); 186 ipipe_trace_end(0x80000001);
187 __hard_local_irq_enable();
188 }
138} 189}
139 190
140#ifdef CONFIG_IPIPE_TRACE_IRQSOFF
141# define local_irq_disable_hw() \
142 do { \
143 if (!irqs_disabled_hw()) { \
144 local_irq_disable_hw_notrace(); \
145 ipipe_trace_begin(0x80000000); \
146 } \
147 } while (0)
148# define local_irq_enable_hw() \
149 do { \
150 if (irqs_disabled_hw()) { \
151 ipipe_trace_end(0x80000000); \
152 local_irq_enable_hw_notrace(); \
153 } \
154 } while (0)
155# define local_irq_save_hw(flags) \
156 do { \
157 local_save_flags_hw(flags); \
158 if (!irqs_disabled_flags_hw(flags)) { \
159 local_irq_disable_hw_notrace(); \
160 ipipe_trace_begin(0x80000001); \
161 } \
162 } while (0)
163# define local_irq_restore_hw(flags) \
164 do { \
165 if (!irqs_disabled_flags_hw(flags)) { \
166 ipipe_trace_end(0x80000001); \
167 local_irq_enable_hw_notrace(); \
168 } \
169 } while (0)
170#else /* !CONFIG_IPIPE_TRACE_IRQSOFF */ 191#else /* !CONFIG_IPIPE_TRACE_IRQSOFF */
171# define local_irq_disable_hw() local_irq_disable_hw_notrace() 192# define hard_local_irq_disable() __hard_local_irq_disable()
172# define local_irq_enable_hw() local_irq_enable_hw_notrace() 193# define hard_local_irq_enable() __hard_local_irq_enable()
173# define local_irq_save_hw(flags) local_irq_save_hw_notrace(flags) 194# define hard_local_irq_save() __hard_local_irq_save()
174# define local_irq_restore_hw(flags) local_irq_restore_hw_notrace(flags) 195# define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
175#endif /* !CONFIG_IPIPE_TRACE_IRQSOFF */ 196#endif /* !CONFIG_IPIPE_TRACE_IRQSOFF */
176 197
177#else /* CONFIG_IPIPE */ 198#else /* CONFIG_IPIPE */
178 199
179static inline void raw_local_irq_disable(void) 200/*
180{ 201 * Direct interface to linux/irqflags.h.
181 bfin_cli(); 202 */
182} 203#define arch_local_save_flags() hard_local_save_flags()
183static inline void raw_local_irq_enable(void) 204#define arch_local_irq_save(flags) __hard_local_irq_save()
184{ 205#define arch_local_irq_restore(flags) __hard_local_irq_restore(flags)
185 bfin_sti(bfin_irq_flags); 206#define arch_local_irq_enable() __hard_local_irq_enable()
186} 207#define arch_local_irq_disable() __hard_local_irq_disable()
187 208#define arch_irqs_disabled_flags(flags) hard_irqs_disabled_flags(flags)
188#define raw_local_save_flags(flags) do { (flags) = bfin_read_IMASK(); } while (0) 209#define arch_irqs_disabled() hard_irqs_disabled()
189
190#define raw_irqs_disabled_flags(flags) (((flags) & ~0x3f) == 0)
191 210
192static inline unsigned long __raw_local_irq_save(void) 211/*
193{ 212 * Interface to various arch routines that may be traced.
194 unsigned long flags = bfin_cli(); 213 */
195#ifdef CONFIG_DEBUG_HWERR 214#define hard_local_irq_save() __hard_local_irq_save()
196 bfin_sti(0x3f); 215#define hard_local_irq_restore(flags) __hard_local_irq_restore(flags)
197#endif 216#define hard_local_irq_enable() __hard_local_irq_enable()
198 return flags; 217#define hard_local_irq_disable() __hard_local_irq_disable()
199}
200#define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0)
201 218
202#define local_irq_save_hw(flags) raw_local_irq_save(flags)
203#define local_irq_restore_hw(flags) raw_local_irq_restore(flags)
204#define local_irq_enable_hw() raw_local_irq_enable()
205#define local_irq_disable_hw() raw_local_irq_disable()
206#define irqs_disabled_hw() irqs_disabled()
207 219
208#endif /* !CONFIG_IPIPE */ 220#endif /* !CONFIG_IPIPE */
209
210static inline void raw_local_irq_restore(unsigned long flags)
211{
212 if (!raw_irqs_disabled_flags(flags))
213 raw_local_irq_enable();
214}
215
216#endif 221#endif
diff --git a/arch/blackfin/include/asm/mmu_context.h b/arch/blackfin/include/asm/mmu_context.h
index e1a9b4624f91..3828c70e7a2e 100644
--- a/arch/blackfin/include/asm/mmu_context.h
+++ b/arch/blackfin/include/asm/mmu_context.h
@@ -97,8 +97,8 @@ static inline void __switch_mm(struct mm_struct *prev_mm, struct mm_struct *next
97} 97}
98 98
99#ifdef CONFIG_IPIPE 99#ifdef CONFIG_IPIPE
100#define lock_mm_switch(flags) local_irq_save_hw_cond(flags) 100#define lock_mm_switch(flags) flags = hard_local_irq_save_cond()
101#define unlock_mm_switch(flags) local_irq_restore_hw_cond(flags) 101#define unlock_mm_switch(flags) hard_local_irq_restore_cond(flags)
102#else 102#else
103#define lock_mm_switch(flags) do { (void)(flags); } while (0) 103#define lock_mm_switch(flags) do { (void)(flags); } while (0)
104#define unlock_mm_switch(flags) do { (void)(flags); } while (0) 104#define unlock_mm_switch(flags) do { (void)(flags); } while (0)
@@ -205,9 +205,9 @@ static inline void destroy_context(struct mm_struct *mm)
205} 205}
206 206
207#define ipipe_mm_switch_protect(flags) \ 207#define ipipe_mm_switch_protect(flags) \
208 local_irq_save_hw_cond(flags) 208 flags = hard_local_irq_save_cond()
209 209
210#define ipipe_mm_switch_unprotect(flags) \ 210#define ipipe_mm_switch_unprotect(flags) \
211 local_irq_restore_hw_cond(flags) 211 hard_local_irq_restore_cond(flags)
212 212
213#endif 213#endif
diff --git a/arch/blackfin/include/asm/ptrace.h b/arch/blackfin/include/asm/ptrace.h
index aaa1c6c2bc19..832d7c009a2c 100644
--- a/arch/blackfin/include/asm/ptrace.h
+++ b/arch/blackfin/include/asm/ptrace.h
@@ -113,6 +113,9 @@ extern void user_disable_single_step(struct task_struct *child);
113/* common code demands this function */ 113/* common code demands this function */
114#define ptrace_disable(child) user_disable_single_step(child) 114#define ptrace_disable(child) user_disable_single_step(child)
115 115
116extern int is_user_addr_valid(struct task_struct *child,
117 unsigned long start, unsigned long len);
118
116/* 119/*
117 * Get the address of the live pt_regs for the specified task. 120 * Get the address of the live pt_regs for the specified task.
118 * These are saved onto the top kernel stack when the process 121 * These are saved onto the top kernel stack when the process
diff --git a/arch/blackfin/include/asm/serial.h b/arch/blackfin/include/asm/serial.h
index 94a4a12e3bf2..a0cb0caff152 100644
--- a/arch/blackfin/include/asm/serial.h
+++ b/arch/blackfin/include/asm/serial.h
@@ -1,2 +1 @@
1#include <asm-generic/serial.h> #include <asm-generic/serial.h>
2#define SERIAL_EXTRA_IRQ_FLAGS IRQF_TRIGGER_HIGH
diff --git a/arch/blackfin/include/asm/system.h b/arch/blackfin/include/asm/system.h
index dde19b1d25f5..19e2c7c3e63a 100644
--- a/arch/blackfin/include/asm/system.h
+++ b/arch/blackfin/include/asm/system.h
@@ -117,7 +117,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
117 unsigned long tmp = 0; 117 unsigned long tmp = 0;
118 unsigned long flags; 118 unsigned long flags;
119 119
120 local_irq_save_hw(flags); 120 flags = hard_local_irq_save();
121 121
122 switch (size) { 122 switch (size) {
123 case 1: 123 case 1:
@@ -139,7 +139,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
139 : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory"); 139 : "=&d" (tmp) : "d" (x), "m" (*__xg(ptr)) : "memory");
140 break; 140 break;
141 } 141 }
142 local_irq_restore_hw(flags); 142 hard_local_irq_restore(flags);
143 return tmp; 143 return tmp;
144} 144}
145 145
diff --git a/arch/blackfin/include/asm/unistd.h b/arch/blackfin/include/asm/unistd.h
index 14fcd254b185..928ae975b87e 100644
--- a/arch/blackfin/include/asm/unistd.h
+++ b/arch/blackfin/include/asm/unistd.h
@@ -392,8 +392,9 @@
392#define __NR_fanotify_init 371 392#define __NR_fanotify_init 371
393#define __NR_fanotify_mark 372 393#define __NR_fanotify_mark 372
394#define __NR_prlimit64 373 394#define __NR_prlimit64 373
395#define __NR_cacheflush 374
395 396
396#define __NR_syscall 374 397#define __NR_syscall 375
397#define NR_syscalls __NR_syscall 398#define NR_syscalls __NR_syscall
398 399
399/* Old optional stuff no one actually uses */ 400/* Old optional stuff no one actually uses */
diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index dc07ed08b37f..170cf90735ba 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * GPIO Abstraction Layer 2 * GPIO Abstraction Layer
3 * 3 *
4 * Copyright 2006-2009 Analog Devices Inc. 4 * Copyright 2006-2010 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later 6 * Licensed under the GPL-2 or later
7 */ 7 */
@@ -215,82 +215,91 @@ static void port_setup(unsigned gpio, unsigned short usage)
215} 215}
216 216
217#ifdef BF537_FAMILY 217#ifdef BF537_FAMILY
218static struct { 218static const s8 port_mux[] = {
219 unsigned short res; 219 [GPIO_PF0] = 3,
220 unsigned short offset; 220 [GPIO_PF1] = 3,
221} port_mux_lut[] = { 221 [GPIO_PF2] = 4,
222 {.res = P_PPI0_D13, .offset = 11}, 222 [GPIO_PF3] = 4,
223 {.res = P_PPI0_D14, .offset = 11}, 223 [GPIO_PF4] = 5,
224 {.res = P_PPI0_D15, .offset = 11}, 224 [GPIO_PF5] = 6,
225 {.res = P_SPORT1_TFS, .offset = 11}, 225 [GPIO_PF6] = 7,
226 {.res = P_SPORT1_TSCLK, .offset = 11}, 226 [GPIO_PF7] = 8,
227 {.res = P_SPORT1_DTPRI, .offset = 11}, 227 [GPIO_PF8 ... GPIO_PF15] = -1,
228 {.res = P_PPI0_D10, .offset = 10}, 228 [GPIO_PG0 ... GPIO_PG7] = -1,
229 {.res = P_PPI0_D11, .offset = 10}, 229 [GPIO_PG8] = 9,
230 {.res = P_PPI0_D12, .offset = 10}, 230 [GPIO_PG9] = 9,
231 {.res = P_SPORT1_RSCLK, .offset = 10}, 231 [GPIO_PG10] = 10,
232 {.res = P_SPORT1_RFS, .offset = 10}, 232 [GPIO_PG11] = 10,
233 {.res = P_SPORT1_DRPRI, .offset = 10}, 233 [GPIO_PG12] = 10,
234 {.res = P_PPI0_D8, .offset = 9}, 234 [GPIO_PG13] = 11,
235 {.res = P_PPI0_D9, .offset = 9}, 235 [GPIO_PG14] = 11,
236 {.res = P_SPORT1_DRSEC, .offset = 9}, 236 [GPIO_PG15] = 11,
237 {.res = P_SPORT1_DTSEC, .offset = 9}, 237 [GPIO_PH0 ... GPIO_PH15] = -1,
238 {.res = P_TMR2, .offset = 8}, 238 [PORT_PJ0 ... PORT_PJ3] = -1,
239 {.res = P_PPI0_FS3, .offset = 8}, 239 [PORT_PJ4] = 1,
240 {.res = P_TMR3, .offset = 7}, 240 [PORT_PJ5] = 1,
241 {.res = P_SPI0_SSEL4, .offset = 7}, 241 [PORT_PJ6 ... PORT_PJ9] = -1,
242 {.res = P_TMR4, .offset = 6}, 242 [PORT_PJ10] = 0,
243 {.res = P_SPI0_SSEL5, .offset = 6}, 243 [PORT_PJ11] = 0,
244 {.res = P_TMR5, .offset = 5},
245 {.res = P_SPI0_SSEL6, .offset = 5},
246 {.res = P_UART1_RX, .offset = 4},
247 {.res = P_UART1_TX, .offset = 4},
248 {.res = P_TMR6, .offset = 4},
249 {.res = P_TMR7, .offset = 4},
250 {.res = P_UART0_RX, .offset = 3},
251 {.res = P_UART0_TX, .offset = 3},
252 {.res = P_DMAR0, .offset = 3},
253 {.res = P_DMAR1, .offset = 3},
254 {.res = P_SPORT0_DTSEC, .offset = 1},
255 {.res = P_SPORT0_DRSEC, .offset = 1},
256 {.res = P_CAN0_RX, .offset = 1},
257 {.res = P_CAN0_TX, .offset = 1},
258 {.res = P_SPI0_SSEL7, .offset = 1},
259 {.res = P_SPORT0_TFS, .offset = 0},
260 {.res = P_SPORT0_DTPRI, .offset = 0},
261 {.res = P_SPI0_SSEL2, .offset = 0},
262 {.res = P_SPI0_SSEL3, .offset = 0},
263}; 244};
264 245
265static void portmux_setup(unsigned short per) 246static int portmux_group_check(unsigned short per)
266{ 247{
267 u16 y, offset, muxreg; 248 u16 ident = P_IDENT(per);
268 u16 function = P_FUNCT2MUX(per); 249 u16 function = P_FUNCT2MUX(per);
250 s8 offset = port_mux[ident];
251 u16 m, pmux, pfunc;
269 252
270 for (y = 0; y < ARRAY_SIZE(port_mux_lut); y++) { 253 if (offset < 0)
271 if (port_mux_lut[y].res == per) { 254 return 0;
272
273 /* SET PORTMUX REG */
274
275 offset = port_mux_lut[y].offset;
276 muxreg = bfin_read_PORT_MUX();
277 255
278 if (offset != 1) 256 pmux = bfin_read_PORT_MUX();
279 muxreg &= ~(1 << offset); 257 for (m = 0; m < ARRAY_SIZE(port_mux); ++m) {
280 else 258 if (m == ident)
281 muxreg &= ~(3 << 1); 259 continue;
260 if (port_mux[m] != offset)
261 continue;
262 if (!is_reserved(peri, m, 1))
263 continue;
282 264
283 muxreg |= (function << offset); 265 if (offset == 1)
284 bfin_write_PORT_MUX(muxreg); 266 pfunc = (pmux >> offset) & 3;
267 else
268 pfunc = (pmux >> offset) & 1;
269 if (pfunc != function) {
270 pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n",
271 ident, function, m, pfunc);
272 return -EINVAL;
285 } 273 }
286 } 274 }
275
276 return 0;
277}
278
279static void portmux_setup(unsigned short per)
280{
281 u16 ident = P_IDENT(per);
282 u16 function = P_FUNCT2MUX(per);
283 s8 offset = port_mux[ident];
284 u16 pmux;
285
286 if (offset == -1)
287 return;
288
289 pmux = bfin_read_PORT_MUX();
290 if (offset != 1)
291 pmux &= ~(1 << offset);
292 else
293 pmux &= ~(3 << 1);
294 pmux |= (function << offset);
295 bfin_write_PORT_MUX(pmux);
287} 296}
288#elif defined(CONFIG_BF54x) 297#elif defined(CONFIG_BF54x)
289inline void portmux_setup(unsigned short per) 298inline void portmux_setup(unsigned short per)
290{ 299{
291 u32 pmux;
292 u16 ident = P_IDENT(per); 300 u16 ident = P_IDENT(per);
293 u16 function = P_FUNCT2MUX(per); 301 u16 function = P_FUNCT2MUX(per);
302 u32 pmux;
294 303
295 pmux = gpio_array[gpio_bank(ident)]->port_mux; 304 pmux = gpio_array[gpio_bank(ident)]->port_mux;
296 305
@@ -302,20 +311,54 @@ inline void portmux_setup(unsigned short per)
302 311
303inline u16 get_portmux(unsigned short per) 312inline u16 get_portmux(unsigned short per)
304{ 313{
305 u32 pmux;
306 u16 ident = P_IDENT(per); 314 u16 ident = P_IDENT(per);
307 315 u32 pmux = gpio_array[gpio_bank(ident)]->port_mux;
308 pmux = gpio_array[gpio_bank(ident)]->port_mux;
309
310 return (pmux >> (2 * gpio_sub_n(ident)) & 0x3); 316 return (pmux >> (2 * gpio_sub_n(ident)) & 0x3);
311} 317}
318static int portmux_group_check(unsigned short per)
319{
320 return 0;
321}
312#elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x) 322#elif defined(CONFIG_BF52x) || defined(CONFIG_BF51x)
323static int portmux_group_check(unsigned short per)
324{
325 u16 ident = P_IDENT(per);
326 u16 function = P_FUNCT2MUX(per);
327 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)];
328 u16 pin, gpiopin, pfunc;
329
330 for (pin = 0; pin < GPIO_BANKSIZE; ++pin) {
331 if (offset != pmux_offset[gpio_bank(ident)][pin])
332 continue;
333
334 gpiopin = gpio_bank(ident) * GPIO_BANKSIZE + pin;
335 if (gpiopin == ident)
336 continue;
337 if (!is_reserved(peri, gpiopin, 1))
338 continue;
339
340 pfunc = *port_mux[gpio_bank(ident)];
341 pfunc = (pfunc >> offset) & 3;
342 if (pfunc != function) {
343 pr_err("pin group conflict! request pin %d func %d conflict with pin %d func %d\n",
344 ident, function, gpiopin, pfunc);
345 return -EINVAL;
346 }
347 }
348
349 return 0;
350}
351
313inline void portmux_setup(unsigned short per) 352inline void portmux_setup(unsigned short per)
314{ 353{
315 u16 pmux, ident = P_IDENT(per), function = P_FUNCT2MUX(per); 354 u16 ident = P_IDENT(per);
355 u16 function = P_FUNCT2MUX(per);
316 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)]; 356 u8 offset = pmux_offset[gpio_bank(ident)][gpio_sub_n(ident)];
357 u16 pmux;
317 358
318 pmux = *port_mux[gpio_bank(ident)]; 359 pmux = *port_mux[gpio_bank(ident)];
360 if (((pmux >> offset) & 3) == function)
361 return;
319 pmux &= ~(3 << offset); 362 pmux &= ~(3 << offset);
320 pmux |= (function & 3) << offset; 363 pmux |= (function & 3) << offset;
321 *port_mux[gpio_bank(ident)] = pmux; 364 *port_mux[gpio_bank(ident)] = pmux;
@@ -323,6 +366,10 @@ inline void portmux_setup(unsigned short per)
323} 366}
324#else 367#else
325# define portmux_setup(...) do { } while (0) 368# define portmux_setup(...) do { } while (0)
369static int portmux_group_check(unsigned short per)
370{
371 return 0;
372}
326#endif 373#endif
327 374
328#ifndef CONFIG_BF54x 375#ifndef CONFIG_BF54x
@@ -349,13 +396,13 @@ inline void portmux_setup(unsigned short per)
349void set_gpio_ ## name(unsigned gpio, unsigned short arg) \ 396void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
350{ \ 397{ \
351 unsigned long flags; \ 398 unsigned long flags; \
352 local_irq_save_hw(flags); \ 399 flags = hard_local_irq_save(); \
353 if (arg) \ 400 if (arg) \
354 gpio_array[gpio_bank(gpio)]->name |= gpio_bit(gpio); \ 401 gpio_array[gpio_bank(gpio)]->name |= gpio_bit(gpio); \
355 else \ 402 else \
356 gpio_array[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \ 403 gpio_array[gpio_bank(gpio)]->name &= ~gpio_bit(gpio); \
357 AWA_DUMMY_READ(name); \ 404 AWA_DUMMY_READ(name); \
358 local_irq_restore_hw(flags); \ 405 hard_local_irq_restore(flags); \
359} \ 406} \
360EXPORT_SYMBOL(set_gpio_ ## name); 407EXPORT_SYMBOL(set_gpio_ ## name);
361 408
@@ -371,14 +418,14 @@ void set_gpio_ ## name(unsigned gpio, unsigned short arg) \
371{ \ 418{ \
372 unsigned long flags; \ 419 unsigned long flags; \
373 if (ANOMALY_05000311 || ANOMALY_05000323) \ 420 if (ANOMALY_05000311 || ANOMALY_05000323) \
374 local_irq_save_hw(flags); \ 421 flags = hard_local_irq_save(); \
375 if (arg) \ 422 if (arg) \
376 gpio_array[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \ 423 gpio_array[gpio_bank(gpio)]->name ## _set = gpio_bit(gpio); \
377 else \ 424 else \
378 gpio_array[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \ 425 gpio_array[gpio_bank(gpio)]->name ## _clear = gpio_bit(gpio); \
379 if (ANOMALY_05000311 || ANOMALY_05000323) { \ 426 if (ANOMALY_05000311 || ANOMALY_05000323) { \
380 AWA_DUMMY_READ(name); \ 427 AWA_DUMMY_READ(name); \
381 local_irq_restore_hw(flags); \ 428 hard_local_irq_restore(flags); \
382 } \ 429 } \
383} \ 430} \
384EXPORT_SYMBOL(set_gpio_ ## name); 431EXPORT_SYMBOL(set_gpio_ ## name);
@@ -391,11 +438,11 @@ void set_gpio_toggle(unsigned gpio)
391{ 438{
392 unsigned long flags; 439 unsigned long flags;
393 if (ANOMALY_05000311 || ANOMALY_05000323) 440 if (ANOMALY_05000311 || ANOMALY_05000323)
394 local_irq_save_hw(flags); 441 flags = hard_local_irq_save();
395 gpio_array[gpio_bank(gpio)]->toggle = gpio_bit(gpio); 442 gpio_array[gpio_bank(gpio)]->toggle = gpio_bit(gpio);
396 if (ANOMALY_05000311 || ANOMALY_05000323) { 443 if (ANOMALY_05000311 || ANOMALY_05000323) {
397 AWA_DUMMY_READ(toggle); 444 AWA_DUMMY_READ(toggle);
398 local_irq_restore_hw(flags); 445 hard_local_irq_restore(flags);
399 } 446 }
400} 447}
401EXPORT_SYMBOL(set_gpio_toggle); 448EXPORT_SYMBOL(set_gpio_toggle);
@@ -408,11 +455,11 @@ void set_gpiop_ ## name(unsigned gpio, unsigned short arg) \
408{ \ 455{ \
409 unsigned long flags; \ 456 unsigned long flags; \
410 if (ANOMALY_05000311 || ANOMALY_05000323) \ 457 if (ANOMALY_05000311 || ANOMALY_05000323) \
411 local_irq_save_hw(flags); \ 458 flags = hard_local_irq_save(); \
412 gpio_array[gpio_bank(gpio)]->name = arg; \ 459 gpio_array[gpio_bank(gpio)]->name = arg; \
413 if (ANOMALY_05000311 || ANOMALY_05000323) { \ 460 if (ANOMALY_05000311 || ANOMALY_05000323) { \
414 AWA_DUMMY_READ(name); \ 461 AWA_DUMMY_READ(name); \
415 local_irq_restore_hw(flags); \ 462 hard_local_irq_restore(flags); \
416 } \ 463 } \
417} \ 464} \
418EXPORT_SYMBOL(set_gpiop_ ## name); 465EXPORT_SYMBOL(set_gpiop_ ## name);
@@ -433,11 +480,11 @@ unsigned short get_gpio_ ## name(unsigned gpio) \
433 unsigned long flags; \ 480 unsigned long flags; \
434 unsigned short ret; \ 481 unsigned short ret; \
435 if (ANOMALY_05000311 || ANOMALY_05000323) \ 482 if (ANOMALY_05000311 || ANOMALY_05000323) \
436 local_irq_save_hw(flags); \ 483 flags = hard_local_irq_save(); \
437 ret = 0x01 & (gpio_array[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \ 484 ret = 0x01 & (gpio_array[gpio_bank(gpio)]->name >> gpio_sub_n(gpio)); \
438 if (ANOMALY_05000311 || ANOMALY_05000323) { \ 485 if (ANOMALY_05000311 || ANOMALY_05000323) { \
439 AWA_DUMMY_READ(name); \ 486 AWA_DUMMY_READ(name); \
440 local_irq_restore_hw(flags); \ 487 hard_local_irq_restore(flags); \
441 } \ 488 } \
442 return ret; \ 489 return ret; \
443} \ 490} \
@@ -460,11 +507,11 @@ unsigned short get_gpiop_ ## name(unsigned gpio) \
460 unsigned long flags; \ 507 unsigned long flags; \
461 unsigned short ret; \ 508 unsigned short ret; \
462 if (ANOMALY_05000311 || ANOMALY_05000323) \ 509 if (ANOMALY_05000311 || ANOMALY_05000323) \
463 local_irq_save_hw(flags); \ 510 flags = hard_local_irq_save(); \
464 ret = (gpio_array[gpio_bank(gpio)]->name); \ 511 ret = (gpio_array[gpio_bank(gpio)]->name); \
465 if (ANOMALY_05000311 || ANOMALY_05000323) { \ 512 if (ANOMALY_05000311 || ANOMALY_05000323) { \
466 AWA_DUMMY_READ(name); \ 513 AWA_DUMMY_READ(name); \
467 local_irq_restore_hw(flags); \ 514 hard_local_irq_restore(flags); \
468 } \ 515 } \
469 return ret; \ 516 return ret; \
470} \ 517} \
@@ -525,14 +572,14 @@ int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl)
525 if (check_gpio(gpio) < 0) 572 if (check_gpio(gpio) < 0)
526 return -EINVAL; 573 return -EINVAL;
527 574
528 local_irq_save_hw(flags); 575 flags = hard_local_irq_save();
529 if (ctrl) 576 if (ctrl)
530 reserve(wakeup, gpio); 577 reserve(wakeup, gpio);
531 else 578 else
532 unreserve(wakeup, gpio); 579 unreserve(wakeup, gpio);
533 580
534 set_gpio_maskb(gpio, ctrl); 581 set_gpio_maskb(gpio, ctrl);
535 local_irq_restore_hw(flags); 582 hard_local_irq_restore(flags);
536 583
537 return 0; 584 return 0;
538} 585}
@@ -690,7 +737,7 @@ int peripheral_request(unsigned short per, const char *label)
690 737
691 BUG_ON(ident >= MAX_RESOURCES); 738 BUG_ON(ident >= MAX_RESOURCES);
692 739
693 local_irq_save_hw(flags); 740 flags = hard_local_irq_save();
694 741
695 /* If a pin can be muxed as either GPIO or peripheral, make 742 /* If a pin can be muxed as either GPIO or peripheral, make
696 * sure it is not already a GPIO pin when we request it. 743 * sure it is not already a GPIO pin when we request it.
@@ -701,7 +748,7 @@ int peripheral_request(unsigned short per, const char *label)
701 printk(KERN_ERR 748 printk(KERN_ERR
702 "%s: Peripheral %d is already reserved as GPIO by %s !\n", 749 "%s: Peripheral %d is already reserved as GPIO by %s !\n",
703 __func__, ident, get_label(ident)); 750 __func__, ident, get_label(ident));
704 local_irq_restore_hw(flags); 751 hard_local_irq_restore(flags);
705 return -EBUSY; 752 return -EBUSY;
706 } 753 }
707 754
@@ -730,18 +777,22 @@ int peripheral_request(unsigned short per, const char *label)
730 printk(KERN_ERR 777 printk(KERN_ERR
731 "%s: Peripheral %d function %d is already reserved by %s !\n", 778 "%s: Peripheral %d function %d is already reserved by %s !\n",
732 __func__, ident, P_FUNCT2MUX(per), get_label(ident)); 779 __func__, ident, P_FUNCT2MUX(per), get_label(ident));
733 local_irq_restore_hw(flags); 780 hard_local_irq_restore(flags);
734 return -EBUSY; 781 return -EBUSY;
735 } 782 }
736 } 783 }
737 784
785 if (unlikely(portmux_group_check(per))) {
786 hard_local_irq_restore(flags);
787 return -EBUSY;
788 }
738 anyway: 789 anyway:
739 reserve(peri, ident); 790 reserve(peri, ident);
740 791
741 portmux_setup(per); 792 portmux_setup(per);
742 port_setup(ident, PERIPHERAL_USAGE); 793 port_setup(ident, PERIPHERAL_USAGE);
743 794
744 local_irq_restore_hw(flags); 795 hard_local_irq_restore(flags);
745 set_label(ident, label); 796 set_label(ident, label);
746 797
747 return 0; 798 return 0;
@@ -780,10 +831,10 @@ void peripheral_free(unsigned short per)
780 if (!(per & P_DEFINED)) 831 if (!(per & P_DEFINED))
781 return; 832 return;
782 833
783 local_irq_save_hw(flags); 834 flags = hard_local_irq_save();
784 835
785 if (unlikely(!is_reserved(peri, ident, 0))) { 836 if (unlikely(!is_reserved(peri, ident, 0))) {
786 local_irq_restore_hw(flags); 837 hard_local_irq_restore(flags);
787 return; 838 return;
788 } 839 }
789 840
@@ -794,7 +845,7 @@ void peripheral_free(unsigned short per)
794 845
795 set_label(ident, "free"); 846 set_label(ident, "free");
796 847
797 local_irq_restore_hw(flags); 848 hard_local_irq_restore(flags);
798} 849}
799EXPORT_SYMBOL(peripheral_free); 850EXPORT_SYMBOL(peripheral_free);
800 851
@@ -828,7 +879,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
828 if (check_gpio(gpio) < 0) 879 if (check_gpio(gpio) < 0)
829 return -EINVAL; 880 return -EINVAL;
830 881
831 local_irq_save_hw(flags); 882 flags = hard_local_irq_save();
832 883
833 /* 884 /*
834 * Allow that the identical GPIO can 885 * Allow that the identical GPIO can
@@ -837,7 +888,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
837 */ 888 */
838 889
839 if (cmp_label(gpio, label) == 0) { 890 if (cmp_label(gpio, label) == 0) {
840 local_irq_restore_hw(flags); 891 hard_local_irq_restore(flags);
841 return 0; 892 return 0;
842 } 893 }
843 894
@@ -846,7 +897,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
846 dump_stack(); 897 dump_stack();
847 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n", 898 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n",
848 gpio, get_label(gpio)); 899 gpio, get_label(gpio));
849 local_irq_restore_hw(flags); 900 hard_local_irq_restore(flags);
850 return -EBUSY; 901 return -EBUSY;
851 } 902 }
852 if (unlikely(is_reserved(peri, gpio, 1))) { 903 if (unlikely(is_reserved(peri, gpio, 1))) {
@@ -855,7 +906,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
855 printk(KERN_ERR 906 printk(KERN_ERR
856 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n", 907 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
857 gpio, get_label(gpio)); 908 gpio, get_label(gpio));
858 local_irq_restore_hw(flags); 909 hard_local_irq_restore(flags);
859 return -EBUSY; 910 return -EBUSY;
860 } 911 }
861 if (unlikely(is_reserved(gpio_irq, gpio, 1))) { 912 if (unlikely(is_reserved(gpio_irq, gpio, 1))) {
@@ -871,7 +922,7 @@ int bfin_gpio_request(unsigned gpio, const char *label)
871 reserve(gpio, gpio); 922 reserve(gpio, gpio);
872 set_label(gpio, label); 923 set_label(gpio, label);
873 924
874 local_irq_restore_hw(flags); 925 hard_local_irq_restore(flags);
875 926
876 port_setup(gpio, GPIO_USAGE); 927 port_setup(gpio, GPIO_USAGE);
877 928
@@ -888,13 +939,13 @@ void bfin_gpio_free(unsigned gpio)
888 939
889 might_sleep(); 940 might_sleep();
890 941
891 local_irq_save_hw(flags); 942 flags = hard_local_irq_save();
892 943
893 if (unlikely(!is_reserved(gpio, gpio, 0))) { 944 if (unlikely(!is_reserved(gpio, gpio, 0))) {
894 if (system_state == SYSTEM_BOOTING) 945 if (system_state == SYSTEM_BOOTING)
895 dump_stack(); 946 dump_stack();
896 gpio_error(gpio); 947 gpio_error(gpio);
897 local_irq_restore_hw(flags); 948 hard_local_irq_restore(flags);
898 return; 949 return;
899 } 950 }
900 951
@@ -902,7 +953,7 @@ void bfin_gpio_free(unsigned gpio)
902 953
903 set_label(gpio, "free"); 954 set_label(gpio, "free");
904 955
905 local_irq_restore_hw(flags); 956 hard_local_irq_restore(flags);
906} 957}
907EXPORT_SYMBOL(bfin_gpio_free); 958EXPORT_SYMBOL(bfin_gpio_free);
908 959
@@ -913,7 +964,7 @@ int bfin_special_gpio_request(unsigned gpio, const char *label)
913{ 964{
914 unsigned long flags; 965 unsigned long flags;
915 966
916 local_irq_save_hw(flags); 967 flags = hard_local_irq_save();
917 968
918 /* 969 /*
919 * Allow that the identical GPIO can 970 * Allow that the identical GPIO can
@@ -922,19 +973,19 @@ int bfin_special_gpio_request(unsigned gpio, const char *label)
922 */ 973 */
923 974
924 if (cmp_label(gpio, label) == 0) { 975 if (cmp_label(gpio, label) == 0) {
925 local_irq_restore_hw(flags); 976 hard_local_irq_restore(flags);
926 return 0; 977 return 0;
927 } 978 }
928 979
929 if (unlikely(is_reserved(special_gpio, gpio, 1))) { 980 if (unlikely(is_reserved(special_gpio, gpio, 1))) {
930 local_irq_restore_hw(flags); 981 hard_local_irq_restore(flags);
931 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n", 982 printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n",
932 gpio, get_label(gpio)); 983 gpio, get_label(gpio));
933 984
934 return -EBUSY; 985 return -EBUSY;
935 } 986 }
936 if (unlikely(is_reserved(peri, gpio, 1))) { 987 if (unlikely(is_reserved(peri, gpio, 1))) {
937 local_irq_restore_hw(flags); 988 hard_local_irq_restore(flags);
938 printk(KERN_ERR 989 printk(KERN_ERR
939 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n", 990 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
940 gpio, get_label(gpio)); 991 gpio, get_label(gpio));
@@ -946,7 +997,7 @@ int bfin_special_gpio_request(unsigned gpio, const char *label)
946 reserve(peri, gpio); 997 reserve(peri, gpio);
947 998
948 set_label(gpio, label); 999 set_label(gpio, label);
949 local_irq_restore_hw(flags); 1000 hard_local_irq_restore(flags);
950 port_setup(gpio, GPIO_USAGE); 1001 port_setup(gpio, GPIO_USAGE);
951 1002
952 return 0; 1003 return 0;
@@ -959,18 +1010,18 @@ void bfin_special_gpio_free(unsigned gpio)
959 1010
960 might_sleep(); 1011 might_sleep();
961 1012
962 local_irq_save_hw(flags); 1013 flags = hard_local_irq_save();
963 1014
964 if (unlikely(!is_reserved(special_gpio, gpio, 0))) { 1015 if (unlikely(!is_reserved(special_gpio, gpio, 0))) {
965 gpio_error(gpio); 1016 gpio_error(gpio);
966 local_irq_restore_hw(flags); 1017 hard_local_irq_restore(flags);
967 return; 1018 return;
968 } 1019 }
969 1020
970 unreserve(special_gpio, gpio); 1021 unreserve(special_gpio, gpio);
971 unreserve(peri, gpio); 1022 unreserve(peri, gpio);
972 set_label(gpio, "free"); 1023 set_label(gpio, "free");
973 local_irq_restore_hw(flags); 1024 hard_local_irq_restore(flags);
974} 1025}
975EXPORT_SYMBOL(bfin_special_gpio_free); 1026EXPORT_SYMBOL(bfin_special_gpio_free);
976#endif 1027#endif
@@ -983,7 +1034,7 @@ int bfin_gpio_irq_request(unsigned gpio, const char *label)
983 if (check_gpio(gpio) < 0) 1034 if (check_gpio(gpio) < 0)
984 return -EINVAL; 1035 return -EINVAL;
985 1036
986 local_irq_save_hw(flags); 1037 flags = hard_local_irq_save();
987 1038
988 if (unlikely(is_reserved(peri, gpio, 1))) { 1039 if (unlikely(is_reserved(peri, gpio, 1))) {
989 if (system_state == SYSTEM_BOOTING) 1040 if (system_state == SYSTEM_BOOTING)
@@ -991,7 +1042,7 @@ int bfin_gpio_irq_request(unsigned gpio, const char *label)
991 printk(KERN_ERR 1042 printk(KERN_ERR
992 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n", 1043 "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
993 gpio, get_label(gpio)); 1044 gpio, get_label(gpio));
994 local_irq_restore_hw(flags); 1045 hard_local_irq_restore(flags);
995 return -EBUSY; 1046 return -EBUSY;
996 } 1047 }
997 if (unlikely(is_reserved(gpio, gpio, 1))) 1048 if (unlikely(is_reserved(gpio, gpio, 1)))
@@ -1002,7 +1053,7 @@ int bfin_gpio_irq_request(unsigned gpio, const char *label)
1002 reserve(gpio_irq, gpio); 1053 reserve(gpio_irq, gpio);
1003 set_label(gpio, label); 1054 set_label(gpio, label);
1004 1055
1005 local_irq_restore_hw(flags); 1056 hard_local_irq_restore(flags);
1006 1057
1007 port_setup(gpio, GPIO_USAGE); 1058 port_setup(gpio, GPIO_USAGE);
1008 1059
@@ -1016,13 +1067,13 @@ void bfin_gpio_irq_free(unsigned gpio)
1016 if (check_gpio(gpio) < 0) 1067 if (check_gpio(gpio) < 0)
1017 return; 1068 return;
1018 1069
1019 local_irq_save_hw(flags); 1070 flags = hard_local_irq_save();
1020 1071
1021 if (unlikely(!is_reserved(gpio_irq, gpio, 0))) { 1072 if (unlikely(!is_reserved(gpio_irq, gpio, 0))) {
1022 if (system_state == SYSTEM_BOOTING) 1073 if (system_state == SYSTEM_BOOTING)
1023 dump_stack(); 1074 dump_stack();
1024 gpio_error(gpio); 1075 gpio_error(gpio);
1025 local_irq_restore_hw(flags); 1076 hard_local_irq_restore(flags);
1026 return; 1077 return;
1027 } 1078 }
1028 1079
@@ -1030,7 +1081,7 @@ void bfin_gpio_irq_free(unsigned gpio)
1030 1081
1031 set_label(gpio, "free"); 1082 set_label(gpio, "free");
1032 1083
1033 local_irq_restore_hw(flags); 1084 hard_local_irq_restore(flags);
1034} 1085}
1035 1086
1036static inline void __bfin_gpio_direction_input(unsigned gpio) 1087static inline void __bfin_gpio_direction_input(unsigned gpio)
@@ -1052,10 +1103,10 @@ int bfin_gpio_direction_input(unsigned gpio)
1052 return -EINVAL; 1103 return -EINVAL;
1053 } 1104 }
1054 1105
1055 local_irq_save_hw(flags); 1106 flags = hard_local_irq_save();
1056 __bfin_gpio_direction_input(gpio); 1107 __bfin_gpio_direction_input(gpio);
1057 AWA_DUMMY_READ(inen); 1108 AWA_DUMMY_READ(inen);
1058 local_irq_restore_hw(flags); 1109 hard_local_irq_restore(flags);
1059 1110
1060 return 0; 1111 return 0;
1061} 1112}
@@ -1070,9 +1121,9 @@ void bfin_gpio_irq_prepare(unsigned gpio)
1070 port_setup(gpio, GPIO_USAGE); 1121 port_setup(gpio, GPIO_USAGE);
1071 1122
1072#ifdef CONFIG_BF54x 1123#ifdef CONFIG_BF54x
1073 local_irq_save_hw(flags); 1124 flags = hard_local_irq_save();
1074 __bfin_gpio_direction_input(gpio); 1125 __bfin_gpio_direction_input(gpio);
1075 local_irq_restore_hw(flags); 1126 hard_local_irq_restore(flags);
1076#endif 1127#endif
1077} 1128}
1078 1129
@@ -1094,7 +1145,7 @@ int bfin_gpio_direction_output(unsigned gpio, int value)
1094 return -EINVAL; 1145 return -EINVAL;
1095 } 1146 }
1096 1147
1097 local_irq_save_hw(flags); 1148 flags = hard_local_irq_save();
1098 1149
1099 gpio_array[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio); 1150 gpio_array[gpio_bank(gpio)]->inen &= ~gpio_bit(gpio);
1100 gpio_set_value(gpio, value); 1151 gpio_set_value(gpio, value);
@@ -1105,7 +1156,7 @@ int bfin_gpio_direction_output(unsigned gpio, int value)
1105#endif 1156#endif
1106 1157
1107 AWA_DUMMY_READ(dir); 1158 AWA_DUMMY_READ(dir);
1108 local_irq_restore_hw(flags); 1159 hard_local_irq_restore(flags);
1109 1160
1110 return 0; 1161 return 0;
1111} 1162}
@@ -1120,11 +1171,11 @@ int bfin_gpio_get_value(unsigned gpio)
1120 1171
1121 if (unlikely(get_gpio_edge(gpio))) { 1172 if (unlikely(get_gpio_edge(gpio))) {
1122 int ret; 1173 int ret;
1123 local_irq_save_hw(flags); 1174 flags = hard_local_irq_save();
1124 set_gpio_edge(gpio, 0); 1175 set_gpio_edge(gpio, 0);
1125 ret = get_gpio_data(gpio); 1176 ret = get_gpio_data(gpio);
1126 set_gpio_edge(gpio, 1); 1177 set_gpio_edge(gpio, 1);
1127 local_irq_restore_hw(flags); 1178 hard_local_irq_restore(flags);
1128 return ret; 1179 return ret;
1129 } else 1180 } else
1130 return get_gpio_data(gpio); 1181 return get_gpio_data(gpio);
diff --git a/arch/blackfin/kernel/cplb-mpu/cplbmgr.c b/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
index 87b25b1b30ed..8de92299b3ee 100644
--- a/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
+++ b/arch/blackfin/kernel/cplb-mpu/cplbmgr.c
@@ -318,7 +318,7 @@ void flush_switched_cplbs(unsigned int cpu)
318 318
319 nr_cplb_flush[cpu]++; 319 nr_cplb_flush[cpu]++;
320 320
321 local_irq_save_hw(flags); 321 flags = hard_local_irq_save();
322 _disable_icplb(); 322 _disable_icplb();
323 for (i = first_switched_icplb; i < MAX_CPLBS; i++) { 323 for (i = first_switched_icplb; i < MAX_CPLBS; i++) {
324 icplb_tbl[cpu][i].data = 0; 324 icplb_tbl[cpu][i].data = 0;
@@ -332,7 +332,7 @@ void flush_switched_cplbs(unsigned int cpu)
332 bfin_write32(DCPLB_DATA0 + i * 4, 0); 332 bfin_write32(DCPLB_DATA0 + i * 4, 0);
333 } 333 }
334 _enable_dcplb(); 334 _enable_dcplb();
335 local_irq_restore_hw(flags); 335 hard_local_irq_restore(flags);
336 336
337} 337}
338 338
@@ -348,7 +348,7 @@ void set_mask_dcplbs(unsigned long *masks, unsigned int cpu)
348 return; 348 return;
349 } 349 }
350 350
351 local_irq_save_hw(flags); 351 flags = hard_local_irq_save();
352 current_rwx_mask[cpu] = masks; 352 current_rwx_mask[cpu] = masks;
353 353
354 if (L2_LENGTH && addr >= L2_START && addr < L2_START + L2_LENGTH) { 354 if (L2_LENGTH && addr >= L2_START && addr < L2_START + L2_LENGTH) {
@@ -373,5 +373,5 @@ void set_mask_dcplbs(unsigned long *masks, unsigned int cpu)
373 addr += PAGE_SIZE; 373 addr += PAGE_SIZE;
374 } 374 }
375 _enable_dcplb(); 375 _enable_dcplb();
376 local_irq_restore_hw(flags); 376 hard_local_irq_restore(flags);
377} 377}
diff --git a/arch/blackfin/kernel/ipipe.c b/arch/blackfin/kernel/ipipe.c
index 1a496cd71ba2..3b1da4aff2a1 100644
--- a/arch/blackfin/kernel/ipipe.c
+++ b/arch/blackfin/kernel/ipipe.c
@@ -219,10 +219,10 @@ int __ipipe_syscall_root(struct pt_regs *regs)
219 219
220 ret = __ipipe_dispatch_event(IPIPE_EVENT_SYSCALL, regs); 220 ret = __ipipe_dispatch_event(IPIPE_EVENT_SYSCALL, regs);
221 221
222 local_irq_save_hw(flags); 222 flags = hard_local_irq_save();
223 223
224 if (!__ipipe_root_domain_p) { 224 if (!__ipipe_root_domain_p) {
225 local_irq_restore_hw(flags); 225 hard_local_irq_restore(flags);
226 return 1; 226 return 1;
227 } 227 }
228 228
@@ -230,7 +230,7 @@ int __ipipe_syscall_root(struct pt_regs *regs)
230 if ((p->irqpend_himask & IPIPE_IRQMASK_VIRT) != 0) 230 if ((p->irqpend_himask & IPIPE_IRQMASK_VIRT) != 0)
231 __ipipe_sync_pipeline(IPIPE_IRQMASK_VIRT); 231 __ipipe_sync_pipeline(IPIPE_IRQMASK_VIRT);
232 232
233 local_irq_restore_hw(flags); 233 hard_local_irq_restore(flags);
234 234
235 return -ret; 235 return -ret;
236} 236}
@@ -239,14 +239,14 @@ unsigned long ipipe_critical_enter(void (*syncfn) (void))
239{ 239{
240 unsigned long flags; 240 unsigned long flags;
241 241
242 local_irq_save_hw(flags); 242 flags = hard_local_irq_save();
243 243
244 return flags; 244 return flags;
245} 245}
246 246
247void ipipe_critical_exit(unsigned long flags) 247void ipipe_critical_exit(unsigned long flags)
248{ 248{
249 local_irq_restore_hw(flags); 249 hard_local_irq_restore(flags);
250} 250}
251 251
252static void __ipipe_no_irqtail(void) 252static void __ipipe_no_irqtail(void)
@@ -279,9 +279,9 @@ int ipipe_trigger_irq(unsigned irq)
279 return -EINVAL; 279 return -EINVAL;
280#endif 280#endif
281 281
282 local_irq_save_hw(flags); 282 flags = hard_local_irq_save();
283 __ipipe_handle_irq(irq, NULL); 283 __ipipe_handle_irq(irq, NULL);
284 local_irq_restore_hw(flags); 284 hard_local_irq_restore(flags);
285 285
286 return 1; 286 return 1;
287} 287}
@@ -293,7 +293,7 @@ asmlinkage void __ipipe_sync_root(void)
293 293
294 BUG_ON(irqs_disabled()); 294 BUG_ON(irqs_disabled());
295 295
296 local_irq_save_hw(flags); 296 flags = hard_local_irq_save();
297 297
298 if (irq_tail_hook) 298 if (irq_tail_hook)
299 irq_tail_hook(); 299 irq_tail_hook();
@@ -303,7 +303,7 @@ asmlinkage void __ipipe_sync_root(void)
303 if (ipipe_root_cpudom_var(irqpend_himask) != 0) 303 if (ipipe_root_cpudom_var(irqpend_himask) != 0)
304 __ipipe_sync_pipeline(IPIPE_IRQMASK_ANY); 304 __ipipe_sync_pipeline(IPIPE_IRQMASK_ANY);
305 305
306 local_irq_restore_hw(flags); 306 hard_local_irq_restore(flags);
307} 307}
308 308
309void ___ipipe_sync_pipeline(unsigned long syncmask) 309void ___ipipe_sync_pipeline(unsigned long syncmask)
@@ -344,10 +344,10 @@ void __ipipe_stall_root(void)
344{ 344{
345 unsigned long *p, flags; 345 unsigned long *p, flags;
346 346
347 local_irq_save_hw(flags); 347 flags = hard_local_irq_save();
348 p = &__ipipe_root_status; 348 p = &__ipipe_root_status;
349 __set_bit(IPIPE_STALL_FLAG, p); 349 __set_bit(IPIPE_STALL_FLAG, p);
350 local_irq_restore_hw(flags); 350 hard_local_irq_restore(flags);
351} 351}
352EXPORT_SYMBOL(__ipipe_stall_root); 352EXPORT_SYMBOL(__ipipe_stall_root);
353 353
@@ -356,10 +356,10 @@ unsigned long __ipipe_test_and_stall_root(void)
356 unsigned long *p, flags; 356 unsigned long *p, flags;
357 int x; 357 int x;
358 358
359 local_irq_save_hw(flags); 359 flags = hard_local_irq_save();
360 p = &__ipipe_root_status; 360 p = &__ipipe_root_status;
361 x = __test_and_set_bit(IPIPE_STALL_FLAG, p); 361 x = __test_and_set_bit(IPIPE_STALL_FLAG, p);
362 local_irq_restore_hw(flags); 362 hard_local_irq_restore(flags);
363 363
364 return x; 364 return x;
365} 365}
@@ -371,10 +371,10 @@ unsigned long __ipipe_test_root(void)
371 unsigned long flags; 371 unsigned long flags;
372 int x; 372 int x;
373 373
374 local_irq_save_hw_smp(flags); 374 flags = hard_local_irq_save_smp();
375 p = &__ipipe_root_status; 375 p = &__ipipe_root_status;
376 x = test_bit(IPIPE_STALL_FLAG, p); 376 x = test_bit(IPIPE_STALL_FLAG, p);
377 local_irq_restore_hw_smp(flags); 377 hard_local_irq_restore_smp(flags);
378 378
379 return x; 379 return x;
380} 380}
@@ -384,10 +384,10 @@ void __ipipe_lock_root(void)
384{ 384{
385 unsigned long *p, flags; 385 unsigned long *p, flags;
386 386
387 local_irq_save_hw(flags); 387 flags = hard_local_irq_save();
388 p = &__ipipe_root_status; 388 p = &__ipipe_root_status;
389 __set_bit(IPIPE_SYNCDEFER_FLAG, p); 389 __set_bit(IPIPE_SYNCDEFER_FLAG, p);
390 local_irq_restore_hw(flags); 390 hard_local_irq_restore(flags);
391} 391}
392EXPORT_SYMBOL(__ipipe_lock_root); 392EXPORT_SYMBOL(__ipipe_lock_root);
393 393
@@ -395,9 +395,9 @@ void __ipipe_unlock_root(void)
395{ 395{
396 unsigned long *p, flags; 396 unsigned long *p, flags;
397 397
398 local_irq_save_hw(flags); 398 flags = hard_local_irq_save();
399 p = &__ipipe_root_status; 399 p = &__ipipe_root_status;
400 __clear_bit(IPIPE_SYNCDEFER_FLAG, p); 400 __clear_bit(IPIPE_SYNCDEFER_FLAG, p);
401 local_irq_restore_hw(flags); 401 hard_local_irq_restore(flags);
402} 402}
403EXPORT_SYMBOL(__ipipe_unlock_root); 403EXPORT_SYMBOL(__ipipe_unlock_root);
diff --git a/arch/blackfin/kernel/kgdb_test.c b/arch/blackfin/kernel/kgdb_test.c
index 9a4b07594389..08c0236acf3c 100644
--- a/arch/blackfin/kernel/kgdb_test.c
+++ b/arch/blackfin/kernel/kgdb_test.c
@@ -88,6 +88,7 @@ static const struct file_operations kgdb_test_proc_fops = {
88 .owner = THIS_MODULE, 88 .owner = THIS_MODULE,
89 .read = kgdb_test_proc_read, 89 .read = kgdb_test_proc_read,
90 .write = kgdb_test_proc_write, 90 .write = kgdb_test_proc_write,
91 .llseek = noop_llseek,
91}; 92};
92 93
93static int __init kgdbtest_init(void) 94static int __init kgdbtest_init(void)
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index 01f98cb964d2..cd0c090ebc54 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -65,11 +65,11 @@ static void default_idle(void)
65#ifdef CONFIG_IPIPE 65#ifdef CONFIG_IPIPE
66 ipipe_suspend_domain(); 66 ipipe_suspend_domain();
67#endif 67#endif
68 local_irq_disable_hw(); 68 hard_local_irq_disable();
69 if (!need_resched()) 69 if (!need_resched())
70 idle_with_irq_disabled(); 70 idle_with_irq_disabled();
71 71
72 local_irq_enable_hw(); 72 hard_local_irq_enable();
73} 73}
74 74
75/* 75/*
@@ -493,6 +493,11 @@ int _access_ok(unsigned long addr, unsigned long size)
493 return 1; 493 return 1;
494#endif 494#endif
495 495
496#ifndef CONFIG_EXCEPTION_L1_SCRATCH
497 if (in_mem_const(addr, size, (unsigned long)l1_stack_base, l1_stack_len))
498 return 1;
499#endif
500
496 aret = in_async(addr, size); 501 aret = in_async(addr, size);
497 if (aret < 2) 502 if (aret < 2)
498 return aret; 503 return aret;
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index 6ec77685df52..b35839354130 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -27,6 +27,7 @@
27#include <asm/fixed_code.h> 27#include <asm/fixed_code.h>
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/mem_map.h> 29#include <asm/mem_map.h>
30#include <asm/mmu_context.h>
30 31
31/* 32/*
32 * does not yet catch signals sent when the child dies. 33 * does not yet catch signals sent when the child dies.
@@ -113,8 +114,8 @@ put_reg(struct task_struct *task, long regno, unsigned long data)
113/* 114/*
114 * check that an address falls within the bounds of the target process's memory mappings 115 * check that an address falls within the bounds of the target process's memory mappings
115 */ 116 */
116static inline int is_user_addr_valid(struct task_struct *child, 117int
117 unsigned long start, unsigned long len) 118is_user_addr_valid(struct task_struct *child, unsigned long start, unsigned long len)
118{ 119{
119 struct vm_area_struct *vma; 120 struct vm_area_struct *vma;
120 struct sram_list_struct *sraml; 121 struct sram_list_struct *sraml;
@@ -135,6 +136,13 @@ static inline int is_user_addr_valid(struct task_struct *child,
135 if (start >= FIXED_CODE_START && start + len < FIXED_CODE_END) 136 if (start >= FIXED_CODE_START && start + len < FIXED_CODE_END)
136 return 0; 137 return 0;
137 138
139#ifdef CONFIG_APP_STACK_L1
140 if (child->mm->context.l1_stack_save)
141 if (start >= (unsigned long)l1_stack_base &&
142 start + len < (unsigned long)l1_stack_base + l1_stack_len)
143 return 0;
144#endif
145
138 return -EIO; 146 return -EIO;
139} 147}
140 148
diff --git a/arch/blackfin/kernel/sys_bfin.c b/arch/blackfin/kernel/sys_bfin.c
index bdc1e2f0da32..89448ed7065d 100644
--- a/arch/blackfin/kernel/sys_bfin.c
+++ b/arch/blackfin/kernel/sys_bfin.c
@@ -21,6 +21,8 @@
21 21
22#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
23#include <asm/dma.h> 23#include <asm/dma.h>
24#include <asm/cachectl.h>
25#include <asm/ptrace.h>
24 26
25asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags) 27asmlinkage void *sys_sram_alloc(size_t size, unsigned long flags)
26{ 28{
@@ -70,3 +72,16 @@ asmlinkage int sys_bfin_spinlock(int *p)
70 72
71 return ret; 73 return ret;
72} 74}
75
76SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, len, int, op)
77{
78 if (is_user_addr_valid(current, addr, len) != 0)
79 return -EINVAL;
80
81 if (op & DCACHE)
82 blackfin_dcache_flush_range(addr, addr + len);
83 if (op & ICACHE)
84 blackfin_icache_flush_range(addr, addr + len);
85
86 return 0;
87}
diff --git a/arch/blackfin/kernel/trace.c b/arch/blackfin/kernel/trace.c
index 59fcdf6b0138..05b550891ce5 100644
--- a/arch/blackfin/kernel/trace.c
+++ b/arch/blackfin/kernel/trace.c
@@ -15,6 +15,7 @@
15#include <linux/kallsyms.h> 15#include <linux/kallsyms.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/irq.h>
18#include <asm/dma.h> 19#include <asm/dma.h>
19#include <asm/trace.h> 20#include <asm/trace.h>
20#include <asm/fixed_code.h> 21#include <asm/fixed_code.h>
diff --git a/arch/blackfin/mach-bf518/boards/ezbrd.c b/arch/blackfin/mach-bf518/boards/ezbrd.c
index 44d6d5299022..f95e6096719b 100644
--- a/arch/blackfin/mach-bf518/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf518/boards/ezbrd.c
@@ -312,7 +312,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
312#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 312#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
313/* SPI (0) */ 313/* SPI (0) */
314static struct bfin5xx_spi_master bfin_spi0_info = { 314static struct bfin5xx_spi_master bfin_spi0_info = {
315 .num_chipselect = 5, 315 .num_chipselect = 6,
316 .enable_dma = 1, /* master has the ability to do dma transfer */ 316 .enable_dma = 1, /* master has the ability to do dma transfer */
317 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 317 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
318}; 318};
@@ -347,7 +347,7 @@ static struct platform_device bfin_spi0_device = {
347 347
348/* SPI (1) */ 348/* SPI (1) */
349static struct bfin5xx_spi_master bfin_spi1_info = { 349static struct bfin5xx_spi_master bfin_spi1_info = {
350 .num_chipselect = 5, 350 .num_chipselect = 6,
351 .enable_dma = 1, /* master has the ability to do dma transfer */ 351 .enable_dma = 1, /* master has the ability to do dma transfer */
352 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 352 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
353}; 353};
@@ -525,6 +525,14 @@ static struct platform_device bfin_sir1_device = {
525#endif 525#endif
526#endif 526#endif
527 527
528#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
529static struct platform_device bfin_i2s = {
530 .name = "bfin-i2s",
531 .id = CONFIG_SND_BF5XX_SPORT_NUM,
532 /* TODO: add platform data here */
533};
534#endif
535
528#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 536#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
529static struct resource bfin_twi0_resource[] = { 537static struct resource bfin_twi0_resource[] = {
530 [0] = { 538 [0] = {
@@ -559,6 +567,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
559 .irq = IRQ_PF8, 567 .irq = IRQ_PF8,
560 }, 568 },
561#endif 569#endif
570#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
571 {
572 I2C_BOARD_INFO("ssm2602", 0x1b),
573 },
574#endif
562}; 575};
563 576
564#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 577#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -736,6 +749,10 @@ static struct platform_device *stamp_devices[] __initdata = {
736 &i2c_bfin_twi_device, 749 &i2c_bfin_twi_device,
737#endif 750#endif
738 751
752#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
753 &bfin_i2s,
754#endif
755
739#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 756#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
740#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 757#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
741 &bfin_sport0_uart_device, 758 &bfin_sport0_uart_device,
diff --git a/arch/blackfin/mach-bf518/boards/tcm-bf518.c b/arch/blackfin/mach-bf518/boards/tcm-bf518.c
index 9b72e5cb21fe..bead810a6546 100644
--- a/arch/blackfin/mach-bf518/boards/tcm-bf518.c
+++ b/arch/blackfin/mach-bf518/boards/tcm-bf518.c
@@ -291,7 +291,7 @@ static struct platform_device bfin_spi0_device = {
291 291
292/* SPI (1) */ 292/* SPI (1) */
293static struct bfin5xx_spi_master bfin_spi1_info = { 293static struct bfin5xx_spi_master bfin_spi1_info = {
294 .num_chipselect = 5, 294 .num_chipselect = 6,
295 .enable_dma = 1, /* master has the ability to do dma transfer */ 295 .enable_dma = 1, /* master has the ability to do dma transfer */
296 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 296 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
297}; 297};
diff --git a/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h b/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h
index e548e9d1d6fa..e16969f24ffd 100644
--- a/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h
+++ b/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h
@@ -262,14 +262,14 @@
262#define bfin_write_SPORT0_TX(val) bfin_write32(SPORT0_TX, val) 262#define bfin_write_SPORT0_TX(val) bfin_write32(SPORT0_TX, val)
263#define bfin_read_SPORT0_RX() bfin_read32(SPORT0_RX) 263#define bfin_read_SPORT0_RX() bfin_read32(SPORT0_RX)
264#define bfin_write_SPORT0_RX(val) bfin_write32(SPORT0_RX, val) 264#define bfin_write_SPORT0_RX(val) bfin_write32(SPORT0_RX, val)
265#define bfin_read_SPORT0_TX32() bfin_read32(SPORT0_TX32) 265#define bfin_read_SPORT0_TX32() bfin_read32(SPORT0_TX)
266#define bfin_write_SPORT0_TX32(val) bfin_write32(SPORT0_TX32, val) 266#define bfin_write_SPORT0_TX32(val) bfin_write32(SPORT0_TX, val)
267#define bfin_read_SPORT0_RX32() bfin_read32(SPORT0_RX32) 267#define bfin_read_SPORT0_RX32() bfin_read32(SPORT0_RX)
268#define bfin_write_SPORT0_RX32(val) bfin_write32(SPORT0_RX32, val) 268#define bfin_write_SPORT0_RX32(val) bfin_write32(SPORT0_RX, val)
269#define bfin_read_SPORT0_TX16() bfin_read16(SPORT0_TX16) 269#define bfin_read_SPORT0_TX16() bfin_read16(SPORT0_TX)
270#define bfin_write_SPORT0_TX16(val) bfin_write16(SPORT0_TX16, val) 270#define bfin_write_SPORT0_TX16(val) bfin_write16(SPORT0_TX, val)
271#define bfin_read_SPORT0_RX16() bfin_read16(SPORT0_RX16) 271#define bfin_read_SPORT0_RX16() bfin_read16(SPORT0_RX)
272#define bfin_write_SPORT0_RX16(val) bfin_write16(SPORT0_RX16, val) 272#define bfin_write_SPORT0_RX16(val) bfin_write16(SPORT0_RX, val)
273#define bfin_read_SPORT0_RCR1() bfin_read16(SPORT0_RCR1) 273#define bfin_read_SPORT0_RCR1() bfin_read16(SPORT0_RCR1)
274#define bfin_write_SPORT0_RCR1(val) bfin_write16(SPORT0_RCR1, val) 274#define bfin_write_SPORT0_RCR1(val) bfin_write16(SPORT0_RCR1, val)
275#define bfin_read_SPORT0_RCR2() bfin_read16(SPORT0_RCR2) 275#define bfin_read_SPORT0_RCR2() bfin_read16(SPORT0_RCR2)
@@ -317,14 +317,14 @@
317#define bfin_write_SPORT1_TX(val) bfin_write32(SPORT1_TX, val) 317#define bfin_write_SPORT1_TX(val) bfin_write32(SPORT1_TX, val)
318#define bfin_read_SPORT1_RX() bfin_read32(SPORT1_RX) 318#define bfin_read_SPORT1_RX() bfin_read32(SPORT1_RX)
319#define bfin_write_SPORT1_RX(val) bfin_write32(SPORT1_RX, val) 319#define bfin_write_SPORT1_RX(val) bfin_write32(SPORT1_RX, val)
320#define bfin_read_SPORT1_TX32() bfin_read32(SPORT1_TX32) 320#define bfin_read_SPORT1_TX32() bfin_read32(SPORT1_TX)
321#define bfin_write_SPORT1_TX32(val) bfin_write32(SPORT1_TX32, val) 321#define bfin_write_SPORT1_TX32(val) bfin_write32(SPORT1_TX, val)
322#define bfin_read_SPORT1_RX32() bfin_read32(SPORT1_RX32) 322#define bfin_read_SPORT1_RX32() bfin_read32(SPORT1_RX)
323#define bfin_write_SPORT1_RX32(val) bfin_write32(SPORT1_RX32, val) 323#define bfin_write_SPORT1_RX32(val) bfin_write32(SPORT1_RX, val)
324#define bfin_read_SPORT1_TX16() bfin_read16(SPORT1_TX16) 324#define bfin_read_SPORT1_TX16() bfin_read16(SPORT1_TX)
325#define bfin_write_SPORT1_TX16(val) bfin_write16(SPORT1_TX16, val) 325#define bfin_write_SPORT1_TX16(val) bfin_write16(SPORT1_TX, val)
326#define bfin_read_SPORT1_RX16() bfin_read16(SPORT1_RX16) 326#define bfin_read_SPORT1_RX16() bfin_read16(SPORT1_RX)
327#define bfin_write_SPORT1_RX16(val) bfin_write16(SPORT1_RX16, val) 327#define bfin_write_SPORT1_RX16(val) bfin_write16(SPORT1_RX, val)
328#define bfin_read_SPORT1_RCR1() bfin_read16(SPORT1_RCR1) 328#define bfin_read_SPORT1_RCR1() bfin_read16(SPORT1_RCR1)
329#define bfin_write_SPORT1_RCR1(val) bfin_write16(SPORT1_RCR1, val) 329#define bfin_write_SPORT1_RCR1(val) bfin_write16(SPORT1_RCR1, val)
330#define bfin_read_SPORT1_RCR2() bfin_read16(SPORT1_RCR2) 330#define bfin_read_SPORT1_RCR2() bfin_read16(SPORT1_RCR2)
@@ -1058,54 +1058,4 @@
1058/* These need to be last due to the cdef/linux inter-dependencies */ 1058/* These need to be last due to the cdef/linux inter-dependencies */
1059#include <asm/irq.h> 1059#include <asm/irq.h>
1060 1060
1061/* Writing to PLL_CTL initiates a PLL relock sequence. */
1062static __inline__ void bfin_write_PLL_CTL(unsigned int val)
1063{
1064 unsigned long flags, iwr0, iwr1;
1065
1066 if (val == bfin_read_PLL_CTL())
1067 return;
1068
1069 local_irq_save_hw(flags);
1070 /* Enable the PLL Wakeup bit in SIC IWR */
1071 iwr0 = bfin_read32(SIC_IWR0);
1072 iwr1 = bfin_read32(SIC_IWR1);
1073 /* Only allow PPL Wakeup) */
1074 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
1075 bfin_write32(SIC_IWR1, 0);
1076
1077 bfin_write16(PLL_CTL, val);
1078 SSYNC();
1079 asm("IDLE;");
1080
1081 bfin_write32(SIC_IWR0, iwr0);
1082 bfin_write32(SIC_IWR1, iwr1);
1083 local_irq_restore_hw(flags);
1084}
1085
1086/* Writing to VR_CTL initiates a PLL relock sequence. */
1087static __inline__ void bfin_write_VR_CTL(unsigned int val)
1088{
1089 unsigned long flags, iwr0, iwr1;
1090
1091 if (val == bfin_read_VR_CTL())
1092 return;
1093
1094 local_irq_save_hw(flags);
1095 /* Enable the PLL Wakeup bit in SIC IWR */
1096 iwr0 = bfin_read32(SIC_IWR0);
1097 iwr1 = bfin_read32(SIC_IWR1);
1098 /* Only allow PPL Wakeup) */
1099 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
1100 bfin_write32(SIC_IWR1, 0);
1101
1102 bfin_write16(VR_CTL, val);
1103 SSYNC();
1104 asm("IDLE;");
1105
1106 bfin_write32(SIC_IWR0, iwr0);
1107 bfin_write32(SIC_IWR1, iwr1);
1108 local_irq_restore_hw(flags);
1109}
1110
1111#endif /* _CDEF_BF52X_H */ 1061#endif /* _CDEF_BF52X_H */
diff --git a/arch/blackfin/mach-bf518/include/mach/defBF51x_base.h b/arch/blackfin/mach-bf518/include/mach/defBF51x_base.h
index 037a51fd8e93..5f84913dcd91 100644
--- a/arch/blackfin/mach-bf518/include/mach/defBF51x_base.h
+++ b/arch/blackfin/mach-bf518/include/mach/defBF51x_base.h
@@ -748,51 +748,6 @@
748#define FFE 0x20 /* Force Framing Error On Transmit */ 748#define FFE 0x20 /* Force Framing Error On Transmit */
749 749
750 750
751/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS ****************************/
752/* SPI_CTL Masks */
753#define TIMOD 0x0003 /* Transfer Initiate Mode */
754#define RDBR_CORE 0x0000 /* RDBR Read Initiates, IRQ When RDBR Full */
755#define TDBR_CORE 0x0001 /* TDBR Write Initiates, IRQ When TDBR Empty */
756#define RDBR_DMA 0x0002 /* DMA Read, DMA Until FIFO Empty */
757#define TDBR_DMA 0x0003 /* DMA Write, DMA Until FIFO Full */
758#define SZ 0x0004 /* Send Zero (When TDBR Empty, Send Zero/Last*) */
759#define GM 0x0008 /* Get More (When RDBR Full, Overwrite/Discard*) */
760#define PSSE 0x0010 /* Slave-Select Input Enable */
761#define EMISO 0x0020 /* Enable MISO As Output */
762#define SIZE 0x0100 /* Size of Words (16/8* Bits) */
763#define LSBF 0x0200 /* LSB First */
764#define CPHA 0x0400 /* Clock Phase */
765#define CPOL 0x0800 /* Clock Polarity */
766#define MSTR 0x1000 /* Master/Slave* */
767#define WOM 0x2000 /* Write Open Drain Master */
768#define SPE 0x4000 /* SPI Enable */
769
770/* SPI_FLG Masks */
771#define FLS1 0x0002 /* Enables SPI_FLOUT1 as SPI Slave-Select Output */
772#define FLS2 0x0004 /* Enables SPI_FLOUT2 as SPI Slave-Select Output */
773#define FLS3 0x0008 /* Enables SPI_FLOUT3 as SPI Slave-Select Output */
774#define FLS4 0x0010 /* Enables SPI_FLOUT4 as SPI Slave-Select Output */
775#define FLS5 0x0020 /* Enables SPI_FLOUT5 as SPI Slave-Select Output */
776#define FLS6 0x0040 /* Enables SPI_FLOUT6 as SPI Slave-Select Output */
777#define FLS7 0x0080 /* Enables SPI_FLOUT7 as SPI Slave-Select Output */
778#define FLG1 0xFDFF /* Activates SPI_FLOUT1 */
779#define FLG2 0xFBFF /* Activates SPI_FLOUT2 */
780#define FLG3 0xF7FF /* Activates SPI_FLOUT3 */
781#define FLG4 0xEFFF /* Activates SPI_FLOUT4 */
782#define FLG5 0xDFFF /* Activates SPI_FLOUT5 */
783#define FLG6 0xBFFF /* Activates SPI_FLOUT6 */
784#define FLG7 0x7FFF /* Activates SPI_FLOUT7 */
785
786/* SPI_STAT Masks */
787#define SPIF 0x0001 /* SPI Finished (Single-Word Transfer Complete) */
788#define MODF 0x0002 /* Mode Fault Error (Another Device Tried To Become Master) */
789#define TXE 0x0004 /* Transmission Error (Data Sent With No New Data In TDBR) */
790#define TXS 0x0008 /* SPI_TDBR Data Buffer Status (Full/Empty*) */
791#define RBSY 0x0010 /* Receive Error (Data Received With RDBR Full) */
792#define RXS 0x0020 /* SPI_RDBR Data Buffer Status (Full/Empty*) */
793#define TXCOL 0x0040 /* Transmit Collision Error (Corrupt Data May Have Been Sent) */
794
795
796/* **************** GENERAL PURPOSE TIMER MASKS **********************/ 751/* **************** GENERAL PURPOSE TIMER MASKS **********************/
797/* TIMER_ENABLE Masks */ 752/* TIMER_ENABLE Masks */
798#define TIMEN0 0x0001 /* Enable Timer 0 */ 753#define TIMEN0 0x0001 /* Enable Timer 0 */
diff --git a/arch/blackfin/mach-bf518/include/mach/pll.h b/arch/blackfin/mach-bf518/include/mach/pll.h
new file mode 100644
index 000000000000..d5502988896b
--- /dev/null
+++ b/arch/blackfin/mach-bf518/include/mach/pll.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr0, iwr1;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr0 = bfin_read32(SIC_IWR0);
24 iwr1 = bfin_read32(SIC_IWR1);
25 /* Only allow PPL Wakeup) */
26 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
27 bfin_write32(SIC_IWR1, 0);
28
29 bfin_write16(PLL_CTL, val);
30 SSYNC();
31 asm("IDLE;");
32
33 bfin_write32(SIC_IWR0, iwr0);
34 bfin_write32(SIC_IWR1, iwr1);
35 hard_local_irq_restore(flags);
36}
37
38/* Writing to VR_CTL initiates a PLL relock sequence. */
39static __inline__ void bfin_write_VR_CTL(unsigned int val)
40{
41 unsigned long flags, iwr0, iwr1;
42
43 if (val == bfin_read_VR_CTL())
44 return;
45
46 flags = hard_local_irq_save();
47 /* Enable the PLL Wakeup bit in SIC IWR */
48 iwr0 = bfin_read32(SIC_IWR0);
49 iwr1 = bfin_read32(SIC_IWR1);
50 /* Only allow PPL Wakeup) */
51 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
52 bfin_write32(SIC_IWR1, 0);
53
54 bfin_write16(VR_CTL, val);
55 SSYNC();
56 asm("IDLE;");
57
58 bfin_write32(SIC_IWR0, iwr0);
59 bfin_write32(SIC_IWR1, iwr1);
60 hard_local_irq_restore(flags);
61}
62
63#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf527/boards/Kconfig b/arch/blackfin/mach-bf527/boards/Kconfig
index b14c28810a44..1cc2667c10f1 100644
--- a/arch/blackfin/mach-bf527/boards/Kconfig
+++ b/arch/blackfin/mach-bf527/boards/Kconfig
@@ -24,4 +24,14 @@ config BFIN526_EZBRD
24 help 24 help
25 BF526-EZBRD/EZKIT Lite board support. 25 BF526-EZBRD/EZKIT Lite board support.
26 26
27config BFIN527_AD7160EVAL
28 bool "BF527-AD7160-EVAL"
29 help
30 BF527-AD7160-EVAL board support.
31
32config BFIN527_TLL6527M
33 bool "The Learning Labs TLL6527M"
34 help
35 TLL6527M V1.0 platform support
36
27endchoice 37endchoice
diff --git a/arch/blackfin/mach-bf527/boards/Makefile b/arch/blackfin/mach-bf527/boards/Makefile
index 51a5817c4a90..1d67da9f05ac 100644
--- a/arch/blackfin/mach-bf527/boards/Makefile
+++ b/arch/blackfin/mach-bf527/boards/Makefile
@@ -6,3 +6,5 @@ obj-$(CONFIG_BFIN527_EZKIT) += ezkit.o
6obj-$(CONFIG_BFIN527_EZKIT_V2) += ezkit.o 6obj-$(CONFIG_BFIN527_EZKIT_V2) += ezkit.o
7obj-$(CONFIG_BFIN527_BLUETECHNIX_CM) += cm_bf527.o 7obj-$(CONFIG_BFIN527_BLUETECHNIX_CM) += cm_bf527.o
8obj-$(CONFIG_BFIN526_EZBRD) += ezbrd.o 8obj-$(CONFIG_BFIN526_EZBRD) += ezbrd.o
9obj-$(CONFIG_BFIN527_AD7160EVAL) += ad7160eval.o
10obj-$(CONFIG_BFIN527_TLL6527M) += tll6527m.o
diff --git a/arch/blackfin/mach-bf527/boards/ad7160eval.c b/arch/blackfin/mach-bf527/boards/ad7160eval.c
new file mode 100644
index 000000000000..fc767ac76381
--- /dev/null
+++ b/arch/blackfin/mach-bf527/boards/ad7160eval.c
@@ -0,0 +1,870 @@
1/*
2 * Copyright 2004-20010 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/device.h>
10#include <linux/platform_device.h>
11#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
13#include <linux/mtd/physmap.h>
14#include <linux/spi/spi.h>
15#include <linux/spi/flash.h>
16#include <linux/i2c.h>
17#include <linux/irq.h>
18#include <linux/interrupt.h>
19#include <linux/usb/musb.h>
20#include <linux/leds.h>
21#include <linux/input.h>
22#include <asm/dma.h>
23#include <asm/bfin5xx_spi.h>
24#include <asm/reboot.h>
25#include <asm/nand.h>
26#include <asm/portmux.h>
27#include <asm/dpmc.h>
28
29
30/*
31 * Name the Board for the /proc/cpuinfo
32 */
33const char bfin_board_name[] = "ADI BF527-AD7160EVAL";
34
35/*
36 * Driver needs to know address, irq and flag pin.
37 */
38
39#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
40static struct resource musb_resources[] = {
41 [0] = {
42 .start = 0xffc03800,
43 .end = 0xffc03cff,
44 .flags = IORESOURCE_MEM,
45 },
46 [1] = { /* general IRQ */
47 .start = IRQ_USB_INT0,
48 .end = IRQ_USB_INT0,
49 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
50 },
51 [2] = { /* DMA IRQ */
52 .start = IRQ_USB_DMA,
53 .end = IRQ_USB_DMA,
54 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
55 },
56};
57
58static struct musb_hdrc_config musb_config = {
59 .multipoint = 0,
60 .dyn_fifo = 0,
61 .soft_con = 1,
62 .dma = 1,
63 .num_eps = 8,
64 .dma_channels = 8,
65 .gpio_vrsel = GPIO_PG13,
66 /* Some custom boards need to be active low, just set it to "0"
67 * if it is the case.
68 */
69 .gpio_vrsel_active = 1,
70};
71
72static struct musb_hdrc_platform_data musb_plat = {
73#if defined(CONFIG_USB_MUSB_OTG)
74 .mode = MUSB_OTG,
75#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
76 .mode = MUSB_HOST,
77#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
78 .mode = MUSB_PERIPHERAL,
79#endif
80 .config = &musb_config,
81};
82
83static u64 musb_dmamask = ~(u32)0;
84
85static struct platform_device musb_device = {
86 .name = "musb_hdrc",
87 .id = 0,
88 .dev = {
89 .dma_mask = &musb_dmamask,
90 .coherent_dma_mask = 0xffffffff,
91 .platform_data = &musb_plat,
92 },
93 .num_resources = ARRAY_SIZE(musb_resources),
94 .resource = musb_resources,
95};
96#endif
97
98#if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE)
99static struct resource bf52x_ra158z_resources[] = {
100 {
101 .start = IRQ_PPI_ERROR,
102 .end = IRQ_PPI_ERROR,
103 .flags = IORESOURCE_IRQ,
104 },
105};
106
107static struct platform_device bf52x_ra158z_device = {
108 .name = "bfin-ra158z",
109 .id = -1,
110 .num_resources = ARRAY_SIZE(bf52x_ra158z_resources),
111 .resource = bf52x_ra158z_resources,
112};
113#endif
114
115#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
116static struct mtd_partition ad7160eval_partitions[] = {
117 {
118 .name = "bootloader(nor)",
119 .size = 0x40000,
120 .offset = 0,
121 }, {
122 .name = "linux kernel(nor)",
123 .size = 0x1C0000,
124 .offset = MTDPART_OFS_APPEND,
125 }, {
126 .name = "file system(nor)",
127 .size = MTDPART_SIZ_FULL,
128 .offset = MTDPART_OFS_APPEND,
129 }
130};
131
132static struct physmap_flash_data ad7160eval_flash_data = {
133 .width = 2,
134 .parts = ad7160eval_partitions,
135 .nr_parts = ARRAY_SIZE(ad7160eval_partitions),
136};
137
138static struct resource ad7160eval_flash_resource = {
139 .start = 0x20000000,
140 .end = 0x203fffff,
141 .flags = IORESOURCE_MEM,
142};
143
144static struct platform_device ad7160eval_flash_device = {
145 .name = "physmap-flash",
146 .id = 0,
147 .dev = {
148 .platform_data = &ad7160eval_flash_data,
149 },
150 .num_resources = 1,
151 .resource = &ad7160eval_flash_resource,
152};
153#endif
154
155#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
156static struct mtd_partition partition_info[] = {
157 {
158 .name = "linux kernel(nand)",
159 .offset = 0,
160 .size = 4 * 1024 * 1024,
161 },
162 {
163 .name = "file system(nand)",
164 .offset = MTDPART_OFS_APPEND,
165 .size = MTDPART_SIZ_FULL,
166 },
167};
168
169static struct bf5xx_nand_platform bf5xx_nand_platform = {
170 .data_width = NFC_NWIDTH_8,
171 .partitions = partition_info,
172 .nr_partitions = ARRAY_SIZE(partition_info),
173 .rd_dly = 3,
174 .wr_dly = 3,
175};
176
177static struct resource bf5xx_nand_resources[] = {
178 {
179 .start = NFC_CTL,
180 .end = NFC_DATA_RD + 2,
181 .flags = IORESOURCE_MEM,
182 },
183 {
184 .start = CH_NFC,
185 .end = CH_NFC,
186 .flags = IORESOURCE_IRQ,
187 },
188};
189
190static struct platform_device bf5xx_nand_device = {
191 .name = "bf5xx-nand",
192 .id = 0,
193 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
194 .resource = bf5xx_nand_resources,
195 .dev = {
196 .platform_data = &bf5xx_nand_platform,
197 },
198};
199#endif
200
201#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
202static struct platform_device rtc_device = {
203 .name = "rtc-bfin",
204 .id = -1,
205};
206#endif
207
208#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
209#include <linux/bfin_mac.h>
210static const unsigned short bfin_mac_peripherals[] = P_RMII0;
211
212static struct bfin_phydev_platform_data bfin_phydev_data[] = {
213 {
214 .addr = 1,
215 .irq = IRQ_MAC_PHYINT,
216 },
217};
218
219static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
220 .phydev_number = 1,
221 .phydev_data = bfin_phydev_data,
222 .phy_mode = PHY_INTERFACE_MODE_RMII,
223 .mac_peripherals = bfin_mac_peripherals,
224};
225
226static struct platform_device bfin_mii_bus = {
227 .name = "bfin_mii_bus",
228 .dev = {
229 .platform_data = &bfin_mii_bus_data,
230 }
231};
232
233static struct platform_device bfin_mac_device = {
234 .name = "bfin_mac",
235 .dev = {
236 .platform_data = &bfin_mii_bus,
237 }
238};
239#endif
240
241
242#if defined(CONFIG_MTD_M25P80) \
243 || defined(CONFIG_MTD_M25P80_MODULE)
244static struct mtd_partition bfin_spi_flash_partitions[] = {
245 {
246 .name = "bootloader(spi)",
247 .size = 0x00040000,
248 .offset = 0,
249 .mask_flags = MTD_CAP_ROM
250 }, {
251 .name = "linux kernel(spi)",
252 .size = MTDPART_SIZ_FULL,
253 .offset = MTDPART_OFS_APPEND,
254 }
255};
256
257static struct flash_platform_data bfin_spi_flash_data = {
258 .name = "m25p80",
259 .parts = bfin_spi_flash_partitions,
260 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
261 .type = "m25p16",
262};
263
264/* SPI flash chip (m25p64) */
265static struct bfin5xx_spi_chip spi_flash_chip_info = {
266 .enable_dma = 0, /* use dma transfer with this chip*/
267 .bits_per_word = 8,
268};
269#endif
270
271#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
272 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
273static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
274 .enable_dma = 0,
275 .bits_per_word = 16,
276};
277#endif
278
279#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
280static struct bfin5xx_spi_chip mmc_spi_chip_info = {
281 .enable_dma = 0,
282 .bits_per_word = 8,
283};
284#endif
285
286#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
287static struct bfin5xx_spi_chip spidev_chip_info = {
288 .enable_dma = 0,
289 .bits_per_word = 8,
290};
291#endif
292
293#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
294static struct platform_device bfin_i2s = {
295 .name = "bfin-i2s",
296 .id = CONFIG_SND_BF5XX_SPORT_NUM,
297 /* TODO: add platform data here */
298};
299#endif
300
301#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
302static struct platform_device bfin_tdm = {
303 .name = "bfin-tdm",
304 .id = CONFIG_SND_BF5XX_SPORT_NUM,
305 /* TODO: add platform data here */
306};
307#endif
308
309static struct spi_board_info bfin_spi_board_info[] __initdata = {
310#if defined(CONFIG_MTD_M25P80) \
311 || defined(CONFIG_MTD_M25P80_MODULE)
312 {
313 /* the modalias must be the same as spi device driver name */
314 .modalias = "m25p80", /* Name of spi_driver for this device */
315 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
316 .bus_num = 0, /* Framework bus number */
317 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
318 .platform_data = &bfin_spi_flash_data,
319 .controller_data = &spi_flash_chip_info,
320 .mode = SPI_MODE_3,
321 },
322#endif
323#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
324 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
325 {
326 .modalias = "ad183x",
327 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
328 .bus_num = 0,
329 .chip_select = 4,
330 .controller_data = &ad1836_spi_chip_info,
331 },
332#endif
333#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
334 {
335 .modalias = "mmc_spi",
336 .max_speed_hz = 30000000, /* max spi clock (SCK) speed in HZ */
337 .bus_num = 0,
338 .chip_select = GPIO_PH3 + MAX_CTRL_CS,
339 .controller_data = &mmc_spi_chip_info,
340 .mode = SPI_MODE_3,
341 },
342#endif
343#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
344 {
345 .modalias = "spidev",
346 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
347 .bus_num = 0,
348 .chip_select = 1,
349 .controller_data = &spidev_chip_info,
350 },
351#endif
352};
353
354#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
355/* SPI controller data */
356static struct bfin5xx_spi_master bfin_spi0_info = {
357 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
358 .enable_dma = 1, /* master has the ability to do dma transfer */
359 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
360};
361
362/* SPI (0) */
363static struct resource bfin_spi0_resource[] = {
364 [0] = {
365 .start = SPI0_REGBASE,
366 .end = SPI0_REGBASE + 0xFF,
367 .flags = IORESOURCE_MEM,
368 },
369 [1] = {
370 .start = CH_SPI,
371 .end = CH_SPI,
372 .flags = IORESOURCE_DMA,
373 },
374 [2] = {
375 .start = IRQ_SPI,
376 .end = IRQ_SPI,
377 .flags = IORESOURCE_IRQ,
378 },
379};
380
381static struct platform_device bfin_spi0_device = {
382 .name = "bfin-spi",
383 .id = 0, /* Bus number */
384 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
385 .resource = bfin_spi0_resource,
386 .dev = {
387 .platform_data = &bfin_spi0_info, /* Passed to driver */
388 },
389};
390#endif /* spi master and devices */
391
392#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
393#ifdef CONFIG_SERIAL_BFIN_UART0
394static struct resource bfin_uart0_resources[] = {
395 {
396 .start = UART0_THR,
397 .end = UART0_GCTL+2,
398 .flags = IORESOURCE_MEM,
399 },
400 {
401 .start = IRQ_UART0_RX,
402 .end = IRQ_UART0_RX+1,
403 .flags = IORESOURCE_IRQ,
404 },
405 {
406 .start = IRQ_UART0_ERROR,
407 .end = IRQ_UART0_ERROR,
408 .flags = IORESOURCE_IRQ,
409 },
410 {
411 .start = CH_UART0_TX,
412 .end = CH_UART0_TX,
413 .flags = IORESOURCE_DMA,
414 },
415 {
416 .start = CH_UART0_RX,
417 .end = CH_UART0_RX,
418 .flags = IORESOURCE_DMA,
419 },
420};
421
422unsigned short bfin_uart0_peripherals[] = {
423 P_UART0_TX, P_UART0_RX, 0
424};
425
426static struct platform_device bfin_uart0_device = {
427 .name = "bfin-uart",
428 .id = 0,
429 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
430 .resource = bfin_uart0_resources,
431 .dev = {
432 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
433 },
434};
435#endif
436#ifdef CONFIG_SERIAL_BFIN_UART1
437static struct resource bfin_uart1_resources[] = {
438 {
439 .start = UART1_THR,
440 .end = UART1_GCTL+2,
441 .flags = IORESOURCE_MEM,
442 },
443 {
444 .start = IRQ_UART1_RX,
445 .end = IRQ_UART1_RX+1,
446 .flags = IORESOURCE_IRQ,
447 },
448 {
449 .start = IRQ_UART1_ERROR,
450 .end = IRQ_UART1_ERROR,
451 .flags = IORESOURCE_IRQ,
452 },
453 {
454 .start = CH_UART1_TX,
455 .end = CH_UART1_TX,
456 .flags = IORESOURCE_DMA,
457 },
458 {
459 .start = CH_UART1_RX,
460 .end = CH_UART1_RX,
461 .flags = IORESOURCE_DMA,
462 },
463#ifdef CONFIG_BFIN_UART1_CTSRTS
464 { /* CTS pin */
465 .start = GPIO_PF9,
466 .end = GPIO_PF9,
467 .flags = IORESOURCE_IO,
468 },
469 { /* RTS pin */
470 .start = GPIO_PF10,
471 .end = GPIO_PF10,
472 .flags = IORESOURCE_IO,
473 },
474#endif
475};
476
477unsigned short bfin_uart1_peripherals[] = {
478 P_UART1_TX, P_UART1_RX, 0
479};
480
481static struct platform_device bfin_uart1_device = {
482 .name = "bfin-uart",
483 .id = 1,
484 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
485 .resource = bfin_uart1_resources,
486 .dev = {
487 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
488 },
489};
490#endif
491#endif
492
493#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
494#ifdef CONFIG_BFIN_SIR0
495static struct resource bfin_sir0_resources[] = {
496 {
497 .start = 0xFFC00400,
498 .end = 0xFFC004FF,
499 .flags = IORESOURCE_MEM,
500 },
501 {
502 .start = IRQ_UART0_RX,
503 .end = IRQ_UART0_RX+1,
504 .flags = IORESOURCE_IRQ,
505 },
506 {
507 .start = CH_UART0_RX,
508 .end = CH_UART0_RX+1,
509 .flags = IORESOURCE_DMA,
510 },
511};
512
513static struct platform_device bfin_sir0_device = {
514 .name = "bfin_sir",
515 .id = 0,
516 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
517 .resource = bfin_sir0_resources,
518};
519#endif
520#ifdef CONFIG_BFIN_SIR1
521static struct resource bfin_sir1_resources[] = {
522 {
523 .start = 0xFFC02000,
524 .end = 0xFFC020FF,
525 .flags = IORESOURCE_MEM,
526 },
527 {
528 .start = IRQ_UART1_RX,
529 .end = IRQ_UART1_RX+1,
530 .flags = IORESOURCE_IRQ,
531 },
532 {
533 .start = CH_UART1_RX,
534 .end = CH_UART1_RX+1,
535 .flags = IORESOURCE_DMA,
536 },
537};
538
539static struct platform_device bfin_sir1_device = {
540 .name = "bfin_sir",
541 .id = 1,
542 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
543 .resource = bfin_sir1_resources,
544};
545#endif
546#endif
547
548#if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
549#include <linux/input/ad7160.h>
550static const struct ad7160_platform_data bfin_ad7160_ts_info = {
551 .sensor_x_res = 854,
552 .sensor_y_res = 480,
553 .pressure = 100,
554 .filter_coef = 3,
555 .coord_pref = AD7160_ORIG_TOP_LEFT,
556 .first_touch_window = 5,
557 .move_window = 3,
558 .event_cabs = AD7160_EMIT_ABS_MT_TRACKING_ID |
559 AD7160_EMIT_ABS_MT_PRESSURE |
560 AD7160_TRACKING_ID_ASCENDING,
561 .finger_act_ctrl = 0x64,
562 .haptic_effect1_ctrl = AD7160_HAPTIC_SLOT_A(60) |
563 AD7160_HAPTIC_SLOT_A_LVL_HIGH |
564 AD7160_HAPTIC_SLOT_B(60) |
565 AD7160_HAPTIC_SLOT_B_LVL_LOW,
566
567 .haptic_effect2_ctrl = AD7160_HAPTIC_SLOT_A(20) |
568 AD7160_HAPTIC_SLOT_A_LVL_HIGH |
569 AD7160_HAPTIC_SLOT_B(80) |
570 AD7160_HAPTIC_SLOT_B_LVL_LOW |
571 AD7160_HAPTIC_SLOT_C(120) |
572 AD7160_HAPTIC_SLOT_C_LVL_HIGH |
573 AD7160_HAPTIC_SLOT_D(30) |
574 AD7160_HAPTIC_SLOT_D_LVL_LOW,
575};
576#endif
577
578#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
579static struct resource bfin_twi0_resource[] = {
580 [0] = {
581 .start = TWI0_REGBASE,
582 .end = TWI0_REGBASE,
583 .flags = IORESOURCE_MEM,
584 },
585 [1] = {
586 .start = IRQ_TWI,
587 .end = IRQ_TWI,
588 .flags = IORESOURCE_IRQ,
589 },
590};
591
592static struct platform_device i2c_bfin_twi_device = {
593 .name = "i2c-bfin-twi",
594 .id = 0,
595 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
596 .resource = bfin_twi0_resource,
597};
598#endif
599
600static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
601#if defined(CONFIG_TOUCHSCREEN_AD7160) || defined(CONFIG_TOUCHSCREEN_AD7160_MODULE)
602 {
603 I2C_BOARD_INFO("ad7160", 0x33),
604 .irq = IRQ_PH1,
605 .platform_data = (void *)&bfin_ad7160_ts_info,
606 },
607#endif
608};
609
610#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
611#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
612static struct resource bfin_sport0_uart_resources[] = {
613 {
614 .start = SPORT0_TCR1,
615 .end = SPORT0_MRCS3+4,
616 .flags = IORESOURCE_MEM,
617 },
618 {
619 .start = IRQ_SPORT0_RX,
620 .end = IRQ_SPORT0_RX+1,
621 .flags = IORESOURCE_IRQ,
622 },
623 {
624 .start = IRQ_SPORT0_ERROR,
625 .end = IRQ_SPORT0_ERROR,
626 .flags = IORESOURCE_IRQ,
627 },
628};
629
630unsigned short bfin_sport0_peripherals[] = {
631 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
632 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
633};
634
635static struct platform_device bfin_sport0_uart_device = {
636 .name = "bfin-sport-uart",
637 .id = 0,
638 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
639 .resource = bfin_sport0_uart_resources,
640 .dev = {
641 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
642 },
643};
644#endif
645#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
646static struct resource bfin_sport1_uart_resources[] = {
647 {
648 .start = SPORT1_TCR1,
649 .end = SPORT1_MRCS3+4,
650 .flags = IORESOURCE_MEM,
651 },
652 {
653 .start = IRQ_SPORT1_RX,
654 .end = IRQ_SPORT1_RX+1,
655 .flags = IORESOURCE_IRQ,
656 },
657 {
658 .start = IRQ_SPORT1_ERROR,
659 .end = IRQ_SPORT1_ERROR,
660 .flags = IORESOURCE_IRQ,
661 },
662};
663
664unsigned short bfin_sport1_peripherals[] = {
665 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
666 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
667};
668
669static struct platform_device bfin_sport1_uart_device = {
670 .name = "bfin-sport-uart",
671 .id = 1,
672 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
673 .resource = bfin_sport1_uart_resources,
674 .dev = {
675 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
676 },
677};
678#endif
679#endif
680
681#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
682#include <asm/bfin_rotary.h>
683
684static struct bfin_rotary_platform_data bfin_rotary_data = {
685 /*.rotary_up_key = KEY_UP,*/
686 /*.rotary_down_key = KEY_DOWN,*/
687 .rotary_rel_code = REL_WHEEL,
688 .rotary_button_key = KEY_ENTER,
689 .debounce = 10, /* 0..17 */
690 .mode = ROT_QUAD_ENC | ROT_DEBE,
691};
692
693static struct resource bfin_rotary_resources[] = {
694 {
695 .start = IRQ_CNT,
696 .end = IRQ_CNT,
697 .flags = IORESOURCE_IRQ,
698 },
699};
700
701static struct platform_device bfin_rotary_device = {
702 .name = "bfin-rotary",
703 .id = -1,
704 .num_resources = ARRAY_SIZE(bfin_rotary_resources),
705 .resource = bfin_rotary_resources,
706 .dev = {
707 .platform_data = &bfin_rotary_data,
708 },
709};
710#endif
711
712static const unsigned int cclk_vlev_datasheet[] = {
713 VRPAIR(VLEV_100, 400000000),
714 VRPAIR(VLEV_105, 426000000),
715 VRPAIR(VLEV_110, 500000000),
716 VRPAIR(VLEV_115, 533000000),
717 VRPAIR(VLEV_120, 600000000),
718};
719
720static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
721 .tuple_tab = cclk_vlev_datasheet,
722 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
723 .vr_settling_time = 25 /* us */,
724};
725
726static struct platform_device bfin_dpmc = {
727 .name = "bfin dpmc",
728 .dev = {
729 .platform_data = &bfin_dmpc_vreg_data,
730 },
731};
732
733static struct platform_device *stamp_devices[] __initdata = {
734
735 &bfin_dpmc,
736
737#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
738 &bf5xx_nand_device,
739#endif
740
741#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
742 &rtc_device,
743#endif
744
745#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
746 &musb_device,
747#endif
748
749#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
750 &bfin_mii_bus,
751 &bfin_mac_device,
752#endif
753
754#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
755 &bfin_spi0_device,
756#endif
757
758#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
759#ifdef CONFIG_SERIAL_BFIN_UART0
760 &bfin_uart0_device,
761#endif
762#ifdef CONFIG_SERIAL_BFIN_UART1
763 &bfin_uart1_device,
764#endif
765#endif
766
767#if defined(CONFIG_FB_BFIN_RA158Z) || defined(CONFIG_FB_BFIN_RA158Z_MODULE)
768 &bf52x_ra158z_device,
769#endif
770
771#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
772#ifdef CONFIG_BFIN_SIR0
773 &bfin_sir0_device,
774#endif
775#ifdef CONFIG_BFIN_SIR1
776 &bfin_sir1_device,
777#endif
778#endif
779
780#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
781 &i2c_bfin_twi_device,
782#endif
783
784#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
785#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
786 &bfin_sport0_uart_device,
787#endif
788#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
789 &bfin_sport1_uart_device,
790#endif
791#endif
792
793#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
794 &bfin_rotary_device,
795#endif
796
797#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
798 &ad7160eval_flash_device,
799#endif
800
801#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
802 &bfin_i2s,
803#endif
804
805#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
806 &bfin_tdm,
807#endif
808};
809
810static int __init ad7160eval_init(void)
811{
812 printk(KERN_INFO "%s(): registering device resources\n", __func__);
813 i2c_register_board_info(0, bfin_i2c_board_info,
814 ARRAY_SIZE(bfin_i2c_board_info));
815 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
816 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
817 return 0;
818}
819
820arch_initcall(ad7160eval_init);
821
822static struct platform_device *ad7160eval_early_devices[] __initdata = {
823#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
824#ifdef CONFIG_SERIAL_BFIN_UART0
825 &bfin_uart0_device,
826#endif
827#ifdef CONFIG_SERIAL_BFIN_UART1
828 &bfin_uart1_device,
829#endif
830#endif
831
832#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
833#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
834 &bfin_sport0_uart_device,
835#endif
836#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
837 &bfin_sport1_uart_device,
838#endif
839#endif
840};
841
842void __init native_machine_early_platform_add_devices(void)
843{
844 printk(KERN_INFO "register early platform devices\n");
845 early_platform_add_devices(ad7160eval_early_devices,
846 ARRAY_SIZE(ad7160eval_early_devices));
847}
848
849void native_machine_restart(char *cmd)
850{
851 /* workaround reboot hang when booting from SPI */
852 if ((bfin_read_SYSCR() & 0x7) == 0x3)
853 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
854}
855
856void bfin_get_ether_addr(char *addr)
857{
858 /* the MAC is stored in OTP memory page 0xDF */
859 u32 ret;
860 u64 otp_mac;
861 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
862
863 ret = otp_read(0xDF, 0x00, &otp_mac);
864 if (!(ret & 0x1)) {
865 char *otp_mac_p = (char *)&otp_mac;
866 for (ret = 0; ret < 6; ++ret)
867 addr[ret] = otp_mac_p[5 - ret];
868 }
869}
870EXPORT_SYMBOL(bfin_get_ether_addr);
diff --git a/arch/blackfin/mach-bf527/boards/cm_bf527.c b/arch/blackfin/mach-bf527/boards/cm_bf527.c
index 645ba5c8077b..38037c7e125a 100644
--- a/arch/blackfin/mach-bf527/boards/cm_bf527.c
+++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c
@@ -342,8 +342,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
342}; 342};
343#endif 343#endif
344 344
345#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 345#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
346 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 346 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
347static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 347static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
348 .enable_dma = 0, 348 .enable_dma = 0,
349 .bits_per_word = 16, 349 .bits_per_word = 16,
@@ -420,13 +420,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
420 }, 420 },
421#endif 421#endif
422 422
423#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 423#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
424 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 424 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
425 { 425 {
426 .modalias = "ad1836", 426 .modalias = "ad183x",
427 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 427 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
428 .bus_num = 0, 428 .bus_num = 0,
429 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 429 .chip_select = 4,
430 .controller_data = &ad1836_spi_chip_info, 430 .controller_data = &ad1836_spi_chip_info,
431 }, 431 },
432#endif 432#endif
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index c975fe88eba3..6cc64a1e78b9 100644
--- a/arch/blackfin/mach-bf527/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf527/boards/ezbrd.c
@@ -137,8 +137,12 @@ static struct platform_device ezbrd_flash_device = {
137#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 137#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
138static struct mtd_partition partition_info[] = { 138static struct mtd_partition partition_info[] = {
139 { 139 {
140 .name = "linux kernel(nand)", 140 .name = "bootloader(nand)",
141 .offset = 0, 141 .offset = 0,
142 .size = 0x40000,
143 }, {
144 .name = "linux kernel(nand)",
145 .offset = MTDPART_OFS_APPEND,
142 .size = 4 * 1024 * 1024, 146 .size = 4 * 1024 * 1024,
143 }, 147 },
144 { 148 {
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 87b41e994ba3..df82723fb504 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -222,8 +222,12 @@ static struct platform_device ezkit_flash_device = {
222#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 222#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
223static struct mtd_partition partition_info[] = { 223static struct mtd_partition partition_info[] = {
224 { 224 {
225 .name = "linux kernel(nand)", 225 .name = "bootloader(nand)",
226 .offset = 0, 226 .offset = 0,
227 .size = 0x40000,
228 }, {
229 .name = "linux kernel(nand)",
230 .offset = MTDPART_OFS_APPEND,
227 .size = 4 * 1024 * 1024, 231 .size = 4 * 1024 * 1024,
228 }, 232 },
229 { 233 {
@@ -431,8 +435,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
431}; 435};
432#endif 436#endif
433 437
434#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 438#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
435 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 439 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
436static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 440static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
437 .enable_dma = 0, 441 .enable_dma = 0,
438 .bits_per_word = 16, 442 .bits_per_word = 16,
@@ -547,13 +551,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
547 }, 551 },
548#endif 552#endif
549 553
550#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 554#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
551 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 555 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
552 { 556 {
553 .modalias = "ad1836", 557 .modalias = "ad183x",
554 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 558 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
555 .bus_num = 0, 559 .bus_num = 0,
556 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 560 .chip_select = 4,
557 .controller_data = &ad1836_spi_chip_info, 561 .controller_data = &ad1836_spi_chip_info,
558 }, 562 },
559#endif 563#endif
@@ -883,7 +887,7 @@ static struct adp5520_keys_platform_data adp5520_keys_data = {
883}; 887};
884 888
885 /* 889 /*
886 * ADP5520/5501 Multifuction Device Init Data 890 * ADP5520/5501 Multifunction Device Init Data
887 */ 891 */
888 892
889static struct adp5520_platform_data adp5520_pdev_data = { 893static struct adp5520_platform_data adp5520_pdev_data = {
@@ -929,6 +933,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
929 I2C_BOARD_INFO("ssm2602", 0x1b), 933 I2C_BOARD_INFO("ssm2602", 0x1b),
930 }, 934 },
931#endif 935#endif
936#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
937 {
938 I2C_BOARD_INFO("ad5252", 0x2f),
939 },
940#endif
932}; 941};
933 942
934#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 943#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c
new file mode 100644
index 000000000000..ae4130e97c01
--- /dev/null
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -0,0 +1,986 @@
1/* File: arch/blackfin/mach-bf527/boards/tll6527m.c
2 * Based on: arch/blackfin/mach-bf527/boards/ezkit.c
3 * Author: Ashish Gupta
4 *
5 * Copyright: 2010 - The Learning Labs Inc.
6 *
7 * Licensed under the GPL-2 or later.
8 */
9
10#include <linux/device.h>
11#include <linux/platform_device.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/mtd/physmap.h>
15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h>
17#include <linux/i2c.h>
18#include <linux/irq.h>
19#include <linux/interrupt.h>
20#include <linux/usb/musb.h>
21#include <linux/leds.h>
22#include <linux/input.h>
23#include <asm/dma.h>
24#include <asm/bfin5xx_spi.h>
25#include <asm/reboot.h>
26#include <asm/nand.h>
27#include <asm/portmux.h>
28#include <asm/dpmc.h>
29
30#if defined(CONFIG_TOUCHSCREEN_AD7879) \
31 || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
32#include <linux/spi/ad7879.h>
33#define LCD_BACKLIGHT_GPIO 0x40
34/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
35 * LCD Backlight Enable
36 */
37#endif
38
39/*
40 * Name the Board for the /proc/cpuinfo
41 */
42const char bfin_board_name[] = "TLL6527M";
43/*
44 * Driver needs to know address, irq and flag pin.
45 */
46
47#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
48static struct resource musb_resources[] = {
49 [0] = {
50 .start = 0xffc03800,
51 .end = 0xffc03cff,
52 .flags = IORESOURCE_MEM,
53 },
54 [1] = { /* general IRQ */
55 .start = IRQ_USB_INT0,
56 .end = IRQ_USB_INT0,
57 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
58 },
59 [2] = { /* DMA IRQ */
60 .start = IRQ_USB_DMA,
61 .end = IRQ_USB_DMA,
62 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
63 },
64};
65
66static struct musb_hdrc_config musb_config = {
67 .multipoint = 0,
68 .dyn_fifo = 0,
69 .soft_con = 1,
70 .dma = 1,
71 .num_eps = 8,
72 .dma_channels = 8,
73 /*.gpio_vrsel = GPIO_PG13,*/
74 /* Some custom boards need to be active low, just set it to "0"
75 * if it is the case.
76 */
77 .gpio_vrsel_active = 1,
78};
79
80static struct musb_hdrc_platform_data musb_plat = {
81#if defined(CONFIG_USB_MUSB_OTG)
82 .mode = MUSB_OTG,
83#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
84 .mode = MUSB_HOST,
85#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
86 .mode = MUSB_PERIPHERAL,
87#endif
88 .config = &musb_config,
89};
90
91static u64 musb_dmamask = ~(u32)0;
92
93static struct platform_device musb_device = {
94 .name = "musb_hdrc",
95 .id = 0,
96 .dev = {
97 .dma_mask = &musb_dmamask,
98 .coherent_dma_mask = 0xffffffff,
99 .platform_data = &musb_plat,
100 },
101 .num_resources = ARRAY_SIZE(musb_resources),
102 .resource = musb_resources,
103};
104#endif
105
106#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
107#include <asm/bfin-lq035q1.h>
108
109static struct bfin_lq035q1fb_disp_info bfin_lq035q1_data = {
110 .mode = LQ035_NORM | LQ035_RGB | LQ035_RL | LQ035_TB,
111 .ppi_mode = USE_RGB565_16_BIT_PPI,
112 .use_bl = 1,
113 .gpio_bl = LCD_BACKLIGHT_GPIO,
114};
115
116static struct resource bfin_lq035q1_resources[] = {
117 {
118 .start = IRQ_PPI_ERROR,
119 .end = IRQ_PPI_ERROR,
120 .flags = IORESOURCE_IRQ,
121 },
122};
123
124static struct platform_device bfin_lq035q1_device = {
125 .name = "bfin-lq035q1",
126 .id = -1,
127 .num_resources = ARRAY_SIZE(bfin_lq035q1_resources),
128 .resource = bfin_lq035q1_resources,
129 .dev = {
130 .platform_data = &bfin_lq035q1_data,
131 },
132};
133#endif
134
135#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
136static struct mtd_partition tll6527m_partitions[] = {
137 {
138 .name = "bootloader(nor)",
139 .size = 0xA0000,
140 .offset = 0,
141 }, {
142 .name = "linux kernel(nor)",
143 .size = 0xD00000,
144 .offset = MTDPART_OFS_APPEND,
145 }, {
146 .name = "file system(nor)",
147 .size = MTDPART_SIZ_FULL,
148 .offset = MTDPART_OFS_APPEND,
149 }
150};
151
152static struct physmap_flash_data tll6527m_flash_data = {
153 .width = 2,
154 .parts = tll6527m_partitions,
155 .nr_parts = ARRAY_SIZE(tll6527m_partitions),
156};
157
158static unsigned tll6527m_flash_gpios[] = { GPIO_PG11, GPIO_PH11, GPIO_PH12 };
159
160static struct resource tll6527m_flash_resource[] = {
161 {
162 .name = "cfi_probe",
163 .start = 0x20000000,
164 .end = 0x201fffff,
165 .flags = IORESOURCE_MEM,
166 }, {
167 .start = (unsigned long)tll6527m_flash_gpios,
168 .end = ARRAY_SIZE(tll6527m_flash_gpios),
169 .flags = IORESOURCE_IRQ,
170 }
171};
172
173static struct platform_device tll6527m_flash_device = {
174 .name = "gpio-addr-flash",
175 .id = 0,
176 .dev = {
177 .platform_data = &tll6527m_flash_data,
178 },
179 .num_resources = ARRAY_SIZE(tll6527m_flash_resource),
180 .resource = tll6527m_flash_resource,
181};
182#endif
183
184#if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE)
185/* An SN74LVC138A 3:8 decoder chip has been used to generate 7 augmented
186 * outputs used as SPI CS lines for all SPI SLAVE devices on TLL6527v1-0.
187 * EXP_GPIO_SPISEL_BASE is the base number for the expanded outputs being
188 * used as SPI CS lines, this should be > MAX_BLACKFIN_GPIOS
189 */
190#include <linux/gpio-decoder.h>
191#define EXP_GPIO_SPISEL_BASE 0x64
192static unsigned gpio_addr_inputs[] = {
193 GPIO_PG1, GPIO_PH9, GPIO_PH10
194};
195
196static struct gpio_decoder_platfrom_data spi_decoded_cs = {
197 .base = EXP_GPIO_SPISEL_BASE,
198 .input_addrs = gpio_addr_inputs,
199 .nr_input_addrs = ARRAY_SIZE(gpio_addr_inputs),
200 .default_output = 0,
201/* .default_output = (1 << ARRAY_SIZE(gpio_addr_inputs)) - 1 */
202};
203
204static struct platform_device spi_decoded_gpio = {
205 .name = "gpio-decoder",
206 .id = 0,
207 .dev = {
208 .platform_data = &spi_decoded_cs,
209 },
210};
211
212#else
213#define EXP_GPIO_SPISEL_BASE 0x0
214
215#endif
216
217#if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)
218#include <linux/input/adxl34x.h>
219static const struct adxl34x_platform_data adxl345_info = {
220 .x_axis_offset = 0,
221 .y_axis_offset = 0,
222 .z_axis_offset = 0,
223 .tap_threshold = 0x31,
224 .tap_duration = 0x10,
225 .tap_latency = 0x60,
226 .tap_window = 0xF0,
227 .tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN,
228 .act_axis_control = 0xFF,
229 .activity_threshold = 5,
230 .inactivity_threshold = 2,
231 .inactivity_time = 2,
232 .free_fall_threshold = 0x7,
233 .free_fall_time = 0x20,
234 .data_rate = 0x8,
235 .data_range = ADXL_FULL_RES,
236
237 .ev_type = EV_ABS,
238 .ev_code_x = ABS_X, /* EV_REL */
239 .ev_code_y = ABS_Y, /* EV_REL */
240 .ev_code_z = ABS_Z, /* EV_REL */
241
242 .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */
243
244/* .ev_code_ff = KEY_F,*/ /* EV_KEY */
245 .ev_code_act_inactivity = KEY_A, /* EV_KEY */
246 .use_int2 = 1,
247 .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK,
248 .fifo_mode = ADXL_FIFO_STREAM,
249};
250#endif
251
252#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
253static struct platform_device rtc_device = {
254 .name = "rtc-bfin",
255 .id = -1,
256};
257#endif
258
259#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
260static struct platform_device bfin_mii_bus = {
261 .name = "bfin_mii_bus",
262};
263
264static struct platform_device bfin_mac_device = {
265 .name = "bfin_mac",
266 .dev.platform_data = &bfin_mii_bus,
267};
268#endif
269
270#if defined(CONFIG_MTD_M25P80) \
271 || defined(CONFIG_MTD_M25P80_MODULE)
272static struct mtd_partition bfin_spi_flash_partitions[] = {
273 {
274 .name = "bootloader(spi)",
275 .size = 0x00040000,
276 .offset = 0,
277 .mask_flags = MTD_CAP_ROM
278 }, {
279 .name = "linux kernel(spi)",
280 .size = MTDPART_SIZ_FULL,
281 .offset = MTDPART_OFS_APPEND,
282 }
283};
284
285static struct flash_platform_data bfin_spi_flash_data = {
286 .name = "m25p80",
287 .parts = bfin_spi_flash_partitions,
288 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
289 .type = "m25p16",
290};
291
292/* SPI flash chip (m25p64) */
293static struct bfin5xx_spi_chip spi_flash_chip_info = {
294 .enable_dma = 0, /* use dma transfer with this chip*/
295 .bits_per_word = 8,
296};
297#endif
298
299#if defined(CONFIG_BFIN_SPI_ADC) \
300 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
301/* SPI ADC chip */
302static struct bfin5xx_spi_chip spi_adc_chip_info = {
303 .enable_dma = 0, /* use dma transfer with this chip*/
304/*
305 * tll6527m V1.0 does not support native spi slave selects
306 * hence DMA mode will not be useful since the ADC needs
307 * CS to toggle for each sample and cs_change_per_word
308 * seems to be removed from spi_bfin5xx.c
309 */
310 .bits_per_word = 16,
311};
312#endif
313
314#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
315static struct bfin5xx_spi_chip mmc_spi_chip_info = {
316 .enable_dma = 0,
317 .bits_per_word = 8,
318};
319#endif
320
321#if defined(CONFIG_TOUCHSCREEN_AD7879) \
322 || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
323static const struct ad7879_platform_data bfin_ad7879_ts_info = {
324 .model = 7879, /* Model = AD7879 */
325 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
326 .pressure_max = 10000,
327 .pressure_min = 0,
328 .first_conversion_delay = 3,
329 /* wait 512us before do a first conversion */
330 .acquisition_time = 1, /* 4us acquisition time per sample */
331 .median = 2, /* do 8 measurements */
332 .averaging = 1,
333 /* take the average of 4 middle samples */
334 .pen_down_acc_interval = 255, /* 9.4 ms */
335 .gpio_export = 1, /* configure AUX as GPIO output*/
336 .gpio_base = LCD_BACKLIGHT_GPIO,
337};
338#endif
339
340#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
341 || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
342static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
343 .enable_dma = 0,
344 .bits_per_word = 16,
345};
346#endif
347
348#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
349static struct bfin5xx_spi_chip spidev_chip_info = {
350 .enable_dma = 0,
351 .bits_per_word = 8,
352};
353#endif
354
355#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
356static struct platform_device bfin_i2s = {
357 .name = "bfin-i2s",
358 .id = CONFIG_SND_BF5XX_SPORT_NUM,
359 /* TODO: add platform data here */
360};
361#endif
362
363#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
364static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
365 .enable_dma = 0,
366 .bits_per_word = 8,
367};
368#endif
369
370#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
371static struct bfin5xx_spi_chip spi_mcp23s08_sys_chip_info = {
372 .enable_dma = 0,
373 .bits_per_word = 8,
374};
375
376static struct bfin5xx_spi_chip spi_mcp23s08_usr_chip_info = {
377 .enable_dma = 0,
378 .bits_per_word = 8,
379};
380
381#include <linux/spi/mcp23s08.h>
382static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = {
383 .chip[0].is_present = true,
384 .base = 0x30,
385};
386static const struct mcp23s08_platform_data bfin_mcp23s08_usr_gpio_info = {
387 .chip[2].is_present = true,
388 .base = 0x38,
389};
390#endif
391
392static struct spi_board_info bfin_spi_board_info[] __initdata = {
393#if defined(CONFIG_MTD_M25P80) \
394 || defined(CONFIG_MTD_M25P80_MODULE)
395 {
396 /* the modalias must be the same as spi device driver name */
397 .modalias = "m25p80", /* Name of spi_driver for this device */
398 .max_speed_hz = 25000000,
399 /* max spi clock (SCK) speed in HZ */
400 .bus_num = 0, /* Framework bus number */
401 .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
402 /* Can be connected to TLL6527M GPIO connector */
403 /* Either SPI_ADC or M25P80 FLASH can be installed at a time */
404 .platform_data = &bfin_spi_flash_data,
405 .controller_data = &spi_flash_chip_info,
406 .mode = SPI_MODE_3,
407 },
408#endif
409
410#if defined(CONFIG_BFIN_SPI_ADC)
411 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
412 {
413 .modalias = "bfin_spi_adc",
414 /* Name of spi_driver for this device */
415 .max_speed_hz = 10000000,
416 /* max spi clock (SCK) speed in HZ */
417 .bus_num = 0, /* Framework bus number */
418 .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
419 /* Framework chip select. */
420 .platform_data = NULL, /* No spi_driver specific config */
421 .controller_data = &spi_adc_chip_info,
422 .mode = SPI_MODE_0,
423 },
424#endif
425
426#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
427 {
428 .modalias = "mmc_spi",
429/*
430 * TLL6527M V1.0 does not support SD Card at SPI Clock > 10 MHz due to
431 * SPI buffer limitations
432 */
433 .max_speed_hz = 10000000,
434 /* max spi clock (SCK) speed in HZ */
435 .bus_num = 0,
436 .chip_select = EXP_GPIO_SPISEL_BASE + 0x05 + MAX_CTRL_CS,
437 .controller_data = &mmc_spi_chip_info,
438 .mode = SPI_MODE_0,
439 },
440#endif
441#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
442 || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
443 {
444 .modalias = "ad7879",
445 .platform_data = &bfin_ad7879_ts_info,
446 .irq = IRQ_PH14,
447 .max_speed_hz = 5000000,
448 /* max spi clock (SCK) speed in HZ */
449 .bus_num = 0,
450 .chip_select = EXP_GPIO_SPISEL_BASE + 0x07 + MAX_CTRL_CS,
451 .controller_data = &spi_ad7879_chip_info,
452 .mode = SPI_CPHA | SPI_CPOL,
453 },
454#endif
455#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
456 {
457 .modalias = "spidev",
458 .max_speed_hz = 10000000,
459 /* TLL6527Mv1-0 supports max spi clock (SCK) speed = 10 MHz */
460 .bus_num = 0,
461 .chip_select = EXP_GPIO_SPISEL_BASE + 0x03 + MAX_CTRL_CS,
462 .mode = SPI_CPHA | SPI_CPOL,
463 .controller_data = &spidev_chip_info,
464 },
465#endif
466#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
467 {
468 .modalias = "bfin-lq035q1-spi",
469 .max_speed_hz = 20000000,
470 .bus_num = 0,
471 .chip_select = EXP_GPIO_SPISEL_BASE + 0x06 + MAX_CTRL_CS,
472 .controller_data = &lq035q1_spi_chip_info,
473 .mode = SPI_CPHA | SPI_CPOL,
474 },
475#endif
476#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
477 {
478 .modalias = "mcp23s08",
479 .platform_data = &bfin_mcp23s08_sys_gpio_info,
480 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
481 .bus_num = 0,
482 .chip_select = EXP_GPIO_SPISEL_BASE + 0x01 + MAX_CTRL_CS,
483 .controller_data = &spi_mcp23s08_sys_chip_info,
484 .mode = SPI_CPHA | SPI_CPOL,
485 },
486 {
487 .modalias = "mcp23s08",
488 .platform_data = &bfin_mcp23s08_usr_gpio_info,
489 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
490 .bus_num = 0,
491 .chip_select = EXP_GPIO_SPISEL_BASE + 0x02 + MAX_CTRL_CS,
492 .controller_data = &spi_mcp23s08_usr_chip_info,
493 .mode = SPI_CPHA | SPI_CPOL,
494 },
495#endif
496};
497
498#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
499/* SPI controller data */
500static struct bfin5xx_spi_master bfin_spi0_info = {
501 .num_chipselect = EXP_GPIO_SPISEL_BASE + 8 + MAX_CTRL_CS,
502 /* EXP_GPIO_SPISEL_BASE will be > MAX_BLACKFIN_GPIOS */
503 .enable_dma = 1, /* master has the ability to do dma transfer */
504 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
505};
506
507/* SPI (0) */
508static struct resource bfin_spi0_resource[] = {
509 [0] = {
510 .start = SPI0_REGBASE,
511 .end = SPI0_REGBASE + 0xFF,
512 .flags = IORESOURCE_MEM,
513 },
514 [1] = {
515 .start = CH_SPI,
516 .end = CH_SPI,
517 .flags = IORESOURCE_DMA,
518 },
519 [2] = {
520 .start = IRQ_SPI,
521 .end = IRQ_SPI,
522 .flags = IORESOURCE_IRQ,
523 },
524};
525
526static struct platform_device bfin_spi0_device = {
527 .name = "bfin-spi",
528 .id = 0, /* Bus number */
529 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
530 .resource = bfin_spi0_resource,
531 .dev = {
532 .platform_data = &bfin_spi0_info, /* Passed to driver */
533 },
534};
535#endif /* spi master and devices */
536
537#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
538#ifdef CONFIG_SERIAL_BFIN_UART0
539static struct resource bfin_uart0_resources[] = {
540 {
541 .start = UART0_THR,
542 .end = UART0_GCTL+2,
543 .flags = IORESOURCE_MEM,
544 },
545 {
546 .start = IRQ_UART0_RX,
547 .end = IRQ_UART0_RX+1,
548 .flags = IORESOURCE_IRQ,
549 },
550 {
551 .start = IRQ_UART0_ERROR,
552 .end = IRQ_UART0_ERROR,
553 .flags = IORESOURCE_IRQ,
554 },
555 {
556 .start = CH_UART0_TX,
557 .end = CH_UART0_TX,
558 .flags = IORESOURCE_DMA,
559 },
560 {
561 .start = CH_UART0_RX,
562 .end = CH_UART0_RX,
563 .flags = IORESOURCE_DMA,
564 },
565};
566
567unsigned short bfin_uart0_peripherals[] = {
568 P_UART0_TX, P_UART0_RX, 0
569};
570
571static struct platform_device bfin_uart0_device = {
572 .name = "bfin-uart",
573 .id = 0,
574 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
575 .resource = bfin_uart0_resources,
576 .dev = {
577 .platform_data = &bfin_uart0_peripherals,
578 /* Passed to driver */
579 },
580};
581#endif
582#ifdef CONFIG_SERIAL_BFIN_UART1
583static struct resource bfin_uart1_resources[] = {
584 {
585 .start = UART1_THR,
586 .end = UART1_GCTL+2,
587 .flags = IORESOURCE_MEM,
588 },
589 {
590 .start = IRQ_UART1_RX,
591 .end = IRQ_UART1_RX+1,
592 .flags = IORESOURCE_IRQ,
593 },
594 {
595 .start = IRQ_UART1_ERROR,
596 .end = IRQ_UART1_ERROR,
597 .flags = IORESOURCE_IRQ,
598 },
599 {
600 .start = CH_UART1_TX,
601 .end = CH_UART1_TX,
602 .flags = IORESOURCE_DMA,
603 },
604 {
605 .start = CH_UART1_RX,
606 .end = CH_UART1_RX,
607 .flags = IORESOURCE_DMA,
608 },
609#ifdef CONFIG_BFIN_UART1_CTSRTS
610 { /* CTS pin */
611 .start = GPIO_PF9,
612 .end = GPIO_PF9,
613 .flags = IORESOURCE_IO,
614 },
615 { /* RTS pin */
616 .start = GPIO_PF10,
617 .end = GPIO_PF10,
618 .flags = IORESOURCE_IO,
619 },
620#endif
621};
622
623unsigned short bfin_uart1_peripherals[] = {
624 P_UART1_TX, P_UART1_RX, 0
625};
626
627static struct platform_device bfin_uart1_device = {
628 .name = "bfin-uart",
629 .id = 1,
630 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
631 .resource = bfin_uart1_resources,
632 .dev = {
633 .platform_data = &bfin_uart1_peripherals,
634 /* Passed to driver */
635 },
636};
637#endif
638#endif
639
640#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
641#ifdef CONFIG_BFIN_SIR0
642static struct resource bfin_sir0_resources[] = {
643 {
644 .start = 0xFFC00400,
645 .end = 0xFFC004FF,
646 .flags = IORESOURCE_MEM,
647 },
648 {
649 .start = IRQ_UART0_RX,
650 .end = IRQ_UART0_RX+1,
651 .flags = IORESOURCE_IRQ,
652 },
653 {
654 .start = CH_UART0_RX,
655 .end = CH_UART0_RX+1,
656 .flags = IORESOURCE_DMA,
657 },
658};
659
660static struct platform_device bfin_sir0_device = {
661 .name = "bfin_sir",
662 .id = 0,
663 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
664 .resource = bfin_sir0_resources,
665};
666#endif
667#ifdef CONFIG_BFIN_SIR1
668static struct resource bfin_sir1_resources[] = {
669 {
670 .start = 0xFFC02000,
671 .end = 0xFFC020FF,
672 .flags = IORESOURCE_MEM,
673 },
674 {
675 .start = IRQ_UART1_RX,
676 .end = IRQ_UART1_RX+1,
677 .flags = IORESOURCE_IRQ,
678 },
679 {
680 .start = CH_UART1_RX,
681 .end = CH_UART1_RX+1,
682 .flags = IORESOURCE_DMA,
683 },
684};
685
686static struct platform_device bfin_sir1_device = {
687 .name = "bfin_sir",
688 .id = 1,
689 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
690 .resource = bfin_sir1_resources,
691};
692#endif
693#endif
694
695#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
696static struct resource bfin_twi0_resource[] = {
697 [0] = {
698 .start = TWI0_REGBASE,
699 .end = TWI0_REGBASE,
700 .flags = IORESOURCE_MEM,
701 },
702 [1] = {
703 .start = IRQ_TWI,
704 .end = IRQ_TWI,
705 .flags = IORESOURCE_IRQ,
706 },
707};
708
709static struct platform_device i2c_bfin_twi_device = {
710 .name = "i2c-bfin-twi",
711 .id = 0,
712 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
713 .resource = bfin_twi0_resource,
714};
715#endif
716
717static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
718#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
719 {
720 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
721 },
722#endif
723
724#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
725 {
726 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
727 },
728#endif
729#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) \
730 || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
731 {
732 I2C_BOARD_INFO("ad7879", 0x2C),
733 .irq = IRQ_PH14,
734 .platform_data = (void *)&bfin_ad7879_ts_info,
735 },
736#endif
737#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
738 {
739 I2C_BOARD_INFO("ssm2602", 0x1b),
740 },
741#endif
742 {
743 I2C_BOARD_INFO("adm1192", 0x2e),
744 },
745
746 {
747 I2C_BOARD_INFO("ltc3576", 0x09),
748 },
749#if defined(CONFIG_INPUT_ADXL34X_I2C) \
750 || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE)
751 {
752 I2C_BOARD_INFO("adxl34x", 0x53),
753 .irq = IRQ_PH13,
754 .platform_data = (void *)&adxl345_info,
755 },
756#endif
757};
758
759#if defined(CONFIG_SERIAL_BFIN_SPORT) \
760 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
761#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
762static struct resource bfin_sport0_uart_resources[] = {
763 {
764 .start = SPORT0_TCR1,
765 .end = SPORT0_MRCS3+4,
766 .flags = IORESOURCE_MEM,
767 },
768 {
769 .start = IRQ_SPORT0_RX,
770 .end = IRQ_SPORT0_RX+1,
771 .flags = IORESOURCE_IRQ,
772 },
773 {
774 .start = IRQ_SPORT0_ERROR,
775 .end = IRQ_SPORT0_ERROR,
776 .flags = IORESOURCE_IRQ,
777 },
778};
779
780unsigned short bfin_sport0_peripherals[] = {
781 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
782 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
783};
784
785static struct platform_device bfin_sport0_uart_device = {
786 .name = "bfin-sport-uart",
787 .id = 0,
788 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
789 .resource = bfin_sport0_uart_resources,
790 .dev = {
791 .platform_data = &bfin_sport0_peripherals,
792 /* Passed to driver */
793 },
794};
795#endif
796#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
797static struct resource bfin_sport1_uart_resources[] = {
798 {
799 .start = SPORT1_TCR1,
800 .end = SPORT1_MRCS3+4,
801 .flags = IORESOURCE_MEM,
802 },
803 {
804 .start = IRQ_SPORT1_RX,
805 .end = IRQ_SPORT1_RX+1,
806 .flags = IORESOURCE_IRQ,
807 },
808 {
809 .start = IRQ_SPORT1_ERROR,
810 .end = IRQ_SPORT1_ERROR,
811 .flags = IORESOURCE_IRQ,
812 },
813};
814
815unsigned short bfin_sport1_peripherals[] = {
816 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
817 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
818};
819
820static struct platform_device bfin_sport1_uart_device = {
821 .name = "bfin-sport-uart",
822 .id = 1,
823 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
824 .resource = bfin_sport1_uart_resources,
825 .dev = {
826 .platform_data = &bfin_sport1_peripherals,
827 /* Passed to driver */
828 },
829};
830#endif
831#endif
832
833static const unsigned int cclk_vlev_datasheet[] = {
834 VRPAIR(VLEV_100, 400000000),
835 VRPAIR(VLEV_105, 426000000),
836 VRPAIR(VLEV_110, 500000000),
837 VRPAIR(VLEV_115, 533000000),
838 VRPAIR(VLEV_120, 600000000),
839};
840
841static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
842 .tuple_tab = cclk_vlev_datasheet,
843 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
844 .vr_settling_time = 25 /* us */,
845};
846
847static struct platform_device bfin_dpmc = {
848 .name = "bfin dpmc",
849 .dev = {
850 .platform_data = &bfin_dmpc_vreg_data,
851 },
852};
853
854static struct platform_device *tll6527m_devices[] __initdata = {
855
856 &bfin_dpmc,
857
858#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
859 &rtc_device,
860#endif
861
862#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
863 &musb_device,
864#endif
865
866#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
867 &bfin_mii_bus,
868 &bfin_mac_device,
869#endif
870
871#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
872 &bfin_spi0_device,
873#endif
874
875#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
876 &bfin_lq035q1_device,
877#endif
878
879#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
880#ifdef CONFIG_SERIAL_BFIN_UART0
881 &bfin_uart0_device,
882#endif
883#ifdef CONFIG_SERIAL_BFIN_UART1
884 &bfin_uart1_device,
885#endif
886#endif
887
888#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
889#ifdef CONFIG_BFIN_SIR0
890 &bfin_sir0_device,
891#endif
892#ifdef CONFIG_BFIN_SIR1
893 &bfin_sir1_device,
894#endif
895#endif
896
897#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
898 &i2c_bfin_twi_device,
899#endif
900
901#if defined(CONFIG_SERIAL_BFIN_SPORT) \
902 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
903#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
904 &bfin_sport0_uart_device,
905#endif
906#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
907 &bfin_sport1_uart_device,
908#endif
909#endif
910
911#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
912 &tll6527m_flash_device,
913#endif
914
915#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
916 &bfin_i2s,
917#endif
918
919#if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE)
920 &spi_decoded_gpio,
921#endif
922};
923
924static int __init tll6527m_init(void)
925{
926 printk(KERN_INFO "%s(): registering device resources\n", __func__);
927 i2c_register_board_info(0, bfin_i2c_board_info,
928 ARRAY_SIZE(bfin_i2c_board_info));
929 platform_add_devices(tll6527m_devices, ARRAY_SIZE(tll6527m_devices));
930 spi_register_board_info(bfin_spi_board_info,
931 ARRAY_SIZE(bfin_spi_board_info));
932 return 0;
933}
934
935arch_initcall(tll6527m_init);
936
937static struct platform_device *tll6527m_early_devices[] __initdata = {
938#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
939#ifdef CONFIG_SERIAL_BFIN_UART0
940 &bfin_uart0_device,
941#endif
942#ifdef CONFIG_SERIAL_BFIN_UART1
943 &bfin_uart1_device,
944#endif
945#endif
946
947#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
948#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
949 &bfin_sport0_uart_device,
950#endif
951#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
952 &bfin_sport1_uart_device,
953#endif
954#endif
955};
956
957void __init native_machine_early_platform_add_devices(void)
958{
959 printk(KERN_INFO "register early platform devices\n");
960 early_platform_add_devices(tll6527m_early_devices,
961 ARRAY_SIZE(tll6527m_early_devices));
962}
963
964void native_machine_restart(char *cmd)
965{
966 /* workaround reboot hang when booting from SPI */
967 if ((bfin_read_SYSCR() & 0x7) == 0x3)
968 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
969}
970
971void bfin_get_ether_addr(char *addr)
972{
973 /* the MAC is stored in OTP memory page 0xDF */
974 u32 ret;
975 u64 otp_mac;
976 u32 (*otp_read)(u32 page, u32 flags,
977 u64 *page_content) = (void *)0xEF00001A;
978
979 ret = otp_read(0xDF, 0x00, &otp_mac);
980 if (!(ret & 0x1)) {
981 char *otp_mac_p = (char *)&otp_mac;
982 for (ret = 0; ret < 6; ++ret)
983 addr[ret] = otp_mac_p[5 - ret];
984 }
985}
986EXPORT_SYMBOL(bfin_get_ether_addr);
diff --git a/arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h b/arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h
index 12f2ad45314e..3048b52bf46a 100644
--- a/arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h
+++ b/arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h
@@ -279,14 +279,14 @@
279#define bfin_write_SPORT0_TX(val) bfin_write32(SPORT0_TX, val) 279#define bfin_write_SPORT0_TX(val) bfin_write32(SPORT0_TX, val)
280#define bfin_read_SPORT0_RX() bfin_read32(SPORT0_RX) 280#define bfin_read_SPORT0_RX() bfin_read32(SPORT0_RX)
281#define bfin_write_SPORT0_RX(val) bfin_write32(SPORT0_RX, val) 281#define bfin_write_SPORT0_RX(val) bfin_write32(SPORT0_RX, val)
282#define bfin_read_SPORT0_TX32() bfin_read32(SPORT0_TX32) 282#define bfin_read_SPORT0_TX32() bfin_read32(SPORT0_TX)
283#define bfin_write_SPORT0_TX32(val) bfin_write32(SPORT0_TX32, val) 283#define bfin_write_SPORT0_TX32(val) bfin_write32(SPORT0_TX, val)
284#define bfin_read_SPORT0_RX32() bfin_read32(SPORT0_RX32) 284#define bfin_read_SPORT0_RX32() bfin_read32(SPORT0_RX)
285#define bfin_write_SPORT0_RX32(val) bfin_write32(SPORT0_RX32, val) 285#define bfin_write_SPORT0_RX32(val) bfin_write32(SPORT0_RX, val)
286#define bfin_read_SPORT0_TX16() bfin_read16(SPORT0_TX16) 286#define bfin_read_SPORT0_TX16() bfin_read16(SPORT0_TX)
287#define bfin_write_SPORT0_TX16(val) bfin_write16(SPORT0_TX16, val) 287#define bfin_write_SPORT0_TX16(val) bfin_write16(SPORT0_TX, val)
288#define bfin_read_SPORT0_RX16() bfin_read16(SPORT0_RX16) 288#define bfin_read_SPORT0_RX16() bfin_read16(SPORT0_RX)
289#define bfin_write_SPORT0_RX16(val) bfin_write16(SPORT0_RX16, val) 289#define bfin_write_SPORT0_RX16(val) bfin_write16(SPORT0_RX, val)
290#define bfin_read_SPORT0_RCR1() bfin_read16(SPORT0_RCR1) 290#define bfin_read_SPORT0_RCR1() bfin_read16(SPORT0_RCR1)
291#define bfin_write_SPORT0_RCR1(val) bfin_write16(SPORT0_RCR1, val) 291#define bfin_write_SPORT0_RCR1(val) bfin_write16(SPORT0_RCR1, val)
292#define bfin_read_SPORT0_RCR2() bfin_read16(SPORT0_RCR2) 292#define bfin_read_SPORT0_RCR2() bfin_read16(SPORT0_RCR2)
@@ -334,14 +334,14 @@
334#define bfin_write_SPORT1_TX(val) bfin_write32(SPORT1_TX, val) 334#define bfin_write_SPORT1_TX(val) bfin_write32(SPORT1_TX, val)
335#define bfin_read_SPORT1_RX() bfin_read32(SPORT1_RX) 335#define bfin_read_SPORT1_RX() bfin_read32(SPORT1_RX)
336#define bfin_write_SPORT1_RX(val) bfin_write32(SPORT1_RX, val) 336#define bfin_write_SPORT1_RX(val) bfin_write32(SPORT1_RX, val)
337#define bfin_read_SPORT1_TX32() bfin_read32(SPORT1_TX32) 337#define bfin_read_SPORT1_TX32() bfin_read32(SPORT1_TX)
338#define bfin_write_SPORT1_TX32(val) bfin_write32(SPORT1_TX32, val) 338#define bfin_write_SPORT1_TX32(val) bfin_write32(SPORT1_TX, val)
339#define bfin_read_SPORT1_RX32() bfin_read32(SPORT1_RX32) 339#define bfin_read_SPORT1_RX32() bfin_read32(SPORT1_RX)
340#define bfin_write_SPORT1_RX32(val) bfin_write32(SPORT1_RX32, val) 340#define bfin_write_SPORT1_RX32(val) bfin_write32(SPORT1_RX, val)
341#define bfin_read_SPORT1_TX16() bfin_read16(SPORT1_TX16) 341#define bfin_read_SPORT1_TX16() bfin_read16(SPORT1_TX)
342#define bfin_write_SPORT1_TX16(val) bfin_write16(SPORT1_TX16, val) 342#define bfin_write_SPORT1_TX16(val) bfin_write16(SPORT1_TX, val)
343#define bfin_read_SPORT1_RX16() bfin_read16(SPORT1_RX16) 343#define bfin_read_SPORT1_RX16() bfin_read16(SPORT1_RX)
344#define bfin_write_SPORT1_RX16(val) bfin_write16(SPORT1_RX16, val) 344#define bfin_write_SPORT1_RX16(val) bfin_write16(SPORT1_RX, val)
345#define bfin_read_SPORT1_RCR1() bfin_read16(SPORT1_RCR1) 345#define bfin_read_SPORT1_RCR1() bfin_read16(SPORT1_RCR1)
346#define bfin_write_SPORT1_RCR1(val) bfin_write16(SPORT1_RCR1, val) 346#define bfin_write_SPORT1_RCR1(val) bfin_write16(SPORT1_RCR1, val)
347#define bfin_read_SPORT1_RCR2() bfin_read16(SPORT1_RCR2) 347#define bfin_read_SPORT1_RCR2() bfin_read16(SPORT1_RCR2)
@@ -1110,54 +1110,4 @@
1110/* These need to be last due to the cdef/linux inter-dependencies */ 1110/* These need to be last due to the cdef/linux inter-dependencies */
1111#include <asm/irq.h> 1111#include <asm/irq.h>
1112 1112
1113/* Writing to PLL_CTL initiates a PLL relock sequence. */
1114static __inline__ void bfin_write_PLL_CTL(unsigned int val)
1115{
1116 unsigned long flags, iwr0, iwr1;
1117
1118 if (val == bfin_read_PLL_CTL())
1119 return;
1120
1121 local_irq_save_hw(flags);
1122 /* Enable the PLL Wakeup bit in SIC IWR */
1123 iwr0 = bfin_read32(SIC_IWR0);
1124 iwr1 = bfin_read32(SIC_IWR1);
1125 /* Only allow PPL Wakeup) */
1126 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
1127 bfin_write32(SIC_IWR1, 0);
1128
1129 bfin_write16(PLL_CTL, val);
1130 SSYNC();
1131 asm("IDLE;");
1132
1133 bfin_write32(SIC_IWR0, iwr0);
1134 bfin_write32(SIC_IWR1, iwr1);
1135 local_irq_restore_hw(flags);
1136}
1137
1138/* Writing to VR_CTL initiates a PLL relock sequence. */
1139static __inline__ void bfin_write_VR_CTL(unsigned int val)
1140{
1141 unsigned long flags, iwr0, iwr1;
1142
1143 if (val == bfin_read_VR_CTL())
1144 return;
1145
1146 local_irq_save_hw(flags);
1147 /* Enable the PLL Wakeup bit in SIC IWR */
1148 iwr0 = bfin_read32(SIC_IWR0);
1149 iwr1 = bfin_read32(SIC_IWR1);
1150 /* Only allow PPL Wakeup) */
1151 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
1152 bfin_write32(SIC_IWR1, 0);
1153
1154 bfin_write16(VR_CTL, val);
1155 SSYNC();
1156 asm("IDLE;");
1157
1158 bfin_write32(SIC_IWR0, iwr0);
1159 bfin_write32(SIC_IWR1, iwr1);
1160 local_irq_restore_hw(flags);
1161}
1162
1163#endif /* _CDEF_BF52X_H */ 1113#endif /* _CDEF_BF52X_H */
diff --git a/arch/blackfin/mach-bf527/include/mach/defBF52x_base.h b/arch/blackfin/mach-bf527/include/mach/defBF52x_base.h
index 3e000756aacd..09475034c6a1 100644
--- a/arch/blackfin/mach-bf527/include/mach/defBF52x_base.h
+++ b/arch/blackfin/mach-bf527/include/mach/defBF52x_base.h
@@ -749,51 +749,6 @@
749#define FFE 0x20 /* Force Framing Error On Transmit */ 749#define FFE 0x20 /* Force Framing Error On Transmit */
750 750
751 751
752/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS ****************************/
753/* SPI_CTL Masks */
754#define TIMOD 0x0003 /* Transfer Initiate Mode */
755#define RDBR_CORE 0x0000 /* RDBR Read Initiates, IRQ When RDBR Full */
756#define TDBR_CORE 0x0001 /* TDBR Write Initiates, IRQ When TDBR Empty */
757#define RDBR_DMA 0x0002 /* DMA Read, DMA Until FIFO Empty */
758#define TDBR_DMA 0x0003 /* DMA Write, DMA Until FIFO Full */
759#define SZ 0x0004 /* Send Zero (When TDBR Empty, Send Zero/Last*) */
760#define GM 0x0008 /* Get More (When RDBR Full, Overwrite/Discard*) */
761#define PSSE 0x0010 /* Slave-Select Input Enable */
762#define EMISO 0x0020 /* Enable MISO As Output */
763#define SIZE 0x0100 /* Size of Words (16/8* Bits) */
764#define LSBF 0x0200 /* LSB First */
765#define CPHA 0x0400 /* Clock Phase */
766#define CPOL 0x0800 /* Clock Polarity */
767#define MSTR 0x1000 /* Master/Slave* */
768#define WOM 0x2000 /* Write Open Drain Master */
769#define SPE 0x4000 /* SPI Enable */
770
771/* SPI_FLG Masks */
772#define FLS1 0x0002 /* Enables SPI_FLOUT1 as SPI Slave-Select Output */
773#define FLS2 0x0004 /* Enables SPI_FLOUT2 as SPI Slave-Select Output */
774#define FLS3 0x0008 /* Enables SPI_FLOUT3 as SPI Slave-Select Output */
775#define FLS4 0x0010 /* Enables SPI_FLOUT4 as SPI Slave-Select Output */
776#define FLS5 0x0020 /* Enables SPI_FLOUT5 as SPI Slave-Select Output */
777#define FLS6 0x0040 /* Enables SPI_FLOUT6 as SPI Slave-Select Output */
778#define FLS7 0x0080 /* Enables SPI_FLOUT7 as SPI Slave-Select Output */
779#define FLG1 0xFDFF /* Activates SPI_FLOUT1 */
780#define FLG2 0xFBFF /* Activates SPI_FLOUT2 */
781#define FLG3 0xF7FF /* Activates SPI_FLOUT3 */
782#define FLG4 0xEFFF /* Activates SPI_FLOUT4 */
783#define FLG5 0xDFFF /* Activates SPI_FLOUT5 */
784#define FLG6 0xBFFF /* Activates SPI_FLOUT6 */
785#define FLG7 0x7FFF /* Activates SPI_FLOUT7 */
786
787/* SPI_STAT Masks */
788#define SPIF 0x0001 /* SPI Finished (Single-Word Transfer Complete) */
789#define MODF 0x0002 /* Mode Fault Error (Another Device Tried To Become Master) */
790#define TXE 0x0004 /* Transmission Error (Data Sent With No New Data In TDBR) */
791#define TXS 0x0008 /* SPI_TDBR Data Buffer Status (Full/Empty*) */
792#define RBSY 0x0010 /* Receive Error (Data Received With RDBR Full) */
793#define RXS 0x0020 /* SPI_RDBR Data Buffer Status (Full/Empty*) */
794#define TXCOL 0x0040 /* Transmit Collision Error (Corrupt Data May Have Been Sent) */
795
796
797/* **************** GENERAL PURPOSE TIMER MASKS **********************/ 752/* **************** GENERAL PURPOSE TIMER MASKS **********************/
798/* TIMER_ENABLE Masks */ 753/* TIMER_ENABLE Masks */
799#define TIMEN0 0x0001 /* Enable Timer 0 */ 754#define TIMEN0 0x0001 /* Enable Timer 0 */
diff --git a/arch/blackfin/mach-bf527/include/mach/pll.h b/arch/blackfin/mach-bf527/include/mach/pll.h
new file mode 100644
index 000000000000..24f1d7c02325
--- /dev/null
+++ b/arch/blackfin/mach-bf527/include/mach/pll.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2007-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr0, iwr1;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr0 = bfin_read32(SIC_IWR0);
24 iwr1 = bfin_read32(SIC_IWR1);
25 /* Only allow PPL Wakeup) */
26 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
27 bfin_write32(SIC_IWR1, 0);
28
29 bfin_write16(PLL_CTL, val);
30 SSYNC();
31 asm("IDLE;");
32
33 bfin_write32(SIC_IWR0, iwr0);
34 bfin_write32(SIC_IWR1, iwr1);
35 hard_local_irq_restore(flags);
36}
37
38/* Writing to VR_CTL initiates a PLL relock sequence. */
39static __inline__ void bfin_write_VR_CTL(unsigned int val)
40{
41 unsigned long flags, iwr0, iwr1;
42
43 if (val == bfin_read_VR_CTL())
44 return;
45
46 flags = hard_local_irq_save();
47 /* Enable the PLL Wakeup bit in SIC IWR */
48 iwr0 = bfin_read32(SIC_IWR0);
49 iwr1 = bfin_read32(SIC_IWR1);
50 /* Only allow PPL Wakeup) */
51 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
52 bfin_write32(SIC_IWR1, 0);
53
54 bfin_write16(VR_CTL, val);
55 SSYNC();
56 asm("IDLE;");
57
58 bfin_write32(SIC_IWR0, iwr0);
59 bfin_write32(SIC_IWR1, iwr1);
60 hard_local_irq_restore(flags);
61}
62
63#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf533/boards/H8606.c b/arch/blackfin/mach-bf533/boards/H8606.c
index 175371af0692..2ce7b16faee1 100644
--- a/arch/blackfin/mach-bf533/boards/H8606.c
+++ b/arch/blackfin/mach-bf533/boards/H8606.c
@@ -171,7 +171,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
171}; 171};
172#endif 172#endif
173 173
174#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 174#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
175static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 175static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
176 .enable_dma = 0, 176 .enable_dma = 0,
177 .bits_per_word = 16, 177 .bits_per_word = 16,
@@ -206,12 +206,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
206 }, 206 },
207#endif 207#endif
208 208
209#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 209#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
210 { 210 {
211 .modalias = "ad1836", 211 .modalias = "ad183x",
212 .max_speed_hz = 16, 212 .max_speed_hz = 16,
213 .bus_num = 1, 213 .bus_num = 1,
214 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 214 .chip_select = 4,
215 .controller_data = &ad1836_spi_chip_info, 215 .controller_data = &ad1836_spi_chip_info,
216 }, 216 },
217#endif 217#endif
@@ -347,6 +347,7 @@ static struct plat_serial8250_port serial8250_platform_data [] = {
347 .membase = (void *)0x20200000, 347 .membase = (void *)0x20200000,
348 .mapbase = 0x20200000, 348 .mapbase = 0x20200000,
349 .irq = IRQ_PF8, 349 .irq = IRQ_PF8,
350 .irqflags = IRQF_TRIGGER_HIGH,
350 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE, 351 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
351 .iotype = UPIO_MEM, 352 .iotype = UPIO_MEM,
352 .regshift = 1, 353 .regshift = 1,
@@ -355,6 +356,7 @@ static struct plat_serial8250_port serial8250_platform_data [] = {
355 .membase = (void *)0x20200010, 356 .membase = (void *)0x20200010,
356 .mapbase = 0x20200010, 357 .mapbase = 0x20200010,
357 .irq = IRQ_PF8, 358 .irq = IRQ_PF8,
359 .irqflags = IRQF_TRIGGER_HIGH,
358 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE, 360 .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
359 .iotype = UPIO_MEM, 361 .iotype = UPIO_MEM,
360 .regshift = 1, 362 .regshift = 1,
diff --git a/arch/blackfin/mach-bf533/boards/blackstamp.c b/arch/blackfin/mach-bf533/boards/blackstamp.c
index 842b4fa76ea9..20c102285bef 100644
--- a/arch/blackfin/mach-bf533/boards/blackstamp.c
+++ b/arch/blackfin/mach-bf533/boards/blackstamp.c
@@ -25,6 +25,7 @@
25#include <asm/bfin5xx_spi.h> 25#include <asm/bfin5xx_spi.h>
26#include <asm/portmux.h> 26#include <asm/portmux.h>
27#include <asm/dpmc.h> 27#include <asm/dpmc.h>
28#include <mach/fio_flag.h>
28 29
29/* 30/*
30 * Name the Board for the /proc/cpuinfo 31 * Name the Board for the /proc/cpuinfo
@@ -367,8 +368,8 @@ static struct platform_device bfin_device_gpiokeys = {
367#include <linux/i2c-gpio.h> 368#include <linux/i2c-gpio.h>
368 369
369static struct i2c_gpio_platform_data i2c_gpio_data = { 370static struct i2c_gpio_platform_data i2c_gpio_data = {
370 .sda_pin = 8, 371 .sda_pin = GPIO_PF8,
371 .scl_pin = 9, 372 .scl_pin = GPIO_PF9,
372 .sda_is_open_drain = 0, 373 .sda_is_open_drain = 0,
373 .scl_is_open_drain = 0, 374 .scl_is_open_drain = 0,
374 .udelay = 40, 375 .udelay = 40,
diff --git a/arch/blackfin/mach-bf533/boards/cm_bf533.c b/arch/blackfin/mach-bf533/boards/cm_bf533.c
index fdcde61906dc..adbe62a81e25 100644
--- a/arch/blackfin/mach-bf533/boards/cm_bf533.c
+++ b/arch/blackfin/mach-bf533/boards/cm_bf533.c
@@ -71,7 +71,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
71}; 71};
72#endif 72#endif
73 73
74#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 74#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
75static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 75static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
76 .enable_dma = 0, 76 .enable_dma = 0,
77 .bits_per_word = 16, 77 .bits_per_word = 16,
@@ -110,12 +110,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
110 }, 110 },
111#endif 111#endif
112 112
113#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 113#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
114 { 114 {
115 .modalias = "ad1836", 115 .modalias = "ad183x",
116 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 116 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
117 .bus_num = 0, 117 .bus_num = 0,
118 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 118 .chip_select = 4,
119 .controller_data = &ad1836_spi_chip_info, 119 .controller_data = &ad1836_spi_chip_info,
120 }, 120 },
121#endif 121#endif
@@ -400,7 +400,7 @@ static struct resource isp1362_hcd_resources[] = {
400 }, { 400 }, {
401 .start = IRQ_PF4, 401 .start = IRQ_PF4,
402 .end = IRQ_PF4, 402 .end = IRQ_PF4,
403 .flags = IORESOURCE_IRQ, 403 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
404 }, 404 },
405}; 405};
406 406
diff --git a/arch/blackfin/mach-bf533/boards/ezkit.c b/arch/blackfin/mach-bf533/boards/ezkit.c
index 739773cb7fc6..a1cb8e7c1010 100644
--- a/arch/blackfin/mach-bf533/boards/ezkit.c
+++ b/arch/blackfin/mach-bf533/boards/ezkit.c
@@ -222,7 +222,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
222}; 222};
223#endif 223#endif
224 224
225#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 225#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
226static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 226static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
227 .enable_dma = 0, 227 .enable_dma = 0,
228 .bits_per_word = 16, 228 .bits_per_word = 16,
@@ -261,12 +261,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
261 }, 261 },
262#endif 262#endif
263 263
264#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 264#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
265 { 265 {
266 .modalias = "ad1836", 266 .modalias = "ad183x",
267 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 267 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
268 .bus_num = 0, 268 .bus_num = 0,
269 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 269 .chip_select = 4,
270 .controller_data = &ad1836_spi_chip_info, 270 .controller_data = &ad1836_spi_chip_info,
271 }, 271 },
272#endif 272#endif
@@ -422,8 +422,8 @@ static struct platform_device bfin_device_gpiokeys = {
422#include <linux/i2c-gpio.h> 422#include <linux/i2c-gpio.h>
423 423
424static struct i2c_gpio_platform_data i2c_gpio_data = { 424static struct i2c_gpio_platform_data i2c_gpio_data = {
425 .sda_pin = 1, 425 .sda_pin = GPIO_PF1,
426 .scl_pin = 0, 426 .scl_pin = GPIO_PF0,
427 .sda_is_open_drain = 0, 427 .sda_is_open_drain = 0,
428 .scl_is_open_drain = 0, 428 .scl_is_open_drain = 0,
429 .udelay = 40, 429 .udelay = 40,
diff --git a/arch/blackfin/mach-bf533/boards/ip0x.c b/arch/blackfin/mach-bf533/boards/ip0x.c
index 7349970db978..5ba4b02a12eb 100644
--- a/arch/blackfin/mach-bf533/boards/ip0x.c
+++ b/arch/blackfin/mach-bf533/boards/ip0x.c
@@ -22,6 +22,7 @@
22#include <asm/dma.h> 22#include <asm/dma.h>
23#include <asm/bfin5xx_spi.h> 23#include <asm/bfin5xx_spi.h>
24#include <asm/portmux.h> 24#include <asm/portmux.h>
25#include <mach/fio_flag.h>
25 26
26/* 27/*
27 * Name the Board for the /proc/cpuinfo 28 * Name the Board for the /proc/cpuinfo
@@ -231,7 +232,7 @@ static struct resource isp1362_hcd_resources[] = {
231 },{ 232 },{
232 .start = IRQ_PF11, 233 .start = IRQ_PF11,
233 .end = IRQ_PF11, 234 .end = IRQ_PF11,
234 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
235 }, 236 },
236}; 237};
237 238
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index c457eaa60239..b3b1cdea2703 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -24,6 +24,7 @@
24#include <asm/reboot.h> 24#include <asm/reboot.h>
25#include <asm/portmux.h> 25#include <asm/portmux.h>
26#include <asm/dpmc.h> 26#include <asm/dpmc.h>
27#include <mach/fio_flag.h>
27 28
28/* 29/*
29 * Name the Board for the /proc/cpuinfo 30 * Name the Board for the /proc/cpuinfo
@@ -184,7 +185,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
184}; 185};
185#endif 186#endif
186 187
187#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 188#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
188static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 189static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
189 .enable_dma = 0, 190 .enable_dma = 0,
190 .bits_per_word = 16, 191 .bits_per_word = 16,
@@ -251,13 +252,15 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
251 }, 252 },
252#endif 253#endif
253 254
254#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 255#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
255 { 256 {
256 .modalias = "ad1836", 257 .modalias = "ad183x",
257 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 258 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
258 .bus_num = 0, 259 .bus_num = 0,
259 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 260 .chip_select = 4,
261 .platform_data = "ad1836", /* only includes chip name for the moment */
260 .controller_data = &ad1836_spi_chip_info, 262 .controller_data = &ad1836_spi_chip_info,
263 .mode = SPI_MODE_3,
261 }, 264 },
262#endif 265#endif
263 266
@@ -494,8 +497,8 @@ static struct platform_device bfin_device_gpiokeys = {
494#include <linux/i2c-gpio.h> 497#include <linux/i2c-gpio.h>
495 498
496static struct i2c_gpio_platform_data i2c_gpio_data = { 499static struct i2c_gpio_platform_data i2c_gpio_data = {
497 .sda_pin = 2, 500 .sda_pin = GPIO_PF2,
498 .scl_pin = 3, 501 .scl_pin = GPIO_PF3,
499 .sda_is_open_drain = 0, 502 .sda_is_open_drain = 0,
500 .scl_is_open_drain = 0, 503 .scl_is_open_drain = 0,
501 .udelay = 40, 504 .udelay = 40,
@@ -533,6 +536,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
533 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 536 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
534 }, 537 },
535#endif 538#endif
539#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
540 {
541 I2C_BOARD_INFO("ad5252", 0x2f),
542 },
543#endif
536}; 544};
537 545
538static const unsigned int cclk_vlev_datasheet[] = 546static const unsigned int cclk_vlev_datasheet[] =
diff --git a/arch/blackfin/mach-bf533/include/mach/cdefBF532.h b/arch/blackfin/mach-bf533/include/mach/cdefBF532.h
index feb2392c43ea..401e524f5321 100644
--- a/arch/blackfin/mach-bf533/include/mach/cdefBF532.h
+++ b/arch/blackfin/mach-bf533/include/mach/cdefBF532.h
@@ -7,11 +7,6 @@
7#ifndef _CDEF_BF532_H 7#ifndef _CDEF_BF532_H
8#define _CDEF_BF532_H 8#define _CDEF_BF532_H
9 9
10#include <asm/blackfin.h>
11
12/*include all Core registers and bit definitions*/
13#include "defBF532.h"
14
15/*include core specific register pointer definitions*/ 10/*include core specific register pointer definitions*/
16#include <asm/cdef_LPBlackfin.h> 11#include <asm/cdef_LPBlackfin.h>
17 12
@@ -655,90 +650,4 @@
655/* These need to be last due to the cdef/linux inter-dependencies */ 650/* These need to be last due to the cdef/linux inter-dependencies */
656#include <asm/irq.h> 651#include <asm/irq.h>
657 652
658#if ANOMALY_05000311
659#define BFIN_WRITE_FIO_FLAG(name) \
660static inline void bfin_write_FIO_FLAG_##name(unsigned short val) \
661{ \
662 unsigned long flags; \
663 local_irq_save_hw(flags); \
664 bfin_write16(FIO_FLAG_##name, val); \
665 bfin_read_CHIPID(); \
666 local_irq_restore_hw(flags); \
667}
668BFIN_WRITE_FIO_FLAG(D)
669BFIN_WRITE_FIO_FLAG(C)
670BFIN_WRITE_FIO_FLAG(S)
671BFIN_WRITE_FIO_FLAG(T)
672
673#define BFIN_READ_FIO_FLAG(name) \
674static inline u16 bfin_read_FIO_FLAG_##name(void) \
675{ \
676 unsigned long flags; \
677 u16 ret; \
678 local_irq_save_hw(flags); \
679 ret = bfin_read16(FIO_FLAG_##name); \
680 bfin_read_CHIPID(); \
681 local_irq_restore_hw(flags); \
682 return ret; \
683}
684BFIN_READ_FIO_FLAG(D)
685BFIN_READ_FIO_FLAG(C)
686BFIN_READ_FIO_FLAG(S)
687BFIN_READ_FIO_FLAG(T)
688
689#else
690#define bfin_write_FIO_FLAG_D(val) bfin_write16(FIO_FLAG_D, val)
691#define bfin_write_FIO_FLAG_C(val) bfin_write16(FIO_FLAG_C, val)
692#define bfin_write_FIO_FLAG_S(val) bfin_write16(FIO_FLAG_S, val)
693#define bfin_write_FIO_FLAG_T(val) bfin_write16(FIO_FLAG_T, val)
694#define bfin_read_FIO_FLAG_T() bfin_read16(FIO_FLAG_T)
695#define bfin_read_FIO_FLAG_C() bfin_read16(FIO_FLAG_C)
696#define bfin_read_FIO_FLAG_S() bfin_read16(FIO_FLAG_S)
697#define bfin_read_FIO_FLAG_D() bfin_read16(FIO_FLAG_D)
698#endif
699
700/* Writing to PLL_CTL initiates a PLL relock sequence. */
701static __inline__ void bfin_write_PLL_CTL(unsigned int val)
702{
703 unsigned long flags, iwr;
704
705 if (val == bfin_read_PLL_CTL())
706 return;
707
708 local_irq_save_hw(flags);
709 /* Enable the PLL Wakeup bit in SIC IWR */
710 iwr = bfin_read32(SIC_IWR);
711 /* Only allow PPL Wakeup) */
712 bfin_write32(SIC_IWR, IWR_ENABLE(0));
713
714 bfin_write16(PLL_CTL, val);
715 SSYNC();
716 asm("IDLE;");
717
718 bfin_write32(SIC_IWR, iwr);
719 local_irq_restore_hw(flags);
720}
721
722/* Writing to VR_CTL initiates a PLL relock sequence. */
723static __inline__ void bfin_write_VR_CTL(unsigned int val)
724{
725 unsigned long flags, iwr;
726
727 if (val == bfin_read_VR_CTL())
728 return;
729
730 local_irq_save_hw(flags);
731 /* Enable the PLL Wakeup bit in SIC IWR */
732 iwr = bfin_read32(SIC_IWR);
733 /* Only allow PPL Wakeup) */
734 bfin_write32(SIC_IWR, IWR_ENABLE(0));
735
736 bfin_write16(VR_CTL, val);
737 SSYNC();
738 asm("IDLE;");
739
740 bfin_write32(SIC_IWR, iwr);
741 local_irq_restore_hw(flags);
742}
743
744#endif /* _CDEF_BF532_H */ 653#endif /* _CDEF_BF532_H */
diff --git a/arch/blackfin/mach-bf533/include/mach/defBF532.h b/arch/blackfin/mach-bf533/include/mach/defBF532.h
index 04acf1ed10f9..3adb0b44e597 100644
--- a/arch/blackfin/mach-bf533/include/mach/defBF532.h
+++ b/arch/blackfin/mach-bf533/include/mach/defBF532.h
@@ -681,76 +681,6 @@
681#define PF14_P 14 681#define PF14_P 14
682#define PF15_P 15 682#define PF15_P 15
683 683
684/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS **************** */
685
686/* SPI_CTL Masks */
687#define TIMOD 0x00000003 /* Transfer initiation mode and interrupt generation */
688#define RDBR_CORE 0x0000 /* RDBR Read Initiates, IRQ When RDBR Full */
689#define TDBR_CORE 0x0001 /* TDBR Write Initiates, IRQ When TDBR Empty */
690#define RDBR_DMA 0x0002 /* DMA Read, DMA Until FIFO Empty */
691#define TDBR_DMA 0x0003 /* DMA Write, DMA Until FIFO Full */
692#define SZ 0x00000004 /* Send Zero (=0) or last (=1) word when TDBR empty. */
693#define GM 0x00000008 /* When RDBR full, get more (=1) data or discard (=0) incoming Data */
694#define PSSE 0x00000010 /* Enable (=1) Slave-Select input for Master. */
695#define EMISO 0x00000020 /* Enable (=1) MISO pin as an output. */
696#define SIZE 0x00000100 /* Word length (0 => 8 bits, 1 => 16 bits) */
697#define LSBF 0x00000200 /* Data format (0 => MSB sent/received first 1 => LSB sent/received first) */
698#define CPHA 0x00000400 /* Clock phase (0 => SPICLK starts toggling in middle of xfer, 1 => SPICLK toggles at the beginning of xfer. */
699#define CPOL 0x00000800 /* Clock polarity (0 => active-high, 1 => active-low) */
700#define MSTR 0x00001000 /* Configures SPI as master (=1) or slave (=0) */
701#define WOM 0x00002000 /* Open drain (=1) data output enable (for MOSI and MISO) */
702#define SPE 0x00004000 /* SPI module enable (=1), disable (=0) */
703
704/* SPI_FLG Masks */
705#define FLS1 0x00000002 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
706#define FLS2 0x00000004 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
707#define FLS3 0x00000008 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
708#define FLS4 0x00000010 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
709#define FLS5 0x00000020 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
710#define FLS6 0x00000040 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
711#define FLS7 0x00000080 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
712#define FLG1 0x00000200 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
713#define FLG2 0x00000400 /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
714#define FLG3 0x00000800 /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
715#define FLG4 0x00001000 /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
716#define FLG5 0x00002000 /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
717#define FLG6 0x00004000 /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
718#define FLG7 0x00008000 /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
719
720/* SPI_FLG Bit Positions */
721#define FLS1_P 0x00000001 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
722#define FLS2_P 0x00000002 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
723#define FLS3_P 0x00000003 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
724#define FLS4_P 0x00000004 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
725#define FLS5_P 0x00000005 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
726#define FLS6_P 0x00000006 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
727#define FLS7_P 0x00000007 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
728#define FLG1_P 0x00000009 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
729#define FLG2_P 0x0000000A /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
730#define FLG3_P 0x0000000B /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
731#define FLG4_P 0x0000000C /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
732#define FLG5_P 0x0000000D /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
733#define FLG6_P 0x0000000E /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
734#define FLG7_P 0x0000000F /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
735
736/* SPI_STAT Masks */
737#define SPIF 0x00000001 /* Set (=1) when SPI single-word transfer complete */
738#define MODF 0x00000002 /* Set (=1) in a master device when some other device tries to become master */
739#define TXE 0x00000004 /* Set (=1) when transmission occurs with no new data in SPI_TDBR */
740#define TXS 0x00000008 /* SPI_TDBR Data Buffer Status (0=Empty, 1=Full) */
741#define RBSY 0x00000010 /* Set (=1) when data is received with RDBR full */
742#define RXS 0x00000020 /* SPI_RDBR Data Buffer Status (0=Empty, 1=Full) */
743#define TXCOL 0x00000040 /* When set (=1), corrupt data may have been transmitted */
744
745/* SPIx_FLG Masks */
746#define FLG1E 0xFDFF /* Activates SPI_FLOUT1 */
747#define FLG2E 0xFBFF /* Activates SPI_FLOUT2 */
748#define FLG3E 0xF7FF /* Activates SPI_FLOUT3 */
749#define FLG4E 0xEFFF /* Activates SPI_FLOUT4 */
750#define FLG5E 0xDFFF /* Activates SPI_FLOUT5 */
751#define FLG6E 0xBFFF /* Activates SPI_FLOUT6 */
752#define FLG7E 0x7FFF /* Activates SPI_FLOUT7 */
753
754/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */ 684/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */
755 685
756/* AMGCTL Masks */ 686/* AMGCTL Masks */
diff --git a/arch/blackfin/mach-bf533/include/mach/fio_flag.h b/arch/blackfin/mach-bf533/include/mach/fio_flag.h
new file mode 100644
index 000000000000..d0bfba0b083b
--- /dev/null
+++ b/arch/blackfin/mach-bf533/include/mach/fio_flag.h
@@ -0,0 +1,55 @@
1/*
2 * Copyright 2005-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#ifndef _MACH_FIO_FLAG_H
8#define _MACH_FIO_FLAG_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13#if ANOMALY_05000311
14#define BFIN_WRITE_FIO_FLAG(name) \
15static inline void bfin_write_FIO_FLAG_##name(unsigned short val) \
16{ \
17 unsigned long flags; \
18 flags = hard_local_irq_save(); \
19 bfin_write16(FIO_FLAG_##name, val); \
20 bfin_read_CHIPID(); \
21 hard_local_irq_restore(flags); \
22}
23BFIN_WRITE_FIO_FLAG(D)
24BFIN_WRITE_FIO_FLAG(C)
25BFIN_WRITE_FIO_FLAG(S)
26BFIN_WRITE_FIO_FLAG(T)
27
28#define BFIN_READ_FIO_FLAG(name) \
29static inline u16 bfin_read_FIO_FLAG_##name(void) \
30{ \
31 unsigned long flags; \
32 u16 ret; \
33 flags = hard_local_irq_save(); \
34 ret = bfin_read16(FIO_FLAG_##name); \
35 bfin_read_CHIPID(); \
36 hard_local_irq_restore(flags); \
37 return ret; \
38}
39BFIN_READ_FIO_FLAG(D)
40BFIN_READ_FIO_FLAG(C)
41BFIN_READ_FIO_FLAG(S)
42BFIN_READ_FIO_FLAG(T)
43
44#else
45#define bfin_write_FIO_FLAG_D(val) bfin_write16(FIO_FLAG_D, val)
46#define bfin_write_FIO_FLAG_C(val) bfin_write16(FIO_FLAG_C, val)
47#define bfin_write_FIO_FLAG_S(val) bfin_write16(FIO_FLAG_S, val)
48#define bfin_write_FIO_FLAG_T(val) bfin_write16(FIO_FLAG_T, val)
49#define bfin_read_FIO_FLAG_T() bfin_read16(FIO_FLAG_T)
50#define bfin_read_FIO_FLAG_C() bfin_read16(FIO_FLAG_C)
51#define bfin_read_FIO_FLAG_S() bfin_read16(FIO_FLAG_S)
52#define bfin_read_FIO_FLAG_D() bfin_read16(FIO_FLAG_D)
53#endif
54
55#endif /* _MACH_FIO_FLAG_H */
diff --git a/arch/blackfin/mach-bf533/include/mach/pll.h b/arch/blackfin/mach-bf533/include/mach/pll.h
new file mode 100644
index 000000000000..169c106d0edb
--- /dev/null
+++ b/arch/blackfin/mach-bf533/include/mach/pll.h
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2005-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr = bfin_read32(SIC_IWR);
24 /* Only allow PPL Wakeup) */
25 bfin_write32(SIC_IWR, IWR_ENABLE(0));
26
27 bfin_write16(PLL_CTL, val);
28 SSYNC();
29 asm("IDLE;");
30
31 bfin_write32(SIC_IWR, iwr);
32 hard_local_irq_restore(flags);
33}
34
35/* Writing to VR_CTL initiates a PLL relock sequence. */
36static __inline__ void bfin_write_VR_CTL(unsigned int val)
37{
38 unsigned long flags, iwr;
39
40 if (val == bfin_read_VR_CTL())
41 return;
42
43 flags = hard_local_irq_save();
44 /* Enable the PLL Wakeup bit in SIC IWR */
45 iwr = bfin_read32(SIC_IWR);
46 /* Only allow PPL Wakeup) */
47 bfin_write32(SIC_IWR, IWR_ENABLE(0));
48
49 bfin_write16(VR_CTL, val);
50 SSYNC();
51 asm("IDLE;");
52
53 bfin_write32(SIC_IWR, iwr);
54 hard_local_irq_restore(flags);
55}
56
57#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf537/Kconfig b/arch/blackfin/mach-bf537/Kconfig
index d81224f9d723..08b2b343ccec 100644
--- a/arch/blackfin/mach-bf537/Kconfig
+++ b/arch/blackfin/mach-bf537/Kconfig
@@ -14,8 +14,8 @@ config IRQ_DMA_ERROR
14 int "IRQ_DMA_ERROR Generic" 14 int "IRQ_DMA_ERROR Generic"
15 default 7 15 default 7
16config IRQ_ERROR 16config IRQ_ERROR
17 int "IRQ_ERROR: CAN MAC SPORT0 SPORT1 SPI UART0 UART1" 17 int "IRQ_ERROR: PPI CAN MAC SPORT0 SPORT1 SPI UART0 UART1"
18 default 7 18 default 11
19config IRQ_RTC 19config IRQ_RTC
20 int "IRQ_RTC" 20 int "IRQ_RTC"
21 default 8 21 default 8
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537e.c b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
index d35fc5fe4c2b..e2e7be40ef44 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537e.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537e.c
@@ -73,7 +73,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
73}; 73};
74#endif 74#endif
75 75
76#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 76#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
77static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 77static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
78 .enable_dma = 0, 78 .enable_dma = 0,
79 .bits_per_word = 16, 79 .bits_per_word = 16,
@@ -112,12 +112,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
112 }, 112 },
113#endif 113#endif
114 114
115#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 115#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
116 { 116 {
117 .modalias = "ad1836", 117 .modalias = "ad183x",
118 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 118 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
119 .bus_num = 0, 119 .bus_num = 0,
120 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 120 .chip_select = 4,
121 .controller_data = &ad1836_spi_chip_info, 121 .controller_data = &ad1836_spi_chip_info,
122 }, 122 },
123#endif 123#endif
@@ -229,7 +229,7 @@ static struct resource isp1362_hcd_resources[] = {
229 }, { 229 }, {
230 .start = IRQ_PG15, 230 .start = IRQ_PG15,
231 .end = IRQ_PG15, 231 .end = IRQ_PG15,
232 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 232 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
233 }, 233 },
234}; 234};
235 235
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
index d464ad5b72b2..752c833f7ca8 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537u.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
@@ -74,7 +74,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
74}; 74};
75#endif 75#endif
76 76
77#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 77#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
78static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 78static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
79 .enable_dma = 0, 79 .enable_dma = 0,
80 .bits_per_word = 16, 80 .bits_per_word = 16,
@@ -113,12 +113,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
113 }, 113 },
114#endif 114#endif
115 115
116#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 116#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
117 { 117 {
118 .modalias = "ad1836", 118 .modalias = "ad183x",
119 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 119 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
120 .bus_num = 0, 120 .bus_num = 0,
121 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 121 .chip_select = 4,
122 .controller_data = &ad1836_spi_chip_info, 122 .controller_data = &ad1836_spi_chip_info,
123 }, 123 },
124#endif 124#endif
@@ -230,7 +230,7 @@ static struct resource isp1362_hcd_resources[] = {
230 }, { 230 }, {
231 .start = IRQ_PG15, 231 .start = IRQ_PG15,
232 .end = IRQ_PG15, 232 .end = IRQ_PG15,
233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
234 }, 234 },
235}; 235};
236 236
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
index 812e8f991601..6b03808800a6 100644
--- a/arch/blackfin/mach-bf537/boards/pnav10.c
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -175,8 +175,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
175}; 175};
176#endif 176#endif
177 177
178#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 178#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
179 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 179 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
180static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 180static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
181 .enable_dma = 0, 181 .enable_dma = 0,
182 .bits_per_word = 16, 182 .bits_per_word = 16,
@@ -238,13 +238,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
238 }, 238 },
239#endif 239#endif
240 240
241#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 241#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
242 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 242 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
243 { 243 {
244 .modalias = "ad1836", 244 .modalias = "ad183x",
245 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 245 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
246 .bus_num = 0, 246 .bus_num = 0,
247 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 247 .chip_select = 4,
248 .controller_data = &ad1836_spi_chip_info, 248 .controller_data = &ad1836_spi_chip_info,
249 }, 249 },
250#endif 250#endif
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 68a27bccc7d4..cd2c797c8c9f 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -35,12 +35,10 @@
35#include <asm/reboot.h> 35#include <asm/reboot.h>
36#include <asm/portmux.h> 36#include <asm/portmux.h>
37#include <asm/dpmc.h> 37#include <asm/dpmc.h>
38#ifdef CONFIG_REGULATOR_ADP_SWITCH 38#ifdef CONFIG_REGULATOR_FIXED_VOLTAGE
39#include <linux/regulator/adp_switch.h> 39#include <linux/regulator/fixed.h>
40#endif
41#ifdef CONFIG_REGULATOR_AD5398
42#include <linux/regulator/ad5398.h>
43#endif 40#endif
41#include <linux/regulator/machine.h>
44#include <linux/regulator/consumer.h> 42#include <linux/regulator/consumer.h>
45#include <linux/regulator/userspace-consumer.h> 43#include <linux/regulator/userspace-consumer.h>
46 44
@@ -264,7 +262,7 @@ static struct resource isp1362_hcd_resources[] = {
264 }, { 262 }, {
265 .start = IRQ_PF3, 263 .start = IRQ_PF3,
266 .end = IRQ_PF3, 264 .end = IRQ_PF3,
267 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 265 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
268 }, 266 },
269}; 267};
270 268
@@ -418,7 +416,7 @@ static struct platform_nand_data bfin_plat_nand_data = {
418static struct resource bfin_plat_nand_resources = { 416static struct resource bfin_plat_nand_resources = {
419 .start = 0x20212000, 417 .start = 0x20212000,
420 .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)), 418 .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
421 .flags = IORESOURCE_IO, 419 .flags = IORESOURCE_MEM,
422}; 420};
423 421
424static struct platform_device bfin_async_nand_device = { 422static struct platform_device bfin_async_nand_device = {
@@ -545,6 +543,14 @@ static struct bfin5xx_spi_chip ad1938_spi_chip_info = {
545}; 543};
546#endif 544#endif
547 545
546#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) \
547 || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
548static struct bfin5xx_spi_chip adav801_spi_chip_info = {
549 .enable_dma = 0,
550 .bits_per_word = 8,
551};
552#endif
553
548#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 554#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
549#include <linux/input/ad714x.h> 555#include <linux/input/ad714x.h>
550static struct bfin5xx_spi_chip ad7147_spi_chip_info = { 556static struct bfin5xx_spi_chip ad7147_spi_chip_info = {
@@ -693,6 +699,65 @@ static struct bfin5xx_spi_chip ad2s1210_spi_chip_info = {
693}; 699};
694#endif 700#endif
695 701
702#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE)
703static struct bfin5xx_spi_chip ad7314_spi_chip_info = {
704 .enable_dma = 0,
705 .bits_per_word = 16,
706};
707#endif
708
709#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE)
710static unsigned short ad7816_platform_data[] = {
711 GPIO_PF4, /* rdwr_pin */
712 GPIO_PF5, /* convert_pin */
713 GPIO_PF7, /* busy_pin */
714 0,
715};
716
717static struct bfin5xx_spi_chip ad7816_spi_chip_info = {
718 .enable_dma = 0,
719 .bits_per_word = 8,
720};
721#endif
722
723#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE)
724static unsigned long adt7310_platform_data[3] = {
725/* INT bound temperature alarm event. line 1 */
726 IRQ_PG4, IRQF_TRIGGER_LOW,
727/* CT bound temperature alarm event irq_flags. line 0 */
728 IRQF_TRIGGER_LOW,
729};
730
731static struct bfin5xx_spi_chip adt7310_spi_chip_info = {
732 .enable_dma = 0,
733 .bits_per_word = 8,
734};
735#endif
736
737#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE)
738static unsigned short ad7298_platform_data[] = {
739 GPIO_PF7, /* busy_pin */
740 0,
741};
742
743static struct bfin5xx_spi_chip ad7298_spi_chip_info = {
744 .enable_dma = 0,
745 .bits_per_word = 16,
746};
747#endif
748
749#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE)
750static unsigned long adt7316_spi_data[2] = {
751 IRQF_TRIGGER_LOW, /* interrupt flags */
752 GPIO_PF7, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */
753};
754
755static struct bfin5xx_spi_chip adt7316_spi_chip_info = {
756 .enable_dma = 0,
757 .bits_per_word = 8,
758};
759#endif
760
696#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 761#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
697#define MMC_SPI_CARD_DETECT_INT IRQ_PF5 762#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
698 763
@@ -824,14 +889,12 @@ static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
824static struct bfin5xx_spi_chip enc28j60_spi_chip_info = { 889static struct bfin5xx_spi_chip enc28j60_spi_chip_info = {
825 .enable_dma = 1, 890 .enable_dma = 1,
826 .bits_per_word = 8, 891 .bits_per_word = 8,
827 .cs_gpio = GPIO_PF10,
828}; 892};
829#endif 893#endif
830 894
831#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE) 895#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE)
832static struct bfin5xx_spi_chip adf7021_spi_chip_info = { 896static struct bfin5xx_spi_chip adf7021_spi_chip_info = {
833 .bits_per_word = 16, 897 .bits_per_word = 16,
834 .cs_gpio = GPIO_PF10,
835}; 898};
836 899
837#include <linux/spi/adf702x.h> 900#include <linux/spi/adf702x.h>
@@ -938,6 +1001,13 @@ static struct bfin5xx_spi_chip spi_adxl34x_chip_info = {
938}; 1001};
939#endif 1002#endif
940 1003
1004#if defined(CONFIG_AD7476) || defined(CONFIG_AD7476_MODULE)
1005static struct bfin5xx_spi_chip spi_ad7476_chip_info = {
1006 .enable_dma = 0, /* use dma transfer with this chip*/
1007 .bits_per_word = 8,
1008};
1009#endif
1010
941static struct spi_board_info bfin_spi_board_info[] __initdata = { 1011static struct spi_board_info bfin_spi_board_info[] __initdata = {
942#if defined(CONFIG_MTD_M25P80) \ 1012#if defined(CONFIG_MTD_M25P80) \
943 || defined(CONFIG_MTD_M25P80_MODULE) 1013 || defined(CONFIG_MTD_M25P80_MODULE)
@@ -982,7 +1052,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
982 .modalias = "ad183x", 1052 .modalias = "ad183x",
983 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1053 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
984 .bus_num = 0, 1054 .bus_num = 0,
985 .chip_select = 4,/* CONFIG_SND_BLACKFIN_SPI_PFBIT */ 1055 .chip_select = 4,
986 .platform_data = "ad1836", /* only includes chip name for the moment */ 1056 .platform_data = "ad1836", /* only includes chip name for the moment */
987 .controller_data = &ad1836_spi_chip_info, 1057 .controller_data = &ad1836_spi_chip_info,
988 .mode = SPI_MODE_3, 1058 .mode = SPI_MODE_3,
@@ -1000,6 +1070,17 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1000 }, 1070 },
1001#endif 1071#endif
1002 1072
1073#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
1074 {
1075 .modalias = "adav80x",
1076 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
1077 .bus_num = 0,
1078 .chip_select = 1,
1079 .controller_data = &adav801_spi_chip_info,
1080 .mode = SPI_MODE_3,
1081 },
1082#endif
1083
1003#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 1084#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
1004 { 1085 {
1005 .modalias = "ad714x_captouch", 1086 .modalias = "ad714x_captouch",
@@ -1018,6 +1099,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1018 .modalias = "ad2s90", 1099 .modalias = "ad2s90",
1019 .bus_num = 0, 1100 .bus_num = 0,
1020 .chip_select = 3, /* change it for your board */ 1101 .chip_select = 3, /* change it for your board */
1102 .mode = SPI_MODE_3,
1021 .platform_data = NULL, 1103 .platform_data = NULL,
1022 .controller_data = &ad2s90_spi_chip_info, 1104 .controller_data = &ad2s90_spi_chip_info,
1023 }, 1105 },
@@ -1044,6 +1126,67 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1044 }, 1126 },
1045#endif 1127#endif
1046 1128
1129#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE)
1130 {
1131 .modalias = "ad7314",
1132 .max_speed_hz = 1000000,
1133 .bus_num = 0,
1134 .chip_select = 4, /* CS, change it for your board */
1135 .controller_data = &ad7314_spi_chip_info,
1136 .mode = SPI_MODE_1,
1137 },
1138#endif
1139
1140#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE)
1141 {
1142 .modalias = "ad7818",
1143 .max_speed_hz = 1000000,
1144 .bus_num = 0,
1145 .chip_select = 4, /* CS, change it for your board */
1146 .platform_data = ad7816_platform_data,
1147 .controller_data = &ad7816_spi_chip_info,
1148 .mode = SPI_MODE_3,
1149 },
1150#endif
1151
1152#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE)
1153 {
1154 .modalias = "adt7310",
1155 .max_speed_hz = 1000000,
1156 .irq = IRQ_PG5, /* CT alarm event. Line 0 */
1157 .bus_num = 0,
1158 .chip_select = 4, /* CS, change it for your board */
1159 .platform_data = adt7310_platform_data,
1160 .controller_data = &adt7310_spi_chip_info,
1161 .mode = SPI_MODE_3,
1162 },
1163#endif
1164
1165#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE)
1166 {
1167 .modalias = "ad7298",
1168 .max_speed_hz = 1000000,
1169 .bus_num = 0,
1170 .chip_select = 4, /* CS, change it for your board */
1171 .platform_data = ad7298_platform_data,
1172 .controller_data = &ad7298_spi_chip_info,
1173 .mode = SPI_MODE_3,
1174 },
1175#endif
1176
1177#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE)
1178 {
1179 .modalias = "adt7316",
1180 .max_speed_hz = 1000000,
1181 .irq = IRQ_PG5, /* interrupt line */
1182 .bus_num = 0,
1183 .chip_select = 4, /* CS, change it for your board */
1184 .platform_data = adt7316_spi_data,
1185 .controller_data = &adt7316_spi_chip_info,
1186 .mode = SPI_MODE_3,
1187 },
1188#endif
1189
1047#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 1190#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
1048 { 1191 {
1049 .modalias = "mmc_spi", 1192 .modalias = "mmc_spi",
@@ -1103,7 +1246,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1103 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 1246 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
1104 .irq = IRQ_PF6, 1247 .irq = IRQ_PF6,
1105 .bus_num = 0, 1248 .bus_num = 0,
1106 .chip_select = 0, /* GPIO controlled SSEL */ 1249 .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* GPIO controlled SSEL */
1107 .controller_data = &enc28j60_spi_chip_info, 1250 .controller_data = &enc28j60_spi_chip_info,
1108 .mode = SPI_MODE_0, 1251 .mode = SPI_MODE_0,
1109 }, 1252 },
@@ -1125,7 +1268,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1125 .modalias = "adf702x", 1268 .modalias = "adf702x",
1126 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */ 1269 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */
1127 .bus_num = 0, 1270 .bus_num = 0,
1128 .chip_select = 0, /* GPIO controlled SSEL */ 1271 .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* GPIO controlled SSEL */
1129 .controller_data = &adf7021_spi_chip_info, 1272 .controller_data = &adf7021_spi_chip_info,
1130 .platform_data = &adf7021_platform_data, 1273 .platform_data = &adf7021_platform_data,
1131 .mode = SPI_MODE_0, 1274 .mode = SPI_MODE_0,
@@ -1143,12 +1286,239 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1143 .mode = SPI_MODE_0, 1286 .mode = SPI_MODE_0,
1144 }, 1287 },
1145#endif 1288#endif
1289#if defined(CONFIG_AD7476) \
1290 || defined(CONFIG_AD7476_MODULE)
1291 {
1292 .modalias = "ad7476", /* Name of spi_driver for this device */
1293 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
1294 .bus_num = 0, /* Framework bus number */
1295 .chip_select = 1, /* Framework chip select. */
1296 .platform_data = NULL, /* No spi_driver specific config */
1297 .controller_data = &spi_ad7476_chip_info,
1298 .mode = SPI_MODE_3,
1299 },
1300#endif
1301#if defined(CONFIG_ADE7753) \
1302 || defined(CONFIG_ADE7753_MODULE)
1303 {
1304 .modalias = "ade7753",
1305 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1306 .bus_num = 0,
1307 .chip_select = 1, /* CS, change it for your board */
1308 .platform_data = NULL, /* No spi_driver specific config */
1309 .mode = SPI_MODE_1,
1310 },
1311#endif
1312#if defined(CONFIG_ADE7754) \
1313 || defined(CONFIG_ADE7754_MODULE)
1314 {
1315 .modalias = "ade7754",
1316 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1317 .bus_num = 0,
1318 .chip_select = 1, /* CS, change it for your board */
1319 .platform_data = NULL, /* No spi_driver specific config */
1320 .mode = SPI_MODE_1,
1321 },
1322#endif
1323#if defined(CONFIG_ADE7758) \
1324 || defined(CONFIG_ADE7758_MODULE)
1325 {
1326 .modalias = "ade7758",
1327 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1328 .bus_num = 0,
1329 .chip_select = 1, /* CS, change it for your board */
1330 .platform_data = NULL, /* No spi_driver specific config */
1331 .mode = SPI_MODE_1,
1332 },
1333#endif
1334#if defined(CONFIG_ADE7759) \
1335 || defined(CONFIG_ADE7759_MODULE)
1336 {
1337 .modalias = "ade7759",
1338 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1339 .bus_num = 0,
1340 .chip_select = 1, /* CS, change it for your board */
1341 .platform_data = NULL, /* No spi_driver specific config */
1342 .mode = SPI_MODE_1,
1343 },
1344#endif
1345#if defined(CONFIG_ADE7854_SPI) \
1346 || defined(CONFIG_ADE7854_SPI_MODULE)
1347 {
1348 .modalias = "ade7854",
1349 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1350 .bus_num = 0,
1351 .chip_select = 1, /* CS, change it for your board */
1352 .platform_data = NULL, /* No spi_driver specific config */
1353 .mode = SPI_MODE_3,
1354 },
1355#endif
1356#if defined(CONFIG_ADIS16060) \
1357 || defined(CONFIG_ADIS16060_MODULE)
1358 {
1359 .modalias = "adis16060_r",
1360 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */
1361 .bus_num = 0,
1362 .chip_select = MAX_CTRL_CS + 1, /* CS for read, change it for your board */
1363 .platform_data = NULL, /* No spi_driver specific config */
1364 .mode = SPI_MODE_0,
1365 },
1366 {
1367 .modalias = "adis16060_w",
1368 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */
1369 .bus_num = 0,
1370 .chip_select = 2, /* CS for write, change it for your board */
1371 .platform_data = NULL, /* No spi_driver specific config */
1372 .mode = SPI_MODE_1,
1373 },
1374#endif
1375#if defined(CONFIG_ADIS16130) \
1376 || defined(CONFIG_ADIS16130_MODULE)
1377 {
1378 .modalias = "adis16130",
1379 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1380 .bus_num = 0,
1381 .chip_select = 1, /* CS for read, change it for your board */
1382 .platform_data = NULL, /* No spi_driver specific config */
1383 .mode = SPI_MODE_3,
1384 },
1385#endif
1386#if defined(CONFIG_ADIS16201) \
1387 || defined(CONFIG_ADIS16201_MODULE)
1388 {
1389 .modalias = "adis16201",
1390 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1391 .bus_num = 0,
1392 .chip_select = 5, /* CS, change it for your board */
1393 .platform_data = NULL, /* No spi_driver specific config */
1394 .mode = SPI_MODE_3,
1395 .irq = IRQ_PF4,
1396 },
1397#endif
1398#if defined(CONFIG_ADIS16203) \
1399 || defined(CONFIG_ADIS16203_MODULE)
1400 {
1401 .modalias = "adis16203",
1402 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1403 .bus_num = 0,
1404 .chip_select = 5, /* CS, change it for your board */
1405 .platform_data = NULL, /* No spi_driver specific config */
1406 .mode = SPI_MODE_3,
1407 .irq = IRQ_PF4,
1408 },
1409#endif
1410#if defined(CONFIG_ADIS16204) \
1411 || defined(CONFIG_ADIS16204_MODULE)
1412 {
1413 .modalias = "adis16204",
1414 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1415 .bus_num = 0,
1416 .chip_select = 5, /* CS, change it for your board */
1417 .platform_data = NULL, /* No spi_driver specific config */
1418 .mode = SPI_MODE_3,
1419 .irq = IRQ_PF4,
1420 },
1421#endif
1422#if defined(CONFIG_ADIS16209) \
1423 || defined(CONFIG_ADIS16209_MODULE)
1424 {
1425 .modalias = "adis16209",
1426 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1427 .bus_num = 0,
1428 .chip_select = 5, /* CS, change it for your board */
1429 .platform_data = NULL, /* No spi_driver specific config */
1430 .mode = SPI_MODE_3,
1431 .irq = IRQ_PF4,
1432 },
1433#endif
1434#if defined(CONFIG_ADIS16220) \
1435 || defined(CONFIG_ADIS16220_MODULE)
1436 {
1437 .modalias = "adis16220",
1438 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */
1439 .bus_num = 0,
1440 .chip_select = 5, /* CS, change it for your board */
1441 .platform_data = NULL, /* No spi_driver specific config */
1442 .mode = SPI_MODE_3,
1443 .irq = IRQ_PF4,
1444 },
1445#endif
1446#if defined(CONFIG_ADIS16240) \
1447 || defined(CONFIG_ADIS16240_MODULE)
1448 {
1449 .modalias = "adis16240",
1450 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
1451 .bus_num = 0,
1452 .chip_select = 5, /* CS, change it for your board */
1453 .platform_data = NULL, /* No spi_driver specific config */
1454 .mode = SPI_MODE_3,
1455 .irq = IRQ_PF4,
1456 },
1457#endif
1458#if defined(CONFIG_ADIS16260) \
1459 || defined(CONFIG_ADIS16260_MODULE)
1460 {
1461 .modalias = "adis16260",
1462 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
1463 .bus_num = 0,
1464 .chip_select = 5, /* CS, change it for your board */
1465 .platform_data = NULL, /* No spi_driver specific config */
1466 .mode = SPI_MODE_3,
1467 .irq = IRQ_PF4,
1468 },
1469#endif
1470#if defined(CONFIG_ADIS16261) \
1471 || defined(CONFIG_ADIS16261_MODULE)
1472 {
1473 .modalias = "adis16261",
1474 .max_speed_hz = 2500000, /* max spi clock (SCK) speed in HZ */
1475 .bus_num = 0,
1476 .chip_select = 1, /* CS, change it for your board */
1477 .platform_data = NULL, /* No spi_driver specific config */
1478 .mode = SPI_MODE_3,
1479 },
1480#endif
1481#if defined(CONFIG_ADIS16300) \
1482 || defined(CONFIG_ADIS16300_MODULE)
1483 {
1484 .modalias = "adis16300",
1485 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1486 .bus_num = 0,
1487 .chip_select = 5, /* CS, change it for your board */
1488 .platform_data = NULL, /* No spi_driver specific config */
1489 .mode = SPI_MODE_3,
1490 .irq = IRQ_PF4,
1491 },
1492#endif
1493#if defined(CONFIG_ADIS16350) \
1494 || defined(CONFIG_ADIS16350_MODULE)
1495 {
1496 .modalias = "adis16364",
1497 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1498 .bus_num = 0,
1499 .chip_select = 5, /* CS, change it for your board */
1500 .platform_data = NULL, /* No spi_driver specific config */
1501 .mode = SPI_MODE_3,
1502 .irq = IRQ_PF4,
1503 },
1504#endif
1505#if defined(CONFIG_ADIS16400) \
1506 || defined(CONFIG_ADIS16400_MODULE)
1507 {
1508 .modalias = "adis16400",
1509 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1510 .bus_num = 0,
1511 .chip_select = 1, /* CS, change it for your board */
1512 .platform_data = NULL, /* No spi_driver specific config */
1513 .mode = SPI_MODE_3,
1514 },
1515#endif
1146}; 1516};
1147 1517
1148#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 1518#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1149/* SPI controller data */ 1519/* SPI controller data */
1150static struct bfin5xx_spi_master bfin_spi0_info = { 1520static struct bfin5xx_spi_master bfin_spi0_info = {
1151 .num_chipselect = 8, 1521 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
1152 .enable_dma = 1, /* master has the ability to do dma transfer */ 1522 .enable_dma = 1, /* master has the ability to do dma transfer */
1153 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 1523 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1154}; 1524};
@@ -1645,7 +2015,7 @@ static struct adp5520_keys_platform_data adp5520_keys_data = {
1645}; 2015};
1646 2016
1647 /* 2017 /*
1648 * ADP5520/5501 Multifuction Device Init Data 2018 * ADP5520/5501 Multifunction Device Init Data
1649 */ 2019 */
1650 2020
1651static struct adp5520_platform_data adp5520_pdev_data = { 2021static struct adp5520_platform_data adp5520_pdev_data = {
@@ -1773,12 +2143,6 @@ static struct regulator_init_data ad5398_regulator_data = {
1773 .consumer_supplies = &ad5398_consumer, 2143 .consumer_supplies = &ad5398_consumer,
1774}; 2144};
1775 2145
1776static struct ad5398_platform_data ad5398_i2c_platform_data = {
1777 .current_bits = 10,
1778 .current_offset = 4,
1779 .regulator_data = &ad5398_regulator_data,
1780};
1781
1782#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \ 2146#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \
1783 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE) 2147 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
1784static struct platform_device ad5398_virt_consumer_device = { 2148static struct platform_device ad5398_virt_consumer_device = {
@@ -1811,7 +2175,34 @@ static struct platform_device ad5398_userspace_consumer_device = {
1811#endif 2175#endif
1812#endif 2176#endif
1813 2177
2178#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE)
2179/* INT bound temperature alarm event. line 1 */
2180static unsigned long adt7410_platform_data[2] = {
2181 IRQ_PG4, IRQF_TRIGGER_LOW,
2182};
2183#endif
2184
2185#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE)
2186/* INT bound temperature alarm event. line 1 */
2187static unsigned long adt7316_i2c_data[2] = {
2188 IRQF_TRIGGER_LOW, /* interrupt flags */
2189 GPIO_PF4, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */
2190};
2191#endif
2192
1814static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 2193static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2194#if defined(CONFIG_SND_BF5XX_SOC_AD193X) || defined(CONFIG_SND_BF5XX_SOC_AD193X_MODULE)
2195 {
2196 I2C_BOARD_INFO("ad1937", 0x04),
2197 },
2198#endif
2199
2200#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
2201 {
2202 I2C_BOARD_INFO("adav803", 0x10),
2203 },
2204#endif
2205
1815#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE) 2206#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE)
1816 { 2207 {
1817 I2C_BOARD_INFO("ad7142_captouch", 0x2C), 2208 I2C_BOARD_INFO("ad7142_captouch", 0x2C),
@@ -1843,12 +2234,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1843 { 2234 {
1844 I2C_BOARD_INFO("ad7414", 0x9), 2235 I2C_BOARD_INFO("ad7414", 0x9),
1845 .irq = IRQ_PG5, 2236 .irq = IRQ_PG5,
1846 /* 2237 .irq_flags = IRQF_TRIGGER_LOW,
1847 * platform_data pointer is borrwoed by the driver to
1848 * store custimer defined IRQ ALART level mode.
1849 * only IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW are valid.
1850 */
1851 .platform_data = (void *)IRQF_TRIGGER_LOW,
1852 }, 2238 },
1853#endif 2239#endif
1854 2240
@@ -1856,12 +2242,56 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1856 { 2242 {
1857 I2C_BOARD_INFO("ad7417", 0xb), 2243 I2C_BOARD_INFO("ad7417", 0xb),
1858 .irq = IRQ_PG5, 2244 .irq = IRQ_PG5,
1859 /* 2245 .irq_flags = IRQF_TRIGGER_LOW,
1860 * platform_data pointer is borrwoed by the driver to 2246 .platform_data = (void *)GPIO_PF4,
1861 * store custimer defined IRQ ALART level mode. 2247 },
1862 * only IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW are valid. 2248#endif
1863 */ 2249
1864 .platform_data = (void *)IRQF_TRIGGER_LOW, 2250#if defined(CONFIG_ADE7854_I2C) || defined(CONFIG_ADE7854_I2C_MODULE)
2251 {
2252 I2C_BOARD_INFO("ade7854", 0x38),
2253 },
2254#endif
2255
2256#if defined(CONFIG_ADT75) || defined(CONFIG_ADT75_MODULE)
2257 {
2258 I2C_BOARD_INFO("adt75", 0x9),
2259 .irq = IRQ_PG5,
2260 .irq_flags = IRQF_TRIGGER_LOW,
2261 },
2262#endif
2263
2264#if defined(CONFIG_ADT7408) || defined(CONFIG_ADT7408_MODULE)
2265 {
2266 I2C_BOARD_INFO("adt7408", 0x18),
2267 .irq = IRQ_PG5,
2268 .irq_flags = IRQF_TRIGGER_LOW,
2269 },
2270#endif
2271
2272#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE)
2273 {
2274 I2C_BOARD_INFO("adt7410", 0x48),
2275 /* CT critical temperature event. line 0 */
2276 .irq = IRQ_PG5,
2277 .irq_flags = IRQF_TRIGGER_LOW,
2278 .platform_data = (void *)&adt7410_platform_data,
2279 },
2280#endif
2281
2282#if defined(CONFIG_AD7291) || defined(CONFIG_AD7291_MODULE)
2283 {
2284 I2C_BOARD_INFO("ad7291", 0x20),
2285 .irq = IRQ_PG5,
2286 .irq_flags = IRQF_TRIGGER_LOW,
2287 },
2288#endif
2289
2290#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE)
2291 {
2292 I2C_BOARD_INFO("adt7316", 0x48),
2293 .irq = IRQ_PG6,
2294 .platform_data = (void *)&adt7316_i2c_data,
1865 }, 2295 },
1866#endif 2296#endif
1867 2297
@@ -1917,7 +2347,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1917#endif 2347#endif
1918#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 2348#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
1919 { 2349 {
1920 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2C), 2350 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2F),
1921 }, 2351 },
1922#endif 2352#endif
1923#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE) 2353#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE)
@@ -1954,7 +2384,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1954#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE) 2384#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
1955 { 2385 {
1956 I2C_BOARD_INFO("ad5398", 0xC), 2386 I2C_BOARD_INFO("ad5398", 0xC),
1957 .platform_data = (void *)&ad5398_i2c_platform_data, 2387 .platform_data = (void *)&ad5398_regulator_data,
1958 }, 2388 },
1959#endif 2389#endif
1960#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE) 2390#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE)
@@ -1963,6 +2393,16 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1963 .platform_data = (void *)&adp8860_pdata, 2393 .platform_data = (void *)&adp8860_pdata,
1964 }, 2394 },
1965#endif 2395#endif
2396#if defined(CONFIG_SND_SOC_ADAU1373) || defined(CONFIG_SND_SOC_ADAU1373_MODULE)
2397 {
2398 I2C_BOARD_INFO("adau1373", 0x1A),
2399 },
2400#endif
2401#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
2402 {
2403 I2C_BOARD_INFO("ad5252", 0x2e),
2404 },
2405#endif
1966}; 2406};
1967 2407
1968#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 2408#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -2147,50 +2587,38 @@ static struct platform_device bfin_ac97 = {
2147}; 2587};
2148#endif 2588#endif
2149 2589
2150#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE) 2590#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
2151#define REGULATOR_ADP122 "adp122" 2591#define REGULATOR_ADP122 "adp122"
2152#define REGULATOR_ADP150 "adp150" 2592#define REGULATOR_ADP122_UV 2500000
2153 2593
2154static struct regulator_consumer_supply adp122_consumers = { 2594static struct regulator_consumer_supply adp122_consumers = {
2155 .supply = REGULATOR_ADP122, 2595 .supply = REGULATOR_ADP122,
2156}; 2596};
2157 2597
2158static struct regulator_consumer_supply adp150_consumers = { 2598static struct regulator_init_data adp_switch_regulator_data = {
2159 .supply = REGULATOR_ADP150, 2599 .constraints = {
2160}; 2600 .name = REGULATOR_ADP122,
2161 2601 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2162static struct regulator_init_data adp_switch_regulator_data[] = { 2602 .min_uV = REGULATOR_ADP122_UV,
2163 { 2603 .max_uV = REGULATOR_ADP122_UV,
2164 .constraints = { 2604 .min_uA = 0,
2165 .name = REGULATOR_ADP122, 2605 .max_uA = 300000,
2166 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2167 .min_uA = 0,
2168 .max_uA = 300000,
2169 },
2170 .num_consumer_supplies = 1, /* only 1 */
2171 .consumer_supplies = &adp122_consumers,
2172 .driver_data = (void *)GPIO_PF2, /* gpio port only */
2173 },
2174 {
2175 .constraints = {
2176 .name = REGULATOR_ADP150,
2177 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2178 .min_uA = 0,
2179 .max_uA = 150000,
2180 },
2181 .num_consumer_supplies = 1, /* only 1 */
2182 .consumer_supplies = &adp150_consumers,
2183 .driver_data = (void *)GPIO_PF3, /* gpio port only */
2184 }, 2606 },
2607 .num_consumer_supplies = 1, /* only 1 */
2608 .consumer_supplies = &adp122_consumers,
2185}; 2609};
2186 2610
2187static struct adp_switch_platform_data adp_switch_pdata = { 2611static struct fixed_voltage_config adp_switch_pdata = {
2188 .regulator_num = ARRAY_SIZE(adp_switch_regulator_data), 2612 .supply_name = REGULATOR_ADP122,
2189 .regulator_data = adp_switch_regulator_data, 2613 .microvolts = REGULATOR_ADP122_UV,
2614 .gpio = GPIO_PF2,
2615 .enable_high = 1,
2616 .enabled_at_boot = 0,
2617 .init_data = &adp_switch_regulator_data,
2190}; 2618};
2191 2619
2192static struct platform_device adp_switch_device = { 2620static struct platform_device adp_switch_device = {
2193 .name = "adp_switch", 2621 .name = "reg-fixed-voltage",
2194 .id = 0, 2622 .id = 0,
2195 .dev = { 2623 .dev = {
2196 .platform_data = &adp_switch_pdata, 2624 .platform_data = &adp_switch_pdata,
@@ -2216,27 +2644,26 @@ static struct platform_device adp122_userspace_consumer_device = {
2216 .platform_data = &adp122_userspace_comsumer_data, 2644 .platform_data = &adp122_userspace_comsumer_data,
2217 }, 2645 },
2218}; 2646};
2647#endif
2648#endif
2219 2649
2220static struct regulator_bulk_data adp150_bulk_data = { 2650#if defined(CONFIG_IIO_GPIO_TRIGGER) || \
2221 .supply = REGULATOR_ADP150, 2651 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2222};
2223 2652
2224static struct regulator_userspace_consumer_data adp150_userspace_comsumer_data = { 2653static struct resource iio_gpio_trigger_resources[] = {
2225 .name = REGULATOR_ADP150, 2654 [0] = {
2226 .num_supplies = 1, 2655 .start = IRQ_PF5,
2227 .supplies = &adp150_bulk_data, 2656 .end = IRQ_PF5,
2657 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
2658 },
2228}; 2659};
2229 2660
2230static struct platform_device adp150_userspace_consumer_device = { 2661static struct platform_device iio_gpio_trigger = {
2231 .name = "reg-userspace-consumer", 2662 .name = "iio_gpio_trigger",
2232 .id = 1, 2663 .num_resources = ARRAY_SIZE(iio_gpio_trigger_resources),
2233 .dev = { 2664 .resource = iio_gpio_trigger_resources,
2234 .platform_data = &adp150_userspace_comsumer_data,
2235 },
2236}; 2665};
2237#endif 2666#endif
2238#endif
2239
2240 2667
2241static struct platform_device *stamp_devices[] __initdata = { 2668static struct platform_device *stamp_devices[] __initdata = {
2242 2669
@@ -2369,14 +2796,18 @@ static struct platform_device *stamp_devices[] __initdata = {
2369#endif 2796#endif
2370#endif 2797#endif
2371 2798
2372#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE) 2799#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
2373 &adp_switch_device, 2800 &adp_switch_device,
2374#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2801#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
2375 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE) 2802 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2376 &adp122_userspace_consumer_device, 2803 &adp122_userspace_consumer_device,
2377 &adp150_userspace_consumer_device,
2378#endif 2804#endif
2379#endif 2805#endif
2806
2807#if defined(CONFIG_IIO_GPIO_TRIGGER) || \
2808 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2809 &iio_gpio_trigger,
2810#endif
2380}; 2811};
2381 2812
2382static int __init stamp_init(void) 2813static int __init stamp_init(void)
diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
index 4f0a2e72ce4c..a4d62b5fc7ba 100644
--- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c
@@ -74,7 +74,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
74}; 74};
75#endif 75#endif
76 76
77#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 77#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
78static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 78static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
79 .enable_dma = 0, 79 .enable_dma = 0,
80 .bits_per_word = 16, 80 .bits_per_word = 16,
@@ -113,12 +113,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
113 }, 113 },
114#endif 114#endif
115 115
116#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 116#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
117 { 117 {
118 .modalias = "ad1836", 118 .modalias = "ad183x",
119 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 119 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
120 .bus_num = 0, 120 .bus_num = 0,
121 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 121 .chip_select = 4,
122 .controller_data = &ad1836_spi_chip_info, 122 .controller_data = &ad1836_spi_chip_info,
123 }, 123 },
124#endif 124#endif
@@ -230,7 +230,7 @@ static struct resource isp1362_hcd_resources[] = {
230 }, { 230 }, {
231 .start = IRQ_PG15, 231 .start = IRQ_PG15,
232 .end = IRQ_PG15, 232 .end = IRQ_PG15,
233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
234 }, 234 },
235}; 235};
236 236
diff --git a/arch/blackfin/mach-bf537/include/mach/cdefBF534.h b/arch/blackfin/mach-bf537/include/mach/cdefBF534.h
index 91825c9bd226..fbeb35e14135 100644
--- a/arch/blackfin/mach-bf537/include/mach/cdefBF534.h
+++ b/arch/blackfin/mach-bf537/include/mach/cdefBF534.h
@@ -1750,48 +1750,4 @@
1750/* These need to be last due to the cdef/linux inter-dependencies */ 1750/* These need to be last due to the cdef/linux inter-dependencies */
1751#include <asm/irq.h> 1751#include <asm/irq.h>
1752 1752
1753/* Writing to PLL_CTL initiates a PLL relock sequence. */
1754static __inline__ void bfin_write_PLL_CTL(unsigned int val)
1755{
1756 unsigned long flags, iwr;
1757
1758 if (val == bfin_read_PLL_CTL())
1759 return;
1760
1761 local_irq_save_hw(flags);
1762 /* Enable the PLL Wakeup bit in SIC IWR */
1763 iwr = bfin_read32(SIC_IWR);
1764 /* Only allow PPL Wakeup) */
1765 bfin_write32(SIC_IWR, IWR_ENABLE(0));
1766
1767 bfin_write16(PLL_CTL, val);
1768 SSYNC();
1769 asm("IDLE;");
1770
1771 bfin_write32(SIC_IWR, iwr);
1772 local_irq_restore_hw(flags);
1773}
1774
1775/* Writing to VR_CTL initiates a PLL relock sequence. */
1776static __inline__ void bfin_write_VR_CTL(unsigned int val)
1777{
1778 unsigned long flags, iwr;
1779
1780 if (val == bfin_read_VR_CTL())
1781 return;
1782
1783 local_irq_save_hw(flags);
1784 /* Enable the PLL Wakeup bit in SIC IWR */
1785 iwr = bfin_read32(SIC_IWR);
1786 /* Only allow PPL Wakeup) */
1787 bfin_write32(SIC_IWR, IWR_ENABLE(0));
1788
1789 bfin_write16(VR_CTL, val);
1790 SSYNC();
1791 asm("IDLE;");
1792
1793 bfin_write32(SIC_IWR, iwr);
1794 local_irq_restore_hw(flags);
1795}
1796
1797#endif /* _CDEF_BF534_H */ 1753#endif /* _CDEF_BF534_H */
diff --git a/arch/blackfin/mach-bf537/include/mach/defBF534.h b/arch/blackfin/mach-bf537/include/mach/defBF534.h
index 6f56907a18c0..0323e6bacdae 100644
--- a/arch/blackfin/mach-bf537/include/mach/defBF534.h
+++ b/arch/blackfin/mach-bf537/include/mach/defBF534.h
@@ -1071,50 +1071,6 @@
1071#define FPE 0x10 /* Force Parity Error On Transmit */ 1071#define FPE 0x10 /* Force Parity Error On Transmit */
1072#define FFE 0x20 /* Force Framing Error On Transmit */ 1072#define FFE 0x20 /* Force Framing Error On Transmit */
1073 1073
1074/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS ****************************/
1075/* SPI_CTL Masks */
1076#define TIMOD 0x0003 /* Transfer Initiate Mode */
1077#define RDBR_CORE 0x0000 /* RDBR Read Initiates, IRQ When RDBR Full */
1078#define TDBR_CORE 0x0001 /* TDBR Write Initiates, IRQ When TDBR Empty */
1079#define RDBR_DMA 0x0002 /* DMA Read, DMA Until FIFO Empty */
1080#define TDBR_DMA 0x0003 /* DMA Write, DMA Until FIFO Full */
1081#define SZ 0x0004 /* Send Zero (When TDBR Empty, Send Zero/Last*) */
1082#define GM 0x0008 /* Get More (When RDBR Full, Overwrite/Discard*) */
1083#define PSSE 0x0010 /* Slave-Select Input Enable */
1084#define EMISO 0x0020 /* Enable MISO As Output */
1085#define SIZE 0x0100 /* Size of Words (16/8* Bits) */
1086#define LSBF 0x0200 /* LSB First */
1087#define CPHA 0x0400 /* Clock Phase */
1088#define CPOL 0x0800 /* Clock Polarity */
1089#define MSTR 0x1000 /* Master/Slave* */
1090#define WOM 0x2000 /* Write Open Drain Master */
1091#define SPE 0x4000 /* SPI Enable */
1092
1093/* SPI_FLG Masks */
1094#define FLS1 0x0002 /* Enables SPI_FLOUT1 as SPI Slave-Select Output */
1095#define FLS2 0x0004 /* Enables SPI_FLOUT2 as SPI Slave-Select Output */
1096#define FLS3 0x0008 /* Enables SPI_FLOUT3 as SPI Slave-Select Output */
1097#define FLS4 0x0010 /* Enables SPI_FLOUT4 as SPI Slave-Select Output */
1098#define FLS5 0x0020 /* Enables SPI_FLOUT5 as SPI Slave-Select Output */
1099#define FLS6 0x0040 /* Enables SPI_FLOUT6 as SPI Slave-Select Output */
1100#define FLS7 0x0080 /* Enables SPI_FLOUT7 as SPI Slave-Select Output */
1101#define FLG1 0xFDFF /* Activates SPI_FLOUT1 */
1102#define FLG2 0xFBFF /* Activates SPI_FLOUT2 */
1103#define FLG3 0xF7FF /* Activates SPI_FLOUT3 */
1104#define FLG4 0xEFFF /* Activates SPI_FLOUT4 */
1105#define FLG5 0xDFFF /* Activates SPI_FLOUT5 */
1106#define FLG6 0xBFFF /* Activates SPI_FLOUT6 */
1107#define FLG7 0x7FFF /* Activates SPI_FLOUT7 */
1108
1109/* SPI_STAT Masks */
1110#define SPIF 0x0001 /* SPI Finished (Single-Word Transfer Complete) */
1111#define MODF 0x0002 /* Mode Fault Error (Another Device Tried To Become Master) */
1112#define TXE 0x0004 /* Transmission Error (Data Sent With No New Data In TDBR) */
1113#define TXS 0x0008 /* SPI_TDBR Data Buffer Status (Full/Empty*) */
1114#define RBSY 0x0010 /* Receive Error (Data Received With RDBR Full) */
1115#define RXS 0x0020 /* SPI_RDBR Data Buffer Status (Full/Empty*) */
1116#define TXCOL 0x0040 /* Transmit Collision Error (Corrupt Data May Have Been Sent) */
1117
1118/* **************** GENERAL PURPOSE TIMER MASKS **********************/ 1074/* **************** GENERAL PURPOSE TIMER MASKS **********************/
1119/* TIMER_ENABLE Masks */ 1075/* TIMER_ENABLE Masks */
1120#define TIMEN0 0x0001 /* Enable Timer 0 */ 1076#define TIMEN0 0x0001 /* Enable Timer 0 */
diff --git a/arch/blackfin/mach-bf537/include/mach/pll.h b/arch/blackfin/mach-bf537/include/mach/pll.h
new file mode 100644
index 000000000000..169c106d0edb
--- /dev/null
+++ b/arch/blackfin/mach-bf537/include/mach/pll.h
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2005-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr = bfin_read32(SIC_IWR);
24 /* Only allow PPL Wakeup) */
25 bfin_write32(SIC_IWR, IWR_ENABLE(0));
26
27 bfin_write16(PLL_CTL, val);
28 SSYNC();
29 asm("IDLE;");
30
31 bfin_write32(SIC_IWR, iwr);
32 hard_local_irq_restore(flags);
33}
34
35/* Writing to VR_CTL initiates a PLL relock sequence. */
36static __inline__ void bfin_write_VR_CTL(unsigned int val)
37{
38 unsigned long flags, iwr;
39
40 if (val == bfin_read_VR_CTL())
41 return;
42
43 flags = hard_local_irq_save();
44 /* Enable the PLL Wakeup bit in SIC IWR */
45 iwr = bfin_read32(SIC_IWR);
46 /* Only allow PPL Wakeup) */
47 bfin_write32(SIC_IWR, IWR_ENABLE(0));
48
49 bfin_write16(VR_CTL, val);
50 SSYNC();
51 asm("IDLE;");
52
53 bfin_write32(SIC_IWR, iwr);
54 hard_local_irq_restore(flags);
55}
56
57#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf538/boards/ezkit.c b/arch/blackfin/mach-bf538/boards/ezkit.c
index 1a1f65855b03..c6fb0a52f849 100644
--- a/arch/blackfin/mach-bf538/boards/ezkit.c
+++ b/arch/blackfin/mach-bf538/boards/ezkit.c
@@ -695,7 +695,7 @@ static struct platform_device bf538_spi_master0 = {
695}; 695};
696 696
697static struct bfin5xx_spi_master bf538_spi_master_info1 = { 697static struct bfin5xx_spi_master bf538_spi_master_info1 = {
698 .num_chipselect = 8, 698 .num_chipselect = 2,
699 .enable_dma = 1, /* master has the ability to do dma transfer */ 699 .enable_dma = 1, /* master has the ability to do dma transfer */
700 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 700 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
701}; 701};
@@ -711,7 +711,7 @@ static struct platform_device bf538_spi_master1 = {
711}; 711};
712 712
713static struct bfin5xx_spi_master bf538_spi_master_info2 = { 713static struct bfin5xx_spi_master bf538_spi_master_info2 = {
714 .num_chipselect = 8, 714 .num_chipselect = 2,
715 .enable_dma = 1, /* master has the ability to do dma transfer */ 715 .enable_dma = 1, /* master has the ability to do dma transfer */
716 .pin_req = {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0}, 716 .pin_req = {P_SPI2_SCK, P_SPI2_MISO, P_SPI2_MOSI, 0},
717}; 717};
diff --git a/arch/blackfin/mach-bf538/include/mach/cdefBF538.h b/arch/blackfin/mach-bf538/include/mach/cdefBF538.h
index 66aa722cf6c8..085b06b8c0a5 100644
--- a/arch/blackfin/mach-bf538/include/mach/cdefBF538.h
+++ b/arch/blackfin/mach-bf538/include/mach/cdefBF538.h
@@ -2027,54 +2027,4 @@
2027/* These need to be last due to the cdef/linux inter-dependencies */ 2027/* These need to be last due to the cdef/linux inter-dependencies */
2028#include <asm/irq.h> 2028#include <asm/irq.h>
2029 2029
2030/* Writing to PLL_CTL initiates a PLL relock sequence. */
2031static __inline__ void bfin_write_PLL_CTL(unsigned int val)
2032{
2033 unsigned long flags, iwr0, iwr1;
2034
2035 if (val == bfin_read_PLL_CTL())
2036 return;
2037
2038 local_irq_save_hw(flags);
2039 /* Enable the PLL Wakeup bit in SIC IWR */
2040 iwr0 = bfin_read32(SIC_IWR0);
2041 iwr1 = bfin_read32(SIC_IWR1);
2042 /* Only allow PPL Wakeup) */
2043 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
2044 bfin_write32(SIC_IWR1, 0);
2045
2046 bfin_write16(PLL_CTL, val);
2047 SSYNC();
2048 asm("IDLE;");
2049
2050 bfin_write32(SIC_IWR0, iwr0);
2051 bfin_write32(SIC_IWR1, iwr1);
2052 local_irq_restore_hw(flags);
2053}
2054
2055/* Writing to VR_CTL initiates a PLL relock sequence. */
2056static __inline__ void bfin_write_VR_CTL(unsigned int val)
2057{
2058 unsigned long flags, iwr0, iwr1;
2059
2060 if (val == bfin_read_VR_CTL())
2061 return;
2062
2063 local_irq_save_hw(flags);
2064 /* Enable the PLL Wakeup bit in SIC IWR */
2065 iwr0 = bfin_read32(SIC_IWR0);
2066 iwr1 = bfin_read32(SIC_IWR1);
2067 /* Only allow PPL Wakeup) */
2068 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
2069 bfin_write32(SIC_IWR1, 0);
2070
2071 bfin_write16(VR_CTL, val);
2072 SSYNC();
2073 asm("IDLE;");
2074
2075 bfin_write32(SIC_IWR0, iwr0);
2076 bfin_write32(SIC_IWR1, iwr1);
2077 local_irq_restore_hw(flags);
2078}
2079
2080#endif 2030#endif
diff --git a/arch/blackfin/mach-bf538/include/mach/defBF539.h b/arch/blackfin/mach-bf538/include/mach/defBF539.h
index fe43062b4975..7a8ac5f44204 100644
--- a/arch/blackfin/mach-bf538/include/mach/defBF539.h
+++ b/arch/blackfin/mach-bf538/include/mach/defBF539.h
@@ -32,6 +32,7 @@
32/* System Interrupt Controller (0xFFC00100 - 0xFFC001FF) */ 32/* System Interrupt Controller (0xFFC00100 - 0xFFC001FF) */
33#define SWRST 0xFFC00100 /* Software Reset Register (16-bit) */ 33#define SWRST 0xFFC00100 /* Software Reset Register (16-bit) */
34#define SYSCR 0xFFC00104 /* System Configuration registe */ 34#define SYSCR 0xFFC00104 /* System Configuration registe */
35#define SIC_RVECT 0xFFC00108
35#define SIC_IMASK0 0xFFC0010C /* Interrupt Mask Register */ 36#define SIC_IMASK0 0xFFC0010C /* Interrupt Mask Register */
36#define SIC_IAR0 0xFFC00110 /* Interrupt Assignment Register 0 */ 37#define SIC_IAR0 0xFFC00110 /* Interrupt Assignment Register 0 */
37#define SIC_IAR1 0xFFC00114 /* Interrupt Assignment Register 1 */ 38#define SIC_IAR1 0xFFC00114 /* Interrupt Assignment Register 1 */
@@ -1894,78 +1895,6 @@
1894#define PE14_P 0xE 1895#define PE14_P 0xE
1895#define PE15_P 0xF 1896#define PE15_P 0xF
1896 1897
1897
1898/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS **************** */
1899/* SPIx_CTL Masks */
1900#define TIMOD 0x0003 /* Transfer Initiate Mode */
1901#define RDBR_CORE 0x0000 /* RDBR Read Initiates, IRQ When RDBR Full */
1902#define TDBR_CORE 0x0001 /* TDBR Write Initiates, IRQ When TDBR Empty */
1903#define RDBR_DMA 0x0002 /* DMA Read, DMA Until FIFO Empty */
1904#define TDBR_DMA 0x0003 /* DMA Write, DMA Until FIFO Full */
1905#define SZ 0x0004 /* Send Zero (When TDBR Empty, Send Zero/Last*) */
1906#define GM 0x0008 /* Get More (When RDBR Full, Overwrite/Discard*) */
1907#define PSSE 0x0010 /* Slave-Select Input Enable */
1908#define EMISO 0x0020 /* Enable MISO As Output */
1909#define SIZE 0x0100 /* Size of Words (16/8* Bits) */
1910#define LSBF 0x0200 /* LSB First */
1911#define CPHA 0x0400 /* Clock Phase */
1912#define CPOL 0x0800 /* Clock Polarity */
1913#define MSTR 0x1000 /* Master/Slave* */
1914#define WOM 0x2000 /* Write Open Drain Master */
1915#define SPE 0x4000 /* SPI Enable */
1916
1917/* SPIx_FLG Masks */
1918#define FLS1 0x0002 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
1919#define FLS2 0x0004 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
1920#define FLS3 0x0008 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
1921#define FLS4 0x0010 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
1922#define FLS5 0x0020 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
1923#define FLS6 0x0040 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
1924#define FLS7 0x0080 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
1925
1926#define FLG1 0x0200 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
1927#define FLG2 0x0400 /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
1928#define FLG3 0x0800 /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
1929#define FLG4 0x1000 /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
1930#define FLG5 0x2000 /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
1931#define FLG6 0x4000 /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
1932#define FLG7 0x8000 /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
1933
1934/* SPIx_FLG Bit Positions */
1935#define FLS1_P 0x0001 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
1936#define FLS2_P 0x0002 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
1937#define FLS3_P 0x0003 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
1938#define FLS4_P 0x0004 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
1939#define FLS5_P 0x0005 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
1940#define FLS6_P 0x0006 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
1941#define FLS7_P 0x0007 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
1942#define FLG1_P 0x0009 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
1943#define FLG2_P 0x000A /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
1944#define FLG3_P 0x000B /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
1945#define FLG4_P 0x000C /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
1946#define FLG5_P 0x000D /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
1947#define FLG6_P 0x000E /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
1948#define FLG7_P 0x000F /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
1949
1950/* SPIx_STAT Masks */
1951#define SPIF 0x0001 /* Set (=1) when SPI single-word transfer complete */
1952#define MODF 0x0002 /* Set (=1) in a master device when some other device tries to become master */
1953#define TXE 0x0004 /* Set (=1) when transmission occurs with no new data in SPI_TDBR */
1954#define TXS 0x0008 /* SPI_TDBR Data Buffer Status (0=Empty, 1=Full) */
1955#define RBSY 0x0010 /* Set (=1) when data is received with RDBR full */
1956#define RXS 0x0020 /* SPI_RDBR Data Buffer Status (0=Empty, 1=Full) */
1957#define TXCOL 0x0040 /* When set (=1), corrupt data may have been transmitted */
1958
1959/* SPIx_FLG Masks */
1960#define FLG1E 0xFDFF /* Activates SPI_FLOUT1 */
1961#define FLG2E 0xFBFF /* Activates SPI_FLOUT2 */
1962#define FLG3E 0xF7FF /* Activates SPI_FLOUT3 */
1963#define FLG4E 0xEFFF /* Activates SPI_FLOUT4 */
1964#define FLG5E 0xDFFF /* Activates SPI_FLOUT5 */
1965#define FLG6E 0xBFFF /* Activates SPI_FLOUT6 */
1966#define FLG7E 0x7FFF /* Activates SPI_FLOUT7 */
1967
1968
1969/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */ 1898/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */
1970/* EBIU_AMGCTL Masks */ 1899/* EBIU_AMGCTL Masks */
1971#define AMCKEN 0x0001 /* Enable CLKOUT */ 1900#define AMCKEN 0x0001 /* Enable CLKOUT */
diff --git a/arch/blackfin/mach-bf538/include/mach/pll.h b/arch/blackfin/mach-bf538/include/mach/pll.h
new file mode 100644
index 000000000000..b30bbcd412a7
--- /dev/null
+++ b/arch/blackfin/mach-bf538/include/mach/pll.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2008-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr0, iwr1;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr0 = bfin_read32(SIC_IWR0);
24 iwr1 = bfin_read32(SIC_IWR1);
25 /* Only allow PPL Wakeup) */
26 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
27 bfin_write32(SIC_IWR1, 0);
28
29 bfin_write16(PLL_CTL, val);
30 SSYNC();
31 asm("IDLE;");
32
33 bfin_write32(SIC_IWR0, iwr0);
34 bfin_write32(SIC_IWR1, iwr1);
35 hard_local_irq_restore(flags);
36}
37
38/* Writing to VR_CTL initiates a PLL relock sequence. */
39static __inline__ void bfin_write_VR_CTL(unsigned int val)
40{
41 unsigned long flags, iwr0, iwr1;
42
43 if (val == bfin_read_VR_CTL())
44 return;
45
46 flags = hard_local_irq_save();
47 /* Enable the PLL Wakeup bit in SIC IWR */
48 iwr0 = bfin_read32(SIC_IWR0);
49 iwr1 = bfin_read32(SIC_IWR1);
50 /* Only allow PPL Wakeup) */
51 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
52 bfin_write32(SIC_IWR1, 0);
53
54 bfin_write16(VR_CTL, val);
55 SSYNC();
56 asm("IDLE;");
57
58 bfin_write32(SIC_IWR0, iwr0);
59 bfin_write32(SIC_IWR1, iwr1);
60 hard_local_irq_restore(flags);
61}
62
63#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf548/boards/cm_bf548.c b/arch/blackfin/mach-bf548/boards/cm_bf548.c
index 0c38eec9ade1..f0c0eef95ba8 100644
--- a/arch/blackfin/mach-bf548/boards/cm_bf548.c
+++ b/arch/blackfin/mach-bf548/boards/cm_bf548.c
@@ -753,6 +753,44 @@ static struct platform_device bf54x_sdh_device = {
753}; 753};
754#endif 754#endif
755 755
756#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
757unsigned short bfin_can_peripherals[] = {
758 P_CAN0_RX, P_CAN0_TX, 0
759};
760
761static struct resource bfin_can_resources[] = {
762 {
763 .start = 0xFFC02A00,
764 .end = 0xFFC02FFF,
765 .flags = IORESOURCE_MEM,
766 },
767 {
768 .start = IRQ_CAN0_RX,
769 .end = IRQ_CAN0_RX,
770 .flags = IORESOURCE_IRQ,
771 },
772 {
773 .start = IRQ_CAN0_TX,
774 .end = IRQ_CAN0_TX,
775 .flags = IORESOURCE_IRQ,
776 },
777 {
778 .start = IRQ_CAN0_ERROR,
779 .end = IRQ_CAN0_ERROR,
780 .flags = IORESOURCE_IRQ,
781 },
782};
783
784static struct platform_device bfin_can_device = {
785 .name = "bfin_can",
786 .num_resources = ARRAY_SIZE(bfin_can_resources),
787 .resource = bfin_can_resources,
788 .dev = {
789 .platform_data = &bfin_can_peripherals, /* Passed to driver */
790 },
791};
792#endif
793
756#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 794#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
757static struct mtd_partition para_partitions[] = { 795static struct mtd_partition para_partitions[] = {
758 { 796 {
@@ -928,7 +966,7 @@ static struct resource bfin_spi1_resource[] = {
928 966
929/* SPI controller data */ 967/* SPI controller data */
930static struct bfin5xx_spi_master bf54x_spi_master_info0 = { 968static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
931 .num_chipselect = 3, 969 .num_chipselect = 4,
932 .enable_dma = 1, /* master has the ability to do dma transfer */ 970 .enable_dma = 1, /* master has the ability to do dma transfer */
933 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 971 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
934}; 972};
@@ -944,7 +982,7 @@ static struct platform_device bf54x_spi_master0 = {
944}; 982};
945 983
946static struct bfin5xx_spi_master bf54x_spi_master_info1 = { 984static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
947 .num_chipselect = 3, 985 .num_chipselect = 4,
948 .enable_dma = 1, /* master has the ability to do dma transfer */ 986 .enable_dma = 1, /* master has the ability to do dma transfer */
949 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 987 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
950}; 988};
@@ -1152,6 +1190,11 @@ static struct platform_device *cm_bf548_devices[] __initdata = {
1152#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 1190#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1153 &para_flash_device, 1191 &para_flash_device,
1154#endif 1192#endif
1193
1194#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
1195 &bfin_can_device,
1196#endif
1197
1155}; 1198};
1156 1199
1157static int __init cm_bf548_init(void) 1200static int __init cm_bf548_init(void)
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index 56682a36e42d..216e26999af9 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -837,8 +837,12 @@ static struct platform_device bfin_atapi_device = {
837#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 837#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
838static struct mtd_partition partition_info[] = { 838static struct mtd_partition partition_info[] = {
839 { 839 {
840 .name = "linux kernel(nand)", 840 .name = "bootloader(nand)",
841 .offset = 0, 841 .offset = 0,
842 .size = 0x80000,
843 }, {
844 .name = "linux kernel(nand)",
845 .offset = MTDPART_OFS_APPEND,
842 .size = 4 * 1024 * 1024, 846 .size = 4 * 1024 * 1024,
843 }, 847 },
844 { 848 {
@@ -901,7 +905,7 @@ static struct platform_device bf54x_sdh_device = {
901static struct mtd_partition ezkit_partitions[] = { 905static struct mtd_partition ezkit_partitions[] = {
902 { 906 {
903 .name = "bootloader(nor)", 907 .name = "bootloader(nor)",
904 .size = 0x40000, 908 .size = 0x80000,
905 .offset = 0, 909 .offset = 0,
906 }, { 910 }, {
907 .name = "linux kernel(nor)", 911 .name = "linux kernel(nor)",
@@ -943,7 +947,7 @@ static struct platform_device ezkit_flash_device = {
943static struct mtd_partition bfin_spi_flash_partitions[] = { 947static struct mtd_partition bfin_spi_flash_partitions[] = {
944 { 948 {
945 .name = "bootloader(spi)", 949 .name = "bootloader(spi)",
946 .size = 0x00040000, 950 .size = 0x00080000,
947 .offset = 0, 951 .offset = 0,
948 .mask_flags = MTD_CAP_ROM 952 .mask_flags = MTD_CAP_ROM
949 }, { 953 }, {
@@ -966,8 +970,8 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
966}; 970};
967#endif 971#endif
968 972
969#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 973#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
970 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 974 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
971static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 975static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
972 .enable_dma = 0, 976 .enable_dma = 0,
973 .bits_per_word = 16, 977 .bits_per_word = 16,
@@ -1023,13 +1027,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1023 .mode = SPI_MODE_3, 1027 .mode = SPI_MODE_3,
1024 }, 1028 },
1025#endif 1029#endif
1026#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 1030#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
1027 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 1031 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
1028 { 1032 {
1029 .modalias = "ad1836", 1033 .modalias = "ad183x",
1030 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1034 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
1031 .bus_num = 1, 1035 .bus_num = 1,
1032 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 1036 .chip_select = 4,
1033 .controller_data = &ad1836_spi_chip_info, 1037 .controller_data = &ad1836_spi_chip_info,
1034 }, 1038 },
1035#endif 1039#endif
@@ -1107,7 +1111,7 @@ static struct resource bfin_spi1_resource[] = {
1107 1111
1108/* SPI controller data */ 1112/* SPI controller data */
1109static struct bfin5xx_spi_master bf54x_spi_master_info0 = { 1113static struct bfin5xx_spi_master bf54x_spi_master_info0 = {
1110 .num_chipselect = 3, 1114 .num_chipselect = 4,
1111 .enable_dma = 1, /* master has the ability to do dma transfer */ 1115 .enable_dma = 1, /* master has the ability to do dma transfer */
1112 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 1116 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1113}; 1117};
@@ -1123,7 +1127,7 @@ static struct platform_device bf54x_spi_master0 = {
1123}; 1127};
1124 1128
1125static struct bfin5xx_spi_master bf54x_spi_master_info1 = { 1129static struct bfin5xx_spi_master bf54x_spi_master_info1 = {
1126 .num_chipselect = 3, 1130 .num_chipselect = 4,
1127 .enable_dma = 1, /* master has the ability to do dma transfer */ 1131 .enable_dma = 1, /* master has the ability to do dma transfer */
1128 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 1132 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
1129}; 1133};
@@ -1206,6 +1210,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info1[] = {
1206 .platform_data = (void *)&adxl34x_info, 1210 .platform_data = (void *)&adxl34x_info,
1207 }, 1211 },
1208#endif 1212#endif
1213#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
1214 {
1215 I2C_BOARD_INFO("ad5252", 0x2f),
1216 },
1217#endif
1209}; 1218};
1210#endif 1219#endif
1211 1220
diff --git a/arch/blackfin/mach-bf548/dma.c b/arch/blackfin/mach-bf548/dma.c
index 039a6d9d38f3..888b9cc0b822 100644
--- a/arch/blackfin/mach-bf548/dma.c
+++ b/arch/blackfin/mach-bf548/dma.c
@@ -63,6 +63,7 @@ int channel2irq(unsigned int channel)
63 break; 63 break;
64 case CH_SPORT1_TX: 64 case CH_SPORT1_TX:
65 ret_irq = IRQ_SPORT1_TX; 65 ret_irq = IRQ_SPORT1_TX;
66 break;
66 case CH_SPI0: 67 case CH_SPI0:
67 ret_irq = IRQ_SPI0; 68 ret_irq = IRQ_SPI0;
68 break; 69 break;
diff --git a/arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h b/arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h
index ea3ec4ea9e2b..deaf5d6542d5 100644
--- a/arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h
+++ b/arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h
@@ -40,6 +40,8 @@
40 40
41/* SIC Registers */ 41/* SIC Registers */
42 42
43#define bfin_read_SIC_RVECT() bfin_read32(SIC_RVECT)
44#define bfin_write_SIC_RVECT(val) bfin_write32(SIC_RVECT, val)
43#define bfin_read_SIC_IMASK0() bfin_read32(SIC_IMASK0) 45#define bfin_read_SIC_IMASK0() bfin_read32(SIC_IMASK0)
44#define bfin_write_SIC_IMASK0(val) bfin_write32(SIC_IMASK0, val) 46#define bfin_write_SIC_IMASK0(val) bfin_write32(SIC_IMASK0, val)
45#define bfin_read_SIC_IMASK1() bfin_read32(SIC_IMASK1) 47#define bfin_read_SIC_IMASK1() bfin_read32(SIC_IMASK1)
@@ -2648,61 +2650,5 @@
2648/* These need to be last due to the cdef/linux inter-dependencies */ 2650/* These need to be last due to the cdef/linux inter-dependencies */
2649#include <asm/irq.h> 2651#include <asm/irq.h>
2650 2652
2651/* Writing to PLL_CTL initiates a PLL relock sequence. */
2652static __inline__ void bfin_write_PLL_CTL(unsigned int val)
2653{
2654 unsigned long flags, iwr0, iwr1, iwr2;
2655
2656 if (val == bfin_read_PLL_CTL())
2657 return;
2658
2659 local_irq_save_hw(flags);
2660 /* Enable the PLL Wakeup bit in SIC IWR */
2661 iwr0 = bfin_read32(SIC_IWR0);
2662 iwr1 = bfin_read32(SIC_IWR1);
2663 iwr2 = bfin_read32(SIC_IWR2);
2664 /* Only allow PPL Wakeup) */
2665 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
2666 bfin_write32(SIC_IWR1, 0);
2667 bfin_write32(SIC_IWR2, 0);
2668
2669 bfin_write16(PLL_CTL, val);
2670 SSYNC();
2671 asm("IDLE;");
2672
2673 bfin_write32(SIC_IWR0, iwr0);
2674 bfin_write32(SIC_IWR1, iwr1);
2675 bfin_write32(SIC_IWR2, iwr2);
2676 local_irq_restore_hw(flags);
2677}
2678
2679/* Writing to VR_CTL initiates a PLL relock sequence. */
2680static __inline__ void bfin_write_VR_CTL(unsigned int val)
2681{
2682 unsigned long flags, iwr0, iwr1, iwr2;
2683
2684 if (val == bfin_read_VR_CTL())
2685 return;
2686
2687 local_irq_save_hw(flags);
2688 /* Enable the PLL Wakeup bit in SIC IWR */
2689 iwr0 = bfin_read32(SIC_IWR0);
2690 iwr1 = bfin_read32(SIC_IWR1);
2691 iwr2 = bfin_read32(SIC_IWR2);
2692 /* Only allow PPL Wakeup) */
2693 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
2694 bfin_write32(SIC_IWR1, 0);
2695 bfin_write32(SIC_IWR2, 0);
2696
2697 bfin_write16(VR_CTL, val);
2698 SSYNC();
2699 asm("IDLE;");
2700
2701 bfin_write32(SIC_IWR0, iwr0);
2702 bfin_write32(SIC_IWR1, iwr1);
2703 bfin_write32(SIC_IWR2, iwr2);
2704 local_irq_restore_hw(flags);
2705}
2706
2707#endif /* _CDEF_BF54X_H */ 2653#endif /* _CDEF_BF54X_H */
2708 2654
diff --git a/arch/blackfin/mach-bf548/include/mach/defBF54x_base.h b/arch/blackfin/mach-bf548/include/mach/defBF54x_base.h
index 7866197f5485..78f91103f175 100644
--- a/arch/blackfin/mach-bf548/include/mach/defBF54x_base.h
+++ b/arch/blackfin/mach-bf548/include/mach/defBF54x_base.h
@@ -35,6 +35,7 @@
35 35
36/* SIC Registers */ 36/* SIC Registers */
37 37
38#define SIC_RVECT 0xffc00108
38#define SIC_IMASK0 0xffc0010c /* System Interrupt Mask Register 0 */ 39#define SIC_IMASK0 0xffc0010c /* System Interrupt Mask Register 0 */
39#define SIC_IMASK1 0xffc00110 /* System Interrupt Mask Register 1 */ 40#define SIC_IMASK1 0xffc00110 /* System Interrupt Mask Register 1 */
40#define SIC_IMASK2 0xffc00114 /* System Interrupt Mask Register 2 */ 41#define SIC_IMASK2 0xffc00114 /* System Interrupt Mask Register 2 */
@@ -2061,56 +2062,6 @@
2061#define LOW_EVEN 0xff0000 /* Lower Limit for Even Bytes (Luma) */ 2062#define LOW_EVEN 0xff0000 /* Lower Limit for Even Bytes (Luma) */
2062#define HIGH_EVEN 0xff000000 /* Upper Limit for Even Bytes (Luma) */ 2063#define HIGH_EVEN 0xff000000 /* Upper Limit for Even Bytes (Luma) */
2063 2064
2064/* Bit masks for SPIx_BAUD */
2065
2066#define SPI_BAUD 0xffff /* Baud Rate */
2067
2068/* Bit masks for SPIx_CTL */
2069
2070#define SPE 0x4000 /* SPI Enable */
2071#define WOM 0x2000 /* Write Open Drain Master */
2072#define MSTR 0x1000 /* Master Mode */
2073#define CPOL 0x800 /* Clock Polarity */
2074#define CPHA 0x400 /* Clock Phase */
2075#define LSBF 0x200 /* LSB First */
2076#define SIZE 0x100 /* Size of Words */
2077#define EMISO 0x20 /* Enable MISO Output */
2078#define PSSE 0x10 /* Slave-Select Enable */
2079#define GM 0x8 /* Get More Data */
2080#define SZ 0x4 /* Send Zero */
2081#define TIMOD 0x3 /* Transfer Initiation Mode */
2082
2083/* Bit masks for SPIx_FLG */
2084
2085#define FLS1 0x2 /* Slave Select Enable 1 */
2086#define FLS2 0x4 /* Slave Select Enable 2 */
2087#define FLS3 0x8 /* Slave Select Enable 3 */
2088#define FLG1 0x200 /* Slave Select Value 1 */
2089#define FLG2 0x400 /* Slave Select Value 2 */
2090#define FLG3 0x800 /* Slave Select Value 3 */
2091
2092/* Bit masks for SPIx_STAT */
2093
2094#define TXCOL 0x40 /* Transmit Collision Error */
2095#define RXS 0x20 /* RDBR Data Buffer Status */
2096#define RBSY 0x10 /* Receive Error */
2097#define TXS 0x8 /* TDBR Data Buffer Status */
2098#define TXE 0x4 /* Transmission Error */
2099#define MODF 0x2 /* Mode Fault Error */
2100#define SPIF 0x1 /* SPI Finished */
2101
2102/* Bit masks for SPIx_TDBR */
2103
2104#define TDBR 0xffff /* Transmit Data Buffer */
2105
2106/* Bit masks for SPIx_RDBR */
2107
2108#define RDBR 0xffff /* Receive Data Buffer */
2109
2110/* Bit masks for SPIx_SHADOW */
2111
2112#define SHADOW 0xffff /* RDBR Shadow */
2113
2114/* ************************************************ */ 2065/* ************************************************ */
2115/* The TWI bit masks fields are from the ADSP-BF538 */ 2066/* The TWI bit masks fields are from the ADSP-BF538 */
2116/* and they have not been verified as the final */ 2067/* and they have not been verified as the final */
diff --git a/arch/blackfin/mach-bf548/include/mach/pll.h b/arch/blackfin/mach-bf548/include/mach/pll.h
new file mode 100644
index 000000000000..7865a090d333
--- /dev/null
+++ b/arch/blackfin/mach-bf548/include/mach/pll.h
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2007-2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr0, iwr1, iwr2;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr0 = bfin_read32(SIC_IWR0);
24 iwr1 = bfin_read32(SIC_IWR1);
25 iwr2 = bfin_read32(SIC_IWR2);
26 /* Only allow PPL Wakeup) */
27 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
28 bfin_write32(SIC_IWR1, 0);
29 bfin_write32(SIC_IWR2, 0);
30
31 bfin_write16(PLL_CTL, val);
32 SSYNC();
33 asm("IDLE;");
34
35 bfin_write32(SIC_IWR0, iwr0);
36 bfin_write32(SIC_IWR1, iwr1);
37 bfin_write32(SIC_IWR2, iwr2);
38 hard_local_irq_restore(flags);
39}
40
41/* Writing to VR_CTL initiates a PLL relock sequence. */
42static __inline__ void bfin_write_VR_CTL(unsigned int val)
43{
44 unsigned long flags, iwr0, iwr1, iwr2;
45
46 if (val == bfin_read_VR_CTL())
47 return;
48
49 flags = hard_local_irq_save();
50 /* Enable the PLL Wakeup bit in SIC IWR */
51 iwr0 = bfin_read32(SIC_IWR0);
52 iwr1 = bfin_read32(SIC_IWR1);
53 iwr2 = bfin_read32(SIC_IWR2);
54 /* Only allow PPL Wakeup) */
55 bfin_write32(SIC_IWR0, IWR_ENABLE(0));
56 bfin_write32(SIC_IWR1, 0);
57 bfin_write32(SIC_IWR2, 0);
58
59 bfin_write16(VR_CTL, val);
60 SSYNC();
61 asm("IDLE;");
62
63 bfin_write32(SIC_IWR0, iwr0);
64 bfin_write32(SIC_IWR1, iwr1);
65 bfin_write32(SIC_IWR2, iwr2);
66 hard_local_irq_restore(flags);
67}
68
69#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c
index 35b6d124c1e3..0b1c20f14fe0 100644
--- a/arch/blackfin/mach-bf561/boards/acvilon.c
+++ b/arch/blackfin/mach-bf561/boards/acvilon.c
@@ -302,7 +302,7 @@ static struct platform_nand_data bfin_plat_nand_data = {
302static struct resource bfin_plat_nand_resources = { 302static struct resource bfin_plat_nand_resources = {
303 .start = 0x24000000, 303 .start = 0x24000000,
304 .end = 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)), 304 .end = 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
305 .flags = IORESOURCE_IO, 305 .flags = IORESOURCE_MEM,
306}; 306};
307 307
308static struct platform_device bfin_async_nand_device = { 308static struct platform_device bfin_async_nand_device = {
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
index e127aedc1d7f..087b6b05cc73 100644
--- a/arch/blackfin/mach-bf561/boards/cm_bf561.c
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -72,7 +72,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
72}; 72};
73#endif 73#endif
74 74
75#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 75#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
76static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 76static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
77 .enable_dma = 0, 77 .enable_dma = 0,
78 .bits_per_word = 16, 78 .bits_per_word = 16,
@@ -111,12 +111,12 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
111 }, 111 },
112#endif 112#endif
113 113
114#if defined(CONFIG_SND_BLACKFIN_AD183X) || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 114#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
115 { 115 {
116 .modalias = "ad1836", 116 .modalias = "ad183x",
117 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 117 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
118 .bus_num = 0, 118 .bus_num = 0,
119 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 119 .chip_select = 4,
120 .controller_data = &ad1836_spi_chip_info, 120 .controller_data = &ad1836_spi_chip_info,
121 }, 121 },
122#endif 122#endif
@@ -278,7 +278,7 @@ static struct resource isp1362_hcd_resources[] = {
278 }, { 278 }, {
279 .start = IRQ_PF47, 279 .start = IRQ_PF47,
280 .end = IRQ_PF47, 280 .end = IRQ_PF47,
281 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 281 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
282 }, 282 },
283}; 283};
284 284
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 9b93e2f95791..ab7a487975fd 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -14,6 +14,7 @@
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/delay.h>
17#include <asm/dma.h> 18#include <asm/dma.h>
18#include <asm/bfin5xx_spi.h> 19#include <asm/bfin5xx_spi.h>
19#include <asm/portmux.h> 20#include <asm/portmux.h>
@@ -74,7 +75,7 @@ static struct resource isp1362_hcd_resources[] = {
74 }, { 75 }, {
75 .start = IRQ_PF8, 76 .start = IRQ_PF8,
76 .end = IRQ_PF8, 77 .end = IRQ_PF8,
77 .flags = IORESOURCE_IRQ, 78 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
78 }, 79 },
79}; 80};
80 81
@@ -274,8 +275,8 @@ static struct platform_device ezkit_flash_device = {
274}; 275};
275#endif 276#endif
276 277
277#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 278#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
278 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 279 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
279static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 280static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
280 .enable_dma = 0, 281 .enable_dma = 0,
281 .bits_per_word = 16, 282 .bits_per_word = 16,
@@ -328,14 +329,16 @@ static struct platform_device bfin_spi0_device = {
328#endif 329#endif
329 330
330static struct spi_board_info bfin_spi_board_info[] __initdata = { 331static struct spi_board_info bfin_spi_board_info[] __initdata = {
331#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 332#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
332 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 333 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
333 { 334 {
334 .modalias = "ad1836", 335 .modalias = "ad183x",
335 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 336 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
336 .bus_num = 0, 337 .bus_num = 0,
337 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 338 .chip_select = 4,
339 .platform_data = "ad1836", /* only includes chip name for the moment */
338 .controller_data = &ad1836_spi_chip_info, 340 .controller_data = &ad1836_spi_chip_info,
341 .mode = SPI_MODE_3,
339 }, 342 },
340#endif 343#endif
341#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) 344#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
@@ -377,8 +380,8 @@ static struct platform_device bfin_device_gpiokeys = {
377#include <linux/i2c-gpio.h> 380#include <linux/i2c-gpio.h>
378 381
379static struct i2c_gpio_platform_data i2c_gpio_data = { 382static struct i2c_gpio_platform_data i2c_gpio_data = {
380 .sda_pin = 1, 383 .sda_pin = GPIO_PF1,
381 .scl_pin = 0, 384 .scl_pin = GPIO_PF0,
382 .sda_is_open_drain = 0, 385 .sda_is_open_drain = 0,
383 .scl_is_open_drain = 0, 386 .scl_is_open_drain = 0,
384 .udelay = 40, 387 .udelay = 40,
@@ -420,6 +423,30 @@ static struct platform_device bfin_dpmc = {
420 }, 423 },
421}; 424};
422 425
426#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
427static struct platform_device bfin_i2s = {
428 .name = "bfin-i2s",
429 .id = CONFIG_SND_BF5XX_SPORT_NUM,
430 /* TODO: add platform data here */
431};
432#endif
433
434#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
435static struct platform_device bfin_tdm = {
436 .name = "bfin-tdm",
437 .id = CONFIG_SND_BF5XX_SPORT_NUM,
438 /* TODO: add platform data here */
439};
440#endif
441
442#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
443static struct platform_device bfin_ac97 = {
444 .name = "bfin-ac97",
445 .id = CONFIG_SND_BF5XX_SPORT_NUM,
446 /* TODO: add platform data here */
447};
448#endif
449
423static struct platform_device *ezkit_devices[] __initdata = { 450static struct platform_device *ezkit_devices[] __initdata = {
424 451
425 &bfin_dpmc, 452 &bfin_dpmc,
@@ -467,6 +494,18 @@ static struct platform_device *ezkit_devices[] __initdata = {
467#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 494#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
468 &ezkit_flash_device, 495 &ezkit_flash_device,
469#endif 496#endif
497
498#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
499 &bfin_i2s,
500#endif
501
502#if defined(CONFIG_SND_BF5XX_TDM) || defined(CONFIG_SND_BF5XX_TDM_MODULE)
503 &bfin_tdm,
504#endif
505
506#if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
507 &bfin_ac97,
508#endif
470}; 509};
471 510
472static int __init ezkit_init(void) 511static int __init ezkit_init(void)
@@ -484,6 +523,17 @@ static int __init ezkit_init(void)
484 SSYNC(); 523 SSYNC();
485#endif 524#endif
486 525
526#if defined(CONFIG_SND_BF5XX_SOC_AD183X) || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
527 bfin_write_FIO0_DIR(bfin_read_FIO0_DIR() | (1 << 15));
528 bfin_write_FIO0_FLAG_S(1 << 15);
529 SSYNC();
530 /*
531 * This initialization lasts for approximately 4500 MCLKs.
532 * MCLK = 12.288MHz
533 */
534 udelay(400);
535#endif
536
487 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info)); 537 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
488 return 0; 538 return 0;
489} 539}
diff --git a/arch/blackfin/mach-bf561/coreb.c b/arch/blackfin/mach-bf561/coreb.c
index deb2271d09a3..78ecb50bafc8 100644
--- a/arch/blackfin/mach-bf561/coreb.c
+++ b/arch/blackfin/mach-bf561/coreb.c
@@ -18,9 +18,9 @@
18#include <linux/miscdevice.h> 18#include <linux/miscdevice.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#define CMD_COREB_START 2 21#define CMD_COREB_START _IO('b', 0)
22#define CMD_COREB_STOP 3 22#define CMD_COREB_STOP _IO('b', 1)
23#define CMD_COREB_RESET 4 23#define CMD_COREB_RESET _IO('b', 2)
24 24
25static long 25static long
26coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 26coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
@@ -29,10 +29,10 @@ coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
29 29
30 switch (cmd) { 30 switch (cmd) {
31 case CMD_COREB_START: 31 case CMD_COREB_START:
32 bfin_write_SICA_SYSCR(bfin_read_SICA_SYSCR() & ~0x0020); 32 bfin_write_SYSCR(bfin_read_SYSCR() & ~0x0020);
33 break; 33 break;
34 case CMD_COREB_STOP: 34 case CMD_COREB_STOP:
35 bfin_write_SICA_SYSCR(bfin_read_SICA_SYSCR() | 0x0020); 35 bfin_write_SYSCR(bfin_read_SYSCR() | 0x0020);
36 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080); 36 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
37 break; 37 break;
38 case CMD_COREB_RESET: 38 case CMD_COREB_RESET:
@@ -51,6 +51,7 @@ coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
51static const struct file_operations coreb_fops = { 51static const struct file_operations coreb_fops = {
52 .owner = THIS_MODULE, 52 .owner = THIS_MODULE,
53 .unlocked_ioctl = coreb_ioctl, 53 .unlocked_ioctl = coreb_ioctl,
54 .llseek = noop_llseek,
54}; 55};
55 56
56static struct miscdevice coreb_dev = { 57static struct miscdevice coreb_dev = {
@@ -73,3 +74,4 @@ module_exit(bf561_coreb_exit);
73 74
74MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>"); 75MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>");
75MODULE_DESCRIPTION("BF561 Core B Support"); 76MODULE_DESCRIPTION("BF561 Core B Support");
77MODULE_LICENSE("GPL");
diff --git a/arch/blackfin/mach-bf561/include/mach/blackfin.h b/arch/blackfin/mach-bf561/include/mach/blackfin.h
index 67d6bdcd3fa8..6c7dc58c018c 100644
--- a/arch/blackfin/mach-bf561/include/mach/blackfin.h
+++ b/arch/blackfin/mach-bf561/include/mach/blackfin.h
@@ -24,29 +24,16 @@
24#define bfin_read_FIO_INEN() bfin_read_FIO0_INEN() 24#define bfin_read_FIO_INEN() bfin_read_FIO0_INEN()
25#define bfin_write_FIO_INEN(val) bfin_write_FIO0_INEN(val) 25#define bfin_write_FIO_INEN(val) bfin_write_FIO0_INEN(val)
26 26
27#define SIC_IWR0 SICA_IWR0 27/* Weird muxer funcs which pick SIC regs from IMASK base */
28#define SIC_IWR1 SICA_IWR1 28#define __SIC_MUX(base, x) ((base) + ((x) << 2))
29#define SIC_IAR0 SICA_IAR0 29#define bfin_read_SIC_IMASK(x) bfin_read32(__SIC_MUX(SIC_IMASK0, x))
30#define bfin_write_SIC_IMASK0 bfin_write_SICA_IMASK0 30#define bfin_write_SIC_IMASK(x, val) bfin_write32(__SIC_MUX(SIC_IMASK0, x), val)
31#define bfin_write_SIC_IMASK1 bfin_write_SICA_IMASK1 31#define bfin_read_SICB_IMASK(x) bfin_read32(__SIC_MUX(SICB_IMASK0, x))
32#define bfin_write_SIC_IWR0 bfin_write_SICA_IWR0 32#define bfin_write_SICB_IMASK(x, val) bfin_write32(__SIC_MUX(SICB_IMASK0, x), val)
33#define bfin_write_SIC_IWR1 bfin_write_SICA_IWR1 33#define bfin_read_SIC_ISR(x) bfin_read32(__SIC_MUX(SIC_ISR0, x))
34 34#define bfin_write_SIC_ISR(x, val) bfin_write32(__SIC_MUX(SIC_ISR0, x), val)
35#define bfin_read_SIC_IMASK0 bfin_read_SICA_IMASK0 35#define bfin_read_SICB_ISR(x) bfin_read32(__SIC_MUX(SICB_ISR0, x))
36#define bfin_read_SIC_IMASK1 bfin_read_SICA_IMASK1 36#define bfin_write_SICB_ISR(x, val) bfin_write32(__SIC_MUX(SICB_ISR0, x), val)
37#define bfin_read_SIC_IWR0 bfin_read_SICA_IWR0
38#define bfin_read_SIC_IWR1 bfin_read_SICA_IWR1
39#define bfin_read_SIC_ISR0 bfin_read_SICA_ISR0
40#define bfin_read_SIC_ISR1 bfin_read_SICA_ISR1
41
42#define bfin_read_SIC_IMASK(x) bfin_read32(SICA_IMASK0 + (x << 2))
43#define bfin_write_SIC_IMASK(x, val) bfin_write32((SICA_IMASK0 + (x << 2)), val)
44#define bfin_read_SICB_IMASK(x) bfin_read32(SICB_IMASK0 + (x << 2))
45#define bfin_write_SICB_IMASK(x, val) bfin_write32((SICB_IMASK0 + (x << 2)), val)
46#define bfin_read_SIC_ISR(x) bfin_read32(SICA_ISR0 + (x << 2))
47#define bfin_write_SIC_ISR(x, val) bfin_write32((SICA_ISR0 + (x << 2)), val)
48#define bfin_read_SICB_ISR(x) bfin_read32(SICB_ISR0 + (x << 2))
49#define bfin_write_SICB_ISR(x, val) bfin_write32((SICB_ISR0 + (x << 2)), val)
50 37
51#define BFIN_UART_NR_PORTS 1 38#define BFIN_UART_NR_PORTS 1
52 39
diff --git a/arch/blackfin/mach-bf561/include/mach/cdefBF561.h b/arch/blackfin/mach-bf561/include/mach/cdefBF561.h
index 81ecdb71c6af..2bab99152495 100644
--- a/arch/blackfin/mach-bf561/include/mach/cdefBF561.h
+++ b/arch/blackfin/mach-bf561/include/mach/cdefBF561.h
@@ -30,49 +30,41 @@
30#define bfin_write_PLL_LOCKCNT(val) bfin_write16(PLL_LOCKCNT,val) 30#define bfin_write_PLL_LOCKCNT(val) bfin_write16(PLL_LOCKCNT,val)
31#define bfin_read_CHIPID() bfin_read32(CHIPID) 31#define bfin_read_CHIPID() bfin_read32(CHIPID)
32 32
33/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */
34#define bfin_read_SWRST() bfin_read_SICA_SWRST()
35#define bfin_write_SWRST(val) bfin_write_SICA_SWRST(val)
36#define bfin_read_SYSCR() bfin_read_SICA_SYSCR()
37#define bfin_write_SYSCR(val) bfin_write_SICA_SYSCR(val)
38
39/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ 33/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */
40#define bfin_read_SICA_SWRST() bfin_read16(SICA_SWRST) 34#define bfin_read_SWRST() bfin_read16(SWRST)
41#define bfin_write_SICA_SWRST(val) bfin_write16(SICA_SWRST,val) 35#define bfin_write_SWRST(val) bfin_write16(SWRST,val)
42#define bfin_read_SICA_SYSCR() bfin_read16(SICA_SYSCR) 36#define bfin_read_SYSCR() bfin_read16(SYSCR)
43#define bfin_write_SICA_SYSCR(val) bfin_write16(SICA_SYSCR,val) 37#define bfin_write_SYSCR(val) bfin_write16(SYSCR,val)
44#define bfin_read_SICA_RVECT() bfin_read16(SICA_RVECT) 38#define bfin_read_SIC_RVECT() bfin_read16(SIC_RVECT)
45#define bfin_write_SICA_RVECT(val) bfin_write16(SICA_RVECT,val) 39#define bfin_write_SIC_RVECT(val) bfin_write16(SIC_RVECT,val)
46#define bfin_read_SICA_IMASK() bfin_read32(SICA_IMASK) 40#define bfin_read_SIC_IMASK0() bfin_read32(SIC_IMASK0)
47#define bfin_write_SICA_IMASK(val) bfin_write32(SICA_IMASK,val) 41#define bfin_write_SIC_IMASK0(val) bfin_write32(SIC_IMASK0,val)
48#define bfin_read_SICA_IMASK0() bfin_read32(SICA_IMASK0) 42#define bfin_read_SIC_IMASK1() bfin_read32(SIC_IMASK1)
49#define bfin_write_SICA_IMASK0(val) bfin_write32(SICA_IMASK0,val) 43#define bfin_write_SIC_IMASK1(val) bfin_write32(SIC_IMASK1,val)
50#define bfin_read_SICA_IMASK1() bfin_read32(SICA_IMASK1) 44#define bfin_read_SIC_IAR0() bfin_read32(SIC_IAR0)
51#define bfin_write_SICA_IMASK1(val) bfin_write32(SICA_IMASK1,val) 45#define bfin_write_SIC_IAR0(val) bfin_write32(SIC_IAR0,val)
52#define bfin_read_SICA_IAR0() bfin_read32(SICA_IAR0) 46#define bfin_read_SIC_IAR1() bfin_read32(SIC_IAR1)
53#define bfin_write_SICA_IAR0(val) bfin_write32(SICA_IAR0,val) 47#define bfin_write_SIC_IAR1(val) bfin_write32(SIC_IAR1,val)
54#define bfin_read_SICA_IAR1() bfin_read32(SICA_IAR1) 48#define bfin_read_SIC_IAR2() bfin_read32(SIC_IAR2)
55#define bfin_write_SICA_IAR1(val) bfin_write32(SICA_IAR1,val) 49#define bfin_write_SIC_IAR2(val) bfin_write32(SIC_IAR2,val)
56#define bfin_read_SICA_IAR2() bfin_read32(SICA_IAR2) 50#define bfin_read_SIC_IAR3() bfin_read32(SIC_IAR3)
57#define bfin_write_SICA_IAR2(val) bfin_write32(SICA_IAR2,val) 51#define bfin_write_SIC_IAR3(val) bfin_write32(SIC_IAR3,val)
58#define bfin_read_SICA_IAR3() bfin_read32(SICA_IAR3) 52#define bfin_read_SIC_IAR4() bfin_read32(SIC_IAR4)
59#define bfin_write_SICA_IAR3(val) bfin_write32(SICA_IAR3,val) 53#define bfin_write_SIC_IAR4(val) bfin_write32(SIC_IAR4,val)
60#define bfin_read_SICA_IAR4() bfin_read32(SICA_IAR4) 54#define bfin_read_SIC_IAR5() bfin_read32(SIC_IAR5)
61#define bfin_write_SICA_IAR4(val) bfin_write32(SICA_IAR4,val) 55#define bfin_write_SIC_IAR5(val) bfin_write32(SIC_IAR5,val)
62#define bfin_read_SICA_IAR5() bfin_read32(SICA_IAR5) 56#define bfin_read_SIC_IAR6() bfin_read32(SIC_IAR6)
63#define bfin_write_SICA_IAR5(val) bfin_write32(SICA_IAR5,val) 57#define bfin_write_SIC_IAR6(val) bfin_write32(SIC_IAR6,val)
64#define bfin_read_SICA_IAR6() bfin_read32(SICA_IAR6) 58#define bfin_read_SIC_IAR7() bfin_read32(SIC_IAR7)
65#define bfin_write_SICA_IAR6(val) bfin_write32(SICA_IAR6,val) 59#define bfin_write_SIC_IAR7(val) bfin_write32(SIC_IAR7,val)
66#define bfin_read_SICA_IAR7() bfin_read32(SICA_IAR7) 60#define bfin_read_SIC_ISR0() bfin_read32(SIC_ISR0)
67#define bfin_write_SICA_IAR7(val) bfin_write32(SICA_IAR7,val) 61#define bfin_write_SIC_ISR0(val) bfin_write32(SIC_ISR0,val)
68#define bfin_read_SICA_ISR0() bfin_read32(SICA_ISR0) 62#define bfin_read_SIC_ISR1() bfin_read32(SIC_ISR1)
69#define bfin_write_SICA_ISR0(val) bfin_write32(SICA_ISR0,val) 63#define bfin_write_SIC_ISR1(val) bfin_write32(SIC_ISR1,val)
70#define bfin_read_SICA_ISR1() bfin_read32(SICA_ISR1) 64#define bfin_read_SIC_IWR0() bfin_read32(SIC_IWR0)
71#define bfin_write_SICA_ISR1(val) bfin_write32(SICA_ISR1,val) 65#define bfin_write_SIC_IWR0(val) bfin_write32(SIC_IWR0,val)
72#define bfin_read_SICA_IWR0() bfin_read32(SICA_IWR0) 66#define bfin_read_SIC_IWR1() bfin_read32(SIC_IWR1)
73#define bfin_write_SICA_IWR0(val) bfin_write32(SICA_IWR0,val) 67#define bfin_write_SIC_IWR1(val) bfin_write32(SIC_IWR1,val)
74#define bfin_read_SICA_IWR1() bfin_read32(SICA_IWR1)
75#define bfin_write_SICA_IWR1(val) bfin_write32(SICA_IWR1,val)
76 68
77/* System Reset and Interrupt Controller registers for Core B (0xFFC0 1100-0xFFC0 11FF) */ 69/* System Reset and Interrupt Controller registers for Core B (0xFFC0 1100-0xFFC0 11FF) */
78#define bfin_read_SICB_SWRST() bfin_read16(SICB_SWRST) 70#define bfin_read_SICB_SWRST() bfin_read16(SICB_SWRST)
@@ -1534,54 +1526,4 @@
1534/* These need to be last due to the cdef/linux inter-dependencies */ 1526/* These need to be last due to the cdef/linux inter-dependencies */
1535#include <asm/irq.h> 1527#include <asm/irq.h>
1536 1528
1537/* Writing to PLL_CTL initiates a PLL relock sequence. */
1538static __inline__ void bfin_write_PLL_CTL(unsigned int val)
1539{
1540 unsigned long flags, iwr0, iwr1;
1541
1542 if (val == bfin_read_PLL_CTL())
1543 return;
1544
1545 local_irq_save_hw(flags);
1546 /* Enable the PLL Wakeup bit in SIC IWR */
1547 iwr0 = bfin_read32(SICA_IWR0);
1548 iwr1 = bfin_read32(SICA_IWR1);
1549 /* Only allow PPL Wakeup) */
1550 bfin_write32(SICA_IWR0, IWR_ENABLE(0));
1551 bfin_write32(SICA_IWR1, 0);
1552
1553 bfin_write16(PLL_CTL, val);
1554 SSYNC();
1555 asm("IDLE;");
1556
1557 bfin_write32(SICA_IWR0, iwr0);
1558 bfin_write32(SICA_IWR1, iwr1);
1559 local_irq_restore_hw(flags);
1560}
1561
1562/* Writing to VR_CTL initiates a PLL relock sequence. */
1563static __inline__ void bfin_write_VR_CTL(unsigned int val)
1564{
1565 unsigned long flags, iwr0, iwr1;
1566
1567 if (val == bfin_read_VR_CTL())
1568 return;
1569
1570 local_irq_save_hw(flags);
1571 /* Enable the PLL Wakeup bit in SIC IWR */
1572 iwr0 = bfin_read32(SICA_IWR0);
1573 iwr1 = bfin_read32(SICA_IWR1);
1574 /* Only allow PPL Wakeup) */
1575 bfin_write32(SICA_IWR0, IWR_ENABLE(0));
1576 bfin_write32(SICA_IWR1, 0);
1577
1578 bfin_write16(VR_CTL, val);
1579 SSYNC();
1580 asm("IDLE;");
1581
1582 bfin_write32(SICA_IWR0, iwr0);
1583 bfin_write32(SICA_IWR1, iwr1);
1584 local_irq_restore_hw(flags);
1585}
1586
1587#endif /* _CDEF_BF561_H */ 1529#endif /* _CDEF_BF561_H */
diff --git a/arch/blackfin/mach-bf561/include/mach/defBF561.h b/arch/blackfin/mach-bf561/include/mach/defBF561.h
index 2674f0097576..79e048d452e0 100644
--- a/arch/blackfin/mach-bf561/include/mach/defBF561.h
+++ b/arch/blackfin/mach-bf561/include/mach/defBF561.h
@@ -28,32 +28,29 @@
28#define CHIPID 0xFFC00014 /* Chip ID Register */ 28#define CHIPID 0xFFC00014 /* Chip ID Register */
29 29
30/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */ 30/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */
31#define SWRST SICA_SWRST
32#define SYSCR SICA_SYSCR
33#define DOUBLE_FAULT (DOUBLE_FAULT_B|DOUBLE_FAULT_A) 31#define DOUBLE_FAULT (DOUBLE_FAULT_B|DOUBLE_FAULT_A)
34#define RESET_DOUBLE (SWRST_DBL_FAULT_B|SWRST_DBL_FAULT_A) 32#define RESET_DOUBLE (SWRST_DBL_FAULT_B|SWRST_DBL_FAULT_A)
35#define RESET_WDOG (SWRST_WDT_B|SWRST_WDT_A) 33#define RESET_WDOG (SWRST_WDT_B|SWRST_WDT_A)
36#define RESET_SOFTWARE (SWRST_OCCURRED) 34#define RESET_SOFTWARE (SWRST_OCCURRED)
37 35
38/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ 36/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */
39#define SICA_SWRST 0xFFC00100 /* Software Reset register */ 37#define SWRST 0xFFC00100 /* Software Reset register */
40#define SICA_SYSCR 0xFFC00104 /* System Reset Configuration register */ 38#define SYSCR 0xFFC00104 /* System Reset Configuration register */
41#define SICA_RVECT 0xFFC00108 /* SIC Reset Vector Address Register */ 39#define SIC_RVECT 0xFFC00108 /* SIC Reset Vector Address Register */
42#define SICA_IMASK 0xFFC0010C /* SIC Interrupt Mask register 0 - hack to fix old tests */ 40#define SIC_IMASK0 0xFFC0010C /* SIC Interrupt Mask register 0 */
43#define SICA_IMASK0 0xFFC0010C /* SIC Interrupt Mask register 0 */ 41#define SIC_IMASK1 0xFFC00110 /* SIC Interrupt Mask register 1 */
44#define SICA_IMASK1 0xFFC00110 /* SIC Interrupt Mask register 1 */ 42#define SIC_IAR0 0xFFC00124 /* SIC Interrupt Assignment Register 0 */
45#define SICA_IAR0 0xFFC00124 /* SIC Interrupt Assignment Register 0 */ 43#define SIC_IAR1 0xFFC00128 /* SIC Interrupt Assignment Register 1 */
46#define SICA_IAR1 0xFFC00128 /* SIC Interrupt Assignment Register 1 */ 44#define SIC_IAR2 0xFFC0012C /* SIC Interrupt Assignment Register 2 */
47#define SICA_IAR2 0xFFC0012C /* SIC Interrupt Assignment Register 2 */ 45#define SIC_IAR3 0xFFC00130 /* SIC Interrupt Assignment Register 3 */
48#define SICA_IAR3 0xFFC00130 /* SIC Interrupt Assignment Register 3 */ 46#define SIC_IAR4 0xFFC00134 /* SIC Interrupt Assignment Register 4 */
49#define SICA_IAR4 0xFFC00134 /* SIC Interrupt Assignment Register 4 */ 47#define SIC_IAR5 0xFFC00138 /* SIC Interrupt Assignment Register 5 */
50#define SICA_IAR5 0xFFC00138 /* SIC Interrupt Assignment Register 5 */ 48#define SIC_IAR6 0xFFC0013C /* SIC Interrupt Assignment Register 6 */
51#define SICA_IAR6 0xFFC0013C /* SIC Interrupt Assignment Register 6 */ 49#define SIC_IAR7 0xFFC00140 /* SIC Interrupt Assignment Register 7 */
52#define SICA_IAR7 0xFFC00140 /* SIC Interrupt Assignment Register 7 */ 50#define SIC_ISR0 0xFFC00114 /* SIC Interrupt Status register 0 */
53#define SICA_ISR0 0xFFC00114 /* SIC Interrupt Status register 0 */ 51#define SIC_ISR1 0xFFC00118 /* SIC Interrupt Status register 1 */
54#define SICA_ISR1 0xFFC00118 /* SIC Interrupt Status register 1 */ 52#define SIC_IWR0 0xFFC0011C /* SIC Interrupt Wakeup-Enable register 0 */
55#define SICA_IWR0 0xFFC0011C /* SIC Interrupt Wakeup-Enable register 0 */ 53#define SIC_IWR1 0xFFC00120 /* SIC Interrupt Wakeup-Enable register 1 */
56#define SICA_IWR1 0xFFC00120 /* SIC Interrupt Wakeup-Enable register 1 */
57 54
58/* System Reset and Interrupt Controller registers for Core B (0xFFC0 1100-0xFFC0 11FF) */ 55/* System Reset and Interrupt Controller registers for Core B (0xFFC0 1100-0xFFC0 11FF) */
59#define SICB_SWRST 0xFFC01100 /* reserved */ 56#define SICB_SWRST 0xFFC01100 /* reserved */
@@ -1271,63 +1268,6 @@
1271#define PF14_P 14 1268#define PF14_P 14
1272#define PF15_P 15 1269#define PF15_P 15
1273 1270
1274/* *********** SERIAL PERIPHERAL INTERFACE (SPI) MASKS **************** */
1275
1276/* SPI_CTL Masks */
1277#define TIMOD 0x00000003 /* Transfer initiation mode and interrupt generation */
1278#define SZ 0x00000004 /* Send Zero (=0) or last (=1) word when TDBR empty. */
1279#define GM 0x00000008 /* When RDBR full, get more (=1) data or discard (=0) incoming Data */
1280#define PSSE 0x00000010 /* Enable (=1) Slave-Select input for Master. */
1281#define EMISO 0x00000020 /* Enable (=1) MISO pin as an output. */
1282#define SIZE 0x00000100 /* Word length (0 => 8 bits, 1 => 16 bits) */
1283#define LSBF 0x00000200 /* Data format (0 => MSB sent/received first 1 => LSB sent/received first) */
1284#define CPHA 0x00000400 /* Clock phase (0 => SPICLK starts toggling in middle of xfer, 1 => SPICLK toggles at the beginning of xfer. */
1285#define CPOL 0x00000800 /* Clock polarity (0 => active-high, 1 => active-low) */
1286#define MSTR 0x00001000 /* Configures SPI as master (=1) or slave (=0) */
1287#define WOM 0x00002000 /* Open drain (=1) data output enable (for MOSI and MISO) */
1288#define SPE 0x00004000 /* SPI module enable (=1), disable (=0) */
1289
1290/* SPI_FLG Masks */
1291#define FLS1 0x00000002 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
1292#define FLS2 0x00000004 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
1293#define FLS3 0x00000008 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
1294#define FLS4 0x00000010 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
1295#define FLS5 0x00000020 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
1296#define FLS6 0x00000040 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
1297#define FLS7 0x00000080 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
1298#define FLG1 0x00000200 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
1299#define FLG2 0x00000400 /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
1300#define FLG3 0x00000800 /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
1301#define FLG4 0x00001000 /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
1302#define FLG5 0x00002000 /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
1303#define FLG6 0x00004000 /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
1304#define FLG7 0x00008000 /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
1305
1306/* SPI_FLG Bit Positions */
1307#define FLS1_P 0x00000001 /* Enables (=1) SPI_FLOUT1 as flag output for SPI Slave-select */
1308#define FLS2_P 0x00000002 /* Enables (=1) SPI_FLOUT2 as flag output for SPI Slave-select */
1309#define FLS3_P 0x00000003 /* Enables (=1) SPI_FLOUT3 as flag output for SPI Slave-select */
1310#define FLS4_P 0x00000004 /* Enables (=1) SPI_FLOUT4 as flag output for SPI Slave-select */
1311#define FLS5_P 0x00000005 /* Enables (=1) SPI_FLOUT5 as flag output for SPI Slave-select */
1312#define FLS6_P 0x00000006 /* Enables (=1) SPI_FLOUT6 as flag output for SPI Slave-select */
1313#define FLS7_P 0x00000007 /* Enables (=1) SPI_FLOUT7 as flag output for SPI Slave-select */
1314#define FLG1_P 0x00000009 /* Activates (=0) SPI_FLOUT1 as flag output for SPI Slave-select */
1315#define FLG2_P 0x0000000A /* Activates (=0) SPI_FLOUT2 as flag output for SPI Slave-select */
1316#define FLG3_P 0x0000000B /* Activates (=0) SPI_FLOUT3 as flag output for SPI Slave-select */
1317#define FLG4_P 0x0000000C /* Activates (=0) SPI_FLOUT4 as flag output for SPI Slave-select */
1318#define FLG5_P 0x0000000D /* Activates (=0) SPI_FLOUT5 as flag output for SPI Slave-select */
1319#define FLG6_P 0x0000000E /* Activates (=0) SPI_FLOUT6 as flag output for SPI Slave-select */
1320#define FLG7_P 0x0000000F /* Activates (=0) SPI_FLOUT7 as flag output for SPI Slave-select */
1321
1322/* SPI_STAT Masks */
1323#define SPIF 0x00000001 /* Set (=1) when SPI single-word transfer complete */
1324#define MODF 0x00000002 /* Set (=1) in a master device when some other device tries to become master */
1325#define TXE 0x00000004 /* Set (=1) when transmission occurs with no new data in SPI_TDBR */
1326#define TXS 0x00000008 /* SPI_TDBR Data Buffer Status (0=Empty, 1=Full) */
1327#define RBSY 0x00000010 /* Set (=1) when data is received with RDBR full */
1328#define RXS 0x00000020 /* SPI_RDBR Data Buffer Status (0=Empty, 1=Full) */
1329#define TXCOL 0x00000040 /* When set (=1), corrupt data may have been transmitted */
1330
1331/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */ 1271/* ********************* ASYNCHRONOUS MEMORY CONTROLLER MASKS ************* */
1332 1272
1333/* AMGCTL Masks */ 1273/* AMGCTL Masks */
diff --git a/arch/blackfin/mach-bf561/include/mach/pll.h b/arch/blackfin/mach-bf561/include/mach/pll.h
new file mode 100644
index 000000000000..f2b1fbdb8e72
--- /dev/null
+++ b/arch/blackfin/mach-bf561/include/mach/pll.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2005-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7#ifndef _MACH_PLL_H
8#define _MACH_PLL_H
9
10#include <asm/blackfin.h>
11#include <asm/irqflags.h>
12
13/* Writing to PLL_CTL initiates a PLL relock sequence. */
14static __inline__ void bfin_write_PLL_CTL(unsigned int val)
15{
16 unsigned long flags, iwr0, iwr1;
17
18 if (val == bfin_read_PLL_CTL())
19 return;
20
21 flags = hard_local_irq_save();
22 /* Enable the PLL Wakeup bit in SIC IWR */
23 iwr0 = bfin_read32(SICA_IWR0);
24 iwr1 = bfin_read32(SICA_IWR1);
25 /* Only allow PPL Wakeup) */
26 bfin_write32(SICA_IWR0, IWR_ENABLE(0));
27 bfin_write32(SICA_IWR1, 0);
28
29 bfin_write16(PLL_CTL, val);
30 SSYNC();
31 asm("IDLE;");
32
33 bfin_write32(SICA_IWR0, iwr0);
34 bfin_write32(SICA_IWR1, iwr1);
35 hard_local_irq_restore(flags);
36}
37
38/* Writing to VR_CTL initiates a PLL relock sequence. */
39static __inline__ void bfin_write_VR_CTL(unsigned int val)
40{
41 unsigned long flags, iwr0, iwr1;
42
43 if (val == bfin_read_VR_CTL())
44 return;
45
46 flags = hard_local_irq_save();
47 /* Enable the PLL Wakeup bit in SIC IWR */
48 iwr0 = bfin_read32(SICA_IWR0);
49 iwr1 = bfin_read32(SICA_IWR1);
50 /* Only allow PPL Wakeup) */
51 bfin_write32(SICA_IWR0, IWR_ENABLE(0));
52 bfin_write32(SICA_IWR1, 0);
53
54 bfin_write16(VR_CTL, val);
55 SSYNC();
56 asm("IDLE;");
57
58 bfin_write32(SICA_IWR0, iwr0);
59 bfin_write32(SICA_IWR1, iwr1);
60 hard_local_irq_restore(flags);
61}
62
63#endif /* _MACH_PLL_H */
diff --git a/arch/blackfin/mach-bf561/ints-priority.c b/arch/blackfin/mach-bf561/ints-priority.c
index b4424172ad9e..7ee9262fe132 100644
--- a/arch/blackfin/mach-bf561/ints-priority.c
+++ b/arch/blackfin/mach-bf561/ints-priority.c
@@ -13,7 +13,7 @@
13void __init program_IAR(void) 13void __init program_IAR(void)
14{ 14{
15 /* Program the IAR0 Register with the configured priority */ 15 /* Program the IAR0 Register with the configured priority */
16 bfin_write_SICA_IAR0(((CONFIG_IRQ_PLL_WAKEUP - 7) << IRQ_PLL_WAKEUP_POS) | 16 bfin_write_SIC_IAR0(((CONFIG_IRQ_PLL_WAKEUP - 7) << IRQ_PLL_WAKEUP_POS) |
17 ((CONFIG_IRQ_DMA1_ERROR - 7) << IRQ_DMA1_ERROR_POS) | 17 ((CONFIG_IRQ_DMA1_ERROR - 7) << IRQ_DMA1_ERROR_POS) |
18 ((CONFIG_IRQ_DMA2_ERROR - 7) << IRQ_DMA2_ERROR_POS) | 18 ((CONFIG_IRQ_DMA2_ERROR - 7) << IRQ_DMA2_ERROR_POS) |
19 ((CONFIG_IRQ_IMDMA_ERROR - 7) << IRQ_IMDMA_ERROR_POS) | 19 ((CONFIG_IRQ_IMDMA_ERROR - 7) << IRQ_IMDMA_ERROR_POS) |
@@ -22,7 +22,7 @@ void __init program_IAR(void)
22 ((CONFIG_IRQ_SPORT0_ERROR - 7) << IRQ_SPORT0_ERROR_POS) | 22 ((CONFIG_IRQ_SPORT0_ERROR - 7) << IRQ_SPORT0_ERROR_POS) |
23 ((CONFIG_IRQ_SPORT1_ERROR - 7) << IRQ_SPORT1_ERROR_POS)); 23 ((CONFIG_IRQ_SPORT1_ERROR - 7) << IRQ_SPORT1_ERROR_POS));
24 24
25 bfin_write_SICA_IAR1(((CONFIG_IRQ_SPI_ERROR - 7) << IRQ_SPI_ERROR_POS) | 25 bfin_write_SIC_IAR1(((CONFIG_IRQ_SPI_ERROR - 7) << IRQ_SPI_ERROR_POS) |
26 ((CONFIG_IRQ_UART_ERROR - 7) << IRQ_UART_ERROR_POS) | 26 ((CONFIG_IRQ_UART_ERROR - 7) << IRQ_UART_ERROR_POS) |
27 ((CONFIG_IRQ_RESERVED_ERROR - 7) << IRQ_RESERVED_ERROR_POS) | 27 ((CONFIG_IRQ_RESERVED_ERROR - 7) << IRQ_RESERVED_ERROR_POS) |
28 ((CONFIG_IRQ_DMA1_0 - 7) << IRQ_DMA1_0_POS) | 28 ((CONFIG_IRQ_DMA1_0 - 7) << IRQ_DMA1_0_POS) |
@@ -31,7 +31,7 @@ void __init program_IAR(void)
31 ((CONFIG_IRQ_DMA1_3 - 7) << IRQ_DMA1_3_POS) | 31 ((CONFIG_IRQ_DMA1_3 - 7) << IRQ_DMA1_3_POS) |
32 ((CONFIG_IRQ_DMA1_4 - 7) << IRQ_DMA1_4_POS)); 32 ((CONFIG_IRQ_DMA1_4 - 7) << IRQ_DMA1_4_POS));
33 33
34 bfin_write_SICA_IAR2(((CONFIG_IRQ_DMA1_5 - 7) << IRQ_DMA1_5_POS) | 34 bfin_write_SIC_IAR2(((CONFIG_IRQ_DMA1_5 - 7) << IRQ_DMA1_5_POS) |
35 ((CONFIG_IRQ_DMA1_6 - 7) << IRQ_DMA1_6_POS) | 35 ((CONFIG_IRQ_DMA1_6 - 7) << IRQ_DMA1_6_POS) |
36 ((CONFIG_IRQ_DMA1_7 - 7) << IRQ_DMA1_7_POS) | 36 ((CONFIG_IRQ_DMA1_7 - 7) << IRQ_DMA1_7_POS) |
37 ((CONFIG_IRQ_DMA1_8 - 7) << IRQ_DMA1_8_POS) | 37 ((CONFIG_IRQ_DMA1_8 - 7) << IRQ_DMA1_8_POS) |
@@ -40,7 +40,7 @@ void __init program_IAR(void)
40 ((CONFIG_IRQ_DMA1_11 - 7) << IRQ_DMA1_11_POS) | 40 ((CONFIG_IRQ_DMA1_11 - 7) << IRQ_DMA1_11_POS) |
41 ((CONFIG_IRQ_DMA2_0 - 7) << IRQ_DMA2_0_POS)); 41 ((CONFIG_IRQ_DMA2_0 - 7) << IRQ_DMA2_0_POS));
42 42
43 bfin_write_SICA_IAR3(((CONFIG_IRQ_DMA2_1 - 7) << IRQ_DMA2_1_POS) | 43 bfin_write_SIC_IAR3(((CONFIG_IRQ_DMA2_1 - 7) << IRQ_DMA2_1_POS) |
44 ((CONFIG_IRQ_DMA2_2 - 7) << IRQ_DMA2_2_POS) | 44 ((CONFIG_IRQ_DMA2_2 - 7) << IRQ_DMA2_2_POS) |
45 ((CONFIG_IRQ_DMA2_3 - 7) << IRQ_DMA2_3_POS) | 45 ((CONFIG_IRQ_DMA2_3 - 7) << IRQ_DMA2_3_POS) |
46 ((CONFIG_IRQ_DMA2_4 - 7) << IRQ_DMA2_4_POS) | 46 ((CONFIG_IRQ_DMA2_4 - 7) << IRQ_DMA2_4_POS) |
@@ -49,7 +49,7 @@ void __init program_IAR(void)
49 ((CONFIG_IRQ_DMA2_7 - 7) << IRQ_DMA2_7_POS) | 49 ((CONFIG_IRQ_DMA2_7 - 7) << IRQ_DMA2_7_POS) |
50 ((CONFIG_IRQ_DMA2_8 - 7) << IRQ_DMA2_8_POS)); 50 ((CONFIG_IRQ_DMA2_8 - 7) << IRQ_DMA2_8_POS));
51 51
52 bfin_write_SICA_IAR4(((CONFIG_IRQ_DMA2_9 - 7) << IRQ_DMA2_9_POS) | 52 bfin_write_SIC_IAR4(((CONFIG_IRQ_DMA2_9 - 7) << IRQ_DMA2_9_POS) |
53 ((CONFIG_IRQ_DMA2_10 - 7) << IRQ_DMA2_10_POS) | 53 ((CONFIG_IRQ_DMA2_10 - 7) << IRQ_DMA2_10_POS) |
54 ((CONFIG_IRQ_DMA2_11 - 7) << IRQ_DMA2_11_POS) | 54 ((CONFIG_IRQ_DMA2_11 - 7) << IRQ_DMA2_11_POS) |
55 ((CONFIG_IRQ_TIMER0 - 7) << IRQ_TIMER0_POS) | 55 ((CONFIG_IRQ_TIMER0 - 7) << IRQ_TIMER0_POS) |
@@ -58,7 +58,7 @@ void __init program_IAR(void)
58 ((CONFIG_IRQ_TIMER3 - 7) << IRQ_TIMER3_POS) | 58 ((CONFIG_IRQ_TIMER3 - 7) << IRQ_TIMER3_POS) |
59 ((CONFIG_IRQ_TIMER4 - 7) << IRQ_TIMER4_POS)); 59 ((CONFIG_IRQ_TIMER4 - 7) << IRQ_TIMER4_POS));
60 60
61 bfin_write_SICA_IAR5(((CONFIG_IRQ_TIMER5 - 7) << IRQ_TIMER5_POS) | 61 bfin_write_SIC_IAR5(((CONFIG_IRQ_TIMER5 - 7) << IRQ_TIMER5_POS) |
62 ((CONFIG_IRQ_TIMER6 - 7) << IRQ_TIMER6_POS) | 62 ((CONFIG_IRQ_TIMER6 - 7) << IRQ_TIMER6_POS) |
63 ((CONFIG_IRQ_TIMER7 - 7) << IRQ_TIMER7_POS) | 63 ((CONFIG_IRQ_TIMER7 - 7) << IRQ_TIMER7_POS) |
64 ((CONFIG_IRQ_TIMER8 - 7) << IRQ_TIMER8_POS) | 64 ((CONFIG_IRQ_TIMER8 - 7) << IRQ_TIMER8_POS) |
@@ -67,7 +67,7 @@ void __init program_IAR(void)
67 ((CONFIG_IRQ_TIMER11 - 7) << IRQ_TIMER11_POS) | 67 ((CONFIG_IRQ_TIMER11 - 7) << IRQ_TIMER11_POS) |
68 ((CONFIG_IRQ_PROG0_INTA - 7) << IRQ_PROG0_INTA_POS)); 68 ((CONFIG_IRQ_PROG0_INTA - 7) << IRQ_PROG0_INTA_POS));
69 69
70 bfin_write_SICA_IAR6(((CONFIG_IRQ_PROG0_INTB - 7) << IRQ_PROG0_INTB_POS) | 70 bfin_write_SIC_IAR6(((CONFIG_IRQ_PROG0_INTB - 7) << IRQ_PROG0_INTB_POS) |
71 ((CONFIG_IRQ_PROG1_INTA - 7) << IRQ_PROG1_INTA_POS) | 71 ((CONFIG_IRQ_PROG1_INTA - 7) << IRQ_PROG1_INTA_POS) |
72 ((CONFIG_IRQ_PROG1_INTB - 7) << IRQ_PROG1_INTB_POS) | 72 ((CONFIG_IRQ_PROG1_INTB - 7) << IRQ_PROG1_INTB_POS) |
73 ((CONFIG_IRQ_PROG2_INTA - 7) << IRQ_PROG2_INTA_POS) | 73 ((CONFIG_IRQ_PROG2_INTA - 7) << IRQ_PROG2_INTA_POS) |
@@ -76,7 +76,7 @@ void __init program_IAR(void)
76 ((CONFIG_IRQ_DMA1_WRRD1 - 7) << IRQ_DMA1_WRRD1_POS) | 76 ((CONFIG_IRQ_DMA1_WRRD1 - 7) << IRQ_DMA1_WRRD1_POS) |
77 ((CONFIG_IRQ_DMA2_WRRD0 - 7) << IRQ_DMA2_WRRD0_POS)); 77 ((CONFIG_IRQ_DMA2_WRRD0 - 7) << IRQ_DMA2_WRRD0_POS));
78 78
79 bfin_write_SICA_IAR7(((CONFIG_IRQ_DMA2_WRRD1 - 7) << IRQ_DMA2_WRRD1_POS) | 79 bfin_write_SIC_IAR7(((CONFIG_IRQ_DMA2_WRRD1 - 7) << IRQ_DMA2_WRRD1_POS) |
80 ((CONFIG_IRQ_IMDMA_WRRD0 - 7) << IRQ_IMDMA_WRRD0_POS) | 80 ((CONFIG_IRQ_IMDMA_WRRD0 - 7) << IRQ_IMDMA_WRRD0_POS) |
81 ((CONFIG_IRQ_IMDMA_WRRD1 - 7) << IRQ_IMDMA_WRRD1_POS) | 81 ((CONFIG_IRQ_IMDMA_WRRD1 - 7) << IRQ_IMDMA_WRRD1_POS) |
82 ((CONFIG_IRQ_WDTIMER - 7) << IRQ_WDTIMER_POS) | 82 ((CONFIG_IRQ_WDTIMER - 7) << IRQ_WDTIMER_POS) |
diff --git a/arch/blackfin/mach-bf561/smp.c b/arch/blackfin/mach-bf561/smp.c
index 3b9a4bf7dacc..f540ed1257d6 100644
--- a/arch/blackfin/mach-bf561/smp.c
+++ b/arch/blackfin/mach-bf561/smp.c
@@ -52,19 +52,19 @@ int __init setup_profiling_timer(unsigned int multiplier) /* not supported */
52void __cpuinit platform_secondary_init(unsigned int cpu) 52void __cpuinit platform_secondary_init(unsigned int cpu)
53{ 53{
54 /* Clone setup for peripheral interrupt sources from CoreA. */ 54 /* Clone setup for peripheral interrupt sources from CoreA. */
55 bfin_write_SICB_IMASK0(bfin_read_SICA_IMASK0()); 55 bfin_write_SICB_IMASK0(bfin_read_SIC_IMASK0());
56 bfin_write_SICB_IMASK1(bfin_read_SICA_IMASK1()); 56 bfin_write_SICB_IMASK1(bfin_read_SIC_IMASK1());
57 SSYNC(); 57 SSYNC();
58 58
59 /* Clone setup for IARs from CoreA. */ 59 /* Clone setup for IARs from CoreA. */
60 bfin_write_SICB_IAR0(bfin_read_SICA_IAR0()); 60 bfin_write_SICB_IAR0(bfin_read_SIC_IAR0());
61 bfin_write_SICB_IAR1(bfin_read_SICA_IAR1()); 61 bfin_write_SICB_IAR1(bfin_read_SIC_IAR1());
62 bfin_write_SICB_IAR2(bfin_read_SICA_IAR2()); 62 bfin_write_SICB_IAR2(bfin_read_SIC_IAR2());
63 bfin_write_SICB_IAR3(bfin_read_SICA_IAR3()); 63 bfin_write_SICB_IAR3(bfin_read_SIC_IAR3());
64 bfin_write_SICB_IAR4(bfin_read_SICA_IAR4()); 64 bfin_write_SICB_IAR4(bfin_read_SIC_IAR4());
65 bfin_write_SICB_IAR5(bfin_read_SICA_IAR5()); 65 bfin_write_SICB_IAR5(bfin_read_SIC_IAR5());
66 bfin_write_SICB_IAR6(bfin_read_SICA_IAR6()); 66 bfin_write_SICB_IAR6(bfin_read_SIC_IAR6());
67 bfin_write_SICB_IAR7(bfin_read_SICA_IAR7()); 67 bfin_write_SICB_IAR7(bfin_read_SIC_IAR7());
68 bfin_write_SICB_IWR0(IWR_DISABLE_ALL); 68 bfin_write_SICB_IWR0(IWR_DISABLE_ALL);
69 bfin_write_SICB_IWR1(IWR_DISABLE_ALL); 69 bfin_write_SICB_IWR1(IWR_DISABLE_ALL);
70 SSYNC(); 70 SSYNC();
@@ -86,12 +86,12 @@ int __cpuinit platform_boot_secondary(unsigned int cpu, struct task_struct *idle
86 86
87 spin_lock(&boot_lock); 87 spin_lock(&boot_lock);
88 88
89 if ((bfin_read_SICA_SYSCR() & COREB_SRAM_INIT) == 0) { 89 if ((bfin_read_SIC_SYSCR() & COREB_SRAM_INIT) == 0) {
90 /* CoreB already running, sending ipi to wakeup it */ 90 /* CoreB already running, sending ipi to wakeup it */
91 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_0); 91 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_0);
92 } else { 92 } else {
93 /* Kick CoreB, which should start execution from CORE_SRAM_BASE. */ 93 /* Kick CoreB, which should start execution from CORE_SRAM_BASE. */
94 bfin_write_SICA_SYSCR(bfin_read_SICA_SYSCR() & ~COREB_SRAM_INIT); 94 bfin_write_SIC_SYSCR(bfin_read_SIC_SYSCR() & ~COREB_SRAM_INIT);
95 SSYNC(); 95 SSYNC();
96 } 96 }
97 97
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index 4391d03dc845..f4cf11d362e1 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -134,7 +134,7 @@ static int bfin_target(struct cpufreq_policy *poli,
134 134
135 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 135 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
136 if (cpu == CPUFREQ_CPU) { 136 if (cpu == CPUFREQ_CPU) {
137 local_irq_save_hw(flags); 137 flags = hard_local_irq_save();
138 plldiv = (bfin_read_PLL_DIV() & SSEL) | 138 plldiv = (bfin_read_PLL_DIV() & SSEL) |
139 dpm_state_table[index].csel; 139 dpm_state_table[index].csel;
140 bfin_write_PLL_DIV(plldiv); 140 bfin_write_PLL_DIV(plldiv);
@@ -155,7 +155,7 @@ static int bfin_target(struct cpufreq_policy *poli,
155 loops_per_jiffy = cpufreq_scale(lpj_ref, 155 loops_per_jiffy = cpufreq_scale(lpj_ref,
156 lpj_ref_freq, freqs.new); 156 lpj_ref_freq, freqs.new);
157 } 157 }
158 local_irq_restore_hw(flags); 158 hard_local_irq_restore(flags);
159 } 159 }
160 /* TODO: just test case for cycles clock source, remove later */ 160 /* TODO: just test case for cycles clock source, remove later */
161 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 161 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
diff --git a/arch/blackfin/mach-common/dpmc_modes.S b/arch/blackfin/mach-common/dpmc_modes.S
index 5969d86836a5..9cfdd49a3127 100644
--- a/arch/blackfin/mach-common/dpmc_modes.S
+++ b/arch/blackfin/mach-common/dpmc_modes.S
@@ -292,13 +292,7 @@ ENTRY(_do_hibernate)
292#ifdef SIC_IMASK 292#ifdef SIC_IMASK
293 PM_SYS_PUSH(SIC_IMASK) 293 PM_SYS_PUSH(SIC_IMASK)
294#endif 294#endif
295#ifdef SICA_IMASK0 295#ifdef SIC_IAR0
296 PM_SYS_PUSH(SICA_IMASK0)
297#endif
298#ifdef SICA_IMASK1
299 PM_SYS_PUSH(SICA_IMASK1)
300#endif
301#ifdef SIC_IAR2
302 PM_SYS_PUSH(SIC_IAR0) 296 PM_SYS_PUSH(SIC_IAR0)
303 PM_SYS_PUSH(SIC_IAR1) 297 PM_SYS_PUSH(SIC_IAR1)
304 PM_SYS_PUSH(SIC_IAR2) 298 PM_SYS_PUSH(SIC_IAR2)
@@ -321,17 +315,6 @@ ENTRY(_do_hibernate)
321 PM_SYS_PUSH(SIC_IAR11) 315 PM_SYS_PUSH(SIC_IAR11)
322#endif 316#endif
323 317
324#ifdef SICA_IAR0
325 PM_SYS_PUSH(SICA_IAR0)
326 PM_SYS_PUSH(SICA_IAR1)
327 PM_SYS_PUSH(SICA_IAR2)
328 PM_SYS_PUSH(SICA_IAR3)
329 PM_SYS_PUSH(SICA_IAR4)
330 PM_SYS_PUSH(SICA_IAR5)
331 PM_SYS_PUSH(SICA_IAR6)
332 PM_SYS_PUSH(SICA_IAR7)
333#endif
334
335#ifdef SIC_IWR 318#ifdef SIC_IWR
336 PM_SYS_PUSH(SIC_IWR) 319 PM_SYS_PUSH(SIC_IWR)
337#endif 320#endif
@@ -344,12 +327,6 @@ ENTRY(_do_hibernate)
344#ifdef SIC_IWR2 327#ifdef SIC_IWR2
345 PM_SYS_PUSH(SIC_IWR2) 328 PM_SYS_PUSH(SIC_IWR2)
346#endif 329#endif
347#ifdef SICA_IWR0
348 PM_SYS_PUSH(SICA_IWR0)
349#endif
350#ifdef SICA_IWR1
351 PM_SYS_PUSH(SICA_IWR1)
352#endif
353 330
354#ifdef PINT0_ASSIGN 331#ifdef PINT0_ASSIGN
355 PM_SYS_PUSH(PINT0_MASK_SET) 332 PM_SYS_PUSH(PINT0_MASK_SET)
@@ -750,12 +727,6 @@ ENTRY(_do_hibernate)
750 PM_SYS_POP(PINT0_MASK_SET) 727 PM_SYS_POP(PINT0_MASK_SET)
751#endif 728#endif
752 729
753#ifdef SICA_IWR1
754 PM_SYS_POP(SICA_IWR1)
755#endif
756#ifdef SICA_IWR0
757 PM_SYS_POP(SICA_IWR0)
758#endif
759#ifdef SIC_IWR2 730#ifdef SIC_IWR2
760 PM_SYS_POP(SIC_IWR2) 731 PM_SYS_POP(SIC_IWR2)
761#endif 732#endif
@@ -769,17 +740,6 @@ ENTRY(_do_hibernate)
769 PM_SYS_POP(SIC_IWR) 740 PM_SYS_POP(SIC_IWR)
770#endif 741#endif
771 742
772#ifdef SICA_IAR0
773 PM_SYS_POP(SICA_IAR7)
774 PM_SYS_POP(SICA_IAR6)
775 PM_SYS_POP(SICA_IAR5)
776 PM_SYS_POP(SICA_IAR4)
777 PM_SYS_POP(SICA_IAR3)
778 PM_SYS_POP(SICA_IAR2)
779 PM_SYS_POP(SICA_IAR1)
780 PM_SYS_POP(SICA_IAR0)
781#endif
782
783#ifdef SIC_IAR8 743#ifdef SIC_IAR8
784 PM_SYS_POP(SIC_IAR11) 744 PM_SYS_POP(SIC_IAR11)
785 PM_SYS_POP(SIC_IAR10) 745 PM_SYS_POP(SIC_IAR10)
@@ -797,17 +757,11 @@ ENTRY(_do_hibernate)
797#ifdef SIC_IAR3 757#ifdef SIC_IAR3
798 PM_SYS_POP(SIC_IAR3) 758 PM_SYS_POP(SIC_IAR3)
799#endif 759#endif
800#ifdef SIC_IAR2 760#ifdef SIC_IAR0
801 PM_SYS_POP(SIC_IAR2) 761 PM_SYS_POP(SIC_IAR2)
802 PM_SYS_POP(SIC_IAR1) 762 PM_SYS_POP(SIC_IAR1)
803 PM_SYS_POP(SIC_IAR0) 763 PM_SYS_POP(SIC_IAR0)
804#endif 764#endif
805#ifdef SICA_IMASK1
806 PM_SYS_POP(SICA_IMASK1)
807#endif
808#ifdef SICA_IMASK0
809 PM_SYS_POP(SICA_IMASK0)
810#endif
811#ifdef SIC_IMASK 765#ifdef SIC_IMASK
812 PM_SYS_POP(SIC_IMASK) 766 PM_SYS_POP(SIC_IMASK)
813#endif 767#endif
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index af1bffa21dc1..2ca915ee181f 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -889,6 +889,66 @@ ENTRY(_ret_from_exception)
889 rts; 889 rts;
890ENDPROC(_ret_from_exception) 890ENDPROC(_ret_from_exception)
891 891
892#if defined(CONFIG_PREEMPT)
893
894ENTRY(_up_to_irq14)
895#if ANOMALY_05000281 || ANOMALY_05000461
896 r0.l = lo(SAFE_USER_INSTRUCTION);
897 r0.h = hi(SAFE_USER_INSTRUCTION);
898 reti = r0;
899#endif
900
901#ifdef CONFIG_DEBUG_HWERR
902 /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
903 r0 = (EVT_IVG14 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
904#else
905 /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
906 r0 = (EVT_IVG14 | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
907#endif
908 sti r0;
909
910 p0.l = lo(EVT14);
911 p0.h = hi(EVT14);
912 p1.l = _evt_up_evt14;
913 p1.h = _evt_up_evt14;
914 [p0] = p1;
915 csync;
916
917 raise 14;
9181:
919 jump 1b;
920ENDPROC(_up_to_irq14)
921
922ENTRY(_evt_up_evt14)
923#ifdef CONFIG_DEBUG_HWERR
924 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
925 sti r0;
926#else
927 cli r0;
928#endif
929#ifdef CONFIG_TRACE_IRQFLAGS
930 [--sp] = rets;
931 sp += -12;
932 call _trace_hardirqs_off;
933 sp += 12;
934 rets = [sp++];
935#endif
936 [--sp] = RETI;
937 SP += 4;
938
939 /* restore normal evt14 */
940 p0.l = lo(EVT14);
941 p0.h = hi(EVT14);
942 p1.l = _evt_evt14;
943 p1.h = _evt_evt14;
944 [p0] = p1;
945 csync;
946
947 rts;
948ENDPROC(_evt_up_evt14)
949
950#endif
951
892#ifdef CONFIG_IPIPE 952#ifdef CONFIG_IPIPE
893 953
894_resume_kernel_from_int: 954_resume_kernel_from_int:
@@ -902,8 +962,54 @@ _resume_kernel_from_int:
902 ( r7:4, p5:3 ) = [sp++]; 962 ( r7:4, p5:3 ) = [sp++];
903 rets = [sp++]; 963 rets = [sp++];
904 rts 964 rts
965#elif defined(CONFIG_PREEMPT)
966
967_resume_kernel_from_int:
968 /* check preempt_count */
969 r7 = sp;
970 r4.l = lo(ALIGN_PAGE_MASK);
971 r4.h = hi(ALIGN_PAGE_MASK);
972 r7 = r7 & r4;
973 p5 = r7;
974 r7 = [p5 + TI_PREEMPT];
975 cc = r7 == 0x0;
976 if !cc jump .Lreturn_to_kernel;
977.Lneed_schedule:
978 r7 = [p5 + TI_FLAGS];
979 r4.l = lo(_TIF_WORK_MASK);
980 r4.h = hi(_TIF_WORK_MASK);
981 r7 = r7 & r4;
982 cc = BITTST(r7, TIF_NEED_RESCHED);
983 if !cc jump .Lreturn_to_kernel;
984 /*
985 * let schedule done at level 15, otherwise sheduled process will run
986 * at high level and block low level interrupt
987 */
988 r6 = reti; /* save reti */
989 r5.l = .Lkernel_schedule;
990 r5.h = .Lkernel_schedule;
991 reti = r5;
992 rti;
993.Lkernel_schedule:
994 [--sp] = rets;
995 sp += -12;
996 pseudo_long_call _preempt_schedule_irq, p4;
997 sp += 12;
998 rets = [sp++];
999
1000 [--sp] = rets;
1001 sp += -12;
1002 /* up to irq14 so that reti after restore_all can return to irq15(kernel) */
1003 pseudo_long_call _up_to_irq14, p4;
1004 sp += 12;
1005 rets = [sp++];
1006
1007 reti = r6; /* restore reti so that origin process can return to interrupted point */
1008
1009 jump .Lneed_schedule;
905#else 1010#else
906#define _resume_kernel_from_int 2f 1011
1012#define _resume_kernel_from_int .Lreturn_to_kernel
907#endif 1013#endif
908 1014
909ENTRY(_return_from_int) 1015ENTRY(_return_from_int)
@@ -913,7 +1019,7 @@ ENTRY(_return_from_int)
913 p2.h = hi(ILAT); 1019 p2.h = hi(ILAT);
914 r0 = [p2]; 1020 r0 = [p2];
915 cc = bittst (r0, EVT_IVG15_P); 1021 cc = bittst (r0, EVT_IVG15_P);
916 if cc jump 2f; 1022 if cc jump .Lreturn_to_kernel;
917 1023
918 /* if not return to user mode, get out */ 1024 /* if not return to user mode, get out */
919 p2.l = lo(IPEND); 1025 p2.l = lo(IPEND);
@@ -945,7 +1051,7 @@ ENTRY(_return_from_int)
945 STI r0; 1051 STI r0;
946 raise 15; /* raise evt15 to do signal or reschedule */ 1052 raise 15; /* raise evt15 to do signal or reschedule */
947 rti; 1053 rti;
9482: 1054.Lreturn_to_kernel:
949 rts; 1055 rts;
950ENDPROC(_return_from_int) 1056ENDPROC(_return_from_int)
951 1057
@@ -1631,6 +1737,7 @@ ENTRY(_sys_call_table)
1631 .long _sys_fanotify_init 1737 .long _sys_fanotify_init
1632 .long _sys_fanotify_mark 1738 .long _sys_fanotify_mark
1633 .long _sys_prlimit64 1739 .long _sys_prlimit64
1740 .long _sys_cacheflush
1634 1741
1635 .rept NR_syscalls-(.-_sys_call_table)/4 1742 .rept NR_syscalls-(.-_sys_call_table)/4
1636 .long _sys_ni_syscall 1743 .long _sys_ni_syscall
diff --git a/arch/blackfin/mach-common/interrupt.S b/arch/blackfin/mach-common/interrupt.S
index cee62cf4acd4..2df37db3b49b 100644
--- a/arch/blackfin/mach-common/interrupt.S
+++ b/arch/blackfin/mach-common/interrupt.S
@@ -116,7 +116,24 @@ __common_int_entry:
116 cc = r0 == 0; 116 cc = r0 == 0;
117 if cc jump .Lcommon_restore_context; 117 if cc jump .Lcommon_restore_context;
118#else /* CONFIG_IPIPE */ 118#else /* CONFIG_IPIPE */
119
120#ifdef CONFIG_PREEMPT
121 r7 = sp;
122 r4.l = lo(ALIGN_PAGE_MASK);
123 r4.h = hi(ALIGN_PAGE_MASK);
124 r7 = r7 & r4;
125 p5 = r7;
126 r7 = [p5 + TI_PREEMPT]; /* get preempt count */
127 r7 += 1; /* increment it */
128 [p5 + TI_PREEMPT] = r7;
129#endif
119 pseudo_long_call _do_irq, p2; 130 pseudo_long_call _do_irq, p2;
131
132#ifdef CONFIG_PREEMPT
133 r7 += -1;
134 [p5 + TI_PREEMPT] = r7; /* restore preempt count */
135#endif
136
120 SP += 12; 137 SP += 12;
121#endif /* CONFIG_IPIPE */ 138#endif /* CONFIG_IPIPE */
122 pseudo_long_call _return_from_int, p2; 139 pseudo_long_call _return_from_int, p2;
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c
index 1c8c4c7245c3..da7e3c63746b 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -132,8 +132,8 @@ static void bfin_ack_noop(unsigned int irq)
132static void bfin_core_mask_irq(unsigned int irq) 132static void bfin_core_mask_irq(unsigned int irq)
133{ 133{
134 bfin_irq_flags &= ~(1 << irq); 134 bfin_irq_flags &= ~(1 << irq);
135 if (!irqs_disabled_hw()) 135 if (!hard_irqs_disabled())
136 local_irq_enable_hw(); 136 hard_local_irq_enable();
137} 137}
138 138
139static void bfin_core_unmask_irq(unsigned int irq) 139static void bfin_core_unmask_irq(unsigned int irq)
@@ -148,8 +148,8 @@ static void bfin_core_unmask_irq(unsigned int irq)
148 * local_irq_enable just does "STI bfin_irq_flags", so it's exactly 148 * local_irq_enable just does "STI bfin_irq_flags", so it's exactly
149 * what we need. 149 * what we need.
150 */ 150 */
151 if (!irqs_disabled_hw()) 151 if (!hard_irqs_disabled())
152 local_irq_enable_hw(); 152 hard_local_irq_enable();
153 return; 153 return;
154} 154}
155 155
@@ -158,12 +158,12 @@ static void bfin_internal_mask_irq(unsigned int irq)
158 unsigned long flags; 158 unsigned long flags;
159 159
160#ifdef CONFIG_BF53x 160#ifdef CONFIG_BF53x
161 local_irq_save_hw(flags); 161 flags = hard_local_irq_save();
162 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() & 162 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() &
163 ~(1 << SIC_SYSIRQ(irq))); 163 ~(1 << SIC_SYSIRQ(irq)));
164#else 164#else
165 unsigned mask_bank, mask_bit; 165 unsigned mask_bank, mask_bit;
166 local_irq_save_hw(flags); 166 flags = hard_local_irq_save();
167 mask_bank = SIC_SYSIRQ(irq) / 32; 167 mask_bank = SIC_SYSIRQ(irq) / 32;
168 mask_bit = SIC_SYSIRQ(irq) % 32; 168 mask_bit = SIC_SYSIRQ(irq) % 32;
169 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) & 169 bfin_write_SIC_IMASK(mask_bank, bfin_read_SIC_IMASK(mask_bank) &
@@ -173,7 +173,7 @@ static void bfin_internal_mask_irq(unsigned int irq)
173 ~(1 << mask_bit)); 173 ~(1 << mask_bit));
174#endif 174#endif
175#endif 175#endif
176 local_irq_restore_hw(flags); 176 hard_local_irq_restore(flags);
177} 177}
178 178
179#ifdef CONFIG_SMP 179#ifdef CONFIG_SMP
@@ -186,12 +186,12 @@ static void bfin_internal_unmask_irq(unsigned int irq)
186 unsigned long flags; 186 unsigned long flags;
187 187
188#ifdef CONFIG_BF53x 188#ifdef CONFIG_BF53x
189 local_irq_save_hw(flags); 189 flags = hard_local_irq_save();
190 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() | 190 bfin_write_SIC_IMASK(bfin_read_SIC_IMASK() |
191 (1 << SIC_SYSIRQ(irq))); 191 (1 << SIC_SYSIRQ(irq)));
192#else 192#else
193 unsigned mask_bank, mask_bit; 193 unsigned mask_bank, mask_bit;
194 local_irq_save_hw(flags); 194 flags = hard_local_irq_save();
195 mask_bank = SIC_SYSIRQ(irq) / 32; 195 mask_bank = SIC_SYSIRQ(irq) / 32;
196 mask_bit = SIC_SYSIRQ(irq) % 32; 196 mask_bit = SIC_SYSIRQ(irq) % 32;
197#ifdef CONFIG_SMP 197#ifdef CONFIG_SMP
@@ -207,7 +207,7 @@ static void bfin_internal_unmask_irq(unsigned int irq)
207 (1 << mask_bit)); 207 (1 << mask_bit));
208#endif 208#endif
209#endif 209#endif
210 local_irq_restore_hw(flags); 210 hard_local_irq_restore(flags);
211} 211}
212 212
213#ifdef CONFIG_SMP 213#ifdef CONFIG_SMP
@@ -264,7 +264,7 @@ int bfin_internal_set_wake(unsigned int irq, unsigned int state)
264 break; 264 break;
265 } 265 }
266 266
267 local_irq_save_hw(flags); 267 flags = hard_local_irq_save();
268 268
269 if (state) { 269 if (state) {
270 bfin_sic_iwr[bank] |= (1 << bit); 270 bfin_sic_iwr[bank] |= (1 << bit);
@@ -275,7 +275,7 @@ int bfin_internal_set_wake(unsigned int irq, unsigned int state)
275 vr_wakeup &= ~wakeup; 275 vr_wakeup &= ~wakeup;
276 } 276 }
277 277
278 local_irq_restore_hw(flags); 278 hard_local_irq_restore(flags);
279 279
280 return 0; 280 return 0;
281} 281}
@@ -511,7 +511,7 @@ static void bfin_demux_mac_status_irq(unsigned int int_err_irq,
511 int i, irq = 0; 511 int i, irq = 0;
512 u32 status = bfin_read_EMAC_SYSTAT(); 512 u32 status = bfin_read_EMAC_SYSTAT();
513 513
514 for (i = 0; i < (IRQ_MAC_STMDONE - IRQ_MAC_PHYINT); i++) 514 for (i = 0; i <= (IRQ_MAC_STMDONE - IRQ_MAC_PHYINT); i++)
515 if (status & (1L << i)) { 515 if (status & (1L << i)) {
516 irq = IRQ_MAC_PHYINT + i; 516 irq = IRQ_MAC_PHYINT + i;
517 break; 517 break;
@@ -529,8 +529,9 @@ static void bfin_demux_mac_status_irq(unsigned int int_err_irq,
529 } else 529 } else
530 printk(KERN_ERR 530 printk(KERN_ERR
531 "%s : %s : LINE %d :\nIRQ ?: MAC ERROR" 531 "%s : %s : LINE %d :\nIRQ ?: MAC ERROR"
532 " INTERRUPT ASSERTED BUT NO SOURCE FOUND\n", 532 " INTERRUPT ASSERTED BUT NO SOURCE FOUND"
533 __func__, __FILE__, __LINE__); 533 "(EMAC_SYSTAT=0x%X)\n",
534 __func__, __FILE__, __LINE__, status);
534} 535}
535#endif 536#endif
536 537
@@ -1298,7 +1299,7 @@ void do_irq(int vec, struct pt_regs *fp)
1298 } else { 1299 } else {
1299 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst; 1300 struct ivgx *ivg = ivg7_13[vec - IVG7].ifirst;
1300 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop; 1301 struct ivgx *ivg_stop = ivg7_13[vec - IVG7].istop;
1301#if defined(SIC_ISR0) || defined(SICA_ISR0) 1302#if defined(SIC_ISR0)
1302 unsigned long sic_status[3]; 1303 unsigned long sic_status[3];
1303 1304
1304 if (smp_processor_id()) { 1305 if (smp_processor_id()) {
@@ -1378,7 +1379,7 @@ asmlinkage int __ipipe_grab_irq(int vec, struct pt_regs *regs)
1378 if (likely(vec == EVT_IVTMR_P)) 1379 if (likely(vec == EVT_IVTMR_P))
1379 irq = IRQ_CORETMR; 1380 irq = IRQ_CORETMR;
1380 else { 1381 else {
1381#if defined(SIC_ISR0) || defined(SICA_ISR0) 1382#if defined(SIC_ISR0)
1382 unsigned long sic_status[3]; 1383 unsigned long sic_status[3];
1383 1384
1384 sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0(); 1385 sic_status[0] = bfin_read_SIC_ISR0() & bfin_read_SIC_IMASK0();
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index 09c1fb410748..80884b136a0c 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -25,7 +25,7 @@ void bfin_pm_suspend_standby_enter(void)
25{ 25{
26 unsigned long flags; 26 unsigned long flags;
27 27
28 local_irq_save_hw(flags); 28 flags = hard_local_irq_save();
29 bfin_pm_standby_setup(); 29 bfin_pm_standby_setup();
30 30
31#ifdef CONFIG_PM_BFIN_SLEEP_DEEPER 31#ifdef CONFIG_PM_BFIN_SLEEP_DEEPER
@@ -56,7 +56,7 @@ void bfin_pm_suspend_standby_enter(void)
56 bfin_write_SIC_IWR(IWR_DISABLE_ALL); 56 bfin_write_SIC_IWR(IWR_DISABLE_ALL);
57#endif 57#endif
58 58
59 local_irq_restore_hw(flags); 59 hard_local_irq_restore(flags);
60} 60}
61 61
62int bf53x_suspend_l1_mem(unsigned char *memptr) 62int bf53x_suspend_l1_mem(unsigned char *memptr)
@@ -149,12 +149,12 @@ int bfin_pm_suspend_mem_enter(void)
149 wakeup |= GPWE; 149 wakeup |= GPWE;
150#endif 150#endif
151 151
152 local_irq_save_hw(flags); 152 flags = hard_local_irq_save();
153 153
154 ret = blackfin_dma_suspend(); 154 ret = blackfin_dma_suspend();
155 155
156 if (ret) { 156 if (ret) {
157 local_irq_restore_hw(flags); 157 hard_local_irq_restore(flags);
158 kfree(memptr); 158 kfree(memptr);
159 return ret; 159 return ret;
160 } 160 }
@@ -178,7 +178,7 @@ int bfin_pm_suspend_mem_enter(void)
178 bfin_gpio_pm_hibernate_restore(); 178 bfin_gpio_pm_hibernate_restore();
179 blackfin_dma_resume(); 179 blackfin_dma_resume();
180 180
181 local_irq_restore_hw(flags); 181 hard_local_irq_restore(flags);
182 kfree(memptr); 182 kfree(memptr);
183 183
184 return 0; 184 return 0;
diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index bb4e8fff4b55..f8435cd36c7c 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -158,5 +158,8 @@ void __init_refok free_initmem(void)
158 free_init_pages("unused kernel memory", 158 free_init_pages("unused kernel memory",
159 (unsigned long)(&__init_begin), 159 (unsigned long)(&__init_begin),
160 (unsigned long)(&__init_end)); 160 (unsigned long)(&__init_end));
161
162 if (memory_start == (unsigned long)(&__init_end))
163 memory_start = (unsigned long)(&__init_begin);
161#endif 164#endif
162} 165}
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 884275629ef7..3d655dcc65da 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -19,7 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/smp_lock.h> 22#include <linux/mutex.h>
23#include <linux/bcd.h> 23#include <linux/bcd.h>
24#include <linux/capability.h> 24#include <linux/capability.h>
25 25
@@ -34,6 +34,7 @@
34 34
35#define RTC_MAJOR_NR 121 /* local major, change later */ 35#define RTC_MAJOR_NR 121 /* local major, change later */
36 36
37static DEFINE_MUTEX(ds1302_mutex);
37static const char ds1302_name[] = "ds1302"; 38static const char ds1302_name[] = "ds1302";
38 39
39/* The DS1302 might be connected to different bits on different products. 40/* The DS1302 might be connected to different bits on different products.
@@ -357,9 +358,9 @@ static long rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned lon
357{ 358{
358 int ret; 359 int ret;
359 360
360 lock_kernel(); 361 mutex_lock(&ds1302_mutex);
361 ret = rtc_ioctl(file, cmd, arg); 362 ret = rtc_ioctl(file, cmd, arg);
362 unlock_kernel(); 363 mutex_unlock(&ds1302_mutex);
363 364
364 return ret; 365 return ret;
365} 366}
@@ -387,6 +388,7 @@ print_rtc_status(void)
387static const struct file_operations rtc_fops = { 388static const struct file_operations rtc_fops = {
388 .owner = THIS_MODULE, 389 .owner = THIS_MODULE,
389 .unlocked_ioctl = rtc_unlocked_ioctl, 390 .unlocked_ioctl = rtc_unlocked_ioctl,
391 .llseek = noop_llseek,
390}; 392};
391 393
392/* Probe for the chip by writing something to its RAM and try reading it back. */ 394/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index a07b6d25b0c7..a276f0811731 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -745,6 +745,7 @@ static const struct file_operations gpio_fops = {
745 .write = gpio_write, 745 .write = gpio_write,
746 .open = gpio_open, 746 .open = gpio_open,
747 .release = gpio_release, 747 .release = gpio_release,
748 .llseek = noop_llseek,
748}; 749};
749 750
750static void ioif_watcher(const unsigned int gpio_in_available, 751static void ioif_watcher(const unsigned int gpio_in_available,
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index 77a941813819..c413539d4205 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -617,6 +617,7 @@ static const struct file_operations i2c_fops = {
617 .unlocked_ioctl = i2c_ioctl, 617 .unlocked_ioctl = i2c_ioctl,
618 .open = i2c_open, 618 .open = i2c_open,
619 .release = i2c_release, 619 .release = i2c_release,
620 .llseek = noop_llseek,
620}; 621};
621 622
622int __init 623int __init
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 7dcb1f85f42b..ea69faba9b62 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -27,7 +27,6 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/bcd.h> 28#include <linux/bcd.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/smp_lock.h>
31 30
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
33#include <asm/system.h> 32#include <asm/system.h>
@@ -49,6 +48,7 @@
49#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) 48#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x)
50#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) 49#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y)
51 50
51static DEFINE_MUTEX(pcf8563_mutex);
52static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ 52static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
53 53
54static const unsigned char days_in_month[] = 54static const unsigned char days_in_month[] =
@@ -64,6 +64,7 @@ static int voltage_low;
64static const struct file_operations pcf8563_fops = { 64static const struct file_operations pcf8563_fops = {
65 .owner = THIS_MODULE, 65 .owner = THIS_MODULE,
66 .unlocked_ioctl = pcf8563_unlocked_ioctl, 66 .unlocked_ioctl = pcf8563_unlocked_ioctl,
67 .llseek = noop_llseek,
67}; 68};
68 69
69unsigned char 70unsigned char
@@ -343,9 +344,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
343{ 344{
344 int ret; 345 int ret;
345 346
346 lock_kernel(); 347 mutex_lock(&pcf8563_mutex);
347 return pcf8563_ioctl(filp, cmd, arg); 348 return pcf8563_ioctl(filp, cmd, arg);
348 unlock_kernel(); 349 mutex_unlock(&pcf8563_mutex);
349 350
350 return ret; 351 return ret;
351} 352}
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
index ee2dd4323daf..399dc1ec8e6f 100644
--- a/arch/cris/arch-v10/drivers/sync_serial.c
+++ b/arch/cris/arch-v10/drivers/sync_serial.c
@@ -20,7 +20,7 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/timer.h> 24#include <linux/timer.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/dma.h> 26#include <asm/dma.h>
@@ -149,6 +149,7 @@ struct sync_port {
149}; 149};
150 150
151 151
152static DEFINE_MUTEX(sync_serial_mutex);
152static int etrax_sync_serial_init(void); 153static int etrax_sync_serial_init(void);
153static void initialize_port(int portnbr); 154static void initialize_port(int portnbr);
154static inline int sync_data_avail(struct sync_port *port); 155static inline int sync_data_avail(struct sync_port *port);
@@ -250,7 +251,8 @@ static const struct file_operations sync_serial_fops = {
250 .poll = sync_serial_poll, 251 .poll = sync_serial_poll,
251 .unlocked_ioctl = sync_serial_ioctl, 252 .unlocked_ioctl = sync_serial_ioctl,
252 .open = sync_serial_open, 253 .open = sync_serial_open,
253 .release = sync_serial_release 254 .release = sync_serial_release,
255 .llseek = noop_llseek,
254}; 256};
255 257
256static int __init etrax_sync_serial_init(void) 258static int __init etrax_sync_serial_init(void)
@@ -445,7 +447,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
445 int mode; 447 int mode;
446 int err = -EBUSY; 448 int err = -EBUSY;
447 449
448 lock_kernel(); 450 mutex_lock(&sync_serial_mutex);
449 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 451 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
450 452
451 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { 453 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
@@ -626,7 +628,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
626 ret = 0; 628 ret = 0;
627 629
628out: 630out:
629 unlock_kernel(); 631 mutex_unlock(&sync_serial_mutex);
630 return ret; 632 return ret;
631} 633}
632 634
@@ -961,9 +963,9 @@ static long sync_serial_ioctl(struct file *file,
961{ 963{
962 long ret; 964 long ret;
963 965
964 lock_kernel(); 966 mutex_lock(&sync_serial_mutex);
965 ret = sync_serial_ioctl_unlocked(file, cmd, arg); 967 ret = sync_serial_ioctl_unlocked(file, cmd, arg);
966 unlock_kernel(); 968 mutex_unlock(&sync_serial_mutex);
967 969
968 return ret; 970 return ret;
969} 971}
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index b07646a30509..c03bc3bc30c2 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -281,7 +281,8 @@ const struct file_operations cryptocop_fops = {
281 .owner = THIS_MODULE, 281 .owner = THIS_MODULE,
282 .open = cryptocop_open, 282 .open = cryptocop_open,
283 .release = cryptocop_release, 283 .release = cryptocop_release,
284 .unlocked_ioctl = cryptocop_ioctl 284 .unlocked_ioctl = cryptocop_ioctl,
285 .llseek = noop_llseek,
285}; 286};
286 287
287 288
@@ -3139,9 +3140,9 @@ cryptocop_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3139 struct inode *inode = file->f_path.dentry->d_inode; 3140 struct inode *inode = file->f_path.dentry->d_inode;
3140 long ret; 3141 long ret;
3141 3142
3142 lock_kernel(); 3143 mutex_lock(&cryptocop_mutex);
3143 ret = cryptocop_ioctl_unlocked(inode, filp, cmd, arg); 3144 ret = cryptocop_ioctl_unlocked(inode, filp, cmd, arg);
3144 unlock_kernel(); 3145 mutex_unlock(&cryptocop_mutex);
3145 3146
3146 return ret; 3147 return ret;
3147} 3148}
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 5a3e900c9a78..ddb23996f11a 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -698,6 +698,7 @@ static const struct file_operations i2c_fops = {
698 .unlocked_ioctl = i2c_ioctl, 698 .unlocked_ioctl = i2c_ioctl,
699 .open = i2c_open, 699 .open = i2c_open,
700 .release = i2c_release, 700 .release = i2c_release,
701 .llseek = noop_llseek,
701}; 702};
702 703
703static int __init i2c_init(void) 704static int __init i2c_init(void)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
index 2dcd27adbad4..c845831e2225 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
@@ -23,7 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/smp_lock.h> 26#include <linux/mutex.h>
27 27
28#include <asm/etraxgpio.h> 28#include <asm/etraxgpio.h>
29#include <hwregs/reg_map.h> 29#include <hwregs/reg_map.h>
@@ -66,6 +66,7 @@ static int dp_cnt;
66#define DP(x) 66#define DP(x)
67#endif 67#endif
68 68
69static DEFINE_MUTEX(gpio_mutex);
69static char gpio_name[] = "etrax gpio"; 70static char gpio_name[] = "etrax gpio";
70 71
71#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 72#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
@@ -391,7 +392,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
391 if (!priv) 392 if (!priv)
392 return -ENOMEM; 393 return -ENOMEM;
393 394
394 lock_kernel(); 395 mutex_lock(&gpio_mutex);
395 memset(priv, 0, sizeof(*priv)); 396 memset(priv, 0, sizeof(*priv));
396 397
397 priv->minor = p; 398 priv->minor = p;
@@ -414,7 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
414 spin_unlock_irq(&gpio_lock); 415 spin_unlock_irq(&gpio_lock);
415 } 416 }
416 417
417 unlock_kernel(); 418 mutex_unlock(&gpio_mutex);
418 return 0; 419 return 0;
419} 420}
420 421
@@ -667,9 +668,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
667{ 668{
668 long ret; 669 long ret;
669 670
670 lock_kernel(); 671 mutex_lock(&gpio_mutex);
671 ret = gpio_ioctl_unlocked(file, cmd, arg); 672 ret = gpio_ioctl_unlocked(file, cmd, arg);
672 unlock_kernel(); 673 mutex_unlock(&gpio_mutex);
673 674
674 return ret; 675 return ret;
675} 676}
@@ -893,6 +894,7 @@ static const struct file_operations gpio_fops = {
893 .write = gpio_write, 894 .write = gpio_write,
894 .open = gpio_open, 895 .open = gpio_open,
895 .release = gpio_release, 896 .release = gpio_release,
897 .llseek = noop_llseek,
896}; 898};
897 899
898#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 900#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
index 5ec8a7d4e7d7..ee90d2659be7 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
@@ -22,7 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/smp_lock.h> 25#include <linux/mutex.h>
26 26
27#include <asm/etraxgpio.h> 27#include <asm/etraxgpio.h>
28#include <hwregs/reg_map.h> 28#include <hwregs/reg_map.h>
@@ -64,6 +64,7 @@ static int dp_cnt;
64#define DP(x) 64#define DP(x)
65#endif 65#endif
66 66
67static DEFINE_MUTEX(gpio_mutex);
67static char gpio_name[] = "etrax gpio"; 68static char gpio_name[] = "etrax gpio";
68 69
69#if 0 70#if 0
@@ -429,7 +430,7 @@ gpio_open(struct inode *inode, struct file *filp)
429 if (!priv) 430 if (!priv)
430 return -ENOMEM; 431 return -ENOMEM;
431 432
432 lock_kernel(); 433 mutex_lock(&gpio_mutex);
433 memset(priv, 0, sizeof(*priv)); 434 memset(priv, 0, sizeof(*priv));
434 435
435 priv->minor = p; 436 priv->minor = p;
@@ -450,7 +451,7 @@ gpio_open(struct inode *inode, struct file *filp)
450 alarmlist = priv; 451 alarmlist = priv;
451 spin_unlock_irq(&alarm_lock); 452 spin_unlock_irq(&alarm_lock);
452 453
453 unlock_kernel(); 454 mutex_unlock(&gpio_mutex);
454 return 0; 455 return 0;
455} 456}
456 457
@@ -708,9 +709,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
708{ 709{
709 long ret; 710 long ret;
710 711
711 lock_kernel(); 712 mutex_lock(&gpio_mutex);
712 ret = gpio_ioctl_unlocked(file, cmd, arg); 713 ret = gpio_ioctl_unlocked(file, cmd, arg);
713 unlock_kernel(); 714 mutex_unlock(&gpio_mutex);
714 715
715 return ret; 716 return ret;
716} 717}
@@ -870,6 +871,7 @@ static const struct file_operations gpio_fops = {
870 .write = gpio_write, 871 .write = gpio_write,
871 .open = gpio_open, 872 .open = gpio_open,
872 .release = gpio_release, 873 .release = gpio_release,
874 .llseek = noop_llseek,
873}; 875};
874 876
875#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 877#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index bef6eb53b153..b6e4fc0aad42 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/smp_lock.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/bcd.h> 28#include <linux/bcd.h>
30#include <linux/mutex.h> 29#include <linux/mutex.h>
@@ -45,6 +44,7 @@
45#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) 44#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x)
46#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) 45#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y)
47 46
47static DEFINE_MUTEX(pcf8563_mutex);
48static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ 48static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
49 49
50static const unsigned char days_in_month[] = 50static const unsigned char days_in_month[] =
@@ -60,6 +60,7 @@ static int voltage_low;
60static const struct file_operations pcf8563_fops = { 60static const struct file_operations pcf8563_fops = {
61 .owner = THIS_MODULE, 61 .owner = THIS_MODULE,
62 .unlocked_ioctl = pcf8563_unlocked_ioctl, 62 .unlocked_ioctl = pcf8563_unlocked_ioctl,
63 .llseek = noop_llseek,
63}; 64};
64 65
65unsigned char 66unsigned char
@@ -339,9 +340,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
339{ 340{
340 int ret; 341 int ret;
341 342
342 lock_kernel(); 343 mutex_lock(&pcf8563_mutex);
343 return pcf8563_ioctl(filp, cmd, arg); 344 return pcf8563_ioctl(filp, cmd, arg);
344 unlock_kernel(); 345 mutex_unlock(&pcf8563_mutex);
345 346
346 return ret; 347 return ret;
347} 348}
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index ca248f3adb80..c8637a9195ea 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -13,7 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/major.h> 14#include <linux/major.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/smp_lock.h> 16#include <linux/mutex.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/poll.h> 18#include <linux/poll.h>
19#include <linux/init.h> 19#include <linux/init.h>
@@ -145,6 +145,7 @@ typedef struct sync_port
145 spinlock_t lock; 145 spinlock_t lock;
146} sync_port; 146} sync_port;
147 147
148static DEFINE_MUTEX(sync_serial_mutex);
148static int etrax_sync_serial_init(void); 149static int etrax_sync_serial_init(void);
149static void initialize_port(int portnbr); 150static void initialize_port(int portnbr);
150static inline int sync_data_avail(struct sync_port *port); 151static inline int sync_data_avail(struct sync_port *port);
@@ -247,7 +248,8 @@ static const struct file_operations sync_serial_fops = {
247 .poll = sync_serial_poll, 248 .poll = sync_serial_poll,
248 .unlocked_ioctl = sync_serial_ioctl, 249 .unlocked_ioctl = sync_serial_ioctl,
249 .open = sync_serial_open, 250 .open = sync_serial_open,
250 .release = sync_serial_release 251 .release = sync_serial_release,
252 .llseek = noop_llseek,
251}; 253};
252 254
253static int __init etrax_sync_serial_init(void) 255static int __init etrax_sync_serial_init(void)
@@ -434,7 +436,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
434 reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; 436 reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
435 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; 437 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes};
436 438
437 lock_kernel(); 439 mutex_lock(&sync_serial_mutex);
438 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 440 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
439 441
440 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) 442 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
@@ -583,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
583 port->busy++; 585 port->busy++;
584 ret = 0; 586 ret = 0;
585out: 587out:
586 unlock_kernel(); 588 mutex_unlock(&sync_serial_mutex);
587 return ret; 589 return ret;
588} 590}
589 591
@@ -966,9 +968,9 @@ static long sync_serial_ioctl(struct file *file,
966{ 968{
967 long ret; 969 long ret;
968 970
969 lock_kernel(); 971 mutex_lock(&sync_serial_mutex);
970 ret = sync_serial_ioctl_unlocked(file, cmd, arg); 972 ret = sync_serial_ioctl_unlocked(file, cmd, arg);
971 unlock_kernel(); 973 mutex_unlock(&sync_serial_mutex);
972 974
973 return ret; 975 return ret;
974} 976}
diff --git a/arch/cris/include/arch-v10/arch/irqflags.h b/arch/cris/include/arch-v10/arch/irqflags.h
new file mode 100644
index 000000000000..75ef18991240
--- /dev/null
+++ b/arch/cris/include/arch-v10/arch/irqflags.h
@@ -0,0 +1,45 @@
1#ifndef __ASM_CRIS_ARCH_IRQFLAGS_H
2#define __ASM_CRIS_ARCH_IRQFLAGS_H
3
4#include <linux/types.h>
5
6static inline unsigned long arch_local_save_flags(void)
7{
8 unsigned long flags;
9 asm volatile("move $ccr,%0" : "=rm" (flags) : : "memory");
10 return flags;
11}
12
13static inline void arch_local_irq_disable(void)
14{
15 asm volatile("di" : : : "memory");
16}
17
18static inline void arch_local_irq_enable(void)
19{
20 asm volatile("ei" : : : "memory");
21}
22
23static inline unsigned long arch_local_irq_save(void)
24{
25 unsigned long flags = arch_local_save_flags();
26 arch_local_irq_disable();
27 return flags;
28}
29
30static inline void arch_local_irq_restore(unsigned long flags)
31{
32 asm volatile("move %0,$ccr" : : "rm" (flags) : "memory");
33}
34
35static inline bool arch_irqs_disabled_flags(unsigned long flags)
36{
37 return !(flags & (1 << 5));
38}
39
40static inline bool arch_irqs_disabled(void)
41{
42 return arch_irqs_disabled_flags(arch_local_save_flags());
43}
44
45#endif /* __ASM_CRIS_ARCH_IRQFLAGS_H */
diff --git a/arch/cris/include/arch-v10/arch/system.h b/arch/cris/include/arch-v10/arch/system.h
index 4a9cd36c9e16..935fde34aa15 100644
--- a/arch/cris/include/arch-v10/arch/system.h
+++ b/arch/cris/include/arch-v10/arch/system.h
@@ -44,20 +44,4 @@ static inline unsigned long _get_base(char * addr)
44struct __xchg_dummy { unsigned long a[100]; }; 44struct __xchg_dummy { unsigned long a[100]; };
45#define __xg(x) ((struct __xchg_dummy *)(x)) 45#define __xg(x) ((struct __xchg_dummy *)(x))
46 46
47/* interrupt control.. */
48#define local_save_flags(x) __asm__ __volatile__ ("move $ccr,%0" : "=rm" (x) : : "memory");
49#define local_irq_restore(x) __asm__ __volatile__ ("move %0,$ccr" : : "rm" (x) : "memory");
50#define local_irq_disable() __asm__ __volatile__ ( "di" : : :"memory");
51#define local_irq_enable() __asm__ __volatile__ ( "ei" : : :"memory");
52
53#define irqs_disabled() \
54({ \
55 unsigned long flags; \
56 local_save_flags(flags); \
57 !(flags & (1<<5)); \
58})
59
60/* For spinlocks etc */
61#define local_irq_save(x) __asm__ __volatile__ ("move $ccr,%0\n\tdi" : "=rm" (x) : : "memory");
62
63#endif 47#endif
diff --git a/arch/cris/include/arch-v32/arch/irqflags.h b/arch/cris/include/arch-v32/arch/irqflags.h
new file mode 100644
index 000000000000..041851f8ec6f
--- /dev/null
+++ b/arch/cris/include/arch-v32/arch/irqflags.h
@@ -0,0 +1,46 @@
1#ifndef __ASM_CRIS_ARCH_IRQFLAGS_H
2#define __ASM_CRIS_ARCH_IRQFLAGS_H
3
4#include <linux/types.h>
5#include <arch/ptrace.h>
6
7static inline unsigned long arch_local_save_flags(void)
8{
9 unsigned long flags;
10 asm volatile("move $ccs,%0" : "=rm" (flags) : : "memory");
11 return flags;
12}
13
14static inline void arch_local_irq_disable(void)
15{
16 asm volatile("di" : : : "memory");
17}
18
19static inline void arch_local_irq_enable(void)
20{
21 asm volatile("ei" : : : "memory");
22}
23
24static inline unsigned long arch_local_irq_save(void)
25{
26 unsigned long flags = arch_local_save_flags();
27 arch_local_irq_disable();
28 return flags;
29}
30
31static inline void arch_local_irq_restore(unsigned long flags)
32{
33 asm volatile("move %0,$ccs" : : "rm" (flags) : "memory");
34}
35
36static inline bool arch_irqs_disabled_flags(unsigned long flags)
37{
38 return !(flags & (1 << I_CCS_BITNR));
39}
40
41static inline bool arch_irqs_disabled(void)
42{
43 return arch_irqs_disabled_flags(arch_local_save_flags());
44}
45
46#endif /* __ASM_CRIS_ARCH_IRQFLAGS_H */
diff --git a/arch/cris/include/arch-v32/arch/system.h b/arch/cris/include/arch-v32/arch/system.h
index 6ca90f1f110a..76cea99eaa60 100644
--- a/arch/cris/include/arch-v32/arch/system.h
+++ b/arch/cris/include/arch-v32/arch/system.h
@@ -44,26 +44,4 @@ static inline unsigned long rdsp(void)
44struct __xchg_dummy { unsigned long a[100]; }; 44struct __xchg_dummy { unsigned long a[100]; };
45#define __xg(x) ((struct __xchg_dummy *)(x)) 45#define __xg(x) ((struct __xchg_dummy *)(x))
46 46
47/* Used for interrupt control. */
48#define local_save_flags(x) \
49 __asm__ __volatile__ ("move $ccs, %0" : "=rm" (x) : : "memory");
50
51#define local_irq_restore(x) \
52 __asm__ __volatile__ ("move %0, $ccs" : : "rm" (x) : "memory");
53
54#define local_irq_disable() __asm__ __volatile__ ("di" : : : "memory");
55#define local_irq_enable() __asm__ __volatile__ ("ei" : : : "memory");
56
57#define irqs_disabled() \
58({ \
59 unsigned long flags; \
60 \
61 local_save_flags(flags);\
62 !(flags & (1 << I_CCS_BITNR)); \
63})
64
65/* Used for spinlocks, etc. */
66#define local_irq_save(x) \
67 __asm__ __volatile__ ("move $ccs, %0\n\tdi" : "=rm" (x) : : "memory");
68
69#endif /* _ASM_CRIS_ARCH_SYSTEM_H */ 47#endif /* _ASM_CRIS_ARCH_SYSTEM_H */
diff --git a/arch/cris/include/asm/ioctls.h b/arch/cris/include/asm/ioctls.h
index c9129ed37443..488fbb3f5e84 100644
--- a/arch/cris/include/asm/ioctls.h
+++ b/arch/cris/include/asm/ioctls.h
@@ -1,93 +1,11 @@
1#ifndef __ARCH_CRIS_IOCTLS_H__ 1#ifndef __ARCH_CRIS_IOCTLS_H__
2#define __ARCH_CRIS_IOCTLS_H__ 2#define __ARCH_CRIS_IOCTLS_H__
3 3
4/* verbatim copy of asm-i386/ioctls.h */
5
6#include <asm/ioctl.h>
7
8/* 0x54 is just a magic number to make these relatively unique ('T') */
9
10#define TCGETS 0x5401
11#define TCSETS 0x5402
12#define TCSETSW 0x5403
13#define TCSETSF 0x5404
14#define TCGETA 0x5405
15#define TCSETA 0x5406
16#define TCSETAW 0x5407
17#define TCSETAF 0x5408
18#define TCSBRK 0x5409
19#define TCXONC 0x540A
20#define TCFLSH 0x540B
21#define TIOCEXCL 0x540C
22#define TIOCNXCL 0x540D
23#define TIOCSCTTY 0x540E
24#define TIOCGPGRP 0x540F
25#define TIOCSPGRP 0x5410
26#define TIOCOUTQ 0x5411
27#define TIOCSTI 0x5412
28#define TIOCGWINSZ 0x5413
29#define TIOCSWINSZ 0x5414
30#define TIOCMGET 0x5415
31#define TIOCMBIS 0x5416
32#define TIOCMBIC 0x5417
33#define TIOCMSET 0x5418
34#define TIOCGSOFTCAR 0x5419
35#define TIOCSSOFTCAR 0x541A
36#define FIONREAD 0x541B
37#define TIOCINQ FIONREAD
38#define TIOCLINUX 0x541C
39#define TIOCCONS 0x541D
40#define TIOCGSERIAL 0x541E
41#define TIOCSSERIAL 0x541F
42#define TIOCPKT 0x5420
43#define FIONBIO 0x5421
44#define TIOCNOTTY 0x5422
45#define TIOCSETD 0x5423
46#define TIOCGETD 0x5424
47#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
48#define TIOCSBRK 0x5427 /* BSD compatibility */
49#define TIOCCBRK 0x5428 /* BSD compatibility */
50#define TIOCGSID 0x5429 /* Return the session ID of FD */
51#define TCGETS2 _IOR('T',0x2A, struct termios2)
52#define TCSETS2 _IOW('T',0x2B, struct termios2)
53#define TCSETSW2 _IOW('T',0x2C, struct termios2)
54#define TCSETSF2 _IOW('T',0x2D, struct termios2)
55#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
56#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
57#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
58
59#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
60#define FIOCLEX 0x5451
61#define FIOASYNC 0x5452
62#define TIOCSERCONFIG 0x5453
63#define TIOCSERGWILD 0x5454
64#define TIOCSERSWILD 0x5455
65#define TIOCGLCKTRMIOS 0x5456
66#define TIOCSLCKTRMIOS 0x5457
67#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 4#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
68#define TIOCSERGETLSR 0x5459 /* Get line status register */
69#define TIOCSERGETMULTI 0x545A /* Get multiport config */
70#define TIOCSERSETMULTI 0x545B /* Set multiport config */
71
72#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
73#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
74#define FIOQSIZE 0x5460
75
76#define TIOCSERSETRS485 0x5461 /* enable rs-485 (deprecated) */ 5#define TIOCSERSETRS485 0x5461 /* enable rs-485 (deprecated) */
77#define TIOCSERWRRS485 0x5462 /* write rs-485 */ 6#define TIOCSERWRRS485 0x5462 /* write rs-485 */
78#define TIOCSRS485 0x5463 /* enable rs-485 */ 7#define TIOCSRS485 0x5463 /* enable rs-485 */
79#define TIOCGRS485 0x542E /* get rs-485 */
80
81/* Used for packet mode */
82#define TIOCPKT_DATA 0
83#define TIOCPKT_FLUSHREAD 1
84#define TIOCPKT_FLUSHWRITE 2
85#define TIOCPKT_STOP 4
86#define TIOCPKT_START 8
87#define TIOCPKT_NOSTOP 16
88#define TIOCPKT_DOSTOP 32
89#define TIOCPKT_IOCTL 64
90 8
91#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 9#include <asm-generic/ioctls.h>
92 10
93#endif 11#endif
diff --git a/arch/cris/include/asm/irqflags.h b/arch/cris/include/asm/irqflags.h
new file mode 100644
index 000000000000..943ba5ca6d2c
--- /dev/null
+++ b/arch/cris/include/asm/irqflags.h
@@ -0,0 +1 @@
#include <arch/irqflags.h>
diff --git a/arch/cris/include/asm/system.h b/arch/cris/include/asm/system.h
index 8657b084a922..ea10592f7d75 100644
--- a/arch/cris/include/asm/system.h
+++ b/arch/cris/include/asm/system.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_CRIS_SYSTEM_H 1#ifndef __ASM_CRIS_SYSTEM_H
2#define __ASM_CRIS_SYSTEM_H 2#define __ASM_CRIS_SYSTEM_H
3 3
4#include <linux/irqflags.h>
4#include <arch/system.h> 5#include <arch/system.h>
5 6
6/* the switch_to macro calls resume, an asm function in entry.S which does the actual 7/* the switch_to macro calls resume, an asm function in entry.S which does the actual
diff --git a/arch/cris/kernel/profile.c b/arch/cris/kernel/profile.c
index 195ec5fa0dd2..b82e08615d1b 100644
--- a/arch/cris/kernel/profile.c
+++ b/arch/cris/kernel/profile.c
@@ -59,6 +59,7 @@ write_cris_profile(struct file *file, const char __user *buf,
59static const struct file_operations cris_proc_profile_operations = { 59static const struct file_operations cris_proc_profile_operations = {
60 .read = read_cris_profile, 60 .read = read_cris_profile,
61 .write = write_cris_profile, 61 .write = write_cris_profile,
62 .llseek = default_llseek,
62}; 63};
63 64
64static int __init init_cris_profile(void) 65static int __init init_cris_profile(void)
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index 16399bd24993..0f2417df6323 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -7,6 +7,7 @@ config FRV
7 default y 7 default y
8 select HAVE_IDE 8 select HAVE_IDE
9 select HAVE_ARCH_TRACEHOOK 9 select HAVE_ARCH_TRACEHOOK
10 select HAVE_IRQ_WORK
10 select HAVE_PERF_EVENTS 11 select HAVE_PERF_EVENTS
11 12
12config ZONE_DMA 13config ZONE_DMA
diff --git a/arch/frv/include/asm/ioctls.h b/arch/frv/include/asm/ioctls.h
index a993e3759ccf..2f9fb436ec3c 100644
--- a/arch/frv/include/asm/ioctls.h
+++ b/arch/frv/include/asm/ioctls.h
@@ -1,88 +1,10 @@
1#ifndef __ASM_IOCTLS_H__ 1#ifndef __ASM_IOCTLS_H__
2#define __ASM_IOCTLS_H__ 2#define __ASM_IOCTLS_H__
3 3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ 4#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
57
58#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
59#define FIOCLEX 0x5451
60#define FIOASYNC 0x5452
61#define TIOCSERCONFIG 0x5453
62#define TIOCSERGWILD 0x5454
63#define TIOCSERSWILD 0x5455
64#define TIOCGLCKTRMIOS 0x5456
65#define TIOCSLCKTRMIOS 0x5457
66#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
67#define TIOCSERGETLSR 0x5459 /* Get line status register */
68#define TIOCSERGETMULTI 0x545A /* Get multiport config */
69#define TIOCSERSETMULTI 0x545B /* Set multiport config */
70
71#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
72#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
73#define FIOQSIZE 0x545E 5#define FIOQSIZE 0x545E
74 6
75/* Used for packet mode */ 7#include <asm-generic/ioctls.h>
76#define TIOCPKT_DATA 0
77#define TIOCPKT_FLUSHREAD 1
78#define TIOCPKT_FLUSHWRITE 2
79#define TIOCPKT_STOP 4
80#define TIOCPKT_START 8
81#define TIOCPKT_NOSTOP 16
82#define TIOCPKT_DOSTOP 32
83#define TIOCPKT_IOCTL 64
84
85#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
86 8
87#endif /* __ASM_IOCTLS_H__ */ 9#endif /* __ASM_IOCTLS_H__ */
88 10
diff --git a/arch/frv/include/asm/irqflags.h b/arch/frv/include/asm/irqflags.h
new file mode 100644
index 000000000000..82f0b5363f42
--- /dev/null
+++ b/arch/frv/include/asm/irqflags.h
@@ -0,0 +1,158 @@
1/* FR-V interrupt handling
2 *
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IRQFLAGS_H
13#define _ASM_IRQFLAGS_H
14
15/*
16 * interrupt flag manipulation
17 * - use virtual interrupt management since touching the PSR is slow
18 * - ICC2.Z: T if interrupts virtually disabled
19 * - ICC2.C: F if interrupts really disabled
20 * - if Z==1 upon interrupt:
21 * - C is set to 0
22 * - interrupts are really disabled
23 * - entry.S returns immediately
24 * - uses TIHI (TRAP if Z==0 && C==0) #2 to really reenable interrupts
25 * - if taken, the trap:
26 * - sets ICC2.C
27 * - enables interrupts
28 */
29static inline void arch_local_irq_disable(void)
30{
31 /* set Z flag, but don't change the C flag */
32 asm volatile(" andcc gr0,gr0,gr0,icc2 \n"
33 :
34 :
35 : "memory", "icc2"
36 );
37}
38
39static inline void arch_local_irq_enable(void)
40{
41 /* clear Z flag and then test the C flag */
42 asm volatile(" oricc gr0,#1,gr0,icc2 \n"
43 " tihi icc2,gr0,#2 \n"
44 :
45 :
46 : "memory", "icc2"
47 );
48}
49
50static inline unsigned long arch_local_save_flags(void)
51{
52 unsigned long flags;
53
54 asm volatile("movsg ccr,%0"
55 : "=r"(flags)
56 :
57 : "memory");
58
59 /* shift ICC2.Z to bit 0 */
60 flags >>= 26;
61
62 /* make flags 1 if interrupts disabled, 0 otherwise */
63 return flags & 1UL;
64
65}
66
67static inline unsigned long arch_local_irq_save(void)
68{
69 unsigned long flags = arch_local_save_flags();
70 arch_local_irq_disable();
71 return flags;
72}
73
74static inline void arch_local_irq_restore(unsigned long flags)
75{
76 /* load the Z flag by turning 1 if disabled into 0 if disabled
77 * and thus setting the Z flag but not the C flag */
78 asm volatile(" xoricc %0,#1,gr0,icc2 \n"
79 /* then trap if Z=0 and C=0 */
80 " tihi icc2,gr0,#2 \n"
81 :
82 : "r"(flags)
83 : "memory", "icc2"
84 );
85
86}
87
88static inline bool arch_irqs_disabled_flags(unsigned long flags)
89{
90 return flags;
91}
92
93static inline bool arch_irqs_disabled(void)
94{
95 return arch_irqs_disabled_flags(arch_local_save_flags());
96}
97
98/*
99 * real interrupt flag manipulation
100 */
101#define __arch_local_irq_disable() \
102do { \
103 unsigned long psr; \
104 asm volatile(" movsg psr,%0 \n" \
105 " andi %0,%2,%0 \n" \
106 " ori %0,%1,%0 \n" \
107 " movgs %0,psr \n" \
108 : "=r"(psr) \
109 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
110 : "memory"); \
111} while (0)
112
113#define __arch_local_irq_enable() \
114do { \
115 unsigned long psr; \
116 asm volatile(" movsg psr,%0 \n" \
117 " andi %0,%1,%0 \n" \
118 " movgs %0,psr \n" \
119 : "=r"(psr) \
120 : "i" (~PSR_PIL) \
121 : "memory"); \
122} while (0)
123
124#define __arch_local_save_flags(flags) \
125do { \
126 typecheck(unsigned long, flags); \
127 asm("movsg psr,%0" \
128 : "=r"(flags) \
129 : \
130 : "memory"); \
131} while (0)
132
133#define __arch_local_irq_save(flags) \
134do { \
135 unsigned long npsr; \
136 typecheck(unsigned long, flags); \
137 asm volatile(" movsg psr,%0 \n" \
138 " andi %0,%3,%1 \n" \
139 " ori %1,%2,%1 \n" \
140 " movgs %1,psr \n" \
141 : "=r"(flags), "=r"(npsr) \
142 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
143 : "memory"); \
144} while (0)
145
146#define __arch_local_irq_restore(flags) \
147do { \
148 typecheck(unsigned long, flags); \
149 asm volatile(" movgs %0,psr \n" \
150 : \
151 : "r" (flags) \
152 : "memory"); \
153} while (0)
154
155#define __arch_irqs_disabled() \
156 ((__get_PSR() & PSR_PIL) >= PSR_PIL_14)
157
158#endif /* _ASM_IRQFLAGS_H */
diff --git a/arch/frv/include/asm/system.h b/arch/frv/include/asm/system.h
index efd22d9077ac..0a6d8d9ca45b 100644
--- a/arch/frv/include/asm/system.h
+++ b/arch/frv/include/asm/system.h
@@ -37,142 +37,6 @@ do { \
37} while(0) 37} while(0)
38 38
39/* 39/*
40 * interrupt flag manipulation
41 * - use virtual interrupt management since touching the PSR is slow
42 * - ICC2.Z: T if interrupts virtually disabled
43 * - ICC2.C: F if interrupts really disabled
44 * - if Z==1 upon interrupt:
45 * - C is set to 0
46 * - interrupts are really disabled
47 * - entry.S returns immediately
48 * - uses TIHI (TRAP if Z==0 && C==0) #2 to really reenable interrupts
49 * - if taken, the trap:
50 * - sets ICC2.C
51 * - enables interrupts
52 */
53#define local_irq_disable() \
54do { \
55 /* set Z flag, but don't change the C flag */ \
56 asm volatile(" andcc gr0,gr0,gr0,icc2 \n" \
57 : \
58 : \
59 : "memory", "icc2" \
60 ); \
61} while(0)
62
63#define local_irq_enable() \
64do { \
65 /* clear Z flag and then test the C flag */ \
66 asm volatile(" oricc gr0,#1,gr0,icc2 \n" \
67 " tihi icc2,gr0,#2 \n" \
68 : \
69 : \
70 : "memory", "icc2" \
71 ); \
72} while(0)
73
74#define local_save_flags(flags) \
75do { \
76 typecheck(unsigned long, flags); \
77 asm volatile("movsg ccr,%0" \
78 : "=r"(flags) \
79 : \
80 : "memory"); \
81 \
82 /* shift ICC2.Z to bit 0 */ \
83 flags >>= 26; \
84 \
85 /* make flags 1 if interrupts disabled, 0 otherwise */ \
86 flags &= 1UL; \
87} while(0)
88
89#define irqs_disabled() \
90 ({unsigned long flags; local_save_flags(flags); !!flags; })
91
92#define local_irq_save(flags) \
93do { \
94 typecheck(unsigned long, flags); \
95 local_save_flags(flags); \
96 local_irq_disable(); \
97} while(0)
98
99#define local_irq_restore(flags) \
100do { \
101 typecheck(unsigned long, flags); \
102 \
103 /* load the Z flag by turning 1 if disabled into 0 if disabled \
104 * and thus setting the Z flag but not the C flag */ \
105 asm volatile(" xoricc %0,#1,gr0,icc2 \n" \
106 /* then test Z=0 and C=0 */ \
107 " tihi icc2,gr0,#2 \n" \
108 : \
109 : "r"(flags) \
110 : "memory", "icc2" \
111 ); \
112 \
113} while(0)
114
115/*
116 * real interrupt flag manipulation
117 */
118#define __local_irq_disable() \
119do { \
120 unsigned long psr; \
121 asm volatile(" movsg psr,%0 \n" \
122 " andi %0,%2,%0 \n" \
123 " ori %0,%1,%0 \n" \
124 " movgs %0,psr \n" \
125 : "=r"(psr) \
126 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
127 : "memory"); \
128} while(0)
129
130#define __local_irq_enable() \
131do { \
132 unsigned long psr; \
133 asm volatile(" movsg psr,%0 \n" \
134 " andi %0,%1,%0 \n" \
135 " movgs %0,psr \n" \
136 : "=r"(psr) \
137 : "i" (~PSR_PIL) \
138 : "memory"); \
139} while(0)
140
141#define __local_save_flags(flags) \
142do { \
143 typecheck(unsigned long, flags); \
144 asm("movsg psr,%0" \
145 : "=r"(flags) \
146 : \
147 : "memory"); \
148} while(0)
149
150#define __local_irq_save(flags) \
151do { \
152 unsigned long npsr; \
153 typecheck(unsigned long, flags); \
154 asm volatile(" movsg psr,%0 \n" \
155 " andi %0,%3,%1 \n" \
156 " ori %1,%2,%1 \n" \
157 " movgs %1,psr \n" \
158 : "=r"(flags), "=r"(npsr) \
159 : "i" (PSR_PIL_14), "i" (~PSR_PIL) \
160 : "memory"); \
161} while(0)
162
163#define __local_irq_restore(flags) \
164do { \
165 typecheck(unsigned long, flags); \
166 asm volatile(" movgs %0,psr \n" \
167 : \
168 : "r" (flags) \
169 : "memory"); \
170} while(0)
171
172#define __irqs_disabled() \
173 ((__get_PSR() & PSR_PIL) >= PSR_PIL_14)
174
175/*
176 * Force strict CPU ordering. 40 * Force strict CPU ordering.
177 */ 41 */
178#define nop() asm volatile ("nop"::) 42#define nop() asm volatile ("nop"::)
diff --git a/arch/frv/lib/Makefile b/arch/frv/lib/Makefile
index f4709756d0d9..4ff2fb1e6b16 100644
--- a/arch/frv/lib/Makefile
+++ b/arch/frv/lib/Makefile
@@ -5,4 +5,4 @@
5lib-y := \ 5lib-y := \
6 __ashldi3.o __lshrdi3.o __muldi3.o __ashrdi3.o __negdi2.o __ucmpdi2.o \ 6 __ashldi3.o __lshrdi3.o __muldi3.o __ashrdi3.o __negdi2.o __ucmpdi2.o \
7 checksum.o memcpy.o memset.o atomic-ops.o atomic64-ops.o \ 7 checksum.o memcpy.o memset.o atomic-ops.o atomic64-ops.o \
8 outsl_ns.o outsl_sw.o insl_ns.o insl_sw.o cache.o perf_event.o 8 outsl_ns.o outsl_sw.o insl_ns.o insl_sw.o cache.o
diff --git a/arch/frv/lib/perf_event.c b/arch/frv/lib/perf_event.c
deleted file mode 100644
index 9ac5acfd2e91..000000000000
--- a/arch/frv/lib/perf_event.c
+++ /dev/null
@@ -1,19 +0,0 @@
1/* Performance event handling
2 *
3 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#include <linux/perf_event.h>
13
14/*
15 * mark the performance event as pending
16 */
17void set_perf_event_pending(void)
18{
19}
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu
index 6e2ecff199c5..d236ab4232ca 100644
--- a/arch/h8300/Kconfig.cpu
+++ b/arch/h8300/Kconfig.cpu
@@ -17,7 +17,7 @@ config H8300H_AKI3068NET
17 help 17 help
18 AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support 18 AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support
19 More Information. (Japanese Only) 19 More Information. (Japanese Only)
20 <http://akizukidensi.com/catalog/h8.html> 20 <http://akizukidenshi.com/catalog/default.aspx>
21 AE-3068/69 Evaluation Board Support 21 AE-3068/69 Evaluation Board Support
22 More Information. 22 More Information.
23 <http://www.microtronique.com/ae3069lan.htm> 23 <http://www.microtronique.com/ae3069lan.htm>
@@ -36,7 +36,7 @@ config H8300H_SIM
36 help 36 help
37 GDB Simulator Support 37 GDB Simulator Support
38 More Information. 38 More Information.
39 arch/h8300/Doc/simulator.txt 39 <http://sourceware.org/sid/>
40 40
41config H8S_GENERIC 41config H8S_GENERIC
42 bool "H8S Generic" 42 bool "H8S Generic"
@@ -50,14 +50,14 @@ config H8S_EDOSK2674
50 Renesas EDOSK-2674 Evaluation Board Support 50 Renesas EDOSK-2674 Evaluation Board Support
51 More Information. 51 More Information.
52 <http://www.azpower.com/H8-uClinux/index.html> 52 <http://www.azpower.com/H8-uClinux/index.html>
53 <http://www.eu.renesas.com/tools/edk/support/edosk2674.html> 53 <http://www.renesas.eu/products/tools/introductory_evaluation_tools/evaluation_development_os_kits/edosk2674r/edosk2674r_software_tools_root.jsp>
54 54
55config H8S_SIM 55config H8S_SIM
56 bool "H8S Simulator" 56 bool "H8S Simulator"
57 help 57 help
58 GDB Simulator Support 58 GDB Simulator Support
59 More Information. 59 More Information.
60 arch/h8300/Doc/simulator.txt 60 <http://sourceware.org/sid/>
61 61
62endchoice 62endchoice
63 63
diff --git a/arch/h8300/README b/arch/h8300/README
index 2fd6f6d7a019..637f5a02f311 100644
--- a/arch/h8300/README
+++ b/arch/h8300/README
@@ -18,6 +18,7 @@ H8/300H and H8S
18 18
194.EDOSK2674 194.EDOSK2674
20 see http://www.eu.renesas.com/products/mpumcu/tool/edk/support/edosk2674.html 20 see http://www.eu.renesas.com/products/mpumcu/tool/edk/support/edosk2674.html
21 http://www.uclinux.org/pub/uClinux/ports/h8/HITACHI-EDOSK2674-HOWTO
21 http://www.azpower.com/H8-uClinux/ 22 http://www.azpower.com/H8-uClinux/
22 23
23* Toolchain Version 24* Toolchain Version
diff --git a/arch/h8300/include/asm/ioctls.h b/arch/h8300/include/asm/ioctls.h
index b6b249f9f308..30eaed2facdb 100644
--- a/arch/h8300/include/asm/ioctls.h
+++ b/arch/h8300/include/asm/ioctls.h
@@ -1,87 +1,8 @@
1#ifndef __ARCH_H8300_IOCTLS_H__ 1#ifndef __ARCH_H8300_IOCTLS_H__
2#define __ARCH_H8300_IOCTLS_H__ 2#define __ARCH_H8300_IOCTLS_H__
3 3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
57
58#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
59#define FIOCLEX 0x5451
60#define FIOASYNC 0x5452
61#define TIOCSERCONFIG 0x5453
62#define TIOCSERGWILD 0x5454
63#define TIOCSERSWILD 0x5455
64#define TIOCGLCKTRMIOS 0x5456
65#define TIOCSLCKTRMIOS 0x5457
66#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
67#define TIOCSERGETLSR 0x5459 /* Get line status register */
68#define TIOCSERGETMULTI 0x545A /* Get multiport config */
69#define TIOCSERSETMULTI 0x545B /* Set multiport config */
70
71#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
72#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
73#define FIOQSIZE 0x545E 4#define FIOQSIZE 0x545E
74 5
75/* Used for packet mode */ 6#include <asm-generic/ioctls.h>
76#define TIOCPKT_DATA 0
77#define TIOCPKT_FLUSHREAD 1
78#define TIOCPKT_FLUSHWRITE 2
79#define TIOCPKT_STOP 4
80#define TIOCPKT_START 8
81#define TIOCPKT_NOSTOP 16
82#define TIOCPKT_DOSTOP 32
83#define TIOCPKT_IOCTL 64
84
85#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
86 7
87#endif /* __ARCH_H8300_IOCTLS_H__ */ 8#endif /* __ARCH_H8300_IOCTLS_H__ */
diff --git a/arch/h8300/include/asm/irqflags.h b/arch/h8300/include/asm/irqflags.h
new file mode 100644
index 000000000000..9617cd57aebd
--- /dev/null
+++ b/arch/h8300/include/asm/irqflags.h
@@ -0,0 +1,43 @@
1#ifndef _H8300_IRQFLAGS_H
2#define _H8300_IRQFLAGS_H
3
4static inline unsigned long arch_local_save_flags(void)
5{
6 unsigned long flags;
7 asm volatile ("stc ccr,%w0" : "=r" (flags));
8 return flags;
9}
10
11static inline void arch_local_irq_disable(void)
12{
13 asm volatile ("orc #0x80,ccr" : : : "memory");
14}
15
16static inline void arch_local_irq_enable(void)
17{
18 asm volatile ("andc #0x7f,ccr" : : : "memory");
19}
20
21static inline unsigned long arch_local_irq_save(void)
22{
23 unsigned long flags = arch_local_save_flags();
24 arch_local_irq_disable();
25 return flags;
26}
27
28static inline void arch_local_irq_restore(unsigned long flags)
29{
30 asm volatile ("ldc %w0,ccr" : : "r" (flags) : "memory");
31}
32
33static inline bool arch_irqs_disabled_flags(unsigned long flags)
34{
35 return (flags & 0x80) == 0x80;
36}
37
38static inline bool arch_irqs_disabled(void)
39{
40 return arch_irqs_disabled_flags(arch_local_save_flags());
41}
42
43#endif /* _H8300_IRQFLAGS_H */
diff --git a/arch/h8300/include/asm/system.h b/arch/h8300/include/asm/system.h
index 16bf1560ff68..2c2382e50d93 100644
--- a/arch/h8300/include/asm/system.h
+++ b/arch/h8300/include/asm/system.h
@@ -2,6 +2,7 @@
2#define _H8300_SYSTEM_H 2#define _H8300_SYSTEM_H
3 3
4#include <linux/linkage.h> 4#include <linux/linkage.h>
5#include <linux/irqflags.h>
5 6
6struct pt_regs; 7struct pt_regs;
7 8
@@ -51,31 +52,8 @@ asmlinkage void resume(void);
51 (last) = _last; \ 52 (last) = _last; \
52} 53}
53 54
54#define __sti() asm volatile ("andc #0x7f,ccr")
55#define __cli() asm volatile ("orc #0x80,ccr")
56
57#define __save_flags(x) \
58 asm volatile ("stc ccr,%w0":"=r" (x))
59
60#define __restore_flags(x) \
61 asm volatile ("ldc %w0,ccr": :"r" (x))
62
63#define irqs_disabled() \
64({ \
65 unsigned char flags; \
66 __save_flags(flags); \
67 ((flags & 0x80) == 0x80); \
68})
69
70#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc") 55#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")
71 56
72/* For spinlocks etc */
73#define local_irq_disable() __cli()
74#define local_irq_enable() __sti()
75#define local_irq_save(x) ({ __save_flags(x); local_irq_disable(); })
76#define local_irq_restore(x) __restore_flags(x)
77#define local_save_flags(x) __save_flags(x)
78
79/* 57/*
80 * Force strict CPU ordering. 58 * Force strict CPU ordering.
81 * Not really required on H8... 59 * Not really required on H8...
diff --git a/arch/h8300/kernel/module.c b/arch/h8300/kernel/module.c
index 0865e291c20d..db4953dc4e1b 100644
--- a/arch/h8300/kernel/module.c
+++ b/arch/h8300/kernel/module.c
@@ -112,10 +112,9 @@ int module_finalize(const Elf_Ehdr *hdr,
112 const Elf_Shdr *sechdrs, 112 const Elf_Shdr *sechdrs,
113 struct module *me) 113 struct module *me)
114{ 114{
115 return module_bug_finalize(hdr, sechdrs, me); 115 return 0;
116} 116}
117 117
118void module_arch_cleanup(struct module *mod) 118void module_arch_cleanup(struct module *mod)
119{ 119{
120 module_bug_cleanup(mod);
121} 120}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index ba22849ee3ec..7c82fa1fc911 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -53,6 +53,9 @@ config MMU
53 bool 53 bool
54 default y 54 default y
55 55
56config ARCH_DMA_ADDR_T_64BIT
57 def_bool y
58
56config NEED_DMA_MAP_STATE 59config NEED_DMA_MAP_STATE
57 def_bool y 60 def_bool y
58 61
@@ -62,6 +65,9 @@ config NEED_SG_DMA_LENGTH
62config SWIOTLB 65config SWIOTLB
63 bool 66 bool
64 67
68config STACKTRACE_SUPPORT
69 def_bool y
70
65config GENERIC_LOCKBREAK 71config GENERIC_LOCKBREAK
66 def_bool n 72 def_bool n
67 73
@@ -683,8 +689,10 @@ source "lib/Kconfig"
683# Use the generic interrupt handling code in kernel/irq/: 689# Use the generic interrupt handling code in kernel/irq/:
684# 690#
685config GENERIC_HARDIRQS 691config GENERIC_HARDIRQS
686 bool 692 def_bool y
687 default y 693
694config GENERIC_HARDIRQS_NO__DO_IRQ
695 def_bool y
688 696
689config GENERIC_IRQ_PROBE 697config GENERIC_IRQ_PROBE
690 bool 698 bool
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 1e8d71ad93ef..13633da0d3de 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -395,7 +395,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
395{ 395{
396 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 396 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
397 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && 397 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
398 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 398 (cmd != TIOCMIWAIT)) {
399 if (tty->flags & (1 << TTY_IO_ERROR)) 399 if (tty->flags & (1 << TTY_IO_ERROR))
400 return -EIO; 400 return -EIO;
401 } 401 }
@@ -433,16 +433,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
433 case TIOCMIWAIT: 433 case TIOCMIWAIT:
434 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n"); 434 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n");
435 return 0; 435 return 0;
436 /*
437 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
438 * Return: write counters to the user passed counter struct
439 * NB: both 1->0 and 0->1 transitions are counted except for
440 * RI where only 0->1 is counted.
441 */
442 case TIOCGICOUNT:
443 printk(KERN_INFO "rs_ioctl: TIOCGICOUNT called\n");
444 return 0;
445
446 case TIOCSERGWILD: 436 case TIOCSERGWILD:
447 case TIOCSERSWILD: 437 case TIOCSERSWILD:
448 /* "setserial -W" is called in Debian boot */ 438 /* "setserial -W" is called in Debian boot */
diff --git a/arch/ia64/include/asm/compat.h b/arch/ia64/include/asm/compat.h
deleted file mode 100644
index 9301a2821615..000000000000
--- a/arch/ia64/include/asm/compat.h
+++ /dev/null
@@ -1,208 +0,0 @@
1#ifndef _ASM_IA64_COMPAT_H
2#define _ASM_IA64_COMPAT_H
3/*
4 * Architecture specific compatibility types
5 */
6#include <linux/types.h>
7
8#define COMPAT_USER_HZ 100
9#define COMPAT_UTS_MACHINE "i686\0\0\0"
10
11typedef u32 compat_size_t;
12typedef s32 compat_ssize_t;
13typedef s32 compat_time_t;
14typedef s32 compat_clock_t;
15typedef s32 compat_key_t;
16typedef s32 compat_pid_t;
17typedef u16 __compat_uid_t;
18typedef u16 __compat_gid_t;
19typedef u32 __compat_uid32_t;
20typedef u32 __compat_gid32_t;
21typedef u16 compat_mode_t;
22typedef u32 compat_ino_t;
23typedef u16 compat_dev_t;
24typedef s32 compat_off_t;
25typedef s64 compat_loff_t;
26typedef u16 compat_nlink_t;
27typedef u16 compat_ipc_pid_t;
28typedef s32 compat_daddr_t;
29typedef u32 compat_caddr_t;
30typedef __kernel_fsid_t compat_fsid_t;
31typedef s32 compat_timer_t;
32
33typedef s32 compat_int_t;
34typedef s32 compat_long_t;
35typedef s64 __attribute__((aligned(4))) compat_s64;
36typedef u32 compat_uint_t;
37typedef u32 compat_ulong_t;
38typedef u64 __attribute__((aligned(4))) compat_u64;
39
40struct compat_timespec {
41 compat_time_t tv_sec;
42 s32 tv_nsec;
43};
44
45struct compat_timeval {
46 compat_time_t tv_sec;
47 s32 tv_usec;
48};
49
50struct compat_stat {
51 compat_dev_t st_dev;
52 u16 __pad1;
53 compat_ino_t st_ino;
54 compat_mode_t st_mode;
55 compat_nlink_t st_nlink;
56 __compat_uid_t st_uid;
57 __compat_gid_t st_gid;
58 compat_dev_t st_rdev;
59 u16 __pad2;
60 u32 st_size;
61 u32 st_blksize;
62 u32 st_blocks;
63 u32 st_atime;
64 u32 st_atime_nsec;
65 u32 st_mtime;
66 u32 st_mtime_nsec;
67 u32 st_ctime;
68 u32 st_ctime_nsec;
69 u32 __unused4;
70 u32 __unused5;
71};
72
73struct compat_flock {
74 short l_type;
75 short l_whence;
76 compat_off_t l_start;
77 compat_off_t l_len;
78 compat_pid_t l_pid;
79};
80
81#define F_GETLK64 12
82#define F_SETLK64 13
83#define F_SETLKW64 14
84
85/*
86 * IA32 uses 4 byte alignment for 64 bit quantities,
87 * so we need to pack this structure.
88 */
89struct compat_flock64 {
90 short l_type;
91 short l_whence;
92 compat_loff_t l_start;
93 compat_loff_t l_len;
94 compat_pid_t l_pid;
95} __attribute__((packed));
96
97struct compat_statfs {
98 int f_type;
99 int f_bsize;
100 int f_blocks;
101 int f_bfree;
102 int f_bavail;
103 int f_files;
104 int f_ffree;
105 compat_fsid_t f_fsid;
106 int f_namelen; /* SunOS ignores this field. */
107 int f_frsize;
108 int f_spare[5];
109};
110
111#define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
112#define COMPAT_RLIM_INFINITY 0xffffffff
113
114typedef u32 compat_old_sigset_t; /* at least 32 bits */
115
116#define _COMPAT_NSIG 64
117#define _COMPAT_NSIG_BPW 32
118
119typedef u32 compat_sigset_word;
120
121#define COMPAT_OFF_T_MAX 0x7fffffff
122#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
123
124struct compat_ipc64_perm {
125 compat_key_t key;
126 __compat_uid32_t uid;
127 __compat_gid32_t gid;
128 __compat_uid32_t cuid;
129 __compat_gid32_t cgid;
130 unsigned short mode;
131 unsigned short __pad1;
132 unsigned short seq;
133 unsigned short __pad2;
134 compat_ulong_t unused1;
135 compat_ulong_t unused2;
136};
137
138struct compat_semid64_ds {
139 struct compat_ipc64_perm sem_perm;
140 compat_time_t sem_otime;
141 compat_ulong_t __unused1;
142 compat_time_t sem_ctime;
143 compat_ulong_t __unused2;
144 compat_ulong_t sem_nsems;
145 compat_ulong_t __unused3;
146 compat_ulong_t __unused4;
147};
148
149struct compat_msqid64_ds {
150 struct compat_ipc64_perm msg_perm;
151 compat_time_t msg_stime;
152 compat_ulong_t __unused1;
153 compat_time_t msg_rtime;
154 compat_ulong_t __unused2;
155 compat_time_t msg_ctime;
156 compat_ulong_t __unused3;
157 compat_ulong_t msg_cbytes;
158 compat_ulong_t msg_qnum;
159 compat_ulong_t msg_qbytes;
160 compat_pid_t msg_lspid;
161 compat_pid_t msg_lrpid;
162 compat_ulong_t __unused4;
163 compat_ulong_t __unused5;
164};
165
166struct compat_shmid64_ds {
167 struct compat_ipc64_perm shm_perm;
168 compat_size_t shm_segsz;
169 compat_time_t shm_atime;
170 compat_ulong_t __unused1;
171 compat_time_t shm_dtime;
172 compat_ulong_t __unused2;
173 compat_time_t shm_ctime;
174 compat_ulong_t __unused3;
175 compat_pid_t shm_cpid;
176 compat_pid_t shm_lpid;
177 compat_ulong_t shm_nattch;
178 compat_ulong_t __unused4;
179 compat_ulong_t __unused5;
180};
181
182/*
183 * A pointer passed in from user mode. This should not be used for syscall parameters,
184 * just declare them as pointers because the syscall entry code will have appropriately
185 * converted them already.
186 */
187typedef u32 compat_uptr_t;
188
189static inline void __user *
190compat_ptr (compat_uptr_t uptr)
191{
192 return (void __user *) (unsigned long) uptr;
193}
194
195static inline compat_uptr_t
196ptr_to_compat(void __user *uptr)
197{
198 return (u32)(unsigned long)uptr;
199}
200
201static __inline__ void __user *
202arch_compat_alloc_user_space (long len)
203{
204 struct pt_regs *regs = task_pt_regs(current);
205 return (void __user *) (((regs->r12 & 0xffffffff) & -16) - len);
206}
207
208#endif /* _ASM_IA64_COMPAT_H */
diff --git a/arch/ia64/include/asm/hardirq.h b/arch/ia64/include/asm/hardirq.h
index d514cd9edb49..8fb7d33a661f 100644
--- a/arch/ia64/include/asm/hardirq.h
+++ b/arch/ia64/include/asm/hardirq.h
@@ -6,12 +6,6 @@
6 * David Mosberger-Tang <davidm@hpl.hp.com> 6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */ 7 */
8 8
9
10#include <linux/threads.h>
11#include <linux/irq.h>
12
13#include <asm/processor.h>
14
15/* 9/*
16 * No irq_cpustat_t for IA-64. The data is held in the per-CPU data structure. 10 * No irq_cpustat_t for IA-64. The data is held in the per-CPU data structure.
17 */ 11 */
@@ -20,6 +14,11 @@
20 14
21#define local_softirq_pending() (local_cpu_data->softirq_pending) 15#define local_softirq_pending() (local_cpu_data->softirq_pending)
22 16
17#include <linux/threads.h>
18#include <linux/irq.h>
19
20#include <asm/processor.h>
21
23extern void __iomem *ipi_base_addr; 22extern void __iomem *ipi_base_addr;
24 23
25void ack_bad_irq(unsigned int irq); 24void ack_bad_irq(unsigned int irq);
diff --git a/arch/ia64/include/asm/ioctls.h b/arch/ia64/include/asm/ioctls.h
index b79c385114ef..f3aab5512e98 100644
--- a/arch/ia64/include/asm/ioctls.h
+++ b/arch/ia64/include/asm/ioctls.h
@@ -1,93 +1,6 @@
1#ifndef _ASM_IA64_IOCTLS_H 1#ifndef _ASM_IA64_IOCTLS_H
2#define _ASM_IA64_IOCTLS_H 2#define _ASM_IA64_IOCTLS_H
3 3
4/* 4#include <asm-generic/ioctls.h>
5 * Based on <asm-i386/ioctls.h>
6 *
7 * Modified 1998, 1999, 2002
8 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
9 */
10
11#include <asm/ioctl.h>
12
13/* 0x54 is just a magic number to make these relatively unique ('T') */
14
15#define TCGETS 0x5401
16#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
17#define TCSETSW 0x5403
18#define TCSETSF 0x5404
19#define TCGETA 0x5405
20#define TCSETA 0x5406
21#define TCSETAW 0x5407
22#define TCSETAF 0x5408
23#define TCSBRK 0x5409
24#define TCXONC 0x540A
25#define TCFLSH 0x540B
26#define TIOCEXCL 0x540C
27#define TIOCNXCL 0x540D
28#define TIOCSCTTY 0x540E
29#define TIOCGPGRP 0x540F
30#define TIOCSPGRP 0x5410
31#define TIOCOUTQ 0x5411
32#define TIOCSTI 0x5412
33#define TIOCGWINSZ 0x5413
34#define TIOCSWINSZ 0x5414
35#define TIOCMGET 0x5415
36#define TIOCMBIS 0x5416
37#define TIOCMBIC 0x5417
38#define TIOCMSET 0x5418
39#define TIOCGSOFTCAR 0x5419
40#define TIOCSSOFTCAR 0x541A
41#define FIONREAD 0x541B
42#define TIOCINQ FIONREAD
43#define TIOCLINUX 0x541C
44#define TIOCCONS 0x541D
45#define TIOCGSERIAL 0x541E
46#define TIOCSSERIAL 0x541F
47#define TIOCPKT 0x5420
48#define FIONBIO 0x5421
49#define TIOCNOTTY 0x5422
50#define TIOCSETD 0x5423
51#define TIOCGETD 0x5424
52#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
53#define TIOCSBRK 0x5427 /* BSD compatibility */
54#define TIOCCBRK 0x5428 /* BSD compatibility */
55#define TIOCGSID 0x5429 /* Return the session ID of FD */
56#define TCGETS2 _IOR('T',0x2A, struct termios2)
57#define TCSETS2 _IOW('T',0x2B, struct termios2)
58#define TCSETSW2 _IOW('T',0x2C, struct termios2)
59#define TCSETSF2 _IOW('T',0x2D, struct termios2)
60#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
61#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
62#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
63
64#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
65#define FIOCLEX 0x5451
66#define FIOASYNC 0x5452
67#define TIOCSERCONFIG 0x5453
68#define TIOCSERGWILD 0x5454
69#define TIOCSERSWILD 0x5455
70#define TIOCGLCKTRMIOS 0x5456
71#define TIOCSLCKTRMIOS 0x5457
72#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
73#define TIOCSERGETLSR 0x5459 /* Get line status register */
74#define TIOCSERGETMULTI 0x545A /* Get multiport config */
75#define TIOCSERSETMULTI 0x545B /* Set multiport config */
76
77#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
78#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
79#define FIOQSIZE 0x5460
80
81/* Used for packet mode */
82#define TIOCPKT_DATA 0
83#define TIOCPKT_FLUSHREAD 1
84#define TIOCPKT_FLUSHWRITE 2
85#define TIOCPKT_STOP 4
86#define TIOCPKT_START 8
87#define TIOCPKT_NOSTOP 16
88#define TIOCPKT_DOSTOP 32
89#define TIOCPKT_IOCTL 64
90
91#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
92 5
93#endif /* _ASM_IA64_IOCTLS_H */ 6#endif /* _ASM_IA64_IOCTLS_H */
diff --git a/arch/ia64/include/asm/iommu_table.h b/arch/ia64/include/asm/iommu_table.h
new file mode 100644
index 000000000000..92c8d36ae5ae
--- /dev/null
+++ b/arch/ia64/include/asm/iommu_table.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_IA64_IOMMU_TABLE_H
2#define _ASM_IA64_IOMMU_TABLE_H
3
4#define IOMMU_INIT_POST(_detect)
5
6#endif /* _ASM_IA64_IOMMU_TABLE_H */
diff --git a/arch/ia64/include/asm/irqflags.h b/arch/ia64/include/asm/irqflags.h
new file mode 100644
index 000000000000..f82d6be2ecd2
--- /dev/null
+++ b/arch/ia64/include/asm/irqflags.h
@@ -0,0 +1,94 @@
1/*
2 * IRQ flags defines.
3 *
4 * Copyright (C) 1998-2003 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
7 * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
8 */
9
10#ifndef _ASM_IA64_IRQFLAGS_H
11#define _ASM_IA64_IRQFLAGS_H
12
13#ifdef CONFIG_IA64_DEBUG_IRQ
14extern unsigned long last_cli_ip;
15static inline void arch_maybe_save_ip(unsigned long flags)
16{
17 if (flags & IA64_PSR_I)
18 last_cli_ip = ia64_getreg(_IA64_REG_IP);
19}
20#else
21#define arch_maybe_save_ip(flags) do {} while (0)
22#endif
23
24/*
25 * - clearing psr.i is implicitly serialized (visible by next insn)
26 * - setting psr.i requires data serialization
27 * - we need a stop-bit before reading PSR because we sometimes
28 * write a floating-point register right before reading the PSR
29 * and that writes to PSR.mfl
30 */
31
32static inline unsigned long arch_local_save_flags(void)
33{
34 ia64_stop();
35#ifdef CONFIG_PARAVIRT
36 return ia64_get_psr_i();
37#else
38 return ia64_getreg(_IA64_REG_PSR);
39#endif
40}
41
42static inline unsigned long arch_local_irq_save(void)
43{
44 unsigned long flags = arch_local_save_flags();
45
46 ia64_stop();
47 ia64_rsm(IA64_PSR_I);
48 arch_maybe_save_ip(flags);
49 return flags;
50}
51
52static inline void arch_local_irq_disable(void)
53{
54#ifdef CONFIG_IA64_DEBUG_IRQ
55 arch_local_irq_save();
56#else
57 ia64_stop();
58 ia64_rsm(IA64_PSR_I);
59#endif
60}
61
62static inline void arch_local_irq_enable(void)
63{
64 ia64_stop();
65 ia64_ssm(IA64_PSR_I);
66 ia64_srlz_d();
67}
68
69static inline void arch_local_irq_restore(unsigned long flags)
70{
71#ifdef CONFIG_IA64_DEBUG_IRQ
72 unsigned long old_psr = arch_local_save_flags();
73#endif
74 ia64_intrin_local_irq_restore(flags & IA64_PSR_I);
75 arch_maybe_save_ip(old_psr & ~flags);
76}
77
78static inline bool arch_irqs_disabled_flags(unsigned long flags)
79{
80 return (flags & IA64_PSR_I) == 0;
81}
82
83static inline bool arch_irqs_disabled(void)
84{
85 return arch_irqs_disabled_flags(arch_local_save_flags());
86}
87
88static inline void arch_safe_halt(void)
89{
90 ia64_pal_halt_light(); /* PAL_HALT_LIGHT */
91}
92
93
94#endif /* _ASM_IA64_IRQFLAGS_H */
diff --git a/arch/ia64/include/asm/system.h b/arch/ia64/include/asm/system.h
index 9f342a574ce8..6cca30705d50 100644
--- a/arch/ia64/include/asm/system.h
+++ b/arch/ia64/include/asm/system.h
@@ -107,87 +107,11 @@ extern struct ia64_boot_param {
107 */ 107 */
108#define set_mb(var, value) do { (var) = (value); mb(); } while (0) 108#define set_mb(var, value) do { (var) = (value); mb(); } while (0)
109 109
110#define safe_halt() ia64_pal_halt_light() /* PAL_HALT_LIGHT */
111
112/* 110/*
113 * The group barrier in front of the rsm & ssm are necessary to ensure 111 * The group barrier in front of the rsm & ssm are necessary to ensure
114 * that none of the previous instructions in the same group are 112 * that none of the previous instructions in the same group are
115 * affected by the rsm/ssm. 113 * affected by the rsm/ssm.
116 */ 114 */
117/* For spinlocks etc */
118
119/*
120 * - clearing psr.i is implicitly serialized (visible by next insn)
121 * - setting psr.i requires data serialization
122 * - we need a stop-bit before reading PSR because we sometimes
123 * write a floating-point register right before reading the PSR
124 * and that writes to PSR.mfl
125 */
126#ifdef CONFIG_PARAVIRT
127#define __local_save_flags() ia64_get_psr_i()
128#else
129#define __local_save_flags() ia64_getreg(_IA64_REG_PSR)
130#endif
131
132#define __local_irq_save(x) \
133do { \
134 ia64_stop(); \
135 (x) = __local_save_flags(); \
136 ia64_stop(); \
137 ia64_rsm(IA64_PSR_I); \
138} while (0)
139
140#define __local_irq_disable() \
141do { \
142 ia64_stop(); \
143 ia64_rsm(IA64_PSR_I); \
144} while (0)
145
146#define __local_irq_restore(x) ia64_intrin_local_irq_restore((x) & IA64_PSR_I)
147
148#ifdef CONFIG_IA64_DEBUG_IRQ
149
150 extern unsigned long last_cli_ip;
151
152# define __save_ip() last_cli_ip = ia64_getreg(_IA64_REG_IP)
153
154# define local_irq_save(x) \
155do { \
156 unsigned long __psr; \
157 \
158 __local_irq_save(__psr); \
159 if (__psr & IA64_PSR_I) \
160 __save_ip(); \
161 (x) = __psr; \
162} while (0)
163
164# define local_irq_disable() do { unsigned long __x; local_irq_save(__x); } while (0)
165
166# define local_irq_restore(x) \
167do { \
168 unsigned long __old_psr, __psr = (x); \
169 \
170 local_save_flags(__old_psr); \
171 __local_irq_restore(__psr); \
172 if ((__old_psr & IA64_PSR_I) && !(__psr & IA64_PSR_I)) \
173 __save_ip(); \
174} while (0)
175
176#else /* !CONFIG_IA64_DEBUG_IRQ */
177# define local_irq_save(x) __local_irq_save(x)
178# define local_irq_disable() __local_irq_disable()
179# define local_irq_restore(x) __local_irq_restore(x)
180#endif /* !CONFIG_IA64_DEBUG_IRQ */
181
182#define local_irq_enable() ({ ia64_stop(); ia64_ssm(IA64_PSR_I); ia64_srlz_d(); })
183#define local_save_flags(flags) ({ ia64_stop(); (flags) = __local_save_flags(); })
184
185#define irqs_disabled() \
186({ \
187 unsigned long __ia64_id_flags; \
188 local_save_flags(__ia64_id_flags); \
189 (__ia64_id_flags & IA64_PSR_I) == 0; \
190})
191 115
192#ifdef __KERNEL__ 116#ifdef __KERNEL__
193 117
@@ -272,10 +196,6 @@ void cpu_idle_wait(void);
272 196
273void default_idle(void); 197void default_idle(void);
274 198
275#ifdef CONFIG_VIRT_CPU_ACCOUNTING
276extern void account_system_vtime(struct task_struct *);
277#endif
278
279#endif /* __KERNEL__ */ 199#endif /* __KERNEL__ */
280 200
281#endif /* __ASSEMBLY__ */ 201#endif /* __ASSEMBLY__ */
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index db10b1e378b0..395c2f216dd8 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_AUDIT) += audit.o
34obj-$(CONFIG_PCI_MSI) += msi_ia64.o 34obj-$(CONFIG_PCI_MSI) += msi_ia64.o
35mca_recovery-y += mca_drv.o mca_drv_asm.o 35mca_recovery-y += mca_drv.o mca_drv_asm.o
36obj-$(CONFIG_IA64_MC_ERR_INJECT)+= err_inject.o 36obj-$(CONFIG_IA64_MC_ERR_INJECT)+= err_inject.o
37obj-$(CONFIG_STACKTRACE) += stacktrace.o
37 38
38obj-$(CONFIG_PARAVIRT) += paravirt.o paravirtentry.o \ 39obj-$(CONFIG_PARAVIRT) += paravirt.o paravirtentry.o \
39 paravirt_patch.o 40 paravirt_patch.o
diff --git a/arch/ia64/kernel/cyclone.c b/arch/ia64/kernel/cyclone.c
index 71e35864d2e2..d52f1f78eff2 100644
--- a/arch/ia64/kernel/cyclone.c
+++ b/arch/ia64/kernel/cyclone.c
@@ -59,13 +59,13 @@ int __init init_cyclone_clock(void)
59 return -ENODEV; 59 return -ENODEV;
60 } 60 }
61 base = readq(reg); 61 base = readq(reg);
62 iounmap(reg);
62 if(!base){ 63 if(!base){
63 printk(KERN_ERR "Summit chipset: Could not find valid CBAR" 64 printk(KERN_ERR "Summit chipset: Could not find valid CBAR"
64 " value.\n"); 65 " value.\n");
65 use_cyclone = 0; 66 use_cyclone = 0;
66 return -ENODEV; 67 return -ENODEV;
67 } 68 }
68 iounmap(reg);
69 69
70 /* setup PMCC */ 70 /* setup PMCC */
71 offset = (base + CYCLONE_PMCC_OFFSET); 71 offset = (base + CYCLONE_PMCC_OFFSET);
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index 7ded76658d2d..22c38404f539 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -108,10 +108,6 @@
108#define DBG(fmt...) 108#define DBG(fmt...)
109#endif 109#endif
110 110
111#define NR_PREALLOCATE_RTE_ENTRIES \
112 (PAGE_SIZE / sizeof(struct iosapic_rte_info))
113#define RTE_PREALLOCATED (1)
114
115static DEFINE_SPINLOCK(iosapic_lock); 111static DEFINE_SPINLOCK(iosapic_lock);
116 112
117/* 113/*
@@ -136,7 +132,6 @@ struct iosapic_rte_info {
136 struct list_head rte_list; /* RTEs sharing the same vector */ 132 struct list_head rte_list; /* RTEs sharing the same vector */
137 char rte_index; /* IOSAPIC RTE index */ 133 char rte_index; /* IOSAPIC RTE index */
138 int refcnt; /* reference counter */ 134 int refcnt; /* reference counter */
139 unsigned int flags; /* flags */
140 struct iosapic *iosapic; 135 struct iosapic *iosapic;
141} ____cacheline_aligned; 136} ____cacheline_aligned;
142 137
@@ -155,9 +150,6 @@ static struct iosapic_intr_info {
155 150
156static unsigned char pcat_compat __devinitdata; /* 8259 compatibility flag */ 151static unsigned char pcat_compat __devinitdata; /* 8259 compatibility flag */
157 152
158static int iosapic_kmalloc_ok;
159static LIST_HEAD(free_rte_list);
160
161static inline void 153static inline void
162iosapic_write(struct iosapic *iosapic, unsigned int reg, u32 val) 154iosapic_write(struct iosapic *iosapic, unsigned int reg, u32 val)
163{ 155{
@@ -394,7 +386,7 @@ iosapic_startup_level_irq (unsigned int irq)
394} 386}
395 387
396static void 388static void
397iosapic_end_level_irq (unsigned int irq) 389iosapic_unmask_level_irq (unsigned int irq)
398{ 390{
399 ia64_vector vec = irq_to_vector(irq); 391 ia64_vector vec = irq_to_vector(irq);
400 struct iosapic_rte_info *rte; 392 struct iosapic_rte_info *rte;
@@ -404,7 +396,8 @@ iosapic_end_level_irq (unsigned int irq)
404 if (unlikely(irq_desc[irq].status & IRQ_MOVE_PENDING)) { 396 if (unlikely(irq_desc[irq].status & IRQ_MOVE_PENDING)) {
405 do_unmask_irq = 1; 397 do_unmask_irq = 1;
406 mask_irq(irq); 398 mask_irq(irq);
407 } 399 } else
400 unmask_irq(irq);
408 401
409 list_for_each_entry(rte, &iosapic_intr_info[irq].rtes, rte_list) 402 list_for_each_entry(rte, &iosapic_intr_info[irq].rtes, rte_list)
410 iosapic_eoi(rte->iosapic->addr, vec); 403 iosapic_eoi(rte->iosapic->addr, vec);
@@ -427,9 +420,8 @@ static struct irq_chip irq_type_iosapic_level = {
427 .enable = iosapic_enable_level_irq, 420 .enable = iosapic_enable_level_irq,
428 .disable = iosapic_disable_level_irq, 421 .disable = iosapic_disable_level_irq,
429 .ack = iosapic_ack_level_irq, 422 .ack = iosapic_ack_level_irq,
430 .end = iosapic_end_level_irq,
431 .mask = mask_irq, 423 .mask = mask_irq,
432 .unmask = unmask_irq, 424 .unmask = iosapic_unmask_level_irq,
433 .set_affinity = iosapic_set_affinity 425 .set_affinity = iosapic_set_affinity
434}; 426};
435 427
@@ -552,37 +544,6 @@ iosapic_reassign_vector (int irq)
552 } 544 }
553} 545}
554 546
555static struct iosapic_rte_info * __init_refok iosapic_alloc_rte (void)
556{
557 int i;
558 struct iosapic_rte_info *rte;
559 int preallocated = 0;
560
561 if (!iosapic_kmalloc_ok && list_empty(&free_rte_list)) {
562 rte = alloc_bootmem(sizeof(struct iosapic_rte_info) *
563 NR_PREALLOCATE_RTE_ENTRIES);
564 for (i = 0; i < NR_PREALLOCATE_RTE_ENTRIES; i++, rte++)
565 list_add(&rte->rte_list, &free_rte_list);
566 }
567
568 if (!list_empty(&free_rte_list)) {
569 rte = list_entry(free_rte_list.next, struct iosapic_rte_info,
570 rte_list);
571 list_del(&rte->rte_list);
572 preallocated++;
573 } else {
574 rte = kmalloc(sizeof(struct iosapic_rte_info), GFP_ATOMIC);
575 if (!rte)
576 return NULL;
577 }
578
579 memset(rte, 0, sizeof(struct iosapic_rte_info));
580 if (preallocated)
581 rte->flags |= RTE_PREALLOCATED;
582
583 return rte;
584}
585
586static inline int irq_is_shared (int irq) 547static inline int irq_is_shared (int irq)
587{ 548{
588 return (iosapic_intr_info[irq].count > 1); 549 return (iosapic_intr_info[irq].count > 1);
@@ -615,7 +576,7 @@ register_intr (unsigned int gsi, int irq, unsigned char delivery,
615 576
616 rte = find_rte(irq, gsi); 577 rte = find_rte(irq, gsi);
617 if (!rte) { 578 if (!rte) {
618 rte = iosapic_alloc_rte(); 579 rte = kzalloc(sizeof (*rte), GFP_ATOMIC);
619 if (!rte) { 580 if (!rte) {
620 printk(KERN_WARNING "%s: cannot allocate memory\n", 581 printk(KERN_WARNING "%s: cannot allocate memory\n",
621 __func__); 582 __func__);
@@ -658,6 +619,10 @@ register_intr (unsigned int gsi, int irq, unsigned char delivery,
658 idesc->chip->name, irq_type->name); 619 idesc->chip->name, irq_type->name);
659 idesc->chip = irq_type; 620 idesc->chip = irq_type;
660 } 621 }
622 if (trigger == IOSAPIC_EDGE)
623 __set_irq_handler_unlocked(irq, handle_edge_irq);
624 else
625 __set_irq_handler_unlocked(irq, handle_level_irq);
661 return 0; 626 return 0;
662} 627}
663 628
@@ -1161,10 +1126,3 @@ map_iosapic_to_node(unsigned int gsi_base, int node)
1161 return; 1126 return;
1162} 1127}
1163#endif 1128#endif
1164
1165static int __init iosapic_enable_kmalloc (void)
1166{
1167 iosapic_kmalloc_ok = 1;
1168 return 0;
1169}
1170core_initcall (iosapic_enable_kmalloc);
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index f14c35f9b03a..9a26015c3e50 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -30,6 +30,7 @@
30#include <linux/bitops.h> 30#include <linux/bitops.h>
31#include <linux/irq.h> 31#include <linux/irq.h>
32#include <linux/ratelimit.h> 32#include <linux/ratelimit.h>
33#include <linux/acpi.h>
33 34
34#include <asm/delay.h> 35#include <asm/delay.h>
35#include <asm/intrinsics.h> 36#include <asm/intrinsics.h>
@@ -635,6 +636,7 @@ ia64_native_register_percpu_irq (ia64_vector vec, struct irqaction *action)
635 desc->chip = &irq_type_ia64_lsapic; 636 desc->chip = &irq_type_ia64_lsapic;
636 if (action) 637 if (action)
637 setup_irq(irq, action); 638 setup_irq(irq, action);
639 set_irq_handler(irq, handle_percpu_irq);
638} 640}
639 641
640void __init 642void __init
@@ -650,6 +652,9 @@ ia64_native_register_ipi(void)
650void __init 652void __init
651init_IRQ (void) 653init_IRQ (void)
652{ 654{
655#ifdef CONFIG_ACPI
656 acpi_boot_init();
657#endif
653 ia64_register_ipi(); 658 ia64_register_ipi();
654 register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL); 659 register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
655#ifdef CONFIG_SMP 660#ifdef CONFIG_SMP
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index a0220dc5ff42..1753f6a30d55 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -2055,25 +2055,6 @@ ia64_mca_init(void)
2055 2055
2056 IA64_MCA_DEBUG("%s: registered OS INIT handler with SAL\n", __func__); 2056 IA64_MCA_DEBUG("%s: registered OS INIT handler with SAL\n", __func__);
2057 2057
2058 /*
2059 * Configure the CMCI/P vector and handler. Interrupts for CMC are
2060 * per-processor, so AP CMC interrupts are setup in smp_callin() (smpboot.c).
2061 */
2062 register_percpu_irq(IA64_CMC_VECTOR, &cmci_irqaction);
2063 register_percpu_irq(IA64_CMCP_VECTOR, &cmcp_irqaction);
2064 ia64_mca_cmc_vector_setup(); /* Setup vector on BSP */
2065
2066 /* Setup the MCA rendezvous interrupt vector */
2067 register_percpu_irq(IA64_MCA_RENDEZ_VECTOR, &mca_rdzv_irqaction);
2068
2069 /* Setup the MCA wakeup interrupt vector */
2070 register_percpu_irq(IA64_MCA_WAKEUP_VECTOR, &mca_wkup_irqaction);
2071
2072#ifdef CONFIG_ACPI
2073 /* Setup the CPEI/P handler */
2074 register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction);
2075#endif
2076
2077 /* Initialize the areas set aside by the OS to buffer the 2058 /* Initialize the areas set aside by the OS to buffer the
2078 * platform/processor error states for MCA/INIT/CMC 2059 * platform/processor error states for MCA/INIT/CMC
2079 * handling. 2060 * handling.
@@ -2103,6 +2084,25 @@ ia64_mca_late_init(void)
2103 if (!mca_init) 2084 if (!mca_init)
2104 return 0; 2085 return 0;
2105 2086
2087 /*
2088 * Configure the CMCI/P vector and handler. Interrupts for CMC are
2089 * per-processor, so AP CMC interrupts are setup in smp_callin() (smpboot.c).
2090 */
2091 register_percpu_irq(IA64_CMC_VECTOR, &cmci_irqaction);
2092 register_percpu_irq(IA64_CMCP_VECTOR, &cmcp_irqaction);
2093 ia64_mca_cmc_vector_setup(); /* Setup vector on BSP */
2094
2095 /* Setup the MCA rendezvous interrupt vector */
2096 register_percpu_irq(IA64_MCA_RENDEZ_VECTOR, &mca_rdzv_irqaction);
2097
2098 /* Setup the MCA wakeup interrupt vector */
2099 register_percpu_irq(IA64_MCA_WAKEUP_VECTOR, &mca_wkup_irqaction);
2100
2101#ifdef CONFIG_ACPI
2102 /* Setup the CPEI/P handler */
2103 register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction);
2104#endif
2105
2106 register_hotcpu_notifier(&mca_cpu_notifier); 2106 register_hotcpu_notifier(&mca_cpu_notifier);
2107 2107
2108 /* Setup the CMCI/P vector and handler */ 2108 /* Setup the CMCI/P vector and handler */
diff --git a/arch/ia64/kernel/msi_ia64.c b/arch/ia64/kernel/msi_ia64.c
index 4a746ea838ff..00b19a416eab 100644
--- a/arch/ia64/kernel/msi_ia64.c
+++ b/arch/ia64/kernel/msi_ia64.c
@@ -104,8 +104,8 @@ static int ia64_msi_retrigger_irq(unsigned int irq)
104 */ 104 */
105static struct irq_chip ia64_msi_chip = { 105static struct irq_chip ia64_msi_chip = {
106 .name = "PCI-MSI", 106 .name = "PCI-MSI",
107 .mask = mask_msi_irq, 107 .irq_mask = mask_msi_irq,
108 .unmask = unmask_msi_irq, 108 .irq_unmask = unmask_msi_irq,
109 .ack = ia64_ack_msi_irq, 109 .ack = ia64_ack_msi_irq,
110#ifdef CONFIG_SMP 110#ifdef CONFIG_SMP
111 .set_affinity = ia64_set_msi_irq_affinity, 111 .set_affinity = ia64_set_msi_irq_affinity,
@@ -160,8 +160,8 @@ static int dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
160 160
161static struct irq_chip dmar_msi_type = { 161static struct irq_chip dmar_msi_type = {
162 .name = "DMAR_MSI", 162 .name = "DMAR_MSI",
163 .unmask = dmar_msi_unmask, 163 .irq_unmask = dmar_msi_unmask,
164 .mask = dmar_msi_mask, 164 .irq_mask = dmar_msi_mask,
165 .ack = ia64_ack_msi_irq, 165 .ack = ia64_ack_msi_irq,
166#ifdef CONFIG_SMP 166#ifdef CONFIG_SMP
167 .set_affinity = dmar_msi_set_affinity, 167 .set_affinity = dmar_msi_set_affinity,
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index fdf6f9d013e5..77597e5ea60a 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -434,7 +434,7 @@ register_info(char *page)
434 unsigned long phys_stacked; 434 unsigned long phys_stacked;
435 pal_hints_u_t hints; 435 pal_hints_u_t hints;
436 unsigned long iregs, dregs; 436 unsigned long iregs, dregs;
437 char *info_type[]={ 437 static const char * const info_type[] = {
438 "Implemented AR(s)", 438 "Implemented AR(s)",
439 "AR(s) with read side-effects", 439 "AR(s) with read side-effects",
440 "Implemented CR(s)", 440 "Implemented CR(s)",
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index cce050e85c73..6b1852f7f972 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -1573,7 +1573,7 @@ pfm_read(struct file *filp, char __user *buf, size_t size, loff_t *ppos)
1573 return -EINVAL; 1573 return -EINVAL;
1574 } 1574 }
1575 1575
1576 ctx = (pfm_context_t *)filp->private_data; 1576 ctx = filp->private_data;
1577 if (ctx == NULL) { 1577 if (ctx == NULL) {
1578 printk(KERN_ERR "perfmon: pfm_read: NULL ctx [%d]\n", task_pid_nr(current)); 1578 printk(KERN_ERR "perfmon: pfm_read: NULL ctx [%d]\n", task_pid_nr(current));
1579 return -EINVAL; 1579 return -EINVAL;
@@ -1673,7 +1673,7 @@ pfm_poll(struct file *filp, poll_table * wait)
1673 return 0; 1673 return 0;
1674 } 1674 }
1675 1675
1676 ctx = (pfm_context_t *)filp->private_data; 1676 ctx = filp->private_data;
1677 if (ctx == NULL) { 1677 if (ctx == NULL) {
1678 printk(KERN_ERR "perfmon: pfm_poll: NULL ctx [%d]\n", task_pid_nr(current)); 1678 printk(KERN_ERR "perfmon: pfm_poll: NULL ctx [%d]\n", task_pid_nr(current));
1679 return 0; 1679 return 0;
@@ -1733,7 +1733,7 @@ pfm_fasync(int fd, struct file *filp, int on)
1733 return -EBADF; 1733 return -EBADF;
1734 } 1734 }
1735 1735
1736 ctx = (pfm_context_t *)filp->private_data; 1736 ctx = filp->private_data;
1737 if (ctx == NULL) { 1737 if (ctx == NULL) {
1738 printk(KERN_ERR "perfmon: pfm_fasync NULL ctx [%d]\n", task_pid_nr(current)); 1738 printk(KERN_ERR "perfmon: pfm_fasync NULL ctx [%d]\n", task_pid_nr(current));
1739 return -EBADF; 1739 return -EBADF;
@@ -1841,7 +1841,7 @@ pfm_flush(struct file *filp, fl_owner_t id)
1841 return -EBADF; 1841 return -EBADF;
1842 } 1842 }
1843 1843
1844 ctx = (pfm_context_t *)filp->private_data; 1844 ctx = filp->private_data;
1845 if (ctx == NULL) { 1845 if (ctx == NULL) {
1846 printk(KERN_ERR "perfmon: pfm_flush: NULL ctx [%d]\n", task_pid_nr(current)); 1846 printk(KERN_ERR "perfmon: pfm_flush: NULL ctx [%d]\n", task_pid_nr(current));
1847 return -EBADF; 1847 return -EBADF;
@@ -1984,7 +1984,7 @@ pfm_close(struct inode *inode, struct file *filp)
1984 return -EBADF; 1984 return -EBADF;
1985 } 1985 }
1986 1986
1987 ctx = (pfm_context_t *)filp->private_data; 1987 ctx = filp->private_data;
1988 if (ctx == NULL) { 1988 if (ctx == NULL) {
1989 printk(KERN_ERR "perfmon: pfm_close: NULL ctx [%d]\n", task_pid_nr(current)); 1989 printk(KERN_ERR "perfmon: pfm_close: NULL ctx [%d]\n", task_pid_nr(current));
1990 return -EBADF; 1990 return -EBADF;
@@ -4907,7 +4907,7 @@ restart_args:
4907 goto error_args; 4907 goto error_args;
4908 } 4908 }
4909 4909
4910 ctx = (pfm_context_t *)file->private_data; 4910 ctx = file->private_data;
4911 if (unlikely(ctx == NULL)) { 4911 if (unlikely(ctx == NULL)) {
4912 DPRINT(("no context for fd %d\n", fd)); 4912 DPRINT(("no context for fd %d\n", fd));
4913 goto error_args; 4913 goto error_args;
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index aa8b5fa1a8de..79802e540e53 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -354,6 +354,7 @@ retry:
354static const struct file_operations salinfo_event_fops = { 354static const struct file_operations salinfo_event_fops = {
355 .open = salinfo_event_open, 355 .open = salinfo_event_open,
356 .read = salinfo_event_read, 356 .read = salinfo_event_read,
357 .llseek = noop_llseek,
357}; 358};
358 359
359static int 360static int
@@ -571,6 +572,7 @@ static const struct file_operations salinfo_data_fops = {
571 .release = salinfo_log_release, 572 .release = salinfo_log_release,
572 .read = salinfo_log_read, 573 .read = salinfo_log_read,
573 .write = salinfo_log_write, 574 .write = salinfo_log_write,
575 .llseek = default_llseek,
574}; 576};
575 577
576static int __cpuinit 578static int __cpuinit
@@ -642,7 +644,7 @@ salinfo_init(void)
642 for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) { 644 for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
643 data = salinfo_data + i; 645 data = salinfo_data + i;
644 data->type = i; 646 data->type = i;
645 init_MUTEX(&data->mutex); 647 sema_init(&data->mutex, 1);
646 dir = proc_mkdir(salinfo_log_name[i], salinfo_dir); 648 dir = proc_mkdir(salinfo_log_name[i], salinfo_dir);
647 if (!dir) 649 if (!dir)
648 continue; 650 continue;
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 8fb958abf8d0..911cf9749700 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -594,10 +594,6 @@ setup_arch (char **cmdline_p)
594 cpu_init(); /* initialize the bootstrap CPU */ 594 cpu_init(); /* initialize the bootstrap CPU */
595 mmu_context_init(); /* initialize context_id bitmap */ 595 mmu_context_init(); /* initialize context_id bitmap */
596 596
597#ifdef CONFIG_ACPI
598 acpi_boot_init();
599#endif
600
601 paravirt_banner(); 597 paravirt_banner();
602 paravirt_arch_setup_console(cmdline_p); 598 paravirt_arch_setup_console(cmdline_p);
603 599
diff --git a/arch/ia64/kernel/stacktrace.c b/arch/ia64/kernel/stacktrace.c
new file mode 100644
index 000000000000..5af2783a87f4
--- /dev/null
+++ b/arch/ia64/kernel/stacktrace.c
@@ -0,0 +1,39 @@
1/*
2 * arch/ia64/kernel/stacktrace.c
3 *
4 * Stack trace management functions
5 *
6 */
7#include <linux/sched.h>
8#include <linux/stacktrace.h>
9#include <linux/module.h>
10
11static void
12ia64_do_save_stack(struct unw_frame_info *info, void *arg)
13{
14 struct stack_trace *trace = arg;
15 unsigned long ip;
16 int skip = trace->skip;
17
18 trace->nr_entries = 0;
19 do {
20 unw_get_ip(info, &ip);
21 if (ip == 0)
22 break;
23 if (skip == 0) {
24 trace->entries[trace->nr_entries++] = ip;
25 if (trace->nr_entries == trace->max_entries)
26 break;
27 } else
28 skip--;
29 } while (unw_unwind(info) >= 0);
30}
31
32/*
33 * Save stack-backtrace addresses into a stack_trace buffer.
34 */
35void save_stack_trace(struct stack_trace *trace)
36{
37 unw_init_running(ia64_do_save_stack, trace);
38}
39EXPORT_SYMBOL(save_stack_trace);
diff --git a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
index b6c0e63a0bf6..fed6afa2e8a9 100644
--- a/arch/ia64/kernel/unwind.c
+++ b/arch/ia64/kernel/unwind.c
@@ -1204,10 +1204,10 @@ desc_spill_sprel_p (unsigned char qp, unw_word t, unsigned char abreg, unw_word
1204static inline unw_hash_index_t 1204static inline unw_hash_index_t
1205hash (unsigned long ip) 1205hash (unsigned long ip)
1206{ 1206{
1207# define hashmagic 0x9e3779b97f4a7c16UL /* based on (sqrt(5)/2-1)*2^64 */ 1207 /* magic number = ((sqrt(5)-1)/2)*2^64 */
1208 static const unsigned long hashmagic = 0x9e3779b97f4a7c16UL;
1208 1209
1209 return (ip >> 4)*hashmagic >> (64 - UNW_LOG_HASH_SIZE); 1210 return (ip >> 4) * hashmagic >> (64 - UNW_LOG_HASH_SIZE);
1210#undef hashmagic
1211} 1211}
1212 1212
1213static inline long 1213static inline long
@@ -1531,7 +1531,7 @@ build_script (struct unw_frame_info *info)
1531 struct unw_labeled_state *ls, *next; 1531 struct unw_labeled_state *ls, *next;
1532 unsigned long ip = info->ip; 1532 unsigned long ip = info->ip;
1533 struct unw_state_record sr; 1533 struct unw_state_record sr;
1534 struct unw_table *table; 1534 struct unw_table *table, *prev;
1535 struct unw_reg_info *r; 1535 struct unw_reg_info *r;
1536 struct unw_insn insn; 1536 struct unw_insn insn;
1537 u8 *dp, *desc_end; 1537 u8 *dp, *desc_end;
@@ -1560,11 +1560,26 @@ build_script (struct unw_frame_info *info)
1560 1560
1561 STAT(parse_start = ia64_get_itc()); 1561 STAT(parse_start = ia64_get_itc());
1562 1562
1563 prev = NULL;
1563 for (table = unw.tables; table; table = table->next) { 1564 for (table = unw.tables; table; table = table->next) {
1564 if (ip >= table->start && ip < table->end) { 1565 if (ip >= table->start && ip < table->end) {
1566 /*
1567 * Leave the kernel unwind table at the very front,
1568 * lest moving it breaks some assumption elsewhere.
1569 * Otherwise, move the matching table to the second
1570 * position in the list so that traversals can benefit
1571 * from commonality in backtrace paths.
1572 */
1573 if (prev && prev != unw.tables) {
1574 /* unw is safe - we're already spinlocked */
1575 prev->next = table->next;
1576 table->next = unw.tables->next;
1577 unw.tables->next = table;
1578 }
1565 e = lookup(table, ip - table->segment_base); 1579 e = lookup(table, ip - table->segment_base);
1566 break; 1580 break;
1567 } 1581 }
1582 prev = table;
1568 } 1583 }
1569 if (!e) { 1584 if (!e) {
1570 /* no info, return default unwinder (leaf proc, no mem stack, no saved regs) */ 1585 /* no info, return default unwinder (leaf proc, no mem stack, no saved regs) */
diff --git a/arch/ia64/kvm/lapic.h b/arch/ia64/kvm/lapic.h
index ee541cebcd78..c5f92a926a9a 100644
--- a/arch/ia64/kvm/lapic.h
+++ b/arch/ia64/kvm/lapic.h
@@ -25,5 +25,6 @@ int kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source,
25int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2); 25int kvm_apic_compare_prio(struct kvm_vcpu *vcpu1, struct kvm_vcpu *vcpu2);
26int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq); 26int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq);
27#define kvm_apic_present(x) (true) 27#define kvm_apic_present(x) (true)
28#define kvm_lapic_enabled(x) (true)
28 29
29#endif 30#endif
diff --git a/arch/ia64/sn/kernel/msi_sn.c b/arch/ia64/sn/kernel/msi_sn.c
index 0c72dd463831..a5e500f02853 100644
--- a/arch/ia64/sn/kernel/msi_sn.c
+++ b/arch/ia64/sn/kernel/msi_sn.c
@@ -228,8 +228,8 @@ static int sn_msi_retrigger_irq(unsigned int irq)
228 228
229static struct irq_chip sn_msi_chip = { 229static struct irq_chip sn_msi_chip = {
230 .name = "PCI-MSI", 230 .name = "PCI-MSI",
231 .mask = mask_msi_irq, 231 .irq_mask = mask_msi_irq,
232 .unmask = unmask_msi_irq, 232 .irq_unmask = unmask_msi_irq,
233 .ack = sn_ack_msi_irq, 233 .ack = sn_ack_msi_irq,
234#ifdef CONFIG_SMP 234#ifdef CONFIG_SMP
235 .set_affinity = sn_set_msi_irq_affinity, 235 .set_affinity = sn_set_msi_irq_affinity,
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index fa1eceed0d23..30862c0358cd 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -860,6 +860,7 @@ error:
860 860
861static const struct file_operations sn_hwperf_fops = { 861static const struct file_operations sn_hwperf_fops = {
862 .unlocked_ioctl = sn_hwperf_ioctl, 862 .unlocked_ioctl = sn_hwperf_ioctl,
863 .llseek = noop_llseek,
863}; 864};
864 865
865static struct miscdevice sn_hwperf_dev = { 866static struct miscdevice sn_hwperf_dev = {
diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c
index 8adc6a14272a..3e8d350fdf39 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
@@ -1136,7 +1136,6 @@ __initconst = {
1136static void __init 1136static void __init
1137xen_patch_branch(unsigned long tag, unsigned long type) 1137xen_patch_branch(unsigned long tag, unsigned long type)
1138{ 1138{
1139 const unsigned long nelem = 1139 __paravirt_patch_apply_branch(tag, type, xen_branch_target,
1140 sizeof(xen_branch_target) / sizeof(xen_branch_target[0]); 1140 ARRAY_SIZE(xen_branch_target));
1141 __paravirt_patch_apply_branch(tag, type, xen_branch_target, nelem);
1142} 1141}
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 836abbbc9c04..3867fd21f333 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -315,7 +315,7 @@ config SMP
315 Management" code will be disabled if you say Y here. 315 Management" code will be disabled if you say Y here.
316 316
317 See also the SMP-HOWTO available at 317 See also the SMP-HOWTO available at
318 <http://www.linuxdoc.org/docs.html#howto>. 318 <http://tldp.org/HOWTO/SMP-HOWTO.html>.
319 319
320 If you don't know what to do here, say N. 320 If you don't know what to do here, say N.
321 321
diff --git a/arch/m32r/include/asm/elf.h b/arch/m32r/include/asm/elf.h
index 2f85412ef730..b8da7d0574d2 100644
--- a/arch/m32r/include/asm/elf.h
+++ b/arch/m32r/include/asm/elf.h
@@ -82,9 +82,9 @@ typedef elf_fpreg_t elf_fpregset_t;
82 * These are used to set parameters in the core dumps. 82 * These are used to set parameters in the core dumps.
83 */ 83 */
84#define ELF_CLASS ELFCLASS32 84#define ELF_CLASS ELFCLASS32
85#if defined(__LITTLE_ENDIAN) 85#if defined(__LITTLE_ENDIAN__)
86#define ELF_DATA ELFDATA2LSB 86#define ELF_DATA ELFDATA2LSB
87#elif defined(__BIG_ENDIAN) 87#elif defined(__BIG_ENDIAN__)
88#define ELF_DATA ELFDATA2MSB 88#define ELF_DATA ELFDATA2MSB
89#else 89#else
90#error no endian defined 90#error no endian defined
diff --git a/arch/m32r/include/asm/ioctls.h b/arch/m32r/include/asm/ioctls.h
index 66288063a4c0..349bf87bfbd0 100644
--- a/arch/m32r/include/asm/ioctls.h
+++ b/arch/m32r/include/asm/ioctls.h
@@ -1,87 +1,6 @@
1#ifndef __ARCH_M32R_IOCTLS_H__ 1#ifndef __ARCH_M32R_IOCTLS_H__
2#define __ARCH_M32R_IOCTLS_H__ 2#define __ARCH_M32R_IOCTLS_H__
3 3
4#include <asm/ioctl.h> 4#include <asm-generic/ioctls.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
57
58#define FIONCLEX 0x5450
59#define FIOCLEX 0x5451
60#define FIOASYNC 0x5452
61#define TIOCSERCONFIG 0x5453
62#define TIOCSERGWILD 0x5454
63#define TIOCSERSWILD 0x5455
64#define TIOCGLCKTRMIOS 0x5456
65#define TIOCSLCKTRMIOS 0x5457
66#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
67#define TIOCSERGETLSR 0x5459 /* Get line status register */
68#define TIOCSERGETMULTI 0x545A /* Get multiport config */
69#define TIOCSERSETMULTI 0x545B /* Set multiport config */
70
71#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
72#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
73#define FIOQSIZE 0x5460
74
75/* Used for packet mode */
76#define TIOCPKT_DATA 0
77#define TIOCPKT_FLUSHREAD 1
78#define TIOCPKT_FLUSHWRITE 2
79#define TIOCPKT_STOP 4
80#define TIOCPKT_START 8
81#define TIOCPKT_NOSTOP 16
82#define TIOCPKT_DOSTOP 32
83#define TIOCPKT_IOCTL 64
84
85#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
86 5
87#endif /* __ARCH_M32R_IOCTLS_H__ */ 6#endif /* __ARCH_M32R_IOCTLS_H__ */
diff --git a/arch/m32r/include/asm/irqflags.h b/arch/m32r/include/asm/irqflags.h
new file mode 100644
index 000000000000..1f92d29982ae
--- /dev/null
+++ b/arch/m32r/include/asm/irqflags.h
@@ -0,0 +1,104 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2001 Hiroyuki Kondo, Hirokazu Takata, and Hitoshi Yamamoto
7 * Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
8 */
9
10#ifndef _ASM_M32R_IRQFLAGS_H
11#define _ASM_M32R_IRQFLAGS_H
12
13#include <linux/types.h>
14
15static inline unsigned long arch_local_save_flags(void)
16{
17 unsigned long flags;
18 asm volatile("mvfc %0,psw" : "=r"(flags));
19 return flags;
20}
21
22static inline void arch_local_irq_disable(void)
23{
24#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
25 asm volatile (
26 "clrpsw #0x40 -> nop"
27 : : : "memory");
28#else
29 unsigned long tmpreg0, tmpreg1;
30 asm volatile (
31 "ld24 %0, #0 ; Use 32-bit insn. \n\t"
32 "mvfc %1, psw ; No interrupt can be accepted here. \n\t"
33 "mvtc %0, psw \n\t"
34 "and3 %0, %1, #0xffbf \n\t"
35 "mvtc %0, psw \n\t"
36 : "=&r" (tmpreg0), "=&r" (tmpreg1)
37 :
38 : "cbit", "memory");
39#endif
40}
41
42static inline void arch_local_irq_enable(void)
43{
44#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
45 asm volatile (
46 "setpsw #0x40 -> nop"
47 : : : "memory");
48#else
49 unsigned long tmpreg;
50 asm volatile (
51 "mvfc %0, psw; \n\t"
52 "or3 %0, %0, #0x0040; \n\t"
53 "mvtc %0, psw; \n\t"
54 : "=&r" (tmpreg)
55 :
56 : "cbit", "memory");
57#endif
58}
59
60static inline unsigned long arch_local_irq_save(void)
61{
62 unsigned long flags;
63
64#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
65 asm volatile (
66 "mvfc %0, psw; \n\t"
67 "clrpsw #0x40 -> nop; \n\t"
68 : "=r" (flags)
69 :
70 : "memory");
71#else
72 unsigned long tmpreg;
73 asm volatile (
74 "ld24 %1, #0 \n\t"
75 "mvfc %0, psw \n\t"
76 "mvtc %1, psw \n\t"
77 "and3 %1, %0, #0xffbf \n\t"
78 "mvtc %1, psw \n\t"
79 : "=r" (flags), "=&r" (tmpreg)
80 :
81 : "cbit", "memory");
82#endif
83 return flags;
84}
85
86static inline void arch_local_irq_restore(unsigned long flags)
87{
88 asm volatile("mvtc %0,psw"
89 :
90 : "r" (flags)
91 : "cbit", "memory");
92}
93
94static inline bool arch_irqs_disabled_flags(unsigned long flags)
95{
96 return !(flags & 0x40);
97}
98
99static inline bool arch_irqs_disabled(void)
100{
101 return arch_irqs_disabled_flags(arch_local_save_flags());
102}
103
104#endif /* _ASM_M32R_IRQFLAGS_H */
diff --git a/arch/m32r/include/asm/system.h b/arch/m32r/include/asm/system.h
index c980f5ba8de7..13c46794ccb1 100644
--- a/arch/m32r/include/asm/system.h
+++ b/arch/m32r/include/asm/system.h
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/compiler.h> 13#include <linux/compiler.h>
14#include <linux/irqflags.h>
14#include <asm/assembler.h> 15#include <asm/assembler.h>
15 16
16#ifdef __KERNEL__ 17#ifdef __KERNEL__
@@ -54,71 +55,6 @@
54 ); \ 55 ); \
55} while(0) 56} while(0)
56 57
57/* Interrupt Control */
58#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104)
59#define local_irq_enable() \
60 __asm__ __volatile__ ("setpsw #0x40 -> nop": : :"memory")
61#define local_irq_disable() \
62 __asm__ __volatile__ ("clrpsw #0x40 -> nop": : :"memory")
63#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
64static inline void local_irq_enable(void)
65{
66 unsigned long tmpreg;
67 __asm__ __volatile__(
68 "mvfc %0, psw; \n\t"
69 "or3 %0, %0, #0x0040; \n\t"
70 "mvtc %0, psw; \n\t"
71 : "=&r" (tmpreg) : : "cbit", "memory");
72}
73
74static inline void local_irq_disable(void)
75{
76 unsigned long tmpreg0, tmpreg1;
77 __asm__ __volatile__(
78 "ld24 %0, #0 ; Use 32-bit insn. \n\t"
79 "mvfc %1, psw ; No interrupt can be accepted here. \n\t"
80 "mvtc %0, psw \n\t"
81 "and3 %0, %1, #0xffbf \n\t"
82 "mvtc %0, psw \n\t"
83 : "=&r" (tmpreg0), "=&r" (tmpreg1) : : "cbit", "memory");
84}
85#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
86
87#define local_save_flags(x) \
88 __asm__ __volatile__("mvfc %0,psw" : "=r"(x) : /* no input */)
89
90#define local_irq_restore(x) \
91 __asm__ __volatile__("mvtc %0,psw" : /* no outputs */ \
92 : "r" (x) : "cbit", "memory")
93
94#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104))
95#define local_irq_save(x) \
96 __asm__ __volatile__( \
97 "mvfc %0, psw; \n\t" \
98 "clrpsw #0x40 -> nop; \n\t" \
99 : "=r" (x) : /* no input */ : "memory")
100#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
101#define local_irq_save(x) \
102 ({ \
103 unsigned long tmpreg; \
104 __asm__ __volatile__( \
105 "ld24 %1, #0 \n\t" \
106 "mvfc %0, psw \n\t" \
107 "mvtc %1, psw \n\t" \
108 "and3 %1, %0, #0xffbf \n\t" \
109 "mvtc %1, psw \n\t" \
110 : "=r" (x), "=&r" (tmpreg) \
111 : : "cbit", "memory"); \
112 })
113#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */
114
115#define irqs_disabled() \
116 ({ \
117 unsigned long flags; \
118 local_save_flags(flags); \
119 !(flags & 0x40); \
120 })
121
122#define nop() __asm__ __volatile__ ("nop" : : ) 58#define nop() __asm__ __volatile__ ("nop" : : )
123 59
124#define xchg(ptr, x) \ 60#define xchg(ptr, x) \
diff --git a/arch/m32r/kernel/.gitignore b/arch/m32r/kernel/.gitignore
new file mode 100644
index 000000000000..c5f676c3c224
--- /dev/null
+++ b/arch/m32r/kernel/.gitignore
@@ -0,0 +1 @@
vmlinux.lds
diff --git a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c
index 3c71f776872c..7db26f1f082d 100644
--- a/arch/m32r/kernel/irq.c
+++ b/arch/m32r/kernel/irq.c
@@ -51,7 +51,7 @@ int show_interrupts(struct seq_file *p, void *v)
51 for_each_online_cpu(j) 51 for_each_online_cpu(j)
52 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 52 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
53#endif 53#endif
54 seq_printf(p, " %14s", irq_desc[i].chip->typename); 54 seq_printf(p, " %14s", irq_desc[i].chip->name);
55 seq_printf(p, " %s", action->name); 55 seq_printf(p, " %s", action->name);
56 56
57 for (action=action->next; action; action = action->next) 57 for (action=action->next; action; action = action->next)
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index 7bbe38645ed5..a08697f0886d 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -28,6 +28,8 @@
28 28
29#define DEBUG_SIG 0 29#define DEBUG_SIG 0
30 30
31#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
32
31asmlinkage int 33asmlinkage int
32sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 34sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
33 unsigned long r2, unsigned long r3, unsigned long r4, 35 unsigned long r2, unsigned long r3, unsigned long r4,
@@ -254,7 +256,7 @@ give_sigsegv:
254static int prev_insn(struct pt_regs *regs) 256static int prev_insn(struct pt_regs *regs)
255{ 257{
256 u16 inst; 258 u16 inst;
257 if (get_user(&inst, (u16 __user *)(regs->bpc - 2))) 259 if (get_user(inst, (u16 __user *)(regs->bpc - 2)))
258 return -EFAULT; 260 return -EFAULT;
259 if ((inst & 0xfff0) == 0x10f0) /* trap ? */ 261 if ((inst & 0xfff0) == 0x10f0) /* trap ? */
260 regs->bpc -= 2; 262 regs->bpc -= 2;
diff --git a/arch/m32r/platforms/m32104ut/setup.c b/arch/m32r/platforms/m32104ut/setup.c
index 922fdfdadeaa..402a59d7219b 100644
--- a/arch/m32r/platforms/m32104ut/setup.c
+++ b/arch/m32r/platforms/m32104ut/setup.c
@@ -65,7 +65,7 @@ static void shutdown_m32104ut_irq(unsigned int irq)
65 65
66static struct irq_chip m32104ut_irq_type = 66static struct irq_chip m32104ut_irq_type =
67{ 67{
68 .typename = "M32104UT-IRQ", 68 .name = "M32104UT-IRQ",
69 .startup = startup_m32104ut_irq, 69 .startup = startup_m32104ut_irq,
70 .shutdown = shutdown_m32104ut_irq, 70 .shutdown = shutdown_m32104ut_irq,
71 .enable = enable_m32104ut_irq, 71 .enable = enable_m32104ut_irq,
diff --git a/arch/m32r/platforms/m32700ut/setup.c b/arch/m32r/platforms/m32700ut/setup.c
index 9c1bc7487c1e..80b1a026795a 100644
--- a/arch/m32r/platforms/m32700ut/setup.c
+++ b/arch/m32r/platforms/m32700ut/setup.c
@@ -71,7 +71,7 @@ static void shutdown_m32700ut_irq(unsigned int irq)
71 71
72static struct irq_chip m32700ut_irq_type = 72static struct irq_chip m32700ut_irq_type =
73{ 73{
74 .typename = "M32700UT-IRQ", 74 .name = "M32700UT-IRQ",
75 .startup = startup_m32700ut_irq, 75 .startup = startup_m32700ut_irq,
76 .shutdown = shutdown_m32700ut_irq, 76 .shutdown = shutdown_m32700ut_irq,
77 .enable = enable_m32700ut_irq, 77 .enable = enable_m32700ut_irq,
@@ -148,7 +148,7 @@ static void shutdown_m32700ut_pld_irq(unsigned int irq)
148 148
149static struct irq_chip m32700ut_pld_irq_type = 149static struct irq_chip m32700ut_pld_irq_type =
150{ 150{
151 .typename = "M32700UT-PLD-IRQ", 151 .name = "M32700UT-PLD-IRQ",
152 .startup = startup_m32700ut_pld_irq, 152 .startup = startup_m32700ut_pld_irq,
153 .shutdown = shutdown_m32700ut_pld_irq, 153 .shutdown = shutdown_m32700ut_pld_irq,
154 .enable = enable_m32700ut_pld_irq, 154 .enable = enable_m32700ut_pld_irq,
@@ -217,7 +217,7 @@ static void shutdown_m32700ut_lanpld_irq(unsigned int irq)
217 217
218static struct irq_chip m32700ut_lanpld_irq_type = 218static struct irq_chip m32700ut_lanpld_irq_type =
219{ 219{
220 .typename = "M32700UT-PLD-LAN-IRQ", 220 .name = "M32700UT-PLD-LAN-IRQ",
221 .startup = startup_m32700ut_lanpld_irq, 221 .startup = startup_m32700ut_lanpld_irq,
222 .shutdown = shutdown_m32700ut_lanpld_irq, 222 .shutdown = shutdown_m32700ut_lanpld_irq,
223 .enable = enable_m32700ut_lanpld_irq, 223 .enable = enable_m32700ut_lanpld_irq,
@@ -286,7 +286,7 @@ static void shutdown_m32700ut_lcdpld_irq(unsigned int irq)
286 286
287static struct irq_chip m32700ut_lcdpld_irq_type = 287static struct irq_chip m32700ut_lcdpld_irq_type =
288{ 288{
289 .typename = "M32700UT-PLD-LCD-IRQ", 289 .name = "M32700UT-PLD-LCD-IRQ",
290 .startup = startup_m32700ut_lcdpld_irq, 290 .startup = startup_m32700ut_lcdpld_irq,
291 .shutdown = shutdown_m32700ut_lcdpld_irq, 291 .shutdown = shutdown_m32700ut_lcdpld_irq,
292 .enable = enable_m32700ut_lcdpld_irq, 292 .enable = enable_m32700ut_lcdpld_irq,
diff --git a/arch/m32r/platforms/mappi/setup.c b/arch/m32r/platforms/mappi/setup.c
index fb4b17799b66..ea00c84d6b1b 100644
--- a/arch/m32r/platforms/mappi/setup.c
+++ b/arch/m32r/platforms/mappi/setup.c
@@ -65,7 +65,7 @@ static void shutdown_mappi_irq(unsigned int irq)
65 65
66static struct irq_chip mappi_irq_type = 66static struct irq_chip mappi_irq_type =
67{ 67{
68 .typename = "MAPPI-IRQ", 68 .name = "MAPPI-IRQ",
69 .startup = startup_mappi_irq, 69 .startup = startup_mappi_irq,
70 .shutdown = shutdown_mappi_irq, 70 .shutdown = shutdown_mappi_irq,
71 .enable = enable_mappi_irq, 71 .enable = enable_mappi_irq,
diff --git a/arch/m32r/platforms/mappi2/setup.c b/arch/m32r/platforms/mappi2/setup.c
index 6a65eda0a056..c049376d0270 100644
--- a/arch/m32r/platforms/mappi2/setup.c
+++ b/arch/m32r/platforms/mappi2/setup.c
@@ -72,7 +72,7 @@ static void shutdown_mappi2_irq(unsigned int irq)
72 72
73static struct irq_chip mappi2_irq_type = 73static struct irq_chip mappi2_irq_type =
74{ 74{
75 .typename = "MAPPI2-IRQ", 75 .name = "MAPPI2-IRQ",
76 .startup = startup_mappi2_irq, 76 .startup = startup_mappi2_irq,
77 .shutdown = shutdown_mappi2_irq, 77 .shutdown = shutdown_mappi2_irq,
78 .enable = enable_mappi2_irq, 78 .enable = enable_mappi2_irq,
diff --git a/arch/m32r/platforms/mappi3/setup.c b/arch/m32r/platforms/mappi3/setup.c
index 9c337aeac94b..882de25c6e8c 100644
--- a/arch/m32r/platforms/mappi3/setup.c
+++ b/arch/m32r/platforms/mappi3/setup.c
@@ -72,7 +72,7 @@ static void shutdown_mappi3_irq(unsigned int irq)
72 72
73static struct irq_chip mappi3_irq_type = 73static struct irq_chip mappi3_irq_type =
74{ 74{
75 .typename = "MAPPI3-IRQ", 75 .name = "MAPPI3-IRQ",
76 .startup = startup_mappi3_irq, 76 .startup = startup_mappi3_irq,
77 .shutdown = shutdown_mappi3_irq, 77 .shutdown = shutdown_mappi3_irq,
78 .enable = enable_mappi3_irq, 78 .enable = enable_mappi3_irq,
diff --git a/arch/m32r/platforms/oaks32r/setup.c b/arch/m32r/platforms/oaks32r/setup.c
index ed865741c38d..d11d93bf74f5 100644
--- a/arch/m32r/platforms/oaks32r/setup.c
+++ b/arch/m32r/platforms/oaks32r/setup.c
@@ -63,7 +63,7 @@ static void shutdown_oaks32r_irq(unsigned int irq)
63 63
64static struct irq_chip oaks32r_irq_type = 64static struct irq_chip oaks32r_irq_type =
65{ 65{
66 .typename = "OAKS32R-IRQ", 66 .name = "OAKS32R-IRQ",
67 .startup = startup_oaks32r_irq, 67 .startup = startup_oaks32r_irq,
68 .shutdown = shutdown_oaks32r_irq, 68 .shutdown = shutdown_oaks32r_irq,
69 .enable = enable_oaks32r_irq, 69 .enable = enable_oaks32r_irq,
diff --git a/arch/m32r/platforms/opsput/setup.c b/arch/m32r/platforms/opsput/setup.c
index 80d680657019..5f3402a2fbaf 100644
--- a/arch/m32r/platforms/opsput/setup.c
+++ b/arch/m32r/platforms/opsput/setup.c
@@ -72,7 +72,7 @@ static void shutdown_opsput_irq(unsigned int irq)
72 72
73static struct irq_chip opsput_irq_type = 73static struct irq_chip opsput_irq_type =
74{ 74{
75 .typename = "OPSPUT-IRQ", 75 .name = "OPSPUT-IRQ",
76 .startup = startup_opsput_irq, 76 .startup = startup_opsput_irq,
77 .shutdown = shutdown_opsput_irq, 77 .shutdown = shutdown_opsput_irq,
78 .enable = enable_opsput_irq, 78 .enable = enable_opsput_irq,
@@ -149,7 +149,7 @@ static void shutdown_opsput_pld_irq(unsigned int irq)
149 149
150static struct irq_chip opsput_pld_irq_type = 150static struct irq_chip opsput_pld_irq_type =
151{ 151{
152 .typename = "OPSPUT-PLD-IRQ", 152 .name = "OPSPUT-PLD-IRQ",
153 .startup = startup_opsput_pld_irq, 153 .startup = startup_opsput_pld_irq,
154 .shutdown = shutdown_opsput_pld_irq, 154 .shutdown = shutdown_opsput_pld_irq,
155 .enable = enable_opsput_pld_irq, 155 .enable = enable_opsput_pld_irq,
@@ -218,7 +218,7 @@ static void shutdown_opsput_lanpld_irq(unsigned int irq)
218 218
219static struct irq_chip opsput_lanpld_irq_type = 219static struct irq_chip opsput_lanpld_irq_type =
220{ 220{
221 .typename = "OPSPUT-PLD-LAN-IRQ", 221 .name = "OPSPUT-PLD-LAN-IRQ",
222 .startup = startup_opsput_lanpld_irq, 222 .startup = startup_opsput_lanpld_irq,
223 .shutdown = shutdown_opsput_lanpld_irq, 223 .shutdown = shutdown_opsput_lanpld_irq,
224 .enable = enable_opsput_lanpld_irq, 224 .enable = enable_opsput_lanpld_irq,
diff --git a/arch/m32r/platforms/usrv/setup.c b/arch/m32r/platforms/usrv/setup.c
index 757302660af8..1beac7a51ed4 100644
--- a/arch/m32r/platforms/usrv/setup.c
+++ b/arch/m32r/platforms/usrv/setup.c
@@ -63,7 +63,7 @@ static void shutdown_mappi_irq(unsigned int irq)
63 63
64static struct irq_chip mappi_irq_type = 64static struct irq_chip mappi_irq_type =
65{ 65{
66 .typename = "M32700-IRQ", 66 .name = "M32700-IRQ",
67 .startup = startup_mappi_irq, 67 .startup = startup_mappi_irq,
68 .shutdown = shutdown_mappi_irq, 68 .shutdown = shutdown_mappi_irq,
69 .enable = enable_mappi_irq, 69 .enable = enable_mappi_irq,
@@ -136,7 +136,7 @@ static void shutdown_m32700ut_pld_irq(unsigned int irq)
136 136
137static struct irq_chip m32700ut_pld_irq_type = 137static struct irq_chip m32700ut_pld_irq_type =
138{ 138{
139 .typename = "USRV-PLD-IRQ", 139 .name = "USRV-PLD-IRQ",
140 .startup = startup_m32700ut_pld_irq, 140 .startup = startup_m32700ut_pld_irq,
141 .shutdown = shutdown_m32700ut_pld_irq, 141 .shutdown = shutdown_m32700ut_pld_irq,
142 .enable = enable_m32700ut_pld_irq, 142 .enable = enable_m32700ut_pld_irq,
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 8030e2481d97..77bb0d6baa62 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -434,7 +434,7 @@ config PROC_HARDWARE
434 434
435config ISA 435config ISA
436 bool 436 bool
437 depends on Q40 || AMIGA_PCMCIA || GG2 437 depends on Q40 || AMIGA_PCMCIA
438 default y 438 default y
439 help 439 help
440 Find out whether you have ISA slots on your motherboard. ISA is the 440 Find out whether you have ISA slots on your motherboard. ISA is the
@@ -445,7 +445,7 @@ config ISA
445 445
446config GENERIC_ISA_DMA 446config GENERIC_ISA_DMA
447 bool 447 bool
448 depends on Q40 || AMIGA_PCMCIA || GG2 448 depends on Q40 || AMIGA_PCMCIA
449 default y 449 default y
450 450
451config ZONE_DMA 451config ZONE_DMA
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index cb8617bb194b..1c4d4c7bf4d4 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -155,6 +155,7 @@ static const struct file_operations rtc_fops = {
155 .unlocked_ioctl = rtc_ioctl, 155 .unlocked_ioctl = rtc_ioctl,
156 .open = rtc_open, 156 .open = rtc_open,
157 .release = rtc_release, 157 .release = rtc_release,
158 .llseek = noop_llseek,
158}; 159};
159 160
160static struct miscdevice rtc_dev = { 161static struct miscdevice rtc_dev = {
diff --git a/arch/m68k/include/asm/amigahw.h b/arch/m68k/include/asm/amigahw.h
index 5ca5dd951a4a..7a19b5686a4a 100644
--- a/arch/m68k/include/asm/amigahw.h
+++ b/arch/m68k/include/asm/amigahw.h
@@ -102,7 +102,6 @@ struct amiga_hw_present {
102 AMIGAHW_DECLARE(ALICE_NTSC); /* NTSC Alice (8374) */ 102 AMIGAHW_DECLARE(ALICE_NTSC); /* NTSC Alice (8374) */
103 AMIGAHW_DECLARE(MAGIC_REKICK); /* A3000 Magic Hard Rekick */ 103 AMIGAHW_DECLARE(MAGIC_REKICK); /* A3000 Magic Hard Rekick */
104 AMIGAHW_DECLARE(PCMCIA); /* PCMCIA Slot */ 104 AMIGAHW_DECLARE(PCMCIA); /* PCMCIA Slot */
105 AMIGAHW_DECLARE(GG2_ISA); /* GG2 Zorro2ISA Bridge */
106 AMIGAHW_DECLARE(ZORRO); /* Zorro AutoConfig */ 105 AMIGAHW_DECLARE(ZORRO); /* Zorro AutoConfig */
107 AMIGAHW_DECLARE(ZORRO3); /* Zorro III */ 106 AMIGAHW_DECLARE(ZORRO3); /* Zorro III */
108}; 107};
diff --git a/arch/m68k/include/asm/atomic.h b/arch/m68k/include/asm/atomic.h
index eab36dcacf6c..03ae3d14cd4a 100644
--- a/arch/m68k/include/asm/atomic.h
+++ b/arch/m68k/include/asm/atomic.h
@@ -1,7 +1,211 @@
1#ifdef __uClinux__ 1#ifndef __ARCH_M68K_ATOMIC__
2#include "atomic_no.h" 2#define __ARCH_M68K_ATOMIC__
3
4#include <linux/types.h>
5#include <asm/system.h>
6
7/*
8 * Atomic operations that C can't guarantee us. Useful for
9 * resource counting etc..
10 */
11
12/*
13 * We do not have SMP m68k systems, so we don't have to deal with that.
14 */
15
16#define ATOMIC_INIT(i) { (i) }
17
18#define atomic_read(v) (*(volatile int *)&(v)->counter)
19#define atomic_set(v, i) (((v)->counter) = i)
20
21/*
22 * The ColdFire parts cannot do some immediate to memory operations,
23 * so for them we do not specify the "i" asm constraint.
24 */
25#ifdef CONFIG_COLDFIRE
26#define ASM_DI "d"
3#else 27#else
4#include "atomic_mm.h" 28#define ASM_DI "di"
5#endif 29#endif
6 30
31static inline void atomic_add(int i, atomic_t *v)
32{
33 __asm__ __volatile__("addl %1,%0" : "+m" (*v) : ASM_DI (i));
34}
35
36static inline void atomic_sub(int i, atomic_t *v)
37{
38 __asm__ __volatile__("subl %1,%0" : "+m" (*v) : ASM_DI (i));
39}
40
41static inline void atomic_inc(atomic_t *v)
42{
43 __asm__ __volatile__("addql #1,%0" : "+m" (*v));
44}
45
46static inline void atomic_dec(atomic_t *v)
47{
48 __asm__ __volatile__("subql #1,%0" : "+m" (*v));
49}
50
51static inline int atomic_dec_and_test(atomic_t *v)
52{
53 char c;
54 __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "+m" (*v));
55 return c != 0;
56}
57
58static inline int atomic_inc_and_test(atomic_t *v)
59{
60 char c;
61 __asm__ __volatile__("addql #1,%1; seq %0" : "=d" (c), "+m" (*v));
62 return c != 0;
63}
64
65#ifdef CONFIG_RMW_INSNS
66
67static inline int atomic_add_return(int i, atomic_t *v)
68{
69 int t, tmp;
70
71 __asm__ __volatile__(
72 "1: movel %2,%1\n"
73 " addl %3,%1\n"
74 " casl %2,%1,%0\n"
75 " jne 1b"
76 : "+m" (*v), "=&d" (t), "=&d" (tmp)
77 : "g" (i), "2" (atomic_read(v)));
78 return t;
79}
80
81static inline int atomic_sub_return(int i, atomic_t *v)
82{
83 int t, tmp;
84
85 __asm__ __volatile__(
86 "1: movel %2,%1\n"
87 " subl %3,%1\n"
88 " casl %2,%1,%0\n"
89 " jne 1b"
90 : "+m" (*v), "=&d" (t), "=&d" (tmp)
91 : "g" (i), "2" (atomic_read(v)));
92 return t;
93}
94
95#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
96#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
97
98#else /* !CONFIG_RMW_INSNS */
99
100static inline int atomic_add_return(int i, atomic_t * v)
101{
102 unsigned long flags;
103 int t;
104
105 local_irq_save(flags);
106 t = atomic_read(v);
107 t += i;
108 atomic_set(v, t);
109 local_irq_restore(flags);
110
111 return t;
112}
113
114static inline int atomic_sub_return(int i, atomic_t * v)
115{
116 unsigned long flags;
117 int t;
118
119 local_irq_save(flags);
120 t = atomic_read(v);
121 t -= i;
122 atomic_set(v, t);
123 local_irq_restore(flags);
124
125 return t;
126}
127
128static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
129{
130 unsigned long flags;
131 int prev;
132
133 local_irq_save(flags);
134 prev = atomic_read(v);
135 if (prev == old)
136 atomic_set(v, new);
137 local_irq_restore(flags);
138 return prev;
139}
140
141static inline int atomic_xchg(atomic_t *v, int new)
142{
143 unsigned long flags;
144 int prev;
145
146 local_irq_save(flags);
147 prev = atomic_read(v);
148 atomic_set(v, new);
149 local_irq_restore(flags);
150 return prev;
151}
152
153#endif /* !CONFIG_RMW_INSNS */
154
155#define atomic_dec_return(v) atomic_sub_return(1, (v))
156#define atomic_inc_return(v) atomic_add_return(1, (v))
157
158static inline int atomic_sub_and_test(int i, atomic_t *v)
159{
160 char c;
161 __asm__ __volatile__("subl %2,%1; seq %0"
162 : "=d" (c), "+m" (*v)
163 : ASM_DI (i));
164 return c != 0;
165}
166
167static inline int atomic_add_negative(int i, atomic_t *v)
168{
169 char c;
170 __asm__ __volatile__("addl %2,%1; smi %0"
171 : "=d" (c), "+m" (*v)
172 : "id" (i));
173 return c != 0;
174}
175
176static inline void atomic_clear_mask(unsigned long mask, unsigned long *v)
177{
178 __asm__ __volatile__("andl %1,%0" : "+m" (*v) : "id" (~(mask)));
179}
180
181static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
182{
183 __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
184}
185
186static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
187{
188 int c, old;
189 c = atomic_read(v);
190 for (;;) {
191 if (unlikely(c == (u)))
192 break;
193 old = atomic_cmpxchg((v), c, c + (a));
194 if (likely(old == c))
195 break;
196 c = old;
197 }
198 return c != (u);
199}
200
201#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
202
203/* Atomic operations are already serializing */
204#define smp_mb__before_atomic_dec() barrier()
205#define smp_mb__after_atomic_dec() barrier()
206#define smp_mb__before_atomic_inc() barrier()
207#define smp_mb__after_atomic_inc() barrier()
208
209#include <asm-generic/atomic-long.h>
7#include <asm-generic/atomic64.h> 210#include <asm-generic/atomic64.h>
211#endif /* __ARCH_M68K_ATOMIC __ */
diff --git a/arch/m68k/include/asm/atomic_mm.h b/arch/m68k/include/asm/atomic_mm.h
deleted file mode 100644
index 6a223b3f7e74..000000000000
--- a/arch/m68k/include/asm/atomic_mm.h
+++ /dev/null
@@ -1,200 +0,0 @@
1#ifndef __ARCH_M68K_ATOMIC__
2#define __ARCH_M68K_ATOMIC__
3
4#include <linux/types.h>
5#include <asm/system.h>
6
7/*
8 * Atomic operations that C can't guarantee us. Useful for
9 * resource counting etc..
10 */
11
12/*
13 * We do not have SMP m68k systems, so we don't have to deal with that.
14 */
15
16#define ATOMIC_INIT(i) { (i) }
17
18#define atomic_read(v) (*(volatile int *)&(v)->counter)
19#define atomic_set(v, i) (((v)->counter) = i)
20
21static inline void atomic_add(int i, atomic_t *v)
22{
23 __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "id" (i));
24}
25
26static inline void atomic_sub(int i, atomic_t *v)
27{
28 __asm__ __volatile__("subl %1,%0" : "+m" (*v) : "id" (i));
29}
30
31static inline void atomic_inc(atomic_t *v)
32{
33 __asm__ __volatile__("addql #1,%0" : "+m" (*v));
34}
35
36static inline void atomic_dec(atomic_t *v)
37{
38 __asm__ __volatile__("subql #1,%0" : "+m" (*v));
39}
40
41static inline int atomic_dec_and_test(atomic_t *v)
42{
43 char c;
44 __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "+m" (*v));
45 return c != 0;
46}
47
48static inline int atomic_inc_and_test(atomic_t *v)
49{
50 char c;
51 __asm__ __volatile__("addql #1,%1; seq %0" : "=d" (c), "+m" (*v));
52 return c != 0;
53}
54
55#ifdef CONFIG_RMW_INSNS
56
57static inline int atomic_add_return(int i, atomic_t *v)
58{
59 int t, tmp;
60
61 __asm__ __volatile__(
62 "1: movel %2,%1\n"
63 " addl %3,%1\n"
64 " casl %2,%1,%0\n"
65 " jne 1b"
66 : "+m" (*v), "=&d" (t), "=&d" (tmp)
67 : "g" (i), "2" (atomic_read(v)));
68 return t;
69}
70
71static inline int atomic_sub_return(int i, atomic_t *v)
72{
73 int t, tmp;
74
75 __asm__ __volatile__(
76 "1: movel %2,%1\n"
77 " subl %3,%1\n"
78 " casl %2,%1,%0\n"
79 " jne 1b"
80 : "+m" (*v), "=&d" (t), "=&d" (tmp)
81 : "g" (i), "2" (atomic_read(v)));
82 return t;
83}
84
85#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
86#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
87
88#else /* !CONFIG_RMW_INSNS */
89
90static inline int atomic_add_return(int i, atomic_t * v)
91{
92 unsigned long flags;
93 int t;
94
95 local_irq_save(flags);
96 t = atomic_read(v);
97 t += i;
98 atomic_set(v, t);
99 local_irq_restore(flags);
100
101 return t;
102}
103
104static inline int atomic_sub_return(int i, atomic_t * v)
105{
106 unsigned long flags;
107 int t;
108
109 local_irq_save(flags);
110 t = atomic_read(v);
111 t -= i;
112 atomic_set(v, t);
113 local_irq_restore(flags);
114
115 return t;
116}
117
118static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
119{
120 unsigned long flags;
121 int prev;
122
123 local_irq_save(flags);
124 prev = atomic_read(v);
125 if (prev == old)
126 atomic_set(v, new);
127 local_irq_restore(flags);
128 return prev;
129}
130
131static inline int atomic_xchg(atomic_t *v, int new)
132{
133 unsigned long flags;
134 int prev;
135
136 local_irq_save(flags);
137 prev = atomic_read(v);
138 atomic_set(v, new);
139 local_irq_restore(flags);
140 return prev;
141}
142
143#endif /* !CONFIG_RMW_INSNS */
144
145#define atomic_dec_return(v) atomic_sub_return(1, (v))
146#define atomic_inc_return(v) atomic_add_return(1, (v))
147
148static inline int atomic_sub_and_test(int i, atomic_t *v)
149{
150 char c;
151 __asm__ __volatile__("subl %2,%1; seq %0"
152 : "=d" (c), "+m" (*v)
153 : "id" (i));
154 return c != 0;
155}
156
157static inline int atomic_add_negative(int i, atomic_t *v)
158{
159 char c;
160 __asm__ __volatile__("addl %2,%1; smi %0"
161 : "=d" (c), "+m" (*v)
162 : "id" (i));
163 return c != 0;
164}
165
166static inline void atomic_clear_mask(unsigned long mask, unsigned long *v)
167{
168 __asm__ __volatile__("andl %1,%0" : "+m" (*v) : "id" (~(mask)));
169}
170
171static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
172{
173 __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
174}
175
176static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
177{
178 int c, old;
179 c = atomic_read(v);
180 for (;;) {
181 if (unlikely(c == (u)))
182 break;
183 old = atomic_cmpxchg((v), c, c + (a));
184 if (likely(old == c))
185 break;
186 c = old;
187 }
188 return c != (u);
189}
190
191#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
192
193/* Atomic operations are already serializing */
194#define smp_mb__before_atomic_dec() barrier()
195#define smp_mb__after_atomic_dec() barrier()
196#define smp_mb__before_atomic_inc() barrier()
197#define smp_mb__after_atomic_inc() barrier()
198
199#include <asm-generic/atomic-long.h>
200#endif /* __ARCH_M68K_ATOMIC __ */
diff --git a/arch/m68k/include/asm/atomic_no.h b/arch/m68k/include/asm/atomic_no.h
deleted file mode 100644
index 289310c63a8a..000000000000
--- a/arch/m68k/include/asm/atomic_no.h
+++ /dev/null
@@ -1,155 +0,0 @@
1#ifndef __ARCH_M68KNOMMU_ATOMIC__
2#define __ARCH_M68KNOMMU_ATOMIC__
3
4#include <linux/types.h>
5#include <asm/system.h>
6
7/*
8 * Atomic operations that C can't guarantee us. Useful for
9 * resource counting etc..
10 */
11
12/*
13 * We do not have SMP m68k systems, so we don't have to deal with that.
14 */
15
16#define ATOMIC_INIT(i) { (i) }
17
18#define atomic_read(v) (*(volatile int *)&(v)->counter)
19#define atomic_set(v, i) (((v)->counter) = i)
20
21static __inline__ void atomic_add(int i, atomic_t *v)
22{
23#ifdef CONFIG_COLDFIRE
24 __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "d" (i));
25#else
26 __asm__ __volatile__("addl %1,%0" : "+m" (*v) : "di" (i));
27#endif
28}
29
30static __inline__ void atomic_sub(int i, atomic_t *v)
31{
32#ifdef CONFIG_COLDFIRE
33 __asm__ __volatile__("subl %1,%0" : "+m" (*v) : "d" (i));
34#else
35 __asm__ __volatile__("subl %1,%0" : "+m" (*v) : "di" (i));
36#endif
37}
38
39static __inline__ int atomic_sub_and_test(int i, atomic_t * v)
40{
41 char c;
42#ifdef CONFIG_COLDFIRE
43 __asm__ __volatile__("subl %2,%1; seq %0"
44 : "=d" (c), "+m" (*v)
45 : "d" (i));
46#else
47 __asm__ __volatile__("subl %2,%1; seq %0"
48 : "=d" (c), "+m" (*v)
49 : "di" (i));
50#endif
51 return c != 0;
52}
53
54static __inline__ void atomic_inc(volatile atomic_t *v)
55{
56 __asm__ __volatile__("addql #1,%0" : "+m" (*v));
57}
58
59/*
60 * atomic_inc_and_test - increment and test
61 * @v: pointer of type atomic_t
62 *
63 * Atomically increments @v by 1
64 * and returns true if the result is zero, or false for all
65 * other cases.
66 */
67
68static __inline__ int atomic_inc_and_test(volatile atomic_t *v)
69{
70 char c;
71 __asm__ __volatile__("addql #1,%1; seq %0" : "=d" (c), "+m" (*v));
72 return c != 0;
73}
74
75static __inline__ void atomic_dec(volatile atomic_t *v)
76{
77 __asm__ __volatile__("subql #1,%0" : "+m" (*v));
78}
79
80static __inline__ int atomic_dec_and_test(volatile atomic_t *v)
81{
82 char c;
83 __asm__ __volatile__("subql #1,%1; seq %0" : "=d" (c), "+m" (*v));
84 return c != 0;
85}
86
87static __inline__ void atomic_clear_mask(unsigned long mask, unsigned long *v)
88{
89 __asm__ __volatile__("andl %1,%0" : "+m" (*v) : "id" (~(mask)));
90}
91
92static __inline__ void atomic_set_mask(unsigned long mask, unsigned long *v)
93{
94 __asm__ __volatile__("orl %1,%0" : "+m" (*v) : "id" (mask));
95}
96
97/* Atomic operations are already serializing */
98#define smp_mb__before_atomic_dec() barrier()
99#define smp_mb__after_atomic_dec() barrier()
100#define smp_mb__before_atomic_inc() barrier()
101#define smp_mb__after_atomic_inc() barrier()
102
103static inline int atomic_add_return(int i, atomic_t * v)
104{
105 unsigned long temp, flags;
106
107 local_irq_save(flags);
108 temp = *(long *)v;
109 temp += i;
110 *(long *)v = temp;
111 local_irq_restore(flags);
112
113 return temp;
114}
115
116#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
117
118static inline int atomic_sub_return(int i, atomic_t * v)
119{
120 unsigned long temp, flags;
121
122 local_irq_save(flags);
123 temp = *(long *)v;
124 temp -= i;
125 *(long *)v = temp;
126 local_irq_restore(flags);
127
128 return temp;
129}
130
131#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
132#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
133
134static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
135{
136 int c, old;
137 c = atomic_read(v);
138 for (;;) {
139 if (unlikely(c == (u)))
140 break;
141 old = atomic_cmpxchg((v), c, c + (a));
142 if (likely(old == c))
143 break;
144 c = old;
145 }
146 return c != (u);
147}
148
149#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
150
151#define atomic_dec_return(v) atomic_sub_return(1,(v))
152#define atomic_inc_return(v) atomic_add_return(1,(v))
153
154#include <asm-generic/atomic-long.h>
155#endif /* __ARCH_M68KNOMMU_ATOMIC __ */
diff --git a/arch/m68k/include/asm/cacheflush_no.h b/arch/m68k/include/asm/cacheflush_no.h
index 89f195656be7..7085bd51668b 100644
--- a/arch/m68k/include/asm/cacheflush_no.h
+++ b/arch/m68k/include/asm/cacheflush_no.h
@@ -29,7 +29,7 @@
29 29
30static inline void __flush_cache_all(void) 30static inline void __flush_cache_all(void)
31{ 31{
32#ifdef CONFIG_M5407 32#if defined(CONFIG_M5407) || defined(CONFIG_M548x)
33 /* 33 /*
34 * Use cpushl to push and invalidate all cache lines. 34 * Use cpushl to push and invalidate all cache lines.
35 * Gas doesn't seem to know how to generate the ColdFire 35 * Gas doesn't seem to know how to generate the ColdFire
diff --git a/arch/m68k/include/asm/coldfire.h b/arch/m68k/include/asm/coldfire.h
index 83a9fa4e618a..3b0a34d0fe33 100644
--- a/arch/m68k/include/asm/coldfire.h
+++ b/arch/m68k/include/asm/coldfire.h
@@ -32,7 +32,9 @@
32 */ 32 */
33#define MCF_MBAR 0x10000000 33#define MCF_MBAR 0x10000000
34#define MCF_MBAR2 0x80000000 34#define MCF_MBAR2 0x80000000
35#if defined(CONFIG_M520x) 35#if defined(CONFIG_M548x)
36#define MCF_IPSBAR MCF_MBAR
37#elif defined(CONFIG_M520x)
36#define MCF_IPSBAR 0xFC000000 38#define MCF_IPSBAR 0xFC000000
37#else 39#else
38#define MCF_IPSBAR 0x40000000 40#define MCF_IPSBAR 0x40000000
diff --git a/arch/m68k/include/asm/entry_mm.h b/arch/m68k/include/asm/entry_mm.h
index 474125886218..e41fea399bfe 100644
--- a/arch/m68k/include/asm/entry_mm.h
+++ b/arch/m68k/include/asm/entry_mm.h
@@ -3,6 +3,9 @@
3 3
4#include <asm/setup.h> 4#include <asm/setup.h>
5#include <asm/page.h> 5#include <asm/page.h>
6#ifdef __ASSEMBLY__
7#include <asm/thread_info.h>
8#endif
6 9
7/* 10/*
8 * Stack layout in 'ret_from_exception': 11 * Stack layout in 'ret_from_exception':
diff --git a/arch/m68k/include/asm/entry_no.h b/arch/m68k/include/asm/entry_no.h
index 907ed03d792f..80e41492aa2a 100644
--- a/arch/m68k/include/asm/entry_no.h
+++ b/arch/m68k/include/asm/entry_no.h
@@ -28,7 +28,7 @@
28 * M68K COLDFIRE 28 * M68K COLDFIRE
29 */ 29 */
30 30
31#define ALLOWINT 0xf8ff 31#define ALLOWINT (~0x700)
32 32
33#ifdef __ASSEMBLY__ 33#ifdef __ASSEMBLY__
34 34
diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h
index 283214dc65a7..1b57adbafad5 100644
--- a/arch/m68k/include/asm/gpio.h
+++ b/arch/m68k/include/asm/gpio.h
@@ -36,7 +36,8 @@
36 */ 36 */
37#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \ 37#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
38 defined(CONFIG_M520x) || defined(CONFIG_M523x) || \ 38 defined(CONFIG_M520x) || defined(CONFIG_M523x) || \
39 defined(CONFIG_M527x) || defined(CONFIG_M528x) || defined(CONFIG_M532x) 39 defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
40 defined(CONFIG_M532x) || defined(CONFIG_M548x)
40 41
41/* These parts have GPIO organized by 8 bit ports */ 42/* These parts have GPIO organized by 8 bit ports */
42 43
@@ -136,6 +137,8 @@ static inline u32 __mcf_gpio_ppdr(unsigned gpio)
136#endif 137#endif
137 else 138 else
138 return MCFGPIO_PPDR + mcfgpio_port(gpio - MCFGPIO_SCR_START); 139 return MCFGPIO_PPDR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
140#else
141 return 0;
139#endif 142#endif
140} 143}
141 144
@@ -173,6 +176,8 @@ static inline u32 __mcf_gpio_podr(unsigned gpio)
173#endif 176#endif
174 else 177 else
175 return MCFGPIO_PODR + mcfgpio_port(gpio - MCFGPIO_SCR_START); 178 return MCFGPIO_PODR + mcfgpio_port(gpio - MCFGPIO_SCR_START);
179#else
180 return 0;
176#endif 181#endif
177} 182}
178 183
diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index 9e673e3bd434..0fb3468000e7 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -49,23 +49,6 @@
49#define MULTI_ISA 0 49#define MULTI_ISA 0
50#endif /* Q40 */ 50#endif /* Q40 */
51 51
52/* GG-II Zorro to ISA bridge */
53#ifdef CONFIG_GG2
54
55extern unsigned long gg2_isa_base;
56#define GG2_ISA_IO_B(ioaddr) (gg2_isa_base+1+((unsigned long)(ioaddr)*4))
57#define GG2_ISA_IO_W(ioaddr) (gg2_isa_base+ ((unsigned long)(ioaddr)*4))
58#define GG2_ISA_MEM_B(madr) (gg2_isa_base+1+(((unsigned long)(madr)*4) & 0xfffff))
59#define GG2_ISA_MEM_W(madr) (gg2_isa_base+ (((unsigned long)(madr)*4) & 0xfffff))
60
61#ifndef MULTI_ISA
62#define MULTI_ISA 0
63#else
64#undef MULTI_ISA
65#define MULTI_ISA 1
66#endif
67#endif /* GG2 */
68
69#ifdef CONFIG_AMIGA_PCMCIA 52#ifdef CONFIG_AMIGA_PCMCIA
70#include <asm/amigayle.h> 53#include <asm/amigayle.h>
71 54
@@ -89,8 +72,7 @@ extern unsigned long gg2_isa_base;
89#endif 72#endif
90 73
91#define ISA_TYPE_Q40 (1) 74#define ISA_TYPE_Q40 (1)
92#define ISA_TYPE_GG2 (2) 75#define ISA_TYPE_AG (2)
93#define ISA_TYPE_AG (3)
94 76
95#if defined(CONFIG_Q40) && !defined(MULTI_ISA) 77#if defined(CONFIG_Q40) && !defined(MULTI_ISA)
96#define ISA_TYPE ISA_TYPE_Q40 78#define ISA_TYPE ISA_TYPE_Q40
@@ -100,10 +82,6 @@ extern unsigned long gg2_isa_base;
100#define ISA_TYPE ISA_TYPE_AG 82#define ISA_TYPE ISA_TYPE_AG
101#define ISA_SEX 1 83#define ISA_SEX 1
102#endif 84#endif
103#if defined(CONFIG_GG2) && !defined(MULTI_ISA)
104#define ISA_TYPE ISA_TYPE_GG2
105#define ISA_SEX 0
106#endif
107 85
108#ifdef MULTI_ISA 86#ifdef MULTI_ISA
109extern int isa_type; 87extern int isa_type;
@@ -125,9 +103,6 @@ static inline u8 __iomem *isa_itb(unsigned long addr)
125#ifdef CONFIG_Q40 103#ifdef CONFIG_Q40
126 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr); 104 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_IO_B(addr);
127#endif 105#endif
128#ifdef CONFIG_GG2
129 case ISA_TYPE_GG2: return (u8 __iomem *)GG2_ISA_IO_B(addr);
130#endif
131#ifdef CONFIG_AMIGA_PCMCIA 106#ifdef CONFIG_AMIGA_PCMCIA
132 case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr); 107 case ISA_TYPE_AG: return (u8 __iomem *)AG_ISA_IO_B(addr);
133#endif 108#endif
@@ -141,9 +116,6 @@ static inline u16 __iomem *isa_itw(unsigned long addr)
141#ifdef CONFIG_Q40 116#ifdef CONFIG_Q40
142 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr); 117 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_IO_W(addr);
143#endif 118#endif
144#ifdef CONFIG_GG2
145 case ISA_TYPE_GG2: return (u16 __iomem *)GG2_ISA_IO_W(addr);
146#endif
147#ifdef CONFIG_AMIGA_PCMCIA 119#ifdef CONFIG_AMIGA_PCMCIA
148 case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr); 120 case ISA_TYPE_AG: return (u16 __iomem *)AG_ISA_IO_W(addr);
149#endif 121#endif
@@ -167,9 +139,6 @@ static inline u8 __iomem *isa_mtb(unsigned long addr)
167#ifdef CONFIG_Q40 139#ifdef CONFIG_Q40
168 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr); 140 case ISA_TYPE_Q40: return (u8 __iomem *)Q40_ISA_MEM_B(addr);
169#endif 141#endif
170#ifdef CONFIG_GG2
171 case ISA_TYPE_GG2: return (u8 __iomem *)GG2_ISA_MEM_B(addr);
172#endif
173#ifdef CONFIG_AMIGA_PCMCIA 142#ifdef CONFIG_AMIGA_PCMCIA
174 case ISA_TYPE_AG: return (u8 __iomem *)addr; 143 case ISA_TYPE_AG: return (u8 __iomem *)addr;
175#endif 144#endif
@@ -183,9 +152,6 @@ static inline u16 __iomem *isa_mtw(unsigned long addr)
183#ifdef CONFIG_Q40 152#ifdef CONFIG_Q40
184 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr); 153 case ISA_TYPE_Q40: return (u16 __iomem *)Q40_ISA_MEM_W(addr);
185#endif 154#endif
186#ifdef CONFIG_GG2
187 case ISA_TYPE_GG2: return (u16 __iomem *)GG2_ISA_MEM_W(addr);
188#endif
189#ifdef CONFIG_AMIGA_PCMCIA 155#ifdef CONFIG_AMIGA_PCMCIA
190 case ISA_TYPE_AG: return (u16 __iomem *)addr; 156 case ISA_TYPE_AG: return (u16 __iomem *)addr;
191#endif 157#endif
@@ -217,9 +183,6 @@ static inline void isa_delay(void)
217#ifdef CONFIG_Q40 183#ifdef CONFIG_Q40
218 case ISA_TYPE_Q40: isa_outb(0,0x80); break; 184 case ISA_TYPE_Q40: isa_outb(0,0x80); break;
219#endif 185#endif
220#ifdef CONFIG_GG2
221 case ISA_TYPE_GG2: break;
222#endif
223#ifdef CONFIG_AMIGA_PCMCIA 186#ifdef CONFIG_AMIGA_PCMCIA
224 case ISA_TYPE_AG: break; 187 case ISA_TYPE_AG: break;
225#endif 188#endif
@@ -287,9 +250,13 @@ static inline void isa_delay(void)
287#define outb(val,port) ((void)0) 250#define outb(val,port) ((void)0)
288#define outb_p(val,port) ((void)0) 251#define outb_p(val,port) ((void)0)
289#define inw(port) 0xffff 252#define inw(port) 0xffff
253#define inw_p(port) 0xffff
290#define outw(val,port) ((void)0) 254#define outw(val,port) ((void)0)
255#define outw_p(val,port) ((void)0)
291#define inl(port) 0xffffffffUL 256#define inl(port) 0xffffffffUL
257#define inl_p(port) 0xffffffffUL
292#define outl(val,port) ((void)0) 258#define outl(val,port) ((void)0)
259#define outl_p(val,port) ((void)0)
293 260
294#define insb(port,buf,nr) ((void)0) 261#define insb(port,buf,nr) ((void)0)
295#define outsb(port,buf,nr) ((void)0) 262#define outsb(port,buf,nr) ((void)0)
diff --git a/arch/m68k/include/asm/ioctls.h b/arch/m68k/include/asm/ioctls.h
index 91a57d665460..1332bb4ca5b0 100644
--- a/arch/m68k/include/asm/ioctls.h
+++ b/arch/m68k/include/asm/ioctls.h
@@ -1,86 +1,8 @@
1#ifndef __ARCH_M68K_IOCTLS_H__ 1#ifndef __ARCH_M68K_IOCTLS_H__
2#define __ARCH_M68K_IOCTLS_H__ 2#define __ARCH_M68K_IOCTLS_H__
3 3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCSBRK 0x5427 /* BSD compatibility */
47#define TIOCCBRK 0x5428 /* BSD compatibility */
48#define TIOCGSID 0x5429 /* Return the session ID of FD */
49#define TCGETS2 _IOR('T',0x2A, struct termios2)
50#define TCSETS2 _IOW('T',0x2B, struct termios2)
51#define TCSETSW2 _IOW('T',0x2C, struct termios2)
52#define TCSETSF2 _IOW('T',0x2D, struct termios2)
53#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
54#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
55#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
56
57#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
58#define FIOCLEX 0x5451
59#define FIOASYNC 0x5452
60#define TIOCSERCONFIG 0x5453
61#define TIOCSERGWILD 0x5454
62#define TIOCSERSWILD 0x5455
63#define TIOCGLCKTRMIOS 0x5456
64#define TIOCSLCKTRMIOS 0x5457
65#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
66#define TIOCSERGETLSR 0x5459 /* Get line status register */
67#define TIOCSERGETMULTI 0x545A /* Get multiport config */
68#define TIOCSERSETMULTI 0x545B /* Set multiport config */
69
70#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
71#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
72#define FIOQSIZE 0x545E 4#define FIOQSIZE 0x545E
73 5
74/* Used for packet mode */ 6#include <asm-generic/ioctls.h>
75#define TIOCPKT_DATA 0
76#define TIOCPKT_FLUSHREAD 1
77#define TIOCPKT_FLUSHWRITE 2
78#define TIOCPKT_STOP 4
79#define TIOCPKT_START 8
80#define TIOCPKT_NOSTOP 16
81#define TIOCPKT_DOSTOP 32
82#define TIOCPKT_IOCTL 64
83
84#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
85 7
86#endif /* __ARCH_M68K_IOCTLS_H__ */ 8#endif /* __ARCH_M68K_IOCTLS_H__ */
diff --git a/arch/m68k/include/asm/irqflags.h b/arch/m68k/include/asm/irqflags.h
new file mode 100644
index 000000000000..4a5b284a1550
--- /dev/null
+++ b/arch/m68k/include/asm/irqflags.h
@@ -0,0 +1,76 @@
1#ifndef _M68K_IRQFLAGS_H
2#define _M68K_IRQFLAGS_H
3
4#include <linux/types.h>
5#include <linux/hardirq.h>
6#include <linux/preempt.h>
7#include <asm/thread_info.h>
8#include <asm/entry.h>
9
10static inline unsigned long arch_local_save_flags(void)
11{
12 unsigned long flags;
13 asm volatile ("movew %%sr,%0" : "=d" (flags) : : "memory");
14 return flags;
15}
16
17static inline void arch_local_irq_disable(void)
18{
19#ifdef CONFIG_COLDFIRE
20 asm volatile (
21 "move %/sr,%%d0 \n\t"
22 "ori.l #0x0700,%%d0 \n\t"
23 "move %%d0,%/sr \n"
24 : /* no outputs */
25 :
26 : "cc", "%d0", "memory");
27#else
28 asm volatile ("oriw #0x0700,%%sr" : : : "memory");
29#endif
30}
31
32static inline void arch_local_irq_enable(void)
33{
34#if defined(CONFIG_COLDFIRE)
35 asm volatile (
36 "move %/sr,%%d0 \n\t"
37 "andi.l #0xf8ff,%%d0 \n\t"
38 "move %%d0,%/sr \n"
39 : /* no outputs */
40 :
41 : "cc", "%d0", "memory");
42#else
43# if defined(CONFIG_MMU)
44 if (MACH_IS_Q40 || !hardirq_count())
45# endif
46 asm volatile (
47 "andiw %0,%%sr"
48 :
49 : "i" (ALLOWINT)
50 : "memory");
51#endif
52}
53
54static inline unsigned long arch_local_irq_save(void)
55{
56 unsigned long flags = arch_local_save_flags();
57 arch_local_irq_disable();
58 return flags;
59}
60
61static inline void arch_local_irq_restore(unsigned long flags)
62{
63 asm volatile ("movew %0,%%sr" : : "d" (flags) : "memory");
64}
65
66static inline bool arch_irqs_disabled_flags(unsigned long flags)
67{
68 return (flags & ~ALLOWINT) != 0;
69}
70
71static inline bool arch_irqs_disabled(void)
72{
73 return arch_irqs_disabled_flags(arch_local_save_flags());
74}
75
76#endif /* _M68K_IRQFLAGS_H */
diff --git a/arch/m68k/include/asm/m548xgpt.h b/arch/m68k/include/asm/m548xgpt.h
new file mode 100644
index 000000000000..c8ef158a1c4e
--- /dev/null
+++ b/arch/m68k/include/asm/m548xgpt.h
@@ -0,0 +1,88 @@
1/*
2 * File: m548xgpt.h
3 * Purpose: Register and bit definitions for the MCF548X
4 *
5 * Notes:
6 *
7 */
8
9#ifndef m548xgpt_h
10#define m548xgpt_h
11
12/*********************************************************************
13*
14* General Purpose Timers (GPT)
15*
16*********************************************************************/
17
18/* Register read/write macros */
19#define MCF_GPT_GMS0 0x000800
20#define MCF_GPT_GCIR0 0x000804
21#define MCF_GPT_GPWM0 0x000808
22#define MCF_GPT_GSR0 0x00080C
23#define MCF_GPT_GMS1 0x000810
24#define MCF_GPT_GCIR1 0x000814
25#define MCF_GPT_GPWM1 0x000818
26#define MCF_GPT_GSR1 0x00081C
27#define MCF_GPT_GMS2 0x000820
28#define MCF_GPT_GCIR2 0x000824
29#define MCF_GPT_GPWM2 0x000828
30#define MCF_GPT_GSR2 0x00082C
31#define MCF_GPT_GMS3 0x000830
32#define MCF_GPT_GCIR3 0x000834
33#define MCF_GPT_GPWM3 0x000838
34#define MCF_GPT_GSR3 0x00083C
35#define MCF_GPT_GMS(x) (0x000800+((x)*0x010))
36#define MCF_GPT_GCIR(x) (0x000804+((x)*0x010))
37#define MCF_GPT_GPWM(x) (0x000808+((x)*0x010))
38#define MCF_GPT_GSR(x) (0x00080C+((x)*0x010))
39
40/* Bit definitions and macros for MCF_GPT_GMS */
41#define MCF_GPT_GMS_TMS(x) (((x)&0x00000007)<<0)
42#define MCF_GPT_GMS_GPIO(x) (((x)&0x00000003)<<4)
43#define MCF_GPT_GMS_IEN (0x00000100)
44#define MCF_GPT_GMS_OD (0x00000200)
45#define MCF_GPT_GMS_SC (0x00000400)
46#define MCF_GPT_GMS_CE (0x00001000)
47#define MCF_GPT_GMS_WDEN (0x00008000)
48#define MCF_GPT_GMS_ICT(x) (((x)&0x00000003)<<16)
49#define MCF_GPT_GMS_OCT(x) (((x)&0x00000003)<<20)
50#define MCF_GPT_GMS_OCPW(x) (((x)&0x000000FF)<<24)
51#define MCF_GPT_GMS_OCT_FRCLOW (0x00000000)
52#define MCF_GPT_GMS_OCT_PULSEHI (0x00100000)
53#define MCF_GPT_GMS_OCT_PULSELO (0x00200000)
54#define MCF_GPT_GMS_OCT_TOGGLE (0x00300000)
55#define MCF_GPT_GMS_ICT_ANY (0x00000000)
56#define MCF_GPT_GMS_ICT_RISE (0x00010000)
57#define MCF_GPT_GMS_ICT_FALL (0x00020000)
58#define MCF_GPT_GMS_ICT_PULSE (0x00030000)
59#define MCF_GPT_GMS_GPIO_INPUT (0x00000000)
60#define MCF_GPT_GMS_GPIO_OUTLO (0x00000020)
61#define MCF_GPT_GMS_GPIO_OUTHI (0x00000030)
62#define MCF_GPT_GMS_TMS_DISABLE (0x00000000)
63#define MCF_GPT_GMS_TMS_INCAPT (0x00000001)
64#define MCF_GPT_GMS_TMS_OUTCAPT (0x00000002)
65#define MCF_GPT_GMS_TMS_PWM (0x00000003)
66#define MCF_GPT_GMS_TMS_GPIO (0x00000004)
67
68/* Bit definitions and macros for MCF_GPT_GCIR */
69#define MCF_GPT_GCIR_CNT(x) (((x)&0x0000FFFF)<<0)
70#define MCF_GPT_GCIR_PRE(x) (((x)&0x0000FFFF)<<16)
71
72/* Bit definitions and macros for MCF_GPT_GPWM */
73#define MCF_GPT_GPWM_LOAD (0x00000001)
74#define MCF_GPT_GPWM_PWMOP (0x00000100)
75#define MCF_GPT_GPWM_WIDTH(x) (((x)&0x0000FFFF)<<16)
76
77/* Bit definitions and macros for MCF_GPT_GSR */
78#define MCF_GPT_GSR_CAPT (0x00000001)
79#define MCF_GPT_GSR_COMP (0x00000002)
80#define MCF_GPT_GSR_PWMP (0x00000004)
81#define MCF_GPT_GSR_TEXP (0x00000008)
82#define MCF_GPT_GSR_PIN (0x00000100)
83#define MCF_GPT_GSR_OVF(x) (((x)&0x00000007)<<12)
84#define MCF_GPT_GSR_CAPTURE(x) (((x)&0x0000FFFF)<<16)
85
86/********************************************************************/
87
88#endif /* m548xgpt_h */
diff --git a/arch/m68k/include/asm/m548xsim.h b/arch/m68k/include/asm/m548xsim.h
new file mode 100644
index 000000000000..149135ef30d2
--- /dev/null
+++ b/arch/m68k/include/asm/m548xsim.h
@@ -0,0 +1,55 @@
1/*
2 * m548xsim.h -- ColdFire 547x/548x System Integration Unit support.
3 */
4
5#ifndef m548xsim_h
6#define m548xsim_h
7
8#define MCFINT_VECBASE 64
9
10/*
11 * Interrupt Controller Registers
12 */
13#define MCFICM_INTC0 0x0700 /* Base for Interrupt Ctrl 0 */
14#define MCFINTC_IPRH 0x00 /* Interrupt pending 32-63 */
15#define MCFINTC_IPRL 0x04 /* Interrupt pending 1-31 */
16#define MCFINTC_IMRH 0x08 /* Interrupt mask 32-63 */
17#define MCFINTC_IMRL 0x0c /* Interrupt mask 1-31 */
18#define MCFINTC_INTFRCH 0x10 /* Interrupt force 32-63 */
19#define MCFINTC_INTFRCL 0x14 /* Interrupt force 1-31 */
20#define MCFINTC_IRLR 0x18 /* */
21#define MCFINTC_IACKL 0x19 /* */
22#define MCFINTC_ICR0 0x40 /* Base ICR register */
23
24/*
25 * Define system peripheral IRQ usage.
26 */
27#define MCF_IRQ_TIMER (64 + 54) /* Slice Timer 0 */
28#define MCF_IRQ_PROFILER (64 + 53) /* Slice Timer 1 */
29
30/*
31 * Generic GPIO support
32 */
33#define MCFGPIO_PIN_MAX 0 /* I am too lazy to count */
34#define MCFGPIO_IRQ_MAX -1
35#define MCFGPIO_IRQ_VECBASE -1
36
37/*
38 * Some PSC related definitions
39 */
40#define MCF_PAR_PSC(x) (0x000A4F-((x)&0x3))
41#define MCF_PAR_SDA (0x0008)
42#define MCF_PAR_SCL (0x0004)
43#define MCF_PAR_PSC_TXD (0x04)
44#define MCF_PAR_PSC_RXD (0x08)
45#define MCF_PAR_PSC_RTS(x) (((x)&0x03)<<4)
46#define MCF_PAR_PSC_CTS(x) (((x)&0x03)<<6)
47#define MCF_PAR_PSC_CTS_GPIO (0x00)
48#define MCF_PAR_PSC_CTS_BCLK (0x80)
49#define MCF_PAR_PSC_CTS_CTS (0xC0)
50#define MCF_PAR_PSC_RTS_GPIO (0x00)
51#define MCF_PAR_PSC_RTS_FSYNC (0x20)
52#define MCF_PAR_PSC_RTS_RTS (0x30)
53#define MCF_PAR_PSC_CANRX (0x40)
54
55#endif /* m548xsim_h */
diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h
index fc24b6fc5508..789f3b2de0e9 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -1,5 +1,44 @@
1#ifdef __uClinux__ 1#ifndef _M68K_MACHDEP_H
2#include "machdep_no.h" 2#define _M68K_MACHDEP_H
3#else 3
4#include "machdep_mm.h" 4#include <linux/seq_file.h>
5#endif 5#include <linux/interrupt.h>
6
7struct pt_regs;
8struct mktime;
9struct rtc_time;
10struct rtc_pll_info;
11struct buffer_head;
12
13extern void (*mach_sched_init) (irq_handler_t handler);
14/* machine dependent irq functions */
15extern void (*mach_init_IRQ) (void);
16extern void (*mach_get_model) (char *model);
17extern void (*mach_get_hardware_list) (struct seq_file *m);
18/* machine dependent timer functions */
19extern unsigned long (*mach_gettimeoffset)(void);
20extern int (*mach_hwclk)(int, struct rtc_time*);
21extern unsigned int (*mach_get_ss)(void);
22extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
23extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
24extern int (*mach_set_clock_mmss)(unsigned long);
25extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour,
26 int *min, int *sec);
27extern void (*mach_reset)( void );
28extern void (*mach_halt)( void );
29extern void (*mach_power_off)( void );
30extern unsigned long (*mach_hd_init) (unsigned long, unsigned long);
31extern void (*mach_hd_setup)(char *, int *);
32extern long mach_max_dma_address;
33extern void (*mach_heartbeat) (int);
34extern void (*mach_l2_flush) (int);
35extern void (*mach_beep) (unsigned int, unsigned int);
36
37/* Hardware clock functions */
38extern void hw_timer_init(void);
39extern unsigned long hw_timer_offset(void);
40extern irqreturn_t arch_timer_interrupt(int irq, void *dummy);
41
42extern void config_BSP(char *command, int len);
43
44#endif /* _M68K_MACHDEP_H */
diff --git a/arch/m68k/include/asm/machdep_mm.h b/arch/m68k/include/asm/machdep_mm.h
deleted file mode 100644
index 5637dcef314e..000000000000
--- a/arch/m68k/include/asm/machdep_mm.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef _M68K_MACHDEP_H
2#define _M68K_MACHDEP_H
3
4#include <linux/seq_file.h>
5#include <linux/interrupt.h>
6
7struct pt_regs;
8struct mktime;
9struct rtc_time;
10struct rtc_pll_info;
11struct buffer_head;
12
13extern void (*mach_sched_init) (irq_handler_t handler);
14/* machine dependent irq functions */
15extern void (*mach_init_IRQ) (void);
16extern void (*mach_get_model) (char *model);
17extern void (*mach_get_hardware_list) (struct seq_file *m);
18/* machine dependent timer functions */
19extern unsigned long (*mach_gettimeoffset)(void);
20extern int (*mach_hwclk)(int, struct rtc_time*);
21extern unsigned int (*mach_get_ss)(void);
22extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
23extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
24extern int (*mach_set_clock_mmss)(unsigned long);
25extern void (*mach_reset)( void );
26extern void (*mach_halt)( void );
27extern void (*mach_power_off)( void );
28extern unsigned long (*mach_hd_init) (unsigned long, unsigned long);
29extern void (*mach_hd_setup)(char *, int *);
30extern long mach_max_dma_address;
31extern void (*mach_heartbeat) (int);
32extern void (*mach_l2_flush) (int);
33extern void (*mach_beep) (unsigned int, unsigned int);
34
35#endif /* _M68K_MACHDEP_H */
diff --git a/arch/m68k/include/asm/machdep_no.h b/arch/m68k/include/asm/machdep_no.h
deleted file mode 100644
index de9f47a51cc2..000000000000
--- a/arch/m68k/include/asm/machdep_no.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef _M68KNOMMU_MACHDEP_H
2#define _M68KNOMMU_MACHDEP_H
3
4#include <linux/interrupt.h>
5
6/* Hardware clock functions */
7extern void hw_timer_init(void);
8extern unsigned long hw_timer_offset(void);
9
10extern irqreturn_t arch_timer_interrupt(int irq, void *dummy);
11
12/* Machine dependent time handling */
13extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour,
14 int *min, int *sec);
15extern int (*mach_set_clock_mmss)(unsigned long);
16
17/* machine dependent power off functions */
18extern void (*mach_reset)( void );
19extern void (*mach_halt)( void );
20extern void (*mach_power_off)( void );
21
22extern void config_BSP(char *command, int len);
23
24extern void do_IRQ(int irq, struct pt_regs *fp);
25
26#endif /* _M68KNOMMU_MACHDEP_H */
diff --git a/arch/m68k/include/asm/mcfcache.h b/arch/m68k/include/asm/mcfcache.h
index c042634fadaa..f49dfc09f70a 100644
--- a/arch/m68k/include/asm/mcfcache.h
+++ b/arch/m68k/include/asm/mcfcache.h
@@ -107,7 +107,7 @@
107.endm 107.endm
108#endif /* CONFIG_M532x */ 108#endif /* CONFIG_M532x */
109 109
110#if defined(CONFIG_M5407) 110#if defined(CONFIG_M5407) || defined(CONFIG_M548x)
111/* 111/*
112 * Version 4 cores have a true harvard style separate instruction 112 * Version 4 cores have a true harvard style separate instruction
113 * and data cache. Invalidate and enable cache, also enable write 113 * and data cache. Invalidate and enable cache, also enable write
diff --git a/arch/m68k/include/asm/mcfsim.h b/arch/m68k/include/asm/mcfsim.h
index 9c70a67bf85f..6901fd68165b 100644
--- a/arch/m68k/include/asm/mcfsim.h
+++ b/arch/m68k/include/asm/mcfsim.h
@@ -41,6 +41,8 @@
41#elif defined(CONFIG_M5407) 41#elif defined(CONFIG_M5407)
42#include <asm/m5407sim.h> 42#include <asm/m5407sim.h>
43#include <asm/mcfintc.h> 43#include <asm/mcfintc.h>
44#elif defined(CONFIG_M548x)
45#include <asm/m548xsim.h>
44#endif 46#endif
45 47
46/****************************************************************************/ 48/****************************************************************************/
diff --git a/arch/m68k/include/asm/mcfslt.h b/arch/m68k/include/asm/mcfslt.h
new file mode 100644
index 000000000000..d0d0ecba5333
--- /dev/null
+++ b/arch/m68k/include/asm/mcfslt.h
@@ -0,0 +1,44 @@
1/****************************************************************************/
2
3/*
4 * mcfslt.h -- ColdFire internal Slice (SLT) timer support defines.
5 *
6 * (C) Copyright 2004, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2009, Philippe De Muyter (phdm@macqel.be)
8 */
9
10/****************************************************************************/
11#ifndef mcfslt_h
12#define mcfslt_h
13/****************************************************************************/
14
15/*
16 * Get address specific defines for the 547x.
17 */
18#define MCFSLT_TIMER0 0x900 /* Base address of TIMER0 */
19#define MCFSLT_TIMER1 0x910 /* Base address of TIMER1 */
20
21
22/*
23 * Define the SLT timer register set addresses.
24 */
25#define MCFSLT_STCNT 0x00 /* Terminal count */
26#define MCFSLT_SCR 0x04 /* Control */
27#define MCFSLT_SCNT 0x08 /* Current count */
28#define MCFSLT_SSR 0x0C /* Status */
29
30/*
31 * Bit definitions for the SCR control register.
32 */
33#define MCFSLT_SCR_RUN 0x04000000 /* Run mode (continuous) */
34#define MCFSLT_SCR_IEN 0x02000000 /* Interrupt enable */
35#define MCFSLT_SCR_TEN 0x01000000 /* Timer enable */
36
37/*
38 * Bit definitions for the SSR status register.
39 */
40#define MCFSLT_SSR_BE 0x02000000 /* Bus error condition */
41#define MCFSLT_SSR_TE 0x01000000 /* Timeout condition */
42
43/****************************************************************************/
44#endif /* mcfslt_h */
diff --git a/arch/m68k/include/asm/mcfuart.h b/arch/m68k/include/asm/mcfuart.h
index 01a8716c5fc5..db72e2b889ca 100644
--- a/arch/m68k/include/asm/mcfuart.h
+++ b/arch/m68k/include/asm/mcfuart.h
@@ -47,6 +47,11 @@
47#define MCFUART_BASE1 0xfc060000 /* Base address of UART1 */ 47#define MCFUART_BASE1 0xfc060000 /* Base address of UART1 */
48#define MCFUART_BASE2 0xfc064000 /* Base address of UART2 */ 48#define MCFUART_BASE2 0xfc064000 /* Base address of UART2 */
49#define MCFUART_BASE3 0xfc068000 /* Base address of UART3 */ 49#define MCFUART_BASE3 0xfc068000 /* Base address of UART3 */
50#elif defined(CONFIG_M548x)
51#define MCFUART_BASE1 0x8600 /* on M548x */
52#define MCFUART_BASE2 0x8700 /* on M548x */
53#define MCFUART_BASE3 0x8800 /* on M548x */
54#define MCFUART_BASE4 0x8900 /* on M548x */
50#endif 55#endif
51 56
52 57
@@ -212,7 +217,9 @@ struct mcf_platform_uart {
212#define MCFUART_URF_RXS 0xc0 /* Receiver status */ 217#define MCFUART_URF_RXS 0xc0 /* Receiver status */
213#endif 218#endif
214 219
215#if defined(CONFIG_M5272) 220#if defined(CONFIG_M548x)
221#define MCFUART_TXFIFOSIZE 512
222#elif defined(CONFIG_M5272)
216#define MCFUART_TXFIFOSIZE 25 223#define MCFUART_TXFIFOSIZE 25
217#else 224#else
218#define MCFUART_TXFIFOSIZE 1 225#define MCFUART_TXFIFOSIZE 1
diff --git a/arch/m68k/include/asm/page.h b/arch/m68k/include/asm/page.h
index f2b4480cc98a..dfebb7c1e379 100644
--- a/arch/m68k/include/asm/page.h
+++ b/arch/m68k/include/asm/page.h
@@ -1,5 +1,49 @@
1#ifdef __uClinux__ 1#ifndef _M68K_PAGE_H
2#include "page_no.h" 2#define _M68K_PAGE_H
3
4#include <linux/const.h>
5#include <asm/setup.h>
6#include <asm/page_offset.h>
7
8/* PAGE_SHIFT determines the page size */
9#ifndef CONFIG_SUN3
10#define PAGE_SHIFT (12)
3#else 11#else
12#define PAGE_SHIFT (13)
13#endif
14#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
15#define PAGE_MASK (~(PAGE_SIZE-1))
16#define PAGE_OFFSET (PAGE_OFFSET_RAW)
17
18#ifndef __ASSEMBLY__
19
20/*
21 * These are used to make use of C type-checking..
22 */
23typedef struct { unsigned long pte; } pte_t;
24typedef struct { unsigned long pmd[16]; } pmd_t;
25typedef struct { unsigned long pgd; } pgd_t;
26typedef struct { unsigned long pgprot; } pgprot_t;
27typedef struct page *pgtable_t;
28
29#define pte_val(x) ((x).pte)
30#define pmd_val(x) ((&x)->pmd[0])
31#define pgd_val(x) ((x).pgd)
32#define pgprot_val(x) ((x).pgprot)
33
34#define __pte(x) ((pte_t) { (x) } )
35#define __pmd(x) ((pmd_t) { (x) } )
36#define __pgd(x) ((pgd_t) { (x) } )
37#define __pgprot(x) ((pgprot_t) { (x) } )
38
39#endif /* !__ASSEMBLY__ */
40
41#ifdef CONFIG_MMU
4#include "page_mm.h" 42#include "page_mm.h"
43#else
44#include "page_no.h"
5#endif 45#endif
46
47#include <asm-generic/getorder.h>
48
49#endif /* _M68K_PAGE_H */
diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h
index d009f3ea39ab..31d5570d6567 100644
--- a/arch/m68k/include/asm/page_mm.h
+++ b/arch/m68k/include/asm/page_mm.h
@@ -1,29 +1,9 @@
1#ifndef _M68K_PAGE_H 1#ifndef _M68K_PAGE_MM_H
2#define _M68K_PAGE_H 2#define _M68K_PAGE_MM_H
3
4#include <linux/const.h>
5
6/* PAGE_SHIFT determines the page size */
7#ifndef CONFIG_SUN3
8#define PAGE_SHIFT (12)
9#else
10#define PAGE_SHIFT (13)
11#endif
12#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
13#define PAGE_MASK (~(PAGE_SIZE-1))
14
15#include <asm/setup.h>
16
17#if PAGE_SHIFT < 13
18#define THREAD_SIZE (8192)
19#else
20#define THREAD_SIZE PAGE_SIZE
21#endif
22 3
23#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
24 5
25#include <linux/compiler.h> 6#include <linux/compiler.h>
26
27#include <asm/module.h> 7#include <asm/module.h>
28 8
29#define get_user_page(vaddr) __get_free_page(GFP_KERNEL) 9#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
@@ -84,33 +64,6 @@ static inline void clear_page(void *page)
84 flush_dcache_page(page); \ 64 flush_dcache_page(page); \
85 } while (0) 65 } while (0)
86 66
87/*
88 * These are used to make use of C type-checking..
89 */
90typedef struct { unsigned long pte; } pte_t;
91typedef struct { unsigned long pmd[16]; } pmd_t;
92typedef struct { unsigned long pgd; } pgd_t;
93typedef struct { unsigned long pgprot; } pgprot_t;
94typedef struct page *pgtable_t;
95
96#define pte_val(x) ((x).pte)
97#define pmd_val(x) ((&x)->pmd[0])
98#define pgd_val(x) ((x).pgd)
99#define pgprot_val(x) ((x).pgprot)
100
101#define __pte(x) ((pte_t) { (x) } )
102#define __pmd(x) ((pmd_t) { (x) } )
103#define __pgd(x) ((pgd_t) { (x) } )
104#define __pgprot(x) ((pgprot_t) { (x) } )
105
106#endif /* !__ASSEMBLY__ */
107
108#include <asm/page_offset.h>
109
110#define PAGE_OFFSET (PAGE_OFFSET_RAW)
111
112#ifndef __ASSEMBLY__
113
114extern unsigned long m68k_memoffset; 67extern unsigned long m68k_memoffset;
115 68
116#ifndef CONFIG_SUN3 69#ifndef CONFIG_SUN3
@@ -127,7 +80,7 @@ static inline unsigned long ___pa(void *vaddr)
127 : "0" (vaddr), "i" (m68k_fixup_memoffset)); 80 : "0" (vaddr), "i" (m68k_fixup_memoffset));
128 return paddr; 81 return paddr;
129} 82}
130#define __pa(vaddr) ___pa((void *)(vaddr)) 83#define __pa(vaddr) ___pa((void *)(long)(vaddr))
131static inline void *__va(unsigned long paddr) 84static inline void *__va(unsigned long paddr)
132{ 85{
133 void *vaddr; 86 void *vaddr;
@@ -223,6 +176,4 @@ static inline __attribute_const__ int __virt_to_node_shift(void)
223#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 176#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
224 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 177 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
225 178
226#include <asm-generic/getorder.h> 179#endif /* _M68K_PAGE_MM_H */
227
228#endif /* _M68K_PAGE_H */
diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h
index 8029a33e03c3..90595721185f 100644
--- a/arch/m68k/include/asm/page_no.h
+++ b/arch/m68k/include/asm/page_no.h
@@ -1,18 +1,11 @@
1#ifndef _M68KNOMMU_PAGE_H 1#ifndef _M68K_PAGE_NO_H
2#define _M68KNOMMU_PAGE_H 2#define _M68K_PAGE_NO_H
3
4#include <linux/const.h>
5
6/* PAGE_SHIFT determines the page size */
7
8#define PAGE_SHIFT (12)
9#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
10#define PAGE_MASK (~(PAGE_SIZE-1))
11
12#include <asm/setup.h>
13 3
14#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
15 5
6extern unsigned long memory_start;
7extern unsigned long memory_end;
8
16#define get_user_page(vaddr) __get_free_page(GFP_KERNEL) 9#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
17#define free_user_page(page, addr) free_page(addr) 10#define free_user_page(page, addr) free_page(addr)
18 11
@@ -26,36 +19,6 @@
26 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) 19 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
27#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE 20#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
28 21
29/*
30 * These are used to make use of C type-checking..
31 */
32typedef struct { unsigned long pte; } pte_t;
33typedef struct { unsigned long pmd[16]; } pmd_t;
34typedef struct { unsigned long pgd; } pgd_t;
35typedef struct { unsigned long pgprot; } pgprot_t;
36typedef struct page *pgtable_t;
37
38#define pte_val(x) ((x).pte)
39#define pmd_val(x) ((&x)->pmd[0])
40#define pgd_val(x) ((x).pgd)
41#define pgprot_val(x) ((x).pgprot)
42
43#define __pte(x) ((pte_t) { (x) } )
44#define __pmd(x) ((pmd_t) { (x) } )
45#define __pgd(x) ((pgd_t) { (x) } )
46#define __pgprot(x) ((pgprot_t) { (x) } )
47
48extern unsigned long memory_start;
49extern unsigned long memory_end;
50
51#endif /* !__ASSEMBLY__ */
52
53#include <asm/page_offset.h>
54
55#define PAGE_OFFSET (PAGE_OFFSET_RAW)
56
57#ifndef __ASSEMBLY__
58
59#define __pa(vaddr) ((unsigned long)(vaddr)) 22#define __pa(vaddr) ((unsigned long)(vaddr))
60#define __va(paddr) ((void *)(paddr)) 23#define __va(paddr) ((void *)(paddr))
61 24
@@ -74,6 +37,4 @@ extern unsigned long memory_end;
74 37
75#endif /* __ASSEMBLY__ */ 38#endif /* __ASSEMBLY__ */
76 39
77#include <asm-generic/getorder.h> 40#endif /* _M68K_PAGE_NO_H */
78
79#endif /* _M68KNOMMU_PAGE_H */
diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h
index 2c356f90f171..2936dda938d7 100644
--- a/arch/m68k/include/asm/string.h
+++ b/arch/m68k/include/asm/string.h
@@ -1,5 +1,133 @@
1#ifdef __uClinux__ 1#ifndef _M68K_STRING_H_
2#include "string_no.h" 2#define _M68K_STRING_H_
3
4#include <linux/types.h>
5#include <linux/compiler.h>
6
7static inline size_t __kernel_strlen(const char *s)
8{
9 const char *sc;
10
11 for (sc = s; *sc++; )
12 ;
13 return sc - s - 1;
14}
15
16static inline char *__kernel_strcpy(char *dest, const char *src)
17{
18 char *xdest = dest;
19
20 asm volatile ("\n"
21 "1: move.b (%1)+,(%0)+\n"
22 " jne 1b"
23 : "+a" (dest), "+a" (src)
24 : : "memory");
25 return xdest;
26}
27
28#ifndef __IN_STRING_C
29
30#define __HAVE_ARCH_STRLEN
31#define strlen(s) (__builtin_constant_p(s) ? \
32 __builtin_strlen(s) : \
33 __kernel_strlen(s))
34
35#define __HAVE_ARCH_STRNLEN
36static inline size_t strnlen(const char *s, size_t count)
37{
38 const char *sc = s;
39
40 asm volatile ("\n"
41 "1: subq.l #1,%1\n"
42 " jcs 2f\n"
43 " tst.b (%0)+\n"
44 " jne 1b\n"
45 " subq.l #1,%0\n"
46 "2:"
47 : "+a" (sc), "+d" (count));
48 return sc - s;
49}
50
51#define __HAVE_ARCH_STRCPY
52#if __GNUC__ >= 4
53#define strcpy(d, s) (__builtin_constant_p(s) && \
54 __builtin_strlen(s) <= 32 ? \
55 __builtin_strcpy(d, s) : \
56 __kernel_strcpy(d, s))
3#else 57#else
4#include "string_mm.h" 58#define strcpy(d, s) __kernel_strcpy(d, s)
5#endif 59#endif
60
61#define __HAVE_ARCH_STRNCPY
62static inline char *strncpy(char *dest, const char *src, size_t n)
63{
64 char *xdest = dest;
65
66 asm volatile ("\n"
67 " jra 2f\n"
68 "1: move.b (%1),(%0)+\n"
69 " jeq 2f\n"
70 " addq.l #1,%1\n"
71 "2: subq.l #1,%2\n"
72 " jcc 1b\n"
73 : "+a" (dest), "+a" (src), "+d" (n)
74 : : "memory");
75 return xdest;
76}
77
78#define __HAVE_ARCH_STRCAT
79#define strcat(d, s) ({ \
80 char *__d = (d); \
81 strcpy(__d + strlen(__d), (s)); \
82})
83
84#define __HAVE_ARCH_STRCHR
85static inline char *strchr(const char *s, int c)
86{
87 char sc, ch = c;
88
89 for (; (sc = *s++) != ch; ) {
90 if (!sc)
91 return NULL;
92 }
93 return (char *)s - 1;
94}
95
96#ifndef CONFIG_COLDFIRE
97#define __HAVE_ARCH_STRCMP
98static inline int strcmp(const char *cs, const char *ct)
99{
100 char res;
101
102 asm ("\n"
103 "1: move.b (%0)+,%2\n" /* get *cs */
104 " cmp.b (%1)+,%2\n" /* compare a byte */
105 " jne 2f\n" /* not equal, break out */
106 " tst.b %2\n" /* at end of cs? */
107 " jne 1b\n" /* no, keep going */
108 " jra 3f\n" /* strings are equal */
109 "2: sub.b -(%1),%2\n" /* *cs - *ct */
110 "3:"
111 : "+a" (cs), "+a" (ct), "=d" (res));
112 return res;
113}
114
115#define __HAVE_ARCH_MEMMOVE
116extern void *memmove(void *, const void *, __kernel_size_t);
117
118#define __HAVE_ARCH_MEMCMP
119extern int memcmp(const void *, const void *, __kernel_size_t);
120#define memcmp(d, s, n) __builtin_memcmp(d, s, n)
121#endif /* CONFIG_COLDFIRE */
122
123#define __HAVE_ARCH_MEMSET
124extern void *memset(void *, int, __kernel_size_t);
125#define memset(d, c, n) __builtin_memset(d, c, n)
126
127#define __HAVE_ARCH_MEMCPY
128extern void *memcpy(void *, const void *, __kernel_size_t);
129#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
130
131#endif
132
133#endif /* _M68K_STRING_H_ */
diff --git a/arch/m68k/include/asm/string_mm.h b/arch/m68k/include/asm/string_mm.h
deleted file mode 100644
index 2eb7df1e0f5d..000000000000
--- a/arch/m68k/include/asm/string_mm.h
+++ /dev/null
@@ -1,131 +0,0 @@
1#ifndef _M68K_STRING_H_
2#define _M68K_STRING_H_
3
4#include <linux/types.h>
5#include <linux/compiler.h>
6
7static inline size_t __kernel_strlen(const char *s)
8{
9 const char *sc;
10
11 for (sc = s; *sc++; )
12 ;
13 return sc - s - 1;
14}
15
16static inline char *__kernel_strcpy(char *dest, const char *src)
17{
18 char *xdest = dest;
19
20 asm volatile ("\n"
21 "1: move.b (%1)+,(%0)+\n"
22 " jne 1b"
23 : "+a" (dest), "+a" (src)
24 : : "memory");
25 return xdest;
26}
27
28#ifndef __IN_STRING_C
29
30#define __HAVE_ARCH_STRLEN
31#define strlen(s) (__builtin_constant_p(s) ? \
32 __builtin_strlen(s) : \
33 __kernel_strlen(s))
34
35#define __HAVE_ARCH_STRNLEN
36static inline size_t strnlen(const char *s, size_t count)
37{
38 const char *sc = s;
39
40 asm volatile ("\n"
41 "1: subq.l #1,%1\n"
42 " jcs 2f\n"
43 " tst.b (%0)+\n"
44 " jne 1b\n"
45 " subq.l #1,%0\n"
46 "2:"
47 : "+a" (sc), "+d" (count));
48 return sc - s;
49}
50
51#define __HAVE_ARCH_STRCPY
52#if __GNUC__ >= 4
53#define strcpy(d, s) (__builtin_constant_p(s) && \
54 __builtin_strlen(s) <= 32 ? \
55 __builtin_strcpy(d, s) : \
56 __kernel_strcpy(d, s))
57#else
58#define strcpy(d, s) __kernel_strcpy(d, s)
59#endif
60
61#define __HAVE_ARCH_STRNCPY
62static inline char *strncpy(char *dest, const char *src, size_t n)
63{
64 char *xdest = dest;
65
66 asm volatile ("\n"
67 " jra 2f\n"
68 "1: move.b (%1),(%0)+\n"
69 " jeq 2f\n"
70 " addq.l #1,%1\n"
71 "2: subq.l #1,%2\n"
72 " jcc 1b\n"
73 : "+a" (dest), "+a" (src), "+d" (n)
74 : : "memory");
75 return xdest;
76}
77
78#define __HAVE_ARCH_STRCAT
79#define strcat(d, s) ({ \
80 char *__d = (d); \
81 strcpy(__d + strlen(__d), (s)); \
82})
83
84#define __HAVE_ARCH_STRCHR
85static inline char *strchr(const char *s, int c)
86{
87 char sc, ch = c;
88
89 for (; (sc = *s++) != ch; ) {
90 if (!sc)
91 return NULL;
92 }
93 return (char *)s - 1;
94}
95
96#define __HAVE_ARCH_STRCMP
97static inline int strcmp(const char *cs, const char *ct)
98{
99 char res;
100
101 asm ("\n"
102 "1: move.b (%0)+,%2\n" /* get *cs */
103 " cmp.b (%1)+,%2\n" /* compare a byte */
104 " jne 2f\n" /* not equal, break out */
105 " tst.b %2\n" /* at end of cs? */
106 " jne 1b\n" /* no, keep going */
107 " jra 3f\n" /* strings are equal */
108 "2: sub.b -(%1),%2\n" /* *cs - *ct */
109 "3:"
110 : "+a" (cs), "+a" (ct), "=d" (res));
111 return res;
112}
113
114#define __HAVE_ARCH_MEMSET
115extern void *memset(void *, int, __kernel_size_t);
116#define memset(d, c, n) __builtin_memset(d, c, n)
117
118#define __HAVE_ARCH_MEMCPY
119extern void *memcpy(void *, const void *, __kernel_size_t);
120#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
121
122#define __HAVE_ARCH_MEMMOVE
123extern void *memmove(void *, const void *, __kernel_size_t);
124
125#define __HAVE_ARCH_MEMCMP
126extern int memcmp(const void *, const void *, __kernel_size_t);
127#define memcmp(d, s, n) __builtin_memcmp(d, s, n)
128
129#endif
130
131#endif /* _M68K_STRING_H_ */
diff --git a/arch/m68k/include/asm/string_no.h b/arch/m68k/include/asm/string_no.h
deleted file mode 100644
index af09e17000fc..000000000000
--- a/arch/m68k/include/asm/string_no.h
+++ /dev/null
@@ -1,126 +0,0 @@
1#ifndef _M68KNOMMU_STRING_H_
2#define _M68KNOMMU_STRING_H_
3
4#ifdef __KERNEL__ /* only set these up for kernel code */
5
6#include <asm/setup.h>
7#include <asm/page.h>
8
9#define __HAVE_ARCH_STRCPY
10static inline char * strcpy(char * dest,const char *src)
11{
12 char *xdest = dest;
13
14 __asm__ __volatile__
15 ("1:\tmoveb %1@+,%0@+\n\t"
16 "jne 1b"
17 : "=a" (dest), "=a" (src)
18 : "0" (dest), "1" (src) : "memory");
19 return xdest;
20}
21
22#define __HAVE_ARCH_STRNCPY
23static inline char * strncpy(char *dest, const char *src, size_t n)
24{
25 char *xdest = dest;
26
27 if (n == 0)
28 return xdest;
29
30 __asm__ __volatile__
31 ("1:\tmoveb %1@+,%0@+\n\t"
32 "jeq 2f\n\t"
33 "subql #1,%2\n\t"
34 "jne 1b\n\t"
35 "2:"
36 : "=a" (dest), "=a" (src), "=d" (n)
37 : "0" (dest), "1" (src), "2" (n)
38 : "memory");
39 return xdest;
40}
41
42
43#ifndef CONFIG_COLDFIRE
44
45#define __HAVE_ARCH_STRCMP
46static inline int strcmp(const char * cs,const char * ct)
47{
48 char __res;
49
50 __asm__
51 ("1:\tmoveb %0@+,%2\n\t" /* get *cs */
52 "cmpb %1@+,%2\n\t" /* compare a byte */
53 "jne 2f\n\t" /* not equal, break out */
54 "tstb %2\n\t" /* at end of cs? */
55 "jne 1b\n\t" /* no, keep going */
56 "jra 3f\n\t" /* strings are equal */
57 "2:\tsubb %1@-,%2\n\t" /* *cs - *ct */
58 "3:"
59 : "=a" (cs), "=a" (ct), "=d" (__res)
60 : "0" (cs), "1" (ct));
61
62 return __res;
63}
64
65#define __HAVE_ARCH_STRNCMP
66static inline int strncmp(const char * cs,const char * ct,size_t count)
67{
68 char __res;
69
70 if (!count)
71 return 0;
72 __asm__
73 ("1:\tmovb %0@+,%3\n\t" /* get *cs */
74 "cmpb %1@+,%3\n\t" /* compare a byte */
75 "jne 3f\n\t" /* not equal, break out */
76 "tstb %3\n\t" /* at end of cs? */
77 "jeq 4f\n\t" /* yes, all done */
78 "subql #1,%2\n\t" /* no, adjust count */
79 "jne 1b\n\t" /* more to do, keep going */
80 "2:\tmoveq #0,%3\n\t" /* strings are equal */
81 "jra 4f\n\t"
82 "3:\tsubb %1@-,%3\n\t" /* *cs - *ct */
83 "4:"
84 : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res)
85 : "0" (cs), "1" (ct), "2" (count));
86 return __res;
87}
88
89#endif /* CONFIG_COLDFIRE */
90
91#define __HAVE_ARCH_MEMSET
92extern void * memset(void * s, int c, size_t count);
93
94#define __HAVE_ARCH_MEMCPY
95extern void * memcpy(void *d, const void *s, size_t count);
96
97#else /* KERNEL */
98
99/*
100 * let user libraries deal with these,
101 * IMHO the kernel has no place defining these functions for user apps
102 */
103
104#define __HAVE_ARCH_STRCPY 1
105#define __HAVE_ARCH_STRNCPY 1
106#define __HAVE_ARCH_STRCAT 1
107#define __HAVE_ARCH_STRNCAT 1
108#define __HAVE_ARCH_STRCMP 1
109#define __HAVE_ARCH_STRNCMP 1
110#define __HAVE_ARCH_STRNICMP 1
111#define __HAVE_ARCH_STRCHR 1
112#define __HAVE_ARCH_STRRCHR 1
113#define __HAVE_ARCH_STRSTR 1
114#define __HAVE_ARCH_STRLEN 1
115#define __HAVE_ARCH_STRNLEN 1
116#define __HAVE_ARCH_MEMSET 1
117#define __HAVE_ARCH_MEMCPY 1
118#define __HAVE_ARCH_MEMMOVE 1
119#define __HAVE_ARCH_MEMSCAN 1
120#define __HAVE_ARCH_MEMCMP 1
121#define __HAVE_ARCH_MEMCHR 1
122#define __HAVE_ARCH_STRTOK 1
123
124#endif /* KERNEL */
125
126#endif /* _M68K_STRING_H_ */
diff --git a/arch/m68k/include/asm/system_mm.h b/arch/m68k/include/asm/system_mm.h
index dbb6515ffd5b..47b01f4726bc 100644
--- a/arch/m68k/include/asm/system_mm.h
+++ b/arch/m68k/include/asm/system_mm.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/linkage.h> 4#include <linux/linkage.h>
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/irqflags.h>
6#include <asm/segment.h> 7#include <asm/segment.h>
7#include <asm/entry.h> 8#include <asm/entry.h>
8 9
@@ -62,30 +63,6 @@ asmlinkage void resume(void);
62#define smp_wmb() barrier() 63#define smp_wmb() barrier()
63#define smp_read_barrier_depends() ((void)0) 64#define smp_read_barrier_depends() ((void)0)
64 65
65/* interrupt control.. */
66#if 0
67#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory")
68#else
69#include <linux/hardirq.h>
70#define local_irq_enable() ({ \
71 if (MACH_IS_Q40 || !hardirq_count()) \
72 asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory"); \
73})
74#endif
75#define local_irq_disable() asm volatile ("oriw #0x0700,%%sr": : : "memory")
76#define local_save_flags(x) asm volatile ("movew %%sr,%0":"=d" (x) : : "memory")
77#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : "memory")
78
79static inline int irqs_disabled(void)
80{
81 unsigned long flags;
82 local_save_flags(flags);
83 return flags & ~ALLOWINT;
84}
85
86/* For spinlocks etc */
87#define local_irq_save(x) ({ local_save_flags(x); local_irq_disable(); })
88
89#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 66#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
90 67
91struct __xchg_dummy { unsigned long a[100]; }; 68struct __xchg_dummy { unsigned long a[100]; };
@@ -205,9 +182,7 @@ static inline unsigned long __cmpxchg(volatile void *p, unsigned long old,
205 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ 182 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
206 (unsigned long)(n), sizeof(*(ptr)))) 183 (unsigned long)(n), sizeof(*(ptr))))
207 184
208#ifndef CONFIG_SMP
209#include <asm-generic/cmpxchg.h> 185#include <asm-generic/cmpxchg.h>
210#endif
211 186
212#endif 187#endif
213 188
diff --git a/arch/m68k/include/asm/system_no.h b/arch/m68k/include/asm/system_no.h
index 3c0718d74398..6fe9f93bc3ff 100644
--- a/arch/m68k/include/asm/system_no.h
+++ b/arch/m68k/include/asm/system_no.h
@@ -2,6 +2,7 @@
2#define _M68KNOMMU_SYSTEM_H 2#define _M68KNOMMU_SYSTEM_H
3 3
4#include <linux/linkage.h> 4#include <linux/linkage.h>
5#include <linux/irqflags.h>
5#include <asm/segment.h> 6#include <asm/segment.h>
6#include <asm/entry.h> 7#include <asm/entry.h>
7 8
@@ -46,54 +47,6 @@ asmlinkage void resume(void);
46 (last) = _last; \ 47 (last) = _last; \
47} 48}
48 49
49#ifdef CONFIG_COLDFIRE
50#define local_irq_enable() __asm__ __volatile__ ( \
51 "move %/sr,%%d0\n\t" \
52 "andi.l #0xf8ff,%%d0\n\t" \
53 "move %%d0,%/sr\n" \
54 : /* no outputs */ \
55 : \
56 : "cc", "%d0", "memory")
57#define local_irq_disable() __asm__ __volatile__ ( \
58 "move %/sr,%%d0\n\t" \
59 "ori.l #0x0700,%%d0\n\t" \
60 "move %%d0,%/sr\n" \
61 : /* no outputs */ \
62 : \
63 : "cc", "%d0", "memory")
64/* For spinlocks etc */
65#define local_irq_save(x) __asm__ __volatile__ ( \
66 "movew %%sr,%0\n\t" \
67 "movew #0x0700,%%d0\n\t" \
68 "or.l %0,%%d0\n\t" \
69 "movew %%d0,%/sr" \
70 : "=d" (x) \
71 : \
72 : "cc", "%d0", "memory")
73#else
74
75/* portable version */ /* FIXME - see entry.h*/
76#define ALLOWINT 0xf8ff
77
78#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory")
79#define local_irq_disable() asm volatile ("oriw #0x0700,%%sr": : : "memory")
80#endif
81
82#define local_save_flags(x) asm volatile ("movew %%sr,%0":"=d" (x) : : "memory")
83#define local_irq_restore(x) asm volatile ("movew %0,%%sr": :"d" (x) : "memory")
84
85/* For spinlocks etc */
86#ifndef local_irq_save
87#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } while (0)
88#endif
89
90#define irqs_disabled() \
91({ \
92 unsigned long flags; \
93 local_save_flags(flags); \
94 ((flags & 0x0700) == 0x0700); \
95})
96
97#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc") 50#define iret() __asm__ __volatile__ ("rte": : :"memory", "sp", "cc")
98 51
99/* 52/*
@@ -106,17 +59,10 @@ asmlinkage void resume(void);
106#define wmb() asm volatile ("" : : :"memory") 59#define wmb() asm volatile ("" : : :"memory")
107#define set_mb(var, value) ({ (var) = (value); wmb(); }) 60#define set_mb(var, value) ({ (var) = (value); wmb(); })
108 61
109#ifdef CONFIG_SMP
110#define smp_mb() mb()
111#define smp_rmb() rmb()
112#define smp_wmb() wmb()
113#define smp_read_barrier_depends() read_barrier_depends()
114#else
115#define smp_mb() barrier() 62#define smp_mb() barrier()
116#define smp_rmb() barrier() 63#define smp_rmb() barrier()
117#define smp_wmb() barrier() 64#define smp_wmb() barrier()
118#define smp_read_barrier_depends() do { } while(0) 65#define smp_read_barrier_depends() do { } while(0)
119#endif
120 66
121#define read_barrier_depends() ((void)0) 67#define read_barrier_depends() ((void)0)
122 68
@@ -199,19 +145,9 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
199 (unsigned long)(n), sizeof(*(ptr)))) 145 (unsigned long)(n), sizeof(*(ptr))))
200#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) 146#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
201 147
202#ifndef CONFIG_SMP
203#include <asm-generic/cmpxchg.h> 148#include <asm-generic/cmpxchg.h>
204#endif
205 149
206#define arch_align_stack(x) (x) 150#define arch_align_stack(x) (x)
207 151
208 152
209static inline int irqs_disabled_flags(unsigned long flags)
210{
211 if (flags & 0x0700)
212 return 0;
213 else
214 return 1;
215}
216
217#endif /* _M68KNOMMU_SYSTEM_H */ 153#endif /* _M68KNOMMU_SYSTEM_H */
diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h
index f31a3f42b7b3..1da5d53a00eb 100644
--- a/arch/m68k/include/asm/thread_info.h
+++ b/arch/m68k/include/asm/thread_info.h
@@ -1,5 +1,108 @@
1#ifdef __uClinux__ 1#ifndef _ASM_M68K_THREAD_INFO_H
2#include "thread_info_no.h" 2#define _ASM_M68K_THREAD_INFO_H
3
4#include <asm/types.h>
5#include <asm/page.h>
6
7/*
8 * On machines with 4k pages we default to an 8k thread size, though we
9 * allow a 4k with config option. Any other machine page size then
10 * the thread size must match the page size (which is 8k and larger here).
11 */
12#if PAGE_SHIFT < 13
13#ifdef CONFIG_4KSTACKS
14#define THREAD_SIZE 4096
3#else 15#else
4#include "thread_info_mm.h" 16#define THREAD_SIZE 8192
5#endif 17#endif
18#else
19#define THREAD_SIZE PAGE_SIZE
20#endif
21#define THREAD_SIZE_ORDER ((THREAD_SIZE / PAGE_SIZE) - 1)
22
23#ifndef __ASSEMBLY__
24
25struct thread_info {
26 struct task_struct *task; /* main task structure */
27 unsigned long flags;
28 struct exec_domain *exec_domain; /* execution domain */
29 int preempt_count; /* 0 => preemptable, <0 => BUG */
30 __u32 cpu; /* should always be 0 on m68k */
31 unsigned long tp_value; /* thread pointer */
32 struct restart_block restart_block;
33};
34#endif /* __ASSEMBLY__ */
35
36#define PREEMPT_ACTIVE 0x4000000
37
38#define INIT_THREAD_INFO(tsk) \
39{ \
40 .task = &tsk, \
41 .exec_domain = &default_exec_domain, \
42 .preempt_count = INIT_PREEMPT_COUNT, \
43 .restart_block = { \
44 .fn = do_no_restart_syscall, \
45 }, \
46}
47
48#define init_stack (init_thread_union.stack)
49
50#ifdef CONFIG_MMU
51
52#ifndef __ASSEMBLY__
53#include <asm/current.h>
54#endif
55
56#ifdef ASM_OFFSETS_C
57#define task_thread_info(tsk) ((struct thread_info *) NULL)
58#else
59#include <asm/asm-offsets.h>
60#define task_thread_info(tsk) ((struct thread_info *)((char *)tsk+TASK_TINFO))
61#endif
62
63#define init_thread_info (init_task.thread.info)
64#define task_stack_page(tsk) ((tsk)->stack)
65#define current_thread_info() task_thread_info(current)
66
67#define __HAVE_THREAD_FUNCTIONS
68
69#define setup_thread_stack(p, org) ({ \
70 *(struct task_struct **)(p)->stack = (p); \
71 task_thread_info(p)->task = (p); \
72})
73
74#define end_of_stack(p) ((unsigned long *)(p)->stack + 1)
75
76#else /* !CONFIG_MMU */
77
78#ifndef __ASSEMBLY__
79/* how to get the thread information struct from C */
80static inline struct thread_info *current_thread_info(void)
81{
82 struct thread_info *ti;
83 __asm__(
84 "move.l %%sp, %0 \n\t"
85 "and.l %1, %0"
86 : "=&d"(ti)
87 : "di" (~(THREAD_SIZE-1))
88 );
89 return ti;
90}
91#endif
92
93#define init_thread_info (init_thread_union.thread_info)
94
95#endif /* CONFIG_MMU */
96
97/* entry.S relies on these definitions!
98 * bits 0-7 are tested at every exception exit
99 * bits 8-15 are also tested at syscall exit
100 */
101#define TIF_SIGPENDING 6 /* signal pending */
102#define TIF_NEED_RESCHED 7 /* rescheduling necessary */
103#define TIF_DELAYED_TRACE 14 /* single step a syscall */
104#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
105#define TIF_MEMDIE 16 /* is terminating due to OOM killer */
106#define TIF_FREEZE 17 /* thread is freezing for suspend */
107
108#endif /* _ASM_M68K_THREAD_INFO_H */
diff --git a/arch/m68k/include/asm/thread_info_mm.h b/arch/m68k/include/asm/thread_info_mm.h
deleted file mode 100644
index 3bf31dc51b12..000000000000
--- a/arch/m68k/include/asm/thread_info_mm.h
+++ /dev/null
@@ -1,71 +0,0 @@
1#ifndef _ASM_M68K_THREAD_INFO_H
2#define _ASM_M68K_THREAD_INFO_H
3
4#ifndef ASM_OFFSETS_C
5#include <asm/asm-offsets.h>
6#endif
7#include <asm/types.h>
8#include <asm/page.h>
9
10#ifndef __ASSEMBLY__
11#include <asm/current.h>
12
13struct thread_info {
14 struct task_struct *task; /* main task structure */
15 unsigned long flags;
16 struct exec_domain *exec_domain; /* execution domain */
17 int preempt_count; /* 0 => preemptable, <0 => BUG */
18 __u32 cpu; /* should always be 0 on m68k */
19 unsigned long tp_value; /* thread pointer */
20 struct restart_block restart_block;
21};
22#endif /* __ASSEMBLY__ */
23
24#define PREEMPT_ACTIVE 0x4000000
25
26#define INIT_THREAD_INFO(tsk) \
27{ \
28 .task = &tsk, \
29 .exec_domain = &default_exec_domain, \
30 .preempt_count = INIT_PREEMPT_COUNT, \
31 .restart_block = { \
32 .fn = do_no_restart_syscall, \
33 }, \
34}
35
36/* THREAD_SIZE should be 8k, so handle differently for 4k and 8k machines */
37#define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
38
39#define init_thread_info (init_task.thread.info)
40#define init_stack (init_thread_union.stack)
41
42#ifdef ASM_OFFSETS_C
43#define task_thread_info(tsk) ((struct thread_info *) NULL)
44#else
45#define task_thread_info(tsk) ((struct thread_info *)((char *)tsk+TASK_TINFO))
46#endif
47
48#define task_stack_page(tsk) ((tsk)->stack)
49#define current_thread_info() task_thread_info(current)
50
51#define __HAVE_THREAD_FUNCTIONS
52
53#define setup_thread_stack(p, org) ({ \
54 *(struct task_struct **)(p)->stack = (p); \
55 task_thread_info(p)->task = (p); \
56})
57
58#define end_of_stack(p) ((unsigned long *)(p)->stack + 1)
59
60/* entry.S relies on these definitions!
61 * bits 0-7 are tested at every exception exit
62 * bits 8-15 are also tested at syscall exit
63 */
64#define TIF_SIGPENDING 6 /* signal pending */
65#define TIF_NEED_RESCHED 7 /* rescheduling necessary */
66#define TIF_DELAYED_TRACE 14 /* single step a syscall */
67#define TIF_SYSCALL_TRACE 15 /* syscall trace active */
68#define TIF_MEMDIE 16 /* is terminating due to OOM killer */
69#define TIF_FREEZE 17 /* thread is freezing for suspend */
70
71#endif /* _ASM_M68K_THREAD_INFO_H */
diff --git a/arch/m68k/include/asm/thread_info_no.h b/arch/m68k/include/asm/thread_info_no.h
deleted file mode 100644
index 51f354b672e6..000000000000
--- a/arch/m68k/include/asm/thread_info_no.h
+++ /dev/null
@@ -1,102 +0,0 @@
1/* thread_info.h: m68knommu low-level thread information
2 * adapted from the i386 and PPC versions by Greg Ungerer (gerg@snapgear.com)
3 *
4 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
5 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6 */
7
8#ifndef _ASM_THREAD_INFO_H
9#define _ASM_THREAD_INFO_H
10
11#include <asm/page.h>
12
13#ifdef __KERNEL__
14
15/*
16 * Size of kernel stack for each process. This must be a power of 2...
17 */
18#ifdef CONFIG_4KSTACKS
19#define THREAD_SIZE_ORDER (0)
20#else
21#define THREAD_SIZE_ORDER (1)
22#endif
23
24/*
25 * for asm files, THREAD_SIZE is now generated by asm-offsets.c
26 */
27#define THREAD_SIZE (PAGE_SIZE<<THREAD_SIZE_ORDER)
28
29#ifndef __ASSEMBLY__
30
31/*
32 * low level task data.
33 */
34struct thread_info {
35 struct task_struct *task; /* main task structure */
36 struct exec_domain *exec_domain; /* execution domain */
37 unsigned long flags; /* low level flags */
38 int cpu; /* cpu we're on */
39 int preempt_count; /* 0 => preemptable, <0 => BUG */
40 unsigned long tp_value; /* thread pointer */
41 struct restart_block restart_block;
42};
43
44/*
45 * macros/functions for gaining access to the thread information structure
46 */
47#define INIT_THREAD_INFO(tsk) \
48{ \
49 .task = &tsk, \
50 .exec_domain = &default_exec_domain, \
51 .flags = 0, \
52 .cpu = 0, \
53 .preempt_count = INIT_PREEMPT_COUNT, \
54 .restart_block = { \
55 .fn = do_no_restart_syscall, \
56 }, \
57}
58
59#define init_thread_info (init_thread_union.thread_info)
60#define init_stack (init_thread_union.stack)
61
62
63/* how to get the thread information struct from C */
64static inline struct thread_info *current_thread_info(void)
65{
66 struct thread_info *ti;
67 __asm__(
68 "move.l %%sp, %0 \n\t"
69 "and.l %1, %0"
70 : "=&d"(ti)
71 : "di" (~(THREAD_SIZE-1))
72 );
73 return ti;
74}
75
76#endif /* __ASSEMBLY__ */
77
78#define PREEMPT_ACTIVE 0x4000000
79
80/*
81 * thread information flag bit numbers
82 */
83#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
84#define TIF_SIGPENDING 1 /* signal pending */
85#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
86#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
87 TIF_NEED_RESCHED */
88#define TIF_MEMDIE 4 /* is terminating due to OOM killer */
89#define TIF_FREEZE 16 /* is freezing for suspend */
90
91/* as above, but as bit values */
92#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
93#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
94#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
95#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
96#define _TIF_FREEZE (1<<TIF_FREEZE)
97
98#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
99
100#endif /* __KERNEL__ */
101
102#endif /* _ASM_THREAD_INFO_H */
diff --git a/arch/m68k/include/asm/traps.h b/arch/m68k/include/asm/traps.h
index 3011ec0f5365..0bffb17d5db7 100644
--- a/arch/m68k/include/asm/traps.h
+++ b/arch/m68k/include/asm/traps.h
@@ -1,5 +1,272 @@
1#ifdef __uClinux__ 1/*
2#include "traps_no.h" 2 * linux/include/asm/traps.h
3#else 3 *
4#include "traps_mm.h" 4 * Copyright (C) 1993 Hamish Macdonald
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _M68K_TRAPS_H
12#define _M68K_TRAPS_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/linkage.h>
17#include <asm/ptrace.h>
18
19typedef void (*e_vector)(void);
20extern e_vector vectors[];
21
22asmlinkage void auto_inthandler(void);
23asmlinkage void user_inthandler(void);
24asmlinkage void bad_inthandler(void);
25extern void init_vectors(void);
26
5#endif 27#endif
28
29#define VEC_RESETSP (0)
30#define VEC_RESETPC (1)
31#define VEC_BUSERR (2)
32#define VEC_ADDRERR (3)
33#define VEC_ILLEGAL (4)
34#define VEC_ZERODIV (5)
35#define VEC_CHK (6)
36#define VEC_TRAP (7)
37#define VEC_PRIV (8)
38#define VEC_TRACE (9)
39#define VEC_LINE10 (10)
40#define VEC_LINE11 (11)
41#define VEC_RESV12 (12)
42#define VEC_COPROC (13)
43#define VEC_FORMAT (14)
44#define VEC_UNINT (15)
45#define VEC_RESV16 (16)
46#define VEC_RESV17 (17)
47#define VEC_RESV18 (18)
48#define VEC_RESV19 (19)
49#define VEC_RESV20 (20)
50#define VEC_RESV21 (21)
51#define VEC_RESV22 (22)
52#define VEC_RESV23 (23)
53#define VEC_SPUR (24)
54#define VEC_INT1 (25)
55#define VEC_INT2 (26)
56#define VEC_INT3 (27)
57#define VEC_INT4 (28)
58#define VEC_INT5 (29)
59#define VEC_INT6 (30)
60#define VEC_INT7 (31)
61#define VEC_SYS (32)
62#define VEC_TRAP1 (33)
63#define VEC_TRAP2 (34)
64#define VEC_TRAP3 (35)
65#define VEC_TRAP4 (36)
66#define VEC_TRAP5 (37)
67#define VEC_TRAP6 (38)
68#define VEC_TRAP7 (39)
69#define VEC_TRAP8 (40)
70#define VEC_TRAP9 (41)
71#define VEC_TRAP10 (42)
72#define VEC_TRAP11 (43)
73#define VEC_TRAP12 (44)
74#define VEC_TRAP13 (45)
75#define VEC_TRAP14 (46)
76#define VEC_TRAP15 (47)
77#define VEC_FPBRUC (48)
78#define VEC_FPIR (49)
79#define VEC_FPDIVZ (50)
80#define VEC_FPUNDER (51)
81#define VEC_FPOE (52)
82#define VEC_FPOVER (53)
83#define VEC_FPNAN (54)
84#define VEC_FPUNSUP (55)
85#define VEC_MMUCFG (56)
86#define VEC_MMUILL (57)
87#define VEC_MMUACC (58)
88#define VEC_RESV59 (59)
89#define VEC_UNIMPEA (60)
90#define VEC_UNIMPII (61)
91#define VEC_RESV62 (62)
92#define VEC_RESV63 (63)
93#define VEC_USER (64)
94
95#define VECOFF(vec) ((vec)<<2)
96
97#ifndef __ASSEMBLY__
98
99/* Status register bits */
100#define PS_T (0x8000)
101#define PS_S (0x2000)
102#define PS_M (0x1000)
103#define PS_C (0x0001)
104
105/* bits for 68020/68030 special status word */
106
107#define FC (0x8000)
108#define FB (0x4000)
109#define RC (0x2000)
110#define RB (0x1000)
111#define DF (0x0100)
112#define RM (0x0080)
113#define RW (0x0040)
114#define SZ (0x0030)
115#define DFC (0x0007)
116
117/* bits for 68030 MMU status register (mmusr,psr) */
118
119#define MMU_B (0x8000) /* bus error */
120#define MMU_L (0x4000) /* limit violation */
121#define MMU_S (0x2000) /* supervisor violation */
122#define MMU_WP (0x0800) /* write-protected */
123#define MMU_I (0x0400) /* invalid descriptor */
124#define MMU_M (0x0200) /* ATC entry modified */
125#define MMU_T (0x0040) /* transparent translation */
126#define MMU_NUM (0x0007) /* number of levels traversed */
127
128
129/* bits for 68040 special status word */
130#define CP_040 (0x8000)
131#define CU_040 (0x4000)
132#define CT_040 (0x2000)
133#define CM_040 (0x1000)
134#define MA_040 (0x0800)
135#define ATC_040 (0x0400)
136#define LK_040 (0x0200)
137#define RW_040 (0x0100)
138#define SIZ_040 (0x0060)
139#define TT_040 (0x0018)
140#define TM_040 (0x0007)
141
142/* bits for 68040 write back status word */
143#define WBV_040 (0x80)
144#define WBSIZ_040 (0x60)
145#define WBBYT_040 (0x20)
146#define WBWRD_040 (0x40)
147#define WBLNG_040 (0x00)
148#define WBTT_040 (0x18)
149#define WBTM_040 (0x07)
150
151/* bus access size codes */
152#define BA_SIZE_BYTE (0x20)
153#define BA_SIZE_WORD (0x40)
154#define BA_SIZE_LONG (0x00)
155#define BA_SIZE_LINE (0x60)
156
157/* bus access transfer type codes */
158#define BA_TT_MOVE16 (0x08)
159
160/* bits for 68040 MMU status register (mmusr) */
161#define MMU_B_040 (0x0800)
162#define MMU_G_040 (0x0400)
163#define MMU_S_040 (0x0080)
164#define MMU_CM_040 (0x0060)
165#define MMU_M_040 (0x0010)
166#define MMU_WP_040 (0x0004)
167#define MMU_T_040 (0x0002)
168#define MMU_R_040 (0x0001)
169
170/* bits in the 68060 fault status long word (FSLW) */
171#define MMU060_MA (0x08000000) /* misaligned */
172#define MMU060_LK (0x02000000) /* locked transfer */
173#define MMU060_RW (0x01800000) /* read/write */
174# define MMU060_RW_W (0x00800000) /* write */
175# define MMU060_RW_R (0x01000000) /* read */
176# define MMU060_RW_RMW (0x01800000) /* read/modify/write */
177# define MMU060_W (0x00800000) /* general write, includes rmw */
178#define MMU060_SIZ (0x00600000) /* transfer size */
179#define MMU060_TT (0x00180000) /* transfer type (TT) bits */
180#define MMU060_TM (0x00070000) /* transfer modifier (TM) bits */
181#define MMU060_IO (0x00008000) /* instruction or operand */
182#define MMU060_PBE (0x00004000) /* push buffer bus error */
183#define MMU060_SBE (0x00002000) /* store buffer bus error */
184#define MMU060_PTA (0x00001000) /* pointer A fault */
185#define MMU060_PTB (0x00000800) /* pointer B fault */
186#define MMU060_IL (0x00000400) /* double indirect descr fault */
187#define MMU060_PF (0x00000200) /* page fault (invalid descr) */
188#define MMU060_SP (0x00000100) /* supervisor protection */
189#define MMU060_WP (0x00000080) /* write protection */
190#define MMU060_TWE (0x00000040) /* bus error on table search */
191#define MMU060_RE (0x00000020) /* bus error on read */
192#define MMU060_WE (0x00000010) /* bus error on write */
193#define MMU060_TTR (0x00000008) /* error caused by TTR translation */
194#define MMU060_BPE (0x00000004) /* branch prediction error */
195#define MMU060_SEE (0x00000001) /* software emulated error */
196
197/* cases of missing or invalid descriptors */
198#define MMU060_DESC_ERR (MMU060_PTA | MMU060_PTB | \
199 MMU060_IL | MMU060_PF)
200/* bits that indicate real errors */
201#define MMU060_ERR_BITS (MMU060_PBE | MMU060_SBE | MMU060_DESC_ERR | MMU060_SP | \
202 MMU060_WP | MMU060_TWE | MMU060_RE | MMU060_WE)
203
204/* structure for stack frames */
205
206struct frame {
207 struct pt_regs ptregs;
208 union {
209 struct {
210 unsigned long iaddr; /* instruction address */
211 } fmt2;
212 struct {
213 unsigned long effaddr; /* effective address */
214 } fmt3;
215 struct {
216 unsigned long effaddr; /* effective address */
217 unsigned long pc; /* pc of faulted instr */
218 } fmt4;
219 struct {
220 unsigned long effaddr; /* effective address */
221 unsigned short ssw; /* special status word */
222 unsigned short wb3s; /* write back 3 status */
223 unsigned short wb2s; /* write back 2 status */
224 unsigned short wb1s; /* write back 1 status */
225 unsigned long faddr; /* fault address */
226 unsigned long wb3a; /* write back 3 address */
227 unsigned long wb3d; /* write back 3 data */
228 unsigned long wb2a; /* write back 2 address */
229 unsigned long wb2d; /* write back 2 data */
230 unsigned long wb1a; /* write back 1 address */
231 unsigned long wb1dpd0; /* write back 1 data/push data 0*/
232 unsigned long pd1; /* push data 1*/
233 unsigned long pd2; /* push data 2*/
234 unsigned long pd3; /* push data 3*/
235 } fmt7;
236 struct {
237 unsigned long iaddr; /* instruction address */
238 unsigned short int1[4]; /* internal registers */
239 } fmt9;
240 struct {
241 unsigned short int1;
242 unsigned short ssw; /* special status word */
243 unsigned short isc; /* instruction stage c */
244 unsigned short isb; /* instruction stage b */
245 unsigned long daddr; /* data cycle fault address */
246 unsigned short int2[2];
247 unsigned long dobuf; /* data cycle output buffer */
248 unsigned short int3[2];
249 } fmta;
250 struct {
251 unsigned short int1;
252 unsigned short ssw; /* special status word */
253 unsigned short isc; /* instruction stage c */
254 unsigned short isb; /* instruction stage b */
255 unsigned long daddr; /* data cycle fault address */
256 unsigned short int2[2];
257 unsigned long dobuf; /* data cycle output buffer */
258 unsigned short int3[4];
259 unsigned long baddr; /* stage B address */
260 unsigned short int4[2];
261 unsigned long dibuf; /* data cycle input buffer */
262 unsigned short int5[3];
263 unsigned ver : 4; /* stack frame version # */
264 unsigned int6:12;
265 unsigned short int7[18];
266 } fmtb;
267 } un;
268};
269
270#endif /* __ASSEMBLY__ */
271
272#endif /* _M68K_TRAPS_H */
diff --git a/arch/m68k/include/asm/traps_mm.h b/arch/m68k/include/asm/traps_mm.h
deleted file mode 100644
index 8caef25624c7..000000000000
--- a/arch/m68k/include/asm/traps_mm.h
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * linux/include/asm/traps.h
3 *
4 * Copyright (C) 1993 Hamish Macdonald
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _M68K_TRAPS_H
12#define _M68K_TRAPS_H
13
14#ifndef __ASSEMBLY__
15
16#include <linux/linkage.h>
17#include <asm/ptrace.h>
18
19typedef void (*e_vector)(void);
20
21asmlinkage void auto_inthandler(void);
22asmlinkage void user_inthandler(void);
23asmlinkage void bad_inthandler(void);
24
25extern e_vector vectors[];
26
27#endif
28
29#define VEC_RESETSP (0)
30#define VEC_RESETPC (1)
31#define VEC_BUSERR (2)
32#define VEC_ADDRERR (3)
33#define VEC_ILLEGAL (4)
34#define VEC_ZERODIV (5)
35#define VEC_CHK (6)
36#define VEC_TRAP (7)
37#define VEC_PRIV (8)
38#define VEC_TRACE (9)
39#define VEC_LINE10 (10)
40#define VEC_LINE11 (11)
41#define VEC_RESV12 (12)
42#define VEC_COPROC (13)
43#define VEC_FORMAT (14)
44#define VEC_UNINT (15)
45#define VEC_RESV16 (16)
46#define VEC_RESV17 (17)
47#define VEC_RESV18 (18)
48#define VEC_RESV19 (19)
49#define VEC_RESV20 (20)
50#define VEC_RESV21 (21)
51#define VEC_RESV22 (22)
52#define VEC_RESV23 (23)
53#define VEC_SPUR (24)
54#define VEC_INT1 (25)
55#define VEC_INT2 (26)
56#define VEC_INT3 (27)
57#define VEC_INT4 (28)
58#define VEC_INT5 (29)
59#define VEC_INT6 (30)
60#define VEC_INT7 (31)
61#define VEC_SYS (32)
62#define VEC_TRAP1 (33)
63#define VEC_TRAP2 (34)
64#define VEC_TRAP3 (35)
65#define VEC_TRAP4 (36)
66#define VEC_TRAP5 (37)
67#define VEC_TRAP6 (38)
68#define VEC_TRAP7 (39)
69#define VEC_TRAP8 (40)
70#define VEC_TRAP9 (41)
71#define VEC_TRAP10 (42)
72#define VEC_TRAP11 (43)
73#define VEC_TRAP12 (44)
74#define VEC_TRAP13 (45)
75#define VEC_TRAP14 (46)
76#define VEC_TRAP15 (47)
77#define VEC_FPBRUC (48)
78#define VEC_FPIR (49)
79#define VEC_FPDIVZ (50)
80#define VEC_FPUNDER (51)
81#define VEC_FPOE (52)
82#define VEC_FPOVER (53)
83#define VEC_FPNAN (54)
84#define VEC_FPUNSUP (55)
85#define VEC_MMUCFG (56)
86#define VEC_MMUILL (57)
87#define VEC_MMUACC (58)
88#define VEC_RESV59 (59)
89#define VEC_UNIMPEA (60)
90#define VEC_UNIMPII (61)
91#define VEC_RESV62 (62)
92#define VEC_RESV63 (63)
93#define VEC_USER (64)
94
95#define VECOFF(vec) ((vec)<<2)
96
97#ifndef __ASSEMBLY__
98
99/* Status register bits */
100#define PS_T (0x8000)
101#define PS_S (0x2000)
102#define PS_M (0x1000)
103#define PS_C (0x0001)
104
105/* bits for 68020/68030 special status word */
106
107#define FC (0x8000)
108#define FB (0x4000)
109#define RC (0x2000)
110#define RB (0x1000)
111#define DF (0x0100)
112#define RM (0x0080)
113#define RW (0x0040)
114#define SZ (0x0030)
115#define DFC (0x0007)
116
117/* bits for 68030 MMU status register (mmusr,psr) */
118
119#define MMU_B (0x8000) /* bus error */
120#define MMU_L (0x4000) /* limit violation */
121#define MMU_S (0x2000) /* supervisor violation */
122#define MMU_WP (0x0800) /* write-protected */
123#define MMU_I (0x0400) /* invalid descriptor */
124#define MMU_M (0x0200) /* ATC entry modified */
125#define MMU_T (0x0040) /* transparent translation */
126#define MMU_NUM (0x0007) /* number of levels traversed */
127
128
129/* bits for 68040 special status word */
130#define CP_040 (0x8000)
131#define CU_040 (0x4000)
132#define CT_040 (0x2000)
133#define CM_040 (0x1000)
134#define MA_040 (0x0800)
135#define ATC_040 (0x0400)
136#define LK_040 (0x0200)
137#define RW_040 (0x0100)
138#define SIZ_040 (0x0060)
139#define TT_040 (0x0018)
140#define TM_040 (0x0007)
141
142/* bits for 68040 write back status word */
143#define WBV_040 (0x80)
144#define WBSIZ_040 (0x60)
145#define WBBYT_040 (0x20)
146#define WBWRD_040 (0x40)
147#define WBLNG_040 (0x00)
148#define WBTT_040 (0x18)
149#define WBTM_040 (0x07)
150
151/* bus access size codes */
152#define BA_SIZE_BYTE (0x20)
153#define BA_SIZE_WORD (0x40)
154#define BA_SIZE_LONG (0x00)
155#define BA_SIZE_LINE (0x60)
156
157/* bus access transfer type codes */
158#define BA_TT_MOVE16 (0x08)
159
160/* bits for 68040 MMU status register (mmusr) */
161#define MMU_B_040 (0x0800)
162#define MMU_G_040 (0x0400)
163#define MMU_S_040 (0x0080)
164#define MMU_CM_040 (0x0060)
165#define MMU_M_040 (0x0010)
166#define MMU_WP_040 (0x0004)
167#define MMU_T_040 (0x0002)
168#define MMU_R_040 (0x0001)
169
170/* bits in the 68060 fault status long word (FSLW) */
171#define MMU060_MA (0x08000000) /* misaligned */
172#define MMU060_LK (0x02000000) /* locked transfer */
173#define MMU060_RW (0x01800000) /* read/write */
174# define MMU060_RW_W (0x00800000) /* write */
175# define MMU060_RW_R (0x01000000) /* read */
176# define MMU060_RW_RMW (0x01800000) /* read/modify/write */
177# define MMU060_W (0x00800000) /* general write, includes rmw */
178#define MMU060_SIZ (0x00600000) /* transfer size */
179#define MMU060_TT (0x00180000) /* transfer type (TT) bits */
180#define MMU060_TM (0x00070000) /* transfer modifier (TM) bits */
181#define MMU060_IO (0x00008000) /* instruction or operand */
182#define MMU060_PBE (0x00004000) /* push buffer bus error */
183#define MMU060_SBE (0x00002000) /* store buffer bus error */
184#define MMU060_PTA (0x00001000) /* pointer A fault */
185#define MMU060_PTB (0x00000800) /* pointer B fault */
186#define MMU060_IL (0x00000400) /* double indirect descr fault */
187#define MMU060_PF (0x00000200) /* page fault (invalid descr) */
188#define MMU060_SP (0x00000100) /* supervisor protection */
189#define MMU060_WP (0x00000080) /* write protection */
190#define MMU060_TWE (0x00000040) /* bus error on table search */
191#define MMU060_RE (0x00000020) /* bus error on read */
192#define MMU060_WE (0x00000010) /* bus error on write */
193#define MMU060_TTR (0x00000008) /* error caused by TTR translation */
194#define MMU060_BPE (0x00000004) /* branch prediction error */
195#define MMU060_SEE (0x00000001) /* software emulated error */
196
197/* cases of missing or invalid descriptors */
198#define MMU060_DESC_ERR (MMU060_PTA | MMU060_PTB | \
199 MMU060_IL | MMU060_PF)
200/* bits that indicate real errors */
201#define MMU060_ERR_BITS (MMU060_PBE | MMU060_SBE | MMU060_DESC_ERR | MMU060_SP | \
202 MMU060_WP | MMU060_TWE | MMU060_RE | MMU060_WE)
203
204/* structure for stack frames */
205
206struct frame {
207 struct pt_regs ptregs;
208 union {
209 struct {
210 unsigned long iaddr; /* instruction address */
211 } fmt2;
212 struct {
213 unsigned long effaddr; /* effective address */
214 } fmt3;
215 struct {
216 unsigned long effaddr; /* effective address */
217 unsigned long pc; /* pc of faulted instr */
218 } fmt4;
219 struct {
220 unsigned long effaddr; /* effective address */
221 unsigned short ssw; /* special status word */
222 unsigned short wb3s; /* write back 3 status */
223 unsigned short wb2s; /* write back 2 status */
224 unsigned short wb1s; /* write back 1 status */
225 unsigned long faddr; /* fault address */
226 unsigned long wb3a; /* write back 3 address */
227 unsigned long wb3d; /* write back 3 data */
228 unsigned long wb2a; /* write back 2 address */
229 unsigned long wb2d; /* write back 2 data */
230 unsigned long wb1a; /* write back 1 address */
231 unsigned long wb1dpd0; /* write back 1 data/push data 0*/
232 unsigned long pd1; /* push data 1*/
233 unsigned long pd2; /* push data 2*/
234 unsigned long pd3; /* push data 3*/
235 } fmt7;
236 struct {
237 unsigned long iaddr; /* instruction address */
238 unsigned short int1[4]; /* internal registers */
239 } fmt9;
240 struct {
241 unsigned short int1;
242 unsigned short ssw; /* special status word */
243 unsigned short isc; /* instruction stage c */
244 unsigned short isb; /* instruction stage b */
245 unsigned long daddr; /* data cycle fault address */
246 unsigned short int2[2];
247 unsigned long dobuf; /* data cycle output buffer */
248 unsigned short int3[2];
249 } fmta;
250 struct {
251 unsigned short int1;
252 unsigned short ssw; /* special status word */
253 unsigned short isc; /* instruction stage c */
254 unsigned short isb; /* instruction stage b */
255 unsigned long daddr; /* data cycle fault address */
256 unsigned short int2[2];
257 unsigned long dobuf; /* data cycle output buffer */
258 unsigned short int3[4];
259 unsigned long baddr; /* stage B address */
260 unsigned short int4[2];
261 unsigned long dibuf; /* data cycle input buffer */
262 unsigned short int5[3];
263 unsigned ver : 4; /* stack frame version # */
264 unsigned int6:12;
265 unsigned short int7[18];
266 } fmtb;
267 } un;
268};
269
270#endif /* __ASSEMBLY__ */
271
272#endif /* _M68K_TRAPS_H */
diff --git a/arch/m68k/include/asm/traps_no.h b/arch/m68k/include/asm/traps_no.h
deleted file mode 100644
index d0671e5f8e29..000000000000
--- a/arch/m68k/include/asm/traps_no.h
+++ /dev/null
@@ -1,154 +0,0 @@
1/*
2 * linux/include/asm/traps.h
3 *
4 * Copyright (C) 1993 Hamish Macdonald
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _M68KNOMMU_TRAPS_H
12#define _M68KNOMMU_TRAPS_H
13
14#ifndef __ASSEMBLY__
15
16typedef void (*e_vector)(void);
17
18extern e_vector vectors[];
19extern void init_vectors(void);
20extern void enable_vector(unsigned int irq);
21extern void disable_vector(unsigned int irq);
22extern void ack_vector(unsigned int irq);
23
24#endif
25
26#define VEC_BUSERR (2)
27#define VEC_ADDRERR (3)
28#define VEC_ILLEGAL (4)
29#define VEC_ZERODIV (5)
30#define VEC_CHK (6)
31#define VEC_TRAP (7)
32#define VEC_PRIV (8)
33#define VEC_TRACE (9)
34#define VEC_LINE10 (10)
35#define VEC_LINE11 (11)
36#define VEC_RESV1 (12)
37#define VEC_COPROC (13)
38#define VEC_FORMAT (14)
39#define VEC_UNINT (15)
40#define VEC_SPUR (24)
41#define VEC_INT1 (25)
42#define VEC_INT2 (26)
43#define VEC_INT3 (27)
44#define VEC_INT4 (28)
45#define VEC_INT5 (29)
46#define VEC_INT6 (30)
47#define VEC_INT7 (31)
48#define VEC_SYS (32)
49#define VEC_TRAP1 (33)
50#define VEC_TRAP2 (34)
51#define VEC_TRAP3 (35)
52#define VEC_TRAP4 (36)
53#define VEC_TRAP5 (37)
54#define VEC_TRAP6 (38)
55#define VEC_TRAP7 (39)
56#define VEC_TRAP8 (40)
57#define VEC_TRAP9 (41)
58#define VEC_TRAP10 (42)
59#define VEC_TRAP11 (43)
60#define VEC_TRAP12 (44)
61#define VEC_TRAP13 (45)
62#define VEC_TRAP14 (46)
63#define VEC_TRAP15 (47)
64#define VEC_FPBRUC (48)
65#define VEC_FPIR (49)
66#define VEC_FPDIVZ (50)
67#define VEC_FPUNDER (51)
68#define VEC_FPOE (52)
69#define VEC_FPOVER (53)
70#define VEC_FPNAN (54)
71#define VEC_FPUNSUP (55)
72#define VEC_UNIMPEA (60)
73#define VEC_UNIMPII (61)
74#define VEC_USER (64)
75
76#define VECOFF(vec) ((vec)<<2)
77
78#ifndef __ASSEMBLY__
79
80/* Status register bits */
81#define PS_T (0x8000)
82#define PS_S (0x2000)
83#define PS_M (0x1000)
84#define PS_C (0x0001)
85
86/* structure for stack frames */
87
88struct frame {
89 struct pt_regs ptregs;
90 union {
91 struct {
92 unsigned long iaddr; /* instruction address */
93 } fmt2;
94 struct {
95 unsigned long effaddr; /* effective address */
96 } fmt3;
97 struct {
98 unsigned long effaddr; /* effective address */
99 unsigned long pc; /* pc of faulted instr */
100 } fmt4;
101 struct {
102 unsigned long effaddr; /* effective address */
103 unsigned short ssw; /* special status word */
104 unsigned short wb3s; /* write back 3 status */
105 unsigned short wb2s; /* write back 2 status */
106 unsigned short wb1s; /* write back 1 status */
107 unsigned long faddr; /* fault address */
108 unsigned long wb3a; /* write back 3 address */
109 unsigned long wb3d; /* write back 3 data */
110 unsigned long wb2a; /* write back 2 address */
111 unsigned long wb2d; /* write back 2 data */
112 unsigned long wb1a; /* write back 1 address */
113 unsigned long wb1dpd0; /* write back 1 data/push data 0*/
114 unsigned long pd1; /* push data 1*/
115 unsigned long pd2; /* push data 2*/
116 unsigned long pd3; /* push data 3*/
117 } fmt7;
118 struct {
119 unsigned long iaddr; /* instruction address */
120 unsigned short int1[4]; /* internal registers */
121 } fmt9;
122 struct {
123 unsigned short int1;
124 unsigned short ssw; /* special status word */
125 unsigned short isc; /* instruction stage c */
126 unsigned short isb; /* instruction stage b */
127 unsigned long daddr; /* data cycle fault address */
128 unsigned short int2[2];
129 unsigned long dobuf; /* data cycle output buffer */
130 unsigned short int3[2];
131 } fmta;
132 struct {
133 unsigned short int1;
134 unsigned short ssw; /* special status word */
135 unsigned short isc; /* instruction stage c */
136 unsigned short isb; /* instruction stage b */
137 unsigned long daddr; /* data cycle fault address */
138 unsigned short int2[2];
139 unsigned long dobuf; /* data cycle output buffer */
140 unsigned short int3[4];
141 unsigned long baddr; /* stage B address */
142 unsigned short int4[2];
143 unsigned long dibuf; /* data cycle input buffer */
144 unsigned short int5[3];
145 unsigned ver : 4; /* stack frame version # */
146 unsigned int6:12;
147 unsigned short int7[18];
148 } fmtb;
149 } un;
150};
151
152#endif /* __ASSEMBLY__ */
153
154#endif /* _M68KNOMMU_TRAPS_H */
diff --git a/arch/m68k/kernel/asm-offsets.c b/arch/m68k/kernel/asm-offsets.c
index 73e5e581245b..78e59b82ebc3 100644
--- a/arch/m68k/kernel/asm-offsets.c
+++ b/arch/m68k/kernel/asm-offsets.c
@@ -22,13 +22,9 @@
22int main(void) 22int main(void)
23{ 23{
24 /* offsets into the task struct */ 24 /* offsets into the task struct */
25 DEFINE(TASK_STATE, offsetof(struct task_struct, state));
26 DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
27 DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
28 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); 25 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
29 DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info)); 26 DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info));
30 DEFINE(TASK_MM, offsetof(struct task_struct, mm)); 27 DEFINE(TASK_MM, offsetof(struct task_struct, mm));
31 DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
32#ifdef CONFIG_MMU 28#ifdef CONFIG_MMU
33 DEFINE(TASK_TINFO, offsetof(struct task_struct, thread.info)); 29 DEFINE(TASK_TINFO, offsetof(struct task_struct, thread.info));
34#endif 30#endif
@@ -64,14 +60,6 @@ int main(void)
64 /* bitfields are a bit difficult */ 60 /* bitfields are a bit difficult */
65 DEFINE(PT_OFF_FORMATVEC, offsetof(struct pt_regs, pc) + 4); 61 DEFINE(PT_OFF_FORMATVEC, offsetof(struct pt_regs, pc) + 4);
66 62
67 /* offsets into the irq_handler struct */
68 DEFINE(IRQ_HANDLER, offsetof(struct irq_node, handler));
69 DEFINE(IRQ_DEVID, offsetof(struct irq_node, dev_id));
70 DEFINE(IRQ_NEXT, offsetof(struct irq_node, next));
71
72 /* offsets into the kernel_stat struct */
73 DEFINE(STAT_IRQ, offsetof(struct kernel_stat, irqs));
74
75 /* offsets into the irq_cpustat_t struct */ 63 /* offsets into the irq_cpustat_t struct */
76 DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending)); 64 DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
77 65
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index 303730afb1c9..b3963ab3d149 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -359,12 +359,6 @@ void __init setup_arch(char **cmdline_p)
359 isa_type = ISA_TYPE_Q40; 359 isa_type = ISA_TYPE_Q40;
360 isa_sex = 0; 360 isa_sex = 0;
361 } 361 }
362#ifdef CONFIG_GG2
363 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(GG2_ISA)) {
364 isa_type = ISA_TYPE_GG2;
365 isa_sex = 0;
366 }
367#endif
368#ifdef CONFIG_AMIGA_PCMCIA 362#ifdef CONFIG_AMIGA_PCMCIA
369 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) { 363 if (MACH_IS_AMIGA && AMIGAHW_PRESENT(PCMCIA)) {
370 isa_type = ISA_TYPE_AG; 364 isa_type = ISA_TYPE_AG;
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 2f431ece7b5f..3db2e7f902aa 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -12,7 +12,6 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/smp.h> 14#include <linux/smp.h>
15#include <linux/smp_lock.h>
16#include <linux/sem.h> 15#include <linux/sem.h>
17#include <linux/msg.h> 16#include <linux/msg.h>
18#include <linux/shm.h> 17#include <linux/shm.h>
@@ -377,7 +376,6 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
377 struct vm_area_struct *vma; 376 struct vm_area_struct *vma;
378 int ret = -EINVAL; 377 int ret = -EINVAL;
379 378
380 lock_kernel();
381 if (scope < FLUSH_SCOPE_LINE || scope > FLUSH_SCOPE_ALL || 379 if (scope < FLUSH_SCOPE_LINE || scope > FLUSH_SCOPE_ALL ||
382 cache & ~FLUSH_CACHE_BOTH) 380 cache & ~FLUSH_CACHE_BOTH)
383 goto out; 381 goto out;
@@ -446,7 +444,6 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
446 } 444 }
447 } 445 }
448out: 446out:
449 unlock_kernel();
450 return ret; 447 return ret;
451} 448}
452 449
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 4926b3856c15..06438dac08ff 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -42,9 +42,7 @@ static inline int set_rtc_mmss(unsigned long nowtime)
42static irqreturn_t timer_interrupt(int irq, void *dummy) 42static irqreturn_t timer_interrupt(int irq, void *dummy)
43{ 43{
44 do_timer(1); 44 do_timer(1);
45#ifndef CONFIG_SMP
46 update_process_times(user_mode(get_irq_regs())); 45 update_process_times(user_mode(get_irq_regs()));
47#endif
48 profile_tick(CPU_PROFILING); 46 profile_tick(CPU_PROFILING);
49 47
50#ifdef CONFIG_HEARTBEAT 48#ifdef CONFIG_HEARTBEAT
diff --git a/arch/m68k/mac/macboing.c b/arch/m68k/mac/macboing.c
index 8f0640847ad2..ffaa1f6439ae 100644
--- a/arch/m68k/mac/macboing.c
+++ b/arch/m68k/mac/macboing.c
@@ -114,7 +114,8 @@ static void mac_init_asc( void )
114 * 16-bit I/O functionality. The PowerBook 500 series computers 114 * 16-bit I/O functionality. The PowerBook 500 series computers
115 * support 16-bit stereo output, but only mono input." 115 * support 16-bit stereo output, but only mono input."
116 * 116 *
117 * http://til.info.apple.com/techinfo.nsf/artnum/n16405 117 * Technical Information Library (TIL) article number 16405.
118 * http://support.apple.com/kb/TA32601
118 * 119 *
119 * --David Kilzer 120 * --David Kilzer
120 */ 121 */
@@ -162,7 +163,7 @@ static void mac_init_asc( void )
162void mac_mksound( unsigned int freq, unsigned int length ) 163void mac_mksound( unsigned int freq, unsigned int length )
163{ 164{
164 __u32 cfreq = ( freq << 5 ) / 468; 165 __u32 cfreq = ( freq << 5 ) / 468;
165 __u32 flags; 166 unsigned long flags;
166 int i; 167 int i;
167 168
168 if ( mac_special_bell == NULL ) 169 if ( mac_special_bell == NULL )
@@ -224,7 +225,7 @@ static void mac_nosound( unsigned long ignored )
224 */ 225 */
225static void mac_quadra_start_bell( unsigned int freq, unsigned int length, unsigned int volume ) 226static void mac_quadra_start_bell( unsigned int freq, unsigned int length, unsigned int volume )
226{ 227{
227 __u32 flags; 228 unsigned long flags;
228 229
229 /* if the bell is already ringing, ring longer */ 230 /* if the bell is already ringing, ring longer */
230 if ( mac_bell_duration > 0 ) 231 if ( mac_bell_duration > 0 )
@@ -271,7 +272,7 @@ static void mac_quadra_start_bell( unsigned int freq, unsigned int length, unsig
271static void mac_quadra_ring_bell( unsigned long ignored ) 272static void mac_quadra_ring_bell( unsigned long ignored )
272{ 273{
273 int i, count = mac_asc_samplespersec / HZ; 274 int i, count = mac_asc_samplespersec / HZ;
274 __u32 flags; 275 unsigned long flags;
275 276
276 /* 277 /*
277 * we neither want a sound buffer overflow nor underflow, so we need to match 278 * we neither want a sound buffer overflow nor underflow, so we need to match
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 11ac6f63967a..39c79ebcd18a 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -144,6 +144,7 @@ static const struct file_operations rtc_fops = {
144 .unlocked_ioctl = rtc_ioctl, 144 .unlocked_ioctl = rtc_ioctl,
145 .open = rtc_open, 145 .open = rtc_open,
146 .release = rtc_release, 146 .release = rtc_release,
147 .llseek = noop_llseek,
147}; 148};
148 149
149static struct miscdevice rtc_dev= 150static struct miscdevice rtc_dev=
diff --git a/arch/m68k/q40/README b/arch/m68k/q40/README
index 6bdbf4879570..f877b7249790 100644
--- a/arch/m68k/q40/README
+++ b/arch/m68k/q40/README
@@ -3,7 +3,7 @@ Linux for the Q40
3 3
4You may try http://www.geocities.com/SiliconValley/Bay/2602/ for 4You may try http://www.geocities.com/SiliconValley/Bay/2602/ for
5some up to date information. Booter and other tools will be also 5some up to date information. Booter and other tools will be also
6available from this place or ftp.uni-erlangen.de/linux/680x0/q40/ 6available from this place or http://ftp.uni-erlangen.de/pub/unix/Linux/680x0/q40/
7and mirrors. 7and mirrors.
8 8
9Hints to documentation usually refer to the linux source tree in 9Hints to documentation usually refer to the linux source tree in
diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
index ad90393a3361..2d9e21bd313a 100644
--- a/arch/m68k/sun3/sun3ints.c
+++ b/arch/m68k/sun3/sun3ints.c
@@ -67,9 +67,7 @@ static irqreturn_t sun3_int5(int irq, void *dev_id)
67 intersil_clear(); 67 intersil_clear();
68#endif 68#endif
69 do_timer(1); 69 do_timer(1);
70#ifndef CONFIG_SMP
71 update_process_times(user_mode(get_irq_regs())); 70 update_process_times(user_mode(get_irq_regs()));
72#endif
73 if (!(kstat_cpu(0).irqs[irq] % 20)) 71 if (!(kstat_cpu(0).irqs[irq] % 20))
74 sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]); 72 sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]);
75 return IRQ_HANDLED; 73 return IRQ_HANDLED;
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index 2609c394e1df..9287150e5fb0 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -59,6 +59,10 @@ config GENERIC_HARDIRQS
59 bool 59 bool
60 default y 60 default y
61 61
62config GENERIC_HARDIRQS_NO__DO_IRQ
63 bool
64 default y
65
62config GENERIC_CALIBRATE_DELAY 66config GENERIC_CALIBRATE_DELAY
63 bool 67 bool
64 default y 68 default y
@@ -171,6 +175,11 @@ config M5407
171 help 175 help
172 Motorola ColdFire 5407 processor support. 176 Motorola ColdFire 5407 processor support.
173 177
178config M548x
179 bool "MCF548x"
180 help
181 Freescale ColdFire 5480/5481/5482/5483/5484/5485 processor support.
182
174endchoice 183endchoice
175 184
176config M527x 185config M527x
@@ -181,7 +190,7 @@ config M527x
181 190
182config COLDFIRE 191config COLDFIRE
183 bool 192 bool
184 depends on (M5206 || M5206e || M520x || M523x || M5249 || M527x || M5272 || M528x || M5307 || M532x || M5407) 193 depends on (M5206 || M5206e || M520x || M523x || M5249 || M527x || M5272 || M528x || M5307 || M532x || M5407 || M548x)
185 select GENERIC_GPIO 194 select GENERIC_GPIO
186 select ARCH_REQUIRE_GPIOLIB 195 select ARCH_REQUIRE_GPIOLIB
187 default y 196 default y
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index 14042574ac21..026ef16fa68e 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -25,6 +25,7 @@ platform-$(CONFIG_M528x) := 528x
25platform-$(CONFIG_M5307) := 5307 25platform-$(CONFIG_M5307) := 5307
26platform-$(CONFIG_M532x) := 532x 26platform-$(CONFIG_M532x) := 532x
27platform-$(CONFIG_M5407) := 5407 27platform-$(CONFIG_M5407) := 5407
28platform-$(CONFIG_M548x) := 548x
28PLATFORM := $(platform-y) 29PLATFORM := $(platform-y)
29 30
30board-$(CONFIG_PILOT) := pilot 31board-$(CONFIG_PILOT) := pilot
@@ -73,6 +74,7 @@ cpuclass-$(CONFIG_M528x) := coldfire
73cpuclass-$(CONFIG_M5307) := coldfire 74cpuclass-$(CONFIG_M5307) := coldfire
74cpuclass-$(CONFIG_M532x) := coldfire 75cpuclass-$(CONFIG_M532x) := coldfire
75cpuclass-$(CONFIG_M5407) := coldfire 76cpuclass-$(CONFIG_M5407) := coldfire
77cpuclass-$(CONFIG_M548x) := coldfire
76cpuclass-$(CONFIG_M68328) := 68328 78cpuclass-$(CONFIG_M68328) := 68328
77cpuclass-$(CONFIG_M68EZ328) := 68328 79cpuclass-$(CONFIG_M68EZ328) := 68328
78cpuclass-$(CONFIG_M68VZ328) := 68328 80cpuclass-$(CONFIG_M68VZ328) := 68328
@@ -100,6 +102,7 @@ cflags-$(CONFIG_M528x) := $(call cc-option,-m528x,-m5307)
100cflags-$(CONFIG_M5307) := $(call cc-option,-m5307,-m5200) 102cflags-$(CONFIG_M5307) := $(call cc-option,-m5307,-m5200)
101cflags-$(CONFIG_M532x) := $(call cc-option,-mcpu=532x,-m5307) 103cflags-$(CONFIG_M532x) := $(call cc-option,-mcpu=532x,-m5307)
102cflags-$(CONFIG_M5407) := $(call cc-option,-m5407,-m5200) 104cflags-$(CONFIG_M5407) := $(call cc-option,-m5407,-m5200)
105cflags-$(CONFIG_M548x) := $(call cc-option,-m5407,-m5200)
103cflags-$(CONFIG_M68328) := -m68000 106cflags-$(CONFIG_M68328) := -m68000
104cflags-$(CONFIG_M68EZ328) := -m68000 107cflags-$(CONFIG_M68EZ328) := -m68000
105cflags-$(CONFIG_M68VZ328) := -m68000 108cflags-$(CONFIG_M68VZ328) := -m68000
diff --git a/arch/m68knommu/kernel/.gitignore b/arch/m68knommu/kernel/.gitignore
new file mode 100644
index 000000000000..c5f676c3c224
--- /dev/null
+++ b/arch/m68knommu/kernel/.gitignore
@@ -0,0 +1 @@
vmlinux.lds
diff --git a/arch/m68knommu/kernel/asm-offsets.c b/arch/m68knommu/kernel/asm-offsets.c
index 9a8876f715d8..ffe02f41ad46 100644
--- a/arch/m68knommu/kernel/asm-offsets.c
+++ b/arch/m68knommu/kernel/asm-offsets.c
@@ -21,14 +21,8 @@
21int main(void) 21int main(void)
22{ 22{
23 /* offsets into the task struct */ 23 /* offsets into the task struct */
24 DEFINE(TASK_STATE, offsetof(struct task_struct, state));
25 DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
26 DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
27 DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
28 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); 24 DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
29 DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, stack));
30 DEFINE(TASK_MM, offsetof(struct task_struct, mm)); 25 DEFINE(TASK_MM, offsetof(struct task_struct, mm));
31 DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
32 26
33 /* offsets into the irq_cpustat_t struct */ 27 /* offsets into the irq_cpustat_t struct */
34 DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending)); 28 DEFINE(CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
@@ -63,7 +57,7 @@ int main(void)
63 DEFINE(PT_OFF_FORMATVEC, offsetof(struct pt_regs, sr) - 2); 57 DEFINE(PT_OFF_FORMATVEC, offsetof(struct pt_regs, sr) - 2);
64#else 58#else
65 /* bitfields are a bit difficult */ 59 /* bitfields are a bit difficult */
66 DEFINE(PT_OFF_VECTOR, offsetof(struct pt_regs, pc) + 4); 60 DEFINE(PT_OFF_FORMATVEC, offsetof(struct pt_regs, pc) + 4);
67#endif 61#endif
68 62
69 /* signal defines */ 63 /* signal defines */
@@ -74,14 +68,9 @@ int main(void)
74 68
75 DEFINE(PT_PTRACED, PT_PTRACED); 69 DEFINE(PT_PTRACED, PT_PTRACED);
76 70
77 DEFINE(THREAD_SIZE, THREAD_SIZE);
78
79 /* Offsets in thread_info structure */ 71 /* Offsets in thread_info structure */
80 DEFINE(TI_TASK, offsetof(struct thread_info, task));
81 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
82 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); 72 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
83 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count)); 73 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count));
84 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
85 74
86 return 0; 75 return 0;
87} 76}
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index f6be1248d216..6fe7c38cd556 100644
--- a/arch/m68knommu/kernel/ptrace.c
+++ b/arch/m68knommu/kernel/ptrace.c
@@ -18,6 +18,7 @@
18#include <linux/ptrace.h> 18#include <linux/ptrace.h>
19#include <linux/user.h> 19#include <linux/user.h>
20#include <linux/signal.h> 20#include <linux/signal.h>
21#include <linux/tracehook.h>
21 22
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include <asm/page.h> 24#include <asm/page.h>
@@ -134,14 +135,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
134 tmp >>= 16; 135 tmp >>= 16;
135 } else if (addr >= 21 && addr < 49) { 136 } else if (addr >= 21 && addr < 49) {
136 tmp = child->thread.fp[addr - 21]; 137 tmp = child->thread.fp[addr - 21];
137#ifdef CONFIG_M68KFPU_EMU
138 /* Convert internal fpu reg representation
139 * into long double format
140 */
141 if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
142 tmp = ((tmp & 0xffff0000) << 15) |
143 ((tmp & 0x0000ffff) << 16);
144#endif
145 } else if (addr == 49) { 138 } else if (addr == 49) {
146 tmp = child->mm->start_code; 139 tmp = child->mm->start_code;
147 } else if (addr == 50) { 140 } else if (addr == 50) {
@@ -175,16 +168,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
175 } 168 }
176 if (addr >= 21 && addr < 48) 169 if (addr >= 21 && addr < 48)
177 { 170 {
178#ifdef CONFIG_M68KFPU_EMU
179 /* Convert long double format
180 * into internal fpu reg representation
181 */
182 if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
183 data = (unsigned long)data << 15;
184 data = (data & 0xffff0000) |
185 ((data & 0x0000ffff) >> 1);
186 }
187#endif
188 child->thread.fp[addr - 21] = data; 171 child->thread.fp[addr - 21] = data;
189 ret = 0; 172 ret = 0;
190 } 173 }
@@ -259,21 +242,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
259 return ret; 242 return ret;
260} 243}
261 244
262asmlinkage void syscall_trace(void) 245asmlinkage int syscall_trace_enter(void)
263{ 246{
264 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 247 int ret = 0;
265 return; 248
266 if (!(current->ptrace & PT_PTRACED)) 249 if (test_thread_flag(TIF_SYSCALL_TRACE))
267 return; 250 ret = tracehook_report_syscall_entry(task_pt_regs(current));
268 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) 251 return ret;
269 ? 0x80 : 0)); 252}
270 /* 253
271 * this isn't the same as continuing with a signal, but it will do 254asmlinkage void syscall_trace_leave(void)
272 * for normal use. strace only continues with a signal if the 255{
273 * stopping signal is not SIGTRAP. -brl 256 if (test_thread_flag(TIF_SYSCALL_TRACE))
274 */ 257 tracehook_report_syscall_exit(task_pt_regs(current), 0);
275 if (current->exit_code) {
276 send_sig(current->exit_code, current, 1);
277 current->exit_code = 0;
278 }
279} 258}
diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c
index ba92b90d5fbc..c684adf5dc40 100644
--- a/arch/m68knommu/kernel/setup.c
+++ b/arch/m68knommu/kernel/setup.c
@@ -54,9 +54,6 @@ void (*mach_reset)(void);
54void (*mach_halt)(void); 54void (*mach_halt)(void);
55void (*mach_power_off)(void); 55void (*mach_power_off)(void);
56 56
57#ifdef CONFIG_M68000
58 #define CPU "MC68000"
59#endif
60#ifdef CONFIG_M68328 57#ifdef CONFIG_M68328
61 #define CPU "MC68328" 58 #define CPU "MC68328"
62#endif 59#endif
diff --git a/arch/m68knommu/kernel/time.c b/arch/m68knommu/kernel/time.c
index a90acf5b0cde..d6ac2a43453c 100644
--- a/arch/m68knommu/kernel/time.c
+++ b/arch/m68knommu/kernel/time.c
@@ -50,9 +50,8 @@ irqreturn_t arch_timer_interrupt(int irq, void *dummy)
50 50
51 write_sequnlock(&xtime_lock); 51 write_sequnlock(&xtime_lock);
52 52
53#ifndef CONFIG_SMP
54 update_process_times(user_mode(get_irq_regs())); 53 update_process_times(user_mode(get_irq_regs()));
55#endif 54
56 return(IRQ_HANDLED); 55 return(IRQ_HANDLED);
57} 56}
58#endif 57#endif
@@ -61,13 +60,16 @@ static unsigned long read_rtc_mmss(void)
61{ 60{
62 unsigned int year, mon, day, hour, min, sec; 61 unsigned int year, mon, day, hour, min, sec;
63 62
64 if (mach_gettod) 63 if (mach_gettod) {
65 mach_gettod(&year, &mon, &day, &hour, &min, &sec); 64 mach_gettod(&year, &mon, &day, &hour, &min, &sec);
66 else 65 if ((year += 1900) < 1970)
67 year = mon = day = hour = min = sec = 0; 66 year += 100;
67 } else {
68 year = 1970;
69 mon = day = 1;
70 hour = min = sec = 0;
71 }
68 72
69 if ((year += 1900) < 1970)
70 year += 100;
71 73
72 return mktime(year, mon, day, hour, min, sec); 74 return mktime(year, mon, day, hour, min, sec);
73} 75}
diff --git a/arch/m68knommu/kernel/traps.c b/arch/m68knommu/kernel/traps.c
index 3739c8f657d7..a768008dfd06 100644
--- a/arch/m68knommu/kernel/traps.c
+++ b/arch/m68knommu/kernel/traps.c
@@ -179,14 +179,16 @@ static void __show_stack(struct task_struct *task, unsigned long *stack)
179 179
180void bad_super_trap(struct frame *fp) 180void bad_super_trap(struct frame *fp)
181{ 181{
182 int vector = (fp->ptregs.vector >> 2) & 0xff;
183
182 console_verbose(); 184 console_verbose();
183 if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names)) 185 if (vector < ARRAY_SIZE(vec_names))
184 printk (KERN_WARNING "*** %s *** FORMAT=%X\n", 186 printk (KERN_WARNING "*** %s *** FORMAT=%X\n",
185 vec_names[(fp->ptregs.vector) >> 2], 187 vec_names[vector],
186 fp->ptregs.format); 188 fp->ptregs.format);
187 else 189 else
188 printk (KERN_WARNING "*** Exception %d *** FORMAT=%X\n", 190 printk (KERN_WARNING "*** Exception %d *** FORMAT=%X\n",
189 (fp->ptregs.vector) >> 2, 191 vector,
190 fp->ptregs.format); 192 fp->ptregs.format);
191 printk (KERN_WARNING "Current process id is %d\n", current->pid); 193 printk (KERN_WARNING "Current process id is %d\n", current->pid);
192 die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0); 194 die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
@@ -195,10 +197,11 @@ void bad_super_trap(struct frame *fp)
195asmlinkage void trap_c(struct frame *fp) 197asmlinkage void trap_c(struct frame *fp)
196{ 198{
197 int sig; 199 int sig;
200 int vector = (fp->ptregs.vector >> 2) & 0xff;
198 siginfo_t info; 201 siginfo_t info;
199 202
200 if (fp->ptregs.sr & PS_S) { 203 if (fp->ptregs.sr & PS_S) {
201 if ((fp->ptregs.vector >> 2) == VEC_TRACE) { 204 if (vector == VEC_TRACE) {
202 /* traced a trapping instruction */ 205 /* traced a trapping instruction */
203 } else 206 } else
204 bad_super_trap(fp); 207 bad_super_trap(fp);
@@ -206,7 +209,7 @@ asmlinkage void trap_c(struct frame *fp)
206 } 209 }
207 210
208 /* send the appropriate signal to the user program */ 211 /* send the appropriate signal to the user program */
209 switch ((fp->ptregs.vector) >> 2) { 212 switch (vector) {
210 case VEC_ADDRERR: 213 case VEC_ADDRERR:
211 info.si_code = BUS_ADRALN; 214 info.si_code = BUS_ADRALN;
212 sig = SIGBUS; 215 sig = SIGBUS;
@@ -360,16 +363,3 @@ void show_stack(struct task_struct *task, unsigned long *stack)
360 else 363 else
361 __show_stack(task, stack); 364 __show_stack(task, stack);
362} 365}
363
364#ifdef CONFIG_M68KFPU_EMU
365asmlinkage void fpemu_signal(int signal, int code, void *addr)
366{
367 siginfo_t info;
368
369 info.si_signo = signal;
370 info.si_errno = 0;
371 info.si_code = code;
372 info.si_addr = addr;
373 force_sig_info(signal, &info, current);
374}
375#endif
diff --git a/arch/m68knommu/platform/5206/Makefile b/arch/m68knommu/platform/5206/Makefile
index 113c33390064..b5db05625cfa 100644
--- a/arch/m68knommu/platform/5206/Makefile
+++ b/arch/m68knommu/platform/5206/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5206e/Makefile b/arch/m68knommu/platform/5206e/Makefile
index 113c33390064..b5db05625cfa 100644
--- a/arch/m68knommu/platform/5206e/Makefile
+++ b/arch/m68knommu/platform/5206e/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/520x/Makefile b/arch/m68knommu/platform/520x/Makefile
index 435ab3483dc1..ad3f4e5a57ce 100644
--- a/arch/m68knommu/platform/520x/Makefile
+++ b/arch/m68knommu/platform/520x/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/523x/Makefile b/arch/m68knommu/platform/523x/Makefile
index b8f9b45440c2..c04b8f71c88c 100644
--- a/arch/m68knommu/platform/523x/Makefile
+++ b/arch/m68knommu/platform/523x/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5249/Makefile b/arch/m68knommu/platform/5249/Makefile
index f56225d1582f..4bed30fd0073 100644
--- a/arch/m68knommu/platform/5249/Makefile
+++ b/arch/m68knommu/platform/5249/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5272/Makefile b/arch/m68knommu/platform/5272/Makefile
index 93673ef8e2c1..34110fc14301 100644
--- a/arch/m68knommu/platform/5272/Makefile
+++ b/arch/m68knommu/platform/5272/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
index 59278c0887d0..65bb582734e1 100644
--- a/arch/m68knommu/platform/5272/config.c
+++ b/arch/m68knommu/platform/5272/config.c
@@ -13,6 +13,8 @@
13#include <linux/param.h> 13#include <linux/param.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/phy.h>
17#include <linux/phy_fixed.h>
16#include <asm/machdep.h> 18#include <asm/machdep.h>
17#include <asm/coldfire.h> 19#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 20#include <asm/mcfsim.h>
@@ -148,9 +150,23 @@ void __init config_BSP(char *commandp, int size)
148 150
149/***************************************************************************/ 151/***************************************************************************/
150 152
153/*
154 * Some 5272 based boards have the FEC ethernet diectly connected to
155 * an ethernet switch. In this case we need to use the fixed phy type,
156 * and we need to declare it early in boot.
157 */
158static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
159 .link = 1,
160 .speed = 100,
161 .duplex = 0,
162};
163
164/***************************************************************************/
165
151static int __init init_BSP(void) 166static int __init init_BSP(void)
152{ 167{
153 m5272_uarts_init(); 168 m5272_uarts_init();
169 fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
154 platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices)); 170 platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
155 return 0; 171 return 0;
156} 172}
diff --git a/arch/m68knommu/platform/5272/intc.c b/arch/m68knommu/platform/5272/intc.c
index 7081e0a9720e..3cf681c177aa 100644
--- a/arch/m68knommu/platform/5272/intc.c
+++ b/arch/m68knommu/platform/5272/intc.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/kernel_stat.h>
15#include <linux/irq.h> 16#include <linux/irq.h>
16#include <linux/io.h> 17#include <linux/io.h>
17#include <asm/coldfire.h> 18#include <asm/coldfire.h>
@@ -29,6 +30,10 @@
29 * via a set of 4 "Interrupt Controller Registers" (ICR). There is a 30 * via a set of 4 "Interrupt Controller Registers" (ICR). There is a
30 * loose mapping of vector number to register and internal bits, but 31 * loose mapping of vector number to register and internal bits, but
31 * a table is the easiest and quickest way to map them. 32 * a table is the easiest and quickest way to map them.
33 *
34 * Note that the external interrupts are edge triggered (unlike the
35 * internal interrupt sources which are level triggered). Which means
36 * they also need acknowledgeing via acknowledge bits.
32 */ 37 */
33struct irqmap { 38struct irqmap {
34 unsigned char icr; 39 unsigned char icr;
@@ -68,6 +73,11 @@ static struct irqmap intc_irqmap[MCFINT_VECMAX - MCFINT_VECBASE] = {
68 /*MCF_IRQ_SWTO*/ { .icr = MCFSIM_ICR4, .index = 16, .ack = 0, }, 73 /*MCF_IRQ_SWTO*/ { .icr = MCFSIM_ICR4, .index = 16, .ack = 0, },
69}; 74};
70 75
76/*
77 * The act of masking the interrupt also has a side effect of 'ack'ing
78 * an interrupt on this irq (for the external irqs). So this mask function
79 * is also an ack_mask function.
80 */
71static void intc_irq_mask(unsigned int irq) 81static void intc_irq_mask(unsigned int irq)
72{ 82{
73 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECMAX)) { 83 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECMAX)) {
@@ -95,7 +105,9 @@ static void intc_irq_ack(unsigned int irq)
95 irq -= MCFINT_VECBASE; 105 irq -= MCFINT_VECBASE;
96 if (intc_irqmap[irq].ack) { 106 if (intc_irqmap[irq].ack) {
97 u32 v; 107 u32 v;
98 v = 0xd << intc_irqmap[irq].index; 108 v = readl(MCF_MBAR + intc_irqmap[irq].icr);
109 v &= (0x7 << intc_irqmap[irq].index);
110 v |= (0x8 << intc_irqmap[irq].index);
99 writel(v, MCF_MBAR + intc_irqmap[irq].icr); 111 writel(v, MCF_MBAR + intc_irqmap[irq].icr);
100 } 112 }
101 } 113 }
@@ -103,21 +115,47 @@ static void intc_irq_ack(unsigned int irq)
103 115
104static int intc_irq_set_type(unsigned int irq, unsigned int type) 116static int intc_irq_set_type(unsigned int irq, unsigned int type)
105{ 117{
106 /* We can set the edge type here for external interrupts */ 118 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECMAX)) {
119 irq -= MCFINT_VECBASE;
120 if (intc_irqmap[irq].ack) {
121 u32 v;
122 v = readl(MCF_MBAR + MCFSIM_PITR);
123 if (type == IRQ_TYPE_EDGE_FALLING)
124 v &= ~(0x1 << (32 - irq));
125 else
126 v |= (0x1 << (32 - irq));
127 writel(v, MCF_MBAR + MCFSIM_PITR);
128 }
129 }
107 return 0; 130 return 0;
108} 131}
109 132
133/*
134 * Simple flow handler to deal with the external edge triggered interrupts.
135 * We need to be careful with the masking/acking due to the side effects
136 * of masking an interrupt.
137 */
138static void intc_external_irq(unsigned int irq, struct irq_desc *desc)
139{
140 kstat_incr_irqs_this_cpu(irq, desc);
141 desc->status |= IRQ_INPROGRESS;
142 desc->chip->ack(irq);
143 handle_IRQ_event(irq, desc->action);
144 desc->status &= ~IRQ_INPROGRESS;
145}
146
110static struct irq_chip intc_irq_chip = { 147static struct irq_chip intc_irq_chip = {
111 .name = "CF-INTC", 148 .name = "CF-INTC",
112 .mask = intc_irq_mask, 149 .mask = intc_irq_mask,
113 .unmask = intc_irq_unmask, 150 .unmask = intc_irq_unmask,
151 .mask_ack = intc_irq_mask,
114 .ack = intc_irq_ack, 152 .ack = intc_irq_ack,
115 .set_type = intc_irq_set_type, 153 .set_type = intc_irq_set_type,
116}; 154};
117 155
118void __init init_IRQ(void) 156void __init init_IRQ(void)
119{ 157{
120 int irq; 158 int irq, edge;
121 159
122 init_vectors(); 160 init_vectors();
123 161
@@ -128,11 +166,17 @@ void __init init_IRQ(void)
128 writel(0x88888888, MCF_MBAR + MCFSIM_ICR4); 166 writel(0x88888888, MCF_MBAR + MCFSIM_ICR4);
129 167
130 for (irq = 0; (irq < NR_IRQS); irq++) { 168 for (irq = 0; (irq < NR_IRQS); irq++) {
131 irq_desc[irq].status = IRQ_DISABLED; 169 set_irq_chip(irq, &intc_irq_chip);
132 irq_desc[irq].action = NULL; 170 edge = 0;
133 irq_desc[irq].depth = 1; 171 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECMAX))
134 irq_desc[irq].chip = &intc_irq_chip; 172 edge = intc_irqmap[irq - MCFINT_VECBASE].ack;
135 intc_irq_set_type(irq, 0); 173 if (edge) {
174 set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
175 set_irq_handler(irq, intc_external_irq);
176 } else {
177 set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH);
178 set_irq_handler(irq, handle_level_irq);
179 }
136 } 180 }
137} 181}
138 182
diff --git a/arch/m68knommu/platform/527x/Makefile b/arch/m68knommu/platform/527x/Makefile
index 3d90e6d92459..6ac4b57370ea 100644
--- a/arch/m68knommu/platform/527x/Makefile
+++ b/arch/m68knommu/platform/527x/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/528x/Makefile b/arch/m68knommu/platform/528x/Makefile
index 3d90e6d92459..6ac4b57370ea 100644
--- a/arch/m68knommu/platform/528x/Makefile
+++ b/arch/m68knommu/platform/528x/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5307/Makefile b/arch/m68knommu/platform/5307/Makefile
index 6de526976828..d4293b791f2e 100644
--- a/arch/m68knommu/platform/5307/Makefile
+++ b/arch/m68knommu/platform/5307/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/532x/Makefile b/arch/m68knommu/platform/532x/Makefile
index 4cc23245bcd1..ce01669399c6 100644
--- a/arch/m68knommu/platform/532x/Makefile
+++ b/arch/m68knommu/platform/532x/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/5407/Makefile b/arch/m68knommu/platform/5407/Makefile
index dee62c5dbaa6..e83fe148eddc 100644
--- a/arch/m68knommu/platform/5407/Makefile
+++ b/arch/m68knommu/platform/5407/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
diff --git a/arch/m68knommu/platform/548x/Makefile b/arch/m68knommu/platform/548x/Makefile
new file mode 100644
index 000000000000..e6035e7a2d3f
--- /dev/null
+++ b/arch/m68knommu/platform/548x/Makefile
@@ -0,0 +1,18 @@
1#
2# Makefile for the m68knommu linux kernel.
3#
4
5#
6# If you want to play with the HW breakpoints then you will
7# need to add define this, which will give you a stack backtrace
8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt:
10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13#
14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16
17obj-y := config.o
18
diff --git a/arch/m68knommu/platform/548x/config.c b/arch/m68knommu/platform/548x/config.c
new file mode 100644
index 000000000000..9888846bd1cf
--- /dev/null
+++ b/arch/m68knommu/platform/548x/config.c
@@ -0,0 +1,115 @@
1/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/548x/config.c
5 *
6 * Copyright (C) 2010, Philippe De Muyter <phdm@macqel.be>
7 */
8
9/***************************************************************************/
10
11#include <linux/kernel.h>
12#include <linux/param.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/io.h>
16#include <asm/machdep.h>
17#include <asm/coldfire.h>
18#include <asm/m548xsim.h>
19#include <asm/mcfuart.h>
20#include <asm/m548xgpt.h>
21
22/***************************************************************************/
23
24static struct mcf_platform_uart m548x_uart_platform[] = {
25 {
26 .mapbase = MCF_MBAR + MCFUART_BASE1,
27 .irq = 64 + 35,
28 },
29 {
30 .mapbase = MCF_MBAR + MCFUART_BASE2,
31 .irq = 64 + 34,
32 },
33 {
34 .mapbase = MCF_MBAR + MCFUART_BASE3,
35 .irq = 64 + 33,
36 },
37 {
38 .mapbase = MCF_MBAR + MCFUART_BASE4,
39 .irq = 64 + 32,
40 },
41};
42
43static struct platform_device m548x_uart = {
44 .name = "mcfuart",
45 .id = 0,
46 .dev.platform_data = m548x_uart_platform,
47};
48
49static struct platform_device *m548x_devices[] __initdata = {
50 &m548x_uart,
51};
52
53
54/***************************************************************************/
55
56static void __init m548x_uart_init_line(int line, int irq)
57{
58 int rts_cts;
59
60 /* enable io pins */
61 switch (line) {
62 case 0:
63 rts_cts = 0; break;
64 case 1:
65 rts_cts = MCF_PAR_PSC_RTS_RTS; break;
66 case 2:
67 rts_cts = MCF_PAR_PSC_RTS_RTS | MCF_PAR_PSC_CTS_CTS; break;
68 case 3:
69 rts_cts = 0; break;
70 }
71 __raw_writeb(MCF_PAR_PSC_TXD | rts_cts | MCF_PAR_PSC_RXD,
72 MCF_MBAR + MCF_PAR_PSC(line));
73}
74
75static void __init m548x_uarts_init(void)
76{
77 const int nrlines = ARRAY_SIZE(m548x_uart_platform);
78 int line;
79
80 for (line = 0; (line < nrlines); line++)
81 m548x_uart_init_line(line, m548x_uart_platform[line].irq);
82}
83
84/***************************************************************************/
85
86static void mcf548x_reset(void)
87{
88 /* disable interrupts and enable the watchdog */
89 asm("movew #0x2700, %sr\n");
90 __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
91 __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
92 __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
93 MCF_MBAR + MCF_GPT_GMS0);
94}
95
96/***************************************************************************/
97
98void __init config_BSP(char *commandp, int size)
99{
100 mach_reset = mcf548x_reset;
101 m548x_uarts_init();
102}
103
104/***************************************************************************/
105
106static int __init init_BSP(void)
107{
108
109 platform_add_devices(m548x_devices, ARRAY_SIZE(m548x_devices));
110 return 0;
111}
112
113arch_initcall(init_BSP);
114
115/***************************************************************************/
diff --git a/arch/m68knommu/platform/68328/entry.S b/arch/m68knommu/platform/68328/entry.S
index 9d80d2c42866..27241e16a526 100644
--- a/arch/m68knommu/platform/68328/entry.S
+++ b/arch/m68knommu/platform/68328/entry.S
@@ -43,10 +43,10 @@ badsys:
43 jra ret_from_exception 43 jra ret_from_exception
44 44
45do_trace: 45do_trace:
46 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ 46 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
47 subql #4,%sp 47 subql #4,%sp
48 SAVE_SWITCH_STACK 48 SAVE_SWITCH_STACK
49 jbsr syscall_trace 49 jbsr syscall_trace_enter
50 RESTORE_SWITCH_STACK 50 RESTORE_SWITCH_STACK
51 addql #4,%sp 51 addql #4,%sp
52 movel %sp@(PT_OFF_ORIG_D0),%d1 52 movel %sp@(PT_OFF_ORIG_D0),%d1
@@ -57,10 +57,10 @@ do_trace:
57 lea sys_call_table, %a0 57 lea sys_call_table, %a0
58 jbsr %a0@(%d1) 58 jbsr %a0@(%d1)
59 59
601: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ 601: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
61 subql #4,%sp /* dummy return address */ 61 subql #4,%sp /* dummy return address */
62 SAVE_SWITCH_STACK 62 SAVE_SWITCH_STACK
63 jbsr syscall_trace 63 jbsr syscall_trace_leave
64 64
65ret_from_signal: 65ret_from_signal:
66 RESTORE_SWITCH_STACK 66 RESTORE_SWITCH_STACK
@@ -71,16 +71,16 @@ ENTRY(system_call)
71 SAVE_ALL 71 SAVE_ALL
72 72
73 /* save top of frame*/ 73 /* save top of frame*/
74 pea %sp@ 74 pea %sp@
75 jbsr set_esp0 75 jbsr set_esp0
76 addql #4,%sp 76 addql #4,%sp
77 77
78 movel %sp@(PT_OFF_ORIG_D0),%d0 78 movel %sp@(PT_OFF_ORIG_D0),%d0
79 79
80 movel %sp,%d1 /* get thread_info pointer */ 80 movel %sp,%d1 /* get thread_info pointer */
81 andl #-THREAD_SIZE,%d1 81 andl #-THREAD_SIZE,%d1
82 movel %d1,%a2 82 movel %d1,%a2
83 btst #TIF_SYSCALL_TRACE,%a2@(TI_FLAGS) 83 btst #(TIF_SYSCALL_TRACE%8),%a2@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
84 jne do_trace 84 jne do_trace
85 cmpl #NR_syscalls,%d0 85 cmpl #NR_syscalls,%d0
86 jcc badsys 86 jcc badsys
@@ -88,10 +88,10 @@ ENTRY(system_call)
88 lea sys_call_table,%a0 88 lea sys_call_table,%a0
89 movel %a0@(%d0), %a0 89 movel %a0@(%d0), %a0
90 jbsr %a0@ 90 jbsr %a0@
91 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/ 91 movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
92 92
93ret_from_exception: 93ret_from_exception:
94 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/ 94 btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
95 jeq Luser_return /* if so, skip resched, signals*/ 95 jeq Luser_return /* if so, skip resched, signals*/
96 96
97Lkernel_return: 97Lkernel_return:
@@ -133,7 +133,7 @@ Lreturn:
133 */ 133 */
134inthandler1: 134inthandler1:
135 SAVE_ALL 135 SAVE_ALL
136 movew %sp@(PT_OFF_VECTOR), %d0 136 movew %sp@(PT_OFF_FORMATVEC), %d0
137 and #0x3ff, %d0 137 and #0x3ff, %d0
138 138
139 movel %sp,%sp@- 139 movel %sp,%sp@-
@@ -144,7 +144,7 @@ inthandler1:
144 144
145inthandler2: 145inthandler2:
146 SAVE_ALL 146 SAVE_ALL
147 movew %sp@(PT_OFF_VECTOR), %d0 147 movew %sp@(PT_OFF_FORMATVEC), %d0
148 and #0x3ff, %d0 148 and #0x3ff, %d0
149 149
150 movel %sp,%sp@- 150 movel %sp,%sp@-
@@ -155,7 +155,7 @@ inthandler2:
155 155
156inthandler3: 156inthandler3:
157 SAVE_ALL 157 SAVE_ALL
158 movew %sp@(PT_OFF_VECTOR), %d0 158 movew %sp@(PT_OFF_FORMATVEC), %d0
159 and #0x3ff, %d0 159 and #0x3ff, %d0
160 160
161 movel %sp,%sp@- 161 movel %sp,%sp@-
@@ -166,7 +166,7 @@ inthandler3:
166 166
167inthandler4: 167inthandler4:
168 SAVE_ALL 168 SAVE_ALL
169 movew %sp@(PT_OFF_VECTOR), %d0 169 movew %sp@(PT_OFF_FORMATVEC), %d0
170 and #0x3ff, %d0 170 and #0x3ff, %d0
171 171
172 movel %sp,%sp@- 172 movel %sp,%sp@-
@@ -177,7 +177,7 @@ inthandler4:
177 177
178inthandler5: 178inthandler5:
179 SAVE_ALL 179 SAVE_ALL
180 movew %sp@(PT_OFF_VECTOR), %d0 180 movew %sp@(PT_OFF_FORMATVEC), %d0
181 and #0x3ff, %d0 181 and #0x3ff, %d0
182 182
183 movel %sp,%sp@- 183 movel %sp,%sp@-
@@ -188,7 +188,7 @@ inthandler5:
188 188
189inthandler6: 189inthandler6:
190 SAVE_ALL 190 SAVE_ALL
191 movew %sp@(PT_OFF_VECTOR), %d0 191 movew %sp@(PT_OFF_FORMATVEC), %d0
192 and #0x3ff, %d0 192 and #0x3ff, %d0
193 193
194 movel %sp,%sp@- 194 movel %sp,%sp@-
@@ -199,7 +199,7 @@ inthandler6:
199 199
200inthandler7: 200inthandler7:
201 SAVE_ALL 201 SAVE_ALL
202 movew %sp@(PT_OFF_VECTOR), %d0 202 movew %sp@(PT_OFF_FORMATVEC), %d0
203 and #0x3ff, %d0 203 and #0x3ff, %d0
204 204
205 movel %sp,%sp@- 205 movel %sp,%sp@-
@@ -210,7 +210,7 @@ inthandler7:
210 210
211inthandler: 211inthandler:
212 SAVE_ALL 212 SAVE_ALL
213 movew %sp@(PT_OFF_VECTOR), %d0 213 movew %sp@(PT_OFF_FORMATVEC), %d0
214 and #0x3ff, %d0 214 and #0x3ff, %d0
215 215
216 movel %sp,%sp@- 216 movel %sp,%sp@-
diff --git a/arch/m68knommu/platform/68328/head-de2.S b/arch/m68knommu/platform/68328/head-de2.S
index 92d96456d363..f632fdcb93e9 100644
--- a/arch/m68knommu/platform/68328/head-de2.S
+++ b/arch/m68knommu/platform/68328/head-de2.S
@@ -1,11 +1,5 @@
1 1
2#if defined(CONFIG_RAM32MB)
3#define MEM_END 0x02000000 /* Memory size 32Mb */
4#elif defined(CONFIG_RAM16MB)
5#define MEM_END 0x01000000 /* Memory size 16Mb */
6#else
7#define MEM_END 0x00800000 /* Memory size 8Mb */ 2#define MEM_END 0x00800000 /* Memory size 8Mb */
8#endif
9 3
10#undef CRT_DEBUG 4#undef CRT_DEBUG
11 5
diff --git a/arch/m68knommu/platform/68328/head-ram.S b/arch/m68knommu/platform/68328/head-ram.S
index 252b80b02038..7f1aeeacb219 100644
--- a/arch/m68knommu/platform/68328/head-ram.S
+++ b/arch/m68knommu/platform/68328/head-ram.S
@@ -67,33 +67,6 @@ pclp1:
67 beq pclp1 67 beq pclp1
68#endif /* DEBUG */ 68#endif /* DEBUG */
69 69
70#ifdef CONFIG_RELOCATE
71 /* Copy me to RAM */
72 moveal #__rom_start, %a0
73 moveal #_stext, %a1
74 moveal #_edata, %a2
75
76 /* Copy %a0 to %a1 until %a1 == %a2 */
77LD1:
78 movel %a0@+, %d0
79 movel %d0, %a1@+
80 cmpal %a1, %a2
81 bhi LD1
82
83#ifdef DEBUG
84 moveq #74, %d7 /* 'J' */
85 moveb %d7,0xfffff907 /* No absolute addresses */
86pclp2:
87 movew 0xfffff906, %d7
88 andw #0x2000, %d7
89 beq pclp2
90#endif /* DEBUG */
91 /* jump into the RAM copy */
92 jmp ram_jump
93ram_jump:
94
95#endif /* CONFIG_RELOCATE */
96
97#ifdef DEBUG 70#ifdef DEBUG
98 moveq #82, %d7 /* 'R' */ 71 moveq #82, %d7 /* 'R' */
99 moveb %d7,0xfffff907 /* No absolute addresses */ 72 moveb %d7,0xfffff907 /* No absolute addresses */
diff --git a/arch/m68knommu/platform/68328/ints.c b/arch/m68knommu/platform/68328/ints.c
index b91ee85d4b5d..865852806a17 100644
--- a/arch/m68knommu/platform/68328/ints.c
+++ b/arch/m68knommu/platform/68328/ints.c
@@ -179,10 +179,8 @@ void __init init_IRQ(void)
179 IMR = ~0; 179 IMR = ~0;
180 180
181 for (i = 0; (i < NR_IRQS); i++) { 181 for (i = 0; (i < NR_IRQS); i++) {
182 irq_desc[i].status = IRQ_DISABLED; 182 set_irq_chip(irq, &intc_irq_chip);
183 irq_desc[i].action = NULL; 183 set_irq_handler(irq, handle_level_irq);
184 irq_desc[i].depth = 1;
185 irq_desc[i].chip = &intc_irq_chip;
186 } 184 }
187} 185}
188 186
diff --git a/arch/m68knommu/platform/68360/entry.S b/arch/m68knommu/platform/68360/entry.S
index 6d3460a39cac..c131c6e1d92d 100644
--- a/arch/m68knommu/platform/68360/entry.S
+++ b/arch/m68knommu/platform/68360/entry.S
@@ -42,7 +42,7 @@ do_trace:
42 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/ 42 movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
43 subql #4,%sp 43 subql #4,%sp
44 SAVE_SWITCH_STACK 44 SAVE_SWITCH_STACK
45 jbsr syscall_trace 45 jbsr syscall_trace_enter
46 RESTORE_SWITCH_STACK 46 RESTORE_SWITCH_STACK
47 addql #4,%sp 47 addql #4,%sp
48 movel %sp@(PT_OFF_ORIG_D0),%d1 48 movel %sp@(PT_OFF_ORIG_D0),%d1
@@ -56,7 +56,7 @@ do_trace:
561: movel %d0,%sp@(PT_OFF_D0) /* save the return value */ 561: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
57 subql #4,%sp /* dummy return address */ 57 subql #4,%sp /* dummy return address */
58 SAVE_SWITCH_STACK 58 SAVE_SWITCH_STACK
59 jbsr syscall_trace 59 jbsr syscall_trace_leave
60 60
61ret_from_signal: 61ret_from_signal:
62 RESTORE_SWITCH_STACK 62 RESTORE_SWITCH_STACK
@@ -71,7 +71,12 @@ ENTRY(system_call)
71 jbsr set_esp0 71 jbsr set_esp0
72 addql #4,%sp 72 addql #4,%sp
73 73
74 btst #PF_TRACESYS_BIT,%a2@(TASK_FLAGS+PF_TRACESYS_OFF) 74 movel %sp@(PT_OFF_ORIG_D0),%d0
75
76 movel %sp,%d1 /* get thread_info pointer */
77 andl #-THREAD_SIZE,%d1
78 movel %d1,%a2
79 btst #(TIF_SYSCALL_TRACE%8),%a2@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
75 jne do_trace 80 jne do_trace
76 cmpl #NR_syscalls,%d0 81 cmpl #NR_syscalls,%d0
77 jcc badsys 82 jcc badsys
@@ -124,7 +129,7 @@ Lreturn:
124 */ 129 */
125inthandler: 130inthandler:
126 SAVE_ALL 131 SAVE_ALL
127 movew %sp@(PT_OFF_VECTOR), %d0 132 movew %sp@(PT_OFF_FORMATVEC), %d0
128 and.l #0x3ff, %d0 133 and.l #0x3ff, %d0
129 lsr.l #0x02, %d0 134 lsr.l #0x02, %d0
130 135
diff --git a/arch/m68knommu/platform/68360/ints.c b/arch/m68knommu/platform/68360/ints.c
index 6f22970d8c20..ad96ab1051f0 100644
--- a/arch/m68knommu/platform/68360/ints.c
+++ b/arch/m68knommu/platform/68360/ints.c
@@ -132,10 +132,8 @@ void init_IRQ(void)
132 pquicc->intr_cimr = 0x00000000; 132 pquicc->intr_cimr = 0x00000000;
133 133
134 for (i = 0; (i < NR_IRQS); i++) { 134 for (i = 0; (i < NR_IRQS); i++) {
135 irq_desc[i].status = IRQ_DISABLED; 135 set_irq_chip(irq, &intc_irq_chip);
136 irq_desc[i].action = NULL; 136 set_irq_handler(irq, handle_level_irq);
137 irq_desc[i].depth = 1;
138 irq_desc[i].chip = &intc_irq_chip;
139 } 137 }
140} 138}
141 139
diff --git a/arch/m68knommu/platform/68VZ328/config.c b/arch/m68knommu/platform/68VZ328/config.c
index fc5c63054e98..eabaabe8af36 100644
--- a/arch/m68knommu/platform/68VZ328/config.c
+++ b/arch/m68knommu/platform/68VZ328/config.c
@@ -90,11 +90,6 @@ static void init_hardware(char *command, int size)
90 PDIQEG &= ~PD(1); 90 PDIQEG &= ~PD(1);
91 PDIRQEN |= PD(1); /* IRQ enabled */ 91 PDIRQEN |= PD(1); /* IRQ enabled */
92 92
93#ifdef CONFIG_68328_SERIAL_UART2
94 /* Enable RXD TXD port bits to enable UART2 */
95 PJSEL &= ~(PJ(5) | PJ(4));
96#endif
97
98#ifdef CONFIG_INIT_LCD 93#ifdef CONFIG_INIT_LCD
99 /* initialize LCD controller */ 94 /* initialize LCD controller */
100 LSSA = (long) screen_bits; 95 LSSA = (long) screen_bits;
diff --git a/arch/m68knommu/platform/coldfire/Makefile b/arch/m68knommu/platform/coldfire/Makefile
index f72a0e5d9996..45f501fa4525 100644
--- a/arch/m68knommu/platform/coldfire/Makefile
+++ b/arch/m68knommu/platform/coldfire/Makefile
@@ -8,8 +8,8 @@
8# on the console port whenever a DBG interrupt occurs. You have to 8# on the console port whenever a DBG interrupt occurs. You have to
9# set up you HW breakpoints to trigger a DBG interrupt: 9# set up you HW breakpoints to trigger a DBG interrupt:
10# 10#
11# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT 11# ccflags-y := -DTRAP_DBG_INTERRUPT
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# asflags-y := -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
@@ -26,6 +26,7 @@ obj-$(CONFIG_M528x) += pit.o intc-2.o
26obj-$(CONFIG_M5307) += timers.o intc.o 26obj-$(CONFIG_M5307) += timers.o intc.o
27obj-$(CONFIG_M532x) += timers.o intc-simr.o 27obj-$(CONFIG_M532x) += timers.o intc-simr.o
28obj-$(CONFIG_M5407) += timers.o intc.o 28obj-$(CONFIG_M5407) += timers.o intc.o
29obj-$(CONFIG_M548x) += sltimers.o intc-2.o
29 30
30obj-y += pinmux.o gpio.o 31obj-y += pinmux.o gpio.o
31extra-y := head.o 32extra-y := head.o
diff --git a/arch/m68knommu/platform/coldfire/entry.S b/arch/m68knommu/platform/coldfire/entry.S
index dd7d591f70ea..5e92bed94b7e 100644
--- a/arch/m68knommu/platform/coldfire/entry.S
+++ b/arch/m68knommu/platform/coldfire/entry.S
@@ -88,7 +88,7 @@ ENTRY(system_call)
88 movel %d2,PT_OFF_D0(%sp) /* on syscall entry */ 88 movel %d2,PT_OFF_D0(%sp) /* on syscall entry */
89 subql #4,%sp 89 subql #4,%sp
90 SAVE_SWITCH_STACK 90 SAVE_SWITCH_STACK
91 jbsr syscall_trace 91 jbsr syscall_trace_enter
92 RESTORE_SWITCH_STACK 92 RESTORE_SWITCH_STACK
93 addql #4,%sp 93 addql #4,%sp
94 movel %d3,%a0 94 movel %d3,%a0
@@ -96,7 +96,7 @@ ENTRY(system_call)
96 movel %d0,%sp@(PT_OFF_D0) /* save the return value */ 96 movel %d0,%sp@(PT_OFF_D0) /* save the return value */
97 subql #4,%sp /* dummy return address */ 97 subql #4,%sp /* dummy return address */
98 SAVE_SWITCH_STACK 98 SAVE_SWITCH_STACK
99 jbsr syscall_trace 99 jbsr syscall_trace_leave
100 100
101ret_from_signal: 101ret_from_signal:
102 RESTORE_SWITCH_STACK 102 RESTORE_SWITCH_STACK
@@ -112,7 +112,7 @@ ret_from_exception:
112 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */ 112 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
113 movel %d1,%a0 113 movel %d1,%a0
114 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ 114 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
115 andl #_TIF_NEED_RESCHED,%d1 115 andl #(1<<TIF_NEED_RESCHED),%d1
116 jeq Lkernel_return 116 jeq Lkernel_return
117 117
118 movel %a0@(TI_PREEMPTCOUNT),%d1 118 movel %a0@(TI_PREEMPTCOUNT),%d1
@@ -136,7 +136,7 @@ Luser_return:
136 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */ 136 andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
137 movel %d1,%a0 137 movel %d1,%a0
138 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */ 138 movel %a0@(TI_FLAGS),%d1 /* get thread_info->flags */
139 andl #_TIF_WORK_MASK,%d1 139 andl #0xefff,%d1
140 jne Lwork_to_do /* still work to do */ 140 jne Lwork_to_do /* still work to do */
141 141
142Lreturn: 142Lreturn:
diff --git a/arch/m68knommu/platform/coldfire/head.S b/arch/m68knommu/platform/coldfire/head.S
index 4b91aa24eb00..0b2d7c7adf79 100644
--- a/arch/m68knommu/platform/coldfire/head.S
+++ b/arch/m68knommu/platform/coldfire/head.S
@@ -15,6 +15,7 @@
15#include <asm/coldfire.h> 15#include <asm/coldfire.h>
16#include <asm/mcfcache.h> 16#include <asm/mcfcache.h>
17#include <asm/mcfsim.h> 17#include <asm/mcfsim.h>
18#include <asm/thread_info.h>
18 19
19/*****************************************************************************/ 20/*****************************************************************************/
20 21
diff --git a/arch/m68knommu/platform/coldfire/intc-2.c b/arch/m68knommu/platform/coldfire/intc-2.c
index 5598c8b8661f..85daa2b3001a 100644
--- a/arch/m68knommu/platform/coldfire/intc-2.c
+++ b/arch/m68knommu/platform/coldfire/intc-2.c
@@ -1,5 +1,11 @@
1/* 1/*
2 * intc-1.c 2 * intc-2.c
3 *
4 * General interrupt controller code for the many ColdFire cores that use
5 * interrupt controllers with 63 interrupt sources, organized as 56 fully-
6 * programmable + 7 fixed-level interrupt sources. This includes the 523x
7 * family, the 5270, 5271, 5274, 5275, and the 528x family which have two such
8 * controllers, and the 547x and 548x families which have only one of them.
3 * 9 *
4 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com> 10 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
5 * 11 *
@@ -19,21 +25,37 @@
19#include <asm/traps.h> 25#include <asm/traps.h>
20 26
21/* 27/*
22 * Each vector needs a unique priority and level asscoiated with it. 28 * Bit definitions for the ICR family of registers.
29 */
30#define MCFSIM_ICR_LEVEL(l) ((l)<<3) /* Level l intr */
31#define MCFSIM_ICR_PRI(p) (p) /* Priority p intr */
32
33/*
34 * Each vector needs a unique priority and level associated with it.
23 * We don't really care so much what they are, we don't rely on the 35 * We don't really care so much what they are, we don't rely on the
24 * tranditional priority interrupt scheme of the m68k/ColdFire. 36 * traditional priority interrupt scheme of the m68k/ColdFire.
25 */ 37 */
26static u8 intc_intpri = 0x36; 38static u8 intc_intpri = MCFSIM_ICR_LEVEL(6) | MCFSIM_ICR_PRI(6);
39
40#ifdef MCFICM_INTC1
41#define NR_VECS 128
42#else
43#define NR_VECS 64
44#endif
27 45
28static void intc_irq_mask(unsigned int irq) 46static void intc_irq_mask(unsigned int irq)
29{ 47{
30 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + 128)) { 48 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + NR_VECS)) {
31 unsigned long imraddr; 49 unsigned long imraddr;
32 u32 val, imrbit; 50 u32 val, imrbit;
33 51
34 irq -= MCFINT_VECBASE; 52 irq -= MCFINT_VECBASE;
35 imraddr = MCF_IPSBAR; 53 imraddr = MCF_IPSBAR;
54#ifdef MCFICM_INTC1
36 imraddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0; 55 imraddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0;
56#else
57 imraddr += MCFICM_INTC0;
58#endif
37 imraddr += (irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL; 59 imraddr += (irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL;
38 imrbit = 0x1 << (irq & 0x1f); 60 imrbit = 0x1 << (irq & 0x1f);
39 61
@@ -44,13 +66,17 @@ static void intc_irq_mask(unsigned int irq)
44 66
45static void intc_irq_unmask(unsigned int irq) 67static void intc_irq_unmask(unsigned int irq)
46{ 68{
47 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + 128)) { 69 if ((irq >= MCFINT_VECBASE) && (irq <= MCFINT_VECBASE + NR_VECS)) {
48 unsigned long intaddr, imraddr, icraddr; 70 unsigned long intaddr, imraddr, icraddr;
49 u32 val, imrbit; 71 u32 val, imrbit;
50 72
51 irq -= MCFINT_VECBASE; 73 irq -= MCFINT_VECBASE;
52 intaddr = MCF_IPSBAR; 74 intaddr = MCF_IPSBAR;
75#ifdef MCFICM_INTC1
53 intaddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0; 76 intaddr += (irq & 0x40) ? MCFICM_INTC1 : MCFICM_INTC0;
77#else
78 intaddr += MCFICM_INTC0;
79#endif
54 imraddr = intaddr + ((irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL); 80 imraddr = intaddr + ((irq & 0x20) ? MCFINTC_IMRH : MCFINTC_IMRL);
55 icraddr = intaddr + MCFINTC_ICR0 + (irq & 0x3f); 81 icraddr = intaddr + MCFINTC_ICR0 + (irq & 0x3f);
56 imrbit = 0x1 << (irq & 0x1f); 82 imrbit = 0x1 << (irq & 0x1f);
@@ -67,10 +93,16 @@ static void intc_irq_unmask(unsigned int irq)
67 } 93 }
68} 94}
69 95
96static int intc_irq_set_type(unsigned int irq, unsigned int type)
97{
98 return 0;
99}
100
70static struct irq_chip intc_irq_chip = { 101static struct irq_chip intc_irq_chip = {
71 .name = "CF-INTC", 102 .name = "CF-INTC",
72 .mask = intc_irq_mask, 103 .mask = intc_irq_mask,
73 .unmask = intc_irq_unmask, 104 .unmask = intc_irq_unmask,
105 .set_type = intc_irq_set_type,
74}; 106};
75 107
76void __init init_IRQ(void) 108void __init init_IRQ(void)
@@ -81,13 +113,14 @@ void __init init_IRQ(void)
81 113
82 /* Mask all interrupt sources */ 114 /* Mask all interrupt sources */
83 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL); 115 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
116#ifdef MCFICM_INTC1
84 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC1 + MCFINTC_IMRL); 117 __raw_writel(0x1, MCF_IPSBAR + MCFICM_INTC1 + MCFINTC_IMRL);
118#endif
85 119
86 for (irq = 0; (irq < NR_IRQS); irq++) { 120 for (irq = 0; (irq < NR_IRQS); irq++) {
87 irq_desc[irq].status = IRQ_DISABLED; 121 set_irq_chip(irq, &intc_irq_chip);
88 irq_desc[irq].action = NULL; 122 set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH);
89 irq_desc[irq].depth = 1; 123 set_irq_handler(irq, handle_level_irq);
90 irq_desc[irq].chip = &intc_irq_chip;
91 } 124 }
92} 125}
93 126
diff --git a/arch/m68knommu/platform/coldfire/intc-simr.c b/arch/m68knommu/platform/coldfire/intc-simr.c
index 1b01e79c2f63..bb7048636140 100644
--- a/arch/m68knommu/platform/coldfire/intc-simr.c
+++ b/arch/m68knommu/platform/coldfire/intc-simr.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * intc-simr.c 2 * intc-simr.c
3 * 3 *
4 * Interrupt controller code for the ColdFire 5208, 5207 & 532x parts.
5 *
4 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com> 6 * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
5 * 7 *
6 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
@@ -68,11 +70,9 @@ void __init init_IRQ(void)
68 __raw_writeb(0xff, MCFINTC1_SIMR); 70 __raw_writeb(0xff, MCFINTC1_SIMR);
69 71
70 for (irq = 0; (irq < NR_IRQS); irq++) { 72 for (irq = 0; (irq < NR_IRQS); irq++) {
71 irq_desc[irq].status = IRQ_DISABLED; 73 set_irq_chip(irq, &intc_irq_chip);
72 irq_desc[irq].action = NULL; 74 set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH);
73 irq_desc[irq].depth = 1; 75 set_irq_handler(irq, handle_level_irq);
74 irq_desc[irq].chip = &intc_irq_chip;
75 intc_irq_set_type(irq, 0);
76 } 76 }
77} 77}
78 78
diff --git a/arch/m68knommu/platform/coldfire/intc.c b/arch/m68knommu/platform/coldfire/intc.c
index a4560c86db71..60d2fcbe182b 100644
--- a/arch/m68knommu/platform/coldfire/intc.c
+++ b/arch/m68knommu/platform/coldfire/intc.c
@@ -143,11 +143,9 @@ void __init init_IRQ(void)
143 mcf_maskimr(0xffffffff); 143 mcf_maskimr(0xffffffff);
144 144
145 for (irq = 0; (irq < NR_IRQS); irq++) { 145 for (irq = 0; (irq < NR_IRQS); irq++) {
146 irq_desc[irq].status = IRQ_DISABLED; 146 set_irq_chip(irq, &intc_irq_chip);
147 irq_desc[irq].action = NULL; 147 set_irq_type(irq, IRQ_TYPE_LEVEL_HIGH);
148 irq_desc[irq].depth = 1; 148 set_irq_handler(irq, handle_level_irq);
149 irq_desc[irq].chip = &intc_irq_chip;
150 intc_irq_set_type(irq, 0);
151 } 149 }
152} 150}
153 151
diff --git a/arch/m68knommu/platform/coldfire/sltimers.c b/arch/m68knommu/platform/coldfire/sltimers.c
new file mode 100644
index 000000000000..0a1b937c3e18
--- /dev/null
+++ b/arch/m68knommu/platform/coldfire/sltimers.c
@@ -0,0 +1,145 @@
1/***************************************************************************/
2
3/*
4 * sltimers.c -- generic ColdFire slice timer support.
5 *
6 * Copyright (C) 2009-2010, Philippe De Muyter <phdm@macqel.be>
7 * based on
8 * timers.c -- generic ColdFire hardware timer support.
9 * Copyright (C) 1999-2008, Greg Ungerer <gerg@snapgear.com>
10 */
11
12/***************************************************************************/
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/sched.h>
17#include <linux/interrupt.h>
18#include <linux/irq.h>
19#include <linux/profile.h>
20#include <linux/clocksource.h>
21#include <asm/io.h>
22#include <asm/traps.h>
23#include <asm/machdep.h>
24#include <asm/coldfire.h>
25#include <asm/mcfslt.h>
26#include <asm/mcfsim.h>
27
28/***************************************************************************/
29
30#ifdef CONFIG_HIGHPROFILE
31
32/*
33 * By default use Slice Timer 1 as the profiler clock timer.
34 */
35#define PA(a) (MCF_MBAR + MCFSLT_TIMER1 + (a))
36
37/*
38 * Choose a reasonably fast profile timer. Make it an odd value to
39 * try and get good coverage of kernel operations.
40 */
41#define PROFILEHZ 1013
42
43irqreturn_t mcfslt_profile_tick(int irq, void *dummy)
44{
45 /* Reset Slice Timer 1 */
46 __raw_writel(MCFSLT_SSR_BE | MCFSLT_SSR_TE, PA(MCFSLT_SSR));
47 if (current->pid)
48 profile_tick(CPU_PROFILING);
49 return IRQ_HANDLED;
50}
51
52static struct irqaction mcfslt_profile_irq = {
53 .name = "profile timer",
54 .flags = IRQF_DISABLED | IRQF_TIMER,
55 .handler = mcfslt_profile_tick,
56};
57
58void mcfslt_profile_init(void)
59{
60 printk(KERN_INFO "PROFILE: lodging TIMER 1 @ %dHz as profile timer\n",
61 PROFILEHZ);
62
63 setup_irq(MCF_IRQ_PROFILER, &mcfslt_profile_irq);
64
65 /* Set up TIMER 2 as high speed profile clock */
66 __raw_writel(MCF_BUSCLK / PROFILEHZ - 1, PA(MCFSLT_STCNT));
67 __raw_writel(MCFSLT_SCR_RUN | MCFSLT_SCR_IEN | MCFSLT_SCR_TEN,
68 PA(MCFSLT_SCR));
69
70}
71
72#endif /* CONFIG_HIGHPROFILE */
73
74/***************************************************************************/
75
76/*
77 * By default use Slice Timer 0 as the system clock timer.
78 */
79#define TA(a) (MCF_MBAR + MCFSLT_TIMER0 + (a))
80
81static u32 mcfslt_cycles_per_jiffy;
82static u32 mcfslt_cnt;
83
84static irqreturn_t mcfslt_tick(int irq, void *dummy)
85{
86 /* Reset Slice Timer 0 */
87 __raw_writel(MCFSLT_SSR_BE | MCFSLT_SSR_TE, TA(MCFSLT_SSR));
88 mcfslt_cnt += mcfslt_cycles_per_jiffy;
89 return arch_timer_interrupt(irq, dummy);
90}
91
92static struct irqaction mcfslt_timer_irq = {
93 .name = "timer",
94 .flags = IRQF_DISABLED | IRQF_TIMER,
95 .handler = mcfslt_tick,
96};
97
98static cycle_t mcfslt_read_clk(struct clocksource *cs)
99{
100 unsigned long flags;
101 u32 cycles;
102 u16 scnt;
103
104 local_irq_save(flags);
105 scnt = __raw_readl(TA(MCFSLT_SCNT));
106 cycles = mcfslt_cnt;
107 local_irq_restore(flags);
108
109 /* substract because slice timers count down */
110 return cycles - scnt;
111}
112
113static struct clocksource mcfslt_clk = {
114 .name = "slt",
115 .rating = 250,
116 .read = mcfslt_read_clk,
117 .shift = 20,
118 .mask = CLOCKSOURCE_MASK(32),
119 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
120};
121
122void hw_timer_init(void)
123{
124 mcfslt_cycles_per_jiffy = MCF_BUSCLK / HZ;
125 /*
126 * The coldfire slice timer (SLT) runs from STCNT to 0 included,
127 * then STCNT again and so on. It counts thus actually
128 * STCNT + 1 steps for 1 tick, not STCNT. So if you want
129 * n cycles, initialize STCNT with n - 1.
130 */
131 __raw_writel(mcfslt_cycles_per_jiffy - 1, TA(MCFSLT_STCNT));
132 __raw_writel(MCFSLT_SCR_RUN | MCFSLT_SCR_IEN | MCFSLT_SCR_TEN,
133 TA(MCFSLT_SCR));
134 /* initialize mcfslt_cnt knowing that slice timers count down */
135 mcfslt_cnt = mcfslt_cycles_per_jiffy;
136
137 setup_irq(MCF_IRQ_TIMER, &mcfslt_timer_irq);
138
139 mcfslt_clk.mult = clocksource_hz2mult(MCF_BUSCLK, mcfslt_clk.shift);
140 clocksource_register(&mcfslt_clk);
141
142#ifdef CONFIG_HIGHPROFILE
143 mcfslt_profile_init();
144#endif
145}
diff --git a/arch/microblaze/include/asm/irqflags.h b/arch/microblaze/include/asm/irqflags.h
index 2c38c6d80176..5fd31905775d 100644
--- a/arch/microblaze/include/asm/irqflags.h
+++ b/arch/microblaze/include/asm/irqflags.h
@@ -9,103 +9,114 @@
9#ifndef _ASM_MICROBLAZE_IRQFLAGS_H 9#ifndef _ASM_MICROBLAZE_IRQFLAGS_H
10#define _ASM_MICROBLAZE_IRQFLAGS_H 10#define _ASM_MICROBLAZE_IRQFLAGS_H
11 11
12#include <linux/irqflags.h> 12#include <linux/types.h>
13#include <asm/registers.h> 13#include <asm/registers.h>
14 14
15# if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 15#ifdef CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
16 16
17# define raw_local_irq_save(flags) \ 17static inline unsigned long arch_local_irq_save(void)
18 do { \ 18{
19 asm volatile (" msrclr %0, %1; \ 19 unsigned long flags;
20 nop;" \ 20 asm volatile(" msrclr %0, %1 \n"
21 : "=r"(flags) \ 21 " nop \n"
22 : "i"(MSR_IE) \ 22 : "=r"(flags)
23 : "memory"); \ 23 : "i"(MSR_IE)
24 } while (0) 24 : "memory");
25 25 return flags;
26# define raw_local_irq_disable() \ 26}
27 do { \ 27
28 asm volatile (" msrclr r0, %0; \ 28static inline void arch_local_irq_disable(void)
29 nop;" \ 29{
30 : \ 30 /* this uses r0 without declaring it - is that correct? */
31 : "i"(MSR_IE) \ 31 asm volatile(" msrclr r0, %0 \n"
32 : "memory"); \ 32 " nop \n"
33 } while (0) 33 :
34 34 : "i"(MSR_IE)
35# define raw_local_irq_enable() \ 35 : "memory");
36 do { \ 36}
37 asm volatile (" msrset r0, %0; \ 37
38 nop;" \ 38static inline void arch_local_irq_enable(void)
39 : \ 39{
40 : "i"(MSR_IE) \ 40 /* this uses r0 without declaring it - is that correct? */
41 : "memory"); \ 41 asm volatile(" msrset r0, %0 \n"
42 } while (0) 42 " nop \n"
43 43 :
44# else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */ 44 : "i"(MSR_IE)
45 45 : "memory");
46# define raw_local_irq_save(flags) \ 46}
47 do { \ 47
48 register unsigned tmp; \ 48#else /* !CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
49 asm volatile (" mfs %0, rmsr; \ 49
50 nop; \ 50static inline unsigned long arch_local_irq_save(void)
51 andi %1, %0, %2; \ 51{
52 mts rmsr, %1; \ 52 unsigned long flags, tmp;
53 nop;" \ 53 asm volatile (" mfs %0, rmsr \n"
54 : "=r"(flags), "=r" (tmp) \ 54 " nop \n"
55 : "i"(~MSR_IE) \ 55 " andi %1, %0, %2 \n"
56 : "memory"); \ 56 " mts rmsr, %1 \n"
57 } while (0) 57 " nop \n"
58 58 : "=r"(flags), "=r"(tmp)
59# define raw_local_irq_disable() \ 59 : "i"(~MSR_IE)
60 do { \ 60 : "memory");
61 register unsigned tmp; \ 61 return flags;
62 asm volatile (" mfs %0, rmsr; \ 62}
63 nop; \ 63
64 andi %0, %0, %1; \ 64static inline void arch_local_irq_disable(void)
65 mts rmsr, %0; \ 65{
66 nop;" \ 66 unsigned long tmp;
67 : "=r"(tmp) \ 67 asm volatile(" mfs %0, rmsr \n"
68 : "i"(~MSR_IE) \ 68 " nop \n"
69 : "memory"); \ 69 " andi %0, %0, %1 \n"
70 } while (0) 70 " mts rmsr, %0 \n"
71 71 " nop \n"
72# define raw_local_irq_enable() \ 72 : "=r"(tmp)
73 do { \ 73 : "i"(~MSR_IE)
74 register unsigned tmp; \ 74 : "memory");
75 asm volatile (" mfs %0, rmsr; \ 75}
76 nop; \ 76
77 ori %0, %0, %1; \ 77static inline void arch_local_irq_enable(void)
78 mts rmsr, %0; \ 78{
79 nop;" \ 79 unsigned long tmp;
80 : "=r"(tmp) \ 80 asm volatile(" mfs %0, rmsr \n"
81 : "i"(MSR_IE) \ 81 " nop \n"
82 : "memory"); \ 82 " ori %0, %0, %1 \n"
83 } while (0) 83 " mts rmsr, %0 \n"
84 84 " nop \n"
85# endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 85 : "=r"(tmp)
86 86 : "i"(MSR_IE)
87#define raw_local_irq_restore(flags) \ 87 : "memory");
88 do { \ 88}
89 asm volatile (" mts rmsr, %0; \ 89
90 nop;" \ 90#endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
91 : \ 91
92 : "r"(flags) \ 92static inline unsigned long arch_local_save_flags(void)
93 : "memory"); \
94 } while (0)
95
96static inline unsigned long get_msr(void)
97{ 93{
98 unsigned long flags; 94 unsigned long flags;
99 asm volatile (" mfs %0, rmsr; \ 95 asm volatile(" mfs %0, rmsr \n"
100 nop;" \ 96 " nop \n"
101 : "=r"(flags) \ 97 : "=r"(flags)
102 : \ 98 :
103 : "memory"); \ 99 : "memory");
104 return flags; 100 return flags;
105} 101}
106 102
107#define raw_local_save_flags(flags) ((flags) = get_msr()) 103static inline void arch_local_irq_restore(unsigned long flags)
108#define raw_irqs_disabled() ((get_msr() & MSR_IE) == 0) 104{
109#define raw_irqs_disabled_flags(flags) ((flags & MSR_IE) == 0) 105 asm volatile(" mts rmsr, %0 \n"
106 " nop \n"
107 :
108 : "r"(flags)
109 : "memory");
110}
111
112static inline bool arch_irqs_disabled_flags(unsigned long flags)
113{
114 return (flags & MSR_IE) == 0;
115}
116
117static inline bool arch_irqs_disabled(void)
118{
119 return arch_irqs_disabled_flags(arch_local_save_flags());
120}
110 121
111#endif /* _ASM_MICROBLAZE_IRQFLAGS_H */ 122#endif /* _ASM_MICROBLAZE_IRQFLAGS_H */
diff --git a/arch/microblaze/include/asm/memblock.h b/arch/microblaze/include/asm/memblock.h
index f9c2fa331d2a..20a8e257c77f 100644
--- a/arch/microblaze/include/asm/memblock.h
+++ b/arch/microblaze/include/asm/memblock.h
@@ -9,9 +9,6 @@
9#ifndef _ASM_MICROBLAZE_MEMBLOCK_H 9#ifndef _ASM_MICROBLAZE_MEMBLOCK_H
10#define _ASM_MICROBLAZE_MEMBLOCK_H 10#define _ASM_MICROBLAZE_MEMBLOCK_H
11 11
12/* MEMBLOCK limit is OFF */
13#define MEMBLOCK_REAL_LIMIT 0xFFFFFFFF
14
15#endif /* _ASM_MICROBLAZE_MEMBLOCK_H */ 12#endif /* _ASM_MICROBLAZE_MEMBLOCK_H */
16 13
17 14
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 427b13b4740f..bacbd3d41ec7 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -42,11 +42,6 @@
42#include <asm/sections.h> 42#include <asm/sections.h>
43#include <asm/pci-bridge.h> 43#include <asm/pci-bridge.h>
44 44
45void __init early_init_dt_scan_chosen_arch(unsigned long node)
46{
47 /* No Microblaze specific code here */
48}
49
50void __init early_init_dt_add_memory_arch(u64 base, u64 size) 45void __init early_init_dt_add_memory_arch(u64 base, u64 size)
51{ 46{
52 memblock_add(base, size); 47 memblock_add(base, size);
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 65eb00419d19..c8437866d3b7 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -70,16 +70,16 @@ static void __init paging_init(void)
70 70
71void __init setup_memory(void) 71void __init setup_memory(void)
72{ 72{
73 int i;
74 unsigned long map_size; 73 unsigned long map_size;
74 struct memblock_region *reg;
75
75#ifndef CONFIG_MMU 76#ifndef CONFIG_MMU
76 u32 kernel_align_start, kernel_align_size; 77 u32 kernel_align_start, kernel_align_size;
77 78
78 /* Find main memory where is the kernel */ 79 /* Find main memory where is the kernel */
79 for (i = 0; i < memblock.memory.cnt; i++) { 80 for_each_memblock(memory, reg) {
80 memory_start = (u32) memblock.memory.region[i].base; 81 memory_start = (u32)reg->base;
81 memory_end = (u32) memblock.memory.region[i].base 82 memory_end = (u32) reg->base + reg->size;
82 + (u32) memblock.memory.region[i].size;
83 if ((memory_start <= (u32)_text) && 83 if ((memory_start <= (u32)_text) &&
84 ((u32)_text <= memory_end)) { 84 ((u32)_text <= memory_end)) {
85 memory_size = memory_end - memory_start; 85 memory_size = memory_end - memory_start;
@@ -142,12 +142,10 @@ void __init setup_memory(void)
142 free_bootmem(memory_start, memory_size); 142 free_bootmem(memory_start, memory_size);
143 143
144 /* reserve allocate blocks */ 144 /* reserve allocate blocks */
145 for (i = 0; i < memblock.reserved.cnt; i++) { 145 for_each_memblock(reserved, reg) {
146 pr_debug("reserved %d - 0x%08x-0x%08x\n", i, 146 pr_debug("reserved - 0x%08x-0x%08x\n",
147 (u32) memblock.reserved.region[i].base, 147 (u32) reg->base, (u32) reg->size);
148 (u32) memblock_size_bytes(&memblock.reserved, i)); 148 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
149 reserve_bootmem(memblock.reserved.region[i].base,
150 memblock_size_bytes(&memblock.reserved, i) - 1, BOOTMEM_DEFAULT);
151 } 149 }
152#ifdef CONFIG_MMU 150#ifdef CONFIG_MMU
153 init_bootmem_done = 1; 151 init_bootmem_done = 1;
@@ -230,7 +228,7 @@ static void mm_cmdline_setup(void)
230 if (maxmem && memory_size > maxmem) { 228 if (maxmem && memory_size > maxmem) {
231 memory_size = maxmem; 229 memory_size = maxmem;
232 memory_end = memory_start + memory_size; 230 memory_end = memory_start + memory_size;
233 memblock.memory.region[0].size = memory_size; 231 memblock.memory.regions[0].size = memory_size;
234 } 232 }
235 } 233 }
236} 234}
@@ -273,14 +271,14 @@ asmlinkage void __init mmu_init(void)
273 machine_restart(NULL); 271 machine_restart(NULL);
274 } 272 }
275 273
276 if ((u32) memblock.memory.region[0].size < 0x1000000) { 274 if ((u32) memblock.memory.regions[0].size < 0x1000000) {
277 printk(KERN_EMERG "Memory must be greater than 16MB\n"); 275 printk(KERN_EMERG "Memory must be greater than 16MB\n");
278 machine_restart(NULL); 276 machine_restart(NULL);
279 } 277 }
280 /* Find main memory where the kernel is */ 278 /* Find main memory where the kernel is */
281 memory_start = (u32) memblock.memory.region[0].base; 279 memory_start = (u32) memblock.memory.regions[0].base;
282 memory_end = (u32) memblock.memory.region[0].base + 280 memory_end = (u32) memblock.memory.regions[0].base +
283 (u32) memblock.memory.region[0].size; 281 (u32) memblock.memory.regions[0].size;
284 memory_size = memory_end - memory_start; 282 memory_size = memory_end - memory_start;
285 283
286 mm_cmdline_setup(); /* FIXME parse args from command line - not used */ 284 mm_cmdline_setup(); /* FIXME parse args from command line - not used */
diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild
index e322d65f33a4..7dd65cfae837 100644
--- a/arch/mips/Kbuild
+++ b/arch/mips/Kbuild
@@ -7,6 +7,10 @@ subdir-ccflags-y := -Werror
7include arch/mips/Kbuild.platforms 7include arch/mips/Kbuild.platforms
8obj-y := $(platform-y) 8obj-y := $(platform-y)
9 9
10# make clean traverses $(obj-) without having included .config, so
11# everything ends up here
12obj- := $(platform-)
13
10# mips object files 14# mips object files
11# The object files are linked as core-y files would be linked 15# The object files are linked as core-y files would be linked
12 16
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3ad59dde4852..46cae2b163e4 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -13,6 +13,7 @@ config MIPS
13 select HAVE_KPROBES 13 select HAVE_KPROBES
14 select HAVE_KRETPROBES 14 select HAVE_KRETPROBES
15 select RTC_LIB if !MACH_LOONGSON 15 select RTC_LIB if !MACH_LOONGSON
16 select GENERIC_ATOMIC64 if !64BIT
16 17
17mainmenu "Linux/MIPS Kernel Configuration" 18mainmenu "Linux/MIPS Kernel Configuration"
18 19
@@ -880,11 +881,15 @@ config NO_IOPORT
880config GENERIC_ISA_DMA 881config GENERIC_ISA_DMA
881 bool 882 bool
882 select ZONE_DMA if GENERIC_ISA_DMA_SUPPORT_BROKEN=n 883 select ZONE_DMA if GENERIC_ISA_DMA_SUPPORT_BROKEN=n
884 select ISA_DMA_API
883 885
884config GENERIC_ISA_DMA_SUPPORT_BROKEN 886config GENERIC_ISA_DMA_SUPPORT_BROKEN
885 bool 887 bool
886 select GENERIC_ISA_DMA 888 select GENERIC_ISA_DMA
887 889
890config ISA_DMA_API
891 bool
892
888config GENERIC_GPIO 893config GENERIC_GPIO
889 bool 894 bool
890 895
@@ -1646,8 +1651,16 @@ config MIPS_MT_SMP
1646 select SYS_SUPPORTS_SMP 1651 select SYS_SUPPORTS_SMP
1647 select SMP_UP 1652 select SMP_UP
1648 help 1653 help
1649 This is a kernel model which is also known a VSMP or lately 1654 This is a kernel model which is known a VSMP but lately has been
1650 has been marketesed into SMVP. 1655 marketesed into SMVP.
1656 Virtual SMP uses the processor's VPEs to implement virtual
1657 processors. In currently available configuration of the 34K processor
1658 this allows for a dual processor. Both processors will share the same
1659 primary caches; each will obtain the half of the TLB for it's own
1660 exclusive use. For a layman this model can be described as similar to
1661 what Intel calls Hyperthreading.
1662
1663 For further information see http://www.linux-mips.org/wiki/34K#VSMP
1651 1664
1652config MIPS_MT_SMTC 1665config MIPS_MT_SMTC
1653 bool "SMTC: Use all TCs on all VPEs for SMP" 1666 bool "SMTC: Use all TCs on all VPEs for SMP"
@@ -1664,6 +1677,14 @@ config MIPS_MT_SMTC
1664 help 1677 help
1665 This is a kernel model which is known a SMTC or lately has been 1678 This is a kernel model which is known a SMTC or lately has been
1666 marketesed into SMVP. 1679 marketesed into SMVP.
1680 is presenting the available TC's of the core as processors to Linux.
1681 On currently available 34K processors this means a Linux system will
1682 see up to 5 processors. The implementation of the SMTC kernel differs
1683 significantly from VSMP and cannot efficiently coexist in the same
1684 kernel binary so the choice between VSMP and SMTC is a compile time
1685 decision.
1686
1687 For further information see http://www.linux-mips.org/wiki/34K#SMTC
1667 1688
1668endchoice 1689endchoice
1669 1690
@@ -2107,6 +2128,13 @@ config SECCOMP
2107 2128
2108 If unsure, say Y. Only embedded should say N here. 2129 If unsure, say Y. Only embedded should say N here.
2109 2130
2131config USE_OF
2132 bool "Flattened Device Tree support"
2133 select OF
2134 select OF_FLATTREE
2135 help
2136 Include support for flattened device tree machine descriptions.
2137
2110endmenu 2138endmenu
2111 2139
2112config LOCKDEP_SUPPORT 2140config LOCKDEP_SUPPORT
@@ -2175,10 +2203,14 @@ config TC
2175 bool "TURBOchannel support" 2203 bool "TURBOchannel support"
2176 depends on MACH_DECSTATION 2204 depends on MACH_DECSTATION
2177 help 2205 help
2178 TurboChannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS 2206 TURBOchannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS
2179 processors. Documentation on writing device drivers for TurboChannel 2207 processors. TURBOchannel programming specifications are available
2180 is available at: 2208 at:
2181 <http://www.cs.arizona.edu/computer.help/policy/DIGITAL_unix/AA-PS3HD-TET1_html/TITLE.html>. 2209 <ftp://ftp.hp.com/pub/alphaserver/archive/triadd/>
2210 and:
2211 <http://www.computer-refuge.org/classiccmp/ftp.digital.com/pub/DEC/TriAdd/>
2212 Linux driver support status is documented at:
2213 <http://www.linux-mips.org/wiki/DECstation>
2182 2214
2183#config ACCESSBUS 2215#config ACCESSBUS
2184# bool "Access.Bus support" 2216# bool "Access.Bus support"
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 1dc55ee2681b..3691630931d6 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -24,6 +24,33 @@
24 24
25#include <prom.h> 25#include <prom.h>
26 26
27static void alchemy_8250_pm(struct uart_port *port, unsigned int state,
28 unsigned int old_state)
29{
30 switch (state) {
31 case 0:
32 if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) {
33 /* power-on sequence as suggested in the databooks */
34 __raw_writel(0, port->membase + UART_MOD_CNTRL);
35 wmb();
36 __raw_writel(1, port->membase + UART_MOD_CNTRL);
37 wmb();
38 }
39 __raw_writel(3, port->membase + UART_MOD_CNTRL); /* full on */
40 wmb();
41 serial8250_do_pm(port, state, old_state);
42 break;
43 case 3: /* power off */
44 serial8250_do_pm(port, state, old_state);
45 __raw_writel(0, port->membase + UART_MOD_CNTRL);
46 wmb();
47 break;
48 default:
49 serial8250_do_pm(port, state, old_state);
50 break;
51 }
52}
53
27#define PORT(_base, _irq) \ 54#define PORT(_base, _irq) \
28 { \ 55 { \
29 .mapbase = _base, \ 56 .mapbase = _base, \
@@ -33,6 +60,7 @@
33 .flags = UPF_SKIP_TEST | UPF_IOREMAP | \ 60 .flags = UPF_SKIP_TEST | UPF_IOREMAP | \
34 UPF_FIXED_TYPE, \ 61 UPF_FIXED_TYPE, \
35 .type = PORT_16550A, \ 62 .type = PORT_16550A, \
63 .pm = alchemy_8250_pm, \
36 } 64 }
37 65
38static struct plat_serial8250_port au1x00_uart_data[] = { 66static struct plat_serial8250_port au1x00_uart_data[] = {
diff --git a/arch/mips/alchemy/common/power.c b/arch/mips/alchemy/common/power.c
index 5ef06a164a82..e5916a516e58 100644
--- a/arch/mips/alchemy/common/power.c
+++ b/arch/mips/alchemy/common/power.c
@@ -49,11 +49,6 @@
49 * We only have to save/restore registers that aren't otherwise 49 * We only have to save/restore registers that aren't otherwise
50 * done as part of a driver pm_* function. 50 * done as part of a driver pm_* function.
51 */ 51 */
52static unsigned int sleep_uart0_inten;
53static unsigned int sleep_uart0_fifoctl;
54static unsigned int sleep_uart0_linectl;
55static unsigned int sleep_uart0_clkdiv;
56static unsigned int sleep_uart0_enable;
57static unsigned int sleep_usb[2]; 52static unsigned int sleep_usb[2];
58static unsigned int sleep_sys_clocks[5]; 53static unsigned int sleep_sys_clocks[5];
59static unsigned int sleep_sys_pinfunc; 54static unsigned int sleep_sys_pinfunc;
@@ -62,22 +57,6 @@ static unsigned int sleep_static_memctlr[4][3];
62 57
63static void save_core_regs(void) 58static void save_core_regs(void)
64{ 59{
65 extern void save_au1xxx_intctl(void);
66 extern void pm_eth0_shutdown(void);
67
68 /*
69 * Do the serial ports.....these really should be a pm_*
70 * registered function by the driver......but of course the
71 * standard serial driver doesn't understand our Au1xxx
72 * unique registers.
73 */
74 sleep_uart0_inten = au_readl(UART0_ADDR + UART_IER);
75 sleep_uart0_fifoctl = au_readl(UART0_ADDR + UART_FCR);
76 sleep_uart0_linectl = au_readl(UART0_ADDR + UART_LCR);
77 sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK);
78 sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL);
79 au_sync();
80
81#ifndef CONFIG_SOC_AU1200 60#ifndef CONFIG_SOC_AU1200
82 /* Shutdown USB host/device. */ 61 /* Shutdown USB host/device. */
83 sleep_usb[0] = au_readl(USB_HOST_CONFIG); 62 sleep_usb[0] = au_readl(USB_HOST_CONFIG);
@@ -175,20 +154,6 @@ static void restore_core_regs(void)
175 au_writel(sleep_static_memctlr[3][0], MEM_STCFG3); 154 au_writel(sleep_static_memctlr[3][0], MEM_STCFG3);
176 au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); 155 au_writel(sleep_static_memctlr[3][1], MEM_STTIME3);
177 au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); 156 au_writel(sleep_static_memctlr[3][2], MEM_STADDR3);
178
179 /*
180 * Enable the UART if it was enabled before sleep.
181 * I guess I should define module control bits........
182 */
183 if (sleep_uart0_enable & 0x02) {
184 au_writel(0, UART0_ADDR + UART_MOD_CNTRL); au_sync();
185 au_writel(1, UART0_ADDR + UART_MOD_CNTRL); au_sync();
186 au_writel(3, UART0_ADDR + UART_MOD_CNTRL); au_sync();
187 au_writel(sleep_uart0_inten, UART0_ADDR + UART_IER); au_sync();
188 au_writel(sleep_uart0_fifoctl, UART0_ADDR + UART_FCR); au_sync();
189 au_writel(sleep_uart0_linectl, UART0_ADDR + UART_LCR); au_sync();
190 au_writel(sleep_uart0_clkdiv, UART0_ADDR + UART_CLK); au_sync();
191 }
192} 157}
193 158
194void au_sleep(void) 159void au_sleep(void)
diff --git a/arch/mips/alchemy/common/prom.c b/arch/mips/alchemy/common/prom.c
index c29511b11d44..534021059629 100644
--- a/arch/mips/alchemy/common/prom.c
+++ b/arch/mips/alchemy/common/prom.c
@@ -43,7 +43,7 @@ int prom_argc;
43char **prom_argv; 43char **prom_argv;
44char **prom_envp; 44char **prom_envp;
45 45
46void prom_init_cmdline(void) 46void __init prom_init_cmdline(void)
47{ 47{
48 int i; 48 int i;
49 49
@@ -104,7 +104,7 @@ static inline void str2eaddr(unsigned char *ea, unsigned char *str)
104 } 104 }
105} 105}
106 106
107int prom_get_ethernet_addr(char *ethernet_addr) 107int __init prom_get_ethernet_addr(char *ethernet_addr)
108{ 108{
109 char *ethaddr_str; 109 char *ethaddr_str;
110 110
@@ -123,7 +123,6 @@ int prom_get_ethernet_addr(char *ethernet_addr)
123 123
124 return 0; 124 return 0;
125} 125}
126EXPORT_SYMBOL(prom_get_ethernet_addr);
127 126
128void __init prom_free_prom_memory(void) 127void __init prom_free_prom_memory(void)
129{ 128{
diff --git a/arch/mips/alchemy/devboards/bcsr.c b/arch/mips/alchemy/devboards/bcsr.c
index 3bc4fd2155d7..c52af8821da0 100644
--- a/arch/mips/alchemy/devboards/bcsr.c
+++ b/arch/mips/alchemy/devboards/bcsr.c
@@ -10,6 +10,7 @@
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/irq.h>
13#include <asm/addrspace.h> 14#include <asm/addrspace.h>
14#include <asm/io.h> 15#include <asm/io.h>
15#include <asm/mach-db1x00/bcsr.h> 16#include <asm/mach-db1x00/bcsr.h>
diff --git a/arch/mips/ar7/irq.c b/arch/mips/ar7/irq.c
index c781556c44e4..4ec2642c568f 100644
--- a/arch/mips/ar7/irq.c
+++ b/arch/mips/ar7/irq.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/irq.h>
22 23
23#include <asm/irq_cpu.h> 24#include <asm/irq_cpu.h>
24#include <asm/mipsregs.h> 25#include <asm/mipsregs.h>
diff --git a/arch/mips/bcm63xx/irq.c b/arch/mips/bcm63xx/irq.c
index a0c5cd18c192..3be87f2422f0 100644
--- a/arch/mips/bcm63xx/irq.c
+++ b/arch/mips/bcm63xx/irq.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/irq.h>
14#include <asm/irq_cpu.h> 15#include <asm/irq_cpu.h>
15#include <asm/mipsregs.h> 16#include <asm/mipsregs.h>
16#include <bcm63xx_cpu.h> 17#include <bcm63xx_cpu.h>
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index ed9bb709c9a3..5042d51b0512 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -59,7 +59,7 @@ $(obj)/piggy.o: $(obj)/dummy.o $(obj)/vmlinux.bin.z FORCE
59hostprogs-y := calc_vmlinuz_load_addr 59hostprogs-y := calc_vmlinuz_load_addr
60 60
61VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \ 61VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
62 $(objtree)/$(KBUILD_IMAGE) $(VMLINUX_LOAD_ADDRESS)) 62 $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
63 63
64vmlinuzobjs-y += $(obj)/piggy.o 64vmlinuzobjs-y += $(obj)/piggy.o
65 65
@@ -105,4 +105,4 @@ OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
105vmlinuz.srec: vmlinuz 105vmlinuz.srec: vmlinuz
106 $(call cmd,objcopy) 106 $(call cmd,objcopy)
107 107
108clean-files := $(objtree)/vmlinuz.* 108clean-files := $(objtree)/vmlinuz $(objtree)/vmlinuz.{32,ecoff,bin,srec}
diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig
index 094c17e38e16..47323ca452dc 100644
--- a/arch/mips/cavium-octeon/Kconfig
+++ b/arch/mips/cavium-octeon/Kconfig
@@ -83,3 +83,7 @@ config ARCH_SPARSEMEM_ENABLE
83 def_bool y 83 def_bool y
84 select SPARSEMEM_STATIC 84 select SPARSEMEM_STATIC
85 depends on CPU_CAVIUM_OCTEON 85 depends on CPU_CAVIUM_OCTEON
86
87config CAVIUM_OCTEON_HELPER
88 def_bool y
89 depends on OCTEON_ETHERNET || PCI
diff --git a/arch/mips/cavium-octeon/cpu.c b/arch/mips/cavium-octeon/cpu.c
index c664c8cc2b42..a5b427909b5c 100644
--- a/arch/mips/cavium-octeon/cpu.c
+++ b/arch/mips/cavium-octeon/cpu.c
@@ -41,7 +41,7 @@ static int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action,
41 return NOTIFY_OK; /* Let default notifier send signals */ 41 return NOTIFY_OK; /* Let default notifier send signals */
42} 42}
43 43
44static int cnmips_cu2_setup(void) 44static int __init cnmips_cu2_setup(void)
45{ 45{
46 return cu2_notifier(cnmips_cu2_call, 0); 46 return cu2_notifier(cnmips_cu2_call, 0);
47} 47}
diff --git a/arch/mips/cavium-octeon/executive/Makefile b/arch/mips/cavium-octeon/executive/Makefile
index 2fd66db6939e..7f41c5be2190 100644
--- a/arch/mips/cavium-octeon/executive/Makefile
+++ b/arch/mips/cavium-octeon/executive/Makefile
@@ -11,4 +11,4 @@
11 11
12obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o 12obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o
13 13
14obj-$(CONFIG_PCI) += cvmx-helper-errata.o cvmx-helper-jtag.o 14obj-$(CONFIG_CAVIUM_OCTEON_HELPER) += cvmx-helper-errata.o cvmx-helper-jtag.o
diff --git a/arch/mips/cavium-octeon/serial.c b/arch/mips/cavium-octeon/serial.c
index 638adab02842..12dbf533b77d 100644
--- a/arch/mips/cavium-octeon/serial.c
+++ b/arch/mips/cavium-octeon/serial.c
@@ -13,6 +13,7 @@
13#include <linux/serial_8250.h> 13#include <linux/serial_8250.h>
14#include <linux/serial_reg.h> 14#include <linux/serial_reg.h>
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/irq.h>
16 17
17#include <asm/time.h> 18#include <asm/time.h>
18 19
diff --git a/arch/mips/dec/Platform b/arch/mips/dec/Platform
index 3adbcbd95db1..cf55a6f4e720 100644
--- a/arch/mips/dec/Platform
+++ b/arch/mips/dec/Platform
@@ -1,7 +1,7 @@
1# 1#
2# DECstation family 2# DECstation family
3# 3#
4platform-$(CONFIG_MACH_DECSTATION) = dec/ 4platform-$(CONFIG_MACH_DECSTATION) += dec/
5cflags-$(CONFIG_MACH_DECSTATION) += \ 5cflags-$(CONFIG_MACH_DECSTATION) += \
6 -I$(srctree)/arch/mips/include/asm/mach-dec 6 -I$(srctree)/arch/mips/include/asm/mach-dec
7libs-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/prom/ 7libs-$(CONFIG_MACH_DECSTATION) += arch/mips/dec/prom/
diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c
index bd5431e1f408..fa45e924be05 100644
--- a/arch/mips/dec/setup.c
+++ b/arch/mips/dec/setup.c
@@ -18,6 +18,7 @@
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/irq.h>
21 22
22#include <asm/bootinfo.h> 23#include <asm/bootinfo.h>
23#include <asm/cpu.h> 24#include <asm/cpu.h>
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index c63c56bfd184..47d87da379f9 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -782,6 +782,10 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
782 */ 782 */
783#define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0) 783#define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
784 784
785#else /* !CONFIG_64BIT */
786
787#include <asm-generic/atomic64.h>
788
785#endif /* CONFIG_64BIT */ 789#endif /* CONFIG_64BIT */
786 790
787/* 791/*
diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h
index 2cb2f0c2c4f8..3532e2c5f098 100644
--- a/arch/mips/include/asm/cop2.h
+++ b/arch/mips/include/asm/cop2.h
@@ -24,7 +24,7 @@ extern int cu2_notifier_call_chain(unsigned long val, void *v);
24 24
25#define cu2_notifier(fn, pri) \ 25#define cu2_notifier(fn, pri) \
26({ \ 26({ \
27 static struct notifier_block fn##_nb __cpuinitdata = { \ 27 static struct notifier_block fn##_nb = { \
28 .notifier_call = fn, \ 28 .notifier_call = fn, \
29 .priority = pri \ 29 .priority = pri \
30 }; \ 30 }; \
diff --git a/arch/mips/include/asm/fcntl.h b/arch/mips/include/asm/fcntl.h
index e482fe90fe88..75eddedcfc3e 100644
--- a/arch/mips/include/asm/fcntl.h
+++ b/arch/mips/include/asm/fcntl.h
@@ -56,6 +56,7 @@
56 */ 56 */
57 57
58#ifdef CONFIG_32BIT 58#ifdef CONFIG_32BIT
59#include <linux/types.h>
59 60
60struct flock { 61struct flock {
61 short l_type; 62 short l_type;
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
index 9b9436a4d816..86548da650e7 100644
--- a/arch/mips/include/asm/gic.h
+++ b/arch/mips/include/asm/gic.h
@@ -321,6 +321,7 @@ struct gic_intrmask_regs {
321 */ 321 */
322struct gic_intr_map { 322struct gic_intr_map {
323 unsigned int cpunum; /* Directed to this CPU */ 323 unsigned int cpunum; /* Directed to this CPU */
324#define GIC_UNUSED 0xdead /* Dummy data */
324 unsigned int pin; /* Directed to this Pin */ 325 unsigned int pin; /* Directed to this Pin */
325 unsigned int polarity; /* Polarity : +/- */ 326 unsigned int polarity; /* Polarity : +/- */
326 unsigned int trigtype; /* Trigger : Edge/Levl */ 327 unsigned int trigtype; /* Trigger : Edge/Levl */
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index dea4aed6478f..b003ed52ed17 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -16,6 +16,11 @@
16 16
17#include <irq.h> 17#include <irq.h>
18 18
19static inline void irq_dispose_mapping(unsigned int virq)
20{
21 return;
22}
23
19#ifdef CONFIG_I8259 24#ifdef CONFIG_I8259
20static inline int irq_canonicalize(int irq) 25static inline int irq_canonicalize(int irq)
21{ 26{
diff --git a/arch/mips/include/asm/irqflags.h b/arch/mips/include/asm/irqflags.h
index 701ec0ba8fa9..9ef3b0d17896 100644
--- a/arch/mips/include/asm/irqflags.h
+++ b/arch/mips/include/asm/irqflags.h
@@ -17,7 +17,7 @@
17#include <asm/hazards.h> 17#include <asm/hazards.h>
18 18
19__asm__( 19__asm__(
20 " .macro raw_local_irq_enable \n" 20 " .macro arch_local_irq_enable \n"
21 " .set push \n" 21 " .set push \n"
22 " .set reorder \n" 22 " .set reorder \n"
23 " .set noat \n" 23 " .set noat \n"
@@ -40,7 +40,7 @@ __asm__(
40 40
41extern void smtc_ipi_replay(void); 41extern void smtc_ipi_replay(void);
42 42
43static inline void raw_local_irq_enable(void) 43static inline void arch_local_irq_enable(void)
44{ 44{
45#ifdef CONFIG_MIPS_MT_SMTC 45#ifdef CONFIG_MIPS_MT_SMTC
46 /* 46 /*
@@ -50,7 +50,7 @@ static inline void raw_local_irq_enable(void)
50 smtc_ipi_replay(); 50 smtc_ipi_replay();
51#endif 51#endif
52 __asm__ __volatile__( 52 __asm__ __volatile__(
53 "raw_local_irq_enable" 53 "arch_local_irq_enable"
54 : /* no outputs */ 54 : /* no outputs */
55 : /* no inputs */ 55 : /* no inputs */
56 : "memory"); 56 : "memory");
@@ -76,7 +76,7 @@ static inline void raw_local_irq_enable(void)
76 * Workaround: mask EXL bit of the result or place a nop before mfc0. 76 * Workaround: mask EXL bit of the result or place a nop before mfc0.
77 */ 77 */
78__asm__( 78__asm__(
79 " .macro raw_local_irq_disable\n" 79 " .macro arch_local_irq_disable\n"
80 " .set push \n" 80 " .set push \n"
81 " .set noat \n" 81 " .set noat \n"
82#ifdef CONFIG_MIPS_MT_SMTC 82#ifdef CONFIG_MIPS_MT_SMTC
@@ -97,17 +97,17 @@ __asm__(
97 " .set pop \n" 97 " .set pop \n"
98 " .endm \n"); 98 " .endm \n");
99 99
100static inline void raw_local_irq_disable(void) 100static inline void arch_local_irq_disable(void)
101{ 101{
102 __asm__ __volatile__( 102 __asm__ __volatile__(
103 "raw_local_irq_disable" 103 "arch_local_irq_disable"
104 : /* no outputs */ 104 : /* no outputs */
105 : /* no inputs */ 105 : /* no inputs */
106 : "memory"); 106 : "memory");
107} 107}
108 108
109__asm__( 109__asm__(
110 " .macro raw_local_save_flags flags \n" 110 " .macro arch_local_save_flags flags \n"
111 " .set push \n" 111 " .set push \n"
112 " .set reorder \n" 112 " .set reorder \n"
113#ifdef CONFIG_MIPS_MT_SMTC 113#ifdef CONFIG_MIPS_MT_SMTC
@@ -118,13 +118,15 @@ __asm__(
118 " .set pop \n" 118 " .set pop \n"
119 " .endm \n"); 119 " .endm \n");
120 120
121#define raw_local_save_flags(x) \ 121static inline unsigned long arch_local_save_flags(void)
122__asm__ __volatile__( \ 122{
123 "raw_local_save_flags %0" \ 123 unsigned long flags;
124 : "=r" (x)) 124 asm volatile("arch_local_save_flags %0" : "=r" (flags));
125 return flags;
126}
125 127
126__asm__( 128__asm__(
127 " .macro raw_local_irq_save result \n" 129 " .macro arch_local_irq_save result \n"
128 " .set push \n" 130 " .set push \n"
129 " .set reorder \n" 131 " .set reorder \n"
130 " .set noat \n" 132 " .set noat \n"
@@ -148,15 +150,18 @@ __asm__(
148 " .set pop \n" 150 " .set pop \n"
149 " .endm \n"); 151 " .endm \n");
150 152
151#define raw_local_irq_save(x) \ 153static inline unsigned long arch_local_irq_save(void)
152__asm__ __volatile__( \ 154{
153 "raw_local_irq_save\t%0" \ 155 unsigned long flags;
154 : "=r" (x) \ 156 asm volatile("arch_local_irq_save\t%0"
155 : /* no inputs */ \ 157 : "=r" (flags)
156 : "memory") 158 : /* no inputs */
159 : "memory");
160 return flags;
161}
157 162
158__asm__( 163__asm__(
159 " .macro raw_local_irq_restore flags \n" 164 " .macro arch_local_irq_restore flags \n"
160 " .set push \n" 165 " .set push \n"
161 " .set noreorder \n" 166 " .set noreorder \n"
162 " .set noat \n" 167 " .set noat \n"
@@ -196,7 +201,7 @@ __asm__(
196 " .endm \n"); 201 " .endm \n");
197 202
198 203
199static inline void raw_local_irq_restore(unsigned long flags) 204static inline void arch_local_irq_restore(unsigned long flags)
200{ 205{
201 unsigned long __tmp1; 206 unsigned long __tmp1;
202 207
@@ -211,24 +216,24 @@ static inline void raw_local_irq_restore(unsigned long flags)
211#endif 216#endif
212 217
213 __asm__ __volatile__( 218 __asm__ __volatile__(
214 "raw_local_irq_restore\t%0" 219 "arch_local_irq_restore\t%0"
215 : "=r" (__tmp1) 220 : "=r" (__tmp1)
216 : "0" (flags) 221 : "0" (flags)
217 : "memory"); 222 : "memory");
218} 223}
219 224
220static inline void __raw_local_irq_restore(unsigned long flags) 225static inline void __arch_local_irq_restore(unsigned long flags)
221{ 226{
222 unsigned long __tmp1; 227 unsigned long __tmp1;
223 228
224 __asm__ __volatile__( 229 __asm__ __volatile__(
225 "raw_local_irq_restore\t%0" 230 "arch_local_irq_restore\t%0"
226 : "=r" (__tmp1) 231 : "=r" (__tmp1)
227 : "0" (flags) 232 : "0" (flags)
228 : "memory"); 233 : "memory");
229} 234}
230 235
231static inline int raw_irqs_disabled_flags(unsigned long flags) 236static inline int arch_irqs_disabled_flags(unsigned long flags)
232{ 237{
233#ifdef CONFIG_MIPS_MT_SMTC 238#ifdef CONFIG_MIPS_MT_SMTC
234 /* 239 /*
diff --git a/arch/mips/include/asm/mach-loongson/loongson.h b/arch/mips/include/asm/mach-loongson/loongson.h
index cb6985f24303..1e29b9dd1d73 100644
--- a/arch/mips/include/asm/mach-loongson/loongson.h
+++ b/arch/mips/include/asm/mach-loongson/loongson.h
@@ -13,6 +13,7 @@
13 13
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h>
16 17
17/* loongson internal northbridge initialization */ 18/* loongson internal northbridge initialization */
18extern void bonito_irq_init(void); 19extern void bonito_irq_init(void);
diff --git a/arch/mips/include/asm/mach-tx49xx/kmalloc.h b/arch/mips/include/asm/mach-tx49xx/kmalloc.h
index b74caf65482b..ff9a8b86cb93 100644
--- a/arch/mips/include/asm/mach-tx49xx/kmalloc.h
+++ b/arch/mips/include/asm/mach-tx49xx/kmalloc.h
@@ -1,6 +1,6 @@
1#ifndef __ASM_MACH_TX49XX_KMALLOC_H 1#ifndef __ASM_MACH_TX49XX_KMALLOC_H
2#define __ASM_MACH_TX49XX_KMALLOC_H 2#define __ASM_MACH_TX49XX_KMALLOC_H
3 3
4#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES 4#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5 5
6#endif /* __ASM_MACH_TX49XX_KMALLOC_H */ 6#endif /* __ASM_MACH_TX49XX_KMALLOC_H */
diff --git a/arch/mips/include/asm/mips-boards/maltaint.h b/arch/mips/include/asm/mips-boards/maltaint.h
index cea872fc6f5c..d11aa02a956a 100644
--- a/arch/mips/include/asm/mips-boards/maltaint.h
+++ b/arch/mips/include/asm/mips-boards/maltaint.h
@@ -88,9 +88,6 @@
88 88
89#define GIC_EXT_INTR(x) x 89#define GIC_EXT_INTR(x) x
90 90
91/* Dummy data */
92#define X 0xdead
93
94/* External Interrupts used for IPI */ 91/* External Interrupts used for IPI */
95#define GIC_IPI_EXT_INTR_RESCHED_VPE0 16 92#define GIC_IPI_EXT_INTR_RESCHED_VPE0 16
96#define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17 93#define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index a16beafcea91..e59cd1ac09c2 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -150,6 +150,20 @@ typedef struct { unsigned long pgprot; } pgprot_t;
150 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET) 150 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
151#endif 151#endif
152#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET)) 152#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET))
153
154/*
155 * RELOC_HIDE was originally added by 6007b903dfe5f1d13e0c711ac2894bdd4a61b1ad
156 * (lmo) rsp. 8431fd094d625b94d364fe393076ccef88e6ce18 (kernel.org). The
157 * discussion can be found in lkml posting
158 * <a2ebde260608230500o3407b108hc03debb9da6e62c@mail.gmail.com> which is
159 * archived at http://lists.linuxcoding.com/kernel/2006-q3/msg17360.html
160 *
161 * It is unclear if the misscompilations mentioned in
162 * http://lkml.org/lkml/2010/8/8/138 also affect MIPS so we keep this one
163 * until GCC 3.x has been retired before we can apply
164 * https://patchwork.linux-mips.org/patch/1541/
165 */
166
153#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) 167#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0))
154 168
155#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 169#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
diff --git a/arch/mips/include/asm/prom.h b/arch/mips/include/asm/prom.h
new file mode 100644
index 000000000000..f29b862d9db3
--- /dev/null
+++ b/arch/mips/include/asm/prom.h
@@ -0,0 +1,31 @@
1/*
2 * arch/mips/include/asm/prom.h
3 *
4 * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11#ifndef __ASM_MIPS_PROM_H
12#define __ASM_MIPS_PROM_H
13
14#ifdef CONFIG_OF
15#include <asm/bootinfo.h>
16
17/* which is compatible with the flattened device tree (FDT) */
18#define cmd_line arcs_cmdline
19
20extern int early_init_dt_scan_memory_arch(unsigned long node,
21 const char *uname, int depth, void *data);
22
23extern int reserve_mem_mach(unsigned long addr, unsigned long size);
24extern void free_mem_mach(unsigned long addr, unsigned long size);
25
26extern void device_tree_init(void);
27#else /* CONFIG_OF */
28static inline void device_tree_init(void) { }
29#endif /* CONFIG_OF */
30
31#endif /* _ASM_MIPS_PROM_H */
diff --git a/arch/mips/include/asm/siginfo.h b/arch/mips/include/asm/siginfo.h
index 96e28f18dad1..1ca64b4d33d9 100644
--- a/arch/mips/include/asm/siginfo.h
+++ b/arch/mips/include/asm/siginfo.h
@@ -88,6 +88,7 @@ typedef struct siginfo {
88#ifdef __ARCH_SI_TRAPNO 88#ifdef __ARCH_SI_TRAPNO
89 int _trapno; /* TRAP # which caused the signal */ 89 int _trapno; /* TRAP # which caused the signal */
90#endif 90#endif
91 short _addr_lsb;
91 } _sigfault; 92 } _sigfault;
92 93
93 /* SIGPOLL, SIGXFSZ (To do ...) */ 94 /* SIGPOLL, SIGXFSZ (To do ...) */
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 2376f2e06e47..70df9c0d3c5b 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -146,7 +146,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
146#define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH) 146#define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
147 147
148/* work to do on interrupt/exception return */ 148/* work to do on interrupt/exception return */
149#define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP) 149#define _TIF_WORK_MASK (0x0000ffef & \
150 ~(_TIF_SECCOMP | _TIF_SYSCALL_AUDIT))
150/* work to do on any return to u-space */ 151/* work to do on any return to u-space */
151#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP) 152#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP)
152 153
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index baa318a59c97..550725b881d5 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -356,16 +356,19 @@
356#define __NR_perf_event_open (__NR_Linux + 333) 356#define __NR_perf_event_open (__NR_Linux + 333)
357#define __NR_accept4 (__NR_Linux + 334) 357#define __NR_accept4 (__NR_Linux + 334)
358#define __NR_recvmmsg (__NR_Linux + 335) 358#define __NR_recvmmsg (__NR_Linux + 335)
359#define __NR_fanotify_init (__NR_Linux + 336)
360#define __NR_fanotify_mark (__NR_Linux + 337)
361#define __NR_prlimit64 (__NR_Linux + 338)
359 362
360/* 363/*
361 * Offset of the last Linux o32 flavoured syscall 364 * Offset of the last Linux o32 flavoured syscall
362 */ 365 */
363#define __NR_Linux_syscalls 335 366#define __NR_Linux_syscalls 338
364 367
365#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 368#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
366 369
367#define __NR_O32_Linux 4000 370#define __NR_O32_Linux 4000
368#define __NR_O32_Linux_syscalls 335 371#define __NR_O32_Linux_syscalls 338
369 372
370#if _MIPS_SIM == _MIPS_SIM_ABI64 373#if _MIPS_SIM == _MIPS_SIM_ABI64
371 374
@@ -668,16 +671,19 @@
668#define __NR_perf_event_open (__NR_Linux + 292) 671#define __NR_perf_event_open (__NR_Linux + 292)
669#define __NR_accept4 (__NR_Linux + 293) 672#define __NR_accept4 (__NR_Linux + 293)
670#define __NR_recvmmsg (__NR_Linux + 294) 673#define __NR_recvmmsg (__NR_Linux + 294)
674#define __NR_fanotify_init (__NR_Linux + 295)
675#define __NR_fanotify_mark (__NR_Linux + 296)
676#define __NR_prlimit64 (__NR_Linux + 297)
671 677
672/* 678/*
673 * Offset of the last Linux 64-bit flavoured syscall 679 * Offset of the last Linux 64-bit flavoured syscall
674 */ 680 */
675#define __NR_Linux_syscalls 294 681#define __NR_Linux_syscalls 297
676 682
677#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 683#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
678 684
679#define __NR_64_Linux 5000 685#define __NR_64_Linux 5000
680#define __NR_64_Linux_syscalls 294 686#define __NR_64_Linux_syscalls 297
681 687
682#if _MIPS_SIM == _MIPS_SIM_NABI32 688#if _MIPS_SIM == _MIPS_SIM_NABI32
683 689
@@ -985,16 +991,19 @@
985#define __NR_accept4 (__NR_Linux + 297) 991#define __NR_accept4 (__NR_Linux + 297)
986#define __NR_recvmmsg (__NR_Linux + 298) 992#define __NR_recvmmsg (__NR_Linux + 298)
987#define __NR_getdents64 (__NR_Linux + 299) 993#define __NR_getdents64 (__NR_Linux + 299)
994#define __NR_fanotify_init (__NR_Linux + 300)
995#define __NR_fanotify_mark (__NR_Linux + 301)
996#define __NR_prlimit64 (__NR_Linux + 302)
988 997
989/* 998/*
990 * Offset of the last N32 flavoured syscall 999 * Offset of the last N32 flavoured syscall
991 */ 1000 */
992#define __NR_Linux_syscalls 299 1001#define __NR_Linux_syscalls 302
993 1002
994#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 1003#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
995 1004
996#define __NR_N32_Linux 6000 1005#define __NR_N32_Linux 6000
997#define __NR_N32_Linux_syscalls 299 1006#define __NR_N32_Linux_syscalls 302
998 1007
999#ifdef __KERNEL__ 1008#ifdef __KERNEL__
1000 1009
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
index ee18028efe92..35b3e2f0af04 100644
--- a/arch/mips/jazz/irq.c
+++ b/arch/mips/jazz/irq.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/irq.h>
15 16
16#include <asm/irq_cpu.h> 17#include <asm/irq_cpu.h>
17#include <asm/i8253.h> 18#include <asm/i8253.h>
diff --git a/arch/mips/jz4740/Platform b/arch/mips/jz4740/Platform
index 6a97230e3d05..ba91be9c21ef 100644
--- a/arch/mips/jz4740/Platform
+++ b/arch/mips/jz4740/Platform
@@ -1,3 +1,3 @@
1core-$(CONFIG_MACH_JZ4740) += arch/mips/jz4740/ 1platform-$(CONFIG_MACH_JZ4740) += jz4740/
2cflags-$(CONFIG_MACH_JZ4740) += -I$(srctree)/arch/mips/include/asm/mach-jz4740 2cflags-$(CONFIG_MACH_JZ4740) += -I$(srctree)/arch/mips/include/asm/mach-jz4740
3load-$(CONFIG_MACH_JZ4740) += 0xffffffff80010000 3load-$(CONFIG_MACH_JZ4740) += 0xffffffff80010000
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 06f848299785..80884983270d 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -96,6 +96,8 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
96obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 96obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
97obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o 97obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
98 98
99obj-$(CONFIG_OF) += prom.o
100
99CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 101CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
100 102
101obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o 103obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index 0176ed015c89..32103cc2a257 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -40,7 +40,6 @@ int __compute_return_epc(struct pt_regs *regs)
40 return -EFAULT; 40 return -EFAULT;
41 } 41 }
42 42
43 regs->regs[0] = 0;
44 switch (insn.i_format.opcode) { 43 switch (insn.i_format.opcode) {
45 /* 44 /*
46 * jr and jalr are in r_format format. 45 * jr and jalr are in r_format format.
diff --git a/arch/mips/kernel/cevt-bcm1480.c b/arch/mips/kernel/cevt-bcm1480.c
index bfea327c636c..36c3898b76db 100644
--- a/arch/mips/kernel/cevt-bcm1480.c
+++ b/arch/mips/kernel/cevt-bcm1480.c
@@ -19,6 +19,7 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/percpu.h> 20#include <linux/percpu.h>
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/irq.h>
22 23
23#include <asm/addrspace.h> 24#include <asm/addrspace.h>
24#include <asm/io.h> 25#include <asm/io.h>
diff --git a/arch/mips/kernel/cevt-ds1287.c b/arch/mips/kernel/cevt-ds1287.c
index 00a4da277cbb..939157e397b9 100644
--- a/arch/mips/kernel/cevt-ds1287.c
+++ b/arch/mips/kernel/cevt-ds1287.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/mc146818rtc.h> 23#include <linux/mc146818rtc.h>
24#include <linux/irq.h>
24 25
25#include <asm/time.h> 26#include <asm/time.h>
26 27
diff --git a/arch/mips/kernel/cevt-gt641xx.c b/arch/mips/kernel/cevt-gt641xx.c
index 392ef3756c56..339f3639b90e 100644
--- a/arch/mips/kernel/cevt-gt641xx.c
+++ b/arch/mips/kernel/cevt-gt641xx.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/irq.h>
24 25
25#include <asm/gt64120.h> 26#include <asm/gt64120.h>
26#include <asm/time.h> 27#include <asm/time.h>
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c
index 2a4d50ff5e2c..2f4d7a99bcc2 100644
--- a/arch/mips/kernel/cevt-r4k.c
+++ b/arch/mips/kernel/cevt-r4k.c
@@ -10,6 +10,7 @@
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/percpu.h> 11#include <linux/percpu.h>
12#include <linux/smp.h> 12#include <linux/smp.h>
13#include <linux/irq.h>
13 14
14#include <asm/smtc_ipi.h> 15#include <asm/smtc_ipi.h>
15#include <asm/time.h> 16#include <asm/time.h>
diff --git a/arch/mips/kernel/cevt-sb1250.c b/arch/mips/kernel/cevt-sb1250.c
index da78eeaea6e8..590c54f28a81 100644
--- a/arch/mips/kernel/cevt-sb1250.c
+++ b/arch/mips/kernel/cevt-sb1250.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/clockchips.h> 18#include <linux/clockchips.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/irq.h>
20#include <linux/percpu.h> 21#include <linux/percpu.h>
21#include <linux/smp.h> 22#include <linux/smp.h>
22 23
diff --git a/arch/mips/kernel/cevt-smtc.c b/arch/mips/kernel/cevt-smtc.c
index b102e4f1630e..2e72d30b2f05 100644
--- a/arch/mips/kernel/cevt-smtc.c
+++ b/arch/mips/kernel/cevt-smtc.c
@@ -11,6 +11,7 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/irq.h>
14 15
15#include <asm/smtc_ipi.h> 16#include <asm/smtc_ipi.h>
16#include <asm/time.h> 17#include <asm/time.h>
diff --git a/arch/mips/kernel/cevt-txx9.c b/arch/mips/kernel/cevt-txx9.c
index 218ee6bda935..0b7377361e22 100644
--- a/arch/mips/kernel/cevt-txx9.c
+++ b/arch/mips/kernel/cevt-txx9.c
@@ -13,6 +13,7 @@
13 */ 13 */
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/irq.h>
16#include <asm/time.h> 17#include <asm/time.h>
17#include <asm/txx9tmr.h> 18#include <asm/txx9tmr.h>
18 19
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 94794062a177..2392a7a296d4 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -9,6 +9,7 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/smp.h> 10#include <linux/smp.h>
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/irq.h>
12 13
13#include <asm/delay.h> 14#include <asm/delay.h>
14#include <asm/i8253.h> 15#include <asm/i8253.h>
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 27799113332c..c58176cc796b 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/sysdev.h> 17#include <linux/sysdev.h>
18#include <linux/irq.h>
18 19
19#include <asm/i8259.h> 20#include <asm/i8259.h>
20#include <asm/io.h> 21#include <asm/io.h>
diff --git a/arch/mips/kernel/irq-gic.c b/arch/mips/kernel/irq-gic.c
index b181f2f0ea8e..1774271af848 100644
--- a/arch/mips/kernel/irq-gic.c
+++ b/arch/mips/kernel/irq-gic.c
@@ -3,12 +3,11 @@
3#include <linux/bitmap.h> 3#include <linux/bitmap.h>
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/smp.h> 5#include <linux/smp.h>
6#include <linux/irq.h>
6 7
7#include <asm/io.h> 8#include <asm/io.h>
8#include <asm/gic.h> 9#include <asm/gic.h>
9#include <asm/gcmpregs.h> 10#include <asm/gcmpregs.h>
10#include <asm/mips-boards/maltaint.h>
11#include <asm/irq.h>
12#include <linux/hardirq.h> 11#include <linux/hardirq.h>
13#include <asm-generic/bitops/find.h> 12#include <asm-generic/bitops/find.h>
14 13
@@ -131,7 +130,7 @@ static int gic_set_affinity(unsigned int irq, const struct cpumask *cpumask)
131 int i; 130 int i;
132 131
133 irq -= _irqbase; 132 irq -= _irqbase;
134 pr_debug(KERN_DEBUG "%s(%d) called\n", __func__, irq); 133 pr_debug("%s(%d) called\n", __func__, irq);
135 cpumask_and(&tmp, cpumask, cpu_online_mask); 134 cpumask_and(&tmp, cpumask, cpu_online_mask);
136 if (cpus_empty(tmp)) 135 if (cpus_empty(tmp))
137 return -1; 136 return -1;
@@ -222,7 +221,7 @@ static void __init gic_basic_init(int numintrs, int numvpes,
222 /* Setup specifics */ 221 /* Setup specifics */
223 for (i = 0; i < mapsize; i++) { 222 for (i = 0; i < mapsize; i++) {
224 cpu = intrmap[i].cpunum; 223 cpu = intrmap[i].cpunum;
225 if (cpu == X) 224 if (cpu == GIC_UNUSED)
226 continue; 225 continue;
227 if (cpu == 0 && i != 0 && intrmap[i].flags == 0) 226 if (cpu == 0 && i != 0 && intrmap[i].flags == 0)
228 continue; 227 continue;
diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c
index fb50cc78b28b..9731e8b47862 100644
--- a/arch/mips/kernel/irq-rm7000.c
+++ b/arch/mips/kernel/irq-rm7000.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15 16
16#include <asm/irq_cpu.h> 17#include <asm/irq_cpu.h>
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index b47e4615ec12..b7e4025b58a8 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/module.h> 16#include <linux/module.h>
16 17
diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c
index 55c8a3ca507b..0262abe09121 100644
--- a/arch/mips/kernel/irq_cpu.c
+++ b/arch/mips/kernel/irq_cpu.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/irq.h>
33 34
34#include <asm/irq_cpu.h> 35#include <asm/irq_cpu.h>
35#include <asm/mipsregs.h> 36#include <asm/mipsregs.h>
diff --git a/arch/mips/kernel/irq_txx9.c b/arch/mips/kernel/irq_txx9.c
index 9b78029bea70..95a96f69172d 100644
--- a/arch/mips/kernel/irq_txx9.c
+++ b/arch/mips/kernel/irq_txx9.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/irq.h>
19#include <asm/txx9irq.h> 20#include <asm/txx9irq.h>
20 21
21struct txx9_irc_reg { 22struct txx9_irc_reg {
diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
index 1f4e2fa64140..f4546e97c60d 100644
--- a/arch/mips/kernel/kgdb.c
+++ b/arch/mips/kernel/kgdb.c
@@ -283,7 +283,7 @@ static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
283 struct pt_regs *regs = args->regs; 283 struct pt_regs *regs = args->regs;
284 int trap = (regs->cp0_cause & 0x7c) >> 2; 284 int trap = (regs->cp0_cause & 0x7c) >> 2;
285 285
286 /* Userpace events, ignore. */ 286 /* Userspace events, ignore. */
287 if (user_mode(regs)) 287 if (user_mode(regs))
288 return NOTIFY_DONE; 288 return NOTIFY_DONE;
289 289
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index 80e2ba694bab..29811f043399 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -251,7 +251,7 @@ void sp_work_handle_request(void)
251 memset(&tz, 0, sizeof(tz)); 251 memset(&tz, 0, sizeof(tz));
252 if ((ret.retval = sp_syscall(__NR_gettimeofday, (int)&tv, 252 if ((ret.retval = sp_syscall(__NR_gettimeofday, (int)&tv,
253 (int)&tz, 0, 0)) == 0) 253 (int)&tz, 0, 0)) == 0)
254 ret.retval = tv.tv_sec; 254 ret.retval = tv.tv_sec;
255 break; 255 break;
256 256
257 case MTSP_SYSCALL_EXIT: 257 case MTSP_SYSCALL_EXIT:
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index c2dab140dc98..6343b4a5b835 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -341,3 +341,10 @@ asmlinkage long sys32_lookup_dcookie(u32 a0, u32 a1, char __user *buf,
341{ 341{
342 return sys_lookup_dcookie(merge_64(a0, a1), buf, len); 342 return sys_lookup_dcookie(merge_64(a0, a1), buf, len);
343} 343}
344
345SYSCALL_DEFINE6(32_fanotify_mark, int, fanotify_fd, unsigned int, flags,
346 u64, a3, u64, a4, int, dfd, const char __user *, pathname)
347{
348 return sys_fanotify_mark(fanotify_fd, flags, merge_64(a3, a4),
349 dfd, pathname);
350}
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index 2340f11dc29c..802e6160f37e 100644
--- a/arch/mips/kernel/mips-mt-fpaff.c
+++ b/arch/mips/kernel/mips-mt-fpaff.c
@@ -103,7 +103,7 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
103 if (!check_same_owner(p) && !capable(CAP_SYS_NICE)) 103 if (!check_same_owner(p) && !capable(CAP_SYS_NICE))
104 goto out_unlock; 104 goto out_unlock;
105 105
106 retval = security_task_setscheduler(p, 0, NULL); 106 retval = security_task_setscheduler(p);
107 if (retval) 107 if (retval)
108 goto out_unlock; 108 goto out_unlock;
109 109
diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
new file mode 100644
index 000000000000..e000b278f024
--- /dev/null
+++ b/arch/mips/kernel/prom.c
@@ -0,0 +1,112 @@
1/*
2 * MIPS support for CONFIG_OF device tree support
3 *
4 * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/errno.h>
14#include <linux/types.h>
15#include <linux/bootmem.h>
16#include <linux/initrd.h>
17#include <linux/debugfs.h>
18#include <linux/of.h>
19#include <linux/of_fdt.h>
20#include <linux/of_irq.h>
21#include <linux/of_platform.h>
22
23#include <asm/page.h>
24#include <asm/prom.h>
25
26int __init early_init_dt_scan_memory_arch(unsigned long node,
27 const char *uname, int depth,
28 void *data)
29{
30 return early_init_dt_scan_memory(node, uname, depth, data);
31}
32
33void __init early_init_dt_add_memory_arch(u64 base, u64 size)
34{
35 return add_memory_region(base, size, BOOT_MEM_RAM);
36}
37
38int __init reserve_mem_mach(unsigned long addr, unsigned long size)
39{
40 return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
41}
42
43void __init free_mem_mach(unsigned long addr, unsigned long size)
44{
45 return free_bootmem(addr, size);
46}
47
48u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
49{
50 return virt_to_phys(
51 __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
52 );
53}
54
55#ifdef CONFIG_BLK_DEV_INITRD
56void __init early_init_dt_setup_initrd_arch(unsigned long start,
57 unsigned long end)
58{
59 initrd_start = (unsigned long)__va(start);
60 initrd_end = (unsigned long)__va(end);
61 initrd_below_start_ok = 1;
62}
63#endif
64
65/*
66 * irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
67 *
68 * Currently the mapping mechanism is trivial; simple flat hwirq numbers are
69 * mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
70 * supported.
71 */
72unsigned int irq_create_of_mapping(struct device_node *controller,
73 const u32 *intspec, unsigned int intsize)
74{
75 return intspec[0];
76}
77EXPORT_SYMBOL_GPL(irq_create_of_mapping);
78
79void __init early_init_devtree(void *params)
80{
81 /* Setup flat device-tree pointer */
82 initial_boot_params = params;
83
84 /* Retrieve various informations from the /chosen node of the
85 * device-tree, including the platform type, initrd location and
86 * size, and more ...
87 */
88 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
89
90 /* Scan memory nodes */
91 of_scan_flat_dt(early_init_dt_scan_root, NULL);
92 of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
93}
94
95void __init device_tree_init(void)
96{
97 unsigned long base, size;
98
99 if (!initial_boot_params)
100 return;
101
102 base = virt_to_phys((void *)initial_boot_params);
103 size = initial_boot_params->totalsize;
104
105 /* Before we do anything, lets reserve the dt blob */
106 reserve_mem_mach(base, size);
107
108 unflatten_device_tree();
109
110 /* free the space reserved for the dt blob */
111 free_mem_mach(base, size);
112}
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index c51b95ff8644..c8777333e198 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -536,7 +536,7 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
536{ 536{
537 /* do the secure computing check first */ 537 /* do the secure computing check first */
538 if (!entryexit) 538 if (!entryexit)
539 secure_computing(regs->regs[0]); 539 secure_computing(regs->regs[2]);
540 540
541 if (unlikely(current->audit_context) && entryexit) 541 if (unlikely(current->audit_context) && entryexit)
542 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]), 542 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]),
@@ -565,7 +565,7 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
565 565
566out: 566out:
567 if (unlikely(current->audit_context) && !entryexit) 567 if (unlikely(current->audit_context) && !entryexit)
568 audit_syscall_entry(audit_arch(), regs->regs[0], 568 audit_syscall_entry(audit_arch(), regs->regs[2],
569 regs->regs[4], regs->regs[5], 569 regs->regs[4], regs->regs[5],
570 regs->regs[6], regs->regs[7]); 570 regs->regs[6], regs->regs[7]);
571} 571}
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 26f9b9ab19cc..557ef72472e0 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -468,7 +468,8 @@ static const struct file_operations rtlx_fops = {
468 .release = file_release, 468 .release = file_release,
469 .write = file_write, 469 .write = file_write,
470 .read = file_read, 470 .read = file_read,
471 .poll = file_poll 471 .poll = file_poll,
472 .llseek = noop_llseek,
472}; 473};
473 474
474static struct irqaction rtlx_irq = { 475static struct irqaction rtlx_irq = {
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 17202bbe843f..fbaabad0e6e2 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -63,9 +63,9 @@ stack_done:
63 sw t0, PT_R7(sp) # set error flag 63 sw t0, PT_R7(sp) # set error flag
64 beqz t0, 1f 64 beqz t0, 1f
65 65
66 lw t1, PT_R2(sp) # syscall number
66 negu v0 # error 67 negu v0 # error
67 sw v0, PT_R0(sp) # set flag for syscall 68 sw t1, PT_R0(sp) # save it for syscall restarting
68 # restarting
691: sw v0, PT_R2(sp) # result 691: sw v0, PT_R2(sp) # result
70 70
71o32_syscall_exit: 71o32_syscall_exit:
@@ -104,9 +104,9 @@ syscall_trace_entry:
104 sw t0, PT_R7(sp) # set error flag 104 sw t0, PT_R7(sp) # set error flag
105 beqz t0, 1f 105 beqz t0, 1f
106 106
107 lw t1, PT_R2(sp) # syscall number
107 negu v0 # error 108 negu v0 # error
108 sw v0, PT_R0(sp) # set flag for syscall 109 sw t1, PT_R0(sp) # save it for syscall restarting
109 # restarting
1101: sw v0, PT_R2(sp) # result 1101: sw v0, PT_R2(sp) # result
111 111
112 j syscall_exit 112 j syscall_exit
@@ -169,8 +169,7 @@ stackargs:
169 * We probably should handle this case a bit more drastic. 169 * We probably should handle this case a bit more drastic.
170 */ 170 */
171bad_stack: 171bad_stack:
172 negu v0 # error 172 li v0, EFAULT
173 sw v0, PT_R0(sp)
174 sw v0, PT_R2(sp) 173 sw v0, PT_R2(sp)
175 li t0, 1 # set error flag 174 li t0, 1 # set error flag
176 sw t0, PT_R7(sp) 175 sw t0, PT_R7(sp)
@@ -583,7 +582,10 @@ einval: li v0, -ENOSYS
583 sys sys_rt_tgsigqueueinfo 4 582 sys sys_rt_tgsigqueueinfo 4
584 sys sys_perf_event_open 5 583 sys sys_perf_event_open 5
585 sys sys_accept4 4 584 sys sys_accept4 4
586 sys sys_recvmmsg 5 585 sys sys_recvmmsg 5 /* 4335 */
586 sys sys_fanotify_init 2
587 sys sys_fanotify_mark 6
588 sys sys_prlimit64 4
587 .endm 589 .endm
588 590
589 /* We pre-compute the number of _instruction_ bytes needed to 591 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index a8a6c596eb04..3f4179283207 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -66,9 +66,9 @@ NESTED(handle_sys64, PT_SIZE, sp)
66 sd t0, PT_R7(sp) # set error flag 66 sd t0, PT_R7(sp) # set error flag
67 beqz t0, 1f 67 beqz t0, 1f
68 68
69 ld t1, PT_R2(sp) # syscall number
69 dnegu v0 # error 70 dnegu v0 # error
70 sd v0, PT_R0(sp) # set flag for syscall 71 sd t1, PT_R0(sp) # save it for syscall restarting
71 # restarting
721: sd v0, PT_R2(sp) # result 721: sd v0, PT_R2(sp) # result
73 73
74n64_syscall_exit: 74n64_syscall_exit:
@@ -109,8 +109,9 @@ syscall_trace_entry:
109 sd t0, PT_R7(sp) # set error flag 109 sd t0, PT_R7(sp) # set error flag
110 beqz t0, 1f 110 beqz t0, 1f
111 111
112 ld t1, PT_R2(sp) # syscall number
112 dnegu v0 # error 113 dnegu v0 # error
113 sd v0, PT_R0(sp) # set flag for syscall restarting 114 sd t1, PT_R0(sp) # save it for syscall restarting
1141: sd v0, PT_R2(sp) # result 1151: sd v0, PT_R2(sp) # result
115 116
116 j syscall_exit 117 j syscall_exit
@@ -416,9 +417,12 @@ sys_call_table:
416 PTR sys_pipe2 417 PTR sys_pipe2
417 PTR sys_inotify_init1 418 PTR sys_inotify_init1
418 PTR sys_preadv 419 PTR sys_preadv
419 PTR sys_pwritev /* 5390 */ 420 PTR sys_pwritev /* 5290 */
420 PTR sys_rt_tgsigqueueinfo 421 PTR sys_rt_tgsigqueueinfo
421 PTR sys_perf_event_open 422 PTR sys_perf_event_open
422 PTR sys_accept4 423 PTR sys_accept4
423 PTR sys_recvmmsg 424 PTR sys_recvmmsg
425 PTR sys_fanotify_init /* 5295 */
426 PTR sys_fanotify_mark
427 PTR sys_prlimit64
424 .size sys_call_table,.-sys_call_table 428 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index a3d66137731a..f08ece6d8acc 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -65,8 +65,9 @@ NESTED(handle_sysn32, PT_SIZE, sp)
65 sd t0, PT_R7(sp) # set error flag 65 sd t0, PT_R7(sp) # set error flag
66 beqz t0, 1f 66 beqz t0, 1f
67 67
68 ld t1, PT_R2(sp) # syscall number
68 dnegu v0 # error 69 dnegu v0 # error
69 sd v0, PT_R0(sp) # set flag for syscall restarting 70 sd t1, PT_R0(sp) # save it for syscall restarting
701: sd v0, PT_R2(sp) # result 711: sd v0, PT_R2(sp) # result
71 72
72 local_irq_disable # make sure need_resched and 73 local_irq_disable # make sure need_resched and
@@ -106,8 +107,9 @@ n32_syscall_trace_entry:
106 sd t0, PT_R7(sp) # set error flag 107 sd t0, PT_R7(sp) # set error flag
107 beqz t0, 1f 108 beqz t0, 1f
108 109
110 ld t1, PT_R2(sp) # syscall number
109 dnegu v0 # error 111 dnegu v0 # error
110 sd v0, PT_R0(sp) # set flag for syscall restarting 112 sd t1, PT_R0(sp) # save it for syscall restarting
1111: sd v0, PT_R2(sp) # result 1131: sd v0, PT_R2(sp) # result
112 114
113 j syscall_exit 115 j syscall_exit
@@ -320,10 +322,10 @@ EXPORT(sysn32_call_table)
320 PTR sys_cacheflush 322 PTR sys_cacheflush
321 PTR sys_cachectl 323 PTR sys_cachectl
322 PTR sys_sysmips 324 PTR sys_sysmips
323 PTR sys_io_setup /* 6200 */ 325 PTR compat_sys_io_setup /* 6200 */
324 PTR sys_io_destroy 326 PTR sys_io_destroy
325 PTR sys_io_getevents 327 PTR compat_sys_io_getevents
326 PTR sys_io_submit 328 PTR compat_sys_io_submit
327 PTR sys_io_cancel 329 PTR sys_io_cancel
328 PTR sys_exit_group /* 6205 */ 330 PTR sys_exit_group /* 6205 */
329 PTR sys_lookup_dcookie 331 PTR sys_lookup_dcookie
@@ -419,5 +421,8 @@ EXPORT(sysn32_call_table)
419 PTR sys_perf_event_open 421 PTR sys_perf_event_open
420 PTR sys_accept4 422 PTR sys_accept4
421 PTR compat_sys_recvmmsg 423 PTR compat_sys_recvmmsg
422 PTR sys_getdents 424 PTR sys_getdents64
425 PTR sys_fanotify_init /* 6300 */
426 PTR sys_fanotify_mark
427 PTR sys_prlimit64
423 .size sysn32_call_table,.-sysn32_call_table 428 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 813689ef2384..78d768a3e19d 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -93,8 +93,9 @@ NESTED(handle_sys, PT_SIZE, sp)
93 sd t0, PT_R7(sp) # set error flag 93 sd t0, PT_R7(sp) # set error flag
94 beqz t0, 1f 94 beqz t0, 1f
95 95
96 ld t1, PT_R2(sp) # syscall number
96 dnegu v0 # error 97 dnegu v0 # error
97 sd v0, PT_R0(sp) # flag for syscall restarting 98 sd t1, PT_R0(sp) # save it for syscall restarting
981: sd v0, PT_R2(sp) # result 991: sd v0, PT_R2(sp) # result
99 100
100o32_syscall_exit: 101o32_syscall_exit:
@@ -142,8 +143,9 @@ trace_a_syscall:
142 sd t0, PT_R7(sp) # set error flag 143 sd t0, PT_R7(sp) # set error flag
143 beqz t0, 1f 144 beqz t0, 1f
144 145
146 ld t1, PT_R2(sp) # syscall number
145 dnegu v0 # error 147 dnegu v0 # error
146 sd v0, PT_R0(sp) # set flag for syscall restarting 148 sd t1, PT_R0(sp) # save it for syscall restarting
1471: sd v0, PT_R2(sp) # result 1491: sd v0, PT_R2(sp) # result
148 150
149 j syscall_exit 151 j syscall_exit
@@ -154,8 +156,7 @@ trace_a_syscall:
154 * The stackpointer for a call with more than 4 arguments is bad. 156 * The stackpointer for a call with more than 4 arguments is bad.
155 */ 157 */
156bad_stack: 158bad_stack:
157 dnegu v0 # error 159 li v0, EFAULT
158 sd v0, PT_R0(sp)
159 sd v0, PT_R2(sp) 160 sd v0, PT_R2(sp)
160 li t0, 1 # set error flag 161 li t0, 1 # set error flag
161 sd t0, PT_R7(sp) 162 sd t0, PT_R7(sp)
@@ -444,10 +445,10 @@ sys_call_table:
444 PTR compat_sys_futex 445 PTR compat_sys_futex
445 PTR compat_sys_sched_setaffinity 446 PTR compat_sys_sched_setaffinity
446 PTR compat_sys_sched_getaffinity /* 4240 */ 447 PTR compat_sys_sched_getaffinity /* 4240 */
447 PTR sys_io_setup 448 PTR compat_sys_io_setup
448 PTR sys_io_destroy 449 PTR sys_io_destroy
449 PTR sys_io_getevents 450 PTR compat_sys_io_getevents
450 PTR sys_io_submit 451 PTR compat_sys_io_submit
451 PTR sys_io_cancel /* 4245 */ 452 PTR sys_io_cancel /* 4245 */
452 PTR sys_exit_group 453 PTR sys_exit_group
453 PTR sys32_lookup_dcookie 454 PTR sys32_lookup_dcookie
@@ -538,5 +539,8 @@ sys_call_table:
538 PTR compat_sys_rt_tgsigqueueinfo 539 PTR compat_sys_rt_tgsigqueueinfo
539 PTR sys_perf_event_open 540 PTR sys_perf_event_open
540 PTR sys_accept4 541 PTR sys_accept4
541 PTR compat_sys_recvmmsg 542 PTR compat_sys_recvmmsg /* 4335 */
543 PTR sys_fanotify_init
544 PTR sys_32_fanotify_mark
545 PTR sys_prlimit64
542 .size sys_call_table,.-sys_call_table 546 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 85aef3fc6716..a6b900f2962b 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -31,6 +31,7 @@
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/smp-ops.h> 32#include <asm/smp-ops.h>
33#include <asm/system.h> 33#include <asm/system.h>
34#include <asm/prom.h>
34 35
35struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly; 36struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
36 37
@@ -487,6 +488,7 @@ static void __init arch_mem_init(char **cmdline_p)
487 } 488 }
488 489
489 bootmem_init(); 490 bootmem_init();
491 device_tree_init();
490 sparse_init(); 492 sparse_init();
491 paging_init(); 493 paging_init();
492} 494}
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 2099d5a4c4b7..5922342bca39 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -390,7 +390,6 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
390{ 390{
391 struct rt_sigframe __user *frame; 391 struct rt_sigframe __user *frame;
392 sigset_t set; 392 sigset_t set;
393 stack_t st;
394 int sig; 393 int sig;
395 394
396 frame = (struct rt_sigframe __user *) regs.regs[29]; 395 frame = (struct rt_sigframe __user *) regs.regs[29];
@@ -411,11 +410,9 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
411 else if (sig) 410 else if (sig)
412 force_sig(sig, current); 411 force_sig(sig, current);
413 412
414 if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
415 goto badframe;
416 /* It is more difficult to avoid calling this function than to 413 /* It is more difficult to avoid calling this function than to
417 call it and ignore errors. */ 414 call it and ignore errors. */
418 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]); 415 do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs.regs[29]);
419 416
420 /* 417 /*
421 * Don't let your children do this ... 418 * Don't let your children do this ...
@@ -550,23 +547,26 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
550 struct mips_abi *abi = current->thread.abi; 547 struct mips_abi *abi = current->thread.abi;
551 void *vdso = current->mm->context.vdso; 548 void *vdso = current->mm->context.vdso;
552 549
553 switch(regs->regs[0]) { 550 if (regs->regs[0]) {
554 case ERESTART_RESTARTBLOCK: 551 switch(regs->regs[2]) {
555 case ERESTARTNOHAND: 552 case ERESTART_RESTARTBLOCK:
556 regs->regs[2] = EINTR; 553 case ERESTARTNOHAND:
557 break;
558 case ERESTARTSYS:
559 if (!(ka->sa.sa_flags & SA_RESTART)) {
560 regs->regs[2] = EINTR; 554 regs->regs[2] = EINTR;
561 break; 555 break;
556 case ERESTARTSYS:
557 if (!(ka->sa.sa_flags & SA_RESTART)) {
558 regs->regs[2] = EINTR;
559 break;
560 }
561 /* fallthrough */
562 case ERESTARTNOINTR:
563 regs->regs[7] = regs->regs[26];
564 regs->regs[2] = regs->regs[0];
565 regs->cp0_epc -= 4;
562 } 566 }
563 /* fallthrough */
564 case ERESTARTNOINTR: /* Userland will reload $v0. */
565 regs->regs[7] = regs->regs[26];
566 regs->cp0_epc -= 8;
567 }
568 567
569 regs->regs[0] = 0; /* Don't deal with this again. */ 568 regs->regs[0] = 0; /* Don't deal with this again. */
569 }
570 570
571 if (sig_uses_siginfo(ka)) 571 if (sig_uses_siginfo(ka))
572 ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset, 572 ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset,
@@ -575,6 +575,9 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
575 ret = abi->setup_frame(vdso + abi->signal_return_offset, 575 ret = abi->setup_frame(vdso + abi->signal_return_offset,
576 ka, regs, sig, oldset); 576 ka, regs, sig, oldset);
577 577
578 if (ret)
579 return ret;
580
578 spin_lock_irq(&current->sighand->siglock); 581 spin_lock_irq(&current->sighand->siglock);
579 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask); 582 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
580 if (!(ka->sa.sa_flags & SA_NODEFER)) 583 if (!(ka->sa.sa_flags & SA_NODEFER))
@@ -622,17 +625,13 @@ static void do_signal(struct pt_regs *regs)
622 return; 625 return;
623 } 626 }
624 627
625 /*
626 * Who's code doesn't conform to the restartable syscall convention
627 * dies here!!! The li instruction, a single machine instruction,
628 * must directly be followed by the syscall instruction.
629 */
630 if (regs->regs[0]) { 628 if (regs->regs[0]) {
631 if (regs->regs[2] == ERESTARTNOHAND || 629 if (regs->regs[2] == ERESTARTNOHAND ||
632 regs->regs[2] == ERESTARTSYS || 630 regs->regs[2] == ERESTARTSYS ||
633 regs->regs[2] == ERESTARTNOINTR) { 631 regs->regs[2] == ERESTARTNOINTR) {
632 regs->regs[2] = regs->regs[0];
634 regs->regs[7] = regs->regs[26]; 633 regs->regs[7] = regs->regs[26];
635 regs->cp0_epc -= 8; 634 regs->cp0_epc -= 4;
636 } 635 }
637 if (regs->regs[2] == ERESTART_RESTARTBLOCK) { 636 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
638 regs->regs[2] = current->thread.abi->restart; 637 regs->regs[2] = current->thread.abi->restart;
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
index 2c5df818c65a..ee24d814d5b9 100644
--- a/arch/mips/kernel/signal_n32.c
+++ b/arch/mips/kernel/signal_n32.c
@@ -109,6 +109,7 @@ asmlinkage int sysn32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
109asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) 109asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
110{ 110{
111 struct rt_sigframe_n32 __user *frame; 111 struct rt_sigframe_n32 __user *frame;
112 mm_segment_t old_fs;
112 sigset_t set; 113 sigset_t set;
113 stack_t st; 114 stack_t st;
114 s32 sp; 115 s32 sp;
@@ -143,7 +144,11 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
143 144
144 /* It is more difficult to avoid calling this function than to 145 /* It is more difficult to avoid calling this function than to
145 call it and ignore errors. */ 146 call it and ignore errors. */
147 old_fs = get_fs();
148 set_fs(KERNEL_DS);
146 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]); 149 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]);
150 set_fs(old_fs);
151
147 152
148 /* 153 /*
149 * Don't let your children do this ... 154 * Don't let your children do this ...
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index cfeb2c155896..39c08254b0f1 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -1038,7 +1038,7 @@ void deferred_smtc_ipi(void)
1038 * but it's more efficient, given that we're already 1038 * but it's more efficient, given that we're already
1039 * running down the IPI queue. 1039 * running down the IPI queue.
1040 */ 1040 */
1041 __raw_local_irq_restore(flags); 1041 __arch_local_irq_restore(flags);
1042 } 1042 }
1043} 1043}
1044 1044
@@ -1190,7 +1190,7 @@ void smtc_ipi_replay(void)
1190 /* 1190 /*
1191 ** But use a raw restore here to avoid recursion. 1191 ** But use a raw restore here to avoid recursion.
1192 */ 1192 */
1193 __raw_local_irq_restore(flags); 1193 __arch_local_irq_restore(flags);
1194 1194
1195 if (pipi) { 1195 if (pipi) {
1196 self_ipi(pipi); 1196 self_ipi(pipi);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 03ec0019032b..d053bf4759e4 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -28,6 +28,7 @@
28#include <linux/kprobes.h> 28#include <linux/kprobes.h>
29#include <linux/notifier.h> 29#include <linux/notifier.h>
30#include <linux/kdb.h> 30#include <linux/kdb.h>
31#include <linux/irq.h>
31 32
32#include <asm/bootinfo.h> 33#include <asm/bootinfo.h>
33#include <asm/branch.h> 34#include <asm/branch.h>
@@ -51,7 +52,6 @@
51#include <asm/mmu_context.h> 52#include <asm/mmu_context.h>
52#include <asm/types.h> 53#include <asm/types.h>
53#include <asm/stacktrace.h> 54#include <asm/stacktrace.h>
54#include <asm/irq.h>
55#include <asm/uasm.h> 55#include <asm/uasm.h>
56 56
57extern void check_wait(void); 57extern void check_wait(void);
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 69b039ca8d83..33d5a5ce4a29 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -109,8 +109,6 @@ static void emulate_load_store_insn(struct pt_regs *regs,
109 unsigned long value; 109 unsigned long value;
110 unsigned int res; 110 unsigned int res;
111 111
112 regs->regs[0] = 0;
113
114 /* 112 /*
115 * This load never faults. 113 * This load never faults.
116 */ 114 */
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 2bd2151c586a..3eb3cde2f661 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1192,7 +1192,8 @@ static const struct file_operations vpe_fops = {
1192 .owner = THIS_MODULE, 1192 .owner = THIS_MODULE,
1193 .open = vpe_open, 1193 .open = vpe_open,
1194 .release = vpe_release, 1194 .release = vpe_release,
1195 .write = vpe_write 1195 .write = vpe_write,
1196 .llseek = noop_llseek,
1196}; 1197};
1197 1198
1198/* module wrapper entry points */ 1199/* module wrapper entry points */
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 47842b7d26ae..ec3faa413f3b 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * MIPS floating point support 4 * MIPS floating point support
5 * Copyright (C) 1994-2000 Algorithmics Ltd. 5 * Copyright (C) 1994-2000 Algorithmics Ltd.
6 * http://www.algor.co.uk
7 * 6 *
8 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com 7 * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
9 * Copyright (C) 2000 MIPS Technologies, Inc. 8 * Copyright (C) 2000 MIPS Technologies, Inc.
diff --git a/arch/mips/math-emu/dp_add.c b/arch/mips/math-emu/dp_add.c
index bcf73bb5c33a..b422fcad852a 100644
--- a/arch/mips/math-emu/dp_add.c
+++ b/arch/mips/math-emu/dp_add.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_cmp.c b/arch/mips/math-emu/dp_cmp.c
index 8ab4f320a478..0f32486b0ed9 100644
--- a/arch/mips/math-emu/dp_cmp.c
+++ b/arch/mips/math-emu/dp_cmp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_div.c b/arch/mips/math-emu/dp_div.c
index 6acedce3b32d..a1bce1b7c09c 100644
--- a/arch/mips/math-emu/dp_div.c
+++ b/arch/mips/math-emu/dp_div.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_fint.c b/arch/mips/math-emu/dp_fint.c
index 39a71de16f47..88571288c9e0 100644
--- a/arch/mips/math-emu/dp_fint.c
+++ b/arch/mips/math-emu/dp_fint.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_flong.c b/arch/mips/math-emu/dp_flong.c
index f08f223e488a..14fc01ec742d 100644
--- a/arch/mips/math-emu/dp_flong.c
+++ b/arch/mips/math-emu/dp_flong.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_frexp.c b/arch/mips/math-emu/dp_frexp.c
index e650cb10c947..cb15a5eaecbb 100644
--- a/arch/mips/math-emu/dp_frexp.c
+++ b/arch/mips/math-emu/dp_frexp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_fsp.c b/arch/mips/math-emu/dp_fsp.c
index 494d19ac7049..1dfbd92ba9d0 100644
--- a/arch/mips/math-emu/dp_fsp.c
+++ b/arch/mips/math-emu/dp_fsp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_logb.c b/arch/mips/math-emu/dp_logb.c
index 603388621ca5..151127e59f5c 100644
--- a/arch/mips/math-emu/dp_logb.c
+++ b/arch/mips/math-emu/dp_logb.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_modf.c b/arch/mips/math-emu/dp_modf.c
index a8570e5c3efc..b01f9cf6d402 100644
--- a/arch/mips/math-emu/dp_modf.c
+++ b/arch/mips/math-emu/dp_modf.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_mul.c b/arch/mips/math-emu/dp_mul.c
index 48908a809c17..aa566e785f5a 100644
--- a/arch/mips/math-emu/dp_mul.c
+++ b/arch/mips/math-emu/dp_mul.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_scalb.c b/arch/mips/math-emu/dp_scalb.c
index b84e6338330e..6f5df438dda8 100644
--- a/arch/mips/math-emu/dp_scalb.c
+++ b/arch/mips/math-emu/dp_scalb.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_simple.c b/arch/mips/math-emu/dp_simple.c
index b90974246e5b..79ce2673a714 100644
--- a/arch/mips/math-emu/dp_simple.c
+++ b/arch/mips/math-emu/dp_simple.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_sqrt.c b/arch/mips/math-emu/dp_sqrt.c
index 032328c49888..a2a51b87ae8f 100644
--- a/arch/mips/math-emu/dp_sqrt.c
+++ b/arch/mips/math-emu/dp_sqrt.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_sub.c b/arch/mips/math-emu/dp_sub.c
index a2127d685a0d..0de098cbc77b 100644
--- a/arch/mips/math-emu/dp_sub.c
+++ b/arch/mips/math-emu/dp_sub.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_tint.c b/arch/mips/math-emu/dp_tint.c
index 24478623c117..0ebe8598b94a 100644
--- a/arch/mips/math-emu/dp_tint.c
+++ b/arch/mips/math-emu/dp_tint.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/dp_tlong.c b/arch/mips/math-emu/dp_tlong.c
index 0f07ec2be3f9..133ce2ba0012 100644
--- a/arch/mips/math-emu/dp_tlong.c
+++ b/arch/mips/math-emu/dp_tlong.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/ieee754.c b/arch/mips/math-emu/ieee754.c
index cb1b6822711a..30554e1c67b4 100644
--- a/arch/mips/math-emu/ieee754.c
+++ b/arch/mips/math-emu/ieee754.c
@@ -9,7 +9,6 @@
9/* 9/*
10 * MIPS floating point support 10 * MIPS floating point support
11 * Copyright (C) 1994-2000 Algorithmics Ltd. 11 * Copyright (C) 1994-2000 Algorithmics Ltd.
12 * http://www.algor.co.uk
13 * 12 *
14 * ######################################################################## 13 * ########################################################################
15 * 14 *
diff --git a/arch/mips/math-emu/ieee754.h b/arch/mips/math-emu/ieee754.h
index dd917332792c..22796e012060 100644
--- a/arch/mips/math-emu/ieee754.h
+++ b/arch/mips/math-emu/ieee754.h
@@ -1,7 +1,6 @@
1/* 1/*
2 * MIPS floating point support 2 * MIPS floating point support
3 * Copyright (C) 1994-2000 Algorithmics Ltd. 3 * Copyright (C) 1994-2000 Algorithmics Ltd.
4 * http://www.algor.co.uk
5 * 4 *
6 * This program is free software; you can distribute it and/or modify it 5 * This program is free software; you can distribute it and/or modify it
7 * under the terms of the GNU General Public License (Version 2) as 6 * under the terms of the GNU General Public License (Version 2) as
diff --git a/arch/mips/math-emu/ieee754d.c b/arch/mips/math-emu/ieee754d.c
index a0325337b76c..9599bdd32585 100644
--- a/arch/mips/math-emu/ieee754d.c
+++ b/arch/mips/math-emu/ieee754d.c
@@ -4,7 +4,6 @@
4 * MIPS floating point support 4 * MIPS floating point support
5 * 5 *
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * This program is free software; you can distribute it and/or modify it 8 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as 9 * under the terms of the GNU General Public License (Version 2) as
diff --git a/arch/mips/math-emu/ieee754dp.c b/arch/mips/math-emu/ieee754dp.c
index 2f22fd7fd784..080b5ca03fc6 100644
--- a/arch/mips/math-emu/ieee754dp.c
+++ b/arch/mips/math-emu/ieee754dp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/ieee754dp.h b/arch/mips/math-emu/ieee754dp.h
index 762786538449..f139c724c59a 100644
--- a/arch/mips/math-emu/ieee754dp.h
+++ b/arch/mips/math-emu/ieee754dp.h
@@ -5,7 +5,6 @@
5/* 5/*
6 * MIPS floating point support 6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd. 7 * Copyright (C) 1994-2000 Algorithmics Ltd.
8 * http://www.algor.co.uk
9 * 8 *
10 * ######################################################################## 9 * ########################################################################
11 * 10 *
diff --git a/arch/mips/math-emu/ieee754int.h b/arch/mips/math-emu/ieee754int.h
index 1a846c5425cd..2701d9500959 100644
--- a/arch/mips/math-emu/ieee754int.h
+++ b/arch/mips/math-emu/ieee754int.h
@@ -5,7 +5,6 @@
5/* 5/*
6 * MIPS floating point support 6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd. 7 * Copyright (C) 1994-2000 Algorithmics Ltd.
8 * http://www.algor.co.uk
9 * 8 *
10 * ######################################################################## 9 * ########################################################################
11 * 10 *
diff --git a/arch/mips/math-emu/ieee754m.c b/arch/mips/math-emu/ieee754m.c
index d66896cd8f21..24190f3c9dd6 100644
--- a/arch/mips/math-emu/ieee754m.c
+++ b/arch/mips/math-emu/ieee754m.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/ieee754sp.c b/arch/mips/math-emu/ieee754sp.c
index a19b72185ab9..271d00d6113a 100644
--- a/arch/mips/math-emu/ieee754sp.c
+++ b/arch/mips/math-emu/ieee754sp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/ieee754sp.h b/arch/mips/math-emu/ieee754sp.h
index d9e3586b5bce..754fd54649b5 100644
--- a/arch/mips/math-emu/ieee754sp.h
+++ b/arch/mips/math-emu/ieee754sp.h
@@ -5,7 +5,6 @@
5/* 5/*
6 * MIPS floating point support 6 * MIPS floating point support
7 * Copyright (C) 1994-2000 Algorithmics Ltd. 7 * Copyright (C) 1994-2000 Algorithmics Ltd.
8 * http://www.algor.co.uk
9 * 8 *
10 * ######################################################################## 9 * ########################################################################
11 * 10 *
diff --git a/arch/mips/math-emu/ieee754xcpt.c b/arch/mips/math-emu/ieee754xcpt.c
index e02423a0ae23..b99a693c05af 100644
--- a/arch/mips/math-emu/ieee754xcpt.c
+++ b/arch/mips/math-emu/ieee754xcpt.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * MIPS floating point support 2 * MIPS floating point support
3 * Copyright (C) 1994-2000 Algorithmics Ltd. 3 * Copyright (C) 1994-2000 Algorithmics Ltd.
4 * http://www.algor.co.uk
5 * 4 *
6 * ######################################################################## 5 * ########################################################################
7 * 6 *
diff --git a/arch/mips/math-emu/sp_add.c b/arch/mips/math-emu/sp_add.c
index d8c4211bcfbe..ae1a327ccac0 100644
--- a/arch/mips/math-emu/sp_add.c
+++ b/arch/mips/math-emu/sp_add.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_cmp.c b/arch/mips/math-emu/sp_cmp.c
index d3eff6b04b5a..716cf37e2465 100644
--- a/arch/mips/math-emu/sp_cmp.c
+++ b/arch/mips/math-emu/sp_cmp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_div.c b/arch/mips/math-emu/sp_div.c
index 2b437fcfdad9..d7747928c954 100644
--- a/arch/mips/math-emu/sp_div.c
+++ b/arch/mips/math-emu/sp_div.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_fdp.c b/arch/mips/math-emu/sp_fdp.c
index 4093723d1aa5..e1515aae0166 100644
--- a/arch/mips/math-emu/sp_fdp.c
+++ b/arch/mips/math-emu/sp_fdp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_fint.c b/arch/mips/math-emu/sp_fint.c
index e88e125e01c2..9694d6c016cb 100644
--- a/arch/mips/math-emu/sp_fint.c
+++ b/arch/mips/math-emu/sp_fint.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_flong.c b/arch/mips/math-emu/sp_flong.c
index 26d6919a269a..16a651f29865 100644
--- a/arch/mips/math-emu/sp_flong.c
+++ b/arch/mips/math-emu/sp_flong.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_frexp.c b/arch/mips/math-emu/sp_frexp.c
index 359c6483dbfa..5bc993c30044 100644
--- a/arch/mips/math-emu/sp_frexp.c
+++ b/arch/mips/math-emu/sp_frexp.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_logb.c b/arch/mips/math-emu/sp_logb.c
index 3c337219ca32..9c14e0c75bd2 100644
--- a/arch/mips/math-emu/sp_logb.c
+++ b/arch/mips/math-emu/sp_logb.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_modf.c b/arch/mips/math-emu/sp_modf.c
index 76568946b4c0..25a0fbaa0556 100644
--- a/arch/mips/math-emu/sp_modf.c
+++ b/arch/mips/math-emu/sp_modf.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_mul.c b/arch/mips/math-emu/sp_mul.c
index 3f070f82212f..c06bb4022be5 100644
--- a/arch/mips/math-emu/sp_mul.c
+++ b/arch/mips/math-emu/sp_mul.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_scalb.c b/arch/mips/math-emu/sp_scalb.c
index 44ceb87ea944..dd76196984c8 100644
--- a/arch/mips/math-emu/sp_scalb.c
+++ b/arch/mips/math-emu/sp_scalb.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_simple.c b/arch/mips/math-emu/sp_simple.c
index 2fd53c920e99..ae4fcfafd853 100644
--- a/arch/mips/math-emu/sp_simple.c
+++ b/arch/mips/math-emu/sp_simple.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_sqrt.c b/arch/mips/math-emu/sp_sqrt.c
index 8a934b9f7eb8..fed20175f5fb 100644
--- a/arch/mips/math-emu/sp_sqrt.c
+++ b/arch/mips/math-emu/sp_sqrt.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_sub.c b/arch/mips/math-emu/sp_sub.c
index dbb802c1a086..886ed5bcfefb 100644
--- a/arch/mips/math-emu/sp_sub.c
+++ b/arch/mips/math-emu/sp_sub.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_tint.c b/arch/mips/math-emu/sp_tint.c
index 352dc3a5f1af..0fe9acc7716e 100644
--- a/arch/mips/math-emu/sp_tint.c
+++ b/arch/mips/math-emu/sp_tint.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/math-emu/sp_tlong.c b/arch/mips/math-emu/sp_tlong.c
index 92cd9c511a10..d0ca6e22be29 100644
--- a/arch/mips/math-emu/sp_tlong.c
+++ b/arch/mips/math-emu/sp_tlong.c
@@ -4,7 +4,6 @@
4/* 4/*
5 * MIPS floating point support 5 * MIPS floating point support
6 * Copyright (C) 1994-2000 Algorithmics Ltd. 6 * Copyright (C) 1994-2000 Algorithmics Ltd.
7 * http://www.algor.co.uk
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
10 * 9 *
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 7ba890860d98..469d4019f795 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -44,27 +44,39 @@ static inline int cpu_is_noncoherent_r10000(struct device *dev)
44 44
45static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp) 45static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
46{ 46{
47 gfp_t dma_flag;
48
47 /* ignore region specifiers */ 49 /* ignore region specifiers */
48 gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM); 50 gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
49 51
50#ifdef CONFIG_ZONE_DMA 52#ifdef CONFIG_ISA
51 if (dev == NULL) 53 if (dev == NULL)
52 gfp |= __GFP_DMA; 54 dma_flag = __GFP_DMA;
53 else if (dev->coherent_dma_mask < DMA_BIT_MASK(24))
54 gfp |= __GFP_DMA;
55 else 55 else
56#endif 56#endif
57#ifdef CONFIG_ZONE_DMA32 57#if defined(CONFIG_ZONE_DMA32) && defined(CONFIG_ZONE_DMA)
58 if (dev->coherent_dma_mask < DMA_BIT_MASK(32)) 58 if (dev->coherent_dma_mask < DMA_BIT_MASK(32))
59 gfp |= __GFP_DMA32; 59 dma_flag = __GFP_DMA;
60 else if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
61 dma_flag = __GFP_DMA32;
62 else
63#endif
64#if defined(CONFIG_ZONE_DMA32) && !defined(CONFIG_ZONE_DMA)
65 if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
66 dma_flag = __GFP_DMA32;
67 else
68#endif
69#if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
70 if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
71 dma_flag = __GFP_DMA;
60 else 72 else
61#endif 73#endif
62 ; 74 dma_flag = 0;
63 75
64 /* Don't invoke OOM killer */ 76 /* Don't invoke OOM killer */
65 gfp |= __GFP_NORETRY; 77 gfp |= __GFP_NORETRY;
66 78
67 return gfp; 79 return gfp | dma_flag;
68} 80}
69 81
70void *dma_alloc_noncoherent(struct device *dev, size_t size, 82void *dma_alloc_noncoherent(struct device *dev, size_t size,
diff --git a/arch/mips/mm/sc-rm7k.c b/arch/mips/mm/sc-rm7k.c
index 1ef75cd80a0d..274af3be1442 100644
--- a/arch/mips/mm/sc-rm7k.c
+++ b/arch/mips/mm/sc-rm7k.c
@@ -30,7 +30,7 @@
30#define tc_lsize 32 30#define tc_lsize 32
31 31
32extern unsigned long icache_way_size, dcache_way_size; 32extern unsigned long icache_way_size, dcache_way_size;
33unsigned long tcache_size; 33static unsigned long tcache_size;
34 34
35#include <asm/r4kcache.h> 35#include <asm/r4kcache.h>
36 36
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index 15949b0be811..b79b24afe3a2 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -385,6 +385,8 @@ static int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap);
385 */ 385 */
386 386
387#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK 387#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK
388#define X GIC_UNUSED
389
388static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = { 390static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
389 { X, X, X, X, 0 }, 391 { X, X, X, X, 0 },
390 { X, X, X, X, 0 }, 392 { X, X, X, X, 0 },
@@ -404,6 +406,7 @@ static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
404 { X, X, X, X, 0 }, 406 { X, X, X, X, 0 },
405 /* The remainder of this table is initialised by fill_ipi_map */ 407 /* The remainder of this table is initialised by fill_ipi_map */
406}; 408};
409#undef X
407 410
408/* 411/*
409 * GCMP needs to be detected before any SMP initialisation 412 * GCMP needs to be detected before any SMP initialisation
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c
index 72e32a7715be..4c35301720e7 100644
--- a/arch/mips/mti-malta/malta-platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
@@ -25,6 +25,7 @@
25#include <linux/serial_8250.h> 25#include <linux/serial_8250.h>
26#include <linux/mc146818rtc.h> 26#include <linux/mc146818rtc.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/irq.h>
28#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
30#include <linux/platform_device.h> 31#include <linux/platform_device.h>
diff --git a/arch/mips/pci/fixup-fuloong2e.c b/arch/mips/pci/fixup-fuloong2e.c
index 4f6d8da07f93..d5d4c018fb04 100644
--- a/arch/mips/pci/fixup-fuloong2e.c
+++ b/arch/mips/pci/fixup-fuloong2e.c
@@ -52,7 +52,7 @@ static void __init loongson2e_nec_fixup(struct pci_dev *pdev)
52{ 52{
53 unsigned int val; 53 unsigned int val;
54 54
55 /* Configues port 1, 2, 3, 4 to be validate*/ 55 /* Configures port 1, 2, 3, 4 to be validate*/
56 pci_read_config_dword(pdev, 0xe0, &val); 56 pci_read_config_dword(pdev, 0xe0, &val);
57 pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x4); 57 pci_write_config_dword(pdev, 0xe0, (val & ~7) | 0x4);
58 58
diff --git a/arch/mips/pci/ops-tx3927.c b/arch/mips/pci/ops-tx3927.c
index 31c150196595..6a3bdb5ffa80 100644
--- a/arch/mips/pci/ops-tx3927.c
+++ b/arch/mips/pci/ops-tx3927.c
@@ -38,6 +38,7 @@
38#include <linux/kernel.h> 38#include <linux/kernel.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/irq.h>
41 42
42#include <asm/addrspace.h> 43#include <asm/addrspace.h>
43#include <asm/txx9irq.h> 44#include <asm/txx9irq.h>
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index 5989e747527f..a1e7e6d80c8c 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/irq.h>
20#include <asm/txx9/pci.h> 21#include <asm/txx9/pci.h>
21#include <asm/txx9/tx4927pcic.h> 22#include <asm/txx9/tx4927pcic.h>
22 23
diff --git a/arch/mips/pci/pci-rc32434.c b/arch/mips/pci/pci-rc32434.c
index 71f7d27b0d4c..f31218e17d3c 100644
--- a/arch/mips/pci/pci-rc32434.c
+++ b/arch/mips/pci/pci-rc32434.c
@@ -118,7 +118,7 @@ static int __init rc32434_pcibridge_init(void)
118 if (!((pcicvalue == PCIM_H_EA) || 118 if (!((pcicvalue == PCIM_H_EA) ||
119 (pcicvalue == PCIM_H_IA_FIX) || 119 (pcicvalue == PCIM_H_IA_FIX) ||
120 (pcicvalue == PCIM_H_IA_RR))) { 120 (pcicvalue == PCIM_H_IA_RR))) {
121 pr_err(KERN_ERR "PCI init error!!!\n"); 121 pr_err("PCI init error!!!\n");
122 /* Not in Host Mode, return ERROR */ 122 /* Not in Host Mode, return ERROR */
123 return -1; 123 return -1;
124 } 124 }
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_irq_cic.c b/arch/mips/pmc-sierra/msp71xx/msp_irq_cic.c
index 94c9c2c9fbc1..07e71ff2433f 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_irq_cic.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_irq_cic.c
@@ -14,6 +14,7 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/irq.h>
17 18
18#include <asm/system.h> 19#include <asm/system.h>
19 20
diff --git a/arch/mips/pnx8550/common/reset.c b/arch/mips/pnx8550/common/reset.c
index fadd8744a6bc..e7a12ff304b9 100644
--- a/arch/mips/pnx8550/common/reset.c
+++ b/arch/mips/pnx8550/common/reset.c
@@ -22,29 +22,19 @@
22 */ 22 */
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24 24
25#include <asm/processor.h>
25#include <asm/reboot.h> 26#include <asm/reboot.h>
26#include <glb.h> 27#include <glb.h>
27 28
28void pnx8550_machine_restart(char *command) 29void pnx8550_machine_restart(char *command)
29{ 30{
30 char head[] = "************* Machine restart *************";
31 char foot[] = "*******************************************";
32
33 printk("\n\n");
34 printk("%s\n", head);
35 if (command != NULL)
36 printk("* %s\n", command);
37 printk("%s\n", foot);
38
39 PNX8550_RST_CTL = PNX8550_RST_DO_SW_RST; 31 PNX8550_RST_CTL = PNX8550_RST_DO_SW_RST;
40} 32}
41 33
42void pnx8550_machine_halt(void) 34void pnx8550_machine_halt(void)
43{ 35{
44 printk("*** Machine halt. (Not implemented) ***\n"); 36 while (1) {
45} 37 if (cpu_wait)
46 38 cpu_wait();
47void pnx8550_machine_power_off(void) 39 }
48{
49 printk("*** Machine power off. (Not implemented) ***\n");
50} 40}
diff --git a/arch/mips/pnx8550/common/setup.c b/arch/mips/pnx8550/common/setup.c
index 64246c9c875c..43cb3945fdbf 100644
--- a/arch/mips/pnx8550/common/setup.c
+++ b/arch/mips/pnx8550/common/setup.c
@@ -44,7 +44,6 @@
44extern void __init board_setup(void); 44extern void __init board_setup(void);
45extern void pnx8550_machine_restart(char *); 45extern void pnx8550_machine_restart(char *);
46extern void pnx8550_machine_halt(void); 46extern void pnx8550_machine_halt(void);
47extern void pnx8550_machine_power_off(void);
48extern struct resource ioport_resource; 47extern struct resource ioport_resource;
49extern struct resource iomem_resource; 48extern struct resource iomem_resource;
50extern char *prom_getcmdline(void); 49extern char *prom_getcmdline(void);
@@ -100,7 +99,7 @@ void __init plat_mem_setup(void)
100 99
101 _machine_restart = pnx8550_machine_restart; 100 _machine_restart = pnx8550_machine_restart;
102 _machine_halt = pnx8550_machine_halt; 101 _machine_halt = pnx8550_machine_halt;
103 pm_power_off = pnx8550_machine_power_off; 102 pm_power_off = pnx8550_machine_halt;
104 103
105 /* Clear the Global 2 Register, PCI Inta Output Enable Registers 104 /* Clear the Global 2 Register, PCI Inta Output Enable Registers
106 Bit 1:Enable DAC Powerdown 105 Bit 1:Enable DAC Powerdown
diff --git a/arch/mips/powertv/asic/irq_asic.c b/arch/mips/powertv/asic/irq_asic.c
index b54d24499b06..e55382434155 100644
--- a/arch/mips/powertv/asic/irq_asic.c
+++ b/arch/mips/powertv/asic/irq_asic.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/irq.h>
16 17
17#include <asm/irq_cpu.h> 18#include <asm/irq_cpu.h>
18#include <asm/mipsregs.h> 19#include <asm/mipsregs.h>
diff --git a/arch/mips/rb532/serial.c b/arch/mips/rb532/serial.c
index 00ed19f0bdb5..70482540b3db 100644
--- a/arch/mips/rb532/serial.c
+++ b/arch/mips/rb532/serial.c
@@ -29,6 +29,7 @@
29#include <linux/tty.h> 29#include <linux/tty.h>
30#include <linux/serial_core.h> 30#include <linux/serial_core.h>
31#include <linux/serial_8250.h> 31#include <linux/serial_8250.h>
32#include <linux/irq.h>
32 33
33#include <asm/serial.h> 34#include <asm/serial.h>
34#include <asm/mach-rc32434/rb.h> 35#include <asm/mach-rc32434/rb.h>
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index d4ed7a9156f5..87ccdb4b5ac9 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -43,7 +43,7 @@
43#include <asm/sibyte/sb1250_scd.h> 43#include <asm/sibyte/sb1250_scd.h>
44#include <asm/sibyte/sb1250_int.h> 44#include <asm/sibyte/sb1250_int.h>
45#else 45#else
46#error invalid SiByte UART configuation 46#error invalid SiByte UART configuration
47#endif 47#endif
48 48
49#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) 49#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
@@ -545,6 +545,7 @@ static const struct file_operations sbprof_tb_fops = {
545 .unlocked_ioctl = sbprof_tb_ioctl, 545 .unlocked_ioctl = sbprof_tb_ioctl,
546 .compat_ioctl = sbprof_tb_ioctl, 546 .compat_ioctl = sbprof_tb_ioctl,
547 .mmap = NULL, 547 .mmap = NULL,
548 .llseek = default_llseek,
548}; 549};
549 550
550static struct class *tb_class; 551static struct class *tb_class;
diff --git a/arch/mips/sni/a20r.c b/arch/mips/sni/a20r.c
index e6980892834a..bbe7187879fa 100644
--- a/arch/mips/sni/a20r.c
+++ b/arch/mips/sni/a20r.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/irq.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
15 16
diff --git a/arch/mips/sni/pcimt.c b/arch/mips/sni/pcimt.c
index 51e62bbaa23b..8c92c73bc717 100644
--- a/arch/mips/sni/pcimt.c
+++ b/arch/mips/sni/pcimt.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h>
14#include <linux/pci.h> 15#include <linux/pci.h>
15#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
16 17
diff --git a/arch/mips/sni/pcit.c b/arch/mips/sni/pcit.c
index f4699d35858b..dc9874553bec 100644
--- a/arch/mips/sni/pcit.c
+++ b/arch/mips/sni/pcit.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/irq.h>
13#include <linux/pci.h> 14#include <linux/pci.h>
14#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
15 16
diff --git a/arch/mips/sni/rm200.c b/arch/mips/sni/rm200.c
index 90c558f7c0fa..0e6f42c2bbc8 100644
--- a/arch/mips/sni/rm200.c
+++ b/arch/mips/sni/rm200.c
@@ -13,6 +13,7 @@
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/irq.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/serial_8250.h> 18#include <linux/serial_8250.h>
18#include <linux/io.h> 19#include <linux/io.h>
diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c
index f3b60e671207..c76151b56568 100644
--- a/arch/mips/sni/time.c
+++ b/arch/mips/sni/time.c
@@ -1,5 +1,6 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include <linux/interrupt.h> 2#include <linux/interrupt.h>
3#include <linux/irq.h>
3#include <linux/smp.h> 4#include <linux/smp.h>
4#include <linux/time.h> 5#include <linux/time.h>
5#include <linux/clockchips.h> 6#include <linux/clockchips.h>
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c
index ad2870def8f1..e1828e8bcaef 100644
--- a/arch/mips/txx9/generic/irq_tx4927.c
+++ b/arch/mips/txx9/generic/irq_tx4927.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/irq.h>
28#include <asm/irq_cpu.h> 29#include <asm/irq_cpu.h>
29#include <asm/txx9/tx4927.h> 30#include <asm/txx9/tx4927.h>
30 31
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c
index 025ae11359a8..a6e6e805097a 100644
--- a/arch/mips/txx9/generic/irq_tx4938.c
+++ b/arch/mips/txx9/generic/irq_tx4938.c
@@ -13,6 +13,7 @@
13 */ 13 */
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/irq.h>
16#include <asm/irq_cpu.h> 17#include <asm/irq_cpu.h>
17#include <asm/txx9/tx4938.h> 18#include <asm/txx9/tx4938.h>
18 19
diff --git a/arch/mips/txx9/generic/irq_tx4939.c b/arch/mips/txx9/generic/irq_tx4939.c
index 013213a8706b..3886ad77cbad 100644
--- a/arch/mips/txx9/generic/irq_tx4939.c
+++ b/arch/mips/txx9/generic/irq_tx4939.c
@@ -19,6 +19,7 @@
19 */ 19 */
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/irq.h>
22#include <linux/types.h> 23#include <linux/types.h>
23#include <asm/irq_cpu.h> 24#include <asm/irq_cpu.h>
24#include <asm/txx9irq.h> 25#include <asm/txx9irq.h>
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 575d219b8001..812816c45662 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -24,6 +24,7 @@
24#include <linux/leds.h> 24#include <linux/leds.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/irq.h>
27#include <asm/bootinfo.h> 28#include <asm/bootinfo.h>
28#include <asm/time.h> 29#include <asm/time.h>
29#include <asm/reboot.h> 30#include <asm/reboot.h>
diff --git a/arch/mips/txx9/jmr3927/irq.c b/arch/mips/txx9/jmr3927/irq.c
index 6ec626c9473f..0a7f8e3b9fd7 100644
--- a/arch/mips/txx9/jmr3927/irq.c
+++ b/arch/mips/txx9/jmr3927/irq.c
@@ -32,6 +32,7 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/irq.h>
35 36
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/mipsregs.h> 38#include <asm/mipsregs.h>
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
index 9c14ebb26cb4..c4b54d20efd3 100644
--- a/arch/mips/txx9/rbtx4927/irq.c
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -111,6 +111,7 @@
111#include <linux/init.h> 111#include <linux/init.h>
112#include <linux/types.h> 112#include <linux/types.h>
113#include <linux/interrupt.h> 113#include <linux/interrupt.h>
114#include <linux/irq.h>
114#include <asm/io.h> 115#include <asm/io.h>
115#include <asm/mipsregs.h> 116#include <asm/mipsregs.h>
116#include <asm/txx9/generic.h> 117#include <asm/txx9/generic.h>
diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c
index 7d21befb8932..67a73a8065ec 100644
--- a/arch/mips/txx9/rbtx4938/irq.c
+++ b/arch/mips/txx9/rbtx4938/irq.c
@@ -64,6 +64,7 @@
64 */ 64 */
65#include <linux/init.h> 65#include <linux/init.h>
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/irq.h>
67#include <asm/mipsregs.h> 68#include <asm/mipsregs.h>
68#include <asm/txx9/generic.h> 69#include <asm/txx9/generic.h>
69#include <asm/txx9/rbtx4938.h> 70#include <asm/txx9/rbtx4938.h>
diff --git a/arch/mips/txx9/rbtx4939/irq.c b/arch/mips/txx9/rbtx4939/irq.c
index 500cc0a908e6..57fa740a7205 100644
--- a/arch/mips/txx9/rbtx4939/irq.c
+++ b/arch/mips/txx9/rbtx4939/irq.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/irq.h>
14#include <asm/mipsregs.h> 15#include <asm/mipsregs.h>
15#include <asm/txx9/rbtx4939.h> 16#include <asm/txx9/rbtx4939.h>
16 17
diff --git a/arch/mips/vr41xx/common/irq.c b/arch/mips/vr41xx/common/irq.c
index bef06872f012..0975eb72d385 100644
--- a/arch/mips/vr41xx/common/irq.c
+++ b/arch/mips/vr41xx/common/irq.c
@@ -19,6 +19,7 @@
19 */ 19 */
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/irq.h>
22 23
23#include <asm/irq_cpu.h> 24#include <asm/irq_cpu.h>
24#include <asm/system.h> 25#include <asm/system.h>
diff --git a/arch/mips/vr41xx/common/siu.c b/arch/mips/vr41xx/common/siu.c
index 54eae56108fb..bbd45d2559d6 100644
--- a/arch/mips/vr41xx/common/siu.c
+++ b/arch/mips/vr41xx/common/siu.c
@@ -22,6 +22,7 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/irq.h>
25 26
26#include <asm/cpu.h> 27#include <asm/cpu.h>
27#include <asm/vr41xx/siu.h> 28#include <asm/vr41xx/siu.h>
diff --git a/arch/mn10300/include/asm/ioctls.h b/arch/mn10300/include/asm/ioctls.h
index cb8cf1902234..0212f4b22557 100644
--- a/arch/mn10300/include/asm/ioctls.h
+++ b/arch/mn10300/include/asm/ioctls.h
@@ -1,88 +1,6 @@
1#ifndef _ASM_IOCTLS_H 1#ifndef _ASM_IOCTLS_H
2#define _ASM_IOCTLS_H 2#define _ASM_IOCTLS_H
3 3
4#include <asm/ioctl.h> 4#include <asm-generic/ioctls.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T', 0x2A, struct termios2)
51#define TCSETS2 _IOW('T', 0x2B, struct termios2)
52#define TCSETSW2 _IOW('T', 0x2C, struct termios2)
53#define TCSETSF2 _IOW('T', 0x2D, struct termios2)
54#define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number
55 * (of pty-mux device) */
56#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */
57#define TIOCSIG _IOW('T', 0x36, int) /* Generate signal on Pty slave */
58
59#define FIONCLEX 0x5450
60#define FIOCLEX 0x5451
61#define FIOASYNC 0x5452
62#define TIOCSERCONFIG 0x5453
63#define TIOCSERGWILD 0x5454
64#define TIOCSERSWILD 0x5455
65#define TIOCGLCKTRMIOS 0x5456
66#define TIOCSLCKTRMIOS 0x5457
67#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
68#define TIOCSERGETLSR 0x5459 /* Get line status register */
69#define TIOCSERGETMULTI 0x545A /* Get multiport config */
70#define TIOCSERSETMULTI 0x545B /* Set multiport config */
71
72#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
73#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
74#define FIOQSIZE 0x5460
75
76/* Used for packet mode */
77#define TIOCPKT_DATA 0
78#define TIOCPKT_FLUSHREAD 1
79#define TIOCPKT_FLUSHWRITE 2
80#define TIOCPKT_STOP 4
81#define TIOCPKT_START 8
82#define TIOCPKT_NOSTOP 16
83#define TIOCPKT_DOSTOP 32
84#define TIOCPKT_IOCTL 64
85
86#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
87 5
88#endif /* _ASM_IOCTLS_H */ 6#endif /* _ASM_IOCTLS_H */
diff --git a/arch/mn10300/include/asm/irqflags.h b/arch/mn10300/include/asm/irqflags.h
new file mode 100644
index 000000000000..5e529a117cb2
--- /dev/null
+++ b/arch/mn10300/include/asm/irqflags.h
@@ -0,0 +1,123 @@
1/* MN10300 IRQ flag handling
2 *
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _ASM_IRQFLAGS_H
13#define _ASM_IRQFLAGS_H
14
15#include <asm/cpu-regs.h>
16
17/*
18 * interrupt control
19 * - "disabled": run in IM1/2
20 * - level 0 - GDB stub
21 * - level 1 - virtual serial DMA (if present)
22 * - level 5 - normal interrupt priority
23 * - level 6 - timer interrupt
24 * - "enabled": run in IM7
25 */
26#ifdef CONFIG_MN10300_TTYSM
27#define MN10300_CLI_LEVEL EPSW_IM_2
28#else
29#define MN10300_CLI_LEVEL EPSW_IM_1
30#endif
31
32#ifndef __ASSEMBLY__
33
34static inline unsigned long arch_local_save_flags(void)
35{
36 unsigned long flags;
37
38 asm volatile("mov epsw,%0" : "=d"(flags));
39 return flags;
40}
41
42static inline void arch_local_irq_disable(void)
43{
44 asm volatile(
45 " and %0,epsw \n"
46 " or %1,epsw \n"
47 " nop \n"
48 " nop \n"
49 " nop \n"
50 :
51 : "i"(~EPSW_IM), "i"(EPSW_IE | MN10300_CLI_LEVEL)
52 : "memory");
53}
54
55static inline unsigned long arch_local_irq_save(void)
56{
57 unsigned long flags;
58
59 flags = arch_local_save_flags();
60 arch_local_irq_disable();
61 return flags;
62}
63
64/*
65 * we make sure arch_irq_enable() doesn't cause priority inversion
66 */
67extern unsigned long __mn10300_irq_enabled_epsw;
68
69static inline void arch_local_irq_enable(void)
70{
71 unsigned long tmp;
72
73 asm volatile(
74 " mov epsw,%0 \n"
75 " and %1,%0 \n"
76 " or %2,%0 \n"
77 " mov %0,epsw \n"
78 : "=&d"(tmp)
79 : "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw)
80 : "memory");
81}
82
83static inline void arch_local_irq_restore(unsigned long flags)
84{
85 asm volatile(
86 " mov %0,epsw \n"
87 " nop \n"
88 " nop \n"
89 " nop \n"
90 :
91 : "d"(flags)
92 : "memory", "cc");
93}
94
95static inline bool arch_irqs_disabled_flags(unsigned long flags)
96{
97 return (flags & EPSW_IM) <= MN10300_CLI_LEVEL;
98}
99
100static inline bool arch_irqs_disabled(void)
101{
102 return arch_irqs_disabled_flags(arch_local_save_flags());
103}
104
105/*
106 * Hook to save power by halting the CPU
107 * - called from the idle loop
108 * - must reenable interrupts (which takes three instruction cycles to complete)
109 */
110static inline void arch_safe_halt(void)
111{
112 asm volatile(
113 " or %0,epsw \n"
114 " nop \n"
115 " nop \n"
116 " bset %2,(%1) \n"
117 :
118 : "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP)
119 : "cc");
120}
121
122#endif /* __ASSEMBLY__ */
123#endif /* _ASM_IRQFLAGS_H */
diff --git a/arch/mn10300/include/asm/system.h b/arch/mn10300/include/asm/system.h
index 3636c054dcd5..9f7c7e17c01e 100644
--- a/arch/mn10300/include/asm/system.h
+++ b/arch/mn10300/include/asm/system.h
@@ -17,6 +17,7 @@
17#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/irqflags.h>
20 21
21struct task_struct; 22struct task_struct;
22struct thread_struct; 23struct thread_struct;
@@ -81,114 +82,6 @@ do { \
81 82
82/*****************************************************************************/ 83/*****************************************************************************/
83/* 84/*
84 * interrupt control
85 * - "disabled": run in IM1/2
86 * - level 0 - GDB stub
87 * - level 1 - virtual serial DMA (if present)
88 * - level 5 - normal interrupt priority
89 * - level 6 - timer interrupt
90 * - "enabled": run in IM7
91 */
92#ifdef CONFIG_MN10300_TTYSM
93#define MN10300_CLI_LEVEL EPSW_IM_2
94#else
95#define MN10300_CLI_LEVEL EPSW_IM_1
96#endif
97
98#define local_save_flags(x) \
99do { \
100 typecheck(unsigned long, x); \
101 asm volatile( \
102 " mov epsw,%0 \n" \
103 : "=d"(x) \
104 ); \
105} while (0)
106
107#define local_irq_disable() \
108do { \
109 asm volatile( \
110 " and %0,epsw \n" \
111 " or %1,epsw \n" \
112 " nop \n" \
113 " nop \n" \
114 " nop \n" \
115 : \
116 : "i"(~EPSW_IM), "i"(EPSW_IE | MN10300_CLI_LEVEL) \
117 ); \
118} while (0)
119
120#define local_irq_save(x) \
121do { \
122 local_save_flags(x); \
123 local_irq_disable(); \
124} while (0)
125
126/*
127 * we make sure local_irq_enable() doesn't cause priority inversion
128 */
129#ifndef __ASSEMBLY__
130
131extern unsigned long __mn10300_irq_enabled_epsw;
132
133#endif
134
135#define local_irq_enable() \
136do { \
137 unsigned long tmp; \
138 \
139 asm volatile( \
140 " mov epsw,%0 \n" \
141 " and %1,%0 \n" \
142 " or %2,%0 \n" \
143 " mov %0,epsw \n" \
144 : "=&d"(tmp) \
145 : "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw) \
146 : "cc" \
147 ); \
148} while (0)
149
150#define local_irq_restore(x) \
151do { \
152 typecheck(unsigned long, x); \
153 asm volatile( \
154 " mov %0,epsw \n" \
155 " nop \n" \
156 " nop \n" \
157 " nop \n" \
158 : \
159 : "d"(x) \
160 : "memory", "cc" \
161 ); \
162} while (0)
163
164#define irqs_disabled() \
165({ \
166 unsigned long flags; \
167 local_save_flags(flags); \
168 (flags & EPSW_IM) <= MN10300_CLI_LEVEL; \
169})
170
171/* hook to save power by halting the CPU
172 * - called from the idle loop
173 * - must reenable interrupts (which takes three instruction cycles to complete)
174 */
175#define safe_halt() \
176do { \
177 asm volatile(" or %0,epsw \n" \
178 " nop \n" \
179 " nop \n" \
180 " bset %2,(%1) \n" \
181 : \
182 : "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP)\
183 : "cc" \
184 ); \
185} while (0)
186
187#define STI or EPSW_IE|EPSW_IM,epsw
188#define CLI and ~EPSW_IM,epsw; or EPSW_IE|MN10300_CLI_LEVEL,epsw; nop; nop; nop
189
190/*****************************************************************************/
191/*
192 * MN10300 doesn't actually have an exchange instruction 85 * MN10300 doesn't actually have an exchange instruction
193 */ 86 */
194#ifndef __ASSEMBLY__ 87#ifndef __ASSEMBLY__
diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
index d9ed5a15c547..3d394b4eefba 100644
--- a/arch/mn10300/kernel/entry.S
+++ b/arch/mn10300/kernel/entry.S
@@ -16,6 +16,7 @@
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <asm/smp.h> 17#include <asm/smp.h>
18#include <asm/system.h> 18#include <asm/system.h>
19#include <asm/irqflags.h>
19#include <asm/thread_info.h> 20#include <asm/thread_info.h>
20#include <asm/intctl-regs.h> 21#include <asm/intctl-regs.h>
21#include <asm/busctl-regs.h> 22#include <asm/busctl-regs.h>
diff --git a/arch/mn10300/kernel/module.c b/arch/mn10300/kernel/module.c
index 6aea7fd76993..196a111e2e29 100644
--- a/arch/mn10300/kernel/module.c
+++ b/arch/mn10300/kernel/module.c
@@ -206,7 +206,7 @@ int module_finalize(const Elf_Ehdr *hdr,
206 const Elf_Shdr *sechdrs, 206 const Elf_Shdr *sechdrs,
207 struct module *me) 207 struct module *me)
208{ 208{
209 return module_bug_finalize(hdr, sechdrs, me); 209 return 0;
210} 210}
211 211
212/* 212/*
@@ -214,5 +214,4 @@ int module_finalize(const Elf_Ehdr *hdr,
214 */ 214 */
215void module_arch_cleanup(struct module *mod) 215void module_arch_cleanup(struct module *mod)
216{ 216{
217 module_bug_cleanup(mod);
218} 217}
diff --git a/arch/mn10300/mm/cache.c b/arch/mn10300/mm/cache.c
index 1b76719ec1c3..9261217e8d2c 100644
--- a/arch/mn10300/mm/cache.c
+++ b/arch/mn10300/mm/cache.c
@@ -54,13 +54,30 @@ EXPORT_SYMBOL(flush_icache_page);
54void flush_icache_range(unsigned long start, unsigned long end) 54void flush_icache_range(unsigned long start, unsigned long end)
55{ 55{
56#ifdef CONFIG_MN10300_CACHE_WBACK 56#ifdef CONFIG_MN10300_CACHE_WBACK
57 unsigned long addr, size, off; 57 unsigned long addr, size, base, off;
58 struct page *page; 58 struct page *page;
59 pgd_t *pgd; 59 pgd_t *pgd;
60 pud_t *pud; 60 pud_t *pud;
61 pmd_t *pmd; 61 pmd_t *pmd;
62 pte_t *ppte, pte; 62 pte_t *ppte, pte;
63 63
64 if (end > 0x80000000UL) {
65 /* addresses above 0xa0000000 do not go through the cache */
66 if (end > 0xa0000000UL) {
67 end = 0xa0000000UL;
68 if (start >= end)
69 return;
70 }
71
72 /* kernel addresses between 0x80000000 and 0x9fffffff do not
73 * require page tables, so we just map such addresses directly */
74 base = (start >= 0x80000000UL) ? start : 0x80000000UL;
75 mn10300_dcache_flush_range(base, end);
76 if (base == start)
77 goto invalidate;
78 end = base;
79 }
80
64 for (; start < end; start += size) { 81 for (; start < end; start += size) {
65 /* work out how much of the page to flush */ 82 /* work out how much of the page to flush */
66 off = start & (PAGE_SIZE - 1); 83 off = start & (PAGE_SIZE - 1);
@@ -104,6 +121,7 @@ void flush_icache_range(unsigned long start, unsigned long end)
104 } 121 }
105#endif 122#endif
106 123
124invalidate:
107 mn10300_icache_inv(); 125 mn10300_icache_inv();
108} 126}
109EXPORT_SYMBOL(flush_icache_range); 127EXPORT_SYMBOL(flush_icache_range);
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 907417d187e1..79a04a9394d5 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -16,6 +16,7 @@ config PARISC
16 select RTC_DRV_GENERIC 16 select RTC_DRV_GENERIC
17 select INIT_ALL_POSSIBLE 17 select INIT_ALL_POSSIBLE
18 select BUG 18 select BUG
19 select HAVE_IRQ_WORK
19 select HAVE_PERF_EVENTS 20 select HAVE_PERF_EVENTS
20 select GENERIC_ATOMIC64 if !64BIT 21 select GENERIC_ATOMIC64 if !64BIT
21 help 22 help
diff --git a/arch/parisc/include/asm/irqflags.h b/arch/parisc/include/asm/irqflags.h
new file mode 100644
index 000000000000..34f9cb9b4754
--- /dev/null
+++ b/arch/parisc/include/asm/irqflags.h
@@ -0,0 +1,46 @@
1#ifndef __PARISC_IRQFLAGS_H
2#define __PARISC_IRQFLAGS_H
3
4#include <linux/types.h>
5#include <asm/psw.h>
6
7static inline unsigned long arch_local_save_flags(void)
8{
9 unsigned long flags;
10 asm volatile("ssm 0, %0" : "=r" (flags) : : "memory");
11 return flags;
12}
13
14static inline void arch_local_irq_disable(void)
15{
16 asm volatile("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory");
17}
18
19static inline void arch_local_irq_enable(void)
20{
21 asm volatile("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory");
22}
23
24static inline unsigned long arch_local_irq_save(void)
25{
26 unsigned long flags;
27 asm volatile("rsm %1,%0" : "=r" (flags) : "i" (PSW_I) : "memory");
28 return flags;
29}
30
31static inline void arch_local_irq_restore(unsigned long flags)
32{
33 asm volatile("mtsm %0" : : "r" (flags) : "memory");
34}
35
36static inline bool arch_irqs_disabled_flags(unsigned long flags)
37{
38 return (flags & PSW_I) == 0;
39}
40
41static inline bool arch_irqs_disabled(void)
42{
43 return arch_irqs_disabled_flags(arch_local_save_flags());
44}
45
46#endif /* __PARISC_IRQFLAGS_H */
diff --git a/arch/parisc/include/asm/perf_event.h b/arch/parisc/include/asm/perf_event.h
index cc146427d8f9..1e0fd8ba6c03 100644
--- a/arch/parisc/include/asm/perf_event.h
+++ b/arch/parisc/include/asm/perf_event.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_PARISC_PERF_EVENT_H 1#ifndef __ASM_PARISC_PERF_EVENT_H
2#define __ASM_PARISC_PERF_EVENT_H 2#define __ASM_PARISC_PERF_EVENT_H
3 3
4/* parisc only supports software events through this interface. */ 4/* Empty, just to avoid compiling error */
5static inline void set_perf_event_pending(void) { }
6 5
7#endif /* __ASM_PARISC_PERF_EVENT_H */ 6#endif /* __ASM_PARISC_PERF_EVENT_H */
diff --git a/arch/parisc/include/asm/system.h b/arch/parisc/include/asm/system.h
index 2ab4af58ecb9..b19e63a8e848 100644
--- a/arch/parisc/include/asm/system.h
+++ b/arch/parisc/include/asm/system.h
@@ -1,7 +1,7 @@
1#ifndef __PARISC_SYSTEM_H 1#ifndef __PARISC_SYSTEM_H
2#define __PARISC_SYSTEM_H 2#define __PARISC_SYSTEM_H
3 3
4#include <asm/psw.h> 4#include <linux/irqflags.h>
5 5
6/* The program status word as bitfields. */ 6/* The program status word as bitfields. */
7struct pa_psw { 7struct pa_psw {
@@ -48,23 +48,6 @@ extern struct task_struct *_switch_to(struct task_struct *, struct task_struct *
48 (last) = _switch_to(prev, next); \ 48 (last) = _switch_to(prev, next); \
49} while(0) 49} while(0)
50 50
51/* interrupt control */
52#define local_save_flags(x) __asm__ __volatile__("ssm 0, %0" : "=r" (x) : : "memory")
53#define local_irq_disable() __asm__ __volatile__("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
54#define local_irq_enable() __asm__ __volatile__("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
55
56#define local_irq_save(x) \
57 __asm__ __volatile__("rsm %1,%0" : "=r" (x) :"i" (PSW_I) : "memory" )
58#define local_irq_restore(x) \
59 __asm__ __volatile__("mtsm %0" : : "r" (x) : "memory" )
60
61#define irqs_disabled() \
62({ \
63 unsigned long flags; \
64 local_save_flags(flags); \
65 (flags & PSW_I) == 0; \
66})
67
68#define mfctl(reg) ({ \ 51#define mfctl(reg) ({ \
69 unsigned long cr; \ 52 unsigned long cr; \
70 __asm__ __volatile__( \ 53 __asm__ __volatile__( \
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index 159a2b81e90c..6e81bb596e5b 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -941,11 +941,10 @@ int module_finalize(const Elf_Ehdr *hdr,
941 nsyms = newptr - (Elf_Sym *)symhdr->sh_addr; 941 nsyms = newptr - (Elf_Sym *)symhdr->sh_addr;
942 DEBUGP("NEW num_symtab %lu\n", nsyms); 942 DEBUGP("NEW num_symtab %lu\n", nsyms);
943 symhdr->sh_size = nsyms * sizeof(Elf_Sym); 943 symhdr->sh_size = nsyms * sizeof(Elf_Sym);
944 return module_bug_finalize(hdr, sechdrs, me); 944 return 0;
945} 945}
946 946
947void module_arch_cleanup(struct module *mod) 947void module_arch_cleanup(struct module *mod)
948{ 948{
949 deregister_unwind_table(mod); 949 deregister_unwind_table(mod);
950 module_bug_cleanup(mod);
951} 950}
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index f9f6783e4bdd..ba0c053e25ae 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -46,7 +46,6 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
49#include <linux/smp_lock.h>
50#include <linux/spinlock.h> 49#include <linux/spinlock.h>
51 50
52#include <asm/uaccess.h> 51#include <asm/uaccess.h>
@@ -261,16 +260,13 @@ printk("Preparing to start counters\n");
261 */ 260 */
262static int perf_open(struct inode *inode, struct file *file) 261static int perf_open(struct inode *inode, struct file *file)
263{ 262{
264 lock_kernel();
265 spin_lock(&perf_lock); 263 spin_lock(&perf_lock);
266 if (perf_enabled) { 264 if (perf_enabled) {
267 spin_unlock(&perf_lock); 265 spin_unlock(&perf_lock);
268 unlock_kernel();
269 return -EBUSY; 266 return -EBUSY;
270 } 267 }
271 perf_enabled = 1; 268 perf_enabled = 1;
272 spin_unlock(&perf_lock); 269 spin_unlock(&perf_lock);
273 unlock_kernel();
274 270
275 return 0; 271 return 0;
276} 272}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 44df1bac9701..29158913a66b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -138,6 +138,7 @@ config PPC
138 select HAVE_OPROFILE 138 select HAVE_OPROFILE
139 select HAVE_SYSCALL_WRAPPERS if PPC64 139 select HAVE_SYSCALL_WRAPPERS if PPC64
140 select GENERIC_ATOMIC64 if PPC32 140 select GENERIC_ATOMIC64 if PPC32
141 select HAVE_IRQ_WORK
141 select HAVE_PERF_EVENTS 142 select HAVE_PERF_EVENTS
142 select HAVE_REGS_AND_STACK_ACCESS_API 143 select HAVE_REGS_AND_STACK_ACCESS_API
143 select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 144 select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index b1e5611b2ab1..349b5530d2c4 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -20,7 +20,7 @@
20#include <string.h> 20#include <string.h>
21 21
22/* CHRP note section */ 22/* CHRP note section */
23char arch[] = "PowerPC"; 23static const char arch[] = "PowerPC";
24 24
25#define N_DESCR 6 25#define N_DESCR 6
26unsigned int descr[N_DESCR] = { 26unsigned int descr[N_DESCR] = {
@@ -33,7 +33,7 @@ unsigned int descr[N_DESCR] = {
33}; 33};
34 34
35/* RPA note section */ 35/* RPA note section */
36char rpaname[] = "IBM,RPA-Client-Config"; 36static const char rpaname[] = "IBM,RPA-Client-Config";
37 37
38/* 38/*
39 * Note: setting ignore_my_client_config *should* mean that OF ignores 39 * Note: setting ignore_my_client_config *should* mean that OF ignores
diff --git a/arch/powerpc/boot/dts/bluestone.dts b/arch/powerpc/boot/dts/bluestone.dts
new file mode 100644
index 000000000000..9bb3d72c0e5a
--- /dev/null
+++ b/arch/powerpc/boot/dts/bluestone.dts
@@ -0,0 +1,254 @@
1/*
2 * Device Tree for Bluestone (APM821xx) board.
3 *
4 * Copyright (c) 2010, Applied Micro Circuits Corporation
5 * Author: Tirumala R Marri <tmarri@apm.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 *
22 */
23
24/dts-v1/;
25
26/ {
27 #address-cells = <2>;
28 #size-cells = <1>;
29 model = "apm,bluestone";
30 compatible = "apm,bluestone";
31 dcr-parent = <&{/cpus/cpu@0}>;
32
33 aliases {
34 ethernet0 = &EMAC0;
35 serial0 = &UART0;
36 serial1 = &UART1;
37 };
38
39 cpus {
40 #address-cells = <1>;
41 #size-cells = <0>;
42
43 cpu@0 {
44 device_type = "cpu";
45 model = "PowerPC,apm821xx";
46 reg = <0x00000000>;
47 clock-frequency = <0>; /* Filled in by U-Boot */
48 timebase-frequency = <0>; /* Filled in by U-Boot */
49 i-cache-line-size = <32>;
50 d-cache-line-size = <32>;
51 i-cache-size = <32768>;
52 d-cache-size = <32768>;
53 dcr-controller;
54 dcr-access-method = "native";
55 next-level-cache = <&L2C0>;
56 };
57 };
58
59 memory {
60 device_type = "memory";
61 reg = <0x00000000 0x00000000 0x00000000>; /* Filled in by U-Boot */
62 };
63
64 UIC0: interrupt-controller0 {
65 compatible = "ibm,uic";
66 interrupt-controller;
67 cell-index = <0>;
68 dcr-reg = <0x0c0 0x009>;
69 #address-cells = <0>;
70 #size-cells = <0>;
71 #interrupt-cells = <2>;
72 };
73
74 UIC1: interrupt-controller1 {
75 compatible = "ibm,uic";
76 interrupt-controller;
77 cell-index = <1>;
78 dcr-reg = <0x0d0 0x009>;
79 #address-cells = <0>;
80 #size-cells = <0>;
81 #interrupt-cells = <2>;
82 interrupts = <0x1e 0x4 0x1f 0x4>; /* cascade */
83 interrupt-parent = <&UIC0>;
84 };
85
86 UIC2: interrupt-controller2 {
87 compatible = "ibm,uic";
88 interrupt-controller;
89 cell-index = <2>;
90 dcr-reg = <0x0e0 0x009>;
91 #address-cells = <0>;
92 #size-cells = <0>;
93 #interrupt-cells = <2>;
94 interrupts = <0xa 0x4 0xb 0x4>; /* cascade */
95 interrupt-parent = <&UIC0>;
96 };
97
98 UIC3: interrupt-controller3 {
99 compatible = "ibm,uic";
100 interrupt-controller;
101 cell-index = <3>;
102 dcr-reg = <0x0f0 0x009>;
103 #address-cells = <0>;
104 #size-cells = <0>;
105 #interrupt-cells = <2>;
106 interrupts = <0x10 0x4 0x11 0x4>; /* cascade */
107 interrupt-parent = <&UIC0>;
108 };
109
110 SDR0: sdr {
111 compatible = "ibm,sdr-apm821xx";
112 dcr-reg = <0x00e 0x002>;
113 };
114
115 CPR0: cpr {
116 compatible = "ibm,cpr-apm821xx";
117 dcr-reg = <0x00c 0x002>;
118 };
119
120 plb {
121 compatible = "ibm,plb4";
122 #address-cells = <2>;
123 #size-cells = <1>;
124 ranges;
125 clock-frequency = <0>; /* Filled in by U-Boot */
126
127 SDRAM0: sdram {
128 compatible = "ibm,sdram-apm821xx";
129 dcr-reg = <0x010 0x002>;
130 };
131
132 MAL0: mcmal {
133 compatible = "ibm,mcmal2";
134 descriptor-memory = "ocm";
135 dcr-reg = <0x180 0x062>;
136 num-tx-chans = <1>;
137 num-rx-chans = <1>;
138 #address-cells = <0>;
139 #size-cells = <0>;
140 interrupt-parent = <&UIC2>;
141 interrupts = < /*TXEOB*/ 0x6 0x4
142 /*RXEOB*/ 0x7 0x4
143 /*SERR*/ 0x3 0x4
144 /*TXDE*/ 0x4 0x4
145 /*RXDE*/ 0x5 0x4
146 };
147
148 POB0: opb {
149 compatible = "ibm,opb";
150 #address-cells = <1>;
151 #size-cells = <1>;
152 ranges = <0xb0000000 0x00000004 0xb0000000 0x50000000>;
153 clock-frequency = <0>; /* Filled in by U-Boot */
154
155 EBC0: ebc {
156 compatible = "ibm,ebc";
157 dcr-reg = <0x012 0x002>;
158 #address-cells = <2>;
159 #size-cells = <1>;
160 clock-frequency = <0>; /* Filled in by U-Boot */
161 /* ranges property is supplied by U-Boot */
162 ranges = < 0x00000003 0x00000000 0xe0000000 0x8000000>;
163 interrupts = <0x6 0x4>;
164 interrupt-parent = <&UIC1>;
165
166 nor_flash@0,0 {
167 compatible = "amd,s29gl512n", "cfi-flash";
168 bank-width = <2>;
169 reg = <0x00000000 0x00000000 0x00400000>;
170 #address-cells = <1>;
171 #size-cells = <1>;
172 partition@0 {
173 label = "kernel";
174 reg = <0x00000000 0x00180000>;
175 };
176 partition@180000 {
177 label = "env";
178 reg = <0x00180000 0x00020000>;
179 };
180 partition@1a0000 {
181 label = "u-boot";
182 reg = <0x001a0000 0x00060000>;
183 };
184 };
185 }
186
187 UART0: serial@ef600300 {
188 device_type = "serial";
189 compatible = "ns16550";
190 reg = <0xef600300 0x00000008>;
191 virtual-reg = <0xef600300>;
192 clock-frequency = <0>; /* Filled in by U-Boot */
193 current-speed = <0>; /* Filled in by U-Boot */
194 interrupt-parent = <&UIC1>;
195 interrupts = <0x1 0x4>;
196 };
197
198 IIC0: i2c@ef600700 {
199 compatible = "ibm,iic";
200 reg = <0xef600700 0x00000014>;
201 interrupt-parent = <&UIC0>;
202 interrupts = <0x2 0x4>;
203 };
204
205 IIC1: i2c@ef600800 {
206 compatible = "ibm,iic";
207 reg = <0xef600800 0x00000014>;
208 interrupt-parent = <&UIC0>;
209 interrupts = <0x3 0x4>;
210 };
211
212 RGMII0: emac-rgmii@ef601500 {
213 compatible = "ibm,rgmii";
214 reg = <0xef601500 0x00000008>;
215 has-mdio;
216 };
217
218 TAH0: emac-tah@ef601350 {
219 compatible = "ibm,tah";
220 reg = <0xef601350 0x00000030>;
221 };
222
223 EMAC0: ethernet@ef600c00 {
224 device_type = "network";
225 compatible = "ibm,emac4sync";
226 interrupt-parent = <&EMAC0>;
227 interrupts = <0x0 0x1>;
228 #interrupt-cells = <1>;
229 #address-cells = <0>;
230 #size-cells = <0>;
231 interrupt-map = </*Status*/ 0x0 &UIC2 0x10 0x4
232 /*Wake*/ 0x1 &UIC2 0x14 0x4>;
233 reg = <0xef600c00 0x000000c4>;
234 local-mac-address = [000000000000]; /* Filled in by U-Boot */
235 mal-device = <&MAL0>;
236 mal-tx-channel = <0>;
237 mal-rx-channel = <0>;
238 cell-index = <0>;
239 max-frame-size = <9000>;
240 rx-fifo-size = <16384>;
241 tx-fifo-size = <2048>;
242 phy-mode = "rgmii";
243 phy-map = <0x00000000>;
244 rgmii-device = <&RGMII0>;
245 rgmii-channel = <0>;
246 tah-device = <&TAH0>;
247 tah-channel = <0>;
248 has-inverted-stacr-oc;
249 has-new-stacr-staopc;
250 };
251 };
252
253 };
254};
diff --git a/arch/powerpc/boot/dts/mpc8308_p1m.dts b/arch/powerpc/boot/dts/mpc8308_p1m.dts
new file mode 100644
index 000000000000..05a76ccfd499
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc8308_p1m.dts
@@ -0,0 +1,332 @@
1/*
2 * mpc8308_p1m Device Tree Source
3 *
4 * Copyright 2010 Ilya Yanok, Emcraft Systems, yanok@emcraft.com
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/dts-v1/;
13
14/ {
15 compatible = "denx,mpc8308_p1m";
16 #address-cells = <1>;
17 #size-cells = <1>;
18
19 aliases {
20 ethernet0 = &enet0;
21 ethernet1 = &enet1;
22 serial0 = &serial0;
23 serial1 = &serial1;
24 pci0 = &pci0;
25 };
26
27 cpus {
28 #address-cells = <1>;
29 #size-cells = <0>;
30
31 PowerPC,8308@0 {
32 device_type = "cpu";
33 reg = <0x0>;
34 d-cache-line-size = <32>;
35 i-cache-line-size = <32>;
36 d-cache-size = <16384>;
37 i-cache-size = <16384>;
38 timebase-frequency = <0>; // from bootloader
39 bus-frequency = <0>; // from bootloader
40 clock-frequency = <0>; // from bootloader
41 };
42 };
43
44 memory {
45 device_type = "memory";
46 reg = <0x00000000 0x08000000>; // 128MB at 0
47 };
48
49 localbus@e0005000 {
50 #address-cells = <2>;
51 #size-cells = <1>;
52 compatible = "fsl,mpc8315-elbc", "fsl,elbc", "simple-bus";
53 reg = <0xe0005000 0x1000>;
54 interrupts = <77 0x8>;
55 interrupt-parent = <&ipic>;
56
57 ranges = <0x0 0x0 0xfc000000 0x04000000
58 0x1 0x0 0xfbff0000 0x00008000
59 0x2 0x0 0xfbff8000 0x00008000>;
60
61 flash@0,0 {
62 #address-cells = <1>;
63 #size-cells = <1>;
64 compatible = "cfi-flash";
65 reg = <0x0 0x0 0x4000000>;
66 bank-width = <2>;
67 device-width = <1>;
68
69 u-boot@0 {
70 reg = <0x0 0x60000>;
71 read-only;
72 };
73 env@60000 {
74 reg = <0x60000 0x20000>;
75 };
76 env1@80000 {
77 reg = <0x80000 0x20000>;
78 };
79 kernel@a0000 {
80 reg = <0xa0000 0x200000>;
81 };
82 dtb@2a0000 {
83 reg = <0x2a0000 0x20000>;
84 };
85 ramdisk@2c0000 {
86 reg = <0x2c0000 0x640000>;
87 };
88 user@700000 {
89 reg = <0x700000 0x3900000>;
90 };
91 };
92
93 can@1,0 {
94 compatible = "nxp,sja1000";
95 reg = <0x1 0x0 0x80>;
96 interrupts = <18 0x8>;
97 interrups-parent = <&ipic>;
98 };
99
100 cpld@2,0 {
101 compatible = "denx,mpc8308_p1m-cpld";
102 reg = <0x2 0x0 0x8>;
103 interrupts = <48 0x8>;
104 interrups-parent = <&ipic>;
105 };
106 };
107
108 immr@e0000000 {
109 #address-cells = <1>;
110 #size-cells = <1>;
111 device_type = "soc";
112 compatible = "fsl,mpc8308-immr", "simple-bus";
113 ranges = <0 0xe0000000 0x00100000>;
114 reg = <0xe0000000 0x00000200>;
115 bus-frequency = <0>;
116
117 i2c@3000 {
118 #address-cells = <1>;
119 #size-cells = <0>;
120 compatible = "fsl-i2c";
121 reg = <0x3000 0x100>;
122 interrupts = <14 0x8>;
123 interrupt-parent = <&ipic>;
124 dfsrr;
125 fram@50 {
126 compatible = "ramtron,24c64";
127 reg = <0x50>;
128 };
129 };
130
131 i2c@3100 {
132 #address-cells = <1>;
133 #size-cells = <0>;
134 compatible = "fsl-i2c";
135 reg = <0x3100 0x100>;
136 interrupts = <15 0x8>;
137 interrupt-parent = <&ipic>;
138 dfsrr;
139 pwm@28 {
140 compatible = "maxim,ds1050";
141 reg = <0x28>;
142 };
143 sensor@48 {
144 compatible = "maxim,max6625";
145 reg = <0x48>;
146 };
147 sensor@49 {
148 compatible = "maxim,max6625";
149 reg = <0x49>;
150 };
151 sensor@4b {
152 compatible = "maxim,max6625";
153 reg = <0x4b>;
154 };
155 };
156
157 usb@23000 {
158 compatible = "fsl-usb2-dr";
159 reg = <0x23000 0x1000>;
160 #address-cells = <1>;
161 #size-cells = <0>;
162 interrupt-parent = <&ipic>;
163 interrupts = <38 0x8>;
164 dr_mode = "peripheral";
165 phy_type = "ulpi";
166 };
167
168 enet0: ethernet@24000 {
169 #address-cells = <1>;
170 #size-cells = <1>;
171 ranges = <0x0 0x24000 0x1000>;
172
173 cell-index = <0>;
174 device_type = "network";
175 model = "eTSEC";
176 compatible = "gianfar";
177 reg = <0x24000 0x1000>;
178 local-mac-address = [ 00 00 00 00 00 00 ];
179 interrupts = <32 0x8 33 0x8 34 0x8>;
180 interrupt-parent = <&ipic>;
181 phy-handle = < &phy1 >;
182
183 mdio@520 {
184 #address-cells = <1>;
185 #size-cells = <0>;
186 compatible = "fsl,gianfar-mdio";
187 reg = <0x520 0x20>;
188 phy1: ethernet-phy@1 {
189 interrupt-parent = <&ipic>;
190 interrupts = <17 0x8>;
191 reg = <0x1>;
192 device_type = "ethernet-phy";
193 };
194 phy2: ethernet-phy@2 {
195 interrupt-parent = <&ipic>;
196 interrupts = <19 0x8>;
197 reg = <0x2>;
198 device_type = "ethernet-phy";
199 };
200 tbi0: tbi-phy@11 {
201 reg = <0x11>;
202 device_type = "tbi-phy";
203 };
204 };
205 };
206
207 enet1: ethernet@25000 {
208 #address-cells = <1>;
209 #size-cells = <1>;
210 cell-index = <1>;
211 device_type = "network";
212 model = "eTSEC";
213 compatible = "gianfar";
214 reg = <0x25000 0x1000>;
215 ranges = <0x0 0x25000 0x1000>;
216 local-mac-address = [ 00 00 00 00 00 00 ];
217 interrupts = <35 0x8 36 0x8 37 0x8>;
218 interrupt-parent = <&ipic>;
219 phy-handle = < &phy2 >;
220
221 mdio@520 {
222 #address-cells = <1>;
223 #size-cells = <0>;
224 compatible = "fsl,gianfar-tbi";
225 reg = <0x520 0x20>;
226 tbi1: tbi-phy@11 {
227 reg = <0x11>;
228 device_type = "tbi-phy";
229 };
230 };
231 };
232
233 serial0: serial@4500 {
234 cell-index = <0>;
235 device_type = "serial";
236 compatible = "ns16550";
237 reg = <0x4500 0x100>;
238 clock-frequency = <133333333>;
239 interrupts = <9 0x8>;
240 interrupt-parent = <&ipic>;
241 };
242
243 serial1: serial@4600 {
244 cell-index = <1>;
245 device_type = "serial";
246 compatible = "ns16550";
247 reg = <0x4600 0x100>;
248 clock-frequency = <133333333>;
249 interrupts = <10 0x8>;
250 interrupt-parent = <&ipic>;
251 };
252
253 gpio@c00 {
254 #gpio-cells = <2>;
255 compatible = "fsl,mpc8308-gpio", "fsl,mpc8349-gpio";
256 reg = <0xc00 0x18>;
257 interrupts = <74 0x8>;
258 interrupt-parent = <&ipic>;
259 gpio-controller;
260 };
261
262 timer@500 {
263 compatible = "fsl,mpc8308-gtm", "fsl,gtm";
264 reg = <0x500 0x100>;
265 interrupts = <90 8 78 8 84 8 72 8>;
266 interrupt-parent = <&ipic>;
267 clock-frequency = <133333333>;
268 };
269
270 /* IPIC
271 * interrupts cell = <intr #, sense>
272 * sense values match linux IORESOURCE_IRQ_* defines:
273 * sense == 8: Level, low assertion
274 * sense == 2: Edge, high-to-low change
275 */
276 ipic: interrupt-controller@700 {
277 compatible = "fsl,ipic";
278 interrupt-controller;
279 #address-cells = <0>;
280 #interrupt-cells = <2>;
281 reg = <0x700 0x100>;
282 device_type = "ipic";
283 };
284
285 ipic-msi@7c0 {
286 compatible = "fsl,ipic-msi";
287 reg = <0x7c0 0x40>;
288 msi-available-ranges = <0x0 0x100>;
289 interrupts = < 0x43 0x8
290 0x4 0x8
291 0x51 0x8
292 0x52 0x8
293 0x56 0x8
294 0x57 0x8
295 0x58 0x8
296 0x59 0x8 >;
297 interrupt-parent = < &ipic >;
298 };
299
300 };
301
302 pci0: pcie@e0009000 {
303 #address-cells = <3>;
304 #size-cells = <2>;
305 #interrupt-cells = <1>;
306 device_type = "pci";
307 compatible = "fsl,mpc8308-pcie", "fsl,mpc8314-pcie";
308 reg = <0xe0009000 0x00001000
309 0xb0000000 0x01000000>;
310 ranges = <0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
311 0x01000000 0 0x00000000 0xb1000000 0 0x00800000>;
312 bus-range = <0 0>;
313 interrupt-map-mask = <0 0 0 0>;
314 interrupt-map = <0 0 0 0 &ipic 1 8>;
315 interrupts = <0x1 0x8>;
316 interrupt-parent = <&ipic>;
317 clock-frequency = <0>;
318
319 pcie@0 {
320 #address-cells = <3>;
321 #size-cells = <2>;
322 device_type = "pci";
323 reg = <0 0 0 0 0>;
324 ranges = <0x02000000 0 0xa0000000
325 0x02000000 0 0xa0000000
326 0 0x10000000
327 0x01000000 0 0x00000000
328 0x01000000 0 0x00000000
329 0 0x00800000>;
330 };
331 };
332};
diff --git a/arch/powerpc/boot/dts/mpc8536ds.dts b/arch/powerpc/boot/dts/mpc8536ds.dts
index 815cebb2e3e5..a75c10eed269 100644
--- a/arch/powerpc/boot/dts/mpc8536ds.dts
+++ b/arch/powerpc/boot/dts/mpc8536ds.dts
@@ -108,6 +108,58 @@
108 }; 108 };
109 }; 109 };
110 110
111 spi@7000 {
112 #address-cells = <1>;
113 #size-cells = <0>;
114 compatible = "fsl,mpc8536-espi";
115 reg = <0x7000 0x1000>;
116 interrupts = <59 0x2>;
117 interrupt-parent = <&mpic>;
118 fsl,espi-num-chipselects = <4>;
119
120 flash@0 {
121 #address-cells = <1>;
122 #size-cells = <1>;
123 compatible = "spansion,s25sl12801";
124 reg = <0>;
125 spi-max-frequency = <40000000>;
126 partition@u-boot {
127 label = "u-boot";
128 reg = <0x00000000 0x00100000>;
129 read-only;
130 };
131 partition@kernel {
132 label = "kernel";
133 reg = <0x00100000 0x00500000>;
134 read-only;
135 };
136 partition@dtb {
137 label = "dtb";
138 reg = <0x00600000 0x00100000>;
139 read-only;
140 };
141 partition@fs {
142 label = "file system";
143 reg = <0x00700000 0x00900000>;
144 };
145 };
146 flash@1 {
147 compatible = "spansion,s25sl12801";
148 reg = <1>;
149 spi-max-frequency = <40000000>;
150 };
151 flash@2 {
152 compatible = "spansion,s25sl12801";
153 reg = <2>;
154 spi-max-frequency = <40000000>;
155 };
156 flash@3 {
157 compatible = "spansion,s25sl12801";
158 reg = <3>;
159 spi-max-frequency = <40000000>;
160 };
161 };
162
111 dma@21300 { 163 dma@21300 {
112 #address-cells = <1>; 164 #address-cells = <1>;
113 #size-cells = <1>; 165 #size-cells = <1>;
diff --git a/arch/powerpc/boot/dts/p1022ds.dts b/arch/powerpc/boot/dts/p1022ds.dts
index 8bcb10b92677..2bbecbb4cbf9 100644
--- a/arch/powerpc/boot/dts/p1022ds.dts
+++ b/arch/powerpc/boot/dts/p1022ds.dts
@@ -148,6 +148,17 @@
148 label = "reserved-nand"; 148 label = "reserved-nand";
149 }; 149 };
150 }; 150 };
151
152 board-control@3,0 {
153 compatible = "fsl,p1022ds-pixis";
154 reg = <3 0 0x30>;
155 interrupt-parent = <&mpic>;
156 /*
157 * IRQ8 is generated if the "EVENT" switch is pressed
158 * and PX_CTL[EVESEL] is set to 00.
159 */
160 interrupts = <8 8>;
161 };
151 }; 162 };
152 163
153 soc@fffe00000 { 164 soc@fffe00000 {
diff --git a/arch/powerpc/boot/dts/p4080ds.dts b/arch/powerpc/boot/dts/p4080ds.dts
index 2f0de24e3822..5b7fc29dd6cf 100644
--- a/arch/powerpc/boot/dts/p4080ds.dts
+++ b/arch/powerpc/boot/dts/p4080ds.dts
@@ -236,22 +236,19 @@
236 }; 236 };
237 237
238 spi@110000 { 238 spi@110000 {
239 cell-index = <0>;
240 #address-cells = <1>; 239 #address-cells = <1>;
241 #size-cells = <0>; 240 #size-cells = <0>;
242 compatible = "fsl,espi"; 241 compatible = "fsl,p4080-espi", "fsl,mpc8536-espi";
243 reg = <0x110000 0x1000>; 242 reg = <0x110000 0x1000>;
244 interrupts = <53 0x2>; 243 interrupts = <53 0x2>;
245 interrupt-parent = <&mpic>; 244 interrupt-parent = <&mpic>;
246 espi,num-ss-bits = <4>; 245 fsl,espi-num-chipselects = <4>;
247 mode = "cpu";
248 246
249 fsl_m25p80@0 { 247 flash@0 {
250 #address-cells = <1>; 248 #address-cells = <1>;
251 #size-cells = <1>; 249 #size-cells = <1>;
252 compatible = "fsl,espi-flash"; 250 compatible = "spansion,s25sl12801";
253 reg = <0>; 251 reg = <0>;
254 linux,modalias = "fsl_m25p80";
255 spi-max-frequency = <40000000>; /* input clock */ 252 spi-max-frequency = <40000000>; /* input clock */
256 partition@u-boot { 253 partition@u-boot {
257 label = "u-boot"; 254 label = "u-boot";
diff --git a/arch/powerpc/configs/44x/bluestone_defconfig b/arch/powerpc/configs/44x/bluestone_defconfig
new file mode 100644
index 000000000000..ac65b48b8ccd
--- /dev/null
+++ b/arch/powerpc/configs/44x/bluestone_defconfig
@@ -0,0 +1,68 @@
1CONFIG_44x=y
2CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y
7CONFIG_EMBEDDED=y
8# CONFIG_VM_EVENT_COUNTERS is not set
9# CONFIG_PCI_QUIRKS is not set
10# CONFIG_COMPAT_BRK is not set
11CONFIG_BLUESTONE=y
12# CONFIG_EBONY is not set
13# CONFIG_KVM_GUEST is not set
14CONFIG_NO_HZ=y
15CONFIG_HIGH_RES_TIMERS=y
16CONFIG_SPARSE_IRQ=y
17CONFIG_CMDLINE_BOOL=y
18CONFIG_CMDLINE=""
19CONFIG_NET=y
20CONFIG_PACKET=y
21CONFIG_UNIX=y
22CONFIG_INET=y
23CONFIG_IP_PNP=y
24CONFIG_IP_PNP_DHCP=y
25CONFIG_IP_PNP_BOOTP=y
26CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
27CONFIG_CONNECTOR=y
28CONFIG_MTD=y
29CONFIG_MTD_PARTITIONS=y
30CONFIG_MTD_CMDLINE_PARTS=y
31CONFIG_MTD_OF_PARTS=y
32CONFIG_MTD_CHAR=y
33CONFIG_MTD_BLOCK=y
34CONFIG_MTD_CFI=y
35CONFIG_MTD_CFI_AMDSTD=y
36CONFIG_MTD_PHYSMAP_OF=y
37CONFIG_PROC_DEVICETREE=y
38CONFIG_BLK_DEV_RAM=y
39CONFIG_BLK_DEV_RAM_SIZE=35000
40CONFIG_NETDEVICES=y
41CONFIG_NET_ETHERNET=y
42CONFIG_IBM_NEW_EMAC=y
43CONFIG_IBM_NEW_EMAC_RXB=256
44CONFIG_IBM_NEW_EMAC_TXB=256
45CONFIG_SERIAL_8250=y
46CONFIG_SERIAL_8250_CONSOLE=y
47CONFIG_SERIAL_8250_NR_UARTS=2
48CONFIG_SERIAL_8250_RUNTIME_UARTS=2
49CONFIG_SERIAL_8250_EXTENDED=y
50CONFIG_SERIAL_8250_SHARE_IRQ=y
51CONFIG_SERIAL_OF_PLATFORM=y
52CONFIG_I2C=y
53CONFIG_I2C_CHARDEV=y
54CONFIG_I2C_IBM_IIC=y
55CONFIG_SENSORS_AD7414=y
56# CONFIG_HID_SUPPORT is not set
57# CONFIG_USB_SUPPORT is not set
58CONFIG_RTC_CLASS=y
59CONFIG_RTC_DRV_M41T80=y
60CONFIG_EXT2_FS=y
61CONFIG_EXT3_FS=y
62CONFIG_PROC_KCORE=y
63CONFIG_TMPFS=y
64CONFIG_CRAMFS=y
65CONFIG_NFS_FS=y
66CONFIG_NFS_V3=y
67CONFIG_ROOT_NFS=y
68CONFIG_NLS=y
diff --git a/arch/powerpc/configs/e55xx_smp_defconfig b/arch/powerpc/configs/e55xx_smp_defconfig
new file mode 100644
index 000000000000..94d120ef99cf
--- /dev/null
+++ b/arch/powerpc/configs/e55xx_smp_defconfig
@@ -0,0 +1,84 @@
1CONFIG_PPC64=y
2CONFIG_PPC_BOOK3E_64=y
3# CONFIG_VIRT_CPU_ACCOUNTING is not set
4CONFIG_SMP=y
5CONFIG_NR_CPUS=2
6CONFIG_EXPERIMENTAL=y
7CONFIG_SYSVIPC=y
8CONFIG_BSD_PROCESS_ACCT=y
9CONFIG_IKCONFIG=y
10CONFIG_IKCONFIG_PROC=y
11CONFIG_LOG_BUF_SHIFT=14
12CONFIG_SYSFS_DEPRECATED_V2=y
13CONFIG_BLK_DEV_INITRD=y
14# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
15CONFIG_EMBEDDED=y
16CONFIG_KALLSYMS_ALL=y
17CONFIG_KALLSYMS_EXTRA_PASS=y
18CONFIG_MODULES=y
19CONFIG_MODULE_UNLOAD=y
20CONFIG_MODULE_FORCE_UNLOAD=y
21CONFIG_MODVERSIONS=y
22# CONFIG_BLK_DEV_BSG is not set
23CONFIG_P5020_DS=y
24# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
25CONFIG_NO_HZ=y
26CONFIG_HIGH_RES_TIMERS=y
27CONFIG_BINFMT_MISC=m
28CONFIG_SPARSE_IRQ=y
29# CONFIG_PCI is not set
30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
31CONFIG_PROC_DEVICETREE=y
32CONFIG_BLK_DEV_LOOP=y
33CONFIG_BLK_DEV_RAM=y
34CONFIG_BLK_DEV_RAM_SIZE=131072
35CONFIG_EEPROM_LEGACY=y
36CONFIG_INPUT_FF_MEMLESS=m
37# CONFIG_INPUT_MOUSEDEV is not set
38# CONFIG_INPUT_KEYBOARD is not set
39# CONFIG_INPUT_MOUSE is not set
40CONFIG_SERIO_LIBPS2=y
41CONFIG_SERIAL_8250=y
42CONFIG_SERIAL_8250_CONSOLE=y
43CONFIG_SERIAL_8250_EXTENDED=y
44CONFIG_SERIAL_8250_MANY_PORTS=y
45CONFIG_SERIAL_8250_DETECT_IRQ=y
46CONFIG_SERIAL_8250_RSA=y
47CONFIG_I2C=y
48# CONFIG_HWMON is not set
49CONFIG_VIDEO_OUTPUT_CONTROL=y
50# CONFIG_HID_SUPPORT is not set
51# CONFIG_USB_SUPPORT is not set
52CONFIG_DMADEVICES=y
53CONFIG_FSL_DMA=y
54CONFIG_EXT2_FS=y
55CONFIG_EXT3_FS=y
56# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
57CONFIG_PROC_KCORE=y
58CONFIG_TMPFS=y
59# CONFIG_MISC_FILESYSTEMS is not set
60CONFIG_PARTITION_ADVANCED=y
61CONFIG_MAC_PARTITION=y
62CONFIG_NLS=y
63CONFIG_NLS_UTF8=m
64CONFIG_CRC_T10DIF=y
65CONFIG_CRC_ITU_T=m
66CONFIG_LIBCRC32C=m
67CONFIG_FRAME_WARN=1024
68CONFIG_DEBUG_FS=y
69CONFIG_DEBUG_KERNEL=y
70CONFIG_DETECT_HUNG_TASK=y
71# CONFIG_DEBUG_BUGVERBOSE is not set
72CONFIG_DEBUG_INFO=y
73# CONFIG_RCU_CPU_STALL_DETECTOR is not set
74CONFIG_SYSCTL_SYSCALL_CHECK=y
75CONFIG_VIRQ_DEBUG=y
76CONFIG_CRYPTO=y
77CONFIG_CRYPTO_CBC=y
78CONFIG_CRYPTO_PCBC=m
79CONFIG_CRYPTO_HMAC=y
80CONFIG_CRYPTO_MD5=y
81CONFIG_CRYPTO_SHA1=m
82CONFIG_CRYPTO_DES=y
83# CONFIG_CRYPTO_ANSI_CPRNG is not set
84CONFIG_CRYPTO_DEV_TALITOS=y
diff --git a/arch/powerpc/configs/ppc44x_defconfig b/arch/powerpc/configs/ppc44x_defconfig
index cd446fba3fae..2fa05f7be4cb 100644
--- a/arch/powerpc/configs/ppc44x_defconfig
+++ b/arch/powerpc/configs/ppc44x_defconfig
@@ -12,6 +12,7 @@ CONFIG_MODULES=y
12CONFIG_MODULE_UNLOAD=y 12CONFIG_MODULE_UNLOAD=y
13# CONFIG_BLK_DEV_BSG is not set 13# CONFIG_BLK_DEV_BSG is not set
14CONFIG_BAMBOO=y 14CONFIG_BAMBOO=y
15CONFIG_BLUESTONE=y
15CONFIG_SAM440EP=y 16CONFIG_SAM440EP=y
16CONFIG_SEQUOIA=y 17CONFIG_SEQUOIA=y
17CONFIG_TAISHAN=y 18CONFIG_TAISHAN=y
@@ -97,14 +98,17 @@ CONFIG_USB_STORAGE=m
97CONFIG_EXT2_FS=y 98CONFIG_EXT2_FS=y
98CONFIG_EXT3_FS=m 99CONFIG_EXT3_FS=m
99# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 100# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
100CONFIG_INOTIFY=y
101CONFIG_VFAT_FS=m 101CONFIG_VFAT_FS=m
102CONFIG_PROC_KCORE=y 102CONFIG_PROC_KCORE=y
103CONFIG_TMPFS=y 103CONFIG_TMPFS=y
104CONFIG_JFFS2_FS=y 104CONFIG_JFFS2_FS=y
105CONFIG_UBIFS_FS=m 105CONFIG_UBIFS_FS=m
106CONFIG_UBIFS_FS_XATTR=y 106CONFIG_UBIFS_FS_XATTR=y
107CONFIG_LOGFS=m
107CONFIG_CRAMFS=y 108CONFIG_CRAMFS=y
109CONFIG_SQUASHFS=m
110CONFIG_SQUASHFS_XATTR=y
111CONFIG_SQUASHFS_LZO=y
108CONFIG_NFS_FS=y 112CONFIG_NFS_FS=y
109CONFIG_NFS_V3=y 113CONFIG_NFS_V3=y
110CONFIG_ROOT_NFS=y 114CONFIG_ROOT_NFS=y
@@ -116,11 +120,8 @@ CONFIG_DEBUG_KERNEL=y
116CONFIG_DETECT_HUNG_TASK=y 120CONFIG_DETECT_HUNG_TASK=y
117# CONFIG_RCU_CPU_STALL_DETECTOR is not set 121# CONFIG_RCU_CPU_STALL_DETECTOR is not set
118CONFIG_SYSCTL_SYSCALL_CHECK=y 122CONFIG_SYSCTL_SYSCALL_CHECK=y
119CONFIG_CRYPTO_CBC=y
120CONFIG_CRYPTO_ECB=y 123CONFIG_CRYPTO_ECB=y
121CONFIG_CRYPTO_PCBC=y 124CONFIG_CRYPTO_PCBC=y
122CONFIG_CRYPTO_MD5=y
123CONFIG_CRYPTO_DES=y
124# CONFIG_CRYPTO_ANSI_CPRNG is not set 125# CONFIG_CRYPTO_ANSI_CPRNG is not set
125# CONFIG_CRYPTO_HW is not set 126# CONFIG_CRYPTO_HW is not set
126CONFIG_VIRTUALIZATION=y 127CONFIG_VIRTUALIZATION=y
diff --git a/arch/powerpc/configs/ppc64e_defconfig b/arch/powerpc/configs/ppc64e_defconfig
index 04ae0740b6d0..7bd1763877ba 100644
--- a/arch/powerpc/configs/ppc64e_defconfig
+++ b/arch/powerpc/configs/ppc64e_defconfig
@@ -18,6 +18,7 @@ CONFIG_MODULES=y
18CONFIG_MODULE_UNLOAD=y 18CONFIG_MODULE_UNLOAD=y
19CONFIG_MODVERSIONS=y 19CONFIG_MODVERSIONS=y
20CONFIG_MODULE_SRCVERSION_ALL=y 20CONFIG_MODULE_SRCVERSION_ALL=y
21CONFIG_P5020_DS=y
21CONFIG_CPU_FREQ=y 22CONFIG_CPU_FREQ=y
22CONFIG_CPU_FREQ_GOV_POWERSAVE=y 23CONFIG_CPU_FREQ_GOV_POWERSAVE=y
23CONFIG_CPU_FREQ_GOV_USERSPACE=y 24CONFIG_CPU_FREQ_GOV_USERSPACE=y
@@ -256,7 +257,6 @@ CONFIG_HID_ZEROPLUS=y
256CONFIG_USB=y 257CONFIG_USB=y
257CONFIG_USB_DEVICEFS=y 258CONFIG_USB_DEVICEFS=y
258CONFIG_USB_EHCI_HCD=y 259CONFIG_USB_EHCI_HCD=y
259CONFIG_USB_EHCI_TT_NEWSCHED=y
260# CONFIG_USB_EHCI_HCD_PPC_OF is not set 260# CONFIG_USB_EHCI_HCD_PPC_OF is not set
261CONFIG_USB_OHCI_HCD=y 261CONFIG_USB_OHCI_HCD=y
262CONFIG_USB_STORAGE=m 262CONFIG_USB_STORAGE=m
@@ -290,7 +290,6 @@ CONFIG_JFS_POSIX_ACL=y
290CONFIG_JFS_SECURITY=y 290CONFIG_JFS_SECURITY=y
291CONFIG_XFS_FS=m 291CONFIG_XFS_FS=m
292CONFIG_XFS_POSIX_ACL=y 292CONFIG_XFS_POSIX_ACL=y
293CONFIG_INOTIFY=y
294CONFIG_AUTOFS4_FS=m 293CONFIG_AUTOFS4_FS=m
295CONFIG_ISO9660_FS=y 294CONFIG_ISO9660_FS=y
296CONFIG_UDF_FS=m 295CONFIG_UDF_FS=m
@@ -384,7 +383,6 @@ CONFIG_CRYPTO_TGR192=m
384CONFIG_CRYPTO_WP512=m 383CONFIG_CRYPTO_WP512=m
385CONFIG_CRYPTO_AES=m 384CONFIG_CRYPTO_AES=m
386CONFIG_CRYPTO_ANUBIS=m 385CONFIG_CRYPTO_ANUBIS=m
387CONFIG_CRYPTO_ARC4=m
388CONFIG_CRYPTO_BLOWFISH=m 386CONFIG_CRYPTO_BLOWFISH=m
389CONFIG_CRYPTO_CAST6=m 387CONFIG_CRYPTO_CAST6=m
390CONFIG_CRYPTO_KHAZAD=m 388CONFIG_CRYPTO_KHAZAD=m
diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h
index 7cdf358337cf..ce0c28495f9a 100644
--- a/arch/powerpc/include/asm/checksum.h
+++ b/arch/powerpc/include/asm/checksum.h
@@ -52,12 +52,22 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
52extern __wsum csum_partial_copy_generic(const void *src, void *dst, 52extern __wsum csum_partial_copy_generic(const void *src, void *dst,
53 int len, __wsum sum, 53 int len, __wsum sum,
54 int *src_err, int *dst_err); 54 int *src_err, int *dst_err);
55
56#ifdef __powerpc64__
57#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
58extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
59 int len, __wsum sum, int *err_ptr);
60#define HAVE_CSUM_COPY_USER
61extern __wsum csum_and_copy_to_user(const void *src, void __user *dst,
62 int len, __wsum sum, int *err_ptr);
63#else
55/* 64/*
56 * the same as csum_partial, but copies from src to dst while it 65 * the same as csum_partial, but copies from src to dst while it
57 * checksums. 66 * checksums.
58 */ 67 */
59#define csum_partial_copy_from_user(src, dst, len, sum, errp) \ 68#define csum_partial_copy_from_user(src, dst, len, sum, errp) \
60 csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL) 69 csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL)
70#endif
61 71
62#define csum_partial_copy_nocheck(src, dst, len, sum) \ 72#define csum_partial_copy_nocheck(src, dst, len, sum) \
63 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL) 73 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)
diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index a11d4eac4f97..2296112e247b 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -143,7 +143,7 @@ static inline void __user *arch_compat_alloc_user_space(long len)
143 * We cant access below the stack pointer in the 32bit ABI and 143 * We cant access below the stack pointer in the 32bit ABI and
144 * can access 288 bytes in the 64bit ABI 144 * can access 288 bytes in the 64bit ABI
145 */ 145 */
146 if (!(test_thread_flag(TIF_32BIT))) 146 if (!is_32bit_task())
147 usp -= 288; 147 usp -= 288;
148 148
149 return (void __user *) (usp - len); 149 return (void __user *) (usp - len);
@@ -213,7 +213,7 @@ struct compat_shmid64_ds {
213 213
214static inline int is_compat_task(void) 214static inline int is_compat_task(void)
215{ 215{
216 return test_thread_flag(TIF_32BIT); 216 return is_32bit_task();
217} 217}
218 218
219#endif /* __KERNEL__ */ 219#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 3a40a992e594..f3a1fdd9cf08 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -198,6 +198,7 @@ extern const char *powerpc_base_platform;
198#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0040000000000000) 198#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0040000000000000)
199#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0080000000000000) 199#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0080000000000000)
200#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0100000000000000) 200#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0100000000000000)
201#define CPU_FTR_STCX_CHECKS_ADDRESS LONG_ASM_CONST(0x0200000000000000)
201 202
202#ifndef __ASSEMBLY__ 203#ifndef __ASSEMBLY__
203 204
@@ -392,28 +393,31 @@ extern const char *powerpc_base_platform;
392 CPU_FTR_MMCRA | CPU_FTR_CTRL) 393 CPU_FTR_MMCRA | CPU_FTR_CTRL)
393#define CPU_FTRS_POWER4 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 394#define CPU_FTRS_POWER4 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
394 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 395 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
395 CPU_FTR_MMCRA | CPU_FTR_CP_USE_DCBTZ) 396 CPU_FTR_MMCRA | CPU_FTR_CP_USE_DCBTZ | \
397 CPU_FTR_STCX_CHECKS_ADDRESS)
396#define CPU_FTRS_PPC970 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 398#define CPU_FTRS_PPC970 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
397 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 399 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
398 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA | \ 400 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA | \
399 CPU_FTR_CP_USE_DCBTZ) 401 CPU_FTR_CP_USE_DCBTZ | CPU_FTR_STCX_CHECKS_ADDRESS)
400#define CPU_FTRS_POWER5 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 402#define CPU_FTRS_POWER5 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
401 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 403 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
402 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 404 CPU_FTR_MMCRA | CPU_FTR_SMT | \
403 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 405 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
404 CPU_FTR_PURR) 406 CPU_FTR_PURR | CPU_FTR_STCX_CHECKS_ADDRESS)
405#define CPU_FTRS_POWER6 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 407#define CPU_FTRS_POWER6 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
406 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 408 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
407 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 409 CPU_FTR_MMCRA | CPU_FTR_SMT | \
408 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 410 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
409 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \ 411 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
410 CPU_FTR_DSCR | CPU_FTR_UNALIGNED_LD_STD) 412 CPU_FTR_DSCR | CPU_FTR_UNALIGNED_LD_STD | \
413 CPU_FTR_STCX_CHECKS_ADDRESS)
411#define CPU_FTRS_POWER7 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 414#define CPU_FTRS_POWER7 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
412 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 415 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
413 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 416 CPU_FTR_MMCRA | CPU_FTR_SMT | \
414 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 417 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
415 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \ 418 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
416 CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT) 419 CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT | \
420 CPU_FTR_STCX_CHECKS_ADDRESS)
417#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 421#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
418 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 422 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
419 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 423 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 8c9c6ad2004e..6d2416a85709 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -127,19 +127,7 @@ static inline int dma_supported(struct device *dev, u64 mask)
127 return dma_ops->dma_supported(dev, mask); 127 return dma_ops->dma_supported(dev, mask);
128} 128}
129 129
130static inline int dma_set_mask(struct device *dev, u64 dma_mask) 130extern int dma_set_mask(struct device *dev, u64 dma_mask);
131{
132 struct dma_map_ops *dma_ops = get_dma_ops(dev);
133
134 if (unlikely(dma_ops == NULL))
135 return -EIO;
136 if (dma_ops->set_dma_mask != NULL)
137 return dma_ops->set_dma_mask(dev, dma_mask);
138 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
139 return -EIO;
140 *dev->dma_mask = dma_mask;
141 return 0;
142}
143 131
144static inline void *dma_alloc_coherent(struct device *dev, size_t size, 132static inline void *dma_alloc_coherent(struct device *dev, size_t size,
145 dma_addr_t *dma_handle, gfp_t flag) 133 dma_addr_t *dma_handle, gfp_t flag)
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index c376eda15313..2b917c69ed15 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -250,7 +250,7 @@ do { \
250 * the 64bit ABI has never had these issues dont enable the workaround 250 * the 64bit ABI has never had these issues dont enable the workaround
251 * even if we have an executable stack. 251 * even if we have an executable stack.
252 */ 252 */
253# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \ 253# define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
254 (exec_stk == EXSTACK_DEFAULT) : 0) 254 (exec_stk == EXSTACK_DEFAULT) : 0)
255#else 255#else
256# define SET_PERSONALITY(ex) \ 256# define SET_PERSONALITY(ex) \
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 57c400071995..7778d6f0c878 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -137,7 +137,8 @@
137 li r10,0; \ 137 li r10,0; \
138 ld r11,exception_marker@toc(r2); \ 138 ld r11,exception_marker@toc(r2); \
139 std r10,RESULT(r1); /* clear regs->result */ \ 139 std r10,RESULT(r1); /* clear regs->result */ \
140 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 140 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \
141 ACCOUNT_STOLEN_TIME
141 142
142/* 143/*
143 * Exception vectors. 144 * Exception vectors.
diff --git a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h
new file mode 100644
index 000000000000..2af2bdc37b2e
--- /dev/null
+++ b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h
@@ -0,0 +1,48 @@
1/*
2 * Copyright 2009 Freescale Semiconductor, Inc.
3 *
4 * Cache SRAM handling for QorIQ platform
5 *
6 * Author: Vivek Mahajan <vivek.mahajan@freescale.com>
7
8 * This file is derived from the original work done
9 * by Sylvain Munaut for the Bestcomm SRAM allocator.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#ifndef __ASM_POWERPC_FSL_85XX_CACHE_SRAM_H__
27#define __ASM_POWERPC_FSL_85XX_CACHE_SRAM_H__
28
29#include <asm/rheap.h>
30#include <linux/spinlock.h>
31
32/*
33 * Cache-SRAM
34 */
35
36struct mpc85xx_cache_sram {
37 phys_addr_t base_phys;
38 void *base_virt;
39 unsigned int size;
40 rh_info_t *rh;
41 spinlock_t lock;
42};
43
44extern void mpc85xx_cache_sram_free(void *ptr);
45extern void *mpc85xx_cache_sram_alloc(unsigned int size,
46 phys_addr_t *phys, unsigned int align);
47
48#endif /* __AMS_POWERPC_FSL_85XX_CACHE_SRAM_H__ */
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index bd100fcf40d0..ff08b70b36d4 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -16,42 +16,57 @@ extern void timer_interrupt(struct pt_regs *);
16#ifdef CONFIG_PPC64 16#ifdef CONFIG_PPC64
17#include <asm/paca.h> 17#include <asm/paca.h>
18 18
19static inline unsigned long local_get_flags(void) 19static inline unsigned long arch_local_save_flags(void)
20{ 20{
21 unsigned long flags; 21 unsigned long flags;
22 22
23 __asm__ __volatile__("lbz %0,%1(13)" 23 asm volatile(
24 : "=r" (flags) 24 "lbz %0,%1(13)"
25 : "i" (offsetof(struct paca_struct, soft_enabled))); 25 : "=r" (flags)
26 : "i" (offsetof(struct paca_struct, soft_enabled)));
26 27
27 return flags; 28 return flags;
28} 29}
29 30
30static inline unsigned long raw_local_irq_disable(void) 31static inline unsigned long arch_local_irq_disable(void)
31{ 32{
32 unsigned long flags, zero; 33 unsigned long flags, zero;
33 34
34 __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)" 35 asm volatile(
35 : "=r" (flags), "=&r" (zero) 36 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
36 : "i" (offsetof(struct paca_struct, soft_enabled)) 37 : "=r" (flags), "=&r" (zero)
37 : "memory"); 38 : "i" (offsetof(struct paca_struct, soft_enabled))
39 : "memory");
38 40
39 return flags; 41 return flags;
40} 42}
41 43
42extern void raw_local_irq_restore(unsigned long); 44extern void arch_local_irq_restore(unsigned long);
43extern void iseries_handle_interrupts(void); 45extern void iseries_handle_interrupts(void);
44 46
45#define raw_local_irq_enable() raw_local_irq_restore(1) 47static inline void arch_local_irq_enable(void)
46#define raw_local_save_flags(flags) ((flags) = local_get_flags()) 48{
47#define raw_local_irq_save(flags) ((flags) = raw_local_irq_disable()) 49 arch_local_irq_restore(1);
50}
51
52static inline unsigned long arch_local_irq_save(void)
53{
54 return arch_local_irq_disable();
55}
56
57static inline bool arch_irqs_disabled_flags(unsigned long flags)
58{
59 return flags == 0;
60}
48 61
49#define raw_irqs_disabled() (local_get_flags() == 0) 62static inline bool arch_irqs_disabled(void)
50#define raw_irqs_disabled_flags(flags) ((flags) == 0) 63{
64 return arch_irqs_disabled_flags(arch_local_save_flags());
65}
51 66
52#ifdef CONFIG_PPC_BOOK3E 67#ifdef CONFIG_PPC_BOOK3E
53#define __hard_irq_enable() __asm__ __volatile__("wrteei 1": : :"memory"); 68#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory");
54#define __hard_irq_disable() __asm__ __volatile__("wrteei 0": : :"memory"); 69#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory");
55#else 70#else
56#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) 71#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
57#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) 72#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
@@ -64,64 +79,66 @@ extern void iseries_handle_interrupts(void);
64 get_paca()->hard_enabled = 0; \ 79 get_paca()->hard_enabled = 0; \
65 } while(0) 80 } while(0)
66 81
67#else 82#else /* CONFIG_PPC64 */
68 83
69#if defined(CONFIG_BOOKE)
70#define SET_MSR_EE(x) mtmsr(x) 84#define SET_MSR_EE(x) mtmsr(x)
71#define raw_local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") 85
86static inline unsigned long arch_local_save_flags(void)
87{
88 return mfmsr();
89}
90
91static inline void arch_local_irq_restore(unsigned long flags)
92{
93#if defined(CONFIG_BOOKE)
94 asm volatile("wrtee %0" : : "r" (flags) : "memory");
72#else 95#else
73#define SET_MSR_EE(x) mtmsr(x) 96 mtmsr(flags);
74#define raw_local_irq_restore(flags) mtmsr(flags)
75#endif 97#endif
98}
76 99
77static inline void raw_local_irq_disable(void) 100static inline unsigned long arch_local_irq_save(void)
78{ 101{
102 unsigned long flags = arch_local_save_flags();
79#ifdef CONFIG_BOOKE 103#ifdef CONFIG_BOOKE
80 __asm__ __volatile__("wrteei 0": : :"memory"); 104 asm volatile("wrteei 0" : : : "memory");
81#else 105#else
82 unsigned long msr; 106 SET_MSR_EE(flags & ~MSR_EE);
83
84 msr = mfmsr();
85 SET_MSR_EE(msr & ~MSR_EE);
86#endif 107#endif
108 return flags;
87} 109}
88 110
89static inline void raw_local_irq_enable(void) 111static inline void arch_local_irq_disable(void)
90{ 112{
91#ifdef CONFIG_BOOKE 113#ifdef CONFIG_BOOKE
92 __asm__ __volatile__("wrteei 1": : :"memory"); 114 asm volatile("wrteei 0" : : : "memory");
93#else 115#else
94 unsigned long msr; 116 arch_local_irq_save();
95
96 msr = mfmsr();
97 SET_MSR_EE(msr | MSR_EE);
98#endif 117#endif
99} 118}
100 119
101static inline void raw_local_irq_save_ptr(unsigned long *flags) 120static inline void arch_local_irq_enable(void)
102{ 121{
103 unsigned long msr;
104 msr = mfmsr();
105 *flags = msr;
106#ifdef CONFIG_BOOKE 122#ifdef CONFIG_BOOKE
107 __asm__ __volatile__("wrteei 0": : :"memory"); 123 asm volatile("wrteei 1" : : : "memory");
108#else 124#else
109 SET_MSR_EE(msr & ~MSR_EE); 125 unsigned long msr = mfmsr();
126 SET_MSR_EE(msr | MSR_EE);
110#endif 127#endif
111} 128}
112 129
113#define raw_local_save_flags(flags) ((flags) = mfmsr()) 130static inline bool arch_irqs_disabled_flags(unsigned long flags)
114#define raw_local_irq_save(flags) raw_local_irq_save_ptr(&flags)
115#define raw_irqs_disabled() ((mfmsr() & MSR_EE) == 0)
116#define raw_irqs_disabled_flags(flags) (((flags) & MSR_EE) == 0)
117
118#define hard_irq_disable() raw_local_irq_disable()
119
120static inline int irqs_disabled_flags(unsigned long flags)
121{ 131{
122 return (flags & MSR_EE) == 0; 132 return (flags & MSR_EE) == 0;
123} 133}
124 134
135static inline bool arch_irqs_disabled(void)
136{
137 return arch_irqs_disabled_flags(arch_local_save_flags());
138}
139
140#define hard_irq_disable() arch_local_irq_disable()
141
125#endif /* CONFIG_PPC64 */ 142#endif /* CONFIG_PPC64 */
126 143
127/* 144/*
diff --git a/arch/powerpc/include/asm/hydra.h b/arch/powerpc/include/asm/hydra.h
index 1ad4eed07fbe..5b0c98bd46ab 100644
--- a/arch/powerpc/include/asm/hydra.h
+++ b/arch/powerpc/include/asm/hydra.h
@@ -10,7 +10,7 @@
10 * 10 *
11 * © Copyright 1995 Apple Computer, Inc. All rights reserved. 11 * © Copyright 1995 Apple Computer, Inc. All rights reserved.
12 * 12 *
13 * It's available online from http://chrp.apple.com/MacTech.pdf. 13 * It's available online from http://www.cpu.lu/~mlan/ftp/MacTech.pdf
14 * You can obtain paper copies of this book from computer bookstores or by 14 * You can obtain paper copies of this book from computer bookstores or by
15 * writing Morgan Kaufmann Publishers, Inc., 340 Pine Street, Sixth Floor, San 15 * writing Morgan Kaufmann Publishers, Inc., 340 Pine Street, Sixth Floor, San
16 * Francisco, CA 94104. Reference ISBN 1-55860-393-X. 16 * Francisco, CA 94104. Reference ISBN 1-55860-393-X.
diff --git a/arch/powerpc/include/asm/irqflags.h b/arch/powerpc/include/asm/irqflags.h
index 5f68ecfdf516..b85d8ddbb666 100644
--- a/arch/powerpc/include/asm/irqflags.h
+++ b/arch/powerpc/include/asm/irqflags.h
@@ -6,7 +6,7 @@
6 6
7#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
8/* 8/*
9 * Get definitions for raw_local_save_flags(x), etc. 9 * Get definitions for arch_local_save_flags(x), etc.
10 */ 10 */
11#include <asm/hw_irq.h> 11#include <asm/hw_irq.h>
12 12
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 076327f2eff7..f54408d995b5 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -91,6 +91,7 @@ extern void machine_kexec_simple(struct kimage *image);
91extern void crash_kexec_secondary(struct pt_regs *regs); 91extern void crash_kexec_secondary(struct pt_regs *regs);
92extern int overlaps_crashkernel(unsigned long start, unsigned long size); 92extern int overlaps_crashkernel(unsigned long start, unsigned long size);
93extern void reserve_crashkernel(void); 93extern void reserve_crashkernel(void);
94extern void machine_kexec_mask_interrupts(void);
94 95
95#else /* !CONFIG_KEXEC */ 96#else /* !CONFIG_KEXEC */
96static inline int kexec_sr_activated(int cpu) { return 0; } 97static inline int kexec_sr_activated(int cpu) { return 0; }
diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index 6c5547d82bbe..18ea6963ad77 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -86,5 +86,6 @@ struct kvm_guest_debug_arch {
86 86
87#define KVM_INTERRUPT_SET -1U 87#define KVM_INTERRUPT_SET -1U
88#define KVM_INTERRUPT_UNSET -2U 88#define KVM_INTERRUPT_UNSET -2U
89#define KVM_INTERRUPT_SET_LEVEL -3U
89 90
90#endif /* __LINUX_KVM_POWERPC_H */ 91#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/arch/powerpc/include/asm/kvm_asm.h b/arch/powerpc/include/asm/kvm_asm.h
index c5ea4cda34b3..5b7504674397 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -58,6 +58,7 @@
58#define BOOK3S_INTERRUPT_INST_STORAGE 0x400 58#define BOOK3S_INTERRUPT_INST_STORAGE 0x400
59#define BOOK3S_INTERRUPT_INST_SEGMENT 0x480 59#define BOOK3S_INTERRUPT_INST_SEGMENT 0x480
60#define BOOK3S_INTERRUPT_EXTERNAL 0x500 60#define BOOK3S_INTERRUPT_EXTERNAL 0x500
61#define BOOK3S_INTERRUPT_EXTERNAL_LEVEL 0x501
61#define BOOK3S_INTERRUPT_ALIGNMENT 0x600 62#define BOOK3S_INTERRUPT_ALIGNMENT 0x600
62#define BOOK3S_INTERRUPT_PROGRAM 0x700 63#define BOOK3S_INTERRUPT_PROGRAM 0x700
63#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800 64#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800
@@ -84,7 +85,8 @@
84#define BOOK3S_IRQPRIO_EXTERNAL 13 85#define BOOK3S_IRQPRIO_EXTERNAL 13
85#define BOOK3S_IRQPRIO_DECREMENTER 14 86#define BOOK3S_IRQPRIO_DECREMENTER 14
86#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15 87#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15
87#define BOOK3S_IRQPRIO_MAX 16 88#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 16
89#define BOOK3S_IRQPRIO_MAX 17
88 90
89#define BOOK3S_HFLAG_DCBZ32 0x1 91#define BOOK3S_HFLAG_DCBZ32 0x1
90#define BOOK3S_HFLAG_SLB 0x2 92#define BOOK3S_HFLAG_SLB 0x2
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 8274a2d43925..d62e703f1214 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -38,15 +38,6 @@ struct kvmppc_slb {
38 bool class : 1; 38 bool class : 1;
39}; 39};
40 40
41struct kvmppc_sr {
42 u32 raw;
43 u32 vsid;
44 bool Ks : 1;
45 bool Kp : 1;
46 bool nx : 1;
47 bool valid : 1;
48};
49
50struct kvmppc_bat { 41struct kvmppc_bat {
51 u64 raw; 42 u64 raw;
52 u32 bepi; 43 u32 bepi;
@@ -69,6 +60,13 @@ struct kvmppc_sid_map {
69#define SID_MAP_NUM (1 << SID_MAP_BITS) 60#define SID_MAP_NUM (1 << SID_MAP_BITS)
70#define SID_MAP_MASK (SID_MAP_NUM - 1) 61#define SID_MAP_MASK (SID_MAP_NUM - 1)
71 62
63#ifdef CONFIG_PPC_BOOK3S_64
64#define SID_CONTEXTS 1
65#else
66#define SID_CONTEXTS 128
67#define VSID_POOL_SIZE (SID_CONTEXTS * 16)
68#endif
69
72struct kvmppc_vcpu_book3s { 70struct kvmppc_vcpu_book3s {
73 struct kvm_vcpu vcpu; 71 struct kvm_vcpu vcpu;
74 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu; 72 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
@@ -79,20 +77,22 @@ struct kvmppc_vcpu_book3s {
79 u64 vsid; 77 u64 vsid;
80 } slb_shadow[64]; 78 } slb_shadow[64];
81 u8 slb_shadow_max; 79 u8 slb_shadow_max;
82 struct kvmppc_sr sr[16];
83 struct kvmppc_bat ibat[8]; 80 struct kvmppc_bat ibat[8];
84 struct kvmppc_bat dbat[8]; 81 struct kvmppc_bat dbat[8];
85 u64 hid[6]; 82 u64 hid[6];
86 u64 gqr[8]; 83 u64 gqr[8];
87 int slb_nr; 84 int slb_nr;
88 u32 dsisr;
89 u64 sdr1; 85 u64 sdr1;
90 u64 hior; 86 u64 hior;
91 u64 msr_mask; 87 u64 msr_mask;
92 u64 vsid_first;
93 u64 vsid_next; 88 u64 vsid_next;
89#ifdef CONFIG_PPC_BOOK3S_32
90 u32 vsid_pool[VSID_POOL_SIZE];
91#else
92 u64 vsid_first;
94 u64 vsid_max; 93 u64 vsid_max;
95 int context_id; 94#endif
95 int context_id[SID_CONTEXTS];
96 ulong prog_flags; /* flags to inject when giving a 700 trap */ 96 ulong prog_flags; /* flags to inject when giving a 700 trap */
97}; 97};
98 98
@@ -131,9 +131,10 @@ extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
131 bool upper, u32 val); 131 bool upper, u32 val);
132extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr); 132extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
133extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu); 133extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
134extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn);
134 135
135extern u32 kvmppc_trampoline_lowmem; 136extern ulong kvmppc_trampoline_lowmem;
136extern u32 kvmppc_trampoline_enter; 137extern ulong kvmppc_trampoline_enter;
137extern void kvmppc_rmcall(ulong srr0, ulong srr1); 138extern void kvmppc_rmcall(ulong srr0, ulong srr1);
138extern void kvmppc_load_up_fpu(void); 139extern void kvmppc_load_up_fpu(void);
139extern void kvmppc_load_up_altivec(void); 140extern void kvmppc_load_up_altivec(void);
diff --git a/arch/powerpc/include/asm/kvm_fpu.h b/arch/powerpc/include/asm/kvm_fpu.h
index c3d4f0518a67..92daae132492 100644
--- a/arch/powerpc/include/asm/kvm_fpu.h
+++ b/arch/powerpc/include/asm/kvm_fpu.h
@@ -82,7 +82,7 @@ FPD_THREE_IN(fmadd)
82FPD_THREE_IN(fnmsub) 82FPD_THREE_IN(fnmsub)
83FPD_THREE_IN(fnmadd) 83FPD_THREE_IN(fnmadd)
84 84
85extern void kvm_cvt_fd(u32 *from, u64 *to, u64 *fpscr); 85extern void kvm_cvt_fd(u32 *from, u64 *to);
86extern void kvm_cvt_df(u64 *from, u32 *to, u64 *fpscr); 86extern void kvm_cvt_df(u64 *from, u32 *to);
87 87
88#endif 88#endif
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index b0b23c007d6e..bba3b9b72a39 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/kvm_types.h> 27#include <linux/kvm_types.h>
28#include <linux/kvm_para.h>
28#include <asm/kvm_asm.h> 29#include <asm/kvm_asm.h>
29 30
30#define KVM_MAX_VCPUS 1 31#define KVM_MAX_VCPUS 1
@@ -41,12 +42,17 @@
41 42
42#define HPTEG_CACHE_NUM (1 << 15) 43#define HPTEG_CACHE_NUM (1 << 15)
43#define HPTEG_HASH_BITS_PTE 13 44#define HPTEG_HASH_BITS_PTE 13
45#define HPTEG_HASH_BITS_PTE_LONG 12
44#define HPTEG_HASH_BITS_VPTE 13 46#define HPTEG_HASH_BITS_VPTE 13
45#define HPTEG_HASH_BITS_VPTE_LONG 5 47#define HPTEG_HASH_BITS_VPTE_LONG 5
46#define HPTEG_HASH_NUM_PTE (1 << HPTEG_HASH_BITS_PTE) 48#define HPTEG_HASH_NUM_PTE (1 << HPTEG_HASH_BITS_PTE)
49#define HPTEG_HASH_NUM_PTE_LONG (1 << HPTEG_HASH_BITS_PTE_LONG)
47#define HPTEG_HASH_NUM_VPTE (1 << HPTEG_HASH_BITS_VPTE) 50#define HPTEG_HASH_NUM_VPTE (1 << HPTEG_HASH_BITS_VPTE)
48#define HPTEG_HASH_NUM_VPTE_LONG (1 << HPTEG_HASH_BITS_VPTE_LONG) 51#define HPTEG_HASH_NUM_VPTE_LONG (1 << HPTEG_HASH_BITS_VPTE_LONG)
49 52
53/* Physical Address Mask - allowed range of real mode RAM access */
54#define KVM_PAM 0x0fffffffffffffffULL
55
50struct kvm; 56struct kvm;
51struct kvm_run; 57struct kvm_run;
52struct kvm_vcpu; 58struct kvm_vcpu;
@@ -159,8 +165,10 @@ struct kvmppc_mmu {
159 165
160struct hpte_cache { 166struct hpte_cache {
161 struct hlist_node list_pte; 167 struct hlist_node list_pte;
168 struct hlist_node list_pte_long;
162 struct hlist_node list_vpte; 169 struct hlist_node list_vpte;
163 struct hlist_node list_vpte_long; 170 struct hlist_node list_vpte_long;
171 struct rcu_head rcu_head;
164 u64 host_va; 172 u64 host_va;
165 u64 pfn; 173 u64 pfn;
166 ulong slot; 174 ulong slot;
@@ -210,28 +218,20 @@ struct kvm_vcpu_arch {
210 u32 cr; 218 u32 cr;
211#endif 219#endif
212 220
213 ulong msr;
214#ifdef CONFIG_PPC_BOOK3S 221#ifdef CONFIG_PPC_BOOK3S
215 ulong shadow_msr; 222 ulong shadow_msr;
216 ulong hflags; 223 ulong hflags;
217 ulong guest_owned_ext; 224 ulong guest_owned_ext;
218#endif 225#endif
219 u32 mmucr; 226 u32 mmucr;
220 ulong sprg0;
221 ulong sprg1;
222 ulong sprg2;
223 ulong sprg3;
224 ulong sprg4; 227 ulong sprg4;
225 ulong sprg5; 228 ulong sprg5;
226 ulong sprg6; 229 ulong sprg6;
227 ulong sprg7; 230 ulong sprg7;
228 ulong srr0;
229 ulong srr1;
230 ulong csrr0; 231 ulong csrr0;
231 ulong csrr1; 232 ulong csrr1;
232 ulong dsrr0; 233 ulong dsrr0;
233 ulong dsrr1; 234 ulong dsrr1;
234 ulong dear;
235 ulong esr; 235 ulong esr;
236 u32 dec; 236 u32 dec;
237 u32 decar; 237 u32 decar;
@@ -290,12 +290,17 @@ struct kvm_vcpu_arch {
290 struct tasklet_struct tasklet; 290 struct tasklet_struct tasklet;
291 u64 dec_jiffies; 291 u64 dec_jiffies;
292 unsigned long pending_exceptions; 292 unsigned long pending_exceptions;
293 struct kvm_vcpu_arch_shared *shared;
294 unsigned long magic_page_pa; /* phys addr to map the magic page to */
295 unsigned long magic_page_ea; /* effect. addr to map the magic page to */
293 296
294#ifdef CONFIG_PPC_BOOK3S 297#ifdef CONFIG_PPC_BOOK3S
295 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE]; 298 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
299 struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
296 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE]; 300 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
297 struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG]; 301 struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG];
298 int hpte_cache_count; 302 int hpte_cache_count;
303 spinlock_t mmu_lock;
299#endif 304#endif
300}; 305};
301 306
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 2d48f6a63d0b..50533f9adf40 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -20,16 +20,153 @@
20#ifndef __POWERPC_KVM_PARA_H__ 20#ifndef __POWERPC_KVM_PARA_H__
21#define __POWERPC_KVM_PARA_H__ 21#define __POWERPC_KVM_PARA_H__
22 22
23#include <linux/types.h>
24
25struct kvm_vcpu_arch_shared {
26 __u64 scratch1;
27 __u64 scratch2;
28 __u64 scratch3;
29 __u64 critical; /* Guest may not get interrupts if == r1 */
30 __u64 sprg0;
31 __u64 sprg1;
32 __u64 sprg2;
33 __u64 sprg3;
34 __u64 srr0;
35 __u64 srr1;
36 __u64 dar;
37 __u64 msr;
38 __u32 dsisr;
39 __u32 int_pending; /* Tells the guest if we have an interrupt */
40 __u32 sr[16];
41};
42
43#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
44#define HC_VENDOR_KVM (42 << 16)
45#define HC_EV_SUCCESS 0
46#define HC_EV_UNIMPLEMENTED 12
47
48#define KVM_FEATURE_MAGIC_PAGE 1
49
50#define KVM_MAGIC_FEAT_SR (1 << 0)
51
23#ifdef __KERNEL__ 52#ifdef __KERNEL__
24 53
54#ifdef CONFIG_KVM_GUEST
55
56#include <linux/of.h>
57
58static inline int kvm_para_available(void)
59{
60 struct device_node *hyper_node;
61
62 hyper_node = of_find_node_by_path("/hypervisor");
63 if (!hyper_node)
64 return 0;
65
66 if (!of_device_is_compatible(hyper_node, "linux,kvm"))
67 return 0;
68
69 return 1;
70}
71
72extern unsigned long kvm_hypercall(unsigned long *in,
73 unsigned long *out,
74 unsigned long nr);
75
76#else
77
25static inline int kvm_para_available(void) 78static inline int kvm_para_available(void)
26{ 79{
27 return 0; 80 return 0;
28} 81}
29 82
83static unsigned long kvm_hypercall(unsigned long *in,
84 unsigned long *out,
85 unsigned long nr)
86{
87 return HC_EV_UNIMPLEMENTED;
88}
89
90#endif
91
92static inline long kvm_hypercall0_1(unsigned int nr, unsigned long *r2)
93{
94 unsigned long in[8];
95 unsigned long out[8];
96 unsigned long r;
97
98 r = kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
99 *r2 = out[0];
100
101 return r;
102}
103
104static inline long kvm_hypercall0(unsigned int nr)
105{
106 unsigned long in[8];
107 unsigned long out[8];
108
109 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
110}
111
112static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
113{
114 unsigned long in[8];
115 unsigned long out[8];
116
117 in[0] = p1;
118 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
119}
120
121static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
122 unsigned long p2)
123{
124 unsigned long in[8];
125 unsigned long out[8];
126
127 in[0] = p1;
128 in[1] = p2;
129 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
130}
131
132static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
133 unsigned long p2, unsigned long p3)
134{
135 unsigned long in[8];
136 unsigned long out[8];
137
138 in[0] = p1;
139 in[1] = p2;
140 in[2] = p3;
141 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
142}
143
144static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
145 unsigned long p2, unsigned long p3,
146 unsigned long p4)
147{
148 unsigned long in[8];
149 unsigned long out[8];
150
151 in[0] = p1;
152 in[1] = p2;
153 in[2] = p3;
154 in[3] = p4;
155 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
156}
157
158
30static inline unsigned int kvm_arch_para_features(void) 159static inline unsigned int kvm_arch_para_features(void)
31{ 160{
32 return 0; 161 unsigned long r;
162
163 if (!kvm_para_available())
164 return 0;
165
166 if(kvm_hypercall0_1(KVM_HC_FEATURES, &r))
167 return 0;
168
169 return r;
33} 170}
34 171
35#endif /* __KERNEL__ */ 172#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 18d139ec2d22..ecb3bc74c344 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -107,6 +107,7 @@ extern int kvmppc_booke_init(void);
107extern void kvmppc_booke_exit(void); 107extern void kvmppc_booke_exit(void);
108 108
109extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); 109extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu);
110extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu);
110 111
111/* 112/*
112 * Cuts out inst bits with ordering according to spec. 113 * Cuts out inst bits with ordering according to spec.
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 14b592dfb4e8..7f5e0fefebb0 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -153,6 +153,8 @@ struct lppaca {
153 153
154extern struct lppaca lppaca[]; 154extern struct lppaca lppaca[];
155 155
156#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr)
157
156/* 158/*
157 * SLB shadow buffer structure as defined in the PAPR. The save_area 159 * SLB shadow buffer structure as defined in the PAPR. The save_area
158 * contains adjacent ESID and VSID pairs for each shadowed SLB. The 160 * contains adjacent ESID and VSID pairs for each shadowed SLB. The
@@ -170,6 +172,33 @@ struct slb_shadow {
170 172
171extern struct slb_shadow slb_shadow[]; 173extern struct slb_shadow slb_shadow[];
172 174
175/*
176 * Layout of entries in the hypervisor's dispatch trace log buffer.
177 */
178struct dtl_entry {
179 u8 dispatch_reason;
180 u8 preempt_reason;
181 u16 processor_id;
182 u32 enqueue_to_dispatch_time;
183 u32 ready_to_enqueue_time;
184 u32 waiting_to_ready_time;
185 u64 timebase;
186 u64 fault_addr;
187 u64 srr0;
188 u64 srr1;
189};
190
191#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */
192#define N_DISPATCH_LOG (DISPATCH_LOG_BYTES / sizeof(struct dtl_entry))
193
194/*
195 * When CONFIG_VIRT_CPU_ACCOUNTING = y, the cpu accounting code controls
196 * reading from the dispatch trace log. If other code wants to consume
197 * DTL entries, it can set this pointer to a function that will get
198 * called once for each DTL entry that gets processed.
199 */
200extern void (*dtl_consumer)(struct dtl_entry *entry, u64 index);
201
173#endif /* CONFIG_PPC_BOOK3S */ 202#endif /* CONFIG_PPC_BOOK3S */
174#endif /* __KERNEL__ */ 203#endif /* __KERNEL__ */
175#endif /* _ASM_POWERPC_LPPACA_H */ 204#endif /* _ASM_POWERPC_LPPACA_H */
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index adc8e6cdf339..d045b0145537 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -102,6 +102,9 @@ struct machdep_calls {
102 void (*pci_dma_dev_setup)(struct pci_dev *dev); 102 void (*pci_dma_dev_setup)(struct pci_dev *dev);
103 void (*pci_dma_bus_setup)(struct pci_bus *bus); 103 void (*pci_dma_bus_setup)(struct pci_bus *bus);
104 104
105 /* Platform set_dma_mask override */
106 int (*dma_set_mask)(struct device *dev, u64 dma_mask);
107
105 int (*probe)(void); 108 int (*probe)(void);
106 void (*setup_arch)(void); /* Optional, may be NULL */ 109 void (*setup_arch)(void); /* Optional, may be NULL */
107 void (*init_early)(void); 110 void (*init_early)(void);
diff --git a/arch/powerpc/include/asm/memblock.h b/arch/powerpc/include/asm/memblock.h
index 3c29728b56b1..43efc345065e 100644
--- a/arch/powerpc/include/asm/memblock.h
+++ b/arch/powerpc/include/asm/memblock.h
@@ -5,11 +5,4 @@
5 5
6#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt) 6#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt)
7 7
8#ifdef CONFIG_PPC32
9extern phys_addr_t lowmem_end_addr;
10#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
11#else
12#define MEMBLOCK_REAL_LIMIT 0
13#endif
14
15#endif /* _ASM_POWERPC_MEMBLOCK_H */ 8#endif /* _ASM_POWERPC_MEMBLOCK_H */
diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index 87a1d787c5b6..8eaed81ea642 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -114,6 +114,17 @@
114 114
115#define MAS7_RPN 0xFFFFFFFF 115#define MAS7_RPN 0xFFFFFFFF
116 116
117/* Bit definitions for MMUCFG */
118#define MMUCFG_MAVN 0x00000003 /* MMU Architecture Version Number */
119#define MMUCFG_MAVN_V1 0x00000000 /* v1.0 */
120#define MMUCFG_MAVN_V2 0x00000001 /* v2.0 */
121#define MMUCFG_NTLBS 0x0000000c /* Number of TLBs */
122#define MMUCFG_PIDSIZE 0x000007c0 /* PID Reg Size */
123#define MMUCFG_TWC 0x00008000 /* TLB Write Conditional (v2.0) */
124#define MMUCFG_LRAT 0x00010000 /* LRAT Supported (v2.0) */
125#define MMUCFG_RASIZE 0x00fe0000 /* Real Addr Size */
126#define MMUCFG_LPIDSIZE 0x0f000000 /* LPID Reg Size */
127
117/* Bit definitions for MMUCSR0 */ 128/* Bit definitions for MMUCSR0 */
118#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */ 129#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */
119#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */ 130#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */
@@ -133,6 +144,10 @@
133#define TLBnCFG_GTWE 0x00010000 /* Guest can write */ 144#define TLBnCFG_GTWE 0x00010000 /* Guest can write */
134#define TLBnCFG_IND 0x00020000 /* IND entries supported */ 145#define TLBnCFG_IND 0x00020000 /* IND entries supported */
135#define TLBnCFG_PT 0x00040000 /* Can load from page table */ 146#define TLBnCFG_PT 0x00040000 /* Can load from page table */
147#define TLBnCFG_MINSIZE 0x00f00000 /* Minimum Page Size (v1.0) */
148#define TLBnCFG_MINSIZE_SHIFT 20
149#define TLBnCFG_MAXSIZE 0x000f0000 /* Maximum Page Size (v1.0) */
150#define TLBnCFG_MAXSIZE_SHIFT 16
136#define TLBnCFG_ASSOC 0xff000000 /* Associativity */ 151#define TLBnCFG_ASSOC 0xff000000 /* Associativity */
137 152
138/* TLBnPS encoding */ 153/* TLBnPS encoding */
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 7ebf42ed84a2..bb40a06d3b77 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -2,6 +2,8 @@
2#define _ASM_POWERPC_MMU_H_ 2#define _ASM_POWERPC_MMU_H_
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/types.h>
6
5#include <asm/asm-compat.h> 7#include <asm/asm-compat.h>
6#include <asm/feature-fixups.h> 8#include <asm/feature-fixups.h>
7 9
@@ -82,6 +84,16 @@ extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
82extern void early_init_mmu(void); 84extern void early_init_mmu(void);
83extern void early_init_mmu_secondary(void); 85extern void early_init_mmu_secondary(void);
84 86
87extern void setup_initial_memory_limit(phys_addr_t first_memblock_base,
88 phys_addr_t first_memblock_size);
89
90#ifdef CONFIG_PPC64
91/* This is our real memory area size on ppc64 server, on embedded, we
92 * make it match the size our of bolted TLB area
93 */
94extern u64 ppc64_rma_size;
95#endif /* CONFIG_PPC64 */
96
85#endif /* !__ASSEMBLY__ */ 97#endif /* !__ASSEMBLY__ */
86 98
87/* The kernel use the constants below to index in the page sizes array. 99/* The kernel use the constants below to index in the page sizes array.
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 1ff6662f7faf..ec57540cd7af 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -85,6 +85,8 @@ struct paca_struct {
85 u8 kexec_state; /* set when kexec down has irqs off */ 85 u8 kexec_state; /* set when kexec down has irqs off */
86#ifdef CONFIG_PPC_STD_MMU_64 86#ifdef CONFIG_PPC_STD_MMU_64
87 struct slb_shadow *slb_shadow_ptr; 87 struct slb_shadow *slb_shadow_ptr;
88 struct dtl_entry *dispatch_log;
89 struct dtl_entry *dispatch_log_end;
88 90
89 /* 91 /*
90 * Now, starting in cacheline 2, the exception save areas 92 * Now, starting in cacheline 2, the exception save areas
@@ -129,13 +131,19 @@ struct paca_struct {
129 u8 soft_enabled; /* irq soft-enable flag */ 131 u8 soft_enabled; /* irq soft-enable flag */
130 u8 hard_enabled; /* set if irqs are enabled in MSR */ 132 u8 hard_enabled; /* set if irqs are enabled in MSR */
131 u8 io_sync; /* writel() needs spin_unlock sync */ 133 u8 io_sync; /* writel() needs spin_unlock sync */
132 u8 perf_event_pending; /* PM interrupt while soft-disabled */ 134 u8 irq_work_pending; /* IRQ_WORK interrupt while soft-disable */
133 135
134 /* Stuff for accurate time accounting */ 136 /* Stuff for accurate time accounting */
135 u64 user_time; /* accumulated usermode TB ticks */ 137 u64 user_time; /* accumulated usermode TB ticks */
136 u64 system_time; /* accumulated system TB ticks */ 138 u64 system_time; /* accumulated system TB ticks */
137 u64 startpurr; /* PURR/TB value snapshot */ 139 u64 user_time_scaled; /* accumulated usermode SPURR ticks */
140 u64 starttime; /* TB value snapshot */
141 u64 starttime_user; /* TB value on exit to usermode */
138 u64 startspurr; /* SPURR value snapshot */ 142 u64 startspurr; /* SPURR value snapshot */
143 u64 utime_sspurr; /* ->user_time when ->startspurr set */
144 u64 stolen_time; /* TB ticks taken by hypervisor */
145 u64 dtl_ridx; /* read index in dispatch log */
146 struct dtl_entry *dtl_curr; /* pointer corresponding to dtl_ridx */
139 147
140#ifdef CONFIG_KVM_BOOK3S_HANDLER 148#ifdef CONFIG_KVM_BOOK3S_HANDLER
141 /* We use this to store guest state in */ 149 /* We use this to store guest state in */
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index 358ff14ea25e..932f88dcf6fa 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -163,7 +163,7 @@ do { \
163#endif /* !CONFIG_HUGETLB_PAGE */ 163#endif /* !CONFIG_HUGETLB_PAGE */
164 164
165#define VM_DATA_DEFAULT_FLAGS \ 165#define VM_DATA_DEFAULT_FLAGS \
166 (test_thread_flag(TIF_32BIT) ? \ 166 (is_32bit_task() ? \
167 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64) 167 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
168 168
169/* 169/*
@@ -179,7 +179,7 @@ do { \
179 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 179 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
180 180
181#define VM_STACK_DEFAULT_FLAGS \ 181#define VM_STACK_DEFAULT_FLAGS \
182 (test_thread_flag(TIF_32BIT) ? \ 182 (is_32bit_task() ? \
183 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64) 183 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
184 184
185#include <asm-generic/getorder.h> 185#include <asm-generic/getorder.h>
diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
index 42fdff0e4b32..43268f15004e 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -28,8 +28,8 @@ extern void find_and_init_phbs(void);
28extern struct pci_dev *isa_bridge_pcidev; /* may be NULL if no ISA bus */ 28extern struct pci_dev *isa_bridge_pcidev; /* may be NULL if no ISA bus */
29 29
30/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */ 30/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
31#define BUID_HI(buid) ((buid) >> 32) 31#define BUID_HI(buid) upper_32_bits(buid)
32#define BUID_LO(buid) ((buid) & 0xffffffff) 32#define BUID_LO(buid) lower_32_bits(buid)
33 33
34/* PCI device_node operations */ 34/* PCI device_node operations */
35struct device_node; 35struct device_node;
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 498fe09263d3..98210067c1cc 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -9,6 +9,7 @@
9#include <asm/asm-compat.h> 9#include <asm/asm-compat.h>
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/ppc-opcode.h> 11#include <asm/ppc-opcode.h>
12#include <asm/firmware.h>
12 13
13#ifndef __ASSEMBLY__ 14#ifndef __ASSEMBLY__
14#error __FILE__ should only be used in assembler files 15#error __FILE__ should only be used in assembler files
@@ -26,17 +27,13 @@
26#ifndef CONFIG_VIRT_CPU_ACCOUNTING 27#ifndef CONFIG_VIRT_CPU_ACCOUNTING
27#define ACCOUNT_CPU_USER_ENTRY(ra, rb) 28#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
28#define ACCOUNT_CPU_USER_EXIT(ra, rb) 29#define ACCOUNT_CPU_USER_EXIT(ra, rb)
30#define ACCOUNT_STOLEN_TIME
29#else 31#else
30#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \ 32#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
31 beq 2f; /* if from kernel mode */ \ 33 beq 2f; /* if from kernel mode */ \
32BEGIN_FTR_SECTION; \ 34 MFTB(ra); /* get timebase */ \
33 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 35 ld rb,PACA_STARTTIME_USER(r13); \
34END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 36 std ra,PACA_STARTTIME(r13); \
35BEGIN_FTR_SECTION; \
36 MFTB(ra); /* or get TB if no PURR */ \
37END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
38 ld rb,PACA_STARTPURR(r13); \
39 std ra,PACA_STARTPURR(r13); \
40 subf rb,rb,ra; /* subtract start value */ \ 37 subf rb,rb,ra; /* subtract start value */ \
41 ld ra,PACA_USER_TIME(r13); \ 38 ld ra,PACA_USER_TIME(r13); \
42 add ra,ra,rb; /* add on to user time */ \ 39 add ra,ra,rb; /* add on to user time */ \
@@ -44,19 +41,34 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
442: 412:
45 42
46#define ACCOUNT_CPU_USER_EXIT(ra, rb) \ 43#define ACCOUNT_CPU_USER_EXIT(ra, rb) \
47BEGIN_FTR_SECTION; \ 44 MFTB(ra); /* get timebase */ \
48 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 45 ld rb,PACA_STARTTIME(r13); \
49END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 46 std ra,PACA_STARTTIME_USER(r13); \
50BEGIN_FTR_SECTION; \
51 MFTB(ra); /* or get TB if no PURR */ \
52END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
53 ld rb,PACA_STARTPURR(r13); \
54 std ra,PACA_STARTPURR(r13); \
55 subf rb,rb,ra; /* subtract start value */ \ 47 subf rb,rb,ra; /* subtract start value */ \
56 ld ra,PACA_SYSTEM_TIME(r13); \ 48 ld ra,PACA_SYSTEM_TIME(r13); \
57 add ra,ra,rb; /* add on to user time */ \ 49 add ra,ra,rb; /* add on to system time */ \
58 std ra,PACA_SYSTEM_TIME(r13); 50 std ra,PACA_SYSTEM_TIME(r13)
59#endif 51
52#ifdef CONFIG_PPC_SPLPAR
53#define ACCOUNT_STOLEN_TIME \
54BEGIN_FW_FTR_SECTION; \
55 beq 33f; \
56 /* from user - see if there are any DTL entries to process */ \
57 ld r10,PACALPPACAPTR(r13); /* get ptr to VPA */ \
58 ld r11,PACA_DTL_RIDX(r13); /* get log read index */ \
59 ld r10,LPPACA_DTLIDX(r10); /* get log write index */ \
60 cmpd cr1,r11,r10; \
61 beq+ cr1,33f; \
62 bl .accumulate_stolen_time; \
6333: \
64END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
65
66#else /* CONFIG_PPC_SPLPAR */
67#define ACCOUNT_STOLEN_TIME
68
69#endif /* CONFIG_PPC_SPLPAR */
70
71#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
60 72
61/* 73/*
62 * Macros for storing registers into and loading registers from 74 * Macros for storing registers into and loading registers from
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 19c05b0f74be..4c14187ba02d 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -118,7 +118,7 @@ extern struct task_struct *last_task_used_spe;
118#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) 118#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
119#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4)) 119#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
120 120
121#define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \ 121#define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \
122 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) 122 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
123#endif 123#endif
124 124
@@ -128,7 +128,7 @@ extern struct task_struct *last_task_used_spe;
128#define STACK_TOP_USER64 TASK_SIZE_USER64 128#define STACK_TOP_USER64 TASK_SIZE_USER64
129#define STACK_TOP_USER32 TASK_SIZE_USER32 129#define STACK_TOP_USER32 TASK_SIZE_USER32
130 130
131#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ 131#define STACK_TOP (is_32bit_task() ? \
132 STACK_TOP_USER32 : STACK_TOP_USER64) 132 STACK_TOP_USER32 : STACK_TOP_USER64)
133 133
134#define STACK_TOP_MAX STACK_TOP_USER64 134#define STACK_TOP_MAX STACK_TOP_USER64
diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h
index f2b370180a09..76bb195e4f24 100644
--- a/arch/powerpc/include/asm/pte-common.h
+++ b/arch/powerpc/include/asm/pte-common.h
@@ -171,6 +171,13 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
171/* Make modules code happy. We don't set RO yet */ 171/* Make modules code happy. We don't set RO yet */
172#define PAGE_KERNEL_EXEC PAGE_KERNEL_X 172#define PAGE_KERNEL_EXEC PAGE_KERNEL_X
173 173
174/*
175 * Don't just check for any non zero bits in __PAGE_USER, since for book3e
176 * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in
177 * _PAGE_USER. Need to explictly match _PAGE_BAP_UR bit in that case too.
178 */
179#define pte_user(val) ((val & _PAGE_USER) == _PAGE_USER)
180
174/* Advertise special mapping type for AGP */ 181/* Advertise special mapping type for AGP */
175#define PAGE_AGP (PAGE_KERNEL_NC) 182#define PAGE_AGP (PAGE_KERNEL_NC)
176#define HAVE_PAGE_AGP 183#define HAVE_PAGE_AGP
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 3d35f8ae377e..9a1193e30f26 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -187,6 +187,7 @@ extern void rtas_progress(char *s, unsigned short hex);
187extern void rtas_initialize(void); 187extern void rtas_initialize(void);
188extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); 188extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
189extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); 189extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
190extern int rtas_ibm_suspend_me(struct rtas_args *);
190 191
191struct rtc_time; 192struct rtc_time;
192extern unsigned long rtas_get_boot_time(void); 193extern unsigned long rtas_get_boot_time(void);
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 3d212669a130..aa0f1ebb4aaf 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -329,3 +329,22 @@ COMPAT_SYS(rt_tgsigqueueinfo)
329SYSCALL(fanotify_init) 329SYSCALL(fanotify_init)
330COMPAT_SYS(fanotify_mark) 330COMPAT_SYS(fanotify_mark)
331SYSCALL_SPU(prlimit64) 331SYSCALL_SPU(prlimit64)
332SYSCALL_SPU(socket)
333SYSCALL_SPU(bind)
334SYSCALL_SPU(connect)
335SYSCALL_SPU(listen)
336SYSCALL_SPU(accept)
337SYSCALL_SPU(getsockname)
338SYSCALL_SPU(getpeername)
339SYSCALL_SPU(socketpair)
340SYSCALL_SPU(send)
341SYSCALL_SPU(sendto)
342COMPAT_SYS_SPU(recv)
343COMPAT_SYS_SPU(recvfrom)
344SYSCALL_SPU(shutdown)
345COMPAT_SYS_SPU(setsockopt)
346COMPAT_SYS_SPU(getsockopt)
347COMPAT_SYS_SPU(sendmsg)
348COMPAT_SYS_SPU(recvmsg)
349COMPAT_SYS_SPU(recvmmsg)
350SYSCALL_SPU(accept4)
diff --git a/arch/powerpc/include/asm/system.h b/arch/powerpc/include/asm/system.h
index 6c294acac848..5e474ddd2273 100644
--- a/arch/powerpc/include/asm/system.h
+++ b/arch/powerpc/include/asm/system.h
@@ -154,8 +154,8 @@ extern void enable_kernel_spe(void);
154extern void giveup_spe(struct task_struct *); 154extern void giveup_spe(struct task_struct *);
155extern void load_up_spe(struct task_struct *); 155extern void load_up_spe(struct task_struct *);
156extern int fix_alignment(struct pt_regs *); 156extern int fix_alignment(struct pt_regs *);
157extern void cvt_fd(float *from, double *to, struct thread_struct *thread); 157extern void cvt_fd(float *from, double *to);
158extern void cvt_df(double *from, float *to, struct thread_struct *thread); 158extern void cvt_df(double *from, float *to);
159 159
160#ifndef CONFIG_SMP 160#ifndef CONFIG_SMP
161extern void discard_lazy_cpu_state(void); 161extern void discard_lazy_cpu_state(void);
@@ -542,10 +542,6 @@ extern void reloc_got2(unsigned long);
542 542
543#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x))) 543#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
544 544
545#ifdef CONFIG_VIRT_CPU_ACCOUNTING
546extern void account_system_vtime(struct task_struct *);
547#endif
548
549extern struct dentry *powerpc_debugfs_root; 545extern struct dentry *powerpc_debugfs_root;
550 546
551#endif /* __KERNEL__ */ 547#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index dc779dfcf258..fe6f7c2c9c68 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -34,7 +34,6 @@ extern void to_tm(int tim, struct rtc_time * tm);
34extern void GregorianDay(struct rtc_time *tm); 34extern void GregorianDay(struct rtc_time *tm);
35 35
36extern void generic_calibrate_decr(void); 36extern void generic_calibrate_decr(void);
37extern void snapshot_timebase(void);
38 37
39extern void set_dec_cpu6(unsigned int val); 38extern void set_dec_cpu6(unsigned int val);
40 39
@@ -212,12 +211,8 @@ struct cpu_usage {
212DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array); 211DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
213 212
214#if defined(CONFIG_VIRT_CPU_ACCOUNTING) 213#if defined(CONFIG_VIRT_CPU_ACCOUNTING)
215extern void calculate_steal_time(void);
216extern void snapshot_timebases(void);
217#define account_process_vtime(tsk) account_process_tick(tsk, 0) 214#define account_process_vtime(tsk) account_process_tick(tsk, 0)
218#else 215#else
219#define calculate_steal_time() do { } while (0)
220#define snapshot_timebases() do { } while (0)
221#define account_process_vtime(tsk) do { } while (0) 216#define account_process_vtime(tsk) do { } while (0)
222#endif 217#endif
223 218
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 597e6f9d094a..6151937657f6 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -348,10 +348,29 @@
348#define __NR_fanotify_init 323 348#define __NR_fanotify_init 323
349#define __NR_fanotify_mark 324 349#define __NR_fanotify_mark 324
350#define __NR_prlimit64 325 350#define __NR_prlimit64 325
351#define __NR_socket 326
352#define __NR_bind 327
353#define __NR_connect 328
354#define __NR_listen 329
355#define __NR_accept 330
356#define __NR_getsockname 331
357#define __NR_getpeername 332
358#define __NR_socketpair 333
359#define __NR_send 334
360#define __NR_sendto 335
361#define __NR_recv 336
362#define __NR_recvfrom 337
363#define __NR_shutdown 338
364#define __NR_setsockopt 339
365#define __NR_getsockopt 340
366#define __NR_sendmsg 341
367#define __NR_recvmsg 342
368#define __NR_recvmmsg 343
369#define __NR_accept4 344
351 370
352#ifdef __KERNEL__ 371#ifdef __KERNEL__
353 372
354#define __NR_syscalls 326 373#define __NR_syscalls 345
355 374
356#define __NR__exit __NR_exit 375#define __NR__exit __NR_exit
357#define NR_syscalls __NR_syscalls 376#define NR_syscalls __NR_syscalls
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 1dda70129141..36c30f31ec93 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -55,7 +55,9 @@ obj-$(CONFIG_IBMVIO) += vio.o
55obj-$(CONFIG_IBMEBUS) += ibmebus.o 55obj-$(CONFIG_IBMEBUS) += ibmebus.o
56obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o 56obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o
57obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 57obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
58ifeq ($(CONFIG_PPC32),y)
58obj-$(CONFIG_E500) += idle_e500.o 59obj-$(CONFIG_E500) += idle_e500.o
60endif
59obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o 61obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
60obj-$(CONFIG_TAU) += tau_6xx.o 62obj-$(CONFIG_TAU) += tau_6xx.o
61obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o 63obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o
@@ -67,7 +69,7 @@ endif
67obj64-$(CONFIG_HIBERNATION) += swsusp_asm64.o 69obj64-$(CONFIG_HIBERNATION) += swsusp_asm64.o
68obj-$(CONFIG_MODULES) += module.o module_$(CONFIG_WORD_SIZE).o 70obj-$(CONFIG_MODULES) += module.o module_$(CONFIG_WORD_SIZE).o
69obj-$(CONFIG_44x) += cpu_setup_44x.o 71obj-$(CONFIG_44x) += cpu_setup_44x.o
70obj-$(CONFIG_FSL_BOOKE) += cpu_setup_fsl_booke.o dbell.o 72obj-$(CONFIG_PPC_FSL_BOOK3E) += cpu_setup_fsl_booke.o dbell.o
71obj-$(CONFIG_PPC_BOOK3E_64) += dbell.o 73obj-$(CONFIG_PPC_BOOK3E_64) += dbell.o
72 74
73extra-y := head_$(CONFIG_WORD_SIZE).o 75extra-y := head_$(CONFIG_WORD_SIZE).o
@@ -127,6 +129,8 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),)
127obj-y += ppc_save_regs.o 129obj-y += ppc_save_regs.o
128endif 130endif
129 131
132obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o
133
130# Disable GCOV in odd or sensitive code 134# Disable GCOV in odd or sensitive code
131GCOV_PROFILE_prom_init.o := n 135GCOV_PROFILE_prom_init.o := n
132GCOV_PROFILE_ftrace.o := n 136GCOV_PROFILE_ftrace.o := n
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index b876e989220b..8184ee97e484 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -889,7 +889,7 @@ int fix_alignment(struct pt_regs *regs)
889#ifdef CONFIG_PPC_FPU 889#ifdef CONFIG_PPC_FPU
890 preempt_disable(); 890 preempt_disable();
891 enable_kernel_fp(); 891 enable_kernel_fp();
892 cvt_df(&data.dd, (float *)&data.v[4], &current->thread); 892 cvt_df(&data.dd, (float *)&data.v[4]);
893 preempt_enable(); 893 preempt_enable();
894#else 894#else
895 return 0; 895 return 0;
@@ -933,7 +933,7 @@ int fix_alignment(struct pt_regs *regs)
933#ifdef CONFIG_PPC_FPU 933#ifdef CONFIG_PPC_FPU
934 preempt_disable(); 934 preempt_disable();
935 enable_kernel_fp(); 935 enable_kernel_fp();
936 cvt_fd((float *)&data.v[4], &data.dd, &current->thread); 936 cvt_fd((float *)&data.v[4], &data.dd);
937 preempt_enable(); 937 preempt_enable();
938#else 938#else
939 return 0; 939 return 0;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 1c0607ddccc0..bd0df2e6aa8f 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -48,11 +48,11 @@
48#ifdef CONFIG_PPC_ISERIES 48#ifdef CONFIG_PPC_ISERIES
49#include <asm/iseries/alpaca.h> 49#include <asm/iseries/alpaca.h>
50#endif 50#endif
51#ifdef CONFIG_KVM 51#if defined(CONFIG_KVM) || defined(CONFIG_KVM_GUEST)
52#include <linux/kvm_host.h> 52#include <linux/kvm_host.h>
53#ifndef CONFIG_BOOKE
54#include <asm/kvm_book3s.h>
55#endif 53#endif
54#if defined(CONFIG_KVM) && defined(CONFIG_PPC_BOOK3S)
55#include <asm/kvm_book3s.h>
56#endif 56#endif
57 57
58#ifdef CONFIG_PPC32 58#ifdef CONFIG_PPC32
@@ -61,7 +61,7 @@
61#endif 61#endif
62#endif 62#endif
63 63
64#if defined(CONFIG_FSL_BOOKE) 64#if defined(CONFIG_PPC_FSL_BOOK3E)
65#include "../mm/mmu_decl.h" 65#include "../mm/mmu_decl.h"
66#endif 66#endif
67 67
@@ -181,17 +181,19 @@ int main(void)
181 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid)); 181 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid));
182 DEFINE(SLBSHADOW_STACKESID, 182 DEFINE(SLBSHADOW_STACKESID,
183 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid)); 183 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid));
184 DEFINE(SLBSHADOW_SAVEAREA, offsetof(struct slb_shadow, save_area));
184 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0)); 185 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0));
185 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); 186 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));
186 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int)); 187 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int));
187 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int)); 188 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int));
188 DEFINE(SLBSHADOW_SAVEAREA, offsetof(struct slb_shadow, save_area)); 189 DEFINE(LPPACA_DTLIDX, offsetof(struct lppaca, dtl_idx));
190 DEFINE(PACA_DTL_RIDX, offsetof(struct paca_struct, dtl_ridx));
189#endif /* CONFIG_PPC_STD_MMU_64 */ 191#endif /* CONFIG_PPC_STD_MMU_64 */
190 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp)); 192 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));
191 DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id)); 193 DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));
192 DEFINE(PACAKEXECSTATE, offsetof(struct paca_struct, kexec_state)); 194 DEFINE(PACAKEXECSTATE, offsetof(struct paca_struct, kexec_state));
193 DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr)); 195 DEFINE(PACA_STARTTIME, offsetof(struct paca_struct, starttime));
194 DEFINE(PACA_STARTSPURR, offsetof(struct paca_struct, startspurr)); 196 DEFINE(PACA_STARTTIME_USER, offsetof(struct paca_struct, starttime_user));
195 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time)); 197 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
196 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 198 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
197 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save)); 199 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
@@ -394,12 +396,13 @@ int main(void)
394 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 396 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack));
395 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 397 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
396 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 398 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr));
397 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.msr));
398 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4)); 399 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4));
399 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 400 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5));
400 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 401 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6));
401 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); 402 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7));
402 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid)); 403 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid));
404 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared));
405 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
403 406
404 /* book3s */ 407 /* book3s */
405#ifdef CONFIG_PPC_BOOK3S 408#ifdef CONFIG_PPC_BOOK3S
@@ -464,11 +467,27 @@ int main(void)
464 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); 467 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
465#endif /* CONFIG_PPC_BOOK3S */ 468#endif /* CONFIG_PPC_BOOK3S */
466#endif 469#endif
470
471#ifdef CONFIG_KVM_GUEST
472 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared,
473 scratch1));
474 DEFINE(KVM_MAGIC_SCRATCH2, offsetof(struct kvm_vcpu_arch_shared,
475 scratch2));
476 DEFINE(KVM_MAGIC_SCRATCH3, offsetof(struct kvm_vcpu_arch_shared,
477 scratch3));
478 DEFINE(KVM_MAGIC_INT, offsetof(struct kvm_vcpu_arch_shared,
479 int_pending));
480 DEFINE(KVM_MAGIC_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
481 DEFINE(KVM_MAGIC_CRITICAL, offsetof(struct kvm_vcpu_arch_shared,
482 critical));
483 DEFINE(KVM_MAGIC_SR, offsetof(struct kvm_vcpu_arch_shared, sr));
484#endif
485
467#ifdef CONFIG_44x 486#ifdef CONFIG_44x
468 DEFINE(PGD_T_LOG2, PGD_T_LOG2); 487 DEFINE(PGD_T_LOG2, PGD_T_LOG2);
469 DEFINE(PTE_T_LOG2, PTE_T_LOG2); 488 DEFINE(PTE_T_LOG2, PTE_T_LOG2);
470#endif 489#endif
471#ifdef CONFIG_FSL_BOOKE 490#ifdef CONFIG_PPC_FSL_BOOK3E
472 DEFINE(TLBCAM_SIZE, sizeof(struct tlbcam)); 491 DEFINE(TLBCAM_SIZE, sizeof(struct tlbcam));
473 DEFINE(TLBCAM_MAS0, offsetof(struct tlbcam, MAS0)); 492 DEFINE(TLBCAM_MAS0, offsetof(struct tlbcam, MAS0));
474 DEFINE(TLBCAM_MAS1, offsetof(struct tlbcam, MAS1)); 493 DEFINE(TLBCAM_MAS1, offsetof(struct tlbcam, MAS1));
diff --git a/arch/powerpc/kernel/cpu_setup_44x.S b/arch/powerpc/kernel/cpu_setup_44x.S
index 7d606f89a839..e32b4a9a2c22 100644
--- a/arch/powerpc/kernel/cpu_setup_44x.S
+++ b/arch/powerpc/kernel/cpu_setup_44x.S
@@ -35,6 +35,7 @@ _GLOBAL(__setup_cpu_440grx)
35_GLOBAL(__setup_cpu_460ex) 35_GLOBAL(__setup_cpu_460ex)
36_GLOBAL(__setup_cpu_460gt) 36_GLOBAL(__setup_cpu_460gt)
37_GLOBAL(__setup_cpu_460sx) 37_GLOBAL(__setup_cpu_460sx)
38_GLOBAL(__setup_cpu_apm821xx)
38 mflr r4 39 mflr r4
39 bl __init_fpu_44x 40 bl __init_fpu_44x
40 bl __fixup_440A_mcheck 41 bl __fixup_440A_mcheck
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 0adb50ad8031..894e64fa481e 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -51,6 +51,7 @@ _GLOBAL(__e500_dcache_setup)
51 isync 51 isync
52 blr 52 blr
53 53
54#ifdef CONFIG_PPC32
54_GLOBAL(__setup_cpu_e200) 55_GLOBAL(__setup_cpu_e200)
55 /* enable dedicated debug exception handling resources (Debug APU) */ 56 /* enable dedicated debug exception handling resources (Debug APU) */
56 mfspr r3,SPRN_HID0 57 mfspr r3,SPRN_HID0
@@ -72,3 +73,17 @@ _GLOBAL(__setup_cpu_e500mc)
72 bl __setup_e500mc_ivors 73 bl __setup_e500mc_ivors
73 mtlr r4 74 mtlr r4
74 blr 75 blr
76#endif
77/* Right now, restore and setup are the same thing */
78_GLOBAL(__restore_cpu_e5500)
79_GLOBAL(__setup_cpu_e5500)
80 mflr r4
81 bl __e500_icache_setup
82 bl __e500_dcache_setup
83#ifdef CONFIG_PPC_BOOK3E_64
84 bl .__setup_base_ivors
85#else
86 bl __setup_e500mc_ivors
87#endif
88 mtlr r4
89 blr
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 1f9123f412ec..96a908f1cd87 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -48,6 +48,7 @@ extern void __setup_cpu_440x5(unsigned long offset, struct cpu_spec* spec);
48extern void __setup_cpu_460ex(unsigned long offset, struct cpu_spec* spec); 48extern void __setup_cpu_460ex(unsigned long offset, struct cpu_spec* spec);
49extern void __setup_cpu_460gt(unsigned long offset, struct cpu_spec* spec); 49extern void __setup_cpu_460gt(unsigned long offset, struct cpu_spec* spec);
50extern void __setup_cpu_460sx(unsigned long offset, struct cpu_spec *spec); 50extern void __setup_cpu_460sx(unsigned long offset, struct cpu_spec *spec);
51extern void __setup_cpu_apm821xx(unsigned long offset, struct cpu_spec *spec);
51extern void __setup_cpu_603(unsigned long offset, struct cpu_spec* spec); 52extern void __setup_cpu_603(unsigned long offset, struct cpu_spec* spec);
52extern void __setup_cpu_604(unsigned long offset, struct cpu_spec* spec); 53extern void __setup_cpu_604(unsigned long offset, struct cpu_spec* spec);
53extern void __setup_cpu_750(unsigned long offset, struct cpu_spec* spec); 54extern void __setup_cpu_750(unsigned long offset, struct cpu_spec* spec);
@@ -66,6 +67,10 @@ extern void __restore_cpu_ppc970(void);
66extern void __setup_cpu_power7(unsigned long offset, struct cpu_spec* spec); 67extern void __setup_cpu_power7(unsigned long offset, struct cpu_spec* spec);
67extern void __restore_cpu_power7(void); 68extern void __restore_cpu_power7(void);
68#endif /* CONFIG_PPC64 */ 69#endif /* CONFIG_PPC64 */
70#if defined(CONFIG_E500)
71extern void __setup_cpu_e5500(unsigned long offset, struct cpu_spec* spec);
72extern void __restore_cpu_e5500(void);
73#endif /* CONFIG_E500 */
69 74
70/* This table only contains "desktop" CPUs, it need to be filled with embedded 75/* This table only contains "desktop" CPUs, it need to be filled with embedded
71 * ones as well... 76 * ones as well...
@@ -1805,6 +1810,20 @@ static struct cpu_spec __initdata cpu_specs[] = {
1805 .machine_check = machine_check_440A, 1810 .machine_check = machine_check_440A,
1806 .platform = "ppc440", 1811 .platform = "ppc440",
1807 }, 1812 },
1813 { /* 464 in APM821xx */
1814 .pvr_mask = 0xffffff00,
1815 .pvr_value = 0x12C41C80,
1816 .cpu_name = "APM821XX",
1817 .cpu_features = CPU_FTRS_44X,
1818 .cpu_user_features = COMMON_USER_BOOKE |
1819 PPC_FEATURE_HAS_FPU,
1820 .mmu_features = MMU_FTR_TYPE_44x,
1821 .icache_bsize = 32,
1822 .dcache_bsize = 32,
1823 .cpu_setup = __setup_cpu_apm821xx,
1824 .machine_check = machine_check_440A,
1825 .platform = "ppc440",
1826 },
1808 { /* 476 core */ 1827 { /* 476 core */
1809 .pvr_mask = 0xffff0000, 1828 .pvr_mask = 0xffff0000,
1810 .pvr_value = 0x11a50000, 1829 .pvr_value = 0x11a50000,
@@ -1891,7 +1910,9 @@ static struct cpu_spec __initdata cpu_specs[] = {
1891 .platform = "ppc5554", 1910 .platform = "ppc5554",
1892 } 1911 }
1893#endif /* CONFIG_E200 */ 1912#endif /* CONFIG_E200 */
1913#endif /* CONFIG_PPC32 */
1894#ifdef CONFIG_E500 1914#ifdef CONFIG_E500
1915#ifdef CONFIG_PPC32
1895 { /* e500 */ 1916 { /* e500 */
1896 .pvr_mask = 0xffff0000, 1917 .pvr_mask = 0xffff0000,
1897 .pvr_value = 0x80200000, 1918 .pvr_value = 0x80200000,
@@ -1946,6 +1967,26 @@ static struct cpu_spec __initdata cpu_specs[] = {
1946 .machine_check = machine_check_e500mc, 1967 .machine_check = machine_check_e500mc,
1947 .platform = "ppce500mc", 1968 .platform = "ppce500mc",
1948 }, 1969 },
1970#endif /* CONFIG_PPC32 */
1971 { /* e5500 */
1972 .pvr_mask = 0xffff0000,
1973 .pvr_value = 0x80240000,
1974 .cpu_name = "e5500",
1975 .cpu_features = CPU_FTRS_E500MC,
1976 .cpu_user_features = COMMON_USER_BOOKE,
1977 .mmu_features = MMU_FTR_TYPE_FSL_E | MMU_FTR_BIG_PHYS |
1978 MMU_FTR_USE_TLBILX,
1979 .icache_bsize = 64,
1980 .dcache_bsize = 64,
1981 .num_pmcs = 4,
1982 .oprofile_cpu_type = "ppc/e500mc",
1983 .oprofile_type = PPC_OPROFILE_FSL_EMB,
1984 .cpu_setup = __setup_cpu_e5500,
1985 .cpu_restore = __restore_cpu_e5500,
1986 .machine_check = machine_check_e500mc,
1987 .platform = "ppce5500",
1988 },
1989#ifdef CONFIG_PPC32
1949 { /* default match */ 1990 { /* default match */
1950 .pvr_mask = 0x00000000, 1991 .pvr_mask = 0x00000000,
1951 .pvr_value = 0x00000000, 1992 .pvr_value = 0x00000000,
@@ -1960,8 +2001,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
1960 .machine_check = machine_check_e500, 2001 .machine_check = machine_check_e500,
1961 .platform = "powerpc", 2002 .platform = "powerpc",
1962 } 2003 }
1963#endif /* CONFIG_E500 */
1964#endif /* CONFIG_PPC32 */ 2004#endif /* CONFIG_PPC32 */
2005#endif /* CONFIG_E500 */
1965 2006
1966#ifdef CONFIG_PPC_BOOK3E_64 2007#ifdef CONFIG_PPC_BOOK3E_64
1967 { /* This is a default entry to get going, to be replaced by 2008 { /* This is a default entry to get going, to be replaced by
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 4457382f8667..832c8c4db254 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -414,18 +414,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
414 crash_kexec_wait_realmode(crashing_cpu); 414 crash_kexec_wait_realmode(crashing_cpu);
415#endif 415#endif
416 416
417 for_each_irq(i) { 417 machine_kexec_mask_interrupts();
418 struct irq_desc *desc = irq_to_desc(i);
419
420 if (!desc || !desc->chip || !desc->chip->eoi)
421 continue;
422
423 if (desc->status & IRQ_INPROGRESS)
424 desc->chip->eoi(i);
425
426 if (!(desc->status & IRQ_DISABLED))
427 desc->chip->shutdown(i);
428 }
429 418
430 /* 419 /*
431 * Call registered shutdown routines savely. Swap out 420 * Call registered shutdown routines savely. Swap out
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 37771a518119..6e54a0fd31aa 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -74,16 +74,17 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
74{ 74{
75 struct iommu_table *tbl = get_iommu_table_base(dev); 75 struct iommu_table *tbl = get_iommu_table_base(dev);
76 76
77 if (!tbl || tbl->it_offset > mask) { 77 if (!tbl) {
78 printk(KERN_INFO 78 dev_info(dev, "Warning: IOMMU dma not supported: mask 0x%08llx"
79 "Warning: IOMMU offset too big for device mask\n"); 79 ", table unavailable\n", mask);
80 if (tbl) 80 return 0;
81 printk(KERN_INFO 81 }
82 "mask: 0x%08llx, table offset: 0x%08lx\n", 82
83 mask, tbl->it_offset); 83 if ((tbl->it_offset + tbl->it_size) > (mask >> IOMMU_PAGE_SHIFT)) {
84 else 84 dev_info(dev, "Warning: IOMMU window too big for device mask\n");
85 printk(KERN_INFO "mask: 0x%08llx, table unavailable\n", 85 dev_info(dev, "mask: 0x%08llx, table end: 0x%08lx\n",
86 mask); 86 mask, (tbl->it_offset + tbl->it_size) <<
87 IOMMU_PAGE_SHIFT);
87 return 0; 88 return 0;
88 } else 89 } else
89 return 1; 90 return 1;
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 84d6367ec003..cf02cad62d9a 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -12,6 +12,7 @@
12#include <linux/memblock.h> 12#include <linux/memblock.h>
13#include <asm/bug.h> 13#include <asm/bug.h>
14#include <asm/abs_addr.h> 14#include <asm/abs_addr.h>
15#include <asm/machdep.h>
15 16
16/* 17/*
17 * Generic direct DMA implementation 18 * Generic direct DMA implementation
@@ -89,7 +90,7 @@ static int dma_direct_dma_supported(struct device *dev, u64 mask)
89 /* Could be improved so platforms can set the limit in case 90 /* Could be improved so platforms can set the limit in case
90 * they have limited DMA windows 91 * they have limited DMA windows
91 */ 92 */
92 return mask >= (memblock_end_of_DRAM() - 1); 93 return mask >= get_dma_offset(dev) + (memblock_end_of_DRAM() - 1);
93#else 94#else
94 return 1; 95 return 1;
95#endif 96#endif
@@ -154,6 +155,23 @@ EXPORT_SYMBOL(dma_direct_ops);
154 155
155#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16) 156#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
156 157
158int dma_set_mask(struct device *dev, u64 dma_mask)
159{
160 struct dma_map_ops *dma_ops = get_dma_ops(dev);
161
162 if (ppc_md.dma_set_mask)
163 return ppc_md.dma_set_mask(dev, dma_mask);
164 if (unlikely(dma_ops == NULL))
165 return -EIO;
166 if (dma_ops->set_dma_mask != NULL)
167 return dma_ops->set_dma_mask(dev, dma_mask);
168 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
169 return -EIO;
170 *dev->dma_mask = dma_mask;
171 return 0;
172}
173EXPORT_SYMBOL(dma_set_mask);
174
157static int __init dma_init(void) 175static int __init dma_init(void)
158{ 176{
159 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); 177 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 42e9d908914a..d82878c4daa6 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -97,6 +97,24 @@ system_call_common:
97 addi r9,r1,STACK_FRAME_OVERHEAD 97 addi r9,r1,STACK_FRAME_OVERHEAD
98 ld r11,exception_marker@toc(r2) 98 ld r11,exception_marker@toc(r2)
99 std r11,-16(r9) /* "regshere" marker */ 99 std r11,-16(r9) /* "regshere" marker */
100#if defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR)
101BEGIN_FW_FTR_SECTION
102 beq 33f
103 /* if from user, see if there are any DTL entries to process */
104 ld r10,PACALPPACAPTR(r13) /* get ptr to VPA */
105 ld r11,PACA_DTL_RIDX(r13) /* get log read index */
106 ld r10,LPPACA_DTLIDX(r10) /* get log write index */
107 cmpd cr1,r11,r10
108 beq+ cr1,33f
109 bl .accumulate_stolen_time
110 REST_GPR(0,r1)
111 REST_4GPRS(3,r1)
112 REST_2GPRS(7,r1)
113 addi r9,r1,STACK_FRAME_OVERHEAD
11433:
115END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
116#endif /* CONFIG_VIRT_CPU_ACCOUNTING && CONFIG_PPC_SPLPAR */
117
100#ifdef CONFIG_TRACE_IRQFLAGS 118#ifdef CONFIG_TRACE_IRQFLAGS
101 bl .trace_hardirqs_on 119 bl .trace_hardirqs_on
102 REST_GPR(0,r1) 120 REST_GPR(0,r1)
@@ -202,7 +220,9 @@ syscall_exit:
202 bge- syscall_error 220 bge- syscall_error
203syscall_error_cont: 221syscall_error_cont:
204 ld r7,_NIP(r1) 222 ld r7,_NIP(r1)
223BEGIN_FTR_SECTION
205 stdcx. r0,0,r1 /* to clear the reservation */ 224 stdcx. r0,0,r1 /* to clear the reservation */
225END_FTR_SECTION_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
206 andi. r6,r8,MSR_PR 226 andi. r6,r8,MSR_PR
207 ld r4,_LINK(r1) 227 ld r4,_LINK(r1)
208 /* 228 /*
@@ -419,6 +439,17 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
419 sync 439 sync
420#endif /* CONFIG_SMP */ 440#endif /* CONFIG_SMP */
421 441
442 /*
443 * If we optimise away the clear of the reservation in system
444 * calls because we know the CPU tracks the address of the
445 * reservation, then we need to clear it here to cover the
446 * case that the kernel context switch path has no larx
447 * instructions.
448 */
449BEGIN_FTR_SECTION
450 ldarx r6,0,r1
451END_FTR_SECTION_IFSET(CPU_FTR_STCX_CHECKS_ADDRESS)
452
422 addi r6,r4,-THREAD /* Convert THREAD to 'current' */ 453 addi r6,r4,-THREAD /* Convert THREAD to 'current' */
423 std r6,PACACURRENT(r13) /* Set new 'current' */ 454 std r6,PACACURRENT(r13) /* Set new 'current' */
424 455
@@ -576,7 +607,16 @@ ALT_FW_FTR_SECTION_END_IFCLR(FW_FEATURE_ISERIES)
576 andi. r0,r3,MSR_RI 607 andi. r0,r3,MSR_RI
577 beq- unrecov_restore 608 beq- unrecov_restore
578 609
610 /*
611 * Clear the reservation. If we know the CPU tracks the address of
612 * the reservation then we can potentially save some cycles and use
613 * a larx. On POWER6 and POWER7 this is significantly faster.
614 */
615BEGIN_FTR_SECTION
579 stdcx. r0,0,r1 /* to clear the reservation */ 616 stdcx. r0,0,r1 /* to clear the reservation */
617FTR_SECTION_ELSE
618 ldarx r4,0,r1
619ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
580 620
581 /* 621 /*
582 * Clear RI before restoring r13. If we are returning to 622 * Clear RI before restoring r13. If we are returning to
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index f53029a01554..9f8b01d6466f 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -299,6 +299,12 @@ slb_miss_user_pseries:
299 b . /* prevent spec. execution */ 299 b . /* prevent spec. execution */
300#endif /* __DISABLED__ */ 300#endif /* __DISABLED__ */
301 301
302/* KVM's trampoline code needs to be close to the interrupt handlers */
303
304#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
305#include "../kvm/book3s_rmhandlers.S"
306#endif
307
302 .align 7 308 .align 7
303 .globl __end_interrupts 309 .globl __end_interrupts
304__end_interrupts: 310__end_interrupts:
@@ -818,12 +824,12 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
818 824
819 /* 825 /*
820 * hash_page couldn't handle it, set soft interrupt enable back 826 * hash_page couldn't handle it, set soft interrupt enable back
821 * to what it was before the trap. Note that .raw_local_irq_restore 827 * to what it was before the trap. Note that .arch_local_irq_restore
822 * handles any interrupts pending at this point. 828 * handles any interrupts pending at this point.
823 */ 829 */
824 ld r3,SOFTE(r1) 830 ld r3,SOFTE(r1)
825 TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f) 831 TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f)
826 bl .raw_local_irq_restore 832 bl .arch_local_irq_restore
827 b 11f 833 b 11f
828 834
829/* We have a data breakpoint exception - handle it */ 835/* We have a data breakpoint exception - handle it */
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index fc8f5b14019c..e86c040ae585 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -163,24 +163,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
163/* 163/*
164 * These are used in the alignment trap handler when emulating 164 * These are used in the alignment trap handler when emulating
165 * single-precision loads and stores. 165 * single-precision loads and stores.
166 * We restore and save the fpscr so the task gets the same result
167 * and exceptions as if the cpu had performed the load or store.
168 */ 166 */
169 167
170_GLOBAL(cvt_fd) 168_GLOBAL(cvt_fd)
171 lfd 0,THREAD_FPSCR(r5) /* load up fpscr value */
172 MTFSF_L(0)
173 lfs 0,0(r3) 169 lfs 0,0(r3)
174 stfd 0,0(r4) 170 stfd 0,0(r4)
175 mffs 0
176 stfd 0,THREAD_FPSCR(r5) /* save new fpscr value */
177 blr 171 blr
178 172
179_GLOBAL(cvt_df) 173_GLOBAL(cvt_df)
180 lfd 0,THREAD_FPSCR(r5) /* load up fpscr value */
181 MTFSF_L(0)
182 lfd 0,0(r3) 174 lfd 0,0(r3)
183 stfs 0,0(r4) 175 stfs 0,0(r4)
184 mffs 0
185 stfd 0,THREAD_FPSCR(r5) /* save new fpscr value */
186 blr 176 blr
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index a90625f9b485..8278e8bad5a0 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -923,11 +923,7 @@ initial_mmu:
923 mtspr SPRN_PID,r0 923 mtspr SPRN_PID,r0
924 sync 924 sync
925 925
926 /* Configure and load two entries into TLB slots 62 and 63. 926 /* Configure and load one entry into TLB slots 63 */
927 * In case we are pinning TLBs, these are reserved in by the
928 * other TLB functions. If not reserving, then it doesn't
929 * matter where they are loaded.
930 */
931 clrrwi r4,r4,10 /* Mask off the real page number */ 927 clrrwi r4,r4,10 /* Mask off the real page number */
932 ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */ 928 ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */
933 929
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index c571cd3c1453..f0dd577e4a5b 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -166,12 +166,6 @@ exception_marker:
166#include "exceptions-64s.S" 166#include "exceptions-64s.S"
167#endif 167#endif
168 168
169/* KVM trampoline code needs to be close to the interrupt handlers */
170
171#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
172#include "../kvm/book3s_rmhandlers.S"
173#endif
174
175_GLOBAL(generic_secondary_thread_init) 169_GLOBAL(generic_secondary_thread_init)
176 mr r24,r3 170 mr r24,r3
177 171
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 4faeba247854..529b817f473b 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -152,8 +152,11 @@ _ENTRY(__early_start)
152 /* Check to see if we're the second processor, and jump 152 /* Check to see if we're the second processor, and jump
153 * to the secondary_start code if so 153 * to the secondary_start code if so
154 */ 154 */
155 mfspr r24,SPRN_PIR 155 lis r24, boot_cpuid@h
156 cmpwi r24,0 156 ori r24, r24, boot_cpuid@l
157 lwz r24, 0(r24)
158 cmpwi r24, -1
159 mfspr r24,SPRN_PIR
157 bne __secondary_start 160 bne __secondary_start
158#endif 161#endif
159 162
@@ -175,6 +178,9 @@ _ENTRY(__early_start)
175 li r0,0 178 li r0,0
176 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1) 179 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
177 180
181 rlwinm r22,r1,0,0,31-THREAD_SHIFT /* current thread_info */
182 stw r24, TI_CPU(r22)
183
178 bl early_init 184 bl early_init
179 185
180#ifdef CONFIG_RELOCATABLE 186#ifdef CONFIG_RELOCATABLE
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 9b626cfffce1..f62efdfd1769 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -162,13 +162,10 @@ static int ibmebus_create_device(struct device_node *dn)
162 dev->dev.bus = &ibmebus_bus_type; 162 dev->dev.bus = &ibmebus_bus_type;
163 dev->dev.archdata.dma_ops = &ibmebus_dma_ops; 163 dev->dev.archdata.dma_ops = &ibmebus_dma_ops;
164 164
165 ret = of_device_register(dev); 165 ret = of_device_add(dev);
166 if (ret) { 166 if (ret)
167 of_device_free(dev); 167 platform_device_put(dev);
168 return ret; 168 return ret;
169 }
170
171 return 0;
172} 169}
173 170
174static int ibmebus_create_devices(const struct of_device_id *matches) 171static int ibmebus_create_devices(const struct of_device_id *matches)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 4a65386995d7..ce557f6f00fc 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -116,7 +116,7 @@ static inline notrace void set_soft_enabled(unsigned long enable)
116 : : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled))); 116 : : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled)));
117} 117}
118 118
119notrace void raw_local_irq_restore(unsigned long en) 119notrace void arch_local_irq_restore(unsigned long en)
120{ 120{
121 /* 121 /*
122 * get_paca()->soft_enabled = en; 122 * get_paca()->soft_enabled = en;
@@ -192,7 +192,7 @@ notrace void raw_local_irq_restore(unsigned long en)
192 192
193 __hard_irq_enable(); 193 __hard_irq_enable();
194} 194}
195EXPORT_SYMBOL(raw_local_irq_restore); 195EXPORT_SYMBOL(arch_local_irq_restore);
196#endif /* CONFIG_PPC64 */ 196#endif /* CONFIG_PPC64 */
197 197
198static int show_other_interrupts(struct seq_file *p, int prec) 198static int show_other_interrupts(struct seq_file *p, int prec)
@@ -587,8 +587,10 @@ struct irq_host *irq_alloc_host(struct device_node *of_node,
587 * this will be fixed once slab is made available early 587 * this will be fixed once slab is made available early
588 * instead of the current cruft 588 * instead of the current cruft
589 */ 589 */
590 if (mem_init_done) 590 if (mem_init_done) {
591 of_node_put(host->of_node);
591 kfree(host); 592 kfree(host);
593 }
592 return NULL; 594 return NULL;
593 } 595 }
594 irq_map[0].host = host; 596 irq_map[0].host = host;
@@ -1143,7 +1145,7 @@ static int virq_debug_show(struct seq_file *m, void *private)
1143 unsigned long flags; 1145 unsigned long flags;
1144 struct irq_desc *desc; 1146 struct irq_desc *desc;
1145 const char *p; 1147 const char *p;
1146 char none[] = "none"; 1148 static const char none[] = "none";
1147 int i; 1149 int i;
1148 1150
1149 seq_printf(m, "%-5s %-7s %-15s %s\n", "virq", "hwirq", 1151 seq_printf(m, "%-5s %-7s %-15s %s\n", "virq", "hwirq",
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
new file mode 100644
index 000000000000..428d0e538aec
--- /dev/null
+++ b/arch/powerpc/kernel/kvm.c
@@ -0,0 +1,596 @@
1/*
2 * Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved.
3 *
4 * Authors:
5 * Alexander Graf <agraf@suse.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2, as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include <linux/kvm_host.h>
22#include <linux/init.h>
23#include <linux/kvm_para.h>
24#include <linux/slab.h>
25#include <linux/of.h>
26
27#include <asm/reg.h>
28#include <asm/sections.h>
29#include <asm/cacheflush.h>
30#include <asm/disassemble.h>
31
32#define KVM_MAGIC_PAGE (-4096L)
33#define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x)
34
35#define KVM_INST_LWZ 0x80000000
36#define KVM_INST_STW 0x90000000
37#define KVM_INST_LD 0xe8000000
38#define KVM_INST_STD 0xf8000000
39#define KVM_INST_NOP 0x60000000
40#define KVM_INST_B 0x48000000
41#define KVM_INST_B_MASK 0x03ffffff
42#define KVM_INST_B_MAX 0x01ffffff
43
44#define KVM_MASK_RT 0x03e00000
45#define KVM_RT_30 0x03c00000
46#define KVM_MASK_RB 0x0000f800
47#define KVM_INST_MFMSR 0x7c0000a6
48#define KVM_INST_MFSPR_SPRG0 0x7c1042a6
49#define KVM_INST_MFSPR_SPRG1 0x7c1142a6
50#define KVM_INST_MFSPR_SPRG2 0x7c1242a6
51#define KVM_INST_MFSPR_SPRG3 0x7c1342a6
52#define KVM_INST_MFSPR_SRR0 0x7c1a02a6
53#define KVM_INST_MFSPR_SRR1 0x7c1b02a6
54#define KVM_INST_MFSPR_DAR 0x7c1302a6
55#define KVM_INST_MFSPR_DSISR 0x7c1202a6
56
57#define KVM_INST_MTSPR_SPRG0 0x7c1043a6
58#define KVM_INST_MTSPR_SPRG1 0x7c1143a6
59#define KVM_INST_MTSPR_SPRG2 0x7c1243a6
60#define KVM_INST_MTSPR_SPRG3 0x7c1343a6
61#define KVM_INST_MTSPR_SRR0 0x7c1a03a6
62#define KVM_INST_MTSPR_SRR1 0x7c1b03a6
63#define KVM_INST_MTSPR_DAR 0x7c1303a6
64#define KVM_INST_MTSPR_DSISR 0x7c1203a6
65
66#define KVM_INST_TLBSYNC 0x7c00046c
67#define KVM_INST_MTMSRD_L0 0x7c000164
68#define KVM_INST_MTMSRD_L1 0x7c010164
69#define KVM_INST_MTMSR 0x7c000124
70
71#define KVM_INST_WRTEEI_0 0x7c000146
72#define KVM_INST_WRTEEI_1 0x7c008146
73
74#define KVM_INST_MTSRIN 0x7c0001e4
75
76static bool kvm_patching_worked = true;
77static char kvm_tmp[1024 * 1024];
78static int kvm_tmp_index;
79
80static inline void kvm_patch_ins(u32 *inst, u32 new_inst)
81{
82 *inst = new_inst;
83 flush_icache_range((ulong)inst, (ulong)inst + 4);
84}
85
86static void kvm_patch_ins_ll(u32 *inst, long addr, u32 rt)
87{
88#ifdef CONFIG_64BIT
89 kvm_patch_ins(inst, KVM_INST_LD | rt | (addr & 0x0000fffc));
90#else
91 kvm_patch_ins(inst, KVM_INST_LWZ | rt | (addr & 0x0000fffc));
92#endif
93}
94
95static void kvm_patch_ins_ld(u32 *inst, long addr, u32 rt)
96{
97#ifdef CONFIG_64BIT
98 kvm_patch_ins(inst, KVM_INST_LD | rt | (addr & 0x0000fffc));
99#else
100 kvm_patch_ins(inst, KVM_INST_LWZ | rt | ((addr + 4) & 0x0000fffc));
101#endif
102}
103
104static void kvm_patch_ins_lwz(u32 *inst, long addr, u32 rt)
105{
106 kvm_patch_ins(inst, KVM_INST_LWZ | rt | (addr & 0x0000ffff));
107}
108
109static void kvm_patch_ins_std(u32 *inst, long addr, u32 rt)
110{
111#ifdef CONFIG_64BIT
112 kvm_patch_ins(inst, KVM_INST_STD | rt | (addr & 0x0000fffc));
113#else
114 kvm_patch_ins(inst, KVM_INST_STW | rt | ((addr + 4) & 0x0000fffc));
115#endif
116}
117
118static void kvm_patch_ins_stw(u32 *inst, long addr, u32 rt)
119{
120 kvm_patch_ins(inst, KVM_INST_STW | rt | (addr & 0x0000fffc));
121}
122
123static void kvm_patch_ins_nop(u32 *inst)
124{
125 kvm_patch_ins(inst, KVM_INST_NOP);
126}
127
128static void kvm_patch_ins_b(u32 *inst, int addr)
129{
130#ifdef CONFIG_RELOCATABLE
131 /* On relocatable kernels interrupts handlers and our code
132 can be in different regions, so we don't patch them */
133
134 extern u32 __end_interrupts;
135 if ((ulong)inst < (ulong)&__end_interrupts)
136 return;
137#endif
138
139 kvm_patch_ins(inst, KVM_INST_B | (addr & KVM_INST_B_MASK));
140}
141
142static u32 *kvm_alloc(int len)
143{
144 u32 *p;
145
146 if ((kvm_tmp_index + len) > ARRAY_SIZE(kvm_tmp)) {
147 printk(KERN_ERR "KVM: No more space (%d + %d)\n",
148 kvm_tmp_index, len);
149 kvm_patching_worked = false;
150 return NULL;
151 }
152
153 p = (void*)&kvm_tmp[kvm_tmp_index];
154 kvm_tmp_index += len;
155
156 return p;
157}
158
159extern u32 kvm_emulate_mtmsrd_branch_offs;
160extern u32 kvm_emulate_mtmsrd_reg_offs;
161extern u32 kvm_emulate_mtmsrd_orig_ins_offs;
162extern u32 kvm_emulate_mtmsrd_len;
163extern u32 kvm_emulate_mtmsrd[];
164
165static void kvm_patch_ins_mtmsrd(u32 *inst, u32 rt)
166{
167 u32 *p;
168 int distance_start;
169 int distance_end;
170 ulong next_inst;
171
172 p = kvm_alloc(kvm_emulate_mtmsrd_len * 4);
173 if (!p)
174 return;
175
176 /* Find out where we are and put everything there */
177 distance_start = (ulong)p - (ulong)inst;
178 next_inst = ((ulong)inst + 4);
179 distance_end = next_inst - (ulong)&p[kvm_emulate_mtmsrd_branch_offs];
180
181 /* Make sure we only write valid b instructions */
182 if (distance_start > KVM_INST_B_MAX) {
183 kvm_patching_worked = false;
184 return;
185 }
186
187 /* Modify the chunk to fit the invocation */
188 memcpy(p, kvm_emulate_mtmsrd, kvm_emulate_mtmsrd_len * 4);
189 p[kvm_emulate_mtmsrd_branch_offs] |= distance_end & KVM_INST_B_MASK;
190 switch (get_rt(rt)) {
191 case 30:
192 kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
193 magic_var(scratch2), KVM_RT_30);
194 break;
195 case 31:
196 kvm_patch_ins_ll(&p[kvm_emulate_mtmsrd_reg_offs],
197 magic_var(scratch1), KVM_RT_30);
198 break;
199 default:
200 p[kvm_emulate_mtmsrd_reg_offs] |= rt;
201 break;
202 }
203
204 p[kvm_emulate_mtmsrd_orig_ins_offs] = *inst;
205 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsrd_len * 4);
206
207 /* Patch the invocation */
208 kvm_patch_ins_b(inst, distance_start);
209}
210
211extern u32 kvm_emulate_mtmsr_branch_offs;
212extern u32 kvm_emulate_mtmsr_reg1_offs;
213extern u32 kvm_emulate_mtmsr_reg2_offs;
214extern u32 kvm_emulate_mtmsr_orig_ins_offs;
215extern u32 kvm_emulate_mtmsr_len;
216extern u32 kvm_emulate_mtmsr[];
217
218static void kvm_patch_ins_mtmsr(u32 *inst, u32 rt)
219{
220 u32 *p;
221 int distance_start;
222 int distance_end;
223 ulong next_inst;
224
225 p = kvm_alloc(kvm_emulate_mtmsr_len * 4);
226 if (!p)
227 return;
228
229 /* Find out where we are and put everything there */
230 distance_start = (ulong)p - (ulong)inst;
231 next_inst = ((ulong)inst + 4);
232 distance_end = next_inst - (ulong)&p[kvm_emulate_mtmsr_branch_offs];
233
234 /* Make sure we only write valid b instructions */
235 if (distance_start > KVM_INST_B_MAX) {
236 kvm_patching_worked = false;
237 return;
238 }
239
240 /* Modify the chunk to fit the invocation */
241 memcpy(p, kvm_emulate_mtmsr, kvm_emulate_mtmsr_len * 4);
242 p[kvm_emulate_mtmsr_branch_offs] |= distance_end & KVM_INST_B_MASK;
243
244 /* Make clobbered registers work too */
245 switch (get_rt(rt)) {
246 case 30:
247 kvm_patch_ins_ll(&p[kvm_emulate_mtmsr_reg1_offs],
248 magic_var(scratch2), KVM_RT_30);
249 kvm_patch_ins_ll(&p[kvm_emulate_mtmsr_reg2_offs],
250 magic_var(scratch2), KVM_RT_30);
251 break;
252 case 31:
253 kvm_patch_ins_ll(&p[kvm_emulate_mtmsr_reg1_offs],
254 magic_var(scratch1), KVM_RT_30);
255 kvm_patch_ins_ll(&p[kvm_emulate_mtmsr_reg2_offs],
256 magic_var(scratch1), KVM_RT_30);
257 break;
258 default:
259 p[kvm_emulate_mtmsr_reg1_offs] |= rt;
260 p[kvm_emulate_mtmsr_reg2_offs] |= rt;
261 break;
262 }
263
264 p[kvm_emulate_mtmsr_orig_ins_offs] = *inst;
265 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtmsr_len * 4);
266
267 /* Patch the invocation */
268 kvm_patch_ins_b(inst, distance_start);
269}
270
271#ifdef CONFIG_BOOKE
272
273extern u32 kvm_emulate_wrteei_branch_offs;
274extern u32 kvm_emulate_wrteei_ee_offs;
275extern u32 kvm_emulate_wrteei_len;
276extern u32 kvm_emulate_wrteei[];
277
278static void kvm_patch_ins_wrteei(u32 *inst)
279{
280 u32 *p;
281 int distance_start;
282 int distance_end;
283 ulong next_inst;
284
285 p = kvm_alloc(kvm_emulate_wrteei_len * 4);
286 if (!p)
287 return;
288
289 /* Find out where we are and put everything there */
290 distance_start = (ulong)p - (ulong)inst;
291 next_inst = ((ulong)inst + 4);
292 distance_end = next_inst - (ulong)&p[kvm_emulate_wrteei_branch_offs];
293
294 /* Make sure we only write valid b instructions */
295 if (distance_start > KVM_INST_B_MAX) {
296 kvm_patching_worked = false;
297 return;
298 }
299
300 /* Modify the chunk to fit the invocation */
301 memcpy(p, kvm_emulate_wrteei, kvm_emulate_wrteei_len * 4);
302 p[kvm_emulate_wrteei_branch_offs] |= distance_end & KVM_INST_B_MASK;
303 p[kvm_emulate_wrteei_ee_offs] |= (*inst & MSR_EE);
304 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_wrteei_len * 4);
305
306 /* Patch the invocation */
307 kvm_patch_ins_b(inst, distance_start);
308}
309
310#endif
311
312#ifdef CONFIG_PPC_BOOK3S_32
313
314extern u32 kvm_emulate_mtsrin_branch_offs;
315extern u32 kvm_emulate_mtsrin_reg1_offs;
316extern u32 kvm_emulate_mtsrin_reg2_offs;
317extern u32 kvm_emulate_mtsrin_orig_ins_offs;
318extern u32 kvm_emulate_mtsrin_len;
319extern u32 kvm_emulate_mtsrin[];
320
321static void kvm_patch_ins_mtsrin(u32 *inst, u32 rt, u32 rb)
322{
323 u32 *p;
324 int distance_start;
325 int distance_end;
326 ulong next_inst;
327
328 p = kvm_alloc(kvm_emulate_mtsrin_len * 4);
329 if (!p)
330 return;
331
332 /* Find out where we are and put everything there */
333 distance_start = (ulong)p - (ulong)inst;
334 next_inst = ((ulong)inst + 4);
335 distance_end = next_inst - (ulong)&p[kvm_emulate_mtsrin_branch_offs];
336
337 /* Make sure we only write valid b instructions */
338 if (distance_start > KVM_INST_B_MAX) {
339 kvm_patching_worked = false;
340 return;
341 }
342
343 /* Modify the chunk to fit the invocation */
344 memcpy(p, kvm_emulate_mtsrin, kvm_emulate_mtsrin_len * 4);
345 p[kvm_emulate_mtsrin_branch_offs] |= distance_end & KVM_INST_B_MASK;
346 p[kvm_emulate_mtsrin_reg1_offs] |= (rb << 10);
347 p[kvm_emulate_mtsrin_reg2_offs] |= rt;
348 p[kvm_emulate_mtsrin_orig_ins_offs] = *inst;
349 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_mtsrin_len * 4);
350
351 /* Patch the invocation */
352 kvm_patch_ins_b(inst, distance_start);
353}
354
355#endif
356
357static void kvm_map_magic_page(void *data)
358{
359 u32 *features = data;
360
361 ulong in[8];
362 ulong out[8];
363
364 in[0] = KVM_MAGIC_PAGE;
365 in[1] = KVM_MAGIC_PAGE;
366
367 kvm_hypercall(in, out, HC_VENDOR_KVM | KVM_HC_PPC_MAP_MAGIC_PAGE);
368
369 *features = out[0];
370}
371
372static void kvm_check_ins(u32 *inst, u32 features)
373{
374 u32 _inst = *inst;
375 u32 inst_no_rt = _inst & ~KVM_MASK_RT;
376 u32 inst_rt = _inst & KVM_MASK_RT;
377
378 switch (inst_no_rt) {
379 /* Loads */
380 case KVM_INST_MFMSR:
381 kvm_patch_ins_ld(inst, magic_var(msr), inst_rt);
382 break;
383 case KVM_INST_MFSPR_SPRG0:
384 kvm_patch_ins_ld(inst, magic_var(sprg0), inst_rt);
385 break;
386 case KVM_INST_MFSPR_SPRG1:
387 kvm_patch_ins_ld(inst, magic_var(sprg1), inst_rt);
388 break;
389 case KVM_INST_MFSPR_SPRG2:
390 kvm_patch_ins_ld(inst, magic_var(sprg2), inst_rt);
391 break;
392 case KVM_INST_MFSPR_SPRG3:
393 kvm_patch_ins_ld(inst, magic_var(sprg3), inst_rt);
394 break;
395 case KVM_INST_MFSPR_SRR0:
396 kvm_patch_ins_ld(inst, magic_var(srr0), inst_rt);
397 break;
398 case KVM_INST_MFSPR_SRR1:
399 kvm_patch_ins_ld(inst, magic_var(srr1), inst_rt);
400 break;
401 case KVM_INST_MFSPR_DAR:
402 kvm_patch_ins_ld(inst, magic_var(dar), inst_rt);
403 break;
404 case KVM_INST_MFSPR_DSISR:
405 kvm_patch_ins_lwz(inst, magic_var(dsisr), inst_rt);
406 break;
407
408 /* Stores */
409 case KVM_INST_MTSPR_SPRG0:
410 kvm_patch_ins_std(inst, magic_var(sprg0), inst_rt);
411 break;
412 case KVM_INST_MTSPR_SPRG1:
413 kvm_patch_ins_std(inst, magic_var(sprg1), inst_rt);
414 break;
415 case KVM_INST_MTSPR_SPRG2:
416 kvm_patch_ins_std(inst, magic_var(sprg2), inst_rt);
417 break;
418 case KVM_INST_MTSPR_SPRG3:
419 kvm_patch_ins_std(inst, magic_var(sprg3), inst_rt);
420 break;
421 case KVM_INST_MTSPR_SRR0:
422 kvm_patch_ins_std(inst, magic_var(srr0), inst_rt);
423 break;
424 case KVM_INST_MTSPR_SRR1:
425 kvm_patch_ins_std(inst, magic_var(srr1), inst_rt);
426 break;
427 case KVM_INST_MTSPR_DAR:
428 kvm_patch_ins_std(inst, magic_var(dar), inst_rt);
429 break;
430 case KVM_INST_MTSPR_DSISR:
431 kvm_patch_ins_stw(inst, magic_var(dsisr), inst_rt);
432 break;
433
434 /* Nops */
435 case KVM_INST_TLBSYNC:
436 kvm_patch_ins_nop(inst);
437 break;
438
439 /* Rewrites */
440 case KVM_INST_MTMSRD_L1:
441 kvm_patch_ins_mtmsrd(inst, inst_rt);
442 break;
443 case KVM_INST_MTMSR:
444 case KVM_INST_MTMSRD_L0:
445 kvm_patch_ins_mtmsr(inst, inst_rt);
446 break;
447 }
448
449 switch (inst_no_rt & ~KVM_MASK_RB) {
450#ifdef CONFIG_PPC_BOOK3S_32
451 case KVM_INST_MTSRIN:
452 if (features & KVM_MAGIC_FEAT_SR) {
453 u32 inst_rb = _inst & KVM_MASK_RB;
454 kvm_patch_ins_mtsrin(inst, inst_rt, inst_rb);
455 }
456 break;
457 break;
458#endif
459 }
460
461 switch (_inst) {
462#ifdef CONFIG_BOOKE
463 case KVM_INST_WRTEEI_0:
464 case KVM_INST_WRTEEI_1:
465 kvm_patch_ins_wrteei(inst);
466 break;
467#endif
468 }
469}
470
471static void kvm_use_magic_page(void)
472{
473 u32 *p;
474 u32 *start, *end;
475 u32 tmp;
476 u32 features;
477
478 /* Tell the host to map the magic page to -4096 on all CPUs */
479 on_each_cpu(kvm_map_magic_page, &features, 1);
480
481 /* Quick self-test to see if the mapping works */
482 if (__get_user(tmp, (u32*)KVM_MAGIC_PAGE)) {
483 kvm_patching_worked = false;
484 return;
485 }
486
487 /* Now loop through all code and find instructions */
488 start = (void*)_stext;
489 end = (void*)_etext;
490
491 for (p = start; p < end; p++)
492 kvm_check_ins(p, features);
493
494 printk(KERN_INFO "KVM: Live patching for a fast VM %s\n",
495 kvm_patching_worked ? "worked" : "failed");
496}
497
498unsigned long kvm_hypercall(unsigned long *in,
499 unsigned long *out,
500 unsigned long nr)
501{
502 unsigned long register r0 asm("r0");
503 unsigned long register r3 asm("r3") = in[0];
504 unsigned long register r4 asm("r4") = in[1];
505 unsigned long register r5 asm("r5") = in[2];
506 unsigned long register r6 asm("r6") = in[3];
507 unsigned long register r7 asm("r7") = in[4];
508 unsigned long register r8 asm("r8") = in[5];
509 unsigned long register r9 asm("r9") = in[6];
510 unsigned long register r10 asm("r10") = in[7];
511 unsigned long register r11 asm("r11") = nr;
512 unsigned long register r12 asm("r12");
513
514 asm volatile("bl kvm_hypercall_start"
515 : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6),
516 "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11),
517 "=r"(r12)
518 : "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7), "r"(r8),
519 "r"(r9), "r"(r10), "r"(r11)
520 : "memory", "cc", "xer", "ctr", "lr");
521
522 out[0] = r4;
523 out[1] = r5;
524 out[2] = r6;
525 out[3] = r7;
526 out[4] = r8;
527 out[5] = r9;
528 out[6] = r10;
529 out[7] = r11;
530
531 return r3;
532}
533EXPORT_SYMBOL_GPL(kvm_hypercall);
534
535static int kvm_para_setup(void)
536{
537 extern u32 kvm_hypercall_start;
538 struct device_node *hyper_node;
539 u32 *insts;
540 int len, i;
541
542 hyper_node = of_find_node_by_path("/hypervisor");
543 if (!hyper_node)
544 return -1;
545
546 insts = (u32*)of_get_property(hyper_node, "hcall-instructions", &len);
547 if (len % 4)
548 return -1;
549 if (len > (4 * 4))
550 return -1;
551
552 for (i = 0; i < (len / 4); i++)
553 kvm_patch_ins(&(&kvm_hypercall_start)[i], insts[i]);
554
555 return 0;
556}
557
558static __init void kvm_free_tmp(void)
559{
560 unsigned long start, end;
561
562 start = (ulong)&kvm_tmp[kvm_tmp_index + (PAGE_SIZE - 1)] & PAGE_MASK;
563 end = (ulong)&kvm_tmp[ARRAY_SIZE(kvm_tmp)] & PAGE_MASK;
564
565 /* Free the tmp space we don't need */
566 for (; start < end; start += PAGE_SIZE) {
567 ClearPageReserved(virt_to_page(start));
568 init_page_count(virt_to_page(start));
569 free_page(start);
570 totalram_pages++;
571 }
572}
573
574static int __init kvm_guest_init(void)
575{
576 if (!kvm_para_available())
577 goto free_tmp;
578
579 if (kvm_para_setup())
580 goto free_tmp;
581
582 if (kvm_para_has_feature(KVM_FEATURE_MAGIC_PAGE))
583 kvm_use_magic_page();
584
585#ifdef CONFIG_PPC_BOOK3S_64
586 /* Enable napping */
587 powersave_nap = 1;
588#endif
589
590free_tmp:
591 kvm_free_tmp();
592
593 return 0;
594}
595
596postcore_initcall(kvm_guest_init);
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
new file mode 100644
index 000000000000..f2b1b2523e61
--- /dev/null
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -0,0 +1,302 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 * Copyright SUSE Linux Products GmbH 2010
16 *
17 * Authors: Alexander Graf <agraf@suse.de>
18 */
19
20#include <asm/ppc_asm.h>
21#include <asm/kvm_asm.h>
22#include <asm/reg.h>
23#include <asm/page.h>
24#include <asm/asm-offsets.h>
25
26/* Hypercall entry point. Will be patched with device tree instructions. */
27
28.global kvm_hypercall_start
29kvm_hypercall_start:
30 li r3, -1
31 nop
32 nop
33 nop
34 blr
35
36#define KVM_MAGIC_PAGE (-4096)
37
38#ifdef CONFIG_64BIT
39#define LL64(reg, offs, reg2) ld reg, (offs)(reg2)
40#define STL64(reg, offs, reg2) std reg, (offs)(reg2)
41#else
42#define LL64(reg, offs, reg2) lwz reg, (offs + 4)(reg2)
43#define STL64(reg, offs, reg2) stw reg, (offs + 4)(reg2)
44#endif
45
46#define SCRATCH_SAVE \
47 /* Enable critical section. We are critical if \
48 shared->critical == r1 */ \
49 STL64(r1, KVM_MAGIC_PAGE + KVM_MAGIC_CRITICAL, 0); \
50 \
51 /* Save state */ \
52 PPC_STL r31, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH1)(0); \
53 PPC_STL r30, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH2)(0); \
54 mfcr r31; \
55 stw r31, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH3)(0);
56
57#define SCRATCH_RESTORE \
58 /* Restore state */ \
59 PPC_LL r31, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH1)(0); \
60 lwz r30, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH3)(0); \
61 mtcr r30; \
62 PPC_LL r30, (KVM_MAGIC_PAGE + KVM_MAGIC_SCRATCH2)(0); \
63 \
64 /* Disable critical section. We are critical if \
65 shared->critical == r1 and r2 is always != r1 */ \
66 STL64(r2, KVM_MAGIC_PAGE + KVM_MAGIC_CRITICAL, 0);
67
68.global kvm_emulate_mtmsrd
69kvm_emulate_mtmsrd:
70
71 SCRATCH_SAVE
72
73 /* Put MSR & ~(MSR_EE|MSR_RI) in r31 */
74 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
75 lis r30, (~(MSR_EE | MSR_RI))@h
76 ori r30, r30, (~(MSR_EE | MSR_RI))@l
77 and r31, r31, r30
78
79 /* OR the register's (MSR_EE|MSR_RI) on MSR */
80kvm_emulate_mtmsrd_reg:
81 ori r30, r0, 0
82 andi. r30, r30, (MSR_EE|MSR_RI)
83 or r31, r31, r30
84
85 /* Put MSR back into magic page */
86 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
87
88 /* Check if we have to fetch an interrupt */
89 lwz r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
90 cmpwi r31, 0
91 beq+ no_check
92
93 /* Check if we may trigger an interrupt */
94 andi. r30, r30, MSR_EE
95 beq no_check
96
97 SCRATCH_RESTORE
98
99 /* Nag hypervisor */
100kvm_emulate_mtmsrd_orig_ins:
101 tlbsync
102
103 b kvm_emulate_mtmsrd_branch
104
105no_check:
106
107 SCRATCH_RESTORE
108
109 /* Go back to caller */
110kvm_emulate_mtmsrd_branch:
111 b .
112kvm_emulate_mtmsrd_end:
113
114.global kvm_emulate_mtmsrd_branch_offs
115kvm_emulate_mtmsrd_branch_offs:
116 .long (kvm_emulate_mtmsrd_branch - kvm_emulate_mtmsrd) / 4
117
118.global kvm_emulate_mtmsrd_reg_offs
119kvm_emulate_mtmsrd_reg_offs:
120 .long (kvm_emulate_mtmsrd_reg - kvm_emulate_mtmsrd) / 4
121
122.global kvm_emulate_mtmsrd_orig_ins_offs
123kvm_emulate_mtmsrd_orig_ins_offs:
124 .long (kvm_emulate_mtmsrd_orig_ins - kvm_emulate_mtmsrd) / 4
125
126.global kvm_emulate_mtmsrd_len
127kvm_emulate_mtmsrd_len:
128 .long (kvm_emulate_mtmsrd_end - kvm_emulate_mtmsrd) / 4
129
130
131#define MSR_SAFE_BITS (MSR_EE | MSR_CE | MSR_ME | MSR_RI)
132#define MSR_CRITICAL_BITS ~MSR_SAFE_BITS
133
134.global kvm_emulate_mtmsr
135kvm_emulate_mtmsr:
136
137 SCRATCH_SAVE
138
139 /* Fetch old MSR in r31 */
140 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
141
142 /* Find the changed bits between old and new MSR */
143kvm_emulate_mtmsr_reg1:
144 ori r30, r0, 0
145 xor r31, r30, r31
146
147 /* Check if we need to really do mtmsr */
148 LOAD_REG_IMMEDIATE(r30, MSR_CRITICAL_BITS)
149 and. r31, r31, r30
150
151 /* No critical bits changed? Maybe we can stay in the guest. */
152 beq maybe_stay_in_guest
153
154do_mtmsr:
155
156 SCRATCH_RESTORE
157
158 /* Just fire off the mtmsr if it's critical */
159kvm_emulate_mtmsr_orig_ins:
160 mtmsr r0
161
162 b kvm_emulate_mtmsr_branch
163
164maybe_stay_in_guest:
165
166 /* Get the target register in r30 */
167kvm_emulate_mtmsr_reg2:
168 ori r30, r0, 0
169
170 /* Check if we have to fetch an interrupt */
171 lwz r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
172 cmpwi r31, 0
173 beq+ no_mtmsr
174
175 /* Check if we may trigger an interrupt */
176 andi. r31, r30, MSR_EE
177 beq no_mtmsr
178
179 b do_mtmsr
180
181no_mtmsr:
182
183 /* Put MSR into magic page because we don't call mtmsr */
184 STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
185
186 SCRATCH_RESTORE
187
188 /* Go back to caller */
189kvm_emulate_mtmsr_branch:
190 b .
191kvm_emulate_mtmsr_end:
192
193.global kvm_emulate_mtmsr_branch_offs
194kvm_emulate_mtmsr_branch_offs:
195 .long (kvm_emulate_mtmsr_branch - kvm_emulate_mtmsr) / 4
196
197.global kvm_emulate_mtmsr_reg1_offs
198kvm_emulate_mtmsr_reg1_offs:
199 .long (kvm_emulate_mtmsr_reg1 - kvm_emulate_mtmsr) / 4
200
201.global kvm_emulate_mtmsr_reg2_offs
202kvm_emulate_mtmsr_reg2_offs:
203 .long (kvm_emulate_mtmsr_reg2 - kvm_emulate_mtmsr) / 4
204
205.global kvm_emulate_mtmsr_orig_ins_offs
206kvm_emulate_mtmsr_orig_ins_offs:
207 .long (kvm_emulate_mtmsr_orig_ins - kvm_emulate_mtmsr) / 4
208
209.global kvm_emulate_mtmsr_len
210kvm_emulate_mtmsr_len:
211 .long (kvm_emulate_mtmsr_end - kvm_emulate_mtmsr) / 4
212
213
214
215.global kvm_emulate_wrteei
216kvm_emulate_wrteei:
217
218 SCRATCH_SAVE
219
220 /* Fetch old MSR in r31 */
221 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
222
223 /* Remove MSR_EE from old MSR */
224 li r30, 0
225 ori r30, r30, MSR_EE
226 andc r31, r31, r30
227
228 /* OR new MSR_EE onto the old MSR */
229kvm_emulate_wrteei_ee:
230 ori r31, r31, 0
231
232 /* Write new MSR value back */
233 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
234
235 SCRATCH_RESTORE
236
237 /* Go back to caller */
238kvm_emulate_wrteei_branch:
239 b .
240kvm_emulate_wrteei_end:
241
242.global kvm_emulate_wrteei_branch_offs
243kvm_emulate_wrteei_branch_offs:
244 .long (kvm_emulate_wrteei_branch - kvm_emulate_wrteei) / 4
245
246.global kvm_emulate_wrteei_ee_offs
247kvm_emulate_wrteei_ee_offs:
248 .long (kvm_emulate_wrteei_ee - kvm_emulate_wrteei) / 4
249
250.global kvm_emulate_wrteei_len
251kvm_emulate_wrteei_len:
252 .long (kvm_emulate_wrteei_end - kvm_emulate_wrteei) / 4
253
254
255.global kvm_emulate_mtsrin
256kvm_emulate_mtsrin:
257
258 SCRATCH_SAVE
259
260 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
261 andi. r31, r31, MSR_DR | MSR_IR
262 beq kvm_emulate_mtsrin_reg1
263
264 SCRATCH_RESTORE
265
266kvm_emulate_mtsrin_orig_ins:
267 nop
268 b kvm_emulate_mtsrin_branch
269
270kvm_emulate_mtsrin_reg1:
271 /* rX >> 26 */
272 rlwinm r30,r0,6,26,29
273
274kvm_emulate_mtsrin_reg2:
275 stw r0, (KVM_MAGIC_PAGE + KVM_MAGIC_SR)(r30)
276
277 SCRATCH_RESTORE
278
279 /* Go back to caller */
280kvm_emulate_mtsrin_branch:
281 b .
282kvm_emulate_mtsrin_end:
283
284.global kvm_emulate_mtsrin_branch_offs
285kvm_emulate_mtsrin_branch_offs:
286 .long (kvm_emulate_mtsrin_branch - kvm_emulate_mtsrin) / 4
287
288.global kvm_emulate_mtsrin_reg1_offs
289kvm_emulate_mtsrin_reg1_offs:
290 .long (kvm_emulate_mtsrin_reg1 - kvm_emulate_mtsrin) / 4
291
292.global kvm_emulate_mtsrin_reg2_offs
293kvm_emulate_mtsrin_reg2_offs:
294 .long (kvm_emulate_mtsrin_reg2 - kvm_emulate_mtsrin) / 4
295
296.global kvm_emulate_mtsrin_orig_ins_offs
297kvm_emulate_mtsrin_orig_ins_offs:
298 .long (kvm_emulate_mtsrin_orig_ins - kvm_emulate_mtsrin) / 4
299
300.global kvm_emulate_mtsrin_len
301kvm_emulate_mtsrin_len:
302 .long (kvm_emulate_mtsrin_end - kvm_emulate_mtsrin) / 4
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index c1fd0f9658fd..c834757bebc0 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
52 phys_addr_t taddr, unsigned long irq, 52 phys_addr_t taddr, unsigned long irq,
53 upf_t flags, int irq_check_parent) 53 upf_t flags, int irq_check_parent)
54{ 54{
55 const u32 *clk, *spd; 55 const __be32 *clk, *spd;
56 u32 clock = BASE_BAUD * 16; 56 u32 clock = BASE_BAUD * 16;
57 int index; 57 int index;
58 58
59 /* get clock freq. if present */ 59 /* get clock freq. if present */
60 clk = of_get_property(np, "clock-frequency", NULL); 60 clk = of_get_property(np, "clock-frequency", NULL);
61 if (clk && *clk) 61 if (clk && *clk)
62 clock = *clk; 62 clock = be32_to_cpup(clk);
63 63
64 /* get default speed if present */ 64 /* get default speed if present */
65 spd = of_get_property(np, "current-speed", NULL); 65 spd = of_get_property(np, "current-speed", NULL);
@@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
109 legacy_serial_infos[index].taddr = taddr; 109 legacy_serial_infos[index].taddr = taddr;
110 legacy_serial_infos[index].np = of_node_get(np); 110 legacy_serial_infos[index].np = of_node_get(np);
111 legacy_serial_infos[index].clock = clock; 111 legacy_serial_infos[index].clock = clock;
112 legacy_serial_infos[index].speed = spd ? *spd : 0; 112 legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
113 legacy_serial_infos[index].irq_check_parent = irq_check_parent; 113 legacy_serial_infos[index].irq_check_parent = irq_check_parent;
114 114
115 printk(KERN_DEBUG "Found legacy serial port %d for %s\n", 115 printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
@@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
168static int __init add_legacy_isa_port(struct device_node *np, 168static int __init add_legacy_isa_port(struct device_node *np,
169 struct device_node *isa_brg) 169 struct device_node *isa_brg)
170{ 170{
171 const u32 *reg; 171 const __be32 *reg;
172 const char *typep; 172 const char *typep;
173 int index = -1; 173 int index = -1;
174 u64 taddr; 174 u64 taddr;
@@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
181 return -1; 181 return -1;
182 182
183 /* Verify it's an IO port, we don't support anything else */ 183 /* Verify it's an IO port, we don't support anything else */
184 if (!(reg[0] & 0x00000001)) 184 if (!(be32_to_cpu(reg[0]) & 0x00000001))
185 return -1; 185 return -1;
186 186
187 /* Now look for an "ibm,aix-loc" property that gives us ordering 187 /* Now look for an "ibm,aix-loc" property that gives us ordering
@@ -202,7 +202,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
202 taddr = 0; 202 taddr = 0;
203 203
204 /* Add port, irq will be dealt with later */ 204 /* Add port, irq will be dealt with later */
205 return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, 205 return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
206 NO_IRQ, UPF_BOOT_AUTOCONF, 0); 206 NO_IRQ, UPF_BOOT_AUTOCONF, 0);
207 207
208} 208}
@@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
251 * we get to their "reg" property 251 * we get to their "reg" property
252 */ 252 */
253 if (np != pci_dev) { 253 if (np != pci_dev) {
254 const u32 *reg = of_get_property(np, "reg", NULL); 254 const __be32 *reg = of_get_property(np, "reg", NULL);
255 if (reg && (*reg < 4)) 255 if (reg && (be32_to_cpup(reg) < 4))
256 index = lindex = *reg; 256 index = lindex = be32_to_cpup(reg);
257 } 257 }
258 258
259 /* Local index means it's the Nth port in the PCI chip. Unfortunately 259 /* Local index means it's the Nth port in the PCI chip. Unfortunately
@@ -507,7 +507,7 @@ static int __init check_legacy_serial_console(void)
507 struct device_node *prom_stdout = NULL; 507 struct device_node *prom_stdout = NULL;
508 int i, speed = 0, offset = 0; 508 int i, speed = 0, offset = 0;
509 const char *name; 509 const char *name;
510 const u32 *spd; 510 const __be32 *spd;
511 511
512 DBG(" -> check_legacy_serial_console()\n"); 512 DBG(" -> check_legacy_serial_console()\n");
513 513
@@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
547 } 547 }
548 spd = of_get_property(prom_stdout, "current-speed", NULL); 548 spd = of_get_property(prom_stdout, "current-speed", NULL);
549 if (spd) 549 if (spd)
550 speed = *spd; 550 speed = be32_to_cpup(spd);
551 551
552 if (strcmp(name, "serial") != 0) 552 if (strcmp(name, "serial") != 0)
553 goto not_found; 553 goto not_found;
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 50362b6ef6e9..16468362ad57 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -56,7 +56,7 @@ static unsigned long get_purr(void)
56 56
57 for_each_possible_cpu(cpu) { 57 for_each_possible_cpu(cpu) {
58 if (firmware_has_feature(FW_FEATURE_ISERIES)) 58 if (firmware_has_feature(FW_FEATURE_ISERIES))
59 sum_purr += lppaca[cpu].emulated_time_base; 59 sum_purr += lppaca_of(cpu).emulated_time_base;
60 else { 60 else {
61 struct cpu_usage *cu; 61 struct cpu_usage *cu;
62 62
@@ -263,7 +263,7 @@ static void parse_ppp_data(struct seq_file *m)
263 ppp_data.active_system_procs); 263 ppp_data.active_system_procs);
264 264
265 /* pool related entries are apropriate for shared configs */ 265 /* pool related entries are apropriate for shared configs */
266 if (lppaca[0].shared_proc) { 266 if (lppaca_of(0).shared_proc) {
267 unsigned long pool_idle_time, pool_procs; 267 unsigned long pool_idle_time, pool_procs;
268 268
269 seq_printf(m, "pool=%d\n", ppp_data.pool_num); 269 seq_printf(m, "pool=%d\n", ppp_data.pool_num);
@@ -460,8 +460,8 @@ static void pseries_cmo_data(struct seq_file *m)
460 return; 460 return;
461 461
462 for_each_possible_cpu(cpu) { 462 for_each_possible_cpu(cpu) {
463 cmo_faults += lppaca[cpu].cmo_faults; 463 cmo_faults += lppaca_of(cpu).cmo_faults;
464 cmo_fault_time += lppaca[cpu].cmo_fault_time; 464 cmo_fault_time += lppaca_of(cpu).cmo_fault_time;
465 } 465 }
466 466
467 seq_printf(m, "cmo_faults=%lu\n", cmo_faults); 467 seq_printf(m, "cmo_faults=%lu\n", cmo_faults);
@@ -479,8 +479,8 @@ static void splpar_dispatch_data(struct seq_file *m)
479 unsigned long dispatch_dispersions = 0; 479 unsigned long dispatch_dispersions = 0;
480 480
481 for_each_possible_cpu(cpu) { 481 for_each_possible_cpu(cpu) {
482 dispatches += lppaca[cpu].yield_count; 482 dispatches += lppaca_of(cpu).yield_count;
483 dispatch_dispersions += lppaca[cpu].dispersion_count; 483 dispatch_dispersions += lppaca_of(cpu).dispersion_count;
484 } 484 }
485 485
486 seq_printf(m, "dispatches=%lu\n", dispatches); 486 seq_printf(m, "dispatches=%lu\n", dispatches);
@@ -545,7 +545,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
545 seq_printf(m, "partition_potential_processors=%d\n", 545 seq_printf(m, "partition_potential_processors=%d\n",
546 partition_potential_processors); 546 partition_potential_processors);
547 547
548 seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc); 548 seq_printf(m, "shared_processor_mode=%d\n", lppaca_of(0).shared_proc);
549 549
550 seq_printf(m, "slb_size=%d\n", mmu_slb_size); 550 seq_printf(m, "slb_size=%d\n", mmu_slb_size);
551 551
@@ -780,6 +780,7 @@ static const struct file_operations lparcfg_fops = {
780 .write = lparcfg_write, 780 .write = lparcfg_write,
781 .open = lparcfg_open, 781 .open = lparcfg_open,
782 .release = single_release, 782 .release = single_release,
783 .llseek = seq_lseek,
783}; 784};
784 785
785static int __init lparcfg_init(void) 786static int __init lparcfg_init(void)
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index dd6c141f1662..df7e20c191cd 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -14,10 +14,34 @@
14#include <linux/threads.h> 14#include <linux/threads.h>
15#include <linux/memblock.h> 15#include <linux/memblock.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/irq.h>
18
17#include <asm/machdep.h> 19#include <asm/machdep.h>
18#include <asm/prom.h> 20#include <asm/prom.h>
19#include <asm/sections.h> 21#include <asm/sections.h>
20 22
23void machine_kexec_mask_interrupts(void) {
24 unsigned int i;
25
26 for_each_irq(i) {
27 struct irq_desc *desc = irq_to_desc(i);
28
29 if (!desc || !desc->chip)
30 continue;
31
32 if (desc->chip->eoi &&
33 desc->status & IRQ_INPROGRESS)
34 desc->chip->eoi(i);
35
36 if (desc->chip->mask)
37 desc->chip->mask(i);
38
39 if (desc->chip->disable &&
40 !(desc->status & IRQ_DISABLED))
41 desc->chip->disable(i);
42 }
43}
44
21void machine_crash_shutdown(struct pt_regs *regs) 45void machine_crash_shutdown(struct pt_regs *regs)
22{ 46{
23 if (ppc_md.machine_crash_shutdown) 47 if (ppc_md.machine_crash_shutdown)
diff --git a/arch/powerpc/kernel/machine_kexec_32.c b/arch/powerpc/kernel/machine_kexec_32.c
index ae63a964b858..e63f2e7d2efb 100644
--- a/arch/powerpc/kernel/machine_kexec_32.c
+++ b/arch/powerpc/kernel/machine_kexec_32.c
@@ -39,6 +39,10 @@ void default_machine_kexec(struct kimage *image)
39 /* Interrupts aren't acceptable while we reboot */ 39 /* Interrupts aren't acceptable while we reboot */
40 local_irq_disable(); 40 local_irq_disable();
41 41
42 /* mask each interrupt so we are in a more sane state for the
43 * kexec kernel */
44 machine_kexec_mask_interrupts();
45
42 page_list = image->head; 46 page_list = image->head;
43 47
44 /* we need both effective and real address here */ 48 /* we need both effective and real address here */
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index 477c663e0140..49cee9df225b 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -63,11 +63,6 @@ int module_finalize(const Elf_Ehdr *hdr,
63 const Elf_Shdr *sechdrs, struct module *me) 63 const Elf_Shdr *sechdrs, struct module *me)
64{ 64{
65 const Elf_Shdr *sect; 65 const Elf_Shdr *sect;
66 int err;
67
68 err = module_bug_finalize(hdr, sechdrs, me);
69 if (err)
70 return err;
71 66
72 /* Apply feature fixups */ 67 /* Apply feature fixups */
73 sect = find_section(hdr, sechdrs, "__ftr_fixup"); 68 sect = find_section(hdr, sechdrs, "__ftr_fixup");
@@ -101,5 +96,4 @@ int module_finalize(const Elf_Ehdr *hdr,
101 96
102void module_arch_cleanup(struct module *mod) 97void module_arch_cleanup(struct module *mod)
103{ 98{
104 module_bug_cleanup(mod);
105} 99}
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index d0a26f1770fe..ebf9846f3c3b 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -27,6 +27,20 @@ extern unsigned long __toc_start;
27#ifdef CONFIG_PPC_BOOK3S 27#ifdef CONFIG_PPC_BOOK3S
28 28
29/* 29/*
30 * We only have to have statically allocated lppaca structs on
31 * legacy iSeries, which supports at most 64 cpus.
32 */
33#ifdef CONFIG_PPC_ISERIES
34#if NR_CPUS < 64
35#define NR_LPPACAS NR_CPUS
36#else
37#define NR_LPPACAS 64
38#endif
39#else /* not iSeries */
40#define NR_LPPACAS 1
41#endif
42
43/*
30 * The structure which the hypervisor knows about - this structure 44 * The structure which the hypervisor knows about - this structure
31 * should not cross a page boundary. The vpa_init/register_vpa call 45 * should not cross a page boundary. The vpa_init/register_vpa call
32 * is now known to fail if the lppaca structure crosses a page 46 * is now known to fail if the lppaca structure crosses a page
@@ -36,7 +50,7 @@ extern unsigned long __toc_start;
36 * will suffice to ensure that it doesn't cross a page boundary. 50 * will suffice to ensure that it doesn't cross a page boundary.
37 */ 51 */
38struct lppaca lppaca[] = { 52struct lppaca lppaca[] = {
39 [0 ... (NR_CPUS-1)] = { 53 [0 ... (NR_LPPACAS-1)] = {
40 .desc = 0xd397d781, /* "LpPa" */ 54 .desc = 0xd397d781, /* "LpPa" */
41 .size = sizeof(struct lppaca), 55 .size = sizeof(struct lppaca),
42 .dyn_proc_status = 2, 56 .dyn_proc_status = 2,
@@ -49,6 +63,54 @@ struct lppaca lppaca[] = {
49 }, 63 },
50}; 64};
51 65
66static struct lppaca *extra_lppacas;
67static long __initdata lppaca_size;
68
69static void allocate_lppacas(int nr_cpus, unsigned long limit)
70{
71 if (nr_cpus <= NR_LPPACAS)
72 return;
73
74 lppaca_size = PAGE_ALIGN(sizeof(struct lppaca) *
75 (nr_cpus - NR_LPPACAS));
76 extra_lppacas = __va(memblock_alloc_base(lppaca_size,
77 PAGE_SIZE, limit));
78}
79
80static struct lppaca *new_lppaca(int cpu)
81{
82 struct lppaca *lp;
83
84 if (cpu < NR_LPPACAS)
85 return &lppaca[cpu];
86
87 lp = extra_lppacas + (cpu - NR_LPPACAS);
88 *lp = lppaca[0];
89
90 return lp;
91}
92
93static void free_lppacas(void)
94{
95 long new_size = 0, nr;
96
97 if (!lppaca_size)
98 return;
99 nr = num_possible_cpus() - NR_LPPACAS;
100 if (nr > 0)
101 new_size = PAGE_ALIGN(nr * sizeof(struct lppaca));
102 if (new_size >= lppaca_size)
103 return;
104
105 memblock_free(__pa(extra_lppacas) + new_size, lppaca_size - new_size);
106 lppaca_size = new_size;
107}
108
109#else
110
111static inline void allocate_lppacas(int nr_cpus, unsigned long limit) { }
112static inline void free_lppacas(void) { }
113
52#endif /* CONFIG_PPC_BOOK3S */ 114#endif /* CONFIG_PPC_BOOK3S */
53 115
54#ifdef CONFIG_PPC_STD_MMU_64 116#ifdef CONFIG_PPC_STD_MMU_64
@@ -88,7 +150,7 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu)
88 unsigned long kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL; 150 unsigned long kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL;
89 151
90#ifdef CONFIG_PPC_BOOK3S 152#ifdef CONFIG_PPC_BOOK3S
91 new_paca->lppaca_ptr = &lppaca[cpu]; 153 new_paca->lppaca_ptr = new_lppaca(cpu);
92#else 154#else
93 new_paca->kernel_pgd = swapper_pg_dir; 155 new_paca->kernel_pgd = swapper_pg_dir;
94#endif 156#endif
@@ -127,7 +189,7 @@ void __init allocate_pacas(void)
127 * the first segment. On iSeries they must be within the area mapped 189 * the first segment. On iSeries they must be within the area mapped
128 * by the HV, which is HvPagesToMap * HVPAGESIZE bytes. 190 * by the HV, which is HvPagesToMap * HVPAGESIZE bytes.
129 */ 191 */
130 limit = min(0x10000000ULL, memblock.rmo_size); 192 limit = min(0x10000000ULL, ppc64_rma_size);
131 if (firmware_has_feature(FW_FEATURE_ISERIES)) 193 if (firmware_has_feature(FW_FEATURE_ISERIES))
132 limit = min(limit, HvPagesToMap * HVPAGESIZE); 194 limit = min(limit, HvPagesToMap * HVPAGESIZE);
133 195
@@ -144,6 +206,8 @@ void __init allocate_pacas(void)
144 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n", 206 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n",
145 paca_size, nr_cpus, paca); 207 paca_size, nr_cpus, paca);
146 208
209 allocate_lppacas(nr_cpus, limit);
210
147 /* Can't use for_each_*_cpu, as they aren't functional yet */ 211 /* Can't use for_each_*_cpu, as they aren't functional yet */
148 for (cpu = 0; cpu < nr_cpus; cpu++) 212 for (cpu = 0; cpu < nr_cpus; cpu++)
149 initialise_paca(&paca[cpu], cpu); 213 initialise_paca(&paca[cpu], cpu);
@@ -164,4 +228,6 @@ void __init free_unused_pacas(void)
164 paca_size - new_size); 228 paca_size - new_size);
165 229
166 paca_size = new_size; 230 paca_size = new_size;
231
232 free_lppacas();
167} 233}
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 9021c4ad4bbd..10a44e68ef11 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1090,8 +1090,6 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
1090 bus->number, bus->self ? pci_name(bus->self) : "PHB"); 1090 bus->number, bus->self ? pci_name(bus->self) : "PHB");
1091 1091
1092 list_for_each_entry(dev, &bus->devices, bus_list) { 1092 list_for_each_entry(dev, &bus->devices, bus_list) {
1093 struct dev_archdata *sd = &dev->dev.archdata;
1094
1095 /* Cardbus can call us to add new devices to a bus, so ignore 1093 /* Cardbus can call us to add new devices to a bus, so ignore
1096 * those who are already fully discovered 1094 * those who are already fully discovered
1097 */ 1095 */
@@ -1107,7 +1105,7 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
1107 set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); 1105 set_dev_node(&dev->dev, pcibus_to_node(dev->bus));
1108 1106
1109 /* Hook up default DMA ops */ 1107 /* Hook up default DMA ops */
1110 sd->dma_ops = pci_dma_ops; 1108 set_dma_ops(&dev->dev, pci_dma_ops);
1111 set_dma_offset(&dev->dev, PCI_DRAM_OFFSET); 1109 set_dma_offset(&dev->dev, PCI_DRAM_OFFSET);
1112 1110
1113 /* Additional platform DMA/iommu setup */ 1111 /* Additional platform DMA/iommu setup */
diff --git a/arch/powerpc/kernel/perf_callchain.c b/arch/powerpc/kernel/perf_callchain.c
index 95ad9dad298e..d05ae4204bbf 100644
--- a/arch/powerpc/kernel/perf_callchain.c
+++ b/arch/powerpc/kernel/perf_callchain.c
@@ -23,18 +23,6 @@
23#include "ppc32.h" 23#include "ppc32.h"
24#endif 24#endif
25 25
26/*
27 * Store another value in a callchain_entry.
28 */
29static inline void callchain_store(struct perf_callchain_entry *entry, u64 ip)
30{
31 unsigned int nr = entry->nr;
32
33 if (nr < PERF_MAX_STACK_DEPTH) {
34 entry->ip[nr] = ip;
35 entry->nr = nr + 1;
36 }
37}
38 26
39/* 27/*
40 * Is sp valid as the address of the next kernel stack frame after prev_sp? 28 * Is sp valid as the address of the next kernel stack frame after prev_sp?
@@ -58,8 +46,8 @@ static int valid_next_sp(unsigned long sp, unsigned long prev_sp)
58 return 0; 46 return 0;
59} 47}
60 48
61static void perf_callchain_kernel(struct pt_regs *regs, 49void
62 struct perf_callchain_entry *entry) 50perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
63{ 51{
64 unsigned long sp, next_sp; 52 unsigned long sp, next_sp;
65 unsigned long next_ip; 53 unsigned long next_ip;
@@ -69,8 +57,7 @@ static void perf_callchain_kernel(struct pt_regs *regs,
69 57
70 lr = regs->link; 58 lr = regs->link;
71 sp = regs->gpr[1]; 59 sp = regs->gpr[1];
72 callchain_store(entry, PERF_CONTEXT_KERNEL); 60 perf_callchain_store(entry, regs->nip);
73 callchain_store(entry, regs->nip);
74 61
75 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD)) 62 if (!validate_sp(sp, current, STACK_FRAME_OVERHEAD))
76 return; 63 return;
@@ -89,7 +76,7 @@ static void perf_callchain_kernel(struct pt_regs *regs,
89 next_ip = regs->nip; 76 next_ip = regs->nip;
90 lr = regs->link; 77 lr = regs->link;
91 level = 0; 78 level = 0;
92 callchain_store(entry, PERF_CONTEXT_KERNEL); 79 perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
93 80
94 } else { 81 } else {
95 if (level == 0) 82 if (level == 0)
@@ -111,7 +98,7 @@ static void perf_callchain_kernel(struct pt_regs *regs,
111 ++level; 98 ++level;
112 } 99 }
113 100
114 callchain_store(entry, next_ip); 101 perf_callchain_store(entry, next_ip);
115 if (!valid_next_sp(next_sp, sp)) 102 if (!valid_next_sp(next_sp, sp))
116 return; 103 return;
117 sp = next_sp; 104 sp = next_sp;
@@ -233,8 +220,8 @@ static int sane_signal_64_frame(unsigned long sp)
233 puc == (unsigned long) &sf->uc; 220 puc == (unsigned long) &sf->uc;
234} 221}
235 222
236static void perf_callchain_user_64(struct pt_regs *regs, 223static void perf_callchain_user_64(struct perf_callchain_entry *entry,
237 struct perf_callchain_entry *entry) 224 struct pt_regs *regs)
238{ 225{
239 unsigned long sp, next_sp; 226 unsigned long sp, next_sp;
240 unsigned long next_ip; 227 unsigned long next_ip;
@@ -246,8 +233,7 @@ static void perf_callchain_user_64(struct pt_regs *regs,
246 next_ip = regs->nip; 233 next_ip = regs->nip;
247 lr = regs->link; 234 lr = regs->link;
248 sp = regs->gpr[1]; 235 sp = regs->gpr[1];
249 callchain_store(entry, PERF_CONTEXT_USER); 236 perf_callchain_store(entry, next_ip);
250 callchain_store(entry, next_ip);
251 237
252 for (;;) { 238 for (;;) {
253 fp = (unsigned long __user *) sp; 239 fp = (unsigned long __user *) sp;
@@ -276,14 +262,14 @@ static void perf_callchain_user_64(struct pt_regs *regs,
276 read_user_stack_64(&uregs[PT_R1], &sp)) 262 read_user_stack_64(&uregs[PT_R1], &sp))
277 return; 263 return;
278 level = 0; 264 level = 0;
279 callchain_store(entry, PERF_CONTEXT_USER); 265 perf_callchain_store(entry, PERF_CONTEXT_USER);
280 callchain_store(entry, next_ip); 266 perf_callchain_store(entry, next_ip);
281 continue; 267 continue;
282 } 268 }
283 269
284 if (level == 0) 270 if (level == 0)
285 next_ip = lr; 271 next_ip = lr;
286 callchain_store(entry, next_ip); 272 perf_callchain_store(entry, next_ip);
287 ++level; 273 ++level;
288 sp = next_sp; 274 sp = next_sp;
289 } 275 }
@@ -315,8 +301,8 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
315 return __get_user_inatomic(*ret, ptr); 301 return __get_user_inatomic(*ret, ptr);
316} 302}
317 303
318static inline void perf_callchain_user_64(struct pt_regs *regs, 304static inline void perf_callchain_user_64(struct perf_callchain_entry *entry,
319 struct perf_callchain_entry *entry) 305 struct pt_regs *regs)
320{ 306{
321} 307}
322 308
@@ -435,8 +421,8 @@ static unsigned int __user *signal_frame_32_regs(unsigned int sp,
435 return mctx->mc_gregs; 421 return mctx->mc_gregs;
436} 422}
437 423
438static void perf_callchain_user_32(struct pt_regs *regs, 424static void perf_callchain_user_32(struct perf_callchain_entry *entry,
439 struct perf_callchain_entry *entry) 425 struct pt_regs *regs)
440{ 426{
441 unsigned int sp, next_sp; 427 unsigned int sp, next_sp;
442 unsigned int next_ip; 428 unsigned int next_ip;
@@ -447,8 +433,7 @@ static void perf_callchain_user_32(struct pt_regs *regs,
447 next_ip = regs->nip; 433 next_ip = regs->nip;
448 lr = regs->link; 434 lr = regs->link;
449 sp = regs->gpr[1]; 435 sp = regs->gpr[1];
450 callchain_store(entry, PERF_CONTEXT_USER); 436 perf_callchain_store(entry, next_ip);
451 callchain_store(entry, next_ip);
452 437
453 while (entry->nr < PERF_MAX_STACK_DEPTH) { 438 while (entry->nr < PERF_MAX_STACK_DEPTH) {
454 fp = (unsigned int __user *) (unsigned long) sp; 439 fp = (unsigned int __user *) (unsigned long) sp;
@@ -470,45 +455,24 @@ static void perf_callchain_user_32(struct pt_regs *regs,
470 read_user_stack_32(&uregs[PT_R1], &sp)) 455 read_user_stack_32(&uregs[PT_R1], &sp))
471 return; 456 return;
472 level = 0; 457 level = 0;
473 callchain_store(entry, PERF_CONTEXT_USER); 458 perf_callchain_store(entry, PERF_CONTEXT_USER);
474 callchain_store(entry, next_ip); 459 perf_callchain_store(entry, next_ip);
475 continue; 460 continue;
476 } 461 }
477 462
478 if (level == 0) 463 if (level == 0)
479 next_ip = lr; 464 next_ip = lr;
480 callchain_store(entry, next_ip); 465 perf_callchain_store(entry, next_ip);
481 ++level; 466 ++level;
482 sp = next_sp; 467 sp = next_sp;
483 } 468 }
484} 469}
485 470
486/* 471void
487 * Since we can't get PMU interrupts inside a PMU interrupt handler, 472perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
488 * we don't need separate irq and nmi entries here.
489 */
490static DEFINE_PER_CPU(struct perf_callchain_entry, cpu_perf_callchain);
491
492struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
493{ 473{
494 struct perf_callchain_entry *entry = &__get_cpu_var(cpu_perf_callchain); 474 if (current_is_64bit())
495 475 perf_callchain_user_64(entry, regs);
496 entry->nr = 0; 476 else
497 477 perf_callchain_user_32(entry, regs);
498 if (!user_mode(regs)) {
499 perf_callchain_kernel(regs, entry);
500 if (current->mm)
501 regs = task_pt_regs(current);
502 else
503 regs = NULL;
504 }
505
506 if (regs) {
507 if (current_is_64bit())
508 perf_callchain_user_64(regs, entry);
509 else
510 perf_callchain_user_32(regs, entry);
511 }
512
513 return entry;
514} 478}
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c
index d301a30445e0..3129c855933c 100644
--- a/arch/powerpc/kernel/perf_event.c
+++ b/arch/powerpc/kernel/perf_event.c
@@ -402,6 +402,9 @@ static void power_pmu_read(struct perf_event *event)
402{ 402{
403 s64 val, delta, prev; 403 s64 val, delta, prev;
404 404
405 if (event->hw.state & PERF_HES_STOPPED)
406 return;
407
405 if (!event->hw.idx) 408 if (!event->hw.idx)
406 return; 409 return;
407 /* 410 /*
@@ -517,7 +520,7 @@ static void write_mmcr0(struct cpu_hw_events *cpuhw, unsigned long mmcr0)
517 * Disable all events to prevent PMU interrupts and to allow 520 * Disable all events to prevent PMU interrupts and to allow
518 * events to be added or removed. 521 * events to be added or removed.
519 */ 522 */
520void hw_perf_disable(void) 523static void power_pmu_disable(struct pmu *pmu)
521{ 524{
522 struct cpu_hw_events *cpuhw; 525 struct cpu_hw_events *cpuhw;
523 unsigned long flags; 526 unsigned long flags;
@@ -565,7 +568,7 @@ void hw_perf_disable(void)
565 * If we were previously disabled and events were added, then 568 * If we were previously disabled and events were added, then
566 * put the new config on the PMU. 569 * put the new config on the PMU.
567 */ 570 */
568void hw_perf_enable(void) 571static void power_pmu_enable(struct pmu *pmu)
569{ 572{
570 struct perf_event *event; 573 struct perf_event *event;
571 struct cpu_hw_events *cpuhw; 574 struct cpu_hw_events *cpuhw;
@@ -672,6 +675,8 @@ void hw_perf_enable(void)
672 } 675 }
673 local64_set(&event->hw.prev_count, val); 676 local64_set(&event->hw.prev_count, val);
674 event->hw.idx = idx; 677 event->hw.idx = idx;
678 if (event->hw.state & PERF_HES_STOPPED)
679 val = 0;
675 write_pmc(idx, val); 680 write_pmc(idx, val);
676 perf_event_update_userpage(event); 681 perf_event_update_userpage(event);
677 } 682 }
@@ -727,7 +732,7 @@ static int collect_events(struct perf_event *group, int max_count,
727 * re-enable the PMU in order to get hw_perf_enable to do the 732 * re-enable the PMU in order to get hw_perf_enable to do the
728 * actual work of reconfiguring the PMU. 733 * actual work of reconfiguring the PMU.
729 */ 734 */
730static int power_pmu_enable(struct perf_event *event) 735static int power_pmu_add(struct perf_event *event, int ef_flags)
731{ 736{
732 struct cpu_hw_events *cpuhw; 737 struct cpu_hw_events *cpuhw;
733 unsigned long flags; 738 unsigned long flags;
@@ -735,7 +740,7 @@ static int power_pmu_enable(struct perf_event *event)
735 int ret = -EAGAIN; 740 int ret = -EAGAIN;
736 741
737 local_irq_save(flags); 742 local_irq_save(flags);
738 perf_disable(); 743 perf_pmu_disable(event->pmu);
739 744
740 /* 745 /*
741 * Add the event to the list (if there is room) 746 * Add the event to the list (if there is room)
@@ -749,6 +754,9 @@ static int power_pmu_enable(struct perf_event *event)
749 cpuhw->events[n0] = event->hw.config; 754 cpuhw->events[n0] = event->hw.config;
750 cpuhw->flags[n0] = event->hw.event_base; 755 cpuhw->flags[n0] = event->hw.event_base;
751 756
757 if (!(ef_flags & PERF_EF_START))
758 event->hw.state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
759
752 /* 760 /*
753 * If group events scheduling transaction was started, 761 * If group events scheduling transaction was started,
754 * skip the schedulability test here, it will be peformed 762 * skip the schedulability test here, it will be peformed
@@ -769,7 +777,7 @@ nocheck:
769 777
770 ret = 0; 778 ret = 0;
771 out: 779 out:
772 perf_enable(); 780 perf_pmu_enable(event->pmu);
773 local_irq_restore(flags); 781 local_irq_restore(flags);
774 return ret; 782 return ret;
775} 783}
@@ -777,14 +785,14 @@ nocheck:
777/* 785/*
778 * Remove a event from the PMU. 786 * Remove a event from the PMU.
779 */ 787 */
780static void power_pmu_disable(struct perf_event *event) 788static void power_pmu_del(struct perf_event *event, int ef_flags)
781{ 789{
782 struct cpu_hw_events *cpuhw; 790 struct cpu_hw_events *cpuhw;
783 long i; 791 long i;
784 unsigned long flags; 792 unsigned long flags;
785 793
786 local_irq_save(flags); 794 local_irq_save(flags);
787 perf_disable(); 795 perf_pmu_disable(event->pmu);
788 796
789 power_pmu_read(event); 797 power_pmu_read(event);
790 798
@@ -821,34 +829,60 @@ static void power_pmu_disable(struct perf_event *event)
821 cpuhw->mmcr[0] &= ~(MMCR0_PMXE | MMCR0_FCECE); 829 cpuhw->mmcr[0] &= ~(MMCR0_PMXE | MMCR0_FCECE);
822 } 830 }
823 831
824 perf_enable(); 832 perf_pmu_enable(event->pmu);
825 local_irq_restore(flags); 833 local_irq_restore(flags);
826} 834}
827 835
828/* 836/*
829 * Re-enable interrupts on a event after they were throttled 837 * POWER-PMU does not support disabling individual counters, hence
830 * because they were coming too fast. 838 * program their cycle counter to their max value and ignore the interrupts.
831 */ 839 */
832static void power_pmu_unthrottle(struct perf_event *event) 840
841static void power_pmu_start(struct perf_event *event, int ef_flags)
842{
843 unsigned long flags;
844 s64 left;
845
846 if (!event->hw.idx || !event->hw.sample_period)
847 return;
848
849 if (!(event->hw.state & PERF_HES_STOPPED))
850 return;
851
852 if (ef_flags & PERF_EF_RELOAD)
853 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
854
855 local_irq_save(flags);
856 perf_pmu_disable(event->pmu);
857
858 event->hw.state = 0;
859 left = local64_read(&event->hw.period_left);
860 write_pmc(event->hw.idx, left);
861
862 perf_event_update_userpage(event);
863 perf_pmu_enable(event->pmu);
864 local_irq_restore(flags);
865}
866
867static void power_pmu_stop(struct perf_event *event, int ef_flags)
833{ 868{
834 s64 val, left;
835 unsigned long flags; 869 unsigned long flags;
836 870
837 if (!event->hw.idx || !event->hw.sample_period) 871 if (!event->hw.idx || !event->hw.sample_period)
838 return; 872 return;
873
874 if (event->hw.state & PERF_HES_STOPPED)
875 return;
876
839 local_irq_save(flags); 877 local_irq_save(flags);
840 perf_disable(); 878 perf_pmu_disable(event->pmu);
879
841 power_pmu_read(event); 880 power_pmu_read(event);
842 left = event->hw.sample_period; 881 event->hw.state |= PERF_HES_STOPPED | PERF_HES_UPTODATE;
843 event->hw.last_period = left; 882 write_pmc(event->hw.idx, 0);
844 val = 0; 883
845 if (left < 0x80000000L)
846 val = 0x80000000L - left;
847 write_pmc(event->hw.idx, val);
848 local64_set(&event->hw.prev_count, val);
849 local64_set(&event->hw.period_left, left);
850 perf_event_update_userpage(event); 884 perf_event_update_userpage(event);
851 perf_enable(); 885 perf_pmu_enable(event->pmu);
852 local_irq_restore(flags); 886 local_irq_restore(flags);
853} 887}
854 888
@@ -857,10 +891,11 @@ static void power_pmu_unthrottle(struct perf_event *event)
857 * Set the flag to make pmu::enable() not perform the 891 * Set the flag to make pmu::enable() not perform the
858 * schedulability test, it will be performed at commit time 892 * schedulability test, it will be performed at commit time
859 */ 893 */
860void power_pmu_start_txn(const struct pmu *pmu) 894void power_pmu_start_txn(struct pmu *pmu)
861{ 895{
862 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 896 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
863 897
898 perf_pmu_disable(pmu);
864 cpuhw->group_flag |= PERF_EVENT_TXN; 899 cpuhw->group_flag |= PERF_EVENT_TXN;
865 cpuhw->n_txn_start = cpuhw->n_events; 900 cpuhw->n_txn_start = cpuhw->n_events;
866} 901}
@@ -870,11 +905,12 @@ void power_pmu_start_txn(const struct pmu *pmu)
870 * Clear the flag and pmu::enable() will perform the 905 * Clear the flag and pmu::enable() will perform the
871 * schedulability test. 906 * schedulability test.
872 */ 907 */
873void power_pmu_cancel_txn(const struct pmu *pmu) 908void power_pmu_cancel_txn(struct pmu *pmu)
874{ 909{
875 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 910 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
876 911
877 cpuhw->group_flag &= ~PERF_EVENT_TXN; 912 cpuhw->group_flag &= ~PERF_EVENT_TXN;
913 perf_pmu_enable(pmu);
878} 914}
879 915
880/* 916/*
@@ -882,7 +918,7 @@ void power_pmu_cancel_txn(const struct pmu *pmu)
882 * Perform the group schedulability test as a whole 918 * Perform the group schedulability test as a whole
883 * Return 0 if success 919 * Return 0 if success
884 */ 920 */
885int power_pmu_commit_txn(const struct pmu *pmu) 921int power_pmu_commit_txn(struct pmu *pmu)
886{ 922{
887 struct cpu_hw_events *cpuhw; 923 struct cpu_hw_events *cpuhw;
888 long i, n; 924 long i, n;
@@ -901,19 +937,10 @@ int power_pmu_commit_txn(const struct pmu *pmu)
901 cpuhw->event[i]->hw.config = cpuhw->events[i]; 937 cpuhw->event[i]->hw.config = cpuhw->events[i];
902 938
903 cpuhw->group_flag &= ~PERF_EVENT_TXN; 939 cpuhw->group_flag &= ~PERF_EVENT_TXN;
940 perf_pmu_enable(pmu);
904 return 0; 941 return 0;
905} 942}
906 943
907struct pmu power_pmu = {
908 .enable = power_pmu_enable,
909 .disable = power_pmu_disable,
910 .read = power_pmu_read,
911 .unthrottle = power_pmu_unthrottle,
912 .start_txn = power_pmu_start_txn,
913 .cancel_txn = power_pmu_cancel_txn,
914 .commit_txn = power_pmu_commit_txn,
915};
916
917/* 944/*
918 * Return 1 if we might be able to put event on a limited PMC, 945 * Return 1 if we might be able to put event on a limited PMC,
919 * or 0 if not. 946 * or 0 if not.
@@ -1014,7 +1041,7 @@ static int hw_perf_cache_event(u64 config, u64 *eventp)
1014 return 0; 1041 return 0;
1015} 1042}
1016 1043
1017const struct pmu *hw_perf_event_init(struct perf_event *event) 1044static int power_pmu_event_init(struct perf_event *event)
1018{ 1045{
1019 u64 ev; 1046 u64 ev;
1020 unsigned long flags; 1047 unsigned long flags;
@@ -1026,25 +1053,27 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1026 struct cpu_hw_events *cpuhw; 1053 struct cpu_hw_events *cpuhw;
1027 1054
1028 if (!ppmu) 1055 if (!ppmu)
1029 return ERR_PTR(-ENXIO); 1056 return -ENOENT;
1057
1030 switch (event->attr.type) { 1058 switch (event->attr.type) {
1031 case PERF_TYPE_HARDWARE: 1059 case PERF_TYPE_HARDWARE:
1032 ev = event->attr.config; 1060 ev = event->attr.config;
1033 if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0) 1061 if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0)
1034 return ERR_PTR(-EOPNOTSUPP); 1062 return -EOPNOTSUPP;
1035 ev = ppmu->generic_events[ev]; 1063 ev = ppmu->generic_events[ev];
1036 break; 1064 break;
1037 case PERF_TYPE_HW_CACHE: 1065 case PERF_TYPE_HW_CACHE:
1038 err = hw_perf_cache_event(event->attr.config, &ev); 1066 err = hw_perf_cache_event(event->attr.config, &ev);
1039 if (err) 1067 if (err)
1040 return ERR_PTR(err); 1068 return err;
1041 break; 1069 break;
1042 case PERF_TYPE_RAW: 1070 case PERF_TYPE_RAW:
1043 ev = event->attr.config; 1071 ev = event->attr.config;
1044 break; 1072 break;
1045 default: 1073 default:
1046 return ERR_PTR(-EINVAL); 1074 return -ENOENT;
1047 } 1075 }
1076
1048 event->hw.config_base = ev; 1077 event->hw.config_base = ev;
1049 event->hw.idx = 0; 1078 event->hw.idx = 0;
1050 1079
@@ -1063,7 +1092,7 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1063 * XXX we should check if the task is an idle task. 1092 * XXX we should check if the task is an idle task.
1064 */ 1093 */
1065 flags = 0; 1094 flags = 0;
1066 if (event->ctx->task) 1095 if (event->attach_state & PERF_ATTACH_TASK)
1067 flags |= PPMU_ONLY_COUNT_RUN; 1096 flags |= PPMU_ONLY_COUNT_RUN;
1068 1097
1069 /* 1098 /*
@@ -1081,7 +1110,7 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1081 */ 1110 */
1082 ev = normal_pmc_alternative(ev, flags); 1111 ev = normal_pmc_alternative(ev, flags);
1083 if (!ev) 1112 if (!ev)
1084 return ERR_PTR(-EINVAL); 1113 return -EINVAL;
1085 } 1114 }
1086 } 1115 }
1087 1116
@@ -1095,19 +1124,19 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1095 n = collect_events(event->group_leader, ppmu->n_counter - 1, 1124 n = collect_events(event->group_leader, ppmu->n_counter - 1,
1096 ctrs, events, cflags); 1125 ctrs, events, cflags);
1097 if (n < 0) 1126 if (n < 0)
1098 return ERR_PTR(-EINVAL); 1127 return -EINVAL;
1099 } 1128 }
1100 events[n] = ev; 1129 events[n] = ev;
1101 ctrs[n] = event; 1130 ctrs[n] = event;
1102 cflags[n] = flags; 1131 cflags[n] = flags;
1103 if (check_excludes(ctrs, cflags, n, 1)) 1132 if (check_excludes(ctrs, cflags, n, 1))
1104 return ERR_PTR(-EINVAL); 1133 return -EINVAL;
1105 1134
1106 cpuhw = &get_cpu_var(cpu_hw_events); 1135 cpuhw = &get_cpu_var(cpu_hw_events);
1107 err = power_check_constraints(cpuhw, events, cflags, n + 1); 1136 err = power_check_constraints(cpuhw, events, cflags, n + 1);
1108 put_cpu_var(cpu_hw_events); 1137 put_cpu_var(cpu_hw_events);
1109 if (err) 1138 if (err)
1110 return ERR_PTR(-EINVAL); 1139 return -EINVAL;
1111 1140
1112 event->hw.config = events[n]; 1141 event->hw.config = events[n];
1113 event->hw.event_base = cflags[n]; 1142 event->hw.event_base = cflags[n];
@@ -1132,11 +1161,23 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1132 } 1161 }
1133 event->destroy = hw_perf_event_destroy; 1162 event->destroy = hw_perf_event_destroy;
1134 1163
1135 if (err) 1164 return err;
1136 return ERR_PTR(err);
1137 return &power_pmu;
1138} 1165}
1139 1166
1167struct pmu power_pmu = {
1168 .pmu_enable = power_pmu_enable,
1169 .pmu_disable = power_pmu_disable,
1170 .event_init = power_pmu_event_init,
1171 .add = power_pmu_add,
1172 .del = power_pmu_del,
1173 .start = power_pmu_start,
1174 .stop = power_pmu_stop,
1175 .read = power_pmu_read,
1176 .start_txn = power_pmu_start_txn,
1177 .cancel_txn = power_pmu_cancel_txn,
1178 .commit_txn = power_pmu_commit_txn,
1179};
1180
1140/* 1181/*
1141 * A counter has overflowed; update its count and record 1182 * A counter has overflowed; update its count and record
1142 * things if requested. Note that interrupts are hard-disabled 1183 * things if requested. Note that interrupts are hard-disabled
@@ -1149,6 +1190,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
1149 s64 prev, delta, left; 1190 s64 prev, delta, left;
1150 int record = 0; 1191 int record = 0;
1151 1192
1193 if (event->hw.state & PERF_HES_STOPPED) {
1194 write_pmc(event->hw.idx, 0);
1195 return;
1196 }
1197
1152 /* we don't have to worry about interrupts here */ 1198 /* we don't have to worry about interrupts here */
1153 prev = local64_read(&event->hw.prev_count); 1199 prev = local64_read(&event->hw.prev_count);
1154 delta = (val - prev) & 0xfffffffful; 1200 delta = (val - prev) & 0xfffffffful;
@@ -1171,6 +1217,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
1171 val = 0x80000000LL - left; 1217 val = 0x80000000LL - left;
1172 } 1218 }
1173 1219
1220 write_pmc(event->hw.idx, val);
1221 local64_set(&event->hw.prev_count, val);
1222 local64_set(&event->hw.period_left, left);
1223 perf_event_update_userpage(event);
1224
1174 /* 1225 /*
1175 * Finally record data if requested. 1226 * Finally record data if requested.
1176 */ 1227 */
@@ -1183,23 +1234,9 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
1183 if (event->attr.sample_type & PERF_SAMPLE_ADDR) 1234 if (event->attr.sample_type & PERF_SAMPLE_ADDR)
1184 perf_get_data_addr(regs, &data.addr); 1235 perf_get_data_addr(regs, &data.addr);
1185 1236
1186 if (perf_event_overflow(event, nmi, &data, regs)) { 1237 if (perf_event_overflow(event, nmi, &data, regs))
1187 /* 1238 power_pmu_stop(event, 0);
1188 * Interrupts are coming too fast - throttle them
1189 * by setting the event to 0, so it will be
1190 * at least 2^30 cycles until the next interrupt
1191 * (assuming each event counts at most 2 counts
1192 * per cycle).
1193 */
1194 val = 0;
1195 left = ~0ULL >> 1;
1196 }
1197 } 1239 }
1198
1199 write_pmc(event->hw.idx, val);
1200 local64_set(&event->hw.prev_count, val);
1201 local64_set(&event->hw.period_left, left);
1202 perf_event_update_userpage(event);
1203} 1240}
1204 1241
1205/* 1242/*
@@ -1342,6 +1379,7 @@ int register_power_pmu(struct power_pmu *pmu)
1342 freeze_events_kernel = MMCR0_FCHV; 1379 freeze_events_kernel = MMCR0_FCHV;
1343#endif /* CONFIG_PPC64 */ 1380#endif /* CONFIG_PPC64 */
1344 1381
1382 perf_pmu_register(&power_pmu);
1345 perf_cpu_notifier(power_pmu_notifier); 1383 perf_cpu_notifier(power_pmu_notifier);
1346 1384
1347 return 0; 1385 return 0;
diff --git a/arch/powerpc/kernel/perf_event_fsl_emb.c b/arch/powerpc/kernel/perf_event_fsl_emb.c
index 1ba45471ae43..7ecca59ddf77 100644
--- a/arch/powerpc/kernel/perf_event_fsl_emb.c
+++ b/arch/powerpc/kernel/perf_event_fsl_emb.c
@@ -156,6 +156,9 @@ static void fsl_emb_pmu_read(struct perf_event *event)
156{ 156{
157 s64 val, delta, prev; 157 s64 val, delta, prev;
158 158
159 if (event->hw.state & PERF_HES_STOPPED)
160 return;
161
159 /* 162 /*
160 * Performance monitor interrupts come even when interrupts 163 * Performance monitor interrupts come even when interrupts
161 * are soft-disabled, as long as interrupts are hard-enabled. 164 * are soft-disabled, as long as interrupts are hard-enabled.
@@ -177,7 +180,7 @@ static void fsl_emb_pmu_read(struct perf_event *event)
177 * Disable all events to prevent PMU interrupts and to allow 180 * Disable all events to prevent PMU interrupts and to allow
178 * events to be added or removed. 181 * events to be added or removed.
179 */ 182 */
180void hw_perf_disable(void) 183static void fsl_emb_pmu_disable(struct pmu *pmu)
181{ 184{
182 struct cpu_hw_events *cpuhw; 185 struct cpu_hw_events *cpuhw;
183 unsigned long flags; 186 unsigned long flags;
@@ -216,7 +219,7 @@ void hw_perf_disable(void)
216 * If we were previously disabled and events were added, then 219 * If we were previously disabled and events were added, then
217 * put the new config on the PMU. 220 * put the new config on the PMU.
218 */ 221 */
219void hw_perf_enable(void) 222static void fsl_emb_pmu_enable(struct pmu *pmu)
220{ 223{
221 struct cpu_hw_events *cpuhw; 224 struct cpu_hw_events *cpuhw;
222 unsigned long flags; 225 unsigned long flags;
@@ -262,8 +265,8 @@ static int collect_events(struct perf_event *group, int max_count,
262 return n; 265 return n;
263} 266}
264 267
265/* perf must be disabled, context locked on entry */ 268/* context locked on entry */
266static int fsl_emb_pmu_enable(struct perf_event *event) 269static int fsl_emb_pmu_add(struct perf_event *event, int flags)
267{ 270{
268 struct cpu_hw_events *cpuhw; 271 struct cpu_hw_events *cpuhw;
269 int ret = -EAGAIN; 272 int ret = -EAGAIN;
@@ -271,6 +274,7 @@ static int fsl_emb_pmu_enable(struct perf_event *event)
271 u64 val; 274 u64 val;
272 int i; 275 int i;
273 276
277 perf_pmu_disable(event->pmu);
274 cpuhw = &get_cpu_var(cpu_hw_events); 278 cpuhw = &get_cpu_var(cpu_hw_events);
275 279
276 if (event->hw.config & FSL_EMB_EVENT_RESTRICTED) 280 if (event->hw.config & FSL_EMB_EVENT_RESTRICTED)
@@ -301,6 +305,12 @@ static int fsl_emb_pmu_enable(struct perf_event *event)
301 val = 0x80000000L - left; 305 val = 0x80000000L - left;
302 } 306 }
303 local64_set(&event->hw.prev_count, val); 307 local64_set(&event->hw.prev_count, val);
308
309 if (!(flags & PERF_EF_START)) {
310 event->hw.state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
311 val = 0;
312 }
313
304 write_pmc(i, val); 314 write_pmc(i, val);
305 perf_event_update_userpage(event); 315 perf_event_update_userpage(event);
306 316
@@ -310,15 +320,17 @@ static int fsl_emb_pmu_enable(struct perf_event *event)
310 ret = 0; 320 ret = 0;
311 out: 321 out:
312 put_cpu_var(cpu_hw_events); 322 put_cpu_var(cpu_hw_events);
323 perf_pmu_enable(event->pmu);
313 return ret; 324 return ret;
314} 325}
315 326
316/* perf must be disabled, context locked on entry */ 327/* context locked on entry */
317static void fsl_emb_pmu_disable(struct perf_event *event) 328static void fsl_emb_pmu_del(struct perf_event *event, int flags)
318{ 329{
319 struct cpu_hw_events *cpuhw; 330 struct cpu_hw_events *cpuhw;
320 int i = event->hw.idx; 331 int i = event->hw.idx;
321 332
333 perf_pmu_disable(event->pmu);
322 if (i < 0) 334 if (i < 0)
323 goto out; 335 goto out;
324 336
@@ -346,44 +358,57 @@ static void fsl_emb_pmu_disable(struct perf_event *event)
346 cpuhw->n_events--; 358 cpuhw->n_events--;
347 359
348 out: 360 out:
361 perf_pmu_enable(event->pmu);
349 put_cpu_var(cpu_hw_events); 362 put_cpu_var(cpu_hw_events);
350} 363}
351 364
352/* 365static void fsl_emb_pmu_start(struct perf_event *event, int ef_flags)
353 * Re-enable interrupts on a event after they were throttled
354 * because they were coming too fast.
355 *
356 * Context is locked on entry, but perf is not disabled.
357 */
358static void fsl_emb_pmu_unthrottle(struct perf_event *event)
359{ 366{
360 s64 val, left;
361 unsigned long flags; 367 unsigned long flags;
368 s64 left;
362 369
363 if (event->hw.idx < 0 || !event->hw.sample_period) 370 if (event->hw.idx < 0 || !event->hw.sample_period)
364 return; 371 return;
372
373 if (!(event->hw.state & PERF_HES_STOPPED))
374 return;
375
376 if (ef_flags & PERF_EF_RELOAD)
377 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
378
365 local_irq_save(flags); 379 local_irq_save(flags);
366 perf_disable(); 380 perf_pmu_disable(event->pmu);
367 fsl_emb_pmu_read(event); 381
368 left = event->hw.sample_period; 382 event->hw.state = 0;
369 event->hw.last_period = left; 383 left = local64_read(&event->hw.period_left);
370 val = 0; 384 write_pmc(event->hw.idx, left);
371 if (left < 0x80000000L) 385
372 val = 0x80000000L - left;
373 write_pmc(event->hw.idx, val);
374 local64_set(&event->hw.prev_count, val);
375 local64_set(&event->hw.period_left, left);
376 perf_event_update_userpage(event); 386 perf_event_update_userpage(event);
377 perf_enable(); 387 perf_pmu_enable(event->pmu);
378 local_irq_restore(flags); 388 local_irq_restore(flags);
379} 389}
380 390
381static struct pmu fsl_emb_pmu = { 391static void fsl_emb_pmu_stop(struct perf_event *event, int ef_flags)
382 .enable = fsl_emb_pmu_enable, 392{
383 .disable = fsl_emb_pmu_disable, 393 unsigned long flags;
384 .read = fsl_emb_pmu_read, 394
385 .unthrottle = fsl_emb_pmu_unthrottle, 395 if (event->hw.idx < 0 || !event->hw.sample_period)
386}; 396 return;
397
398 if (event->hw.state & PERF_HES_STOPPED)
399 return;
400
401 local_irq_save(flags);
402 perf_pmu_disable(event->pmu);
403
404 fsl_emb_pmu_read(event);
405 event->hw.state |= PERF_HES_STOPPED | PERF_HES_UPTODATE;
406 write_pmc(event->hw.idx, 0);
407
408 perf_event_update_userpage(event);
409 perf_pmu_enable(event->pmu);
410 local_irq_restore(flags);
411}
387 412
388/* 413/*
389 * Release the PMU if this is the last perf_event. 414 * Release the PMU if this is the last perf_event.
@@ -428,7 +453,7 @@ static int hw_perf_cache_event(u64 config, u64 *eventp)
428 return 0; 453 return 0;
429} 454}
430 455
431const struct pmu *hw_perf_event_init(struct perf_event *event) 456static int fsl_emb_pmu_event_init(struct perf_event *event)
432{ 457{
433 u64 ev; 458 u64 ev;
434 struct perf_event *events[MAX_HWEVENTS]; 459 struct perf_event *events[MAX_HWEVENTS];
@@ -441,14 +466,14 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
441 case PERF_TYPE_HARDWARE: 466 case PERF_TYPE_HARDWARE:
442 ev = event->attr.config; 467 ev = event->attr.config;
443 if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0) 468 if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0)
444 return ERR_PTR(-EOPNOTSUPP); 469 return -EOPNOTSUPP;
445 ev = ppmu->generic_events[ev]; 470 ev = ppmu->generic_events[ev];
446 break; 471 break;
447 472
448 case PERF_TYPE_HW_CACHE: 473 case PERF_TYPE_HW_CACHE:
449 err = hw_perf_cache_event(event->attr.config, &ev); 474 err = hw_perf_cache_event(event->attr.config, &ev);
450 if (err) 475 if (err)
451 return ERR_PTR(err); 476 return err;
452 break; 477 break;
453 478
454 case PERF_TYPE_RAW: 479 case PERF_TYPE_RAW:
@@ -456,12 +481,12 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
456 break; 481 break;
457 482
458 default: 483 default:
459 return ERR_PTR(-EINVAL); 484 return -ENOENT;
460 } 485 }
461 486
462 event->hw.config = ppmu->xlate_event(ev); 487 event->hw.config = ppmu->xlate_event(ev);
463 if (!(event->hw.config & FSL_EMB_EVENT_VALID)) 488 if (!(event->hw.config & FSL_EMB_EVENT_VALID))
464 return ERR_PTR(-EINVAL); 489 return -EINVAL;
465 490
466 /* 491 /*
467 * If this is in a group, check if it can go on with all the 492 * If this is in a group, check if it can go on with all the
@@ -473,7 +498,7 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
473 n = collect_events(event->group_leader, 498 n = collect_events(event->group_leader,
474 ppmu->n_counter - 1, events); 499 ppmu->n_counter - 1, events);
475 if (n < 0) 500 if (n < 0)
476 return ERR_PTR(-EINVAL); 501 return -EINVAL;
477 } 502 }
478 503
479 if (event->hw.config & FSL_EMB_EVENT_RESTRICTED) { 504 if (event->hw.config & FSL_EMB_EVENT_RESTRICTED) {
@@ -484,7 +509,7 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
484 } 509 }
485 510
486 if (num_restricted >= ppmu->n_restricted) 511 if (num_restricted >= ppmu->n_restricted)
487 return ERR_PTR(-EINVAL); 512 return -EINVAL;
488 } 513 }
489 514
490 event->hw.idx = -1; 515 event->hw.idx = -1;
@@ -497,7 +522,7 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
497 if (event->attr.exclude_kernel) 522 if (event->attr.exclude_kernel)
498 event->hw.config_base |= PMLCA_FCS; 523 event->hw.config_base |= PMLCA_FCS;
499 if (event->attr.exclude_idle) 524 if (event->attr.exclude_idle)
500 return ERR_PTR(-ENOTSUPP); 525 return -ENOTSUPP;
501 526
502 event->hw.last_period = event->hw.sample_period; 527 event->hw.last_period = event->hw.sample_period;
503 local64_set(&event->hw.period_left, event->hw.last_period); 528 local64_set(&event->hw.period_left, event->hw.last_period);
@@ -523,11 +548,20 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
523 } 548 }
524 event->destroy = hw_perf_event_destroy; 549 event->destroy = hw_perf_event_destroy;
525 550
526 if (err) 551 return err;
527 return ERR_PTR(err);
528 return &fsl_emb_pmu;
529} 552}
530 553
554static struct pmu fsl_emb_pmu = {
555 .pmu_enable = fsl_emb_pmu_enable,
556 .pmu_disable = fsl_emb_pmu_disable,
557 .event_init = fsl_emb_pmu_event_init,
558 .add = fsl_emb_pmu_add,
559 .del = fsl_emb_pmu_del,
560 .start = fsl_emb_pmu_start,
561 .stop = fsl_emb_pmu_stop,
562 .read = fsl_emb_pmu_read,
563};
564
531/* 565/*
532 * A counter has overflowed; update its count and record 566 * A counter has overflowed; update its count and record
533 * things if requested. Note that interrupts are hard-disabled 567 * things if requested. Note that interrupts are hard-disabled
@@ -540,6 +574,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
540 s64 prev, delta, left; 574 s64 prev, delta, left;
541 int record = 0; 575 int record = 0;
542 576
577 if (event->hw.state & PERF_HES_STOPPED) {
578 write_pmc(event->hw.idx, 0);
579 return;
580 }
581
543 /* we don't have to worry about interrupts here */ 582 /* we don't have to worry about interrupts here */
544 prev = local64_read(&event->hw.prev_count); 583 prev = local64_read(&event->hw.prev_count);
545 delta = (val - prev) & 0xfffffffful; 584 delta = (val - prev) & 0xfffffffful;
@@ -562,6 +601,11 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
562 val = 0x80000000LL - left; 601 val = 0x80000000LL - left;
563 } 602 }
564 603
604 write_pmc(event->hw.idx, val);
605 local64_set(&event->hw.prev_count, val);
606 local64_set(&event->hw.period_left, left);
607 perf_event_update_userpage(event);
608
565 /* 609 /*
566 * Finally record data if requested. 610 * Finally record data if requested.
567 */ 611 */
@@ -571,23 +615,9 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
571 perf_sample_data_init(&data, 0); 615 perf_sample_data_init(&data, 0);
572 data.period = event->hw.last_period; 616 data.period = event->hw.last_period;
573 617
574 if (perf_event_overflow(event, nmi, &data, regs)) { 618 if (perf_event_overflow(event, nmi, &data, regs))
575 /* 619 fsl_emb_pmu_stop(event, 0);
576 * Interrupts are coming too fast - throttle them
577 * by setting the event to 0, so it will be
578 * at least 2^30 cycles until the next interrupt
579 * (assuming each event counts at most 2 counts
580 * per cycle).
581 */
582 val = 0;
583 left = ~0ULL >> 1;
584 }
585 } 620 }
586
587 write_pmc(event->hw.idx, val);
588 local64_set(&event->hw.prev_count, val);
589 local64_set(&event->hw.period_left, left);
590 perf_event_update_userpage(event);
591} 621}
592 622
593static void perf_event_interrupt(struct pt_regs *regs) 623static void perf_event_interrupt(struct pt_regs *regs)
@@ -651,5 +681,7 @@ int register_fsl_emb_pmu(struct fsl_emb_pmu *pmu)
651 pr_info("%s performance monitor hardware support registered\n", 681 pr_info("%s performance monitor hardware support registered\n",
652 pmu->name); 682 pmu->name);
653 683
684 perf_pmu_register(&fsl_emb_pmu);
685
654 return 0; 686 return 0;
655} 687}
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c
index 8eff48e20dba..3fee685de4df 100644
--- a/arch/powerpc/kernel/ppc970-pmu.c
+++ b/arch/powerpc/kernel/ppc970-pmu.c
@@ -169,9 +169,11 @@ static int p970_marked_instr_event(u64 event)
169 switch (unit) { 169 switch (unit) {
170 case PM_VPU: 170 case PM_VPU:
171 mask = 0x4c; /* byte 0 bits 2,3,6 */ 171 mask = 0x4c; /* byte 0 bits 2,3,6 */
172 break;
172 case PM_LSU0: 173 case PM_LSU0:
173 /* byte 2 bits 0,2,3,4,6; all of byte 1 */ 174 /* byte 2 bits 0,2,3,4,6; all of byte 1 */
174 mask = 0x085dff00; 175 mask = 0x085dff00;
176 break;
175 case PM_LSU1L: 177 case PM_LSU1L:
176 mask = 0x50 << 24; /* byte 3 bits 4,6 */ 178 mask = 0x50 << 24; /* byte 3 bits 4,6 */
177 break; 179 break;
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b1c648a36b03..84906d3fc860 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -517,7 +517,6 @@ struct task_struct *__switch_to(struct task_struct *prev,
517 517
518 account_system_vtime(current); 518 account_system_vtime(current);
519 account_process_vtime(current); 519 account_process_vtime(current);
520 calculate_steal_time();
521 520
522 /* 521 /*
523 * We can't take a PMU exception inside _switch() since there is a 522 * We can't take a PMU exception inside _switch() since there is a
@@ -1298,14 +1297,3 @@ unsigned long randomize_et_dyn(unsigned long base)
1298 1297
1299 return ret; 1298 return ret;
1300} 1299}
1301
1302#ifdef CONFIG_SMP
1303int arch_sd_sibling_asym_packing(void)
1304{
1305 if (cpu_has_feature(CPU_FTR_ASYM_SMT)) {
1306 printk_once(KERN_INFO "Enabling Asymmetric SMT scheduling\n");
1307 return SD_ASYM_PACKING;
1308 }
1309 return 0;
1310}
1311#endif
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index fed9bf6187d1..9e3132db718b 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -66,6 +66,7 @@
66int __initdata iommu_is_off; 66int __initdata iommu_is_off;
67int __initdata iommu_force_on; 67int __initdata iommu_force_on;
68unsigned long tce_alloc_start, tce_alloc_end; 68unsigned long tce_alloc_start, tce_alloc_end;
69u64 ppc64_rma_size;
69#endif 70#endif
70 71
71static int __init early_parse_mem(char *p) 72static int __init early_parse_mem(char *p)
@@ -98,7 +99,7 @@ static void __init move_device_tree(void)
98 99
99 if ((memory_limit && (start + size) > memory_limit) || 100 if ((memory_limit && (start + size) > memory_limit) ||
100 overlaps_crashkernel(start, size)) { 101 overlaps_crashkernel(start, size)) {
101 p = __va(memblock_alloc_base(size, PAGE_SIZE, memblock.rmo_size)); 102 p = __va(memblock_alloc(size, PAGE_SIZE));
102 memcpy(p, initial_boot_params, size); 103 memcpy(p, initial_boot_params, size);
103 initial_boot_params = (struct boot_param_header *)p; 104 initial_boot_params = (struct boot_param_header *)p;
104 DBG("Moved device tree to 0x%p\n", p); 105 DBG("Moved device tree to 0x%p\n", p);
@@ -363,10 +364,15 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
363 return 0; 364 return 0;
364} 365}
365 366
366void __init early_init_dt_scan_chosen_arch(unsigned long node) 367int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
368 int depth, void *data)
367{ 369{
368 unsigned long *lprop; 370 unsigned long *lprop;
369 371
372 /* Use common scan routine to determine if this is the chosen node */
373 if (early_init_dt_scan_chosen(node, uname, depth, data) == 0)
374 return 0;
375
370#ifdef CONFIG_PPC64 376#ifdef CONFIG_PPC64
371 /* check if iommu is forced on or off */ 377 /* check if iommu is forced on or off */
372 if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL) 378 if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL)
@@ -398,6 +404,9 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)
398 if (lprop) 404 if (lprop)
399 crashk_res.end = crashk_res.start + *lprop - 1; 405 crashk_res.end = crashk_res.start + *lprop - 1;
400#endif 406#endif
407
408 /* break now */
409 return 1;
401} 410}
402 411
403#ifdef CONFIG_PPC_PSERIES 412#ifdef CONFIG_PPC_PSERIES
@@ -492,7 +501,7 @@ static int __init early_init_dt_scan_memory_ppc(unsigned long node,
492 501
493void __init early_init_dt_add_memory_arch(u64 base, u64 size) 502void __init early_init_dt_add_memory_arch(u64 base, u64 size)
494{ 503{
495#if defined(CONFIG_PPC64) 504#ifdef CONFIG_PPC64
496 if (iommu_is_off) { 505 if (iommu_is_off) {
497 if (base >= 0x80000000ul) 506 if (base >= 0x80000000ul)
498 return; 507 return;
@@ -501,9 +510,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
501 } 510 }
502#endif 511#endif
503 512
504 memblock_add(base, size); 513 /* First MEMBLOCK added, do some special initializations */
505 514 if (memstart_addr == ~(phys_addr_t)0)
515 setup_initial_memory_limit(base, size);
506 memstart_addr = min((u64)memstart_addr, base); 516 memstart_addr = min((u64)memstart_addr, base);
517
518 /* Add the chunk to the MEMBLOCK list */
519 memblock_add(base, size);
507} 520}
508 521
509u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 522u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
@@ -655,7 +668,6 @@ static void __init phyp_dump_reserve_mem(void)
655static inline void __init phyp_dump_reserve_mem(void) {} 668static inline void __init phyp_dump_reserve_mem(void) {}
656#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ 669#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */
657 670
658
659void __init early_init_devtree(void *params) 671void __init early_init_devtree(void *params)
660{ 672{
661 phys_addr_t limit; 673 phys_addr_t limit;
@@ -679,10 +691,11 @@ void __init early_init_devtree(void *params)
679 * device-tree, including the platform type, initrd location and 691 * device-tree, including the platform type, initrd location and
680 * size, TCE reserve, and more ... 692 * size, TCE reserve, and more ...
681 */ 693 */
682 of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 694 of_scan_flat_dt(early_init_dt_scan_chosen_ppc, NULL);
683 695
684 /* Scan memory nodes and rebuild MEMBLOCKs */ 696 /* Scan memory nodes and rebuild MEMBLOCKs */
685 memblock_init(); 697 memblock_init();
698
686 of_scan_flat_dt(early_init_dt_scan_root, NULL); 699 of_scan_flat_dt(early_init_dt_scan_root, NULL);
687 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); 700 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
688 701
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 11f3cd9c832f..286d9783d93f 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1681,7 +1681,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
1681 1681
1682 if (unlikely(current->audit_context)) { 1682 if (unlikely(current->audit_context)) {
1683#ifdef CONFIG_PPC64 1683#ifdef CONFIG_PPC64
1684 if (!test_thread_flag(TIF_32BIT)) 1684 if (!is_32bit_task())
1685 audit_syscall_entry(AUDIT_ARCH_PPC64, 1685 audit_syscall_entry(AUDIT_ARCH_PPC64,
1686 regs->gpr[0], 1686 regs->gpr[0],
1687 regs->gpr[3], regs->gpr[4], 1687 regs->gpr[3], regs->gpr[4],
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 41048de3c6c3..8fe8bc61c10a 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -805,7 +805,7 @@ static void rtas_percpu_suspend_me(void *info)
805 __rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1); 805 __rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1);
806} 806}
807 807
808static int rtas_ibm_suspend_me(struct rtas_args *args) 808int rtas_ibm_suspend_me(struct rtas_args *args)
809{ 809{
810 long state; 810 long state;
811 long rc; 811 long rc;
@@ -855,7 +855,7 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
855 return atomic_read(&data.error); 855 return atomic_read(&data.error);
856} 856}
857#else /* CONFIG_PPC_PSERIES */ 857#else /* CONFIG_PPC_PSERIES */
858static int rtas_ibm_suspend_me(struct rtas_args *args) 858int rtas_ibm_suspend_me(struct rtas_args *args)
859{ 859{
860 return -ENOSYS; 860 return -ENOSYS;
861} 861}
@@ -969,7 +969,7 @@ void __init rtas_initialize(void)
969 */ 969 */
970#ifdef CONFIG_PPC64 970#ifdef CONFIG_PPC64
971 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) { 971 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) {
972 rtas_region = min(memblock.rmo_size, RTAS_INSTANTIATE_MAX); 972 rtas_region = min(ppc64_rma_size, RTAS_INSTANTIATE_MAX);
973 ibm_suspend_me_token = rtas_token("ibm,suspend-me"); 973 ibm_suspend_me_token = rtas_token("ibm,suspend-me");
974 } 974 }
975#endif 975#endif
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 67a84d8f118d..2b442e6c21e6 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -716,6 +716,7 @@ static const struct file_operations rtas_flash_operations = {
716 .write = rtas_flash_write, 716 .write = rtas_flash_write,
717 .open = rtas_excl_open, 717 .open = rtas_excl_open,
718 .release = rtas_flash_release, 718 .release = rtas_flash_release,
719 .llseek = default_llseek,
719}; 720};
720 721
721static const struct file_operations manage_flash_operations = { 722static const struct file_operations manage_flash_operations = {
@@ -724,6 +725,7 @@ static const struct file_operations manage_flash_operations = {
724 .write = manage_flash_write, 725 .write = manage_flash_write,
725 .open = rtas_excl_open, 726 .open = rtas_excl_open,
726 .release = rtas_excl_release, 727 .release = rtas_excl_release,
728 .llseek = default_llseek,
727}; 729};
728 730
729static const struct file_operations validate_flash_operations = { 731static const struct file_operations validate_flash_operations = {
@@ -732,6 +734,7 @@ static const struct file_operations validate_flash_operations = {
732 .write = validate_flash_write, 734 .write = validate_flash_write,
733 .open = rtas_excl_open, 735 .open = rtas_excl_open,
734 .release = validate_flash_release, 736 .release = validate_flash_release,
737 .llseek = default_llseek,
735}; 738};
736 739
737static int __init rtas_flash_init(void) 740static int __init rtas_flash_init(void)
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index 638883e23e3a..0438f819fe6b 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -354,6 +354,7 @@ static const struct file_operations proc_rtas_log_operations = {
354 .poll = rtas_log_poll, 354 .poll = rtas_log_poll,
355 .open = rtas_log_open, 355 .open = rtas_log_open,
356 .release = rtas_log_release, 356 .release = rtas_log_release,
357 .llseek = noop_llseek,
357}; 358};
358 359
359static int enable_surveillance(int timeout) 360static int enable_surveillance(int timeout)
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 93666f9cabf1..1d2fbc905303 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -46,7 +46,7 @@
46 46
47extern void bootx_init(unsigned long r4, unsigned long phys); 47extern void bootx_init(unsigned long r4, unsigned long phys);
48 48
49int boot_cpuid; 49int boot_cpuid = -1;
50EXPORT_SYMBOL_GPL(boot_cpuid); 50EXPORT_SYMBOL_GPL(boot_cpuid);
51int boot_cpuid_phys; 51int boot_cpuid_phys;
52 52
@@ -246,7 +246,7 @@ static void __init irqstack_early_init(void)
246 unsigned int i; 246 unsigned int i;
247 247
248 /* interrupt stacks must be in lowmem, we get that for free on ppc32 248 /* interrupt stacks must be in lowmem, we get that for free on ppc32
249 * as the memblock is limited to lowmem by MEMBLOCK_REAL_LIMIT */ 249 * as the memblock is limited to lowmem by default */
250 for_each_possible_cpu(i) { 250 for_each_possible_cpu(i) {
251 softirq_ctx[i] = (struct thread_info *) 251 softirq_ctx[i] = (struct thread_info *)
252 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE)); 252 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index e72690ec9b87..2a178b0ebcdf 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -486,7 +486,7 @@ static void __init emergency_stack_init(void)
486 * bringup, we need to get at them in real mode. This means they 486 * bringup, we need to get at them in real mode. This means they
487 * must also be within the RMO region. 487 * must also be within the RMO region.
488 */ 488 */
489 limit = min(slb0_limit(), memblock.rmo_size); 489 limit = min(slb0_limit(), ppc64_rma_size);
490 490
491 for_each_possible_cpu(i) { 491 for_each_possible_cpu(i) {
492 unsigned long sp; 492 unsigned long sp;
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 0008bc58e826..68034bbf2e4f 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -508,9 +508,6 @@ int __devinit start_secondary(void *unused)
508 if (smp_ops->take_timebase) 508 if (smp_ops->take_timebase)
509 smp_ops->take_timebase(); 509 smp_ops->take_timebase();
510 510
511 if (system_state > SYSTEM_BOOTING)
512 snapshot_timebase();
513
514 secondary_cpu_time_init(); 511 secondary_cpu_time_init();
515 512
516 ipi_call_lock(); 513 ipi_call_lock();
@@ -575,11 +572,18 @@ void __init smp_cpus_done(unsigned int max_cpus)
575 572
576 free_cpumask_var(old_mask); 573 free_cpumask_var(old_mask);
577 574
578 snapshot_timebases();
579
580 dump_numa_cpu_topology(); 575 dump_numa_cpu_topology();
581} 576}
582 577
578int arch_sd_sibling_asym_packing(void)
579{
580 if (cpu_has_feature(CPU_FTR_ASYM_SMT)) {
581 printk_once(KERN_INFO "Enabling Asymmetric SMT scheduling\n");
582 return SD_ASYM_PACKING;
583 }
584 return 0;
585}
586
583#ifdef CONFIG_HOTPLUG_CPU 587#ifdef CONFIG_HOTPLUG_CPU
584int __cpu_disable(void) 588int __cpu_disable(void)
585{ 589{
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 8533b3b83f5d..010406958d97 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -53,7 +53,7 @@
53#include <linux/posix-timers.h> 53#include <linux/posix-timers.h>
54#include <linux/irq.h> 54#include <linux/irq.h>
55#include <linux/delay.h> 55#include <linux/delay.h>
56#include <linux/perf_event.h> 56#include <linux/irq_work.h>
57#include <asm/trace.h> 57#include <asm/trace.h>
58 58
59#include <asm/io.h> 59#include <asm/io.h>
@@ -161,10 +161,9 @@ extern struct timezone sys_tz;
161static long timezone_offset; 161static long timezone_offset;
162 162
163unsigned long ppc_proc_freq; 163unsigned long ppc_proc_freq;
164EXPORT_SYMBOL(ppc_proc_freq); 164EXPORT_SYMBOL_GPL(ppc_proc_freq);
165unsigned long ppc_tb_freq; 165unsigned long ppc_tb_freq;
166 166EXPORT_SYMBOL_GPL(ppc_tb_freq);
167static DEFINE_PER_CPU(u64, last_jiffy);
168 167
169#ifdef CONFIG_VIRT_CPU_ACCOUNTING 168#ifdef CONFIG_VIRT_CPU_ACCOUNTING
170/* 169/*
@@ -185,6 +184,8 @@ DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta);
185 184
186cputime_t cputime_one_jiffy; 185cputime_t cputime_one_jiffy;
187 186
187void (*dtl_consumer)(struct dtl_entry *, u64);
188
188static void calc_cputime_factors(void) 189static void calc_cputime_factors(void)
189{ 190{
190 struct div_result res; 191 struct div_result res;
@@ -200,62 +201,153 @@ static void calc_cputime_factors(void)
200} 201}
201 202
202/* 203/*
203 * Read the PURR on systems that have it, otherwise the timebase. 204 * Read the SPURR on systems that have it, otherwise the PURR,
205 * or if that doesn't exist return the timebase value passed in.
204 */ 206 */
205static u64 read_purr(void) 207static u64 read_spurr(u64 tb)
206{ 208{
209 if (cpu_has_feature(CPU_FTR_SPURR))
210 return mfspr(SPRN_SPURR);
207 if (cpu_has_feature(CPU_FTR_PURR)) 211 if (cpu_has_feature(CPU_FTR_PURR))
208 return mfspr(SPRN_PURR); 212 return mfspr(SPRN_PURR);
209 return mftb(); 213 return tb;
210} 214}
211 215
216#ifdef CONFIG_PPC_SPLPAR
217
212/* 218/*
213 * Read the SPURR on systems that have it, otherwise the purr 219 * Scan the dispatch trace log and count up the stolen time.
220 * Should be called with interrupts disabled.
214 */ 221 */
215static u64 read_spurr(u64 purr) 222static u64 scan_dispatch_log(u64 stop_tb)
216{ 223{
217 /* 224 u64 i = local_paca->dtl_ridx;
218 * cpus without PURR won't have a SPURR 225 struct dtl_entry *dtl = local_paca->dtl_curr;
219 * We already know the former when we use this, so tell gcc 226 struct dtl_entry *dtl_end = local_paca->dispatch_log_end;
220 */ 227 struct lppaca *vpa = local_paca->lppaca_ptr;
221 if (cpu_has_feature(CPU_FTR_PURR) && cpu_has_feature(CPU_FTR_SPURR)) 228 u64 tb_delta;
222 return mfspr(SPRN_SPURR); 229 u64 stolen = 0;
223 return purr; 230 u64 dtb;
231
232 if (i == vpa->dtl_idx)
233 return 0;
234 while (i < vpa->dtl_idx) {
235 if (dtl_consumer)
236 dtl_consumer(dtl, i);
237 dtb = dtl->timebase;
238 tb_delta = dtl->enqueue_to_dispatch_time +
239 dtl->ready_to_enqueue_time;
240 barrier();
241 if (i + N_DISPATCH_LOG < vpa->dtl_idx) {
242 /* buffer has overflowed */
243 i = vpa->dtl_idx - N_DISPATCH_LOG;
244 dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG);
245 continue;
246 }
247 if (dtb > stop_tb)
248 break;
249 stolen += tb_delta;
250 ++i;
251 ++dtl;
252 if (dtl == dtl_end)
253 dtl = local_paca->dispatch_log;
254 }
255 local_paca->dtl_ridx = i;
256 local_paca->dtl_curr = dtl;
257 return stolen;
224} 258}
225 259
226/* 260/*
261 * Accumulate stolen time by scanning the dispatch trace log.
262 * Called on entry from user mode.
263 */
264void accumulate_stolen_time(void)
265{
266 u64 sst, ust;
267
268 sst = scan_dispatch_log(get_paca()->starttime_user);
269 ust = scan_dispatch_log(get_paca()->starttime);
270 get_paca()->system_time -= sst;
271 get_paca()->user_time -= ust;
272 get_paca()->stolen_time += ust + sst;
273}
274
275static inline u64 calculate_stolen_time(u64 stop_tb)
276{
277 u64 stolen = 0;
278
279 if (get_paca()->dtl_ridx != get_paca()->lppaca_ptr->dtl_idx) {
280 stolen = scan_dispatch_log(stop_tb);
281 get_paca()->system_time -= stolen;
282 }
283
284 stolen += get_paca()->stolen_time;
285 get_paca()->stolen_time = 0;
286 return stolen;
287}
288
289#else /* CONFIG_PPC_SPLPAR */
290static inline u64 calculate_stolen_time(u64 stop_tb)
291{
292 return 0;
293}
294
295#endif /* CONFIG_PPC_SPLPAR */
296
297/*
227 * Account time for a transition between system, hard irq 298 * Account time for a transition between system, hard irq
228 * or soft irq state. 299 * or soft irq state.
229 */ 300 */
230void account_system_vtime(struct task_struct *tsk) 301void account_system_vtime(struct task_struct *tsk)
231{ 302{
232 u64 now, nowscaled, delta, deltascaled, sys_time; 303 u64 now, nowscaled, delta, deltascaled;
233 unsigned long flags; 304 unsigned long flags;
305 u64 stolen, udelta, sys_scaled, user_scaled;
234 306
235 local_irq_save(flags); 307 local_irq_save(flags);
236 now = read_purr(); 308 now = mftb();
237 nowscaled = read_spurr(now); 309 nowscaled = read_spurr(now);
238 delta = now - get_paca()->startpurr; 310 get_paca()->system_time += now - get_paca()->starttime;
311 get_paca()->starttime = now;
239 deltascaled = nowscaled - get_paca()->startspurr; 312 deltascaled = nowscaled - get_paca()->startspurr;
240 get_paca()->startpurr = now;
241 get_paca()->startspurr = nowscaled; 313 get_paca()->startspurr = nowscaled;
242 if (!in_interrupt()) { 314
243 /* deltascaled includes both user and system time. 315 stolen = calculate_stolen_time(now);
244 * Hence scale it based on the purr ratio to estimate 316
245 * the system time */ 317 delta = get_paca()->system_time;
246 sys_time = get_paca()->system_time; 318 get_paca()->system_time = 0;
247 if (get_paca()->user_time) 319 udelta = get_paca()->user_time - get_paca()->utime_sspurr;
248 deltascaled = deltascaled * sys_time / 320 get_paca()->utime_sspurr = get_paca()->user_time;
249 (sys_time + get_paca()->user_time); 321
250 delta += sys_time; 322 /*
251 get_paca()->system_time = 0; 323 * Because we don't read the SPURR on every kernel entry/exit,
324 * deltascaled includes both user and system SPURR ticks.
325 * Apportion these ticks to system SPURR ticks and user
326 * SPURR ticks in the same ratio as the system time (delta)
327 * and user time (udelta) values obtained from the timebase
328 * over the same interval. The system ticks get accounted here;
329 * the user ticks get saved up in paca->user_time_scaled to be
330 * used by account_process_tick.
331 */
332 sys_scaled = delta;
333 user_scaled = udelta;
334 if (deltascaled != delta + udelta) {
335 if (udelta) {
336 sys_scaled = deltascaled * delta / (delta + udelta);
337 user_scaled = deltascaled - sys_scaled;
338 } else {
339 sys_scaled = deltascaled;
340 }
341 }
342 get_paca()->user_time_scaled += user_scaled;
343
344 if (in_irq() || idle_task(smp_processor_id()) != tsk) {
345 account_system_time(tsk, 0, delta, sys_scaled);
346 if (stolen)
347 account_steal_time(stolen);
348 } else {
349 account_idle_time(delta + stolen);
252 } 350 }
253 if (in_irq() || idle_task(smp_processor_id()) != tsk)
254 account_system_time(tsk, 0, delta, deltascaled);
255 else
256 account_idle_time(delta);
257 __get_cpu_var(cputime_last_delta) = delta;
258 __get_cpu_var(cputime_scaled_last_delta) = deltascaled;
259 local_irq_restore(flags); 351 local_irq_restore(flags);
260} 352}
261EXPORT_SYMBOL_GPL(account_system_vtime); 353EXPORT_SYMBOL_GPL(account_system_vtime);
@@ -265,125 +357,26 @@ EXPORT_SYMBOL_GPL(account_system_vtime);
265 * by the exception entry and exit code to the generic process 357 * by the exception entry and exit code to the generic process
266 * user and system time records. 358 * user and system time records.
267 * Must be called with interrupts disabled. 359 * Must be called with interrupts disabled.
360 * Assumes that account_system_vtime() has been called recently
361 * (i.e. since the last entry from usermode) so that
362 * get_paca()->user_time_scaled is up to date.
268 */ 363 */
269void account_process_tick(struct task_struct *tsk, int user_tick) 364void account_process_tick(struct task_struct *tsk, int user_tick)
270{ 365{
271 cputime_t utime, utimescaled; 366 cputime_t utime, utimescaled;
272 367
273 utime = get_paca()->user_time; 368 utime = get_paca()->user_time;
369 utimescaled = get_paca()->user_time_scaled;
274 get_paca()->user_time = 0; 370 get_paca()->user_time = 0;
275 utimescaled = cputime_to_scaled(utime); 371 get_paca()->user_time_scaled = 0;
372 get_paca()->utime_sspurr = 0;
276 account_user_time(tsk, utime, utimescaled); 373 account_user_time(tsk, utime, utimescaled);
277} 374}
278 375
279/*
280 * Stuff for accounting stolen time.
281 */
282struct cpu_purr_data {
283 int initialized; /* thread is running */
284 u64 tb; /* last TB value read */
285 u64 purr; /* last PURR value read */
286 u64 spurr; /* last SPURR value read */
287};
288
289/*
290 * Each entry in the cpu_purr_data array is manipulated only by its
291 * "owner" cpu -- usually in the timer interrupt but also occasionally
292 * in process context for cpu online. As long as cpus do not touch
293 * each others' cpu_purr_data, disabling local interrupts is
294 * sufficient to serialize accesses.
295 */
296static DEFINE_PER_CPU(struct cpu_purr_data, cpu_purr_data);
297
298static void snapshot_tb_and_purr(void *data)
299{
300 unsigned long flags;
301 struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data);
302
303 local_irq_save(flags);
304 p->tb = get_tb_or_rtc();
305 p->purr = mfspr(SPRN_PURR);
306 wmb();
307 p->initialized = 1;
308 local_irq_restore(flags);
309}
310
311/*
312 * Called during boot when all cpus have come up.
313 */
314void snapshot_timebases(void)
315{
316 if (!cpu_has_feature(CPU_FTR_PURR))
317 return;
318 on_each_cpu(snapshot_tb_and_purr, NULL, 1);
319}
320
321/*
322 * Must be called with interrupts disabled.
323 */
324void calculate_steal_time(void)
325{
326 u64 tb, purr;
327 s64 stolen;
328 struct cpu_purr_data *pme;
329
330 pme = &__get_cpu_var(cpu_purr_data);
331 if (!pme->initialized)
332 return; /* !CPU_FTR_PURR or early in early boot */
333 tb = mftb();
334 purr = mfspr(SPRN_PURR);
335 stolen = (tb - pme->tb) - (purr - pme->purr);
336 if (stolen > 0) {
337 if (idle_task(smp_processor_id()) != current)
338 account_steal_time(stolen);
339 else
340 account_idle_time(stolen);
341 }
342 pme->tb = tb;
343 pme->purr = purr;
344}
345
346#ifdef CONFIG_PPC_SPLPAR
347/*
348 * Must be called before the cpu is added to the online map when
349 * a cpu is being brought up at runtime.
350 */
351static void snapshot_purr(void)
352{
353 struct cpu_purr_data *pme;
354 unsigned long flags;
355
356 if (!cpu_has_feature(CPU_FTR_PURR))
357 return;
358 local_irq_save(flags);
359 pme = &__get_cpu_var(cpu_purr_data);
360 pme->tb = mftb();
361 pme->purr = mfspr(SPRN_PURR);
362 pme->initialized = 1;
363 local_irq_restore(flags);
364}
365
366#endif /* CONFIG_PPC_SPLPAR */
367
368#else /* ! CONFIG_VIRT_CPU_ACCOUNTING */ 376#else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
369#define calc_cputime_factors() 377#define calc_cputime_factors()
370#define calculate_steal_time() do { } while (0)
371#endif 378#endif
372 379
373#if !(defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR))
374#define snapshot_purr() do { } while (0)
375#endif
376
377/*
378 * Called when a cpu comes up after the system has finished booting,
379 * i.e. as a result of a hotplug cpu action.
380 */
381void snapshot_timebase(void)
382{
383 __get_cpu_var(last_jiffy) = get_tb_or_rtc();
384 snapshot_purr();
385}
386
387void __delay(unsigned long loops) 380void __delay(unsigned long loops)
388{ 381{
389 unsigned long start; 382 unsigned long start;
@@ -493,60 +486,60 @@ void __init iSeries_time_init_early(void)
493} 486}
494#endif /* CONFIG_PPC_ISERIES */ 487#endif /* CONFIG_PPC_ISERIES */
495 488
496#ifdef CONFIG_PERF_EVENTS 489#ifdef CONFIG_IRQ_WORK
497 490
498/* 491/*
499 * 64-bit uses a byte in the PACA, 32-bit uses a per-cpu variable... 492 * 64-bit uses a byte in the PACA, 32-bit uses a per-cpu variable...
500 */ 493 */
501#ifdef CONFIG_PPC64 494#ifdef CONFIG_PPC64
502static inline unsigned long test_perf_event_pending(void) 495static inline unsigned long test_irq_work_pending(void)
503{ 496{
504 unsigned long x; 497 unsigned long x;
505 498
506 asm volatile("lbz %0,%1(13)" 499 asm volatile("lbz %0,%1(13)"
507 : "=r" (x) 500 : "=r" (x)
508 : "i" (offsetof(struct paca_struct, perf_event_pending))); 501 : "i" (offsetof(struct paca_struct, irq_work_pending)));
509 return x; 502 return x;
510} 503}
511 504
512static inline void set_perf_event_pending_flag(void) 505static inline void set_irq_work_pending_flag(void)
513{ 506{
514 asm volatile("stb %0,%1(13)" : : 507 asm volatile("stb %0,%1(13)" : :
515 "r" (1), 508 "r" (1),
516 "i" (offsetof(struct paca_struct, perf_event_pending))); 509 "i" (offsetof(struct paca_struct, irq_work_pending)));
517} 510}
518 511
519static inline void clear_perf_event_pending(void) 512static inline void clear_irq_work_pending(void)
520{ 513{
521 asm volatile("stb %0,%1(13)" : : 514 asm volatile("stb %0,%1(13)" : :
522 "r" (0), 515 "r" (0),
523 "i" (offsetof(struct paca_struct, perf_event_pending))); 516 "i" (offsetof(struct paca_struct, irq_work_pending)));
524} 517}
525 518
526#else /* 32-bit */ 519#else /* 32-bit */
527 520
528DEFINE_PER_CPU(u8, perf_event_pending); 521DEFINE_PER_CPU(u8, irq_work_pending);
529 522
530#define set_perf_event_pending_flag() __get_cpu_var(perf_event_pending) = 1 523#define set_irq_work_pending_flag() __get_cpu_var(irq_work_pending) = 1
531#define test_perf_event_pending() __get_cpu_var(perf_event_pending) 524#define test_irq_work_pending() __get_cpu_var(irq_work_pending)
532#define clear_perf_event_pending() __get_cpu_var(perf_event_pending) = 0 525#define clear_irq_work_pending() __get_cpu_var(irq_work_pending) = 0
533 526
534#endif /* 32 vs 64 bit */ 527#endif /* 32 vs 64 bit */
535 528
536void set_perf_event_pending(void) 529void set_irq_work_pending(void)
537{ 530{
538 preempt_disable(); 531 preempt_disable();
539 set_perf_event_pending_flag(); 532 set_irq_work_pending_flag();
540 set_dec(1); 533 set_dec(1);
541 preempt_enable(); 534 preempt_enable();
542} 535}
543 536
544#else /* CONFIG_PERF_EVENTS */ 537#else /* CONFIG_IRQ_WORK */
545 538
546#define test_perf_event_pending() 0 539#define test_irq_work_pending() 0
547#define clear_perf_event_pending() 540#define clear_irq_work_pending()
548 541
549#endif /* CONFIG_PERF_EVENTS */ 542#endif /* CONFIG_IRQ_WORK */
550 543
551/* 544/*
552 * For iSeries shared processors, we have to let the hypervisor 545 * For iSeries shared processors, we have to let the hypervisor
@@ -585,11 +578,9 @@ void timer_interrupt(struct pt_regs * regs)
585 old_regs = set_irq_regs(regs); 578 old_regs = set_irq_regs(regs);
586 irq_enter(); 579 irq_enter();
587 580
588 calculate_steal_time(); 581 if (test_irq_work_pending()) {
589 582 clear_irq_work_pending();
590 if (test_perf_event_pending()) { 583 irq_work_run();
591 clear_perf_event_pending();
592 perf_event_do_pending();
593 } 584 }
594 585
595#ifdef CONFIG_PPC_ISERIES 586#ifdef CONFIG_PPC_ISERIES
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index a45a63c3a0c7..1b2cdc8eec90 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -538,6 +538,11 @@ int machine_check_e500(struct pt_regs *regs)
538 538
539 return 0; 539 return 0;
540} 540}
541
542int machine_check_generic(struct pt_regs *regs)
543{
544 return 0;
545}
541#elif defined(CONFIG_E200) 546#elif defined(CONFIG_E200)
542int machine_check_e200(struct pt_regs *regs) 547int machine_check_e200(struct pt_regs *regs)
543{ 548{
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 13002fe206e7..fd8728729abc 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -159,7 +159,7 @@ static void dump_vdso_pages(struct vm_area_struct * vma)
159{ 159{
160 int i; 160 int i;
161 161
162 if (!vma || test_thread_flag(TIF_32BIT)) { 162 if (!vma || is_32bit_task()) {
163 printk("vDSO32 @ %016lx:\n", (unsigned long)vdso32_kbase); 163 printk("vDSO32 @ %016lx:\n", (unsigned long)vdso32_kbase);
164 for (i=0; i<vdso32_pages; i++) { 164 for (i=0; i<vdso32_pages; i++) {
165 struct page *pg = virt_to_page(vdso32_kbase + 165 struct page *pg = virt_to_page(vdso32_kbase +
@@ -170,7 +170,7 @@ static void dump_vdso_pages(struct vm_area_struct * vma)
170 dump_one_vdso_page(pg, upg); 170 dump_one_vdso_page(pg, upg);
171 } 171 }
172 } 172 }
173 if (!vma || !test_thread_flag(TIF_32BIT)) { 173 if (!vma || !is_32bit_task()) {
174 printk("vDSO64 @ %016lx:\n", (unsigned long)vdso64_kbase); 174 printk("vDSO64 @ %016lx:\n", (unsigned long)vdso64_kbase);
175 for (i=0; i<vdso64_pages; i++) { 175 for (i=0; i<vdso64_pages; i++) {
176 struct page *pg = virt_to_page(vdso64_kbase + 176 struct page *pg = virt_to_page(vdso64_kbase +
@@ -200,7 +200,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
200 return 0; 200 return 0;
201 201
202#ifdef CONFIG_PPC64 202#ifdef CONFIG_PPC64
203 if (test_thread_flag(TIF_32BIT)) { 203 if (is_32bit_task()) {
204 vdso_pagelist = vdso32_pagelist; 204 vdso_pagelist = vdso32_pagelist;
205 vdso_pages = vdso32_pages; 205 vdso_pages = vdso32_pages;
206 vdso_base = VDSO32_MBASE; 206 vdso_base = VDSO32_MBASE;
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index 51ead52141bd..9a7946c41738 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -14,10 +14,10 @@ obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
14 14
15GCOV_PROFILE := n 15GCOV_PROFILE := n
16 16
17EXTRA_CFLAGS := -shared -fno-common -fno-builtin 17ccflags-y := -shared -fno-common -fno-builtin
18EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso32.so.1 \ 18ccflags-y += -nostdlib -Wl,-soname=linux-vdso32.so.1 \
19 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 19 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
20EXTRA_AFLAGS := -D__VDSO32__ -s 20asflags-y := -D__VDSO32__ -s
21 21
22obj-y += vdso32_wrapper.o 22obj-y += vdso32_wrapper.o
23extra-y += vdso32.lds 23extra-y += vdso32.lds
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
index 79da65d44a2a..8c500d8622e4 100644
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -9,10 +9,10 @@ obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
9 9
10GCOV_PROFILE := n 10GCOV_PROFILE := n
11 11
12EXTRA_CFLAGS := -shared -fno-common -fno-builtin 12ccflags-y := -shared -fno-common -fno-builtin
13EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ 13ccflags-y += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
14 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) 14 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
15EXTRA_AFLAGS := -D__VDSO64__ -s 15asflags-y := -D__VDSO64__ -s
16 16
17obj-y += vdso64_wrapper.o 17obj-y += vdso64_wrapper.o
18extra-y += vdso64.lds 18extra-y += vdso64.lds
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index fa3469ddaef8..d692989a4318 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1184,7 +1184,12 @@ EXPORT_SYMBOL(vio_unregister_driver);
1184/* vio_dev refcount hit 0 */ 1184/* vio_dev refcount hit 0 */
1185static void __devinit vio_dev_release(struct device *dev) 1185static void __devinit vio_dev_release(struct device *dev)
1186{ 1186{
1187 /* XXX should free TCE table */ 1187 struct iommu_table *tbl = get_iommu_table_base(dev);
1188
1189 /* iSeries uses a common table for all vio devices */
1190 if (!firmware_has_feature(FW_FEATURE_ISERIES) && tbl)
1191 iommu_free_table(tbl, dev->of_node ?
1192 dev->of_node->full_name : dev_name(dev));
1188 of_node_put(dev->of_node); 1193 of_node_put(dev->of_node);
1189 kfree(to_vio_dev(dev)); 1194 kfree(to_vio_dev(dev));
1190} 1195}
@@ -1254,8 +1259,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1254 if (device_register(&viodev->dev)) { 1259 if (device_register(&viodev->dev)) {
1255 printk(KERN_ERR "%s: failed to register device %s\n", 1260 printk(KERN_ERR "%s: failed to register device %s\n",
1256 __func__, dev_name(&viodev->dev)); 1261 __func__, dev_name(&viodev->dev));
1257 /* XXX free TCE table */ 1262 put_device(&viodev->dev);
1258 kfree(viodev);
1259 return NULL; 1263 return NULL;
1260 } 1264 }
1261 1265
diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c
index 73c0a3f64ed1..74d0e7421143 100644
--- a/arch/powerpc/kvm/44x.c
+++ b/arch/powerpc/kvm/44x.c
@@ -43,7 +43,7 @@ int kvmppc_core_check_processor_compat(void)
43{ 43{
44 int r; 44 int r;
45 45
46 if (strcmp(cur_cpu_spec->platform, "ppc440") == 0) 46 if (strncmp(cur_cpu_spec->platform, "ppc440", 6) == 0)
47 r = 0; 47 r = 0;
48 else 48 else
49 r = -ENOTSUPP; 49 r = -ENOTSUPP;
@@ -72,6 +72,7 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
72 /* Since the guest can directly access the timebase, it must know the 72 /* Since the guest can directly access the timebase, it must know the
73 * real timebase frequency. Accordingly, it must see the state of 73 * real timebase frequency. Accordingly, it must see the state of
74 * CCR1[TCS]. */ 74 * CCR1[TCS]. */
75 /* XXX CCR1 doesn't exist on all 440 SoCs. */
75 vcpu->arch.ccr1 = mfspr(SPRN_CCR1); 76 vcpu->arch.ccr1 = mfspr(SPRN_CCR1);
76 77
77 for (i = 0; i < ARRAY_SIZE(vcpu_44x->shadow_refs); i++) 78 for (i = 0; i < ARRAY_SIZE(vcpu_44x->shadow_refs); i++)
@@ -123,8 +124,14 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
123 if (err) 124 if (err)
124 goto free_vcpu; 125 goto free_vcpu;
125 126
127 vcpu->arch.shared = (void*)__get_free_page(GFP_KERNEL|__GFP_ZERO);
128 if (!vcpu->arch.shared)
129 goto uninit_vcpu;
130
126 return vcpu; 131 return vcpu;
127 132
133uninit_vcpu:
134 kvm_vcpu_uninit(vcpu);
128free_vcpu: 135free_vcpu:
129 kmem_cache_free(kvm_vcpu_cache, vcpu_44x); 136 kmem_cache_free(kvm_vcpu_cache, vcpu_44x);
130out: 137out:
@@ -135,6 +142,7 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
135{ 142{
136 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu); 143 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
137 144
145 free_page((unsigned long)vcpu->arch.shared);
138 kvm_vcpu_uninit(vcpu); 146 kvm_vcpu_uninit(vcpu);
139 kmem_cache_free(kvm_vcpu_cache, vcpu_44x); 147 kmem_cache_free(kvm_vcpu_cache, vcpu_44x);
140} 148}
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index 9b9b5cdea840..5f3cff83e089 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -47,6 +47,7 @@
47#ifdef DEBUG 47#ifdef DEBUG
48void kvmppc_dump_tlbs(struct kvm_vcpu *vcpu) 48void kvmppc_dump_tlbs(struct kvm_vcpu *vcpu)
49{ 49{
50 struct kvmppc_vcpu_44x *vcpu_44x = to_44x(vcpu);
50 struct kvmppc_44x_tlbe *tlbe; 51 struct kvmppc_44x_tlbe *tlbe;
51 int i; 52 int i;
52 53
@@ -221,14 +222,14 @@ gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index,
221 222
222int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr) 223int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
223{ 224{
224 unsigned int as = !!(vcpu->arch.msr & MSR_IS); 225 unsigned int as = !!(vcpu->arch.shared->msr & MSR_IS);
225 226
226 return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as); 227 return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as);
227} 228}
228 229
229int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr) 230int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
230{ 231{
231 unsigned int as = !!(vcpu->arch.msr & MSR_DS); 232 unsigned int as = !!(vcpu->arch.shared->msr & MSR_DS);
232 233
233 return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as); 234 return kvmppc_44x_tlb_index(vcpu, eaddr, vcpu->arch.pid, as);
234} 235}
@@ -354,7 +355,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr,
354 355
355 stlbe.word1 = (hpaddr & 0xfffffc00) | ((hpaddr >> 32) & 0xf); 356 stlbe.word1 = (hpaddr & 0xfffffc00) | ((hpaddr >> 32) & 0xf);
356 stlbe.word2 = kvmppc_44x_tlb_shadow_attrib(flags, 357 stlbe.word2 = kvmppc_44x_tlb_shadow_attrib(flags,
357 vcpu->arch.msr & MSR_PR); 358 vcpu->arch.shared->msr & MSR_PR);
358 stlbe.tid = !(asid & 0xff); 359 stlbe.tid = !(asid & 0xff);
359 360
360 /* Keep track of the reference so we can properly release it later. */ 361 /* Keep track of the reference so we can properly release it later. */
@@ -423,7 +424,7 @@ static int tlbe_is_host_safe(const struct kvm_vcpu *vcpu,
423 424
424 /* Does it match current guest AS? */ 425 /* Does it match current guest AS? */
425 /* XXX what about IS != DS? */ 426 /* XXX what about IS != DS? */
426 if (get_tlb_ts(tlbe) != !!(vcpu->arch.msr & MSR_IS)) 427 if (get_tlb_ts(tlbe) != !!(vcpu->arch.shared->msr & MSR_IS))
427 return 0; 428 return 0;
428 429
429 gpa = get_tlb_raddr(tlbe); 430 gpa = get_tlb_raddr(tlbe);
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index d45c818a384c..4d6863823f69 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -4,7 +4,7 @@
4 4
5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
6 6
7EXTRA_CFLAGS += -Ivirt/kvm -Iarch/powerpc/kvm 7ccflags-y := -Ivirt/kvm -Iarch/powerpc/kvm
8 8
9common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o) 9common-objs-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o)
10 10
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index a3cef30d1d42..e316847c08c0 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -17,6 +17,7 @@
17#include <linux/kvm_host.h> 17#include <linux/kvm_host.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include "trace.h"
20 21
21#include <asm/reg.h> 22#include <asm/reg.h>
22#include <asm/cputable.h> 23#include <asm/cputable.h>
@@ -35,7 +36,6 @@
35#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU 36#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
36 37
37/* #define EXIT_DEBUG */ 38/* #define EXIT_DEBUG */
38/* #define EXIT_DEBUG_SIMPLE */
39/* #define DEBUG_EXT */ 39/* #define DEBUG_EXT */
40 40
41static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr, 41static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
@@ -105,65 +105,71 @@ void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu)
105 kvmppc_giveup_ext(vcpu, MSR_VSX); 105 kvmppc_giveup_ext(vcpu, MSR_VSX);
106} 106}
107 107
108#if defined(EXIT_DEBUG)
109static u32 kvmppc_get_dec(struct kvm_vcpu *vcpu)
110{
111 u64 jd = mftb() - vcpu->arch.dec_jiffies;
112 return vcpu->arch.dec - jd;
113}
114#endif
115
116static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu) 108static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu)
117{ 109{
118 vcpu->arch.shadow_msr = vcpu->arch.msr; 110 ulong smsr = vcpu->arch.shared->msr;
111
119 /* Guest MSR values */ 112 /* Guest MSR values */
120 vcpu->arch.shadow_msr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | 113 smsr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | MSR_BE | MSR_DE;
121 MSR_BE | MSR_DE;
122 /* Process MSR values */ 114 /* Process MSR values */
123 vcpu->arch.shadow_msr |= MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_PR | 115 smsr |= MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_PR | MSR_EE;
124 MSR_EE;
125 /* External providers the guest reserved */ 116 /* External providers the guest reserved */
126 vcpu->arch.shadow_msr |= (vcpu->arch.msr & vcpu->arch.guest_owned_ext); 117 smsr |= (vcpu->arch.shared->msr & vcpu->arch.guest_owned_ext);
127 /* 64-bit Process MSR values */ 118 /* 64-bit Process MSR values */
128#ifdef CONFIG_PPC_BOOK3S_64 119#ifdef CONFIG_PPC_BOOK3S_64
129 vcpu->arch.shadow_msr |= MSR_ISF | MSR_HV; 120 smsr |= MSR_ISF | MSR_HV;
130#endif 121#endif
122 vcpu->arch.shadow_msr = smsr;
131} 123}
132 124
133void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr) 125void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr)
134{ 126{
135 ulong old_msr = vcpu->arch.msr; 127 ulong old_msr = vcpu->arch.shared->msr;
136 128
137#ifdef EXIT_DEBUG 129#ifdef EXIT_DEBUG
138 printk(KERN_INFO "KVM: Set MSR to 0x%llx\n", msr); 130 printk(KERN_INFO "KVM: Set MSR to 0x%llx\n", msr);
139#endif 131#endif
140 132
141 msr &= to_book3s(vcpu)->msr_mask; 133 msr &= to_book3s(vcpu)->msr_mask;
142 vcpu->arch.msr = msr; 134 vcpu->arch.shared->msr = msr;
143 kvmppc_recalc_shadow_msr(vcpu); 135 kvmppc_recalc_shadow_msr(vcpu);
144 136
145 if (msr & (MSR_WE|MSR_POW)) { 137 if (msr & MSR_POW) {
146 if (!vcpu->arch.pending_exceptions) { 138 if (!vcpu->arch.pending_exceptions) {
147 kvm_vcpu_block(vcpu); 139 kvm_vcpu_block(vcpu);
148 vcpu->stat.halt_wakeup++; 140 vcpu->stat.halt_wakeup++;
141
142 /* Unset POW bit after we woke up */
143 msr &= ~MSR_POW;
144 vcpu->arch.shared->msr = msr;
149 } 145 }
150 } 146 }
151 147
152 if ((vcpu->arch.msr & (MSR_PR|MSR_IR|MSR_DR)) != 148 if ((vcpu->arch.shared->msr & (MSR_PR|MSR_IR|MSR_DR)) !=
153 (old_msr & (MSR_PR|MSR_IR|MSR_DR))) { 149 (old_msr & (MSR_PR|MSR_IR|MSR_DR))) {
154 kvmppc_mmu_flush_segments(vcpu); 150 kvmppc_mmu_flush_segments(vcpu);
155 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu)); 151 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu));
152
153 /* Preload magic page segment when in kernel mode */
154 if (!(msr & MSR_PR) && vcpu->arch.magic_page_pa) {
155 struct kvm_vcpu_arch *a = &vcpu->arch;
156
157 if (msr & MSR_DR)
158 kvmppc_mmu_map_segment(vcpu, a->magic_page_ea);
159 else
160 kvmppc_mmu_map_segment(vcpu, a->magic_page_pa);
161 }
156 } 162 }
157 163
158 /* Preload FPU if it's enabled */ 164 /* Preload FPU if it's enabled */
159 if (vcpu->arch.msr & MSR_FP) 165 if (vcpu->arch.shared->msr & MSR_FP)
160 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP); 166 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP);
161} 167}
162 168
163void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags) 169void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags)
164{ 170{
165 vcpu->arch.srr0 = kvmppc_get_pc(vcpu); 171 vcpu->arch.shared->srr0 = kvmppc_get_pc(vcpu);
166 vcpu->arch.srr1 = vcpu->arch.msr | flags; 172 vcpu->arch.shared->srr1 = vcpu->arch.shared->msr | flags;
167 kvmppc_set_pc(vcpu, to_book3s(vcpu)->hior + vec); 173 kvmppc_set_pc(vcpu, to_book3s(vcpu)->hior + vec);
168 vcpu->arch.mmu.reset_msr(vcpu); 174 vcpu->arch.mmu.reset_msr(vcpu);
169} 175}
@@ -180,6 +186,7 @@ static int kvmppc_book3s_vec2irqprio(unsigned int vec)
180 case 0x400: prio = BOOK3S_IRQPRIO_INST_STORAGE; break; 186 case 0x400: prio = BOOK3S_IRQPRIO_INST_STORAGE; break;
181 case 0x480: prio = BOOK3S_IRQPRIO_INST_SEGMENT; break; 187 case 0x480: prio = BOOK3S_IRQPRIO_INST_SEGMENT; break;
182 case 0x500: prio = BOOK3S_IRQPRIO_EXTERNAL; break; 188 case 0x500: prio = BOOK3S_IRQPRIO_EXTERNAL; break;
189 case 0x501: prio = BOOK3S_IRQPRIO_EXTERNAL_LEVEL; break;
183 case 0x600: prio = BOOK3S_IRQPRIO_ALIGNMENT; break; 190 case 0x600: prio = BOOK3S_IRQPRIO_ALIGNMENT; break;
184 case 0x700: prio = BOOK3S_IRQPRIO_PROGRAM; break; 191 case 0x700: prio = BOOK3S_IRQPRIO_PROGRAM; break;
185 case 0x800: prio = BOOK3S_IRQPRIO_FP_UNAVAIL; break; 192 case 0x800: prio = BOOK3S_IRQPRIO_FP_UNAVAIL; break;
@@ -199,6 +206,9 @@ static void kvmppc_book3s_dequeue_irqprio(struct kvm_vcpu *vcpu,
199{ 206{
200 clear_bit(kvmppc_book3s_vec2irqprio(vec), 207 clear_bit(kvmppc_book3s_vec2irqprio(vec),
201 &vcpu->arch.pending_exceptions); 208 &vcpu->arch.pending_exceptions);
209
210 if (!vcpu->arch.pending_exceptions)
211 vcpu->arch.shared->int_pending = 0;
202} 212}
203 213
204void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec) 214void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec)
@@ -237,13 +247,19 @@ void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu)
237void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, 247void kvmppc_core_queue_external(struct kvm_vcpu *vcpu,
238 struct kvm_interrupt *irq) 248 struct kvm_interrupt *irq)
239{ 249{
240 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_EXTERNAL); 250 unsigned int vec = BOOK3S_INTERRUPT_EXTERNAL;
251
252 if (irq->irq == KVM_INTERRUPT_SET_LEVEL)
253 vec = BOOK3S_INTERRUPT_EXTERNAL_LEVEL;
254
255 kvmppc_book3s_queue_irqprio(vcpu, vec);
241} 256}
242 257
243void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu, 258void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu,
244 struct kvm_interrupt *irq) 259 struct kvm_interrupt *irq)
245{ 260{
246 kvmppc_book3s_dequeue_irqprio(vcpu, BOOK3S_INTERRUPT_EXTERNAL); 261 kvmppc_book3s_dequeue_irqprio(vcpu, BOOK3S_INTERRUPT_EXTERNAL);
262 kvmppc_book3s_dequeue_irqprio(vcpu, BOOK3S_INTERRUPT_EXTERNAL_LEVEL);
247} 263}
248 264
249int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority) 265int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority)
@@ -251,14 +267,29 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority)
251 int deliver = 1; 267 int deliver = 1;
252 int vec = 0; 268 int vec = 0;
253 ulong flags = 0ULL; 269 ulong flags = 0ULL;
270 ulong crit_raw = vcpu->arch.shared->critical;
271 ulong crit_r1 = kvmppc_get_gpr(vcpu, 1);
272 bool crit;
273
274 /* Truncate crit indicators in 32 bit mode */
275 if (!(vcpu->arch.shared->msr & MSR_SF)) {
276 crit_raw &= 0xffffffff;
277 crit_r1 &= 0xffffffff;
278 }
279
280 /* Critical section when crit == r1 */
281 crit = (crit_raw == crit_r1);
282 /* ... and we're in supervisor mode */
283 crit = crit && !(vcpu->arch.shared->msr & MSR_PR);
254 284
255 switch (priority) { 285 switch (priority) {
256 case BOOK3S_IRQPRIO_DECREMENTER: 286 case BOOK3S_IRQPRIO_DECREMENTER:
257 deliver = vcpu->arch.msr & MSR_EE; 287 deliver = (vcpu->arch.shared->msr & MSR_EE) && !crit;
258 vec = BOOK3S_INTERRUPT_DECREMENTER; 288 vec = BOOK3S_INTERRUPT_DECREMENTER;
259 break; 289 break;
260 case BOOK3S_IRQPRIO_EXTERNAL: 290 case BOOK3S_IRQPRIO_EXTERNAL:
261 deliver = vcpu->arch.msr & MSR_EE; 291 case BOOK3S_IRQPRIO_EXTERNAL_LEVEL:
292 deliver = (vcpu->arch.shared->msr & MSR_EE) && !crit;
262 vec = BOOK3S_INTERRUPT_EXTERNAL; 293 vec = BOOK3S_INTERRUPT_EXTERNAL;
263 break; 294 break;
264 case BOOK3S_IRQPRIO_SYSTEM_RESET: 295 case BOOK3S_IRQPRIO_SYSTEM_RESET:
@@ -320,9 +351,27 @@ int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu, unsigned int priority)
320 return deliver; 351 return deliver;
321} 352}
322 353
354/*
355 * This function determines if an irqprio should be cleared once issued.
356 */
357static bool clear_irqprio(struct kvm_vcpu *vcpu, unsigned int priority)
358{
359 switch (priority) {
360 case BOOK3S_IRQPRIO_DECREMENTER:
361 /* DEC interrupts get cleared by mtdec */
362 return false;
363 case BOOK3S_IRQPRIO_EXTERNAL_LEVEL:
364 /* External interrupts get cleared by userspace */
365 return false;
366 }
367
368 return true;
369}
370
323void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu) 371void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
324{ 372{
325 unsigned long *pending = &vcpu->arch.pending_exceptions; 373 unsigned long *pending = &vcpu->arch.pending_exceptions;
374 unsigned long old_pending = vcpu->arch.pending_exceptions;
326 unsigned int priority; 375 unsigned int priority;
327 376
328#ifdef EXIT_DEBUG 377#ifdef EXIT_DEBUG
@@ -332,8 +381,7 @@ void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
332 priority = __ffs(*pending); 381 priority = __ffs(*pending);
333 while (priority < BOOK3S_IRQPRIO_MAX) { 382 while (priority < BOOK3S_IRQPRIO_MAX) {
334 if (kvmppc_book3s_irqprio_deliver(vcpu, priority) && 383 if (kvmppc_book3s_irqprio_deliver(vcpu, priority) &&
335 (priority != BOOK3S_IRQPRIO_DECREMENTER)) { 384 clear_irqprio(vcpu, priority)) {
336 /* DEC interrupts get cleared by mtdec */
337 clear_bit(priority, &vcpu->arch.pending_exceptions); 385 clear_bit(priority, &vcpu->arch.pending_exceptions);
338 break; 386 break;
339 } 387 }
@@ -342,6 +390,12 @@ void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
342 BITS_PER_BYTE * sizeof(*pending), 390 BITS_PER_BYTE * sizeof(*pending),
343 priority + 1); 391 priority + 1);
344 } 392 }
393
394 /* Tell the guest about our interrupt status */
395 if (*pending)
396 vcpu->arch.shared->int_pending = 1;
397 else if (old_pending)
398 vcpu->arch.shared->int_pending = 0;
345} 399}
346 400
347void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr) 401void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
@@ -398,6 +452,25 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
398 } 452 }
399} 453}
400 454
455pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn)
456{
457 ulong mp_pa = vcpu->arch.magic_page_pa;
458
459 /* Magic page override */
460 if (unlikely(mp_pa) &&
461 unlikely(((gfn << PAGE_SHIFT) & KVM_PAM) ==
462 ((mp_pa & PAGE_MASK) & KVM_PAM))) {
463 ulong shared_page = ((ulong)vcpu->arch.shared) & PAGE_MASK;
464 pfn_t pfn;
465
466 pfn = (pfn_t)virt_to_phys((void*)shared_page) >> PAGE_SHIFT;
467 get_page(pfn_to_page(pfn));
468 return pfn;
469 }
470
471 return gfn_to_pfn(vcpu->kvm, gfn);
472}
473
401/* Book3s_32 CPUs always have 32 bytes cache line size, which Linux assumes. To 474/* Book3s_32 CPUs always have 32 bytes cache line size, which Linux assumes. To
402 * make Book3s_32 Linux work on Book3s_64, we have to make sure we trap dcbz to 475 * make Book3s_32 Linux work on Book3s_64, we have to make sure we trap dcbz to
403 * emulate 32 bytes dcbz length. 476 * emulate 32 bytes dcbz length.
@@ -415,8 +488,10 @@ static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)
415 int i; 488 int i;
416 489
417 hpage = gfn_to_page(vcpu->kvm, pte->raddr >> PAGE_SHIFT); 490 hpage = gfn_to_page(vcpu->kvm, pte->raddr >> PAGE_SHIFT);
418 if (is_error_page(hpage)) 491 if (is_error_page(hpage)) {
492 kvm_release_page_clean(hpage);
419 return; 493 return;
494 }
420 495
421 hpage_offset = pte->raddr & ~PAGE_MASK; 496 hpage_offset = pte->raddr & ~PAGE_MASK;
422 hpage_offset &= ~0xFFFULL; 497 hpage_offset &= ~0xFFFULL;
@@ -437,14 +512,14 @@ static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)
437static int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, bool data, 512static int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, bool data,
438 struct kvmppc_pte *pte) 513 struct kvmppc_pte *pte)
439{ 514{
440 int relocated = (vcpu->arch.msr & (data ? MSR_DR : MSR_IR)); 515 int relocated = (vcpu->arch.shared->msr & (data ? MSR_DR : MSR_IR));
441 int r; 516 int r;
442 517
443 if (relocated) { 518 if (relocated) {
444 r = vcpu->arch.mmu.xlate(vcpu, eaddr, pte, data); 519 r = vcpu->arch.mmu.xlate(vcpu, eaddr, pte, data);
445 } else { 520 } else {
446 pte->eaddr = eaddr; 521 pte->eaddr = eaddr;
447 pte->raddr = eaddr & 0xffffffff; 522 pte->raddr = eaddr & KVM_PAM;
448 pte->vpage = VSID_REAL | eaddr >> 12; 523 pte->vpage = VSID_REAL | eaddr >> 12;
449 pte->may_read = true; 524 pte->may_read = true;
450 pte->may_write = true; 525 pte->may_write = true;
@@ -533,6 +608,13 @@ mmio:
533 608
534static int kvmppc_visible_gfn(struct kvm_vcpu *vcpu, gfn_t gfn) 609static int kvmppc_visible_gfn(struct kvm_vcpu *vcpu, gfn_t gfn)
535{ 610{
611 ulong mp_pa = vcpu->arch.magic_page_pa;
612
613 if (unlikely(mp_pa) &&
614 unlikely((mp_pa & KVM_PAM) >> PAGE_SHIFT == gfn)) {
615 return 1;
616 }
617
536 return kvm_is_visible_gfn(vcpu->kvm, gfn); 618 return kvm_is_visible_gfn(vcpu->kvm, gfn);
537} 619}
538 620
@@ -545,8 +627,8 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
545 int page_found = 0; 627 int page_found = 0;
546 struct kvmppc_pte pte; 628 struct kvmppc_pte pte;
547 bool is_mmio = false; 629 bool is_mmio = false;
548 bool dr = (vcpu->arch.msr & MSR_DR) ? true : false; 630 bool dr = (vcpu->arch.shared->msr & MSR_DR) ? true : false;
549 bool ir = (vcpu->arch.msr & MSR_IR) ? true : false; 631 bool ir = (vcpu->arch.shared->msr & MSR_IR) ? true : false;
550 u64 vsid; 632 u64 vsid;
551 633
552 relocated = data ? dr : ir; 634 relocated = data ? dr : ir;
@@ -558,12 +640,12 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
558 pte.may_execute = true; 640 pte.may_execute = true;
559 pte.may_read = true; 641 pte.may_read = true;
560 pte.may_write = true; 642 pte.may_write = true;
561 pte.raddr = eaddr & 0xffffffff; 643 pte.raddr = eaddr & KVM_PAM;
562 pte.eaddr = eaddr; 644 pte.eaddr = eaddr;
563 pte.vpage = eaddr >> 12; 645 pte.vpage = eaddr >> 12;
564 } 646 }
565 647
566 switch (vcpu->arch.msr & (MSR_DR|MSR_IR)) { 648 switch (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
567 case 0: 649 case 0:
568 pte.vpage |= ((u64)VSID_REAL << (SID_SHIFT - 12)); 650 pte.vpage |= ((u64)VSID_REAL << (SID_SHIFT - 12));
569 break; 651 break;
@@ -571,7 +653,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
571 case MSR_IR: 653 case MSR_IR:
572 vcpu->arch.mmu.esid_to_vsid(vcpu, eaddr >> SID_SHIFT, &vsid); 654 vcpu->arch.mmu.esid_to_vsid(vcpu, eaddr >> SID_SHIFT, &vsid);
573 655
574 if ((vcpu->arch.msr & (MSR_DR|MSR_IR)) == MSR_DR) 656 if ((vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) == MSR_DR)
575 pte.vpage |= ((u64)VSID_REAL_DR << (SID_SHIFT - 12)); 657 pte.vpage |= ((u64)VSID_REAL_DR << (SID_SHIFT - 12));
576 else 658 else
577 pte.vpage |= ((u64)VSID_REAL_IR << (SID_SHIFT - 12)); 659 pte.vpage |= ((u64)VSID_REAL_IR << (SID_SHIFT - 12));
@@ -594,20 +676,23 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
594 676
595 if (page_found == -ENOENT) { 677 if (page_found == -ENOENT) {
596 /* Page not found in guest PTE entries */ 678 /* Page not found in guest PTE entries */
597 vcpu->arch.dear = kvmppc_get_fault_dar(vcpu); 679 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
598 to_book3s(vcpu)->dsisr = to_svcpu(vcpu)->fault_dsisr; 680 vcpu->arch.shared->dsisr = to_svcpu(vcpu)->fault_dsisr;
599 vcpu->arch.msr |= (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL); 681 vcpu->arch.shared->msr |=
682 (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL);
600 kvmppc_book3s_queue_irqprio(vcpu, vec); 683 kvmppc_book3s_queue_irqprio(vcpu, vec);
601 } else if (page_found == -EPERM) { 684 } else if (page_found == -EPERM) {
602 /* Storage protection */ 685 /* Storage protection */
603 vcpu->arch.dear = kvmppc_get_fault_dar(vcpu); 686 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
604 to_book3s(vcpu)->dsisr = to_svcpu(vcpu)->fault_dsisr & ~DSISR_NOHPTE; 687 vcpu->arch.shared->dsisr =
605 to_book3s(vcpu)->dsisr |= DSISR_PROTFAULT; 688 to_svcpu(vcpu)->fault_dsisr & ~DSISR_NOHPTE;
606 vcpu->arch.msr |= (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL); 689 vcpu->arch.shared->dsisr |= DSISR_PROTFAULT;
690 vcpu->arch.shared->msr |=
691 (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL);
607 kvmppc_book3s_queue_irqprio(vcpu, vec); 692 kvmppc_book3s_queue_irqprio(vcpu, vec);
608 } else if (page_found == -EINVAL) { 693 } else if (page_found == -EINVAL) {
609 /* Page not found in guest SLB */ 694 /* Page not found in guest SLB */
610 vcpu->arch.dear = kvmppc_get_fault_dar(vcpu); 695 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
611 kvmppc_book3s_queue_irqprio(vcpu, vec + 0x80); 696 kvmppc_book3s_queue_irqprio(vcpu, vec + 0x80);
612 } else if (!is_mmio && 697 } else if (!is_mmio &&
613 kvmppc_visible_gfn(vcpu, pte.raddr >> PAGE_SHIFT)) { 698 kvmppc_visible_gfn(vcpu, pte.raddr >> PAGE_SHIFT)) {
@@ -695,9 +780,11 @@ static int kvmppc_read_inst(struct kvm_vcpu *vcpu)
695 780
696 ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false); 781 ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false);
697 if (ret == -ENOENT) { 782 if (ret == -ENOENT) {
698 vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 33, 33, 1); 783 ulong msr = vcpu->arch.shared->msr;
699 vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 34, 36, 0); 784
700 vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 42, 47, 0); 785 msr = kvmppc_set_field(msr, 33, 33, 1);
786 msr = kvmppc_set_field(msr, 34, 36, 0);
787 vcpu->arch.shared->msr = kvmppc_set_field(msr, 42, 47, 0);
701 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE); 788 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE);
702 return EMULATE_AGAIN; 789 return EMULATE_AGAIN;
703 } 790 }
@@ -736,7 +823,7 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
736 if (vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE) 823 if (vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)
737 return RESUME_GUEST; 824 return RESUME_GUEST;
738 825
739 if (!(vcpu->arch.msr & msr)) { 826 if (!(vcpu->arch.shared->msr & msr)) {
740 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 827 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
741 return RESUME_GUEST; 828 return RESUME_GUEST;
742 } 829 }
@@ -796,16 +883,8 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
796 883
797 run->exit_reason = KVM_EXIT_UNKNOWN; 884 run->exit_reason = KVM_EXIT_UNKNOWN;
798 run->ready_for_interrupt_injection = 1; 885 run->ready_for_interrupt_injection = 1;
799#ifdef EXIT_DEBUG 886
800 printk(KERN_EMERG "exit_nr=0x%x | pc=0x%lx | dar=0x%lx | dec=0x%x | msr=0x%lx\n", 887 trace_kvm_book3s_exit(exit_nr, vcpu);
801 exit_nr, kvmppc_get_pc(vcpu), kvmppc_get_fault_dar(vcpu),
802 kvmppc_get_dec(vcpu), to_svcpu(vcpu)->shadow_srr1);
803#elif defined (EXIT_DEBUG_SIMPLE)
804 if ((exit_nr != 0x900) && (exit_nr != 0x500))
805 printk(KERN_EMERG "exit_nr=0x%x | pc=0x%lx | dar=0x%lx | msr=0x%lx\n",
806 exit_nr, kvmppc_get_pc(vcpu), kvmppc_get_fault_dar(vcpu),
807 vcpu->arch.msr);
808#endif
809 kvm_resched(vcpu); 888 kvm_resched(vcpu);
810 switch (exit_nr) { 889 switch (exit_nr) {
811 case BOOK3S_INTERRUPT_INST_STORAGE: 890 case BOOK3S_INTERRUPT_INST_STORAGE:
@@ -836,9 +915,9 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
836 kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL); 915 kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL);
837 r = RESUME_GUEST; 916 r = RESUME_GUEST;
838 } else { 917 } else {
839 vcpu->arch.msr |= to_svcpu(vcpu)->shadow_srr1 & 0x58000000; 918 vcpu->arch.shared->msr |=
919 to_svcpu(vcpu)->shadow_srr1 & 0x58000000;
840 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 920 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
841 kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL);
842 r = RESUME_GUEST; 921 r = RESUME_GUEST;
843 } 922 }
844 break; 923 break;
@@ -861,17 +940,16 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
861 if (to_svcpu(vcpu)->fault_dsisr & DSISR_NOHPTE) { 940 if (to_svcpu(vcpu)->fault_dsisr & DSISR_NOHPTE) {
862 r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr); 941 r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr);
863 } else { 942 } else {
864 vcpu->arch.dear = dar; 943 vcpu->arch.shared->dar = dar;
865 to_book3s(vcpu)->dsisr = to_svcpu(vcpu)->fault_dsisr; 944 vcpu->arch.shared->dsisr = to_svcpu(vcpu)->fault_dsisr;
866 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 945 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
867 kvmppc_mmu_pte_flush(vcpu, vcpu->arch.dear, ~0xFFFUL);
868 r = RESUME_GUEST; 946 r = RESUME_GUEST;
869 } 947 }
870 break; 948 break;
871 } 949 }
872 case BOOK3S_INTERRUPT_DATA_SEGMENT: 950 case BOOK3S_INTERRUPT_DATA_SEGMENT:
873 if (kvmppc_mmu_map_segment(vcpu, kvmppc_get_fault_dar(vcpu)) < 0) { 951 if (kvmppc_mmu_map_segment(vcpu, kvmppc_get_fault_dar(vcpu)) < 0) {
874 vcpu->arch.dear = kvmppc_get_fault_dar(vcpu); 952 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
875 kvmppc_book3s_queue_irqprio(vcpu, 953 kvmppc_book3s_queue_irqprio(vcpu,
876 BOOK3S_INTERRUPT_DATA_SEGMENT); 954 BOOK3S_INTERRUPT_DATA_SEGMENT);
877 } 955 }
@@ -904,7 +982,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
904program_interrupt: 982program_interrupt:
905 flags = to_svcpu(vcpu)->shadow_srr1 & 0x1f0000ull; 983 flags = to_svcpu(vcpu)->shadow_srr1 & 0x1f0000ull;
906 984
907 if (vcpu->arch.msr & MSR_PR) { 985 if (vcpu->arch.shared->msr & MSR_PR) {
908#ifdef EXIT_DEBUG 986#ifdef EXIT_DEBUG
909 printk(KERN_INFO "Userspace triggered 0x700 exception at 0x%lx (0x%x)\n", kvmppc_get_pc(vcpu), kvmppc_get_last_inst(vcpu)); 987 printk(KERN_INFO "Userspace triggered 0x700 exception at 0x%lx (0x%x)\n", kvmppc_get_pc(vcpu), kvmppc_get_last_inst(vcpu));
910#endif 988#endif
@@ -941,10 +1019,10 @@ program_interrupt:
941 break; 1019 break;
942 } 1020 }
943 case BOOK3S_INTERRUPT_SYSCALL: 1021 case BOOK3S_INTERRUPT_SYSCALL:
944 // XXX make user settable
945 if (vcpu->arch.osi_enabled && 1022 if (vcpu->arch.osi_enabled &&
946 (((u32)kvmppc_get_gpr(vcpu, 3)) == OSI_SC_MAGIC_R3) && 1023 (((u32)kvmppc_get_gpr(vcpu, 3)) == OSI_SC_MAGIC_R3) &&
947 (((u32)kvmppc_get_gpr(vcpu, 4)) == OSI_SC_MAGIC_R4)) { 1024 (((u32)kvmppc_get_gpr(vcpu, 4)) == OSI_SC_MAGIC_R4)) {
1025 /* MOL hypercalls */
948 u64 *gprs = run->osi.gprs; 1026 u64 *gprs = run->osi.gprs;
949 int i; 1027 int i;
950 1028
@@ -953,8 +1031,13 @@ program_interrupt:
953 gprs[i] = kvmppc_get_gpr(vcpu, i); 1031 gprs[i] = kvmppc_get_gpr(vcpu, i);
954 vcpu->arch.osi_needed = 1; 1032 vcpu->arch.osi_needed = 1;
955 r = RESUME_HOST_NV; 1033 r = RESUME_HOST_NV;
956 1034 } else if (!(vcpu->arch.shared->msr & MSR_PR) &&
1035 (((u32)kvmppc_get_gpr(vcpu, 0)) == KVM_SC_MAGIC_R0)) {
1036 /* KVM PV hypercalls */
1037 kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu));
1038 r = RESUME_GUEST;
957 } else { 1039 } else {
1040 /* Guest syscalls */
958 vcpu->stat.syscall_exits++; 1041 vcpu->stat.syscall_exits++;
959 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 1042 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
960 r = RESUME_GUEST; 1043 r = RESUME_GUEST;
@@ -989,9 +1072,9 @@ program_interrupt:
989 } 1072 }
990 case BOOK3S_INTERRUPT_ALIGNMENT: 1073 case BOOK3S_INTERRUPT_ALIGNMENT:
991 if (kvmppc_read_inst(vcpu) == EMULATE_DONE) { 1074 if (kvmppc_read_inst(vcpu) == EMULATE_DONE) {
992 to_book3s(vcpu)->dsisr = kvmppc_alignment_dsisr(vcpu, 1075 vcpu->arch.shared->dsisr = kvmppc_alignment_dsisr(vcpu,
993 kvmppc_get_last_inst(vcpu)); 1076 kvmppc_get_last_inst(vcpu));
994 vcpu->arch.dear = kvmppc_alignment_dar(vcpu, 1077 vcpu->arch.shared->dar = kvmppc_alignment_dar(vcpu,
995 kvmppc_get_last_inst(vcpu)); 1078 kvmppc_get_last_inst(vcpu));
996 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 1079 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
997 } 1080 }
@@ -1031,9 +1114,7 @@ program_interrupt:
1031 } 1114 }
1032 } 1115 }
1033 1116
1034#ifdef EXIT_DEBUG 1117 trace_kvm_book3s_reenter(r, vcpu);
1035 printk(KERN_EMERG "KVM exit: vcpu=0x%p pc=0x%lx r=0x%x\n", vcpu, kvmppc_get_pc(vcpu), r);
1036#endif
1037 1118
1038 return r; 1119 return r;
1039} 1120}
@@ -1052,14 +1133,14 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
1052 regs->ctr = kvmppc_get_ctr(vcpu); 1133 regs->ctr = kvmppc_get_ctr(vcpu);
1053 regs->lr = kvmppc_get_lr(vcpu); 1134 regs->lr = kvmppc_get_lr(vcpu);
1054 regs->xer = kvmppc_get_xer(vcpu); 1135 regs->xer = kvmppc_get_xer(vcpu);
1055 regs->msr = vcpu->arch.msr; 1136 regs->msr = vcpu->arch.shared->msr;
1056 regs->srr0 = vcpu->arch.srr0; 1137 regs->srr0 = vcpu->arch.shared->srr0;
1057 regs->srr1 = vcpu->arch.srr1; 1138 regs->srr1 = vcpu->arch.shared->srr1;
1058 regs->pid = vcpu->arch.pid; 1139 regs->pid = vcpu->arch.pid;
1059 regs->sprg0 = vcpu->arch.sprg0; 1140 regs->sprg0 = vcpu->arch.shared->sprg0;
1060 regs->sprg1 = vcpu->arch.sprg1; 1141 regs->sprg1 = vcpu->arch.shared->sprg1;
1061 regs->sprg2 = vcpu->arch.sprg2; 1142 regs->sprg2 = vcpu->arch.shared->sprg2;
1062 regs->sprg3 = vcpu->arch.sprg3; 1143 regs->sprg3 = vcpu->arch.shared->sprg3;
1063 regs->sprg5 = vcpu->arch.sprg4; 1144 regs->sprg5 = vcpu->arch.sprg4;
1064 regs->sprg6 = vcpu->arch.sprg5; 1145 regs->sprg6 = vcpu->arch.sprg5;
1065 regs->sprg7 = vcpu->arch.sprg6; 1146 regs->sprg7 = vcpu->arch.sprg6;
@@ -1080,12 +1161,12 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
1080 kvmppc_set_lr(vcpu, regs->lr); 1161 kvmppc_set_lr(vcpu, regs->lr);
1081 kvmppc_set_xer(vcpu, regs->xer); 1162 kvmppc_set_xer(vcpu, regs->xer);
1082 kvmppc_set_msr(vcpu, regs->msr); 1163 kvmppc_set_msr(vcpu, regs->msr);
1083 vcpu->arch.srr0 = regs->srr0; 1164 vcpu->arch.shared->srr0 = regs->srr0;
1084 vcpu->arch.srr1 = regs->srr1; 1165 vcpu->arch.shared->srr1 = regs->srr1;
1085 vcpu->arch.sprg0 = regs->sprg0; 1166 vcpu->arch.shared->sprg0 = regs->sprg0;
1086 vcpu->arch.sprg1 = regs->sprg1; 1167 vcpu->arch.shared->sprg1 = regs->sprg1;
1087 vcpu->arch.sprg2 = regs->sprg2; 1168 vcpu->arch.shared->sprg2 = regs->sprg2;
1088 vcpu->arch.sprg3 = regs->sprg3; 1169 vcpu->arch.shared->sprg3 = regs->sprg3;
1089 vcpu->arch.sprg5 = regs->sprg4; 1170 vcpu->arch.sprg5 = regs->sprg4;
1090 vcpu->arch.sprg6 = regs->sprg5; 1171 vcpu->arch.sprg6 = regs->sprg5;
1091 vcpu->arch.sprg7 = regs->sprg6; 1172 vcpu->arch.sprg7 = regs->sprg6;
@@ -1111,10 +1192,9 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
1111 sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv; 1192 sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv;
1112 } 1193 }
1113 } else { 1194 } else {
1114 for (i = 0; i < 16; i++) { 1195 for (i = 0; i < 16; i++)
1115 sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i].raw; 1196 sregs->u.s.ppc32.sr[i] = vcpu->arch.shared->sr[i];
1116 sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i].raw; 1197
1117 }
1118 for (i = 0; i < 8; i++) { 1198 for (i = 0; i < 8; i++) {
1119 sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw; 1199 sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw;
1120 sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw; 1200 sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw;
@@ -1225,6 +1305,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
1225 struct kvmppc_vcpu_book3s *vcpu_book3s; 1305 struct kvmppc_vcpu_book3s *vcpu_book3s;
1226 struct kvm_vcpu *vcpu; 1306 struct kvm_vcpu *vcpu;
1227 int err = -ENOMEM; 1307 int err = -ENOMEM;
1308 unsigned long p;
1228 1309
1229 vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s)); 1310 vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s));
1230 if (!vcpu_book3s) 1311 if (!vcpu_book3s)
@@ -1242,6 +1323,12 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
1242 if (err) 1323 if (err)
1243 goto free_shadow_vcpu; 1324 goto free_shadow_vcpu;
1244 1325
1326 p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
1327 /* the real shared page fills the last 4k of our page */
1328 vcpu->arch.shared = (void*)(p + PAGE_SIZE - 4096);
1329 if (!p)
1330 goto uninit_vcpu;
1331
1245 vcpu->arch.host_retip = kvm_return_point; 1332 vcpu->arch.host_retip = kvm_return_point;
1246 vcpu->arch.host_msr = mfmsr(); 1333 vcpu->arch.host_msr = mfmsr();
1247#ifdef CONFIG_PPC_BOOK3S_64 1334#ifdef CONFIG_PPC_BOOK3S_64
@@ -1268,10 +1355,12 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
1268 1355
1269 err = kvmppc_mmu_init(vcpu); 1356 err = kvmppc_mmu_init(vcpu);
1270 if (err < 0) 1357 if (err < 0)
1271 goto free_shadow_vcpu; 1358 goto uninit_vcpu;
1272 1359
1273 return vcpu; 1360 return vcpu;
1274 1361
1362uninit_vcpu:
1363 kvm_vcpu_uninit(vcpu);
1275free_shadow_vcpu: 1364free_shadow_vcpu:
1276 kfree(vcpu_book3s->shadow_vcpu); 1365 kfree(vcpu_book3s->shadow_vcpu);
1277free_vcpu: 1366free_vcpu:
@@ -1284,6 +1373,7 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
1284{ 1373{
1285 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); 1374 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
1286 1375
1376 free_page((unsigned long)vcpu->arch.shared & PAGE_MASK);
1287 kvm_vcpu_uninit(vcpu); 1377 kvm_vcpu_uninit(vcpu);
1288 kfree(vcpu_book3s->shadow_vcpu); 1378 kfree(vcpu_book3s->shadow_vcpu);
1289 vfree(vcpu_book3s); 1379 vfree(vcpu_book3s);
@@ -1346,7 +1436,7 @@ int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1346 local_irq_enable(); 1436 local_irq_enable();
1347 1437
1348 /* Preload FPU if it's enabled */ 1438 /* Preload FPU if it's enabled */
1349 if (vcpu->arch.msr & MSR_FP) 1439 if (vcpu->arch.shared->msr & MSR_FP)
1350 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP); 1440 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP);
1351 1441
1352 ret = __kvmppc_vcpu_entry(kvm_run, vcpu); 1442 ret = __kvmppc_vcpu_entry(kvm_run, vcpu);
diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c
index 3292d76101d2..c8cefdd15fd8 100644
--- a/arch/powerpc/kvm/book3s_32_mmu.c
+++ b/arch/powerpc/kvm/book3s_32_mmu.c
@@ -58,14 +58,39 @@ static inline bool check_debug_ip(struct kvm_vcpu *vcpu)
58#endif 58#endif
59} 59}
60 60
61static inline u32 sr_vsid(u32 sr_raw)
62{
63 return sr_raw & 0x0fffffff;
64}
65
66static inline bool sr_valid(u32 sr_raw)
67{
68 return (sr_raw & 0x80000000) ? false : true;
69}
70
71static inline bool sr_ks(u32 sr_raw)
72{
73 return (sr_raw & 0x40000000) ? true: false;
74}
75
76static inline bool sr_kp(u32 sr_raw)
77{
78 return (sr_raw & 0x20000000) ? true: false;
79}
80
81static inline bool sr_nx(u32 sr_raw)
82{
83 return (sr_raw & 0x10000000) ? true: false;
84}
85
61static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr, 86static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
62 struct kvmppc_pte *pte, bool data); 87 struct kvmppc_pte *pte, bool data);
63static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid, 88static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
64 u64 *vsid); 89 u64 *vsid);
65 90
66static struct kvmppc_sr *find_sr(struct kvmppc_vcpu_book3s *vcpu_book3s, gva_t eaddr) 91static u32 find_sr(struct kvm_vcpu *vcpu, gva_t eaddr)
67{ 92{
68 return &vcpu_book3s->sr[(eaddr >> 28) & 0xf]; 93 return vcpu->arch.shared->sr[(eaddr >> 28) & 0xf];
69} 94}
70 95
71static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr, 96static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr,
@@ -87,7 +112,7 @@ static void kvmppc_mmu_book3s_32_reset_msr(struct kvm_vcpu *vcpu)
87} 112}
88 113
89static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3s, 114static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3s,
90 struct kvmppc_sr *sre, gva_t eaddr, 115 u32 sre, gva_t eaddr,
91 bool primary) 116 bool primary)
92{ 117{
93 u32 page, hash, pteg, htabmask; 118 u32 page, hash, pteg, htabmask;
@@ -96,7 +121,7 @@ static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3
96 page = (eaddr & 0x0FFFFFFF) >> 12; 121 page = (eaddr & 0x0FFFFFFF) >> 12;
97 htabmask = ((vcpu_book3s->sdr1 & 0x1FF) << 16) | 0xFFC0; 122 htabmask = ((vcpu_book3s->sdr1 & 0x1FF) << 16) | 0xFFC0;
98 123
99 hash = ((sre->vsid ^ page) << 6); 124 hash = ((sr_vsid(sre) ^ page) << 6);
100 if (!primary) 125 if (!primary)
101 hash = ~hash; 126 hash = ~hash;
102 hash &= htabmask; 127 hash &= htabmask;
@@ -104,8 +129,8 @@ static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3
104 pteg = (vcpu_book3s->sdr1 & 0xffff0000) | hash; 129 pteg = (vcpu_book3s->sdr1 & 0xffff0000) | hash;
105 130
106 dprintk("MMU: pc=0x%lx eaddr=0x%lx sdr1=0x%llx pteg=0x%x vsid=0x%x\n", 131 dprintk("MMU: pc=0x%lx eaddr=0x%lx sdr1=0x%llx pteg=0x%x vsid=0x%x\n",
107 vcpu_book3s->vcpu.arch.pc, eaddr, vcpu_book3s->sdr1, pteg, 132 kvmppc_get_pc(&vcpu_book3s->vcpu), eaddr, vcpu_book3s->sdr1, pteg,
108 sre->vsid); 133 sr_vsid(sre));
109 134
110 r = gfn_to_hva(vcpu_book3s->vcpu.kvm, pteg >> PAGE_SHIFT); 135 r = gfn_to_hva(vcpu_book3s->vcpu.kvm, pteg >> PAGE_SHIFT);
111 if (kvm_is_error_hva(r)) 136 if (kvm_is_error_hva(r))
@@ -113,10 +138,9 @@ static hva_t kvmppc_mmu_book3s_32_get_pteg(struct kvmppc_vcpu_book3s *vcpu_book3
113 return r | (pteg & ~PAGE_MASK); 138 return r | (pteg & ~PAGE_MASK);
114} 139}
115 140
116static u32 kvmppc_mmu_book3s_32_get_ptem(struct kvmppc_sr *sre, gva_t eaddr, 141static u32 kvmppc_mmu_book3s_32_get_ptem(u32 sre, gva_t eaddr, bool primary)
117 bool primary)
118{ 142{
119 return ((eaddr & 0x0fffffff) >> 22) | (sre->vsid << 7) | 143 return ((eaddr & 0x0fffffff) >> 22) | (sr_vsid(sre) << 7) |
120 (primary ? 0 : 0x40) | 0x80000000; 144 (primary ? 0 : 0x40) | 0x80000000;
121} 145}
122 146
@@ -133,7 +157,7 @@ static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
133 else 157 else
134 bat = &vcpu_book3s->ibat[i]; 158 bat = &vcpu_book3s->ibat[i];
135 159
136 if (vcpu->arch.msr & MSR_PR) { 160 if (vcpu->arch.shared->msr & MSR_PR) {
137 if (!bat->vp) 161 if (!bat->vp)
138 continue; 162 continue;
139 } else { 163 } else {
@@ -180,17 +204,17 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
180 bool primary) 204 bool primary)
181{ 205{
182 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); 206 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
183 struct kvmppc_sr *sre; 207 u32 sre;
184 hva_t ptegp; 208 hva_t ptegp;
185 u32 pteg[16]; 209 u32 pteg[16];
186 u32 ptem = 0; 210 u32 ptem = 0;
187 int i; 211 int i;
188 int found = 0; 212 int found = 0;
189 213
190 sre = find_sr(vcpu_book3s, eaddr); 214 sre = find_sr(vcpu, eaddr);
191 215
192 dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28, 216 dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28,
193 sre->vsid, sre->raw); 217 sr_vsid(sre), sre);
194 218
195 pte->vpage = kvmppc_mmu_book3s_32_ea_to_vp(vcpu, eaddr, data); 219 pte->vpage = kvmppc_mmu_book3s_32_ea_to_vp(vcpu, eaddr, data);
196 220
@@ -214,8 +238,8 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
214 pte->raddr = (pteg[i+1] & ~(0xFFFULL)) | (eaddr & 0xFFF); 238 pte->raddr = (pteg[i+1] & ~(0xFFFULL)) | (eaddr & 0xFFF);
215 pp = pteg[i+1] & 3; 239 pp = pteg[i+1] & 3;
216 240
217 if ((sre->Kp && (vcpu->arch.msr & MSR_PR)) || 241 if ((sr_kp(sre) && (vcpu->arch.shared->msr & MSR_PR)) ||
218 (sre->Ks && !(vcpu->arch.msr & MSR_PR))) 242 (sr_ks(sre) && !(vcpu->arch.shared->msr & MSR_PR)))
219 pp |= 4; 243 pp |= 4;
220 244
221 pte->may_write = false; 245 pte->may_write = false;
@@ -269,7 +293,7 @@ no_page_found:
269 dprintk_pte("KVM MMU: No PTE found (sdr1=0x%llx ptegp=0x%lx)\n", 293 dprintk_pte("KVM MMU: No PTE found (sdr1=0x%llx ptegp=0x%lx)\n",
270 to_book3s(vcpu)->sdr1, ptegp); 294 to_book3s(vcpu)->sdr1, ptegp);
271 for (i=0; i<16; i+=2) { 295 for (i=0; i<16; i+=2) {
272 dprintk_pte(" %02d: 0x%x - 0x%x (0x%llx)\n", 296 dprintk_pte(" %02d: 0x%x - 0x%x (0x%x)\n",
273 i, pteg[i], pteg[i+1], ptem); 297 i, pteg[i], pteg[i+1], ptem);
274 } 298 }
275 } 299 }
@@ -281,8 +305,24 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
281 struct kvmppc_pte *pte, bool data) 305 struct kvmppc_pte *pte, bool data)
282{ 306{
283 int r; 307 int r;
308 ulong mp_ea = vcpu->arch.magic_page_ea;
284 309
285 pte->eaddr = eaddr; 310 pte->eaddr = eaddr;
311
312 /* Magic page override */
313 if (unlikely(mp_ea) &&
314 unlikely((eaddr & ~0xfffULL) == (mp_ea & ~0xfffULL)) &&
315 !(vcpu->arch.shared->msr & MSR_PR)) {
316 pte->vpage = kvmppc_mmu_book3s_32_ea_to_vp(vcpu, eaddr, data);
317 pte->raddr = vcpu->arch.magic_page_pa | (pte->raddr & 0xfff);
318 pte->raddr &= KVM_PAM;
319 pte->may_execute = true;
320 pte->may_read = true;
321 pte->may_write = true;
322
323 return 0;
324 }
325
286 r = kvmppc_mmu_book3s_32_xlate_bat(vcpu, eaddr, pte, data); 326 r = kvmppc_mmu_book3s_32_xlate_bat(vcpu, eaddr, pte, data);
287 if (r < 0) 327 if (r < 0)
288 r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte, data, true); 328 r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte, data, true);
@@ -295,30 +335,13 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
295 335
296static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum) 336static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum)
297{ 337{
298 return to_book3s(vcpu)->sr[srnum].raw; 338 return vcpu->arch.shared->sr[srnum];
299} 339}
300 340
301static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum, 341static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
302 ulong value) 342 ulong value)
303{ 343{
304 struct kvmppc_sr *sre; 344 vcpu->arch.shared->sr[srnum] = value;
305
306 sre = &to_book3s(vcpu)->sr[srnum];
307
308 /* Flush any left-over shadows from the previous SR */
309
310 /* XXX Not necessary? */
311 /* kvmppc_mmu_pte_flush(vcpu, ((u64)sre->vsid) << 28, 0xf0000000ULL); */
312
313 /* And then put in the new SR */
314 sre->raw = value;
315 sre->vsid = (value & 0x0fffffff);
316 sre->valid = (value & 0x80000000) ? false : true;
317 sre->Ks = (value & 0x40000000) ? true : false;
318 sre->Kp = (value & 0x20000000) ? true : false;
319 sre->nx = (value & 0x10000000) ? true : false;
320
321 /* Map the new segment */
322 kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT); 345 kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT);
323} 346}
324 347
@@ -331,19 +354,19 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
331 u64 *vsid) 354 u64 *vsid)
332{ 355{
333 ulong ea = esid << SID_SHIFT; 356 ulong ea = esid << SID_SHIFT;
334 struct kvmppc_sr *sr; 357 u32 sr;
335 u64 gvsid = esid; 358 u64 gvsid = esid;
336 359
337 if (vcpu->arch.msr & (MSR_DR|MSR_IR)) { 360 if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
338 sr = find_sr(to_book3s(vcpu), ea); 361 sr = find_sr(vcpu, ea);
339 if (sr->valid) 362 if (sr_valid(sr))
340 gvsid = sr->vsid; 363 gvsid = sr_vsid(sr);
341 } 364 }
342 365
343 /* In case we only have one of MSR_IR or MSR_DR set, let's put 366 /* In case we only have one of MSR_IR or MSR_DR set, let's put
344 that in the real-mode context (and hope RM doesn't access 367 that in the real-mode context (and hope RM doesn't access
345 high memory) */ 368 high memory) */
346 switch (vcpu->arch.msr & (MSR_DR|MSR_IR)) { 369 switch (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
347 case 0: 370 case 0:
348 *vsid = VSID_REAL | esid; 371 *vsid = VSID_REAL | esid;
349 break; 372 break;
@@ -354,8 +377,8 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
354 *vsid = VSID_REAL_DR | gvsid; 377 *vsid = VSID_REAL_DR | gvsid;
355 break; 378 break;
356 case MSR_DR|MSR_IR: 379 case MSR_DR|MSR_IR:
357 if (sr->valid) 380 if (sr_valid(sr))
358 *vsid = sr->vsid; 381 *vsid = sr_vsid(sr);
359 else 382 else
360 *vsid = VSID_BAT | gvsid; 383 *vsid = VSID_BAT | gvsid;
361 break; 384 break;
@@ -363,7 +386,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
363 BUG(); 386 BUG();
364 } 387 }
365 388
366 if (vcpu->arch.msr & MSR_PR) 389 if (vcpu->arch.shared->msr & MSR_PR)
367 *vsid |= VSID_PR; 390 *vsid |= VSID_PR;
368 391
369 return 0; 392 return 0;
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 0b51ef872c1e..9fecbfbce773 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/kvm_host.h> 21#include <linux/kvm_host.h>
22#include <linux/hash.h>
23 22
24#include <asm/kvm_ppc.h> 23#include <asm/kvm_ppc.h>
25#include <asm/kvm_book3s.h> 24#include <asm/kvm_book3s.h>
@@ -77,7 +76,14 @@ void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
77 * a hash, so we don't waste cycles on looping */ 76 * a hash, so we don't waste cycles on looping */
78static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid) 77static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid)
79{ 78{
80 return hash_64(gvsid, SID_MAP_BITS); 79 return (u16)(((gvsid >> (SID_MAP_BITS * 7)) & SID_MAP_MASK) ^
80 ((gvsid >> (SID_MAP_BITS * 6)) & SID_MAP_MASK) ^
81 ((gvsid >> (SID_MAP_BITS * 5)) & SID_MAP_MASK) ^
82 ((gvsid >> (SID_MAP_BITS * 4)) & SID_MAP_MASK) ^
83 ((gvsid >> (SID_MAP_BITS * 3)) & SID_MAP_MASK) ^
84 ((gvsid >> (SID_MAP_BITS * 2)) & SID_MAP_MASK) ^
85 ((gvsid >> (SID_MAP_BITS * 1)) & SID_MAP_MASK) ^
86 ((gvsid >> (SID_MAP_BITS * 0)) & SID_MAP_MASK));
81} 87}
82 88
83 89
@@ -86,7 +92,7 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)
86 struct kvmppc_sid_map *map; 92 struct kvmppc_sid_map *map;
87 u16 sid_map_mask; 93 u16 sid_map_mask;
88 94
89 if (vcpu->arch.msr & MSR_PR) 95 if (vcpu->arch.shared->msr & MSR_PR)
90 gvsid |= VSID_PR; 96 gvsid |= VSID_PR;
91 97
92 sid_map_mask = kvmppc_sid_hash(vcpu, gvsid); 98 sid_map_mask = kvmppc_sid_hash(vcpu, gvsid);
@@ -147,8 +153,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
147 struct hpte_cache *pte; 153 struct hpte_cache *pte;
148 154
149 /* Get host physical address for gpa */ 155 /* Get host physical address for gpa */
150 hpaddr = gfn_to_pfn(vcpu->kvm, orig_pte->raddr >> PAGE_SHIFT); 156 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
151 if (kvm_is_error_hva(hpaddr)) { 157 if (is_error_pfn(hpaddr)) {
152 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", 158 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n",
153 orig_pte->eaddr); 159 orig_pte->eaddr);
154 return -EINVAL; 160 return -EINVAL;
@@ -253,7 +259,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
253 u16 sid_map_mask; 259 u16 sid_map_mask;
254 static int backwards_map = 0; 260 static int backwards_map = 0;
255 261
256 if (vcpu->arch.msr & MSR_PR) 262 if (vcpu->arch.shared->msr & MSR_PR)
257 gvsid |= VSID_PR; 263 gvsid |= VSID_PR;
258 264
259 /* We might get collisions that trap in preceding order, so let's 265 /* We might get collisions that trap in preceding order, so let's
@@ -269,18 +275,15 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
269 backwards_map = !backwards_map; 275 backwards_map = !backwards_map;
270 276
271 /* Uh-oh ... out of mappings. Let's flush! */ 277 /* Uh-oh ... out of mappings. Let's flush! */
272 if (vcpu_book3s->vsid_next >= vcpu_book3s->vsid_max) { 278 if (vcpu_book3s->vsid_next >= VSID_POOL_SIZE) {
273 vcpu_book3s->vsid_next = vcpu_book3s->vsid_first; 279 vcpu_book3s->vsid_next = 0;
274 memset(vcpu_book3s->sid_map, 0, 280 memset(vcpu_book3s->sid_map, 0,
275 sizeof(struct kvmppc_sid_map) * SID_MAP_NUM); 281 sizeof(struct kvmppc_sid_map) * SID_MAP_NUM);
276 kvmppc_mmu_pte_flush(vcpu, 0, 0); 282 kvmppc_mmu_pte_flush(vcpu, 0, 0);
277 kvmppc_mmu_flush_segments(vcpu); 283 kvmppc_mmu_flush_segments(vcpu);
278 } 284 }
279 map->host_vsid = vcpu_book3s->vsid_next; 285 map->host_vsid = vcpu_book3s->vsid_pool[vcpu_book3s->vsid_next];
280 286 vcpu_book3s->vsid_next++;
281 /* Would have to be 111 to be completely aligned with the rest of
282 Linux, but that is just way too little space! */
283 vcpu_book3s->vsid_next+=1;
284 287
285 map->guest_vsid = gvsid; 288 map->guest_vsid = gvsid;
286 map->valid = true; 289 map->valid = true;
@@ -327,40 +330,38 @@ void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu)
327 330
328void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) 331void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu)
329{ 332{
333 int i;
334
330 kvmppc_mmu_hpte_destroy(vcpu); 335 kvmppc_mmu_hpte_destroy(vcpu);
331 preempt_disable(); 336 preempt_disable();
332 __destroy_context(to_book3s(vcpu)->context_id); 337 for (i = 0; i < SID_CONTEXTS; i++)
338 __destroy_context(to_book3s(vcpu)->context_id[i]);
333 preempt_enable(); 339 preempt_enable();
334} 340}
335 341
336/* From mm/mmu_context_hash32.c */ 342/* From mm/mmu_context_hash32.c */
337#define CTX_TO_VSID(ctx) (((ctx) * (897 * 16)) & 0xffffff) 343#define CTX_TO_VSID(c, id) ((((c) * (897 * 16)) + (id * 0x111)) & 0xffffff)
338 344
339int kvmppc_mmu_init(struct kvm_vcpu *vcpu) 345int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
340{ 346{
341 struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); 347 struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
342 int err; 348 int err;
343 ulong sdr1; 349 ulong sdr1;
350 int i;
351 int j;
344 352
345 err = __init_new_context(); 353 for (i = 0; i < SID_CONTEXTS; i++) {
346 if (err < 0) 354 err = __init_new_context();
347 return -1; 355 if (err < 0)
348 vcpu3s->context_id = err; 356 goto init_fail;
349 357 vcpu3s->context_id[i] = err;
350 vcpu3s->vsid_max = CTX_TO_VSID(vcpu3s->context_id + 1) - 1;
351 vcpu3s->vsid_first = CTX_TO_VSID(vcpu3s->context_id);
352
353#if 0 /* XXX still doesn't guarantee uniqueness */
354 /* We could collide with the Linux vsid space because the vsid
355 * wraps around at 24 bits. We're safe if we do our own space
356 * though, so let's always set the highest bit. */
357 358
358 vcpu3s->vsid_max |= 0x00800000; 359 /* Remember context id for this combination */
359 vcpu3s->vsid_first |= 0x00800000; 360 for (j = 0; j < 16; j++)
360#endif 361 vcpu3s->vsid_pool[(i * 16) + j] = CTX_TO_VSID(err, j);
361 BUG_ON(vcpu3s->vsid_max < vcpu3s->vsid_first); 362 }
362 363
363 vcpu3s->vsid_next = vcpu3s->vsid_first; 364 vcpu3s->vsid_next = 0;
364 365
365 /* Remember where the HTAB is */ 366 /* Remember where the HTAB is */
366 asm ( "mfsdr1 %0" : "=r"(sdr1) ); 367 asm ( "mfsdr1 %0" : "=r"(sdr1) );
@@ -370,4 +371,14 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
370 kvmppc_mmu_hpte_init(vcpu); 371 kvmppc_mmu_hpte_init(vcpu);
371 372
372 return 0; 373 return 0;
374
375init_fail:
376 for (j = 0; j < i; j++) {
377 if (!vcpu3s->context_id[j])
378 continue;
379
380 __destroy_context(to_book3s(vcpu)->context_id[j]);
381 }
382
383 return -1;
373} 384}
diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index 4025ea26b3c1..d7889ef3211e 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -163,6 +163,22 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
163 bool found = false; 163 bool found = false;
164 bool perm_err = false; 164 bool perm_err = false;
165 int second = 0; 165 int second = 0;
166 ulong mp_ea = vcpu->arch.magic_page_ea;
167
168 /* Magic page override */
169 if (unlikely(mp_ea) &&
170 unlikely((eaddr & ~0xfffULL) == (mp_ea & ~0xfffULL)) &&
171 !(vcpu->arch.shared->msr & MSR_PR)) {
172 gpte->eaddr = eaddr;
173 gpte->vpage = kvmppc_mmu_book3s_64_ea_to_vp(vcpu, eaddr, data);
174 gpte->raddr = vcpu->arch.magic_page_pa | (gpte->raddr & 0xfff);
175 gpte->raddr &= KVM_PAM;
176 gpte->may_execute = true;
177 gpte->may_read = true;
178 gpte->may_write = true;
179
180 return 0;
181 }
166 182
167 slbe = kvmppc_mmu_book3s_64_find_slbe(vcpu_book3s, eaddr); 183 slbe = kvmppc_mmu_book3s_64_find_slbe(vcpu_book3s, eaddr);
168 if (!slbe) 184 if (!slbe)
@@ -180,9 +196,9 @@ do_second:
180 goto no_page_found; 196 goto no_page_found;
181 } 197 }
182 198
183 if ((vcpu->arch.msr & MSR_PR) && slbe->Kp) 199 if ((vcpu->arch.shared->msr & MSR_PR) && slbe->Kp)
184 key = 4; 200 key = 4;
185 else if (!(vcpu->arch.msr & MSR_PR) && slbe->Ks) 201 else if (!(vcpu->arch.shared->msr & MSR_PR) && slbe->Ks)
186 key = 4; 202 key = 4;
187 203
188 for (i=0; i<16; i+=2) { 204 for (i=0; i<16; i+=2) {
@@ -381,7 +397,7 @@ static void kvmppc_mmu_book3s_64_slbia(struct kvm_vcpu *vcpu)
381 for (i = 1; i < vcpu_book3s->slb_nr; i++) 397 for (i = 1; i < vcpu_book3s->slb_nr; i++)
382 vcpu_book3s->slb[i].valid = false; 398 vcpu_book3s->slb[i].valid = false;
383 399
384 if (vcpu->arch.msr & MSR_IR) { 400 if (vcpu->arch.shared->msr & MSR_IR) {
385 kvmppc_mmu_flush_segments(vcpu); 401 kvmppc_mmu_flush_segments(vcpu);
386 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu)); 402 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu));
387 } 403 }
@@ -445,14 +461,15 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
445 ulong ea = esid << SID_SHIFT; 461 ulong ea = esid << SID_SHIFT;
446 struct kvmppc_slb *slb; 462 struct kvmppc_slb *slb;
447 u64 gvsid = esid; 463 u64 gvsid = esid;
464 ulong mp_ea = vcpu->arch.magic_page_ea;
448 465
449 if (vcpu->arch.msr & (MSR_DR|MSR_IR)) { 466 if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
450 slb = kvmppc_mmu_book3s_64_find_slbe(to_book3s(vcpu), ea); 467 slb = kvmppc_mmu_book3s_64_find_slbe(to_book3s(vcpu), ea);
451 if (slb) 468 if (slb)
452 gvsid = slb->vsid; 469 gvsid = slb->vsid;
453 } 470 }
454 471
455 switch (vcpu->arch.msr & (MSR_DR|MSR_IR)) { 472 switch (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
456 case 0: 473 case 0:
457 *vsid = VSID_REAL | esid; 474 *vsid = VSID_REAL | esid;
458 break; 475 break;
@@ -464,7 +481,7 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
464 break; 481 break;
465 case MSR_DR|MSR_IR: 482 case MSR_DR|MSR_IR:
466 if (!slb) 483 if (!slb)
467 return -ENOENT; 484 goto no_slb;
468 485
469 *vsid = gvsid; 486 *vsid = gvsid;
470 break; 487 break;
@@ -473,10 +490,21 @@ static int kvmppc_mmu_book3s_64_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
473 break; 490 break;
474 } 491 }
475 492
476 if (vcpu->arch.msr & MSR_PR) 493 if (vcpu->arch.shared->msr & MSR_PR)
477 *vsid |= VSID_PR; 494 *vsid |= VSID_PR;
478 495
479 return 0; 496 return 0;
497
498no_slb:
499 /* Catch magic page case */
500 if (unlikely(mp_ea) &&
501 unlikely(esid == (mp_ea >> SID_SHIFT)) &&
502 !(vcpu->arch.shared->msr & MSR_PR)) {
503 *vsid = VSID_REAL | esid;
504 return 0;
505 }
506
507 return -EINVAL;
480} 508}
481 509
482static bool kvmppc_mmu_book3s_64_is_dcbz32(struct kvm_vcpu *vcpu) 510static bool kvmppc_mmu_book3s_64_is_dcbz32(struct kvm_vcpu *vcpu)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index 384179a5002b..fa2f08434ba5 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/kvm_host.h> 22#include <linux/kvm_host.h>
23#include <linux/hash.h>
24 23
25#include <asm/kvm_ppc.h> 24#include <asm/kvm_ppc.h>
26#include <asm/kvm_book3s.h> 25#include <asm/kvm_book3s.h>
@@ -28,24 +27,9 @@
28#include <asm/machdep.h> 27#include <asm/machdep.h>
29#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
30#include <asm/hw_irq.h> 29#include <asm/hw_irq.h>
30#include "trace.h"
31 31
32#define PTE_SIZE 12 32#define PTE_SIZE 12
33#define VSID_ALL 0
34
35/* #define DEBUG_MMU */
36/* #define DEBUG_SLB */
37
38#ifdef DEBUG_MMU
39#define dprintk_mmu(a, ...) printk(KERN_INFO a, __VA_ARGS__)
40#else
41#define dprintk_mmu(a, ...) do { } while(0)
42#endif
43
44#ifdef DEBUG_SLB
45#define dprintk_slb(a, ...) printk(KERN_INFO a, __VA_ARGS__)
46#else
47#define dprintk_slb(a, ...) do { } while(0)
48#endif
49 33
50void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) 34void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
51{ 35{
@@ -58,34 +42,39 @@ void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
58 * a hash, so we don't waste cycles on looping */ 42 * a hash, so we don't waste cycles on looping */
59static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid) 43static u16 kvmppc_sid_hash(struct kvm_vcpu *vcpu, u64 gvsid)
60{ 44{
61 return hash_64(gvsid, SID_MAP_BITS); 45 return (u16)(((gvsid >> (SID_MAP_BITS * 7)) & SID_MAP_MASK) ^
46 ((gvsid >> (SID_MAP_BITS * 6)) & SID_MAP_MASK) ^
47 ((gvsid >> (SID_MAP_BITS * 5)) & SID_MAP_MASK) ^
48 ((gvsid >> (SID_MAP_BITS * 4)) & SID_MAP_MASK) ^
49 ((gvsid >> (SID_MAP_BITS * 3)) & SID_MAP_MASK) ^
50 ((gvsid >> (SID_MAP_BITS * 2)) & SID_MAP_MASK) ^
51 ((gvsid >> (SID_MAP_BITS * 1)) & SID_MAP_MASK) ^
52 ((gvsid >> (SID_MAP_BITS * 0)) & SID_MAP_MASK));
62} 53}
63 54
55
64static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid) 56static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)
65{ 57{
66 struct kvmppc_sid_map *map; 58 struct kvmppc_sid_map *map;
67 u16 sid_map_mask; 59 u16 sid_map_mask;
68 60
69 if (vcpu->arch.msr & MSR_PR) 61 if (vcpu->arch.shared->msr & MSR_PR)
70 gvsid |= VSID_PR; 62 gvsid |= VSID_PR;
71 63
72 sid_map_mask = kvmppc_sid_hash(vcpu, gvsid); 64 sid_map_mask = kvmppc_sid_hash(vcpu, gvsid);
73 map = &to_book3s(vcpu)->sid_map[sid_map_mask]; 65 map = &to_book3s(vcpu)->sid_map[sid_map_mask];
74 if (map->guest_vsid == gvsid) { 66 if (map->valid && (map->guest_vsid == gvsid)) {
75 dprintk_slb("SLB: Searching: 0x%llx -> 0x%llx\n", 67 trace_kvm_book3s_slb_found(gvsid, map->host_vsid);
76 gvsid, map->host_vsid);
77 return map; 68 return map;
78 } 69 }
79 70
80 map = &to_book3s(vcpu)->sid_map[SID_MAP_MASK - sid_map_mask]; 71 map = &to_book3s(vcpu)->sid_map[SID_MAP_MASK - sid_map_mask];
81 if (map->guest_vsid == gvsid) { 72 if (map->valid && (map->guest_vsid == gvsid)) {
82 dprintk_slb("SLB: Searching 0x%llx -> 0x%llx\n", 73 trace_kvm_book3s_slb_found(gvsid, map->host_vsid);
83 gvsid, map->host_vsid);
84 return map; 74 return map;
85 } 75 }
86 76
87 dprintk_slb("SLB: Searching %d/%d: 0x%llx -> not found\n", 77 trace_kvm_book3s_slb_fail(sid_map_mask, gvsid);
88 sid_map_mask, SID_MAP_MASK - sid_map_mask, gvsid);
89 return NULL; 78 return NULL;
90} 79}
91 80
@@ -101,18 +90,13 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
101 struct kvmppc_sid_map *map; 90 struct kvmppc_sid_map *map;
102 91
103 /* Get host physical address for gpa */ 92 /* Get host physical address for gpa */
104 hpaddr = gfn_to_pfn(vcpu->kvm, orig_pte->raddr >> PAGE_SHIFT); 93 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
105 if (kvm_is_error_hva(hpaddr)) { 94 if (is_error_pfn(hpaddr)) {
106 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", orig_pte->eaddr); 95 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", orig_pte->eaddr);
107 return -EINVAL; 96 return -EINVAL;
108 } 97 }
109 hpaddr <<= PAGE_SHIFT; 98 hpaddr <<= PAGE_SHIFT;
110#if PAGE_SHIFT == 12 99 hpaddr |= orig_pte->raddr & (~0xfffULL & ~PAGE_MASK);
111#elif PAGE_SHIFT == 16
112 hpaddr |= orig_pte->raddr & 0xf000;
113#else
114#error Unknown page size
115#endif
116 100
117 /* and write the mapping ea -> hpa into the pt */ 101 /* and write the mapping ea -> hpa into the pt */
118 vcpu->arch.mmu.esid_to_vsid(vcpu, orig_pte->eaddr >> SID_SHIFT, &vsid); 102 vcpu->arch.mmu.esid_to_vsid(vcpu, orig_pte->eaddr >> SID_SHIFT, &vsid);
@@ -161,10 +145,7 @@ map_again:
161 } else { 145 } else {
162 struct hpte_cache *pte = kvmppc_mmu_hpte_cache_next(vcpu); 146 struct hpte_cache *pte = kvmppc_mmu_hpte_cache_next(vcpu);
163 147
164 dprintk_mmu("KVM: %c%c Map 0x%lx: [%lx] 0x%lx (0x%llx) -> %lx\n", 148 trace_kvm_book3s_64_mmu_map(rflags, hpteg, va, hpaddr, orig_pte);
165 ((rflags & HPTE_R_PP) == 3) ? '-' : 'w',
166 (rflags & HPTE_R_N) ? '-' : 'x',
167 orig_pte->eaddr, hpteg, va, orig_pte->vpage, hpaddr);
168 149
169 /* The ppc_md code may give us a secondary entry even though we 150 /* The ppc_md code may give us a secondary entry even though we
170 asked for a primary. Fix up. */ 151 asked for a primary. Fix up. */
@@ -191,7 +172,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
191 u16 sid_map_mask; 172 u16 sid_map_mask;
192 static int backwards_map = 0; 173 static int backwards_map = 0;
193 174
194 if (vcpu->arch.msr & MSR_PR) 175 if (vcpu->arch.shared->msr & MSR_PR)
195 gvsid |= VSID_PR; 176 gvsid |= VSID_PR;
196 177
197 /* We might get collisions that trap in preceding order, so let's 178 /* We might get collisions that trap in preceding order, so let's
@@ -219,8 +200,7 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
219 map->guest_vsid = gvsid; 200 map->guest_vsid = gvsid;
220 map->valid = true; 201 map->valid = true;
221 202
222 dprintk_slb("SLB: New mapping at %d: 0x%llx -> 0x%llx\n", 203 trace_kvm_book3s_slb_map(sid_map_mask, gvsid, map->host_vsid);
223 sid_map_mask, gvsid, map->host_vsid);
224 204
225 return map; 205 return map;
226} 206}
@@ -292,7 +272,7 @@ int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr)
292 to_svcpu(vcpu)->slb[slb_index].esid = slb_esid; 272 to_svcpu(vcpu)->slb[slb_index].esid = slb_esid;
293 to_svcpu(vcpu)->slb[slb_index].vsid = slb_vsid; 273 to_svcpu(vcpu)->slb[slb_index].vsid = slb_vsid;
294 274
295 dprintk_slb("slbmte %#llx, %#llx\n", slb_vsid, slb_esid); 275 trace_kvm_book3s_slbmte(slb_vsid, slb_esid);
296 276
297 return 0; 277 return 0;
298} 278}
@@ -306,7 +286,7 @@ void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu)
306void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) 286void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu)
307{ 287{
308 kvmppc_mmu_hpte_destroy(vcpu); 288 kvmppc_mmu_hpte_destroy(vcpu);
309 __destroy_context(to_book3s(vcpu)->context_id); 289 __destroy_context(to_book3s(vcpu)->context_id[0]);
310} 290}
311 291
312int kvmppc_mmu_init(struct kvm_vcpu *vcpu) 292int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
@@ -317,10 +297,10 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
317 err = __init_new_context(); 297 err = __init_new_context();
318 if (err < 0) 298 if (err < 0)
319 return -1; 299 return -1;
320 vcpu3s->context_id = err; 300 vcpu3s->context_id[0] = err;
321 301
322 vcpu3s->vsid_max = ((vcpu3s->context_id + 1) << USER_ESID_BITS) - 1; 302 vcpu3s->vsid_max = ((vcpu3s->context_id[0] + 1) << USER_ESID_BITS) - 1;
323 vcpu3s->vsid_first = vcpu3s->context_id << USER_ESID_BITS; 303 vcpu3s->vsid_first = vcpu3s->context_id[0] << USER_ESID_BITS;
324 vcpu3s->vsid_next = vcpu3s->vsid_first; 304 vcpu3s->vsid_next = vcpu3s->vsid_first;
325 305
326 kvmppc_mmu_hpte_init(vcpu); 306 kvmppc_mmu_hpte_init(vcpu);
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
index c85f906038ce..466846557089 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -73,8 +73,8 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
73 switch (get_xop(inst)) { 73 switch (get_xop(inst)) {
74 case OP_19_XOP_RFID: 74 case OP_19_XOP_RFID:
75 case OP_19_XOP_RFI: 75 case OP_19_XOP_RFI:
76 kvmppc_set_pc(vcpu, vcpu->arch.srr0); 76 kvmppc_set_pc(vcpu, vcpu->arch.shared->srr0);
77 kvmppc_set_msr(vcpu, vcpu->arch.srr1); 77 kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
78 *advance = 0; 78 *advance = 0;
79 break; 79 break;
80 80
@@ -86,14 +86,15 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
86 case 31: 86 case 31:
87 switch (get_xop(inst)) { 87 switch (get_xop(inst)) {
88 case OP_31_XOP_MFMSR: 88 case OP_31_XOP_MFMSR:
89 kvmppc_set_gpr(vcpu, get_rt(inst), vcpu->arch.msr); 89 kvmppc_set_gpr(vcpu, get_rt(inst),
90 vcpu->arch.shared->msr);
90 break; 91 break;
91 case OP_31_XOP_MTMSRD: 92 case OP_31_XOP_MTMSRD:
92 { 93 {
93 ulong rs = kvmppc_get_gpr(vcpu, get_rs(inst)); 94 ulong rs = kvmppc_get_gpr(vcpu, get_rs(inst));
94 if (inst & 0x10000) { 95 if (inst & 0x10000) {
95 vcpu->arch.msr &= ~(MSR_RI | MSR_EE); 96 vcpu->arch.shared->msr &= ~(MSR_RI | MSR_EE);
96 vcpu->arch.msr |= rs & (MSR_RI | MSR_EE); 97 vcpu->arch.shared->msr |= rs & (MSR_RI | MSR_EE);
97 } else 98 } else
98 kvmppc_set_msr(vcpu, rs); 99 kvmppc_set_msr(vcpu, rs);
99 break; 100 break;
@@ -204,14 +205,14 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
204 ra = kvmppc_get_gpr(vcpu, get_ra(inst)); 205 ra = kvmppc_get_gpr(vcpu, get_ra(inst));
205 206
206 addr = (ra + rb) & ~31ULL; 207 addr = (ra + rb) & ~31ULL;
207 if (!(vcpu->arch.msr & MSR_SF)) 208 if (!(vcpu->arch.shared->msr & MSR_SF))
208 addr &= 0xffffffff; 209 addr &= 0xffffffff;
209 vaddr = addr; 210 vaddr = addr;
210 211
211 r = kvmppc_st(vcpu, &addr, 32, zeros, true); 212 r = kvmppc_st(vcpu, &addr, 32, zeros, true);
212 if ((r == -ENOENT) || (r == -EPERM)) { 213 if ((r == -ENOENT) || (r == -EPERM)) {
213 *advance = 0; 214 *advance = 0;
214 vcpu->arch.dear = vaddr; 215 vcpu->arch.shared->dar = vaddr;
215 to_svcpu(vcpu)->fault_dar = vaddr; 216 to_svcpu(vcpu)->fault_dar = vaddr;
216 217
217 dsisr = DSISR_ISSTORE; 218 dsisr = DSISR_ISSTORE;
@@ -220,7 +221,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
220 else if (r == -EPERM) 221 else if (r == -EPERM)
221 dsisr |= DSISR_PROTFAULT; 222 dsisr |= DSISR_PROTFAULT;
222 223
223 to_book3s(vcpu)->dsisr = dsisr; 224 vcpu->arch.shared->dsisr = dsisr;
224 to_svcpu(vcpu)->fault_dsisr = dsisr; 225 to_svcpu(vcpu)->fault_dsisr = dsisr;
225 226
226 kvmppc_book3s_queue_irqprio(vcpu, 227 kvmppc_book3s_queue_irqprio(vcpu,
@@ -263,7 +264,7 @@ void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, bool upper,
263 } 264 }
264} 265}
265 266
266static u32 kvmppc_read_bat(struct kvm_vcpu *vcpu, int sprn) 267static struct kvmppc_bat *kvmppc_find_bat(struct kvm_vcpu *vcpu, int sprn)
267{ 268{
268 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu); 269 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
269 struct kvmppc_bat *bat; 270 struct kvmppc_bat *bat;
@@ -285,35 +286,7 @@ static u32 kvmppc_read_bat(struct kvm_vcpu *vcpu, int sprn)
285 BUG(); 286 BUG();
286 } 287 }
287 288
288 if (sprn % 2) 289 return bat;
289 return bat->raw >> 32;
290 else
291 return bat->raw;
292}
293
294static void kvmppc_write_bat(struct kvm_vcpu *vcpu, int sprn, u32 val)
295{
296 struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
297 struct kvmppc_bat *bat;
298
299 switch (sprn) {
300 case SPRN_IBAT0U ... SPRN_IBAT3L:
301 bat = &vcpu_book3s->ibat[(sprn - SPRN_IBAT0U) / 2];
302 break;
303 case SPRN_IBAT4U ... SPRN_IBAT7L:
304 bat = &vcpu_book3s->ibat[4 + ((sprn - SPRN_IBAT4U) / 2)];
305 break;
306 case SPRN_DBAT0U ... SPRN_DBAT3L:
307 bat = &vcpu_book3s->dbat[(sprn - SPRN_DBAT0U) / 2];
308 break;
309 case SPRN_DBAT4U ... SPRN_DBAT7L:
310 bat = &vcpu_book3s->dbat[4 + ((sprn - SPRN_DBAT4U) / 2)];
311 break;
312 default:
313 BUG();
314 }
315
316 kvmppc_set_bat(vcpu, bat, !(sprn % 2), val);
317} 290}
318 291
319int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs) 292int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
@@ -326,10 +299,10 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
326 to_book3s(vcpu)->sdr1 = spr_val; 299 to_book3s(vcpu)->sdr1 = spr_val;
327 break; 300 break;
328 case SPRN_DSISR: 301 case SPRN_DSISR:
329 to_book3s(vcpu)->dsisr = spr_val; 302 vcpu->arch.shared->dsisr = spr_val;
330 break; 303 break;
331 case SPRN_DAR: 304 case SPRN_DAR:
332 vcpu->arch.dear = spr_val; 305 vcpu->arch.shared->dar = spr_val;
333 break; 306 break;
334 case SPRN_HIOR: 307 case SPRN_HIOR:
335 to_book3s(vcpu)->hior = spr_val; 308 to_book3s(vcpu)->hior = spr_val;
@@ -338,12 +311,16 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
338 case SPRN_IBAT4U ... SPRN_IBAT7L: 311 case SPRN_IBAT4U ... SPRN_IBAT7L:
339 case SPRN_DBAT0U ... SPRN_DBAT3L: 312 case SPRN_DBAT0U ... SPRN_DBAT3L:
340 case SPRN_DBAT4U ... SPRN_DBAT7L: 313 case SPRN_DBAT4U ... SPRN_DBAT7L:
341 kvmppc_write_bat(vcpu, sprn, (u32)spr_val); 314 {
315 struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);
316
317 kvmppc_set_bat(vcpu, bat, !(sprn % 2), (u32)spr_val);
342 /* BAT writes happen so rarely that we're ok to flush 318 /* BAT writes happen so rarely that we're ok to flush
343 * everything here */ 319 * everything here */
344 kvmppc_mmu_pte_flush(vcpu, 0, 0); 320 kvmppc_mmu_pte_flush(vcpu, 0, 0);
345 kvmppc_mmu_flush_segments(vcpu); 321 kvmppc_mmu_flush_segments(vcpu);
346 break; 322 break;
323 }
347 case SPRN_HID0: 324 case SPRN_HID0:
348 to_book3s(vcpu)->hid[0] = spr_val; 325 to_book3s(vcpu)->hid[0] = spr_val;
349 break; 326 break;
@@ -433,16 +410,24 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
433 case SPRN_IBAT4U ... SPRN_IBAT7L: 410 case SPRN_IBAT4U ... SPRN_IBAT7L:
434 case SPRN_DBAT0U ... SPRN_DBAT3L: 411 case SPRN_DBAT0U ... SPRN_DBAT3L:
435 case SPRN_DBAT4U ... SPRN_DBAT7L: 412 case SPRN_DBAT4U ... SPRN_DBAT7L:
436 kvmppc_set_gpr(vcpu, rt, kvmppc_read_bat(vcpu, sprn)); 413 {
414 struct kvmppc_bat *bat = kvmppc_find_bat(vcpu, sprn);
415
416 if (sprn % 2)
417 kvmppc_set_gpr(vcpu, rt, bat->raw >> 32);
418 else
419 kvmppc_set_gpr(vcpu, rt, bat->raw);
420
437 break; 421 break;
422 }
438 case SPRN_SDR1: 423 case SPRN_SDR1:
439 kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->sdr1); 424 kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->sdr1);
440 break; 425 break;
441 case SPRN_DSISR: 426 case SPRN_DSISR:
442 kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->dsisr); 427 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dsisr);
443 break; 428 break;
444 case SPRN_DAR: 429 case SPRN_DAR:
445 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dear); 430 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dar);
446 break; 431 break;
447 case SPRN_HIOR: 432 case SPRN_HIOR:
448 kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hior); 433 kvmppc_set_gpr(vcpu, rt, to_book3s(vcpu)->hior);
diff --git a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c
index 4868d4a7ebc5..79751d8dd131 100644
--- a/arch/powerpc/kvm/book3s_mmu_hpte.c
+++ b/arch/powerpc/kvm/book3s_mmu_hpte.c
@@ -21,6 +21,7 @@
21#include <linux/kvm_host.h> 21#include <linux/kvm_host.h>
22#include <linux/hash.h> 22#include <linux/hash.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include "trace.h"
24 25
25#include <asm/kvm_ppc.h> 26#include <asm/kvm_ppc.h>
26#include <asm/kvm_book3s.h> 27#include <asm/kvm_book3s.h>
@@ -30,14 +31,6 @@
30 31
31#define PTE_SIZE 12 32#define PTE_SIZE 12
32 33
33/* #define DEBUG_MMU */
34
35#ifdef DEBUG_MMU
36#define dprintk_mmu(a, ...) printk(KERN_INFO a, __VA_ARGS__)
37#else
38#define dprintk_mmu(a, ...) do { } while(0)
39#endif
40
41static struct kmem_cache *hpte_cache; 34static struct kmem_cache *hpte_cache;
42 35
43static inline u64 kvmppc_mmu_hash_pte(u64 eaddr) 36static inline u64 kvmppc_mmu_hash_pte(u64 eaddr)
@@ -45,6 +38,12 @@ static inline u64 kvmppc_mmu_hash_pte(u64 eaddr)
45 return hash_64(eaddr >> PTE_SIZE, HPTEG_HASH_BITS_PTE); 38 return hash_64(eaddr >> PTE_SIZE, HPTEG_HASH_BITS_PTE);
46} 39}
47 40
41static inline u64 kvmppc_mmu_hash_pte_long(u64 eaddr)
42{
43 return hash_64((eaddr & 0x0ffff000) >> PTE_SIZE,
44 HPTEG_HASH_BITS_PTE_LONG);
45}
46
48static inline u64 kvmppc_mmu_hash_vpte(u64 vpage) 47static inline u64 kvmppc_mmu_hash_vpte(u64 vpage)
49{ 48{
50 return hash_64(vpage & 0xfffffffffULL, HPTEG_HASH_BITS_VPTE); 49 return hash_64(vpage & 0xfffffffffULL, HPTEG_HASH_BITS_VPTE);
@@ -60,77 +59,128 @@ void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
60{ 59{
61 u64 index; 60 u64 index;
62 61
62 trace_kvm_book3s_mmu_map(pte);
63
64 spin_lock(&vcpu->arch.mmu_lock);
65
63 /* Add to ePTE list */ 66 /* Add to ePTE list */
64 index = kvmppc_mmu_hash_pte(pte->pte.eaddr); 67 index = kvmppc_mmu_hash_pte(pte->pte.eaddr);
65 hlist_add_head(&pte->list_pte, &vcpu->arch.hpte_hash_pte[index]); 68 hlist_add_head_rcu(&pte->list_pte, &vcpu->arch.hpte_hash_pte[index]);
69
70 /* Add to ePTE_long list */
71 index = kvmppc_mmu_hash_pte_long(pte->pte.eaddr);
72 hlist_add_head_rcu(&pte->list_pte_long,
73 &vcpu->arch.hpte_hash_pte_long[index]);
66 74
67 /* Add to vPTE list */ 75 /* Add to vPTE list */
68 index = kvmppc_mmu_hash_vpte(pte->pte.vpage); 76 index = kvmppc_mmu_hash_vpte(pte->pte.vpage);
69 hlist_add_head(&pte->list_vpte, &vcpu->arch.hpte_hash_vpte[index]); 77 hlist_add_head_rcu(&pte->list_vpte, &vcpu->arch.hpte_hash_vpte[index]);
70 78
71 /* Add to vPTE_long list */ 79 /* Add to vPTE_long list */
72 index = kvmppc_mmu_hash_vpte_long(pte->pte.vpage); 80 index = kvmppc_mmu_hash_vpte_long(pte->pte.vpage);
73 hlist_add_head(&pte->list_vpte_long, 81 hlist_add_head_rcu(&pte->list_vpte_long,
74 &vcpu->arch.hpte_hash_vpte_long[index]); 82 &vcpu->arch.hpte_hash_vpte_long[index]);
83
84 spin_unlock(&vcpu->arch.mmu_lock);
85}
86
87static void free_pte_rcu(struct rcu_head *head)
88{
89 struct hpte_cache *pte = container_of(head, struct hpte_cache, rcu_head);
90 kmem_cache_free(hpte_cache, pte);
75} 91}
76 92
77static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) 93static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
78{ 94{
79 dprintk_mmu("KVM: Flushing SPT: 0x%lx (0x%llx) -> 0x%llx\n", 95 trace_kvm_book3s_mmu_invalidate(pte);
80 pte->pte.eaddr, pte->pte.vpage, pte->host_va);
81 96
82 /* Different for 32 and 64 bit */ 97 /* Different for 32 and 64 bit */
83 kvmppc_mmu_invalidate_pte(vcpu, pte); 98 kvmppc_mmu_invalidate_pte(vcpu, pte);
84 99
100 spin_lock(&vcpu->arch.mmu_lock);
101
102 /* pte already invalidated in between? */
103 if (hlist_unhashed(&pte->list_pte)) {
104 spin_unlock(&vcpu->arch.mmu_lock);
105 return;
106 }
107
108 hlist_del_init_rcu(&pte->list_pte);
109 hlist_del_init_rcu(&pte->list_pte_long);
110 hlist_del_init_rcu(&pte->list_vpte);
111 hlist_del_init_rcu(&pte->list_vpte_long);
112
85 if (pte->pte.may_write) 113 if (pte->pte.may_write)
86 kvm_release_pfn_dirty(pte->pfn); 114 kvm_release_pfn_dirty(pte->pfn);
87 else 115 else
88 kvm_release_pfn_clean(pte->pfn); 116 kvm_release_pfn_clean(pte->pfn);
89 117
90 hlist_del(&pte->list_pte); 118 spin_unlock(&vcpu->arch.mmu_lock);
91 hlist_del(&pte->list_vpte);
92 hlist_del(&pte->list_vpte_long);
93 119
94 vcpu->arch.hpte_cache_count--; 120 vcpu->arch.hpte_cache_count--;
95 kmem_cache_free(hpte_cache, pte); 121 call_rcu(&pte->rcu_head, free_pte_rcu);
96} 122}
97 123
98static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu) 124static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu)
99{ 125{
100 struct hpte_cache *pte; 126 struct hpte_cache *pte;
101 struct hlist_node *node, *tmp; 127 struct hlist_node *node;
102 int i; 128 int i;
103 129
130 rcu_read_lock();
131
104 for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) { 132 for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) {
105 struct hlist_head *list = &vcpu->arch.hpte_hash_vpte_long[i]; 133 struct hlist_head *list = &vcpu->arch.hpte_hash_vpte_long[i];
106 134
107 hlist_for_each_entry_safe(pte, node, tmp, list, list_vpte_long) 135 hlist_for_each_entry_rcu(pte, node, list, list_vpte_long)
108 invalidate_pte(vcpu, pte); 136 invalidate_pte(vcpu, pte);
109 } 137 }
138
139 rcu_read_unlock();
110} 140}
111 141
112static void kvmppc_mmu_pte_flush_page(struct kvm_vcpu *vcpu, ulong guest_ea) 142static void kvmppc_mmu_pte_flush_page(struct kvm_vcpu *vcpu, ulong guest_ea)
113{ 143{
114 struct hlist_head *list; 144 struct hlist_head *list;
115 struct hlist_node *node, *tmp; 145 struct hlist_node *node;
116 struct hpte_cache *pte; 146 struct hpte_cache *pte;
117 147
118 /* Find the list of entries in the map */ 148 /* Find the list of entries in the map */
119 list = &vcpu->arch.hpte_hash_pte[kvmppc_mmu_hash_pte(guest_ea)]; 149 list = &vcpu->arch.hpte_hash_pte[kvmppc_mmu_hash_pte(guest_ea)];
120 150
151 rcu_read_lock();
152
121 /* Check the list for matching entries and invalidate */ 153 /* Check the list for matching entries and invalidate */
122 hlist_for_each_entry_safe(pte, node, tmp, list, list_pte) 154 hlist_for_each_entry_rcu(pte, node, list, list_pte)
123 if ((pte->pte.eaddr & ~0xfffUL) == guest_ea) 155 if ((pte->pte.eaddr & ~0xfffUL) == guest_ea)
124 invalidate_pte(vcpu, pte); 156 invalidate_pte(vcpu, pte);
157
158 rcu_read_unlock();
125} 159}
126 160
127void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong guest_ea, ulong ea_mask) 161static void kvmppc_mmu_pte_flush_long(struct kvm_vcpu *vcpu, ulong guest_ea)
128{ 162{
129 u64 i; 163 struct hlist_head *list;
164 struct hlist_node *node;
165 struct hpte_cache *pte;
130 166
131 dprintk_mmu("KVM: Flushing %d Shadow PTEs: 0x%lx & 0x%lx\n", 167 /* Find the list of entries in the map */
132 vcpu->arch.hpte_cache_count, guest_ea, ea_mask); 168 list = &vcpu->arch.hpte_hash_pte_long[
169 kvmppc_mmu_hash_pte_long(guest_ea)];
133 170
171 rcu_read_lock();
172
173 /* Check the list for matching entries and invalidate */
174 hlist_for_each_entry_rcu(pte, node, list, list_pte_long)
175 if ((pte->pte.eaddr & 0x0ffff000UL) == guest_ea)
176 invalidate_pte(vcpu, pte);
177
178 rcu_read_unlock();
179}
180
181void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong guest_ea, ulong ea_mask)
182{
183 trace_kvm_book3s_mmu_flush("", vcpu, guest_ea, ea_mask);
134 guest_ea &= ea_mask; 184 guest_ea &= ea_mask;
135 185
136 switch (ea_mask) { 186 switch (ea_mask) {
@@ -138,9 +188,7 @@ void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong guest_ea, ulong ea_mask)
138 kvmppc_mmu_pte_flush_page(vcpu, guest_ea); 188 kvmppc_mmu_pte_flush_page(vcpu, guest_ea);
139 break; 189 break;
140 case 0x0ffff000: 190 case 0x0ffff000:
141 /* 32-bit flush w/o segment, go through all possible segments */ 191 kvmppc_mmu_pte_flush_long(vcpu, guest_ea);
142 for (i = 0; i < 0x100000000ULL; i += 0x10000000ULL)
143 kvmppc_mmu_pte_flush(vcpu, guest_ea | i, ~0xfffUL);
144 break; 192 break;
145 case 0: 193 case 0:
146 /* Doing a complete flush -> start from scratch */ 194 /* Doing a complete flush -> start from scratch */
@@ -156,39 +204,46 @@ void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong guest_ea, ulong ea_mask)
156static void kvmppc_mmu_pte_vflush_short(struct kvm_vcpu *vcpu, u64 guest_vp) 204static void kvmppc_mmu_pte_vflush_short(struct kvm_vcpu *vcpu, u64 guest_vp)
157{ 205{
158 struct hlist_head *list; 206 struct hlist_head *list;
159 struct hlist_node *node, *tmp; 207 struct hlist_node *node;
160 struct hpte_cache *pte; 208 struct hpte_cache *pte;
161 u64 vp_mask = 0xfffffffffULL; 209 u64 vp_mask = 0xfffffffffULL;
162 210
163 list = &vcpu->arch.hpte_hash_vpte[kvmppc_mmu_hash_vpte(guest_vp)]; 211 list = &vcpu->arch.hpte_hash_vpte[kvmppc_mmu_hash_vpte(guest_vp)];
164 212
213 rcu_read_lock();
214
165 /* Check the list for matching entries and invalidate */ 215 /* Check the list for matching entries and invalidate */
166 hlist_for_each_entry_safe(pte, node, tmp, list, list_vpte) 216 hlist_for_each_entry_rcu(pte, node, list, list_vpte)
167 if ((pte->pte.vpage & vp_mask) == guest_vp) 217 if ((pte->pte.vpage & vp_mask) == guest_vp)
168 invalidate_pte(vcpu, pte); 218 invalidate_pte(vcpu, pte);
219
220 rcu_read_unlock();
169} 221}
170 222
171/* Flush with mask 0xffffff000 */ 223/* Flush with mask 0xffffff000 */
172static void kvmppc_mmu_pte_vflush_long(struct kvm_vcpu *vcpu, u64 guest_vp) 224static void kvmppc_mmu_pte_vflush_long(struct kvm_vcpu *vcpu, u64 guest_vp)
173{ 225{
174 struct hlist_head *list; 226 struct hlist_head *list;
175 struct hlist_node *node, *tmp; 227 struct hlist_node *node;
176 struct hpte_cache *pte; 228 struct hpte_cache *pte;
177 u64 vp_mask = 0xffffff000ULL; 229 u64 vp_mask = 0xffffff000ULL;
178 230
179 list = &vcpu->arch.hpte_hash_vpte_long[ 231 list = &vcpu->arch.hpte_hash_vpte_long[
180 kvmppc_mmu_hash_vpte_long(guest_vp)]; 232 kvmppc_mmu_hash_vpte_long(guest_vp)];
181 233
234 rcu_read_lock();
235
182 /* Check the list for matching entries and invalidate */ 236 /* Check the list for matching entries and invalidate */
183 hlist_for_each_entry_safe(pte, node, tmp, list, list_vpte_long) 237 hlist_for_each_entry_rcu(pte, node, list, list_vpte_long)
184 if ((pte->pte.vpage & vp_mask) == guest_vp) 238 if ((pte->pte.vpage & vp_mask) == guest_vp)
185 invalidate_pte(vcpu, pte); 239 invalidate_pte(vcpu, pte);
240
241 rcu_read_unlock();
186} 242}
187 243
188void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 guest_vp, u64 vp_mask) 244void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 guest_vp, u64 vp_mask)
189{ 245{
190 dprintk_mmu("KVM: Flushing %d Shadow vPTEs: 0x%llx & 0x%llx\n", 246 trace_kvm_book3s_mmu_flush("v", vcpu, guest_vp, vp_mask);
191 vcpu->arch.hpte_cache_count, guest_vp, vp_mask);
192 guest_vp &= vp_mask; 247 guest_vp &= vp_mask;
193 248
194 switch(vp_mask) { 249 switch(vp_mask) {
@@ -206,21 +261,24 @@ void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 guest_vp, u64 vp_mask)
206 261
207void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end) 262void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end)
208{ 263{
209 struct hlist_node *node, *tmp; 264 struct hlist_node *node;
210 struct hpte_cache *pte; 265 struct hpte_cache *pte;
211 int i; 266 int i;
212 267
213 dprintk_mmu("KVM: Flushing %d Shadow pPTEs: 0x%lx - 0x%lx\n", 268 trace_kvm_book3s_mmu_flush("p", vcpu, pa_start, pa_end);
214 vcpu->arch.hpte_cache_count, pa_start, pa_end); 269
270 rcu_read_lock();
215 271
216 for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) { 272 for (i = 0; i < HPTEG_HASH_NUM_VPTE_LONG; i++) {
217 struct hlist_head *list = &vcpu->arch.hpte_hash_vpte_long[i]; 273 struct hlist_head *list = &vcpu->arch.hpte_hash_vpte_long[i];
218 274
219 hlist_for_each_entry_safe(pte, node, tmp, list, list_vpte_long) 275 hlist_for_each_entry_rcu(pte, node, list, list_vpte_long)
220 if ((pte->pte.raddr >= pa_start) && 276 if ((pte->pte.raddr >= pa_start) &&
221 (pte->pte.raddr < pa_end)) 277 (pte->pte.raddr < pa_end))
222 invalidate_pte(vcpu, pte); 278 invalidate_pte(vcpu, pte);
223 } 279 }
280
281 rcu_read_unlock();
224} 282}
225 283
226struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu) 284struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu)
@@ -254,11 +312,15 @@ int kvmppc_mmu_hpte_init(struct kvm_vcpu *vcpu)
254 /* init hpte lookup hashes */ 312 /* init hpte lookup hashes */
255 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_pte, 313 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_pte,
256 ARRAY_SIZE(vcpu->arch.hpte_hash_pte)); 314 ARRAY_SIZE(vcpu->arch.hpte_hash_pte));
315 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_pte_long,
316 ARRAY_SIZE(vcpu->arch.hpte_hash_pte_long));
257 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_vpte, 317 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_vpte,
258 ARRAY_SIZE(vcpu->arch.hpte_hash_vpte)); 318 ARRAY_SIZE(vcpu->arch.hpte_hash_vpte));
259 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_vpte_long, 319 kvmppc_mmu_hpte_init_hash(vcpu->arch.hpte_hash_vpte_long,
260 ARRAY_SIZE(vcpu->arch.hpte_hash_vpte_long)); 320 ARRAY_SIZE(vcpu->arch.hpte_hash_vpte_long));
261 321
322 spin_lock_init(&vcpu->arch.mmu_lock);
323
262 return 0; 324 return 0;
263} 325}
264 326
diff --git a/arch/powerpc/kvm/book3s_paired_singles.c b/arch/powerpc/kvm/book3s_paired_singles.c
index 474f2e24050a..7b0ee96c1bed 100644
--- a/arch/powerpc/kvm/book3s_paired_singles.c
+++ b/arch/powerpc/kvm/book3s_paired_singles.c
@@ -159,20 +159,21 @@
159 159
160static inline void kvmppc_sync_qpr(struct kvm_vcpu *vcpu, int rt) 160static inline void kvmppc_sync_qpr(struct kvm_vcpu *vcpu, int rt)
161{ 161{
162 kvm_cvt_df(&vcpu->arch.fpr[rt], &vcpu->arch.qpr[rt], &vcpu->arch.fpscr); 162 kvm_cvt_df(&vcpu->arch.fpr[rt], &vcpu->arch.qpr[rt]);
163} 163}
164 164
165static void kvmppc_inject_pf(struct kvm_vcpu *vcpu, ulong eaddr, bool is_store) 165static void kvmppc_inject_pf(struct kvm_vcpu *vcpu, ulong eaddr, bool is_store)
166{ 166{
167 u64 dsisr; 167 u64 dsisr;
168 struct kvm_vcpu_arch_shared *shared = vcpu->arch.shared;
168 169
169 vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 33, 36, 0); 170 shared->msr = kvmppc_set_field(shared->msr, 33, 36, 0);
170 vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 42, 47, 0); 171 shared->msr = kvmppc_set_field(shared->msr, 42, 47, 0);
171 vcpu->arch.dear = eaddr; 172 shared->dar = eaddr;
172 /* Page Fault */ 173 /* Page Fault */
173 dsisr = kvmppc_set_field(0, 33, 33, 1); 174 dsisr = kvmppc_set_field(0, 33, 33, 1);
174 if (is_store) 175 if (is_store)
175 to_book3s(vcpu)->dsisr = kvmppc_set_field(dsisr, 38, 38, 1); 176 shared->dsisr = kvmppc_set_field(dsisr, 38, 38, 1);
176 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE); 177 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE);
177} 178}
178 179
@@ -204,7 +205,7 @@ static int kvmppc_emulate_fpr_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
204 /* put in registers */ 205 /* put in registers */
205 switch (ls_type) { 206 switch (ls_type) {
206 case FPU_LS_SINGLE: 207 case FPU_LS_SINGLE:
207 kvm_cvt_fd((u32*)tmp, &vcpu->arch.fpr[rs], &vcpu->arch.fpscr); 208 kvm_cvt_fd((u32*)tmp, &vcpu->arch.fpr[rs]);
208 vcpu->arch.qpr[rs] = *((u32*)tmp); 209 vcpu->arch.qpr[rs] = *((u32*)tmp);
209 break; 210 break;
210 case FPU_LS_DOUBLE: 211 case FPU_LS_DOUBLE:
@@ -230,7 +231,7 @@ static int kvmppc_emulate_fpr_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
230 231
231 switch (ls_type) { 232 switch (ls_type) {
232 case FPU_LS_SINGLE: 233 case FPU_LS_SINGLE:
233 kvm_cvt_df(&vcpu->arch.fpr[rs], (u32*)tmp, &vcpu->arch.fpscr); 234 kvm_cvt_df(&vcpu->arch.fpr[rs], (u32*)tmp);
234 val = *((u32*)tmp); 235 val = *((u32*)tmp);
235 len = sizeof(u32); 236 len = sizeof(u32);
236 break; 237 break;
@@ -296,7 +297,7 @@ static int kvmppc_emulate_psq_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
296 emulated = EMULATE_DONE; 297 emulated = EMULATE_DONE;
297 298
298 /* put in registers */ 299 /* put in registers */
299 kvm_cvt_fd(&tmp[0], &vcpu->arch.fpr[rs], &vcpu->arch.fpscr); 300 kvm_cvt_fd(&tmp[0], &vcpu->arch.fpr[rs]);
300 vcpu->arch.qpr[rs] = tmp[1]; 301 vcpu->arch.qpr[rs] = tmp[1];
301 302
302 dprintk(KERN_INFO "KVM: PSQ_LD [0x%x, 0x%x] at 0x%lx (%d)\n", tmp[0], 303 dprintk(KERN_INFO "KVM: PSQ_LD [0x%x, 0x%x] at 0x%lx (%d)\n", tmp[0],
@@ -314,7 +315,7 @@ static int kvmppc_emulate_psq_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
314 u32 tmp[2]; 315 u32 tmp[2];
315 int len = w ? sizeof(u32) : sizeof(u64); 316 int len = w ? sizeof(u32) : sizeof(u64);
316 317
317 kvm_cvt_df(&vcpu->arch.fpr[rs], &tmp[0], &vcpu->arch.fpscr); 318 kvm_cvt_df(&vcpu->arch.fpr[rs], &tmp[0]);
318 tmp[1] = vcpu->arch.qpr[rs]; 319 tmp[1] = vcpu->arch.qpr[rs];
319 320
320 r = kvmppc_st(vcpu, &addr, len, tmp, true); 321 r = kvmppc_st(vcpu, &addr, len, tmp, true);
@@ -516,9 +517,9 @@ static int kvmppc_ps_three_in(struct kvm_vcpu *vcpu, bool rc,
516 WARN_ON(rc); 517 WARN_ON(rc);
517 518
518 /* PS0 */ 519 /* PS0 */
519 kvm_cvt_df(&fpr[reg_in1], &ps0_in1, &vcpu->arch.fpscr); 520 kvm_cvt_df(&fpr[reg_in1], &ps0_in1);
520 kvm_cvt_df(&fpr[reg_in2], &ps0_in2, &vcpu->arch.fpscr); 521 kvm_cvt_df(&fpr[reg_in2], &ps0_in2);
521 kvm_cvt_df(&fpr[reg_in3], &ps0_in3, &vcpu->arch.fpscr); 522 kvm_cvt_df(&fpr[reg_in3], &ps0_in3);
522 523
523 if (scalar & SCALAR_LOW) 524 if (scalar & SCALAR_LOW)
524 ps0_in2 = qpr[reg_in2]; 525 ps0_in2 = qpr[reg_in2];
@@ -529,7 +530,7 @@ static int kvmppc_ps_three_in(struct kvm_vcpu *vcpu, bool rc,
529 ps0_in1, ps0_in2, ps0_in3, ps0_out); 530 ps0_in1, ps0_in2, ps0_in3, ps0_out);
530 531
531 if (!(scalar & SCALAR_NO_PS0)) 532 if (!(scalar & SCALAR_NO_PS0))
532 kvm_cvt_fd(&ps0_out, &fpr[reg_out], &vcpu->arch.fpscr); 533 kvm_cvt_fd(&ps0_out, &fpr[reg_out]);
533 534
534 /* PS1 */ 535 /* PS1 */
535 ps1_in1 = qpr[reg_in1]; 536 ps1_in1 = qpr[reg_in1];
@@ -566,12 +567,12 @@ static int kvmppc_ps_two_in(struct kvm_vcpu *vcpu, bool rc,
566 WARN_ON(rc); 567 WARN_ON(rc);
567 568
568 /* PS0 */ 569 /* PS0 */
569 kvm_cvt_df(&fpr[reg_in1], &ps0_in1, &vcpu->arch.fpscr); 570 kvm_cvt_df(&fpr[reg_in1], &ps0_in1);
570 571
571 if (scalar & SCALAR_LOW) 572 if (scalar & SCALAR_LOW)
572 ps0_in2 = qpr[reg_in2]; 573 ps0_in2 = qpr[reg_in2];
573 else 574 else
574 kvm_cvt_df(&fpr[reg_in2], &ps0_in2, &vcpu->arch.fpscr); 575 kvm_cvt_df(&fpr[reg_in2], &ps0_in2);
575 576
576 func(&vcpu->arch.fpscr, &ps0_out, &ps0_in1, &ps0_in2); 577 func(&vcpu->arch.fpscr, &ps0_out, &ps0_in1, &ps0_in2);
577 578
@@ -579,7 +580,7 @@ static int kvmppc_ps_two_in(struct kvm_vcpu *vcpu, bool rc,
579 dprintk(KERN_INFO "PS2 ps0 -> f(0x%x, 0x%x) = 0x%x\n", 580 dprintk(KERN_INFO "PS2 ps0 -> f(0x%x, 0x%x) = 0x%x\n",
580 ps0_in1, ps0_in2, ps0_out); 581 ps0_in1, ps0_in2, ps0_out);
581 582
582 kvm_cvt_fd(&ps0_out, &fpr[reg_out], &vcpu->arch.fpscr); 583 kvm_cvt_fd(&ps0_out, &fpr[reg_out]);
583 } 584 }
584 585
585 /* PS1 */ 586 /* PS1 */
@@ -615,13 +616,13 @@ static int kvmppc_ps_one_in(struct kvm_vcpu *vcpu, bool rc,
615 WARN_ON(rc); 616 WARN_ON(rc);
616 617
617 /* PS0 */ 618 /* PS0 */
618 kvm_cvt_df(&fpr[reg_in], &ps0_in, &vcpu->arch.fpscr); 619 kvm_cvt_df(&fpr[reg_in], &ps0_in);
619 func(&vcpu->arch.fpscr, &ps0_out, &ps0_in); 620 func(&vcpu->arch.fpscr, &ps0_out, &ps0_in);
620 621
621 dprintk(KERN_INFO "PS1 ps0 -> f(0x%x) = 0x%x\n", 622 dprintk(KERN_INFO "PS1 ps0 -> f(0x%x) = 0x%x\n",
622 ps0_in, ps0_out); 623 ps0_in, ps0_out);
623 624
624 kvm_cvt_fd(&ps0_out, &fpr[reg_out], &vcpu->arch.fpscr); 625 kvm_cvt_fd(&ps0_out, &fpr[reg_out]);
625 626
626 /* PS1 */ 627 /* PS1 */
627 ps1_in = qpr[reg_in]; 628 ps1_in = qpr[reg_in];
@@ -658,7 +659,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
658 if (!kvmppc_inst_is_paired_single(vcpu, inst)) 659 if (!kvmppc_inst_is_paired_single(vcpu, inst))
659 return EMULATE_FAIL; 660 return EMULATE_FAIL;
660 661
661 if (!(vcpu->arch.msr & MSR_FP)) { 662 if (!(vcpu->arch.shared->msr & MSR_FP)) {
662 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL); 663 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL);
663 return EMULATE_AGAIN; 664 return EMULATE_AGAIN;
664 } 665 }
@@ -671,7 +672,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
671#ifdef DEBUG 672#ifdef DEBUG
672 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++) { 673 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++) {
673 u32 f; 674 u32 f;
674 kvm_cvt_df(&vcpu->arch.fpr[i], &f, &vcpu->arch.fpscr); 675 kvm_cvt_df(&vcpu->arch.fpr[i], &f);
675 dprintk(KERN_INFO "FPR[%d] = 0x%x / 0x%llx QPR[%d] = 0x%x\n", 676 dprintk(KERN_INFO "FPR[%d] = 0x%x / 0x%llx QPR[%d] = 0x%x\n",
676 i, f, vcpu->arch.fpr[i], i, vcpu->arch.qpr[i]); 677 i, f, vcpu->arch.fpr[i], i, vcpu->arch.qpr[i]);
677 } 678 }
@@ -796,8 +797,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
796 vcpu->arch.fpr[ax_rd] = vcpu->arch.fpr[ax_ra]; 797 vcpu->arch.fpr[ax_rd] = vcpu->arch.fpr[ax_ra];
797 /* vcpu->arch.qpr[ax_rd] = vcpu->arch.fpr[ax_rb]; */ 798 /* vcpu->arch.qpr[ax_rd] = vcpu->arch.fpr[ax_rb]; */
798 kvm_cvt_df(&vcpu->arch.fpr[ax_rb], 799 kvm_cvt_df(&vcpu->arch.fpr[ax_rb],
799 &vcpu->arch.qpr[ax_rd], 800 &vcpu->arch.qpr[ax_rd]);
800 &vcpu->arch.fpscr);
801 break; 801 break;
802 case OP_4X_PS_MERGE01: 802 case OP_4X_PS_MERGE01:
803 WARN_ON(rcomp); 803 WARN_ON(rcomp);
@@ -808,19 +808,16 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
808 WARN_ON(rcomp); 808 WARN_ON(rcomp);
809 /* vcpu->arch.fpr[ax_rd] = vcpu->arch.qpr[ax_ra]; */ 809 /* vcpu->arch.fpr[ax_rd] = vcpu->arch.qpr[ax_ra]; */
810 kvm_cvt_fd(&vcpu->arch.qpr[ax_ra], 810 kvm_cvt_fd(&vcpu->arch.qpr[ax_ra],
811 &vcpu->arch.fpr[ax_rd], 811 &vcpu->arch.fpr[ax_rd]);
812 &vcpu->arch.fpscr);
813 /* vcpu->arch.qpr[ax_rd] = vcpu->arch.fpr[ax_rb]; */ 812 /* vcpu->arch.qpr[ax_rd] = vcpu->arch.fpr[ax_rb]; */
814 kvm_cvt_df(&vcpu->arch.fpr[ax_rb], 813 kvm_cvt_df(&vcpu->arch.fpr[ax_rb],
815 &vcpu->arch.qpr[ax_rd], 814 &vcpu->arch.qpr[ax_rd]);
816 &vcpu->arch.fpscr);
817 break; 815 break;
818 case OP_4X_PS_MERGE11: 816 case OP_4X_PS_MERGE11:
819 WARN_ON(rcomp); 817 WARN_ON(rcomp);
820 /* vcpu->arch.fpr[ax_rd] = vcpu->arch.qpr[ax_ra]; */ 818 /* vcpu->arch.fpr[ax_rd] = vcpu->arch.qpr[ax_ra]; */
821 kvm_cvt_fd(&vcpu->arch.qpr[ax_ra], 819 kvm_cvt_fd(&vcpu->arch.qpr[ax_ra],
822 &vcpu->arch.fpr[ax_rd], 820 &vcpu->arch.fpr[ax_rd]);
823 &vcpu->arch.fpscr);
824 vcpu->arch.qpr[ax_rd] = vcpu->arch.qpr[ax_rb]; 821 vcpu->arch.qpr[ax_rd] = vcpu->arch.qpr[ax_rb];
825 break; 822 break;
826 } 823 }
@@ -1255,7 +1252,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
1255#ifdef DEBUG 1252#ifdef DEBUG
1256 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++) { 1253 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++) {
1257 u32 f; 1254 u32 f;
1258 kvm_cvt_df(&vcpu->arch.fpr[i], &f, &vcpu->arch.fpscr); 1255 kvm_cvt_df(&vcpu->arch.fpr[i], &f);
1259 dprintk(KERN_INFO "FPR[%d] = 0x%x\n", i, f); 1256 dprintk(KERN_INFO "FPR[%d] = 0x%x\n", i, f);
1260 } 1257 }
1261#endif 1258#endif
diff --git a/arch/powerpc/kvm/book3s_rmhandlers.S b/arch/powerpc/kvm/book3s_rmhandlers.S
index 506d5c316c96..2b9c9088d00e 100644
--- a/arch/powerpc/kvm/book3s_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_rmhandlers.S
@@ -202,8 +202,25 @@ _GLOBAL(kvmppc_rmcall)
202 202
203#if defined(CONFIG_PPC_BOOK3S_32) 203#if defined(CONFIG_PPC_BOOK3S_32)
204#define STACK_LR INT_FRAME_SIZE+4 204#define STACK_LR INT_FRAME_SIZE+4
205
206/* load_up_xxx have to run with MSR_DR=0 on Book3S_32 */
207#define MSR_EXT_START \
208 PPC_STL r20, _NIP(r1); \
209 mfmsr r20; \
210 LOAD_REG_IMMEDIATE(r3, MSR_DR|MSR_EE); \
211 andc r3,r20,r3; /* Disable DR,EE */ \
212 mtmsr r3; \
213 sync
214
215#define MSR_EXT_END \
216 mtmsr r20; /* Enable DR,EE */ \
217 sync; \
218 PPC_LL r20, _NIP(r1)
219
205#elif defined(CONFIG_PPC_BOOK3S_64) 220#elif defined(CONFIG_PPC_BOOK3S_64)
206#define STACK_LR _LINK 221#define STACK_LR _LINK
222#define MSR_EXT_START
223#define MSR_EXT_END
207#endif 224#endif
208 225
209/* 226/*
@@ -215,19 +232,12 @@ _GLOBAL(kvmppc_load_up_ ## what); \
215 PPC_STLU r1, -INT_FRAME_SIZE(r1); \ 232 PPC_STLU r1, -INT_FRAME_SIZE(r1); \
216 mflr r3; \ 233 mflr r3; \
217 PPC_STL r3, STACK_LR(r1); \ 234 PPC_STL r3, STACK_LR(r1); \
218 PPC_STL r20, _NIP(r1); \ 235 MSR_EXT_START; \
219 mfmsr r20; \
220 LOAD_REG_IMMEDIATE(r3, MSR_DR|MSR_EE); \
221 andc r3,r20,r3; /* Disable DR,EE */ \
222 mtmsr r3; \
223 sync; \
224 \ 236 \
225 bl FUNC(load_up_ ## what); \ 237 bl FUNC(load_up_ ## what); \
226 \ 238 \
227 mtmsr r20; /* Enable DR,EE */ \ 239 MSR_EXT_END; \
228 sync; \
229 PPC_LL r3, STACK_LR(r1); \ 240 PPC_LL r3, STACK_LR(r1); \
230 PPC_LL r20, _NIP(r1); \
231 mtlr r3; \ 241 mtlr r3; \
232 addi r1, r1, INT_FRAME_SIZE; \ 242 addi r1, r1, INT_FRAME_SIZE; \
233 blr 243 blr
@@ -242,10 +252,10 @@ define_load_up(vsx)
242 252
243.global kvmppc_trampoline_lowmem 253.global kvmppc_trampoline_lowmem
244kvmppc_trampoline_lowmem: 254kvmppc_trampoline_lowmem:
245 .long kvmppc_handler_lowmem_trampoline - CONFIG_KERNEL_START 255 PPC_LONG kvmppc_handler_lowmem_trampoline - CONFIG_KERNEL_START
246 256
247.global kvmppc_trampoline_enter 257.global kvmppc_trampoline_enter
248kvmppc_trampoline_enter: 258kvmppc_trampoline_enter:
249 .long kvmppc_handler_trampoline_enter - CONFIG_KERNEL_START 259 PPC_LONG kvmppc_handler_trampoline_enter - CONFIG_KERNEL_START
250 260
251#include "book3s_segment.S" 261#include "book3s_segment.S"
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 8d4e35f5372c..77575d08c818 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -62,9 +62,10 @@ void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu)
62{ 62{
63 int i; 63 int i;
64 64
65 printk("pc: %08lx msr: %08lx\n", vcpu->arch.pc, vcpu->arch.msr); 65 printk("pc: %08lx msr: %08llx\n", vcpu->arch.pc, vcpu->arch.shared->msr);
66 printk("lr: %08lx ctr: %08lx\n", vcpu->arch.lr, vcpu->arch.ctr); 66 printk("lr: %08lx ctr: %08lx\n", vcpu->arch.lr, vcpu->arch.ctr);
67 printk("srr0: %08lx srr1: %08lx\n", vcpu->arch.srr0, vcpu->arch.srr1); 67 printk("srr0: %08llx srr1: %08llx\n", vcpu->arch.shared->srr0,
68 vcpu->arch.shared->srr1);
68 69
69 printk("exceptions: %08lx\n", vcpu->arch.pending_exceptions); 70 printk("exceptions: %08lx\n", vcpu->arch.pending_exceptions);
70 71
@@ -130,13 +131,19 @@ void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu)
130void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, 131void kvmppc_core_queue_external(struct kvm_vcpu *vcpu,
131 struct kvm_interrupt *irq) 132 struct kvm_interrupt *irq)
132{ 133{
133 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_EXTERNAL); 134 unsigned int prio = BOOKE_IRQPRIO_EXTERNAL;
135
136 if (irq->irq == KVM_INTERRUPT_SET_LEVEL)
137 prio = BOOKE_IRQPRIO_EXTERNAL_LEVEL;
138
139 kvmppc_booke_queue_irqprio(vcpu, prio);
134} 140}
135 141
136void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu, 142void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu,
137 struct kvm_interrupt *irq) 143 struct kvm_interrupt *irq)
138{ 144{
139 clear_bit(BOOKE_IRQPRIO_EXTERNAL, &vcpu->arch.pending_exceptions); 145 clear_bit(BOOKE_IRQPRIO_EXTERNAL, &vcpu->arch.pending_exceptions);
146 clear_bit(BOOKE_IRQPRIO_EXTERNAL_LEVEL, &vcpu->arch.pending_exceptions);
140} 147}
141 148
142/* Deliver the interrupt of the corresponding priority, if possible. */ 149/* Deliver the interrupt of the corresponding priority, if possible. */
@@ -146,6 +153,26 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
146 int allowed = 0; 153 int allowed = 0;
147 ulong uninitialized_var(msr_mask); 154 ulong uninitialized_var(msr_mask);
148 bool update_esr = false, update_dear = false; 155 bool update_esr = false, update_dear = false;
156 ulong crit_raw = vcpu->arch.shared->critical;
157 ulong crit_r1 = kvmppc_get_gpr(vcpu, 1);
158 bool crit;
159 bool keep_irq = false;
160
161 /* Truncate crit indicators in 32 bit mode */
162 if (!(vcpu->arch.shared->msr & MSR_SF)) {
163 crit_raw &= 0xffffffff;
164 crit_r1 &= 0xffffffff;
165 }
166
167 /* Critical section when crit == r1 */
168 crit = (crit_raw == crit_r1);
169 /* ... and we're in supervisor mode */
170 crit = crit && !(vcpu->arch.shared->msr & MSR_PR);
171
172 if (priority == BOOKE_IRQPRIO_EXTERNAL_LEVEL) {
173 priority = BOOKE_IRQPRIO_EXTERNAL;
174 keep_irq = true;
175 }
149 176
150 switch (priority) { 177 switch (priority) {
151 case BOOKE_IRQPRIO_DTLB_MISS: 178 case BOOKE_IRQPRIO_DTLB_MISS:
@@ -169,36 +196,38 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
169 break; 196 break;
170 case BOOKE_IRQPRIO_CRITICAL: 197 case BOOKE_IRQPRIO_CRITICAL:
171 case BOOKE_IRQPRIO_WATCHDOG: 198 case BOOKE_IRQPRIO_WATCHDOG:
172 allowed = vcpu->arch.msr & MSR_CE; 199 allowed = vcpu->arch.shared->msr & MSR_CE;
173 msr_mask = MSR_ME; 200 msr_mask = MSR_ME;
174 break; 201 break;
175 case BOOKE_IRQPRIO_MACHINE_CHECK: 202 case BOOKE_IRQPRIO_MACHINE_CHECK:
176 allowed = vcpu->arch.msr & MSR_ME; 203 allowed = vcpu->arch.shared->msr & MSR_ME;
177 msr_mask = 0; 204 msr_mask = 0;
178 break; 205 break;
179 case BOOKE_IRQPRIO_EXTERNAL: 206 case BOOKE_IRQPRIO_EXTERNAL:
180 case BOOKE_IRQPRIO_DECREMENTER: 207 case BOOKE_IRQPRIO_DECREMENTER:
181 case BOOKE_IRQPRIO_FIT: 208 case BOOKE_IRQPRIO_FIT:
182 allowed = vcpu->arch.msr & MSR_EE; 209 allowed = vcpu->arch.shared->msr & MSR_EE;
210 allowed = allowed && !crit;
183 msr_mask = MSR_CE|MSR_ME|MSR_DE; 211 msr_mask = MSR_CE|MSR_ME|MSR_DE;
184 break; 212 break;
185 case BOOKE_IRQPRIO_DEBUG: 213 case BOOKE_IRQPRIO_DEBUG:
186 allowed = vcpu->arch.msr & MSR_DE; 214 allowed = vcpu->arch.shared->msr & MSR_DE;
187 msr_mask = MSR_ME; 215 msr_mask = MSR_ME;
188 break; 216 break;
189 } 217 }
190 218
191 if (allowed) { 219 if (allowed) {
192 vcpu->arch.srr0 = vcpu->arch.pc; 220 vcpu->arch.shared->srr0 = vcpu->arch.pc;
193 vcpu->arch.srr1 = vcpu->arch.msr; 221 vcpu->arch.shared->srr1 = vcpu->arch.shared->msr;
194 vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[priority]; 222 vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[priority];
195 if (update_esr == true) 223 if (update_esr == true)
196 vcpu->arch.esr = vcpu->arch.queued_esr; 224 vcpu->arch.esr = vcpu->arch.queued_esr;
197 if (update_dear == true) 225 if (update_dear == true)
198 vcpu->arch.dear = vcpu->arch.queued_dear; 226 vcpu->arch.shared->dar = vcpu->arch.queued_dear;
199 kvmppc_set_msr(vcpu, vcpu->arch.msr & msr_mask); 227 kvmppc_set_msr(vcpu, vcpu->arch.shared->msr & msr_mask);
200 228
201 clear_bit(priority, &vcpu->arch.pending_exceptions); 229 if (!keep_irq)
230 clear_bit(priority, &vcpu->arch.pending_exceptions);
202 } 231 }
203 232
204 return allowed; 233 return allowed;
@@ -208,6 +237,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
208void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu) 237void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
209{ 238{
210 unsigned long *pending = &vcpu->arch.pending_exceptions; 239 unsigned long *pending = &vcpu->arch.pending_exceptions;
240 unsigned long old_pending = vcpu->arch.pending_exceptions;
211 unsigned int priority; 241 unsigned int priority;
212 242
213 priority = __ffs(*pending); 243 priority = __ffs(*pending);
@@ -219,6 +249,12 @@ void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
219 BITS_PER_BYTE * sizeof(*pending), 249 BITS_PER_BYTE * sizeof(*pending),
220 priority + 1); 250 priority + 1);
221 } 251 }
252
253 /* Tell the guest about our interrupt status */
254 if (*pending)
255 vcpu->arch.shared->int_pending = 1;
256 else if (old_pending)
257 vcpu->arch.shared->int_pending = 0;
222} 258}
223 259
224/** 260/**
@@ -265,7 +301,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
265 break; 301 break;
266 302
267 case BOOKE_INTERRUPT_PROGRAM: 303 case BOOKE_INTERRUPT_PROGRAM:
268 if (vcpu->arch.msr & MSR_PR) { 304 if (vcpu->arch.shared->msr & MSR_PR) {
269 /* Program traps generated by user-level software must be handled 305 /* Program traps generated by user-level software must be handled
270 * by the guest kernel. */ 306 * by the guest kernel. */
271 kvmppc_core_queue_program(vcpu, vcpu->arch.fault_esr); 307 kvmppc_core_queue_program(vcpu, vcpu->arch.fault_esr);
@@ -337,7 +373,15 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
337 break; 373 break;
338 374
339 case BOOKE_INTERRUPT_SYSCALL: 375 case BOOKE_INTERRUPT_SYSCALL:
340 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SYSCALL); 376 if (!(vcpu->arch.shared->msr & MSR_PR) &&
377 (((u32)kvmppc_get_gpr(vcpu, 0)) == KVM_SC_MAGIC_R0)) {
378 /* KVM PV hypercalls */
379 kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu));
380 r = RESUME_GUEST;
381 } else {
382 /* Guest syscalls */
383 kvmppc_booke_queue_irqprio(vcpu, BOOKE_IRQPRIO_SYSCALL);
384 }
341 kvmppc_account_exit(vcpu, SYSCALL_EXITS); 385 kvmppc_account_exit(vcpu, SYSCALL_EXITS);
342 r = RESUME_GUEST; 386 r = RESUME_GUEST;
343 break; 387 break;
@@ -466,15 +510,19 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
466/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */ 510/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
467int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) 511int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
468{ 512{
513 int i;
514
469 vcpu->arch.pc = 0; 515 vcpu->arch.pc = 0;
470 vcpu->arch.msr = 0; 516 vcpu->arch.shared->msr = 0;
471 kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */ 517 kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */
472 518
473 vcpu->arch.shadow_pid = 1; 519 vcpu->arch.shadow_pid = 1;
474 520
475 /* Eye-catching number so we know if the guest takes an interrupt 521 /* Eye-catching numbers so we know if the guest takes an interrupt
476 * before it's programmed its own IVPR. */ 522 * before it's programmed its own IVPR/IVORs. */
477 vcpu->arch.ivpr = 0x55550000; 523 vcpu->arch.ivpr = 0x55550000;
524 for (i = 0; i < BOOKE_IRQPRIO_MAX; i++)
525 vcpu->arch.ivor[i] = 0x7700 | i * 4;
478 526
479 kvmppc_init_timing_stats(vcpu); 527 kvmppc_init_timing_stats(vcpu);
480 528
@@ -490,14 +538,14 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
490 regs->ctr = vcpu->arch.ctr; 538 regs->ctr = vcpu->arch.ctr;
491 regs->lr = vcpu->arch.lr; 539 regs->lr = vcpu->arch.lr;
492 regs->xer = kvmppc_get_xer(vcpu); 540 regs->xer = kvmppc_get_xer(vcpu);
493 regs->msr = vcpu->arch.msr; 541 regs->msr = vcpu->arch.shared->msr;
494 regs->srr0 = vcpu->arch.srr0; 542 regs->srr0 = vcpu->arch.shared->srr0;
495 regs->srr1 = vcpu->arch.srr1; 543 regs->srr1 = vcpu->arch.shared->srr1;
496 regs->pid = vcpu->arch.pid; 544 regs->pid = vcpu->arch.pid;
497 regs->sprg0 = vcpu->arch.sprg0; 545 regs->sprg0 = vcpu->arch.shared->sprg0;
498 regs->sprg1 = vcpu->arch.sprg1; 546 regs->sprg1 = vcpu->arch.shared->sprg1;
499 regs->sprg2 = vcpu->arch.sprg2; 547 regs->sprg2 = vcpu->arch.shared->sprg2;
500 regs->sprg3 = vcpu->arch.sprg3; 548 regs->sprg3 = vcpu->arch.shared->sprg3;
501 regs->sprg5 = vcpu->arch.sprg4; 549 regs->sprg5 = vcpu->arch.sprg4;
502 regs->sprg6 = vcpu->arch.sprg5; 550 regs->sprg6 = vcpu->arch.sprg5;
503 regs->sprg7 = vcpu->arch.sprg6; 551 regs->sprg7 = vcpu->arch.sprg6;
@@ -518,12 +566,12 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
518 vcpu->arch.lr = regs->lr; 566 vcpu->arch.lr = regs->lr;
519 kvmppc_set_xer(vcpu, regs->xer); 567 kvmppc_set_xer(vcpu, regs->xer);
520 kvmppc_set_msr(vcpu, regs->msr); 568 kvmppc_set_msr(vcpu, regs->msr);
521 vcpu->arch.srr0 = regs->srr0; 569 vcpu->arch.shared->srr0 = regs->srr0;
522 vcpu->arch.srr1 = regs->srr1; 570 vcpu->arch.shared->srr1 = regs->srr1;
523 vcpu->arch.sprg0 = regs->sprg0; 571 vcpu->arch.shared->sprg0 = regs->sprg0;
524 vcpu->arch.sprg1 = regs->sprg1; 572 vcpu->arch.shared->sprg1 = regs->sprg1;
525 vcpu->arch.sprg2 = regs->sprg2; 573 vcpu->arch.shared->sprg2 = regs->sprg2;
526 vcpu->arch.sprg3 = regs->sprg3; 574 vcpu->arch.shared->sprg3 = regs->sprg3;
527 vcpu->arch.sprg5 = regs->sprg4; 575 vcpu->arch.sprg5 = regs->sprg4;
528 vcpu->arch.sprg6 = regs->sprg5; 576 vcpu->arch.sprg6 = regs->sprg5;
529 vcpu->arch.sprg7 = regs->sprg6; 577 vcpu->arch.sprg7 = regs->sprg6;
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
index d59bcca1f9d8..492bb7030358 100644
--- a/arch/powerpc/kvm/booke.h
+++ b/arch/powerpc/kvm/booke.h
@@ -46,7 +46,9 @@
46#define BOOKE_IRQPRIO_FIT 17 46#define BOOKE_IRQPRIO_FIT 17
47#define BOOKE_IRQPRIO_DECREMENTER 18 47#define BOOKE_IRQPRIO_DECREMENTER 18
48#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19 48#define BOOKE_IRQPRIO_PERFORMANCE_MONITOR 19
49#define BOOKE_IRQPRIO_MAX 19 49/* Internal pseudo-irqprio for level triggered externals */
50#define BOOKE_IRQPRIO_EXTERNAL_LEVEL 20
51#define BOOKE_IRQPRIO_MAX 20
50 52
51extern unsigned long kvmppc_booke_handlers; 53extern unsigned long kvmppc_booke_handlers;
52 54
@@ -54,12 +56,12 @@ extern unsigned long kvmppc_booke_handlers;
54 * changing. */ 56 * changing. */
55static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) 57static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
56{ 58{
57 if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR)) 59 if ((new_msr & MSR_PR) != (vcpu->arch.shared->msr & MSR_PR))
58 kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR); 60 kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR);
59 61
60 vcpu->arch.msr = new_msr; 62 vcpu->arch.shared->msr = new_msr;
61 63
62 if (vcpu->arch.msr & MSR_WE) { 64 if (vcpu->arch.shared->msr & MSR_WE) {
63 kvm_vcpu_block(vcpu); 65 kvm_vcpu_block(vcpu);
64 kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS); 66 kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
65 }; 67 };
diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index cbc790ee1928..1260f5f24c0c 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -31,8 +31,8 @@
31 31
32static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu) 32static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
33{ 33{
34 vcpu->arch.pc = vcpu->arch.srr0; 34 vcpu->arch.pc = vcpu->arch.shared->srr0;
35 kvmppc_set_msr(vcpu, vcpu->arch.srr1); 35 kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
36} 36}
37 37
38int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, 38int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
@@ -62,7 +62,7 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
62 62
63 case OP_31_XOP_MFMSR: 63 case OP_31_XOP_MFMSR:
64 rt = get_rt(inst); 64 rt = get_rt(inst);
65 kvmppc_set_gpr(vcpu, rt, vcpu->arch.msr); 65 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->msr);
66 kvmppc_set_exit_type(vcpu, EMULATED_MFMSR_EXITS); 66 kvmppc_set_exit_type(vcpu, EMULATED_MFMSR_EXITS);
67 break; 67 break;
68 68
@@ -74,13 +74,13 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
74 74
75 case OP_31_XOP_WRTEE: 75 case OP_31_XOP_WRTEE:
76 rs = get_rs(inst); 76 rs = get_rs(inst);
77 vcpu->arch.msr = (vcpu->arch.msr & ~MSR_EE) 77 vcpu->arch.shared->msr = (vcpu->arch.shared->msr & ~MSR_EE)
78 | (kvmppc_get_gpr(vcpu, rs) & MSR_EE); 78 | (kvmppc_get_gpr(vcpu, rs) & MSR_EE);
79 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS); 79 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS);
80 break; 80 break;
81 81
82 case OP_31_XOP_WRTEEI: 82 case OP_31_XOP_WRTEEI:
83 vcpu->arch.msr = (vcpu->arch.msr & ~MSR_EE) 83 vcpu->arch.shared->msr = (vcpu->arch.shared->msr & ~MSR_EE)
84 | (inst & MSR_EE); 84 | (inst & MSR_EE);
85 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS); 85 kvmppc_set_exit_type(vcpu, EMULATED_WRTEE_EXITS);
86 break; 86 break;
@@ -105,7 +105,7 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
105 105
106 switch (sprn) { 106 switch (sprn) {
107 case SPRN_DEAR: 107 case SPRN_DEAR:
108 vcpu->arch.dear = spr_val; break; 108 vcpu->arch.shared->dar = spr_val; break;
109 case SPRN_ESR: 109 case SPRN_ESR:
110 vcpu->arch.esr = spr_val; break; 110 vcpu->arch.esr = spr_val; break;
111 case SPRN_DBCR0: 111 case SPRN_DBCR0:
@@ -200,7 +200,7 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
200 case SPRN_IVPR: 200 case SPRN_IVPR:
201 kvmppc_set_gpr(vcpu, rt, vcpu->arch.ivpr); break; 201 kvmppc_set_gpr(vcpu, rt, vcpu->arch.ivpr); break;
202 case SPRN_DEAR: 202 case SPRN_DEAR:
203 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dear); break; 203 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dar); break;
204 case SPRN_ESR: 204 case SPRN_ESR:
205 kvmppc_set_gpr(vcpu, rt, vcpu->arch.esr); break; 205 kvmppc_set_gpr(vcpu, rt, vcpu->arch.esr); break;
206 case SPRN_DBCR0: 206 case SPRN_DBCR0:
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 380a78cf484d..049846911ce4 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -415,7 +415,8 @@ lightweight_exit:
415 lwz r8, VCPU_GPR(r8)(r4) 415 lwz r8, VCPU_GPR(r8)(r4)
416 lwz r3, VCPU_PC(r4) 416 lwz r3, VCPU_PC(r4)
417 mtsrr0 r3 417 mtsrr0 r3
418 lwz r3, VCPU_MSR(r4) 418 lwz r3, VCPU_SHARED(r4)
419 lwz r3, VCPU_SHARED_MSR(r3)
419 oris r3, r3, KVMPPC_MSR_MASK@h 420 oris r3, r3, KVMPPC_MSR_MASK@h
420 ori r3, r3, KVMPPC_MSR_MASK@l 421 ori r3, r3, KVMPPC_MSR_MASK@l
421 mtsrr1 r3 422 mtsrr1 r3
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index e8a00b0c4449..71750f2dd5d3 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -117,8 +117,14 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
117 if (err) 117 if (err)
118 goto uninit_vcpu; 118 goto uninit_vcpu;
119 119
120 vcpu->arch.shared = (void*)__get_free_page(GFP_KERNEL|__GFP_ZERO);
121 if (!vcpu->arch.shared)
122 goto uninit_tlb;
123
120 return vcpu; 124 return vcpu;
121 125
126uninit_tlb:
127 kvmppc_e500_tlb_uninit(vcpu_e500);
122uninit_vcpu: 128uninit_vcpu:
123 kvm_vcpu_uninit(vcpu); 129 kvm_vcpu_uninit(vcpu);
124free_vcpu: 130free_vcpu:
@@ -131,6 +137,7 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
131{ 137{
132 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 138 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
133 139
140 free_page((unsigned long)vcpu->arch.shared);
134 kvmppc_e500_tlb_uninit(vcpu_e500); 141 kvmppc_e500_tlb_uninit(vcpu_e500);
135 kvm_vcpu_uninit(vcpu); 142 kvm_vcpu_uninit(vcpu);
136 kmem_cache_free(kvm_vcpu_cache, vcpu_e500); 143 kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index 21011e12caeb..d6d6d47a75a9 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -226,8 +226,7 @@ static void kvmppc_e500_stlbe_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
226 226
227 kvmppc_e500_shadow_release(vcpu_e500, tlbsel, esel); 227 kvmppc_e500_shadow_release(vcpu_e500, tlbsel, esel);
228 stlbe->mas1 = 0; 228 stlbe->mas1 = 0;
229 trace_kvm_stlb_inval(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2, 229 trace_kvm_stlb_inval(index_of(tlbsel, esel));
230 stlbe->mas3, stlbe->mas7);
231} 230}
232 231
233static void kvmppc_e500_tlb1_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500, 232static void kvmppc_e500_tlb1_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
@@ -298,7 +297,8 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
298 /* Get reference to new page. */ 297 /* Get reference to new page. */
299 new_page = gfn_to_page(vcpu_e500->vcpu.kvm, gfn); 298 new_page = gfn_to_page(vcpu_e500->vcpu.kvm, gfn);
300 if (is_error_page(new_page)) { 299 if (is_error_page(new_page)) {
301 printk(KERN_ERR "Couldn't get guest page for gfn %lx!\n", gfn); 300 printk(KERN_ERR "Couldn't get guest page for gfn %lx!\n",
301 (long)gfn);
302 kvm_release_page_clean(new_page); 302 kvm_release_page_clean(new_page);
303 return; 303 return;
304 } 304 }
@@ -314,10 +314,10 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
314 | MAS1_TID(get_tlb_tid(gtlbe)) | MAS1_TS | MAS1_VALID; 314 | MAS1_TID(get_tlb_tid(gtlbe)) | MAS1_TS | MAS1_VALID;
315 stlbe->mas2 = (gvaddr & MAS2_EPN) 315 stlbe->mas2 = (gvaddr & MAS2_EPN)
316 | e500_shadow_mas2_attrib(gtlbe->mas2, 316 | e500_shadow_mas2_attrib(gtlbe->mas2,
317 vcpu_e500->vcpu.arch.msr & MSR_PR); 317 vcpu_e500->vcpu.arch.shared->msr & MSR_PR);
318 stlbe->mas3 = (hpaddr & MAS3_RPN) 318 stlbe->mas3 = (hpaddr & MAS3_RPN)
319 | e500_shadow_mas3_attrib(gtlbe->mas3, 319 | e500_shadow_mas3_attrib(gtlbe->mas3,
320 vcpu_e500->vcpu.arch.msr & MSR_PR); 320 vcpu_e500->vcpu.arch.shared->msr & MSR_PR);
321 stlbe->mas7 = (hpaddr >> 32) & MAS7_RPN; 321 stlbe->mas7 = (hpaddr >> 32) & MAS7_RPN;
322 322
323 trace_kvm_stlb_write(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2, 323 trace_kvm_stlb_write(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2,
@@ -576,28 +576,28 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
576 576
577int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr) 577int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
578{ 578{
579 unsigned int as = !!(vcpu->arch.msr & MSR_IS); 579 unsigned int as = !!(vcpu->arch.shared->msr & MSR_IS);
580 580
581 return kvmppc_e500_tlb_search(vcpu, eaddr, get_cur_pid(vcpu), as); 581 return kvmppc_e500_tlb_search(vcpu, eaddr, get_cur_pid(vcpu), as);
582} 582}
583 583
584int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr) 584int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr)
585{ 585{
586 unsigned int as = !!(vcpu->arch.msr & MSR_DS); 586 unsigned int as = !!(vcpu->arch.shared->msr & MSR_DS);
587 587
588 return kvmppc_e500_tlb_search(vcpu, eaddr, get_cur_pid(vcpu), as); 588 return kvmppc_e500_tlb_search(vcpu, eaddr, get_cur_pid(vcpu), as);
589} 589}
590 590
591void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu) 591void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
592{ 592{
593 unsigned int as = !!(vcpu->arch.msr & MSR_IS); 593 unsigned int as = !!(vcpu->arch.shared->msr & MSR_IS);
594 594
595 kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.pc, as); 595 kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.pc, as);
596} 596}
597 597
598void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu) 598void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
599{ 599{
600 unsigned int as = !!(vcpu->arch.msr & MSR_DS); 600 unsigned int as = !!(vcpu->arch.shared->msr & MSR_DS);
601 601
602 kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.fault_dear, as); 602 kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.fault_dear, as);
603} 603}
diff --git a/arch/powerpc/kvm/e500_tlb.h b/arch/powerpc/kvm/e500_tlb.h
index d28e3010a5e2..458946b4775d 100644
--- a/arch/powerpc/kvm/e500_tlb.h
+++ b/arch/powerpc/kvm/e500_tlb.h
@@ -171,7 +171,7 @@ static inline int tlbe_is_host_safe(const struct kvm_vcpu *vcpu,
171 171
172 /* Does it match current guest AS? */ 172 /* Does it match current guest AS? */
173 /* XXX what about IS != DS? */ 173 /* XXX what about IS != DS? */
174 if (get_tlb_ts(tlbe) != !!(vcpu->arch.msr & MSR_IS)) 174 if (get_tlb_ts(tlbe) != !!(vcpu->arch.shared->msr & MSR_IS))
175 return 0; 175 return 0;
176 176
177 gpa = get_tlb_raddr(tlbe); 177 gpa = get_tlb_raddr(tlbe);
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 4568ec386c2a..c64fd2909bb2 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -145,7 +145,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
145 /* this default type might be overwritten by subcategories */ 145 /* this default type might be overwritten by subcategories */
146 kvmppc_set_exit_type(vcpu, EMULATED_INST_EXITS); 146 kvmppc_set_exit_type(vcpu, EMULATED_INST_EXITS);
147 147
148 pr_debug(KERN_INFO "Emulating opcode %d / %d\n", get_op(inst), get_xop(inst)); 148 pr_debug("Emulating opcode %d / %d\n", get_op(inst), get_xop(inst));
149 149
150 switch (get_op(inst)) { 150 switch (get_op(inst)) {
151 case OP_TRAP: 151 case OP_TRAP:
@@ -242,9 +242,11 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
242 242
243 switch (sprn) { 243 switch (sprn) {
244 case SPRN_SRR0: 244 case SPRN_SRR0:
245 kvmppc_set_gpr(vcpu, rt, vcpu->arch.srr0); break; 245 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->srr0);
246 break;
246 case SPRN_SRR1: 247 case SPRN_SRR1:
247 kvmppc_set_gpr(vcpu, rt, vcpu->arch.srr1); break; 248 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->srr1);
249 break;
248 case SPRN_PVR: 250 case SPRN_PVR:
249 kvmppc_set_gpr(vcpu, rt, vcpu->arch.pvr); break; 251 kvmppc_set_gpr(vcpu, rt, vcpu->arch.pvr); break;
250 case SPRN_PIR: 252 case SPRN_PIR:
@@ -261,13 +263,17 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
261 kvmppc_set_gpr(vcpu, rt, get_tb()); break; 263 kvmppc_set_gpr(vcpu, rt, get_tb()); break;
262 264
263 case SPRN_SPRG0: 265 case SPRN_SPRG0:
264 kvmppc_set_gpr(vcpu, rt, vcpu->arch.sprg0); break; 266 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg0);
267 break;
265 case SPRN_SPRG1: 268 case SPRN_SPRG1:
266 kvmppc_set_gpr(vcpu, rt, vcpu->arch.sprg1); break; 269 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg1);
270 break;
267 case SPRN_SPRG2: 271 case SPRN_SPRG2:
268 kvmppc_set_gpr(vcpu, rt, vcpu->arch.sprg2); break; 272 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg2);
273 break;
269 case SPRN_SPRG3: 274 case SPRN_SPRG3:
270 kvmppc_set_gpr(vcpu, rt, vcpu->arch.sprg3); break; 275 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->sprg3);
276 break;
271 /* Note: SPRG4-7 are user-readable, so we don't get 277 /* Note: SPRG4-7 are user-readable, so we don't get
272 * a trap. */ 278 * a trap. */
273 279
@@ -275,7 +281,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
275 { 281 {
276 u64 jd = get_tb() - vcpu->arch.dec_jiffies; 282 u64 jd = get_tb() - vcpu->arch.dec_jiffies;
277 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dec - jd); 283 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dec - jd);
278 pr_debug(KERN_INFO "mfDEC: %x - %llx = %lx\n", 284 pr_debug("mfDEC: %x - %llx = %lx\n",
279 vcpu->arch.dec, jd, 285 vcpu->arch.dec, jd,
280 kvmppc_get_gpr(vcpu, rt)); 286 kvmppc_get_gpr(vcpu, rt));
281 break; 287 break;
@@ -320,9 +326,11 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
320 rs = get_rs(inst); 326 rs = get_rs(inst);
321 switch (sprn) { 327 switch (sprn) {
322 case SPRN_SRR0: 328 case SPRN_SRR0:
323 vcpu->arch.srr0 = kvmppc_get_gpr(vcpu, rs); break; 329 vcpu->arch.shared->srr0 = kvmppc_get_gpr(vcpu, rs);
330 break;
324 case SPRN_SRR1: 331 case SPRN_SRR1:
325 vcpu->arch.srr1 = kvmppc_get_gpr(vcpu, rs); break; 332 vcpu->arch.shared->srr1 = kvmppc_get_gpr(vcpu, rs);
333 break;
326 334
327 /* XXX We need to context-switch the timebase for 335 /* XXX We need to context-switch the timebase for
328 * watchdog and FIT. */ 336 * watchdog and FIT. */
@@ -337,13 +345,17 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
337 break; 345 break;
338 346
339 case SPRN_SPRG0: 347 case SPRN_SPRG0:
340 vcpu->arch.sprg0 = kvmppc_get_gpr(vcpu, rs); break; 348 vcpu->arch.shared->sprg0 = kvmppc_get_gpr(vcpu, rs);
349 break;
341 case SPRN_SPRG1: 350 case SPRN_SPRG1:
342 vcpu->arch.sprg1 = kvmppc_get_gpr(vcpu, rs); break; 351 vcpu->arch.shared->sprg1 = kvmppc_get_gpr(vcpu, rs);
352 break;
343 case SPRN_SPRG2: 353 case SPRN_SPRG2:
344 vcpu->arch.sprg2 = kvmppc_get_gpr(vcpu, rs); break; 354 vcpu->arch.shared->sprg2 = kvmppc_get_gpr(vcpu, rs);
355 break;
345 case SPRN_SPRG3: 356 case SPRN_SPRG3:
346 vcpu->arch.sprg3 = kvmppc_get_gpr(vcpu, rs); break; 357 vcpu->arch.shared->sprg3 = kvmppc_get_gpr(vcpu, rs);
358 break;
347 359
348 default: 360 default:
349 emulated = kvmppc_core_emulate_mtspr(vcpu, sprn, rs); 361 emulated = kvmppc_core_emulate_mtspr(vcpu, sprn, rs);
diff --git a/arch/powerpc/kvm/fpu.S b/arch/powerpc/kvm/fpu.S
index cb34bbe16113..bf68d597549e 100644
--- a/arch/powerpc/kvm/fpu.S
+++ b/arch/powerpc/kvm/fpu.S
@@ -273,19 +273,11 @@ FPD_THREE_IN(fnmsub)
273FPD_THREE_IN(fnmadd) 273FPD_THREE_IN(fnmadd)
274 274
275_GLOBAL(kvm_cvt_fd) 275_GLOBAL(kvm_cvt_fd)
276 lfd 0,0(r5) /* load up fpscr value */
277 MTFSF_L(0)
278 lfs 0,0(r3) 276 lfs 0,0(r3)
279 stfd 0,0(r4) 277 stfd 0,0(r4)
280 mffs 0
281 stfd 0,0(r5) /* save new fpscr value */
282 blr 278 blr
283 279
284_GLOBAL(kvm_cvt_df) 280_GLOBAL(kvm_cvt_df)
285 lfd 0,0(r5) /* load up fpscr value */
286 MTFSF_L(0)
287 lfd 0,0(r3) 281 lfd 0,0(r3)
288 stfs 0,0(r4) 282 stfs 0,0(r4)
289 mffs 0
290 stfd 0,0(r5) /* save new fpscr value */
291 blr 283 blr
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 72a4ad86ee91..2f87a1627f6c 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -38,9 +38,56 @@
38 38
39int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) 39int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
40{ 40{
41 return !(v->arch.msr & MSR_WE) || !!(v->arch.pending_exceptions); 41 return !(v->arch.shared->msr & MSR_WE) ||
42 !!(v->arch.pending_exceptions);
42} 43}
43 44
45int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
46{
47 int nr = kvmppc_get_gpr(vcpu, 11);
48 int r;
49 unsigned long __maybe_unused param1 = kvmppc_get_gpr(vcpu, 3);
50 unsigned long __maybe_unused param2 = kvmppc_get_gpr(vcpu, 4);
51 unsigned long __maybe_unused param3 = kvmppc_get_gpr(vcpu, 5);
52 unsigned long __maybe_unused param4 = kvmppc_get_gpr(vcpu, 6);
53 unsigned long r2 = 0;
54
55 if (!(vcpu->arch.shared->msr & MSR_SF)) {
56 /* 32 bit mode */
57 param1 &= 0xffffffff;
58 param2 &= 0xffffffff;
59 param3 &= 0xffffffff;
60 param4 &= 0xffffffff;
61 }
62
63 switch (nr) {
64 case HC_VENDOR_KVM | KVM_HC_PPC_MAP_MAGIC_PAGE:
65 {
66 vcpu->arch.magic_page_pa = param1;
67 vcpu->arch.magic_page_ea = param2;
68
69 r2 = KVM_MAGIC_FEAT_SR;
70
71 r = HC_EV_SUCCESS;
72 break;
73 }
74 case HC_VENDOR_KVM | KVM_HC_FEATURES:
75 r = HC_EV_SUCCESS;
76#if defined(CONFIG_PPC_BOOK3S) /* XXX Missing magic page on BookE */
77 r2 |= (1 << KVM_FEATURE_MAGIC_PAGE);
78#endif
79
80 /* Second return value is in r4 */
81 break;
82 default:
83 r = HC_EV_UNIMPLEMENTED;
84 break;
85 }
86
87 kvmppc_set_gpr(vcpu, 4, r2);
88
89 return r;
90}
44 91
45int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) 92int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
46{ 93{
@@ -145,8 +192,10 @@ int kvm_dev_ioctl_check_extension(long ext)
145 case KVM_CAP_PPC_SEGSTATE: 192 case KVM_CAP_PPC_SEGSTATE:
146 case KVM_CAP_PPC_PAIRED_SINGLES: 193 case KVM_CAP_PPC_PAIRED_SINGLES:
147 case KVM_CAP_PPC_UNSET_IRQ: 194 case KVM_CAP_PPC_UNSET_IRQ:
195 case KVM_CAP_PPC_IRQ_LEVEL:
148 case KVM_CAP_ENABLE_CAP: 196 case KVM_CAP_ENABLE_CAP:
149 case KVM_CAP_PPC_OSI: 197 case KVM_CAP_PPC_OSI:
198 case KVM_CAP_PPC_GET_PVINFO:
150 r = 1; 199 r = 1;
151 break; 200 break;
152 case KVM_CAP_COALESCED_MMIO: 201 case KVM_CAP_COALESCED_MMIO:
@@ -534,16 +583,53 @@ out:
534 return r; 583 return r;
535} 584}
536 585
586static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
587{
588 u32 inst_lis = 0x3c000000;
589 u32 inst_ori = 0x60000000;
590 u32 inst_nop = 0x60000000;
591 u32 inst_sc = 0x44000002;
592 u32 inst_imm_mask = 0xffff;
593
594 /*
595 * The hypercall to get into KVM from within guest context is as
596 * follows:
597 *
598 * lis r0, r0, KVM_SC_MAGIC_R0@h
599 * ori r0, KVM_SC_MAGIC_R0@l
600 * sc
601 * nop
602 */
603 pvinfo->hcall[0] = inst_lis | ((KVM_SC_MAGIC_R0 >> 16) & inst_imm_mask);
604 pvinfo->hcall[1] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask);
605 pvinfo->hcall[2] = inst_sc;
606 pvinfo->hcall[3] = inst_nop;
607
608 return 0;
609}
610
537long kvm_arch_vm_ioctl(struct file *filp, 611long kvm_arch_vm_ioctl(struct file *filp,
538 unsigned int ioctl, unsigned long arg) 612 unsigned int ioctl, unsigned long arg)
539{ 613{
614 void __user *argp = (void __user *)arg;
540 long r; 615 long r;
541 616
542 switch (ioctl) { 617 switch (ioctl) {
618 case KVM_PPC_GET_PVINFO: {
619 struct kvm_ppc_pvinfo pvinfo;
620 r = kvm_vm_ioctl_get_pvinfo(&pvinfo);
621 if (copy_to_user(argp, &pvinfo, sizeof(pvinfo))) {
622 r = -EFAULT;
623 goto out;
624 }
625
626 break;
627 }
543 default: 628 default:
544 r = -ENOTTY; 629 r = -ENOTTY;
545 } 630 }
546 631
632out:
547 return r; 633 return r;
548} 634}
549 635
diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h
index a8e840018052..3aca1b042b8c 100644
--- a/arch/powerpc/kvm/trace.h
+++ b/arch/powerpc/kvm/trace.h
@@ -98,6 +98,245 @@ TRACE_EVENT(kvm_gtlb_write,
98 __entry->word1, __entry->word2) 98 __entry->word1, __entry->word2)
99); 99);
100 100
101
102/*************************************************************************
103 * Book3S trace points *
104 *************************************************************************/
105
106#ifdef CONFIG_PPC_BOOK3S
107
108TRACE_EVENT(kvm_book3s_exit,
109 TP_PROTO(unsigned int exit_nr, struct kvm_vcpu *vcpu),
110 TP_ARGS(exit_nr, vcpu),
111
112 TP_STRUCT__entry(
113 __field( unsigned int, exit_nr )
114 __field( unsigned long, pc )
115 __field( unsigned long, msr )
116 __field( unsigned long, dar )
117 __field( unsigned long, srr1 )
118 ),
119
120 TP_fast_assign(
121 __entry->exit_nr = exit_nr;
122 __entry->pc = kvmppc_get_pc(vcpu);
123 __entry->dar = kvmppc_get_fault_dar(vcpu);
124 __entry->msr = vcpu->arch.shared->msr;
125 __entry->srr1 = to_svcpu(vcpu)->shadow_srr1;
126 ),
127
128 TP_printk("exit=0x%x | pc=0x%lx | msr=0x%lx | dar=0x%lx | srr1=0x%lx",
129 __entry->exit_nr, __entry->pc, __entry->msr, __entry->dar,
130 __entry->srr1)
131);
132
133TRACE_EVENT(kvm_book3s_reenter,
134 TP_PROTO(int r, struct kvm_vcpu *vcpu),
135 TP_ARGS(r, vcpu),
136
137 TP_STRUCT__entry(
138 __field( unsigned int, r )
139 __field( unsigned long, pc )
140 ),
141
142 TP_fast_assign(
143 __entry->r = r;
144 __entry->pc = kvmppc_get_pc(vcpu);
145 ),
146
147 TP_printk("reentry r=%d | pc=0x%lx", __entry->r, __entry->pc)
148);
149
150#ifdef CONFIG_PPC_BOOK3S_64
151
152TRACE_EVENT(kvm_book3s_64_mmu_map,
153 TP_PROTO(int rflags, ulong hpteg, ulong va, pfn_t hpaddr,
154 struct kvmppc_pte *orig_pte),
155 TP_ARGS(rflags, hpteg, va, hpaddr, orig_pte),
156
157 TP_STRUCT__entry(
158 __field( unsigned char, flag_w )
159 __field( unsigned char, flag_x )
160 __field( unsigned long, eaddr )
161 __field( unsigned long, hpteg )
162 __field( unsigned long, va )
163 __field( unsigned long long, vpage )
164 __field( unsigned long, hpaddr )
165 ),
166
167 TP_fast_assign(
168 __entry->flag_w = ((rflags & HPTE_R_PP) == 3) ? '-' : 'w';
169 __entry->flag_x = (rflags & HPTE_R_N) ? '-' : 'x';
170 __entry->eaddr = orig_pte->eaddr;
171 __entry->hpteg = hpteg;
172 __entry->va = va;
173 __entry->vpage = orig_pte->vpage;
174 __entry->hpaddr = hpaddr;
175 ),
176
177 TP_printk("KVM: %c%c Map 0x%lx: [%lx] 0x%lx (0x%llx) -> %lx",
178 __entry->flag_w, __entry->flag_x, __entry->eaddr,
179 __entry->hpteg, __entry->va, __entry->vpage, __entry->hpaddr)
180);
181
182#endif /* CONFIG_PPC_BOOK3S_64 */
183
184TRACE_EVENT(kvm_book3s_mmu_map,
185 TP_PROTO(struct hpte_cache *pte),
186 TP_ARGS(pte),
187
188 TP_STRUCT__entry(
189 __field( u64, host_va )
190 __field( u64, pfn )
191 __field( ulong, eaddr )
192 __field( u64, vpage )
193 __field( ulong, raddr )
194 __field( int, flags )
195 ),
196
197 TP_fast_assign(
198 __entry->host_va = pte->host_va;
199 __entry->pfn = pte->pfn;
200 __entry->eaddr = pte->pte.eaddr;
201 __entry->vpage = pte->pte.vpage;
202 __entry->raddr = pte->pte.raddr;
203 __entry->flags = (pte->pte.may_read ? 0x4 : 0) |
204 (pte->pte.may_write ? 0x2 : 0) |
205 (pte->pte.may_execute ? 0x1 : 0);
206 ),
207
208 TP_printk("Map: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
209 __entry->host_va, __entry->pfn, __entry->eaddr,
210 __entry->vpage, __entry->raddr, __entry->flags)
211);
212
213TRACE_EVENT(kvm_book3s_mmu_invalidate,
214 TP_PROTO(struct hpte_cache *pte),
215 TP_ARGS(pte),
216
217 TP_STRUCT__entry(
218 __field( u64, host_va )
219 __field( u64, pfn )
220 __field( ulong, eaddr )
221 __field( u64, vpage )
222 __field( ulong, raddr )
223 __field( int, flags )
224 ),
225
226 TP_fast_assign(
227 __entry->host_va = pte->host_va;
228 __entry->pfn = pte->pfn;
229 __entry->eaddr = pte->pte.eaddr;
230 __entry->vpage = pte->pte.vpage;
231 __entry->raddr = pte->pte.raddr;
232 __entry->flags = (pte->pte.may_read ? 0x4 : 0) |
233 (pte->pte.may_write ? 0x2 : 0) |
234 (pte->pte.may_execute ? 0x1 : 0);
235 ),
236
237 TP_printk("Flush: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]",
238 __entry->host_va, __entry->pfn, __entry->eaddr,
239 __entry->vpage, __entry->raddr, __entry->flags)
240);
241
242TRACE_EVENT(kvm_book3s_mmu_flush,
243 TP_PROTO(const char *type, struct kvm_vcpu *vcpu, unsigned long long p1,
244 unsigned long long p2),
245 TP_ARGS(type, vcpu, p1, p2),
246
247 TP_STRUCT__entry(
248 __field( int, count )
249 __field( unsigned long long, p1 )
250 __field( unsigned long long, p2 )
251 __field( const char *, type )
252 ),
253
254 TP_fast_assign(
255 __entry->count = vcpu->arch.hpte_cache_count;
256 __entry->p1 = p1;
257 __entry->p2 = p2;
258 __entry->type = type;
259 ),
260
261 TP_printk("Flush %d %sPTEs: %llx - %llx",
262 __entry->count, __entry->type, __entry->p1, __entry->p2)
263);
264
265TRACE_EVENT(kvm_book3s_slb_found,
266 TP_PROTO(unsigned long long gvsid, unsigned long long hvsid),
267 TP_ARGS(gvsid, hvsid),
268
269 TP_STRUCT__entry(
270 __field( unsigned long long, gvsid )
271 __field( unsigned long long, hvsid )
272 ),
273
274 TP_fast_assign(
275 __entry->gvsid = gvsid;
276 __entry->hvsid = hvsid;
277 ),
278
279 TP_printk("%llx -> %llx", __entry->gvsid, __entry->hvsid)
280);
281
282TRACE_EVENT(kvm_book3s_slb_fail,
283 TP_PROTO(u16 sid_map_mask, unsigned long long gvsid),
284 TP_ARGS(sid_map_mask, gvsid),
285
286 TP_STRUCT__entry(
287 __field( unsigned short, sid_map_mask )
288 __field( unsigned long long, gvsid )
289 ),
290
291 TP_fast_assign(
292 __entry->sid_map_mask = sid_map_mask;
293 __entry->gvsid = gvsid;
294 ),
295
296 TP_printk("%x/%x: %llx", __entry->sid_map_mask,
297 SID_MAP_MASK - __entry->sid_map_mask, __entry->gvsid)
298);
299
300TRACE_EVENT(kvm_book3s_slb_map,
301 TP_PROTO(u16 sid_map_mask, unsigned long long gvsid,
302 unsigned long long hvsid),
303 TP_ARGS(sid_map_mask, gvsid, hvsid),
304
305 TP_STRUCT__entry(
306 __field( unsigned short, sid_map_mask )
307 __field( unsigned long long, guest_vsid )
308 __field( unsigned long long, host_vsid )
309 ),
310
311 TP_fast_assign(
312 __entry->sid_map_mask = sid_map_mask;
313 __entry->guest_vsid = gvsid;
314 __entry->host_vsid = hvsid;
315 ),
316
317 TP_printk("%x: %llx -> %llx", __entry->sid_map_mask,
318 __entry->guest_vsid, __entry->host_vsid)
319);
320
321TRACE_EVENT(kvm_book3s_slbmte,
322 TP_PROTO(u64 slb_vsid, u64 slb_esid),
323 TP_ARGS(slb_vsid, slb_esid),
324
325 TP_STRUCT__entry(
326 __field( u64, slb_vsid )
327 __field( u64, slb_esid )
328 ),
329
330 TP_fast_assign(
331 __entry->slb_vsid = slb_vsid;
332 __entry->slb_esid = slb_esid;
333 ),
334
335 TP_printk("%llx, %llx", __entry->slb_vsid, __entry->slb_esid)
336);
337
338#endif /* CONFIG_PPC_BOOK3S */
339
101#endif /* _TRACE_KVM_H */ 340#endif /* _TRACE_KVM_H */
102 341
103/* This part must be outside protection */ 342/* This part must be outside protection */
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 5bb89c828070..889f2bc106dd 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -4,9 +4,7 @@
4 4
5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
6 6
7ifeq ($(CONFIG_PPC64),y) 7ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
8EXTRA_CFLAGS += -mno-minimal-toc
9endif
10 8
11CFLAGS_REMOVE_code-patching.o = -pg 9CFLAGS_REMOVE_code-patching.o = -pg
12CFLAGS_REMOVE_feature-fixups.o = -pg 10CFLAGS_REMOVE_feature-fixups.o = -pg
@@ -17,7 +15,8 @@ obj-$(CONFIG_PPC32) += div64.o copy_32.o
17obj-$(CONFIG_HAS_IOMEM) += devres.o 15obj-$(CONFIG_HAS_IOMEM) += devres.o
18 16
19obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \ 17obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \
20 memcpy_64.o usercopy_64.o mem_64.o string.o 18 memcpy_64.o usercopy_64.o mem_64.o string.o \
19 checksum_wrappers_64.o
21obj-$(CONFIG_XMON) += sstep.o ldstfp.o 20obj-$(CONFIG_XMON) += sstep.o ldstfp.o
22obj-$(CONFIG_KPROBES) += sstep.o ldstfp.o 21obj-$(CONFIG_KPROBES) += sstep.o ldstfp.o
23obj-$(CONFIG_HAVE_HW_BREAKPOINT) += sstep.o ldstfp.o 22obj-$(CONFIG_HAVE_HW_BREAKPOINT) += sstep.o ldstfp.o
diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
index ef96c6c58efc..18245af38aea 100644
--- a/arch/powerpc/lib/checksum_64.S
+++ b/arch/powerpc/lib/checksum_64.S
@@ -65,165 +65,393 @@ _GLOBAL(csum_tcpudp_magic)
65 srwi r3,r3,16 65 srwi r3,r3,16
66 blr 66 blr
67 67
68#define STACKFRAMESIZE 256
69#define STK_REG(i) (112 + ((i)-14)*8)
70
68/* 71/*
69 * Computes the checksum of a memory block at buff, length len, 72 * Computes the checksum of a memory block at buff, length len,
70 * and adds in "sum" (32-bit). 73 * and adds in "sum" (32-bit).
71 * 74 *
72 * This code assumes at least halfword alignment, though the length
73 * can be any number of bytes. The sum is accumulated in r5.
74 *
75 * csum_partial(r3=buff, r4=len, r5=sum) 75 * csum_partial(r3=buff, r4=len, r5=sum)
76 */ 76 */
77_GLOBAL(csum_partial) 77_GLOBAL(csum_partial)
78 subi r3,r3,8 /* we'll offset by 8 for the loads */ 78 addic r0,r5,0 /* clear carry */
79 srdi. r6,r4,3 /* divide by 8 for doubleword count */ 79
80 addic r5,r5,0 /* clear carry */ 80 srdi. r6,r4,3 /* less than 8 bytes? */
81 beq 3f /* if we're doing < 8 bytes */ 81 beq .Lcsum_tail_word
82 andi. r0,r3,2 /* aligned on a word boundary already? */ 82
83 beq+ 1f 83 /*
84 lhz r6,8(r3) /* do 2 bytes to get aligned */ 84 * If only halfword aligned, align to a double word. Since odd
85 addi r3,r3,2 85 * aligned addresses should be rare and they would require more
86 subi r4,r4,2 86 * work to calculate the correct checksum, we ignore that case
87 addc r5,r5,r6 87 * and take the potential slowdown of unaligned loads.
88 srdi. r6,r4,3 /* recompute number of doublewords */ 88 */
89 beq 3f /* any left? */ 89 rldicl. r6,r3,64-1,64-2 /* r6 = (r3 & 0x3) >> 1 */
901: mtctr r6 90 beq .Lcsum_aligned
912: ldu r6,8(r3) /* main sum loop */ 91
92 adde r5,r5,r6 92 li r7,4
93 bdnz 2b 93 sub r6,r7,r6
94 andi. r4,r4,7 /* compute bytes left to sum after doublewords */ 94 mtctr r6
953: cmpwi 0,r4,4 /* is at least a full word left? */ 95
96 blt 4f 961:
97 lwz r6,8(r3) /* sum this word */ 97 lhz r6,0(r3) /* align to doubleword */
98 subi r4,r4,2
99 addi r3,r3,2
100 adde r0,r0,r6
101 bdnz 1b
102
103.Lcsum_aligned:
104 /*
105 * We unroll the loop such that each iteration is 64 bytes with an
106 * entry and exit limb of 64 bytes, meaning a minimum size of
107 * 128 bytes.
108 */
109 srdi. r6,r4,7
110 beq .Lcsum_tail_doublewords /* len < 128 */
111
112 srdi r6,r4,6
113 subi r6,r6,1
114 mtctr r6
115
116 stdu r1,-STACKFRAMESIZE(r1)
117 std r14,STK_REG(r14)(r1)
118 std r15,STK_REG(r15)(r1)
119 std r16,STK_REG(r16)(r1)
120
121 ld r6,0(r3)
122 ld r9,8(r3)
123
124 ld r10,16(r3)
125 ld r11,24(r3)
126
127 /*
128 * On POWER6 and POWER7 back to back addes take 2 cycles because of
129 * the XER dependency. This means the fastest this loop can go is
130 * 16 cycles per iteration. The scheduling of the loop below has
131 * been shown to hit this on both POWER6 and POWER7.
132 */
133 .align 5
1342:
135 adde r0,r0,r6
136 ld r12,32(r3)
137 ld r14,40(r3)
138
139 adde r0,r0,r9
140 ld r15,48(r3)
141 ld r16,56(r3)
142 addi r3,r3,64
143
144 adde r0,r0,r10
145
146 adde r0,r0,r11
147
148 adde r0,r0,r12
149
150 adde r0,r0,r14
151
152 adde r0,r0,r15
153 ld r6,0(r3)
154 ld r9,8(r3)
155
156 adde r0,r0,r16
157 ld r10,16(r3)
158 ld r11,24(r3)
159 bdnz 2b
160
161
162 adde r0,r0,r6
163 ld r12,32(r3)
164 ld r14,40(r3)
165
166 adde r0,r0,r9
167 ld r15,48(r3)
168 ld r16,56(r3)
169 addi r3,r3,64
170
171 adde r0,r0,r10
172 adde r0,r0,r11
173 adde r0,r0,r12
174 adde r0,r0,r14
175 adde r0,r0,r15
176 adde r0,r0,r16
177
178 ld r14,STK_REG(r14)(r1)
179 ld r15,STK_REG(r15)(r1)
180 ld r16,STK_REG(r16)(r1)
181 addi r1,r1,STACKFRAMESIZE
182
183 andi. r4,r4,63
184
185.Lcsum_tail_doublewords: /* Up to 127 bytes to go */
186 srdi. r6,r4,3
187 beq .Lcsum_tail_word
188
189 mtctr r6
1903:
191 ld r6,0(r3)
192 addi r3,r3,8
193 adde r0,r0,r6
194 bdnz 3b
195
196 andi. r4,r4,7
197
198.Lcsum_tail_word: /* Up to 7 bytes to go */
199 srdi. r6,r4,2
200 beq .Lcsum_tail_halfword
201
202 lwz r6,0(r3)
98 addi r3,r3,4 203 addi r3,r3,4
204 adde r0,r0,r6
99 subi r4,r4,4 205 subi r4,r4,4
100 adde r5,r5,r6 206
1014: cmpwi 0,r4,2 /* is at least a halfword left? */ 207.Lcsum_tail_halfword: /* Up to 3 bytes to go */
102 blt+ 5f 208 srdi. r6,r4,1
103 lhz r6,8(r3) /* sum this halfword */ 209 beq .Lcsum_tail_byte
104 addi r3,r3,2 210
105 subi r4,r4,2 211 lhz r6,0(r3)
106 adde r5,r5,r6 212 addi r3,r3,2
1075: cmpwi 0,r4,1 /* is at least a byte left? */ 213 adde r0,r0,r6
108 bne+ 6f 214 subi r4,r4,2
109 lbz r6,8(r3) /* sum this byte */ 215
110 slwi r6,r6,8 /* this byte is assumed to be the upper byte of a halfword */ 216.Lcsum_tail_byte: /* Up to 1 byte to go */
111 adde r5,r5,r6 217 andi. r6,r4,1
1126: addze r5,r5 /* add in final carry */ 218 beq .Lcsum_finish
113 rldicl r4,r5,32,0 /* fold two 32-bit halves together */ 219
114 add r3,r4,r5 220 lbz r6,0(r3)
115 srdi r3,r3,32 221 sldi r9,r6,8 /* Pad the byte out to 16 bits */
116 blr 222 adde r0,r0,r9
223
224.Lcsum_finish:
225 addze r0,r0 /* add in final carry */
226 rldicl r4,r0,32,0 /* fold two 32 bit halves together */
227 add r3,r4,r0
228 srdi r3,r3,32
229 blr
230
231
232 .macro source
233100:
234 .section __ex_table,"a"
235 .align 3
236 .llong 100b,.Lsrc_error
237 .previous
238 .endm
239
240 .macro dest
241200:
242 .section __ex_table,"a"
243 .align 3
244 .llong 200b,.Ldest_error
245 .previous
246 .endm
117 247
118/* 248/*
119 * Computes the checksum of a memory block at src, length len, 249 * Computes the checksum of a memory block at src, length len,
120 * and adds in "sum" (32-bit), while copying the block to dst. 250 * and adds in "sum" (32-bit), while copying the block to dst.
121 * If an access exception occurs on src or dst, it stores -EFAULT 251 * If an access exception occurs on src or dst, it stores -EFAULT
122 * to *src_err or *dst_err respectively, and (for an error on 252 * to *src_err or *dst_err respectively. The caller must take any action
123 * src) zeroes the rest of dst. 253 * required in this case (zeroing memory, recalculating partial checksum etc).
124 *
125 * This code needs to be reworked to take advantage of 64 bit sum+copy.
126 * However, due to tokenring halfword alignment problems this will be very
127 * tricky. For now we'll leave it until we instrument it somehow.
128 * 254 *
129 * csum_partial_copy_generic(r3=src, r4=dst, r5=len, r6=sum, r7=src_err, r8=dst_err) 255 * csum_partial_copy_generic(r3=src, r4=dst, r5=len, r6=sum, r7=src_err, r8=dst_err)
130 */ 256 */
131_GLOBAL(csum_partial_copy_generic) 257_GLOBAL(csum_partial_copy_generic)
132 addic r0,r6,0 258 addic r0,r6,0 /* clear carry */
133 subi r3,r3,4 259
134 subi r4,r4,4 260 srdi. r6,r5,3 /* less than 8 bytes? */
135 srwi. r6,r5,2 261 beq .Lcopy_tail_word
136 beq 3f /* if we're doing < 4 bytes */ 262
137 andi. r9,r4,2 /* Align dst to longword boundary */ 263 /*
138 beq+ 1f 264 * If only halfword aligned, align to a double word. Since odd
13981: lhz r6,4(r3) /* do 2 bytes to get aligned */ 265 * aligned addresses should be rare and they would require more
140 addi r3,r3,2 266 * work to calculate the correct checksum, we ignore that case
267 * and take the potential slowdown of unaligned loads.
268 *
269 * If the source and destination are relatively unaligned we only
270 * align the source. This keeps things simple.
271 */
272 rldicl. r6,r3,64-1,64-2 /* r6 = (r3 & 0x3) >> 1 */
273 beq .Lcopy_aligned
274
275 li r7,4
276 sub r6,r7,r6
277 mtctr r6
278
2791:
280source; lhz r6,0(r3) /* align to doubleword */
141 subi r5,r5,2 281 subi r5,r5,2
14291: sth r6,4(r4)
143 addi r4,r4,2
144 addc r0,r0,r6
145 srwi. r6,r5,2 /* # words to do */
146 beq 3f
1471: mtctr r6
14882: lwzu r6,4(r3) /* the bdnz has zero overhead, so it should */
14992: stwu r6,4(r4) /* be unnecessary to unroll this loop */
150 adde r0,r0,r6
151 bdnz 82b
152 andi. r5,r5,3
1533: cmpwi 0,r5,2
154 blt+ 4f
15583: lhz r6,4(r3)
156 addi r3,r3,2 282 addi r3,r3,2
157 subi r5,r5,2 283 adde r0,r0,r6
15893: sth r6,4(r4) 284dest; sth r6,0(r4)
159 addi r4,r4,2 285 addi r4,r4,2
286 bdnz 1b
287
288.Lcopy_aligned:
289 /*
290 * We unroll the loop such that each iteration is 64 bytes with an
291 * entry and exit limb of 64 bytes, meaning a minimum size of
292 * 128 bytes.
293 */
294 srdi. r6,r5,7
295 beq .Lcopy_tail_doublewords /* len < 128 */
296
297 srdi r6,r5,6
298 subi r6,r6,1
299 mtctr r6
300
301 stdu r1,-STACKFRAMESIZE(r1)
302 std r14,STK_REG(r14)(r1)
303 std r15,STK_REG(r15)(r1)
304 std r16,STK_REG(r16)(r1)
305
306source; ld r6,0(r3)
307source; ld r9,8(r3)
308
309source; ld r10,16(r3)
310source; ld r11,24(r3)
311
312 /*
313 * On POWER6 and POWER7 back to back addes take 2 cycles because of
314 * the XER dependency. This means the fastest this loop can go is
315 * 16 cycles per iteration. The scheduling of the loop below has
316 * been shown to hit this on both POWER6 and POWER7.
317 */
318 .align 5
3192:
160 adde r0,r0,r6 320 adde r0,r0,r6
1614: cmpwi 0,r5,1 321source; ld r12,32(r3)
162 bne+ 5f 322source; ld r14,40(r3)
16384: lbz r6,4(r3) 323
16494: stb r6,4(r4) 324 adde r0,r0,r9
165 slwi r6,r6,8 /* Upper byte of word */ 325source; ld r15,48(r3)
326source; ld r16,56(r3)
327 addi r3,r3,64
328
329 adde r0,r0,r10
330dest; std r6,0(r4)
331dest; std r9,8(r4)
332
333 adde r0,r0,r11
334dest; std r10,16(r4)
335dest; std r11,24(r4)
336
337 adde r0,r0,r12
338dest; std r12,32(r4)
339dest; std r14,40(r4)
340
341 adde r0,r0,r14
342dest; std r15,48(r4)
343dest; std r16,56(r4)
344 addi r4,r4,64
345
346 adde r0,r0,r15
347source; ld r6,0(r3)
348source; ld r9,8(r3)
349
350 adde r0,r0,r16
351source; ld r10,16(r3)
352source; ld r11,24(r3)
353 bdnz 2b
354
355
166 adde r0,r0,r6 356 adde r0,r0,r6
1675: addze r3,r0 /* add in final carry (unlikely with 64-bit regs) */ 357source; ld r12,32(r3)
168 rldicl r4,r3,32,0 /* fold 64 bit value */ 358source; ld r14,40(r3)
169 add r3,r4,r3
170 srdi r3,r3,32
171 blr
172 359
173/* These shouldn't go in the fixup section, since that would 360 adde r0,r0,r9
174 cause the ex_table addresses to get out of order. */ 361source; ld r15,48(r3)
362source; ld r16,56(r3)
363 addi r3,r3,64
364
365 adde r0,r0,r10
366dest; std r6,0(r4)
367dest; std r9,8(r4)
368
369 adde r0,r0,r11
370dest; std r10,16(r4)
371dest; std r11,24(r4)
372
373 adde r0,r0,r12
374dest; std r12,32(r4)
375dest; std r14,40(r4)
376
377 adde r0,r0,r14
378dest; std r15,48(r4)
379dest; std r16,56(r4)
380 addi r4,r4,64
381
382 adde r0,r0,r15
383 adde r0,r0,r16
384
385 ld r14,STK_REG(r14)(r1)
386 ld r15,STK_REG(r15)(r1)
387 ld r16,STK_REG(r16)(r1)
388 addi r1,r1,STACKFRAMESIZE
389
390 andi. r5,r5,63
391
392.Lcopy_tail_doublewords: /* Up to 127 bytes to go */
393 srdi. r6,r5,3
394 beq .Lcopy_tail_word
175 395
176 .globl src_error_1
177src_error_1:
178 li r6,0
179 subi r5,r5,2
18095: sth r6,4(r4)
181 addi r4,r4,2
182 srwi. r6,r5,2
183 beq 3f
184 mtctr r6 396 mtctr r6
185 .globl src_error_2 3973:
186src_error_2: 398source; ld r6,0(r3)
187 li r6,0 399 addi r3,r3,8
18896: stwu r6,4(r4) 400 adde r0,r0,r6
189 bdnz 96b 401dest; std r6,0(r4)
1903: andi. r5,r5,3 402 addi r4,r4,8
191 beq src_error 403 bdnz 3b
192 .globl src_error_3 404
193src_error_3: 405 andi. r5,r5,7
194 li r6,0 406
195 mtctr r5 407.Lcopy_tail_word: /* Up to 7 bytes to go */
196 addi r4,r4,3 408 srdi. r6,r5,2
19797: stbu r6,1(r4) 409 beq .Lcopy_tail_halfword
198 bdnz 97b 410
199 .globl src_error 411source; lwz r6,0(r3)
200src_error: 412 addi r3,r3,4
413 adde r0,r0,r6
414dest; stw r6,0(r4)
415 addi r4,r4,4
416 subi r5,r5,4
417
418.Lcopy_tail_halfword: /* Up to 3 bytes to go */
419 srdi. r6,r5,1
420 beq .Lcopy_tail_byte
421
422source; lhz r6,0(r3)
423 addi r3,r3,2
424 adde r0,r0,r6
425dest; sth r6,0(r4)
426 addi r4,r4,2
427 subi r5,r5,2
428
429.Lcopy_tail_byte: /* Up to 1 byte to go */
430 andi. r6,r5,1
431 beq .Lcopy_finish
432
433source; lbz r6,0(r3)
434 sldi r9,r6,8 /* Pad the byte out to 16 bits */
435 adde r0,r0,r9
436dest; stb r6,0(r4)
437
438.Lcopy_finish:
439 addze r0,r0 /* add in final carry */
440 rldicl r4,r0,32,0 /* fold two 32 bit halves together */
441 add r3,r4,r0
442 srdi r3,r3,32
443 blr
444
445.Lsrc_error:
201 cmpdi 0,r7,0 446 cmpdi 0,r7,0
202 beq 1f 447 beqlr
203 li r6,-EFAULT 448 li r6,-EFAULT
204 stw r6,0(r7) 449 stw r6,0(r7)
2051: addze r3,r0
206 blr 450 blr
207 451
208 .globl dst_error 452.Ldest_error:
209dst_error:
210 cmpdi 0,r8,0 453 cmpdi 0,r8,0
211 beq 1f 454 beqlr
212 li r6,-EFAULT 455 li r6,-EFAULT
213 stw r6,0(r8) 456 stw r6,0(r8)
2141: addze r3,r0
215 blr 457 blr
216
217.section __ex_table,"a"
218 .align 3
219 .llong 81b,src_error_1
220 .llong 91b,dst_error
221 .llong 82b,src_error_2
222 .llong 92b,dst_error
223 .llong 83b,src_error_3
224 .llong 93b,dst_error
225 .llong 84b,src_error_3
226 .llong 94b,dst_error
227 .llong 95b,dst_error
228 .llong 96b,dst_error
229 .llong 97b,dst_error
diff --git a/arch/powerpc/lib/checksum_wrappers_64.c b/arch/powerpc/lib/checksum_wrappers_64.c
new file mode 100644
index 000000000000..769b817fbb32
--- /dev/null
+++ b/arch/powerpc/lib/checksum_wrappers_64.c
@@ -0,0 +1,102 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2010
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <linux/module.h>
21#include <linux/compiler.h>
22#include <linux/types.h>
23#include <asm/checksum.h>
24#include <asm/uaccess.h>
25
26__wsum csum_and_copy_from_user(const void __user *src, void *dst,
27 int len, __wsum sum, int *err_ptr)
28{
29 unsigned int csum;
30
31 might_sleep();
32
33 *err_ptr = 0;
34
35 if (!len) {
36 csum = 0;
37 goto out;
38 }
39
40 if (unlikely((len < 0) || !access_ok(VERIFY_READ, src, len))) {
41 *err_ptr = -EFAULT;
42 csum = (__force unsigned int)sum;
43 goto out;
44 }
45
46 csum = csum_partial_copy_generic((void __force *)src, dst,
47 len, sum, err_ptr, NULL);
48
49 if (unlikely(*err_ptr)) {
50 int missing = __copy_from_user(dst, src, len);
51
52 if (missing) {
53 memset(dst + len - missing, 0, missing);
54 *err_ptr = -EFAULT;
55 } else {
56 *err_ptr = 0;
57 }
58
59 csum = csum_partial(dst, len, sum);
60 }
61
62out:
63 return (__force __wsum)csum;
64}
65EXPORT_SYMBOL(csum_and_copy_from_user);
66
67__wsum csum_and_copy_to_user(const void *src, void __user *dst, int len,
68 __wsum sum, int *err_ptr)
69{
70 unsigned int csum;
71
72 might_sleep();
73
74 *err_ptr = 0;
75
76 if (!len) {
77 csum = 0;
78 goto out;
79 }
80
81 if (unlikely((len < 0) || !access_ok(VERIFY_WRITE, dst, len))) {
82 *err_ptr = -EFAULT;
83 csum = -1; /* invalid checksum */
84 goto out;
85 }
86
87 csum = csum_partial_copy_generic(src, (void __force *)dst,
88 len, sum, NULL, err_ptr);
89
90 if (unlikely(*err_ptr)) {
91 csum = csum_partial(src, len, sum);
92
93 if (copy_to_user(dst, src, len)) {
94 *err_ptr = -EFAULT;
95 csum = -1; /* invalid checksum */
96 }
97 }
98
99out:
100 return (__force __wsum)csum;
101}
102EXPORT_SYMBOL(csum_and_copy_to_user);
diff --git a/arch/powerpc/lib/copy_32.S b/arch/powerpc/lib/copy_32.S
index 74a7f4130b4c..55f19f9fd708 100644
--- a/arch/powerpc/lib/copy_32.S
+++ b/arch/powerpc/lib/copy_32.S
@@ -62,7 +62,7 @@
62 62
63 .text 63 .text
64 .stabs "arch/powerpc/lib/",N_SO,0,0,0f 64 .stabs "arch/powerpc/lib/",N_SO,0,0,0f
65 .stabs "copy32.S",N_SO,0,0,0f 65 .stabs "copy_32.S",N_SO,0,0,0f
660: 660:
67 67
68CACHELINE_BYTES = L1_CACHE_BYTES 68CACHELINE_BYTES = L1_CACHE_BYTES
diff --git a/arch/powerpc/lib/ldstfp.S b/arch/powerpc/lib/ldstfp.S
index f6448636baf5..6a85380520b6 100644
--- a/arch/powerpc/lib/ldstfp.S
+++ b/arch/powerpc/lib/ldstfp.S
@@ -17,6 +17,8 @@
17#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19 19
20#ifdef CONFIG_PPC_FPU
21
20#define STKFRM (PPC_MIN_STKFRM + 16) 22#define STKFRM (PPC_MIN_STKFRM + 16)
21 23
22 .macro extab instr,handler 24 .macro extab instr,handler
@@ -81,7 +83,7 @@ _GLOBAL(do_lfs)
81 mfmsr r6 83 mfmsr r6
82 ori r7,r6,MSR_FP 84 ori r7,r6,MSR_FP
83 cmpwi cr7,r3,0 85 cmpwi cr7,r3,0
84 mtmsrd r7 86 MTMSRD(r7)
85 isync 87 isync
86 beq cr7,1f 88 beq cr7,1f
87 stfd fr0,STKFRM-16(r1) 89 stfd fr0,STKFRM-16(r1)
@@ -93,7 +95,7 @@ _GLOBAL(do_lfs)
93 lfd fr0,STKFRM-16(r1) 95 lfd fr0,STKFRM-16(r1)
944: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 964: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
95 mtlr r0 97 mtlr r0
96 mtmsrd r6 98 MTMSRD(r6)
97 isync 99 isync
98 mr r3,r9 100 mr r3,r9
99 addi r1,r1,STKFRM 101 addi r1,r1,STKFRM
@@ -108,7 +110,7 @@ _GLOBAL(do_lfd)
108 mfmsr r6 110 mfmsr r6
109 ori r7,r6,MSR_FP 111 ori r7,r6,MSR_FP
110 cmpwi cr7,r3,0 112 cmpwi cr7,r3,0
111 mtmsrd r7 113 MTMSRD(r7)
112 isync 114 isync
113 beq cr7,1f 115 beq cr7,1f
114 stfd fr0,STKFRM-16(r1) 116 stfd fr0,STKFRM-16(r1)
@@ -120,7 +122,7 @@ _GLOBAL(do_lfd)
120 lfd fr0,STKFRM-16(r1) 122 lfd fr0,STKFRM-16(r1)
1214: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 1234: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
122 mtlr r0 124 mtlr r0
123 mtmsrd r6 125 MTMSRD(r6)
124 isync 126 isync
125 mr r3,r9 127 mr r3,r9
126 addi r1,r1,STKFRM 128 addi r1,r1,STKFRM
@@ -135,7 +137,7 @@ _GLOBAL(do_stfs)
135 mfmsr r6 137 mfmsr r6
136 ori r7,r6,MSR_FP 138 ori r7,r6,MSR_FP
137 cmpwi cr7,r3,0 139 cmpwi cr7,r3,0
138 mtmsrd r7 140 MTMSRD(r7)
139 isync 141 isync
140 beq cr7,1f 142 beq cr7,1f
141 stfd fr0,STKFRM-16(r1) 143 stfd fr0,STKFRM-16(r1)
@@ -147,7 +149,7 @@ _GLOBAL(do_stfs)
147 lfd fr0,STKFRM-16(r1) 149 lfd fr0,STKFRM-16(r1)
1484: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 1504: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
149 mtlr r0 151 mtlr r0
150 mtmsrd r6 152 MTMSRD(r6)
151 isync 153 isync
152 mr r3,r9 154 mr r3,r9
153 addi r1,r1,STKFRM 155 addi r1,r1,STKFRM
@@ -162,7 +164,7 @@ _GLOBAL(do_stfd)
162 mfmsr r6 164 mfmsr r6
163 ori r7,r6,MSR_FP 165 ori r7,r6,MSR_FP
164 cmpwi cr7,r3,0 166 cmpwi cr7,r3,0
165 mtmsrd r7 167 MTMSRD(r7)
166 isync 168 isync
167 beq cr7,1f 169 beq cr7,1f
168 stfd fr0,STKFRM-16(r1) 170 stfd fr0,STKFRM-16(r1)
@@ -174,7 +176,7 @@ _GLOBAL(do_stfd)
174 lfd fr0,STKFRM-16(r1) 176 lfd fr0,STKFRM-16(r1)
1754: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 1774: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
176 mtlr r0 178 mtlr r0
177 mtmsrd r6 179 MTMSRD(r6)
178 isync 180 isync
179 mr r3,r9 181 mr r3,r9
180 addi r1,r1,STKFRM 182 addi r1,r1,STKFRM
@@ -229,7 +231,7 @@ _GLOBAL(do_lvx)
229 oris r7,r6,MSR_VEC@h 231 oris r7,r6,MSR_VEC@h
230 cmpwi cr7,r3,0 232 cmpwi cr7,r3,0
231 li r8,STKFRM-16 233 li r8,STKFRM-16
232 mtmsrd r7 234 MTMSRD(r7)
233 isync 235 isync
234 beq cr7,1f 236 beq cr7,1f
235 stvx vr0,r1,r8 237 stvx vr0,r1,r8
@@ -241,7 +243,7 @@ _GLOBAL(do_lvx)
241 lvx vr0,r1,r8 243 lvx vr0,r1,r8
2424: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 2444: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
243 mtlr r0 245 mtlr r0
244 mtmsrd r6 246 MTMSRD(r6)
245 isync 247 isync
246 mr r3,r9 248 mr r3,r9
247 addi r1,r1,STKFRM 249 addi r1,r1,STKFRM
@@ -257,7 +259,7 @@ _GLOBAL(do_stvx)
257 oris r7,r6,MSR_VEC@h 259 oris r7,r6,MSR_VEC@h
258 cmpwi cr7,r3,0 260 cmpwi cr7,r3,0
259 li r8,STKFRM-16 261 li r8,STKFRM-16
260 mtmsrd r7 262 MTMSRD(r7)
261 isync 263 isync
262 beq cr7,1f 264 beq cr7,1f
263 stvx vr0,r1,r8 265 stvx vr0,r1,r8
@@ -269,7 +271,7 @@ _GLOBAL(do_stvx)
269 lvx vr0,r1,r8 271 lvx vr0,r1,r8
2704: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 2724: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
271 mtlr r0 273 mtlr r0
272 mtmsrd r6 274 MTMSRD(r6)
273 isync 275 isync
274 mr r3,r9 276 mr r3,r9
275 addi r1,r1,STKFRM 277 addi r1,r1,STKFRM
@@ -325,7 +327,7 @@ _GLOBAL(do_lxvd2x)
325 oris r7,r6,MSR_VSX@h 327 oris r7,r6,MSR_VSX@h
326 cmpwi cr7,r3,0 328 cmpwi cr7,r3,0
327 li r8,STKFRM-16 329 li r8,STKFRM-16
328 mtmsrd r7 330 MTMSRD(r7)
329 isync 331 isync
330 beq cr7,1f 332 beq cr7,1f
331 STXVD2X(0,r1,r8) 333 STXVD2X(0,r1,r8)
@@ -337,7 +339,7 @@ _GLOBAL(do_lxvd2x)
337 LXVD2X(0,r1,r8) 339 LXVD2X(0,r1,r8)
3384: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 3404: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
339 mtlr r0 341 mtlr r0
340 mtmsrd r6 342 MTMSRD(r6)
341 isync 343 isync
342 mr r3,r9 344 mr r3,r9
343 addi r1,r1,STKFRM 345 addi r1,r1,STKFRM
@@ -353,7 +355,7 @@ _GLOBAL(do_stxvd2x)
353 oris r7,r6,MSR_VSX@h 355 oris r7,r6,MSR_VSX@h
354 cmpwi cr7,r3,0 356 cmpwi cr7,r3,0
355 li r8,STKFRM-16 357 li r8,STKFRM-16
356 mtmsrd r7 358 MTMSRD(r7)
357 isync 359 isync
358 beq cr7,1f 360 beq cr7,1f
359 STXVD2X(0,r1,r8) 361 STXVD2X(0,r1,r8)
@@ -365,7 +367,7 @@ _GLOBAL(do_stxvd2x)
365 LXVD2X(0,r1,r8) 367 LXVD2X(0,r1,r8)
3664: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1) 3684: PPC_LL r0,STKFRM+PPC_LR_STKOFF(r1)
367 mtlr r0 369 mtlr r0
368 mtmsrd r6 370 MTMSRD(r6)
369 isync 371 isync
370 mr r3,r9 372 mr r3,r9
371 addi r1,r1,STKFRM 373 addi r1,r1,STKFRM
@@ -373,3 +375,5 @@ _GLOBAL(do_stxvd2x)
373 extab 2b,3b 375 extab 2b,3b
374 376
375#endif /* CONFIG_VSX */ 377#endif /* CONFIG_VSX */
378
379#endif /* CONFIG_PPC_FPU */
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index 58e14fba11b1..9b8182e82166 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -34,7 +34,7 @@ void __spin_yield(arch_spinlock_t *lock)
34 return; 34 return;
35 holder_cpu = lock_value & 0xffff; 35 holder_cpu = lock_value & 0xffff;
36 BUG_ON(holder_cpu >= NR_CPUS); 36 BUG_ON(holder_cpu >= NR_CPUS);
37 yield_count = lppaca[holder_cpu].yield_count; 37 yield_count = lppaca_of(holder_cpu).yield_count;
38 if ((yield_count & 1) == 0) 38 if ((yield_count & 1) == 0)
39 return; /* virtual cpu is currently running */ 39 return; /* virtual cpu is currently running */
40 rmb(); 40 rmb();
@@ -65,7 +65,7 @@ void __rw_yield(arch_rwlock_t *rw)
65 return; /* no write lock at present */ 65 return; /* no write lock at present */
66 holder_cpu = lock_value & 0xffff; 66 holder_cpu = lock_value & 0xffff;
67 BUG_ON(holder_cpu >= NR_CPUS); 67 BUG_ON(holder_cpu >= NR_CPUS);
68 yield_count = lppaca[holder_cpu].yield_count; 68 yield_count = lppaca_of(holder_cpu).yield_count;
69 if ((yield_count & 1) == 0) 69 if ((yield_count & 1) == 0)
70 return; /* virtual cpu is currently running */ 70 return; /* virtual cpu is currently running */
71 rmb(); 71 rmb();
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index e0a9858d537e..ae5189ab0049 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -30,6 +30,7 @@ extern char system_call_common[];
30#define XER_OV 0x40000000U 30#define XER_OV 0x40000000U
31#define XER_CA 0x20000000U 31#define XER_CA 0x20000000U
32 32
33#ifdef CONFIG_PPC_FPU
33/* 34/*
34 * Functions in ldstfp.S 35 * Functions in ldstfp.S
35 */ 36 */
@@ -41,6 +42,7 @@ extern int do_lvx(int rn, unsigned long ea);
41extern int do_stvx(int rn, unsigned long ea); 42extern int do_stvx(int rn, unsigned long ea);
42extern int do_lxvd2x(int rn, unsigned long ea); 43extern int do_lxvd2x(int rn, unsigned long ea);
43extern int do_stxvd2x(int rn, unsigned long ea); 44extern int do_stxvd2x(int rn, unsigned long ea);
45#endif
44 46
45/* 47/*
46 * Determine whether a conditional branch instruction would branch. 48 * Determine whether a conditional branch instruction would branch.
@@ -290,6 +292,7 @@ static int __kprobes write_mem(unsigned long val, unsigned long ea, int nb,
290 return write_mem_unaligned(val, ea, nb, regs); 292 return write_mem_unaligned(val, ea, nb, regs);
291} 293}
292 294
295#ifdef CONFIG_PPC_FPU
293/* 296/*
294 * Check the address and alignment, and call func to do the actual 297 * Check the address and alignment, and call func to do the actual
295 * load or store. 298 * load or store.
@@ -351,6 +354,7 @@ static int __kprobes do_fp_store(int rn, int (*func)(int, unsigned long),
351 } 354 }
352 return err; 355 return err;
353} 356}
357#endif
354 358
355#ifdef CONFIG_ALTIVEC 359#ifdef CONFIG_ALTIVEC
356/* For Altivec/VMX, no need to worry about alignment */ 360/* For Altivec/VMX, no need to worry about alignment */
@@ -1393,6 +1397,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
1393 regs->gpr[rd] = byterev_4(val); 1397 regs->gpr[rd] = byterev_4(val);
1394 goto ldst_done; 1398 goto ldst_done;
1395 1399
1400#ifdef CONFIG_PPC_CPU
1396 case 535: /* lfsx */ 1401 case 535: /* lfsx */
1397 case 567: /* lfsux */ 1402 case 567: /* lfsux */
1398 if (!(regs->msr & MSR_FP)) 1403 if (!(regs->msr & MSR_FP))
@@ -1424,6 +1429,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
1424 ea = xform_ea(instr, regs, u); 1429 ea = xform_ea(instr, regs, u);
1425 err = do_fp_store(rd, do_stfd, ea, 8, regs); 1430 err = do_fp_store(rd, do_stfd, ea, 8, regs);
1426 goto ldst_done; 1431 goto ldst_done;
1432#endif
1427 1433
1428#ifdef __powerpc64__ 1434#ifdef __powerpc64__
1429 case 660: /* stdbrx */ 1435 case 660: /* stdbrx */
@@ -1534,6 +1540,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
1534 } while (++rd < 32); 1540 } while (++rd < 32);
1535 goto instr_done; 1541 goto instr_done;
1536 1542
1543#ifdef CONFIG_PPC_FPU
1537 case 48: /* lfs */ 1544 case 48: /* lfs */
1538 case 49: /* lfsu */ 1545 case 49: /* lfsu */
1539 if (!(regs->msr & MSR_FP)) 1546 if (!(regs->msr & MSR_FP))
@@ -1565,6 +1572,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
1565 ea = dform_ea(instr, regs); 1572 ea = dform_ea(instr, regs);
1566 err = do_fp_store(rd, do_stfd, ea, 8, regs); 1573 err = do_fp_store(rd, do_stfd, ea, 8, regs);
1567 goto ldst_done; 1574 goto ldst_done;
1575#endif
1568 1576
1569#ifdef __powerpc64__ 1577#ifdef __powerpc64__
1570 case 58: /* ld[u], lwa */ 1578 case 58: /* ld[u], lwa */
diff --git a/arch/powerpc/math-emu/Makefile b/arch/powerpc/math-emu/Makefile
index 0c16ab947f1f..7d1dba0d57f9 100644
--- a/arch/powerpc/math-emu/Makefile
+++ b/arch/powerpc/math-emu/Makefile
@@ -15,4 +15,4 @@ obj-$(CONFIG_SPE) += math_efp.o
15CFLAGS_fabs.o = -fno-builtin-fabs 15CFLAGS_fabs.o = -fno-builtin-fabs
16CFLAGS_math.o = -fno-builtin-fabs 16CFLAGS_math.o = -fno-builtin-fabs
17 17
18EXTRA_CFLAGS = -I. -Iinclude/math-emu -w 18ccflags-y = -I. -Iinclude/math-emu -w
diff --git a/arch/powerpc/mm/40x_mmu.c b/arch/powerpc/mm/40x_mmu.c
index 1dc2fa5ce1bd..5810967511d4 100644
--- a/arch/powerpc/mm/40x_mmu.c
+++ b/arch/powerpc/mm/40x_mmu.c
@@ -35,6 +35,7 @@
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/highmem.h> 37#include <linux/highmem.h>
38#include <linux/memblock.h>
38 39
39#include <asm/pgalloc.h> 40#include <asm/pgalloc.h>
40#include <asm/prom.h> 41#include <asm/prom.h>
@@ -47,6 +48,7 @@
47#include <asm/bootx.h> 48#include <asm/bootx.h>
48#include <asm/machdep.h> 49#include <asm/machdep.h>
49#include <asm/setup.h> 50#include <asm/setup.h>
51
50#include "mmu_decl.h" 52#include "mmu_decl.h"
51 53
52extern int __map_without_ltlbs; 54extern int __map_without_ltlbs;
@@ -139,8 +141,19 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
139 * coverage with normal-sized pages (or other reasons) do not 141 * coverage with normal-sized pages (or other reasons) do not
140 * attempt to allocate outside the allowed range. 142 * attempt to allocate outside the allowed range.
141 */ 143 */
142 144 memblock_set_current_limit(mapped);
143 __initial_memory_limit_addr = memstart_addr + mapped;
144 145
145 return mapped; 146 return mapped;
146} 147}
148
149void setup_initial_memory_limit(phys_addr_t first_memblock_base,
150 phys_addr_t first_memblock_size)
151{
152 /* We don't currently support the first MEMBLOCK not mapping 0
153 * physical on those processors
154 */
155 BUG_ON(first_memblock_base != 0);
156
157 /* 40x can only access 16MB at the moment (see head_40x.S) */
158 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
159}
diff --git a/arch/powerpc/mm/44x_mmu.c b/arch/powerpc/mm/44x_mmu.c
index d8c6efb32bc6..024acab588fd 100644
--- a/arch/powerpc/mm/44x_mmu.c
+++ b/arch/powerpc/mm/44x_mmu.c
@@ -24,6 +24,8 @@
24 */ 24 */
25 25
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/memblock.h>
28
27#include <asm/mmu.h> 29#include <asm/mmu.h>
28#include <asm/system.h> 30#include <asm/system.h>
29#include <asm/page.h> 31#include <asm/page.h>
@@ -213,6 +215,18 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
213 return total_lowmem; 215 return total_lowmem;
214} 216}
215 217
218void setup_initial_memory_limit(phys_addr_t first_memblock_base,
219 phys_addr_t first_memblock_size)
220{
221 /* We don't currently support the first MEMBLOCK not mapping 0
222 * physical on those processors
223 */
224 BUG_ON(first_memblock_base != 0);
225
226 /* 44x has a 256M TLB entry pinned at boot */
227 memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));
228}
229
216#ifdef CONFIG_SMP 230#ifdef CONFIG_SMP
217void __cpuinit mmu_init_secondary(int cpu) 231void __cpuinit mmu_init_secondary(int cpu)
218{ 232{
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index ce68708bbad5..bdca46e08382 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -4,9 +4,7 @@
4 4
5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 5subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
6 6
7ifeq ($(CONFIG_PPC64),y) 7ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
8EXTRA_CFLAGS += -mno-minimal-toc
9endif
10 8
11obj-y := fault.o mem.o pgtable.o gup.o \ 9obj-y := fault.o mem.o pgtable.o gup.o \
12 init_$(CONFIG_WORD_SIZE).o \ 10 init_$(CONFIG_WORD_SIZE).o \
@@ -25,7 +23,7 @@ obj-$(CONFIG_PPC_STD_MMU) += hash_low_$(CONFIG_WORD_SIZE).o \
25 mmu_context_hash$(CONFIG_WORD_SIZE).o 23 mmu_context_hash$(CONFIG_WORD_SIZE).o
26obj-$(CONFIG_40x) += 40x_mmu.o 24obj-$(CONFIG_40x) += 40x_mmu.o
27obj-$(CONFIG_44x) += 44x_mmu.o 25obj-$(CONFIG_44x) += 44x_mmu.o
28obj-$(CONFIG_FSL_BOOKE) += fsl_booke_mmu.o 26obj-$(CONFIG_PPC_FSL_BOOK3E) += fsl_booke_mmu.o
29obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o 27obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
30obj-$(CONFIG_PPC_MM_SLICES) += slice.o 28obj-$(CONFIG_PPC_MM_SLICES) += slice.o
31ifeq ($(CONFIG_HUGETLB_PAGE),y) 29ifeq ($(CONFIG_HUGETLB_PAGE),y)
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 1bd712c33ce2..54f4fb994e99 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -30,6 +30,7 @@
30#include <linux/kprobes.h> 30#include <linux/kprobes.h>
31#include <linux/kdebug.h> 31#include <linux/kdebug.h>
32#include <linux/perf_event.h> 32#include <linux/perf_event.h>
33#include <linux/magic.h>
33 34
34#include <asm/firmware.h> 35#include <asm/firmware.h>
35#include <asm/page.h> 36#include <asm/page.h>
@@ -385,6 +386,7 @@ do_sigbus:
385void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig) 386void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
386{ 387{
387 const struct exception_table_entry *entry; 388 const struct exception_table_entry *entry;
389 unsigned long *stackend;
388 390
389 /* Are we prepared to handle this fault? */ 391 /* Are we prepared to handle this fault? */
390 if ((entry = search_exception_tables(regs->nip)) != NULL) { 392 if ((entry = search_exception_tables(regs->nip)) != NULL) {
@@ -413,5 +415,9 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
413 printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n", 415 printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n",
414 regs->nip); 416 regs->nip);
415 417
418 stackend = end_of_stack(current);
419 if (current != &init_task && *stackend != STACK_END_MAGIC)
420 printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");
421
416 die("Kernel access of bad area", regs, sig); 422 die("Kernel access of bad area", regs, sig);
417} 423}
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c
index 4b66a1ece6d8..f7802c8bba0a 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -40,6 +40,7 @@
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/highmem.h> 42#include <linux/highmem.h>
43#include <linux/memblock.h>
43 44
44#include <asm/pgalloc.h> 45#include <asm/pgalloc.h>
45#include <asm/prom.h> 46#include <asm/prom.h>
@@ -56,11 +57,6 @@
56 57
57unsigned int tlbcam_index; 58unsigned int tlbcam_index;
58 59
59
60#if defined(CONFIG_LOWMEM_CAM_NUM_BOOL) && (CONFIG_LOWMEM_CAM_NUM >= NUM_TLBCAMS)
61#error "LOWMEM_CAM_NUM must be less than NUM_TLBCAMS"
62#endif
63
64#define NUM_TLBCAMS (64) 60#define NUM_TLBCAMS (64)
65struct tlbcam TLBCAM[NUM_TLBCAMS]; 61struct tlbcam TLBCAM[NUM_TLBCAMS];
66 62
@@ -137,7 +133,8 @@ static void settlbcam(int index, unsigned long virt, phys_addr_t phys,
137 if (mmu_has_feature(MMU_FTR_BIG_PHYS)) 133 if (mmu_has_feature(MMU_FTR_BIG_PHYS))
138 TLBCAM[index].MAS7 = (u64)phys >> 32; 134 TLBCAM[index].MAS7 = (u64)phys >> 32;
139 135
140 if (flags & _PAGE_USER) { 136 /* Below is unlikely -- only for large user pages or similar */
137 if (pte_user(flags)) {
141 TLBCAM[index].MAS3 |= MAS3_UX | MAS3_UR; 138 TLBCAM[index].MAS3 |= MAS3_UX | MAS3_UR;
142 TLBCAM[index].MAS3 |= ((flags & _PAGE_RW) ? MAS3_UW : 0); 139 TLBCAM[index].MAS3 |= ((flags & _PAGE_RW) ? MAS3_UW : 0);
143 } 140 }
@@ -184,6 +181,12 @@ unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx)
184 return amount_mapped; 181 return amount_mapped;
185} 182}
186 183
184#ifdef CONFIG_PPC32
185
186#if defined(CONFIG_LOWMEM_CAM_NUM_BOOL) && (CONFIG_LOWMEM_CAM_NUM >= NUM_TLBCAMS)
187#error "LOWMEM_CAM_NUM must be less than NUM_TLBCAMS"
188#endif
189
187unsigned long __init mmu_mapin_ram(unsigned long top) 190unsigned long __init mmu_mapin_ram(unsigned long top)
188{ 191{
189 return tlbcam_addrs[tlbcam_index - 1].limit - PAGE_OFFSET + 1; 192 return tlbcam_addrs[tlbcam_index - 1].limit - PAGE_OFFSET + 1;
@@ -213,5 +216,15 @@ void __init adjust_total_lowmem(void)
213 pr_cont("%lu Mb, residual: %dMb\n", tlbcam_sz(tlbcam_index - 1) >> 20, 216 pr_cont("%lu Mb, residual: %dMb\n", tlbcam_sz(tlbcam_index - 1) >> 20,
214 (unsigned int)((total_lowmem - __max_low_memory) >> 20)); 217 (unsigned int)((total_lowmem - __max_low_memory) >> 20));
215 218
216 __initial_memory_limit_addr = memstart_addr + __max_low_memory; 219 memblock_set_current_limit(memstart_addr + __max_low_memory);
217} 220}
221
222void setup_initial_memory_limit(phys_addr_t first_memblock_base,
223 phys_addr_t first_memblock_size)
224{
225 phys_addr_t limit = first_memblock_base + first_memblock_size;
226
227 /* 64M mapped initially according to head_fsl_booke.S */
228 memblock_set_current_limit(min_t(u64, limit, 0x04000000));
229}
230#endif
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 09dffe6efa46..83f534d862db 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -588,7 +588,7 @@ static void __init htab_initialize(void)
588 unsigned long pteg_count; 588 unsigned long pteg_count;
589 unsigned long prot; 589 unsigned long prot;
590 unsigned long base = 0, size = 0, limit; 590 unsigned long base = 0, size = 0, limit;
591 int i; 591 struct memblock_region *reg;
592 592
593 DBG(" -> htab_initialize()\n"); 593 DBG(" -> htab_initialize()\n");
594 594
@@ -625,7 +625,7 @@ static void __init htab_initialize(void)
625 if (machine_is(cell)) 625 if (machine_is(cell))
626 limit = 0x80000000; 626 limit = 0x80000000;
627 else 627 else
628 limit = 0; 628 limit = MEMBLOCK_ALLOC_ANYWHERE;
629 629
630 table = memblock_alloc_base(htab_size_bytes, htab_size_bytes, limit); 630 table = memblock_alloc_base(htab_size_bytes, htab_size_bytes, limit);
631 631
@@ -649,7 +649,7 @@ static void __init htab_initialize(void)
649#ifdef CONFIG_DEBUG_PAGEALLOC 649#ifdef CONFIG_DEBUG_PAGEALLOC
650 linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT; 650 linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT;
651 linear_map_hash_slots = __va(memblock_alloc_base(linear_map_hash_count, 651 linear_map_hash_slots = __va(memblock_alloc_base(linear_map_hash_count,
652 1, memblock.rmo_size)); 652 1, ppc64_rma_size));
653 memset(linear_map_hash_slots, 0, linear_map_hash_count); 653 memset(linear_map_hash_slots, 0, linear_map_hash_count);
654#endif /* CONFIG_DEBUG_PAGEALLOC */ 654#endif /* CONFIG_DEBUG_PAGEALLOC */
655 655
@@ -659,9 +659,9 @@ static void __init htab_initialize(void)
659 */ 659 */
660 660
661 /* create bolted the linear mapping in the hash table */ 661 /* create bolted the linear mapping in the hash table */
662 for (i=0; i < memblock.memory.cnt; i++) { 662 for_each_memblock(memory, reg) {
663 base = (unsigned long)__va(memblock.memory.region[i].base); 663 base = (unsigned long)__va(reg->base);
664 size = memblock.memory.region[i].size; 664 size = reg->size;
665 665
666 DBG("creating mapping for region: %lx..%lx (prot: %lx)\n", 666 DBG("creating mapping for region: %lx..%lx (prot: %lx)\n",
667 base, size, prot); 667 base, size, prot);
@@ -696,7 +696,8 @@ static void __init htab_initialize(void)
696#endif /* CONFIG_U3_DART */ 696#endif /* CONFIG_U3_DART */
697 BUG_ON(htab_bolt_mapping(base, base + size, __pa(base), 697 BUG_ON(htab_bolt_mapping(base, base + size, __pa(base),
698 prot, mmu_linear_psize, mmu_kernel_ssize)); 698 prot, mmu_linear_psize, mmu_kernel_ssize));
699 } 699 }
700 memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);
700 701
701 /* 702 /*
702 * If we have a memory_limit and we've allocated TCEs then we need to 703 * If we have a memory_limit and we've allocated TCEs then we need to
@@ -1247,3 +1248,23 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
1247 local_irq_restore(flags); 1248 local_irq_restore(flags);
1248} 1249}
1249#endif /* CONFIG_DEBUG_PAGEALLOC */ 1250#endif /* CONFIG_DEBUG_PAGEALLOC */
1251
1252void setup_initial_memory_limit(phys_addr_t first_memblock_base,
1253 phys_addr_t first_memblock_size)
1254{
1255 /* We don't currently support the first MEMBLOCK not mapping 0
1256 * physical on those processors
1257 */
1258 BUG_ON(first_memblock_base != 0);
1259
1260 /* On LPAR systems, the first entry is our RMA region,
1261 * non-LPAR 64-bit hash MMU systems don't have a limitation
1262 * on real mode access, but using the first entry works well
1263 * enough. We also clamp it to 1G to avoid some funky things
1264 * such as RTAS bugs etc...
1265 */
1266 ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000);
1267
1268 /* Finally limit subsequent allocations */
1269 memblock_set_current_limit(ppc64_rma_size);
1270}
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 6a6975dc2654..742da43b4ab6 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -92,12 +92,6 @@ int __allow_ioremap_reserved;
92unsigned long __max_low_memory = MAX_LOW_MEM; 92unsigned long __max_low_memory = MAX_LOW_MEM;
93 93
94/* 94/*
95 * address of the limit of what is accessible with initial MMU setup -
96 * 256MB usually, but only 16MB on 601.
97 */
98phys_addr_t __initial_memory_limit_addr = (phys_addr_t)0x10000000;
99
100/*
101 * Check for command-line options that affect what MMU_init will do. 95 * Check for command-line options that affect what MMU_init will do.
102 */ 96 */
103void MMU_setup(void) 97void MMU_setup(void)
@@ -126,13 +120,6 @@ void __init MMU_init(void)
126 if (ppc_md.progress) 120 if (ppc_md.progress)
127 ppc_md.progress("MMU:enter", 0x111); 121 ppc_md.progress("MMU:enter", 0x111);
128 122
129 /* 601 can only access 16MB at the moment */
130 if (PVR_VER(mfspr(SPRN_PVR)) == 1)
131 __initial_memory_limit_addr = 0x01000000;
132 /* 8xx can only access 8MB at the moment */
133 if (PVR_VER(mfspr(SPRN_PVR)) == 0x50)
134 __initial_memory_limit_addr = 0x00800000;
135
136 /* parse args from command line */ 123 /* parse args from command line */
137 MMU_setup(); 124 MMU_setup();
138 125
@@ -190,20 +177,18 @@ void __init MMU_init(void)
190#ifdef CONFIG_BOOTX_TEXT 177#ifdef CONFIG_BOOTX_TEXT
191 btext_unmap(); 178 btext_unmap();
192#endif 179#endif
180
181 /* Shortly after that, the entire linear mapping will be available */
182 memblock_set_current_limit(lowmem_end_addr);
193} 183}
194 184
195/* This is only called until mem_init is done. */ 185/* This is only called until mem_init is done. */
196void __init *early_get_page(void) 186void __init *early_get_page(void)
197{ 187{
198 void *p; 188 if (init_bootmem_done)
199 189 return alloc_bootmem_pages(PAGE_SIZE);
200 if (init_bootmem_done) { 190 else
201 p = alloc_bootmem_pages(PAGE_SIZE); 191 return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
202 } else {
203 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
204 __initial_memory_limit_addr));
205 }
206 return p;
207} 192}
208 193
209/* Free up now-unused memory */ 194/* Free up now-unused memory */
@@ -252,3 +237,17 @@ void free_initrd_mem(unsigned long start, unsigned long end)
252} 237}
253#endif 238#endif
254 239
240
241#ifdef CONFIG_8xx /* No 8xx specific .c file to put that in ... */
242void setup_initial_memory_limit(phys_addr_t first_memblock_base,
243 phys_addr_t first_memblock_size)
244{
245 /* We don't currently support the first MEMBLOCK not mapping 0
246 * physical on those processors
247 */
248 BUG_ON(first_memblock_base != 0);
249
250 /* 8xx can only access 8MB at the moment */
251 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
252}
253#endif /* CONFIG_8xx */
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index ace85fa74b29..6374b2196a17 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -330,3 +330,4 @@ int __meminit vmemmap_populate(struct page *start_page,
330 return 0; 330 return 0;
331} 331}
332#endif /* CONFIG_SPARSEMEM_VMEMMAP */ 332#endif /* CONFIG_SPARSEMEM_VMEMMAP */
333
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 1a84a8d00005..a66499650909 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -82,18 +82,11 @@ int page_is_ram(unsigned long pfn)
82 return pfn < max_pfn; 82 return pfn < max_pfn;
83#else 83#else
84 unsigned long paddr = (pfn << PAGE_SHIFT); 84 unsigned long paddr = (pfn << PAGE_SHIFT);
85 int i; 85 struct memblock_region *reg;
86 for (i=0; i < memblock.memory.cnt; i++) {
87 unsigned long base;
88 86
89 base = memblock.memory.region[i].base; 87 for_each_memblock(memory, reg)
90 88 if (paddr >= reg->base && paddr < (reg->base + reg->size))
91 if ((paddr >= base) &&
92 (paddr < (base + memblock.memory.region[i].size))) {
93 return 1; 89 return 1;
94 }
95 }
96
97 return 0; 90 return 0;
98#endif 91#endif
99} 92}
@@ -149,23 +142,19 @@ int
149walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, 142walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
150 void *arg, int (*func)(unsigned long, unsigned long, void *)) 143 void *arg, int (*func)(unsigned long, unsigned long, void *))
151{ 144{
152 struct memblock_property res; 145 struct memblock_region *reg;
153 unsigned long pfn, len; 146 unsigned long end_pfn = start_pfn + nr_pages;
154 u64 end; 147 unsigned long tstart, tend;
155 int ret = -1; 148 int ret = -1;
156 149
157 res.base = (u64) start_pfn << PAGE_SHIFT; 150 for_each_memblock(memory, reg) {
158 res.size = (u64) nr_pages << PAGE_SHIFT; 151 tstart = max(start_pfn, memblock_region_memory_base_pfn(reg));
159 152 tend = min(end_pfn, memblock_region_memory_end_pfn(reg));
160 end = res.base + res.size - 1; 153 if (tstart >= tend)
161 while ((res.base < end) && (memblock_find(&res) >= 0)) { 154 continue;
162 pfn = (unsigned long)(res.base >> PAGE_SHIFT); 155 ret = (*func)(tstart, tend - tstart, arg);
163 len = (unsigned long)(res.size >> PAGE_SHIFT);
164 ret = (*func)(pfn, len, arg);
165 if (ret) 156 if (ret)
166 break; 157 break;
167 res.base += (res.size + 1);
168 res.size = (end - res.base + 1);
169 } 158 }
170 return ret; 159 return ret;
171} 160}
@@ -179,9 +168,9 @@ EXPORT_SYMBOL_GPL(walk_system_ram_range);
179#ifndef CONFIG_NEED_MULTIPLE_NODES 168#ifndef CONFIG_NEED_MULTIPLE_NODES
180void __init do_init_bootmem(void) 169void __init do_init_bootmem(void)
181{ 170{
182 unsigned long i;
183 unsigned long start, bootmap_pages; 171 unsigned long start, bootmap_pages;
184 unsigned long total_pages; 172 unsigned long total_pages;
173 struct memblock_region *reg;
185 int boot_mapsize; 174 int boot_mapsize;
186 175
187 max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT; 176 max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
@@ -204,10 +193,10 @@ void __init do_init_bootmem(void)
204 boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn); 193 boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn);
205 194
206 /* Add active regions with valid PFNs */ 195 /* Add active regions with valid PFNs */
207 for (i = 0; i < memblock.memory.cnt; i++) { 196 for_each_memblock(memory, reg) {
208 unsigned long start_pfn, end_pfn; 197 unsigned long start_pfn, end_pfn;
209 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; 198 start_pfn = memblock_region_memory_base_pfn(reg);
210 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); 199 end_pfn = memblock_region_memory_end_pfn(reg);
211 add_active_range(0, start_pfn, end_pfn); 200 add_active_range(0, start_pfn, end_pfn);
212 } 201 }
213 202
@@ -218,29 +207,21 @@ void __init do_init_bootmem(void)
218 free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT); 207 free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT);
219 208
220 /* reserve the sections we're already using */ 209 /* reserve the sections we're already using */
221 for (i = 0; i < memblock.reserved.cnt; i++) { 210 for_each_memblock(reserved, reg) {
222 unsigned long addr = memblock.reserved.region[i].base + 211 unsigned long top = reg->base + reg->size - 1;
223 memblock_size_bytes(&memblock.reserved, i) - 1; 212 if (top < lowmem_end_addr)
224 if (addr < lowmem_end_addr) 213 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
225 reserve_bootmem(memblock.reserved.region[i].base, 214 else if (reg->base < lowmem_end_addr) {
226 memblock_size_bytes(&memblock.reserved, i), 215 unsigned long trunc_size = lowmem_end_addr - reg->base;
227 BOOTMEM_DEFAULT); 216 reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT);
228 else if (memblock.reserved.region[i].base < lowmem_end_addr) {
229 unsigned long adjusted_size = lowmem_end_addr -
230 memblock.reserved.region[i].base;
231 reserve_bootmem(memblock.reserved.region[i].base,
232 adjusted_size, BOOTMEM_DEFAULT);
233 } 217 }
234 } 218 }
235#else 219#else
236 free_bootmem_with_active_regions(0, max_pfn); 220 free_bootmem_with_active_regions(0, max_pfn);
237 221
238 /* reserve the sections we're already using */ 222 /* reserve the sections we're already using */
239 for (i = 0; i < memblock.reserved.cnt; i++) 223 for_each_memblock(reserved, reg)
240 reserve_bootmem(memblock.reserved.region[i].base, 224 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
241 memblock_size_bytes(&memblock.reserved, i),
242 BOOTMEM_DEFAULT);
243
244#endif 225#endif
245 /* XXX need to clip this if using highmem? */ 226 /* XXX need to clip this if using highmem? */
246 sparse_memory_present_with_active_regions(0); 227 sparse_memory_present_with_active_regions(0);
@@ -251,22 +232,15 @@ void __init do_init_bootmem(void)
251/* mark pages that don't exist as nosave */ 232/* mark pages that don't exist as nosave */
252static int __init mark_nonram_nosave(void) 233static int __init mark_nonram_nosave(void)
253{ 234{
254 unsigned long memblock_next_region_start_pfn, 235 struct memblock_region *reg, *prev = NULL;
255 memblock_region_max_pfn; 236
256 int i; 237 for_each_memblock(memory, reg) {
257 238 if (prev &&
258 for (i = 0; i < memblock.memory.cnt - 1; i++) { 239 memblock_region_memory_end_pfn(prev) < memblock_region_memory_base_pfn(reg))
259 memblock_region_max_pfn = 240 register_nosave_region(memblock_region_memory_end_pfn(prev),
260 (memblock.memory.region[i].base >> PAGE_SHIFT) + 241 memblock_region_memory_base_pfn(reg));
261 (memblock.memory.region[i].size >> PAGE_SHIFT); 242 prev = reg;
262 memblock_next_region_start_pfn =
263 memblock.memory.region[i+1].base >> PAGE_SHIFT;
264
265 if (memblock_region_max_pfn < memblock_next_region_start_pfn)
266 register_nosave_region(memblock_region_max_pfn,
267 memblock_next_region_start_pfn);
268 } 243 }
269
270 return 0; 244 return 0;
271} 245}
272 246
@@ -327,7 +301,7 @@ void __init mem_init(void)
327 swiotlb_init(1); 301 swiotlb_init(1);
328#endif 302#endif
329 303
330 num_physpages = memblock.memory.size >> PAGE_SHIFT; 304 num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
331 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); 305 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
332 306
333#ifdef CONFIG_NEED_MULTIPLE_NODES 307#ifdef CONFIG_NEED_MULTIPLE_NODES
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index ddfd7ad4e1d6..5ce99848d91e 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -334,7 +334,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
334 /* We don't touch CPU 0 map, it's allocated at aboot and kept 334 /* We don't touch CPU 0 map, it's allocated at aboot and kept
335 * around forever 335 * around forever
336 */ 336 */
337 if (cpu == 0) 337 if (cpu == boot_cpuid)
338 return NOTIFY_OK; 338 return NOTIFY_OK;
339 339
340 switch (action) { 340 switch (action) {
@@ -420,9 +420,11 @@ void __init mmu_context_init(void)
420 */ 420 */
421 context_map = alloc_bootmem(CTX_MAP_SIZE); 421 context_map = alloc_bootmem(CTX_MAP_SIZE);
422 context_mm = alloc_bootmem(sizeof(void *) * (last_context + 1)); 422 context_mm = alloc_bootmem(sizeof(void *) * (last_context + 1));
423#ifndef CONFIG_SMP
423 stale_map[0] = alloc_bootmem(CTX_MAP_SIZE); 424 stale_map[0] = alloc_bootmem(CTX_MAP_SIZE);
425#else
426 stale_map[boot_cpuid] = alloc_bootmem(CTX_MAP_SIZE);
424 427
425#ifdef CONFIG_SMP
426 register_cpu_notifier(&mmu_context_cpu_nb); 428 register_cpu_notifier(&mmu_context_cpu_nb);
427#endif 429#endif
428 430
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
index 63b84a0d3b10..dd0a2589591d 100644
--- a/arch/powerpc/mm/mmu_decl.h
+++ b/arch/powerpc/mm/mmu_decl.h
@@ -140,10 +140,13 @@ extern void wii_memory_fixups(void);
140extern void MMU_init_hw(void); 140extern void MMU_init_hw(void);
141extern unsigned long mmu_mapin_ram(unsigned long top); 141extern unsigned long mmu_mapin_ram(unsigned long top);
142 142
143#elif defined(CONFIG_FSL_BOOKE) 143#elif defined(CONFIG_PPC_FSL_BOOK3E)
144extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx);
145#ifdef CONFIG_PPC32
144extern void MMU_init_hw(void); 146extern void MMU_init_hw(void);
145extern unsigned long mmu_mapin_ram(unsigned long top); 147extern unsigned long mmu_mapin_ram(unsigned long top);
146extern void adjust_total_lowmem(void); 148extern void adjust_total_lowmem(void);
149#endif
147extern void loadcam_entry(unsigned int index); 150extern void loadcam_entry(unsigned int index);
148 151
149struct tlbcam { 152struct tlbcam {
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 002878ccf90b..74505b245374 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -802,16 +802,17 @@ static void __init setup_nonnuma(void)
802 unsigned long top_of_ram = memblock_end_of_DRAM(); 802 unsigned long top_of_ram = memblock_end_of_DRAM();
803 unsigned long total_ram = memblock_phys_mem_size(); 803 unsigned long total_ram = memblock_phys_mem_size();
804 unsigned long start_pfn, end_pfn; 804 unsigned long start_pfn, end_pfn;
805 unsigned int i, nid = 0; 805 unsigned int nid = 0;
806 struct memblock_region *reg;
806 807
807 printk(KERN_DEBUG "Top of RAM: 0x%lx, Total RAM: 0x%lx\n", 808 printk(KERN_DEBUG "Top of RAM: 0x%lx, Total RAM: 0x%lx\n",
808 top_of_ram, total_ram); 809 top_of_ram, total_ram);
809 printk(KERN_DEBUG "Memory hole size: %ldMB\n", 810 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
810 (top_of_ram - total_ram) >> 20); 811 (top_of_ram - total_ram) >> 20);
811 812
812 for (i = 0; i < memblock.memory.cnt; ++i) { 813 for_each_memblock(memory, reg) {
813 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; 814 start_pfn = memblock_region_memory_base_pfn(reg);
814 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); 815 end_pfn = memblock_region_memory_end_pfn(reg);
815 816
816 fake_numa_create_new_node(end_pfn, &nid); 817 fake_numa_create_new_node(end_pfn, &nid);
817 add_active_range(nid, start_pfn, end_pfn); 818 add_active_range(nid, start_pfn, end_pfn);
@@ -947,11 +948,11 @@ static struct notifier_block __cpuinitdata ppc64_numa_nb = {
947static void mark_reserved_regions_for_nid(int nid) 948static void mark_reserved_regions_for_nid(int nid)
948{ 949{
949 struct pglist_data *node = NODE_DATA(nid); 950 struct pglist_data *node = NODE_DATA(nid);
950 int i; 951 struct memblock_region *reg;
951 952
952 for (i = 0; i < memblock.reserved.cnt; i++) { 953 for_each_memblock(reserved, reg) {
953 unsigned long physbase = memblock.reserved.region[i].base; 954 unsigned long physbase = reg->base;
954 unsigned long size = memblock.reserved.region[i].size; 955 unsigned long size = reg->size;
955 unsigned long start_pfn = physbase >> PAGE_SHIFT; 956 unsigned long start_pfn = physbase >> PAGE_SHIFT;
956 unsigned long end_pfn = PFN_UP(physbase + size); 957 unsigned long end_pfn = PFN_UP(physbase + size);
957 struct node_active_region node_ar; 958 struct node_active_region node_ar;
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index f8a01829d64f..11571e118831 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -223,8 +223,7 @@ void __init MMU_init_hw(void)
223 * Find some memory for the hash table. 223 * Find some memory for the hash table.
224 */ 224 */
225 if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); 225 if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322);
226 Hash = __va(memblock_alloc_base(Hash_size, Hash_size, 226 Hash = __va(memblock_alloc(Hash_size, Hash_size));
227 __initial_memory_limit_addr));
228 cacheable_memzero(Hash, Hash_size); 227 cacheable_memzero(Hash, Hash_size);
229 _SDR1 = __pa(Hash) | SDR1_LOW_BITS; 228 _SDR1 = __pa(Hash) | SDR1_LOW_BITS;
230 229
@@ -272,3 +271,18 @@ void __init MMU_init_hw(void)
272 271
273 if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205); 272 if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205);
274} 273}
274
275void setup_initial_memory_limit(phys_addr_t first_memblock_base,
276 phys_addr_t first_memblock_size)
277{
278 /* We don't currently support the first MEMBLOCK not mapping 0
279 * physical on those processors
280 */
281 BUG_ON(first_memblock_base != 0);
282
283 /* 601 can only access 16MB at the moment */
284 if (PVR_VER(mfspr(SPRN_PVR)) == 1)
285 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x01000000));
286 else /* Anything else has 256M mapped */
287 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));
288}
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index fe391e942521..36c0c449a899 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -349,11 +349,47 @@ void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address)
349 349
350static void setup_page_sizes(void) 350static void setup_page_sizes(void)
351{ 351{
352 unsigned int tlb0cfg = mfspr(SPRN_TLB0CFG); 352 unsigned int tlb0cfg;
353 unsigned int tlb0ps = mfspr(SPRN_TLB0PS); 353 unsigned int tlb0ps;
354 unsigned int eptcfg = mfspr(SPRN_EPTCFG); 354 unsigned int eptcfg;
355 int i, psize; 355 int i, psize;
356 356
357#ifdef CONFIG_PPC_FSL_BOOK3E
358 unsigned int mmucfg = mfspr(SPRN_MMUCFG);
359
360 if (((mmucfg & MMUCFG_MAVN) == MMUCFG_MAVN_V1) &&
361 (mmu_has_feature(MMU_FTR_TYPE_FSL_E))) {
362 unsigned int tlb1cfg = mfspr(SPRN_TLB1CFG);
363 unsigned int min_pg, max_pg;
364
365 min_pg = (tlb1cfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
366 max_pg = (tlb1cfg & TLBnCFG_MAXSIZE) >> TLBnCFG_MAXSIZE_SHIFT;
367
368 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize) {
369 struct mmu_psize_def *def;
370 unsigned int shift;
371
372 def = &mmu_psize_defs[psize];
373 shift = def->shift;
374
375 if (shift == 0)
376 continue;
377
378 /* adjust to be in terms of 4^shift Kb */
379 shift = (shift - 10) >> 1;
380
381 if ((shift >= min_pg) && (shift <= max_pg))
382 def->flags |= MMU_PAGE_SIZE_DIRECT;
383 }
384
385 goto no_indirect;
386 }
387#endif
388
389 tlb0cfg = mfspr(SPRN_TLB0CFG);
390 tlb0ps = mfspr(SPRN_TLB0PS);
391 eptcfg = mfspr(SPRN_EPTCFG);
392
357 /* Look for supported direct sizes */ 393 /* Look for supported direct sizes */
358 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize) { 394 for (psize = 0; psize < MMU_PAGE_COUNT; ++psize) {
359 struct mmu_psize_def *def = &mmu_psize_defs[psize]; 395 struct mmu_psize_def *def = &mmu_psize_defs[psize];
@@ -505,10 +541,26 @@ static void __early_init_mmu(int boot_cpu)
505 */ 541 */
506 linear_map_top = memblock_end_of_DRAM(); 542 linear_map_top = memblock_end_of_DRAM();
507 543
544#ifdef CONFIG_PPC_FSL_BOOK3E
545 if (mmu_has_feature(MMU_FTR_TYPE_FSL_E)) {
546 unsigned int num_cams;
547
548 /* use a quarter of the TLBCAM for bolted linear map */
549 num_cams = (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) / 4;
550 linear_map_top = map_mem_in_cams(linear_map_top, num_cams);
551
552 /* limit memory so we dont have linear faults */
553 memblock_enforce_memory_limit(linear_map_top);
554 memblock_analyze();
555 }
556#endif
557
508 /* A sync won't hurt us after mucking around with 558 /* A sync won't hurt us after mucking around with
509 * the MMU configuration 559 * the MMU configuration
510 */ 560 */
511 mb(); 561 mb();
562
563 memblock_set_current_limit(linear_map_top);
512} 564}
513 565
514void __init early_init_mmu(void) 566void __init early_init_mmu(void)
@@ -521,4 +573,18 @@ void __cpuinit early_init_mmu_secondary(void)
521 __early_init_mmu(0); 573 __early_init_mmu(0);
522} 574}
523 575
576void setup_initial_memory_limit(phys_addr_t first_memblock_base,
577 phys_addr_t first_memblock_size)
578{
579 /* On Embedded 64-bit, we adjust the RMA size to match
580 * the bolted TLB entry. We know for now that only 1G
581 * entries are supported though that may eventually
582 * change. We crop it to the size of the first MEMBLOCK to
583 * avoid going over total available memory just in case...
584 */
585 ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000);
586
587 /* Finally limit subsequent allocations */
588 memblock_set_current_limit(ppc64_memblock_base + ppc64_rma_size);
589}
524#endif /* CONFIG_PPC64 */ 590#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index b9d9fed8f36e..af405eefe48d 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -367,7 +367,7 @@ _GLOBAL(set_context)
367#error Unsupported processor type ! 367#error Unsupported processor type !
368#endif 368#endif
369 369
370#if defined(CONFIG_FSL_BOOKE) 370#if defined(CONFIG_PPC_FSL_BOOK3E)
371/* 371/*
372 * extern void loadcam_entry(unsigned int index) 372 * extern void loadcam_entry(unsigned int index)
373 * 373 *
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index e219ca43962d..73456c4cec28 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -1,8 +1,6 @@
1subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 1subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
2 2
3ifeq ($(CONFIG_PPC64),y) 3ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
4EXTRA_CFLAGS += -mno-minimal-toc
5endif
6 4
7obj-$(CONFIG_OPROFILE) += oprofile.o 5obj-$(CONFIG_OPROFILE) += oprofile.o
8 6
diff --git a/arch/powerpc/oprofile/backtrace.c b/arch/powerpc/oprofile/backtrace.c
index b4278cfd1f80..f75301f2c85f 100644
--- a/arch/powerpc/oprofile/backtrace.c
+++ b/arch/powerpc/oprofile/backtrace.c
@@ -105,7 +105,7 @@ void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth)
105 } 105 }
106 } else { 106 } else {
107#ifdef CONFIG_PPC64 107#ifdef CONFIG_PPC64
108 if (!test_thread_flag(TIF_32BIT)) { 108 if (!is_32bit_task()) {
109 while (depth--) { 109 while (depth--) {
110 sp = user_getsp64(sp, first_frame); 110 sp = user_getsp64(sp, first_frame);
111 if (!sp) 111 if (!sp)
diff --git a/arch/powerpc/oprofile/op_model_fsl_emb.c b/arch/powerpc/oprofile/op_model_fsl_emb.c
index 62312abffa28..d4e6507277b5 100644
--- a/arch/powerpc/oprofile/op_model_fsl_emb.c
+++ b/arch/powerpc/oprofile/op_model_fsl_emb.c
@@ -2,7 +2,7 @@
2 * Freescale Embedded oprofile support, based on ppc64 oprofile support 2 * Freescale Embedded oprofile support, based on ppc64 oprofile support
3 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM 3 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
4 * 4 *
5 * Copyright (c) 2004 Freescale Semiconductor, Inc 5 * Copyright (c) 2004, 2010 Freescale Semiconductor, Inc
6 * 6 *
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala <galak@kernel.crashing.org> 8 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -321,9 +321,6 @@ static void fsl_emb_handle_interrupt(struct pt_regs *regs,
321 int val; 321 int val;
322 int i; 322 int i;
323 323
324 /* set the PMM bit (see comment below) */
325 mtmsr(mfmsr() | MSR_PMM);
326
327 pc = regs->nip; 324 pc = regs->nip;
328 is_kernel = is_kernel_addr(pc); 325 is_kernel = is_kernel_addr(pc);
329 326
@@ -340,9 +337,13 @@ static void fsl_emb_handle_interrupt(struct pt_regs *regs,
340 } 337 }
341 338
342 /* The freeze bit was set by the interrupt. */ 339 /* The freeze bit was set by the interrupt. */
343 /* Clear the freeze bit, and reenable the interrupt. 340 /* Clear the freeze bit, and reenable the interrupt. The
344 * The counters won't actually start until the rfi clears 341 * counters won't actually start until the rfi clears the PMM
345 * the PMM bit */ 342 * bit. The PMM bit should not be set until after the interrupt
343 * is cleared to avoid it getting lost in some hypervisor
344 * environments.
345 */
346 mtmsr(mfmsr() | MSR_PMM);
346 pmc_start_ctrs(1); 347 pmc_start_ctrs(1);
347} 348}
348 349
diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
index 69d668c072ae..0f979c5c756b 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -17,6 +17,16 @@ config BAMBOO
17 help 17 help
18 This option enables support for the IBM PPC440EP evaluation board. 18 This option enables support for the IBM PPC440EP evaluation board.
19 19
20config BLUESTONE
21 bool "Bluestone"
22 depends on 44x
23 default n
24 select PPC44x_SIMPLE
25 select APM821xx
26 select IBM_NEW_EMAC_RGMII
27 help
28 This option enables support for the APM APM821xx Evaluation board.
29
20config EBONY 30config EBONY
21 bool "Ebony" 31 bool "Ebony"
22 depends on 44x 32 depends on 44x
@@ -293,6 +303,12 @@ config 460SX
293 select IBM_NEW_EMAC_ZMII 303 select IBM_NEW_EMAC_ZMII
294 select IBM_NEW_EMAC_TAH 304 select IBM_NEW_EMAC_TAH
295 305
306config APM821xx
307 bool
308 select PPC_FPU
309 select IBM_NEW_EMAC_EMAC4
310 select IBM_NEW_EMAC_TAH
311
296# 44x errata/workaround config symbols, selected by the CPU models above 312# 44x errata/workaround config symbols, selected by the CPU models above
297config IBM440EP_ERR42 313config IBM440EP_ERR42
298 bool 314 bool
diff --git a/arch/powerpc/platforms/44x/ppc44x_simple.c b/arch/powerpc/platforms/44x/ppc44x_simple.c
index 5f7a29d7f590..7ddcba3b9397 100644
--- a/arch/powerpc/platforms/44x/ppc44x_simple.c
+++ b/arch/powerpc/platforms/44x/ppc44x_simple.c
@@ -52,6 +52,7 @@ machine_device_initcall(ppc44x_simple, ppc44x_device_probe);
52static char *board[] __initdata = { 52static char *board[] __initdata = {
53 "amcc,arches", 53 "amcc,arches",
54 "amcc,bamboo", 54 "amcc,bamboo",
55 "amcc,bluestone",
55 "amcc,canyonlands", 56 "amcc,canyonlands",
56 "amcc,glacier", 57 "amcc,glacier",
57 "ibm,ebony", 58 "ibm,ebony",
diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c
index 5b243bd3eb3b..3dc2a8d262b8 100644
--- a/arch/powerpc/platforms/512x/clock.c
+++ b/arch/powerpc/platforms/512x/clock.c
@@ -57,7 +57,7 @@ static struct clk *mpc5121_clk_get(struct device *dev, const char *id)
57 int id_match = 0; 57 int id_match = 0;
58 58
59 if (dev == NULL || id == NULL) 59 if (dev == NULL || id == NULL)
60 return NULL; 60 return clk;
61 61
62 mutex_lock(&clocks_mutex); 62 mutex_lock(&clocks_mutex);
63 list_for_each_entry(p, &clocks, node) { 63 list_for_each_entry(p, &clocks, node) {
diff --git a/arch/powerpc/platforms/52xx/efika.c b/arch/powerpc/platforms/52xx/efika.c
index 45c0cb9b67e6..18c104820198 100644
--- a/arch/powerpc/platforms/52xx/efika.c
+++ b/arch/powerpc/platforms/52xx/efika.c
@@ -99,7 +99,7 @@ static void __init efika_pcisetup(void)
99 if (bus_range == NULL || len < 2 * sizeof(int)) { 99 if (bus_range == NULL || len < 2 * sizeof(int)) {
100 printk(KERN_WARNING EFIKA_PLATFORM_NAME 100 printk(KERN_WARNING EFIKA_PLATFORM_NAME
101 ": Can't get bus-range for %s\n", pcictrl->full_name); 101 ": Can't get bus-range for %s\n", pcictrl->full_name);
102 return; 102 goto out_put;
103 } 103 }
104 104
105 if (bus_range[1] == bus_range[0]) 105 if (bus_range[1] == bus_range[0])
@@ -111,12 +111,12 @@ static void __init efika_pcisetup(void)
111 printk(" controlled by %s\n", pcictrl->full_name); 111 printk(" controlled by %s\n", pcictrl->full_name);
112 printk("\n"); 112 printk("\n");
113 113
114 hose = pcibios_alloc_controller(of_node_get(pcictrl)); 114 hose = pcibios_alloc_controller(pcictrl);
115 if (!hose) { 115 if (!hose) {
116 printk(KERN_WARNING EFIKA_PLATFORM_NAME 116 printk(KERN_WARNING EFIKA_PLATFORM_NAME
117 ": Can't allocate PCI controller structure for %s\n", 117 ": Can't allocate PCI controller structure for %s\n",
118 pcictrl->full_name); 118 pcictrl->full_name);
119 return; 119 goto out_put;
120 } 120 }
121 121
122 hose->first_busno = bus_range[0]; 122 hose->first_busno = bus_range[0];
@@ -124,6 +124,9 @@ static void __init efika_pcisetup(void)
124 hose->ops = &rtas_pci_ops; 124 hose->ops = &rtas_pci_ops;
125 125
126 pci_process_bridge_OF_ranges(hose, pcictrl, 0); 126 pci_process_bridge_OF_ranges(hose, pcictrl, 0);
127 return;
128out_put:
129 of_node_put(pcictrl);
127} 130}
128 131
129#else 132#else
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 6e905314ad5d..41f3a7eda1de 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -325,12 +325,16 @@ int mpc5200_psc_ac97_gpio_reset(int psc_number)
325 clrbits32(&simple_gpio->simple_dvo, sync | out); 325 clrbits32(&simple_gpio->simple_dvo, sync | out);
326 clrbits8(&wkup_gpio->wkup_dvo, reset); 326 clrbits8(&wkup_gpio->wkup_dvo, reset);
327 327
328 /* wait at lease 1 us */ 328 /* wait for 1 us */
329 udelay(2); 329 udelay(1);
330 330
331 /* Deassert reset */ 331 /* Deassert reset */
332 setbits8(&wkup_gpio->wkup_dvo, reset); 332 setbits8(&wkup_gpio->wkup_dvo, reset);
333 333
334 /* wait at least 200ns */
335 /* 7 ~= (200ns * timebase) / ns2sec */
336 __delay(7);
337
334 /* Restore pin-muxing */ 338 /* Restore pin-muxing */
335 out_be32(&simple_gpio->port_config, mux); 339 out_be32(&simple_gpio->port_config, mux);
336 340
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 021763a32c2f..73f4135f3a1a 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -10,12 +10,12 @@ menuconfig PPC_83xx
10if PPC_83xx 10if PPC_83xx
11 11
12config MPC830x_RDB 12config MPC830x_RDB
13 bool "Freescale MPC830x RDB" 13 bool "Freescale MPC830x RDB and derivatives"
14 select DEFAULT_UIMAGE 14 select DEFAULT_UIMAGE
15 select PPC_MPC831x 15 select PPC_MPC831x
16 select FSL_GTM 16 select FSL_GTM
17 help 17 help
18 This option enables support for the MPC8308 RDB board. 18 This option enables support for the MPC8308 RDB and MPC8308 P1M boards.
19 19
20config MPC831x_RDB 20config MPC831x_RDB
21 bool "Freescale MPC831x RDB" 21 bool "Freescale MPC831x RDB"
diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
index ac102ee9abe8..846831d495b5 100644
--- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
@@ -65,7 +65,8 @@ static int __init mpc830x_rdb_probe(void)
65 unsigned long root = of_get_flat_dt_root(); 65 unsigned long root = of_get_flat_dt_root();
66 66
67 return of_flat_dt_is_compatible(root, "MPC8308RDB") || 67 return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
68 of_flat_dt_is_compatible(root, "fsl,mpc8308rdb"); 68 of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
69 of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
69} 70}
70 71
71static struct of_device_id __initdata of_bus_ids[] = { 72static struct of_device_id __initdata of_bus_ids[] = {
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index bea1f5905ad4..b6976e1726e4 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -11,6 +11,8 @@ menuconfig FSL_SOC_BOOKE
11 11
12if FSL_SOC_BOOKE 12if FSL_SOC_BOOKE
13 13
14if PPC32
15
14config MPC8540_ADS 16config MPC8540_ADS
15 bool "Freescale MPC8540 ADS" 17 bool "Freescale MPC8540 ADS"
16 select DEFAULT_UIMAGE 18 select DEFAULT_UIMAGE
@@ -153,10 +155,20 @@ config SBC8560
153 help 155 help
154 This option enables support for the Wind River SBC8560 board 156 This option enables support for the Wind River SBC8560 board
155 157
158config P3041_DS
159 bool "Freescale P3041 DS"
160 select DEFAULT_UIMAGE
161 select PPC_E500MC
162 select PHYS_64BIT
163 select SWIOTLB
164 select MPC8xxx_GPIO
165 select HAS_RAPIDIO
166 help
167 This option enables support for the P3041 DS board
168
156config P4080_DS 169config P4080_DS
157 bool "Freescale P4080 DS" 170 bool "Freescale P4080 DS"
158 select DEFAULT_UIMAGE 171 select DEFAULT_UIMAGE
159 select PPC_FSL_BOOK3E
160 select PPC_E500MC 172 select PPC_E500MC
161 select PHYS_64BIT 173 select PHYS_64BIT
162 select SWIOTLB 174 select SWIOTLB
@@ -165,6 +177,20 @@ config P4080_DS
165 help 177 help
166 This option enables support for the P4080 DS board 178 This option enables support for the P4080 DS board
167 179
180endif # PPC32
181
182config P5020_DS
183 bool "Freescale P5020 DS"
184 select DEFAULT_UIMAGE
185 select E500
186 select PPC_E500MC
187 select PHYS_64BIT
188 select SWIOTLB
189 select MPC8xxx_GPIO
190 select HAS_RAPIDIO
191 help
192 This option enables support for the P5020 DS board
193
168endif # FSL_SOC_BOOKE 194endif # FSL_SOC_BOOKE
169 195
170config TQM85xx 196config TQM85xx
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index a2ec3f8f4d06..dd70db77d63e 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -11,7 +11,9 @@ obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o
11obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o 11obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
12obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o 12obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
13obj-$(CONFIG_P1022_DS) += p1022_ds.o 13obj-$(CONFIG_P1022_DS) += p1022_ds.o
14obj-$(CONFIG_P3041_DS) += p3041_ds.o corenet_ds.o
14obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o 15obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o
16obj-$(CONFIG_P5020_DS) += p5020_ds.o corenet_ds.o
15obj-$(CONFIG_STX_GP3) += stx_gp3.o 17obj-$(CONFIG_STX_GP3) += stx_gp3.o
16obj-$(CONFIG_TQM85xx) += tqm85xx.o 18obj-$(CONFIG_TQM85xx) += tqm85xx.o
17obj-$(CONFIG_SBC8560) += sbc8560.o 19obj-$(CONFIG_SBC8560) += sbc8560.o
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 34e00902ce86..2b390d19a1d1 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -112,6 +112,8 @@ static struct of_device_id __initdata p1022_ds_ids[] = {
112 { .compatible = "soc", }, 112 { .compatible = "soc", },
113 { .compatible = "simple-bus", }, 113 { .compatible = "simple-bus", },
114 { .compatible = "gianfar", }, 114 { .compatible = "gianfar", },
115 /* So that the DMA channel nodes can be probed individually: */
116 { .compatible = "fsl,eloplus-dma", },
115 {}, 117 {},
116}; 118};
117 119
diff --git a/arch/powerpc/platforms/85xx/p3041_ds.c b/arch/powerpc/platforms/85xx/p3041_ds.c
new file mode 100644
index 000000000000..0ed52e18298c
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/p3041_ds.c
@@ -0,0 +1,64 @@
1/*
2 * P3041 DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2010 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 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/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/system.h>
22#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
29
30#include <linux/of_platform.h>
31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init p3041_ds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42
43 return of_flat_dt_is_compatible(root, "fsl,P3041DS");
44}
45
46define_machine(p3041_ds) {
47 .name = "P3041 DS",
48 .probe = p3041_ds_probe,
49 .setup_arch = corenet_ds_setup_arch,
50 .init_IRQ = corenet_ds_pic_init,
51#ifdef CONFIG_PCI
52 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
53#endif
54 .get_irq = mpic_get_coreint_irq,
55 .restart = fsl_rstcr_restart,
56 .calibrate_decr = generic_calibrate_decr,
57 .progress = udbg_progress,
58};
59
60machine_device_initcall(p3041_ds, corenet_ds_publish_devices);
61
62#ifdef CONFIG_SWIOTLB
63machine_arch_initcall(p3041_ds, swiotlb_setup_bus_notifier);
64#endif
diff --git a/arch/powerpc/platforms/85xx/p5020_ds.c b/arch/powerpc/platforms/85xx/p5020_ds.c
new file mode 100644
index 000000000000..7467b712ee00
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/p5020_ds.c
@@ -0,0 +1,69 @@
1/*
2 * P5020 DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2010 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 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/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/system.h>
22#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
29
30#include <linux/of_platform.h>
31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init p5020_ds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42
43 return of_flat_dt_is_compatible(root, "fsl,P5020DS");
44}
45
46define_machine(p5020_ds) {
47 .name = "P5020 DS",
48 .probe = p5020_ds_probe,
49 .setup_arch = corenet_ds_setup_arch,
50 .init_IRQ = corenet_ds_pic_init,
51#ifdef CONFIG_PCI
52 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
53#endif
54/* coreint doesn't play nice with lazy EE, use legacy mpic for now */
55#ifdef CONFIG_PPC64
56 .get_irq = mpic_get_irq,
57#else
58 .get_irq = mpic_get_coreint_irq,
59#endif
60 .restart = fsl_rstcr_restart,
61 .calibrate_decr = generic_calibrate_decr,
62 .progress = udbg_progress,
63};
64
65machine_device_initcall(p5020_ds, corenet_ds_publish_devices);
66
67#ifdef CONFIG_SWIOTLB
68machine_arch_initcall(p5020_ds, swiotlb_setup_bus_notifier);
69#endif
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index a6b106557be4..5c91a992f02b 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/kexec.h> 18#include <linux/kexec.h>
19#include <linux/highmem.h>
19 20
20#include <asm/machdep.h> 21#include <asm/machdep.h>
21#include <asm/pgtable.h> 22#include <asm/pgtable.h>
@@ -79,6 +80,7 @@ smp_85xx_kick_cpu(int nr)
79 local_irq_save(flags); 80 local_irq_save(flags);
80 81
81 out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr); 82 out_be32(bptr_vaddr + BOOT_ENTRY_PIR, nr);
83#ifdef CONFIG_PPC32
82 out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start)); 84 out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start));
83 85
84 if (!ioremappable) 86 if (!ioremappable)
@@ -88,6 +90,12 @@ smp_85xx_kick_cpu(int nr)
88 /* Wait a bit for the CPU to ack. */ 90 /* Wait a bit for the CPU to ack. */
89 while ((__secondary_hold_acknowledge != nr) && (++n < 1000)) 91 while ((__secondary_hold_acknowledge != nr) && (++n < 1000))
90 mdelay(1); 92 mdelay(1);
93#else
94 out_be64((u64 *)(bptr_vaddr + BOOT_ENTRY_ADDR_UPPER),
95 __pa((u64)*((unsigned long long *) generic_secondary_smp_init)));
96
97 smp_generic_kick_cpu(nr);
98#endif
91 99
92 local_irq_restore(flags); 100 local_irq_restore(flags);
93 101
@@ -114,19 +122,15 @@ struct smp_ops_t smp_85xx_ops = {
114}; 122};
115 123
116#ifdef CONFIG_KEXEC 124#ifdef CONFIG_KEXEC
117static int kexec_down_cpus = 0; 125atomic_t kexec_down_cpus = ATOMIC_INIT(0);
118 126
119void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary) 127void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary)
120{ 128{
121 mpic_teardown_this_cpu(1); 129 local_irq_disable();
122
123 /* When crashing, this gets called on all CPU's we only
124 * take down the non-boot cpus */
125 if (smp_processor_id() != boot_cpuid)
126 {
127 local_irq_disable();
128 kexec_down_cpus++;
129 130
131 if (secondary) {
132 atomic_inc(&kexec_down_cpus);
133 /* loop forever */
130 while (1); 134 while (1);
131 } 135 }
132} 136}
@@ -137,16 +141,65 @@ static void mpc85xx_smp_kexec_down(void *arg)
137 ppc_md.kexec_cpu_down(0,1); 141 ppc_md.kexec_cpu_down(0,1);
138} 142}
139 143
140static void mpc85xx_smp_machine_kexec(struct kimage *image) 144static void map_and_flush(unsigned long paddr)
141{ 145{
142 int timeout = 2000; 146 struct page *page = pfn_to_page(paddr >> PAGE_SHIFT);
147 unsigned long kaddr = (unsigned long)kmap(page);
148
149 flush_dcache_range(kaddr, kaddr + PAGE_SIZE);
150 kunmap(page);
151}
152
153/**
154 * Before we reset the other cores, we need to flush relevant cache
155 * out to memory so we don't get anything corrupted, some of these flushes
156 * are performed out of an overabundance of caution as interrupts are not
157 * disabled yet and we can switch cores
158 */
159static void mpc85xx_smp_flush_dcache_kexec(struct kimage *image)
160{
161 kimage_entry_t *ptr, entry;
162 unsigned long paddr;
143 int i; 163 int i;
144 164
145 set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid)); 165 if (image->type == KEXEC_TYPE_DEFAULT) {
166 /* normal kexec images are stored in temporary pages */
167 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE);
168 ptr = (entry & IND_INDIRECTION) ?
169 phys_to_virt(entry & PAGE_MASK) : ptr + 1) {
170 if (!(entry & IND_DESTINATION)) {
171 map_and_flush(entry);
172 }
173 }
174 /* flush out last IND_DONE page */
175 map_and_flush(entry);
176 } else {
177 /* crash type kexec images are copied to the crash region */
178 for (i = 0; i < image->nr_segments; i++) {
179 struct kexec_segment *seg = &image->segment[i];
180 for (paddr = seg->mem; paddr < seg->mem + seg->memsz;
181 paddr += PAGE_SIZE) {
182 map_and_flush(paddr);
183 }
184 }
185 }
186
187 /* also flush the kimage struct to be passed in as well */
188 flush_dcache_range((unsigned long)image,
189 (unsigned long)image + sizeof(*image));
190}
191
192static void mpc85xx_smp_machine_kexec(struct kimage *image)
193{
194 int timeout = INT_MAX;
195 int i, num_cpus = num_present_cpus();
196
197 mpc85xx_smp_flush_dcache_kexec(image);
146 198
147 smp_call_function(mpc85xx_smp_kexec_down, NULL, 0); 199 if (image->type == KEXEC_TYPE_DEFAULT)
200 smp_call_function(mpc85xx_smp_kexec_down, NULL, 0);
148 201
149 while ( (kexec_down_cpus != (num_online_cpus() - 1)) && 202 while ( (atomic_read(&kexec_down_cpus) != (num_cpus - 1)) &&
150 ( timeout > 0 ) ) 203 ( timeout > 0 ) )
151 { 204 {
152 timeout--; 205 timeout--;
@@ -155,7 +208,7 @@ static void mpc85xx_smp_machine_kexec(struct kimage *image)
155 if ( !timeout ) 208 if ( !timeout )
156 printk(KERN_ERR "Unable to bring down secondary cpu(s)"); 209 printk(KERN_ERR "Unable to bring down secondary cpu(s)");
157 210
158 for (i = 0; i < num_present_cpus(); i++) 211 for (i = 0; i < num_cpus; i++)
159 { 212 {
160 if ( i == smp_processor_id() ) continue; 213 if ( i == smp_processor_id() ) continue;
161 mpic_reset_core(i); 214 mpic_reset_core(i);
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 81c9208025fa..956154f32cfe 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -21,6 +21,16 @@ source "arch/powerpc/platforms/44x/Kconfig"
21source "arch/powerpc/platforms/40x/Kconfig" 21source "arch/powerpc/platforms/40x/Kconfig"
22source "arch/powerpc/platforms/amigaone/Kconfig" 22source "arch/powerpc/platforms/amigaone/Kconfig"
23 23
24config KVM_GUEST
25 bool "KVM Guest support"
26 default y
27 ---help---
28 This option enables various optimizations for running under the KVM
29 hypervisor. Overhead for the kernel when not running inside KVM should
30 be minimal.
31
32 In case of doubt, say Y
33
24config PPC_NATIVE 34config PPC_NATIVE
25 bool 35 bool
26 depends on 6xx || PPC64 36 depends on 6xx || PPC64
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index d361f8119b1e..111138c55f9c 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -125,6 +125,7 @@ config 8xx
125 125
126config E500 126config E500
127 select FSL_EMB_PERFMON 127 select FSL_EMB_PERFMON
128 select PPC_FSL_BOOK3E
128 bool 129 bool
129 130
130config PPC_E500MC 131config PPC_E500MC
@@ -166,9 +167,14 @@ config BOOKE
166 167
167config FSL_BOOKE 168config FSL_BOOKE
168 bool 169 bool
169 depends on E200 || E500 170 depends on (E200 || E500) && PPC32
170 default y 171 default y
171 172
173# this is for common code between PPC32 & PPC64 FSL BOOKE
174config PPC_FSL_BOOK3E
175 bool
176 select FSL_EMB_PERFMON
177 default y if FSL_BOOKE
172 178
173config PTE_64BIT 179config PTE_64BIT
174 bool 180 bool
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 97085530aa63..e3e379c6caa7 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -310,9 +310,9 @@ static void axon_msi_teardown_msi_irqs(struct pci_dev *dev)
310} 310}
311 311
312static struct irq_chip msic_irq_chip = { 312static struct irq_chip msic_irq_chip = {
313 .mask = mask_msi_irq, 313 .irq_mask = mask_msi_irq,
314 .unmask = unmask_msi_irq, 314 .irq_unmask = unmask_msi_irq,
315 .shutdown = unmask_msi_irq, 315 .irq_shutdown = mask_msi_irq,
316 .name = "AXON-MSI", 316 .name = "AXON-MSI",
317}; 317};
318 318
diff --git a/arch/powerpc/platforms/cell/ras.c b/arch/powerpc/platforms/cell/ras.c
index 1d3c4effea10..5ec1e47a0d77 100644
--- a/arch/powerpc/platforms/cell/ras.c
+++ b/arch/powerpc/platforms/cell/ras.c
@@ -173,8 +173,10 @@ static int __init cbe_ptcal_enable(void)
173 return -ENODEV; 173 return -ENODEV;
174 174
175 size = of_get_property(np, "ibm,cbe-ptcal-size", NULL); 175 size = of_get_property(np, "ibm,cbe-ptcal-size", NULL);
176 if (!size) 176 if (!size) {
177 of_node_put(np);
177 return -ENODEV; 178 return -ENODEV;
179 }
178 180
179 pr_debug("%s: enabling PTCAL, size = 0x%x\n", __func__, *size); 181 pr_debug("%s: enabling PTCAL, size = 0x%x\n", __func__, *size);
180 order = get_order(*size); 182 order = get_order(*size);
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 5876e888e412..3f2e557344a3 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -258,8 +258,10 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
258 return NO_IRQ; 258 return NO_IRQ;
259 imap += intsize + 1; 259 imap += intsize + 1;
260 tmp = of_get_property(iic, "#interrupt-cells", NULL); 260 tmp = of_get_property(iic, "#interrupt-cells", NULL);
261 if (tmp == NULL) 261 if (tmp == NULL) {
262 of_node_put(iic);
262 return NO_IRQ; 263 return NO_IRQ;
264 }
263 intsize = *tmp; 265 intsize = *tmp;
264 /* Assume unit is last entry of interrupt specifier */ 266 /* Assume unit is last entry of interrupt specifier */
265 unit = imap[intsize - 1]; 267 unit = imap[intsize - 1];
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 1a40da92154c..02f7b113a31b 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -154,6 +154,7 @@ static const struct file_operations __fops = { \
154 .release = spufs_attr_release, \ 154 .release = spufs_attr_release, \
155 .read = spufs_attr_read, \ 155 .read = spufs_attr_read, \
156 .write = spufs_attr_write, \ 156 .write = spufs_attr_write, \
157 .llseek = generic_file_llseek, \
157}; 158};
158 159
159 160
@@ -521,6 +522,7 @@ static const struct file_operations spufs_cntl_fops = {
521 .release = spufs_cntl_release, 522 .release = spufs_cntl_release,
522 .read = simple_attr_read, 523 .read = simple_attr_read,
523 .write = simple_attr_write, 524 .write = simple_attr_write,
525 .llseek = generic_file_llseek,
524 .mmap = spufs_cntl_mmap, 526 .mmap = spufs_cntl_mmap,
525}; 527};
526 528
@@ -714,6 +716,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
714static const struct file_operations spufs_mbox_fops = { 716static const struct file_operations spufs_mbox_fops = {
715 .open = spufs_pipe_open, 717 .open = spufs_pipe_open,
716 .read = spufs_mbox_read, 718 .read = spufs_mbox_read,
719 .llseek = no_llseek,
717}; 720};
718 721
719static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf, 722static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
@@ -743,6 +746,7 @@ static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
743static const struct file_operations spufs_mbox_stat_fops = { 746static const struct file_operations spufs_mbox_stat_fops = {
744 .open = spufs_pipe_open, 747 .open = spufs_pipe_open,
745 .read = spufs_mbox_stat_read, 748 .read = spufs_mbox_stat_read,
749 .llseek = no_llseek,
746}; 750};
747 751
748/* low-level ibox access function */ 752/* low-level ibox access function */
@@ -863,6 +867,7 @@ static const struct file_operations spufs_ibox_fops = {
863 .read = spufs_ibox_read, 867 .read = spufs_ibox_read,
864 .poll = spufs_ibox_poll, 868 .poll = spufs_ibox_poll,
865 .fasync = spufs_ibox_fasync, 869 .fasync = spufs_ibox_fasync,
870 .llseek = no_llseek,
866}; 871};
867 872
868static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf, 873static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
@@ -890,6 +895,7 @@ static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
890static const struct file_operations spufs_ibox_stat_fops = { 895static const struct file_operations spufs_ibox_stat_fops = {
891 .open = spufs_pipe_open, 896 .open = spufs_pipe_open,
892 .read = spufs_ibox_stat_read, 897 .read = spufs_ibox_stat_read,
898 .llseek = no_llseek,
893}; 899};
894 900
895/* low-level mailbox write */ 901/* low-level mailbox write */
@@ -1011,6 +1017,7 @@ static const struct file_operations spufs_wbox_fops = {
1011 .write = spufs_wbox_write, 1017 .write = spufs_wbox_write,
1012 .poll = spufs_wbox_poll, 1018 .poll = spufs_wbox_poll,
1013 .fasync = spufs_wbox_fasync, 1019 .fasync = spufs_wbox_fasync,
1020 .llseek = no_llseek,
1014}; 1021};
1015 1022
1016static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf, 1023static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
@@ -1038,6 +1045,7 @@ static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
1038static const struct file_operations spufs_wbox_stat_fops = { 1045static const struct file_operations spufs_wbox_stat_fops = {
1039 .open = spufs_pipe_open, 1046 .open = spufs_pipe_open,
1040 .read = spufs_wbox_stat_read, 1047 .read = spufs_wbox_stat_read,
1048 .llseek = no_llseek,
1041}; 1049};
1042 1050
1043static int spufs_signal1_open(struct inode *inode, struct file *file) 1051static int spufs_signal1_open(struct inode *inode, struct file *file)
@@ -1166,6 +1174,7 @@ static const struct file_operations spufs_signal1_fops = {
1166 .read = spufs_signal1_read, 1174 .read = spufs_signal1_read,
1167 .write = spufs_signal1_write, 1175 .write = spufs_signal1_write,
1168 .mmap = spufs_signal1_mmap, 1176 .mmap = spufs_signal1_mmap,
1177 .llseek = no_llseek,
1169}; 1178};
1170 1179
1171static const struct file_operations spufs_signal1_nosched_fops = { 1180static const struct file_operations spufs_signal1_nosched_fops = {
@@ -1173,6 +1182,7 @@ static const struct file_operations spufs_signal1_nosched_fops = {
1173 .release = spufs_signal1_release, 1182 .release = spufs_signal1_release,
1174 .write = spufs_signal1_write, 1183 .write = spufs_signal1_write,
1175 .mmap = spufs_signal1_mmap, 1184 .mmap = spufs_signal1_mmap,
1185 .llseek = no_llseek,
1176}; 1186};
1177 1187
1178static int spufs_signal2_open(struct inode *inode, struct file *file) 1188static int spufs_signal2_open(struct inode *inode, struct file *file)
@@ -1305,6 +1315,7 @@ static const struct file_operations spufs_signal2_fops = {
1305 .read = spufs_signal2_read, 1315 .read = spufs_signal2_read,
1306 .write = spufs_signal2_write, 1316 .write = spufs_signal2_write,
1307 .mmap = spufs_signal2_mmap, 1317 .mmap = spufs_signal2_mmap,
1318 .llseek = no_llseek,
1308}; 1319};
1309 1320
1310static const struct file_operations spufs_signal2_nosched_fops = { 1321static const struct file_operations spufs_signal2_nosched_fops = {
@@ -1312,6 +1323,7 @@ static const struct file_operations spufs_signal2_nosched_fops = {
1312 .release = spufs_signal2_release, 1323 .release = spufs_signal2_release,
1313 .write = spufs_signal2_write, 1324 .write = spufs_signal2_write,
1314 .mmap = spufs_signal2_mmap, 1325 .mmap = spufs_signal2_mmap,
1326 .llseek = no_llseek,
1315}; 1327};
1316 1328
1317/* 1329/*
@@ -1451,6 +1463,7 @@ static const struct file_operations spufs_mss_fops = {
1451 .open = spufs_mss_open, 1463 .open = spufs_mss_open,
1452 .release = spufs_mss_release, 1464 .release = spufs_mss_release,
1453 .mmap = spufs_mss_mmap, 1465 .mmap = spufs_mss_mmap,
1466 .llseek = no_llseek,
1454}; 1467};
1455 1468
1456static int 1469static int
@@ -1508,6 +1521,7 @@ static const struct file_operations spufs_psmap_fops = {
1508 .open = spufs_psmap_open, 1521 .open = spufs_psmap_open,
1509 .release = spufs_psmap_release, 1522 .release = spufs_psmap_release,
1510 .mmap = spufs_psmap_mmap, 1523 .mmap = spufs_psmap_mmap,
1524 .llseek = no_llseek,
1511}; 1525};
1512 1526
1513 1527
@@ -1871,6 +1885,7 @@ static const struct file_operations spufs_mfc_fops = {
1871 .fsync = spufs_mfc_fsync, 1885 .fsync = spufs_mfc_fsync,
1872 .fasync = spufs_mfc_fasync, 1886 .fasync = spufs_mfc_fasync,
1873 .mmap = spufs_mfc_mmap, 1887 .mmap = spufs_mfc_mmap,
1888 .llseek = no_llseek,
1874}; 1889};
1875 1890
1876static int spufs_npc_set(void *data, u64 val) 1891static int spufs_npc_set(void *data, u64 val)
@@ -2246,6 +2261,7 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
2246static const struct file_operations spufs_dma_info_fops = { 2261static const struct file_operations spufs_dma_info_fops = {
2247 .open = spufs_info_open, 2262 .open = spufs_info_open,
2248 .read = spufs_dma_info_read, 2263 .read = spufs_dma_info_read,
2264 .llseek = no_llseek,
2249}; 2265};
2250 2266
2251static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx, 2267static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
@@ -2299,6 +2315,7 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
2299static const struct file_operations spufs_proxydma_info_fops = { 2315static const struct file_operations spufs_proxydma_info_fops = {
2300 .open = spufs_info_open, 2316 .open = spufs_info_open,
2301 .read = spufs_proxydma_info_read, 2317 .read = spufs_proxydma_info_read,
2318 .llseek = no_llseek,
2302}; 2319};
2303 2320
2304static int spufs_show_tid(struct seq_file *s, void *private) 2321static int spufs_show_tid(struct seq_file *s, void *private)
@@ -2585,6 +2602,7 @@ static const struct file_operations spufs_switch_log_fops = {
2585 .read = spufs_switch_log_read, 2602 .read = spufs_switch_log_read,
2586 .poll = spufs_switch_log_poll, 2603 .poll = spufs_switch_log_poll,
2587 .release = spufs_switch_log_release, 2604 .release = spufs_switch_log_release,
2605 .llseek = no_llseek,
2588}; 2606};
2589 2607
2590/** 2608/**
diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index ba3588f2d8e0..d3ceff04ffc7 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -74,8 +74,10 @@ void __init chrp_nvram_init(void)
74 return; 74 return;
75 75
76 nbytes_p = of_get_property(nvram, "#bytes", &proplen); 76 nbytes_p = of_get_property(nvram, "#bytes", &proplen);
77 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 77 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) {
78 of_node_put(nvram);
78 return; 79 return;
80 }
79 81
80 nvram_size = *nbytes_p; 82 nvram_size = *nbytes_p;
81 83
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
index 5cdcc7c8d973..649473a729b8 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -65,7 +65,7 @@ static int __init page_aligned(unsigned long x)
65 65
66void __init wii_memory_fixups(void) 66void __init wii_memory_fixups(void)
67{ 67{
68 struct memblock_property *p = memblock.memory.region; 68 struct memblock_region *p = memblock.memory.regions;
69 69
70 /* 70 /*
71 * This is part of a workaround to allow the use of two 71 * This is part of a workaround to allow the use of two
diff --git a/arch/powerpc/platforms/iseries/Makefile b/arch/powerpc/platforms/iseries/Makefile
index ce014928d460..a7602b11ed9d 100644
--- a/arch/powerpc/platforms/iseries/Makefile
+++ b/arch/powerpc/platforms/iseries/Makefile
@@ -1,4 +1,4 @@
1EXTRA_CFLAGS += -mno-minimal-toc 1ccflags-y := -mno-minimal-toc
2 2
3obj-y += exception.o 3obj-y += exception.o
4obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt.o mf.o lpevents.o \ 4obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt.o mf.o lpevents.o \
diff --git a/arch/powerpc/platforms/iseries/dt.c b/arch/powerpc/platforms/iseries/dt.c
index 7f45a51fe793..fdb7384c0c4f 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -243,7 +243,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt)
243 pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE); 243 pft_size[1] = __ilog2(HvCallHpt_getHptPages() * HW_PAGE_SIZE);
244 244
245 for (i = 0; i < NR_CPUS; i++) { 245 for (i = 0; i < NR_CPUS; i++) {
246 if (lppaca[i].dyn_proc_status >= 2) 246 if (lppaca_of(i).dyn_proc_status >= 2)
247 continue; 247 continue;
248 248
249 snprintf(p, 32 - (p - buf), "@%d", i); 249 snprintf(p, 32 - (p - buf), "@%d", i);
@@ -251,7 +251,7 @@ static void __init dt_cpus(struct iseries_flat_dt *dt)
251 251
252 dt_prop_str(dt, "device_type", device_type_cpu); 252 dt_prop_str(dt, "device_type", device_type_cpu);
253 253
254 index = lppaca[i].dyn_hv_phys_proc_index; 254 index = lppaca_of(i).dyn_hv_phys_proc_index;
255 d = &xIoHriProcessorVpd[index]; 255 d = &xIoHriProcessorVpd[index];
256 256
257 dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024); 257 dt_prop_u32(dt, "i-cache-size", d->xInstCacheSize * 1024);
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index 33e5fc7334fc..42d0a886de05 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -1249,6 +1249,7 @@ out:
1249 1249
1250static const struct file_operations proc_vmlinux_operations = { 1250static const struct file_operations proc_vmlinux_operations = {
1251 .write = proc_mf_change_vmlinux, 1251 .write = proc_mf_change_vmlinux,
1252 .llseek = default_llseek,
1252}; 1253};
1253 1254
1254static int __init mf_proc_init(void) 1255static int __init mf_proc_init(void)
diff --git a/arch/powerpc/platforms/iseries/smp.c b/arch/powerpc/platforms/iseries/smp.c
index 6590850045af..6c6029914dbc 100644
--- a/arch/powerpc/platforms/iseries/smp.c
+++ b/arch/powerpc/platforms/iseries/smp.c
@@ -91,7 +91,7 @@ static void smp_iSeries_kick_cpu(int nr)
91 BUG_ON((nr < 0) || (nr >= NR_CPUS)); 91 BUG_ON((nr < 0) || (nr >= NR_CPUS));
92 92
93 /* Verify that our partition has a processor nr */ 93 /* Verify that our partition has a processor nr */
94 if (lppaca[nr].dyn_proc_status >= 2) 94 if (lppaca_of(nr).dyn_proc_status >= 2)
95 return; 95 return;
96 96
97 /* The processor is currently spinning, waiting 97 /* The processor is currently spinning, waiting
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 3fff8d979b41..fe34c3d9bb74 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -358,6 +358,7 @@ static int __init maple_cpc925_edac_setup(void)
358 model = (const unsigned char *)of_get_property(np, "model", NULL); 358 model = (const unsigned char *)of_get_property(np, "model", NULL);
359 if (!model) { 359 if (!model) {
360 printk(KERN_ERR "%s: Unabel to get model info\n", __func__); 360 printk(KERN_ERR "%s: Unabel to get model info\n", __func__);
361 of_node_put(np);
361 return -ENODEV; 362 return -ENODEV;
362 } 363 }
363 364
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index cec635942657..b0c3777528a1 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -837,8 +837,10 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
837 return NULL; 837 return NULL;
838 find_it: 838 find_it:
839 dev = pmf_find_device(actor); 839 dev = pmf_find_device(actor);
840 if (dev == NULL) 840 if (dev == NULL) {
841 return NULL; 841 result = NULL;
842 goto out;
843 }
842 844
843 list_for_each_entry(func, &dev->functions, link) { 845 list_for_each_entry(func, &dev->functions, link) {
844 if (name && strcmp(name, func->name)) 846 if (name && strcmp(name, func->name))
@@ -850,8 +852,9 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
850 result = func; 852 result = func;
851 break; 853 break;
852 } 854 }
853 of_node_put(actor);
854 pmf_put_device(dev); 855 pmf_put_device(dev);
856out:
857 of_node_put(actor);
855 return result; 858 return result;
856} 859}
857 860
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 046ace9c4381..59eb8bdaa79d 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -1,14 +1,9 @@
1ifeq ($(CONFIG_PPC64),y) 1ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
2EXTRA_CFLAGS += -mno-minimal-toc 2ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
3endif
4
5ifeq ($(CONFIG_PPC_PSERIES_DEBUG),y)
6EXTRA_CFLAGS += -DDEBUG
7endif
8 3
9obj-y := lpar.o hvCall.o nvram.o reconfig.o \ 4obj-y := lpar.o hvCall.o nvram.o reconfig.o \
10 setup.o iommu.o event_sources.o ras.o \ 5 setup.o iommu.o event_sources.o ras.o \
11 firmware.o power.o dlpar.o 6 firmware.o power.o dlpar.o mobility.o
12obj-$(CONFIG_SMP) += smp.o 7obj-$(CONFIG_SMP) += smp.o
13obj-$(CONFIG_XICS) += xics.o 8obj-$(CONFIG_XICS) += xics.o
14obj-$(CONFIG_SCANLOG) += scanlog.o 9obj-$(CONFIG_SCANLOG) += scanlog.o
@@ -23,7 +18,7 @@ obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o
23obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o 18obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
24obj-$(CONFIG_HVCS) += hvcserver.o 19obj-$(CONFIG_HVCS) += hvcserver.o
25obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o 20obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
26obj-$(CONFIG_PHYP_DUMP) += phyp_dump.o 21obj-$(CONFIG_PHYP_DUMP) += phyp_dump.o
27obj-$(CONFIG_CMM) += cmm.o 22obj-$(CONFIG_CMM) += cmm.o
28obj-$(CONFIG_DTL) += dtl.o 23obj-$(CONFIG_DTL) += dtl.o
29 24
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 72d8054fa739..b74a9230edc9 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -33,7 +33,7 @@ struct cc_workarea {
33 u32 prop_offset; 33 u32 prop_offset;
34}; 34};
35 35
36static void dlpar_free_cc_property(struct property *prop) 36void dlpar_free_cc_property(struct property *prop)
37{ 37{
38 kfree(prop->name); 38 kfree(prop->name);
39 kfree(prop->value); 39 kfree(prop->value);
@@ -55,13 +55,12 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
55 55
56 prop->length = ccwa->prop_length; 56 prop->length = ccwa->prop_length;
57 value = (char *)ccwa + ccwa->prop_offset; 57 value = (char *)ccwa + ccwa->prop_offset;
58 prop->value = kzalloc(prop->length, GFP_KERNEL); 58 prop->value = kmemdup(value, prop->length, GFP_KERNEL);
59 if (!prop->value) { 59 if (!prop->value) {
60 dlpar_free_cc_property(prop); 60 dlpar_free_cc_property(prop);
61 return NULL; 61 return NULL;
62 } 62 }
63 63
64 memcpy(prop->value, value, prop->length);
65 return prop; 64 return prop;
66} 65}
67 66
@@ -102,7 +101,7 @@ static void dlpar_free_one_cc_node(struct device_node *dn)
102 kfree(dn); 101 kfree(dn);
103} 102}
104 103
105static void dlpar_free_cc_nodes(struct device_node *dn) 104void dlpar_free_cc_nodes(struct device_node *dn)
106{ 105{
107 if (dn->child) 106 if (dn->child)
108 dlpar_free_cc_nodes(dn->child); 107 dlpar_free_cc_nodes(dn->child);
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index a00addb55945..c371bc06434b 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -23,37 +23,22 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/debugfs.h> 25#include <linux/debugfs.h>
26#include <linux/spinlock.h>
26#include <asm/smp.h> 27#include <asm/smp.h>
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/firmware.h> 30#include <asm/firmware.h>
31#include <asm/lppaca.h>
30 32
31#include "plpar_wrappers.h" 33#include "plpar_wrappers.h"
32 34
33/*
34 * Layout of entries in the hypervisor's DTL buffer. Although we don't
35 * actually access the internals of an entry (we only need to know the size),
36 * we might as well define it here for reference.
37 */
38struct dtl_entry {
39 u8 dispatch_reason;
40 u8 preempt_reason;
41 u16 processor_id;
42 u32 enqueue_to_dispatch_time;
43 u32 ready_to_enqueue_time;
44 u32 waiting_to_ready_time;
45 u64 timebase;
46 u64 fault_addr;
47 u64 srr0;
48 u64 srr1;
49};
50
51struct dtl { 35struct dtl {
52 struct dtl_entry *buf; 36 struct dtl_entry *buf;
53 struct dentry *file; 37 struct dentry *file;
54 int cpu; 38 int cpu;
55 int buf_entries; 39 int buf_entries;
56 u64 last_idx; 40 u64 last_idx;
41 spinlock_t lock;
57}; 42};
58static DEFINE_PER_CPU(struct dtl, cpu_dtl); 43static DEFINE_PER_CPU(struct dtl, cpu_dtl);
59 44
@@ -72,25 +57,97 @@ static u8 dtl_event_mask = 0x7;
72static int dtl_buf_entries = (16 * 85); 57static int dtl_buf_entries = (16 * 85);
73 58
74 59
75static int dtl_enable(struct dtl *dtl) 60#ifdef CONFIG_VIRT_CPU_ACCOUNTING
61struct dtl_ring {
62 u64 write_index;
63 struct dtl_entry *write_ptr;
64 struct dtl_entry *buf;
65 struct dtl_entry *buf_end;
66 u8 saved_dtl_mask;
67};
68
69static DEFINE_PER_CPU(struct dtl_ring, dtl_rings);
70
71static atomic_t dtl_count;
72
73/*
74 * The cpu accounting code controls the DTL ring buffer, and we get
75 * given entries as they are processed.
76 */
77static void consume_dtle(struct dtl_entry *dtle, u64 index)
76{ 78{
77 unsigned long addr; 79 struct dtl_ring *dtlr = &__get_cpu_var(dtl_rings);
78 int ret, hwcpu; 80 struct dtl_entry *wp = dtlr->write_ptr;
81 struct lppaca *vpa = local_paca->lppaca_ptr;
79 82
80 /* only allow one reader */ 83 if (!wp)
81 if (dtl->buf) 84 return;
82 return -EBUSY;
83 85
84 /* we need to store the original allocation size for use during read */ 86 *wp = *dtle;
85 dtl->buf_entries = dtl_buf_entries; 87 barrier();
86 88
87 dtl->buf = kmalloc_node(dtl->buf_entries * sizeof(struct dtl_entry), 89 /* check for hypervisor ring buffer overflow, ignore this entry if so */
88 GFP_KERNEL, cpu_to_node(dtl->cpu)); 90 if (index + N_DISPATCH_LOG < vpa->dtl_idx)
89 if (!dtl->buf) { 91 return;
90 printk(KERN_WARNING "%s: buffer alloc failed for cpu %d\n", 92
91 __func__, dtl->cpu); 93 ++wp;
92 return -ENOMEM; 94 if (wp == dtlr->buf_end)
93 } 95 wp = dtlr->buf;
96 dtlr->write_ptr = wp;
97
98 /* incrementing write_index makes the new entry visible */
99 smp_wmb();
100 ++dtlr->write_index;
101}
102
103static int dtl_start(struct dtl *dtl)
104{
105 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
106
107 dtlr->buf = dtl->buf;
108 dtlr->buf_end = dtl->buf + dtl->buf_entries;
109 dtlr->write_index = 0;
110
111 /* setting write_ptr enables logging into our buffer */
112 smp_wmb();
113 dtlr->write_ptr = dtl->buf;
114
115 /* enable event logging */
116 dtlr->saved_dtl_mask = lppaca_of(dtl->cpu).dtl_enable_mask;
117 lppaca_of(dtl->cpu).dtl_enable_mask |= dtl_event_mask;
118
119 dtl_consumer = consume_dtle;
120 atomic_inc(&dtl_count);
121 return 0;
122}
123
124static void dtl_stop(struct dtl *dtl)
125{
126 struct dtl_ring *dtlr = &per_cpu(dtl_rings, dtl->cpu);
127
128 dtlr->write_ptr = NULL;
129 smp_wmb();
130
131 dtlr->buf = NULL;
132
133 /* restore dtl_enable_mask */
134 lppaca_of(dtl->cpu).dtl_enable_mask = dtlr->saved_dtl_mask;
135
136 if (atomic_dec_and_test(&dtl_count))
137 dtl_consumer = NULL;
138}
139
140static u64 dtl_current_index(struct dtl *dtl)
141{
142 return per_cpu(dtl_rings, dtl->cpu).write_index;
143}
144
145#else /* CONFIG_VIRT_CPU_ACCOUNTING */
146
147static int dtl_start(struct dtl *dtl)
148{
149 unsigned long addr;
150 int ret, hwcpu;
94 151
95 /* Register our dtl buffer with the hypervisor. The HV expects the 152 /* Register our dtl buffer with the hypervisor. The HV expects the
96 * buffer size to be passed in the second word of the buffer */ 153 * buffer size to be passed in the second word of the buffer */
@@ -102,34 +159,82 @@ static int dtl_enable(struct dtl *dtl)
102 if (ret) { 159 if (ret) {
103 printk(KERN_WARNING "%s: DTL registration for cpu %d (hw %d) " 160 printk(KERN_WARNING "%s: DTL registration for cpu %d (hw %d) "
104 "failed with %d\n", __func__, dtl->cpu, hwcpu, ret); 161 "failed with %d\n", __func__, dtl->cpu, hwcpu, ret);
105 kfree(dtl->buf);
106 return -EIO; 162 return -EIO;
107 } 163 }
108 164
109 /* set our initial buffer indices */ 165 /* set our initial buffer indices */
110 dtl->last_idx = lppaca[dtl->cpu].dtl_idx = 0; 166 lppaca_of(dtl->cpu).dtl_idx = 0;
111 167
112 /* ensure that our updates to the lppaca fields have occurred before 168 /* ensure that our updates to the lppaca fields have occurred before
113 * we actually enable the logging */ 169 * we actually enable the logging */
114 smp_wmb(); 170 smp_wmb();
115 171
116 /* enable event logging */ 172 /* enable event logging */
117 lppaca[dtl->cpu].dtl_enable_mask = dtl_event_mask; 173 lppaca_of(dtl->cpu).dtl_enable_mask = dtl_event_mask;
118 174
119 return 0; 175 return 0;
120} 176}
121 177
122static void dtl_disable(struct dtl *dtl) 178static void dtl_stop(struct dtl *dtl)
123{ 179{
124 int hwcpu = get_hard_smp_processor_id(dtl->cpu); 180 int hwcpu = get_hard_smp_processor_id(dtl->cpu);
125 181
126 lppaca[dtl->cpu].dtl_enable_mask = 0x0; 182 lppaca_of(dtl->cpu).dtl_enable_mask = 0x0;
127 183
128 unregister_dtl(hwcpu, __pa(dtl->buf)); 184 unregister_dtl(hwcpu, __pa(dtl->buf));
185}
186
187static u64 dtl_current_index(struct dtl *dtl)
188{
189 return lppaca_of(dtl->cpu).dtl_idx;
190}
191#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
192
193static int dtl_enable(struct dtl *dtl)
194{
195 long int n_entries;
196 long int rc;
197 struct dtl_entry *buf = NULL;
129 198
199 /* only allow one reader */
200 if (dtl->buf)
201 return -EBUSY;
202
203 n_entries = dtl_buf_entries;
204 buf = kmalloc_node(n_entries * sizeof(struct dtl_entry),
205 GFP_KERNEL, cpu_to_node(dtl->cpu));
206 if (!buf) {
207 printk(KERN_WARNING "%s: buffer alloc failed for cpu %d\n",
208 __func__, dtl->cpu);
209 return -ENOMEM;
210 }
211
212 spin_lock(&dtl->lock);
213 rc = -EBUSY;
214 if (!dtl->buf) {
215 /* store the original allocation size for use during read */
216 dtl->buf_entries = n_entries;
217 dtl->buf = buf;
218 dtl->last_idx = 0;
219 rc = dtl_start(dtl);
220 if (rc)
221 dtl->buf = NULL;
222 }
223 spin_unlock(&dtl->lock);
224
225 if (rc)
226 kfree(buf);
227 return rc;
228}
229
230static void dtl_disable(struct dtl *dtl)
231{
232 spin_lock(&dtl->lock);
233 dtl_stop(dtl);
130 kfree(dtl->buf); 234 kfree(dtl->buf);
131 dtl->buf = NULL; 235 dtl->buf = NULL;
132 dtl->buf_entries = 0; 236 dtl->buf_entries = 0;
237 spin_unlock(&dtl->lock);
133} 238}
134 239
135/* file interface */ 240/* file interface */
@@ -157,8 +262,9 @@ static int dtl_file_release(struct inode *inode, struct file *filp)
157static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len, 262static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
158 loff_t *pos) 263 loff_t *pos)
159{ 264{
160 int rc, cur_idx, last_idx, n_read, n_req, read_size; 265 long int rc, n_read, n_req, read_size;
161 struct dtl *dtl; 266 struct dtl *dtl;
267 u64 cur_idx, last_idx, i;
162 268
163 if ((len % sizeof(struct dtl_entry)) != 0) 269 if ((len % sizeof(struct dtl_entry)) != 0)
164 return -EINVAL; 270 return -EINVAL;
@@ -171,41 +277,48 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
171 /* actual number of entries read */ 277 /* actual number of entries read */
172 n_read = 0; 278 n_read = 0;
173 279
174 cur_idx = lppaca[dtl->cpu].dtl_idx; 280 spin_lock(&dtl->lock);
281
282 cur_idx = dtl_current_index(dtl);
175 last_idx = dtl->last_idx; 283 last_idx = dtl->last_idx;
176 284
177 if (cur_idx - last_idx > dtl->buf_entries) { 285 if (last_idx + dtl->buf_entries <= cur_idx)
178 pr_debug("%s: hv buffer overflow for cpu %d, samples lost\n", 286 last_idx = cur_idx - dtl->buf_entries + 1;
179 __func__, dtl->cpu); 287
180 } 288 if (last_idx + n_req > cur_idx)
289 n_req = cur_idx - last_idx;
290
291 if (n_req > 0)
292 dtl->last_idx = last_idx + n_req;
293
294 spin_unlock(&dtl->lock);
295
296 if (n_req <= 0)
297 return 0;
181 298
182 cur_idx %= dtl->buf_entries; 299 i = last_idx % dtl->buf_entries;
183 last_idx %= dtl->buf_entries;
184 300
185 /* read the tail of the buffer if we've wrapped */ 301 /* read the tail of the buffer if we've wrapped */
186 if (last_idx > cur_idx) { 302 if (i + n_req > dtl->buf_entries) {
187 read_size = min(n_req, dtl->buf_entries - last_idx); 303 read_size = dtl->buf_entries - i;
188 304
189 rc = copy_to_user(buf, &dtl->buf[last_idx], 305 rc = copy_to_user(buf, &dtl->buf[i],
190 read_size * sizeof(struct dtl_entry)); 306 read_size * sizeof(struct dtl_entry));
191 if (rc) 307 if (rc)
192 return -EFAULT; 308 return -EFAULT;
193 309
194 last_idx = 0; 310 i = 0;
195 n_req -= read_size; 311 n_req -= read_size;
196 n_read += read_size; 312 n_read += read_size;
197 buf += read_size * sizeof(struct dtl_entry); 313 buf += read_size * sizeof(struct dtl_entry);
198 } 314 }
199 315
200 /* .. and now the head */ 316 /* .. and now the head */
201 read_size = min(n_req, cur_idx - last_idx); 317 rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry));
202 rc = copy_to_user(buf, &dtl->buf[last_idx],
203 read_size * sizeof(struct dtl_entry));
204 if (rc) 318 if (rc)
205 return -EFAULT; 319 return -EFAULT;
206 320
207 n_read += read_size; 321 n_read += n_req;
208 dtl->last_idx += n_read;
209 322
210 return n_read * sizeof(struct dtl_entry); 323 return n_read * sizeof(struct dtl_entry);
211} 324}
@@ -263,6 +376,7 @@ static int dtl_init(void)
263 /* set up the per-cpu log structures */ 376 /* set up the per-cpu log structures */
264 for_each_possible_cpu(i) { 377 for_each_possible_cpu(i) {
265 struct dtl *dtl = &per_cpu(cpu_dtl, i); 378 struct dtl *dtl = &per_cpu(cpu_dtl, i);
379 spin_lock_init(&dtl->lock);
266 dtl->cpu = i; 380 dtl->cpu = i;
267 381
268 rc = dtl_setup_file(dtl); 382 rc = dtl_setup_file(dtl);
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index cf79b46d8f88..f129040d974c 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -248,11 +248,13 @@ void vpa_init(int cpu)
248 int hwcpu = get_hard_smp_processor_id(cpu); 248 int hwcpu = get_hard_smp_processor_id(cpu);
249 unsigned long addr; 249 unsigned long addr;
250 long ret; 250 long ret;
251 struct paca_struct *pp;
252 struct dtl_entry *dtl;
251 253
252 if (cpu_has_feature(CPU_FTR_ALTIVEC)) 254 if (cpu_has_feature(CPU_FTR_ALTIVEC))
253 lppaca[cpu].vmxregs_in_use = 1; 255 lppaca_of(cpu).vmxregs_in_use = 1;
254 256
255 addr = __pa(&lppaca[cpu]); 257 addr = __pa(&lppaca_of(cpu));
256 ret = register_vpa(hwcpu, addr); 258 ret = register_vpa(hwcpu, addr);
257 259
258 if (ret) { 260 if (ret) {
@@ -274,6 +276,25 @@ void vpa_init(int cpu)
274 "registration for cpu %d (hw %d) of area %lx " 276 "registration for cpu %d (hw %d) of area %lx "
275 "returns %ld\n", cpu, hwcpu, addr, ret); 277 "returns %ld\n", cpu, hwcpu, addr, ret);
276 } 278 }
279
280 /*
281 * Register dispatch trace log, if one has been allocated.
282 */
283 pp = &paca[cpu];
284 dtl = pp->dispatch_log;
285 if (dtl) {
286 pp->dtl_ridx = 0;
287 pp->dtl_curr = dtl;
288 lppaca_of(cpu).dtl_idx = 0;
289
290 /* hypervisor reads buffer length from this field */
291 dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES;
292 ret = register_dtl(hwcpu, __pa(dtl));
293 if (ret)
294 pr_warn("DTL registration failed for cpu %d (%ld)\n",
295 cpu, ret);
296 lppaca_of(cpu).dtl_enable_mask = 2;
297 }
277} 298}
278 299
279static long pSeries_lpar_hpte_insert(unsigned long hpte_group, 300static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
new file mode 100644
index 000000000000..3e7f651e50ac
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -0,0 +1,362 @@
1/*
2 * Support for Partition Mobility/Migration
3 *
4 * Copyright (C) 2010 Nathan Fontenot
5 * Copyright (C) 2010 IBM Corporation
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/kobject.h>
14#include <linux/smp.h>
15#include <linux/completion.h>
16#include <linux/device.h>
17#include <linux/delay.h>
18#include <linux/slab.h>
19
20#include <asm/rtas.h>
21#include "pseries.h"
22
23static struct kobject *mobility_kobj;
24
25struct update_props_workarea {
26 u32 phandle;
27 u32 state;
28 u64 reserved;
29 u32 nprops;
30};
31
32#define NODE_ACTION_MASK 0xff000000
33#define NODE_COUNT_MASK 0x00ffffff
34
35#define DELETE_DT_NODE 0x01000000
36#define UPDATE_DT_NODE 0x02000000
37#define ADD_DT_NODE 0x03000000
38
39static int mobility_rtas_call(int token, char *buf)
40{
41 int rc;
42
43 spin_lock(&rtas_data_buf_lock);
44
45 memcpy(rtas_data_buf, buf, RTAS_DATA_BUF_SIZE);
46 rc = rtas_call(token, 2, 1, NULL, rtas_data_buf, 1);
47 memcpy(buf, rtas_data_buf, RTAS_DATA_BUF_SIZE);
48
49 spin_unlock(&rtas_data_buf_lock);
50 return rc;
51}
52
53static int delete_dt_node(u32 phandle)
54{
55 struct device_node *dn;
56
57 dn = of_find_node_by_phandle(phandle);
58 if (!dn)
59 return -ENOENT;
60
61 dlpar_detach_node(dn);
62 return 0;
63}
64
65static int update_dt_property(struct device_node *dn, struct property **prop,
66 const char *name, u32 vd, char *value)
67{
68 struct property *new_prop = *prop;
69 struct property *old_prop;
70 int more = 0;
71
72 /* A negative 'vd' value indicates that only part of the new property
73 * value is contained in the buffer and we need to call
74 * ibm,update-properties again to get the rest of the value.
75 *
76 * A negative value is also the two's compliment of the actual value.
77 */
78 if (vd & 0x80000000) {
79 vd = ~vd + 1;
80 more = 1;
81 }
82
83 if (new_prop) {
84 /* partial property fixup */
85 char *new_data = kzalloc(new_prop->length + vd, GFP_KERNEL);
86 if (!new_data)
87 return -ENOMEM;
88
89 memcpy(new_data, new_prop->value, new_prop->length);
90 memcpy(new_data + new_prop->length, value, vd);
91
92 kfree(new_prop->value);
93 new_prop->value = new_data;
94 new_prop->length += vd;
95 } else {
96 new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
97 if (!new_prop)
98 return -ENOMEM;
99
100 new_prop->name = kstrdup(name, GFP_KERNEL);
101 if (!new_prop->name) {
102 kfree(new_prop);
103 return -ENOMEM;
104 }
105
106 new_prop->length = vd;
107 new_prop->value = kzalloc(new_prop->length, GFP_KERNEL);
108 if (!new_prop->value) {
109 kfree(new_prop->name);
110 kfree(new_prop);
111 return -ENOMEM;
112 }
113
114 memcpy(new_prop->value, value, vd);
115 *prop = new_prop;
116 }
117
118 if (!more) {
119 old_prop = of_find_property(dn, new_prop->name, NULL);
120 if (old_prop)
121 prom_update_property(dn, new_prop, old_prop);
122 else
123 prom_add_property(dn, new_prop);
124
125 new_prop = NULL;
126 }
127
128 return 0;
129}
130
131static int update_dt_node(u32 phandle)
132{
133 struct update_props_workarea *upwa;
134 struct device_node *dn;
135 struct property *prop = NULL;
136 int i, rc;
137 char *prop_data;
138 char *rtas_buf;
139 int update_properties_token;
140
141 update_properties_token = rtas_token("ibm,update-properties");
142 if (update_properties_token == RTAS_UNKNOWN_SERVICE)
143 return -EINVAL;
144
145 rtas_buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
146 if (!rtas_buf)
147 return -ENOMEM;
148
149 dn = of_find_node_by_phandle(phandle);
150 if (!dn) {
151 kfree(rtas_buf);
152 return -ENOENT;
153 }
154
155 upwa = (struct update_props_workarea *)&rtas_buf[0];
156 upwa->phandle = phandle;
157
158 do {
159 rc = mobility_rtas_call(update_properties_token, rtas_buf);
160 if (rc < 0)
161 break;
162
163 prop_data = rtas_buf + sizeof(*upwa);
164
165 for (i = 0; i < upwa->nprops; i++) {
166 char *prop_name;
167 u32 vd;
168
169 prop_name = prop_data + 1;
170 prop_data += strlen(prop_name) + 1;
171 vd = *prop_data++;
172
173 switch (vd) {
174 case 0x00000000:
175 /* name only property, nothing to do */
176 break;
177
178 case 0x80000000:
179 prop = of_find_property(dn, prop_name, NULL);
180 prom_remove_property(dn, prop);
181 prop = NULL;
182 break;
183
184 default:
185 rc = update_dt_property(dn, &prop, prop_name,
186 vd, prop_data);
187 if (rc) {
188 printk(KERN_ERR "Could not update %s"
189 " property\n", prop_name);
190 }
191
192 prop_data += vd;
193 }
194 }
195 } while (rc == 1);
196
197 of_node_put(dn);
198 kfree(rtas_buf);
199 return 0;
200}
201
202static int add_dt_node(u32 parent_phandle, u32 drc_index)
203{
204 struct device_node *dn;
205 struct device_node *parent_dn;
206 int rc;
207
208 dn = dlpar_configure_connector(drc_index);
209 if (!dn)
210 return -ENOENT;
211
212 parent_dn = of_find_node_by_phandle(parent_phandle);
213 if (!parent_dn) {
214 dlpar_free_cc_nodes(dn);
215 return -ENOENT;
216 }
217
218 dn->parent = parent_dn;
219 rc = dlpar_attach_node(dn);
220 if (rc)
221 dlpar_free_cc_nodes(dn);
222
223 of_node_put(parent_dn);
224 return rc;
225}
226
227static int pseries_devicetree_update(void)
228{
229 char *rtas_buf;
230 u32 *data;
231 int update_nodes_token;
232 int rc;
233
234 update_nodes_token = rtas_token("ibm,update-nodes");
235 if (update_nodes_token == RTAS_UNKNOWN_SERVICE)
236 return -EINVAL;
237
238 rtas_buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
239 if (!rtas_buf)
240 return -ENOMEM;
241
242 do {
243 rc = mobility_rtas_call(update_nodes_token, rtas_buf);
244 if (rc && rc != 1)
245 break;
246
247 data = (u32 *)rtas_buf + 4;
248 while (*data & NODE_ACTION_MASK) {
249 int i;
250 u32 action = *data & NODE_ACTION_MASK;
251 int node_count = *data & NODE_COUNT_MASK;
252
253 data++;
254
255 for (i = 0; i < node_count; i++) {
256 u32 phandle = *data++;
257 u32 drc_index;
258
259 switch (action) {
260 case DELETE_DT_NODE:
261 delete_dt_node(phandle);
262 break;
263 case UPDATE_DT_NODE:
264 update_dt_node(phandle);
265 break;
266 case ADD_DT_NODE:
267 drc_index = *data++;
268 add_dt_node(phandle, drc_index);
269 break;
270 }
271 }
272 }
273 } while (rc == 1);
274
275 kfree(rtas_buf);
276 return rc;
277}
278
279void post_mobility_fixup(void)
280{
281 int rc;
282 int activate_fw_token;
283
284 rc = pseries_devicetree_update();
285 if (rc) {
286 printk(KERN_ERR "Initial post-mobility device tree update "
287 "failed: %d\n", rc);
288 return;
289 }
290
291 activate_fw_token = rtas_token("ibm,activate-firmware");
292 if (activate_fw_token == RTAS_UNKNOWN_SERVICE) {
293 printk(KERN_ERR "Could not make post-mobility "
294 "activate-fw call.\n");
295 return;
296 }
297
298 rc = rtas_call(activate_fw_token, 0, 1, NULL);
299 if (!rc) {
300 rc = pseries_devicetree_update();
301 if (rc)
302 printk(KERN_ERR "Secondary post-mobility device tree "
303 "update failed: %d\n", rc);
304 } else {
305 printk(KERN_ERR "Post-mobility activate-fw failed: %d\n", rc);
306 return;
307 }
308
309 return;
310}
311
312static ssize_t migrate_store(struct class *class, struct class_attribute *attr,
313 const char *buf, size_t count)
314{
315 struct rtas_args args;
316 u64 streamid;
317 int rc;
318
319 rc = strict_strtoull(buf, 0, &streamid);
320 if (rc)
321 return rc;
322
323 memset(&args, 0, sizeof(args));
324 args.token = rtas_token("ibm,suspend-me");
325 args.nargs = 2;
326 args.nret = 1;
327
328 args.args[0] = streamid >> 32 ;
329 args.args[1] = streamid & 0xffffffff;
330 args.rets = &args.args[args.nargs];
331
332 do {
333 args.rets[0] = 0;
334 rc = rtas_ibm_suspend_me(&args);
335 if (!rc && args.rets[0] == RTAS_NOT_SUSPENDABLE)
336 ssleep(1);
337 } while (!rc && args.rets[0] == RTAS_NOT_SUSPENDABLE);
338
339 if (rc)
340 return rc;
341 else if (args.rets[0])
342 return args.rets[0];
343
344 post_mobility_fixup();
345 return count;
346}
347
348static CLASS_ATTR(migration, S_IWUSR, NULL, migrate_store);
349
350static int __init mobility_sysfs_init(void)
351{
352 int rc;
353
354 mobility_kobj = kobject_create_and_add("mobility", kernel_kobj);
355 if (!mobility_kobj)
356 return -ENOMEM;
357
358 rc = sysfs_create_file(mobility_kobj, &class_attr_migration.attr);
359
360 return rc;
361}
362device_initcall(mobility_sysfs_init);
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 40c93cad91d2..e9f6d2859c3c 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -17,6 +17,8 @@ struct device_node;
17extern void request_event_sources_irqs(struct device_node *np, 17extern void request_event_sources_irqs(struct device_node *np,
18 irq_handler_t handler, const char *name); 18 irq_handler_t handler, const char *name);
19 19
20#include <linux/of.h>
21
20extern void __init fw_feature_init(const char *hypertas, unsigned long len); 22extern void __init fw_feature_init(const char *hypertas, unsigned long len);
21 23
22struct pt_regs; 24struct pt_regs;
@@ -47,4 +49,11 @@ extern unsigned long rtas_poweron_auto;
47 49
48extern void find_udbg_vterm(void); 50extern void find_udbg_vterm(void);
49 51
52/* Dynamic logical Partitioning/Mobility */
53extern void dlpar_free_cc_nodes(struct device_node *);
54extern void dlpar_free_cc_property(struct property *);
55extern struct device_node *dlpar_configure_connector(u32);
56extern int dlpar_attach_node(struct device_node *);
57extern int dlpar_detach_node(struct device_node *);
58
50#endif /* _PSERIES_PSERIES_H */ 59#endif /* _PSERIES_PSERIES_H */
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 57ddbb43b33a..1de2cbb92303 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -539,7 +539,8 @@ out:
539} 539}
540 540
541static const struct file_operations ofdt_fops = { 541static const struct file_operations ofdt_fops = {
542 .write = ofdt_write 542 .write = ofdt_write,
543 .llseek = noop_llseek,
543}; 544};
544 545
545/* create /proc/powerpc/ofdt write-only by root */ 546/* create /proc/powerpc/ofdt write-only by root */
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index 80e9e7652a4d..554457294a2b 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -170,6 +170,7 @@ const struct file_operations scanlog_fops = {
170 .write = scanlog_write, 170 .write = scanlog_write,
171 .open = scanlog_open, 171 .open = scanlog_open,
172 .release = scanlog_release, 172 .release = scanlog_release,
173 .llseek = noop_llseek,
173}; 174};
174 175
175static int __init scanlog_init(void) 176static int __init scanlog_init(void)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index a6d19e3a505e..d345bfd56bbe 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -273,6 +273,58 @@ static struct notifier_block pci_dn_reconfig_nb = {
273 .notifier_call = pci_dn_reconfig_notifier, 273 .notifier_call = pci_dn_reconfig_notifier,
274}; 274};
275 275
276#ifdef CONFIG_VIRT_CPU_ACCOUNTING
277/*
278 * Allocate space for the dispatch trace log for all possible cpus
279 * and register the buffers with the hypervisor. This is used for
280 * computing time stolen by the hypervisor.
281 */
282static int alloc_dispatch_logs(void)
283{
284 int cpu, ret;
285 struct paca_struct *pp;
286 struct dtl_entry *dtl;
287
288 if (!firmware_has_feature(FW_FEATURE_SPLPAR))
289 return 0;
290
291 for_each_possible_cpu(cpu) {
292 pp = &paca[cpu];
293 dtl = kmalloc_node(DISPATCH_LOG_BYTES, GFP_KERNEL,
294 cpu_to_node(cpu));
295 if (!dtl) {
296 pr_warn("Failed to allocate dispatch trace log for cpu %d\n",
297 cpu);
298 pr_warn("Stolen time statistics will be unreliable\n");
299 break;
300 }
301
302 pp->dtl_ridx = 0;
303 pp->dispatch_log = dtl;
304 pp->dispatch_log_end = dtl + N_DISPATCH_LOG;
305 pp->dtl_curr = dtl;
306 }
307
308 /* Register the DTL for the current (boot) cpu */
309 dtl = get_paca()->dispatch_log;
310 get_paca()->dtl_ridx = 0;
311 get_paca()->dtl_curr = dtl;
312 get_paca()->lppaca_ptr->dtl_idx = 0;
313
314 /* hypervisor reads buffer length from this field */
315 dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES;
316 ret = register_dtl(hard_smp_processor_id(), __pa(dtl));
317 if (ret)
318 pr_warn("DTL registration failed for boot cpu %d (%d)\n",
319 smp_processor_id(), ret);
320 get_paca()->lppaca_ptr->dtl_enable_mask = 2;
321
322 return 0;
323}
324
325early_initcall(alloc_dispatch_logs);
326#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
327
276static void __init pSeries_setup_arch(void) 328static void __init pSeries_setup_arch(void)
277{ 329{
278 /* Discover PIC type and setup ppc_md accordingly */ 330 /* Discover PIC type and setup ppc_md accordingly */
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index 93834b0d8272..7b96e5a270ce 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -178,7 +178,7 @@ static int get_irq_server(unsigned int virq, const struct cpumask *cpumask,
178 if (!distribute_irqs) 178 if (!distribute_irqs)
179 return default_server; 179 return default_server;
180 180
181 if (!cpumask_equal(cpumask, cpu_all_mask)) { 181 if (!cpumask_subset(cpu_possible_mask, cpumask)) {
182 int server = cpumask_first_and(cpu_online_mask, cpumask); 182 int server = cpumask_first_and(cpu_online_mask, cpumask);
183 183
184 if (server < nr_cpu_ids) 184 if (server < nr_cpu_ids)
@@ -243,7 +243,7 @@ static unsigned int xics_startup(unsigned int virq)
243 * at that level, so we do it here by hand. 243 * at that level, so we do it here by hand.
244 */ 244 */
245 if (irq_to_desc(virq)->msi_desc) 245 if (irq_to_desc(virq)->msi_desc)
246 unmask_msi_irq(virq); 246 unmask_msi_irq(irq_get_irq_data(virq));
247 247
248 /* unmask it */ 248 /* unmask it */
249 xics_unmask_irq(virq); 249 xics_unmask_irq(virq);
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 5642924fb9fb..0bef9dacb64e 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -1,8 +1,6 @@
1subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 1subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
2 2
3ifeq ($(CONFIG_PPC64),y) 3ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
4EXTRA_CFLAGS += -mno-minimal-toc
5endif
6 4
7mpic-msi-obj-$(CONFIG_PCI_MSI) += mpic_msi.o mpic_u3msi.o mpic_pasemi_msi.o 5mpic-msi-obj-$(CONFIG_PCI_MSI) += mpic_msi.o mpic_u3msi.o mpic_pasemi_msi.o
8obj-$(CONFIG_MPIC) += mpic.o $(mpic-msi-obj-y) 6obj-$(CONFIG_MPIC) += mpic.o $(mpic-msi-obj-y)
@@ -20,6 +18,7 @@ obj-$(CONFIG_FSL_PMC) += fsl_pmc.o
20obj-$(CONFIG_FSL_LBC) += fsl_lbc.o 18obj-$(CONFIG_FSL_LBC) += fsl_lbc.o
21obj-$(CONFIG_FSL_GTM) += fsl_gtm.o 19obj-$(CONFIG_FSL_GTM) += fsl_gtm.o
22obj-$(CONFIG_MPC8xxx_GPIO) += mpc8xxx_gpio.o 20obj-$(CONFIG_MPC8xxx_GPIO) += mpc8xxx_gpio.o
21obj-$(CONFIG_FSL_85XX_CACHE_SRAM) += fsl_85xx_l2ctlr.o fsl_85xx_cache_sram.o
23obj-$(CONFIG_SIMPLE_GPIO) += simple_gpio.o 22obj-$(CONFIG_SIMPLE_GPIO) += simple_gpio.o
24obj-$(CONFIG_RAPIDIO) += fsl_rio.o 23obj-$(CONFIG_RAPIDIO) += fsl_rio.o
25obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o 24obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 559db2b846a9..17cf15ec38be 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -70,6 +70,8 @@ static int iommu_table_dart_inited;
70static int dart_dirty; 70static int dart_dirty;
71static int dart_is_u4; 71static int dart_is_u4;
72 72
73#define DART_U4_BYPASS_BASE 0x8000000000ull
74
73#define DBG(...) 75#define DBG(...)
74 76
75static inline void dart_tlb_invalidate_all(void) 77static inline void dart_tlb_invalidate_all(void)
@@ -292,12 +294,20 @@ static void iommu_table_dart_setup(void)
292 set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map); 294 set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map);
293} 295}
294 296
295static void pci_dma_dev_setup_dart(struct pci_dev *dev) 297static void dma_dev_setup_dart(struct device *dev)
296{ 298{
297 /* We only have one iommu table on the mac for now, which makes 299 /* We only have one iommu table on the mac for now, which makes
298 * things simple. Setup all PCI devices to point to this table 300 * things simple. Setup all PCI devices to point to this table
299 */ 301 */
300 set_iommu_table_base(&dev->dev, &iommu_table_dart); 302 if (get_dma_ops(dev) == &dma_direct_ops)
303 set_dma_offset(dev, DART_U4_BYPASS_BASE);
304 else
305 set_iommu_table_base(dev, &iommu_table_dart);
306}
307
308static void pci_dma_dev_setup_dart(struct pci_dev *dev)
309{
310 dma_dev_setup_dart(&dev->dev);
301} 311}
302 312
303static void pci_dma_bus_setup_dart(struct pci_bus *bus) 313static void pci_dma_bus_setup_dart(struct pci_bus *bus)
@@ -315,6 +325,45 @@ static void pci_dma_bus_setup_dart(struct pci_bus *bus)
315 PCI_DN(dn)->iommu_table = &iommu_table_dart; 325 PCI_DN(dn)->iommu_table = &iommu_table_dart;
316} 326}
317 327
328static bool dart_device_on_pcie(struct device *dev)
329{
330 struct device_node *np = of_node_get(dev->of_node);
331
332 while(np) {
333 if (of_device_is_compatible(np, "U4-pcie") ||
334 of_device_is_compatible(np, "u4-pcie")) {
335 of_node_put(np);
336 return true;
337 }
338 np = of_get_next_parent(np);
339 }
340 return false;
341}
342
343static int dart_dma_set_mask(struct device *dev, u64 dma_mask)
344{
345 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
346 return -EIO;
347
348 /* U4 supports a DART bypass, we use it for 64-bit capable
349 * devices to improve performances. However, that only works
350 * for devices connected to U4 own PCIe interface, not bridged
351 * through hypertransport. We need the device to support at
352 * least 40 bits of addresses.
353 */
354 if (dart_device_on_pcie(dev) && dma_mask >= DMA_BIT_MASK(40)) {
355 dev_info(dev, "Using 64-bit DMA iommu bypass\n");
356 set_dma_ops(dev, &dma_direct_ops);
357 } else {
358 dev_info(dev, "Using 32-bit DMA via iommu\n");
359 set_dma_ops(dev, &dma_iommu_ops);
360 }
361 dma_dev_setup_dart(dev);
362
363 *dev->dma_mask = dma_mask;
364 return 0;
365}
366
318void __init iommu_init_early_dart(void) 367void __init iommu_init_early_dart(void)
319{ 368{
320 struct device_node *dn; 369 struct device_node *dn;
@@ -328,20 +377,25 @@ void __init iommu_init_early_dart(void)
328 dart_is_u4 = 1; 377 dart_is_u4 = 1;
329 } 378 }
330 379
380 /* Initialize the DART HW */
381 if (dart_init(dn) != 0)
382 goto bail;
383
331 /* Setup low level TCE operations for the core IOMMU code */ 384 /* Setup low level TCE operations for the core IOMMU code */
332 ppc_md.tce_build = dart_build; 385 ppc_md.tce_build = dart_build;
333 ppc_md.tce_free = dart_free; 386 ppc_md.tce_free = dart_free;
334 ppc_md.tce_flush = dart_flush; 387 ppc_md.tce_flush = dart_flush;
335 388
336 /* Initialize the DART HW */ 389 /* Setup bypass if supported */
337 if (dart_init(dn) == 0) { 390 if (dart_is_u4)
338 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart; 391 ppc_md.dma_set_mask = dart_dma_set_mask;
339 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart;
340 392
341 /* Setup pci_dma ops */ 393 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart;
342 set_pci_dma_ops(&dma_iommu_ops); 394 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart;
343 return; 395
344 } 396 /* Setup pci_dma ops */
397 set_pci_dma_ops(&dma_iommu_ops);
398 return;
345 399
346 bail: 400 bail:
347 /* If init failed, use direct iommu and null setup functions */ 401 /* If init failed, use direct iommu and null setup functions */
diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
new file mode 100644
index 000000000000..60c9c0bd5ba2
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_ctlr.h
@@ -0,0 +1,101 @@
1/*
2 * Copyright 2009-2010 Freescale Semiconductor, Inc
3 *
4 * QorIQ based Cache Controller Memory Mapped Registers
5 *
6 * Author: Vivek Mahajan <vivek.mahajan@freescale.com>
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 * 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
23#ifndef __FSL_85XX_CACHE_CTLR_H__
24#define __FSL_85XX_CACHE_CTLR_H__
25
26#define L2CR_L2FI 0x40000000 /* L2 flash invalidate */
27#define L2CR_L2IO 0x00200000 /* L2 instruction only */
28#define L2CR_SRAM_ZERO 0x00000000 /* L2SRAM zero size */
29#define L2CR_SRAM_FULL 0x00010000 /* L2SRAM full size */
30#define L2CR_SRAM_HALF 0x00020000 /* L2SRAM half size */
31#define L2CR_SRAM_TWO_HALFS 0x00030000 /* L2SRAM two half sizes */
32#define L2CR_SRAM_QUART 0x00040000 /* L2SRAM one quarter size */
33#define L2CR_SRAM_TWO_QUARTS 0x00050000 /* L2SRAM two quarter size */
34#define L2CR_SRAM_EIGHTH 0x00060000 /* L2SRAM one eighth size */
35#define L2CR_SRAM_TWO_EIGHTH 0x00070000 /* L2SRAM two eighth size */
36
37#define L2SRAM_OPTIMAL_SZ_SHIFT 0x00000003 /* Optimum size for L2SRAM */
38
39#define L2SRAM_BAR_MSK_LO18 0xFFFFC000 /* Lower 18 bits */
40#define L2SRAM_BARE_MSK_HI4 0x0000000F /* Upper 4 bits */
41
42enum cache_sram_lock_ways {
43 LOCK_WAYS_ZERO,
44 LOCK_WAYS_EIGHTH,
45 LOCK_WAYS_TWO_EIGHTH,
46 LOCK_WAYS_HALF = 4,
47 LOCK_WAYS_FULL = 8,
48};
49
50struct mpc85xx_l2ctlr {
51 u32 ctl; /* 0x000 - L2 control */
52 u8 res1[0xC];
53 u32 ewar0; /* 0x010 - External write address 0 */
54 u32 ewarea0; /* 0x014 - External write address extended 0 */
55 u32 ewcr0; /* 0x018 - External write ctrl */
56 u8 res2[4];
57 u32 ewar1; /* 0x020 - External write address 1 */
58 u32 ewarea1; /* 0x024 - External write address extended 1 */
59 u32 ewcr1; /* 0x028 - External write ctrl 1 */
60 u8 res3[4];
61 u32 ewar2; /* 0x030 - External write address 2 */
62 u32 ewarea2; /* 0x034 - External write address extended 2 */
63 u32 ewcr2; /* 0x038 - External write ctrl 2 */
64 u8 res4[4];
65 u32 ewar3; /* 0x040 - External write address 3 */
66 u32 ewarea3; /* 0x044 - External write address extended 3 */
67 u32 ewcr3; /* 0x048 - External write ctrl 3 */
68 u8 res5[0xB4];
69 u32 srbar0; /* 0x100 - SRAM base address 0 */
70 u32 srbarea0; /* 0x104 - SRAM base addr reg ext address 0 */
71 u32 srbar1; /* 0x108 - SRAM base address 1 */
72 u32 srbarea1; /* 0x10C - SRAM base addr reg ext address 1 */
73 u8 res6[0xCF0];
74 u32 errinjhi; /* 0xE00 - Error injection mask high */
75 u32 errinjlo; /* 0xE04 - Error injection mask low */
76 u32 errinjctl; /* 0xE08 - Error injection tag/ecc control */
77 u8 res7[0x14];
78 u32 captdatahi; /* 0xE20 - Error data high capture */
79 u32 captdatalo; /* 0xE24 - Error data low capture */
80 u32 captecc; /* 0xE28 - Error syndrome */
81 u8 res8[0x14];
82 u32 errdet; /* 0xE40 - Error detect */
83 u32 errdis; /* 0xE44 - Error disable */
84 u32 errinten; /* 0xE48 - Error interrupt enable */
85 u32 errattr; /* 0xE4c - Error attribute capture */
86 u32 erradrrl; /* 0xE50 - Error address capture low */
87 u32 erradrrh; /* 0xE54 - Error address capture high */
88 u32 errctl; /* 0xE58 - Error control */
89 u8 res9[0x1A4];
90};
91
92struct sram_parameters {
93 unsigned int sram_size;
94 uint64_t sram_offset;
95};
96
97extern int instantiate_cache_sram(struct platform_device *dev,
98 struct sram_parameters sram_params);
99extern void remove_cache_sram(struct platform_device *dev);
100
101#endif /* __FSL_85XX_CACHE_CTLR_H__ */
diff --git a/arch/powerpc/sysdev/fsl_85xx_cache_sram.c b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
new file mode 100644
index 000000000000..54fb1922fe30
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_85xx_cache_sram.c
@@ -0,0 +1,159 @@
1/*
2 * Copyright 2009-2010 Freescale Semiconductor, Inc.
3 *
4 * Simple memory allocator abstraction for QorIQ (P1/P2) based Cache-SRAM
5 *
6 * Author: Vivek Mahajan <vivek.mahajan@freescale.com>
7 *
8 * This file is derived from the original work done
9 * by Sylvain Munaut for the Bestcomm SRAM allocator.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/err.h>
29#include <linux/of_platform.h>
30#include <asm/pgtable.h>
31#include <asm/fsl_85xx_cache_sram.h>
32
33#include "fsl_85xx_cache_ctlr.h"
34
35struct mpc85xx_cache_sram *cache_sram;
36
37void *mpc85xx_cache_sram_alloc(unsigned int size,
38 phys_addr_t *phys, unsigned int align)
39{
40 unsigned long offset;
41 unsigned long flags;
42
43 if (unlikely(cache_sram == NULL))
44 return NULL;
45
46 if (!size || (size > cache_sram->size) || (align > cache_sram->size)) {
47 pr_err("%s(): size(=%x) or align(=%x) zero or too big\n",
48 __func__, size, align);
49 return NULL;
50 }
51
52 if ((align & (align - 1)) || align <= 1) {
53 pr_err("%s(): align(=%x) must be power of two and >1\n",
54 __func__, align);
55 return NULL;
56 }
57
58 spin_lock_irqsave(&cache_sram->lock, flags);
59 offset = rh_alloc_align(cache_sram->rh, size, align, NULL);
60 spin_unlock_irqrestore(&cache_sram->lock, flags);
61
62 if (IS_ERR_VALUE(offset))
63 return NULL;
64
65 *phys = cache_sram->base_phys + offset;
66
67 return (unsigned char *)cache_sram->base_virt + offset;
68}
69EXPORT_SYMBOL(mpc85xx_cache_sram_alloc);
70
71void mpc85xx_cache_sram_free(void *ptr)
72{
73 unsigned long flags;
74 BUG_ON(!ptr);
75
76 spin_lock_irqsave(&cache_sram->lock, flags);
77 rh_free(cache_sram->rh, ptr - cache_sram->base_virt);
78 spin_unlock_irqrestore(&cache_sram->lock, flags);
79}
80EXPORT_SYMBOL(mpc85xx_cache_sram_free);
81
82int __init instantiate_cache_sram(struct platform_device *dev,
83 struct sram_parameters sram_params)
84{
85 int ret = 0;
86
87 if (cache_sram) {
88 dev_err(&dev->dev, "Already initialized cache-sram\n");
89 return -EBUSY;
90 }
91
92 cache_sram = kzalloc(sizeof(struct mpc85xx_cache_sram), GFP_KERNEL);
93 if (!cache_sram) {
94 dev_err(&dev->dev, "Out of memory for cache_sram structure\n");
95 return -ENOMEM;
96 }
97
98 cache_sram->base_phys = sram_params.sram_offset;
99 cache_sram->size = sram_params.sram_size;
100
101 if (!request_mem_region(cache_sram->base_phys, cache_sram->size,
102 "fsl_85xx_cache_sram")) {
103 dev_err(&dev->dev, "%s: request memory failed\n",
104 dev->dev.of_node->full_name);
105 ret = -ENXIO;
106 goto out_free;
107 }
108
109 cache_sram->base_virt = ioremap_flags(cache_sram->base_phys,
110 cache_sram->size, _PAGE_COHERENT | PAGE_KERNEL);
111 if (!cache_sram->base_virt) {
112 dev_err(&dev->dev, "%s: ioremap_flags failed\n",
113 dev->dev.of_node->full_name);
114 ret = -ENOMEM;
115 goto out_release;
116 }
117
118 cache_sram->rh = rh_create(sizeof(unsigned int));
119 if (IS_ERR(cache_sram->rh)) {
120 dev_err(&dev->dev, "%s: Unable to create remote heap\n",
121 dev->dev.of_node->full_name);
122 ret = PTR_ERR(cache_sram->rh);
123 goto out_unmap;
124 }
125
126 rh_attach_region(cache_sram->rh, 0, cache_sram->size);
127 spin_lock_init(&cache_sram->lock);
128
129 dev_info(&dev->dev, "[base:0x%llx, size:0x%x] configured and loaded\n",
130 (unsigned long long)cache_sram->base_phys, cache_sram->size);
131
132 return 0;
133
134out_unmap:
135 iounmap(cache_sram->base_virt);
136
137out_release:
138 release_mem_region(cache_sram->base_phys, cache_sram->size);
139
140out_free:
141 kfree(cache_sram);
142 return ret;
143}
144
145void remove_cache_sram(struct platform_device *dev)
146{
147 BUG_ON(!cache_sram);
148
149 rh_detach_region(cache_sram->rh, 0, cache_sram->size);
150 rh_destroy(cache_sram->rh);
151
152 iounmap(cache_sram->base_virt);
153 release_mem_region(cache_sram->base_phys, cache_sram->size);
154
155 kfree(cache_sram);
156 cache_sram = NULL;
157
158 dev_info(&dev->dev, "MPC85xx Cache-SRAM driver unloaded\n");
159}
diff --git a/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
new file mode 100644
index 000000000000..cc8d6556d799
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c
@@ -0,0 +1,231 @@
1/*
2 * Copyright 2009-2010 Freescale Semiconductor, Inc.
3 *
4 * QorIQ (P1/P2) L2 controller init for Cache-SRAM instantiation
5 *
6 * Author: Vivek Mahajan <vivek.mahajan@freescale.com>
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 * 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
23#include <linux/kernel.h>
24#include <linux/of_platform.h>
25#include <asm/io.h>
26
27#include "fsl_85xx_cache_ctlr.h"
28
29static char *sram_size;
30static char *sram_offset;
31struct mpc85xx_l2ctlr __iomem *l2ctlr;
32
33static long get_cache_sram_size(void)
34{
35 unsigned long val;
36
37 if (!sram_size || (strict_strtoul(sram_size, 0, &val) < 0))
38 return -EINVAL;
39
40 return val;
41}
42
43static long get_cache_sram_offset(void)
44{
45 unsigned long val;
46
47 if (!sram_offset || (strict_strtoul(sram_offset, 0, &val) < 0))
48 return -EINVAL;
49
50 return val;
51}
52
53static int __init get_size_from_cmdline(char *str)
54{
55 if (!str)
56 return 0;
57
58 sram_size = str;
59 return 1;
60}
61
62static int __init get_offset_from_cmdline(char *str)
63{
64 if (!str)
65 return 0;
66
67 sram_offset = str;
68 return 1;
69}
70
71__setup("cache-sram-size=", get_size_from_cmdline);
72__setup("cache-sram-offset=", get_offset_from_cmdline);
73
74static int __devinit mpc85xx_l2ctlr_of_probe(struct platform_device *dev,
75 const struct of_device_id *match)
76{
77 long rval;
78 unsigned int rem;
79 unsigned char ways;
80 const unsigned int *prop;
81 unsigned int l2cache_size;
82 struct sram_parameters sram_params;
83
84 if (!dev->dev.of_node) {
85 dev_err(&dev->dev, "Device's OF-node is NULL\n");
86 return -EINVAL;
87 }
88
89 prop = of_get_property(dev->dev.of_node, "cache-size", NULL);
90 if (!prop) {
91 dev_err(&dev->dev, "Missing L2 cache-size\n");
92 return -EINVAL;
93 }
94 l2cache_size = *prop;
95
96 sram_params.sram_size = get_cache_sram_size();
97 if (sram_params.sram_size <= 0) {
98 dev_err(&dev->dev,
99 "Entire L2 as cache, Aborting Cache-SRAM stuff\n");
100 return -EINVAL;
101 }
102
103 sram_params.sram_offset = get_cache_sram_offset();
104 if (sram_params.sram_offset <= 0) {
105 dev_err(&dev->dev,
106 "Entire L2 as cache, provide a valid sram offset\n");
107 return -EINVAL;
108 }
109
110
111 rem = l2cache_size % sram_params.sram_size;
112 ways = LOCK_WAYS_FULL * sram_params.sram_size / l2cache_size;
113 if (rem || (ways & (ways - 1))) {
114 dev_err(&dev->dev, "Illegal cache-sram-size in command line\n");
115 return -EINVAL;
116 }
117
118 l2ctlr = of_iomap(dev->dev.of_node, 0);
119 if (!l2ctlr) {
120 dev_err(&dev->dev, "Can't map L2 controller\n");
121 return -EINVAL;
122 }
123
124 /*
125 * Write bits[0-17] to srbar0
126 */
127 out_be32(&l2ctlr->srbar0,
128 sram_params.sram_offset & L2SRAM_BAR_MSK_LO18);
129
130 /*
131 * Write bits[18-21] to srbare0
132 */
133#ifdef CONFIG_PHYS_64BIT
134 out_be32(&l2ctlr->srbarea0,
135 (sram_params.sram_offset >> 32) & L2SRAM_BARE_MSK_HI4);
136#endif
137
138 clrsetbits_be32(&l2ctlr->ctl, L2CR_L2E, L2CR_L2FI);
139
140 switch (ways) {
141 case LOCK_WAYS_EIGHTH:
142 setbits32(&l2ctlr->ctl,
143 L2CR_L2E | L2CR_L2FI | L2CR_SRAM_EIGHTH);
144 break;
145
146 case LOCK_WAYS_TWO_EIGHTH:
147 setbits32(&l2ctlr->ctl,
148 L2CR_L2E | L2CR_L2FI | L2CR_SRAM_QUART);
149 break;
150
151 case LOCK_WAYS_HALF:
152 setbits32(&l2ctlr->ctl,
153 L2CR_L2E | L2CR_L2FI | L2CR_SRAM_HALF);
154 break;
155
156 case LOCK_WAYS_FULL:
157 default:
158 setbits32(&l2ctlr->ctl,
159 L2CR_L2E | L2CR_L2FI | L2CR_SRAM_FULL);
160 break;
161 }
162 eieio();
163
164 rval = instantiate_cache_sram(dev, sram_params);
165 if (rval < 0) {
166 dev_err(&dev->dev, "Can't instantiate Cache-SRAM\n");
167 iounmap(l2ctlr);
168 return -EINVAL;
169 }
170
171 return 0;
172}
173
174static int __devexit mpc85xx_l2ctlr_of_remove(struct platform_device *dev)
175{
176 BUG_ON(!l2ctlr);
177
178 iounmap(l2ctlr);
179 remove_cache_sram(dev);
180 dev_info(&dev->dev, "MPC85xx L2 controller unloaded\n");
181
182 return 0;
183}
184
185static struct of_device_id mpc85xx_l2ctlr_of_match[] = {
186 {
187 .compatible = "fsl,p2020-l2-cache-controller",
188 },
189 {
190 .compatible = "fsl,p2010-l2-cache-controller",
191 },
192 {
193 .compatible = "fsl,p1020-l2-cache-controller",
194 },
195 {
196 .compatible = "fsl,p1011-l2-cache-controller",
197 },
198 {
199 .compatible = "fsl,p1013-l2-cache-controller",
200 },
201 {
202 .compatible = "fsl,p1022-l2-cache-controller",
203 },
204 {},
205};
206
207static struct of_platform_driver mpc85xx_l2ctlr_of_platform_driver = {
208 .driver = {
209 .name = "fsl-l2ctlr",
210 .owner = THIS_MODULE,
211 .of_match_table = mpc85xx_l2ctlr_of_match,
212 },
213 .probe = mpc85xx_l2ctlr_of_probe,
214 .remove = __devexit_p(mpc85xx_l2ctlr_of_remove),
215};
216
217static __init int mpc85xx_l2ctlr_of_init(void)
218{
219 return of_register_platform_driver(&mpc85xx_l2ctlr_of_platform_driver);
220}
221
222static void __exit mpc85xx_l2ctlr_of_exit(void)
223{
224 of_unregister_platform_driver(&mpc85xx_l2ctlr_of_platform_driver);
225}
226
227subsys_initcall(mpc85xx_l2ctlr_of_init);
228module_exit(mpc85xx_l2ctlr_of_exit);
229
230MODULE_DESCRIPTION("Freescale MPC85xx L2 controller init");
231MODULE_LICENSE("GPL v2");
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 87991d3abbab..108d76fa8f1c 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -24,6 +24,7 @@
24#include <asm/ppc-pci.h> 24#include <asm/ppc-pci.h>
25#include <asm/mpic.h> 25#include <asm/mpic.h>
26#include "fsl_msi.h" 26#include "fsl_msi.h"
27#include "fsl_pci.h"
27 28
28LIST_HEAD(msi_head); 29LIST_HEAD(msi_head);
29 30
@@ -51,8 +52,8 @@ static void fsl_msi_end_irq(unsigned int virq)
51} 52}
52 53
53static struct irq_chip fsl_msi_chip = { 54static struct irq_chip fsl_msi_chip = {
54 .mask = mask_msi_irq, 55 .irq_mask = mask_msi_irq,
55 .unmask = unmask_msi_irq, 56 .irq_unmask = unmask_msi_irq,
56 .ack = fsl_msi_end_irq, 57 .ack = fsl_msi_end_irq,
57 .name = "FSL-MSI", 58 .name = "FSL-MSI",
58}; 59};
@@ -125,13 +126,11 @@ static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq,
125{ 126{
126 struct fsl_msi *msi_data = fsl_msi_data; 127 struct fsl_msi *msi_data = fsl_msi_data;
127 struct pci_controller *hose = pci_bus_to_host(pdev->bus); 128 struct pci_controller *hose = pci_bus_to_host(pdev->bus);
128 u32 base = 0; 129 u64 base = fsl_pci_immrbar_base(hose);
129 130
130 pci_bus_read_config_dword(hose->bus, 131 msg->address_lo = msi_data->msi_addr_lo + lower_32_bits(base);
131 PCI_DEVFN(0, 0), PCI_BASE_ADDRESS_0, &base); 132 msg->address_hi = msi_data->msi_addr_hi + upper_32_bits(base);
132 133
133 msg->address_lo = msi_data->msi_addr_lo + base;
134 msg->address_hi = msi_data->msi_addr_hi;
135 msg->data = hwirq; 134 msg->data = hwirq;
136 135
137 pr_debug("%s: allocated srs: %d, ibs: %d\n", 136 pr_debug("%s: allocated srs: %d, ibs: %d\n",
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 4ae933225251..818f7c6c8fa1 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * MPC83xx/85xx/86xx PCI/PCIE support routing. 2 * MPC83xx/85xx/86xx PCI/PCIE support routing.
3 * 3 *
4 * Copyright 2007-2009 Freescale Semiconductor, Inc. 4 * Copyright 2007-2010 Freescale Semiconductor, Inc.
5 * Copyright 2008-2009 MontaVista Software, Inc. 5 * Copyright 2008-2009 MontaVista Software, Inc.
6 * 6 *
7 * Initial author: Xianghua Xiao <x.xiao@freescale.com> 7 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
@@ -34,7 +34,7 @@
34#include <sysdev/fsl_soc.h> 34#include <sysdev/fsl_soc.h>
35#include <sysdev/fsl_pci.h> 35#include <sysdev/fsl_pci.h>
36 36
37static int fsl_pcie_bus_fixup; 37static int fsl_pcie_bus_fixup, is_mpc83xx_pci;
38 38
39static void __init quirk_fsl_pcie_header(struct pci_dev *dev) 39static void __init quirk_fsl_pcie_header(struct pci_dev *dev)
40{ 40{
@@ -407,10 +407,18 @@ DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2010E, quirk_fsl_pcie_header);
407DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2010, quirk_fsl_pcie_header); 407DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2010, quirk_fsl_pcie_header);
408DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2020E, quirk_fsl_pcie_header); 408DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2020E, quirk_fsl_pcie_header);
409DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2020, quirk_fsl_pcie_header); 409DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2020, quirk_fsl_pcie_header);
410DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2040E, quirk_fsl_pcie_header);
411DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P2040, quirk_fsl_pcie_header);
412DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P3041E, quirk_fsl_pcie_header);
413DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P3041, quirk_fsl_pcie_header);
410DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4040E, quirk_fsl_pcie_header); 414DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4040E, quirk_fsl_pcie_header);
411DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4040, quirk_fsl_pcie_header); 415DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4040, quirk_fsl_pcie_header);
412DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4080E, quirk_fsl_pcie_header); 416DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4080E, quirk_fsl_pcie_header);
413DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4080, quirk_fsl_pcie_header); 417DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P4080, quirk_fsl_pcie_header);
418DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P5010E, quirk_fsl_pcie_header);
419DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P5010, quirk_fsl_pcie_header);
420DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P5020E, quirk_fsl_pcie_header);
421DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_P5020, quirk_fsl_pcie_header);
414#endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */ 422#endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */
415 423
416#if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x) 424#if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x)
@@ -430,6 +438,13 @@ struct mpc83xx_pcie_priv {
430 u32 dev_base; 438 u32 dev_base;
431}; 439};
432 440
441struct pex_inbound_window {
442 u32 ar;
443 u32 tar;
444 u32 barl;
445 u32 barh;
446};
447
433/* 448/*
434 * With the convention of u-boot, the PCIE outbound window 0 serves 449 * With the convention of u-boot, the PCIE outbound window 0 serves
435 * as configuration transactions outbound. 450 * as configuration transactions outbound.
@@ -437,6 +452,8 @@ struct mpc83xx_pcie_priv {
437#define PEX_OUTWIN0_BAR 0xCA4 452#define PEX_OUTWIN0_BAR 0xCA4
438#define PEX_OUTWIN0_TAL 0xCA8 453#define PEX_OUTWIN0_TAL 0xCA8
439#define PEX_OUTWIN0_TAH 0xCAC 454#define PEX_OUTWIN0_TAH 0xCAC
455#define PEX_RC_INWIN_BASE 0xE60
456#define PEX_RCIWARn_EN 0x1
440 457
441static int mpc83xx_pcie_exclude_device(struct pci_bus *bus, unsigned int devfn) 458static int mpc83xx_pcie_exclude_device(struct pci_bus *bus, unsigned int devfn)
442{ 459{
@@ -604,6 +621,8 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
604 const int *bus_range; 621 const int *bus_range;
605 int primary; 622 int primary;
606 623
624 is_mpc83xx_pci = 1;
625
607 if (!of_device_is_available(dev)) { 626 if (!of_device_is_available(dev)) {
608 pr_warning("%s: disabled by the firmware.\n", 627 pr_warning("%s: disabled by the firmware.\n",
609 dev->full_name); 628 dev->full_name);
@@ -683,3 +702,40 @@ err0:
683 return ret; 702 return ret;
684} 703}
685#endif /* CONFIG_PPC_83xx */ 704#endif /* CONFIG_PPC_83xx */
705
706u64 fsl_pci_immrbar_base(struct pci_controller *hose)
707{
708#ifdef CONFIG_PPC_83xx
709 if (is_mpc83xx_pci) {
710 struct mpc83xx_pcie_priv *pcie = hose->dn->data;
711 struct pex_inbound_window *in;
712 int i;
713
714 /* Walk the Root Complex Inbound windows to match IMMR base */
715 in = pcie->cfg_type0 + PEX_RC_INWIN_BASE;
716 for (i = 0; i < 4; i++) {
717 /* not enabled, skip */
718 if (!in_le32(&in[i].ar) & PEX_RCIWARn_EN)
719 continue;
720
721 if (get_immrbase() == in_le32(&in[i].tar))
722 return (u64)in_le32(&in[i].barh) << 32 |
723 in_le32(&in[i].barl);
724 }
725
726 printk(KERN_WARNING "could not find PCI BAR matching IMMR\n");
727 }
728#endif
729
730#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
731 if (!is_mpc83xx_pci) {
732 u32 base;
733
734 pci_bus_read_config_dword(hose->bus,
735 PCI_DEVFN(0, 0), PCI_BASE_ADDRESS_0, &base);
736 return base;
737 }
738#endif
739
740 return 0;
741}
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index a9d8bbebed80..8ad72a11f77b 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -88,6 +88,7 @@ struct ccsr_pci {
88extern int fsl_add_bridge(struct device_node *dev, int is_primary); 88extern int fsl_add_bridge(struct device_node *dev, int is_primary);
89extern void fsl_pcibios_fixup_bus(struct pci_bus *bus); 89extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
90extern int mpc83xx_add_bridge(struct device_node *dev); 90extern int mpc83xx_add_bridge(struct device_node *dev);
91u64 fsl_pci_immrbar_base(struct pci_controller *hose);
91 92
92#endif /* __POWERPC_FSL_PCI_H */ 93#endif /* __POWERPC_FSL_PCI_H */
93#endif /* __KERNEL__ */ 94#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 3017532319c8..412763672d23 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -117,44 +117,59 @@ struct rio_atmu_regs {
117}; 117};
118 118
119struct rio_msg_regs { 119struct rio_msg_regs {
120 u32 omr; 120 u32 omr; /* 0xD_3000 - Outbound message 0 mode register */
121 u32 osr; 121 u32 osr; /* 0xD_3004 - Outbound message 0 status register */
122 u32 pad1; 122 u32 pad1;
123 u32 odqdpar; 123 u32 odqdpar; /* 0xD_300C - Outbound message 0 descriptor queue
124 dequeue pointer address register */
124 u32 pad2; 125 u32 pad2;
125 u32 osar; 126 u32 osar; /* 0xD_3014 - Outbound message 0 source address
126 u32 odpr; 127 register */
127 u32 odatr; 128 u32 odpr; /* 0xD_3018 - Outbound message 0 destination port
128 u32 odcr; 129 register */
130 u32 odatr; /* 0xD_301C - Outbound message 0 destination attributes
131 Register*/
132 u32 odcr; /* 0xD_3020 - Outbound message 0 double-word count
133 register */
129 u32 pad3; 134 u32 pad3;
130 u32 odqepar; 135 u32 odqepar; /* 0xD_3028 - Outbound message 0 descriptor queue
136 enqueue pointer address register */
131 u32 pad4[13]; 137 u32 pad4[13];
132 u32 imr; 138 u32 imr; /* 0xD_3060 - Inbound message 0 mode register */
133 u32 isr; 139 u32 isr; /* 0xD_3064 - Inbound message 0 status register */
134 u32 pad5; 140 u32 pad5;
135 u32 ifqdpar; 141 u32 ifqdpar; /* 0xD_306C - Inbound message 0 frame queue dequeue
142 pointer address register*/
136 u32 pad6; 143 u32 pad6;
137 u32 ifqepar; 144 u32 ifqepar; /* 0xD_3074 - Inbound message 0 frame queue enqueue
145 pointer address register */
138 u32 pad7[226]; 146 u32 pad7[226];
139 u32 odmr; 147 u32 odmr; /* 0xD_3400 - Outbound doorbell mode register */
140 u32 odsr; 148 u32 odsr; /* 0xD_3404 - Outbound doorbell status register */
141 u32 res0[4]; 149 u32 res0[4];
142 u32 oddpr; 150 u32 oddpr; /* 0xD_3418 - Outbound doorbell destination port
143 u32 oddatr; 151 register */
152 u32 oddatr; /* 0xD_341c - Outbound doorbell destination attributes
153 register */
144 u32 res1[3]; 154 u32 res1[3];
145 u32 odretcr; 155 u32 odretcr; /* 0xD_342C - Outbound doorbell retry error threshold
156 configuration register */
146 u32 res2[12]; 157 u32 res2[12];
147 u32 dmr; 158 u32 dmr; /* 0xD_3460 - Inbound doorbell mode register */
148 u32 dsr; 159 u32 dsr; /* 0xD_3464 - Inbound doorbell status register */
149 u32 pad8; 160 u32 pad8;
150 u32 dqdpar; 161 u32 dqdpar; /* 0xD_346C - Inbound doorbell queue dequeue Pointer
162 address register */
151 u32 pad9; 163 u32 pad9;
152 u32 dqepar; 164 u32 dqepar; /* 0xD_3474 - Inbound doorbell Queue enqueue pointer
165 address register */
153 u32 pad10[26]; 166 u32 pad10[26];
154 u32 pwmr; 167 u32 pwmr; /* 0xD_34E0 - Inbound port-write mode register */
155 u32 pwsr; 168 u32 pwsr; /* 0xD_34E4 - Inbound port-write status register */
156 u32 epwqbar; 169 u32 epwqbar; /* 0xD_34E8 - Extended Port-Write Queue Base Address
157 u32 pwqbar; 170 register */
171 u32 pwqbar; /* 0xD_34EC - Inbound port-write queue base address
172 register */
158}; 173};
159 174
160struct rio_tx_desc { 175struct rio_tx_desc {
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index b91f7acdda6f..19e5015e039b 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -209,186 +209,29 @@ static int __init of_add_fixed_phys(void)
209arch_initcall(of_add_fixed_phys); 209arch_initcall(of_add_fixed_phys);
210#endif /* CONFIG_FIXED_PHY */ 210#endif /* CONFIG_FIXED_PHY */
211 211
212static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type) 212#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
213{ 213static __be32 __iomem *rstcr;
214 if (!phy_type)
215 return FSL_USB2_PHY_NONE;
216 if (!strcasecmp(phy_type, "ulpi"))
217 return FSL_USB2_PHY_ULPI;
218 if (!strcasecmp(phy_type, "utmi"))
219 return FSL_USB2_PHY_UTMI;
220 if (!strcasecmp(phy_type, "utmi_wide"))
221 return FSL_USB2_PHY_UTMI_WIDE;
222 if (!strcasecmp(phy_type, "serial"))
223 return FSL_USB2_PHY_SERIAL;
224
225 return FSL_USB2_PHY_NONE;
226}
227 214
228static int __init fsl_usb_of_init(void) 215static int __init setup_rstcr(void)
229{ 216{
230 struct device_node *np; 217 struct device_node *np;
231 unsigned int i = 0;
232 struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL,
233 *usb_dev_dr_client = NULL;
234 int ret;
235
236 for_each_compatible_node(np, NULL, "fsl-usb2-mph") {
237 struct resource r[2];
238 struct fsl_usb2_platform_data usb_data;
239 const unsigned char *prop = NULL;
240
241 memset(&r, 0, sizeof(r));
242 memset(&usb_data, 0, sizeof(usb_data));
243
244 ret = of_address_to_resource(np, 0, &r[0]);
245 if (ret)
246 goto err;
247
248 of_irq_to_resource(np, 0, &r[1]);
249
250 usb_dev_mph =
251 platform_device_register_simple("fsl-ehci", i, r, 2);
252 if (IS_ERR(usb_dev_mph)) {
253 ret = PTR_ERR(usb_dev_mph);
254 goto err;
255 }
256
257 usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
258 usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
259
260 usb_data.operating_mode = FSL_USB2_MPH_HOST;
261
262 prop = of_get_property(np, "port0", NULL);
263 if (prop)
264 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
265
266 prop = of_get_property(np, "port1", NULL);
267 if (prop)
268 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
269
270 prop = of_get_property(np, "phy_type", NULL);
271 usb_data.phy_mode = determine_usb_phy(prop);
272
273 ret =
274 platform_device_add_data(usb_dev_mph, &usb_data,
275 sizeof(struct
276 fsl_usb2_platform_data));
277 if (ret)
278 goto unreg_mph;
279 i++;
280 }
281
282 for_each_compatible_node(np, NULL, "fsl-usb2-dr") {
283 struct resource r[2];
284 struct fsl_usb2_platform_data usb_data;
285 const unsigned char *prop = NULL;
286 218
287 if (!of_device_is_available(np)) 219 for_each_node_by_name(np, "global-utilities") {
288 continue; 220 if ((of_get_property(np, "fsl,has-rstcr", NULL))) {
289 221 rstcr = of_iomap(np, 0) + 0xb0;
290 memset(&r, 0, sizeof(r)); 222 if (!rstcr)
291 memset(&usb_data, 0, sizeof(usb_data)); 223 printk (KERN_ERR "Error: reset control "
292 224 "register not mapped!\n");
293 ret = of_address_to_resource(np, 0, &r[0]); 225 break;
294 if (ret)
295 goto unreg_mph;
296
297 of_irq_to_resource(np, 0, &r[1]);
298
299 prop = of_get_property(np, "dr_mode", NULL);
300
301 if (!prop || !strcmp(prop, "host")) {
302 usb_data.operating_mode = FSL_USB2_DR_HOST;
303 usb_dev_dr_host = platform_device_register_simple(
304 "fsl-ehci", i, r, 2);
305 if (IS_ERR(usb_dev_dr_host)) {
306 ret = PTR_ERR(usb_dev_dr_host);
307 goto err;
308 }
309 } else if (prop && !strcmp(prop, "peripheral")) {
310 usb_data.operating_mode = FSL_USB2_DR_DEVICE;
311 usb_dev_dr_client = platform_device_register_simple(
312 "fsl-usb2-udc", i, r, 2);
313 if (IS_ERR(usb_dev_dr_client)) {
314 ret = PTR_ERR(usb_dev_dr_client);
315 goto err;
316 }
317 } else if (prop && !strcmp(prop, "otg")) {
318 usb_data.operating_mode = FSL_USB2_DR_OTG;
319 usb_dev_dr_host = platform_device_register_simple(
320 "fsl-ehci", i, r, 2);
321 if (IS_ERR(usb_dev_dr_host)) {
322 ret = PTR_ERR(usb_dev_dr_host);
323 goto err;
324 }
325 usb_dev_dr_client = platform_device_register_simple(
326 "fsl-usb2-udc", i, r, 2);
327 if (IS_ERR(usb_dev_dr_client)) {
328 ret = PTR_ERR(usb_dev_dr_client);
329 goto err;
330 }
331 } else {
332 ret = -EINVAL;
333 goto err;
334 } 226 }
335
336 prop = of_get_property(np, "phy_type", NULL);
337 usb_data.phy_mode = determine_usb_phy(prop);
338
339 if (usb_dev_dr_host) {
340 usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL;
341 usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host->
342 dev.coherent_dma_mask;
343 if ((ret = platform_device_add_data(usb_dev_dr_host,
344 &usb_data, sizeof(struct
345 fsl_usb2_platform_data))))
346 goto unreg_dr;
347 }
348 if (usb_dev_dr_client) {
349 usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL;
350 usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client->
351 dev.coherent_dma_mask;
352 if ((ret = platform_device_add_data(usb_dev_dr_client,
353 &usb_data, sizeof(struct
354 fsl_usb2_platform_data))))
355 goto unreg_dr;
356 }
357 i++;
358 } 227 }
359 return 0;
360
361unreg_dr:
362 if (usb_dev_dr_host)
363 platform_device_unregister(usb_dev_dr_host);
364 if (usb_dev_dr_client)
365 platform_device_unregister(usb_dev_dr_client);
366unreg_mph:
367 if (usb_dev_mph)
368 platform_device_unregister(usb_dev_mph);
369err:
370 return ret;
371}
372
373arch_initcall(fsl_usb_of_init);
374
375#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
376static __be32 __iomem *rstcr;
377 228
378static int __init setup_rstcr(void) 229 if (!rstcr && ppc_md.restart == fsl_rstcr_restart)
379{
380 struct device_node *np;
381 np = of_find_node_by_name(NULL, "global-utilities");
382 if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {
383 rstcr = of_iomap(np, 0) + 0xb0;
384 if (!rstcr)
385 printk (KERN_EMERG "Error: reset control register "
386 "not mapped!\n");
387 } else if (ppc_md.restart == fsl_rstcr_restart)
388 printk(KERN_ERR "No RSTCR register, warm reboot won't work\n"); 230 printk(KERN_ERR "No RSTCR register, warm reboot won't work\n");
389 231
390 if (np) 232 if (np)
391 of_node_put(np); 233 of_node_put(np);
234
392 return 0; 235 return 0;
393} 236}
394 237
diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c
index 2b69084d0f0c..c0ea05e87f1d 100644
--- a/arch/powerpc/sysdev/mpc8xxx_gpio.c
+++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c
@@ -330,6 +330,9 @@ static int __init mpc8xxx_add_gpiochips(void)
330 for_each_compatible_node(np, NULL, "fsl,mpc8610-gpio") 330 for_each_compatible_node(np, NULL, "fsl,mpc8610-gpio")
331 mpc8xxx_add_controller(np); 331 mpc8xxx_add_controller(np);
332 332
333 for_each_compatible_node(np, NULL, "fsl,qoriq-gpio")
334 mpc8xxx_add_controller(np);
335
333 return 0; 336 return 0;
334} 337}
335arch_initcall(mpc8xxx_add_gpiochips); 338arch_initcall(mpc8xxx_add_gpiochips);
diff --git a/arch/powerpc/sysdev/mpic_pasemi_msi.c b/arch/powerpc/sysdev/mpic_pasemi_msi.c
index 3b6a9a43718f..320ad5a9a25d 100644
--- a/arch/powerpc/sysdev/mpic_pasemi_msi.c
+++ b/arch/powerpc/sysdev/mpic_pasemi_msi.c
@@ -39,24 +39,24 @@
39static struct mpic *msi_mpic; 39static struct mpic *msi_mpic;
40 40
41 41
42static void mpic_pasemi_msi_mask_irq(unsigned int irq) 42static void mpic_pasemi_msi_mask_irq(struct irq_data *data)
43{ 43{
44 pr_debug("mpic_pasemi_msi_mask_irq %d\n", irq); 44 pr_debug("mpic_pasemi_msi_mask_irq %d\n", data->irq);
45 mask_msi_irq(irq); 45 mask_msi_irq(data);
46 mpic_mask_irq(irq); 46 mpic_mask_irq(data->irq);
47} 47}
48 48
49static void mpic_pasemi_msi_unmask_irq(unsigned int irq) 49static void mpic_pasemi_msi_unmask_irq(struct irq_data *data)
50{ 50{
51 pr_debug("mpic_pasemi_msi_unmask_irq %d\n", irq); 51 pr_debug("mpic_pasemi_msi_unmask_irq %d\n", data->irq);
52 mpic_unmask_irq(irq); 52 mpic_unmask_irq(data->irq);
53 unmask_msi_irq(irq); 53 unmask_msi_irq(data);
54} 54}
55 55
56static struct irq_chip mpic_pasemi_msi_chip = { 56static struct irq_chip mpic_pasemi_msi_chip = {
57 .shutdown = mpic_pasemi_msi_mask_irq, 57 .irq_shutdown = mpic_pasemi_msi_mask_irq,
58 .mask = mpic_pasemi_msi_mask_irq, 58 .irq_mask = mpic_pasemi_msi_mask_irq,
59 .unmask = mpic_pasemi_msi_unmask_irq, 59 .irq_unmask = mpic_pasemi_msi_unmask_irq,
60 .eoi = mpic_end_irq, 60 .eoi = mpic_end_irq,
61 .set_type = mpic_set_irq_type, 61 .set_type = mpic_set_irq_type,
62 .set_affinity = mpic_set_affinity, 62 .set_affinity = mpic_set_affinity,
diff --git a/arch/powerpc/sysdev/mpic_u3msi.c b/arch/powerpc/sysdev/mpic_u3msi.c
index bcbfe79c704b..a2b028b4a202 100644
--- a/arch/powerpc/sysdev/mpic_u3msi.c
+++ b/arch/powerpc/sysdev/mpic_u3msi.c
@@ -23,22 +23,22 @@
23/* A bit ugly, can we get this from the pci_dev somehow? */ 23/* A bit ugly, can we get this from the pci_dev somehow? */
24static struct mpic *msi_mpic; 24static struct mpic *msi_mpic;
25 25
26static void mpic_u3msi_mask_irq(unsigned int irq) 26static void mpic_u3msi_mask_irq(struct irq_data *data)
27{ 27{
28 mask_msi_irq(irq); 28 mask_msi_irq(data);
29 mpic_mask_irq(irq); 29 mpic_mask_irq(data->irq);
30} 30}
31 31
32static void mpic_u3msi_unmask_irq(unsigned int irq) 32static void mpic_u3msi_unmask_irq(struct irq_data *data)
33{ 33{
34 mpic_unmask_irq(irq); 34 mpic_unmask_irq(data->irq);
35 unmask_msi_irq(irq); 35 unmask_msi_irq(data);
36} 36}
37 37
38static struct irq_chip mpic_u3msi_chip = { 38static struct irq_chip mpic_u3msi_chip = {
39 .shutdown = mpic_u3msi_mask_irq, 39 .irq_shutdown = mpic_u3msi_mask_irq,
40 .mask = mpic_u3msi_mask_irq, 40 .irq_mask = mpic_u3msi_mask_irq,
41 .unmask = mpic_u3msi_unmask_irq, 41 .irq_unmask = mpic_u3msi_unmask_irq,
42 .eoi = mpic_end_irq, 42 .eoi = mpic_end_irq,
43 .set_type = mpic_set_irq_type, 43 .set_type = mpic_set_irq_type,
44 .set_affinity = mpic_set_affinity, 44 .set_affinity = mpic_set_affinity,
diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c
index 24a0bb955b18..4260f368db52 100644
--- a/arch/powerpc/sysdev/pmi.c
+++ b/arch/powerpc/sysdev/pmi.c
@@ -114,7 +114,7 @@ static void pmi_notify_handlers(struct work_struct *work)
114 114
115 spin_lock(&data->handler_spinlock); 115 spin_lock(&data->handler_spinlock);
116 list_for_each_entry(handler, &data->handler, node) { 116 list_for_each_entry(handler, &data->handler, node) {
117 pr_debug(KERN_INFO "pmi: notifying handler %p\n", handler); 117 pr_debug("pmi: notifying handler %p\n", handler);
118 if (handler->type == data->msg.type) 118 if (handler->type == data->msg.type)
119 handler->handle_pmi_message(data->msg); 119 handler->handle_pmi_message(data->msg);
120 } 120 }
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index faa81b6a6612..c168c54e3c40 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -4,9 +4,7 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
4 4
5GCOV_PROFILE := n 5GCOV_PROFILE := n
6 6
7ifdef CONFIG_PPC64 7ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
8EXTRA_CFLAGS += -mno-minimal-toc
9endif
10 8
11obj-y += xmon.o start.o nonstdio.o 9obj-y += xmon.o start.o nonstdio.o
12 10
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f0777a47e3a5..75976a141947 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -95,6 +95,7 @@ config S390
95 select HAVE_KVM if 64BIT 95 select HAVE_KVM if 64BIT
96 select HAVE_ARCH_TRACEHOOK 96 select HAVE_ARCH_TRACEHOOK
97 select INIT_ALL_POSSIBLE 97 select INIT_ALL_POSSIBLE
98 select HAVE_IRQ_WORK
98 select HAVE_PERF_EVENTS 99 select HAVE_PERF_EVENTS
99 select HAVE_KERNEL_GZIP 100 select HAVE_KERNEL_GZIP
100 select HAVE_KERNEL_BZIP2 101 select HAVE_KERNEL_BZIP2
@@ -198,6 +199,13 @@ config HOTPLUG_CPU
198 can be controlled through /sys/devices/system/cpu/cpu#. 199 can be controlled through /sys/devices/system/cpu/cpu#.
199 Say N if you want to disable CPU hotplug. 200 Say N if you want to disable CPU hotplug.
200 201
202config SCHED_BOOK
203 bool "Book scheduler support"
204 depends on SMP
205 help
206 Book scheduler support improves the CPU scheduler's decision making
207 when dealing with machines that have several books.
208
201config MATHEMU 209config MATHEMU
202 bool "IEEE FPU emulation" 210 bool "IEEE FPU emulation"
203 depends on MARCH_G5 211 depends on MARCH_G5
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index aa819dac2360..975e3ab13cb5 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -152,6 +152,7 @@ static const struct file_operations prng_fops = {
152 .open = &prng_open, 152 .open = &prng_open,
153 .release = NULL, 153 .release = NULL,
154 .read = &prng_read, 154 .read = &prng_read,
155 .llseek = noop_llseek,
155}; 156};
156 157
157static struct miscdevice prng_dev = { 158static struct miscdevice prng_dev = {
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index 1211bb1d2f24..020e51c063d2 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -618,6 +618,7 @@ static const struct file_operations dbfs_d204_ops = {
618 .open = dbfs_d204_open, 618 .open = dbfs_d204_open,
619 .read = dbfs_d204_read, 619 .read = dbfs_d204_read,
620 .release = dbfs_d204_release, 620 .release = dbfs_d204_release,
621 .llseek = no_llseek,
621}; 622};
622 623
623static int hypfs_dbfs_init(void) 624static int hypfs_dbfs_init(void)
diff --git a/arch/s390/hypfs/hypfs_vm.c b/arch/s390/hypfs/hypfs_vm.c
index ee5ab1a578e7..26cf177f6a3a 100644
--- a/arch/s390/hypfs/hypfs_vm.c
+++ b/arch/s390/hypfs/hypfs_vm.c
@@ -275,6 +275,7 @@ static const struct file_operations dbfs_d2fc_ops = {
275 .open = dbfs_d2fc_open, 275 .open = dbfs_d2fc_open,
276 .read = dbfs_d2fc_read, 276 .read = dbfs_d2fc_read,
277 .release = dbfs_d2fc_release, 277 .release = dbfs_d2fc_release,
278 .llseek = no_llseek,
278}; 279};
279 280
280int hypfs_vm_init(void) 281int hypfs_vm_init(void)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 98a4a4c267a7..74d98670be27 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -449,6 +449,7 @@ static const struct file_operations hypfs_file_ops = {
449 .write = do_sync_write, 449 .write = do_sync_write,
450 .aio_read = hypfs_aio_read, 450 .aio_read = hypfs_aio_read,
451 .aio_write = hypfs_aio_write, 451 .aio_write = hypfs_aio_write,
452 .llseek = no_llseek,
452}; 453};
453 454
454static struct file_system_type hypfs_type = { 455static struct file_system_type hypfs_type = {
diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild
index 42e512ba8b43..287d7bbb6d36 100644
--- a/arch/s390/include/asm/Kbuild
+++ b/arch/s390/include/asm/Kbuild
@@ -5,6 +5,7 @@ header-y += chsc.h
5header-y += cmb.h 5header-y += cmb.h
6header-y += dasd.h 6header-y += dasd.h
7header-y += debug.h 7header-y += debug.h
8header-y += kvm_virtio.h
8header-y += monwriter.h 9header-y += monwriter.h
9header-y += qeth.h 10header-y += qeth.h
10header-y += schid.h 11header-y += schid.h
diff --git a/arch/s390/include/asm/hardirq.h b/arch/s390/include/asm/hardirq.h
index 498bc3892385..881d94590aeb 100644
--- a/arch/s390/include/asm/hardirq.h
+++ b/arch/s390/include/asm/hardirq.h
@@ -12,10 +12,6 @@
12#ifndef __ASM_HARDIRQ_H 12#ifndef __ASM_HARDIRQ_H
13#define __ASM_HARDIRQ_H 13#define __ASM_HARDIRQ_H
14 14
15#include <linux/threads.h>
16#include <linux/sched.h>
17#include <linux/cache.h>
18#include <linux/interrupt.h>
19#include <asm/lowcore.h> 15#include <asm/lowcore.h>
20 16
21#define local_softirq_pending() (S390_lowcore.softirq_pending) 17#define local_softirq_pending() (S390_lowcore.softirq_pending)
diff --git a/arch/s390/include/asm/ioctls.h b/arch/s390/include/asm/ioctls.h
index 2f3d8736361f..960a4c1ebdf1 100644
--- a/arch/s390/include/asm/ioctls.h
+++ b/arch/s390/include/asm/ioctls.h
@@ -1,94 +1,8 @@
1/*
2 * include/asm-s390/ioctls.h
3 *
4 * S390 version
5 *
6 * Derived from "include/asm-i386/ioctls.h"
7 */
8
9#ifndef __ARCH_S390_IOCTLS_H__ 1#ifndef __ARCH_S390_IOCTLS_H__
10#define __ARCH_S390_IOCTLS_H__ 2#define __ARCH_S390_IOCTLS_H__
11 3
12#include <asm/ioctl.h>
13
14/* 0x54 is just a magic number to make these relatively unique ('T') */
15
16#define TCGETS 0x5401
17#define TCSETS 0x5402
18#define TCSETSW 0x5403
19#define TCSETSF 0x5404
20#define TCGETA 0x5405
21#define TCSETA 0x5406
22#define TCSETAW 0x5407
23#define TCSETAF 0x5408
24#define TCSBRK 0x5409
25#define TCXONC 0x540A
26#define TCFLSH 0x540B
27#define TIOCEXCL 0x540C
28#define TIOCNXCL 0x540D
29#define TIOCSCTTY 0x540E
30#define TIOCGPGRP 0x540F
31#define TIOCSPGRP 0x5410
32#define TIOCOUTQ 0x5411
33#define TIOCSTI 0x5412
34#define TIOCGWINSZ 0x5413
35#define TIOCSWINSZ 0x5414
36#define TIOCMGET 0x5415
37#define TIOCMBIS 0x5416
38#define TIOCMBIC 0x5417
39#define TIOCMSET 0x5418
40#define TIOCGSOFTCAR 0x5419
41#define TIOCSSOFTCAR 0x541A
42#define FIONREAD 0x541B
43#define TIOCINQ FIONREAD
44#define TIOCLINUX 0x541C
45#define TIOCCONS 0x541D
46#define TIOCGSERIAL 0x541E
47#define TIOCSSERIAL 0x541F
48#define TIOCPKT 0x5420
49#define FIONBIO 0x5421
50#define TIOCNOTTY 0x5422
51#define TIOCSETD 0x5423
52#define TIOCGETD 0x5424
53#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
54#define TIOCSBRK 0x5427 /* BSD compatibility */
55#define TIOCCBRK 0x5428 /* BSD compatibility */
56#define TIOCGSID 0x5429 /* Return the session ID of FD */
57#define TCGETS2 _IOR('T',0x2A, struct termios2)
58#define TCSETS2 _IOW('T',0x2B, struct termios2)
59#define TCSETSW2 _IOW('T',0x2C, struct termios2)
60#define TCSETSF2 _IOW('T',0x2D, struct termios2)
61#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
62#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
63#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
64
65#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
66#define FIOCLEX 0x5451
67#define FIOASYNC 0x5452
68#define TIOCSERCONFIG 0x5453
69#define TIOCSERGWILD 0x5454
70#define TIOCSERSWILD 0x5455
71#define TIOCGLCKTRMIOS 0x5456
72#define TIOCSLCKTRMIOS 0x5457
73#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
74#define TIOCSERGETLSR 0x5459 /* Get line status register */
75#define TIOCSERGETMULTI 0x545A /* Get multiport config */
76#define TIOCSERSETMULTI 0x545B /* Set multiport config */
77
78#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
79#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
80#define FIOQSIZE 0x545E 4#define FIOQSIZE 0x545E
81 5
82/* Used for packet mode */ 6#include <asm-generic/ioctls.h>
83#define TIOCPKT_DATA 0
84#define TIOCPKT_FLUSHREAD 1
85#define TIOCPKT_FLUSHWRITE 2
86#define TIOCPKT_STOP 4
87#define TIOCPKT_START 8
88#define TIOCPKT_NOSTOP 16
89#define TIOCPKT_DOSTOP 32
90#define TIOCPKT_IOCTL 64
91
92#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
93 7
94#endif 8#endif
diff --git a/arch/s390/include/asm/irqflags.h b/arch/s390/include/asm/irqflags.h
index 15b3ac253898..865d6d891ace 100644
--- a/arch/s390/include/asm/irqflags.h
+++ b/arch/s390/include/asm/irqflags.h
@@ -8,8 +8,8 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10 10
11/* store then or system mask. */ 11/* store then OR system mask. */
12#define __raw_local_irq_stosm(__or) \ 12#define __arch_local_irq_stosm(__or) \
13({ \ 13({ \
14 unsigned long __mask; \ 14 unsigned long __mask; \
15 asm volatile( \ 15 asm volatile( \
@@ -18,8 +18,8 @@
18 __mask; \ 18 __mask; \
19}) 19})
20 20
21/* store then and system mask. */ 21/* store then AND system mask. */
22#define __raw_local_irq_stnsm(__and) \ 22#define __arch_local_irq_stnsm(__and) \
23({ \ 23({ \
24 unsigned long __mask; \ 24 unsigned long __mask; \
25 asm volatile( \ 25 asm volatile( \
@@ -29,39 +29,44 @@
29}) 29})
30 30
31/* set system mask. */ 31/* set system mask. */
32#define __raw_local_irq_ssm(__mask) \ 32static inline void __arch_local_irq_ssm(unsigned long flags)
33({ \ 33{
34 asm volatile("ssm %0" : : "Q" (__mask) : "memory"); \ 34 asm volatile("ssm %0" : : "Q" (flags) : "memory");
35}) 35}
36 36
37/* interrupt control.. */ 37static inline unsigned long arch_local_save_flags(void)
38static inline unsigned long raw_local_irq_enable(void)
39{ 38{
40 return __raw_local_irq_stosm(0x03); 39 return __arch_local_irq_stosm(0x00);
41} 40}
42 41
43static inline unsigned long raw_local_irq_disable(void) 42static inline unsigned long arch_local_irq_save(void)
44{ 43{
45 return __raw_local_irq_stnsm(0xfc); 44 return __arch_local_irq_stnsm(0xfc);
46} 45}
47 46
48#define raw_local_save_flags(x) \ 47static inline void arch_local_irq_disable(void)
49do { \ 48{
50 typecheck(unsigned long, x); \ 49 arch_local_irq_save();
51 (x) = __raw_local_irq_stosm(0x00); \ 50}
52} while (0)
53 51
54static inline void raw_local_irq_restore(unsigned long flags) 52static inline void arch_local_irq_enable(void)
55{ 53{
56 __raw_local_irq_ssm(flags); 54 __arch_local_irq_stosm(0x03);
57} 55}
58 56
59static inline int raw_irqs_disabled_flags(unsigned long flags) 57static inline void arch_local_irq_restore(unsigned long flags)
58{
59 __arch_local_irq_ssm(flags);
60}
61
62static inline bool arch_irqs_disabled_flags(unsigned long flags)
60{ 63{
61 return !(flags & (3UL << (BITS_PER_LONG - 8))); 64 return !(flags & (3UL << (BITS_PER_LONG - 8)));
62} 65}
63 66
64/* For spinlocks etc */ 67static inline bool arch_irqs_disabled(void)
65#define raw_local_irq_save(x) ((x) = raw_local_irq_disable()) 68{
69 return arch_irqs_disabled_flags(arch_local_save_flags());
70}
66 71
67#endif /* __ASM_IRQFLAGS_H */ 72#endif /* __ASM_IRQFLAGS_H */
diff --git a/arch/s390/include/asm/kvm_virtio.h b/arch/s390/include/asm/kvm_virtio.h
index acdfdff26611..72f614181eff 100644
--- a/arch/s390/include/asm/kvm_virtio.h
+++ b/arch/s390/include/asm/kvm_virtio.h
@@ -54,4 +54,11 @@ struct kvm_vqconfig {
54 * This is pagesize for historical reasons. */ 54 * This is pagesize for historical reasons. */
55#define KVM_S390_VIRTIO_RING_ALIGN 4096 55#define KVM_S390_VIRTIO_RING_ALIGN 4096
56 56
57
58/* These values are supposed to be in ext_params on an interrupt */
59#define VIRTIO_PARAM_MASK 0xff
60#define VIRTIO_PARAM_VRING_INTERRUPT 0x0
61#define VIRTIO_PARAM_CONFIG_CHANGED 0x1
62#define VIRTIO_PARAM_DEV_ADD 0x2
63
57#endif 64#endif
diff --git a/arch/s390/include/asm/perf_event.h b/arch/s390/include/asm/perf_event.h
index 3840cbe77637..a75f168d2718 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -4,7 +4,6 @@
4 * Copyright 2009 Martin Schwidefsky, IBM Corporation. 4 * Copyright 2009 Martin Schwidefsky, IBM Corporation.
5 */ 5 */
6 6
7static inline void set_perf_event_pending(void) {} 7/* Empty, just to avoid compiling error */
8static inline void clear_perf_event_pending(void) {}
9 8
10#define PERF_EVENT_INDEX_OFFSET 0 9#define PERF_EVENT_INDEX_OFFSET 0
diff --git a/arch/s390/include/asm/qdio.h b/arch/s390/include/asm/qdio.h
index 2ba630276295..46e96bc1f5a1 100644
--- a/arch/s390/include/asm/qdio.h
+++ b/arch/s390/include/asm/qdio.h
@@ -360,6 +360,7 @@ struct qdio_initialize {
360 unsigned int no_output_qs; 360 unsigned int no_output_qs;
361 qdio_handler_t *input_handler; 361 qdio_handler_t *input_handler;
362 qdio_handler_t *output_handler; 362 qdio_handler_t *output_handler;
363 void (*queue_start_poll) (struct ccw_device *, int, unsigned long);
363 unsigned long int_parm; 364 unsigned long int_parm;
364 void **input_sbal_addr_array; 365 void **input_sbal_addr_array;
365 void **output_sbal_addr_array; 366 void **output_sbal_addr_array;
@@ -377,11 +378,13 @@ struct qdio_initialize {
377extern int qdio_allocate(struct qdio_initialize *); 378extern int qdio_allocate(struct qdio_initialize *);
378extern int qdio_establish(struct qdio_initialize *); 379extern int qdio_establish(struct qdio_initialize *);
379extern int qdio_activate(struct ccw_device *); 380extern int qdio_activate(struct ccw_device *);
380 381extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
381extern int do_QDIO(struct ccw_device *cdev, unsigned int callflags, 382 unsigned int);
382 int q_nr, unsigned int bufnr, unsigned int count); 383extern int qdio_start_irq(struct ccw_device *, int);
383extern int qdio_shutdown(struct ccw_device*, int); 384extern int qdio_stop_irq(struct ccw_device *, int);
385extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
386extern int qdio_shutdown(struct ccw_device *, int);
384extern int qdio_free(struct ccw_device *); 387extern int qdio_free(struct ccw_device *);
385extern int qdio_get_ssqd_desc(struct ccw_device *dev, struct qdio_ssqd_desc*); 388extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
386 389
387#endif /* __QDIO_H__ */ 390#endif /* __QDIO_H__ */
diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
index cef66210c846..1f2ebc4afd82 100644
--- a/arch/s390/include/asm/system.h
+++ b/arch/s390/include/asm/system.h
@@ -97,7 +97,6 @@ static inline void restore_access_regs(unsigned int *acrs)
97 97
98extern void account_vtime(struct task_struct *, struct task_struct *); 98extern void account_vtime(struct task_struct *, struct task_struct *);
99extern void account_tick_vtime(struct task_struct *); 99extern void account_tick_vtime(struct task_struct *);
100extern void account_system_vtime(struct task_struct *);
101 100
102#ifdef CONFIG_PFAULT 101#ifdef CONFIG_PFAULT
103extern void pfault_irq_init(void); 102extern void pfault_irq_init(void);
@@ -399,7 +398,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
399static inline void 398static inline void
400__set_psw_mask(unsigned long mask) 399__set_psw_mask(unsigned long mask)
401{ 400{
402 __load_psw_mask(mask | (__raw_local_irq_stosm(0x00) & ~(-1UL >> 8))); 401 __load_psw_mask(mask | (arch_local_save_flags() & ~(-1UL >> 8)));
403} 402}
404 403
405#define local_mcck_enable() __set_psw_mask(psw_kernel_bits) 404#define local_mcck_enable() __set_psw_mask(psw_kernel_bits)
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index 831bd033ea77..051107a2c5e2 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -3,15 +3,32 @@
3 3
4#include <linux/cpumask.h> 4#include <linux/cpumask.h>
5 5
6#define mc_capable() (1)
7
8const struct cpumask *cpu_coregroup_mask(unsigned int cpu);
9
10extern unsigned char cpu_core_id[NR_CPUS]; 6extern unsigned char cpu_core_id[NR_CPUS];
11extern cpumask_t cpu_core_map[NR_CPUS]; 7extern cpumask_t cpu_core_map[NR_CPUS];
12 8
9static inline const struct cpumask *cpu_coregroup_mask(unsigned int cpu)
10{
11 return &cpu_core_map[cpu];
12}
13
13#define topology_core_id(cpu) (cpu_core_id[cpu]) 14#define topology_core_id(cpu) (cpu_core_id[cpu])
14#define topology_core_cpumask(cpu) (&cpu_core_map[cpu]) 15#define topology_core_cpumask(cpu) (&cpu_core_map[cpu])
16#define mc_capable() (1)
17
18#ifdef CONFIG_SCHED_BOOK
19
20extern unsigned char cpu_book_id[NR_CPUS];
21extern cpumask_t cpu_book_map[NR_CPUS];
22
23static inline const struct cpumask *cpu_book_mask(unsigned int cpu)
24{
25 return &cpu_book_map[cpu];
26}
27
28#define topology_book_id(cpu) (cpu_book_id[cpu])
29#define topology_book_cpumask(cpu) (&cpu_book_map[cpu])
30
31#endif /* CONFIG_SCHED_BOOK */
15 32
16int topology_set_cpu_management(int fc); 33int topology_set_cpu_management(int fc);
17void topology_schedule_update(void); 34void topology_schedule_update(void);
@@ -30,6 +47,8 @@ static inline void s390_init_cpu_topology(void)
30}; 47};
31#endif 48#endif
32 49
50#define SD_BOOK_INIT SD_CPU_INIT
51
33#include <asm-generic/topology.h> 52#include <asm-generic/topology.h>
34 53
35#endif /* _ASM_S390_TOPOLOGY_H */ 54#endif /* _ASM_S390_TOPOLOGY_H */
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 98192261491d..5ad6bc078bfd 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -174,6 +174,7 @@ static const struct file_operations debug_file_ops = {
174 .write = debug_input, 174 .write = debug_input,
175 .open = debug_open, 175 .open = debug_open,
176 .release = debug_close, 176 .release = debug_close,
177 .llseek = no_llseek,
177}; 178};
178 179
179static struct dentry *debug_debugfs_root_entry; 180static struct dentry *debug_debugfs_root_entry;
diff --git a/arch/s390/kernel/mem_detect.c b/arch/s390/kernel/mem_detect.c
index 559af0d07878..0fbe4e32f7ba 100644
--- a/arch/s390/kernel/mem_detect.c
+++ b/arch/s390/kernel/mem_detect.c
@@ -54,11 +54,11 @@ void detect_memory_layout(struct mem_chunk chunk[])
54 * right thing and we don't get scheduled away with low address 54 * right thing and we don't get scheduled away with low address
55 * protection disabled. 55 * protection disabled.
56 */ 56 */
57 flags = __raw_local_irq_stnsm(0xf8); 57 flags = __arch_local_irq_stnsm(0xf8);
58 __ctl_store(cr0, 0, 0); 58 __ctl_store(cr0, 0, 0);
59 __ctl_clear_bit(0, 28); 59 __ctl_clear_bit(0, 28);
60 find_memory_chunks(chunk); 60 find_memory_chunks(chunk);
61 __ctl_load(cr0, 0, 0); 61 __ctl_load(cr0, 0, 0);
62 __raw_local_irq_ssm(flags); 62 arch_local_irq_restore(flags);
63} 63}
64EXPORT_SYMBOL(detect_memory_layout); 64EXPORT_SYMBOL(detect_memory_layout);
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index 22cfd634c355..f7167ee4604c 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -407,10 +407,9 @@ int module_finalize(const Elf_Ehdr *hdr,
407{ 407{
408 vfree(me->arch.syminfo); 408 vfree(me->arch.syminfo);
409 me->arch.syminfo = NULL; 409 me->arch.syminfo = NULL;
410 return module_bug_finalize(hdr, sechdrs, me); 410 return 0;
411} 411}
412 412
413void module_arch_cleanup(struct module *mod) 413void module_arch_cleanup(struct module *mod)
414{ 414{
415 module_bug_cleanup(mod);
416} 415}
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index bcef00766a64..13559c993847 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -57,8 +57,8 @@ struct tl_info {
57 union tl_entry tle[0]; 57 union tl_entry tle[0];
58}; 58};
59 59
60struct core_info { 60struct mask_info {
61 struct core_info *next; 61 struct mask_info *next;
62 unsigned char id; 62 unsigned char id;
63 cpumask_t mask; 63 cpumask_t mask;
64}; 64};
@@ -66,7 +66,6 @@ struct core_info {
66static int topology_enabled; 66static int topology_enabled;
67static void topology_work_fn(struct work_struct *work); 67static void topology_work_fn(struct work_struct *work);
68static struct tl_info *tl_info; 68static struct tl_info *tl_info;
69static struct core_info core_info;
70static int machine_has_topology; 69static int machine_has_topology;
71static struct timer_list topology_timer; 70static struct timer_list topology_timer;
72static void set_topology_timer(void); 71static void set_topology_timer(void);
@@ -74,38 +73,37 @@ static DECLARE_WORK(topology_work, topology_work_fn);
74/* topology_lock protects the core linked list */ 73/* topology_lock protects the core linked list */
75static DEFINE_SPINLOCK(topology_lock); 74static DEFINE_SPINLOCK(topology_lock);
76 75
76static struct mask_info core_info;
77cpumask_t cpu_core_map[NR_CPUS]; 77cpumask_t cpu_core_map[NR_CPUS];
78unsigned char cpu_core_id[NR_CPUS]; 78unsigned char cpu_core_id[NR_CPUS];
79 79
80static cpumask_t cpu_coregroup_map(unsigned int cpu) 80#ifdef CONFIG_SCHED_BOOK
81static struct mask_info book_info;
82cpumask_t cpu_book_map[NR_CPUS];
83unsigned char cpu_book_id[NR_CPUS];
84#endif
85
86static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
81{ 87{
82 struct core_info *core = &core_info;
83 unsigned long flags;
84 cpumask_t mask; 88 cpumask_t mask;
85 89
86 cpus_clear(mask); 90 cpus_clear(mask);
87 if (!topology_enabled || !machine_has_topology) 91 if (!topology_enabled || !machine_has_topology)
88 return cpu_possible_map; 92 return cpu_possible_map;
89 spin_lock_irqsave(&topology_lock, flags); 93 while (info) {
90 while (core) { 94 if (cpu_isset(cpu, info->mask)) {
91 if (cpu_isset(cpu, core->mask)) { 95 mask = info->mask;
92 mask = core->mask;
93 break; 96 break;
94 } 97 }
95 core = core->next; 98 info = info->next;
96 } 99 }
97 spin_unlock_irqrestore(&topology_lock, flags);
98 if (cpus_empty(mask)) 100 if (cpus_empty(mask))
99 mask = cpumask_of_cpu(cpu); 101 mask = cpumask_of_cpu(cpu);
100 return mask; 102 return mask;
101} 103}
102 104
103const struct cpumask *cpu_coregroup_mask(unsigned int cpu) 105static void add_cpus_to_mask(struct tl_cpu *tl_cpu, struct mask_info *book,
104{ 106 struct mask_info *core)
105 return &cpu_core_map[cpu];
106}
107
108static void add_cpus_to_core(struct tl_cpu *tl_cpu, struct core_info *core)
109{ 107{
110 unsigned int cpu; 108 unsigned int cpu;
111 109
@@ -117,23 +115,35 @@ static void add_cpus_to_core(struct tl_cpu *tl_cpu, struct core_info *core)
117 115
118 rcpu = CPU_BITS - 1 - cpu + tl_cpu->origin; 116 rcpu = CPU_BITS - 1 - cpu + tl_cpu->origin;
119 for_each_present_cpu(lcpu) { 117 for_each_present_cpu(lcpu) {
120 if (cpu_logical_map(lcpu) == rcpu) { 118 if (cpu_logical_map(lcpu) != rcpu)
121 cpu_set(lcpu, core->mask); 119 continue;
122 cpu_core_id[lcpu] = core->id; 120#ifdef CONFIG_SCHED_BOOK
123 smp_cpu_polarization[lcpu] = tl_cpu->pp; 121 cpu_set(lcpu, book->mask);
124 } 122 cpu_book_id[lcpu] = book->id;
123#endif
124 cpu_set(lcpu, core->mask);
125 cpu_core_id[lcpu] = core->id;
126 smp_cpu_polarization[lcpu] = tl_cpu->pp;
125 } 127 }
126 } 128 }
127} 129}
128 130
129static void clear_cores(void) 131static void clear_masks(void)
130{ 132{
131 struct core_info *core = &core_info; 133 struct mask_info *info;
132 134
133 while (core) { 135 info = &core_info;
134 cpus_clear(core->mask); 136 while (info) {
135 core = core->next; 137 cpus_clear(info->mask);
138 info = info->next;
139 }
140#ifdef CONFIG_SCHED_BOOK
141 info = &book_info;
142 while (info) {
143 cpus_clear(info->mask);
144 info = info->next;
136 } 145 }
146#endif
137} 147}
138 148
139static union tl_entry *next_tle(union tl_entry *tle) 149static union tl_entry *next_tle(union tl_entry *tle)
@@ -146,29 +156,36 @@ static union tl_entry *next_tle(union tl_entry *tle)
146 156
147static void tl_to_cores(struct tl_info *info) 157static void tl_to_cores(struct tl_info *info)
148{ 158{
159#ifdef CONFIG_SCHED_BOOK
160 struct mask_info *book = &book_info;
161#else
162 struct mask_info *book = NULL;
163#endif
164 struct mask_info *core = &core_info;
149 union tl_entry *tle, *end; 165 union tl_entry *tle, *end;
150 struct core_info *core = &core_info; 166
151 167
152 spin_lock_irq(&topology_lock); 168 spin_lock_irq(&topology_lock);
153 clear_cores(); 169 clear_masks();
154 tle = info->tle; 170 tle = info->tle;
155 end = (union tl_entry *)((unsigned long)info + info->length); 171 end = (union tl_entry *)((unsigned long)info + info->length);
156 while (tle < end) { 172 while (tle < end) {
157 switch (tle->nl) { 173 switch (tle->nl) {
158 case 5: 174#ifdef CONFIG_SCHED_BOOK
159 case 4:
160 case 3:
161 case 2: 175 case 2:
176 book = book->next;
177 book->id = tle->container.id;
162 break; 178 break;
179#endif
163 case 1: 180 case 1:
164 core = core->next; 181 core = core->next;
165 core->id = tle->container.id; 182 core->id = tle->container.id;
166 break; 183 break;
167 case 0: 184 case 0:
168 add_cpus_to_core(&tle->cpu, core); 185 add_cpus_to_mask(&tle->cpu, book, core);
169 break; 186 break;
170 default: 187 default:
171 clear_cores(); 188 clear_masks();
172 machine_has_topology = 0; 189 machine_has_topology = 0;
173 goto out; 190 goto out;
174 } 191 }
@@ -221,10 +238,29 @@ int topology_set_cpu_management(int fc)
221 238
222static void update_cpu_core_map(void) 239static void update_cpu_core_map(void)
223{ 240{
241 unsigned long flags;
224 int cpu; 242 int cpu;
225 243
226 for_each_possible_cpu(cpu) 244 spin_lock_irqsave(&topology_lock, flags);
227 cpu_core_map[cpu] = cpu_coregroup_map(cpu); 245 for_each_possible_cpu(cpu) {
246 cpu_core_map[cpu] = cpu_group_map(&core_info, cpu);
247#ifdef CONFIG_SCHED_BOOK
248 cpu_book_map[cpu] = cpu_group_map(&book_info, cpu);
249#endif
250 }
251 spin_unlock_irqrestore(&topology_lock, flags);
252}
253
254static void store_topology(struct tl_info *info)
255{
256#ifdef CONFIG_SCHED_BOOK
257 int rc;
258
259 rc = stsi(info, 15, 1, 3);
260 if (rc != -ENOSYS)
261 return;
262#endif
263 stsi(info, 15, 1, 2);
228} 264}
229 265
230int arch_update_cpu_topology(void) 266int arch_update_cpu_topology(void)
@@ -238,7 +274,7 @@ int arch_update_cpu_topology(void)
238 topology_update_polarization_simple(); 274 topology_update_polarization_simple();
239 return 0; 275 return 0;
240 } 276 }
241 stsi(info, 15, 1, 2); 277 store_topology(info);
242 tl_to_cores(info); 278 tl_to_cores(info);
243 update_cpu_core_map(); 279 update_cpu_core_map();
244 for_each_online_cpu(cpu) { 280 for_each_online_cpu(cpu) {
@@ -299,12 +335,24 @@ out:
299} 335}
300__initcall(init_topology_update); 336__initcall(init_topology_update);
301 337
338static void alloc_masks(struct tl_info *info, struct mask_info *mask, int offset)
339{
340 int i, nr_masks;
341
342 nr_masks = info->mag[NR_MAG - offset];
343 for (i = 0; i < info->mnest - offset; i++)
344 nr_masks *= info->mag[NR_MAG - offset - 1 - i];
345 nr_masks = max(nr_masks, 1);
346 for (i = 0; i < nr_masks; i++) {
347 mask->next = alloc_bootmem(sizeof(struct mask_info));
348 mask = mask->next;
349 }
350}
351
302void __init s390_init_cpu_topology(void) 352void __init s390_init_cpu_topology(void)
303{ 353{
304 unsigned long long facility_bits; 354 unsigned long long facility_bits;
305 struct tl_info *info; 355 struct tl_info *info;
306 struct core_info *core;
307 int nr_cores;
308 int i; 356 int i;
309 357
310 if (stfle(&facility_bits, 1) <= 0) 358 if (stfle(&facility_bits, 1) <= 0)
@@ -315,25 +363,13 @@ void __init s390_init_cpu_topology(void)
315 363
316 tl_info = alloc_bootmem_pages(PAGE_SIZE); 364 tl_info = alloc_bootmem_pages(PAGE_SIZE);
317 info = tl_info; 365 info = tl_info;
318 stsi(info, 15, 1, 2); 366 store_topology(info);
319
320 nr_cores = info->mag[NR_MAG - 2];
321 for (i = 0; i < info->mnest - 2; i++)
322 nr_cores *= info->mag[NR_MAG - 3 - i];
323
324 pr_info("The CPU configuration topology of the machine is:"); 367 pr_info("The CPU configuration topology of the machine is:");
325 for (i = 0; i < NR_MAG; i++) 368 for (i = 0; i < NR_MAG; i++)
326 printk(" %d", info->mag[i]); 369 printk(" %d", info->mag[i]);
327 printk(" / %d\n", info->mnest); 370 printk(" / %d\n", info->mnest);
328 371 alloc_masks(info, &core_info, 2);
329 core = &core_info; 372#ifdef CONFIG_SCHED_BOOK
330 for (i = 0; i < nr_cores; i++) { 373 alloc_masks(info, &book_info, 3);
331 core->next = alloc_bootmem(sizeof(struct core_info)); 374#endif
332 core = core->next;
333 if (!core)
334 goto error;
335 }
336 return;
337error:
338 machine_has_topology = 0;
339} 375}
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 30eb6d02ddb8..94b8ba2ec857 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -50,7 +50,6 @@ EXPORT_SYMBOL(empty_zero_page);
50 */ 50 */
51void __init paging_init(void) 51void __init paging_init(void)
52{ 52{
53 static const int ssm_mask = 0x04000000L;
54 unsigned long max_zone_pfns[MAX_NR_ZONES]; 53 unsigned long max_zone_pfns[MAX_NR_ZONES];
55 unsigned long pgd_type; 54 unsigned long pgd_type;
56 55
@@ -72,7 +71,7 @@ void __init paging_init(void)
72 __ctl_load(S390_lowcore.kernel_asce, 1, 1); 71 __ctl_load(S390_lowcore.kernel_asce, 1, 1);
73 __ctl_load(S390_lowcore.kernel_asce, 7, 7); 72 __ctl_load(S390_lowcore.kernel_asce, 7, 7);
74 __ctl_load(S390_lowcore.kernel_asce, 13, 13); 73 __ctl_load(S390_lowcore.kernel_asce, 13, 13);
75 __raw_local_irq_ssm(ssm_mask); 74 arch_local_irq_restore(4UL << (BITS_PER_LONG - 8));
76 75
77 atomic_set(&init_mm.context.attach_count, 1); 76 atomic_set(&init_mm.context.attach_count, 1);
78 77
diff --git a/arch/s390/mm/maccess.c b/arch/s390/mm/maccess.c
index a8c2af8c650f..71a4b0d34be0 100644
--- a/arch/s390/mm/maccess.c
+++ b/arch/s390/mm/maccess.c
@@ -71,7 +71,7 @@ int memcpy_real(void *dest, void *src, size_t count)
71 71
72 if (!count) 72 if (!count)
73 return 0; 73 return 0;
74 flags = __raw_local_irq_stnsm(0xf8UL); 74 flags = __arch_local_irq_stnsm(0xf8UL);
75 asm volatile ( 75 asm volatile (
76 "0: mvcle %1,%2,0x0\n" 76 "0: mvcle %1,%2,0x0\n"
77 "1: jo 0b\n" 77 "1: jo 0b\n"
@@ -82,6 +82,6 @@ int memcpy_real(void *dest, void *src, size_t count)
82 "+d" (_len2), "=m" (*((long *) dest)) 82 "+d" (_len2), "=m" (*((long *) dest))
83 : "m" (*((long *) src)) 83 : "m" (*((long *) src))
84 : "cc", "memory"); 84 : "cc", "memory");
85 __raw_local_irq_ssm(flags); 85 arch_local_irq_restore(flags);
86 return rc; 86 return rc;
87} 87}
diff --git a/arch/score/include/asm/irqflags.h b/arch/score/include/asm/irqflags.h
index 690a6cae7294..5c7563891e28 100644
--- a/arch/score/include/asm/irqflags.h
+++ b/arch/score/include/asm/irqflags.h
@@ -3,107 +3,118 @@
3 3
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5 5
6#define raw_local_irq_save(x) \ 6#include <linux/types.h>
7{ \ 7
8 __asm__ __volatile__( \ 8static inline unsigned long arch_local_save_flags(void)
9 "mfcr r8, cr0;" \ 9{
10 "li r9, 0xfffffffe;" \ 10 unsigned long flags;
11 "nop;" \ 11
12 "mv %0, r8;" \ 12 asm volatile(
13 "and r8, r8, r9;" \ 13 " mfcr r8, cr0 \n"
14 "mtcr r8, cr0;" \ 14 " nop \n"
15 "nop;" \ 15 " nop \n"
16 "nop;" \ 16 " mv %0, r8 \n"
17 "nop;" \ 17 " nop \n"
18 "nop;" \ 18 " nop \n"
19 "nop;" \ 19 " nop \n"
20 : "=r" (x) \ 20 " nop \n"
21 : \ 21 " nop \n"
22 : "r8", "r9" \ 22 " ldi r9, 0x1 \n"
23 ); \ 23 " and %0, %0, r9 \n"
24 : "=r" (flags)
25 :
26 : "r8", "r9");
27 return flags;
24} 28}
25 29
26#define raw_local_irq_restore(x) \ 30static inline unsigned long arch_local_irq_save(void)
27{ \ 31{
28 __asm__ __volatile__( \ 32 unsigned long flags
29 "mfcr r8, cr0;" \ 33
30 "ldi r9, 0x1;" \ 34 asm volatile(
31 "and %0, %0, r9;" \ 35 " mfcr r8, cr0 \n"
32 "or r8, r8, %0;" \ 36 " li r9, 0xfffffffe \n"
33 "mtcr r8, cr0;" \ 37 " nop \n"
34 "nop;" \ 38 " mv %0, r8 \n"
35 "nop;" \ 39 " and r8, r8, r9 \n"
36 "nop;" \ 40 " mtcr r8, cr0 \n"
37 "nop;" \ 41 " nop \n"
38 "nop;" \ 42 " nop \n"
39 : \ 43 " nop \n"
40 : "r"(x) \ 44 " nop \n"
41 : "r8", "r9" \ 45 " nop \n"
42 ); \ 46 : "=r" (flags)
47 :
48 : "r8", "r9", "memory");
49
50 return flags;
43} 51}
44 52
45#define raw_local_irq_enable(void) \ 53static inline void arch_local_irq_restore(unsigned long flags)
46{ \ 54{
47 __asm__ __volatile__( \ 55 asm volatile(
48 "mfcr\tr8,cr0;" \ 56 " mfcr r8, cr0 \n"
49 "nop;" \ 57 " ldi r9, 0x1 \n"
50 "nop;" \ 58 " and %0, %0, r9 \n"
51 "ori\tr8,0x1;" \ 59 " or r8, r8, %0 \n"
52 "mtcr\tr8,cr0;" \ 60 " mtcr r8, cr0 \n"
53 "nop;" \ 61 " nop \n"
54 "nop;" \ 62 " nop \n"
55 "nop;" \ 63 " nop \n"
56 "nop;" \ 64 " nop \n"
57 "nop;" \ 65 " nop \n"
58 : \ 66 :
59 : \ 67 : "r"(flags)
60 : "r8"); \ 68 : "r8", "r9", "memory");
61} 69}
62 70
63#define raw_local_irq_disable(void) \ 71static inline void arch_local_irq_enable(void)
64{ \ 72{
65 __asm__ __volatile__( \ 73 asm volatile(
66 "mfcr\tr8,cr0;" \ 74 " mfcr r8,cr0 \n"
67 "nop;" \ 75 " nop \n"
68 "nop;" \ 76 " nop \n"
69 "srli\tr8,r8,1;" \ 77 " ori r8,0x1 \n"
70 "slli\tr8,r8,1;" \ 78 " mtcr r8,cr0 \n"
71 "mtcr\tr8,cr0;" \ 79 " nop \n"
72 "nop;" \ 80 " nop \n"
73 "nop;" \ 81 " nop \n"
74 "nop;" \ 82 " nop \n"
75 "nop;" \ 83 " nop \n"
76 "nop;" \ 84 :
77 : \ 85 :
78 : \ 86 : "r8", "memory");
79 : "r8"); \
80} 87}
81 88
82#define raw_local_save_flags(x) \ 89static inline void arch_local_irq_disable(void)
83{ \ 90{
84 __asm__ __volatile__( \ 91 asm volatile(
85 "mfcr r8, cr0;" \ 92 " mfcr r8,cr0 \n"
86 "nop;" \ 93 " nop \n"
87 "nop;" \ 94 " nop \n"
88 "mv %0, r8;" \ 95 " srli r8,r8,1 \n"
89 "nop;" \ 96 " slli r8,r8,1 \n"
90 "nop;" \ 97 " mtcr r8,cr0 \n"
91 "nop;" \ 98 " nop \n"
92 "nop;" \ 99 " nop \n"
93 "nop;" \ 100 " nop \n"
94 "ldi r9, 0x1;" \ 101 " nop \n"
95 "and %0, %0, r9;" \ 102 " nop \n"
96 : "=r" (x) \ 103 :
97 : \ 104 :
98 : "r8", "r9" \ 105 : "r8", "memory");
99 ); \
100} 106}
101 107
102static inline int raw_irqs_disabled_flags(unsigned long flags) 108static inline bool arch_irqs_disabled_flags(unsigned long flags)
103{ 109{
104 return !(flags & 1); 110 return !(flags & 1);
105} 111}
106 112
107#endif 113static inline bool arch_irqs_disabled(void)
114{
115 return arch_irqs_disabled_flags(arch_local_save_flags());
116}
117
118#endif /* __ASSEMBLY__ */
108 119
109#endif /* _ASM_SCORE_IRQFLAGS_H */ 120#endif /* _ASM_SCORE_IRQFLAGS_H */
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 33990fa95af0..0f40fc35d0a2 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -16,6 +16,7 @@ config SUPERH
16 select HAVE_ARCH_TRACEHOOK 16 select HAVE_ARCH_TRACEHOOK
17 select HAVE_DMA_API_DEBUG 17 select HAVE_DMA_API_DEBUG
18 select HAVE_DMA_ATTRS 18 select HAVE_DMA_ATTRS
19 select HAVE_IRQ_WORK
19 select HAVE_PERF_EVENTS 20 select HAVE_PERF_EVENTS
20 select PERF_USE_VMALLOC 21 select PERF_USE_VMALLOC
21 select HAVE_KERNEL_GZIP 22 select HAVE_KERNEL_GZIP
@@ -23,6 +24,7 @@ config SUPERH
23 select HAVE_KERNEL_LZMA 24 select HAVE_KERNEL_LZMA
24 select HAVE_KERNEL_LZO 25 select HAVE_KERNEL_LZO
25 select HAVE_SYSCALL_TRACEPOINTS 26 select HAVE_SYSCALL_TRACEPOINTS
27 select HAVE_REGS_AND_STACK_ACCESS_API
26 select RTC_LIB 28 select RTC_LIB
27 select GENERIC_ATOMIC64 29 select GENERIC_ATOMIC64
28 help 30 help
@@ -45,7 +47,7 @@ config SUPERH32
45 select HAVE_ARCH_KGDB 47 select HAVE_ARCH_KGDB
46 select HAVE_HW_BREAKPOINT 48 select HAVE_HW_BREAKPOINT
47 select HAVE_MIXED_BREAKPOINTS_REGS 49 select HAVE_MIXED_BREAKPOINTS_REGS
48 select PERF_EVENTS if HAVE_HW_BREAKPOINT 50 select PERF_EVENTS
49 select ARCH_HIBERNATION_POSSIBLE if MMU 51 select ARCH_HIBERNATION_POSSIBLE if MMU
50 52
51config SUPERH64 53config SUPERH64
@@ -249,6 +251,11 @@ config ARCH_SHMOBILE
249 select PM 251 select PM
250 select PM_RUNTIME 252 select PM_RUNTIME
251 253
254config CPU_HAS_PMU
255 depends on CPU_SH4 || CPU_SH4A
256 default y
257 bool
258
252if SUPERH32 259if SUPERH32
253 260
254choice 261choice
@@ -465,6 +472,7 @@ config CPU_SUBTYPE_SHX3
465 select CPU_SH4A 472 select CPU_SH4A
466 select CPU_SHX3 473 select CPU_SHX3
467 select GENERIC_CLOCKEVENTS_BROADCAST if SMP 474 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
475 select ARCH_REQUIRE_GPIOLIB
468 476
469# SH4AL-DSP Processor Support 477# SH4AL-DSP Processor Support
470 478
@@ -569,7 +577,7 @@ config SH_CLK_CPG
569config SH_CLK_CPG_LEGACY 577config SH_CLK_CPG_LEGACY
570 depends on SH_CLK_CPG 578 depends on SH_CLK_CPG
571 def_bool y if !CPU_SUBTYPE_SH7785 && !ARCH_SHMOBILE && \ 579 def_bool y if !CPU_SUBTYPE_SH7785 && !ARCH_SHMOBILE && \
572 !CPU_SUBTYPE_SH7786 580 !CPU_SHX3 && !CPU_SUBTYPE_SH7757
573 581
574config SH_CLK_MD 582config SH_CLK_MD
575 int "CPU Mode Pin Setting" 583 int "CPU Mode Pin Setting"
@@ -738,6 +746,14 @@ config GUSA_RB
738 LLSC, this should be more efficient than the other alternative of 746 LLSC, this should be more efficient than the other alternative of
739 disabling interrupts around the atomic sequence. 747 disabling interrupts around the atomic sequence.
740 748
749config HW_PERF_EVENTS
750 bool "Enable hardware performance counter support for perf events"
751 depends on PERF_EVENTS && CPU_HAS_PMU
752 default y
753 help
754 Enable hardware performance counter support for perf events. If
755 disabled, perf events will use software events only.
756
741source "drivers/sh/Kconfig" 757source "drivers/sh/Kconfig"
742 758
743endmenu 759endmenu
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 07b35ca2f644..9c94711aa6ca 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -155,6 +155,8 @@ config SH_SDK7786
155 depends on CPU_SUBTYPE_SH7786 155 depends on CPU_SUBTYPE_SH7786
156 select SYS_SUPPORTS_PCI 156 select SYS_SUPPORTS_PCI
157 select NO_IOPORT if !PCI 157 select NO_IOPORT if !PCI
158 select ARCH_WANT_OPTIONAL_GPIOLIB
159 select HAVE_SRAM_POOL
158 help 160 help
159 Select SDK7786 if configuring for a Renesas Technology Europe 161 Select SDK7786 if configuring for a Renesas Technology Europe
160 SH7786-65nm board. 162 SH7786-65nm board.
@@ -165,6 +167,11 @@ config SH_HIGHLANDER
165 select SYS_SUPPORTS_PCI 167 select SYS_SUPPORTS_PCI
166 select IO_TRAPPED if MMU 168 select IO_TRAPPED if MMU
167 169
170config SH_SH7757LCR
171 bool "SH7757LCR"
172 depends on CPU_SUBTYPE_SH7757
173 select ARCH_REQUIRE_GPIOLIB
174
168config SH_SH7785LCR 175config SH_SH7785LCR
169 bool "SH7785LCR" 176 bool "SH7785LCR"
170 depends on CPU_SUBTYPE_SH7785 177 depends on CPU_SUBTYPE_SH7785
@@ -309,6 +316,17 @@ config SH_POLARIS
309 help 316 help
310 Select if configuring for an SMSC Polaris development board 317 Select if configuring for an SMSC Polaris development board
311 318
319config SH_SH2007
320 bool "SH-2007 board"
321 select NO_IOPORT
322 depends on CPU_SUBTYPE_SH7780
323 help
324 SH-2007 is a single-board computer based around SH7780 chip
325 intended for embedded applications.
326 It has an Ethernet interface (SMC9118), direct connected
327 Compact Flash socket, two serial ports and PC-104 bus.
328 More information at <http://sh2000.sh-linux.org>.
329
312endmenu 330endmenu
313 331
314source "arch/sh/boards/mach-r2d/Kconfig" 332source "arch/sh/boards/mach-r2d/Kconfig"
diff --git a/arch/sh/boards/Makefile b/arch/sh/boards/Makefile
index 4f90f9b7a922..38ef655cc0f0 100644
--- a/arch/sh/boards/Makefile
+++ b/arch/sh/boards/Makefile
@@ -2,6 +2,7 @@
2# Specific board support, not covered by a mach group. 2# Specific board support, not covered by a mach group.
3# 3#
4obj-$(CONFIG_SH_MAGIC_PANEL_R2) += board-magicpanelr2.o 4obj-$(CONFIG_SH_MAGIC_PANEL_R2) += board-magicpanelr2.o
5obj-$(CONFIG_SH_SH2007) += board-sh2007.o
5obj-$(CONFIG_SH_SH7785LCR) += board-sh7785lcr.o 6obj-$(CONFIG_SH_SH7785LCR) += board-sh7785lcr.o
6obj-$(CONFIG_SH_URQUELL) += board-urquell.o 7obj-$(CONFIG_SH_URQUELL) += board-urquell.o
7obj-$(CONFIG_SH_SHMIN) += board-shmin.o 8obj-$(CONFIG_SH_SHMIN) += board-shmin.o
@@ -9,3 +10,4 @@ obj-$(CONFIG_SH_EDOSK7760) += board-edosk7760.o
9obj-$(CONFIG_SH_ESPT) += board-espt.o 10obj-$(CONFIG_SH_ESPT) += board-espt.o
10obj-$(CONFIG_SH_POLARIS) += board-polaris.o 11obj-$(CONFIG_SH_POLARIS) += board-polaris.o
11obj-$(CONFIG_SH_TITAN) += board-titan.o 12obj-$(CONFIG_SH_TITAN) += board-titan.o
13obj-$(CONFIG_SH_SH7757LCR) += board-sh7757lcr.o
diff --git a/arch/sh/boards/board-sh2007.c b/arch/sh/boards/board-sh2007.c
new file mode 100644
index 000000000000..b90b78f6a829
--- /dev/null
+++ b/arch/sh/boards/board-sh2007.c
@@ -0,0 +1,133 @@
1/*
2 * SH-2007 board support.
3 *
4 * Copyright (C) 2003, 2004 SUGIOKA Toshinobu
5 * Copyright (C) 2010 Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
6 */
7#include <linux/init.h>
8#include <linux/irq.h>
9#include <linux/smsc911x.h>
10#include <linux/platform_device.h>
11#include <linux/ata_platform.h>
12#include <linux/io.h>
13#include <asm/machvec.h>
14#include <mach/sh2007.h>
15
16struct smsc911x_platform_config smc911x_info = {
17 .flags = SMSC911X_USE_32BIT,
18 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
19 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
20};
21
22static struct resource smsc9118_0_resources[] = {
23 [0] = {
24 .start = SMC0_BASE,
25 .end = SMC0_BASE + 0xff,
26 .flags = IORESOURCE_MEM,
27 },
28 [1] = {
29 .start = evt2irq(0x240),
30 .end = evt2irq(0x240),
31 .flags = IORESOURCE_IRQ,
32 }
33};
34
35static struct resource smsc9118_1_resources[] = {
36 [0] = {
37 .start = SMC1_BASE,
38 .end = SMC1_BASE + 0xff,
39 .flags = IORESOURCE_MEM,
40 },
41 [1] = {
42 .start = evt2irq(0x280),
43 .end = evt2irq(0x280),
44 .flags = IORESOURCE_IRQ,
45 }
46};
47
48static struct platform_device smsc9118_0_device = {
49 .name = "smsc911x",
50 .id = 0,
51 .num_resources = ARRAY_SIZE(smsc9118_0_resources),
52 .resource = smsc9118_0_resources,
53 .dev = {
54 .platform_data = &smc911x_info,
55 },
56};
57
58static struct platform_device smsc9118_1_device = {
59 .name = "smsc911x",
60 .id = 1,
61 .num_resources = ARRAY_SIZE(smsc9118_1_resources),
62 .resource = smsc9118_1_resources,
63 .dev = {
64 .platform_data = &smc911x_info,
65 },
66};
67
68static struct resource cf_resources[] = {
69 [0] = {
70 .start = CF_BASE + CF_OFFSET,
71 .end = CF_BASE + CF_OFFSET + 0x0f,
72 .flags = IORESOURCE_MEM,
73 },
74 [1] = {
75 .start = CF_BASE + CF_OFFSET + 0x206,
76 .end = CF_BASE + CF_OFFSET + 0x20f,
77 .flags = IORESOURCE_MEM,
78 },
79 [2] = {
80 .start = evt2irq(0x2c0),
81 .end = evt2irq(0x2c0),
82 .flags = IORESOURCE_IRQ,
83 },
84};
85
86static struct platform_device cf_device = {
87 .name = "pata_platform",
88 .id = 0,
89 .num_resources = ARRAY_SIZE(cf_resources),
90 .resource = cf_resources,
91};
92
93static struct platform_device *sh2007_devices[] __initdata = {
94 &smsc9118_0_device,
95 &smsc9118_1_device,
96 &cf_device,
97};
98
99static int __init sh2007_io_init(void)
100{
101 platform_add_devices(sh2007_devices, ARRAY_SIZE(sh2007_devices));
102 return 0;
103}
104subsys_initcall(sh2007_io_init);
105
106static void __init sh2007_init_irq(void)
107{
108 plat_irq_setup_pins(IRQ_MODE_IRQ);
109}
110
111/*
112 * Initialize the board
113 */
114static void __init sh2007_setup(char **cmdline_p)
115{
116 printk(KERN_INFO "SH-2007 Setup...");
117
118 /* setup wait control registers for area 5 */
119 __raw_writel(CS5BCR_D, CS5BCR);
120 __raw_writel(CS5WCR_D, CS5WCR);
121 __raw_writel(CS5PCR_D, CS5PCR);
122
123 printk(KERN_INFO " done.\n");
124}
125
126/*
127 * The Machine Vector
128 */
129struct sh_machine_vector mv_sh2007 __initmv = {
130 .mv_setup = sh2007_setup,
131 .mv_name = "sh2007",
132 .mv_init_irq = sh2007_init_irq,
133};
diff --git a/arch/sh/boards/board-sh7757lcr.c b/arch/sh/boards/board-sh7757lcr.c
new file mode 100644
index 000000000000..c475f1056ab4
--- /dev/null
+++ b/arch/sh/boards/board-sh7757lcr.c
@@ -0,0 +1,374 @@
1/*
2 * Renesas R0P7757LC0012RL Support.
3 *
4 * Copyright (C) 2009 - 2010 Renesas Solutions Corp.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <linux/gpio.h>
14#include <linux/irq.h>
15#include <linux/spi/spi.h>
16#include <linux/spi/flash.h>
17#include <linux/io.h>
18#include <cpu/sh7757.h>
19#include <asm/sh_eth.h>
20#include <asm/heartbeat.h>
21
22static struct resource heartbeat_resource = {
23 .start = 0xffec005c, /* PUDR */
24 .end = 0xffec005c,
25 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8BIT,
26};
27
28static unsigned char heartbeat_bit_pos[] = { 0, 1, 2, 3 };
29
30static struct heartbeat_data heartbeat_data = {
31 .bit_pos = heartbeat_bit_pos,
32 .nr_bits = ARRAY_SIZE(heartbeat_bit_pos),
33 .flags = HEARTBEAT_INVERTED,
34};
35
36static struct platform_device heartbeat_device = {
37 .name = "heartbeat",
38 .id = -1,
39 .dev = {
40 .platform_data = &heartbeat_data,
41 },
42 .num_resources = 1,
43 .resource = &heartbeat_resource,
44};
45
46/* Fast Ethernet */
47static struct resource sh_eth0_resources[] = {
48 {
49 .start = 0xfef00000,
50 .end = 0xfef001ff,
51 .flags = IORESOURCE_MEM,
52 }, {
53 .start = 84,
54 .end = 84,
55 .flags = IORESOURCE_IRQ,
56 },
57};
58
59static struct sh_eth_plat_data sh7757_eth0_pdata = {
60 .phy = 1,
61 .edmac_endian = EDMAC_LITTLE_ENDIAN,
62};
63
64static struct platform_device sh7757_eth0_device = {
65 .name = "sh-eth",
66 .resource = sh_eth0_resources,
67 .id = 0,
68 .num_resources = ARRAY_SIZE(sh_eth0_resources),
69 .dev = {
70 .platform_data = &sh7757_eth0_pdata,
71 },
72};
73
74static struct resource sh_eth1_resources[] = {
75 {
76 .start = 0xfef00800,
77 .end = 0xfef009ff,
78 .flags = IORESOURCE_MEM,
79 }, {
80 .start = 84,
81 .end = 84,
82 .flags = IORESOURCE_IRQ,
83 },
84};
85
86static struct sh_eth_plat_data sh7757_eth1_pdata = {
87 .phy = 1,
88 .edmac_endian = EDMAC_LITTLE_ENDIAN,
89};
90
91static struct platform_device sh7757_eth1_device = {
92 .name = "sh-eth",
93 .resource = sh_eth1_resources,
94 .id = 1,
95 .num_resources = ARRAY_SIZE(sh_eth1_resources),
96 .dev = {
97 .platform_data = &sh7757_eth1_pdata,
98 },
99};
100
101static struct platform_device *sh7757lcr_devices[] __initdata = {
102 &heartbeat_device,
103 &sh7757_eth0_device,
104 &sh7757_eth1_device,
105};
106
107static int __init sh7757lcr_devices_setup(void)
108{
109 /* RGMII (PTA) */
110 gpio_request(GPIO_FN_ET0_MDC, NULL);
111 gpio_request(GPIO_FN_ET0_MDIO, NULL);
112 gpio_request(GPIO_FN_ET1_MDC, NULL);
113 gpio_request(GPIO_FN_ET1_MDIO, NULL);
114
115 /* ONFI (PTB, PTZ) */
116 gpio_request(GPIO_FN_ON_NRE, NULL);
117 gpio_request(GPIO_FN_ON_NWE, NULL);
118 gpio_request(GPIO_FN_ON_NWP, NULL);
119 gpio_request(GPIO_FN_ON_NCE0, NULL);
120 gpio_request(GPIO_FN_ON_R_B0, NULL);
121 gpio_request(GPIO_FN_ON_ALE, NULL);
122 gpio_request(GPIO_FN_ON_CLE, NULL);
123
124 gpio_request(GPIO_FN_ON_DQ7, NULL);
125 gpio_request(GPIO_FN_ON_DQ6, NULL);
126 gpio_request(GPIO_FN_ON_DQ5, NULL);
127 gpio_request(GPIO_FN_ON_DQ4, NULL);
128 gpio_request(GPIO_FN_ON_DQ3, NULL);
129 gpio_request(GPIO_FN_ON_DQ2, NULL);
130 gpio_request(GPIO_FN_ON_DQ1, NULL);
131 gpio_request(GPIO_FN_ON_DQ0, NULL);
132
133 /* IRQ8 to 0 (PTB, PTC) */
134 gpio_request(GPIO_FN_IRQ8, NULL);
135 gpio_request(GPIO_FN_IRQ7, NULL);
136 gpio_request(GPIO_FN_IRQ6, NULL);
137 gpio_request(GPIO_FN_IRQ5, NULL);
138 gpio_request(GPIO_FN_IRQ4, NULL);
139 gpio_request(GPIO_FN_IRQ3, NULL);
140 gpio_request(GPIO_FN_IRQ2, NULL);
141 gpio_request(GPIO_FN_IRQ1, NULL);
142 gpio_request(GPIO_FN_IRQ0, NULL);
143
144 /* SPI0 (PTD) */
145 gpio_request(GPIO_FN_SP0_MOSI, NULL);
146 gpio_request(GPIO_FN_SP0_MISO, NULL);
147 gpio_request(GPIO_FN_SP0_SCK, NULL);
148 gpio_request(GPIO_FN_SP0_SCK_FB, NULL);
149 gpio_request(GPIO_FN_SP0_SS0, NULL);
150 gpio_request(GPIO_FN_SP0_SS1, NULL);
151 gpio_request(GPIO_FN_SP0_SS2, NULL);
152 gpio_request(GPIO_FN_SP0_SS3, NULL);
153
154 /* RMII 0/1 (PTE, PTF) */
155 gpio_request(GPIO_FN_RMII0_CRS_DV, NULL);
156 gpio_request(GPIO_FN_RMII0_TXD1, NULL);
157 gpio_request(GPIO_FN_RMII0_TXD0, NULL);
158 gpio_request(GPIO_FN_RMII0_TXEN, NULL);
159 gpio_request(GPIO_FN_RMII0_REFCLK, NULL);
160 gpio_request(GPIO_FN_RMII0_RXD1, NULL);
161 gpio_request(GPIO_FN_RMII0_RXD0, NULL);
162 gpio_request(GPIO_FN_RMII0_RX_ER, NULL);
163 gpio_request(GPIO_FN_RMII1_CRS_DV, NULL);
164 gpio_request(GPIO_FN_RMII1_TXD1, NULL);
165 gpio_request(GPIO_FN_RMII1_TXD0, NULL);
166 gpio_request(GPIO_FN_RMII1_TXEN, NULL);
167 gpio_request(GPIO_FN_RMII1_REFCLK, NULL);
168 gpio_request(GPIO_FN_RMII1_RXD1, NULL);
169 gpio_request(GPIO_FN_RMII1_RXD0, NULL);
170 gpio_request(GPIO_FN_RMII1_RX_ER, NULL);
171
172 /* eMMC (PTG) */
173 gpio_request(GPIO_FN_MMCCLK, NULL);
174 gpio_request(GPIO_FN_MMCCMD, NULL);
175 gpio_request(GPIO_FN_MMCDAT7, NULL);
176 gpio_request(GPIO_FN_MMCDAT6, NULL);
177 gpio_request(GPIO_FN_MMCDAT5, NULL);
178 gpio_request(GPIO_FN_MMCDAT4, NULL);
179 gpio_request(GPIO_FN_MMCDAT3, NULL);
180 gpio_request(GPIO_FN_MMCDAT2, NULL);
181 gpio_request(GPIO_FN_MMCDAT1, NULL);
182 gpio_request(GPIO_FN_MMCDAT0, NULL);
183
184 /* LPC (PTG, PTH, PTQ, PTU) */
185 gpio_request(GPIO_FN_SERIRQ, NULL);
186 gpio_request(GPIO_FN_LPCPD, NULL);
187 gpio_request(GPIO_FN_LDRQ, NULL);
188 gpio_request(GPIO_FN_WP, NULL);
189 gpio_request(GPIO_FN_FMS0, NULL);
190 gpio_request(GPIO_FN_LAD3, NULL);
191 gpio_request(GPIO_FN_LAD2, NULL);
192 gpio_request(GPIO_FN_LAD1, NULL);
193 gpio_request(GPIO_FN_LAD0, NULL);
194 gpio_request(GPIO_FN_LFRAME, NULL);
195 gpio_request(GPIO_FN_LRESET, NULL);
196 gpio_request(GPIO_FN_LCLK, NULL);
197 gpio_request(GPIO_FN_LGPIO7, NULL);
198 gpio_request(GPIO_FN_LGPIO6, NULL);
199 gpio_request(GPIO_FN_LGPIO5, NULL);
200 gpio_request(GPIO_FN_LGPIO4, NULL);
201
202 /* SPI1 (PTH) */
203 gpio_request(GPIO_FN_SP1_MOSI, NULL);
204 gpio_request(GPIO_FN_SP1_MISO, NULL);
205 gpio_request(GPIO_FN_SP1_SCK, NULL);
206 gpio_request(GPIO_FN_SP1_SCK_FB, NULL);
207 gpio_request(GPIO_FN_SP1_SS0, NULL);
208 gpio_request(GPIO_FN_SP1_SS1, NULL);
209
210 /* SDHI (PTI) */
211 gpio_request(GPIO_FN_SD_WP, NULL);
212 gpio_request(GPIO_FN_SD_CD, NULL);
213 gpio_request(GPIO_FN_SD_CLK, NULL);
214 gpio_request(GPIO_FN_SD_CMD, NULL);
215 gpio_request(GPIO_FN_SD_D3, NULL);
216 gpio_request(GPIO_FN_SD_D2, NULL);
217 gpio_request(GPIO_FN_SD_D1, NULL);
218 gpio_request(GPIO_FN_SD_D0, NULL);
219
220 /* SCIF3/4 (PTJ, PTW) */
221 gpio_request(GPIO_FN_RTS3, NULL);
222 gpio_request(GPIO_FN_CTS3, NULL);
223 gpio_request(GPIO_FN_TXD3, NULL);
224 gpio_request(GPIO_FN_RXD3, NULL);
225 gpio_request(GPIO_FN_RTS4, NULL);
226 gpio_request(GPIO_FN_RXD4, NULL);
227 gpio_request(GPIO_FN_TXD4, NULL);
228 gpio_request(GPIO_FN_CTS4, NULL);
229
230 /* SERMUX (PTK, PTL, PTO, PTV) */
231 gpio_request(GPIO_FN_COM2_TXD, NULL);
232 gpio_request(GPIO_FN_COM2_RXD, NULL);
233 gpio_request(GPIO_FN_COM2_RTS, NULL);
234 gpio_request(GPIO_FN_COM2_CTS, NULL);
235 gpio_request(GPIO_FN_COM2_DTR, NULL);
236 gpio_request(GPIO_FN_COM2_DSR, NULL);
237 gpio_request(GPIO_FN_COM2_DCD, NULL);
238 gpio_request(GPIO_FN_COM2_RI, NULL);
239 gpio_request(GPIO_FN_RAC_RXD, NULL);
240 gpio_request(GPIO_FN_RAC_RTS, NULL);
241 gpio_request(GPIO_FN_RAC_CTS, NULL);
242 gpio_request(GPIO_FN_RAC_DTR, NULL);
243 gpio_request(GPIO_FN_RAC_DSR, NULL);
244 gpio_request(GPIO_FN_RAC_DCD, NULL);
245 gpio_request(GPIO_FN_RAC_TXD, NULL);
246 gpio_request(GPIO_FN_COM1_TXD, NULL);
247 gpio_request(GPIO_FN_COM1_RXD, NULL);
248 gpio_request(GPIO_FN_COM1_RTS, NULL);
249 gpio_request(GPIO_FN_COM1_CTS, NULL);
250
251 writeb(0x10, 0xfe470000); /* SMR0: SerMux mode 0 */
252
253 /* IIC (PTM, PTR, PTS) */
254 gpio_request(GPIO_FN_SDA7, NULL);
255 gpio_request(GPIO_FN_SCL7, NULL);
256 gpio_request(GPIO_FN_SDA6, NULL);
257 gpio_request(GPIO_FN_SCL6, NULL);
258 gpio_request(GPIO_FN_SDA5, NULL);
259 gpio_request(GPIO_FN_SCL5, NULL);
260 gpio_request(GPIO_FN_SDA4, NULL);
261 gpio_request(GPIO_FN_SCL4, NULL);
262 gpio_request(GPIO_FN_SDA3, NULL);
263 gpio_request(GPIO_FN_SCL3, NULL);
264 gpio_request(GPIO_FN_SDA2, NULL);
265 gpio_request(GPIO_FN_SCL2, NULL);
266 gpio_request(GPIO_FN_SDA1, NULL);
267 gpio_request(GPIO_FN_SCL1, NULL);
268 gpio_request(GPIO_FN_SDA0, NULL);
269 gpio_request(GPIO_FN_SCL0, NULL);
270
271 /* USB (PTN) */
272 gpio_request(GPIO_FN_VBUS_EN, NULL);
273 gpio_request(GPIO_FN_VBUS_OC, NULL);
274
275 /* SGPIO1/0 (PTN, PTO) */
276 gpio_request(GPIO_FN_SGPIO1_CLK, NULL);
277 gpio_request(GPIO_FN_SGPIO1_LOAD, NULL);
278 gpio_request(GPIO_FN_SGPIO1_DI, NULL);
279 gpio_request(GPIO_FN_SGPIO1_DO, NULL);
280 gpio_request(GPIO_FN_SGPIO0_CLK, NULL);
281 gpio_request(GPIO_FN_SGPIO0_LOAD, NULL);
282 gpio_request(GPIO_FN_SGPIO0_DI, NULL);
283 gpio_request(GPIO_FN_SGPIO0_DO, NULL);
284
285 /* WDT (PTN) */
286 gpio_request(GPIO_FN_SUB_CLKIN, NULL);
287
288 /* System (PTT) */
289 gpio_request(GPIO_FN_STATUS1, NULL);
290 gpio_request(GPIO_FN_STATUS0, NULL);
291
292 /* PWMX (PTT) */
293 gpio_request(GPIO_FN_PWMX1, NULL);
294 gpio_request(GPIO_FN_PWMX0, NULL);
295
296 /* R-SPI (PTV) */
297 gpio_request(GPIO_FN_R_SPI_MOSI, NULL);
298 gpio_request(GPIO_FN_R_SPI_MISO, NULL);
299 gpio_request(GPIO_FN_R_SPI_RSPCK, NULL);
300 gpio_request(GPIO_FN_R_SPI_SSL0, NULL);
301 gpio_request(GPIO_FN_R_SPI_SSL1, NULL);
302
303 /* EVC (PTV, PTW) */
304 gpio_request(GPIO_FN_EVENT7, NULL);
305 gpio_request(GPIO_FN_EVENT6, NULL);
306 gpio_request(GPIO_FN_EVENT5, NULL);
307 gpio_request(GPIO_FN_EVENT4, NULL);
308 gpio_request(GPIO_FN_EVENT3, NULL);
309 gpio_request(GPIO_FN_EVENT2, NULL);
310 gpio_request(GPIO_FN_EVENT1, NULL);
311 gpio_request(GPIO_FN_EVENT0, NULL);
312
313 /* LED for heartbeat */
314 gpio_request(GPIO_PTU3, NULL);
315 gpio_direction_output(GPIO_PTU3, 1);
316 gpio_request(GPIO_PTU2, NULL);
317 gpio_direction_output(GPIO_PTU2, 1);
318 gpio_request(GPIO_PTU1, NULL);
319 gpio_direction_output(GPIO_PTU1, 1);
320 gpio_request(GPIO_PTU0, NULL);
321 gpio_direction_output(GPIO_PTU0, 1);
322
323 /* control for MDIO of Gigabit Ethernet */
324 gpio_request(GPIO_PTT4, NULL);
325 gpio_direction_output(GPIO_PTT4, 1);
326
327 /* control for eMMC */
328 gpio_request(GPIO_PTT7, NULL); /* eMMC_RST# */
329 gpio_direction_output(GPIO_PTT7, 0);
330 gpio_request(GPIO_PTT6, NULL); /* eMMC_INDEX# */
331 gpio_direction_output(GPIO_PTT6, 0);
332 gpio_request(GPIO_PTT5, NULL); /* eMMC_PRST# */
333 gpio_direction_output(GPIO_PTT5, 1);
334
335 /* General platform */
336 return platform_add_devices(sh7757lcr_devices,
337 ARRAY_SIZE(sh7757lcr_devices));
338}
339arch_initcall(sh7757lcr_devices_setup);
340
341/* Initialize IRQ setting */
342void __init init_sh7757lcr_IRQ(void)
343{
344 plat_irq_setup_pins(IRQ_MODE_IRQ7654);
345 plat_irq_setup_pins(IRQ_MODE_IRQ3210);
346}
347
348/* Initialize the board */
349static void __init sh7757lcr_setup(char **cmdline_p)
350{
351 printk(KERN_INFO "Renesas R0P7757LC0012RL support.\n");
352}
353
354static int sh7757lcr_mode_pins(void)
355{
356 int value = 0;
357
358 /* These are the factory default settings of S3 (Low active).
359 * If you change these dip switches then you will need to
360 * adjust the values below as well.
361 */
362 value |= MODE_PIN0; /* Clock Mode: 1 */
363
364 return value;
365}
366
367/* The Machine Vector */
368static struct sh_machine_vector mv_sh7757lcr __initmv = {
369 .mv_name = "SH7757LCR",
370 .mv_setup = sh7757lcr_setup,
371 .mv_init_irq = init_sh7757lcr_IRQ,
372 .mv_mode_pins = sh7757lcr_mode_pins,
373};
374
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 1d7b495a7db4..71a3368ab1fc 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -1248,14 +1248,14 @@ static int __init arch_setup(void)
1248 1248
1249 /* set SPU2 clock to 83.4 MHz */ 1249 /* set SPU2 clock to 83.4 MHz */
1250 clk = clk_get(NULL, "spu_clk"); 1250 clk = clk_get(NULL, "spu_clk");
1251 if (clk) { 1251 if (!IS_ERR(clk)) {
1252 clk_set_rate(clk, clk_round_rate(clk, 83333333)); 1252 clk_set_rate(clk, clk_round_rate(clk, 83333333));
1253 clk_put(clk); 1253 clk_put(clk);
1254 } 1254 }
1255 1255
1256 /* change parent of FSI B */ 1256 /* change parent of FSI B */
1257 clk = clk_get(NULL, "fsib_clk"); 1257 clk = clk_get(NULL, "fsib_clk");
1258 if (clk) { 1258 if (!IS_ERR(clk)) {
1259 clk_register(&fsimckb_clk); 1259 clk_register(&fsimckb_clk);
1260 clk_set_parent(clk, &fsimckb_clk); 1260 clk_set_parent(clk, &fsimckb_clk);
1261 clk_set_rate(clk, 11000); 1261 clk_set_rate(clk, 11000);
@@ -1273,7 +1273,7 @@ static int __init arch_setup(void)
1273 1273
1274 /* set VPU clock to 166 MHz */ 1274 /* set VPU clock to 166 MHz */
1275 clk = clk_get(NULL, "vpu_clk"); 1275 clk = clk_get(NULL, "vpu_clk");
1276 if (clk) { 1276 if (!IS_ERR(clk)) {
1277 clk_set_rate(clk, clk_round_rate(clk, 166000000)); 1277 clk_set_rate(clk, clk_round_rate(clk, 166000000));
1278 clk_put(clk); 1278 clk_put(clk);
1279 } 1279 }
diff --git a/arch/sh/boards/mach-landisk/gio.c b/arch/sh/boards/mach-landisk/gio.c
index 01e6abb769b9..8132dff078fb 100644
--- a/arch/sh/boards/mach-landisk/gio.c
+++ b/arch/sh/boards/mach-landisk/gio.c
@@ -128,6 +128,7 @@ static const struct file_operations gio_fops = {
128 .open = gio_open, /* open */ 128 .open = gio_open, /* open */
129 .release = gio_close, /* release */ 129 .release = gio_close, /* release */
130 .unlocked_ioctl = gio_ioctl, 130 .unlocked_ioctl = gio_ioctl,
131 .llseek = noop_llseek,
131}; 132};
132 133
133static int __init gio_init(void) 134static int __init gio_init(void)
diff --git a/arch/sh/boards/mach-sdk7786/Makefile b/arch/sh/boards/mach-sdk7786/Makefile
index a29f19e85b63..23ff7d4ac491 100644
--- a/arch/sh/boards/mach-sdk7786/Makefile
+++ b/arch/sh/boards/mach-sdk7786/Makefile
@@ -1 +1,4 @@
1obj-y := setup.o fpga.o irq.o 1obj-y := fpga.o irq.o setup.o
2
3obj-$(CONFIG_GENERIC_GPIO) += gpio.o
4obj-$(CONFIG_HAVE_SRAM_POOL) += sram.o
diff --git a/arch/sh/boards/mach-sdk7786/gpio.c b/arch/sh/boards/mach-sdk7786/gpio.c
new file mode 100644
index 000000000000..f71ce09d4e15
--- /dev/null
+++ b/arch/sh/boards/mach-sdk7786/gpio.c
@@ -0,0 +1,49 @@
1/*
2 * SDK7786 FPGA USRGPIR Support.
3 *
4 * Copyright (C) 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/interrupt.h>
12#include <linux/gpio.h>
13#include <linux/irq.h>
14#include <linux/kernel.h>
15#include <linux/spinlock.h>
16#include <linux/io.h>
17#include <mach/fpga.h>
18
19#define NR_FPGA_GPIOS 8
20
21static const char *usrgpir_gpio_names[NR_FPGA_GPIOS] = {
22 "in0", "in1", "in2", "in3", "in4", "in5", "in6", "in7",
23};
24
25static int usrgpir_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
26{
27 /* always in */
28 return 0;
29}
30
31static int usrgpir_gpio_get(struct gpio_chip *chip, unsigned gpio)
32{
33 return !!(fpga_read_reg(USRGPIR) & (1 << gpio));
34}
35
36static struct gpio_chip usrgpir_gpio_chip = {
37 .label = "sdk7786-fpga",
38 .names = usrgpir_gpio_names,
39 .direction_input = usrgpir_gpio_direction_input,
40 .get = usrgpir_gpio_get,
41 .base = -1, /* don't care */
42 .ngpio = NR_FPGA_GPIOS,
43};
44
45static int __init usrgpir_gpio_setup(void)
46{
47 return gpiochip_add(&usrgpir_gpio_chip);
48}
49device_initcall(usrgpir_gpio_setup);
diff --git a/arch/sh/boards/mach-sdk7786/setup.c b/arch/sh/boards/mach-sdk7786/setup.c
index 2ec1ea5cf8ef..7e0c4e3878e0 100644
--- a/arch/sh/boards/mach-sdk7786/setup.c
+++ b/arch/sh/boards/mach-sdk7786/setup.c
@@ -20,6 +20,8 @@
20#include <asm/machvec.h> 20#include <asm/machvec.h>
21#include <asm/heartbeat.h> 21#include <asm/heartbeat.h>
22#include <asm/sizes.h> 22#include <asm/sizes.h>
23#include <asm/clock.h>
24#include <asm/clkdev.h>
23#include <asm/reboot.h> 25#include <asm/reboot.h>
24#include <asm/smp-ops.h> 26#include <asm/smp-ops.h>
25 27
@@ -140,6 +142,45 @@ static int sdk7786_mode_pins(void)
140 return fpga_read_reg(MODSWR); 142 return fpga_read_reg(MODSWR);
141} 143}
142 144
145/*
146 * FPGA-driven PCIe clocks
147 *
148 * Historically these include the oscillator, clock B (slots 2/3/4) and
149 * clock A (slot 1 and the CPU clock). Newer revs of the PCB shove
150 * everything under a single PCIe clocks enable bit that happens to map
151 * to the same bit position as the oscillator bit for earlier FPGA
152 * versions.
153 *
154 * Given that the legacy clocks have the side-effect of shutting the CPU
155 * off through the FPGA along with the PCI slots, we simply leave them in
156 * their initial state and don't bother registering them with the clock
157 * framework.
158 */
159static int sdk7786_pcie_clk_enable(struct clk *clk)
160{
161 fpga_write_reg(fpga_read_reg(PCIECR) | PCIECR_CLKEN, PCIECR);
162 return 0;
163}
164
165static void sdk7786_pcie_clk_disable(struct clk *clk)
166{
167 fpga_write_reg(fpga_read_reg(PCIECR) & ~PCIECR_CLKEN, PCIECR);
168}
169
170static struct clk_ops sdk7786_pcie_clk_ops = {
171 .enable = sdk7786_pcie_clk_enable,
172 .disable = sdk7786_pcie_clk_disable,
173};
174
175static struct clk sdk7786_pcie_clk = {
176 .ops = &sdk7786_pcie_clk_ops,
177};
178
179static struct clk_lookup sdk7786_pcie_cl = {
180 .con_id = "pcie_plat_clk",
181 .clk = &sdk7786_pcie_clk,
182};
183
143static int sdk7786_clk_init(void) 184static int sdk7786_clk_init(void)
144{ 185{
145 struct clk *clk; 186 struct clk *clk;
@@ -158,7 +199,18 @@ static int sdk7786_clk_init(void)
158 ret = clk_set_rate(clk, 33333333); 199 ret = clk_set_rate(clk, 33333333);
159 clk_put(clk); 200 clk_put(clk);
160 201
161 return ret; 202 /*
203 * Setup the FPGA clocks.
204 */
205 ret = clk_register(&sdk7786_pcie_clk);
206 if (unlikely(ret)) {
207 pr_err("FPGA clock registration failed\n");
208 return ret;
209 }
210
211 clkdev_add(&sdk7786_pcie_cl);
212
213 return 0;
162} 214}
163 215
164static void sdk7786_restart(char *cmd) 216static void sdk7786_restart(char *cmd)
diff --git a/arch/sh/boards/mach-sdk7786/sram.c b/arch/sh/boards/mach-sdk7786/sram.c
new file mode 100644
index 000000000000..c81c3abbe01c
--- /dev/null
+++ b/arch/sh/boards/mach-sdk7786/sram.c
@@ -0,0 +1,72 @@
1/*
2 * SDK7786 FPGA SRAM Support.
3 *
4 * Copyright (C) 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/io.h>
16#include <linux/string.h>
17#include <mach/fpga.h>
18#include <asm/sram.h>
19#include <asm/sizes.h>
20
21static int __init fpga_sram_init(void)
22{
23 unsigned long phys;
24 unsigned int area;
25 void __iomem *vaddr;
26 int ret;
27 u16 data;
28
29 /* Enable FPGA SRAM */
30 data = fpga_read_reg(LCLASR);
31 data |= LCLASR_FRAMEN;
32 fpga_write_reg(data, LCLASR);
33
34 /*
35 * FPGA_SEL determines the area mapping
36 */
37 area = (data & LCLASR_FPGA_SEL_MASK) >> LCLASR_FPGA_SEL_SHIFT;
38 if (unlikely(area == LCLASR_AREA_MASK)) {
39 pr_err("FPGA memory unmapped.\n");
40 return -ENXIO;
41 }
42
43 /*
44 * The memory itself occupies a 2KiB range at the top of the area
45 * immediately below the system registers.
46 */
47 phys = (area << 26) + SZ_64M - SZ_4K;
48
49 /*
50 * The FPGA SRAM resides in translatable physical space, so set
51 * up a mapping prior to inserting it in to the pool.
52 */
53 vaddr = ioremap(phys, SZ_2K);
54 if (unlikely(!vaddr)) {
55 pr_err("Failed remapping FPGA memory.\n");
56 return -ENXIO;
57 }
58
59 pr_info("Adding %dKiB of FPGA memory at 0x%08lx-0x%08lx "
60 "(area %d) to pool.\n",
61 SZ_2K >> 10, phys, phys + SZ_2K - 1, area);
62
63 ret = gen_pool_add(sram_pool, (unsigned long)vaddr, SZ_2K, -1);
64 if (unlikely(ret < 0)) {
65 pr_err("Failed adding memory\n");
66 iounmap(vaddr);
67 return ret;
68 }
69
70 return 0;
71}
72postcore_initcall(fpga_sram_init);
diff --git a/arch/sh/boards/mach-x3proto/Makefile b/arch/sh/boards/mach-x3proto/Makefile
index 983e4551fecf..708c21c919ff 100644
--- a/arch/sh/boards/mach-x3proto/Makefile
+++ b/arch/sh/boards/mach-x3proto/Makefile
@@ -1 +1,3 @@
1obj-y += setup.o ilsel.o 1obj-y += setup.o ilsel.o
2
3obj-$(CONFIG_GENERIC_GPIO) += gpio.o
diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c
new file mode 100644
index 000000000000..594adf76e46a
--- /dev/null
+++ b/arch/sh/boards/mach-x3proto/gpio.c
@@ -0,0 +1,135 @@
1/*
2 * arch/sh/boards/mach-x3proto/gpio.c
3 *
4 * Renesas SH-X3 Prototype Baseboard GPIO Support.
5 *
6 * Copyright (C) 2010 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/gpio.h>
17#include <linux/irq.h>
18#include <linux/kernel.h>
19#include <linux/spinlock.h>
20#include <linux/io.h>
21#include <mach/ilsel.h>
22#include <mach/hardware.h>
23
24#define KEYCTLR 0xb81c0000
25#define KEYOUTR 0xb81c0002
26#define KEYDETR 0xb81c0004
27
28static DEFINE_SPINLOCK(x3proto_gpio_lock);
29static unsigned int x3proto_gpio_irq_map[NR_BASEBOARD_GPIOS] = { 0, };
30
31static int x3proto_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
32{
33 unsigned long flags;
34 unsigned int data;
35
36 spin_lock_irqsave(&x3proto_gpio_lock, flags);
37 data = __raw_readw(KEYCTLR);
38 data |= (1 << gpio);
39 __raw_writew(data, KEYCTLR);
40 spin_unlock_irqrestore(&x3proto_gpio_lock, flags);
41
42 return 0;
43}
44
45static int x3proto_gpio_get(struct gpio_chip *chip, unsigned gpio)
46{
47 return !!(__raw_readw(KEYDETR) & (1 << gpio));
48}
49
50static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
51{
52 return x3proto_gpio_irq_map[gpio];
53}
54
55static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
56{
57 struct irq_chip *chip = get_irq_desc_chip(desc);
58 unsigned long mask;
59 int pin;
60
61 chip->mask_ack(irq);
62
63 mask = __raw_readw(KEYDETR);
64
65 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS)
66 generic_handle_irq(x3proto_gpio_to_irq(NULL, pin));
67
68 chip->unmask(irq);
69}
70
71struct gpio_chip x3proto_gpio_chip = {
72 .label = "x3proto-gpio",
73 .direction_input = x3proto_gpio_direction_input,
74 .get = x3proto_gpio_get,
75 .to_irq = x3proto_gpio_to_irq,
76 .base = -1,
77 .ngpio = NR_BASEBOARD_GPIOS,
78};
79
80int __init x3proto_gpio_setup(void)
81{
82 int ilsel;
83 int ret, i;
84
85 ilsel = ilsel_enable(ILSEL_KEY);
86 if (unlikely(ilsel < 0))
87 return ilsel;
88
89 ret = gpiochip_add(&x3proto_gpio_chip);
90 if (unlikely(ret))
91 goto err_gpio;
92
93 for (i = 0; i < NR_BASEBOARD_GPIOS; i++) {
94 unsigned long flags;
95 int irq = create_irq();
96
97 if (unlikely(irq < 0)) {
98 ret = -EINVAL;
99 goto err_irq;
100 }
101
102 spin_lock_irqsave(&x3proto_gpio_lock, flags);
103 x3proto_gpio_irq_map[i] = irq;
104 set_irq_chip_and_handler_name(irq, &dummy_irq_chip,
105 handle_simple_irq, "gpio");
106 spin_unlock_irqrestore(&x3proto_gpio_lock, flags);
107 }
108
109 pr_info("registering '%s' support, handling GPIOs %u -> %u, "
110 "bound to IRQ %u\n",
111 x3proto_gpio_chip.label, x3proto_gpio_chip.base,
112 x3proto_gpio_chip.base + x3proto_gpio_chip.ngpio,
113 ilsel);
114
115 set_irq_chained_handler(ilsel, x3proto_gpio_irq_handler);
116 set_irq_wake(ilsel, 1);
117
118 return 0;
119
120err_irq:
121 for (; i >= 0; --i)
122 if (x3proto_gpio_irq_map[i])
123 destroy_irq(x3proto_gpio_irq_map[i]);
124
125 ret = gpiochip_remove(&x3proto_gpio_chip);
126 if (unlikely(ret))
127 pr_err("Failed deregistering GPIO\n");
128
129err_gpio:
130 synchronize_irq(ilsel);
131
132 ilsel_disable(ILSEL_KEY);
133
134 return ret;
135}
diff --git a/arch/sh/boards/mach-x3proto/ilsel.c b/arch/sh/boards/mach-x3proto/ilsel.c
index 5c9842704c60..95e346139515 100644
--- a/arch/sh/boards/mach-x3proto/ilsel.c
+++ b/arch/sh/boards/mach-x3proto/ilsel.c
@@ -1,20 +1,22 @@
1/* 1/*
2 * arch/sh/boards/renesas/x3proto/ilsel.c 2 * arch/sh/boards/mach-x3proto/ilsel.c
3 * 3 *
4 * Helper routines for SH-X3 proto board ILSEL. 4 * Helper routines for SH-X3 proto board ILSEL.
5 * 5 *
6 * Copyright (C) 2007 Paul Mundt 6 * Copyright (C) 2007 - 2010 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 10 * for more details.
11 */ 11 */
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/init.h> 14#include <linux/init.h>
13#include <linux/kernel.h> 15#include <linux/kernel.h>
14#include <linux/module.h> 16#include <linux/module.h>
15#include <linux/bitmap.h> 17#include <linux/bitmap.h>
16#include <linux/io.h> 18#include <linux/io.h>
17#include <asm/ilsel.h> 19#include <mach/ilsel.h>
18 20
19/* 21/*
20 * ILSEL is split across: 22 * ILSEL is split across:
@@ -64,6 +66,8 @@ static void __ilsel_enable(ilsel_source_t set, unsigned int bit)
64 unsigned int tmp, shift; 66 unsigned int tmp, shift;
65 unsigned long addr; 67 unsigned long addr;
66 68
69 pr_notice("enabling ILSEL set %d\n", set);
70
67 addr = mk_ilsel_addr(bit); 71 addr = mk_ilsel_addr(bit);
68 shift = mk_ilsel_shift(bit); 72 shift = mk_ilsel_shift(bit);
69 73
@@ -92,8 +96,10 @@ int ilsel_enable(ilsel_source_t set)
92{ 96{
93 unsigned int bit; 97 unsigned int bit;
94 98
95 /* Aliased sources must use ilsel_enable_fixed() */ 99 if (unlikely(set > ILSEL_KEY)) {
96 BUG_ON(set > ILSEL_KEY); 100 pr_err("Aliased sources must use ilsel_enable_fixed()\n");
101 return -EINVAL;
102 }
97 103
98 do { 104 do {
99 bit = find_first_zero_bit(&ilsel_level_map, ILSEL_LEVELS); 105 bit = find_first_zero_bit(&ilsel_level_map, ILSEL_LEVELS);
@@ -140,6 +146,8 @@ void ilsel_disable(unsigned int irq)
140 unsigned long addr; 146 unsigned long addr;
141 unsigned int tmp; 147 unsigned int tmp;
142 148
149 pr_notice("disabling ILSEL set %d\n", irq);
150
143 addr = mk_ilsel_addr(irq); 151 addr = mk_ilsel_addr(irq);
144 152
145 tmp = __raw_readw(addr); 153 tmp = __raw_readw(addr);
diff --git a/arch/sh/boards/mach-x3proto/setup.c b/arch/sh/boards/mach-x3proto/setup.c
index 102bf56befb4..d682e2b6a856 100644
--- a/arch/sh/boards/mach-x3proto/setup.c
+++ b/arch/sh/boards/mach-x3proto/setup.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * arch/sh/boards/renesas/x3proto/setup.c 2 * arch/sh/boards/mach-x3proto/setup.c
3 * 3 *
4 * Renesas SH-X3 Prototype Board Support. 4 * Renesas SH-X3 Prototype Board Support.
5 * 5 *
6 * Copyright (C) 2007 - 2008 Paul Mundt 6 * Copyright (C) 2007 - 2010 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -16,9 +16,13 @@
16#include <linux/smc91x.h> 16#include <linux/smc91x.h>
17#include <linux/irq.h> 17#include <linux/irq.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/input.h>
19#include <linux/usb/r8a66597.h> 20#include <linux/usb/r8a66597.h>
20#include <linux/usb/m66592.h> 21#include <linux/usb/m66592.h>
21#include <asm/ilsel.h> 22#include <linux/gpio.h>
23#include <linux/gpio_keys.h>
24#include <mach/ilsel.h>
25#include <mach/hardware.h>
22#include <asm/smp-ops.h> 26#include <asm/smp-ops.h>
23 27
24static struct resource heartbeat_resources[] = { 28static struct resource heartbeat_resources[] = {
@@ -122,15 +126,128 @@ static struct platform_device m66592_usb_peripheral_device = {
122 .resource = m66592_usb_peripheral_resources, 126 .resource = m66592_usb_peripheral_resources,
123}; 127};
124 128
129static struct gpio_keys_button baseboard_buttons[NR_BASEBOARD_GPIOS] = {
130 {
131 .desc = "key44",
132 .code = KEY_POWER,
133 .active_low = 1,
134 .wakeup = 1,
135 }, {
136 .desc = "key43",
137 .code = KEY_SUSPEND,
138 .active_low = 1,
139 .wakeup = 1,
140 }, {
141 .desc = "key42",
142 .code = KEY_KATAKANAHIRAGANA,
143 .active_low = 1,
144 }, {
145 .desc = "key41",
146 .code = KEY_SWITCHVIDEOMODE,
147 .active_low = 1,
148 }, {
149 .desc = "key34",
150 .code = KEY_F12,
151 .active_low = 1,
152 }, {
153 .desc = "key33",
154 .code = KEY_F11,
155 .active_low = 1,
156 }, {
157 .desc = "key32",
158 .code = KEY_F10,
159 .active_low = 1,
160 }, {
161 .desc = "key31",
162 .code = KEY_F9,
163 .active_low = 1,
164 }, {
165 .desc = "key24",
166 .code = KEY_F8,
167 .active_low = 1,
168 }, {
169 .desc = "key23",
170 .code = KEY_F7,
171 .active_low = 1,
172 }, {
173 .desc = "key22",
174 .code = KEY_F6,
175 .active_low = 1,
176 }, {
177 .desc = "key21",
178 .code = KEY_F5,
179 .active_low = 1,
180 }, {
181 .desc = "key14",
182 .code = KEY_F4,
183 .active_low = 1,
184 }, {
185 .desc = "key13",
186 .code = KEY_F3,
187 .active_low = 1,
188 }, {
189 .desc = "key12",
190 .code = KEY_F2,
191 .active_low = 1,
192 }, {
193 .desc = "key11",
194 .code = KEY_F1,
195 .active_low = 1,
196 },
197};
198
199static struct gpio_keys_platform_data baseboard_buttons_data = {
200 .buttons = baseboard_buttons,
201 .nbuttons = ARRAY_SIZE(baseboard_buttons),
202};
203
204static struct platform_device baseboard_buttons_device = {
205 .name = "gpio-keys",
206 .id = -1,
207 .dev = {
208 .platform_data = &baseboard_buttons_data,
209 },
210};
211
125static struct platform_device *x3proto_devices[] __initdata = { 212static struct platform_device *x3proto_devices[] __initdata = {
126 &heartbeat_device, 213 &heartbeat_device,
127 &smc91x_device, 214 &smc91x_device,
128 &r8a66597_usb_host_device, 215 &r8a66597_usb_host_device,
129 &m66592_usb_peripheral_device, 216 &m66592_usb_peripheral_device,
217 &baseboard_buttons_device,
130}; 218};
131 219
220static void __init x3proto_init_irq(void)
221{
222 plat_irq_setup_pins(IRQ_MODE_IRL3210);
223
224 /* Set ICR0.LVLMODE */
225 __raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000);
226}
227
132static int __init x3proto_devices_setup(void) 228static int __init x3proto_devices_setup(void)
133{ 229{
230 int ret, i;
231
232 /*
233 * IRLs are only needed for ILSEL mappings, so flip over the INTC
234 * pins at a later point to enable the GPIOs to settle.
235 */
236 x3proto_init_irq();
237
238 /*
239 * Now that ILSELs are available, set up the baseboard GPIOs.
240 */
241 ret = x3proto_gpio_setup();
242 if (unlikely(ret))
243 return ret;
244
245 /*
246 * Propagate dynamic GPIOs for the baseboard button device.
247 */
248 for (i = 0; i < ARRAY_SIZE(baseboard_buttons); i++)
249 baseboard_buttons[i].gpio = x3proto_gpio_chip.base + i;
250
134 r8a66597_usb_host_resources[1].start = 251 r8a66597_usb_host_resources[1].start =
135 r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I); 252 r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I);
136 253
@@ -145,14 +262,6 @@ static int __init x3proto_devices_setup(void)
145} 262}
146device_initcall(x3proto_devices_setup); 263device_initcall(x3proto_devices_setup);
147 264
148static void __init x3proto_init_irq(void)
149{
150 plat_irq_setup_pins(IRQ_MODE_IRL3210);
151
152 /* Set ICR0.LVLMODE */
153 __raw_writel(__raw_readl(0xfe410000) | (1 << 21), 0xfe410000);
154}
155
156static void __init x3proto_setup(char **cmdline_p) 265static void __init x3proto_setup(char **cmdline_p)
157{ 266{
158 register_smp_ops(&shx3_smp_ops); 267 register_smp_ops(&shx3_smp_ops);
@@ -161,5 +270,4 @@ static void __init x3proto_setup(char **cmdline_p)
161static struct sh_machine_vector mv_x3proto __initmv = { 270static struct sh_machine_vector mv_x3proto __initmv = {
162 .mv_name = "x3proto", 271 .mv_name = "x3proto",
163 .mv_setup = x3proto_setup, 272 .mv_setup = x3proto_setup,
164 .mv_init_irq = x3proto_init_irq,
165}; 273};
diff --git a/arch/sh/boot/compressed/head_32.S b/arch/sh/boot/compressed/head_32.S
index 200c1d4f1efe..3e150326f1fd 100644
--- a/arch/sh/boot/compressed/head_32.S
+++ b/arch/sh/boot/compressed/head_32.S
@@ -91,7 +91,9 @@ bss_start_addr:
91end_addr: 91end_addr:
92 .long _end 92 .long _end
93init_sr: 93init_sr:
94 .long 0x400000F0 /* Privileged mode, Bank=0, Block=0, IMASK=0xF */ 94 .long 0x500000F0 /* Privileged mode, Bank=0, Block=1, IMASK=0xF */
95kexec_magic:
96 .long 0x400000F0 /* magic used by kexec to parse zImage format */
95init_stack_addr: 97init_stack_addr:
96 .long stack_start 98 .long stack_start
97decompress_kernel_addr: 99decompress_kernel_addr:
diff --git a/arch/sh/cchips/hd6446x/Makefile b/arch/sh/cchips/hd6446x/Makefile
index 9682e3ab668f..59c348337bb8 100644
--- a/arch/sh/cchips/hd6446x/Makefile
+++ b/arch/sh/cchips/hd6446x/Makefile
@@ -1,3 +1,3 @@
1obj-$(CONFIG_HD64461) += hd64461.o 1obj-$(CONFIG_HD64461) += hd64461.o
2 2
3EXTRA_CFLAGS += -Werror 3ccflags-y := -Werror
diff --git a/arch/sh/configs/ap325rxa_defconfig b/arch/sh/configs/ap325rxa_defconfig
index 238d6833ac70..e5335123b5e9 100644
--- a/arch/sh/configs/ap325rxa_defconfig
+++ b/arch/sh/configs/ap325rxa_defconfig
@@ -3,7 +3,6 @@ CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 4CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_KALLSYMS is not set 6# CONFIG_KALLSYMS is not set
8CONFIG_SLAB=y 7CONFIG_SLAB=y
9CONFIG_MODULES=y 8CONFIG_MODULES=y
diff --git a/arch/sh/configs/cayman_defconfig b/arch/sh/configs/cayman_defconfig
index b3bf11bcf025..67e150631ea5 100644
--- a/arch/sh/configs/cayman_defconfig
+++ b/arch/sh/configs/cayman_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_POSIX_MQUEUE=y 2CONFIG_POSIX_MQUEUE=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6CONFIG_SLAB=y 5CONFIG_SLAB=y
7CONFIG_MODULES=y 6CONFIG_MODULES=y
diff --git a/arch/sh/configs/dreamcast_defconfig b/arch/sh/configs/dreamcast_defconfig
index 3cdee4f0c184..ec243ca29529 100644
--- a/arch/sh/configs/dreamcast_defconfig
+++ b/arch/sh/configs/dreamcast_defconfig
@@ -2,7 +2,6 @@ CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_LOG_BUF_SHIFT=14 4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_SYSFS_DEPRECATED_V2=y
6# CONFIG_SYSCTL_SYSCALL is not set 5# CONFIG_SYSCTL_SYSCALL is not set
7CONFIG_SLAB=y 6CONFIG_SLAB=y
8CONFIG_PROFILING=y 7CONFIG_PROFILING=y
diff --git a/arch/sh/configs/ecovec24-romimage_defconfig b/arch/sh/configs/ecovec24-romimage_defconfig
index 021633b02835..5fcb17bff24a 100644
--- a/arch/sh/configs/ecovec24-romimage_defconfig
+++ b/arch/sh/configs/ecovec24-romimage_defconfig
@@ -5,7 +5,6 @@ CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
10# CONFIG_KALLSYMS is not set 9# CONFIG_KALLSYMS is not set
11CONFIG_SLAB=y 10CONFIG_SLAB=y
diff --git a/arch/sh/configs/edosk7760_defconfig b/arch/sh/configs/edosk7760_defconfig
index 365f2318e9b5..e1077a041ac3 100644
--- a/arch/sh/configs/edosk7760_defconfig
+++ b/arch/sh/configs/edosk7760_defconfig
@@ -5,7 +5,6 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_BSD_PROCESS_ACCT=y 5CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_IKCONFIG=y 6CONFIG_IKCONFIG=y
7CONFIG_IKCONFIG_PROC=y 7CONFIG_IKCONFIG_PROC=y
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
10CONFIG_KALLSYMS_ALL=y 9CONFIG_KALLSYMS_ALL=y
11CONFIG_MODULES=y 10CONFIG_MODULES=y
diff --git a/arch/sh/configs/espt_defconfig b/arch/sh/configs/espt_defconfig
index ca7fc1b3d567..67cb1094a033 100644
--- a/arch/sh/configs/espt_defconfig
+++ b/arch/sh/configs/espt_defconfig
@@ -3,7 +3,6 @@ CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_NAMESPACES=y 6CONFIG_NAMESPACES=y
8CONFIG_UTS_NS=y 7CONFIG_UTS_NS=y
9CONFIG_IPC_NS=y 8CONFIG_IPC_NS=y
diff --git a/arch/sh/configs/hp6xx_defconfig b/arch/sh/configs/hp6xx_defconfig
index 45c18a3830d2..496edcdf95a3 100644
--- a/arch/sh/configs/hp6xx_defconfig
+++ b/arch/sh/configs/hp6xx_defconfig
@@ -3,7 +3,6 @@ CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 6# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
8# CONFIG_SYSCTL_SYSCALL is not set 7# CONFIG_SYSCTL_SYSCALL is not set
9CONFIG_SLAB=y 8CONFIG_SLAB=y
diff --git a/arch/sh/configs/kfr2r09-romimage_defconfig b/arch/sh/configs/kfr2r09-romimage_defconfig
index d4268b1953bc..029a506ca325 100644
--- a/arch/sh/configs/kfr2r09-romimage_defconfig
+++ b/arch/sh/configs/kfr2r09-romimage_defconfig
@@ -5,7 +5,6 @@ CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
10# CONFIG_KALLSYMS is not set 9# CONFIG_KALLSYMS is not set
11CONFIG_SLAB=y 10CONFIG_SLAB=y
diff --git a/arch/sh/configs/kfr2r09_defconfig b/arch/sh/configs/kfr2r09_defconfig
index ad5d296b375f..fac13ded07b2 100644
--- a/arch/sh/configs/kfr2r09_defconfig
+++ b/arch/sh/configs/kfr2r09_defconfig
@@ -5,7 +5,6 @@ CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
10# CONFIG_KALLSYMS is not set 9# CONFIG_KALLSYMS is not set
11CONFIG_SLAB=y 10CONFIG_SLAB=y
diff --git a/arch/sh/configs/landisk_defconfig b/arch/sh/configs/landisk_defconfig
index 14e658e9318f..3670e937f2b7 100644
--- a/arch/sh/configs/landisk_defconfig
+++ b/arch/sh/configs/landisk_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5# CONFIG_SYSCTL_SYSCALL is not set 4# CONFIG_SYSCTL_SYSCALL is not set
6CONFIG_KALLSYMS_EXTRA_PASS=y 5CONFIG_KALLSYMS_EXTRA_PASS=y
7CONFIG_SLAB=y 6CONFIG_SLAB=y
diff --git a/arch/sh/configs/lboxre2_defconfig b/arch/sh/configs/lboxre2_defconfig
index 6be7eaaa8bb6..e3c0894b1bb4 100644
--- a/arch/sh/configs/lboxre2_defconfig
+++ b/arch/sh/configs/lboxre2_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5# CONFIG_SYSCTL_SYSCALL is not set 4# CONFIG_SYSCTL_SYSCALL is not set
6CONFIG_KALLSYMS_EXTRA_PASS=y 5CONFIG_KALLSYMS_EXTRA_PASS=y
7CONFIG_SLAB=y 6CONFIG_SLAB=y
diff --git a/arch/sh/configs/magicpanelr2_defconfig b/arch/sh/configs/magicpanelr2_defconfig
index 4d61b7711b40..9479872b1ae6 100644
--- a/arch/sh/configs/magicpanelr2_defconfig
+++ b/arch/sh/configs/magicpanelr2_defconfig
@@ -5,7 +5,6 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_BSD_PROCESS_ACCT=y 5CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_BSD_PROCESS_ACCT_V3=y 6CONFIG_BSD_PROCESS_ACCT_V3=y
7CONFIG_AUDIT=y 7CONFIG_AUDIT=y
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_RELAY=y 8CONFIG_RELAY=y
10CONFIG_BLK_DEV_INITRD=y 9CONFIG_BLK_DEV_INITRD=y
11# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 10# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
diff --git a/arch/sh/configs/microdev_defconfig b/arch/sh/configs/microdev_defconfig
index 0e32a24fed53..f1d2e1b5ee41 100644
--- a/arch/sh/configs/microdev_defconfig
+++ b/arch/sh/configs/microdev_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_BSD_PROCESS_ACCT=y 2CONFIG_BSD_PROCESS_ACCT=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5CONFIG_BLK_DEV_INITRD=y 4CONFIG_BLK_DEV_INITRD=y
6# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
7# CONFIG_SYSCTL_SYSCALL is not set 6# CONFIG_SYSCTL_SYSCALL is not set
diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig
index c19fcdfdee37..9ad904a110de 100644
--- a/arch/sh/configs/migor_defconfig
+++ b/arch/sh/configs/migor_defconfig
@@ -3,7 +3,6 @@ CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
8# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 7# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
9# CONFIG_SYSCTL_SYSCALL is not set 8# CONFIG_SYSCTL_SYSCALL is not set
diff --git a/arch/sh/configs/polaris_defconfig b/arch/sh/configs/polaris_defconfig
index 984e3fe1ce5d..f3d5d9f76310 100644
--- a/arch/sh/configs/polaris_defconfig
+++ b/arch/sh/configs/polaris_defconfig
@@ -7,7 +7,6 @@ CONFIG_BSD_PROCESS_ACCT=y
7CONFIG_BSD_PROCESS_ACCT_V3=y 7CONFIG_BSD_PROCESS_ACCT_V3=y
8CONFIG_AUDIT=y 8CONFIG_AUDIT=y
9CONFIG_LOG_BUF_SHIFT=14 9CONFIG_LOG_BUF_SHIFT=14
10CONFIG_SYSFS_DEPRECATED_V2=y
11# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 10# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
12CONFIG_SLAB=y 11CONFIG_SLAB=y
13CONFIG_MODULES=y 12CONFIG_MODULES=y
diff --git a/arch/sh/configs/r7780mp_defconfig b/arch/sh/configs/r7780mp_defconfig
index e8b5472e6d84..920b8471ceb7 100644
--- a/arch/sh/configs/r7780mp_defconfig
+++ b/arch/sh/configs/r7780mp_defconfig
@@ -4,7 +4,6 @@ CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_SYSFS_DEPRECATED_V2=y
8# CONFIG_SYSCTL_SYSCALL is not set 7# CONFIG_SYSCTL_SYSCALL is not set
9# CONFIG_FUTEX is not set 8# CONFIG_FUTEX is not set
10# CONFIG_EPOLL is not set 9# CONFIG_EPOLL is not set
diff --git a/arch/sh/configs/r7785rp_defconfig b/arch/sh/configs/r7785rp_defconfig
index fd8848060982..c77da6be06b8 100644
--- a/arch/sh/configs/r7785rp_defconfig
+++ b/arch/sh/configs/r7785rp_defconfig
@@ -8,7 +8,6 @@ CONFIG_RCU_TRACE=y
8CONFIG_IKCONFIG=y 8CONFIG_IKCONFIG=y
9CONFIG_IKCONFIG_PROC=y 9CONFIG_IKCONFIG_PROC=y
10CONFIG_LOG_BUF_SHIFT=14 10CONFIG_LOG_BUF_SHIFT=14
11CONFIG_SYSFS_DEPRECATED_V2=y
12# CONFIG_SYSCTL_SYSCALL is not set 11# CONFIG_SYSCTL_SYSCALL is not set
13CONFIG_SLAB=y 12CONFIG_SLAB=y
14CONFIG_PROFILING=y 13CONFIG_PROFILING=y
diff --git a/arch/sh/configs/rts7751r2d1_defconfig b/arch/sh/configs/rts7751r2d1_defconfig
index a42f7c22ca1a..a3d081095ce2 100644
--- a/arch/sh/configs/rts7751r2d1_defconfig
+++ b/arch/sh/configs/rts7751r2d1_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6# CONFIG_SYSCTL_SYSCALL is not set 5# CONFIG_SYSCTL_SYSCALL is not set
7CONFIG_SLAB=y 6CONFIG_SLAB=y
diff --git a/arch/sh/configs/rts7751r2dplus_defconfig b/arch/sh/configs/rts7751r2dplus_defconfig
index 742aa61f2427..b1a04f3c598b 100644
--- a/arch/sh/configs/rts7751r2dplus_defconfig
+++ b/arch/sh/configs/rts7751r2dplus_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6# CONFIG_SYSCTL_SYSCALL is not set 5# CONFIG_SYSCTL_SYSCALL is not set
7CONFIG_SLAB=y 6CONFIG_SLAB=y
diff --git a/arch/sh/configs/sdk7780_defconfig b/arch/sh/configs/sdk7780_defconfig
index aed394d89346..ae1115849dda 100644
--- a/arch/sh/configs/sdk7780_defconfig
+++ b/arch/sh/configs/sdk7780_defconfig
@@ -6,7 +6,6 @@ CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_IKCONFIG=y 6CONFIG_IKCONFIG=y
7CONFIG_IKCONFIG_PROC=y 7CONFIG_IKCONFIG_PROC=y
8CONFIG_LOG_BUF_SHIFT=18 8CONFIG_LOG_BUF_SHIFT=18
9CONFIG_SYSFS_DEPRECATED_V2=y
10CONFIG_RELAY=y 9CONFIG_RELAY=y
11CONFIG_KALLSYMS_ALL=y 10CONFIG_KALLSYMS_ALL=y
12CONFIG_MODULES=y 11CONFIG_MODULES=y
diff --git a/arch/sh/configs/se7343_defconfig b/arch/sh/configs/se7343_defconfig
index 7a7e13853cfd..be9c474197b3 100644
--- a/arch/sh/configs/se7343_defconfig
+++ b/arch/sh/configs/se7343_defconfig
@@ -3,7 +3,6 @@ CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_SYSCTL_SYSCALL is not set 6# CONFIG_SYSCTL_SYSCALL is not set
8# CONFIG_FUTEX is not set 7# CONFIG_FUTEX is not set
9# CONFIG_EPOLL is not set 8# CONFIG_EPOLL is not set
diff --git a/arch/sh/configs/se7712_defconfig b/arch/sh/configs/se7712_defconfig
index 3620a7f4c821..1248635e4f88 100644
--- a/arch/sh/configs/se7712_defconfig
+++ b/arch/sh/configs/se7712_defconfig
@@ -5,7 +5,6 @@ CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
6CONFIG_BSD_PROCESS_ACCT=y 6CONFIG_BSD_PROCESS_ACCT=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 8# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
10CONFIG_KALLSYMS_ALL=y 9CONFIG_KALLSYMS_ALL=y
11# CONFIG_BUG is not set 10# CONFIG_BUG is not set
diff --git a/arch/sh/configs/se7721_defconfig b/arch/sh/configs/se7721_defconfig
index fe22f599c0cb..c3ba6e8a9818 100644
--- a/arch/sh/configs/se7721_defconfig
+++ b/arch/sh/configs/se7721_defconfig
@@ -5,7 +5,6 @@ CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
6CONFIG_BSD_PROCESS_ACCT=y 6CONFIG_BSD_PROCESS_ACCT=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 8# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
10CONFIG_KALLSYMS_ALL=y 9CONFIG_KALLSYMS_ALL=y
11# CONFIG_BUG is not set 10# CONFIG_BUG is not set
diff --git a/arch/sh/configs/se7722_defconfig b/arch/sh/configs/se7722_defconfig
index b9b64c38810e..ae998c7e2ee0 100644
--- a/arch/sh/configs/se7722_defconfig
+++ b/arch/sh/configs/se7722_defconfig
@@ -4,7 +4,6 @@ CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_SYSFS_DEPRECATED_V2=y
8CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
9CONFIG_PROFILING=y 8CONFIG_PROFILING=y
10CONFIG_MODULES=y 9CONFIG_MODULES=y
diff --git a/arch/sh/configs/se7724_defconfig b/arch/sh/configs/se7724_defconfig
index 03e736781c2e..ed35093e3758 100644
--- a/arch/sh/configs/se7724_defconfig
+++ b/arch/sh/configs/se7724_defconfig
@@ -3,7 +3,6 @@ CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_BSD_PROCESS_ACCT=y 4CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_KALLSYMS is not set 6# CONFIG_KALLSYMS is not set
8CONFIG_SLAB=y 7CONFIG_SLAB=y
9CONFIG_MODULES=y 8CONFIG_MODULES=y
diff --git a/arch/sh/configs/se7750_defconfig b/arch/sh/configs/se7750_defconfig
index 1a686b6d5cd4..912c98590e22 100644
--- a/arch/sh/configs/se7750_defconfig
+++ b/arch/sh/configs/se7750_defconfig
@@ -5,7 +5,6 @@ CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=14 7CONFIG_LOG_BUF_SHIFT=14
8CONFIG_SYSFS_DEPRECATED_V2=y
9# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 8# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
10# CONFIG_SYSCTL_SYSCALL is not set 9# CONFIG_SYSCTL_SYSCALL is not set
11# CONFIG_HOTPLUG is not set 10# CONFIG_HOTPLUG is not set
diff --git a/arch/sh/configs/se7751_defconfig b/arch/sh/configs/se7751_defconfig
index 7e03451a9fad..75c92fc1876b 100644
--- a/arch/sh/configs/se7751_defconfig
+++ b/arch/sh/configs/se7751_defconfig
@@ -2,7 +2,6 @@ CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y 3CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_LOG_BUF_SHIFT=14 4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_SYSFS_DEPRECATED_V2=y
6CONFIG_BLK_DEV_INITRD=y 5CONFIG_BLK_DEV_INITRD=y
7# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 6# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
8# CONFIG_SYSCTL_SYSCALL is not set 7# CONFIG_SYSCTL_SYSCALL is not set
diff --git a/arch/sh/configs/se7780_defconfig b/arch/sh/configs/se7780_defconfig
index 4cfc4deff135..c8c5e7f7a68d 100644
--- a/arch/sh/configs/se7780_defconfig
+++ b/arch/sh/configs/se7780_defconfig
@@ -3,7 +3,6 @@ CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_KALLSYMS is not set 6# CONFIG_KALLSYMS is not set
8# CONFIG_HOTPLUG is not set 7# CONFIG_HOTPLUG is not set
9# CONFIG_EPOLL is not set 8# CONFIG_EPOLL is not set
diff --git a/arch/sh/configs/sh03_defconfig b/arch/sh/configs/sh03_defconfig
index b95dc76b04c1..2051821724c6 100644
--- a/arch/sh/configs/sh03_defconfig
+++ b/arch/sh/configs/sh03_defconfig
@@ -3,7 +3,6 @@ CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y 4CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
8# CONFIG_SYSCTL_SYSCALL is not set 7# CONFIG_SYSCTL_SYSCALL is not set
9CONFIG_SLAB=y 8CONFIG_SLAB=y
diff --git a/arch/sh/configs/sh2007_defconfig b/arch/sh/configs/sh2007_defconfig
new file mode 100644
index 000000000000..0d2f41472a19
--- /dev/null
+++ b/arch/sh/configs/sh2007_defconfig
@@ -0,0 +1,212 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y
5CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_AUDIT=y
7CONFIG_AUDITSYSCALL=y
8CONFIG_IKCONFIG=y
9CONFIG_LOG_BUF_SHIFT=14
10# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
11CONFIG_KALLSYMS_ALL=y
12CONFIG_SLAB=y
13# CONFIG_BLK_DEV_BSG is not set
14CONFIG_CPU_SUBTYPE_SH7780=y
15CONFIG_MEMORY_SIZE=0x08000000
16# CONFIG_VSYSCALL is not set
17CONFIG_FLATMEM_MANUAL=y
18CONFIG_SH_SH2007=y
19CONFIG_HIGH_RES_TIMERS=y
20CONFIG_SH_DMA=y
21CONFIG_SH_DMA_API=y
22CONFIG_NR_DMA_CHANNELS_BOOL=y
23CONFIG_HZ_100=y
24CONFIG_CMDLINE_OVERWRITE=y
25CONFIG_CMDLINE="console=ttySC1,115200 ip=dhcp root=/dev/nfs rw nfsroot=/nfs/rootfs,rsize=1024,wsize=1024 earlyprintk=sh-sci.1"
26CONFIG_PCCARD=y
27CONFIG_BINFMT_MISC=y
28CONFIG_PACKET=y
29CONFIG_UNIX=y
30CONFIG_XFRM_USER=y
31CONFIG_NET_KEY=y
32CONFIG_NET_KEY_MIGRATE=y
33CONFIG_INET=y
34CONFIG_IP_ADVANCED_ROUTER=y
35CONFIG_IP_MULTIPLE_TABLES=y
36CONFIG_IP_ROUTE_MULTIPATH=y
37CONFIG_IP_ROUTE_VERBOSE=y
38CONFIG_IP_PNP=y
39CONFIG_IP_PNP_DHCP=y
40CONFIG_NET_IPIP=y
41# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
42# CONFIG_INET_XFRM_MODE_TUNNEL is not set
43# CONFIG_INET_XFRM_MODE_BEET is not set
44# CONFIG_INET_LRO is not set
45# CONFIG_IPV6 is not set
46CONFIG_NETWORK_SECMARK=y
47CONFIG_NET_PKTGEN=y
48CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
49CONFIG_BLK_DEV_LOOP=y
50CONFIG_BLK_DEV_RAM=y
51CONFIG_CDROM_PKTCDVD=y
52# CONFIG_MISC_DEVICES is not set
53CONFIG_RAID_ATTRS=y
54CONFIG_SCSI=y
55CONFIG_SCSI_TGT=y
56CONFIG_BLK_DEV_SD=y
57CONFIG_BLK_DEV_SR=y
58CONFIG_CHR_DEV_SG=y
59CONFIG_SCSI_MULTI_LUN=y
60CONFIG_SCSI_CONSTANTS=y
61CONFIG_SCSI_LOGGING=y
62CONFIG_SCSI_SCAN_ASYNC=y
63CONFIG_SCSI_SPI_ATTRS=y
64CONFIG_SCSI_FC_ATTRS=y
65CONFIG_SCSI_ISCSI_ATTRS=y
66CONFIG_SCSI_SRP_ATTRS=y
67# CONFIG_SCSI_LOWLEVEL is not set
68CONFIG_NETDEVICES=y
69CONFIG_DUMMY=y
70CONFIG_EQUALIZER=y
71CONFIG_TUN=y
72CONFIG_VETH=y
73CONFIG_NET_ETHERNET=y
74CONFIG_SMSC911X=y
75# CONFIG_NETDEV_1000 is not set
76# CONFIG_NETDEV_10000 is not set
77# CONFIG_WLAN is not set
78CONFIG_INPUT_FF_MEMLESS=y
79# CONFIG_INPUT_MOUSEDEV is not set
80# CONFIG_INPUT_KEYBOARD is not set
81# CONFIG_INPUT_MOUSE is not set
82# CONFIG_SERIO is not set
83CONFIG_VT_HW_CONSOLE_BINDING=y
84# CONFIG_DEVKMEM is not set
85CONFIG_SERIAL_SH_SCI=y
86CONFIG_SERIAL_SH_SCI_CONSOLE=y
87# CONFIG_LEGACY_PTYS is not set
88# CONFIG_HWMON is not set
89CONFIG_WATCHDOG=y
90CONFIG_SH_WDT=y
91CONFIG_SSB=y
92CONFIG_FB=y
93CONFIG_BACKLIGHT_LCD_SUPPORT=y
94# CONFIG_LCD_CLASS_DEVICE is not set
95CONFIG_FRAMEBUFFER_CONSOLE=y
96CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
97CONFIG_LOGO=y
98# CONFIG_HID_SUPPORT is not set
99CONFIG_USB=y
100CONFIG_USB_DEVICEFS=y
101# CONFIG_USB_DEVICE_CLASS is not set
102CONFIG_USB_MON=y
103CONFIG_NEW_LEDS=y
104CONFIG_LEDS_CLASS=y
105CONFIG_LEDS_TRIGGERS=y
106CONFIG_RTC_CLASS=y
107CONFIG_RTC_INTF_DEV_UIE_EMUL=y
108CONFIG_DMADEVICES=y
109CONFIG_TIMB_DMA=y
110CONFIG_EXT3_FS=y
111CONFIG_ISO9660_FS=y
112CONFIG_JOLIET=y
113CONFIG_ZISOFS=y
114CONFIG_UDF_FS=y
115CONFIG_MSDOS_FS=y
116CONFIG_VFAT_FS=y
117CONFIG_FAT_DEFAULT_CODEPAGE=932
118CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
119CONFIG_PROC_KCORE=y
120CONFIG_TMPFS=y
121CONFIG_TMPFS_POSIX_ACL=y
122CONFIG_CONFIGFS_FS=y
123# CONFIG_MISC_FILESYSTEMS is not set
124CONFIG_NFS_FS=y
125CONFIG_NFS_V3=y
126CONFIG_NFS_V3_ACL=y
127CONFIG_NFS_V4=y
128CONFIG_ROOT_NFS=y
129CONFIG_NLS_DEFAULT="utf8"
130CONFIG_NLS_CODEPAGE_437=y
131CONFIG_NLS_CODEPAGE_737=y
132CONFIG_NLS_CODEPAGE_775=y
133CONFIG_NLS_CODEPAGE_850=y
134CONFIG_NLS_CODEPAGE_852=y
135CONFIG_NLS_CODEPAGE_855=y
136CONFIG_NLS_CODEPAGE_857=y
137CONFIG_NLS_CODEPAGE_860=y
138CONFIG_NLS_CODEPAGE_861=y
139CONFIG_NLS_CODEPAGE_862=y
140CONFIG_NLS_CODEPAGE_863=y
141CONFIG_NLS_CODEPAGE_864=y
142CONFIG_NLS_CODEPAGE_865=y
143CONFIG_NLS_CODEPAGE_866=y
144CONFIG_NLS_CODEPAGE_869=y
145CONFIG_NLS_CODEPAGE_936=y
146CONFIG_NLS_CODEPAGE_950=y
147CONFIG_NLS_CODEPAGE_932=y
148CONFIG_NLS_CODEPAGE_949=y
149CONFIG_NLS_CODEPAGE_874=y
150CONFIG_NLS_ISO8859_8=y
151CONFIG_NLS_CODEPAGE_1250=y
152CONFIG_NLS_CODEPAGE_1251=y
153CONFIG_NLS_ASCII=y
154CONFIG_NLS_ISO8859_1=y
155CONFIG_NLS_ISO8859_2=y
156CONFIG_NLS_ISO8859_3=y
157CONFIG_NLS_ISO8859_4=y
158CONFIG_NLS_ISO8859_5=y
159CONFIG_NLS_ISO8859_6=y
160CONFIG_NLS_ISO8859_7=y
161CONFIG_NLS_ISO8859_9=y
162CONFIG_NLS_ISO8859_13=y
163CONFIG_NLS_ISO8859_14=y
164CONFIG_NLS_ISO8859_15=y
165CONFIG_NLS_KOI8_R=y
166CONFIG_NLS_KOI8_U=y
167CONFIG_NLS_UTF8=y
168# CONFIG_ENABLE_WARN_DEPRECATED is not set
169# CONFIG_ENABLE_MUST_CHECK is not set
170CONFIG_DEBUG_FS=y
171CONFIG_DEBUG_KERNEL=y
172# CONFIG_DETECT_SOFTLOCKUP is not set
173# CONFIG_SCHED_DEBUG is not set
174CONFIG_DEBUG_INFO=y
175CONFIG_FRAME_POINTER=y
176# CONFIG_RCU_CPU_STALL_DETECTOR is not set
177CONFIG_SH_STANDARD_BIOS=y
178CONFIG_CRYPTO_NULL=y
179CONFIG_CRYPTO_AUTHENC=y
180CONFIG_CRYPTO_ECB=y
181CONFIG_CRYPTO_LRW=y
182CONFIG_CRYPTO_PCBC=y
183CONFIG_CRYPTO_XTS=y
184CONFIG_CRYPTO_HMAC=y
185CONFIG_CRYPTO_XCBC=y
186CONFIG_CRYPTO_MD4=y
187CONFIG_CRYPTO_MICHAEL_MIC=y
188CONFIG_CRYPTO_SHA1=y
189CONFIG_CRYPTO_SHA256=y
190CONFIG_CRYPTO_SHA512=y
191CONFIG_CRYPTO_TGR192=y
192CONFIG_CRYPTO_WP512=y
193CONFIG_CRYPTO_AES=y
194CONFIG_CRYPTO_ANUBIS=y
195CONFIG_CRYPTO_ARC4=y
196CONFIG_CRYPTO_BLOWFISH=y
197CONFIG_CRYPTO_CAMELLIA=y
198CONFIG_CRYPTO_CAST5=y
199CONFIG_CRYPTO_CAST6=y
200CONFIG_CRYPTO_FCRYPT=y
201CONFIG_CRYPTO_KHAZAD=y
202CONFIG_CRYPTO_SEED=y
203CONFIG_CRYPTO_SERPENT=y
204CONFIG_CRYPTO_TEA=y
205CONFIG_CRYPTO_TWOFISH=y
206CONFIG_CRYPTO_DEFLATE=y
207CONFIG_CRYPTO_LZO=y
208# CONFIG_CRYPTO_ANSI_CPRNG is not set
209# CONFIG_CRYPTO_HW is not set
210CONFIG_CRC_CCITT=y
211CONFIG_CRC16=y
212CONFIG_LIBCRC32C=y
diff --git a/arch/sh/configs/sh7710voipgw_defconfig b/arch/sh/configs/sh7710voipgw_defconfig
index b804641c8dd2..f92ad17cd629 100644
--- a/arch/sh/configs/sh7710voipgw_defconfig
+++ b/arch/sh/configs/sh7710voipgw_defconfig
@@ -3,7 +3,6 @@ CONFIG_EXPERIMENTAL=y
3CONFIG_SYSVIPC=y 3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y 4CONFIG_POSIX_MQUEUE=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7# CONFIG_SYSCTL_SYSCALL is not set 6# CONFIG_SYSCTL_SYSCALL is not set
8# CONFIG_FUTEX is not set 7# CONFIG_FUTEX is not set
9# CONFIG_EPOLL is not set 8# CONFIG_EPOLL is not set
diff --git a/arch/sh/configs/sh7757lcr_defconfig b/arch/sh/configs/sh7757lcr_defconfig
new file mode 100644
index 000000000000..273f3fa198f7
--- /dev/null
+++ b/arch/sh/configs/sh7757lcr_defconfig
@@ -0,0 +1,85 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_POSIX_MQUEUE=y
5CONFIG_BSD_PROCESS_ACCT=y
6CONFIG_TASKSTATS=y
7CONFIG_TASK_DELAY_ACCT=y
8CONFIG_TASK_XACCT=y
9CONFIG_TASK_IO_ACCOUNTING=y
10CONFIG_LOG_BUF_SHIFT=14
11CONFIG_BLK_DEV_INITRD=y
12# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
13# CONFIG_SYSCTL_SYSCALL is not set
14CONFIG_KALLSYMS_ALL=y
15CONFIG_SLAB=y
16CONFIG_MODULES=y
17CONFIG_MODULE_UNLOAD=y
18# CONFIG_BLK_DEV_BSG is not set
19CONFIG_CPU_SUBTYPE_SH7757=y
20CONFIG_MEMORY_START=0x40000000
21CONFIG_MEMORY_SIZE=0x0f000000
22CONFIG_PMB=y
23CONFIG_FLATMEM_MANUAL=y
24CONFIG_SH_SH7757LCR=y
25CONFIG_HEARTBEAT=y
26CONFIG_SECCOMP=y
27CONFIG_CMDLINE_OVERWRITE=y
28CONFIG_CMDLINE="console=ttySC2,115200 root=/dev/nfs ip=dhcp"
29CONFIG_NET=y
30CONFIG_PACKET=y
31CONFIG_UNIX=y
32CONFIG_INET=y
33CONFIG_IP_MULTICAST=y
34CONFIG_IP_PNP=y
35CONFIG_IP_PNP_DHCP=y
36# CONFIG_INET_LRO is not set
37CONFIG_IPV6=y
38# CONFIG_WIRELESS is not set
39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
40# CONFIG_FW_LOADER is not set
41CONFIG_BLK_DEV_RAM=y
42# CONFIG_MISC_DEVICES is not set
43CONFIG_NETDEVICES=y
44CONFIG_PHYLIB=y
45CONFIG_VITESSE_PHY=y
46CONFIG_MDIO_BITBANG=y
47CONFIG_NET_ETHERNET=y
48CONFIG_MII=y
49# CONFIG_NETDEV_10000 is not set
50# CONFIG_WLAN is not set
51# CONFIG_KEYBOARD_ATKBD is not set
52# CONFIG_MOUSE_PS2 is not set
53# CONFIG_SERIO is not set
54CONFIG_SERIAL_8250=y
55CONFIG_SERIAL_8250_CONSOLE=y
56CONFIG_SERIAL_8250_NR_UARTS=2
57CONFIG_SERIAL_SH_SCI=y
58CONFIG_SERIAL_SH_SCI_NR_UARTS=3
59CONFIG_SERIAL_SH_SCI_CONSOLE=y
60# CONFIG_LEGACY_PTYS is not set
61# CONFIG_HW_RANDOM is not set
62# CONFIG_HWMON is not set
63# CONFIG_USB_SUPPORT is not set
64CONFIG_EXT2_FS=y
65CONFIG_EXT3_FS=y
66CONFIG_INOTIFY=y
67CONFIG_ISO9660_FS=y
68CONFIG_VFAT_FS=y
69CONFIG_PROC_KCORE=y
70CONFIG_TMPFS=y
71CONFIG_SQUASHFS=y
72CONFIG_MINIX_FS=y
73CONFIG_NFS_FS=y
74CONFIG_ROOT_NFS=y
75CONFIG_NLS_CODEPAGE_437=y
76CONFIG_NLS_CODEPAGE_932=y
77CONFIG_NLS_ISO8859_1=y
78CONFIG_DEBUG_KERNEL=y
79# CONFIG_DETECT_SOFTLOCKUP is not set
80# CONFIG_SCHED_DEBUG is not set
81# CONFIG_DEBUG_BUGVERBOSE is not set
82CONFIG_DEBUG_INFO=y
83# CONFIG_RCU_CPU_STALL_DETECTOR is not set
84# CONFIG_FTRACE is not set
85# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/sh/configs/sh7763rdp_defconfig b/arch/sh/configs/sh7763rdp_defconfig
index 361876786932..479536440264 100644
--- a/arch/sh/configs/sh7763rdp_defconfig
+++ b/arch/sh/configs/sh7763rdp_defconfig
@@ -3,7 +3,6 @@ CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y 3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_NAMESPACES=y 6CONFIG_NAMESPACES=y
8CONFIG_UTS_NS=y 7CONFIG_UTS_NS=y
9CONFIG_IPC_NS=y 8CONFIG_IPC_NS=y
diff --git a/arch/sh/configs/sh7785lcr_defconfig b/arch/sh/configs/sh7785lcr_defconfig
index ee6b81f7539e..51561f5677d8 100644
--- a/arch/sh/configs/sh7785lcr_defconfig
+++ b/arch/sh/configs/sh7785lcr_defconfig
@@ -4,7 +4,6 @@ CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_SYSFS_DEPRECATED_V2=y
8CONFIG_SLAB=y 7CONFIG_SLAB=y
9CONFIG_PROFILING=y 8CONFIG_PROFILING=y
10CONFIG_MODULES=y 9CONFIG_MODULES=y
diff --git a/arch/sh/configs/shx3_defconfig b/arch/sh/configs/shx3_defconfig
index bb4f60c0f866..3f92d37c6374 100644
--- a/arch/sh/configs/shx3_defconfig
+++ b/arch/sh/configs/shx3_defconfig
@@ -15,7 +15,6 @@ CONFIG_CGROUP_DEVICE=y
15CONFIG_CGROUP_CPUACCT=y 15CONFIG_CGROUP_CPUACCT=y
16CONFIG_RESOURCE_COUNTERS=y 16CONFIG_RESOURCE_COUNTERS=y
17CONFIG_CGROUP_MEM_RES_CTLR=y 17CONFIG_CGROUP_MEM_RES_CTLR=y
18CONFIG_SYSFS_DEPRECATED_V2=y
19CONFIG_RELAY=y 18CONFIG_RELAY=y
20CONFIG_NAMESPACES=y 19CONFIG_NAMESPACES=y
21CONFIG_UTS_NS=y 20CONFIG_UTS_NS=y
diff --git a/arch/sh/configs/snapgear_defconfig b/arch/sh/configs/snapgear_defconfig
index f38c98341f15..7eae4e59d7f0 100644
--- a/arch/sh/configs/snapgear_defconfig
+++ b/arch/sh/configs/snapgear_defconfig
@@ -1,7 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2# CONFIG_SWAP is not set 2# CONFIG_SWAP is not set
3CONFIG_LOG_BUF_SHIFT=14 3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_SYSFS_DEPRECATED_V2=y
5CONFIG_BLK_DEV_INITRD=y 4CONFIG_BLK_DEV_INITRD=y
6# CONFIG_SYSCTL_SYSCALL is not set 5# CONFIG_SYSCTL_SYSCALL is not set
7# CONFIG_HOTPLUG is not set 6# CONFIG_HOTPLUG is not set
diff --git a/arch/sh/configs/systemh_defconfig b/arch/sh/configs/systemh_defconfig
index 7007d00c67e0..b58dfc505efe 100644
--- a/arch/sh/configs/systemh_defconfig
+++ b/arch/sh/configs/systemh_defconfig
@@ -1,6 +1,5 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_LOG_BUF_SHIFT=14 2CONFIG_LOG_BUF_SHIFT=14
3CONFIG_SYSFS_DEPRECATED_V2=y
4CONFIG_BLK_DEV_INITRD=y 3CONFIG_BLK_DEV_INITRD=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 4# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6# CONFIG_SYSCTL_SYSCALL is not set 5# CONFIG_SYSCTL_SYSCALL is not set
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
index 45c309ff447e..0f558914e760 100644
--- a/arch/sh/configs/titan_defconfig
+++ b/arch/sh/configs/titan_defconfig
@@ -5,7 +5,6 @@ CONFIG_POSIX_MQUEUE=y
5CONFIG_IKCONFIG=y 5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y 6CONFIG_IKCONFIG_PROC=y
7CONFIG_LOG_BUF_SHIFT=16 7CONFIG_LOG_BUF_SHIFT=16
8CONFIG_SYSFS_DEPRECATED_V2=y
9CONFIG_BLK_DEV_INITRD=y 8CONFIG_BLK_DEV_INITRD=y
10# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 9# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
11# CONFIG_SYSCTL_SYSCALL is not set 10# CONFIG_SYSCTL_SYSCALL is not set
diff --git a/arch/sh/configs/ul2_defconfig b/arch/sh/configs/ul2_defconfig
index e107d424acf0..2d288b887fbd 100644
--- a/arch/sh/configs/ul2_defconfig
+++ b/arch/sh/configs/ul2_defconfig
@@ -4,7 +4,6 @@ CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
5CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
6CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
7CONFIG_SYSFS_DEPRECATED_V2=y
8CONFIG_BLK_DEV_INITRD=y 7CONFIG_BLK_DEV_INITRD=y
9CONFIG_PROFILING=y 8CONFIG_PROFILING=y
10CONFIG_MODULES=y 9CONFIG_MODULES=y
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index 4a277224a871..f46848f088e4 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -412,8 +412,8 @@ EXPORT_SYMBOL(unregister_dmac);
412static int __init dma_api_init(void) 412static int __init dma_api_init(void)
413{ 413{
414 printk(KERN_NOTICE "DMA: Registering DMA API.\n"); 414 printk(KERN_NOTICE "DMA: Registering DMA API.\n");
415 create_proc_read_entry("dma", 0, 0, dma_read_proc, 0); 415 return create_proc_read_entry("dma", 0, 0, dma_read_proc, 0)
416 return 0; 416 ? 0 : -ENOMEM;
417} 417}
418subsys_initcall(dma_api_init); 418subsys_initcall(dma_api_init);
419 419
diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 4a59e6890876..82f0a335fd19 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_SH_RTS7751R2D) += fixups-rts7751r2d.o
19obj-$(CONFIG_SH_SH03) += fixups-sh03.o 19obj-$(CONFIG_SH_SH03) += fixups-sh03.o
20obj-$(CONFIG_SH_HIGHLANDER) += fixups-r7780rp.o 20obj-$(CONFIG_SH_HIGHLANDER) += fixups-r7780rp.o
21obj-$(CONFIG_SH_SH7785LCR) += fixups-r7780rp.o 21obj-$(CONFIG_SH_SH7785LCR) += fixups-r7780rp.o
22obj-$(CONFIG_SH_SDK7786) += fixups-sdk7786.o
22obj-$(CONFIG_SH_SDK7780) += fixups-sdk7780.o 23obj-$(CONFIG_SH_SDK7780) += fixups-sdk7780.o
23obj-$(CONFIG_SH_7780_SOLUTION_ENGINE) += fixups-sdk7780.o 24obj-$(CONFIG_SH_7780_SOLUTION_ENGINE) += fixups-sdk7780.o
24obj-$(CONFIG_SH_TITAN) += fixups-titan.o 25obj-$(CONFIG_SH_TITAN) += fixups-titan.o
diff --git a/arch/sh/drivers/pci/fixups-sdk7786.c b/arch/sh/drivers/pci/fixups-sdk7786.c
new file mode 100644
index 000000000000..0e18ee332553
--- /dev/null
+++ b/arch/sh/drivers/pci/fixups-sdk7786.c
@@ -0,0 +1,67 @@
1/*
2 * SDK7786 FPGA PCIe mux handling
3 *
4 * Copyright (C) 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#define pr_fmt(fmt) "PCI: " fmt
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <mach/fpga.h>
16
17/*
18 * The SDK7786 FPGA supports mangling of most of the slots in some way or
19 * another. Slots 3/4 are special in that only one can be supported at a
20 * time, and both appear on port 3 to the PCI bus scan. Enabling slot 4
21 * (the horizontal edge connector) will disable slot 3 entirely.
22 *
23 * Misconfigurations can be detected through the FPGA via the slot
24 * resistors to determine card presence. Hotplug remains unsupported.
25 */
26static unsigned int slot4en __devinitdata;
27
28char *__devinit pcibios_setup(char *str)
29{
30 if (strcmp(str, "slot4en") == 0) {
31 slot4en = 1;
32 return NULL;
33 }
34
35 return str;
36}
37
38static int __init sdk7786_pci_init(void)
39{
40 u16 data = fpga_read_reg(PCIECR);
41
42 /*
43 * Enable slot #4 if it's been specified on the command line.
44 *
45 * Optionally reroute if slot #4 has a card present while slot #3
46 * does not, regardless of command line value.
47 *
48 * Card presence is logically inverted.
49 */
50 slot4en ?: (!(data & PCIECR_PRST4) && (data & PCIECR_PRST3));
51 if (slot4en) {
52 pr_info("Activating PCIe slot#4 (disabling slot#3)\n");
53
54 data &= ~PCIECR_PCIEMUX1;
55 fpga_write_reg(data, PCIECR);
56
57 /* Warn about forced rerouting if slot#3 is occupied */
58 if ((data & PCIECR_PRST3) == 0) {
59 pr_warning("Unreachable card detected in slot#3\n");
60 return -EBUSY;
61 }
62 } else
63 pr_info("PCIe slot#4 disabled\n");
64
65 return 0;
66}
67postcore_initcall(sdk7786_pci_init);
diff --git a/arch/sh/drivers/pci/ops-sh4.c b/arch/sh/drivers/pci/ops-sh4.c
index 0b81999fb88b..b6234203e0ac 100644
--- a/arch/sh/drivers/pci/ops-sh4.c
+++ b/arch/sh/drivers/pci/ops-sh4.c
@@ -9,6 +9,7 @@
9 */ 9 */
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/io.h> 11#include <linux/io.h>
12#include <linux/spinlock.h>
12#include <asm/addrspace.h> 13#include <asm/addrspace.h>
13#include "pci-sh4.h" 14#include "pci-sh4.h"
14 15
@@ -18,8 +19,6 @@
18#define CONFIG_CMD(bus, devfn, where) \ 19#define CONFIG_CMD(bus, devfn, where) \
19 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3)) 20 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
20 21
21static DEFINE_SPINLOCK(sh4_pci_lock);
22
23/* 22/*
24 * Functions for accessing PCI configuration space with type 1 accesses 23 * Functions for accessing PCI configuration space with type 1 accesses
25 */ 24 */
@@ -34,10 +33,10 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,
34 * PCIPDR may only be accessed as 32 bit words, 33 * PCIPDR may only be accessed as 32 bit words,
35 * so we must do byte alignment by hand 34 * so we must do byte alignment by hand
36 */ 35 */
37 spin_lock_irqsave(&sh4_pci_lock, flags); 36 raw_spin_lock_irqsave(&pci_config_lock, flags);
38 pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR); 37 pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
39 data = pci_read_reg(chan, SH4_PCIPDR); 38 data = pci_read_reg(chan, SH4_PCIPDR);
40 spin_unlock_irqrestore(&sh4_pci_lock, flags); 39 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
41 40
42 switch (size) { 41 switch (size) {
43 case 1: 42 case 1:
@@ -69,10 +68,10 @@ static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,
69 int shift; 68 int shift;
70 u32 data; 69 u32 data;
71 70
72 spin_lock_irqsave(&sh4_pci_lock, flags); 71 raw_spin_lock_irqsave(&pci_config_lock, flags);
73 pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR); 72 pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
74 data = pci_read_reg(chan, SH4_PCIPDR); 73 data = pci_read_reg(chan, SH4_PCIPDR);
75 spin_unlock_irqrestore(&sh4_pci_lock, flags); 74 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
76 75
77 switch (size) { 76 switch (size) {
78 case 1: 77 case 1:
diff --git a/arch/sh/drivers/pci/ops-sh7786.c b/arch/sh/drivers/pci/ops-sh7786.c
index 48f594b9582b..128421009e3f 100644
--- a/arch/sh/drivers/pci/ops-sh7786.c
+++ b/arch/sh/drivers/pci/ops-sh7786.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Generic SH7786 PCI-Express operations. 2 * Generic SH7786 PCI-Express operations.
3 * 3 *
4 * Copyright (C) 2009 Paul Mundt 4 * Copyright (C) 2009 - 2010 Paul Mundt
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License v2. See the file "COPYING" in the main directory of this archive 7 * License v2. See the file "COPYING" in the main directory of this archive
@@ -19,37 +19,72 @@ enum {
19 PCI_ACCESS_WRITE, 19 PCI_ACCESS_WRITE,
20}; 20};
21 21
22static DEFINE_SPINLOCK(sh7786_pcie_lock);
23
24static int sh7786_pcie_config_access(unsigned char access_type, 22static int sh7786_pcie_config_access(unsigned char access_type,
25 struct pci_bus *bus, unsigned int devfn, int where, u32 *data) 23 struct pci_bus *bus, unsigned int devfn, int where, u32 *data)
26{ 24{
27 struct pci_channel *chan = bus->sysdata; 25 struct pci_channel *chan = bus->sysdata;
28 int dev, func; 26 int dev, func, type, reg;
29 27
30 dev = PCI_SLOT(devfn); 28 dev = PCI_SLOT(devfn);
31 func = PCI_FUNC(devfn); 29 func = PCI_FUNC(devfn);
30 type = !!bus->parent;
31 reg = where & ~3;
32 32
33 if (bus->number > 255 || dev > 31 || func > 7) 33 if (bus->number > 255 || dev > 31 || func > 7)
34 return PCIBIOS_FUNC_NOT_SUPPORTED; 34 return PCIBIOS_FUNC_NOT_SUPPORTED;
35 if (devfn) 35
36 return PCIBIOS_DEVICE_NOT_FOUND; 36 /*
37 * While each channel has its own memory-mapped extended config
38 * space, it's generally only accessible when in endpoint mode.
39 * When in root complex mode, the controller is unable to target
40 * itself with either type 0 or type 1 accesses, and indeed, any
41 * controller initiated target transfer to its own config space
42 * result in a completer abort.
43 *
44 * Each channel effectively only supports a single device, but as
45 * the same channel <-> device access works for any PCI_SLOT()
46 * value, we cheat a bit here and bind the controller's config
47 * space to devfn 0 in order to enable self-enumeration. In this
48 * case the regular PAR/PDR path is sidelined and the mangled
49 * config access itself is initiated as a SuperHyway transaction.
50 */
51 if (pci_is_root_bus(bus)) {
52 if (dev == 0) {
53 if (access_type == PCI_ACCESS_READ)
54 *data = pci_read_reg(chan, PCI_REG(reg));
55 else
56 pci_write_reg(chan, *data, PCI_REG(reg));
57
58 return PCIBIOS_SUCCESSFUL;
59 } else if (dev > 1)
60 return PCIBIOS_DEVICE_NOT_FOUND;
61 }
62
63 /* Clear errors */
64 pci_write_reg(chan, pci_read_reg(chan, SH4A_PCIEERRFR), SH4A_PCIEERRFR);
37 65
38 /* Set the PIO address */ 66 /* Set the PIO address */
39 pci_write_reg(chan, (bus->number << 24) | (dev << 19) | 67 pci_write_reg(chan, (bus->number << 24) | (dev << 19) |
40 (func << 16) | (where & ~3), SH4A_PCIEPAR); 68 (func << 16) | reg, SH4A_PCIEPAR);
41 69
42 /* Enable the configuration access */ 70 /* Enable the configuration access */
43 pci_write_reg(chan, (1 << 31), SH4A_PCIEPCTLR); 71 pci_write_reg(chan, (1 << 31) | (type << 8), SH4A_PCIEPCTLR);
72
73 /* Check for errors */
74 if (pci_read_reg(chan, SH4A_PCIEERRFR) & 0x10)
75 return PCIBIOS_DEVICE_NOT_FOUND;
76
77 /* Check for master and target aborts */
78 if (pci_read_reg(chan, SH4A_PCIEPCICONF1) & ((1 << 29) | (1 << 28)))
79 return PCIBIOS_DEVICE_NOT_FOUND;
44 80
45 if (access_type == PCI_ACCESS_READ) 81 if (access_type == PCI_ACCESS_READ)
46 *data = pci_read_reg(chan, SH4A_PCIEPDR); 82 *data = pci_read_reg(chan, SH4A_PCIEPDR);
47 else 83 else
48 pci_write_reg(chan, *data, SH4A_PCIEPDR); 84 pci_write_reg(chan, *data, SH4A_PCIEPDR);
49 85
50 /* Check for master and target aborts */ 86 /* Disable the configuration access */
51 if (pci_read_reg(chan, SH4A_PCIEPCICONF1) & ((1 << 29) | (1 << 28))) 87 pci_write_reg(chan, 0, SH4A_PCIEPCTLR);
52 return PCIBIOS_DEVICE_NOT_FOUND;
53 88
54 return PCIBIOS_SUCCESSFUL; 89 return PCIBIOS_SUCCESSFUL;
55} 90}
@@ -66,11 +101,13 @@ static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,
66 else if ((size == 4) && (where & 3)) 101 else if ((size == 4) && (where & 3))
67 return PCIBIOS_BAD_REGISTER_NUMBER; 102 return PCIBIOS_BAD_REGISTER_NUMBER;
68 103
69 spin_lock_irqsave(&sh7786_pcie_lock, flags); 104 raw_spin_lock_irqsave(&pci_config_lock, flags);
70 ret = sh7786_pcie_config_access(PCI_ACCESS_READ, bus, 105 ret = sh7786_pcie_config_access(PCI_ACCESS_READ, bus,
71 devfn, where, &data); 106 devfn, where, &data);
72 if (ret != PCIBIOS_SUCCESSFUL) 107 if (ret != PCIBIOS_SUCCESSFUL) {
108 *val = 0xffffffff;
73 goto out; 109 goto out;
110 }
74 111
75 if (size == 1) 112 if (size == 1)
76 *val = (data >> ((where & 3) << 3)) & 0xff; 113 *val = (data >> ((where & 3) << 3)) & 0xff;
@@ -84,7 +121,7 @@ static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,
84 devfn, where, size, (unsigned long)*val); 121 devfn, where, size, (unsigned long)*val);
85 122
86out: 123out:
87 spin_unlock_irqrestore(&sh7786_pcie_lock, flags); 124 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
88 return ret; 125 return ret;
89} 126}
90 127
@@ -100,7 +137,7 @@ static int sh7786_pcie_write(struct pci_bus *bus, unsigned int devfn,
100 else if ((size == 4) && (where & 3)) 137 else if ((size == 4) && (where & 3))
101 return PCIBIOS_BAD_REGISTER_NUMBER; 138 return PCIBIOS_BAD_REGISTER_NUMBER;
102 139
103 spin_lock_irqsave(&sh7786_pcie_lock, flags); 140 raw_spin_lock_irqsave(&pci_config_lock, flags);
104 ret = sh7786_pcie_config_access(PCI_ACCESS_READ, bus, 141 ret = sh7786_pcie_config_access(PCI_ACCESS_READ, bus,
105 devfn, where, &data); 142 devfn, where, &data);
106 if (ret != PCIBIOS_SUCCESSFUL) 143 if (ret != PCIBIOS_SUCCESSFUL)
@@ -124,7 +161,7 @@ static int sh7786_pcie_write(struct pci_bus *bus, unsigned int devfn,
124 ret = sh7786_pcie_config_access(PCI_ACCESS_WRITE, bus, 161 ret = sh7786_pcie_config_access(PCI_ACCESS_WRITE, bus,
125 devfn, where, &data); 162 devfn, where, &data);
126out: 163out:
127 spin_unlock_irqrestore(&sh7786_pcie_lock, flags); 164 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
128 return ret; 165 return ret;
129} 166}
130 167
diff --git a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
index f98141b3b7d7..86adb1e235cd 100644
--- a/arch/sh/drivers/pci/pci-sh7751.c
+++ b/arch/sh/drivers/pci/pci-sh7751.c
@@ -81,7 +81,7 @@ static int __init sh7751_pci_init(void)
81 unsigned int id; 81 unsigned int id;
82 u32 word, reg; 82 u32 word, reg;
83 83
84 printk(KERN_NOTICE "PCI: Starting intialization.\n"); 84 printk(KERN_NOTICE "PCI: Starting initialization.\n");
85 85
86 chan->reg_base = 0xfe200000; 86 chan->reg_base = 0xfe200000;
87 87
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index ffdcbf10b95e..edb7cca14882 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -246,7 +246,7 @@ static int __init sh7780_pci_init(void)
246 const char *type; 246 const char *type;
247 int ret, i; 247 int ret, i;
248 248
249 printk(KERN_NOTICE "PCI: Starting intialization.\n"); 249 printk(KERN_NOTICE "PCI: Starting initialization.\n");
250 250
251 chan->reg_base = 0xfe040000; 251 chan->reg_base = 0xfe040000;
252 252
diff --git a/arch/sh/drivers/pci/pci-sh7780.h b/arch/sh/drivers/pci/pci-sh7780.h
index 205dcbefe275..1742e2c9db7a 100644
--- a/arch/sh/drivers/pci/pci-sh7780.h
+++ b/arch/sh/drivers/pci/pci-sh7780.h
@@ -12,12 +12,6 @@
12#ifndef _PCI_SH7780_H_ 12#ifndef _PCI_SH7780_H_
13#define _PCI_SH7780_H_ 13#define _PCI_SH7780_H_
14 14
15#define PCI_VENDOR_ID_RENESAS 0x1912
16#define PCI_DEVICE_ID_RENESAS_SH7781 0x0001
17#define PCI_DEVICE_ID_RENESAS_SH7780 0x0002
18#define PCI_DEVICE_ID_RENESAS_SH7763 0x0004
19#define PCI_DEVICE_ID_RENESAS_SH7785 0x0007
20
21/* SH7780 Control Registers */ 15/* SH7780 Control Registers */
22#define PCIECR 0xFE000008 16#define PCIECR 0xFE000008
23#define PCIECR_ENBL 0x01 17#define PCIECR_ENBL 0x01
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1e9598d2bbf4..60ee09a4e121 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -19,6 +19,7 @@
19#include <linux/dma-debug.h> 19#include <linux/dma-debug.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/spinlock.h>
22 23
23unsigned long PCIBIOS_MIN_IO = 0x0000; 24unsigned long PCIBIOS_MIN_IO = 0x0000;
24unsigned long PCIBIOS_MIN_MEM = 0; 25unsigned long PCIBIOS_MIN_MEM = 0;
@@ -56,6 +57,11 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
56 } 57 }
57} 58}
58 59
60/*
61 * This interrupt-safe spinlock protects all accesses to PCI
62 * configuration space.
63 */
64DEFINE_RAW_SPINLOCK(pci_config_lock);
59static DEFINE_MUTEX(pci_scan_mutex); 65static DEFINE_MUTEX(pci_scan_mutex);
60 66
61int __devinit register_pci_controller(struct pci_channel *hose) 67int __devinit register_pci_controller(struct pci_channel *hose)
@@ -233,40 +239,7 @@ void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
233 239
234int pcibios_enable_device(struct pci_dev *dev, int mask) 240int pcibios_enable_device(struct pci_dev *dev, int mask)
235{ 241{
236 u16 cmd, old_cmd; 242 return pci_enable_resources(dev, mask);
237 int idx;
238 struct resource *r;
239
240 pci_read_config_word(dev, PCI_COMMAND, &cmd);
241 old_cmd = cmd;
242 for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
243 /* Only set up the requested stuff */
244 if (!(mask & (1<<idx)))
245 continue;
246
247 r = &dev->resource[idx];
248 if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
249 continue;
250 if ((idx == PCI_ROM_RESOURCE) &&
251 (!(r->flags & IORESOURCE_ROM_ENABLE)))
252 continue;
253 if (!r->start && r->end) {
254 printk(KERN_ERR "PCI: Device %s not available "
255 "because of resource collisions\n",
256 pci_name(dev));
257 return -EINVAL;
258 }
259 if (r->flags & IORESOURCE_IO)
260 cmd |= PCI_COMMAND_IO;
261 if (r->flags & IORESOURCE_MEM)
262 cmd |= PCI_COMMAND_MEMORY;
263 }
264 if (cmd != old_cmd) {
265 printk("PCI: Enabling device %s (%04x -> %04x)\n",
266 pci_name(dev), old_cmd, cmd);
267 pci_write_config_word(dev, PCI_COMMAND, cmd);
268 }
269 return 0;
270} 243}
271 244
272/* 245/*
@@ -295,7 +268,7 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
295 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 268 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
296} 269}
297 270
298char * __devinit pcibios_setup(char *str) 271char * __devinit __weak pcibios_setup(char *str)
299{ 272{
300 return str; 273 return str;
301} 274}
diff --git a/arch/sh/drivers/pci/pcie-sh7786.c b/arch/sh/drivers/pci/pcie-sh7786.c
index 68cb9b0ac9d2..96e9b058aa1d 100644
--- a/arch/sh/drivers/pci/pcie-sh7786.c
+++ b/arch/sh/drivers/pci/pcie-sh7786.c
@@ -13,11 +13,14 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/clk.h>
17#include <linux/sh_clk.h>
16#include "pcie-sh7786.h" 18#include "pcie-sh7786.h"
17#include <asm/sizes.h> 19#include <asm/sizes.h>
18 20
19struct sh7786_pcie_port { 21struct sh7786_pcie_port {
20 struct pci_channel *hose; 22 struct pci_channel *hose;
23 struct clk *fclk, phy_clk;
21 unsigned int index; 24 unsigned int index;
22 int endpoint; 25 int endpoint;
23 int link; 26 int link;
@@ -51,6 +54,7 @@ static struct resource sh7786_pci0_resources[] = {
51 .name = "PCIe0 MEM 2", 54 .name = "PCIe0 MEM 2",
52 .start = 0xfe100000, 55 .start = 0xfe100000,
53 .end = 0xfe100000 + SZ_1M - 1, 56 .end = 0xfe100000 + SZ_1M - 1,
57 .flags = IORESOURCE_MEM,
54 }, 58 },
55}; 59};
56 60
@@ -74,6 +78,7 @@ static struct resource sh7786_pci1_resources[] = {
74 .name = "PCIe1 MEM 2", 78 .name = "PCIe1 MEM 2",
75 .start = 0xfe300000, 79 .start = 0xfe300000,
76 .end = 0xfe300000 + SZ_1M - 1, 80 .end = 0xfe300000 + SZ_1M - 1,
81 .flags = IORESOURCE_MEM,
77 }, 82 },
78}; 83};
79 84
@@ -82,6 +87,7 @@ static struct resource sh7786_pci2_resources[] = {
82 .name = "PCIe2 IO", 87 .name = "PCIe2 IO",
83 .start = 0xfc800000, 88 .start = 0xfc800000,
84 .end = 0xfc800000 + SZ_4M - 1, 89 .end = 0xfc800000 + SZ_4M - 1,
90 .flags = IORESOURCE_IO,
85 }, { 91 }, {
86 .name = "PCIe2 MEM 0", 92 .name = "PCIe2 MEM 0",
87 .start = 0x80000000, 93 .start = 0x80000000,
@@ -96,6 +102,7 @@ static struct resource sh7786_pci2_resources[] = {
96 .name = "PCIe2 MEM 2", 102 .name = "PCIe2 MEM 2",
97 .start = 0xfcd00000, 103 .start = 0xfcd00000,
98 .end = 0xfcd00000 + SZ_1M - 1, 104 .end = 0xfcd00000 + SZ_1M - 1,
105 .flags = IORESOURCE_MEM,
99 }, 106 },
100}; 107};
101 108
@@ -117,7 +124,29 @@ static struct pci_channel sh7786_pci_channels[] = {
117 DEFINE_CONTROLLER(0xfcc00000, 2), 124 DEFINE_CONTROLLER(0xfcc00000, 2),
118}; 125};
119 126
120static int phy_wait_for_ack(struct pci_channel *chan) 127static struct clk fixed_pciexclkp = {
128 .rate = 100000000, /* 100 MHz reference clock */
129};
130
131static void __devinit sh7786_pci_fixup(struct pci_dev *dev)
132{
133 /*
134 * Prevent enumeration of root complex resources.
135 */
136 if (pci_is_root_bus(dev->bus) && dev->devfn == 0) {
137 int i;
138
139 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
140 dev->resource[i].start = 0;
141 dev->resource[i].end = 0;
142 dev->resource[i].flags = 0;
143 }
144 }
145}
146DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_RENESAS, PCI_DEVICE_ID_RENESAS_SH7786,
147 sh7786_pci_fixup);
148
149static int __init phy_wait_for_ack(struct pci_channel *chan)
121{ 150{
122 unsigned int timeout = 100; 151 unsigned int timeout = 100;
123 152
@@ -131,7 +160,7 @@ static int phy_wait_for_ack(struct pci_channel *chan)
131 return -ETIMEDOUT; 160 return -ETIMEDOUT;
132} 161}
133 162
134static int pci_wait_for_irq(struct pci_channel *chan, unsigned int mask) 163static int __init pci_wait_for_irq(struct pci_channel *chan, unsigned int mask)
135{ 164{
136 unsigned int timeout = 100; 165 unsigned int timeout = 100;
137 166
@@ -145,19 +174,14 @@ static int pci_wait_for_irq(struct pci_channel *chan, unsigned int mask)
145 return -ETIMEDOUT; 174 return -ETIMEDOUT;
146} 175}
147 176
148static void phy_write_reg(struct pci_channel *chan, unsigned int addr, 177static void __init phy_write_reg(struct pci_channel *chan, unsigned int addr,
149 unsigned int lane, unsigned int data) 178 unsigned int lane, unsigned int data)
150{ 179{
151 unsigned long phyaddr, ctrl; 180 unsigned long phyaddr;
152 181
153 phyaddr = (1 << BITS_CMD) + ((lane & 0xf) << BITS_LANE) + 182 phyaddr = (1 << BITS_CMD) + ((lane & 0xf) << BITS_LANE) +
154 ((addr & 0xff) << BITS_ADR); 183 ((addr & 0xff) << BITS_ADR);
155 184
156 /* Enable clock */
157 ctrl = pci_read_reg(chan, SH4A_PCIEPHYCTLR);
158 ctrl |= (1 << BITS_CKE);
159 pci_write_reg(chan, ctrl, SH4A_PCIEPHYCTLR);
160
161 /* Set write data */ 185 /* Set write data */
162 pci_write_reg(chan, data, SH4A_PCIEPHYDOUTR); 186 pci_write_reg(chan, data, SH4A_PCIEPHYDOUTR);
163 pci_write_reg(chan, phyaddr, SH4A_PCIEPHYADRR); 187 pci_write_reg(chan, phyaddr, SH4A_PCIEPHYADRR);
@@ -165,20 +189,74 @@ static void phy_write_reg(struct pci_channel *chan, unsigned int addr,
165 phy_wait_for_ack(chan); 189 phy_wait_for_ack(chan);
166 190
167 /* Clear command */ 191 /* Clear command */
192 pci_write_reg(chan, 0, SH4A_PCIEPHYDOUTR);
168 pci_write_reg(chan, 0, SH4A_PCIEPHYADRR); 193 pci_write_reg(chan, 0, SH4A_PCIEPHYADRR);
169 194
170 phy_wait_for_ack(chan); 195 phy_wait_for_ack(chan);
196}
171 197
172 /* Disable clock */ 198static int __init pcie_clk_init(struct sh7786_pcie_port *port)
173 ctrl = pci_read_reg(chan, SH4A_PCIEPHYCTLR); 199{
174 ctrl &= ~(1 << BITS_CKE); 200 struct pci_channel *chan = port->hose;
175 pci_write_reg(chan, ctrl, SH4A_PCIEPHYCTLR); 201 struct clk *clk;
202 char fclk_name[16];
203 int ret;
204
205 /*
206 * First register the fixed clock
207 */
208 ret = clk_register(&fixed_pciexclkp);
209 if (unlikely(ret != 0))
210 return ret;
211
212 /*
213 * Grab the port's function clock, which the PHY clock depends
214 * on. clock lookups don't help us much at this point, since no
215 * dev_id is available this early. Lame.
216 */
217 snprintf(fclk_name, sizeof(fclk_name), "pcie%d_fck", port->index);
218
219 port->fclk = clk_get(NULL, fclk_name);
220 if (IS_ERR(port->fclk)) {
221 ret = PTR_ERR(port->fclk);
222 goto err_fclk;
223 }
224
225 clk_enable(port->fclk);
226
227 /*
228 * And now, set up the PHY clock
229 */
230 clk = &port->phy_clk;
231
232 memset(clk, 0, sizeof(struct clk));
233
234 clk->parent = &fixed_pciexclkp;
235 clk->enable_reg = (void __iomem *)(chan->reg_base + SH4A_PCIEPHYCTLR);
236 clk->enable_bit = BITS_CKE;
237
238 ret = sh_clk_mstp32_register(clk, 1);
239 if (unlikely(ret < 0))
240 goto err_phy;
241
242 return 0;
243
244err_phy:
245 clk_disable(port->fclk);
246 clk_put(port->fclk);
247err_fclk:
248 clk_unregister(&fixed_pciexclkp);
249
250 return ret;
176} 251}
177 252
178static int phy_init(struct pci_channel *chan) 253static int __init phy_init(struct sh7786_pcie_port *port)
179{ 254{
255 struct pci_channel *chan = port->hose;
180 unsigned int timeout = 100; 256 unsigned int timeout = 100;
181 257
258 clk_enable(&port->phy_clk);
259
182 /* Initialize the phy */ 260 /* Initialize the phy */
183 phy_write_reg(chan, 0x60, 0xf, 0x004b008b); 261 phy_write_reg(chan, 0x60, 0xf, 0x004b008b);
184 phy_write_reg(chan, 0x61, 0xf, 0x00007b41); 262 phy_write_reg(chan, 0x61, 0xf, 0x00007b41);
@@ -187,9 +265,13 @@ static int phy_init(struct pci_channel *chan)
187 phy_write_reg(chan, 0x66, 0xf, 0x00000010); 265 phy_write_reg(chan, 0x66, 0xf, 0x00000010);
188 phy_write_reg(chan, 0x74, 0xf, 0x0007001c); 266 phy_write_reg(chan, 0x74, 0xf, 0x0007001c);
189 phy_write_reg(chan, 0x79, 0xf, 0x01fc000d); 267 phy_write_reg(chan, 0x79, 0xf, 0x01fc000d);
268 phy_write_reg(chan, 0xb0, 0xf, 0x00000610);
190 269
191 /* Deassert Standby */ 270 /* Deassert Standby */
192 phy_write_reg(chan, 0x67, 0xf, 0x00000400); 271 phy_write_reg(chan, 0x67, 0x1, 0x00000400);
272
273 /* Disable clock */
274 clk_disable(&port->phy_clk);
193 275
194 while (timeout--) { 276 while (timeout--) {
195 if (pci_read_reg(chan, SH4A_PCIEPHYSR)) 277 if (pci_read_reg(chan, SH4A_PCIEPHYSR))
@@ -201,22 +283,33 @@ static int phy_init(struct pci_channel *chan)
201 return -ETIMEDOUT; 283 return -ETIMEDOUT;
202} 284}
203 285
204static int pcie_init(struct sh7786_pcie_port *port) 286static void __init pcie_reset(struct sh7786_pcie_port *port)
287{
288 struct pci_channel *chan = port->hose;
289
290 pci_write_reg(chan, 1, SH4A_PCIESRSTR);
291 pci_write_reg(chan, 0, SH4A_PCIETCTLR);
292 pci_write_reg(chan, 0, SH4A_PCIESRSTR);
293 pci_write_reg(chan, 0, SH4A_PCIETXVC0SR);
294}
295
296static int __init pcie_init(struct sh7786_pcie_port *port)
205{ 297{
206 struct pci_channel *chan = port->hose; 298 struct pci_channel *chan = port->hose;
207 unsigned int data; 299 unsigned int data;
208 phys_addr_t memphys; 300 phys_addr_t memphys;
209 size_t memsize; 301 size_t memsize;
210 int ret, i; 302 int ret, i, win;
211 303
212 /* Begin initialization */ 304 /* Begin initialization */
213 pci_write_reg(chan, 0, SH4A_PCIETCTLR); 305 pcie_reset(port);
214 306
215 /* Initialize as type1. */ 307 /*
216 data = pci_read_reg(chan, SH4A_PCIEPCICONF3); 308 * Initial header for port config space is type 1, set the device
217 data &= ~(0x7f << 16); 309 * class to match. Hardware takes care of propagating the IDSETR
218 data |= PCI_HEADER_TYPE_BRIDGE << 16; 310 * settings, so there is no need to bother with a quirk.
219 pci_write_reg(chan, data, SH4A_PCIEPCICONF3); 311 */
312 pci_write_reg(chan, PCI_CLASS_BRIDGE_PCI << 16, SH4A_PCIEIDSETR1);
220 313
221 /* Initialize default capabilities. */ 314 /* Initialize default capabilities. */
222 data = pci_read_reg(chan, SH4A_PCIEEXPCAP0); 315 data = pci_read_reg(chan, SH4A_PCIEEXPCAP0);
@@ -268,30 +361,33 @@ static int pcie_init(struct sh7786_pcie_port *port)
268 * LAR1/LAMR1. 361 * LAR1/LAMR1.
269 */ 362 */
270 if (memsize > SZ_512M) { 363 if (memsize > SZ_512M) {
271 __raw_writel(memphys + SZ_512M, chan->reg_base + SH4A_PCIELAR1); 364 pci_write_reg(chan, memphys + SZ_512M, SH4A_PCIELAR1);
272 __raw_writel(((memsize - SZ_512M) - SZ_256) | 1, 365 pci_write_reg(chan, ((memsize - SZ_512M) - SZ_256) | 1,
273 chan->reg_base + SH4A_PCIELAMR1); 366 SH4A_PCIELAMR1);
274 memsize = SZ_512M; 367 memsize = SZ_512M;
275 } else { 368 } else {
276 /* 369 /*
277 * Otherwise just zero it out and disable it. 370 * Otherwise just zero it out and disable it.
278 */ 371 */
279 __raw_writel(0, chan->reg_base + SH4A_PCIELAR1); 372 pci_write_reg(chan, 0, SH4A_PCIELAR1);
280 __raw_writel(0, chan->reg_base + SH4A_PCIELAMR1); 373 pci_write_reg(chan, 0, SH4A_PCIELAMR1);
281 } 374 }
282 375
283 /* 376 /*
284 * LAR0/LAMR0 covers up to the first 512MB, which is enough to 377 * LAR0/LAMR0 covers up to the first 512MB, which is enough to
285 * cover all of lowmem on most platforms. 378 * cover all of lowmem on most platforms.
286 */ 379 */
287 __raw_writel(memphys, chan->reg_base + SH4A_PCIELAR0); 380 pci_write_reg(chan, memphys, SH4A_PCIELAR0);
288 __raw_writel((memsize - SZ_256) | 1, chan->reg_base + SH4A_PCIELAMR0); 381 pci_write_reg(chan, (memsize - SZ_256) | 1, SH4A_PCIELAMR0);
289 382
290 /* Finish initialization */ 383 /* Finish initialization */
291 data = pci_read_reg(chan, SH4A_PCIETCTLR); 384 data = pci_read_reg(chan, SH4A_PCIETCTLR);
292 data |= 0x1; 385 data |= 0x1;
293 pci_write_reg(chan, data, SH4A_PCIETCTLR); 386 pci_write_reg(chan, data, SH4A_PCIETCTLR);
294 387
388 /* Let things settle down a bit.. */
389 mdelay(100);
390
295 /* Enable DL_Active Interrupt generation */ 391 /* Enable DL_Active Interrupt generation */
296 data = pci_read_reg(chan, SH4A_PCIEDLINTENR); 392 data = pci_read_reg(chan, SH4A_PCIEDLINTENR);
297 data |= PCIEDLINTENR_DLL_ACT_ENABLE; 393 data |= PCIEDLINTENR_DLL_ACT_ENABLE;
@@ -302,9 +398,12 @@ static int pcie_init(struct sh7786_pcie_port *port)
302 data |= PCIEMACCTLR_SCR_DIS | (0xff << 16); 398 data |= PCIEMACCTLR_SCR_DIS | (0xff << 16);
303 pci_write_reg(chan, data, SH4A_PCIEMACCTLR); 399 pci_write_reg(chan, data, SH4A_PCIEMACCTLR);
304 400
401 /*
402 * This will timeout if we don't have a link, but we permit the
403 * port to register anyways in order to support hotplug on future
404 * hardware.
405 */
305 ret = pci_wait_for_irq(chan, MASK_INT_TX_CTRL); 406 ret = pci_wait_for_irq(chan, MASK_INT_TX_CTRL);
306 if (unlikely(ret != 0))
307 return -ENODEV;
308 407
309 data = pci_read_reg(chan, SH4A_PCIEPCICONF1); 408 data = pci_read_reg(chan, SH4A_PCIEPCICONF1);
310 data &= ~(PCI_STATUS_DEVSEL_MASK << 16); 409 data &= ~(PCI_STATUS_DEVSEL_MASK << 16);
@@ -317,35 +416,48 @@ static int pcie_init(struct sh7786_pcie_port *port)
317 416
318 wmb(); 417 wmb();
319 418
320 data = pci_read_reg(chan, SH4A_PCIEMACSR); 419 if (ret == 0) {
321 printk(KERN_NOTICE "PCI: PCIe#%d link width %d\n", 420 data = pci_read_reg(chan, SH4A_PCIEMACSR);
322 port->index, (data >> 20) & 0x3f); 421 printk(KERN_NOTICE "PCI: PCIe#%d x%d link detected\n",
323 422 port->index, (data >> 20) & 0x3f);
423 } else
424 printk(KERN_NOTICE "PCI: PCIe#%d link down\n",
425 port->index);
324 426
325 for (i = 0; i < chan->nr_resources; i++) { 427 for (i = win = 0; i < chan->nr_resources; i++) {
326 struct resource *res = chan->resources + i; 428 struct resource *res = chan->resources + i;
327 resource_size_t size; 429 resource_size_t size;
328 u32 enable_mask; 430 u32 mask;
329 431
330 pci_write_reg(chan, 0x00000000, SH4A_PCIEPTCTLR(i)); 432 /*
433 * We can't use the 32-bit mode windows in legacy 29-bit
434 * mode, so just skip them entirely.
435 */
436 if ((res->flags & IORESOURCE_MEM_32BIT) && __in_29bit_mode())
437 continue;
331 438
332 size = resource_size(res); 439 pci_write_reg(chan, 0x00000000, SH4A_PCIEPTCTLR(win));
333 440
334 /* 441 /*
335 * The PAMR mask is calculated in units of 256kB, which 442 * The PAMR mask is calculated in units of 256kB, which
336 * keeps things pretty simple. 443 * keeps things pretty simple.
337 */ 444 */
338 __raw_writel(((roundup_pow_of_two(size) / SZ_256K) - 1) << 18, 445 size = resource_size(res);
339 chan->reg_base + SH4A_PCIEPAMR(i)); 446 mask = (roundup_pow_of_two(size) / SZ_256K) - 1;
447 pci_write_reg(chan, mask << 18, SH4A_PCIEPAMR(win));
340 448
341 pci_write_reg(chan, 0x00000000, SH4A_PCIEPARH(i)); 449 pci_write_reg(chan, upper_32_bits(res->start),
342 pci_write_reg(chan, 0x00000000, SH4A_PCIEPARL(i)); 450 SH4A_PCIEPARH(win));
451 pci_write_reg(chan, lower_32_bits(res->start),
452 SH4A_PCIEPARL(win));
343 453
344 enable_mask = MASK_PARE; 454 mask = MASK_PARE;
345 if (res->flags & IORESOURCE_IO) 455 if (res->flags & IORESOURCE_IO)
346 enable_mask |= MASK_SPC; 456 mask |= MASK_SPC;
457
458 pci_write_reg(chan, mask, SH4A_PCIEPTCTLR(win));
347 459
348 pci_write_reg(chan, enable_mask, SH4A_PCIEPTCTLR(i)); 460 win++;
349 } 461 }
350 462
351 return 0; 463 return 0;
@@ -356,26 +468,33 @@ int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
356 return 71; 468 return 71;
357} 469}
358 470
359static int sh7786_pcie_core_init(void) 471static int __init sh7786_pcie_core_init(void)
360{ 472{
361 /* Return the number of ports */ 473 /* Return the number of ports */
362 return test_mode_pin(MODE_PIN12) ? 3 : 2; 474 return test_mode_pin(MODE_PIN12) ? 3 : 2;
363} 475}
364 476
365static int __devinit sh7786_pcie_init_hw(struct sh7786_pcie_port *port) 477static int __init sh7786_pcie_init_hw(struct sh7786_pcie_port *port)
366{ 478{
367 int ret; 479 int ret;
368 480
369 ret = phy_init(port->hose);
370 if (unlikely(ret < 0))
371 return ret;
372
373 /* 481 /*
374 * Check if we are configured in endpoint or root complex mode, 482 * Check if we are configured in endpoint or root complex mode,
375 * this is a fixed pin setting that applies to all PCIe ports. 483 * this is a fixed pin setting that applies to all PCIe ports.
376 */ 484 */
377 port->endpoint = test_mode_pin(MODE_PIN11); 485 port->endpoint = test_mode_pin(MODE_PIN11);
378 486
487 /*
488 * Setup clocks, needed both for PHY and PCIe registers.
489 */
490 ret = pcie_clk_init(port);
491 if (unlikely(ret < 0))
492 return ret;
493
494 ret = phy_init(port);
495 if (unlikely(ret < 0))
496 return ret;
497
379 ret = pcie_init(port); 498 ret = pcie_init(port);
380 if (unlikely(ret < 0)) 499 if (unlikely(ret < 0))
381 return ret; 500 return ret;
@@ -390,9 +509,10 @@ static struct sh7786_pcie_hwops sh7786_65nm_pcie_hwops __initdata = {
390 509
391static int __init sh7786_pcie_init(void) 510static int __init sh7786_pcie_init(void)
392{ 511{
512 struct clk *platclk;
393 int ret = 0, i; 513 int ret = 0, i;
394 514
395 printk(KERN_NOTICE "PCI: Starting intialization.\n"); 515 printk(KERN_NOTICE "PCI: Starting initialization.\n");
396 516
397 sh7786_pcie_hwops = &sh7786_65nm_pcie_hwops; 517 sh7786_pcie_hwops = &sh7786_65nm_pcie_hwops;
398 518
@@ -407,6 +527,22 @@ static int __init sh7786_pcie_init(void)
407 if (unlikely(!sh7786_pcie_ports)) 527 if (unlikely(!sh7786_pcie_ports))
408 return -ENOMEM; 528 return -ENOMEM;
409 529
530 /*
531 * Fetch any optional platform clock associated with this block.
532 *
533 * This is a rather nasty hack for boards with spec-mocking FPGAs
534 * that have a secondary set of clocks outside of the on-chip
535 * ones that need to be accounted for before there is any chance
536 * of touching the existing MSTP bits or CPG clocks.
537 */
538 platclk = clk_get(NULL, "pcie_plat_clk");
539 if (IS_ERR(platclk)) {
540 /* Sane hardware should probably get a WARN_ON.. */
541 platclk = NULL;
542 }
543
544 clk_enable(platclk);
545
410 printk(KERN_NOTICE "PCI: probing %d ports.\n", nr_ports); 546 printk(KERN_NOTICE "PCI: probing %d ports.\n", nr_ports);
411 547
412 for (i = 0; i < nr_ports; i++) { 548 for (i = 0; i < nr_ports; i++) {
@@ -419,8 +555,11 @@ static int __init sh7786_pcie_init(void)
419 ret |= sh7786_pcie_hwops->port_init_hw(port); 555 ret |= sh7786_pcie_hwops->port_init_hw(port);
420 } 556 }
421 557
422 if (unlikely(ret)) 558 if (unlikely(ret)) {
559 clk_disable(platclk);
560 clk_put(platclk);
423 return ret; 561 return ret;
562 }
424 563
425 return 0; 564 return 0;
426} 565}
diff --git a/arch/sh/drivers/pci/pcie-sh7786.h b/arch/sh/drivers/pci/pcie-sh7786.h
index 90a6992576b0..1ee054e47eae 100644
--- a/arch/sh/drivers/pci/pcie-sh7786.h
+++ b/arch/sh/drivers/pci/pcie-sh7786.h
@@ -55,8 +55,11 @@
55#define BITS_ERRRCV (0) /* 0 ERRRCV 0 */ 55#define BITS_ERRRCV (0) /* 0 ERRRCV 0 */
56#define MASK_ERRRCV (1<<BITS_ERRRCV) 56#define MASK_ERRRCV (1<<BITS_ERRRCV)
57 57
58/* PCIEENBLR */
59#define SH4A_PCIEENBLR (0x000008) /* R/W - 0x0000 0001 32 */
60
58/* PCIEECR */ 61/* PCIEECR */
59#define SH4A_PCIEECR (0x000008) /* R/W - 0x0000 0000 32 */ 62#define SH4A_PCIEECR (0x00000C) /* R/W - 0x0000 0000 32 */
60#define BITS_ENBL (0) /* 0 ENBL 0 R/W */ 63#define BITS_ENBL (0) /* 0 ENBL 0 R/W */
61#define MASK_ENBL (1<<BITS_ENBL) 64#define MASK_ENBL (1<<BITS_ENBL)
62 65
@@ -113,6 +116,27 @@
113#define BITS_MDATA (0) 116#define BITS_MDATA (0)
114#define MASK_MDATA (0xffffffff<<BITS_MDATA) 117#define MASK_MDATA (0xffffffff<<BITS_MDATA)
115 118
119/* PCIEUNLOCKCR */
120#define SH4A_PCIEUNLOCKCR (0x000048) /* R/W - 0x0000 0000 32 */
121
122/* PCIEIDR */
123#define SH4A_PCIEIDR (0x000060) /* R/W - 0x0101 1101 32 */
124
125/* PCIEDBGCTLR */
126#define SH4A_PCIEDBGCTLR (0x000100) /* R/W - 0x0000 0000 32 */
127
128/* PCIEINTXR */
129#define SH4A_PCIEINTXR (0x004000) /* R/W - 0x0000 0000 32 */
130
131/* PCIERMSGR */
132#define SH4A_PCIERMSGR (0x004010) /* R/W - 0x0000 0000 32 */
133
134/* PCIERSTR */
135#define SH4A_PCIERSTR(x) (0x008000 + ((x) * 0x4)) /* R/W - 0x0000 0000 32 */
136
137/* PCIESRSTR */
138#define SH4A_PCIESRSTR (0x008040) /* R/W - 0x0000 0000 32 */
139
116/* PCIEPHYCTLR */ 140/* PCIEPHYCTLR */
117#define SH4A_PCIEPHYCTLR (0x010000) /* R/W - 0x0000 0000 32 */ 141#define SH4A_PCIEPHYCTLR (0x010000) /* R/W - 0x0000 0000 32 */
118#define BITS_CKE (0) 142#define BITS_CKE (0)
@@ -121,6 +145,9 @@
121/* PCIERMSGIER */ 145/* PCIERMSGIER */
122#define SH4A_PCIERMSGIER (0x004040) /* R/W - 0x0000 0000 32 */ 146#define SH4A_PCIERMSGIER (0x004040) /* R/W - 0x0000 0000 32 */
123 147
148/* PCIEPHYCTLR */
149#define SH4A_PCIEPHYCTLR (0x010000) /* R/W - 0x0000 0000 32 */
150
124/* PCIEPHYADRR */ 151/* PCIEPHYADRR */
125#define SH4A_PCIEPHYADRR (0x010004) /* R/W - 0x0000 0000 32 */ 152#define SH4A_PCIEPHYADRR (0x010004) /* R/W - 0x0000 0000 32 */
126#define BITS_ACK (24) // Rev1.171 153#define BITS_ACK (24) // Rev1.171
@@ -152,7 +179,7 @@
152#define MASK_CFINT (1<<BITS_CFINT) 179#define MASK_CFINT (1<<BITS_CFINT)
153 180
154/* PCIETSTR */ 181/* PCIETSTR */
155#define SH4A_PCIETSTR (0x020004) /* R/W R/W 0x0000 0000 32 */ 182#define SH4A_PCIETSTR (0x020004) /* R 0x0000 0000 32 */
156 183
157/* PCIEINTR */ 184/* PCIEINTR */
158#define SH4A_PCIEINTR (0x020008) /* R/W R/W 0x0000 0000 32 */ 185#define SH4A_PCIEINTR (0x020008) /* R/W R/W 0x0000 0000 32 */
@@ -236,6 +263,9 @@
236#define BITS_INTPM (8) 263#define BITS_INTPM (8)
237#define MASK_INTPM (1<<BITS_INTPM) 264#define MASK_INTPM (1<<BITS_INTPM)
238 265
266/* PCIEEH0R */
267#define SH4A_PCIEEHR(x) (0x020010 + ((x) * 0x4)) /* R - 0x0000 0000 32 */
268
239/* PCIEAIR */ 269/* PCIEAIR */
240#define SH4A_PCIEAIR (SH4A_PCIE_BASE + 0x020010) /* R/W R/W 0xxxxx xxxx 32 */ 270#define SH4A_PCIEAIR (SH4A_PCIE_BASE + 0x020010) /* R/W R/W 0xxxxx xxxx 32 */
241 271
@@ -244,6 +274,25 @@
244 274
245/* PCIEERRFR */ // Rev1.18 275/* PCIEERRFR */ // Rev1.18
246#define SH4A_PCIEERRFR (0x020020) /* R/W R/W 0xxxxx xxxx 32 */ // Rev1.18 276#define SH4A_PCIEERRFR (0x020020) /* R/W R/W 0xxxxx xxxx 32 */ // Rev1.18
277
278/* PCIEERRFER */
279#define SH4A_PCIEERRFER (0x020024) /* R/W R/W 0x0000 0000 32 */
280
281/* PCIEERRFR2 */
282#define SH4A_PCIEERRFR2 (0x020028) /* R/W R/W 0x0000 0000 32 */
283
284/* PCIEMSIR */
285#define SH4A_PCIEMSIR (0x020040) /* R/W - 0x0000 0000 32 */
286
287/* PCIEMSIFR */
288#define SH4A_PCIEMSIFR (0x020044) /* R/W R/W 0x0000 0000 32 */
289
290/* PCIEPWRCTLR */
291#define SH4A_PCIEPWRCTLR (0x020100) /* R/W - 0x0000 0000 32 */
292
293/* PCIEPCCTLR */
294#define SH4A_PCIEPCCTLR (0x020180) /* R/W - 0x0000 0000 32 */
295
247 // Rev1.18 296 // Rev1.18
248/* PCIELAR0 */ 297/* PCIELAR0 */
249#define SH4A_PCIELAR0 (0x020200) /* R/W R/W 0x0000 0000 32 */ 298#define SH4A_PCIELAR0 (0x020200) /* R/W R/W 0x0000 0000 32 */
@@ -352,6 +401,7 @@
352#define SH4A_PCIEDMCCR0 (0x021120) /* R/W R/W 0x0000 0000 32 */ 401#define SH4A_PCIEDMCCR0 (0x021120) /* R/W R/W 0x0000 0000 32 */
353#define SH4A_PCIEDMCC2R0 (0x021124) /* R/W R/W 0x0000 0000 - */ 402#define SH4A_PCIEDMCC2R0 (0x021124) /* R/W R/W 0x0000 0000 - */
354#define SH4A_PCIEDMCCCR0 (0x021128) /* R/W R/W 0x0000 0000 32 */ 403#define SH4A_PCIEDMCCCR0 (0x021128) /* R/W R/W 0x0000 0000 32 */
404#define SH4A_PCIEDMCHSR0 (0x02112C) /* R/W - 0x0000 0000 32 */
355#define SH4A_PCIEDMSAR1 (0x021140) /* R/W R/W 0x0000 0000 32 */ 405#define SH4A_PCIEDMSAR1 (0x021140) /* R/W R/W 0x0000 0000 32 */
356#define SH4A_PCIEDMSAHR1 (0x021144) /* R/W R/W 0x0000 0000 32 */ 406#define SH4A_PCIEDMSAHR1 (0x021144) /* R/W R/W 0x0000 0000 32 */
357#define SH4A_PCIEDMDAR1 (0x021148) /* R/W R/W 0x0000 0000 32 */ 407#define SH4A_PCIEDMDAR1 (0x021148) /* R/W R/W 0x0000 0000 32 */
@@ -363,6 +413,7 @@
363#define SH4A_PCIEDMCCR1 (0x021160) /* R/W R/W 0x0000 0000 32 */ 413#define SH4A_PCIEDMCCR1 (0x021160) /* R/W R/W 0x0000 0000 32 */
364#define SH4A_PCIEDMCC2R1 (0x021164) /* R/W R/W 0x0000 0000 - */ 414#define SH4A_PCIEDMCC2R1 (0x021164) /* R/W R/W 0x0000 0000 - */
365#define SH4A_PCIEDMCCCR1 (0x021168) /* R/W R/W 0x0000 0000 32 */ 415#define SH4A_PCIEDMCCCR1 (0x021168) /* R/W R/W 0x0000 0000 32 */
416#define SH4A_PCIEDMCHSR1 (0x02116C) /* R/W - 0x0000 0000 32 */
366#define SH4A_PCIEDMSAR2 (0x021180) /* R/W R/W 0x0000 0000 32 */ 417#define SH4A_PCIEDMSAR2 (0x021180) /* R/W R/W 0x0000 0000 32 */
367#define SH4A_PCIEDMSAHR2 (0x021184) /* R/W R/W 0x0000 0000 32 */ 418#define SH4A_PCIEDMSAHR2 (0x021184) /* R/W R/W 0x0000 0000 32 */
368#define SH4A_PCIEDMDAR2 (0x021188) /* R/W R/W 0x0000 0000 32 */ 419#define SH4A_PCIEDMDAR2 (0x021188) /* R/W R/W 0x0000 0000 32 */
@@ -385,6 +436,7 @@
385#define SH4A_PCIEDMCCR3 (0x0211E0) /* R/W R/W 0x0000 0000 32 */ 436#define SH4A_PCIEDMCCR3 (0x0211E0) /* R/W R/W 0x0000 0000 32 */
386#define SH4A_PCIEDMCC2R3 (0x0211E4) /* R/W R/W 0x0000 0000 - */ 437#define SH4A_PCIEDMCC2R3 (0x0211E4) /* R/W R/W 0x0000 0000 - */
387#define SH4A_PCIEDMCCCR3 (0x0211E8) /* R/W R/W 0x0000 0000 32 */ 438#define SH4A_PCIEDMCCCR3 (0x0211E8) /* R/W R/W 0x0000 0000 32 */
439#define SH4A_PCIEDMCHSR3 (0x0211EC) /* R/W R/W 0x0000 0000 32 */
388#define SH4A_PCIEPCICONF0 (0x040000) /* R R - 8/16/32 */ 440#define SH4A_PCIEPCICONF0 (0x040000) /* R R - 8/16/32 */
389#define SH4A_PCIEPCICONF1 (0x040004) /* R/W R/W 0x0008 0000 8/16/32 */ 441#define SH4A_PCIEPCICONF1 (0x040004) /* R/W R/W 0x0008 0000 8/16/32 */
390#define SH4A_PCIEPCICONF2 (0x040008) /* R/W R/W 0xFF00 0000 8/16/32 */ 442#define SH4A_PCIEPCICONF2 (0x040008) /* R/W R/W 0xFF00 0000 8/16/32 */
diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild
index 0eed47b236ab..7beb42322f60 100644
--- a/arch/sh/include/asm/Kbuild
+++ b/arch/sh/include/asm/Kbuild
@@ -5,5 +5,7 @@ header-y += cpu-features.h
5header-y += hw_breakpoint.h 5header-y += hw_breakpoint.h
6header-y += posix_types_32.h 6header-y += posix_types_32.h
7header-y += posix_types_64.h 7header-y += posix_types_64.h
8header-y += ptrace_32.h
9header-y += ptrace_64.h
8header-y += unistd_32.h 10header-y += unistd_32.h
9header-y += unistd_64.h 11header-y += unistd_64.h
diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
index ce830faeebbf..f38112be67d2 100644
--- a/arch/sh/include/asm/elf.h
+++ b/arch/sh/include/asm/elf.h
@@ -50,25 +50,14 @@
50#define R_SH_GOTPC 167 50#define R_SH_GOTPC 167
51 51
52/* FDPIC relocs */ 52/* FDPIC relocs */
53#define R_SH_GOT20 70 53#define R_SH_GOT20 201
54#define R_SH_GOTOFF20 71 54#define R_SH_GOTOFF20 202
55#define R_SH_GOTFUNCDESC 72 55#define R_SH_GOTFUNCDESC 203
56#define R_SH_GOTFUNCDESC20 73 56#define R_SH_GOTFUNCDESC20 204
57#define R_SH_GOTOFFFUNCDESC 74 57#define R_SH_GOTOFFFUNCDESC 205
58#define R_SH_GOTOFFFUNCDESC20 75 58#define R_SH_GOTOFFFUNCDESC20 206
59#define R_SH_FUNCDESC 76 59#define R_SH_FUNCDESC 207
60#define R_SH_FUNCDESC_VALUE 77 60#define R_SH_FUNCDESC_VALUE 208
61
62#if 0 /* XXX - later .. */
63#define R_SH_GOT20 198
64#define R_SH_GOTOFF20 199
65#define R_SH_GOTFUNCDESC 200
66#define R_SH_GOTFUNCDESC20 201
67#define R_SH_GOTOFFFUNCDESC 202
68#define R_SH_GOTOFFFUNCDESC20 203
69#define R_SH_FUNCDESC 204
70#define R_SH_FUNCDESC_VALUE 205
71#endif
72 61
73/* SHmedia relocs */ 62/* SHmedia relocs */
74#define R_SH_IMM_LOW16 246 63#define R_SH_IMM_LOW16 246
diff --git a/arch/sh/include/asm/fixmap.h b/arch/sh/include/asm/fixmap.h
index 6e7cea453895..bd7e79a12653 100644
--- a/arch/sh/include/asm/fixmap.h
+++ b/arch/sh/include/asm/fixmap.h
@@ -58,7 +58,7 @@ enum fixed_addresses {
58 58
59#ifdef CONFIG_HIGHMEM 59#ifdef CONFIG_HIGHMEM
60 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 60 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
61 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 61 FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
62#endif 62#endif
63 63
64#ifdef CONFIG_IOREMAP_FIXED 64#ifdef CONFIG_IOREMAP_FIXED
@@ -69,7 +69,7 @@ enum fixed_addresses {
69 */ 69 */
70#define FIX_N_IOREMAPS 32 70#define FIX_N_IOREMAPS 32
71 FIX_IOREMAP_BEGIN, 71 FIX_IOREMAP_BEGIN,
72 FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS, 72 FIX_IOREMAP_END = FIX_IOREMAP_BEGIN + FIX_N_IOREMAPS - 1,
73#endif 73#endif
74 74
75 __end_of_fixed_addresses 75 __end_of_fixed_addresses
diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h
index f8d9a731e903..04f53d31489f 100644
--- a/arch/sh/include/asm/gpio.h
+++ b/arch/sh/include/asm/gpio.h
@@ -41,14 +41,12 @@ static inline int gpio_cansleep(unsigned gpio)
41 41
42static inline int gpio_to_irq(unsigned gpio) 42static inline int gpio_to_irq(unsigned gpio)
43{ 43{
44 WARN_ON(1); 44 return __gpio_to_irq(gpio);
45 return -ENOSYS;
46} 45}
47 46
48static inline int irq_to_gpio(unsigned int irq) 47static inline int irq_to_gpio(unsigned int irq)
49{ 48{
50 WARN_ON(1); 49 return -ENOSYS;
51 return -EINVAL;
52} 50}
53 51
54#endif /* CONFIG_GPIOLIB */ 52#endif /* CONFIG_GPIOLIB */
diff --git a/arch/sh/include/asm/irq.h b/arch/sh/include/asm/irq.h
index 02c2f0102cfa..45d08b6a5ef7 100644
--- a/arch/sh/include/asm/irq.h
+++ b/arch/sh/include/asm/irq.h
@@ -9,7 +9,7 @@
9 * advised to cap this at the hard limit that they're interested in 9 * advised to cap this at the hard limit that they're interested in
10 * through the machvec. 10 * through the machvec.
11 */ 11 */
12#define NR_IRQS 256 12#define NR_IRQS 512
13#define NR_IRQS_LEGACY 8 /* Legacy external IRQ0-7 */ 13#define NR_IRQS_LEGACY 8 /* Legacy external IRQ0-7 */
14 14
15/* 15/*
diff --git a/arch/sh/include/asm/irqflags.h b/arch/sh/include/asm/irqflags.h
index a741153b41c2..43b7608606c3 100644
--- a/arch/sh/include/asm/irqflags.h
+++ b/arch/sh/include/asm/irqflags.h
@@ -1,8 +1,8 @@
1#ifndef __ASM_SH_IRQFLAGS_H 1#ifndef __ASM_SH_IRQFLAGS_H
2#define __ASM_SH_IRQFLAGS_H 2#define __ASM_SH_IRQFLAGS_H
3 3
4#define RAW_IRQ_DISABLED 0xf0 4#define ARCH_IRQ_DISABLED 0xf0
5#define RAW_IRQ_ENABLED 0x00 5#define ARCH_IRQ_ENABLED 0x00
6 6
7#include <asm-generic/irqflags.h> 7#include <asm-generic/irqflags.h>
8 8
diff --git a/arch/sh/include/asm/kprobes.h b/arch/sh/include/asm/kprobes.h
index 036c3311233c..134f3980e44a 100644
--- a/arch/sh/include/asm/kprobes.h
+++ b/arch/sh/include/asm/kprobes.h
@@ -16,7 +16,6 @@ typedef insn_size_t kprobe_opcode_t;
16 ? (MAX_STACK_SIZE) \ 16 ? (MAX_STACK_SIZE) \
17 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) 17 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
18 18
19#define regs_return_value(_regs) ((_regs)->regs[0])
20#define flush_insn_slot(p) do { } while (0) 19#define flush_insn_slot(p) do { } while (0)
21#define kretprobe_blacklist_size 0 20#define kretprobe_blacklist_size 0
22 21
diff --git a/arch/sh/include/asm/memblock.h b/arch/sh/include/asm/memblock.h
index dfe683b88075..e87063fad2ea 100644
--- a/arch/sh/include/asm/memblock.h
+++ b/arch/sh/include/asm/memblock.h
@@ -1,6 +1,4 @@
1#ifndef __ASM_SH_MEMBLOCK_H 1#ifndef __ASM_SH_MEMBLOCK_H
2#define __ASM_SH_MEMBLOCK_H 2#define __ASM_SH_MEMBLOCK_H
3 3
4#define MEMBLOCK_REAL_LIMIT 0
5
6#endif /* __ASM_SH_MEMBLOCK_H */ 4#endif /* __ASM_SH_MEMBLOCK_H */
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 8bd952fcf3ba..f0efe97f1750 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -37,6 +37,8 @@ struct pci_channel {
37}; 37};
38 38
39/* arch/sh/drivers/pci/pci.c */ 39/* arch/sh/drivers/pci/pci.c */
40extern raw_spinlock_t pci_config_lock;
41
40extern int register_pci_controller(struct pci_channel *hose); 42extern int register_pci_controller(struct pci_channel *hose);
41extern void pcibios_report_status(unsigned int status_mask, int warn); 43extern void pcibios_report_status(unsigned int status_mask, int warn);
42 44
diff --git a/arch/sh/include/asm/perf_event.h b/arch/sh/include/asm/perf_event.h
index 3d0c9f36d150..14308bed7ea5 100644
--- a/arch/sh/include/asm/perf_event.h
+++ b/arch/sh/include/asm/perf_event.h
@@ -26,11 +26,4 @@ extern int register_sh_pmu(struct sh_pmu *);
26extern int reserve_pmc_hardware(void); 26extern int reserve_pmc_hardware(void);
27extern void release_pmc_hardware(void); 27extern void release_pmc_hardware(void);
28 28
29static inline void set_perf_event_pending(void)
30{
31 /* Nothing to see here, move along. */
32}
33
34#define PERF_EVENT_INDEX_OFFSET 0
35
36#endif /* __ASM_SH_PERF_EVENT_H */ 29#endif /* __ASM_SH_PERF_EVENT_H */
diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h
index 61a445d2d02a..46d5179c9f49 100644
--- a/arch/sh/include/asm/processor_32.h
+++ b/arch/sh/include/asm/processor_32.h
@@ -13,7 +13,6 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/page.h> 14#include <asm/page.h>
15#include <asm/types.h> 15#include <asm/types.h>
16#include <asm/ptrace.h>
17#include <asm/hw_breakpoint.h> 16#include <asm/hw_breakpoint.h>
18 17
19/* 18/*
@@ -194,8 +193,6 @@ extern unsigned long get_wchan(struct task_struct *p);
194#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc) 193#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
195#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15]) 194#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
196 195
197#define user_stack_pointer(_regs) ((_regs)->regs[15])
198
199#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH4) 196#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH4)
200#define PREFETCH_STRIDE L1_CACHE_BYTES 197#define PREFETCH_STRIDE L1_CACHE_BYTES
201#define ARCH_HAS_PREFETCH 198#define ARCH_HAS_PREFETCH
diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h
index 621bc4618c6b..2a541ddb5a1b 100644
--- a/arch/sh/include/asm/processor_64.h
+++ b/arch/sh/include/asm/processor_64.h
@@ -17,7 +17,6 @@
17#include <linux/compiler.h> 17#include <linux/compiler.h>
18#include <asm/page.h> 18#include <asm/page.h>
19#include <asm/types.h> 19#include <asm/types.h>
20#include <asm/ptrace.h>
21#include <cpu/registers.h> 20#include <cpu/registers.h>
22 21
23/* 22/*
@@ -231,7 +230,5 @@ extern unsigned long get_wchan(struct task_struct *p);
231#define KSTK_EIP(tsk) ((tsk)->thread.pc) 230#define KSTK_EIP(tsk) ((tsk)->thread.pc)
232#define KSTK_ESP(tsk) ((tsk)->thread.sp) 231#define KSTK_ESP(tsk) ((tsk)->thread.sp)
233 232
234#define user_stack_pointer(_regs) ((_regs)->regs[15])
235
236#endif /* __ASSEMBLY__ */ 233#endif /* __ASSEMBLY__ */
237#endif /* __ASM_SH_PROCESSOR_64_H */ 234#endif /* __ASM_SH_PROCESSOR_64_H */
diff --git a/arch/sh/include/asm/ptrace.h b/arch/sh/include/asm/ptrace.h
index 2168fde25611..f6edc10aa0d3 100644
--- a/arch/sh/include/asm/ptrace.h
+++ b/arch/sh/include/asm/ptrace.h
@@ -3,90 +3,7 @@
3 3
4/* 4/*
5 * Copyright (C) 1999, 2000 Niibe Yutaka 5 * Copyright (C) 1999, 2000 Niibe Yutaka
6 *
7 */
8#if defined(__SH5__)
9struct pt_regs {
10 unsigned long long pc;
11 unsigned long long sr;
12 long long syscall_nr;
13 unsigned long long regs[63];
14 unsigned long long tregs[8];
15 unsigned long long pad[2];
16};
17#else
18/*
19 * GCC defines register number like this:
20 * -----------------------------
21 * 0 - 15 are integer registers
22 * 17 - 22 are control/special registers
23 * 24 - 39 fp registers
24 * 40 - 47 xd registers
25 * 48 - fpscr register
26 * -----------------------------
27 *
28 * We follows above, except:
29 * 16 --- program counter (PC)
30 * 22 --- syscall #
31 * 23 --- floating point communication register
32 */ 6 */
33#define REG_REG0 0
34#define REG_REG15 15
35
36#define REG_PC 16
37
38#define REG_PR 17
39#define REG_SR 18
40#define REG_GBR 19
41#define REG_MACH 20
42#define REG_MACL 21
43
44#define REG_SYSCALL 22
45
46#define REG_FPREG0 23
47#define REG_FPREG15 38
48#define REG_XFREG0 39
49#define REG_XFREG15 54
50
51#define REG_FPSCR 55
52#define REG_FPUL 56
53
54/*
55 * This struct defines the way the registers are stored on the
56 * kernel stack during a system call or other kernel entry.
57 */
58struct pt_regs {
59 unsigned long regs[16];
60 unsigned long pc;
61 unsigned long pr;
62 unsigned long sr;
63 unsigned long gbr;
64 unsigned long mach;
65 unsigned long macl;
66 long tra;
67};
68
69/*
70 * This struct defines the way the DSP registers are stored on the
71 * kernel stack during a system call or other kernel entry.
72 */
73struct pt_dspregs {
74 unsigned long a1;
75 unsigned long a0g;
76 unsigned long a1g;
77 unsigned long m0;
78 unsigned long m1;
79 unsigned long a0;
80 unsigned long x0;
81 unsigned long x1;
82 unsigned long y0;
83 unsigned long y1;
84 unsigned long dsr;
85 unsigned long rs;
86 unsigned long re;
87 unsigned long mod;
88};
89#endif
90 7
91#define PTRACE_GETREGS 12 /* General registers */ 8#define PTRACE_GETREGS 12 /* General registers */
92#define PTRACE_SETREGS 13 9#define PTRACE_SETREGS 13
@@ -107,22 +24,102 @@ struct pt_dspregs {
107#define PT_DATA_ADDR 248 /* &(struct user)->start_data */ 24#define PT_DATA_ADDR 248 /* &(struct user)->start_data */
108#define PT_TEXT_LEN 252 25#define PT_TEXT_LEN 252
109 26
27#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
28#include "ptrace_64.h"
29#else
30#include "ptrace_32.h"
31#endif
32
110#ifdef __KERNEL__ 33#ifdef __KERNEL__
34
35#include <linux/stringify.h>
36#include <linux/stddef.h>
37#include <linux/thread_info.h>
111#include <asm/addrspace.h> 38#include <asm/addrspace.h>
112#include <asm/page.h> 39#include <asm/page.h>
113#include <asm/system.h> 40#include <asm/system.h>
114 41
115#define user_mode(regs) (((regs)->sr & 0x40000000)==0) 42#define user_mode(regs) (((regs)->sr & 0x40000000)==0)
43#define user_stack_pointer(regs) ((unsigned long)(regs)->regs[15])
44#define kernel_stack_pointer(regs) ((unsigned long)(regs)->regs[15])
116#define instruction_pointer(regs) ((unsigned long)(regs)->pc) 45#define instruction_pointer(regs) ((unsigned long)(regs)->pc)
117 46
118extern void show_regs(struct pt_regs *); 47extern void show_regs(struct pt_regs *);
119 48
49#define arch_has_single_step() (1)
50
120/* 51/*
121 * These are defined as per linux/ptrace.h. 52 * kprobe-based event tracer support
122 */ 53 */
123struct task_struct; 54struct pt_regs_offset {
55 const char *name;
56 int offset;
57};
124 58
125#define arch_has_single_step() (1) 59#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
60#define REGS_OFFSET_NAME(num) \
61 {.name = __stringify(r##num), .offset = offsetof(struct pt_regs, regs[num])}
62#define TREGS_OFFSET_NAME(num) \
63 {.name = __stringify(tr##num), .offset = offsetof(struct pt_regs, tregs[num])}
64#define REG_OFFSET_END {.name = NULL, .offset = 0}
65
66/* Query offset/name of register from its name/offset */
67extern int regs_query_register_offset(const char *name);
68extern const char *regs_query_register_name(unsigned int offset);
69
70extern const struct pt_regs_offset regoffset_table[];
71
72/**
73 * regs_get_register() - get register value from its offset
74 * @regs: pt_regs from which register value is gotten.
75 * @offset: offset number of the register.
76 *
77 * regs_get_register returns the value of a register. The @offset is the
78 * offset of the register in struct pt_regs address which specified by @regs.
79 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
80 */
81static inline unsigned long regs_get_register(struct pt_regs *regs,
82 unsigned int offset)
83{
84 if (unlikely(offset > MAX_REG_OFFSET))
85 return 0;
86 return *(unsigned long *)((unsigned long)regs + offset);
87}
88
89/**
90 * regs_within_kernel_stack() - check the address in the stack
91 * @regs: pt_regs which contains kernel stack pointer.
92 * @addr: address which is checked.
93 *
94 * regs_within_kernel_stack() checks @addr is within the kernel stack page(s).
95 * If @addr is within the kernel stack, it returns true. If not, returns false.
96 */
97static inline int regs_within_kernel_stack(struct pt_regs *regs,
98 unsigned long addr)
99{
100 return ((addr & ~(THREAD_SIZE - 1)) ==
101 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
102}
103
104/**
105 * regs_get_kernel_stack_nth() - get Nth entry of the stack
106 * @regs: pt_regs which contains kernel stack pointer.
107 * @n: stack entry number.
108 *
109 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
110 * is specified by @regs. If the @n th entry is NOT in the kernel stack,
111 * this returns 0.
112 */
113static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
114 unsigned int n)
115{
116 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
117 addr += n;
118 if (regs_within_kernel_stack(regs, (unsigned long)addr))
119 return *addr;
120 else
121 return 0;
122}
126 123
127struct perf_event; 124struct perf_event;
128struct perf_sample_data; 125struct perf_sample_data;
diff --git a/arch/sh/include/asm/ptrace_32.h b/arch/sh/include/asm/ptrace_32.h
new file mode 100644
index 000000000000..35d9e257558c
--- /dev/null
+++ b/arch/sh/include/asm/ptrace_32.h
@@ -0,0 +1,83 @@
1#ifndef __ASM_SH_PTRACE_32_H
2#define __ASM_SH_PTRACE_32_H
3
4/*
5 * GCC defines register number like this:
6 * -----------------------------
7 * 0 - 15 are integer registers
8 * 17 - 22 are control/special registers
9 * 24 - 39 fp registers
10 * 40 - 47 xd registers
11 * 48 - fpscr register
12 * -----------------------------
13 *
14 * We follows above, except:
15 * 16 --- program counter (PC)
16 * 22 --- syscall #
17 * 23 --- floating point communication register
18 */
19#define REG_REG0 0
20#define REG_REG15 15
21
22#define REG_PC 16
23
24#define REG_PR 17
25#define REG_SR 18
26#define REG_GBR 19
27#define REG_MACH 20
28#define REG_MACL 21
29
30#define REG_SYSCALL 22
31
32#define REG_FPREG0 23
33#define REG_FPREG15 38
34#define REG_XFREG0 39
35#define REG_XFREG15 54
36
37#define REG_FPSCR 55
38#define REG_FPUL 56
39
40/*
41 * This struct defines the way the registers are stored on the
42 * kernel stack during a system call or other kernel entry.
43 */
44struct pt_regs {
45 unsigned long regs[16];
46 unsigned long pc;
47 unsigned long pr;
48 unsigned long sr;
49 unsigned long gbr;
50 unsigned long mach;
51 unsigned long macl;
52 long tra;
53};
54
55/*
56 * This struct defines the way the DSP registers are stored on the
57 * kernel stack during a system call or other kernel entry.
58 */
59struct pt_dspregs {
60 unsigned long a1;
61 unsigned long a0g;
62 unsigned long a1g;
63 unsigned long m0;
64 unsigned long m1;
65 unsigned long a0;
66 unsigned long x0;
67 unsigned long x1;
68 unsigned long y0;
69 unsigned long y1;
70 unsigned long dsr;
71 unsigned long rs;
72 unsigned long re;
73 unsigned long mod;
74};
75
76#ifdef __KERNEL__
77
78#define MAX_REG_OFFSET offsetof(struct pt_regs, tra)
79#define regs_return_value(regs) ((regs)->regs[0])
80
81#endif /* __KERNEL__ */
82
83#endif /* __ASM_SH_PTRACE_32_H */
diff --git a/arch/sh/include/asm/ptrace_64.h b/arch/sh/include/asm/ptrace_64.h
new file mode 100644
index 000000000000..d43c1cb0bbe7
--- /dev/null
+++ b/arch/sh/include/asm/ptrace_64.h
@@ -0,0 +1,20 @@
1#ifndef __ASM_SH_PTRACE_64_H
2#define __ASM_SH_PTRACE_64_H
3
4struct pt_regs {
5 unsigned long long pc;
6 unsigned long long sr;
7 long long syscall_nr;
8 unsigned long long regs[63];
9 unsigned long long tregs[8];
10 unsigned long long pad[2];
11};
12
13#ifdef __KERNEL__
14
15#define MAX_REG_OFFSET offsetof(struct pt_regs, tregs[7])
16#define regs_return_value(regs) ((regs)->regs[3])
17
18#endif /* __KERNEL__ */
19
20#endif /* __ASM_SH_PTRACE_64_H */
diff --git a/arch/sh/include/asm/sizes.h b/arch/sh/include/asm/sizes.h
index 3a1fb97770f1..0b9fe2d5c36d 100644
--- a/arch/sh/include/asm/sizes.h
+++ b/arch/sh/include/asm/sizes.h
@@ -32,6 +32,7 @@
32#define SZ_512 0x00000200 32#define SZ_512 0x00000200
33 33
34#define SZ_1K 0x00000400 34#define SZ_1K 0x00000400
35#define SZ_2K 0x00000800
35#define SZ_4K 0x00001000 36#define SZ_4K 0x00001000
36#define SZ_8K 0x00002000 37#define SZ_8K 0x00002000
37#define SZ_16K 0x00004000 38#define SZ_16K 0x00004000
diff --git a/arch/sh/include/asm/sram.h b/arch/sh/include/asm/sram.h
new file mode 100644
index 000000000000..a2808ce4c0aa
--- /dev/null
+++ b/arch/sh/include/asm/sram.h
@@ -0,0 +1,38 @@
1#ifndef __ASM_SRAM_H
2#define __ASM_SRAM_H
3
4#ifdef CONFIG_HAVE_SRAM_POOL
5
6#include <linux/spinlock.h>
7#include <linux/genalloc.h>
8
9/* arch/sh/mm/sram.c */
10extern struct gen_pool *sram_pool;
11
12static inline unsigned long sram_alloc(size_t len)
13{
14 if (!sram_pool)
15 return 0UL;
16
17 return gen_pool_alloc(sram_pool, len);
18}
19
20static inline void sram_free(unsigned long addr, size_t len)
21{
22 return gen_pool_free(sram_pool, addr, len);
23}
24
25#else
26
27static inline unsigned long sram_alloc(size_t len)
28{
29 return 0;
30}
31
32static inline void sram_free(unsigned long addr, size_t len)
33{
34}
35
36#endif /* CONFIG_HAVE_SRAM_POOL */
37
38#endif /* __ASM_SRAM_H */
diff --git a/arch/sh/include/asm/syscalls_32.h b/arch/sh/include/asm/syscalls_32.h
index be201fdc97aa..ae717e3c26d6 100644
--- a/arch/sh/include/asm/syscalls_32.h
+++ b/arch/sh/include/asm/syscalls_32.h
@@ -19,9 +19,10 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
19asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, 19asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
20 unsigned long r6, unsigned long r7, 20 unsigned long r6, unsigned long r7,
21 struct pt_regs __regs); 21 struct pt_regs __regs);
22asmlinkage int sys_execve(const char __user *ufilename, char __user * __user *uargv, 22asmlinkage int sys_execve(const char __user *ufilename,
23 char __user * __user *uenvp, unsigned long r7, 23 const char __user *const __user *uargv,
24 struct pt_regs __regs); 24 const char __user *const __user *uenvp,
25 unsigned long r7, struct pt_regs __regs);
25asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5, 26asmlinkage int sys_sigsuspend(old_sigset_t mask, unsigned long r5,
26 unsigned long r6, unsigned long r7, 27 unsigned long r6, unsigned long r7,
27 struct pt_regs __regs); 28 struct pt_regs __regs);
diff --git a/arch/sh/include/asm/system.h b/arch/sh/include/asm/system.h
index 0bd7a17d5e1a..1f1af5afff03 100644
--- a/arch/sh/include/asm/system.h
+++ b/arch/sh/include/asm/system.h
@@ -140,8 +140,6 @@ extern unsigned int instruction_size(unsigned int insn);
140extern unsigned long cached_to_uncached; 140extern unsigned long cached_to_uncached;
141extern unsigned long uncached_size; 141extern unsigned long uncached_size;
142 142
143extern struct dentry *sh_debugfs_root;
144
145void per_cpu_trap_init(void); 143void per_cpu_trap_init(void);
146void default_idle(void); 144void default_idle(void);
147void cpu_idle_wait(void); 145void cpu_idle_wait(void);
diff --git a/arch/sh/include/asm/system_32.h b/arch/sh/include/asm/system_32.h
index 51296b36770e..c941b2739405 100644
--- a/arch/sh/include/asm/system_32.h
+++ b/arch/sh/include/asm/system_32.h
@@ -212,17 +212,16 @@ static inline reg_size_t register_align(void *val)
212} 212}
213 213
214int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, 214int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
215 struct mem_access *ma, int); 215 struct mem_access *ma, int, unsigned long address);
216 216
217static inline void trigger_address_error(void) 217static inline void trigger_address_error(void)
218{ 218{
219 if (__in_29bit_mode()) 219 __asm__ __volatile__ (
220 __asm__ __volatile__ ( 220 "ldc %0, sr\n\t"
221 "ldc %0, sr\n\t" 221 "mov.l @%1, %0"
222 "mov.l @%1, %0" 222 :
223 : 223 : "r" (0x10000000), "r" (0x80000001)
224 : "r" (0x10000000), "r" (0x80000001) 224 );
225 );
226} 225}
227 226
228asmlinkage void do_address_error(struct pt_regs *regs, 227asmlinkage void do_address_error(struct pt_regs *regs,
diff --git a/arch/sh/include/asm/tlbflush.h b/arch/sh/include/asm/tlbflush.h
index e0ac97221ae6..0df66f0c7284 100644
--- a/arch/sh/include/asm/tlbflush.h
+++ b/arch/sh/include/asm/tlbflush.h
@@ -21,6 +21,8 @@ extern void local_flush_tlb_kernel_range(unsigned long start,
21 unsigned long end); 21 unsigned long end);
22extern void local_flush_tlb_one(unsigned long asid, unsigned long page); 22extern void local_flush_tlb_one(unsigned long asid, unsigned long page);
23 23
24extern void __flush_tlb_global(void);
25
24#ifdef CONFIG_SMP 26#ifdef CONFIG_SMP
25 27
26extern void flush_tlb_all(void); 28extern void flush_tlb_all(void);
diff --git a/arch/sh/include/asm/unistd_32.h b/arch/sh/include/asm/unistd_32.h
index 0e7f0fc8f086..903cd618eb74 100644
--- a/arch/sh/include/asm/unistd_32.h
+++ b/arch/sh/include/asm/unistd_32.h
@@ -345,12 +345,33 @@
345#define __NR_pwritev 334 345#define __NR_pwritev 334
346#define __NR_rt_tgsigqueueinfo 335 346#define __NR_rt_tgsigqueueinfo 335
347#define __NR_perf_event_open 336 347#define __NR_perf_event_open 336
348#define __NR_fanotify_init 337
349#define __NR_fanotify_mark 338
350#define __NR_prlimit64 339
348 351
349#define NR_syscalls 337 352/* Non-multiplexed socket family */
353#define __NR_socket 340
354#define __NR_bind 341
355#define __NR_connect 342
356#define __NR_listen 343
357#define __NR_accept 344
358#define __NR_getsockname 345
359#define __NR_getpeername 346
360#define __NR_socketpair 347
361#define __NR_send 348
362#define __NR_sendto 349
363#define __NR_recv 350
364#define __NR_recvfrom 351
365#define __NR_shutdown 352
366#define __NR_setsockopt 353
367#define __NR_getsockopt 354
368#define __NR_sendmsg 355
369#define __NR_recvmsg 356
370#define __NR_recvmmsg 357
350 371
351#ifdef __KERNEL__ 372#define NR_syscalls 358
352 373
353#define __IGNORE_recvmmsg 374#ifdef __KERNEL__
354 375
355#define __ARCH_WANT_IPC_PARSE_VERSION 376#define __ARCH_WANT_IPC_PARSE_VERSION
356#define __ARCH_WANT_OLD_READDIR 377#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/sh/include/asm/unistd_64.h b/arch/sh/include/asm/unistd_64.h
index 0580c33a1e04..09aa93f9eb70 100644
--- a/arch/sh/include/asm/unistd_64.h
+++ b/arch/sh/include/asm/unistd_64.h
@@ -387,10 +387,13 @@
387#define __NR_perf_event_open 364 387#define __NR_perf_event_open 364
388#define __NR_recvmmsg 365 388#define __NR_recvmmsg 365
389#define __NR_accept4 366 389#define __NR_accept4 366
390#define __NR_fanotify_init 367
391#define __NR_fanotify_mark 368
392#define __NR_prlimit64 369
390 393
391#ifdef __KERNEL__ 394#ifdef __KERNEL__
392 395
393#define NR_syscalls 367 396#define NR_syscalls 370
394 397
395#define __ARCH_WANT_IPC_PARSE_VERSION 398#define __ARCH_WANT_IPC_PARSE_VERSION
396#define __ARCH_WANT_OLD_READDIR 399#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/sh/include/cpu-sh3/cpu/mmu_context.h b/arch/sh/include/cpu-sh3/cpu/mmu_context.h
index ab09da73ce77..0c7c735ea82a 100644
--- a/arch/sh/include/cpu-sh3/cpu/mmu_context.h
+++ b/arch/sh/include/cpu-sh3/cpu/mmu_context.h
@@ -16,6 +16,7 @@
16#define MMU_TEA 0xFFFFFFFC /* TLB Exception Address */ 16#define MMU_TEA 0xFFFFFFFC /* TLB Exception Address */
17 17
18#define MMUCR 0xFFFFFFE0 /* MMU Control Register */ 18#define MMUCR 0xFFFFFFE0 /* MMU Control Register */
19#define MMUCR_TI (1 << 2) /* TLB flush bit */
19 20
20#define MMU_TLB_ADDRESS_ARRAY 0xF2000000 21#define MMU_TLB_ADDRESS_ARRAY 0xF2000000
21#define MMU_PAGE_ASSOC_BIT 0x80 22#define MMU_PAGE_ASSOC_BIT 0x80
diff --git a/arch/sh/include/cpu-sh4/cpu/freq.h b/arch/sh/include/cpu-sh4/cpu/freq.h
index e1e90960ee9a..cffd25ed0240 100644
--- a/arch/sh/include/cpu-sh4/cpu/freq.h
+++ b/arch/sh/include/cpu-sh4/cpu/freq.h
@@ -56,7 +56,9 @@
56#define FRQCR1 0xffc40004 56#define FRQCR1 0xffc40004
57#define FRQMR1 0xffc40014 57#define FRQMR1 0xffc40014
58#elif defined(CONFIG_CPU_SUBTYPE_SHX3) 58#elif defined(CONFIG_CPU_SUBTYPE_SHX3)
59#define FRQCR 0xffc00014 59#define FRQCR0 0xffc00000
60#define FRQCR1 0xffc00004
61#define FRQMR1 0xffc00014
60#else 62#else
61#define FRQCR 0xffc00000 63#define FRQCR 0xffc00000
62#define FRQCR_PSTBY 0x0200 64#define FRQCR_PSTBY 0x0200
diff --git a/arch/sh/include/cpu-sh4/cpu/sh7757.h b/arch/sh/include/cpu-sh4/cpu/sh7757.h
index f4d267efad71..15f3de11c55a 100644
--- a/arch/sh/include/cpu-sh4/cpu/sh7757.h
+++ b/arch/sh/include/cpu-sh4/cpu/sh7757.h
@@ -3,241 +3,252 @@
3 3
4enum { 4enum {
5 /* PTA */ 5 /* PTA */
6 GPIO_PTA7, GPIO_PTA6, GPIO_PTA5, GPIO_PTA4, 6 GPIO_PTA0, GPIO_PTA1, GPIO_PTA2, GPIO_PTA3,
7 GPIO_PTA3, GPIO_PTA2, GPIO_PTA1, GPIO_PTA0, 7 GPIO_PTA4, GPIO_PTA5, GPIO_PTA6, GPIO_PTA7,
8 8
9 /* PTB */ 9 /* PTB */
10 GPIO_PTB7, GPIO_PTB6, GPIO_PTB5, GPIO_PTB4, 10 GPIO_PTB0, GPIO_PTB1, GPIO_PTB2, GPIO_PTB3,
11 GPIO_PTB3, GPIO_PTB2, GPIO_PTB1, GPIO_PTB0, 11 GPIO_PTB4, GPIO_PTB5, GPIO_PTB6, GPIO_PTB7,
12 12
13 /* PTC */ 13 /* PTC */
14 GPIO_PTC7, GPIO_PTC6, GPIO_PTC5, GPIO_PTC4, 14 GPIO_PTC0, GPIO_PTC1, GPIO_PTC2, GPIO_PTC3,
15 GPIO_PTC3, GPIO_PTC2, GPIO_PTC1, GPIO_PTC0, 15 GPIO_PTC4, GPIO_PTC5, GPIO_PTC6, GPIO_PTC7,
16 16
17 /* PTD */ 17 /* PTD */
18 GPIO_PTD7, GPIO_PTD6, GPIO_PTD5, GPIO_PTD4, 18 GPIO_PTD0, GPIO_PTD1, GPIO_PTD2, GPIO_PTD3,
19 GPIO_PTD3, GPIO_PTD2, GPIO_PTD1, GPIO_PTD0, 19 GPIO_PTD4, GPIO_PTD5, GPIO_PTD6, GPIO_PTD7,
20 20
21 /* PTE */ 21 /* PTE */
22 GPIO_PTE7, GPIO_PTE6, GPIO_PTE5, GPIO_PTE4, 22 GPIO_PTE0, GPIO_PTE1, GPIO_PTE2, GPIO_PTE3,
23 GPIO_PTE3, GPIO_PTE2, GPIO_PTE1, GPIO_PTE0, 23 GPIO_PTE4, GPIO_PTE5, GPIO_PTE6, GPIO_PTE7,
24 24
25 /* PTF */ 25 /* PTF */
26 GPIO_PTF7, GPIO_PTF6, GPIO_PTF5, GPIO_PTF4, 26 GPIO_PTF0, GPIO_PTF1, GPIO_PTF2, GPIO_PTF3,
27 GPIO_PTF3, GPIO_PTF2, GPIO_PTF1, GPIO_PTF0, 27 GPIO_PTF4, GPIO_PTF5, GPIO_PTF6, GPIO_PTF7,
28 28
29 /* PTG */ 29 /* PTG */
30 GPIO_PTG7, GPIO_PTG6, GPIO_PTG5, GPIO_PTG4, 30 GPIO_PTG0, GPIO_PTG1, GPIO_PTG2, GPIO_PTG3,
31 GPIO_PTG3, GPIO_PTG2, GPIO_PTG1, GPIO_PTG0, 31 GPIO_PTG4, GPIO_PTG5, GPIO_PTG6, GPIO_PTG7,
32 32
33 /* PTH */ 33 /* PTH */
34 GPIO_PTH7, GPIO_PTH6, GPIO_PTH5, GPIO_PTH4, 34 GPIO_PTH0, GPIO_PTH1, GPIO_PTH2, GPIO_PTH3,
35 GPIO_PTH3, GPIO_PTH2, GPIO_PTH1, GPIO_PTH0, 35 GPIO_PTH4, GPIO_PTH5, GPIO_PTH6, GPIO_PTH7,
36 36
37 /* PTI */ 37 /* PTI */
38 GPIO_PTI7, GPIO_PTI6, GPIO_PTI5, GPIO_PTI4, 38 GPIO_PTI0, GPIO_PTI1, GPIO_PTI2, GPIO_PTI3,
39 GPIO_PTI3, GPIO_PTI2, GPIO_PTI1, GPIO_PTI0, 39 GPIO_PTI4, GPIO_PTI5, GPIO_PTI6, GPIO_PTI7,
40 40
41 /* PTJ */ 41 /* PTJ */
42 GPIO_PTJ7, GPIO_PTJ6, GPIO_PTJ5, GPIO_PTJ4, 42 GPIO_PTJ0, GPIO_PTJ1, GPIO_PTJ2, GPIO_PTJ3,
43 GPIO_PTJ3, GPIO_PTJ2, GPIO_PTJ1, GPIO_PTJ0, 43 GPIO_PTJ4, GPIO_PTJ5, GPIO_PTJ6, GPIO_PTJ7_RESV,
44 44
45 /* PTK */ 45 /* PTK */
46 GPIO_PTK7, GPIO_PTK6, GPIO_PTK5, GPIO_PTK4, 46 GPIO_PTK0, GPIO_PTK1, GPIO_PTK2, GPIO_PTK3,
47 GPIO_PTK3, GPIO_PTK2, GPIO_PTK1, GPIO_PTK0, 47 GPIO_PTK4, GPIO_PTK5, GPIO_PTK6, GPIO_PTK7,
48 48
49 /* PTL */ 49 /* PTL */
50 GPIO_PTL7, GPIO_PTL6, GPIO_PTL5, GPIO_PTL4, 50 GPIO_PTL0, GPIO_PTL1, GPIO_PTL2, GPIO_PTL3,
51 GPIO_PTL3, GPIO_PTL2, GPIO_PTL1, GPIO_PTL0, 51 GPIO_PTL4, GPIO_PTL5, GPIO_PTL6, GPIO_PTL7_RESV,
52 52
53 /* PTM */ 53 /* PTM */
54 GPIO_PTM6, GPIO_PTM5, GPIO_PTM4, 54 GPIO_PTM0, GPIO_PTM1, GPIO_PTM2, GPIO_PTM3,
55 GPIO_PTM3, GPIO_PTM2, GPIO_PTM1, GPIO_PTM0, 55 GPIO_PTM4, GPIO_PTM5, GPIO_PTM6, GPIO_PTM7,
56 56
57 /* PTN */ 57 /* PTN */
58 GPIO_PTN7, GPIO_PTN6, GPIO_PTN5, GPIO_PTN4, 58 GPIO_PTN0, GPIO_PTN1, GPIO_PTN2, GPIO_PTN3,
59 GPIO_PTN3, GPIO_PTN2, GPIO_PTN1, GPIO_PTN0, 59 GPIO_PTN4, GPIO_PTN5, GPIO_PTN6, GPIO_PTN7_RESV,
60 60
61 /* PTO */ 61 /* PTO */
62 GPIO_PTO7, GPIO_PTO6, GPIO_PTO5, GPIO_PTO4, 62 GPIO_PTO0, GPIO_PTO1, GPIO_PTO2, GPIO_PTO3,
63 GPIO_PTO3, GPIO_PTO2, GPIO_PTO1, GPIO_PTO0, 63 GPIO_PTO4, GPIO_PTO5, GPIO_PTO6, GPIO_PTO7,
64 64
65 /* PTP */ 65 /* PTP */
66 GPIO_PTP6, GPIO_PTP5, GPIO_PTP4, 66 GPIO_PTP0, GPIO_PTP1, GPIO_PTP2, GPIO_PTP3,
67 GPIO_PTP3, GPIO_PTP2, GPIO_PTP1, GPIO_PTP0, 67 GPIO_PTP4, GPIO_PTP5, GPIO_PTP6, GPIO_PTP7,
68 68
69 /* PTQ */ 69 /* PTQ */
70 GPIO_PTQ6, GPIO_PTQ5, GPIO_PTQ4, 70 GPIO_PTQ0, GPIO_PTQ1, GPIO_PTQ2, GPIO_PTQ3,
71 GPIO_PTQ3, GPIO_PTQ2, GPIO_PTQ1, GPIO_PTQ0, 71 GPIO_PTQ4, GPIO_PTQ5, GPIO_PTQ6, GPIO_PTQ7_RESV,
72 72
73 /* PTR */ 73 /* PTR */
74 GPIO_PTR7, GPIO_PTR6, GPIO_PTR5, GPIO_PTR4, 74 GPIO_PTR0, GPIO_PTR1, GPIO_PTR2, GPIO_PTR3,
75 GPIO_PTR3, GPIO_PTR2, GPIO_PTR1, GPIO_PTR0, 75 GPIO_PTR4, GPIO_PTR5, GPIO_PTR6, GPIO_PTR7,
76 76
77 /* PTS */ 77 /* PTS */
78 GPIO_PTS7, GPIO_PTS6, GPIO_PTS5, GPIO_PTS4, 78 GPIO_PTS0, GPIO_PTS1, GPIO_PTS2, GPIO_PTS3,
79 GPIO_PTS3, GPIO_PTS2, GPIO_PTS1, GPIO_PTS0, 79 GPIO_PTS4, GPIO_PTS5, GPIO_PTS6, GPIO_PTS7,
80 80
81 /* PTT */ 81 /* PTT */
82 GPIO_PTT5, GPIO_PTT4, 82 GPIO_PTT0, GPIO_PTT1, GPIO_PTT2, GPIO_PTT3,
83 GPIO_PTT3, GPIO_PTT2, GPIO_PTT1, GPIO_PTT0, 83 GPIO_PTT4, GPIO_PTT5, GPIO_PTT6, GPIO_PTT7,
84 84
85 /* PTU */ 85 /* PTU */
86 GPIO_PTU7, GPIO_PTU6, GPIO_PTU5, GPIO_PTU4, 86 GPIO_PTU0, GPIO_PTU1, GPIO_PTU2, GPIO_PTU3,
87 GPIO_PTU3, GPIO_PTU2, GPIO_PTU1, GPIO_PTU0, 87 GPIO_PTU4, GPIO_PTU5, GPIO_PTU6, GPIO_PTU7,
88 88
89 /* PTV */ 89 /* PTV */
90 GPIO_PTV7, GPIO_PTV6, GPIO_PTV5, GPIO_PTV4, 90 GPIO_PTV0, GPIO_PTV1, GPIO_PTV2, GPIO_PTV3,
91 GPIO_PTV3, GPIO_PTV2, GPIO_PTV1, GPIO_PTV0, 91 GPIO_PTV4, GPIO_PTV5, GPIO_PTV6, GPIO_PTV7,
92 92
93 /* PTW */ 93 /* PTW */
94 GPIO_PTW7, GPIO_PTW6, GPIO_PTW5, GPIO_PTW4, 94 GPIO_PTW0, GPIO_PTW1, GPIO_PTW2, GPIO_PTW3,
95 GPIO_PTW3, GPIO_PTW2, GPIO_PTW1, GPIO_PTW0, 95 GPIO_PTW4, GPIO_PTW5, GPIO_PTW6, GPIO_PTW7,
96 96
97 /* PTX */ 97 /* PTX */
98 GPIO_PTX7, GPIO_PTX6, GPIO_PTX5, GPIO_PTX4, 98 GPIO_PTX0, GPIO_PTX1, GPIO_PTX2, GPIO_PTX3,
99 GPIO_PTX3, GPIO_PTX2, GPIO_PTX1, GPIO_PTX0, 99 GPIO_PTX4, GPIO_PTX5, GPIO_PTX6, GPIO_PTX7,
100 100
101 /* PTY */ 101 /* PTY */
102 GPIO_PTY7, GPIO_PTY6, GPIO_PTY5, GPIO_PTY4, 102 GPIO_PTY0, GPIO_PTY1, GPIO_PTY2, GPIO_PTY3,
103 GPIO_PTY3, GPIO_PTY2, GPIO_PTY1, GPIO_PTY0, 103 GPIO_PTY4, GPIO_PTY5, GPIO_PTY6, GPIO_PTY7,
104 104
105 /* PTZ */ 105 /* PTZ */
106 GPIO_PTZ7, GPIO_PTZ6, GPIO_PTZ5, GPIO_PTZ4, 106 GPIO_PTZ0, GPIO_PTZ1, GPIO_PTZ2, GPIO_PTZ3,
107 GPIO_PTZ3, GPIO_PTZ2, GPIO_PTZ1, GPIO_PTZ0, 107 GPIO_PTZ4, GPIO_PTZ5, GPIO_PTZ6, GPIO_PTZ7,
108 108
109 109
110 /* PTA (mobule: LBSC, CPG, LPC) */ 110 /* PTA (mobule: LBSC, RGMII) */
111 GPIO_FN_BS, GPIO_FN_RDWR, GPIO_FN_WE1, GPIO_FN_RDY, 111 GPIO_FN_BS, GPIO_FN_RDWR, GPIO_FN_WE1, GPIO_FN_RDY,
112 GPIO_FN_MD10, GPIO_FN_MD9, GPIO_FN_MD8, 112 GPIO_FN_ET0_MDC, GPIO_FN_ET0_MDIO,
113 GPIO_FN_LGPIO7, GPIO_FN_LGPIO6, GPIO_FN_LGPIO5, GPIO_FN_LGPIO4, 113 GPIO_FN_ET1_MDC, GPIO_FN_ET1_MDIO,
114 GPIO_FN_LGPIO3, GPIO_FN_LGPIO2, GPIO_FN_LGPIO1, GPIO_FN_LGPIO0,
115
116 /* PTB (mobule: LBSC, EtherC, SIM, LPC) */
117 GPIO_FN_D15, GPIO_FN_D14, GPIO_FN_D13, GPIO_FN_D12,
118 GPIO_FN_D11, GPIO_FN_D10, GPIO_FN_D9, GPIO_FN_D8,
119 GPIO_FN_ET0_MDC, GPIO_FN_ET0_MDIO,
120 GPIO_FN_ET1_MDC, GPIO_FN_ET1_MDIO,
121 GPIO_FN_SIM_D, GPIO_FN_SIM_CLK, GPIO_FN_SIM_RST,
122 GPIO_FN_WPSZ1, GPIO_FN_WPSZ0, GPIO_FN_FWID, GPIO_FN_FLSHSZ,
123 GPIO_FN_LPC_SPIEN, GPIO_FN_BASEL,
124 114
125 /* PTC (mobule: SD) */ 115 /* PTB (mobule: INTC, ONFI, TMU) */
126 GPIO_FN_SD_WP, GPIO_FN_SD_CD, GPIO_FN_SD_CLK, GPIO_FN_SD_CMD, 116 GPIO_FN_IRQ15, GPIO_FN_IRQ14, GPIO_FN_IRQ13, GPIO_FN_IRQ12,
127 GPIO_FN_SD_D3, GPIO_FN_SD_D2, GPIO_FN_SD_D1, GPIO_FN_SD_D0, 117 GPIO_FN_IRQ11, GPIO_FN_IRQ10, GPIO_FN_IRQ9, GPIO_FN_IRQ8,
118 GPIO_FN_ON_NRE, GPIO_FN_ON_NWE, GPIO_FN_ON_NWP, GPIO_FN_ON_NCE0,
119 GPIO_FN_ON_R_B0, GPIO_FN_ON_ALE, GPIO_FN_ON_CLE,
120 GPIO_FN_TCLK,
128 121
129 /* PTD (mobule: INTC, SPI0, LBSC, CPG, ADC) */ 122 /* PTC (mobule: IRQ, PWMU) */
130 GPIO_FN_IRQ7, GPIO_FN_IRQ6, GPIO_FN_IRQ5, GPIO_FN_IRQ4, 123 GPIO_FN_IRQ7, GPIO_FN_IRQ6, GPIO_FN_IRQ5, GPIO_FN_IRQ4,
131 GPIO_FN_IRQ3, GPIO_FN_IRQ2, GPIO_FN_IRQ1, GPIO_FN_IRQ0, 124 GPIO_FN_IRQ3, GPIO_FN_IRQ2, GPIO_FN_IRQ1, GPIO_FN_IRQ0,
132 GPIO_FN_MD6, GPIO_FN_MD5, GPIO_FN_MD3, GPIO_FN_MD2, 125 GPIO_FN_PWMU0, GPIO_FN_PWMU1, GPIO_FN_PWMU2, GPIO_FN_PWMU3,
133 GPIO_FN_MD1, GPIO_FN_MD0, GPIO_FN_ADTRG1, GPIO_FN_ADTRG0, 126 GPIO_FN_PWMU4, GPIO_FN_PWMU5,
134 127
135 /* PTE (mobule: EtherC) */ 128 /* PTD (mobule: SPI0, DMAC) */
136 GPIO_FN_ET0_CRS_DV, GPIO_FN_ET0_TXD1, 129 GPIO_FN_SP0_MOSI, GPIO_FN_SP0_MISO, GPIO_FN_SP0_SCK,
137 GPIO_FN_ET0_TXD0, GPIO_FN_ET0_TX_EN, 130 GPIO_FN_SP0_SCK_FB, GPIO_FN_SP0_SS0, GPIO_FN_SP0_SS1,
138 GPIO_FN_ET0_REF_CLK, GPIO_FN_ET0_RXD1, 131 GPIO_FN_SP0_SS2, GPIO_FN_SP0_SS3, GPIO_FN_DREQ0,
139 GPIO_FN_ET0_RXD0, GPIO_FN_ET0_RX_ER, 132 GPIO_FN_DACK0, GPIO_FN_TEND0,
140 133
141 /* PTF (mobule: EtherC) */ 134 /* PTE (mobule: RMII) */
142 GPIO_FN_ET1_CRS_DV, GPIO_FN_ET1_TXD1, 135 GPIO_FN_RMII0_CRS_DV, GPIO_FN_RMII0_TXD1, GPIO_FN_RMII0_TXD0,
143 GPIO_FN_ET1_TXD0, GPIO_FN_ET1_TX_EN, 136 GPIO_FN_RMII0_TXEN, GPIO_FN_RMII0_REFCLK, GPIO_FN_RMII0_RXD1,
144 GPIO_FN_ET1_REF_CLK, GPIO_FN_ET1_RXD1, 137 GPIO_FN_RMII0_RXD0, GPIO_FN_RMII0_RX_ER,
145 GPIO_FN_ET1_RXD0, GPIO_FN_ET1_RX_ER, 138
146 139 /* PTF (mobule: RMII, SerMux) */
147 /* PTG (mobule: SYSTEM, PWMX, LPC) */ 140 GPIO_FN_RMII1_CRS_DV, GPIO_FN_RMII1_TXD1, GPIO_FN_RMII1_TXD0,
148 GPIO_FN_STATUS0, GPIO_FN_STATUS1, 141 GPIO_FN_RMII1_TXEN, GPIO_FN_RMII1_REFCLK, GPIO_FN_RMII1_RXD1,
149 GPIO_FN_PWX0, GPIO_FN_PWX1, GPIO_FN_PWX2, GPIO_FN_PWX3, 142 GPIO_FN_RMII1_RXD0, GPIO_FN_RMII1_RX_ER, GPIO_FN_RAC_RI,
150 GPIO_FN_SERIRQ, GPIO_FN_CLKRUN, GPIO_FN_LPCPD, GPIO_FN_LDRQ, 143
151 144 /* PTG (mobule: system, LBSC, LPC, WDT, LPC, eMMC) */
152 /* PTH (mobule: TMU, SCIF234, SPI1, SPI0) */ 145 GPIO_FN_BOOTFMS, GPIO_FN_BOOTWP,
153 GPIO_FN_TCLK, GPIO_FN_RXD4, GPIO_FN_TXD4, 146 GPIO_FN_A25, GPIO_FN_A24, GPIO_FN_SERIRQ, GPIO_FN_WDTOVF,
147 GPIO_FN_LPCPD, GPIO_FN_LDRQ, GPIO_FN_MMCCLK, GPIO_FN_MMCCMD,
148
149 /* PTH (mobule: SPI1, LPC, DMAC, ADC) */
154 GPIO_FN_SP1_MOSI, GPIO_FN_SP1_MISO, 150 GPIO_FN_SP1_MOSI, GPIO_FN_SP1_MISO,
155 GPIO_FN_SP1_SCK, GPIO_FN_SP1_SCK_FB, 151 GPIO_FN_SP1_SCK, GPIO_FN_SP1_SCK_FB,
156 GPIO_FN_SP1_SS0, GPIO_FN_SP1_SS1, 152 GPIO_FN_SP1_SS0, GPIO_FN_SP1_SS1,
157 GPIO_FN_SP0_SS1, 153 GPIO_FN_WP, GPIO_FN_FMS0, GPIO_FN_TEND1, GPIO_FN_DREQ1,
158 154 GPIO_FN_DACK1, GPIO_FN_ADTRG1, GPIO_FN_ADTRG0,
159 /* PTI (mobule: INTC) */
160 GPIO_FN_IRQ15, GPIO_FN_IRQ14, GPIO_FN_IRQ13, GPIO_FN_IRQ12,
161 GPIO_FN_IRQ11, GPIO_FN_IRQ10, GPIO_FN_IRQ9, GPIO_FN_IRQ8,
162
163 /* PTJ (mobule: SCIF234, SERMUX) */
164 GPIO_FN_RXD3, GPIO_FN_TXD3, GPIO_FN_RXD2, GPIO_FN_TXD2,
165 GPIO_FN_COM1_TXD, GPIO_FN_COM1_RXD,
166 GPIO_FN_COM1_RTS, GPIO_FN_COM1_CTS,
167
168 /* PTK (mobule: SERMUX) */
169 GPIO_FN_COM2_TXD, GPIO_FN_COM2_RXD,
170 GPIO_FN_COM2_RTS, GPIO_FN_COM2_CTS,
171 GPIO_FN_COM2_DTR, GPIO_FN_COM2_DSR,
172 GPIO_FN_COM2_DCD, GPIO_FN_COM2_RI,
173 155
174 /* PTL (mobule: SERMUX) */ 156 /* PTI (mobule: LBSC, SDHI) */
175 GPIO_FN_RAC_TXD, GPIO_FN_RAC_RXD, 157 GPIO_FN_D15, GPIO_FN_D14, GPIO_FN_D13, GPIO_FN_D12,
176 GPIO_FN_RAC_RTS, GPIO_FN_RAC_CTS, 158 GPIO_FN_D11, GPIO_FN_D10, GPIO_FN_D9, GPIO_FN_D8,
177 GPIO_FN_RAC_DTR, GPIO_FN_RAC_DSR, 159 GPIO_FN_SD_WP, GPIO_FN_SD_CD, GPIO_FN_SD_CLK, GPIO_FN_SD_CMD,
178 GPIO_FN_RAC_DCD, GPIO_FN_RAC_RI, 160 GPIO_FN_SD_D3, GPIO_FN_SD_D2, GPIO_FN_SD_D1, GPIO_FN_SD_D0,
179 161
180 /* PTM (mobule: IIC, LPC) */ 162 /* PTJ (mobule: SCIF234) */
163 GPIO_FN_RTS3, GPIO_FN_CTS3, GPIO_FN_TXD3, GPIO_FN_RXD3,
164 GPIO_FN_RTS4, GPIO_FN_RXD4, GPIO_FN_TXD4,
165
166 /* PTK (mobule: SERMUX, LBSC, SCIF) */
167 GPIO_FN_COM2_TXD, GPIO_FN_COM2_RXD, GPIO_FN_COM2_RTS,
168 GPIO_FN_COM2_CTS, GPIO_FN_COM2_DTR, GPIO_FN_COM2_DSR,
169 GPIO_FN_COM2_DCD, GPIO_FN_CLKOUT,
170 GPIO_FN_SCK2, GPIO_FN_SCK4, GPIO_FN_SCK3,
171
172 /* PTL (mobule: SERMUX, SCIF, LBSC, AUD) */
173 GPIO_FN_RAC_RXD, GPIO_FN_RAC_RTS, GPIO_FN_RAC_CTS,
174 GPIO_FN_RAC_DTR, GPIO_FN_RAC_DSR, GPIO_FN_RAC_DCD,
175 GPIO_FN_RAC_TXD, GPIO_FN_RXD2, GPIO_FN_CS5,
176 GPIO_FN_CS6, GPIO_FN_AUDSYNC, GPIO_FN_AUDCK,
177 GPIO_FN_TXD2,
178
179 /* PTM (mobule: LBSC, IIC) */
180 GPIO_FN_CS4, GPIO_FN_RD, GPIO_FN_WE0, GPIO_FN_CS0,
181 GPIO_FN_SDA6, GPIO_FN_SCL6, GPIO_FN_SDA7, GPIO_FN_SCL7, 181 GPIO_FN_SDA6, GPIO_FN_SCL6, GPIO_FN_SDA7, GPIO_FN_SCL7,
182 GPIO_FN_WP, GPIO_FN_FMS0, GPIO_FN_FMS1,
183
184 /* PTN (mobule: SCIF234, EVC) */
185 GPIO_FN_SCK2, GPIO_FN_RTS4, GPIO_FN_RTS3, GPIO_FN_RTS2,
186 GPIO_FN_CTS4, GPIO_FN_CTS3, GPIO_FN_CTS2,
187 GPIO_FN_EVENT7, GPIO_FN_EVENT6, GPIO_FN_EVENT5, GPIO_FN_EVENT4,
188 GPIO_FN_EVENT3, GPIO_FN_EVENT2, GPIO_FN_EVENT1, GPIO_FN_EVENT0,
189 182
190 /* PTO (mobule: SGPIO) */ 183 /* PTN (mobule: USB, JMC, SGPIO, WDT) */
191 GPIO_FN_SGPIO0_CLK, GPIO_FN_SGPIO0_LOAD, 184 GPIO_FN_VBUS_EN, GPIO_FN_VBUS_OC, GPIO_FN_JMCTCK,
192 GPIO_FN_SGPIO0_DI, GPIO_FN_SGPIO0_DO, 185 GPIO_FN_JMCTMS, GPIO_FN_JMCTDO, GPIO_FN_JMCTDI,
193 GPIO_FN_SGPIO1_CLK, GPIO_FN_SGPIO1_LOAD, 186 GPIO_FN_JMCTRST,
194 GPIO_FN_SGPIO1_DI, GPIO_FN_SGPIO1_DO, 187 GPIO_FN_SGPIO1_CLK, GPIO_FN_SGPIO1_LOAD, GPIO_FN_SGPIO1_DI,
188 GPIO_FN_SGPIO1_DO, GPIO_FN_SUB_CLKIN,
195 189
196 /* PTP (mobule: JMC, SCIF234) */ 190 /* PTO (mobule: SGPIO, SerMux) */
197 GPIO_FN_JMCTCK, GPIO_FN_JMCTMS, GPIO_FN_JMCTDO, GPIO_FN_JMCTDI, 191 GPIO_FN_SGPIO0_CLK, GPIO_FN_SGPIO0_LOAD, GPIO_FN_SGPIO0_DI,
198 GPIO_FN_JMCRST, GPIO_FN_SCK4, GPIO_FN_SCK3, 192 GPIO_FN_SGPIO0_DO, GPIO_FN_SGPIO2_CLK, GPIO_FN_SGPIO2_LOAD,
193 GPIO_FN_SGPIO2_DI, GPIO_FN_SGPIO2_DO, GPIO_FN_COM1_TXD,
194 GPIO_FN_COM1_RXD, GPIO_FN_COM1_RTS, GPIO_FN_COM1_CTS,
199 195
200 /* PTQ (mobule: LPC) */ 196 /* PTQ (mobule: LPC) */
201 GPIO_FN_LAD3, GPIO_FN_LAD2, GPIO_FN_LAD1, GPIO_FN_LAD0, 197 GPIO_FN_LAD3, GPIO_FN_LAD2, GPIO_FN_LAD1, GPIO_FN_LAD0,
202 GPIO_FN_LFRAME, GPIO_FN_LRESET, GPIO_FN_LCLK, 198 GPIO_FN_LFRAME, GPIO_FN_LRESET, GPIO_FN_LCLK,
203 199
204 /* PTR (mobule: GRA, IIC) */ 200 /* PTR (mobule: GRA, IIC) */
205 GPIO_FN_DDC3, GPIO_FN_DDC2, 201 GPIO_FN_DDC3, GPIO_FN_DDC2, GPIO_FN_SDA2, GPIO_FN_SCL2,
206 GPIO_FN_SDA8, GPIO_FN_SCL8, GPIO_FN_SDA2, GPIO_FN_SCL2,
207 GPIO_FN_SDA1, GPIO_FN_SCL1, GPIO_FN_SDA0, GPIO_FN_SCL0, 202 GPIO_FN_SDA1, GPIO_FN_SCL1, GPIO_FN_SDA0, GPIO_FN_SCL0,
203 GPIO_FN_SDA8, GPIO_FN_SCL8,
208 204
209 /* PTS (mobule: GRA, IIC) */ 205 /* PTS (mobule: GRA, IIC) */
210 GPIO_FN_DDC1, GPIO_FN_DDC0, 206 GPIO_FN_DDC1, GPIO_FN_DDC0, GPIO_FN_SDA5, GPIO_FN_SCL5,
211 GPIO_FN_SDA9, GPIO_FN_SCL9, GPIO_FN_SDA5, GPIO_FN_SCL5,
212 GPIO_FN_SDA4, GPIO_FN_SCL4, GPIO_FN_SDA3, GPIO_FN_SCL3, 207 GPIO_FN_SDA4, GPIO_FN_SCL4, GPIO_FN_SDA3, GPIO_FN_SCL3,
208 GPIO_FN_SDA9, GPIO_FN_SCL9,
213 209
214 /* PTT (mobule: SYSTEM, PWMX) */ 210 /* PTT (mobule: PWMX, AUD) */
215 GPIO_FN_AUDSYNC, GPIO_FN_AUDCK, 211 GPIO_FN_PWMX7, GPIO_FN_PWMX6, GPIO_FN_PWMX5, GPIO_FN_PWMX4,
216 GPIO_FN_AUDATA3, GPIO_FN_AUDATA2, 212 GPIO_FN_PWMX3, GPIO_FN_PWMX2, GPIO_FN_PWMX1, GPIO_FN_PWMX0,
217 GPIO_FN_AUDATA1, GPIO_FN_AUDATA0, 213 GPIO_FN_AUDATA3, GPIO_FN_AUDATA2, GPIO_FN_AUDATA1,
218 GPIO_FN_PWX7, GPIO_FN_PWX6, GPIO_FN_PWX5, GPIO_FN_PWX4, 214 GPIO_FN_AUDATA0, GPIO_FN_STATUS1, GPIO_FN_STATUS0,
219 215
220 /* PTU (mobule: LBSC, DMAC) */ 216 /* PTU (mobule: LPC, APM) */
221 GPIO_FN_CS6, GPIO_FN_CS5, GPIO_FN_CS4, GPIO_FN_CS0, 217 GPIO_FN_LGPIO7, GPIO_FN_LGPIO6, GPIO_FN_LGPIO5, GPIO_FN_LGPIO4,
222 GPIO_FN_RD, GPIO_FN_WE0, GPIO_FN_A25, GPIO_FN_A24, 218 GPIO_FN_LGPIO3, GPIO_FN_LGPIO2, GPIO_FN_LGPIO1, GPIO_FN_LGPIO0,
223 GPIO_FN_DREQ0, GPIO_FN_DACK0, 219 GPIO_FN_APMONCTL_O, GPIO_FN_APMPWBTOUT_O, GPIO_FN_APMSCI_O,
220 GPIO_FN_APMVDDON, GPIO_FN_APMSLPBTN, GPIO_FN_APMPWRBTN,
221 GPIO_FN_APMS5N, GPIO_FN_APMS3N,
224 222
225 /* PTV (mobule: LBSC, DMAC) */ 223 /* PTV (mobule: LBSC, SerMux, R-SPI, EVC, GRA) */
226 GPIO_FN_A23, GPIO_FN_A22, GPIO_FN_A21, GPIO_FN_A20, 224 GPIO_FN_A23, GPIO_FN_A22, GPIO_FN_A21, GPIO_FN_A20,
227 GPIO_FN_A19, GPIO_FN_A18, GPIO_FN_A17, GPIO_FN_A16, 225 GPIO_FN_A19, GPIO_FN_A18, GPIO_FN_A17, GPIO_FN_A16,
228 GPIO_FN_TEND0, GPIO_FN_DREQ1, GPIO_FN_DACK1, GPIO_FN_TEND1, 226 GPIO_FN_COM2_RI, GPIO_FN_R_SPI_MOSI, GPIO_FN_R_SPI_MISO,
227 GPIO_FN_R_SPI_RSPCK, GPIO_FN_R_SPI_SSL0, GPIO_FN_R_SPI_SSL1,
228 GPIO_FN_EVENT7, GPIO_FN_EVENT6, GPIO_FN_VBIOS_DI,
229 GPIO_FN_VBIOS_DO, GPIO_FN_VBIOS_CLK, GPIO_FN_VBIOS_CS,
229 230
230 /* PTW (mobule: LBSC) */ 231 /* PTW (mobule: LBSC, EVC, SCIF) */
231 GPIO_FN_A15, GPIO_FN_A14, GPIO_FN_A13, GPIO_FN_A12, 232 GPIO_FN_A15, GPIO_FN_A14, GPIO_FN_A13, GPIO_FN_A12,
232 GPIO_FN_A11, GPIO_FN_A10, GPIO_FN_A9, GPIO_FN_A8, 233 GPIO_FN_A11, GPIO_FN_A10, GPIO_FN_A9, GPIO_FN_A8,
234 GPIO_FN_EVENT5, GPIO_FN_EVENT4, GPIO_FN_EVENT3, GPIO_FN_EVENT2,
235 GPIO_FN_EVENT1, GPIO_FN_EVENT0, GPIO_FN_CTS4, GPIO_FN_CTS2,
233 236
234 /* PTX (mobule: LBSC) */ 237 /* PTX (mobule: LBSC, SCIF, SIM) */
235 GPIO_FN_A7, GPIO_FN_A6, GPIO_FN_A5, GPIO_FN_A4, 238 GPIO_FN_A7, GPIO_FN_A6, GPIO_FN_A5, GPIO_FN_A4,
236 GPIO_FN_A3, GPIO_FN_A2, GPIO_FN_A1, GPIO_FN_A0, 239 GPIO_FN_A3, GPIO_FN_A2, GPIO_FN_A1, GPIO_FN_A0,
240 GPIO_FN_RTS2, GPIO_FN_SIM_D, GPIO_FN_SIM_CLK, GPIO_FN_SIM_RST,
237 241
238 /* PTY (mobule: LBSC) */ 242 /* PTY (mobule: LBSC) */
239 GPIO_FN_D7, GPIO_FN_D6, GPIO_FN_D5, GPIO_FN_D4, 243 GPIO_FN_D7, GPIO_FN_D6, GPIO_FN_D5, GPIO_FN_D4,
240 GPIO_FN_D3, GPIO_FN_D2, GPIO_FN_D1, GPIO_FN_D0, 244 GPIO_FN_D3, GPIO_FN_D2, GPIO_FN_D1, GPIO_FN_D0,
245
246 /* PTZ (mobule: eMMC, ONFI) */
247 GPIO_FN_MMCDAT7, GPIO_FN_MMCDAT6, GPIO_FN_MMCDAT5,
248 GPIO_FN_MMCDAT4, GPIO_FN_MMCDAT3, GPIO_FN_MMCDAT2,
249 GPIO_FN_MMCDAT1, GPIO_FN_MMCDAT0,
250 GPIO_FN_ON_DQ7, GPIO_FN_ON_DQ6, GPIO_FN_ON_DQ5, GPIO_FN_ON_DQ4,
251 GPIO_FN_ON_DQ3, GPIO_FN_ON_DQ2, GPIO_FN_ON_DQ1, GPIO_FN_ON_DQ0,
241}; 252};
242 253
243#endif /* __ASM_SH7757_H__ */ 254#endif /* __ASM_SH7757_H__ */
diff --git a/arch/sh/include/cpu-sh4/cpu/shx3.h b/arch/sh/include/cpu-sh4/cpu/shx3.h
new file mode 100644
index 000000000000..68d9080a8da9
--- /dev/null
+++ b/arch/sh/include/cpu-sh4/cpu/shx3.h
@@ -0,0 +1,64 @@
1#ifndef __CPU_SHX3_H
2#define __CPU_SHX3_H
3
4enum {
5 /* PA */
6 GPIO_PA7, GPIO_PA6, GPIO_PA5, GPIO_PA4,
7 GPIO_PA3, GPIO_PA2, GPIO_PA1, GPIO_PA0,
8
9 /* PB */
10 GPIO_PB7, GPIO_PB6, GPIO_PB5, GPIO_PB4,
11 GPIO_PB3, GPIO_PB2, GPIO_PB1, GPIO_PB0,
12
13 /* PC */
14 GPIO_PC7, GPIO_PC6, GPIO_PC5, GPIO_PC4,
15 GPIO_PC3, GPIO_PC2, GPIO_PC1, GPIO_PC0,
16
17 /* PD */
18 GPIO_PD7, GPIO_PD6, GPIO_PD5, GPIO_PD4,
19 GPIO_PD3, GPIO_PD2, GPIO_PD1, GPIO_PD0,
20
21 /* PE */
22 GPIO_PE7, GPIO_PE6, GPIO_PE5, GPIO_PE4,
23 GPIO_PE3, GPIO_PE2, GPIO_PE1, GPIO_PE0,
24
25 /* PF */
26 GPIO_PF7, GPIO_PF6, GPIO_PF5, GPIO_PF4,
27 GPIO_PF3, GPIO_PF2, GPIO_PF1, GPIO_PF0,
28
29 /* PG */
30 GPIO_PG7, GPIO_PG6, GPIO_PG5, GPIO_PG4,
31 GPIO_PG3, GPIO_PG2, GPIO_PG1, GPIO_PG0,
32
33 /* PH */
34 GPIO_PH5, GPIO_PH4,
35 GPIO_PH3, GPIO_PH2, GPIO_PH1, GPIO_PH0,
36
37 /* SCIF */
38 GPIO_FN_SCK3, GPIO_FN_TXD3, GPIO_FN_RXD3,
39 GPIO_FN_SCK2, GPIO_FN_TXD2, GPIO_FN_RXD2,
40 GPIO_FN_SCK1, GPIO_FN_TXD1, GPIO_FN_RXD1,
41 GPIO_FN_SCK0, GPIO_FN_TXD0, GPIO_FN_RXD0,
42
43 /* LBSC */
44 GPIO_FN_D31, GPIO_FN_D30, GPIO_FN_D29, GPIO_FN_D28,
45 GPIO_FN_D27, GPIO_FN_D26, GPIO_FN_D25, GPIO_FN_D24,
46 GPIO_FN_D23, GPIO_FN_D22, GPIO_FN_D21, GPIO_FN_D20,
47 GPIO_FN_D19, GPIO_FN_D18, GPIO_FN_D17, GPIO_FN_D16,
48 GPIO_FN_WE3, GPIO_FN_WE2, GPIO_FN_CS6, GPIO_FN_CS5,
49 GPIO_FN_CS4, GPIO_FN_CLKOUTENB, GPIO_FN_BREQ,
50 GPIO_FN_IOIS16, GPIO_FN_CE2B, GPIO_FN_CE2A, GPIO_FN_BACK,
51
52 /* DMAC */
53 GPIO_FN_DACK0, GPIO_FN_DREQ0, GPIO_FN_DRAK0,
54 GPIO_FN_DACK1, GPIO_FN_DREQ1, GPIO_FN_DRAK1,
55 GPIO_FN_DACK2, GPIO_FN_DREQ2, GPIO_FN_DRAK2,
56 GPIO_FN_DACK3, GPIO_FN_DREQ3, GPIO_FN_DRAK3,
57
58 /* INTC */
59 GPIO_FN_IRQ3, GPIO_FN_IRQ2, GPIO_FN_IRQ1, GPIO_FN_IRQ0,
60 GPIO_FN_IRL3, GPIO_FN_IRL2, GPIO_FN_IRL1, GPIO_FN_IRL0,
61 GPIO_FN_IRQOUT, GPIO_FN_STATUS1, GPIO_FN_STATUS0,
62};
63
64#endif /* __CPU_SHX3_H */
diff --git a/arch/sh/include/mach-common/mach/sh2007.h b/arch/sh/include/mach-common/mach/sh2007.h
new file mode 100644
index 000000000000..48180b9aa03d
--- /dev/null
+++ b/arch/sh/include/mach-common/mach/sh2007.h
@@ -0,0 +1,117 @@
1#ifndef __MACH_SH2007_H
2#define __MACH_SH2007_H
3
4#define CS5BCR 0xff802050
5#define CS5WCR 0xff802058
6#define CS5PCR 0xff802070
7
8#define BUS_SZ8 1
9#define BUS_SZ16 2
10#define BUS_SZ32 3
11
12#define PCMCIA_IODYN 1
13#define PCMCIA_ATA 0
14#define PCMCIA_IO8 2
15#define PCMCIA_IO16 3
16#define PCMCIA_COMM8 4
17#define PCMCIA_COMM16 5
18#define PCMCIA_ATTR8 6
19#define PCMCIA_ATTR16 7
20
21#define TYPE_SRAM 0
22#define TYPE_PCMCIA 4
23
24/* write-read/write-write delay (0-7:0,1,2,3,4,5,6,7) */
25#define IWW5 0
26#define IWW6 3
27/* different area, read-write delay (0-7:0,1,2,3,4,5,6,7) */
28#define IWRWD5 2
29#define IWRWD6 2
30/* same area, read-write delay (0-7:0,1,2,3,4,5,6,7) */
31#define IWRWS5 2
32#define IWRWS6 2
33/* different area, read-read delay (0-7:0,1,2,3,4,5,6,7) */
34#define IWRRD5 2
35#define IWRRD6 2
36/* same area, read-read delay (0-7:0,1,2,3,4,5,6,7) */
37#define IWRRS5 0
38#define IWRRS6 2
39/* burst count (0-3:4,8,16,32) */
40#define BST5 0
41#define BST6 0
42/* bus size */
43#define SZ5 BUS_SZ16
44#define SZ6 BUS_SZ16
45/* RD hold for SRAM (0-1:0,1) */
46#define RDSPL5 0
47#define RDSPL6 0
48/* Burst pitch (0-7:0,1,2,3,4,5,6,7) */
49#define BW5 0
50#define BW6 0
51/* Multiplex (0-1:0,1) */
52#define MPX5 0
53#define MPX6 0
54/* device type */
55#define TYPE5 TYPE_PCMCIA
56#define TYPE6 TYPE_PCMCIA
57/* address setup before assert CSn for SRAM (0-7:0,1,2,3,4,5,6,7) */
58#define ADS5 0
59#define ADS6 0
60/* address hold after negate CSn for SRAM (0-7:0,1,2,3,4,5,6,7) */
61#define ADH5 0
62#define ADH6 0
63/* CSn assert to RD assert delay for SRAM (0-7:0,1,2,3,4,5,6,7) */
64#define RDS5 0
65#define RDS6 0
66/* RD negate to CSn negate delay for SRAM (0-7:0,1,2,3,4,5,6,7) */
67#define RDH5 0
68#define RDH6 0
69/* CSn assert to WE assert delay for SRAM (0-7:0,1,2,3,4,5,6,7) */
70#define WTS5 0
71#define WTS6 0
72/* WE negate to CSn negate delay for SRAM (0-7:0,1,2,3,4,5,6,7) */
73#define WTH5 0
74#define WTH6 0
75/* BS hold (0-1:1,2) */
76#define BSH5 0
77#define BSH6 0
78/* wait cycle (0-15:0,1,2,3,4,5,6,7,8,9,11,13,15,17,21,25) */
79#define IW5 6 /* 60ns PIO mode 4 */
80#define IW6 15 /* 250ns */
81
82#define SAA5 PCMCIA_IODYN /* IDE area b4000000-b5ffffff */
83#define SAB5 PCMCIA_IODYN /* CF area b6000000-b7ffffff */
84#define PCWA5 0 /* additional wait A (0-3:0,15,30,50) */
85#define PCWB5 0 /* additional wait B (0-3:0,15,30,50) */
86/* wait B (0-15:0,1,2,3,4,5,6,7,8,9,11,13,15,17,21,25) */
87#define PCIW5 12
88/* Address->OE/WE assert delay A (0-7:0,1,2,3,6,9,12,15) */
89#define TEDA5 2
90/* Address->OE/WE assert delay B (0-7:0,1,2,3,6,9,12,15) */
91#define TEDB5 4
92/* OE/WE negate->Address delay A (0-7:0,1,2,3,6,9,12,15) */
93#define TEHA5 2
94/* OE/WE negate->Address delay B (0-7:0,1,2,3,6,9,12,15) */
95#define TEHB5 3
96
97#define CS5BCR_D ((IWW5<<28)|(IWRWD5<<24)|(IWRWS5<<20)| \
98 (IWRRD5<<16)|(IWRRS5<<12)|(BST5<<10)| \
99 (SZ5<<8)|(RDSPL5<<7)|(BW5<<4)|(MPX5<<3)|TYPE5)
100#define CS5WCR_D ((ADS5<<28)|(ADH5<<24)|(RDS5<<20)| \
101 (RDH5<<16)|(WTS5<<12)|(WTH5<<8)|(BSH5<<4)|IW5)
102#define CS5PCR_D ((SAA5<<28)|(SAB5<<24)|(PCWA5<<22)| \
103 (PCWB5<<20)|(PCIW5<<16)|(TEDA5<<12)| \
104 (TEDB5<<8)|(TEHA5<<4)|TEHB5)
105
106#define SMC0_BASE 0xb0800000 /* eth0 */
107#define SMC1_BASE 0xb0900000 /* eth1 */
108#define CF_BASE 0xb6100000 /* Compact Flash (I/O area) */
109#define IDE_BASE 0xb4000000 /* IDE */
110#define PC104_IO_BASE 0xb8000000
111#define PC104_MEM_BASE 0xba000000
112#define SMC_IO_SIZE 0x100
113
114#define CF_OFFSET 0x1f0
115#define IDE_OFFSET 0x170
116
117#endif /* __MACH_SH2007_H */
diff --git a/arch/sh/include/mach-sdk7786/mach/fpga.h b/arch/sh/include/mach-sdk7786/mach/fpga.h
index 416b621d94d1..40f0c2d3690c 100644
--- a/arch/sh/include/mach-sdk7786/mach/fpga.h
+++ b/arch/sh/include/mach-sdk7786/mach/fpga.h
@@ -31,11 +31,35 @@
31#define EXTASR 0x110 31#define EXTASR 0x110
32#define SPCAR 0x120 32#define SPCAR 0x120
33#define INTMSR 0x130 33#define INTMSR 0x130
34
34#define PCIECR 0x140 35#define PCIECR 0x140
36#define PCIECR_PCIEMUX1 BIT(15)
37#define PCIECR_PCIEMUX0 BIT(14)
38#define PCIECR_PRST4 BIT(12) /* slot 4 card present */
39#define PCIECR_PRST3 BIT(11) /* slot 3 card present */
40#define PCIECR_PRST2 BIT(10) /* slot 2 card present */
41#define PCIECR_PRST1 BIT(9) /* slot 1 card present */
42#define PCIECR_CLKEN BIT(4) /* oscillator enable */
43
35#define FAER 0x150 44#define FAER 0x150
36#define USRGPIR 0x160 45#define USRGPIR 0x160
46
37/* 0x170 reserved */ 47/* 0x170 reserved */
38#define LCLASR 0x180 48
49#define LCLASR 0x180
50#define LCLASR_FRAMEN BIT(15)
51
52#define LCLASR_FPGA_SEL_SHIFT 12
53#define LCLASR_NAND_SEL_SHIFT 8
54#define LCLASR_NORB_SEL_SHIFT 4
55#define LCLASR_NORA_SEL_SHIFT 0
56
57#define LCLASR_AREA_MASK 0x7
58
59#define LCLASR_FPGA_SEL_MASK (LCLASR_AREA_MASK << LCLASR_FPGA_SEL_SHIFT)
60#define LCLASR_NAND_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NAND_SEL_SHIFT)
61#define LCLASR_NORB_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NORB_SEL_SHIFT)
62#define LCLASR_NORA_SEL_MASK (LCLASR_AREA_MASK << LCLASR_NORA_SEL_SHIFT)
39 63
40#define SBCR 0x190 64#define SBCR 0x190
41#define SCBR_I2CMEN BIT(0) /* FPGA I2C master enable */ 65#define SCBR_I2CMEN BIT(0) /* FPGA I2C master enable */
diff --git a/arch/sh/include/mach-x3proto/mach/hardware.h b/arch/sh/include/mach-x3proto/mach/hardware.h
new file mode 100644
index 000000000000..52bca57bfeb6
--- /dev/null
+++ b/arch/sh/include/mach-x3proto/mach/hardware.h
@@ -0,0 +1,12 @@
1#ifndef __MACH_X3PROTO_HARDWARE_H
2#define __MACH_X3PROTO_HARDWARE_H
3
4struct gpio_chip;
5
6/* arch/sh/boards/mach-x3proto/gpio.c */
7int x3proto_gpio_setup(void);
8extern struct gpio_chip x3proto_gpio_chip;
9
10#define NR_BASEBOARD_GPIOS 16
11
12#endif /* __MACH_X3PROTO_HARDWARE_H */
diff --git a/arch/sh/include/asm/ilsel.h b/arch/sh/include/mach-x3proto/mach/ilsel.h
index e3d304b280f6..e3d304b280f6 100644
--- a/arch/sh/include/asm/ilsel.h
+++ b/arch/sh/include/mach-x3proto/mach/ilsel.h
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index e25f3c69525d..8eed6a485446 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -12,9 +12,9 @@ endif
12CFLAGS_REMOVE_return_address.o = -pg 12CFLAGS_REMOVE_return_address.o = -pg
13 13
14obj-y := clkdev.o debugtraps.o dma-nommu.o dumpstack.o \ 14obj-y := clkdev.o debugtraps.o dma-nommu.o dumpstack.o \
15 idle.o io.o irq.o \ 15 idle.o io.o irq.o irq_$(BITS).o kdebugfs.o \
16 irq_$(BITS).o machvec.o nmi_debug.o process.o \ 16 machvec.o nmi_debug.o process.o \
17 process_$(BITS).o ptrace_$(BITS).o \ 17 process_$(BITS).o ptrace.o ptrace_$(BITS).o \
18 reboot.o return_address.o \ 18 reboot.o return_address.o \
19 setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \ 19 setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \
20 syscalls_$(BITS).o time.o topology.o traps.o \ 20 syscalls_$(BITS).o time.o topology.o traps.o \
@@ -44,4 +44,4 @@ obj-$(CONFIG_HAS_IOPORT) += io_generic.o
44obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 44obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
45obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += localtimer.o 45obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += localtimer.o
46 46
47EXTRA_CFLAGS += -Werror 47ccflags-y := -Werror
diff --git a/arch/sh/kernel/clkdev.c b/arch/sh/kernel/clkdev.c
index befc255830a4..1f800ef4a735 100644
--- a/arch/sh/kernel/clkdev.c
+++ b/arch/sh/kernel/clkdev.c
@@ -161,9 +161,11 @@ EXPORT_SYMBOL(clk_add_alias);
161 */ 161 */
162void clkdev_drop(struct clk_lookup *cl) 162void clkdev_drop(struct clk_lookup *cl)
163{ 163{
164 struct clk_lookup_alloc *cla = container_of(cl, struct clk_lookup_alloc, cl);
165
164 mutex_lock(&clocks_mutex); 166 mutex_lock(&clocks_mutex);
165 list_del(&cl->node); 167 list_del(&cl->node);
166 mutex_unlock(&clocks_mutex); 168 mutex_unlock(&clocks_mutex);
167 kfree(cl); 169 kfree(cla);
168} 170}
169EXPORT_SYMBOL(clkdev_drop); 171EXPORT_SYMBOL(clkdev_drop);
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index d180f16281ed..b93458f33b74 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -150,7 +150,7 @@ void __cpuinit cpu_probe(void)
150 boot_cpu_data.type = CPU_SH7724; 150 boot_cpu_data.type = CPU_SH7724;
151 boot_cpu_data.flags |= CPU_HAS_L2_CACHE; 151 boot_cpu_data.flags |= CPU_HAS_L2_CACHE;
152 break; 152 break;
153 case 0x50: 153 case 0x10:
154 boot_cpu_data.type = CPU_SH7757; 154 boot_cpu_data.type = CPU_SH7757;
155 break; 155 break;
156 } 156 }
diff --git a/arch/sh/kernel/cpu/sh4a/Makefile b/arch/sh/kernel/cpu/sh4a/Makefile
index b144e8af89dc..cc122b1d3035 100644
--- a/arch/sh/kernel/cpu/sh4a/Makefile
+++ b/arch/sh/kernel/cpu/sh4a/Makefile
@@ -8,13 +8,13 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7763) += setup-sh7763.o
8obj-$(CONFIG_CPU_SUBTYPE_SH7770) += setup-sh7770.o 8obj-$(CONFIG_CPU_SUBTYPE_SH7770) += setup-sh7770.o
9obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o 9obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o 10obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o
11obj-$(CONFIG_CPU_SUBTYPE_SH7786) += setup-sh7786.o 11obj-$(CONFIG_CPU_SUBTYPE_SH7786) += setup-sh7786.o intc-shx3.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o 12obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o
13obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o 13obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o
14obj-$(CONFIG_CPU_SUBTYPE_SH7723) += setup-sh7723.o 14obj-$(CONFIG_CPU_SUBTYPE_SH7723) += setup-sh7723.o
15obj-$(CONFIG_CPU_SUBTYPE_SH7724) += setup-sh7724.o 15obj-$(CONFIG_CPU_SUBTYPE_SH7724) += setup-sh7724.o
16obj-$(CONFIG_CPU_SUBTYPE_SH7366) += setup-sh7366.o 16obj-$(CONFIG_CPU_SUBTYPE_SH7366) += setup-sh7366.o
17obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o 17obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o intc-shx3.o
18 18
19# SMP setup 19# SMP setup
20smp-$(CONFIG_CPU_SHX3) := smp-shx3.o 20smp-$(CONFIG_CPU_SHX3) := smp-shx3.o
@@ -40,6 +40,7 @@ pinmux-$(CONFIG_CPU_SUBTYPE_SH7724) := pinmux-sh7724.o
40pinmux-$(CONFIG_CPU_SUBTYPE_SH7757) := pinmux-sh7757.o 40pinmux-$(CONFIG_CPU_SUBTYPE_SH7757) := pinmux-sh7757.o
41pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o 41pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o
42pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o 42pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o
43pinmux-$(CONFIG_CPU_SUBTYPE_SHX3) := pinmux-shx3.o
43 44
44obj-y += $(clock-y) 45obj-y += $(clock-y)
45obj-$(CONFIG_SMP) += $(smp-y) 46obj-$(CONFIG_SMP) += $(smp-y)
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0a752bd324ac..ce39a2ae8c6c 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * SH7757 support for the clock framework 4 * SH7757 support for the clock framework
5 * 5 *
6 * Copyright (C) 2009 Renesas Solutions Corp. 6 * Copyright (C) 2009-2010 Renesas Solutions Corp.
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -16,124 +16,147 @@
16#include <asm/clock.h> 16#include <asm/clock.h>
17#include <asm/freq.h> 17#include <asm/freq.h>
18 18
19static int ifc_divisors[] = { 2, 1, 4, 1, 1, 8, 1, 1, 19/*
20 16, 1, 1, 32, 1, 1, 1, 1 }; 20 * Default rate for the root input clock, reset this with clk_set_rate()
21static int sfc_divisors[] = { 2, 1, 4, 1, 1, 8, 1, 1, 21 * from the platform code.
22 16, 1, 1, 32, 1, 1, 1, 1 }; 22 */
23static int bfc_divisors[] = { 2, 1, 4, 1, 1, 8, 1, 1, 23static struct clk extal_clk = {
24 16, 1, 1, 32, 1, 1, 1, 1 }; 24 .rate = 48000000,
25static int p1fc_divisors[] = { 2, 1, 4, 1, 1, 8, 1, 1, 25};
26 16, 1, 1, 32, 1, 1, 1, 1 };
27 26
28static void master_clk_init(struct clk *clk) 27static unsigned long pll_recalc(struct clk *clk)
29{ 28{
30 clk->rate = CONFIG_SH_PCLK_FREQ * 16; 29 int multiplier;
31}
32 30
33static struct clk_ops sh7757_master_clk_ops = { 31 multiplier = test_mode_pin(MODE_PIN0) ? 24 : 16;
34 .init = master_clk_init,
35};
36 32
37static void module_clk_recalc(struct clk *clk) 33 return clk->parent->rate * multiplier;
38{
39 int idx = __raw_readl(FRQCR) & 0x0000000f;
40 clk->rate = clk->parent->rate / p1fc_divisors[idx];
41} 34}
42 35
43static struct clk_ops sh7757_module_clk_ops = { 36static struct clk_ops pll_clk_ops = {
44 .recalc = module_clk_recalc, 37 .recalc = pll_recalc,
45}; 38};
46 39
47static void bus_clk_recalc(struct clk *clk) 40static struct clk pll_clk = {
48{ 41 .ops = &pll_clk_ops,
49 int idx = (__raw_readl(FRQCR) >> 8) & 0x0000000f; 42 .parent = &extal_clk,
50 clk->rate = clk->parent->rate / bfc_divisors[idx]; 43 .flags = CLK_ENABLE_ON_INIT,
51} 44};
52 45
53static struct clk_ops sh7757_bus_clk_ops = { 46static struct clk *clks[] = {
54 .recalc = bus_clk_recalc, 47 &extal_clk,
48 &pll_clk,
55}; 49};
56 50
57static void cpu_clk_recalc(struct clk *clk) 51static unsigned int div2[] = { 1, 1, 2, 1, 1, 4, 1, 6,
58{ 52 1, 1, 1, 16, 1, 24, 1, 1 };
59 int idx = (__raw_readl(FRQCR) >> 20) & 0x0000000f;
60 clk->rate = clk->parent->rate / ifc_divisors[idx];
61}
62 53
63static struct clk_ops sh7757_cpu_clk_ops = { 54static struct clk_div_mult_table div4_div_mult_table = {
64 .recalc = cpu_clk_recalc, 55 .divisors = div2,
56 .nr_divisors = ARRAY_SIZE(div2),
65}; 57};
66 58
67static struct clk_ops *sh7757_clk_ops[] = { 59static struct clk_div4_table div4_table = {
68 &sh7757_master_clk_ops, 60 .div_mult_table = &div4_div_mult_table,
69 &sh7757_module_clk_ops,
70 &sh7757_bus_clk_ops,
71 &sh7757_cpu_clk_ops,
72}; 61};
73 62
74void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 63enum { DIV4_I, DIV4_SH, DIV4_P, DIV4_NR };
75{
76 if (idx < ARRAY_SIZE(sh7757_clk_ops))
77 *ops = sh7757_clk_ops[idx];
78}
79 64
80static void shyway_clk_recalc(struct clk *clk) 65#define DIV4(_bit, _mask, _flags) \
81{ 66 SH_CLK_DIV4(&pll_clk, FRQCR, _bit, _mask, _flags)
82 int idx = (__raw_readl(FRQCR) >> 12) & 0x0000000f;
83 clk->rate = clk->parent->rate / sfc_divisors[idx];
84}
85
86static struct clk_ops sh7757_shyway_clk_ops = {
87 .recalc = shyway_clk_recalc,
88};
89 67
90static struct clk sh7757_shyway_clk = { 68struct clk div4_clks[DIV4_NR] = {
91 .flags = CLK_ENABLE_ON_INIT, 69 /*
92 .ops = &sh7757_shyway_clk_ops, 70 * P clock is always enable, because some P clock modules is used
71 * by Host PC.
72 */
73 [DIV4_P] = DIV4(0, 0x2800, CLK_ENABLE_ON_INIT),
74 [DIV4_SH] = DIV4(12, 0x00a0, CLK_ENABLE_ON_INIT),
75 [DIV4_I] = DIV4(20, 0x0004, CLK_ENABLE_ON_INIT),
93}; 76};
94 77
95/* 78#define MSTPCR0 0xffc80030
96 * Additional sh7757-specific on-chip clocks that aren't already part of the 79#define MSTPCR1 0xffc80034
97 * clock framework 80
98 */ 81enum { MSTP004, MSTP000, MSTP114, MSTP113, MSTP112,
99static struct clk *sh7757_onchip_clocks[] = { 82 MSTP111, MSTP110, MSTP103, MSTP102,
100 &sh7757_shyway_clk, 83 MSTP_NR };
84
85static struct clk mstp_clks[MSTP_NR] = {
86 /* MSTPCR0 */
87 [MSTP004] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 4, 0),
88 [MSTP000] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 0, 0),
89
90 /* MSTPCR1 */
91 [MSTP114] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 14, 0),
92 [MSTP113] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 13, 0),
93 [MSTP112] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 12, 0),
94 [MSTP111] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 11, 0),
95 [MSTP110] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 10, 0),
96 [MSTP103] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 3, 0),
97 [MSTP102] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR1, 2, 0),
101}; 98};
102 99
103#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk } 100#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
104 101
105static struct clk_lookup lookups[] = { 102static struct clk_lookup lookups[] = {
106 /* main clocks */ 103 /* main clocks */
107 CLKDEV_CON_ID("shyway_clk", &sh7757_shyway_clk), 104 CLKDEV_CON_ID("extal", &extal_clk),
105 CLKDEV_CON_ID("pll_clk", &pll_clk),
106
107 /* DIV4 clocks */
108 CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
109 CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),
110 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
111
112 /* MSTP32 clocks */
113 CLKDEV_CON_ID("sdhi0", &mstp_clks[MSTP004]),
114 CLKDEV_CON_ID("riic", &mstp_clks[MSTP000]),
115 {
116 /* TMU0 */
117 .dev_id = "sh_tmu.0",
118 .con_id = "tmu_fck",
119 .clk = &mstp_clks[MSTP113],
120 }, {
121 /* TMU1 */
122 .dev_id = "sh_tmu.1",
123 .con_id = "tmu_fck",
124 .clk = &mstp_clks[MSTP114],
125 },
126 {
127 /* SCIF4 (But, ID is 2) */
128 .dev_id = "sh-sci.2",
129 .con_id = "sci_fck",
130 .clk = &mstp_clks[MSTP112],
131 }, {
132 /* SCIF3 */
133 .dev_id = "sh-sci.1",
134 .con_id = "sci_fck",
135 .clk = &mstp_clks[MSTP111],
136 }, {
137 /* SCIF2 */
138 .dev_id = "sh-sci.0",
139 .con_id = "sci_fck",
140 .clk = &mstp_clks[MSTP110],
141 },
142 CLKDEV_CON_ID("usb0", &mstp_clks[MSTP102]),
108}; 143};
109 144
110static int __init sh7757_clk_init(void) 145int __init arch_clk_init(void)
111{ 146{
112 struct clk *clk = clk_get(NULL, "master_clk"); 147 int i, ret = 0;
113 int i;
114
115 for (i = 0; i < ARRAY_SIZE(sh7757_onchip_clocks); i++) {
116 struct clk *clkp = sh7757_onchip_clocks[i];
117 148
118 clkp->parent = clk; 149 for (i = 0; i < ARRAY_SIZE(clks); i++)
119 clk_register(clkp); 150 ret |= clk_register(clks[i]);
120 clk_enable(clkp); 151 for (i = 0; i < ARRAY_SIZE(lookups); i++)
121 } 152 clkdev_add(&lookups[i]);
122 153
123 /* 154 if (!ret)
124 * Now that we have the rest of the clocks registered, we need to 155 ret = sh_clk_div4_register(div4_clks, ARRAY_SIZE(div4_clks),
125 * force the parent clock to propagate so that these clocks will 156 &div4_table);
126 * automatically figure out their rate. We cheat by handing the 157 if (!ret)
127 * parent clock its current rate and forcing child propagation. 158 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
128 */
129 clk_set_rate(clk, clk_get_rate(clk));
130 159
131 clk_put(clk); 160 return ret;
132
133 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
134
135 return 0;
136} 161}
137 162
138arch_initcall(sh7757_clk_init);
139
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index 236a6282d778..4f70df6b6169 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2006-2007 Renesas Technology Corp. 6 * Copyright (C) 2006-2007 Renesas Technology Corp.
7 * Copyright (C) 2006-2007 Renesas Solutions Corp. 7 * Copyright (C) 2006-2007 Renesas Solutions Corp.
8 * Copyright (C) 2006-2007 Paul Mundt 8 * Copyright (C) 2006-2010 Paul Mundt
9 * 9 *
10 * This file is subject to the terms and conditions of the GNU General Public 10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive 11 * License. See the file "COPYING" in the main directory of this archive
@@ -18,120 +18,179 @@
18#include <asm/clock.h> 18#include <asm/clock.h>
19#include <asm/freq.h> 19#include <asm/freq.h>
20 20
21static int ifc_divisors[] = { 1, 2, 4 ,6 }; 21/*
22static int bfc_divisors[] = { 1, 1, 1, 1, 1, 12, 16, 18, 24, 32, 36, 48 }; 22 * Default rate for the root input clock, reset this with clk_set_rate()
23static int pfc_divisors[] = { 1, 1, 1, 1, 1, 1, 1, 18, 24, 32, 36, 48 }; 23 * from the platform code.
24static int cfc_divisors[] = { 1, 1, 4, 6 }; 24 */
25 25static struct clk extal_clk = {
26#define IFC_POS 28 26 .rate = 16666666,
27#define IFC_MSK 0x0003
28#define BFC_MSK 0x000f
29#define PFC_MSK 0x000f
30#define CFC_MSK 0x0003
31#define BFC_POS 16
32#define PFC_POS 0
33#define CFC_POS 20
34
35static void master_clk_init(struct clk *clk)
36{
37 clk->rate *= pfc_divisors[(__raw_readl(FRQCR) >> PFC_POS) & PFC_MSK];
38}
39
40static struct clk_ops shx3_master_clk_ops = {
41 .init = master_clk_init,
42}; 27};
43 28
44static unsigned long module_clk_recalc(struct clk *clk) 29static unsigned long pll_recalc(struct clk *clk)
45{ 30{
46 int idx = ((__raw_readl(FRQCR) >> PFC_POS) & PFC_MSK); 31 /* PLL1 has a fixed x72 multiplier. */
47 return clk->parent->rate / pfc_divisors[idx]; 32 return clk->parent->rate * 72;
48} 33}
49 34
50static struct clk_ops shx3_module_clk_ops = { 35static struct clk_ops pll_clk_ops = {
51 .recalc = module_clk_recalc, 36 .recalc = pll_recalc,
52}; 37};
53 38
54static unsigned long bus_clk_recalc(struct clk *clk) 39static struct clk pll_clk = {
55{ 40 .ops = &pll_clk_ops,
56 int idx = ((__raw_readl(FRQCR) >> BFC_POS) & BFC_MSK); 41 .parent = &extal_clk,
57 return clk->parent->rate / bfc_divisors[idx]; 42 .flags = CLK_ENABLE_ON_INIT,
58} 43};
59 44
60static struct clk_ops shx3_bus_clk_ops = { 45static struct clk *clks[] = {
61 .recalc = bus_clk_recalc, 46 &extal_clk,
47 &pll_clk,
62}; 48};
63 49
64static unsigned long cpu_clk_recalc(struct clk *clk) 50static unsigned int div2[] = { 1, 2, 4, 6, 8, 12, 16, 18,
65{ 51 24, 32, 36, 48 };
66 int idx = ((__raw_readl(FRQCR) >> IFC_POS) & IFC_MSK);
67 return clk->parent->rate / ifc_divisors[idx];
68}
69 52
70static struct clk_ops shx3_cpu_clk_ops = { 53static struct clk_div_mult_table div4_div_mult_table = {
71 .recalc = cpu_clk_recalc, 54 .divisors = div2,
55 .nr_divisors = ARRAY_SIZE(div2),
72}; 56};
73 57
74static struct clk_ops *shx3_clk_ops[] = { 58static struct clk_div4_table div4_table = {
75 &shx3_master_clk_ops, 59 .div_mult_table = &div4_div_mult_table,
76 &shx3_module_clk_ops,
77 &shx3_bus_clk_ops,
78 &shx3_cpu_clk_ops,
79}; 60};
80 61
81void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 62enum { DIV4_I, DIV4_SH, DIV4_B, DIV4_DDR, DIV4_SHA, DIV4_P, DIV4_NR };
82{
83 if (idx < ARRAY_SIZE(shx3_clk_ops))
84 *ops = shx3_clk_ops[idx];
85}
86 63
87static unsigned long shyway_clk_recalc(struct clk *clk) 64#define DIV4(_bit, _mask, _flags) \
88{ 65 SH_CLK_DIV4(&pll_clk, FRQMR1, _bit, _mask, _flags)
89 int idx = ((__raw_readl(FRQCR) >> CFC_POS) & CFC_MSK);
90 return clk->parent->rate / cfc_divisors[idx];
91}
92 66
93static struct clk_ops shx3_shyway_clk_ops = { 67struct clk div4_clks[DIV4_NR] = {
94 .recalc = shyway_clk_recalc, 68 [DIV4_P] = DIV4(0, 0x0f80, 0),
69 [DIV4_SHA] = DIV4(4, 0x0ff0, 0),
70 [DIV4_DDR] = DIV4(12, 0x000c, CLK_ENABLE_ON_INIT),
71 [DIV4_B] = DIV4(16, 0x0fe0, CLK_ENABLE_ON_INIT),
72 [DIV4_SH] = DIV4(20, 0x000c, CLK_ENABLE_ON_INIT),
73 [DIV4_I] = DIV4(28, 0x000e, CLK_ENABLE_ON_INIT),
95}; 74};
96 75
97static struct clk shx3_shyway_clk = { 76#define MSTPCR0 0xffc00030
98 .flags = CLK_ENABLE_ON_INIT, 77#define MSTPCR1 0xffc00034
99 .ops = &shx3_shyway_clk_ops, 78
100}; 79enum { MSTP027, MSTP026, MSTP025, MSTP024,
101 80 MSTP009, MSTP008, MSTP003, MSTP002,
102/* 81 MSTP001, MSTP000, MSTP119, MSTP105,
103 * Additional SHx3-specific on-chip clocks that aren't already part of the 82 MSTP104, MSTP_NR };
104 * clock framework 83
105 */ 84static struct clk mstp_clks[MSTP_NR] = {
106static struct clk *shx3_onchip_clocks[] = { 85 /* MSTPCR0 */
107 &shx3_shyway_clk, 86 [MSTP027] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 27, 0),
87 [MSTP026] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 26, 0),
88 [MSTP025] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 25, 0),
89 [MSTP024] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 24, 0),
90 [MSTP009] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 9, 0),
91 [MSTP008] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 8, 0),
92 [MSTP003] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 3, 0),
93 [MSTP002] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 2, 0),
94 [MSTP001] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 1, 0),
95 [MSTP000] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 0, 0),
96
97 /* MSTPCR1 */
98 [MSTP119] = SH_CLK_MSTP32(NULL, MSTPCR1, 19, 0),
99 [MSTP105] = SH_CLK_MSTP32(NULL, MSTPCR1, 5, 0),
100 [MSTP104] = SH_CLK_MSTP32(NULL, MSTPCR1, 4, 0),
108}; 101};
109 102
110#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk } 103#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
111 104
112static struct clk_lookup lookups[] = { 105static struct clk_lookup lookups[] = {
113 /* main clocks */ 106 /* main clocks */
114 CLKDEV_CON_ID("shyway_clk", &shx3_shyway_clk), 107 CLKDEV_CON_ID("extal", &extal_clk),
108 CLKDEV_CON_ID("pll_clk", &pll_clk),
109
110 /* DIV4 clocks */
111 CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),
112 CLKDEV_CON_ID("shywaya_clk", &div4_clks[DIV4_SHA]),
113 CLKDEV_CON_ID("ddr_clk", &div4_clks[DIV4_DDR]),
114 CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]),
115 CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),
116 CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
117
118 /* MSTP32 clocks */
119 {
120 /* SCIF3 */
121 .dev_id = "sh-sci.3",
122 .con_id = "sci_fck",
123 .clk = &mstp_clks[MSTP027],
124 }, {
125 /* SCIF2 */
126 .dev_id = "sh-sci.2",
127 .con_id = "sci_fck",
128 .clk = &mstp_clks[MSTP026],
129 }, {
130 /* SCIF1 */
131 .dev_id = "sh-sci.1",
132 .con_id = "sci_fck",
133 .clk = &mstp_clks[MSTP025],
134 }, {
135 /* SCIF0 */
136 .dev_id = "sh-sci.0",
137 .con_id = "sci_fck",
138 .clk = &mstp_clks[MSTP024],
139 },
140 CLKDEV_CON_ID("h8ex_fck", &mstp_clks[MSTP003]),
141 CLKDEV_CON_ID("csm_fck", &mstp_clks[MSTP002]),
142 CLKDEV_CON_ID("fe1_fck", &mstp_clks[MSTP001]),
143 CLKDEV_CON_ID("fe0_fck", &mstp_clks[MSTP000]),
144 {
145 /* TMU0 */
146 .dev_id = "sh_tmu.0",
147 .con_id = "tmu_fck",
148 .clk = &mstp_clks[MSTP008],
149 }, {
150 /* TMU1 */
151 .dev_id = "sh_tmu.1",
152 .con_id = "tmu_fck",
153 .clk = &mstp_clks[MSTP008],
154 }, {
155 /* TMU2 */
156 .dev_id = "sh_tmu.2",
157 .con_id = "tmu_fck",
158 .clk = &mstp_clks[MSTP008],
159 }, {
160 /* TMU3 */
161 .dev_id = "sh_tmu.3",
162 .con_id = "tmu_fck",
163 .clk = &mstp_clks[MSTP009],
164 }, {
165 /* TMU4 */
166 .dev_id = "sh_tmu.4",
167 .con_id = "tmu_fck",
168 .clk = &mstp_clks[MSTP009],
169 }, {
170 /* TMU5 */
171 .dev_id = "sh_tmu.5",
172 .con_id = "tmu_fck",
173 .clk = &mstp_clks[MSTP009],
174 },
175 CLKDEV_CON_ID("hudi_fck", &mstp_clks[MSTP119]),
176 CLKDEV_CON_ID("dmac_11_6_fck", &mstp_clks[MSTP105]),
177 CLKDEV_CON_ID("dmac_5_0_fck", &mstp_clks[MSTP104]),
115}; 178};
116 179
117int __init arch_clk_init(void) 180int __init arch_clk_init(void)
118{ 181{
119 struct clk *clk;
120 int i, ret = 0; 182 int i, ret = 0;
121 183
122 cpg_clk_init(); 184 for (i = 0; i < ARRAY_SIZE(clks); i++)
123 185 ret |= clk_register(clks[i]);
124 clk = clk_get(NULL, "master_clk"); 186 for (i = 0; i < ARRAY_SIZE(lookups); i++)
125 for (i = 0; i < ARRAY_SIZE(shx3_onchip_clocks); i++) { 187 clkdev_add(&lookups[i]);
126 struct clk *clkp = shx3_onchip_clocks[i];
127
128 clkp->parent = clk;
129 ret |= clk_register(clkp);
130 }
131
132 clk_put(clk);
133 188
134 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 189 if (!ret)
190 ret = sh_clk_div4_register(div4_clks, ARRAY_SIZE(div4_clks),
191 &div4_table);
192 if (!ret)
193 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
135 194
136 return ret; 195 return ret;
137} 196}
diff --git a/arch/sh/kernel/cpu/sh4a/intc-shx3.c b/arch/sh/kernel/cpu/sh4a/intc-shx3.c
new file mode 100644
index 000000000000..78c971486b4e
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4a/intc-shx3.c
@@ -0,0 +1,34 @@
1/*
2 * Shared support for SH-X3 interrupt controllers.
3 *
4 * Copyright (C) 2009 - 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/irq.h>
11#include <linux/io.h>
12#include <linux/init.h>
13
14#define INTACK 0xfe4100b8
15#define INTACKCLR 0xfe4100bc
16#define INTC_USERIMASK 0xfe411000
17
18#ifdef CONFIG_INTC_BALANCING
19unsigned int irq_lookup(unsigned int irq)
20{
21 return __raw_readl(INTACK) & 1 ? irq : NO_IRQ_IGNORE;
22}
23
24void irq_finish(unsigned int irq)
25{
26 __raw_writel(irq2evt(irq), INTACKCLR);
27}
28#endif
29
30static int __init shx3_irq_setup(void)
31{
32 return register_intc_userimask(INTC_USERIMASK);
33}
34arch_initcall(shx3_irq_setup);
diff --git a/arch/sh/kernel/cpu/sh4a/perf_event.c b/arch/sh/kernel/cpu/sh4a/perf_event.c
index eddc21973fa1..b8b873d8d6b5 100644
--- a/arch/sh/kernel/cpu/sh4a/perf_event.c
+++ b/arch/sh/kernel/cpu/sh4a/perf_event.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Performance events support for SH-4A performance counters 2 * Performance events support for SH-4A performance counters
3 * 3 *
4 * Copyright (C) 2009 Paul Mundt 4 * Copyright (C) 2009, 2010 Paul Mundt
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
@@ -22,7 +22,25 @@
22#define CCBR_CMDS (1 << 1) 22#define CCBR_CMDS (1 << 1)
23#define CCBR_PPCE (1 << 0) 23#define CCBR_PPCE (1 << 0)
24 24
25#ifdef CONFIG_CPU_SHX3
26/*
27 * The PMCAT location for SH-X3 CPUs was quietly moved, while the CCBR
28 * and PMCTR locations remains tentatively constant. This change remains
29 * wholly undocumented, and was simply found through trial and error.
30 *
31 * Early cuts of SH-X3 still appear to use the SH-X/SH-X2 locations, and
32 * it's unclear when this ceased to be the case. For now we always use
33 * the new location (if future parts keep up with this trend then
34 * scanning for them at runtime also remains a viable option.)
35 *
36 * The gap in the register space also suggests that there are other
37 * undocumented counters, so this will need to be revisited at a later
38 * point in time.
39 */
40#define PPC_PMCAT 0xfc100240
41#else
25#define PPC_PMCAT 0xfc100080 42#define PPC_PMCAT 0xfc100080
43#endif
26 44
27#define PMCAT_OVF3 (1 << 27) 45#define PMCAT_OVF3 (1 << 27)
28#define PMCAT_CNN3 (1 << 26) 46#define PMCAT_CNN3 (1 << 26)
diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c b/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
index ed23b155c097..4c74bd04bba4 100644
--- a/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-sh7757.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * SH7757 (A0 step) Pinmux 2 * SH7757 (B0 step) Pinmux
3 * 3 *
4 * Copyright (C) 2009 Renesas Solutions Corp. 4 * Copyright (C) 2009-2010 Renesas Solutions Corp.
5 * 5 *
6 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> 6 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
7 * 7 *
8 * Based on SH7757 Pinmux 8 * Based on SH7723 Pinmux
9 * Copyright (C) 2008 Magnus Damm 9 * Copyright (C) 2008 Magnus Damm
10 * 10 *
11 * This file is subject to the terms and conditions of the GNU General Public 11 * This file is subject to the terms and conditions of the GNU General Public
@@ -40,27 +40,27 @@ enum {
40 PTH3_DATA, PTH2_DATA, PTH1_DATA, PTH0_DATA, 40 PTH3_DATA, PTH2_DATA, PTH1_DATA, PTH0_DATA,
41 PTI7_DATA, PTI6_DATA, PTI5_DATA, PTI4_DATA, 41 PTI7_DATA, PTI6_DATA, PTI5_DATA, PTI4_DATA,
42 PTI3_DATA, PTI2_DATA, PTI1_DATA, PTI0_DATA, 42 PTI3_DATA, PTI2_DATA, PTI1_DATA, PTI0_DATA,
43 PTJ7_DATA, PTJ6_DATA, PTJ5_DATA, PTJ4_DATA, 43 PTJ6_DATA, PTJ5_DATA, PTJ4_DATA,
44 PTJ3_DATA, PTJ2_DATA, PTJ1_DATA, PTJ0_DATA, 44 PTJ3_DATA, PTJ2_DATA, PTJ1_DATA, PTJ0_DATA,
45 PTK7_DATA, PTK6_DATA, PTK5_DATA, PTK4_DATA, 45 PTK7_DATA, PTK6_DATA, PTK5_DATA, PTK4_DATA,
46 PTK3_DATA, PTK2_DATA, PTK1_DATA, PTK0_DATA, 46 PTK3_DATA, PTK2_DATA, PTK1_DATA, PTK0_DATA,
47 PTL7_DATA, PTL6_DATA, PTL5_DATA, PTL4_DATA, 47 PTL6_DATA, PTL5_DATA, PTL4_DATA,
48 PTL3_DATA, PTL2_DATA, PTL1_DATA, PTL0_DATA, 48 PTL3_DATA, PTL2_DATA, PTL1_DATA, PTL0_DATA,
49 PTM6_DATA, PTM5_DATA, PTM4_DATA, 49 PTM7_DATA, PTM6_DATA, PTM5_DATA, PTM4_DATA,
50 PTM3_DATA, PTM2_DATA, PTM1_DATA, PTM0_DATA, 50 PTM3_DATA, PTM2_DATA, PTM1_DATA, PTM0_DATA,
51 PTN7_DATA, PTN6_DATA, PTN5_DATA, PTN4_DATA, 51 PTN6_DATA, PTN5_DATA, PTN4_DATA,
52 PTN3_DATA, PTN2_DATA, PTN1_DATA, PTN0_DATA, 52 PTN3_DATA, PTN2_DATA, PTN1_DATA, PTN0_DATA,
53 PTO7_DATA, PTO6_DATA, PTO5_DATA, PTO4_DATA, 53 PTO7_DATA, PTO6_DATA, PTO5_DATA, PTO4_DATA,
54 PTO3_DATA, PTO2_DATA, PTO1_DATA, PTO0_DATA, 54 PTO3_DATA, PTO2_DATA, PTO1_DATA, PTO0_DATA,
55 PTP6_DATA, PTP5_DATA, PTP4_DATA, 55 PTP7_DATA, PTP6_DATA, PTP5_DATA, PTP4_DATA,
56 PTP3_DATA, PTP2_DATA, PTP1_DATA, PTP0_DATA, 56 PTP3_DATA, PTP2_DATA, PTP1_DATA, PTP0_DATA,
57 PTQ6_DATA, PTQ5_DATA, PTQ4_DATA, 57 PTQ6_DATA, PTQ5_DATA, PTQ4_DATA,
58 PTQ3_DATA, PTQ2_DATA, PTQ1_DATA, PTQ0_DATA, 58 PTQ3_DATA, PTQ2_DATA, PTQ1_DATA, PTQ0_DATA,
59 PTR7_DATA, PTR6_DATA, PTR5_DATA, PTR4_DATA, 59 PTR7_DATA, PTR6_DATA, PTR5_DATA, PTR4_DATA,
60 PTR3_DATA, PTR2_DATA, PTR1_DATA, PTR0_DATA, 60 PTR3_DATA, PTR2_DATA, PTR1_DATA, PTR0_DATA,
61 PTS7_DATA, PTS6_DATA, PTS5_DATA, PTS4_DATA, 61 PTS7_DATA, PTS6_DATA, PTS5_DATA, PTS4_DATA,
62 PTS3_DATA, PTS2_DATA, PTS1_DATA, PTS0_DATA, 62 PTS3_DATA, PTS2_DATA, PTS1_DATA, PTS0_DATA,
63 PTT5_DATA, PTT4_DATA, 63 PTT7_DATA, PTT6_DATA, PTT5_DATA, PTT4_DATA,
64 PTT3_DATA, PTT2_DATA, PTT1_DATA, PTT0_DATA, 64 PTT3_DATA, PTT2_DATA, PTT1_DATA, PTT0_DATA,
65 PTU7_DATA, PTU6_DATA, PTU5_DATA, PTU4_DATA, 65 PTU7_DATA, PTU6_DATA, PTU5_DATA, PTU4_DATA,
66 PTU3_DATA, PTU2_DATA, PTU1_DATA, PTU0_DATA, 66 PTU3_DATA, PTU2_DATA, PTU1_DATA, PTU0_DATA,
@@ -95,27 +95,27 @@ enum {
95 PTH3_IN, PTH2_IN, PTH1_IN, PTH0_IN, 95 PTH3_IN, PTH2_IN, PTH1_IN, PTH0_IN,
96 PTI7_IN, PTI6_IN, PTI5_IN, PTI4_IN, 96 PTI7_IN, PTI6_IN, PTI5_IN, PTI4_IN,
97 PTI3_IN, PTI2_IN, PTI1_IN, PTI0_IN, 97 PTI3_IN, PTI2_IN, PTI1_IN, PTI0_IN,
98 PTJ7_IN, PTJ6_IN, PTJ5_IN, PTJ4_IN, 98 PTJ6_IN, PTJ5_IN, PTJ4_IN,
99 PTJ3_IN, PTJ2_IN, PTJ1_IN, PTJ0_IN, 99 PTJ3_IN, PTJ2_IN, PTJ1_IN, PTJ0_IN,
100 PTK7_IN, PTK6_IN, PTK5_IN, PTK4_IN, 100 PTK7_IN, PTK6_IN, PTK5_IN, PTK4_IN,
101 PTK3_IN, PTK2_IN, PTK1_IN, PTK0_IN, 101 PTK3_IN, PTK2_IN, PTK1_IN, PTK0_IN,
102 PTL7_IN, PTL6_IN, PTL5_IN, PTL4_IN, 102 PTL6_IN, PTL5_IN, PTL4_IN,
103 PTL3_IN, PTL2_IN, PTL1_IN, PTL0_IN, 103 PTL3_IN, PTL2_IN, PTL1_IN, PTL0_IN,
104 PTM6_IN, PTM5_IN, PTM4_IN, 104 PTM7_IN, PTM6_IN, PTM5_IN, PTM4_IN,
105 PTM3_IN, PTM2_IN, PTM1_IN, PTM0_IN, 105 PTM3_IN, PTM2_IN, PTM1_IN, PTM0_IN,
106 PTN7_IN, PTN6_IN, PTN5_IN, PTN4_IN, 106 PTN6_IN, PTN5_IN, PTN4_IN,
107 PTN3_IN, PTN2_IN, PTN1_IN, PTN0_IN, 107 PTN3_IN, PTN2_IN, PTN1_IN, PTN0_IN,
108 PTO7_IN, PTO6_IN, PTO5_IN, PTO4_IN, 108 PTO7_IN, PTO6_IN, PTO5_IN, PTO4_IN,
109 PTO3_IN, PTO2_IN, PTO1_IN, PTO0_IN, 109 PTO3_IN, PTO2_IN, PTO1_IN, PTO0_IN,
110 PTP6_IN, PTP5_IN, PTP4_IN, 110 PTP7_IN, PTP6_IN, PTP5_IN, PTP4_IN,
111 PTP3_IN, PTP2_IN, PTP1_IN, PTP0_IN, 111 PTP3_IN, PTP2_IN, PTP1_IN, PTP0_IN,
112 PTQ6_IN, PTQ5_IN, PTQ4_IN, 112 PTQ6_IN, PTQ5_IN, PTQ4_IN,
113 PTQ3_IN, PTQ2_IN, PTQ1_IN, PTQ0_IN, 113 PTQ3_IN, PTQ2_IN, PTQ1_IN, PTQ0_IN,
114 PTR7_IN, PTR6_IN, PTR5_IN, PTR4_IN, 114 PTR7_IN, PTR6_IN, PTR5_IN, PTR4_IN,
115 PTR3_IN, PTR2_IN, PTR1_IN, PTR0_IN, 115 PTR3_IN, PTR2_IN, PTR1_IN, PTR0_IN,
116 PTS7_IN, PTS6_IN, PTS5_IN, PTS4_IN, 116 PTS7_IN, PTS6_IN, PTS5_IN, PTS4_IN,
117 PTS3_IN, PTS2_IN, PTS1_IN, PTS0_IN, 117 PTS3_IN, PTS2_IN, PTS1_IN, PTS0_IN,
118 PTT5_IN, PTT4_IN, 118 PTT7_IN, PTT6_IN, PTT5_IN, PTT4_IN,
119 PTT3_IN, PTT2_IN, PTT1_IN, PTT0_IN, 119 PTT3_IN, PTT2_IN, PTT1_IN, PTT0_IN,
120 PTU7_IN, PTU6_IN, PTU5_IN, PTU4_IN, 120 PTU7_IN, PTU6_IN, PTU5_IN, PTU4_IN,
121 PTU3_IN, PTU2_IN, PTU1_IN, PTU0_IN, 121 PTU3_IN, PTU2_IN, PTU1_IN, PTU0_IN,
@@ -132,16 +132,43 @@ enum {
132 PINMUX_INPUT_END, 132 PINMUX_INPUT_END,
133 133
134 PINMUX_INPUT_PULLUP_BEGIN, 134 PINMUX_INPUT_PULLUP_BEGIN,
135 PTA7_IN_PU, PTA6_IN_PU, PTA5_IN_PU, PTA4_IN_PU,
136 PTA3_IN_PU, PTA2_IN_PU, PTA1_IN_PU, PTA0_IN_PU,
137 PTD7_IN_PU, PTD6_IN_PU, PTD5_IN_PU, PTD4_IN_PU,
138 PTD3_IN_PU, PTD2_IN_PU, PTD1_IN_PU, PTD0_IN_PU,
139 PTE7_IN_PU, PTE6_IN_PU, PTE5_IN_PU, PTE4_IN_PU,
140 PTE3_IN_PU, PTE2_IN_PU, PTE1_IN_PU, PTE0_IN_PU,
141 PTF7_IN_PU, PTF6_IN_PU, PTF5_IN_PU, PTF4_IN_PU,
142 PTF3_IN_PU, PTF2_IN_PU, PTF1_IN_PU, PTF0_IN_PU,
143 PTG7_IN_PU, PTG6_IN_PU, PTG4_IN_PU,
144 PTH7_IN_PU, PTH6_IN_PU, PTH5_IN_PU, PTH4_IN_PU,
145 PTH3_IN_PU, PTH2_IN_PU, PTH1_IN_PU, PTH0_IN_PU,
146 PTI7_IN_PU, PTI6_IN_PU, PTI4_IN_PU,
147 PTI3_IN_PU, PTI2_IN_PU, PTI1_IN_PU, PTI0_IN_PU,
148 PTJ6_IN_PU, PTJ5_IN_PU, PTJ4_IN_PU,
149 PTJ3_IN_PU, PTJ2_IN_PU, PTJ1_IN_PU, PTJ0_IN_PU,
150 PTK7_IN_PU, PTK6_IN_PU, PTK5_IN_PU, PTK4_IN_PU,
151 PTK3_IN_PU, PTK2_IN_PU, PTK1_IN_PU, PTK0_IN_PU,
152 PTL6_IN_PU, PTL5_IN_PU, PTL4_IN_PU,
153 PTL3_IN_PU, PTL2_IN_PU, PTL1_IN_PU, PTL0_IN_PU,
154 PTM7_IN_PU, PTM6_IN_PU, PTM5_IN_PU, PTM4_IN_PU,
155 PTN4_IN_PU,
156 PTN3_IN_PU, PTN2_IN_PU, PTN1_IN_PU, PTN0_IN_PU,
157 PTO7_IN_PU, PTO6_IN_PU, PTO5_IN_PU, PTO4_IN_PU,
158 PTO3_IN_PU, PTO2_IN_PU, PTO1_IN_PU, PTO0_IN_PU,
159 PTT7_IN_PU, PTT6_IN_PU, PTT5_IN_PU, PTT4_IN_PU,
160 PTT3_IN_PU, PTT2_IN_PU, PTT1_IN_PU, PTT0_IN_PU,
135 PTU7_IN_PU, PTU6_IN_PU, PTU5_IN_PU, PTU4_IN_PU, 161 PTU7_IN_PU, PTU6_IN_PU, PTU5_IN_PU, PTU4_IN_PU,
136 PTU3_IN_PU, PTU2_IN_PU, PTU1_IN_PU, PTU0_IN_PU, 162 PTU3_IN_PU, PTU2_IN_PU, PTU1_IN_PU, PTU0_IN_PU,
137 PTV7_IN_PU, PTV6_IN_PU, PTV5_IN_PU, PTV4_IN_PU, 163 PTV7_IN_PU, PTV6_IN_PU, PTV5_IN_PU, PTV4_IN_PU,
138 PTV3_IN_PU, PTV2_IN_PU, PTV1_IN_PU, PTV0_IN_PU, 164 PTV3_IN_PU, PTV2_IN_PU,
139 PTW7_IN_PU, PTW6_IN_PU, PTW5_IN_PU, PTW4_IN_PU, 165 PTW1_IN_PU, PTW0_IN_PU,
140 PTW3_IN_PU, PTW2_IN_PU, PTW1_IN_PU, PTW0_IN_PU,
141 PTX7_IN_PU, PTX6_IN_PU, PTX5_IN_PU, PTX4_IN_PU, 166 PTX7_IN_PU, PTX6_IN_PU, PTX5_IN_PU, PTX4_IN_PU,
142 PTX3_IN_PU, PTX2_IN_PU, PTX1_IN_PU, PTX0_IN_PU, 167 PTX3_IN_PU, PTX2_IN_PU, PTX1_IN_PU, PTX0_IN_PU,
143 PTY7_IN_PU, PTY6_IN_PU, PTY5_IN_PU, PTY4_IN_PU, 168 PTY7_IN_PU, PTY6_IN_PU, PTY5_IN_PU, PTY4_IN_PU,
144 PTY3_IN_PU, PTY2_IN_PU, PTY1_IN_PU, PTY0_IN_PU, 169 PTY3_IN_PU, PTY2_IN_PU, PTY1_IN_PU, PTY0_IN_PU,
170 PTZ7_IN_PU, PTZ6_IN_PU, PTZ5_IN_PU, PTZ4_IN_PU,
171 PTZ3_IN_PU, PTZ2_IN_PU, PTZ1_IN_PU, PTZ0_IN_PU,
145 PINMUX_INPUT_PULLUP_END, 172 PINMUX_INPUT_PULLUP_END,
146 173
147 PINMUX_OUTPUT_BEGIN, 174 PINMUX_OUTPUT_BEGIN,
@@ -163,27 +190,27 @@ enum {
163 PTH3_OUT, PTH2_OUT, PTH1_OUT, PTH0_OUT, 190 PTH3_OUT, PTH2_OUT, PTH1_OUT, PTH0_OUT,
164 PTI7_OUT, PTI6_OUT, PTI5_OUT, PTI4_OUT, 191 PTI7_OUT, PTI6_OUT, PTI5_OUT, PTI4_OUT,
165 PTI3_OUT, PTI2_OUT, PTI1_OUT, PTI0_OUT, 192 PTI3_OUT, PTI2_OUT, PTI1_OUT, PTI0_OUT,
166 PTJ7_OUT, PTJ6_OUT, PTJ5_OUT, PTJ4_OUT, 193 PTJ6_OUT, PTJ5_OUT, PTJ4_OUT,
167 PTJ3_OUT, PTJ2_OUT, PTJ1_OUT, PTJ0_OUT, 194 PTJ3_OUT, PTJ2_OUT, PTJ1_OUT, PTJ0_OUT,
168 PTK7_OUT, PTK6_OUT, PTK5_OUT, PTK4_OUT, 195 PTK7_OUT, PTK6_OUT, PTK5_OUT, PTK4_OUT,
169 PTK3_OUT, PTK2_OUT, PTK1_OUT, PTK0_OUT, 196 PTK3_OUT, PTK2_OUT, PTK1_OUT, PTK0_OUT,
170 PTL7_OUT, PTL6_OUT, PTL5_OUT, PTL4_OUT, 197 PTL6_OUT, PTL5_OUT, PTL4_OUT,
171 PTL3_OUT, PTL2_OUT, PTL1_OUT, PTL0_OUT, 198 PTL3_OUT, PTL2_OUT, PTL1_OUT, PTL0_OUT,
172 PTM6_OUT, PTM5_OUT, PTM4_OUT, 199 PTM7_OUT, PTM6_OUT, PTM5_OUT, PTM4_OUT,
173 PTM3_OUT, PTM2_OUT, PTM1_OUT, PTM0_OUT, 200 PTM3_OUT, PTM2_OUT, PTM1_OUT, PTM0_OUT,
174 PTN7_OUT, PTN6_OUT, PTN5_OUT, PTN4_OUT, 201 PTN6_OUT, PTN5_OUT, PTN4_OUT,
175 PTN3_OUT, PTN2_OUT, PTN1_OUT, PTN0_OUT, 202 PTN3_OUT, PTN2_OUT, PTN1_OUT, PTN0_OUT,
176 PTO7_OUT, PTO6_OUT, PTO5_OUT, PTO4_OUT, 203 PTO7_OUT, PTO6_OUT, PTO5_OUT, PTO4_OUT,
177 PTO3_OUT, PTO2_OUT, PTO1_OUT, PTO0_OUT, 204 PTO3_OUT, PTO2_OUT, PTO1_OUT, PTO0_OUT,
178 PTP6_OUT, PTP5_OUT, PTP4_OUT, 205 PTP7_OUT, PTP6_OUT, PTP5_OUT, PTP4_OUT,
179 PTP3_OUT, PTP2_OUT, PTP1_OUT, PTP0_OUT, 206 PTP3_OUT, PTP2_OUT, PTP1_OUT, PTP0_OUT,
180 PTQ6_OUT, PTQ5_OUT, PTQ4_OUT, 207 PTQ6_OUT, PTQ5_OUT, PTQ4_OUT,
181 PTQ3_OUT, PTQ2_OUT, PTQ1_OUT, PTQ0_OUT, 208 PTQ3_OUT, PTQ2_OUT, PTQ1_OUT, PTQ0_OUT,
182 PTR7_OUT, PTR6_OUT, PTR5_OUT, PTR4_OUT, 209 PTR7_OUT, PTR6_OUT, PTR5_OUT, PTR4_OUT,
183 PTR3_OUT, PTR2_OUT, PTR1_OUT, PTR0_OUT, 210 PTR3_OUT, PTR2_OUT, PTR1_OUT, PTR0_OUT,
184 PTS7_OUT, PTS6_OUT, PTS5_OUT, PTS4_OUT, 211 PTS7_OUT, PTS6_OUT, PTS5_OUT, PTS4_OUT,
185 PTS3_OUT, PTS2_OUT, PTS1_OUT, PTS0_OUT, 212 PTS3_OUT, PTS2_OUT, PTS1_OUT, PTS0_OUT,
186 PTT5_OUT, PTT4_OUT, 213 PTT7_OUT, PTT6_OUT, PTT5_OUT, PTT4_OUT,
187 PTT3_OUT, PTT2_OUT, PTT1_OUT, PTT0_OUT, 214 PTT3_OUT, PTT2_OUT, PTT1_OUT, PTT0_OUT,
188 PTU7_OUT, PTU6_OUT, PTU5_OUT, PTU4_OUT, 215 PTU7_OUT, PTU6_OUT, PTU5_OUT, PTU4_OUT,
189 PTU3_OUT, PTU2_OUT, PTU1_OUT, PTU0_OUT, 216 PTU3_OUT, PTU2_OUT, PTU1_OUT, PTU0_OUT,
@@ -218,27 +245,27 @@ enum {
218 PTH3_FN, PTH2_FN, PTH1_FN, PTH0_FN, 245 PTH3_FN, PTH2_FN, PTH1_FN, PTH0_FN,
219 PTI7_FN, PTI6_FN, PTI5_FN, PTI4_FN, 246 PTI7_FN, PTI6_FN, PTI5_FN, PTI4_FN,
220 PTI3_FN, PTI2_FN, PTI1_FN, PTI0_FN, 247 PTI3_FN, PTI2_FN, PTI1_FN, PTI0_FN,
221 PTJ7_FN, PTJ6_FN, PTJ5_FN, PTJ4_FN, 248 PTJ6_FN, PTJ5_FN, PTJ4_FN,
222 PTJ3_FN, PTJ2_FN, PTJ1_FN, PTJ0_FN, 249 PTJ3_FN, PTJ2_FN, PTJ1_FN, PTJ0_FN,
223 PTK7_FN, PTK6_FN, PTK5_FN, PTK4_FN, 250 PTK7_FN, PTK6_FN, PTK5_FN, PTK4_FN,
224 PTK3_FN, PTK2_FN, PTK1_FN, PTK0_FN, 251 PTK3_FN, PTK2_FN, PTK1_FN, PTK0_FN,
225 PTL7_FN, PTL6_FN, PTL5_FN, PTL4_FN, 252 PTL6_FN, PTL5_FN, PTL4_FN,
226 PTL3_FN, PTL2_FN, PTL1_FN, PTL0_FN, 253 PTL3_FN, PTL2_FN, PTL1_FN, PTL0_FN,
227 PTM6_FN, PTM5_FN, PTM4_FN, 254 PTM7_FN, PTM6_FN, PTM5_FN, PTM4_FN,
228 PTM3_FN, PTM2_FN, PTM1_FN, PTM0_FN, 255 PTM3_FN, PTM2_FN, PTM1_FN, PTM0_FN,
229 PTN7_FN, PTN6_FN, PTN5_FN, PTN4_FN, 256 PTN6_FN, PTN5_FN, PTN4_FN,
230 PTN3_FN, PTN2_FN, PTN1_FN, PTN0_FN, 257 PTN3_FN, PTN2_FN, PTN1_FN, PTN0_FN,
231 PTO7_FN, PTO6_FN, PTO5_FN, PTO4_FN, 258 PTO7_FN, PTO6_FN, PTO5_FN, PTO4_FN,
232 PTO3_FN, PTO2_FN, PTO1_FN, PTO0_FN, 259 PTO3_FN, PTO2_FN, PTO1_FN, PTO0_FN,
233 PTP6_FN, PTP5_FN, PTP4_FN, 260 PTP7_FN, PTP6_FN, PTP5_FN, PTP4_FN,
234 PTP3_FN, PTP2_FN, PTP1_FN, PTP0_FN, 261 PTP3_FN, PTP2_FN, PTP1_FN, PTP0_FN,
235 PTQ6_FN, PTQ5_FN, PTQ4_FN, 262 PTQ6_FN, PTQ5_FN, PTQ4_FN,
236 PTQ3_FN, PTQ2_FN, PTQ1_FN, PTQ0_FN, 263 PTQ3_FN, PTQ2_FN, PTQ1_FN, PTQ0_FN,
237 PTR7_FN, PTR6_FN, PTR5_FN, PTR4_FN, 264 PTR7_FN, PTR6_FN, PTR5_FN, PTR4_FN,
238 PTR3_FN, PTR2_FN, PTR1_FN, PTR0_FN, 265 PTR3_FN, PTR2_FN, PTR1_FN, PTR0_FN,
239 PTS7_FN, PTS6_FN, PTS5_FN, PTS4_FN, 266 PTS7_FN, PTS6_FN, PTS5_FN, PTS4_FN,
240 PTS3_FN, PTS2_FN, PTS1_FN, PTS0_FN, 267 PTS3_FN, PTS2_FN, PTS1_FN, PTS0_FN,
241 PTT5_FN, PTT4_FN, 268 PTT7_FN, PTT6_FN, PTT5_FN, PTT4_FN,
242 PTT3_FN, PTT2_FN, PTT1_FN, PTT0_FN, 269 PTT3_FN, PTT2_FN, PTT1_FN, PTT0_FN,
243 PTU7_FN, PTU6_FN, PTU5_FN, PTU4_FN, 270 PTU7_FN, PTU6_FN, PTU5_FN, PTU4_FN,
244 PTU3_FN, PTU2_FN, PTU1_FN, PTU0_FN, 271 PTU3_FN, PTU2_FN, PTU1_FN, PTU0_FN,
@@ -253,181 +280,248 @@ enum {
253 PTZ7_FN, PTZ6_FN, PTZ5_FN, PTZ4_FN, 280 PTZ7_FN, PTZ6_FN, PTZ5_FN, PTZ4_FN,
254 PTZ3_FN, PTZ2_FN, PTZ1_FN, PTZ0_FN, 281 PTZ3_FN, PTZ2_FN, PTZ1_FN, PTZ0_FN,
255 282
256 PS0_15_FN1, PS0_15_FN3, 283 PS0_15_FN1, PS0_15_FN2,
257 PS0_14_FN1, PS0_14_FN3, 284 PS0_14_FN1, PS0_14_FN2,
258 PS0_13_FN1, PS0_13_FN3, 285 PS0_13_FN1, PS0_13_FN2,
259 PS0_12_FN1, PS0_12_FN3, 286 PS0_12_FN1, PS0_12_FN2,
287 PS0_11_FN1, PS0_11_FN2,
288 PS0_10_FN1, PS0_10_FN2,
289 PS0_9_FN1, PS0_9_FN2,
290 PS0_8_FN1, PS0_8_FN2,
260 PS0_7_FN1, PS0_7_FN2, 291 PS0_7_FN1, PS0_7_FN2,
261 PS0_6_FN1, PS0_6_FN2, 292 PS0_6_FN1, PS0_6_FN2,
262 PS0_5_FN1, PS0_5_FN2, 293 PS0_5_FN1, PS0_5_FN2,
263 PS0_4_FN1, PS0_4_FN2, 294 PS0_4_FN1, PS0_4_FN2,
264 PS0_3_FN1, PS0_3_FN2, 295 PS0_3_FN1, PS0_3_FN2,
265 PS0_2_FN1, PS0_2_FN2, 296 PS0_2_FN1, PS0_2_FN2,
266 PS0_1_FN1, PS0_1_FN2,
267 297
268 PS1_7_FN1, PS1_7_FN3, 298 PS1_10_FN1, PS1_10_FN2,
269 PS1_6_FN1, PS1_6_FN3, 299 PS1_9_FN1, PS1_9_FN2,
300 PS1_8_FN1, PS1_8_FN2,
301 PS1_2_FN1, PS1_2_FN2,
302
303 PS2_13_FN1, PS2_13_FN2,
304 PS2_12_FN1, PS2_12_FN2,
305 PS2_7_FN1, PS2_7_FN2,
306 PS2_6_FN1, PS2_6_FN2,
307 PS2_5_FN1, PS2_5_FN2,
308 PS2_4_FN1, PS2_4_FN2,
309 PS2_2_FN1, PS2_2_FN2,
310
311 PS3_15_FN1, PS3_15_FN2,
312 PS3_14_FN1, PS3_14_FN2,
313 PS3_13_FN1, PS3_13_FN2,
314 PS3_12_FN1, PS3_12_FN2,
315 PS3_11_FN1, PS3_11_FN2,
316 PS3_10_FN1, PS3_10_FN2,
317 PS3_9_FN1, PS3_9_FN2,
318 PS3_8_FN1, PS3_8_FN2,
319 PS3_7_FN1, PS3_7_FN2,
320 PS3_2_FN1, PS3_2_FN2,
321 PS3_1_FN1, PS3_1_FN2,
270 322
271 PS2_13_FN1, PS2_13_FN3,
272 PS2_12_FN1, PS2_12_FN3,
273 PS2_1_FN1, PS2_1_FN2,
274 PS2_0_FN1, PS2_0_FN2,
275
276 PS4_15_FN1, PS4_15_FN2,
277 PS4_14_FN1, PS4_14_FN2, 323 PS4_14_FN1, PS4_14_FN2,
278 PS4_13_FN1, PS4_13_FN2, 324 PS4_13_FN1, PS4_13_FN2,
279 PS4_12_FN1, PS4_12_FN2, 325 PS4_12_FN1, PS4_12_FN2,
280 PS4_11_FN1, PS4_11_FN2,
281 PS4_10_FN1, PS4_10_FN2, 326 PS4_10_FN1, PS4_10_FN2,
282 PS4_9_FN1, PS4_9_FN2, 327 PS4_9_FN1, PS4_9_FN2,
328 PS4_8_FN1, PS4_8_FN2,
329 PS4_4_FN1, PS4_4_FN2,
283 PS4_3_FN1, PS4_3_FN2, 330 PS4_3_FN1, PS4_3_FN2,
284 PS4_2_FN1, PS4_2_FN2, 331 PS4_2_FN1, PS4_2_FN2,
285 PS4_1_FN1, PS4_1_FN2, 332 PS4_1_FN1, PS4_1_FN2,
286 PS4_0_FN1, PS4_0_FN2, 333 PS4_0_FN1, PS4_0_FN2,
287 334
335 PS5_11_FN1, PS5_11_FN2,
336 PS5_10_FN1, PS5_10_FN2,
288 PS5_9_FN1, PS5_9_FN2, 337 PS5_9_FN1, PS5_9_FN2,
289 PS5_8_FN1, PS5_8_FN2, 338 PS5_8_FN1, PS5_8_FN2,
290 PS5_7_FN1, PS5_7_FN2, 339 PS5_7_FN1, PS5_7_FN2,
291 PS5_6_FN1, PS5_6_FN2, 340 PS5_6_FN1, PS5_6_FN2,
292 PS5_5_FN1, PS5_5_FN2, 341 PS5_5_FN1, PS5_5_FN2,
293 PS5_4_FN1, PS5_4_FN2, 342 PS5_4_FN1, PS5_4_FN2,
294 343 PS5_3_FN1, PS5_3_FN2,
295 /* AN15 to 8 : EVENT15 to 8 */ 344 PS5_2_FN1, PS5_2_FN2,
296 PS6_7_FN_AN, PS6_7_FN_EV, 345
297 PS6_6_FN_AN, PS6_6_FN_EV, 346 PS6_15_FN1, PS6_15_FN2,
298 PS6_5_FN_AN, PS6_5_FN_EV, 347 PS6_14_FN1, PS6_14_FN2,
299 PS6_4_FN_AN, PS6_4_FN_EV, 348 PS6_13_FN1, PS6_13_FN2,
300 PS6_3_FN_AN, PS6_3_FN_EV, 349 PS6_12_FN1, PS6_12_FN2,
301 PS6_2_FN_AN, PS6_2_FN_EV, 350 PS6_11_FN1, PS6_11_FN2,
302 PS6_1_FN_AN, PS6_1_FN_EV, 351 PS6_10_FN1, PS6_10_FN2,
303 PS6_0_FN_AN, PS6_0_FN_EV, 352 PS6_9_FN1, PS6_9_FN2,
304 353 PS6_8_FN1, PS6_8_FN2,
354 PS6_7_FN1, PS6_7_FN2,
355 PS6_6_FN1, PS6_6_FN2,
356 PS6_5_FN1, PS6_5_FN2,
357 PS6_4_FN1, PS6_4_FN2,
358 PS6_3_FN1, PS6_3_FN2,
359 PS6_2_FN1, PS6_2_FN2,
360 PS6_1_FN1, PS6_1_FN2,
361 PS6_0_FN1, PS6_0_FN2,
362
363 PS7_15_FN1, PS7_15_FN2,
364 PS7_14_FN1, PS7_14_FN2,
365 PS7_13_FN1, PS7_13_FN2,
366 PS7_12_FN1, PS7_12_FN2,
367 PS7_11_FN1, PS7_11_FN2,
368 PS7_10_FN1, PS7_10_FN2,
369 PS7_9_FN1, PS7_9_FN2,
370 PS7_8_FN1, PS7_8_FN2,
371 PS7_7_FN1, PS7_7_FN2,
372 PS7_6_FN1, PS7_6_FN2,
373 PS7_5_FN1, PS7_5_FN2,
374 PS7_4_FN1, PS7_4_FN2,
375
376 PS8_15_FN1, PS8_15_FN2,
377 PS8_14_FN1, PS8_14_FN2,
378 PS8_13_FN1, PS8_13_FN2,
379 PS8_12_FN1, PS8_12_FN2,
380 PS8_11_FN1, PS8_11_FN2,
381 PS8_10_FN1, PS8_10_FN2,
382 PS8_9_FN1, PS8_9_FN2,
383 PS8_8_FN1, PS8_8_FN2,
305 PINMUX_FUNCTION_END, 384 PINMUX_FUNCTION_END,
306 385
307 PINMUX_MARK_BEGIN, 386 PINMUX_MARK_BEGIN,
308 /* PTA (mobule: LBSC, CPG, LPC) */ 387 /* PTA (mobule: LBSC, RGMII) */
309 BS_MARK, RDWR_MARK, WE1_MARK, RDY_MARK, 388 BS_MARK, RDWR_MARK, WE1_MARK, RDY_MARK,
310 MD10_MARK, MD9_MARK, MD8_MARK,
311 LGPIO7_MARK, LGPIO6_MARK, LGPIO5_MARK, LGPIO4_MARK,
312 LGPIO3_MARK, LGPIO2_MARK, LGPIO1_MARK, LGPIO0_MARK,
313
314 /* PTB (mobule: LBSC, EtherC, SIM, LPC) */
315 D15_MARK, D14_MARK, D13_MARK, D12_MARK,
316 D11_MARK, D10_MARK, D9_MARK, D8_MARK,
317 ET0_MDC_MARK, ET0_MDIO_MARK, ET1_MDC_MARK, ET1_MDIO_MARK, 389 ET0_MDC_MARK, ET0_MDIO_MARK, ET1_MDC_MARK, ET1_MDIO_MARK,
318 SIM_D_MARK, SIM_CLK_MARK, SIM_RST_MARK,
319 WPSZ1_MARK, WPSZ0_MARK, FWID_MARK, FLSHSZ_MARK,
320 LPC_SPIEN_MARK, BASEL_MARK,
321 390
322 /* PTC (mobule: SD) */ 391 /* PTB (mobule: INTC, ONFI, TMU) */
323 SD_WP_MARK, SD_CD_MARK, SD_CLK_MARK, SD_CMD_MARK, 392 IRQ15_MARK, IRQ14_MARK, IRQ13_MARK, IRQ12_MARK,
324 SD_D3_MARK, SD_D2_MARK, SD_D1_MARK, SD_D0_MARK, 393 IRQ11_MARK, IRQ10_MARK, IRQ9_MARK, IRQ8_MARK,
394 ON_NRE_MARK, ON_NWE_MARK, ON_NWP_MARK, ON_NCE0_MARK,
395 ON_R_B0_MARK, ON_ALE_MARK, ON_CLE_MARK, TCLK_MARK,
325 396
326 /* PTD (mobule: INTC, SPI0, LBSC, CPG, ADC) */ 397 /* PTC (mobule: IRQ, PWMU) */
327 IRQ7_MARK, IRQ6_MARK, IRQ5_MARK, IRQ4_MARK, 398 IRQ7_MARK, IRQ6_MARK, IRQ5_MARK, IRQ4_MARK,
328 IRQ3_MARK, IRQ2_MARK, IRQ1_MARK, IRQ0_MARK, 399 IRQ3_MARK, IRQ2_MARK, IRQ1_MARK, IRQ0_MARK,
329 MD6_MARK, MD5_MARK, MD3_MARK, MD2_MARK, 400 PWMU0_MARK, PWMU1_MARK, PWMU2_MARK, PWMU3_MARK,
330 MD1_MARK, MD0_MARK, ADTRG1_MARK, ADTRG0_MARK, 401 PWMU4_MARK, PWMU5_MARK,
331 402
332 /* PTE (mobule: EtherC) */ 403 /* PTD (mobule: SPI0, DMAC) */
333 ET0_CRS_DV_MARK, ET0_TXD1_MARK, 404 SP0_MOSI_MARK, SP0_MISO_MARK, SP0_SCK_MARK, SP0_SCK_FB_MARK,
334 ET0_TXD0_MARK, ET0_TX_EN_MARK, 405 SP0_SS0_MARK, SP0_SS1_MARK, SP0_SS2_MARK, SP0_SS3_MARK,
335 ET0_REF_CLK_MARK, ET0_RXD1_MARK, 406 DREQ0_MARK, DACK0_MARK, TEND0_MARK,
336 ET0_RXD0_MARK, ET0_RX_ER_MARK, 407
337 408 /* PTE (mobule: RMII) */
338 /* PTF (mobule: EtherC) */ 409 RMII0_CRS_DV_MARK, RMII0_TXD1_MARK,
339 ET1_CRS_DV_MARK, ET1_TXD1_MARK, 410 RMII0_TXD0_MARK, RMII0_TXEN_MARK,
340 ET1_TXD0_MARK, ET1_TX_EN_MARK, 411 RMII0_REFCLK_MARK, RMII0_RXD1_MARK,
341 ET1_REF_CLK_MARK, ET1_RXD1_MARK, 412 RMII0_RXD0_MARK, RMII0_RX_ER_MARK,
342 ET1_RXD0_MARK, ET1_RX_ER_MARK, 413
343 414 /* PTF (mobule: RMII, SerMux) */
344 /* PTG (mobule: SYSTEM, PWMX, LPC) */ 415 RMII1_CRS_DV_MARK, RMII1_TXD1_MARK,
345 STATUS0_MARK, STATUS1_MARK, 416 RMII1_TXD0_MARK, RMII1_TXEN_MARK,
346 PWX0_MARK, PWX1_MARK, PWX2_MARK, PWX3_MARK, 417 RMII1_REFCLK_MARK, RMII1_RXD1_MARK,
347 SERIRQ_MARK, CLKRUN_MARK, LPCPD_MARK, LDRQ_MARK, 418 RMII1_RXD0_MARK, RMII1_RX_ER_MARK,
348 419 RAC_RI_MARK,
349 /* PTH (mobule: TMU, SCIF234, SPI1, SPI0) */ 420
350 TCLK_MARK, RXD4_MARK, TXD4_MARK, 421 /* PTG (mobule: system, LBSC, LPC, WDT, LPC, eMMC) */
422 BOOTFMS_MARK, BOOTWP_MARK, A25_MARK, A24_MARK,
423 SERIRQ_MARK, WDTOVF_MARK, LPCPD_MARK, LDRQ_MARK,
424 MMCCLK_MARK, MMCCMD_MARK,
425
426 /* PTH (mobule: SPI1, LPC, DMAC, ADC) */
351 SP1_MOSI_MARK, SP1_MISO_MARK, SP1_SCK_MARK, SP1_SCK_FB_MARK, 427 SP1_MOSI_MARK, SP1_MISO_MARK, SP1_SCK_MARK, SP1_SCK_FB_MARK,
352 SP1_SS0_MARK, SP1_SS1_MARK, SP0_SS1_MARK, 428 SP1_SS0_MARK, SP1_SS1_MARK, WP_MARK, FMS0_MARK,
429 TEND1_MARK, DREQ1_MARK, DACK1_MARK, ADTRG1_MARK,
430 ADTRG0_MARK,
353 431
354 /* PTI (mobule: INTC) */ 432 /* PTI (mobule: LBSC, SDHI) */
355 IRQ15_MARK, IRQ14_MARK, IRQ13_MARK, IRQ12_MARK, 433 D15_MARK, D14_MARK, D13_MARK, D12_MARK,
356 IRQ11_MARK, IRQ10_MARK, IRQ9_MARK, IRQ8_MARK, 434 D11_MARK, D10_MARK, D9_MARK, D8_MARK,
435 SD_WP_MARK, SD_CD_MARK, SD_CLK_MARK, SD_CMD_MARK,
436 SD_D3_MARK, SD_D2_MARK, SD_D1_MARK, SD_D0_MARK,
357 437
358 /* PTJ (mobule: SCIF234, SERMUX) */ 438 /* PTJ (mobule: SCIF234) */
359 RXD3_MARK, TXD3_MARK, RXD2_MARK, TXD2_MARK, 439 RTS3_MARK, CTS3_MARK, TXD3_MARK, RXD3_MARK,
360 COM1_TXD_MARK, COM1_RXD_MARK, COM1_RTS_MARK, COM1_CTS_MARK, 440 RTS4_MARK, RXD4_MARK, TXD4_MARK,
361 441
362 /* PTK (mobule: SERMUX) */ 442 /* PTK (mobule: SERMUX, LBSC, SCIF) */
363 COM2_TXD_MARK, COM2_RXD_MARK, COM2_RTS_MARK, COM2_CTS_MARK, 443 COM2_TXD_MARK, COM2_RXD_MARK, COM2_RTS_MARK, COM2_CTS_MARK,
364 COM2_DTR_MARK, COM2_DSR_MARK, COM2_DCD_MARK, COM2_RI_MARK, 444 COM2_DTR_MARK, COM2_DSR_MARK, COM2_DCD_MARK, CLKOUT_MARK,
445 SCK2_MARK, SCK4_MARK, SCK3_MARK,
365 446
366 /* PTL (mobule: SERMUX) */ 447 /* PTL (mobule: SERMUX, SCIF, LBSC, AUD) */
367 RAC_TXD_MARK, RAC_RXD_MARK, RAC_RTS_MARK, RAC_CTS_MARK, 448 RAC_RXD_MARK, RAC_RTS_MARK, RAC_CTS_MARK, RAC_DTR_MARK,
368 RAC_DTR_MARK, RAC_DSR_MARK, RAC_DCD_MARK, RAC_RI_MARK, 449 RAC_DSR_MARK, RAC_DCD_MARK, RAC_TXD_MARK, RXD2_MARK,
450 CS5_MARK, CS6_MARK, AUDSYNC_MARK, AUDCK_MARK,
451 TXD2_MARK,
369 452
370 /* PTM (mobule: IIC, LPC) */ 453 /* PTM (mobule: LBSC, IIC) */
454 CS4_MARK, RD_MARK, WE0_MARK, CS0_MARK,
371 SDA6_MARK, SCL6_MARK, SDA7_MARK, SCL7_MARK, 455 SDA6_MARK, SCL6_MARK, SDA7_MARK, SCL7_MARK,
372 WP_MARK, FMS0_MARK, FMS1_MARK,
373 456
374 /* PTN (mobule: SCIF234, EVC) */ 457 /* PTN (mobule: USB, JMC, SGPIO, WDT) */
375 SCK2_MARK, RTS4_MARK, RTS3_MARK, RTS2_MARK, 458 VBUS_EN_MARK, VBUS_OC_MARK, JMCTCK_MARK, JMCTMS_MARK,
376 CTS4_MARK, CTS3_MARK, CTS2_MARK, 459 JMCTDO_MARK, JMCTDI_MARK, JMCTRST_MARK,
377 EVENT7_MARK, EVENT6_MARK, EVENT5_MARK, EVENT4_MARK, 460 SGPIO1_CLK_MARK, SGPIO1_LOAD_MARK, SGPIO1_DI_MARK,
378 EVENT3_MARK, EVENT2_MARK, EVENT1_MARK, EVENT0_MARK, 461 SGPIO1_DO_MARK, SUB_CLKIN_MARK,
379 462
380 /* PTO (mobule: SGPIO) */ 463 /* PTO (mobule: SGPIO, SerMux) */
381 SGPIO0_CLK_MARK, SGPIO0_LOAD_MARK, 464 SGPIO0_CLK_MARK, SGPIO0_LOAD_MARK, SGPIO0_DI_MARK,
382 SGPIO0_DI_MARK, SGPIO0_DO_MARK, 465 SGPIO0_DO_MARK, SGPIO2_CLK_MARK, SGPIO2_LOAD_MARK,
383 SGPIO1_CLK_MARK, SGPIO1_LOAD_MARK, 466 SGPIO2_DI_MARK, SGPIO2_DO_MARK,
384 SGPIO1_DI_MARK, SGPIO1_DO_MARK, 467 COM1_TXD_MARK, COM1_RXD_MARK, COM1_RTS_MARK, COM1_CTS_MARK,
385
386 /* PTP (mobule: JMC, SCIF234) */
387 JMCTCK_MARK, JMCTMS_MARK, JMCTDO_MARK, JMCTDI_MARK,
388 JMCRST_MARK, SCK4_MARK, SCK3_MARK,
389 468
390 /* PTQ (mobule: LPC) */ 469 /* PTQ (mobule: LPC) */
391 LAD3_MARK, LAD2_MARK, LAD1_MARK, LAD0_MARK, 470 LAD3_MARK, LAD2_MARK, LAD1_MARK, LAD0_MARK,
392 LFRAME_MARK, LRESET_MARK, LCLK_MARK, 471 LFRAME_MARK, LRESET_MARK, LCLK_MARK,
393 472
394 /* PTR (mobule: GRA, IIC) */ 473 /* PTR (mobule: GRA, IIC) */
395 DDC3_MARK, DDC2_MARK, 474 DDC3_MARK, DDC2_MARK, SDA2_MARK, SCL2_MARK,
396 SDA8_MARK, SCL8_MARK, SDA2_MARK, SCL2_MARK,
397 SDA1_MARK, SCL1_MARK, SDA0_MARK, SCL0_MARK, 475 SDA1_MARK, SCL1_MARK, SDA0_MARK, SCL0_MARK,
476 SDA8_MARK, SCL8_MARK,
398 477
399 /* PTS (mobule: GRA, IIC) */ 478 /* PTS (mobule: GRA, IIC) */
400 DDC1_MARK, DDC0_MARK, 479 DDC1_MARK, DDC0_MARK, SDA5_MARK, SCL5_MARK,
401 SDA9_MARK, SCL9_MARK, SDA5_MARK, SCL5_MARK,
402 SDA4_MARK, SCL4_MARK, SDA3_MARK, SCL3_MARK, 480 SDA4_MARK, SCL4_MARK, SDA3_MARK, SCL3_MARK,
481 SDA9_MARK, SCL9_MARK,
403 482
404 /* PTT (mobule: SYSTEM, PWMX) */ 483 /* PTT (mobule: PWMX, AUD) */
405 AUDSYNC_MARK, AUDCK_MARK, 484 PWMX7_MARK, PWMX6_MARK, PWMX5_MARK, PWMX4_MARK,
406 AUDATA3_MARK, AUDATA2_MARK, 485 PWMX3_MARK, PWMX2_MARK, PWMX1_MARK, PWMX0_MARK,
407 AUDATA1_MARK, AUDATA0_MARK, 486 AUDATA3_MARK, AUDATA2_MARK, AUDATA1_MARK, AUDATA0_MARK,
408 PWX7_MARK, PWX6_MARK, PWX5_MARK, PWX4_MARK, 487 STATUS1_MARK, STATUS0_MARK,
409 488
410 /* PTU (mobule: LBSC, DMAC) */ 489 /* PTU (mobule: LPC, APM) */
411 CS6_MARK, CS5_MARK, CS4_MARK, CS0_MARK, 490 LGPIO7_MARK, LGPIO6_MARK, LGPIO5_MARK, LGPIO4_MARK,
412 RD_MARK, WE0_MARK, A25_MARK, A24_MARK, 491 LGPIO3_MARK, LGPIO2_MARK, LGPIO1_MARK, LGPIO0_MARK,
413 DREQ0_MARK, DACK0_MARK, 492 APMONCTL_O_MARK, APMPWBTOUT_O_MARK, APMSCI_O_MARK,
493 APMVDDON_MARK, APMSLPBTN_MARK, APMPWRBTN_MARK, APMS5N_MARK,
494 APMS3N_MARK,
414 495
415 /* PTV (mobule: LBSC, DMAC) */ 496 /* PTV (mobule: LBSC, SerMux, R-SPI, EVC, GRA) */
416 A23_MARK, A22_MARK, A21_MARK, A20_MARK, 497 A23_MARK, A22_MARK, A21_MARK, A20_MARK,
417 A19_MARK, A18_MARK, A17_MARK, A16_MARK, 498 A19_MARK, A18_MARK, A17_MARK, A16_MARK,
418 TEND0_MARK, DREQ1_MARK, DACK1_MARK, TEND1_MARK, 499 COM2_RI_MARK, R_SPI_MOSI_MARK, R_SPI_MISO_MARK,
500 R_SPI_RSPCK_MARK, R_SPI_SSL0_MARK, R_SPI_SSL1_MARK,
501 EVENT7_MARK, EVENT6_MARK, VBIOS_DI_MARK, VBIOS_DO_MARK,
502 VBIOS_CLK_MARK, VBIOS_CS_MARK,
419 503
420 /* PTW (mobule: LBSC) */ 504 /* PTW (mobule: LBSC, EVC, SCIF) */
421 A15_MARK, A14_MARK, A13_MARK, A12_MARK, 505 A15_MARK, A14_MARK, A13_MARK, A12_MARK,
422 A11_MARK, A10_MARK, A9_MARK, A8_MARK, 506 A11_MARK, A10_MARK, A9_MARK, A8_MARK,
507 EVENT5_MARK, EVENT4_MARK, EVENT3_MARK, EVENT2_MARK,
508 EVENT1_MARK, EVENT0_MARK, CTS4_MARK, CTS2_MARK,
423 509
424 /* PTX (mobule: LBSC) */ 510 /* PTX (mobule: LBSC, SCIF, SIM) */
425 A7_MARK, A6_MARK, A5_MARK, A4_MARK, 511 A7_MARK, A6_MARK, A5_MARK, A4_MARK,
426 A3_MARK, A2_MARK, A1_MARK, A0_MARK, 512 A3_MARK, A2_MARK, A1_MARK, A0_MARK,
513 RTS2_MARK, SIM_D_MARK, SIM_CLK_MARK, SIM_RST_MARK,
427 514
428 /* PTY (mobule: LBSC) */ 515 /* PTY (mobule: LBSC) */
429 D7_MARK, D6_MARK, D5_MARK, D4_MARK, 516 D7_MARK, D6_MARK, D5_MARK, D4_MARK,
430 D3_MARK, D2_MARK, D1_MARK, D0_MARK, 517 D3_MARK, D2_MARK, D1_MARK, D0_MARK,
518
519 /* PTZ (mobule: eMMC, ONFI) */
520 MMCDAT7_MARK, MMCDAT6_MARK, MMCDAT5_MARK, MMCDAT4_MARK,
521 MMCDAT3_MARK, MMCDAT2_MARK, MMCDAT1_MARK, MMCDAT0_MARK,
522 ON_DQ7_MARK, ON_DQ6_MARK, ON_DQ5_MARK, ON_DQ4_MARK,
523 ON_DQ3_MARK, ON_DQ2_MARK, ON_DQ1_MARK, ON_DQ0_MARK,
524
431 PINMUX_MARK_END, 525 PINMUX_MARK_END,
432}; 526};
433 527
@@ -473,6 +567,8 @@ static pinmux_enum_t pinmux_data[] = {
473 PINMUX_DATA(PTD0_DATA, PTD0_IN, PTD0_OUT), 567 PINMUX_DATA(PTD0_DATA, PTD0_IN, PTD0_OUT),
474 568
475 /* PTE GPIO */ 569 /* PTE GPIO */
570 PINMUX_DATA(PTE7_DATA, PTE7_IN, PTE7_OUT),
571 PINMUX_DATA(PTE6_DATA, PTE6_IN, PTE6_OUT),
476 PINMUX_DATA(PTE5_DATA, PTE5_IN, PTE5_OUT), 572 PINMUX_DATA(PTE5_DATA, PTE5_IN, PTE5_OUT),
477 PINMUX_DATA(PTE4_DATA, PTE4_IN, PTE4_OUT), 573 PINMUX_DATA(PTE4_DATA, PTE4_IN, PTE4_OUT),
478 PINMUX_DATA(PTE3_DATA, PTE3_IN, PTE3_OUT), 574 PINMUX_DATA(PTE3_DATA, PTE3_IN, PTE3_OUT),
@@ -521,7 +617,6 @@ static pinmux_enum_t pinmux_data[] = {
521 PINMUX_DATA(PTI0_DATA, PTI0_IN, PTI0_OUT), 617 PINMUX_DATA(PTI0_DATA, PTI0_IN, PTI0_OUT),
522 618
523 /* PTJ GPIO */ 619 /* PTJ GPIO */
524 PINMUX_DATA(PTJ7_DATA, PTJ7_IN, PTJ7_OUT),
525 PINMUX_DATA(PTJ6_DATA, PTJ6_IN, PTJ6_OUT), 620 PINMUX_DATA(PTJ6_DATA, PTJ6_IN, PTJ6_OUT),
526 PINMUX_DATA(PTJ5_DATA, PTJ5_IN, PTJ5_OUT), 621 PINMUX_DATA(PTJ5_DATA, PTJ5_IN, PTJ5_OUT),
527 PINMUX_DATA(PTJ4_DATA, PTJ4_IN, PTJ4_OUT), 622 PINMUX_DATA(PTJ4_DATA, PTJ4_IN, PTJ4_OUT),
@@ -541,7 +636,6 @@ static pinmux_enum_t pinmux_data[] = {
541 PINMUX_DATA(PTK0_DATA, PTK0_IN, PTK0_OUT), 636 PINMUX_DATA(PTK0_DATA, PTK0_IN, PTK0_OUT),
542 637
543 /* PTL GPIO */ 638 /* PTL GPIO */
544 PINMUX_DATA(PTL7_DATA, PTL7_IN, PTL7_OUT),
545 PINMUX_DATA(PTL6_DATA, PTL6_IN, PTL6_OUT), 639 PINMUX_DATA(PTL6_DATA, PTL6_IN, PTL6_OUT),
546 PINMUX_DATA(PTL5_DATA, PTL5_IN, PTL5_OUT), 640 PINMUX_DATA(PTL5_DATA, PTL5_IN, PTL5_OUT),
547 PINMUX_DATA(PTL4_DATA, PTL4_IN, PTL4_OUT), 641 PINMUX_DATA(PTL4_DATA, PTL4_IN, PTL4_OUT),
@@ -560,7 +654,6 @@ static pinmux_enum_t pinmux_data[] = {
560 PINMUX_DATA(PTM0_DATA, PTM0_IN, PTM0_OUT), 654 PINMUX_DATA(PTM0_DATA, PTM0_IN, PTM0_OUT),
561 655
562 /* PTN GPIO */ 656 /* PTN GPIO */
563 PINMUX_DATA(PTN7_DATA, PTN7_IN, PTN7_OUT),
564 PINMUX_DATA(PTN6_DATA, PTN6_IN, PTN6_OUT), 657 PINMUX_DATA(PTN6_DATA, PTN6_IN, PTN6_OUT),
565 PINMUX_DATA(PTN5_DATA, PTN5_IN, PTN5_OUT), 658 PINMUX_DATA(PTN5_DATA, PTN5_IN, PTN5_OUT),
566 PINMUX_DATA(PTN4_DATA, PTN4_IN, PTN4_OUT), 659 PINMUX_DATA(PTN4_DATA, PTN4_IN, PTN4_OUT),
@@ -609,6 +702,8 @@ static pinmux_enum_t pinmux_data[] = {
609 PINMUX_DATA(PTS0_DATA, PTS0_IN, PTS0_OUT), 702 PINMUX_DATA(PTS0_DATA, PTS0_IN, PTS0_OUT),
610 703
611 /* PTT GPIO */ 704 /* PTT GPIO */
705 PINMUX_DATA(PTT7_DATA, PTT7_IN, PTT7_OUT),
706 PINMUX_DATA(PTT6_DATA, PTT6_IN, PTT6_OUT),
612 PINMUX_DATA(PTT5_DATA, PTT5_IN, PTT5_OUT), 707 PINMUX_DATA(PTT5_DATA, PTT5_IN, PTT5_OUT),
613 PINMUX_DATA(PTT4_DATA, PTT4_IN, PTT4_OUT), 708 PINMUX_DATA(PTT4_DATA, PTT4_IN, PTT4_OUT),
614 PINMUX_DATA(PTT3_DATA, PTT3_IN, PTT3_OUT), 709 PINMUX_DATA(PTT3_DATA, PTT3_IN, PTT3_OUT),
@@ -677,186 +772,204 @@ static pinmux_enum_t pinmux_data[] = {
677 PINMUX_DATA(PTZ0_DATA, PTZ0_IN, PTZ0_OUT), 772 PINMUX_DATA(PTZ0_DATA, PTZ0_IN, PTZ0_OUT),
678 773
679 /* PTA FN */ 774 /* PTA FN */
680 PINMUX_DATA(BS_MARK, PS0_15_FN1, PTA7_FN), 775 PINMUX_DATA(BS_MARK, PTA7_FN),
681 PINMUX_DATA(LGPIO7_MARK, PS0_15_FN3, PTA7_FN), 776 PINMUX_DATA(RDWR_MARK, PTA6_FN),
682 PINMUX_DATA(RDWR_MARK, PS0_14_FN1, PTA6_FN), 777 PINMUX_DATA(WE1_MARK, PTA5_FN),
683 PINMUX_DATA(LGPIO6_MARK, PS0_14_FN3, PTA6_FN), 778 PINMUX_DATA(RDY_MARK, PTA4_FN),
684 PINMUX_DATA(WE1_MARK, PS0_13_FN1, PTA5_FN), 779 PINMUX_DATA(ET0_MDC_MARK, PTA3_FN),
685 PINMUX_DATA(LGPIO5_MARK, PS0_13_FN3, PTA5_FN), 780 PINMUX_DATA(ET0_MDIO_MARK, PTA2_FN),
686 PINMUX_DATA(RDY_MARK, PS0_12_FN1, PTA4_FN), 781 PINMUX_DATA(ET1_MDC_MARK, PTA1_FN),
687 PINMUX_DATA(LGPIO4_MARK, PS0_12_FN3, PTA4_FN), 782 PINMUX_DATA(ET1_MDIO_MARK, PTA0_FN),
688 PINMUX_DATA(LGPIO3_MARK, PTA3_FN),
689 PINMUX_DATA(LGPIO2_MARK, PTA2_FN),
690 PINMUX_DATA(LGPIO1_MARK, PTA1_FN),
691 PINMUX_DATA(LGPIO0_MARK, PTA0_FN),
692 783
693 /* PTB FN */ 784 /* PTB FN */
694 PINMUX_DATA(D15_MARK, PS0_7_FN1, PTB7_FN), 785 PINMUX_DATA(IRQ15_MARK, PS0_15_FN1, PTB7_FN),
695 PINMUX_DATA(ET0_MDC_MARK, PS0_7_FN2, PTB7_FN), 786 PINMUX_DATA(ON_NRE_MARK, PS0_15_FN2, PTB7_FN),
696 PINMUX_DATA(D14_MARK, PS0_6_FN1, PTB6_FN), 787 PINMUX_DATA(IRQ14_MARK, PS0_14_FN1, PTB6_FN),
697 PINMUX_DATA(ET0_MDIO_MARK, PS0_6_FN2, PTB6_FN), 788 PINMUX_DATA(ON_NWE_MARK, PS0_14_FN2, PTB6_FN),
698 PINMUX_DATA(D13_MARK, PS0_5_FN1, PTB5_FN), 789 PINMUX_DATA(IRQ13_MARK, PS0_13_FN1, PTB5_FN),
699 PINMUX_DATA(ET1_MDC_MARK, PS0_5_FN2, PTB5_FN), 790 PINMUX_DATA(ON_NWP_MARK, PS0_13_FN2, PTB5_FN),
700 PINMUX_DATA(D12_MARK, PS0_4_FN1, PTB4_FN), 791 PINMUX_DATA(IRQ12_MARK, PS0_12_FN1, PTB4_FN),
701 PINMUX_DATA(ET1_MDIO_MARK, PS0_4_FN2, PTB4_FN), 792 PINMUX_DATA(ON_NCE0_MARK, PS0_12_FN2, PTB4_FN),
702 PINMUX_DATA(D11_MARK, PS0_3_FN1, PTB3_FN), 793 PINMUX_DATA(IRQ11_MARK, PS0_11_FN1, PTB3_FN),
703 PINMUX_DATA(SIM_D_MARK, PS0_3_FN2, PTB3_FN), 794 PINMUX_DATA(ON_R_B0_MARK, PS0_11_FN2, PTB3_FN),
704 PINMUX_DATA(D10_MARK, PS0_2_FN1, PTB2_FN), 795 PINMUX_DATA(IRQ10_MARK, PS0_10_FN1, PTB2_FN),
705 PINMUX_DATA(SIM_CLK_MARK, PS0_2_FN2, PTB2_FN), 796 PINMUX_DATA(ON_ALE_MARK, PS0_10_FN2, PTB2_FN),
706 PINMUX_DATA(D9_MARK, PS0_1_FN1, PTB1_FN), 797 PINMUX_DATA(IRQ9_MARK, PS0_9_FN1, PTB1_FN),
707 PINMUX_DATA(SIM_RST_MARK, PS0_1_FN2, PTB1_FN), 798 PINMUX_DATA(ON_CLE_MARK, PS0_9_FN2, PTB1_FN),
708 PINMUX_DATA(D8_MARK, PTB0_FN), 799 PINMUX_DATA(IRQ8_MARK, PS0_8_FN1, PTB0_FN),
800 PINMUX_DATA(TCLK_MARK, PS0_8_FN2, PTB0_FN),
709 801
710 /* PTC FN */ 802 /* PTC FN */
711 PINMUX_DATA(SD_WP_MARK, PTC7_FN), 803 PINMUX_DATA(IRQ7_MARK, PS0_7_FN1, PTC7_FN),
712 PINMUX_DATA(SD_CD_MARK, PTC6_FN), 804 PINMUX_DATA(PWMU0_MARK, PS0_7_FN2, PTC7_FN),
713 PINMUX_DATA(SD_CLK_MARK, PTC5_FN), 805 PINMUX_DATA(IRQ6_MARK, PS0_6_FN1, PTC6_FN),
714 PINMUX_DATA(SD_CMD_MARK, PTC4_FN), 806 PINMUX_DATA(PWMU1_MARK, PS0_6_FN2, PTC6_FN),
715 PINMUX_DATA(SD_D3_MARK, PTC3_FN), 807 PINMUX_DATA(IRQ5_MARK, PS0_5_FN1, PTC5_FN),
716 PINMUX_DATA(SD_D2_MARK, PTC2_FN), 808 PINMUX_DATA(PWMU2_MARK, PS0_5_FN2, PTC5_FN),
717 PINMUX_DATA(SD_D1_MARK, PTC1_FN), 809 PINMUX_DATA(IRQ4_MARK, PS0_4_FN1, PTC5_FN),
718 PINMUX_DATA(SD_D0_MARK, PTC0_FN), 810 PINMUX_DATA(PWMU3_MARK, PS0_4_FN2, PTC4_FN),
811 PINMUX_DATA(IRQ3_MARK, PS0_3_FN1, PTC3_FN),
812 PINMUX_DATA(PWMU4_MARK, PS0_3_FN2, PTC3_FN),
813 PINMUX_DATA(IRQ2_MARK, PS0_2_FN1, PTC2_FN),
814 PINMUX_DATA(PWMU5_MARK, PS0_2_FN2, PTC2_FN),
815 PINMUX_DATA(IRQ1_MARK, PTC1_FN),
816 PINMUX_DATA(IRQ0_MARK, PTC0_FN),
719 817
720 /* PTD FN */ 818 /* PTD FN */
721 PINMUX_DATA(IRQ7_MARK, PS1_7_FN1, PTD7_FN), 819 PINMUX_DATA(SP0_MOSI_MARK, PTD7_FN),
722 PINMUX_DATA(ADTRG1_MARK, PS1_7_FN3, PTD7_FN), 820 PINMUX_DATA(SP0_MISO_MARK, PTD6_FN),
723 PINMUX_DATA(IRQ6_MARK, PS1_6_FN1, PTD6_FN), 821 PINMUX_DATA(SP0_SCK_MARK, PTD5_FN),
724 PINMUX_DATA(ADTRG0_MARK, PS1_6_FN3, PTD6_FN), 822 PINMUX_DATA(SP0_SCK_FB_MARK, PTD4_FN),
725 PINMUX_DATA(IRQ5_MARK, PTD5_FN), 823 PINMUX_DATA(SP0_SS0_MARK, PTD3_FN),
726 PINMUX_DATA(IRQ4_MARK, PTD4_FN), 824 PINMUX_DATA(SP0_SS1_MARK, PS1_10_FN1, PTD2_FN),
727 PINMUX_DATA(IRQ3_MARK, PTD3_FN), 825 PINMUX_DATA(DREQ0_MARK, PS1_10_FN2, PTD2_FN),
728 PINMUX_DATA(IRQ2_MARK, PTD2_FN), 826 PINMUX_DATA(SP0_SS2_MARK, PS1_9_FN1, PTD1_FN),
729 PINMUX_DATA(IRQ1_MARK, PTD1_FN), 827 PINMUX_DATA(DACK0_MARK, PS1_9_FN2, PTD1_FN),
730 PINMUX_DATA(IRQ0_MARK, PTD0_FN), 828 PINMUX_DATA(SP0_SS3_MARK, PS1_8_FN1, PTD0_FN),
829 PINMUX_DATA(TEND0_MARK, PS1_8_FN2, PTD0_FN),
731 830
732 /* PTE FN */ 831 /* PTE FN */
733 PINMUX_DATA(ET0_CRS_DV_MARK, PTE7_FN), 832 PINMUX_DATA(RMII0_CRS_DV_MARK, PTE7_FN),
734 PINMUX_DATA(ET0_TXD1_MARK, PTE6_FN), 833 PINMUX_DATA(RMII0_TXD1_MARK, PTE6_FN),
735 PINMUX_DATA(ET0_TXD0_MARK, PTE5_FN), 834 PINMUX_DATA(RMII0_TXD0_MARK, PTE5_FN),
736 PINMUX_DATA(ET0_TX_EN_MARK, PTE4_FN), 835 PINMUX_DATA(RMII0_TXEN_MARK, PTE4_FN),
737 PINMUX_DATA(ET0_REF_CLK_MARK, PTE3_FN), 836 PINMUX_DATA(RMII0_REFCLK_MARK, PTE3_FN),
738 PINMUX_DATA(ET0_RXD1_MARK, PTE2_FN), 837 PINMUX_DATA(RMII0_RXD1_MARK, PTE2_FN),
739 PINMUX_DATA(ET0_RXD0_MARK, PTE1_FN), 838 PINMUX_DATA(RMII0_RXD0_MARK, PTE1_FN),
740 PINMUX_DATA(ET0_RX_ER_MARK, PTE0_FN), 839 PINMUX_DATA(RMII0_RX_ER_MARK, PTE0_FN),
741 840
742 /* PTF FN */ 841 /* PTF FN */
743 PINMUX_DATA(ET1_CRS_DV_MARK, PTF7_FN), 842 PINMUX_DATA(RMII1_CRS_DV_MARK, PTF7_FN),
744 PINMUX_DATA(ET1_TXD1_MARK, PTF6_FN), 843 PINMUX_DATA(RMII1_TXD1_MARK, PTF6_FN),
745 PINMUX_DATA(ET1_TXD0_MARK, PTF5_FN), 844 PINMUX_DATA(RMII1_TXD0_MARK, PTF5_FN),
746 PINMUX_DATA(ET1_TX_EN_MARK, PTF4_FN), 845 PINMUX_DATA(RMII1_TXEN_MARK, PTF4_FN),
747 PINMUX_DATA(ET1_REF_CLK_MARK, PTF3_FN), 846 PINMUX_DATA(RMII1_REFCLK_MARK, PTF3_FN),
748 PINMUX_DATA(ET1_RXD1_MARK, PTF2_FN), 847 PINMUX_DATA(RMII1_RXD1_MARK, PS1_2_FN1, PTF2_FN),
749 PINMUX_DATA(ET1_RXD0_MARK, PTF1_FN), 848 PINMUX_DATA(RAC_RI_MARK, PS1_2_FN2, PTF2_FN),
750 PINMUX_DATA(ET1_RX_ER_MARK, PTF0_FN), 849 PINMUX_DATA(RMII1_RXD0_MARK, PTF1_FN),
850 PINMUX_DATA(RMII1_RX_ER_MARK, PTF0_FN),
751 851
752 /* PTG FN */ 852 /* PTG FN */
753 PINMUX_DATA(PWX0_MARK, PTG7_FN), 853 PINMUX_DATA(BOOTFMS_MARK, PTG7_FN),
754 PINMUX_DATA(PWX1_MARK, PTG6_FN), 854 PINMUX_DATA(BOOTWP_MARK, PTG6_FN),
755 PINMUX_DATA(STATUS0_MARK, PS2_13_FN1, PTG5_FN), 855 PINMUX_DATA(A25_MARK, PS2_13_FN1, PTG5_FN),
756 PINMUX_DATA(PWX2_MARK, PS2_13_FN3, PTG5_FN), 856 PINMUX_DATA(MMCCLK_MARK, PS2_13_FN2, PTG5_FN),
757 PINMUX_DATA(STATUS1_MARK, PS2_12_FN1, PTG4_FN), 857 PINMUX_DATA(A24_MARK, PS2_12_FN1, PTG4_FN),
758 PINMUX_DATA(PWX3_MARK, PS2_12_FN3, PTG4_FN), 858 PINMUX_DATA(MMCCMD_MARK, PS2_12_FN2, PTG4_FN),
759 PINMUX_DATA(SERIRQ_MARK, PTG3_FN), 859 PINMUX_DATA(SERIRQ_MARK, PTG3_FN),
760 PINMUX_DATA(CLKRUN_MARK, PTG2_FN), 860 PINMUX_DATA(WDTOVF_MARK, PTG2_FN),
761 PINMUX_DATA(LPCPD_MARK, PTG1_FN), 861 PINMUX_DATA(LPCPD_MARK, PTG1_FN),
762 PINMUX_DATA(LDRQ_MARK, PTG0_FN), 862 PINMUX_DATA(LDRQ_MARK, PTG0_FN),
763 863
764 /* PTH FN */ 864 /* PTH FN */
765 PINMUX_DATA(SP1_MOSI_MARK, PTH7_FN), 865 PINMUX_DATA(SP1_MOSI_MARK, PS2_7_FN1, PTH7_FN),
766 PINMUX_DATA(SP1_MISO_MARK, PTH6_FN), 866 PINMUX_DATA(TEND1_MARK, PS2_7_FN2, PTH7_FN),
767 PINMUX_DATA(SP1_SCK_MARK, PTH5_FN), 867 PINMUX_DATA(SP1_MISO_MARK, PS2_6_FN1, PTH6_FN),
768 PINMUX_DATA(SP1_SCK_FB_MARK, PTH4_FN), 868 PINMUX_DATA(DREQ1_MARK, PS2_6_FN2, PTH6_FN),
869 PINMUX_DATA(SP1_SCK_MARK, PS2_5_FN1, PTH5_FN),
870 PINMUX_DATA(DACK1_MARK, PS2_5_FN2, PTH5_FN),
871 PINMUX_DATA(SP1_SCK_FB_MARK, PS2_4_FN1, PTH4_FN),
872 PINMUX_DATA(ADTRG1_MARK, PS2_4_FN2, PTH4_FN),
769 PINMUX_DATA(SP1_SS0_MARK, PTH3_FN), 873 PINMUX_DATA(SP1_SS0_MARK, PTH3_FN),
770 PINMUX_DATA(TCLK_MARK, PTH2_FN), 874 PINMUX_DATA(SP1_SS1_MARK, PS2_2_FN1, PTH2_FN),
771 PINMUX_DATA(RXD4_MARK, PS2_1_FN1, PTH1_FN), 875 PINMUX_DATA(ADTRG0_MARK, PS2_2_FN2, PTH2_FN),
772 PINMUX_DATA(SP1_SS1_MARK, PS2_1_FN2, PTH1_FN), 876 PINMUX_DATA(WP_MARK, PTH1_FN),
773 PINMUX_DATA(TXD4_MARK, PS2_0_FN1, PTH0_FN), 877 PINMUX_DATA(FMS0_MARK, PTH0_FN),
774 PINMUX_DATA(SP0_SS1_MARK, PS2_0_FN2, PTH0_FN),
775 878
776 /* PTI FN */ 879 /* PTI FN */
777 PINMUX_DATA(IRQ15_MARK, PTI7_FN), 880 PINMUX_DATA(D15_MARK, PS3_15_FN1, PTI7_FN),
778 PINMUX_DATA(IRQ14_MARK, PTI6_FN), 881 PINMUX_DATA(SD_WP_MARK, PS3_15_FN2, PTI7_FN),
779 PINMUX_DATA(IRQ13_MARK, PTI5_FN), 882 PINMUX_DATA(D14_MARK, PS3_14_FN1, PTI6_FN),
780 PINMUX_DATA(IRQ12_MARK, PTI4_FN), 883 PINMUX_DATA(SD_CD_MARK, PS3_14_FN2, PTI6_FN),
781 PINMUX_DATA(IRQ11_MARK, PTI3_FN), 884 PINMUX_DATA(D13_MARK, PS3_13_FN1, PTI5_FN),
782 PINMUX_DATA(IRQ10_MARK, PTI2_FN), 885 PINMUX_DATA(SD_CLK_MARK, PS3_13_FN2, PTI5_FN),
783 PINMUX_DATA(IRQ9_MARK, PTI1_FN), 886 PINMUX_DATA(D12_MARK, PS3_12_FN1, PTI4_FN),
784 PINMUX_DATA(IRQ8_MARK, PTI0_FN), 887 PINMUX_DATA(SD_CMD_MARK, PS3_12_FN2, PTI4_FN),
888 PINMUX_DATA(D11_MARK, PS3_11_FN1, PTI3_FN),
889 PINMUX_DATA(SD_D3_MARK, PS3_11_FN2, PTI3_FN),
890 PINMUX_DATA(D10_MARK, PS3_10_FN1, PTI2_FN),
891 PINMUX_DATA(SD_D2_MARK, PS3_10_FN2, PTI2_FN),
892 PINMUX_DATA(D9_MARK, PS3_9_FN1, PTI1_FN),
893 PINMUX_DATA(SD_D1_MARK, PS3_9_FN2, PTI1_FN),
894 PINMUX_DATA(D8_MARK, PS3_8_FN1, PTI0_FN),
895 PINMUX_DATA(SD_D0_MARK, PS3_8_FN2, PTI0_FN),
785 896
786 /* PTJ FN */ 897 /* PTJ FN */
787 PINMUX_DATA(RXD3_MARK, PTJ7_FN), 898 PINMUX_DATA(RTS3_MARK, PTJ6_FN),
788 PINMUX_DATA(TXD3_MARK, PTJ6_FN), 899 PINMUX_DATA(CTS3_MARK, PTJ5_FN),
789 PINMUX_DATA(RXD2_MARK, PTJ5_FN), 900 PINMUX_DATA(TXD3_MARK, PTJ4_FN),
790 PINMUX_DATA(TXD2_MARK, PTJ4_FN), 901 PINMUX_DATA(RXD3_MARK, PTJ3_FN),
791 PINMUX_DATA(COM1_TXD_MARK, PTJ3_FN), 902 PINMUX_DATA(RTS4_MARK, PTJ2_FN),
792 PINMUX_DATA(COM1_RXD_MARK, PTJ2_FN), 903 PINMUX_DATA(RXD4_MARK, PTJ1_FN),
793 PINMUX_DATA(COM1_RTS_MARK, PTJ1_FN), 904 PINMUX_DATA(TXD4_MARK, PTJ0_FN),
794 PINMUX_DATA(COM1_CTS_MARK, PTJ0_FN),
795 905
796 /* PTK FN */ 906 /* PTK FN */
797 PINMUX_DATA(COM2_TXD_MARK, PTK7_FN), 907 PINMUX_DATA(COM2_TXD_MARK, PS3_7_FN1, PTK7_FN),
908 PINMUX_DATA(SCK2_MARK, PS3_7_FN2, PTK7_FN),
798 PINMUX_DATA(COM2_RXD_MARK, PTK6_FN), 909 PINMUX_DATA(COM2_RXD_MARK, PTK6_FN),
799 PINMUX_DATA(COM2_RTS_MARK, PTK5_FN), 910 PINMUX_DATA(COM2_RTS_MARK, PTK5_FN),
800 PINMUX_DATA(COM2_CTS_MARK, PTK4_FN), 911 PINMUX_DATA(COM2_CTS_MARK, PTK4_FN),
801 PINMUX_DATA(COM2_DTR_MARK, PTK3_FN), 912 PINMUX_DATA(COM2_DTR_MARK, PTK3_FN),
802 PINMUX_DATA(COM2_DSR_MARK, PTK2_FN), 913 PINMUX_DATA(COM2_DSR_MARK, PS3_2_FN1, PTK2_FN),
803 PINMUX_DATA(COM2_DCD_MARK, PTK1_FN), 914 PINMUX_DATA(SCK4_MARK, PS3_2_FN2, PTK2_FN),
804 PINMUX_DATA(COM2_RI_MARK, PTK0_FN), 915 PINMUX_DATA(COM2_DCD_MARK, PS3_1_FN1, PTK1_FN),
916 PINMUX_DATA(SCK3_MARK, PS3_1_FN2, PTK1_FN),
917 PINMUX_DATA(CLKOUT_MARK, PTK0_FN),
805 918
806 /* PTL FN */ 919 /* PTL FN */
807 PINMUX_DATA(RAC_TXD_MARK, PTL7_FN), 920 PINMUX_DATA(RAC_RXD_MARK, PS4_14_FN1, PTL6_FN),
808 PINMUX_DATA(RAC_RXD_MARK, PTL6_FN), 921 PINMUX_DATA(RXD2_MARK, PS4_14_FN2, PTL6_FN),
809 PINMUX_DATA(RAC_RTS_MARK, PTL5_FN), 922 PINMUX_DATA(RAC_RTS_MARK, PS4_13_FN1, PTL5_FN),
810 PINMUX_DATA(RAC_CTS_MARK, PTL4_FN), 923 PINMUX_DATA(CS5_MARK, PS4_13_FN2, PTL5_FN),
924 PINMUX_DATA(RAC_CTS_MARK, PS4_12_FN1, PTL4_FN),
925 PINMUX_DATA(CS6_MARK, PS4_12_FN2, PTL4_FN),
811 PINMUX_DATA(RAC_DTR_MARK, PTL3_FN), 926 PINMUX_DATA(RAC_DTR_MARK, PTL3_FN),
812 PINMUX_DATA(RAC_DSR_MARK, PTL2_FN), 927 PINMUX_DATA(RAC_DSR_MARK, PS4_10_FN1, PTL2_FN),
813 PINMUX_DATA(RAC_DCD_MARK, PTL1_FN), 928 PINMUX_DATA(AUDSYNC_MARK, PS4_10_FN2, PTL2_FN),
814 PINMUX_DATA(RAC_RI_MARK, PTL0_FN), 929 PINMUX_DATA(RAC_DCD_MARK, PS4_9_FN1, PTL1_FN),
930 PINMUX_DATA(AUDCK_MARK, PS4_9_FN2, PTL1_FN),
931 PINMUX_DATA(RAC_TXD_MARK, PS4_8_FN1, PTL0_FN),
932 PINMUX_DATA(TXD2_MARK, PS4_8_FN1, PTL0_FN),
815 933
816 /* PTM FN */ 934 /* PTM FN */
817 PINMUX_DATA(WP_MARK, PTM6_FN), 935 PINMUX_DATA(CS4_MARK, PTM7_FN),
818 PINMUX_DATA(FMS0_MARK, PTM5_FN), 936 PINMUX_DATA(RD_MARK, PTM6_FN),
819 PINMUX_DATA(FMS1_MARK, PTM4_FN), 937 PINMUX_DATA(WE0_MARK, PTM7_FN),
938 PINMUX_DATA(CS0_MARK, PTM4_FN),
820 PINMUX_DATA(SDA6_MARK, PTM3_FN), 939 PINMUX_DATA(SDA6_MARK, PTM3_FN),
821 PINMUX_DATA(SCL6_MARK, PTM2_FN), 940 PINMUX_DATA(SCL6_MARK, PTM2_FN),
822 PINMUX_DATA(SDA7_MARK, PTM1_FN), 941 PINMUX_DATA(SDA7_MARK, PTM1_FN),
823 PINMUX_DATA(SCL7_MARK, PTM0_FN), 942 PINMUX_DATA(SCL7_MARK, PTM0_FN),
824 943
825 /* PTN FN */ 944 /* PTN FN */
826 PINMUX_DATA(SCK2_MARK, PS4_15_FN1, PTN7_FN), 945 PINMUX_DATA(VBUS_EN_MARK, PTN6_FN),
827 PINMUX_DATA(EVENT7_MARK, PS4_15_FN2, PTN7_FN), 946 PINMUX_DATA(VBUS_OC_MARK, PTN5_FN),
828 PINMUX_DATA(RTS4_MARK, PS4_14_FN1, PTN6_FN), 947 PINMUX_DATA(JMCTCK_MARK, PS4_4_FN1, PTN4_FN),
829 PINMUX_DATA(EVENT6_MARK, PS4_14_FN2, PTN6_FN), 948 PINMUX_DATA(SGPIO1_CLK_MARK, PS4_4_FN2, PTN4_FN),
830 PINMUX_DATA(RTS3_MARK, PS4_13_FN1, PTN5_FN), 949 PINMUX_DATA(JMCTMS_MARK, PS4_3_FN1, PTN5_FN),
831 PINMUX_DATA(EVENT5_MARK, PS4_13_FN2, PTN5_FN), 950 PINMUX_DATA(SGPIO1_LOAD_MARK, PS4_3_FN2, PTN5_FN),
832 PINMUX_DATA(RTS2_MARK, PS4_12_FN1, PTN4_FN), 951 PINMUX_DATA(JMCTDO_MARK, PS4_2_FN1, PTN2_FN),
833 PINMUX_DATA(EVENT4_MARK, PS4_12_FN2, PTN4_FN), 952 PINMUX_DATA(SGPIO1_DO_MARK, PS4_2_FN2, PTN2_FN),
834 PINMUX_DATA(CTS4_MARK, PS4_11_FN1, PTN3_FN), 953 PINMUX_DATA(JMCTDI_MARK, PS4_1_FN1, PTN1_FN),
835 PINMUX_DATA(EVENT3_MARK, PS4_11_FN2, PTN3_FN), 954 PINMUX_DATA(SGPIO1_DI_MARK, PS4_1_FN2, PTN1_FN),
836 PINMUX_DATA(CTS3_MARK, PS4_10_FN1, PTN2_FN), 955 PINMUX_DATA(JMCTRST_MARK, PS4_0_FN1, PTN0_FN),
837 PINMUX_DATA(EVENT2_MARK, PS4_10_FN2, PTN2_FN), 956 PINMUX_DATA(SUB_CLKIN_MARK, PS4_0_FN2, PTN0_FN),
838 PINMUX_DATA(CTS2_MARK, PS4_9_FN1, PTN1_FN),
839 PINMUX_DATA(EVENT1_MARK, PS4_9_FN2, PTN1_FN),
840 PINMUX_DATA(EVENT0_MARK, PTN0_FN),
841 957
842 /* PTO FN */ 958 /* PTO FN */
843 PINMUX_DATA(SGPIO0_CLK_MARK, PTO7_FN), 959 PINMUX_DATA(SGPIO0_CLK_MARK, PTO7_FN),
844 PINMUX_DATA(SGPIO0_LOAD_MARK, PTO6_FN), 960 PINMUX_DATA(SGPIO0_LOAD_MARK, PTO6_FN),
845 PINMUX_DATA(SGPIO0_DI_MARK, PTO5_FN), 961 PINMUX_DATA(SGPIO0_DI_MARK, PTO5_FN),
846 PINMUX_DATA(SGPIO0_DO_MARK, PTO4_FN), 962 PINMUX_DATA(SGPIO0_DO_MARK, PTO4_FN),
847 PINMUX_DATA(SGPIO1_CLK_MARK, PTO3_FN), 963 PINMUX_DATA(SGPIO2_CLK_MARK, PS5_11_FN1, PTO3_FN),
848 PINMUX_DATA(SGPIO1_LOAD_MARK, PTO2_FN), 964 PINMUX_DATA(COM1_TXD_MARK, PS5_11_FN2, PTO3_FN),
849 PINMUX_DATA(SGPIO1_DI_MARK, PTO1_FN), 965 PINMUX_DATA(SGPIO2_LOAD_MARK, PS5_10_FN1, PTO2_FN),
850 PINMUX_DATA(SGPIO1_DO_MARK, PTO0_FN), 966 PINMUX_DATA(COM1_RXD_MARK, PS5_10_FN2, PTO2_FN),
967 PINMUX_DATA(SGPIO2_DI_MARK, PS5_9_FN1, PTO1_FN),
968 PINMUX_DATA(COM1_RTS_MARK, PS5_9_FN2, PTO1_FN),
969 PINMUX_DATA(SGPIO2_DO_MARK, PS5_8_FN1, PTO0_FN),
970 PINMUX_DATA(COM1_CTS_MARK, PS5_8_FN2, PTO0_FN),
851 971
852 /* PTP FN */ 972 /* PTP FN */
853 PINMUX_DATA(JMCTCK_MARK, PTP6_FN),
854 PINMUX_DATA(JMCTMS_MARK, PTP5_FN),
855 PINMUX_DATA(JMCTDO_MARK, PTP4_FN),
856 PINMUX_DATA(JMCTDI_MARK, PTP3_FN),
857 PINMUX_DATA(JMCRST_MARK, PTP2_FN),
858 PINMUX_DATA(SCK4_MARK, PTP1_FN),
859 PINMUX_DATA(SCK3_MARK, PTP0_FN),
860 973
861 /* PTQ FN */ 974 /* PTQ FN */
862 PINMUX_DATA(LAD3_MARK, PTQ6_FN), 975 PINMUX_DATA(LAD3_MARK, PTQ6_FN),
@@ -864,8 +977,8 @@ static pinmux_enum_t pinmux_data[] = {
864 PINMUX_DATA(LAD1_MARK, PTQ4_FN), 977 PINMUX_DATA(LAD1_MARK, PTQ4_FN),
865 PINMUX_DATA(LAD0_MARK, PTQ3_FN), 978 PINMUX_DATA(LAD0_MARK, PTQ3_FN),
866 PINMUX_DATA(LFRAME_MARK, PTQ2_FN), 979 PINMUX_DATA(LFRAME_MARK, PTQ2_FN),
867 PINMUX_DATA(SCK4_MARK, PTQ1_FN), 980 PINMUX_DATA(LRESET_MARK, PTQ1_FN),
868 PINMUX_DATA(SCK3_MARK, PTQ0_FN), 981 PINMUX_DATA(LCLK_MARK, PTQ0_FN),
869 982
870 /* PTR FN */ 983 /* PTR FN */
871 PINMUX_DATA(SDA8_MARK, PTR7_FN), /* DDC3? */ 984 PINMUX_DATA(SDA8_MARK, PTR7_FN), /* DDC3? */
@@ -888,58 +1001,84 @@ static pinmux_enum_t pinmux_data[] = {
888 PINMUX_DATA(SCL3_MARK, PTS0_FN), 1001 PINMUX_DATA(SCL3_MARK, PTS0_FN),
889 1002
890 /* PTT FN */ 1003 /* PTT FN */
891 PINMUX_DATA(AUDSYNC_MARK, PTS5_FN), 1004 PINMUX_DATA(PWMX7_MARK, PS5_7_FN1, PTT7_FN),
892 PINMUX_DATA(AUDCK_MARK, PTS4_FN), 1005 PINMUX_DATA(AUDATA3_MARK, PS5_7_FN2, PTT7_FN),
893 PINMUX_DATA(AUDATA3_MARK, PS4_3_FN1, PTS3_FN), 1006 PINMUX_DATA(PWMX6_MARK, PS5_6_FN1, PTT6_FN),
894 PINMUX_DATA(PWX7_MARK, PS4_3_FN2, PTS3_FN), 1007 PINMUX_DATA(AUDATA2_MARK, PS5_6_FN2, PTT6_FN),
895 PINMUX_DATA(AUDATA2_MARK, PS4_2_FN1, PTS2_FN), 1008 PINMUX_DATA(PWMX5_MARK, PS5_5_FN1, PTT5_FN),
896 PINMUX_DATA(PWX6_MARK, PS4_2_FN2, PTS2_FN), 1009 PINMUX_DATA(AUDATA1_MARK, PS5_5_FN2, PTT5_FN),
897 PINMUX_DATA(AUDATA1_MARK, PS4_1_FN1, PTS1_FN), 1010 PINMUX_DATA(PWMX4_MARK, PS5_4_FN1, PTT4_FN),
898 PINMUX_DATA(PWX5_MARK, PS4_1_FN2, PTS1_FN), 1011 PINMUX_DATA(AUDATA0_MARK, PS5_4_FN2, PTT4_FN),
899 PINMUX_DATA(AUDATA0_MARK, PS4_0_FN1, PTS0_FN), 1012 PINMUX_DATA(PWMX3_MARK, PS5_3_FN1, PTT3_FN),
900 PINMUX_DATA(PWX4_MARK, PS4_0_FN2, PTS0_FN), 1013 PINMUX_DATA(STATUS1_MARK, PS5_3_FN2, PTT3_FN),
1014 PINMUX_DATA(PWMX2_MARK, PS5_2_FN1, PTT2_FN),
1015 PINMUX_DATA(STATUS0_MARK, PS5_2_FN2, PTT2_FN),
1016 PINMUX_DATA(PWMX1_MARK, PTT1_FN),
1017 PINMUX_DATA(PWMX0_MARK, PTT0_FN),
901 1018
902 /* PTU FN */ 1019 /* PTU FN */
903 PINMUX_DATA(CS6_MARK, PTU7_FN), 1020 PINMUX_DATA(LGPIO7_MARK, PS6_15_FN1, PTU7_FN),
904 PINMUX_DATA(CS5_MARK, PTU6_FN), 1021 PINMUX_DATA(APMONCTL_O_MARK, PS6_15_FN2, PTU7_FN),
905 PINMUX_DATA(CS4_MARK, PTU5_FN), 1022 PINMUX_DATA(LGPIO6_MARK, PS6_14_FN1, PTU6_FN),
906 PINMUX_DATA(CS0_MARK, PTU4_FN), 1023 PINMUX_DATA(APMPWBTOUT_O_MARK, PS6_14_FN2, PTU6_FN),
907 PINMUX_DATA(RD_MARK, PTU3_FN), 1024 PINMUX_DATA(LGPIO5_MARK, PS6_13_FN1, PTU5_FN),
908 PINMUX_DATA(WE0_MARK, PTU2_FN), 1025 PINMUX_DATA(APMSCI_O_MARK, PS6_13_FN2, PTU5_FN),
909 PINMUX_DATA(A25_MARK, PS5_9_FN1, PTU1_FN), 1026 PINMUX_DATA(LGPIO4_MARK, PS6_12_FN1, PTU4_FN),
910 PINMUX_DATA(DREQ0_MARK, PS5_9_FN2, PTU1_FN), 1027 PINMUX_DATA(APMVDDON_MARK, PS6_12_FN2, PTU4_FN),
911 PINMUX_DATA(A24_MARK, PS5_8_FN1, PTU0_FN), 1028 PINMUX_DATA(LGPIO3_MARK, PS6_11_FN1, PTU3_FN),
912 PINMUX_DATA(DACK0_MARK, PS5_8_FN2, PTU0_FN), 1029 PINMUX_DATA(APMSLPBTN_MARK, PS6_11_FN2, PTU3_FN),
1030 PINMUX_DATA(LGPIO2_MARK, PS6_10_FN1, PTU2_FN),
1031 PINMUX_DATA(APMPWRBTN_MARK, PS6_10_FN2, PTU2_FN),
1032 PINMUX_DATA(LGPIO1_MARK, PS6_9_FN1, PTU1_FN),
1033 PINMUX_DATA(APMS5N_MARK, PS6_9_FN2, PTU1_FN),
1034 PINMUX_DATA(LGPIO0_MARK, PS6_8_FN1, PTU0_FN),
1035 PINMUX_DATA(APMS3N_MARK, PS6_8_FN2, PTU0_FN),
913 1036
914 /* PTV FN */ 1037 /* PTV FN */
915 PINMUX_DATA(A23_MARK, PS5_7_FN1, PTV7_FN), 1038 PINMUX_DATA(A23_MARK, PS6_7_FN1, PTV7_FN),
916 PINMUX_DATA(TEND0_MARK, PS5_7_FN2, PTV7_FN), 1039 PINMUX_DATA(COM2_RI_MARK, PS6_7_FN2, PTV7_FN),
917 PINMUX_DATA(A22_MARK, PS5_6_FN1, PTV6_FN), 1040 PINMUX_DATA(A22_MARK, PS6_6_FN1, PTV6_FN),
918 PINMUX_DATA(DREQ1_MARK, PS5_6_FN2, PTV6_FN), 1041 PINMUX_DATA(R_SPI_MOSI_MARK, PS6_6_FN2, PTV6_FN),
919 PINMUX_DATA(A21_MARK, PS5_5_FN1, PTV5_FN), 1042 PINMUX_DATA(A21_MARK, PS6_5_FN1, PTV5_FN),
920 PINMUX_DATA(DACK1_MARK, PS5_5_FN2, PTV5_FN), 1043 PINMUX_DATA(R_SPI_MISO_MARK, PS6_5_FN2, PTV5_FN),
921 PINMUX_DATA(A20_MARK, PS5_4_FN1, PTV4_FN), 1044 PINMUX_DATA(A20_MARK, PS6_4_FN1, PTV4_FN),
922 PINMUX_DATA(TEND1_MARK, PS5_4_FN2, PTV4_FN), 1045 PINMUX_DATA(R_SPI_RSPCK_MARK, PS6_4_FN2, PTV4_FN),
923 PINMUX_DATA(A19_MARK, PTV3_FN), 1046 PINMUX_DATA(A19_MARK, PS6_3_FN1, PTV3_FN),
924 PINMUX_DATA(A18_MARK, PTV2_FN), 1047 PINMUX_DATA(R_SPI_SSL0_MARK, PS6_3_FN2, PTV3_FN),
925 PINMUX_DATA(A17_MARK, PTV1_FN), 1048 PINMUX_DATA(A18_MARK, PS6_2_FN1, PTV2_FN),
926 PINMUX_DATA(A16_MARK, PTV0_FN), 1049 PINMUX_DATA(R_SPI_SSL1_MARK, PS6_2_FN2, PTV2_FN),
1050 PINMUX_DATA(A17_MARK, PS6_1_FN1, PTV1_FN),
1051 PINMUX_DATA(EVENT7_MARK, PS6_1_FN2, PTV1_FN),
1052 PINMUX_DATA(A16_MARK, PS6_0_FN1, PTV0_FN),
1053 PINMUX_DATA(EVENT6_MARK, PS6_0_FN1, PTV0_FN),
927 1054
928 /* PTW FN */ 1055 /* PTW FN */
929 PINMUX_DATA(A15_MARK, PTW7_FN), 1056 PINMUX_DATA(A15_MARK, PS7_15_FN1, PTW7_FN),
930 PINMUX_DATA(A14_MARK, PTW6_FN), 1057 PINMUX_DATA(EVENT5_MARK, PS7_15_FN2, PTW7_FN),
931 PINMUX_DATA(A13_MARK, PTW5_FN), 1058 PINMUX_DATA(A14_MARK, PS7_14_FN1, PTW6_FN),
932 PINMUX_DATA(A12_MARK, PTW4_FN), 1059 PINMUX_DATA(EVENT4_MARK, PS7_14_FN2, PTW6_FN),
933 PINMUX_DATA(A11_MARK, PTW3_FN), 1060 PINMUX_DATA(A13_MARK, PS7_13_FN1, PTW5_FN),
934 PINMUX_DATA(A10_MARK, PTW2_FN), 1061 PINMUX_DATA(EVENT3_MARK, PS7_13_FN2, PTW5_FN),
935 PINMUX_DATA(A9_MARK, PTW1_FN), 1062 PINMUX_DATA(A12_MARK, PS7_12_FN1, PTW4_FN),
936 PINMUX_DATA(A8_MARK, PTW0_FN), 1063 PINMUX_DATA(EVENT2_MARK, PS7_12_FN2, PTW4_FN),
1064 PINMUX_DATA(A11_MARK, PS7_11_FN1, PTW3_FN),
1065 PINMUX_DATA(EVENT1_MARK, PS7_11_FN2, PTW3_FN),
1066 PINMUX_DATA(A10_MARK, PS7_10_FN1, PTW2_FN),
1067 PINMUX_DATA(EVENT0_MARK, PS7_10_FN2, PTW2_FN),
1068 PINMUX_DATA(A9_MARK, PS7_9_FN1, PTW1_FN),
1069 PINMUX_DATA(CTS4_MARK, PS7_9_FN2, PTW1_FN),
1070 PINMUX_DATA(A8_MARK, PS7_8_FN1, PTW0_FN),
1071 PINMUX_DATA(CTS2_MARK, PS7_8_FN2, PTW0_FN),
937 1072
938 /* PTX FN */ 1073 /* PTX FN */
939 PINMUX_DATA(A7_MARK, PTX7_FN), 1074 PINMUX_DATA(A7_MARK, PS7_7_FN1, PTX7_FN),
940 PINMUX_DATA(A6_MARK, PTX6_FN), 1075 PINMUX_DATA(RTS2_MARK, PS7_7_FN2, PTX7_FN),
941 PINMUX_DATA(A5_MARK, PTX5_FN), 1076 PINMUX_DATA(A6_MARK, PS7_6_FN1, PTX6_FN),
942 PINMUX_DATA(A4_MARK, PTX4_FN), 1077 PINMUX_DATA(SIM_D_MARK, PS7_6_FN2, PTX6_FN),
1078 PINMUX_DATA(A5_MARK, PS7_5_FN1, PTX5_FN),
1079 PINMUX_DATA(SIM_CLK_MARK, PS7_5_FN2, PTX5_FN),
1080 PINMUX_DATA(A4_MARK, PS7_4_FN1, PTX4_FN),
1081 PINMUX_DATA(SIM_RST_MARK, PS7_4_FN2, PTX4_FN),
943 PINMUX_DATA(A3_MARK, PTX3_FN), 1082 PINMUX_DATA(A3_MARK, PTX3_FN),
944 PINMUX_DATA(A2_MARK, PTX2_FN), 1083 PINMUX_DATA(A2_MARK, PTX2_FN),
945 PINMUX_DATA(A1_MARK, PTX1_FN), 1084 PINMUX_DATA(A1_MARK, PTX1_FN),
@@ -954,6 +1093,24 @@ static pinmux_enum_t pinmux_data[] = {
954 PINMUX_DATA(D2_MARK, PTY2_FN), 1093 PINMUX_DATA(D2_MARK, PTY2_FN),
955 PINMUX_DATA(D1_MARK, PTY1_FN), 1094 PINMUX_DATA(D1_MARK, PTY1_FN),
956 PINMUX_DATA(D0_MARK, PTY0_FN), 1095 PINMUX_DATA(D0_MARK, PTY0_FN),
1096
1097 /* PTZ FN */
1098 PINMUX_DATA(MMCDAT7_MARK, PS8_15_FN1, PTZ7_FN),
1099 PINMUX_DATA(ON_DQ7_MARK, PS8_15_FN2, PTZ7_FN),
1100 PINMUX_DATA(MMCDAT6_MARK, PS8_14_FN1, PTZ6_FN),
1101 PINMUX_DATA(ON_DQ6_MARK, PS8_14_FN2, PTZ6_FN),
1102 PINMUX_DATA(MMCDAT5_MARK, PS8_13_FN1, PTZ5_FN),
1103 PINMUX_DATA(ON_DQ5_MARK, PS8_13_FN2, PTZ5_FN),
1104 PINMUX_DATA(MMCDAT4_MARK, PS8_12_FN1, PTZ4_FN),
1105 PINMUX_DATA(ON_DQ4_MARK, PS8_12_FN2, PTZ4_FN),
1106 PINMUX_DATA(MMCDAT3_MARK, PS8_11_FN1, PTZ3_FN),
1107 PINMUX_DATA(ON_DQ3_MARK, PS8_11_FN2, PTZ3_FN),
1108 PINMUX_DATA(MMCDAT2_MARK, PS8_10_FN1, PTZ2_FN),
1109 PINMUX_DATA(ON_DQ2_MARK, PS8_10_FN2, PTZ2_FN),
1110 PINMUX_DATA(MMCDAT1_MARK, PS8_9_FN1, PTZ1_FN),
1111 PINMUX_DATA(ON_DQ1_MARK, PS8_9_FN2, PTZ1_FN),
1112 PINMUX_DATA(MMCDAT0_MARK, PS8_8_FN1, PTZ0_FN),
1113 PINMUX_DATA(ON_DQ0_MARK, PS8_8_FN2, PTZ0_FN),
957}; 1114};
958 1115
959static struct pinmux_gpio pinmux_gpios[] = { 1116static struct pinmux_gpio pinmux_gpios[] = {
@@ -1048,7 +1205,6 @@ static struct pinmux_gpio pinmux_gpios[] = {
1048 PINMUX_GPIO(GPIO_PTI0, PTI0_DATA), 1205 PINMUX_GPIO(GPIO_PTI0, PTI0_DATA),
1049 1206
1050 /* PTJ */ 1207 /* PTJ */
1051 PINMUX_GPIO(GPIO_PTJ7, PTJ7_DATA),
1052 PINMUX_GPIO(GPIO_PTJ6, PTJ6_DATA), 1208 PINMUX_GPIO(GPIO_PTJ6, PTJ6_DATA),
1053 PINMUX_GPIO(GPIO_PTJ5, PTJ5_DATA), 1209 PINMUX_GPIO(GPIO_PTJ5, PTJ5_DATA),
1054 PINMUX_GPIO(GPIO_PTJ4, PTJ4_DATA), 1210 PINMUX_GPIO(GPIO_PTJ4, PTJ4_DATA),
@@ -1068,7 +1224,6 @@ static struct pinmux_gpio pinmux_gpios[] = {
1068 PINMUX_GPIO(GPIO_PTK0, PTK0_DATA), 1224 PINMUX_GPIO(GPIO_PTK0, PTK0_DATA),
1069 1225
1070 /* PTL */ 1226 /* PTL */
1071 PINMUX_GPIO(GPIO_PTL7, PTL7_DATA),
1072 PINMUX_GPIO(GPIO_PTL6, PTL6_DATA), 1227 PINMUX_GPIO(GPIO_PTL6, PTL6_DATA),
1073 PINMUX_GPIO(GPIO_PTL5, PTL5_DATA), 1228 PINMUX_GPIO(GPIO_PTL5, PTL5_DATA),
1074 PINMUX_GPIO(GPIO_PTL4, PTL4_DATA), 1229 PINMUX_GPIO(GPIO_PTL4, PTL4_DATA),
@@ -1078,6 +1233,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
1078 PINMUX_GPIO(GPIO_PTL0, PTL0_DATA), 1233 PINMUX_GPIO(GPIO_PTL0, PTL0_DATA),
1079 1234
1080 /* PTM */ 1235 /* PTM */
1236 PINMUX_GPIO(GPIO_PTM7, PTM7_DATA),
1081 PINMUX_GPIO(GPIO_PTM6, PTM6_DATA), 1237 PINMUX_GPIO(GPIO_PTM6, PTM6_DATA),
1082 PINMUX_GPIO(GPIO_PTM5, PTM5_DATA), 1238 PINMUX_GPIO(GPIO_PTM5, PTM5_DATA),
1083 PINMUX_GPIO(GPIO_PTM4, PTM4_DATA), 1239 PINMUX_GPIO(GPIO_PTM4, PTM4_DATA),
@@ -1087,7 +1243,6 @@ static struct pinmux_gpio pinmux_gpios[] = {
1087 PINMUX_GPIO(GPIO_PTM0, PTM0_DATA), 1243 PINMUX_GPIO(GPIO_PTM0, PTM0_DATA),
1088 1244
1089 /* PTN */ 1245 /* PTN */
1090 PINMUX_GPIO(GPIO_PTN7, PTN7_DATA),
1091 PINMUX_GPIO(GPIO_PTN6, PTN6_DATA), 1246 PINMUX_GPIO(GPIO_PTN6, PTN6_DATA),
1092 PINMUX_GPIO(GPIO_PTN5, PTN5_DATA), 1247 PINMUX_GPIO(GPIO_PTN5, PTN5_DATA),
1093 PINMUX_GPIO(GPIO_PTN4, PTN4_DATA), 1248 PINMUX_GPIO(GPIO_PTN4, PTN4_DATA),
@@ -1107,6 +1262,7 @@ static struct pinmux_gpio pinmux_gpios[] = {
1107 PINMUX_GPIO(GPIO_PTO0, PTO0_DATA), 1262 PINMUX_GPIO(GPIO_PTO0, PTO0_DATA),
1108 1263
1109 /* PTP */ 1264 /* PTP */
1265 PINMUX_GPIO(GPIO_PTP7, PTP7_DATA),
1110 PINMUX_GPIO(GPIO_PTP6, PTP6_DATA), 1266 PINMUX_GPIO(GPIO_PTP6, PTP6_DATA),
1111 PINMUX_GPIO(GPIO_PTP5, PTP5_DATA), 1267 PINMUX_GPIO(GPIO_PTP5, PTP5_DATA),
1112 PINMUX_GPIO(GPIO_PTP4, PTP4_DATA), 1268 PINMUX_GPIO(GPIO_PTP4, PTP4_DATA),
@@ -1145,6 +1301,8 @@ static struct pinmux_gpio pinmux_gpios[] = {
1145 PINMUX_GPIO(GPIO_PTS0, PTS0_DATA), 1301 PINMUX_GPIO(GPIO_PTS0, PTS0_DATA),
1146 1302
1147 /* PTT */ 1303 /* PTT */
1304 PINMUX_GPIO(GPIO_PTT7, PTT7_DATA),
1305 PINMUX_GPIO(GPIO_PTT6, PTT6_DATA),
1148 PINMUX_GPIO(GPIO_PTT5, PTT5_DATA), 1306 PINMUX_GPIO(GPIO_PTT5, PTT5_DATA),
1149 PINMUX_GPIO(GPIO_PTT4, PTT4_DATA), 1307 PINMUX_GPIO(GPIO_PTT4, PTT4_DATA),
1150 PINMUX_GPIO(GPIO_PTT3, PTT3_DATA), 1308 PINMUX_GPIO(GPIO_PTT3, PTT3_DATA),
@@ -1212,54 +1370,35 @@ static struct pinmux_gpio pinmux_gpios[] = {
1212 PINMUX_GPIO(GPIO_PTZ1, PTZ1_DATA), 1370 PINMUX_GPIO(GPIO_PTZ1, PTZ1_DATA),
1213 PINMUX_GPIO(GPIO_PTZ0, PTZ0_DATA), 1371 PINMUX_GPIO(GPIO_PTZ0, PTZ0_DATA),
1214 1372
1215 /* PTA (mobule: LBSC, CPG, LPC) */ 1373 /* PTA (mobule: LBSC, RGMII) */
1216 PINMUX_GPIO(GPIO_FN_BS, BS_MARK), 1374 PINMUX_GPIO(GPIO_FN_BS, BS_MARK),
1217 PINMUX_GPIO(GPIO_FN_RDWR, RDWR_MARK), 1375 PINMUX_GPIO(GPIO_FN_RDWR, RDWR_MARK),
1218 PINMUX_GPIO(GPIO_FN_WE1, WE1_MARK), 1376 PINMUX_GPIO(GPIO_FN_WE1, WE1_MARK),
1219 PINMUX_GPIO(GPIO_FN_RDY, RDY_MARK), 1377 PINMUX_GPIO(GPIO_FN_RDY, RDY_MARK),
1220 PINMUX_GPIO(GPIO_FN_MD10, MD10_MARK),
1221 PINMUX_GPIO(GPIO_FN_MD9, MD9_MARK),
1222 PINMUX_GPIO(GPIO_FN_MD8, MD8_MARK),
1223 PINMUX_GPIO(GPIO_FN_LGPIO7, LGPIO7_MARK),
1224 PINMUX_GPIO(GPIO_FN_LGPIO6, LGPIO6_MARK),
1225 PINMUX_GPIO(GPIO_FN_LGPIO5, LGPIO5_MARK),
1226 PINMUX_GPIO(GPIO_FN_LGPIO4, LGPIO4_MARK),
1227 PINMUX_GPIO(GPIO_FN_LGPIO3, LGPIO3_MARK),
1228 PINMUX_GPIO(GPIO_FN_LGPIO2, LGPIO2_MARK),
1229 PINMUX_GPIO(GPIO_FN_LGPIO1, LGPIO1_MARK),
1230 PINMUX_GPIO(GPIO_FN_LGPIO0, LGPIO0_MARK),
1231
1232 /* PTB (mobule: LBSC, EtherC, SIM, LPC) */
1233 PINMUX_GPIO(GPIO_FN_D15, D15_MARK),
1234 PINMUX_GPIO(GPIO_FN_D14, D14_MARK),
1235 PINMUX_GPIO(GPIO_FN_D13, D13_MARK),
1236 PINMUX_GPIO(GPIO_FN_D12, D12_MARK),
1237 PINMUX_GPIO(GPIO_FN_D11, D11_MARK),
1238 PINMUX_GPIO(GPIO_FN_D10, D10_MARK),
1239 PINMUX_GPIO(GPIO_FN_D9, D9_MARK),
1240 PINMUX_GPIO(GPIO_FN_D8, D8_MARK),
1241 PINMUX_GPIO(GPIO_FN_ET0_MDC, ET0_MDC_MARK), 1378 PINMUX_GPIO(GPIO_FN_ET0_MDC, ET0_MDC_MARK),
1242 PINMUX_GPIO(GPIO_FN_ET0_MDIO, ET0_MDIO_MARK), 1379 PINMUX_GPIO(GPIO_FN_ET0_MDIO, ET0_MDC_MARK),
1243 PINMUX_GPIO(GPIO_FN_ET1_MDC, ET1_MDC_MARK), 1380 PINMUX_GPIO(GPIO_FN_ET1_MDC, ET1_MDC_MARK),
1244 PINMUX_GPIO(GPIO_FN_ET1_MDIO, ET1_MDIO_MARK), 1381 PINMUX_GPIO(GPIO_FN_ET1_MDIO, ET1_MDC_MARK),
1245 PINMUX_GPIO(GPIO_FN_WPSZ1, WPSZ1_MARK),
1246 PINMUX_GPIO(GPIO_FN_WPSZ0, WPSZ0_MARK),
1247 PINMUX_GPIO(GPIO_FN_FWID, FWID_MARK),
1248 PINMUX_GPIO(GPIO_FN_FLSHSZ, FLSHSZ_MARK),
1249 PINMUX_GPIO(GPIO_FN_LPC_SPIEN, LPC_SPIEN_MARK),
1250 PINMUX_GPIO(GPIO_FN_BASEL, BASEL_MARK),
1251
1252 /* PTC (mobule: SD) */
1253 PINMUX_GPIO(GPIO_FN_SD_WP, SD_WP_MARK),
1254 PINMUX_GPIO(GPIO_FN_SD_CD, SD_CD_MARK),
1255 PINMUX_GPIO(GPIO_FN_SD_CLK, SD_CLK_MARK),
1256 PINMUX_GPIO(GPIO_FN_SD_CMD, SD_CMD_MARK),
1257 PINMUX_GPIO(GPIO_FN_SD_D3, SD_D3_MARK),
1258 PINMUX_GPIO(GPIO_FN_SD_D2, SD_D2_MARK),
1259 PINMUX_GPIO(GPIO_FN_SD_D1, SD_D1_MARK),
1260 PINMUX_GPIO(GPIO_FN_SD_D0, SD_D0_MARK),
1261 1382
1262 /* PTD (mobule: INTC, SPI0, LBSC, CPG, ADC) */ 1383 /* PTB (mobule: INTC, ONFI, TMU) */
1384 PINMUX_GPIO(GPIO_FN_IRQ15, IRQ15_MARK),
1385 PINMUX_GPIO(GPIO_FN_IRQ14, IRQ14_MARK),
1386 PINMUX_GPIO(GPIO_FN_IRQ13, IRQ13_MARK),
1387 PINMUX_GPIO(GPIO_FN_IRQ12, IRQ12_MARK),
1388 PINMUX_GPIO(GPIO_FN_IRQ11, IRQ11_MARK),
1389 PINMUX_GPIO(GPIO_FN_IRQ10, IRQ10_MARK),
1390 PINMUX_GPIO(GPIO_FN_IRQ9, IRQ9_MARK),
1391 PINMUX_GPIO(GPIO_FN_IRQ8, IRQ8_MARK),
1392 PINMUX_GPIO(GPIO_FN_ON_NRE, ON_NRE_MARK),
1393 PINMUX_GPIO(GPIO_FN_ON_NWE, ON_NWE_MARK),
1394 PINMUX_GPIO(GPIO_FN_ON_NWP, ON_NWP_MARK),
1395 PINMUX_GPIO(GPIO_FN_ON_NCE0, ON_NCE0_MARK),
1396 PINMUX_GPIO(GPIO_FN_ON_R_B0, ON_R_B0_MARK),
1397 PINMUX_GPIO(GPIO_FN_ON_ALE, ON_ALE_MARK),
1398 PINMUX_GPIO(GPIO_FN_ON_CLE, ON_CLE_MARK),
1399 PINMUX_GPIO(GPIO_FN_TCLK, TCLK_MARK),
1400
1401 /* PTC (mobule: IRQ, PWMU) */
1263 PINMUX_GPIO(GPIO_FN_IRQ7, IRQ7_MARK), 1402 PINMUX_GPIO(GPIO_FN_IRQ7, IRQ7_MARK),
1264 PINMUX_GPIO(GPIO_FN_IRQ6, IRQ6_MARK), 1403 PINMUX_GPIO(GPIO_FN_IRQ6, IRQ6_MARK),
1265 PINMUX_GPIO(GPIO_FN_IRQ5, IRQ5_MARK), 1404 PINMUX_GPIO(GPIO_FN_IRQ5, IRQ5_MARK),
@@ -1268,80 +1407,102 @@ static struct pinmux_gpio pinmux_gpios[] = {
1268 PINMUX_GPIO(GPIO_FN_IRQ2, IRQ2_MARK), 1407 PINMUX_GPIO(GPIO_FN_IRQ2, IRQ2_MARK),
1269 PINMUX_GPIO(GPIO_FN_IRQ1, IRQ1_MARK), 1408 PINMUX_GPIO(GPIO_FN_IRQ1, IRQ1_MARK),
1270 PINMUX_GPIO(GPIO_FN_IRQ0, IRQ0_MARK), 1409 PINMUX_GPIO(GPIO_FN_IRQ0, IRQ0_MARK),
1271 PINMUX_GPIO(GPIO_FN_MD6, MD6_MARK), 1410 PINMUX_GPIO(GPIO_FN_PWMU0, PWMU0_MARK),
1272 PINMUX_GPIO(GPIO_FN_MD5, MD5_MARK), 1411 PINMUX_GPIO(GPIO_FN_PWMU1, PWMU1_MARK),
1273 PINMUX_GPIO(GPIO_FN_MD3, MD3_MARK), 1412 PINMUX_GPIO(GPIO_FN_PWMU2, PWMU2_MARK),
1274 PINMUX_GPIO(GPIO_FN_MD2, MD2_MARK), 1413 PINMUX_GPIO(GPIO_FN_PWMU3, PWMU3_MARK),
1275 PINMUX_GPIO(GPIO_FN_MD1, MD1_MARK), 1414 PINMUX_GPIO(GPIO_FN_PWMU4, PWMU4_MARK),
1276 PINMUX_GPIO(GPIO_FN_MD0, MD0_MARK), 1415 PINMUX_GPIO(GPIO_FN_PWMU5, PWMU5_MARK),
1277 PINMUX_GPIO(GPIO_FN_ADTRG1, ADTRG1_MARK), 1416
1278 PINMUX_GPIO(GPIO_FN_ADTRG0, ADTRG0_MARK), 1417 /* PTD (mobule: SPI0, DMAC) */
1418 PINMUX_GPIO(GPIO_FN_SP0_MOSI, SP0_MOSI_MARK),
1419 PINMUX_GPIO(GPIO_FN_SP0_MISO, SP0_MISO_MARK),
1420 PINMUX_GPIO(GPIO_FN_SP0_SCK, SP0_SCK_MARK),
1421 PINMUX_GPIO(GPIO_FN_SP0_SCK_FB, SP0_SCK_FB_MARK),
1422 PINMUX_GPIO(GPIO_FN_SP0_SS0, SP0_SS0_MARK),
1423 PINMUX_GPIO(GPIO_FN_SP0_SS1, SP0_SS1_MARK),
1424 PINMUX_GPIO(GPIO_FN_SP0_SS2, SP0_SS2_MARK),
1425 PINMUX_GPIO(GPIO_FN_SP0_SS3, SP0_SS3_MARK),
1426 PINMUX_GPIO(GPIO_FN_DREQ0, DREQ0_MARK),
1427 PINMUX_GPIO(GPIO_FN_DACK0, DACK0_MARK),
1428 PINMUX_GPIO(GPIO_FN_TEND0, TEND0_MARK),
1279 1429
1280 /* PTE (mobule: EtherC) */ 1430 /* PTE (mobule: RMII) */
1281 PINMUX_GPIO(GPIO_FN_ET0_CRS_DV, ET0_CRS_DV_MARK), 1431 PINMUX_GPIO(GPIO_FN_RMII0_CRS_DV, RMII0_CRS_DV_MARK),
1282 PINMUX_GPIO(GPIO_FN_ET0_TXD1, ET0_TXD1_MARK), 1432 PINMUX_GPIO(GPIO_FN_RMII0_TXD1, RMII0_TXD1_MARK),
1283 PINMUX_GPIO(GPIO_FN_ET0_TXD0, ET0_TXD0_MARK), 1433 PINMUX_GPIO(GPIO_FN_RMII0_TXD0, RMII0_TXD0_MARK),
1284 PINMUX_GPIO(GPIO_FN_ET0_TX_EN, ET0_TX_EN_MARK), 1434 PINMUX_GPIO(GPIO_FN_RMII0_TXEN, RMII0_TXEN_MARK),
1285 PINMUX_GPIO(GPIO_FN_ET0_REF_CLK, ET0_REF_CLK_MARK), 1435 PINMUX_GPIO(GPIO_FN_RMII0_REFCLK, RMII0_REFCLK_MARK),
1286 PINMUX_GPIO(GPIO_FN_ET0_RXD1, ET0_RXD1_MARK), 1436 PINMUX_GPIO(GPIO_FN_RMII0_RXD1, RMII0_RXD1_MARK),
1287 PINMUX_GPIO(GPIO_FN_ET0_RXD0, ET0_RXD0_MARK), 1437 PINMUX_GPIO(GPIO_FN_RMII0_RXD0, RMII0_RXD0_MARK),
1288 PINMUX_GPIO(GPIO_FN_ET0_RX_ER, ET0_RX_ER_MARK), 1438 PINMUX_GPIO(GPIO_FN_RMII0_RX_ER, RMII0_RX_ER_MARK),
1289 1439
1290 /* PTF (mobule: EtherC) */ 1440 /* PTF (mobule: RMII, SerMux) */
1291 PINMUX_GPIO(GPIO_FN_ET1_CRS_DV, ET1_CRS_DV_MARK), 1441 PINMUX_GPIO(GPIO_FN_RMII1_CRS_DV, RMII1_CRS_DV_MARK),
1292 PINMUX_GPIO(GPIO_FN_ET1_TXD1, ET1_TXD1_MARK), 1442 PINMUX_GPIO(GPIO_FN_RMII1_TXD1, RMII1_TXD1_MARK),
1293 PINMUX_GPIO(GPIO_FN_ET1_TXD0, ET1_TXD0_MARK), 1443 PINMUX_GPIO(GPIO_FN_RMII1_TXD0, RMII1_TXD0_MARK),
1294 PINMUX_GPIO(GPIO_FN_ET1_TX_EN, ET1_TX_EN_MARK), 1444 PINMUX_GPIO(GPIO_FN_RMII1_TXEN, RMII1_TXEN_MARK),
1295 PINMUX_GPIO(GPIO_FN_ET1_REF_CLK, ET1_REF_CLK_MARK), 1445 PINMUX_GPIO(GPIO_FN_RMII1_REFCLK, RMII1_REFCLK_MARK),
1296 PINMUX_GPIO(GPIO_FN_ET1_RXD1, ET1_RXD1_MARK), 1446 PINMUX_GPIO(GPIO_FN_RMII1_RXD1, RMII1_RXD1_MARK),
1297 PINMUX_GPIO(GPIO_FN_ET1_RXD0, ET1_RXD0_MARK), 1447 PINMUX_GPIO(GPIO_FN_RMII1_RXD0, RMII1_RXD0_MARK),
1298 PINMUX_GPIO(GPIO_FN_ET1_RX_ER, ET1_RX_ER_MARK), 1448 PINMUX_GPIO(GPIO_FN_RMII1_RX_ER, RMII1_RX_ER_MARK),
1299 1449 PINMUX_GPIO(GPIO_FN_RAC_RI, RAC_RI_MARK),
1300 /* PTG (mobule: SYSTEM, PWMX, LPC) */ 1450
1301 PINMUX_GPIO(GPIO_FN_STATUS0, STATUS0_MARK), 1451 /* PTG (mobule: system, LBSC, LPC, WDT, LPC, eMMC) */
1302 PINMUX_GPIO(GPIO_FN_STATUS1, STATUS1_MARK), 1452 PINMUX_GPIO(GPIO_FN_BOOTFMS, BOOTFMS_MARK),
1303 PINMUX_GPIO(GPIO_FN_PWX0, PWX0_MARK), 1453 PINMUX_GPIO(GPIO_FN_BOOTWP, BOOTWP_MARK),
1304 PINMUX_GPIO(GPIO_FN_PWX1, PWX1_MARK), 1454 PINMUX_GPIO(GPIO_FN_A25, A25_MARK),
1305 PINMUX_GPIO(GPIO_FN_PWX2, PWX2_MARK), 1455 PINMUX_GPIO(GPIO_FN_A24, A24_MARK),
1306 PINMUX_GPIO(GPIO_FN_PWX3, PWX3_MARK),
1307 PINMUX_GPIO(GPIO_FN_SERIRQ, SERIRQ_MARK), 1456 PINMUX_GPIO(GPIO_FN_SERIRQ, SERIRQ_MARK),
1308 PINMUX_GPIO(GPIO_FN_CLKRUN, CLKRUN_MARK), 1457 PINMUX_GPIO(GPIO_FN_WDTOVF, WDTOVF_MARK),
1309 PINMUX_GPIO(GPIO_FN_LPCPD, LPCPD_MARK), 1458 PINMUX_GPIO(GPIO_FN_LPCPD, LPCPD_MARK),
1310 PINMUX_GPIO(GPIO_FN_LDRQ, LDRQ_MARK), 1459 PINMUX_GPIO(GPIO_FN_LDRQ, LDRQ_MARK),
1460 PINMUX_GPIO(GPIO_FN_MMCCLK, MMCCLK_MARK),
1461 PINMUX_GPIO(GPIO_FN_MMCCMD, MMCCMD_MARK),
1311 1462
1312 /* PTH (mobule: TMU, SCIF234, SPI1, SPI0) */ 1463 /* PTH (mobule: SPI1, LPC, DMAC, ADC) */
1313 PINMUX_GPIO(GPIO_FN_TCLK, TCLK_MARK),
1314 PINMUX_GPIO(GPIO_FN_RXD4, RXD4_MARK),
1315 PINMUX_GPIO(GPIO_FN_TXD4, TXD4_MARK),
1316 PINMUX_GPIO(GPIO_FN_SP1_MOSI, SP1_MOSI_MARK), 1464 PINMUX_GPIO(GPIO_FN_SP1_MOSI, SP1_MOSI_MARK),
1317 PINMUX_GPIO(GPIO_FN_SP1_MISO, SP1_MISO_MARK), 1465 PINMUX_GPIO(GPIO_FN_SP1_MISO, SP1_MISO_MARK),
1318 PINMUX_GPIO(GPIO_FN_SP1_SCK, SP1_SCK_MARK), 1466 PINMUX_GPIO(GPIO_FN_SP1_SCK, SP1_SCK_MARK),
1319 PINMUX_GPIO(GPIO_FN_SP1_SCK_FB, SP1_SCK_FB_MARK), 1467 PINMUX_GPIO(GPIO_FN_SP1_SCK_FB, SP1_SCK_FB_MARK),
1320 PINMUX_GPIO(GPIO_FN_SP1_SS0, SP1_SS0_MARK), 1468 PINMUX_GPIO(GPIO_FN_SP1_SS0, SP1_SS0_MARK),
1321 PINMUX_GPIO(GPIO_FN_SP1_SS1, SP1_SS1_MARK), 1469 PINMUX_GPIO(GPIO_FN_SP1_SS1, SP1_SS1_MARK),
1322 PINMUX_GPIO(GPIO_FN_SP0_SS1, SP0_SS1_MARK), 1470 PINMUX_GPIO(GPIO_FN_WP, WP_MARK),
1471 PINMUX_GPIO(GPIO_FN_FMS0, FMS0_MARK),
1472 PINMUX_GPIO(GPIO_FN_TEND1, TEND1_MARK),
1473 PINMUX_GPIO(GPIO_FN_DREQ1, DREQ1_MARK),
1474 PINMUX_GPIO(GPIO_FN_DACK1, DACK1_MARK),
1475 PINMUX_GPIO(GPIO_FN_ADTRG1, ADTRG1_MARK),
1476 PINMUX_GPIO(GPIO_FN_ADTRG0, ADTRG0_MARK),
1323 1477
1324 /* PTI (mobule: INTC) */ 1478 /* PTI (mobule: LBSC, SDHI) */
1325 PINMUX_GPIO(GPIO_FN_IRQ15, IRQ15_MARK), 1479 PINMUX_GPIO(GPIO_FN_D15, D15_MARK),
1326 PINMUX_GPIO(GPIO_FN_IRQ14, IRQ14_MARK), 1480 PINMUX_GPIO(GPIO_FN_D14, D14_MARK),
1327 PINMUX_GPIO(GPIO_FN_IRQ13, IRQ13_MARK), 1481 PINMUX_GPIO(GPIO_FN_D13, D13_MARK),
1328 PINMUX_GPIO(GPIO_FN_IRQ12, IRQ12_MARK), 1482 PINMUX_GPIO(GPIO_FN_D12, D12_MARK),
1329 PINMUX_GPIO(GPIO_FN_IRQ11, IRQ11_MARK), 1483 PINMUX_GPIO(GPIO_FN_D11, D11_MARK),
1330 PINMUX_GPIO(GPIO_FN_IRQ10, IRQ10_MARK), 1484 PINMUX_GPIO(GPIO_FN_D10, D10_MARK),
1331 PINMUX_GPIO(GPIO_FN_IRQ9, IRQ9_MARK), 1485 PINMUX_GPIO(GPIO_FN_D9, D9_MARK),
1332 PINMUX_GPIO(GPIO_FN_IRQ8, IRQ8_MARK), 1486 PINMUX_GPIO(GPIO_FN_D8, D8_MARK),
1487 PINMUX_GPIO(GPIO_FN_SD_WP, SD_WP_MARK),
1488 PINMUX_GPIO(GPIO_FN_SD_CD, SD_CD_MARK),
1489 PINMUX_GPIO(GPIO_FN_SD_CLK, SD_CLK_MARK),
1490 PINMUX_GPIO(GPIO_FN_SD_CMD, SD_CMD_MARK),
1491 PINMUX_GPIO(GPIO_FN_SD_D3, SD_D3_MARK),
1492 PINMUX_GPIO(GPIO_FN_SD_D2, SD_D2_MARK),
1493 PINMUX_GPIO(GPIO_FN_SD_D1, SD_D1_MARK),
1494 PINMUX_GPIO(GPIO_FN_SD_D0, SD_D0_MARK),
1333 1495
1334 /* PTJ (mobule: SCIF234, SERMUX) */ 1496 /* PTJ (mobule: SCIF234, SERMUX) */
1335 PINMUX_GPIO(GPIO_FN_RXD3, RXD3_MARK), 1497 PINMUX_GPIO(GPIO_FN_RTS3, RTS3_MARK),
1498 PINMUX_GPIO(GPIO_FN_CTS3, CTS3_MARK),
1336 PINMUX_GPIO(GPIO_FN_TXD3, TXD3_MARK), 1499 PINMUX_GPIO(GPIO_FN_TXD3, TXD3_MARK),
1337 PINMUX_GPIO(GPIO_FN_RXD2, RXD2_MARK), 1500 PINMUX_GPIO(GPIO_FN_RXD3, RXD3_MARK),
1338 PINMUX_GPIO(GPIO_FN_TXD2, TXD2_MARK), 1501 PINMUX_GPIO(GPIO_FN_RTS4, RTS4_MARK),
1339 PINMUX_GPIO(GPIO_FN_COM1_TXD, COM1_TXD_MARK), 1502 PINMUX_GPIO(GPIO_FN_RXD4, RXD4_MARK),
1340 PINMUX_GPIO(GPIO_FN_COM1_RXD, COM1_RXD_MARK), 1503 PINMUX_GPIO(GPIO_FN_TXD4, TXD4_MARK),
1341 PINMUX_GPIO(GPIO_FN_COM1_RTS, COM1_RTS_MARK),
1342 PINMUX_GPIO(GPIO_FN_COM1_CTS, COM1_CTS_MARK),
1343 1504
1344 /* PTK (mobule: SERMUX) */ 1505 /* PTK (mobule: SERMUX, LBSC, SCIF) */
1345 PINMUX_GPIO(GPIO_FN_COM2_TXD, COM2_TXD_MARK), 1506 PINMUX_GPIO(GPIO_FN_COM2_TXD, COM2_TXD_MARK),
1346 PINMUX_GPIO(GPIO_FN_COM2_RXD, COM2_RXD_MARK), 1507 PINMUX_GPIO(GPIO_FN_COM2_RXD, COM2_RXD_MARK),
1347 PINMUX_GPIO(GPIO_FN_COM2_RTS, COM2_RTS_MARK), 1508 PINMUX_GPIO(GPIO_FN_COM2_RTS, COM2_RTS_MARK),
@@ -1349,62 +1510,65 @@ static struct pinmux_gpio pinmux_gpios[] = {
1349 PINMUX_GPIO(GPIO_FN_COM2_DTR, COM2_DTR_MARK), 1510 PINMUX_GPIO(GPIO_FN_COM2_DTR, COM2_DTR_MARK),
1350 PINMUX_GPIO(GPIO_FN_COM2_DSR, COM2_DSR_MARK), 1511 PINMUX_GPIO(GPIO_FN_COM2_DSR, COM2_DSR_MARK),
1351 PINMUX_GPIO(GPIO_FN_COM2_DCD, COM2_DCD_MARK), 1512 PINMUX_GPIO(GPIO_FN_COM2_DCD, COM2_DCD_MARK),
1352 PINMUX_GPIO(GPIO_FN_COM2_RI, COM2_RI_MARK), 1513 PINMUX_GPIO(GPIO_FN_CLKOUT, CLKOUT_MARK),
1514 PINMUX_GPIO(GPIO_FN_SCK2, SCK2_MARK),
1515 PINMUX_GPIO(GPIO_FN_SCK4, SCK4_MARK),
1516 PINMUX_GPIO(GPIO_FN_SCK3, SCK3_MARK),
1353 1517
1354 /* PTL (mobule: SERMUX) */ 1518 /* PTL (mobule: SERMUX, SCIF, LBSC, AUD) */
1355 PINMUX_GPIO(GPIO_FN_RAC_TXD, RAC_TXD_MARK),
1356 PINMUX_GPIO(GPIO_FN_RAC_RXD, RAC_RXD_MARK), 1519 PINMUX_GPIO(GPIO_FN_RAC_RXD, RAC_RXD_MARK),
1357 PINMUX_GPIO(GPIO_FN_RAC_RTS, RAC_RTS_MARK), 1520 PINMUX_GPIO(GPIO_FN_RAC_RTS, RAC_RTS_MARK),
1358 PINMUX_GPIO(GPIO_FN_RAC_CTS, RAC_CTS_MARK), 1521 PINMUX_GPIO(GPIO_FN_RAC_CTS, RAC_CTS_MARK),
1359 PINMUX_GPIO(GPIO_FN_RAC_DTR, RAC_DTR_MARK), 1522 PINMUX_GPIO(GPIO_FN_RAC_DTR, RAC_DTR_MARK),
1360 PINMUX_GPIO(GPIO_FN_RAC_DSR, RAC_DSR_MARK), 1523 PINMUX_GPIO(GPIO_FN_RAC_DSR, RAC_DSR_MARK),
1361 PINMUX_GPIO(GPIO_FN_RAC_DCD, RAC_DCD_MARK), 1524 PINMUX_GPIO(GPIO_FN_RAC_DCD, RAC_DCD_MARK),
1362 PINMUX_GPIO(GPIO_FN_RAC_RI, RAC_RI_MARK), 1525 PINMUX_GPIO(GPIO_FN_RAC_TXD, RAC_TXD_MARK),
1526 PINMUX_GPIO(GPIO_FN_RXD2, RXD2_MARK),
1527 PINMUX_GPIO(GPIO_FN_CS5, CS5_MARK),
1528 PINMUX_GPIO(GPIO_FN_CS6, CS6_MARK),
1529 PINMUX_GPIO(GPIO_FN_AUDSYNC, AUDSYNC_MARK),
1530 PINMUX_GPIO(GPIO_FN_AUDCK, AUDCK_MARK),
1531 PINMUX_GPIO(GPIO_FN_TXD2, TXD2_MARK),
1363 1532
1364 /* PTM (mobule: IIC, LPC) */ 1533 /* PTM (mobule: LBSC, IIC) */
1534 PINMUX_GPIO(GPIO_FN_CS4, CS4_MARK),
1535 PINMUX_GPIO(GPIO_FN_RD, RD_MARK),
1536 PINMUX_GPIO(GPIO_FN_WE0, WE0_MARK),
1537 PINMUX_GPIO(GPIO_FN_CS0, CS0_MARK),
1365 PINMUX_GPIO(GPIO_FN_SDA6, SDA6_MARK), 1538 PINMUX_GPIO(GPIO_FN_SDA6, SDA6_MARK),
1366 PINMUX_GPIO(GPIO_FN_SCL6, SCL6_MARK), 1539 PINMUX_GPIO(GPIO_FN_SCL6, SCL6_MARK),
1367 PINMUX_GPIO(GPIO_FN_SDA7, SDA7_MARK), 1540 PINMUX_GPIO(GPIO_FN_SDA7, SDA7_MARK),
1368 PINMUX_GPIO(GPIO_FN_SCL7, SCL7_MARK), 1541 PINMUX_GPIO(GPIO_FN_SCL7, SCL7_MARK),
1369 PINMUX_GPIO(GPIO_FN_WP, WP_MARK),
1370 PINMUX_GPIO(GPIO_FN_FMS0, FMS0_MARK),
1371 PINMUX_GPIO(GPIO_FN_FMS1, FMS1_MARK),
1372 1542
1373 /* PTN (mobule: SCIF234, EVC) */ 1543 /* PTN (mobule: USB, JMC, SGPIO, WDT) */
1374 PINMUX_GPIO(GPIO_FN_SCK2, SCK2_MARK), 1544 PINMUX_GPIO(GPIO_FN_VBUS_EN, VBUS_EN_MARK),
1375 PINMUX_GPIO(GPIO_FN_RTS4, RTS4_MARK), 1545 PINMUX_GPIO(GPIO_FN_VBUS_OC, VBUS_OC_MARK),
1376 PINMUX_GPIO(GPIO_FN_RTS3, RTS3_MARK), 1546 PINMUX_GPIO(GPIO_FN_JMCTCK, JMCTCK_MARK),
1377 PINMUX_GPIO(GPIO_FN_RTS2, RTS2_MARK), 1547 PINMUX_GPIO(GPIO_FN_JMCTMS, JMCTMS_MARK),
1378 PINMUX_GPIO(GPIO_FN_CTS4, CTS4_MARK), 1548 PINMUX_GPIO(GPIO_FN_JMCTDO, JMCTDO_MARK),
1379 PINMUX_GPIO(GPIO_FN_CTS3, CTS3_MARK), 1549 PINMUX_GPIO(GPIO_FN_JMCTDI, JMCTDI_MARK),
1380 PINMUX_GPIO(GPIO_FN_CTS2, CTS2_MARK), 1550 PINMUX_GPIO(GPIO_FN_JMCTRST, JMCTRST_MARK),
1381 PINMUX_GPIO(GPIO_FN_EVENT7, EVENT7_MARK), 1551 PINMUX_GPIO(GPIO_FN_SGPIO1_CLK, SGPIO1_CLK_MARK),
1382 PINMUX_GPIO(GPIO_FN_EVENT6, EVENT6_MARK), 1552 PINMUX_GPIO(GPIO_FN_SGPIO1_LOAD, SGPIO1_LOAD_MARK),
1383 PINMUX_GPIO(GPIO_FN_EVENT5, EVENT5_MARK), 1553 PINMUX_GPIO(GPIO_FN_SGPIO1_DI, SGPIO1_DI_MARK),
1384 PINMUX_GPIO(GPIO_FN_EVENT4, EVENT4_MARK), 1554 PINMUX_GPIO(GPIO_FN_SGPIO1_DO, SGPIO1_DO_MARK),
1385 PINMUX_GPIO(GPIO_FN_EVENT3, EVENT3_MARK), 1555 PINMUX_GPIO(GPIO_FN_SUB_CLKIN, SUB_CLKIN_MARK),
1386 PINMUX_GPIO(GPIO_FN_EVENT2, EVENT2_MARK),
1387 PINMUX_GPIO(GPIO_FN_EVENT1, EVENT1_MARK),
1388 PINMUX_GPIO(GPIO_FN_EVENT0, EVENT0_MARK),
1389 1556
1390 /* PTO (mobule: SGPIO) */ 1557 /* PTO (mobule: SGPIO, SerMux) */
1391 PINMUX_GPIO(GPIO_FN_SGPIO0_CLK, SGPIO0_CLK_MARK), 1558 PINMUX_GPIO(GPIO_FN_SGPIO0_CLK, SGPIO0_CLK_MARK),
1392 PINMUX_GPIO(GPIO_FN_SGPIO0_LOAD, SGPIO0_LOAD_MARK), 1559 PINMUX_GPIO(GPIO_FN_SGPIO0_LOAD, SGPIO0_LOAD_MARK),
1393 PINMUX_GPIO(GPIO_FN_SGPIO0_DI, SGPIO0_DI_MARK), 1560 PINMUX_GPIO(GPIO_FN_SGPIO0_DI, SGPIO0_DI_MARK),
1394 PINMUX_GPIO(GPIO_FN_SGPIO0_DO, SGPIO0_DO_MARK), 1561 PINMUX_GPIO(GPIO_FN_SGPIO0_DO, SGPIO0_DO_MARK),
1395 PINMUX_GPIO(GPIO_FN_SGPIO1_CLK, SGPIO1_CLK_MARK), 1562 PINMUX_GPIO(GPIO_FN_SGPIO2_CLK, SGPIO2_CLK_MARK),
1396 PINMUX_GPIO(GPIO_FN_SGPIO1_LOAD, SGPIO1_LOAD_MARK), 1563 PINMUX_GPIO(GPIO_FN_SGPIO2_LOAD, SGPIO2_LOAD_MARK),
1397 PINMUX_GPIO(GPIO_FN_SGPIO1_DI, SGPIO1_DI_MARK), 1564 PINMUX_GPIO(GPIO_FN_SGPIO2_DI, SGPIO2_DI_MARK),
1398 PINMUX_GPIO(GPIO_FN_SGPIO1_DO, SGPIO1_DO_MARK), 1565 PINMUX_GPIO(GPIO_FN_SGPIO2_DO, SGPIO2_DO_MARK),
1566 PINMUX_GPIO(GPIO_FN_COM1_TXD, COM1_TXD_MARK),
1567 PINMUX_GPIO(GPIO_FN_COM1_RXD, COM1_RXD_MARK),
1568 PINMUX_GPIO(GPIO_FN_COM1_RTS, COM1_RTS_MARK),
1569 PINMUX_GPIO(GPIO_FN_COM1_CTS, COM1_CTS_MARK),
1399 1570
1400 /* PTP (mobule: JMC, SCIF234) */ 1571 /* PTP (mobule: EVC, ADC) */
1401 PINMUX_GPIO(GPIO_FN_JMCTCK, JMCTCK_MARK),
1402 PINMUX_GPIO(GPIO_FN_JMCTMS, JMCTMS_MARK),
1403 PINMUX_GPIO(GPIO_FN_JMCTDO, JMCTDO_MARK),
1404 PINMUX_GPIO(GPIO_FN_JMCTDI, JMCTDI_MARK),
1405 PINMUX_GPIO(GPIO_FN_JMCRST, JMCRST_MARK),
1406 PINMUX_GPIO(GPIO_FN_SCK4, SCK4_MARK),
1407 PINMUX_GPIO(GPIO_FN_SCK3, SCK3_MARK),
1408 1572
1409 /* PTQ (mobule: LPC) */ 1573 /* PTQ (mobule: LPC) */
1410 PINMUX_GPIO(GPIO_FN_LAD3, LAD3_MARK), 1574 PINMUX_GPIO(GPIO_FN_LAD3, LAD3_MARK),
@@ -1439,31 +1603,41 @@ static struct pinmux_gpio pinmux_gpios[] = {
1439 PINMUX_GPIO(GPIO_FN_SDA3, SDA3_MARK), 1603 PINMUX_GPIO(GPIO_FN_SDA3, SDA3_MARK),
1440 PINMUX_GPIO(GPIO_FN_SCL3, SCL3_MARK), 1604 PINMUX_GPIO(GPIO_FN_SCL3, SCL3_MARK),
1441 1605
1442 /* PTT (mobule: SYSTEM, PWMX) */ 1606 /* PTT (mobule: PWMX, AUD) */
1443 PINMUX_GPIO(GPIO_FN_AUDSYNC, AUDSYNC_MARK), 1607 PINMUX_GPIO(GPIO_FN_PWMX7, PWMX7_MARK),
1444 PINMUX_GPIO(GPIO_FN_AUDCK, AUDCK_MARK), 1608 PINMUX_GPIO(GPIO_FN_PWMX6, PWMX6_MARK),
1609 PINMUX_GPIO(GPIO_FN_PWMX5, PWMX5_MARK),
1610 PINMUX_GPIO(GPIO_FN_PWMX4, PWMX4_MARK),
1611 PINMUX_GPIO(GPIO_FN_PWMX3, PWMX3_MARK),
1612 PINMUX_GPIO(GPIO_FN_PWMX2, PWMX2_MARK),
1613 PINMUX_GPIO(GPIO_FN_PWMX1, PWMX1_MARK),
1614 PINMUX_GPIO(GPIO_FN_PWMX0, PWMX0_MARK),
1445 PINMUX_GPIO(GPIO_FN_AUDATA3, AUDATA3_MARK), 1615 PINMUX_GPIO(GPIO_FN_AUDATA3, AUDATA3_MARK),
1446 PINMUX_GPIO(GPIO_FN_AUDATA2, AUDATA2_MARK), 1616 PINMUX_GPIO(GPIO_FN_AUDATA2, AUDATA2_MARK),
1447 PINMUX_GPIO(GPIO_FN_AUDATA1, AUDATA1_MARK), 1617 PINMUX_GPIO(GPIO_FN_AUDATA1, AUDATA1_MARK),
1448 PINMUX_GPIO(GPIO_FN_AUDATA0, AUDATA0_MARK), 1618 PINMUX_GPIO(GPIO_FN_AUDATA0, AUDATA0_MARK),
1449 PINMUX_GPIO(GPIO_FN_PWX7, PWX7_MARK), 1619 PINMUX_GPIO(GPIO_FN_STATUS1, STATUS1_MARK),
1450 PINMUX_GPIO(GPIO_FN_PWX6, PWX6_MARK), 1620 PINMUX_GPIO(GPIO_FN_STATUS0, STATUS0_MARK),
1451 PINMUX_GPIO(GPIO_FN_PWX5, PWX5_MARK),
1452 PINMUX_GPIO(GPIO_FN_PWX4, PWX4_MARK),
1453
1454 /* PTU (mobule: LBSC, DMAC) */
1455 PINMUX_GPIO(GPIO_FN_CS6, CS6_MARK),
1456 PINMUX_GPIO(GPIO_FN_CS5, CS5_MARK),
1457 PINMUX_GPIO(GPIO_FN_CS4, CS4_MARK),
1458 PINMUX_GPIO(GPIO_FN_CS0, CS0_MARK),
1459 PINMUX_GPIO(GPIO_FN_RD, RD_MARK),
1460 PINMUX_GPIO(GPIO_FN_WE0, WE0_MARK),
1461 PINMUX_GPIO(GPIO_FN_A25, A25_MARK),
1462 PINMUX_GPIO(GPIO_FN_A24, A24_MARK),
1463 PINMUX_GPIO(GPIO_FN_DREQ0, DREQ0_MARK),
1464 PINMUX_GPIO(GPIO_FN_DACK0, DACK0_MARK),
1465 1621
1466 /* PTV (mobule: LBSC, DMAC) */ 1622 /* PTU (mobule: LPC, APM) */
1623 PINMUX_GPIO(GPIO_FN_LGPIO7, LGPIO7_MARK),
1624 PINMUX_GPIO(GPIO_FN_LGPIO6, LGPIO6_MARK),
1625 PINMUX_GPIO(GPIO_FN_LGPIO5, LGPIO5_MARK),
1626 PINMUX_GPIO(GPIO_FN_LGPIO4, LGPIO4_MARK),
1627 PINMUX_GPIO(GPIO_FN_LGPIO3, LGPIO3_MARK),
1628 PINMUX_GPIO(GPIO_FN_LGPIO2, LGPIO2_MARK),
1629 PINMUX_GPIO(GPIO_FN_LGPIO1, LGPIO1_MARK),
1630 PINMUX_GPIO(GPIO_FN_LGPIO0, LGPIO0_MARK),
1631 PINMUX_GPIO(GPIO_FN_APMONCTL_O, APMONCTL_O_MARK),
1632 PINMUX_GPIO(GPIO_FN_APMPWBTOUT_O, APMPWBTOUT_O_MARK),
1633 PINMUX_GPIO(GPIO_FN_APMSCI_O, APMSCI_O_MARK),
1634 PINMUX_GPIO(GPIO_FN_APMVDDON, APMVDDON_MARK),
1635 PINMUX_GPIO(GPIO_FN_APMSLPBTN, APMSLPBTN_MARK),
1636 PINMUX_GPIO(GPIO_FN_APMPWRBTN, APMPWRBTN_MARK),
1637 PINMUX_GPIO(GPIO_FN_APMS5N, APMS5N_MARK),
1638 PINMUX_GPIO(GPIO_FN_APMS3N, APMS3N_MARK),
1639
1640 /* PTV (mobule: LBSC, SerMux, R-SPI, EVC, GRA) */
1467 PINMUX_GPIO(GPIO_FN_A23, A23_MARK), 1641 PINMUX_GPIO(GPIO_FN_A23, A23_MARK),
1468 PINMUX_GPIO(GPIO_FN_A22, A22_MARK), 1642 PINMUX_GPIO(GPIO_FN_A22, A22_MARK),
1469 PINMUX_GPIO(GPIO_FN_A21, A21_MARK), 1643 PINMUX_GPIO(GPIO_FN_A21, A21_MARK),
@@ -1472,12 +1646,20 @@ static struct pinmux_gpio pinmux_gpios[] = {
1472 PINMUX_GPIO(GPIO_FN_A18, A18_MARK), 1646 PINMUX_GPIO(GPIO_FN_A18, A18_MARK),
1473 PINMUX_GPIO(GPIO_FN_A17, A17_MARK), 1647 PINMUX_GPIO(GPIO_FN_A17, A17_MARK),
1474 PINMUX_GPIO(GPIO_FN_A16, A16_MARK), 1648 PINMUX_GPIO(GPIO_FN_A16, A16_MARK),
1475 PINMUX_GPIO(GPIO_FN_TEND0, TEND0_MARK), 1649 PINMUX_GPIO(GPIO_FN_COM2_RI, COM2_RI_MARK),
1476 PINMUX_GPIO(GPIO_FN_DREQ1, DREQ1_MARK), 1650 PINMUX_GPIO(GPIO_FN_R_SPI_MOSI, R_SPI_MOSI_MARK),
1477 PINMUX_GPIO(GPIO_FN_DACK1, DACK1_MARK), 1651 PINMUX_GPIO(GPIO_FN_R_SPI_MISO, R_SPI_MISO_MARK),
1478 PINMUX_GPIO(GPIO_FN_TEND1, TEND1_MARK), 1652 PINMUX_GPIO(GPIO_FN_R_SPI_RSPCK, R_SPI_RSPCK_MARK),
1653 PINMUX_GPIO(GPIO_FN_R_SPI_SSL0, R_SPI_SSL0_MARK),
1654 PINMUX_GPIO(GPIO_FN_R_SPI_SSL1, R_SPI_SSL1_MARK),
1655 PINMUX_GPIO(GPIO_FN_EVENT7, EVENT7_MARK),
1656 PINMUX_GPIO(GPIO_FN_EVENT6, EVENT6_MARK),
1657 PINMUX_GPIO(GPIO_FN_VBIOS_DI, VBIOS_DI_MARK),
1658 PINMUX_GPIO(GPIO_FN_VBIOS_DO, VBIOS_DO_MARK),
1659 PINMUX_GPIO(GPIO_FN_VBIOS_CLK, VBIOS_CLK_MARK),
1660 PINMUX_GPIO(GPIO_FN_VBIOS_CS, VBIOS_CS_MARK),
1479 1661
1480 /* PTW (mobule: LBSC) */ 1662 /* PTW (mobule: LBSC, EVC, SCIF) */
1481 PINMUX_GPIO(GPIO_FN_A16, A16_MARK), 1663 PINMUX_GPIO(GPIO_FN_A16, A16_MARK),
1482 PINMUX_GPIO(GPIO_FN_A15, A15_MARK), 1664 PINMUX_GPIO(GPIO_FN_A15, A15_MARK),
1483 PINMUX_GPIO(GPIO_FN_A14, A14_MARK), 1665 PINMUX_GPIO(GPIO_FN_A14, A14_MARK),
@@ -1487,6 +1669,14 @@ static struct pinmux_gpio pinmux_gpios[] = {
1487 PINMUX_GPIO(GPIO_FN_A10, A10_MARK), 1669 PINMUX_GPIO(GPIO_FN_A10, A10_MARK),
1488 PINMUX_GPIO(GPIO_FN_A9, A9_MARK), 1670 PINMUX_GPIO(GPIO_FN_A9, A9_MARK),
1489 PINMUX_GPIO(GPIO_FN_A8, A8_MARK), 1671 PINMUX_GPIO(GPIO_FN_A8, A8_MARK),
1672 PINMUX_GPIO(GPIO_FN_EVENT5, EVENT5_MARK),
1673 PINMUX_GPIO(GPIO_FN_EVENT4, EVENT4_MARK),
1674 PINMUX_GPIO(GPIO_FN_EVENT3, EVENT3_MARK),
1675 PINMUX_GPIO(GPIO_FN_EVENT2, EVENT2_MARK),
1676 PINMUX_GPIO(GPIO_FN_EVENT1, EVENT1_MARK),
1677 PINMUX_GPIO(GPIO_FN_EVENT0, EVENT0_MARK),
1678 PINMUX_GPIO(GPIO_FN_CTS4, CTS4_MARK),
1679 PINMUX_GPIO(GPIO_FN_CTS2, CTS2_MARK),
1490 1680
1491 /* PTX (mobule: LBSC) */ 1681 /* PTX (mobule: LBSC) */
1492 PINMUX_GPIO(GPIO_FN_A7, A7_MARK), 1682 PINMUX_GPIO(GPIO_FN_A7, A7_MARK),
@@ -1497,6 +1687,10 @@ static struct pinmux_gpio pinmux_gpios[] = {
1497 PINMUX_GPIO(GPIO_FN_A2, A2_MARK), 1687 PINMUX_GPIO(GPIO_FN_A2, A2_MARK),
1498 PINMUX_GPIO(GPIO_FN_A1, A1_MARK), 1688 PINMUX_GPIO(GPIO_FN_A1, A1_MARK),
1499 PINMUX_GPIO(GPIO_FN_A0, A0_MARK), 1689 PINMUX_GPIO(GPIO_FN_A0, A0_MARK),
1690 PINMUX_GPIO(GPIO_FN_RTS2, RTS2_MARK),
1691 PINMUX_GPIO(GPIO_FN_SIM_D, SIM_D_MARK),
1692 PINMUX_GPIO(GPIO_FN_SIM_CLK, SIM_CLK_MARK),
1693 PINMUX_GPIO(GPIO_FN_SIM_RST, SIM_RST_MARK),
1500 1694
1501 /* PTY (mobule: LBSC) */ 1695 /* PTY (mobule: LBSC) */
1502 PINMUX_GPIO(GPIO_FN_D7, D7_MARK), 1696 PINMUX_GPIO(GPIO_FN_D7, D7_MARK),
@@ -1507,18 +1701,36 @@ static struct pinmux_gpio pinmux_gpios[] = {
1507 PINMUX_GPIO(GPIO_FN_D2, D2_MARK), 1701 PINMUX_GPIO(GPIO_FN_D2, D2_MARK),
1508 PINMUX_GPIO(GPIO_FN_D1, D1_MARK), 1702 PINMUX_GPIO(GPIO_FN_D1, D1_MARK),
1509 PINMUX_GPIO(GPIO_FN_D0, D0_MARK), 1703 PINMUX_GPIO(GPIO_FN_D0, D0_MARK),
1704
1705 /* PTZ (mobule: eMMC, ONFI) */
1706 PINMUX_GPIO(GPIO_FN_MMCDAT7, MMCDAT7_MARK),
1707 PINMUX_GPIO(GPIO_FN_MMCDAT6, MMCDAT6_MARK),
1708 PINMUX_GPIO(GPIO_FN_MMCDAT5, MMCDAT5_MARK),
1709 PINMUX_GPIO(GPIO_FN_MMCDAT4, MMCDAT4_MARK),
1710 PINMUX_GPIO(GPIO_FN_MMCDAT3, MMCDAT3_MARK),
1711 PINMUX_GPIO(GPIO_FN_MMCDAT2, MMCDAT2_MARK),
1712 PINMUX_GPIO(GPIO_FN_MMCDAT1, MMCDAT1_MARK),
1713 PINMUX_GPIO(GPIO_FN_MMCDAT0, MMCDAT0_MARK),
1714 PINMUX_GPIO(GPIO_FN_ON_DQ7, ON_DQ7_MARK),
1715 PINMUX_GPIO(GPIO_FN_ON_DQ6, ON_DQ6_MARK),
1716 PINMUX_GPIO(GPIO_FN_ON_DQ5, ON_DQ5_MARK),
1717 PINMUX_GPIO(GPIO_FN_ON_DQ4, ON_DQ4_MARK),
1718 PINMUX_GPIO(GPIO_FN_ON_DQ3, ON_DQ3_MARK),
1719 PINMUX_GPIO(GPIO_FN_ON_DQ2, ON_DQ2_MARK),
1720 PINMUX_GPIO(GPIO_FN_ON_DQ1, ON_DQ1_MARK),
1721 PINMUX_GPIO(GPIO_FN_ON_DQ0, ON_DQ0_MARK),
1510 }; 1722 };
1511 1723
1512static struct pinmux_cfg_reg pinmux_config_regs[] = { 1724static struct pinmux_cfg_reg pinmux_config_regs[] = {
1513 { PINMUX_CFG_REG("PACR", 0xffec0000, 16, 2) { 1725 { PINMUX_CFG_REG("PACR", 0xffec0000, 16, 2) {
1514 PTA7_FN, PTA7_OUT, PTA7_IN, 0, 1726 PTA7_FN, PTA7_OUT, PTA7_IN, PTA7_IN_PU,
1515 PTA6_FN, PTA6_OUT, PTA6_IN, 0, 1727 PTA6_FN, PTA6_OUT, PTA6_IN, PTA6_IN_PU,
1516 PTA5_FN, PTA5_OUT, PTA5_IN, 0, 1728 PTA5_FN, PTA5_OUT, PTA5_IN, PTA5_IN_PU,
1517 PTA4_FN, PTA4_OUT, PTA4_IN, 0, 1729 PTA4_FN, PTA4_OUT, PTA4_IN, PTA4_IN_PU,
1518 PTA3_FN, PTA3_OUT, PTA3_IN, 0, 1730 PTA3_FN, PTA3_OUT, PTA3_IN, PTA3_IN_PU,
1519 PTA2_FN, PTA2_OUT, PTA2_IN, 0, 1731 PTA2_FN, PTA2_OUT, PTA2_IN, PTA2_IN_PU,
1520 PTA1_FN, PTA1_OUT, PTA1_IN, 0, 1732 PTA1_FN, PTA1_OUT, PTA1_IN, PTA1_IN_PU,
1521 PTA0_FN, PTA0_OUT, PTA0_IN, 0 } 1733 PTA0_FN, PTA0_OUT, PTA0_IN, PTA0_IN_PU }
1522 }, 1734 },
1523 { PINMUX_CFG_REG("PBCR", 0xffec0002, 16, 2) { 1735 { PINMUX_CFG_REG("PBCR", 0xffec0002, 16, 2) {
1524 PTB7_FN, PTB7_OUT, PTB7_IN, 0, 1736 PTB7_FN, PTB7_OUT, PTB7_IN, 0,
@@ -1541,125 +1753,126 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1541 PTC0_FN, PTC0_OUT, PTC0_IN, 0 } 1753 PTC0_FN, PTC0_OUT, PTC0_IN, 0 }
1542 }, 1754 },
1543 { PINMUX_CFG_REG("PDCR", 0xffec0006, 16, 2) { 1755 { PINMUX_CFG_REG("PDCR", 0xffec0006, 16, 2) {
1544 PTD7_FN, PTD7_OUT, PTD7_IN, 0, 1756 PTD7_FN, PTD7_OUT, PTD7_IN, PTD7_IN_PU,
1545 PTD6_FN, PTD6_OUT, PTD6_IN, 0, 1757 PTD6_FN, PTD6_OUT, PTD6_IN, PTD6_IN_PU,
1546 PTD5_FN, PTD5_OUT, PTD5_IN, 0, 1758 PTD5_FN, PTD5_OUT, PTD5_IN, PTD5_IN_PU,
1547 PTD4_FN, PTD4_OUT, PTD4_IN, 0, 1759 PTD4_FN, PTD4_OUT, PTD4_IN, PTD4_IN_PU,
1548 PTD3_FN, PTD3_OUT, PTD3_IN, 0, 1760 PTD3_FN, PTD3_OUT, PTD3_IN, PTD3_IN_PU,
1549 PTD2_FN, PTD2_OUT, PTD2_IN, 0, 1761 PTD2_FN, PTD2_OUT, PTD2_IN, PTD2_IN_PU,
1550 PTD1_FN, PTD1_OUT, PTD1_IN, 0, 1762 PTD1_FN, PTD1_OUT, PTD1_IN, PTD1_IN_PU,
1551 PTD0_FN, PTD0_OUT, PTD0_IN, 0 } 1763 PTD0_FN, PTD0_OUT, PTD0_IN, PTD0_IN_PU }
1552 }, 1764 },
1553 { PINMUX_CFG_REG("PECR", 0xffec0008, 16, 2) { 1765 { PINMUX_CFG_REG("PECR", 0xffec0008, 16, 2) {
1554 PTE7_FN, PTE7_OUT, PTE7_IN, 0, 1766 PTE7_FN, PTE7_OUT, PTE7_IN, PTE7_IN_PU,
1555 PTE6_FN, PTE6_OUT, PTE6_IN, 0, 1767 PTE6_FN, PTE6_OUT, PTE6_IN, PTE6_IN_PU,
1556 PTE5_FN, PTE5_OUT, PTE5_IN, 0, 1768 PTE5_FN, PTE5_OUT, PTE5_IN, PTE5_IN_PU,
1557 PTE4_FN, PTE4_OUT, PTE4_IN, 0, 1769 PTE4_FN, PTE4_OUT, PTE4_IN, PTE4_IN_PU,
1558 PTE3_FN, PTE3_OUT, PTE3_IN, 0, 1770 PTE3_FN, PTE3_OUT, PTE3_IN, PTE3_IN_PU,
1559 PTE2_FN, PTE2_OUT, PTE2_IN, 0, 1771 PTE2_FN, PTE2_OUT, PTE2_IN, PTE2_IN_PU,
1560 PTE1_FN, PTE1_OUT, PTE1_IN, 0, 1772 PTE1_FN, PTE1_OUT, PTE1_IN, PTE1_IN_PU,
1561 PTE0_FN, PTE0_OUT, PTE0_IN, 0 } 1773 PTE0_FN, PTE0_OUT, PTE0_IN, PTE0_IN_PU }
1562 }, 1774 },
1563 { PINMUX_CFG_REG("PFCR", 0xffec000a, 16, 2) { 1775 { PINMUX_CFG_REG("PFCR", 0xffec000a, 16, 2) {
1564 PTF7_FN, PTF7_OUT, PTF7_IN, 0, 1776 PTF7_FN, PTF7_OUT, PTF7_IN, PTF7_IN_PU,
1565 PTF6_FN, PTF6_OUT, PTF6_IN, 0, 1777 PTF6_FN, PTF6_OUT, PTF6_IN, PTF6_IN_PU,
1566 PTF5_FN, PTF5_OUT, PTF5_IN, 0, 1778 PTF5_FN, PTF5_OUT, PTF5_IN, PTF5_IN_PU,
1567 PTF4_FN, PTF4_OUT, PTF4_IN, 0, 1779 PTF4_FN, PTF4_OUT, PTF4_IN, PTF4_IN_PU,
1568 PTF3_FN, PTF3_OUT, PTF3_IN, 0, 1780 PTF3_FN, PTF3_OUT, PTF3_IN, PTF3_IN_PU,
1569 PTF2_FN, PTF2_OUT, PTF2_IN, 0, 1781 PTF2_FN, PTF2_OUT, PTF2_IN, PTF2_IN_PU,
1570 PTF1_FN, PTF1_OUT, PTF1_IN, 0, 1782 PTF1_FN, PTF1_OUT, PTF1_IN, PTF1_IN_PU,
1571 PTF0_FN, PTF0_OUT, PTF0_IN, 0 } 1783 PTF0_FN, PTF0_OUT, PTF0_IN, PTF0_IN_PU }
1572 }, 1784 },
1573 { PINMUX_CFG_REG("PGCR", 0xffec000c, 16, 2) { 1785 { PINMUX_CFG_REG("PGCR", 0xffec000c, 16, 2) {
1574 PTG7_FN, PTG7_OUT, PTG7_IN, 0, 1786 PTG7_FN, PTG7_OUT, PTG7_IN, PTG7_IN_PU ,
1575 PTG6_FN, PTG6_OUT, PTG6_IN, 0, 1787 PTG6_FN, PTG6_OUT, PTG6_IN, PTG6_IN_PU ,
1576 PTG5_FN, PTG5_OUT, PTG5_IN, 0, 1788 PTG5_FN, PTG5_OUT, PTG5_IN, 0,
1577 PTG4_FN, PTG4_OUT, PTG4_IN, 0, 1789 PTG4_FN, PTG4_OUT, PTG4_IN, PTG4_IN_PU ,
1578 PTG3_FN, PTG3_OUT, PTG3_IN, 0, 1790 PTG3_FN, PTG3_OUT, PTG3_IN, 0,
1579 PTG2_FN, PTG2_OUT, PTG2_IN, 0, 1791 PTG2_FN, PTG2_OUT, PTG2_IN, 0,
1580 PTG1_FN, PTG1_OUT, PTG1_IN, 0, 1792 PTG1_FN, PTG1_OUT, PTG1_IN, 0,
1581 PTG0_FN, PTG0_OUT, PTG0_IN, 0 } 1793 PTG0_FN, PTG0_OUT, PTG0_IN, 0 }
1582 }, 1794 },
1583 { PINMUX_CFG_REG("PHCR", 0xffec000e, 16, 2) { 1795 { PINMUX_CFG_REG("PHCR", 0xffec000e, 16, 2) {
1584 PTH7_FN, PTH7_OUT, PTH7_IN, 0, 1796 PTH7_FN, PTH7_OUT, PTH7_IN, PTH7_IN_PU,
1585 PTH6_FN, PTH6_OUT, PTH6_IN, 0, 1797 PTH6_FN, PTH6_OUT, PTH6_IN, PTH6_IN_PU,
1586 PTH5_FN, PTH5_OUT, PTH5_IN, 0, 1798 PTH5_FN, PTH5_OUT, PTH5_IN, PTH5_IN_PU,
1587 PTH4_FN, PTH4_OUT, PTH4_IN, 0, 1799 PTH4_FN, PTH4_OUT, PTH4_IN, PTH4_IN_PU,
1588 PTH3_FN, PTH3_OUT, PTH3_IN, 0, 1800 PTH3_FN, PTH3_OUT, PTH3_IN, PTH3_IN_PU,
1589 PTH2_FN, PTH2_OUT, PTH2_IN, 0, 1801 PTH2_FN, PTH2_OUT, PTH2_IN, PTH2_IN_PU,
1590 PTH1_FN, PTH1_OUT, PTH1_IN, 0, 1802 PTH1_FN, PTH1_OUT, PTH1_IN, PTH1_IN_PU,
1591 PTH0_FN, PTH0_OUT, PTH0_IN, 0 } 1803 PTH0_FN, PTH0_OUT, PTH0_IN, PTH0_IN_PU }
1592 }, 1804 },
1593 { PINMUX_CFG_REG("PICR", 0xffec0010, 16, 2) { 1805 { PINMUX_CFG_REG("PICR", 0xffec0010, 16, 2) {
1594 PTI7_FN, PTI7_OUT, PTI7_IN, 0, 1806 PTI7_FN, PTI7_OUT, PTI7_IN, PTI7_IN_PU,
1595 PTI6_FN, PTI6_OUT, PTI6_IN, 0, 1807 PTI6_FN, PTI6_OUT, PTI6_IN, PTI6_IN_PU,
1596 PTI5_FN, PTI5_OUT, PTI5_IN, 0, 1808 PTI5_FN, PTI5_OUT, PTI5_IN, 0,
1597 PTI4_FN, PTI4_OUT, PTI4_IN, 0, 1809 PTI4_FN, PTI4_OUT, PTI4_IN, PTI4_IN_PU,
1598 PTI3_FN, PTI3_OUT, PTI3_IN, 0, 1810 PTI3_FN, PTI3_OUT, PTI3_IN, PTI3_IN_PU,
1599 PTI2_FN, PTI2_OUT, PTI2_IN, 0, 1811 PTI2_FN, PTI2_OUT, PTI2_IN, PTI2_IN_PU,
1600 PTI1_FN, PTI1_OUT, PTI1_IN, 0, 1812 PTI1_FN, PTI1_OUT, PTI1_IN, PTI1_IN_PU,
1601 PTI0_FN, PTI0_OUT, PTI0_IN, 0 } 1813 PTI0_FN, PTI0_OUT, PTI0_IN, PTI0_IN_PU }
1602 }, 1814 },
1603 { PINMUX_CFG_REG("PJCR", 0xffec0012, 16, 2) { 1815 { PINMUX_CFG_REG("PJCR", 0xffec0012, 16, 2) {
1604 PTJ7_FN, PTJ7_OUT, PTJ7_IN, 0, 1816 0, 0, 0, 0, /* reserved: always set 1 */
1605 PTJ6_FN, PTJ6_OUT, PTJ6_IN, 0, 1817 PTJ6_FN, PTJ6_OUT, PTJ6_IN, PTJ6_IN_PU,
1606 PTJ5_FN, PTJ5_OUT, PTJ5_IN, 0, 1818 PTJ5_FN, PTJ5_OUT, PTJ5_IN, PTJ5_IN_PU,
1607 PTJ4_FN, PTJ4_OUT, PTJ4_IN, 0, 1819 PTJ4_FN, PTJ4_OUT, PTJ4_IN, PTJ4_IN_PU,
1608 PTJ3_FN, PTJ3_OUT, PTJ3_IN, 0, 1820 PTJ3_FN, PTJ3_OUT, PTJ3_IN, PTJ3_IN_PU,
1609 PTJ2_FN, PTJ2_OUT, PTJ2_IN, 0, 1821 PTJ2_FN, PTJ2_OUT, PTJ2_IN, PTJ2_IN_PU,
1610 PTJ1_FN, PTJ1_OUT, PTJ1_IN, 0, 1822 PTJ1_FN, PTJ1_OUT, PTJ1_IN, PTJ1_IN_PU,
1611 PTJ0_FN, PTJ0_OUT, PTJ0_IN, 0 } 1823 PTJ0_FN, PTJ0_OUT, PTJ0_IN, PTJ0_IN_PU }
1612 }, 1824 },
1613 { PINMUX_CFG_REG("PKCR", 0xffec0014, 16, 2) { 1825 { PINMUX_CFG_REG("PKCR", 0xffec0014, 16, 2) {
1614 PTK7_FN, PTK7_OUT, PTK7_IN, 0, 1826 PTK7_FN, PTK7_OUT, PTK7_IN, PTK7_IN_PU,
1615 PTK6_FN, PTK6_OUT, PTK6_IN, 0, 1827 PTK6_FN, PTK6_OUT, PTK6_IN, PTK6_IN_PU,
1616 PTK5_FN, PTK5_OUT, PTK5_IN, 0, 1828 PTK5_FN, PTK5_OUT, PTK5_IN, PTK5_IN_PU,
1617 PTK4_FN, PTK4_OUT, PTK4_IN, 0, 1829 PTK4_FN, PTK4_OUT, PTK4_IN, PTK4_IN_PU,
1618 PTK3_FN, PTK3_OUT, PTK3_IN, 0, 1830 PTK3_FN, PTK3_OUT, PTK3_IN, PTK3_IN_PU,
1619 PTK2_FN, PTK2_OUT, PTK2_IN, 0, 1831 PTK2_FN, PTK2_OUT, PTK2_IN, PTK2_IN_PU,
1620 PTK1_FN, PTK1_OUT, PTK1_IN, 0, 1832 PTK1_FN, PTK1_OUT, PTK1_IN, PTK1_IN_PU,
1621 PTK0_FN, PTK0_OUT, PTK0_IN, 0 } 1833 PTK0_FN, PTK0_OUT, PTK0_IN, PTK0_IN_PU }
1622 }, 1834 },
1623 { PINMUX_CFG_REG("PLCR", 0xffec0016, 16, 2) { 1835 { PINMUX_CFG_REG("PLCR", 0xffec0016, 16, 2) {
1624 PTL7_FN, PTL7_OUT, PTL7_IN, 0, 1836 0, 0, 0, 0, /* reserved: always set 1 */
1625 PTL6_FN, PTL6_OUT, PTL6_IN, 0, 1837 PTL6_FN, PTL6_OUT, PTL6_IN, PTL6_IN_PU,
1626 PTL5_FN, PTL5_OUT, PTL5_IN, 0, 1838 PTL5_FN, PTL5_OUT, PTL5_IN, PTL5_IN_PU,
1627 PTL4_FN, PTL4_OUT, PTL4_IN, 0, 1839 PTL4_FN, PTL4_OUT, PTL4_IN, PTL4_IN_PU,
1628 PTL3_FN, PTL3_OUT, PTL3_IN, 0, 1840 PTL3_FN, PTL3_OUT, PTL3_IN, PTL3_IN_PU,
1629 PTL2_FN, PTL2_OUT, PTL2_IN, 0, 1841 PTL2_FN, PTL2_OUT, PTL2_IN, PTL2_IN_PU,
1630 PTL1_FN, PTL1_OUT, PTL1_IN, 0, 1842 PTL1_FN, PTL1_OUT, PTL1_IN, PTL1_IN_PU,
1631 PTL0_FN, PTL0_OUT, PTL0_IN, 0 } 1843 PTL0_FN, PTL0_OUT, PTL0_IN, PTL0_IN_PU }
1632 }, 1844 },
1633 { PINMUX_CFG_REG("PMCR", 0xffec0018, 16, 2) { 1845 { PINMUX_CFG_REG("PMCR", 0xffec0018, 16, 2) {
1634 0, 0, 0, 0, /* reserved: always set 1 */ 1846 PTM7_FN, PTM7_OUT, PTM7_IN, PTM7_IN_PU,
1635 PTM6_FN, PTM6_OUT, PTM6_IN, 0, 1847 PTM6_FN, PTM6_OUT, PTM6_IN, PTM6_IN_PU,
1636 PTM5_FN, PTM5_OUT, PTM5_IN, 0, 1848 PTM5_FN, PTM5_OUT, PTM5_IN, PTM5_IN_PU,
1637 PTM4_FN, PTM4_OUT, PTM4_IN, 0, 1849 PTM4_FN, PTM4_OUT, PTM4_IN, PTM4_IN_PU,
1638 PTM3_FN, PTM3_OUT, PTM3_IN, 0, 1850 PTM3_FN, PTM3_OUT, PTM3_IN, 0,
1639 PTM2_FN, PTM2_OUT, PTM2_IN, 0, 1851 PTM2_FN, PTM2_OUT, PTM2_IN, 0,
1640 PTM1_FN, PTM1_OUT, PTM1_IN, 0, 1852 PTM1_FN, PTM1_OUT, PTM1_IN, 0,
1641 PTM0_FN, PTM0_OUT, PTM0_IN, 0 } 1853 PTM0_FN, PTM0_OUT, PTM0_IN, 0 }
1642 }, 1854 },
1643 { PINMUX_CFG_REG("PNCR", 0xffec001a, 16, 2) { 1855 { PINMUX_CFG_REG("PNCR", 0xffec001a, 16, 2) {
1644 PTN7_FN, PTN7_OUT, PTN7_IN, 0, 1856 0, 0, 0, 0, /* reserved: always set 1 */
1645 PTN6_FN, PTN6_OUT, PTN6_IN, 0, 1857 PTN6_FN, PTN6_OUT, PTN6_IN, 0,
1646 PTN5_FN, PTN5_OUT, PTN5_IN, 0, 1858 PTN5_FN, PTN5_OUT, PTN5_IN, 0,
1647 PTN4_FN, PTN4_OUT, PTN4_IN, 0, 1859 PTN4_FN, PTN4_OUT, PTN4_IN, PTN4_IN_PU,
1648 PTN3_FN, PTN3_OUT, PTN3_IN, 0, 1860 PTN3_FN, PTN3_OUT, PTN3_IN, PTN3_IN_PU,
1649 PTN2_FN, PTN2_OUT, PTN2_IN, 0, 1861 PTN2_FN, PTN2_OUT, PTN2_IN, PTN2_IN_PU,
1650 PTN1_FN, PTN1_OUT, PTN1_IN, 0, 1862 PTN1_FN, PTN1_OUT, PTN1_IN, PTN1_IN_PU,
1651 PTN0_FN, PTN0_OUT, PTN0_IN, 0 } 1863 PTN0_FN, PTN0_OUT, PTN0_IN, PTN0_IN_PU }
1652 }, 1864 },
1653 { PINMUX_CFG_REG("POCR", 0xffec001c, 16, 2) { 1865 { PINMUX_CFG_REG("POCR", 0xffec001c, 16, 2) {
1654 PTO7_FN, PTO7_OUT, PTO7_IN, 0, 1866 PTO7_FN, PTO7_OUT, PTO7_IN, PTO7_IN_PU,
1655 PTO6_FN, PTO6_OUT, PTO6_IN, 0, 1867 PTO6_FN, PTO6_OUT, PTO6_IN, PTO6_IN_PU,
1656 PTO5_FN, PTO5_OUT, PTO5_IN, 0, 1868 PTO5_FN, PTO5_OUT, PTO5_IN, PTO5_IN_PU,
1657 PTO4_FN, PTO4_OUT, PTO4_IN, 0, 1869 PTO4_FN, PTO4_OUT, PTO4_IN, PTO4_IN_PU,
1658 PTO3_FN, PTO3_OUT, PTO3_IN, 0, 1870 PTO3_FN, PTO3_OUT, PTO3_IN, PTO3_IN_PU,
1659 PTO2_FN, PTO2_OUT, PTO2_IN, 0, 1871 PTO2_FN, PTO2_OUT, PTO2_IN, PTO2_IN_PU,
1660 PTO1_FN, PTO1_OUT, PTO1_IN, 0, 1872 PTO1_FN, PTO1_OUT, PTO1_IN, PTO1_IN_PU,
1661 PTO0_FN, PTO0_OUT, PTO0_IN, 0 } 1873 PTO0_FN, PTO0_OUT, PTO0_IN, PTO0_IN_PU }
1662 }, 1874 },
1875#if 0 /* FIXME: Remove it? */
1663 { PINMUX_CFG_REG("PPCR", 0xffec001e, 16, 2) { 1876 { PINMUX_CFG_REG("PPCR", 0xffec001e, 16, 2) {
1664 0, 0, 0, 0, /* reserved: always set 1 */ 1877 0, 0, 0, 0, /* reserved: always set 1 */
1665 PTP6_FN, PTP6_OUT, PTP6_IN, 0, 1878 PTP6_FN, PTP6_OUT, PTP6_IN, 0,
@@ -1670,6 +1883,7 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1670 PTP1_FN, PTP1_OUT, PTP1_IN, 0, 1883 PTP1_FN, PTP1_OUT, PTP1_IN, 0,
1671 PTP0_FN, PTP0_OUT, PTP0_IN, 0 } 1884 PTP0_FN, PTP0_OUT, PTP0_IN, 0 }
1672 }, 1885 },
1886#endif
1673 { PINMUX_CFG_REG("PQCR", 0xffec0020, 16, 2) { 1887 { PINMUX_CFG_REG("PQCR", 0xffec0020, 16, 2) {
1674 0, 0, 0, 0, /* reserved: always set 1 */ 1888 0, 0, 0, 0, /* reserved: always set 1 */
1675 PTQ6_FN, PTQ6_OUT, PTQ6_IN, 0, 1889 PTQ6_FN, PTQ6_OUT, PTQ6_IN, 0,
@@ -1701,14 +1915,14 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1701 PTS0_FN, PTS0_OUT, PTS0_IN, 0 } 1915 PTS0_FN, PTS0_OUT, PTS0_IN, 0 }
1702 }, 1916 },
1703 { PINMUX_CFG_REG("PTCR", 0xffec0026, 16, 2) { 1917 { PINMUX_CFG_REG("PTCR", 0xffec0026, 16, 2) {
1704 0, 0, 0, 0, /* reserved: always set 1 */ 1918 PTT7_FN, PTT7_OUT, PTT7_IN, PTO7_IN_PU,
1705 0, 0, 0, 0, /* reserved: always set 1 */ 1919 PTT6_FN, PTT6_OUT, PTT6_IN, PTO6_IN_PU,
1706 PTT5_FN, PTT5_OUT, PTT5_IN, 0, 1920 PTT5_FN, PTT5_OUT, PTT5_IN, PTO5_IN_PU,
1707 PTT4_FN, PTT4_OUT, PTT4_IN, 0, 1921 PTT4_FN, PTT4_OUT, PTT4_IN, PTO4_IN_PU,
1708 PTT3_FN, PTT3_OUT, PTT3_IN, 0, 1922 PTT3_FN, PTT3_OUT, PTT3_IN, PTO3_IN_PU,
1709 PTT2_FN, PTT2_OUT, PTT2_IN, 0, 1923 PTT2_FN, PTT2_OUT, PTT2_IN, PTO2_IN_PU,
1710 PTT1_FN, PTT1_OUT, PTT1_IN, 0, 1924 PTT1_FN, PTT1_OUT, PTT1_IN, PTO1_IN_PU,
1711 PTT0_FN, PTT0_OUT, PTT0_IN, 0 } 1925 PTT0_FN, PTT0_OUT, PTT0_IN, PTO0_IN_PU }
1712 }, 1926 },
1713 { PINMUX_CFG_REG("PUCR", 0xffec0028, 16, 2) { 1927 { PINMUX_CFG_REG("PUCR", 0xffec0028, 16, 2) {
1714 PTU7_FN, PTU7_OUT, PTU7_IN, PTU7_IN_PU, 1928 PTU7_FN, PTU7_OUT, PTU7_IN, PTU7_IN_PU,
@@ -1727,16 +1941,16 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1727 PTV4_FN, PTV4_OUT, PTV4_IN, PTV4_IN_PU, 1941 PTV4_FN, PTV4_OUT, PTV4_IN, PTV4_IN_PU,
1728 PTV3_FN, PTV3_OUT, PTV3_IN, PTV3_IN_PU, 1942 PTV3_FN, PTV3_OUT, PTV3_IN, PTV3_IN_PU,
1729 PTV2_FN, PTV2_OUT, PTV2_IN, PTV2_IN_PU, 1943 PTV2_FN, PTV2_OUT, PTV2_IN, PTV2_IN_PU,
1730 PTV1_FN, PTV1_OUT, PTV1_IN, PTV1_IN_PU, 1944 PTV1_FN, PTV1_OUT, PTV1_IN, 0,
1731 PTV0_FN, PTV0_OUT, PTV0_IN, PTV0_IN_PU } 1945 PTV0_FN, PTV0_OUT, PTV0_IN, 0 }
1732 }, 1946 },
1733 { PINMUX_CFG_REG("PWCR", 0xffec002c, 16, 2) { 1947 { PINMUX_CFG_REG("PWCR", 0xffec002c, 16, 2) {
1734 PTW7_FN, PTW7_OUT, PTW7_IN, PTW7_IN_PU, 1948 PTW7_FN, PTW7_OUT, PTW7_IN, 0,
1735 PTW6_FN, PTW6_OUT, PTW6_IN, PTW6_IN_PU, 1949 PTW6_FN, PTW6_OUT, PTW6_IN, 0,
1736 PTW5_FN, PTW5_OUT, PTW5_IN, PTW5_IN_PU, 1950 PTW5_FN, PTW5_OUT, PTW5_IN, 0,
1737 PTW4_FN, PTW4_OUT, PTW4_IN, PTW4_IN_PU, 1951 PTW4_FN, PTW4_OUT, PTW4_IN, 0,
1738 PTW3_FN, PTW3_OUT, PTW3_IN, PTW3_IN_PU, 1952 PTW3_FN, PTW3_OUT, PTW3_IN, 0,
1739 PTW2_FN, PTW2_OUT, PTW2_IN, PTW2_IN_PU, 1953 PTW2_FN, PTW2_OUT, PTW2_IN, 0,
1740 PTW1_FN, PTW1_OUT, PTW1_IN, PTW1_IN_PU, 1954 PTW1_FN, PTW1_OUT, PTW1_IN, PTW1_IN_PU,
1741 PTW0_FN, PTW0_OUT, PTW0_IN, PTW0_IN_PU } 1955 PTW0_FN, PTW0_OUT, PTW0_IN, PTW0_IN_PU }
1742 }, 1956 },
@@ -1761,32 +1975,32 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1761 PTY0_FN, PTY0_OUT, PTY0_IN, PTY0_IN_PU } 1975 PTY0_FN, PTY0_OUT, PTY0_IN, PTY0_IN_PU }
1762 }, 1976 },
1763 { PINMUX_CFG_REG("PZCR", 0xffec0032, 16, 2) { 1977 { PINMUX_CFG_REG("PZCR", 0xffec0032, 16, 2) {
1764 0, PTZ7_OUT, PTZ7_IN, 0, 1978 PTZ7_FN, PTZ7_OUT, PTZ7_IN, 0,
1765 0, PTZ6_OUT, PTZ6_IN, 0, 1979 PTZ6_FN, PTZ6_OUT, PTZ6_IN, 0,
1766 0, PTZ5_OUT, PTZ5_IN, 0, 1980 PTZ5_FN, PTZ5_OUT, PTZ5_IN, 0,
1767 0, PTZ4_OUT, PTZ4_IN, 0, 1981 PTZ4_FN, PTZ4_OUT, PTZ4_IN, 0,
1768 0, PTZ3_OUT, PTZ3_IN, 0, 1982 PTZ3_FN, PTZ3_OUT, PTZ3_IN, 0,
1769 0, PTZ2_OUT, PTZ2_IN, 0, 1983 PTZ2_FN, PTZ2_OUT, PTZ2_IN, 0,
1770 0, PTZ1_OUT, PTZ1_IN, 0, 1984 PTZ1_FN, PTZ1_OUT, PTZ1_IN, 0,
1771 0, PTZ0_OUT, PTZ0_IN, 0 } 1985 PTZ0_FN, PTZ0_OUT, PTZ0_IN, 0 }
1772 }, 1986 },
1773 1987
1774 { PINMUX_CFG_REG("PSEL0", 0xffec0070, 16, 1) { 1988 { PINMUX_CFG_REG("PSEL0", 0xffec0070, 16, 1) {
1775 PS0_15_FN3, PS0_15_FN1, 1989 PS0_15_FN1, PS0_15_FN2,
1776 PS0_14_FN3, PS0_14_FN1, 1990 PS0_14_FN1, PS0_14_FN2,
1777 PS0_13_FN3, PS0_13_FN1, 1991 PS0_13_FN1, PS0_13_FN2,
1778 PS0_12_FN3, PS0_12_FN1, 1992 PS0_12_FN1, PS0_12_FN2,
1779 0, 0, 1993 PS0_11_FN1, PS0_11_FN2,
1780 0, 0, 1994 PS0_10_FN1, PS0_10_FN2,
1995 PS0_9_FN1, PS0_9_FN2,
1996 PS0_8_FN1, PS0_8_FN2,
1997 PS0_7_FN1, PS0_7_FN2,
1998 PS0_6_FN1, PS0_6_FN2,
1999 PS0_5_FN1, PS0_5_FN2,
2000 PS0_4_FN1, PS0_4_FN2,
2001 PS0_3_FN1, PS0_3_FN2,
2002 PS0_2_FN1, PS0_2_FN2,
1781 0, 0, 2003 0, 0,
1782 0, 0,
1783 PS0_7_FN2, PS0_7_FN1,
1784 PS0_6_FN2, PS0_6_FN1,
1785 PS0_5_FN2, PS0_5_FN1,
1786 PS0_4_FN2, PS0_4_FN1,
1787 PS0_3_FN2, PS0_3_FN1,
1788 PS0_2_FN2, PS0_2_FN1,
1789 PS0_1_FN2, PS0_1_FN1,
1790 0, 0, } 2004 0, 0, }
1791 }, 2005 },
1792 { PINMUX_CFG_REG("PSEL1", 0xffec0072, 16, 1) { 2006 { PINMUX_CFG_REG("PSEL1", 0xffec0072, 16, 1) {
@@ -1795,73 +2009,136 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1795 0, 0, 2009 0, 0,
1796 0, 0, 2010 0, 0,
1797 0, 0, 2011 0, 0,
2012 PS1_10_FN1, PS1_10_FN2,
2013 PS1_9_FN1, PS1_9_FN2,
2014 PS1_8_FN1, PS1_8_FN2,
1798 0, 0, 2015 0, 0,
1799 0, 0, 2016 0, 0,
1800 0, 0, 2017 0, 0,
1801 PS1_7_FN1, PS1_7_FN3,
1802 PS1_6_FN1, PS1_6_FN3,
1803 0, 0,
1804 0, 0,
1805 0, 0, 2018 0, 0,
1806 0, 0, 2019 0, 0,
2020 PS1_2_FN1, PS1_2_FN2,
1807 0, 0, 2021 0, 0,
1808 0, 0, } 2022 0, 0, }
1809 }, 2023 },
1810 { PINMUX_CFG_REG("PSEL2", 0xffec0074, 16, 1) { 2024 { PINMUX_CFG_REG("PSEL2", 0xffec0074, 16, 1) {
1811 0, 0, 2025 0, 0,
1812 0, 0, 2026 0, 0,
1813 PS2_13_FN3, PS2_13_FN1, 2027 PS2_13_FN1, PS2_13_FN2,
1814 PS2_12_FN3, PS2_12_FN1, 2028 PS2_12_FN1, PS2_12_FN2,
1815 0, 0, 2029 0, 0,
1816 0, 0, 2030 0, 0,
1817 0, 0, 2031 0, 0,
1818 0, 0, 2032 0, 0,
2033 PS2_7_FN1, PS2_7_FN2,
2034 PS2_6_FN1, PS2_6_FN2,
2035 PS2_5_FN1, PS2_5_FN2,
2036 PS2_4_FN1, PS2_4_FN2,
1819 0, 0, 2037 0, 0,
2038 PS2_2_FN1, PS2_2_FN2,
1820 0, 0, 2039 0, 0,
2040 0, 0, }
2041 },
2042 { PINMUX_CFG_REG("PSEL3", 0xffec0076, 16, 1) {
2043 PS3_15_FN1, PS3_15_FN2,
2044 PS3_14_FN1, PS3_14_FN2,
2045 PS3_13_FN1, PS3_13_FN2,
2046 PS3_12_FN1, PS3_12_FN2,
2047 PS3_11_FN1, PS3_11_FN2,
2048 PS3_10_FN1, PS3_10_FN2,
2049 PS3_9_FN1, PS3_9_FN2,
2050 PS3_8_FN1, PS3_8_FN2,
2051 PS3_7_FN1, PS3_7_FN2,
1821 0, 0, 2052 0, 0,
1822 0, 0, 2053 0, 0,
1823 0, 0, 2054 0, 0,
1824 0, 0, 2055 0, 0,
1825 PS2_1_FN1, PS2_1_FN2, 2056 PS3_2_FN1, PS3_2_FN2,
1826 PS2_0_FN1, PS2_0_FN2, } 2057 PS3_1_FN1, PS3_1_FN2,
2058 0, 0, }
1827 }, 2059 },
2060
1828 { PINMUX_CFG_REG("PSEL4", 0xffec0078, 16, 1) { 2061 { PINMUX_CFG_REG("PSEL4", 0xffec0078, 16, 1) {
1829 PS4_15_FN2, PS4_15_FN1,
1830 PS4_14_FN2, PS4_14_FN1,
1831 PS4_13_FN2, PS4_13_FN1,
1832 PS4_12_FN2, PS4_12_FN1,
1833 PS4_11_FN2, PS4_11_FN1,
1834 PS4_10_FN2, PS4_10_FN1,
1835 PS4_9_FN2, PS4_9_FN1,
1836 0, 0, 2062 0, 0,
2063 PS4_14_FN1, PS4_14_FN2,
2064 PS4_13_FN1, PS4_13_FN2,
2065 PS4_12_FN1, PS4_12_FN2,
1837 0, 0, 2066 0, 0,
2067 PS4_10_FN1, PS4_10_FN2,
2068 PS4_9_FN1, PS4_9_FN2,
2069 PS4_8_FN1, PS4_8_FN2,
1838 0, 0, 2070 0, 0,
1839 0, 0, 2071 0, 0,
1840 0, 0, 2072 0, 0,
1841 PS4_3_FN2, PS4_3_FN1, 2073 PS4_4_FN1, PS4_4_FN2,
1842 PS4_2_FN2, PS4_2_FN1, 2074 PS4_3_FN1, PS4_3_FN2,
1843 PS4_1_FN2, PS4_1_FN1, 2075 PS4_2_FN1, PS4_2_FN2,
1844 PS4_0_FN2, PS4_0_FN1, } 2076 PS4_1_FN1, PS4_1_FN2,
2077 PS4_0_FN1, PS4_0_FN2, }
1845 }, 2078 },
1846 { PINMUX_CFG_REG("PSEL5", 0xffec007a, 16, 1) { 2079 { PINMUX_CFG_REG("PSEL5", 0xffec007a, 16, 1) {
1847 0, 0, 2080 0, 0,
1848 0, 0, 2081 0, 0,
1849 0, 0, 2082 0, 0,
1850 0, 0, 2083 0, 0,
1851 0, 0, 2084 PS5_11_FN1, PS5_11_FN2,
1852 0, 0, 2085 PS5_10_FN1, PS5_10_FN2,
1853 PS5_9_FN1, PS5_9_FN2, 2086 PS5_9_FN1, PS5_9_FN2,
1854 PS5_8_FN1, PS5_8_FN2, 2087 PS5_8_FN1, PS5_8_FN2,
1855 PS5_7_FN1, PS5_7_FN2, 2088 PS5_7_FN1, PS5_7_FN2,
1856 PS5_6_FN1, PS5_6_FN2, 2089 PS5_6_FN1, PS5_6_FN2,
1857 PS5_5_FN1, PS5_5_FN2, 2090 PS5_5_FN1, PS5_5_FN2,
2091 PS5_4_FN1, PS5_4_FN2,
2092 PS5_3_FN1, PS5_3_FN2,
2093 PS5_2_FN1, PS5_2_FN2,
2094 0, 0,
2095 0, 0, }
2096 },
2097 { PINMUX_CFG_REG("PSEL6", 0xffec007c, 16, 1) {
2098 PS6_15_FN1, PS6_15_FN2,
2099 PS6_14_FN1, PS6_14_FN2,
2100 PS6_13_FN1, PS6_13_FN2,
2101 PS6_12_FN1, PS6_12_FN2,
2102 PS6_11_FN1, PS6_11_FN2,
2103 PS6_10_FN1, PS6_10_FN2,
2104 PS6_9_FN1, PS6_9_FN2,
2105 PS6_8_FN1, PS6_8_FN2,
2106 PS6_7_FN1, PS6_7_FN2,
2107 PS6_6_FN1, PS6_6_FN2,
2108 PS6_5_FN1, PS6_5_FN2,
2109 PS6_4_FN1, PS6_4_FN2,
2110 PS6_3_FN1, PS6_3_FN2,
2111 PS6_2_FN1, PS6_2_FN2,
2112 PS6_1_FN1, PS6_1_FN2,
2113 PS6_0_FN1, PS6_0_FN2, }
2114 },
2115 { PINMUX_CFG_REG("PSEL7", 0xffec0082, 16, 1) {
2116 PS7_15_FN1, PS7_15_FN2,
2117 PS7_14_FN1, PS7_14_FN2,
2118 PS7_13_FN1, PS7_13_FN2,
2119 PS7_12_FN1, PS7_12_FN2,
2120 PS7_11_FN1, PS7_11_FN2,
2121 PS7_10_FN1, PS7_10_FN2,
2122 PS7_9_FN1, PS7_9_FN2,
2123 PS7_8_FN1, PS7_8_FN2,
2124 PS7_7_FN1, PS7_7_FN2,
2125 PS7_6_FN1, PS7_6_FN2,
2126 PS7_5_FN1, PS7_5_FN2,
1858 0, 0, 2127 0, 0,
1859 0, 0, 2128 0, 0,
1860 0, 0, 2129 0, 0,
1861 0, 0, 2130 0, 0,
1862 0, 0, } 2131 0, 0, }
1863 }, 2132 },
1864 { PINMUX_CFG_REG("PSEL6", 0xffec007c, 16, 1) { 2133 { PINMUX_CFG_REG("PSEL8", 0xffec0084, 16, 1) {
2134 PS8_15_FN1, PS8_15_FN2,
2135 PS8_14_FN1, PS8_14_FN2,
2136 PS8_13_FN1, PS8_13_FN2,
2137 PS8_12_FN1, PS8_12_FN2,
2138 PS8_11_FN1, PS8_11_FN2,
2139 PS8_10_FN1, PS8_10_FN2,
2140 PS8_9_FN1, PS8_9_FN2,
2141 PS8_8_FN1, PS8_8_FN2,
1865 0, 0, 2142 0, 0,
1866 0, 0, 2143 0, 0,
1867 0, 0, 2144 0, 0,
@@ -1869,15 +2146,7 @@ static struct pinmux_cfg_reg pinmux_config_regs[] = {
1869 0, 0, 2146 0, 0,
1870 0, 0, 2147 0, 0,
1871 0, 0, 2148 0, 0,
1872 0, 0, 2149 0, 0, }
1873 PS6_7_FN_AN, PS6_7_FN_EV,
1874 PS6_6_FN_AN, PS6_6_FN_EV,
1875 PS6_5_FN_AN, PS6_5_FN_EV,
1876 PS6_4_FN_AN, PS6_4_FN_EV,
1877 PS6_3_FN_AN, PS6_3_FN_EV,
1878 PS6_2_FN_AN, PS6_2_FN_EV,
1879 PS6_1_FN_AN, PS6_1_FN_EV,
1880 PS6_0_FN_AN, PS6_0_FN_EV, }
1881 }, 2150 },
1882 {} 2151 {}
1883}; 2152};
@@ -1920,7 +2189,7 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1920 PTI3_DATA, PTI2_DATA, PTI1_DATA, PTI0_DATA } 2189 PTI3_DATA, PTI2_DATA, PTI1_DATA, PTI0_DATA }
1921 }, 2190 },
1922 { PINMUX_DATA_REG("PJDR", 0xffec0046, 8) { 2191 { PINMUX_DATA_REG("PJDR", 0xffec0046, 8) {
1923 PTJ7_DATA, PTJ6_DATA, PTJ5_DATA, PTJ4_DATA, 2192 0, PTJ6_DATA, PTJ5_DATA, PTJ4_DATA,
1924 PTJ3_DATA, PTJ2_DATA, PTJ1_DATA, PTJ0_DATA } 2193 PTJ3_DATA, PTJ2_DATA, PTJ1_DATA, PTJ0_DATA }
1925 }, 2194 },
1926 { PINMUX_DATA_REG("PKDR", 0xffec0048, 8) { 2195 { PINMUX_DATA_REG("PKDR", 0xffec0048, 8) {
@@ -1928,15 +2197,15 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1928 PTK3_DATA, PTK2_DATA, PTK1_DATA, PTK0_DATA } 2197 PTK3_DATA, PTK2_DATA, PTK1_DATA, PTK0_DATA }
1929 }, 2198 },
1930 { PINMUX_DATA_REG("PLDR", 0xffec004a, 8) { 2199 { PINMUX_DATA_REG("PLDR", 0xffec004a, 8) {
1931 PTL7_DATA, PTL6_DATA, PTL5_DATA, PTL4_DATA, 2200 0, PTL6_DATA, PTL5_DATA, PTL4_DATA,
1932 PTL3_DATA, PTL2_DATA, PTL1_DATA, PTL0_DATA } 2201 PTL3_DATA, PTL2_DATA, PTL1_DATA, PTL0_DATA }
1933 }, 2202 },
1934 { PINMUX_DATA_REG("PMDR", 0xffec004c, 8) { 2203 { PINMUX_DATA_REG("PMDR", 0xffec004c, 8) {
1935 0, PTM6_DATA, PTM5_DATA, PTM4_DATA, 2204 PTM7_DATA, PTM6_DATA, PTM5_DATA, PTM4_DATA,
1936 PTM3_DATA, PTM2_DATA, PTM1_DATA, PTM0_DATA } 2205 PTM3_DATA, PTM2_DATA, PTM1_DATA, PTM0_DATA }
1937 }, 2206 },
1938 { PINMUX_DATA_REG("PNDR", 0xffec004e, 8) { 2207 { PINMUX_DATA_REG("PNDR", 0xffec004e, 8) {
1939 PTN7_DATA, PTN6_DATA, PTN5_DATA, PTN4_DATA, 2208 0, PTN6_DATA, PTN5_DATA, PTN4_DATA,
1940 PTN3_DATA, PTN2_DATA, PTN1_DATA, PTN0_DATA } 2209 PTN3_DATA, PTN2_DATA, PTN1_DATA, PTN0_DATA }
1941 }, 2210 },
1942 { PINMUX_DATA_REG("PODR", 0xffec0050, 8) { 2211 { PINMUX_DATA_REG("PODR", 0xffec0050, 8) {
@@ -1944,7 +2213,7 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1944 PTO3_DATA, PTO2_DATA, PTO1_DATA, PTO0_DATA } 2213 PTO3_DATA, PTO2_DATA, PTO1_DATA, PTO0_DATA }
1945 }, 2214 },
1946 { PINMUX_DATA_REG("PPDR", 0xffec0052, 8) { 2215 { PINMUX_DATA_REG("PPDR", 0xffec0052, 8) {
1947 0, PTP6_DATA, PTP5_DATA, PTP4_DATA, 2216 PTP7_DATA, PTP6_DATA, PTP5_DATA, PTP4_DATA,
1948 PTP3_DATA, PTP2_DATA, PTP1_DATA, PTP0_DATA } 2217 PTP3_DATA, PTP2_DATA, PTP1_DATA, PTP0_DATA }
1949 }, 2218 },
1950 { PINMUX_DATA_REG("PQDR", 0xffec0054, 8) { 2219 { PINMUX_DATA_REG("PQDR", 0xffec0054, 8) {
@@ -1960,7 +2229,7 @@ static struct pinmux_data_reg pinmux_data_regs[] = {
1960 PTS3_DATA, PTS2_DATA, PTS1_DATA, PTS0_DATA } 2229 PTS3_DATA, PTS2_DATA, PTS1_DATA, PTS0_DATA }
1961 }, 2230 },
1962 { PINMUX_DATA_REG("PTDR", 0xffec005a, 8) { 2231 { PINMUX_DATA_REG("PTDR", 0xffec005a, 8) {
1963 0, 0, PTT5_DATA, PTT4_DATA, 2232 PTT7_DATA, PTT6_DATA, PTT5_DATA, PTT4_DATA,
1964 PTT3_DATA, PTT2_DATA, PTT1_DATA, PTT0_DATA } 2233 PTT3_DATA, PTT2_DATA, PTT1_DATA, PTT0_DATA }
1965 }, 2234 },
1966 { PINMUX_DATA_REG("PUDR", 0xffec005c, 8) { 2235 { PINMUX_DATA_REG("PUDR", 0xffec005c, 8) {
@@ -2000,8 +2269,8 @@ static struct pinmux_info sh7757_pinmux_info = {
2000 .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END }, 2269 .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
2001 .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END }, 2270 .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
2002 2271
2003 .first_gpio = GPIO_PTA7, 2272 .first_gpio = GPIO_PTA0,
2004 .last_gpio = GPIO_FN_D0, 2273 .last_gpio = GPIO_FN_ON_DQ0,
2005 2274
2006 .gpios = pinmux_gpios, 2275 .gpios = pinmux_gpios,
2007 .cfg_regs = pinmux_config_regs, 2276 .cfg_regs = pinmux_config_regs,
@@ -2015,5 +2284,4 @@ static int __init plat_pinmux_setup(void)
2015{ 2284{
2016 return register_pinmux(&sh7757_pinmux_info); 2285 return register_pinmux(&sh7757_pinmux_info);
2017} 2286}
2018
2019arch_initcall(plat_pinmux_setup); 2287arch_initcall(plat_pinmux_setup);
diff --git a/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c b/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c
new file mode 100644
index 000000000000..aaa5338abbff
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4a/pinmux-shx3.c
@@ -0,0 +1,587 @@
1/*
2 * SH-X3 prototype CPU pinmux
3 *
4 * Copyright (C) 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/gpio.h>
13#include <cpu/shx3.h>
14
15enum {
16 PINMUX_RESERVED = 0,
17
18 PINMUX_DATA_BEGIN,
19 PA7_DATA, PA6_DATA, PA5_DATA, PA4_DATA,
20 PA3_DATA, PA2_DATA, PA1_DATA, PA0_DATA,
21 PB7_DATA, PB6_DATA, PB5_DATA, PB4_DATA,
22 PB3_DATA, PB2_DATA, PB1_DATA, PB0_DATA,
23 PC7_DATA, PC6_DATA, PC5_DATA, PC4_DATA,
24 PC3_DATA, PC2_DATA, PC1_DATA, PC0_DATA,
25 PD7_DATA, PD6_DATA, PD5_DATA, PD4_DATA,
26 PD3_DATA, PD2_DATA, PD1_DATA, PD0_DATA,
27 PE7_DATA, PE6_DATA, PE5_DATA, PE4_DATA,
28 PE3_DATA, PE2_DATA, PE1_DATA, PE0_DATA,
29 PF7_DATA, PF6_DATA, PF5_DATA, PF4_DATA,
30 PF3_DATA, PF2_DATA, PF1_DATA, PF0_DATA,
31 PG7_DATA, PG6_DATA, PG5_DATA, PG4_DATA,
32 PG3_DATA, PG2_DATA, PG1_DATA, PG0_DATA,
33
34 PH5_DATA, PH4_DATA,
35 PH3_DATA, PH2_DATA, PH1_DATA, PH0_DATA,
36 PINMUX_DATA_END,
37
38 PINMUX_INPUT_BEGIN,
39 PA7_IN, PA6_IN, PA5_IN, PA4_IN,
40 PA3_IN, PA2_IN, PA1_IN, PA0_IN,
41 PB7_IN, PB6_IN, PB5_IN, PB4_IN,
42 PB3_IN, PB2_IN, PB1_IN, PB0_IN,
43 PC7_IN, PC6_IN, PC5_IN, PC4_IN,
44 PC3_IN, PC2_IN, PC1_IN, PC0_IN,
45 PD7_IN, PD6_IN, PD5_IN, PD4_IN,
46 PD3_IN, PD2_IN, PD1_IN, PD0_IN,
47 PE7_IN, PE6_IN, PE5_IN, PE4_IN,
48 PE3_IN, PE2_IN, PE1_IN, PE0_IN,
49 PF7_IN, PF6_IN, PF5_IN, PF4_IN,
50 PF3_IN, PF2_IN, PF1_IN, PF0_IN,
51 PG7_IN, PG6_IN, PG5_IN, PG4_IN,
52 PG3_IN, PG2_IN, PG1_IN, PG0_IN,
53
54 PH5_IN, PH4_IN,
55 PH3_IN, PH2_IN, PH1_IN, PH0_IN,
56 PINMUX_INPUT_END,
57
58 PINMUX_INPUT_PULLUP_BEGIN,
59 PA7_IN_PU, PA6_IN_PU, PA5_IN_PU, PA4_IN_PU,
60 PA3_IN_PU, PA2_IN_PU, PA1_IN_PU, PA0_IN_PU,
61 PB7_IN_PU, PB6_IN_PU, PB5_IN_PU, PB4_IN_PU,
62 PB3_IN_PU, PB2_IN_PU, PB1_IN_PU, PB0_IN_PU,
63 PC7_IN_PU, PC6_IN_PU, PC5_IN_PU, PC4_IN_PU,
64 PC3_IN_PU, PC2_IN_PU, PC1_IN_PU, PC0_IN_PU,
65 PD7_IN_PU, PD6_IN_PU, PD5_IN_PU, PD4_IN_PU,
66 PD3_IN_PU, PD2_IN_PU, PD1_IN_PU, PD0_IN_PU,
67 PE7_IN_PU, PE6_IN_PU, PE5_IN_PU, PE4_IN_PU,
68 PE3_IN_PU, PE2_IN_PU, PE1_IN_PU, PE0_IN_PU,
69 PF7_IN_PU, PF6_IN_PU, PF5_IN_PU, PF4_IN_PU,
70 PF3_IN_PU, PF2_IN_PU, PF1_IN_PU, PF0_IN_PU,
71 PG7_IN_PU, PG6_IN_PU, PG5_IN_PU, PG4_IN_PU,
72 PG3_IN_PU, PG2_IN_PU, PG1_IN_PU, PG0_IN_PU,
73
74 PH5_IN_PU, PH4_IN_PU,
75 PH3_IN_PU, PH2_IN_PU, PH1_IN_PU, PH0_IN_PU,
76 PINMUX_INPUT_PULLUP_END,
77
78 PINMUX_OUTPUT_BEGIN,
79 PA7_OUT, PA6_OUT, PA5_OUT, PA4_OUT,
80 PA3_OUT, PA2_OUT, PA1_OUT, PA0_OUT,
81 PB7_OUT, PB6_OUT, PB5_OUT, PB4_OUT,
82 PB3_OUT, PB2_OUT, PB1_OUT, PB0_OUT,
83 PC7_OUT, PC6_OUT, PC5_OUT, PC4_OUT,
84 PC3_OUT, PC2_OUT, PC1_OUT, PC0_OUT,
85 PD7_OUT, PD6_OUT, PD5_OUT, PD4_OUT,
86 PD3_OUT, PD2_OUT, PD1_OUT, PD0_OUT,
87 PE7_OUT, PE6_OUT, PE5_OUT, PE4_OUT,
88 PE3_OUT, PE2_OUT, PE1_OUT, PE0_OUT,
89 PF7_OUT, PF6_OUT, PF5_OUT, PF4_OUT,
90 PF3_OUT, PF2_OUT, PF1_OUT, PF0_OUT,
91 PG7_OUT, PG6_OUT, PG5_OUT, PG4_OUT,
92 PG3_OUT, PG2_OUT, PG1_OUT, PG0_OUT,
93
94 PH5_OUT, PH4_OUT,
95 PH3_OUT, PH2_OUT, PH1_OUT, PH0_OUT,
96 PINMUX_OUTPUT_END,
97
98 PINMUX_FUNCTION_BEGIN,
99 PA7_FN, PA6_FN, PA5_FN, PA4_FN,
100 PA3_FN, PA2_FN, PA1_FN, PA0_FN,
101 PB7_FN, PB6_FN, PB5_FN, PB4_FN,
102 PB3_FN, PB2_FN, PB1_FN, PB0_FN,
103 PC7_FN, PC6_FN, PC5_FN, PC4_FN,
104 PC3_FN, PC2_FN, PC1_FN, PC0_FN,
105 PD7_FN, PD6_FN, PD5_FN, PD4_FN,
106 PD3_FN, PD2_FN, PD1_FN, PD0_FN,
107 PE7_FN, PE6_FN, PE5_FN, PE4_FN,
108 PE3_FN, PE2_FN, PE1_FN, PE0_FN,
109 PF7_FN, PF6_FN, PF5_FN, PF4_FN,
110 PF3_FN, PF2_FN, PF1_FN, PF0_FN,
111 PG7_FN, PG6_FN, PG5_FN, PG4_FN,
112 PG3_FN, PG2_FN, PG1_FN, PG0_FN,
113
114 PH5_FN, PH4_FN,
115 PH3_FN, PH2_FN, PH1_FN, PH0_FN,
116 PINMUX_FUNCTION_END,
117
118 PINMUX_MARK_BEGIN,
119
120 D31_MARK, D30_MARK, D29_MARK, D28_MARK, D27_MARK, D26_MARK,
121 D25_MARK, D24_MARK, D23_MARK, D22_MARK, D21_MARK, D20_MARK,
122 D19_MARK, D18_MARK, D17_MARK, D16_MARK,
123
124 BACK_MARK, BREQ_MARK,
125 WE3_MARK, WE2_MARK,
126 CS6_MARK, CS5_MARK, CS4_MARK,
127 CLKOUTENB_MARK,
128
129 DACK3_MARK, DACK2_MARK, DACK1_MARK, DACK0_MARK,
130 DREQ3_MARK, DREQ2_MARK, DREQ1_MARK, DREQ0_MARK,
131
132 IRQ3_MARK, IRQ2_MARK, IRQ1_MARK, IRQ0_MARK,
133
134 DRAK3_MARK, DRAK2_MARK, DRAK1_MARK, DRAK0_MARK,
135
136 SCK3_MARK, SCK2_MARK, SCK1_MARK, SCK0_MARK,
137 IRL3_MARK, IRL2_MARK, IRL1_MARK, IRL0_MARK,
138 TXD3_MARK, TXD2_MARK, TXD1_MARK, TXD0_MARK,
139 RXD3_MARK, RXD2_MARK, RXD1_MARK, RXD0_MARK,
140
141 CE2B_MARK, CE2A_MARK, IOIS16_MARK,
142 STATUS1_MARK, STATUS0_MARK,
143
144 IRQOUT_MARK,
145
146 PINMUX_MARK_END,
147};
148
149static pinmux_enum_t shx3_pinmux_data[] = {
150
151 /* PA GPIO */
152 PINMUX_DATA(PA7_DATA, PA7_IN, PA7_OUT, PA7_IN_PU),
153 PINMUX_DATA(PA6_DATA, PA6_IN, PA6_OUT, PA6_IN_PU),
154 PINMUX_DATA(PA5_DATA, PA5_IN, PA5_OUT, PA5_IN_PU),
155 PINMUX_DATA(PA4_DATA, PA4_IN, PA4_OUT, PA4_IN_PU),
156 PINMUX_DATA(PA3_DATA, PA3_IN, PA3_OUT, PA3_IN_PU),
157 PINMUX_DATA(PA2_DATA, PA2_IN, PA2_OUT, PA2_IN_PU),
158 PINMUX_DATA(PA1_DATA, PA1_IN, PA1_OUT, PA1_IN_PU),
159 PINMUX_DATA(PA0_DATA, PA0_IN, PA0_OUT, PA0_IN_PU),
160
161 /* PB GPIO */
162 PINMUX_DATA(PB7_DATA, PB7_IN, PB7_OUT, PB7_IN_PU),
163 PINMUX_DATA(PB6_DATA, PB6_IN, PB6_OUT, PB6_IN_PU),
164 PINMUX_DATA(PB5_DATA, PB5_IN, PB5_OUT, PB5_IN_PU),
165 PINMUX_DATA(PB4_DATA, PB4_IN, PB4_OUT, PB4_IN_PU),
166 PINMUX_DATA(PB3_DATA, PB3_IN, PB3_OUT, PB3_IN_PU),
167 PINMUX_DATA(PB2_DATA, PB2_IN, PB2_OUT, PB2_IN_PU),
168 PINMUX_DATA(PB1_DATA, PB1_IN, PB1_OUT, PB1_IN_PU),
169 PINMUX_DATA(PB0_DATA, PB0_IN, PB0_OUT, PB0_IN_PU),
170
171 /* PC GPIO */
172 PINMUX_DATA(PC7_DATA, PC7_IN, PC7_OUT, PC7_IN_PU),
173 PINMUX_DATA(PC6_DATA, PC6_IN, PC6_OUT, PC6_IN_PU),
174 PINMUX_DATA(PC5_DATA, PC5_IN, PC5_OUT, PC5_IN_PU),
175 PINMUX_DATA(PC4_DATA, PC4_IN, PC4_OUT, PC4_IN_PU),
176 PINMUX_DATA(PC3_DATA, PC3_IN, PC3_OUT, PC3_IN_PU),
177 PINMUX_DATA(PC2_DATA, PC2_IN, PC2_OUT, PC2_IN_PU),
178 PINMUX_DATA(PC1_DATA, PC1_IN, PC1_OUT, PC1_IN_PU),
179 PINMUX_DATA(PC0_DATA, PC0_IN, PC0_OUT, PC0_IN_PU),
180
181 /* PD GPIO */
182 PINMUX_DATA(PD7_DATA, PD7_IN, PD7_OUT, PD7_IN_PU),
183 PINMUX_DATA(PD6_DATA, PD6_IN, PD6_OUT, PD6_IN_PU),
184 PINMUX_DATA(PD5_DATA, PD5_IN, PD5_OUT, PD5_IN_PU),
185 PINMUX_DATA(PD4_DATA, PD4_IN, PD4_OUT, PD4_IN_PU),
186 PINMUX_DATA(PD3_DATA, PD3_IN, PD3_OUT, PD3_IN_PU),
187 PINMUX_DATA(PD2_DATA, PD2_IN, PD2_OUT, PD2_IN_PU),
188 PINMUX_DATA(PD1_DATA, PD1_IN, PD1_OUT, PD1_IN_PU),
189 PINMUX_DATA(PD0_DATA, PD0_IN, PD0_OUT, PD0_IN_PU),
190
191 /* PE GPIO */
192 PINMUX_DATA(PE7_DATA, PE7_IN, PE7_OUT, PE7_IN_PU),
193 PINMUX_DATA(PE6_DATA, PE6_IN, PE6_OUT, PE6_IN_PU),
194 PINMUX_DATA(PE5_DATA, PE5_IN, PE5_OUT, PE5_IN_PU),
195 PINMUX_DATA(PE4_DATA, PE4_IN, PE4_OUT, PE4_IN_PU),
196 PINMUX_DATA(PE3_DATA, PE3_IN, PE3_OUT, PE3_IN_PU),
197 PINMUX_DATA(PE2_DATA, PE2_IN, PE2_OUT, PE2_IN_PU),
198 PINMUX_DATA(PE1_DATA, PE1_IN, PE1_OUT, PE1_IN_PU),
199 PINMUX_DATA(PE0_DATA, PE0_IN, PE0_OUT, PE0_IN_PU),
200
201 /* PF GPIO */
202 PINMUX_DATA(PF7_DATA, PF7_IN, PF7_OUT, PF7_IN_PU),
203 PINMUX_DATA(PF6_DATA, PF6_IN, PF6_OUT, PF6_IN_PU),
204 PINMUX_DATA(PF5_DATA, PF5_IN, PF5_OUT, PF5_IN_PU),
205 PINMUX_DATA(PF4_DATA, PF4_IN, PF4_OUT, PF4_IN_PU),
206 PINMUX_DATA(PF3_DATA, PF3_IN, PF3_OUT, PF3_IN_PU),
207 PINMUX_DATA(PF2_DATA, PF2_IN, PF2_OUT, PF2_IN_PU),
208 PINMUX_DATA(PF1_DATA, PF1_IN, PF1_OUT, PF1_IN_PU),
209 PINMUX_DATA(PF0_DATA, PF0_IN, PF0_OUT, PF0_IN_PU),
210
211 /* PG GPIO */
212 PINMUX_DATA(PG7_DATA, PG7_IN, PG7_OUT, PG7_IN_PU),
213 PINMUX_DATA(PG6_DATA, PG6_IN, PG6_OUT, PG6_IN_PU),
214 PINMUX_DATA(PG5_DATA, PG5_IN, PG5_OUT, PG5_IN_PU),
215 PINMUX_DATA(PG4_DATA, PG4_IN, PG4_OUT, PG4_IN_PU),
216 PINMUX_DATA(PG3_DATA, PG3_IN, PG3_OUT, PG3_IN_PU),
217 PINMUX_DATA(PG2_DATA, PG2_IN, PG2_OUT, PG2_IN_PU),
218 PINMUX_DATA(PG1_DATA, PG1_IN, PG1_OUT, PG1_IN_PU),
219 PINMUX_DATA(PG0_DATA, PG0_IN, PG0_OUT, PG0_IN_PU),
220
221 /* PH GPIO */
222 PINMUX_DATA(PH5_DATA, PH5_IN, PH5_OUT, PH5_IN_PU),
223 PINMUX_DATA(PH4_DATA, PH4_IN, PH4_OUT, PH4_IN_PU),
224 PINMUX_DATA(PH3_DATA, PH3_IN, PH3_OUT, PH3_IN_PU),
225 PINMUX_DATA(PH2_DATA, PH2_IN, PH2_OUT, PH2_IN_PU),
226 PINMUX_DATA(PH1_DATA, PH1_IN, PH1_OUT, PH1_IN_PU),
227 PINMUX_DATA(PH0_DATA, PH0_IN, PH0_OUT, PH0_IN_PU),
228
229 /* PA FN */
230 PINMUX_DATA(D31_MARK, PA7_FN),
231 PINMUX_DATA(D30_MARK, PA6_FN),
232 PINMUX_DATA(D29_MARK, PA5_FN),
233 PINMUX_DATA(D28_MARK, PA4_FN),
234 PINMUX_DATA(D27_MARK, PA3_FN),
235 PINMUX_DATA(D26_MARK, PA2_FN),
236 PINMUX_DATA(D25_MARK, PA1_FN),
237 PINMUX_DATA(D24_MARK, PA0_FN),
238
239 /* PB FN */
240 PINMUX_DATA(D23_MARK, PB7_FN),
241 PINMUX_DATA(D22_MARK, PB6_FN),
242 PINMUX_DATA(D21_MARK, PB5_FN),
243 PINMUX_DATA(D20_MARK, PB4_FN),
244 PINMUX_DATA(D19_MARK, PB3_FN),
245 PINMUX_DATA(D18_MARK, PB2_FN),
246 PINMUX_DATA(D17_MARK, PB1_FN),
247 PINMUX_DATA(D16_MARK, PB0_FN),
248
249 /* PC FN */
250 PINMUX_DATA(BACK_MARK, PC7_FN),
251 PINMUX_DATA(BREQ_MARK, PC6_FN),
252 PINMUX_DATA(WE3_MARK, PC5_FN),
253 PINMUX_DATA(WE2_MARK, PC4_FN),
254 PINMUX_DATA(CS6_MARK, PC3_FN),
255 PINMUX_DATA(CS5_MARK, PC2_FN),
256 PINMUX_DATA(CS4_MARK, PC1_FN),
257 PINMUX_DATA(CLKOUTENB_MARK, PC0_FN),
258
259 /* PD FN */
260 PINMUX_DATA(DACK3_MARK, PD7_FN),
261 PINMUX_DATA(DACK2_MARK, PD6_FN),
262 PINMUX_DATA(DACK1_MARK, PD5_FN),
263 PINMUX_DATA(DACK0_MARK, PD4_FN),
264 PINMUX_DATA(DREQ3_MARK, PD3_FN),
265 PINMUX_DATA(DREQ2_MARK, PD2_FN),
266 PINMUX_DATA(DREQ1_MARK, PD1_FN),
267 PINMUX_DATA(DREQ0_MARK, PD0_FN),
268
269 /* PE FN */
270 PINMUX_DATA(IRQ3_MARK, PE7_FN),
271 PINMUX_DATA(IRQ2_MARK, PE6_FN),
272 PINMUX_DATA(IRQ1_MARK, PE5_FN),
273 PINMUX_DATA(IRQ0_MARK, PE4_FN),
274 PINMUX_DATA(DRAK3_MARK, PE3_FN),
275 PINMUX_DATA(DRAK2_MARK, PE2_FN),
276 PINMUX_DATA(DRAK1_MARK, PE1_FN),
277 PINMUX_DATA(DRAK0_MARK, PE0_FN),
278
279 /* PF FN */
280 PINMUX_DATA(SCK3_MARK, PF7_FN),
281 PINMUX_DATA(SCK2_MARK, PF6_FN),
282 PINMUX_DATA(SCK1_MARK, PF5_FN),
283 PINMUX_DATA(SCK0_MARK, PF4_FN),
284 PINMUX_DATA(IRL3_MARK, PF3_FN),
285 PINMUX_DATA(IRL2_MARK, PF2_FN),
286 PINMUX_DATA(IRL1_MARK, PF1_FN),
287 PINMUX_DATA(IRL0_MARK, PF0_FN),
288
289 /* PG FN */
290 PINMUX_DATA(TXD3_MARK, PG7_FN),
291 PINMUX_DATA(TXD2_MARK, PG6_FN),
292 PINMUX_DATA(TXD1_MARK, PG5_FN),
293 PINMUX_DATA(TXD0_MARK, PG4_FN),
294 PINMUX_DATA(RXD3_MARK, PG3_FN),
295 PINMUX_DATA(RXD2_MARK, PG2_FN),
296 PINMUX_DATA(RXD1_MARK, PG1_FN),
297 PINMUX_DATA(RXD0_MARK, PG0_FN),
298
299 /* PH FN */
300 PINMUX_DATA(CE2B_MARK, PH5_FN),
301 PINMUX_DATA(CE2A_MARK, PH4_FN),
302 PINMUX_DATA(IOIS16_MARK, PH3_FN),
303 PINMUX_DATA(STATUS1_MARK, PH2_FN),
304 PINMUX_DATA(STATUS0_MARK, PH1_FN),
305 PINMUX_DATA(IRQOUT_MARK, PH0_FN),
306};
307
308static struct pinmux_gpio shx3_pinmux_gpios[] = {
309 /* PA */
310 PINMUX_GPIO(GPIO_PA7, PA7_DATA),
311 PINMUX_GPIO(GPIO_PA6, PA6_DATA),
312 PINMUX_GPIO(GPIO_PA5, PA5_DATA),
313 PINMUX_GPIO(GPIO_PA4, PA4_DATA),
314 PINMUX_GPIO(GPIO_PA3, PA3_DATA),
315 PINMUX_GPIO(GPIO_PA2, PA2_DATA),
316 PINMUX_GPIO(GPIO_PA1, PA1_DATA),
317 PINMUX_GPIO(GPIO_PA0, PA0_DATA),
318
319 /* PB */
320 PINMUX_GPIO(GPIO_PB7, PB7_DATA),
321 PINMUX_GPIO(GPIO_PB6, PB6_DATA),
322 PINMUX_GPIO(GPIO_PB5, PB5_DATA),
323 PINMUX_GPIO(GPIO_PB4, PB4_DATA),
324 PINMUX_GPIO(GPIO_PB3, PB3_DATA),
325 PINMUX_GPIO(GPIO_PB2, PB2_DATA),
326 PINMUX_GPIO(GPIO_PB1, PB1_DATA),
327 PINMUX_GPIO(GPIO_PB0, PB0_DATA),
328
329 /* PC */
330 PINMUX_GPIO(GPIO_PC7, PC7_DATA),
331 PINMUX_GPIO(GPIO_PC6, PC6_DATA),
332 PINMUX_GPIO(GPIO_PC5, PC5_DATA),
333 PINMUX_GPIO(GPIO_PC4, PC4_DATA),
334 PINMUX_GPIO(GPIO_PC3, PC3_DATA),
335 PINMUX_GPIO(GPIO_PC2, PC2_DATA),
336 PINMUX_GPIO(GPIO_PC1, PC1_DATA),
337 PINMUX_GPIO(GPIO_PC0, PC0_DATA),
338
339 /* PD */
340 PINMUX_GPIO(GPIO_PD7, PD7_DATA),
341 PINMUX_GPIO(GPIO_PD6, PD6_DATA),
342 PINMUX_GPIO(GPIO_PD5, PD5_DATA),
343 PINMUX_GPIO(GPIO_PD4, PD4_DATA),
344 PINMUX_GPIO(GPIO_PD3, PD3_DATA),
345 PINMUX_GPIO(GPIO_PD2, PD2_DATA),
346 PINMUX_GPIO(GPIO_PD1, PD1_DATA),
347 PINMUX_GPIO(GPIO_PD0, PD0_DATA),
348
349 /* PE */
350 PINMUX_GPIO(GPIO_PE7, PE7_DATA),
351 PINMUX_GPIO(GPIO_PE6, PE6_DATA),
352 PINMUX_GPIO(GPIO_PE5, PE5_DATA),
353 PINMUX_GPIO(GPIO_PE4, PE4_DATA),
354 PINMUX_GPIO(GPIO_PE3, PE3_DATA),
355 PINMUX_GPIO(GPIO_PE2, PE2_DATA),
356 PINMUX_GPIO(GPIO_PE1, PE1_DATA),
357 PINMUX_GPIO(GPIO_PE0, PE0_DATA),
358
359 /* PF */
360 PINMUX_GPIO(GPIO_PF7, PF7_DATA),
361 PINMUX_GPIO(GPIO_PF6, PF6_DATA),
362 PINMUX_GPIO(GPIO_PF5, PF5_DATA),
363 PINMUX_GPIO(GPIO_PF4, PF4_DATA),
364 PINMUX_GPIO(GPIO_PF3, PF3_DATA),
365 PINMUX_GPIO(GPIO_PF2, PF2_DATA),
366 PINMUX_GPIO(GPIO_PF1, PF1_DATA),
367 PINMUX_GPIO(GPIO_PF0, PF0_DATA),
368
369 /* PG */
370 PINMUX_GPIO(GPIO_PG7, PG7_DATA),
371 PINMUX_GPIO(GPIO_PG6, PG6_DATA),
372 PINMUX_GPIO(GPIO_PG5, PG5_DATA),
373 PINMUX_GPIO(GPIO_PG4, PG4_DATA),
374 PINMUX_GPIO(GPIO_PG3, PG3_DATA),
375 PINMUX_GPIO(GPIO_PG2, PG2_DATA),
376 PINMUX_GPIO(GPIO_PG1, PG1_DATA),
377 PINMUX_GPIO(GPIO_PG0, PG0_DATA),
378
379 /* PH */
380 PINMUX_GPIO(GPIO_PH5, PH5_DATA),
381 PINMUX_GPIO(GPIO_PH4, PH4_DATA),
382 PINMUX_GPIO(GPIO_PH3, PH3_DATA),
383 PINMUX_GPIO(GPIO_PH2, PH2_DATA),
384 PINMUX_GPIO(GPIO_PH1, PH1_DATA),
385 PINMUX_GPIO(GPIO_PH0, PH0_DATA),
386
387 /* FN */
388 PINMUX_GPIO(GPIO_FN_D31, D31_MARK),
389 PINMUX_GPIO(GPIO_FN_D30, D30_MARK),
390 PINMUX_GPIO(GPIO_FN_D29, D29_MARK),
391 PINMUX_GPIO(GPIO_FN_D28, D28_MARK),
392 PINMUX_GPIO(GPIO_FN_D27, D27_MARK),
393 PINMUX_GPIO(GPIO_FN_D26, D26_MARK),
394 PINMUX_GPIO(GPIO_FN_D25, D25_MARK),
395 PINMUX_GPIO(GPIO_FN_D24, D24_MARK),
396 PINMUX_GPIO(GPIO_FN_D23, D23_MARK),
397 PINMUX_GPIO(GPIO_FN_D22, D22_MARK),
398 PINMUX_GPIO(GPIO_FN_D21, D21_MARK),
399 PINMUX_GPIO(GPIO_FN_D20, D20_MARK),
400 PINMUX_GPIO(GPIO_FN_D19, D19_MARK),
401 PINMUX_GPIO(GPIO_FN_D18, D18_MARK),
402 PINMUX_GPIO(GPIO_FN_D17, D17_MARK),
403 PINMUX_GPIO(GPIO_FN_D16, D16_MARK),
404 PINMUX_GPIO(GPIO_FN_BACK, BACK_MARK),
405 PINMUX_GPIO(GPIO_FN_BREQ, BREQ_MARK),
406 PINMUX_GPIO(GPIO_FN_WE3, WE3_MARK),
407 PINMUX_GPIO(GPIO_FN_WE2, WE2_MARK),
408 PINMUX_GPIO(GPIO_FN_CS6, CS6_MARK),
409 PINMUX_GPIO(GPIO_FN_CS5, CS5_MARK),
410 PINMUX_GPIO(GPIO_FN_CS4, CS4_MARK),
411 PINMUX_GPIO(GPIO_FN_CLKOUTENB, CLKOUTENB_MARK),
412 PINMUX_GPIO(GPIO_FN_DACK3, DACK3_MARK),
413 PINMUX_GPIO(GPIO_FN_DACK2, DACK2_MARK),
414 PINMUX_GPIO(GPIO_FN_DACK1, DACK1_MARK),
415 PINMUX_GPIO(GPIO_FN_DACK0, DACK0_MARK),
416 PINMUX_GPIO(GPIO_FN_DREQ3, DREQ3_MARK),
417 PINMUX_GPIO(GPIO_FN_DREQ2, DREQ2_MARK),
418 PINMUX_GPIO(GPIO_FN_DREQ1, DREQ1_MARK),
419 PINMUX_GPIO(GPIO_FN_DREQ0, DREQ0_MARK),
420 PINMUX_GPIO(GPIO_FN_IRQ3, IRQ3_MARK),
421 PINMUX_GPIO(GPIO_FN_IRQ2, IRQ2_MARK),
422 PINMUX_GPIO(GPIO_FN_IRQ1, IRQ1_MARK),
423 PINMUX_GPIO(GPIO_FN_IRQ0, IRQ0_MARK),
424 PINMUX_GPIO(GPIO_FN_DRAK3, DRAK3_MARK),
425 PINMUX_GPIO(GPIO_FN_DRAK2, DRAK2_MARK),
426 PINMUX_GPIO(GPIO_FN_DRAK1, DRAK1_MARK),
427 PINMUX_GPIO(GPIO_FN_DRAK0, DRAK0_MARK),
428 PINMUX_GPIO(GPIO_FN_SCK3, SCK3_MARK),
429 PINMUX_GPIO(GPIO_FN_SCK2, SCK2_MARK),
430 PINMUX_GPIO(GPIO_FN_SCK1, SCK1_MARK),
431 PINMUX_GPIO(GPIO_FN_SCK0, SCK0_MARK),
432 PINMUX_GPIO(GPIO_FN_IRL3, IRL3_MARK),
433 PINMUX_GPIO(GPIO_FN_IRL2, IRL2_MARK),
434 PINMUX_GPIO(GPIO_FN_IRL1, IRL1_MARK),
435 PINMUX_GPIO(GPIO_FN_IRL0, IRL0_MARK),
436 PINMUX_GPIO(GPIO_FN_TXD3, TXD3_MARK),
437 PINMUX_GPIO(GPIO_FN_TXD2, TXD2_MARK),
438 PINMUX_GPIO(GPIO_FN_TXD1, TXD1_MARK),
439 PINMUX_GPIO(GPIO_FN_TXD0, TXD0_MARK),
440 PINMUX_GPIO(GPIO_FN_RXD3, RXD3_MARK),
441 PINMUX_GPIO(GPIO_FN_RXD2, RXD2_MARK),
442 PINMUX_GPIO(GPIO_FN_RXD1, RXD1_MARK),
443 PINMUX_GPIO(GPIO_FN_RXD0, RXD0_MARK),
444 PINMUX_GPIO(GPIO_FN_CE2B, CE2B_MARK),
445 PINMUX_GPIO(GPIO_FN_CE2A, CE2A_MARK),
446 PINMUX_GPIO(GPIO_FN_IOIS16, IOIS16_MARK),
447 PINMUX_GPIO(GPIO_FN_STATUS1, STATUS1_MARK),
448 PINMUX_GPIO(GPIO_FN_STATUS0, STATUS0_MARK),
449 PINMUX_GPIO(GPIO_FN_IRQOUT, IRQOUT_MARK),
450};
451
452static struct pinmux_cfg_reg shx3_pinmux_config_regs[] = {
453 { PINMUX_CFG_REG("PABCR", 0xffc70000, 32, 2) {
454 PA7_FN, PA7_OUT, PA7_IN, PA7_IN_PU,
455 PA6_FN, PA6_OUT, PA6_IN, PA6_IN_PU,
456 PA5_FN, PA5_OUT, PA5_IN, PA5_IN_PU,
457 PA4_FN, PA4_OUT, PA4_IN, PA4_IN_PU,
458 PA3_FN, PA3_OUT, PA3_IN, PA3_IN_PU,
459 PA2_FN, PA2_OUT, PA2_IN, PA2_IN_PU,
460 PA1_FN, PA1_OUT, PA1_IN, PA1_IN_PU,
461 PA0_FN, PA0_OUT, PA0_IN, PA0_IN_PU,
462 PB7_FN, PB7_OUT, PB7_IN, PB7_IN_PU,
463 PB6_FN, PB6_OUT, PB6_IN, PB6_IN_PU,
464 PB5_FN, PB5_OUT, PB5_IN, PB5_IN_PU,
465 PB4_FN, PB4_OUT, PB4_IN, PB4_IN_PU,
466 PB3_FN, PB3_OUT, PB3_IN, PB3_IN_PU,
467 PB2_FN, PB2_OUT, PB2_IN, PB2_IN_PU,
468 PB1_FN, PB1_OUT, PB1_IN, PB1_IN_PU,
469 PB0_FN, PB0_OUT, PB0_IN, PB0_IN_PU, },
470 },
471 { PINMUX_CFG_REG("PCDCR", 0xffc70004, 32, 2) {
472 PC7_FN, PC7_OUT, PC7_IN, PC7_IN_PU,
473 PC6_FN, PC6_OUT, PC6_IN, PC6_IN_PU,
474 PC5_FN, PC5_OUT, PC5_IN, PC5_IN_PU,
475 PC4_FN, PC4_OUT, PC4_IN, PC4_IN_PU,
476 PC3_FN, PC3_OUT, PC3_IN, PC3_IN_PU,
477 PC2_FN, PC2_OUT, PC2_IN, PC2_IN_PU,
478 PC1_FN, PC1_OUT, PC1_IN, PC1_IN_PU,
479 PC0_FN, PC0_OUT, PC0_IN, PC0_IN_PU,
480 PD7_FN, PD7_OUT, PD7_IN, PD7_IN_PU,
481 PD6_FN, PD6_OUT, PD6_IN, PD6_IN_PU,
482 PD5_FN, PD5_OUT, PD5_IN, PD5_IN_PU,
483 PD4_FN, PD4_OUT, PD4_IN, PD4_IN_PU,
484 PD3_FN, PD3_OUT, PD3_IN, PD3_IN_PU,
485 PD2_FN, PD2_OUT, PD2_IN, PD2_IN_PU,
486 PD1_FN, PD1_OUT, PD1_IN, PD1_IN_PU,
487 PD0_FN, PD0_OUT, PD0_IN, PD0_IN_PU, },
488 },
489 { PINMUX_CFG_REG("PEFCR", 0xffc70008, 32, 2) {
490 PE7_FN, PE7_OUT, PE7_IN, PE7_IN_PU,
491 PE6_FN, PE6_OUT, PE6_IN, PE6_IN_PU,
492 PE5_FN, PE5_OUT, PE5_IN, PE5_IN_PU,
493 PE4_FN, PE4_OUT, PE4_IN, PE4_IN_PU,
494 PE3_FN, PE3_OUT, PE3_IN, PE3_IN_PU,
495 PE2_FN, PE2_OUT, PE2_IN, PE2_IN_PU,
496 PE1_FN, PE1_OUT, PE1_IN, PE1_IN_PU,
497 PE0_FN, PE0_OUT, PE0_IN, PE0_IN_PU,
498 PF7_FN, PF7_OUT, PF7_IN, PF7_IN_PU,
499 PF6_FN, PF6_OUT, PF6_IN, PF6_IN_PU,
500 PF5_FN, PF5_OUT, PF5_IN, PF5_IN_PU,
501 PF4_FN, PF4_OUT, PF4_IN, PF4_IN_PU,
502 PF3_FN, PF3_OUT, PF3_IN, PF3_IN_PU,
503 PF2_FN, PF2_OUT, PF2_IN, PF2_IN_PU,
504 PF1_FN, PF1_OUT, PF1_IN, PF1_IN_PU,
505 PF0_FN, PF0_OUT, PF0_IN, PF0_IN_PU, },
506 },
507 { PINMUX_CFG_REG("PGHCR", 0xffc7000c, 32, 2) {
508 PG7_FN, PG7_OUT, PG7_IN, PG7_IN_PU,
509 PG6_FN, PG6_OUT, PG6_IN, PG6_IN_PU,
510 PG5_FN, PG5_OUT, PG5_IN, PG5_IN_PU,
511 PG4_FN, PG4_OUT, PG4_IN, PG4_IN_PU,
512 PG3_FN, PG3_OUT, PG3_IN, PG3_IN_PU,
513 PG2_FN, PG2_OUT, PG2_IN, PG2_IN_PU,
514 PG1_FN, PG1_OUT, PG1_IN, PG1_IN_PU,
515 PG0_FN, PG0_OUT, PG0_IN, PG0_IN_PU,
516 0, 0, 0, 0,
517 0, 0, 0, 0,
518 PH5_FN, PH5_OUT, PH5_IN, PH5_IN_PU,
519 PH4_FN, PH4_OUT, PH4_IN, PH4_IN_PU,
520 PH3_FN, PH3_OUT, PH3_IN, PH3_IN_PU,
521 PH2_FN, PH2_OUT, PH2_IN, PH2_IN_PU,
522 PH1_FN, PH1_OUT, PH1_IN, PH1_IN_PU,
523 PH0_FN, PH0_OUT, PH0_IN, PH0_IN_PU, },
524 },
525 { },
526};
527
528static struct pinmux_data_reg shx3_pinmux_data_regs[] = {
529 { PINMUX_DATA_REG("PABDR", 0xffc70010, 32) {
530 0, 0, 0, 0, 0, 0, 0, 0,
531 PA7_DATA, PA6_DATA, PA5_DATA, PA4_DATA,
532 PA3_DATA, PA2_DATA, PA1_DATA, PA0_DATA,
533 0, 0, 0, 0, 0, 0, 0, 0,
534 PB7_DATA, PB6_DATA, PB5_DATA, PB4_DATA,
535 PB3_DATA, PB2_DATA, PB1_DATA, PB0_DATA, },
536 },
537 { PINMUX_DATA_REG("PCDDR", 0xffc70014, 32) {
538 0, 0, 0, 0, 0, 0, 0, 0,
539 PC7_DATA, PC6_DATA, PC5_DATA, PC4_DATA,
540 PC3_DATA, PC2_DATA, PC1_DATA, PC0_DATA,
541 0, 0, 0, 0, 0, 0, 0, 0,
542 PD7_DATA, PD6_DATA, PD5_DATA, PD4_DATA,
543 PD3_DATA, PD2_DATA, PD1_DATA, PD0_DATA, },
544 },
545 { PINMUX_DATA_REG("PEFDR", 0xffc70018, 32) {
546 0, 0, 0, 0, 0, 0, 0, 0,
547 PE7_DATA, PE6_DATA, PE5_DATA, PE4_DATA,
548 PE3_DATA, PE2_DATA, PE1_DATA, PE0_DATA,
549 0, 0, 0, 0, 0, 0, 0, 0,
550 PF7_DATA, PF6_DATA, PF5_DATA, PF4_DATA,
551 PF3_DATA, PF2_DATA, PF1_DATA, PF0_DATA, },
552 },
553 { PINMUX_DATA_REG("PGHDR", 0xffc7001c, 32) {
554 0, 0, 0, 0, 0, 0, 0, 0,
555 PG7_DATA, PG6_DATA, PG5_DATA, PG4_DATA,
556 PG3_DATA, PG2_DATA, PG1_DATA, PG0_DATA,
557 0, 0, 0, 0, 0, 0, 0, 0,
558 0, 0, PH5_DATA, PH4_DATA,
559 PH3_DATA, PH2_DATA, PH1_DATA, PH0_DATA, },
560 },
561 { },
562};
563
564static struct pinmux_info shx3_pinmux_info = {
565 .name = "shx3_pfc",
566 .reserved_id = PINMUX_RESERVED,
567 .data = { PINMUX_DATA_BEGIN, PINMUX_DATA_END },
568 .input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
569 .input_pu = { PINMUX_INPUT_PULLUP_BEGIN,
570 PINMUX_INPUT_PULLUP_END },
571 .output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
572 .mark = { PINMUX_MARK_BEGIN, PINMUX_MARK_END },
573 .function = { PINMUX_FUNCTION_BEGIN, PINMUX_FUNCTION_END },
574 .first_gpio = GPIO_PA7,
575 .last_gpio = GPIO_FN_IRQOUT,
576 .gpios = shx3_pinmux_gpios,
577 .gpio_data = shx3_pinmux_data,
578 .gpio_data_size = ARRAY_SIZE(shx3_pinmux_data),
579 .cfg_regs = shx3_pinmux_config_regs,
580 .data_regs = shx3_pinmux_data_regs,
581};
582
583static int __init shx3_pinmux_setup(void)
584{
585 return register_pinmux(&shx3_pinmux_info);
586}
587arch_initcall(shx3_pinmux_setup);
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
index 79c556e56262..828c9657eb52 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
@@ -524,6 +524,70 @@ static struct platform_device veu1_device = {
524 }, 524 },
525}; 525};
526 526
527/* BEU0 */
528static struct uio_info beu0_platform_data = {
529 .name = "BEU0",
530 .version = "0",
531 .irq = evt2irq(0x8A0),
532};
533
534static struct resource beu0_resources[] = {
535 [0] = {
536 .name = "BEU0",
537 .start = 0xfe930000,
538 .end = 0xfe933400,
539 .flags = IORESOURCE_MEM,
540 },
541 [1] = {
542 /* place holder for contiguous memory */
543 },
544};
545
546static struct platform_device beu0_device = {
547 .name = "uio_pdrv_genirq",
548 .id = 6,
549 .dev = {
550 .platform_data = &beu0_platform_data,
551 },
552 .resource = beu0_resources,
553 .num_resources = ARRAY_SIZE(beu0_resources),
554 .archdata = {
555 .hwblk_id = HWBLK_BEU0,
556 },
557};
558
559/* BEU1 */
560static struct uio_info beu1_platform_data = {
561 .name = "BEU1",
562 .version = "0",
563 .irq = evt2irq(0xA00),
564};
565
566static struct resource beu1_resources[] = {
567 [0] = {
568 .name = "BEU1",
569 .start = 0xfe940000,
570 .end = 0xfe943400,
571 .flags = IORESOURCE_MEM,
572 },
573 [1] = {
574 /* place holder for contiguous memory */
575 },
576};
577
578static struct platform_device beu1_device = {
579 .name = "uio_pdrv_genirq",
580 .id = 7,
581 .dev = {
582 .platform_data = &beu1_platform_data,
583 },
584 .resource = beu1_resources,
585 .num_resources = ARRAY_SIZE(beu1_resources),
586 .archdata = {
587 .hwblk_id = HWBLK_BEU1,
588 },
589};
590
527static struct sh_timer_config cmt_platform_data = { 591static struct sh_timer_config cmt_platform_data = {
528 .channel_offset = 0x60, 592 .channel_offset = 0x60,
529 .timer_bit = 5, 593 .timer_bit = 5,
@@ -857,6 +921,8 @@ static struct platform_device *sh7724_devices[] __initdata = {
857 &vpu_device, 921 &vpu_device,
858 &veu0_device, 922 &veu0_device,
859 &veu1_device, 923 &veu1_device,
924 &beu0_device,
925 &beu1_device,
860 &jpu_device, 926 &jpu_device,
861 &spu0_device, 927 &spu0_device,
862 &spu1_device, 928 &spu1_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
index 444aca95b20d..749c6388d5a5 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7757.c
@@ -26,7 +26,7 @@ static struct plat_sci_port scif2_platform_data = {
26 26
27static struct platform_device scif2_device = { 27static struct platform_device scif2_device = {
28 .name = "sh-sci", 28 .name = "sh-sci",
29 .id = 2, 29 .id = 0,
30 .dev = { 30 .dev = {
31 .platform_data = &scif2_platform_data, 31 .platform_data = &scif2_platform_data,
32 }, 32 },
@@ -41,7 +41,7 @@ static struct plat_sci_port scif3_platform_data = {
41 41
42static struct platform_device scif3_device = { 42static struct platform_device scif3_device = {
43 .name = "sh-sci", 43 .name = "sh-sci",
44 .id = 3, 44 .id = 1,
45 .dev = { 45 .dev = {
46 .platform_data = &scif3_platform_data, 46 .platform_data = &scif3_platform_data,
47 }, 47 },
@@ -56,7 +56,7 @@ static struct plat_sci_port scif4_platform_data = {
56 56
57static struct platform_device scif4_device = { 57static struct platform_device scif4_device = {
58 .name = "sh-sci", 58 .name = "sh-sci",
59 .id = 4, 59 .id = 2,
60 .dev = { 60 .dev = {
61 .platform_data = &scif4_platform_data, 61 .platform_data = &scif4_platform_data,
62 }, 62 },
@@ -163,39 +163,23 @@ enum {
163 IRL4_HHLL, IRL4_HHLH, IRL4_HHHL, 163 IRL4_HHLL, IRL4_HHLH, IRL4_HHHL,
164 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7, 164 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
165 165
166 SDHI, 166 SDHI, DVC,
167 DVC, 167 IRQ8, IRQ9, IRQ11, IRQ10, IRQ12, IRQ13, IRQ14, IRQ15,
168 IRQ8, IRQ9, IRQ10, 168 TMU0, TMU1, TMU2, TMU2_TICPI, TMU3, TMU4, TMU5,
169 WDT0,
170 TMU0, TMU1, TMU2, TMU2_TICPI,
171 HUDI, 169 HUDI,
172
173 ARC4, 170 ARC4,
174 DMAC0, 171 DMAC0_5, DMAC6_7, DMAC8_11,
175 IRQ11, 172 SCIF0, SCIF1, SCIF2, SCIF3, SCIF4,
176 SCIF2, 173 USB0, USB1,
177 DMAC1_6,
178 USB0,
179 IRQ12,
180 JMC, 174 JMC,
181 SPI1, 175 SPI0, SPI1,
182 IRQ13, IRQ14,
183 USB1,
184 TMR01, TMR23, TMR45, 176 TMR01, TMR23, TMR45,
185 WDT1,
186 FRT, 177 FRT,
187 LPC, 178 LPC, LPC5, LPC6, LPC7, LPC8,
188 SCIF0, SCIF1, SCIF3, 179 PECI0, PECI1, PECI2, PECI3, PECI4, PECI5,
189 PECI0I, PECI1I, PECI2I,
190 IRQ15,
191 ETHERC, 180 ETHERC,
192 SPI0, 181 ADC0, ADC1,
193 ADC1,
194 DMAC1_8,
195 SIM, 182 SIM,
196 TMU3, TMU4, TMU5,
197 ADC0,
198 SCIF4,
199 IIC0_0, IIC0_1, IIC0_2, IIC0_3, 183 IIC0_0, IIC0_1, IIC0_2, IIC0_3,
200 IIC1_0, IIC1_1, IIC1_2, IIC1_3, 184 IIC1_0, IIC1_1, IIC1_2, IIC1_3,
201 IIC2_0, IIC2_1, IIC2_2, IIC2_3, 185 IIC2_0, IIC2_1, IIC2_2, IIC2_3,
@@ -206,9 +190,23 @@ enum {
206 IIC7_0, IIC7_1, IIC7_2, IIC7_3, 190 IIC7_0, IIC7_1, IIC7_2, IIC7_3,
207 IIC8_0, IIC8_1, IIC8_2, IIC8_3, 191 IIC8_0, IIC8_1, IIC8_2, IIC8_3,
208 IIC9_0, IIC9_1, IIC9_2, IIC9_3, 192 IIC9_0, IIC9_1, IIC9_2, IIC9_3,
209 PCIINTA, 193 ONFICTL,
210 PCIE, 194 MMC1, MMC2,
195 ECCU,
196 PCIC,
197 G200,
198 RSPI,
211 SGPIO, 199 SGPIO,
200 DMINT12, DMINT13, DMINT14, DMINT15, DMINT16, DMINT17, DMINT18, DMINT19,
201 DMINT20, DMINT21, DMINT22, DMINT23,
202 DDRECC,
203 TSIP,
204 PCIE_BRIDGE,
205 WDT0B, WDT1B, WDT2B, WDT3B, WDT4B, WDT5B, WDT6B, WDT7B, WDT8B,
206 GETHER0, GETHER1, GETHER2,
207 PBIA, PBIB, PBIC,
208 DMAE2, DMAE3,
209 SERMUX2, SERMUX3,
212 210
213 /* interrupt groups */ 211 /* interrupt groups */
214 212
@@ -221,19 +219,18 @@ static struct intc_vect vectors[] __initdata = {
221 INTC_VECT(DVC, 0x4e0), 219 INTC_VECT(DVC, 0x4e0),
222 INTC_VECT(IRQ8, 0x500), INTC_VECT(IRQ9, 0x520), 220 INTC_VECT(IRQ8, 0x500), INTC_VECT(IRQ9, 0x520),
223 INTC_VECT(IRQ10, 0x540), 221 INTC_VECT(IRQ10, 0x540),
224 INTC_VECT(WDT0, 0x560),
225 INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0), 222 INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),
226 INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0), 223 INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),
227 INTC_VECT(HUDI, 0x600), 224 INTC_VECT(HUDI, 0x600),
228 INTC_VECT(ARC4, 0x620), 225 INTC_VECT(ARC4, 0x620),
229 INTC_VECT(DMAC0, 0x640), INTC_VECT(DMAC0, 0x660), 226 INTC_VECT(DMAC0_5, 0x640), INTC_VECT(DMAC0_5, 0x660),
230 INTC_VECT(DMAC0, 0x680), INTC_VECT(DMAC0, 0x6a0), 227 INTC_VECT(DMAC0_5, 0x680), INTC_VECT(DMAC0_5, 0x6a0),
231 INTC_VECT(DMAC0, 0x6c0), 228 INTC_VECT(DMAC0_5, 0x6c0),
232 INTC_VECT(IRQ11, 0x6e0), 229 INTC_VECT(IRQ11, 0x6e0),
233 INTC_VECT(SCIF2, 0x700), INTC_VECT(SCIF2, 0x720), 230 INTC_VECT(SCIF2, 0x700), INTC_VECT(SCIF2, 0x720),
234 INTC_VECT(SCIF2, 0x740), INTC_VECT(SCIF2, 0x760), 231 INTC_VECT(SCIF2, 0x740), INTC_VECT(SCIF2, 0x760),
235 INTC_VECT(DMAC0, 0x780), INTC_VECT(DMAC0, 0x7a0), 232 INTC_VECT(DMAC0_5, 0x780), INTC_VECT(DMAC0_5, 0x7a0),
236 INTC_VECT(DMAC1_6, 0x7c0), INTC_VECT(DMAC1_6, 0x7e0), 233 INTC_VECT(DMAC6_7, 0x7c0), INTC_VECT(DMAC6_7, 0x7e0),
237 INTC_VECT(USB0, 0x840), 234 INTC_VECT(USB0, 0x840),
238 INTC_VECT(IRQ12, 0x880), 235 INTC_VECT(IRQ12, 0x880),
239 INTC_VECT(JMC, 0x8a0), 236 INTC_VECT(JMC, 0x8a0),
@@ -242,7 +239,6 @@ static struct intc_vect vectors[] __initdata = {
242 INTC_VECT(USB1, 0x920), 239 INTC_VECT(USB1, 0x920),
243 INTC_VECT(TMR01, 0xa00), INTC_VECT(TMR23, 0xa20), 240 INTC_VECT(TMR01, 0xa00), INTC_VECT(TMR23, 0xa20),
244 INTC_VECT(TMR45, 0xa40), 241 INTC_VECT(TMR45, 0xa40),
245 INTC_VECT(WDT1, 0xa60),
246 INTC_VECT(FRT, 0xa80), 242 INTC_VECT(FRT, 0xa80),
247 INTC_VECT(LPC, 0xaa0), INTC_VECT(LPC, 0xac0), 243 INTC_VECT(LPC, 0xaa0), INTC_VECT(LPC, 0xac0),
248 INTC_VECT(LPC, 0xae0), INTC_VECT(LPC, 0xb00), 244 INTC_VECT(LPC, 0xae0), INTC_VECT(LPC, 0xb00),
@@ -250,14 +246,14 @@ static struct intc_vect vectors[] __initdata = {
250 INTC_VECT(SCIF0, 0xb40), INTC_VECT(SCIF1, 0xb60), 246 INTC_VECT(SCIF0, 0xb40), INTC_VECT(SCIF1, 0xb60),
251 INTC_VECT(SCIF3, 0xb80), INTC_VECT(SCIF3, 0xba0), 247 INTC_VECT(SCIF3, 0xb80), INTC_VECT(SCIF3, 0xba0),
252 INTC_VECT(SCIF3, 0xbc0), INTC_VECT(SCIF3, 0xbe0), 248 INTC_VECT(SCIF3, 0xbc0), INTC_VECT(SCIF3, 0xbe0),
253 INTC_VECT(PECI0I, 0xc00), INTC_VECT(PECI1I, 0xc20), 249 INTC_VECT(PECI0, 0xc00), INTC_VECT(PECI1, 0xc20),
254 INTC_VECT(PECI2I, 0xc40), 250 INTC_VECT(PECI2, 0xc40),
255 INTC_VECT(IRQ15, 0xc60), 251 INTC_VECT(IRQ15, 0xc60),
256 INTC_VECT(ETHERC, 0xc80), INTC_VECT(ETHERC, 0xca0), 252 INTC_VECT(ETHERC, 0xc80), INTC_VECT(ETHERC, 0xca0),
257 INTC_VECT(SPI0, 0xcc0), 253 INTC_VECT(SPI0, 0xcc0),
258 INTC_VECT(ADC1, 0xce0), 254 INTC_VECT(ADC1, 0xce0),
259 INTC_VECT(DMAC1_8, 0xd00), INTC_VECT(DMAC1_8, 0xd20), 255 INTC_VECT(DMAC8_11, 0xd00), INTC_VECT(DMAC8_11, 0xd20),
260 INTC_VECT(DMAC1_8, 0xd40), INTC_VECT(DMAC1_8, 0xd60), 256 INTC_VECT(DMAC8_11, 0xd40), INTC_VECT(DMAC8_11, 0xd60),
261 INTC_VECT(SIM, 0xd80), INTC_VECT(SIM, 0xda0), 257 INTC_VECT(SIM, 0xd80), INTC_VECT(SIM, 0xda0),
262 INTC_VECT(SIM, 0xdc0), INTC_VECT(SIM, 0xde0), 258 INTC_VECT(SIM, 0xdc0), INTC_VECT(SIM, 0xde0),
263 INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20), 259 INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
@@ -278,17 +274,47 @@ static struct intc_vect vectors[] __initdata = {
278 INTC_VECT(IIC5_0, 0x1860), INTC_VECT(IIC5_1, 0x1880), 274 INTC_VECT(IIC5_0, 0x1860), INTC_VECT(IIC5_1, 0x1880),
279 INTC_VECT(IIC5_2, 0x18a0), INTC_VECT(IIC5_3, 0x18c0), 275 INTC_VECT(IIC5_2, 0x18a0), INTC_VECT(IIC5_3, 0x18c0),
280 INTC_VECT(IIC6_0, 0x18e0), INTC_VECT(IIC6_1, 0x1900), 276 INTC_VECT(IIC6_0, 0x18e0), INTC_VECT(IIC6_1, 0x1900),
281 INTC_VECT(IIC6_2, 0x1920), INTC_VECT(IIC6_3, 0x1980), 277 INTC_VECT(IIC6_2, 0x1920),
278 INTC_VECT(ONFICTL, 0x1960),
279 INTC_VECT(IIC6_3, 0x1980),
282 INTC_VECT(IIC7_0, 0x19a0), INTC_VECT(IIC7_1, 0x1a00), 280 INTC_VECT(IIC7_0, 0x19a0), INTC_VECT(IIC7_1, 0x1a00),
283 INTC_VECT(IIC7_2, 0x1a20), INTC_VECT(IIC7_3, 0x1a40), 281 INTC_VECT(IIC7_2, 0x1a20), INTC_VECT(IIC7_3, 0x1a40),
284 INTC_VECT(IIC8_0, 0x1a60), INTC_VECT(IIC8_1, 0x1a80), 282 INTC_VECT(IIC8_0, 0x1a60), INTC_VECT(IIC8_1, 0x1a80),
285 INTC_VECT(IIC8_2, 0x1aa0), INTC_VECT(IIC8_3, 0x1b40), 283 INTC_VECT(IIC8_2, 0x1aa0), INTC_VECT(IIC8_3, 0x1b40),
286 INTC_VECT(IIC9_0, 0x1b60), INTC_VECT(IIC9_1, 0x1b80), 284 INTC_VECT(IIC9_0, 0x1b60), INTC_VECT(IIC9_1, 0x1b80),
287 INTC_VECT(IIC9_2, 0x1c00), INTC_VECT(IIC9_3, 0x1c20), 285 INTC_VECT(IIC9_2, 0x1c00), INTC_VECT(IIC9_3, 0x1c20),
288 INTC_VECT(PCIINTA, 0x1ce0), 286 INTC_VECT(MMC1, 0x1c60), INTC_VECT(MMC2, 0x1c80),
289 INTC_VECT(PCIE, 0x1e00), 287 INTC_VECT(ECCU, 0x1cc0),
290 INTC_VECT(SGPIO, 0x1f80), 288 INTC_VECT(PCIC, 0x1ce0),
291 INTC_VECT(SGPIO, 0x1fa0), 289 INTC_VECT(G200, 0x1d00),
290 INTC_VECT(RSPI, 0x1d80), INTC_VECT(RSPI, 0x1da0),
291 INTC_VECT(RSPI, 0x1dc0), INTC_VECT(RSPI, 0x1de0),
292 INTC_VECT(PECI3, 0x1ec0), INTC_VECT(PECI4, 0x1ee0),
293 INTC_VECT(PECI5, 0x1f00),
294 INTC_VECT(SGPIO, 0x1f80), INTC_VECT(SGPIO, 0x1fa0),
295 INTC_VECT(SGPIO, 0x1fc0),
296 INTC_VECT(DMINT12, 0x2400), INTC_VECT(DMINT13, 0x2420),
297 INTC_VECT(DMINT14, 0x2440), INTC_VECT(DMINT15, 0x2460),
298 INTC_VECT(DMINT16, 0x2480), INTC_VECT(DMINT17, 0x24e0),
299 INTC_VECT(DMINT18, 0x2500), INTC_VECT(DMINT19, 0x2520),
300 INTC_VECT(DMINT20, 0x2540), INTC_VECT(DMINT21, 0x2560),
301 INTC_VECT(DMINT22, 0x2580), INTC_VECT(DMINT23, 0x2600),
302 INTC_VECT(DDRECC, 0x2620),
303 INTC_VECT(TSIP, 0x2640),
304 INTC_VECT(PCIE_BRIDGE, 0x27c0),
305 INTC_VECT(WDT0B, 0x2800), INTC_VECT(WDT1B, 0x2820),
306 INTC_VECT(WDT2B, 0x2840), INTC_VECT(WDT3B, 0x2860),
307 INTC_VECT(WDT4B, 0x2880), INTC_VECT(WDT5B, 0x28a0),
308 INTC_VECT(WDT6B, 0x28c0), INTC_VECT(WDT7B, 0x28e0),
309 INTC_VECT(WDT8B, 0x2900),
310 INTC_VECT(GETHER0, 0x2960), INTC_VECT(GETHER1, 0x2980),
311 INTC_VECT(GETHER2, 0x29a0),
312 INTC_VECT(PBIA, 0x2a00), INTC_VECT(PBIB, 0x2a20),
313 INTC_VECT(PBIC, 0x2a40),
314 INTC_VECT(DMAE2, 0x2a60), INTC_VECT(DMAE3, 0x2a80),
315 INTC_VECT(SERMUX2, 0x2aa0), INTC_VECT(SERMUX3, 0x2b40),
316 INTC_VECT(LPC5, 0x2b60), INTC_VECT(LPC6, 0x2b80),
317 INTC_VECT(LPC7, 0x2c00), INTC_VECT(LPC8, 0x2c20),
292}; 318};
293 319
294static struct intc_group groups[] __initdata = { 320static struct intc_group groups[] __initdata = {
@@ -312,31 +338,45 @@ static struct intc_mask_reg mask_registers[] __initdata = {
312 338
313 { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */ 339 { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
314 { 0, 0, 0, 0, 0, 0, 0, 0, 340 { 0, 0, 0, 0, 0, 0, 0, 0,
315 0, DMAC1_8, 0, PECI0I, LPC, FRT, WDT1, TMR45, 341 0, DMAC8_11, 0, PECI0, LPC, FRT, 0, TMR45,
316 TMR23, TMR01, 0, 0, 0, 0, 0, DMAC0, 342 TMR23, TMR01, 0, 0, 0, 0, 0, DMAC0_5,
317 HUDI, 0, WDT0, SCIF3, SCIF2, SDHI, TMU345, TMU012 343 HUDI, 0, 0, SCIF3, SCIF2, SDHI, TMU345, TMU012
318 } }, 344 } },
319 345
320 { 0xffd400d0, 0xffd400d4, 32, /* INT2MSKR1 / INT2MSKCR1 */ 346 { 0xffd400d0, 0xffd400d4, 32, /* INT2MSKR1 / INT2MSKCR1 */
321 { IRQ15, IRQ14, IRQ13, IRQ12, IRQ11, IRQ10, SCIF4, ETHERC, 347 { IRQ15, IRQ14, IRQ13, IRQ12, IRQ11, IRQ10, SCIF4, ETHERC,
322 IRQ9, IRQ8, SCIF1, SCIF0, USB0, 0, 0, USB1, 348 IRQ9, IRQ8, SCIF1, SCIF0, USB0, 0, 0, USB1,
323 ADC1, 0, DMAC1_6, ADC0, SPI0, SIM, PECI2I, PECI1I, 349 ADC1, 0, DMAC6_7, ADC0, SPI0, SIM, PECI2, PECI1,
324 ARC4, 0, SPI1, JMC, 0, 0, 0, DVC 350 ARC4, 0, SPI1, JMC, 0, 0, 0, DVC
325 } }, 351 } },
326 352
327 { 0xffd10038, 0xffd1003c, 32, /* INT2MSKR2 / INT2MSKCR2 */ 353 { 0xffd10038, 0xffd1003c, 32, /* INT2MSKR2 / INT2MSKCR2 */
328 { IIC4_1, IIC4_2, IIC5_0, 0, 0, 0, SGPIO, 0, 354 { IIC4_1, IIC4_2, IIC5_0, ONFICTL, 0, 0, SGPIO, 0,
329 0, 0, 0, IIC9_2, IIC8_2, IIC8_1, IIC8_0, IIC7_3, 355 0, G200, 0, IIC9_2, IIC8_2, IIC8_1, IIC8_0, IIC7_3,
330 IIC7_2, IIC7_1, IIC6_3, IIC0_0, IIC0_1, IIC0_2, IIC0_3, IIC3_1, 356 IIC7_2, IIC7_1, IIC6_3, IIC0_0, IIC0_1, IIC0_2, IIC0_3, IIC3_1,
331 IIC2_3, 0, IIC2_1, IIC9_1, IIC3_3, IIC1_0, PCIE, IIC2_2 357 IIC2_3, 0, IIC2_1, IIC9_1, IIC3_3, IIC1_0, 0, IIC2_2
332 } }, 358 } },
333 359
334 { 0xffd100d0, 0xff1400d4, 32, /* INT2MSKR3 / INT2MSKCR4 */ 360 { 0xffd100d0, 0xffd100d4, 32, /* INT2MSKR3 / INT2MSKCR3 */
335 { 0, IIC6_1, IIC6_0, IIC5_1, IIC3_2, IIC2_0, 0, 0, 361 { MMC1, IIC6_1, IIC6_0, IIC5_1, IIC3_2, IIC2_0, PECI5, MMC2,
336 IIC1_3, IIC1_2, IIC9_0, IIC8_3, IIC4_3, IIC7_0, 0, IIC6_2, 362 IIC1_3, IIC1_2, IIC9_0, IIC8_3, IIC4_3, IIC7_0, 0, IIC6_2,
337 PCIINTA, 0, IIC4_0, 0, 0, 0, 0, IIC9_3, 363 PCIC, 0, IIC4_0, 0, ECCU, RSPI, 0, IIC9_3,
338 IIC3_0, 0, IIC5_3, IIC5_2, 0, 0, 0, IIC1_1 364 IIC3_0, 0, IIC5_3, IIC5_2, 0, 0, 0, IIC1_1
339 } }, 365 } },
366
367 { 0xffd20038, 0xffd2003c, 32, /* INT2MSKR4 / INT2MSKCR4 */
368 { WDT0B, WDT1B, WDT3B, GETHER0, 0, 0, 0, 0,
369 0, 0, 0, LPC7, SERMUX2, DMAE3, DMAE2, PBIC,
370 PBIB, PBIA, GETHER1, DMINT12, DMINT13, DMINT14, DMINT15, TSIP,
371 DMINT23, 0, DMINT21, LPC6, 0, DMINT16, 0, DMINT22
372 } },
373
374 { 0xffd200d0, 0xffd200d4, 32, /* INT2MSKR5 / INT2MSKCR5 */
375 { 0, WDT8B, WDT7B, WDT4B, 0, DMINT20, 0, 0,
376 DMINT19, DMINT18, LPC5, SERMUX3, WDT2B, GETHER2, 0, 0,
377 0, 0, PCIE_BRIDGE, 0, 0, 0, 0, LPC8,
378 DDRECC, 0, WDT6B, WDT5B, 0, 0, 0, DMINT17
379 } },
340}; 380};
341 381
342#define INTPRI 0xffd00010 382#define INTPRI 0xffd00010
@@ -372,6 +412,22 @@ static struct intc_mask_reg mask_registers[] __initdata = {
372#define INT2PRI29 0xffd100b4 412#define INT2PRI29 0xffd100b4
373#define INT2PRI30 0xffd100b8 413#define INT2PRI30 0xffd100b8
374#define INT2PRI31 0xffd100bc 414#define INT2PRI31 0xffd100bc
415#define INT2PRI32 0xffd20000
416#define INT2PRI33 0xffd20004
417#define INT2PRI34 0xffd20008
418#define INT2PRI35 0xffd2000c
419#define INT2PRI36 0xffd20010
420#define INT2PRI37 0xffd20014
421#define INT2PRI38 0xffd20018
422#define INT2PRI39 0xffd2001c
423#define INT2PRI40 0xffd200a0
424#define INT2PRI41 0xffd200a4
425#define INT2PRI42 0xffd200a8
426#define INT2PRI43 0xffd200ac
427#define INT2PRI44 0xffd200b0
428#define INT2PRI45 0xffd200b4
429#define INT2PRI46 0xffd200b8
430#define INT2PRI47 0xffd200bc
375 431
376static struct intc_prio_reg prio_registers[] __initdata = { 432static struct intc_prio_reg prio_registers[] __initdata = {
377 { INTPRI, 0, 32, 4, { IRQ0, IRQ1, IRQ2, IRQ3, 433 { INTPRI, 0, 32, 4, { IRQ0, IRQ1, IRQ2, IRQ3,
@@ -379,39 +435,61 @@ static struct intc_prio_reg prio_registers[] __initdata = {
379 435
380 { INT2PRI0, 0, 32, 8, { TMU0, TMU1, TMU2, TMU2_TICPI } }, 436 { INT2PRI0, 0, 32, 8, { TMU0, TMU1, TMU2, TMU2_TICPI } },
381 { INT2PRI1, 0, 32, 8, { TMU3, TMU4, TMU5, SDHI } }, 437 { INT2PRI1, 0, 32, 8, { TMU3, TMU4, TMU5, SDHI } },
382 { INT2PRI2, 0, 32, 8, { SCIF2, SCIF3, WDT0, IRQ8 } }, 438 { INT2PRI2, 0, 32, 8, { SCIF2, SCIF3, 0, IRQ8 } },
383 { INT2PRI3, 0, 32, 8, { HUDI, DMAC0, ADC0, IRQ9 } }, 439 { INT2PRI3, 0, 32, 8, { HUDI, DMAC0_5, ADC0, IRQ9 } },
384 { INT2PRI4, 0, 32, 8, { IRQ10, 0, TMR01, TMR23 } }, 440 { INT2PRI4, 0, 32, 8, { IRQ10, 0, TMR01, TMR23 } },
385 { INT2PRI5, 0, 32, 8, { TMR45, WDT1, FRT, LPC } }, 441 { INT2PRI5, 0, 32, 8, { TMR45, 0, FRT, LPC } },
386 { INT2PRI6, 0, 32, 8, { PECI0I, ETHERC, DMAC1_8, 0 } }, 442 { INT2PRI6, 0, 32, 8, { PECI0, ETHERC, DMAC8_11, 0 } },
387 { INT2PRI7, 0, 32, 8, { SCIF4, 0, IRQ11, IRQ12 } }, 443 { INT2PRI7, 0, 32, 8, { SCIF4, 0, IRQ11, IRQ12 } },
388 { INT2PRI8, 0, 32, 8, { 0, 0, 0, DVC } }, 444 { INT2PRI8, 0, 32, 8, { 0, 0, 0, DVC } },
389 { INT2PRI9, 0, 32, 8, { ARC4, 0, SPI1, JMC } }, 445 { INT2PRI9, 0, 32, 8, { ARC4, 0, SPI1, JMC } },
390 { INT2PRI10, 0, 32, 8, { SPI0, SIM, PECI2I, PECI1I } }, 446 { INT2PRI10, 0, 32, 8, { SPI0, SIM, PECI2, PECI1 } },
391 { INT2PRI11, 0, 32, 8, { ADC1, IRQ13, DMAC1_6, IRQ14 } }, 447 { INT2PRI11, 0, 32, 8, { ADC1, IRQ13, DMAC6_7, IRQ14 } },
392 { INT2PRI12, 0, 32, 8, { USB0, 0, IRQ15, USB1 } }, 448 { INT2PRI12, 0, 32, 8, { USB0, 0, IRQ15, USB1 } },
393 { INT2PRI13, 0, 32, 8, { 0, 0, SCIF1, SCIF0 } }, 449 { INT2PRI13, 0, 32, 8, { 0, 0, SCIF1, SCIF0 } },
394 450
395 { INT2PRI16, 0, 32, 8, { IIC2_2, 0, 0, 0 } }, 451 { INT2PRI16, 0, 32, 8, { IIC2_2, 0, 0, 0 } },
396 { INT2PRI17, 0, 32, 8, { PCIE, 0, 0, IIC1_0 } }, 452 { INT2PRI17, 0, 32, 8, { 0, 0, 0, IIC1_0 } },
397 { INT2PRI18, 0, 32, 8, { IIC3_3, IIC9_1, IIC2_1, IIC1_2 } }, 453 { INT2PRI18, 0, 32, 8, { IIC3_3, IIC9_1, IIC2_1, IIC1_2 } },
398 { INT2PRI19, 0, 32, 8, { IIC2_3, IIC3_1, 0, IIC1_3 } }, 454 { INT2PRI19, 0, 32, 8, { IIC2_3, IIC3_1, 0, IIC1_3 } },
399 { INT2PRI20, 0, 32, 8, { IIC2_0, IIC6_3, IIC7_1, IIC7_2 } }, 455 { INT2PRI20, 0, 32, 8, { IIC2_0, IIC6_3, IIC7_1, IIC7_2 } },
400 { INT2PRI21, 0, 32, 8, { IIC7_3, IIC8_0, IIC8_1, IIC8_2 } }, 456 { INT2PRI21, 0, 32, 8, { IIC7_3, IIC8_0, IIC8_1, IIC8_2 } },
401 { INT2PRI22, 0, 32, 8, { IIC9_2, 0, 0, 0 } }, 457 { INT2PRI22, 0, 32, 8, { IIC9_2, MMC2, G200, 0 } },
402 { INT2PRI23, 0, 32, 8, { 0, SGPIO, IIC3_2, IIC5_1 } }, 458 { INT2PRI23, 0, 32, 8, { PECI5, SGPIO, IIC3_2, IIC5_1 } },
403 { INT2PRI24, 0, 32, 8, { 0, 0, 0, IIC1_1 } }, 459 { INT2PRI24, 0, 32, 8, { PECI4, PECI3, 0, IIC1_1 } },
404 { INT2PRI25, 0, 32, 8, { IIC3_0, 0, IIC5_3, IIC5_2 } }, 460 { INT2PRI25, 0, 32, 8, { IIC3_0, 0, IIC5_3, IIC5_2 } },
405 { INT2PRI26, 0, 32, 8, { 0, 0, 0, IIC9_3 } }, 461 { INT2PRI26, 0, 32, 8, { ECCU, RSPI, 0, IIC9_3 } },
406 { INT2PRI27, 0, 32, 8, { PCIINTA, IIC6_0, IIC4_0, IIC6_1 } }, 462 { INT2PRI27, 0, 32, 8, { PCIC, IIC6_0, IIC4_0, IIC6_1 } },
407 { INT2PRI28, 0, 32, 8, { IIC4_3, IIC7_0, 0, IIC6_2 } }, 463 { INT2PRI28, 0, 32, 8, { IIC4_3, IIC7_0, MMC1, IIC6_2 } },
408 { INT2PRI29, 0, 32, 8, { 0, 0, IIC9_0, IIC8_3 } }, 464 { INT2PRI29, 0, 32, 8, { 0, 0, IIC9_0, IIC8_3 } },
409 { INT2PRI30, 0, 32, 8, { IIC4_1, IIC4_2, IIC5_0, 0 } }, 465 { INT2PRI30, 0, 32, 8, { IIC4_1, IIC4_2, IIC5_0, ONFICTL } },
410 { INT2PRI31, 0, 32, 8, { IIC0_0, IIC0_1, IIC0_2, IIC0_3 } }, 466 { INT2PRI31, 0, 32, 8, { IIC0_0, IIC0_1, IIC0_2, IIC0_3 } },
467 { INT2PRI32, 0, 32, 8, { DMINT22, 0, 0, 0 } },
468 { INT2PRI33, 0, 32, 8, { 0, 0, 0, DMINT16 } },
469 { INT2PRI34, 0, 32, 8, { 0, LPC6, DMINT21, DMINT18 } },
470 { INT2PRI35, 0, 32, 8, { DMINT23, TSIP, 0, DMINT19 } },
471 { INT2PRI36, 0, 32, 8, { DMINT20, GETHER1, PBIA, PBIB } },
472 { INT2PRI37, 0, 32, 8, { PBIC, DMAE2, DMAE3, SERMUX2 } },
473 { INT2PRI38, 0, 32, 8, { LPC7, 0, 0, 0 } },
474 { INT2PRI39, 0, 32, 8, { 0, 0, 0, WDT4B } },
475 { INT2PRI40, 0, 32, 8, { 0, 0, 0, DMINT17 } },
476 { INT2PRI41, 0, 32, 8, { DDRECC, 0, WDT6B, WDT5B } },
477 { INT2PRI42, 0, 32, 8, { 0, 0, 0, LPC8 } },
478 { INT2PRI43, 0, 32, 8, { 0, WDT7B, PCIE_BRIDGE, WDT8B } },
479 { INT2PRI44, 0, 32, 8, { WDT2B, GETHER2, 0, 0 } },
480 { INT2PRI45, 0, 32, 8, { 0, 0, LPC5, SERMUX3 } },
481 { INT2PRI46, 0, 32, 8, { WDT0B, WDT1B, WDT3B, GETHER0 } },
482 { INT2PRI47, 0, 32, 8, { DMINT12, DMINT13, DMINT14, DMINT15 } },
483};
484
485static struct intc_sense_reg sense_registers_irq8to15[] __initdata = {
486 { 0xffd100f8, 32, 2, /* ICR2 */ { IRQ15, IRQ14, IRQ13, IRQ12,
487 IRQ11, IRQ10, IRQ9, IRQ8 } },
411}; 488};
412 489
413static DECLARE_INTC_DESC(intc_desc, "sh7757", vectors, groups, 490static DECLARE_INTC_DESC(intc_desc, "sh7757", vectors, groups,
414 mask_registers, prio_registers, NULL); 491 mask_registers, prio_registers,
492 sense_registers_irq8to15);
415 493
416/* Support for external interrupt pins in IRQ mode */ 494/* Support for external interrupt pins in IRQ mode */
417static struct intc_vect vectors_irq0123[] __initdata = { 495static struct intc_vect vectors_irq0123[] __initdata = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
index 8797723231ea..c016c0004714 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
@@ -629,33 +629,10 @@ static void __init sh7786_usb_setup(void)
629 } 629 }
630} 630}
631 631
632static int __init sh7786_devices_setup(void)
633{
634 int ret;
635
636 sh7786_usb_setup();
637
638 ret = platform_add_devices(sh7786_early_devices,
639 ARRAY_SIZE(sh7786_early_devices));
640 if (unlikely(ret != 0))
641 return ret;
642
643 return platform_add_devices(sh7786_devices,
644 ARRAY_SIZE(sh7786_devices));
645}
646arch_initcall(sh7786_devices_setup);
647
648void __init plat_early_device_setup(void)
649{
650 early_platform_add_devices(sh7786_early_devices,
651 ARRAY_SIZE(sh7786_early_devices));
652}
653
654enum { 632enum {
655 UNUSED = 0, 633 UNUSED = 0,
656 634
657 /* interrupt sources */ 635 /* interrupt sources */
658
659 IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH, 636 IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
660 IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH, 637 IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
661 IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH, 638 IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
@@ -693,9 +670,12 @@ enum {
693 Thermal, 670 Thermal,
694 INTICI0, INTICI1, INTICI2, INTICI3, 671 INTICI0, INTICI1, INTICI2, INTICI3,
695 INTICI4, INTICI5, INTICI6, INTICI7, 672 INTICI4, INTICI5, INTICI6, INTICI7,
673
674 /* Muxed sub-events */
675 TXI1, BRI1, RXI1, ERI1,
696}; 676};
697 677
698static struct intc_vect vectors[] __initdata = { 678static struct intc_vect sh7786_vectors[] __initdata = {
699 INTC_VECT(WDT, 0x3e0), 679 INTC_VECT(WDT, 0x3e0),
700 INTC_VECT(TMU0_0, 0x400), INTC_VECT(TMU0_1, 0x420), 680 INTC_VECT(TMU0_0, 0x400), INTC_VECT(TMU0_1, 0x420),
701 INTC_VECT(TMU0_2, 0x440), INTC_VECT(TMU0_3, 0x460), 681 INTC_VECT(TMU0_2, 0x440), INTC_VECT(TMU0_3, 0x460),
@@ -756,14 +736,12 @@ static struct intc_vect vectors[] __initdata = {
756 736
757#define INTDISTCR0 0xfe4100b0 737#define INTDISTCR0 0xfe4100b0
758#define INTDISTCR1 0xfe4100b4 738#define INTDISTCR1 0xfe4100b4
759#define INTACK 0xfe4100b8
760#define INTACKCLR 0xfe4100bc
761#define INT2DISTCR0 0xfe410900 739#define INT2DISTCR0 0xfe410900
762#define INT2DISTCR1 0xfe410904 740#define INT2DISTCR1 0xfe410904
763#define INT2DISTCR2 0xfe410908 741#define INT2DISTCR2 0xfe410908
764#define INT2DISTCR3 0xfe41090c 742#define INT2DISTCR3 0xfe41090c
765 743
766static struct intc_mask_reg mask_registers[] __initdata = { 744static struct intc_mask_reg sh7786_mask_registers[] __initdata = {
767 { CnINTMSK0, CnINTMSKCLR0, 32, 745 { CnINTMSK0, CnINTMSKCLR0, 32,
768 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 }, 746 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 },
769 INTC_SMP_BALANCING(INTDISTCR0) }, 747 INTC_SMP_BALANCING(INTDISTCR0) },
@@ -807,7 +785,7 @@ static struct intc_mask_reg mask_registers[] __initdata = {
807 0, 0, 0, 0, 0, 0, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR3) }, 785 0, 0, 0, 0, 0, 0, 0, 0 }, INTC_SMP_BALANCING(INT2DISTCR3) },
808}; 786};
809 787
810static struct intc_prio_reg prio_registers[] __initdata = { 788static struct intc_prio_reg sh7786_prio_registers[] __initdata = {
811 { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3, 789 { 0xfe410010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
812 IRQ4, IRQ5, IRQ6, IRQ7 } }, 790 IRQ4, IRQ5, IRQ6, IRQ7 } },
813 { 0xfe410800, 0, 32, 8, /* INT2PRI0 */ { 0, 0, 0, WDT } }, 791 { 0xfe410800, 0, 32, 8, /* INT2PRI0 */ { 0, 0, 0, WDT } },
@@ -851,11 +829,27 @@ static struct intc_prio_reg prio_registers[] __initdata = {
851 INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) }, 829 INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) },
852}; 830};
853 831
854static DECLARE_INTC_DESC(intc_desc, "sh7786", vectors, NULL, 832static struct intc_subgroup sh7786_subgroups[] __initdata = {
855 mask_registers, prio_registers, NULL); 833 { 0xfe410c20, 32, SCIF1,
834 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
835 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TXI1, BRI1, RXI1, ERI1 } },
836};
856 837
857/* Support for external interrupt pins in IRQ mode */ 838static struct intc_desc sh7786_intc_desc __initdata = {
839 .name = "sh7786",
840 .hw = {
841 .vectors = sh7786_vectors,
842 .nr_vectors = ARRAY_SIZE(sh7786_vectors),
843 .mask_regs = sh7786_mask_registers,
844 .nr_mask_regs = ARRAY_SIZE(sh7786_mask_registers),
845 .subgroups = sh7786_subgroups,
846 .nr_subgroups = ARRAY_SIZE(sh7786_subgroups),
847 .prio_regs = sh7786_prio_registers,
848 .nr_prio_regs = ARRAY_SIZE(sh7786_prio_registers),
849 },
850};
858 851
852/* Support for external interrupt pins in IRQ mode */
859static struct intc_vect vectors_irq0123[] __initdata = { 853static struct intc_vect vectors_irq0123[] __initdata = {
860 INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240), 854 INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240),
861 INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0), 855 INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0),
@@ -866,23 +860,25 @@ static struct intc_vect vectors_irq4567[] __initdata = {
866 INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0), 860 INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0),
867}; 861};
868 862
869static struct intc_sense_reg sense_registers[] __initdata = { 863static struct intc_sense_reg sh7786_sense_registers[] __initdata = {
870 { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3, 864 { 0xfe41001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
871 IRQ4, IRQ5, IRQ6, IRQ7 } }, 865 IRQ4, IRQ5, IRQ6, IRQ7 } },
872}; 866};
873 867
874static struct intc_mask_reg ack_registers[] __initdata = { 868static struct intc_mask_reg sh7786_ack_registers[] __initdata = {
875 { 0xfe410024, 0, 32, /* INTREQ */ 869 { 0xfe410024, 0, 32, /* INTREQ */
876 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } }, 870 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
877}; 871};
878 872
879static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7786-irq0123", 873static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7786-irq0123",
880 vectors_irq0123, NULL, mask_registers, 874 vectors_irq0123, NULL, sh7786_mask_registers,
881 prio_registers, sense_registers, ack_registers); 875 sh7786_prio_registers, sh7786_sense_registers,
876 sh7786_ack_registers);
882 877
883static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7786-irq4567", 878static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7786-irq4567",
884 vectors_irq4567, NULL, mask_registers, 879 vectors_irq4567, NULL, sh7786_mask_registers,
885 prio_registers, sense_registers, ack_registers); 880 sh7786_prio_registers, sh7786_sense_registers,
881 sh7786_ack_registers);
886 882
887/* External interrupt pins in IRL mode */ 883/* External interrupt pins in IRL mode */
888 884
@@ -909,10 +905,10 @@ static struct intc_vect vectors_irl4567[] __initdata = {
909}; 905};
910 906
911static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7786-irl0123", vectors_irl0123, 907static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7786-irl0123", vectors_irl0123,
912 NULL, mask_registers, NULL, NULL); 908 NULL, sh7786_mask_registers, NULL, NULL);
913 909
914static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567, 910static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567,
915 NULL, mask_registers, NULL, NULL); 911 NULL, sh7786_mask_registers, NULL, NULL);
916 912
917#define INTC_ICR0 0xfe410000 913#define INTC_ICR0 0xfe410000
918#define INTC_INTMSK0 CnINTMSK0 914#define INTC_INTMSK0 CnINTMSK0
@@ -920,19 +916,6 @@ static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7786-irl4567", vectors_irl4567,
920#define INTC_INTMSK2 INTMSK2 916#define INTC_INTMSK2 INTMSK2
921#define INTC_INTMSKCLR1 CnINTMSKCLR1 917#define INTC_INTMSKCLR1 CnINTMSKCLR1
922#define INTC_INTMSKCLR2 INTMSKCLR2 918#define INTC_INTMSKCLR2 INTMSKCLR2
923#define INTC_USERIMASK 0xfe411000
924
925#ifdef CONFIG_INTC_BALANCING
926unsigned int irq_lookup(unsigned int irq)
927{
928 return __raw_readl(INTACK) & 1 ? irq : NO_IRQ_IGNORE;
929}
930
931void irq_finish(unsigned int irq)
932{
933 __raw_writel(irq2evt(irq), INTACKCLR);
934}
935#endif
936 919
937void __init plat_irq_setup(void) 920void __init plat_irq_setup(void)
938{ 921{
@@ -946,8 +929,7 @@ void __init plat_irq_setup(void)
946 /* select IRL mode for IRL3-0 + IRL7-4 */ 929 /* select IRL mode for IRL3-0 + IRL7-4 */
947 __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0); 930 __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
948 931
949 register_intc_controller(&intc_desc); 932 register_intc_controller(&sh7786_intc_desc);
950 register_intc_userimask(INTC_USERIMASK);
951} 933}
952 934
953void __init plat_irq_setup_pins(int mode) 935void __init plat_irq_setup_pins(int mode)
@@ -991,3 +973,39 @@ void __init plat_irq_setup_pins(int mode)
991void __init plat_mem_setup(void) 973void __init plat_mem_setup(void)
992{ 974{
993} 975}
976
977static int __init sh7786_devices_setup(void)
978{
979 int ret, irq;
980
981 sh7786_usb_setup();
982
983 /*
984 * De-mux SCIF1 IRQs if possible
985 */
986 irq = intc_irq_lookup(sh7786_intc_desc.name, TXI1);
987 if (irq > 0) {
988 scif1_platform_data.irqs[SCIx_TXI_IRQ] = irq;
989 scif1_platform_data.irqs[SCIx_ERI_IRQ] =
990 intc_irq_lookup(sh7786_intc_desc.name, ERI1);
991 scif1_platform_data.irqs[SCIx_BRI_IRQ] =
992 intc_irq_lookup(sh7786_intc_desc.name, BRI1);
993 scif1_platform_data.irqs[SCIx_RXI_IRQ] =
994 intc_irq_lookup(sh7786_intc_desc.name, RXI1);
995 }
996
997 ret = platform_add_devices(sh7786_early_devices,
998 ARRAY_SIZE(sh7786_early_devices));
999 if (unlikely(ret != 0))
1000 return ret;
1001
1002 return platform_add_devices(sh7786_devices,
1003 ARRAY_SIZE(sh7786_devices));
1004}
1005arch_initcall(sh7786_devices_setup);
1006
1007void __init plat_early_device_setup(void)
1008{
1009 early_platform_add_devices(sh7786_early_devices,
1010 ARRAY_SIZE(sh7786_early_devices));
1011}
diff --git a/arch/sh/kernel/cpu/sh4a/setup-shx3.c b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
index 9158bc5ea38b..013f0b144489 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SH-X3 Prototype Setup 2 * SH-X3 Prototype Setup
3 * 3 *
4 * Copyright (C) 2007 - 2009 Paul Mundt 4 * Copyright (C) 2007 - 2010 Paul Mundt
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
@@ -12,7 +12,9 @@
12#include <linux/serial.h> 12#include <linux/serial.h>
13#include <linux/serial_sci.h> 13#include <linux/serial_sci.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/gpio.h>
15#include <linux/sh_timer.h> 16#include <linux/sh_timer.h>
17#include <cpu/shx3.h>
16#include <asm/mmzone.h> 18#include <asm/mmzone.h>
17 19
18/* 20/*
@@ -354,6 +356,10 @@ static struct intc_group groups[] __initdata = {
354 DMAC1_DMINT9, DMAC1_DMINT10, DMAC1_DMINT11), 356 DMAC1_DMINT9, DMAC1_DMINT10, DMAC1_DMINT11),
355}; 357};
356 358
359#define INT2DISTCR0 0xfe4108a0
360#define INT2DISTCR1 0xfe4108a4
361#define INT2DISTCR2 0xfe4108a8
362
357static struct intc_mask_reg mask_registers[] __initdata = { 363static struct intc_mask_reg mask_registers[] __initdata = {
358 { 0xfe410030, 0xfe410050, 32, /* CnINTMSK0 / CnINTMSKCLR0 */ 364 { 0xfe410030, 0xfe410050, 32, /* CnINTMSK0 / CnINTMSKCLR0 */
359 { IRQ0, IRQ1, IRQ2, IRQ3 } }, 365 { IRQ0, IRQ1, IRQ2, IRQ3 } },
@@ -363,20 +369,23 @@ static struct intc_mask_reg mask_registers[] __initdata = {
363 { FE1, FE0, 0, ATAPI, VCORE0, VIN1, VIN0, IIC, 369 { FE1, FE0, 0, ATAPI, VCORE0, VIN1, VIN0, IIC,
364 DU, GPIO3, GPIO2, GPIO1, GPIO0, PAM, 0, 0, 370 DU, GPIO3, GPIO2, GPIO1, GPIO0, PAM, 0, 0,
365 0, 0, 0, 0, 0, 0, 0, 0, /* HUDI bits ignored */ 371 0, 0, 0, 0, 0, 0, 0, 0, /* HUDI bits ignored */
366 0, TMU5, TMU4, TMU3, TMU2, TMU1, TMU0, 0, } }, 372 0, TMU5, TMU4, TMU3, TMU2, TMU1, TMU0, 0, },
373 INTC_SMP_BALANCING(INT2DISTCR0) },
367 { 0xfe410830, 0xfe410860, 32, /* CnINT2MSK1 / CnINT2MSKCLR1 */ 374 { 0xfe410830, 0xfe410860, 32, /* CnINT2MSK1 / CnINT2MSKCLR1 */
368 { 0, 0, 0, 0, DTU3, DTU2, DTU1, DTU0, /* IRM bits ignored */ 375 { 0, 0, 0, 0, DTU3, DTU2, DTU1, DTU0, /* IRM bits ignored */
369 PCII9, PCII8, PCII7, PCII6, PCII5, PCII4, PCII3, PCII2, 376 PCII9, PCII8, PCII7, PCII6, PCII5, PCII4, PCII3, PCII2,
370 PCII1, PCII0, DMAC1_DMAE, DMAC1_DMINT11, 377 PCII1, PCII0, DMAC1_DMAE, DMAC1_DMINT11,
371 DMAC1_DMINT10, DMAC1_DMINT9, DMAC1_DMINT8, DMAC1_DMINT7, 378 DMAC1_DMINT10, DMAC1_DMINT9, DMAC1_DMINT8, DMAC1_DMINT7,
372 DMAC1_DMINT6, DMAC0_DMAE, DMAC0_DMINT5, DMAC0_DMINT4, 379 DMAC1_DMINT6, DMAC0_DMAE, DMAC0_DMINT5, DMAC0_DMINT4,
373 DMAC0_DMINT3, DMAC0_DMINT2, DMAC0_DMINT1, DMAC0_DMINT0 } }, 380 DMAC0_DMINT3, DMAC0_DMINT2, DMAC0_DMINT1, DMAC0_DMINT0 },
381 INTC_SMP_BALANCING(INT2DISTCR1) },
374 { 0xfe410840, 0xfe410870, 32, /* CnINT2MSK2 / CnINT2MSKCLR2 */ 382 { 0xfe410840, 0xfe410870, 32, /* CnINT2MSK2 / CnINT2MSKCLR2 */
375 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 383 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
376 SCIF3_TXI, SCIF3_BRI, SCIF3_RXI, SCIF3_ERI, 384 SCIF3_TXI, SCIF3_BRI, SCIF3_RXI, SCIF3_ERI,
377 SCIF2_TXI, SCIF2_BRI, SCIF2_RXI, SCIF2_ERI, 385 SCIF2_TXI, SCIF2_BRI, SCIF2_RXI, SCIF2_ERI,
378 SCIF1_TXI, SCIF1_BRI, SCIF1_RXI, SCIF1_ERI, 386 SCIF1_TXI, SCIF1_BRI, SCIF1_RXI, SCIF1_ERI,
379 SCIF0_TXI, SCIF0_BRI, SCIF0_RXI, SCIF0_ERI } }, 387 SCIF0_TXI, SCIF0_BRI, SCIF0_RXI, SCIF0_ERI },
388 INTC_SMP_BALANCING(INT2DISTCR2) },
380}; 389};
381 390
382static struct intc_prio_reg prio_registers[] __initdata = { 391static struct intc_prio_reg prio_registers[] __initdata = {
@@ -433,11 +442,33 @@ static DECLARE_INTC_DESC(intc_desc_irl, "shx3-irl", vectors_irl, groups,
433 442
434void __init plat_irq_setup_pins(int mode) 443void __init plat_irq_setup_pins(int mode)
435{ 444{
445 int ret = 0;
446
436 switch (mode) { 447 switch (mode) {
437 case IRQ_MODE_IRQ: 448 case IRQ_MODE_IRQ:
449 ret |= gpio_request(GPIO_FN_IRQ3, intc_desc_irq.name);
450 ret |= gpio_request(GPIO_FN_IRQ2, intc_desc_irq.name);
451 ret |= gpio_request(GPIO_FN_IRQ1, intc_desc_irq.name);
452 ret |= gpio_request(GPIO_FN_IRQ0, intc_desc_irq.name);
453
454 if (unlikely(ret)) {
455 pr_err("Failed to set IRQ mode\n");
456 return;
457 }
458
438 register_intc_controller(&intc_desc_irq); 459 register_intc_controller(&intc_desc_irq);
439 break; 460 break;
440 case IRQ_MODE_IRL3210: 461 case IRQ_MODE_IRL3210:
462 ret |= gpio_request(GPIO_FN_IRL3, intc_desc_irl.name);
463 ret |= gpio_request(GPIO_FN_IRL2, intc_desc_irl.name);
464 ret |= gpio_request(GPIO_FN_IRL1, intc_desc_irl.name);
465 ret |= gpio_request(GPIO_FN_IRL0, intc_desc_irl.name);
466
467 if (unlikely(ret)) {
468 pr_err("Failed to set IRL mode\n");
469 return;
470 }
471
441 register_intc_controller(&intc_desc_irl); 472 register_intc_controller(&intc_desc_irl);
442 break; 473 break;
443 default: 474 default:
@@ -447,6 +478,9 @@ void __init plat_irq_setup_pins(int mode)
447 478
448void __init plat_irq_setup(void) 479void __init plat_irq_setup(void)
449{ 480{
481 reserve_intc_vectors(vectors_irq, ARRAY_SIZE(vectors_irq));
482 reserve_intc_vectors(vectors_irl, ARRAY_SIZE(vectors_irl));
483
450 register_intc_controller(&intc_desc); 484 register_intc_controller(&intc_desc);
451} 485}
452 486
diff --git a/arch/sh/kernel/head_32.S b/arch/sh/kernel/head_32.S
index 6e35f012cc03..7db248936b60 100644
--- a/arch/sh/kernel/head_32.S
+++ b/arch/sh/kernel/head_32.S
@@ -330,7 +330,7 @@ ENTRY(_stext)
330#if defined(CONFIG_CPU_SH2) 330#if defined(CONFIG_CPU_SH2)
3311: .long 0x000000F0 ! IMASK=0xF 3311: .long 0x000000F0 ! IMASK=0xF
332#else 332#else
3331: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF 3331: .long 0x500080F0 ! MD=1, RB=0, BL=1, FD=1, IMASK=0xF
334#endif 334#endif
335ENTRY(stack_start) 335ENTRY(stack_start)
3362: .long init_thread_union+THREAD_SIZE 3362: .long init_thread_union+THREAD_SIZE
diff --git a/arch/sh/kernel/io_trapped.c b/arch/sh/kernel/io_trapped.c
index 2947d2bd1291..32c385ef1011 100644
--- a/arch/sh/kernel/io_trapped.c
+++ b/arch/sh/kernel/io_trapped.c
@@ -291,7 +291,7 @@ int handle_trapped_io(struct pt_regs *regs, unsigned long address)
291 } 291 }
292 292
293 tmp = handle_unaligned_access(instruction, regs, 293 tmp = handle_unaligned_access(instruction, regs,
294 &trapped_io_access, 1); 294 &trapped_io_access, 1, address);
295 set_fs(oldfs); 295 set_fs(oldfs);
296 return tmp == 0; 296 return tmp == 0;
297} 297}
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 257de1f0692b..9dc447db8a44 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -283,6 +283,8 @@ void __init init_IRQ(void)
283 if (sh_mv.mv_init_irq) 283 if (sh_mv.mv_init_irq)
284 sh_mv.mv_init_irq(); 284 sh_mv.mv_init_irq();
285 285
286 intc_finalize();
287
286 irq_ctx_init(smp_processor_id()); 288 irq_ctx_init(smp_processor_id());
287} 289}
288 290
@@ -290,7 +292,7 @@ void __init init_IRQ(void)
290int __init arch_probe_nr_irqs(void) 292int __init arch_probe_nr_irqs(void)
291{ 293{
292 nr_irqs = sh_mv.mv_nr_irqs; 294 nr_irqs = sh_mv.mv_nr_irqs;
293 return 0; 295 return NR_IRQS_LEGACY;
294} 296}
295#endif 297#endif
296 298
diff --git a/arch/sh/kernel/irq_32.c b/arch/sh/kernel/irq_32.c
index e33ab15831f9..e5a755be9129 100644
--- a/arch/sh/kernel/irq_32.c
+++ b/arch/sh/kernel/irq_32.c
@@ -10,11 +10,11 @@
10#include <linux/irqflags.h> 10#include <linux/irqflags.h>
11#include <linux/module.h> 11#include <linux/module.h>
12 12
13void notrace raw_local_irq_restore(unsigned long flags) 13void notrace arch_local_irq_restore(unsigned long flags)
14{ 14{
15 unsigned long __dummy0, __dummy1; 15 unsigned long __dummy0, __dummy1;
16 16
17 if (flags == RAW_IRQ_DISABLED) { 17 if (flags == ARCH_IRQ_DISABLED) {
18 __asm__ __volatile__ ( 18 __asm__ __volatile__ (
19 "stc sr, %0\n\t" 19 "stc sr, %0\n\t"
20 "or #0xf0, %0\n\t" 20 "or #0xf0, %0\n\t"
@@ -33,14 +33,14 @@ void notrace raw_local_irq_restore(unsigned long flags)
33#endif 33#endif
34 "ldc %0, sr\n\t" 34 "ldc %0, sr\n\t"
35 : "=&r" (__dummy0), "=r" (__dummy1) 35 : "=&r" (__dummy0), "=r" (__dummy1)
36 : "1" (~RAW_IRQ_DISABLED) 36 : "1" (~ARCH_IRQ_DISABLED)
37 : "memory" 37 : "memory"
38 ); 38 );
39 } 39 }
40} 40}
41EXPORT_SYMBOL(raw_local_irq_restore); 41EXPORT_SYMBOL(arch_local_irq_restore);
42 42
43unsigned long notrace __raw_local_save_flags(void) 43unsigned long notrace arch_local_save_flags(void)
44{ 44{
45 unsigned long flags; 45 unsigned long flags;
46 46
@@ -54,4 +54,4 @@ unsigned long notrace __raw_local_save_flags(void)
54 54
55 return flags; 55 return flags;
56} 56}
57EXPORT_SYMBOL(__raw_local_save_flags); 57EXPORT_SYMBOL(arch_local_save_flags);
diff --git a/arch/sh/kernel/kdebugfs.c b/arch/sh/kernel/kdebugfs.c
new file mode 100644
index 000000000000..e11c30bb100c
--- /dev/null
+++ b/arch/sh/kernel/kdebugfs.c
@@ -0,0 +1,16 @@
1#include <linux/module.h>
2#include <linux/init.h>
3#include <linux/debugfs.h>
4
5struct dentry *arch_debugfs_dir;
6EXPORT_SYMBOL(arch_debugfs_dir);
7
8static int __init arch_kdebugfs_init(void)
9{
10 arch_debugfs_dir = debugfs_create_dir("sh", NULL);
11 if (!arch_debugfs_dir)
12 return -ENOMEM;
13
14 return 0;
15}
16arch_initcall(arch_kdebugfs_init);
diff --git a/arch/sh/kernel/kprobes.c b/arch/sh/kernel/kprobes.c
index 4049d99f76e1..1208b09e95c3 100644
--- a/arch/sh/kernel/kprobes.c
+++ b/arch/sh/kernel/kprobes.c
@@ -20,9 +20,9 @@
20DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 20DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
21DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 21DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
22 22
23static struct kprobe saved_current_opcode; 23static DEFINE_PER_CPU(struct kprobe, saved_current_opcode);
24static struct kprobe saved_next_opcode; 24static DEFINE_PER_CPU(struct kprobe, saved_next_opcode);
25static struct kprobe saved_next_opcode2; 25static DEFINE_PER_CPU(struct kprobe, saved_next_opcode2);
26 26
27#define OPCODE_JMP(x) (((x) & 0xF0FF) == 0x402b) 27#define OPCODE_JMP(x) (((x) & 0xF0FF) == 0x402b)
28#define OPCODE_JSR(x) (((x) & 0xF0FF) == 0x400b) 28#define OPCODE_JSR(x) (((x) & 0xF0FF) == 0x400b)
@@ -102,16 +102,21 @@ int __kprobes kprobe_handle_illslot(unsigned long pc)
102 102
103void __kprobes arch_remove_kprobe(struct kprobe *p) 103void __kprobes arch_remove_kprobe(struct kprobe *p)
104{ 104{
105 if (saved_next_opcode.addr != 0x0) { 105 struct kprobe *saved = &__get_cpu_var(saved_next_opcode);
106
107 if (saved->addr) {
106 arch_disarm_kprobe(p); 108 arch_disarm_kprobe(p);
107 arch_disarm_kprobe(&saved_next_opcode); 109 arch_disarm_kprobe(saved);
108 saved_next_opcode.addr = 0x0; 110
109 saved_next_opcode.opcode = 0x0; 111 saved->addr = NULL;
110 112 saved->opcode = 0;
111 if (saved_next_opcode2.addr != 0x0) { 113
112 arch_disarm_kprobe(&saved_next_opcode2); 114 saved = &__get_cpu_var(saved_next_opcode2);
113 saved_next_opcode2.addr = 0x0; 115 if (saved->addr) {
114 saved_next_opcode2.opcode = 0x0; 116 arch_disarm_kprobe(saved);
117
118 saved->addr = NULL;
119 saved->opcode = 0;
115 } 120 }
116 } 121 }
117} 122}
@@ -141,57 +146,59 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
141 */ 146 */
142static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 147static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
143{ 148{
144 kprobe_opcode_t *addr = NULL; 149 __get_cpu_var(saved_current_opcode).addr = (kprobe_opcode_t *)regs->pc;
145 saved_current_opcode.addr = (kprobe_opcode_t *) (regs->pc);
146 addr = saved_current_opcode.addr;
147 150
148 if (p != NULL) { 151 if (p != NULL) {
152 struct kprobe *op1, *op2;
153
149 arch_disarm_kprobe(p); 154 arch_disarm_kprobe(p);
150 155
156 op1 = &__get_cpu_var(saved_next_opcode);
157 op2 = &__get_cpu_var(saved_next_opcode2);
158
151 if (OPCODE_JSR(p->opcode) || OPCODE_JMP(p->opcode)) { 159 if (OPCODE_JSR(p->opcode) || OPCODE_JMP(p->opcode)) {
152 unsigned int reg_nr = ((p->opcode >> 8) & 0x000F); 160 unsigned int reg_nr = ((p->opcode >> 8) & 0x000F);
153 saved_next_opcode.addr = 161 op1->addr = (kprobe_opcode_t *) regs->regs[reg_nr];
154 (kprobe_opcode_t *) regs->regs[reg_nr];
155 } else if (OPCODE_BRA(p->opcode) || OPCODE_BSR(p->opcode)) { 162 } else if (OPCODE_BRA(p->opcode) || OPCODE_BSR(p->opcode)) {
156 unsigned long disp = (p->opcode & 0x0FFF); 163 unsigned long disp = (p->opcode & 0x0FFF);
157 saved_next_opcode.addr = 164 op1->addr =
158 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2); 165 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2);
159 166
160 } else if (OPCODE_BRAF(p->opcode) || OPCODE_BSRF(p->opcode)) { 167 } else if (OPCODE_BRAF(p->opcode) || OPCODE_BSRF(p->opcode)) {
161 unsigned int reg_nr = ((p->opcode >> 8) & 0x000F); 168 unsigned int reg_nr = ((p->opcode >> 8) & 0x000F);
162 saved_next_opcode.addr = 169 op1->addr =
163 (kprobe_opcode_t *) (regs->pc + 4 + 170 (kprobe_opcode_t *) (regs->pc + 4 +
164 regs->regs[reg_nr]); 171 regs->regs[reg_nr]);
165 172
166 } else if (OPCODE_RTS(p->opcode)) { 173 } else if (OPCODE_RTS(p->opcode)) {
167 saved_next_opcode.addr = (kprobe_opcode_t *) regs->pr; 174 op1->addr = (kprobe_opcode_t *) regs->pr;
168 175
169 } else if (OPCODE_BF(p->opcode) || OPCODE_BT(p->opcode)) { 176 } else if (OPCODE_BF(p->opcode) || OPCODE_BT(p->opcode)) {
170 unsigned long disp = (p->opcode & 0x00FF); 177 unsigned long disp = (p->opcode & 0x00FF);
171 /* case 1 */ 178 /* case 1 */
172 saved_next_opcode.addr = p->addr + 1; 179 op1->addr = p->addr + 1;
173 /* case 2 */ 180 /* case 2 */
174 saved_next_opcode2.addr = 181 op2->addr =
175 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2); 182 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2);
176 saved_next_opcode2.opcode = *(saved_next_opcode2.addr); 183 op2->opcode = *(op2->addr);
177 arch_arm_kprobe(&saved_next_opcode2); 184 arch_arm_kprobe(op2);
178 185
179 } else if (OPCODE_BF_S(p->opcode) || OPCODE_BT_S(p->opcode)) { 186 } else if (OPCODE_BF_S(p->opcode) || OPCODE_BT_S(p->opcode)) {
180 unsigned long disp = (p->opcode & 0x00FF); 187 unsigned long disp = (p->opcode & 0x00FF);
181 /* case 1 */ 188 /* case 1 */
182 saved_next_opcode.addr = p->addr + 2; 189 op1->addr = p->addr + 2;
183 /* case 2 */ 190 /* case 2 */
184 saved_next_opcode2.addr = 191 op2->addr =
185 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2); 192 (kprobe_opcode_t *) (regs->pc + 4 + disp * 2);
186 saved_next_opcode2.opcode = *(saved_next_opcode2.addr); 193 op2->opcode = *(op2->addr);
187 arch_arm_kprobe(&saved_next_opcode2); 194 arch_arm_kprobe(op2);
188 195
189 } else { 196 } else {
190 saved_next_opcode.addr = p->addr + 1; 197 op1->addr = p->addr + 1;
191 } 198 }
192 199
193 saved_next_opcode.opcode = *(saved_next_opcode.addr); 200 op1->opcode = *(op1->addr);
194 arch_arm_kprobe(&saved_next_opcode); 201 arch_arm_kprobe(op1);
195 } 202 }
196} 203}
197 204
@@ -376,21 +383,23 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
376 cur->post_handler(cur, regs, 0); 383 cur->post_handler(cur, regs, 0);
377 } 384 }
378 385
379 if (saved_next_opcode.addr != 0x0) { 386 p = &__get_cpu_var(saved_next_opcode);
380 arch_disarm_kprobe(&saved_next_opcode); 387 if (p->addr) {
381 saved_next_opcode.addr = 0x0; 388 arch_disarm_kprobe(p);
382 saved_next_opcode.opcode = 0x0; 389 p->addr = NULL;
390 p->opcode = 0;
383 391
384 addr = saved_current_opcode.addr; 392 addr = __get_cpu_var(saved_current_opcode).addr;
385 saved_current_opcode.addr = 0x0; 393 __get_cpu_var(saved_current_opcode).addr = NULL;
386 394
387 p = get_kprobe(addr); 395 p = get_kprobe(addr);
388 arch_arm_kprobe(p); 396 arch_arm_kprobe(p);
389 397
390 if (saved_next_opcode2.addr != 0x0) { 398 p = &__get_cpu_var(saved_next_opcode2);
391 arch_disarm_kprobe(&saved_next_opcode2); 399 if (p->addr) {
392 saved_next_opcode2.addr = 0x0; 400 arch_disarm_kprobe(p);
393 saved_next_opcode2.opcode = 0x0; 401 p->addr = NULL;
402 p->opcode = 0;
394 } 403 }
395 } 404 }
396 405
@@ -572,14 +581,5 @@ static struct kprobe trampoline_p = {
572 581
573int __init arch_init_kprobes(void) 582int __init arch_init_kprobes(void)
574{ 583{
575 saved_next_opcode.addr = 0x0;
576 saved_next_opcode.opcode = 0x0;
577
578 saved_current_opcode.addr = 0x0;
579 saved_current_opcode.opcode = 0x0;
580
581 saved_next_opcode2.addr = 0x0;
582 saved_next_opcode2.opcode = 0x0;
583
584 return register_kprobe(&trampoline_p); 584 return register_kprobe(&trampoline_p);
585} 585}
diff --git a/arch/sh/kernel/module.c b/arch/sh/kernel/module.c
index 43adddfe4c04..ae0be697a89e 100644
--- a/arch/sh/kernel/module.c
+++ b/arch/sh/kernel/module.c
@@ -149,13 +149,11 @@ int module_finalize(const Elf_Ehdr *hdr,
149 int ret = 0; 149 int ret = 0;
150 150
151 ret |= module_dwarf_finalize(hdr, sechdrs, me); 151 ret |= module_dwarf_finalize(hdr, sechdrs, me);
152 ret |= module_bug_finalize(hdr, sechdrs, me);
153 152
154 return ret; 153 return ret;
155} 154}
156 155
157void module_arch_cleanup(struct module *mod) 156void module_arch_cleanup(struct module *mod)
158{ 157{
159 module_bug_cleanup(mod);
160 module_dwarf_cleanup(mod); 158 module_dwarf_cleanup(mod);
161} 159}
diff --git a/arch/sh/kernel/perf_callchain.c b/arch/sh/kernel/perf_callchain.c
index a9dd3abde28e..d5ca1ef50fa9 100644
--- a/arch/sh/kernel/perf_callchain.c
+++ b/arch/sh/kernel/perf_callchain.c
@@ -14,11 +14,6 @@
14#include <asm/unwinder.h> 14#include <asm/unwinder.h>
15#include <asm/ptrace.h> 15#include <asm/ptrace.h>
16 16
17static inline void callchain_store(struct perf_callchain_entry *entry, u64 ip)
18{
19 if (entry->nr < PERF_MAX_STACK_DEPTH)
20 entry->ip[entry->nr++] = ip;
21}
22 17
23static void callchain_warning(void *data, char *msg) 18static void callchain_warning(void *data, char *msg)
24{ 19{
@@ -39,7 +34,7 @@ static void callchain_address(void *data, unsigned long addr, int reliable)
39 struct perf_callchain_entry *entry = data; 34 struct perf_callchain_entry *entry = data;
40 35
41 if (reliable) 36 if (reliable)
42 callchain_store(entry, addr); 37 perf_callchain_store(entry, addr);
43} 38}
44 39
45static const struct stacktrace_ops callchain_ops = { 40static const struct stacktrace_ops callchain_ops = {
@@ -49,47 +44,10 @@ static const struct stacktrace_ops callchain_ops = {
49 .address = callchain_address, 44 .address = callchain_address,
50}; 45};
51 46
52static void 47void
53perf_callchain_kernel(struct pt_regs *regs, struct perf_callchain_entry *entry) 48perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
54{ 49{
55 callchain_store(entry, PERF_CONTEXT_KERNEL); 50 perf_callchain_store(entry, regs->pc);
56 callchain_store(entry, regs->pc);
57 51
58 unwind_stack(NULL, regs, NULL, &callchain_ops, entry); 52 unwind_stack(NULL, regs, NULL, &callchain_ops, entry);
59} 53}
60
61static void
62perf_do_callchain(struct pt_regs *regs, struct perf_callchain_entry *entry)
63{
64 int is_user;
65
66 if (!regs)
67 return;
68
69 is_user = user_mode(regs);
70
71 if (is_user && current->state != TASK_RUNNING)
72 return;
73
74 /*
75 * Only the kernel side is implemented for now.
76 */
77 if (!is_user)
78 perf_callchain_kernel(regs, entry);
79}
80
81/*
82 * No need for separate IRQ and NMI entries.
83 */
84static DEFINE_PER_CPU(struct perf_callchain_entry, callchain);
85
86struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
87{
88 struct perf_callchain_entry *entry = &__get_cpu_var(callchain);
89
90 entry->nr = 0;
91
92 perf_do_callchain(regs, entry);
93
94 return entry;
95}
diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c
index 7a3dc3567258..5a4b33435650 100644
--- a/arch/sh/kernel/perf_event.c
+++ b/arch/sh/kernel/perf_event.c
@@ -59,6 +59,24 @@ static inline int sh_pmu_initialized(void)
59 return !!sh_pmu; 59 return !!sh_pmu;
60} 60}
61 61
62const char *perf_pmu_name(void)
63{
64 if (!sh_pmu)
65 return NULL;
66
67 return sh_pmu->name;
68}
69EXPORT_SYMBOL_GPL(perf_pmu_name);
70
71int perf_num_counters(void)
72{
73 if (!sh_pmu)
74 return 0;
75
76 return sh_pmu->num_events;
77}
78EXPORT_SYMBOL_GPL(perf_num_counters);
79
62/* 80/*
63 * Release the PMU if this is the last perf_event. 81 * Release the PMU if this is the last perf_event.
64 */ 82 */
@@ -206,50 +224,80 @@ again:
206 local64_add(delta, &event->count); 224 local64_add(delta, &event->count);
207} 225}
208 226
209static void sh_pmu_disable(struct perf_event *event) 227static void sh_pmu_stop(struct perf_event *event, int flags)
210{ 228{
211 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 229 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
212 struct hw_perf_event *hwc = &event->hw; 230 struct hw_perf_event *hwc = &event->hw;
213 int idx = hwc->idx; 231 int idx = hwc->idx;
214 232
215 clear_bit(idx, cpuc->active_mask); 233 if (!(event->hw.state & PERF_HES_STOPPED)) {
216 sh_pmu->disable(hwc, idx); 234 sh_pmu->disable(hwc, idx);
235 cpuc->events[idx] = NULL;
236 event->hw.state |= PERF_HES_STOPPED;
237 }
238
239 if ((flags & PERF_EF_UPDATE) && !(event->hw.state & PERF_HES_UPTODATE)) {
240 sh_perf_event_update(event, &event->hw, idx);
241 event->hw.state |= PERF_HES_UPTODATE;
242 }
243}
244
245static void sh_pmu_start(struct perf_event *event, int flags)
246{
247 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
248 struct hw_perf_event *hwc = &event->hw;
249 int idx = hwc->idx;
250
251 if (WARN_ON_ONCE(idx == -1))
252 return;
253
254 if (flags & PERF_EF_RELOAD)
255 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
217 256
218 barrier(); 257 cpuc->events[idx] = event;
258 event->hw.state = 0;
259 sh_pmu->enable(hwc, idx);
260}
219 261
220 sh_perf_event_update(event, &event->hw, idx); 262static void sh_pmu_del(struct perf_event *event, int flags)
263{
264 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
221 265
222 cpuc->events[idx] = NULL; 266 sh_pmu_stop(event, PERF_EF_UPDATE);
223 clear_bit(idx, cpuc->used_mask); 267 __clear_bit(event->hw.idx, cpuc->used_mask);
224 268
225 perf_event_update_userpage(event); 269 perf_event_update_userpage(event);
226} 270}
227 271
228static int sh_pmu_enable(struct perf_event *event) 272static int sh_pmu_add(struct perf_event *event, int flags)
229{ 273{
230 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 274 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
231 struct hw_perf_event *hwc = &event->hw; 275 struct hw_perf_event *hwc = &event->hw;
232 int idx = hwc->idx; 276 int idx = hwc->idx;
277 int ret = -EAGAIN;
278
279 perf_pmu_disable(event->pmu);
233 280
234 if (test_and_set_bit(idx, cpuc->used_mask)) { 281 if (__test_and_set_bit(idx, cpuc->used_mask)) {
235 idx = find_first_zero_bit(cpuc->used_mask, sh_pmu->num_events); 282 idx = find_first_zero_bit(cpuc->used_mask, sh_pmu->num_events);
236 if (idx == sh_pmu->num_events) 283 if (idx == sh_pmu->num_events)
237 return -EAGAIN; 284 goto out;
238 285
239 set_bit(idx, cpuc->used_mask); 286 __set_bit(idx, cpuc->used_mask);
240 hwc->idx = idx; 287 hwc->idx = idx;
241 } 288 }
242 289
243 sh_pmu->disable(hwc, idx); 290 sh_pmu->disable(hwc, idx);
244 291
245 cpuc->events[idx] = event; 292 event->hw.state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
246 set_bit(idx, cpuc->active_mask); 293 if (flags & PERF_EF_START)
247 294 sh_pmu_start(event, PERF_EF_RELOAD);
248 sh_pmu->enable(hwc, idx);
249 295
250 perf_event_update_userpage(event); 296 perf_event_update_userpage(event);
251 297 ret = 0;
252 return 0; 298out:
299 perf_pmu_enable(event->pmu);
300 return ret;
253} 301}
254 302
255static void sh_pmu_read(struct perf_event *event) 303static void sh_pmu_read(struct perf_event *event)
@@ -257,24 +305,56 @@ static void sh_pmu_read(struct perf_event *event)
257 sh_perf_event_update(event, &event->hw, event->hw.idx); 305 sh_perf_event_update(event, &event->hw, event->hw.idx);
258} 306}
259 307
260static const struct pmu pmu = { 308static int sh_pmu_event_init(struct perf_event *event)
261 .enable = sh_pmu_enable,
262 .disable = sh_pmu_disable,
263 .read = sh_pmu_read,
264};
265
266const struct pmu *hw_perf_event_init(struct perf_event *event)
267{ 309{
268 int err = __hw_perf_event_init(event); 310 int err;
311
312 switch (event->attr.type) {
313 case PERF_TYPE_RAW:
314 case PERF_TYPE_HW_CACHE:
315 case PERF_TYPE_HARDWARE:
316 err = __hw_perf_event_init(event);
317 break;
318
319 default:
320 return -ENOENT;
321 }
322
269 if (unlikely(err)) { 323 if (unlikely(err)) {
270 if (event->destroy) 324 if (event->destroy)
271 event->destroy(event); 325 event->destroy(event);
272 return ERR_PTR(err);
273 } 326 }
274 327
275 return &pmu; 328 return err;
329}
330
331static void sh_pmu_enable(struct pmu *pmu)
332{
333 if (!sh_pmu_initialized())
334 return;
335
336 sh_pmu->enable_all();
337}
338
339static void sh_pmu_disable(struct pmu *pmu)
340{
341 if (!sh_pmu_initialized())
342 return;
343
344 sh_pmu->disable_all();
276} 345}
277 346
347static struct pmu pmu = {
348 .pmu_enable = sh_pmu_enable,
349 .pmu_disable = sh_pmu_disable,
350 .event_init = sh_pmu_event_init,
351 .add = sh_pmu_add,
352 .del = sh_pmu_del,
353 .start = sh_pmu_start,
354 .stop = sh_pmu_stop,
355 .read = sh_pmu_read,
356};
357
278static void sh_pmu_setup(int cpu) 358static void sh_pmu_setup(int cpu)
279{ 359{
280 struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu); 360 struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu);
@@ -299,32 +379,17 @@ sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
299 return NOTIFY_OK; 379 return NOTIFY_OK;
300} 380}
301 381
302void hw_perf_enable(void) 382int __cpuinit register_sh_pmu(struct sh_pmu *_pmu)
303{
304 if (!sh_pmu_initialized())
305 return;
306
307 sh_pmu->enable_all();
308}
309
310void hw_perf_disable(void)
311{
312 if (!sh_pmu_initialized())
313 return;
314
315 sh_pmu->disable_all();
316}
317
318int __cpuinit register_sh_pmu(struct sh_pmu *pmu)
319{ 383{
320 if (sh_pmu) 384 if (sh_pmu)
321 return -EBUSY; 385 return -EBUSY;
322 sh_pmu = pmu; 386 sh_pmu = _pmu;
323 387
324 pr_info("Performance Events: %s support registered\n", pmu->name); 388 pr_info("Performance Events: %s support registered\n", _pmu->name);
325 389
326 WARN_ON(pmu->num_events > MAX_HWEVENTS); 390 WARN_ON(_pmu->num_events > MAX_HWEVENTS);
327 391
392 perf_pmu_register(&pmu);
328 perf_cpu_notifier(sh_pmu_notifier); 393 perf_cpu_notifier(sh_pmu_notifier);
329 return 0; 394 return 0;
330} 395}
diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c
new file mode 100644
index 000000000000..0a05983633ca
--- /dev/null
+++ b/arch/sh/kernel/ptrace.c
@@ -0,0 +1,33 @@
1#include <linux/ptrace.h>
2
3/**
4 * regs_query_register_offset() - query register offset from its name
5 * @name: the name of a register
6 *
7 * regs_query_register_offset() returns the offset of a register in struct
8 * pt_regs from its name. If the name is invalid, this returns -EINVAL;
9 */
10int regs_query_register_offset(const char *name)
11{
12 const struct pt_regs_offset *roff;
13 for (roff = regoffset_table; roff->name != NULL; roff++)
14 if (!strcmp(roff->name, name))
15 return roff->offset;
16 return -EINVAL;
17}
18
19/**
20 * regs_query_register_name() - query register name from its offset
21 * @offset: the offset of a register in struct pt_regs.
22 *
23 * regs_query_register_name() returns the name of a register from its
24 * offset in struct pt_regs. If the @offset is invalid, this returns NULL;
25 */
26const char *regs_query_register_name(unsigned int offset)
27{
28 const struct pt_regs_offset *roff;
29 for (roff = regoffset_table; roff->name != NULL; roff++)
30 if (roff->offset == offset)
31 return roff->name;
32 return NULL;
33}
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 6c4bbba2a675..2cd42b58cb20 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -274,6 +274,33 @@ static int dspregs_active(struct task_struct *target,
274} 274}
275#endif 275#endif
276 276
277const struct pt_regs_offset regoffset_table[] = {
278 REGS_OFFSET_NAME(0),
279 REGS_OFFSET_NAME(1),
280 REGS_OFFSET_NAME(2),
281 REGS_OFFSET_NAME(3),
282 REGS_OFFSET_NAME(4),
283 REGS_OFFSET_NAME(5),
284 REGS_OFFSET_NAME(6),
285 REGS_OFFSET_NAME(7),
286 REGS_OFFSET_NAME(8),
287 REGS_OFFSET_NAME(9),
288 REGS_OFFSET_NAME(10),
289 REGS_OFFSET_NAME(11),
290 REGS_OFFSET_NAME(12),
291 REGS_OFFSET_NAME(13),
292 REGS_OFFSET_NAME(14),
293 REGS_OFFSET_NAME(15),
294 REG_OFFSET_NAME(pc),
295 REG_OFFSET_NAME(pr),
296 REG_OFFSET_NAME(sr),
297 REG_OFFSET_NAME(gbr),
298 REG_OFFSET_NAME(mach),
299 REG_OFFSET_NAME(macl),
300 REG_OFFSET_NAME(tra),
301 REG_OFFSET_END,
302};
303
277/* 304/*
278 * These are our native regset flavours. 305 * These are our native regset flavours.
279 */ 306 */
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index 5fd644da7f02..e0fb065914aa 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -20,7 +20,7 @@
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/smp_lock.h> 23#include <linux/bitops.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/ptrace.h> 25#include <linux/ptrace.h>
26#include <linux/user.h> 26#include <linux/user.h>
@@ -252,6 +252,85 @@ static int fpregs_active(struct task_struct *target,
252} 252}
253#endif 253#endif
254 254
255const struct pt_regs_offset regoffset_table[] = {
256 REG_OFFSET_NAME(pc),
257 REG_OFFSET_NAME(sr),
258 REG_OFFSET_NAME(syscall_nr),
259 REGS_OFFSET_NAME(0),
260 REGS_OFFSET_NAME(1),
261 REGS_OFFSET_NAME(2),
262 REGS_OFFSET_NAME(3),
263 REGS_OFFSET_NAME(4),
264 REGS_OFFSET_NAME(5),
265 REGS_OFFSET_NAME(6),
266 REGS_OFFSET_NAME(7),
267 REGS_OFFSET_NAME(8),
268 REGS_OFFSET_NAME(9),
269 REGS_OFFSET_NAME(10),
270 REGS_OFFSET_NAME(11),
271 REGS_OFFSET_NAME(12),
272 REGS_OFFSET_NAME(13),
273 REGS_OFFSET_NAME(14),
274 REGS_OFFSET_NAME(15),
275 REGS_OFFSET_NAME(16),
276 REGS_OFFSET_NAME(17),
277 REGS_OFFSET_NAME(18),
278 REGS_OFFSET_NAME(19),
279 REGS_OFFSET_NAME(20),
280 REGS_OFFSET_NAME(21),
281 REGS_OFFSET_NAME(22),
282 REGS_OFFSET_NAME(23),
283 REGS_OFFSET_NAME(24),
284 REGS_OFFSET_NAME(25),
285 REGS_OFFSET_NAME(26),
286 REGS_OFFSET_NAME(27),
287 REGS_OFFSET_NAME(28),
288 REGS_OFFSET_NAME(29),
289 REGS_OFFSET_NAME(30),
290 REGS_OFFSET_NAME(31),
291 REGS_OFFSET_NAME(32),
292 REGS_OFFSET_NAME(33),
293 REGS_OFFSET_NAME(34),
294 REGS_OFFSET_NAME(35),
295 REGS_OFFSET_NAME(36),
296 REGS_OFFSET_NAME(37),
297 REGS_OFFSET_NAME(38),
298 REGS_OFFSET_NAME(39),
299 REGS_OFFSET_NAME(40),
300 REGS_OFFSET_NAME(41),
301 REGS_OFFSET_NAME(42),
302 REGS_OFFSET_NAME(43),
303 REGS_OFFSET_NAME(44),
304 REGS_OFFSET_NAME(45),
305 REGS_OFFSET_NAME(46),
306 REGS_OFFSET_NAME(47),
307 REGS_OFFSET_NAME(48),
308 REGS_OFFSET_NAME(49),
309 REGS_OFFSET_NAME(50),
310 REGS_OFFSET_NAME(51),
311 REGS_OFFSET_NAME(52),
312 REGS_OFFSET_NAME(53),
313 REGS_OFFSET_NAME(54),
314 REGS_OFFSET_NAME(55),
315 REGS_OFFSET_NAME(56),
316 REGS_OFFSET_NAME(57),
317 REGS_OFFSET_NAME(58),
318 REGS_OFFSET_NAME(59),
319 REGS_OFFSET_NAME(60),
320 REGS_OFFSET_NAME(61),
321 REGS_OFFSET_NAME(62),
322 REGS_OFFSET_NAME(63),
323 TREGS_OFFSET_NAME(0),
324 TREGS_OFFSET_NAME(1),
325 TREGS_OFFSET_NAME(2),
326 TREGS_OFFSET_NAME(3),
327 TREGS_OFFSET_NAME(4),
328 TREGS_OFFSET_NAME(5),
329 TREGS_OFFSET_NAME(6),
330 TREGS_OFFSET_NAME(7),
331 REG_OFFSET_END,
332};
333
255/* 334/*
256 * These are our native regset flavours. 335 * These are our native regset flavours.
257 */ 336 */
@@ -395,10 +474,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
395asmlinkage int sh64_ptrace(long request, long pid, long addr, long data) 474asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
396{ 475{
397#define WPC_DBRMODE 0x0d104008 476#define WPC_DBRMODE 0x0d104008
398 static int first_call = 1; 477 static unsigned long first_call;
399 478
400 lock_kernel(); 479 if (!test_and_set_bit(0, &first_call)) {
401 if (first_call) {
402 /* Set WPC.DBRMODE to 0. This makes all debug events get 480 /* Set WPC.DBRMODE to 0. This makes all debug events get
403 * delivered through RESVEC, i.e. into the handlers in entry.S. 481 * delivered through RESVEC, i.e. into the handlers in entry.S.
404 * (If the kernel was downloaded using a remote gdb, WPC.DBRMODE 482 * (If the kernel was downloaded using a remote gdb, WPC.DBRMODE
@@ -408,9 +486,7 @@ asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
408 * the remote gdb.) */ 486 * the remote gdb.) */
409 printk("DBRMODE set to 0 to permit native debugging\n"); 487 printk("DBRMODE set to 0 to permit native debugging\n");
410 poke_real_address_q(WPC_DBRMODE, 0); 488 poke_real_address_q(WPC_DBRMODE, 0);
411 first_call = 0;
412 } 489 }
413 unlock_kernel();
414 490
415 return sys_ptrace(request, pid, addr, data); 491 return sys_ptrace(request, pid, addr, data);
416} 492}
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
index b1fca66bb92e..ca6a5ca64015 100644
--- a/arch/sh/kernel/reboot.c
+++ b/arch/sh/kernel/reboot.c
@@ -9,6 +9,7 @@
9#include <asm/addrspace.h> 9#include <asm/addrspace.h>
10#include <asm/reboot.h> 10#include <asm/reboot.h>
11#include <asm/system.h> 11#include <asm/system.h>
12#include <asm/tlbflush.h>
12 13
13void (*pm_power_off)(void); 14void (*pm_power_off)(void);
14EXPORT_SYMBOL(pm_power_off); 15EXPORT_SYMBOL(pm_power_off);
@@ -25,6 +26,9 @@ static void native_machine_restart(char * __unused)
25{ 26{
26 local_irq_disable(); 27 local_irq_disable();
27 28
29 /* Destroy all of the TLBs in preparation for reset by MMU */
30 __flush_tlb_global();
31
28 /* Address error with SR.BL=1 first. */ 32 /* Address error with SR.BL=1 first. */
29 trigger_address_error(); 33 trigger_address_error();
30 34
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index e769401a78ba..4e278467f76c 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -24,7 +24,6 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/smp.h> 25#include <linux/smp.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/debugfs.h>
28#include <linux/crash_dump.h> 27#include <linux/crash_dump.h>
29#include <linux/mmzone.h> 28#include <linux/mmzone.h>
30#include <linux/clk.h> 29#include <linux/clk.h>
@@ -136,8 +135,9 @@ void __init check_for_initrd(void)
136 goto disable; 135 goto disable;
137 } 136 }
138 137
139 if (unlikely(start < PAGE_OFFSET)) { 138 if (unlikely(start < __MEMORY_START)) {
140 pr_err("initrd start < PAGE_OFFSET\n"); 139 pr_err("initrd start (%08lx) < __MEMORY_START(%x)\n",
140 start, __MEMORY_START);
141 goto disable; 141 goto disable;
142 } 142 }
143 143
@@ -158,7 +158,7 @@ void __init check_for_initrd(void)
158 /* 158 /*
159 * Address sanitization 159 * Address sanitization
160 */ 160 */
161 initrd_start = (unsigned long)__va(__pa(start)); 161 initrd_start = (unsigned long)__va(start);
162 initrd_end = initrd_start + INITRD_SIZE; 162 initrd_end = initrd_start + INITRD_SIZE;
163 163
164 memblock_reserve(__pa(initrd_start), INITRD_SIZE); 164 memblock_reserve(__pa(initrd_start), INITRD_SIZE);
@@ -458,17 +458,3 @@ const struct seq_operations cpuinfo_op = {
458 .show = show_cpuinfo, 458 .show = show_cpuinfo,
459}; 459};
460#endif /* CONFIG_PROC_FS */ 460#endif /* CONFIG_PROC_FS */
461
462struct dentry *sh_debugfs_root;
463
464static int __init sh_debugfs_init(void)
465{
466 sh_debugfs_root = debugfs_create_dir("sh", NULL);
467 if (!sh_debugfs_root)
468 return -ENOMEM;
469 if (IS_ERR(sh_debugfs_root))
470 return PTR_ERR(sh_debugfs_root);
471
472 return 0;
473}
474arch_initcall(sh_debugfs_init);
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index 19fd11dd9871..e872e81add8a 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -353,3 +353,25 @@ ENTRY(sys_call_table)
353 .long sys_pwritev 353 .long sys_pwritev
354 .long sys_rt_tgsigqueueinfo /* 335 */ 354 .long sys_rt_tgsigqueueinfo /* 335 */
355 .long sys_perf_event_open 355 .long sys_perf_event_open
356 .long sys_fanotify_init
357 .long sys_fanotify_mark
358 .long sys_prlimit64
359 /* Broken-out socket family */
360 .long sys_socket /* 340 */
361 .long sys_bind
362 .long sys_connect
363 .long sys_listen
364 .long sys_accept
365 .long sys_getsockname /* 345 */
366 .long sys_getpeername
367 .long sys_socketpair
368 .long sys_send
369 .long sys_sendto
370 .long sys_recv /* 350 */
371 .long sys_recvfrom
372 .long sys_shutdown
373 .long sys_setsockopt
374 .long sys_getsockopt
375 .long sys_sendmsg /* 355 */
376 .long sys_recvmsg
377 .long sys_recvmmsg
diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S
index 2048a20d7c80..66585708ce90 100644
--- a/arch/sh/kernel/syscalls_64.S
+++ b/arch/sh/kernel/syscalls_64.S
@@ -393,3 +393,6 @@ sys_call_table:
393 .long sys_perf_event_open 393 .long sys_perf_event_open
394 .long sys_recvmmsg /* 365 */ 394 .long sys_recvmmsg /* 365 */
395 .long sys_accept4 395 .long sys_accept4
396 .long sys_fanotify_init
397 .long sys_fanotify_mark
398 .long sys_prlimit64
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index c3d86fa71ddf..3484c2f65aba 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -5,7 +5,7 @@
5 * SuperH version: Copyright (C) 1999 Niibe Yutaka 5 * SuperH version: Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000 Philipp Rumpf 6 * Copyright (C) 2000 Philipp Rumpf
7 * Copyright (C) 2000 David Howells 7 * Copyright (C) 2000 David Howells
8 * Copyright (C) 2002 - 2007 Paul Mundt 8 * Copyright (C) 2002 - 2010 Paul Mundt
9 * 9 *
10 * This file is subject to the terms and conditions of the GNU General Public 10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive 11 * License. See the file "COPYING" in the main directory of this archive
@@ -26,6 +26,7 @@
26#include <linux/limits.h> 26#include <linux/limits.h>
27#include <linux/sysfs.h> 27#include <linux/sysfs.h>
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/perf_event.h>
29#include <asm/system.h> 30#include <asm/system.h>
30#include <asm/alignment.h> 31#include <asm/alignment.h>
31#include <asm/fpu.h> 32#include <asm/fpu.h>
@@ -369,7 +370,8 @@ static inline int handle_delayslot(struct pt_regs *regs,
369#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4) 370#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4)
370 371
371int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, 372int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
372 struct mem_access *ma, int expected) 373 struct mem_access *ma, int expected,
374 unsigned long address)
373{ 375{
374 u_int rm; 376 u_int rm;
375 int ret, index; 377 int ret, index;
@@ -383,9 +385,18 @@ int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
383 index = (instruction>>8)&15; /* 0x0F00 */ 385 index = (instruction>>8)&15; /* 0x0F00 */
384 rm = regs->regs[index]; 386 rm = regs->regs[index];
385 387
386 /* shout about fixups */ 388 /*
387 if (!expected) 389 * Log the unexpected fixups, and then pass them on to perf.
390 *
391 * We intentionally don't report the expected cases to perf as
392 * otherwise the trapped I/O case will skew the results too much
393 * to be useful.
394 */
395 if (!expected) {
388 unaligned_fixups_notify(current, instruction, regs); 396 unaligned_fixups_notify(current, instruction, regs);
397 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0,
398 regs, address);
399 }
389 400
390 ret = -EFAULT; 401 ret = -EFAULT;
391 switch (instruction&0xF000) { 402 switch (instruction&0xF000) {
@@ -574,7 +585,8 @@ fixup:
574 585
575 set_fs(USER_DS); 586 set_fs(USER_DS);
576 tmp = handle_unaligned_access(instruction, regs, 587 tmp = handle_unaligned_access(instruction, regs,
577 &user_mem_access, 0); 588 &user_mem_access, 0,
589 address);
578 set_fs(oldfs); 590 set_fs(oldfs);
579 591
580 if (tmp == 0) 592 if (tmp == 0)
@@ -607,8 +619,8 @@ uspace_segv:
607 619
608 unaligned_fixups_notify(current, instruction, regs); 620 unaligned_fixups_notify(current, instruction, regs);
609 621
610 handle_unaligned_access(instruction, regs, 622 handle_unaligned_access(instruction, regs, &user_mem_access,
611 &user_mem_access, 0); 623 0, address);
612 set_fs(oldfs); 624 set_fs(oldfs);
613 } 625 }
614} 626}
@@ -802,6 +814,9 @@ void __cpuinit per_cpu_trap_init(void)
802 : /* no output */ 814 : /* no output */
803 : "r" (&vbr_base) 815 : "r" (&vbr_base)
804 : "memory"); 816 : "memory");
817
818 /* disable exception blocking now when the vbr has been setup */
819 clear_bl_bit();
805} 820}
806 821
807void *set_exception_table_vec(unsigned int vec, void *handler) 822void *set_exception_table_vec(unsigned int vec, void *handler)
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index e67e140bf1f6..6713ca97e553 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -24,6 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/sysctl.h> 25#include <linux/sysctl.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/perf_event.h>
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/io.h> 30#include <asm/io.h>
@@ -50,7 +51,7 @@ asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
50 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \ 51 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
51} 52}
52 53
53spinlock_t die_lock; 54static DEFINE_SPINLOCK(die_lock);
54 55
55void die(const char * str, struct pt_regs * regs, long err) 56void die(const char * str, struct pt_regs * regs, long err)
56{ 57{
@@ -433,6 +434,8 @@ static int misaligned_load(struct pt_regs *regs,
433 return error; 434 return error;
434 } 435 }
435 436
437 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, address);
438
436 destreg = (opcode >> 4) & 0x3f; 439 destreg = (opcode >> 4) & 0x3f;
437 if (user_mode(regs)) { 440 if (user_mode(regs)) {
438 __u64 buffer; 441 __u64 buffer;
@@ -509,6 +512,8 @@ static int misaligned_store(struct pt_regs *regs,
509 return error; 512 return error;
510 } 513 }
511 514
515 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, address);
516
512 srcreg = (opcode >> 4) & 0x3f; 517 srcreg = (opcode >> 4) & 0x3f;
513 if (user_mode(regs)) { 518 if (user_mode(regs)) {
514 __u64 buffer; 519 __u64 buffer;
@@ -583,6 +588,8 @@ static int misaligned_fpu_load(struct pt_regs *regs,
583 return error; 588 return error;
584 } 589 }
585 590
591 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, address);
592
586 destreg = (opcode >> 4) & 0x3f; 593 destreg = (opcode >> 4) & 0x3f;
587 if (user_mode(regs)) { 594 if (user_mode(regs)) {
588 __u64 buffer; 595 __u64 buffer;
@@ -658,6 +665,8 @@ static int misaligned_fpu_store(struct pt_regs *regs,
658 return error; 665 return error;
659 } 666 }
660 667
668 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, address);
669
661 srcreg = (opcode >> 4) & 0x3f; 670 srcreg = (opcode >> 4) & 0x3f;
662 if (user_mode(regs)) { 671 if (user_mode(regs)) {
663 __u64 buffer; 672 __u64 buffer;
diff --git a/arch/sh/lib/Makefile b/arch/sh/lib/Makefile
index dab4d2129812..7b95f29e3174 100644
--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -30,4 +30,4 @@ lib-$(CONFIG_MMU) += copy_page.o __clear_user.o
30lib-$(CONFIG_MCOUNT) += mcount.o 30lib-$(CONFIG_MCOUNT) += mcount.o
31lib-y += $(memcpy-y) $(memset-y) $(udivsi3-y) 31lib-y += $(memcpy-y) $(memset-y) $(udivsi3-y)
32 32
33EXTRA_CFLAGS += -Werror 33ccflags-y := -Werror
diff --git a/arch/sh/math-emu/math.c b/arch/sh/math-emu/math.c
index 1fcdb1220975..f76a5090d5d1 100644
--- a/arch/sh/math-emu/math.c
+++ b/arch/sh/math-emu/math.c
@@ -12,6 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/signal.h> 14#include <linux/signal.h>
15#include <linux/perf_event.h>
15 16
16#include <asm/system.h> 17#include <asm/system.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
@@ -619,6 +620,8 @@ int do_fpu_inst(unsigned short inst, struct pt_regs *regs)
619 struct task_struct *tsk = current; 620 struct task_struct *tsk = current;
620 struct sh_fpu_soft_struct *fpu = &(tsk->thread.xstate->softfpu); 621 struct sh_fpu_soft_struct *fpu = &(tsk->thread.xstate->softfpu);
621 622
623 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
624
622 if (!(task_thread_info(tsk)->status & TS_USEDFPU)) { 625 if (!(task_thread_info(tsk)->status & TS_USEDFPU)) {
623 /* initialize once. */ 626 /* initialize once. */
624 fpu_init(fpu); 627 fpu_init(fpu);
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 1445ca6257df..09370392aff1 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -168,6 +168,10 @@ config IOREMAP_FIXED
168config UNCACHED_MAPPING 168config UNCACHED_MAPPING
169 bool 169 bool
170 170
171config HAVE_SRAM_POOL
172 bool
173 select GENERIC_ALLOCATOR
174
171choice 175choice
172 prompt "Kernel page size" 176 prompt "Kernel page size"
173 default PAGE_SIZE_4KB 177 default PAGE_SIZE_4KB
diff --git a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile
index 53f7c684afb2..ab89ea4f9414 100644
--- a/arch/sh/mm/Makefile
+++ b/arch/sh/mm/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_PMB) += pmb.o
40obj-$(CONFIG_NUMA) += numa.o 40obj-$(CONFIG_NUMA) += numa.o
41obj-$(CONFIG_IOREMAP_FIXED) += ioremap_fixed.o 41obj-$(CONFIG_IOREMAP_FIXED) += ioremap_fixed.o
42obj-$(CONFIG_UNCACHED_MAPPING) += uncached.o 42obj-$(CONFIG_UNCACHED_MAPPING) += uncached.o
43obj-$(CONFIG_HAVE_SRAM_POOL) += sram.o
43 44
44# Special flags for fault_64.o. This puts restrictions on the number of 45# Special flags for fault_64.o. This puts restrictions on the number of
45# caller-save registers that the compiler can target when building this file. 46# caller-save registers that the compiler can target when building this file.
@@ -66,4 +67,4 @@ CFLAGS_fault_64.o += -ffixed-r7 \
66 -ffixed-r60 -ffixed-r61 -ffixed-r62 \ 67 -ffixed-r60 -ffixed-r61 -ffixed-r62 \
67 -fomit-frame-pointer 68 -fomit-frame-pointer
68 69
69EXTRA_CFLAGS += -Werror 70ccflags-y := -Werror
diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c
index cd8c3bf39b5a..74c03ecc4871 100644
--- a/arch/sh/mm/asids-debugfs.c
+++ b/arch/sh/mm/asids-debugfs.c
@@ -63,7 +63,7 @@ static int __init asids_debugfs_init(void)
63{ 63{
64 struct dentry *asids_dentry; 64 struct dentry *asids_dentry;
65 65
66 asids_dentry = debugfs_create_file("asids", S_IRUSR, sh_debugfs_root, 66 asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir,
67 NULL, &asids_debugfs_fops); 67 NULL, &asids_debugfs_fops);
68 if (!asids_dentry) 68 if (!asids_dentry)
69 return -ENOMEM; 69 return -ENOMEM;
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index 690ed010d002..52411462c409 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -126,25 +126,19 @@ static int __init cache_debugfs_init(void)
126{ 126{
127 struct dentry *dcache_dentry, *icache_dentry; 127 struct dentry *dcache_dentry, *icache_dentry;
128 128
129 dcache_dentry = debugfs_create_file("dcache", S_IRUSR, sh_debugfs_root, 129 dcache_dentry = debugfs_create_file("dcache", S_IRUSR, arch_debugfs_dir,
130 (unsigned int *)CACHE_TYPE_DCACHE, 130 (unsigned int *)CACHE_TYPE_DCACHE,
131 &cache_debugfs_fops); 131 &cache_debugfs_fops);
132 if (!dcache_dentry) 132 if (!dcache_dentry)
133 return -ENOMEM; 133 return -ENOMEM;
134 if (IS_ERR(dcache_dentry))
135 return PTR_ERR(dcache_dentry);
136 134
137 icache_dentry = debugfs_create_file("icache", S_IRUSR, sh_debugfs_root, 135 icache_dentry = debugfs_create_file("icache", S_IRUSR, arch_debugfs_dir,
138 (unsigned int *)CACHE_TYPE_ICACHE, 136 (unsigned int *)CACHE_TYPE_ICACHE,
139 &cache_debugfs_fops); 137 &cache_debugfs_fops);
140 if (!icache_dentry) { 138 if (!icache_dentry) {
141 debugfs_remove(dcache_dentry); 139 debugfs_remove(dcache_dentry);
142 return -ENOMEM; 140 return -ENOMEM;
143 } 141 }
144 if (IS_ERR(icache_dentry)) {
145 debugfs_remove(dcache_dentry);
146 return PTR_ERR(icache_dentry);
147 }
148 142
149 return 0; 143 return 0;
150} 144}
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index c86a08540258..038793286990 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -38,11 +38,12 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
38 void *ret, *ret_nocache; 38 void *ret, *ret_nocache;
39 int order = get_order(size); 39 int order = get_order(size);
40 40
41 gfp |= __GFP_ZERO;
42
41 ret = (void *)__get_free_pages(gfp, order); 43 ret = (void *)__get_free_pages(gfp, order);
42 if (!ret) 44 if (!ret)
43 return NULL; 45 return NULL;
44 46
45 memset(ret, 0, size);
46 /* 47 /*
47 * Pages from the page allocator may have data present in 48 * Pages from the page allocator may have data present in
48 * cache. So flush the cache before using uncached memory. 49 * cache. So flush the cache before using uncached memory.
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index d0e249100e98..3385b28acaac 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -47,7 +47,6 @@ static pte_t *__get_pte_phys(unsigned long addr)
47 pgd_t *pgd; 47 pgd_t *pgd;
48 pud_t *pud; 48 pud_t *pud;
49 pmd_t *pmd; 49 pmd_t *pmd;
50 pte_t *pte;
51 50
52 pgd = pgd_offset_k(addr); 51 pgd = pgd_offset_k(addr);
53 if (pgd_none(*pgd)) { 52 if (pgd_none(*pgd)) {
@@ -67,8 +66,7 @@ static pte_t *__get_pte_phys(unsigned long addr)
67 return NULL; 66 return NULL;
68 } 67 }
69 68
70 pte = pte_offset_kernel(pmd, addr); 69 return pte_offset_kernel(pmd, addr);
71 return pte;
72} 70}
73 71
74static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) 72static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
@@ -125,13 +123,45 @@ void __clear_fixmap(enum fixed_addresses idx, pgprot_t prot)
125 clear_pte_phys(address, prot); 123 clear_pte_phys(address, prot);
126} 124}
127 125
126static pmd_t * __init one_md_table_init(pud_t *pud)
127{
128 if (pud_none(*pud)) {
129 pmd_t *pmd;
130
131 pmd = alloc_bootmem_pages(PAGE_SIZE);
132 pud_populate(&init_mm, pud, pmd);
133 BUG_ON(pmd != pmd_offset(pud, 0));
134 }
135
136 return pmd_offset(pud, 0);
137}
138
139static pte_t * __init one_page_table_init(pmd_t *pmd)
140{
141 if (pmd_none(*pmd)) {
142 pte_t *pte;
143
144 pte = alloc_bootmem_pages(PAGE_SIZE);
145 pmd_populate_kernel(&init_mm, pmd, pte);
146 BUG_ON(pte != pte_offset_kernel(pmd, 0));
147 }
148
149 return pte_offset_kernel(pmd, 0);
150}
151
152static pte_t * __init page_table_kmap_check(pte_t *pte, pmd_t *pmd,
153 unsigned long vaddr, pte_t *lastpte)
154{
155 return pte;
156}
157
128void __init page_table_range_init(unsigned long start, unsigned long end, 158void __init page_table_range_init(unsigned long start, unsigned long end,
129 pgd_t *pgd_base) 159 pgd_t *pgd_base)
130{ 160{
131 pgd_t *pgd; 161 pgd_t *pgd;
132 pud_t *pud; 162 pud_t *pud;
133 pmd_t *pmd; 163 pmd_t *pmd;
134 pte_t *pte; 164 pte_t *pte = NULL;
135 int i, j, k; 165 int i, j, k;
136 unsigned long vaddr; 166 unsigned long vaddr;
137 167
@@ -144,19 +174,13 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
144 for ( ; (i < PTRS_PER_PGD) && (vaddr != end); pgd++, i++) { 174 for ( ; (i < PTRS_PER_PGD) && (vaddr != end); pgd++, i++) {
145 pud = (pud_t *)pgd; 175 pud = (pud_t *)pgd;
146 for ( ; (j < PTRS_PER_PUD) && (vaddr != end); pud++, j++) { 176 for ( ; (j < PTRS_PER_PUD) && (vaddr != end); pud++, j++) {
147#ifdef __PAGETABLE_PMD_FOLDED 177 pmd = one_md_table_init(pud);
148 pmd = (pmd_t *)pud; 178#ifndef __PAGETABLE_PMD_FOLDED
149#else
150 pmd = (pmd_t *)alloc_bootmem_low_pages(PAGE_SIZE);
151 pud_populate(&init_mm, pud, pmd);
152 pmd += k; 179 pmd += k;
153#endif 180#endif
154 for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) { 181 for (; (k < PTRS_PER_PMD) && (vaddr != end); pmd++, k++) {
155 if (pmd_none(*pmd)) { 182 pte = page_table_kmap_check(one_page_table_init(pmd),
156 pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); 183 pmd, vaddr, pte);
157 pmd_populate_kernel(&init_mm, pmd, pte);
158 BUG_ON(pte != pte_offset_kernel(pmd, 0));
159 }
160 vaddr += PMD_SIZE; 184 vaddr += PMD_SIZE;
161 } 185 }
162 k = 0; 186 k = 0;
@@ -200,7 +224,6 @@ static void __init bootmem_init_one_node(unsigned int nid)
200 unsigned long total_pages, paddr; 224 unsigned long total_pages, paddr;
201 unsigned long end_pfn; 225 unsigned long end_pfn;
202 struct pglist_data *p; 226 struct pglist_data *p;
203 int i;
204 227
205 p = NODE_DATA(nid); 228 p = NODE_DATA(nid);
206 229
@@ -226,11 +249,12 @@ static void __init bootmem_init_one_node(unsigned int nid)
226 * reservations in other nodes. 249 * reservations in other nodes.
227 */ 250 */
228 if (nid == 0) { 251 if (nid == 0) {
252 struct memblock_region *reg;
253
229 /* Reserve the sections we're already using. */ 254 /* Reserve the sections we're already using. */
230 for (i = 0; i < memblock.reserved.cnt; i++) 255 for_each_memblock(reserved, reg) {
231 reserve_bootmem(memblock.reserved.region[i].base, 256 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
232 memblock_size_bytes(&memblock.reserved, i), 257 }
233 BOOTMEM_DEFAULT);
234 } 258 }
235 259
236 sparse_memory_present_with_active_regions(nid); 260 sparse_memory_present_with_active_regions(nid);
@@ -238,13 +262,14 @@ static void __init bootmem_init_one_node(unsigned int nid)
238 262
239static void __init do_init_bootmem(void) 263static void __init do_init_bootmem(void)
240{ 264{
265 struct memblock_region *reg;
241 int i; 266 int i;
242 267
243 /* Add active regions with valid PFNs. */ 268 /* Add active regions with valid PFNs. */
244 for (i = 0; i < memblock.memory.cnt; i++) { 269 for_each_memblock(memory, reg) {
245 unsigned long start_pfn, end_pfn; 270 unsigned long start_pfn, end_pfn;
246 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; 271 start_pfn = memblock_region_memory_base_pfn(reg);
247 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); 272 end_pfn = memblock_region_memory_end_pfn(reg);
248 __add_active_range(0, start_pfn, end_pfn); 273 __add_active_range(0, start_pfn, end_pfn);
249 } 274 }
250 275
diff --git a/arch/sh/mm/nommu.c b/arch/sh/mm/nommu.c
index 7694f50c9034..36312d254faf 100644
--- a/arch/sh/mm/nommu.c
+++ b/arch/sh/mm/nommu.c
@@ -67,6 +67,10 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
67 BUG(); 67 BUG();
68} 68}
69 69
70void __flush_tlb_global(void)
71{
72}
73
70void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) 74void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
71{ 75{
72} 76}
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 6379091a1647..b20b1b3eee4b 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -40,7 +40,7 @@ struct pmb_entry {
40 unsigned long flags; 40 unsigned long flags;
41 unsigned long size; 41 unsigned long size;
42 42
43 spinlock_t lock; 43 raw_spinlock_t lock;
44 44
45 /* 45 /*
46 * 0 .. NR_PMB_ENTRIES for specific entry selection, or 46 * 0 .. NR_PMB_ENTRIES for specific entry selection, or
@@ -265,7 +265,7 @@ static struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn,
265 265
266 memset(pmbe, 0, sizeof(struct pmb_entry)); 266 memset(pmbe, 0, sizeof(struct pmb_entry));
267 267
268 spin_lock_init(&pmbe->lock); 268 raw_spin_lock_init(&pmbe->lock);
269 269
270 pmbe->vpn = vpn; 270 pmbe->vpn = vpn;
271 pmbe->ppn = ppn; 271 pmbe->ppn = ppn;
@@ -327,9 +327,9 @@ static void set_pmb_entry(struct pmb_entry *pmbe)
327{ 327{
328 unsigned long flags; 328 unsigned long flags;
329 329
330 spin_lock_irqsave(&pmbe->lock, flags); 330 raw_spin_lock_irqsave(&pmbe->lock, flags);
331 __set_pmb_entry(pmbe); 331 __set_pmb_entry(pmbe);
332 spin_unlock_irqrestore(&pmbe->lock, flags); 332 raw_spin_unlock_irqrestore(&pmbe->lock, flags);
333} 333}
334#endif /* CONFIG_PM */ 334#endif /* CONFIG_PM */
335 335
@@ -368,7 +368,7 @@ int pmb_bolt_mapping(unsigned long vaddr, phys_addr_t phys,
368 return PTR_ERR(pmbe); 368 return PTR_ERR(pmbe);
369 } 369 }
370 370
371 spin_lock_irqsave(&pmbe->lock, flags); 371 raw_spin_lock_irqsave(&pmbe->lock, flags);
372 372
373 pmbe->size = pmb_sizes[i].size; 373 pmbe->size = pmb_sizes[i].size;
374 374
@@ -383,9 +383,10 @@ int pmb_bolt_mapping(unsigned long vaddr, phys_addr_t phys,
383 * entries for easier tear-down. 383 * entries for easier tear-down.
384 */ 384 */
385 if (likely(pmbp)) { 385 if (likely(pmbp)) {
386 spin_lock(&pmbp->lock); 386 raw_spin_lock_nested(&pmbp->lock,
387 SINGLE_DEPTH_NESTING);
387 pmbp->link = pmbe; 388 pmbp->link = pmbe;
388 spin_unlock(&pmbp->lock); 389 raw_spin_unlock(&pmbp->lock);
389 } 390 }
390 391
391 pmbp = pmbe; 392 pmbp = pmbe;
@@ -398,7 +399,7 @@ int pmb_bolt_mapping(unsigned long vaddr, phys_addr_t phys,
398 i--; 399 i--;
399 mapped++; 400 mapped++;
400 401
401 spin_unlock_irqrestore(&pmbe->lock, flags); 402 raw_spin_unlock_irqrestore(&pmbe->lock, flags);
402 } 403 }
403 } while (size >= SZ_16M); 404 } while (size >= SZ_16M);
404 405
@@ -627,15 +628,14 @@ static void __init pmb_synchronize(void)
627 continue; 628 continue;
628 } 629 }
629 630
630 spin_lock_irqsave(&pmbe->lock, irqflags); 631 raw_spin_lock_irqsave(&pmbe->lock, irqflags);
631 632
632 for (j = 0; j < ARRAY_SIZE(pmb_sizes); j++) 633 for (j = 0; j < ARRAY_SIZE(pmb_sizes); j++)
633 if (pmb_sizes[j].flag == size) 634 if (pmb_sizes[j].flag == size)
634 pmbe->size = pmb_sizes[j].size; 635 pmbe->size = pmb_sizes[j].size;
635 636
636 if (pmbp) { 637 if (pmbp) {
637 spin_lock(&pmbp->lock); 638 raw_spin_lock_nested(&pmbp->lock, SINGLE_DEPTH_NESTING);
638
639 /* 639 /*
640 * Compare the previous entry against the current one to 640 * Compare the previous entry against the current one to
641 * see if the entries span a contiguous mapping. If so, 641 * see if the entries span a contiguous mapping. If so,
@@ -644,13 +644,12 @@ static void __init pmb_synchronize(void)
644 */ 644 */
645 if (pmb_can_merge(pmbp, pmbe)) 645 if (pmb_can_merge(pmbp, pmbe))
646 pmbp->link = pmbe; 646 pmbp->link = pmbe;
647 647 raw_spin_unlock(&pmbp->lock);
648 spin_unlock(&pmbp->lock);
649 } 648 }
650 649
651 pmbp = pmbe; 650 pmbp = pmbe;
652 651
653 spin_unlock_irqrestore(&pmbe->lock, irqflags); 652 raw_spin_unlock_irqrestore(&pmbe->lock, irqflags);
654 } 653 }
655} 654}
656 655
@@ -757,7 +756,7 @@ static void __init pmb_resize(void)
757 /* 756 /*
758 * Found it, now resize it. 757 * Found it, now resize it.
759 */ 758 */
760 spin_lock_irqsave(&pmbe->lock, flags); 759 raw_spin_lock_irqsave(&pmbe->lock, flags);
761 760
762 pmbe->size = SZ_16M; 761 pmbe->size = SZ_16M;
763 pmbe->flags &= ~PMB_SZ_MASK; 762 pmbe->flags &= ~PMB_SZ_MASK;
@@ -767,7 +766,7 @@ static void __init pmb_resize(void)
767 766
768 __set_pmb_entry(pmbe); 767 __set_pmb_entry(pmbe);
769 768
770 spin_unlock_irqrestore(&pmbe->lock, flags); 769 raw_spin_unlock_irqrestore(&pmbe->lock, flags);
771 } 770 }
772 771
773 read_unlock(&pmb_rwlock); 772 read_unlock(&pmb_rwlock);
@@ -866,11 +865,9 @@ static int __init pmb_debugfs_init(void)
866 struct dentry *dentry; 865 struct dentry *dentry;
867 866
868 dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO, 867 dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO,
869 sh_debugfs_root, NULL, &pmb_debugfs_fops); 868 arch_debugfs_dir, NULL, &pmb_debugfs_fops);
870 if (!dentry) 869 if (!dentry)
871 return -ENOMEM; 870 return -ENOMEM;
872 if (IS_ERR(dentry))
873 return PTR_ERR(dentry);
874 871
875 return 0; 872 return 0;
876} 873}
diff --git a/arch/sh/mm/sram.c b/arch/sh/mm/sram.c
new file mode 100644
index 000000000000..bc156ec4545e
--- /dev/null
+++ b/arch/sh/mm/sram.c
@@ -0,0 +1,34 @@
1/*
2 * SRAM pool for tiny memories not otherwise managed.
3 *
4 * Copyright (C) 2010 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <asm/sram.h>
13
14/*
15 * This provides a standard SRAM pool for tiny memories that can be
16 * added either by the CPU or the platform code. Typical SRAM sizes
17 * to be inserted in to the pool will generally be less than the page
18 * size, with anything more reasonably sized handled as a NUMA memory
19 * node.
20 */
21struct gen_pool *sram_pool;
22
23static int __init sram_pool_init(void)
24{
25 /*
26 * This is a global pool, we don't care about node locality.
27 */
28 sram_pool = gen_pool_create(1, -1);
29 if (unlikely(!sram_pool))
30 return -ENOMEM;
31
32 return 0;
33}
34core_initcall(sram_pool_init);
diff --git a/arch/sh/mm/tlb-debugfs.c b/arch/sh/mm/tlb-debugfs.c
index 229bf75f28df..dea637a09246 100644
--- a/arch/sh/mm/tlb-debugfs.c
+++ b/arch/sh/mm/tlb-debugfs.c
@@ -151,15 +151,13 @@ static int __init tlb_debugfs_init(void)
151{ 151{
152 struct dentry *itlb, *utlb; 152 struct dentry *itlb, *utlb;
153 153
154 itlb = debugfs_create_file("itlb", S_IRUSR, sh_debugfs_root, 154 itlb = debugfs_create_file("itlb", S_IRUSR, arch_debugfs_dir,
155 (unsigned int *)TLB_TYPE_ITLB, 155 (unsigned int *)TLB_TYPE_ITLB,
156 &tlb_debugfs_fops); 156 &tlb_debugfs_fops);
157 if (unlikely(!itlb)) 157 if (unlikely(!itlb))
158 return -ENOMEM; 158 return -ENOMEM;
159 if (IS_ERR(itlb))
160 return PTR_ERR(itlb);
161 159
162 utlb = debugfs_create_file("utlb", S_IRUSR, sh_debugfs_root, 160 utlb = debugfs_create_file("utlb", S_IRUSR, arch_debugfs_dir,
163 (unsigned int *)TLB_TYPE_UTLB, 161 (unsigned int *)TLB_TYPE_UTLB,
164 &tlb_debugfs_fops); 162 &tlb_debugfs_fops);
165 if (unlikely(!utlb)) { 163 if (unlikely(!utlb)) {
@@ -167,11 +165,6 @@ static int __init tlb_debugfs_init(void)
167 return -ENOMEM; 165 return -ENOMEM;
168 } 166 }
169 167
170 if (IS_ERR(utlb)) {
171 debugfs_remove(itlb);
172 return PTR_ERR(utlb);
173 }
174
175 return 0; 168 return 0;
176} 169}
177module_init(tlb_debugfs_init); 170module_init(tlb_debugfs_init);
diff --git a/arch/sh/mm/tlbflush_32.c b/arch/sh/mm/tlbflush_32.c
index 3fbe03ce8fe3..a6a20d6de4c0 100644
--- a/arch/sh/mm/tlbflush_32.c
+++ b/arch/sh/mm/tlbflush_32.c
@@ -119,3 +119,19 @@ void local_flush_tlb_mm(struct mm_struct *mm)
119 local_irq_restore(flags); 119 local_irq_restore(flags);
120 } 120 }
121} 121}
122
123void __flush_tlb_global(void)
124{
125 unsigned long flags;
126
127 local_irq_save(flags);
128
129 /*
130 * This is the most destructive of the TLB flushing options,
131 * and will tear down all of the UTLB/ITLB mappings, including
132 * wired entries.
133 */
134 __raw_writel(__raw_readl(MMUCR) | MMUCR_TI, MMUCR);
135
136 local_irq_restore(flags);
137}
diff --git a/arch/sh/mm/tlbflush_64.c b/arch/sh/mm/tlbflush_64.c
index 03db41cc1268..7f5810f5dfdc 100644
--- a/arch/sh/mm/tlbflush_64.c
+++ b/arch/sh/mm/tlbflush_64.c
@@ -455,6 +455,11 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
455 flush_tlb_all(); 455 flush_tlb_all();
456} 456}
457 457
458void __flush_tlb_global(void)
459{
460 flush_tlb_all();
461}
462
458void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte) 463void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
459{ 464{
460} 465}
diff --git a/arch/sh/oprofile/Makefile b/arch/sh/oprofile/Makefile
index 4886c5c1786c..e85aae73e3dc 100644
--- a/arch/sh/oprofile/Makefile
+++ b/arch/sh/oprofile/Makefile
@@ -6,4 +6,8 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
6 oprofilefs.o oprofile_stats.o \ 6 oprofilefs.o oprofile_stats.o \
7 timer_int.o ) 7 timer_int.o )
8 8
9ifeq ($(CONFIG_HW_PERF_EVENTS),y)
10DRIVER_OBJS += $(addprefix ../../../drivers/oprofile/, oprofile_perf.o)
11endif
12
9oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
diff --git a/arch/sh/oprofile/common.c b/arch/sh/oprofile/common.c
index ac604937f3ee..e10d89376f9b 100644
--- a/arch/sh/oprofile/common.c
+++ b/arch/sh/oprofile/common.c
@@ -17,114 +17,45 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/perf_event.h>
20#include <asm/processor.h> 21#include <asm/processor.h>
21#include "op_impl.h"
22
23static struct op_sh_model *model;
24
25static struct op_counter_config ctr[20];
26 22
23#ifdef CONFIG_HW_PERF_EVENTS
27extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth); 24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
28 25
29static int op_sh_setup(void) 26char *op_name_from_perf_id(void)
30{
31 /* Pre-compute the values to stuff in the hardware registers. */
32 model->reg_setup(ctr);
33
34 /* Configure the registers on all cpus. */
35 on_each_cpu(model->cpu_setup, NULL, 1);
36
37 return 0;
38}
39
40static int op_sh_create_files(struct super_block *sb, struct dentry *root)
41{ 27{
42 int i, ret = 0; 28 const char *pmu;
29 char buf[20];
30 int size;
43 31
44 for (i = 0; i < model->num_counters; i++) { 32 pmu = perf_pmu_name();
45 struct dentry *dir; 33 if (!pmu)
46 char buf[4]; 34 return NULL;
47 35
48 snprintf(buf, sizeof(buf), "%d", i); 36 size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
49 dir = oprofilefs_mkdir(sb, root, buf); 37 if (size > -1 && size < sizeof(buf))
38 return buf;
50 39
51 ret |= oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled); 40 return NULL;
52 ret |= oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
53 ret |= oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
54 ret |= oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
55
56 if (model->create_files)
57 ret |= model->create_files(sb, dir);
58 else
59 ret |= oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count);
60
61 /* Dummy entries */
62 ret |= oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask);
63 }
64
65 return ret;
66} 41}
67 42
68static int op_sh_start(void) 43int __init oprofile_arch_init(struct oprofile_operations *ops)
69{ 44{
70 /* Enable performance monitoring for all counters. */ 45 ops->backtrace = sh_backtrace;
71 on_each_cpu(model->cpu_start, NULL, 1);
72 46
73 return 0; 47 return oprofile_perf_init(ops);
74} 48}
75 49
76static void op_sh_stop(void) 50void __exit oprofile_arch_exit(void)
77{ 51{
78 /* Disable performance monitoring for all counters. */ 52 oprofile_perf_exit();
79 on_each_cpu(model->cpu_stop, NULL, 1);
80} 53}
81 54#else
82int __init oprofile_arch_init(struct oprofile_operations *ops) 55int __init oprofile_arch_init(struct oprofile_operations *ops)
83{ 56{
84 struct op_sh_model *lmodel = NULL; 57 pr_info("oprofile: hardware counters not available\n");
85 int ret; 58 return -ENODEV;
86
87 /*
88 * Always assign the backtrace op. If the counter initialization
89 * fails, we fall back to the timer which will still make use of
90 * this.
91 */
92 ops->backtrace = sh_backtrace;
93
94 /*
95 * XXX
96 *
97 * All of the SH7750/SH-4A counters have been converted to perf,
98 * this infrastructure hook is left for other users until they've
99 * had a chance to convert over, at which point all of this
100 * will be deleted.
101 */
102
103 if (!lmodel)
104 return -ENODEV;
105 if (!(current_cpu_data.flags & CPU_HAS_PERF_COUNTER))
106 return -ENODEV;
107
108 ret = lmodel->init();
109 if (unlikely(ret != 0))
110 return ret;
111
112 model = lmodel;
113
114 ops->setup = op_sh_setup;
115 ops->create_files = op_sh_create_files;
116 ops->start = op_sh_start;
117 ops->stop = op_sh_stop;
118 ops->cpu_type = lmodel->cpu_type;
119
120 printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
121 lmodel->cpu_type);
122
123 return 0;
124}
125
126void oprofile_arch_exit(void)
127{
128 if (model && model->exit)
129 model->exit();
130} 59}
60void __exit oprofile_arch_exit(void) {}
61#endif /* CONFIG_HW_PERF_EVENTS */
diff --git a/arch/sh/oprofile/op_impl.h b/arch/sh/oprofile/op_impl.h
deleted file mode 100644
index 1244479ceb29..000000000000
--- a/arch/sh/oprofile/op_impl.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef __OP_IMPL_H
2#define __OP_IMPL_H
3
4/* Per-counter configuration as set via oprofilefs. */
5struct op_counter_config {
6 unsigned long enabled;
7 unsigned long event;
8
9 unsigned long count;
10
11 /* Dummy values for userspace tool compliance */
12 unsigned long kernel;
13 unsigned long user;
14 unsigned long unit_mask;
15};
16
17/* Per-architecture configury and hooks. */
18struct op_sh_model {
19 void (*reg_setup)(struct op_counter_config *);
20 int (*create_files)(struct super_block *sb, struct dentry *dir);
21 void (*cpu_setup)(void *dummy);
22 int (*init)(void);
23 void (*exit)(void);
24 void (*cpu_start)(void *args);
25 void (*cpu_stop)(void *args);
26 char *cpu_type;
27 unsigned char num_counters;
28};
29
30/* arch/sh/oprofile/common.c */
31extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
32
33#endif /* __OP_IMPL_H */
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index b25aa554ee5e..9f56eb978024 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -52,6 +52,8 @@ MIGOR SH_MIGOR
52RSK7201 SH_RSK7201 52RSK7201 SH_RSK7201
53RSK7203 SH_RSK7203 53RSK7203 SH_RSK7203
54AP325RXA SH_AP325RXA 54AP325RXA SH_AP325RXA
55SH2007 SH_SH2007
56SH7757LCR SH_SH7757LCR
55SH7763RDP SH_SH7763RDP 57SH7763RDP SH_SH7763RDP
56SH7785LCR SH_SH7785LCR 58SH7785LCR SH_SH7785LCR
57SH7785LCR_PT SH_SH7785LCR_PT 59SH7785LCR_PT SH_SH7785LCR_PT
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 491e9d6de191..8e7bafc5dd0e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -19,6 +19,7 @@ config SPARC
19 bool 19 bool
20 default y 20 default y
21 select OF 21 select OF
22 select OF_PROMTREE
22 select HAVE_IDE 23 select HAVE_IDE
23 select HAVE_OPROFILE 24 select HAVE_OPROFILE
24 select HAVE_ARCH_KGDB if !SMP || SPARC64 25 select HAVE_ARCH_KGDB if !SMP || SPARC64
@@ -26,10 +27,12 @@ config SPARC
26 select ARCH_WANT_OPTIONAL_GPIOLIB 27 select ARCH_WANT_OPTIONAL_GPIOLIB
27 select RTC_CLASS 28 select RTC_CLASS
28 select RTC_DRV_M48T59 29 select RTC_DRV_M48T59
30 select HAVE_IRQ_WORK
29 select HAVE_PERF_EVENTS 31 select HAVE_PERF_EVENTS
30 select PERF_USE_VMALLOC 32 select PERF_USE_VMALLOC
31 select HAVE_DMA_ATTRS 33 select HAVE_DMA_ATTRS
32 select HAVE_DMA_API_DEBUG 34 select HAVE_DMA_API_DEBUG
35 select HAVE_ARCH_JUMP_LABEL
33 36
34config SPARC32 37config SPARC32
35 def_bool !64BIT 38 def_bool !64BIT
@@ -53,6 +56,7 @@ config SPARC64
53 select RTC_DRV_BQ4802 56 select RTC_DRV_BQ4802
54 select RTC_DRV_SUN4V 57 select RTC_DRV_SUN4V
55 select RTC_DRV_STARFIRE 58 select RTC_DRV_STARFIRE
59 select HAVE_IRQ_WORK
56 select HAVE_PERF_EVENTS 60 select HAVE_PERF_EVENTS
57 select PERF_USE_VMALLOC 61 select PERF_USE_VMALLOC
58 62
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index deeb0fba8029..3c93f08ce187 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -7,7 +7,6 @@ header-y += display7seg.h
7header-y += envctrl.h 7header-y += envctrl.h
8header-y += fbio.h 8header-y += fbio.h
9header-y += jsflash.h 9header-y += jsflash.h
10header-y += openprom.h
11header-y += openpromio.h 10header-y += openpromio.h
12header-y += perfctr.h 11header-y += perfctr.h
13header-y += psrcompat.h 12header-y += psrcompat.h
diff --git a/arch/sparc/include/asm/floppy_32.h b/arch/sparc/include/asm/floppy_32.h
index c792830636de..86666f70322e 100644
--- a/arch/sparc/include/asm/floppy_32.h
+++ b/arch/sparc/include/asm/floppy_32.h
@@ -304,7 +304,8 @@ static struct linux_prom_registers fd_regs[2];
304static int sun_floppy_init(void) 304static int sun_floppy_init(void)
305{ 305{
306 char state[128]; 306 char state[128];
307 int tnode, fd_node, num_regs; 307 phandle tnode, fd_node;
308 int num_regs;
308 struct resource r; 309 struct resource r;
309 310
310 use_virtual_dma = 1; 311 use_virtual_dma = 1;
diff --git a/arch/sparc/include/asm/irqflags_32.h b/arch/sparc/include/asm/irqflags_32.h
index 0fca9d97d44f..d4d0711de0f9 100644
--- a/arch/sparc/include/asm/irqflags_32.h
+++ b/arch/sparc/include/asm/irqflags_32.h
@@ -5,33 +5,40 @@
5 * 5 *
6 * This file gets included from lowlevel asm headers too, to provide 6 * This file gets included from lowlevel asm headers too, to provide
7 * wrapped versions of the local_irq_*() APIs, based on the 7 * wrapped versions of the local_irq_*() APIs, based on the
8 * raw_local_irq_*() functions from the lowlevel headers. 8 * arch_local_irq_*() functions from the lowlevel headers.
9 */ 9 */
10#ifndef _ASM_IRQFLAGS_H 10#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H 11#define _ASM_IRQFLAGS_H
12 12
13#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
14 14
15extern void raw_local_irq_restore(unsigned long); 15#include <linux/types.h>
16extern unsigned long __raw_local_irq_save(void);
17extern void raw_local_irq_enable(void);
18 16
19static inline unsigned long getipl(void) 17extern void arch_local_irq_restore(unsigned long);
18extern unsigned long arch_local_irq_save(void);
19extern void arch_local_irq_enable(void);
20
21static inline unsigned long arch_local_save_flags(void)
20{ 22{
21 unsigned long retval; 23 unsigned long flags;
24
25 asm volatile("rd %%psr, %0" : "=r" (flags));
26 return flags;
27}
22 28
23 __asm__ __volatile__("rd %%psr, %0" : "=r" (retval)); 29static inline void arch_local_irq_disable(void)
24 return retval; 30{
31 arch_local_irq_save();
25} 32}
26 33
27#define raw_local_save_flags(flags) ((flags) = getipl()) 34static inline bool arch_irqs_disabled_flags(unsigned long flags)
28#define raw_local_irq_save(flags) ((flags) = __raw_local_irq_save()) 35{
29#define raw_local_irq_disable() ((void) __raw_local_irq_save()) 36 return (flags & PSR_PIL) != 0;
30#define raw_irqs_disabled() ((getipl() & PSR_PIL) != 0) 37}
31 38
32static inline int raw_irqs_disabled_flags(unsigned long flags) 39static inline bool arch_irqs_disabled(void)
33{ 40{
34 return ((flags & PSR_PIL) != 0); 41 return arch_irqs_disabled_flags(arch_local_save_flags());
35} 42}
36 43
37#endif /* (__ASSEMBLY__) */ 44#endif /* (__ASSEMBLY__) */
diff --git a/arch/sparc/include/asm/irqflags_64.h b/arch/sparc/include/asm/irqflags_64.h
index bfa1ea45b4cd..aab969c82c2b 100644
--- a/arch/sparc/include/asm/irqflags_64.h
+++ b/arch/sparc/include/asm/irqflags_64.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * This file gets included from lowlevel asm headers too, to provide 6 * This file gets included from lowlevel asm headers too, to provide
7 * wrapped versions of the local_irq_*() APIs, based on the 7 * wrapped versions of the local_irq_*() APIs, based on the
8 * raw_local_irq_*() functions from the lowlevel headers. 8 * arch_local_irq_*() functions from the lowlevel headers.
9 */ 9 */
10#ifndef _ASM_IRQFLAGS_H 10#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H 11#define _ASM_IRQFLAGS_H
@@ -14,7 +14,7 @@
14 14
15#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
16 16
17static inline unsigned long __raw_local_save_flags(void) 17static inline unsigned long arch_local_save_flags(void)
18{ 18{
19 unsigned long flags; 19 unsigned long flags;
20 20
@@ -26,10 +26,7 @@ static inline unsigned long __raw_local_save_flags(void)
26 return flags; 26 return flags;
27} 27}
28 28
29#define raw_local_save_flags(flags) \ 29static inline void arch_local_irq_restore(unsigned long flags)
30 do { (flags) = __raw_local_save_flags(); } while (0)
31
32static inline void raw_local_irq_restore(unsigned long flags)
33{ 30{
34 __asm__ __volatile__( 31 __asm__ __volatile__(
35 "wrpr %0, %%pil" 32 "wrpr %0, %%pil"
@@ -39,7 +36,7 @@ static inline void raw_local_irq_restore(unsigned long flags)
39 ); 36 );
40} 37}
41 38
42static inline void raw_local_irq_disable(void) 39static inline void arch_local_irq_disable(void)
43{ 40{
44 __asm__ __volatile__( 41 __asm__ __volatile__(
45 "wrpr %0, %%pil" 42 "wrpr %0, %%pil"
@@ -49,7 +46,7 @@ static inline void raw_local_irq_disable(void)
49 ); 46 );
50} 47}
51 48
52static inline void raw_local_irq_enable(void) 49static inline void arch_local_irq_enable(void)
53{ 50{
54 __asm__ __volatile__( 51 __asm__ __volatile__(
55 "wrpr 0, %%pil" 52 "wrpr 0, %%pil"
@@ -59,22 +56,17 @@ static inline void raw_local_irq_enable(void)
59 ); 56 );
60} 57}
61 58
62static inline int raw_irqs_disabled_flags(unsigned long flags) 59static inline int arch_irqs_disabled_flags(unsigned long flags)
63{ 60{
64 return (flags > 0); 61 return (flags > 0);
65} 62}
66 63
67static inline int raw_irqs_disabled(void) 64static inline int arch_irqs_disabled(void)
68{ 65{
69 unsigned long flags = __raw_local_save_flags(); 66 return arch_irqs_disabled_flags(arch_local_save_flags());
70
71 return raw_irqs_disabled_flags(flags);
72} 67}
73 68
74/* 69static inline unsigned long arch_local_irq_save(void)
75 * For spinlocks, etc:
76 */
77static inline unsigned long __raw_local_irq_save(void)
78{ 70{
79 unsigned long flags, tmp; 71 unsigned long flags, tmp;
80 72
@@ -100,9 +92,6 @@ static inline unsigned long __raw_local_irq_save(void)
100 return flags; 92 return flags;
101} 93}
102 94
103#define raw_local_irq_save(flags) \
104 do { (flags) = __raw_local_irq_save(); } while (0)
105
106#endif /* (__ASSEMBLY__) */ 95#endif /* (__ASSEMBLY__) */
107 96
108#endif /* !(_ASM_IRQFLAGS_H) */ 97#endif /* !(_ASM_IRQFLAGS_H) */
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
new file mode 100644
index 000000000000..62e66d7b2fb6
--- /dev/null
+++ b/arch/sparc/include/asm/jump_label.h
@@ -0,0 +1,32 @@
1#ifndef _ASM_SPARC_JUMP_LABEL_H
2#define _ASM_SPARC_JUMP_LABEL_H
3
4#ifdef __KERNEL__
5
6#include <linux/types.h>
7#include <asm/system.h>
8
9#define JUMP_LABEL_NOP_SIZE 4
10
11#define JUMP_LABEL(key, label) \
12 do { \
13 asm goto("1:\n\t" \
14 "nop\n\t" \
15 "nop\n\t" \
16 ".pushsection __jump_table, \"a\"\n\t"\
17 ".word 1b, %l[" #label "], %c0\n\t" \
18 ".popsection \n\t" \
19 : : "i" (key) : : label);\
20 } while (0)
21
22#endif /* __KERNEL__ */
23
24typedef u32 jump_label_t;
25
26struct jump_entry {
27 jump_label_t code;
28 jump_label_t target;
29 jump_label_t key;
30};
31
32#endif
diff --git a/arch/sparc/include/asm/memblock.h b/arch/sparc/include/asm/memblock.h
index f12af880649b..c67b047ef85e 100644
--- a/arch/sparc/include/asm/memblock.h
+++ b/arch/sparc/include/asm/memblock.h
@@ -5,6 +5,4 @@
5 5
6#define MEMBLOCK_DBG(fmt...) prom_printf(fmt) 6#define MEMBLOCK_DBG(fmt...) prom_printf(fmt)
7 7
8#define MEMBLOCK_REAL_LIMIT 0
9
10#endif /* !(_SPARC64_MEMBLOCK_H) */ 8#endif /* !(_SPARC64_MEMBLOCK_H) */
diff --git a/arch/sparc/include/asm/openprom.h b/arch/sparc/include/asm/openprom.h
index 963e1a45c35f..81cd43432dc0 100644
--- a/arch/sparc/include/asm/openprom.h
+++ b/arch/sparc/include/asm/openprom.h
@@ -11,6 +11,8 @@
11#define LINUX_OPPROM_MAGIC 0x10010407 11#define LINUX_OPPROM_MAGIC 0x10010407
12 12
13#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
14#include <linux/of.h>
15
14/* V0 prom device operations. */ 16/* V0 prom device operations. */
15struct linux_dev_v0_funcs { 17struct linux_dev_v0_funcs {
16 int (*v0_devopen)(char *device_str); 18 int (*v0_devopen)(char *device_str);
@@ -26,7 +28,7 @@ struct linux_dev_v0_funcs {
26 28
27/* V2 and later prom device operations. */ 29/* V2 and later prom device operations. */
28struct linux_dev_v2_funcs { 30struct linux_dev_v2_funcs {
29 int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */ 31 phandle (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
30 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz); 32 char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
31 void (*v2_dumb_mem_free)(char *va, unsigned sz); 33 void (*v2_dumb_mem_free)(char *va, unsigned sz);
32 34
@@ -168,12 +170,12 @@ struct linux_romvec {
168 170
169/* Routines for traversing the prom device tree. */ 171/* Routines for traversing the prom device tree. */
170struct linux_nodeops { 172struct linux_nodeops {
171 int (*no_nextnode)(int node); 173 phandle (*no_nextnode)(phandle node);
172 int (*no_child)(int node); 174 phandle (*no_child)(phandle node);
173 int (*no_proplen)(int node, const char *name); 175 int (*no_proplen)(phandle node, const char *name);
174 int (*no_getprop)(int node, const char *name, char *val); 176 int (*no_getprop)(phandle node, const char *name, char *val);
175 int (*no_setprop)(int node, const char *name, char *val, int len); 177 int (*no_setprop)(phandle node, const char *name, char *val, int len);
176 char * (*no_nextprop)(int node, char *name); 178 char * (*no_nextprop)(phandle node, char *name);
177}; 179};
178 180
179/* More fun PROM structures for device probing. */ 181/* More fun PROM structures for device probing. */
diff --git a/arch/sparc/include/asm/oplib_32.h b/arch/sparc/include/asm/oplib_32.h
index 33e31ce6b31f..51296a6f5005 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -30,7 +30,7 @@ extern unsigned int prom_rev, prom_prev;
30/* Root node of the prom device tree, this stays constant after 30/* Root node of the prom device tree, this stays constant after
31 * initialization is complete. 31 * initialization is complete.
32 */ 32 */
33extern int prom_root_node; 33extern phandle prom_root_node;
34 34
35/* Pointer to prom structure containing the device tree traversal 35/* Pointer to prom structure containing the device tree traversal
36 * and usage utility functions. Only prom-lib should use these, 36 * and usage utility functions. Only prom-lib should use these,
@@ -178,68 +178,68 @@ extern void prom_putsegment(int context, unsigned long virt_addr,
178/* PROM device tree traversal functions... */ 178/* PROM device tree traversal functions... */
179 179
180/* Get the child node of the given node, or zero if no child exists. */ 180/* Get the child node of the given node, or zero if no child exists. */
181extern int prom_getchild(int parent_node); 181extern phandle prom_getchild(phandle parent_node);
182 182
183/* Get the next sibling node of the given node, or zero if no further 183/* Get the next sibling node of the given node, or zero if no further
184 * siblings exist. 184 * siblings exist.
185 */ 185 */
186extern int prom_getsibling(int node); 186extern phandle prom_getsibling(phandle node);
187 187
188/* Get the length, at the passed node, of the given property type. 188/* Get the length, at the passed node, of the given property type.
189 * Returns -1 on error (ie. no such property at this node). 189 * Returns -1 on error (ie. no such property at this node).
190 */ 190 */
191extern int prom_getproplen(int thisnode, const char *property); 191extern int prom_getproplen(phandle thisnode, const char *property);
192 192
193/* Fetch the requested property using the given buffer. Returns 193/* Fetch the requested property using the given buffer. Returns
194 * the number of bytes the prom put into your buffer or -1 on error. 194 * the number of bytes the prom put into your buffer or -1 on error.
195 */ 195 */
196extern int __must_check prom_getproperty(int thisnode, const char *property, 196extern int __must_check prom_getproperty(phandle thisnode, const char *property,
197 char *prop_buffer, int propbuf_size); 197 char *prop_buffer, int propbuf_size);
198 198
199/* Acquire an integer property. */ 199/* Acquire an integer property. */
200extern int prom_getint(int node, char *property); 200extern int prom_getint(phandle node, char *property);
201 201
202/* Acquire an integer property, with a default value. */ 202/* Acquire an integer property, with a default value. */
203extern int prom_getintdefault(int node, char *property, int defval); 203extern int prom_getintdefault(phandle node, char *property, int defval);
204 204
205/* Acquire a boolean property, 0=FALSE 1=TRUE. */ 205/* Acquire a boolean property, 0=FALSE 1=TRUE. */
206extern int prom_getbool(int node, char *prop); 206extern int prom_getbool(phandle node, char *prop);
207 207
208/* Acquire a string property, null string on error. */ 208/* Acquire a string property, null string on error. */
209extern void prom_getstring(int node, char *prop, char *buf, int bufsize); 209extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize);
210 210
211/* Does the passed node have the given "name"? YES=1 NO=0 */ 211/* Does the passed node have the given "name"? YES=1 NO=0 */
212extern int prom_nodematch(int thisnode, char *name); 212extern int prom_nodematch(phandle thisnode, char *name);
213 213
214/* Search all siblings starting at the passed node for "name" matching 214/* Search all siblings starting at the passed node for "name" matching
215 * the given string. Returns the node on success, zero on failure. 215 * the given string. Returns the node on success, zero on failure.
216 */ 216 */
217extern int prom_searchsiblings(int node_start, char *name); 217extern phandle prom_searchsiblings(phandle node_start, char *name);
218 218
219/* Return the first property type, as a string, for the given node. 219/* Return the first property type, as a string, for the given node.
220 * Returns a null string on error. 220 * Returns a null string on error.
221 */ 221 */
222extern char *prom_firstprop(int node, char *buffer); 222extern char *prom_firstprop(phandle node, char *buffer);
223 223
224/* Returns the next property after the passed property for the given 224/* Returns the next property after the passed property for the given
225 * node. Returns null string on failure. 225 * node. Returns null string on failure.
226 */ 226 */
227extern char *prom_nextprop(int node, char *prev_property, char *buffer); 227extern char *prom_nextprop(phandle node, char *prev_property, char *buffer);
228 228
229/* Returns phandle of the path specified */ 229/* Returns phandle of the path specified */
230extern int prom_finddevice(char *name); 230extern phandle prom_finddevice(char *name);
231 231
232/* Returns 1 if the specified node has given property. */ 232/* Returns 1 if the specified node has given property. */
233extern int prom_node_has_property(int node, char *property); 233extern int prom_node_has_property(phandle node, char *property);
234 234
235/* Set the indicated property at the given node with the passed value. 235/* Set the indicated property at the given node with the passed value.
236 * Returns the number of bytes of your value that the prom took. 236 * Returns the number of bytes of your value that the prom took.
237 */ 237 */
238extern int prom_setprop(int node, const char *prop_name, char *prop_value, 238extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
239 int value_size); 239 int value_size);
240 240
241extern int prom_pathtoinode(char *path); 241extern phandle prom_pathtoinode(char *path);
242extern int prom_inst2pkg(int); 242extern phandle prom_inst2pkg(int);
243 243
244/* Dorking with Bus ranges... */ 244/* Dorking with Bus ranges... */
245 245
@@ -247,13 +247,13 @@ extern int prom_inst2pkg(int);
247extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs); 247extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
248 248
249/* Apply ranges of any prom node (and optionally parent node as well) to registers. */ 249/* Apply ranges of any prom node (and optionally parent node as well) to registers. */
250extern void prom_apply_generic_ranges(int node, int parent, 250extern void prom_apply_generic_ranges(phandle node, phandle parent,
251 struct linux_prom_registers *sbusregs, int nregs); 251 struct linux_prom_registers *sbusregs, int nregs);
252 252
253/* CPU probing helpers. */ 253/* CPU probing helpers. */
254int cpu_find_by_instance(int instance, int *prom_node, int *mid); 254int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
255int cpu_find_by_mid(int mid, int *prom_node); 255int cpu_find_by_mid(int mid, phandle *prom_node);
256int cpu_get_hwmid(int prom_node); 256int cpu_get_hwmid(phandle prom_node);
257 257
258extern spinlock_t prom_lock; 258extern spinlock_t prom_lock;
259 259
diff --git a/arch/sparc/include/asm/oplib_64.h b/arch/sparc/include/asm/oplib_64.h
index 3e0b2d62303d..c9cc078e3e31 100644
--- a/arch/sparc/include/asm/oplib_64.h
+++ b/arch/sparc/include/asm/oplib_64.h
@@ -16,7 +16,7 @@ extern char prom_version[];
16/* Root node of the prom device tree, this stays constant after 16/* Root node of the prom device tree, this stays constant after
17 * initialization is complete. 17 * initialization is complete.
18 */ 18 */
19extern int prom_root_node; 19extern phandle prom_root_node;
20 20
21/* PROM stdin and stdout */ 21/* PROM stdin and stdout */
22extern int prom_stdin, prom_stdout; 22extern int prom_stdin, prom_stdout;
@@ -24,7 +24,7 @@ extern int prom_stdin, prom_stdout;
24/* /chosen node of the prom device tree, this stays constant after 24/* /chosen node of the prom device tree, this stays constant after
25 * initialization is complete. 25 * initialization is complete.
26 */ 26 */
27extern int prom_chosen_node; 27extern phandle prom_chosen_node;
28 28
29/* Helper values and strings in arch/sparc64/kernel/head.S */ 29/* Helper values and strings in arch/sparc64/kernel/head.S */
30extern const char prom_peer_name[]; 30extern const char prom_peer_name[];
@@ -218,68 +218,69 @@ extern void prom_unmap(unsigned long size, unsigned long vaddr);
218/* PROM device tree traversal functions... */ 218/* PROM device tree traversal functions... */
219 219
220/* Get the child node of the given node, or zero if no child exists. */ 220/* Get the child node of the given node, or zero if no child exists. */
221extern int prom_getchild(int parent_node); 221extern phandle prom_getchild(phandle parent_node);
222 222
223/* Get the next sibling node of the given node, or zero if no further 223/* Get the next sibling node of the given node, or zero if no further
224 * siblings exist. 224 * siblings exist.
225 */ 225 */
226extern int prom_getsibling(int node); 226extern phandle prom_getsibling(phandle node);
227 227
228/* Get the length, at the passed node, of the given property type. 228/* Get the length, at the passed node, of the given property type.
229 * Returns -1 on error (ie. no such property at this node). 229 * Returns -1 on error (ie. no such property at this node).
230 */ 230 */
231extern int prom_getproplen(int thisnode, const char *property); 231extern int prom_getproplen(phandle thisnode, const char *property);
232 232
233/* Fetch the requested property using the given buffer. Returns 233/* Fetch the requested property using the given buffer. Returns
234 * the number of bytes the prom put into your buffer or -1 on error. 234 * the number of bytes the prom put into your buffer or -1 on error.
235 */ 235 */
236extern int prom_getproperty(int thisnode, const char *property, 236extern int prom_getproperty(phandle thisnode, const char *property,
237 char *prop_buffer, int propbuf_size); 237 char *prop_buffer, int propbuf_size);
238 238
239/* Acquire an integer property. */ 239/* Acquire an integer property. */
240extern int prom_getint(int node, const char *property); 240extern int prom_getint(phandle node, const char *property);
241 241
242/* Acquire an integer property, with a default value. */ 242/* Acquire an integer property, with a default value. */
243extern int prom_getintdefault(int node, const char *property, int defval); 243extern int prom_getintdefault(phandle node, const char *property, int defval);
244 244
245/* Acquire a boolean property, 0=FALSE 1=TRUE. */ 245/* Acquire a boolean property, 0=FALSE 1=TRUE. */
246extern int prom_getbool(int node, const char *prop); 246extern int prom_getbool(phandle node, const char *prop);
247 247
248/* Acquire a string property, null string on error. */ 248/* Acquire a string property, null string on error. */
249extern void prom_getstring(int node, const char *prop, char *buf, int bufsize); 249extern void prom_getstring(phandle node, const char *prop, char *buf,
250 int bufsize);
250 251
251/* Does the passed node have the given "name"? YES=1 NO=0 */ 252/* Does the passed node have the given "name"? YES=1 NO=0 */
252extern int prom_nodematch(int thisnode, const char *name); 253extern int prom_nodematch(phandle thisnode, const char *name);
253 254
254/* Search all siblings starting at the passed node for "name" matching 255/* Search all siblings starting at the passed node for "name" matching
255 * the given string. Returns the node on success, zero on failure. 256 * the given string. Returns the node on success, zero on failure.
256 */ 257 */
257extern int prom_searchsiblings(int node_start, const char *name); 258extern phandle prom_searchsiblings(phandle node_start, const char *name);
258 259
259/* Return the first property type, as a string, for the given node. 260/* Return the first property type, as a string, for the given node.
260 * Returns a null string on error. Buffer should be at least 32B long. 261 * Returns a null string on error. Buffer should be at least 32B long.
261 */ 262 */
262extern char *prom_firstprop(int node, char *buffer); 263extern char *prom_firstprop(phandle node, char *buffer);
263 264
264/* Returns the next property after the passed property for the given 265/* Returns the next property after the passed property for the given
265 * node. Returns null string on failure. Buffer should be at least 32B long. 266 * node. Returns null string on failure. Buffer should be at least 32B long.
266 */ 267 */
267extern char *prom_nextprop(int node, const char *prev_property, char *buffer); 268extern char *prom_nextprop(phandle node, const char *prev_property, char *buf);
268 269
269/* Returns 1 if the specified node has given property. */ 270/* Returns 1 if the specified node has given property. */
270extern int prom_node_has_property(int node, const char *property); 271extern int prom_node_has_property(phandle node, const char *property);
271 272
272/* Returns phandle of the path specified */ 273/* Returns phandle of the path specified */
273extern int prom_finddevice(const char *name); 274extern phandle prom_finddevice(const char *name);
274 275
275/* Set the indicated property at the given node with the passed value. 276/* Set the indicated property at the given node with the passed value.
276 * Returns the number of bytes of your value that the prom took. 277 * Returns the number of bytes of your value that the prom took.
277 */ 278 */
278extern int prom_setprop(int node, const char *prop_name, char *prop_value, 279extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
279 int value_size); 280 int value_size);
280 281
281extern int prom_pathtoinode(const char *path); 282extern phandle prom_pathtoinode(const char *path);
282extern int prom_inst2pkg(int); 283extern phandle prom_inst2pkg(int);
283extern int prom_service_exists(const char *service_name); 284extern int prom_service_exists(const char *service_name);
284extern void prom_sun4v_guest_soft_state(void); 285extern void prom_sun4v_guest_soft_state(void);
285 286
diff --git a/arch/sparc/include/asm/perf_event.h b/arch/sparc/include/asm/perf_event.h
index 727af70646cb..6e8bfa1786da 100644
--- a/arch/sparc/include/asm/perf_event.h
+++ b/arch/sparc/include/asm/perf_event.h
@@ -1,10 +1,6 @@
1#ifndef __ASM_SPARC_PERF_EVENT_H 1#ifndef __ASM_SPARC_PERF_EVENT_H
2#define __ASM_SPARC_PERF_EVENT_H 2#define __ASM_SPARC_PERF_EVENT_H
3 3
4extern void set_perf_event_pending(void);
5
6#define PERF_EVENT_INDEX_OFFSET 0
7
8#ifdef CONFIG_PERF_EVENTS 4#ifdef CONFIG_PERF_EVENTS
9#include <asm/ptrace.h> 5#include <asm/ptrace.h>
10 6
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index 291f12575edd..56bbaadef646 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -18,6 +18,7 @@
18 * 2 of the License, or (at your option) any later version. 18 * 2 of the License, or (at your option) any later version.
19 */ 19 */
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/of_pdt.h>
21#include <linux/proc_fs.h> 22#include <linux/proc_fs.h>
22#include <linux/mutex.h> 23#include <linux/mutex.h>
23#include <asm/atomic.h> 24#include <asm/atomic.h>
@@ -67,8 +68,8 @@ extern struct device_node *of_console_device;
67extern char *of_console_path; 68extern char *of_console_path;
68extern char *of_console_options; 69extern char *of_console_options;
69 70
70extern void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp); 71extern void irq_trans_init(struct device_node *dp);
71extern char *build_full_name(struct device_node *dp); 72extern char *build_path_component(struct device_node *dp);
72 73
73#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
74#endif /* _SPARC_PROM_H */ 75#endif /* _SPARC_PROM_H */
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 0c2dc1f24a9a..599398fbbc7c 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -119,3 +119,5 @@ obj-$(CONFIG_COMPAT) += $(audit--y)
119 119
120pc--$(CONFIG_PERF_EVENTS) := perf_event.o 120pc--$(CONFIG_PERF_EVENTS) := perf_event.o
121obj-$(CONFIG_SPARC64) += $(pc--y) 121obj-$(CONFIG_SPARC64) += $(pc--y)
122
123obj-$(CONFIG_SPARC64) += jump_label.o
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index 2c0046ecc715..52de4a9424e8 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -132,6 +132,7 @@ static const struct file_operations apc_fops = {
132 .unlocked_ioctl = apc_ioctl, 132 .unlocked_ioctl = apc_ioctl,
133 .open = apc_open, 133 .open = apc_open,
134 .release = apc_release, 134 .release = apc_release,
135 .llseek = noop_llseek,
135}; 136};
136 137
137static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; 138static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };
diff --git a/arch/sparc/kernel/auxio_32.c b/arch/sparc/kernel/auxio_32.c
index ee8d214cae1e..35f48837871a 100644
--- a/arch/sparc/kernel/auxio_32.c
+++ b/arch/sparc/kernel/auxio_32.c
@@ -23,7 +23,7 @@ static DEFINE_SPINLOCK(auxio_lock);
23 23
24void __init auxio_probe(void) 24void __init auxio_probe(void)
25{ 25{
26 int node, auxio_nd; 26 phandle node, auxio_nd;
27 struct linux_prom_registers auxregs[1]; 27 struct linux_prom_registers auxregs[1];
28 struct resource r; 28 struct resource r;
29 29
@@ -113,7 +113,7 @@ volatile unsigned char * auxio_power_register = NULL;
113void __init auxio_power_probe(void) 113void __init auxio_power_probe(void)
114{ 114{
115 struct linux_prom_registers regs; 115 struct linux_prom_registers regs;
116 int node; 116 phandle node;
117 struct resource r; 117 struct resource r;
118 118
119 /* Attempt to find the sun4m power control node. */ 119 /* Attempt to find the sun4m power control node. */
diff --git a/arch/sparc/kernel/btext.c b/arch/sparc/kernel/btext.c
index 8cc2d56ffe9a..89aa4eb20cf5 100644
--- a/arch/sparc/kernel/btext.c
+++ b/arch/sparc/kernel/btext.c
@@ -40,7 +40,7 @@ static unsigned char *dispDeviceBase __force_data;
40 40
41static unsigned char vga_font[cmapsz]; 41static unsigned char vga_font[cmapsz];
42 42
43static int __init btext_initialize(unsigned int node) 43static int __init btext_initialize(phandle node)
44{ 44{
45 unsigned int width, height, depth, pitch; 45 unsigned int width, height, depth, pitch;
46 unsigned long address = 0; 46 unsigned long address = 0;
@@ -309,7 +309,7 @@ static struct console btext_console = {
309 309
310int __init btext_find_display(void) 310int __init btext_find_display(void)
311{ 311{
312 unsigned int node; 312 phandle node;
313 char type[32]; 313 char type[32];
314 int ret; 314 int ret;
315 315
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index 62dc7a021413..d2eddd6647cd 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -31,9 +31,9 @@ static char *cpu_mid_prop(void)
31 return "mid"; 31 return "mid";
32} 32}
33 33
34static int check_cpu_node(int nd, int *cur_inst, 34static int check_cpu_node(phandle nd, int *cur_inst,
35 int (*compare)(int, int, void *), void *compare_arg, 35 int (*compare)(phandle, int, void *), void *compare_arg,
36 int *prom_node, int *mid) 36 phandle *prom_node, int *mid)
37{ 37{
38 if (!compare(nd, *cur_inst, compare_arg)) { 38 if (!compare(nd, *cur_inst, compare_arg)) {
39 if (prom_node) 39 if (prom_node)
@@ -51,8 +51,8 @@ static int check_cpu_node(int nd, int *cur_inst,
51 return -ENODEV; 51 return -ENODEV;
52} 52}
53 53
54static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, 54static int __cpu_find_by(int (*compare)(phandle, int, void *),
55 int *prom_node, int *mid) 55 void *compare_arg, phandle *prom_node, int *mid)
56{ 56{
57 struct device_node *dp; 57 struct device_node *dp;
58 int cur_inst; 58 int cur_inst;
@@ -71,7 +71,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
71 return -ENODEV; 71 return -ENODEV;
72} 72}
73 73
74static int cpu_instance_compare(int nd, int instance, void *_arg) 74static int cpu_instance_compare(phandle nd, int instance, void *_arg)
75{ 75{
76 int desired_instance = (int) _arg; 76 int desired_instance = (int) _arg;
77 77
@@ -80,13 +80,13 @@ static int cpu_instance_compare(int nd, int instance, void *_arg)
80 return -ENODEV; 80 return -ENODEV;
81} 81}
82 82
83int cpu_find_by_instance(int instance, int *prom_node, int *mid) 83int cpu_find_by_instance(int instance, phandle *prom_node, int *mid)
84{ 84{
85 return __cpu_find_by(cpu_instance_compare, (void *)instance, 85 return __cpu_find_by(cpu_instance_compare, (void *)instance,
86 prom_node, mid); 86 prom_node, mid);
87} 87}
88 88
89static int cpu_mid_compare(int nd, int instance, void *_arg) 89static int cpu_mid_compare(phandle nd, int instance, void *_arg)
90{ 90{
91 int desired_mid = (int) _arg; 91 int desired_mid = (int) _arg;
92 int this_mid; 92 int this_mid;
@@ -98,7 +98,7 @@ static int cpu_mid_compare(int nd, int instance, void *_arg)
98 return -ENODEV; 98 return -ENODEV;
99} 99}
100 100
101int cpu_find_by_mid(int mid, int *prom_node) 101int cpu_find_by_mid(int mid, phandle *prom_node)
102{ 102{
103 return __cpu_find_by(cpu_mid_compare, (void *)mid, 103 return __cpu_find_by(cpu_mid_compare, (void *)mid,
104 prom_node, NULL); 104 prom_node, NULL);
@@ -108,7 +108,7 @@ int cpu_find_by_mid(int mid, int *prom_node)
108 * address (0-3). This gives us the true hardware mid, which might have 108 * address (0-3). This gives us the true hardware mid, which might have
109 * some other bits set. On 4d hardware and software mids are the same. 109 * some other bits set. On 4d hardware and software mids are the same.
110 */ 110 */
111int cpu_get_hwmid(int prom_node) 111int cpu_get_hwmid(phandle prom_node)
112{ 112{
113 return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV); 113 return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV);
114} 114}
@@ -119,7 +119,8 @@ void __init device_scan(void)
119 119
120#ifndef CONFIG_SMP 120#ifndef CONFIG_SMP
121 { 121 {
122 int err, cpu_node; 122 phandle cpu_node;
123 int err;
123 err = cpu_find_by_instance(0, &cpu_node, NULL); 124 err = cpu_find_by_instance(0, &cpu_node, NULL);
124 if (err) { 125 if (err) {
125 /* Probably a sun4e, Sun is trying to trick us ;-) */ 126 /* Probably a sun4e, Sun is trying to trick us ;-) */
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index e1af43728329..0116d8d10def 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -57,7 +57,7 @@
57#define SMP_NOP2 57#define SMP_NOP2
58#define SMP_NOP3 58#define SMP_NOP3
59#endif /* SMP */ 59#endif /* SMP */
60unsigned long __raw_local_irq_save(void) 60unsigned long arch_local_irq_save(void)
61{ 61{
62 unsigned long retval; 62 unsigned long retval;
63 unsigned long tmp; 63 unsigned long tmp;
@@ -74,8 +74,9 @@ unsigned long __raw_local_irq_save(void)
74 74
75 return retval; 75 return retval;
76} 76}
77EXPORT_SYMBOL(arch_local_irq_save);
77 78
78void raw_local_irq_enable(void) 79void arch_local_irq_enable(void)
79{ 80{
80 unsigned long tmp; 81 unsigned long tmp;
81 82
@@ -89,8 +90,9 @@ void raw_local_irq_enable(void)
89 : "i" (PSR_PIL) 90 : "i" (PSR_PIL)
90 : "memory"); 91 : "memory");
91} 92}
93EXPORT_SYMBOL(arch_local_irq_enable);
92 94
93void raw_local_irq_restore(unsigned long old_psr) 95void arch_local_irq_restore(unsigned long old_psr)
94{ 96{
95 unsigned long tmp; 97 unsigned long tmp;
96 98
@@ -105,10 +107,7 @@ void raw_local_irq_restore(unsigned long old_psr)
105 : "i" (PSR_PIL), "r" (old_psr) 107 : "i" (PSR_PIL), "r" (old_psr)
106 : "memory"); 108 : "memory");
107} 109}
108 110EXPORT_SYMBOL(arch_local_irq_restore);
109EXPORT_SYMBOL(__raw_local_irq_save);
110EXPORT_SYMBOL(raw_local_irq_enable);
111EXPORT_SYMBOL(raw_local_irq_restore);
112 111
113/* 112/*
114 * Dave Redman (djhr@tadpole.co.uk) 113 * Dave Redman (djhr@tadpole.co.uk)
diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
new file mode 100644
index 000000000000..ea2dafc93d78
--- /dev/null
+++ b/arch/sparc/kernel/jump_label.c
@@ -0,0 +1,47 @@
1#include <linux/kernel.h>
2#include <linux/types.h>
3#include <linux/mutex.h>
4#include <linux/cpu.h>
5
6#include <linux/jump_label.h>
7#include <linux/memory.h>
8
9#ifdef HAVE_JUMP_LABEL
10
11void arch_jump_label_transform(struct jump_entry *entry,
12 enum jump_label_type type)
13{
14 u32 val;
15 u32 *insn = (u32 *) (unsigned long) entry->code;
16
17 if (type == JUMP_LABEL_ENABLE) {
18 s32 off = (s32)entry->target - (s32)entry->code;
19
20#ifdef CONFIG_SPARC64
21 /* ba,pt %xcc, . + (off << 2) */
22 val = 0x10680000 | ((u32) off >> 2);
23#else
24 /* ba . + (off << 2) */
25 val = 0x10800000 | ((u32) off >> 2);
26#endif
27 } else {
28 val = 0x01000000;
29 }
30
31 get_online_cpus();
32 mutex_lock(&text_mutex);
33 *insn = val;
34 flushi(insn);
35 mutex_unlock(&text_mutex);
36 put_online_cpus();
37}
38
39void arch_jump_label_text_poke_early(jump_label_t addr)
40{
41 u32 *insn_p = (u32 *) (unsigned long) addr;
42
43 *insn_p = 0x01000000;
44 flushi(insn_p);
45}
46
47#endif
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index 6a7b4dbc8e09..2d51527d810f 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -282,5 +282,5 @@ void __init leon_init_IRQ(void)
282 282
283void __init leon_init(void) 283void __init leon_init(void)
284{ 284{
285 prom_build_more = &leon_node_init; 285 of_pdt_build_more = &leon_node_init;
286} 286}
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 83e85c2e802a..6addb914fcc8 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -890,6 +890,7 @@ static ssize_t mdesc_read(struct file *file, char __user *buf,
890static const struct file_operations mdesc_fops = { 890static const struct file_operations mdesc_fops = {
891 .read = mdesc_read, 891 .read = mdesc_read,
892 .owner = THIS_MODULE, 892 .owner = THIS_MODULE,
893 .llseek = noop_llseek,
893}; 894};
894 895
895static struct miscdevice mdesc_misc = { 896static struct miscdevice mdesc_misc = {
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index f848aadf54dc..ee3c7dde8d9f 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -18,6 +18,9 @@
18#include <asm/spitfire.h> 18#include <asm/spitfire.h>
19 19
20#ifdef CONFIG_SPARC64 20#ifdef CONFIG_SPARC64
21
22#include <linux/jump_label.h>
23
21static void *module_map(unsigned long size) 24static void *module_map(unsigned long size)
22{ 25{
23 struct vm_struct *area; 26 struct vm_struct *area;
@@ -227,6 +230,9 @@ int module_finalize(const Elf_Ehdr *hdr,
227 const Elf_Shdr *sechdrs, 230 const Elf_Shdr *sechdrs,
228 struct module *me) 231 struct module *me)
229{ 232{
233 /* make jump label nops */
234 jump_label_apply_nops(me);
235
230 /* Cheetah's I-cache is fully coherent. */ 236 /* Cheetah's I-cache is fully coherent. */
231 if (tlb_type == spitfire) { 237 if (tlb_type == spitfire) {
232 unsigned long va; 238 unsigned long va;
diff --git a/arch/sparc/kernel/pci_msi.c b/arch/sparc/kernel/pci_msi.c
index 548b8ca9c210..b210416ace7b 100644
--- a/arch/sparc/kernel/pci_msi.c
+++ b/arch/sparc/kernel/pci_msi.c
@@ -114,10 +114,10 @@ static void free_msi(struct pci_pbm_info *pbm, int msi_num)
114 114
115static struct irq_chip msi_irq = { 115static struct irq_chip msi_irq = {
116 .name = "PCI-MSI", 116 .name = "PCI-MSI",
117 .mask = mask_msi_irq, 117 .irq_mask = mask_msi_irq,
118 .unmask = unmask_msi_irq, 118 .irq_unmask = unmask_msi_irq,
119 .enable = unmask_msi_irq, 119 .irq_enable = unmask_msi_irq,
120 .disable = mask_msi_irq, 120 .irq_disable = mask_msi_irq,
121 /* XXX affinity XXX */ 121 /* XXX affinity XXX */
122}; 122};
123 123
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index d36a8d391ca0..aeaa09a3c655 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -284,7 +284,7 @@ int __init pcic_probe(void)
284 struct linux_prom_registers regs[PROMREG_MAX]; 284 struct linux_prom_registers regs[PROMREG_MAX];
285 struct linux_pbm_info* pbm; 285 struct linux_pbm_info* pbm;
286 char namebuf[64]; 286 char namebuf[64];
287 int node; 287 phandle node;
288 int err; 288 int err;
289 289
290 if (pcic0_up) { 290 if (pcic0_up) {
@@ -440,7 +440,7 @@ static int __devinit pdev_to_pnode(struct linux_pbm_info *pbm,
440{ 440{
441 struct linux_prom_pci_registers regs[PROMREG_MAX]; 441 struct linux_prom_pci_registers regs[PROMREG_MAX];
442 int err; 442 int err;
443 int node = prom_getchild(pbm->prom_node); 443 phandle node = prom_getchild(pbm->prom_node);
444 444
445 while(node) { 445 while(node) {
446 err = prom_getproperty(node, "reg", 446 err = prom_getproperty(node, "reg",
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
index c4a6a50b4849..b87873c0e8ea 100644
--- a/arch/sparc/kernel/pcr.c
+++ b/arch/sparc/kernel/pcr.c
@@ -7,7 +7,7 @@
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/irq.h> 8#include <linux/irq.h>
9 9
10#include <linux/perf_event.h> 10#include <linux/irq_work.h>
11#include <linux/ftrace.h> 11#include <linux/ftrace.h>
12 12
13#include <asm/pil.h> 13#include <asm/pil.h>
@@ -43,14 +43,14 @@ void __irq_entry deferred_pcr_work_irq(int irq, struct pt_regs *regs)
43 43
44 old_regs = set_irq_regs(regs); 44 old_regs = set_irq_regs(regs);
45 irq_enter(); 45 irq_enter();
46#ifdef CONFIG_PERF_EVENTS 46#ifdef CONFIG_IRQ_WORK
47 perf_event_do_pending(); 47 irq_work_run();
48#endif 48#endif
49 irq_exit(); 49 irq_exit();
50 set_irq_regs(old_regs); 50 set_irq_regs(old_regs);
51} 51}
52 52
53void set_perf_event_pending(void) 53void arch_irq_work_raise(void)
54{ 54{
55 set_softint(1 << PIL_DEFERRED_PCR_WORK); 55 set_softint(1 << PIL_DEFERRED_PCR_WORK);
56} 56}
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 6318e622cfb0..0d6deb55a2ae 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -658,13 +658,16 @@ static u64 maybe_change_configuration(struct cpu_hw_events *cpuc, u64 pcr)
658 658
659 enc = perf_event_get_enc(cpuc->events[i]); 659 enc = perf_event_get_enc(cpuc->events[i]);
660 pcr &= ~mask_for_index(idx); 660 pcr &= ~mask_for_index(idx);
661 pcr |= event_encoding(enc, idx); 661 if (hwc->state & PERF_HES_STOPPED)
662 pcr |= nop_for_index(idx);
663 else
664 pcr |= event_encoding(enc, idx);
662 } 665 }
663out: 666out:
664 return pcr; 667 return pcr;
665} 668}
666 669
667void hw_perf_enable(void) 670static void sparc_pmu_enable(struct pmu *pmu)
668{ 671{
669 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 672 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
670 u64 pcr; 673 u64 pcr;
@@ -691,7 +694,7 @@ void hw_perf_enable(void)
691 pcr_ops->write(cpuc->pcr); 694 pcr_ops->write(cpuc->pcr);
692} 695}
693 696
694void hw_perf_disable(void) 697static void sparc_pmu_disable(struct pmu *pmu)
695{ 698{
696 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 699 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
697 u64 val; 700 u64 val;
@@ -710,19 +713,65 @@ void hw_perf_disable(void)
710 pcr_ops->write(cpuc->pcr); 713 pcr_ops->write(cpuc->pcr);
711} 714}
712 715
713static void sparc_pmu_disable(struct perf_event *event) 716static int active_event_index(struct cpu_hw_events *cpuc,
717 struct perf_event *event)
718{
719 int i;
720
721 for (i = 0; i < cpuc->n_events; i++) {
722 if (cpuc->event[i] == event)
723 break;
724 }
725 BUG_ON(i == cpuc->n_events);
726 return cpuc->current_idx[i];
727}
728
729static void sparc_pmu_start(struct perf_event *event, int flags)
730{
731 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
732 int idx = active_event_index(cpuc, event);
733
734 if (flags & PERF_EF_RELOAD) {
735 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
736 sparc_perf_event_set_period(event, &event->hw, idx);
737 }
738
739 event->hw.state = 0;
740
741 sparc_pmu_enable_event(cpuc, &event->hw, idx);
742}
743
744static void sparc_pmu_stop(struct perf_event *event, int flags)
745{
746 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
747 int idx = active_event_index(cpuc, event);
748
749 if (!(event->hw.state & PERF_HES_STOPPED)) {
750 sparc_pmu_disable_event(cpuc, &event->hw, idx);
751 event->hw.state |= PERF_HES_STOPPED;
752 }
753
754 if (!(event->hw.state & PERF_HES_UPTODATE) && (flags & PERF_EF_UPDATE)) {
755 sparc_perf_event_update(event, &event->hw, idx);
756 event->hw.state |= PERF_HES_UPTODATE;
757 }
758}
759
760static void sparc_pmu_del(struct perf_event *event, int _flags)
714{ 761{
715 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 762 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
716 struct hw_perf_event *hwc = &event->hw;
717 unsigned long flags; 763 unsigned long flags;
718 int i; 764 int i;
719 765
720 local_irq_save(flags); 766 local_irq_save(flags);
721 perf_disable(); 767 perf_pmu_disable(event->pmu);
722 768
723 for (i = 0; i < cpuc->n_events; i++) { 769 for (i = 0; i < cpuc->n_events; i++) {
724 if (event == cpuc->event[i]) { 770 if (event == cpuc->event[i]) {
725 int idx = cpuc->current_idx[i]; 771 /* Absorb the final count and turn off the
772 * event.
773 */
774 sparc_pmu_stop(event, PERF_EF_UPDATE);
726 775
727 /* Shift remaining entries down into 776 /* Shift remaining entries down into
728 * the existing slot. 777 * the existing slot.
@@ -734,13 +783,6 @@ static void sparc_pmu_disable(struct perf_event *event)
734 cpuc->current_idx[i]; 783 cpuc->current_idx[i];
735 } 784 }
736 785
737 /* Absorb the final count and turn off the
738 * event.
739 */
740 sparc_pmu_disable_event(cpuc, hwc, idx);
741 barrier();
742 sparc_perf_event_update(event, hwc, idx);
743
744 perf_event_update_userpage(event); 786 perf_event_update_userpage(event);
745 787
746 cpuc->n_events--; 788 cpuc->n_events--;
@@ -748,23 +790,10 @@ static void sparc_pmu_disable(struct perf_event *event)
748 } 790 }
749 } 791 }
750 792
751 perf_enable(); 793 perf_pmu_enable(event->pmu);
752 local_irq_restore(flags); 794 local_irq_restore(flags);
753} 795}
754 796
755static int active_event_index(struct cpu_hw_events *cpuc,
756 struct perf_event *event)
757{
758 int i;
759
760 for (i = 0; i < cpuc->n_events; i++) {
761 if (cpuc->event[i] == event)
762 break;
763 }
764 BUG_ON(i == cpuc->n_events);
765 return cpuc->current_idx[i];
766}
767
768static void sparc_pmu_read(struct perf_event *event) 797static void sparc_pmu_read(struct perf_event *event)
769{ 798{
770 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 799 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
@@ -774,15 +803,6 @@ static void sparc_pmu_read(struct perf_event *event)
774 sparc_perf_event_update(event, hwc, idx); 803 sparc_perf_event_update(event, hwc, idx);
775} 804}
776 805
777static void sparc_pmu_unthrottle(struct perf_event *event)
778{
779 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
780 int idx = active_event_index(cpuc, event);
781 struct hw_perf_event *hwc = &event->hw;
782
783 sparc_pmu_enable_event(cpuc, hwc, idx);
784}
785
786static atomic_t active_events = ATOMIC_INIT(0); 806static atomic_t active_events = ATOMIC_INIT(0);
787static DEFINE_MUTEX(pmc_grab_mutex); 807static DEFINE_MUTEX(pmc_grab_mutex);
788 808
@@ -877,7 +897,7 @@ static int sparc_check_constraints(struct perf_event **evts,
877 if (!n_ev) 897 if (!n_ev)
878 return 0; 898 return 0;
879 899
880 if (n_ev > perf_max_events) 900 if (n_ev > MAX_HWEVENTS)
881 return -1; 901 return -1;
882 902
883 msk0 = perf_event_get_msk(events[0]); 903 msk0 = perf_event_get_msk(events[0]);
@@ -984,23 +1004,27 @@ static int collect_events(struct perf_event *group, int max_count,
984 return n; 1004 return n;
985} 1005}
986 1006
987static int sparc_pmu_enable(struct perf_event *event) 1007static int sparc_pmu_add(struct perf_event *event, int ef_flags)
988{ 1008{
989 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1009 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
990 int n0, ret = -EAGAIN; 1010 int n0, ret = -EAGAIN;
991 unsigned long flags; 1011 unsigned long flags;
992 1012
993 local_irq_save(flags); 1013 local_irq_save(flags);
994 perf_disable(); 1014 perf_pmu_disable(event->pmu);
995 1015
996 n0 = cpuc->n_events; 1016 n0 = cpuc->n_events;
997 if (n0 >= perf_max_events) 1017 if (n0 >= MAX_HWEVENTS)
998 goto out; 1018 goto out;
999 1019
1000 cpuc->event[n0] = event; 1020 cpuc->event[n0] = event;
1001 cpuc->events[n0] = event->hw.event_base; 1021 cpuc->events[n0] = event->hw.event_base;
1002 cpuc->current_idx[n0] = PIC_NO_INDEX; 1022 cpuc->current_idx[n0] = PIC_NO_INDEX;
1003 1023
1024 event->hw.state = PERF_HES_UPTODATE;
1025 if (!(ef_flags & PERF_EF_START))
1026 event->hw.state |= PERF_HES_STOPPED;
1027
1004 /* 1028 /*
1005 * If group events scheduling transaction was started, 1029 * If group events scheduling transaction was started,
1006 * skip the schedulability test here, it will be peformed 1030 * skip the schedulability test here, it will be peformed
@@ -1020,12 +1044,12 @@ nocheck:
1020 1044
1021 ret = 0; 1045 ret = 0;
1022out: 1046out:
1023 perf_enable(); 1047 perf_pmu_enable(event->pmu);
1024 local_irq_restore(flags); 1048 local_irq_restore(flags);
1025 return ret; 1049 return ret;
1026} 1050}
1027 1051
1028static int __hw_perf_event_init(struct perf_event *event) 1052static int sparc_pmu_event_init(struct perf_event *event)
1029{ 1053{
1030 struct perf_event_attr *attr = &event->attr; 1054 struct perf_event_attr *attr = &event->attr;
1031 struct perf_event *evts[MAX_HWEVENTS]; 1055 struct perf_event *evts[MAX_HWEVENTS];
@@ -1038,22 +1062,33 @@ static int __hw_perf_event_init(struct perf_event *event)
1038 if (atomic_read(&nmi_active) < 0) 1062 if (atomic_read(&nmi_active) < 0)
1039 return -ENODEV; 1063 return -ENODEV;
1040 1064
1041 pmap = NULL; 1065 switch (attr->type) {
1042 if (attr->type == PERF_TYPE_HARDWARE) { 1066 case PERF_TYPE_HARDWARE:
1043 if (attr->config >= sparc_pmu->max_events) 1067 if (attr->config >= sparc_pmu->max_events)
1044 return -EINVAL; 1068 return -EINVAL;
1045 pmap = sparc_pmu->event_map(attr->config); 1069 pmap = sparc_pmu->event_map(attr->config);
1046 } else if (attr->type == PERF_TYPE_HW_CACHE) { 1070 break;
1071
1072 case PERF_TYPE_HW_CACHE:
1047 pmap = sparc_map_cache_event(attr->config); 1073 pmap = sparc_map_cache_event(attr->config);
1048 if (IS_ERR(pmap)) 1074 if (IS_ERR(pmap))
1049 return PTR_ERR(pmap); 1075 return PTR_ERR(pmap);
1050 } else if (attr->type != PERF_TYPE_RAW) 1076 break;
1051 return -EOPNOTSUPP; 1077
1078 case PERF_TYPE_RAW:
1079 pmap = NULL;
1080 break;
1081
1082 default:
1083 return -ENOENT;
1084
1085 }
1052 1086
1053 if (pmap) { 1087 if (pmap) {
1054 hwc->event_base = perf_event_encode(pmap); 1088 hwc->event_base = perf_event_encode(pmap);
1055 } else { 1089 } else {
1056 /* User gives us "(encoding << 16) | pic_mask" for 1090 /*
1091 * User gives us "(encoding << 16) | pic_mask" for
1057 * PERF_TYPE_RAW events. 1092 * PERF_TYPE_RAW events.
1058 */ 1093 */
1059 hwc->event_base = attr->config; 1094 hwc->event_base = attr->config;
@@ -1071,7 +1106,7 @@ static int __hw_perf_event_init(struct perf_event *event)
1071 n = 0; 1106 n = 0;
1072 if (event->group_leader != event) { 1107 if (event->group_leader != event) {
1073 n = collect_events(event->group_leader, 1108 n = collect_events(event->group_leader,
1074 perf_max_events - 1, 1109 MAX_HWEVENTS - 1,
1075 evts, events, current_idx_dmy); 1110 evts, events, current_idx_dmy);
1076 if (n < 0) 1111 if (n < 0)
1077 return -EINVAL; 1112 return -EINVAL;
@@ -1107,10 +1142,11 @@ static int __hw_perf_event_init(struct perf_event *event)
1107 * Set the flag to make pmu::enable() not perform the 1142 * Set the flag to make pmu::enable() not perform the
1108 * schedulability test, it will be performed at commit time 1143 * schedulability test, it will be performed at commit time
1109 */ 1144 */
1110static void sparc_pmu_start_txn(const struct pmu *pmu) 1145static void sparc_pmu_start_txn(struct pmu *pmu)
1111{ 1146{
1112 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1147 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
1113 1148
1149 perf_pmu_disable(pmu);
1114 cpuhw->group_flag |= PERF_EVENT_TXN; 1150 cpuhw->group_flag |= PERF_EVENT_TXN;
1115} 1151}
1116 1152
@@ -1119,11 +1155,12 @@ static void sparc_pmu_start_txn(const struct pmu *pmu)
1119 * Clear the flag and pmu::enable() will perform the 1155 * Clear the flag and pmu::enable() will perform the
1120 * schedulability test. 1156 * schedulability test.
1121 */ 1157 */
1122static void sparc_pmu_cancel_txn(const struct pmu *pmu) 1158static void sparc_pmu_cancel_txn(struct pmu *pmu)
1123{ 1159{
1124 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1160 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
1125 1161
1126 cpuhw->group_flag &= ~PERF_EVENT_TXN; 1162 cpuhw->group_flag &= ~PERF_EVENT_TXN;
1163 perf_pmu_enable(pmu);
1127} 1164}
1128 1165
1129/* 1166/*
@@ -1131,7 +1168,7 @@ static void sparc_pmu_cancel_txn(const struct pmu *pmu)
1131 * Perform the group schedulability test as a whole 1168 * Perform the group schedulability test as a whole
1132 * Return 0 if success 1169 * Return 0 if success
1133 */ 1170 */
1134static int sparc_pmu_commit_txn(const struct pmu *pmu) 1171static int sparc_pmu_commit_txn(struct pmu *pmu)
1135{ 1172{
1136 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1173 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1137 int n; 1174 int n;
@@ -1147,28 +1184,24 @@ static int sparc_pmu_commit_txn(const struct pmu *pmu)
1147 return -EAGAIN; 1184 return -EAGAIN;
1148 1185
1149 cpuc->group_flag &= ~PERF_EVENT_TXN; 1186 cpuc->group_flag &= ~PERF_EVENT_TXN;
1187 perf_pmu_enable(pmu);
1150 return 0; 1188 return 0;
1151} 1189}
1152 1190
1153static const struct pmu pmu = { 1191static struct pmu pmu = {
1154 .enable = sparc_pmu_enable, 1192 .pmu_enable = sparc_pmu_enable,
1155 .disable = sparc_pmu_disable, 1193 .pmu_disable = sparc_pmu_disable,
1194 .event_init = sparc_pmu_event_init,
1195 .add = sparc_pmu_add,
1196 .del = sparc_pmu_del,
1197 .start = sparc_pmu_start,
1198 .stop = sparc_pmu_stop,
1156 .read = sparc_pmu_read, 1199 .read = sparc_pmu_read,
1157 .unthrottle = sparc_pmu_unthrottle,
1158 .start_txn = sparc_pmu_start_txn, 1200 .start_txn = sparc_pmu_start_txn,
1159 .cancel_txn = sparc_pmu_cancel_txn, 1201 .cancel_txn = sparc_pmu_cancel_txn,
1160 .commit_txn = sparc_pmu_commit_txn, 1202 .commit_txn = sparc_pmu_commit_txn,
1161}; 1203};
1162 1204
1163const struct pmu *hw_perf_event_init(struct perf_event *event)
1164{
1165 int err = __hw_perf_event_init(event);
1166
1167 if (err)
1168 return ERR_PTR(err);
1169 return &pmu;
1170}
1171
1172void perf_event_print_debug(void) 1205void perf_event_print_debug(void)
1173{ 1206{
1174 unsigned long flags; 1207 unsigned long flags;
@@ -1244,7 +1277,7 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
1244 continue; 1277 continue;
1245 1278
1246 if (perf_event_overflow(event, 1, &data, regs)) 1279 if (perf_event_overflow(event, 1, &data, regs))
1247 sparc_pmu_disable_event(cpuc, hwc, idx); 1280 sparc_pmu_stop(event, 0);
1248 } 1281 }
1249 1282
1250 return NOTIFY_STOP; 1283 return NOTIFY_STOP;
@@ -1285,28 +1318,21 @@ void __init init_hw_perf_events(void)
1285 1318
1286 pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type); 1319 pr_cont("Supported PMU type is '%s'\n", sparc_pmu_type);
1287 1320
1288 /* All sparc64 PMUs currently have 2 events. */ 1321 perf_pmu_register(&pmu);
1289 perf_max_events = 2;
1290
1291 register_die_notifier(&perf_event_nmi_notifier); 1322 register_die_notifier(&perf_event_nmi_notifier);
1292} 1323}
1293 1324
1294static inline void callchain_store(struct perf_callchain_entry *entry, u64 ip) 1325void perf_callchain_kernel(struct perf_callchain_entry *entry,
1295{ 1326 struct pt_regs *regs)
1296 if (entry->nr < PERF_MAX_STACK_DEPTH)
1297 entry->ip[entry->nr++] = ip;
1298}
1299
1300static void perf_callchain_kernel(struct pt_regs *regs,
1301 struct perf_callchain_entry *entry)
1302{ 1327{
1303 unsigned long ksp, fp; 1328 unsigned long ksp, fp;
1304#ifdef CONFIG_FUNCTION_GRAPH_TRACER 1329#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1305 int graph = 0; 1330 int graph = 0;
1306#endif 1331#endif
1307 1332
1308 callchain_store(entry, PERF_CONTEXT_KERNEL); 1333 stack_trace_flush();
1309 callchain_store(entry, regs->tpc); 1334
1335 perf_callchain_store(entry, regs->tpc);
1310 1336
1311 ksp = regs->u_regs[UREG_I6]; 1337 ksp = regs->u_regs[UREG_I6];
1312 fp = ksp + STACK_BIAS; 1338 fp = ksp + STACK_BIAS;
@@ -1330,13 +1356,13 @@ static void perf_callchain_kernel(struct pt_regs *regs,
1330 pc = sf->callers_pc; 1356 pc = sf->callers_pc;
1331 fp = (unsigned long)sf->fp + STACK_BIAS; 1357 fp = (unsigned long)sf->fp + STACK_BIAS;
1332 } 1358 }
1333 callchain_store(entry, pc); 1359 perf_callchain_store(entry, pc);
1334#ifdef CONFIG_FUNCTION_GRAPH_TRACER 1360#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1335 if ((pc + 8UL) == (unsigned long) &return_to_handler) { 1361 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
1336 int index = current->curr_ret_stack; 1362 int index = current->curr_ret_stack;
1337 if (current->ret_stack && index >= graph) { 1363 if (current->ret_stack && index >= graph) {
1338 pc = current->ret_stack[index - graph].ret; 1364 pc = current->ret_stack[index - graph].ret;
1339 callchain_store(entry, pc); 1365 perf_callchain_store(entry, pc);
1340 graph++; 1366 graph++;
1341 } 1367 }
1342 } 1368 }
@@ -1344,13 +1370,12 @@ static void perf_callchain_kernel(struct pt_regs *regs,
1344 } while (entry->nr < PERF_MAX_STACK_DEPTH); 1370 } while (entry->nr < PERF_MAX_STACK_DEPTH);
1345} 1371}
1346 1372
1347static void perf_callchain_user_64(struct pt_regs *regs, 1373static void perf_callchain_user_64(struct perf_callchain_entry *entry,
1348 struct perf_callchain_entry *entry) 1374 struct pt_regs *regs)
1349{ 1375{
1350 unsigned long ufp; 1376 unsigned long ufp;
1351 1377
1352 callchain_store(entry, PERF_CONTEXT_USER); 1378 perf_callchain_store(entry, regs->tpc);
1353 callchain_store(entry, regs->tpc);
1354 1379
1355 ufp = regs->u_regs[UREG_I6] + STACK_BIAS; 1380 ufp = regs->u_regs[UREG_I6] + STACK_BIAS;
1356 do { 1381 do {
@@ -1363,17 +1388,16 @@ static void perf_callchain_user_64(struct pt_regs *regs,
1363 1388
1364 pc = sf.callers_pc; 1389 pc = sf.callers_pc;
1365 ufp = (unsigned long)sf.fp + STACK_BIAS; 1390 ufp = (unsigned long)sf.fp + STACK_BIAS;
1366 callchain_store(entry, pc); 1391 perf_callchain_store(entry, pc);
1367 } while (entry->nr < PERF_MAX_STACK_DEPTH); 1392 } while (entry->nr < PERF_MAX_STACK_DEPTH);
1368} 1393}
1369 1394
1370static void perf_callchain_user_32(struct pt_regs *regs, 1395static void perf_callchain_user_32(struct perf_callchain_entry *entry,
1371 struct perf_callchain_entry *entry) 1396 struct pt_regs *regs)
1372{ 1397{
1373 unsigned long ufp; 1398 unsigned long ufp;
1374 1399
1375 callchain_store(entry, PERF_CONTEXT_USER); 1400 perf_callchain_store(entry, regs->tpc);
1376 callchain_store(entry, regs->tpc);
1377 1401
1378 ufp = regs->u_regs[UREG_I6] & 0xffffffffUL; 1402 ufp = regs->u_regs[UREG_I6] & 0xffffffffUL;
1379 do { 1403 do {
@@ -1386,34 +1410,16 @@ static void perf_callchain_user_32(struct pt_regs *regs,
1386 1410
1387 pc = sf.callers_pc; 1411 pc = sf.callers_pc;
1388 ufp = (unsigned long)sf.fp; 1412 ufp = (unsigned long)sf.fp;
1389 callchain_store(entry, pc); 1413 perf_callchain_store(entry, pc);
1390 } while (entry->nr < PERF_MAX_STACK_DEPTH); 1414 } while (entry->nr < PERF_MAX_STACK_DEPTH);
1391} 1415}
1392 1416
1393/* Like powerpc we can't get PMU interrupts within the PMU handler, 1417void
1394 * so no need for separate NMI and IRQ chains as on x86. 1418perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1395 */
1396static DEFINE_PER_CPU(struct perf_callchain_entry, callchain);
1397
1398struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
1399{ 1419{
1400 struct perf_callchain_entry *entry = &__get_cpu_var(callchain); 1420 flushw_user();
1401 1421 if (test_thread_flag(TIF_32BIT))
1402 entry->nr = 0; 1422 perf_callchain_user_32(entry, regs);
1403 if (!user_mode(regs)) { 1423 else
1404 stack_trace_flush(); 1424 perf_callchain_user_64(entry, regs);
1405 perf_callchain_kernel(regs, entry);
1406 if (current->mm)
1407 regs = task_pt_regs(current);
1408 else
1409 regs = NULL;
1410 }
1411 if (regs) {
1412 flushw_user();
1413 if (test_thread_flag(TIF_32BIT))
1414 perf_callchain_user_32(regs, entry);
1415 else
1416 perf_callchain_user_64(regs, entry);
1417 }
1418 return entry;
1419} 1425}
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index eeb04a782ec8..cf5fe1c0b024 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -4,12 +4,6 @@
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <asm/prom.h> 5#include <asm/prom.h>
6 6
7extern void * prom_early_alloc(unsigned long size);
8extern void irq_trans_init(struct device_node *dp);
9
10extern unsigned int prom_unique_id;
11
12extern char *build_path_component(struct device_node *dp);
13extern void of_console_init(void); 7extern void of_console_init(void);
14 8
15extern unsigned int prom_early_allocated; 9extern unsigned int prom_early_allocated;
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 1f830da2ddf2..ed25834328f4 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -20,14 +20,13 @@
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_pdt.h>
23#include <asm/prom.h> 24#include <asm/prom.h>
24#include <asm/oplib.h> 25#include <asm/oplib.h>
25#include <asm/leon.h> 26#include <asm/leon.h>
26 27
27#include "prom.h" 28#include "prom.h"
28 29
29void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp);
30
31struct device_node *of_console_device; 30struct device_node *of_console_device;
32EXPORT_SYMBOL(of_console_device); 31EXPORT_SYMBOL(of_console_device);
33 32
@@ -119,192 +118,47 @@ int of_find_in_proplist(const char *list, const char *match, int len)
119} 118}
120EXPORT_SYMBOL(of_find_in_proplist); 119EXPORT_SYMBOL(of_find_in_proplist);
121 120
122unsigned int prom_unique_id; 121/*
123 122 * SPARC32 and SPARC64's prom_nextprop() do things differently
124static struct property * __init build_one_prop(phandle node, char *prev, 123 * here, despite sharing the same interface. SPARC32 doesn't fill in 'buf',
125 char *special_name, 124 * returning NULL on an error. SPARC64 fills in 'buf', but sets it to an
126 void *special_val, 125 * empty string upon error.
127 int special_len) 126 */
127static int __init handle_nextprop_quirks(char *buf, const char *name)
128{ 128{
129 static struct property *tmp = NULL; 129 if (!name || strlen(name) == 0)
130 struct property *p; 130 return -1;
131 const char *name;
132
133 if (tmp) {
134 p = tmp;
135 memset(p, 0, sizeof(*p) + 32);
136 tmp = NULL;
137 } else {
138 p = prom_early_alloc(sizeof(struct property) + 32);
139 p->unique_id = prom_unique_id++;
140 }
141
142 p->name = (char *) (p + 1);
143 if (special_name) {
144 strcpy(p->name, special_name);
145 p->length = special_len;
146 p->value = prom_early_alloc(special_len);
147 memcpy(p->value, special_val, special_len);
148 } else {
149 if (prev == NULL) {
150 name = prom_firstprop(node, p->name);
151 } else {
152 name = prom_nextprop(node, prev, p->name);
153 }
154 131
155 if (!name || strlen(name) == 0) {
156 tmp = p;
157 return NULL;
158 }
159#ifdef CONFIG_SPARC32 132#ifdef CONFIG_SPARC32
160 strcpy(p->name, name); 133 strcpy(buf, name);
161#endif 134#endif
162 p->length = prom_getproplen(node, p->name); 135 return 0;
163 if (p->length <= 0) {
164 p->length = 0;
165 } else {
166 int len;
167
168 p->value = prom_early_alloc(p->length + 1);
169 len = prom_getproperty(node, p->name, p->value,
170 p->length);
171 if (len <= 0)
172 p->length = 0;
173 ((unsigned char *)p->value)[p->length] = '\0';
174 }
175 }
176 return p;
177}
178
179static struct property * __init build_prop_list(phandle node)
180{
181 struct property *head, *tail;
182
183 head = tail = build_one_prop(node, NULL,
184 ".node", &node, sizeof(node));
185
186 tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
187 tail = tail->next;
188 while(tail) {
189 tail->next = build_one_prop(node, tail->name,
190 NULL, NULL, 0);
191 tail = tail->next;
192 }
193
194 return head;
195}
196
197static char * __init get_one_property(phandle node, const char *name)
198{
199 char *buf = "<NULL>";
200 int len;
201
202 len = prom_getproplen(node, name);
203 if (len > 0) {
204 buf = prom_early_alloc(len);
205 len = prom_getproperty(node, name, buf, len);
206 }
207
208 return buf;
209}
210
211static struct device_node * __init prom_create_node(phandle node,
212 struct device_node *parent)
213{
214 struct device_node *dp;
215
216 if (!node)
217 return NULL;
218
219 dp = prom_early_alloc(sizeof(*dp));
220 dp->unique_id = prom_unique_id++;
221 dp->parent = parent;
222
223 kref_init(&dp->kref);
224
225 dp->name = get_one_property(node, "name");
226 dp->type = get_one_property(node, "device_type");
227 dp->phandle = node;
228
229 dp->properties = build_prop_list(node);
230
231 irq_trans_init(dp);
232
233 return dp;
234}
235
236char * __init build_full_name(struct device_node *dp)
237{
238 int len, ourlen, plen;
239 char *n;
240
241 plen = strlen(dp->parent->full_name);
242 ourlen = strlen(dp->path_component_name);
243 len = ourlen + plen + 2;
244
245 n = prom_early_alloc(len);
246 strcpy(n, dp->parent->full_name);
247 if (!of_node_is_root(dp->parent)) {
248 strcpy(n + plen, "/");
249 plen++;
250 }
251 strcpy(n + plen, dp->path_component_name);
252
253 return n;
254} 136}
255 137
256static struct device_node * __init prom_build_tree(struct device_node *parent, 138static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
257 phandle node,
258 struct device_node ***nextp)
259{ 139{
260 struct device_node *ret = NULL, *prev_sibling = NULL; 140 const char *name;
261 struct device_node *dp;
262
263 while (1) {
264 dp = prom_create_node(node, parent);
265 if (!dp)
266 break;
267
268 if (prev_sibling)
269 prev_sibling->sibling = dp;
270
271 if (!ret)
272 ret = dp;
273 prev_sibling = dp;
274
275 *(*nextp) = dp;
276 *nextp = &dp->allnext;
277
278 dp->path_component_name = build_path_component(dp);
279 dp->full_name = build_full_name(dp);
280
281 dp->child = prom_build_tree(dp, prom_getchild(node), nextp);
282
283 if (prom_build_more)
284 prom_build_more(dp, nextp);
285
286 node = prom_getsibling(node);
287 }
288 141
289 return ret; 142 buf[0] = '\0';
143 name = prom_nextprop(node, prev, buf);
144 return handle_nextprop_quirks(buf, name);
290} 145}
291 146
292unsigned int prom_early_allocated __initdata; 147unsigned int prom_early_allocated __initdata;
293 148
149static struct of_pdt_ops prom_sparc_ops __initdata = {
150 .nextprop = prom_common_nextprop,
151 .getproplen = prom_getproplen,
152 .getproperty = prom_getproperty,
153 .getchild = prom_getchild,
154 .getsibling = prom_getsibling,
155};
156
294void __init prom_build_devicetree(void) 157void __init prom_build_devicetree(void)
295{ 158{
296 struct device_node **nextp; 159 of_pdt_build_devicetree(prom_root_node, &prom_sparc_ops);
297
298 allnodes = prom_create_node(prom_root_node, NULL);
299 allnodes->path_component_name = "";
300 allnodes->full_name = "/";
301
302 nextp = &allnodes->allnext;
303 allnodes->child = prom_build_tree(allnodes,
304 prom_getchild(allnodes->phandle),
305 &nextp);
306 of_console_init(); 160 of_console_init();
307 161
308 printk("PROM: Built device tree with %u bytes of memory.\n", 162 pr_info("PROM: Built device tree with %u bytes of memory.\n",
309 prom_early_allocated); 163 prom_early_allocated);
310} 164}
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 5f72de67588b..29bafe051bb1 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -315,7 +315,7 @@ void __init setup_arch(char **cmdline_p)
315 315
316#ifdef CONFIG_IP_PNP 316#ifdef CONFIG_IP_PNP
317 if (!ic_set_manually) { 317 if (!ic_set_manually) {
318 int chosen = prom_finddevice ("/chosen"); 318 phandle chosen = prom_finddevice("/chosen");
319 u32 cl, sv, gw; 319 u32 cl, sv, gw;
320 320
321 cl = prom_getintdefault (chosen, "client-ip", 0); 321 cl = prom_getintdefault (chosen, "client-ip", 0);
diff --git a/arch/sparc/kernel/starfire.c b/arch/sparc/kernel/starfire.c
index 060d0f3a6151..a4446c0fb7a1 100644
--- a/arch/sparc/kernel/starfire.c
+++ b/arch/sparc/kernel/starfire.c
@@ -23,7 +23,7 @@ int this_is_starfire = 0;
23 23
24void check_if_starfire(void) 24void check_if_starfire(void)
25{ 25{
26 int ssnode = prom_finddevice("/ssp-serial"); 26 phandle ssnode = prom_finddevice("/ssp-serial");
27 if (ssnode != 0 && ssnode != -1) 27 if (ssnode != 0 && ssnode != -1)
28 this_is_starfire = 1; 28 this_is_starfire = 1;
29} 29}
diff --git a/arch/sparc/kernel/tadpole.c b/arch/sparc/kernel/tadpole.c
index f476a5f4af6a..9aba8bd5a78b 100644
--- a/arch/sparc/kernel/tadpole.c
+++ b/arch/sparc/kernel/tadpole.c
@@ -100,7 +100,7 @@ static void swift_clockstop(void)
100 100
101void __init clock_stop_probe(void) 101void __init clock_stop_probe(void)
102{ 102{
103 unsigned int node, clk_nd; 103 phandle node, clk_nd;
104 char name[20]; 104 char name[20];
105 105
106 prom_getstring(prom_root_node, "name", name, sizeof(name)); 106 prom_getstring(prom_root_node, "name", name, sizeof(name));
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index f0434513df15..2f6ae1d1fb6b 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -88,7 +88,7 @@ static void __init read_obp_memory(const char *property,
88 struct linux_prom64_registers *regs, 88 struct linux_prom64_registers *regs,
89 int *num_ents) 89 int *num_ents)
90{ 90{
91 int node = prom_finddevice("/memory"); 91 phandle node = prom_finddevice("/memory");
92 int prop_size = prom_getproplen(node, property); 92 int prop_size = prom_getproplen(node, property);
93 int ents, ret, i; 93 int ents, ret, i;
94 94
@@ -785,8 +785,7 @@ static int find_node(unsigned long addr)
785 return -1; 785 return -1;
786} 786}
787 787
788static unsigned long long nid_range(unsigned long long start, 788u64 memblock_nid_range(u64 start, u64 end, int *nid)
789 unsigned long long end, int *nid)
790{ 789{
791 *nid = find_node(start); 790 *nid = find_node(start);
792 start += PAGE_SIZE; 791 start += PAGE_SIZE;
@@ -804,8 +803,7 @@ static unsigned long long nid_range(unsigned long long start,
804 return start; 803 return start;
805} 804}
806#else 805#else
807static unsigned long long nid_range(unsigned long long start, 806u64 memblock_nid_range(u64 start, u64 end, int *nid)
808 unsigned long long end, int *nid)
809{ 807{
810 *nid = 0; 808 *nid = 0;
811 return end; 809 return end;
@@ -822,8 +820,7 @@ static void __init allocate_node_data(int nid)
822 struct pglist_data *p; 820 struct pglist_data *p;
823 821
824#ifdef CONFIG_NEED_MULTIPLE_NODES 822#ifdef CONFIG_NEED_MULTIPLE_NODES
825 paddr = memblock_alloc_nid(sizeof(struct pglist_data), 823 paddr = memblock_alloc_try_nid(sizeof(struct pglist_data), SMP_CACHE_BYTES, nid);
826 SMP_CACHE_BYTES, nid, nid_range);
827 if (!paddr) { 824 if (!paddr) {
828 prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); 825 prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid);
829 prom_halt(); 826 prom_halt();
@@ -843,8 +840,7 @@ static void __init allocate_node_data(int nid)
843 if (p->node_spanned_pages) { 840 if (p->node_spanned_pages) {
844 num_pages = bootmem_bootmap_pages(p->node_spanned_pages); 841 num_pages = bootmem_bootmap_pages(p->node_spanned_pages);
845 842
846 paddr = memblock_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid, 843 paddr = memblock_alloc_try_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid);
847 nid_range);
848 if (!paddr) { 844 if (!paddr) {
849 prom_printf("Cannot allocate bootmap for nid[%d]\n", 845 prom_printf("Cannot allocate bootmap for nid[%d]\n",
850 nid); 846 nid);
@@ -972,19 +968,19 @@ int of_node_to_nid(struct device_node *dp)
972 968
973static void __init add_node_ranges(void) 969static void __init add_node_ranges(void)
974{ 970{
975 int i; 971 struct memblock_region *reg;
976 972
977 for (i = 0; i < memblock.memory.cnt; i++) { 973 for_each_memblock(memory, reg) {
978 unsigned long size = memblock_size_bytes(&memblock.memory, i); 974 unsigned long size = reg->size;
979 unsigned long start, end; 975 unsigned long start, end;
980 976
981 start = memblock.memory.region[i].base; 977 start = reg->base;
982 end = start + size; 978 end = start + size;
983 while (start < end) { 979 while (start < end) {
984 unsigned long this_end; 980 unsigned long this_end;
985 int nid; 981 int nid;
986 982
987 this_end = nid_range(start, end, &nid); 983 this_end = memblock_nid_range(start, end, &nid);
988 984
989 numadbg("Adding active range nid[%d] " 985 numadbg("Adding active range nid[%d] "
990 "start[%lx] end[%lx]\n", 986 "start[%lx] end[%lx]\n",
@@ -1281,7 +1277,7 @@ static void __init bootmem_init_nonnuma(void)
1281{ 1277{
1282 unsigned long top_of_ram = memblock_end_of_DRAM(); 1278 unsigned long top_of_ram = memblock_end_of_DRAM();
1283 unsigned long total_ram = memblock_phys_mem_size(); 1279 unsigned long total_ram = memblock_phys_mem_size();
1284 unsigned int i; 1280 struct memblock_region *reg;
1285 1281
1286 numadbg("bootmem_init_nonnuma()\n"); 1282 numadbg("bootmem_init_nonnuma()\n");
1287 1283
@@ -1292,15 +1288,14 @@ static void __init bootmem_init_nonnuma(void)
1292 1288
1293 init_node_masks_nonnuma(); 1289 init_node_masks_nonnuma();
1294 1290
1295 for (i = 0; i < memblock.memory.cnt; i++) { 1291 for_each_memblock(memory, reg) {
1296 unsigned long size = memblock_size_bytes(&memblock.memory, i);
1297 unsigned long start_pfn, end_pfn; 1292 unsigned long start_pfn, end_pfn;
1298 1293
1299 if (!size) 1294 if (!reg->size)
1300 continue; 1295 continue;
1301 1296
1302 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT; 1297 start_pfn = memblock_region_memory_base_pfn(reg);
1303 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i); 1298 end_pfn = memblock_region_memory_end_pfn(reg);
1304 add_active_range(0, start_pfn, end_pfn); 1299 add_active_range(0, start_pfn, end_pfn);
1305 } 1300 }
1306 1301
@@ -1318,7 +1313,7 @@ static void __init reserve_range_in_node(int nid, unsigned long start,
1318 unsigned long this_end; 1313 unsigned long this_end;
1319 int n; 1314 int n;
1320 1315
1321 this_end = nid_range(start, end, &n); 1316 this_end = memblock_nid_range(start, end, &n);
1322 if (n == nid) { 1317 if (n == nid) {
1323 numadbg(" MATCH reserving range [%lx:%lx]\n", 1318 numadbg(" MATCH reserving range [%lx:%lx]\n",
1324 start, this_end); 1319 start, this_end);
@@ -1334,17 +1329,12 @@ static void __init reserve_range_in_node(int nid, unsigned long start,
1334 1329
1335static void __init trim_reserved_in_node(int nid) 1330static void __init trim_reserved_in_node(int nid)
1336{ 1331{
1337 int i; 1332 struct memblock_region *reg;
1338 1333
1339 numadbg(" trim_reserved_in_node(%d)\n", nid); 1334 numadbg(" trim_reserved_in_node(%d)\n", nid);
1340 1335
1341 for (i = 0; i < memblock.reserved.cnt; i++) { 1336 for_each_memblock(reserved, reg)
1342 unsigned long start = memblock.reserved.region[i].base; 1337 reserve_range_in_node(nid, reg->base, reg->base + reg->size);
1343 unsigned long size = memblock_size_bytes(&memblock.reserved, i);
1344 unsigned long end = start + size;
1345
1346 reserve_range_in_node(nid, start, end);
1347 }
1348} 1338}
1349 1339
1350static void __init bootmem_init_one_node(int nid) 1340static void __init bootmem_init_one_node(int nid)
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index b0b43aa5e45a..92319aa8b662 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -1262,7 +1262,8 @@ extern unsigned long bootmem_init(unsigned long *pages_avail);
1262 1262
1263void __init srmmu_paging_init(void) 1263void __init srmmu_paging_init(void)
1264{ 1264{
1265 int i, cpunode; 1265 int i;
1266 phandle cpunode;
1266 char node_str[128]; 1267 char node_str[128];
1267 pgd_t *pgd; 1268 pgd_t *pgd;
1268 pmd_t *pmd; 1269 pmd_t *pmd;
@@ -1398,7 +1399,8 @@ static void __init srmmu_is_bad(void)
1398 1399
1399static void __init init_vac_layout(void) 1400static void __init init_vac_layout(void)
1400{ 1401{
1401 int nd, cache_lines; 1402 phandle nd;
1403 int cache_lines;
1402 char node_str[128]; 1404 char node_str[128];
1403#ifdef CONFIG_SMP 1405#ifdef CONFIG_SMP
1404 int cpu = 0; 1406 int cpu = 0;
@@ -2082,7 +2084,7 @@ static void __init get_srmmu_type(void)
2082 2084
2083 /* Next check for Fujitsu Swift. */ 2085 /* Next check for Fujitsu Swift. */
2084 if(psr_typ == 0 && psr_vers == 4) { 2086 if(psr_typ == 0 && psr_vers == 4) {
2085 int cpunode; 2087 phandle cpunode;
2086 char node_str[128]; 2088 char node_str[128];
2087 2089
2088 /* Look if it is not a TurboSparc emulating Swift... */ 2090 /* Look if it is not a TurboSparc emulating Swift... */
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index 4289f90f8697..ddd0d86e508e 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -420,7 +420,7 @@ volatile unsigned long __iomem *sun4c_memerr_reg = NULL;
420 420
421void __init sun4c_probe_memerr_reg(void) 421void __init sun4c_probe_memerr_reg(void)
422{ 422{
423 int node; 423 phandle node;
424 struct linux_prom_registers regs[1]; 424 struct linux_prom_registers regs[1];
425 425
426 node = prom_getchild(prom_root_node); 426 node = prom_getchild(prom_root_node);
diff --git a/arch/sparc/prom/init_32.c b/arch/sparc/prom/init_32.c
index ccb36c7f9b8c..d342dba4dd54 100644
--- a/arch/sparc/prom/init_32.c
+++ b/arch/sparc/prom/init_32.c
@@ -20,7 +20,7 @@ enum prom_major_version prom_vers;
20unsigned int prom_rev, prom_prev; 20unsigned int prom_rev, prom_prev;
21 21
22/* The root node of the prom device tree. */ 22/* The root node of the prom device tree. */
23int prom_root_node; 23phandle prom_root_node;
24EXPORT_SYMBOL(prom_root_node); 24EXPORT_SYMBOL(prom_root_node);
25 25
26/* Pointer to the device tree operations structure. */ 26/* Pointer to the device tree operations structure. */
diff --git a/arch/sparc/prom/init_64.c b/arch/sparc/prom/init_64.c
index 7b00f89490a4..3ff911e7d25b 100644
--- a/arch/sparc/prom/init_64.c
+++ b/arch/sparc/prom/init_64.c
@@ -19,7 +19,7 @@ char prom_version[80];
19 19
20/* The root node of the prom device tree. */ 20/* The root node of the prom device tree. */
21int prom_stdin, prom_stdout; 21int prom_stdin, prom_stdout;
22int prom_chosen_node; 22phandle prom_chosen_node;
23 23
24/* You must call prom_init() before you attempt to use any of the 24/* You must call prom_init() before you attempt to use any of the
25 * routines in the prom library. It returns 0 on success, 1 on 25 * routines in the prom library. It returns 0 on success, 1 on
@@ -30,7 +30,7 @@ extern void prom_cif_init(void *, void *);
30 30
31void __init prom_init(void *cif_handler, void *cif_stack) 31void __init prom_init(void *cif_handler, void *cif_stack)
32{ 32{
33 int node; 33 phandle node;
34 34
35 prom_cif_init(cif_handler, cif_stack); 35 prom_cif_init(cif_handler, cif_stack);
36 36
diff --git a/arch/sparc/prom/memory.c b/arch/sparc/prom/memory.c
index fac7899a29c3..3f263a64857d 100644
--- a/arch/sparc/prom/memory.c
+++ b/arch/sparc/prom/memory.c
@@ -31,7 +31,8 @@ static int __init prom_meminit_v0(void)
31static int __init prom_meminit_v2(void) 31static int __init prom_meminit_v2(void)
32{ 32{
33 struct linux_prom_registers reg[64]; 33 struct linux_prom_registers reg[64];
34 int node, size, num_ents, i; 34 phandle node;
35 int size, num_ents, i;
35 36
36 node = prom_searchsiblings(prom_getchild(prom_root_node), "memory"); 37 node = prom_searchsiblings(prom_getchild(prom_root_node), "memory");
37 size = prom_getproperty(node, "available", (char *) reg, sizeof(reg)); 38 size = prom_getproperty(node, "available", (char *) reg, sizeof(reg));
diff --git a/arch/sparc/prom/misc_64.c b/arch/sparc/prom/misc_64.c
index 6cb1581d6aef..d24bc44e361e 100644
--- a/arch/sparc/prom/misc_64.c
+++ b/arch/sparc/prom/misc_64.c
@@ -183,7 +183,8 @@ unsigned char prom_get_idprom(char *idbuf, int num_bytes)
183 183
184int prom_get_mmu_ihandle(void) 184int prom_get_mmu_ihandle(void)
185{ 185{
186 int node, ret; 186 phandle node;
187 int ret;
187 188
188 if (prom_mmu_ihandle_cache != 0) 189 if (prom_mmu_ihandle_cache != 0)
189 return prom_mmu_ihandle_cache; 190 return prom_mmu_ihandle_cache;
@@ -201,7 +202,8 @@ int prom_get_mmu_ihandle(void)
201static int prom_get_memory_ihandle(void) 202static int prom_get_memory_ihandle(void)
202{ 203{
203 static int memory_ihandle_cache; 204 static int memory_ihandle_cache;
204 int node, ret; 205 phandle node;
206 int ret;
205 207
206 if (memory_ihandle_cache != 0) 208 if (memory_ihandle_cache != 0)
207 return memory_ihandle_cache; 209 return memory_ihandle_cache;
diff --git a/arch/sparc/prom/p1275.c b/arch/sparc/prom/p1275.c
index fa6e4e219b9c..d9850c2b9bf2 100644
--- a/arch/sparc/prom/p1275.c
+++ b/arch/sparc/prom/p1275.c
@@ -39,7 +39,7 @@ void p1275_cmd_direct(unsigned long *args)
39 unsigned long flags; 39 unsigned long flags;
40 40
41 raw_local_save_flags(flags); 41 raw_local_save_flags(flags);
42 raw_local_irq_restore(PIL_NMI); 42 raw_local_irq_restore((unsigned long)PIL_NMI);
43 raw_spin_lock(&prom_entry_lock); 43 raw_spin_lock(&prom_entry_lock);
44 44
45 prom_world(1); 45 prom_world(1);
diff --git a/arch/sparc/prom/ranges.c b/arch/sparc/prom/ranges.c
index aeff43e44e45..541fc829c207 100644
--- a/arch/sparc/prom/ranges.c
+++ b/arch/sparc/prom/ranges.c
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(prom_apply_obio_ranges);
68 68
69void __init prom_ranges_init(void) 69void __init prom_ranges_init(void)
70{ 70{
71 int node, obio_node; 71 phandle node, obio_node;
72 int success; 72 int success;
73 73
74 num_obio_ranges = 0; 74 num_obio_ranges = 0;
@@ -89,8 +89,8 @@ void __init prom_ranges_init(void)
89 prom_printf("PROMLIB: obio_ranges %d\n", num_obio_ranges); 89 prom_printf("PROMLIB: obio_ranges %d\n", num_obio_ranges);
90} 90}
91 91
92void 92void prom_apply_generic_ranges(phandle node, phandle parent,
93prom_apply_generic_ranges (int node, int parent, struct linux_prom_registers *regs, int nregs) 93 struct linux_prom_registers *regs, int nregs)
94{ 94{
95 int success; 95 int success;
96 int num_ranges; 96 int num_ranges;
diff --git a/arch/sparc/prom/tree_32.c b/arch/sparc/prom/tree_32.c
index b21592f8e3fe..63e08e149774 100644
--- a/arch/sparc/prom/tree_32.c
+++ b/arch/sparc/prom/tree_32.c
@@ -20,10 +20,10 @@ extern void restore_current(void);
20static char promlib_buf[128]; 20static char promlib_buf[128];
21 21
22/* Internal version of prom_getchild that does not alter return values. */ 22/* Internal version of prom_getchild that does not alter return values. */
23int __prom_getchild(int node) 23phandle __prom_getchild(phandle node)
24{ 24{
25 unsigned long flags; 25 unsigned long flags;
26 int cnode; 26 phandle cnode;
27 27
28 spin_lock_irqsave(&prom_lock, flags); 28 spin_lock_irqsave(&prom_lock, flags);
29 cnode = prom_nodeops->no_child(node); 29 cnode = prom_nodeops->no_child(node);
@@ -36,9 +36,9 @@ int __prom_getchild(int node)
36/* Return the child of node 'node' or zero if no this node has no 36/* Return the child of node 'node' or zero if no this node has no
37 * direct descendent. 37 * direct descendent.
38 */ 38 */
39int prom_getchild(int node) 39phandle prom_getchild(phandle node)
40{ 40{
41 int cnode; 41 phandle cnode;
42 42
43 if (node == -1) 43 if (node == -1)
44 return 0; 44 return 0;
@@ -52,10 +52,10 @@ int prom_getchild(int node)
52EXPORT_SYMBOL(prom_getchild); 52EXPORT_SYMBOL(prom_getchild);
53 53
54/* Internal version of prom_getsibling that does not alter return values. */ 54/* Internal version of prom_getsibling that does not alter return values. */
55int __prom_getsibling(int node) 55phandle __prom_getsibling(phandle node)
56{ 56{
57 unsigned long flags; 57 unsigned long flags;
58 int cnode; 58 phandle cnode;
59 59
60 spin_lock_irqsave(&prom_lock, flags); 60 spin_lock_irqsave(&prom_lock, flags);
61 cnode = prom_nodeops->no_nextnode(node); 61 cnode = prom_nodeops->no_nextnode(node);
@@ -68,9 +68,9 @@ int __prom_getsibling(int node)
68/* Return the next sibling of node 'node' or zero if no more siblings 68/* Return the next sibling of node 'node' or zero if no more siblings
69 * at this level of depth in the tree. 69 * at this level of depth in the tree.
70 */ 70 */
71int prom_getsibling(int node) 71phandle prom_getsibling(phandle node)
72{ 72{
73 int sibnode; 73 phandle sibnode;
74 74
75 if (node == -1) 75 if (node == -1)
76 return 0; 76 return 0;
@@ -86,7 +86,7 @@ EXPORT_SYMBOL(prom_getsibling);
86/* Return the length in bytes of property 'prop' at node 'node'. 86/* Return the length in bytes of property 'prop' at node 'node'.
87 * Return -1 on error. 87 * Return -1 on error.
88 */ 88 */
89int prom_getproplen(int node, const char *prop) 89int prom_getproplen(phandle node, const char *prop)
90{ 90{
91 int ret; 91 int ret;
92 unsigned long flags; 92 unsigned long flags;
@@ -106,7 +106,7 @@ EXPORT_SYMBOL(prom_getproplen);
106 * 'buffer' which has a size of 'bufsize'. If the acquisition 106 * 'buffer' which has a size of 'bufsize'. If the acquisition
107 * was successful the length will be returned, else -1 is returned. 107 * was successful the length will be returned, else -1 is returned.
108 */ 108 */
109int prom_getproperty(int node, const char *prop, char *buffer, int bufsize) 109int prom_getproperty(phandle node, const char *prop, char *buffer, int bufsize)
110{ 110{
111 int plen, ret; 111 int plen, ret;
112 unsigned long flags; 112 unsigned long flags;
@@ -126,7 +126,7 @@ EXPORT_SYMBOL(prom_getproperty);
126/* Acquire an integer property and return its value. Returns -1 126/* Acquire an integer property and return its value. Returns -1
127 * on failure. 127 * on failure.
128 */ 128 */
129int prom_getint(int node, char *prop) 129int prom_getint(phandle node, char *prop)
130{ 130{
131 static int intprop; 131 static int intprop;
132 132
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(prom_getint);
140/* Acquire an integer property, upon error return the passed default 140/* Acquire an integer property, upon error return the passed default
141 * integer. 141 * integer.
142 */ 142 */
143int prom_getintdefault(int node, char *property, int deflt) 143int prom_getintdefault(phandle node, char *property, int deflt)
144{ 144{
145 int retval; 145 int retval;
146 146
@@ -152,7 +152,7 @@ int prom_getintdefault(int node, char *property, int deflt)
152EXPORT_SYMBOL(prom_getintdefault); 152EXPORT_SYMBOL(prom_getintdefault);
153 153
154/* Acquire a boolean property, 1=TRUE 0=FALSE. */ 154/* Acquire a boolean property, 1=TRUE 0=FALSE. */
155int prom_getbool(int node, char *prop) 155int prom_getbool(phandle node, char *prop)
156{ 156{
157 int retval; 157 int retval;
158 158
@@ -166,7 +166,7 @@ EXPORT_SYMBOL(prom_getbool);
166 * string on error. The char pointer is the user supplied string 166 * string on error. The char pointer is the user supplied string
167 * buffer. 167 * buffer.
168 */ 168 */
169void prom_getstring(int node, char *prop, char *user_buf, int ubuf_size) 169void prom_getstring(phandle node, char *prop, char *user_buf, int ubuf_size)
170{ 170{
171 int len; 171 int len;
172 172
@@ -180,7 +180,7 @@ EXPORT_SYMBOL(prom_getstring);
180/* Does the device at node 'node' have name 'name'? 180/* Does the device at node 'node' have name 'name'?
181 * YES = 1 NO = 0 181 * YES = 1 NO = 0
182 */ 182 */
183int prom_nodematch(int node, char *name) 183int prom_nodematch(phandle node, char *name)
184{ 184{
185 int error; 185 int error;
186 186
@@ -194,10 +194,11 @@ int prom_nodematch(int node, char *name)
194/* Search siblings at 'node_start' for a node with name 194/* Search siblings at 'node_start' for a node with name
195 * 'nodename'. Return node if successful, zero if not. 195 * 'nodename'. Return node if successful, zero if not.
196 */ 196 */
197int prom_searchsiblings(int node_start, char *nodename) 197phandle prom_searchsiblings(phandle node_start, char *nodename)
198{ 198{
199 199
200 int thisnode, error; 200 phandle thisnode;
201 int error;
201 202
202 for(thisnode = node_start; thisnode; 203 for(thisnode = node_start; thisnode;
203 thisnode=prom_getsibling(thisnode)) { 204 thisnode=prom_getsibling(thisnode)) {
@@ -213,7 +214,7 @@ int prom_searchsiblings(int node_start, char *nodename)
213EXPORT_SYMBOL(prom_searchsiblings); 214EXPORT_SYMBOL(prom_searchsiblings);
214 215
215/* Interal version of nextprop that does not alter return values. */ 216/* Interal version of nextprop that does not alter return values. */
216char * __prom_nextprop(int node, char * oprop) 217char *__prom_nextprop(phandle node, char * oprop)
217{ 218{
218 unsigned long flags; 219 unsigned long flags;
219 char *prop; 220 char *prop;
@@ -228,7 +229,7 @@ char * __prom_nextprop(int node, char * oprop)
228 229
229/* Return the first property name for node 'node'. */ 230/* Return the first property name for node 'node'. */
230/* buffer is unused argument, but as v9 uses it, we need to have the same interface */ 231/* buffer is unused argument, but as v9 uses it, we need to have the same interface */
231char * prom_firstprop(int node, char *bufer) 232char *prom_firstprop(phandle node, char *bufer)
232{ 233{
233 if (node == 0 || node == -1) 234 if (node == 0 || node == -1)
234 return ""; 235 return "";
@@ -241,7 +242,7 @@ EXPORT_SYMBOL(prom_firstprop);
241 * at node 'node' . Returns empty string if no more 242 * at node 'node' . Returns empty string if no more
242 * property types for this node. 243 * property types for this node.
243 */ 244 */
244char * prom_nextprop(int node, char *oprop, char *buffer) 245char *prom_nextprop(phandle node, char *oprop, char *buffer)
245{ 246{
246 if (node == 0 || node == -1) 247 if (node == 0 || node == -1)
247 return ""; 248 return "";
@@ -250,11 +251,11 @@ char * prom_nextprop(int node, char *oprop, char *buffer)
250} 251}
251EXPORT_SYMBOL(prom_nextprop); 252EXPORT_SYMBOL(prom_nextprop);
252 253
253int prom_finddevice(char *name) 254phandle prom_finddevice(char *name)
254{ 255{
255 char nbuf[128]; 256 char nbuf[128];
256 char *s = name, *d; 257 char *s = name, *d;
257 int node = prom_root_node, node2; 258 phandle node = prom_root_node, node2;
258 unsigned int which_io, phys_addr; 259 unsigned int which_io, phys_addr;
259 struct linux_prom_registers reg[PROMREG_MAX]; 260 struct linux_prom_registers reg[PROMREG_MAX];
260 261
@@ -298,7 +299,7 @@ int prom_finddevice(char *name)
298} 299}
299EXPORT_SYMBOL(prom_finddevice); 300EXPORT_SYMBOL(prom_finddevice);
300 301
301int prom_node_has_property(int node, char *prop) 302int prom_node_has_property(phandle node, char *prop)
302{ 303{
303 char *current_property = ""; 304 char *current_property = "";
304 305
@@ -314,7 +315,7 @@ EXPORT_SYMBOL(prom_node_has_property);
314/* Set property 'pname' at node 'node' to value 'value' which has a length 315/* Set property 'pname' at node 'node' to value 'value' which has a length
315 * of 'size' bytes. Return the number of bytes the prom accepted. 316 * of 'size' bytes. Return the number of bytes the prom accepted.
316 */ 317 */
317int prom_setprop(int node, const char *pname, char *value, int size) 318int prom_setprop(phandle node, const char *pname, char *value, int size)
318{ 319{
319 unsigned long flags; 320 unsigned long flags;
320 int ret; 321 int ret;
@@ -329,9 +330,9 @@ int prom_setprop(int node, const char *pname, char *value, int size)
329} 330}
330EXPORT_SYMBOL(prom_setprop); 331EXPORT_SYMBOL(prom_setprop);
331 332
332int prom_inst2pkg(int inst) 333phandle prom_inst2pkg(int inst)
333{ 334{
334 int node; 335 phandle node;
335 unsigned long flags; 336 unsigned long flags;
336 337
337 spin_lock_irqsave(&prom_lock, flags); 338 spin_lock_irqsave(&prom_lock, flags);
@@ -345,9 +346,10 @@ int prom_inst2pkg(int inst)
345/* Return 'node' assigned to a particular prom 'path' 346/* Return 'node' assigned to a particular prom 'path'
346 * FIXME: Should work for v0 as well 347 * FIXME: Should work for v0 as well
347 */ 348 */
348int prom_pathtoinode(char *path) 349phandle prom_pathtoinode(char *path)
349{ 350{
350 int node, inst; 351 phandle node;
352 int inst;
351 353
352 inst = prom_devopen (path); 354 inst = prom_devopen (path);
353 if (inst == -1) return 0; 355 if (inst == -1) return 0;
diff --git a/arch/sparc/prom/tree_64.c b/arch/sparc/prom/tree_64.c
index 9d3f9137a43a..691be68932f8 100644
--- a/arch/sparc/prom/tree_64.c
+++ b/arch/sparc/prom/tree_64.c
@@ -16,7 +16,7 @@
16#include <asm/oplib.h> 16#include <asm/oplib.h>
17#include <asm/ldc.h> 17#include <asm/ldc.h>
18 18
19static int prom_node_to_node(const char *type, int node) 19static phandle prom_node_to_node(const char *type, phandle node)
20{ 20{
21 unsigned long args[5]; 21 unsigned long args[5];
22 22
@@ -28,20 +28,20 @@ static int prom_node_to_node(const char *type, int node)
28 28
29 p1275_cmd_direct(args); 29 p1275_cmd_direct(args);
30 30
31 return (int) args[4]; 31 return (phandle) args[4];
32} 32}
33 33
34/* Return the child of node 'node' or zero if no this node has no 34/* Return the child of node 'node' or zero if no this node has no
35 * direct descendent. 35 * direct descendent.
36 */ 36 */
37inline int __prom_getchild(int node) 37inline phandle __prom_getchild(phandle node)
38{ 38{
39 return prom_node_to_node("child", node); 39 return prom_node_to_node("child", node);
40} 40}
41 41
42inline int prom_getchild(int node) 42inline phandle prom_getchild(phandle node)
43{ 43{
44 int cnode; 44 phandle cnode;
45 45
46 if (node == -1) 46 if (node == -1)
47 return 0; 47 return 0;
@@ -52,9 +52,9 @@ inline int prom_getchild(int node)
52} 52}
53EXPORT_SYMBOL(prom_getchild); 53EXPORT_SYMBOL(prom_getchild);
54 54
55inline int prom_getparent(int node) 55inline phandle prom_getparent(phandle node)
56{ 56{
57 int cnode; 57 phandle cnode;
58 58
59 if (node == -1) 59 if (node == -1)
60 return 0; 60 return 0;
@@ -67,14 +67,14 @@ inline int prom_getparent(int node)
67/* Return the next sibling of node 'node' or zero if no more siblings 67/* Return the next sibling of node 'node' or zero if no more siblings
68 * at this level of depth in the tree. 68 * at this level of depth in the tree.
69 */ 69 */
70inline int __prom_getsibling(int node) 70inline phandle __prom_getsibling(phandle node)
71{ 71{
72 return prom_node_to_node(prom_peer_name, node); 72 return prom_node_to_node(prom_peer_name, node);
73} 73}
74 74
75inline int prom_getsibling(int node) 75inline phandle prom_getsibling(phandle node)
76{ 76{
77 int sibnode; 77 phandle sibnode;
78 78
79 if (node == -1) 79 if (node == -1)
80 return 0; 80 return 0;
@@ -89,7 +89,7 @@ EXPORT_SYMBOL(prom_getsibling);
89/* Return the length in bytes of property 'prop' at node 'node'. 89/* Return the length in bytes of property 'prop' at node 'node'.
90 * Return -1 on error. 90 * Return -1 on error.
91 */ 91 */
92inline int prom_getproplen(int node, const char *prop) 92inline int prom_getproplen(phandle node, const char *prop)
93{ 93{
94 unsigned long args[6]; 94 unsigned long args[6];
95 95
@@ -113,7 +113,7 @@ EXPORT_SYMBOL(prom_getproplen);
113 * 'buffer' which has a size of 'bufsize'. If the acquisition 113 * 'buffer' which has a size of 'bufsize'. If the acquisition
114 * was successful the length will be returned, else -1 is returned. 114 * was successful the length will be returned, else -1 is returned.
115 */ 115 */
116inline int prom_getproperty(int node, const char *prop, 116inline int prom_getproperty(phandle node, const char *prop,
117 char *buffer, int bufsize) 117 char *buffer, int bufsize)
118{ 118{
119 unsigned long args[8]; 119 unsigned long args[8];
@@ -141,7 +141,7 @@ EXPORT_SYMBOL(prom_getproperty);
141/* Acquire an integer property and return its value. Returns -1 141/* Acquire an integer property and return its value. Returns -1
142 * on failure. 142 * on failure.
143 */ 143 */
144inline int prom_getint(int node, const char *prop) 144inline int prom_getint(phandle node, const char *prop)
145{ 145{
146 int intprop; 146 int intprop;
147 147
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(prom_getint);
156 * integer. 156 * integer.
157 */ 157 */
158 158
159int prom_getintdefault(int node, const char *property, int deflt) 159int prom_getintdefault(phandle node, const char *property, int deflt)
160{ 160{
161 int retval; 161 int retval;
162 162
@@ -169,7 +169,7 @@ int prom_getintdefault(int node, const char *property, int deflt)
169EXPORT_SYMBOL(prom_getintdefault); 169EXPORT_SYMBOL(prom_getintdefault);
170 170
171/* Acquire a boolean property, 1=TRUE 0=FALSE. */ 171/* Acquire a boolean property, 1=TRUE 0=FALSE. */
172int prom_getbool(int node, const char *prop) 172int prom_getbool(phandle node, const char *prop)
173{ 173{
174 int retval; 174 int retval;
175 175
@@ -184,7 +184,8 @@ EXPORT_SYMBOL(prom_getbool);
184 * string on error. The char pointer is the user supplied string 184 * string on error. The char pointer is the user supplied string
185 * buffer. 185 * buffer.
186 */ 186 */
187void prom_getstring(int node, const char *prop, char *user_buf, int ubuf_size) 187void prom_getstring(phandle node, const char *prop, char *user_buf,
188 int ubuf_size)
188{ 189{
189 int len; 190 int len;
190 191
@@ -198,7 +199,7 @@ EXPORT_SYMBOL(prom_getstring);
198/* Does the device at node 'node' have name 'name'? 199/* Does the device at node 'node' have name 'name'?
199 * YES = 1 NO = 0 200 * YES = 1 NO = 0
200 */ 201 */
201int prom_nodematch(int node, const char *name) 202int prom_nodematch(phandle node, const char *name)
202{ 203{
203 char namebuf[128]; 204 char namebuf[128];
204 prom_getproperty(node, "name", namebuf, sizeof(namebuf)); 205 prom_getproperty(node, "name", namebuf, sizeof(namebuf));
@@ -210,10 +211,10 @@ int prom_nodematch(int node, const char *name)
210/* Search siblings at 'node_start' for a node with name 211/* Search siblings at 'node_start' for a node with name
211 * 'nodename'. Return node if successful, zero if not. 212 * 'nodename'. Return node if successful, zero if not.
212 */ 213 */
213int prom_searchsiblings(int node_start, const char *nodename) 214phandle prom_searchsiblings(phandle node_start, const char *nodename)
214{ 215{
215 216 phandle thisnode;
216 int thisnode, error; 217 int error;
217 char promlib_buf[128]; 218 char promlib_buf[128];
218 219
219 for(thisnode = node_start; thisnode; 220 for(thisnode = node_start; thisnode;
@@ -234,7 +235,7 @@ static const char *prom_nextprop_name = "nextprop";
234/* Return the first property type for node 'node'. 235/* Return the first property type for node 'node'.
235 * buffer should be at least 32B in length 236 * buffer should be at least 32B in length
236 */ 237 */
237inline char *prom_firstprop(int node, char *buffer) 238inline char *prom_firstprop(phandle node, char *buffer)
238{ 239{
239 unsigned long args[7]; 240 unsigned long args[7];
240 241
@@ -260,7 +261,7 @@ EXPORT_SYMBOL(prom_firstprop);
260 * at node 'node' . Returns NULL string if no more 261 * at node 'node' . Returns NULL string if no more
261 * property types for this node. 262 * property types for this node.
262 */ 263 */
263inline char *prom_nextprop(int node, const char *oprop, char *buffer) 264inline char *prom_nextprop(phandle node, const char *oprop, char *buffer)
264{ 265{
265 unsigned long args[7]; 266 unsigned long args[7];
266 char buf[32]; 267 char buf[32];
@@ -288,8 +289,7 @@ inline char *prom_nextprop(int node, const char *oprop, char *buffer)
288} 289}
289EXPORT_SYMBOL(prom_nextprop); 290EXPORT_SYMBOL(prom_nextprop);
290 291
291int 292phandle prom_finddevice(const char *name)
292prom_finddevice(const char *name)
293{ 293{
294 unsigned long args[5]; 294 unsigned long args[5];
295 295
@@ -307,7 +307,7 @@ prom_finddevice(const char *name)
307} 307}
308EXPORT_SYMBOL(prom_finddevice); 308EXPORT_SYMBOL(prom_finddevice);
309 309
310int prom_node_has_property(int node, const char *prop) 310int prom_node_has_property(phandle node, const char *prop)
311{ 311{
312 char buf [32]; 312 char buf [32];
313 313
@@ -325,7 +325,7 @@ EXPORT_SYMBOL(prom_node_has_property);
325 * of 'size' bytes. Return the number of bytes the prom accepted. 325 * of 'size' bytes. Return the number of bytes the prom accepted.
326 */ 326 */
327int 327int
328prom_setprop(int node, const char *pname, char *value, int size) 328prom_setprop(phandle node, const char *pname, char *value, int size)
329{ 329{
330 unsigned long args[8]; 330 unsigned long args[8];
331 331
@@ -355,10 +355,10 @@ prom_setprop(int node, const char *pname, char *value, int size)
355} 355}
356EXPORT_SYMBOL(prom_setprop); 356EXPORT_SYMBOL(prom_setprop);
357 357
358inline int prom_inst2pkg(int inst) 358inline phandle prom_inst2pkg(int inst)
359{ 359{
360 unsigned long args[5]; 360 unsigned long args[5];
361 int node; 361 phandle node;
362 362
363 args[0] = (unsigned long) "instance-to-package"; 363 args[0] = (unsigned long) "instance-to-package";
364 args[1] = 1; 364 args[1] = 1;
@@ -377,10 +377,10 @@ inline int prom_inst2pkg(int inst)
377/* Return 'node' assigned to a particular prom 'path' 377/* Return 'node' assigned to a particular prom 'path'
378 * FIXME: Should work for v0 as well 378 * FIXME: Should work for v0 as well
379 */ 379 */
380int 380phandle prom_pathtoinode(const char *path)
381prom_pathtoinode(const char *path)
382{ 381{
383 int node, inst; 382 phandle node;
383 int inst;
384 384
385 inst = prom_devopen (path); 385 inst = prom_devopen (path);
386 if (inst == 0) 386 if (inst == 0)
diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
index 6832b4be8990..6d4f0ff2c68c 100644
--- a/arch/tile/include/asm/bitops.h
+++ b/arch/tile/include/asm/bitops.h
@@ -120,6 +120,7 @@ static inline unsigned long __arch_hweight64(__u64 w)
120 120
121#include <asm-generic/bitops/const_hweight.h> 121#include <asm-generic/bitops/const_hweight.h>
122#include <asm-generic/bitops/lock.h> 122#include <asm-generic/bitops/lock.h>
123#include <asm-generic/bitops/find.h>
123#include <asm-generic/bitops/sched.h> 124#include <asm-generic/bitops/sched.h>
124#include <asm-generic/bitops/ext2-non-atomic.h> 125#include <asm-generic/bitops/ext2-non-atomic.h>
125#include <asm-generic/bitops/minix.h> 126#include <asm-generic/bitops/minix.h>
diff --git a/arch/tile/include/asm/irqflags.h b/arch/tile/include/asm/irqflags.h
index 45cf67c2f286..a11d4837ee4d 100644
--- a/arch/tile/include/asm/irqflags.h
+++ b/arch/tile/include/asm/irqflags.h
@@ -103,55 +103,57 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
103#define INITIAL_INTERRUPTS_ENABLED INT_MASK(INT_MEM_ERROR) 103#define INITIAL_INTERRUPTS_ENABLED INT_MASK(INT_MEM_ERROR)
104 104
105/* Disable interrupts. */ 105/* Disable interrupts. */
106#define raw_local_irq_disable() \ 106#define arch_local_irq_disable() \
107 interrupt_mask_set_mask(LINUX_MASKABLE_INTERRUPTS) 107 interrupt_mask_set_mask(LINUX_MASKABLE_INTERRUPTS)
108 108
109/* Disable all interrupts, including NMIs. */ 109/* Disable all interrupts, including NMIs. */
110#define raw_local_irq_disable_all() \ 110#define arch_local_irq_disable_all() \
111 interrupt_mask_set_mask(-1UL) 111 interrupt_mask_set_mask(-1UL)
112 112
113/* Re-enable all maskable interrupts. */ 113/* Re-enable all maskable interrupts. */
114#define raw_local_irq_enable() \ 114#define arch_local_irq_enable() \
115 interrupt_mask_reset_mask(__get_cpu_var(interrupts_enabled_mask)) 115 interrupt_mask_reset_mask(__get_cpu_var(interrupts_enabled_mask))
116 116
117/* Disable or enable interrupts based on flag argument. */ 117/* Disable or enable interrupts based on flag argument. */
118#define raw_local_irq_restore(disabled) do { \ 118#define arch_local_irq_restore(disabled) do { \
119 if (disabled) \ 119 if (disabled) \
120 raw_local_irq_disable(); \ 120 arch_local_irq_disable(); \
121 else \ 121 else \
122 raw_local_irq_enable(); \ 122 arch_local_irq_enable(); \
123} while (0) 123} while (0)
124 124
125/* Return true if "flags" argument means interrupts are disabled. */ 125/* Return true if "flags" argument means interrupts are disabled. */
126#define raw_irqs_disabled_flags(flags) ((flags) != 0) 126#define arch_irqs_disabled_flags(flags) ((flags) != 0)
127 127
128/* Return true if interrupts are currently disabled. */ 128/* Return true if interrupts are currently disabled. */
129#define raw_irqs_disabled() interrupt_mask_check(INT_MEM_ERROR) 129#define arch_irqs_disabled() interrupt_mask_check(INT_MEM_ERROR)
130 130
131/* Save whether interrupts are currently disabled. */ 131/* Save whether interrupts are currently disabled. */
132#define raw_local_save_flags(flags) ((flags) = raw_irqs_disabled()) 132#define arch_local_save_flags() arch_irqs_disabled()
133 133
134/* Save whether interrupts are currently disabled, then disable them. */ 134/* Save whether interrupts are currently disabled, then disable them. */
135#define raw_local_irq_save(flags) \ 135#define arch_local_irq_save() ({ \
136 do { raw_local_save_flags(flags); raw_local_irq_disable(); } while (0) 136 unsigned long __flags = arch_local_save_flags(); \
137 arch_local_irq_disable(); \
138 __flags; })
137 139
138/* Prevent the given interrupt from being enabled next time we enable irqs. */ 140/* Prevent the given interrupt from being enabled next time we enable irqs. */
139#define raw_local_irq_mask(interrupt) \ 141#define arch_local_irq_mask(interrupt) \
140 (__get_cpu_var(interrupts_enabled_mask) &= ~INT_MASK(interrupt)) 142 (__get_cpu_var(interrupts_enabled_mask) &= ~INT_MASK(interrupt))
141 143
142/* Prevent the given interrupt from being enabled immediately. */ 144/* Prevent the given interrupt from being enabled immediately. */
143#define raw_local_irq_mask_now(interrupt) do { \ 145#define arch_local_irq_mask_now(interrupt) do { \
144 raw_local_irq_mask(interrupt); \ 146 arch_local_irq_mask(interrupt); \
145 interrupt_mask_set(interrupt); \ 147 interrupt_mask_set(interrupt); \
146} while (0) 148} while (0)
147 149
148/* Allow the given interrupt to be enabled next time we enable irqs. */ 150/* Allow the given interrupt to be enabled next time we enable irqs. */
149#define raw_local_irq_unmask(interrupt) \ 151#define arch_local_irq_unmask(interrupt) \
150 (__get_cpu_var(interrupts_enabled_mask) |= INT_MASK(interrupt)) 152 (__get_cpu_var(interrupts_enabled_mask) |= INT_MASK(interrupt))
151 153
152/* Allow the given interrupt to be enabled immediately, if !irqs_disabled. */ 154/* Allow the given interrupt to be enabled immediately, if !irqs_disabled. */
153#define raw_local_irq_unmask_now(interrupt) do { \ 155#define arch_local_irq_unmask_now(interrupt) do { \
154 raw_local_irq_unmask(interrupt); \ 156 arch_local_irq_unmask(interrupt); \
155 if (!irqs_disabled()) \ 157 if (!irqs_disabled()) \
156 interrupt_mask_reset(interrupt); \ 158 interrupt_mask_reset(interrupt); \
157} while (0) 159} while (0)
diff --git a/arch/tile/kernel/hardwall.c b/arch/tile/kernel/hardwall.c
index 584b965dc824..1e54a7843410 100644
--- a/arch/tile/kernel/hardwall.c
+++ b/arch/tile/kernel/hardwall.c
@@ -774,6 +774,7 @@ static const struct file_operations dev_hardwall_fops = {
774#endif 774#endif
775 .flush = hardwall_flush, 775 .flush = hardwall_flush,
776 .release = hardwall_release, 776 .release = hardwall_release,
777 .llseek = noop_llseek,
777}; 778};
778 779
779static struct cdev hardwall_dev; 780static struct cdev hardwall_dev;
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 596c60086930..9a27d563fc30 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -208,7 +208,7 @@ static void tile_irq_chip_eoi(unsigned int irq)
208} 208}
209 209
210static struct irq_chip tile_irq_chip = { 210static struct irq_chip tile_irq_chip = {
211 .typename = "tile_irq_chip", 211 .name = "tile_irq_chip",
212 .ack = tile_irq_chip_ack, 212 .ack = tile_irq_chip_ack,
213 .eoi = tile_irq_chip_eoi, 213 .eoi = tile_irq_chip_eoi,
214 .mask = tile_irq_chip_mask, 214 .mask = tile_irq_chip_mask,
@@ -288,7 +288,7 @@ int show_interrupts(struct seq_file *p, void *v)
288 for_each_online_cpu(j) 288 for_each_online_cpu(j)
289 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 289 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
290#endif 290#endif
291 seq_printf(p, " %14s", irq_desc[i].chip->typename); 291 seq_printf(p, " %14s", irq_desc[i].chip->name);
292 seq_printf(p, " %s", action->name); 292 seq_printf(p, " %s", action->name);
293 293
294 for (action = action->next; action; action = action->next) 294 for (action = action->next; action; action = action->next)
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index cfcac1ff4cf2..2d0266d0254d 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -42,7 +42,7 @@
42#include <linux/miscdevice.h> 42#include <linux/miscdevice.h>
43#include <linux/watchdog.h> 43#include <linux/watchdog.h>
44#include <linux/reboot.h> 44#include <linux/reboot.h>
45#include <linux/smp_lock.h> 45#include <linux/mutex.h>
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/spinlock.h> 47#include <linux/spinlock.h>
48#include <asm/uaccess.h> 48#include <asm/uaccess.h>
@@ -50,6 +50,7 @@
50 50
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
53static DEFINE_MUTEX(harddog_mutex);
53static DEFINE_SPINLOCK(lock); 54static DEFINE_SPINLOCK(lock);
54static int timer_alive; 55static int timer_alive;
55static int harddog_in_fd = -1; 56static int harddog_in_fd = -1;
@@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file)
66 int err = -EBUSY; 67 int err = -EBUSY;
67 char *sock = NULL; 68 char *sock = NULL;
68 69
69 lock_kernel(); 70 mutex_lock(&harddog_mutex);
70 spin_lock(&lock); 71 spin_lock(&lock);
71 if(timer_alive) 72 if(timer_alive)
72 goto err; 73 goto err;
@@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file)
83 84
84 timer_alive = 1; 85 timer_alive = 1;
85 spin_unlock(&lock); 86 spin_unlock(&lock);
86 unlock_kernel(); 87 mutex_unlock(&harddog_mutex);
87 return nonseekable_open(inode, file); 88 return nonseekable_open(inode, file);
88err: 89err:
89 spin_unlock(&lock); 90 spin_unlock(&lock);
90 unlock_kernel(); 91 mutex_unlock(&harddog_mutex);
91 return err; 92 return err;
92} 93}
93 94
@@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file,
153{ 154{
154 long ret; 155 long ret;
155 156
156 lock_kernel(); 157 mutex_lock(&harddog_mutex);
157 ret = harddog_ioctl_unlocked(file, cmd, arg); 158 ret = harddog_ioctl_unlocked(file, cmd, arg);
158 unlock_kernel(); 159 mutex_unlock(&harddog_mutex);
159 160
160 return ret; 161 return ret;
161} 162}
@@ -166,6 +167,7 @@ static const struct file_operations harddog_fops = {
166 .unlocked_ioctl = harddog_ioctl, 167 .unlocked_ioctl = harddog_ioctl,
167 .open = harddog_open, 168 .open = harddog_open,
168 .release = harddog_release, 169 .release = harddog_release,
170 .llseek = no_llseek,
169}; 171};
170 172
171static struct miscdevice harddog_miscdev = { 173static struct miscdevice harddog_miscdev = {
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 0c46e398cd8f..f9f6a4e20590 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -8,7 +8,7 @@
8#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/sound.h" 9#include "linux/sound.h"
10#include "linux/soundcard.h" 10#include "linux/soundcard.h"
11#include "linux/smp_lock.h" 11#include "linux/mutex.h"
12#include "asm/uaccess.h" 12#include "asm/uaccess.h"
13#include "init.h" 13#include "init.h"
14#include "os.h" 14#include "os.h"
@@ -40,6 +40,11 @@ static char *mixer = HOSTAUDIO_DEV_MIXER;
40" This is used to specify the host mixer device to the hostaudio driver.\n"\ 40" This is used to specify the host mixer device to the hostaudio driver.\n"\
41" The default is \"" HOSTAUDIO_DEV_MIXER "\".\n\n" 41" The default is \"" HOSTAUDIO_DEV_MIXER "\".\n\n"
42 42
43module_param(dsp, charp, 0644);
44MODULE_PARM_DESC(dsp, DSP_HELP);
45module_param(mixer, charp, 0644);
46MODULE_PARM_DESC(mixer, MIXER_HELP);
47
43#ifndef MODULE 48#ifndef MODULE
44static int set_dsp(char *name, int *add) 49static int set_dsp(char *name, int *add)
45{ 50{
@@ -56,17 +61,10 @@ static int set_mixer(char *name, int *add)
56} 61}
57 62
58__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); 63__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
59
60#else /*MODULE*/
61
62module_param(dsp, charp, 0644);
63MODULE_PARM_DESC(dsp, DSP_HELP);
64
65module_param(mixer, charp, 0644);
66MODULE_PARM_DESC(mixer, MIXER_HELP);
67
68#endif 64#endif
69 65
66static DEFINE_MUTEX(hostaudio_mutex);
67
70/* /dev/dsp file operations */ 68/* /dev/dsp file operations */
71 69
72static ssize_t hostaudio_read(struct file *file, char __user *buffer, 70static ssize_t hostaudio_read(struct file *file, char __user *buffer,
@@ -202,9 +200,9 @@ static int hostaudio_open(struct inode *inode, struct file *file)
202 w = 1; 200 w = 1;
203 201
204 kparam_block_sysfs_write(dsp); 202 kparam_block_sysfs_write(dsp);
205 lock_kernel(); 203 mutex_lock(&hostaudio_mutex);
206 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); 204 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
207 unlock_kernel(); 205 mutex_unlock(&hostaudio_mutex);
208 kparam_unblock_sysfs_write(dsp); 206 kparam_unblock_sysfs_write(dsp);
209 207
210 if (ret < 0) { 208 if (ret < 0) {
@@ -263,9 +261,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
263 w = 1; 261 w = 1;
264 262
265 kparam_block_sysfs_write(mixer); 263 kparam_block_sysfs_write(mixer);
266 lock_kernel(); 264 mutex_lock(&hostaudio_mutex);
267 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); 265 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
268 unlock_kernel(); 266 mutex_unlock(&hostaudio_mutex);
269 kparam_unblock_sysfs_write(mixer); 267 kparam_unblock_sysfs_write(mixer);
270 268
271 if (ret < 0) { 269 if (ret < 0) {
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index ebc680717e59..975613b23dcf 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -843,6 +843,7 @@ static ssize_t mconsole_proc_write(struct file *file,
843static const struct file_operations mconsole_proc_fops = { 843static const struct file_operations mconsole_proc_fops = {
844 .owner = THIS_MODULE, 844 .owner = THIS_MODULE,
845 .write = mconsole_proc_write, 845 .write = mconsole_proc_write,
846 .llseek = noop_llseek,
846}; 847};
847 848
848static int create_proc_mconsole(void) 849static int create_proc_mconsole(void)
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 7158393b6793..8501e7d0015c 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -93,6 +93,7 @@ static const struct file_operations mmapper_fops = {
93 .mmap = mmapper_mmap, 93 .mmap = mmapper_mmap,
94 .open = mmapper_open, 94 .open = mmapper_open,
95 .release = mmapper_release, 95 .release = mmapper_release,
96 .llseek = default_llseek,
96}; 97};
97 98
98/* 99/*
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 2ab233ba32c1..47d0c37897d5 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -255,18 +255,6 @@ static void uml_net_tx_timeout(struct net_device *dev)
255 netif_wake_queue(dev); 255 netif_wake_queue(dev);
256} 256}
257 257
258static int uml_net_set_mac(struct net_device *dev, void *addr)
259{
260 struct uml_net_private *lp = netdev_priv(dev);
261 struct sockaddr *hwaddr = addr;
262
263 spin_lock_irq(&lp->lock);
264 eth_mac_addr(dev, hwaddr->sa_data);
265 spin_unlock_irq(&lp->lock);
266
267 return 0;
268}
269
270static int uml_net_change_mtu(struct net_device *dev, int new_mtu) 258static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
271{ 259{
272 dev->mtu = new_mtu; 260 dev->mtu = new_mtu;
@@ -373,7 +361,7 @@ static const struct net_device_ops uml_netdev_ops = {
373 .ndo_start_xmit = uml_net_start_xmit, 361 .ndo_start_xmit = uml_net_start_xmit,
374 .ndo_set_multicast_list = uml_net_set_multicast_list, 362 .ndo_set_multicast_list = uml_net_set_multicast_list,
375 .ndo_tx_timeout = uml_net_tx_timeout, 363 .ndo_tx_timeout = uml_net_tx_timeout,
376 .ndo_set_mac_address = uml_net_set_mac, 364 .ndo_set_mac_address = eth_mac_addr,
377 .ndo_change_mtu = uml_net_change_mtu, 365 .ndo_change_mtu = uml_net_change_mtu,
378 .ndo_validate_addr = eth_validate_addr, 366 .ndo_validate_addr = eth_validate_addr,
379}; 367};
@@ -472,7 +460,8 @@ static void eth_configure(int n, void *init, char *mac,
472 ((*transport->user->init)(&lp->user, dev) != 0)) 460 ((*transport->user->init)(&lp->user, dev) != 0))
473 goto out_unregister; 461 goto out_unregister;
474 462
475 eth_mac_addr(dev, device->mac); 463 /* don't use eth_mac_addr, it will not work here */
464 memcpy(dev->dev_addr, device->mac, ETH_ALEN);
476 dev->mtu = transport->user->mtu; 465 dev->mtu = transport->user->mtu;
477 dev->netdev_ops = &uml_netdev_ops; 466 dev->netdev_ops = &uml_netdev_ops;
478 dev->ethtool_ops = &uml_net_ethtool_ops; 467 dev->ethtool_ops = &uml_net_ethtool_ops;
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 4949044773ba..981085a93f30 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -100,6 +100,7 @@ static const struct file_operations rng_chrdev_ops = {
100 .owner = THIS_MODULE, 100 .owner = THIS_MODULE,
101 .open = rng_dev_open, 101 .open = rng_dev_open,
102 .read = rng_dev_read, 102 .read = rng_dev_read,
103 .llseek = noop_llseek,
103}; 104};
104 105
105/* rng_init shouldn't be called more than once at boot time */ 106/* rng_init shouldn't be called more than once at boot time */
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 1bcd208c459f..ba4a98ba39c0 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -33,7 +33,7 @@
33#include "linux/mm.h" 33#include "linux/mm.h"
34#include "linux/slab.h" 34#include "linux/slab.h"
35#include "linux/vmalloc.h" 35#include "linux/vmalloc.h"
36#include "linux/smp_lock.h" 36#include "linux/mutex.h"
37#include "linux/blkpg.h" 37#include "linux/blkpg.h"
38#include "linux/genhd.h" 38#include "linux/genhd.h"
39#include "linux/spinlock.h" 39#include "linux/spinlock.h"
@@ -100,6 +100,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
100#define DRIVER_NAME "uml-blkdev" 100#define DRIVER_NAME "uml-blkdev"
101 101
102static DEFINE_MUTEX(ubd_lock); 102static DEFINE_MUTEX(ubd_lock);
103static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
103 104
104static int ubd_open(struct block_device *bdev, fmode_t mode); 105static int ubd_open(struct block_device *bdev, fmode_t mode);
105static int ubd_release(struct gendisk *disk, fmode_t mode); 106static int ubd_release(struct gendisk *disk, fmode_t mode);
@@ -163,6 +164,7 @@ struct ubd {
163 struct scatterlist sg[MAX_SG]; 164 struct scatterlist sg[MAX_SG];
164 struct request *request; 165 struct request *request;
165 int start_sg, end_sg; 166 int start_sg, end_sg;
167 sector_t rq_pos;
166}; 168};
167 169
168#define DEFAULT_COW { \ 170#define DEFAULT_COW { \
@@ -187,6 +189,7 @@ struct ubd {
187 .request = NULL, \ 189 .request = NULL, \
188 .start_sg = 0, \ 190 .start_sg = 0, \
189 .end_sg = 0, \ 191 .end_sg = 0, \
192 .rq_pos = 0, \
190} 193}
191 194
192/* Protected by ubd_lock */ 195/* Protected by ubd_lock */
@@ -1099,7 +1102,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1099 struct ubd *ubd_dev = disk->private_data; 1102 struct ubd *ubd_dev = disk->private_data;
1100 int err = 0; 1103 int err = 0;
1101 1104
1102 lock_kernel(); 1105 mutex_lock(&ubd_mutex);
1103 if(ubd_dev->count == 0){ 1106 if(ubd_dev->count == 0){
1104 err = ubd_open_dev(ubd_dev); 1107 err = ubd_open_dev(ubd_dev);
1105 if(err){ 1108 if(err){
@@ -1118,7 +1121,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1118 err = -EROFS; 1121 err = -EROFS;
1119 }*/ 1122 }*/
1120out: 1123out:
1121 unlock_kernel(); 1124 mutex_unlock(&ubd_mutex);
1122 return err; 1125 return err;
1123} 1126}
1124 1127
@@ -1126,10 +1129,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode)
1126{ 1129{
1127 struct ubd *ubd_dev = disk->private_data; 1130 struct ubd *ubd_dev = disk->private_data;
1128 1131
1129 lock_kernel(); 1132 mutex_lock(&ubd_mutex);
1130 if(--ubd_dev->count == 0) 1133 if(--ubd_dev->count == 0)
1131 ubd_close_dev(ubd_dev); 1134 ubd_close_dev(ubd_dev);
1132 unlock_kernel(); 1135 mutex_unlock(&ubd_mutex);
1133 return 0; 1136 return 0;
1134} 1137}
1135 1138
@@ -1228,7 +1231,6 @@ static void do_ubd_request(struct request_queue *q)
1228{ 1231{
1229 struct io_thread_req *io_req; 1232 struct io_thread_req *io_req;
1230 struct request *req; 1233 struct request *req;
1231 sector_t sector;
1232 int n; 1234 int n;
1233 1235
1234 while(1){ 1236 while(1){
@@ -1239,12 +1241,12 @@ static void do_ubd_request(struct request_queue *q)
1239 return; 1241 return;
1240 1242
1241 dev->request = req; 1243 dev->request = req;
1244 dev->rq_pos = blk_rq_pos(req);
1242 dev->start_sg = 0; 1245 dev->start_sg = 0;
1243 dev->end_sg = blk_rq_map_sg(q, req, dev->sg); 1246 dev->end_sg = blk_rq_map_sg(q, req, dev->sg);
1244 } 1247 }
1245 1248
1246 req = dev->request; 1249 req = dev->request;
1247 sector = blk_rq_pos(req);
1248 while(dev->start_sg < dev->end_sg){ 1250 while(dev->start_sg < dev->end_sg){
1249 struct scatterlist *sg = &dev->sg[dev->start_sg]; 1251 struct scatterlist *sg = &dev->sg[dev->start_sg];
1250 1252
@@ -1256,10 +1258,9 @@ static void do_ubd_request(struct request_queue *q)
1256 return; 1258 return;
1257 } 1259 }
1258 prepare_request(req, io_req, 1260 prepare_request(req, io_req,
1259 (unsigned long long)sector << 9, 1261 (unsigned long long)dev->rq_pos << 9,
1260 sg->offset, sg->length, sg_page(sg)); 1262 sg->offset, sg->length, sg_page(sg));
1261 1263
1262 sector += sg->length >> 9;
1263 n = os_write_file(thread_fd, &io_req, 1264 n = os_write_file(thread_fd, &io_req,
1264 sizeof(struct io_thread_req *)); 1265 sizeof(struct io_thread_req *));
1265 if(n != sizeof(struct io_thread_req *)){ 1266 if(n != sizeof(struct io_thread_req *)){
@@ -1272,6 +1273,7 @@ static void do_ubd_request(struct request_queue *q)
1272 return; 1273 return;
1273 } 1274 }
1274 1275
1276 dev->rq_pos += sg->length >> 9;
1275 dev->start_sg++; 1277 dev->start_sg++;
1276 } 1278 }
1277 dev->end_sg = 0; 1279 dev->end_sg = 0;
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 49b5e1eb3262..340268be00b5 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -78,13 +78,11 @@ long sys_execve(const char __user *file, const char __user *const __user *argv,
78 long error; 78 long error;
79 char *filename; 79 char *filename;
80 80
81 lock_kernel();
82 filename = getname(file); 81 filename = getname(file);
83 error = PTR_ERR(filename); 82 error = PTR_ERR(filename);
84 if (IS_ERR(filename)) goto out; 83 if (IS_ERR(filename)) goto out;
85 error = execve1(filename, argv, env); 84 error = execve1(filename, argv, env);
86 putname(filename); 85 putname(filename);
87 out: 86 out:
88 unlock_kernel();
89 return error; 87 return error;
90} 88}
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index a3f0b04d7101..a746e3037a5b 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -46,7 +46,7 @@ int show_interrupts(struct seq_file *p, void *v)
46 for_each_online_cpu(j) 46 for_each_online_cpu(j)
47 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 47 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
48#endif 48#endif
49 seq_printf(p, " %14s", irq_desc[i].chip->typename); 49 seq_printf(p, " %14s", irq_desc[i].chip->name);
50 seq_printf(p, " %s", action->name); 50 seq_printf(p, " %s", action->name);
51 51
52 for (action=action->next; action; action = action->next) 52 for (action=action->next; action; action = action->next)
@@ -369,7 +369,7 @@ static void dummy(unsigned int irq)
369 369
370/* This is used for everything else than the timer. */ 370/* This is used for everything else than the timer. */
371static struct irq_chip normal_irq_type = { 371static struct irq_chip normal_irq_type = {
372 .typename = "SIGIO", 372 .name = "SIGIO",
373 .release = free_irq_by_irq_and_dev, 373 .release = free_irq_by_irq_and_dev,
374 .disable = dummy, 374 .disable = dummy,
375 .enable = dummy, 375 .enable = dummy,
@@ -378,7 +378,7 @@ static struct irq_chip normal_irq_type = {
378}; 378};
379 379
380static struct irq_chip SIGVTALRM_irq_type = { 380static struct irq_chip SIGVTALRM_irq_type = {
381 .typename = "SIGVTALRM", 381 .name = "SIGVTALRM",
382 .release = free_irq_by_irq_and_dev, 382 .release = free_irq_by_irq_and_dev,
383 .shutdown = dummy, /* never called */ 383 .shutdown = dummy, /* never called */
384 .disable = dummy, 384 .disable = dummy,
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cea0cd9a316f..dfabfefc21c4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -25,14 +25,17 @@ config X86
25 select HAVE_IDE 25 select HAVE_IDE
26 select HAVE_OPROFILE 26 select HAVE_OPROFILE
27 select HAVE_PERF_EVENTS if (!M386 && !M486) 27 select HAVE_PERF_EVENTS if (!M386 && !M486)
28 select HAVE_IRQ_WORK
28 select HAVE_IOREMAP_PROT 29 select HAVE_IOREMAP_PROT
29 select HAVE_KPROBES 30 select HAVE_KPROBES
31 select HAVE_MEMBLOCK
30 select ARCH_WANT_OPTIONAL_GPIOLIB 32 select ARCH_WANT_OPTIONAL_GPIOLIB
31 select ARCH_WANT_FRAME_POINTERS 33 select ARCH_WANT_FRAME_POINTERS
32 select HAVE_DMA_ATTRS 34 select HAVE_DMA_ATTRS
33 select HAVE_KRETPROBES 35 select HAVE_KRETPROBES
34 select HAVE_OPTPROBES 36 select HAVE_OPTPROBES
35 select HAVE_FTRACE_MCOUNT_RECORD 37 select HAVE_FTRACE_MCOUNT_RECORD
38 select HAVE_C_RECORDMCOUNT
36 select HAVE_DYNAMIC_FTRACE 39 select HAVE_DYNAMIC_FTRACE
37 select HAVE_FUNCTION_TRACER 40 select HAVE_FUNCTION_TRACER
38 select HAVE_FUNCTION_GRAPH_TRACER 41 select HAVE_FUNCTION_GRAPH_TRACER
@@ -59,6 +62,12 @@ config X86
59 select ANON_INODES 62 select ANON_INODES
60 select HAVE_ARCH_KMEMCHECK 63 select HAVE_ARCH_KMEMCHECK
61 select HAVE_USER_RETURN_NOTIFIER 64 select HAVE_USER_RETURN_NOTIFIER
65 select HAVE_ARCH_JUMP_LABEL
66 select HAVE_TEXT_POKE_SMP
67 select HAVE_GENERIC_HARDIRQS
68 select HAVE_SPARSE_IRQ
69 select GENERIC_IRQ_PROBE
70 select GENERIC_PENDING_IRQ if SMP
62 71
63config INSTRUCTION_DECODER 72config INSTRUCTION_DECODER
64 def_bool (KPROBES || PERF_EVENTS) 73 def_bool (KPROBES || PERF_EVENTS)
@@ -193,27 +202,10 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING
193config ARCH_SUPPORTS_DEBUG_PAGEALLOC 202config ARCH_SUPPORTS_DEBUG_PAGEALLOC
194 def_bool y 203 def_bool y
195 204
196config HAVE_EARLY_RES
197 def_bool y
198
199config HAVE_INTEL_TXT 205config HAVE_INTEL_TXT
200 def_bool y 206 def_bool y
201 depends on EXPERIMENTAL && DMAR && ACPI 207 depends on EXPERIMENTAL && DMAR && ACPI
202 208
203# Use the generic interrupt handling code in kernel/irq/:
204config GENERIC_HARDIRQS
205 def_bool y
206
207config GENERIC_HARDIRQS_NO__DO_IRQ
208 def_bool y
209
210config GENERIC_IRQ_PROBE
211 def_bool y
212
213config GENERIC_PENDING_IRQ
214 def_bool y
215 depends on GENERIC_HARDIRQS && SMP
216
217config USE_GENERIC_SMP_HELPERS 209config USE_GENERIC_SMP_HELPERS
218 def_bool y 210 def_bool y
219 depends on SMP 211 depends on SMP
@@ -296,23 +288,6 @@ config X86_X2APIC
296 288
297 If you don't know what to do here, say N. 289 If you don't know what to do here, say N.
298 290
299config SPARSE_IRQ
300 bool "Support sparse irq numbering"
301 depends on PCI_MSI || HT_IRQ
302 ---help---
303 This enables support for sparse irqs. This is useful for distro
304 kernels that want to define a high CONFIG_NR_CPUS value but still
305 want to have low kernel memory footprint on smaller machines.
306
307 ( Sparse IRQs can also be beneficial on NUMA boxes, as they spread
308 out the irq_desc[] array in a more NUMA-friendly way. )
309
310 If you don't know what to do here, say N.
311
312config NUMA_IRQ_DESC
313 def_bool y
314 depends on SPARSE_IRQ && NUMA
315
316config X86_MPPARSE 291config X86_MPPARSE
317 bool "Enable MPS table" if ACPI 292 bool "Enable MPS table" if ACPI
318 default y 293 default y
@@ -517,25 +492,6 @@ if PARAVIRT_GUEST
517 492
518source "arch/x86/xen/Kconfig" 493source "arch/x86/xen/Kconfig"
519 494
520config VMI
521 bool "VMI Guest support (DEPRECATED)"
522 select PARAVIRT
523 depends on X86_32
524 ---help---
525 VMI provides a paravirtualized interface to the VMware ESX server
526 (it could be used by other hypervisors in theory too, but is not
527 at the moment), by linking the kernel to a GPL-ed ROM module
528 provided by the hypervisor.
529
530 As of September 2009, VMware has started a phased retirement
531 of this feature from VMware's products. Please see
532 feature-removal-schedule.txt for details. If you are
533 planning to enable this option, please note that you cannot
534 live migrate a VMI enabled VM to a future VMware product,
535 which doesn't support VMI. So if you expect your kernel to
536 seamlessly migrate to newer VMware products, keep this
537 disabled.
538
539config KVM_CLOCK 495config KVM_CLOCK
540 bool "KVM paravirtualized clock" 496 bool "KVM paravirtualized clock"
541 select PARAVIRT 497 select PARAVIRT
@@ -590,16 +546,7 @@ config PARAVIRT_DEBUG
590 a paravirt_op is missing when it is called. 546 a paravirt_op is missing when it is called.
591 547
592config NO_BOOTMEM 548config NO_BOOTMEM
593 default y 549 def_bool y
594 bool "Disable Bootmem code"
595 ---help---
596 Use early_res directly instead of bootmem before slab is ready.
597 - allocator (buddy) [generic]
598 - early allocator (bootmem) [generic]
599 - very early allocator (reserve_early*()) [x86]
600 - very very early allocator (early brk model) [x86]
601 So reduce one layer between early allocator to final allocator
602
603 550
604config MEMTEST 551config MEMTEST
605 bool "Memtest" 552 bool "Memtest"
@@ -670,7 +617,7 @@ config GART_IOMMU
670 bool "GART IOMMU support" if EMBEDDED 617 bool "GART IOMMU support" if EMBEDDED
671 default y 618 default y
672 select SWIOTLB 619 select SWIOTLB
673 depends on X86_64 && PCI && K8_NB 620 depends on X86_64 && PCI && AMD_NB
674 ---help--- 621 ---help---
675 Support for full DMA access of devices with 32bit memory access only 622 Support for full DMA access of devices with 32bit memory access only
676 on systems with more than 3GB. This is usually needed for USB, 623 on systems with more than 3GB. This is usually needed for USB,
@@ -795,6 +742,17 @@ config SCHED_MC
795 making when dealing with multi-core CPU chips at a cost of slightly 742 making when dealing with multi-core CPU chips at a cost of slightly
796 increased overhead in some places. If unsure say N here. 743 increased overhead in some places. If unsure say N here.
797 744
745config IRQ_TIME_ACCOUNTING
746 bool "Fine granularity task level IRQ time accounting"
747 default n
748 ---help---
749 Select this option to enable fine granularity task irq time
750 accounting. This is done by reading a timestamp on each
751 transitions between softirq and hardirq state, so there can be a
752 small performance impact.
753
754 If in doubt, say N here.
755
798source "kernel/Kconfig.preempt" 756source "kernel/Kconfig.preempt"
799 757
800config X86_UP_APIC 758config X86_UP_APIC
@@ -1148,6 +1106,9 @@ config X86_PAE
1148config ARCH_PHYS_ADDR_T_64BIT 1106config ARCH_PHYS_ADDR_T_64BIT
1149 def_bool X86_64 || X86_PAE 1107 def_bool X86_64 || X86_PAE
1150 1108
1109config ARCH_DMA_ADDR_T_64BIT
1110 def_bool X86_64 || HIGHMEM64G
1111
1151config DIRECT_GBPAGES 1112config DIRECT_GBPAGES
1152 bool "Enable 1GB pages for kernel pagetables" if EMBEDDED 1113 bool "Enable 1GB pages for kernel pagetables" if EMBEDDED
1153 default y 1114 default y
@@ -1326,25 +1287,34 @@ config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
1326 Set whether the default state of memory_corruption_check is 1287 Set whether the default state of memory_corruption_check is
1327 on or off. 1288 on or off.
1328 1289
1329config X86_RESERVE_LOW_64K 1290config X86_RESERVE_LOW
1330 bool "Reserve low 64K of RAM on AMI/Phoenix BIOSen" 1291 int "Amount of low memory, in kilobytes, to reserve for the BIOS"
1331 default y 1292 default 64
1293 range 4 640
1332 ---help--- 1294 ---help---
1333 Reserve the first 64K of physical RAM on BIOSes that are known 1295 Specify the amount of low memory to reserve for the BIOS.
1334 to potentially corrupt that memory range. A numbers of BIOSes are 1296
1335 known to utilize this area during suspend/resume, so it must not 1297 The first page contains BIOS data structures that the kernel
1336 be used by the kernel. 1298 must not use, so that page must always be reserved.
1299
1300 By default we reserve the first 64K of physical RAM, as a
1301 number of BIOSes are known to corrupt that memory range
1302 during events such as suspend/resume or monitor cable
1303 insertion, so it must not be used by the kernel.
1337 1304
1338 Set this to N if you are absolutely sure that you trust the BIOS 1305 You can set this to 4 if you are absolutely sure that you
1339 to get all its memory reservations and usages right. 1306 trust the BIOS to get all its memory reservations and usages
1307 right. If you know your BIOS have problems beyond the
1308 default 64K area, you can set this to 640 to avoid using the
1309 entire low memory range.
1340 1310
1341 If you have doubts about the BIOS (e.g. suspend/resume does not 1311 If you have doubts about the BIOS (e.g. suspend/resume does
1342 work or there's kernel crashes after certain hardware hotplug 1312 not work or there's kernel crashes after certain hardware
1343 events) and it's not AMI or Phoenix, then you might want to enable 1313 hotplug events) then you might want to enable
1344 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check typical 1314 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check
1345 corruption patterns. 1315 typical corruption patterns.
1346 1316
1347 Say Y if unsure. 1317 Leave this to the default value of 64 if you are unsure.
1348 1318
1349config MATH_EMULATION 1319config MATH_EMULATION
1350 bool 1320 bool
@@ -1900,7 +1870,7 @@ config PCI_GODIRECT
1900 bool "Direct" 1870 bool "Direct"
1901 1871
1902config PCI_GOOLPC 1872config PCI_GOOLPC
1903 bool "OLPC" 1873 bool "OLPC XO-1"
1904 depends on OLPC 1874 depends on OLPC
1905 1875
1906config PCI_GOANY 1876config PCI_GOANY
@@ -2061,14 +2031,21 @@ config SCx200HR_TIMER
2061config OLPC 2031config OLPC
2062 bool "One Laptop Per Child support" 2032 bool "One Laptop Per Child support"
2063 select GPIOLIB 2033 select GPIOLIB
2034 select OLPC_OPENFIRMWARE
2064 ---help--- 2035 ---help---
2065 Add support for detecting the unique features of the OLPC 2036 Add support for detecting the unique features of the OLPC
2066 XO hardware. 2037 XO hardware.
2067 2038
2039config OLPC_XO1
2040 tristate "OLPC XO-1 support"
2041 depends on OLPC && PCI
2042 ---help---
2043 Add support for non-essential features of the OLPC XO-1 laptop.
2044
2068config OLPC_OPENFIRMWARE 2045config OLPC_OPENFIRMWARE
2069 bool "Support for OLPC's Open Firmware" 2046 bool "Support for OLPC's Open Firmware"
2070 depends on !X86_64 && !X86_PAE 2047 depends on !X86_64 && !X86_PAE
2071 default y if OLPC 2048 default n
2072 help 2049 help
2073 This option adds support for the implementation of Open Firmware 2050 This option adds support for the implementation of Open Firmware
2074 that is used on the OLPC XO-1 Children's Machine. 2051 that is used on the OLPC XO-1 Children's Machine.
@@ -2076,7 +2053,7 @@ config OLPC_OPENFIRMWARE
2076 2053
2077endif # X86_32 2054endif # X86_32
2078 2055
2079config K8_NB 2056config AMD_NB
2080 def_bool y 2057 def_bool y
2081 depends on CPU_SUP_AMD && PCI 2058 depends on CPU_SUP_AMD && PCI
2082 2059
@@ -2125,6 +2102,10 @@ config HAVE_ATOMIC_IOMAP
2125 def_bool y 2102 def_bool y
2126 depends on X86_32 2103 depends on X86_32
2127 2104
2105config HAVE_TEXT_POKE_SMP
2106 bool
2107 select STOP_MACHINE if SMP
2108
2128source "net/Kconfig" 2109source "net/Kconfig"
2129 2110
2130source "drivers/Kconfig" 2111source "drivers/Kconfig"
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 75085080b63e..b59ee765414e 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -43,6 +43,10 @@ config EARLY_PRINTK
43 with klogd/syslogd or the X server. You should normally N here, 43 with klogd/syslogd or the X server. You should normally N here,
44 unless you want to debug such a crash. 44 unless you want to debug such a crash.
45 45
46config EARLY_PRINTK_MRST
47 bool "Early printk for MRST platform support"
48 depends on EARLY_PRINTK && X86_MRST
49
46config EARLY_PRINTK_DBGP 50config EARLY_PRINTK_DBGP
47 bool "Early printk via EHCI debug port" 51 bool "Early printk via EHCI debug port"
48 depends on EARLY_PRINTK && PCI 52 depends on EARLY_PRINTK && PCI
@@ -121,16 +125,6 @@ config DEBUG_NX_TEST
121 and the software setup of this feature. 125 and the software setup of this feature.
122 If in doubt, say "N" 126 If in doubt, say "N"
123 127
124config 4KSTACKS
125 bool "Use 4Kb for kernel stacks instead of 8Kb"
126 depends on X86_32
127 ---help---
128 If you say Y here the kernel will use a 4Kb stacksize for the
129 kernel stack attached to each process/thread. This facilitates
130 running more threads on a system and also reduces the pressure
131 on the VM subsystem for higher order allocations. This option
132 will also use IRQ stacks to compensate for the reduced stackspace.
133
134config DOUBLEFAULT 128config DOUBLEFAULT
135 default y 129 default y
136 bool "Enable doublefault exception handler" if EMBEDDED 130 bool "Enable doublefault exception handler" if EMBEDDED
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index e8c8881351b3..b02e509072a7 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -96,8 +96,12 @@ cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset $(sp-y)$(comma)0\n.cfi_en
96# is .cfi_signal_frame supported too? 96# is .cfi_signal_frame supported too?
97cfi-sigframe := $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1) 97cfi-sigframe := $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1)
98cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1) 98cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1)
99KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) 99
100KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) 100# does binutils support specific instructions?
101asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1)
102
103KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr)
104KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr)
101 105
102LDFLAGS := -m elf_$(UTS_MACHINE) 106LDFLAGS := -m elf_$(UTS_MACHINE)
103 107
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 8f7bef8e9fff..23f315c9f215 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -229,18 +229,35 @@ void *memset(void *s, int c, size_t n)
229 ss[i] = c; 229 ss[i] = c;
230 return s; 230 return s;
231} 231}
232 232#ifdef CONFIG_X86_32
233void *memcpy(void *dest, const void *src, size_t n) 233void *memcpy(void *dest, const void *src, size_t n)
234{ 234{
235 int i; 235 int d0, d1, d2;
236 const char *s = src; 236 asm volatile(
237 char *d = dest; 237 "rep ; movsl\n\t"
238 "movl %4,%%ecx\n\t"
239 "rep ; movsb\n\t"
240 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
241 : "0" (n >> 2), "g" (n & 3), "1" (dest), "2" (src)
242 : "memory");
238 243
239 for (i = 0; i < n; i++)
240 d[i] = s[i];
241 return dest; 244 return dest;
242} 245}
246#else
247void *memcpy(void *dest, const void *src, size_t n)
248{
249 long d0, d1, d2;
250 asm volatile(
251 "rep ; movsq\n\t"
252 "movq %4,%%rcx\n\t"
253 "rep ; movsb\n\t"
254 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
255 : "0" (n >> 3), "g" (n & 7), "1" (dest), "2" (src)
256 : "memory");
243 257
258 return dest;
259}
260#endif
244 261
245static void error(char *x) 262static void error(char *x)
246{ 263{
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
index 0350311906ae..2d93bdbc9ac0 100644
--- a/arch/x86/ia32/ia32_aout.c
+++ b/arch/x86/ia32/ia32_aout.c
@@ -34,7 +34,7 @@
34#include <asm/ia32.h> 34#include <asm/ia32.h>
35 35
36#undef WARN_OLD 36#undef WARN_OLD
37#undef CORE_DUMP /* probably broken */ 37#undef CORE_DUMP /* definitely broken */
38 38
39static int load_aout_binary(struct linux_binprm *, struct pt_regs *regs); 39static int load_aout_binary(struct linux_binprm *, struct pt_regs *regs);
40static int load_aout_library(struct file *); 40static int load_aout_library(struct file *);
@@ -131,21 +131,15 @@ static void set_brk(unsigned long start, unsigned long end)
131 * macros to write out all the necessary info. 131 * macros to write out all the necessary info.
132 */ 132 */
133 133
134static int dump_write(struct file *file, const void *addr, int nr) 134#include <linux/coredump.h>
135{
136 return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
137}
138 135
139#define DUMP_WRITE(addr, nr) \ 136#define DUMP_WRITE(addr, nr) \
140 if (!dump_write(file, (void *)(addr), (nr))) \ 137 if (!dump_write(file, (void *)(addr), (nr))) \
141 goto end_coredump; 138 goto end_coredump;
142 139
143#define DUMP_SEEK(offset) \ 140#define DUMP_SEEK(offset) \
144 if (file->f_op->llseek) { \ 141 if (!dump_seek(file, offset)) \
145 if (file->f_op->llseek(file, (offset), 0) != (offset)) \ 142 goto end_coredump;
146 goto end_coredump; \
147 } else \
148 file->f_pos = (offset)
149 143
150#define START_DATA() (u.u_tsize << PAGE_SHIFT) 144#define START_DATA() (u.u_tsize << PAGE_SHIFT)
151#define START_STACK(u) (u.start_stack) 145#define START_STACK(u) (u.start_stack)
@@ -217,12 +211,6 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
217 dump_size = dump.u_ssize << PAGE_SHIFT; 211 dump_size = dump.u_ssize << PAGE_SHIFT;
218 DUMP_WRITE(dump_start, dump_size); 212 DUMP_WRITE(dump_start, dump_size);
219 } 213 }
220 /*
221 * Finally dump the task struct. Not be used by gdb, but
222 * could be useful
223 */
224 set_fs(KERNEL_DS);
225 DUMP_WRITE(current, sizeof(*current));
226end_coredump: 214end_coredump:
227 set_fs(fs); 215 set_fs(fs);
228 return has_dumped; 216 return has_dumped;
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index bc6abb7bc7ee..76561d20ea2f 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -4,6 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/stddef.h> 5#include <linux/stddef.h>
6#include <linux/stringify.h> 6#include <linux/stringify.h>
7#include <linux/jump_label.h>
7#include <asm/asm.h> 8#include <asm/asm.h>
8 9
9/* 10/*
@@ -160,6 +161,8 @@ static inline void apply_paravirt(struct paravirt_patch_site *start,
160#define __parainstructions_end NULL 161#define __parainstructions_end NULL
161#endif 162#endif
162 163
164extern void *text_poke_early(void *addr, const void *opcode, size_t len);
165
163/* 166/*
164 * Clear and restore the kernel write-protection flag on the local CPU. 167 * Clear and restore the kernel write-protection flag on the local CPU.
165 * Allows the kernel to edit read-only pages. 168 * Allows the kernel to edit read-only pages.
@@ -180,4 +183,12 @@ static inline void apply_paravirt(struct paravirt_patch_site *start,
180extern void *text_poke(void *addr, const void *opcode, size_t len); 183extern void *text_poke(void *addr, const void *opcode, size_t len);
181extern void *text_poke_smp(void *addr, const void *opcode, size_t len); 184extern void *text_poke_smp(void *addr, const void *opcode, size_t len);
182 185
186#if defined(CONFIG_DYNAMIC_FTRACE) || defined(HAVE_JUMP_LABEL)
187#define IDEAL_NOP_SIZE_5 5
188extern unsigned char ideal_nop5[IDEAL_NOP_SIZE_5];
189extern void arch_init_ideal_nop5(void);
190#else
191static inline void arch_init_ideal_nop5(void) {}
192#endif
193
183#endif /* _ASM_X86_ALTERNATIVE_H */ 194#endif /* _ASM_X86_ALTERNATIVE_H */
diff --git a/arch/x86/include/asm/amd_iommu.h b/arch/x86/include/asm/amd_iommu.h
index 5af2982133b5..a6863a2dec1f 100644
--- a/arch/x86/include/asm/amd_iommu.h
+++ b/arch/x86/include/asm/amd_iommu.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2009 Advanced Micro Devices, Inc. 2 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com> 3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 * Leo Duran <leo.duran@amd.com> 4 * Leo Duran <leo.duran@amd.com>
5 * 5 *
@@ -24,11 +24,11 @@
24 24
25#ifdef CONFIG_AMD_IOMMU 25#ifdef CONFIG_AMD_IOMMU
26 26
27extern void amd_iommu_detect(void); 27extern int amd_iommu_detect(void);
28 28
29#else 29#else
30 30
31static inline void amd_iommu_detect(void) { } 31static inline int amd_iommu_detect(void) { return -ENODEV; }
32 32
33#endif 33#endif
34 34
diff --git a/arch/x86/include/asm/amd_iommu_proto.h b/arch/x86/include/asm/amd_iommu_proto.h
index cb030374b90a..916bc8111a01 100644
--- a/arch/x86/include/asm/amd_iommu_proto.h
+++ b/arch/x86/include/asm/amd_iommu_proto.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2009 Advanced Micro Devices, Inc. 2 * Copyright (C) 2009-2010 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com> 3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h
index 08616180deaf..e3509fc303bf 100644
--- a/arch/x86/include/asm/amd_iommu_types.h
+++ b/arch/x86/include/asm/amd_iommu_types.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2009 Advanced Micro Devices, Inc. 2 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com> 3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 * Leo Duran <leo.duran@amd.com> 4 * Leo Duran <leo.duran@amd.com>
5 * 5 *
@@ -416,13 +416,22 @@ struct amd_iommu {
416 struct dma_ops_domain *default_dom; 416 struct dma_ops_domain *default_dom;
417 417
418 /* 418 /*
419 * This array is required to work around a potential BIOS bug. 419 * We can't rely on the BIOS to restore all values on reinit, so we
420 * The BIOS may miss to restore parts of the PCI configuration 420 * need to stash them
421 * space when the system resumes from S3. The result is that the
422 * IOMMU does not execute commands anymore which leads to system
423 * failure.
424 */ 421 */
425 u32 cache_cfg[4]; 422
423 /* The iommu BAR */
424 u32 stored_addr_lo;
425 u32 stored_addr_hi;
426
427 /*
428 * Each iommu has 6 l1s, each of which is documented as having 0x12
429 * registers
430 */
431 u32 stored_l1[6][0x12];
432
433 /* The l2 indirect registers */
434 u32 stored_l2[0x83];
426}; 435};
427 436
428/* 437/*
diff --git a/arch/x86/include/asm/k8.h b/arch/x86/include/asm/amd_nb.h
index af00bd1d2089..c8517f81b21e 100644
--- a/arch/x86/include/asm/k8.h
+++ b/arch/x86/include/asm/amd_nb.h
@@ -1,5 +1,5 @@
1#ifndef _ASM_X86_K8_H 1#ifndef _ASM_X86_AMD_NB_H
2#define _ASM_X86_K8_H 2#define _ASM_X86_AMD_NB_H
3 3
4#include <linux/pci.h> 4#include <linux/pci.h>
5 5
@@ -7,24 +7,27 @@ extern struct pci_device_id k8_nb_ids[];
7struct bootnode; 7struct bootnode;
8 8
9extern int early_is_k8_nb(u32 value); 9extern int early_is_k8_nb(u32 value);
10extern struct pci_dev **k8_northbridges;
11extern int num_k8_northbridges;
12extern int cache_k8_northbridges(void); 10extern int cache_k8_northbridges(void);
13extern void k8_flush_garts(void); 11extern void k8_flush_garts(void);
14extern int k8_get_nodes(struct bootnode *nodes); 12extern int k8_get_nodes(struct bootnode *nodes);
15extern int k8_numa_init(unsigned long start_pfn, unsigned long end_pfn); 13extern int k8_numa_init(unsigned long start_pfn, unsigned long end_pfn);
16extern int k8_scan_nodes(void); 14extern int k8_scan_nodes(void);
17 15
18#ifdef CONFIG_K8_NB 16struct k8_northbridge_info {
19extern int num_k8_northbridges; 17 u16 num;
18 u8 gart_supported;
19 struct pci_dev **nb_misc;
20};
21extern struct k8_northbridge_info k8_northbridges;
22
23#ifdef CONFIG_AMD_NB
20 24
21static inline struct pci_dev *node_to_k8_nb_misc(int node) 25static inline struct pci_dev *node_to_k8_nb_misc(int node)
22{ 26{
23 return (node < num_k8_northbridges) ? k8_northbridges[node] : NULL; 27 return (node < k8_northbridges.num) ? k8_northbridges.nb_misc[node] : NULL;
24} 28}
25 29
26#else 30#else
27#define num_k8_northbridges 0
28 31
29static inline struct pci_dev *node_to_k8_nb_misc(int node) 32static inline struct pci_dev *node_to_k8_nb_misc(int node)
30{ 33{
@@ -33,4 +36,4 @@ static inline struct pci_dev *node_to_k8_nb_misc(int node)
33#endif 36#endif
34 37
35 38
36#endif /* _ASM_X86_K8_H */ 39#endif /* _ASM_X86_AMD_NB_H */
diff --git a/arch/x86/include/asm/apb_timer.h b/arch/x86/include/asm/apb_timer.h
index a69b1ac9eaf8..2fefa501d3ba 100644
--- a/arch/x86/include/asm/apb_timer.h
+++ b/arch/x86/include/asm/apb_timer.h
@@ -54,7 +54,6 @@ extern struct clock_event_device *global_clock_event;
54extern unsigned long apbt_quick_calibrate(void); 54extern unsigned long apbt_quick_calibrate(void);
55extern int arch_setup_apbt_irqs(int irq, int trigger, int mask, int cpu); 55extern int arch_setup_apbt_irqs(int irq, int trigger, int mask, int cpu);
56extern void apbt_setup_secondary_clock(void); 56extern void apbt_setup_secondary_clock(void);
57extern unsigned int boot_cpu_id;
58 57
59extern struct sfi_timer_table_entry *sfi_get_mtmr(int hint); 58extern struct sfi_timer_table_entry *sfi_get_mtmr(int hint);
60extern void sfi_free_mtmr(struct sfi_timer_table_entry *mtmr); 59extern void sfi_free_mtmr(struct sfi_timer_table_entry *mtmr);
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 1fa03e04ae44..286de34b0ed6 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -252,9 +252,7 @@ static inline int apic_is_clustered_box(void)
252} 252}
253#endif 253#endif
254 254
255extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask); 255extern int setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask);
256extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
257
258 256
259#else /* !CONFIG_X86_LOCAL_APIC */ 257#else /* !CONFIG_X86_LOCAL_APIC */
260static inline void lapic_shutdown(void) { } 258static inline void lapic_shutdown(void) { }
diff --git a/arch/x86/include/asm/apicdef.h b/arch/x86/include/asm/apicdef.h
index 7fe3b3060f08..a859ca461fb0 100644
--- a/arch/x86/include/asm/apicdef.h
+++ b/arch/x86/include/asm/apicdef.h
@@ -131,6 +131,7 @@
131#define APIC_EILVTn(n) (0x500 + 0x10 * n) 131#define APIC_EILVTn(n) (0x500 + 0x10 * n)
132#define APIC_EILVT_NR_AMD_K8 1 /* # of extended interrupts */ 132#define APIC_EILVT_NR_AMD_K8 1 /* # of extended interrupts */
133#define APIC_EILVT_NR_AMD_10H 4 133#define APIC_EILVT_NR_AMD_10H 4
134#define APIC_EILVT_NR_MAX APIC_EILVT_NR_AMD_10H
134#define APIC_EILVT_LVTOFF(x) (((x) >> 4) & 0xF) 135#define APIC_EILVT_LVTOFF(x) (((x) >> 4) & 0xF)
135#define APIC_EILVT_MSG_FIX 0x0 136#define APIC_EILVT_MSG_FIX 0x0
136#define APIC_EILVT_MSG_SMI 0x2 137#define APIC_EILVT_MSG_SMI 0x2
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index bafd80defa43..903683b07e42 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -440,6 +440,8 @@ static inline int fls(int x)
440 440
441#ifdef __KERNEL__ 441#ifdef __KERNEL__
442 442
443#include <asm-generic/bitops/find.h>
444
443#include <asm-generic/bitops/sched.h> 445#include <asm-generic/bitops/sched.h>
444 446
445#define ARCH_HAS_FAST_MULTIPLIER 1 447#define ARCH_HAS_FAST_MULTIPLIER 1
diff --git a/arch/x86/include/asm/calgary.h b/arch/x86/include/asm/calgary.h
index 0918654305af..0d467b338835 100644
--- a/arch/x86/include/asm/calgary.h
+++ b/arch/x86/include/asm/calgary.h
@@ -62,9 +62,9 @@ struct cal_chipset_ops {
62extern int use_calgary; 62extern int use_calgary;
63 63
64#ifdef CONFIG_CALGARY_IOMMU 64#ifdef CONFIG_CALGARY_IOMMU
65extern void detect_calgary(void); 65extern int detect_calgary(void);
66#else 66#else
67static inline void detect_calgary(void) { return; } 67static inline int detect_calgary(void) { return -ENODEV; }
68#endif 68#endif
69 69
70#endif /* _ASM_X86_CALGARY_H */ 70#endif /* _ASM_X86_CALGARY_H */
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 0e63c9a2a8d0..30af5a832163 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -48,36 +48,38 @@ For 32-bit we have the following conventions - kernel is built with
48 48
49 49
50/* 50/*
51 * 64-bit system call stack frame layout defines and helpers, 51 * 64-bit system call stack frame layout defines and helpers, for
52 * for assembly code: 52 * assembly code (note that the seemingly unnecessary parentheses
53 * are to prevent cpp from inserting spaces in expressions that get
54 * passed to macros):
53 */ 55 */
54 56
55#define R15 0 57#define R15 (0)
56#define R14 8 58#define R14 (8)
57#define R13 16 59#define R13 (16)
58#define R12 24 60#define R12 (24)
59#define RBP 32 61#define RBP (32)
60#define RBX 40 62#define RBX (40)
61 63
62/* arguments: interrupts/non tracing syscalls only save up to here: */ 64/* arguments: interrupts/non tracing syscalls only save up to here: */
63#define R11 48 65#define R11 (48)
64#define R10 56 66#define R10 (56)
65#define R9 64 67#define R9 (64)
66#define R8 72 68#define R8 (72)
67#define RAX 80 69#define RAX (80)
68#define RCX 88 70#define RCX (88)
69#define RDX 96 71#define RDX (96)
70#define RSI 104 72#define RSI (104)
71#define RDI 112 73#define RDI (112)
72#define ORIG_RAX 120 /* + error_code */ 74#define ORIG_RAX (120) /* + error_code */
73/* end of arguments */ 75/* end of arguments */
74 76
75/* cpu exception frame or undefined in case of fast syscall: */ 77/* cpu exception frame or undefined in case of fast syscall: */
76#define RIP 128 78#define RIP (128)
77#define CS 136 79#define CS (136)
78#define EFLAGS 144 80#define EFLAGS (144)
79#define RSP 152 81#define RSP (152)
80#define SS 160 82#define SS (160)
81 83
82#define ARGOFFSET R11 84#define ARGOFFSET R11
83#define SWFRAME ORIG_RAX 85#define SWFRAME ORIG_RAX
@@ -111,7 +113,7 @@ For 32-bit we have the following conventions - kernel is built with
111 .endif 113 .endif
112 .endm 114 .endm
113 115
114#define ARG_SKIP 9*8 116#define ARG_SKIP (9*8)
115 117
116 .macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \ 118 .macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
117 skipr8910=0, skiprdx=0 119 skipr8910=0, skiprdx=0
@@ -169,7 +171,7 @@ For 32-bit we have the following conventions - kernel is built with
169 .endif 171 .endif
170 .endm 172 .endm
171 173
172#define REST_SKIP 6*8 174#define REST_SKIP (6*8)
173 175
174 .macro SAVE_REST 176 .macro SAVE_REST
175 subq $REST_SKIP, %rsp 177 subq $REST_SKIP, %rsp
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index b185091bf19c..4fab24de26b1 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -32,6 +32,5 @@ extern void arch_unregister_cpu(int);
32 32
33DECLARE_PER_CPU(int, cpu_state); 33DECLARE_PER_CPU(int, cpu_state);
34 34
35extern unsigned int boot_cpu_id;
36 35
37#endif /* _ASM_X86_CPU_H */ 36#endif /* _ASM_X86_CPU_H */
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 3f76523589af..220e2ea08e80 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -152,10 +152,14 @@
152#define X86_FEATURE_3DNOWPREFETCH (6*32+ 8) /* 3DNow prefetch instructions */ 152#define X86_FEATURE_3DNOWPREFETCH (6*32+ 8) /* 3DNow prefetch instructions */
153#define X86_FEATURE_OSVW (6*32+ 9) /* OS Visible Workaround */ 153#define X86_FEATURE_OSVW (6*32+ 9) /* OS Visible Workaround */
154#define X86_FEATURE_IBS (6*32+10) /* Instruction Based Sampling */ 154#define X86_FEATURE_IBS (6*32+10) /* Instruction Based Sampling */
155#define X86_FEATURE_SSE5 (6*32+11) /* SSE-5 */ 155#define X86_FEATURE_XOP (6*32+11) /* extended AVX instructions */
156#define X86_FEATURE_SKINIT (6*32+12) /* SKINIT/STGI instructions */ 156#define X86_FEATURE_SKINIT (6*32+12) /* SKINIT/STGI instructions */
157#define X86_FEATURE_WDT (6*32+13) /* Watchdog timer */ 157#define X86_FEATURE_WDT (6*32+13) /* Watchdog timer */
158#define X86_FEATURE_LWP (6*32+15) /* Light Weight Profiling */
159#define X86_FEATURE_FMA4 (6*32+16) /* 4 operands MAC instructions */
158#define X86_FEATURE_NODEID_MSR (6*32+19) /* NodeId MSR */ 160#define X86_FEATURE_NODEID_MSR (6*32+19) /* NodeId MSR */
161#define X86_FEATURE_TBM (6*32+21) /* trailing bit manipulations */
162#define X86_FEATURE_TOPOEXT (6*32+22) /* topology extensions CPUID leafs */
159 163
160/* 164/*
161 * Auxiliary flags: Linux defined - For features scattered in various 165 * Auxiliary flags: Linux defined - For features scattered in various
@@ -180,6 +184,13 @@
180#define X86_FEATURE_LBRV (8*32+ 6) /* AMD LBR Virtualization support */ 184#define X86_FEATURE_LBRV (8*32+ 6) /* AMD LBR Virtualization support */
181#define X86_FEATURE_SVML (8*32+ 7) /* "svm_lock" AMD SVM locking MSR */ 185#define X86_FEATURE_SVML (8*32+ 7) /* "svm_lock" AMD SVM locking MSR */
182#define X86_FEATURE_NRIPS (8*32+ 8) /* "nrip_save" AMD SVM next_rip save */ 186#define X86_FEATURE_NRIPS (8*32+ 8) /* "nrip_save" AMD SVM next_rip save */
187#define X86_FEATURE_TSCRATEMSR (8*32+ 9) /* "tsc_scale" AMD TSC scaling support */
188#define X86_FEATURE_VMCBCLEAN (8*32+10) /* "vmcb_clean" AMD VMCB clean bits support */
189#define X86_FEATURE_FLUSHBYASID (8*32+11) /* AMD flush-by-ASID support */
190#define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
191#define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
192#define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
193
183 194
184/* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */ 195/* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
185#define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/ 196#define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
diff --git a/arch/x86/include/asm/dwarf2.h b/arch/x86/include/asm/dwarf2.h
index 733f7e91e7a9..326099199318 100644
--- a/arch/x86/include/asm/dwarf2.h
+++ b/arch/x86/include/asm/dwarf2.h
@@ -89,6 +89,16 @@
89 CFI_ADJUST_CFA_OFFSET -8 89 CFI_ADJUST_CFA_OFFSET -8
90 .endm 90 .endm
91 91
92 .macro pushfq_cfi
93 pushfq
94 CFI_ADJUST_CFA_OFFSET 8
95 .endm
96
97 .macro popfq_cfi
98 popfq
99 CFI_ADJUST_CFA_OFFSET -8
100 .endm
101
92 .macro movq_cfi reg offset=0 102 .macro movq_cfi reg offset=0
93 movq %\reg, \offset(%rsp) 103 movq %\reg, \offset(%rsp)
94 CFI_REL_OFFSET \reg, \offset 104 CFI_REL_OFFSET \reg, \offset
@@ -109,6 +119,16 @@
109 CFI_ADJUST_CFA_OFFSET -4 119 CFI_ADJUST_CFA_OFFSET -4
110 .endm 120 .endm
111 121
122 .macro pushfl_cfi
123 pushfl
124 CFI_ADJUST_CFA_OFFSET 4
125 .endm
126
127 .macro popfl_cfi
128 popfl
129 CFI_ADJUST_CFA_OFFSET -4
130 .endm
131
112 .macro movl_cfi reg offset=0 132 .macro movl_cfi reg offset=0
113 movl %\reg, \offset(%esp) 133 movl %\reg, \offset(%esp)
114 CFI_REL_OFFSET \reg, \offset 134 CFI_REL_OFFSET \reg, \offset
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index ec8a52d14ab1..5be1542fbfaf 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -112,23 +112,13 @@ static inline void early_memtest(unsigned long start, unsigned long end)
112} 112}
113#endif 113#endif
114 114
115extern unsigned long end_user_pfn;
116
117extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align);
118extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align);
119extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
120#include <linux/early_res.h>
121
122extern unsigned long e820_end_of_ram_pfn(void); 115extern unsigned long e820_end_of_ram_pfn(void);
123extern unsigned long e820_end_of_low_ram_pfn(void); 116extern unsigned long e820_end_of_low_ram_pfn(void);
124extern int e820_find_active_region(const struct e820entry *ei, 117extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
125 unsigned long start_pfn, 118
126 unsigned long last_pfn, 119void memblock_x86_fill(void);
127 unsigned long *ei_startpfn, 120void memblock_find_dma_reserve(void);
128 unsigned long *ei_endpfn); 121
129extern void e820_register_active_regions(int nid, unsigned long start_pfn,
130 unsigned long end_pfn);
131extern u64 e820_hole_size(u64 start, u64 end);
132extern void finish_e820_parsing(void); 122extern void finish_e820_parsing(void);
133extern void e820_reserve_resources(void); 123extern void e820_reserve_resources(void);
134extern void e820_reserve_resources_late(void); 124extern void e820_reserve_resources_late(void);
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 8406ed7f9926..8e4a16508d4e 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -90,7 +90,7 @@ extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
90#endif /* CONFIG_X86_32 */ 90#endif /* CONFIG_X86_32 */
91 91
92extern int add_efi_memmap; 92extern int add_efi_memmap;
93extern void efi_reserve_early(void); 93extern void efi_memblock_x86_reserve_range(void);
94extern void efi_call_phys_prelog(void); 94extern void efi_call_phys_prelog(void);
95extern void efi_call_phys_epilog(void); 95extern void efi_call_phys_epilog(void);
96 96
diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index 8e8ec663a98f..57650ab4a5f5 100644
--- a/arch/x86/include/asm/entry_arch.h
+++ b/arch/x86/include/asm/entry_arch.h
@@ -16,22 +16,11 @@ BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR)
16BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) 16BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR)
17BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR) 17BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
18 18
19BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0, 19.irpc idx, "01234567"
20 smp_invalidate_interrupt) 20BUILD_INTERRUPT3(invalidate_interrupt\idx,
21BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1, 21 (INVALIDATE_TLB_VECTOR_START)+\idx,
22 smp_invalidate_interrupt)
23BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2,
24 smp_invalidate_interrupt)
25BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3,
26 smp_invalidate_interrupt)
27BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4,
28 smp_invalidate_interrupt)
29BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5,
30 smp_invalidate_interrupt)
31BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6,
32 smp_invalidate_interrupt)
33BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7,
34 smp_invalidate_interrupt) 22 smp_invalidate_interrupt)
23.endr
35#endif 24#endif
36 25
37BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR) 26BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
@@ -49,8 +38,8 @@ BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR)
49BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR) 38BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR)
50BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR) 39BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR)
51 40
52#ifdef CONFIG_PERF_EVENTS 41#ifdef CONFIG_IRQ_WORK
53BUILD_INTERRUPT(perf_pending_interrupt, LOCAL_PENDING_VECTOR) 42BUILD_INTERRUPT(irq_work_interrupt, IRQ_WORK_VECTOR)
54#endif 43#endif
55 44
56#ifdef CONFIG_X86_THERMAL_VECTOR 45#ifdef CONFIG_X86_THERMAL_VECTOR
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index d07b44f7d1dc..4d293dced62f 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -214,5 +214,20 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
214 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); 214 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
215 return __virt_to_fix(vaddr); 215 return __virt_to_fix(vaddr);
216} 216}
217
218/* Return an pointer with offset calculated */
219static inline unsigned long __set_fixmap_offset(enum fixed_addresses idx,
220 phys_addr_t phys, pgprot_t flags)
221{
222 __set_fixmap(idx, phys, flags);
223 return fix_to_virt(idx) + (phys & (PAGE_SIZE - 1));
224}
225
226#define set_fixmap_offset(idx, phys) \
227 __set_fixmap_offset(idx, phys, PAGE_KERNEL)
228
229#define set_fixmap_offset_nocache(idx, phys) \
230 __set_fixmap_offset(idx, phys, PAGE_KERNEL_NOCACHE)
231
217#endif /* !__ASSEMBLY__ */ 232#endif /* !__ASSEMBLY__ */
218#endif /* _ASM_X86_FIXMAP_H */ 233#endif /* _ASM_X86_FIXMAP_H */
diff --git a/arch/x86/include/asm/gart.h b/arch/x86/include/asm/gart.h
index 4ac5b0f33fc1..43085bfc99c3 100644
--- a/arch/x86/include/asm/gart.h
+++ b/arch/x86/include/asm/gart.h
@@ -17,6 +17,7 @@ extern int fix_aperture;
17#define GARTEN (1<<0) 17#define GARTEN (1<<0)
18#define DISGARTCPU (1<<4) 18#define DISGARTCPU (1<<4)
19#define DISGARTIO (1<<5) 19#define DISGARTIO (1<<5)
20#define DISTLBWALKPRB (1<<6)
20 21
21/* GART cache control register bits. */ 22/* GART cache control register bits. */
22#define INVGART (1<<0) 23#define INVGART (1<<0)
@@ -27,7 +28,6 @@ extern int fix_aperture;
27#define AMD64_GARTAPERTUREBASE 0x94 28#define AMD64_GARTAPERTUREBASE 0x94
28#define AMD64_GARTTABLEBASE 0x98 29#define AMD64_GARTTABLEBASE 0x98
29#define AMD64_GARTCACHECTL 0x9c 30#define AMD64_GARTCACHECTL 0x9c
30#define AMD64_GARTEN (1<<0)
31 31
32#ifdef CONFIG_GART_IOMMU 32#ifdef CONFIG_GART_IOMMU
33extern int gart_iommu_aperture; 33extern int gart_iommu_aperture;
@@ -37,7 +37,7 @@ extern int gart_iommu_aperture_disabled;
37extern void early_gart_iommu_check(void); 37extern void early_gart_iommu_check(void);
38extern int gart_iommu_init(void); 38extern int gart_iommu_init(void);
39extern void __init gart_parse_options(char *); 39extern void __init gart_parse_options(char *);
40extern void gart_iommu_hole_init(void); 40extern int gart_iommu_hole_init(void);
41 41
42#else 42#else
43#define gart_iommu_aperture 0 43#define gart_iommu_aperture 0
@@ -50,13 +50,27 @@ static inline void early_gart_iommu_check(void)
50static inline void gart_parse_options(char *options) 50static inline void gart_parse_options(char *options)
51{ 51{
52} 52}
53static inline void gart_iommu_hole_init(void) 53static inline int gart_iommu_hole_init(void)
54{ 54{
55 return -ENODEV;
55} 56}
56#endif 57#endif
57 58
58extern int agp_amd64_init(void); 59extern int agp_amd64_init(void);
59 60
61static inline void gart_set_size_and_enable(struct pci_dev *dev, u32 order)
62{
63 u32 ctl;
64
65 /*
66 * Don't enable translation but enable GART IO and CPU accesses.
67 * Also, set DISTLBWALKPRB since GART tables memory is UC.
68 */
69 ctl = DISTLBWALKPRB | order << 1;
70
71 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, ctl);
72}
73
60static inline void enable_gart_translation(struct pci_dev *dev, u64 addr) 74static inline void enable_gart_translation(struct pci_dev *dev, u64 addr)
61{ 75{
62 u32 tmp, ctl; 76 u32 tmp, ctl;
diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h
index aeab29aee617..55e4de613f0e 100644
--- a/arch/x86/include/asm/hardirq.h
+++ b/arch/x86/include/asm/hardirq.h
@@ -14,7 +14,7 @@ typedef struct {
14#endif 14#endif
15 unsigned int x86_platform_ipis; /* arch dependent */ 15 unsigned int x86_platform_ipis; /* arch dependent */
16 unsigned int apic_perf_irqs; 16 unsigned int apic_perf_irqs;
17 unsigned int apic_pending_irqs; 17 unsigned int apic_irq_work_irqs;
18#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
19 unsigned int irq_resched_count; 19 unsigned int irq_resched_count;
20 unsigned int irq_call_count; 20 unsigned int irq_call_count;
diff --git a/arch/x86/include/asm/hpet.h b/arch/x86/include/asm/hpet.h
index 1d5c08a1bdfd..2c392d663dce 100644
--- a/arch/x86/include/asm/hpet.h
+++ b/arch/x86/include/asm/hpet.h
@@ -74,10 +74,12 @@ extern void hpet_disable(void);
74extern unsigned int hpet_readl(unsigned int a); 74extern unsigned int hpet_readl(unsigned int a);
75extern void force_hpet_resume(void); 75extern void force_hpet_resume(void);
76 76
77extern void hpet_msi_unmask(unsigned int irq); 77struct irq_data;
78extern void hpet_msi_mask(unsigned int irq); 78extern void hpet_msi_unmask(struct irq_data *data);
79extern void hpet_msi_write(unsigned int irq, struct msi_msg *msg); 79extern void hpet_msi_mask(struct irq_data *data);
80extern void hpet_msi_read(unsigned int irq, struct msi_msg *msg); 80struct hpet_dev;
81extern void hpet_msi_write(struct hpet_dev *hdev, struct msi_msg *msg);
82extern void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg);
81 83
82#ifdef CONFIG_PCI_MSI 84#ifdef CONFIG_PCI_MSI
83extern int arch_setup_hpet_msi(unsigned int irq, unsigned int id); 85extern int arch_setup_hpet_msi(unsigned int irq, unsigned int id);
diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index 46c0fe05f230..0274ec5a7e62 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -29,7 +29,7 @@
29extern void apic_timer_interrupt(void); 29extern void apic_timer_interrupt(void);
30extern void x86_platform_ipi(void); 30extern void x86_platform_ipi(void);
31extern void error_interrupt(void); 31extern void error_interrupt(void);
32extern void perf_pending_interrupt(void); 32extern void irq_work_interrupt(void);
33 33
34extern void spurious_interrupt(void); 34extern void spurious_interrupt(void);
35extern void thermal_interrupt(void); 35extern void thermal_interrupt(void);
@@ -78,6 +78,13 @@ static inline void set_io_apic_irq_attr(struct io_apic_irq_attr *irq_attr,
78 irq_attr->polarity = polarity; 78 irq_attr->polarity = polarity;
79} 79}
80 80
81struct irq_2_iommu {
82 struct intel_iommu *iommu;
83 u16 irte_index;
84 u16 sub_handle;
85 u8 irte_mask;
86};
87
81/* 88/*
82 * This is performance-critical, we want to do it O(1) 89 * This is performance-critical, we want to do it O(1)
83 * 90 *
@@ -89,15 +96,17 @@ struct irq_cfg {
89 cpumask_var_t old_domain; 96 cpumask_var_t old_domain;
90 u8 vector; 97 u8 vector;
91 u8 move_in_progress : 1; 98 u8 move_in_progress : 1;
99#ifdef CONFIG_INTR_REMAP
100 struct irq_2_iommu irq_2_iommu;
101#endif
92}; 102};
93 103
94extern struct irq_cfg *irq_cfg(unsigned int);
95extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *); 104extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
96extern void send_cleanup_vector(struct irq_cfg *); 105extern void send_cleanup_vector(struct irq_cfg *);
97 106
98struct irq_desc; 107struct irq_data;
99extern unsigned int set_desc_affinity(struct irq_desc *, const struct cpumask *, 108int __ioapic_set_affinity(struct irq_data *, const struct cpumask *,
100 unsigned int *dest_id); 109 unsigned int *dest_id);
101extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin, struct io_apic_irq_attr *irq_attr); 110extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin, struct io_apic_irq_attr *irq_attr);
102extern void setup_ioapic_dest(void); 111extern void setup_ioapic_dest(void);
103 112
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index a73a8d5a5e69..4aa2bb3b242a 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -55,6 +55,12 @@ extern int save_i387_xstate_ia32(void __user *buf);
55extern int restore_i387_xstate_ia32(void __user *buf); 55extern int restore_i387_xstate_ia32(void __user *buf);
56#endif 56#endif
57 57
58#ifdef CONFIG_MATH_EMULATION
59extern void finit_soft_fpu(struct i387_soft_struct *soft);
60#else
61static inline void finit_soft_fpu(struct i387_soft_struct *soft) {}
62#endif
63
58#define X87_FSW_ES (1 << 7) /* Exception Summary */ 64#define X87_FSW_ES (1 << 7) /* Exception Summary */
59 65
60static __always_inline __pure bool use_xsaveopt(void) 66static __always_inline __pure bool use_xsaveopt(void)
@@ -67,6 +73,11 @@ static __always_inline __pure bool use_xsave(void)
67 return static_cpu_has(X86_FEATURE_XSAVE); 73 return static_cpu_has(X86_FEATURE_XSAVE);
68} 74}
69 75
76static __always_inline __pure bool use_fxsr(void)
77{
78 return static_cpu_has(X86_FEATURE_FXSR);
79}
80
70extern void __sanitize_i387_state(struct task_struct *); 81extern void __sanitize_i387_state(struct task_struct *);
71 82
72static inline void sanitize_i387_state(struct task_struct *tsk) 83static inline void sanitize_i387_state(struct task_struct *tsk)
@@ -77,19 +88,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
77} 88}
78 89
79#ifdef CONFIG_X86_64 90#ifdef CONFIG_X86_64
80
81/* Ignore delayed exceptions from user space */
82static inline void tolerant_fwait(void)
83{
84 asm volatile("1: fwait\n"
85 "2:\n"
86 _ASM_EXTABLE(1b, 2b));
87}
88
89static inline int fxrstor_checking(struct i387_fxsave_struct *fx) 91static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
90{ 92{
91 int err; 93 int err;
92 94
95 /* See comment in fxsave() below. */
93 asm volatile("1: rex64/fxrstor (%[fx])\n\t" 96 asm volatile("1: rex64/fxrstor (%[fx])\n\t"
94 "2:\n" 97 "2:\n"
95 ".section .fixup,\"ax\"\n" 98 ".section .fixup,\"ax\"\n"
@@ -98,44 +101,10 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
98 ".previous\n" 101 ".previous\n"
99 _ASM_EXTABLE(1b, 3b) 102 _ASM_EXTABLE(1b, 3b)
100 : [err] "=r" (err) 103 : [err] "=r" (err)
101#if 0 /* See comment in fxsave() below. */ 104 : [fx] "R" (fx), "m" (*fx), "0" (0));
102 : [fx] "r" (fx), "m" (*fx), "0" (0));
103#else
104 : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));
105#endif
106 return err; 105 return err;
107} 106}
108 107
109/* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
110 is pending. Clear the x87 state here by setting it to fixed
111 values. The kernel data segment can be sometimes 0 and sometimes
112 new user value. Both should be ok.
113 Use the PDA as safe address because it should be already in L1. */
114static inline void fpu_clear(struct fpu *fpu)
115{
116 struct xsave_struct *xstate = &fpu->state->xsave;
117 struct i387_fxsave_struct *fx = &fpu->state->fxsave;
118
119 /*
120 * xsave header may indicate the init state of the FP.
121 */
122 if (use_xsave() &&
123 !(xstate->xsave_hdr.xstate_bv & XSTATE_FP))
124 return;
125
126 if (unlikely(fx->swd & X87_FSW_ES))
127 asm volatile("fnclex");
128 alternative_input(ASM_NOP8 ASM_NOP2,
129 " emms\n" /* clear stack tags */
130 " fildl %%gs:0", /* load to clear state */
131 X86_FEATURE_FXSAVE_LEAK);
132}
133
134static inline void clear_fpu_state(struct task_struct *tsk)
135{
136 fpu_clear(&tsk->thread.fpu);
137}
138
139static inline int fxsave_user(struct i387_fxsave_struct __user *fx) 108static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
140{ 109{
141 int err; 110 int err;
@@ -149,6 +118,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
149 if (unlikely(err)) 118 if (unlikely(err))
150 return -EFAULT; 119 return -EFAULT;
151 120
121 /* See comment in fxsave() below. */
152 asm volatile("1: rex64/fxsave (%[fx])\n\t" 122 asm volatile("1: rex64/fxsave (%[fx])\n\t"
153 "2:\n" 123 "2:\n"
154 ".section .fixup,\"ax\"\n" 124 ".section .fixup,\"ax\"\n"
@@ -157,11 +127,7 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
157 ".previous\n" 127 ".previous\n"
158 _ASM_EXTABLE(1b, 3b) 128 _ASM_EXTABLE(1b, 3b)
159 : [err] "=r" (err), "=m" (*fx) 129 : [err] "=r" (err), "=m" (*fx)
160#if 0 /* See comment in fxsave() below. */ 130 : [fx] "R" (fx), "0" (0));
161 : [fx] "r" (fx), "0" (0));
162#else
163 : [fx] "cdaSDb" (fx), "0" (0));
164#endif
165 if (unlikely(err) && 131 if (unlikely(err) &&
166 __clear_user(fx, sizeof(struct i387_fxsave_struct))) 132 __clear_user(fx, sizeof(struct i387_fxsave_struct)))
167 err = -EFAULT; 133 err = -EFAULT;
@@ -175,56 +141,29 @@ static inline void fpu_fxsave(struct fpu *fpu)
175 uses any extended registers for addressing, a second REX prefix 141 uses any extended registers for addressing, a second REX prefix
176 will be generated (to the assembler, rex64 followed by semicolon 142 will be generated (to the assembler, rex64 followed by semicolon
177 is a separate instruction), and hence the 64-bitness is lost. */ 143 is a separate instruction), and hence the 64-bitness is lost. */
178#if 0 144
145#ifdef CONFIG_AS_FXSAVEQ
179 /* Using "fxsaveq %0" would be the ideal choice, but is only supported 146 /* Using "fxsaveq %0" would be the ideal choice, but is only supported
180 starting with gas 2.16. */ 147 starting with gas 2.16. */
181 __asm__ __volatile__("fxsaveq %0" 148 __asm__ __volatile__("fxsaveq %0"
182 : "=m" (fpu->state->fxsave)); 149 : "=m" (fpu->state->fxsave));
183#elif 0 150#else
184 /* Using, as a workaround, the properly prefixed form below isn't 151 /* Using, as a workaround, the properly prefixed form below isn't
185 accepted by any binutils version so far released, complaining that 152 accepted by any binutils version so far released, complaining that
186 the same type of prefix is used twice if an extended register is 153 the same type of prefix is used twice if an extended register is
187 needed for addressing (fix submitted to mainline 2005-11-21). */ 154 needed for addressing (fix submitted to mainline 2005-11-21).
188 __asm__ __volatile__("rex64/fxsave %0" 155 asm volatile("rex64/fxsave %0"
189 : "=m" (fpu->state->fxsave)); 156 : "=m" (fpu->state->fxsave));
190#else 157 This, however, we can work around by forcing the compiler to select
191 /* This, however, we can work around by forcing the compiler to select
192 an addressing mode that doesn't require extended registers. */ 158 an addressing mode that doesn't require extended registers. */
193 __asm__ __volatile__("rex64/fxsave (%1)" 159 asm volatile("rex64/fxsave (%[fx])"
194 : "=m" (fpu->state->fxsave) 160 : "=m" (fpu->state->fxsave)
195 : "cdaSDb" (&fpu->state->fxsave)); 161 : [fx] "R" (&fpu->state->fxsave));
196#endif 162#endif
197} 163}
198 164
199static inline void fpu_save_init(struct fpu *fpu)
200{
201 if (use_xsave())
202 fpu_xsave(fpu);
203 else
204 fpu_fxsave(fpu);
205
206 fpu_clear(fpu);
207}
208
209static inline void __save_init_fpu(struct task_struct *tsk)
210{
211 fpu_save_init(&tsk->thread.fpu);
212 task_thread_info(tsk)->status &= ~TS_USEDFPU;
213}
214
215#else /* CONFIG_X86_32 */ 165#else /* CONFIG_X86_32 */
216 166
217#ifdef CONFIG_MATH_EMULATION
218extern void finit_soft_fpu(struct i387_soft_struct *soft);
219#else
220static inline void finit_soft_fpu(struct i387_soft_struct *soft) {}
221#endif
222
223static inline void tolerant_fwait(void)
224{
225 asm volatile("fnclex ; fwait");
226}
227
228/* perform fxrstor iff the processor has extended states, otherwise frstor */ 167/* perform fxrstor iff the processor has extended states, otherwise frstor */
229static inline int fxrstor_checking(struct i387_fxsave_struct *fx) 168static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
230{ 169{
@@ -241,6 +180,14 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
241 return 0; 180 return 0;
242} 181}
243 182
183static inline void fpu_fxsave(struct fpu *fpu)
184{
185 asm volatile("fxsave %[fx]"
186 : [fx] "=m" (fpu->state->fxsave));
187}
188
189#endif /* CONFIG_X86_64 */
190
244/* We need a safe address that is cheap to find and that is already 191/* We need a safe address that is cheap to find and that is already
245 in L1 during context switch. The best choices are unfortunately 192 in L1 during context switch. The best choices are unfortunately
246 different for UP and SMP */ 193 different for UP and SMP */
@@ -256,47 +203,33 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
256static inline void fpu_save_init(struct fpu *fpu) 203static inline void fpu_save_init(struct fpu *fpu)
257{ 204{
258 if (use_xsave()) { 205 if (use_xsave()) {
259 struct xsave_struct *xstate = &fpu->state->xsave;
260 struct i387_fxsave_struct *fx = &fpu->state->fxsave;
261
262 fpu_xsave(fpu); 206 fpu_xsave(fpu);
263 207
264 /* 208 /*
265 * xsave header may indicate the init state of the FP. 209 * xsave header may indicate the init state of the FP.
266 */ 210 */
267 if (!(xstate->xsave_hdr.xstate_bv & XSTATE_FP)) 211 if (!(fpu->state->xsave.xsave_hdr.xstate_bv & XSTATE_FP))
268 goto end; 212 return;
269 213 } else if (use_fxsr()) {
270 if (unlikely(fx->swd & X87_FSW_ES)) 214 fpu_fxsave(fpu);
271 asm volatile("fnclex"); 215 } else {
272 216 asm volatile("fsave %[fx]; fwait"
273 /* 217 : [fx] "=m" (fpu->state->fsave));
274 * we can do a simple return here or be paranoid :) 218 return;
275 */
276 goto clear_state;
277 } 219 }
278 220
279 /* Use more nops than strictly needed in case the compiler 221 if (unlikely(fpu->state->fxsave.swd & X87_FSW_ES))
280 varies code */ 222 asm volatile("fnclex");
281 alternative_input( 223
282 "fnsave %[fx] ;fwait;" GENERIC_NOP8 GENERIC_NOP4,
283 "fxsave %[fx]\n"
284 "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:",
285 X86_FEATURE_FXSR,
286 [fx] "m" (fpu->state->fxsave),
287 [fsw] "m" (fpu->state->fxsave.swd) : "memory");
288clear_state:
289 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception 224 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
290 is pending. Clear the x87 state here by setting it to fixed 225 is pending. Clear the x87 state here by setting it to fixed
291 values. safe_address is a random variable that should be in L1 */ 226 values. safe_address is a random variable that should be in L1 */
292 alternative_input( 227 alternative_input(
293 GENERIC_NOP8 GENERIC_NOP2, 228 ASM_NOP8 ASM_NOP2,
294 "emms\n\t" /* clear stack tags */ 229 "emms\n\t" /* clear stack tags */
295 "fildl %[addr]", /* set F?P to defined value */ 230 "fildl %P[addr]", /* set F?P to defined value */
296 X86_FEATURE_FXSAVE_LEAK, 231 X86_FEATURE_FXSAVE_LEAK,
297 [addr] "m" (safe_address)); 232 [addr] "m" (safe_address));
298end:
299 ;
300} 233}
301 234
302static inline void __save_init_fpu(struct task_struct *tsk) 235static inline void __save_init_fpu(struct task_struct *tsk)
@@ -305,9 +238,6 @@ static inline void __save_init_fpu(struct task_struct *tsk)
305 task_thread_info(tsk)->status &= ~TS_USEDFPU; 238 task_thread_info(tsk)->status &= ~TS_USEDFPU;
306} 239}
307 240
308
309#endif /* CONFIG_X86_64 */
310
311static inline int fpu_fxrstor_checking(struct fpu *fpu) 241static inline int fpu_fxrstor_checking(struct fpu *fpu)
312{ 242{
313 return fxrstor_checking(&fpu->state->fxsave); 243 return fxrstor_checking(&fpu->state->fxsave);
@@ -344,7 +274,10 @@ static inline void __unlazy_fpu(struct task_struct *tsk)
344static inline void __clear_fpu(struct task_struct *tsk) 274static inline void __clear_fpu(struct task_struct *tsk)
345{ 275{
346 if (task_thread_info(tsk)->status & TS_USEDFPU) { 276 if (task_thread_info(tsk)->status & TS_USEDFPU) {
347 tolerant_fwait(); 277 /* Ignore delayed exceptions from user space */
278 asm volatile("1: fwait\n"
279 "2:\n"
280 _ASM_EXTABLE(1b, 2b));
348 task_thread_info(tsk)->status &= ~TS_USEDFPU; 281 task_thread_info(tsk)->status &= ~TS_USEDFPU;
349 stts(); 282 stts();
350 } 283 }
@@ -405,19 +338,6 @@ static inline void irq_ts_restore(int TS_state)
405 stts(); 338 stts();
406} 339}
407 340
408#ifdef CONFIG_X86_64
409
410static inline void save_init_fpu(struct task_struct *tsk)
411{
412 __save_init_fpu(tsk);
413 stts();
414}
415
416#define unlazy_fpu __unlazy_fpu
417#define clear_fpu __clear_fpu
418
419#else /* CONFIG_X86_32 */
420
421/* 341/*
422 * These disable preemption on their own and are safe 342 * These disable preemption on their own and are safe
423 */ 343 */
@@ -443,8 +363,6 @@ static inline void clear_fpu(struct task_struct *tsk)
443 preempt_enable(); 363 preempt_enable();
444} 364}
445 365
446#endif /* CONFIG_X86_64 */
447
448/* 366/*
449 * i387 state interaction 367 * i387 state interaction
450 */ 368 */
@@ -508,7 +426,4 @@ extern void fpu_finit(struct fpu *fpu);
508 426
509#endif /* __ASSEMBLY__ */ 427#endif /* __ASSEMBLY__ */
510 428
511#define PSHUFB_XMM5_XMM0 .byte 0x66, 0x0f, 0x38, 0x00, 0xc5
512#define PSHUFB_XMM5_XMM6 .byte 0x66, 0x0f, 0x38, 0x00, 0xf5
513
514#endif /* _ASM_X86_I387_H */ 429#endif /* _ASM_X86_I387_H */
diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
index 1655147646aa..a20365953bf8 100644
--- a/arch/x86/include/asm/i8259.h
+++ b/arch/x86/include/asm/i8259.h
@@ -55,6 +55,8 @@ extern struct irq_chip i8259A_chip;
55struct legacy_pic { 55struct legacy_pic {
56 int nr_legacy_irqs; 56 int nr_legacy_irqs;
57 struct irq_chip *chip; 57 struct irq_chip *chip;
58 void (*mask)(unsigned int irq);
59 void (*unmask)(unsigned int irq);
58 void (*mask_all)(void); 60 void (*mask_all)(void);
59 void (*restore_mask)(void); 61 void (*restore_mask)(void);
60 void (*init)(int auto_eoi); 62 void (*init)(int auto_eoi);
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 30a3e9776123..f0203f4791a8 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -206,6 +206,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
206 206
207extern void iounmap(volatile void __iomem *addr); 207extern void iounmap(volatile void __iomem *addr);
208 208
209extern void set_iounmap_nonlazy(void);
209 210
210#ifdef __KERNEL__ 211#ifdef __KERNEL__
211 212
@@ -348,6 +349,7 @@ extern void __iomem *early_memremap(resource_size_t phys_addr,
348 unsigned long size); 349 unsigned long size);
349extern void early_iounmap(void __iomem *addr, unsigned long size); 350extern void early_iounmap(void __iomem *addr, unsigned long size);
350extern void fixup_early_ioremap(void); 351extern void fixup_early_ioremap(void);
352extern bool is_early_ioremap_ptep(pte_t *ptep);
351 353
352#define IO_SPACE_LIMIT 0xffff 354#define IO_SPACE_LIMIT 0xffff
353 355
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 9cb2edb87c2f..c8be4566c3d2 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -170,12 +170,6 @@ extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
170 170
171extern void probe_nr_irqs_gsi(void); 171extern void probe_nr_irqs_gsi(void);
172 172
173extern int setup_ioapic_entry(int apic, int irq,
174 struct IO_APIC_route_entry *entry,
175 unsigned int destination, int trigger,
176 int polarity, int vector, int pin);
177extern void ioapic_write_entry(int apic, int pin,
178 struct IO_APIC_route_entry e);
179extern void setup_ioapic_ids_from_mpc(void); 173extern void setup_ioapic_ids_from_mpc(void);
180 174
181struct mp_ioapic_gsi{ 175struct mp_ioapic_gsi{
diff --git a/arch/x86/include/asm/iommu_table.h b/arch/x86/include/asm/iommu_table.h
new file mode 100644
index 000000000000..f229b13a5f30
--- /dev/null
+++ b/arch/x86/include/asm/iommu_table.h
@@ -0,0 +1,100 @@
1#ifndef _ASM_X86_IOMMU_TABLE_H
2#define _ASM_X86_IOMMU_TABLE_H
3
4#include <asm/swiotlb.h>
5
6/*
7 * History lesson:
8 * The execution chain of IOMMUs in 2.6.36 looks as so:
9 *
10 * [xen-swiotlb]
11 * |
12 * +----[swiotlb *]--+
13 * / | \
14 * / | \
15 * [GART] [Calgary] [Intel VT-d]
16 * /
17 * /
18 * [AMD-Vi]
19 *
20 * *: if SWIOTLB detected 'iommu=soft'/'swiotlb=force' it would skip
21 * over the rest of IOMMUs and unconditionally initialize the SWIOTLB.
22 * Also it would surreptitiously initialize set the swiotlb=1 if there were
23 * more than 4GB and if the user did not pass in 'iommu=off'. The swiotlb
24 * flag would be turned off by all IOMMUs except the Calgary one.
25 *
26 * The IOMMU_INIT* macros allow a similar tree (or more complex if desired)
27 * to be built by defining who we depend on.
28 *
29 * And all that needs to be done is to use one of the macros in the IOMMU
30 * and the pci-dma.c will take care of the rest.
31 */
32
33struct iommu_table_entry {
34 initcall_t detect;
35 initcall_t depend;
36 void (*early_init)(void); /* No memory allocate available. */
37 void (*late_init)(void); /* Yes, can allocate memory. */
38#define IOMMU_FINISH_IF_DETECTED (1<<0)
39#define IOMMU_DETECTED (1<<1)
40 int flags;
41};
42/*
43 * Macro fills out an entry in the .iommu_table that is equivalent
44 * to the fields that 'struct iommu_table_entry' has. The entries
45 * that are put in the .iommu_table section are not put in any order
46 * hence during boot-time we will have to resort them based on
47 * dependency. */
48
49
50#define __IOMMU_INIT(_detect, _depend, _early_init, _late_init, _finish)\
51 static const struct iommu_table_entry const \
52 __iommu_entry_##_detect __used \
53 __attribute__ ((unused, __section__(".iommu_table"), \
54 aligned((sizeof(void *))))) \
55 = {_detect, _depend, _early_init, _late_init, \
56 _finish ? IOMMU_FINISH_IF_DETECTED : 0}
57/*
58 * The simplest IOMMU definition. Provide the detection routine
59 * and it will be run after the SWIOTLB and the other IOMMUs
60 * that utilize this macro. If the IOMMU is detected (ie, the
61 * detect routine returns a positive value), the other IOMMUs
62 * are also checked. You can use IOMMU_INIT_POST_FINISH if you prefer
63 * to stop detecting the other IOMMUs after yours has been detected.
64 */
65#define IOMMU_INIT_POST(_detect) \
66 __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 0)
67
68#define IOMMU_INIT_POST_FINISH(detect) \
69 __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 1)
70
71/*
72 * A more sophisticated version of IOMMU_INIT. This variant requires:
73 * a). A detection routine function.
74 * b). The name of the detection routine we depend on to get called
75 * before us.
76 * c). The init routine which gets called if the detection routine
77 * returns a positive value from the pci_iommu_alloc. This means
78 * no presence of a memory allocator.
79 * d). Similar to the 'init', except that this gets called from pci_iommu_init
80 * where we do have a memory allocator.
81 *
82 * The standard vs the _FINISH differs in that the _FINISH variant will
83 * continue detecting other IOMMUs in the call list after the
84 * the detection routine returns a positive number. The _FINISH will
85 * stop the execution chain. Both will still call the 'init' and
86 * 'late_init' functions if they are set.
87 */
88#define IOMMU_INIT_FINISH(_detect, _depend, _init, _late_init) \
89 __IOMMU_INIT(_detect, _depend, _init, _late_init, 1)
90
91#define IOMMU_INIT(_detect, _depend, _init, _late_init) \
92 __IOMMU_INIT(_detect, _depend, _init, _late_init, 0)
93
94void sort_iommu_table(struct iommu_table_entry *start,
95 struct iommu_table_entry *finish);
96
97void check_iommu_entries(struct iommu_table_entry *start,
98 struct iommu_table_entry *finish);
99
100#endif /* _ASM_X86_IOMMU_TABLE_H */
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 5458380b6ef8..0bf5b0083650 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -19,18 +19,16 @@ static inline int irq_canonicalize(int irq)
19# define ARCH_HAS_NMI_WATCHDOG 19# define ARCH_HAS_NMI_WATCHDOG
20#endif 20#endif
21 21
22#ifdef CONFIG_4KSTACKS 22#ifdef CONFIG_X86_32
23 extern void irq_ctx_init(int cpu); 23extern void irq_ctx_init(int cpu);
24 extern void irq_ctx_exit(int cpu); 24extern void irq_ctx_exit(int cpu);
25# define __ARCH_HAS_DO_SOFTIRQ
26#else 25#else
27# define irq_ctx_init(cpu) do { } while (0) 26# define irq_ctx_init(cpu) do { } while (0)
28# define irq_ctx_exit(cpu) do { } while (0) 27# define irq_ctx_exit(cpu) do { } while (0)
29# ifdef CONFIG_X86_64
30# define __ARCH_HAS_DO_SOFTIRQ
31# endif
32#endif 28#endif
33 29
30#define __ARCH_HAS_DO_SOFTIRQ
31
34#ifdef CONFIG_HOTPLUG_CPU 32#ifdef CONFIG_HOTPLUG_CPU
35#include <linux/cpumask.h> 33#include <linux/cpumask.h>
36extern void fixup_irqs(void); 34extern void fixup_irqs(void);
diff --git a/arch/x86/include/asm/irq_remapping.h b/arch/x86/include/asm/irq_remapping.h
index f275e2244505..1c23360fb2d8 100644
--- a/arch/x86/include/asm/irq_remapping.h
+++ b/arch/x86/include/asm/irq_remapping.h
@@ -3,4 +3,39 @@
3 3
4#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8) 4#define IRTE_DEST(dest) ((x2apic_mode) ? dest : dest << 8)
5 5
6#ifdef CONFIG_INTR_REMAP
7static inline void prepare_irte(struct irte *irte, int vector,
8 unsigned int dest)
9{
10 memset(irte, 0, sizeof(*irte));
11
12 irte->present = 1;
13 irte->dst_mode = apic->irq_dest_mode;
14 /*
15 * Trigger mode in the IRTE will always be edge, and for IO-APIC, the
16 * actual level or edge trigger will be setup in the IO-APIC
17 * RTE. This will help simplify level triggered irq migration.
18 * For more details, see the comments (in io_apic.c) explainig IO-APIC
19 * irq migration in the presence of interrupt-remapping.
20 */
21 irte->trigger_mode = 0;
22 irte->dlvry_mode = apic->irq_delivery_mode;
23 irte->vector = vector;
24 irte->dest_id = IRTE_DEST(dest);
25 irte->redir_hint = 1;
26}
27static inline bool irq_remapped(struct irq_cfg *cfg)
28{
29 return cfg->irq_2_iommu.iommu != NULL;
30}
31#else
32static void prepare_irte(struct irte *irte, int vector, unsigned int dest)
33{
34}
35static inline bool irq_remapped(struct irq_cfg *cfg)
36{
37 return false;
38}
39#endif
40
6#endif /* _ASM_X86_IRQ_REMAPPING_H */ 41#endif /* _ASM_X86_IRQ_REMAPPING_H */
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index e2ca30092557..6af0894dafb4 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -114,9 +114,9 @@
114#define X86_PLATFORM_IPI_VECTOR 0xed 114#define X86_PLATFORM_IPI_VECTOR 0xed
115 115
116/* 116/*
117 * Performance monitoring pending work vector: 117 * IRQ work vector:
118 */ 118 */
119#define LOCAL_PENDING_VECTOR 0xec 119#define IRQ_WORK_VECTOR 0xec
120 120
121#define UV_BAU_MESSAGE 0xea 121#define UV_BAU_MESSAGE 0xea
122 122
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
index 9e2b952f810a..5745ce8bf108 100644
--- a/arch/x86/include/asm/irqflags.h
+++ b/arch/x86/include/asm/irqflags.h
@@ -61,22 +61,22 @@ static inline void native_halt(void)
61#else 61#else
62#ifndef __ASSEMBLY__ 62#ifndef __ASSEMBLY__
63 63
64static inline unsigned long __raw_local_save_flags(void) 64static inline unsigned long arch_local_save_flags(void)
65{ 65{
66 return native_save_fl(); 66 return native_save_fl();
67} 67}
68 68
69static inline void raw_local_irq_restore(unsigned long flags) 69static inline void arch_local_irq_restore(unsigned long flags)
70{ 70{
71 native_restore_fl(flags); 71 native_restore_fl(flags);
72} 72}
73 73
74static inline void raw_local_irq_disable(void) 74static inline void arch_local_irq_disable(void)
75{ 75{
76 native_irq_disable(); 76 native_irq_disable();
77} 77}
78 78
79static inline void raw_local_irq_enable(void) 79static inline void arch_local_irq_enable(void)
80{ 80{
81 native_irq_enable(); 81 native_irq_enable();
82} 82}
@@ -85,7 +85,7 @@ static inline void raw_local_irq_enable(void)
85 * Used in the idle loop; sti takes one instruction cycle 85 * Used in the idle loop; sti takes one instruction cycle
86 * to complete: 86 * to complete:
87 */ 87 */
88static inline void raw_safe_halt(void) 88static inline void arch_safe_halt(void)
89{ 89{
90 native_safe_halt(); 90 native_safe_halt();
91} 91}
@@ -102,12 +102,10 @@ static inline void halt(void)
102/* 102/*
103 * For spinlocks, etc: 103 * For spinlocks, etc:
104 */ 104 */
105static inline unsigned long __raw_local_irq_save(void) 105static inline unsigned long arch_local_irq_save(void)
106{ 106{
107 unsigned long flags = __raw_local_save_flags(); 107 unsigned long flags = arch_local_save_flags();
108 108 arch_local_irq_disable();
109 raw_local_irq_disable();
110
111 return flags; 109 return flags;
112} 110}
113#else 111#else
@@ -153,22 +151,16 @@ static inline unsigned long __raw_local_irq_save(void)
153#endif /* CONFIG_PARAVIRT */ 151#endif /* CONFIG_PARAVIRT */
154 152
155#ifndef __ASSEMBLY__ 153#ifndef __ASSEMBLY__
156#define raw_local_save_flags(flags) \ 154static inline int arch_irqs_disabled_flags(unsigned long flags)
157 do { (flags) = __raw_local_save_flags(); } while (0)
158
159#define raw_local_irq_save(flags) \
160 do { (flags) = __raw_local_irq_save(); } while (0)
161
162static inline int raw_irqs_disabled_flags(unsigned long flags)
163{ 155{
164 return !(flags & X86_EFLAGS_IF); 156 return !(flags & X86_EFLAGS_IF);
165} 157}
166 158
167static inline int raw_irqs_disabled(void) 159static inline int arch_irqs_disabled(void)
168{ 160{
169 unsigned long flags = __raw_local_save_flags(); 161 unsigned long flags = arch_local_save_flags();
170 162
171 return raw_irqs_disabled_flags(flags); 163 return arch_irqs_disabled_flags(flags);
172} 164}
173 165
174#else 166#else
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
new file mode 100644
index 000000000000..f52d42e80585
--- /dev/null
+++ b/arch/x86/include/asm/jump_label.h
@@ -0,0 +1,37 @@
1#ifndef _ASM_X86_JUMP_LABEL_H
2#define _ASM_X86_JUMP_LABEL_H
3
4#ifdef __KERNEL__
5
6#include <linux/types.h>
7#include <asm/nops.h>
8
9#define JUMP_LABEL_NOP_SIZE 5
10
11# define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
12
13# define JUMP_LABEL(key, label) \
14 do { \
15 asm goto("1:" \
16 JUMP_LABEL_INITIAL_NOP \
17 ".pushsection __jump_table, \"a\" \n\t"\
18 _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
19 ".popsection \n\t" \
20 : : "i" (key) : : label); \
21 } while (0)
22
23#endif /* __KERNEL__ */
24
25#ifdef CONFIG_X86_64
26typedef u64 jump_label_t;
27#else
28typedef u32 jump_label_t;
29#endif
30
31struct jump_entry {
32 jump_label_t code;
33 jump_label_t target;
34 jump_label_t key;
35};
36
37#endif
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 1f99ecfc48e1..b36c6b3fe144 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -139,6 +139,7 @@ struct x86_emulate_ops {
139 void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu); 139 void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu);
140 unsigned long (*get_cached_segment_base)(int seg, struct kvm_vcpu *vcpu); 140 unsigned long (*get_cached_segment_base)(int seg, struct kvm_vcpu *vcpu);
141 void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu); 141 void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu);
142 void (*get_idt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu);
142 ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu); 143 ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu);
143 int (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); 144 int (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
144 int (*cpl)(struct kvm_vcpu *vcpu); 145 int (*cpl)(struct kvm_vcpu *vcpu);
@@ -156,7 +157,10 @@ struct operand {
156 unsigned long orig_val; 157 unsigned long orig_val;
157 u64 orig_val64; 158 u64 orig_val64;
158 }; 159 };
159 unsigned long *ptr; 160 union {
161 unsigned long *reg;
162 unsigned long mem;
163 } addr;
160 union { 164 union {
161 unsigned long val; 165 unsigned long val;
162 u64 val64; 166 u64 val64;
@@ -190,6 +194,7 @@ struct decode_cache {
190 bool has_seg_override; 194 bool has_seg_override;
191 u8 seg_override; 195 u8 seg_override;
192 unsigned int d; 196 unsigned int d;
197 int (*execute)(struct x86_emulate_ctxt *ctxt);
193 unsigned long regs[NR_VCPU_REGS]; 198 unsigned long regs[NR_VCPU_REGS];
194 unsigned long eip; 199 unsigned long eip;
195 /* modrm */ 200 /* modrm */
@@ -197,17 +202,16 @@ struct decode_cache {
197 u8 modrm_mod; 202 u8 modrm_mod;
198 u8 modrm_reg; 203 u8 modrm_reg;
199 u8 modrm_rm; 204 u8 modrm_rm;
200 u8 use_modrm_ea; 205 u8 modrm_seg;
201 bool rip_relative; 206 bool rip_relative;
202 unsigned long modrm_ea;
203 void *modrm_ptr;
204 unsigned long modrm_val;
205 struct fetch_cache fetch; 207 struct fetch_cache fetch;
206 struct read_cache io_read; 208 struct read_cache io_read;
207 struct read_cache mem_read; 209 struct read_cache mem_read;
208}; 210};
209 211
210struct x86_emulate_ctxt { 212struct x86_emulate_ctxt {
213 struct x86_emulate_ops *ops;
214
211 /* Register state before/after emulation. */ 215 /* Register state before/after emulation. */
212 struct kvm_vcpu *vcpu; 216 struct kvm_vcpu *vcpu;
213 217
@@ -220,12 +224,11 @@ struct x86_emulate_ctxt {
220 /* interruptibility state, as a result of execution of STI or MOV SS */ 224 /* interruptibility state, as a result of execution of STI or MOV SS */
221 int interruptibility; 225 int interruptibility;
222 226
223 bool restart; /* restart string instruction after writeback */ 227 bool perm_ok; /* do not check permissions if true */
224 228
225 int exception; /* exception that happens during emulation or -1 */ 229 int exception; /* exception that happens during emulation or -1 */
226 u32 error_code; /* error code for exception */ 230 u32 error_code; /* error code for exception */
227 bool error_code_valid; 231 bool error_code_valid;
228 unsigned long cr2; /* faulted address in case of #PF */
229 232
230 /* decode cache */ 233 /* decode cache */
231 struct decode_cache decode; 234 struct decode_cache decode;
@@ -249,13 +252,14 @@ struct x86_emulate_ctxt {
249#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 252#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
250#endif 253#endif
251 254
252int x86_decode_insn(struct x86_emulate_ctxt *ctxt, 255int x86_decode_insn(struct x86_emulate_ctxt *ctxt);
253 struct x86_emulate_ops *ops); 256#define EMULATION_FAILED -1
254int x86_emulate_insn(struct x86_emulate_ctxt *ctxt, 257#define EMULATION_OK 0
255 struct x86_emulate_ops *ops); 258#define EMULATION_RESTART 1
259int x86_emulate_insn(struct x86_emulate_ctxt *ctxt);
256int emulator_task_switch(struct x86_emulate_ctxt *ctxt, 260int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
257 struct x86_emulate_ops *ops,
258 u16 tss_selector, int reason, 261 u16 tss_selector, int reason,
259 bool has_error_code, u32 error_code); 262 bool has_error_code, u32 error_code);
260 263int emulate_int_real(struct x86_emulate_ctxt *ctxt,
264 struct x86_emulate_ops *ops, int irq);
261#endif /* _ASM_X86_KVM_X86_EMULATE_H */ 265#endif /* _ASM_X86_KVM_X86_EMULATE_H */
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 502e53f999cf..9e6fe391094e 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -236,10 +236,14 @@ struct kvm_pio_request {
236 */ 236 */
237struct kvm_mmu { 237struct kvm_mmu {
238 void (*new_cr3)(struct kvm_vcpu *vcpu); 238 void (*new_cr3)(struct kvm_vcpu *vcpu);
239 void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root);
240 unsigned long (*get_cr3)(struct kvm_vcpu *vcpu);
239 int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err); 241 int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err);
242 void (*inject_page_fault)(struct kvm_vcpu *vcpu);
240 void (*free)(struct kvm_vcpu *vcpu); 243 void (*free)(struct kvm_vcpu *vcpu);
241 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, 244 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access,
242 u32 *error); 245 u32 *error);
246 gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access);
243 void (*prefetch_page)(struct kvm_vcpu *vcpu, 247 void (*prefetch_page)(struct kvm_vcpu *vcpu,
244 struct kvm_mmu_page *page); 248 struct kvm_mmu_page *page);
245 int (*sync_page)(struct kvm_vcpu *vcpu, 249 int (*sync_page)(struct kvm_vcpu *vcpu,
@@ -249,13 +253,18 @@ struct kvm_mmu {
249 int root_level; 253 int root_level;
250 int shadow_root_level; 254 int shadow_root_level;
251 union kvm_mmu_page_role base_role; 255 union kvm_mmu_page_role base_role;
256 bool direct_map;
252 257
253 u64 *pae_root; 258 u64 *pae_root;
259 u64 *lm_root;
254 u64 rsvd_bits_mask[2][4]; 260 u64 rsvd_bits_mask[2][4];
261
262 bool nx;
263
264 u64 pdptrs[4]; /* pae */
255}; 265};
256 266
257struct kvm_vcpu_arch { 267struct kvm_vcpu_arch {
258 u64 host_tsc;
259 /* 268 /*
260 * rip and regs accesses must go through 269 * rip and regs accesses must go through
261 * kvm_{register,rip}_{read,write} functions. 270 * kvm_{register,rip}_{read,write} functions.
@@ -272,7 +281,6 @@ struct kvm_vcpu_arch {
272 unsigned long cr4_guest_owned_bits; 281 unsigned long cr4_guest_owned_bits;
273 unsigned long cr8; 282 unsigned long cr8;
274 u32 hflags; 283 u32 hflags;
275 u64 pdptrs[4]; /* pae */
276 u64 efer; 284 u64 efer;
277 u64 apic_base; 285 u64 apic_base;
278 struct kvm_lapic *apic; /* kernel irqchip context */ 286 struct kvm_lapic *apic; /* kernel irqchip context */
@@ -282,7 +290,41 @@ struct kvm_vcpu_arch {
282 u64 ia32_misc_enable_msr; 290 u64 ia32_misc_enable_msr;
283 bool tpr_access_reporting; 291 bool tpr_access_reporting;
284 292
293 /*
294 * Paging state of the vcpu
295 *
296 * If the vcpu runs in guest mode with two level paging this still saves
297 * the paging mode of the l1 guest. This context is always used to
298 * handle faults.
299 */
285 struct kvm_mmu mmu; 300 struct kvm_mmu mmu;
301
302 /*
303 * Paging state of an L2 guest (used for nested npt)
304 *
305 * This context will save all necessary information to walk page tables
306 * of the an L2 guest. This context is only initialized for page table
307 * walking and not for faulting since we never handle l2 page faults on
308 * the host.
309 */
310 struct kvm_mmu nested_mmu;
311
312 /*
313 * Pointer to the mmu context currently used for
314 * gva_to_gpa translations.
315 */
316 struct kvm_mmu *walk_mmu;
317
318 /*
319 * This struct is filled with the necessary information to propagate a
320 * page fault into the guest
321 */
322 struct {
323 u64 address;
324 unsigned error_code;
325 bool nested;
326 } fault;
327
286 /* only needed in kvm_pv_mmu_op() path, but it's hot so 328 /* only needed in kvm_pv_mmu_op() path, but it's hot so
287 * put it here to avoid allocation */ 329 * put it here to avoid allocation */
288 struct kvm_pv_mmu_op_buffer mmu_op_buffer; 330 struct kvm_pv_mmu_op_buffer mmu_op_buffer;
@@ -336,9 +378,15 @@ struct kvm_vcpu_arch {
336 378
337 gpa_t time; 379 gpa_t time;
338 struct pvclock_vcpu_time_info hv_clock; 380 struct pvclock_vcpu_time_info hv_clock;
339 unsigned int hv_clock_tsc_khz; 381 unsigned int hw_tsc_khz;
340 unsigned int time_offset; 382 unsigned int time_offset;
341 struct page *time_page; 383 struct page *time_page;
384 u64 last_host_tsc;
385 u64 last_guest_tsc;
386 u64 last_kernel_ns;
387 u64 last_tsc_nsec;
388 u64 last_tsc_write;
389 bool tsc_catchup;
342 390
343 bool nmi_pending; 391 bool nmi_pending;
344 bool nmi_injected; 392 bool nmi_injected;
@@ -367,9 +415,9 @@ struct kvm_vcpu_arch {
367}; 415};
368 416
369struct kvm_arch { 417struct kvm_arch {
370 unsigned int n_free_mmu_pages; 418 unsigned int n_used_mmu_pages;
371 unsigned int n_requested_mmu_pages; 419 unsigned int n_requested_mmu_pages;
372 unsigned int n_alloc_mmu_pages; 420 unsigned int n_max_mmu_pages;
373 atomic_t invlpg_counter; 421 atomic_t invlpg_counter;
374 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; 422 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
375 /* 423 /*
@@ -394,8 +442,14 @@ struct kvm_arch {
394 gpa_t ept_identity_map_addr; 442 gpa_t ept_identity_map_addr;
395 443
396 unsigned long irq_sources_bitmap; 444 unsigned long irq_sources_bitmap;
397 u64 vm_init_tsc;
398 s64 kvmclock_offset; 445 s64 kvmclock_offset;
446 spinlock_t tsc_write_lock;
447 u64 last_tsc_nsec;
448 u64 last_tsc_offset;
449 u64 last_tsc_write;
450 u32 virtual_tsc_khz;
451 u32 virtual_tsc_mult;
452 s8 virtual_tsc_shift;
399 453
400 struct kvm_xen_hvm_config xen_hvm_config; 454 struct kvm_xen_hvm_config xen_hvm_config;
401 455
@@ -505,6 +559,7 @@ struct kvm_x86_ops {
505 void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr, 559 void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
506 bool has_error_code, u32 error_code, 560 bool has_error_code, u32 error_code,
507 bool reinject); 561 bool reinject);
562 void (*cancel_injection)(struct kvm_vcpu *vcpu);
508 int (*interrupt_allowed)(struct kvm_vcpu *vcpu); 563 int (*interrupt_allowed)(struct kvm_vcpu *vcpu);
509 int (*nmi_allowed)(struct kvm_vcpu *vcpu); 564 int (*nmi_allowed)(struct kvm_vcpu *vcpu);
510 bool (*get_nmi_mask)(struct kvm_vcpu *vcpu); 565 bool (*get_nmi_mask)(struct kvm_vcpu *vcpu);
@@ -517,11 +572,16 @@ struct kvm_x86_ops {
517 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); 572 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
518 int (*get_lpage_level)(void); 573 int (*get_lpage_level)(void);
519 bool (*rdtscp_supported)(void); 574 bool (*rdtscp_supported)(void);
575 void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment);
576
577 void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
520 578
521 void (*set_supported_cpuid)(u32 func, struct kvm_cpuid_entry2 *entry); 579 void (*set_supported_cpuid)(u32 func, struct kvm_cpuid_entry2 *entry);
522 580
523 bool (*has_wbinvd_exit)(void); 581 bool (*has_wbinvd_exit)(void);
524 582
583 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset);
584
525 const struct trace_print_flags *exit_reasons_str; 585 const struct trace_print_flags *exit_reasons_str;
526}; 586};
527 587
@@ -544,7 +604,7 @@ void kvm_mmu_zap_all(struct kvm *kvm);
544unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); 604unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
545void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); 605void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
546 606
547int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); 607int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3);
548 608
549int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, 609int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
550 const void *val, int bytes); 610 const void *val, int bytes);
@@ -608,8 +668,11 @@ void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr);
608void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); 668void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
609void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr); 669void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr);
610void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); 670void kvm_requeue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
611void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, 671void kvm_inject_page_fault(struct kvm_vcpu *vcpu);
612 u32 error_code); 672int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
673 gfn_t gfn, void *data, int offset, int len,
674 u32 access);
675void kvm_propagate_fault(struct kvm_vcpu *vcpu);
613bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); 676bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl);
614 677
615int kvm_pic_set_irq(void *opaque, int irq, int level); 678int kvm_pic_set_irq(void *opaque, int irq, int level);
@@ -652,20 +715,6 @@ static inline struct kvm_mmu_page *page_header(hpa_t shadow_page)
652 return (struct kvm_mmu_page *)page_private(page); 715 return (struct kvm_mmu_page *)page_private(page);
653} 716}
654 717
655static inline u16 kvm_read_fs(void)
656{
657 u16 seg;
658 asm("mov %%fs, %0" : "=g"(seg));
659 return seg;
660}
661
662static inline u16 kvm_read_gs(void)
663{
664 u16 seg;
665 asm("mov %%gs, %0" : "=g"(seg));
666 return seg;
667}
668
669static inline u16 kvm_read_ldt(void) 718static inline u16 kvm_read_ldt(void)
670{ 719{
671 u16 ldt; 720 u16 ldt;
@@ -673,16 +722,6 @@ static inline u16 kvm_read_ldt(void)
673 return ldt; 722 return ldt;
674} 723}
675 724
676static inline void kvm_load_fs(u16 sel)
677{
678 asm("mov %0, %%fs" : : "rm"(sel));
679}
680
681static inline void kvm_load_gs(u16 sel)
682{
683 asm("mov %0, %%gs" : : "rm"(sel));
684}
685
686static inline void kvm_load_ldt(u16 sel) 725static inline void kvm_load_ldt(u16 sel)
687{ 726{
688 asm("lldt %0" : : "rm"(sel)); 727 asm("lldt %0" : : "rm"(sel));
diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
index 05eba5e9a8e8..7b562b6184bc 100644
--- a/arch/x86/include/asm/kvm_para.h
+++ b/arch/x86/include/asm/kvm_para.h
@@ -158,6 +158,12 @@ static inline unsigned int kvm_arch_para_features(void)
158 return cpuid_eax(KVM_CPUID_FEATURES); 158 return cpuid_eax(KVM_CPUID_FEATURES);
159} 159}
160 160
161#ifdef CONFIG_KVM_GUEST
162void __init kvm_guest_init(void);
163#else
164#define kvm_guest_init() do { } while (0)
161#endif 165#endif
162 166
167#endif /* __KERNEL__ */
168
163#endif /* _ASM_X86_KVM_PARA_H */ 169#endif /* _ASM_X86_KVM_PARA_H */
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
new file mode 100644
index 000000000000..19ae14ba6978
--- /dev/null
+++ b/arch/x86/include/asm/memblock.h
@@ -0,0 +1,23 @@
1#ifndef _X86_MEMBLOCK_H
2#define _X86_MEMBLOCK_H
3
4#define ARCH_DISCARD_MEMBLOCK
5
6u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align);
7void memblock_x86_to_bootmem(u64 start, u64 end);
8
9void memblock_x86_reserve_range(u64 start, u64 end, char *name);
10void memblock_x86_free_range(u64 start, u64 end);
11struct range;
12int __get_free_all_memory_range(struct range **range, int nodeid,
13 unsigned long start_pfn, unsigned long end_pfn);
14int get_free_all_memory_range(struct range **rangep, int nodeid);
15
16void memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
17 unsigned long last_pfn);
18u64 memblock_x86_hole_size(u64 start, u64 end);
19u64 memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align);
20u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
21u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
22
23#endif
diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
index 3e2ce58a31a3..67763c5d8b4e 100644
--- a/arch/x86/include/asm/module.h
+++ b/arch/x86/include/asm/module.h
@@ -60,12 +60,7 @@
60#endif 60#endif
61 61
62#ifdef CONFIG_X86_32 62#ifdef CONFIG_X86_32
63# ifdef CONFIG_4KSTACKS 63# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
64# define MODULE_STACKSIZE "4KSTACKS "
65# else
66# define MODULE_STACKSIZE ""
67# endif
68# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
69#endif 64#endif
70 65
71#endif /* _ASM_X86_MODULE_H */ 66#endif /* _ASM_X86_MODULE_H */
diff --git a/arch/x86/include/asm/mrst.h b/arch/x86/include/asm/mrst.h
index 16350740edf6..4a711a684b17 100644
--- a/arch/x86/include/asm/mrst.h
+++ b/arch/x86/include/asm/mrst.h
@@ -10,6 +10,9 @@
10 */ 10 */
11#ifndef _ASM_X86_MRST_H 11#ifndef _ASM_X86_MRST_H
12#define _ASM_X86_MRST_H 12#define _ASM_X86_MRST_H
13
14#include <linux/sfi.h>
15
13extern int pci_mrst_init(void); 16extern int pci_mrst_init(void);
14int __init sfi_parse_mrtc(struct sfi_table_header *table); 17int __init sfi_parse_mrtc(struct sfi_table_header *table);
15 18
@@ -26,7 +29,7 @@ enum mrst_cpu_type {
26}; 29};
27 30
28extern enum mrst_cpu_type __mrst_cpu_chip; 31extern enum mrst_cpu_type __mrst_cpu_chip;
29static enum mrst_cpu_type mrst_identify_cpu(void) 32static inline enum mrst_cpu_type mrst_identify_cpu(void)
30{ 33{
31 return __mrst_cpu_chip; 34 return __mrst_cpu_chip;
32} 35}
@@ -42,4 +45,9 @@ extern enum mrst_timer_options mrst_timer_options;
42#define SFI_MTMR_MAX_NUM 8 45#define SFI_MTMR_MAX_NUM 8
43#define SFI_MRTC_MAX 8 46#define SFI_MRTC_MAX 8
44 47
48extern struct console early_mrst_console;
49extern void mrst_early_console_init(void);
50
51extern struct console early_hsu_console;
52extern void hsu_early_console_init(void);
45#endif /* _ASM_X86_MRST_H */ 53#endif /* _ASM_X86_MRST_H */
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 986f7790fdb2..83c4bb1d917d 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -198,6 +198,7 @@
198#define MSR_IA32_TSC 0x00000010 198#define MSR_IA32_TSC 0x00000010
199#define MSR_IA32_PLATFORM_ID 0x00000017 199#define MSR_IA32_PLATFORM_ID 0x00000017
200#define MSR_IA32_EBL_CR_POWERON 0x0000002a 200#define MSR_IA32_EBL_CR_POWERON 0x0000002a
201#define MSR_EBC_FREQUENCY_ID 0x0000002c
201#define MSR_IA32_FEATURE_CONTROL 0x0000003a 202#define MSR_IA32_FEATURE_CONTROL 0x0000003a
202 203
203#define FEATURE_CONTROL_LOCKED (1<<0) 204#define FEATURE_CONTROL_LOCKED (1<<0)
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
new file mode 100644
index 000000000000..bcdff997668c
--- /dev/null
+++ b/arch/x86/include/asm/mwait.h
@@ -0,0 +1,15 @@
1#ifndef _ASM_X86_MWAIT_H
2#define _ASM_X86_MWAIT_H
3
4#define MWAIT_SUBSTATE_MASK 0xf
5#define MWAIT_CSTATE_MASK 0xf
6#define MWAIT_SUBSTATE_SIZE 4
7#define MWAIT_MAX_NUM_CSTATES 8
8
9#define CPUID_MWAIT_LEAF 5
10#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1
11#define CPUID5_ECX_INTERRUPT_BREAK 0x2
12
13#define MWAIT_ECX_INTERRUPT_BREAK 0x1
14
15#endif /* _ASM_X86_MWAIT_H */
diff --git a/arch/x86/include/asm/olpc_ofw.h b/arch/x86/include/asm/olpc_ofw.h
index 08fde475cb3b..2a8478140bb3 100644
--- a/arch/x86/include/asm/olpc_ofw.h
+++ b/arch/x86/include/asm/olpc_ofw.h
@@ -21,10 +21,14 @@ extern void olpc_ofw_detect(void);
21/* install OFW's pde permanently into the kernel's pgtable */ 21/* install OFW's pde permanently into the kernel's pgtable */
22extern void setup_olpc_ofw_pgd(void); 22extern void setup_olpc_ofw_pgd(void);
23 23
24/* check if OFW was detected during boot */
25extern bool olpc_ofw_present(void);
26
24#else /* !CONFIG_OLPC_OPENFIRMWARE */ 27#else /* !CONFIG_OLPC_OPENFIRMWARE */
25 28
26static inline void olpc_ofw_detect(void) { } 29static inline void olpc_ofw_detect(void) { }
27static inline void setup_olpc_ofw_pgd(void) { } 30static inline void setup_olpc_ofw_pgd(void) { }
31static inline bool olpc_ofw_present(void) { return false; }
28 32
29#endif /* !CONFIG_OLPC_OPENFIRMWARE */ 33#endif /* !CONFIG_OLPC_OPENFIRMWARE */
30 34
diff --git a/arch/x86/include/asm/page_32_types.h b/arch/x86/include/asm/page_32_types.h
index 6f1b7331313f..ade619ff9e2a 100644
--- a/arch/x86/include/asm/page_32_types.h
+++ b/arch/x86/include/asm/page_32_types.h
@@ -15,11 +15,7 @@
15 */ 15 */
16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) 16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
17 17
18#ifdef CONFIG_4KSTACKS
19#define THREAD_ORDER 0
20#else
21#define THREAD_ORDER 1 18#define THREAD_ORDER 1
22#endif
23#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 19#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
24 20
25#define STACKFAULT_STACK 0 21#define STACKFAULT_STACK 0
diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
index a667f24c7254..1df66211fd1b 100644
--- a/arch/x86/include/asm/page_types.h
+++ b/arch/x86/include/asm/page_types.h
@@ -8,7 +8,7 @@
8#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 8#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
9#define PAGE_MASK (~(PAGE_SIZE-1)) 9#define PAGE_MASK (~(PAGE_SIZE-1))
10 10
11#define __PHYSICAL_MASK ((phys_addr_t)(1ULL << __PHYSICAL_MASK_SHIFT) - 1) 11#define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
12#define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) 12#define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
13 13
14/* Cast PAGE_MASK to a signed type so that it is sign-extended if 14/* Cast PAGE_MASK to a signed type so that it is sign-extended if
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 5653f43d90e5..18e3b8a8709f 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -105,7 +105,7 @@ static inline void write_cr8(unsigned long x)
105} 105}
106#endif 106#endif
107 107
108static inline void raw_safe_halt(void) 108static inline void arch_safe_halt(void)
109{ 109{
110 PVOP_VCALL0(pv_irq_ops.safe_halt); 110 PVOP_VCALL0(pv_irq_ops.safe_halt);
111} 111}
@@ -416,11 +416,6 @@ static inline void paravirt_alloc_pmd(struct mm_struct *mm, unsigned long pfn)
416 PVOP_VCALL2(pv_mmu_ops.alloc_pmd, mm, pfn); 416 PVOP_VCALL2(pv_mmu_ops.alloc_pmd, mm, pfn);
417} 417}
418 418
419static inline void paravirt_alloc_pmd_clone(unsigned long pfn, unsigned long clonepfn,
420 unsigned long start, unsigned long count)
421{
422 PVOP_VCALL4(pv_mmu_ops.alloc_pmd_clone, pfn, clonepfn, start, count);
423}
424static inline void paravirt_release_pmd(unsigned long pfn) 419static inline void paravirt_release_pmd(unsigned long pfn)
425{ 420{
426 PVOP_VCALL1(pv_mmu_ops.release_pmd, pfn); 421 PVOP_VCALL1(pv_mmu_ops.release_pmd, pfn);
@@ -829,32 +824,32 @@ static __always_inline void arch_spin_unlock(struct arch_spinlock *lock)
829#define __PV_IS_CALLEE_SAVE(func) \ 824#define __PV_IS_CALLEE_SAVE(func) \
830 ((struct paravirt_callee_save) { func }) 825 ((struct paravirt_callee_save) { func })
831 826
832static inline unsigned long __raw_local_save_flags(void) 827static inline unsigned long arch_local_save_flags(void)
833{ 828{
834 return PVOP_CALLEE0(unsigned long, pv_irq_ops.save_fl); 829 return PVOP_CALLEE0(unsigned long, pv_irq_ops.save_fl);
835} 830}
836 831
837static inline void raw_local_irq_restore(unsigned long f) 832static inline void arch_local_irq_restore(unsigned long f)
838{ 833{
839 PVOP_VCALLEE1(pv_irq_ops.restore_fl, f); 834 PVOP_VCALLEE1(pv_irq_ops.restore_fl, f);
840} 835}
841 836
842static inline void raw_local_irq_disable(void) 837static inline void arch_local_irq_disable(void)
843{ 838{
844 PVOP_VCALLEE0(pv_irq_ops.irq_disable); 839 PVOP_VCALLEE0(pv_irq_ops.irq_disable);
845} 840}
846 841
847static inline void raw_local_irq_enable(void) 842static inline void arch_local_irq_enable(void)
848{ 843{
849 PVOP_VCALLEE0(pv_irq_ops.irq_enable); 844 PVOP_VCALLEE0(pv_irq_ops.irq_enable);
850} 845}
851 846
852static inline unsigned long __raw_local_irq_save(void) 847static inline unsigned long arch_local_irq_save(void)
853{ 848{
854 unsigned long f; 849 unsigned long f;
855 850
856 f = __raw_local_save_flags(); 851 f = arch_local_save_flags();
857 raw_local_irq_disable(); 852 arch_local_irq_disable();
858 return f; 853 return f;
859} 854}
860 855
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index db9ef5532341..b82bac975250 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -255,7 +255,6 @@ struct pv_mmu_ops {
255 */ 255 */
256 void (*alloc_pte)(struct mm_struct *mm, unsigned long pfn); 256 void (*alloc_pte)(struct mm_struct *mm, unsigned long pfn);
257 void (*alloc_pmd)(struct mm_struct *mm, unsigned long pfn); 257 void (*alloc_pmd)(struct mm_struct *mm, unsigned long pfn);
258 void (*alloc_pmd_clone)(unsigned long pfn, unsigned long clonepfn, unsigned long start, unsigned long count);
259 void (*alloc_pud)(struct mm_struct *mm, unsigned long pfn); 258 void (*alloc_pud)(struct mm_struct *mm, unsigned long pfn);
260 void (*release_pte)(unsigned long pfn); 259 void (*release_pte)(unsigned long pfn);
261 void (*release_pmd)(unsigned long pfn); 260 void (*release_pmd)(unsigned long pfn);
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index cd28f9ad910d..f899e01a8ac9 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -47,6 +47,20 @@
47#ifdef CONFIG_SMP 47#ifdef CONFIG_SMP
48#define __percpu_arg(x) "%%"__stringify(__percpu_seg)":%P" #x 48#define __percpu_arg(x) "%%"__stringify(__percpu_seg)":%P" #x
49#define __my_cpu_offset percpu_read(this_cpu_off) 49#define __my_cpu_offset percpu_read(this_cpu_off)
50
51/*
52 * Compared to the generic __my_cpu_offset version, the following
53 * saves one instruction and avoids clobbering a temp register.
54 */
55#define __this_cpu_ptr(ptr) \
56({ \
57 unsigned long tcp_ptr__; \
58 __verify_pcpu_ptr(ptr); \
59 asm volatile("add " __percpu_arg(1) ", %0" \
60 : "=r" (tcp_ptr__) \
61 : "m" (this_cpu_off), "0" (ptr)); \
62 (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \
63})
50#else 64#else
51#define __percpu_arg(x) "%P" #x 65#define __percpu_arg(x) "%P" #x
52#endif 66#endif
diff --git a/arch/x86/include/asm/perf_event_p4.h b/arch/x86/include/asm/perf_event_p4.h
index def500776b16..a70cd216be5d 100644
--- a/arch/x86/include/asm/perf_event_p4.h
+++ b/arch/x86/include/asm/perf_event_p4.h
@@ -36,19 +36,6 @@
36#define P4_ESCR_EMASK(v) ((v) << P4_ESCR_EVENTMASK_SHIFT) 36#define P4_ESCR_EMASK(v) ((v) << P4_ESCR_EVENTMASK_SHIFT)
37#define P4_ESCR_TAG(v) ((v) << P4_ESCR_TAG_SHIFT) 37#define P4_ESCR_TAG(v) ((v) << P4_ESCR_TAG_SHIFT)
38 38
39/* Non HT mask */
40#define P4_ESCR_MASK \
41 (P4_ESCR_EVENT_MASK | \
42 P4_ESCR_EVENTMASK_MASK | \
43 P4_ESCR_TAG_MASK | \
44 P4_ESCR_TAG_ENABLE | \
45 P4_ESCR_T0_OS | \
46 P4_ESCR_T0_USR)
47
48/* HT mask */
49#define P4_ESCR_MASK_HT \
50 (P4_ESCR_MASK | P4_ESCR_T1_OS | P4_ESCR_T1_USR)
51
52#define P4_CCCR_OVF 0x80000000U 39#define P4_CCCR_OVF 0x80000000U
53#define P4_CCCR_CASCADE 0x40000000U 40#define P4_CCCR_CASCADE 0x40000000U
54#define P4_CCCR_OVF_PMI_T0 0x04000000U 41#define P4_CCCR_OVF_PMI_T0 0x04000000U
@@ -70,23 +57,6 @@
70#define P4_CCCR_THRESHOLD(v) ((v) << P4_CCCR_THRESHOLD_SHIFT) 57#define P4_CCCR_THRESHOLD(v) ((v) << P4_CCCR_THRESHOLD_SHIFT)
71#define P4_CCCR_ESEL(v) ((v) << P4_CCCR_ESCR_SELECT_SHIFT) 58#define P4_CCCR_ESEL(v) ((v) << P4_CCCR_ESCR_SELECT_SHIFT)
72 59
73/* Non HT mask */
74#define P4_CCCR_MASK \
75 (P4_CCCR_OVF | \
76 P4_CCCR_CASCADE | \
77 P4_CCCR_OVF_PMI_T0 | \
78 P4_CCCR_FORCE_OVF | \
79 P4_CCCR_EDGE | \
80 P4_CCCR_THRESHOLD_MASK | \
81 P4_CCCR_COMPLEMENT | \
82 P4_CCCR_COMPARE | \
83 P4_CCCR_ESCR_SELECT_MASK | \
84 P4_CCCR_ENABLE)
85
86/* HT mask */
87#define P4_CCCR_MASK_HT \
88 (P4_CCCR_MASK | P4_CCCR_OVF_PMI_T1 | P4_CCCR_THREAD_ANY)
89
90#define P4_GEN_ESCR_EMASK(class, name, bit) \ 60#define P4_GEN_ESCR_EMASK(class, name, bit) \
91 class##__##name = ((1 << bit) << P4_ESCR_EVENTMASK_SHIFT) 61 class##__##name = ((1 << bit) << P4_ESCR_EVENTMASK_SHIFT)
92#define P4_ESCR_EMASK_BIT(class, name) class##__##name 62#define P4_ESCR_EMASK_BIT(class, name) class##__##name
@@ -127,6 +97,28 @@
127#define P4_CONFIG_HT_SHIFT 63 97#define P4_CONFIG_HT_SHIFT 63
128#define P4_CONFIG_HT (1ULL << P4_CONFIG_HT_SHIFT) 98#define P4_CONFIG_HT (1ULL << P4_CONFIG_HT_SHIFT)
129 99
100/*
101 * The bits we allow to pass for RAW events
102 */
103#define P4_CONFIG_MASK_ESCR \
104 P4_ESCR_EVENT_MASK | \
105 P4_ESCR_EVENTMASK_MASK | \
106 P4_ESCR_TAG_MASK | \
107 P4_ESCR_TAG_ENABLE
108
109#define P4_CONFIG_MASK_CCCR \
110 P4_CCCR_EDGE | \
111 P4_CCCR_THRESHOLD_MASK | \
112 P4_CCCR_COMPLEMENT | \
113 P4_CCCR_COMPARE | \
114 P4_CCCR_THREAD_ANY | \
115 P4_CCCR_RESERVED
116
117/* some dangerous bits are reserved for kernel internals */
118#define P4_CONFIG_MASK \
119 (p4_config_pack_escr(P4_CONFIG_MASK_ESCR)) | \
120 (p4_config_pack_cccr(P4_CONFIG_MASK_CCCR))
121
130static inline bool p4_is_event_cascaded(u64 config) 122static inline bool p4_is_event_cascaded(u64 config)
131{ 123{
132 u32 cccr = p4_config_unpack_cccr(config); 124 u32 cccr = p4_config_unpack_cccr(config);
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index a34c785c5a63..ada823a13c7c 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -28,6 +28,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
28extern spinlock_t pgd_lock; 28extern spinlock_t pgd_lock;
29extern struct list_head pgd_list; 29extern struct list_head pgd_list;
30 30
31extern struct mm_struct *pgd_page_get_mm(struct page *page);
32
31#ifdef CONFIG_PARAVIRT 33#ifdef CONFIG_PARAVIRT
32#include <asm/paravirt.h> 34#include <asm/paravirt.h>
33#else /* !CONFIG_PARAVIRT */ 35#else /* !CONFIG_PARAVIRT */
@@ -603,6 +605,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,
603 pte_update(mm, addr, ptep); 605 pte_update(mm, addr, ptep);
604} 606}
605 607
608#define flush_tlb_fix_spurious_fault(vma, address)
609
606/* 610/*
607 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count); 611 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
608 * 612 *
diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
index f686f49e8b7b..8abde9ec90bf 100644
--- a/arch/x86/include/asm/pgtable_32.h
+++ b/arch/x86/include/asm/pgtable_32.h
@@ -26,7 +26,7 @@ struct mm_struct;
26struct vm_area_struct; 26struct vm_area_struct;
27 27
28extern pgd_t swapper_pg_dir[1024]; 28extern pgd_t swapper_pg_dir[1024];
29extern pgd_t trampoline_pg_dir[1024]; 29extern pgd_t initial_page_table[1024];
30 30
31static inline void pgtable_cache_init(void) { } 31static inline void pgtable_cache_init(void) { }
32static inline void check_pgt_cache(void) { } 32static inline void check_pgt_cache(void) { }
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 076052cd62be..f96ac9bedf75 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -102,6 +102,8 @@ static inline void native_pgd_clear(pgd_t *pgd)
102 native_set_pgd(pgd, native_make_pgd(0)); 102 native_set_pgd(pgd, native_make_pgd(0));
103} 103}
104 104
105extern void sync_global_pgds(unsigned long start, unsigned long end);
106
105/* 107/*
106 * Conversion functions: convert a page and protection to a page entry, 108 * Conversion functions: convert a page and protection to a page entry,
107 * and a page entry and page directory to the page they refer to. 109 * and a page entry and page directory to the page they refer to.
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 325b7bdbebaa..cae9c3cb95cf 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -110,6 +110,8 @@ struct cpuinfo_x86 {
110 u16 phys_proc_id; 110 u16 phys_proc_id;
111 /* Core id: */ 111 /* Core id: */
112 u16 cpu_core_id; 112 u16 cpu_core_id;
113 /* Compute unit id */
114 u8 compute_unit_id;
113 /* Index into per_cpu list: */ 115 /* Index into per_cpu list: */
114 u16 cpu_index; 116 u16 cpu_index;
115#endif 117#endif
@@ -602,7 +604,7 @@ extern unsigned long mmu_cr4_features;
602 604
603static inline void set_in_cr4(unsigned long mask) 605static inline void set_in_cr4(unsigned long mask)
604{ 606{
605 unsigned cr4; 607 unsigned long cr4;
606 608
607 mmu_cr4_features |= mask; 609 mmu_cr4_features |= mask;
608 cr4 = read_cr4(); 610 cr4 = read_cr4();
@@ -612,7 +614,7 @@ static inline void set_in_cr4(unsigned long mask)
612 614
613static inline void clear_in_cr4(unsigned long mask) 615static inline void clear_in_cr4(unsigned long mask)
614{ 616{
615 unsigned cr4; 617 unsigned long cr4;
616 618
617 mmu_cr4_features &= ~mask; 619 mmu_cr4_features &= ~mask;
618 cr4 = read_cr4(); 620 cr4 = read_cr4();
@@ -764,29 +766,6 @@ extern unsigned long idle_halt;
764extern unsigned long idle_nomwait; 766extern unsigned long idle_nomwait;
765extern bool c1e_detected; 767extern bool c1e_detected;
766 768
767/*
768 * on systems with caches, caches must be flashed as the absolute
769 * last instruction before going into a suspended halt. Otherwise,
770 * dirty data can linger in the cache and become stale on resume,
771 * leading to strange errors.
772 *
773 * perform a variety of operations to guarantee that the compiler
774 * will not reorder instructions. wbinvd itself is serializing
775 * so the processor will not reorder.
776 *
777 * Systems without cache can just go into halt.
778 */
779static inline void wbinvd_halt(void)
780{
781 mb();
782 /* check for clflush to determine if wbinvd is legal */
783 if (cpu_has_clflush)
784 asm volatile("cli; wbinvd; 1: hlt; jmp 1b" : : : "memory");
785 else
786 while (1)
787 halt();
788}
789
790extern void enable_sep_cpu(void); 769extern void enable_sep_cpu(void);
791extern int sysenter_setup(void); 770extern int sysenter_setup(void);
792 771
diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index cd02f324aa6b..7f7e577a0e39 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -12,4 +12,42 @@ void pvclock_read_wallclock(struct pvclock_wall_clock *wall,
12 struct pvclock_vcpu_time_info *vcpu, 12 struct pvclock_vcpu_time_info *vcpu,
13 struct timespec *ts); 13 struct timespec *ts);
14 14
15/*
16 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
17 * yielding a 64-bit result.
18 */
19static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift)
20{
21 u64 product;
22#ifdef __i386__
23 u32 tmp1, tmp2;
24#endif
25
26 if (shift < 0)
27 delta >>= -shift;
28 else
29 delta <<= shift;
30
31#ifdef __i386__
32 __asm__ (
33 "mul %5 ; "
34 "mov %4,%%eax ; "
35 "mov %%edx,%4 ; "
36 "mul %5 ; "
37 "xor %5,%5 ; "
38 "add %4,%%eax ; "
39 "adc %5,%%edx ; "
40 : "=A" (product), "=r" (tmp1), "=r" (tmp2)
41 : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
42#elif defined(__x86_64__)
43 __asm__ (
44 "mul %%rdx ; shrd $32,%%rdx,%%rax"
45 : "=a" (product) : "0" (delta), "d" ((u64)mul_frac) );
46#else
47#error implement me!
48#endif
49
50 return product;
51}
52
15#endif /* _ASM_X86_PVCLOCK_H */ 53#endif /* _ASM_X86_PVCLOCK_H */
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 14e0ed86a6f9..231f1c1d6607 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -73,31 +73,31 @@
73 73
74#define GDT_ENTRY_DEFAULT_USER_DS 15 74#define GDT_ENTRY_DEFAULT_USER_DS 15
75 75
76#define GDT_ENTRY_KERNEL_BASE 12 76#define GDT_ENTRY_KERNEL_BASE (12)
77 77
78#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0) 78#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
79 79
80#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1) 80#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
81 81
82#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4) 82#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
83#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5) 83#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE+5)
84 84
85#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6) 85#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE+6)
86#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11) 86#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE+11)
87 87
88#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14) 88#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE+14)
89#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) 89#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS*8)
90 90
91#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15) 91#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE+15)
92#ifdef CONFIG_SMP 92#ifdef CONFIG_SMP
93#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8) 93#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
94#else 94#else
95#define __KERNEL_PERCPU 0 95#define __KERNEL_PERCPU 0
96#endif 96#endif
97 97
98#define GDT_ENTRY_STACK_CANARY (GDT_ENTRY_KERNEL_BASE + 16) 98#define GDT_ENTRY_STACK_CANARY (GDT_ENTRY_KERNEL_BASE+16)
99#ifdef CONFIG_CC_STACKPROTECTOR 99#ifdef CONFIG_CC_STACKPROTECTOR
100#define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY * 8) 100#define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY*8)
101#else 101#else
102#define __KERNEL_STACK_CANARY 0 102#define __KERNEL_STACK_CANARY 0
103#endif 103#endif
@@ -182,10 +182,10 @@
182 182
183#endif 183#endif
184 184
185#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8) 185#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
186#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8) 186#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
187#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3) 187#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
188#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3) 188#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
189#ifndef CONFIG_PARAVIRT 189#ifndef CONFIG_PARAVIRT
190#define get_kernel_rpl() 0 190#define get_kernel_rpl() 0
191#endif 191#endif
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index ef292c792d74..d6763b139a84 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -93,6 +93,11 @@ void *extend_brk(size_t size, size_t align);
93 : : "i" (sz)); \ 93 : : "i" (sz)); \
94 } 94 }
95 95
96/* Helper for reserving space for arrays of things */
97#define RESERVE_BRK_ARRAY(type, name, entries) \
98 type *name; \
99 RESERVE_BRK(name, sizeof(type) * entries)
100
96#ifdef __i386__ 101#ifdef __i386__
97 102
98void __init i386_start_kernel(void); 103void __init i386_start_kernel(void);
diff --git a/arch/x86/include/asm/swiotlb.h b/arch/x86/include/asm/swiotlb.h
index 8085277e1b8b..977f1761a25d 100644
--- a/arch/x86/include/asm/swiotlb.h
+++ b/arch/x86/include/asm/swiotlb.h
@@ -5,17 +5,26 @@
5 5
6#ifdef CONFIG_SWIOTLB 6#ifdef CONFIG_SWIOTLB
7extern int swiotlb; 7extern int swiotlb;
8extern int __init pci_swiotlb_detect(void); 8extern int __init pci_swiotlb_detect_override(void);
9extern int __init pci_swiotlb_detect_4gb(void);
9extern void __init pci_swiotlb_init(void); 10extern void __init pci_swiotlb_init(void);
11extern void __init pci_swiotlb_late_init(void);
10#else 12#else
11#define swiotlb 0 13#define swiotlb 0
12static inline int pci_swiotlb_detect(void) 14static inline int pci_swiotlb_detect_override(void)
15{
16 return 0;
17}
18static inline int pci_swiotlb_detect_4gb(void)
13{ 19{
14 return 0; 20 return 0;
15} 21}
16static inline void pci_swiotlb_init(void) 22static inline void pci_swiotlb_init(void)
17{ 23{
18} 24}
25static inline void pci_swiotlb_late_init(void)
26{
27}
19#endif 28#endif
20 29
21static inline void dma_mark_clean(void *addr, size_t size) {} 30static inline void dma_mark_clean(void *addr, size_t size) {}
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index 7f3eba08e7de..169be8938b96 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -172,6 +172,4 @@ static inline void flush_tlb_kernel_range(unsigned long start,
172 flush_tlb_all(); 172 flush_tlb_all();
173} 173}
174 174
175extern void zap_low_mappings(bool early);
176
177#endif /* _ASM_X86_TLBFLUSH_H */ 175#endif /* _ASM_X86_TLBFLUSH_H */
diff --git a/arch/x86/include/asm/trampoline.h b/arch/x86/include/asm/trampoline.h
index 4dde797c0578..f4500fb3b485 100644
--- a/arch/x86/include/asm/trampoline.h
+++ b/arch/x86/include/asm/trampoline.h
@@ -13,16 +13,13 @@ extern unsigned char *trampoline_base;
13 13
14extern unsigned long init_rsp; 14extern unsigned long init_rsp;
15extern unsigned long initial_code; 15extern unsigned long initial_code;
16extern unsigned long initial_page_table;
17extern unsigned long initial_gs; 16extern unsigned long initial_gs;
18 17
19#define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE) 18#define TRAMPOLINE_SIZE roundup(trampoline_end - trampoline_data, PAGE_SIZE)
20 19
21extern unsigned long setup_trampoline(void); 20extern unsigned long setup_trampoline(void);
22extern void __init setup_trampoline_page_table(void);
23extern void __init reserve_trampoline_memory(void); 21extern void __init reserve_trampoline_memory(void);
24#else 22#else
25static inline void setup_trampoline_page_table(void) {}
26static inline void reserve_trampoline_memory(void) {} 23static inline void reserve_trampoline_memory(void) {}
27#endif /* CONFIG_X86_TRAMPOLINE */ 24#endif /* CONFIG_X86_TRAMPOLINE */
28 25
diff --git a/arch/x86/include/asm/vmi.h b/arch/x86/include/asm/vmi.h
deleted file mode 100644
index 61e08c0a2907..000000000000
--- a/arch/x86/include/asm/vmi.h
+++ /dev/null
@@ -1,269 +0,0 @@
1/*
2 * VMI interface definition
3 *
4 * Copyright (C) 2005, VMware, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Maintained by: Zachary Amsden zach@vmware.com
22 *
23 */
24#include <linux/types.h>
25
26/*
27 *---------------------------------------------------------------------
28 *
29 * VMI Option ROM API
30 *
31 *---------------------------------------------------------------------
32 */
33#define VMI_SIGNATURE 0x696d5663 /* "cVmi" */
34
35#define PCI_VENDOR_ID_VMWARE 0x15AD
36#define PCI_DEVICE_ID_VMWARE_VMI 0x0801
37
38/*
39 * We use two version numbers for compatibility, with the major
40 * number signifying interface breakages, and the minor number
41 * interface extensions.
42 */
43#define VMI_API_REV_MAJOR 3
44#define VMI_API_REV_MINOR 0
45
46#define VMI_CALL_CPUID 0
47#define VMI_CALL_WRMSR 1
48#define VMI_CALL_RDMSR 2
49#define VMI_CALL_SetGDT 3
50#define VMI_CALL_SetLDT 4
51#define VMI_CALL_SetIDT 5
52#define VMI_CALL_SetTR 6
53#define VMI_CALL_GetGDT 7
54#define VMI_CALL_GetLDT 8
55#define VMI_CALL_GetIDT 9
56#define VMI_CALL_GetTR 10
57#define VMI_CALL_WriteGDTEntry 11
58#define VMI_CALL_WriteLDTEntry 12
59#define VMI_CALL_WriteIDTEntry 13
60#define VMI_CALL_UpdateKernelStack 14
61#define VMI_CALL_SetCR0 15
62#define VMI_CALL_SetCR2 16
63#define VMI_CALL_SetCR3 17
64#define VMI_CALL_SetCR4 18
65#define VMI_CALL_GetCR0 19
66#define VMI_CALL_GetCR2 20
67#define VMI_CALL_GetCR3 21
68#define VMI_CALL_GetCR4 22
69#define VMI_CALL_WBINVD 23
70#define VMI_CALL_SetDR 24
71#define VMI_CALL_GetDR 25
72#define VMI_CALL_RDPMC 26
73#define VMI_CALL_RDTSC 27
74#define VMI_CALL_CLTS 28
75#define VMI_CALL_EnableInterrupts 29
76#define VMI_CALL_DisableInterrupts 30
77#define VMI_CALL_GetInterruptMask 31
78#define VMI_CALL_SetInterruptMask 32
79#define VMI_CALL_IRET 33
80#define VMI_CALL_SYSEXIT 34
81#define VMI_CALL_Halt 35
82#define VMI_CALL_Reboot 36
83#define VMI_CALL_Shutdown 37
84#define VMI_CALL_SetPxE 38
85#define VMI_CALL_SetPxELong 39
86#define VMI_CALL_UpdatePxE 40
87#define VMI_CALL_UpdatePxELong 41
88#define VMI_CALL_MachineToPhysical 42
89#define VMI_CALL_PhysicalToMachine 43
90#define VMI_CALL_AllocatePage 44
91#define VMI_CALL_ReleasePage 45
92#define VMI_CALL_InvalPage 46
93#define VMI_CALL_FlushTLB 47
94#define VMI_CALL_SetLinearMapping 48
95
96#define VMI_CALL_SetIOPLMask 61
97#define VMI_CALL_SetInitialAPState 62
98#define VMI_CALL_APICWrite 63
99#define VMI_CALL_APICRead 64
100#define VMI_CALL_IODelay 65
101#define VMI_CALL_SetLazyMode 73
102
103/*
104 *---------------------------------------------------------------------
105 *
106 * MMU operation flags
107 *
108 *---------------------------------------------------------------------
109 */
110
111/* Flags used by VMI_{Allocate|Release}Page call */
112#define VMI_PAGE_PAE 0x10 /* Allocate PAE shadow */
113#define VMI_PAGE_CLONE 0x20 /* Clone from another shadow */
114#define VMI_PAGE_ZEROED 0x40 /* Page is pre-zeroed */
115
116
117/* Flags shared by Allocate|Release Page and PTE updates */
118#define VMI_PAGE_PT 0x01
119#define VMI_PAGE_PD 0x02
120#define VMI_PAGE_PDP 0x04
121#define VMI_PAGE_PML4 0x08
122
123#define VMI_PAGE_NORMAL 0x00 /* for debugging */
124
125/* Flags used by PTE updates */
126#define VMI_PAGE_CURRENT_AS 0x10 /* implies VMI_PAGE_VA_MASK is valid */
127#define VMI_PAGE_DEFER 0x20 /* may queue update until TLB inval */
128#define VMI_PAGE_VA_MASK 0xfffff000
129
130#ifdef CONFIG_X86_PAE
131#define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_PAE | VMI_PAGE_ZEROED)
132#define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_PAE | VMI_PAGE_ZEROED)
133#else
134#define VMI_PAGE_L1 (VMI_PAGE_PT | VMI_PAGE_ZEROED)
135#define VMI_PAGE_L2 (VMI_PAGE_PD | VMI_PAGE_ZEROED)
136#endif
137
138/* Flags used by VMI_FlushTLB call */
139#define VMI_FLUSH_TLB 0x01
140#define VMI_FLUSH_GLOBAL 0x02
141
142/*
143 *---------------------------------------------------------------------
144 *
145 * VMI relocation definitions for ROM call get_reloc
146 *
147 *---------------------------------------------------------------------
148 */
149
150/* VMI Relocation types */
151#define VMI_RELOCATION_NONE 0
152#define VMI_RELOCATION_CALL_REL 1
153#define VMI_RELOCATION_JUMP_REL 2
154#define VMI_RELOCATION_NOP 3
155
156#ifndef __ASSEMBLY__
157struct vmi_relocation_info {
158 unsigned char *eip;
159 unsigned char type;
160 unsigned char reserved[3];
161};
162#endif
163
164
165/*
166 *---------------------------------------------------------------------
167 *
168 * Generic ROM structures and definitions
169 *
170 *---------------------------------------------------------------------
171 */
172
173#ifndef __ASSEMBLY__
174
175struct vrom_header {
176 u16 rom_signature; /* option ROM signature */
177 u8 rom_length; /* ROM length in 512 byte chunks */
178 u8 rom_entry[4]; /* 16-bit code entry point */
179 u8 rom_pad0; /* 4-byte align pad */
180 u32 vrom_signature; /* VROM identification signature */
181 u8 api_version_min;/* Minor version of API */
182 u8 api_version_maj;/* Major version of API */
183 u8 jump_slots; /* Number of jump slots */
184 u8 reserved1; /* Reserved for expansion */
185 u32 virtual_top; /* Hypervisor virtual address start */
186 u16 reserved2; /* Reserved for expansion */
187 u16 license_offs; /* Offset to License string */
188 u16 pci_header_offs;/* Offset to PCI OPROM header */
189 u16 pnp_header_offs;/* Offset to PnP OPROM header */
190 u32 rom_pad3; /* PnP reserverd / VMI reserved */
191 u8 reserved[96]; /* Reserved for headers */
192 char vmi_init[8]; /* VMI_Init jump point */
193 char get_reloc[8]; /* VMI_GetRelocationInfo jump point */
194} __attribute__((packed));
195
196struct pnp_header {
197 char sig[4];
198 char rev;
199 char size;
200 short next;
201 short res;
202 long devID;
203 unsigned short manufacturer_offset;
204 unsigned short product_offset;
205} __attribute__((packed));
206
207struct pci_header {
208 char sig[4];
209 short vendorID;
210 short deviceID;
211 short vpdData;
212 short size;
213 char rev;
214 char class;
215 char subclass;
216 char interface;
217 short chunks;
218 char rom_version_min;
219 char rom_version_maj;
220 char codetype;
221 char lastRom;
222 short reserved;
223} __attribute__((packed));
224
225/* Function prototypes for bootstrapping */
226#ifdef CONFIG_VMI
227extern void vmi_init(void);
228extern void vmi_activate(void);
229extern void vmi_bringup(void);
230#else
231static inline void vmi_init(void) {}
232static inline void vmi_activate(void) {}
233static inline void vmi_bringup(void) {}
234#endif
235
236/* State needed to start an application processor in an SMP system. */
237struct vmi_ap_state {
238 u32 cr0;
239 u32 cr2;
240 u32 cr3;
241 u32 cr4;
242
243 u64 efer;
244
245 u32 eip;
246 u32 eflags;
247 u32 eax;
248 u32 ebx;
249 u32 ecx;
250 u32 edx;
251 u32 esp;
252 u32 ebp;
253 u32 esi;
254 u32 edi;
255 u16 cs;
256 u16 ss;
257 u16 ds;
258 u16 es;
259 u16 fs;
260 u16 gs;
261 u16 ldtr;
262
263 u16 gdtr_limit;
264 u32 gdtr_base;
265 u32 idtr_base;
266 u16 idtr_limit;
267};
268
269#endif
diff --git a/arch/x86/include/asm/vmi_time.h b/arch/x86/include/asm/vmi_time.h
deleted file mode 100644
index c6e0bee93e3c..000000000000
--- a/arch/x86/include/asm/vmi_time.h
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * VMI Time wrappers
3 *
4 * Copyright (C) 2006, VMware, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Send feedback to dhecht@vmware.com
22 *
23 */
24
25#ifndef _ASM_X86_VMI_TIME_H
26#define _ASM_X86_VMI_TIME_H
27
28/*
29 * Raw VMI call indices for timer functions
30 */
31#define VMI_CALL_GetCycleFrequency 66
32#define VMI_CALL_GetCycleCounter 67
33#define VMI_CALL_SetAlarm 68
34#define VMI_CALL_CancelAlarm 69
35#define VMI_CALL_GetWallclockTime 70
36#define VMI_CALL_WallclockUpdated 71
37
38/* Cached VMI timer operations */
39extern struct vmi_timer_ops {
40 u64 (*get_cycle_frequency)(void);
41 u64 (*get_cycle_counter)(int);
42 u64 (*get_wallclock)(void);
43 int (*wallclock_updated)(void);
44 void (*set_alarm)(u32 flags, u64 expiry, u64 period);
45 void (*cancel_alarm)(u32 flags);
46} vmi_timer_ops;
47
48/* Prototypes */
49extern void __init vmi_time_init(void);
50extern unsigned long vmi_get_wallclock(void);
51extern int vmi_set_wallclock(unsigned long now);
52extern unsigned long long vmi_sched_clock(void);
53extern unsigned long vmi_tsc_khz(void);
54
55#ifdef CONFIG_X86_LOCAL_APIC
56extern void __devinit vmi_time_bsp_init(void);
57extern void __devinit vmi_time_ap_init(void);
58#endif
59
60/*
61 * When run under a hypervisor, a vcpu is always in one of three states:
62 * running, halted, or ready. The vcpu is in the 'running' state if it
63 * is executing. When the vcpu executes the halt interface, the vcpu
64 * enters the 'halted' state and remains halted until there is some work
65 * pending for the vcpu (e.g. an alarm expires, host I/O completes on
66 * behalf of virtual I/O). At this point, the vcpu enters the 'ready'
67 * state (waiting for the hypervisor to reschedule it). Finally, at any
68 * time when the vcpu is not in the 'running' state nor the 'halted'
69 * state, it is in the 'ready' state.
70 *
71 * Real time is advances while the vcpu is 'running', 'ready', or
72 * 'halted'. Stolen time is the time in which the vcpu is in the
73 * 'ready' state. Available time is the remaining time -- the vcpu is
74 * either 'running' or 'halted'.
75 *
76 * All three views of time are accessible through the VMI cycle
77 * counters.
78 */
79
80/* The cycle counters. */
81#define VMI_CYCLES_REAL 0
82#define VMI_CYCLES_AVAILABLE 1
83#define VMI_CYCLES_STOLEN 2
84
85/* The alarm interface 'flags' bits */
86#define VMI_ALARM_COUNTERS 2
87
88#define VMI_ALARM_COUNTER_MASK 0x000000ff
89
90#define VMI_ALARM_WIRED_IRQ0 0x00000000
91#define VMI_ALARM_WIRED_LVTT 0x00010000
92
93#define VMI_ALARM_IS_ONESHOT 0x00000000
94#define VMI_ALARM_IS_PERIODIC 0x00000100
95
96#define CONFIG_VMI_ALARM_HZ 100
97
98#endif /* _ASM_X86_VMI_TIME_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index fedf32a8c3ec..2c833d8c4141 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -34,7 +34,8 @@ GCOV_PROFILE_paravirt.o := n
34obj-y := process_$(BITS).o signal.o entry_$(BITS).o 34obj-y := process_$(BITS).o signal.o entry_$(BITS).o
35obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o 35obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
36obj-y += time.o ioport.o ldt.o dumpstack.o 36obj-y += time.o ioport.o ldt.o dumpstack.o
37obj-y += setup.o x86_init.o i8259.o irqinit.o 37obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
38obj-$(CONFIG_IRQ_WORK) += irq_work.o
38obj-$(CONFIG_X86_VISWS) += visws_quirks.o 39obj-$(CONFIG_X86_VISWS) += visws_quirks.o
39obj-$(CONFIG_X86_32) += probe_roms_32.o 40obj-$(CONFIG_X86_32) += probe_roms_32.o
40obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o 41obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
@@ -44,6 +45,7 @@ obj-y += bootflag.o e820.o
44obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o 45obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o
45obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o 46obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o
46obj-y += tsc.o io_delay.o rtc.o 47obj-y += tsc.o io_delay.o rtc.o
48obj-y += pci-iommu_table.o
47 49
48obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o 50obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o
49obj-y += process.o 51obj-y += process.o
@@ -85,15 +87,15 @@ obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o
85obj-$(CONFIG_KGDB) += kgdb.o 87obj-$(CONFIG_KGDB) += kgdb.o
86obj-$(CONFIG_VM86) += vm86_32.o 88obj-$(CONFIG_VM86) += vm86_32.o
87obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 89obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
90obj-$(CONFIG_EARLY_PRINTK_MRST) += early_printk_mrst.o
88 91
89obj-$(CONFIG_HPET_TIMER) += hpet.o 92obj-$(CONFIG_HPET_TIMER) += hpet.o
90obj-$(CONFIG_APB_TIMER) += apb_timer.o 93obj-$(CONFIG_APB_TIMER) += apb_timer.o
91 94
92obj-$(CONFIG_K8_NB) += k8.o 95obj-$(CONFIG_AMD_NB) += amd_nb.o
93obj-$(CONFIG_DEBUG_RODATA_TEST) += test_rodata.o 96obj-$(CONFIG_DEBUG_RODATA_TEST) += test_rodata.o
94obj-$(CONFIG_DEBUG_NX_TEST) += test_nx.o 97obj-$(CONFIG_DEBUG_NX_TEST) += test_nx.o
95 98
96obj-$(CONFIG_VMI) += vmi_32.o vmiclock_32.o
97obj-$(CONFIG_KVM_GUEST) += kvm.o 99obj-$(CONFIG_KVM_GUEST) += kvm.o
98obj-$(CONFIG_KVM_CLOCK) += kvmclock.o 100obj-$(CONFIG_KVM_CLOCK) += kvmclock.o
99obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o 101obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o
@@ -106,6 +108,7 @@ obj-$(CONFIG_SCx200) += scx200.o
106scx200-y += scx200_32.o 108scx200-y += scx200_32.o
107 109
108obj-$(CONFIG_OLPC) += olpc.o 110obj-$(CONFIG_OLPC) += olpc.o
111obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o
109obj-$(CONFIG_OLPC_OPENFIRMWARE) += olpc_ofw.o 112obj-$(CONFIG_OLPC_OPENFIRMWARE) += olpc_ofw.o
110obj-$(CONFIG_X86_MRST) += mrst.o 113obj-$(CONFIG_X86_MRST) += mrst.o
111 114
@@ -122,7 +125,6 @@ obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
122# 64 bit specific files 125# 64 bit specific files
123ifeq ($(CONFIG_X86_64),y) 126ifeq ($(CONFIG_X86_64),y)
124 obj-$(CONFIG_X86_UV) += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o 127 obj-$(CONFIG_X86_UV) += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o
125 obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o
126 obj-$(CONFIG_AUDIT) += audit_64.o 128 obj-$(CONFIG_AUDIT) += audit_64.o
127 129
128 obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o 130 obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index fb7a5f052e2b..5812404a0d4c 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -13,6 +13,7 @@
13 13
14#include <acpi/processor.h> 14#include <acpi/processor.h>
15#include <asm/acpi.h> 15#include <asm/acpi.h>
16#include <asm/mwait.h>
16 17
17/* 18/*
18 * Initialize bm_flags based on the CPU cache properties 19 * Initialize bm_flags based on the CPU cache properties
@@ -61,20 +62,10 @@ struct cstate_entry {
61 unsigned int ecx; 62 unsigned int ecx;
62 } states[ACPI_PROCESSOR_MAX_POWER]; 63 } states[ACPI_PROCESSOR_MAX_POWER];
63}; 64};
64static struct cstate_entry *cpu_cstate_entry; /* per CPU ptr */ 65static struct cstate_entry __percpu *cpu_cstate_entry; /* per CPU ptr */
65 66
66static short mwait_supported[ACPI_PROCESSOR_MAX_POWER]; 67static short mwait_supported[ACPI_PROCESSOR_MAX_POWER];
67 68
68#define MWAIT_SUBSTATE_MASK (0xf)
69#define MWAIT_CSTATE_MASK (0xf)
70#define MWAIT_SUBSTATE_SIZE (4)
71
72#define CPUID_MWAIT_LEAF (5)
73#define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1)
74#define CPUID5_ECX_INTERRUPT_BREAK (0x2)
75
76#define MWAIT_ECX_INTERRUPT_BREAK (0x1)
77
78#define NATIVE_CSTATE_BEYOND_HALT (2) 69#define NATIVE_CSTATE_BEYOND_HALT (2)
79 70
80static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) 71static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index 33cec152070d..74a847835bab 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -7,11 +7,17 @@
7 7
8#include <linux/acpi.h> 8#include <linux/acpi.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/memblock.h>
10#include <linux/dmi.h> 11#include <linux/dmi.h>
11#include <linux/cpumask.h> 12#include <linux/cpumask.h>
12#include <asm/segment.h> 13#include <asm/segment.h>
13#include <asm/desc.h> 14#include <asm/desc.h>
14 15
16#ifdef CONFIG_X86_32
17#include <asm/pgtable.h>
18#include <asm/pgtable_32.h>
19#endif
20
15#include "realmode/wakeup.h" 21#include "realmode/wakeup.h"
16#include "sleep.h" 22#include "sleep.h"
17 23
@@ -90,7 +96,7 @@ int acpi_save_state_mem(void)
90 96
91#ifndef CONFIG_64BIT 97#ifndef CONFIG_64BIT
92 header->pmode_entry = (u32)&wakeup_pmode_return; 98 header->pmode_entry = (u32)&wakeup_pmode_return;
93 header->pmode_cr3 = (u32)(swsusp_pg_dir - __PAGE_OFFSET); 99 header->pmode_cr3 = (u32)__pa(&initial_page_table);
94 saved_magic = 0x12345678; 100 saved_magic = 0x12345678;
95#else /* CONFIG_64BIT */ 101#else /* CONFIG_64BIT */
96 header->trampoline_segment = setup_trampoline() >> 4; 102 header->trampoline_segment = setup_trampoline() >> 4;
@@ -125,7 +131,7 @@ void acpi_restore_state_mem(void)
125 */ 131 */
126void __init acpi_reserve_wakeup_memory(void) 132void __init acpi_reserve_wakeup_memory(void)
127{ 133{
128 unsigned long mem; 134 phys_addr_t mem;
129 135
130 if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) { 136 if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
131 printk(KERN_ERR 137 printk(KERN_ERR
@@ -133,15 +139,15 @@ void __init acpi_reserve_wakeup_memory(void)
133 return; 139 return;
134 } 140 }
135 141
136 mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE); 142 mem = memblock_find_in_range(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
137 143
138 if (mem == -1L) { 144 if (mem == MEMBLOCK_ERROR) {
139 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n"); 145 printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
140 return; 146 return;
141 } 147 }
142 acpi_realmode = (unsigned long) phys_to_virt(mem); 148 acpi_realmode = (unsigned long) phys_to_virt(mem);
143 acpi_wakeup_address = mem; 149 acpi_wakeup_address = mem;
144 reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP"); 150 memblock_x86_reserve_range(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
145} 151}
146 152
147 153
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index f65ab8b014c4..a36bb90aef53 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -195,7 +195,7 @@ static void __init_or_module add_nops(void *insns, unsigned int len)
195 195
196extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; 196extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
197extern s32 __smp_locks[], __smp_locks_end[]; 197extern s32 __smp_locks[], __smp_locks_end[];
198static void *text_poke_early(void *addr, const void *opcode, size_t len); 198void *text_poke_early(void *addr, const void *opcode, size_t len);
199 199
200/* Replace instructions with better alternatives for this CPU type. 200/* Replace instructions with better alternatives for this CPU type.
201 This runs before SMP is initialized to avoid SMP problems with 201 This runs before SMP is initialized to avoid SMP problems with
@@ -522,7 +522,7 @@ void __init alternative_instructions(void)
522 * instructions. And on the local CPU you need to be protected again NMI or MCE 522 * instructions. And on the local CPU you need to be protected again NMI or MCE
523 * handlers seeing an inconsistent instruction while you patch. 523 * handlers seeing an inconsistent instruction while you patch.
524 */ 524 */
525static void *__init_or_module text_poke_early(void *addr, const void *opcode, 525void *__init_or_module text_poke_early(void *addr, const void *opcode,
526 size_t len) 526 size_t len)
527{ 527{
528 unsigned long flags; 528 unsigned long flags;
@@ -637,7 +637,72 @@ void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
637 tpp.len = len; 637 tpp.len = len;
638 atomic_set(&stop_machine_first, 1); 638 atomic_set(&stop_machine_first, 1);
639 wrote_text = 0; 639 wrote_text = 0;
640 stop_machine(stop_machine_text_poke, (void *)&tpp, NULL); 640 /* Use __stop_machine() because the caller already got online_cpus. */
641 __stop_machine(stop_machine_text_poke, (void *)&tpp, NULL);
641 return addr; 642 return addr;
642} 643}
643 644
645#if defined(CONFIG_DYNAMIC_FTRACE) || defined(HAVE_JUMP_LABEL)
646
647unsigned char ideal_nop5[IDEAL_NOP_SIZE_5];
648
649void __init arch_init_ideal_nop5(void)
650{
651 extern const unsigned char ftrace_test_p6nop[];
652 extern const unsigned char ftrace_test_nop5[];
653 extern const unsigned char ftrace_test_jmp[];
654 int faulted = 0;
655
656 /*
657 * There is no good nop for all x86 archs.
658 * We will default to using the P6_NOP5, but first we
659 * will test to make sure that the nop will actually
660 * work on this CPU. If it faults, we will then
661 * go to a lesser efficient 5 byte nop. If that fails
662 * we then just use a jmp as our nop. This isn't the most
663 * efficient nop, but we can not use a multi part nop
664 * since we would then risk being preempted in the middle
665 * of that nop, and if we enabled tracing then, it might
666 * cause a system crash.
667 *
668 * TODO: check the cpuid to determine the best nop.
669 */
670 asm volatile (
671 "ftrace_test_jmp:"
672 "jmp ftrace_test_p6nop\n"
673 "nop\n"
674 "nop\n"
675 "nop\n" /* 2 byte jmp + 3 bytes */
676 "ftrace_test_p6nop:"
677 P6_NOP5
678 "jmp 1f\n"
679 "ftrace_test_nop5:"
680 ".byte 0x66,0x66,0x66,0x66,0x90\n"
681 "1:"
682 ".section .fixup, \"ax\"\n"
683 "2: movl $1, %0\n"
684 " jmp ftrace_test_nop5\n"
685 "3: movl $2, %0\n"
686 " jmp 1b\n"
687 ".previous\n"
688 _ASM_EXTABLE(ftrace_test_p6nop, 2b)
689 _ASM_EXTABLE(ftrace_test_nop5, 3b)
690 : "=r"(faulted) : "0" (faulted));
691
692 switch (faulted) {
693 case 0:
694 pr_info("converting mcount calls to 0f 1f 44 00 00\n");
695 memcpy(ideal_nop5, ftrace_test_p6nop, IDEAL_NOP_SIZE_5);
696 break;
697 case 1:
698 pr_info("converting mcount calls to 66 66 66 66 90\n");
699 memcpy(ideal_nop5, ftrace_test_nop5, IDEAL_NOP_SIZE_5);
700 break;
701 case 2:
702 pr_info("converting mcount calls to jmp . + 5\n");
703 memcpy(ideal_nop5, ftrace_test_jmp, IDEAL_NOP_SIZE_5);
704 break;
705 }
706
707}
708#endif
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 679b6450382b..d2fdb0826df2 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2009 Advanced Micro Devices, Inc. 2 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com> 3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 * Leo Duran <leo.duran@amd.com> 4 * Leo Duran <leo.duran@amd.com>
5 * 5 *
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index 5a170cbbbed8..6e11c8134158 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2007-2009 Advanced Micro Devices, Inc. 2 * Copyright (C) 2007-2010 Advanced Micro Devices, Inc.
3 * Author: Joerg Roedel <joerg.roedel@amd.com> 3 * Author: Joerg Roedel <joerg.roedel@amd.com>
4 * Leo Duran <leo.duran@amd.com> 4 * Leo Duran <leo.duran@amd.com>
5 * 5 *
@@ -31,7 +31,7 @@
31#include <asm/iommu.h> 31#include <asm/iommu.h>
32#include <asm/gart.h> 32#include <asm/gart.h>
33#include <asm/x86_init.h> 33#include <asm/x86_init.h>
34 34#include <asm/iommu_table.h>
35/* 35/*
36 * definitions for the ACPI scanning code 36 * definitions for the ACPI scanning code
37 */ 37 */
@@ -194,6 +194,39 @@ static inline unsigned long tbl_size(int entry_size)
194 return 1UL << shift; 194 return 1UL << shift;
195} 195}
196 196
197/* Access to l1 and l2 indexed register spaces */
198
199static u32 iommu_read_l1(struct amd_iommu *iommu, u16 l1, u8 address)
200{
201 u32 val;
202
203 pci_write_config_dword(iommu->dev, 0xf8, (address | l1 << 16));
204 pci_read_config_dword(iommu->dev, 0xfc, &val);
205 return val;
206}
207
208static void iommu_write_l1(struct amd_iommu *iommu, u16 l1, u8 address, u32 val)
209{
210 pci_write_config_dword(iommu->dev, 0xf8, (address | l1 << 16 | 1 << 31));
211 pci_write_config_dword(iommu->dev, 0xfc, val);
212 pci_write_config_dword(iommu->dev, 0xf8, (address | l1 << 16));
213}
214
215static u32 iommu_read_l2(struct amd_iommu *iommu, u8 address)
216{
217 u32 val;
218
219 pci_write_config_dword(iommu->dev, 0xf0, address);
220 pci_read_config_dword(iommu->dev, 0xf4, &val);
221 return val;
222}
223
224static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val)
225{
226 pci_write_config_dword(iommu->dev, 0xf0, (address | 1 << 8));
227 pci_write_config_dword(iommu->dev, 0xf4, val);
228}
229
197/**************************************************************************** 230/****************************************************************************
198 * 231 *
199 * AMD IOMMU MMIO register space handling functions 232 * AMD IOMMU MMIO register space handling functions
@@ -619,6 +652,7 @@ static void __init init_iommu_from_pci(struct amd_iommu *iommu)
619{ 652{
620 int cap_ptr = iommu->cap_ptr; 653 int cap_ptr = iommu->cap_ptr;
621 u32 range, misc; 654 u32 range, misc;
655 int i, j;
622 656
623 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET, 657 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
624 &iommu->cap); 658 &iommu->cap);
@@ -633,12 +667,29 @@ static void __init init_iommu_from_pci(struct amd_iommu *iommu)
633 MMIO_GET_LD(range)); 667 MMIO_GET_LD(range));
634 iommu->evt_msi_num = MMIO_MSI_NUM(misc); 668 iommu->evt_msi_num = MMIO_MSI_NUM(misc);
635 669
636 if (is_rd890_iommu(iommu->dev)) { 670 if (!is_rd890_iommu(iommu->dev))
637 pci_read_config_dword(iommu->dev, 0xf0, &iommu->cache_cfg[0]); 671 return;
638 pci_read_config_dword(iommu->dev, 0xf4, &iommu->cache_cfg[1]); 672
639 pci_read_config_dword(iommu->dev, 0xf8, &iommu->cache_cfg[2]); 673 /*
640 pci_read_config_dword(iommu->dev, 0xfc, &iommu->cache_cfg[3]); 674 * Some rd890 systems may not be fully reconfigured by the BIOS, so
641 } 675 * it's necessary for us to store this information so it can be
676 * reprogrammed on resume
677 */
678
679 pci_read_config_dword(iommu->dev, iommu->cap_ptr + 4,
680 &iommu->stored_addr_lo);
681 pci_read_config_dword(iommu->dev, iommu->cap_ptr + 8,
682 &iommu->stored_addr_hi);
683
684 /* Low bit locks writes to configuration space */
685 iommu->stored_addr_lo &= ~1;
686
687 for (i = 0; i < 6; i++)
688 for (j = 0; j < 0x12; j++)
689 iommu->stored_l1[i][j] = iommu_read_l1(iommu, i, j);
690
691 for (i = 0; i < 0x83; i++)
692 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
642} 693}
643 694
644/* 695/*
@@ -1127,14 +1178,53 @@ static void iommu_init_flags(struct amd_iommu *iommu)
1127 iommu_feature_enable(iommu, CONTROL_COHERENT_EN); 1178 iommu_feature_enable(iommu, CONTROL_COHERENT_EN);
1128} 1179}
1129 1180
1130static void iommu_apply_quirks(struct amd_iommu *iommu) 1181static void iommu_apply_resume_quirks(struct amd_iommu *iommu)
1131{ 1182{
1132 if (is_rd890_iommu(iommu->dev)) { 1183 int i, j;
1133 pci_write_config_dword(iommu->dev, 0xf0, iommu->cache_cfg[0]); 1184 u32 ioc_feature_control;
1134 pci_write_config_dword(iommu->dev, 0xf4, iommu->cache_cfg[1]); 1185 struct pci_dev *pdev = NULL;
1135 pci_write_config_dword(iommu->dev, 0xf8, iommu->cache_cfg[2]); 1186
1136 pci_write_config_dword(iommu->dev, 0xfc, iommu->cache_cfg[3]); 1187 /* RD890 BIOSes may not have completely reconfigured the iommu */
1137 } 1188 if (!is_rd890_iommu(iommu->dev))
1189 return;
1190
1191 /*
1192 * First, we need to ensure that the iommu is enabled. This is
1193 * controlled by a register in the northbridge
1194 */
1195 pdev = pci_get_bus_and_slot(iommu->dev->bus->number, PCI_DEVFN(0, 0));
1196
1197 if (!pdev)
1198 return;
1199
1200 /* Select Northbridge indirect register 0x75 and enable writing */
1201 pci_write_config_dword(pdev, 0x60, 0x75 | (1 << 7));
1202 pci_read_config_dword(pdev, 0x64, &ioc_feature_control);
1203
1204 /* Enable the iommu */
1205 if (!(ioc_feature_control & 0x1))
1206 pci_write_config_dword(pdev, 0x64, ioc_feature_control | 1);
1207
1208 pci_dev_put(pdev);
1209
1210 /* Restore the iommu BAR */
1211 pci_write_config_dword(iommu->dev, iommu->cap_ptr + 4,
1212 iommu->stored_addr_lo);
1213 pci_write_config_dword(iommu->dev, iommu->cap_ptr + 8,
1214 iommu->stored_addr_hi);
1215
1216 /* Restore the l1 indirect regs for each of the 6 l1s */
1217 for (i = 0; i < 6; i++)
1218 for (j = 0; j < 0x12; j++)
1219 iommu_write_l1(iommu, i, j, iommu->stored_l1[i][j]);
1220
1221 /* Restore the l2 indirect regs */
1222 for (i = 0; i < 0x83; i++)
1223 iommu_write_l2(iommu, i, iommu->stored_l2[i]);
1224
1225 /* Lock PCI setup registers */
1226 pci_write_config_dword(iommu->dev, iommu->cap_ptr + 4,
1227 iommu->stored_addr_lo | 1);
1138} 1228}
1139 1229
1140/* 1230/*
@@ -1147,7 +1237,6 @@ static void enable_iommus(void)
1147 1237
1148 for_each_iommu(iommu) { 1238 for_each_iommu(iommu) {
1149 iommu_disable(iommu); 1239 iommu_disable(iommu);
1150 iommu_apply_quirks(iommu);
1151 iommu_init_flags(iommu); 1240 iommu_init_flags(iommu);
1152 iommu_set_device_table(iommu); 1241 iommu_set_device_table(iommu);
1153 iommu_enable_command_buffer(iommu); 1242 iommu_enable_command_buffer(iommu);
@@ -1173,6 +1262,11 @@ static void disable_iommus(void)
1173 1262
1174static int amd_iommu_resume(struct sys_device *dev) 1263static int amd_iommu_resume(struct sys_device *dev)
1175{ 1264{
1265 struct amd_iommu *iommu;
1266
1267 for_each_iommu(iommu)
1268 iommu_apply_resume_quirks(iommu);
1269
1176 /* re-load the hardware */ 1270 /* re-load the hardware */
1177 enable_iommus(); 1271 enable_iommus();
1178 1272
@@ -1405,13 +1499,13 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)
1405 return 0; 1499 return 0;
1406} 1500}
1407 1501
1408void __init amd_iommu_detect(void) 1502int __init amd_iommu_detect(void)
1409{ 1503{
1410 if (no_iommu || (iommu_detected && !gart_iommu_aperture)) 1504 if (no_iommu || (iommu_detected && !gart_iommu_aperture))
1411 return; 1505 return -ENODEV;
1412 1506
1413 if (amd_iommu_disabled) 1507 if (amd_iommu_disabled)
1414 return; 1508 return -ENODEV;
1415 1509
1416 if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) { 1510 if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
1417 iommu_detected = 1; 1511 iommu_detected = 1;
@@ -1420,7 +1514,9 @@ void __init amd_iommu_detect(void)
1420 1514
1421 /* Make sure ACS will be enabled */ 1515 /* Make sure ACS will be enabled */
1422 pci_request_acs(); 1516 pci_request_acs();
1517 return 1;
1423 } 1518 }
1519 return -ENODEV;
1424} 1520}
1425 1521
1426/**************************************************************************** 1522/****************************************************************************
@@ -1451,3 +1547,8 @@ static int __init parse_amd_iommu_options(char *str)
1451 1547
1452__setup("amd_iommu_dump", parse_amd_iommu_dump); 1548__setup("amd_iommu_dump", parse_amd_iommu_dump);
1453__setup("amd_iommu=", parse_amd_iommu_options); 1549__setup("amd_iommu=", parse_amd_iommu_options);
1550
1551IOMMU_INIT_FINISH(amd_iommu_detect,
1552 gart_iommu_hole_init,
1553 0,
1554 0);
diff --git a/arch/x86/kernel/k8.c b/arch/x86/kernel/amd_nb.c
index 0f7bc20cfcde..8f6463d8ed0d 100644
--- a/arch/x86/kernel/k8.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -8,21 +8,19 @@
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/spinlock.h> 10#include <linux/spinlock.h>
11#include <asm/k8.h> 11#include <asm/amd_nb.h>
12
13int num_k8_northbridges;
14EXPORT_SYMBOL(num_k8_northbridges);
15 12
16static u32 *flush_words; 13static u32 *flush_words;
17 14
18struct pci_device_id k8_nb_ids[] = { 15struct pci_device_id k8_nb_ids[] = {
19 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) }, 16 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC) },
20 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) }, 17 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
18 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_MISC) },
21 {} 19 {}
22}; 20};
23EXPORT_SYMBOL(k8_nb_ids); 21EXPORT_SYMBOL(k8_nb_ids);
24 22
25struct pci_dev **k8_northbridges; 23struct k8_northbridge_info k8_northbridges;
26EXPORT_SYMBOL(k8_northbridges); 24EXPORT_SYMBOL(k8_northbridges);
27 25
28static struct pci_dev *next_k8_northbridge(struct pci_dev *dev) 26static struct pci_dev *next_k8_northbridge(struct pci_dev *dev)
@@ -40,36 +38,45 @@ int cache_k8_northbridges(void)
40 int i; 38 int i;
41 struct pci_dev *dev; 39 struct pci_dev *dev;
42 40
43 if (num_k8_northbridges) 41 if (k8_northbridges.num)
44 return 0; 42 return 0;
45 43
46 dev = NULL; 44 dev = NULL;
47 while ((dev = next_k8_northbridge(dev)) != NULL) 45 while ((dev = next_k8_northbridge(dev)) != NULL)
48 num_k8_northbridges++; 46 k8_northbridges.num++;
47
48 /* some CPU families (e.g. family 0x11) do not support GART */
49 if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 ||
50 boot_cpu_data.x86 == 0x15)
51 k8_northbridges.gart_supported = 1;
49 52
50 k8_northbridges = kmalloc((num_k8_northbridges + 1) * sizeof(void *), 53 k8_northbridges.nb_misc = kmalloc((k8_northbridges.num + 1) *
51 GFP_KERNEL); 54 sizeof(void *), GFP_KERNEL);
52 if (!k8_northbridges) 55 if (!k8_northbridges.nb_misc)
53 return -ENOMEM; 56 return -ENOMEM;
54 57
55 if (!num_k8_northbridges) { 58 if (!k8_northbridges.num) {
56 k8_northbridges[0] = NULL; 59 k8_northbridges.nb_misc[0] = NULL;
57 return 0; 60 return 0;
58 } 61 }
59 62
60 flush_words = kmalloc(num_k8_northbridges * sizeof(u32), GFP_KERNEL); 63 if (k8_northbridges.gart_supported) {
61 if (!flush_words) { 64 flush_words = kmalloc(k8_northbridges.num * sizeof(u32),
62 kfree(k8_northbridges); 65 GFP_KERNEL);
63 return -ENOMEM; 66 if (!flush_words) {
67 kfree(k8_northbridges.nb_misc);
68 return -ENOMEM;
69 }
64 } 70 }
65 71
66 dev = NULL; 72 dev = NULL;
67 i = 0; 73 i = 0;
68 while ((dev = next_k8_northbridge(dev)) != NULL) { 74 while ((dev = next_k8_northbridge(dev)) != NULL) {
69 k8_northbridges[i] = dev; 75 k8_northbridges.nb_misc[i] = dev;
70 pci_read_config_dword(dev, 0x9c, &flush_words[i++]); 76 if (k8_northbridges.gart_supported)
77 pci_read_config_dword(dev, 0x9c, &flush_words[i++]);
71 } 78 }
72 k8_northbridges[i] = NULL; 79 k8_northbridges.nb_misc[i] = NULL;
73 return 0; 80 return 0;
74} 81}
75EXPORT_SYMBOL_GPL(cache_k8_northbridges); 82EXPORT_SYMBOL_GPL(cache_k8_northbridges);
@@ -93,22 +100,25 @@ void k8_flush_garts(void)
93 unsigned long flags; 100 unsigned long flags;
94 static DEFINE_SPINLOCK(gart_lock); 101 static DEFINE_SPINLOCK(gart_lock);
95 102
103 if (!k8_northbridges.gart_supported)
104 return;
105
96 /* Avoid races between AGP and IOMMU. In theory it's not needed 106 /* Avoid races between AGP and IOMMU. In theory it's not needed
97 but I'm not sure if the hardware won't lose flush requests 107 but I'm not sure if the hardware won't lose flush requests
98 when another is pending. This whole thing is so expensive anyways 108 when another is pending. This whole thing is so expensive anyways
99 that it doesn't matter to serialize more. -AK */ 109 that it doesn't matter to serialize more. -AK */
100 spin_lock_irqsave(&gart_lock, flags); 110 spin_lock_irqsave(&gart_lock, flags);
101 flushed = 0; 111 flushed = 0;
102 for (i = 0; i < num_k8_northbridges; i++) { 112 for (i = 0; i < k8_northbridges.num; i++) {
103 pci_write_config_dword(k8_northbridges[i], 0x9c, 113 pci_write_config_dword(k8_northbridges.nb_misc[i], 0x9c,
104 flush_words[i]|1); 114 flush_words[i]|1);
105 flushed++; 115 flushed++;
106 } 116 }
107 for (i = 0; i < num_k8_northbridges; i++) { 117 for (i = 0; i < k8_northbridges.num; i++) {
108 u32 w; 118 u32 w;
109 /* Make sure the hardware actually executed the flush*/ 119 /* Make sure the hardware actually executed the flush*/
110 for (;;) { 120 for (;;) {
111 pci_read_config_dword(k8_northbridges[i], 121 pci_read_config_dword(k8_northbridges.nb_misc[i],
112 0x9c, &w); 122 0x9c, &w);
113 if (!(w & 1)) 123 if (!(w & 1))
114 break; 124 break;
diff --git a/arch/x86/kernel/apb_timer.c b/arch/x86/kernel/apb_timer.c
index 8dd77800ff5d..92543c73cf8e 100644
--- a/arch/x86/kernel/apb_timer.c
+++ b/arch/x86/kernel/apb_timer.c
@@ -231,34 +231,6 @@ static void apbt_restart_clocksource(struct clocksource *cs)
231 apbt_start_counter(phy_cs_timer_id); 231 apbt_start_counter(phy_cs_timer_id);
232} 232}
233 233
234/* Setup IRQ routing via IOAPIC */
235#ifdef CONFIG_SMP
236static void apbt_setup_irq(struct apbt_dev *adev)
237{
238 struct irq_chip *chip;
239 struct irq_desc *desc;
240
241 /* timer0 irq has been setup early */
242 if (adev->irq == 0)
243 return;
244 desc = irq_to_desc(adev->irq);
245 chip = get_irq_chip(adev->irq);
246 disable_irq(adev->irq);
247 desc->status |= IRQ_MOVE_PCNTXT;
248 irq_set_affinity(adev->irq, cpumask_of(adev->cpu));
249 /* APB timer irqs are set up as mp_irqs, timer is edge triggerred */
250 set_irq_chip_and_handler_name(adev->irq, chip, handle_edge_irq, "edge");
251 enable_irq(adev->irq);
252 if (system_state == SYSTEM_BOOTING)
253 if (request_irq(adev->irq, apbt_interrupt_handler,
254 IRQF_TIMER | IRQF_DISABLED | IRQF_NOBALANCING,
255 adev->name, adev)) {
256 printk(KERN_ERR "Failed request IRQ for APBT%d\n",
257 adev->num);
258 }
259}
260#endif
261
262static void apbt_enable_int(int n) 234static void apbt_enable_int(int n)
263{ 235{
264 unsigned long ctrl = apbt_readl(n, APBTMR_N_CONTROL); 236 unsigned long ctrl = apbt_readl(n, APBTMR_N_CONTROL);
@@ -334,6 +306,27 @@ static int __init apbt_clockevent_register(void)
334} 306}
335 307
336#ifdef CONFIG_SMP 308#ifdef CONFIG_SMP
309
310static void apbt_setup_irq(struct apbt_dev *adev)
311{
312 /* timer0 irq has been setup early */
313 if (adev->irq == 0)
314 return;
315
316 if (system_state == SYSTEM_BOOTING) {
317 irq_modify_status(adev->irq, 0, IRQ_MOVE_PCNTXT);
318 /* APB timer irqs are set up as mp_irqs, timer is edge type */
319 __set_irq_handler(adev->irq, handle_edge_irq, 0, "edge");
320 if (request_irq(adev->irq, apbt_interrupt_handler,
321 IRQF_TIMER | IRQF_DISABLED | IRQF_NOBALANCING,
322 adev->name, adev)) {
323 printk(KERN_ERR "Failed request IRQ for APBT%d\n",
324 adev->num);
325 }
326 } else
327 enable_irq(adev->irq);
328}
329
337/* Should be called with per cpu */ 330/* Should be called with per cpu */
338void apbt_setup_secondary_clock(void) 331void apbt_setup_secondary_clock(void)
339{ 332{
@@ -343,7 +336,7 @@ void apbt_setup_secondary_clock(void)
343 336
344 /* Don't register boot CPU clockevent */ 337 /* Don't register boot CPU clockevent */
345 cpu = smp_processor_id(); 338 cpu = smp_processor_id();
346 if (cpu == boot_cpu_id) 339 if (!cpu)
347 return; 340 return;
348 /* 341 /*
349 * We need to calculate the scaled math multiplication factor for 342 * We need to calculate the scaled math multiplication factor for
@@ -389,16 +382,17 @@ static int apbt_cpuhp_notify(struct notifier_block *n,
389 382
390 switch (action & 0xf) { 383 switch (action & 0xf) {
391 case CPU_DEAD: 384 case CPU_DEAD:
385 disable_irq(adev->irq);
392 apbt_disable_int(cpu); 386 apbt_disable_int(cpu);
393 if (system_state == SYSTEM_RUNNING) 387 if (system_state == SYSTEM_RUNNING) {
394 pr_debug("skipping APBT CPU %lu offline\n", cpu); 388 pr_debug("skipping APBT CPU %lu offline\n", cpu);
395 else if (adev) { 389 } else if (adev) {
396 pr_debug("APBT clockevent for cpu %lu offline\n", cpu); 390 pr_debug("APBT clockevent for cpu %lu offline\n", cpu);
397 free_irq(adev->irq, adev); 391 free_irq(adev->irq, adev);
398 } 392 }
399 break; 393 break;
400 default: 394 default:
401 pr_debug(KERN_INFO "APBT notified %lu, no action\n", action); 395 pr_debug("APBT notified %lu, no action\n", action);
402 } 396 }
403 return NOTIFY_OK; 397 return NOTIFY_OK;
404} 398}
@@ -552,7 +546,7 @@ bad_count:
552 pr_debug("APB CS going back %lx:%lx:%lx ", 546 pr_debug("APB CS going back %lx:%lx:%lx ",
553 t2, last_read, t2 - last_read); 547 t2, last_read, t2 - last_read);
554bad_count_x3: 548bad_count_x3:
555 pr_debug(KERN_INFO "tripple check enforced\n"); 549 pr_debug("triple check enforced\n");
556 t0 = apbt_readl(phy_cs_timer_id, 550 t0 = apbt_readl(phy_cs_timer_id,
557 APBTMR_N_CURRENT_VALUE); 551 APBTMR_N_CURRENT_VALUE);
558 udelay(1); 552 udelay(1);
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index a2e0caf26e17..b3a16e8f0703 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -27,7 +27,7 @@
27#include <asm/gart.h> 27#include <asm/gart.h>
28#include <asm/pci-direct.h> 28#include <asm/pci-direct.h>
29#include <asm/dma.h> 29#include <asm/dma.h>
30#include <asm/k8.h> 30#include <asm/amd_nb.h>
31#include <asm/x86_init.h> 31#include <asm/x86_init.h>
32 32
33int gart_iommu_aperture; 33int gart_iommu_aperture;
@@ -307,7 +307,7 @@ void __init early_gart_iommu_check(void)
307 continue; 307 continue;
308 308
309 ctl = read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL); 309 ctl = read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL);
310 aper_enabled = ctl & AMD64_GARTEN; 310 aper_enabled = ctl & GARTEN;
311 aper_order = (ctl >> 1) & 7; 311 aper_order = (ctl >> 1) & 7;
312 aper_size = (32 * 1024 * 1024) << aper_order; 312 aper_size = (32 * 1024 * 1024) << aper_order;
313 aper_base = read_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE) & 0x7fff; 313 aper_base = read_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE) & 0x7fff;
@@ -362,7 +362,7 @@ void __init early_gart_iommu_check(void)
362 continue; 362 continue;
363 363
364 ctl = read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL); 364 ctl = read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL);
365 ctl &= ~AMD64_GARTEN; 365 ctl &= ~GARTEN;
366 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, ctl); 366 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, ctl);
367 } 367 }
368 } 368 }
@@ -371,7 +371,7 @@ void __init early_gart_iommu_check(void)
371 371
372static int __initdata printed_gart_size_msg; 372static int __initdata printed_gart_size_msg;
373 373
374void __init gart_iommu_hole_init(void) 374int __init gart_iommu_hole_init(void)
375{ 375{
376 u32 agp_aper_base = 0, agp_aper_order = 0; 376 u32 agp_aper_base = 0, agp_aper_order = 0;
377 u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0; 377 u32 aper_size, aper_alloc = 0, aper_order = 0, last_aper_order = 0;
@@ -381,7 +381,7 @@ void __init gart_iommu_hole_init(void)
381 381
382 if (gart_iommu_aperture_disabled || !fix_aperture || 382 if (gart_iommu_aperture_disabled || !fix_aperture ||
383 !early_pci_allowed()) 383 !early_pci_allowed())
384 return; 384 return -ENODEV;
385 385
386 printk(KERN_INFO "Checking aperture...\n"); 386 printk(KERN_INFO "Checking aperture...\n");
387 387
@@ -463,8 +463,9 @@ out:
463 unsigned long n = (32 * 1024 * 1024) << last_aper_order; 463 unsigned long n = (32 * 1024 * 1024) << last_aper_order;
464 464
465 insert_aperture_resource((u32)last_aper_base, n); 465 insert_aperture_resource((u32)last_aper_base, n);
466 return 1;
466 } 467 }
467 return; 468 return 0;
468 } 469 }
469 470
470 if (!fallback_aper_force) { 471 if (!fallback_aper_force) {
@@ -500,13 +501,18 @@ out:
500 panic("Not enough memory for aperture"); 501 panic("Not enough memory for aperture");
501 } 502 }
502 } else { 503 } else {
503 return; 504 return 0;
504 } 505 }
505 506
506 /* Fix up the north bridges */ 507 /* Fix up the north bridges */
507 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) { 508 for (i = 0; i < ARRAY_SIZE(bus_dev_ranges); i++) {
508 int bus; 509 int bus, dev_base, dev_limit;
509 int dev_base, dev_limit; 510
511 /*
512 * Don't enable translation yet but enable GART IO and CPU
513 * accesses and set DISTLBWALKPRB since GART table memory is UC.
514 */
515 u32 ctl = DISTLBWALKPRB | aper_order << 1;
510 516
511 bus = bus_dev_ranges[i].bus; 517 bus = bus_dev_ranges[i].bus;
512 dev_base = bus_dev_ranges[i].dev_base; 518 dev_base = bus_dev_ranges[i].dev_base;
@@ -515,13 +521,12 @@ out:
515 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00))) 521 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00)))
516 continue; 522 continue;
517 523
518 /* Don't enable translation yet. That is done later. 524 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, ctl);
519 Assume this BIOS didn't initialise the GART so
520 just overwrite all previous bits */
521 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, aper_order << 1);
522 write_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE, aper_alloc >> 25); 525 write_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE, aper_alloc >> 25);
523 } 526 }
524 } 527 }
525 528
526 set_up_gart_resume(aper_order, aper_alloc); 529 set_up_gart_resume(aper_order, aper_alloc);
530
531 return 1;
527} 532}
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index e3b534cda49a..850657d1b0ed 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -52,6 +52,7 @@
52#include <asm/mce.h> 52#include <asm/mce.h>
53#include <asm/kvm_para.h> 53#include <asm/kvm_para.h>
54#include <asm/tsc.h> 54#include <asm/tsc.h>
55#include <asm/atomic.h>
55 56
56unsigned int num_processors; 57unsigned int num_processors;
57 58
@@ -370,38 +371,87 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
370} 371}
371 372
372/* 373/*
373 * Setup extended LVT, AMD specific (K8, family 10h) 374 * Setup extended LVT, AMD specific
374 * 375 *
375 * Vector mappings are hard coded. On K8 only offset 0 (APIC500) and 376 * Software should use the LVT offsets the BIOS provides. The offsets
376 * MCE interrupts are supported. Thus MCE offset must be set to 0. 377 * are determined by the subsystems using it like those for MCE
378 * threshold or IBS. On K8 only offset 0 (APIC500) and MCE interrupts
379 * are supported. Beginning with family 10h at least 4 offsets are
380 * available.
377 * 381 *
378 * If mask=1, the LVT entry does not generate interrupts while mask=0 382 * Since the offsets must be consistent for all cores, we keep track
379 * enables the vector. See also the BKDGs. 383 * of the LVT offsets in software and reserve the offset for the same
384 * vector also to be used on other cores. An offset is freed by
385 * setting the entry to APIC_EILVT_MASKED.
386 *
387 * If the BIOS is right, there should be no conflicts. Otherwise a
388 * "[Firmware Bug]: ..." error message is generated. However, if
389 * software does not properly determines the offsets, it is not
390 * necessarily a BIOS bug.
380 */ 391 */
381 392
382#define APIC_EILVT_LVTOFF_MCE 0 393static atomic_t eilvt_offsets[APIC_EILVT_NR_MAX];
383#define APIC_EILVT_LVTOFF_IBS 1
384 394
385static void setup_APIC_eilvt(u8 lvt_off, u8 vector, u8 msg_type, u8 mask) 395static inline int eilvt_entry_is_changeable(unsigned int old, unsigned int new)
386{ 396{
387 unsigned long reg = (lvt_off << 4) + APIC_EILVTn(0); 397 return (old & APIC_EILVT_MASKED)
388 unsigned int v = (mask << 16) | (msg_type << 8) | vector; 398 || (new == APIC_EILVT_MASKED)
389 399 || ((new & ~APIC_EILVT_MASKED) == old);
390 apic_write(reg, v);
391} 400}
392 401
393u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask) 402static unsigned int reserve_eilvt_offset(int offset, unsigned int new)
394{ 403{
395 setup_APIC_eilvt(APIC_EILVT_LVTOFF_MCE, vector, msg_type, mask); 404 unsigned int rsvd; /* 0: uninitialized */
396 return APIC_EILVT_LVTOFF_MCE; 405
406 if (offset >= APIC_EILVT_NR_MAX)
407 return ~0;
408
409 rsvd = atomic_read(&eilvt_offsets[offset]) & ~APIC_EILVT_MASKED;
410 do {
411 if (rsvd &&
412 !eilvt_entry_is_changeable(rsvd, new))
413 /* may not change if vectors are different */
414 return rsvd;
415 rsvd = atomic_cmpxchg(&eilvt_offsets[offset], rsvd, new);
416 } while (rsvd != new);
417
418 return new;
397} 419}
398 420
399u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask) 421/*
422 * If mask=1, the LVT entry does not generate interrupts while mask=0
423 * enables the vector. See also the BKDGs.
424 */
425
426int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
400{ 427{
401 setup_APIC_eilvt(APIC_EILVT_LVTOFF_IBS, vector, msg_type, mask); 428 unsigned long reg = APIC_EILVTn(offset);
402 return APIC_EILVT_LVTOFF_IBS; 429 unsigned int new, old, reserved;
430
431 new = (mask << 16) | (msg_type << 8) | vector;
432 old = apic_read(reg);
433 reserved = reserve_eilvt_offset(offset, new);
434
435 if (reserved != new) {
436 pr_err(FW_BUG "cpu %d, try to setup vector 0x%x, but "
437 "vector 0x%x was already reserved by another core, "
438 "APIC%lX=0x%x\n",
439 smp_processor_id(), new, reserved, reg, old);
440 return -EINVAL;
441 }
442
443 if (!eilvt_entry_is_changeable(old, new)) {
444 pr_err(FW_BUG "cpu %d, try to setup vector 0x%x but "
445 "register already in use, APIC%lX=0x%x\n",
446 smp_processor_id(), new, reg, old);
447 return -EBUSY;
448 }
449
450 apic_write(reg, new);
451
452 return 0;
403} 453}
404EXPORT_SYMBOL_GPL(setup_APIC_eilvt_ibs); 454EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
405 455
406/* 456/*
407 * Program the next event, relative to now 457 * Program the next event, relative to now
@@ -1665,10 +1715,7 @@ int __init APIC_init_uniprocessor(void)
1665 } 1715 }
1666#endif 1716#endif
1667 1717
1668#ifndef CONFIG_SMP
1669 enable_IR_x2apic();
1670 default_setup_apic_routing(); 1718 default_setup_apic_routing();
1671#endif
1672 1719
1673 verify_local_APIC(); 1720 verify_local_APIC();
1674 connect_bsp_APIC(); 1721 connect_bsp_APIC();
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index f1efebaf5510..8ae808d110f4 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -131,13 +131,9 @@ struct irq_pin_list {
131 struct irq_pin_list *next; 131 struct irq_pin_list *next;
132}; 132};
133 133
134static struct irq_pin_list *get_one_free_irq_2_pin(int node) 134static struct irq_pin_list *alloc_irq_pin_list(int node)
135{ 135{
136 struct irq_pin_list *pin; 136 return kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
137
138 pin = kzalloc_node(sizeof(*pin), GFP_ATOMIC, node);
139
140 return pin;
141} 137}
142 138
143/* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */ 139/* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */
@@ -150,10 +146,7 @@ static struct irq_cfg irq_cfgx[NR_IRQS];
150int __init arch_early_irq_init(void) 146int __init arch_early_irq_init(void)
151{ 147{
152 struct irq_cfg *cfg; 148 struct irq_cfg *cfg;
153 struct irq_desc *desc; 149 int count, node, i;
154 int count;
155 int node;
156 int i;
157 150
158 if (!legacy_pic->nr_legacy_irqs) { 151 if (!legacy_pic->nr_legacy_irqs) {
159 nr_irqs_gsi = 0; 152 nr_irqs_gsi = 0;
@@ -162,13 +155,15 @@ int __init arch_early_irq_init(void)
162 155
163 cfg = irq_cfgx; 156 cfg = irq_cfgx;
164 count = ARRAY_SIZE(irq_cfgx); 157 count = ARRAY_SIZE(irq_cfgx);
165 node= cpu_to_node(boot_cpu_id); 158 node = cpu_to_node(0);
159
160 /* Make sure the legacy interrupts are marked in the bitmap */
161 irq_reserve_irqs(0, legacy_pic->nr_legacy_irqs);
166 162
167 for (i = 0; i < count; i++) { 163 for (i = 0; i < count; i++) {
168 desc = irq_to_desc(i); 164 set_irq_chip_data(i, &cfg[i]);
169 desc->chip_data = &cfg[i]; 165 zalloc_cpumask_var_node(&cfg[i].domain, GFP_KERNEL, node);
170 zalloc_cpumask_var_node(&cfg[i].domain, GFP_NOWAIT, node); 166 zalloc_cpumask_var_node(&cfg[i].old_domain, GFP_KERNEL, node);
171 zalloc_cpumask_var_node(&cfg[i].old_domain, GFP_NOWAIT, node);
172 /* 167 /*
173 * For legacy IRQ's, start with assigning irq0 to irq15 to 168 * For legacy IRQ's, start with assigning irq0 to irq15 to
174 * IRQ0_VECTOR to IRQ15_VECTOR on cpu 0. 169 * IRQ0_VECTOR to IRQ15_VECTOR on cpu 0.
@@ -183,165 +178,88 @@ int __init arch_early_irq_init(void)
183} 178}
184 179
185#ifdef CONFIG_SPARSE_IRQ 180#ifdef CONFIG_SPARSE_IRQ
186struct irq_cfg *irq_cfg(unsigned int irq) 181static struct irq_cfg *irq_cfg(unsigned int irq)
187{ 182{
188 struct irq_cfg *cfg = NULL; 183 return get_irq_chip_data(irq);
189 struct irq_desc *desc;
190
191 desc = irq_to_desc(irq);
192 if (desc)
193 cfg = desc->chip_data;
194
195 return cfg;
196} 184}
197 185
198static struct irq_cfg *get_one_free_irq_cfg(int node) 186static struct irq_cfg *alloc_irq_cfg(unsigned int irq, int node)
199{ 187{
200 struct irq_cfg *cfg; 188 struct irq_cfg *cfg;
201 189
202 cfg = kzalloc_node(sizeof(*cfg), GFP_ATOMIC, node); 190 cfg = kzalloc_node(sizeof(*cfg), GFP_KERNEL, node);
203 if (cfg) { 191 if (!cfg)
204 if (!zalloc_cpumask_var_node(&cfg->domain, GFP_ATOMIC, node)) { 192 return NULL;
205 kfree(cfg); 193 if (!zalloc_cpumask_var_node(&cfg->domain, GFP_KERNEL, node))
206 cfg = NULL; 194 goto out_cfg;
207 } else if (!zalloc_cpumask_var_node(&cfg->old_domain, 195 if (!zalloc_cpumask_var_node(&cfg->old_domain, GFP_KERNEL, node))
208 GFP_ATOMIC, node)) { 196 goto out_domain;
209 free_cpumask_var(cfg->domain);
210 kfree(cfg);
211 cfg = NULL;
212 }
213 }
214
215 return cfg; 197 return cfg;
198out_domain:
199 free_cpumask_var(cfg->domain);
200out_cfg:
201 kfree(cfg);
202 return NULL;
216} 203}
217 204
218int arch_init_chip_data(struct irq_desc *desc, int node) 205static void free_irq_cfg(unsigned int at, struct irq_cfg *cfg)
219{
220 struct irq_cfg *cfg;
221
222 cfg = desc->chip_data;
223 if (!cfg) {
224 desc->chip_data = get_one_free_irq_cfg(node);
225 if (!desc->chip_data) {
226 printk(KERN_ERR "can not alloc irq_cfg\n");
227 BUG_ON(1);
228 }
229 }
230
231 return 0;
232}
233
234/* for move_irq_desc */
235static void
236init_copy_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg, int node)
237{ 206{
238 struct irq_pin_list *old_entry, *head, *tail, *entry; 207 if (!cfg)
239
240 cfg->irq_2_pin = NULL;
241 old_entry = old_cfg->irq_2_pin;
242 if (!old_entry)
243 return;
244
245 entry = get_one_free_irq_2_pin(node);
246 if (!entry)
247 return; 208 return;
209 set_irq_chip_data(at, NULL);
210 free_cpumask_var(cfg->domain);
211 free_cpumask_var(cfg->old_domain);
212 kfree(cfg);
213}
248 214
249 entry->apic = old_entry->apic; 215#else
250 entry->pin = old_entry->pin;
251 head = entry;
252 tail = entry;
253 old_entry = old_entry->next;
254 while (old_entry) {
255 entry = get_one_free_irq_2_pin(node);
256 if (!entry) {
257 entry = head;
258 while (entry) {
259 head = entry->next;
260 kfree(entry);
261 entry = head;
262 }
263 /* still use the old one */
264 return;
265 }
266 entry->apic = old_entry->apic;
267 entry->pin = old_entry->pin;
268 tail->next = entry;
269 tail = entry;
270 old_entry = old_entry->next;
271 }
272 216
273 tail->next = NULL; 217struct irq_cfg *irq_cfg(unsigned int irq)
274 cfg->irq_2_pin = head; 218{
219 return irq < nr_irqs ? irq_cfgx + irq : NULL;
275} 220}
276 221
277static void free_irq_2_pin(struct irq_cfg *old_cfg, struct irq_cfg *cfg) 222static struct irq_cfg *alloc_irq_cfg(unsigned int irq, int node)
278{ 223{
279 struct irq_pin_list *entry, *next; 224 return irq_cfgx + irq;
280 225}
281 if (old_cfg->irq_2_pin == cfg->irq_2_pin)
282 return;
283 226
284 entry = old_cfg->irq_2_pin; 227static inline void free_irq_cfg(unsigned int at, struct irq_cfg *cfg) { }
285 228
286 while (entry) { 229#endif
287 next = entry->next;
288 kfree(entry);
289 entry = next;
290 }
291 old_cfg->irq_2_pin = NULL;
292}
293 230
294void arch_init_copy_chip_data(struct irq_desc *old_desc, 231static struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node)
295 struct irq_desc *desc, int node)
296{ 232{
233 int res = irq_alloc_desc_at(at, node);
297 struct irq_cfg *cfg; 234 struct irq_cfg *cfg;
298 struct irq_cfg *old_cfg;
299
300 cfg = get_one_free_irq_cfg(node);
301
302 if (!cfg)
303 return;
304 235
305 desc->chip_data = cfg; 236 if (res < 0) {
306 237 if (res != -EEXIST)
307 old_cfg = old_desc->chip_data; 238 return NULL;
308 239 cfg = get_irq_chip_data(at);
309 memcpy(cfg, old_cfg, sizeof(struct irq_cfg)); 240 if (cfg)
310 241 return cfg;
311 init_copy_irq_2_pin(old_cfg, cfg, node); 242 }
312}
313 243
314static void free_irq_cfg(struct irq_cfg *old_cfg) 244 cfg = alloc_irq_cfg(at, node);
315{ 245 if (cfg)
316 kfree(old_cfg); 246 set_irq_chip_data(at, cfg);
247 else
248 irq_free_desc(at);
249 return cfg;
317} 250}
318 251
319void arch_free_chip_data(struct irq_desc *old_desc, struct irq_desc *desc) 252static int alloc_irq_from(unsigned int from, int node)
320{ 253{
321 struct irq_cfg *old_cfg, *cfg; 254 return irq_alloc_desc_from(from, node);
322
323 old_cfg = old_desc->chip_data;
324 cfg = desc->chip_data;
325
326 if (old_cfg == cfg)
327 return;
328
329 if (old_cfg) {
330 free_irq_2_pin(old_cfg, cfg);
331 free_irq_cfg(old_cfg);
332 old_desc->chip_data = NULL;
333 }
334} 255}
335/* end for move_irq_desc */
336 256
337#else 257static void free_irq_at(unsigned int at, struct irq_cfg *cfg)
338struct irq_cfg *irq_cfg(unsigned int irq)
339{ 258{
340 return irq < nr_irqs ? irq_cfgx + irq : NULL; 259 free_irq_cfg(at, cfg);
260 irq_free_desc(at);
341} 261}
342 262
343#endif
344
345struct io_apic { 263struct io_apic {
346 unsigned int index; 264 unsigned int index;
347 unsigned int unused[3]; 265 unsigned int unused[3];
@@ -446,7 +364,7 @@ __ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
446 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 364 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
447} 365}
448 366
449void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 367static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
450{ 368{
451 unsigned long flags; 369 unsigned long flags;
452 raw_spin_lock_irqsave(&ioapic_lock, flags); 370 raw_spin_lock_irqsave(&ioapic_lock, flags);
@@ -476,7 +394,7 @@ static void ioapic_mask_entry(int apic, int pin)
476 * fast in the common case, and fast for shared ISA-space IRQs. 394 * fast in the common case, and fast for shared ISA-space IRQs.
477 */ 395 */
478static int 396static int
479add_pin_to_irq_node_nopanic(struct irq_cfg *cfg, int node, int apic, int pin) 397__add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
480{ 398{
481 struct irq_pin_list **last, *entry; 399 struct irq_pin_list **last, *entry;
482 400
@@ -488,7 +406,7 @@ add_pin_to_irq_node_nopanic(struct irq_cfg *cfg, int node, int apic, int pin)
488 last = &entry->next; 406 last = &entry->next;
489 } 407 }
490 408
491 entry = get_one_free_irq_2_pin(node); 409 entry = alloc_irq_pin_list(node);
492 if (!entry) { 410 if (!entry) {
493 printk(KERN_ERR "can not alloc irq_pin_list (%d,%d,%d)\n", 411 printk(KERN_ERR "can not alloc irq_pin_list (%d,%d,%d)\n",
494 node, apic, pin); 412 node, apic, pin);
@@ -503,7 +421,7 @@ add_pin_to_irq_node_nopanic(struct irq_cfg *cfg, int node, int apic, int pin)
503 421
504static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin) 422static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
505{ 423{
506 if (add_pin_to_irq_node_nopanic(cfg, node, apic, pin)) 424 if (__add_pin_to_irq_node(cfg, node, apic, pin))
507 panic("IO-APIC: failed to add irq-pin. Can not proceed\n"); 425 panic("IO-APIC: failed to add irq-pin. Can not proceed\n");
508} 426}
509 427
@@ -566,11 +484,6 @@ static void __unmask_and_level_IO_APIC_irq(struct irq_pin_list *entry)
566 IO_APIC_REDIR_LEVEL_TRIGGER, NULL); 484 IO_APIC_REDIR_LEVEL_TRIGGER, NULL);
567} 485}
568 486
569static void __unmask_IO_APIC_irq(struct irq_cfg *cfg)
570{
571 io_apic_modify_irq(cfg, ~IO_APIC_REDIR_MASKED, 0, NULL);
572}
573
574static void io_apic_sync(struct irq_pin_list *entry) 487static void io_apic_sync(struct irq_pin_list *entry)
575{ 488{
576 /* 489 /*
@@ -582,44 +495,37 @@ static void io_apic_sync(struct irq_pin_list *entry)
582 readl(&io_apic->data); 495 readl(&io_apic->data);
583} 496}
584 497
585static void __mask_IO_APIC_irq(struct irq_cfg *cfg) 498static void mask_ioapic(struct irq_cfg *cfg)
586{ 499{
500 unsigned long flags;
501
502 raw_spin_lock_irqsave(&ioapic_lock, flags);
587 io_apic_modify_irq(cfg, ~0, IO_APIC_REDIR_MASKED, &io_apic_sync); 503 io_apic_modify_irq(cfg, ~0, IO_APIC_REDIR_MASKED, &io_apic_sync);
504 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
588} 505}
589 506
590static void mask_IO_APIC_irq_desc(struct irq_desc *desc) 507static void mask_ioapic_irq(struct irq_data *data)
591{ 508{
592 struct irq_cfg *cfg = desc->chip_data; 509 mask_ioapic(data->chip_data);
593 unsigned long flags; 510}
594
595 BUG_ON(!cfg);
596 511
597 raw_spin_lock_irqsave(&ioapic_lock, flags); 512static void __unmask_ioapic(struct irq_cfg *cfg)
598 __mask_IO_APIC_irq(cfg); 513{
599 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 514 io_apic_modify_irq(cfg, ~IO_APIC_REDIR_MASKED, 0, NULL);
600} 515}
601 516
602static void unmask_IO_APIC_irq_desc(struct irq_desc *desc) 517static void unmask_ioapic(struct irq_cfg *cfg)
603{ 518{
604 struct irq_cfg *cfg = desc->chip_data;
605 unsigned long flags; 519 unsigned long flags;
606 520
607 raw_spin_lock_irqsave(&ioapic_lock, flags); 521 raw_spin_lock_irqsave(&ioapic_lock, flags);
608 __unmask_IO_APIC_irq(cfg); 522 __unmask_ioapic(cfg);
609 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 523 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
610} 524}
611 525
612static void mask_IO_APIC_irq(unsigned int irq) 526static void unmask_ioapic_irq(struct irq_data *data)
613{
614 struct irq_desc *desc = irq_to_desc(irq);
615
616 mask_IO_APIC_irq_desc(desc);
617}
618static void unmask_IO_APIC_irq(unsigned int irq)
619{ 527{
620 struct irq_desc *desc = irq_to_desc(irq); 528 unmask_ioapic(data->chip_data);
621
622 unmask_IO_APIC_irq_desc(desc);
623} 529}
624 530
625static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) 531static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
@@ -689,14 +595,14 @@ struct IO_APIC_route_entry **alloc_ioapic_entries(void)
689 struct IO_APIC_route_entry **ioapic_entries; 595 struct IO_APIC_route_entry **ioapic_entries;
690 596
691 ioapic_entries = kzalloc(sizeof(*ioapic_entries) * nr_ioapics, 597 ioapic_entries = kzalloc(sizeof(*ioapic_entries) * nr_ioapics,
692 GFP_ATOMIC); 598 GFP_KERNEL);
693 if (!ioapic_entries) 599 if (!ioapic_entries)
694 return 0; 600 return 0;
695 601
696 for (apic = 0; apic < nr_ioapics; apic++) { 602 for (apic = 0; apic < nr_ioapics; apic++) {
697 ioapic_entries[apic] = 603 ioapic_entries[apic] =
698 kzalloc(sizeof(struct IO_APIC_route_entry) * 604 kzalloc(sizeof(struct IO_APIC_route_entry) *
699 nr_ioapic_registers[apic], GFP_ATOMIC); 605 nr_ioapic_registers[apic], GFP_KERNEL);
700 if (!ioapic_entries[apic]) 606 if (!ioapic_entries[apic])
701 goto nomem; 607 goto nomem;
702 } 608 }
@@ -1254,7 +1160,6 @@ void __setup_vector_irq(int cpu)
1254 /* Initialize vector_irq on a new cpu */ 1160 /* Initialize vector_irq on a new cpu */
1255 int irq, vector; 1161 int irq, vector;
1256 struct irq_cfg *cfg; 1162 struct irq_cfg *cfg;
1257 struct irq_desc *desc;
1258 1163
1259 /* 1164 /*
1260 * vector_lock will make sure that we don't run into irq vector 1165 * vector_lock will make sure that we don't run into irq vector
@@ -1263,9 +1168,10 @@ void __setup_vector_irq(int cpu)
1263 */ 1168 */
1264 raw_spin_lock(&vector_lock); 1169 raw_spin_lock(&vector_lock);
1265 /* Mark the inuse vectors */ 1170 /* Mark the inuse vectors */
1266 for_each_irq_desc(irq, desc) { 1171 for_each_active_irq(irq) {
1267 cfg = desc->chip_data; 1172 cfg = get_irq_chip_data(irq);
1268 1173 if (!cfg)
1174 continue;
1269 /* 1175 /*
1270 * If it is a legacy IRQ handled by the legacy PIC, this cpu 1176 * If it is a legacy IRQ handled by the legacy PIC, this cpu
1271 * will be part of the irq_cfg's domain. 1177 * will be part of the irq_cfg's domain.
@@ -1322,17 +1228,17 @@ static inline int IO_APIC_irq_trigger(int irq)
1322} 1228}
1323#endif 1229#endif
1324 1230
1325static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long trigger) 1231static void ioapic_register_intr(unsigned int irq, unsigned long trigger)
1326{ 1232{
1327 1233
1328 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) || 1234 if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
1329 trigger == IOAPIC_LEVEL) 1235 trigger == IOAPIC_LEVEL)
1330 desc->status |= IRQ_LEVEL; 1236 irq_set_status_flags(irq, IRQ_LEVEL);
1331 else 1237 else
1332 desc->status &= ~IRQ_LEVEL; 1238 irq_clear_status_flags(irq, IRQ_LEVEL);
1333 1239
1334 if (irq_remapped(irq)) { 1240 if (irq_remapped(get_irq_chip_data(irq))) {
1335 desc->status |= IRQ_MOVE_PCNTXT; 1241 irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
1336 if (trigger) 1242 if (trigger)
1337 set_irq_chip_and_handler_name(irq, &ir_ioapic_chip, 1243 set_irq_chip_and_handler_name(irq, &ir_ioapic_chip,
1338 handle_fasteoi_irq, 1244 handle_fasteoi_irq,
@@ -1353,10 +1259,10 @@ static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long t
1353 handle_edge_irq, "edge"); 1259 handle_edge_irq, "edge");
1354} 1260}
1355 1261
1356int setup_ioapic_entry(int apic_id, int irq, 1262static int setup_ioapic_entry(int apic_id, int irq,
1357 struct IO_APIC_route_entry *entry, 1263 struct IO_APIC_route_entry *entry,
1358 unsigned int destination, int trigger, 1264 unsigned int destination, int trigger,
1359 int polarity, int vector, int pin) 1265 int polarity, int vector, int pin)
1360{ 1266{
1361 /* 1267 /*
1362 * add it to the IO-APIC irq-routing table: 1268 * add it to the IO-APIC irq-routing table:
@@ -1377,21 +1283,7 @@ int setup_ioapic_entry(int apic_id, int irq,
1377 if (index < 0) 1283 if (index < 0)
1378 panic("Failed to allocate IRTE for ioapic %d\n", apic_id); 1284 panic("Failed to allocate IRTE for ioapic %d\n", apic_id);
1379 1285
1380 memset(&irte, 0, sizeof(irte)); 1286 prepare_irte(&irte, vector, destination);
1381
1382 irte.present = 1;
1383 irte.dst_mode = apic->irq_dest_mode;
1384 /*
1385 * Trigger mode in the IRTE will always be edge, and the
1386 * actual level or edge trigger will be setup in the IO-APIC
1387 * RTE. This will help simplify level triggered irq migration.
1388 * For more details, see the comments above explainig IO-APIC
1389 * irq migration in the presence of interrupt-remapping.
1390 */
1391 irte.trigger_mode = 0;
1392 irte.dlvry_mode = apic->irq_delivery_mode;
1393 irte.vector = vector;
1394 irte.dest_id = IRTE_DEST(destination);
1395 1287
1396 /* Set source-id of interrupt request */ 1288 /* Set source-id of interrupt request */
1397 set_ioapic_sid(&irte, apic_id); 1289 set_ioapic_sid(&irte, apic_id);
@@ -1426,18 +1318,14 @@ int setup_ioapic_entry(int apic_id, int irq,
1426 return 0; 1318 return 0;
1427} 1319}
1428 1320
1429static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq_desc *desc, 1321static void setup_ioapic_irq(int apic_id, int pin, unsigned int irq,
1430 int trigger, int polarity) 1322 struct irq_cfg *cfg, int trigger, int polarity)
1431{ 1323{
1432 struct irq_cfg *cfg;
1433 struct IO_APIC_route_entry entry; 1324 struct IO_APIC_route_entry entry;
1434 unsigned int dest; 1325 unsigned int dest;
1435 1326
1436 if (!IO_APIC_IRQ(irq)) 1327 if (!IO_APIC_IRQ(irq))
1437 return; 1328 return;
1438
1439 cfg = desc->chip_data;
1440
1441 /* 1329 /*
1442 * For legacy irqs, cfg->domain starts with cpu 0 for legacy 1330 * For legacy irqs, cfg->domain starts with cpu 0 for legacy
1443 * controllers like 8259. Now that IO-APIC can handle this irq, update 1331 * controllers like 8259. Now that IO-APIC can handle this irq, update
@@ -1466,9 +1354,9 @@ static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq
1466 return; 1354 return;
1467 } 1355 }
1468 1356
1469 ioapic_register_intr(irq, desc, trigger); 1357 ioapic_register_intr(irq, trigger);
1470 if (irq < legacy_pic->nr_legacy_irqs) 1358 if (irq < legacy_pic->nr_legacy_irqs)
1471 legacy_pic->chip->mask(irq); 1359 legacy_pic->mask(irq);
1472 1360
1473 ioapic_write_entry(apic_id, pin, entry); 1361 ioapic_write_entry(apic_id, pin, entry);
1474} 1362}
@@ -1479,11 +1367,9 @@ static struct {
1479 1367
1480static void __init setup_IO_APIC_irqs(void) 1368static void __init setup_IO_APIC_irqs(void)
1481{ 1369{
1482 int apic_id, pin, idx, irq; 1370 int apic_id, pin, idx, irq, notcon = 0;
1483 int notcon = 0; 1371 int node = cpu_to_node(0);
1484 struct irq_desc *desc;
1485 struct irq_cfg *cfg; 1372 struct irq_cfg *cfg;
1486 int node = cpu_to_node(boot_cpu_id);
1487 1373
1488 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); 1374 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
1489 1375
@@ -1520,19 +1406,17 @@ static void __init setup_IO_APIC_irqs(void)
1520 apic->multi_timer_check(apic_id, irq)) 1406 apic->multi_timer_check(apic_id, irq))
1521 continue; 1407 continue;
1522 1408
1523 desc = irq_to_desc_alloc_node(irq, node); 1409 cfg = alloc_irq_and_cfg_at(irq, node);
1524 if (!desc) { 1410 if (!cfg)
1525 printk(KERN_INFO "can not get irq_desc for %d\n", irq);
1526 continue; 1411 continue;
1527 } 1412
1528 cfg = desc->chip_data;
1529 add_pin_to_irq_node(cfg, node, apic_id, pin); 1413 add_pin_to_irq_node(cfg, node, apic_id, pin);
1530 /* 1414 /*
1531 * don't mark it in pin_programmed, so later acpi could 1415 * don't mark it in pin_programmed, so later acpi could
1532 * set it correctly when irq < 16 1416 * set it correctly when irq < 16
1533 */ 1417 */
1534 setup_IO_APIC_irq(apic_id, pin, irq, desc, 1418 setup_ioapic_irq(apic_id, pin, irq, cfg, irq_trigger(idx),
1535 irq_trigger(idx), irq_polarity(idx)); 1419 irq_polarity(idx));
1536 } 1420 }
1537 1421
1538 if (notcon) 1422 if (notcon)
@@ -1547,9 +1431,7 @@ static void __init setup_IO_APIC_irqs(void)
1547 */ 1431 */
1548void setup_IO_APIC_irq_extra(u32 gsi) 1432void setup_IO_APIC_irq_extra(u32 gsi)
1549{ 1433{
1550 int apic_id = 0, pin, idx, irq; 1434 int apic_id = 0, pin, idx, irq, node = cpu_to_node(0);
1551 int node = cpu_to_node(boot_cpu_id);
1552 struct irq_desc *desc;
1553 struct irq_cfg *cfg; 1435 struct irq_cfg *cfg;
1554 1436
1555 /* 1437 /*
@@ -1565,18 +1447,15 @@ void setup_IO_APIC_irq_extra(u32 gsi)
1565 return; 1447 return;
1566 1448
1567 irq = pin_2_irq(idx, apic_id, pin); 1449 irq = pin_2_irq(idx, apic_id, pin);
1568#ifdef CONFIG_SPARSE_IRQ 1450
1569 desc = irq_to_desc(irq); 1451 /* Only handle the non legacy irqs on secondary ioapics */
1570 if (desc) 1452 if (apic_id == 0 || irq < NR_IRQS_LEGACY)
1571 return; 1453 return;
1572#endif 1454
1573 desc = irq_to_desc_alloc_node(irq, node); 1455 cfg = alloc_irq_and_cfg_at(irq, node);
1574 if (!desc) { 1456 if (!cfg)
1575 printk(KERN_INFO "can not get irq_desc for %d\n", irq);
1576 return; 1457 return;
1577 }
1578 1458
1579 cfg = desc->chip_data;
1580 add_pin_to_irq_node(cfg, node, apic_id, pin); 1459 add_pin_to_irq_node(cfg, node, apic_id, pin);
1581 1460
1582 if (test_bit(pin, mp_ioapic_routing[apic_id].pin_programmed)) { 1461 if (test_bit(pin, mp_ioapic_routing[apic_id].pin_programmed)) {
@@ -1586,7 +1465,7 @@ void setup_IO_APIC_irq_extra(u32 gsi)
1586 } 1465 }
1587 set_bit(pin, mp_ioapic_routing[apic_id].pin_programmed); 1466 set_bit(pin, mp_ioapic_routing[apic_id].pin_programmed);
1588 1467
1589 setup_IO_APIC_irq(apic_id, pin, irq, desc, 1468 setup_ioapic_irq(apic_id, pin, irq, cfg,
1590 irq_trigger(idx), irq_polarity(idx)); 1469 irq_trigger(idx), irq_polarity(idx));
1591} 1470}
1592 1471
@@ -1637,7 +1516,6 @@ __apicdebuginit(void) print_IO_APIC(void)
1637 union IO_APIC_reg_03 reg_03; 1516 union IO_APIC_reg_03 reg_03;
1638 unsigned long flags; 1517 unsigned long flags;
1639 struct irq_cfg *cfg; 1518 struct irq_cfg *cfg;
1640 struct irq_desc *desc;
1641 unsigned int irq; 1519 unsigned int irq;
1642 1520
1643 printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries); 1521 printk(KERN_DEBUG "number of MP IRQ sources: %d.\n", mp_irq_entries);
@@ -1724,10 +1602,10 @@ __apicdebuginit(void) print_IO_APIC(void)
1724 } 1602 }
1725 } 1603 }
1726 printk(KERN_DEBUG "IRQ to pin mappings:\n"); 1604 printk(KERN_DEBUG "IRQ to pin mappings:\n");
1727 for_each_irq_desc(irq, desc) { 1605 for_each_active_irq(irq) {
1728 struct irq_pin_list *entry; 1606 struct irq_pin_list *entry;
1729 1607
1730 cfg = desc->chip_data; 1608 cfg = get_irq_chip_data(irq);
1731 if (!cfg) 1609 if (!cfg)
1732 continue; 1610 continue;
1733 entry = cfg->irq_2_pin; 1611 entry = cfg->irq_2_pin;
@@ -2234,29 +2112,26 @@ static int __init timer_irq_works(void)
2234 * an edge even if it isn't on the 8259A... 2112 * an edge even if it isn't on the 8259A...
2235 */ 2113 */
2236 2114
2237static unsigned int startup_ioapic_irq(unsigned int irq) 2115static unsigned int startup_ioapic_irq(struct irq_data *data)
2238{ 2116{
2239 int was_pending = 0; 2117 int was_pending = 0, irq = data->irq;
2240 unsigned long flags; 2118 unsigned long flags;
2241 struct irq_cfg *cfg;
2242 2119
2243 raw_spin_lock_irqsave(&ioapic_lock, flags); 2120 raw_spin_lock_irqsave(&ioapic_lock, flags);
2244 if (irq < legacy_pic->nr_legacy_irqs) { 2121 if (irq < legacy_pic->nr_legacy_irqs) {
2245 legacy_pic->chip->mask(irq); 2122 legacy_pic->mask(irq);
2246 if (legacy_pic->irq_pending(irq)) 2123 if (legacy_pic->irq_pending(irq))
2247 was_pending = 1; 2124 was_pending = 1;
2248 } 2125 }
2249 cfg = irq_cfg(irq); 2126 __unmask_ioapic(data->chip_data);
2250 __unmask_IO_APIC_irq(cfg);
2251 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2127 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2252 2128
2253 return was_pending; 2129 return was_pending;
2254} 2130}
2255 2131
2256static int ioapic_retrigger_irq(unsigned int irq) 2132static int ioapic_retrigger_irq(struct irq_data *data)
2257{ 2133{
2258 2134 struct irq_cfg *cfg = data->chip_data;
2259 struct irq_cfg *cfg = irq_cfg(irq);
2260 unsigned long flags; 2135 unsigned long flags;
2261 2136
2262 raw_spin_lock_irqsave(&vector_lock, flags); 2137 raw_spin_lock_irqsave(&vector_lock, flags);
@@ -2307,7 +2182,7 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq
2307 * With interrupt-remapping, destination information comes 2182 * With interrupt-remapping, destination information comes
2308 * from interrupt-remapping table entry. 2183 * from interrupt-remapping table entry.
2309 */ 2184 */
2310 if (!irq_remapped(irq)) 2185 if (!irq_remapped(cfg))
2311 io_apic_write(apic, 0x11 + pin*2, dest); 2186 io_apic_write(apic, 0x11 + pin*2, dest);
2312 reg = io_apic_read(apic, 0x10 + pin*2); 2187 reg = io_apic_read(apic, 0x10 + pin*2);
2313 reg &= ~IO_APIC_REDIR_VECTOR_MASK; 2188 reg &= ~IO_APIC_REDIR_VECTOR_MASK;
@@ -2317,65 +2192,46 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq
2317} 2192}
2318 2193
2319/* 2194/*
2320 * Either sets desc->affinity to a valid value, and returns 2195 * Either sets data->affinity to a valid value, and returns
2321 * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and 2196 * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
2322 * leaves desc->affinity untouched. 2197 * leaves data->affinity untouched.
2323 */ 2198 */
2324unsigned int 2199int __ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2325set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask, 2200 unsigned int *dest_id)
2326 unsigned int *dest_id)
2327{ 2201{
2328 struct irq_cfg *cfg; 2202 struct irq_cfg *cfg = data->chip_data;
2329 unsigned int irq;
2330 2203
2331 if (!cpumask_intersects(mask, cpu_online_mask)) 2204 if (!cpumask_intersects(mask, cpu_online_mask))
2332 return -1; 2205 return -1;
2333 2206
2334 irq = desc->irq; 2207 if (assign_irq_vector(data->irq, data->chip_data, mask))
2335 cfg = desc->chip_data;
2336 if (assign_irq_vector(irq, cfg, mask))
2337 return -1; 2208 return -1;
2338 2209
2339 cpumask_copy(desc->affinity, mask); 2210 cpumask_copy(data->affinity, mask);
2340 2211
2341 *dest_id = apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain); 2212 *dest_id = apic->cpu_mask_to_apicid_and(mask, cfg->domain);
2342 return 0; 2213 return 0;
2343} 2214}
2344 2215
2345static int 2216static int
2346set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) 2217ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2218 bool force)
2347{ 2219{
2348 struct irq_cfg *cfg; 2220 unsigned int dest, irq = data->irq;
2349 unsigned long flags; 2221 unsigned long flags;
2350 unsigned int dest; 2222 int ret;
2351 unsigned int irq;
2352 int ret = -1;
2353
2354 irq = desc->irq;
2355 cfg = desc->chip_data;
2356 2223
2357 raw_spin_lock_irqsave(&ioapic_lock, flags); 2224 raw_spin_lock_irqsave(&ioapic_lock, flags);
2358 ret = set_desc_affinity(desc, mask, &dest); 2225 ret = __ioapic_set_affinity(data, mask, &dest);
2359 if (!ret) { 2226 if (!ret) {
2360 /* Only the high 8 bits are valid. */ 2227 /* Only the high 8 bits are valid. */
2361 dest = SET_APIC_LOGICAL_ID(dest); 2228 dest = SET_APIC_LOGICAL_ID(dest);
2362 __target_IO_APIC_irq(irq, dest, cfg); 2229 __target_IO_APIC_irq(irq, dest, data->chip_data);
2363 } 2230 }
2364 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2231 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2365
2366 return ret; 2232 return ret;
2367} 2233}
2368 2234
2369static int
2370set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask)
2371{
2372 struct irq_desc *desc;
2373
2374 desc = irq_to_desc(irq);
2375
2376 return set_ioapic_affinity_irq_desc(desc, mask);
2377}
2378
2379#ifdef CONFIG_INTR_REMAP 2235#ifdef CONFIG_INTR_REMAP
2380 2236
2381/* 2237/*
@@ -2390,24 +2246,21 @@ set_ioapic_affinity_irq(unsigned int irq, const struct cpumask *mask)
2390 * the interrupt-remapping table entry. 2246 * the interrupt-remapping table entry.
2391 */ 2247 */
2392static int 2248static int
2393migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask) 2249ir_ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2250 bool force)
2394{ 2251{
2395 struct irq_cfg *cfg; 2252 struct irq_cfg *cfg = data->chip_data;
2253 unsigned int dest, irq = data->irq;
2396 struct irte irte; 2254 struct irte irte;
2397 unsigned int dest;
2398 unsigned int irq;
2399 int ret = -1;
2400 2255
2401 if (!cpumask_intersects(mask, cpu_online_mask)) 2256 if (!cpumask_intersects(mask, cpu_online_mask))
2402 return ret; 2257 return -EINVAL;
2403 2258
2404 irq = desc->irq;
2405 if (get_irte(irq, &irte)) 2259 if (get_irte(irq, &irte))
2406 return ret; 2260 return -EBUSY;
2407 2261
2408 cfg = desc->chip_data;
2409 if (assign_irq_vector(irq, cfg, mask)) 2262 if (assign_irq_vector(irq, cfg, mask))
2410 return ret; 2263 return -EBUSY;
2411 2264
2412 dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask); 2265 dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask);
2413 2266
@@ -2422,29 +2275,14 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask)
2422 if (cfg->move_in_progress) 2275 if (cfg->move_in_progress)
2423 send_cleanup_vector(cfg); 2276 send_cleanup_vector(cfg);
2424 2277
2425 cpumask_copy(desc->affinity, mask); 2278 cpumask_copy(data->affinity, mask);
2426
2427 return 0; 2279 return 0;
2428} 2280}
2429 2281
2430/*
2431 * Migrates the IRQ destination in the process context.
2432 */
2433static int set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc,
2434 const struct cpumask *mask)
2435{
2436 return migrate_ioapic_irq_desc(desc, mask);
2437}
2438static int set_ir_ioapic_affinity_irq(unsigned int irq,
2439 const struct cpumask *mask)
2440{
2441 struct irq_desc *desc = irq_to_desc(irq);
2442
2443 return set_ir_ioapic_affinity_irq_desc(desc, mask);
2444}
2445#else 2282#else
2446static inline int set_ir_ioapic_affinity_irq_desc(struct irq_desc *desc, 2283static inline int
2447 const struct cpumask *mask) 2284ir_ioapic_set_affinity(struct irq_data *data, const struct cpumask *mask,
2285 bool force)
2448{ 2286{
2449 return 0; 2287 return 0;
2450} 2288}
@@ -2506,10 +2344,8 @@ unlock:
2506 irq_exit(); 2344 irq_exit();
2507} 2345}
2508 2346
2509static void __irq_complete_move(struct irq_desc **descp, unsigned vector) 2347static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
2510{ 2348{
2511 struct irq_desc *desc = *descp;
2512 struct irq_cfg *cfg = desc->chip_data;
2513 unsigned me; 2349 unsigned me;
2514 2350
2515 if (likely(!cfg->move_in_progress)) 2351 if (likely(!cfg->move_in_progress))
@@ -2521,31 +2357,28 @@ static void __irq_complete_move(struct irq_desc **descp, unsigned vector)
2521 send_cleanup_vector(cfg); 2357 send_cleanup_vector(cfg);
2522} 2358}
2523 2359
2524static void irq_complete_move(struct irq_desc **descp) 2360static void irq_complete_move(struct irq_cfg *cfg)
2525{ 2361{
2526 __irq_complete_move(descp, ~get_irq_regs()->orig_ax); 2362 __irq_complete_move(cfg, ~get_irq_regs()->orig_ax);
2527} 2363}
2528 2364
2529void irq_force_complete_move(int irq) 2365void irq_force_complete_move(int irq)
2530{ 2366{
2531 struct irq_desc *desc = irq_to_desc(irq); 2367 struct irq_cfg *cfg = get_irq_chip_data(irq);
2532 struct irq_cfg *cfg = desc->chip_data;
2533 2368
2534 if (!cfg) 2369 if (!cfg)
2535 return; 2370 return;
2536 2371
2537 __irq_complete_move(&desc, cfg->vector); 2372 __irq_complete_move(cfg, cfg->vector);
2538} 2373}
2539#else 2374#else
2540static inline void irq_complete_move(struct irq_desc **descp) {} 2375static inline void irq_complete_move(struct irq_cfg *cfg) { }
2541#endif 2376#endif
2542 2377
2543static void ack_apic_edge(unsigned int irq) 2378static void ack_apic_edge(struct irq_data *data)
2544{ 2379{
2545 struct irq_desc *desc = irq_to_desc(irq); 2380 irq_complete_move(data->chip_data);
2546 2381 move_native_irq(data->irq);
2547 irq_complete_move(&desc);
2548 move_native_irq(irq);
2549 ack_APIC_irq(); 2382 ack_APIC_irq();
2550} 2383}
2551 2384
@@ -2567,10 +2400,12 @@ atomic_t irq_mis_count;
2567 * Otherwise, we simulate the EOI message manually by changing the trigger 2400 * Otherwise, we simulate the EOI message manually by changing the trigger
2568 * mode to edge and then back to level, with RTE being masked during this. 2401 * mode to edge and then back to level, with RTE being masked during this.
2569*/ 2402*/
2570static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg) 2403static void eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
2571{ 2404{
2572 struct irq_pin_list *entry; 2405 struct irq_pin_list *entry;
2406 unsigned long flags;
2573 2407
2408 raw_spin_lock_irqsave(&ioapic_lock, flags);
2574 for_each_irq_pin(entry, cfg->irq_2_pin) { 2409 for_each_irq_pin(entry, cfg->irq_2_pin) {
2575 if (mp_ioapics[entry->apic].apicver >= 0x20) { 2410 if (mp_ioapics[entry->apic].apicver >= 0x20) {
2576 /* 2411 /*
@@ -2579,7 +2414,7 @@ static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
2579 * intr-remapping table entry. Hence for the io-apic 2414 * intr-remapping table entry. Hence for the io-apic
2580 * EOI we use the pin number. 2415 * EOI we use the pin number.
2581 */ 2416 */
2582 if (irq_remapped(irq)) 2417 if (irq_remapped(cfg))
2583 io_apic_eoi(entry->apic, entry->pin); 2418 io_apic_eoi(entry->apic, entry->pin);
2584 else 2419 else
2585 io_apic_eoi(entry->apic, cfg->vector); 2420 io_apic_eoi(entry->apic, cfg->vector);
@@ -2588,36 +2423,22 @@ static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
2588 __unmask_and_level_IO_APIC_irq(entry); 2423 __unmask_and_level_IO_APIC_irq(entry);
2589 } 2424 }
2590 } 2425 }
2591}
2592
2593static void eoi_ioapic_irq(struct irq_desc *desc)
2594{
2595 struct irq_cfg *cfg;
2596 unsigned long flags;
2597 unsigned int irq;
2598
2599 irq = desc->irq;
2600 cfg = desc->chip_data;
2601
2602 raw_spin_lock_irqsave(&ioapic_lock, flags);
2603 __eoi_ioapic_irq(irq, cfg);
2604 raw_spin_unlock_irqrestore(&ioapic_lock, flags); 2426 raw_spin_unlock_irqrestore(&ioapic_lock, flags);
2605} 2427}
2606 2428
2607static void ack_apic_level(unsigned int irq) 2429static void ack_apic_level(struct irq_data *data)
2608{ 2430{
2431 struct irq_cfg *cfg = data->chip_data;
2432 int i, do_unmask_irq = 0, irq = data->irq;
2609 struct irq_desc *desc = irq_to_desc(irq); 2433 struct irq_desc *desc = irq_to_desc(irq);
2610 unsigned long v; 2434 unsigned long v;
2611 int i;
2612 struct irq_cfg *cfg;
2613 int do_unmask_irq = 0;
2614 2435
2615 irq_complete_move(&desc); 2436 irq_complete_move(cfg);
2616#ifdef CONFIG_GENERIC_PENDING_IRQ 2437#ifdef CONFIG_GENERIC_PENDING_IRQ
2617 /* If we are moving the irq we need to mask it */ 2438 /* If we are moving the irq we need to mask it */
2618 if (unlikely(desc->status & IRQ_MOVE_PENDING)) { 2439 if (unlikely(desc->status & IRQ_MOVE_PENDING)) {
2619 do_unmask_irq = 1; 2440 do_unmask_irq = 1;
2620 mask_IO_APIC_irq_desc(desc); 2441 mask_ioapic(cfg);
2621 } 2442 }
2622#endif 2443#endif
2623 2444
@@ -2653,7 +2474,6 @@ static void ack_apic_level(unsigned int irq)
2653 * we use the above logic (mask+edge followed by unmask+level) from 2474 * we use the above logic (mask+edge followed by unmask+level) from
2654 * Manfred Spraul to clear the remote IRR. 2475 * Manfred Spraul to clear the remote IRR.
2655 */ 2476 */
2656 cfg = desc->chip_data;
2657 i = cfg->vector; 2477 i = cfg->vector;
2658 v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1)); 2478 v = apic_read(APIC_TMR + ((i & ~0x1f) >> 1));
2659 2479
@@ -2673,7 +2493,7 @@ static void ack_apic_level(unsigned int irq)
2673 if (!(v & (1 << (i & 0x1f)))) { 2493 if (!(v & (1 << (i & 0x1f)))) {
2674 atomic_inc(&irq_mis_count); 2494 atomic_inc(&irq_mis_count);
2675 2495
2676 eoi_ioapic_irq(desc); 2496 eoi_ioapic_irq(irq, cfg);
2677 } 2497 }
2678 2498
2679 /* Now we can move and renable the irq */ 2499 /* Now we can move and renable the irq */
@@ -2704,61 +2524,57 @@ static void ack_apic_level(unsigned int irq)
2704 * accurate and is causing problems then it is a hardware bug 2524 * accurate and is causing problems then it is a hardware bug
2705 * and you can go talk to the chipset vendor about it. 2525 * and you can go talk to the chipset vendor about it.
2706 */ 2526 */
2707 cfg = desc->chip_data;
2708 if (!io_apic_level_ack_pending(cfg)) 2527 if (!io_apic_level_ack_pending(cfg))
2709 move_masked_irq(irq); 2528 move_masked_irq(irq);
2710 unmask_IO_APIC_irq_desc(desc); 2529 unmask_ioapic(cfg);
2711 } 2530 }
2712} 2531}
2713 2532
2714#ifdef CONFIG_INTR_REMAP 2533#ifdef CONFIG_INTR_REMAP
2715static void ir_ack_apic_edge(unsigned int irq) 2534static void ir_ack_apic_edge(struct irq_data *data)
2716{ 2535{
2717 ack_APIC_irq(); 2536 ack_APIC_irq();
2718} 2537}
2719 2538
2720static void ir_ack_apic_level(unsigned int irq) 2539static void ir_ack_apic_level(struct irq_data *data)
2721{ 2540{
2722 struct irq_desc *desc = irq_to_desc(irq);
2723
2724 ack_APIC_irq(); 2541 ack_APIC_irq();
2725 eoi_ioapic_irq(desc); 2542 eoi_ioapic_irq(data->irq, data->chip_data);
2726} 2543}
2727#endif /* CONFIG_INTR_REMAP */ 2544#endif /* CONFIG_INTR_REMAP */
2728 2545
2729static struct irq_chip ioapic_chip __read_mostly = { 2546static struct irq_chip ioapic_chip __read_mostly = {
2730 .name = "IO-APIC", 2547 .name = "IO-APIC",
2731 .startup = startup_ioapic_irq, 2548 .irq_startup = startup_ioapic_irq,
2732 .mask = mask_IO_APIC_irq, 2549 .irq_mask = mask_ioapic_irq,
2733 .unmask = unmask_IO_APIC_irq, 2550 .irq_unmask = unmask_ioapic_irq,
2734 .ack = ack_apic_edge, 2551 .irq_ack = ack_apic_edge,
2735 .eoi = ack_apic_level, 2552 .irq_eoi = ack_apic_level,
2736#ifdef CONFIG_SMP 2553#ifdef CONFIG_SMP
2737 .set_affinity = set_ioapic_affinity_irq, 2554 .irq_set_affinity = ioapic_set_affinity,
2738#endif 2555#endif
2739 .retrigger = ioapic_retrigger_irq, 2556 .irq_retrigger = ioapic_retrigger_irq,
2740}; 2557};
2741 2558
2742static struct irq_chip ir_ioapic_chip __read_mostly = { 2559static struct irq_chip ir_ioapic_chip __read_mostly = {
2743 .name = "IR-IO-APIC", 2560 .name = "IR-IO-APIC",
2744 .startup = startup_ioapic_irq, 2561 .irq_startup = startup_ioapic_irq,
2745 .mask = mask_IO_APIC_irq, 2562 .irq_mask = mask_ioapic_irq,
2746 .unmask = unmask_IO_APIC_irq, 2563 .irq_unmask = unmask_ioapic_irq,
2747#ifdef CONFIG_INTR_REMAP 2564#ifdef CONFIG_INTR_REMAP
2748 .ack = ir_ack_apic_edge, 2565 .irq_ack = ir_ack_apic_edge,
2749 .eoi = ir_ack_apic_level, 2566 .irq_eoi = ir_ack_apic_level,
2750#ifdef CONFIG_SMP 2567#ifdef CONFIG_SMP
2751 .set_affinity = set_ir_ioapic_affinity_irq, 2568 .irq_set_affinity = ir_ioapic_set_affinity,
2752#endif 2569#endif
2753#endif 2570#endif
2754 .retrigger = ioapic_retrigger_irq, 2571 .irq_retrigger = ioapic_retrigger_irq,
2755}; 2572};
2756 2573
2757static inline void init_IO_APIC_traps(void) 2574static inline void init_IO_APIC_traps(void)
2758{ 2575{
2759 int irq;
2760 struct irq_desc *desc;
2761 struct irq_cfg *cfg; 2576 struct irq_cfg *cfg;
2577 unsigned int irq;
2762 2578
2763 /* 2579 /*
2764 * NOTE! The local APIC isn't very good at handling 2580 * NOTE! The local APIC isn't very good at handling
@@ -2771,8 +2587,8 @@ static inline void init_IO_APIC_traps(void)
2771 * Also, we've got to be careful not to trash gate 2587 * Also, we've got to be careful not to trash gate
2772 * 0x80, because int 0x80 is hm, kind of importantish. ;) 2588 * 0x80, because int 0x80 is hm, kind of importantish. ;)
2773 */ 2589 */
2774 for_each_irq_desc(irq, desc) { 2590 for_each_active_irq(irq) {
2775 cfg = desc->chip_data; 2591 cfg = get_irq_chip_data(irq);
2776 if (IO_APIC_IRQ(irq) && cfg && !cfg->vector) { 2592 if (IO_APIC_IRQ(irq) && cfg && !cfg->vector) {
2777 /* 2593 /*
2778 * Hmm.. We don't have an entry for this, 2594 * Hmm.. We don't have an entry for this,
@@ -2783,7 +2599,7 @@ static inline void init_IO_APIC_traps(void)
2783 legacy_pic->make_irq(irq); 2599 legacy_pic->make_irq(irq);
2784 else 2600 else
2785 /* Strange. Oh, well.. */ 2601 /* Strange. Oh, well.. */
2786 desc->chip = &no_irq_chip; 2602 set_irq_chip(irq, &no_irq_chip);
2787 } 2603 }
2788 } 2604 }
2789} 2605}
@@ -2792,7 +2608,7 @@ static inline void init_IO_APIC_traps(void)
2792 * The local APIC irq-chip implementation: 2608 * The local APIC irq-chip implementation:
2793 */ 2609 */
2794 2610
2795static void mask_lapic_irq(unsigned int irq) 2611static void mask_lapic_irq(struct irq_data *data)
2796{ 2612{
2797 unsigned long v; 2613 unsigned long v;
2798 2614
@@ -2800,7 +2616,7 @@ static void mask_lapic_irq(unsigned int irq)
2800 apic_write(APIC_LVT0, v | APIC_LVT_MASKED); 2616 apic_write(APIC_LVT0, v | APIC_LVT_MASKED);
2801} 2617}
2802 2618
2803static void unmask_lapic_irq(unsigned int irq) 2619static void unmask_lapic_irq(struct irq_data *data)
2804{ 2620{
2805 unsigned long v; 2621 unsigned long v;
2806 2622
@@ -2808,21 +2624,21 @@ static void unmask_lapic_irq(unsigned int irq)
2808 apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED); 2624 apic_write(APIC_LVT0, v & ~APIC_LVT_MASKED);
2809} 2625}
2810 2626
2811static void ack_lapic_irq(unsigned int irq) 2627static void ack_lapic_irq(struct irq_data *data)
2812{ 2628{
2813 ack_APIC_irq(); 2629 ack_APIC_irq();
2814} 2630}
2815 2631
2816static struct irq_chip lapic_chip __read_mostly = { 2632static struct irq_chip lapic_chip __read_mostly = {
2817 .name = "local-APIC", 2633 .name = "local-APIC",
2818 .mask = mask_lapic_irq, 2634 .irq_mask = mask_lapic_irq,
2819 .unmask = unmask_lapic_irq, 2635 .irq_unmask = unmask_lapic_irq,
2820 .ack = ack_lapic_irq, 2636 .irq_ack = ack_lapic_irq,
2821}; 2637};
2822 2638
2823static void lapic_register_intr(int irq, struct irq_desc *desc) 2639static void lapic_register_intr(int irq)
2824{ 2640{
2825 desc->status &= ~IRQ_LEVEL; 2641 irq_clear_status_flags(irq, IRQ_LEVEL);
2826 set_irq_chip_and_handler_name(irq, &lapic_chip, handle_edge_irq, 2642 set_irq_chip_and_handler_name(irq, &lapic_chip, handle_edge_irq,
2827 "edge"); 2643 "edge");
2828} 2644}
@@ -2925,9 +2741,8 @@ int timer_through_8259 __initdata;
2925 */ 2741 */
2926static inline void __init check_timer(void) 2742static inline void __init check_timer(void)
2927{ 2743{
2928 struct irq_desc *desc = irq_to_desc(0); 2744 struct irq_cfg *cfg = get_irq_chip_data(0);
2929 struct irq_cfg *cfg = desc->chip_data; 2745 int node = cpu_to_node(0);
2930 int node = cpu_to_node(boot_cpu_id);
2931 int apic1, pin1, apic2, pin2; 2746 int apic1, pin1, apic2, pin2;
2932 unsigned long flags; 2747 unsigned long flags;
2933 int no_pin1 = 0; 2748 int no_pin1 = 0;
@@ -2937,7 +2752,7 @@ static inline void __init check_timer(void)
2937 /* 2752 /*
2938 * get/set the timer IRQ vector: 2753 * get/set the timer IRQ vector:
2939 */ 2754 */
2940 legacy_pic->chip->mask(0); 2755 legacy_pic->mask(0);
2941 assign_irq_vector(0, cfg, apic->target_cpus()); 2756 assign_irq_vector(0, cfg, apic->target_cpus());
2942 2757
2943 /* 2758 /*
@@ -2996,7 +2811,7 @@ static inline void __init check_timer(void)
2996 add_pin_to_irq_node(cfg, node, apic1, pin1); 2811 add_pin_to_irq_node(cfg, node, apic1, pin1);
2997 setup_timer_IRQ0_pin(apic1, pin1, cfg->vector); 2812 setup_timer_IRQ0_pin(apic1, pin1, cfg->vector);
2998 } else { 2813 } else {
2999 /* for edge trigger, setup_IO_APIC_irq already 2814 /* for edge trigger, setup_ioapic_irq already
3000 * leave it unmasked. 2815 * leave it unmasked.
3001 * so only need to unmask if it is level-trigger 2816 * so only need to unmask if it is level-trigger
3002 * do we really have level trigger timer? 2817 * do we really have level trigger timer?
@@ -3004,12 +2819,12 @@ static inline void __init check_timer(void)
3004 int idx; 2819 int idx;
3005 idx = find_irq_entry(apic1, pin1, mp_INT); 2820 idx = find_irq_entry(apic1, pin1, mp_INT);
3006 if (idx != -1 && irq_trigger(idx)) 2821 if (idx != -1 && irq_trigger(idx))
3007 unmask_IO_APIC_irq_desc(desc); 2822 unmask_ioapic(cfg);
3008 } 2823 }
3009 if (timer_irq_works()) { 2824 if (timer_irq_works()) {
3010 if (nmi_watchdog == NMI_IO_APIC) { 2825 if (nmi_watchdog == NMI_IO_APIC) {
3011 setup_nmi(); 2826 setup_nmi();
3012 legacy_pic->chip->unmask(0); 2827 legacy_pic->unmask(0);
3013 } 2828 }
3014 if (disable_timer_pin_1 > 0) 2829 if (disable_timer_pin_1 > 0)
3015 clear_IO_APIC_pin(0, pin1); 2830 clear_IO_APIC_pin(0, pin1);
@@ -3032,14 +2847,14 @@ static inline void __init check_timer(void)
3032 */ 2847 */
3033 replace_pin_at_irq_node(cfg, node, apic1, pin1, apic2, pin2); 2848 replace_pin_at_irq_node(cfg, node, apic1, pin1, apic2, pin2);
3034 setup_timer_IRQ0_pin(apic2, pin2, cfg->vector); 2849 setup_timer_IRQ0_pin(apic2, pin2, cfg->vector);
3035 legacy_pic->chip->unmask(0); 2850 legacy_pic->unmask(0);
3036 if (timer_irq_works()) { 2851 if (timer_irq_works()) {
3037 apic_printk(APIC_QUIET, KERN_INFO "....... works.\n"); 2852 apic_printk(APIC_QUIET, KERN_INFO "....... works.\n");
3038 timer_through_8259 = 1; 2853 timer_through_8259 = 1;
3039 if (nmi_watchdog == NMI_IO_APIC) { 2854 if (nmi_watchdog == NMI_IO_APIC) {
3040 legacy_pic->chip->mask(0); 2855 legacy_pic->mask(0);
3041 setup_nmi(); 2856 setup_nmi();
3042 legacy_pic->chip->unmask(0); 2857 legacy_pic->unmask(0);
3043 } 2858 }
3044 goto out; 2859 goto out;
3045 } 2860 }
@@ -3047,7 +2862,7 @@ static inline void __init check_timer(void)
3047 * Cleanup, just in case ... 2862 * Cleanup, just in case ...
3048 */ 2863 */
3049 local_irq_disable(); 2864 local_irq_disable();
3050 legacy_pic->chip->mask(0); 2865 legacy_pic->mask(0);
3051 clear_IO_APIC_pin(apic2, pin2); 2866 clear_IO_APIC_pin(apic2, pin2);
3052 apic_printk(APIC_QUIET, KERN_INFO "....... failed.\n"); 2867 apic_printk(APIC_QUIET, KERN_INFO "....... failed.\n");
3053 } 2868 }
@@ -3064,16 +2879,16 @@ static inline void __init check_timer(void)
3064 apic_printk(APIC_QUIET, KERN_INFO 2879 apic_printk(APIC_QUIET, KERN_INFO
3065 "...trying to set up timer as Virtual Wire IRQ...\n"); 2880 "...trying to set up timer as Virtual Wire IRQ...\n");
3066 2881
3067 lapic_register_intr(0, desc); 2882 lapic_register_intr(0);
3068 apic_write(APIC_LVT0, APIC_DM_FIXED | cfg->vector); /* Fixed mode */ 2883 apic_write(APIC_LVT0, APIC_DM_FIXED | cfg->vector); /* Fixed mode */
3069 legacy_pic->chip->unmask(0); 2884 legacy_pic->unmask(0);
3070 2885
3071 if (timer_irq_works()) { 2886 if (timer_irq_works()) {
3072 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n"); 2887 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n");
3073 goto out; 2888 goto out;
3074 } 2889 }
3075 local_irq_disable(); 2890 local_irq_disable();
3076 legacy_pic->chip->mask(0); 2891 legacy_pic->mask(0);
3077 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector); 2892 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector);
3078 apic_printk(APIC_QUIET, KERN_INFO "..... failed.\n"); 2893 apic_printk(APIC_QUIET, KERN_INFO "..... failed.\n");
3079 2894
@@ -3239,49 +3054,42 @@ device_initcall(ioapic_init_sysfs);
3239/* 3054/*
3240 * Dynamic irq allocate and deallocation 3055 * Dynamic irq allocate and deallocation
3241 */ 3056 */
3242unsigned int create_irq_nr(unsigned int irq_want, int node) 3057unsigned int create_irq_nr(unsigned int from, int node)
3243{ 3058{
3244 /* Allocate an unused irq */ 3059 struct irq_cfg *cfg;
3245 unsigned int irq;
3246 unsigned int new;
3247 unsigned long flags; 3060 unsigned long flags;
3248 struct irq_cfg *cfg_new = NULL; 3061 unsigned int ret = 0;
3249 struct irq_desc *desc_new = NULL; 3062 int irq;
3250
3251 irq = 0;
3252 if (irq_want < nr_irqs_gsi)
3253 irq_want = nr_irqs_gsi;
3254
3255 raw_spin_lock_irqsave(&vector_lock, flags);
3256 for (new = irq_want; new < nr_irqs; new++) {
3257 desc_new = irq_to_desc_alloc_node(new, node);
3258 if (!desc_new) {
3259 printk(KERN_INFO "can not get irq_desc for %d\n", new);
3260 continue;
3261 }
3262 cfg_new = desc_new->chip_data;
3263
3264 if (cfg_new->vector != 0)
3265 continue;
3266 3063
3267 desc_new = move_irq_desc(desc_new, node); 3064 if (from < nr_irqs_gsi)
3268 cfg_new = desc_new->chip_data; 3065 from = nr_irqs_gsi;
3269 3066
3270 if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0) 3067 irq = alloc_irq_from(from, node);
3271 irq = new; 3068 if (irq < 0)
3272 break; 3069 return 0;
3070 cfg = alloc_irq_cfg(irq, node);
3071 if (!cfg) {
3072 free_irq_at(irq, NULL);
3073 return 0;
3273 } 3074 }
3274 raw_spin_unlock_irqrestore(&vector_lock, flags);
3275 3075
3276 if (irq > 0) 3076 raw_spin_lock_irqsave(&vector_lock, flags);
3277 dynamic_irq_init_keep_chip_data(irq); 3077 if (!__assign_irq_vector(irq, cfg, apic->target_cpus()))
3078 ret = irq;
3079 raw_spin_unlock_irqrestore(&vector_lock, flags);
3278 3080
3279 return irq; 3081 if (ret) {
3082 set_irq_chip_data(irq, cfg);
3083 irq_clear_status_flags(irq, IRQ_NOREQUEST);
3084 } else {
3085 free_irq_at(irq, cfg);
3086 }
3087 return ret;
3280} 3088}
3281 3089
3282int create_irq(void) 3090int create_irq(void)
3283{ 3091{
3284 int node = cpu_to_node(boot_cpu_id); 3092 int node = cpu_to_node(0);
3285 unsigned int irq_want; 3093 unsigned int irq_want;
3286 int irq; 3094 int irq;
3287 3095
@@ -3296,14 +3104,17 @@ int create_irq(void)
3296 3104
3297void destroy_irq(unsigned int irq) 3105void destroy_irq(unsigned int irq)
3298{ 3106{
3107 struct irq_cfg *cfg = get_irq_chip_data(irq);
3299 unsigned long flags; 3108 unsigned long flags;
3300 3109
3301 dynamic_irq_cleanup_keep_chip_data(irq); 3110 irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
3302 3111
3303 free_irte(irq); 3112 if (intr_remapping_enabled)
3113 free_irte(irq);
3304 raw_spin_lock_irqsave(&vector_lock, flags); 3114 raw_spin_lock_irqsave(&vector_lock, flags);
3305 __clear_irq_vector(irq, get_irq_chip_data(irq)); 3115 __clear_irq_vector(irq, cfg);
3306 raw_spin_unlock_irqrestore(&vector_lock, flags); 3116 raw_spin_unlock_irqrestore(&vector_lock, flags);
3117 free_irq_at(irq, cfg);
3307} 3118}
3308 3119
3309/* 3120/*
@@ -3327,7 +3138,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
3327 3138
3328 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 3139 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
3329 3140
3330 if (irq_remapped(irq)) { 3141 if (irq_remapped(get_irq_chip_data(irq))) {
3331 struct irte irte; 3142 struct irte irte;
3332 int ir_index; 3143 int ir_index;
3333 u16 sub_handle; 3144 u16 sub_handle;
@@ -3335,14 +3146,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
3335 ir_index = map_irq_to_irte_handle(irq, &sub_handle); 3146 ir_index = map_irq_to_irte_handle(irq, &sub_handle);
3336 BUG_ON(ir_index == -1); 3147 BUG_ON(ir_index == -1);
3337 3148
3338 memset (&irte, 0, sizeof(irte)); 3149 prepare_irte(&irte, cfg->vector, dest);
3339
3340 irte.present = 1;
3341 irte.dst_mode = apic->irq_dest_mode;
3342 irte.trigger_mode = 0; /* edge */
3343 irte.dlvry_mode = apic->irq_delivery_mode;
3344 irte.vector = cfg->vector;
3345 irte.dest_id = IRTE_DEST(dest);
3346 3150
3347 /* Set source-id of interrupt request */ 3151 /* Set source-id of interrupt request */
3348 if (pdev) 3152 if (pdev)
@@ -3387,26 +3191,24 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq,
3387} 3191}
3388 3192
3389#ifdef CONFIG_SMP 3193#ifdef CONFIG_SMP
3390static int set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) 3194static int
3195msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3391{ 3196{
3392 struct irq_desc *desc = irq_to_desc(irq); 3197 struct irq_cfg *cfg = data->chip_data;
3393 struct irq_cfg *cfg;
3394 struct msi_msg msg; 3198 struct msi_msg msg;
3395 unsigned int dest; 3199 unsigned int dest;
3396 3200
3397 if (set_desc_affinity(desc, mask, &dest)) 3201 if (__ioapic_set_affinity(data, mask, &dest))
3398 return -1; 3202 return -1;
3399 3203
3400 cfg = desc->chip_data; 3204 __get_cached_msi_msg(data->msi_desc, &msg);
3401
3402 get_cached_msi_msg_desc(desc, &msg);
3403 3205
3404 msg.data &= ~MSI_DATA_VECTOR_MASK; 3206 msg.data &= ~MSI_DATA_VECTOR_MASK;
3405 msg.data |= MSI_DATA_VECTOR(cfg->vector); 3207 msg.data |= MSI_DATA_VECTOR(cfg->vector);
3406 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; 3208 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
3407 msg.address_lo |= MSI_ADDR_DEST_ID(dest); 3209 msg.address_lo |= MSI_ADDR_DEST_ID(dest);
3408 3210
3409 write_msi_msg_desc(desc, &msg); 3211 __write_msi_msg(data->msi_desc, &msg);
3410 3212
3411 return 0; 3213 return 0;
3412} 3214}
@@ -3416,17 +3218,17 @@ static int set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask)
3416 * done in the process context using interrupt-remapping hardware. 3218 * done in the process context using interrupt-remapping hardware.
3417 */ 3219 */
3418static int 3220static int
3419ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask) 3221ir_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3222 bool force)
3420{ 3223{
3421 struct irq_desc *desc = irq_to_desc(irq); 3224 struct irq_cfg *cfg = data->chip_data;
3422 struct irq_cfg *cfg = desc->chip_data; 3225 unsigned int dest, irq = data->irq;
3423 unsigned int dest;
3424 struct irte irte; 3226 struct irte irte;
3425 3227
3426 if (get_irte(irq, &irte)) 3228 if (get_irte(irq, &irte))
3427 return -1; 3229 return -1;
3428 3230
3429 if (set_desc_affinity(desc, mask, &dest)) 3231 if (__ioapic_set_affinity(data, mask, &dest))
3430 return -1; 3232 return -1;
3431 3233
3432 irte.vector = cfg->vector; 3234 irte.vector = cfg->vector;
@@ -3456,27 +3258,27 @@ ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask)
3456 * which implement the MSI or MSI-X Capability Structure. 3258 * which implement the MSI or MSI-X Capability Structure.
3457 */ 3259 */
3458static struct irq_chip msi_chip = { 3260static struct irq_chip msi_chip = {
3459 .name = "PCI-MSI", 3261 .name = "PCI-MSI",
3460 .unmask = unmask_msi_irq, 3262 .irq_unmask = unmask_msi_irq,
3461 .mask = mask_msi_irq, 3263 .irq_mask = mask_msi_irq,
3462 .ack = ack_apic_edge, 3264 .irq_ack = ack_apic_edge,
3463#ifdef CONFIG_SMP 3265#ifdef CONFIG_SMP
3464 .set_affinity = set_msi_irq_affinity, 3266 .irq_set_affinity = msi_set_affinity,
3465#endif 3267#endif
3466 .retrigger = ioapic_retrigger_irq, 3268 .irq_retrigger = ioapic_retrigger_irq,
3467}; 3269};
3468 3270
3469static struct irq_chip msi_ir_chip = { 3271static struct irq_chip msi_ir_chip = {
3470 .name = "IR-PCI-MSI", 3272 .name = "IR-PCI-MSI",
3471 .unmask = unmask_msi_irq, 3273 .irq_unmask = unmask_msi_irq,
3472 .mask = mask_msi_irq, 3274 .irq_mask = mask_msi_irq,
3473#ifdef CONFIG_INTR_REMAP 3275#ifdef CONFIG_INTR_REMAP
3474 .ack = ir_ack_apic_edge, 3276 .irq_ack = ir_ack_apic_edge,
3475#ifdef CONFIG_SMP 3277#ifdef CONFIG_SMP
3476 .set_affinity = ir_set_msi_irq_affinity, 3278 .irq_set_affinity = ir_msi_set_affinity,
3477#endif 3279#endif
3478#endif 3280#endif
3479 .retrigger = ioapic_retrigger_irq, 3281 .irq_retrigger = ioapic_retrigger_irq,
3480}; 3282};
3481 3283
3482/* 3284/*
@@ -3508,8 +3310,8 @@ static int msi_alloc_irte(struct pci_dev *dev, int irq, int nvec)
3508 3310
3509static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq) 3311static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
3510{ 3312{
3511 int ret;
3512 struct msi_msg msg; 3313 struct msi_msg msg;
3314 int ret;
3513 3315
3514 ret = msi_compose_msg(dev, irq, &msg, -1); 3316 ret = msi_compose_msg(dev, irq, &msg, -1);
3515 if (ret < 0) 3317 if (ret < 0)
@@ -3518,12 +3320,8 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
3518 set_irq_msi(irq, msidesc); 3320 set_irq_msi(irq, msidesc);
3519 write_msi_msg(irq, &msg); 3321 write_msi_msg(irq, &msg);
3520 3322
3521 if (irq_remapped(irq)) { 3323 if (irq_remapped(get_irq_chip_data(irq))) {
3522 struct irq_desc *desc = irq_to_desc(irq); 3324 irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
3523 /*
3524 * irq migration in process context
3525 */
3526 desc->status |= IRQ_MOVE_PCNTXT;
3527 set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge"); 3325 set_irq_chip_and_handler_name(irq, &msi_ir_chip, handle_edge_irq, "edge");
3528 } else 3326 } else
3529 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge"); 3327 set_irq_chip_and_handler_name(irq, &msi_chip, handle_edge_irq, "edge");
@@ -3535,13 +3333,10 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
3535 3333
3536int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) 3334int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
3537{ 3335{
3538 unsigned int irq; 3336 int node, ret, sub_handle, index = 0;
3539 int ret, sub_handle; 3337 unsigned int irq, irq_want;
3540 struct msi_desc *msidesc; 3338 struct msi_desc *msidesc;
3541 unsigned int irq_want;
3542 struct intel_iommu *iommu = NULL; 3339 struct intel_iommu *iommu = NULL;
3543 int index = 0;
3544 int node;
3545 3340
3546 /* x86 doesn't support multiple MSI yet */ 3341 /* x86 doesn't support multiple MSI yet */
3547 if (type == PCI_CAP_ID_MSI && nvec > 1) 3342 if (type == PCI_CAP_ID_MSI && nvec > 1)
@@ -3601,18 +3396,17 @@ void arch_teardown_msi_irq(unsigned int irq)
3601 3396
3602#if defined (CONFIG_DMAR) || defined (CONFIG_INTR_REMAP) 3397#if defined (CONFIG_DMAR) || defined (CONFIG_INTR_REMAP)
3603#ifdef CONFIG_SMP 3398#ifdef CONFIG_SMP
3604static int dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask) 3399static int
3400dmar_msi_set_affinity(struct irq_data *data, const struct cpumask *mask,
3401 bool force)
3605{ 3402{
3606 struct irq_desc *desc = irq_to_desc(irq); 3403 struct irq_cfg *cfg = data->chip_data;
3607 struct irq_cfg *cfg; 3404 unsigned int dest, irq = data->irq;
3608 struct msi_msg msg; 3405 struct msi_msg msg;
3609 unsigned int dest;
3610 3406
3611 if (set_desc_affinity(desc, mask, &dest)) 3407 if (__ioapic_set_affinity(data, mask, &dest))
3612 return -1; 3408 return -1;
3613 3409
3614 cfg = desc->chip_data;
3615
3616 dmar_msi_read(irq, &msg); 3410 dmar_msi_read(irq, &msg);
3617 3411
3618 msg.data &= ~MSI_DATA_VECTOR_MASK; 3412 msg.data &= ~MSI_DATA_VECTOR_MASK;
@@ -3628,14 +3422,14 @@ static int dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
3628#endif /* CONFIG_SMP */ 3422#endif /* CONFIG_SMP */
3629 3423
3630static struct irq_chip dmar_msi_type = { 3424static struct irq_chip dmar_msi_type = {
3631 .name = "DMAR_MSI", 3425 .name = "DMAR_MSI",
3632 .unmask = dmar_msi_unmask, 3426 .irq_unmask = dmar_msi_unmask,
3633 .mask = dmar_msi_mask, 3427 .irq_mask = dmar_msi_mask,
3634 .ack = ack_apic_edge, 3428 .irq_ack = ack_apic_edge,
3635#ifdef CONFIG_SMP 3429#ifdef CONFIG_SMP
3636 .set_affinity = dmar_msi_set_affinity, 3430 .irq_set_affinity = dmar_msi_set_affinity,
3637#endif 3431#endif
3638 .retrigger = ioapic_retrigger_irq, 3432 .irq_retrigger = ioapic_retrigger_irq,
3639}; 3433};
3640 3434
3641int arch_setup_dmar_msi(unsigned int irq) 3435int arch_setup_dmar_msi(unsigned int irq)
@@ -3656,26 +3450,24 @@ int arch_setup_dmar_msi(unsigned int irq)
3656#ifdef CONFIG_HPET_TIMER 3450#ifdef CONFIG_HPET_TIMER
3657 3451
3658#ifdef CONFIG_SMP 3452#ifdef CONFIG_SMP
3659static int hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask) 3453static int hpet_msi_set_affinity(struct irq_data *data,
3454 const struct cpumask *mask, bool force)
3660{ 3455{
3661 struct irq_desc *desc = irq_to_desc(irq); 3456 struct irq_cfg *cfg = data->chip_data;
3662 struct irq_cfg *cfg;
3663 struct msi_msg msg; 3457 struct msi_msg msg;
3664 unsigned int dest; 3458 unsigned int dest;
3665 3459
3666 if (set_desc_affinity(desc, mask, &dest)) 3460 if (__ioapic_set_affinity(data, mask, &dest))
3667 return -1; 3461 return -1;
3668 3462
3669 cfg = desc->chip_data; 3463 hpet_msi_read(data->handler_data, &msg);
3670
3671 hpet_msi_read(irq, &msg);
3672 3464
3673 msg.data &= ~MSI_DATA_VECTOR_MASK; 3465 msg.data &= ~MSI_DATA_VECTOR_MASK;
3674 msg.data |= MSI_DATA_VECTOR(cfg->vector); 3466 msg.data |= MSI_DATA_VECTOR(cfg->vector);
3675 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; 3467 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
3676 msg.address_lo |= MSI_ADDR_DEST_ID(dest); 3468 msg.address_lo |= MSI_ADDR_DEST_ID(dest);
3677 3469
3678 hpet_msi_write(irq, &msg); 3470 hpet_msi_write(data->handler_data, &msg);
3679 3471
3680 return 0; 3472 return 0;
3681} 3473}
@@ -3683,34 +3475,33 @@ static int hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
3683#endif /* CONFIG_SMP */ 3475#endif /* CONFIG_SMP */
3684 3476
3685static struct irq_chip ir_hpet_msi_type = { 3477static struct irq_chip ir_hpet_msi_type = {
3686 .name = "IR-HPET_MSI", 3478 .name = "IR-HPET_MSI",
3687 .unmask = hpet_msi_unmask, 3479 .irq_unmask = hpet_msi_unmask,
3688 .mask = hpet_msi_mask, 3480 .irq_mask = hpet_msi_mask,
3689#ifdef CONFIG_INTR_REMAP 3481#ifdef CONFIG_INTR_REMAP
3690 .ack = ir_ack_apic_edge, 3482 .irq_ack = ir_ack_apic_edge,
3691#ifdef CONFIG_SMP 3483#ifdef CONFIG_SMP
3692 .set_affinity = ir_set_msi_irq_affinity, 3484 .irq_set_affinity = ir_msi_set_affinity,
3693#endif 3485#endif
3694#endif 3486#endif
3695 .retrigger = ioapic_retrigger_irq, 3487 .irq_retrigger = ioapic_retrigger_irq,
3696}; 3488};
3697 3489
3698static struct irq_chip hpet_msi_type = { 3490static struct irq_chip hpet_msi_type = {
3699 .name = "HPET_MSI", 3491 .name = "HPET_MSI",
3700 .unmask = hpet_msi_unmask, 3492 .irq_unmask = hpet_msi_unmask,
3701 .mask = hpet_msi_mask, 3493 .irq_mask = hpet_msi_mask,
3702 .ack = ack_apic_edge, 3494 .irq_ack = ack_apic_edge,
3703#ifdef CONFIG_SMP 3495#ifdef CONFIG_SMP
3704 .set_affinity = hpet_msi_set_affinity, 3496 .irq_set_affinity = hpet_msi_set_affinity,
3705#endif 3497#endif
3706 .retrigger = ioapic_retrigger_irq, 3498 .irq_retrigger = ioapic_retrigger_irq,
3707}; 3499};
3708 3500
3709int arch_setup_hpet_msi(unsigned int irq, unsigned int id) 3501int arch_setup_hpet_msi(unsigned int irq, unsigned int id)
3710{ 3502{
3711 int ret;
3712 struct msi_msg msg; 3503 struct msi_msg msg;
3713 struct irq_desc *desc = irq_to_desc(irq); 3504 int ret;
3714 3505
3715 if (intr_remapping_enabled) { 3506 if (intr_remapping_enabled) {
3716 struct intel_iommu *iommu = map_hpet_to_ir(id); 3507 struct intel_iommu *iommu = map_hpet_to_ir(id);
@@ -3728,9 +3519,9 @@ int arch_setup_hpet_msi(unsigned int irq, unsigned int id)
3728 if (ret < 0) 3519 if (ret < 0)
3729 return ret; 3520 return ret;
3730 3521
3731 hpet_msi_write(irq, &msg); 3522 hpet_msi_write(get_irq_data(irq), &msg);
3732 desc->status |= IRQ_MOVE_PCNTXT; 3523 irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
3733 if (irq_remapped(irq)) 3524 if (irq_remapped(get_irq_chip_data(irq)))
3734 set_irq_chip_and_handler_name(irq, &ir_hpet_msi_type, 3525 set_irq_chip_and_handler_name(irq, &ir_hpet_msi_type,
3735 handle_edge_irq, "edge"); 3526 handle_edge_irq, "edge");
3736 else 3527 else
@@ -3763,33 +3554,30 @@ static void target_ht_irq(unsigned int irq, unsigned int dest, u8 vector)
3763 write_ht_irq_msg(irq, &msg); 3554 write_ht_irq_msg(irq, &msg);
3764} 3555}
3765 3556
3766static int set_ht_irq_affinity(unsigned int irq, const struct cpumask *mask) 3557static int
3558ht_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
3767{ 3559{
3768 struct irq_desc *desc = irq_to_desc(irq); 3560 struct irq_cfg *cfg = data->chip_data;
3769 struct irq_cfg *cfg;
3770 unsigned int dest; 3561 unsigned int dest;
3771 3562
3772 if (set_desc_affinity(desc, mask, &dest)) 3563 if (__ioapic_set_affinity(data, mask, &dest))
3773 return -1; 3564 return -1;
3774 3565
3775 cfg = desc->chip_data; 3566 target_ht_irq(data->irq, dest, cfg->vector);
3776
3777 target_ht_irq(irq, dest, cfg->vector);
3778
3779 return 0; 3567 return 0;
3780} 3568}
3781 3569
3782#endif 3570#endif
3783 3571
3784static struct irq_chip ht_irq_chip = { 3572static struct irq_chip ht_irq_chip = {
3785 .name = "PCI-HT", 3573 .name = "PCI-HT",
3786 .mask = mask_ht_irq, 3574 .irq_mask = mask_ht_irq,
3787 .unmask = unmask_ht_irq, 3575 .irq_unmask = unmask_ht_irq,
3788 .ack = ack_apic_edge, 3576 .irq_ack = ack_apic_edge,
3789#ifdef CONFIG_SMP 3577#ifdef CONFIG_SMP
3790 .set_affinity = set_ht_irq_affinity, 3578 .irq_set_affinity = ht_set_affinity,
3791#endif 3579#endif
3792 .retrigger = ioapic_retrigger_irq, 3580 .irq_retrigger = ioapic_retrigger_irq,
3793}; 3581};
3794 3582
3795int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) 3583int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
@@ -3880,14 +3668,13 @@ int __init arch_probe_nr_irqs(void)
3880 if (nr < nr_irqs) 3668 if (nr < nr_irqs)
3881 nr_irqs = nr; 3669 nr_irqs = nr;
3882 3670
3883 return 0; 3671 return NR_IRQS_LEGACY;
3884} 3672}
3885#endif 3673#endif
3886 3674
3887static int __io_apic_set_pci_routing(struct device *dev, int irq, 3675static int __io_apic_set_pci_routing(struct device *dev, int irq,
3888 struct io_apic_irq_attr *irq_attr) 3676 struct io_apic_irq_attr *irq_attr)
3889{ 3677{
3890 struct irq_desc *desc;
3891 struct irq_cfg *cfg; 3678 struct irq_cfg *cfg;
3892 int node; 3679 int node;
3893 int ioapic, pin; 3680 int ioapic, pin;
@@ -3903,13 +3690,11 @@ static int __io_apic_set_pci_routing(struct device *dev, int irq,
3903 if (dev) 3690 if (dev)
3904 node = dev_to_node(dev); 3691 node = dev_to_node(dev);
3905 else 3692 else
3906 node = cpu_to_node(boot_cpu_id); 3693 node = cpu_to_node(0);
3907 3694
3908 desc = irq_to_desc_alloc_node(irq, node); 3695 cfg = alloc_irq_and_cfg_at(irq, node);
3909 if (!desc) { 3696 if (!cfg)
3910 printk(KERN_INFO "can not get irq_desc %d\n", irq);
3911 return 0; 3697 return 0;
3912 }
3913 3698
3914 pin = irq_attr->ioapic_pin; 3699 pin = irq_attr->ioapic_pin;
3915 trigger = irq_attr->trigger; 3700 trigger = irq_attr->trigger;
@@ -3919,15 +3704,14 @@ static int __io_apic_set_pci_routing(struct device *dev, int irq,
3919 * IRQs < 16 are already in the irq_2_pin[] map 3704 * IRQs < 16 are already in the irq_2_pin[] map
3920 */ 3705 */
3921 if (irq >= legacy_pic->nr_legacy_irqs) { 3706 if (irq >= legacy_pic->nr_legacy_irqs) {
3922 cfg = desc->chip_data; 3707 if (__add_pin_to_irq_node(cfg, node, ioapic, pin)) {
3923 if (add_pin_to_irq_node_nopanic(cfg, node, ioapic, pin)) {
3924 printk(KERN_INFO "can not add pin %d for irq %d\n", 3708 printk(KERN_INFO "can not add pin %d for irq %d\n",
3925 pin, irq); 3709 pin, irq);
3926 return 0; 3710 return 0;
3927 } 3711 }
3928 } 3712 }
3929 3713
3930 setup_IO_APIC_irq(ioapic, pin, irq, desc, trigger, polarity); 3714 setup_ioapic_irq(ioapic, pin, irq, cfg, trigger, polarity);
3931 3715
3932 return 0; 3716 return 0;
3933} 3717}
@@ -4120,14 +3904,14 @@ void __init setup_ioapic_dest(void)
4120 */ 3904 */
4121 if (desc->status & 3905 if (desc->status &
4122 (IRQ_NO_BALANCING | IRQ_AFFINITY_SET)) 3906 (IRQ_NO_BALANCING | IRQ_AFFINITY_SET))
4123 mask = desc->affinity; 3907 mask = desc->irq_data.affinity;
4124 else 3908 else
4125 mask = apic->target_cpus(); 3909 mask = apic->target_cpus();
4126 3910
4127 if (intr_remapping_enabled) 3911 if (intr_remapping_enabled)
4128 set_ir_ioapic_affinity_irq_desc(desc, mask); 3912 ir_ioapic_set_affinity(&desc->irq_data, mask, false);
4129 else 3913 else
4130 set_ioapic_affinity_irq_desc(desc, mask); 3914 ioapic_set_affinity(&desc->irq_data, mask, false);
4131 } 3915 }
4132 3916
4133} 3917}
@@ -4311,19 +4095,18 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
4311void __init pre_init_apic_IRQ0(void) 4095void __init pre_init_apic_IRQ0(void)
4312{ 4096{
4313 struct irq_cfg *cfg; 4097 struct irq_cfg *cfg;
4314 struct irq_desc *desc;
4315 4098
4316 printk(KERN_INFO "Early APIC setup for system timer0\n"); 4099 printk(KERN_INFO "Early APIC setup for system timer0\n");
4317#ifndef CONFIG_SMP 4100#ifndef CONFIG_SMP
4318 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid); 4101 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_physical_apicid);
4319#endif 4102#endif
4320 desc = irq_to_desc_alloc_node(0, 0); 4103 /* Make sure the irq descriptor is set up */
4104 cfg = alloc_irq_and_cfg_at(0, 0);
4321 4105
4322 setup_local_APIC(); 4106 setup_local_APIC();
4323 4107
4324 cfg = irq_cfg(0);
4325 add_pin_to_irq_node(cfg, 0, 0, 0); 4108 add_pin_to_irq_node(cfg, 0, 0, 0);
4326 set_irq_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq, "edge"); 4109 set_irq_chip_and_handler_name(0, &ioapic_chip, handle_edge_irq, "edge");
4327 4110
4328 setup_IO_APIC_irq(0, 0, 0, desc, 0, 0); 4111 setup_ioapic_irq(0, 0, 0, cfg, 0, 0);
4329} 4112}
diff --git a/arch/x86/kernel/apic/nmi.c b/arch/x86/kernel/apic/nmi.c
index a43f71cb30f8..c90041ccb742 100644
--- a/arch/x86/kernel/apic/nmi.c
+++ b/arch/x86/kernel/apic/nmi.c
@@ -178,7 +178,7 @@ int __init check_nmi_watchdog(void)
178error: 178error:
179 if (nmi_watchdog == NMI_IO_APIC) { 179 if (nmi_watchdog == NMI_IO_APIC) {
180 if (!timer_through_8259) 180 if (!timer_through_8259)
181 legacy_pic->chip->mask(0); 181 legacy_pic->mask(0);
182 on_each_cpu(__acpi_nmi_disable, NULL, 1); 182 on_each_cpu(__acpi_nmi_disable, NULL, 1);
183 } 183 }
184 184
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
index 3e28401f161c..960f26ab5c9f 100644
--- a/arch/x86/kernel/apic/numaq_32.c
+++ b/arch/x86/kernel/apic/numaq_32.c
@@ -26,6 +26,7 @@
26#include <linux/nodemask.h> 26#include <linux/nodemask.h>
27#include <linux/topology.h> 27#include <linux/topology.h>
28#include <linux/bootmem.h> 28#include <linux/bootmem.h>
29#include <linux/memblock.h>
29#include <linux/threads.h> 30#include <linux/threads.h>
30#include <linux/cpumask.h> 31#include <linux/cpumask.h>
31#include <linux/kernel.h> 32#include <linux/kernel.h>
@@ -88,7 +89,7 @@ static inline void numaq_register_node(int node, struct sys_cfg_data *scd)
88 node_end_pfn[node] = 89 node_end_pfn[node] =
89 MB_TO_PAGES(eq->hi_shrd_mem_start + eq->hi_shrd_mem_size); 90 MB_TO_PAGES(eq->hi_shrd_mem_start + eq->hi_shrd_mem_size);
90 91
91 e820_register_active_regions(node, node_start_pfn[node], 92 memblock_x86_register_active_regions(node, node_start_pfn[node],
92 node_end_pfn[node]); 93 node_end_pfn[node]);
93 94
94 memory_present(node, node_start_pfn[node], node_end_pfn[node]); 95 memory_present(node, node_start_pfn[node], node_end_pfn[node]);
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c
index 83e9be4778e2..f9e4e6a54073 100644
--- a/arch/x86/kernel/apic/probe_64.c
+++ b/arch/x86/kernel/apic/probe_64.c
@@ -54,6 +54,9 @@ static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
54 */ 54 */
55void __init default_setup_apic_routing(void) 55void __init default_setup_apic_routing(void)
56{ 56{
57
58 enable_IR_x2apic();
59
57#ifdef CONFIG_X86_X2APIC 60#ifdef CONFIG_X86_X2APIC
58 if (x2apic_mode 61 if (x2apic_mode
59#ifdef CONFIG_X86_UV 62#ifdef CONFIG_X86_UV
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 4c9c67bf09b7..0e4f24c2a746 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -189,8 +189,8 @@
189 * Intel Order Number 241704-001. Microsoft Part Number 781-110-X01. 189 * Intel Order Number 241704-001. Microsoft Part Number 781-110-X01.
190 * 190 *
191 * [This document is available free from Intel by calling 800.628.8686 (fax 191 * [This document is available free from Intel by calling 800.628.8686 (fax
192 * 916.356.6100) or 800.548.4725; or via anonymous ftp from 192 * 916.356.6100) or 800.548.4725; or from
193 * ftp://ftp.intel.com/pub/IAL/software_specs/apmv11.doc. It is also 193 * http://www.microsoft.com/whdc/archive/amp_12.mspx It is also
194 * available from Microsoft by calling 206.882.8080.] 194 * available from Microsoft by calling 206.882.8080.]
195 * 195 *
196 * APM 1.2 Reference: 196 * APM 1.2 Reference:
@@ -1926,6 +1926,7 @@ static const struct file_operations apm_bios_fops = {
1926 .unlocked_ioctl = do_ioctl, 1926 .unlocked_ioctl = do_ioctl,
1927 .open = do_open, 1927 .open = do_open,
1928 .release = do_release, 1928 .release = do_release,
1929 .llseek = noop_llseek,
1929}; 1930};
1930 1931
1931static struct miscdevice apm_device = { 1932static struct miscdevice apm_device = {
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index dfdbf6403895..1a4088dda37a 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -99,9 +99,7 @@ void foo(void)
99 99
100 DEFINE(PAGE_SIZE_asm, PAGE_SIZE); 100 DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
101 DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT); 101 DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
102 DEFINE(PTRS_PER_PTE, PTRS_PER_PTE); 102 DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
103 DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
104 DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
105 103
106 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); 104 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
107 105
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index fc999e6fc46a..13a389179514 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -2,7 +2,8 @@
2#include <linux/sched.h> 2#include <linux/sched.h>
3#include <linux/kthread.h> 3#include <linux/kthread.h>
4#include <linux/workqueue.h> 4#include <linux/workqueue.h>
5#include <asm/e820.h> 5#include <linux/memblock.h>
6
6#include <asm/proto.h> 7#include <asm/proto.h>
7 8
8/* 9/*
@@ -18,10 +19,12 @@ static int __read_mostly memory_corruption_check = -1;
18static unsigned __read_mostly corruption_check_size = 64*1024; 19static unsigned __read_mostly corruption_check_size = 64*1024;
19static unsigned __read_mostly corruption_check_period = 60; /* seconds */ 20static unsigned __read_mostly corruption_check_period = 60; /* seconds */
20 21
21static struct e820entry scan_areas[MAX_SCAN_AREAS]; 22static struct scan_area {
23 u64 addr;
24 u64 size;
25} scan_areas[MAX_SCAN_AREAS];
22static int num_scan_areas; 26static int num_scan_areas;
23 27
24
25static __init int set_corruption_check(char *arg) 28static __init int set_corruption_check(char *arg)
26{ 29{
27 char *end; 30 char *end;
@@ -81,9 +84,9 @@ void __init setup_bios_corruption_check(void)
81 84
82 while (addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) { 85 while (addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) {
83 u64 size; 86 u64 size;
84 addr = find_e820_area_size(addr, &size, PAGE_SIZE); 87 addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE);
85 88
86 if (!(addr + 1)) 89 if (addr == MEMBLOCK_ERROR)
87 break; 90 break;
88 91
89 if (addr >= corruption_check_size) 92 if (addr >= corruption_check_size)
@@ -92,7 +95,7 @@ void __init setup_bios_corruption_check(void)
92 if ((addr + size) > corruption_check_size) 95 if ((addr + size) > corruption_check_size)
93 size = corruption_check_size - addr; 96 size = corruption_check_size - addr;
94 97
95 e820_update_range(addr, size, E820_RAM, E820_RESERVED); 98 memblock_x86_reserve_range(addr, addr + size, "SCAN RAM");
96 scan_areas[num_scan_areas].addr = addr; 99 scan_areas[num_scan_areas].addr = addr;
97 scan_areas[num_scan_areas].size = size; 100 scan_areas[num_scan_areas].size = size;
98 num_scan_areas++; 101 num_scan_areas++;
@@ -105,7 +108,6 @@ void __init setup_bios_corruption_check(void)
105 108
106 printk(KERN_INFO "Scanning %d areas for low memory corruption\n", 109 printk(KERN_INFO "Scanning %d areas for low memory corruption\n",
107 num_scan_areas); 110 num_scan_areas);
108 update_e820();
109} 111}
110 112
111 113
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index ba5f62f45f01..9e093f8fe78c 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -148,7 +148,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c)
148{ 148{
149#ifdef CONFIG_SMP 149#ifdef CONFIG_SMP
150 /* calling is from identify_secondary_cpu() ? */ 150 /* calling is from identify_secondary_cpu() ? */
151 if (c->cpu_index == boot_cpu_id) 151 if (!c->cpu_index)
152 return; 152 return;
153 153
154 /* 154 /*
@@ -253,37 +253,51 @@ static int __cpuinit nearby_node(int apicid)
253#endif 253#endif
254 254
255/* 255/*
256 * Fixup core topology information for AMD multi-node processors. 256 * Fixup core topology information for
257 * Assumption: Number of cores in each internal node is the same. 257 * (1) AMD multi-node processors
258 * Assumption: Number of cores in each internal node is the same.
259 * (2) AMD processors supporting compute units
258 */ 260 */
259#ifdef CONFIG_X86_HT 261#ifdef CONFIG_X86_HT
260static void __cpuinit amd_fixup_dcm(struct cpuinfo_x86 *c) 262static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)
261{ 263{
262 unsigned long long value; 264 u32 nodes;
263 u32 nodes, cores_per_node; 265 u8 node_id;
264 int cpu = smp_processor_id(); 266 int cpu = smp_processor_id();
265 267
266 if (!cpu_has(c, X86_FEATURE_NODEID_MSR)) 268 /* get information required for multi-node processors */
267 return; 269 if (cpu_has(c, X86_FEATURE_TOPOEXT)) {
270 u32 eax, ebx, ecx, edx;
268 271
269 /* fixup topology information only once for a core */ 272 cpuid(0x8000001e, &eax, &ebx, &ecx, &edx);
270 if (cpu_has(c, X86_FEATURE_AMD_DCM)) 273 nodes = ((ecx >> 8) & 7) + 1;
271 return; 274 node_id = ecx & 7;
272 275
273 rdmsrl(MSR_FAM10H_NODE_ID, value); 276 /* get compute unit information */
277 smp_num_siblings = ((ebx >> 8) & 3) + 1;
278 c->compute_unit_id = ebx & 0xff;
279 } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) {
280 u64 value;
274 281
275 nodes = ((value >> 3) & 7) + 1; 282 rdmsrl(MSR_FAM10H_NODE_ID, value);
276 if (nodes == 1) 283 nodes = ((value >> 3) & 7) + 1;
284 node_id = value & 7;
285 } else
277 return; 286 return;
278 287
279 set_cpu_cap(c, X86_FEATURE_AMD_DCM); 288 /* fixup multi-node processor information */
280 cores_per_node = c->x86_max_cores / nodes; 289 if (nodes > 1) {
290 u32 cores_per_node;
291
292 set_cpu_cap(c, X86_FEATURE_AMD_DCM);
293 cores_per_node = c->x86_max_cores / nodes;
281 294
282 /* store NodeID, use llc_shared_map to store sibling info */ 295 /* store NodeID, use llc_shared_map to store sibling info */
283 per_cpu(cpu_llc_id, cpu) = value & 7; 296 per_cpu(cpu_llc_id, cpu) = node_id;
284 297
285 /* fixup core id to be in range from 0 to (cores_per_node - 1) */ 298 /* core id to be in range from 0 to (cores_per_node - 1) */
286 c->cpu_core_id = c->cpu_core_id % cores_per_node; 299 c->cpu_core_id = c->cpu_core_id % cores_per_node;
300 }
287} 301}
288#endif 302#endif
289 303
@@ -304,9 +318,7 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c)
304 c->phys_proc_id = c->initial_apicid >> bits; 318 c->phys_proc_id = c->initial_apicid >> bits;
305 /* use socket ID also for last level cache */ 319 /* use socket ID also for last level cache */
306 per_cpu(cpu_llc_id, cpu) = c->phys_proc_id; 320 per_cpu(cpu_llc_id, cpu) = c->phys_proc_id;
307 /* fixup topology information on multi-node processors */ 321 amd_get_topology(c);
308 if ((c->x86 == 0x10) && (c->x86_model == 9))
309 amd_fixup_dcm(c);
310#endif 322#endif
311} 323}
312 324
@@ -412,6 +424,23 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c)
412 set_cpu_cap(c, X86_FEATURE_EXTD_APICID); 424 set_cpu_cap(c, X86_FEATURE_EXTD_APICID);
413 } 425 }
414#endif 426#endif
427
428 /* We need to do the following only once */
429 if (c != &boot_cpu_data)
430 return;
431
432 if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
433
434 if (c->x86 > 0x10 ||
435 (c->x86 == 0x10 && c->x86_model >= 0x2)) {
436 u64 val;
437
438 rdmsrl(MSR_K7_HWCR, val);
439 if (!(val & BIT(24)))
440 printk(KERN_WARNING FW_BUG "TSC doesn't count "
441 "with P0 frequency!\n");
442 }
443 }
415} 444}
416 445
417static void __cpuinit init_amd(struct cpuinfo_x86 *c) 446static void __cpuinit init_amd(struct cpuinfo_x86 *c)
@@ -523,7 +552,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
523#endif 552#endif
524 553
525 if (c->extended_cpuid_level >= 0x80000006) { 554 if (c->extended_cpuid_level >= 0x80000006) {
526 if ((c->x86 >= 0x0f) && (cpuid_edx(0x80000006) & 0xf000)) 555 if (cpuid_edx(0x80000006) & 0xf000)
527 num_cache_leaves = 4; 556 num_cache_leaves = 4;
528 else 557 else
529 num_cache_leaves = 3; 558 num_cache_leaves = 3;
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 490dac63c2d2..4b68bda30938 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -545,7 +545,7 @@ void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
545 } 545 }
546} 546}
547 547
548static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c) 548void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
549{ 549{
550 u32 tfms, xlvl; 550 u32 tfms, xlvl;
551 u32 ebx; 551 u32 ebx;
@@ -665,7 +665,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
665 this_cpu->c_early_init(c); 665 this_cpu->c_early_init(c);
666 666
667#ifdef CONFIG_SMP 667#ifdef CONFIG_SMP
668 c->cpu_index = boot_cpu_id; 668 c->cpu_index = 0;
669#endif 669#endif
670 filter_cpuid_features(c, false); 670 filter_cpuid_features(c, false);
671} 671}
@@ -704,16 +704,21 @@ void __init early_cpu_init(void)
704} 704}
705 705
706/* 706/*
707 * The NOPL instruction is supposed to exist on all CPUs with 707 * The NOPL instruction is supposed to exist on all CPUs of family >= 6;
708 * family >= 6; unfortunately, that's not true in practice because 708 * unfortunately, that's not true in practice because of early VIA
709 * of early VIA chips and (more importantly) broken virtualizers that 709 * chips and (more importantly) broken virtualizers that are not easy
710 * are not easy to detect. In the latter case it doesn't even *fail* 710 * to detect. In the latter case it doesn't even *fail* reliably, so
711 * reliably, so probing for it doesn't even work. Disable it completely 711 * probing for it doesn't even work. Disable it completely on 32-bit
712 * unless we can find a reliable way to detect all the broken cases. 712 * unless we can find a reliable way to detect all the broken cases.
713 * Enable it explicitly on 64-bit for non-constant inputs of cpu_has().
713 */ 714 */
714static void __cpuinit detect_nopl(struct cpuinfo_x86 *c) 715static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
715{ 716{
717#ifdef CONFIG_X86_32
716 clear_cpu_cap(c, X86_FEATURE_NOPL); 718 clear_cpu_cap(c, X86_FEATURE_NOPL);
719#else
720 set_cpu_cap(c, X86_FEATURE_NOPL);
721#endif
717} 722}
718 723
719static void __cpuinit generic_identify(struct cpuinfo_x86 *c) 724static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
@@ -1264,13 +1269,6 @@ void __cpuinit cpu_init(void)
1264 clear_all_debug_regs(); 1269 clear_all_debug_regs();
1265 dbg_restore_debug_regs(); 1270 dbg_restore_debug_regs();
1266 1271
1267 /*
1268 * Force FPU initialization:
1269 */
1270 current_thread_info()->status = 0;
1271 clear_used_math();
1272 mxcsr_feature_mask_init();
1273
1274 fpu_init(); 1272 fpu_init();
1275 xsave_init(); 1273 xsave_init();
1276} 1274}
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index 3624e8a0f71b..e765633f210e 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -32,6 +32,8 @@ struct cpu_dev {
32extern const struct cpu_dev *const __x86_cpu_dev_start[], 32extern const struct cpu_dev *const __x86_cpu_dev_start[],
33 *const __x86_cpu_dev_end[]; 33 *const __x86_cpu_dev_end[];
34 34
35extern void get_cpu_cap(struct cpuinfo_x86 *c);
35extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c); 36extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);
37extern void get_cpu_cap(struct cpuinfo_x86 *c);
36 38
37#endif 39#endif
diff --git a/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c
index 994230d4dc4e..4f6f679f2799 100644
--- a/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c
@@ -368,16 +368,22 @@ static int __init pcc_cpufreq_do_osc(acpi_handle *handle)
368 return -ENODEV; 368 return -ENODEV;
369 369
370 out_obj = output.pointer; 370 out_obj = output.pointer;
371 if (out_obj->type != ACPI_TYPE_BUFFER) 371 if (out_obj->type != ACPI_TYPE_BUFFER) {
372 return -ENODEV; 372 ret = -ENODEV;
373 goto out_free;
374 }
373 375
374 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0); 376 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
375 if (errors) 377 if (errors) {
376 return -ENODEV; 378 ret = -ENODEV;
379 goto out_free;
380 }
377 381
378 supported = *((u32 *)(out_obj->buffer.pointer + 4)); 382 supported = *((u32 *)(out_obj->buffer.pointer + 4));
379 if (!(supported & 0x1)) 383 if (!(supported & 0x1)) {
380 return -ENODEV; 384 ret = -ENODEV;
385 goto out_free;
386 }
381 387
382out_free: 388out_free:
383 kfree(output.pointer); 389 kfree(output.pointer);
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 85f69cdeae10..d16c2c53d6bf 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -39,6 +39,7 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
39 misc_enable &= ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID; 39 misc_enable &= ~MSR_IA32_MISC_ENABLE_LIMIT_CPUID;
40 wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable); 40 wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
41 c->cpuid_level = cpuid_eax(0); 41 c->cpuid_level = cpuid_eax(0);
42 get_cpu_cap(c);
42 } 43 }
43 } 44 }
44 45
@@ -169,7 +170,7 @@ static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
169{ 170{
170#ifdef CONFIG_SMP 171#ifdef CONFIG_SMP
171 /* calling is from identify_secondary_cpu() ? */ 172 /* calling is from identify_secondary_cpu() ? */
172 if (c->cpu_index == boot_cpu_id) 173 if (!c->cpu_index)
173 return; 174 return;
174 175
175 /* 176 /*
@@ -283,9 +284,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
283 /* Don't do the funky fallback heuristics the AMD version employs 284 /* Don't do the funky fallback heuristics the AMD version employs
284 for now. */ 285 for now. */
285 node = apicid_to_node[apicid]; 286 node = apicid_to_node[apicid];
286 if (node == NUMA_NO_NODE) 287 if (node == NUMA_NO_NODE || !node_online(node)) {
287 node = first_node(node_online_map);
288 else if (!node_online(node)) {
289 /* reuse the value from init_cpu_to_node() */ 288 /* reuse the value from init_cpu_to_node() */
290 node = cpu_to_node(cpu); 289 node = cpu_to_node(cpu);
291 } 290 }
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 898c2f4eab88..12cd823c8d03 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -17,7 +17,7 @@
17 17
18#include <asm/processor.h> 18#include <asm/processor.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <asm/k8.h> 20#include <asm/amd_nb.h>
21#include <asm/smp.h> 21#include <asm/smp.h>
22 22
23#define LVL_1_INST 1 23#define LVL_1_INST 1
@@ -306,7 +306,7 @@ struct _cache_attr {
306 ssize_t (*store)(struct _cpuid4_info *, const char *, size_t count); 306 ssize_t (*store)(struct _cpuid4_info *, const char *, size_t count);
307}; 307};
308 308
309#ifdef CONFIG_CPU_SUP_AMD 309#ifdef CONFIG_AMD_NB
310 310
311/* 311/*
312 * L3 cache descriptors 312 * L3 cache descriptors
@@ -369,7 +369,7 @@ static void __cpuinit amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf,
369 return; 369 return;
370 370
371 /* not in virtualized environments */ 371 /* not in virtualized environments */
372 if (num_k8_northbridges == 0) 372 if (k8_northbridges.num == 0)
373 return; 373 return;
374 374
375 /* 375 /*
@@ -377,7 +377,7 @@ static void __cpuinit amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf,
377 * never freed but this is done only on shutdown so it doesn't matter. 377 * never freed but this is done only on shutdown so it doesn't matter.
378 */ 378 */
379 if (!l3_caches) { 379 if (!l3_caches) {
380 int size = num_k8_northbridges * sizeof(struct amd_l3_cache *); 380 int size = k8_northbridges.num * sizeof(struct amd_l3_cache *);
381 381
382 l3_caches = kzalloc(size, GFP_ATOMIC); 382 l3_caches = kzalloc(size, GFP_ATOMIC);
383 if (!l3_caches) 383 if (!l3_caches)
@@ -556,12 +556,12 @@ static struct _cache_attr cache_disable_0 = __ATTR(cache_disable_0, 0644,
556static struct _cache_attr cache_disable_1 = __ATTR(cache_disable_1, 0644, 556static struct _cache_attr cache_disable_1 = __ATTR(cache_disable_1, 0644,
557 show_cache_disable_1, store_cache_disable_1); 557 show_cache_disable_1, store_cache_disable_1);
558 558
559#else /* CONFIG_CPU_SUP_AMD */ 559#else /* CONFIG_AMD_NB */
560static void __cpuinit 560static void __cpuinit
561amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf, int index) 561amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf, int index)
562{ 562{
563}; 563};
564#endif /* CONFIG_CPU_SUP_AMD */ 564#endif /* CONFIG_AMD_NB */
565 565
566static int 566static int
567__cpuinit cpuid4_cache_lookup_regs(int index, 567__cpuinit cpuid4_cache_lookup_regs(int index,
@@ -1000,7 +1000,7 @@ static struct attribute *default_attrs[] = {
1000 1000
1001static struct attribute *default_l3_attrs[] = { 1001static struct attribute *default_l3_attrs[] = {
1002 DEFAULT_SYSFS_CACHE_ATTRS, 1002 DEFAULT_SYSFS_CACHE_ATTRS,
1003#ifdef CONFIG_CPU_SUP_AMD 1003#ifdef CONFIG_AMD_NB
1004 &cache_disable_0.attr, 1004 &cache_disable_0.attr,
1005 &cache_disable_1.attr, 1005 &cache_disable_1.attr,
1006#endif 1006#endif
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index 8a85dd1b1aa1..1e8d66c1336a 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -192,6 +192,7 @@ static const struct file_operations severities_coverage_fops = {
192 .release = seq_release, 192 .release = seq_release,
193 .read = seq_read, 193 .read = seq_read,
194 .write = severities_coverage_write, 194 .write = severities_coverage_write,
195 .llseek = seq_lseek,
195}; 196};
196 197
197static int __init severities_debugfs_init(void) 198static int __init severities_debugfs_init(void)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index ed41562909fe..7a35b72d7c03 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1665,6 +1665,7 @@ struct file_operations mce_chrdev_ops = {
1665 .read = mce_read, 1665 .read = mce_read,
1666 .poll = mce_poll, 1666 .poll = mce_poll,
1667 .unlocked_ioctl = mce_ioctl, 1667 .unlocked_ioctl = mce_ioctl,
1668 .llseek = no_llseek,
1668}; 1669};
1669EXPORT_SYMBOL_GPL(mce_chrdev_ops); 1670EXPORT_SYMBOL_GPL(mce_chrdev_ops);
1670 1671
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 5e975298fa81..80c482382d5c 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -131,7 +131,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
131 u32 low = 0, high = 0, address = 0; 131 u32 low = 0, high = 0, address = 0;
132 unsigned int bank, block; 132 unsigned int bank, block;
133 struct thresh_restart tr; 133 struct thresh_restart tr;
134 u8 lvt_off; 134 int lvt_off = -1;
135 u8 offset;
135 136
136 for (bank = 0; bank < NR_BANKS; ++bank) { 137 for (bank = 0; bank < NR_BANKS; ++bank) {
137 for (block = 0; block < NR_BLOCKS; ++block) { 138 for (block = 0; block < NR_BLOCKS; ++block) {
@@ -141,6 +142,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
141 address = (low & MASK_BLKPTR_LO) >> 21; 142 address = (low & MASK_BLKPTR_LO) >> 21;
142 if (!address) 143 if (!address)
143 break; 144 break;
145
144 address += MCG_XBLK_ADDR; 146 address += MCG_XBLK_ADDR;
145 } else 147 } else
146 ++address; 148 ++address;
@@ -148,12 +150,8 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
148 if (rdmsr_safe(address, &low, &high)) 150 if (rdmsr_safe(address, &low, &high))
149 break; 151 break;
150 152
151 if (!(high & MASK_VALID_HI)) { 153 if (!(high & MASK_VALID_HI))
152 if (block) 154 continue;
153 continue;
154 else
155 break;
156 }
157 155
158 if (!(high & MASK_CNTP_HI) || 156 if (!(high & MASK_CNTP_HI) ||
159 (high & MASK_LOCKED_HI)) 157 (high & MASK_LOCKED_HI))
@@ -165,8 +163,28 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c)
165 if (shared_bank[bank] && c->cpu_core_id) 163 if (shared_bank[bank] && c->cpu_core_id)
166 break; 164 break;
167#endif 165#endif
168 lvt_off = setup_APIC_eilvt_mce(THRESHOLD_APIC_VECTOR, 166 offset = (high & MASK_LVTOFF_HI) >> 20;
169 APIC_EILVT_MSG_FIX, 0); 167 if (lvt_off < 0) {
168 if (setup_APIC_eilvt(offset,
169 THRESHOLD_APIC_VECTOR,
170 APIC_EILVT_MSG_FIX, 0)) {
171 pr_err(FW_BUG "cpu %d, failed to "
172 "setup threshold interrupt "
173 "for bank %d, block %d "
174 "(MSR%08X=0x%x%08x)",
175 smp_processor_id(), bank, block,
176 address, high, low);
177 continue;
178 }
179 lvt_off = offset;
180 } else if (lvt_off != offset) {
181 pr_err(FW_BUG "cpu %d, invalid threshold "
182 "interrupt offset %d for bank %d,"
183 "block %d (MSR%08X=0x%x%08x)",
184 smp_processor_id(), lvt_off, bank,
185 block, address, high, low);
186 continue;
187 }
170 188
171 high &= ~MASK_LVTOFF_HI; 189 high &= ~MASK_LVTOFF_HI;
172 high |= lvt_off << 20; 190 high |= lvt_off << 20;
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index d9368eeda309..4b683267eca5 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -216,7 +216,7 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev,
216 err = sysfs_add_file_to_group(&sys_dev->kobj, 216 err = sysfs_add_file_to_group(&sys_dev->kobj,
217 &attr_core_power_limit_count.attr, 217 &attr_core_power_limit_count.attr,
218 thermal_attr_group.name); 218 thermal_attr_group.name);
219 if (cpu_has(c, X86_FEATURE_PTS)) 219 if (cpu_has(c, X86_FEATURE_PTS)) {
220 err = sysfs_add_file_to_group(&sys_dev->kobj, 220 err = sysfs_add_file_to_group(&sys_dev->kobj,
221 &attr_package_throttle_count.attr, 221 &attr_package_throttle_count.attr,
222 thermal_attr_group.name); 222 thermal_attr_group.name);
@@ -224,6 +224,7 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev,
224 err = sysfs_add_file_to_group(&sys_dev->kobj, 224 err = sysfs_add_file_to_group(&sys_dev->kobj,
225 &attr_package_power_limit_count.attr, 225 &attr_package_power_limit_count.attr,
226 thermal_attr_group.name); 226 thermal_attr_group.name);
227 }
227 228
228 return err; 229 return err;
229} 230}
@@ -349,7 +350,7 @@ static void intel_thermal_interrupt(void)
349 350
350static void unexpected_thermal_interrupt(void) 351static void unexpected_thermal_interrupt(void)
351{ 352{
352 printk(KERN_ERR "CPU%d: Unexpected LVT TMR interrupt!\n", 353 printk(KERN_ERR "CPU%d: Unexpected LVT thermal interrupt!\n",
353 smp_processor_id()); 354 smp_processor_id());
354 add_taint(TAINT_MACHINE_CHECK); 355 add_taint(TAINT_MACHINE_CHECK);
355} 356}
diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c
index c5f59d071425..ac140c7be396 100644
--- a/arch/x86/kernel/cpu/mtrr/cleanup.c
+++ b/arch/x86/kernel/cpu/mtrr/cleanup.c
@@ -827,7 +827,7 @@ int __init amd_special_default_mtrr(void)
827 827
828 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) 828 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
829 return 0; 829 return 0;
830 if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) 830 if (boot_cpu_data.x86 < 0xf)
831 return 0; 831 return 0;
832 /* In case some hypervisor doesn't pass SYSCFG through: */ 832 /* In case some hypervisor doesn't pass SYSCFG through: */
833 if (rdmsr_safe(MSR_K8_SYSCFG, &l, &h) < 0) 833 if (rdmsr_safe(MSR_K8_SYSCFG, &l, &h) < 0)
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index 7d28d7d03885..9f27228ceffd 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -64,18 +64,59 @@ static inline void k8_check_syscfg_dram_mod_en(void)
64 } 64 }
65} 65}
66 66
67/* Get the size of contiguous MTRR range */
68static u64 get_mtrr_size(u64 mask)
69{
70 u64 size;
71
72 mask >>= PAGE_SHIFT;
73 mask |= size_or_mask;
74 size = -mask;
75 size <<= PAGE_SHIFT;
76 return size;
77}
78
67/* 79/*
68 * Returns the effective MTRR type for the region 80 * Check and return the effective type for MTRR-MTRR type overlap.
69 * Error returns: 81 * Returns 1 if the effective type is UNCACHEABLE, else returns 0
70 * - 0xFE - when the range is "not entirely covered" by _any_ var range MTRR
71 * - 0xFF - when MTRR is not enabled
72 */ 82 */
73u8 mtrr_type_lookup(u64 start, u64 end) 83static int check_type_overlap(u8 *prev, u8 *curr)
84{
85 if (*prev == MTRR_TYPE_UNCACHABLE || *curr == MTRR_TYPE_UNCACHABLE) {
86 *prev = MTRR_TYPE_UNCACHABLE;
87 *curr = MTRR_TYPE_UNCACHABLE;
88 return 1;
89 }
90
91 if ((*prev == MTRR_TYPE_WRBACK && *curr == MTRR_TYPE_WRTHROUGH) ||
92 (*prev == MTRR_TYPE_WRTHROUGH && *curr == MTRR_TYPE_WRBACK)) {
93 *prev = MTRR_TYPE_WRTHROUGH;
94 *curr = MTRR_TYPE_WRTHROUGH;
95 }
96
97 if (*prev != *curr) {
98 *prev = MTRR_TYPE_UNCACHABLE;
99 *curr = MTRR_TYPE_UNCACHABLE;
100 return 1;
101 }
102
103 return 0;
104}
105
106/*
107 * Error/Semi-error returns:
108 * 0xFF - when MTRR is not enabled
109 * *repeat == 1 implies [start:end] spanned across MTRR range and type returned
110 * corresponds only to [start:*partial_end].
111 * Caller has to lookup again for [*partial_end:end].
112 */
113static u8 __mtrr_type_lookup(u64 start, u64 end, u64 *partial_end, int *repeat)
74{ 114{
75 int i; 115 int i;
76 u64 base, mask; 116 u64 base, mask;
77 u8 prev_match, curr_match; 117 u8 prev_match, curr_match;
78 118
119 *repeat = 0;
79 if (!mtrr_state_set) 120 if (!mtrr_state_set)
80 return 0xFF; 121 return 0xFF;
81 122
@@ -126,8 +167,34 @@ u8 mtrr_type_lookup(u64 start, u64 end)
126 167
127 start_state = ((start & mask) == (base & mask)); 168 start_state = ((start & mask) == (base & mask));
128 end_state = ((end & mask) == (base & mask)); 169 end_state = ((end & mask) == (base & mask));
129 if (start_state != end_state) 170
130 return 0xFE; 171 if (start_state != end_state) {
172 /*
173 * We have start:end spanning across an MTRR.
174 * We split the region into
175 * either
176 * (start:mtrr_end) (mtrr_end:end)
177 * or
178 * (start:mtrr_start) (mtrr_start:end)
179 * depending on kind of overlap.
180 * Return the type for first region and a pointer to
181 * the start of second region so that caller will
182 * lookup again on the second region.
183 * Note: This way we handle multiple overlaps as well.
184 */
185 if (start_state)
186 *partial_end = base + get_mtrr_size(mask);
187 else
188 *partial_end = base;
189
190 if (unlikely(*partial_end <= start)) {
191 WARN_ON(1);
192 *partial_end = start + PAGE_SIZE;
193 }
194
195 end = *partial_end - 1; /* end is inclusive */
196 *repeat = 1;
197 }
131 198
132 if ((start & mask) != (base & mask)) 199 if ((start & mask) != (base & mask))
133 continue; 200 continue;
@@ -138,21 +205,8 @@ u8 mtrr_type_lookup(u64 start, u64 end)
138 continue; 205 continue;
139 } 206 }
140 207
141 if (prev_match == MTRR_TYPE_UNCACHABLE || 208 if (check_type_overlap(&prev_match, &curr_match))
142 curr_match == MTRR_TYPE_UNCACHABLE) { 209 return curr_match;
143 return MTRR_TYPE_UNCACHABLE;
144 }
145
146 if ((prev_match == MTRR_TYPE_WRBACK &&
147 curr_match == MTRR_TYPE_WRTHROUGH) ||
148 (prev_match == MTRR_TYPE_WRTHROUGH &&
149 curr_match == MTRR_TYPE_WRBACK)) {
150 prev_match = MTRR_TYPE_WRTHROUGH;
151 curr_match = MTRR_TYPE_WRTHROUGH;
152 }
153
154 if (prev_match != curr_match)
155 return MTRR_TYPE_UNCACHABLE;
156 } 210 }
157 211
158 if (mtrr_tom2) { 212 if (mtrr_tom2) {
@@ -166,6 +220,36 @@ u8 mtrr_type_lookup(u64 start, u64 end)
166 return mtrr_state.def_type; 220 return mtrr_state.def_type;
167} 221}
168 222
223/*
224 * Returns the effective MTRR type for the region
225 * Error return:
226 * 0xFF - when MTRR is not enabled
227 */
228u8 mtrr_type_lookup(u64 start, u64 end)
229{
230 u8 type, prev_type;
231 int repeat;
232 u64 partial_end;
233
234 type = __mtrr_type_lookup(start, end, &partial_end, &repeat);
235
236 /*
237 * Common path is with repeat = 0.
238 * However, we can have cases where [start:end] spans across some
239 * MTRR range. Do repeated lookups for that case here.
240 */
241 while (repeat) {
242 prev_type = type;
243 start = partial_end;
244 type = __mtrr_type_lookup(start, end, &partial_end, &repeat);
245
246 if (check_type_overlap(&prev_type, &type))
247 return type;
248 }
249
250 return type;
251}
252
169/* Get the MSR pair relating to a var range */ 253/* Get the MSR pair relating to a var range */
170static void 254static void
171get_mtrr_var_range(unsigned int index, struct mtrr_var_range *vr) 255get_mtrr_var_range(unsigned int index, struct mtrr_var_range *vr)
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 03a5b0385ad6..fe73c1844a9a 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -531,7 +531,7 @@ static int x86_pmu_hw_config(struct perf_event *event)
531/* 531/*
532 * Setup the hardware configuration for a given attr_type 532 * Setup the hardware configuration for a given attr_type
533 */ 533 */
534static int __hw_perf_event_init(struct perf_event *event) 534static int __x86_pmu_event_init(struct perf_event *event)
535{ 535{
536 int err; 536 int err;
537 537
@@ -584,7 +584,7 @@ static void x86_pmu_disable_all(void)
584 } 584 }
585} 585}
586 586
587void hw_perf_disable(void) 587static void x86_pmu_disable(struct pmu *pmu)
588{ 588{
589 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 589 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
590 590
@@ -619,7 +619,7 @@ static void x86_pmu_enable_all(int added)
619 } 619 }
620} 620}
621 621
622static const struct pmu pmu; 622static struct pmu pmu;
623 623
624static inline int is_x86_event(struct perf_event *event) 624static inline int is_x86_event(struct perf_event *event)
625{ 625{
@@ -801,10 +801,10 @@ static inline int match_prev_assignment(struct hw_perf_event *hwc,
801 hwc->last_tag == cpuc->tags[i]; 801 hwc->last_tag == cpuc->tags[i];
802} 802}
803 803
804static int x86_pmu_start(struct perf_event *event); 804static void x86_pmu_start(struct perf_event *event, int flags);
805static void x86_pmu_stop(struct perf_event *event); 805static void x86_pmu_stop(struct perf_event *event, int flags);
806 806
807void hw_perf_enable(void) 807static void x86_pmu_enable(struct pmu *pmu)
808{ 808{
809 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 809 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
810 struct perf_event *event; 810 struct perf_event *event;
@@ -840,7 +840,14 @@ void hw_perf_enable(void)
840 match_prev_assignment(hwc, cpuc, i)) 840 match_prev_assignment(hwc, cpuc, i))
841 continue; 841 continue;
842 842
843 x86_pmu_stop(event); 843 /*
844 * Ensure we don't accidentally enable a stopped
845 * counter simply because we rescheduled.
846 */
847 if (hwc->state & PERF_HES_STOPPED)
848 hwc->state |= PERF_HES_ARCH;
849
850 x86_pmu_stop(event, PERF_EF_UPDATE);
844 } 851 }
845 852
846 for (i = 0; i < cpuc->n_events; i++) { 853 for (i = 0; i < cpuc->n_events; i++) {
@@ -852,7 +859,10 @@ void hw_perf_enable(void)
852 else if (i < n_running) 859 else if (i < n_running)
853 continue; 860 continue;
854 861
855 x86_pmu_start(event); 862 if (hwc->state & PERF_HES_ARCH)
863 continue;
864
865 x86_pmu_start(event, PERF_EF_RELOAD);
856 } 866 }
857 cpuc->n_added = 0; 867 cpuc->n_added = 0;
858 perf_events_lapic_init(); 868 perf_events_lapic_init();
@@ -953,15 +963,12 @@ static void x86_pmu_enable_event(struct perf_event *event)
953} 963}
954 964
955/* 965/*
956 * activate a single event 966 * Add a single event to the PMU.
957 * 967 *
958 * The event is added to the group of enabled events 968 * The event is added to the group of enabled events
959 * but only if it can be scehduled with existing events. 969 * but only if it can be scehduled with existing events.
960 *
961 * Called with PMU disabled. If successful and return value 1,
962 * then guaranteed to call perf_enable() and hw_perf_enable()
963 */ 970 */
964static int x86_pmu_enable(struct perf_event *event) 971static int x86_pmu_add(struct perf_event *event, int flags)
965{ 972{
966 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 973 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
967 struct hw_perf_event *hwc; 974 struct hw_perf_event *hwc;
@@ -970,58 +977,67 @@ static int x86_pmu_enable(struct perf_event *event)
970 977
971 hwc = &event->hw; 978 hwc = &event->hw;
972 979
980 perf_pmu_disable(event->pmu);
973 n0 = cpuc->n_events; 981 n0 = cpuc->n_events;
974 n = collect_events(cpuc, event, false); 982 ret = n = collect_events(cpuc, event, false);
975 if (n < 0) 983 if (ret < 0)
976 return n; 984 goto out;
985
986 hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
987 if (!(flags & PERF_EF_START))
988 hwc->state |= PERF_HES_ARCH;
977 989
978 /* 990 /*
979 * If group events scheduling transaction was started, 991 * If group events scheduling transaction was started,
980 * skip the schedulability test here, it will be peformed 992 * skip the schedulability test here, it will be peformed
981 * at commit time(->commit_txn) as a whole 993 * at commit time (->commit_txn) as a whole
982 */ 994 */
983 if (cpuc->group_flag & PERF_EVENT_TXN) 995 if (cpuc->group_flag & PERF_EVENT_TXN)
984 goto out; 996 goto done_collect;
985 997
986 ret = x86_pmu.schedule_events(cpuc, n, assign); 998 ret = x86_pmu.schedule_events(cpuc, n, assign);
987 if (ret) 999 if (ret)
988 return ret; 1000 goto out;
989 /* 1001 /*
990 * copy new assignment, now we know it is possible 1002 * copy new assignment, now we know it is possible
991 * will be used by hw_perf_enable() 1003 * will be used by hw_perf_enable()
992 */ 1004 */
993 memcpy(cpuc->assign, assign, n*sizeof(int)); 1005 memcpy(cpuc->assign, assign, n*sizeof(int));
994 1006
995out: 1007done_collect:
996 cpuc->n_events = n; 1008 cpuc->n_events = n;
997 cpuc->n_added += n - n0; 1009 cpuc->n_added += n - n0;
998 cpuc->n_txn += n - n0; 1010 cpuc->n_txn += n - n0;
999 1011
1000 return 0; 1012 ret = 0;
1013out:
1014 perf_pmu_enable(event->pmu);
1015 return ret;
1001} 1016}
1002 1017
1003static int x86_pmu_start(struct perf_event *event) 1018static void x86_pmu_start(struct perf_event *event, int flags)
1004{ 1019{
1005 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1020 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1006 int idx = event->hw.idx; 1021 int idx = event->hw.idx;
1007 1022
1008 if (idx == -1) 1023 if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
1009 return -EAGAIN; 1024 return;
1025
1026 if (WARN_ON_ONCE(idx == -1))
1027 return;
1028
1029 if (flags & PERF_EF_RELOAD) {
1030 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
1031 x86_perf_event_set_period(event);
1032 }
1033
1034 event->hw.state = 0;
1010 1035
1011 x86_perf_event_set_period(event);
1012 cpuc->events[idx] = event; 1036 cpuc->events[idx] = event;
1013 __set_bit(idx, cpuc->active_mask); 1037 __set_bit(idx, cpuc->active_mask);
1014 __set_bit(idx, cpuc->running); 1038 __set_bit(idx, cpuc->running);
1015 x86_pmu.enable(event); 1039 x86_pmu.enable(event);
1016 perf_event_update_userpage(event); 1040 perf_event_update_userpage(event);
1017
1018 return 0;
1019}
1020
1021static void x86_pmu_unthrottle(struct perf_event *event)
1022{
1023 int ret = x86_pmu_start(event);
1024 WARN_ON_ONCE(ret);
1025} 1041}
1026 1042
1027void perf_event_print_debug(void) 1043void perf_event_print_debug(void)
@@ -1078,27 +1094,29 @@ void perf_event_print_debug(void)
1078 local_irq_restore(flags); 1094 local_irq_restore(flags);
1079} 1095}
1080 1096
1081static void x86_pmu_stop(struct perf_event *event) 1097static void x86_pmu_stop(struct perf_event *event, int flags)
1082{ 1098{
1083 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1099 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1084 struct hw_perf_event *hwc = &event->hw; 1100 struct hw_perf_event *hwc = &event->hw;
1085 int idx = hwc->idx;
1086 1101
1087 if (!__test_and_clear_bit(idx, cpuc->active_mask)) 1102 if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) {
1088 return; 1103 x86_pmu.disable(event);
1089 1104 cpuc->events[hwc->idx] = NULL;
1090 x86_pmu.disable(event); 1105 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
1091 1106 hwc->state |= PERF_HES_STOPPED;
1092 /* 1107 }
1093 * Drain the remaining delta count out of a event
1094 * that we are disabling:
1095 */
1096 x86_perf_event_update(event);
1097 1108
1098 cpuc->events[idx] = NULL; 1109 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
1110 /*
1111 * Drain the remaining delta count out of a event
1112 * that we are disabling:
1113 */
1114 x86_perf_event_update(event);
1115 hwc->state |= PERF_HES_UPTODATE;
1116 }
1099} 1117}
1100 1118
1101static void x86_pmu_disable(struct perf_event *event) 1119static void x86_pmu_del(struct perf_event *event, int flags)
1102{ 1120{
1103 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1121 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1104 int i; 1122 int i;
@@ -1111,7 +1129,7 @@ static void x86_pmu_disable(struct perf_event *event)
1111 if (cpuc->group_flag & PERF_EVENT_TXN) 1129 if (cpuc->group_flag & PERF_EVENT_TXN)
1112 return; 1130 return;
1113 1131
1114 x86_pmu_stop(event); 1132 x86_pmu_stop(event, PERF_EF_UPDATE);
1115 1133
1116 for (i = 0; i < cpuc->n_events; i++) { 1134 for (i = 0; i < cpuc->n_events; i++) {
1117 if (event == cpuc->event_list[i]) { 1135 if (event == cpuc->event_list[i]) {
@@ -1134,7 +1152,6 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
1134 struct perf_sample_data data; 1152 struct perf_sample_data data;
1135 struct cpu_hw_events *cpuc; 1153 struct cpu_hw_events *cpuc;
1136 struct perf_event *event; 1154 struct perf_event *event;
1137 struct hw_perf_event *hwc;
1138 int idx, handled = 0; 1155 int idx, handled = 0;
1139 u64 val; 1156 u64 val;
1140 1157
@@ -1155,7 +1172,6 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
1155 } 1172 }
1156 1173
1157 event = cpuc->events[idx]; 1174 event = cpuc->events[idx];
1158 hwc = &event->hw;
1159 1175
1160 val = x86_perf_event_update(event); 1176 val = x86_perf_event_update(event);
1161 if (val & (1ULL << (x86_pmu.cntval_bits - 1))) 1177 if (val & (1ULL << (x86_pmu.cntval_bits - 1)))
@@ -1171,7 +1187,7 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
1171 continue; 1187 continue;
1172 1188
1173 if (perf_event_overflow(event, 1, &data, regs)) 1189 if (perf_event_overflow(event, 1, &data, regs))
1174 x86_pmu_stop(event); 1190 x86_pmu_stop(event, 0);
1175 } 1191 }
1176 1192
1177 if (handled) 1193 if (handled)
@@ -1180,25 +1196,6 @@ static int x86_pmu_handle_irq(struct pt_regs *regs)
1180 return handled; 1196 return handled;
1181} 1197}
1182 1198
1183void smp_perf_pending_interrupt(struct pt_regs *regs)
1184{
1185 irq_enter();
1186 ack_APIC_irq();
1187 inc_irq_stat(apic_pending_irqs);
1188 perf_event_do_pending();
1189 irq_exit();
1190}
1191
1192void set_perf_event_pending(void)
1193{
1194#ifdef CONFIG_X86_LOCAL_APIC
1195 if (!x86_pmu.apic || !x86_pmu_initialized())
1196 return;
1197
1198 apic->send_IPI_self(LOCAL_PENDING_VECTOR);
1199#endif
1200}
1201
1202void perf_events_lapic_init(void) 1199void perf_events_lapic_init(void)
1203{ 1200{
1204 if (!x86_pmu.apic || !x86_pmu_initialized()) 1201 if (!x86_pmu.apic || !x86_pmu_initialized())
@@ -1388,7 +1385,6 @@ void __init init_hw_perf_events(void)
1388 x86_pmu.num_counters = X86_PMC_MAX_GENERIC; 1385 x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
1389 } 1386 }
1390 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1; 1387 x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
1391 perf_max_events = x86_pmu.num_counters;
1392 1388
1393 if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) { 1389 if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
1394 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!", 1390 WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
@@ -1424,6 +1420,7 @@ void __init init_hw_perf_events(void)
1424 pr_info("... fixed-purpose events: %d\n", x86_pmu.num_counters_fixed); 1420 pr_info("... fixed-purpose events: %d\n", x86_pmu.num_counters_fixed);
1425 pr_info("... event mask: %016Lx\n", x86_pmu.intel_ctrl); 1421 pr_info("... event mask: %016Lx\n", x86_pmu.intel_ctrl);
1426 1422
1423 perf_pmu_register(&pmu);
1427 perf_cpu_notifier(x86_pmu_notifier); 1424 perf_cpu_notifier(x86_pmu_notifier);
1428} 1425}
1429 1426
@@ -1437,10 +1434,11 @@ static inline void x86_pmu_read(struct perf_event *event)
1437 * Set the flag to make pmu::enable() not perform the 1434 * Set the flag to make pmu::enable() not perform the
1438 * schedulability test, it will be performed at commit time 1435 * schedulability test, it will be performed at commit time
1439 */ 1436 */
1440static void x86_pmu_start_txn(const struct pmu *pmu) 1437static void x86_pmu_start_txn(struct pmu *pmu)
1441{ 1438{
1442 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1439 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1443 1440
1441 perf_pmu_disable(pmu);
1444 cpuc->group_flag |= PERF_EVENT_TXN; 1442 cpuc->group_flag |= PERF_EVENT_TXN;
1445 cpuc->n_txn = 0; 1443 cpuc->n_txn = 0;
1446} 1444}
@@ -1450,7 +1448,7 @@ static void x86_pmu_start_txn(const struct pmu *pmu)
1450 * Clear the flag and pmu::enable() will perform the 1448 * Clear the flag and pmu::enable() will perform the
1451 * schedulability test. 1449 * schedulability test.
1452 */ 1450 */
1453static void x86_pmu_cancel_txn(const struct pmu *pmu) 1451static void x86_pmu_cancel_txn(struct pmu *pmu)
1454{ 1452{
1455 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1453 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1456 1454
@@ -1460,6 +1458,7 @@ static void x86_pmu_cancel_txn(const struct pmu *pmu)
1460 */ 1458 */
1461 cpuc->n_added -= cpuc->n_txn; 1459 cpuc->n_added -= cpuc->n_txn;
1462 cpuc->n_events -= cpuc->n_txn; 1460 cpuc->n_events -= cpuc->n_txn;
1461 perf_pmu_enable(pmu);
1463} 1462}
1464 1463
1465/* 1464/*
@@ -1467,7 +1466,7 @@ static void x86_pmu_cancel_txn(const struct pmu *pmu)
1467 * Perform the group schedulability test as a whole 1466 * Perform the group schedulability test as a whole
1468 * Return 0 if success 1467 * Return 0 if success
1469 */ 1468 */
1470static int x86_pmu_commit_txn(const struct pmu *pmu) 1469static int x86_pmu_commit_txn(struct pmu *pmu)
1471{ 1470{
1472 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 1471 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
1473 int assign[X86_PMC_IDX_MAX]; 1472 int assign[X86_PMC_IDX_MAX];
@@ -1489,22 +1488,10 @@ static int x86_pmu_commit_txn(const struct pmu *pmu)
1489 memcpy(cpuc->assign, assign, n*sizeof(int)); 1488 memcpy(cpuc->assign, assign, n*sizeof(int));
1490 1489
1491 cpuc->group_flag &= ~PERF_EVENT_TXN; 1490 cpuc->group_flag &= ~PERF_EVENT_TXN;
1492 1491 perf_pmu_enable(pmu);
1493 return 0; 1492 return 0;
1494} 1493}
1495 1494
1496static const struct pmu pmu = {
1497 .enable = x86_pmu_enable,
1498 .disable = x86_pmu_disable,
1499 .start = x86_pmu_start,
1500 .stop = x86_pmu_stop,
1501 .read = x86_pmu_read,
1502 .unthrottle = x86_pmu_unthrottle,
1503 .start_txn = x86_pmu_start_txn,
1504 .cancel_txn = x86_pmu_cancel_txn,
1505 .commit_txn = x86_pmu_commit_txn,
1506};
1507
1508/* 1495/*
1509 * validate that we can schedule this event 1496 * validate that we can schedule this event
1510 */ 1497 */
@@ -1579,12 +1566,22 @@ out:
1579 return ret; 1566 return ret;
1580} 1567}
1581 1568
1582const struct pmu *hw_perf_event_init(struct perf_event *event) 1569int x86_pmu_event_init(struct perf_event *event)
1583{ 1570{
1584 const struct pmu *tmp; 1571 struct pmu *tmp;
1585 int err; 1572 int err;
1586 1573
1587 err = __hw_perf_event_init(event); 1574 switch (event->attr.type) {
1575 case PERF_TYPE_RAW:
1576 case PERF_TYPE_HARDWARE:
1577 case PERF_TYPE_HW_CACHE:
1578 break;
1579
1580 default:
1581 return -ENOENT;
1582 }
1583
1584 err = __x86_pmu_event_init(event);
1588 if (!err) { 1585 if (!err) {
1589 /* 1586 /*
1590 * we temporarily connect event to its pmu 1587 * we temporarily connect event to its pmu
@@ -1604,26 +1601,31 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
1604 if (err) { 1601 if (err) {
1605 if (event->destroy) 1602 if (event->destroy)
1606 event->destroy(event); 1603 event->destroy(event);
1607 return ERR_PTR(err);
1608 } 1604 }
1609 1605
1610 return &pmu; 1606 return err;
1611} 1607}
1612 1608
1613/* 1609static struct pmu pmu = {
1614 * callchain support 1610 .pmu_enable = x86_pmu_enable,
1615 */ 1611 .pmu_disable = x86_pmu_disable,
1616 1612
1617static inline 1613 .event_init = x86_pmu_event_init,
1618void callchain_store(struct perf_callchain_entry *entry, u64 ip)
1619{
1620 if (entry->nr < PERF_MAX_STACK_DEPTH)
1621 entry->ip[entry->nr++] = ip;
1622}
1623 1614
1624static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_irq_entry); 1615 .add = x86_pmu_add,
1625static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_nmi_entry); 1616 .del = x86_pmu_del,
1617 .start = x86_pmu_start,
1618 .stop = x86_pmu_stop,
1619 .read = x86_pmu_read,
1626 1620
1621 .start_txn = x86_pmu_start_txn,
1622 .cancel_txn = x86_pmu_cancel_txn,
1623 .commit_txn = x86_pmu_commit_txn,
1624};
1625
1626/*
1627 * callchain support
1628 */
1627 1629
1628static void 1630static void
1629backtrace_warning_symbol(void *data, char *msg, unsigned long symbol) 1631backtrace_warning_symbol(void *data, char *msg, unsigned long symbol)
@@ -1645,7 +1647,7 @@ static void backtrace_address(void *data, unsigned long addr, int reliable)
1645{ 1647{
1646 struct perf_callchain_entry *entry = data; 1648 struct perf_callchain_entry *entry = data;
1647 1649
1648 callchain_store(entry, addr); 1650 perf_callchain_store(entry, addr);
1649} 1651}
1650 1652
1651static const struct stacktrace_ops backtrace_ops = { 1653static const struct stacktrace_ops backtrace_ops = {
@@ -1656,11 +1658,15 @@ static const struct stacktrace_ops backtrace_ops = {
1656 .walk_stack = print_context_stack_bp, 1658 .walk_stack = print_context_stack_bp,
1657}; 1659};
1658 1660
1659static void 1661void
1660perf_callchain_kernel(struct pt_regs *regs, struct perf_callchain_entry *entry) 1662perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
1661{ 1663{
1662 callchain_store(entry, PERF_CONTEXT_KERNEL); 1664 if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
1663 callchain_store(entry, regs->ip); 1665 /* TODO: We don't support guest os callchain now */
1666 return;
1667 }
1668
1669 perf_callchain_store(entry, regs->ip);
1664 1670
1665 dump_trace(NULL, regs, NULL, regs->bp, &backtrace_ops, entry); 1671 dump_trace(NULL, regs, NULL, regs->bp, &backtrace_ops, entry);
1666} 1672}
@@ -1689,7 +1695,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
1689 if (fp < compat_ptr(regs->sp)) 1695 if (fp < compat_ptr(regs->sp))
1690 break; 1696 break;
1691 1697
1692 callchain_store(entry, frame.return_address); 1698 perf_callchain_store(entry, frame.return_address);
1693 fp = compat_ptr(frame.next_frame); 1699 fp = compat_ptr(frame.next_frame);
1694 } 1700 }
1695 return 1; 1701 return 1;
@@ -1702,19 +1708,20 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry *entry)
1702} 1708}
1703#endif 1709#endif
1704 1710
1705static void 1711void
1706perf_callchain_user(struct pt_regs *regs, struct perf_callchain_entry *entry) 1712perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1707{ 1713{
1708 struct stack_frame frame; 1714 struct stack_frame frame;
1709 const void __user *fp; 1715 const void __user *fp;
1710 1716
1711 if (!user_mode(regs)) 1717 if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
1712 regs = task_pt_regs(current); 1718 /* TODO: We don't support guest os callchain now */
1719 return;
1720 }
1713 1721
1714 fp = (void __user *)regs->bp; 1722 fp = (void __user *)regs->bp;
1715 1723
1716 callchain_store(entry, PERF_CONTEXT_USER); 1724 perf_callchain_store(entry, regs->ip);
1717 callchain_store(entry, regs->ip);
1718 1725
1719 if (perf_callchain_user32(regs, entry)) 1726 if (perf_callchain_user32(regs, entry))
1720 return; 1727 return;
@@ -1731,52 +1738,11 @@ perf_callchain_user(struct pt_regs *regs, struct perf_callchain_entry *entry)
1731 if ((unsigned long)fp < regs->sp) 1738 if ((unsigned long)fp < regs->sp)
1732 break; 1739 break;
1733 1740
1734 callchain_store(entry, frame.return_address); 1741 perf_callchain_store(entry, frame.return_address);
1735 fp = frame.next_frame; 1742 fp = frame.next_frame;
1736 } 1743 }
1737} 1744}
1738 1745
1739static void
1740perf_do_callchain(struct pt_regs *regs, struct perf_callchain_entry *entry)
1741{
1742 int is_user;
1743
1744 if (!regs)
1745 return;
1746
1747 is_user = user_mode(regs);
1748
1749 if (is_user && current->state != TASK_RUNNING)
1750 return;
1751
1752 if (!is_user)
1753 perf_callchain_kernel(regs, entry);
1754
1755 if (current->mm)
1756 perf_callchain_user(regs, entry);
1757}
1758
1759struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
1760{
1761 struct perf_callchain_entry *entry;
1762
1763 if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
1764 /* TODO: We don't support guest os callchain now */
1765 return NULL;
1766 }
1767
1768 if (in_nmi())
1769 entry = &__get_cpu_var(pmc_nmi_entry);
1770 else
1771 entry = &__get_cpu_var(pmc_irq_entry);
1772
1773 entry->nr = 0;
1774
1775 perf_do_callchain(regs, entry);
1776
1777 return entry;
1778}
1779
1780unsigned long perf_instruction_pointer(struct pt_regs *regs) 1746unsigned long perf_instruction_pointer(struct pt_regs *regs)
1781{ 1747{
1782 unsigned long ip; 1748 unsigned long ip;
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index c2897b7b4a3b..46d58448c3af 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -52,7 +52,7 @@ static __initconst const u64 amd_hw_cache_event_ids
52 [ C(DTLB) ] = { 52 [ C(DTLB) ] = {
53 [ C(OP_READ) ] = { 53 [ C(OP_READ) ] = {
54 [ C(RESULT_ACCESS) ] = 0x0040, /* Data Cache Accesses */ 54 [ C(RESULT_ACCESS) ] = 0x0040, /* Data Cache Accesses */
55 [ C(RESULT_MISS) ] = 0x0046, /* L1 DTLB and L2 DLTB Miss */ 55 [ C(RESULT_MISS) ] = 0x0746, /* L1_DTLB_AND_L2_DLTB_MISS.ALL */
56 }, 56 },
57 [ C(OP_WRITE) ] = { 57 [ C(OP_WRITE) ] = {
58 [ C(RESULT_ACCESS) ] = 0, 58 [ C(RESULT_ACCESS) ] = 0,
@@ -66,7 +66,7 @@ static __initconst const u64 amd_hw_cache_event_ids
66 [ C(ITLB) ] = { 66 [ C(ITLB) ] = {
67 [ C(OP_READ) ] = { 67 [ C(OP_READ) ] = {
68 [ C(RESULT_ACCESS) ] = 0x0080, /* Instruction fecthes */ 68 [ C(RESULT_ACCESS) ] = 0x0080, /* Instruction fecthes */
69 [ C(RESULT_MISS) ] = 0x0085, /* Instr. fetch ITLB misses */ 69 [ C(RESULT_MISS) ] = 0x0385, /* L1_ITLB_AND_L2_ITLB_MISS.ALL */
70 }, 70 },
71 [ C(OP_WRITE) ] = { 71 [ C(OP_WRITE) ] = {
72 [ C(RESULT_ACCESS) ] = -1, 72 [ C(RESULT_ACCESS) ] = -1,
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index ee05c90012d2..c8f5c088cad1 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -713,18 +713,18 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
713 struct cpu_hw_events *cpuc; 713 struct cpu_hw_events *cpuc;
714 int bit, loops; 714 int bit, loops;
715 u64 status; 715 u64 status;
716 int handled = 0; 716 int handled;
717 717
718 perf_sample_data_init(&data, 0); 718 perf_sample_data_init(&data, 0);
719 719
720 cpuc = &__get_cpu_var(cpu_hw_events); 720 cpuc = &__get_cpu_var(cpu_hw_events);
721 721
722 intel_pmu_disable_all(); 722 intel_pmu_disable_all();
723 intel_pmu_drain_bts_buffer(); 723 handled = intel_pmu_drain_bts_buffer();
724 status = intel_pmu_get_status(); 724 status = intel_pmu_get_status();
725 if (!status) { 725 if (!status) {
726 intel_pmu_enable_all(0); 726 intel_pmu_enable_all(0);
727 return 0; 727 return handled;
728 } 728 }
729 729
730 loops = 0; 730 loops = 0;
@@ -763,7 +763,7 @@ again:
763 data.period = event->hw.last_period; 763 data.period = event->hw.last_period;
764 764
765 if (perf_event_overflow(event, 1, &data, regs)) 765 if (perf_event_overflow(event, 1, &data, regs))
766 x86_pmu_stop(event); 766 x86_pmu_stop(event, 0);
767 } 767 }
768 768
769 /* 769 /*
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 18018d1311cd..4977f9c400e5 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -214,7 +214,7 @@ static void intel_pmu_disable_bts(void)
214 update_debugctlmsr(debugctlmsr); 214 update_debugctlmsr(debugctlmsr);
215} 215}
216 216
217static void intel_pmu_drain_bts_buffer(void) 217static int intel_pmu_drain_bts_buffer(void)
218{ 218{
219 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 219 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
220 struct debug_store *ds = cpuc->ds; 220 struct debug_store *ds = cpuc->ds;
@@ -231,16 +231,16 @@ static void intel_pmu_drain_bts_buffer(void)
231 struct pt_regs regs; 231 struct pt_regs regs;
232 232
233 if (!event) 233 if (!event)
234 return; 234 return 0;
235 235
236 if (!ds) 236 if (!ds)
237 return; 237 return 0;
238 238
239 at = (struct bts_record *)(unsigned long)ds->bts_buffer_base; 239 at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
240 top = (struct bts_record *)(unsigned long)ds->bts_index; 240 top = (struct bts_record *)(unsigned long)ds->bts_index;
241 241
242 if (top <= at) 242 if (top <= at)
243 return; 243 return 0;
244 244
245 ds->bts_index = ds->bts_buffer_base; 245 ds->bts_index = ds->bts_buffer_base;
246 246
@@ -256,7 +256,7 @@ static void intel_pmu_drain_bts_buffer(void)
256 perf_prepare_sample(&header, &data, event, &regs); 256 perf_prepare_sample(&header, &data, event, &regs);
257 257
258 if (perf_output_begin(&handle, event, header.size * (top - at), 1, 1)) 258 if (perf_output_begin(&handle, event, header.size * (top - at), 1, 1))
259 return; 259 return 1;
260 260
261 for (; at < top; at++) { 261 for (; at < top; at++) {
262 data.ip = at->from; 262 data.ip = at->from;
@@ -270,6 +270,7 @@ static void intel_pmu_drain_bts_buffer(void)
270 /* There's new data available. */ 270 /* There's new data available. */
271 event->hw.interrupts++; 271 event->hw.interrupts++;
272 event->pending_kill = POLL_IN; 272 event->pending_kill = POLL_IN;
273 return 1;
273} 274}
274 275
275/* 276/*
@@ -491,7 +492,7 @@ static void __intel_pmu_pebs_event(struct perf_event *event,
491 regs.flags &= ~PERF_EFLAGS_EXACT; 492 regs.flags &= ~PERF_EFLAGS_EXACT;
492 493
493 if (perf_event_overflow(event, 1, &data, &regs)) 494 if (perf_event_overflow(event, 1, &data, &regs))
494 x86_pmu_stop(event); 495 x86_pmu_stop(event, 0);
495} 496}
496 497
497static void intel_pmu_drain_pebs_core(struct pt_regs *iregs) 498static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
diff --git a/arch/x86/kernel/cpu/perf_event_p4.c b/arch/x86/kernel/cpu/perf_event_p4.c
index b560db3305be..81400b93e694 100644
--- a/arch/x86/kernel/cpu/perf_event_p4.c
+++ b/arch/x86/kernel/cpu/perf_event_p4.c
@@ -18,6 +18,8 @@
18struct p4_event_bind { 18struct p4_event_bind {
19 unsigned int opcode; /* Event code and ESCR selector */ 19 unsigned int opcode; /* Event code and ESCR selector */
20 unsigned int escr_msr[2]; /* ESCR MSR for this event */ 20 unsigned int escr_msr[2]; /* ESCR MSR for this event */
21 unsigned int escr_emask; /* valid ESCR EventMask bits */
22 unsigned int shared; /* event is shared across threads */
21 char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on abscence */ 23 char cntr[2][P4_CNTR_LIMIT]; /* counter index (offset), -1 on abscence */
22}; 24};
23 25
@@ -66,231 +68,435 @@ static struct p4_event_bind p4_event_bind_map[] = {
66 [P4_EVENT_TC_DELIVER_MODE] = { 68 [P4_EVENT_TC_DELIVER_MODE] = {
67 .opcode = P4_OPCODE(P4_EVENT_TC_DELIVER_MODE), 69 .opcode = P4_OPCODE(P4_EVENT_TC_DELIVER_MODE),
68 .escr_msr = { MSR_P4_TC_ESCR0, MSR_P4_TC_ESCR1 }, 70 .escr_msr = { MSR_P4_TC_ESCR0, MSR_P4_TC_ESCR1 },
71 .escr_emask =
72 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, DD) |
73 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, DB) |
74 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, DI) |
75 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, BD) |
76 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, BB) |
77 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, BI) |
78 P4_ESCR_EMASK_BIT(P4_EVENT_TC_DELIVER_MODE, ID),
79 .shared = 1,
69 .cntr = { {4, 5, -1}, {6, 7, -1} }, 80 .cntr = { {4, 5, -1}, {6, 7, -1} },
70 }, 81 },
71 [P4_EVENT_BPU_FETCH_REQUEST] = { 82 [P4_EVENT_BPU_FETCH_REQUEST] = {
72 .opcode = P4_OPCODE(P4_EVENT_BPU_FETCH_REQUEST), 83 .opcode = P4_OPCODE(P4_EVENT_BPU_FETCH_REQUEST),
73 .escr_msr = { MSR_P4_BPU_ESCR0, MSR_P4_BPU_ESCR1 }, 84 .escr_msr = { MSR_P4_BPU_ESCR0, MSR_P4_BPU_ESCR1 },
85 .escr_emask =
86 P4_ESCR_EMASK_BIT(P4_EVENT_BPU_FETCH_REQUEST, TCMISS),
74 .cntr = { {0, -1, -1}, {2, -1, -1} }, 87 .cntr = { {0, -1, -1}, {2, -1, -1} },
75 }, 88 },
76 [P4_EVENT_ITLB_REFERENCE] = { 89 [P4_EVENT_ITLB_REFERENCE] = {
77 .opcode = P4_OPCODE(P4_EVENT_ITLB_REFERENCE), 90 .opcode = P4_OPCODE(P4_EVENT_ITLB_REFERENCE),
78 .escr_msr = { MSR_P4_ITLB_ESCR0, MSR_P4_ITLB_ESCR1 }, 91 .escr_msr = { MSR_P4_ITLB_ESCR0, MSR_P4_ITLB_ESCR1 },
92 .escr_emask =
93 P4_ESCR_EMASK_BIT(P4_EVENT_ITLB_REFERENCE, HIT) |
94 P4_ESCR_EMASK_BIT(P4_EVENT_ITLB_REFERENCE, MISS) |
95 P4_ESCR_EMASK_BIT(P4_EVENT_ITLB_REFERENCE, HIT_UK),
79 .cntr = { {0, -1, -1}, {2, -1, -1} }, 96 .cntr = { {0, -1, -1}, {2, -1, -1} },
80 }, 97 },
81 [P4_EVENT_MEMORY_CANCEL] = { 98 [P4_EVENT_MEMORY_CANCEL] = {
82 .opcode = P4_OPCODE(P4_EVENT_MEMORY_CANCEL), 99 .opcode = P4_OPCODE(P4_EVENT_MEMORY_CANCEL),
83 .escr_msr = { MSR_P4_DAC_ESCR0, MSR_P4_DAC_ESCR1 }, 100 .escr_msr = { MSR_P4_DAC_ESCR0, MSR_P4_DAC_ESCR1 },
101 .escr_emask =
102 P4_ESCR_EMASK_BIT(P4_EVENT_MEMORY_CANCEL, ST_RB_FULL) |
103 P4_ESCR_EMASK_BIT(P4_EVENT_MEMORY_CANCEL, 64K_CONF),
84 .cntr = { {8, 9, -1}, {10, 11, -1} }, 104 .cntr = { {8, 9, -1}, {10, 11, -1} },
85 }, 105 },
86 [P4_EVENT_MEMORY_COMPLETE] = { 106 [P4_EVENT_MEMORY_COMPLETE] = {
87 .opcode = P4_OPCODE(P4_EVENT_MEMORY_COMPLETE), 107 .opcode = P4_OPCODE(P4_EVENT_MEMORY_COMPLETE),
88 .escr_msr = { MSR_P4_SAAT_ESCR0 , MSR_P4_SAAT_ESCR1 }, 108 .escr_msr = { MSR_P4_SAAT_ESCR0 , MSR_P4_SAAT_ESCR1 },
109 .escr_emask =
110 P4_ESCR_EMASK_BIT(P4_EVENT_MEMORY_COMPLETE, LSC) |
111 P4_ESCR_EMASK_BIT(P4_EVENT_MEMORY_COMPLETE, SSC),
89 .cntr = { {8, 9, -1}, {10, 11, -1} }, 112 .cntr = { {8, 9, -1}, {10, 11, -1} },
90 }, 113 },
91 [P4_EVENT_LOAD_PORT_REPLAY] = { 114 [P4_EVENT_LOAD_PORT_REPLAY] = {
92 .opcode = P4_OPCODE(P4_EVENT_LOAD_PORT_REPLAY), 115 .opcode = P4_OPCODE(P4_EVENT_LOAD_PORT_REPLAY),
93 .escr_msr = { MSR_P4_SAAT_ESCR0, MSR_P4_SAAT_ESCR1 }, 116 .escr_msr = { MSR_P4_SAAT_ESCR0, MSR_P4_SAAT_ESCR1 },
117 .escr_emask =
118 P4_ESCR_EMASK_BIT(P4_EVENT_LOAD_PORT_REPLAY, SPLIT_LD),
94 .cntr = { {8, 9, -1}, {10, 11, -1} }, 119 .cntr = { {8, 9, -1}, {10, 11, -1} },
95 }, 120 },
96 [P4_EVENT_STORE_PORT_REPLAY] = { 121 [P4_EVENT_STORE_PORT_REPLAY] = {
97 .opcode = P4_OPCODE(P4_EVENT_STORE_PORT_REPLAY), 122 .opcode = P4_OPCODE(P4_EVENT_STORE_PORT_REPLAY),
98 .escr_msr = { MSR_P4_SAAT_ESCR0 , MSR_P4_SAAT_ESCR1 }, 123 .escr_msr = { MSR_P4_SAAT_ESCR0 , MSR_P4_SAAT_ESCR1 },
124 .escr_emask =
125 P4_ESCR_EMASK_BIT(P4_EVENT_STORE_PORT_REPLAY, SPLIT_ST),
99 .cntr = { {8, 9, -1}, {10, 11, -1} }, 126 .cntr = { {8, 9, -1}, {10, 11, -1} },
100 }, 127 },
101 [P4_EVENT_MOB_LOAD_REPLAY] = { 128 [P4_EVENT_MOB_LOAD_REPLAY] = {
102 .opcode = P4_OPCODE(P4_EVENT_MOB_LOAD_REPLAY), 129 .opcode = P4_OPCODE(P4_EVENT_MOB_LOAD_REPLAY),
103 .escr_msr = { MSR_P4_MOB_ESCR0, MSR_P4_MOB_ESCR1 }, 130 .escr_msr = { MSR_P4_MOB_ESCR0, MSR_P4_MOB_ESCR1 },
131 .escr_emask =
132 P4_ESCR_EMASK_BIT(P4_EVENT_MOB_LOAD_REPLAY, NO_STA) |
133 P4_ESCR_EMASK_BIT(P4_EVENT_MOB_LOAD_REPLAY, NO_STD) |
134 P4_ESCR_EMASK_BIT(P4_EVENT_MOB_LOAD_REPLAY, PARTIAL_DATA) |
135 P4_ESCR_EMASK_BIT(P4_EVENT_MOB_LOAD_REPLAY, UNALGN_ADDR),
104 .cntr = { {0, -1, -1}, {2, -1, -1} }, 136 .cntr = { {0, -1, -1}, {2, -1, -1} },
105 }, 137 },
106 [P4_EVENT_PAGE_WALK_TYPE] = { 138 [P4_EVENT_PAGE_WALK_TYPE] = {
107 .opcode = P4_OPCODE(P4_EVENT_PAGE_WALK_TYPE), 139 .opcode = P4_OPCODE(P4_EVENT_PAGE_WALK_TYPE),
108 .escr_msr = { MSR_P4_PMH_ESCR0, MSR_P4_PMH_ESCR1 }, 140 .escr_msr = { MSR_P4_PMH_ESCR0, MSR_P4_PMH_ESCR1 },
141 .escr_emask =
142 P4_ESCR_EMASK_BIT(P4_EVENT_PAGE_WALK_TYPE, DTMISS) |
143 P4_ESCR_EMASK_BIT(P4_EVENT_PAGE_WALK_TYPE, ITMISS),
144 .shared = 1,
109 .cntr = { {0, -1, -1}, {2, -1, -1} }, 145 .cntr = { {0, -1, -1}, {2, -1, -1} },
110 }, 146 },
111 [P4_EVENT_BSQ_CACHE_REFERENCE] = { 147 [P4_EVENT_BSQ_CACHE_REFERENCE] = {
112 .opcode = P4_OPCODE(P4_EVENT_BSQ_CACHE_REFERENCE), 148 .opcode = P4_OPCODE(P4_EVENT_BSQ_CACHE_REFERENCE),
113 .escr_msr = { MSR_P4_BSU_ESCR0, MSR_P4_BSU_ESCR1 }, 149 .escr_msr = { MSR_P4_BSU_ESCR0, MSR_P4_BSU_ESCR1 },
150 .escr_emask =
151 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITS) |
152 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITE) |
153 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_HITM) |
154 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITS) |
155 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITE) |
156 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_HITM) |
157 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_2ndL_MISS) |
158 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, RD_3rdL_MISS) |
159 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_CACHE_REFERENCE, WR_2ndL_MISS),
114 .cntr = { {0, -1, -1}, {2, -1, -1} }, 160 .cntr = { {0, -1, -1}, {2, -1, -1} },
115 }, 161 },
116 [P4_EVENT_IOQ_ALLOCATION] = { 162 [P4_EVENT_IOQ_ALLOCATION] = {
117 .opcode = P4_OPCODE(P4_EVENT_IOQ_ALLOCATION), 163 .opcode = P4_OPCODE(P4_EVENT_IOQ_ALLOCATION),
118 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 164 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
165 .escr_emask =
166 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, DEFAULT) |
167 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, ALL_READ) |
168 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, ALL_WRITE) |
169 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, MEM_UC) |
170 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, MEM_WC) |
171 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, MEM_WT) |
172 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, MEM_WP) |
173 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, MEM_WB) |
174 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, OWN) |
175 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, OTHER) |
176 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ALLOCATION, PREFETCH),
119 .cntr = { {0, -1, -1}, {2, -1, -1} }, 177 .cntr = { {0, -1, -1}, {2, -1, -1} },
120 }, 178 },
121 [P4_EVENT_IOQ_ACTIVE_ENTRIES] = { /* shared ESCR */ 179 [P4_EVENT_IOQ_ACTIVE_ENTRIES] = { /* shared ESCR */
122 .opcode = P4_OPCODE(P4_EVENT_IOQ_ACTIVE_ENTRIES), 180 .opcode = P4_OPCODE(P4_EVENT_IOQ_ACTIVE_ENTRIES),
123 .escr_msr = { MSR_P4_FSB_ESCR1, MSR_P4_FSB_ESCR1 }, 181 .escr_msr = { MSR_P4_FSB_ESCR1, MSR_P4_FSB_ESCR1 },
182 .escr_emask =
183 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, DEFAULT) |
184 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_READ) |
185 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, ALL_WRITE) |
186 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_UC) |
187 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WC) |
188 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WT) |
189 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WP) |
190 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, MEM_WB) |
191 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, OWN) |
192 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, OTHER) |
193 P4_ESCR_EMASK_BIT(P4_EVENT_IOQ_ACTIVE_ENTRIES, PREFETCH),
124 .cntr = { {2, -1, -1}, {3, -1, -1} }, 194 .cntr = { {2, -1, -1}, {3, -1, -1} },
125 }, 195 },
126 [P4_EVENT_FSB_DATA_ACTIVITY] = { 196 [P4_EVENT_FSB_DATA_ACTIVITY] = {
127 .opcode = P4_OPCODE(P4_EVENT_FSB_DATA_ACTIVITY), 197 .opcode = P4_OPCODE(P4_EVENT_FSB_DATA_ACTIVITY),
128 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 198 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
199 .escr_emask =
200 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_DRV) |
201 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OWN) |
202 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DRDY_OTHER) |
203 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_DRV) |
204 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OWN) |
205 P4_ESCR_EMASK_BIT(P4_EVENT_FSB_DATA_ACTIVITY, DBSY_OTHER),
206 .shared = 1,
129 .cntr = { {0, -1, -1}, {2, -1, -1} }, 207 .cntr = { {0, -1, -1}, {2, -1, -1} },
130 }, 208 },
131 [P4_EVENT_BSQ_ALLOCATION] = { /* shared ESCR, broken CCCR1 */ 209 [P4_EVENT_BSQ_ALLOCATION] = { /* shared ESCR, broken CCCR1 */
132 .opcode = P4_OPCODE(P4_EVENT_BSQ_ALLOCATION), 210 .opcode = P4_OPCODE(P4_EVENT_BSQ_ALLOCATION),
133 .escr_msr = { MSR_P4_BSU_ESCR0, MSR_P4_BSU_ESCR0 }, 211 .escr_msr = { MSR_P4_BSU_ESCR0, MSR_P4_BSU_ESCR0 },
212 .escr_emask =
213 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE0) |
214 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_TYPE1) |
215 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_LEN0) |
216 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_LEN1) |
217 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_IO_TYPE) |
218 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_LOCK_TYPE) |
219 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_CACHE_TYPE) |
220 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_SPLIT_TYPE) |
221 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_DEM_TYPE) |
222 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, REQ_ORD_TYPE) |
223 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE0) |
224 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE1) |
225 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ALLOCATION, MEM_TYPE2),
134 .cntr = { {0, -1, -1}, {1, -1, -1} }, 226 .cntr = { {0, -1, -1}, {1, -1, -1} },
135 }, 227 },
136 [P4_EVENT_BSQ_ACTIVE_ENTRIES] = { /* shared ESCR */ 228 [P4_EVENT_BSQ_ACTIVE_ENTRIES] = { /* shared ESCR */
137 .opcode = P4_OPCODE(P4_EVENT_BSQ_ACTIVE_ENTRIES), 229 .opcode = P4_OPCODE(P4_EVENT_BSQ_ACTIVE_ENTRIES),
138 .escr_msr = { MSR_P4_BSU_ESCR1 , MSR_P4_BSU_ESCR1 }, 230 .escr_msr = { MSR_P4_BSU_ESCR1 , MSR_P4_BSU_ESCR1 },
231 .escr_emask =
232 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE0) |
233 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_TYPE1) |
234 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN0) |
235 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LEN1) |
236 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_IO_TYPE) |
237 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_LOCK_TYPE) |
238 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_CACHE_TYPE) |
239 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_SPLIT_TYPE) |
240 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_DEM_TYPE) |
241 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, REQ_ORD_TYPE) |
242 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE0) |
243 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE1) |
244 P4_ESCR_EMASK_BIT(P4_EVENT_BSQ_ACTIVE_ENTRIES, MEM_TYPE2),
139 .cntr = { {2, -1, -1}, {3, -1, -1} }, 245 .cntr = { {2, -1, -1}, {3, -1, -1} },
140 }, 246 },
141 [P4_EVENT_SSE_INPUT_ASSIST] = { 247 [P4_EVENT_SSE_INPUT_ASSIST] = {
142 .opcode = P4_OPCODE(P4_EVENT_SSE_INPUT_ASSIST), 248 .opcode = P4_OPCODE(P4_EVENT_SSE_INPUT_ASSIST),
143 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 249 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
250 .escr_emask =
251 P4_ESCR_EMASK_BIT(P4_EVENT_SSE_INPUT_ASSIST, ALL),
252 .shared = 1,
144 .cntr = { {8, 9, -1}, {10, 11, -1} }, 253 .cntr = { {8, 9, -1}, {10, 11, -1} },
145 }, 254 },
146 [P4_EVENT_PACKED_SP_UOP] = { 255 [P4_EVENT_PACKED_SP_UOP] = {
147 .opcode = P4_OPCODE(P4_EVENT_PACKED_SP_UOP), 256 .opcode = P4_OPCODE(P4_EVENT_PACKED_SP_UOP),
148 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 257 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
258 .escr_emask =
259 P4_ESCR_EMASK_BIT(P4_EVENT_PACKED_SP_UOP, ALL),
260 .shared = 1,
149 .cntr = { {8, 9, -1}, {10, 11, -1} }, 261 .cntr = { {8, 9, -1}, {10, 11, -1} },
150 }, 262 },
151 [P4_EVENT_PACKED_DP_UOP] = { 263 [P4_EVENT_PACKED_DP_UOP] = {
152 .opcode = P4_OPCODE(P4_EVENT_PACKED_DP_UOP), 264 .opcode = P4_OPCODE(P4_EVENT_PACKED_DP_UOP),
153 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 265 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
266 .escr_emask =
267 P4_ESCR_EMASK_BIT(P4_EVENT_PACKED_DP_UOP, ALL),
268 .shared = 1,
154 .cntr = { {8, 9, -1}, {10, 11, -1} }, 269 .cntr = { {8, 9, -1}, {10, 11, -1} },
155 }, 270 },
156 [P4_EVENT_SCALAR_SP_UOP] = { 271 [P4_EVENT_SCALAR_SP_UOP] = {
157 .opcode = P4_OPCODE(P4_EVENT_SCALAR_SP_UOP), 272 .opcode = P4_OPCODE(P4_EVENT_SCALAR_SP_UOP),
158 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 273 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
274 .escr_emask =
275 P4_ESCR_EMASK_BIT(P4_EVENT_SCALAR_SP_UOP, ALL),
276 .shared = 1,
159 .cntr = { {8, 9, -1}, {10, 11, -1} }, 277 .cntr = { {8, 9, -1}, {10, 11, -1} },
160 }, 278 },
161 [P4_EVENT_SCALAR_DP_UOP] = { 279 [P4_EVENT_SCALAR_DP_UOP] = {
162 .opcode = P4_OPCODE(P4_EVENT_SCALAR_DP_UOP), 280 .opcode = P4_OPCODE(P4_EVENT_SCALAR_DP_UOP),
163 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 281 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
282 .escr_emask =
283 P4_ESCR_EMASK_BIT(P4_EVENT_SCALAR_DP_UOP, ALL),
284 .shared = 1,
164 .cntr = { {8, 9, -1}, {10, 11, -1} }, 285 .cntr = { {8, 9, -1}, {10, 11, -1} },
165 }, 286 },
166 [P4_EVENT_64BIT_MMX_UOP] = { 287 [P4_EVENT_64BIT_MMX_UOP] = {
167 .opcode = P4_OPCODE(P4_EVENT_64BIT_MMX_UOP), 288 .opcode = P4_OPCODE(P4_EVENT_64BIT_MMX_UOP),
168 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 289 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
290 .escr_emask =
291 P4_ESCR_EMASK_BIT(P4_EVENT_64BIT_MMX_UOP, ALL),
292 .shared = 1,
169 .cntr = { {8, 9, -1}, {10, 11, -1} }, 293 .cntr = { {8, 9, -1}, {10, 11, -1} },
170 }, 294 },
171 [P4_EVENT_128BIT_MMX_UOP] = { 295 [P4_EVENT_128BIT_MMX_UOP] = {
172 .opcode = P4_OPCODE(P4_EVENT_128BIT_MMX_UOP), 296 .opcode = P4_OPCODE(P4_EVENT_128BIT_MMX_UOP),
173 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 297 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
298 .escr_emask =
299 P4_ESCR_EMASK_BIT(P4_EVENT_128BIT_MMX_UOP, ALL),
300 .shared = 1,
174 .cntr = { {8, 9, -1}, {10, 11, -1} }, 301 .cntr = { {8, 9, -1}, {10, 11, -1} },
175 }, 302 },
176 [P4_EVENT_X87_FP_UOP] = { 303 [P4_EVENT_X87_FP_UOP] = {
177 .opcode = P4_OPCODE(P4_EVENT_X87_FP_UOP), 304 .opcode = P4_OPCODE(P4_EVENT_X87_FP_UOP),
178 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 }, 305 .escr_msr = { MSR_P4_FIRM_ESCR0, MSR_P4_FIRM_ESCR1 },
306 .escr_emask =
307 P4_ESCR_EMASK_BIT(P4_EVENT_X87_FP_UOP, ALL),
308 .shared = 1,
179 .cntr = { {8, 9, -1}, {10, 11, -1} }, 309 .cntr = { {8, 9, -1}, {10, 11, -1} },
180 }, 310 },
181 [P4_EVENT_TC_MISC] = { 311 [P4_EVENT_TC_MISC] = {
182 .opcode = P4_OPCODE(P4_EVENT_TC_MISC), 312 .opcode = P4_OPCODE(P4_EVENT_TC_MISC),
183 .escr_msr = { MSR_P4_TC_ESCR0, MSR_P4_TC_ESCR1 }, 313 .escr_msr = { MSR_P4_TC_ESCR0, MSR_P4_TC_ESCR1 },
314 .escr_emask =
315 P4_ESCR_EMASK_BIT(P4_EVENT_TC_MISC, FLUSH),
184 .cntr = { {4, 5, -1}, {6, 7, -1} }, 316 .cntr = { {4, 5, -1}, {6, 7, -1} },
185 }, 317 },
186 [P4_EVENT_GLOBAL_POWER_EVENTS] = { 318 [P4_EVENT_GLOBAL_POWER_EVENTS] = {
187 .opcode = P4_OPCODE(P4_EVENT_GLOBAL_POWER_EVENTS), 319 .opcode = P4_OPCODE(P4_EVENT_GLOBAL_POWER_EVENTS),
188 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 320 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
321 .escr_emask =
322 P4_ESCR_EMASK_BIT(P4_EVENT_GLOBAL_POWER_EVENTS, RUNNING),
189 .cntr = { {0, -1, -1}, {2, -1, -1} }, 323 .cntr = { {0, -1, -1}, {2, -1, -1} },
190 }, 324 },
191 [P4_EVENT_TC_MS_XFER] = { 325 [P4_EVENT_TC_MS_XFER] = {
192 .opcode = P4_OPCODE(P4_EVENT_TC_MS_XFER), 326 .opcode = P4_OPCODE(P4_EVENT_TC_MS_XFER),
193 .escr_msr = { MSR_P4_MS_ESCR0, MSR_P4_MS_ESCR1 }, 327 .escr_msr = { MSR_P4_MS_ESCR0, MSR_P4_MS_ESCR1 },
328 .escr_emask =
329 P4_ESCR_EMASK_BIT(P4_EVENT_TC_MS_XFER, CISC),
194 .cntr = { {4, 5, -1}, {6, 7, -1} }, 330 .cntr = { {4, 5, -1}, {6, 7, -1} },
195 }, 331 },
196 [P4_EVENT_UOP_QUEUE_WRITES] = { 332 [P4_EVENT_UOP_QUEUE_WRITES] = {
197 .opcode = P4_OPCODE(P4_EVENT_UOP_QUEUE_WRITES), 333 .opcode = P4_OPCODE(P4_EVENT_UOP_QUEUE_WRITES),
198 .escr_msr = { MSR_P4_MS_ESCR0, MSR_P4_MS_ESCR1 }, 334 .escr_msr = { MSR_P4_MS_ESCR0, MSR_P4_MS_ESCR1 },
335 .escr_emask =
336 P4_ESCR_EMASK_BIT(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_BUILD) |
337 P4_ESCR_EMASK_BIT(P4_EVENT_UOP_QUEUE_WRITES, FROM_TC_DELIVER) |
338 P4_ESCR_EMASK_BIT(P4_EVENT_UOP_QUEUE_WRITES, FROM_ROM),
199 .cntr = { {4, 5, -1}, {6, 7, -1} }, 339 .cntr = { {4, 5, -1}, {6, 7, -1} },
200 }, 340 },
201 [P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE] = { 341 [P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE] = {
202 .opcode = P4_OPCODE(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE), 342 .opcode = P4_OPCODE(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE),
203 .escr_msr = { MSR_P4_TBPU_ESCR0 , MSR_P4_TBPU_ESCR0 }, 343 .escr_msr = { MSR_P4_TBPU_ESCR0 , MSR_P4_TBPU_ESCR0 },
344 .escr_emask =
345 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CONDITIONAL) |
346 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, CALL) |
347 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, RETURN) |
348 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_MISPRED_BRANCH_TYPE, INDIRECT),
204 .cntr = { {4, 5, -1}, {6, 7, -1} }, 349 .cntr = { {4, 5, -1}, {6, 7, -1} },
205 }, 350 },
206 [P4_EVENT_RETIRED_BRANCH_TYPE] = { 351 [P4_EVENT_RETIRED_BRANCH_TYPE] = {
207 .opcode = P4_OPCODE(P4_EVENT_RETIRED_BRANCH_TYPE), 352 .opcode = P4_OPCODE(P4_EVENT_RETIRED_BRANCH_TYPE),
208 .escr_msr = { MSR_P4_TBPU_ESCR0 , MSR_P4_TBPU_ESCR1 }, 353 .escr_msr = { MSR_P4_TBPU_ESCR0 , MSR_P4_TBPU_ESCR1 },
354 .escr_emask =
355 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_BRANCH_TYPE, CONDITIONAL) |
356 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_BRANCH_TYPE, CALL) |
357 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_BRANCH_TYPE, RETURN) |
358 P4_ESCR_EMASK_BIT(P4_EVENT_RETIRED_BRANCH_TYPE, INDIRECT),
209 .cntr = { {4, 5, -1}, {6, 7, -1} }, 359 .cntr = { {4, 5, -1}, {6, 7, -1} },
210 }, 360 },
211 [P4_EVENT_RESOURCE_STALL] = { 361 [P4_EVENT_RESOURCE_STALL] = {
212 .opcode = P4_OPCODE(P4_EVENT_RESOURCE_STALL), 362 .opcode = P4_OPCODE(P4_EVENT_RESOURCE_STALL),
213 .escr_msr = { MSR_P4_ALF_ESCR0, MSR_P4_ALF_ESCR1 }, 363 .escr_msr = { MSR_P4_ALF_ESCR0, MSR_P4_ALF_ESCR1 },
364 .escr_emask =
365 P4_ESCR_EMASK_BIT(P4_EVENT_RESOURCE_STALL, SBFULL),
214 .cntr = { {12, 13, 16}, {14, 15, 17} }, 366 .cntr = { {12, 13, 16}, {14, 15, 17} },
215 }, 367 },
216 [P4_EVENT_WC_BUFFER] = { 368 [P4_EVENT_WC_BUFFER] = {
217 .opcode = P4_OPCODE(P4_EVENT_WC_BUFFER), 369 .opcode = P4_OPCODE(P4_EVENT_WC_BUFFER),
218 .escr_msr = { MSR_P4_DAC_ESCR0, MSR_P4_DAC_ESCR1 }, 370 .escr_msr = { MSR_P4_DAC_ESCR0, MSR_P4_DAC_ESCR1 },
371 .escr_emask =
372 P4_ESCR_EMASK_BIT(P4_EVENT_WC_BUFFER, WCB_EVICTS) |
373 P4_ESCR_EMASK_BIT(P4_EVENT_WC_BUFFER, WCB_FULL_EVICTS),
374 .shared = 1,
219 .cntr = { {8, 9, -1}, {10, 11, -1} }, 375 .cntr = { {8, 9, -1}, {10, 11, -1} },
220 }, 376 },
221 [P4_EVENT_B2B_CYCLES] = { 377 [P4_EVENT_B2B_CYCLES] = {
222 .opcode = P4_OPCODE(P4_EVENT_B2B_CYCLES), 378 .opcode = P4_OPCODE(P4_EVENT_B2B_CYCLES),
223 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 379 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
380 .escr_emask = 0,
224 .cntr = { {0, -1, -1}, {2, -1, -1} }, 381 .cntr = { {0, -1, -1}, {2, -1, -1} },
225 }, 382 },
226 [P4_EVENT_BNR] = { 383 [P4_EVENT_BNR] = {
227 .opcode = P4_OPCODE(P4_EVENT_BNR), 384 .opcode = P4_OPCODE(P4_EVENT_BNR),
228 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 385 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
386 .escr_emask = 0,
229 .cntr = { {0, -1, -1}, {2, -1, -1} }, 387 .cntr = { {0, -1, -1}, {2, -1, -1} },
230 }, 388 },
231 [P4_EVENT_SNOOP] = { 389 [P4_EVENT_SNOOP] = {
232 .opcode = P4_OPCODE(P4_EVENT_SNOOP), 390 .opcode = P4_OPCODE(P4_EVENT_SNOOP),
233 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 391 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
392 .escr_emask = 0,
234 .cntr = { {0, -1, -1}, {2, -1, -1} }, 393 .cntr = { {0, -1, -1}, {2, -1, -1} },
235 }, 394 },
236 [P4_EVENT_RESPONSE] = { 395 [P4_EVENT_RESPONSE] = {
237 .opcode = P4_OPCODE(P4_EVENT_RESPONSE), 396 .opcode = P4_OPCODE(P4_EVENT_RESPONSE),
238 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 }, 397 .escr_msr = { MSR_P4_FSB_ESCR0, MSR_P4_FSB_ESCR1 },
398 .escr_emask = 0,
239 .cntr = { {0, -1, -1}, {2, -1, -1} }, 399 .cntr = { {0, -1, -1}, {2, -1, -1} },
240 }, 400 },
241 [P4_EVENT_FRONT_END_EVENT] = { 401 [P4_EVENT_FRONT_END_EVENT] = {
242 .opcode = P4_OPCODE(P4_EVENT_FRONT_END_EVENT), 402 .opcode = P4_OPCODE(P4_EVENT_FRONT_END_EVENT),
243 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 403 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
404 .escr_emask =
405 P4_ESCR_EMASK_BIT(P4_EVENT_FRONT_END_EVENT, NBOGUS) |
406 P4_ESCR_EMASK_BIT(P4_EVENT_FRONT_END_EVENT, BOGUS),
244 .cntr = { {12, 13, 16}, {14, 15, 17} }, 407 .cntr = { {12, 13, 16}, {14, 15, 17} },
245 }, 408 },
246 [P4_EVENT_EXECUTION_EVENT] = { 409 [P4_EVENT_EXECUTION_EVENT] = {
247 .opcode = P4_OPCODE(P4_EVENT_EXECUTION_EVENT), 410 .opcode = P4_OPCODE(P4_EVENT_EXECUTION_EVENT),
248 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 411 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
412 .escr_emask =
413 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS0) |
414 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS1) |
415 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS2) |
416 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, NBOGUS3) |
417 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, BOGUS0) |
418 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, BOGUS1) |
419 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, BOGUS2) |
420 P4_ESCR_EMASK_BIT(P4_EVENT_EXECUTION_EVENT, BOGUS3),
249 .cntr = { {12, 13, 16}, {14, 15, 17} }, 421 .cntr = { {12, 13, 16}, {14, 15, 17} },
250 }, 422 },
251 [P4_EVENT_REPLAY_EVENT] = { 423 [P4_EVENT_REPLAY_EVENT] = {
252 .opcode = P4_OPCODE(P4_EVENT_REPLAY_EVENT), 424 .opcode = P4_OPCODE(P4_EVENT_REPLAY_EVENT),
253 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 425 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
426 .escr_emask =
427 P4_ESCR_EMASK_BIT(P4_EVENT_REPLAY_EVENT, NBOGUS) |
428 P4_ESCR_EMASK_BIT(P4_EVENT_REPLAY_EVENT, BOGUS),
254 .cntr = { {12, 13, 16}, {14, 15, 17} }, 429 .cntr = { {12, 13, 16}, {14, 15, 17} },
255 }, 430 },
256 [P4_EVENT_INSTR_RETIRED] = { 431 [P4_EVENT_INSTR_RETIRED] = {
257 .opcode = P4_OPCODE(P4_EVENT_INSTR_RETIRED), 432 .opcode = P4_OPCODE(P4_EVENT_INSTR_RETIRED),
258 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 }, 433 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 },
434 .escr_emask =
435 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_RETIRED, NBOGUSNTAG) |
436 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_RETIRED, NBOGUSTAG) |
437 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_RETIRED, BOGUSNTAG) |
438 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_RETIRED, BOGUSTAG),
259 .cntr = { {12, 13, 16}, {14, 15, 17} }, 439 .cntr = { {12, 13, 16}, {14, 15, 17} },
260 }, 440 },
261 [P4_EVENT_UOPS_RETIRED] = { 441 [P4_EVENT_UOPS_RETIRED] = {
262 .opcode = P4_OPCODE(P4_EVENT_UOPS_RETIRED), 442 .opcode = P4_OPCODE(P4_EVENT_UOPS_RETIRED),
263 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 }, 443 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 },
444 .escr_emask =
445 P4_ESCR_EMASK_BIT(P4_EVENT_UOPS_RETIRED, NBOGUS) |
446 P4_ESCR_EMASK_BIT(P4_EVENT_UOPS_RETIRED, BOGUS),
264 .cntr = { {12, 13, 16}, {14, 15, 17} }, 447 .cntr = { {12, 13, 16}, {14, 15, 17} },
265 }, 448 },
266 [P4_EVENT_UOP_TYPE] = { 449 [P4_EVENT_UOP_TYPE] = {
267 .opcode = P4_OPCODE(P4_EVENT_UOP_TYPE), 450 .opcode = P4_OPCODE(P4_EVENT_UOP_TYPE),
268 .escr_msr = { MSR_P4_RAT_ESCR0, MSR_P4_RAT_ESCR1 }, 451 .escr_msr = { MSR_P4_RAT_ESCR0, MSR_P4_RAT_ESCR1 },
452 .escr_emask =
453 P4_ESCR_EMASK_BIT(P4_EVENT_UOP_TYPE, TAGLOADS) |
454 P4_ESCR_EMASK_BIT(P4_EVENT_UOP_TYPE, TAGSTORES),
269 .cntr = { {12, 13, 16}, {14, 15, 17} }, 455 .cntr = { {12, 13, 16}, {14, 15, 17} },
270 }, 456 },
271 [P4_EVENT_BRANCH_RETIRED] = { 457 [P4_EVENT_BRANCH_RETIRED] = {
272 .opcode = P4_OPCODE(P4_EVENT_BRANCH_RETIRED), 458 .opcode = P4_OPCODE(P4_EVENT_BRANCH_RETIRED),
273 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 459 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
460 .escr_emask =
461 P4_ESCR_EMASK_BIT(P4_EVENT_BRANCH_RETIRED, MMNP) |
462 P4_ESCR_EMASK_BIT(P4_EVENT_BRANCH_RETIRED, MMNM) |
463 P4_ESCR_EMASK_BIT(P4_EVENT_BRANCH_RETIRED, MMTP) |
464 P4_ESCR_EMASK_BIT(P4_EVENT_BRANCH_RETIRED, MMTM),
274 .cntr = { {12, 13, 16}, {14, 15, 17} }, 465 .cntr = { {12, 13, 16}, {14, 15, 17} },
275 }, 466 },
276 [P4_EVENT_MISPRED_BRANCH_RETIRED] = { 467 [P4_EVENT_MISPRED_BRANCH_RETIRED] = {
277 .opcode = P4_OPCODE(P4_EVENT_MISPRED_BRANCH_RETIRED), 468 .opcode = P4_OPCODE(P4_EVENT_MISPRED_BRANCH_RETIRED),
278 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 }, 469 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 },
470 .escr_emask =
471 P4_ESCR_EMASK_BIT(P4_EVENT_MISPRED_BRANCH_RETIRED, NBOGUS),
279 .cntr = { {12, 13, 16}, {14, 15, 17} }, 472 .cntr = { {12, 13, 16}, {14, 15, 17} },
280 }, 473 },
281 [P4_EVENT_X87_ASSIST] = { 474 [P4_EVENT_X87_ASSIST] = {
282 .opcode = P4_OPCODE(P4_EVENT_X87_ASSIST), 475 .opcode = P4_OPCODE(P4_EVENT_X87_ASSIST),
283 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 476 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
477 .escr_emask =
478 P4_ESCR_EMASK_BIT(P4_EVENT_X87_ASSIST, FPSU) |
479 P4_ESCR_EMASK_BIT(P4_EVENT_X87_ASSIST, FPSO) |
480 P4_ESCR_EMASK_BIT(P4_EVENT_X87_ASSIST, POAO) |
481 P4_ESCR_EMASK_BIT(P4_EVENT_X87_ASSIST, POAU) |
482 P4_ESCR_EMASK_BIT(P4_EVENT_X87_ASSIST, PREA),
284 .cntr = { {12, 13, 16}, {14, 15, 17} }, 483 .cntr = { {12, 13, 16}, {14, 15, 17} },
285 }, 484 },
286 [P4_EVENT_MACHINE_CLEAR] = { 485 [P4_EVENT_MACHINE_CLEAR] = {
287 .opcode = P4_OPCODE(P4_EVENT_MACHINE_CLEAR), 486 .opcode = P4_OPCODE(P4_EVENT_MACHINE_CLEAR),
288 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 }, 487 .escr_msr = { MSR_P4_CRU_ESCR2, MSR_P4_CRU_ESCR3 },
488 .escr_emask =
489 P4_ESCR_EMASK_BIT(P4_EVENT_MACHINE_CLEAR, CLEAR) |
490 P4_ESCR_EMASK_BIT(P4_EVENT_MACHINE_CLEAR, MOCLEAR) |
491 P4_ESCR_EMASK_BIT(P4_EVENT_MACHINE_CLEAR, SMCLEAR),
289 .cntr = { {12, 13, 16}, {14, 15, 17} }, 492 .cntr = { {12, 13, 16}, {14, 15, 17} },
290 }, 493 },
291 [P4_EVENT_INSTR_COMPLETED] = { 494 [P4_EVENT_INSTR_COMPLETED] = {
292 .opcode = P4_OPCODE(P4_EVENT_INSTR_COMPLETED), 495 .opcode = P4_OPCODE(P4_EVENT_INSTR_COMPLETED),
293 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 }, 496 .escr_msr = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 },
497 .escr_emask =
498 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_COMPLETED, NBOGUS) |
499 P4_ESCR_EMASK_BIT(P4_EVENT_INSTR_COMPLETED, BOGUS),
294 .cntr = { {12, 13, 16}, {14, 15, 17} }, 500 .cntr = { {12, 13, 16}, {14, 15, 17} },
295 }, 501 },
296}; 502};
@@ -428,29 +634,73 @@ static u64 p4_pmu_event_map(int hw_event)
428 return config; 634 return config;
429} 635}
430 636
637/* check cpu model specifics */
638static bool p4_event_match_cpu_model(unsigned int event_idx)
639{
640 /* INSTR_COMPLETED event only exist for model 3, 4, 6 (Prescott) */
641 if (event_idx == P4_EVENT_INSTR_COMPLETED) {
642 if (boot_cpu_data.x86_model != 3 &&
643 boot_cpu_data.x86_model != 4 &&
644 boot_cpu_data.x86_model != 6)
645 return false;
646 }
647
648 /*
649 * For info
650 * - IQ_ESCR0, IQ_ESCR1 only for models 1 and 2
651 */
652
653 return true;
654}
655
431static int p4_validate_raw_event(struct perf_event *event) 656static int p4_validate_raw_event(struct perf_event *event)
432{ 657{
433 unsigned int v; 658 unsigned int v, emask;
434 659
435 /* user data may have out-of-bound event index */ 660 /* User data may have out-of-bound event index */
436 v = p4_config_unpack_event(event->attr.config); 661 v = p4_config_unpack_event(event->attr.config);
437 if (v >= ARRAY_SIZE(p4_event_bind_map)) { 662 if (v >= ARRAY_SIZE(p4_event_bind_map))
438 pr_warning("P4 PMU: Unknown event code: %d\n", v); 663 return -EINVAL;
664
665 /* It may be unsupported: */
666 if (!p4_event_match_cpu_model(v))
439 return -EINVAL; 667 return -EINVAL;
668
669 /*
670 * NOTE: P4_CCCR_THREAD_ANY has not the same meaning as
671 * in Architectural Performance Monitoring, it means not
672 * on _which_ logical cpu to count but rather _when_, ie it
673 * depends on logical cpu state -- count event if one cpu active,
674 * none, both or any, so we just allow user to pass any value
675 * desired.
676 *
677 * In turn we always set Tx_OS/Tx_USR bits bound to logical
678 * cpu without their propagation to another cpu
679 */
680
681 /*
682 * if an event is shared accross the logical threads
683 * the user needs special permissions to be able to use it
684 */
685 if (p4_event_bind_map[v].shared) {
686 if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
687 return -EACCES;
440 } 688 }
441 689
690 /* ESCR EventMask bits may be invalid */
691 emask = p4_config_unpack_escr(event->attr.config) & P4_ESCR_EVENTMASK_MASK;
692 if (emask & ~p4_event_bind_map[v].escr_emask)
693 return -EINVAL;
694
442 /* 695 /*
443 * it may have some screwed PEBS bits 696 * it may have some invalid PEBS bits
444 */ 697 */
445 if (p4_config_pebs_has(event->attr.config, P4_PEBS_CONFIG_ENABLE)) { 698 if (p4_config_pebs_has(event->attr.config, P4_PEBS_CONFIG_ENABLE))
446 pr_warning("P4 PMU: PEBS are not supported yet\n");
447 return -EINVAL; 699 return -EINVAL;
448 } 700
449 v = p4_config_unpack_metric(event->attr.config); 701 v = p4_config_unpack_metric(event->attr.config);
450 if (v >= ARRAY_SIZE(p4_pebs_bind_map)) { 702 if (v >= ARRAY_SIZE(p4_pebs_bind_map))
451 pr_warning("P4 PMU: Unknown metric code: %d\n", v);
452 return -EINVAL; 703 return -EINVAL;
453 }
454 704
455 return 0; 705 return 0;
456} 706}
@@ -478,27 +728,21 @@ static int p4_hw_config(struct perf_event *event)
478 728
479 if (event->attr.type == PERF_TYPE_RAW) { 729 if (event->attr.type == PERF_TYPE_RAW) {
480 730
731 /*
732 * Clear bits we reserve to be managed by kernel itself
733 * and never allowed from a user space
734 */
735 event->attr.config &= P4_CONFIG_MASK;
736
481 rc = p4_validate_raw_event(event); 737 rc = p4_validate_raw_event(event);
482 if (rc) 738 if (rc)
483 goto out; 739 goto out;
484 740
485 /* 741 /*
486 * We don't control raw events so it's up to the caller
487 * to pass sane values (and we don't count the thread number
488 * on HT machine but allow HT-compatible specifics to be
489 * passed on)
490 *
491 * Note that for RAW events we allow user to use P4_CCCR_RESERVED 742 * Note that for RAW events we allow user to use P4_CCCR_RESERVED
492 * bits since we keep additional info here (for cache events and etc) 743 * bits since we keep additional info here (for cache events and etc)
493 *
494 * XXX: HT wide things should check perf_paranoid_cpu() &&
495 * CAP_SYS_ADMIN
496 */ 744 */
497 event->hw.config |= event->attr.config & 745 event->hw.config |= event->attr.config;
498 (p4_config_pack_escr(P4_ESCR_MASK_HT) |
499 p4_config_pack_cccr(P4_CCCR_MASK_HT | P4_CCCR_RESERVED));
500
501 event->hw.config &= ~P4_CCCR_FORCE_OVF;
502 } 746 }
503 747
504 rc = x86_setup_perfctr(event); 748 rc = x86_setup_perfctr(event);
@@ -660,8 +904,12 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
660 for (idx = 0; idx < x86_pmu.num_counters; idx++) { 904 for (idx = 0; idx < x86_pmu.num_counters; idx++) {
661 int overflow; 905 int overflow;
662 906
663 if (!test_bit(idx, cpuc->active_mask)) 907 if (!test_bit(idx, cpuc->active_mask)) {
908 /* catch in-flight IRQs */
909 if (__test_and_clear_bit(idx, cpuc->running))
910 handled++;
664 continue; 911 continue;
912 }
665 913
666 event = cpuc->events[idx]; 914 event = cpuc->events[idx];
667 hwc = &event->hw; 915 hwc = &event->hw;
diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index fb329e9f8494..d9f4ff8fcd69 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -700,11 +700,10 @@ static void probe_nmi_watchdog(void)
700{ 700{
701 switch (boot_cpu_data.x86_vendor) { 701 switch (boot_cpu_data.x86_vendor) {
702 case X86_VENDOR_AMD: 702 case X86_VENDOR_AMD:
703 if (boot_cpu_data.x86 != 6 && boot_cpu_data.x86 != 15 && 703 if (boot_cpu_data.x86 == 6 ||
704 boot_cpu_data.x86 != 16 && boot_cpu_data.x86 != 17) 704 (boot_cpu_data.x86 >= 0xf && boot_cpu_data.x86 <= 0x15))
705 return; 705 wd_ops = &k7_wd_ops;
706 wd_ops = &k7_wd_ops; 706 return;
707 break;
708 case X86_VENDOR_INTEL: 707 case X86_VENDOR_INTEL:
709 /* Work around where perfctr1 doesn't have a working enable 708 /* Work around where perfctr1 doesn't have a working enable
710 * bit as described in the following errata: 709 * bit as described in the following errata:
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index d49079515122..c7f64e6f537a 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -44,6 +44,12 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
44 { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 }, 44 { X86_FEATURE_LBRV, CR_EDX, 1, 0x8000000a, 0 },
45 { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 }, 45 { X86_FEATURE_SVML, CR_EDX, 2, 0x8000000a, 0 },
46 { X86_FEATURE_NRIPS, CR_EDX, 3, 0x8000000a, 0 }, 46 { X86_FEATURE_NRIPS, CR_EDX, 3, 0x8000000a, 0 },
47 { X86_FEATURE_TSCRATEMSR, CR_EDX, 4, 0x8000000a, 0 },
48 { X86_FEATURE_VMCBCLEAN, CR_EDX, 5, 0x8000000a, 0 },
49 { X86_FEATURE_FLUSHBYASID, CR_EDX, 6, 0x8000000a, 0 },
50 { X86_FEATURE_DECODEASSISTS, CR_EDX, 7, 0x8000000a, 0 },
51 { X86_FEATURE_PAUSEFILTER, CR_EDX,10, 0x8000000a, 0 },
52 { X86_FEATURE_PFTHRESHOLD, CR_EDX,12, 0x8000000a, 0 },
47 { 0, 0, 0, 0, 0 } 53 { 0, 0, 0, 0, 0 }
48 }; 54 };
49 55
diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
index 045b36cada65..994828899e09 100644
--- a/arch/x86/kernel/crash_dump_64.c
+++ b/arch/x86/kernel/crash_dump_64.c
@@ -34,7 +34,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
34 if (!csize) 34 if (!csize)
35 return 0; 35 return 0;
36 36
37 vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); 37 vaddr = ioremap_cache(pfn << PAGE_SHIFT, PAGE_SIZE);
38 if (!vaddr) 38 if (!vaddr)
39 return -ENOMEM; 39 return -ENOMEM;
40 40
@@ -46,6 +46,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
46 } else 46 } else
47 memcpy(buf, vaddr + offset, csize); 47 memcpy(buf, vaddr + offset, csize);
48 48
49 set_iounmap_nonlazy();
49 iounmap(vaddr); 50 iounmap(vaddr);
50 return csize; 51 return csize;
51} 52}
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 0d6fc71bedb1..0c2b7ef7a34d 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -15,6 +15,7 @@
15#include <linux/pfn.h> 15#include <linux/pfn.h>
16#include <linux/suspend.h> 16#include <linux/suspend.h>
17#include <linux/firmware-map.h> 17#include <linux/firmware-map.h>
18#include <linux/memblock.h>
18 19
19#include <asm/e820.h> 20#include <asm/e820.h>
20#include <asm/proto.h> 21#include <asm/proto.h>
@@ -738,73 +739,7 @@ core_initcall(e820_mark_nvs_memory);
738#endif 739#endif
739 740
740/* 741/*
741 * Find a free area with specified alignment in a specific range. 742 * pre allocated 4k and reserved it in memblock and e820_saved
742 */
743u64 __init find_e820_area(u64 start, u64 end, u64 size, u64 align)
744{
745 int i;
746
747 for (i = 0; i < e820.nr_map; i++) {
748 struct e820entry *ei = &e820.map[i];
749 u64 addr;
750 u64 ei_start, ei_last;
751
752 if (ei->type != E820_RAM)
753 continue;
754
755 ei_last = ei->addr + ei->size;
756 ei_start = ei->addr;
757 addr = find_early_area(ei_start, ei_last, start, end,
758 size, align);
759
760 if (addr != -1ULL)
761 return addr;
762 }
763 return -1ULL;
764}
765
766u64 __init find_fw_memmap_area(u64 start, u64 end, u64 size, u64 align)
767{
768 return find_e820_area(start, end, size, align);
769}
770
771u64 __init get_max_mapped(void)
772{
773 u64 end = max_pfn_mapped;
774
775 end <<= PAGE_SHIFT;
776
777 return end;
778}
779/*
780 * Find next free range after *start
781 */
782u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align)
783{
784 int i;
785
786 for (i = 0; i < e820.nr_map; i++) {
787 struct e820entry *ei = &e820.map[i];
788 u64 addr;
789 u64 ei_start, ei_last;
790
791 if (ei->type != E820_RAM)
792 continue;
793
794 ei_last = ei->addr + ei->size;
795 ei_start = ei->addr;
796 addr = find_early_area_size(ei_start, ei_last, start,
797 sizep, align);
798
799 if (addr != -1ULL)
800 return addr;
801 }
802
803 return -1ULL;
804}
805
806/*
807 * pre allocated 4k and reserved it in e820
808 */ 743 */
809u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) 744u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
810{ 745{
@@ -813,8 +748,8 @@ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
813 u64 start; 748 u64 start;
814 749
815 for (start = startt; ; start += size) { 750 for (start = startt; ; start += size) {
816 start = find_e820_area_size(start, &size, align); 751 start = memblock_x86_find_in_range_size(start, &size, align);
817 if (!(start + 1)) 752 if (start == MEMBLOCK_ERROR)
818 return 0; 753 return 0;
819 if (size >= sizet) 754 if (size >= sizet)
820 break; 755 break;
@@ -830,10 +765,9 @@ u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
830 addr = round_down(start + size - sizet, align); 765 addr = round_down(start + size - sizet, align);
831 if (addr < start) 766 if (addr < start)
832 return 0; 767 return 0;
833 e820_update_range(addr, sizet, E820_RAM, E820_RESERVED); 768 memblock_x86_reserve_range(addr, addr + sizet, "new next");
834 e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED); 769 e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
835 printk(KERN_INFO "update e820 for early_reserve_e820\n"); 770 printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
836 update_e820();
837 update_e820_saved(); 771 update_e820_saved();
838 772
839 return addr; 773 return addr;
@@ -895,74 +829,6 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
895{ 829{
896 return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM); 830 return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
897} 831}
898/*
899 * Finds an active region in the address range from start_pfn to last_pfn and
900 * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
901 */
902int __init e820_find_active_region(const struct e820entry *ei,
903 unsigned long start_pfn,
904 unsigned long last_pfn,
905 unsigned long *ei_startpfn,
906 unsigned long *ei_endpfn)
907{
908 u64 align = PAGE_SIZE;
909
910 *ei_startpfn = round_up(ei->addr, align) >> PAGE_SHIFT;
911 *ei_endpfn = round_down(ei->addr + ei->size, align) >> PAGE_SHIFT;
912
913 /* Skip map entries smaller than a page */
914 if (*ei_startpfn >= *ei_endpfn)
915 return 0;
916
917 /* Skip if map is outside the node */
918 if (ei->type != E820_RAM || *ei_endpfn <= start_pfn ||
919 *ei_startpfn >= last_pfn)
920 return 0;
921
922 /* Check for overlaps */
923 if (*ei_startpfn < start_pfn)
924 *ei_startpfn = start_pfn;
925 if (*ei_endpfn > last_pfn)
926 *ei_endpfn = last_pfn;
927
928 return 1;
929}
930
931/* Walk the e820 map and register active regions within a node */
932void __init e820_register_active_regions(int nid, unsigned long start_pfn,
933 unsigned long last_pfn)
934{
935 unsigned long ei_startpfn;
936 unsigned long ei_endpfn;
937 int i;
938
939 for (i = 0; i < e820.nr_map; i++)
940 if (e820_find_active_region(&e820.map[i],
941 start_pfn, last_pfn,
942 &ei_startpfn, &ei_endpfn))
943 add_active_range(nid, ei_startpfn, ei_endpfn);
944}
945
946/*
947 * Find the hole size (in bytes) in the memory range.
948 * @start: starting address of the memory range to scan
949 * @end: ending address of the memory range to scan
950 */
951u64 __init e820_hole_size(u64 start, u64 end)
952{
953 unsigned long start_pfn = start >> PAGE_SHIFT;
954 unsigned long last_pfn = end >> PAGE_SHIFT;
955 unsigned long ei_startpfn, ei_endpfn, ram = 0;
956 int i;
957
958 for (i = 0; i < e820.nr_map; i++) {
959 if (e820_find_active_region(&e820.map[i],
960 start_pfn, last_pfn,
961 &ei_startpfn, &ei_endpfn))
962 ram += ei_endpfn - ei_startpfn;
963 }
964 return end - start - ((u64)ram << PAGE_SHIFT);
965}
966 832
967static void early_panic(char *msg) 833static void early_panic(char *msg)
968{ 834{
@@ -1210,3 +1076,48 @@ void __init setup_memory_map(void)
1210 printk(KERN_INFO "BIOS-provided physical RAM map:\n"); 1076 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1211 e820_print_map(who); 1077 e820_print_map(who);
1212} 1078}
1079
1080void __init memblock_x86_fill(void)
1081{
1082 int i;
1083 u64 end;
1084
1085 /*
1086 * EFI may have more than 128 entries
1087 * We are safe to enable resizing, beause memblock_x86_fill()
1088 * is rather later for x86
1089 */
1090 memblock_can_resize = 1;
1091
1092 for (i = 0; i < e820.nr_map; i++) {
1093 struct e820entry *ei = &e820.map[i];
1094
1095 end = ei->addr + ei->size;
1096 if (end != (resource_size_t)end)
1097 continue;
1098
1099 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
1100 continue;
1101
1102 memblock_add(ei->addr, ei->size);
1103 }
1104
1105 memblock_analyze();
1106 memblock_dump_all();
1107}
1108
1109void __init memblock_find_dma_reserve(void)
1110{
1111#ifdef CONFIG_X86_64
1112 u64 free_size_pfn;
1113 u64 mem_size_pfn;
1114 /*
1115 * need to find out used area below MAX_DMA_PFN
1116 * need to use memblock to get free size in [0, MAX_DMA_PFN]
1117 * at first, and assume boot_mem will not take below MAX_DMA_PFN
1118 */
1119 mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
1120 free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
1121 set_dma_reserve(mem_size_pfn - free_size_pfn);
1122#endif
1123}
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index ebdb85cf2686..76b8cd953dee 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -97,7 +97,6 @@ static void __init nvidia_bugs(int num, int slot, int func)
97} 97}
98 98
99#if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC) 99#if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
100#if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
101static u32 __init ati_ixp4x0_rev(int num, int slot, int func) 100static u32 __init ati_ixp4x0_rev(int num, int slot, int func)
102{ 101{
103 u32 d; 102 u32 d;
@@ -115,7 +114,6 @@ static u32 __init ati_ixp4x0_rev(int num, int slot, int func)
115 d &= 0xff; 114 d &= 0xff;
116 return d; 115 return d;
117} 116}
118#endif
119 117
120static void __init ati_bugs(int num, int slot, int func) 118static void __init ati_bugs(int num, int slot, int func)
121{ 119{
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index fa99bae75ace..4572f25f9325 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -14,6 +14,7 @@
14#include <xen/hvc-console.h> 14#include <xen/hvc-console.h>
15#include <asm/pci-direct.h> 15#include <asm/pci-direct.h>
16#include <asm/fixmap.h> 16#include <asm/fixmap.h>
17#include <asm/mrst.h>
17#include <asm/pgtable.h> 18#include <asm/pgtable.h>
18#include <linux/usb/ehci_def.h> 19#include <linux/usb/ehci_def.h>
19 20
@@ -239,6 +240,18 @@ static int __init setup_early_printk(char *buf)
239 if (!strncmp(buf, "xen", 3)) 240 if (!strncmp(buf, "xen", 3))
240 early_console_register(&xenboot_console, keep); 241 early_console_register(&xenboot_console, keep);
241#endif 242#endif
243#ifdef CONFIG_X86_MRST_EARLY_PRINTK
244 if (!strncmp(buf, "mrst", 4)) {
245 mrst_early_console_init();
246 early_console_register(&early_mrst_console, keep);
247 }
248
249 if (!strncmp(buf, "hsu", 3)) {
250 hsu_early_console_init();
251 early_console_register(&early_hsu_console, keep);
252 }
253
254#endif
242 buf++; 255 buf++;
243 } 256 }
244 return 0; 257 return 0;
diff --git a/arch/x86/kernel/early_printk_mrst.c b/arch/x86/kernel/early_printk_mrst.c
new file mode 100644
index 000000000000..65df603622b2
--- /dev/null
+++ b/arch/x86/kernel/early_printk_mrst.c
@@ -0,0 +1,319 @@
1/*
2 * early_printk_mrst.c - early consoles for Intel MID platforms
3 *
4 * Copyright (c) 2008-2010, Intel 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; version 2
9 * of the License.
10 */
11
12/*
13 * This file implements two early consoles named mrst and hsu.
14 * mrst is based on Maxim3110 spi-uart device, it exists in both
15 * Moorestown and Medfield platforms, while hsu is based on a High
16 * Speed UART device which only exists in the Medfield platform
17 */
18
19#include <linux/serial_reg.h>
20#include <linux/serial_mfd.h>
21#include <linux/kmsg_dump.h>
22#include <linux/console.h>
23#include <linux/kernel.h>
24#include <linux/delay.h>
25#include <linux/init.h>
26#include <linux/io.h>
27
28#include <asm/fixmap.h>
29#include <asm/pgtable.h>
30#include <asm/mrst.h>
31
32#define MRST_SPI_TIMEOUT 0x200000
33#define MRST_REGBASE_SPI0 0xff128000
34#define MRST_REGBASE_SPI1 0xff128400
35#define MRST_CLK_SPI0_REG 0xff11d86c
36
37/* Bit fields in CTRLR0 */
38#define SPI_DFS_OFFSET 0
39
40#define SPI_FRF_OFFSET 4
41#define SPI_FRF_SPI 0x0
42#define SPI_FRF_SSP 0x1
43#define SPI_FRF_MICROWIRE 0x2
44#define SPI_FRF_RESV 0x3
45
46#define SPI_MODE_OFFSET 6
47#define SPI_SCPH_OFFSET 6
48#define SPI_SCOL_OFFSET 7
49#define SPI_TMOD_OFFSET 8
50#define SPI_TMOD_TR 0x0 /* xmit & recv */
51#define SPI_TMOD_TO 0x1 /* xmit only */
52#define SPI_TMOD_RO 0x2 /* recv only */
53#define SPI_TMOD_EPROMREAD 0x3 /* eeprom read mode */
54
55#define SPI_SLVOE_OFFSET 10
56#define SPI_SRL_OFFSET 11
57#define SPI_CFS_OFFSET 12
58
59/* Bit fields in SR, 7 bits */
60#define SR_MASK 0x7f /* cover 7 bits */
61#define SR_BUSY (1 << 0)
62#define SR_TF_NOT_FULL (1 << 1)
63#define SR_TF_EMPT (1 << 2)
64#define SR_RF_NOT_EMPT (1 << 3)
65#define SR_RF_FULL (1 << 4)
66#define SR_TX_ERR (1 << 5)
67#define SR_DCOL (1 << 6)
68
69struct dw_spi_reg {
70 u32 ctrl0;
71 u32 ctrl1;
72 u32 ssienr;
73 u32 mwcr;
74 u32 ser;
75 u32 baudr;
76 u32 txfltr;
77 u32 rxfltr;
78 u32 txflr;
79 u32 rxflr;
80 u32 sr;
81 u32 imr;
82 u32 isr;
83 u32 risr;
84 u32 txoicr;
85 u32 rxoicr;
86 u32 rxuicr;
87 u32 msticr;
88 u32 icr;
89 u32 dmacr;
90 u32 dmatdlr;
91 u32 dmardlr;
92 u32 idr;
93 u32 version;
94
95 /* Currently operates as 32 bits, though only the low 16 bits matter */
96 u32 dr;
97} __packed;
98
99#define dw_readl(dw, name) __raw_readl(&(dw)->name)
100#define dw_writel(dw, name, val) __raw_writel((val), &(dw)->name)
101
102/* Default use SPI0 register for mrst, we will detect Penwell and use SPI1 */
103static unsigned long mrst_spi_paddr = MRST_REGBASE_SPI0;
104
105static u32 *pclk_spi0;
106/* Always contains an accessable address, start with 0 */
107static struct dw_spi_reg *pspi;
108
109static struct kmsg_dumper dw_dumper;
110static int dumper_registered;
111
112static void dw_kmsg_dump(struct kmsg_dumper *dumper,
113 enum kmsg_dump_reason reason,
114 const char *s1, unsigned long l1,
115 const char *s2, unsigned long l2)
116{
117 int i;
118
119 /* When run to this, we'd better re-init the HW */
120 mrst_early_console_init();
121
122 for (i = 0; i < l1; i++)
123 early_mrst_console.write(&early_mrst_console, s1 + i, 1);
124 for (i = 0; i < l2; i++)
125 early_mrst_console.write(&early_mrst_console, s2 + i, 1);
126}
127
128/* Set the ratio rate to 115200, 8n1, IRQ disabled */
129static void max3110_write_config(void)
130{
131 u16 config;
132
133 config = 0xc001;
134 dw_writel(pspi, dr, config);
135}
136
137/* Translate char to a eligible word and send to max3110 */
138static void max3110_write_data(char c)
139{
140 u16 data;
141
142 data = 0x8000 | c;
143 dw_writel(pspi, dr, data);
144}
145
146void mrst_early_console_init(void)
147{
148 u32 ctrlr0 = 0;
149 u32 spi0_cdiv;
150 u32 freq; /* Freqency info only need be searched once */
151
152 /* Base clk is 100 MHz, the actual clk = 100M / (clk_divider + 1) */
153 pclk_spi0 = (void *)set_fixmap_offset_nocache(FIX_EARLYCON_MEM_BASE,
154 MRST_CLK_SPI0_REG);
155 spi0_cdiv = ((*pclk_spi0) & 0xe00) >> 9;
156 freq = 100000000 / (spi0_cdiv + 1);
157
158 if (mrst_identify_cpu() == MRST_CPU_CHIP_PENWELL)
159 mrst_spi_paddr = MRST_REGBASE_SPI1;
160
161 pspi = (void *)set_fixmap_offset_nocache(FIX_EARLYCON_MEM_BASE,
162 mrst_spi_paddr);
163
164 /* Disable SPI controller */
165 dw_writel(pspi, ssienr, 0);
166
167 /* Set control param, 8 bits, transmit only mode */
168 ctrlr0 = dw_readl(pspi, ctrl0);
169
170 ctrlr0 &= 0xfcc0;
171 ctrlr0 |= 0xf | (SPI_FRF_SPI << SPI_FRF_OFFSET)
172 | (SPI_TMOD_TO << SPI_TMOD_OFFSET);
173 dw_writel(pspi, ctrl0, ctrlr0);
174
175 /*
176 * Change the spi0 clk to comply with 115200 bps, use 100000 to
177 * calculate the clk dividor to make the clock a little slower
178 * than real baud rate.
179 */
180 dw_writel(pspi, baudr, freq/100000);
181
182 /* Disable all INT for early phase */
183 dw_writel(pspi, imr, 0x0);
184
185 /* Set the cs to spi-uart */
186 dw_writel(pspi, ser, 0x2);
187
188 /* Enable the HW, the last step for HW init */
189 dw_writel(pspi, ssienr, 0x1);
190
191 /* Set the default configuration */
192 max3110_write_config();
193
194 /* Register the kmsg dumper */
195 if (!dumper_registered) {
196 dw_dumper.dump = dw_kmsg_dump;
197 kmsg_dump_register(&dw_dumper);
198 dumper_registered = 1;
199 }
200}
201
202/* Slave select should be called in the read/write function */
203static void early_mrst_spi_putc(char c)
204{
205 unsigned int timeout;
206 u32 sr;
207
208 timeout = MRST_SPI_TIMEOUT;
209 /* Early putc needs to make sure the TX FIFO is not full */
210 while (--timeout) {
211 sr = dw_readl(pspi, sr);
212 if (!(sr & SR_TF_NOT_FULL))
213 cpu_relax();
214 else
215 break;
216 }
217
218 if (!timeout)
219 pr_warning("MRST earlycon: timed out\n");
220 else
221 max3110_write_data(c);
222}
223
224/* Early SPI only uses polling mode */
225static void early_mrst_spi_write(struct console *con, const char *str, unsigned n)
226{
227 int i;
228
229 for (i = 0; i < n && *str; i++) {
230 if (*str == '\n')
231 early_mrst_spi_putc('\r');
232 early_mrst_spi_putc(*str);
233 str++;
234 }
235}
236
237struct console early_mrst_console = {
238 .name = "earlymrst",
239 .write = early_mrst_spi_write,
240 .flags = CON_PRINTBUFFER,
241 .index = -1,
242};
243
244/*
245 * Following is the early console based on Medfield HSU (High
246 * Speed UART) device.
247 */
248#define HSU_PORT2_PADDR 0xffa28180
249
250static void __iomem *phsu;
251
252void hsu_early_console_init(void)
253{
254 u8 lcr;
255
256 phsu = (void *)set_fixmap_offset_nocache(FIX_EARLYCON_MEM_BASE,
257 HSU_PORT2_PADDR);
258
259 /* Disable FIFO */
260 writeb(0x0, phsu + UART_FCR);
261
262 /* Set to default 115200 bps, 8n1 */
263 lcr = readb(phsu + UART_LCR);
264 writeb((0x80 | lcr), phsu + UART_LCR);
265 writeb(0x18, phsu + UART_DLL);
266 writeb(lcr, phsu + UART_LCR);
267 writel(0x3600, phsu + UART_MUL*4);
268
269 writeb(0x8, phsu + UART_MCR);
270 writeb(0x7, phsu + UART_FCR);
271 writeb(0x3, phsu + UART_LCR);
272
273 /* Clear IRQ status */
274 readb(phsu + UART_LSR);
275 readb(phsu + UART_RX);
276 readb(phsu + UART_IIR);
277 readb(phsu + UART_MSR);
278
279 /* Enable FIFO */
280 writeb(0x7, phsu + UART_FCR);
281}
282
283#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
284
285static void early_hsu_putc(char ch)
286{
287 unsigned int timeout = 10000; /* 10ms */
288 u8 status;
289
290 while (--timeout) {
291 status = readb(phsu + UART_LSR);
292 if (status & BOTH_EMPTY)
293 break;
294 udelay(1);
295 }
296
297 /* Only write the char when there was no timeout */
298 if (timeout)
299 writeb(ch, phsu + UART_TX);
300}
301
302static void early_hsu_write(struct console *con, const char *str, unsigned n)
303{
304 int i;
305
306 for (i = 0; i < n && *str; i++) {
307 if (*str == '\n')
308 early_hsu_putc('\r');
309 early_hsu_putc(*str);
310 str++;
311 }
312}
313
314struct console early_hsu_console = {
315 .name = "earlyhsu",
316 .write = early_hsu_write,
317 .flags = CON_PRINTBUFFER,
318 .index = -1,
319};
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c
index c2fa9b8b497e..0fe27d7c6258 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/kernel/efi.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/efi.h> 31#include <linux/efi.h>
32#include <linux/bootmem.h> 32#include <linux/bootmem.h>
33#include <linux/memblock.h>
33#include <linux/spinlock.h> 34#include <linux/spinlock.h>
34#include <linux/uaccess.h> 35#include <linux/uaccess.h>
35#include <linux/time.h> 36#include <linux/time.h>
@@ -275,7 +276,7 @@ static void __init do_add_efi_memmap(void)
275 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 276 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
276} 277}
277 278
278void __init efi_reserve_early(void) 279void __init efi_memblock_x86_reserve_range(void)
279{ 280{
280 unsigned long pmap; 281 unsigned long pmap;
281 282
@@ -290,7 +291,7 @@ void __init efi_reserve_early(void)
290 boot_params.efi_info.efi_memdesc_size; 291 boot_params.efi_info.efi_memdesc_size;
291 memmap.desc_version = boot_params.efi_info.efi_memdesc_version; 292 memmap.desc_version = boot_params.efi_info.efi_memdesc_version;
292 memmap.desc_size = boot_params.efi_info.efi_memdesc_size; 293 memmap.desc_size = boot_params.efi_info.efi_memdesc_size;
293 reserve_early(pmap, pmap + memmap.nr_map * memmap.desc_size, 294 memblock_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size,
294 "EFI memmap"); 295 "EFI memmap");
295} 296}
296 297
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 227d00920d2f..59e175e89599 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -115,8 +115,7 @@
115 115
116 /* unfortunately push/pop can't be no-op */ 116 /* unfortunately push/pop can't be no-op */
117.macro PUSH_GS 117.macro PUSH_GS
118 pushl $0 118 pushl_cfi $0
119 CFI_ADJUST_CFA_OFFSET 4
120.endm 119.endm
121.macro POP_GS pop=0 120.macro POP_GS pop=0
122 addl $(4 + \pop), %esp 121 addl $(4 + \pop), %esp
@@ -140,14 +139,12 @@
140#else /* CONFIG_X86_32_LAZY_GS */ 139#else /* CONFIG_X86_32_LAZY_GS */
141 140
142.macro PUSH_GS 141.macro PUSH_GS
143 pushl %gs 142 pushl_cfi %gs
144 CFI_ADJUST_CFA_OFFSET 4
145 /*CFI_REL_OFFSET gs, 0*/ 143 /*CFI_REL_OFFSET gs, 0*/
146.endm 144.endm
147 145
148.macro POP_GS pop=0 146.macro POP_GS pop=0
14998: popl %gs 14798: popl_cfi %gs
150 CFI_ADJUST_CFA_OFFSET -4
151 /*CFI_RESTORE gs*/ 148 /*CFI_RESTORE gs*/
152 .if \pop <> 0 149 .if \pop <> 0
153 add $\pop, %esp 150 add $\pop, %esp
@@ -195,35 +192,25 @@
195.macro SAVE_ALL 192.macro SAVE_ALL
196 cld 193 cld
197 PUSH_GS 194 PUSH_GS
198 pushl %fs 195 pushl_cfi %fs
199 CFI_ADJUST_CFA_OFFSET 4
200 /*CFI_REL_OFFSET fs, 0;*/ 196 /*CFI_REL_OFFSET fs, 0;*/
201 pushl %es 197 pushl_cfi %es
202 CFI_ADJUST_CFA_OFFSET 4
203 /*CFI_REL_OFFSET es, 0;*/ 198 /*CFI_REL_OFFSET es, 0;*/
204 pushl %ds 199 pushl_cfi %ds
205 CFI_ADJUST_CFA_OFFSET 4
206 /*CFI_REL_OFFSET ds, 0;*/ 200 /*CFI_REL_OFFSET ds, 0;*/
207 pushl %eax 201 pushl_cfi %eax
208 CFI_ADJUST_CFA_OFFSET 4
209 CFI_REL_OFFSET eax, 0 202 CFI_REL_OFFSET eax, 0
210 pushl %ebp 203 pushl_cfi %ebp
211 CFI_ADJUST_CFA_OFFSET 4
212 CFI_REL_OFFSET ebp, 0 204 CFI_REL_OFFSET ebp, 0
213 pushl %edi 205 pushl_cfi %edi
214 CFI_ADJUST_CFA_OFFSET 4
215 CFI_REL_OFFSET edi, 0 206 CFI_REL_OFFSET edi, 0
216 pushl %esi 207 pushl_cfi %esi
217 CFI_ADJUST_CFA_OFFSET 4
218 CFI_REL_OFFSET esi, 0 208 CFI_REL_OFFSET esi, 0
219 pushl %edx 209 pushl_cfi %edx
220 CFI_ADJUST_CFA_OFFSET 4
221 CFI_REL_OFFSET edx, 0 210 CFI_REL_OFFSET edx, 0
222 pushl %ecx 211 pushl_cfi %ecx
223 CFI_ADJUST_CFA_OFFSET 4
224 CFI_REL_OFFSET ecx, 0 212 CFI_REL_OFFSET ecx, 0
225 pushl %ebx 213 pushl_cfi %ebx
226 CFI_ADJUST_CFA_OFFSET 4
227 CFI_REL_OFFSET ebx, 0 214 CFI_REL_OFFSET ebx, 0
228 movl $(__USER_DS), %edx 215 movl $(__USER_DS), %edx
229 movl %edx, %ds 216 movl %edx, %ds
@@ -234,39 +221,29 @@
234.endm 221.endm
235 222
236.macro RESTORE_INT_REGS 223.macro RESTORE_INT_REGS
237 popl %ebx 224 popl_cfi %ebx
238 CFI_ADJUST_CFA_OFFSET -4
239 CFI_RESTORE ebx 225 CFI_RESTORE ebx
240 popl %ecx 226 popl_cfi %ecx
241 CFI_ADJUST_CFA_OFFSET -4
242 CFI_RESTORE ecx 227 CFI_RESTORE ecx
243 popl %edx 228 popl_cfi %edx
244 CFI_ADJUST_CFA_OFFSET -4
245 CFI_RESTORE edx 229 CFI_RESTORE edx
246 popl %esi 230 popl_cfi %esi
247 CFI_ADJUST_CFA_OFFSET -4
248 CFI_RESTORE esi 231 CFI_RESTORE esi
249 popl %edi 232 popl_cfi %edi
250 CFI_ADJUST_CFA_OFFSET -4
251 CFI_RESTORE edi 233 CFI_RESTORE edi
252 popl %ebp 234 popl_cfi %ebp
253 CFI_ADJUST_CFA_OFFSET -4
254 CFI_RESTORE ebp 235 CFI_RESTORE ebp
255 popl %eax 236 popl_cfi %eax
256 CFI_ADJUST_CFA_OFFSET -4
257 CFI_RESTORE eax 237 CFI_RESTORE eax
258.endm 238.endm
259 239
260.macro RESTORE_REGS pop=0 240.macro RESTORE_REGS pop=0
261 RESTORE_INT_REGS 241 RESTORE_INT_REGS
2621: popl %ds 2421: popl_cfi %ds
263 CFI_ADJUST_CFA_OFFSET -4
264 /*CFI_RESTORE ds;*/ 243 /*CFI_RESTORE ds;*/
2652: popl %es 2442: popl_cfi %es
266 CFI_ADJUST_CFA_OFFSET -4
267 /*CFI_RESTORE es;*/ 245 /*CFI_RESTORE es;*/
2683: popl %fs 2463: popl_cfi %fs
269 CFI_ADJUST_CFA_OFFSET -4
270 /*CFI_RESTORE fs;*/ 247 /*CFI_RESTORE fs;*/
271 POP_GS \pop 248 POP_GS \pop
272.pushsection .fixup, "ax" 249.pushsection .fixup, "ax"
@@ -320,16 +297,12 @@
320 297
321ENTRY(ret_from_fork) 298ENTRY(ret_from_fork)
322 CFI_STARTPROC 299 CFI_STARTPROC
323 pushl %eax 300 pushl_cfi %eax
324 CFI_ADJUST_CFA_OFFSET 4
325 call schedule_tail 301 call schedule_tail
326 GET_THREAD_INFO(%ebp) 302 GET_THREAD_INFO(%ebp)
327 popl %eax 303 popl_cfi %eax
328 CFI_ADJUST_CFA_OFFSET -4 304 pushl_cfi $0x0202 # Reset kernel eflags
329 pushl $0x0202 # Reset kernel eflags 305 popfl_cfi
330 CFI_ADJUST_CFA_OFFSET 4
331 popfl
332 CFI_ADJUST_CFA_OFFSET -4
333 jmp syscall_exit 306 jmp syscall_exit
334 CFI_ENDPROC 307 CFI_ENDPROC
335END(ret_from_fork) 308END(ret_from_fork)
@@ -409,29 +382,23 @@ sysenter_past_esp:
409 * enough kernel state to call TRACE_IRQS_OFF can be called - but 382 * enough kernel state to call TRACE_IRQS_OFF can be called - but
410 * we immediately enable interrupts at that point anyway. 383 * we immediately enable interrupts at that point anyway.
411 */ 384 */
412 pushl $(__USER_DS) 385 pushl_cfi $__USER_DS
413 CFI_ADJUST_CFA_OFFSET 4
414 /*CFI_REL_OFFSET ss, 0*/ 386 /*CFI_REL_OFFSET ss, 0*/
415 pushl %ebp 387 pushl_cfi %ebp
416 CFI_ADJUST_CFA_OFFSET 4
417 CFI_REL_OFFSET esp, 0 388 CFI_REL_OFFSET esp, 0
418 pushfl 389 pushfl_cfi
419 orl $X86_EFLAGS_IF, (%esp) 390 orl $X86_EFLAGS_IF, (%esp)
420 CFI_ADJUST_CFA_OFFSET 4 391 pushl_cfi $__USER_CS
421 pushl $(__USER_CS)
422 CFI_ADJUST_CFA_OFFSET 4
423 /*CFI_REL_OFFSET cs, 0*/ 392 /*CFI_REL_OFFSET cs, 0*/
424 /* 393 /*
425 * Push current_thread_info()->sysenter_return to the stack. 394 * Push current_thread_info()->sysenter_return to the stack.
426 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words 395 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
427 * pushed above; +8 corresponds to copy_thread's esp0 setting. 396 * pushed above; +8 corresponds to copy_thread's esp0 setting.
428 */ 397 */
429 pushl (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp) 398 pushl_cfi (TI_sysenter_return-THREAD_SIZE_asm+8+4*4)(%esp)
430 CFI_ADJUST_CFA_OFFSET 4
431 CFI_REL_OFFSET eip, 0 399 CFI_REL_OFFSET eip, 0
432 400
433 pushl %eax 401 pushl_cfi %eax
434 CFI_ADJUST_CFA_OFFSET 4
435 SAVE_ALL 402 SAVE_ALL
436 ENABLE_INTERRUPTS(CLBR_NONE) 403 ENABLE_INTERRUPTS(CLBR_NONE)
437 404
@@ -486,8 +453,7 @@ sysenter_audit:
486 movl %eax,%edx /* 2nd arg: syscall number */ 453 movl %eax,%edx /* 2nd arg: syscall number */
487 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */ 454 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
488 call audit_syscall_entry 455 call audit_syscall_entry
489 pushl %ebx 456 pushl_cfi %ebx
490 CFI_ADJUST_CFA_OFFSET 4
491 movl PT_EAX(%esp),%eax /* reload syscall number */ 457 movl PT_EAX(%esp),%eax /* reload syscall number */
492 jmp sysenter_do_call 458 jmp sysenter_do_call
493 459
@@ -529,8 +495,7 @@ ENDPROC(ia32_sysenter_target)
529 # system call handler stub 495 # system call handler stub
530ENTRY(system_call) 496ENTRY(system_call)
531 RING0_INT_FRAME # can't unwind into user space anyway 497 RING0_INT_FRAME # can't unwind into user space anyway
532 pushl %eax # save orig_eax 498 pushl_cfi %eax # save orig_eax
533 CFI_ADJUST_CFA_OFFSET 4
534 SAVE_ALL 499 SAVE_ALL
535 GET_THREAD_INFO(%ebp) 500 GET_THREAD_INFO(%ebp)
536 # system call tracing in operation / emulation 501 # system call tracing in operation / emulation
@@ -566,7 +531,6 @@ restore_all_notrace:
566 je ldt_ss # returning to user-space with LDT SS 531 je ldt_ss # returning to user-space with LDT SS
567restore_nocheck: 532restore_nocheck:
568 RESTORE_REGS 4 # skip orig_eax/error_code 533 RESTORE_REGS 4 # skip orig_eax/error_code
569 CFI_ADJUST_CFA_OFFSET -4
570irq_return: 534irq_return:
571 INTERRUPT_RETURN 535 INTERRUPT_RETURN
572.section .fixup,"ax" 536.section .fixup,"ax"
@@ -619,10 +583,8 @@ ldt_ss:
619 shr $16, %edx 583 shr $16, %edx
620 mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */ 584 mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
621 mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */ 585 mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
622 pushl $__ESPFIX_SS 586 pushl_cfi $__ESPFIX_SS
623 CFI_ADJUST_CFA_OFFSET 4 587 pushl_cfi %eax /* new kernel esp */
624 push %eax /* new kernel esp */
625 CFI_ADJUST_CFA_OFFSET 4
626 /* Disable interrupts, but do not irqtrace this section: we 588 /* Disable interrupts, but do not irqtrace this section: we
627 * will soon execute iret and the tracer was already set to 589 * will soon execute iret and the tracer was already set to
628 * the irqstate after the iret */ 590 * the irqstate after the iret */
@@ -666,11 +628,9 @@ work_notifysig: # deal with pending signals and
666 628
667 ALIGN 629 ALIGN
668work_notifysig_v86: 630work_notifysig_v86:
669 pushl %ecx # save ti_flags for do_notify_resume 631 pushl_cfi %ecx # save ti_flags for do_notify_resume
670 CFI_ADJUST_CFA_OFFSET 4
671 call save_v86_state # %eax contains pt_regs pointer 632 call save_v86_state # %eax contains pt_regs pointer
672 popl %ecx 633 popl_cfi %ecx
673 CFI_ADJUST_CFA_OFFSET -4
674 movl %eax, %esp 634 movl %eax, %esp
675#else 635#else
676 movl %esp, %eax 636 movl %esp, %eax
@@ -750,14 +710,18 @@ ptregs_##name: \
750#define PTREGSCALL3(name) \ 710#define PTREGSCALL3(name) \
751 ALIGN; \ 711 ALIGN; \
752ptregs_##name: \ 712ptregs_##name: \
713 CFI_STARTPROC; \
753 leal 4(%esp),%eax; \ 714 leal 4(%esp),%eax; \
754 pushl %eax; \ 715 pushl_cfi %eax; \
755 movl PT_EDX(%eax),%ecx; \ 716 movl PT_EDX(%eax),%ecx; \
756 movl PT_ECX(%eax),%edx; \ 717 movl PT_ECX(%eax),%edx; \
757 movl PT_EBX(%eax),%eax; \ 718 movl PT_EBX(%eax),%eax; \
758 call sys_##name; \ 719 call sys_##name; \
759 addl $4,%esp; \ 720 addl $4,%esp; \
760 ret 721 CFI_ADJUST_CFA_OFFSET -4; \
722 ret; \
723 CFI_ENDPROC; \
724ENDPROC(ptregs_##name)
761 725
762PTREGSCALL1(iopl) 726PTREGSCALL1(iopl)
763PTREGSCALL0(fork) 727PTREGSCALL0(fork)
@@ -772,15 +736,19 @@ PTREGSCALL1(vm86old)
772/* Clone is an oddball. The 4th arg is in %edi */ 736/* Clone is an oddball. The 4th arg is in %edi */
773 ALIGN; 737 ALIGN;
774ptregs_clone: 738ptregs_clone:
739 CFI_STARTPROC
775 leal 4(%esp),%eax 740 leal 4(%esp),%eax
776 pushl %eax 741 pushl_cfi %eax
777 pushl PT_EDI(%eax) 742 pushl_cfi PT_EDI(%eax)
778 movl PT_EDX(%eax),%ecx 743 movl PT_EDX(%eax),%ecx
779 movl PT_ECX(%eax),%edx 744 movl PT_ECX(%eax),%edx
780 movl PT_EBX(%eax),%eax 745 movl PT_EBX(%eax),%eax
781 call sys_clone 746 call sys_clone
782 addl $8,%esp 747 addl $8,%esp
748 CFI_ADJUST_CFA_OFFSET -8
783 ret 749 ret
750 CFI_ENDPROC
751ENDPROC(ptregs_clone)
784 752
785.macro FIXUP_ESPFIX_STACK 753.macro FIXUP_ESPFIX_STACK
786/* 754/*
@@ -795,10 +763,8 @@ ptregs_clone:
795 mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */ 763 mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
796 shl $16, %eax 764 shl $16, %eax
797 addl %esp, %eax /* the adjusted stack pointer */ 765 addl %esp, %eax /* the adjusted stack pointer */
798 pushl $__KERNEL_DS 766 pushl_cfi $__KERNEL_DS
799 CFI_ADJUST_CFA_OFFSET 4 767 pushl_cfi %eax
800 pushl %eax
801 CFI_ADJUST_CFA_OFFSET 4
802 lss (%esp), %esp /* switch to the normal stack segment */ 768 lss (%esp), %esp /* switch to the normal stack segment */
803 CFI_ADJUST_CFA_OFFSET -8 769 CFI_ADJUST_CFA_OFFSET -8
804.endm 770.endm
@@ -835,8 +801,7 @@ vector=FIRST_EXTERNAL_VECTOR
835 .if vector <> FIRST_EXTERNAL_VECTOR 801 .if vector <> FIRST_EXTERNAL_VECTOR
836 CFI_ADJUST_CFA_OFFSET -4 802 CFI_ADJUST_CFA_OFFSET -4
837 .endif 803 .endif
8381: pushl $(~vector+0x80) /* Note: always in signed byte range */ 8041: pushl_cfi $(~vector+0x80) /* Note: always in signed byte range */
839 CFI_ADJUST_CFA_OFFSET 4
840 .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6 805 .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6
841 jmp 2f 806 jmp 2f
842 .endif 807 .endif
@@ -876,8 +841,7 @@ ENDPROC(common_interrupt)
876#define BUILD_INTERRUPT3(name, nr, fn) \ 841#define BUILD_INTERRUPT3(name, nr, fn) \
877ENTRY(name) \ 842ENTRY(name) \
878 RING0_INT_FRAME; \ 843 RING0_INT_FRAME; \
879 pushl $~(nr); \ 844 pushl_cfi $~(nr); \
880 CFI_ADJUST_CFA_OFFSET 4; \
881 SAVE_ALL; \ 845 SAVE_ALL; \
882 TRACE_IRQS_OFF \ 846 TRACE_IRQS_OFF \
883 movl %esp,%eax; \ 847 movl %esp,%eax; \
@@ -893,21 +857,18 @@ ENDPROC(name)
893 857
894ENTRY(coprocessor_error) 858ENTRY(coprocessor_error)
895 RING0_INT_FRAME 859 RING0_INT_FRAME
896 pushl $0 860 pushl_cfi $0
897 CFI_ADJUST_CFA_OFFSET 4 861 pushl_cfi $do_coprocessor_error
898 pushl $do_coprocessor_error
899 CFI_ADJUST_CFA_OFFSET 4
900 jmp error_code 862 jmp error_code
901 CFI_ENDPROC 863 CFI_ENDPROC
902END(coprocessor_error) 864END(coprocessor_error)
903 865
904ENTRY(simd_coprocessor_error) 866ENTRY(simd_coprocessor_error)
905 RING0_INT_FRAME 867 RING0_INT_FRAME
906 pushl $0 868 pushl_cfi $0
907 CFI_ADJUST_CFA_OFFSET 4
908#ifdef CONFIG_X86_INVD_BUG 869#ifdef CONFIG_X86_INVD_BUG
909 /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */ 870 /* AMD 486 bug: invd from userspace calls exception 19 instead of #GP */
910661: pushl $do_general_protection 871661: pushl_cfi $do_general_protection
911662: 872662:
912.section .altinstructions,"a" 873.section .altinstructions,"a"
913 .balign 4 874 .balign 4
@@ -922,19 +883,16 @@ ENTRY(simd_coprocessor_error)
922664: 883664:
923.previous 884.previous
924#else 885#else
925 pushl $do_simd_coprocessor_error 886 pushl_cfi $do_simd_coprocessor_error
926#endif 887#endif
927 CFI_ADJUST_CFA_OFFSET 4
928 jmp error_code 888 jmp error_code
929 CFI_ENDPROC 889 CFI_ENDPROC
930END(simd_coprocessor_error) 890END(simd_coprocessor_error)
931 891
932ENTRY(device_not_available) 892ENTRY(device_not_available)
933 RING0_INT_FRAME 893 RING0_INT_FRAME
934 pushl $-1 # mark this as an int 894 pushl_cfi $-1 # mark this as an int
935 CFI_ADJUST_CFA_OFFSET 4 895 pushl_cfi $do_device_not_available
936 pushl $do_device_not_available
937 CFI_ADJUST_CFA_OFFSET 4
938 jmp error_code 896 jmp error_code
939 CFI_ENDPROC 897 CFI_ENDPROC
940END(device_not_available) 898END(device_not_available)
@@ -956,82 +914,68 @@ END(native_irq_enable_sysexit)
956 914
957ENTRY(overflow) 915ENTRY(overflow)
958 RING0_INT_FRAME 916 RING0_INT_FRAME
959 pushl $0 917 pushl_cfi $0
960 CFI_ADJUST_CFA_OFFSET 4 918 pushl_cfi $do_overflow
961 pushl $do_overflow
962 CFI_ADJUST_CFA_OFFSET 4
963 jmp error_code 919 jmp error_code
964 CFI_ENDPROC 920 CFI_ENDPROC
965END(overflow) 921END(overflow)
966 922
967ENTRY(bounds) 923ENTRY(bounds)
968 RING0_INT_FRAME 924 RING0_INT_FRAME
969 pushl $0 925 pushl_cfi $0
970 CFI_ADJUST_CFA_OFFSET 4 926 pushl_cfi $do_bounds
971 pushl $do_bounds
972 CFI_ADJUST_CFA_OFFSET 4
973 jmp error_code 927 jmp error_code
974 CFI_ENDPROC 928 CFI_ENDPROC
975END(bounds) 929END(bounds)
976 930
977ENTRY(invalid_op) 931ENTRY(invalid_op)
978 RING0_INT_FRAME 932 RING0_INT_FRAME
979 pushl $0 933 pushl_cfi $0
980 CFI_ADJUST_CFA_OFFSET 4 934 pushl_cfi $do_invalid_op
981 pushl $do_invalid_op
982 CFI_ADJUST_CFA_OFFSET 4
983 jmp error_code 935 jmp error_code
984 CFI_ENDPROC 936 CFI_ENDPROC
985END(invalid_op) 937END(invalid_op)
986 938
987ENTRY(coprocessor_segment_overrun) 939ENTRY(coprocessor_segment_overrun)
988 RING0_INT_FRAME 940 RING0_INT_FRAME
989 pushl $0 941 pushl_cfi $0
990 CFI_ADJUST_CFA_OFFSET 4 942 pushl_cfi $do_coprocessor_segment_overrun
991 pushl $do_coprocessor_segment_overrun
992 CFI_ADJUST_CFA_OFFSET 4
993 jmp error_code 943 jmp error_code
994 CFI_ENDPROC 944 CFI_ENDPROC
995END(coprocessor_segment_overrun) 945END(coprocessor_segment_overrun)
996 946
997ENTRY(invalid_TSS) 947ENTRY(invalid_TSS)
998 RING0_EC_FRAME 948 RING0_EC_FRAME
999 pushl $do_invalid_TSS 949 pushl_cfi $do_invalid_TSS
1000 CFI_ADJUST_CFA_OFFSET 4
1001 jmp error_code 950 jmp error_code
1002 CFI_ENDPROC 951 CFI_ENDPROC
1003END(invalid_TSS) 952END(invalid_TSS)
1004 953
1005ENTRY(segment_not_present) 954ENTRY(segment_not_present)
1006 RING0_EC_FRAME 955 RING0_EC_FRAME
1007 pushl $do_segment_not_present 956 pushl_cfi $do_segment_not_present
1008 CFI_ADJUST_CFA_OFFSET 4
1009 jmp error_code 957 jmp error_code
1010 CFI_ENDPROC 958 CFI_ENDPROC
1011END(segment_not_present) 959END(segment_not_present)
1012 960
1013ENTRY(stack_segment) 961ENTRY(stack_segment)
1014 RING0_EC_FRAME 962 RING0_EC_FRAME
1015 pushl $do_stack_segment 963 pushl_cfi $do_stack_segment
1016 CFI_ADJUST_CFA_OFFSET 4
1017 jmp error_code 964 jmp error_code
1018 CFI_ENDPROC 965 CFI_ENDPROC
1019END(stack_segment) 966END(stack_segment)
1020 967
1021ENTRY(alignment_check) 968ENTRY(alignment_check)
1022 RING0_EC_FRAME 969 RING0_EC_FRAME
1023 pushl $do_alignment_check 970 pushl_cfi $do_alignment_check
1024 CFI_ADJUST_CFA_OFFSET 4
1025 jmp error_code 971 jmp error_code
1026 CFI_ENDPROC 972 CFI_ENDPROC
1027END(alignment_check) 973END(alignment_check)
1028 974
1029ENTRY(divide_error) 975ENTRY(divide_error)
1030 RING0_INT_FRAME 976 RING0_INT_FRAME
1031 pushl $0 # no error code 977 pushl_cfi $0 # no error code
1032 CFI_ADJUST_CFA_OFFSET 4 978 pushl_cfi $do_divide_error
1033 pushl $do_divide_error
1034 CFI_ADJUST_CFA_OFFSET 4
1035 jmp error_code 979 jmp error_code
1036 CFI_ENDPROC 980 CFI_ENDPROC
1037END(divide_error) 981END(divide_error)
@@ -1039,10 +983,8 @@ END(divide_error)
1039#ifdef CONFIG_X86_MCE 983#ifdef CONFIG_X86_MCE
1040ENTRY(machine_check) 984ENTRY(machine_check)
1041 RING0_INT_FRAME 985 RING0_INT_FRAME
1042 pushl $0 986 pushl_cfi $0
1043 CFI_ADJUST_CFA_OFFSET 4 987 pushl_cfi machine_check_vector
1044 pushl machine_check_vector
1045 CFI_ADJUST_CFA_OFFSET 4
1046 jmp error_code 988 jmp error_code
1047 CFI_ENDPROC 989 CFI_ENDPROC
1048END(machine_check) 990END(machine_check)
@@ -1050,10 +992,8 @@ END(machine_check)
1050 992
1051ENTRY(spurious_interrupt_bug) 993ENTRY(spurious_interrupt_bug)
1052 RING0_INT_FRAME 994 RING0_INT_FRAME
1053 pushl $0 995 pushl_cfi $0
1054 CFI_ADJUST_CFA_OFFSET 4 996 pushl_cfi $do_spurious_interrupt_bug
1055 pushl $do_spurious_interrupt_bug
1056 CFI_ADJUST_CFA_OFFSET 4
1057 jmp error_code 997 jmp error_code
1058 CFI_ENDPROC 998 CFI_ENDPROC
1059END(spurious_interrupt_bug) 999END(spurious_interrupt_bug)
@@ -1084,8 +1024,7 @@ ENTRY(xen_sysenter_target)
1084 1024
1085ENTRY(xen_hypervisor_callback) 1025ENTRY(xen_hypervisor_callback)
1086 CFI_STARTPROC 1026 CFI_STARTPROC
1087 pushl $0 1027 pushl_cfi $0
1088 CFI_ADJUST_CFA_OFFSET 4
1089 SAVE_ALL 1028 SAVE_ALL
1090 TRACE_IRQS_OFF 1029 TRACE_IRQS_OFF
1091 1030
@@ -1121,23 +1060,20 @@ ENDPROC(xen_hypervisor_callback)
1121# We distinguish between categories by maintaining a status value in EAX. 1060# We distinguish between categories by maintaining a status value in EAX.
1122ENTRY(xen_failsafe_callback) 1061ENTRY(xen_failsafe_callback)
1123 CFI_STARTPROC 1062 CFI_STARTPROC
1124 pushl %eax 1063 pushl_cfi %eax
1125 CFI_ADJUST_CFA_OFFSET 4
1126 movl $1,%eax 1064 movl $1,%eax
11271: mov 4(%esp),%ds 10651: mov 4(%esp),%ds
11282: mov 8(%esp),%es 10662: mov 8(%esp),%es
11293: mov 12(%esp),%fs 10673: mov 12(%esp),%fs
11304: mov 16(%esp),%gs 10684: mov 16(%esp),%gs
1131 testl %eax,%eax 1069 testl %eax,%eax
1132 popl %eax 1070 popl_cfi %eax
1133 CFI_ADJUST_CFA_OFFSET -4
1134 lea 16(%esp),%esp 1071 lea 16(%esp),%esp
1135 CFI_ADJUST_CFA_OFFSET -16 1072 CFI_ADJUST_CFA_OFFSET -16
1136 jz 5f 1073 jz 5f
1137 addl $16,%esp 1074 addl $16,%esp
1138 jmp iret_exc # EAX != 0 => Category 2 (Bad IRET) 1075 jmp iret_exc # EAX != 0 => Category 2 (Bad IRET)
11395: pushl $0 # EAX == 0 => Category 1 (Bad segment) 10765: pushl_cfi $0 # EAX == 0 => Category 1 (Bad segment)
1140 CFI_ADJUST_CFA_OFFSET 4
1141 SAVE_ALL 1077 SAVE_ALL
1142 jmp ret_from_exception 1078 jmp ret_from_exception
1143 CFI_ENDPROC 1079 CFI_ENDPROC
@@ -1287,40 +1223,29 @@ syscall_table_size=(.-sys_call_table)
1287 1223
1288ENTRY(page_fault) 1224ENTRY(page_fault)
1289 RING0_EC_FRAME 1225 RING0_EC_FRAME
1290 pushl $do_page_fault 1226 pushl_cfi $do_page_fault
1291 CFI_ADJUST_CFA_OFFSET 4
1292 ALIGN 1227 ALIGN
1293error_code: 1228error_code:
1294 /* the function address is in %gs's slot on the stack */ 1229 /* the function address is in %gs's slot on the stack */
1295 pushl %fs 1230 pushl_cfi %fs
1296 CFI_ADJUST_CFA_OFFSET 4
1297 /*CFI_REL_OFFSET fs, 0*/ 1231 /*CFI_REL_OFFSET fs, 0*/
1298 pushl %es 1232 pushl_cfi %es
1299 CFI_ADJUST_CFA_OFFSET 4
1300 /*CFI_REL_OFFSET es, 0*/ 1233 /*CFI_REL_OFFSET es, 0*/
1301 pushl %ds 1234 pushl_cfi %ds
1302 CFI_ADJUST_CFA_OFFSET 4
1303 /*CFI_REL_OFFSET ds, 0*/ 1235 /*CFI_REL_OFFSET ds, 0*/
1304 pushl %eax 1236 pushl_cfi %eax
1305 CFI_ADJUST_CFA_OFFSET 4
1306 CFI_REL_OFFSET eax, 0 1237 CFI_REL_OFFSET eax, 0
1307 pushl %ebp 1238 pushl_cfi %ebp
1308 CFI_ADJUST_CFA_OFFSET 4
1309 CFI_REL_OFFSET ebp, 0 1239 CFI_REL_OFFSET ebp, 0
1310 pushl %edi 1240 pushl_cfi %edi
1311 CFI_ADJUST_CFA_OFFSET 4
1312 CFI_REL_OFFSET edi, 0 1241 CFI_REL_OFFSET edi, 0
1313 pushl %esi 1242 pushl_cfi %esi
1314 CFI_ADJUST_CFA_OFFSET 4
1315 CFI_REL_OFFSET esi, 0 1243 CFI_REL_OFFSET esi, 0
1316 pushl %edx 1244 pushl_cfi %edx
1317 CFI_ADJUST_CFA_OFFSET 4
1318 CFI_REL_OFFSET edx, 0 1245 CFI_REL_OFFSET edx, 0
1319 pushl %ecx 1246 pushl_cfi %ecx
1320 CFI_ADJUST_CFA_OFFSET 4
1321 CFI_REL_OFFSET ecx, 0 1247 CFI_REL_OFFSET ecx, 0
1322 pushl %ebx 1248 pushl_cfi %ebx
1323 CFI_ADJUST_CFA_OFFSET 4
1324 CFI_REL_OFFSET ebx, 0 1249 CFI_REL_OFFSET ebx, 0
1325 cld 1250 cld
1326 movl $(__KERNEL_PERCPU), %ecx 1251 movl $(__KERNEL_PERCPU), %ecx
@@ -1362,12 +1287,9 @@ END(page_fault)
1362 movl TSS_sysenter_sp0 + \offset(%esp), %esp 1287 movl TSS_sysenter_sp0 + \offset(%esp), %esp
1363 CFI_DEF_CFA esp, 0 1288 CFI_DEF_CFA esp, 0
1364 CFI_UNDEFINED eip 1289 CFI_UNDEFINED eip
1365 pushfl 1290 pushfl_cfi
1366 CFI_ADJUST_CFA_OFFSET 4 1291 pushl_cfi $__KERNEL_CS
1367 pushl $__KERNEL_CS 1292 pushl_cfi $sysenter_past_esp
1368 CFI_ADJUST_CFA_OFFSET 4
1369 pushl $sysenter_past_esp
1370 CFI_ADJUST_CFA_OFFSET 4
1371 CFI_REL_OFFSET eip, 0 1293 CFI_REL_OFFSET eip, 0
1372.endm 1294.endm
1373 1295
@@ -1377,8 +1299,7 @@ ENTRY(debug)
1377 jne debug_stack_correct 1299 jne debug_stack_correct
1378 FIX_STACK 12, debug_stack_correct, debug_esp_fix_insn 1300 FIX_STACK 12, debug_stack_correct, debug_esp_fix_insn
1379debug_stack_correct: 1301debug_stack_correct:
1380 pushl $-1 # mark this as an int 1302 pushl_cfi $-1 # mark this as an int
1381 CFI_ADJUST_CFA_OFFSET 4
1382 SAVE_ALL 1303 SAVE_ALL
1383 TRACE_IRQS_OFF 1304 TRACE_IRQS_OFF
1384 xorl %edx,%edx # error code 0 1305 xorl %edx,%edx # error code 0
@@ -1398,32 +1319,27 @@ END(debug)
1398 */ 1319 */
1399ENTRY(nmi) 1320ENTRY(nmi)
1400 RING0_INT_FRAME 1321 RING0_INT_FRAME
1401 pushl %eax 1322 pushl_cfi %eax
1402 CFI_ADJUST_CFA_OFFSET 4
1403 movl %ss, %eax 1323 movl %ss, %eax
1404 cmpw $__ESPFIX_SS, %ax 1324 cmpw $__ESPFIX_SS, %ax
1405 popl %eax 1325 popl_cfi %eax
1406 CFI_ADJUST_CFA_OFFSET -4
1407 je nmi_espfix_stack 1326 je nmi_espfix_stack
1408 cmpl $ia32_sysenter_target,(%esp) 1327 cmpl $ia32_sysenter_target,(%esp)
1409 je nmi_stack_fixup 1328 je nmi_stack_fixup
1410 pushl %eax 1329 pushl_cfi %eax
1411 CFI_ADJUST_CFA_OFFSET 4
1412 movl %esp,%eax 1330 movl %esp,%eax
1413 /* Do not access memory above the end of our stack page, 1331 /* Do not access memory above the end of our stack page,
1414 * it might not exist. 1332 * it might not exist.
1415 */ 1333 */
1416 andl $(THREAD_SIZE-1),%eax 1334 andl $(THREAD_SIZE-1),%eax
1417 cmpl $(THREAD_SIZE-20),%eax 1335 cmpl $(THREAD_SIZE-20),%eax
1418 popl %eax 1336 popl_cfi %eax
1419 CFI_ADJUST_CFA_OFFSET -4
1420 jae nmi_stack_correct 1337 jae nmi_stack_correct
1421 cmpl $ia32_sysenter_target,12(%esp) 1338 cmpl $ia32_sysenter_target,12(%esp)
1422 je nmi_debug_stack_check 1339 je nmi_debug_stack_check
1423nmi_stack_correct: 1340nmi_stack_correct:
1424 /* We have a RING0_INT_FRAME here */ 1341 /* We have a RING0_INT_FRAME here */
1425 pushl %eax 1342 pushl_cfi %eax
1426 CFI_ADJUST_CFA_OFFSET 4
1427 SAVE_ALL 1343 SAVE_ALL
1428 xorl %edx,%edx # zero error code 1344 xorl %edx,%edx # zero error code
1429 movl %esp,%eax # pt_regs pointer 1345 movl %esp,%eax # pt_regs pointer
@@ -1452,18 +1368,14 @@ nmi_espfix_stack:
1452 * 1368 *
1453 * create the pointer to lss back 1369 * create the pointer to lss back
1454 */ 1370 */
1455 pushl %ss 1371 pushl_cfi %ss
1456 CFI_ADJUST_CFA_OFFSET 4 1372 pushl_cfi %esp
1457 pushl %esp
1458 CFI_ADJUST_CFA_OFFSET 4
1459 addl $4, (%esp) 1373 addl $4, (%esp)
1460 /* copy the iret frame of 12 bytes */ 1374 /* copy the iret frame of 12 bytes */
1461 .rept 3 1375 .rept 3
1462 pushl 16(%esp) 1376 pushl_cfi 16(%esp)
1463 CFI_ADJUST_CFA_OFFSET 4
1464 .endr 1377 .endr
1465 pushl %eax 1378 pushl_cfi %eax
1466 CFI_ADJUST_CFA_OFFSET 4
1467 SAVE_ALL 1379 SAVE_ALL
1468 FIXUP_ESPFIX_STACK # %eax == %esp 1380 FIXUP_ESPFIX_STACK # %eax == %esp
1469 xorl %edx,%edx # zero error code 1381 xorl %edx,%edx # zero error code
@@ -1477,8 +1389,7 @@ END(nmi)
1477 1389
1478ENTRY(int3) 1390ENTRY(int3)
1479 RING0_INT_FRAME 1391 RING0_INT_FRAME
1480 pushl $-1 # mark this as an int 1392 pushl_cfi $-1 # mark this as an int
1481 CFI_ADJUST_CFA_OFFSET 4
1482 SAVE_ALL 1393 SAVE_ALL
1483 TRACE_IRQS_OFF 1394 TRACE_IRQS_OFF
1484 xorl %edx,%edx # zero error code 1395 xorl %edx,%edx # zero error code
@@ -1490,8 +1401,7 @@ END(int3)
1490 1401
1491ENTRY(general_protection) 1402ENTRY(general_protection)
1492 RING0_EC_FRAME 1403 RING0_EC_FRAME
1493 pushl $do_general_protection 1404 pushl_cfi $do_general_protection
1494 CFI_ADJUST_CFA_OFFSET 4
1495 jmp error_code 1405 jmp error_code
1496 CFI_ENDPROC 1406 CFI_ENDPROC
1497END(general_protection) 1407END(general_protection)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 17be5ec7cbba..fe2690d71c0c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -213,23 +213,17 @@ ENDPROC(native_usergs_sysret64)
213 .macro FAKE_STACK_FRAME child_rip 213 .macro FAKE_STACK_FRAME child_rip
214 /* push in order ss, rsp, eflags, cs, rip */ 214 /* push in order ss, rsp, eflags, cs, rip */
215 xorl %eax, %eax 215 xorl %eax, %eax
216 pushq $__KERNEL_DS /* ss */ 216 pushq_cfi $__KERNEL_DS /* ss */
217 CFI_ADJUST_CFA_OFFSET 8
218 /*CFI_REL_OFFSET ss,0*/ 217 /*CFI_REL_OFFSET ss,0*/
219 pushq %rax /* rsp */ 218 pushq_cfi %rax /* rsp */
220 CFI_ADJUST_CFA_OFFSET 8
221 CFI_REL_OFFSET rsp,0 219 CFI_REL_OFFSET rsp,0
222 pushq $X86_EFLAGS_IF /* eflags - interrupts on */ 220 pushq_cfi $X86_EFLAGS_IF /* eflags - interrupts on */
223 CFI_ADJUST_CFA_OFFSET 8
224 /*CFI_REL_OFFSET rflags,0*/ 221 /*CFI_REL_OFFSET rflags,0*/
225 pushq $__KERNEL_CS /* cs */ 222 pushq_cfi $__KERNEL_CS /* cs */
226 CFI_ADJUST_CFA_OFFSET 8
227 /*CFI_REL_OFFSET cs,0*/ 223 /*CFI_REL_OFFSET cs,0*/
228 pushq \child_rip /* rip */ 224 pushq_cfi \child_rip /* rip */
229 CFI_ADJUST_CFA_OFFSET 8
230 CFI_REL_OFFSET rip,0 225 CFI_REL_OFFSET rip,0
231 pushq %rax /* orig rax */ 226 pushq_cfi %rax /* orig rax */
232 CFI_ADJUST_CFA_OFFSET 8
233 .endm 227 .endm
234 228
235 .macro UNFAKE_STACK_FRAME 229 .macro UNFAKE_STACK_FRAME
@@ -398,10 +392,8 @@ ENTRY(ret_from_fork)
398 392
399 LOCK ; btr $TIF_FORK,TI_flags(%r8) 393 LOCK ; btr $TIF_FORK,TI_flags(%r8)
400 394
401 push kernel_eflags(%rip) 395 pushq_cfi kernel_eflags(%rip)
402 CFI_ADJUST_CFA_OFFSET 8 396 popfq_cfi # reset kernel eflags
403 popf # reset kernel eflags
404 CFI_ADJUST_CFA_OFFSET -8
405 397
406 call schedule_tail # rdi: 'prev' task parameter 398 call schedule_tail # rdi: 'prev' task parameter
407 399
@@ -521,11 +513,9 @@ sysret_careful:
521 jnc sysret_signal 513 jnc sysret_signal
522 TRACE_IRQS_ON 514 TRACE_IRQS_ON
523 ENABLE_INTERRUPTS(CLBR_NONE) 515 ENABLE_INTERRUPTS(CLBR_NONE)
524 pushq %rdi 516 pushq_cfi %rdi
525 CFI_ADJUST_CFA_OFFSET 8
526 call schedule 517 call schedule
527 popq %rdi 518 popq_cfi %rdi
528 CFI_ADJUST_CFA_OFFSET -8
529 jmp sysret_check 519 jmp sysret_check
530 520
531 /* Handle a signal */ 521 /* Handle a signal */
@@ -634,11 +624,9 @@ int_careful:
634 jnc int_very_careful 624 jnc int_very_careful
635 TRACE_IRQS_ON 625 TRACE_IRQS_ON
636 ENABLE_INTERRUPTS(CLBR_NONE) 626 ENABLE_INTERRUPTS(CLBR_NONE)
637 pushq %rdi 627 pushq_cfi %rdi
638 CFI_ADJUST_CFA_OFFSET 8
639 call schedule 628 call schedule
640 popq %rdi 629 popq_cfi %rdi
641 CFI_ADJUST_CFA_OFFSET -8
642 DISABLE_INTERRUPTS(CLBR_NONE) 630 DISABLE_INTERRUPTS(CLBR_NONE)
643 TRACE_IRQS_OFF 631 TRACE_IRQS_OFF
644 jmp int_with_check 632 jmp int_with_check
@@ -652,12 +640,10 @@ int_check_syscall_exit_work:
652 /* Check for syscall exit trace */ 640 /* Check for syscall exit trace */
653 testl $_TIF_WORK_SYSCALL_EXIT,%edx 641 testl $_TIF_WORK_SYSCALL_EXIT,%edx
654 jz int_signal 642 jz int_signal
655 pushq %rdi 643 pushq_cfi %rdi
656 CFI_ADJUST_CFA_OFFSET 8
657 leaq 8(%rsp),%rdi # &ptregs -> arg1 644 leaq 8(%rsp),%rdi # &ptregs -> arg1
658 call syscall_trace_leave 645 call syscall_trace_leave
659 popq %rdi 646 popq_cfi %rdi
660 CFI_ADJUST_CFA_OFFSET -8
661 andl $~(_TIF_WORK_SYSCALL_EXIT|_TIF_SYSCALL_EMU),%edi 647 andl $~(_TIF_WORK_SYSCALL_EXIT|_TIF_SYSCALL_EMU),%edi
662 jmp int_restore_rest 648 jmp int_restore_rest
663 649
@@ -714,9 +700,8 @@ END(ptregscall_common)
714 700
715ENTRY(stub_execve) 701ENTRY(stub_execve)
716 CFI_STARTPROC 702 CFI_STARTPROC
717 popq %r11 703 addq $8, %rsp
718 CFI_ADJUST_CFA_OFFSET -8 704 PARTIAL_FRAME 0
719 CFI_REGISTER rip, r11
720 SAVE_REST 705 SAVE_REST
721 FIXUP_TOP_OF_STACK %r11 706 FIXUP_TOP_OF_STACK %r11
722 movq %rsp, %rcx 707 movq %rsp, %rcx
@@ -735,7 +720,7 @@ END(stub_execve)
735ENTRY(stub_rt_sigreturn) 720ENTRY(stub_rt_sigreturn)
736 CFI_STARTPROC 721 CFI_STARTPROC
737 addq $8, %rsp 722 addq $8, %rsp
738 CFI_ADJUST_CFA_OFFSET -8 723 PARTIAL_FRAME 0
739 SAVE_REST 724 SAVE_REST
740 movq %rsp,%rdi 725 movq %rsp,%rdi
741 FIXUP_TOP_OF_STACK %r11 726 FIXUP_TOP_OF_STACK %r11
@@ -766,8 +751,7 @@ vector=FIRST_EXTERNAL_VECTOR
766 .if vector <> FIRST_EXTERNAL_VECTOR 751 .if vector <> FIRST_EXTERNAL_VECTOR
767 CFI_ADJUST_CFA_OFFSET -8 752 CFI_ADJUST_CFA_OFFSET -8
768 .endif 753 .endif
7691: pushq $(~vector+0x80) /* Note: always in signed byte range */ 7541: pushq_cfi $(~vector+0x80) /* Note: always in signed byte range */
770 CFI_ADJUST_CFA_OFFSET 8
771 .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6 755 .if ((vector-FIRST_EXTERNAL_VECTOR)%7) <> 6
772 jmp 2f 756 jmp 2f
773 .endif 757 .endif
@@ -796,8 +780,8 @@ END(interrupt)
796 780
797/* 0(%rsp): ~(interrupt number) */ 781/* 0(%rsp): ~(interrupt number) */
798 .macro interrupt func 782 .macro interrupt func
799 subq $10*8, %rsp 783 subq $ORIG_RAX-ARGOFFSET+8, %rsp
800 CFI_ADJUST_CFA_OFFSET 10*8 784 CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+8
801 call save_args 785 call save_args
802 PARTIAL_FRAME 0 786 PARTIAL_FRAME 0
803 call \func 787 call \func
@@ -822,6 +806,7 @@ ret_from_intr:
822 TRACE_IRQS_OFF 806 TRACE_IRQS_OFF
823 decl PER_CPU_VAR(irq_count) 807 decl PER_CPU_VAR(irq_count)
824 leaveq 808 leaveq
809 CFI_RESTORE rbp
825 CFI_DEF_CFA_REGISTER rsp 810 CFI_DEF_CFA_REGISTER rsp
826 CFI_ADJUST_CFA_OFFSET -8 811 CFI_ADJUST_CFA_OFFSET -8
827exit_intr: 812exit_intr:
@@ -903,11 +888,9 @@ retint_careful:
903 jnc retint_signal 888 jnc retint_signal
904 TRACE_IRQS_ON 889 TRACE_IRQS_ON
905 ENABLE_INTERRUPTS(CLBR_NONE) 890 ENABLE_INTERRUPTS(CLBR_NONE)
906 pushq %rdi 891 pushq_cfi %rdi
907 CFI_ADJUST_CFA_OFFSET 8
908 call schedule 892 call schedule
909 popq %rdi 893 popq_cfi %rdi
910 CFI_ADJUST_CFA_OFFSET -8
911 GET_THREAD_INFO(%rcx) 894 GET_THREAD_INFO(%rcx)
912 DISABLE_INTERRUPTS(CLBR_NONE) 895 DISABLE_INTERRUPTS(CLBR_NONE)
913 TRACE_IRQS_OFF 896 TRACE_IRQS_OFF
@@ -956,8 +939,7 @@ END(common_interrupt)
956.macro apicinterrupt num sym do_sym 939.macro apicinterrupt num sym do_sym
957ENTRY(\sym) 940ENTRY(\sym)
958 INTR_FRAME 941 INTR_FRAME
959 pushq $~(\num) 942 pushq_cfi $~(\num)
960 CFI_ADJUST_CFA_OFFSET 8
961 interrupt \do_sym 943 interrupt \do_sym
962 jmp ret_from_intr 944 jmp ret_from_intr
963 CFI_ENDPROC 945 CFI_ENDPROC
@@ -981,22 +963,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
981 x86_platform_ipi smp_x86_platform_ipi 963 x86_platform_ipi smp_x86_platform_ipi
982 964
983#ifdef CONFIG_SMP 965#ifdef CONFIG_SMP
984apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \ 966.irpc idx, "01234567"
985 invalidate_interrupt0 smp_invalidate_interrupt 967apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
986apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \ 968 invalidate_interrupt\idx smp_invalidate_interrupt
987 invalidate_interrupt1 smp_invalidate_interrupt 969.endr
988apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \
989 invalidate_interrupt2 smp_invalidate_interrupt
990apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \
991 invalidate_interrupt3 smp_invalidate_interrupt
992apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \
993 invalidate_interrupt4 smp_invalidate_interrupt
994apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \
995 invalidate_interrupt5 smp_invalidate_interrupt
996apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \
997 invalidate_interrupt6 smp_invalidate_interrupt
998apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \
999 invalidate_interrupt7 smp_invalidate_interrupt
1000#endif 970#endif
1001 971
1002apicinterrupt THRESHOLD_APIC_VECTOR \ 972apicinterrupt THRESHOLD_APIC_VECTOR \
@@ -1023,9 +993,9 @@ apicinterrupt ERROR_APIC_VECTOR \
1023apicinterrupt SPURIOUS_APIC_VECTOR \ 993apicinterrupt SPURIOUS_APIC_VECTOR \
1024 spurious_interrupt smp_spurious_interrupt 994 spurious_interrupt smp_spurious_interrupt
1025 995
1026#ifdef CONFIG_PERF_EVENTS 996#ifdef CONFIG_IRQ_WORK
1027apicinterrupt LOCAL_PENDING_VECTOR \ 997apicinterrupt IRQ_WORK_VECTOR \
1028 perf_pending_interrupt smp_perf_pending_interrupt 998 irq_work_interrupt smp_irq_work_interrupt
1029#endif 999#endif
1030 1000
1031/* 1001/*
@@ -1036,8 +1006,8 @@ ENTRY(\sym)
1036 INTR_FRAME 1006 INTR_FRAME
1037 PARAVIRT_ADJUST_EXCEPTION_FRAME 1007 PARAVIRT_ADJUST_EXCEPTION_FRAME
1038 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1008 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1039 subq $15*8,%rsp 1009 subq $ORIG_RAX-R15, %rsp
1040 CFI_ADJUST_CFA_OFFSET 15*8 1010 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1041 call error_entry 1011 call error_entry
1042 DEFAULT_FRAME 0 1012 DEFAULT_FRAME 0
1043 movq %rsp,%rdi /* pt_regs pointer */ 1013 movq %rsp,%rdi /* pt_regs pointer */
@@ -1052,9 +1022,9 @@ END(\sym)
1052ENTRY(\sym) 1022ENTRY(\sym)
1053 INTR_FRAME 1023 INTR_FRAME
1054 PARAVIRT_ADJUST_EXCEPTION_FRAME 1024 PARAVIRT_ADJUST_EXCEPTION_FRAME
1055 pushq $-1 /* ORIG_RAX: no syscall to restart */ 1025 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1056 CFI_ADJUST_CFA_OFFSET 8 1026 subq $ORIG_RAX-R15, %rsp
1057 subq $15*8, %rsp 1027 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1058 call save_paranoid 1028 call save_paranoid
1059 TRACE_IRQS_OFF 1029 TRACE_IRQS_OFF
1060 movq %rsp,%rdi /* pt_regs pointer */ 1030 movq %rsp,%rdi /* pt_regs pointer */
@@ -1070,9 +1040,9 @@ END(\sym)
1070ENTRY(\sym) 1040ENTRY(\sym)
1071 INTR_FRAME 1041 INTR_FRAME
1072 PARAVIRT_ADJUST_EXCEPTION_FRAME 1042 PARAVIRT_ADJUST_EXCEPTION_FRAME
1073 pushq $-1 /* ORIG_RAX: no syscall to restart */ 1043 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1074 CFI_ADJUST_CFA_OFFSET 8 1044 subq $ORIG_RAX-R15, %rsp
1075 subq $15*8, %rsp 1045 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1076 call save_paranoid 1046 call save_paranoid
1077 TRACE_IRQS_OFF 1047 TRACE_IRQS_OFF
1078 movq %rsp,%rdi /* pt_regs pointer */ 1048 movq %rsp,%rdi /* pt_regs pointer */
@@ -1089,8 +1059,8 @@ END(\sym)
1089ENTRY(\sym) 1059ENTRY(\sym)
1090 XCPT_FRAME 1060 XCPT_FRAME
1091 PARAVIRT_ADJUST_EXCEPTION_FRAME 1061 PARAVIRT_ADJUST_EXCEPTION_FRAME
1092 subq $15*8,%rsp 1062 subq $ORIG_RAX-R15, %rsp
1093 CFI_ADJUST_CFA_OFFSET 15*8 1063 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1094 call error_entry 1064 call error_entry
1095 DEFAULT_FRAME 0 1065 DEFAULT_FRAME 0
1096 movq %rsp,%rdi /* pt_regs pointer */ 1066 movq %rsp,%rdi /* pt_regs pointer */
@@ -1107,8 +1077,8 @@ END(\sym)
1107ENTRY(\sym) 1077ENTRY(\sym)
1108 XCPT_FRAME 1078 XCPT_FRAME
1109 PARAVIRT_ADJUST_EXCEPTION_FRAME 1079 PARAVIRT_ADJUST_EXCEPTION_FRAME
1110 subq $15*8,%rsp 1080 subq $ORIG_RAX-R15, %rsp
1111 CFI_ADJUST_CFA_OFFSET 15*8 1081 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1112 call save_paranoid 1082 call save_paranoid
1113 DEFAULT_FRAME 0 1083 DEFAULT_FRAME 0
1114 TRACE_IRQS_OFF 1084 TRACE_IRQS_OFF
@@ -1139,16 +1109,14 @@ zeroentry simd_coprocessor_error do_simd_coprocessor_error
1139 /* edi: new selector */ 1109 /* edi: new selector */
1140ENTRY(native_load_gs_index) 1110ENTRY(native_load_gs_index)
1141 CFI_STARTPROC 1111 CFI_STARTPROC
1142 pushf 1112 pushfq_cfi
1143 CFI_ADJUST_CFA_OFFSET 8
1144 DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI) 1113 DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
1145 SWAPGS 1114 SWAPGS
1146gs_change: 1115gs_change:
1147 movl %edi,%gs 1116 movl %edi,%gs
11482: mfence /* workaround */ 11172: mfence /* workaround */
1149 SWAPGS 1118 SWAPGS
1150 popf 1119 popfq_cfi
1151 CFI_ADJUST_CFA_OFFSET -8
1152 ret 1120 ret
1153 CFI_ENDPROC 1121 CFI_ENDPROC
1154END(native_load_gs_index) 1122END(native_load_gs_index)
@@ -1215,8 +1183,7 @@ END(kernel_execve)
1215/* Call softirq on interrupt stack. Interrupts are off. */ 1183/* Call softirq on interrupt stack. Interrupts are off. */
1216ENTRY(call_softirq) 1184ENTRY(call_softirq)
1217 CFI_STARTPROC 1185 CFI_STARTPROC
1218 push %rbp 1186 pushq_cfi %rbp
1219 CFI_ADJUST_CFA_OFFSET 8
1220 CFI_REL_OFFSET rbp,0 1187 CFI_REL_OFFSET rbp,0
1221 mov %rsp,%rbp 1188 mov %rsp,%rbp
1222 CFI_DEF_CFA_REGISTER rbp 1189 CFI_DEF_CFA_REGISTER rbp
@@ -1225,6 +1192,7 @@ ENTRY(call_softirq)
1225 push %rbp # backlink for old unwinder 1192 push %rbp # backlink for old unwinder
1226 call __do_softirq 1193 call __do_softirq
1227 leaveq 1194 leaveq
1195 CFI_RESTORE rbp
1228 CFI_DEF_CFA_REGISTER rsp 1196 CFI_DEF_CFA_REGISTER rsp
1229 CFI_ADJUST_CFA_OFFSET -8 1197 CFI_ADJUST_CFA_OFFSET -8
1230 decl PER_CPU_VAR(irq_count) 1198 decl PER_CPU_VAR(irq_count)
@@ -1368,7 +1336,7 @@ paranoidzeroentry machine_check *machine_check_vector(%rip)
1368 1336
1369 /* ebx: no swapgs flag */ 1337 /* ebx: no swapgs flag */
1370ENTRY(paranoid_exit) 1338ENTRY(paranoid_exit)
1371 INTR_FRAME 1339 DEFAULT_FRAME
1372 DISABLE_INTERRUPTS(CLBR_NONE) 1340 DISABLE_INTERRUPTS(CLBR_NONE)
1373 TRACE_IRQS_OFF 1341 TRACE_IRQS_OFF
1374 testl %ebx,%ebx /* swapgs needed? */ 1342 testl %ebx,%ebx /* swapgs needed? */
@@ -1445,7 +1413,6 @@ error_swapgs:
1445error_sti: 1413error_sti:
1446 TRACE_IRQS_OFF 1414 TRACE_IRQS_OFF
1447 ret 1415 ret
1448 CFI_ENDPROC
1449 1416
1450/* 1417/*
1451 * There are two places in the kernel that can potentially fault with 1418 * There are two places in the kernel that can potentially fault with
@@ -1470,6 +1437,7 @@ bstep_iret:
1470 /* Fix truncated RIP */ 1437 /* Fix truncated RIP */
1471 movq %rcx,RIP+8(%rsp) 1438 movq %rcx,RIP+8(%rsp)
1472 jmp error_swapgs 1439 jmp error_swapgs
1440 CFI_ENDPROC
1473END(error_entry) 1441END(error_entry)
1474 1442
1475 1443
@@ -1498,8 +1466,8 @@ ENTRY(nmi)
1498 INTR_FRAME 1466 INTR_FRAME
1499 PARAVIRT_ADJUST_EXCEPTION_FRAME 1467 PARAVIRT_ADJUST_EXCEPTION_FRAME
1500 pushq_cfi $-1 1468 pushq_cfi $-1
1501 subq $15*8, %rsp 1469 subq $ORIG_RAX-R15, %rsp
1502 CFI_ADJUST_CFA_OFFSET 15*8 1470 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
1503 call save_paranoid 1471 call save_paranoid
1504 DEFAULT_FRAME 0 1472 DEFAULT_FRAME 0
1505 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */ 1473 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index cd37469b54ee..3afb33f14d2d 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -257,14 +257,9 @@ do_ftrace_mod_code(unsigned long ip, void *new_code)
257 return mod_code_status; 257 return mod_code_status;
258} 258}
259 259
260
261
262
263static unsigned char ftrace_nop[MCOUNT_INSN_SIZE];
264
265static unsigned char *ftrace_nop_replace(void) 260static unsigned char *ftrace_nop_replace(void)
266{ 261{
267 return ftrace_nop; 262 return ideal_nop5;
268} 263}
269 264
270static int 265static int
@@ -338,62 +333,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
338 333
339int __init ftrace_dyn_arch_init(void *data) 334int __init ftrace_dyn_arch_init(void *data)
340{ 335{
341 extern const unsigned char ftrace_test_p6nop[];
342 extern const unsigned char ftrace_test_nop5[];
343 extern const unsigned char ftrace_test_jmp[];
344 int faulted = 0;
345
346 /*
347 * There is no good nop for all x86 archs.
348 * We will default to using the P6_NOP5, but first we
349 * will test to make sure that the nop will actually
350 * work on this CPU. If it faults, we will then
351 * go to a lesser efficient 5 byte nop. If that fails
352 * we then just use a jmp as our nop. This isn't the most
353 * efficient nop, but we can not use a multi part nop
354 * since we would then risk being preempted in the middle
355 * of that nop, and if we enabled tracing then, it might
356 * cause a system crash.
357 *
358 * TODO: check the cpuid to determine the best nop.
359 */
360 asm volatile (
361 "ftrace_test_jmp:"
362 "jmp ftrace_test_p6nop\n"
363 "nop\n"
364 "nop\n"
365 "nop\n" /* 2 byte jmp + 3 bytes */
366 "ftrace_test_p6nop:"
367 P6_NOP5
368 "jmp 1f\n"
369 "ftrace_test_nop5:"
370 ".byte 0x66,0x66,0x66,0x66,0x90\n"
371 "1:"
372 ".section .fixup, \"ax\"\n"
373 "2: movl $1, %0\n"
374 " jmp ftrace_test_nop5\n"
375 "3: movl $2, %0\n"
376 " jmp 1b\n"
377 ".previous\n"
378 _ASM_EXTABLE(ftrace_test_p6nop, 2b)
379 _ASM_EXTABLE(ftrace_test_nop5, 3b)
380 : "=r"(faulted) : "0" (faulted));
381
382 switch (faulted) {
383 case 0:
384 pr_info("converting mcount calls to 0f 1f 44 00 00\n");
385 memcpy(ftrace_nop, ftrace_test_p6nop, MCOUNT_INSN_SIZE);
386 break;
387 case 1:
388 pr_info("converting mcount calls to 66 66 66 66 90\n");
389 memcpy(ftrace_nop, ftrace_test_nop5, MCOUNT_INSN_SIZE);
390 break;
391 case 2:
392 pr_info("converting mcount calls to jmp . + 5\n");
393 memcpy(ftrace_nop, ftrace_test_jmp, MCOUNT_INSN_SIZE);
394 break;
395 }
396
397 /* The return code is retured via data */ 336 /* The return code is retured via data */
398 *(unsigned long *)data = 0; 337 *(unsigned long *)data = 0;
399 338
diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c
index 3e66bd364a9d..af0699ba48cf 100644
--- a/arch/x86/kernel/head.c
+++ b/arch/x86/kernel/head.c
@@ -1,5 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/init.h> 2#include <linux/init.h>
3#include <linux/memblock.h>
3 4
4#include <asm/setup.h> 5#include <asm/setup.h>
5#include <asm/bios_ebda.h> 6#include <asm/bios_ebda.h>
@@ -51,5 +52,5 @@ void __init reserve_ebda_region(void)
51 lowmem = 0x9f000; 52 lowmem = 0x9f000;
52 53
53 /* reserve all memory between lowmem and the 1MB mark */ 54 /* reserve all memory between lowmem and the 1MB mark */
54 reserve_early_overlap_ok(lowmem, 0x100000, "BIOS reserved"); 55 memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved");
55} 56}
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 784360c0625c..763310165fa0 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -8,6 +8,7 @@
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/start_kernel.h> 9#include <linux/start_kernel.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/memblock.h>
11 12
12#include <asm/setup.h> 13#include <asm/setup.h>
13#include <asm/sections.h> 14#include <asm/sections.h>
@@ -17,6 +18,7 @@
17#include <asm/apic.h> 18#include <asm/apic.h>
18#include <asm/io_apic.h> 19#include <asm/io_apic.h>
19#include <asm/bios_ebda.h> 20#include <asm/bios_ebda.h>
21#include <asm/tlbflush.h>
20 22
21static void __init i386_default_early_setup(void) 23static void __init i386_default_early_setup(void)
22{ 24{
@@ -30,17 +32,18 @@ static void __init i386_default_early_setup(void)
30 32
31void __init i386_start_kernel(void) 33void __init i386_start_kernel(void)
32{ 34{
35 memblock_init();
36
33#ifdef CONFIG_X86_TRAMPOLINE 37#ifdef CONFIG_X86_TRAMPOLINE
34 /* 38 /*
35 * But first pinch a few for the stack/trampoline stuff 39 * But first pinch a few for the stack/trampoline stuff
36 * FIXME: Don't need the extra page at 4K, but need to fix 40 * FIXME: Don't need the extra page at 4K, but need to fix
37 * trampoline before removing it. (see the GDT stuff) 41 * trampoline before removing it. (see the GDT stuff)
38 */ 42 */
39 reserve_early_overlap_ok(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, 43 memblock_x86_reserve_range(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
40 "EX TRAMPOLINE");
41#endif 44#endif
42 45
43 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); 46 memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
44 47
45#ifdef CONFIG_BLK_DEV_INITRD 48#ifdef CONFIG_BLK_DEV_INITRD
46 /* Reserve INITRD */ 49 /* Reserve INITRD */
@@ -49,7 +52,7 @@ void __init i386_start_kernel(void)
49 u64 ramdisk_image = boot_params.hdr.ramdisk_image; 52 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
50 u64 ramdisk_size = boot_params.hdr.ramdisk_size; 53 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
51 u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); 54 u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
52 reserve_early(ramdisk_image, ramdisk_end, "RAMDISK"); 55 memblock_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
53 } 56 }
54#endif 57#endif
55 58
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 7147143fd614..2d2673c28aff 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -12,6 +12,7 @@
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/start_kernel.h> 13#include <linux/start_kernel.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/memblock.h>
15 16
16#include <asm/processor.h> 17#include <asm/processor.h>
17#include <asm/proto.h> 18#include <asm/proto.h>
@@ -79,6 +80,8 @@ void __init x86_64_start_kernel(char * real_mode_data)
79 /* Cleanup the over mapped high alias */ 80 /* Cleanup the over mapped high alias */
80 cleanup_highmap(); 81 cleanup_highmap();
81 82
83 max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
84
82 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) { 85 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
83#ifdef CONFIG_EARLY_PRINTK 86#ifdef CONFIG_EARLY_PRINTK
84 set_intr_gate(i, &early_idt_handlers[i]); 87 set_intr_gate(i, &early_idt_handlers[i]);
@@ -98,7 +101,9 @@ void __init x86_64_start_reservations(char *real_mode_data)
98{ 101{
99 copy_bootdata(__va(real_mode_data)); 102 copy_bootdata(__va(real_mode_data));
100 103
101 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); 104 memblock_init();
105
106 memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
102 107
103#ifdef CONFIG_BLK_DEV_INITRD 108#ifdef CONFIG_BLK_DEV_INITRD
104 /* Reserve INITRD */ 109 /* Reserve INITRD */
@@ -107,7 +112,7 @@ void __init x86_64_start_reservations(char *real_mode_data)
107 unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; 112 unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
108 unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; 113 unsigned long ramdisk_size = boot_params.hdr.ramdisk_size;
109 unsigned long ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); 114 unsigned long ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
110 reserve_early(ramdisk_image, ramdisk_end, "RAMDISK"); 115 memblock_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
111 } 116 }
112#endif 117#endif
113 118
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index fa8c1b8e09fb..bcece91dd311 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -183,13 +183,12 @@ default_entry:
183#ifdef CONFIG_X86_PAE 183#ifdef CONFIG_X86_PAE
184 184
185 /* 185 /*
186 * In PAE mode swapper_pg_dir is statically defined to contain enough 186 * In PAE mode initial_page_table is statically defined to contain
187 * entries to cover the VMSPLIT option (that is the top 1, 2 or 3 187 * enough entries to cover the VMSPLIT option (that is the top 1, 2 or 3
188 * entries). The identity mapping is handled by pointing two PGD 188 * entries). The identity mapping is handled by pointing two PGD entries
189 * entries to the first kernel PMD. 189 * to the first kernel PMD.
190 * 190 *
191 * Note the upper half of each PMD or PTE are always zero at 191 * Note the upper half of each PMD or PTE are always zero at this stage.
192 * this stage.
193 */ 192 */
194 193
195#define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */ 194#define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
@@ -197,7 +196,7 @@ default_entry:
197 xorl %ebx,%ebx /* %ebx is kept at zero */ 196 xorl %ebx,%ebx /* %ebx is kept at zero */
198 197
199 movl $pa(__brk_base), %edi 198 movl $pa(__brk_base), %edi
200 movl $pa(swapper_pg_pmd), %edx 199 movl $pa(initial_pg_pmd), %edx
201 movl $PTE_IDENT_ATTR, %eax 200 movl $PTE_IDENT_ATTR, %eax
20210: 20110:
203 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */ 202 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
@@ -226,14 +225,14 @@ default_entry:
226 movl %eax, pa(max_pfn_mapped) 225 movl %eax, pa(max_pfn_mapped)
227 226
228 /* Do early initialization of the fixmap area */ 227 /* Do early initialization of the fixmap area */
229 movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax 228 movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
230 movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8) 229 movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
231#else /* Not PAE */ 230#else /* Not PAE */
232 231
233page_pde_offset = (__PAGE_OFFSET >> 20); 232page_pde_offset = (__PAGE_OFFSET >> 20);
234 233
235 movl $pa(__brk_base), %edi 234 movl $pa(__brk_base), %edi
236 movl $pa(swapper_pg_dir), %edx 235 movl $pa(initial_page_table), %edx
237 movl $PTE_IDENT_ATTR, %eax 236 movl $PTE_IDENT_ATTR, %eax
23810: 23710:
239 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */ 238 leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
@@ -257,8 +256,8 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
257 movl %eax, pa(max_pfn_mapped) 256 movl %eax, pa(max_pfn_mapped)
258 257
259 /* Do early initialization of the fixmap area */ 258 /* Do early initialization of the fixmap area */
260 movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax 259 movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
261 movl %eax,pa(swapper_pg_dir+0xffc) 260 movl %eax,pa(initial_page_table+0xffc)
262#endif 261#endif
263 jmp 3f 262 jmp 3f
264/* 263/*
@@ -334,7 +333,7 @@ ENTRY(startup_32_smp)
334/* 333/*
335 * Enable paging 334 * Enable paging
336 */ 335 */
337 movl pa(initial_page_table), %eax 336 movl $pa(initial_page_table), %eax
338 movl %eax,%cr3 /* set the page table pointer.. */ 337 movl %eax,%cr3 /* set the page table pointer.. */
339 movl %cr0,%eax 338 movl %cr0,%eax
340 orl $X86_CR0_PG,%eax 339 orl $X86_CR0_PG,%eax
@@ -614,8 +613,6 @@ ignore_int:
614.align 4 613.align 4
615ENTRY(initial_code) 614ENTRY(initial_code)
616 .long i386_start_kernel 615 .long i386_start_kernel
617ENTRY(initial_page_table)
618 .long pa(swapper_pg_dir)
619 616
620/* 617/*
621 * BSS section 618 * BSS section
@@ -623,20 +620,18 @@ ENTRY(initial_page_table)
623__PAGE_ALIGNED_BSS 620__PAGE_ALIGNED_BSS
624 .align PAGE_SIZE_asm 621 .align PAGE_SIZE_asm
625#ifdef CONFIG_X86_PAE 622#ifdef CONFIG_X86_PAE
626swapper_pg_pmd: 623initial_pg_pmd:
627 .fill 1024*KPMDS,4,0 624 .fill 1024*KPMDS,4,0
628#else 625#else
629ENTRY(swapper_pg_dir) 626ENTRY(initial_page_table)
630 .fill 1024,4,0 627 .fill 1024,4,0
631#endif 628#endif
632swapper_pg_fixmap: 629initial_pg_fixmap:
633 .fill 1024,4,0 630 .fill 1024,4,0
634#ifdef CONFIG_X86_TRAMPOLINE
635ENTRY(trampoline_pg_dir)
636 .fill 1024,4,0
637#endif
638ENTRY(empty_zero_page) 631ENTRY(empty_zero_page)
639 .fill 4096,1,0 632 .fill 4096,1,0
633ENTRY(swapper_pg_dir)
634 .fill 1024,4,0
640 635
641/* 636/*
642 * This starts the data section. 637 * This starts the data section.
@@ -645,20 +640,20 @@ ENTRY(empty_zero_page)
645__PAGE_ALIGNED_DATA 640__PAGE_ALIGNED_DATA
646 /* Page-aligned for the benefit of paravirt? */ 641 /* Page-aligned for the benefit of paravirt? */
647 .align PAGE_SIZE_asm 642 .align PAGE_SIZE_asm
648ENTRY(swapper_pg_dir) 643ENTRY(initial_page_table)
649 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */ 644 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
650# if KPMDS == 3 645# if KPMDS == 3
651 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 646 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
652 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0 647 .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x1000),0
653 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0 648 .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x2000),0
654# elif KPMDS == 2 649# elif KPMDS == 2
655 .long 0,0 650 .long 0,0
656 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 651 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
657 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0 652 .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x1000),0
658# elif KPMDS == 1 653# elif KPMDS == 1
659 .long 0,0 654 .long 0,0
660 .long 0,0 655 .long 0,0
661 .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 656 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
662# else 657# else
663# error "Kernel PMDs should be 1, 2 or 3" 658# error "Kernel PMDs should be 1, 2 or 3"
664# endif 659# endif
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 410fdb3f1939..aff0b3c27509 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -380,44 +380,35 @@ static int hpet_next_event(unsigned long delta,
380 struct clock_event_device *evt, int timer) 380 struct clock_event_device *evt, int timer)
381{ 381{
382 u32 cnt; 382 u32 cnt;
383 s32 res;
383 384
384 cnt = hpet_readl(HPET_COUNTER); 385 cnt = hpet_readl(HPET_COUNTER);
385 cnt += (u32) delta; 386 cnt += (u32) delta;
386 hpet_writel(cnt, HPET_Tn_CMP(timer)); 387 hpet_writel(cnt, HPET_Tn_CMP(timer));
387 388
388 /* 389 /*
389 * We need to read back the CMP register on certain HPET 390 * HPETs are a complete disaster. The compare register is
390 * implementations (ATI chipsets) which seem to delay the 391 * based on a equal comparison and neither provides a less
391 * transfer of the compare register into the internal compare 392 * than or equal functionality (which would require to take
392 * logic. With small deltas this might actually be too late as 393 * the wraparound into account) nor a simple count down event
393 * the counter could already be higher than the compare value 394 * mode. Further the write to the comparator register is
394 * at that point and we would wait for the next hpet interrupt 395 * delayed internally up to two HPET clock cycles in certain
395 * forever. We found out that reading the CMP register back 396 * chipsets (ATI, ICH9,10). We worked around that by reading
396 * forces the transfer so we can rely on the comparison with 397 * back the compare register, but that required another
397 * the counter register below. If the read back from the 398 * workaround for ICH9,10 chips where the first readout after
398 * compare register does not match the value we programmed 399 * write can return the old stale value. We already have a
399 * then we might have a real hardware problem. We can not do 400 * minimum delta of 5us enforced, but a NMI or SMI hitting
400 * much about it here, but at least alert the user/admin with 401 * between the counter readout and the comparator write can
401 * a prominent warning. 402 * move us behind that point easily. Now instead of reading
402 * 403 * the compare register back several times, we make the ETIME
403 * An erratum on some chipsets (ICH9,..), results in 404 * decision based on the following: Return ETIME if the
404 * comparator read immediately following a write returning old 405 * counter value after the write is less than 8 HPET cycles
405 * value. Workaround for this is to read this value second 406 * away from the event or if the counter is already ahead of
406 * time, when first read returns old value. 407 * the event.
407 *
408 * In fact the write to the comparator register is delayed up
409 * to two HPET cycles so the workaround we tried to restrict
410 * the readback to those known to be borked ATI chipsets
411 * failed miserably. So we give up on optimizations forever
412 * and penalize all HPET incarnations unconditionally.
413 */ 408 */
414 if (unlikely((u32)hpet_readl(HPET_Tn_CMP(timer)) != cnt)) { 409 res = (s32)(cnt - hpet_readl(HPET_COUNTER));
415 if (hpet_readl(HPET_Tn_CMP(timer)) != cnt)
416 printk_once(KERN_WARNING
417 "hpet: compare register read back failed.\n");
418 }
419 410
420 return (s32)(hpet_readl(HPET_COUNTER) - cnt) >= 0 ? -ETIME : 0; 411 return res < 8 ? -ETIME : 0;
421} 412}
422 413
423static void hpet_legacy_set_mode(enum clock_event_mode mode, 414static void hpet_legacy_set_mode(enum clock_event_mode mode,
@@ -440,9 +431,9 @@ static int hpet_legacy_next_event(unsigned long delta,
440static DEFINE_PER_CPU(struct hpet_dev *, cpu_hpet_dev); 431static DEFINE_PER_CPU(struct hpet_dev *, cpu_hpet_dev);
441static struct hpet_dev *hpet_devs; 432static struct hpet_dev *hpet_devs;
442 433
443void hpet_msi_unmask(unsigned int irq) 434void hpet_msi_unmask(struct irq_data *data)
444{ 435{
445 struct hpet_dev *hdev = get_irq_data(irq); 436 struct hpet_dev *hdev = data->handler_data;
446 unsigned int cfg; 437 unsigned int cfg;
447 438
448 /* unmask it */ 439 /* unmask it */
@@ -451,10 +442,10 @@ void hpet_msi_unmask(unsigned int irq)
451 hpet_writel(cfg, HPET_Tn_CFG(hdev->num)); 442 hpet_writel(cfg, HPET_Tn_CFG(hdev->num));
452} 443}
453 444
454void hpet_msi_mask(unsigned int irq) 445void hpet_msi_mask(struct irq_data *data)
455{ 446{
447 struct hpet_dev *hdev = data->handler_data;
456 unsigned int cfg; 448 unsigned int cfg;
457 struct hpet_dev *hdev = get_irq_data(irq);
458 449
459 /* mask it */ 450 /* mask it */
460 cfg = hpet_readl(HPET_Tn_CFG(hdev->num)); 451 cfg = hpet_readl(HPET_Tn_CFG(hdev->num));
@@ -462,18 +453,14 @@ void hpet_msi_mask(unsigned int irq)
462 hpet_writel(cfg, HPET_Tn_CFG(hdev->num)); 453 hpet_writel(cfg, HPET_Tn_CFG(hdev->num));
463} 454}
464 455
465void hpet_msi_write(unsigned int irq, struct msi_msg *msg) 456void hpet_msi_write(struct hpet_dev *hdev, struct msi_msg *msg)
466{ 457{
467 struct hpet_dev *hdev = get_irq_data(irq);
468
469 hpet_writel(msg->data, HPET_Tn_ROUTE(hdev->num)); 458 hpet_writel(msg->data, HPET_Tn_ROUTE(hdev->num));
470 hpet_writel(msg->address_lo, HPET_Tn_ROUTE(hdev->num) + 4); 459 hpet_writel(msg->address_lo, HPET_Tn_ROUTE(hdev->num) + 4);
471} 460}
472 461
473void hpet_msi_read(unsigned int irq, struct msi_msg *msg) 462void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg)
474{ 463{
475 struct hpet_dev *hdev = get_irq_data(irq);
476
477 msg->data = hpet_readl(HPET_Tn_ROUTE(hdev->num)); 464 msg->data = hpet_readl(HPET_Tn_ROUTE(hdev->num));
478 msg->address_lo = hpet_readl(HPET_Tn_ROUTE(hdev->num) + 4); 465 msg->address_lo = hpet_readl(HPET_Tn_ROUTE(hdev->num) + 4);
479 msg->address_hi = 0; 466 msg->address_hi = 0;
@@ -506,7 +493,7 @@ static int hpet_assign_irq(struct hpet_dev *dev)
506{ 493{
507 unsigned int irq; 494 unsigned int irq;
508 495
509 irq = create_irq(); 496 irq = create_irq_nr(0, -1);
510 if (!irq) 497 if (!irq)
511 return -EINVAL; 498 return -EINVAL;
512 499
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index a46cb3522c0c..58bb239a2fd7 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -68,19 +68,22 @@ static void __cpuinit init_thread_xstate(void)
68 */ 68 */
69 69
70 if (!HAVE_HWFP) { 70 if (!HAVE_HWFP) {
71 /*
72 * Disable xsave as we do not support it if i387
73 * emulation is enabled.
74 */
75 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
76 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
71 xstate_size = sizeof(struct i387_soft_struct); 77 xstate_size = sizeof(struct i387_soft_struct);
72 return; 78 return;
73 } 79 }
74 80
75 if (cpu_has_fxsr) 81 if (cpu_has_fxsr)
76 xstate_size = sizeof(struct i387_fxsave_struct); 82 xstate_size = sizeof(struct i387_fxsave_struct);
77#ifdef CONFIG_X86_32
78 else 83 else
79 xstate_size = sizeof(struct i387_fsave_struct); 84 xstate_size = sizeof(struct i387_fsave_struct);
80#endif
81} 85}
82 86
83#ifdef CONFIG_X86_64
84/* 87/*
85 * Called at bootup to set up the initial FPU state that is later cloned 88 * Called at bootup to set up the initial FPU state that is later cloned
86 * into all processes. 89 * into all processes.
@@ -88,12 +91,21 @@ static void __cpuinit init_thread_xstate(void)
88 91
89void __cpuinit fpu_init(void) 92void __cpuinit fpu_init(void)
90{ 93{
91 unsigned long oldcr0 = read_cr0(); 94 unsigned long cr0;
92 95 unsigned long cr4_mask = 0;
93 set_in_cr4(X86_CR4_OSFXSR);
94 set_in_cr4(X86_CR4_OSXMMEXCPT);
95 96
96 write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */ 97 if (cpu_has_fxsr)
98 cr4_mask |= X86_CR4_OSFXSR;
99 if (cpu_has_xmm)
100 cr4_mask |= X86_CR4_OSXMMEXCPT;
101 if (cr4_mask)
102 set_in_cr4(cr4_mask);
103
104 cr0 = read_cr0();
105 cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
106 if (!HAVE_HWFP)
107 cr0 |= X86_CR0_EM;
108 write_cr0(cr0);
97 109
98 if (!smp_processor_id()) 110 if (!smp_processor_id())
99 init_thread_xstate(); 111 init_thread_xstate();
@@ -104,24 +116,12 @@ void __cpuinit fpu_init(void)
104 clear_used_math(); 116 clear_used_math();
105} 117}
106 118
107#else /* CONFIG_X86_64 */
108
109void __cpuinit fpu_init(void)
110{
111 if (!smp_processor_id())
112 init_thread_xstate();
113}
114
115#endif /* CONFIG_X86_32 */
116
117void fpu_finit(struct fpu *fpu) 119void fpu_finit(struct fpu *fpu)
118{ 120{
119#ifdef CONFIG_X86_32
120 if (!HAVE_HWFP) { 121 if (!HAVE_HWFP) {
121 finit_soft_fpu(&fpu->state->soft); 122 finit_soft_fpu(&fpu->state->soft);
122 return; 123 return;
123 } 124 }
124#endif
125 125
126 if (cpu_has_fxsr) { 126 if (cpu_has_fxsr) {
127 struct i387_fxsave_struct *fx = &fpu->state->fxsave; 127 struct i387_fxsave_struct *fx = &fpu->state->fxsave;
@@ -386,19 +386,17 @@ convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk)
386#ifdef CONFIG_X86_64 386#ifdef CONFIG_X86_64
387 env->fip = fxsave->rip; 387 env->fip = fxsave->rip;
388 env->foo = fxsave->rdp; 388 env->foo = fxsave->rdp;
389 /*
390 * should be actually ds/cs at fpu exception time, but
391 * that information is not available in 64bit mode.
392 */
393 env->fcs = task_pt_regs(tsk)->cs;
389 if (tsk == current) { 394 if (tsk == current) {
390 /* 395 savesegment(ds, env->fos);
391 * should be actually ds/cs at fpu exception time, but
392 * that information is not available in 64bit mode.
393 */
394 asm("mov %%ds, %[fos]" : [fos] "=r" (env->fos));
395 asm("mov %%cs, %[fcs]" : [fcs] "=r" (env->fcs));
396 } else { 396 } else {
397 struct pt_regs *regs = task_pt_regs(tsk); 397 env->fos = tsk->thread.ds;
398
399 env->fos = 0xffff0000 | tsk->thread.ds;
400 env->fcs = regs->cs;
401 } 398 }
399 env->fos |= 0xffff0000;
402#else 400#else
403 env->fip = fxsave->fip; 401 env->fip = fxsave->fip;
404 env->fcs = (u16) fxsave->fcs | ((u32) fxsave->fop << 16); 402 env->fcs = (u16) fxsave->fcs | ((u32) fxsave->fop << 16);
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
index cafa7c80ac95..20757cb2efa3 100644
--- a/arch/x86/kernel/i8259.c
+++ b/arch/x86/kernel/i8259.c
@@ -29,24 +29,10 @@
29 * plus some generic x86 specific things if generic specifics makes 29 * plus some generic x86 specific things if generic specifics makes
30 * any sense at all. 30 * any sense at all.
31 */ 31 */
32static void init_8259A(int auto_eoi);
32 33
33static int i8259A_auto_eoi; 34static int i8259A_auto_eoi;
34DEFINE_RAW_SPINLOCK(i8259A_lock); 35DEFINE_RAW_SPINLOCK(i8259A_lock);
35static void mask_and_ack_8259A(unsigned int);
36static void mask_8259A(void);
37static void unmask_8259A(void);
38static void disable_8259A_irq(unsigned int irq);
39static void enable_8259A_irq(unsigned int irq);
40static void init_8259A(int auto_eoi);
41static int i8259A_irq_pending(unsigned int irq);
42
43struct irq_chip i8259A_chip = {
44 .name = "XT-PIC",
45 .mask = disable_8259A_irq,
46 .disable = disable_8259A_irq,
47 .unmask = enable_8259A_irq,
48 .mask_ack = mask_and_ack_8259A,
49};
50 36
51/* 37/*
52 * 8259A PIC functions to handle ISA devices: 38 * 8259A PIC functions to handle ISA devices:
@@ -68,7 +54,7 @@ unsigned int cached_irq_mask = 0xffff;
68 */ 54 */
69unsigned long io_apic_irqs; 55unsigned long io_apic_irqs;
70 56
71static void disable_8259A_irq(unsigned int irq) 57static void mask_8259A_irq(unsigned int irq)
72{ 58{
73 unsigned int mask = 1 << irq; 59 unsigned int mask = 1 << irq;
74 unsigned long flags; 60 unsigned long flags;
@@ -82,7 +68,12 @@ static void disable_8259A_irq(unsigned int irq)
82 raw_spin_unlock_irqrestore(&i8259A_lock, flags); 68 raw_spin_unlock_irqrestore(&i8259A_lock, flags);
83} 69}
84 70
85static void enable_8259A_irq(unsigned int irq) 71static void disable_8259A_irq(struct irq_data *data)
72{
73 mask_8259A_irq(data->irq);
74}
75
76static void unmask_8259A_irq(unsigned int irq)
86{ 77{
87 unsigned int mask = ~(1 << irq); 78 unsigned int mask = ~(1 << irq);
88 unsigned long flags; 79 unsigned long flags;
@@ -96,6 +87,11 @@ static void enable_8259A_irq(unsigned int irq)
96 raw_spin_unlock_irqrestore(&i8259A_lock, flags); 87 raw_spin_unlock_irqrestore(&i8259A_lock, flags);
97} 88}
98 89
90static void enable_8259A_irq(struct irq_data *data)
91{
92 unmask_8259A_irq(data->irq);
93}
94
99static int i8259A_irq_pending(unsigned int irq) 95static int i8259A_irq_pending(unsigned int irq)
100{ 96{
101 unsigned int mask = 1<<irq; 97 unsigned int mask = 1<<irq;
@@ -117,7 +113,7 @@ static void make_8259A_irq(unsigned int irq)
117 disable_irq_nosync(irq); 113 disable_irq_nosync(irq);
118 io_apic_irqs &= ~(1<<irq); 114 io_apic_irqs &= ~(1<<irq);
119 set_irq_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq, 115 set_irq_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
120 "XT"); 116 i8259A_chip.name);
121 enable_irq(irq); 117 enable_irq(irq);
122} 118}
123 119
@@ -150,8 +146,9 @@ static inline int i8259A_irq_real(unsigned int irq)
150 * first, _then_ send the EOI, and the order of EOI 146 * first, _then_ send the EOI, and the order of EOI
151 * to the two 8259s is important! 147 * to the two 8259s is important!
152 */ 148 */
153static void mask_and_ack_8259A(unsigned int irq) 149static void mask_and_ack_8259A(struct irq_data *data)
154{ 150{
151 unsigned int irq = data->irq;
155 unsigned int irqmask = 1 << irq; 152 unsigned int irqmask = 1 << irq;
156 unsigned long flags; 153 unsigned long flags;
157 154
@@ -223,6 +220,14 @@ spurious_8259A_irq:
223 } 220 }
224} 221}
225 222
223struct irq_chip i8259A_chip = {
224 .name = "XT-PIC",
225 .irq_mask = disable_8259A_irq,
226 .irq_disable = disable_8259A_irq,
227 .irq_unmask = enable_8259A_irq,
228 .irq_mask_ack = mask_and_ack_8259A,
229};
230
226static char irq_trigger[2]; 231static char irq_trigger[2];
227/** 232/**
228 * ELCR registers (0x4d0, 0x4d1) control edge/level of IRQ 233 * ELCR registers (0x4d0, 0x4d1) control edge/level of IRQ
@@ -342,9 +347,9 @@ static void init_8259A(int auto_eoi)
342 * In AEOI mode we just have to mask the interrupt 347 * In AEOI mode we just have to mask the interrupt
343 * when acking. 348 * when acking.
344 */ 349 */
345 i8259A_chip.mask_ack = disable_8259A_irq; 350 i8259A_chip.irq_mask_ack = disable_8259A_irq;
346 else 351 else
347 i8259A_chip.mask_ack = mask_and_ack_8259A; 352 i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
348 353
349 udelay(100); /* wait for 8259A to initialize */ 354 udelay(100); /* wait for 8259A to initialize */
350 355
@@ -363,14 +368,6 @@ static void init_8259A(int auto_eoi)
363static void legacy_pic_noop(void) { }; 368static void legacy_pic_noop(void) { };
364static void legacy_pic_uint_noop(unsigned int unused) { }; 369static void legacy_pic_uint_noop(unsigned int unused) { };
365static void legacy_pic_int_noop(int unused) { }; 370static void legacy_pic_int_noop(int unused) { };
366
367static struct irq_chip dummy_pic_chip = {
368 .name = "dummy pic",
369 .mask = legacy_pic_uint_noop,
370 .unmask = legacy_pic_uint_noop,
371 .disable = legacy_pic_uint_noop,
372 .mask_ack = legacy_pic_uint_noop,
373};
374static int legacy_pic_irq_pending_noop(unsigned int irq) 371static int legacy_pic_irq_pending_noop(unsigned int irq)
375{ 372{
376 return 0; 373 return 0;
@@ -378,7 +375,9 @@ static int legacy_pic_irq_pending_noop(unsigned int irq)
378 375
379struct legacy_pic null_legacy_pic = { 376struct legacy_pic null_legacy_pic = {
380 .nr_legacy_irqs = 0, 377 .nr_legacy_irqs = 0,
381 .chip = &dummy_pic_chip, 378 .chip = &dummy_irq_chip,
379 .mask = legacy_pic_uint_noop,
380 .unmask = legacy_pic_uint_noop,
382 .mask_all = legacy_pic_noop, 381 .mask_all = legacy_pic_noop,
383 .restore_mask = legacy_pic_noop, 382 .restore_mask = legacy_pic_noop,
384 .init = legacy_pic_int_noop, 383 .init = legacy_pic_int_noop,
@@ -389,7 +388,9 @@ struct legacy_pic null_legacy_pic = {
389struct legacy_pic default_legacy_pic = { 388struct legacy_pic default_legacy_pic = {
390 .nr_legacy_irqs = NR_IRQS_LEGACY, 389 .nr_legacy_irqs = NR_IRQS_LEGACY,
391 .chip = &i8259A_chip, 390 .chip = &i8259A_chip,
392 .mask_all = mask_8259A, 391 .mask = mask_8259A_irq,
392 .unmask = unmask_8259A_irq,
393 .mask_all = mask_8259A,
393 .restore_mask = unmask_8259A, 394 .restore_mask = unmask_8259A,
394 .init = init_8259A, 395 .init = init_8259A,
395 .irq_pending = i8259A_irq_pending, 396 .irq_pending = i8259A_irq_pending,
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 91fd0c70a18a..83ec0175f986 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -67,10 +67,10 @@ static int show_other_interrupts(struct seq_file *p, int prec)
67 for_each_online_cpu(j) 67 for_each_online_cpu(j)
68 seq_printf(p, "%10u ", irq_stats(j)->apic_perf_irqs); 68 seq_printf(p, "%10u ", irq_stats(j)->apic_perf_irqs);
69 seq_printf(p, " Performance monitoring interrupts\n"); 69 seq_printf(p, " Performance monitoring interrupts\n");
70 seq_printf(p, "%*s: ", prec, "PND"); 70 seq_printf(p, "%*s: ", prec, "IWI");
71 for_each_online_cpu(j) 71 for_each_online_cpu(j)
72 seq_printf(p, "%10u ", irq_stats(j)->apic_pending_irqs); 72 seq_printf(p, "%10u ", irq_stats(j)->apic_irq_work_irqs);
73 seq_printf(p, " Performance pending work\n"); 73 seq_printf(p, " IRQ work interrupts\n");
74#endif 74#endif
75 if (x86_platform_ipi_callback) { 75 if (x86_platform_ipi_callback) {
76 seq_printf(p, "%*s: ", prec, "PLT"); 76 seq_printf(p, "%*s: ", prec, "PLT");
@@ -159,7 +159,7 @@ int show_interrupts(struct seq_file *p, void *v)
159 seq_printf(p, "%*d: ", prec, i); 159 seq_printf(p, "%*d: ", prec, i);
160 for_each_online_cpu(j) 160 for_each_online_cpu(j)
161 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 161 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
162 seq_printf(p, " %8s", desc->chip->name); 162 seq_printf(p, " %8s", desc->irq_data.chip->name);
163 seq_printf(p, "-%-8s", desc->name); 163 seq_printf(p, "-%-8s", desc->name);
164 164
165 if (action) { 165 if (action) {
@@ -185,7 +185,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
185 sum += irq_stats(cpu)->apic_timer_irqs; 185 sum += irq_stats(cpu)->apic_timer_irqs;
186 sum += irq_stats(cpu)->irq_spurious_count; 186 sum += irq_stats(cpu)->irq_spurious_count;
187 sum += irq_stats(cpu)->apic_perf_irqs; 187 sum += irq_stats(cpu)->apic_perf_irqs;
188 sum += irq_stats(cpu)->apic_pending_irqs; 188 sum += irq_stats(cpu)->apic_irq_work_irqs;
189#endif 189#endif
190 if (x86_platform_ipi_callback) 190 if (x86_platform_ipi_callback)
191 sum += irq_stats(cpu)->x86_platform_ipis; 191 sum += irq_stats(cpu)->x86_platform_ipis;
@@ -282,6 +282,7 @@ void fixup_irqs(void)
282 unsigned int irq, vector; 282 unsigned int irq, vector;
283 static int warned; 283 static int warned;
284 struct irq_desc *desc; 284 struct irq_desc *desc;
285 struct irq_data *data;
285 286
286 for_each_irq_desc(irq, desc) { 287 for_each_irq_desc(irq, desc) {
287 int break_affinity = 0; 288 int break_affinity = 0;
@@ -296,7 +297,8 @@ void fixup_irqs(void)
296 /* interrupt's are disabled at this point */ 297 /* interrupt's are disabled at this point */
297 raw_spin_lock(&desc->lock); 298 raw_spin_lock(&desc->lock);
298 299
299 affinity = desc->affinity; 300 data = &desc->irq_data;
301 affinity = data->affinity;
300 if (!irq_has_action(irq) || 302 if (!irq_has_action(irq) ||
301 cpumask_equal(affinity, cpu_online_mask)) { 303 cpumask_equal(affinity, cpu_online_mask)) {
302 raw_spin_unlock(&desc->lock); 304 raw_spin_unlock(&desc->lock);
@@ -315,16 +317,16 @@ void fixup_irqs(void)
315 affinity = cpu_all_mask; 317 affinity = cpu_all_mask;
316 } 318 }
317 319
318 if (!(desc->status & IRQ_MOVE_PCNTXT) && desc->chip->mask) 320 if (!(desc->status & IRQ_MOVE_PCNTXT) && data->chip->irq_mask)
319 desc->chip->mask(irq); 321 data->chip->irq_mask(data);
320 322
321 if (desc->chip->set_affinity) 323 if (data->chip->irq_set_affinity)
322 desc->chip->set_affinity(irq, affinity); 324 data->chip->irq_set_affinity(data, affinity, true);
323 else if (!(warned++)) 325 else if (!(warned++))
324 set_affinity = 0; 326 set_affinity = 0;
325 327
326 if (!(desc->status & IRQ_MOVE_PCNTXT) && desc->chip->unmask) 328 if (!(desc->status & IRQ_MOVE_PCNTXT) && data->chip->irq_unmask)
327 desc->chip->unmask(irq); 329 data->chip->irq_unmask(data);
328 330
329 raw_spin_unlock(&desc->lock); 331 raw_spin_unlock(&desc->lock);
330 332
@@ -355,10 +357,10 @@ void fixup_irqs(void)
355 if (irr & (1 << (vector % 32))) { 357 if (irr & (1 << (vector % 32))) {
356 irq = __get_cpu_var(vector_irq)[vector]; 358 irq = __get_cpu_var(vector_irq)[vector];
357 359
358 desc = irq_to_desc(irq); 360 data = irq_get_irq_data(irq);
359 raw_spin_lock(&desc->lock); 361 raw_spin_lock(&desc->lock);
360 if (desc->chip->retrigger) 362 if (data->chip->irq_retrigger)
361 desc->chip->retrigger(irq); 363 data->chip->irq_retrigger(data);
362 raw_spin_unlock(&desc->lock); 364 raw_spin_unlock(&desc->lock);
363 } 365 }
364 } 366 }
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 10709f29d166..50fbbe60e507 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -49,20 +49,19 @@ static inline int check_stack_overflow(void) { return 0; }
49static inline void print_stack_overflow(void) { } 49static inline void print_stack_overflow(void) { }
50#endif 50#endif
51 51
52#ifdef CONFIG_4KSTACKS
53/* 52/*
54 * per-CPU IRQ handling contexts (thread information and stack) 53 * per-CPU IRQ handling contexts (thread information and stack)
55 */ 54 */
56union irq_ctx { 55union irq_ctx {
57 struct thread_info tinfo; 56 struct thread_info tinfo;
58 u32 stack[THREAD_SIZE/sizeof(u32)]; 57 u32 stack[THREAD_SIZE/sizeof(u32)];
59} __attribute__((aligned(PAGE_SIZE))); 58} __attribute__((aligned(THREAD_SIZE)));
60 59
61static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx); 60static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
62static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx); 61static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx);
63 62
64static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, hardirq_stack); 63static DEFINE_PER_CPU_MULTIPAGE_ALIGNED(union irq_ctx, hardirq_stack, THREAD_SIZE);
65static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, softirq_stack); 64static DEFINE_PER_CPU_MULTIPAGE_ALIGNED(union irq_ctx, softirq_stack, THREAD_SIZE);
66 65
67static void call_on_stack(void *func, void *stack) 66static void call_on_stack(void *func, void *stack)
68{ 67{
@@ -187,11 +186,6 @@ asmlinkage void do_softirq(void)
187 local_irq_restore(flags); 186 local_irq_restore(flags);
188} 187}
189 188
190#else
191static inline int
192execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) { return 0; }
193#endif
194
195bool handle_irq(unsigned irq, struct pt_regs *regs) 189bool handle_irq(unsigned irq, struct pt_regs *regs)
196{ 190{
197 struct irq_desc *desc; 191 struct irq_desc *desc;
diff --git a/arch/x86/kernel/irq_work.c b/arch/x86/kernel/irq_work.c
new file mode 100644
index 000000000000..ca8f703a1e70
--- /dev/null
+++ b/arch/x86/kernel/irq_work.c
@@ -0,0 +1,30 @@
1/*
2 * x86 specific code for irq_work
3 *
4 * Copyright (C) 2010 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
5 */
6
7#include <linux/kernel.h>
8#include <linux/irq_work.h>
9#include <linux/hardirq.h>
10#include <asm/apic.h>
11
12void smp_irq_work_interrupt(struct pt_regs *regs)
13{
14 irq_enter();
15 ack_APIC_irq();
16 inc_irq_stat(apic_irq_work_irqs);
17 irq_work_run();
18 irq_exit();
19}
20
21void arch_irq_work_raise(void)
22{
23#ifdef CONFIG_X86_LOCAL_APIC
24 if (!cpu_has_apic)
25 return;
26
27 apic->send_IPI_self(IRQ_WORK_VECTOR);
28 apic_wait_icr_idle();
29#endif
30}
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 990ae7cfc578..c752e973958d 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -100,6 +100,8 @@ int vector_used_by_percpu_irq(unsigned int vector)
100 100
101void __init init_ISA_irqs(void) 101void __init init_ISA_irqs(void)
102{ 102{
103 struct irq_chip *chip = legacy_pic->chip;
104 const char *name = chip->name;
103 int i; 105 int i;
104 106
105#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 107#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
@@ -107,19 +109,8 @@ void __init init_ISA_irqs(void)
107#endif 109#endif
108 legacy_pic->init(0); 110 legacy_pic->init(0);
109 111
110 /* 112 for (i = 0; i < legacy_pic->nr_legacy_irqs; i++)
111 * 16 old-style INTA-cycle interrupts: 113 set_irq_chip_and_handler_name(i, chip, handle_level_irq, name);
112 */
113 for (i = 0; i < legacy_pic->nr_legacy_irqs; i++) {
114 struct irq_desc *desc = irq_to_desc(i);
115
116 desc->status = IRQ_DISABLED;
117 desc->action = NULL;
118 desc->depth = 1;
119
120 set_irq_chip_and_handler_name(i, &i8259A_chip,
121 handle_level_irq, "XT");
122 }
123} 114}
124 115
125void __init init_IRQ(void) 116void __init init_IRQ(void)
@@ -224,9 +215,9 @@ static void __init apic_intr_init(void)
224 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt); 215 alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
225 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt); 216 alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
226 217
227 /* Performance monitoring interrupts: */ 218 /* IRQ work interrupts: */
228# ifdef CONFIG_PERF_EVENTS 219# ifdef CONFIG_IRQ_WORK
229 alloc_intr_gate(LOCAL_PENDING_VECTOR, perf_pending_interrupt); 220 alloc_intr_gate(IRQ_WORK_VECTOR, irq_work_interrupt);
230# endif 221# endif
231 222
232#endif 223#endif
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
new file mode 100644
index 000000000000..961b6b30ba90
--- /dev/null
+++ b/arch/x86/kernel/jump_label.c
@@ -0,0 +1,50 @@
1/*
2 * jump label x86 support
3 *
4 * Copyright (C) 2009 Jason Baron <jbaron@redhat.com>
5 *
6 */
7#include <linux/jump_label.h>
8#include <linux/memory.h>
9#include <linux/uaccess.h>
10#include <linux/module.h>
11#include <linux/list.h>
12#include <linux/jhash.h>
13#include <linux/cpu.h>
14#include <asm/kprobes.h>
15#include <asm/alternative.h>
16
17#ifdef HAVE_JUMP_LABEL
18
19union jump_code_union {
20 char code[JUMP_LABEL_NOP_SIZE];
21 struct {
22 char jump;
23 int offset;
24 } __attribute__((packed));
25};
26
27void arch_jump_label_transform(struct jump_entry *entry,
28 enum jump_label_type type)
29{
30 union jump_code_union code;
31
32 if (type == JUMP_LABEL_ENABLE) {
33 code.jump = 0xe9;
34 code.offset = entry->target -
35 (entry->code + JUMP_LABEL_NOP_SIZE);
36 } else
37 memcpy(&code, ideal_nop5, JUMP_LABEL_NOP_SIZE);
38 get_online_cpus();
39 mutex_lock(&text_mutex);
40 text_poke_smp((void *)entry->code, &code, JUMP_LABEL_NOP_SIZE);
41 mutex_unlock(&text_mutex);
42 put_online_cpus();
43}
44
45void arch_jump_label_text_poke_early(jump_label_t addr)
46{
47 text_poke_early((void *)addr, ideal_nop5, JUMP_LABEL_NOP_SIZE);
48}
49
50#endif
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index 8afd9f321f10..90fcf62854bb 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -78,6 +78,7 @@ static int setup_data_open(struct inode *inode, struct file *file)
78static const struct file_operations fops_setup_data = { 78static const struct file_operations fops_setup_data = {
79 .read = setup_data_read, 79 .read = setup_data_read,
80 .open = setup_data_open, 80 .open = setup_data_open,
81 .llseek = default_llseek,
81}; 82};
82 83
83static int __init 84static int __init
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 852b81967a37..d81cfebb848f 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -477,8 +477,6 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
477 raw_smp_processor_id()); 477 raw_smp_processor_id());
478 } 478 }
479 479
480 kgdb_correct_hw_break();
481
482 return 0; 480 return 0;
483 } 481 }
484 482
@@ -621,7 +619,12 @@ int kgdb_arch_init(void)
621static void kgdb_hw_overflow_handler(struct perf_event *event, int nmi, 619static void kgdb_hw_overflow_handler(struct perf_event *event, int nmi,
622 struct perf_sample_data *data, struct pt_regs *regs) 620 struct perf_sample_data *data, struct pt_regs *regs)
623{ 621{
624 kgdb_ll_trap(DIE_DEBUG, "debug", regs, 0, 0, SIGTRAP); 622 struct task_struct *tsk = current;
623 int i;
624
625 for (i = 0; i < 4; i++)
626 if (breakinfo[i].enabled)
627 tsk->thread.debugreg6 |= (DR_TRAP0 << i);
625} 628}
626 629
627void kgdb_arch_late(void) 630void kgdb_arch_late(void)
@@ -644,7 +647,7 @@ void kgdb_arch_late(void)
644 if (breakinfo[i].pev) 647 if (breakinfo[i].pev)
645 continue; 648 continue;
646 breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL); 649 breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL);
647 if (IS_ERR(breakinfo[i].pev)) { 650 if (IS_ERR((void * __force)breakinfo[i].pev)) {
648 printk(KERN_ERR "kgdb: Could not allocate hw" 651 printk(KERN_ERR "kgdb: Could not allocate hw"
649 "breakpoints\nDisabling the kernel debugger\n"); 652 "breakpoints\nDisabling the kernel debugger\n");
650 breakinfo[i].pev = NULL; 653 breakinfo[i].pev = NULL;
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 770ebfb349e9..1cbd54c0df99 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -230,9 +230,6 @@ static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
230 return 0; 230 return 0;
231} 231}
232 232
233/* Dummy buffers for kallsyms_lookup */
234static char __dummy_buf[KSYM_NAME_LEN];
235
236/* Check if paddr is at an instruction boundary */ 233/* Check if paddr is at an instruction boundary */
237static int __kprobes can_probe(unsigned long paddr) 234static int __kprobes can_probe(unsigned long paddr)
238{ 235{
@@ -241,7 +238,7 @@ static int __kprobes can_probe(unsigned long paddr)
241 struct insn insn; 238 struct insn insn;
242 kprobe_opcode_t buf[MAX_INSN_SIZE]; 239 kprobe_opcode_t buf[MAX_INSN_SIZE];
243 240
244 if (!kallsyms_lookup(paddr, NULL, &offset, NULL, __dummy_buf)) 241 if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
245 return 0; 242 return 0;
246 243
247 /* Decode instructions */ 244 /* Decode instructions */
@@ -1129,7 +1126,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr,
1129 *(unsigned long *)addr = val; 1126 *(unsigned long *)addr = val;
1130} 1127}
1131 1128
1132void __kprobes kprobes_optinsn_template_holder(void) 1129static void __used __kprobes kprobes_optinsn_template_holder(void)
1133{ 1130{
1134 asm volatile ( 1131 asm volatile (
1135 ".global optprobe_template_entry\n" 1132 ".global optprobe_template_entry\n"
@@ -1221,7 +1218,8 @@ static int __kprobes copy_optimized_instructions(u8 *dest, u8 *src)
1221 } 1218 }
1222 /* Check whether the address range is reserved */ 1219 /* Check whether the address range is reserved */
1223 if (ftrace_text_reserved(src, src + len - 1) || 1220 if (ftrace_text_reserved(src, src + len - 1) ||
1224 alternatives_text_reserved(src, src + len - 1)) 1221 alternatives_text_reserved(src, src + len - 1) ||
1222 jump_label_text_reserved(src, src + len - 1))
1225 return -EBUSY; 1223 return -EBUSY;
1226 1224
1227 return len; 1225 return len;
@@ -1269,11 +1267,9 @@ static int __kprobes can_optimize(unsigned long paddr)
1269 unsigned long addr, size = 0, offset = 0; 1267 unsigned long addr, size = 0, offset = 0;
1270 struct insn insn; 1268 struct insn insn;
1271 kprobe_opcode_t buf[MAX_INSN_SIZE]; 1269 kprobe_opcode_t buf[MAX_INSN_SIZE];
1272 /* Dummy buffers for lookup_symbol_attrs */
1273 static char __dummy_buf[KSYM_NAME_LEN];
1274 1270
1275 /* Lookup symbol including addr */ 1271 /* Lookup symbol including addr */
1276 if (!kallsyms_lookup(paddr, &size, &offset, NULL, __dummy_buf)) 1272 if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
1277 return 0; 1273 return 0;
1278 1274
1279 /* Check there is enough space for a relative jump. */ 1275 /* Check there is enough space for a relative jump. */
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index eb9b76c716c2..ca43ce31a19c 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -128,13 +128,15 @@ static struct clocksource kvm_clock = {
128static int kvm_register_clock(char *txt) 128static int kvm_register_clock(char *txt)
129{ 129{
130 int cpu = smp_processor_id(); 130 int cpu = smp_processor_id();
131 int low, high; 131 int low, high, ret;
132
132 low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1; 133 low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1;
133 high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32); 134 high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32);
135 ret = native_write_msr_safe(msr_kvm_system_time, low, high);
134 printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n", 136 printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n",
135 cpu, high, low, txt); 137 cpu, high, low, txt);
136 138
137 return native_write_msr_safe(msr_kvm_system_time, low, high); 139 return ret;
138} 140}
139 141
140#ifdef CONFIG_X86_LOCAL_APIC 142#ifdef CONFIG_X86_LOCAL_APIC
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 035c8c529181..b3ea9db39db6 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -36,7 +36,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd,
36 if (!page) 36 if (!page)
37 goto out; 37 goto out;
38 pud = (pud_t *)page_address(page); 38 pud = (pud_t *)page_address(page);
39 memset(pud, 0, PAGE_SIZE); 39 clear_page(pud);
40 set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE)); 40 set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE));
41 } 41 }
42 pud = pud_offset(pgd, addr); 42 pud = pud_offset(pgd, addr);
@@ -45,7 +45,7 @@ static int init_one_level2_page(struct kimage *image, pgd_t *pgd,
45 if (!page) 45 if (!page)
46 goto out; 46 goto out;
47 pmd = (pmd_t *)page_address(page); 47 pmd = (pmd_t *)page_address(page);
48 memset(pmd, 0, PAGE_SIZE); 48 clear_page(pmd);
49 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE)); 49 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE));
50 } 50 }
51 pmd = pmd_offset(pud, addr); 51 pmd = pmd_offset(pud, addr);
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index fa6551d36c10..1cca374a2bac 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -12,7 +12,7 @@
12 * Software Developer's Manual 12 * Software Developer's Manual
13 * Order Number 253668 or free download from: 13 * Order Number 253668 or free download from:
14 * 14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm 15 * http://developer.intel.com/Assets/PDF/manual/253668.pdf
16 * 16 *
17 * For more information, go to http://www.urbanmyth.org/microcode 17 * For more information, go to http://www.urbanmyth.org/microcode
18 * 18 *
@@ -232,6 +232,7 @@ static const struct file_operations microcode_fops = {
232 .owner = THIS_MODULE, 232 .owner = THIS_MODULE,
233 .write = microcode_write, 233 .write = microcode_write,
234 .open = microcode_open, 234 .open = microcode_open,
235 .llseek = no_llseek,
235}; 236};
236 237
237static struct miscdevice microcode_dev = { 238static struct miscdevice microcode_dev = {
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
index 356170262a93..dcb65cc0a053 100644
--- a/arch/x86/kernel/microcode_intel.c
+++ b/arch/x86/kernel/microcode_intel.c
@@ -12,7 +12,7 @@
12 * Software Developer's Manual 12 * Software Developer's Manual
13 * Order Number 253668 or free download from: 13 * Order Number 253668 or free download from:
14 * 14 *
15 * http://developer.intel.com/design/pentium4/manuals/253668.htm 15 * http://developer.intel.com/Assets/PDF/manual/253668.pdf
16 * 16 *
17 * For more information, go to http://www.urbanmyth.org/microcode 17 * For more information, go to http://www.urbanmyth.org/microcode
18 * 18 *
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index e0bc186d7501..8f2956091735 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -239,11 +239,13 @@ int module_finalize(const Elf_Ehdr *hdr,
239 apply_paravirt(pseg, pseg + para->sh_size); 239 apply_paravirt(pseg, pseg + para->sh_size);
240 } 240 }
241 241
242 return module_bug_finalize(hdr, sechdrs, me); 242 /* make jump label nops */
243 jump_label_apply_nops(me);
244
245 return 0;
243} 246}
244 247
245void module_arch_cleanup(struct module *mod) 248void module_arch_cleanup(struct module *mod)
246{ 249{
247 alternatives_smp_module_del(mod); 250 alternatives_smp_module_del(mod);
248 module_bug_cleanup(mod);
249} 251}
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index d7b6f7fb4fec..9af64d9c4b67 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/memblock.h>
14#include <linux/kernel_stat.h> 15#include <linux/kernel_stat.h>
15#include <linux/mc146818rtc.h> 16#include <linux/mc146818rtc.h>
16#include <linux/bitops.h> 17#include <linux/bitops.h>
@@ -657,7 +658,7 @@ static void __init smp_reserve_memory(struct mpf_intel *mpf)
657{ 658{
658 unsigned long size = get_mpc_size(mpf->physptr); 659 unsigned long size = get_mpc_size(mpf->physptr);
659 660
660 reserve_early_overlap_ok(mpf->physptr, mpf->physptr+size, "MP-table mpc"); 661 memblock_x86_reserve_range(mpf->physptr, mpf->physptr+size, "* MP-table mpc");
661} 662}
662 663
663static int __init smp_scan_config(unsigned long base, unsigned long length) 664static int __init smp_scan_config(unsigned long base, unsigned long length)
@@ -686,7 +687,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length)
686 mpf, (u64)virt_to_phys(mpf)); 687 mpf, (u64)virt_to_phys(mpf));
687 688
688 mem = virt_to_phys(mpf); 689 mem = virt_to_phys(mpf);
689 reserve_early_overlap_ok(mem, mem + sizeof(*mpf), "MP-table mpf"); 690 memblock_x86_reserve_range(mem, mem + sizeof(*mpf), "* MP-table mpf");
690 if (mpf->physptr) 691 if (mpf->physptr)
691 smp_reserve_memory(mpf); 692 smp_reserve_memory(mpf);
692 693
diff --git a/arch/x86/kernel/olpc-xo1.c b/arch/x86/kernel/olpc-xo1.c
new file mode 100644
index 000000000000..f5442c03abc3
--- /dev/null
+++ b/arch/x86/kernel/olpc-xo1.c
@@ -0,0 +1,140 @@
1/*
2 * Support for features of the OLPC XO-1 laptop
3 *
4 * Copyright (C) 2010 One Laptop per Child
5 * Copyright (C) 2006 Red Hat, Inc.
6 * Copyright (C) 2006 Advanced Micro Devices, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/module.h>
15#include <linux/pci.h>
16#include <linux/pci_ids.h>
17#include <linux/platform_device.h>
18#include <linux/pm.h>
19
20#include <asm/io.h>
21#include <asm/olpc.h>
22
23#define DRV_NAME "olpc-xo1"
24
25#define PMS_BAR 4
26#define ACPI_BAR 5
27
28/* PMC registers (PMS block) */
29#define PM_SCLK 0x10
30#define PM_IN_SLPCTL 0x20
31#define PM_WKXD 0x34
32#define PM_WKD 0x30
33#define PM_SSC 0x54
34
35/* PM registers (ACPI block) */
36#define PM1_CNT 0x08
37#define PM_GPE0_STS 0x18
38
39static unsigned long acpi_base;
40static unsigned long pms_base;
41
42static void xo1_power_off(void)
43{
44 printk(KERN_INFO "OLPC XO-1 power off sequence...\n");
45
46 /* Enable all of these controls with 0 delay */
47 outl(0x40000000, pms_base + PM_SCLK);
48 outl(0x40000000, pms_base + PM_IN_SLPCTL);
49 outl(0x40000000, pms_base + PM_WKXD);
50 outl(0x40000000, pms_base + PM_WKD);
51
52 /* Clear status bits (possibly unnecessary) */
53 outl(0x0002ffff, pms_base + PM_SSC);
54 outl(0xffffffff, acpi_base + PM_GPE0_STS);
55
56 /* Write SLP_EN bit to start the machinery */
57 outl(0x00002000, acpi_base + PM1_CNT);
58}
59
60/* Read the base addresses from the PCI BAR info */
61static int __devinit setup_bases(struct pci_dev *pdev)
62{
63 int r;
64
65 r = pci_enable_device_io(pdev);
66 if (r) {
67 dev_err(&pdev->dev, "can't enable device IO\n");
68 return r;
69 }
70
71 r = pci_request_region(pdev, ACPI_BAR, DRV_NAME);
72 if (r) {
73 dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", ACPI_BAR);
74 return r;
75 }
76
77 r = pci_request_region(pdev, PMS_BAR, DRV_NAME);
78 if (r) {
79 dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", PMS_BAR);
80 pci_release_region(pdev, ACPI_BAR);
81 return r;
82 }
83
84 acpi_base = pci_resource_start(pdev, ACPI_BAR);
85 pms_base = pci_resource_start(pdev, PMS_BAR);
86
87 return 0;
88}
89
90static int __devinit olpc_xo1_probe(struct platform_device *pdev)
91{
92 struct pci_dev *pcidev;
93 int r;
94
95 pcidev = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA,
96 NULL);
97 if (!pdev)
98 return -ENODEV;
99
100 r = setup_bases(pcidev);
101 if (r)
102 return r;
103
104 pm_power_off = xo1_power_off;
105
106 printk(KERN_INFO "OLPC XO-1 support registered\n");
107 return 0;
108}
109
110static int __devexit olpc_xo1_remove(struct platform_device *pdev)
111{
112 pm_power_off = NULL;
113 return 0;
114}
115
116static struct platform_driver olpc_xo1_driver = {
117 .driver = {
118 .name = DRV_NAME,
119 .owner = THIS_MODULE,
120 },
121 .probe = olpc_xo1_probe,
122 .remove = __devexit_p(olpc_xo1_remove),
123};
124
125static int __init olpc_xo1_init(void)
126{
127 return platform_driver_register(&olpc_xo1_driver);
128}
129
130static void __exit olpc_xo1_exit(void)
131{
132 platform_driver_unregister(&olpc_xo1_driver);
133}
134
135MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
136MODULE_LICENSE("GPL");
137MODULE_ALIAS("platform:olpc-xo1");
138
139module_init(olpc_xo1_init);
140module_exit(olpc_xo1_exit);
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/kernel/olpc.c
index 0e0cdde519be..edaf3fe8dc5e 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/kernel/olpc.c
@@ -17,6 +17,7 @@
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/platform_device.h>
20 21
21#include <asm/geode.h> 22#include <asm/geode.h>
22#include <asm/setup.h> 23#include <asm/setup.h>
@@ -114,6 +115,7 @@ int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen,
114 unsigned long flags; 115 unsigned long flags;
115 int ret = -EIO; 116 int ret = -EIO;
116 int i; 117 int i;
118 int restarts = 0;
117 119
118 spin_lock_irqsave(&ec_lock, flags); 120 spin_lock_irqsave(&ec_lock, flags);
119 121
@@ -169,7 +171,9 @@ restart:
169 if (wait_on_obf(0x6c, 1)) { 171 if (wait_on_obf(0x6c, 1)) {
170 printk(KERN_ERR "olpc-ec: timeout waiting for" 172 printk(KERN_ERR "olpc-ec: timeout waiting for"
171 " EC to provide data!\n"); 173 " EC to provide data!\n");
172 goto restart; 174 if (restarts++ < 10)
175 goto restart;
176 goto err;
173 } 177 }
174 outbuf[i] = inb(0x68); 178 outbuf[i] = inb(0x68);
175 pr_devel("olpc-ec: received 0x%x\n", outbuf[i]); 179 pr_devel("olpc-ec: received 0x%x\n", outbuf[i]);
@@ -183,8 +187,21 @@ err:
183} 187}
184EXPORT_SYMBOL_GPL(olpc_ec_cmd); 188EXPORT_SYMBOL_GPL(olpc_ec_cmd);
185 189
186#ifdef CONFIG_OLPC_OPENFIRMWARE 190static bool __init check_ofw_architecture(void)
187static void __init platform_detect(void) 191{
192 size_t propsize;
193 char olpc_arch[5];
194 const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 };
195 void *res[] = { &propsize };
196
197 if (olpc_ofw("getprop", args, res)) {
198 printk(KERN_ERR "ofw: getprop call failed!\n");
199 return false;
200 }
201 return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0;
202}
203
204static u32 __init get_board_revision(void)
188{ 205{
189 size_t propsize; 206 size_t propsize;
190 __be32 rev; 207 __be32 rev;
@@ -193,45 +210,43 @@ static void __init platform_detect(void)
193 210
194 if (olpc_ofw("getprop", args, res) || propsize != 4) { 211 if (olpc_ofw("getprop", args, res) || propsize != 4) {
195 printk(KERN_ERR "ofw: getprop call failed!\n"); 212 printk(KERN_ERR "ofw: getprop call failed!\n");
196 rev = cpu_to_be32(0); 213 return cpu_to_be32(0);
197 } 214 }
198 olpc_platform_info.boardrev = be32_to_cpu(rev); 215 return be32_to_cpu(rev);
199} 216}
200#else 217
201static void __init platform_detect(void) 218static bool __init platform_detect(void)
202{ 219{
203 /* stopgap until OFW support is added to the kernel */ 220 if (!check_ofw_architecture())
204 olpc_platform_info.boardrev = olpc_board(0xc2); 221 return false;
222 olpc_platform_info.flags |= OLPC_F_PRESENT;
223 olpc_platform_info.boardrev = get_board_revision();
224 return true;
205} 225}
206#endif
207 226
208static int __init olpc_init(void) 227static int __init add_xo1_platform_devices(void)
209{ 228{
210 unsigned char *romsig; 229 struct platform_device *pdev;
211 230
212 /* The ioremap check is dangerous; limit what we run it on */ 231 pdev = platform_device_register_simple("xo1-rfkill", -1, NULL, 0);
213 if (!is_geode() || cs5535_has_vsa2()) 232 if (IS_ERR(pdev))
214 return 0; 233 return PTR_ERR(pdev);
215 234
216 spin_lock_init(&ec_lock); 235 pdev = platform_device_register_simple("olpc-xo1", -1, NULL, 0);
236 if (IS_ERR(pdev))
237 return PTR_ERR(pdev);
217 238
218 romsig = ioremap(0xffffffc0, 16); 239 return 0;
219 if (!romsig) 240}
220 return 0;
221 241
222 if (strncmp(romsig, "CL1 Q", 7)) 242static int __init olpc_init(void)
223 goto unmap; 243{
224 if (strncmp(romsig+6, romsig+13, 3)) { 244 int r = 0;
225 printk(KERN_INFO "OLPC BIOS signature looks invalid. "
226 "Assuming not OLPC\n");
227 goto unmap;
228 }
229 245
230 printk(KERN_INFO "OLPC board with OpenFirmware %.16s\n", romsig); 246 if (!olpc_ofw_present() || !platform_detect())
231 olpc_platform_info.flags |= OLPC_F_PRESENT; 247 return 0;
232 248
233 /* get the platform revision */ 249 spin_lock_init(&ec_lock);
234 platform_detect();
235 250
236 /* assume B1 and above models always have a DCON */ 251 /* assume B1 and above models always have a DCON */
237 if (olpc_board_at_least(olpc_board(0xb1))) 252 if (olpc_board_at_least(olpc_board(0xb1)))
@@ -242,8 +257,10 @@ static int __init olpc_init(void)
242 (unsigned char *) &olpc_platform_info.ecver, 1); 257 (unsigned char *) &olpc_platform_info.ecver, 1);
243 258
244#ifdef CONFIG_PCI_OLPC 259#ifdef CONFIG_PCI_OLPC
245 /* If the VSA exists let it emulate PCI, if not emulate in kernel */ 260 /* If the VSA exists let it emulate PCI, if not emulate in kernel.
246 if (!cs5535_has_vsa2()) 261 * XO-1 only. */
262 if (olpc_platform_info.boardrev < olpc_board_pre(0xd0) &&
263 !cs5535_has_vsa2())
247 x86_init.pci.arch_init = pci_olpc_init; 264 x86_init.pci.arch_init = pci_olpc_init;
248#endif 265#endif
249 266
@@ -252,8 +269,12 @@ static int __init olpc_init(void)
252 olpc_platform_info.boardrev >> 4, 269 olpc_platform_info.boardrev >> 4,
253 olpc_platform_info.ecver); 270 olpc_platform_info.ecver);
254 271
255unmap: 272 if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */
256 iounmap(romsig); 273 r = add_xo1_platform_devices();
274 if (r)
275 return r;
276 }
277
257 return 0; 278 return 0;
258} 279}
259 280
diff --git a/arch/x86/kernel/olpc_ofw.c b/arch/x86/kernel/olpc_ofw.c
index 3218aa71ab5e..787320464379 100644
--- a/arch/x86/kernel/olpc_ofw.c
+++ b/arch/x86/kernel/olpc_ofw.c
@@ -74,6 +74,12 @@ int __olpc_ofw(const char *name, int nr_args, const void **args, int nr_res,
74} 74}
75EXPORT_SYMBOL_GPL(__olpc_ofw); 75EXPORT_SYMBOL_GPL(__olpc_ofw);
76 76
77bool olpc_ofw_present(void)
78{
79 return olpc_ofw_cif != NULL;
80}
81EXPORT_SYMBOL_GPL(olpc_ofw_present);
82
77/* OFW cif _should_ be above this address */ 83/* OFW cif _should_ be above this address */
78#define OFW_MIN 0xff000000 84#define OFW_MIN 0xff000000
79 85
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 1db183ed7c01..c5b250011fd4 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -413,7 +413,6 @@ struct pv_mmu_ops pv_mmu_ops = {
413 413
414 .alloc_pte = paravirt_nop, 414 .alloc_pte = paravirt_nop,
415 .alloc_pmd = paravirt_nop, 415 .alloc_pmd = paravirt_nop,
416 .alloc_pmd_clone = paravirt_nop,
417 .alloc_pud = paravirt_nop, 416 .alloc_pud = paravirt_nop,
418 .release_pte = paravirt_nop, 417 .release_pte = paravirt_nop,
419 .release_pmd = paravirt_nop, 418 .release_pmd = paravirt_nop,
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 078d4ec1a9d9..f56a117cef68 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -47,6 +47,7 @@
47#include <asm/rio.h> 47#include <asm/rio.h>
48#include <asm/bios_ebda.h> 48#include <asm/bios_ebda.h>
49#include <asm/x86_init.h> 49#include <asm/x86_init.h>
50#include <asm/iommu_table.h>
50 51
51#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT 52#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
52int use_calgary __read_mostly = 1; 53int use_calgary __read_mostly = 1;
@@ -1364,7 +1365,7 @@ static int __init calgary_iommu_init(void)
1364 return 0; 1365 return 0;
1365} 1366}
1366 1367
1367void __init detect_calgary(void) 1368int __init detect_calgary(void)
1368{ 1369{
1369 int bus; 1370 int bus;
1370 void *tbl; 1371 void *tbl;
@@ -1378,13 +1379,13 @@ void __init detect_calgary(void)
1378 * another HW IOMMU already, bail out. 1379 * another HW IOMMU already, bail out.
1379 */ 1380 */
1380 if (no_iommu || iommu_detected) 1381 if (no_iommu || iommu_detected)
1381 return; 1382 return -ENODEV;
1382 1383
1383 if (!use_calgary) 1384 if (!use_calgary)
1384 return; 1385 return -ENODEV;
1385 1386
1386 if (!early_pci_allowed()) 1387 if (!early_pci_allowed())
1387 return; 1388 return -ENODEV;
1388 1389
1389 printk(KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n"); 1390 printk(KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n");
1390 1391
@@ -1410,13 +1411,13 @@ void __init detect_calgary(void)
1410 if (!rio_table_hdr) { 1411 if (!rio_table_hdr) {
1411 printk(KERN_DEBUG "Calgary: Unable to locate Rio Grande table " 1412 printk(KERN_DEBUG "Calgary: Unable to locate Rio Grande table "
1412 "in EBDA - bailing!\n"); 1413 "in EBDA - bailing!\n");
1413 return; 1414 return -ENODEV;
1414 } 1415 }
1415 1416
1416 ret = build_detail_arrays(); 1417 ret = build_detail_arrays();
1417 if (ret) { 1418 if (ret) {
1418 printk(KERN_DEBUG "Calgary: build_detail_arrays ret %d\n", ret); 1419 printk(KERN_DEBUG "Calgary: build_detail_arrays ret %d\n", ret);
1419 return; 1420 return -ENOMEM;
1420 } 1421 }
1421 1422
1422 specified_table_size = determine_tce_table_size((is_kdump_kernel() ? 1423 specified_table_size = determine_tce_table_size((is_kdump_kernel() ?
@@ -1464,7 +1465,7 @@ void __init detect_calgary(void)
1464 1465
1465 x86_init.iommu.iommu_init = calgary_iommu_init; 1466 x86_init.iommu.iommu_init = calgary_iommu_init;
1466 } 1467 }
1467 return; 1468 return calgary_found;
1468 1469
1469cleanup: 1470cleanup:
1470 for (--bus; bus >= 0; --bus) { 1471 for (--bus; bus >= 0; --bus) {
@@ -1473,6 +1474,7 @@ cleanup:
1473 if (info->tce_space) 1474 if (info->tce_space)
1474 free_tce_table(info->tce_space); 1475 free_tce_table(info->tce_space);
1475 } 1476 }
1477 return -ENOMEM;
1476} 1478}
1477 1479
1478static int __init calgary_parse_options(char *p) 1480static int __init calgary_parse_options(char *p)
@@ -1594,3 +1596,5 @@ static int __init calgary_fixup_tce_spaces(void)
1594 * and before device_initcall. 1596 * and before device_initcall.
1595 */ 1597 */
1596rootfs_initcall(calgary_fixup_tce_spaces); 1598rootfs_initcall(calgary_fixup_tce_spaces);
1599
1600IOMMU_INIT_POST(detect_calgary);
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 9f07cfcbd3a5..9ea999a4dcc1 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -11,9 +11,8 @@
11#include <asm/iommu.h> 11#include <asm/iommu.h>
12#include <asm/gart.h> 12#include <asm/gart.h>
13#include <asm/calgary.h> 13#include <asm/calgary.h>
14#include <asm/amd_iommu.h>
15#include <asm/x86_init.h> 14#include <asm/x86_init.h>
16#include <asm/xen/swiotlb-xen.h> 15#include <asm/iommu_table.h>
17 16
18static int forbid_dac __read_mostly; 17static int forbid_dac __read_mostly;
19 18
@@ -45,6 +44,8 @@ int iommu_detected __read_mostly = 0;
45 */ 44 */
46int iommu_pass_through __read_mostly; 45int iommu_pass_through __read_mostly;
47 46
47extern struct iommu_table_entry __iommu_table[], __iommu_table_end[];
48
48/* Dummy device used for NULL arguments (normally ISA). */ 49/* Dummy device used for NULL arguments (normally ISA). */
49struct device x86_dma_fallback_dev = { 50struct device x86_dma_fallback_dev = {
50 .init_name = "fallback device", 51 .init_name = "fallback device",
@@ -130,26 +131,24 @@ static void __init dma32_free_bootmem(void)
130 131
131void __init pci_iommu_alloc(void) 132void __init pci_iommu_alloc(void)
132{ 133{
134 struct iommu_table_entry *p;
135
133 /* free the range so iommu could get some range less than 4G */ 136 /* free the range so iommu could get some range less than 4G */
134 dma32_free_bootmem(); 137 dma32_free_bootmem();
135 138
136 if (pci_xen_swiotlb_detect() || pci_swiotlb_detect()) 139 sort_iommu_table(__iommu_table, __iommu_table_end);
137 goto out; 140 check_iommu_entries(__iommu_table, __iommu_table_end);
138
139 gart_iommu_hole_init();
140
141 detect_calgary();
142
143 detect_intel_iommu();
144 141
145 /* needs to be called after gart_iommu_hole_init */ 142 for (p = __iommu_table; p < __iommu_table_end; p++) {
146 amd_iommu_detect(); 143 if (p && p->detect && p->detect() > 0) {
147out: 144 p->flags |= IOMMU_DETECTED;
148 pci_xen_swiotlb_init(); 145 if (p->early_init)
149 146 p->early_init();
150 pci_swiotlb_init(); 147 if (p->flags & IOMMU_FINISH_IF_DETECTED)
148 break;
149 }
150 }
151} 151}
152
153void *dma_generic_alloc_coherent(struct device *dev, size_t size, 152void *dma_generic_alloc_coherent(struct device *dev, size_t size,
154 dma_addr_t *dma_addr, gfp_t flag) 153 dma_addr_t *dma_addr, gfp_t flag)
155{ 154{
@@ -292,6 +291,7 @@ EXPORT_SYMBOL(dma_supported);
292 291
293static int __init pci_iommu_init(void) 292static int __init pci_iommu_init(void)
294{ 293{
294 struct iommu_table_entry *p;
295 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES); 295 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
296 296
297#ifdef CONFIG_PCI 297#ifdef CONFIG_PCI
@@ -299,12 +299,10 @@ static int __init pci_iommu_init(void)
299#endif 299#endif
300 x86_init.iommu.iommu_init(); 300 x86_init.iommu.iommu_init();
301 301
302 if (swiotlb || xen_swiotlb) { 302 for (p = __iommu_table; p < __iommu_table_end; p++) {
303 printk(KERN_INFO "PCI-DMA: " 303 if (p && (p->flags & IOMMU_DETECTED) && p->late_init)
304 "Using software bounce buffering for IO (SWIOTLB)\n"); 304 p->late_init();
305 swiotlb_print_info(); 305 }
306 } else
307 swiotlb_free();
308 306
309 return 0; 307 return 0;
310} 308}
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 0f7f130caa67..ba0f0ca9f280 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -39,8 +39,9 @@
39#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
40#include <asm/swiotlb.h> 40#include <asm/swiotlb.h>
41#include <asm/dma.h> 41#include <asm/dma.h>
42#include <asm/k8.h> 42#include <asm/amd_nb.h>
43#include <asm/x86_init.h> 43#include <asm/x86_init.h>
44#include <asm/iommu_table.h>
44 45
45static unsigned long iommu_bus_base; /* GART remapping area (physical) */ 46static unsigned long iommu_bus_base; /* GART remapping area (physical) */
46static unsigned long iommu_size; /* size of remapping area bytes */ 47static unsigned long iommu_size; /* size of remapping area bytes */
@@ -560,8 +561,11 @@ static void enable_gart_translations(void)
560{ 561{
561 int i; 562 int i;
562 563
563 for (i = 0; i < num_k8_northbridges; i++) { 564 if (!k8_northbridges.gart_supported)
564 struct pci_dev *dev = k8_northbridges[i]; 565 return;
566
567 for (i = 0; i < k8_northbridges.num; i++) {
568 struct pci_dev *dev = k8_northbridges.nb_misc[i];
565 569
566 enable_gart_translation(dev, __pa(agp_gatt_table)); 570 enable_gart_translation(dev, __pa(agp_gatt_table));
567 } 571 }
@@ -592,16 +596,19 @@ static void gart_fixup_northbridges(struct sys_device *dev)
592 if (!fix_up_north_bridges) 596 if (!fix_up_north_bridges)
593 return; 597 return;
594 598
599 if (!k8_northbridges.gart_supported)
600 return;
601
595 pr_info("PCI-DMA: Restoring GART aperture settings\n"); 602 pr_info("PCI-DMA: Restoring GART aperture settings\n");
596 603
597 for (i = 0; i < num_k8_northbridges; i++) { 604 for (i = 0; i < k8_northbridges.num; i++) {
598 struct pci_dev *dev = k8_northbridges[i]; 605 struct pci_dev *dev = k8_northbridges.nb_misc[i];
599 606
600 /* 607 /*
601 * Don't enable translations just yet. That is the next 608 * Don't enable translations just yet. That is the next
602 * step. Restore the pre-suspend aperture settings. 609 * step. Restore the pre-suspend aperture settings.
603 */ 610 */
604 pci_write_config_dword(dev, AMD64_GARTAPERTURECTL, aperture_order << 1); 611 gart_set_size_and_enable(dev, aperture_order);
605 pci_write_config_dword(dev, AMD64_GARTAPERTUREBASE, aperture_alloc >> 25); 612 pci_write_config_dword(dev, AMD64_GARTAPERTUREBASE, aperture_alloc >> 25);
606 } 613 }
607} 614}
@@ -649,8 +656,8 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
649 656
650 aper_size = aper_base = info->aper_size = 0; 657 aper_size = aper_base = info->aper_size = 0;
651 dev = NULL; 658 dev = NULL;
652 for (i = 0; i < num_k8_northbridges; i++) { 659 for (i = 0; i < k8_northbridges.num; i++) {
653 dev = k8_northbridges[i]; 660 dev = k8_northbridges.nb_misc[i];
654 new_aper_base = read_aperture(dev, &new_aper_size); 661 new_aper_base = read_aperture(dev, &new_aper_size);
655 if (!new_aper_base) 662 if (!new_aper_base)
656 goto nommu; 663 goto nommu;
@@ -718,10 +725,13 @@ static void gart_iommu_shutdown(void)
718 if (!no_agp) 725 if (!no_agp)
719 return; 726 return;
720 727
721 for (i = 0; i < num_k8_northbridges; i++) { 728 if (!k8_northbridges.gart_supported)
729 return;
730
731 for (i = 0; i < k8_northbridges.num; i++) {
722 u32 ctl; 732 u32 ctl;
723 733
724 dev = k8_northbridges[i]; 734 dev = k8_northbridges.nb_misc[i];
725 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl); 735 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
726 736
727 ctl &= ~GARTEN; 737 ctl &= ~GARTEN;
@@ -739,7 +749,7 @@ int __init gart_iommu_init(void)
739 unsigned long scratch; 749 unsigned long scratch;
740 long i; 750 long i;
741 751
742 if (num_k8_northbridges == 0) 752 if (!k8_northbridges.gart_supported)
743 return 0; 753 return 0;
744 754
745#ifndef CONFIG_AGP_AMD64 755#ifndef CONFIG_AGP_AMD64
@@ -896,3 +906,4 @@ void __init gart_parse_options(char *p)
896 } 906 }
897 } 907 }
898} 908}
909IOMMU_INIT_POST(gart_iommu_hole_init);
diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
new file mode 100644
index 000000000000..55d745ec1181
--- /dev/null
+++ b/arch/x86/kernel/pci-iommu_table.c
@@ -0,0 +1,89 @@
1#include <linux/dma-mapping.h>
2#include <asm/iommu_table.h>
3#include <linux/string.h>
4#include <linux/kallsyms.h>
5
6
7#define DEBUG 1
8
9static struct iommu_table_entry * __init
10find_dependents_of(struct iommu_table_entry *start,
11 struct iommu_table_entry *finish,
12 struct iommu_table_entry *q)
13{
14 struct iommu_table_entry *p;
15
16 if (!q)
17 return NULL;
18
19 for (p = start; p < finish; p++)
20 if (p->detect == q->depend)
21 return p;
22
23 return NULL;
24}
25
26
27void __init sort_iommu_table(struct iommu_table_entry *start,
28 struct iommu_table_entry *finish) {
29
30 struct iommu_table_entry *p, *q, tmp;
31
32 for (p = start; p < finish; p++) {
33again:
34 q = find_dependents_of(start, finish, p);
35 /* We are bit sneaky here. We use the memory address to figure
36 * out if the node we depend on is past our point, if so, swap.
37 */
38 if (q > p) {
39 tmp = *p;
40 memmove(p, q, sizeof(*p));
41 *q = tmp;
42 goto again;
43 }
44 }
45
46}
47
48#ifdef DEBUG
49void __init check_iommu_entries(struct iommu_table_entry *start,
50 struct iommu_table_entry *finish)
51{
52 struct iommu_table_entry *p, *q, *x;
53 char sym_p[KSYM_SYMBOL_LEN];
54 char sym_q[KSYM_SYMBOL_LEN];
55
56 /* Simple cyclic dependency checker. */
57 for (p = start; p < finish; p++) {
58 q = find_dependents_of(start, finish, p);
59 x = find_dependents_of(start, finish, q);
60 if (p == x) {
61 sprint_symbol(sym_p, (unsigned long)p->detect);
62 sprint_symbol(sym_q, (unsigned long)q->detect);
63
64 printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %s depends" \
65 " on %s and vice-versa. BREAKING IT.\n",
66 sym_p, sym_q);
67 /* Heavy handed way..*/
68 x->depend = 0;
69 }
70 }
71
72 for (p = start; p < finish; p++) {
73 q = find_dependents_of(p, finish, p);
74 if (q && q > p) {
75 sprint_symbol(sym_p, (unsigned long)p->detect);
76 sprint_symbol(sym_q, (unsigned long)q->detect);
77
78 printk(KERN_ERR "EXECUTION ORDER INVALID! %s "\
79 "should be called before %s!\n",
80 sym_p, sym_q);
81 }
82 }
83}
84#else
85inline void check_iommu_entries(struct iommu_table_entry *start,
86 struct iommu_table_entry *finish)
87{
88}
89#endif
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index a5bc528d4328..8f972cbddef0 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -10,7 +10,8 @@
10#include <asm/iommu.h> 10#include <asm/iommu.h>
11#include <asm/swiotlb.h> 11#include <asm/swiotlb.h>
12#include <asm/dma.h> 12#include <asm/dma.h>
13 13#include <asm/xen/swiotlb-xen.h>
14#include <asm/iommu_table.h>
14int swiotlb __read_mostly; 15int swiotlb __read_mostly;
15 16
16static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size, 17static void *x86_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
@@ -41,25 +42,42 @@ static struct dma_map_ops swiotlb_dma_ops = {
41}; 42};
42 43
43/* 44/*
44 * pci_swiotlb_detect - set swiotlb to 1 if necessary 45 * pci_swiotlb_detect_override - set swiotlb to 1 if necessary
45 * 46 *
46 * This returns non-zero if we are forced to use swiotlb (by the boot 47 * This returns non-zero if we are forced to use swiotlb (by the boot
47 * option). 48 * option).
48 */ 49 */
49int __init pci_swiotlb_detect(void) 50int __init pci_swiotlb_detect_override(void)
50{ 51{
51 int use_swiotlb = swiotlb | swiotlb_force; 52 int use_swiotlb = swiotlb | swiotlb_force;
52 53
54 if (swiotlb_force)
55 swiotlb = 1;
56
57 return use_swiotlb;
58}
59IOMMU_INIT_FINISH(pci_swiotlb_detect_override,
60 pci_xen_swiotlb_detect,
61 pci_swiotlb_init,
62 pci_swiotlb_late_init);
63
64/*
65 * if 4GB or more detected (and iommu=off not set) return 1
66 * and set swiotlb to 1.
67 */
68int __init pci_swiotlb_detect_4gb(void)
69{
53 /* don't initialize swiotlb if iommu=off (no_iommu=1) */ 70 /* don't initialize swiotlb if iommu=off (no_iommu=1) */
54#ifdef CONFIG_X86_64 71#ifdef CONFIG_X86_64
55 if (!no_iommu && max_pfn > MAX_DMA32_PFN) 72 if (!no_iommu && max_pfn > MAX_DMA32_PFN)
56 swiotlb = 1; 73 swiotlb = 1;
57#endif 74#endif
58 if (swiotlb_force) 75 return swiotlb;
59 swiotlb = 1;
60
61 return use_swiotlb;
62} 76}
77IOMMU_INIT(pci_swiotlb_detect_4gb,
78 pci_swiotlb_detect_override,
79 pci_swiotlb_init,
80 pci_swiotlb_late_init);
63 81
64void __init pci_swiotlb_init(void) 82void __init pci_swiotlb_init(void)
65{ 83{
@@ -68,3 +86,15 @@ void __init pci_swiotlb_init(void)
68 dma_ops = &swiotlb_dma_ops; 86 dma_ops = &swiotlb_dma_ops;
69 } 87 }
70} 88}
89
90void __init pci_swiotlb_late_init(void)
91{
92 /* An IOMMU turned us off. */
93 if (!swiotlb)
94 swiotlb_free();
95 else {
96 printk(KERN_INFO "PCI-DMA: "
97 "Using software bounce buffering for IO (SWIOTLB)\n");
98 swiotlb_print_info();
99 }
100}
diff --git a/arch/x86/kernel/pmtimer_64.c b/arch/x86/kernel/pmtimer_64.c
deleted file mode 100644
index b112406f1996..000000000000
--- a/arch/x86/kernel/pmtimer_64.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/* Ported over from i386 by AK, original copyright was:
2 *
3 * (C) Dominik Brodowski <linux@brodo.de> 2003
4 *
5 * Driver to use the Power Management Timer (PMTMR) available in some
6 * southbridges as primary timing source for the Linux kernel.
7 *
8 * Based on parts of linux/drivers/acpi/hardware/hwtimer.c, timer_pit.c,
9 * timer_hpet.c, and on Arjan van de Ven's implementation for 2.4.
10 *
11 * This file is licensed under the GPL v2.
12 *
13 * Dropped all the hardware bug workarounds for now. Hopefully they
14 * are not needed on 64bit chipsets.
15 */
16
17#include <linux/jiffies.h>
18#include <linux/kernel.h>
19#include <linux/time.h>
20#include <linux/init.h>
21#include <linux/cpumask.h>
22#include <linux/acpi_pmtmr.h>
23
24#include <asm/io.h>
25#include <asm/proto.h>
26#include <asm/msr.h>
27#include <asm/vsyscall.h>
28
29static inline u32 cyc2us(u32 cycles)
30{
31 /* The Power Management Timer ticks at 3.579545 ticks per microsecond.
32 * 1 / PM_TIMER_FREQUENCY == 0.27936511 =~ 286/1024 [error: 0.024%]
33 *
34 * Even with HZ = 100, delta is at maximum 35796 ticks, so it can
35 * easily be multiplied with 286 (=0x11E) without having to fear
36 * u32 overflows.
37 */
38 cycles *= 286;
39 return (cycles >> 10);
40}
41
42static unsigned pmtimer_wait_tick(void)
43{
44 u32 a, b;
45 for (a = b = inl(pmtmr_ioport) & ACPI_PM_MASK;
46 a == b;
47 b = inl(pmtmr_ioport) & ACPI_PM_MASK)
48 cpu_relax();
49 return b;
50}
51
52/* note: wait time is rounded up to one tick */
53void pmtimer_wait(unsigned us)
54{
55 u32 a, b;
56 a = pmtimer_wait_tick();
57 do {
58 b = inl(pmtmr_ioport);
59 cpu_relax();
60 } while (cyc2us(b - a) < us);
61}
62
63static int __init nopmtimer_setup(char *s)
64{
65 pmtmr_ioport = 0;
66 return 1;
67}
68
69__setup("nopmtimer", nopmtimer_setup);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 3d9ea531ddd1..b3d7a3a04f38 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -424,7 +424,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
424 load_TLS(next, cpu); 424 load_TLS(next, cpu);
425 425
426 /* Must be after DS reload */ 426 /* Must be after DS reload */
427 unlazy_fpu(prev_p); 427 __unlazy_fpu(prev_p);
428 428
429 /* Make sure cpu is ready for new context */ 429 /* Make sure cpu is ready for new context */
430 if (preload_fpu) 430 if (preload_fpu)
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 239427ca02af..bab3b9e6f66d 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -82,7 +82,8 @@ static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
82static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow) 82static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
83{ 83{
84 u64 delta = native_read_tsc() - shadow->tsc_timestamp; 84 u64 delta = native_read_tsc() - shadow->tsc_timestamp;
85 return scale_delta(delta, shadow->tsc_to_nsec_mul, shadow->tsc_shift); 85 return pvclock_scale_delta(delta, shadow->tsc_to_nsec_mul,
86 shadow->tsc_shift);
86} 87}
87 88
88/* 89/*
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 939b9e98245f..8bbe8c56916d 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -344,6 +344,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
344 vt8237_force_enable_hpet); 344 vt8237_force_enable_hpet);
345DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, 345DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
346 vt8237_force_enable_hpet); 346 vt8237_force_enable_hpet);
347DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700,
348 vt8237_force_enable_hpet);
347 349
348static void ati_force_hpet_resume(void) 350static void ati_force_hpet_resume(void)
349{ 351{
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index e3af342fe83a..f7f53dcd3e0a 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -84,7 +84,7 @@ static int __init reboot_setup(char *str)
84 } 84 }
85 /* we will leave sorting out the final value 85 /* we will leave sorting out the final value
86 when we are ready to reboot, since we might not 86 when we are ready to reboot, since we might not
87 have set up boot_cpu_id or smp_num_cpu */ 87 have detected BSP APIC ID or smp_num_cpu */
88 break; 88 break;
89#endif /* CONFIG_SMP */ 89#endif /* CONFIG_SMP */
90 90
@@ -371,16 +371,10 @@ void machine_real_restart(const unsigned char *code, int length)
371 CMOS_WRITE(0x00, 0x8f); 371 CMOS_WRITE(0x00, 0x8f);
372 spin_unlock(&rtc_lock); 372 spin_unlock(&rtc_lock);
373 373
374 /* Remap the kernel at virtual address zero, as well as offset zero
375 from the kernel segment. This assumes the kernel segment starts at
376 virtual address PAGE_OFFSET. */
377 memcpy(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
378 sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS);
379
380 /* 374 /*
381 * Use `swapper_pg_dir' as our page directory. 375 * Switch back to the initial page table.
382 */ 376 */
383 load_cr3(swapper_pg_dir); 377 load_cr3(initial_page_table);
384 378
385 /* Write 0x1234 to absolute memory location 0x472. The BIOS reads 379 /* Write 0x1234 to absolute memory location 0x472. The BIOS reads
386 this on booting to tell it to "Bypass memory test (also warm 380 this on booting to tell it to "Bypass memory test (also warm
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index c3a4fbb2b996..95a32746fbf9 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -31,6 +31,7 @@
31#include <linux/apm_bios.h> 31#include <linux/apm_bios.h>
32#include <linux/initrd.h> 32#include <linux/initrd.h>
33#include <linux/bootmem.h> 33#include <linux/bootmem.h>
34#include <linux/memblock.h>
34#include <linux/seq_file.h> 35#include <linux/seq_file.h>
35#include <linux/console.h> 36#include <linux/console.h>
36#include <linux/mca.h> 37#include <linux/mca.h>
@@ -83,7 +84,6 @@
83#include <asm/dmi.h> 84#include <asm/dmi.h>
84#include <asm/io_apic.h> 85#include <asm/io_apic.h>
85#include <asm/ist.h> 86#include <asm/ist.h>
86#include <asm/vmi.h>
87#include <asm/setup_arch.h> 87#include <asm/setup_arch.h>
88#include <asm/bios_ebda.h> 88#include <asm/bios_ebda.h>
89#include <asm/cacheflush.h> 89#include <asm/cacheflush.h>
@@ -107,11 +107,12 @@
107#include <asm/percpu.h> 107#include <asm/percpu.h>
108#include <asm/topology.h> 108#include <asm/topology.h>
109#include <asm/apicdef.h> 109#include <asm/apicdef.h>
110#include <asm/k8.h> 110#include <asm/amd_nb.h>
111#ifdef CONFIG_X86_64 111#ifdef CONFIG_X86_64
112#include <asm/numa_64.h> 112#include <asm/numa_64.h>
113#endif 113#endif
114#include <asm/mce.h> 114#include <asm/mce.h>
115#include <asm/alternative.h>
115 116
116/* 117/*
117 * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries. 118 * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
@@ -125,7 +126,6 @@ unsigned long max_pfn_mapped;
125RESERVE_BRK(dmi_alloc, 65536); 126RESERVE_BRK(dmi_alloc, 65536);
126#endif 127#endif
127 128
128unsigned int boot_cpu_id __read_mostly;
129 129
130static __initdata unsigned long _brk_start = (unsigned long)__brk_base; 130static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
131unsigned long _brk_end = (unsigned long)__brk_base; 131unsigned long _brk_end = (unsigned long)__brk_base;
@@ -302,7 +302,7 @@ static inline void init_gbpages(void)
302static void __init reserve_brk(void) 302static void __init reserve_brk(void)
303{ 303{
304 if (_brk_end > _brk_start) 304 if (_brk_end > _brk_start)
305 reserve_early(__pa(_brk_start), __pa(_brk_end), "BRK"); 305 memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK");
306 306
307 /* Mark brk area as locked down and no longer taking any 307 /* Mark brk area as locked down and no longer taking any
308 new allocations */ 308 new allocations */
@@ -324,17 +324,16 @@ static void __init relocate_initrd(void)
324 char *p, *q; 324 char *p, *q;
325 325
326 /* We need to move the initrd down into lowmem */ 326 /* We need to move the initrd down into lowmem */
327 ramdisk_here = find_e820_area(0, end_of_lowmem, area_size, 327 ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size,
328 PAGE_SIZE); 328 PAGE_SIZE);
329 329
330 if (ramdisk_here == -1ULL) 330 if (ramdisk_here == MEMBLOCK_ERROR)
331 panic("Cannot find place for new RAMDISK of size %lld\n", 331 panic("Cannot find place for new RAMDISK of size %lld\n",
332 ramdisk_size); 332 ramdisk_size);
333 333
334 /* Note: this includes all the lowmem currently occupied by 334 /* Note: this includes all the lowmem currently occupied by
335 the initrd, we rely on that fact to keep the data intact. */ 335 the initrd, we rely on that fact to keep the data intact. */
336 reserve_early(ramdisk_here, ramdisk_here + area_size, 336 memblock_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK");
337 "NEW RAMDISK");
338 initrd_start = ramdisk_here + PAGE_OFFSET; 337 initrd_start = ramdisk_here + PAGE_OFFSET;
339 initrd_end = initrd_start + ramdisk_size; 338 initrd_end = initrd_start + ramdisk_size;
340 printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", 339 printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
@@ -390,7 +389,7 @@ static void __init reserve_initrd(void)
390 initrd_start = 0; 389 initrd_start = 0;
391 390
392 if (ramdisk_size >= (end_of_lowmem>>1)) { 391 if (ramdisk_size >= (end_of_lowmem>>1)) {
393 free_early(ramdisk_image, ramdisk_end); 392 memblock_x86_free_range(ramdisk_image, ramdisk_end);
394 printk(KERN_ERR "initrd too large to handle, " 393 printk(KERN_ERR "initrd too large to handle, "
395 "disabling initrd\n"); 394 "disabling initrd\n");
396 return; 395 return;
@@ -413,7 +412,7 @@ static void __init reserve_initrd(void)
413 412
414 relocate_initrd(); 413 relocate_initrd();
415 414
416 free_early(ramdisk_image, ramdisk_end); 415 memblock_x86_free_range(ramdisk_image, ramdisk_end);
417} 416}
418#else 417#else
419static void __init reserve_initrd(void) 418static void __init reserve_initrd(void)
@@ -469,7 +468,7 @@ static void __init e820_reserve_setup_data(void)
469 e820_print_map("reserve setup_data"); 468 e820_print_map("reserve setup_data");
470} 469}
471 470
472static void __init reserve_early_setup_data(void) 471static void __init memblock_x86_reserve_range_setup_data(void)
473{ 472{
474 struct setup_data *data; 473 struct setup_data *data;
475 u64 pa_data; 474 u64 pa_data;
@@ -481,7 +480,7 @@ static void __init reserve_early_setup_data(void)
481 while (pa_data) { 480 while (pa_data) {
482 data = early_memremap(pa_data, sizeof(*data)); 481 data = early_memremap(pa_data, sizeof(*data));
483 sprintf(buf, "setup data %x", data->type); 482 sprintf(buf, "setup data %x", data->type);
484 reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf); 483 memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf);
485 pa_data = data->next; 484 pa_data = data->next;
486 early_iounmap(data, sizeof(*data)); 485 early_iounmap(data, sizeof(*data));
487 } 486 }
@@ -502,6 +501,7 @@ static inline unsigned long long get_total_mem(void)
502 return total << PAGE_SHIFT; 501 return total << PAGE_SHIFT;
503} 502}
504 503
504#define DEFAULT_BZIMAGE_ADDR_MAX 0x37FFFFFF
505static void __init reserve_crashkernel(void) 505static void __init reserve_crashkernel(void)
506{ 506{
507 unsigned long long total_mem; 507 unsigned long long total_mem;
@@ -519,23 +519,27 @@ static void __init reserve_crashkernel(void)
519 if (crash_base <= 0) { 519 if (crash_base <= 0) {
520 const unsigned long long alignment = 16<<20; /* 16M */ 520 const unsigned long long alignment = 16<<20; /* 16M */
521 521
522 crash_base = find_e820_area(alignment, ULONG_MAX, crash_size, 522 /*
523 alignment); 523 * kexec want bzImage is below DEFAULT_BZIMAGE_ADDR_MAX
524 if (crash_base == -1ULL) { 524 */
525 crash_base = memblock_find_in_range(alignment,
526 DEFAULT_BZIMAGE_ADDR_MAX, crash_size, alignment);
527
528 if (crash_base == MEMBLOCK_ERROR) {
525 pr_info("crashkernel reservation failed - No suitable area found.\n"); 529 pr_info("crashkernel reservation failed - No suitable area found.\n");
526 return; 530 return;
527 } 531 }
528 } else { 532 } else {
529 unsigned long long start; 533 unsigned long long start;
530 534
531 start = find_e820_area(crash_base, ULONG_MAX, crash_size, 535 start = memblock_find_in_range(crash_base,
532 1<<20); 536 crash_base + crash_size, crash_size, 1<<20);
533 if (start != crash_base) { 537 if (start != crash_base) {
534 pr_info("crashkernel reservation failed - memory is in use.\n"); 538 pr_info("crashkernel reservation failed - memory is in use.\n");
535 return; 539 return;
536 } 540 }
537 } 541 }
538 reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL"); 542 memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL");
539 543
540 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " 544 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
541 "for crashkernel (System RAM: %ldMB)\n", 545 "for crashkernel (System RAM: %ldMB)\n",
@@ -615,82 +619,10 @@ static __init void reserve_ibft_region(void)
615 addr = find_ibft_region(&size); 619 addr = find_ibft_region(&size);
616 620
617 if (size) 621 if (size)
618 reserve_early_overlap_ok(addr, addr + size, "ibft"); 622 memblock_x86_reserve_range(addr, addr + size, "* ibft");
619} 623}
620 624
621#ifdef CONFIG_X86_RESERVE_LOW_64K 625static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
622static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
623{
624 printk(KERN_NOTICE
625 "%s detected: BIOS may corrupt low RAM, working around it.\n",
626 d->ident);
627
628 e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
629 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
630
631 return 0;
632}
633#endif
634
635/* List of systems that have known low memory corruption BIOS problems */
636static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
637#ifdef CONFIG_X86_RESERVE_LOW_64K
638 {
639 .callback = dmi_low_memory_corruption,
640 .ident = "AMI BIOS",
641 .matches = {
642 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
643 },
644 },
645 {
646 .callback = dmi_low_memory_corruption,
647 .ident = "Phoenix BIOS",
648 .matches = {
649 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
650 },
651 },
652 {
653 .callback = dmi_low_memory_corruption,
654 .ident = "Phoenix/MSC BIOS",
655 .matches = {
656 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix/MSC"),
657 },
658 },
659 /*
660 * AMI BIOS with low memory corruption was found on Intel DG45ID and
661 * DG45FC boards.
662 * It has a different DMI_BIOS_VENDOR = "Intel Corp.", for now we will
663 * match only DMI_BOARD_NAME and see if there is more bad products
664 * with this vendor.
665 */
666 {
667 .callback = dmi_low_memory_corruption,
668 .ident = "AMI BIOS",
669 .matches = {
670 DMI_MATCH(DMI_BOARD_NAME, "DG45ID"),
671 },
672 },
673 {
674 .callback = dmi_low_memory_corruption,
675 .ident = "AMI BIOS",
676 .matches = {
677 DMI_MATCH(DMI_BOARD_NAME, "DG45FC"),
678 },
679 },
680 /*
681 * The Dell Inspiron Mini 1012 has DMI_BIOS_VENDOR = "Dell Inc.", so
682 * match on the product name.
683 */
684 {
685 .callback = dmi_low_memory_corruption,
686 .ident = "Phoenix BIOS",
687 .matches = {
688 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 1012"),
689 },
690 },
691#endif
692 {}
693};
694 626
695static void __init trim_bios_range(void) 627static void __init trim_bios_range(void)
696{ 628{
@@ -698,8 +630,14 @@ static void __init trim_bios_range(void)
698 * A special case is the first 4Kb of memory; 630 * A special case is the first 4Kb of memory;
699 * This is a BIOS owned area, not kernel ram, but generally 631 * This is a BIOS owned area, not kernel ram, but generally
700 * not listed as such in the E820 table. 632 * not listed as such in the E820 table.
633 *
634 * This typically reserves additional memory (64KiB by default)
635 * since some BIOSes are known to corrupt low memory. See the
636 * Kconfig help text for X86_RESERVE_LOW.
701 */ 637 */
702 e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED); 638 e820_update_range(0, ALIGN(reserve_low, PAGE_SIZE),
639 E820_RAM, E820_RESERVED);
640
703 /* 641 /*
704 * special case: Some BIOSen report the PC BIOS 642 * special case: Some BIOSen report the PC BIOS
705 * area (640->1Mb) as ram even though it is not. 643 * area (640->1Mb) as ram even though it is not.
@@ -709,6 +647,37 @@ static void __init trim_bios_range(void)
709 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 647 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
710} 648}
711 649
650static int __init parse_reservelow(char *p)
651{
652 unsigned long long size;
653
654 if (!p)
655 return -EINVAL;
656
657 size = memparse(p, &p);
658
659 if (size < 4096)
660 size = 4096;
661
662 if (size > 640*1024)
663 size = 640*1024;
664
665 reserve_low = size;
666
667 return 0;
668}
669
670early_param("reservelow", parse_reservelow);
671
672static u64 __init get_max_mapped(void)
673{
674 u64 end = max_pfn_mapped;
675
676 end <<= PAGE_SHIFT;
677
678 return end;
679}
680
712/* 681/*
713 * Determine if we were loaded by an EFI loader. If so, then we have also been 682 * Determine if we were loaded by an EFI loader. If so, then we have also been
714 * passed the efi memmap, systab, etc., so we should use these data structures 683 * passed the efi memmap, systab, etc., so we should use these data structures
@@ -726,18 +695,30 @@ void __init setup_arch(char **cmdline_p)
726{ 695{
727 int acpi = 0; 696 int acpi = 0;
728 int k8 = 0; 697 int k8 = 0;
698 unsigned long flags;
729 699
730#ifdef CONFIG_X86_32 700#ifdef CONFIG_X86_32
731 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); 701 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
732 visws_early_detect(); 702 visws_early_detect();
703
704 /*
705 * copy kernel address range established so far and switch
706 * to the proper swapper page table
707 */
708 clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
709 initial_page_table + KERNEL_PGD_BOUNDARY,
710 KERNEL_PGD_PTRS);
711
712 load_cr3(swapper_pg_dir);
713 __flush_tlb_all();
733#else 714#else
734 printk(KERN_INFO "Command line: %s\n", boot_command_line); 715 printk(KERN_INFO "Command line: %s\n", boot_command_line);
735#endif 716#endif
736 717
737 /* VMI may relocate the fixmap; do this before touching ioremap area */ 718 /*
738 vmi_init(); 719 * If we have OLPC OFW, we might end up relocating the fixmap due to
739 720 * reserve_top(), so do this before touching the ioremap area.
740 /* OFW also may relocate the fixmap */ 721 */
741 olpc_ofw_detect(); 722 olpc_ofw_detect();
742 723
743 early_trap_init(); 724 early_trap_init();
@@ -782,7 +763,7 @@ void __init setup_arch(char **cmdline_p)
782#endif 763#endif
783 4)) { 764 4)) {
784 efi_enabled = 1; 765 efi_enabled = 1;
785 efi_reserve_early(); 766 efi_memblock_x86_reserve_range();
786 } 767 }
787#endif 768#endif
788 769
@@ -838,11 +819,8 @@ void __init setup_arch(char **cmdline_p)
838 819
839 x86_report_nx(); 820 x86_report_nx();
840 821
841 /* Must be before kernel pagetables are setup */
842 vmi_activate();
843
844 /* after early param, so could get panic from serial */ 822 /* after early param, so could get panic from serial */
845 reserve_early_setup_data(); 823 memblock_x86_reserve_range_setup_data();
846 824
847 if (acpi_mps_check()) { 825 if (acpi_mps_check()) {
848#ifdef CONFIG_X86_LOCAL_APIC 826#ifdef CONFIG_X86_LOCAL_APIC
@@ -863,8 +841,6 @@ void __init setup_arch(char **cmdline_p)
863 841
864 dmi_scan_machine(); 842 dmi_scan_machine();
865 843
866 dmi_check_system(bad_bios_dmi_table);
867
868 /* 844 /*
869 * VMware detection requires dmi to be available, so this 845 * VMware detection requires dmi to be available, so this
870 * needs to be done after dmi_scan_machine, for the BP. 846 * needs to be done after dmi_scan_machine, for the BP.
@@ -897,8 +873,6 @@ void __init setup_arch(char **cmdline_p)
897 */ 873 */
898 max_pfn = e820_end_of_ram_pfn(); 874 max_pfn = e820_end_of_ram_pfn();
899 875
900 /* preallocate 4k for mptable mpc */
901 early_reserve_e820_mpc_new();
902 /* update e820 for memory not covered by WB MTRRs */ 876 /* update e820 for memory not covered by WB MTRRs */
903 mtrr_bp_init(); 877 mtrr_bp_init();
904 if (mtrr_trim_uncached_memory(max_pfn)) 878 if (mtrr_trim_uncached_memory(max_pfn))
@@ -920,18 +894,8 @@ void __init setup_arch(char **cmdline_p)
920 max_low_pfn = max_pfn; 894 max_low_pfn = max_pfn;
921 895
922 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; 896 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
923 max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
924#endif 897#endif
925 898
926#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
927 setup_bios_corruption_check();
928#endif
929
930 printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n",
931 max_pfn_mapped<<PAGE_SHIFT);
932
933 reserve_brk();
934
935 /* 899 /*
936 * Find and reserve possible boot-time SMP configuration: 900 * Find and reserve possible boot-time SMP configuration:
937 */ 901 */
@@ -939,6 +903,26 @@ void __init setup_arch(char **cmdline_p)
939 903
940 reserve_ibft_region(); 904 reserve_ibft_region();
941 905
906 /*
907 * Need to conclude brk, before memblock_x86_fill()
908 * it could use memblock_find_in_range, could overlap with
909 * brk area.
910 */
911 reserve_brk();
912
913 memblock.current_limit = get_max_mapped();
914 memblock_x86_fill();
915
916 /* preallocate 4k for mptable mpc */
917 early_reserve_e820_mpc_new();
918
919#ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
920 setup_bios_corruption_check();
921#endif
922
923 printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n",
924 max_pfn_mapped<<PAGE_SHIFT);
925
942 reserve_trampoline_memory(); 926 reserve_trampoline_memory();
943 927
944#ifdef CONFIG_ACPI_SLEEP 928#ifdef CONFIG_ACPI_SLEEP
@@ -962,6 +946,7 @@ void __init setup_arch(char **cmdline_p)
962 max_low_pfn = max_pfn; 946 max_low_pfn = max_pfn;
963 } 947 }
964#endif 948#endif
949 memblock.current_limit = get_max_mapped();
965 950
966 /* 951 /*
967 * NOTE: On x86-32, only from this point on, fixmaps are ready for use. 952 * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
@@ -1000,10 +985,7 @@ void __init setup_arch(char **cmdline_p)
1000#endif 985#endif
1001 986
1002 initmem_init(0, max_pfn, acpi, k8); 987 initmem_init(0, max_pfn, acpi, k8);
1003#ifndef CONFIG_NO_BOOTMEM 988 memblock_find_dma_reserve();
1004 early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
1005#endif
1006
1007 dma32_reserve_bootmem(); 989 dma32_reserve_bootmem();
1008 990
1009#ifdef CONFIG_KVM_CLOCK 991#ifdef CONFIG_KVM_CLOCK
@@ -1014,7 +996,12 @@ void __init setup_arch(char **cmdline_p)
1014 paging_init(); 996 paging_init();
1015 x86_init.paging.pagetable_setup_done(swapper_pg_dir); 997 x86_init.paging.pagetable_setup_done(swapper_pg_dir);
1016 998
1017 setup_trampoline_page_table(); 999#ifdef CONFIG_X86_32
1000 /* sync back kernel address range */
1001 clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
1002 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
1003 KERNEL_PGD_PTRS);
1004#endif
1018 1005
1019 tboot_probe(); 1006 tboot_probe();
1020 1007
@@ -1071,6 +1058,10 @@ void __init setup_arch(char **cmdline_p)
1071 x86_init.oem.banner(); 1058 x86_init.oem.banner();
1072 1059
1073 mcheck_init(); 1060 mcheck_init();
1061
1062 local_irq_save(flags);
1063 arch_init_ideal_nop5();
1064 local_irq_restore(flags);
1074} 1065}
1075 1066
1076#ifdef CONFIG_X86_32 1067#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index a60df9ae6454..002b79685f73 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -131,13 +131,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
131 131
132static void __init pcpu_fc_free(void *ptr, size_t size) 132static void __init pcpu_fc_free(void *ptr, size_t size)
133{ 133{
134#ifdef CONFIG_NO_BOOTMEM
135 u64 start = __pa(ptr);
136 u64 end = start + size;
137 free_early_partial(start, end);
138#else
139 free_bootmem(__pa(ptr), size); 134 free_bootmem(__pa(ptr), size);
140#endif
141} 135}
142 136
143static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) 137static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
@@ -253,7 +247,7 @@ void __init setup_per_cpu_areas(void)
253 * Up to this point, the boot CPU has been using .init.data 247 * Up to this point, the boot CPU has been using .init.data
254 * area. Reload any changed state for the boot CPU. 248 * area. Reload any changed state for the boot CPU.
255 */ 249 */
256 if (cpu == boot_cpu_id) 250 if (!cpu)
257 switch_to_new_gdt(cpu); 251 switch_to_new_gdt(cpu);
258 } 252 }
259 253
diff --git a/arch/x86/kernel/sfi.c b/arch/x86/kernel/sfi.c
index cb22acf3ed09..dd4c281ffe57 100644
--- a/arch/x86/kernel/sfi.c
+++ b/arch/x86/kernel/sfi.c
@@ -34,7 +34,7 @@
34#ifdef CONFIG_X86_LOCAL_APIC 34#ifdef CONFIG_X86_LOCAL_APIC
35static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; 35static unsigned long sfi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
36 36
37void __init mp_sfi_register_lapic_address(unsigned long address) 37static void __init mp_sfi_register_lapic_address(unsigned long address)
38{ 38{
39 mp_lapic_addr = address; 39 mp_lapic_addr = address;
40 40
@@ -46,7 +46,7 @@ void __init mp_sfi_register_lapic_address(unsigned long address)
46} 46}
47 47
48/* All CPUs enumerated by SFI must be present and enabled */ 48/* All CPUs enumerated by SFI must be present and enabled */
49void __cpuinit mp_sfi_register_lapic(u8 id) 49static void __cpuinit mp_sfi_register_lapic(u8 id)
50{ 50{
51 if (MAX_APICS - id <= 0) { 51 if (MAX_APICS - id <= 0) {
52 pr_warning("Processor #%d invalid (max %d)\n", 52 pr_warning("Processor #%d invalid (max %d)\n",
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 8b3bfc4dd708..6af118511b4a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -62,7 +62,7 @@
62#include <asm/pgtable.h> 62#include <asm/pgtable.h>
63#include <asm/tlbflush.h> 63#include <asm/tlbflush.h>
64#include <asm/mtrr.h> 64#include <asm/mtrr.h>
65#include <asm/vmi.h> 65#include <asm/mwait.h>
66#include <asm/apic.h> 66#include <asm/apic.h>
67#include <asm/setup.h> 67#include <asm/setup.h>
68#include <asm/uv/uv.h> 68#include <asm/uv/uv.h>
@@ -299,23 +299,16 @@ notrace static void __cpuinit start_secondary(void *unused)
299 * fragile that we want to limit the things done here to the 299 * fragile that we want to limit the things done here to the
300 * most necessary things. 300 * most necessary things.
301 */ 301 */
302 cpu_init();
303 preempt_disable();
304 smp_callin();
302 305
303#ifdef CONFIG_X86_32 306#ifdef CONFIG_X86_32
304 /* 307 /* switch away from the initial page table */
305 * Switch away from the trampoline page-table
306 *
307 * Do this before cpu_init() because it needs to access per-cpu
308 * data which may not be mapped in the trampoline page-table.
309 */
310 load_cr3(swapper_pg_dir); 308 load_cr3(swapper_pg_dir);
311 __flush_tlb_all(); 309 __flush_tlb_all();
312#endif 310#endif
313 311
314 vmi_bringup();
315 cpu_init();
316 preempt_disable();
317 smp_callin();
318
319 /* otherwise gcc will move up smp_processor_id before the cpu_init */ 312 /* otherwise gcc will move up smp_processor_id before the cpu_init */
320 barrier(); 313 barrier();
321 /* 314 /*
@@ -324,9 +317,9 @@ notrace static void __cpuinit start_secondary(void *unused)
324 check_tsc_sync_target(); 317 check_tsc_sync_target();
325 318
326 if (nmi_watchdog == NMI_IO_APIC) { 319 if (nmi_watchdog == NMI_IO_APIC) {
327 legacy_pic->chip->mask(0); 320 legacy_pic->mask(0);
328 enable_NMI_through_LVT0(); 321 enable_NMI_through_LVT0();
329 legacy_pic->chip->unmask(0); 322 legacy_pic->unmask(0);
330 } 323 }
331 324
332 /* This must be done before setting cpu_online_mask */ 325 /* This must be done before setting cpu_online_mask */
@@ -397,6 +390,19 @@ void __cpuinit smp_store_cpu_info(int id)
397 identify_secondary_cpu(c); 390 identify_secondary_cpu(c);
398} 391}
399 392
393static void __cpuinit link_thread_siblings(int cpu1, int cpu2)
394{
395 struct cpuinfo_x86 *c1 = &cpu_data(cpu1);
396 struct cpuinfo_x86 *c2 = &cpu_data(cpu2);
397
398 cpumask_set_cpu(cpu1, cpu_sibling_mask(cpu2));
399 cpumask_set_cpu(cpu2, cpu_sibling_mask(cpu1));
400 cpumask_set_cpu(cpu1, cpu_core_mask(cpu2));
401 cpumask_set_cpu(cpu2, cpu_core_mask(cpu1));
402 cpumask_set_cpu(cpu1, c2->llc_shared_map);
403 cpumask_set_cpu(cpu2, c1->llc_shared_map);
404}
405
400 406
401void __cpuinit set_cpu_sibling_map(int cpu) 407void __cpuinit set_cpu_sibling_map(int cpu)
402{ 408{
@@ -409,14 +415,13 @@ void __cpuinit set_cpu_sibling_map(int cpu)
409 for_each_cpu(i, cpu_sibling_setup_mask) { 415 for_each_cpu(i, cpu_sibling_setup_mask) {
410 struct cpuinfo_x86 *o = &cpu_data(i); 416 struct cpuinfo_x86 *o = &cpu_data(i);
411 417
412 if (c->phys_proc_id == o->phys_proc_id && 418 if (cpu_has(c, X86_FEATURE_TOPOEXT)) {
413 c->cpu_core_id == o->cpu_core_id) { 419 if (c->phys_proc_id == o->phys_proc_id &&
414 cpumask_set_cpu(i, cpu_sibling_mask(cpu)); 420 c->compute_unit_id == o->compute_unit_id)
415 cpumask_set_cpu(cpu, cpu_sibling_mask(i)); 421 link_thread_siblings(cpu, i);
416 cpumask_set_cpu(i, cpu_core_mask(cpu)); 422 } else if (c->phys_proc_id == o->phys_proc_id &&
417 cpumask_set_cpu(cpu, cpu_core_mask(i)); 423 c->cpu_core_id == o->cpu_core_id) {
418 cpumask_set_cpu(i, c->llc_shared_map); 424 link_thread_siblings(cpu, i);
419 cpumask_set_cpu(cpu, o->llc_shared_map);
420 } 425 }
421 } 426 }
422 } else { 427 } else {
@@ -774,7 +779,6 @@ do_rest:
774#ifdef CONFIG_X86_32 779#ifdef CONFIG_X86_32
775 /* Stack for startup_32 can be just as for start_secondary onwards */ 780 /* Stack for startup_32 can be just as for start_secondary onwards */
776 irq_ctx_init(cpu); 781 irq_ctx_init(cpu);
777 initial_page_table = __pa(&trampoline_pg_dir);
778#else 782#else
779 clear_tsk_thread_flag(c_idle.idle, TIF_FORK); 783 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
780 initial_gs = per_cpu_offset(cpu); 784 initial_gs = per_cpu_offset(cpu);
@@ -923,7 +927,6 @@ int __cpuinit native_cpu_up(unsigned int cpu)
923 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 927 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
924 928
925 err = do_boot_cpu(apicid, cpu); 929 err = do_boot_cpu(apicid, cpu);
926
927 if (err) { 930 if (err) {
928 pr_debug("do_boot_cpu failed %d\n", err); 931 pr_debug("do_boot_cpu failed %d\n", err);
929 return -EIO; 932 return -EIO;
@@ -1109,8 +1112,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1109 } 1112 }
1110 set_cpu_sibling_map(0); 1113 set_cpu_sibling_map(0);
1111 1114
1112 enable_IR_x2apic();
1113 default_setup_apic_routing();
1114 1115
1115 if (smp_sanity_check(max_cpus) < 0) { 1116 if (smp_sanity_check(max_cpus) < 0) {
1116 printk(KERN_INFO "SMP disabled\n"); 1117 printk(KERN_INFO "SMP disabled\n");
@@ -1118,6 +1119,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1118 goto out; 1119 goto out;
1119 } 1120 }
1120 1121
1122 default_setup_apic_routing();
1123
1121 preempt_disable(); 1124 preempt_disable();
1122 if (read_apic_id() != boot_cpu_physical_apicid) { 1125 if (read_apic_id() != boot_cpu_physical_apicid) {
1123 panic("Boot APIC ID in local APIC unexpected (%d vs %d)", 1126 panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
@@ -1383,11 +1386,88 @@ void play_dead_common(void)
1383 local_irq_disable(); 1386 local_irq_disable();
1384} 1387}
1385 1388
1389/*
1390 * We need to flush the caches before going to sleep, lest we have
1391 * dirty data in our caches when we come back up.
1392 */
1393static inline void mwait_play_dead(void)
1394{
1395 unsigned int eax, ebx, ecx, edx;
1396 unsigned int highest_cstate = 0;
1397 unsigned int highest_subcstate = 0;
1398 int i;
1399 void *mwait_ptr;
1400
1401 if (!cpu_has(&current_cpu_data, X86_FEATURE_MWAIT))
1402 return;
1403 if (!cpu_has(&current_cpu_data, X86_FEATURE_CLFLSH))
1404 return;
1405 if (current_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
1406 return;
1407
1408 eax = CPUID_MWAIT_LEAF;
1409 ecx = 0;
1410 native_cpuid(&eax, &ebx, &ecx, &edx);
1411
1412 /*
1413 * eax will be 0 if EDX enumeration is not valid.
1414 * Initialized below to cstate, sub_cstate value when EDX is valid.
1415 */
1416 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED)) {
1417 eax = 0;
1418 } else {
1419 edx >>= MWAIT_SUBSTATE_SIZE;
1420 for (i = 0; i < 7 && edx; i++, edx >>= MWAIT_SUBSTATE_SIZE) {
1421 if (edx & MWAIT_SUBSTATE_MASK) {
1422 highest_cstate = i;
1423 highest_subcstate = edx & MWAIT_SUBSTATE_MASK;
1424 }
1425 }
1426 eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
1427 (highest_subcstate - 1);
1428 }
1429
1430 /*
1431 * This should be a memory location in a cache line which is
1432 * unlikely to be touched by other processors. The actual
1433 * content is immaterial as it is not actually modified in any way.
1434 */
1435 mwait_ptr = &current_thread_info()->flags;
1436
1437 wbinvd();
1438
1439 while (1) {
1440 /*
1441 * The CLFLUSH is a workaround for erratum AAI65 for
1442 * the Xeon 7400 series. It's not clear it is actually
1443 * needed, but it should be harmless in either case.
1444 * The WBINVD is insufficient due to the spurious-wakeup
1445 * case where we return around the loop.
1446 */
1447 clflush(mwait_ptr);
1448 __monitor(mwait_ptr, 0, 0);
1449 mb();
1450 __mwait(eax, 0);
1451 }
1452}
1453
1454static inline void hlt_play_dead(void)
1455{
1456 if (current_cpu_data.x86 >= 4)
1457 wbinvd();
1458
1459 while (1) {
1460 native_halt();
1461 }
1462}
1463
1386void native_play_dead(void) 1464void native_play_dead(void)
1387{ 1465{
1388 play_dead_common(); 1466 play_dead_common();
1389 tboot_shutdown(TB_SHUTDOWN_WFS); 1467 tboot_shutdown(TB_SHUTDOWN_WFS);
1390 wbinvd_halt(); 1468
1469 mwait_play_dead(); /* Only returns on failure */
1470 hlt_play_dead();
1391} 1471}
1392 1472
1393#else /* ... !CONFIG_HOTPLUG_CPU */ 1473#else /* ... !CONFIG_HOTPLUG_CPU */
diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
index d5e06624e34a..0b0cb5fede19 100644
--- a/arch/x86/kernel/sys_i386_32.c
+++ b/arch/x86/kernel/sys_i386_32.c
@@ -33,8 +33,8 @@ int kernel_execve(const char *filename,
33 const char *const envp[]) 33 const char *const envp[])
34{ 34{
35 long __res; 35 long __res;
36 asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" 36 asm volatile ("int $0x80"
37 : "=a" (__res) 37 : "=a" (__res)
38 : "0" (__NR_execve), "ri" (filename), "c" (argv), "d" (envp) : "memory"); 38 : "0" (__NR_execve), "b" (filename), "c" (argv), "d" (envp) : "memory");
39 return __res; 39 return __res;
40} 40}
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 312ef0292815..20ea20a39e2a 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -1001,10 +1001,10 @@ static int uv_ptc_seq_show(struct seq_file *file, void *data)
1001static ssize_t tunables_read(struct file *file, char __user *userbuf, 1001static ssize_t tunables_read(struct file *file, char __user *userbuf,
1002 size_t count, loff_t *ppos) 1002 size_t count, loff_t *ppos)
1003{ 1003{
1004 char buf[300]; 1004 char *buf;
1005 int ret; 1005 int ret;
1006 1006
1007 ret = snprintf(buf, 300, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n", 1007 buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n",
1008 "max_bau_concurrent plugged_delay plugsb4reset", 1008 "max_bau_concurrent plugged_delay plugsb4reset",
1009 "timeoutsb4reset ipi_reset_limit complete_threshold", 1009 "timeoutsb4reset ipi_reset_limit complete_threshold",
1010 "congested_response_us congested_reps congested_period", 1010 "congested_response_us congested_reps congested_period",
@@ -1012,7 +1012,12 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf,
1012 timeoutsb4reset, ipi_reset_limit, complete_threshold, 1012 timeoutsb4reset, ipi_reset_limit, complete_threshold,
1013 congested_response_us, congested_reps, congested_period); 1013 congested_response_us, congested_reps, congested_period);
1014 1014
1015 return simple_read_from_buffer(userbuf, count, ppos, buf, ret); 1015 if (!buf)
1016 return -ENOMEM;
1017
1018 ret = simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
1019 kfree(buf);
1020 return ret;
1016} 1021}
1017 1022
1018/* 1023/*
@@ -1285,6 +1290,7 @@ static const struct file_operations tunables_fops = {
1285 .open = tunables_open, 1290 .open = tunables_open,
1286 .read = tunables_read, 1291 .read = tunables_read,
1287 .write = tunables_write, 1292 .write = tunables_write,
1293 .llseek = default_llseek,
1288}; 1294};
1289 1295
1290static int __init uv_ptc_init(void) 1296static int __init uv_ptc_init(void)
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index e2a595257390..a375616d77f7 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/arch/x86/kernel/trampoline.c
@@ -1,8 +1,8 @@
1#include <linux/io.h> 1#include <linux/io.h>
2#include <linux/memblock.h>
2 3
3#include <asm/trampoline.h> 4#include <asm/trampoline.h>
4#include <asm/pgtable.h> 5#include <asm/pgtable.h>
5#include <asm/e820.h>
6 6
7#if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP) 7#if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP)
8#define __trampinit 8#define __trampinit
@@ -17,15 +17,15 @@ unsigned char *__trampinitdata trampoline_base;
17 17
18void __init reserve_trampoline_memory(void) 18void __init reserve_trampoline_memory(void)
19{ 19{
20 unsigned long mem; 20 phys_addr_t mem;
21 21
22 /* Has to be in very low memory so we can execute real-mode AP code. */ 22 /* Has to be in very low memory so we can execute real-mode AP code. */
23 mem = find_e820_area(0, 1<<20, TRAMPOLINE_SIZE, PAGE_SIZE); 23 mem = memblock_find_in_range(0, 1<<20, TRAMPOLINE_SIZE, PAGE_SIZE);
24 if (mem == -1L) 24 if (mem == MEMBLOCK_ERROR)
25 panic("Cannot allocate trampoline\n"); 25 panic("Cannot allocate trampoline\n");
26 26
27 trampoline_base = __va(mem); 27 trampoline_base = __va(mem);
28 reserve_early(mem, mem + TRAMPOLINE_SIZE, "TRAMPOLINE"); 28 memblock_x86_reserve_range(mem, mem + TRAMPOLINE_SIZE, "TRAMPOLINE");
29} 29}
30 30
31/* 31/*
@@ -38,19 +38,3 @@ unsigned long __trampinit setup_trampoline(void)
38 memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE); 38 memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
39 return virt_to_phys(trampoline_base); 39 return virt_to_phys(trampoline_base);
40} 40}
41
42void __init setup_trampoline_page_table(void)
43{
44#ifdef CONFIG_X86_32
45 /* Copy kernel address range */
46 clone_pgd_range(trampoline_pg_dir + KERNEL_PGD_BOUNDARY,
47 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
48 KERNEL_PGD_PTRS);
49
50 /* Initialize low mappings */
51 clone_pgd_range(trampoline_pg_dir,
52 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
53 min_t(unsigned long, KERNEL_PGD_PTRS,
54 KERNEL_PGD_BOUNDARY));
55#endif
56}
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 60788dee0f8a..cb838ca42c96 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -575,6 +575,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
575 if (regs->flags & X86_VM_MASK) { 575 if (regs->flags & X86_VM_MASK) {
576 handle_vm86_trap((struct kernel_vm86_regs *) regs, 576 handle_vm86_trap((struct kernel_vm86_regs *) regs,
577 error_code, 1); 577 error_code, 1);
578 preempt_conditional_cli(regs);
578 return; 579 return;
579 } 580 }
580 581
@@ -776,21 +777,10 @@ asmlinkage void math_state_restore(void)
776} 777}
777EXPORT_SYMBOL_GPL(math_state_restore); 778EXPORT_SYMBOL_GPL(math_state_restore);
778 779
779#ifndef CONFIG_MATH_EMULATION
780void math_emulate(struct math_emu_info *info)
781{
782 printk(KERN_EMERG
783 "math-emulation not enabled and no coprocessor found.\n");
784 printk(KERN_EMERG "killing %s.\n", current->comm);
785 force_sig(SIGFPE, current);
786 schedule();
787}
788#endif /* CONFIG_MATH_EMULATION */
789
790dotraplinkage void __kprobes 780dotraplinkage void __kprobes
791do_device_not_available(struct pt_regs *regs, long error_code) 781do_device_not_available(struct pt_regs *regs, long error_code)
792{ 782{
793#ifdef CONFIG_X86_32 783#ifdef CONFIG_MATH_EMULATION
794 if (read_cr0() & X86_CR0_EM) { 784 if (read_cr0() & X86_CR0_EM) {
795 struct math_emu_info info = { }; 785 struct math_emu_info info = { };
796 786
@@ -798,12 +788,12 @@ do_device_not_available(struct pt_regs *regs, long error_code)
798 788
799 info.regs = regs; 789 info.regs = regs;
800 math_emulate(&info); 790 math_emulate(&info);
801 } else { 791 return;
802 math_state_restore(); /* interrupts still off */
803 conditional_sti(regs);
804 } 792 }
805#else 793#endif
806 math_state_restore(); 794 math_state_restore(); /* interrupts still off */
795#ifdef CONFIG_X86_32
796 conditional_sti(regs);
807#endif 797#endif
808} 798}
809 799
@@ -881,18 +871,6 @@ void __init trap_init(void)
881#endif 871#endif
882 872
883#ifdef CONFIG_X86_32 873#ifdef CONFIG_X86_32
884 if (cpu_has_fxsr) {
885 printk(KERN_INFO "Enabling fast FPU save and restore... ");
886 set_in_cr4(X86_CR4_OSFXSR);
887 printk("done.\n");
888 }
889 if (cpu_has_xmm) {
890 printk(KERN_INFO
891 "Enabling unmasked SIMD FPU exception support... ");
892 set_in_cr4(X86_CR4_OSXMMEXCPT);
893 printk("done.\n");
894 }
895
896 set_system_trap_gate(SYSCALL_VECTOR, &system_call); 874 set_system_trap_gate(SYSCALL_VECTOR, &system_call);
897 set_bit(SYSCALL_VECTOR, used_vectors); 875 set_bit(SYSCALL_VECTOR, used_vectors);
898#endif 876#endif
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 26a863a9c2a8..0c40d8b72416 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -104,10 +104,14 @@ int __init notsc_setup(char *str)
104 104
105__setup("notsc", notsc_setup); 105__setup("notsc", notsc_setup);
106 106
107static int no_sched_irq_time;
108
107static int __init tsc_setup(char *str) 109static int __init tsc_setup(char *str)
108{ 110{
109 if (!strcmp(str, "reliable")) 111 if (!strcmp(str, "reliable"))
110 tsc_clocksource_reliable = 1; 112 tsc_clocksource_reliable = 1;
113 if (!strncmp(str, "noirqtime", 9))
114 no_sched_irq_time = 1;
111 return 1; 115 return 1;
112} 116}
113 117
@@ -801,6 +805,7 @@ void mark_tsc_unstable(char *reason)
801 if (!tsc_unstable) { 805 if (!tsc_unstable) {
802 tsc_unstable = 1; 806 tsc_unstable = 1;
803 sched_clock_stable = 0; 807 sched_clock_stable = 0;
808 disable_sched_clock_irqtime();
804 printk(KERN_INFO "Marking TSC unstable due to %s\n", reason); 809 printk(KERN_INFO "Marking TSC unstable due to %s\n", reason);
805 /* Change only the rating, when not registered */ 810 /* Change only the rating, when not registered */
806 if (clocksource_tsc.mult) 811 if (clocksource_tsc.mult)
@@ -892,60 +897,6 @@ static void __init init_tsc_clocksource(void)
892 clocksource_register_khz(&clocksource_tsc, tsc_khz); 897 clocksource_register_khz(&clocksource_tsc, tsc_khz);
893} 898}
894 899
895#ifdef CONFIG_X86_64
896/*
897 * calibrate_cpu is used on systems with fixed rate TSCs to determine
898 * processor frequency
899 */
900#define TICK_COUNT 100000000
901static unsigned long __init calibrate_cpu(void)
902{
903 int tsc_start, tsc_now;
904 int i, no_ctr_free;
905 unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0;
906 unsigned long flags;
907
908 for (i = 0; i < 4; i++)
909 if (avail_to_resrv_perfctr_nmi_bit(i))
910 break;
911 no_ctr_free = (i == 4);
912 if (no_ctr_free) {
913 WARN(1, KERN_WARNING "Warning: AMD perfctrs busy ... "
914 "cpu_khz value may be incorrect.\n");
915 i = 3;
916 rdmsrl(MSR_K7_EVNTSEL3, evntsel3);
917 wrmsrl(MSR_K7_EVNTSEL3, 0);
918 rdmsrl(MSR_K7_PERFCTR3, pmc3);
919 } else {
920 reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i);
921 reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
922 }
923 local_irq_save(flags);
924 /* start measuring cycles, incrementing from 0 */
925 wrmsrl(MSR_K7_PERFCTR0 + i, 0);
926 wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76);
927 rdtscl(tsc_start);
928 do {
929 rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now);
930 tsc_now = get_cycles();
931 } while ((tsc_now - tsc_start) < TICK_COUNT);
932
933 local_irq_restore(flags);
934 if (no_ctr_free) {
935 wrmsrl(MSR_K7_EVNTSEL3, 0);
936 wrmsrl(MSR_K7_PERFCTR3, pmc3);
937 wrmsrl(MSR_K7_EVNTSEL3, evntsel3);
938 } else {
939 release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
940 release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
941 }
942
943 return pmc_now * tsc_khz / (tsc_now - tsc_start);
944}
945#else
946static inline unsigned long calibrate_cpu(void) { return cpu_khz; }
947#endif
948
949void __init tsc_init(void) 900void __init tsc_init(void)
950{ 901{
951 u64 lpj; 902 u64 lpj;
@@ -964,10 +915,6 @@ void __init tsc_init(void)
964 return; 915 return;
965 } 916 }
966 917
967 if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) &&
968 (boot_cpu_data.x86_vendor == X86_VENDOR_AMD))
969 cpu_khz = calibrate_cpu();
970
971 printk("Detected %lu.%03lu MHz processor.\n", 918 printk("Detected %lu.%03lu MHz processor.\n",
972 (unsigned long)cpu_khz / 1000, 919 (unsigned long)cpu_khz / 1000,
973 (unsigned long)cpu_khz % 1000); 920 (unsigned long)cpu_khz % 1000);
@@ -987,6 +934,9 @@ void __init tsc_init(void)
987 /* now allow native_sched_clock() to use rdtsc */ 934 /* now allow native_sched_clock() to use rdtsc */
988 tsc_disabled = 0; 935 tsc_disabled = 0;
989 936
937 if (!no_sched_irq_time)
938 enable_sched_clock_irqtime();
939
990 lpj = ((u64)tsc_khz * 1000); 940 lpj = ((u64)tsc_khz * 1000);
991 do_div(lpj, HZ); 941 do_div(lpj, HZ);
992 lpj_fine = lpj; 942 lpj_fine = lpj;
diff --git a/arch/x86/kernel/uv_irq.c b/arch/x86/kernel/uv_irq.c
index 1132129db792..7b24460917d5 100644
--- a/arch/x86/kernel/uv_irq.c
+++ b/arch/x86/kernel/uv_irq.c
@@ -28,34 +28,21 @@ struct uv_irq_2_mmr_pnode{
28static spinlock_t uv_irq_lock; 28static spinlock_t uv_irq_lock;
29static struct rb_root uv_irq_root; 29static struct rb_root uv_irq_root;
30 30
31static int uv_set_irq_affinity(unsigned int, const struct cpumask *); 31static int uv_set_irq_affinity(struct irq_data *, const struct cpumask *, bool);
32 32
33static void uv_noop(unsigned int irq) 33static void uv_noop(struct irq_data *data) { }
34{
35}
36
37static unsigned int uv_noop_ret(unsigned int irq)
38{
39 return 0;
40}
41 34
42static void uv_ack_apic(unsigned int irq) 35static void uv_ack_apic(struct irq_data *data)
43{ 36{
44 ack_APIC_irq(); 37 ack_APIC_irq();
45} 38}
46 39
47static struct irq_chip uv_irq_chip = { 40static struct irq_chip uv_irq_chip = {
48 .name = "UV-CORE", 41 .name = "UV-CORE",
49 .startup = uv_noop_ret, 42 .irq_mask = uv_noop,
50 .shutdown = uv_noop, 43 .irq_unmask = uv_noop,
51 .enable = uv_noop, 44 .irq_eoi = uv_ack_apic,
52 .disable = uv_noop, 45 .irq_set_affinity = uv_set_irq_affinity,
53 .ack = uv_noop,
54 .mask = uv_noop,
55 .unmask = uv_noop,
56 .eoi = uv_ack_apic,
57 .end = uv_noop,
58 .set_affinity = uv_set_irq_affinity,
59}; 46};
60 47
61/* 48/*
@@ -144,26 +131,22 @@ arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
144 unsigned long mmr_offset, int limit) 131 unsigned long mmr_offset, int limit)
145{ 132{
146 const struct cpumask *eligible_cpu = cpumask_of(cpu); 133 const struct cpumask *eligible_cpu = cpumask_of(cpu);
147 struct irq_desc *desc = irq_to_desc(irq); 134 struct irq_cfg *cfg = get_irq_chip_data(irq);
148 struct irq_cfg *cfg;
149 int mmr_pnode;
150 unsigned long mmr_value; 135 unsigned long mmr_value;
151 struct uv_IO_APIC_route_entry *entry; 136 struct uv_IO_APIC_route_entry *entry;
152 int err; 137 int mmr_pnode, err;
153 138
154 BUILD_BUG_ON(sizeof(struct uv_IO_APIC_route_entry) != 139 BUILD_BUG_ON(sizeof(struct uv_IO_APIC_route_entry) !=
155 sizeof(unsigned long)); 140 sizeof(unsigned long));
156 141
157 cfg = irq_cfg(irq);
158
159 err = assign_irq_vector(irq, cfg, eligible_cpu); 142 err = assign_irq_vector(irq, cfg, eligible_cpu);
160 if (err != 0) 143 if (err != 0)
161 return err; 144 return err;
162 145
163 if (limit == UV_AFFINITY_CPU) 146 if (limit == UV_AFFINITY_CPU)
164 desc->status |= IRQ_NO_BALANCING; 147 irq_set_status_flags(irq, IRQ_NO_BALANCING);
165 else 148 else
166 desc->status |= IRQ_MOVE_PCNTXT; 149 irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
167 150
168 set_irq_chip_and_handler_name(irq, &uv_irq_chip, handle_percpu_irq, 151 set_irq_chip_and_handler_name(irq, &uv_irq_chip, handle_percpu_irq,
169 irq_name); 152 irq_name);
@@ -206,17 +189,17 @@ static void arch_disable_uv_irq(int mmr_pnode, unsigned long mmr_offset)
206 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 189 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
207} 190}
208 191
209static int uv_set_irq_affinity(unsigned int irq, const struct cpumask *mask) 192static int
193uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask,
194 bool force)
210{ 195{
211 struct irq_desc *desc = irq_to_desc(irq); 196 struct irq_cfg *cfg = data->chip_data;
212 struct irq_cfg *cfg = desc->chip_data;
213 unsigned int dest; 197 unsigned int dest;
214 unsigned long mmr_value; 198 unsigned long mmr_value, mmr_offset;
215 struct uv_IO_APIC_route_entry *entry; 199 struct uv_IO_APIC_route_entry *entry;
216 unsigned long mmr_offset;
217 int mmr_pnode; 200 int mmr_pnode;
218 201
219 if (set_desc_affinity(desc, mask, &dest)) 202 if (__ioapic_set_affinity(data, mask, &dest))
220 return -1; 203 return -1;
221 204
222 mmr_value = 0; 205 mmr_value = 0;
@@ -231,7 +214,7 @@ static int uv_set_irq_affinity(unsigned int irq, const struct cpumask *mask)
231 entry->dest = dest; 214 entry->dest = dest;
232 215
233 /* Get previously stored MMR and pnode of hub sourcing interrupts */ 216 /* Get previously stored MMR and pnode of hub sourcing interrupts */
234 if (uv_irq_2_mmr_info(irq, &mmr_offset, &mmr_pnode)) 217 if (uv_irq_2_mmr_info(data->irq, &mmr_offset, &mmr_pnode))
235 return -1; 218 return -1;
236 219
237 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 220 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
diff --git a/arch/x86/kernel/visws_quirks.c b/arch/x86/kernel/visws_quirks.c
index e680ea52db9b..3371bd053b89 100644
--- a/arch/x86/kernel/visws_quirks.c
+++ b/arch/x86/kernel/visws_quirks.c
@@ -66,10 +66,7 @@ static void __init visws_time_init(void)
66} 66}
67 67
68/* Replaces the default init_ISA_irqs in the generic setup */ 68/* Replaces the default init_ISA_irqs in the generic setup */
69static void __init visws_pre_intr_init(void) 69static void __init visws_pre_intr_init(void);
70{
71 init_VISWS_APIC_irqs();
72}
73 70
74/* Quirk for machine specific memory setup. */ 71/* Quirk for machine specific memory setup. */
75 72
@@ -429,67 +426,34 @@ static int is_co_apic(unsigned int irq)
429/* 426/*
430 * This is the SGI Cobalt (IO-)APIC: 427 * This is the SGI Cobalt (IO-)APIC:
431 */ 428 */
432 429static void enable_cobalt_irq(struct irq_data *data)
433static void enable_cobalt_irq(unsigned int irq)
434{ 430{
435 co_apic_set(is_co_apic(irq), irq); 431 co_apic_set(is_co_apic(data->irq), data->irq);
436} 432}
437 433
438static void disable_cobalt_irq(unsigned int irq) 434static void disable_cobalt_irq(struct irq_data *data)
439{ 435{
440 int entry = is_co_apic(irq); 436 int entry = is_co_apic(data->irq);
441 437
442 co_apic_write(CO_APIC_LO(entry), CO_APIC_MASK); 438 co_apic_write(CO_APIC_LO(entry), CO_APIC_MASK);
443 co_apic_read(CO_APIC_LO(entry)); 439 co_apic_read(CO_APIC_LO(entry));
444} 440}
445 441
446/* 442static void ack_cobalt_irq(struct irq_data *data)
447 * "irq" really just serves to identify the device. Here is where we
448 * map this to the Cobalt APIC entry where it's physically wired.
449 * This is called via request_irq -> setup_irq -> irq_desc->startup()
450 */
451static unsigned int startup_cobalt_irq(unsigned int irq)
452{ 443{
453 unsigned long flags; 444 unsigned long flags;
454 struct irq_desc *desc = irq_to_desc(irq);
455 445
456 spin_lock_irqsave(&cobalt_lock, flags); 446 spin_lock_irqsave(&cobalt_lock, flags);
457 if ((desc->status & (IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING))) 447 disable_cobalt_irq(data);
458 desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING);
459 enable_cobalt_irq(irq);
460 spin_unlock_irqrestore(&cobalt_lock, flags);
461 return 0;
462}
463
464static void ack_cobalt_irq(unsigned int irq)
465{
466 unsigned long flags;
467
468 spin_lock_irqsave(&cobalt_lock, flags);
469 disable_cobalt_irq(irq);
470 apic_write(APIC_EOI, APIC_EIO_ACK); 448 apic_write(APIC_EOI, APIC_EIO_ACK);
471 spin_unlock_irqrestore(&cobalt_lock, flags); 449 spin_unlock_irqrestore(&cobalt_lock, flags);
472} 450}
473 451
474static void end_cobalt_irq(unsigned int irq)
475{
476 unsigned long flags;
477 struct irq_desc *desc = irq_to_desc(irq);
478
479 spin_lock_irqsave(&cobalt_lock, flags);
480 if (!(desc->status & (IRQ_DISABLED | IRQ_INPROGRESS)))
481 enable_cobalt_irq(irq);
482 spin_unlock_irqrestore(&cobalt_lock, flags);
483}
484
485static struct irq_chip cobalt_irq_type = { 452static struct irq_chip cobalt_irq_type = {
486 .name = "Cobalt-APIC", 453 .name = "Cobalt-APIC",
487 .startup = startup_cobalt_irq, 454 .irq_enable = enable_cobalt_irq,
488 .shutdown = disable_cobalt_irq, 455 .irq_disable = disable_cobalt_irq,
489 .enable = enable_cobalt_irq, 456 .irq_ack = ack_cobalt_irq,
490 .disable = disable_cobalt_irq,
491 .ack = ack_cobalt_irq,
492 .end = end_cobalt_irq,
493}; 457};
494 458
495 459
@@ -503,35 +467,34 @@ static struct irq_chip cobalt_irq_type = {
503 * interrupt controller type, and through a special virtual interrupt- 467 * interrupt controller type, and through a special virtual interrupt-
504 * controller. Device drivers only see the virtual interrupt sources. 468 * controller. Device drivers only see the virtual interrupt sources.
505 */ 469 */
506static unsigned int startup_piix4_master_irq(unsigned int irq) 470static unsigned int startup_piix4_master_irq(struct irq_data *data)
507{ 471{
508 legacy_pic->init(0); 472 legacy_pic->init(0);
509 473 enable_cobalt_irq(data);
510 return startup_cobalt_irq(irq);
511} 474}
512 475
513static void end_piix4_master_irq(unsigned int irq) 476static void end_piix4_master_irq(struct irq_data *data)
514{ 477{
515 unsigned long flags; 478 unsigned long flags;
516 479
517 spin_lock_irqsave(&cobalt_lock, flags); 480 spin_lock_irqsave(&cobalt_lock, flags);
518 enable_cobalt_irq(irq); 481 enable_cobalt_irq(data);
519 spin_unlock_irqrestore(&cobalt_lock, flags); 482 spin_unlock_irqrestore(&cobalt_lock, flags);
520} 483}
521 484
522static struct irq_chip piix4_master_irq_type = { 485static struct irq_chip piix4_master_irq_type = {
523 .name = "PIIX4-master", 486 .name = "PIIX4-master",
524 .startup = startup_piix4_master_irq, 487 .irq_startup = startup_piix4_master_irq,
525 .ack = ack_cobalt_irq, 488 .irq_ack = ack_cobalt_irq,
526 .end = end_piix4_master_irq,
527}; 489};
528 490
491static void pii4_mask(struct irq_data *data) { }
529 492
530static struct irq_chip piix4_virtual_irq_type = { 493static struct irq_chip piix4_virtual_irq_type = {
531 .name = "PIIX4-virtual", 494 .name = "PIIX4-virtual",
495 .mask = pii4_mask,
532}; 496};
533 497
534
535/* 498/*
536 * PIIX4-8259 master/virtual functions to handle interrupt requests 499 * PIIX4-8259 master/virtual functions to handle interrupt requests
537 * from legacy devices: floppy, parallel, serial, rtc. 500 * from legacy devices: floppy, parallel, serial, rtc.
@@ -549,9 +512,8 @@ static struct irq_chip piix4_virtual_irq_type = {
549 */ 512 */
550static irqreturn_t piix4_master_intr(int irq, void *dev_id) 513static irqreturn_t piix4_master_intr(int irq, void *dev_id)
551{ 514{
552 int realirq;
553 struct irq_desc *desc;
554 unsigned long flags; 515 unsigned long flags;
516 int realirq;
555 517
556 raw_spin_lock_irqsave(&i8259A_lock, flags); 518 raw_spin_lock_irqsave(&i8259A_lock, flags);
557 519
@@ -592,18 +554,10 @@ static irqreturn_t piix4_master_intr(int irq, void *dev_id)
592 554
593 raw_spin_unlock_irqrestore(&i8259A_lock, flags); 555 raw_spin_unlock_irqrestore(&i8259A_lock, flags);
594 556
595 desc = irq_to_desc(realirq);
596
597 /* 557 /*
598 * handle this 'virtual interrupt' as a Cobalt one now. 558 * handle this 'virtual interrupt' as a Cobalt one now.
599 */ 559 */
600 kstat_incr_irqs_this_cpu(realirq, desc); 560 generic_handle_irq(realirq);
601
602 if (likely(desc->action != NULL))
603 handle_IRQ_event(realirq, desc->action);
604
605 if (!(desc->status & IRQ_DISABLED))
606 legacy_pic->chip->unmask(realirq);
607 561
608 return IRQ_HANDLED; 562 return IRQ_HANDLED;
609 563
@@ -624,41 +578,35 @@ static struct irqaction cascade_action = {
624 578
625static inline void set_piix4_virtual_irq_type(void) 579static inline void set_piix4_virtual_irq_type(void)
626{ 580{
627 piix4_virtual_irq_type.shutdown = i8259A_chip.mask;
628 piix4_virtual_irq_type.enable = i8259A_chip.unmask; 581 piix4_virtual_irq_type.enable = i8259A_chip.unmask;
629 piix4_virtual_irq_type.disable = i8259A_chip.mask; 582 piix4_virtual_irq_type.disable = i8259A_chip.mask;
583 piix4_virtual_irq_type.unmask = i8259A_chip.unmask;
630} 584}
631 585
632void init_VISWS_APIC_irqs(void) 586static void __init visws_pre_intr_init(void)
633{ 587{
634 int i; 588 int i;
635 589
636 for (i = 0; i < CO_IRQ_APIC0 + CO_APIC_LAST + 1; i++) { 590 set_piix4_virtual_irq_type();
637 struct irq_desc *desc = irq_to_desc(i);
638
639 desc->status = IRQ_DISABLED;
640 desc->action = 0;
641 desc->depth = 1;
642 591
643 if (i == 0) { 592 for (i = 0; i < CO_IRQ_APIC0 + CO_APIC_LAST + 1; i++) {
644 desc->chip = &cobalt_irq_type; 593 struct irq_chip *chip = NULL;
645 } 594
646 else if (i == CO_IRQ_IDE0) { 595 if (i == 0)
647 desc->chip = &cobalt_irq_type; 596 chip = &cobalt_irq_type;
648 } 597 else if (i == CO_IRQ_IDE0)
649 else if (i == CO_IRQ_IDE1) { 598 chip = &cobalt_irq_type;
650 desc->chip = &cobalt_irq_type; 599 else if (i == CO_IRQ_IDE1)
651 } 600 >chip = &cobalt_irq_type;
652 else if (i == CO_IRQ_8259) { 601 else if (i == CO_IRQ_8259)
653 desc->chip = &piix4_master_irq_type; 602 chip = &piix4_master_irq_type;
654 } 603 else if (i < CO_IRQ_APIC0)
655 else if (i < CO_IRQ_APIC0) { 604 chip = &piix4_virtual_irq_type;
656 set_piix4_virtual_irq_type(); 605 else if (IS_CO_APIC(i))
657 desc->chip = &piix4_virtual_irq_type; 606 chip = &cobalt_irq_type;
658 } 607
659 else if (IS_CO_APIC(i)) { 608 if (chip)
660 desc->chip = &cobalt_irq_type; 609 set_irq_chip(i, chip);
661 }
662 } 610 }
663 611
664 setup_irq(CO_IRQ_8259, &master_action); 612 setup_irq(CO_IRQ_8259, &master_action);
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index 5ffb5622f793..61fb98519622 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -551,8 +551,14 @@ cannot_handle:
551int handle_vm86_trap(struct kernel_vm86_regs *regs, long error_code, int trapno) 551int handle_vm86_trap(struct kernel_vm86_regs *regs, long error_code, int trapno)
552{ 552{
553 if (VMPI.is_vm86pus) { 553 if (VMPI.is_vm86pus) {
554 if ((trapno == 3) || (trapno == 1)) 554 if ((trapno == 3) || (trapno == 1)) {
555 return_to_32bit(regs, VM86_TRAP + (trapno << 8)); 555 KVM86->regs32->ax = VM86_TRAP + (trapno << 8);
556 /* setting this flag forces the code in entry_32.S to
557 call save_v86_state() and change the stack pointer
558 to KVM86->regs32 */
559 set_thread_flag(TIF_IRET);
560 return 0;
561 }
556 do_int(regs, trapno, (unsigned char __user *) (regs->pt.ss << 4), SP(regs)); 562 do_int(regs, trapno, (unsigned char __user *) (regs->pt.ss << 4), SP(regs));
557 return 0; 563 return 0;
558 } 564 }
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
deleted file mode 100644
index ce9fbacb7526..000000000000
--- a/arch/x86/kernel/vmi_32.c
+++ /dev/null
@@ -1,893 +0,0 @@
1/*
2 * VMI specific paravirt-ops implementation
3 *
4 * Copyright (C) 2005, VMware, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 * Send feedback to zach@vmware.com
22 *
23 */
24
25#include <linux/module.h>
26#include <linux/cpu.h>
27#include <linux/bootmem.h>
28#include <linux/mm.h>
29#include <linux/highmem.h>
30#include <linux/sched.h>
31#include <linux/gfp.h>
32#include <asm/vmi.h>
33#include <asm/io.h>
34#include <asm/fixmap.h>
35#include <asm/apicdef.h>
36#include <asm/apic.h>
37#include <asm/pgalloc.h>
38#include <asm/processor.h>
39#include <asm/timer.h>
40#include <asm/vmi_time.h>
41#include <asm/kmap_types.h>
42#include <asm/setup.h>
43
44/* Convenient for calling VMI functions indirectly in the ROM */
45typedef u32 __attribute__((regparm(1))) (VROMFUNC)(void);
46typedef u64 __attribute__((regparm(2))) (VROMLONGFUNC)(int);
47
48#define call_vrom_func(rom,func) \
49 (((VROMFUNC *)(rom->func))())
50
51#define call_vrom_long_func(rom,func,arg) \
52 (((VROMLONGFUNC *)(rom->func)) (arg))
53
54static struct vrom_header *vmi_rom;
55static int disable_pge;
56static int disable_pse;
57static int disable_sep;
58static int disable_tsc;
59static int disable_mtrr;
60static int disable_noidle;
61static int disable_vmi_timer;
62
63/* Cached VMI operations */
64static struct {
65 void (*cpuid)(void /* non-c */);
66 void (*_set_ldt)(u32 selector);
67 void (*set_tr)(u32 selector);
68 void (*write_idt_entry)(struct desc_struct *, int, u32, u32);
69 void (*write_gdt_entry)(struct desc_struct *, int, u32, u32);
70 void (*write_ldt_entry)(struct desc_struct *, int, u32, u32);
71 void (*set_kernel_stack)(u32 selector, u32 sp0);
72 void (*allocate_page)(u32, u32, u32, u32, u32);
73 void (*release_page)(u32, u32);
74 void (*set_pte)(pte_t, pte_t *, unsigned);
75 void (*update_pte)(pte_t *, unsigned);
76 void (*set_linear_mapping)(int, void *, u32, u32);
77 void (*_flush_tlb)(int);
78 void (*set_initial_ap_state)(int, int);
79 void (*halt)(void);
80 void (*set_lazy_mode)(int mode);
81} vmi_ops;
82
83/* Cached VMI operations */
84struct vmi_timer_ops vmi_timer_ops;
85
86/*
87 * VMI patching routines.
88 */
89#define MNEM_CALL 0xe8
90#define MNEM_JMP 0xe9
91#define MNEM_RET 0xc3
92
93#define IRQ_PATCH_INT_MASK 0
94#define IRQ_PATCH_DISABLE 5
95
96static inline void patch_offset(void *insnbuf,
97 unsigned long ip, unsigned long dest)
98{
99 *(unsigned long *)(insnbuf+1) = dest-ip-5;
100}
101
102static unsigned patch_internal(int call, unsigned len, void *insnbuf,
103 unsigned long ip)
104{
105 u64 reloc;
106 struct vmi_relocation_info *const rel = (struct vmi_relocation_info *)&reloc;
107 reloc = call_vrom_long_func(vmi_rom, get_reloc, call);
108 switch(rel->type) {
109 case VMI_RELOCATION_CALL_REL:
110 BUG_ON(len < 5);
111 *(char *)insnbuf = MNEM_CALL;
112 patch_offset(insnbuf, ip, (unsigned long)rel->eip);
113 return 5;
114
115 case VMI_RELOCATION_JUMP_REL:
116 BUG_ON(len < 5);
117 *(char *)insnbuf = MNEM_JMP;
118 patch_offset(insnbuf, ip, (unsigned long)rel->eip);
119 return 5;
120
121 case VMI_RELOCATION_NOP:
122 /* obliterate the whole thing */
123 return 0;
124
125 case VMI_RELOCATION_NONE:
126 /* leave native code in place */
127 break;
128
129 default:
130 BUG();
131 }
132 return len;
133}
134
135/*
136 * Apply patch if appropriate, return length of new instruction
137 * sequence. The callee does nop padding for us.
138 */
139static unsigned vmi_patch(u8 type, u16 clobbers, void *insns,
140 unsigned long ip, unsigned len)
141{
142 switch (type) {
143 case PARAVIRT_PATCH(pv_irq_ops.irq_disable):
144 return patch_internal(VMI_CALL_DisableInterrupts, len,
145 insns, ip);
146 case PARAVIRT_PATCH(pv_irq_ops.irq_enable):
147 return patch_internal(VMI_CALL_EnableInterrupts, len,
148 insns, ip);
149 case PARAVIRT_PATCH(pv_irq_ops.restore_fl):
150 return patch_internal(VMI_CALL_SetInterruptMask, len,
151 insns, ip);
152 case PARAVIRT_PATCH(pv_irq_ops.save_fl):
153 return patch_internal(VMI_CALL_GetInterruptMask, len,
154 insns, ip);
155 case PARAVIRT_PATCH(pv_cpu_ops.iret):
156 return patch_internal(VMI_CALL_IRET, len, insns, ip);
157 case PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit):
158 return patch_internal(VMI_CALL_SYSEXIT, len, insns, ip);
159 default:
160 break;
161 }
162 return len;
163}
164
165/* CPUID has non-C semantics, and paravirt-ops API doesn't match hardware ISA */
166static void vmi_cpuid(unsigned int *ax, unsigned int *bx,
167 unsigned int *cx, unsigned int *dx)
168{
169 int override = 0;
170 if (*ax == 1)
171 override = 1;
172 asm volatile ("call *%6"
173 : "=a" (*ax),
174 "=b" (*bx),
175 "=c" (*cx),
176 "=d" (*dx)
177 : "0" (*ax), "2" (*cx), "r" (vmi_ops.cpuid));
178 if (override) {
179 if (disable_pse)
180 *dx &= ~X86_FEATURE_PSE;
181 if (disable_pge)
182 *dx &= ~X86_FEATURE_PGE;
183 if (disable_sep)
184 *dx &= ~X86_FEATURE_SEP;
185 if (disable_tsc)
186 *dx &= ~X86_FEATURE_TSC;
187 if (disable_mtrr)
188 *dx &= ~X86_FEATURE_MTRR;
189 }
190}
191
192static inline void vmi_maybe_load_tls(struct desc_struct *gdt, int nr, struct desc_struct *new)
193{
194 if (gdt[nr].a != new->a || gdt[nr].b != new->b)
195 write_gdt_entry(gdt, nr, new, 0);
196}
197
198static void vmi_load_tls(struct thread_struct *t, unsigned int cpu)
199{
200 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
201 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 0, &t->tls_array[0]);
202 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 1, &t->tls_array[1]);
203 vmi_maybe_load_tls(gdt, GDT_ENTRY_TLS_MIN + 2, &t->tls_array[2]);
204}
205
206static void vmi_set_ldt(const void *addr, unsigned entries)
207{
208 unsigned cpu = smp_processor_id();
209 struct desc_struct desc;
210
211 pack_descriptor(&desc, (unsigned long)addr,
212 entries * sizeof(struct desc_struct) - 1,
213 DESC_LDT, 0);
214 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, &desc, DESC_LDT);
215 vmi_ops._set_ldt(entries ? GDT_ENTRY_LDT*sizeof(struct desc_struct) : 0);
216}
217
218static void vmi_set_tr(void)
219{
220 vmi_ops.set_tr(GDT_ENTRY_TSS*sizeof(struct desc_struct));
221}
222
223static void vmi_write_idt_entry(gate_desc *dt, int entry, const gate_desc *g)
224{
225 u32 *idt_entry = (u32 *)g;
226 vmi_ops.write_idt_entry(dt, entry, idt_entry[0], idt_entry[1]);
227}
228
229static void vmi_write_gdt_entry(struct desc_struct *dt, int entry,
230 const void *desc, int type)
231{
232 u32 *gdt_entry = (u32 *)desc;
233 vmi_ops.write_gdt_entry(dt, entry, gdt_entry[0], gdt_entry[1]);
234}
235
236static void vmi_write_ldt_entry(struct desc_struct *dt, int entry,
237 const void *desc)
238{
239 u32 *ldt_entry = (u32 *)desc;
240 vmi_ops.write_ldt_entry(dt, entry, ldt_entry[0], ldt_entry[1]);
241}
242
243static void vmi_load_sp0(struct tss_struct *tss,
244 struct thread_struct *thread)
245{
246 tss->x86_tss.sp0 = thread->sp0;
247
248 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
249 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
250 tss->x86_tss.ss1 = thread->sysenter_cs;
251 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
252 }
253 vmi_ops.set_kernel_stack(__KERNEL_DS, tss->x86_tss.sp0);
254}
255
256static void vmi_flush_tlb_user(void)
257{
258 vmi_ops._flush_tlb(VMI_FLUSH_TLB);
259}
260
261static void vmi_flush_tlb_kernel(void)
262{
263 vmi_ops._flush_tlb(VMI_FLUSH_TLB | VMI_FLUSH_GLOBAL);
264}
265
266/* Stub to do nothing at all; used for delays and unimplemented calls */
267static void vmi_nop(void)
268{
269}
270
271static void vmi_allocate_pte(struct mm_struct *mm, unsigned long pfn)
272{
273 vmi_ops.allocate_page(pfn, VMI_PAGE_L1, 0, 0, 0);
274}
275
276static void vmi_allocate_pmd(struct mm_struct *mm, unsigned long pfn)
277{
278 /*
279 * This call comes in very early, before mem_map is setup.
280 * It is called only for swapper_pg_dir, which already has
281 * data on it.
282 */
283 vmi_ops.allocate_page(pfn, VMI_PAGE_L2, 0, 0, 0);
284}
285
286static void vmi_allocate_pmd_clone(unsigned long pfn, unsigned long clonepfn, unsigned long start, unsigned long count)
287{
288 vmi_ops.allocate_page(pfn, VMI_PAGE_L2 | VMI_PAGE_CLONE, clonepfn, start, count);
289}
290
291static void vmi_release_pte(unsigned long pfn)
292{
293 vmi_ops.release_page(pfn, VMI_PAGE_L1);
294}
295
296static void vmi_release_pmd(unsigned long pfn)
297{
298 vmi_ops.release_page(pfn, VMI_PAGE_L2);
299}
300
301/*
302 * We use the pgd_free hook for releasing the pgd page:
303 */
304static void vmi_pgd_free(struct mm_struct *mm, pgd_t *pgd)
305{
306 unsigned long pfn = __pa(pgd) >> PAGE_SHIFT;
307
308 vmi_ops.release_page(pfn, VMI_PAGE_L2);
309}
310
311/*
312 * Helper macros for MMU update flags. We can defer updates until a flush
313 * or page invalidation only if the update is to the current address space
314 * (otherwise, there is no flush). We must check against init_mm, since
315 * this could be a kernel update, which usually passes init_mm, although
316 * sometimes this check can be skipped if we know the particular function
317 * is only called on user mode PTEs. We could change the kernel to pass
318 * current->active_mm here, but in particular, I was unsure if changing
319 * mm/highmem.c to do this would still be correct on other architectures.
320 */
321#define is_current_as(mm, mustbeuser) ((mm) == current->active_mm || \
322 (!mustbeuser && (mm) == &init_mm))
323#define vmi_flags_addr(mm, addr, level, user) \
324 ((level) | (is_current_as(mm, user) ? \
325 (VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
326#define vmi_flags_addr_defer(mm, addr, level, user) \
327 ((level) | (is_current_as(mm, user) ? \
328 (VMI_PAGE_DEFER | VMI_PAGE_CURRENT_AS | ((addr) & VMI_PAGE_VA_MASK)) : 0))
329
330static void vmi_update_pte(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
331{
332 vmi_ops.update_pte(ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
333}
334
335static void vmi_update_pte_defer(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
336{
337 vmi_ops.update_pte(ptep, vmi_flags_addr_defer(mm, addr, VMI_PAGE_PT, 0));
338}
339
340static void vmi_set_pte(pte_t *ptep, pte_t pte)
341{
342 /* XXX because of set_pmd_pte, this can be called on PT or PD layers */
343 vmi_ops.set_pte(pte, ptep, VMI_PAGE_PT);
344}
345
346static void vmi_set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
347{
348 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
349}
350
351static void vmi_set_pmd(pmd_t *pmdp, pmd_t pmdval)
352{
353#ifdef CONFIG_X86_PAE
354 const pte_t pte = { .pte = pmdval.pmd };
355#else
356 const pte_t pte = { pmdval.pud.pgd.pgd };
357#endif
358 vmi_ops.set_pte(pte, (pte_t *)pmdp, VMI_PAGE_PD);
359}
360
361#ifdef CONFIG_X86_PAE
362
363static void vmi_set_pte_atomic(pte_t *ptep, pte_t pteval)
364{
365 /*
366 * XXX This is called from set_pmd_pte, but at both PT
367 * and PD layers so the VMI_PAGE_PT flag is wrong. But
368 * it is only called for large page mapping changes,
369 * the Xen backend, doesn't support large pages, and the
370 * ESX backend doesn't depend on the flag.
371 */
372 set_64bit((unsigned long long *)ptep,pte_val(pteval));
373 vmi_ops.update_pte(ptep, VMI_PAGE_PT);
374}
375
376static void vmi_set_pud(pud_t *pudp, pud_t pudval)
377{
378 /* Um, eww */
379 const pte_t pte = { .pte = pudval.pgd.pgd };
380 vmi_ops.set_pte(pte, (pte_t *)pudp, VMI_PAGE_PDP);
381}
382
383static void vmi_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
384{
385 const pte_t pte = { .pte = 0 };
386 vmi_ops.set_pte(pte, ptep, vmi_flags_addr(mm, addr, VMI_PAGE_PT, 0));
387}
388
389static void vmi_pmd_clear(pmd_t *pmd)
390{
391 const pte_t pte = { .pte = 0 };
392 vmi_ops.set_pte(pte, (pte_t *)pmd, VMI_PAGE_PD);
393}
394#endif
395
396#ifdef CONFIG_SMP
397static void __devinit
398vmi_startup_ipi_hook(int phys_apicid, unsigned long start_eip,
399 unsigned long start_esp)
400{
401 struct vmi_ap_state ap;
402
403 /* Default everything to zero. This is fine for most GPRs. */
404 memset(&ap, 0, sizeof(struct vmi_ap_state));
405
406 ap.gdtr_limit = GDT_SIZE - 1;
407 ap.gdtr_base = (unsigned long) get_cpu_gdt_table(phys_apicid);
408
409 ap.idtr_limit = IDT_ENTRIES * 8 - 1;
410 ap.idtr_base = (unsigned long) idt_table;
411
412 ap.ldtr = 0;
413
414 ap.cs = __KERNEL_CS;
415 ap.eip = (unsigned long) start_eip;
416 ap.ss = __KERNEL_DS;
417 ap.esp = (unsigned long) start_esp;
418
419 ap.ds = __USER_DS;
420 ap.es = __USER_DS;
421 ap.fs = __KERNEL_PERCPU;
422 ap.gs = __KERNEL_STACK_CANARY;
423
424 ap.eflags = 0;
425
426#ifdef CONFIG_X86_PAE
427 /* efer should match BSP efer. */
428 if (cpu_has_nx) {
429 unsigned l, h;
430 rdmsr(MSR_EFER, l, h);
431 ap.efer = (unsigned long long) h << 32 | l;
432 }
433#endif
434
435 ap.cr3 = __pa(swapper_pg_dir);
436 /* Protected mode, paging, AM, WP, NE, MP. */
437 ap.cr0 = 0x80050023;
438 ap.cr4 = mmu_cr4_features;
439 vmi_ops.set_initial_ap_state((u32)&ap, phys_apicid);
440}
441#endif
442
443static void vmi_start_context_switch(struct task_struct *prev)
444{
445 paravirt_start_context_switch(prev);
446 vmi_ops.set_lazy_mode(2);
447}
448
449static void vmi_end_context_switch(struct task_struct *next)
450{
451 vmi_ops.set_lazy_mode(0);
452 paravirt_end_context_switch(next);
453}
454
455static void vmi_enter_lazy_mmu(void)
456{
457 paravirt_enter_lazy_mmu();
458 vmi_ops.set_lazy_mode(1);
459}
460
461static void vmi_leave_lazy_mmu(void)
462{
463 vmi_ops.set_lazy_mode(0);
464 paravirt_leave_lazy_mmu();
465}
466
467static inline int __init check_vmi_rom(struct vrom_header *rom)
468{
469 struct pci_header *pci;
470 struct pnp_header *pnp;
471 const char *manufacturer = "UNKNOWN";
472 const char *product = "UNKNOWN";
473 const char *license = "unspecified";
474
475 if (rom->rom_signature != 0xaa55)
476 return 0;
477 if (rom->vrom_signature != VMI_SIGNATURE)
478 return 0;
479 if (rom->api_version_maj != VMI_API_REV_MAJOR ||
480 rom->api_version_min+1 < VMI_API_REV_MINOR+1) {
481 printk(KERN_WARNING "VMI: Found mismatched rom version %d.%d\n",
482 rom->api_version_maj,
483 rom->api_version_min);
484 return 0;
485 }
486
487 /*
488 * Relying on the VMI_SIGNATURE field is not 100% safe, so check
489 * the PCI header and device type to make sure this is really a
490 * VMI device.
491 */
492 if (!rom->pci_header_offs) {
493 printk(KERN_WARNING "VMI: ROM does not contain PCI header.\n");
494 return 0;
495 }
496
497 pci = (struct pci_header *)((char *)rom+rom->pci_header_offs);
498 if (pci->vendorID != PCI_VENDOR_ID_VMWARE ||
499 pci->deviceID != PCI_DEVICE_ID_VMWARE_VMI) {
500 /* Allow it to run... anyways, but warn */
501 printk(KERN_WARNING "VMI: ROM from unknown manufacturer\n");
502 }
503
504 if (rom->pnp_header_offs) {
505 pnp = (struct pnp_header *)((char *)rom+rom->pnp_header_offs);
506 if (pnp->manufacturer_offset)
507 manufacturer = (const char *)rom+pnp->manufacturer_offset;
508 if (pnp->product_offset)
509 product = (const char *)rom+pnp->product_offset;
510 }
511
512 if (rom->license_offs)
513 license = (char *)rom+rom->license_offs;
514
515 printk(KERN_INFO "VMI: Found %s %s, API version %d.%d, ROM version %d.%d\n",
516 manufacturer, product,
517 rom->api_version_maj, rom->api_version_min,
518 pci->rom_version_maj, pci->rom_version_min);
519
520 /* Don't allow BSD/MIT here for now because we don't want to end up
521 with any binary only shim layers */
522 if (strcmp(license, "GPL") && strcmp(license, "GPL v2")) {
523 printk(KERN_WARNING "VMI: Non GPL license `%s' found for ROM. Not used.\n",
524 license);
525 return 0;
526 }
527
528 return 1;
529}
530
531/*
532 * Probe for the VMI option ROM
533 */
534static inline int __init probe_vmi_rom(void)
535{
536 unsigned long base;
537
538 /* VMI ROM is in option ROM area, check signature */
539 for (base = 0xC0000; base < 0xE0000; base += 2048) {
540 struct vrom_header *romstart;
541 romstart = (struct vrom_header *)isa_bus_to_virt(base);
542 if (check_vmi_rom(romstart)) {
543 vmi_rom = romstart;
544 return 1;
545 }
546 }
547 return 0;
548}
549
550/*
551 * VMI setup common to all processors
552 */
553void vmi_bringup(void)
554{
555 /* We must establish the lowmem mapping for MMU ops to work */
556 if (vmi_ops.set_linear_mapping)
557 vmi_ops.set_linear_mapping(0, (void *)__PAGE_OFFSET, MAXMEM_PFN, 0);
558}
559
560/*
561 * Return a pointer to a VMI function or NULL if unimplemented
562 */
563static void *vmi_get_function(int vmicall)
564{
565 u64 reloc;
566 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
567 reloc = call_vrom_long_func(vmi_rom, get_reloc, vmicall);
568 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL);
569 if (rel->type == VMI_RELOCATION_CALL_REL)
570 return (void *)rel->eip;
571 else
572 return NULL;
573}
574
575/*
576 * Helper macro for making the VMI paravirt-ops fill code readable.
577 * For unimplemented operations, fall back to default, unless nop
578 * is returned by the ROM.
579 */
580#define para_fill(opname, vmicall) \
581do { \
582 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
583 VMI_CALL_##vmicall); \
584 if (rel->type == VMI_RELOCATION_CALL_REL) \
585 opname = (void *)rel->eip; \
586 else if (rel->type == VMI_RELOCATION_NOP) \
587 opname = (void *)vmi_nop; \
588 else if (rel->type != VMI_RELOCATION_NONE) \
589 printk(KERN_WARNING "VMI: Unknown relocation " \
590 "type %d for " #vmicall"\n",\
591 rel->type); \
592} while (0)
593
594/*
595 * Helper macro for making the VMI paravirt-ops fill code readable.
596 * For cached operations which do not match the VMI ROM ABI and must
597 * go through a tranlation stub. Ignore NOPs, since it is not clear
598 * a NOP * VMI function corresponds to a NOP paravirt-op when the
599 * functions are not in 1-1 correspondence.
600 */
601#define para_wrap(opname, wrapper, cache, vmicall) \
602do { \
603 reloc = call_vrom_long_func(vmi_rom, get_reloc, \
604 VMI_CALL_##vmicall); \
605 BUG_ON(rel->type == VMI_RELOCATION_JUMP_REL); \
606 if (rel->type == VMI_RELOCATION_CALL_REL) { \
607 opname = wrapper; \
608 vmi_ops.cache = (void *)rel->eip; \
609 } \
610} while (0)
611
612/*
613 * Activate the VMI interface and switch into paravirtualized mode
614 */
615static inline int __init activate_vmi(void)
616{
617 short kernel_cs;
618 u64 reloc;
619 const struct vmi_relocation_info *rel = (struct vmi_relocation_info *)&reloc;
620
621 /*
622 * Prevent page tables from being allocated in highmem, even if
623 * CONFIG_HIGHPTE is enabled.
624 */
625 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
626
627 if (call_vrom_func(vmi_rom, vmi_init) != 0) {
628 printk(KERN_ERR "VMI ROM failed to initialize!");
629 return 0;
630 }
631 savesegment(cs, kernel_cs);
632
633 pv_info.paravirt_enabled = 1;
634 pv_info.kernel_rpl = kernel_cs & SEGMENT_RPL_MASK;
635 pv_info.name = "vmi [deprecated]";
636
637 pv_init_ops.patch = vmi_patch;
638
639 /*
640 * Many of these operations are ABI compatible with VMI.
641 * This means we can fill in the paravirt-ops with direct
642 * pointers into the VMI ROM. If the calling convention for
643 * these operations changes, this code needs to be updated.
644 *
645 * Exceptions
646 * CPUID paravirt-op uses pointers, not the native ISA
647 * halt has no VMI equivalent; all VMI halts are "safe"
648 * no MSR support yet - just trap and emulate. VMI uses the
649 * same ABI as the native ISA, but Linux wants exceptions
650 * from bogus MSR read / write handled
651 * rdpmc is not yet used in Linux
652 */
653
654 /* CPUID is special, so very special it gets wrapped like a present */
655 para_wrap(pv_cpu_ops.cpuid, vmi_cpuid, cpuid, CPUID);
656
657 para_fill(pv_cpu_ops.clts, CLTS);
658 para_fill(pv_cpu_ops.get_debugreg, GetDR);
659 para_fill(pv_cpu_ops.set_debugreg, SetDR);
660 para_fill(pv_cpu_ops.read_cr0, GetCR0);
661 para_fill(pv_mmu_ops.read_cr2, GetCR2);
662 para_fill(pv_mmu_ops.read_cr3, GetCR3);
663 para_fill(pv_cpu_ops.read_cr4, GetCR4);
664 para_fill(pv_cpu_ops.write_cr0, SetCR0);
665 para_fill(pv_mmu_ops.write_cr2, SetCR2);
666 para_fill(pv_mmu_ops.write_cr3, SetCR3);
667 para_fill(pv_cpu_ops.write_cr4, SetCR4);
668
669 para_fill(pv_irq_ops.save_fl.func, GetInterruptMask);
670 para_fill(pv_irq_ops.restore_fl.func, SetInterruptMask);
671 para_fill(pv_irq_ops.irq_disable.func, DisableInterrupts);
672 para_fill(pv_irq_ops.irq_enable.func, EnableInterrupts);
673
674 para_fill(pv_cpu_ops.wbinvd, WBINVD);
675 para_fill(pv_cpu_ops.read_tsc, RDTSC);
676
677 /* The following we emulate with trap and emulate for now */
678 /* paravirt_ops.read_msr = vmi_rdmsr */
679 /* paravirt_ops.write_msr = vmi_wrmsr */
680 /* paravirt_ops.rdpmc = vmi_rdpmc */
681
682 /* TR interface doesn't pass TR value, wrap */
683 para_wrap(pv_cpu_ops.load_tr_desc, vmi_set_tr, set_tr, SetTR);
684
685 /* LDT is special, too */
686 para_wrap(pv_cpu_ops.set_ldt, vmi_set_ldt, _set_ldt, SetLDT);
687
688 para_fill(pv_cpu_ops.load_gdt, SetGDT);
689 para_fill(pv_cpu_ops.load_idt, SetIDT);
690 para_fill(pv_cpu_ops.store_gdt, GetGDT);
691 para_fill(pv_cpu_ops.store_idt, GetIDT);
692 para_fill(pv_cpu_ops.store_tr, GetTR);
693 pv_cpu_ops.load_tls = vmi_load_tls;
694 para_wrap(pv_cpu_ops.write_ldt_entry, vmi_write_ldt_entry,
695 write_ldt_entry, WriteLDTEntry);
696 para_wrap(pv_cpu_ops.write_gdt_entry, vmi_write_gdt_entry,
697 write_gdt_entry, WriteGDTEntry);
698 para_wrap(pv_cpu_ops.write_idt_entry, vmi_write_idt_entry,
699 write_idt_entry, WriteIDTEntry);
700 para_wrap(pv_cpu_ops.load_sp0, vmi_load_sp0, set_kernel_stack, UpdateKernelStack);
701 para_fill(pv_cpu_ops.set_iopl_mask, SetIOPLMask);
702 para_fill(pv_cpu_ops.io_delay, IODelay);
703
704 para_wrap(pv_cpu_ops.start_context_switch, vmi_start_context_switch,
705 set_lazy_mode, SetLazyMode);
706 para_wrap(pv_cpu_ops.end_context_switch, vmi_end_context_switch,
707 set_lazy_mode, SetLazyMode);
708
709 para_wrap(pv_mmu_ops.lazy_mode.enter, vmi_enter_lazy_mmu,
710 set_lazy_mode, SetLazyMode);
711 para_wrap(pv_mmu_ops.lazy_mode.leave, vmi_leave_lazy_mmu,
712 set_lazy_mode, SetLazyMode);
713
714 /* user and kernel flush are just handled with different flags to FlushTLB */
715 para_wrap(pv_mmu_ops.flush_tlb_user, vmi_flush_tlb_user, _flush_tlb, FlushTLB);
716 para_wrap(pv_mmu_ops.flush_tlb_kernel, vmi_flush_tlb_kernel, _flush_tlb, FlushTLB);
717 para_fill(pv_mmu_ops.flush_tlb_single, InvalPage);
718
719 /*
720 * Until a standard flag format can be agreed on, we need to
721 * implement these as wrappers in Linux. Get the VMI ROM
722 * function pointers for the two backend calls.
723 */
724#ifdef CONFIG_X86_PAE
725 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxELong);
726 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxELong);
727#else
728 vmi_ops.set_pte = vmi_get_function(VMI_CALL_SetPxE);
729 vmi_ops.update_pte = vmi_get_function(VMI_CALL_UpdatePxE);
730#endif
731
732 if (vmi_ops.set_pte) {
733 pv_mmu_ops.set_pte = vmi_set_pte;
734 pv_mmu_ops.set_pte_at = vmi_set_pte_at;
735 pv_mmu_ops.set_pmd = vmi_set_pmd;
736#ifdef CONFIG_X86_PAE
737 pv_mmu_ops.set_pte_atomic = vmi_set_pte_atomic;
738 pv_mmu_ops.set_pud = vmi_set_pud;
739 pv_mmu_ops.pte_clear = vmi_pte_clear;
740 pv_mmu_ops.pmd_clear = vmi_pmd_clear;
741#endif
742 }
743
744 if (vmi_ops.update_pte) {
745 pv_mmu_ops.pte_update = vmi_update_pte;
746 pv_mmu_ops.pte_update_defer = vmi_update_pte_defer;
747 }
748
749 vmi_ops.allocate_page = vmi_get_function(VMI_CALL_AllocatePage);
750 if (vmi_ops.allocate_page) {
751 pv_mmu_ops.alloc_pte = vmi_allocate_pte;
752 pv_mmu_ops.alloc_pmd = vmi_allocate_pmd;
753 pv_mmu_ops.alloc_pmd_clone = vmi_allocate_pmd_clone;
754 }
755
756 vmi_ops.release_page = vmi_get_function(VMI_CALL_ReleasePage);
757 if (vmi_ops.release_page) {
758 pv_mmu_ops.release_pte = vmi_release_pte;
759 pv_mmu_ops.release_pmd = vmi_release_pmd;
760 pv_mmu_ops.pgd_free = vmi_pgd_free;
761 }
762
763 /* Set linear is needed in all cases */
764 vmi_ops.set_linear_mapping = vmi_get_function(VMI_CALL_SetLinearMapping);
765
766 /*
767 * These MUST always be patched. Don't support indirect jumps
768 * through these operations, as the VMI interface may use either
769 * a jump or a call to get to these operations, depending on
770 * the backend. They are performance critical anyway, so requiring
771 * a patch is not a big problem.
772 */
773 pv_cpu_ops.irq_enable_sysexit = (void *)0xfeedbab0;
774 pv_cpu_ops.iret = (void *)0xbadbab0;
775
776#ifdef CONFIG_SMP
777 para_wrap(pv_apic_ops.startup_ipi_hook, vmi_startup_ipi_hook, set_initial_ap_state, SetInitialAPState);
778#endif
779
780#ifdef CONFIG_X86_LOCAL_APIC
781 para_fill(apic->read, APICRead);
782 para_fill(apic->write, APICWrite);
783#endif
784
785 /*
786 * Check for VMI timer functionality by probing for a cycle frequency method
787 */
788 reloc = call_vrom_long_func(vmi_rom, get_reloc, VMI_CALL_GetCycleFrequency);
789 if (!disable_vmi_timer && rel->type != VMI_RELOCATION_NONE) {
790 vmi_timer_ops.get_cycle_frequency = (void *)rel->eip;
791 vmi_timer_ops.get_cycle_counter =
792 vmi_get_function(VMI_CALL_GetCycleCounter);
793 vmi_timer_ops.get_wallclock =
794 vmi_get_function(VMI_CALL_GetWallclockTime);
795 vmi_timer_ops.wallclock_updated =
796 vmi_get_function(VMI_CALL_WallclockUpdated);
797 vmi_timer_ops.set_alarm = vmi_get_function(VMI_CALL_SetAlarm);
798 vmi_timer_ops.cancel_alarm =
799 vmi_get_function(VMI_CALL_CancelAlarm);
800 x86_init.timers.timer_init = vmi_time_init;
801#ifdef CONFIG_X86_LOCAL_APIC
802 x86_init.timers.setup_percpu_clockev = vmi_time_bsp_init;
803 x86_cpuinit.setup_percpu_clockev = vmi_time_ap_init;
804#endif
805 pv_time_ops.sched_clock = vmi_sched_clock;
806 x86_platform.calibrate_tsc = vmi_tsc_khz;
807 x86_platform.get_wallclock = vmi_get_wallclock;
808 x86_platform.set_wallclock = vmi_set_wallclock;
809
810 /* We have true wallclock functions; disable CMOS clock sync */
811 no_sync_cmos_clock = 1;
812 } else {
813 disable_noidle = 1;
814 disable_vmi_timer = 1;
815 }
816
817 para_fill(pv_irq_ops.safe_halt, Halt);
818
819 /*
820 * Alternative instruction rewriting doesn't happen soon enough
821 * to convert VMI_IRET to a call instead of a jump; so we have
822 * to do this before IRQs get reenabled. Fortunately, it is
823 * idempotent.
824 */
825 apply_paravirt(__parainstructions, __parainstructions_end);
826
827 vmi_bringup();
828
829 return 1;
830}
831
832#undef para_fill
833
834void __init vmi_init(void)
835{
836 if (!vmi_rom)
837 probe_vmi_rom();
838 else
839 check_vmi_rom(vmi_rom);
840
841 /* In case probing for or validating the ROM failed, basil */
842 if (!vmi_rom)
843 return;
844
845 reserve_top_address(-vmi_rom->virtual_top);
846
847#ifdef CONFIG_X86_IO_APIC
848 /* This is virtual hardware; timer routing is wired correctly */
849 no_timer_check = 1;
850#endif
851}
852
853void __init vmi_activate(void)
854{
855 unsigned long flags;
856
857 if (!vmi_rom)
858 return;
859
860 local_irq_save(flags);
861 activate_vmi();
862 local_irq_restore(flags & X86_EFLAGS_IF);
863}
864
865static int __init parse_vmi(char *arg)
866{
867 if (!arg)
868 return -EINVAL;
869
870 if (!strcmp(arg, "disable_pge")) {
871 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_PGE);
872 disable_pge = 1;
873 } else if (!strcmp(arg, "disable_pse")) {
874 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_PSE);
875 disable_pse = 1;
876 } else if (!strcmp(arg, "disable_sep")) {
877 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_SEP);
878 disable_sep = 1;
879 } else if (!strcmp(arg, "disable_tsc")) {
880 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_TSC);
881 disable_tsc = 1;
882 } else if (!strcmp(arg, "disable_mtrr")) {
883 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_MTRR);
884 disable_mtrr = 1;
885 } else if (!strcmp(arg, "disable_timer")) {
886 disable_vmi_timer = 1;
887 disable_noidle = 1;
888 } else if (!strcmp(arg, "disable_noidle"))
889 disable_noidle = 1;
890 return 0;
891}
892
893early_param("vmi", parse_vmi);
diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
deleted file mode 100644
index 5e1ff66ecd73..000000000000
--- a/arch/x86/kernel/vmiclock_32.c
+++ /dev/null
@@ -1,317 +0,0 @@
1/*
2 * VMI paravirtual timer support routines.
3 *
4 * Copyright (C) 2007, VMware, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include <linux/smp.h>
24#include <linux/interrupt.h>
25#include <linux/cpumask.h>
26#include <linux/clocksource.h>
27#include <linux/clockchips.h>
28
29#include <asm/vmi.h>
30#include <asm/vmi_time.h>
31#include <asm/apicdef.h>
32#include <asm/apic.h>
33#include <asm/timer.h>
34#include <asm/i8253.h>
35#include <asm/irq_vectors.h>
36
37#define VMI_ONESHOT (VMI_ALARM_IS_ONESHOT | VMI_CYCLES_REAL | vmi_get_alarm_wiring())
38#define VMI_PERIODIC (VMI_ALARM_IS_PERIODIC | VMI_CYCLES_REAL | vmi_get_alarm_wiring())
39
40static DEFINE_PER_CPU(struct clock_event_device, local_events);
41
42static inline u32 vmi_counter(u32 flags)
43{
44 /* Given VMI_ONESHOT or VMI_PERIODIC, return the corresponding
45 * cycle counter. */
46 return flags & VMI_ALARM_COUNTER_MASK;
47}
48
49/* paravirt_ops.get_wallclock = vmi_get_wallclock */
50unsigned long vmi_get_wallclock(void)
51{
52 unsigned long long wallclock;
53 wallclock = vmi_timer_ops.get_wallclock(); // nsec
54 (void)do_div(wallclock, 1000000000); // sec
55
56 return wallclock;
57}
58
59/* paravirt_ops.set_wallclock = vmi_set_wallclock */
60int vmi_set_wallclock(unsigned long now)
61{
62 return 0;
63}
64
65/* paravirt_ops.sched_clock = vmi_sched_clock */
66unsigned long long vmi_sched_clock(void)
67{
68 return cycles_2_ns(vmi_timer_ops.get_cycle_counter(VMI_CYCLES_AVAILABLE));
69}
70
71/* x86_platform.calibrate_tsc = vmi_tsc_khz */
72unsigned long vmi_tsc_khz(void)
73{
74 unsigned long long khz;
75 khz = vmi_timer_ops.get_cycle_frequency();
76 (void)do_div(khz, 1000);
77 return khz;
78}
79
80static inline unsigned int vmi_get_timer_vector(void)
81{
82 return IRQ0_VECTOR;
83}
84
85/** vmi clockchip */
86#ifdef CONFIG_X86_LOCAL_APIC
87static unsigned int startup_timer_irq(unsigned int irq)
88{
89 unsigned long val = apic_read(APIC_LVTT);
90 apic_write(APIC_LVTT, vmi_get_timer_vector());
91
92 return (val & APIC_SEND_PENDING);
93}
94
95static void mask_timer_irq(unsigned int irq)
96{
97 unsigned long val = apic_read(APIC_LVTT);
98 apic_write(APIC_LVTT, val | APIC_LVT_MASKED);
99}
100
101static void unmask_timer_irq(unsigned int irq)
102{
103 unsigned long val = apic_read(APIC_LVTT);
104 apic_write(APIC_LVTT, val & ~APIC_LVT_MASKED);
105}
106
107static void ack_timer_irq(unsigned int irq)
108{
109 ack_APIC_irq();
110}
111
112static struct irq_chip vmi_chip __read_mostly = {
113 .name = "VMI-LOCAL",
114 .startup = startup_timer_irq,
115 .mask = mask_timer_irq,
116 .unmask = unmask_timer_irq,
117 .ack = ack_timer_irq
118};
119#endif
120
121/** vmi clockevent */
122#define VMI_ALARM_WIRED_IRQ0 0x00000000
123#define VMI_ALARM_WIRED_LVTT 0x00010000
124static int vmi_wiring = VMI_ALARM_WIRED_IRQ0;
125
126static inline int vmi_get_alarm_wiring(void)
127{
128 return vmi_wiring;
129}
130
131static void vmi_timer_set_mode(enum clock_event_mode mode,
132 struct clock_event_device *evt)
133{
134 cycle_t now, cycles_per_hz;
135 BUG_ON(!irqs_disabled());
136
137 switch (mode) {
138 case CLOCK_EVT_MODE_ONESHOT:
139 case CLOCK_EVT_MODE_RESUME:
140 break;
141 case CLOCK_EVT_MODE_PERIODIC:
142 cycles_per_hz = vmi_timer_ops.get_cycle_frequency();
143 (void)do_div(cycles_per_hz, HZ);
144 now = vmi_timer_ops.get_cycle_counter(vmi_counter(VMI_PERIODIC));
145 vmi_timer_ops.set_alarm(VMI_PERIODIC, now, cycles_per_hz);
146 break;
147 case CLOCK_EVT_MODE_UNUSED:
148 case CLOCK_EVT_MODE_SHUTDOWN:
149 switch (evt->mode) {
150 case CLOCK_EVT_MODE_ONESHOT:
151 vmi_timer_ops.cancel_alarm(VMI_ONESHOT);
152 break;
153 case CLOCK_EVT_MODE_PERIODIC:
154 vmi_timer_ops.cancel_alarm(VMI_PERIODIC);
155 break;
156 default:
157 break;
158 }
159 break;
160 default:
161 break;
162 }
163}
164
165static int vmi_timer_next_event(unsigned long delta,
166 struct clock_event_device *evt)
167{
168 /* Unfortunately, set_next_event interface only passes relative
169 * expiry, but we want absolute expiry. It'd be better if were
170 * were passed an absolute expiry, since a bunch of time may
171 * have been stolen between the time the delta is computed and
172 * when we set the alarm below. */
173 cycle_t now = vmi_timer_ops.get_cycle_counter(vmi_counter(VMI_ONESHOT));
174
175 BUG_ON(evt->mode != CLOCK_EVT_MODE_ONESHOT);
176 vmi_timer_ops.set_alarm(VMI_ONESHOT, now + delta, 0);
177 return 0;
178}
179
180static struct clock_event_device vmi_clockevent = {
181 .name = "vmi-timer",
182 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
183 .shift = 22,
184 .set_mode = vmi_timer_set_mode,
185 .set_next_event = vmi_timer_next_event,
186 .rating = 1000,
187 .irq = 0,
188};
189
190static irqreturn_t vmi_timer_interrupt(int irq, void *dev_id)
191{
192 struct clock_event_device *evt = &__get_cpu_var(local_events);
193 evt->event_handler(evt);
194 return IRQ_HANDLED;
195}
196
197static struct irqaction vmi_clock_action = {
198 .name = "vmi-timer",
199 .handler = vmi_timer_interrupt,
200 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER,
201};
202
203static void __devinit vmi_time_init_clockevent(void)
204{
205 cycle_t cycles_per_msec;
206 struct clock_event_device *evt;
207
208 int cpu = smp_processor_id();
209 evt = &__get_cpu_var(local_events);
210
211 /* Use cycles_per_msec since div_sc params are 32-bits. */
212 cycles_per_msec = vmi_timer_ops.get_cycle_frequency();
213 (void)do_div(cycles_per_msec, 1000);
214
215 memcpy(evt, &vmi_clockevent, sizeof(*evt));
216 /* Must pick .shift such that .mult fits in 32-bits. Choosing
217 * .shift to be 22 allows 2^(32-22) cycles per nano-seconds
218 * before overflow. */
219 evt->mult = div_sc(cycles_per_msec, NSEC_PER_MSEC, evt->shift);
220 /* Upper bound is clockevent's use of ulong for cycle deltas. */
221 evt->max_delta_ns = clockevent_delta2ns(ULONG_MAX, evt);
222 evt->min_delta_ns = clockevent_delta2ns(1, evt);
223 evt->cpumask = cpumask_of(cpu);
224
225 printk(KERN_WARNING "vmi: registering clock event %s. mult=%u shift=%u\n",
226 evt->name, evt->mult, evt->shift);
227 clockevents_register_device(evt);
228}
229
230void __init vmi_time_init(void)
231{
232 unsigned int cpu;
233 /* Disable PIT: BIOSes start PIT CH0 with 18.2hz peridic. */
234 outb_pit(0x3a, PIT_MODE); /* binary, mode 5, LSB/MSB, ch 0 */
235
236 vmi_time_init_clockevent();
237 setup_irq(0, &vmi_clock_action);
238 for_each_possible_cpu(cpu)
239 per_cpu(vector_irq, cpu)[vmi_get_timer_vector()] = 0;
240}
241
242#ifdef CONFIG_X86_LOCAL_APIC
243void __devinit vmi_time_bsp_init(void)
244{
245 /*
246 * On APIC systems, we want local timers to fire on each cpu. We do
247 * this by programming LVTT to deliver timer events to the IRQ handler
248 * for IRQ-0, since we can't re-use the APIC local timer handler
249 * without interfering with that code.
250 */
251 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
252 local_irq_disable();
253#ifdef CONFIG_SMP
254 /*
255 * XXX handle_percpu_irq only defined for SMP; we need to switch over
256 * to using it, since this is a local interrupt, which each CPU must
257 * handle individually without locking out or dropping simultaneous
258 * local timers on other CPUs. We also don't want to trigger the
259 * quirk workaround code for interrupts which gets invoked from
260 * handle_percpu_irq via eoi, so we use our own IRQ chip.
261 */
262 set_irq_chip_and_handler_name(0, &vmi_chip, handle_percpu_irq, "lvtt");
263#else
264 set_irq_chip_and_handler_name(0, &vmi_chip, handle_edge_irq, "lvtt");
265#endif
266 vmi_wiring = VMI_ALARM_WIRED_LVTT;
267 apic_write(APIC_LVTT, vmi_get_timer_vector());
268 local_irq_enable();
269 clockevents_notify(CLOCK_EVT_NOTIFY_RESUME, NULL);
270}
271
272void __devinit vmi_time_ap_init(void)
273{
274 vmi_time_init_clockevent();
275 apic_write(APIC_LVTT, vmi_get_timer_vector());
276}
277#endif
278
279/** vmi clocksource */
280static struct clocksource clocksource_vmi;
281
282static cycle_t read_real_cycles(struct clocksource *cs)
283{
284 cycle_t ret = (cycle_t)vmi_timer_ops.get_cycle_counter(VMI_CYCLES_REAL);
285 return max(ret, clocksource_vmi.cycle_last);
286}
287
288static struct clocksource clocksource_vmi = {
289 .name = "vmi-timer",
290 .rating = 450,
291 .read = read_real_cycles,
292 .mask = CLOCKSOURCE_MASK(64),
293 .mult = 0, /* to be set */
294 .shift = 22,
295 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
296};
297
298static int __init init_vmi_clocksource(void)
299{
300 cycle_t cycles_per_msec;
301
302 if (!vmi_timer_ops.get_cycle_frequency)
303 return 0;
304 /* Use khz2mult rather than hz2mult since hz arg is only 32-bits. */
305 cycles_per_msec = vmi_timer_ops.get_cycle_frequency();
306 (void)do_div(cycles_per_msec, 1000);
307
308 /* Note that clocksource.{mult, shift} converts in the opposite direction
309 * as clockevents. */
310 clocksource_vmi.mult = clocksource_khz2mult(cycles_per_msec,
311 clocksource_vmi.shift);
312
313 printk(KERN_WARNING "vmi: registering clock source khz=%lld\n", cycles_per_msec);
314 return clocksource_register(&clocksource_vmi);
315
316}
317module_init(init_vmi_clocksource);
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index d0bb52296fa3..e03530aebfd0 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -242,6 +242,12 @@ SECTIONS
242 __x86_cpu_dev_end = .; 242 __x86_cpu_dev_end = .;
243 } 243 }
244 244
245 /*
246 * start address and size of operations which during runtime
247 * can be patched with virtualization friendly instructions or
248 * baremetal native ones. Think page table operations.
249 * Details in paravirt_types.h
250 */
245 . = ALIGN(8); 251 . = ALIGN(8);
246 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { 252 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
247 __parainstructions = .; 253 __parainstructions = .;
@@ -249,6 +255,11 @@ SECTIONS
249 __parainstructions_end = .; 255 __parainstructions_end = .;
250 } 256 }
251 257
258 /*
259 * struct alt_inst entries. From the header (alternative.h):
260 * "Alternative instructions for different CPU types or capabilities"
261 * Think locking instructions on spinlocks.
262 */
252 . = ALIGN(8); 263 . = ALIGN(8);
253 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { 264 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
254 __alt_instructions = .; 265 __alt_instructions = .;
@@ -256,11 +267,28 @@ SECTIONS
256 __alt_instructions_end = .; 267 __alt_instructions_end = .;
257 } 268 }
258 269
270 /*
271 * And here are the replacement instructions. The linker sticks
272 * them as binary blobs. The .altinstructions has enough data to
273 * get the address and the length of them to patch the kernel safely.
274 */
259 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { 275 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
260 *(.altinstr_replacement) 276 *(.altinstr_replacement)
261 } 277 }
262 278
263 /* 279 /*
280 * struct iommu_table_entry entries are injected in this section.
281 * It is an array of IOMMUs which during run time gets sorted depending
282 * on its dependency order. After rootfs_initcall is complete
283 * this section can be safely removed.
284 */
285 .iommu_table : AT(ADDR(.iommu_table) - LOAD_OFFSET) {
286 __iommu_table = .;
287 *(.iommu_table)
288 __iommu_table_end = .;
289 }
290 . = ALIGN(8);
291 /*
264 * .exit.text is discard at runtime, not link time, to deal with 292 * .exit.text is discard at runtime, not link time, to deal with
265 * references from .altinstructions and .eh_frame 293 * references from .altinstructions and .eh_frame
266 */ 294 */
@@ -273,7 +301,7 @@ SECTIONS
273 } 301 }
274 302
275#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP) 303#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
276 PERCPU(PAGE_SIZE) 304 PERCPU(THREAD_SIZE)
277#endif 305#endif
278 306
279 . = ALIGN(PAGE_SIZE); 307 . = ALIGN(PAGE_SIZE);
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 970bbd479516..ddc131ff438f 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -64,6 +64,13 @@ config KVM_AMD
64 To compile this as a module, choose M here: the module 64 To compile this as a module, choose M here: the module
65 will be called kvm-amd. 65 will be called kvm-amd.
66 66
67config KVM_MMU_AUDIT
68 bool "Audit KVM MMU"
69 depends on KVM && TRACEPOINTS
70 ---help---
71 This option adds a R/W kVM module parameter 'mmu_audit', which allows
72 audit KVM MMU at runtime.
73
67# OK, it's a little counter-intuitive to do this, but it puts it neatly under 74# OK, it's a little counter-intuitive to do this, but it puts it neatly under
68# the virtualization menu. 75# the virtualization menu.
69source drivers/vhost/Kconfig 76source drivers/vhost/Kconfig
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 66ca98aafdd6..38b6e8dafaff 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -9,7 +9,7 @@
9 * privileged instructions: 9 * privileged instructions:
10 * 10 *
11 * Copyright (C) 2006 Qumranet 11 * Copyright (C) 2006 Qumranet
12 * Copyright 2010 Red Hat, Inc. and/or its affilates. 12 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
13 * 13 *
14 * Avi Kivity <avi@qumranet.com> 14 * Avi Kivity <avi@qumranet.com>
15 * Yaniv Kamay <yaniv@qumranet.com> 15 * Yaniv Kamay <yaniv@qumranet.com>
@@ -51,13 +51,13 @@
51#define ImplicitOps (1<<1) /* Implicit in opcode. No generic decode. */ 51#define ImplicitOps (1<<1) /* Implicit in opcode. No generic decode. */
52#define DstReg (2<<1) /* Register operand. */ 52#define DstReg (2<<1) /* Register operand. */
53#define DstMem (3<<1) /* Memory operand. */ 53#define DstMem (3<<1) /* Memory operand. */
54#define DstAcc (4<<1) /* Destination Accumulator */ 54#define DstAcc (4<<1) /* Destination Accumulator */
55#define DstDI (5<<1) /* Destination is in ES:(E)DI */ 55#define DstDI (5<<1) /* Destination is in ES:(E)DI */
56#define DstMem64 (6<<1) /* 64bit memory operand */ 56#define DstMem64 (6<<1) /* 64bit memory operand */
57#define DstImmUByte (7<<1) /* 8-bit unsigned immediate operand */
57#define DstMask (7<<1) 58#define DstMask (7<<1)
58/* Source operand type. */ 59/* Source operand type. */
59#define SrcNone (0<<4) /* No source operand. */ 60#define SrcNone (0<<4) /* No source operand. */
60#define SrcImplicit (0<<4) /* Source operand is implicit in the opcode. */
61#define SrcReg (1<<4) /* Register operand. */ 61#define SrcReg (1<<4) /* Register operand. */
62#define SrcMem (2<<4) /* Memory operand. */ 62#define SrcMem (2<<4) /* Memory operand. */
63#define SrcMem16 (3<<4) /* Memory operand (16-bit). */ 63#define SrcMem16 (3<<4) /* Memory operand (16-bit). */
@@ -71,6 +71,7 @@
71#define SrcImmFAddr (0xb<<4) /* Source is immediate far address */ 71#define SrcImmFAddr (0xb<<4) /* Source is immediate far address */
72#define SrcMemFAddr (0xc<<4) /* Source is far address in memory */ 72#define SrcMemFAddr (0xc<<4) /* Source is far address in memory */
73#define SrcAcc (0xd<<4) /* Source Accumulator */ 73#define SrcAcc (0xd<<4) /* Source Accumulator */
74#define SrcImmU16 (0xe<<4) /* Immediate operand, unsigned, 16 bits */
74#define SrcMask (0xf<<4) 75#define SrcMask (0xf<<4)
75/* Generic ModRM decode. */ 76/* Generic ModRM decode. */
76#define ModRM (1<<8) 77#define ModRM (1<<8)
@@ -82,8 +83,10 @@
82#define Stack (1<<13) /* Stack instruction (push/pop) */ 83#define Stack (1<<13) /* Stack instruction (push/pop) */
83#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */ 84#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */
84#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */ 85#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
85#define GroupMask 0xff /* Group number stored in bits 0:7 */
86/* Misc flags */ 86/* Misc flags */
87#define NoAccess (1<<23) /* Don't access memory (lea/invlpg/verr etc) */
88#define Op3264 (1<<24) /* Operand is 64b in long mode, 32b otherwise */
89#define Undefined (1<<25) /* No Such Instruction */
87#define Lock (1<<26) /* lock prefix is allowed for the instruction */ 90#define Lock (1<<26) /* lock prefix is allowed for the instruction */
88#define Priv (1<<27) /* instruction generates #GP if current CPL != 0 */ 91#define Priv (1<<27) /* instruction generates #GP if current CPL != 0 */
89#define No64 (1<<28) 92#define No64 (1<<28)
@@ -92,285 +95,30 @@
92#define Src2CL (1<<29) 95#define Src2CL (1<<29)
93#define Src2ImmByte (2<<29) 96#define Src2ImmByte (2<<29)
94#define Src2One (3<<29) 97#define Src2One (3<<29)
98#define Src2Imm (4<<29)
95#define Src2Mask (7<<29) 99#define Src2Mask (7<<29)
96 100
97enum { 101#define X2(x...) x, x
98 Group1_80, Group1_81, Group1_82, Group1_83, 102#define X3(x...) X2(x), x
99 Group1A, Group3_Byte, Group3, Group4, Group5, Group7, 103#define X4(x...) X2(x), X2(x)
100 Group8, Group9, 104#define X5(x...) X4(x), x
105#define X6(x...) X4(x), X2(x)
106#define X7(x...) X4(x), X3(x)
107#define X8(x...) X4(x), X4(x)
108#define X16(x...) X8(x), X8(x)
109
110struct opcode {
111 u32 flags;
112 union {
113 int (*execute)(struct x86_emulate_ctxt *ctxt);
114 struct opcode *group;
115 struct group_dual *gdual;
116 } u;
101}; 117};
102 118
103static u32 opcode_table[256] = { 119struct group_dual {
104 /* 0x00 - 0x07 */ 120 struct opcode mod012[8];
105 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock, 121 struct opcode mod3[8];
106 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
107 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
108 ImplicitOps | Stack | No64, ImplicitOps | Stack | No64,
109 /* 0x08 - 0x0F */
110 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
111 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
112 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
113 ImplicitOps | Stack | No64, 0,
114 /* 0x10 - 0x17 */
115 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
116 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
117 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
118 ImplicitOps | Stack | No64, ImplicitOps | Stack | No64,
119 /* 0x18 - 0x1F */
120 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
121 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
122 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
123 ImplicitOps | Stack | No64, ImplicitOps | Stack | No64,
124 /* 0x20 - 0x27 */
125 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
126 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
127 ByteOp | DstAcc | SrcImmByte, DstAcc | SrcImm, 0, 0,
128 /* 0x28 - 0x2F */
129 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
130 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
131 ByteOp | DstAcc | SrcImmByte, DstAcc | SrcImm, 0, 0,
132 /* 0x30 - 0x37 */
133 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
134 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
135 ByteOp | DstAcc | SrcImmByte, DstAcc | SrcImm, 0, 0,
136 /* 0x38 - 0x3F */
137 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
138 ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
139 ByteOp | DstAcc | SrcImm, DstAcc | SrcImm,
140 0, 0,
141 /* 0x40 - 0x47 */
142 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
143 /* 0x48 - 0x4F */
144 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
145 /* 0x50 - 0x57 */
146 SrcReg | Stack, SrcReg | Stack, SrcReg | Stack, SrcReg | Stack,
147 SrcReg | Stack, SrcReg | Stack, SrcReg | Stack, SrcReg | Stack,
148 /* 0x58 - 0x5F */
149 DstReg | Stack, DstReg | Stack, DstReg | Stack, DstReg | Stack,
150 DstReg | Stack, DstReg | Stack, DstReg | Stack, DstReg | Stack,
151 /* 0x60 - 0x67 */
152 ImplicitOps | Stack | No64, ImplicitOps | Stack | No64,
153 0, DstReg | SrcMem32 | ModRM | Mov /* movsxd (x86/64) */ ,
154 0, 0, 0, 0,
155 /* 0x68 - 0x6F */
156 SrcImm | Mov | Stack, 0, SrcImmByte | Mov | Stack, 0,
157 DstDI | ByteOp | Mov | String, DstDI | Mov | String, /* insb, insw/insd */
158 SrcSI | ByteOp | ImplicitOps | String, SrcSI | ImplicitOps | String, /* outsb, outsw/outsd */
159 /* 0x70 - 0x77 */
160 SrcImmByte, SrcImmByte, SrcImmByte, SrcImmByte,
161 SrcImmByte, SrcImmByte, SrcImmByte, SrcImmByte,
162 /* 0x78 - 0x7F */
163 SrcImmByte, SrcImmByte, SrcImmByte, SrcImmByte,
164 SrcImmByte, SrcImmByte, SrcImmByte, SrcImmByte,
165 /* 0x80 - 0x87 */
166 Group | Group1_80, Group | Group1_81,
167 Group | Group1_82, Group | Group1_83,
168 ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
169 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
170 /* 0x88 - 0x8F */
171 ByteOp | DstMem | SrcReg | ModRM | Mov, DstMem | SrcReg | ModRM | Mov,
172 ByteOp | DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
173 DstMem | SrcNone | ModRM | Mov, ModRM | DstReg,
174 ImplicitOps | SrcMem16 | ModRM, Group | Group1A,
175 /* 0x90 - 0x97 */
176 DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
177 /* 0x98 - 0x9F */
178 0, 0, SrcImmFAddr | No64, 0,
179 ImplicitOps | Stack, ImplicitOps | Stack, 0, 0,
180 /* 0xA0 - 0xA7 */
181 ByteOp | DstAcc | SrcMem | Mov | MemAbs, DstAcc | SrcMem | Mov | MemAbs,
182 ByteOp | DstMem | SrcAcc | Mov | MemAbs, DstMem | SrcAcc | Mov | MemAbs,
183 ByteOp | SrcSI | DstDI | Mov | String, SrcSI | DstDI | Mov | String,
184 ByteOp | SrcSI | DstDI | String, SrcSI | DstDI | String,
185 /* 0xA8 - 0xAF */
186 DstAcc | SrcImmByte | ByteOp, DstAcc | SrcImm, ByteOp | DstDI | Mov | String, DstDI | Mov | String,
187 ByteOp | SrcSI | DstAcc | Mov | String, SrcSI | DstAcc | Mov | String,
188 ByteOp | DstDI | String, DstDI | String,
189 /* 0xB0 - 0xB7 */
190 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
191 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
192 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
193 ByteOp | DstReg | SrcImm | Mov, ByteOp | DstReg | SrcImm | Mov,
194 /* 0xB8 - 0xBF */
195 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
196 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
197 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
198 DstReg | SrcImm | Mov, DstReg | SrcImm | Mov,
199 /* 0xC0 - 0xC7 */
200 ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM,
201 0, ImplicitOps | Stack, 0, 0,
202 ByteOp | DstMem | SrcImm | ModRM | Mov, DstMem | SrcImm | ModRM | Mov,
203 /* 0xC8 - 0xCF */
204 0, 0, 0, ImplicitOps | Stack,
205 ImplicitOps, SrcImmByte, ImplicitOps | No64, ImplicitOps,
206 /* 0xD0 - 0xD7 */
207 ByteOp | DstMem | SrcImplicit | ModRM, DstMem | SrcImplicit | ModRM,
208 ByteOp | DstMem | SrcImplicit | ModRM, DstMem | SrcImplicit | ModRM,
209 0, 0, 0, 0,
210 /* 0xD8 - 0xDF */
211 0, 0, 0, 0, 0, 0, 0, 0,
212 /* 0xE0 - 0xE7 */
213 0, 0, 0, 0,
214 ByteOp | SrcImmUByte | DstAcc, SrcImmUByte | DstAcc,
215 ByteOp | SrcImmUByte | DstAcc, SrcImmUByte | DstAcc,
216 /* 0xE8 - 0xEF */
217 SrcImm | Stack, SrcImm | ImplicitOps,
218 SrcImmFAddr | No64, SrcImmByte | ImplicitOps,
219 SrcNone | ByteOp | DstAcc, SrcNone | DstAcc,
220 SrcNone | ByteOp | DstAcc, SrcNone | DstAcc,
221 /* 0xF0 - 0xF7 */
222 0, 0, 0, 0,
223 ImplicitOps | Priv, ImplicitOps, Group | Group3_Byte, Group | Group3,
224 /* 0xF8 - 0xFF */
225 ImplicitOps, 0, ImplicitOps, ImplicitOps,
226 ImplicitOps, ImplicitOps, Group | Group4, Group | Group5,
227};
228
229static u32 twobyte_table[256] = {
230 /* 0x00 - 0x0F */
231 0, Group | GroupDual | Group7, 0, 0,
232 0, ImplicitOps, ImplicitOps | Priv, 0,
233 ImplicitOps | Priv, ImplicitOps | Priv, 0, 0,
234 0, ImplicitOps | ModRM, 0, 0,
235 /* 0x10 - 0x1F */
236 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
237 /* 0x20 - 0x2F */
238 ModRM | ImplicitOps | Priv, ModRM | Priv,
239 ModRM | ImplicitOps | Priv, ModRM | Priv,
240 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 0, 0, 0,
242 /* 0x30 - 0x3F */
243 ImplicitOps | Priv, 0, ImplicitOps | Priv, 0,
244 ImplicitOps, ImplicitOps | Priv, 0, 0,
245 0, 0, 0, 0, 0, 0, 0, 0,
246 /* 0x40 - 0x47 */
247 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
248 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
249 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
250 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
251 /* 0x48 - 0x4F */
252 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
253 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
254 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
255 DstReg | SrcMem | ModRM | Mov, DstReg | SrcMem | ModRM | Mov,
256 /* 0x50 - 0x5F */
257 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
258 /* 0x60 - 0x6F */
259 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
260 /* 0x70 - 0x7F */
261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262 /* 0x80 - 0x8F */
263 SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm,
264 SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm, SrcImm,
265 /* 0x90 - 0x9F */
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
267 /* 0xA0 - 0xA7 */
268 ImplicitOps | Stack, ImplicitOps | Stack,
269 0, DstMem | SrcReg | ModRM | BitOp,
270 DstMem | SrcReg | Src2ImmByte | ModRM,
271 DstMem | SrcReg | Src2CL | ModRM, 0, 0,
272 /* 0xA8 - 0xAF */
273 ImplicitOps | Stack, ImplicitOps | Stack,
274 0, DstMem | SrcReg | ModRM | BitOp | Lock,
275 DstMem | SrcReg | Src2ImmByte | ModRM,
276 DstMem | SrcReg | Src2CL | ModRM,
277 ModRM, 0,
278 /* 0xB0 - 0xB7 */
279 ByteOp | DstMem | SrcReg | ModRM | Lock, DstMem | SrcReg | ModRM | Lock,
280 0, DstMem | SrcReg | ModRM | BitOp | Lock,
281 0, 0, ByteOp | DstReg | SrcMem | ModRM | Mov,
282 DstReg | SrcMem16 | ModRM | Mov,
283 /* 0xB8 - 0xBF */
284 0, 0,
285 Group | Group8, DstMem | SrcReg | ModRM | BitOp | Lock,
286 0, 0, ByteOp | DstReg | SrcMem | ModRM | Mov,
287 DstReg | SrcMem16 | ModRM | Mov,
288 /* 0xC0 - 0xCF */
289 0, 0, 0, DstMem | SrcReg | ModRM | Mov,
290 0, 0, 0, Group | GroupDual | Group9,
291 0, 0, 0, 0, 0, 0, 0, 0,
292 /* 0xD0 - 0xDF */
293 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
294 /* 0xE0 - 0xEF */
295 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
296 /* 0xF0 - 0xFF */
297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
298};
299
300static u32 group_table[] = {
301 [Group1_80*8] =
302 ByteOp | DstMem | SrcImm | ModRM | Lock,
303 ByteOp | DstMem | SrcImm | ModRM | Lock,
304 ByteOp | DstMem | SrcImm | ModRM | Lock,
305 ByteOp | DstMem | SrcImm | ModRM | Lock,
306 ByteOp | DstMem | SrcImm | ModRM | Lock,
307 ByteOp | DstMem | SrcImm | ModRM | Lock,
308 ByteOp | DstMem | SrcImm | ModRM | Lock,
309 ByteOp | DstMem | SrcImm | ModRM,
310 [Group1_81*8] =
311 DstMem | SrcImm | ModRM | Lock,
312 DstMem | SrcImm | ModRM | Lock,
313 DstMem | SrcImm | ModRM | Lock,
314 DstMem | SrcImm | ModRM | Lock,
315 DstMem | SrcImm | ModRM | Lock,
316 DstMem | SrcImm | ModRM | Lock,
317 DstMem | SrcImm | ModRM | Lock,
318 DstMem | SrcImm | ModRM,
319 [Group1_82*8] =
320 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
321 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
322 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
323 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
324 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
325 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
326 ByteOp | DstMem | SrcImm | ModRM | No64 | Lock,
327 ByteOp | DstMem | SrcImm | ModRM | No64,
328 [Group1_83*8] =
329 DstMem | SrcImmByte | ModRM | Lock,
330 DstMem | SrcImmByte | ModRM | Lock,
331 DstMem | SrcImmByte | ModRM | Lock,
332 DstMem | SrcImmByte | ModRM | Lock,
333 DstMem | SrcImmByte | ModRM | Lock,
334 DstMem | SrcImmByte | ModRM | Lock,
335 DstMem | SrcImmByte | ModRM | Lock,
336 DstMem | SrcImmByte | ModRM,
337 [Group1A*8] =
338 DstMem | SrcNone | ModRM | Mov | Stack, 0, 0, 0, 0, 0, 0, 0,
339 [Group3_Byte*8] =
340 ByteOp | SrcImm | DstMem | ModRM, ByteOp | SrcImm | DstMem | ModRM,
341 ByteOp | DstMem | SrcNone | ModRM, ByteOp | DstMem | SrcNone | ModRM,
342 0, 0, 0, 0,
343 [Group3*8] =
344 DstMem | SrcImm | ModRM, DstMem | SrcImm | ModRM,
345 DstMem | SrcNone | ModRM, DstMem | SrcNone | ModRM,
346 0, 0, 0, 0,
347 [Group4*8] =
348 ByteOp | DstMem | SrcNone | ModRM | Lock, ByteOp | DstMem | SrcNone | ModRM | Lock,
349 0, 0, 0, 0, 0, 0,
350 [Group5*8] =
351 DstMem | SrcNone | ModRM | Lock, DstMem | SrcNone | ModRM | Lock,
352 SrcMem | ModRM | Stack, 0,
353 SrcMem | ModRM | Stack, SrcMemFAddr | ModRM | ImplicitOps,
354 SrcMem | ModRM | Stack, 0,
355 [Group7*8] =
356 0, 0, ModRM | SrcMem | Priv, ModRM | SrcMem | Priv,
357 SrcNone | ModRM | DstMem | Mov, 0,
358 SrcMem16 | ModRM | Mov | Priv, SrcMem | ModRM | ByteOp | Priv,
359 [Group8*8] =
360 0, 0, 0, 0,
361 DstMem | SrcImmByte | ModRM, DstMem | SrcImmByte | ModRM | Lock,
362 DstMem | SrcImmByte | ModRM | Lock, DstMem | SrcImmByte | ModRM | Lock,
363 [Group9*8] =
364 0, DstMem64 | ModRM | Lock, 0, 0, 0, 0, 0, 0,
365};
366
367static u32 group2_table[] = {
368 [Group7*8] =
369 SrcNone | ModRM | Priv, 0, 0, SrcNone | ModRM | Priv,
370 SrcNone | ModRM | DstMem | Mov, 0,
371 SrcMem16 | ModRM | Mov | Priv, 0,
372 [Group9*8] =
373 0, 0, 0, 0, 0, 0, 0, 0,
374}; 122};
375 123
376/* EFLAGS bit definitions. */ 124/* EFLAGS bit definitions. */
@@ -392,6 +140,9 @@ static u32 group2_table[] = {
392#define EFLG_PF (1<<2) 140#define EFLG_PF (1<<2)
393#define EFLG_CF (1<<0) 141#define EFLG_CF (1<<0)
394 142
143#define EFLG_RESERVED_ZEROS_MASK 0xffc0802a
144#define EFLG_RESERVED_ONE_MASK 2
145
395/* 146/*
396 * Instruction emulation: 147 * Instruction emulation:
397 * Most instructions are emulated directly via a fragment of inline assembly 148 * Most instructions are emulated directly via a fragment of inline assembly
@@ -444,13 +195,13 @@ static u32 group2_table[] = {
444#define ON64(x) 195#define ON64(x)
445#endif 196#endif
446 197
447#define ____emulate_2op(_op, _src, _dst, _eflags, _x, _y, _suffix) \ 198#define ____emulate_2op(_op, _src, _dst, _eflags, _x, _y, _suffix, _dsttype) \
448 do { \ 199 do { \
449 __asm__ __volatile__ ( \ 200 __asm__ __volatile__ ( \
450 _PRE_EFLAGS("0", "4", "2") \ 201 _PRE_EFLAGS("0", "4", "2") \
451 _op _suffix " %"_x"3,%1; " \ 202 _op _suffix " %"_x"3,%1; " \
452 _POST_EFLAGS("0", "4", "2") \ 203 _POST_EFLAGS("0", "4", "2") \
453 : "=m" (_eflags), "=m" ((_dst).val), \ 204 : "=m" (_eflags), "+q" (*(_dsttype*)&(_dst).val),\
454 "=&r" (_tmp) \ 205 "=&r" (_tmp) \
455 : _y ((_src).val), "i" (EFLAGS_MASK)); \ 206 : _y ((_src).val), "i" (EFLAGS_MASK)); \
456 } while (0) 207 } while (0)
@@ -463,13 +214,13 @@ static u32 group2_table[] = {
463 \ 214 \
464 switch ((_dst).bytes) { \ 215 switch ((_dst).bytes) { \
465 case 2: \ 216 case 2: \
466 ____emulate_2op(_op,_src,_dst,_eflags,_wx,_wy,"w"); \ 217 ____emulate_2op(_op,_src,_dst,_eflags,_wx,_wy,"w",u16);\
467 break; \ 218 break; \
468 case 4: \ 219 case 4: \
469 ____emulate_2op(_op,_src,_dst,_eflags,_lx,_ly,"l"); \ 220 ____emulate_2op(_op,_src,_dst,_eflags,_lx,_ly,"l",u32);\
470 break; \ 221 break; \
471 case 8: \ 222 case 8: \
472 ON64(____emulate_2op(_op,_src,_dst,_eflags,_qx,_qy,"q")); \ 223 ON64(____emulate_2op(_op,_src,_dst,_eflags,_qx,_qy,"q",u64)); \
473 break; \ 224 break; \
474 } \ 225 } \
475 } while (0) 226 } while (0)
@@ -479,7 +230,7 @@ static u32 group2_table[] = {
479 unsigned long _tmp; \ 230 unsigned long _tmp; \
480 switch ((_dst).bytes) { \ 231 switch ((_dst).bytes) { \
481 case 1: \ 232 case 1: \
482 ____emulate_2op(_op,_src,_dst,_eflags,_bx,_by,"b"); \ 233 ____emulate_2op(_op,_src,_dst,_eflags,_bx,_by,"b",u8); \
483 break; \ 234 break; \
484 default: \ 235 default: \
485 __emulate_2op_nobyte(_op, _src, _dst, _eflags, \ 236 __emulate_2op_nobyte(_op, _src, _dst, _eflags, \
@@ -566,6 +317,74 @@ static u32 group2_table[] = {
566 } \ 317 } \
567 } while (0) 318 } while (0)
568 319
320#define __emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags, _suffix) \
321 do { \
322 unsigned long _tmp; \
323 \
324 __asm__ __volatile__ ( \
325 _PRE_EFLAGS("0", "4", "1") \
326 _op _suffix " %5; " \
327 _POST_EFLAGS("0", "4", "1") \
328 : "=m" (_eflags), "=&r" (_tmp), \
329 "+a" (_rax), "+d" (_rdx) \
330 : "i" (EFLAGS_MASK), "m" ((_src).val), \
331 "a" (_rax), "d" (_rdx)); \
332 } while (0)
333
334#define __emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, _eflags, _suffix, _ex) \
335 do { \
336 unsigned long _tmp; \
337 \
338 __asm__ __volatile__ ( \
339 _PRE_EFLAGS("0", "5", "1") \
340 "1: \n\t" \
341 _op _suffix " %6; " \
342 "2: \n\t" \
343 _POST_EFLAGS("0", "5", "1") \
344 ".pushsection .fixup,\"ax\" \n\t" \
345 "3: movb $1, %4 \n\t" \
346 "jmp 2b \n\t" \
347 ".popsection \n\t" \
348 _ASM_EXTABLE(1b, 3b) \
349 : "=m" (_eflags), "=&r" (_tmp), \
350 "+a" (_rax), "+d" (_rdx), "+qm"(_ex) \
351 : "i" (EFLAGS_MASK), "m" ((_src).val), \
352 "a" (_rax), "d" (_rdx)); \
353 } while (0)
354
355/* instruction has only one source operand, destination is implicit (e.g. mul, div, imul, idiv) */
356#define emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags) \
357 do { \
358 switch((_src).bytes) { \
359 case 1: __emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags, "b"); break; \
360 case 2: __emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags, "w"); break; \
361 case 4: __emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags, "l"); break; \
362 case 8: ON64(__emulate_1op_rax_rdx(_op, _src, _rax, _rdx, _eflags, "q")); break; \
363 } \
364 } while (0)
365
366#define emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, _eflags, _ex) \
367 do { \
368 switch((_src).bytes) { \
369 case 1: \
370 __emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, \
371 _eflags, "b", _ex); \
372 break; \
373 case 2: \
374 __emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, \
375 _eflags, "w", _ex); \
376 break; \
377 case 4: \
378 __emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, \
379 _eflags, "l", _ex); \
380 break; \
381 case 8: ON64( \
382 __emulate_1op_rax_rdx_ex(_op, _src, _rax, _rdx, \
383 _eflags, "q", _ex)); \
384 break; \
385 } \
386 } while (0)
387
569/* Fetch next part of the instruction being emulated. */ 388/* Fetch next part of the instruction being emulated. */
570#define insn_fetch(_type, _size, _eip) \ 389#define insn_fetch(_type, _size, _eip) \
571({ unsigned long _x; \ 390({ unsigned long _x; \
@@ -661,7 +480,6 @@ static void emulate_exception(struct x86_emulate_ctxt *ctxt, int vec,
661 ctxt->exception = vec; 480 ctxt->exception = vec;
662 ctxt->error_code = error; 481 ctxt->error_code = error;
663 ctxt->error_code_valid = valid; 482 ctxt->error_code_valid = valid;
664 ctxt->restart = false;
665} 483}
666 484
667static void emulate_gp(struct x86_emulate_ctxt *ctxt, int err) 485static void emulate_gp(struct x86_emulate_ctxt *ctxt, int err)
@@ -669,11 +487,9 @@ static void emulate_gp(struct x86_emulate_ctxt *ctxt, int err)
669 emulate_exception(ctxt, GP_VECTOR, err, true); 487 emulate_exception(ctxt, GP_VECTOR, err, true);
670} 488}
671 489
672static void emulate_pf(struct x86_emulate_ctxt *ctxt, unsigned long addr, 490static void emulate_pf(struct x86_emulate_ctxt *ctxt)
673 int err)
674{ 491{
675 ctxt->cr2 = addr; 492 emulate_exception(ctxt, PF_VECTOR, 0, true);
676 emulate_exception(ctxt, PF_VECTOR, err, true);
677} 493}
678 494
679static void emulate_ud(struct x86_emulate_ctxt *ctxt) 495static void emulate_ud(struct x86_emulate_ctxt *ctxt)
@@ -686,6 +502,12 @@ static void emulate_ts(struct x86_emulate_ctxt *ctxt, int err)
686 emulate_exception(ctxt, TS_VECTOR, err, true); 502 emulate_exception(ctxt, TS_VECTOR, err, true);
687} 503}
688 504
505static int emulate_de(struct x86_emulate_ctxt *ctxt)
506{
507 emulate_exception(ctxt, DE_VECTOR, 0, false);
508 return X86EMUL_PROPAGATE_FAULT;
509}
510
689static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, 511static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt,
690 struct x86_emulate_ops *ops, 512 struct x86_emulate_ops *ops,
691 unsigned long eip, u8 *dest) 513 unsigned long eip, u8 *dest)
@@ -742,7 +564,7 @@ static void *decode_register(u8 modrm_reg, unsigned long *regs,
742 564
743static int read_descriptor(struct x86_emulate_ctxt *ctxt, 565static int read_descriptor(struct x86_emulate_ctxt *ctxt,
744 struct x86_emulate_ops *ops, 566 struct x86_emulate_ops *ops,
745 void *ptr, 567 ulong addr,
746 u16 *size, unsigned long *address, int op_bytes) 568 u16 *size, unsigned long *address, int op_bytes)
747{ 569{
748 int rc; 570 int rc;
@@ -750,12 +572,10 @@ static int read_descriptor(struct x86_emulate_ctxt *ctxt,
750 if (op_bytes == 2) 572 if (op_bytes == 2)
751 op_bytes = 3; 573 op_bytes = 3;
752 *address = 0; 574 *address = 0;
753 rc = ops->read_std((unsigned long)ptr, (unsigned long *)size, 2, 575 rc = ops->read_std(addr, (unsigned long *)size, 2, ctxt->vcpu, NULL);
754 ctxt->vcpu, NULL);
755 if (rc != X86EMUL_CONTINUE) 576 if (rc != X86EMUL_CONTINUE)
756 return rc; 577 return rc;
757 rc = ops->read_std((unsigned long)ptr + 2, address, op_bytes, 578 rc = ops->read_std(addr + 2, address, op_bytes, ctxt->vcpu, NULL);
758 ctxt->vcpu, NULL);
759 return rc; 579 return rc;
760} 580}
761 581
@@ -794,6 +614,24 @@ static int test_cc(unsigned int condition, unsigned int flags)
794 return (!!rc ^ (condition & 1)); 614 return (!!rc ^ (condition & 1));
795} 615}
796 616
617static void fetch_register_operand(struct operand *op)
618{
619 switch (op->bytes) {
620 case 1:
621 op->val = *(u8 *)op->addr.reg;
622 break;
623 case 2:
624 op->val = *(u16 *)op->addr.reg;
625 break;
626 case 4:
627 op->val = *(u32 *)op->addr.reg;
628 break;
629 case 8:
630 op->val = *(u64 *)op->addr.reg;
631 break;
632 }
633}
634
797static void decode_register_operand(struct operand *op, 635static void decode_register_operand(struct operand *op,
798 struct decode_cache *c, 636 struct decode_cache *c,
799 int inhibit_bytereg) 637 int inhibit_bytereg)
@@ -805,34 +643,25 @@ static void decode_register_operand(struct operand *op,
805 reg = (c->b & 7) | ((c->rex_prefix & 1) << 3); 643 reg = (c->b & 7) | ((c->rex_prefix & 1) << 3);
806 op->type = OP_REG; 644 op->type = OP_REG;
807 if ((c->d & ByteOp) && !inhibit_bytereg) { 645 if ((c->d & ByteOp) && !inhibit_bytereg) {
808 op->ptr = decode_register(reg, c->regs, highbyte_regs); 646 op->addr.reg = decode_register(reg, c->regs, highbyte_regs);
809 op->val = *(u8 *)op->ptr;
810 op->bytes = 1; 647 op->bytes = 1;
811 } else { 648 } else {
812 op->ptr = decode_register(reg, c->regs, 0); 649 op->addr.reg = decode_register(reg, c->regs, 0);
813 op->bytes = c->op_bytes; 650 op->bytes = c->op_bytes;
814 switch (op->bytes) {
815 case 2:
816 op->val = *(u16 *)op->ptr;
817 break;
818 case 4:
819 op->val = *(u32 *)op->ptr;
820 break;
821 case 8:
822 op->val = *(u64 *) op->ptr;
823 break;
824 }
825 } 651 }
652 fetch_register_operand(op);
826 op->orig_val = op->val; 653 op->orig_val = op->val;
827} 654}
828 655
829static int decode_modrm(struct x86_emulate_ctxt *ctxt, 656static int decode_modrm(struct x86_emulate_ctxt *ctxt,
830 struct x86_emulate_ops *ops) 657 struct x86_emulate_ops *ops,
658 struct operand *op)
831{ 659{
832 struct decode_cache *c = &ctxt->decode; 660 struct decode_cache *c = &ctxt->decode;
833 u8 sib; 661 u8 sib;
834 int index_reg = 0, base_reg = 0, scale; 662 int index_reg = 0, base_reg = 0, scale;
835 int rc = X86EMUL_CONTINUE; 663 int rc = X86EMUL_CONTINUE;
664 ulong modrm_ea = 0;
836 665
837 if (c->rex_prefix) { 666 if (c->rex_prefix) {
838 c->modrm_reg = (c->rex_prefix & 4) << 1; /* REX.R */ 667 c->modrm_reg = (c->rex_prefix & 4) << 1; /* REX.R */
@@ -844,16 +673,19 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
844 c->modrm_mod |= (c->modrm & 0xc0) >> 6; 673 c->modrm_mod |= (c->modrm & 0xc0) >> 6;
845 c->modrm_reg |= (c->modrm & 0x38) >> 3; 674 c->modrm_reg |= (c->modrm & 0x38) >> 3;
846 c->modrm_rm |= (c->modrm & 0x07); 675 c->modrm_rm |= (c->modrm & 0x07);
847 c->modrm_ea = 0; 676 c->modrm_seg = VCPU_SREG_DS;
848 c->use_modrm_ea = 1;
849 677
850 if (c->modrm_mod == 3) { 678 if (c->modrm_mod == 3) {
851 c->modrm_ptr = decode_register(c->modrm_rm, 679 op->type = OP_REG;
680 op->bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
681 op->addr.reg = decode_register(c->modrm_rm,
852 c->regs, c->d & ByteOp); 682 c->regs, c->d & ByteOp);
853 c->modrm_val = *(unsigned long *)c->modrm_ptr; 683 fetch_register_operand(op);
854 return rc; 684 return rc;
855 } 685 }
856 686
687 op->type = OP_MEM;
688
857 if (c->ad_bytes == 2) { 689 if (c->ad_bytes == 2) {
858 unsigned bx = c->regs[VCPU_REGS_RBX]; 690 unsigned bx = c->regs[VCPU_REGS_RBX];
859 unsigned bp = c->regs[VCPU_REGS_RBP]; 691 unsigned bp = c->regs[VCPU_REGS_RBP];
@@ -864,47 +696,46 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
864 switch (c->modrm_mod) { 696 switch (c->modrm_mod) {
865 case 0: 697 case 0:
866 if (c->modrm_rm == 6) 698 if (c->modrm_rm == 6)
867 c->modrm_ea += insn_fetch(u16, 2, c->eip); 699 modrm_ea += insn_fetch(u16, 2, c->eip);
868 break; 700 break;
869 case 1: 701 case 1:
870 c->modrm_ea += insn_fetch(s8, 1, c->eip); 702 modrm_ea += insn_fetch(s8, 1, c->eip);
871 break; 703 break;
872 case 2: 704 case 2:
873 c->modrm_ea += insn_fetch(u16, 2, c->eip); 705 modrm_ea += insn_fetch(u16, 2, c->eip);
874 break; 706 break;
875 } 707 }
876 switch (c->modrm_rm) { 708 switch (c->modrm_rm) {
877 case 0: 709 case 0:
878 c->modrm_ea += bx + si; 710 modrm_ea += bx + si;
879 break; 711 break;
880 case 1: 712 case 1:
881 c->modrm_ea += bx + di; 713 modrm_ea += bx + di;
882 break; 714 break;
883 case 2: 715 case 2:
884 c->modrm_ea += bp + si; 716 modrm_ea += bp + si;
885 break; 717 break;
886 case 3: 718 case 3:
887 c->modrm_ea += bp + di; 719 modrm_ea += bp + di;
888 break; 720 break;
889 case 4: 721 case 4:
890 c->modrm_ea += si; 722 modrm_ea += si;
891 break; 723 break;
892 case 5: 724 case 5:
893 c->modrm_ea += di; 725 modrm_ea += di;
894 break; 726 break;
895 case 6: 727 case 6:
896 if (c->modrm_mod != 0) 728 if (c->modrm_mod != 0)
897 c->modrm_ea += bp; 729 modrm_ea += bp;
898 break; 730 break;
899 case 7: 731 case 7:
900 c->modrm_ea += bx; 732 modrm_ea += bx;
901 break; 733 break;
902 } 734 }
903 if (c->modrm_rm == 2 || c->modrm_rm == 3 || 735 if (c->modrm_rm == 2 || c->modrm_rm == 3 ||
904 (c->modrm_rm == 6 && c->modrm_mod != 0)) 736 (c->modrm_rm == 6 && c->modrm_mod != 0))
905 if (!c->has_seg_override) 737 c->modrm_seg = VCPU_SREG_SS;
906 set_seg_override(c, VCPU_SREG_SS); 738 modrm_ea = (u16)modrm_ea;
907 c->modrm_ea = (u16)c->modrm_ea;
908 } else { 739 } else {
909 /* 32/64-bit ModR/M decode. */ 740 /* 32/64-bit ModR/M decode. */
910 if ((c->modrm_rm & 7) == 4) { 741 if ((c->modrm_rm & 7) == 4) {
@@ -914,410 +745,74 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
914 scale = sib >> 6; 745 scale = sib >> 6;
915 746
916 if ((base_reg & 7) == 5 && c->modrm_mod == 0) 747 if ((base_reg & 7) == 5 && c->modrm_mod == 0)
917 c->modrm_ea += insn_fetch(s32, 4, c->eip); 748 modrm_ea += insn_fetch(s32, 4, c->eip);
918 else 749 else
919 c->modrm_ea += c->regs[base_reg]; 750 modrm_ea += c->regs[base_reg];
920 if (index_reg != 4) 751 if (index_reg != 4)
921 c->modrm_ea += c->regs[index_reg] << scale; 752 modrm_ea += c->regs[index_reg] << scale;
922 } else if ((c->modrm_rm & 7) == 5 && c->modrm_mod == 0) { 753 } else if ((c->modrm_rm & 7) == 5 && c->modrm_mod == 0) {
923 if (ctxt->mode == X86EMUL_MODE_PROT64) 754 if (ctxt->mode == X86EMUL_MODE_PROT64)
924 c->rip_relative = 1; 755 c->rip_relative = 1;
925 } else 756 } else
926 c->modrm_ea += c->regs[c->modrm_rm]; 757 modrm_ea += c->regs[c->modrm_rm];
927 switch (c->modrm_mod) { 758 switch (c->modrm_mod) {
928 case 0: 759 case 0:
929 if (c->modrm_rm == 5) 760 if (c->modrm_rm == 5)
930 c->modrm_ea += insn_fetch(s32, 4, c->eip); 761 modrm_ea += insn_fetch(s32, 4, c->eip);
931 break; 762 break;
932 case 1: 763 case 1:
933 c->modrm_ea += insn_fetch(s8, 1, c->eip); 764 modrm_ea += insn_fetch(s8, 1, c->eip);
934 break; 765 break;
935 case 2: 766 case 2:
936 c->modrm_ea += insn_fetch(s32, 4, c->eip); 767 modrm_ea += insn_fetch(s32, 4, c->eip);
937 break; 768 break;
938 } 769 }
939 } 770 }
771 op->addr.mem = modrm_ea;
940done: 772done:
941 return rc; 773 return rc;
942} 774}
943 775
944static int decode_abs(struct x86_emulate_ctxt *ctxt, 776static int decode_abs(struct x86_emulate_ctxt *ctxt,
945 struct x86_emulate_ops *ops) 777 struct x86_emulate_ops *ops,
778 struct operand *op)
946{ 779{
947 struct decode_cache *c = &ctxt->decode; 780 struct decode_cache *c = &ctxt->decode;
948 int rc = X86EMUL_CONTINUE; 781 int rc = X86EMUL_CONTINUE;
949 782
783 op->type = OP_MEM;
950 switch (c->ad_bytes) { 784 switch (c->ad_bytes) {
951 case 2: 785 case 2:
952 c->modrm_ea = insn_fetch(u16, 2, c->eip); 786 op->addr.mem = insn_fetch(u16, 2, c->eip);
953 break; 787 break;
954 case 4: 788 case 4:
955 c->modrm_ea = insn_fetch(u32, 4, c->eip); 789 op->addr.mem = insn_fetch(u32, 4, c->eip);
956 break; 790 break;
957 case 8: 791 case 8:
958 c->modrm_ea = insn_fetch(u64, 8, c->eip); 792 op->addr.mem = insn_fetch(u64, 8, c->eip);
959 break; 793 break;
960 } 794 }
961done: 795done:
962 return rc; 796 return rc;
963} 797}
964 798
965int 799static void fetch_bit_operand(struct decode_cache *c)
966x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
967{ 800{
968 struct decode_cache *c = &ctxt->decode; 801 long sv = 0, mask;
969 int rc = X86EMUL_CONTINUE;
970 int mode = ctxt->mode;
971 int def_op_bytes, def_ad_bytes, group;
972
973
974 /* we cannot decode insn before we complete previous rep insn */
975 WARN_ON(ctxt->restart);
976
977 c->eip = ctxt->eip;
978 c->fetch.start = c->fetch.end = c->eip;
979 ctxt->cs_base = seg_base(ctxt, ops, VCPU_SREG_CS);
980
981 switch (mode) {
982 case X86EMUL_MODE_REAL:
983 case X86EMUL_MODE_VM86:
984 case X86EMUL_MODE_PROT16:
985 def_op_bytes = def_ad_bytes = 2;
986 break;
987 case X86EMUL_MODE_PROT32:
988 def_op_bytes = def_ad_bytes = 4;
989 break;
990#ifdef CONFIG_X86_64
991 case X86EMUL_MODE_PROT64:
992 def_op_bytes = 4;
993 def_ad_bytes = 8;
994 break;
995#endif
996 default:
997 return -1;
998 }
999
1000 c->op_bytes = def_op_bytes;
1001 c->ad_bytes = def_ad_bytes;
1002
1003 /* Legacy prefixes. */
1004 for (;;) {
1005 switch (c->b = insn_fetch(u8, 1, c->eip)) {
1006 case 0x66: /* operand-size override */
1007 /* switch between 2/4 bytes */
1008 c->op_bytes = def_op_bytes ^ 6;
1009 break;
1010 case 0x67: /* address-size override */
1011 if (mode == X86EMUL_MODE_PROT64)
1012 /* switch between 4/8 bytes */
1013 c->ad_bytes = def_ad_bytes ^ 12;
1014 else
1015 /* switch between 2/4 bytes */
1016 c->ad_bytes = def_ad_bytes ^ 6;
1017 break;
1018 case 0x26: /* ES override */
1019 case 0x2e: /* CS override */
1020 case 0x36: /* SS override */
1021 case 0x3e: /* DS override */
1022 set_seg_override(c, (c->b >> 3) & 3);
1023 break;
1024 case 0x64: /* FS override */
1025 case 0x65: /* GS override */
1026 set_seg_override(c, c->b & 7);
1027 break;
1028 case 0x40 ... 0x4f: /* REX */
1029 if (mode != X86EMUL_MODE_PROT64)
1030 goto done_prefixes;
1031 c->rex_prefix = c->b;
1032 continue;
1033 case 0xf0: /* LOCK */
1034 c->lock_prefix = 1;
1035 break;
1036 case 0xf2: /* REPNE/REPNZ */
1037 c->rep_prefix = REPNE_PREFIX;
1038 break;
1039 case 0xf3: /* REP/REPE/REPZ */
1040 c->rep_prefix = REPE_PREFIX;
1041 break;
1042 default:
1043 goto done_prefixes;
1044 }
1045
1046 /* Any legacy prefix after a REX prefix nullifies its effect. */
1047
1048 c->rex_prefix = 0;
1049 }
1050
1051done_prefixes:
1052
1053 /* REX prefix. */
1054 if (c->rex_prefix)
1055 if (c->rex_prefix & 8)
1056 c->op_bytes = 8; /* REX.W */
1057
1058 /* Opcode byte(s). */
1059 c->d = opcode_table[c->b];
1060 if (c->d == 0) {
1061 /* Two-byte opcode? */
1062 if (c->b == 0x0f) {
1063 c->twobyte = 1;
1064 c->b = insn_fetch(u8, 1, c->eip);
1065 c->d = twobyte_table[c->b];
1066 }
1067 }
1068
1069 if (c->d & Group) {
1070 group = c->d & GroupMask;
1071 c->modrm = insn_fetch(u8, 1, c->eip);
1072 --c->eip;
1073
1074 group = (group << 3) + ((c->modrm >> 3) & 7);
1075 if ((c->d & GroupDual) && (c->modrm >> 6) == 3)
1076 c->d = group2_table[group];
1077 else
1078 c->d = group_table[group];
1079 }
1080
1081 /* Unrecognised? */
1082 if (c->d == 0) {
1083 DPRINTF("Cannot emulate %02x\n", c->b);
1084 return -1;
1085 }
1086
1087 if (mode == X86EMUL_MODE_PROT64 && (c->d & Stack))
1088 c->op_bytes = 8;
1089
1090 /* ModRM and SIB bytes. */
1091 if (c->d & ModRM)
1092 rc = decode_modrm(ctxt, ops);
1093 else if (c->d & MemAbs)
1094 rc = decode_abs(ctxt, ops);
1095 if (rc != X86EMUL_CONTINUE)
1096 goto done;
1097
1098 if (!c->has_seg_override)
1099 set_seg_override(c, VCPU_SREG_DS);
1100
1101 if (!(!c->twobyte && c->b == 0x8d))
1102 c->modrm_ea += seg_override_base(ctxt, ops, c);
1103
1104 if (c->ad_bytes != 8)
1105 c->modrm_ea = (u32)c->modrm_ea;
1106
1107 if (c->rip_relative)
1108 c->modrm_ea += c->eip;
1109
1110 /*
1111 * Decode and fetch the source operand: register, memory
1112 * or immediate.
1113 */
1114 switch (c->d & SrcMask) {
1115 case SrcNone:
1116 break;
1117 case SrcReg:
1118 decode_register_operand(&c->src, c, 0);
1119 break;
1120 case SrcMem16:
1121 c->src.bytes = 2;
1122 goto srcmem_common;
1123 case SrcMem32:
1124 c->src.bytes = 4;
1125 goto srcmem_common;
1126 case SrcMem:
1127 c->src.bytes = (c->d & ByteOp) ? 1 :
1128 c->op_bytes;
1129 /* Don't fetch the address for invlpg: it could be unmapped. */
1130 if (c->twobyte && c->b == 0x01 && c->modrm_reg == 7)
1131 break;
1132 srcmem_common:
1133 /*
1134 * For instructions with a ModR/M byte, switch to register
1135 * access if Mod = 3.
1136 */
1137 if ((c->d & ModRM) && c->modrm_mod == 3) {
1138 c->src.type = OP_REG;
1139 c->src.val = c->modrm_val;
1140 c->src.ptr = c->modrm_ptr;
1141 break;
1142 }
1143 c->src.type = OP_MEM;
1144 c->src.ptr = (unsigned long *)c->modrm_ea;
1145 c->src.val = 0;
1146 break;
1147 case SrcImm:
1148 case SrcImmU:
1149 c->src.type = OP_IMM;
1150 c->src.ptr = (unsigned long *)c->eip;
1151 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1152 if (c->src.bytes == 8)
1153 c->src.bytes = 4;
1154 /* NB. Immediates are sign-extended as necessary. */
1155 switch (c->src.bytes) {
1156 case 1:
1157 c->src.val = insn_fetch(s8, 1, c->eip);
1158 break;
1159 case 2:
1160 c->src.val = insn_fetch(s16, 2, c->eip);
1161 break;
1162 case 4:
1163 c->src.val = insn_fetch(s32, 4, c->eip);
1164 break;
1165 }
1166 if ((c->d & SrcMask) == SrcImmU) {
1167 switch (c->src.bytes) {
1168 case 1:
1169 c->src.val &= 0xff;
1170 break;
1171 case 2:
1172 c->src.val &= 0xffff;
1173 break;
1174 case 4:
1175 c->src.val &= 0xffffffff;
1176 break;
1177 }
1178 }
1179 break;
1180 case SrcImmByte:
1181 case SrcImmUByte:
1182 c->src.type = OP_IMM;
1183 c->src.ptr = (unsigned long *)c->eip;
1184 c->src.bytes = 1;
1185 if ((c->d & SrcMask) == SrcImmByte)
1186 c->src.val = insn_fetch(s8, 1, c->eip);
1187 else
1188 c->src.val = insn_fetch(u8, 1, c->eip);
1189 break;
1190 case SrcAcc:
1191 c->src.type = OP_REG;
1192 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1193 c->src.ptr = &c->regs[VCPU_REGS_RAX];
1194 switch (c->src.bytes) {
1195 case 1:
1196 c->src.val = *(u8 *)c->src.ptr;
1197 break;
1198 case 2:
1199 c->src.val = *(u16 *)c->src.ptr;
1200 break;
1201 case 4:
1202 c->src.val = *(u32 *)c->src.ptr;
1203 break;
1204 case 8:
1205 c->src.val = *(u64 *)c->src.ptr;
1206 break;
1207 }
1208 break;
1209 case SrcOne:
1210 c->src.bytes = 1;
1211 c->src.val = 1;
1212 break;
1213 case SrcSI:
1214 c->src.type = OP_MEM;
1215 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1216 c->src.ptr = (unsigned long *)
1217 register_address(c, seg_override_base(ctxt, ops, c),
1218 c->regs[VCPU_REGS_RSI]);
1219 c->src.val = 0;
1220 break;
1221 case SrcImmFAddr:
1222 c->src.type = OP_IMM;
1223 c->src.ptr = (unsigned long *)c->eip;
1224 c->src.bytes = c->op_bytes + 2;
1225 insn_fetch_arr(c->src.valptr, c->src.bytes, c->eip);
1226 break;
1227 case SrcMemFAddr:
1228 c->src.type = OP_MEM;
1229 c->src.ptr = (unsigned long *)c->modrm_ea;
1230 c->src.bytes = c->op_bytes + 2;
1231 break;
1232 }
1233 802
1234 /* 803 if (c->dst.type == OP_MEM && c->src.type == OP_REG) {
1235 * Decode and fetch the second source operand: register, memory 804 mask = ~(c->dst.bytes * 8 - 1);
1236 * or immediate.
1237 */
1238 switch (c->d & Src2Mask) {
1239 case Src2None:
1240 break;
1241 case Src2CL:
1242 c->src2.bytes = 1;
1243 c->src2.val = c->regs[VCPU_REGS_RCX] & 0x8;
1244 break;
1245 case Src2ImmByte:
1246 c->src2.type = OP_IMM;
1247 c->src2.ptr = (unsigned long *)c->eip;
1248 c->src2.bytes = 1;
1249 c->src2.val = insn_fetch(u8, 1, c->eip);
1250 break;
1251 case Src2One:
1252 c->src2.bytes = 1;
1253 c->src2.val = 1;
1254 break;
1255 }
1256 805
1257 /* Decode and fetch the destination operand: register or memory. */ 806 if (c->src.bytes == 2)
1258 switch (c->d & DstMask) { 807 sv = (s16)c->src.val & (s16)mask;
1259 case ImplicitOps: 808 else if (c->src.bytes == 4)
1260 /* Special instructions do their own operand decoding. */ 809 sv = (s32)c->src.val & (s32)mask;
1261 return 0;
1262 case DstReg:
1263 decode_register_operand(&c->dst, c,
1264 c->twobyte && (c->b == 0xb6 || c->b == 0xb7));
1265 break;
1266 case DstMem:
1267 case DstMem64:
1268 if ((c->d & ModRM) && c->modrm_mod == 3) {
1269 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1270 c->dst.type = OP_REG;
1271 c->dst.val = c->dst.orig_val = c->modrm_val;
1272 c->dst.ptr = c->modrm_ptr;
1273 break;
1274 }
1275 c->dst.type = OP_MEM;
1276 c->dst.ptr = (unsigned long *)c->modrm_ea;
1277 if ((c->d & DstMask) == DstMem64)
1278 c->dst.bytes = 8;
1279 else
1280 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1281 c->dst.val = 0;
1282 if (c->d & BitOp) {
1283 unsigned long mask = ~(c->dst.bytes * 8 - 1);
1284 810
1285 c->dst.ptr = (void *)c->dst.ptr + 811 c->dst.addr.mem += (sv >> 3);
1286 (c->src.val & mask) / 8;
1287 }
1288 break;
1289 case DstAcc:
1290 c->dst.type = OP_REG;
1291 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1292 c->dst.ptr = &c->regs[VCPU_REGS_RAX];
1293 switch (c->dst.bytes) {
1294 case 1:
1295 c->dst.val = *(u8 *)c->dst.ptr;
1296 break;
1297 case 2:
1298 c->dst.val = *(u16 *)c->dst.ptr;
1299 break;
1300 case 4:
1301 c->dst.val = *(u32 *)c->dst.ptr;
1302 break;
1303 case 8:
1304 c->dst.val = *(u64 *)c->dst.ptr;
1305 break;
1306 }
1307 c->dst.orig_val = c->dst.val;
1308 break;
1309 case DstDI:
1310 c->dst.type = OP_MEM;
1311 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
1312 c->dst.ptr = (unsigned long *)
1313 register_address(c, es_base(ctxt, ops),
1314 c->regs[VCPU_REGS_RDI]);
1315 c->dst.val = 0;
1316 break;
1317 } 812 }
1318 813
1319done: 814 /* only subword offset */
1320 return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0; 815 c->src.val &= (c->dst.bytes << 3) - 1;
1321} 816}
1322 817
1323static int read_emulated(struct x86_emulate_ctxt *ctxt, 818static int read_emulated(struct x86_emulate_ctxt *ctxt,
@@ -1337,7 +832,7 @@ static int read_emulated(struct x86_emulate_ctxt *ctxt,
1337 rc = ops->read_emulated(addr, mc->data + mc->end, n, &err, 832 rc = ops->read_emulated(addr, mc->data + mc->end, n, &err,
1338 ctxt->vcpu); 833 ctxt->vcpu);
1339 if (rc == X86EMUL_PROPAGATE_FAULT) 834 if (rc == X86EMUL_PROPAGATE_FAULT)
1340 emulate_pf(ctxt, addr, err); 835 emulate_pf(ctxt);
1341 if (rc != X86EMUL_CONTINUE) 836 if (rc != X86EMUL_CONTINUE)
1342 return rc; 837 return rc;
1343 mc->end += n; 838 mc->end += n;
@@ -1424,7 +919,7 @@ static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1424 addr = dt.address + index * 8; 919 addr = dt.address + index * 8;
1425 ret = ops->read_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); 920 ret = ops->read_std(addr, desc, sizeof *desc, ctxt->vcpu, &err);
1426 if (ret == X86EMUL_PROPAGATE_FAULT) 921 if (ret == X86EMUL_PROPAGATE_FAULT)
1427 emulate_pf(ctxt, addr, err); 922 emulate_pf(ctxt);
1428 923
1429 return ret; 924 return ret;
1430} 925}
@@ -1450,7 +945,7 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1450 addr = dt.address + index * 8; 945 addr = dt.address + index * 8;
1451 ret = ops->write_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); 946 ret = ops->write_std(addr, desc, sizeof *desc, ctxt->vcpu, &err);
1452 if (ret == X86EMUL_PROPAGATE_FAULT) 947 if (ret == X86EMUL_PROPAGATE_FAULT)
1453 emulate_pf(ctxt, addr, err); 948 emulate_pf(ctxt);
1454 949
1455 return ret; 950 return ret;
1456} 951}
@@ -1573,6 +1068,25 @@ exception:
1573 return X86EMUL_PROPAGATE_FAULT; 1068 return X86EMUL_PROPAGATE_FAULT;
1574} 1069}
1575 1070
1071static void write_register_operand(struct operand *op)
1072{
1073 /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
1074 switch (op->bytes) {
1075 case 1:
1076 *(u8 *)op->addr.reg = (u8)op->val;
1077 break;
1078 case 2:
1079 *(u16 *)op->addr.reg = (u16)op->val;
1080 break;
1081 case 4:
1082 *op->addr.reg = (u32)op->val;
1083 break; /* 64b: zero-extend */
1084 case 8:
1085 *op->addr.reg = op->val;
1086 break;
1087 }
1088}
1089
1576static inline int writeback(struct x86_emulate_ctxt *ctxt, 1090static inline int writeback(struct x86_emulate_ctxt *ctxt,
1577 struct x86_emulate_ops *ops) 1091 struct x86_emulate_ops *ops)
1578{ 1092{
@@ -1582,28 +1096,12 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt,
1582 1096
1583 switch (c->dst.type) { 1097 switch (c->dst.type) {
1584 case OP_REG: 1098 case OP_REG:
1585 /* The 4-byte case *is* correct: 1099 write_register_operand(&c->dst);
1586 * in 64-bit mode we zero-extend.
1587 */
1588 switch (c->dst.bytes) {
1589 case 1:
1590 *(u8 *)c->dst.ptr = (u8)c->dst.val;
1591 break;
1592 case 2:
1593 *(u16 *)c->dst.ptr = (u16)c->dst.val;
1594 break;
1595 case 4:
1596 *c->dst.ptr = (u32)c->dst.val;
1597 break; /* 64b: zero-ext */
1598 case 8:
1599 *c->dst.ptr = c->dst.val;
1600 break;
1601 }
1602 break; 1100 break;
1603 case OP_MEM: 1101 case OP_MEM:
1604 if (c->lock_prefix) 1102 if (c->lock_prefix)
1605 rc = ops->cmpxchg_emulated( 1103 rc = ops->cmpxchg_emulated(
1606 (unsigned long)c->dst.ptr, 1104 c->dst.addr.mem,
1607 &c->dst.orig_val, 1105 &c->dst.orig_val,
1608 &c->dst.val, 1106 &c->dst.val,
1609 c->dst.bytes, 1107 c->dst.bytes,
@@ -1611,14 +1109,13 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt,
1611 ctxt->vcpu); 1109 ctxt->vcpu);
1612 else 1110 else
1613 rc = ops->write_emulated( 1111 rc = ops->write_emulated(
1614 (unsigned long)c->dst.ptr, 1112 c->dst.addr.mem,
1615 &c->dst.val, 1113 &c->dst.val,
1616 c->dst.bytes, 1114 c->dst.bytes,
1617 &err, 1115 &err,
1618 ctxt->vcpu); 1116 ctxt->vcpu);
1619 if (rc == X86EMUL_PROPAGATE_FAULT) 1117 if (rc == X86EMUL_PROPAGATE_FAULT)
1620 emulate_pf(ctxt, 1118 emulate_pf(ctxt);
1621 (unsigned long)c->dst.ptr, err);
1622 if (rc != X86EMUL_CONTINUE) 1119 if (rc != X86EMUL_CONTINUE)
1623 return rc; 1120 return rc;
1624 break; 1121 break;
@@ -1640,8 +1137,8 @@ static inline void emulate_push(struct x86_emulate_ctxt *ctxt,
1640 c->dst.bytes = c->op_bytes; 1137 c->dst.bytes = c->op_bytes;
1641 c->dst.val = c->src.val; 1138 c->dst.val = c->src.val;
1642 register_address_increment(c, &c->regs[VCPU_REGS_RSP], -c->op_bytes); 1139 register_address_increment(c, &c->regs[VCPU_REGS_RSP], -c->op_bytes);
1643 c->dst.ptr = (void *) register_address(c, ss_base(ctxt, ops), 1140 c->dst.addr.mem = register_address(c, ss_base(ctxt, ops),
1644 c->regs[VCPU_REGS_RSP]); 1141 c->regs[VCPU_REGS_RSP]);
1645} 1142}
1646 1143
1647static int emulate_pop(struct x86_emulate_ctxt *ctxt, 1144static int emulate_pop(struct x86_emulate_ctxt *ctxt,
@@ -1701,6 +1198,9 @@ static int emulate_popf(struct x86_emulate_ctxt *ctxt,
1701 *(unsigned long *)dest = 1198 *(unsigned long *)dest =
1702 (ctxt->eflags & ~change_mask) | (val & change_mask); 1199 (ctxt->eflags & ~change_mask) | (val & change_mask);
1703 1200
1201 if (rc == X86EMUL_PROPAGATE_FAULT)
1202 emulate_pf(ctxt);
1203
1704 return rc; 1204 return rc;
1705} 1205}
1706 1206
@@ -1778,6 +1278,150 @@ static int emulate_popa(struct x86_emulate_ctxt *ctxt,
1778 return rc; 1278 return rc;
1779} 1279}
1780 1280
1281int emulate_int_real(struct x86_emulate_ctxt *ctxt,
1282 struct x86_emulate_ops *ops, int irq)
1283{
1284 struct decode_cache *c = &ctxt->decode;
1285 int rc;
1286 struct desc_ptr dt;
1287 gva_t cs_addr;
1288 gva_t eip_addr;
1289 u16 cs, eip;
1290 u32 err;
1291
1292 /* TODO: Add limit checks */
1293 c->src.val = ctxt->eflags;
1294 emulate_push(ctxt, ops);
1295 rc = writeback(ctxt, ops);
1296 if (rc != X86EMUL_CONTINUE)
1297 return rc;
1298
1299 ctxt->eflags &= ~(EFLG_IF | EFLG_TF | EFLG_AC);
1300
1301 c->src.val = ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu);
1302 emulate_push(ctxt, ops);
1303 rc = writeback(ctxt, ops);
1304 if (rc != X86EMUL_CONTINUE)
1305 return rc;
1306
1307 c->src.val = c->eip;
1308 emulate_push(ctxt, ops);
1309 rc = writeback(ctxt, ops);
1310 if (rc != X86EMUL_CONTINUE)
1311 return rc;
1312
1313 c->dst.type = OP_NONE;
1314
1315 ops->get_idt(&dt, ctxt->vcpu);
1316
1317 eip_addr = dt.address + (irq << 2);
1318 cs_addr = dt.address + (irq << 2) + 2;
1319
1320 rc = ops->read_std(cs_addr, &cs, 2, ctxt->vcpu, &err);
1321 if (rc != X86EMUL_CONTINUE)
1322 return rc;
1323
1324 rc = ops->read_std(eip_addr, &eip, 2, ctxt->vcpu, &err);
1325 if (rc != X86EMUL_CONTINUE)
1326 return rc;
1327
1328 rc = load_segment_descriptor(ctxt, ops, cs, VCPU_SREG_CS);
1329 if (rc != X86EMUL_CONTINUE)
1330 return rc;
1331
1332 c->eip = eip;
1333
1334 return rc;
1335}
1336
1337static int emulate_int(struct x86_emulate_ctxt *ctxt,
1338 struct x86_emulate_ops *ops, int irq)
1339{
1340 switch(ctxt->mode) {
1341 case X86EMUL_MODE_REAL:
1342 return emulate_int_real(ctxt, ops, irq);
1343 case X86EMUL_MODE_VM86:
1344 case X86EMUL_MODE_PROT16:
1345 case X86EMUL_MODE_PROT32:
1346 case X86EMUL_MODE_PROT64:
1347 default:
1348 /* Protected mode interrupts unimplemented yet */
1349 return X86EMUL_UNHANDLEABLE;
1350 }
1351}
1352
1353static int emulate_iret_real(struct x86_emulate_ctxt *ctxt,
1354 struct x86_emulate_ops *ops)
1355{
1356 struct decode_cache *c = &ctxt->decode;
1357 int rc = X86EMUL_CONTINUE;
1358 unsigned long temp_eip = 0;
1359 unsigned long temp_eflags = 0;
1360 unsigned long cs = 0;
1361 unsigned long mask = EFLG_CF | EFLG_PF | EFLG_AF | EFLG_ZF | EFLG_SF | EFLG_TF |
1362 EFLG_IF | EFLG_DF | EFLG_OF | EFLG_IOPL | EFLG_NT | EFLG_RF |
1363 EFLG_AC | EFLG_ID | (1 << 1); /* Last one is the reserved bit */
1364 unsigned long vm86_mask = EFLG_VM | EFLG_VIF | EFLG_VIP;
1365
1366 /* TODO: Add stack limit check */
1367
1368 rc = emulate_pop(ctxt, ops, &temp_eip, c->op_bytes);
1369
1370 if (rc != X86EMUL_CONTINUE)
1371 return rc;
1372
1373 if (temp_eip & ~0xffff) {
1374 emulate_gp(ctxt, 0);
1375 return X86EMUL_PROPAGATE_FAULT;
1376 }
1377
1378 rc = emulate_pop(ctxt, ops, &cs, c->op_bytes);
1379
1380 if (rc != X86EMUL_CONTINUE)
1381 return rc;
1382
1383 rc = emulate_pop(ctxt, ops, &temp_eflags, c->op_bytes);
1384
1385 if (rc != X86EMUL_CONTINUE)
1386 return rc;
1387
1388 rc = load_segment_descriptor(ctxt, ops, (u16)cs, VCPU_SREG_CS);
1389
1390 if (rc != X86EMUL_CONTINUE)
1391 return rc;
1392
1393 c->eip = temp_eip;
1394
1395
1396 if (c->op_bytes == 4)
1397 ctxt->eflags = ((temp_eflags & mask) | (ctxt->eflags & vm86_mask));
1398 else if (c->op_bytes == 2) {
1399 ctxt->eflags &= ~0xffff;
1400 ctxt->eflags |= temp_eflags;
1401 }
1402
1403 ctxt->eflags &= ~EFLG_RESERVED_ZEROS_MASK; /* Clear reserved zeros */
1404 ctxt->eflags |= EFLG_RESERVED_ONE_MASK;
1405
1406 return rc;
1407}
1408
1409static inline int emulate_iret(struct x86_emulate_ctxt *ctxt,
1410 struct x86_emulate_ops* ops)
1411{
1412 switch(ctxt->mode) {
1413 case X86EMUL_MODE_REAL:
1414 return emulate_iret_real(ctxt, ops);
1415 case X86EMUL_MODE_VM86:
1416 case X86EMUL_MODE_PROT16:
1417 case X86EMUL_MODE_PROT32:
1418 case X86EMUL_MODE_PROT64:
1419 default:
1420 /* iret from protected mode unimplemented yet */
1421 return X86EMUL_UNHANDLEABLE;
1422 }
1423}
1424
1781static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt, 1425static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
1782 struct x86_emulate_ops *ops) 1426 struct x86_emulate_ops *ops)
1783{ 1427{
@@ -1819,6 +1463,9 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
1819 struct x86_emulate_ops *ops) 1463 struct x86_emulate_ops *ops)
1820{ 1464{
1821 struct decode_cache *c = &ctxt->decode; 1465 struct decode_cache *c = &ctxt->decode;
1466 unsigned long *rax = &c->regs[VCPU_REGS_RAX];
1467 unsigned long *rdx = &c->regs[VCPU_REGS_RDX];
1468 u8 de = 0;
1822 1469
1823 switch (c->modrm_reg) { 1470 switch (c->modrm_reg) {
1824 case 0 ... 1: /* test */ 1471 case 0 ... 1: /* test */
@@ -1830,10 +1477,26 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
1830 case 3: /* neg */ 1477 case 3: /* neg */
1831 emulate_1op("neg", c->dst, ctxt->eflags); 1478 emulate_1op("neg", c->dst, ctxt->eflags);
1832 break; 1479 break;
1480 case 4: /* mul */
1481 emulate_1op_rax_rdx("mul", c->src, *rax, *rdx, ctxt->eflags);
1482 break;
1483 case 5: /* imul */
1484 emulate_1op_rax_rdx("imul", c->src, *rax, *rdx, ctxt->eflags);
1485 break;
1486 case 6: /* div */
1487 emulate_1op_rax_rdx_ex("div", c->src, *rax, *rdx,
1488 ctxt->eflags, de);
1489 break;
1490 case 7: /* idiv */
1491 emulate_1op_rax_rdx_ex("idiv", c->src, *rax, *rdx,
1492 ctxt->eflags, de);
1493 break;
1833 default: 1494 default:
1834 return 0; 1495 return X86EMUL_UNHANDLEABLE;
1835 } 1496 }
1836 return 1; 1497 if (de)
1498 return emulate_de(ctxt);
1499 return X86EMUL_CONTINUE;
1837} 1500}
1838 1501
1839static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt, 1502static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
@@ -1905,6 +1568,23 @@ static int emulate_ret_far(struct x86_emulate_ctxt *ctxt,
1905 return rc; 1568 return rc;
1906} 1569}
1907 1570
1571static int emulate_load_segment(struct x86_emulate_ctxt *ctxt,
1572 struct x86_emulate_ops *ops, int seg)
1573{
1574 struct decode_cache *c = &ctxt->decode;
1575 unsigned short sel;
1576 int rc;
1577
1578 memcpy(&sel, c->src.valptr + c->op_bytes, 2);
1579
1580 rc = load_segment_descriptor(ctxt, ops, sel, seg);
1581 if (rc != X86EMUL_CONTINUE)
1582 return rc;
1583
1584 c->dst.val = c->src.val;
1585 return rc;
1586}
1587
1908static inline void 1588static inline void
1909setup_syscalls_segments(struct x86_emulate_ctxt *ctxt, 1589setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
1910 struct x86_emulate_ops *ops, struct desc_struct *cs, 1590 struct x86_emulate_ops *ops, struct desc_struct *cs,
@@ -2160,9 +1840,15 @@ static bool emulator_io_permited(struct x86_emulate_ctxt *ctxt,
2160 struct x86_emulate_ops *ops, 1840 struct x86_emulate_ops *ops,
2161 u16 port, u16 len) 1841 u16 port, u16 len)
2162{ 1842{
1843 if (ctxt->perm_ok)
1844 return true;
1845
2163 if (emulator_bad_iopl(ctxt, ops)) 1846 if (emulator_bad_iopl(ctxt, ops))
2164 if (!emulator_io_port_access_allowed(ctxt, ops, port, len)) 1847 if (!emulator_io_port_access_allowed(ctxt, ops, port, len))
2165 return false; 1848 return false;
1849
1850 ctxt->perm_ok = true;
1851
2166 return true; 1852 return true;
2167} 1853}
2168 1854
@@ -2254,7 +1940,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
2254 &err); 1940 &err);
2255 if (ret == X86EMUL_PROPAGATE_FAULT) { 1941 if (ret == X86EMUL_PROPAGATE_FAULT) {
2256 /* FIXME: need to provide precise fault address */ 1942 /* FIXME: need to provide precise fault address */
2257 emulate_pf(ctxt, old_tss_base, err); 1943 emulate_pf(ctxt);
2258 return ret; 1944 return ret;
2259 } 1945 }
2260 1946
@@ -2264,7 +1950,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
2264 &err); 1950 &err);
2265 if (ret == X86EMUL_PROPAGATE_FAULT) { 1951 if (ret == X86EMUL_PROPAGATE_FAULT) {
2266 /* FIXME: need to provide precise fault address */ 1952 /* FIXME: need to provide precise fault address */
2267 emulate_pf(ctxt, old_tss_base, err); 1953 emulate_pf(ctxt);
2268 return ret; 1954 return ret;
2269 } 1955 }
2270 1956
@@ -2272,7 +1958,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
2272 &err); 1958 &err);
2273 if (ret == X86EMUL_PROPAGATE_FAULT) { 1959 if (ret == X86EMUL_PROPAGATE_FAULT) {
2274 /* FIXME: need to provide precise fault address */ 1960 /* FIXME: need to provide precise fault address */
2275 emulate_pf(ctxt, new_tss_base, err); 1961 emulate_pf(ctxt);
2276 return ret; 1962 return ret;
2277 } 1963 }
2278 1964
@@ -2285,7 +1971,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
2285 ctxt->vcpu, &err); 1971 ctxt->vcpu, &err);
2286 if (ret == X86EMUL_PROPAGATE_FAULT) { 1972 if (ret == X86EMUL_PROPAGATE_FAULT) {
2287 /* FIXME: need to provide precise fault address */ 1973 /* FIXME: need to provide precise fault address */
2288 emulate_pf(ctxt, new_tss_base, err); 1974 emulate_pf(ctxt);
2289 return ret; 1975 return ret;
2290 } 1976 }
2291 } 1977 }
@@ -2396,7 +2082,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
2396 &err); 2082 &err);
2397 if (ret == X86EMUL_PROPAGATE_FAULT) { 2083 if (ret == X86EMUL_PROPAGATE_FAULT) {
2398 /* FIXME: need to provide precise fault address */ 2084 /* FIXME: need to provide precise fault address */
2399 emulate_pf(ctxt, old_tss_base, err); 2085 emulate_pf(ctxt);
2400 return ret; 2086 return ret;
2401 } 2087 }
2402 2088
@@ -2406,7 +2092,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
2406 &err); 2092 &err);
2407 if (ret == X86EMUL_PROPAGATE_FAULT) { 2093 if (ret == X86EMUL_PROPAGATE_FAULT) {
2408 /* FIXME: need to provide precise fault address */ 2094 /* FIXME: need to provide precise fault address */
2409 emulate_pf(ctxt, old_tss_base, err); 2095 emulate_pf(ctxt);
2410 return ret; 2096 return ret;
2411 } 2097 }
2412 2098
@@ -2414,7 +2100,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
2414 &err); 2100 &err);
2415 if (ret == X86EMUL_PROPAGATE_FAULT) { 2101 if (ret == X86EMUL_PROPAGATE_FAULT) {
2416 /* FIXME: need to provide precise fault address */ 2102 /* FIXME: need to provide precise fault address */
2417 emulate_pf(ctxt, new_tss_base, err); 2103 emulate_pf(ctxt);
2418 return ret; 2104 return ret;
2419 } 2105 }
2420 2106
@@ -2427,7 +2113,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
2427 ctxt->vcpu, &err); 2113 ctxt->vcpu, &err);
2428 if (ret == X86EMUL_PROPAGATE_FAULT) { 2114 if (ret == X86EMUL_PROPAGATE_FAULT) {
2429 /* FIXME: need to provide precise fault address */ 2115 /* FIXME: need to provide precise fault address */
2430 emulate_pf(ctxt, new_tss_base, err); 2116 emulate_pf(ctxt);
2431 return ret; 2117 return ret;
2432 } 2118 }
2433 } 2119 }
@@ -2523,10 +2209,10 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2523} 2209}
2524 2210
2525int emulator_task_switch(struct x86_emulate_ctxt *ctxt, 2211int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
2526 struct x86_emulate_ops *ops,
2527 u16 tss_selector, int reason, 2212 u16 tss_selector, int reason,
2528 bool has_error_code, u32 error_code) 2213 bool has_error_code, u32 error_code)
2529{ 2214{
2215 struct x86_emulate_ops *ops = ctxt->ops;
2530 struct decode_cache *c = &ctxt->decode; 2216 struct decode_cache *c = &ctxt->decode;
2531 int rc; 2217 int rc;
2532 2218
@@ -2552,16 +2238,784 @@ static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned long base,
2552 int df = (ctxt->eflags & EFLG_DF) ? -1 : 1; 2238 int df = (ctxt->eflags & EFLG_DF) ? -1 : 1;
2553 2239
2554 register_address_increment(c, &c->regs[reg], df * op->bytes); 2240 register_address_increment(c, &c->regs[reg], df * op->bytes);
2555 op->ptr = (unsigned long *)register_address(c, base, c->regs[reg]); 2241 op->addr.mem = register_address(c, base, c->regs[reg]);
2242}
2243
2244static int em_push(struct x86_emulate_ctxt *ctxt)
2245{
2246 emulate_push(ctxt, ctxt->ops);
2247 return X86EMUL_CONTINUE;
2248}
2249
2250static int em_das(struct x86_emulate_ctxt *ctxt)
2251{
2252 struct decode_cache *c = &ctxt->decode;
2253 u8 al, old_al;
2254 bool af, cf, old_cf;
2255
2256 cf = ctxt->eflags & X86_EFLAGS_CF;
2257 al = c->dst.val;
2258
2259 old_al = al;
2260 old_cf = cf;
2261 cf = false;
2262 af = ctxt->eflags & X86_EFLAGS_AF;
2263 if ((al & 0x0f) > 9 || af) {
2264 al -= 6;
2265 cf = old_cf | (al >= 250);
2266 af = true;
2267 } else {
2268 af = false;
2269 }
2270 if (old_al > 0x99 || old_cf) {
2271 al -= 0x60;
2272 cf = true;
2273 }
2274
2275 c->dst.val = al;
2276 /* Set PF, ZF, SF */
2277 c->src.type = OP_IMM;
2278 c->src.val = 0;
2279 c->src.bytes = 1;
2280 emulate_2op_SrcV("or", c->src, c->dst, ctxt->eflags);
2281 ctxt->eflags &= ~(X86_EFLAGS_AF | X86_EFLAGS_CF);
2282 if (cf)
2283 ctxt->eflags |= X86_EFLAGS_CF;
2284 if (af)
2285 ctxt->eflags |= X86_EFLAGS_AF;
2286 return X86EMUL_CONTINUE;
2287}
2288
2289static int em_call_far(struct x86_emulate_ctxt *ctxt)
2290{
2291 struct decode_cache *c = &ctxt->decode;
2292 u16 sel, old_cs;
2293 ulong old_eip;
2294 int rc;
2295
2296 old_cs = ctxt->ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu);
2297 old_eip = c->eip;
2298
2299 memcpy(&sel, c->src.valptr + c->op_bytes, 2);
2300 if (load_segment_descriptor(ctxt, ctxt->ops, sel, VCPU_SREG_CS))
2301 return X86EMUL_CONTINUE;
2302
2303 c->eip = 0;
2304 memcpy(&c->eip, c->src.valptr, c->op_bytes);
2305
2306 c->src.val = old_cs;
2307 emulate_push(ctxt, ctxt->ops);
2308 rc = writeback(ctxt, ctxt->ops);
2309 if (rc != X86EMUL_CONTINUE)
2310 return rc;
2311
2312 c->src.val = old_eip;
2313 emulate_push(ctxt, ctxt->ops);
2314 rc = writeback(ctxt, ctxt->ops);
2315 if (rc != X86EMUL_CONTINUE)
2316 return rc;
2317
2318 c->dst.type = OP_NONE;
2319
2320 return X86EMUL_CONTINUE;
2321}
2322
2323static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
2324{
2325 struct decode_cache *c = &ctxt->decode;
2326 int rc;
2327
2328 c->dst.type = OP_REG;
2329 c->dst.addr.reg = &c->eip;
2330 c->dst.bytes = c->op_bytes;
2331 rc = emulate_pop(ctxt, ctxt->ops, &c->dst.val, c->op_bytes);
2332 if (rc != X86EMUL_CONTINUE)
2333 return rc;
2334 register_address_increment(c, &c->regs[VCPU_REGS_RSP], c->src.val);
2335 return X86EMUL_CONTINUE;
2336}
2337
2338static int em_imul(struct x86_emulate_ctxt *ctxt)
2339{
2340 struct decode_cache *c = &ctxt->decode;
2341
2342 emulate_2op_SrcV_nobyte("imul", c->src, c->dst, ctxt->eflags);
2343 return X86EMUL_CONTINUE;
2344}
2345
2346static int em_imul_3op(struct x86_emulate_ctxt *ctxt)
2347{
2348 struct decode_cache *c = &ctxt->decode;
2349
2350 c->dst.val = c->src2.val;
2351 return em_imul(ctxt);
2352}
2353
2354static int em_cwd(struct x86_emulate_ctxt *ctxt)
2355{
2356 struct decode_cache *c = &ctxt->decode;
2357
2358 c->dst.type = OP_REG;
2359 c->dst.bytes = c->src.bytes;
2360 c->dst.addr.reg = &c->regs[VCPU_REGS_RDX];
2361 c->dst.val = ~((c->src.val >> (c->src.bytes * 8 - 1)) - 1);
2362
2363 return X86EMUL_CONTINUE;
2364}
2365
2366static int em_rdtsc(struct x86_emulate_ctxt *ctxt)
2367{
2368 unsigned cpl = ctxt->ops->cpl(ctxt->vcpu);
2369 struct decode_cache *c = &ctxt->decode;
2370 u64 tsc = 0;
2371
2372 if (cpl > 0 && (ctxt->ops->get_cr(4, ctxt->vcpu) & X86_CR4_TSD)) {
2373 emulate_gp(ctxt, 0);
2374 return X86EMUL_PROPAGATE_FAULT;
2375 }
2376 ctxt->ops->get_msr(ctxt->vcpu, MSR_IA32_TSC, &tsc);
2377 c->regs[VCPU_REGS_RAX] = (u32)tsc;
2378 c->regs[VCPU_REGS_RDX] = tsc >> 32;
2379 return X86EMUL_CONTINUE;
2380}
2381
2382static int em_mov(struct x86_emulate_ctxt *ctxt)
2383{
2384 struct decode_cache *c = &ctxt->decode;
2385 c->dst.val = c->src.val;
2386 return X86EMUL_CONTINUE;
2387}
2388
2389#define D(_y) { .flags = (_y) }
2390#define N D(0)
2391#define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) }
2392#define GD(_f, _g) { .flags = ((_f) | Group | GroupDual), .u.gdual = (_g) }
2393#define I(_f, _e) { .flags = (_f), .u.execute = (_e) }
2394
2395#define D2bv(_f) D((_f) | ByteOp), D(_f)
2396#define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e)
2397
2398#define D6ALU(_f) D2bv((_f) | DstMem | SrcReg | ModRM), \
2399 D2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock), \
2400 D2bv(((_f) & ~Lock) | DstAcc | SrcImm)
2401
2402
2403static struct opcode group1[] = {
2404 X7(D(Lock)), N
2405};
2406
2407static struct opcode group1A[] = {
2408 D(DstMem | SrcNone | ModRM | Mov | Stack), N, N, N, N, N, N, N,
2409};
2410
2411static struct opcode group3[] = {
2412 D(DstMem | SrcImm | ModRM), D(DstMem | SrcImm | ModRM),
2413 D(DstMem | SrcNone | ModRM | Lock), D(DstMem | SrcNone | ModRM | Lock),
2414 X4(D(SrcMem | ModRM)),
2415};
2416
2417static struct opcode group4[] = {
2418 D(ByteOp | DstMem | SrcNone | ModRM | Lock), D(ByteOp | DstMem | SrcNone | ModRM | Lock),
2419 N, N, N, N, N, N,
2420};
2421
2422static struct opcode group5[] = {
2423 D(DstMem | SrcNone | ModRM | Lock), D(DstMem | SrcNone | ModRM | Lock),
2424 D(SrcMem | ModRM | Stack),
2425 I(SrcMemFAddr | ModRM | ImplicitOps | Stack, em_call_far),
2426 D(SrcMem | ModRM | Stack), D(SrcMemFAddr | ModRM | ImplicitOps),
2427 D(SrcMem | ModRM | Stack), N,
2428};
2429
2430static struct group_dual group7 = { {
2431 N, N, D(ModRM | SrcMem | Priv), D(ModRM | SrcMem | Priv),
2432 D(SrcNone | ModRM | DstMem | Mov), N,
2433 D(SrcMem16 | ModRM | Mov | Priv),
2434 D(SrcMem | ModRM | ByteOp | Priv | NoAccess),
2435}, {
2436 D(SrcNone | ModRM | Priv), N, N, D(SrcNone | ModRM | Priv),
2437 D(SrcNone | ModRM | DstMem | Mov), N,
2438 D(SrcMem16 | ModRM | Mov | Priv), N,
2439} };
2440
2441static struct opcode group8[] = {
2442 N, N, N, N,
2443 D(DstMem | SrcImmByte | ModRM), D(DstMem | SrcImmByte | ModRM | Lock),
2444 D(DstMem | SrcImmByte | ModRM | Lock), D(DstMem | SrcImmByte | ModRM | Lock),
2445};
2446
2447static struct group_dual group9 = { {
2448 N, D(DstMem64 | ModRM | Lock), N, N, N, N, N, N,
2449}, {
2450 N, N, N, N, N, N, N, N,
2451} };
2452
2453static struct opcode group11[] = {
2454 I(DstMem | SrcImm | ModRM | Mov, em_mov), X7(D(Undefined)),
2455};
2456
2457static struct opcode opcode_table[256] = {
2458 /* 0x00 - 0x07 */
2459 D6ALU(Lock),
2460 D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
2461 /* 0x08 - 0x0F */
2462 D6ALU(Lock),
2463 D(ImplicitOps | Stack | No64), N,
2464 /* 0x10 - 0x17 */
2465 D6ALU(Lock),
2466 D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
2467 /* 0x18 - 0x1F */
2468 D6ALU(Lock),
2469 D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
2470 /* 0x20 - 0x27 */
2471 D6ALU(Lock), N, N,
2472 /* 0x28 - 0x2F */
2473 D6ALU(Lock), N, I(ByteOp | DstAcc | No64, em_das),
2474 /* 0x30 - 0x37 */
2475 D6ALU(Lock), N, N,
2476 /* 0x38 - 0x3F */
2477 D6ALU(0), N, N,
2478 /* 0x40 - 0x4F */
2479 X16(D(DstReg)),
2480 /* 0x50 - 0x57 */
2481 X8(I(SrcReg | Stack, em_push)),
2482 /* 0x58 - 0x5F */
2483 X8(D(DstReg | Stack)),
2484 /* 0x60 - 0x67 */
2485 D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
2486 N, D(DstReg | SrcMem32 | ModRM | Mov) /* movsxd (x86/64) */ ,
2487 N, N, N, N,
2488 /* 0x68 - 0x6F */
2489 I(SrcImm | Mov | Stack, em_push),
2490 I(DstReg | SrcMem | ModRM | Src2Imm, em_imul_3op),
2491 I(SrcImmByte | Mov | Stack, em_push),
2492 I(DstReg | SrcMem | ModRM | Src2ImmByte, em_imul_3op),
2493 D2bv(DstDI | Mov | String), /* insb, insw/insd */
2494 D2bv(SrcSI | ImplicitOps | String), /* outsb, outsw/outsd */
2495 /* 0x70 - 0x7F */
2496 X16(D(SrcImmByte)),
2497 /* 0x80 - 0x87 */
2498 G(ByteOp | DstMem | SrcImm | ModRM | Group, group1),
2499 G(DstMem | SrcImm | ModRM | Group, group1),
2500 G(ByteOp | DstMem | SrcImm | ModRM | No64 | Group, group1),
2501 G(DstMem | SrcImmByte | ModRM | Group, group1),
2502 D2bv(DstMem | SrcReg | ModRM), D2bv(DstMem | SrcReg | ModRM | Lock),
2503 /* 0x88 - 0x8F */
2504 I2bv(DstMem | SrcReg | ModRM | Mov, em_mov),
2505 I2bv(DstReg | SrcMem | ModRM | Mov, em_mov),
2506 D(DstMem | SrcNone | ModRM | Mov), D(ModRM | SrcMem | NoAccess | DstReg),
2507 D(ImplicitOps | SrcMem16 | ModRM), G(0, group1A),
2508 /* 0x90 - 0x97 */
2509 X8(D(SrcAcc | DstReg)),
2510 /* 0x98 - 0x9F */
2511 D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd),
2512 I(SrcImmFAddr | No64, em_call_far), N,
2513 D(ImplicitOps | Stack), D(ImplicitOps | Stack), N, N,
2514 /* 0xA0 - 0xA7 */
2515 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
2516 I2bv(DstMem | SrcAcc | Mov | MemAbs, em_mov),
2517 I2bv(SrcSI | DstDI | Mov | String, em_mov),
2518 D2bv(SrcSI | DstDI | String),
2519 /* 0xA8 - 0xAF */
2520 D2bv(DstAcc | SrcImm),
2521 I2bv(SrcAcc | DstDI | Mov | String, em_mov),
2522 I2bv(SrcSI | DstAcc | Mov | String, em_mov),
2523 D2bv(SrcAcc | DstDI | String),
2524 /* 0xB0 - 0xB7 */
2525 X8(I(ByteOp | DstReg | SrcImm | Mov, em_mov)),
2526 /* 0xB8 - 0xBF */
2527 X8(I(DstReg | SrcImm | Mov, em_mov)),
2528 /* 0xC0 - 0xC7 */
2529 D2bv(DstMem | SrcImmByte | ModRM),
2530 I(ImplicitOps | Stack | SrcImmU16, em_ret_near_imm),
2531 D(ImplicitOps | Stack),
2532 D(DstReg | SrcMemFAddr | ModRM | No64), D(DstReg | SrcMemFAddr | ModRM | No64),
2533 G(ByteOp, group11), G(0, group11),
2534 /* 0xC8 - 0xCF */
2535 N, N, N, D(ImplicitOps | Stack),
2536 D(ImplicitOps), D(SrcImmByte), D(ImplicitOps | No64), D(ImplicitOps),
2537 /* 0xD0 - 0xD7 */
2538 D2bv(DstMem | SrcOne | ModRM), D2bv(DstMem | ModRM),
2539 N, N, N, N,
2540 /* 0xD8 - 0xDF */
2541 N, N, N, N, N, N, N, N,
2542 /* 0xE0 - 0xE7 */
2543 X4(D(SrcImmByte)),
2544 D2bv(SrcImmUByte | DstAcc), D2bv(SrcAcc | DstImmUByte),
2545 /* 0xE8 - 0xEF */
2546 D(SrcImm | Stack), D(SrcImm | ImplicitOps),
2547 D(SrcImmFAddr | No64), D(SrcImmByte | ImplicitOps),
2548 D2bv(SrcNone | DstAcc), D2bv(SrcAcc | ImplicitOps),
2549 /* 0xF0 - 0xF7 */
2550 N, N, N, N,
2551 D(ImplicitOps | Priv), D(ImplicitOps), G(ByteOp, group3), G(0, group3),
2552 /* 0xF8 - 0xFF */
2553 D(ImplicitOps), D(ImplicitOps), D(ImplicitOps), D(ImplicitOps),
2554 D(ImplicitOps), D(ImplicitOps), G(0, group4), G(0, group5),
2555};
2556
2557static struct opcode twobyte_table[256] = {
2558 /* 0x00 - 0x0F */
2559 N, GD(0, &group7), N, N,
2560 N, D(ImplicitOps), D(ImplicitOps | Priv), N,
2561 D(ImplicitOps | Priv), D(ImplicitOps | Priv), N, N,
2562 N, D(ImplicitOps | ModRM), N, N,
2563 /* 0x10 - 0x1F */
2564 N, N, N, N, N, N, N, N, D(ImplicitOps | ModRM), N, N, N, N, N, N, N,
2565 /* 0x20 - 0x2F */
2566 D(ModRM | DstMem | Priv | Op3264), D(ModRM | DstMem | Priv | Op3264),
2567 D(ModRM | SrcMem | Priv | Op3264), D(ModRM | SrcMem | Priv | Op3264),
2568 N, N, N, N,
2569 N, N, N, N, N, N, N, N,
2570 /* 0x30 - 0x3F */
2571 D(ImplicitOps | Priv), I(ImplicitOps, em_rdtsc),
2572 D(ImplicitOps | Priv), N,
2573 D(ImplicitOps), D(ImplicitOps | Priv), N, N,
2574 N, N, N, N, N, N, N, N,
2575 /* 0x40 - 0x4F */
2576 X16(D(DstReg | SrcMem | ModRM | Mov)),
2577 /* 0x50 - 0x5F */
2578 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
2579 /* 0x60 - 0x6F */
2580 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
2581 /* 0x70 - 0x7F */
2582 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
2583 /* 0x80 - 0x8F */
2584 X16(D(SrcImm)),
2585 /* 0x90 - 0x9F */
2586 X16(D(ByteOp | DstMem | SrcNone | ModRM| Mov)),
2587 /* 0xA0 - 0xA7 */
2588 D(ImplicitOps | Stack), D(ImplicitOps | Stack),
2589 N, D(DstMem | SrcReg | ModRM | BitOp),
2590 D(DstMem | SrcReg | Src2ImmByte | ModRM),
2591 D(DstMem | SrcReg | Src2CL | ModRM), N, N,
2592 /* 0xA8 - 0xAF */
2593 D(ImplicitOps | Stack), D(ImplicitOps | Stack),
2594 N, D(DstMem | SrcReg | ModRM | BitOp | Lock),
2595 D(DstMem | SrcReg | Src2ImmByte | ModRM),
2596 D(DstMem | SrcReg | Src2CL | ModRM),
2597 D(ModRM), I(DstReg | SrcMem | ModRM, em_imul),
2598 /* 0xB0 - 0xB7 */
2599 D2bv(DstMem | SrcReg | ModRM | Lock),
2600 D(DstReg | SrcMemFAddr | ModRM), D(DstMem | SrcReg | ModRM | BitOp | Lock),
2601 D(DstReg | SrcMemFAddr | ModRM), D(DstReg | SrcMemFAddr | ModRM),
2602 D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
2603 /* 0xB8 - 0xBF */
2604 N, N,
2605 G(BitOp, group8), D(DstMem | SrcReg | ModRM | BitOp | Lock),
2606 D(DstReg | SrcMem | ModRM), D(DstReg | SrcMem | ModRM),
2607 D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
2608 /* 0xC0 - 0xCF */
2609 D2bv(DstMem | SrcReg | ModRM | Lock),
2610 N, D(DstMem | SrcReg | ModRM | Mov),
2611 N, N, N, GD(0, &group9),
2612 N, N, N, N, N, N, N, N,
2613 /* 0xD0 - 0xDF */
2614 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
2615 /* 0xE0 - 0xEF */
2616 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N,
2617 /* 0xF0 - 0xFF */
2618 N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N
2619};
2620
2621#undef D
2622#undef N
2623#undef G
2624#undef GD
2625#undef I
2626
2627#undef D2bv
2628#undef I2bv
2629#undef D6ALU
2630
2631static unsigned imm_size(struct decode_cache *c)
2632{
2633 unsigned size;
2634
2635 size = (c->d & ByteOp) ? 1 : c->op_bytes;
2636 if (size == 8)
2637 size = 4;
2638 return size;
2639}
2640
2641static int decode_imm(struct x86_emulate_ctxt *ctxt, struct operand *op,
2642 unsigned size, bool sign_extension)
2643{
2644 struct decode_cache *c = &ctxt->decode;
2645 struct x86_emulate_ops *ops = ctxt->ops;
2646 int rc = X86EMUL_CONTINUE;
2647
2648 op->type = OP_IMM;
2649 op->bytes = size;
2650 op->addr.mem = c->eip;
2651 /* NB. Immediates are sign-extended as necessary. */
2652 switch (op->bytes) {
2653 case 1:
2654 op->val = insn_fetch(s8, 1, c->eip);
2655 break;
2656 case 2:
2657 op->val = insn_fetch(s16, 2, c->eip);
2658 break;
2659 case 4:
2660 op->val = insn_fetch(s32, 4, c->eip);
2661 break;
2662 }
2663 if (!sign_extension) {
2664 switch (op->bytes) {
2665 case 1:
2666 op->val &= 0xff;
2667 break;
2668 case 2:
2669 op->val &= 0xffff;
2670 break;
2671 case 4:
2672 op->val &= 0xffffffff;
2673 break;
2674 }
2675 }
2676done:
2677 return rc;
2556} 2678}
2557 2679
2558int 2680int
2559x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) 2681x86_decode_insn(struct x86_emulate_ctxt *ctxt)
2560{ 2682{
2683 struct x86_emulate_ops *ops = ctxt->ops;
2684 struct decode_cache *c = &ctxt->decode;
2685 int rc = X86EMUL_CONTINUE;
2686 int mode = ctxt->mode;
2687 int def_op_bytes, def_ad_bytes, dual, goffset;
2688 struct opcode opcode, *g_mod012, *g_mod3;
2689 struct operand memop = { .type = OP_NONE };
2690
2691 c->eip = ctxt->eip;
2692 c->fetch.start = c->fetch.end = c->eip;
2693 ctxt->cs_base = seg_base(ctxt, ops, VCPU_SREG_CS);
2694
2695 switch (mode) {
2696 case X86EMUL_MODE_REAL:
2697 case X86EMUL_MODE_VM86:
2698 case X86EMUL_MODE_PROT16:
2699 def_op_bytes = def_ad_bytes = 2;
2700 break;
2701 case X86EMUL_MODE_PROT32:
2702 def_op_bytes = def_ad_bytes = 4;
2703 break;
2704#ifdef CONFIG_X86_64
2705 case X86EMUL_MODE_PROT64:
2706 def_op_bytes = 4;
2707 def_ad_bytes = 8;
2708 break;
2709#endif
2710 default:
2711 return -1;
2712 }
2713
2714 c->op_bytes = def_op_bytes;
2715 c->ad_bytes = def_ad_bytes;
2716
2717 /* Legacy prefixes. */
2718 for (;;) {
2719 switch (c->b = insn_fetch(u8, 1, c->eip)) {
2720 case 0x66: /* operand-size override */
2721 /* switch between 2/4 bytes */
2722 c->op_bytes = def_op_bytes ^ 6;
2723 break;
2724 case 0x67: /* address-size override */
2725 if (mode == X86EMUL_MODE_PROT64)
2726 /* switch between 4/8 bytes */
2727 c->ad_bytes = def_ad_bytes ^ 12;
2728 else
2729 /* switch between 2/4 bytes */
2730 c->ad_bytes = def_ad_bytes ^ 6;
2731 break;
2732 case 0x26: /* ES override */
2733 case 0x2e: /* CS override */
2734 case 0x36: /* SS override */
2735 case 0x3e: /* DS override */
2736 set_seg_override(c, (c->b >> 3) & 3);
2737 break;
2738 case 0x64: /* FS override */
2739 case 0x65: /* GS override */
2740 set_seg_override(c, c->b & 7);
2741 break;
2742 case 0x40 ... 0x4f: /* REX */
2743 if (mode != X86EMUL_MODE_PROT64)
2744 goto done_prefixes;
2745 c->rex_prefix = c->b;
2746 continue;
2747 case 0xf0: /* LOCK */
2748 c->lock_prefix = 1;
2749 break;
2750 case 0xf2: /* REPNE/REPNZ */
2751 c->rep_prefix = REPNE_PREFIX;
2752 break;
2753 case 0xf3: /* REP/REPE/REPZ */
2754 c->rep_prefix = REPE_PREFIX;
2755 break;
2756 default:
2757 goto done_prefixes;
2758 }
2759
2760 /* Any legacy prefix after a REX prefix nullifies its effect. */
2761
2762 c->rex_prefix = 0;
2763 }
2764
2765done_prefixes:
2766
2767 /* REX prefix. */
2768 if (c->rex_prefix & 8)
2769 c->op_bytes = 8; /* REX.W */
2770
2771 /* Opcode byte(s). */
2772 opcode = opcode_table[c->b];
2773 /* Two-byte opcode? */
2774 if (c->b == 0x0f) {
2775 c->twobyte = 1;
2776 c->b = insn_fetch(u8, 1, c->eip);
2777 opcode = twobyte_table[c->b];
2778 }
2779 c->d = opcode.flags;
2780
2781 if (c->d & Group) {
2782 dual = c->d & GroupDual;
2783 c->modrm = insn_fetch(u8, 1, c->eip);
2784 --c->eip;
2785
2786 if (c->d & GroupDual) {
2787 g_mod012 = opcode.u.gdual->mod012;
2788 g_mod3 = opcode.u.gdual->mod3;
2789 } else
2790 g_mod012 = g_mod3 = opcode.u.group;
2791
2792 c->d &= ~(Group | GroupDual);
2793
2794 goffset = (c->modrm >> 3) & 7;
2795
2796 if ((c->modrm >> 6) == 3)
2797 opcode = g_mod3[goffset];
2798 else
2799 opcode = g_mod012[goffset];
2800 c->d |= opcode.flags;
2801 }
2802
2803 c->execute = opcode.u.execute;
2804
2805 /* Unrecognised? */
2806 if (c->d == 0 || (c->d & Undefined)) {
2807 DPRINTF("Cannot emulate %02x\n", c->b);
2808 return -1;
2809 }
2810
2811 if (mode == X86EMUL_MODE_PROT64 && (c->d & Stack))
2812 c->op_bytes = 8;
2813
2814 if (c->d & Op3264) {
2815 if (mode == X86EMUL_MODE_PROT64)
2816 c->op_bytes = 8;
2817 else
2818 c->op_bytes = 4;
2819 }
2820
2821 /* ModRM and SIB bytes. */
2822 if (c->d & ModRM) {
2823 rc = decode_modrm(ctxt, ops, &memop);
2824 if (!c->has_seg_override)
2825 set_seg_override(c, c->modrm_seg);
2826 } else if (c->d & MemAbs)
2827 rc = decode_abs(ctxt, ops, &memop);
2828 if (rc != X86EMUL_CONTINUE)
2829 goto done;
2830
2831 if (!c->has_seg_override)
2832 set_seg_override(c, VCPU_SREG_DS);
2833
2834 if (memop.type == OP_MEM && !(!c->twobyte && c->b == 0x8d))
2835 memop.addr.mem += seg_override_base(ctxt, ops, c);
2836
2837 if (memop.type == OP_MEM && c->ad_bytes != 8)
2838 memop.addr.mem = (u32)memop.addr.mem;
2839
2840 if (memop.type == OP_MEM && c->rip_relative)
2841 memop.addr.mem += c->eip;
2842
2843 /*
2844 * Decode and fetch the source operand: register, memory
2845 * or immediate.
2846 */
2847 switch (c->d & SrcMask) {
2848 case SrcNone:
2849 break;
2850 case SrcReg:
2851 decode_register_operand(&c->src, c, 0);
2852 break;
2853 case SrcMem16:
2854 memop.bytes = 2;
2855 goto srcmem_common;
2856 case SrcMem32:
2857 memop.bytes = 4;
2858 goto srcmem_common;
2859 case SrcMem:
2860 memop.bytes = (c->d & ByteOp) ? 1 :
2861 c->op_bytes;
2862 srcmem_common:
2863 c->src = memop;
2864 break;
2865 case SrcImmU16:
2866 rc = decode_imm(ctxt, &c->src, 2, false);
2867 break;
2868 case SrcImm:
2869 rc = decode_imm(ctxt, &c->src, imm_size(c), true);
2870 break;
2871 case SrcImmU:
2872 rc = decode_imm(ctxt, &c->src, imm_size(c), false);
2873 break;
2874 case SrcImmByte:
2875 rc = decode_imm(ctxt, &c->src, 1, true);
2876 break;
2877 case SrcImmUByte:
2878 rc = decode_imm(ctxt, &c->src, 1, false);
2879 break;
2880 case SrcAcc:
2881 c->src.type = OP_REG;
2882 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
2883 c->src.addr.reg = &c->regs[VCPU_REGS_RAX];
2884 fetch_register_operand(&c->src);
2885 break;
2886 case SrcOne:
2887 c->src.bytes = 1;
2888 c->src.val = 1;
2889 break;
2890 case SrcSI:
2891 c->src.type = OP_MEM;
2892 c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
2893 c->src.addr.mem =
2894 register_address(c, seg_override_base(ctxt, ops, c),
2895 c->regs[VCPU_REGS_RSI]);
2896 c->src.val = 0;
2897 break;
2898 case SrcImmFAddr:
2899 c->src.type = OP_IMM;
2900 c->src.addr.mem = c->eip;
2901 c->src.bytes = c->op_bytes + 2;
2902 insn_fetch_arr(c->src.valptr, c->src.bytes, c->eip);
2903 break;
2904 case SrcMemFAddr:
2905 memop.bytes = c->op_bytes + 2;
2906 goto srcmem_common;
2907 break;
2908 }
2909
2910 if (rc != X86EMUL_CONTINUE)
2911 goto done;
2912
2913 /*
2914 * Decode and fetch the second source operand: register, memory
2915 * or immediate.
2916 */
2917 switch (c->d & Src2Mask) {
2918 case Src2None:
2919 break;
2920 case Src2CL:
2921 c->src2.bytes = 1;
2922 c->src2.val = c->regs[VCPU_REGS_RCX] & 0x8;
2923 break;
2924 case Src2ImmByte:
2925 rc = decode_imm(ctxt, &c->src2, 1, true);
2926 break;
2927 case Src2One:
2928 c->src2.bytes = 1;
2929 c->src2.val = 1;
2930 break;
2931 case Src2Imm:
2932 rc = decode_imm(ctxt, &c->src2, imm_size(c), true);
2933 break;
2934 }
2935
2936 if (rc != X86EMUL_CONTINUE)
2937 goto done;
2938
2939 /* Decode and fetch the destination operand: register or memory. */
2940 switch (c->d & DstMask) {
2941 case DstReg:
2942 decode_register_operand(&c->dst, c,
2943 c->twobyte && (c->b == 0xb6 || c->b == 0xb7));
2944 break;
2945 case DstImmUByte:
2946 c->dst.type = OP_IMM;
2947 c->dst.addr.mem = c->eip;
2948 c->dst.bytes = 1;
2949 c->dst.val = insn_fetch(u8, 1, c->eip);
2950 break;
2951 case DstMem:
2952 case DstMem64:
2953 c->dst = memop;
2954 if ((c->d & DstMask) == DstMem64)
2955 c->dst.bytes = 8;
2956 else
2957 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
2958 if (c->d & BitOp)
2959 fetch_bit_operand(c);
2960 c->dst.orig_val = c->dst.val;
2961 break;
2962 case DstAcc:
2963 c->dst.type = OP_REG;
2964 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
2965 c->dst.addr.reg = &c->regs[VCPU_REGS_RAX];
2966 fetch_register_operand(&c->dst);
2967 c->dst.orig_val = c->dst.val;
2968 break;
2969 case DstDI:
2970 c->dst.type = OP_MEM;
2971 c->dst.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
2972 c->dst.addr.mem =
2973 register_address(c, es_base(ctxt, ops),
2974 c->regs[VCPU_REGS_RDI]);
2975 c->dst.val = 0;
2976 break;
2977 case ImplicitOps:
2978 /* Special instructions do their own operand decoding. */
2979 default:
2980 c->dst.type = OP_NONE; /* Disable writeback. */
2981 return 0;
2982 }
2983
2984done:
2985 return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0;
2986}
2987
2988static bool string_insn_completed(struct x86_emulate_ctxt *ctxt)
2989{
2990 struct decode_cache *c = &ctxt->decode;
2991
2992 /* The second termination condition only applies for REPE
2993 * and REPNE. Test if the repeat string operation prefix is
2994 * REPE/REPZ or REPNE/REPNZ and if it's the case it tests the
2995 * corresponding termination condition according to:
2996 * - if REPE/REPZ and ZF = 0 then done
2997 * - if REPNE/REPNZ and ZF = 1 then done
2998 */
2999 if (((c->b == 0xa6) || (c->b == 0xa7) ||
3000 (c->b == 0xae) || (c->b == 0xaf))
3001 && (((c->rep_prefix == REPE_PREFIX) &&
3002 ((ctxt->eflags & EFLG_ZF) == 0))
3003 || ((c->rep_prefix == REPNE_PREFIX) &&
3004 ((ctxt->eflags & EFLG_ZF) == EFLG_ZF))))
3005 return true;
3006
3007 return false;
3008}
3009
3010int
3011x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
3012{
3013 struct x86_emulate_ops *ops = ctxt->ops;
2561 u64 msr_data; 3014 u64 msr_data;
2562 struct decode_cache *c = &ctxt->decode; 3015 struct decode_cache *c = &ctxt->decode;
2563 int rc = X86EMUL_CONTINUE; 3016 int rc = X86EMUL_CONTINUE;
2564 int saved_dst_type = c->dst.type; 3017 int saved_dst_type = c->dst.type;
3018 int irq; /* Used for int 3, int, and into */
2565 3019
2566 ctxt->decode.mem_read.pos = 0; 3020 ctxt->decode.mem_read.pos = 0;
2567 3021
@@ -2576,6 +3030,11 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
2576 goto done; 3030 goto done;
2577 } 3031 }
2578 3032
3033 if ((c->d & SrcMask) == SrcMemFAddr && c->src.type != OP_MEM) {
3034 emulate_ud(ctxt);
3035 goto done;
3036 }
3037
2579 /* Privileged instruction can be executed only in CPL=0 */ 3038 /* Privileged instruction can be executed only in CPL=0 */
2580 if ((c->d & Priv) && ops->cpl(ctxt->vcpu)) { 3039 if ((c->d & Priv) && ops->cpl(ctxt->vcpu)) {
2581 emulate_gp(ctxt, 0); 3040 emulate_gp(ctxt, 0);
@@ -2583,35 +3042,15 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
2583 } 3042 }
2584 3043
2585 if (c->rep_prefix && (c->d & String)) { 3044 if (c->rep_prefix && (c->d & String)) {
2586 ctxt->restart = true;
2587 /* All REP prefixes have the same first termination condition */ 3045 /* All REP prefixes have the same first termination condition */
2588 if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0) { 3046 if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0) {
2589 string_done:
2590 ctxt->restart = false;
2591 ctxt->eip = c->eip; 3047 ctxt->eip = c->eip;
2592 goto done; 3048 goto done;
2593 } 3049 }
2594 /* The second termination condition only applies for REPE
2595 * and REPNE. Test if the repeat string operation prefix is
2596 * REPE/REPZ or REPNE/REPNZ and if it's the case it tests the
2597 * corresponding termination condition according to:
2598 * - if REPE/REPZ and ZF = 0 then done
2599 * - if REPNE/REPNZ and ZF = 1 then done
2600 */
2601 if ((c->b == 0xa6) || (c->b == 0xa7) ||
2602 (c->b == 0xae) || (c->b == 0xaf)) {
2603 if ((c->rep_prefix == REPE_PREFIX) &&
2604 ((ctxt->eflags & EFLG_ZF) == 0))
2605 goto string_done;
2606 if ((c->rep_prefix == REPNE_PREFIX) &&
2607 ((ctxt->eflags & EFLG_ZF) == EFLG_ZF))
2608 goto string_done;
2609 }
2610 c->eip = ctxt->eip;
2611 } 3050 }
2612 3051
2613 if (c->src.type == OP_MEM) { 3052 if ((c->src.type == OP_MEM) && !(c->d & NoAccess)) {
2614 rc = read_emulated(ctxt, ops, (unsigned long)c->src.ptr, 3053 rc = read_emulated(ctxt, ops, c->src.addr.mem,
2615 c->src.valptr, c->src.bytes); 3054 c->src.valptr, c->src.bytes);
2616 if (rc != X86EMUL_CONTINUE) 3055 if (rc != X86EMUL_CONTINUE)
2617 goto done; 3056 goto done;
@@ -2619,7 +3058,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
2619 } 3058 }
2620 3059
2621 if (c->src2.type == OP_MEM) { 3060 if (c->src2.type == OP_MEM) {
2622 rc = read_emulated(ctxt, ops, (unsigned long)c->src2.ptr, 3061 rc = read_emulated(ctxt, ops, c->src2.addr.mem,
2623 &c->src2.val, c->src2.bytes); 3062 &c->src2.val, c->src2.bytes);
2624 if (rc != X86EMUL_CONTINUE) 3063 if (rc != X86EMUL_CONTINUE)
2625 goto done; 3064 goto done;
@@ -2631,7 +3070,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
2631 3070
2632 if ((c->dst.type == OP_MEM) && !(c->d & Mov)) { 3071 if ((c->dst.type == OP_MEM) && !(c->d & Mov)) {
2633 /* optimisation - avoid slow emulated read if Mov */ 3072 /* optimisation - avoid slow emulated read if Mov */
2634 rc = read_emulated(ctxt, ops, (unsigned long)c->dst.ptr, 3073 rc = read_emulated(ctxt, ops, c->dst.addr.mem,
2635 &c->dst.val, c->dst.bytes); 3074 &c->dst.val, c->dst.bytes);
2636 if (rc != X86EMUL_CONTINUE) 3075 if (rc != X86EMUL_CONTINUE)
2637 goto done; 3076 goto done;
@@ -2640,6 +3079,13 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
2640 3079
2641special_insn: 3080special_insn:
2642 3081
3082 if (c->execute) {
3083 rc = c->execute(ctxt);
3084 if (rc != X86EMUL_CONTINUE)
3085 goto done;
3086 goto writeback;
3087 }
3088
2643 if (c->twobyte) 3089 if (c->twobyte)
2644 goto twobyte_insn; 3090 goto twobyte_insn;
2645 3091
@@ -2653,8 +3099,6 @@ special_insn:
2653 break; 3099 break;
2654 case 0x07: /* pop es */ 3100 case 0x07: /* pop es */
2655 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_ES); 3101 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_ES);
2656 if (rc != X86EMUL_CONTINUE)
2657 goto done;
2658 break; 3102 break;
2659 case 0x08 ... 0x0d: 3103 case 0x08 ... 0x0d:
2660 or: /* or */ 3104 or: /* or */
@@ -2672,8 +3116,6 @@ special_insn:
2672 break; 3116 break;
2673 case 0x17: /* pop ss */ 3117 case 0x17: /* pop ss */
2674 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_SS); 3118 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_SS);
2675 if (rc != X86EMUL_CONTINUE)
2676 goto done;
2677 break; 3119 break;
2678 case 0x18 ... 0x1d: 3120 case 0x18 ... 0x1d:
2679 sbb: /* sbb */ 3121 sbb: /* sbb */
@@ -2684,8 +3126,6 @@ special_insn:
2684 break; 3126 break;
2685 case 0x1f: /* pop ds */ 3127 case 0x1f: /* pop ds */
2686 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_DS); 3128 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_DS);
2687 if (rc != X86EMUL_CONTINUE)
2688 goto done;
2689 break; 3129 break;
2690 case 0x20 ... 0x25: 3130 case 0x20 ... 0x25:
2691 and: /* and */ 3131 and: /* and */
@@ -2709,58 +3149,29 @@ special_insn:
2709 case 0x48 ... 0x4f: /* dec r16/r32 */ 3149 case 0x48 ... 0x4f: /* dec r16/r32 */
2710 emulate_1op("dec", c->dst, ctxt->eflags); 3150 emulate_1op("dec", c->dst, ctxt->eflags);
2711 break; 3151 break;
2712 case 0x50 ... 0x57: /* push reg */
2713 emulate_push(ctxt, ops);
2714 break;
2715 case 0x58 ... 0x5f: /* pop reg */ 3152 case 0x58 ... 0x5f: /* pop reg */
2716 pop_instruction: 3153 pop_instruction:
2717 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes); 3154 rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes);
2718 if (rc != X86EMUL_CONTINUE)
2719 goto done;
2720 break; 3155 break;
2721 case 0x60: /* pusha */ 3156 case 0x60: /* pusha */
2722 rc = emulate_pusha(ctxt, ops); 3157 rc = emulate_pusha(ctxt, ops);
2723 if (rc != X86EMUL_CONTINUE)
2724 goto done;
2725 break; 3158 break;
2726 case 0x61: /* popa */ 3159 case 0x61: /* popa */
2727 rc = emulate_popa(ctxt, ops); 3160 rc = emulate_popa(ctxt, ops);
2728 if (rc != X86EMUL_CONTINUE)
2729 goto done;
2730 break; 3161 break;
2731 case 0x63: /* movsxd */ 3162 case 0x63: /* movsxd */
2732 if (ctxt->mode != X86EMUL_MODE_PROT64) 3163 if (ctxt->mode != X86EMUL_MODE_PROT64)
2733 goto cannot_emulate; 3164 goto cannot_emulate;
2734 c->dst.val = (s32) c->src.val; 3165 c->dst.val = (s32) c->src.val;
2735 break; 3166 break;
2736 case 0x68: /* push imm */
2737 case 0x6a: /* push imm8 */
2738 emulate_push(ctxt, ops);
2739 break;
2740 case 0x6c: /* insb */ 3167 case 0x6c: /* insb */
2741 case 0x6d: /* insw/insd */ 3168 case 0x6d: /* insw/insd */
2742 c->dst.bytes = min(c->dst.bytes, 4u); 3169 c->src.val = c->regs[VCPU_REGS_RDX];
2743 if (!emulator_io_permited(ctxt, ops, c->regs[VCPU_REGS_RDX], 3170 goto do_io_in;
2744 c->dst.bytes)) {
2745 emulate_gp(ctxt, 0);
2746 goto done;
2747 }
2748 if (!pio_in_emulated(ctxt, ops, c->dst.bytes,
2749 c->regs[VCPU_REGS_RDX], &c->dst.val))
2750 goto done; /* IO is needed, skip writeback */
2751 break;
2752 case 0x6e: /* outsb */ 3171 case 0x6e: /* outsb */
2753 case 0x6f: /* outsw/outsd */ 3172 case 0x6f: /* outsw/outsd */
2754 c->src.bytes = min(c->src.bytes, 4u); 3173 c->dst.val = c->regs[VCPU_REGS_RDX];
2755 if (!emulator_io_permited(ctxt, ops, c->regs[VCPU_REGS_RDX], 3174 goto do_io_out;
2756 c->src.bytes)) {
2757 emulate_gp(ctxt, 0);
2758 goto done;
2759 }
2760 ops->pio_out_emulated(c->src.bytes, c->regs[VCPU_REGS_RDX],
2761 &c->src.val, 1, ctxt->vcpu);
2762
2763 c->dst.type = OP_NONE; /* nothing to writeback */
2764 break; 3175 break;
2765 case 0x70 ... 0x7f: /* jcc (short) */ 3176 case 0x70 ... 0x7f: /* jcc (short) */
2766 if (test_cc(c->b, ctxt->eflags)) 3177 if (test_cc(c->b, ctxt->eflags))
@@ -2793,29 +3204,15 @@ special_insn:
2793 case 0x86 ... 0x87: /* xchg */ 3204 case 0x86 ... 0x87: /* xchg */
2794 xchg: 3205 xchg:
2795 /* Write back the register source. */ 3206 /* Write back the register source. */
2796 switch (c->dst.bytes) { 3207 c->src.val = c->dst.val;
2797 case 1: 3208 write_register_operand(&c->src);
2798 *(u8 *) c->src.ptr = (u8) c->dst.val;
2799 break;
2800 case 2:
2801 *(u16 *) c->src.ptr = (u16) c->dst.val;
2802 break;
2803 case 4:
2804 *c->src.ptr = (u32) c->dst.val;
2805 break; /* 64b reg: zero-extend */
2806 case 8:
2807 *c->src.ptr = c->dst.val;
2808 break;
2809 }
2810 /* 3209 /*
2811 * Write back the memory destination with implicit LOCK 3210 * Write back the memory destination with implicit LOCK
2812 * prefix. 3211 * prefix.
2813 */ 3212 */
2814 c->dst.val = c->src.val; 3213 c->dst.val = c->src.orig_val;
2815 c->lock_prefix = 1; 3214 c->lock_prefix = 1;
2816 break; 3215 break;
2817 case 0x88 ... 0x8b: /* mov */
2818 goto mov;
2819 case 0x8c: /* mov r/m, sreg */ 3216 case 0x8c: /* mov r/m, sreg */
2820 if (c->modrm_reg > VCPU_SREG_GS) { 3217 if (c->modrm_reg > VCPU_SREG_GS) {
2821 emulate_ud(ctxt); 3218 emulate_ud(ctxt);
@@ -2824,7 +3221,7 @@ special_insn:
2824 c->dst.val = ops->get_segment_selector(c->modrm_reg, ctxt->vcpu); 3221 c->dst.val = ops->get_segment_selector(c->modrm_reg, ctxt->vcpu);
2825 break; 3222 break;
2826 case 0x8d: /* lea r16/r32, m */ 3223 case 0x8d: /* lea r16/r32, m */
2827 c->dst.val = c->modrm_ea; 3224 c->dst.val = c->src.addr.mem;
2828 break; 3225 break;
2829 case 0x8e: { /* mov seg, r/m16 */ 3226 case 0x8e: { /* mov seg, r/m16 */
2830 uint16_t sel; 3227 uint16_t sel;
@@ -2847,76 +3244,87 @@ special_insn:
2847 } 3244 }
2848 case 0x8f: /* pop (sole member of Grp1a) */ 3245 case 0x8f: /* pop (sole member of Grp1a) */
2849 rc = emulate_grp1a(ctxt, ops); 3246 rc = emulate_grp1a(ctxt, ops);
2850 if (rc != X86EMUL_CONTINUE)
2851 goto done;
2852 break; 3247 break;
2853 case 0x90: /* nop / xchg r8,rax */ 3248 case 0x90 ... 0x97: /* nop / xchg reg, rax */
2854 if (c->dst.ptr == (unsigned long *)&c->regs[VCPU_REGS_RAX]) { 3249 if (c->dst.addr.reg == &c->regs[VCPU_REGS_RAX])
2855 c->dst.type = OP_NONE; /* nop */
2856 break; 3250 break;
2857 }
2858 case 0x91 ... 0x97: /* xchg reg,rax */
2859 c->src.type = OP_REG;
2860 c->src.bytes = c->op_bytes;
2861 c->src.ptr = (unsigned long *) &c->regs[VCPU_REGS_RAX];
2862 c->src.val = *(c->src.ptr);
2863 goto xchg; 3251 goto xchg;
3252 case 0x98: /* cbw/cwde/cdqe */
3253 switch (c->op_bytes) {
3254 case 2: c->dst.val = (s8)c->dst.val; break;
3255 case 4: c->dst.val = (s16)c->dst.val; break;
3256 case 8: c->dst.val = (s32)c->dst.val; break;
3257 }
3258 break;
2864 case 0x9c: /* pushf */ 3259 case 0x9c: /* pushf */
2865 c->src.val = (unsigned long) ctxt->eflags; 3260 c->src.val = (unsigned long) ctxt->eflags;
2866 emulate_push(ctxt, ops); 3261 emulate_push(ctxt, ops);
2867 break; 3262 break;
2868 case 0x9d: /* popf */ 3263 case 0x9d: /* popf */
2869 c->dst.type = OP_REG; 3264 c->dst.type = OP_REG;
2870 c->dst.ptr = (unsigned long *) &ctxt->eflags; 3265 c->dst.addr.reg = &ctxt->eflags;
2871 c->dst.bytes = c->op_bytes; 3266 c->dst.bytes = c->op_bytes;
2872 rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes); 3267 rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes);
2873 if (rc != X86EMUL_CONTINUE)
2874 goto done;
2875 break; 3268 break;
2876 case 0xa0 ... 0xa3: /* mov */
2877 case 0xa4 ... 0xa5: /* movs */
2878 goto mov;
2879 case 0xa6 ... 0xa7: /* cmps */ 3269 case 0xa6 ... 0xa7: /* cmps */
2880 c->dst.type = OP_NONE; /* Disable writeback. */ 3270 c->dst.type = OP_NONE; /* Disable writeback. */
2881 DPRINTF("cmps: mem1=0x%p mem2=0x%p\n", c->src.ptr, c->dst.ptr); 3271 DPRINTF("cmps: mem1=0x%p mem2=0x%p\n", c->src.addr.mem, c->dst.addr.mem);
2882 goto cmp; 3272 goto cmp;
2883 case 0xa8 ... 0xa9: /* test ax, imm */ 3273 case 0xa8 ... 0xa9: /* test ax, imm */
2884 goto test; 3274 goto test;
2885 case 0xaa ... 0xab: /* stos */
2886 c->dst.val = c->regs[VCPU_REGS_RAX];
2887 break;
2888 case 0xac ... 0xad: /* lods */
2889 goto mov;
2890 case 0xae ... 0xaf: /* scas */ 3275 case 0xae ... 0xaf: /* scas */
2891 DPRINTF("Urk! I don't handle SCAS.\n"); 3276 goto cmp;
2892 goto cannot_emulate;
2893 case 0xb0 ... 0xbf: /* mov r, imm */
2894 goto mov;
2895 case 0xc0 ... 0xc1: 3277 case 0xc0 ... 0xc1:
2896 emulate_grp2(ctxt); 3278 emulate_grp2(ctxt);
2897 break; 3279 break;
2898 case 0xc3: /* ret */ 3280 case 0xc3: /* ret */
2899 c->dst.type = OP_REG; 3281 c->dst.type = OP_REG;
2900 c->dst.ptr = &c->eip; 3282 c->dst.addr.reg = &c->eip;
2901 c->dst.bytes = c->op_bytes; 3283 c->dst.bytes = c->op_bytes;
2902 goto pop_instruction; 3284 goto pop_instruction;
2903 case 0xc6 ... 0xc7: /* mov (sole member of Grp11) */ 3285 case 0xc4: /* les */
2904 mov: 3286 rc = emulate_load_segment(ctxt, ops, VCPU_SREG_ES);
2905 c->dst.val = c->src.val; 3287 break;
3288 case 0xc5: /* lds */
3289 rc = emulate_load_segment(ctxt, ops, VCPU_SREG_DS);
2906 break; 3290 break;
2907 case 0xcb: /* ret far */ 3291 case 0xcb: /* ret far */
2908 rc = emulate_ret_far(ctxt, ops); 3292 rc = emulate_ret_far(ctxt, ops);
2909 if (rc != X86EMUL_CONTINUE) 3293 break;
2910 goto done; 3294 case 0xcc: /* int3 */
3295 irq = 3;
3296 goto do_interrupt;
3297 case 0xcd: /* int n */
3298 irq = c->src.val;
3299 do_interrupt:
3300 rc = emulate_int(ctxt, ops, irq);
3301 break;
3302 case 0xce: /* into */
3303 if (ctxt->eflags & EFLG_OF) {
3304 irq = 4;
3305 goto do_interrupt;
3306 }
3307 break;
3308 case 0xcf: /* iret */
3309 rc = emulate_iret(ctxt, ops);
2911 break; 3310 break;
2912 case 0xd0 ... 0xd1: /* Grp2 */ 3311 case 0xd0 ... 0xd1: /* Grp2 */
2913 c->src.val = 1;
2914 emulate_grp2(ctxt); 3312 emulate_grp2(ctxt);
2915 break; 3313 break;
2916 case 0xd2 ... 0xd3: /* Grp2 */ 3314 case 0xd2 ... 0xd3: /* Grp2 */
2917 c->src.val = c->regs[VCPU_REGS_RCX]; 3315 c->src.val = c->regs[VCPU_REGS_RCX];
2918 emulate_grp2(ctxt); 3316 emulate_grp2(ctxt);
2919 break; 3317 break;
3318 case 0xe0 ... 0xe2: /* loop/loopz/loopnz */
3319 register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
3320 if (address_mask(c, c->regs[VCPU_REGS_RCX]) != 0 &&
3321 (c->b == 0xe2 || test_cc(c->b ^ 0x5, ctxt->eflags)))
3322 jmp_rel(c, c->src.val);
3323 break;
3324 case 0xe3: /* jcxz/jecxz/jrcxz */
3325 if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0)
3326 jmp_rel(c, c->src.val);
3327 break;
2920 case 0xe4: /* inb */ 3328 case 0xe4: /* inb */
2921 case 0xe5: /* in */ 3329 case 0xe5: /* in */
2922 goto do_io_in; 3330 goto do_io_in;
@@ -2964,15 +3372,16 @@ special_insn:
2964 break; 3372 break;
2965 case 0xee: /* out dx,al */ 3373 case 0xee: /* out dx,al */
2966 case 0xef: /* out dx,(e/r)ax */ 3374 case 0xef: /* out dx,(e/r)ax */
2967 c->src.val = c->regs[VCPU_REGS_RDX]; 3375 c->dst.val = c->regs[VCPU_REGS_RDX];
2968 do_io_out: 3376 do_io_out:
2969 c->dst.bytes = min(c->dst.bytes, 4u); 3377 c->src.bytes = min(c->src.bytes, 4u);
2970 if (!emulator_io_permited(ctxt, ops, c->src.val, c->dst.bytes)) { 3378 if (!emulator_io_permited(ctxt, ops, c->dst.val,
3379 c->src.bytes)) {
2971 emulate_gp(ctxt, 0); 3380 emulate_gp(ctxt, 0);
2972 goto done; 3381 goto done;
2973 } 3382 }
2974 ops->pio_out_emulated(c->dst.bytes, c->src.val, &c->dst.val, 1, 3383 ops->pio_out_emulated(c->src.bytes, c->dst.val,
2975 ctxt->vcpu); 3384 &c->src.val, 1, ctxt->vcpu);
2976 c->dst.type = OP_NONE; /* Disable writeback. */ 3385 c->dst.type = OP_NONE; /* Disable writeback. */
2977 break; 3386 break;
2978 case 0xf4: /* hlt */ 3387 case 0xf4: /* hlt */
@@ -2981,24 +3390,22 @@ special_insn:
2981 case 0xf5: /* cmc */ 3390 case 0xf5: /* cmc */
2982 /* complement carry flag from eflags reg */ 3391 /* complement carry flag from eflags reg */
2983 ctxt->eflags ^= EFLG_CF; 3392 ctxt->eflags ^= EFLG_CF;
2984 c->dst.type = OP_NONE; /* Disable writeback. */
2985 break; 3393 break;
2986 case 0xf6 ... 0xf7: /* Grp3 */ 3394 case 0xf6 ... 0xf7: /* Grp3 */
2987 if (!emulate_grp3(ctxt, ops)) 3395 rc = emulate_grp3(ctxt, ops);
2988 goto cannot_emulate;
2989 break; 3396 break;
2990 case 0xf8: /* clc */ 3397 case 0xf8: /* clc */
2991 ctxt->eflags &= ~EFLG_CF; 3398 ctxt->eflags &= ~EFLG_CF;
2992 c->dst.type = OP_NONE; /* Disable writeback. */ 3399 break;
3400 case 0xf9: /* stc */
3401 ctxt->eflags |= EFLG_CF;
2993 break; 3402 break;
2994 case 0xfa: /* cli */ 3403 case 0xfa: /* cli */
2995 if (emulator_bad_iopl(ctxt, ops)) { 3404 if (emulator_bad_iopl(ctxt, ops)) {
2996 emulate_gp(ctxt, 0); 3405 emulate_gp(ctxt, 0);
2997 goto done; 3406 goto done;
2998 } else { 3407 } else
2999 ctxt->eflags &= ~X86_EFLAGS_IF; 3408 ctxt->eflags &= ~X86_EFLAGS_IF;
3000 c->dst.type = OP_NONE; /* Disable writeback. */
3001 }
3002 break; 3409 break;
3003 case 0xfb: /* sti */ 3410 case 0xfb: /* sti */
3004 if (emulator_bad_iopl(ctxt, ops)) { 3411 if (emulator_bad_iopl(ctxt, ops)) {
@@ -3007,29 +3414,29 @@ special_insn:
3007 } else { 3414 } else {
3008 ctxt->interruptibility = KVM_X86_SHADOW_INT_STI; 3415 ctxt->interruptibility = KVM_X86_SHADOW_INT_STI;
3009 ctxt->eflags |= X86_EFLAGS_IF; 3416 ctxt->eflags |= X86_EFLAGS_IF;
3010 c->dst.type = OP_NONE; /* Disable writeback. */
3011 } 3417 }
3012 break; 3418 break;
3013 case 0xfc: /* cld */ 3419 case 0xfc: /* cld */
3014 ctxt->eflags &= ~EFLG_DF; 3420 ctxt->eflags &= ~EFLG_DF;
3015 c->dst.type = OP_NONE; /* Disable writeback. */
3016 break; 3421 break;
3017 case 0xfd: /* std */ 3422 case 0xfd: /* std */
3018 ctxt->eflags |= EFLG_DF; 3423 ctxt->eflags |= EFLG_DF;
3019 c->dst.type = OP_NONE; /* Disable writeback. */
3020 break; 3424 break;
3021 case 0xfe: /* Grp4 */ 3425 case 0xfe: /* Grp4 */
3022 grp45: 3426 grp45:
3023 rc = emulate_grp45(ctxt, ops); 3427 rc = emulate_grp45(ctxt, ops);
3024 if (rc != X86EMUL_CONTINUE)
3025 goto done;
3026 break; 3428 break;
3027 case 0xff: /* Grp5 */ 3429 case 0xff: /* Grp5 */
3028 if (c->modrm_reg == 5) 3430 if (c->modrm_reg == 5)
3029 goto jump_far; 3431 goto jump_far;
3030 goto grp45; 3432 goto grp45;
3433 default:
3434 goto cannot_emulate;
3031 } 3435 }
3032 3436
3437 if (rc != X86EMUL_CONTINUE)
3438 goto done;
3439
3033writeback: 3440writeback:
3034 rc = writeback(ctxt, ops); 3441 rc = writeback(ctxt, ops);
3035 if (rc != X86EMUL_CONTINUE) 3442 if (rc != X86EMUL_CONTINUE)
@@ -3050,25 +3457,32 @@ writeback:
3050 &c->dst); 3457 &c->dst);
3051 3458
3052 if (c->rep_prefix && (c->d & String)) { 3459 if (c->rep_prefix && (c->d & String)) {
3053 struct read_cache *rc = &ctxt->decode.io_read; 3460 struct read_cache *r = &ctxt->decode.io_read;
3054 register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1); 3461 register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
3055 /* 3462
3056 * Re-enter guest when pio read ahead buffer is empty or, 3463 if (!string_insn_completed(ctxt)) {
3057 * if it is not used, after each 1024 iteration. 3464 /*
3058 */ 3465 * Re-enter guest when pio read ahead buffer is empty
3059 if ((rc->end == 0 && !(c->regs[VCPU_REGS_RCX] & 0x3ff)) || 3466 * or, if it is not used, after each 1024 iteration.
3060 (rc->end != 0 && rc->end == rc->pos)) 3467 */
3061 ctxt->restart = false; 3468 if ((r->end != 0 || c->regs[VCPU_REGS_RCX] & 0x3ff) &&
3469 (r->end == 0 || r->end != r->pos)) {
3470 /*
3471 * Reset read cache. Usually happens before
3472 * decode, but since instruction is restarted
3473 * we have to do it here.
3474 */
3475 ctxt->decode.mem_read.end = 0;
3476 return EMULATION_RESTART;
3477 }
3478 goto done; /* skip rip writeback */
3479 }
3062 } 3480 }
3063 /* 3481
3064 * reset read cache here in case string instruction is restared
3065 * without decoding
3066 */
3067 ctxt->decode.mem_read.end = 0;
3068 ctxt->eip = c->eip; 3482 ctxt->eip = c->eip;
3069 3483
3070done: 3484done:
3071 return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0; 3485 return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK;
3072 3486
3073twobyte_insn: 3487twobyte_insn:
3074 switch (c->b) { 3488 switch (c->b) {
@@ -3091,7 +3505,7 @@ twobyte_insn:
3091 c->dst.type = OP_NONE; 3505 c->dst.type = OP_NONE;
3092 break; 3506 break;
3093 case 2: /* lgdt */ 3507 case 2: /* lgdt */
3094 rc = read_descriptor(ctxt, ops, c->src.ptr, 3508 rc = read_descriptor(ctxt, ops, c->src.addr.mem,
3095 &size, &address, c->op_bytes); 3509 &size, &address, c->op_bytes);
3096 if (rc != X86EMUL_CONTINUE) 3510 if (rc != X86EMUL_CONTINUE)
3097 goto done; 3511 goto done;
@@ -3104,14 +3518,12 @@ twobyte_insn:
3104 switch (c->modrm_rm) { 3518 switch (c->modrm_rm) {
3105 case 1: 3519 case 1:
3106 rc = kvm_fix_hypercall(ctxt->vcpu); 3520 rc = kvm_fix_hypercall(ctxt->vcpu);
3107 if (rc != X86EMUL_CONTINUE)
3108 goto done;
3109 break; 3521 break;
3110 default: 3522 default:
3111 goto cannot_emulate; 3523 goto cannot_emulate;
3112 } 3524 }
3113 } else { 3525 } else {
3114 rc = read_descriptor(ctxt, ops, c->src.ptr, 3526 rc = read_descriptor(ctxt, ops, c->src.addr.mem,
3115 &size, &address, 3527 &size, &address,
3116 c->op_bytes); 3528 c->op_bytes);
3117 if (rc != X86EMUL_CONTINUE) 3529 if (rc != X86EMUL_CONTINUE)
@@ -3126,7 +3538,7 @@ twobyte_insn:
3126 c->dst.val = ops->get_cr(0, ctxt->vcpu); 3538 c->dst.val = ops->get_cr(0, ctxt->vcpu);
3127 break; 3539 break;
3128 case 6: /* lmsw */ 3540 case 6: /* lmsw */
3129 ops->set_cr(0, (ops->get_cr(0, ctxt->vcpu) & ~0x0ful) | 3541 ops->set_cr(0, (ops->get_cr(0, ctxt->vcpu) & ~0x0eul) |
3130 (c->src.val & 0x0f), ctxt->vcpu); 3542 (c->src.val & 0x0f), ctxt->vcpu);
3131 c->dst.type = OP_NONE; 3543 c->dst.type = OP_NONE;
3132 break; 3544 break;
@@ -3134,7 +3546,7 @@ twobyte_insn:
3134 emulate_ud(ctxt); 3546 emulate_ud(ctxt);
3135 goto done; 3547 goto done;
3136 case 7: /* invlpg*/ 3548 case 7: /* invlpg*/
3137 emulate_invlpg(ctxt->vcpu, c->modrm_ea); 3549 emulate_invlpg(ctxt->vcpu, c->src.addr.mem);
3138 /* Disable writeback. */ 3550 /* Disable writeback. */
3139 c->dst.type = OP_NONE; 3551 c->dst.type = OP_NONE;
3140 break; 3552 break;
@@ -3144,23 +3556,16 @@ twobyte_insn:
3144 break; 3556 break;
3145 case 0x05: /* syscall */ 3557 case 0x05: /* syscall */
3146 rc = emulate_syscall(ctxt, ops); 3558 rc = emulate_syscall(ctxt, ops);
3147 if (rc != X86EMUL_CONTINUE)
3148 goto done;
3149 else
3150 goto writeback;
3151 break; 3559 break;
3152 case 0x06: 3560 case 0x06:
3153 emulate_clts(ctxt->vcpu); 3561 emulate_clts(ctxt->vcpu);
3154 c->dst.type = OP_NONE;
3155 break; 3562 break;
3156 case 0x09: /* wbinvd */ 3563 case 0x09: /* wbinvd */
3157 kvm_emulate_wbinvd(ctxt->vcpu); 3564 kvm_emulate_wbinvd(ctxt->vcpu);
3158 c->dst.type = OP_NONE;
3159 break; 3565 break;
3160 case 0x08: /* invd */ 3566 case 0x08: /* invd */
3161 case 0x0d: /* GrpP (prefetch) */ 3567 case 0x0d: /* GrpP (prefetch) */
3162 case 0x18: /* Grp16 (prefetch/nop) */ 3568 case 0x18: /* Grp16 (prefetch/nop) */
3163 c->dst.type = OP_NONE;
3164 break; 3569 break;
3165 case 0x20: /* mov cr, reg */ 3570 case 0x20: /* mov cr, reg */
3166 switch (c->modrm_reg) { 3571 switch (c->modrm_reg) {
@@ -3170,8 +3575,7 @@ twobyte_insn:
3170 emulate_ud(ctxt); 3575 emulate_ud(ctxt);
3171 goto done; 3576 goto done;
3172 } 3577 }
3173 c->regs[c->modrm_rm] = ops->get_cr(c->modrm_reg, ctxt->vcpu); 3578 c->dst.val = ops->get_cr(c->modrm_reg, ctxt->vcpu);
3174 c->dst.type = OP_NONE; /* no writeback */
3175 break; 3579 break;
3176 case 0x21: /* mov from dr to reg */ 3580 case 0x21: /* mov from dr to reg */
3177 if ((ops->get_cr(4, ctxt->vcpu) & X86_CR4_DE) && 3581 if ((ops->get_cr(4, ctxt->vcpu) & X86_CR4_DE) &&
@@ -3179,11 +3583,10 @@ twobyte_insn:
3179 emulate_ud(ctxt); 3583 emulate_ud(ctxt);
3180 goto done; 3584 goto done;
3181 } 3585 }
3182 ops->get_dr(c->modrm_reg, &c->regs[c->modrm_rm], ctxt->vcpu); 3586 ops->get_dr(c->modrm_reg, &c->dst.val, ctxt->vcpu);
3183 c->dst.type = OP_NONE; /* no writeback */
3184 break; 3587 break;
3185 case 0x22: /* mov reg, cr */ 3588 case 0x22: /* mov reg, cr */
3186 if (ops->set_cr(c->modrm_reg, c->modrm_val, ctxt->vcpu)) { 3589 if (ops->set_cr(c->modrm_reg, c->src.val, ctxt->vcpu)) {
3187 emulate_gp(ctxt, 0); 3590 emulate_gp(ctxt, 0);
3188 goto done; 3591 goto done;
3189 } 3592 }
@@ -3196,7 +3599,7 @@ twobyte_insn:
3196 goto done; 3599 goto done;
3197 } 3600 }
3198 3601
3199 if (ops->set_dr(c->modrm_reg, c->regs[c->modrm_rm] & 3602 if (ops->set_dr(c->modrm_reg, c->src.val &
3200 ((ctxt->mode == X86EMUL_MODE_PROT64) ? 3603 ((ctxt->mode == X86EMUL_MODE_PROT64) ?
3201 ~0ULL : ~0U), ctxt->vcpu) < 0) { 3604 ~0ULL : ~0U), ctxt->vcpu) < 0) {
3202 /* #UD condition is already handled by the code above */ 3605 /* #UD condition is already handled by the code above */
@@ -3215,7 +3618,6 @@ twobyte_insn:
3215 goto done; 3618 goto done;
3216 } 3619 }
3217 rc = X86EMUL_CONTINUE; 3620 rc = X86EMUL_CONTINUE;
3218 c->dst.type = OP_NONE;
3219 break; 3621 break;
3220 case 0x32: 3622 case 0x32:
3221 /* rdmsr */ 3623 /* rdmsr */
@@ -3227,21 +3629,12 @@ twobyte_insn:
3227 c->regs[VCPU_REGS_RDX] = msr_data >> 32; 3629 c->regs[VCPU_REGS_RDX] = msr_data >> 32;
3228 } 3630 }
3229 rc = X86EMUL_CONTINUE; 3631 rc = X86EMUL_CONTINUE;
3230 c->dst.type = OP_NONE;
3231 break; 3632 break;
3232 case 0x34: /* sysenter */ 3633 case 0x34: /* sysenter */
3233 rc = emulate_sysenter(ctxt, ops); 3634 rc = emulate_sysenter(ctxt, ops);
3234 if (rc != X86EMUL_CONTINUE)
3235 goto done;
3236 else
3237 goto writeback;
3238 break; 3635 break;
3239 case 0x35: /* sysexit */ 3636 case 0x35: /* sysexit */
3240 rc = emulate_sysexit(ctxt, ops); 3637 rc = emulate_sysexit(ctxt, ops);
3241 if (rc != X86EMUL_CONTINUE)
3242 goto done;
3243 else
3244 goto writeback;
3245 break; 3638 break;
3246 case 0x40 ... 0x4f: /* cmov */ 3639 case 0x40 ... 0x4f: /* cmov */
3247 c->dst.val = c->dst.orig_val = c->src.val; 3640 c->dst.val = c->dst.orig_val = c->src.val;
@@ -3251,15 +3644,15 @@ twobyte_insn:
3251 case 0x80 ... 0x8f: /* jnz rel, etc*/ 3644 case 0x80 ... 0x8f: /* jnz rel, etc*/
3252 if (test_cc(c->b, ctxt->eflags)) 3645 if (test_cc(c->b, ctxt->eflags))
3253 jmp_rel(c, c->src.val); 3646 jmp_rel(c, c->src.val);
3254 c->dst.type = OP_NONE; 3647 break;
3648 case 0x90 ... 0x9f: /* setcc r/m8 */
3649 c->dst.val = test_cc(c->b, ctxt->eflags);
3255 break; 3650 break;
3256 case 0xa0: /* push fs */ 3651 case 0xa0: /* push fs */
3257 emulate_push_sreg(ctxt, ops, VCPU_SREG_FS); 3652 emulate_push_sreg(ctxt, ops, VCPU_SREG_FS);
3258 break; 3653 break;
3259 case 0xa1: /* pop fs */ 3654 case 0xa1: /* pop fs */
3260 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_FS); 3655 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_FS);
3261 if (rc != X86EMUL_CONTINUE)
3262 goto done;
3263 break; 3656 break;
3264 case 0xa3: 3657 case 0xa3:
3265 bt: /* bt */ 3658 bt: /* bt */
@@ -3277,13 +3670,9 @@ twobyte_insn:
3277 break; 3670 break;
3278 case 0xa9: /* pop gs */ 3671 case 0xa9: /* pop gs */
3279 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_GS); 3672 rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_GS);
3280 if (rc != X86EMUL_CONTINUE)
3281 goto done;
3282 break; 3673 break;
3283 case 0xab: 3674 case 0xab:
3284 bts: /* bts */ 3675 bts: /* bts */
3285 /* only subword offset */
3286 c->src.val &= (c->dst.bytes << 3) - 1;
3287 emulate_2op_SrcV_nobyte("bts", c->src, c->dst, ctxt->eflags); 3676 emulate_2op_SrcV_nobyte("bts", c->src, c->dst, ctxt->eflags);
3288 break; 3677 break;
3289 case 0xac: /* shrd imm8, r, r/m */ 3678 case 0xac: /* shrd imm8, r, r/m */
@@ -3306,15 +3695,22 @@ twobyte_insn:
3306 } else { 3695 } else {
3307 /* Failure: write the value we saw to EAX. */ 3696 /* Failure: write the value we saw to EAX. */
3308 c->dst.type = OP_REG; 3697 c->dst.type = OP_REG;
3309 c->dst.ptr = (unsigned long *)&c->regs[VCPU_REGS_RAX]; 3698 c->dst.addr.reg = (unsigned long *)&c->regs[VCPU_REGS_RAX];
3310 } 3699 }
3311 break; 3700 break;
3701 case 0xb2: /* lss */
3702 rc = emulate_load_segment(ctxt, ops, VCPU_SREG_SS);
3703 break;
3312 case 0xb3: 3704 case 0xb3:
3313 btr: /* btr */ 3705 btr: /* btr */
3314 /* only subword offset */
3315 c->src.val &= (c->dst.bytes << 3) - 1;
3316 emulate_2op_SrcV_nobyte("btr", c->src, c->dst, ctxt->eflags); 3706 emulate_2op_SrcV_nobyte("btr", c->src, c->dst, ctxt->eflags);
3317 break; 3707 break;
3708 case 0xb4: /* lfs */
3709 rc = emulate_load_segment(ctxt, ops, VCPU_SREG_FS);
3710 break;
3711 case 0xb5: /* lgs */
3712 rc = emulate_load_segment(ctxt, ops, VCPU_SREG_GS);
3713 break;
3318 case 0xb6 ... 0xb7: /* movzx */ 3714 case 0xb6 ... 0xb7: /* movzx */
3319 c->dst.bytes = c->op_bytes; 3715 c->dst.bytes = c->op_bytes;
3320 c->dst.val = (c->d & ByteOp) ? (u8) c->src.val 3716 c->dst.val = (c->d & ByteOp) ? (u8) c->src.val
@@ -3334,15 +3730,43 @@ twobyte_insn:
3334 break; 3730 break;
3335 case 0xbb: 3731 case 0xbb:
3336 btc: /* btc */ 3732 btc: /* btc */
3337 /* only subword offset */
3338 c->src.val &= (c->dst.bytes << 3) - 1;
3339 emulate_2op_SrcV_nobyte("btc", c->src, c->dst, ctxt->eflags); 3733 emulate_2op_SrcV_nobyte("btc", c->src, c->dst, ctxt->eflags);
3340 break; 3734 break;
3735 case 0xbc: { /* bsf */
3736 u8 zf;
3737 __asm__ ("bsf %2, %0; setz %1"
3738 : "=r"(c->dst.val), "=q"(zf)
3739 : "r"(c->src.val));
3740 ctxt->eflags &= ~X86_EFLAGS_ZF;
3741 if (zf) {
3742 ctxt->eflags |= X86_EFLAGS_ZF;
3743 c->dst.type = OP_NONE; /* Disable writeback. */
3744 }
3745 break;
3746 }
3747 case 0xbd: { /* bsr */
3748 u8 zf;
3749 __asm__ ("bsr %2, %0; setz %1"
3750 : "=r"(c->dst.val), "=q"(zf)
3751 : "r"(c->src.val));
3752 ctxt->eflags &= ~X86_EFLAGS_ZF;
3753 if (zf) {
3754 ctxt->eflags |= X86_EFLAGS_ZF;
3755 c->dst.type = OP_NONE; /* Disable writeback. */
3756 }
3757 break;
3758 }
3341 case 0xbe ... 0xbf: /* movsx */ 3759 case 0xbe ... 0xbf: /* movsx */
3342 c->dst.bytes = c->op_bytes; 3760 c->dst.bytes = c->op_bytes;
3343 c->dst.val = (c->d & ByteOp) ? (s8) c->src.val : 3761 c->dst.val = (c->d & ByteOp) ? (s8) c->src.val :
3344 (s16) c->src.val; 3762 (s16) c->src.val;
3345 break; 3763 break;
3764 case 0xc0 ... 0xc1: /* xadd */
3765 emulate_2op_SrcV("add", c->src, c->dst, ctxt->eflags);
3766 /* Write back the register source. */
3767 c->src.val = c->dst.orig_val;
3768 write_register_operand(&c->src);
3769 break;
3346 case 0xc3: /* movnti */ 3770 case 0xc3: /* movnti */
3347 c->dst.bytes = c->op_bytes; 3771 c->dst.bytes = c->op_bytes;
3348 c->dst.val = (c->op_bytes == 4) ? (u32) c->src.val : 3772 c->dst.val = (c->op_bytes == 4) ? (u32) c->src.val :
@@ -3350,10 +3774,14 @@ twobyte_insn:
3350 break; 3774 break;
3351 case 0xc7: /* Grp9 (cmpxchg8b) */ 3775 case 0xc7: /* Grp9 (cmpxchg8b) */
3352 rc = emulate_grp9(ctxt, ops); 3776 rc = emulate_grp9(ctxt, ops);
3353 if (rc != X86EMUL_CONTINUE)
3354 goto done;
3355 break; 3777 break;
3778 default:
3779 goto cannot_emulate;
3356 } 3780 }
3781
3782 if (rc != X86EMUL_CONTINUE)
3783 goto done;
3784
3357 goto writeback; 3785 goto writeback;
3358 3786
3359cannot_emulate: 3787cannot_emulate:
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index ddeb2314b522..efad72385058 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -5,7 +5,7 @@
5 * Copyright (c) 2006 Intel Corporation 5 * Copyright (c) 2006 Intel Corporation
6 * Copyright (c) 2007 Keir Fraser, XenSource Inc 6 * Copyright (c) 2007 Keir Fraser, XenSource Inc
7 * Copyright (c) 2008 Intel Corporation 7 * Copyright (c) 2008 Intel Corporation
8 * Copyright 2009 Red Hat, Inc. and/or its affilates. 8 * Copyright 2009 Red Hat, Inc. and/or its affiliates.
9 * 9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal 11 * of this software and associated documentation files (the "Software"), to deal
@@ -232,15 +232,6 @@ static void pit_latch_status(struct kvm *kvm, int channel)
232 } 232 }
233} 233}
234 234
235int pit_has_pending_timer(struct kvm_vcpu *vcpu)
236{
237 struct kvm_pit *pit = vcpu->kvm->arch.vpit;
238
239 if (pit && kvm_vcpu_is_bsp(vcpu) && pit->pit_state.irq_ack)
240 return atomic_read(&pit->pit_state.pit_timer.pending);
241 return 0;
242}
243
244static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian) 235static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian)
245{ 236{
246 struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state, 237 struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state,
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 4b7b73ce2098..f628234fbeca 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 2003-2004 Fabrice Bellard 4 * Copyright (c) 2003-2004 Fabrice Bellard
5 * Copyright (c) 2007 Intel Corporation 5 * Copyright (c) 2007 Intel Corporation
6 * Copyright 2009 Red Hat, Inc. and/or its affilates. 6 * Copyright 2009 Red Hat, Inc. and/or its affiliates.
7 * 7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal 9 * of this software and associated documentation files (the "Software"), to deal
@@ -39,7 +39,7 @@ static void pic_irq_request(struct kvm *kvm, int level);
39static void pic_lock(struct kvm_pic *s) 39static void pic_lock(struct kvm_pic *s)
40 __acquires(&s->lock) 40 __acquires(&s->lock)
41{ 41{
42 raw_spin_lock(&s->lock); 42 spin_lock(&s->lock);
43} 43}
44 44
45static void pic_unlock(struct kvm_pic *s) 45static void pic_unlock(struct kvm_pic *s)
@@ -51,7 +51,7 @@ static void pic_unlock(struct kvm_pic *s)
51 51
52 s->wakeup_needed = false; 52 s->wakeup_needed = false;
53 53
54 raw_spin_unlock(&s->lock); 54 spin_unlock(&s->lock);
55 55
56 if (wakeup) { 56 if (wakeup) {
57 kvm_for_each_vcpu(i, vcpu, s->kvm) { 57 kvm_for_each_vcpu(i, vcpu, s->kvm) {
@@ -67,6 +67,7 @@ static void pic_unlock(struct kvm_pic *s)
67 if (!found) 67 if (!found)
68 return; 68 return;
69 69
70 kvm_make_request(KVM_REQ_EVENT, found);
70 kvm_vcpu_kick(found); 71 kvm_vcpu_kick(found);
71 } 72 }
72} 73}
@@ -308,13 +309,17 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
308 addr &= 1; 309 addr &= 1;
309 if (addr == 0) { 310 if (addr == 0) {
310 if (val & 0x10) { 311 if (val & 0x10) {
311 kvm_pic_reset(s); /* init */
312 /*
313 * deassert a pending interrupt
314 */
315 pic_irq_request(s->pics_state->kvm, 0);
316 s->init_state = 1;
317 s->init4 = val & 1; 312 s->init4 = val & 1;
313 s->last_irr = 0;
314 s->imr = 0;
315 s->priority_add = 0;
316 s->special_mask = 0;
317 s->read_reg_select = 0;
318 if (!s->init4) {
319 s->special_fully_nested_mode = 0;
320 s->auto_eoi = 0;
321 }
322 s->init_state = 1;
318 if (val & 0x02) 323 if (val & 0x02)
319 printk(KERN_ERR "single mode not supported"); 324 printk(KERN_ERR "single mode not supported");
320 if (val & 0x08) 325 if (val & 0x08)
@@ -564,7 +569,7 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
564 s = kzalloc(sizeof(struct kvm_pic), GFP_KERNEL); 569 s = kzalloc(sizeof(struct kvm_pic), GFP_KERNEL);
565 if (!s) 570 if (!s)
566 return NULL; 571 return NULL;
567 raw_spin_lock_init(&s->lock); 572 spin_lock_init(&s->lock);
568 s->kvm = kvm; 573 s->kvm = kvm;
569 s->pics[0].elcr_mask = 0xf8; 574 s->pics[0].elcr_mask = 0xf8;
570 s->pics[1].elcr_mask = 0xde; 575 s->pics[1].elcr_mask = 0xde;
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 2095a049835e..7e06ba1618bd 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * irq.c: API for in kernel interrupt controller 2 * irq.c: API for in kernel interrupt controller
3 * Copyright (c) 2007, Intel Corporation. 3 * Copyright (c) 2007, Intel Corporation.
4 * Copyright 2009 Red Hat, Inc. and/or its affilates. 4 * Copyright 2009 Red Hat, Inc. and/or its affiliates.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -33,12 +33,7 @@
33 */ 33 */
34int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) 34int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
35{ 35{
36 int ret; 36 return apic_has_pending_timer(vcpu);
37
38 ret = pit_has_pending_timer(vcpu);
39 ret |= apic_has_pending_timer(vcpu);
40
41 return ret;
42} 37}
43EXPORT_SYMBOL(kvm_cpu_has_pending_timer); 38EXPORT_SYMBOL(kvm_cpu_has_pending_timer);
44 39
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 63c314502993..ba910d149410 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -60,7 +60,7 @@ struct kvm_kpic_state {
60}; 60};
61 61
62struct kvm_pic { 62struct kvm_pic {
63 raw_spinlock_t lock; 63 spinlock_t lock;
64 bool wakeup_needed; 64 bool wakeup_needed;
65 unsigned pending_acks; 65 unsigned pending_acks;
66 struct kvm *kvm; 66 struct kvm *kvm;
diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
index 6491ac8e755b..975bb45329a1 100644
--- a/arch/x86/kvm/kvm_cache_regs.h
+++ b/arch/x86/kvm/kvm_cache_regs.h
@@ -42,7 +42,14 @@ static inline u64 kvm_pdptr_read(struct kvm_vcpu *vcpu, int index)
42 (unsigned long *)&vcpu->arch.regs_avail)) 42 (unsigned long *)&vcpu->arch.regs_avail))
43 kvm_x86_ops->cache_reg(vcpu, VCPU_EXREG_PDPTR); 43 kvm_x86_ops->cache_reg(vcpu, VCPU_EXREG_PDPTR);
44 44
45 return vcpu->arch.pdptrs[index]; 45 return vcpu->arch.walk_mmu->pdptrs[index];
46}
47
48static inline u64 kvm_pdptr_read_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, int index)
49{
50 load_pdptrs(vcpu, mmu, mmu->get_cr3(vcpu));
51
52 return mmu->pdptrs[index];
46} 53}
47 54
48static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask) 55static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 77d8c0f4817d..413f8973a855 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 2006 Qumranet, Inc. 5 * Copyright (C) 2006 Qumranet, Inc.
6 * Copyright (C) 2007 Novell 6 * Copyright (C) 2007 Novell
7 * Copyright (C) 2007 Intel 7 * Copyright (C) 2007 Intel
8 * Copyright 2009 Red Hat, Inc. and/or its affilates. 8 * Copyright 2009 Red Hat, Inc. and/or its affiliates.
9 * 9 *
10 * Authors: 10 * Authors:
11 * Dor Laor <dor.laor@qumranet.com> 11 * Dor Laor <dor.laor@qumranet.com>
@@ -259,9 +259,10 @@ static inline int apic_find_highest_isr(struct kvm_lapic *apic)
259 259
260static void apic_update_ppr(struct kvm_lapic *apic) 260static void apic_update_ppr(struct kvm_lapic *apic)
261{ 261{
262 u32 tpr, isrv, ppr; 262 u32 tpr, isrv, ppr, old_ppr;
263 int isr; 263 int isr;
264 264
265 old_ppr = apic_get_reg(apic, APIC_PROCPRI);
265 tpr = apic_get_reg(apic, APIC_TASKPRI); 266 tpr = apic_get_reg(apic, APIC_TASKPRI);
266 isr = apic_find_highest_isr(apic); 267 isr = apic_find_highest_isr(apic);
267 isrv = (isr != -1) ? isr : 0; 268 isrv = (isr != -1) ? isr : 0;
@@ -274,7 +275,10 @@ static void apic_update_ppr(struct kvm_lapic *apic)
274 apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x", 275 apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
275 apic, ppr, isr, isrv); 276 apic, ppr, isr, isrv);
276 277
277 apic_set_reg(apic, APIC_PROCPRI, ppr); 278 if (old_ppr != ppr) {
279 apic_set_reg(apic, APIC_PROCPRI, ppr);
280 kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
281 }
278} 282}
279 283
280static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr) 284static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr)
@@ -391,6 +395,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
391 break; 395 break;
392 } 396 }
393 397
398 kvm_make_request(KVM_REQ_EVENT, vcpu);
394 kvm_vcpu_kick(vcpu); 399 kvm_vcpu_kick(vcpu);
395 break; 400 break;
396 401
@@ -416,6 +421,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
416 "INIT on a runnable vcpu %d\n", 421 "INIT on a runnable vcpu %d\n",
417 vcpu->vcpu_id); 422 vcpu->vcpu_id);
418 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; 423 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
424 kvm_make_request(KVM_REQ_EVENT, vcpu);
419 kvm_vcpu_kick(vcpu); 425 kvm_vcpu_kick(vcpu);
420 } else { 426 } else {
421 apic_debug("Ignoring de-assert INIT to vcpu %d\n", 427 apic_debug("Ignoring de-assert INIT to vcpu %d\n",
@@ -430,6 +436,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
430 result = 1; 436 result = 1;
431 vcpu->arch.sipi_vector = vector; 437 vcpu->arch.sipi_vector = vector;
432 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED; 438 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED;
439 kvm_make_request(KVM_REQ_EVENT, vcpu);
433 kvm_vcpu_kick(vcpu); 440 kvm_vcpu_kick(vcpu);
434 } 441 }
435 break; 442 break;
@@ -475,6 +482,7 @@ static void apic_set_eoi(struct kvm_lapic *apic)
475 trigger_mode = IOAPIC_EDGE_TRIG; 482 trigger_mode = IOAPIC_EDGE_TRIG;
476 if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)) 483 if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI))
477 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode); 484 kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode);
485 kvm_make_request(KVM_REQ_EVENT, apic->vcpu);
478} 486}
479 487
480static void apic_send_ipi(struct kvm_lapic *apic) 488static void apic_send_ipi(struct kvm_lapic *apic)
@@ -1056,14 +1064,13 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu)
1056 1064
1057 vcpu->arch.apic = apic; 1065 vcpu->arch.apic = apic;
1058 1066
1059 apic->regs_page = alloc_page(GFP_KERNEL); 1067 apic->regs_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
1060 if (apic->regs_page == NULL) { 1068 if (apic->regs_page == NULL) {
1061 printk(KERN_ERR "malloc apic regs error for vcpu %x\n", 1069 printk(KERN_ERR "malloc apic regs error for vcpu %x\n",
1062 vcpu->vcpu_id); 1070 vcpu->vcpu_id);
1063 goto nomem_free_apic; 1071 goto nomem_free_apic;
1064 } 1072 }
1065 apic->regs = page_address(apic->regs_page); 1073 apic->regs = page_address(apic->regs_page);
1066 memset(apic->regs, 0, PAGE_SIZE);
1067 apic->vcpu = vcpu; 1074 apic->vcpu = vcpu;
1068 1075
1069 hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, 1076 hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
@@ -1152,6 +1159,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
1152 update_divide_count(apic); 1159 update_divide_count(apic);
1153 start_apic_timer(apic); 1160 start_apic_timer(apic);
1154 apic->irr_pending = true; 1161 apic->irr_pending = true;
1162 kvm_make_request(KVM_REQ_EVENT, vcpu);
1155} 1163}
1156 1164
1157void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) 1165void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 311f6dad8951..908ea5464a51 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -7,7 +7,7 @@
7 * MMU support 7 * MMU support
8 * 8 *
9 * Copyright (C) 2006 Qumranet, Inc. 9 * Copyright (C) 2006 Qumranet, Inc.
10 * Copyright 2010 Red Hat, Inc. and/or its affilates. 10 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
11 * 11 *
12 * Authors: 12 * Authors:
13 * Yaniv Kamay <yaniv@qumranet.com> 13 * Yaniv Kamay <yaniv@qumranet.com>
@@ -49,15 +49,25 @@
49 */ 49 */
50bool tdp_enabled = false; 50bool tdp_enabled = false;
51 51
52#undef MMU_DEBUG 52enum {
53 AUDIT_PRE_PAGE_FAULT,
54 AUDIT_POST_PAGE_FAULT,
55 AUDIT_PRE_PTE_WRITE,
56 AUDIT_POST_PTE_WRITE,
57 AUDIT_PRE_SYNC,
58 AUDIT_POST_SYNC
59};
53 60
54#undef AUDIT 61char *audit_point_name[] = {
62 "pre page fault",
63 "post page fault",
64 "pre pte write",
65 "post pte write",
66 "pre sync",
67 "post sync"
68};
55 69
56#ifdef AUDIT 70#undef MMU_DEBUG
57static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg);
58#else
59static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg) {}
60#endif
61 71
62#ifdef MMU_DEBUG 72#ifdef MMU_DEBUG
63 73
@@ -71,7 +81,7 @@ static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg) {}
71 81
72#endif 82#endif
73 83
74#if defined(MMU_DEBUG) || defined(AUDIT) 84#ifdef MMU_DEBUG
75static int dbg = 0; 85static int dbg = 0;
76module_param(dbg, bool, 0644); 86module_param(dbg, bool, 0644);
77#endif 87#endif
@@ -89,6 +99,8 @@ module_param(oos_shadow, bool, 0644);
89 } 99 }
90#endif 100#endif
91 101
102#define PTE_PREFETCH_NUM 8
103
92#define PT_FIRST_AVAIL_BITS_SHIFT 9 104#define PT_FIRST_AVAIL_BITS_SHIFT 9
93#define PT64_SECOND_AVAIL_BITS_SHIFT 52 105#define PT64_SECOND_AVAIL_BITS_SHIFT 52
94 106
@@ -178,6 +190,7 @@ typedef void (*mmu_parent_walk_fn) (struct kvm_mmu_page *sp, u64 *spte);
178static struct kmem_cache *pte_chain_cache; 190static struct kmem_cache *pte_chain_cache;
179static struct kmem_cache *rmap_desc_cache; 191static struct kmem_cache *rmap_desc_cache;
180static struct kmem_cache *mmu_page_header_cache; 192static struct kmem_cache *mmu_page_header_cache;
193static struct percpu_counter kvm_total_used_mmu_pages;
181 194
182static u64 __read_mostly shadow_trap_nonpresent_pte; 195static u64 __read_mostly shadow_trap_nonpresent_pte;
183static u64 __read_mostly shadow_notrap_nonpresent_pte; 196static u64 __read_mostly shadow_notrap_nonpresent_pte;
@@ -299,18 +312,50 @@ static u64 __xchg_spte(u64 *sptep, u64 new_spte)
299#endif 312#endif
300} 313}
301 314
315static bool spte_has_volatile_bits(u64 spte)
316{
317 if (!shadow_accessed_mask)
318 return false;
319
320 if (!is_shadow_present_pte(spte))
321 return false;
322
323 if ((spte & shadow_accessed_mask) &&
324 (!is_writable_pte(spte) || (spte & shadow_dirty_mask)))
325 return false;
326
327 return true;
328}
329
330static bool spte_is_bit_cleared(u64 old_spte, u64 new_spte, u64 bit_mask)
331{
332 return (old_spte & bit_mask) && !(new_spte & bit_mask);
333}
334
302static void update_spte(u64 *sptep, u64 new_spte) 335static void update_spte(u64 *sptep, u64 new_spte)
303{ 336{
304 u64 old_spte; 337 u64 mask, old_spte = *sptep;
338
339 WARN_ON(!is_rmap_spte(new_spte));
340
341 new_spte |= old_spte & shadow_dirty_mask;
305 342
306 if (!shadow_accessed_mask || (new_spte & shadow_accessed_mask) || 343 mask = shadow_accessed_mask;
307 !is_rmap_spte(*sptep)) 344 if (is_writable_pte(old_spte))
345 mask |= shadow_dirty_mask;
346
347 if (!spte_has_volatile_bits(old_spte) || (new_spte & mask) == mask)
308 __set_spte(sptep, new_spte); 348 __set_spte(sptep, new_spte);
309 else { 349 else
310 old_spte = __xchg_spte(sptep, new_spte); 350 old_spte = __xchg_spte(sptep, new_spte);
311 if (old_spte & shadow_accessed_mask) 351
312 mark_page_accessed(pfn_to_page(spte_to_pfn(old_spte))); 352 if (!shadow_accessed_mask)
313 } 353 return;
354
355 if (spte_is_bit_cleared(old_spte, new_spte, shadow_accessed_mask))
356 kvm_set_pfn_accessed(spte_to_pfn(old_spte));
357 if (spte_is_bit_cleared(old_spte, new_spte, shadow_dirty_mask))
358 kvm_set_pfn_dirty(spte_to_pfn(old_spte));
314} 359}
315 360
316static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, 361static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
@@ -367,7 +412,7 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu)
367 if (r) 412 if (r)
368 goto out; 413 goto out;
369 r = mmu_topup_memory_cache(&vcpu->arch.mmu_rmap_desc_cache, 414 r = mmu_topup_memory_cache(&vcpu->arch.mmu_rmap_desc_cache,
370 rmap_desc_cache, 4); 415 rmap_desc_cache, 4 + PTE_PREFETCH_NUM);
371 if (r) 416 if (r)
372 goto out; 417 goto out;
373 r = mmu_topup_memory_cache_page(&vcpu->arch.mmu_page_cache, 8); 418 r = mmu_topup_memory_cache_page(&vcpu->arch.mmu_page_cache, 8);
@@ -591,6 +636,7 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
591 desc->sptes[0] = (u64 *)*rmapp; 636 desc->sptes[0] = (u64 *)*rmapp;
592 desc->sptes[1] = spte; 637 desc->sptes[1] = spte;
593 *rmapp = (unsigned long)desc | 1; 638 *rmapp = (unsigned long)desc | 1;
639 ++count;
594 } else { 640 } else {
595 rmap_printk("rmap_add: %p %llx many->many\n", spte, *spte); 641 rmap_printk("rmap_add: %p %llx many->many\n", spte, *spte);
596 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul); 642 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul);
@@ -603,7 +649,7 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
603 desc = desc->more; 649 desc = desc->more;
604 } 650 }
605 for (i = 0; desc->sptes[i]; ++i) 651 for (i = 0; desc->sptes[i]; ++i)
606 ; 652 ++count;
607 desc->sptes[i] = spte; 653 desc->sptes[i] = spte;
608 } 654 }
609 return count; 655 return count;
@@ -645,18 +691,17 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
645 gfn = kvm_mmu_page_get_gfn(sp, spte - sp->spt); 691 gfn = kvm_mmu_page_get_gfn(sp, spte - sp->spt);
646 rmapp = gfn_to_rmap(kvm, gfn, sp->role.level); 692 rmapp = gfn_to_rmap(kvm, gfn, sp->role.level);
647 if (!*rmapp) { 693 if (!*rmapp) {
648 printk(KERN_ERR "rmap_remove: %p %llx 0->BUG\n", spte, *spte); 694 printk(KERN_ERR "rmap_remove: %p 0->BUG\n", spte);
649 BUG(); 695 BUG();
650 } else if (!(*rmapp & 1)) { 696 } else if (!(*rmapp & 1)) {
651 rmap_printk("rmap_remove: %p %llx 1->0\n", spte, *spte); 697 rmap_printk("rmap_remove: %p 1->0\n", spte);
652 if ((u64 *)*rmapp != spte) { 698 if ((u64 *)*rmapp != spte) {
653 printk(KERN_ERR "rmap_remove: %p %llx 1->BUG\n", 699 printk(KERN_ERR "rmap_remove: %p 1->BUG\n", spte);
654 spte, *spte);
655 BUG(); 700 BUG();
656 } 701 }
657 *rmapp = 0; 702 *rmapp = 0;
658 } else { 703 } else {
659 rmap_printk("rmap_remove: %p %llx many->many\n", spte, *spte); 704 rmap_printk("rmap_remove: %p many->many\n", spte);
660 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul); 705 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul);
661 prev_desc = NULL; 706 prev_desc = NULL;
662 while (desc) { 707 while (desc) {
@@ -670,7 +715,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
670 prev_desc = desc; 715 prev_desc = desc;
671 desc = desc->more; 716 desc = desc->more;
672 } 717 }
673 pr_err("rmap_remove: %p %llx many->many\n", spte, *spte); 718 pr_err("rmap_remove: %p many->many\n", spte);
674 BUG(); 719 BUG();
675 } 720 }
676} 721}
@@ -680,18 +725,18 @@ static void set_spte_track_bits(u64 *sptep, u64 new_spte)
680 pfn_t pfn; 725 pfn_t pfn;
681 u64 old_spte = *sptep; 726 u64 old_spte = *sptep;
682 727
683 if (!shadow_accessed_mask || !is_shadow_present_pte(old_spte) || 728 if (!spte_has_volatile_bits(old_spte))
684 old_spte & shadow_accessed_mask) {
685 __set_spte(sptep, new_spte); 729 __set_spte(sptep, new_spte);
686 } else 730 else
687 old_spte = __xchg_spte(sptep, new_spte); 731 old_spte = __xchg_spte(sptep, new_spte);
688 732
689 if (!is_rmap_spte(old_spte)) 733 if (!is_rmap_spte(old_spte))
690 return; 734 return;
735
691 pfn = spte_to_pfn(old_spte); 736 pfn = spte_to_pfn(old_spte);
692 if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) 737 if (!shadow_accessed_mask || old_spte & shadow_accessed_mask)
693 kvm_set_pfn_accessed(pfn); 738 kvm_set_pfn_accessed(pfn);
694 if (is_writable_pte(old_spte)) 739 if (!shadow_dirty_mask || (old_spte & shadow_dirty_mask))
695 kvm_set_pfn_dirty(pfn); 740 kvm_set_pfn_dirty(pfn);
696} 741}
697 742
@@ -746,13 +791,6 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn)
746 } 791 }
747 spte = rmap_next(kvm, rmapp, spte); 792 spte = rmap_next(kvm, rmapp, spte);
748 } 793 }
749 if (write_protected) {
750 pfn_t pfn;
751
752 spte = rmap_next(kvm, rmapp, NULL);
753 pfn = spte_to_pfn(*spte);
754 kvm_set_pfn_dirty(pfn);
755 }
756 794
757 /* check for huge page mappings */ 795 /* check for huge page mappings */
758 for (i = PT_DIRECTORY_LEVEL; 796 for (i = PT_DIRECTORY_LEVEL;
@@ -947,6 +985,18 @@ static int is_empty_shadow_page(u64 *spt)
947} 985}
948#endif 986#endif
949 987
988/*
989 * This value is the sum of all of the kvm instances's
990 * kvm->arch.n_used_mmu_pages values. We need a global,
991 * aggregate version in order to make the slab shrinker
992 * faster
993 */
994static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
995{
996 kvm->arch.n_used_mmu_pages += nr;
997 percpu_counter_add(&kvm_total_used_mmu_pages, nr);
998}
999
950static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp) 1000static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp)
951{ 1001{
952 ASSERT(is_empty_shadow_page(sp->spt)); 1002 ASSERT(is_empty_shadow_page(sp->spt));
@@ -956,7 +1006,7 @@ static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp)
956 if (!sp->role.direct) 1006 if (!sp->role.direct)
957 __free_page(virt_to_page(sp->gfns)); 1007 __free_page(virt_to_page(sp->gfns));
958 kmem_cache_free(mmu_page_header_cache, sp); 1008 kmem_cache_free(mmu_page_header_cache, sp);
959 ++kvm->arch.n_free_mmu_pages; 1009 kvm_mod_used_mmu_pages(kvm, -1);
960} 1010}
961 1011
962static unsigned kvm_page_table_hashfn(gfn_t gfn) 1012static unsigned kvm_page_table_hashfn(gfn_t gfn)
@@ -979,7 +1029,7 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu,
979 bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS); 1029 bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
980 sp->multimapped = 0; 1030 sp->multimapped = 0;
981 sp->parent_pte = parent_pte; 1031 sp->parent_pte = parent_pte;
982 --vcpu->kvm->arch.n_free_mmu_pages; 1032 kvm_mod_used_mmu_pages(vcpu->kvm, +1);
983 return sp; 1033 return sp;
984} 1034}
985 1035
@@ -1403,7 +1453,8 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
1403 if (role.direct) 1453 if (role.direct)
1404 role.cr4_pae = 0; 1454 role.cr4_pae = 0;
1405 role.access = access; 1455 role.access = access;
1406 if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { 1456 if (!vcpu->arch.mmu.direct_map
1457 && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
1407 quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level)); 1458 quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level));
1408 quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1; 1459 quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1;
1409 role.quadrant = quadrant; 1460 role.quadrant = quadrant;
@@ -1458,6 +1509,12 @@ static void shadow_walk_init(struct kvm_shadow_walk_iterator *iterator,
1458 iterator->addr = addr; 1509 iterator->addr = addr;
1459 iterator->shadow_addr = vcpu->arch.mmu.root_hpa; 1510 iterator->shadow_addr = vcpu->arch.mmu.root_hpa;
1460 iterator->level = vcpu->arch.mmu.shadow_root_level; 1511 iterator->level = vcpu->arch.mmu.shadow_root_level;
1512
1513 if (iterator->level == PT64_ROOT_LEVEL &&
1514 vcpu->arch.mmu.root_level < PT64_ROOT_LEVEL &&
1515 !vcpu->arch.mmu.direct_map)
1516 --iterator->level;
1517
1461 if (iterator->level == PT32E_ROOT_LEVEL) { 1518 if (iterator->level == PT32E_ROOT_LEVEL) {
1462 iterator->shadow_addr 1519 iterator->shadow_addr
1463 = vcpu->arch.mmu.pae_root[(addr >> 30) & 3]; 1520 = vcpu->arch.mmu.pae_root[(addr >> 30) & 3];
@@ -1665,41 +1722,31 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
1665 1722
1666/* 1723/*
1667 * Changing the number of mmu pages allocated to the vm 1724 * Changing the number of mmu pages allocated to the vm
1668 * Note: if kvm_nr_mmu_pages is too small, you will get dead lock 1725 * Note: if goal_nr_mmu_pages is too small, you will get dead lock
1669 */ 1726 */
1670void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages) 1727void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int goal_nr_mmu_pages)
1671{ 1728{
1672 int used_pages;
1673 LIST_HEAD(invalid_list); 1729 LIST_HEAD(invalid_list);
1674
1675 used_pages = kvm->arch.n_alloc_mmu_pages - kvm->arch.n_free_mmu_pages;
1676 used_pages = max(0, used_pages);
1677
1678 /* 1730 /*
1679 * If we set the number of mmu pages to be smaller be than the 1731 * If we set the number of mmu pages to be smaller be than the
1680 * number of actived pages , we must to free some mmu pages before we 1732 * number of actived pages , we must to free some mmu pages before we
1681 * change the value 1733 * change the value
1682 */ 1734 */
1683 1735
1684 if (used_pages > kvm_nr_mmu_pages) { 1736 if (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages) {
1685 while (used_pages > kvm_nr_mmu_pages && 1737 while (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages &&
1686 !list_empty(&kvm->arch.active_mmu_pages)) { 1738 !list_empty(&kvm->arch.active_mmu_pages)) {
1687 struct kvm_mmu_page *page; 1739 struct kvm_mmu_page *page;
1688 1740
1689 page = container_of(kvm->arch.active_mmu_pages.prev, 1741 page = container_of(kvm->arch.active_mmu_pages.prev,
1690 struct kvm_mmu_page, link); 1742 struct kvm_mmu_page, link);
1691 used_pages -= kvm_mmu_prepare_zap_page(kvm, page, 1743 kvm_mmu_prepare_zap_page(kvm, page, &invalid_list);
1692 &invalid_list); 1744 kvm_mmu_commit_zap_page(kvm, &invalid_list);
1693 } 1745 }
1694 kvm_mmu_commit_zap_page(kvm, &invalid_list); 1746 goal_nr_mmu_pages = kvm->arch.n_used_mmu_pages;
1695 kvm_nr_mmu_pages = used_pages;
1696 kvm->arch.n_free_mmu_pages = 0;
1697 } 1747 }
1698 else
1699 kvm->arch.n_free_mmu_pages += kvm_nr_mmu_pages
1700 - kvm->arch.n_alloc_mmu_pages;
1701 1748
1702 kvm->arch.n_alloc_mmu_pages = kvm_nr_mmu_pages; 1749 kvm->arch.n_max_mmu_pages = goal_nr_mmu_pages;
1703} 1750}
1704 1751
1705static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn) 1752static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn)
@@ -1709,11 +1756,11 @@ static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn)
1709 LIST_HEAD(invalid_list); 1756 LIST_HEAD(invalid_list);
1710 int r; 1757 int r;
1711 1758
1712 pgprintk("%s: looking for gfn %lx\n", __func__, gfn); 1759 pgprintk("%s: looking for gfn %llx\n", __func__, gfn);
1713 r = 0; 1760 r = 0;
1714 1761
1715 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) { 1762 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) {
1716 pgprintk("%s: gfn %lx role %x\n", __func__, gfn, 1763 pgprintk("%s: gfn %llx role %x\n", __func__, gfn,
1717 sp->role.word); 1764 sp->role.word);
1718 r = 1; 1765 r = 1;
1719 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); 1766 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
@@ -1729,7 +1776,7 @@ static void mmu_unshadow(struct kvm *kvm, gfn_t gfn)
1729 LIST_HEAD(invalid_list); 1776 LIST_HEAD(invalid_list);
1730 1777
1731 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) { 1778 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) {
1732 pgprintk("%s: zap %lx %x\n", 1779 pgprintk("%s: zap %llx %x\n",
1733 __func__, gfn, sp->role.word); 1780 __func__, gfn, sp->role.word);
1734 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); 1781 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
1735 } 1782 }
@@ -1925,7 +1972,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1925 * whether the guest actually used the pte (in order to detect 1972 * whether the guest actually used the pte (in order to detect
1926 * demand paging). 1973 * demand paging).
1927 */ 1974 */
1928 spte = shadow_base_present_pte | shadow_dirty_mask; 1975 spte = shadow_base_present_pte;
1929 if (!speculative) 1976 if (!speculative)
1930 spte |= shadow_accessed_mask; 1977 spte |= shadow_accessed_mask;
1931 if (!dirty) 1978 if (!dirty)
@@ -1948,8 +1995,8 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1948 spte |= (u64)pfn << PAGE_SHIFT; 1995 spte |= (u64)pfn << PAGE_SHIFT;
1949 1996
1950 if ((pte_access & ACC_WRITE_MASK) 1997 if ((pte_access & ACC_WRITE_MASK)
1951 || (!tdp_enabled && write_fault && !is_write_protection(vcpu) 1998 || (!vcpu->arch.mmu.direct_map && write_fault
1952 && !user_fault)) { 1999 && !is_write_protection(vcpu) && !user_fault)) {
1953 2000
1954 if (level > PT_PAGE_TABLE_LEVEL && 2001 if (level > PT_PAGE_TABLE_LEVEL &&
1955 has_wrprotected_page(vcpu->kvm, gfn, level)) { 2002 has_wrprotected_page(vcpu->kvm, gfn, level)) {
@@ -1960,7 +2007,8 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1960 2007
1961 spte |= PT_WRITABLE_MASK; 2008 spte |= PT_WRITABLE_MASK;
1962 2009
1963 if (!tdp_enabled && !(pte_access & ACC_WRITE_MASK)) 2010 if (!vcpu->arch.mmu.direct_map
2011 && !(pte_access & ACC_WRITE_MASK))
1964 spte &= ~PT_USER_MASK; 2012 spte &= ~PT_USER_MASK;
1965 2013
1966 /* 2014 /*
@@ -1973,7 +2021,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1973 goto set_pte; 2021 goto set_pte;
1974 2022
1975 if (mmu_need_write_protect(vcpu, gfn, can_unsync)) { 2023 if (mmu_need_write_protect(vcpu, gfn, can_unsync)) {
1976 pgprintk("%s: found shadow page for %lx, marking ro\n", 2024 pgprintk("%s: found shadow page for %llx, marking ro\n",
1977 __func__, gfn); 2025 __func__, gfn);
1978 ret = 1; 2026 ret = 1;
1979 pte_access &= ~ACC_WRITE_MASK; 2027 pte_access &= ~ACC_WRITE_MASK;
@@ -1986,8 +2034,6 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1986 mark_page_dirty(vcpu->kvm, gfn); 2034 mark_page_dirty(vcpu->kvm, gfn);
1987 2035
1988set_pte: 2036set_pte:
1989 if (is_writable_pte(*sptep) && !is_writable_pte(spte))
1990 kvm_set_pfn_dirty(pfn);
1991 update_spte(sptep, spte); 2037 update_spte(sptep, spte);
1992done: 2038done:
1993 return ret; 2039 return ret;
@@ -2004,7 +2050,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2004 int rmap_count; 2050 int rmap_count;
2005 2051
2006 pgprintk("%s: spte %llx access %x write_fault %d" 2052 pgprintk("%s: spte %llx access %x write_fault %d"
2007 " user_fault %d gfn %lx\n", 2053 " user_fault %d gfn %llx\n",
2008 __func__, *sptep, pt_access, 2054 __func__, *sptep, pt_access,
2009 write_fault, user_fault, gfn); 2055 write_fault, user_fault, gfn);
2010 2056
@@ -2023,7 +2069,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2023 __set_spte(sptep, shadow_trap_nonpresent_pte); 2069 __set_spte(sptep, shadow_trap_nonpresent_pte);
2024 kvm_flush_remote_tlbs(vcpu->kvm); 2070 kvm_flush_remote_tlbs(vcpu->kvm);
2025 } else if (pfn != spte_to_pfn(*sptep)) { 2071 } else if (pfn != spte_to_pfn(*sptep)) {
2026 pgprintk("hfn old %lx new %lx\n", 2072 pgprintk("hfn old %llx new %llx\n",
2027 spte_to_pfn(*sptep), pfn); 2073 spte_to_pfn(*sptep), pfn);
2028 drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte); 2074 drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte);
2029 kvm_flush_remote_tlbs(vcpu->kvm); 2075 kvm_flush_remote_tlbs(vcpu->kvm);
@@ -2040,7 +2086,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2040 } 2086 }
2041 2087
2042 pgprintk("%s: setting spte %llx\n", __func__, *sptep); 2088 pgprintk("%s: setting spte %llx\n", __func__, *sptep);
2043 pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n", 2089 pgprintk("instantiating %s PTE (%s) at %llx (%llx) addr %p\n",
2044 is_large_pte(*sptep)? "2MB" : "4kB", 2090 is_large_pte(*sptep)? "2MB" : "4kB",
2045 *sptep & PT_PRESENT_MASK ?"RW":"R", gfn, 2091 *sptep & PT_PRESENT_MASK ?"RW":"R", gfn,
2046 *sptep, sptep); 2092 *sptep, sptep);
@@ -2064,6 +2110,105 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
2064{ 2110{
2065} 2111}
2066 2112
2113static struct kvm_memory_slot *
2114pte_prefetch_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn, bool no_dirty_log)
2115{
2116 struct kvm_memory_slot *slot;
2117
2118 slot = gfn_to_memslot(vcpu->kvm, gfn);
2119 if (!slot || slot->flags & KVM_MEMSLOT_INVALID ||
2120 (no_dirty_log && slot->dirty_bitmap))
2121 slot = NULL;
2122
2123 return slot;
2124}
2125
2126static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn,
2127 bool no_dirty_log)
2128{
2129 struct kvm_memory_slot *slot;
2130 unsigned long hva;
2131
2132 slot = pte_prefetch_gfn_to_memslot(vcpu, gfn, no_dirty_log);
2133 if (!slot) {
2134 get_page(bad_page);
2135 return page_to_pfn(bad_page);
2136 }
2137
2138 hva = gfn_to_hva_memslot(slot, gfn);
2139
2140 return hva_to_pfn_atomic(vcpu->kvm, hva);
2141}
2142
2143static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu,
2144 struct kvm_mmu_page *sp,
2145 u64 *start, u64 *end)
2146{
2147 struct page *pages[PTE_PREFETCH_NUM];
2148 unsigned access = sp->role.access;
2149 int i, ret;
2150 gfn_t gfn;
2151
2152 gfn = kvm_mmu_page_get_gfn(sp, start - sp->spt);
2153 if (!pte_prefetch_gfn_to_memslot(vcpu, gfn, access & ACC_WRITE_MASK))
2154 return -1;
2155
2156 ret = gfn_to_page_many_atomic(vcpu->kvm, gfn, pages, end - start);
2157 if (ret <= 0)
2158 return -1;
2159
2160 for (i = 0; i < ret; i++, gfn++, start++)
2161 mmu_set_spte(vcpu, start, ACC_ALL,
2162 access, 0, 0, 1, NULL,
2163 sp->role.level, gfn,
2164 page_to_pfn(pages[i]), true, true);
2165
2166 return 0;
2167}
2168
2169static void __direct_pte_prefetch(struct kvm_vcpu *vcpu,
2170 struct kvm_mmu_page *sp, u64 *sptep)
2171{
2172 u64 *spte, *start = NULL;
2173 int i;
2174
2175 WARN_ON(!sp->role.direct);
2176
2177 i = (sptep - sp->spt) & ~(PTE_PREFETCH_NUM - 1);
2178 spte = sp->spt + i;
2179
2180 for (i = 0; i < PTE_PREFETCH_NUM; i++, spte++) {
2181 if (*spte != shadow_trap_nonpresent_pte || spte == sptep) {
2182 if (!start)
2183 continue;
2184 if (direct_pte_prefetch_many(vcpu, sp, start, spte) < 0)
2185 break;
2186 start = NULL;
2187 } else if (!start)
2188 start = spte;
2189 }
2190}
2191
2192static void direct_pte_prefetch(struct kvm_vcpu *vcpu, u64 *sptep)
2193{
2194 struct kvm_mmu_page *sp;
2195
2196 /*
2197 * Since it's no accessed bit on EPT, it's no way to
2198 * distinguish between actually accessed translations
2199 * and prefetched, so disable pte prefetch if EPT is
2200 * enabled.
2201 */
2202 if (!shadow_accessed_mask)
2203 return;
2204
2205 sp = page_header(__pa(sptep));
2206 if (sp->role.level > PT_PAGE_TABLE_LEVEL)
2207 return;
2208
2209 __direct_pte_prefetch(vcpu, sp, sptep);
2210}
2211
2067static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, 2212static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2068 int level, gfn_t gfn, pfn_t pfn) 2213 int level, gfn_t gfn, pfn_t pfn)
2069{ 2214{
@@ -2077,6 +2222,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2077 mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, ACC_ALL, 2222 mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, ACC_ALL,
2078 0, write, 1, &pt_write, 2223 0, write, 1, &pt_write,
2079 level, gfn, pfn, false, true); 2224 level, gfn, pfn, false, true);
2225 direct_pte_prefetch(vcpu, iterator.sptep);
2080 ++vcpu->stat.pf_fixed; 2226 ++vcpu->stat.pf_fixed;
2081 break; 2227 break;
2082 } 2228 }
@@ -2098,28 +2244,31 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2098 __set_spte(iterator.sptep, 2244 __set_spte(iterator.sptep,
2099 __pa(sp->spt) 2245 __pa(sp->spt)
2100 | PT_PRESENT_MASK | PT_WRITABLE_MASK 2246 | PT_PRESENT_MASK | PT_WRITABLE_MASK
2101 | shadow_user_mask | shadow_x_mask); 2247 | shadow_user_mask | shadow_x_mask
2248 | shadow_accessed_mask);
2102 } 2249 }
2103 } 2250 }
2104 return pt_write; 2251 return pt_write;
2105} 2252}
2106 2253
2107static void kvm_send_hwpoison_signal(struct kvm *kvm, gfn_t gfn) 2254static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct *tsk)
2108{ 2255{
2109 char buf[1]; 2256 siginfo_t info;
2110 void __user *hva; 2257
2111 int r; 2258 info.si_signo = SIGBUS;
2259 info.si_errno = 0;
2260 info.si_code = BUS_MCEERR_AR;
2261 info.si_addr = (void __user *)address;
2262 info.si_addr_lsb = PAGE_SHIFT;
2112 2263
2113 /* Touch the page, so send SIGBUS */ 2264 send_sig_info(SIGBUS, &info, tsk);
2114 hva = (void __user *)gfn_to_hva(kvm, gfn);
2115 r = copy_from_user(buf, hva, 1);
2116} 2265}
2117 2266
2118static int kvm_handle_bad_page(struct kvm *kvm, gfn_t gfn, pfn_t pfn) 2267static int kvm_handle_bad_page(struct kvm *kvm, gfn_t gfn, pfn_t pfn)
2119{ 2268{
2120 kvm_release_pfn_clean(pfn); 2269 kvm_release_pfn_clean(pfn);
2121 if (is_hwpoison_pfn(pfn)) { 2270 if (is_hwpoison_pfn(pfn)) {
2122 kvm_send_hwpoison_signal(kvm, gfn); 2271 kvm_send_hwpoison_signal(gfn_to_hva(kvm, gfn), current);
2123 return 0; 2272 return 0;
2124 } else if (is_fault_pfn(pfn)) 2273 } else if (is_fault_pfn(pfn))
2125 return -EFAULT; 2274 return -EFAULT;
@@ -2179,7 +2328,9 @@ static void mmu_free_roots(struct kvm_vcpu *vcpu)
2179 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) 2328 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
2180 return; 2329 return;
2181 spin_lock(&vcpu->kvm->mmu_lock); 2330 spin_lock(&vcpu->kvm->mmu_lock);
2182 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2331 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL &&
2332 (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL ||
2333 vcpu->arch.mmu.direct_map)) {
2183 hpa_t root = vcpu->arch.mmu.root_hpa; 2334 hpa_t root = vcpu->arch.mmu.root_hpa;
2184 2335
2185 sp = page_header(root); 2336 sp = page_header(root);
@@ -2222,80 +2373,158 @@ static int mmu_check_root(struct kvm_vcpu *vcpu, gfn_t root_gfn)
2222 return ret; 2373 return ret;
2223} 2374}
2224 2375
2225static int mmu_alloc_roots(struct kvm_vcpu *vcpu) 2376static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
2226{ 2377{
2227 int i;
2228 gfn_t root_gfn;
2229 struct kvm_mmu_page *sp; 2378 struct kvm_mmu_page *sp;
2230 int direct = 0; 2379 unsigned i;
2231 u64 pdptr;
2232
2233 root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT;
2234 2380
2235 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2381 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
2382 spin_lock(&vcpu->kvm->mmu_lock);
2383 kvm_mmu_free_some_pages(vcpu);
2384 sp = kvm_mmu_get_page(vcpu, 0, 0, PT64_ROOT_LEVEL,
2385 1, ACC_ALL, NULL);
2386 ++sp->root_count;
2387 spin_unlock(&vcpu->kvm->mmu_lock);
2388 vcpu->arch.mmu.root_hpa = __pa(sp->spt);
2389 } else if (vcpu->arch.mmu.shadow_root_level == PT32E_ROOT_LEVEL) {
2390 for (i = 0; i < 4; ++i) {
2391 hpa_t root = vcpu->arch.mmu.pae_root[i];
2392
2393 ASSERT(!VALID_PAGE(root));
2394 spin_lock(&vcpu->kvm->mmu_lock);
2395 kvm_mmu_free_some_pages(vcpu);
2396 sp = kvm_mmu_get_page(vcpu, i << 30, i << 30,
2397 PT32_ROOT_LEVEL, 1, ACC_ALL,
2398 NULL);
2399 root = __pa(sp->spt);
2400 ++sp->root_count;
2401 spin_unlock(&vcpu->kvm->mmu_lock);
2402 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK;
2403 }
2404 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
2405 } else
2406 BUG();
2407
2408 return 0;
2409}
2410
2411static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu)
2412{
2413 struct kvm_mmu_page *sp;
2414 u64 pdptr, pm_mask;
2415 gfn_t root_gfn;
2416 int i;
2417
2418 root_gfn = vcpu->arch.mmu.get_cr3(vcpu) >> PAGE_SHIFT;
2419
2420 if (mmu_check_root(vcpu, root_gfn))
2421 return 1;
2422
2423 /*
2424 * Do we shadow a long mode page table? If so we need to
2425 * write-protect the guests page table root.
2426 */
2427 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
2236 hpa_t root = vcpu->arch.mmu.root_hpa; 2428 hpa_t root = vcpu->arch.mmu.root_hpa;
2237 2429
2238 ASSERT(!VALID_PAGE(root)); 2430 ASSERT(!VALID_PAGE(root));
2239 if (mmu_check_root(vcpu, root_gfn)) 2431
2240 return 1;
2241 if (tdp_enabled) {
2242 direct = 1;
2243 root_gfn = 0;
2244 }
2245 spin_lock(&vcpu->kvm->mmu_lock); 2432 spin_lock(&vcpu->kvm->mmu_lock);
2246 kvm_mmu_free_some_pages(vcpu); 2433 kvm_mmu_free_some_pages(vcpu);
2247 sp = kvm_mmu_get_page(vcpu, root_gfn, 0, 2434 sp = kvm_mmu_get_page(vcpu, root_gfn, 0, PT64_ROOT_LEVEL,
2248 PT64_ROOT_LEVEL, direct, 2435 0, ACC_ALL, NULL);
2249 ACC_ALL, NULL);
2250 root = __pa(sp->spt); 2436 root = __pa(sp->spt);
2251 ++sp->root_count; 2437 ++sp->root_count;
2252 spin_unlock(&vcpu->kvm->mmu_lock); 2438 spin_unlock(&vcpu->kvm->mmu_lock);
2253 vcpu->arch.mmu.root_hpa = root; 2439 vcpu->arch.mmu.root_hpa = root;
2254 return 0; 2440 return 0;
2255 } 2441 }
2256 direct = !is_paging(vcpu); 2442
2443 /*
2444 * We shadow a 32 bit page table. This may be a legacy 2-level
2445 * or a PAE 3-level page table. In either case we need to be aware that
2446 * the shadow page table may be a PAE or a long mode page table.
2447 */
2448 pm_mask = PT_PRESENT_MASK;
2449 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL)
2450 pm_mask |= PT_ACCESSED_MASK | PT_WRITABLE_MASK | PT_USER_MASK;
2451
2257 for (i = 0; i < 4; ++i) { 2452 for (i = 0; i < 4; ++i) {
2258 hpa_t root = vcpu->arch.mmu.pae_root[i]; 2453 hpa_t root = vcpu->arch.mmu.pae_root[i];
2259 2454
2260 ASSERT(!VALID_PAGE(root)); 2455 ASSERT(!VALID_PAGE(root));
2261 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { 2456 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) {
2262 pdptr = kvm_pdptr_read(vcpu, i); 2457 pdptr = kvm_pdptr_read_mmu(vcpu, &vcpu->arch.mmu, i);
2263 if (!is_present_gpte(pdptr)) { 2458 if (!is_present_gpte(pdptr)) {
2264 vcpu->arch.mmu.pae_root[i] = 0; 2459 vcpu->arch.mmu.pae_root[i] = 0;
2265 continue; 2460 continue;
2266 } 2461 }
2267 root_gfn = pdptr >> PAGE_SHIFT; 2462 root_gfn = pdptr >> PAGE_SHIFT;
2268 } else if (vcpu->arch.mmu.root_level == 0) 2463 if (mmu_check_root(vcpu, root_gfn))
2269 root_gfn = 0; 2464 return 1;
2270 if (mmu_check_root(vcpu, root_gfn))
2271 return 1;
2272 if (tdp_enabled) {
2273 direct = 1;
2274 root_gfn = i << 30;
2275 } 2465 }
2276 spin_lock(&vcpu->kvm->mmu_lock); 2466 spin_lock(&vcpu->kvm->mmu_lock);
2277 kvm_mmu_free_some_pages(vcpu); 2467 kvm_mmu_free_some_pages(vcpu);
2278 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, 2468 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30,
2279 PT32_ROOT_LEVEL, direct, 2469 PT32_ROOT_LEVEL, 0,
2280 ACC_ALL, NULL); 2470 ACC_ALL, NULL);
2281 root = __pa(sp->spt); 2471 root = __pa(sp->spt);
2282 ++sp->root_count; 2472 ++sp->root_count;
2283 spin_unlock(&vcpu->kvm->mmu_lock); 2473 spin_unlock(&vcpu->kvm->mmu_lock);
2284 2474
2285 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK; 2475 vcpu->arch.mmu.pae_root[i] = root | pm_mask;
2286 } 2476 }
2287 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root); 2477 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
2478
2479 /*
2480 * If we shadow a 32 bit page table with a long mode page
2481 * table we enter this path.
2482 */
2483 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
2484 if (vcpu->arch.mmu.lm_root == NULL) {
2485 /*
2486 * The additional page necessary for this is only
2487 * allocated on demand.
2488 */
2489
2490 u64 *lm_root;
2491
2492 lm_root = (void*)get_zeroed_page(GFP_KERNEL);
2493 if (lm_root == NULL)
2494 return 1;
2495
2496 lm_root[0] = __pa(vcpu->arch.mmu.pae_root) | pm_mask;
2497
2498 vcpu->arch.mmu.lm_root = lm_root;
2499 }
2500
2501 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.lm_root);
2502 }
2503
2288 return 0; 2504 return 0;
2289} 2505}
2290 2506
2507static int mmu_alloc_roots(struct kvm_vcpu *vcpu)
2508{
2509 if (vcpu->arch.mmu.direct_map)
2510 return mmu_alloc_direct_roots(vcpu);
2511 else
2512 return mmu_alloc_shadow_roots(vcpu);
2513}
2514
2291static void mmu_sync_roots(struct kvm_vcpu *vcpu) 2515static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2292{ 2516{
2293 int i; 2517 int i;
2294 struct kvm_mmu_page *sp; 2518 struct kvm_mmu_page *sp;
2295 2519
2520 if (vcpu->arch.mmu.direct_map)
2521 return;
2522
2296 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) 2523 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
2297 return; 2524 return;
2298 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2525
2526 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC);
2527 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
2299 hpa_t root = vcpu->arch.mmu.root_hpa; 2528 hpa_t root = vcpu->arch.mmu.root_hpa;
2300 sp = page_header(root); 2529 sp = page_header(root);
2301 mmu_sync_children(vcpu, sp); 2530 mmu_sync_children(vcpu, sp);
@@ -2310,6 +2539,7 @@ static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2310 mmu_sync_children(vcpu, sp); 2539 mmu_sync_children(vcpu, sp);
2311 } 2540 }
2312 } 2541 }
2542 trace_kvm_mmu_audit(vcpu, AUDIT_POST_SYNC);
2313} 2543}
2314 2544
2315void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) 2545void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu)
@@ -2327,6 +2557,14 @@ static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr,
2327 return vaddr; 2557 return vaddr;
2328} 2558}
2329 2559
2560static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr,
2561 u32 access, u32 *error)
2562{
2563 if (error)
2564 *error = 0;
2565 return vcpu->arch.nested_mmu.translate_gpa(vcpu, vaddr, access);
2566}
2567
2330static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, 2568static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
2331 u32 error_code) 2569 u32 error_code)
2332{ 2570{
@@ -2393,10 +2631,9 @@ static void nonpaging_free(struct kvm_vcpu *vcpu)
2393 mmu_free_roots(vcpu); 2631 mmu_free_roots(vcpu);
2394} 2632}
2395 2633
2396static int nonpaging_init_context(struct kvm_vcpu *vcpu) 2634static int nonpaging_init_context(struct kvm_vcpu *vcpu,
2635 struct kvm_mmu *context)
2397{ 2636{
2398 struct kvm_mmu *context = &vcpu->arch.mmu;
2399
2400 context->new_cr3 = nonpaging_new_cr3; 2637 context->new_cr3 = nonpaging_new_cr3;
2401 context->page_fault = nonpaging_page_fault; 2638 context->page_fault = nonpaging_page_fault;
2402 context->gva_to_gpa = nonpaging_gva_to_gpa; 2639 context->gva_to_gpa = nonpaging_gva_to_gpa;
@@ -2407,6 +2644,8 @@ static int nonpaging_init_context(struct kvm_vcpu *vcpu)
2407 context->root_level = 0; 2644 context->root_level = 0;
2408 context->shadow_root_level = PT32E_ROOT_LEVEL; 2645 context->shadow_root_level = PT32E_ROOT_LEVEL;
2409 context->root_hpa = INVALID_PAGE; 2646 context->root_hpa = INVALID_PAGE;
2647 context->direct_map = true;
2648 context->nx = false;
2410 return 0; 2649 return 0;
2411} 2650}
2412 2651
@@ -2422,11 +2661,14 @@ static void paging_new_cr3(struct kvm_vcpu *vcpu)
2422 mmu_free_roots(vcpu); 2661 mmu_free_roots(vcpu);
2423} 2662}
2424 2663
2425static void inject_page_fault(struct kvm_vcpu *vcpu, 2664static unsigned long get_cr3(struct kvm_vcpu *vcpu)
2426 u64 addr, 2665{
2427 u32 err_code) 2666 return vcpu->arch.cr3;
2667}
2668
2669static void inject_page_fault(struct kvm_vcpu *vcpu)
2428{ 2670{
2429 kvm_inject_page_fault(vcpu, addr, err_code); 2671 vcpu->arch.mmu.inject_page_fault(vcpu);
2430} 2672}
2431 2673
2432static void paging_free(struct kvm_vcpu *vcpu) 2674static void paging_free(struct kvm_vcpu *vcpu)
@@ -2434,12 +2676,12 @@ static void paging_free(struct kvm_vcpu *vcpu)
2434 nonpaging_free(vcpu); 2676 nonpaging_free(vcpu);
2435} 2677}
2436 2678
2437static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level) 2679static bool is_rsvd_bits_set(struct kvm_mmu *mmu, u64 gpte, int level)
2438{ 2680{
2439 int bit7; 2681 int bit7;
2440 2682
2441 bit7 = (gpte >> 7) & 1; 2683 bit7 = (gpte >> 7) & 1;
2442 return (gpte & vcpu->arch.mmu.rsvd_bits_mask[bit7][level-1]) != 0; 2684 return (gpte & mmu->rsvd_bits_mask[bit7][level-1]) != 0;
2443} 2685}
2444 2686
2445#define PTTYPE 64 2687#define PTTYPE 64
@@ -2450,13 +2692,14 @@ static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level)
2450#include "paging_tmpl.h" 2692#include "paging_tmpl.h"
2451#undef PTTYPE 2693#undef PTTYPE
2452 2694
2453static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level) 2695static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
2696 struct kvm_mmu *context,
2697 int level)
2454{ 2698{
2455 struct kvm_mmu *context = &vcpu->arch.mmu;
2456 int maxphyaddr = cpuid_maxphyaddr(vcpu); 2699 int maxphyaddr = cpuid_maxphyaddr(vcpu);
2457 u64 exb_bit_rsvd = 0; 2700 u64 exb_bit_rsvd = 0;
2458 2701
2459 if (!is_nx(vcpu)) 2702 if (!context->nx)
2460 exb_bit_rsvd = rsvd_bits(63, 63); 2703 exb_bit_rsvd = rsvd_bits(63, 63);
2461 switch (level) { 2704 switch (level) {
2462 case PT32_ROOT_LEVEL: 2705 case PT32_ROOT_LEVEL:
@@ -2511,9 +2754,13 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level)
2511 } 2754 }
2512} 2755}
2513 2756
2514static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level) 2757static int paging64_init_context_common(struct kvm_vcpu *vcpu,
2758 struct kvm_mmu *context,
2759 int level)
2515{ 2760{
2516 struct kvm_mmu *context = &vcpu->arch.mmu; 2761 context->nx = is_nx(vcpu);
2762
2763 reset_rsvds_bits_mask(vcpu, context, level);
2517 2764
2518 ASSERT(is_pae(vcpu)); 2765 ASSERT(is_pae(vcpu));
2519 context->new_cr3 = paging_new_cr3; 2766 context->new_cr3 = paging_new_cr3;
@@ -2526,20 +2773,23 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level)
2526 context->root_level = level; 2773 context->root_level = level;
2527 context->shadow_root_level = level; 2774 context->shadow_root_level = level;
2528 context->root_hpa = INVALID_PAGE; 2775 context->root_hpa = INVALID_PAGE;
2776 context->direct_map = false;
2529 return 0; 2777 return 0;
2530} 2778}
2531 2779
2532static int paging64_init_context(struct kvm_vcpu *vcpu) 2780static int paging64_init_context(struct kvm_vcpu *vcpu,
2781 struct kvm_mmu *context)
2533{ 2782{
2534 reset_rsvds_bits_mask(vcpu, PT64_ROOT_LEVEL); 2783 return paging64_init_context_common(vcpu, context, PT64_ROOT_LEVEL);
2535 return paging64_init_context_common(vcpu, PT64_ROOT_LEVEL);
2536} 2784}
2537 2785
2538static int paging32_init_context(struct kvm_vcpu *vcpu) 2786static int paging32_init_context(struct kvm_vcpu *vcpu,
2787 struct kvm_mmu *context)
2539{ 2788{
2540 struct kvm_mmu *context = &vcpu->arch.mmu; 2789 context->nx = false;
2790
2791 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL);
2541 2792
2542 reset_rsvds_bits_mask(vcpu, PT32_ROOT_LEVEL);
2543 context->new_cr3 = paging_new_cr3; 2793 context->new_cr3 = paging_new_cr3;
2544 context->page_fault = paging32_page_fault; 2794 context->page_fault = paging32_page_fault;
2545 context->gva_to_gpa = paging32_gva_to_gpa; 2795 context->gva_to_gpa = paging32_gva_to_gpa;
@@ -2550,18 +2800,19 @@ static int paging32_init_context(struct kvm_vcpu *vcpu)
2550 context->root_level = PT32_ROOT_LEVEL; 2800 context->root_level = PT32_ROOT_LEVEL;
2551 context->shadow_root_level = PT32E_ROOT_LEVEL; 2801 context->shadow_root_level = PT32E_ROOT_LEVEL;
2552 context->root_hpa = INVALID_PAGE; 2802 context->root_hpa = INVALID_PAGE;
2803 context->direct_map = false;
2553 return 0; 2804 return 0;
2554} 2805}
2555 2806
2556static int paging32E_init_context(struct kvm_vcpu *vcpu) 2807static int paging32E_init_context(struct kvm_vcpu *vcpu,
2808 struct kvm_mmu *context)
2557{ 2809{
2558 reset_rsvds_bits_mask(vcpu, PT32E_ROOT_LEVEL); 2810 return paging64_init_context_common(vcpu, context, PT32E_ROOT_LEVEL);
2559 return paging64_init_context_common(vcpu, PT32E_ROOT_LEVEL);
2560} 2811}
2561 2812
2562static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) 2813static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2563{ 2814{
2564 struct kvm_mmu *context = &vcpu->arch.mmu; 2815 struct kvm_mmu *context = vcpu->arch.walk_mmu;
2565 2816
2566 context->new_cr3 = nonpaging_new_cr3; 2817 context->new_cr3 = nonpaging_new_cr3;
2567 context->page_fault = tdp_page_fault; 2818 context->page_fault = tdp_page_fault;
@@ -2571,20 +2822,29 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2571 context->invlpg = nonpaging_invlpg; 2822 context->invlpg = nonpaging_invlpg;
2572 context->shadow_root_level = kvm_x86_ops->get_tdp_level(); 2823 context->shadow_root_level = kvm_x86_ops->get_tdp_level();
2573 context->root_hpa = INVALID_PAGE; 2824 context->root_hpa = INVALID_PAGE;
2825 context->direct_map = true;
2826 context->set_cr3 = kvm_x86_ops->set_tdp_cr3;
2827 context->get_cr3 = get_cr3;
2828 context->inject_page_fault = kvm_inject_page_fault;
2829 context->nx = is_nx(vcpu);
2574 2830
2575 if (!is_paging(vcpu)) { 2831 if (!is_paging(vcpu)) {
2832 context->nx = false;
2576 context->gva_to_gpa = nonpaging_gva_to_gpa; 2833 context->gva_to_gpa = nonpaging_gva_to_gpa;
2577 context->root_level = 0; 2834 context->root_level = 0;
2578 } else if (is_long_mode(vcpu)) { 2835 } else if (is_long_mode(vcpu)) {
2579 reset_rsvds_bits_mask(vcpu, PT64_ROOT_LEVEL); 2836 context->nx = is_nx(vcpu);
2837 reset_rsvds_bits_mask(vcpu, context, PT64_ROOT_LEVEL);
2580 context->gva_to_gpa = paging64_gva_to_gpa; 2838 context->gva_to_gpa = paging64_gva_to_gpa;
2581 context->root_level = PT64_ROOT_LEVEL; 2839 context->root_level = PT64_ROOT_LEVEL;
2582 } else if (is_pae(vcpu)) { 2840 } else if (is_pae(vcpu)) {
2583 reset_rsvds_bits_mask(vcpu, PT32E_ROOT_LEVEL); 2841 context->nx = is_nx(vcpu);
2842 reset_rsvds_bits_mask(vcpu, context, PT32E_ROOT_LEVEL);
2584 context->gva_to_gpa = paging64_gva_to_gpa; 2843 context->gva_to_gpa = paging64_gva_to_gpa;
2585 context->root_level = PT32E_ROOT_LEVEL; 2844 context->root_level = PT32E_ROOT_LEVEL;
2586 } else { 2845 } else {
2587 reset_rsvds_bits_mask(vcpu, PT32_ROOT_LEVEL); 2846 context->nx = false;
2847 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL);
2588 context->gva_to_gpa = paging32_gva_to_gpa; 2848 context->gva_to_gpa = paging32_gva_to_gpa;
2589 context->root_level = PT32_ROOT_LEVEL; 2849 context->root_level = PT32_ROOT_LEVEL;
2590 } 2850 }
@@ -2592,33 +2852,83 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2592 return 0; 2852 return 0;
2593} 2853}
2594 2854
2595static int init_kvm_softmmu(struct kvm_vcpu *vcpu) 2855int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
2596{ 2856{
2597 int r; 2857 int r;
2598
2599 ASSERT(vcpu); 2858 ASSERT(vcpu);
2600 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa)); 2859 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
2601 2860
2602 if (!is_paging(vcpu)) 2861 if (!is_paging(vcpu))
2603 r = nonpaging_init_context(vcpu); 2862 r = nonpaging_init_context(vcpu, context);
2604 else if (is_long_mode(vcpu)) 2863 else if (is_long_mode(vcpu))
2605 r = paging64_init_context(vcpu); 2864 r = paging64_init_context(vcpu, context);
2606 else if (is_pae(vcpu)) 2865 else if (is_pae(vcpu))
2607 r = paging32E_init_context(vcpu); 2866 r = paging32E_init_context(vcpu, context);
2608 else 2867 else
2609 r = paging32_init_context(vcpu); 2868 r = paging32_init_context(vcpu, context);
2610 2869
2611 vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu); 2870 vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu);
2612 vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu); 2871 vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu);
2613 2872
2614 return r; 2873 return r;
2615} 2874}
2875EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu);
2876
2877static int init_kvm_softmmu(struct kvm_vcpu *vcpu)
2878{
2879 int r = kvm_init_shadow_mmu(vcpu, vcpu->arch.walk_mmu);
2880
2881 vcpu->arch.walk_mmu->set_cr3 = kvm_x86_ops->set_cr3;
2882 vcpu->arch.walk_mmu->get_cr3 = get_cr3;
2883 vcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault;
2884
2885 return r;
2886}
2887
2888static int init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
2889{
2890 struct kvm_mmu *g_context = &vcpu->arch.nested_mmu;
2891
2892 g_context->get_cr3 = get_cr3;
2893 g_context->inject_page_fault = kvm_inject_page_fault;
2894
2895 /*
2896 * Note that arch.mmu.gva_to_gpa translates l2_gva to l1_gpa. The
2897 * translation of l2_gpa to l1_gpa addresses is done using the
2898 * arch.nested_mmu.gva_to_gpa function. Basically the gva_to_gpa
2899 * functions between mmu and nested_mmu are swapped.
2900 */
2901 if (!is_paging(vcpu)) {
2902 g_context->nx = false;
2903 g_context->root_level = 0;
2904 g_context->gva_to_gpa = nonpaging_gva_to_gpa_nested;
2905 } else if (is_long_mode(vcpu)) {
2906 g_context->nx = is_nx(vcpu);
2907 reset_rsvds_bits_mask(vcpu, g_context, PT64_ROOT_LEVEL);
2908 g_context->root_level = PT64_ROOT_LEVEL;
2909 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
2910 } else if (is_pae(vcpu)) {
2911 g_context->nx = is_nx(vcpu);
2912 reset_rsvds_bits_mask(vcpu, g_context, PT32E_ROOT_LEVEL);
2913 g_context->root_level = PT32E_ROOT_LEVEL;
2914 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
2915 } else {
2916 g_context->nx = false;
2917 reset_rsvds_bits_mask(vcpu, g_context, PT32_ROOT_LEVEL);
2918 g_context->root_level = PT32_ROOT_LEVEL;
2919 g_context->gva_to_gpa = paging32_gva_to_gpa_nested;
2920 }
2921
2922 return 0;
2923}
2616 2924
2617static int init_kvm_mmu(struct kvm_vcpu *vcpu) 2925static int init_kvm_mmu(struct kvm_vcpu *vcpu)
2618{ 2926{
2619 vcpu->arch.update_pte.pfn = bad_pfn; 2927 vcpu->arch.update_pte.pfn = bad_pfn;
2620 2928
2621 if (tdp_enabled) 2929 if (mmu_is_nested(vcpu))
2930 return init_kvm_nested_mmu(vcpu);
2931 else if (tdp_enabled)
2622 return init_kvm_tdp_mmu(vcpu); 2932 return init_kvm_tdp_mmu(vcpu);
2623 else 2933 else
2624 return init_kvm_softmmu(vcpu); 2934 return init_kvm_softmmu(vcpu);
@@ -2653,7 +2963,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
2653 if (r) 2963 if (r)
2654 goto out; 2964 goto out;
2655 /* set_cr3() should ensure TLB has been flushed */ 2965 /* set_cr3() should ensure TLB has been flushed */
2656 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa); 2966 vcpu->arch.mmu.set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
2657out: 2967out:
2658 return r; 2968 return r;
2659} 2969}
@@ -2663,6 +2973,7 @@ void kvm_mmu_unload(struct kvm_vcpu *vcpu)
2663{ 2973{
2664 mmu_free_roots(vcpu); 2974 mmu_free_roots(vcpu);
2665} 2975}
2976EXPORT_SYMBOL_GPL(kvm_mmu_unload);
2666 2977
2667static void mmu_pte_write_zap_pte(struct kvm_vcpu *vcpu, 2978static void mmu_pte_write_zap_pte(struct kvm_vcpu *vcpu,
2668 struct kvm_mmu_page *sp, 2979 struct kvm_mmu_page *sp,
@@ -2695,7 +3006,7 @@ static void mmu_pte_write_new_pte(struct kvm_vcpu *vcpu,
2695 return; 3006 return;
2696 } 3007 }
2697 3008
2698 if (is_rsvd_bits_set(vcpu, *(u64 *)new, PT_PAGE_TABLE_LEVEL)) 3009 if (is_rsvd_bits_set(&vcpu->arch.mmu, *(u64 *)new, PT_PAGE_TABLE_LEVEL))
2699 return; 3010 return;
2700 3011
2701 ++vcpu->kvm->stat.mmu_pte_updated; 3012 ++vcpu->kvm->stat.mmu_pte_updated;
@@ -2837,7 +3148,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
2837 kvm_mmu_access_page(vcpu, gfn); 3148 kvm_mmu_access_page(vcpu, gfn);
2838 kvm_mmu_free_some_pages(vcpu); 3149 kvm_mmu_free_some_pages(vcpu);
2839 ++vcpu->kvm->stat.mmu_pte_write; 3150 ++vcpu->kvm->stat.mmu_pte_write;
2840 kvm_mmu_audit(vcpu, "pre pte write"); 3151 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE);
2841 if (guest_initiated) { 3152 if (guest_initiated) {
2842 if (gfn == vcpu->arch.last_pt_write_gfn 3153 if (gfn == vcpu->arch.last_pt_write_gfn
2843 && !last_updated_pte_accessed(vcpu)) { 3154 && !last_updated_pte_accessed(vcpu)) {
@@ -2910,7 +3221,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
2910 } 3221 }
2911 mmu_pte_write_flush_tlb(vcpu, zap_page, remote_flush, local_flush); 3222 mmu_pte_write_flush_tlb(vcpu, zap_page, remote_flush, local_flush);
2912 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list); 3223 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2913 kvm_mmu_audit(vcpu, "post pte write"); 3224 trace_kvm_mmu_audit(vcpu, AUDIT_POST_PTE_WRITE);
2914 spin_unlock(&vcpu->kvm->mmu_lock); 3225 spin_unlock(&vcpu->kvm->mmu_lock);
2915 if (!is_error_pfn(vcpu->arch.update_pte.pfn)) { 3226 if (!is_error_pfn(vcpu->arch.update_pte.pfn)) {
2916 kvm_release_pfn_clean(vcpu->arch.update_pte.pfn); 3227 kvm_release_pfn_clean(vcpu->arch.update_pte.pfn);
@@ -2923,7 +3234,7 @@ int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
2923 gpa_t gpa; 3234 gpa_t gpa;
2924 int r; 3235 int r;
2925 3236
2926 if (tdp_enabled) 3237 if (vcpu->arch.mmu.direct_map)
2927 return 0; 3238 return 0;
2928 3239
2929 gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL); 3240 gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL);
@@ -2937,21 +3248,18 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page_virt);
2937 3248
2938void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) 3249void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
2939{ 3250{
2940 int free_pages;
2941 LIST_HEAD(invalid_list); 3251 LIST_HEAD(invalid_list);
2942 3252
2943 free_pages = vcpu->kvm->arch.n_free_mmu_pages; 3253 while (kvm_mmu_available_pages(vcpu->kvm) < KVM_REFILL_PAGES &&
2944 while (free_pages < KVM_REFILL_PAGES &&
2945 !list_empty(&vcpu->kvm->arch.active_mmu_pages)) { 3254 !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
2946 struct kvm_mmu_page *sp; 3255 struct kvm_mmu_page *sp;
2947 3256
2948 sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev, 3257 sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,
2949 struct kvm_mmu_page, link); 3258 struct kvm_mmu_page, link);
2950 free_pages += kvm_mmu_prepare_zap_page(vcpu->kvm, sp, 3259 kvm_mmu_prepare_zap_page(vcpu->kvm, sp, &invalid_list);
2951 &invalid_list); 3260 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2952 ++vcpu->kvm->stat.mmu_recycled; 3261 ++vcpu->kvm->stat.mmu_recycled;
2953 } 3262 }
2954 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2955} 3263}
2956 3264
2957int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code) 3265int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
@@ -3013,6 +3321,8 @@ EXPORT_SYMBOL_GPL(kvm_disable_tdp);
3013static void free_mmu_pages(struct kvm_vcpu *vcpu) 3321static void free_mmu_pages(struct kvm_vcpu *vcpu)
3014{ 3322{
3015 free_page((unsigned long)vcpu->arch.mmu.pae_root); 3323 free_page((unsigned long)vcpu->arch.mmu.pae_root);
3324 if (vcpu->arch.mmu.lm_root != NULL)
3325 free_page((unsigned long)vcpu->arch.mmu.lm_root);
3016} 3326}
3017 3327
3018static int alloc_mmu_pages(struct kvm_vcpu *vcpu) 3328static int alloc_mmu_pages(struct kvm_vcpu *vcpu)
@@ -3054,15 +3364,6 @@ int kvm_mmu_setup(struct kvm_vcpu *vcpu)
3054 return init_kvm_mmu(vcpu); 3364 return init_kvm_mmu(vcpu);
3055} 3365}
3056 3366
3057void kvm_mmu_destroy(struct kvm_vcpu *vcpu)
3058{
3059 ASSERT(vcpu);
3060
3061 destroy_kvm_mmu(vcpu);
3062 free_mmu_pages(vcpu);
3063 mmu_free_memory_caches(vcpu);
3064}
3065
3066void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot) 3367void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
3067{ 3368{
3068 struct kvm_mmu_page *sp; 3369 struct kvm_mmu_page *sp;
@@ -3112,23 +3413,22 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
3112{ 3413{
3113 struct kvm *kvm; 3414 struct kvm *kvm;
3114 struct kvm *kvm_freed = NULL; 3415 struct kvm *kvm_freed = NULL;
3115 int cache_count = 0; 3416
3417 if (nr_to_scan == 0)
3418 goto out;
3116 3419
3117 spin_lock(&kvm_lock); 3420 spin_lock(&kvm_lock);
3118 3421
3119 list_for_each_entry(kvm, &vm_list, vm_list) { 3422 list_for_each_entry(kvm, &vm_list, vm_list) {
3120 int npages, idx, freed_pages; 3423 int idx, freed_pages;
3121 LIST_HEAD(invalid_list); 3424 LIST_HEAD(invalid_list);
3122 3425
3123 idx = srcu_read_lock(&kvm->srcu); 3426 idx = srcu_read_lock(&kvm->srcu);
3124 spin_lock(&kvm->mmu_lock); 3427 spin_lock(&kvm->mmu_lock);
3125 npages = kvm->arch.n_alloc_mmu_pages - 3428 if (!kvm_freed && nr_to_scan > 0 &&
3126 kvm->arch.n_free_mmu_pages; 3429 kvm->arch.n_used_mmu_pages > 0) {
3127 cache_count += npages;
3128 if (!kvm_freed && nr_to_scan > 0 && npages > 0) {
3129 freed_pages = kvm_mmu_remove_some_alloc_mmu_pages(kvm, 3430 freed_pages = kvm_mmu_remove_some_alloc_mmu_pages(kvm,
3130 &invalid_list); 3431 &invalid_list);
3131 cache_count -= freed_pages;
3132 kvm_freed = kvm; 3432 kvm_freed = kvm;
3133 } 3433 }
3134 nr_to_scan--; 3434 nr_to_scan--;
@@ -3142,7 +3442,8 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
3142 3442
3143 spin_unlock(&kvm_lock); 3443 spin_unlock(&kvm_lock);
3144 3444
3145 return cache_count; 3445out:
3446 return percpu_counter_read_positive(&kvm_total_used_mmu_pages);
3146} 3447}
3147 3448
3148static struct shrinker mmu_shrinker = { 3449static struct shrinker mmu_shrinker = {
@@ -3163,6 +3464,7 @@ static void mmu_destroy_caches(void)
3163void kvm_mmu_module_exit(void) 3464void kvm_mmu_module_exit(void)
3164{ 3465{
3165 mmu_destroy_caches(); 3466 mmu_destroy_caches();
3467 percpu_counter_destroy(&kvm_total_used_mmu_pages);
3166 unregister_shrinker(&mmu_shrinker); 3468 unregister_shrinker(&mmu_shrinker);
3167} 3469}
3168 3470
@@ -3185,6 +3487,9 @@ int kvm_mmu_module_init(void)
3185 if (!mmu_page_header_cache) 3487 if (!mmu_page_header_cache)
3186 goto nomem; 3488 goto nomem;
3187 3489
3490 if (percpu_counter_init(&kvm_total_used_mmu_pages, 0))
3491 goto nomem;
3492
3188 register_shrinker(&mmu_shrinker); 3493 register_shrinker(&mmu_shrinker);
3189 3494
3190 return 0; 3495 return 0;
@@ -3355,271 +3660,18 @@ int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4])
3355} 3660}
3356EXPORT_SYMBOL_GPL(kvm_mmu_get_spte_hierarchy); 3661EXPORT_SYMBOL_GPL(kvm_mmu_get_spte_hierarchy);
3357 3662
3358#ifdef AUDIT 3663#ifdef CONFIG_KVM_MMU_AUDIT
3359 3664#include "mmu_audit.c"
3360static const char *audit_msg; 3665#else
3361 3666static void mmu_audit_disable(void) { }
3362static gva_t canonicalize(gva_t gva)
3363{
3364#ifdef CONFIG_X86_64
3365 gva = (long long)(gva << 16) >> 16;
3366#endif 3667#endif
3367 return gva;
3368}
3369
3370
3371typedef void (*inspect_spte_fn) (struct kvm *kvm, u64 *sptep);
3372
3373static void __mmu_spte_walk(struct kvm *kvm, struct kvm_mmu_page *sp,
3374 inspect_spte_fn fn)
3375{
3376 int i;
3377
3378 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
3379 u64 ent = sp->spt[i];
3380
3381 if (is_shadow_present_pte(ent)) {
3382 if (!is_last_spte(ent, sp->role.level)) {
3383 struct kvm_mmu_page *child;
3384 child = page_header(ent & PT64_BASE_ADDR_MASK);
3385 __mmu_spte_walk(kvm, child, fn);
3386 } else
3387 fn(kvm, &sp->spt[i]);
3388 }
3389 }
3390}
3391
3392static void mmu_spte_walk(struct kvm_vcpu *vcpu, inspect_spte_fn fn)
3393{
3394 int i;
3395 struct kvm_mmu_page *sp;
3396
3397 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
3398 return;
3399 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
3400 hpa_t root = vcpu->arch.mmu.root_hpa;
3401 sp = page_header(root);
3402 __mmu_spte_walk(vcpu->kvm, sp, fn);
3403 return;
3404 }
3405 for (i = 0; i < 4; ++i) {
3406 hpa_t root = vcpu->arch.mmu.pae_root[i];
3407
3408 if (root && VALID_PAGE(root)) {
3409 root &= PT64_BASE_ADDR_MASK;
3410 sp = page_header(root);
3411 __mmu_spte_walk(vcpu->kvm, sp, fn);
3412 }
3413 }
3414 return;
3415}
3416
3417static void audit_mappings_page(struct kvm_vcpu *vcpu, u64 page_pte,
3418 gva_t va, int level)
3419{
3420 u64 *pt = __va(page_pte & PT64_BASE_ADDR_MASK);
3421 int i;
3422 gva_t va_delta = 1ul << (PAGE_SHIFT + 9 * (level - 1));
3423
3424 for (i = 0; i < PT64_ENT_PER_PAGE; ++i, va += va_delta) {
3425 u64 ent = pt[i];
3426
3427 if (ent == shadow_trap_nonpresent_pte)
3428 continue;
3429
3430 va = canonicalize(va);
3431 if (is_shadow_present_pte(ent) && !is_last_spte(ent, level))
3432 audit_mappings_page(vcpu, ent, va, level - 1);
3433 else {
3434 gpa_t gpa = kvm_mmu_gva_to_gpa_read(vcpu, va, NULL);
3435 gfn_t gfn = gpa >> PAGE_SHIFT;
3436 pfn_t pfn = gfn_to_pfn(vcpu->kvm, gfn);
3437 hpa_t hpa = (hpa_t)pfn << PAGE_SHIFT;
3438 3668
3439 if (is_error_pfn(pfn)) { 3669void kvm_mmu_destroy(struct kvm_vcpu *vcpu)
3440 kvm_release_pfn_clean(pfn);
3441 continue;
3442 }
3443
3444 if (is_shadow_present_pte(ent)
3445 && (ent & PT64_BASE_ADDR_MASK) != hpa)
3446 printk(KERN_ERR "xx audit error: (%s) levels %d"
3447 " gva %lx gpa %llx hpa %llx ent %llx %d\n",
3448 audit_msg, vcpu->arch.mmu.root_level,
3449 va, gpa, hpa, ent,
3450 is_shadow_present_pte(ent));
3451 else if (ent == shadow_notrap_nonpresent_pte
3452 && !is_error_hpa(hpa))
3453 printk(KERN_ERR "audit: (%s) notrap shadow,"
3454 " valid guest gva %lx\n", audit_msg, va);
3455 kvm_release_pfn_clean(pfn);
3456
3457 }
3458 }
3459}
3460
3461static void audit_mappings(struct kvm_vcpu *vcpu)
3462{
3463 unsigned i;
3464
3465 if (vcpu->arch.mmu.root_level == 4)
3466 audit_mappings_page(vcpu, vcpu->arch.mmu.root_hpa, 0, 4);
3467 else
3468 for (i = 0; i < 4; ++i)
3469 if (vcpu->arch.mmu.pae_root[i] & PT_PRESENT_MASK)
3470 audit_mappings_page(vcpu,
3471 vcpu->arch.mmu.pae_root[i],
3472 i << 30,
3473 2);
3474}
3475
3476static int count_rmaps(struct kvm_vcpu *vcpu)
3477{
3478 struct kvm *kvm = vcpu->kvm;
3479 struct kvm_memslots *slots;
3480 int nmaps = 0;
3481 int i, j, k, idx;
3482
3483 idx = srcu_read_lock(&kvm->srcu);
3484 slots = kvm_memslots(kvm);
3485 for (i = 0; i < KVM_MEMORY_SLOTS; ++i) {
3486 struct kvm_memory_slot *m = &slots->memslots[i];
3487 struct kvm_rmap_desc *d;
3488
3489 for (j = 0; j < m->npages; ++j) {
3490 unsigned long *rmapp = &m->rmap[j];
3491
3492 if (!*rmapp)
3493 continue;
3494 if (!(*rmapp & 1)) {
3495 ++nmaps;
3496 continue;
3497 }
3498 d = (struct kvm_rmap_desc *)(*rmapp & ~1ul);
3499 while (d) {
3500 for (k = 0; k < RMAP_EXT; ++k)
3501 if (d->sptes[k])
3502 ++nmaps;
3503 else
3504 break;
3505 d = d->more;
3506 }
3507 }
3508 }
3509 srcu_read_unlock(&kvm->srcu, idx);
3510 return nmaps;
3511}
3512
3513void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep)
3514{
3515 unsigned long *rmapp;
3516 struct kvm_mmu_page *rev_sp;
3517 gfn_t gfn;
3518
3519 if (is_writable_pte(*sptep)) {
3520 rev_sp = page_header(__pa(sptep));
3521 gfn = kvm_mmu_page_get_gfn(rev_sp, sptep - rev_sp->spt);
3522
3523 if (!gfn_to_memslot(kvm, gfn)) {
3524 if (!printk_ratelimit())
3525 return;
3526 printk(KERN_ERR "%s: no memslot for gfn %ld\n",
3527 audit_msg, gfn);
3528 printk(KERN_ERR "%s: index %ld of sp (gfn=%lx)\n",
3529 audit_msg, (long int)(sptep - rev_sp->spt),
3530 rev_sp->gfn);
3531 dump_stack();
3532 return;
3533 }
3534
3535 rmapp = gfn_to_rmap(kvm, gfn, rev_sp->role.level);
3536 if (!*rmapp) {
3537 if (!printk_ratelimit())
3538 return;
3539 printk(KERN_ERR "%s: no rmap for writable spte %llx\n",
3540 audit_msg, *sptep);
3541 dump_stack();
3542 }
3543 }
3544
3545}
3546
3547void audit_writable_sptes_have_rmaps(struct kvm_vcpu *vcpu)
3548{
3549 mmu_spte_walk(vcpu, inspect_spte_has_rmap);
3550}
3551
3552static void check_writable_mappings_rmap(struct kvm_vcpu *vcpu)
3553{
3554 struct kvm_mmu_page *sp;
3555 int i;
3556
3557 list_for_each_entry(sp, &vcpu->kvm->arch.active_mmu_pages, link) {
3558 u64 *pt = sp->spt;
3559
3560 if (sp->role.level != PT_PAGE_TABLE_LEVEL)
3561 continue;
3562
3563 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
3564 u64 ent = pt[i];
3565
3566 if (!(ent & PT_PRESENT_MASK))
3567 continue;
3568 if (!is_writable_pte(ent))
3569 continue;
3570 inspect_spte_has_rmap(vcpu->kvm, &pt[i]);
3571 }
3572 }
3573 return;
3574}
3575
3576static void audit_rmap(struct kvm_vcpu *vcpu)
3577{
3578 check_writable_mappings_rmap(vcpu);
3579 count_rmaps(vcpu);
3580}
3581
3582static void audit_write_protection(struct kvm_vcpu *vcpu)
3583{
3584 struct kvm_mmu_page *sp;
3585 struct kvm_memory_slot *slot;
3586 unsigned long *rmapp;
3587 u64 *spte;
3588 gfn_t gfn;
3589
3590 list_for_each_entry(sp, &vcpu->kvm->arch.active_mmu_pages, link) {
3591 if (sp->role.direct)
3592 continue;
3593 if (sp->unsync)
3594 continue;
3595
3596 slot = gfn_to_memslot(vcpu->kvm, sp->gfn);
3597 rmapp = &slot->rmap[gfn - slot->base_gfn];
3598
3599 spte = rmap_next(vcpu->kvm, rmapp, NULL);
3600 while (spte) {
3601 if (is_writable_pte(*spte))
3602 printk(KERN_ERR "%s: (%s) shadow page has "
3603 "writable mappings: gfn %lx role %x\n",
3604 __func__, audit_msg, sp->gfn,
3605 sp->role.word);
3606 spte = rmap_next(vcpu->kvm, rmapp, spte);
3607 }
3608 }
3609}
3610
3611static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg)
3612{ 3670{
3613 int olddbg = dbg; 3671 ASSERT(vcpu);
3614 3672
3615 dbg = 0; 3673 destroy_kvm_mmu(vcpu);
3616 audit_msg = msg; 3674 free_mmu_pages(vcpu);
3617 audit_rmap(vcpu); 3675 mmu_free_memory_caches(vcpu);
3618 audit_write_protection(vcpu); 3676 mmu_audit_disable();
3619 if (strcmp("pre pte write", audit_msg) != 0)
3620 audit_mappings(vcpu);
3621 audit_writable_sptes_have_rmaps(vcpu);
3622 dbg = olddbg;
3623} 3677}
3624
3625#endif
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index be66759321a5..7086ca85d3e7 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -49,10 +49,17 @@
49#define PFERR_FETCH_MASK (1U << 4) 49#define PFERR_FETCH_MASK (1U << 4)
50 50
51int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4]); 51int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4]);
52int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context);
53
54static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
55{
56 return kvm->arch.n_max_mmu_pages -
57 kvm->arch.n_used_mmu_pages;
58}
52 59
53static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) 60static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
54{ 61{
55 if (unlikely(vcpu->kvm->arch.n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) 62 if (unlikely(kvm_mmu_available_pages(vcpu->kvm)< KVM_MIN_FREE_MMU_PAGES))
56 __kvm_mmu_free_some_pages(vcpu); 63 __kvm_mmu_free_some_pages(vcpu);
57} 64}
58 65
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
new file mode 100644
index 000000000000..ba2bcdde6221
--- /dev/null
+++ b/arch/x86/kvm/mmu_audit.c
@@ -0,0 +1,299 @@
1/*
2 * mmu_audit.c:
3 *
4 * Audit code for KVM MMU
5 *
6 * Copyright (C) 2006 Qumranet, Inc.
7 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
8 *
9 * Authors:
10 * Yaniv Kamay <yaniv@qumranet.com>
11 * Avi Kivity <avi@qumranet.com>
12 * Marcelo Tosatti <mtosatti@redhat.com>
13 * Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
14 *
15 * This work is licensed under the terms of the GNU GPL, version 2. See
16 * the COPYING file in the top-level directory.
17 *
18 */
19
20#include <linux/ratelimit.h>
21
22static int audit_point;
23
24#define audit_printk(fmt, args...) \
25 printk(KERN_ERR "audit: (%s) error: " \
26 fmt, audit_point_name[audit_point], ##args)
27
28typedef void (*inspect_spte_fn) (struct kvm_vcpu *vcpu, u64 *sptep, int level);
29
30static void __mmu_spte_walk(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
31 inspect_spte_fn fn, int level)
32{
33 int i;
34
35 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
36 u64 *ent = sp->spt;
37
38 fn(vcpu, ent + i, level);
39
40 if (is_shadow_present_pte(ent[i]) &&
41 !is_last_spte(ent[i], level)) {
42 struct kvm_mmu_page *child;
43
44 child = page_header(ent[i] & PT64_BASE_ADDR_MASK);
45 __mmu_spte_walk(vcpu, child, fn, level - 1);
46 }
47 }
48}
49
50static void mmu_spte_walk(struct kvm_vcpu *vcpu, inspect_spte_fn fn)
51{
52 int i;
53 struct kvm_mmu_page *sp;
54
55 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
56 return;
57
58 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
59 hpa_t root = vcpu->arch.mmu.root_hpa;
60
61 sp = page_header(root);
62 __mmu_spte_walk(vcpu, sp, fn, PT64_ROOT_LEVEL);
63 return;
64 }
65
66 for (i = 0; i < 4; ++i) {
67 hpa_t root = vcpu->arch.mmu.pae_root[i];
68
69 if (root && VALID_PAGE(root)) {
70 root &= PT64_BASE_ADDR_MASK;
71 sp = page_header(root);
72 __mmu_spte_walk(vcpu, sp, fn, 2);
73 }
74 }
75
76 return;
77}
78
79typedef void (*sp_handler) (struct kvm *kvm, struct kvm_mmu_page *sp);
80
81static void walk_all_active_sps(struct kvm *kvm, sp_handler fn)
82{
83 struct kvm_mmu_page *sp;
84
85 list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link)
86 fn(kvm, sp);
87}
88
89static void audit_mappings(struct kvm_vcpu *vcpu, u64 *sptep, int level)
90{
91 struct kvm_mmu_page *sp;
92 gfn_t gfn;
93 pfn_t pfn;
94 hpa_t hpa;
95
96 sp = page_header(__pa(sptep));
97
98 if (sp->unsync) {
99 if (level != PT_PAGE_TABLE_LEVEL) {
100 audit_printk("unsync sp: %p level = %d\n", sp, level);
101 return;
102 }
103
104 if (*sptep == shadow_notrap_nonpresent_pte) {
105 audit_printk("notrap spte in unsync sp: %p\n", sp);
106 return;
107 }
108 }
109
110 if (sp->role.direct && *sptep == shadow_notrap_nonpresent_pte) {
111 audit_printk("notrap spte in direct sp: %p\n", sp);
112 return;
113 }
114
115 if (!is_shadow_present_pte(*sptep) || !is_last_spte(*sptep, level))
116 return;
117
118 gfn = kvm_mmu_page_get_gfn(sp, sptep - sp->spt);
119 pfn = gfn_to_pfn_atomic(vcpu->kvm, gfn);
120
121 if (is_error_pfn(pfn)) {
122 kvm_release_pfn_clean(pfn);
123 return;
124 }
125
126 hpa = pfn << PAGE_SHIFT;
127 if ((*sptep & PT64_BASE_ADDR_MASK) != hpa)
128 audit_printk("levels %d pfn %llx hpa %llx ent %llxn",
129 vcpu->arch.mmu.root_level, pfn, hpa, *sptep);
130}
131
132static void inspect_spte_has_rmap(struct kvm *kvm, u64 *sptep)
133{
134 unsigned long *rmapp;
135 struct kvm_mmu_page *rev_sp;
136 gfn_t gfn;
137
138
139 rev_sp = page_header(__pa(sptep));
140 gfn = kvm_mmu_page_get_gfn(rev_sp, sptep - rev_sp->spt);
141
142 if (!gfn_to_memslot(kvm, gfn)) {
143 if (!printk_ratelimit())
144 return;
145 audit_printk("no memslot for gfn %llx\n", gfn);
146 audit_printk("index %ld of sp (gfn=%llx)\n",
147 (long int)(sptep - rev_sp->spt), rev_sp->gfn);
148 dump_stack();
149 return;
150 }
151
152 rmapp = gfn_to_rmap(kvm, gfn, rev_sp->role.level);
153 if (!*rmapp) {
154 if (!printk_ratelimit())
155 return;
156 audit_printk("no rmap for writable spte %llx\n", *sptep);
157 dump_stack();
158 }
159}
160
161static void audit_sptes_have_rmaps(struct kvm_vcpu *vcpu, u64 *sptep, int level)
162{
163 if (is_shadow_present_pte(*sptep) && is_last_spte(*sptep, level))
164 inspect_spte_has_rmap(vcpu->kvm, sptep);
165}
166
167static void audit_spte_after_sync(struct kvm_vcpu *vcpu, u64 *sptep, int level)
168{
169 struct kvm_mmu_page *sp = page_header(__pa(sptep));
170
171 if (audit_point == AUDIT_POST_SYNC && sp->unsync)
172 audit_printk("meet unsync sp(%p) after sync root.\n", sp);
173}
174
175static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp)
176{
177 int i;
178
179 if (sp->role.level != PT_PAGE_TABLE_LEVEL)
180 return;
181
182 for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
183 if (!is_rmap_spte(sp->spt[i]))
184 continue;
185
186 inspect_spte_has_rmap(kvm, sp->spt + i);
187 }
188}
189
190static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
191{
192 struct kvm_memory_slot *slot;
193 unsigned long *rmapp;
194 u64 *spte;
195
196 if (sp->role.direct || sp->unsync || sp->role.invalid)
197 return;
198
199 slot = gfn_to_memslot(kvm, sp->gfn);
200 rmapp = &slot->rmap[sp->gfn - slot->base_gfn];
201
202 spte = rmap_next(kvm, rmapp, NULL);
203 while (spte) {
204 if (is_writable_pte(*spte))
205 audit_printk("shadow page has writable mappings: gfn "
206 "%llx role %x\n", sp->gfn, sp->role.word);
207 spte = rmap_next(kvm, rmapp, spte);
208 }
209}
210
211static void audit_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
212{
213 check_mappings_rmap(kvm, sp);
214 audit_write_protection(kvm, sp);
215}
216
217static void audit_all_active_sps(struct kvm *kvm)
218{
219 walk_all_active_sps(kvm, audit_sp);
220}
221
222static void audit_spte(struct kvm_vcpu *vcpu, u64 *sptep, int level)
223{
224 audit_sptes_have_rmaps(vcpu, sptep, level);
225 audit_mappings(vcpu, sptep, level);
226 audit_spte_after_sync(vcpu, sptep, level);
227}
228
229static void audit_vcpu_spte(struct kvm_vcpu *vcpu)
230{
231 mmu_spte_walk(vcpu, audit_spte);
232}
233
234static void kvm_mmu_audit(void *ignore, struct kvm_vcpu *vcpu, int point)
235{
236 static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
237
238 if (!__ratelimit(&ratelimit_state))
239 return;
240
241 audit_point = point;
242 audit_all_active_sps(vcpu->kvm);
243 audit_vcpu_spte(vcpu);
244}
245
246static bool mmu_audit;
247
248static void mmu_audit_enable(void)
249{
250 int ret;
251
252 if (mmu_audit)
253 return;
254
255 ret = register_trace_kvm_mmu_audit(kvm_mmu_audit, NULL);
256 WARN_ON(ret);
257
258 mmu_audit = true;
259}
260
261static void mmu_audit_disable(void)
262{
263 if (!mmu_audit)
264 return;
265
266 unregister_trace_kvm_mmu_audit(kvm_mmu_audit, NULL);
267 tracepoint_synchronize_unregister();
268 mmu_audit = false;
269}
270
271static int mmu_audit_set(const char *val, const struct kernel_param *kp)
272{
273 int ret;
274 unsigned long enable;
275
276 ret = strict_strtoul(val, 10, &enable);
277 if (ret < 0)
278 return -EINVAL;
279
280 switch (enable) {
281 case 0:
282 mmu_audit_disable();
283 break;
284 case 1:
285 mmu_audit_enable();
286 break;
287 default:
288 return -EINVAL;
289 }
290
291 return 0;
292}
293
294static struct kernel_param_ops audit_param_ops = {
295 .set = mmu_audit_set,
296 .get = param_get_bool,
297};
298
299module_param_cb(mmu_audit, &audit_param_ops, &mmu_audit, 0644);
diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86/kvm/mmutrace.h
index 3aab0f0930ef..b60b4fdb3eda 100644
--- a/arch/x86/kvm/mmutrace.h
+++ b/arch/x86/kvm/mmutrace.h
@@ -195,6 +195,25 @@ DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
195 195
196 TP_ARGS(sp) 196 TP_ARGS(sp)
197); 197);
198
199TRACE_EVENT(
200 kvm_mmu_audit,
201 TP_PROTO(struct kvm_vcpu *vcpu, int audit_point),
202 TP_ARGS(vcpu, audit_point),
203
204 TP_STRUCT__entry(
205 __field(struct kvm_vcpu *, vcpu)
206 __field(int, audit_point)
207 ),
208
209 TP_fast_assign(
210 __entry->vcpu = vcpu;
211 __entry->audit_point = audit_point;
212 ),
213
214 TP_printk("vcpu:%d %s", __entry->vcpu->cpu,
215 audit_point_name[__entry->audit_point])
216);
198#endif /* _TRACE_KVMMMU_H */ 217#endif /* _TRACE_KVMMMU_H */
199 218
200#undef TRACE_INCLUDE_PATH 219#undef TRACE_INCLUDE_PATH
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 51ef9097960d..cd7a833a3b52 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -7,7 +7,7 @@
7 * MMU support 7 * MMU support
8 * 8 *
9 * Copyright (C) 2006 Qumranet, Inc. 9 * Copyright (C) 2006 Qumranet, Inc.
10 * Copyright 2010 Red Hat, Inc. and/or its affilates. 10 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
11 * 11 *
12 * Authors: 12 * Authors:
13 * Yaniv Kamay <yaniv@qumranet.com> 13 * Yaniv Kamay <yaniv@qumranet.com>
@@ -67,6 +67,7 @@ struct guest_walker {
67 int level; 67 int level;
68 gfn_t table_gfn[PT_MAX_FULL_LEVELS]; 68 gfn_t table_gfn[PT_MAX_FULL_LEVELS];
69 pt_element_t ptes[PT_MAX_FULL_LEVELS]; 69 pt_element_t ptes[PT_MAX_FULL_LEVELS];
70 pt_element_t prefetch_ptes[PTE_PREFETCH_NUM];
70 gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; 71 gpa_t pte_gpa[PT_MAX_FULL_LEVELS];
71 unsigned pt_access; 72 unsigned pt_access;
72 unsigned pte_access; 73 unsigned pte_access;
@@ -104,7 +105,7 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte)
104 105
105 access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK; 106 access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK;
106#if PTTYPE == 64 107#if PTTYPE == 64
107 if (is_nx(vcpu)) 108 if (vcpu->arch.mmu.nx)
108 access &= ~(gpte >> PT64_NX_SHIFT); 109 access &= ~(gpte >> PT64_NX_SHIFT);
109#endif 110#endif
110 return access; 111 return access;
@@ -113,26 +114,32 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte)
113/* 114/*
114 * Fetch a guest pte for a guest virtual address 115 * Fetch a guest pte for a guest virtual address
115 */ 116 */
116static int FNAME(walk_addr)(struct guest_walker *walker, 117static int FNAME(walk_addr_generic)(struct guest_walker *walker,
117 struct kvm_vcpu *vcpu, gva_t addr, 118 struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
118 int write_fault, int user_fault, int fetch_fault) 119 gva_t addr, u32 access)
119{ 120{
120 pt_element_t pte; 121 pt_element_t pte;
121 gfn_t table_gfn; 122 gfn_t table_gfn;
122 unsigned index, pt_access, uninitialized_var(pte_access); 123 unsigned index, pt_access, uninitialized_var(pte_access);
123 gpa_t pte_gpa; 124 gpa_t pte_gpa;
124 bool eperm, present, rsvd_fault; 125 bool eperm, present, rsvd_fault;
126 int offset, write_fault, user_fault, fetch_fault;
127
128 write_fault = access & PFERR_WRITE_MASK;
129 user_fault = access & PFERR_USER_MASK;
130 fetch_fault = access & PFERR_FETCH_MASK;
125 131
126 trace_kvm_mmu_pagetable_walk(addr, write_fault, user_fault, 132 trace_kvm_mmu_pagetable_walk(addr, write_fault, user_fault,
127 fetch_fault); 133 fetch_fault);
128walk: 134walk:
129 present = true; 135 present = true;
130 eperm = rsvd_fault = false; 136 eperm = rsvd_fault = false;
131 walker->level = vcpu->arch.mmu.root_level; 137 walker->level = mmu->root_level;
132 pte = vcpu->arch.cr3; 138 pte = mmu->get_cr3(vcpu);
139
133#if PTTYPE == 64 140#if PTTYPE == 64
134 if (!is_long_mode(vcpu)) { 141 if (walker->level == PT32E_ROOT_LEVEL) {
135 pte = kvm_pdptr_read(vcpu, (addr >> 30) & 3); 142 pte = kvm_pdptr_read_mmu(vcpu, mmu, (addr >> 30) & 3);
136 trace_kvm_mmu_paging_element(pte, walker->level); 143 trace_kvm_mmu_paging_element(pte, walker->level);
137 if (!is_present_gpte(pte)) { 144 if (!is_present_gpte(pte)) {
138 present = false; 145 present = false;
@@ -142,7 +149,7 @@ walk:
142 } 149 }
143#endif 150#endif
144 ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) || 151 ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) ||
145 (vcpu->arch.cr3 & CR3_NONPAE_RESERVED_BITS) == 0); 152 (mmu->get_cr3(vcpu) & CR3_NONPAE_RESERVED_BITS) == 0);
146 153
147 pt_access = ACC_ALL; 154 pt_access = ACC_ALL;
148 155
@@ -150,12 +157,14 @@ walk:
150 index = PT_INDEX(addr, walker->level); 157 index = PT_INDEX(addr, walker->level);
151 158
152 table_gfn = gpte_to_gfn(pte); 159 table_gfn = gpte_to_gfn(pte);
153 pte_gpa = gfn_to_gpa(table_gfn); 160 offset = index * sizeof(pt_element_t);
154 pte_gpa += index * sizeof(pt_element_t); 161 pte_gpa = gfn_to_gpa(table_gfn) + offset;
155 walker->table_gfn[walker->level - 1] = table_gfn; 162 walker->table_gfn[walker->level - 1] = table_gfn;
156 walker->pte_gpa[walker->level - 1] = pte_gpa; 163 walker->pte_gpa[walker->level - 1] = pte_gpa;
157 164
158 if (kvm_read_guest(vcpu->kvm, pte_gpa, &pte, sizeof(pte))) { 165 if (kvm_read_guest_page_mmu(vcpu, mmu, table_gfn, &pte,
166 offset, sizeof(pte),
167 PFERR_USER_MASK|PFERR_WRITE_MASK)) {
159 present = false; 168 present = false;
160 break; 169 break;
161 } 170 }
@@ -167,7 +176,7 @@ walk:
167 break; 176 break;
168 } 177 }
169 178
170 if (is_rsvd_bits_set(vcpu, pte, walker->level)) { 179 if (is_rsvd_bits_set(&vcpu->arch.mmu, pte, walker->level)) {
171 rsvd_fault = true; 180 rsvd_fault = true;
172 break; 181 break;
173 } 182 }
@@ -204,17 +213,28 @@ walk:
204 (PTTYPE == 64 || is_pse(vcpu))) || 213 (PTTYPE == 64 || is_pse(vcpu))) ||
205 ((walker->level == PT_PDPE_LEVEL) && 214 ((walker->level == PT_PDPE_LEVEL) &&
206 is_large_pte(pte) && 215 is_large_pte(pte) &&
207 is_long_mode(vcpu))) { 216 mmu->root_level == PT64_ROOT_LEVEL)) {
208 int lvl = walker->level; 217 int lvl = walker->level;
218 gpa_t real_gpa;
219 gfn_t gfn;
220 u32 ac;
209 221
210 walker->gfn = gpte_to_gfn_lvl(pte, lvl); 222 gfn = gpte_to_gfn_lvl(pte, lvl);
211 walker->gfn += (addr & PT_LVL_OFFSET_MASK(lvl)) 223 gfn += (addr & PT_LVL_OFFSET_MASK(lvl)) >> PAGE_SHIFT;
212 >> PAGE_SHIFT;
213 224
214 if (PTTYPE == 32 && 225 if (PTTYPE == 32 &&
215 walker->level == PT_DIRECTORY_LEVEL && 226 walker->level == PT_DIRECTORY_LEVEL &&
216 is_cpuid_PSE36()) 227 is_cpuid_PSE36())
217 walker->gfn += pse36_gfn_delta(pte); 228 gfn += pse36_gfn_delta(pte);
229
230 ac = write_fault | fetch_fault | user_fault;
231
232 real_gpa = mmu->translate_gpa(vcpu, gfn_to_gpa(gfn),
233 ac);
234 if (real_gpa == UNMAPPED_GVA)
235 return 0;
236
237 walker->gfn = real_gpa >> PAGE_SHIFT;
218 238
219 break; 239 break;
220 } 240 }
@@ -249,18 +269,36 @@ error:
249 walker->error_code = 0; 269 walker->error_code = 0;
250 if (present) 270 if (present)
251 walker->error_code |= PFERR_PRESENT_MASK; 271 walker->error_code |= PFERR_PRESENT_MASK;
252 if (write_fault) 272
253 walker->error_code |= PFERR_WRITE_MASK; 273 walker->error_code |= write_fault | user_fault;
254 if (user_fault) 274
255 walker->error_code |= PFERR_USER_MASK; 275 if (fetch_fault && mmu->nx)
256 if (fetch_fault && is_nx(vcpu))
257 walker->error_code |= PFERR_FETCH_MASK; 276 walker->error_code |= PFERR_FETCH_MASK;
258 if (rsvd_fault) 277 if (rsvd_fault)
259 walker->error_code |= PFERR_RSVD_MASK; 278 walker->error_code |= PFERR_RSVD_MASK;
279
280 vcpu->arch.fault.address = addr;
281 vcpu->arch.fault.error_code = walker->error_code;
282
260 trace_kvm_mmu_walker_error(walker->error_code); 283 trace_kvm_mmu_walker_error(walker->error_code);
261 return 0; 284 return 0;
262} 285}
263 286
287static int FNAME(walk_addr)(struct guest_walker *walker,
288 struct kvm_vcpu *vcpu, gva_t addr, u32 access)
289{
290 return FNAME(walk_addr_generic)(walker, vcpu, &vcpu->arch.mmu, addr,
291 access);
292}
293
294static int FNAME(walk_addr_nested)(struct guest_walker *walker,
295 struct kvm_vcpu *vcpu, gva_t addr,
296 u32 access)
297{
298 return FNAME(walk_addr_generic)(walker, vcpu, &vcpu->arch.nested_mmu,
299 addr, access);
300}
301
264static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, 302static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
265 u64 *spte, const void *pte) 303 u64 *spte, const void *pte)
266{ 304{
@@ -302,14 +340,87 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
302static bool FNAME(gpte_changed)(struct kvm_vcpu *vcpu, 340static bool FNAME(gpte_changed)(struct kvm_vcpu *vcpu,
303 struct guest_walker *gw, int level) 341 struct guest_walker *gw, int level)
304{ 342{
305 int r;
306 pt_element_t curr_pte; 343 pt_element_t curr_pte;
307 344 gpa_t base_gpa, pte_gpa = gw->pte_gpa[level - 1];
308 r = kvm_read_guest_atomic(vcpu->kvm, gw->pte_gpa[level - 1], 345 u64 mask;
346 int r, index;
347
348 if (level == PT_PAGE_TABLE_LEVEL) {
349 mask = PTE_PREFETCH_NUM * sizeof(pt_element_t) - 1;
350 base_gpa = pte_gpa & ~mask;
351 index = (pte_gpa - base_gpa) / sizeof(pt_element_t);
352
353 r = kvm_read_guest_atomic(vcpu->kvm, base_gpa,
354 gw->prefetch_ptes, sizeof(gw->prefetch_ptes));
355 curr_pte = gw->prefetch_ptes[index];
356 } else
357 r = kvm_read_guest_atomic(vcpu->kvm, pte_gpa,
309 &curr_pte, sizeof(curr_pte)); 358 &curr_pte, sizeof(curr_pte));
359
310 return r || curr_pte != gw->ptes[level - 1]; 360 return r || curr_pte != gw->ptes[level - 1];
311} 361}
312 362
363static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw,
364 u64 *sptep)
365{
366 struct kvm_mmu_page *sp;
367 struct kvm_mmu *mmu = &vcpu->arch.mmu;
368 pt_element_t *gptep = gw->prefetch_ptes;
369 u64 *spte;
370 int i;
371
372 sp = page_header(__pa(sptep));
373
374 if (sp->role.level > PT_PAGE_TABLE_LEVEL)
375 return;
376
377 if (sp->role.direct)
378 return __direct_pte_prefetch(vcpu, sp, sptep);
379
380 i = (sptep - sp->spt) & ~(PTE_PREFETCH_NUM - 1);
381 spte = sp->spt + i;
382
383 for (i = 0; i < PTE_PREFETCH_NUM; i++, spte++) {
384 pt_element_t gpte;
385 unsigned pte_access;
386 gfn_t gfn;
387 pfn_t pfn;
388 bool dirty;
389
390 if (spte == sptep)
391 continue;
392
393 if (*spte != shadow_trap_nonpresent_pte)
394 continue;
395
396 gpte = gptep[i];
397
398 if (!is_present_gpte(gpte) ||
399 is_rsvd_bits_set(mmu, gpte, PT_PAGE_TABLE_LEVEL)) {
400 if (!sp->unsync)
401 __set_spte(spte, shadow_notrap_nonpresent_pte);
402 continue;
403 }
404
405 if (!(gpte & PT_ACCESSED_MASK))
406 continue;
407
408 pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte);
409 gfn = gpte_to_gfn(gpte);
410 dirty = is_dirty_gpte(gpte);
411 pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn,
412 (pte_access & ACC_WRITE_MASK) && dirty);
413 if (is_error_pfn(pfn)) {
414 kvm_release_pfn_clean(pfn);
415 break;
416 }
417
418 mmu_set_spte(vcpu, spte, sp->role.access, pte_access, 0, 0,
419 dirty, NULL, PT_PAGE_TABLE_LEVEL, gfn,
420 pfn, true, true);
421 }
422}
423
313/* 424/*
314 * Fetch a shadow pte for a specific level in the paging hierarchy. 425 * Fetch a shadow pte for a specific level in the paging hierarchy.
315 */ 426 */
@@ -391,6 +502,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
391 mmu_set_spte(vcpu, it.sptep, access, gw->pte_access & access, 502 mmu_set_spte(vcpu, it.sptep, access, gw->pte_access & access,
392 user_fault, write_fault, dirty, ptwrite, it.level, 503 user_fault, write_fault, dirty, ptwrite, it.level,
393 gw->gfn, pfn, false, true); 504 gw->gfn, pfn, false, true);
505 FNAME(pte_prefetch)(vcpu, gw, it.sptep);
394 506
395 return it.sptep; 507 return it.sptep;
396 508
@@ -420,7 +532,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
420{ 532{
421 int write_fault = error_code & PFERR_WRITE_MASK; 533 int write_fault = error_code & PFERR_WRITE_MASK;
422 int user_fault = error_code & PFERR_USER_MASK; 534 int user_fault = error_code & PFERR_USER_MASK;
423 int fetch_fault = error_code & PFERR_FETCH_MASK;
424 struct guest_walker walker; 535 struct guest_walker walker;
425 u64 *sptep; 536 u64 *sptep;
426 int write_pt = 0; 537 int write_pt = 0;
@@ -430,7 +541,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
430 unsigned long mmu_seq; 541 unsigned long mmu_seq;
431 542
432 pgprintk("%s: addr %lx err %x\n", __func__, addr, error_code); 543 pgprintk("%s: addr %lx err %x\n", __func__, addr, error_code);
433 kvm_mmu_audit(vcpu, "pre page fault");
434 544
435 r = mmu_topup_memory_caches(vcpu); 545 r = mmu_topup_memory_caches(vcpu);
436 if (r) 546 if (r)
@@ -439,15 +549,14 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
439 /* 549 /*
440 * Look up the guest pte for the faulting address. 550 * Look up the guest pte for the faulting address.
441 */ 551 */
442 r = FNAME(walk_addr)(&walker, vcpu, addr, write_fault, user_fault, 552 r = FNAME(walk_addr)(&walker, vcpu, addr, error_code);
443 fetch_fault);
444 553
445 /* 554 /*
446 * The page is not mapped by the guest. Let the guest handle it. 555 * The page is not mapped by the guest. Let the guest handle it.
447 */ 556 */
448 if (!r) { 557 if (!r) {
449 pgprintk("%s: guest page fault\n", __func__); 558 pgprintk("%s: guest page fault\n", __func__);
450 inject_page_fault(vcpu, addr, walker.error_code); 559 inject_page_fault(vcpu);
451 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */ 560 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */
452 return 0; 561 return 0;
453 } 562 }
@@ -468,6 +577,8 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
468 spin_lock(&vcpu->kvm->mmu_lock); 577 spin_lock(&vcpu->kvm->mmu_lock);
469 if (mmu_notifier_retry(vcpu, mmu_seq)) 578 if (mmu_notifier_retry(vcpu, mmu_seq))
470 goto out_unlock; 579 goto out_unlock;
580
581 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT);
471 kvm_mmu_free_some_pages(vcpu); 582 kvm_mmu_free_some_pages(vcpu);
472 sptep = FNAME(fetch)(vcpu, addr, &walker, user_fault, write_fault, 583 sptep = FNAME(fetch)(vcpu, addr, &walker, user_fault, write_fault,
473 level, &write_pt, pfn); 584 level, &write_pt, pfn);
@@ -479,7 +590,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr,
479 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */ 590 vcpu->arch.last_pt_write_count = 0; /* reset fork detector */
480 591
481 ++vcpu->stat.pf_fixed; 592 ++vcpu->stat.pf_fixed;
482 kvm_mmu_audit(vcpu, "post page fault (fixed)"); 593 trace_kvm_mmu_audit(vcpu, AUDIT_POST_PAGE_FAULT);
483 spin_unlock(&vcpu->kvm->mmu_lock); 594 spin_unlock(&vcpu->kvm->mmu_lock);
484 595
485 return write_pt; 596 return write_pt;
@@ -556,10 +667,25 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access,
556 gpa_t gpa = UNMAPPED_GVA; 667 gpa_t gpa = UNMAPPED_GVA;
557 int r; 668 int r;
558 669
559 r = FNAME(walk_addr)(&walker, vcpu, vaddr, 670 r = FNAME(walk_addr)(&walker, vcpu, vaddr, access);
560 !!(access & PFERR_WRITE_MASK), 671
561 !!(access & PFERR_USER_MASK), 672 if (r) {
562 !!(access & PFERR_FETCH_MASK)); 673 gpa = gfn_to_gpa(walker.gfn);
674 gpa |= vaddr & ~PAGE_MASK;
675 } else if (error)
676 *error = walker.error_code;
677
678 return gpa;
679}
680
681static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr,
682 u32 access, u32 *error)
683{
684 struct guest_walker walker;
685 gpa_t gpa = UNMAPPED_GVA;
686 int r;
687
688 r = FNAME(walk_addr_nested)(&walker, vcpu, vaddr, access);
563 689
564 if (r) { 690 if (r) {
565 gpa = gfn_to_gpa(walker.gfn); 691 gpa = gfn_to_gpa(walker.gfn);
@@ -638,7 +764,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
638 return -EINVAL; 764 return -EINVAL;
639 765
640 gfn = gpte_to_gfn(gpte); 766 gfn = gpte_to_gfn(gpte);
641 if (is_rsvd_bits_set(vcpu, gpte, PT_PAGE_TABLE_LEVEL) 767 if (is_rsvd_bits_set(&vcpu->arch.mmu, gpte, PT_PAGE_TABLE_LEVEL)
642 || gfn != sp->gfns[i] || !is_present_gpte(gpte) 768 || gfn != sp->gfns[i] || !is_present_gpte(gpte)
643 || !(gpte & PT_ACCESSED_MASK)) { 769 || !(gpte & PT_ACCESSED_MASK)) {
644 u64 nonpresent; 770 u64 nonpresent;
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index bc5b9b8d4a33..82e144a4e514 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -4,7 +4,7 @@
4 * AMD SVM support 4 * AMD SVM support
5 * 5 *
6 * Copyright (C) 2006 Qumranet, Inc. 6 * Copyright (C) 2006 Qumranet, Inc.
7 * Copyright 2010 Red Hat, Inc. and/or its affilates. 7 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
8 * 8 *
9 * Authors: 9 * Authors:
10 * Yaniv Kamay <yaniv@qumranet.com> 10 * Yaniv Kamay <yaniv@qumranet.com>
@@ -88,6 +88,14 @@ struct nested_state {
88 /* A VMEXIT is required but not yet emulated */ 88 /* A VMEXIT is required but not yet emulated */
89 bool exit_required; 89 bool exit_required;
90 90
91 /*
92 * If we vmexit during an instruction emulation we need this to restore
93 * the l1 guest rip after the emulation
94 */
95 unsigned long vmexit_rip;
96 unsigned long vmexit_rsp;
97 unsigned long vmexit_rax;
98
91 /* cache for intercepts of the guest */ 99 /* cache for intercepts of the guest */
92 u16 intercept_cr_read; 100 u16 intercept_cr_read;
93 u16 intercept_cr_write; 101 u16 intercept_cr_write;
@@ -96,6 +104,8 @@ struct nested_state {
96 u32 intercept_exceptions; 104 u32 intercept_exceptions;
97 u64 intercept; 105 u64 intercept;
98 106
107 /* Nested Paging related state */
108 u64 nested_cr3;
99}; 109};
100 110
101#define MSRPM_OFFSETS 16 111#define MSRPM_OFFSETS 16
@@ -284,6 +294,15 @@ static inline void flush_guest_tlb(struct kvm_vcpu *vcpu)
284 force_new_asid(vcpu); 294 force_new_asid(vcpu);
285} 295}
286 296
297static int get_npt_level(void)
298{
299#ifdef CONFIG_X86_64
300 return PT64_ROOT_LEVEL;
301#else
302 return PT32E_ROOT_LEVEL;
303#endif
304}
305
287static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer) 306static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer)
288{ 307{
289 vcpu->arch.efer = efer; 308 vcpu->arch.efer = efer;
@@ -701,6 +720,29 @@ static void init_sys_seg(struct vmcb_seg *seg, uint32_t type)
701 seg->base = 0; 720 seg->base = 0;
702} 721}
703 722
723static void svm_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
724{
725 struct vcpu_svm *svm = to_svm(vcpu);
726 u64 g_tsc_offset = 0;
727
728 if (is_nested(svm)) {
729 g_tsc_offset = svm->vmcb->control.tsc_offset -
730 svm->nested.hsave->control.tsc_offset;
731 svm->nested.hsave->control.tsc_offset = offset;
732 }
733
734 svm->vmcb->control.tsc_offset = offset + g_tsc_offset;
735}
736
737static void svm_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment)
738{
739 struct vcpu_svm *svm = to_svm(vcpu);
740
741 svm->vmcb->control.tsc_offset += adjustment;
742 if (is_nested(svm))
743 svm->nested.hsave->control.tsc_offset += adjustment;
744}
745
704static void init_vmcb(struct vcpu_svm *svm) 746static void init_vmcb(struct vcpu_svm *svm)
705{ 747{
706 struct vmcb_control_area *control = &svm->vmcb->control; 748 struct vmcb_control_area *control = &svm->vmcb->control;
@@ -766,7 +808,6 @@ static void init_vmcb(struct vcpu_svm *svm)
766 808
767 control->iopm_base_pa = iopm_base; 809 control->iopm_base_pa = iopm_base;
768 control->msrpm_base_pa = __pa(svm->msrpm); 810 control->msrpm_base_pa = __pa(svm->msrpm);
769 control->tsc_offset = 0;
770 control->int_ctl = V_INTR_MASKING_MASK; 811 control->int_ctl = V_INTR_MASKING_MASK;
771 812
772 init_seg(&save->es); 813 init_seg(&save->es);
@@ -794,7 +835,7 @@ static void init_vmcb(struct vcpu_svm *svm)
794 init_sys_seg(&save->ldtr, SEG_TYPE_LDT); 835 init_sys_seg(&save->ldtr, SEG_TYPE_LDT);
795 init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); 836 init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16);
796 837
797 save->efer = EFER_SVME; 838 svm_set_efer(&svm->vcpu, 0);
798 save->dr6 = 0xffff0ff0; 839 save->dr6 = 0xffff0ff0;
799 save->dr7 = 0x400; 840 save->dr7 = 0x400;
800 save->rflags = 2; 841 save->rflags = 2;
@@ -805,8 +846,8 @@ static void init_vmcb(struct vcpu_svm *svm)
805 * This is the guest-visible cr0 value. 846 * This is the guest-visible cr0 value.
806 * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0. 847 * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0.
807 */ 848 */
808 svm->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; 849 svm->vcpu.arch.cr0 = 0;
809 (void)kvm_set_cr0(&svm->vcpu, svm->vcpu.arch.cr0); 850 (void)kvm_set_cr0(&svm->vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET);
810 851
811 save->cr4 = X86_CR4_PAE; 852 save->cr4 = X86_CR4_PAE;
812 /* rdx = ?? */ 853 /* rdx = ?? */
@@ -902,6 +943,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
902 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; 943 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT;
903 svm->asid_generation = 0; 944 svm->asid_generation = 0;
904 init_vmcb(svm); 945 init_vmcb(svm);
946 kvm_write_tsc(&svm->vcpu, 0);
905 947
906 err = fx_init(&svm->vcpu); 948 err = fx_init(&svm->vcpu);
907 if (err) 949 if (err)
@@ -947,20 +989,6 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
947 int i; 989 int i;
948 990
949 if (unlikely(cpu != vcpu->cpu)) { 991 if (unlikely(cpu != vcpu->cpu)) {
950 u64 delta;
951
952 if (check_tsc_unstable()) {
953 /*
954 * Make sure that the guest sees a monotonically
955 * increasing TSC.
956 */
957 delta = vcpu->arch.host_tsc - native_read_tsc();
958 svm->vmcb->control.tsc_offset += delta;
959 if (is_nested(svm))
960 svm->nested.hsave->control.tsc_offset += delta;
961 }
962 vcpu->cpu = cpu;
963 kvm_migrate_timers(vcpu);
964 svm->asid_generation = 0; 992 svm->asid_generation = 0;
965 } 993 }
966 994
@@ -976,8 +1004,6 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
976 ++vcpu->stat.host_state_reload; 1004 ++vcpu->stat.host_state_reload;
977 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++) 1005 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
978 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); 1006 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]);
979
980 vcpu->arch.host_tsc = native_read_tsc();
981} 1007}
982 1008
983static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu) 1009static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu)
@@ -995,7 +1021,7 @@ static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
995 switch (reg) { 1021 switch (reg) {
996 case VCPU_EXREG_PDPTR: 1022 case VCPU_EXREG_PDPTR:
997 BUG_ON(!npt_enabled); 1023 BUG_ON(!npt_enabled);
998 load_pdptrs(vcpu, vcpu->arch.cr3); 1024 load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3);
999 break; 1025 break;
1000 default: 1026 default:
1001 BUG(); 1027 BUG();
@@ -1206,8 +1232,12 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
1206 if (old == new) { 1232 if (old == new) {
1207 /* cr0 write with ts and mp unchanged */ 1233 /* cr0 write with ts and mp unchanged */
1208 svm->vmcb->control.exit_code = SVM_EXIT_CR0_SEL_WRITE; 1234 svm->vmcb->control.exit_code = SVM_EXIT_CR0_SEL_WRITE;
1209 if (nested_svm_exit_handled(svm) == NESTED_EXIT_DONE) 1235 if (nested_svm_exit_handled(svm) == NESTED_EXIT_DONE) {
1236 svm->nested.vmexit_rip = kvm_rip_read(vcpu);
1237 svm->nested.vmexit_rsp = kvm_register_read(vcpu, VCPU_REGS_RSP);
1238 svm->nested.vmexit_rax = kvm_register_read(vcpu, VCPU_REGS_RAX);
1210 return; 1239 return;
1240 }
1211 } 1241 }
1212 } 1242 }
1213 1243
@@ -1581,6 +1611,54 @@ static int vmmcall_interception(struct vcpu_svm *svm)
1581 return 1; 1611 return 1;
1582} 1612}
1583 1613
1614static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
1615{
1616 struct vcpu_svm *svm = to_svm(vcpu);
1617
1618 return svm->nested.nested_cr3;
1619}
1620
1621static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu,
1622 unsigned long root)
1623{
1624 struct vcpu_svm *svm = to_svm(vcpu);
1625
1626 svm->vmcb->control.nested_cr3 = root;
1627 force_new_asid(vcpu);
1628}
1629
1630static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu)
1631{
1632 struct vcpu_svm *svm = to_svm(vcpu);
1633
1634 svm->vmcb->control.exit_code = SVM_EXIT_NPF;
1635 svm->vmcb->control.exit_code_hi = 0;
1636 svm->vmcb->control.exit_info_1 = vcpu->arch.fault.error_code;
1637 svm->vmcb->control.exit_info_2 = vcpu->arch.fault.address;
1638
1639 nested_svm_vmexit(svm);
1640}
1641
1642static int nested_svm_init_mmu_context(struct kvm_vcpu *vcpu)
1643{
1644 int r;
1645
1646 r = kvm_init_shadow_mmu(vcpu, &vcpu->arch.mmu);
1647
1648 vcpu->arch.mmu.set_cr3 = nested_svm_set_tdp_cr3;
1649 vcpu->arch.mmu.get_cr3 = nested_svm_get_tdp_cr3;
1650 vcpu->arch.mmu.inject_page_fault = nested_svm_inject_npf_exit;
1651 vcpu->arch.mmu.shadow_root_level = get_npt_level();
1652 vcpu->arch.walk_mmu = &vcpu->arch.nested_mmu;
1653
1654 return r;
1655}
1656
1657static void nested_svm_uninit_mmu_context(struct kvm_vcpu *vcpu)
1658{
1659 vcpu->arch.walk_mmu = &vcpu->arch.mmu;
1660}
1661
1584static int nested_svm_check_permissions(struct vcpu_svm *svm) 1662static int nested_svm_check_permissions(struct vcpu_svm *svm)
1585{ 1663{
1586 if (!(svm->vcpu.arch.efer & EFER_SVME) 1664 if (!(svm->vcpu.arch.efer & EFER_SVME)
@@ -1629,6 +1707,14 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm)
1629 if (!(svm->vcpu.arch.hflags & HF_HIF_MASK)) 1707 if (!(svm->vcpu.arch.hflags & HF_HIF_MASK))
1630 return false; 1708 return false;
1631 1709
1710 /*
1711 * if vmexit was already requested (by intercepted exception
1712 * for instance) do not overwrite it with "external interrupt"
1713 * vmexit.
1714 */
1715 if (svm->nested.exit_required)
1716 return false;
1717
1632 svm->vmcb->control.exit_code = SVM_EXIT_INTR; 1718 svm->vmcb->control.exit_code = SVM_EXIT_INTR;
1633 svm->vmcb->control.exit_info_1 = 0; 1719 svm->vmcb->control.exit_info_1 = 0;
1634 svm->vmcb->control.exit_info_2 = 0; 1720 svm->vmcb->control.exit_info_2 = 0;
@@ -1896,6 +1982,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1896 nested_vmcb->save.ds = vmcb->save.ds; 1982 nested_vmcb->save.ds = vmcb->save.ds;
1897 nested_vmcb->save.gdtr = vmcb->save.gdtr; 1983 nested_vmcb->save.gdtr = vmcb->save.gdtr;
1898 nested_vmcb->save.idtr = vmcb->save.idtr; 1984 nested_vmcb->save.idtr = vmcb->save.idtr;
1985 nested_vmcb->save.efer = svm->vcpu.arch.efer;
1899 nested_vmcb->save.cr0 = kvm_read_cr0(&svm->vcpu); 1986 nested_vmcb->save.cr0 = kvm_read_cr0(&svm->vcpu);
1900 nested_vmcb->save.cr3 = svm->vcpu.arch.cr3; 1987 nested_vmcb->save.cr3 = svm->vcpu.arch.cr3;
1901 nested_vmcb->save.cr2 = vmcb->save.cr2; 1988 nested_vmcb->save.cr2 = vmcb->save.cr2;
@@ -1917,6 +2004,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1917 nested_vmcb->control.exit_info_2 = vmcb->control.exit_info_2; 2004 nested_vmcb->control.exit_info_2 = vmcb->control.exit_info_2;
1918 nested_vmcb->control.exit_int_info = vmcb->control.exit_int_info; 2005 nested_vmcb->control.exit_int_info = vmcb->control.exit_int_info;
1919 nested_vmcb->control.exit_int_info_err = vmcb->control.exit_int_info_err; 2006 nested_vmcb->control.exit_int_info_err = vmcb->control.exit_int_info_err;
2007 nested_vmcb->control.next_rip = vmcb->control.next_rip;
1920 2008
1921 /* 2009 /*
1922 * If we emulate a VMRUN/#VMEXIT in the same host #vmexit cycle we have 2010 * If we emulate a VMRUN/#VMEXIT in the same host #vmexit cycle we have
@@ -1947,6 +2035,8 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1947 kvm_clear_exception_queue(&svm->vcpu); 2035 kvm_clear_exception_queue(&svm->vcpu);
1948 kvm_clear_interrupt_queue(&svm->vcpu); 2036 kvm_clear_interrupt_queue(&svm->vcpu);
1949 2037
2038 svm->nested.nested_cr3 = 0;
2039
1950 /* Restore selected save entries */ 2040 /* Restore selected save entries */
1951 svm->vmcb->save.es = hsave->save.es; 2041 svm->vmcb->save.es = hsave->save.es;
1952 svm->vmcb->save.cs = hsave->save.cs; 2042 svm->vmcb->save.cs = hsave->save.cs;
@@ -1973,6 +2063,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1973 2063
1974 nested_svm_unmap(page); 2064 nested_svm_unmap(page);
1975 2065
2066 nested_svm_uninit_mmu_context(&svm->vcpu);
1976 kvm_mmu_reset_context(&svm->vcpu); 2067 kvm_mmu_reset_context(&svm->vcpu);
1977 kvm_mmu_load(&svm->vcpu); 2068 kvm_mmu_load(&svm->vcpu);
1978 2069
@@ -2012,6 +2103,20 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
2012 return true; 2103 return true;
2013} 2104}
2014 2105
2106static bool nested_vmcb_checks(struct vmcb *vmcb)
2107{
2108 if ((vmcb->control.intercept & (1ULL << INTERCEPT_VMRUN)) == 0)
2109 return false;
2110
2111 if (vmcb->control.asid == 0)
2112 return false;
2113
2114 if (vmcb->control.nested_ctl && !npt_enabled)
2115 return false;
2116
2117 return true;
2118}
2119
2015static bool nested_svm_vmrun(struct vcpu_svm *svm) 2120static bool nested_svm_vmrun(struct vcpu_svm *svm)
2016{ 2121{
2017 struct vmcb *nested_vmcb; 2122 struct vmcb *nested_vmcb;
@@ -2026,7 +2131,18 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
2026 if (!nested_vmcb) 2131 if (!nested_vmcb)
2027 return false; 2132 return false;
2028 2133
2029 trace_kvm_nested_vmrun(svm->vmcb->save.rip - 3, vmcb_gpa, 2134 if (!nested_vmcb_checks(nested_vmcb)) {
2135 nested_vmcb->control.exit_code = SVM_EXIT_ERR;
2136 nested_vmcb->control.exit_code_hi = 0;
2137 nested_vmcb->control.exit_info_1 = 0;
2138 nested_vmcb->control.exit_info_2 = 0;
2139
2140 nested_svm_unmap(page);
2141
2142 return false;
2143 }
2144
2145 trace_kvm_nested_vmrun(svm->vmcb->save.rip, vmcb_gpa,
2030 nested_vmcb->save.rip, 2146 nested_vmcb->save.rip,
2031 nested_vmcb->control.int_ctl, 2147 nested_vmcb->control.int_ctl,
2032 nested_vmcb->control.event_inj, 2148 nested_vmcb->control.event_inj,
@@ -2055,7 +2171,7 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
2055 hsave->save.cr0 = kvm_read_cr0(&svm->vcpu); 2171 hsave->save.cr0 = kvm_read_cr0(&svm->vcpu);
2056 hsave->save.cr4 = svm->vcpu.arch.cr4; 2172 hsave->save.cr4 = svm->vcpu.arch.cr4;
2057 hsave->save.rflags = vmcb->save.rflags; 2173 hsave->save.rflags = vmcb->save.rflags;
2058 hsave->save.rip = svm->next_rip; 2174 hsave->save.rip = kvm_rip_read(&svm->vcpu);
2059 hsave->save.rsp = vmcb->save.rsp; 2175 hsave->save.rsp = vmcb->save.rsp;
2060 hsave->save.rax = vmcb->save.rax; 2176 hsave->save.rax = vmcb->save.rax;
2061 if (npt_enabled) 2177 if (npt_enabled)
@@ -2070,6 +2186,12 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm)
2070 else 2186 else
2071 svm->vcpu.arch.hflags &= ~HF_HIF_MASK; 2187 svm->vcpu.arch.hflags &= ~HF_HIF_MASK;
2072 2188
2189 if (nested_vmcb->control.nested_ctl) {
2190 kvm_mmu_unload(&svm->vcpu);
2191 svm->nested.nested_cr3 = nested_vmcb->control.nested_cr3;
2192 nested_svm_init_mmu_context(&svm->vcpu);
2193 }
2194
2073 /* Load the nested guest state */ 2195 /* Load the nested guest state */
2074 svm->vmcb->save.es = nested_vmcb->save.es; 2196 svm->vmcb->save.es = nested_vmcb->save.es;
2075 svm->vmcb->save.cs = nested_vmcb->save.cs; 2197 svm->vmcb->save.cs = nested_vmcb->save.cs;
@@ -2227,8 +2349,8 @@ static int vmrun_interception(struct vcpu_svm *svm)
2227 if (nested_svm_check_permissions(svm)) 2349 if (nested_svm_check_permissions(svm))
2228 return 1; 2350 return 1;
2229 2351
2230 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; 2352 /* Save rip after vmrun instruction */
2231 skip_emulated_instruction(&svm->vcpu); 2353 kvm_rip_write(&svm->vcpu, kvm_rip_read(&svm->vcpu) + 3);
2232 2354
2233 if (!nested_svm_vmrun(svm)) 2355 if (!nested_svm_vmrun(svm))
2234 return 1; 2356 return 1;
@@ -2257,6 +2379,7 @@ static int stgi_interception(struct vcpu_svm *svm)
2257 2379
2258 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; 2380 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
2259 skip_emulated_instruction(&svm->vcpu); 2381 skip_emulated_instruction(&svm->vcpu);
2382 kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
2260 2383
2261 enable_gif(svm); 2384 enable_gif(svm);
2262 2385
@@ -2399,6 +2522,23 @@ static int emulate_on_interception(struct vcpu_svm *svm)
2399 return emulate_instruction(&svm->vcpu, 0, 0, 0) == EMULATE_DONE; 2522 return emulate_instruction(&svm->vcpu, 0, 0, 0) == EMULATE_DONE;
2400} 2523}
2401 2524
2525static int cr0_write_interception(struct vcpu_svm *svm)
2526{
2527 struct kvm_vcpu *vcpu = &svm->vcpu;
2528 int r;
2529
2530 r = emulate_instruction(&svm->vcpu, 0, 0, 0);
2531
2532 if (svm->nested.vmexit_rip) {
2533 kvm_register_write(vcpu, VCPU_REGS_RIP, svm->nested.vmexit_rip);
2534 kvm_register_write(vcpu, VCPU_REGS_RSP, svm->nested.vmexit_rsp);
2535 kvm_register_write(vcpu, VCPU_REGS_RAX, svm->nested.vmexit_rax);
2536 svm->nested.vmexit_rip = 0;
2537 }
2538
2539 return r == EMULATE_DONE;
2540}
2541
2402static int cr8_write_interception(struct vcpu_svm *svm) 2542static int cr8_write_interception(struct vcpu_svm *svm)
2403{ 2543{
2404 struct kvm_run *kvm_run = svm->vcpu.run; 2544 struct kvm_run *kvm_run = svm->vcpu.run;
@@ -2542,20 +2682,9 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
2542 struct vcpu_svm *svm = to_svm(vcpu); 2682 struct vcpu_svm *svm = to_svm(vcpu);
2543 2683
2544 switch (ecx) { 2684 switch (ecx) {
2545 case MSR_IA32_TSC: { 2685 case MSR_IA32_TSC:
2546 u64 tsc_offset = data - native_read_tsc(); 2686 kvm_write_tsc(vcpu, data);
2547 u64 g_tsc_offset = 0;
2548
2549 if (is_nested(svm)) {
2550 g_tsc_offset = svm->vmcb->control.tsc_offset -
2551 svm->nested.hsave->control.tsc_offset;
2552 svm->nested.hsave->control.tsc_offset = tsc_offset;
2553 }
2554
2555 svm->vmcb->control.tsc_offset = tsc_offset + g_tsc_offset;
2556
2557 break; 2687 break;
2558 }
2559 case MSR_STAR: 2688 case MSR_STAR:
2560 svm->vmcb->save.star = data; 2689 svm->vmcb->save.star = data;
2561 break; 2690 break;
@@ -2643,6 +2772,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm)
2643{ 2772{
2644 struct kvm_run *kvm_run = svm->vcpu.run; 2773 struct kvm_run *kvm_run = svm->vcpu.run;
2645 2774
2775 kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
2646 svm_clear_vintr(svm); 2776 svm_clear_vintr(svm);
2647 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; 2777 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
2648 /* 2778 /*
@@ -2672,7 +2802,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = {
2672 [SVM_EXIT_READ_CR4] = emulate_on_interception, 2802 [SVM_EXIT_READ_CR4] = emulate_on_interception,
2673 [SVM_EXIT_READ_CR8] = emulate_on_interception, 2803 [SVM_EXIT_READ_CR8] = emulate_on_interception,
2674 [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, 2804 [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception,
2675 [SVM_EXIT_WRITE_CR0] = emulate_on_interception, 2805 [SVM_EXIT_WRITE_CR0] = cr0_write_interception,
2676 [SVM_EXIT_WRITE_CR3] = emulate_on_interception, 2806 [SVM_EXIT_WRITE_CR3] = emulate_on_interception,
2677 [SVM_EXIT_WRITE_CR4] = emulate_on_interception, 2807 [SVM_EXIT_WRITE_CR4] = emulate_on_interception,
2678 [SVM_EXIT_WRITE_CR8] = cr8_write_interception, 2808 [SVM_EXIT_WRITE_CR8] = cr8_write_interception,
@@ -2871,7 +3001,8 @@ static int handle_exit(struct kvm_vcpu *vcpu)
2871 3001
2872 if (is_external_interrupt(svm->vmcb->control.exit_int_info) && 3002 if (is_external_interrupt(svm->vmcb->control.exit_int_info) &&
2873 exit_code != SVM_EXIT_EXCP_BASE + PF_VECTOR && 3003 exit_code != SVM_EXIT_EXCP_BASE + PF_VECTOR &&
2874 exit_code != SVM_EXIT_NPF && exit_code != SVM_EXIT_TASK_SWITCH) 3004 exit_code != SVM_EXIT_NPF && exit_code != SVM_EXIT_TASK_SWITCH &&
3005 exit_code != SVM_EXIT_INTR && exit_code != SVM_EXIT_NMI)
2875 printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x " 3006 printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x "
2876 "exit_code 0x%x\n", 3007 "exit_code 0x%x\n",
2877 __func__, svm->vmcb->control.exit_int_info, 3008 __func__, svm->vmcb->control.exit_int_info,
@@ -3088,8 +3219,10 @@ static void svm_complete_interrupts(struct vcpu_svm *svm)
3088 3219
3089 svm->int3_injected = 0; 3220 svm->int3_injected = 0;
3090 3221
3091 if (svm->vcpu.arch.hflags & HF_IRET_MASK) 3222 if (svm->vcpu.arch.hflags & HF_IRET_MASK) {
3092 svm->vcpu.arch.hflags &= ~(HF_NMI_MASK | HF_IRET_MASK); 3223 svm->vcpu.arch.hflags &= ~(HF_NMI_MASK | HF_IRET_MASK);
3224 kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
3225 }
3093 3226
3094 svm->vcpu.arch.nmi_injected = false; 3227 svm->vcpu.arch.nmi_injected = false;
3095 kvm_clear_exception_queue(&svm->vcpu); 3228 kvm_clear_exception_queue(&svm->vcpu);
@@ -3098,6 +3231,8 @@ static void svm_complete_interrupts(struct vcpu_svm *svm)
3098 if (!(exitintinfo & SVM_EXITINTINFO_VALID)) 3231 if (!(exitintinfo & SVM_EXITINTINFO_VALID))
3099 return; 3232 return;
3100 3233
3234 kvm_make_request(KVM_REQ_EVENT, &svm->vcpu);
3235
3101 vector = exitintinfo & SVM_EXITINTINFO_VEC_MASK; 3236 vector = exitintinfo & SVM_EXITINTINFO_VEC_MASK;
3102 type = exitintinfo & SVM_EXITINTINFO_TYPE_MASK; 3237 type = exitintinfo & SVM_EXITINTINFO_TYPE_MASK;
3103 3238
@@ -3134,6 +3269,17 @@ static void svm_complete_interrupts(struct vcpu_svm *svm)
3134 } 3269 }
3135} 3270}
3136 3271
3272static void svm_cancel_injection(struct kvm_vcpu *vcpu)
3273{
3274 struct vcpu_svm *svm = to_svm(vcpu);
3275 struct vmcb_control_area *control = &svm->vmcb->control;
3276
3277 control->exit_int_info = control->event_inj;
3278 control->exit_int_info_err = control->event_inj_err;
3279 control->event_inj = 0;
3280 svm_complete_interrupts(svm);
3281}
3282
3137#ifdef CONFIG_X86_64 3283#ifdef CONFIG_X86_64
3138#define R "r" 3284#define R "r"
3139#else 3285#else
@@ -3163,13 +3309,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3163 sync_lapic_to_cr8(vcpu); 3309 sync_lapic_to_cr8(vcpu);
3164 3310
3165 save_host_msrs(vcpu); 3311 save_host_msrs(vcpu);
3166 fs_selector = kvm_read_fs(); 3312 savesegment(fs, fs_selector);
3167 gs_selector = kvm_read_gs(); 3313 savesegment(gs, gs_selector);
3168 ldt_selector = kvm_read_ldt(); 3314 ldt_selector = kvm_read_ldt();
3169 svm->vmcb->save.cr2 = vcpu->arch.cr2; 3315 svm->vmcb->save.cr2 = vcpu->arch.cr2;
3170 /* required for live migration with NPT */
3171 if (npt_enabled)
3172 svm->vmcb->save.cr3 = vcpu->arch.cr3;
3173 3316
3174 clgi(); 3317 clgi();
3175 3318
@@ -3251,10 +3394,15 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3251 vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp; 3394 vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp;
3252 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip; 3395 vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip;
3253 3396
3254 kvm_load_fs(fs_selector);
3255 kvm_load_gs(gs_selector);
3256 kvm_load_ldt(ldt_selector);
3257 load_host_msrs(vcpu); 3397 load_host_msrs(vcpu);
3398 loadsegment(fs, fs_selector);
3399#ifdef CONFIG_X86_64
3400 load_gs_index(gs_selector);
3401 wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gs);
3402#else
3403 loadsegment(gs, gs_selector);
3404#endif
3405 kvm_load_ldt(ldt_selector);
3258 3406
3259 reload_tss(vcpu); 3407 reload_tss(vcpu);
3260 3408
@@ -3286,16 +3434,22 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root)
3286{ 3434{
3287 struct vcpu_svm *svm = to_svm(vcpu); 3435 struct vcpu_svm *svm = to_svm(vcpu);
3288 3436
3289 if (npt_enabled) {
3290 svm->vmcb->control.nested_cr3 = root;
3291 force_new_asid(vcpu);
3292 return;
3293 }
3294
3295 svm->vmcb->save.cr3 = root; 3437 svm->vmcb->save.cr3 = root;
3296 force_new_asid(vcpu); 3438 force_new_asid(vcpu);
3297} 3439}
3298 3440
3441static void set_tdp_cr3(struct kvm_vcpu *vcpu, unsigned long root)
3442{
3443 struct vcpu_svm *svm = to_svm(vcpu);
3444
3445 svm->vmcb->control.nested_cr3 = root;
3446
3447 /* Also sync guest cr3 here in case we live migrate */
3448 svm->vmcb->save.cr3 = vcpu->arch.cr3;
3449
3450 force_new_asid(vcpu);
3451}
3452
3299static int is_disabled(void) 3453static int is_disabled(void)
3300{ 3454{
3301 u64 vm_cr; 3455 u64 vm_cr;
@@ -3328,15 +3482,6 @@ static bool svm_cpu_has_accelerated_tpr(void)
3328 return false; 3482 return false;
3329} 3483}
3330 3484
3331static int get_npt_level(void)
3332{
3333#ifdef CONFIG_X86_64
3334 return PT64_ROOT_LEVEL;
3335#else
3336 return PT32E_ROOT_LEVEL;
3337#endif
3338}
3339
3340static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) 3485static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
3341{ 3486{
3342 return 0; 3487 return 0;
@@ -3349,12 +3494,25 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
3349static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) 3494static void svm_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry)
3350{ 3495{
3351 switch (func) { 3496 switch (func) {
3497 case 0x80000001:
3498 if (nested)
3499 entry->ecx |= (1 << 2); /* Set SVM bit */
3500 break;
3352 case 0x8000000A: 3501 case 0x8000000A:
3353 entry->eax = 1; /* SVM revision 1 */ 3502 entry->eax = 1; /* SVM revision 1 */
3354 entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper 3503 entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper
3355 ASID emulation to nested SVM */ 3504 ASID emulation to nested SVM */
3356 entry->ecx = 0; /* Reserved */ 3505 entry->ecx = 0; /* Reserved */
3357 entry->edx = 0; /* Do not support any additional features */ 3506 entry->edx = 0; /* Per default do not support any
3507 additional features */
3508
3509 /* Support next_rip if host supports it */
3510 if (svm_has(SVM_FEATURE_NRIP))
3511 entry->edx |= SVM_FEATURE_NRIP;
3512
3513 /* Support NPT for the guest if enabled */
3514 if (npt_enabled)
3515 entry->edx |= SVM_FEATURE_NPT;
3358 3516
3359 break; 3517 break;
3360 } 3518 }
@@ -3492,6 +3650,7 @@ static struct kvm_x86_ops svm_x86_ops = {
3492 .set_irq = svm_set_irq, 3650 .set_irq = svm_set_irq,
3493 .set_nmi = svm_inject_nmi, 3651 .set_nmi = svm_inject_nmi,
3494 .queue_exception = svm_queue_exception, 3652 .queue_exception = svm_queue_exception,
3653 .cancel_injection = svm_cancel_injection,
3495 .interrupt_allowed = svm_interrupt_allowed, 3654 .interrupt_allowed = svm_interrupt_allowed,
3496 .nmi_allowed = svm_nmi_allowed, 3655 .nmi_allowed = svm_nmi_allowed,
3497 .get_nmi_mask = svm_get_nmi_mask, 3656 .get_nmi_mask = svm_get_nmi_mask,
@@ -3514,6 +3673,11 @@ static struct kvm_x86_ops svm_x86_ops = {
3514 .set_supported_cpuid = svm_set_supported_cpuid, 3673 .set_supported_cpuid = svm_set_supported_cpuid,
3515 3674
3516 .has_wbinvd_exit = svm_has_wbinvd_exit, 3675 .has_wbinvd_exit = svm_has_wbinvd_exit,
3676
3677 .write_tsc_offset = svm_write_tsc_offset,
3678 .adjust_tsc_offset = svm_adjust_tsc_offset,
3679
3680 .set_tdp_cr3 = set_tdp_cr3,
3517}; 3681};
3518 3682
3519static int __init svm_init(void) 3683static int __init svm_init(void)
diff --git a/arch/x86/kvm/timer.c b/arch/x86/kvm/timer.c
index e16a0dbe74d8..fc7a101c4a35 100644
--- a/arch/x86/kvm/timer.c
+++ b/arch/x86/kvm/timer.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * timer support 7 * timer support
8 * 8 *
9 * Copyright 2010 Red Hat, Inc. and/or its affilates. 9 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
10 * 10 *
11 * This work is licensed under the terms of the GNU GPL, version 2. See 11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory. 12 * the COPYING file in the top-level directory.
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 49b25eee25ac..8da0e45ff7c9 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5,7 +5,7 @@
5 * machines without emulation or binary translation. 5 * machines without emulation or binary translation.
6 * 6 *
7 * Copyright (C) 2006 Qumranet, Inc. 7 * Copyright (C) 2006 Qumranet, Inc.
8 * Copyright 2010 Red Hat, Inc. and/or its affilates. 8 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
9 * 9 *
10 * Authors: 10 * Authors:
11 * Avi Kivity <avi@qumranet.com> 11 * Avi Kivity <avi@qumranet.com>
@@ -125,6 +125,7 @@ struct vcpu_vmx {
125 unsigned long host_rsp; 125 unsigned long host_rsp;
126 int launched; 126 int launched;
127 u8 fail; 127 u8 fail;
128 u32 exit_intr_info;
128 u32 idt_vectoring_info; 129 u32 idt_vectoring_info;
129 struct shared_msr_entry *guest_msrs; 130 struct shared_msr_entry *guest_msrs;
130 int nmsrs; 131 int nmsrs;
@@ -154,11 +155,6 @@ struct vcpu_vmx {
154 u32 limit; 155 u32 limit;
155 u32 ar; 156 u32 ar;
156 } tr, es, ds, fs, gs; 157 } tr, es, ds, fs, gs;
157 struct {
158 bool pending;
159 u8 vector;
160 unsigned rip;
161 } irq;
162 } rmode; 158 } rmode;
163 int vpid; 159 int vpid;
164 bool emulation_required; 160 bool emulation_required;
@@ -505,7 +501,6 @@ static void __vcpu_clear(void *arg)
505 vmcs_clear(vmx->vmcs); 501 vmcs_clear(vmx->vmcs);
506 if (per_cpu(current_vmcs, cpu) == vmx->vmcs) 502 if (per_cpu(current_vmcs, cpu) == vmx->vmcs)
507 per_cpu(current_vmcs, cpu) = NULL; 503 per_cpu(current_vmcs, cpu) = NULL;
508 rdtscll(vmx->vcpu.arch.host_tsc);
509 list_del(&vmx->local_vcpus_link); 504 list_del(&vmx->local_vcpus_link);
510 vmx->vcpu.cpu = -1; 505 vmx->vcpu.cpu = -1;
511 vmx->launched = 0; 506 vmx->launched = 0;
@@ -706,11 +701,10 @@ static void reload_tss(void)
706 /* 701 /*
707 * VT restores TR but not its size. Useless. 702 * VT restores TR but not its size. Useless.
708 */ 703 */
709 struct desc_ptr gdt; 704 struct desc_ptr *gdt = &__get_cpu_var(host_gdt);
710 struct desc_struct *descs; 705 struct desc_struct *descs;
711 706
712 native_store_gdt(&gdt); 707 descs = (void *)gdt->address;
713 descs = (void *)gdt.address;
714 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */ 708 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
715 load_TR_desc(); 709 load_TR_desc();
716} 710}
@@ -753,7 +747,7 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
753 747
754static unsigned long segment_base(u16 selector) 748static unsigned long segment_base(u16 selector)
755{ 749{
756 struct desc_ptr gdt; 750 struct desc_ptr *gdt = &__get_cpu_var(host_gdt);
757 struct desc_struct *d; 751 struct desc_struct *d;
758 unsigned long table_base; 752 unsigned long table_base;
759 unsigned long v; 753 unsigned long v;
@@ -761,8 +755,7 @@ static unsigned long segment_base(u16 selector)
761 if (!(selector & ~3)) 755 if (!(selector & ~3))
762 return 0; 756 return 0;
763 757
764 native_store_gdt(&gdt); 758 table_base = gdt->address;
765 table_base = gdt.address;
766 759
767 if (selector & 4) { /* from ldt */ 760 if (selector & 4) { /* from ldt */
768 u16 ldt_selector = kvm_read_ldt(); 761 u16 ldt_selector = kvm_read_ldt();
@@ -803,7 +796,7 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
803 */ 796 */
804 vmx->host_state.ldt_sel = kvm_read_ldt(); 797 vmx->host_state.ldt_sel = kvm_read_ldt();
805 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel; 798 vmx->host_state.gs_ldt_reload_needed = vmx->host_state.ldt_sel;
806 vmx->host_state.fs_sel = kvm_read_fs(); 799 savesegment(fs, vmx->host_state.fs_sel);
807 if (!(vmx->host_state.fs_sel & 7)) { 800 if (!(vmx->host_state.fs_sel & 7)) {
808 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel); 801 vmcs_write16(HOST_FS_SELECTOR, vmx->host_state.fs_sel);
809 vmx->host_state.fs_reload_needed = 0; 802 vmx->host_state.fs_reload_needed = 0;
@@ -811,7 +804,7 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
811 vmcs_write16(HOST_FS_SELECTOR, 0); 804 vmcs_write16(HOST_FS_SELECTOR, 0);
812 vmx->host_state.fs_reload_needed = 1; 805 vmx->host_state.fs_reload_needed = 1;
813 } 806 }
814 vmx->host_state.gs_sel = kvm_read_gs(); 807 savesegment(gs, vmx->host_state.gs_sel);
815 if (!(vmx->host_state.gs_sel & 7)) 808 if (!(vmx->host_state.gs_sel & 7))
816 vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel); 809 vmcs_write16(HOST_GS_SELECTOR, vmx->host_state.gs_sel);
817 else { 810 else {
@@ -841,27 +834,21 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
841 834
842static void __vmx_load_host_state(struct vcpu_vmx *vmx) 835static void __vmx_load_host_state(struct vcpu_vmx *vmx)
843{ 836{
844 unsigned long flags;
845
846 if (!vmx->host_state.loaded) 837 if (!vmx->host_state.loaded)
847 return; 838 return;
848 839
849 ++vmx->vcpu.stat.host_state_reload; 840 ++vmx->vcpu.stat.host_state_reload;
850 vmx->host_state.loaded = 0; 841 vmx->host_state.loaded = 0;
851 if (vmx->host_state.fs_reload_needed) 842 if (vmx->host_state.fs_reload_needed)
852 kvm_load_fs(vmx->host_state.fs_sel); 843 loadsegment(fs, vmx->host_state.fs_sel);
853 if (vmx->host_state.gs_ldt_reload_needed) { 844 if (vmx->host_state.gs_ldt_reload_needed) {
854 kvm_load_ldt(vmx->host_state.ldt_sel); 845 kvm_load_ldt(vmx->host_state.ldt_sel);
855 /*
856 * If we have to reload gs, we must take care to
857 * preserve our gs base.
858 */
859 local_irq_save(flags);
860 kvm_load_gs(vmx->host_state.gs_sel);
861#ifdef CONFIG_X86_64 846#ifdef CONFIG_X86_64
862 wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); 847 load_gs_index(vmx->host_state.gs_sel);
848 wrmsrl(MSR_KERNEL_GS_BASE, current->thread.gs);
849#else
850 loadsegment(gs, vmx->host_state.gs_sel);
863#endif 851#endif
864 local_irq_restore(flags);
865 } 852 }
866 reload_tss(); 853 reload_tss();
867#ifdef CONFIG_X86_64 854#ifdef CONFIG_X86_64
@@ -889,7 +876,6 @@ static void vmx_load_host_state(struct vcpu_vmx *vmx)
889static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 876static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
890{ 877{
891 struct vcpu_vmx *vmx = to_vmx(vcpu); 878 struct vcpu_vmx *vmx = to_vmx(vcpu);
892 u64 tsc_this, delta, new_offset;
893 u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); 879 u64 phys_addr = __pa(per_cpu(vmxarea, cpu));
894 880
895 if (!vmm_exclusive) 881 if (!vmm_exclusive)
@@ -903,37 +889,24 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
903 } 889 }
904 890
905 if (vcpu->cpu != cpu) { 891 if (vcpu->cpu != cpu) {
906 struct desc_ptr dt; 892 struct desc_ptr *gdt = &__get_cpu_var(host_gdt);
907 unsigned long sysenter_esp; 893 unsigned long sysenter_esp;
908 894
909 kvm_migrate_timers(vcpu);
910 kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 895 kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
911 local_irq_disable(); 896 local_irq_disable();
912 list_add(&vmx->local_vcpus_link, 897 list_add(&vmx->local_vcpus_link,
913 &per_cpu(vcpus_on_cpu, cpu)); 898 &per_cpu(vcpus_on_cpu, cpu));
914 local_irq_enable(); 899 local_irq_enable();
915 900
916 vcpu->cpu = cpu;
917 /* 901 /*
918 * Linux uses per-cpu TSS and GDT, so set these when switching 902 * Linux uses per-cpu TSS and GDT, so set these when switching
919 * processors. 903 * processors.
920 */ 904 */
921 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */ 905 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
922 native_store_gdt(&dt); 906 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
923 vmcs_writel(HOST_GDTR_BASE, dt.address); /* 22.2.4 */
924 907
925 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); 908 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
926 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ 909 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
927
928 /*
929 * Make sure the time stamp counter is monotonous.
930 */
931 rdtscll(tsc_this);
932 if (tsc_this < vcpu->arch.host_tsc) {
933 delta = vcpu->arch.host_tsc - tsc_this;
934 new_offset = vmcs_read64(TSC_OFFSET) + delta;
935 vmcs_write64(TSC_OFFSET, new_offset);
936 }
937 } 910 }
938} 911}
939 912
@@ -1050,16 +1023,8 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
1050 } 1023 }
1051 1024
1052 if (vmx->rmode.vm86_active) { 1025 if (vmx->rmode.vm86_active) {
1053 vmx->rmode.irq.pending = true; 1026 if (kvm_inject_realmode_interrupt(vcpu, nr) != EMULATE_DONE)
1054 vmx->rmode.irq.vector = nr; 1027 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
1055 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
1056 if (kvm_exception_is_soft(nr))
1057 vmx->rmode.irq.rip +=
1058 vmx->vcpu.arch.event_exit_inst_len;
1059 intr_info |= INTR_TYPE_SOFT_INTR;
1060 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info);
1061 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
1062 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
1063 return; 1028 return;
1064 } 1029 }
1065 1030
@@ -1155,12 +1120,17 @@ static u64 guest_read_tsc(void)
1155} 1120}
1156 1121
1157/* 1122/*
1158 * writes 'guest_tsc' into guest's timestamp counter "register" 1123 * writes 'offset' into guest's timestamp counter offset register
1159 * guest_tsc = host_tsc + tsc_offset ==> tsc_offset = guest_tsc - host_tsc
1160 */ 1124 */
1161static void guest_write_tsc(u64 guest_tsc, u64 host_tsc) 1125static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
1162{ 1126{
1163 vmcs_write64(TSC_OFFSET, guest_tsc - host_tsc); 1127 vmcs_write64(TSC_OFFSET, offset);
1128}
1129
1130static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment)
1131{
1132 u64 offset = vmcs_read64(TSC_OFFSET);
1133 vmcs_write64(TSC_OFFSET, offset + adjustment);
1164} 1134}
1165 1135
1166/* 1136/*
@@ -1233,7 +1203,6 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
1233{ 1203{
1234 struct vcpu_vmx *vmx = to_vmx(vcpu); 1204 struct vcpu_vmx *vmx = to_vmx(vcpu);
1235 struct shared_msr_entry *msr; 1205 struct shared_msr_entry *msr;
1236 u64 host_tsc;
1237 int ret = 0; 1206 int ret = 0;
1238 1207
1239 switch (msr_index) { 1208 switch (msr_index) {
@@ -1263,8 +1232,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
1263 vmcs_writel(GUEST_SYSENTER_ESP, data); 1232 vmcs_writel(GUEST_SYSENTER_ESP, data);
1264 break; 1233 break;
1265 case MSR_IA32_TSC: 1234 case MSR_IA32_TSC:
1266 rdtscll(host_tsc); 1235 kvm_write_tsc(vcpu, data);
1267 guest_write_tsc(data, host_tsc);
1268 break; 1236 break;
1269 case MSR_IA32_CR_PAT: 1237 case MSR_IA32_CR_PAT:
1270 if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) { 1238 if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
@@ -1862,20 +1830,20 @@ static void ept_load_pdptrs(struct kvm_vcpu *vcpu)
1862 return; 1830 return;
1863 1831
1864 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) { 1832 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) {
1865 vmcs_write64(GUEST_PDPTR0, vcpu->arch.pdptrs[0]); 1833 vmcs_write64(GUEST_PDPTR0, vcpu->arch.mmu.pdptrs[0]);
1866 vmcs_write64(GUEST_PDPTR1, vcpu->arch.pdptrs[1]); 1834 vmcs_write64(GUEST_PDPTR1, vcpu->arch.mmu.pdptrs[1]);
1867 vmcs_write64(GUEST_PDPTR2, vcpu->arch.pdptrs[2]); 1835 vmcs_write64(GUEST_PDPTR2, vcpu->arch.mmu.pdptrs[2]);
1868 vmcs_write64(GUEST_PDPTR3, vcpu->arch.pdptrs[3]); 1836 vmcs_write64(GUEST_PDPTR3, vcpu->arch.mmu.pdptrs[3]);
1869 } 1837 }
1870} 1838}
1871 1839
1872static void ept_save_pdptrs(struct kvm_vcpu *vcpu) 1840static void ept_save_pdptrs(struct kvm_vcpu *vcpu)
1873{ 1841{
1874 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) { 1842 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) {
1875 vcpu->arch.pdptrs[0] = vmcs_read64(GUEST_PDPTR0); 1843 vcpu->arch.mmu.pdptrs[0] = vmcs_read64(GUEST_PDPTR0);
1876 vcpu->arch.pdptrs[1] = vmcs_read64(GUEST_PDPTR1); 1844 vcpu->arch.mmu.pdptrs[1] = vmcs_read64(GUEST_PDPTR1);
1877 vcpu->arch.pdptrs[2] = vmcs_read64(GUEST_PDPTR2); 1845 vcpu->arch.mmu.pdptrs[2] = vmcs_read64(GUEST_PDPTR2);
1878 vcpu->arch.pdptrs[3] = vmcs_read64(GUEST_PDPTR3); 1846 vcpu->arch.mmu.pdptrs[3] = vmcs_read64(GUEST_PDPTR3);
1879 } 1847 }
1880 1848
1881 __set_bit(VCPU_EXREG_PDPTR, 1849 __set_bit(VCPU_EXREG_PDPTR,
@@ -2521,7 +2489,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2521{ 2489{
2522 u32 host_sysenter_cs, msr_low, msr_high; 2490 u32 host_sysenter_cs, msr_low, msr_high;
2523 u32 junk; 2491 u32 junk;
2524 u64 host_pat, tsc_this, tsc_base; 2492 u64 host_pat;
2525 unsigned long a; 2493 unsigned long a;
2526 struct desc_ptr dt; 2494 struct desc_ptr dt;
2527 int i; 2495 int i;
@@ -2589,8 +2557,8 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2589 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */ 2557 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
2590 vmcs_write16(HOST_DS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 2558 vmcs_write16(HOST_DS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
2591 vmcs_write16(HOST_ES_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 2559 vmcs_write16(HOST_ES_SELECTOR, __KERNEL_DS); /* 22.2.4 */
2592 vmcs_write16(HOST_FS_SELECTOR, kvm_read_fs()); /* 22.2.4 */ 2560 vmcs_write16(HOST_FS_SELECTOR, 0); /* 22.2.4 */
2593 vmcs_write16(HOST_GS_SELECTOR, kvm_read_gs()); /* 22.2.4 */ 2561 vmcs_write16(HOST_GS_SELECTOR, 0); /* 22.2.4 */
2594 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ 2562 vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */
2595#ifdef CONFIG_X86_64 2563#ifdef CONFIG_X86_64
2596 rdmsrl(MSR_FS_BASE, a); 2564 rdmsrl(MSR_FS_BASE, a);
@@ -2662,12 +2630,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2662 vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE; 2630 vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE;
2663 vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits); 2631 vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits);
2664 2632
2665 tsc_base = vmx->vcpu.kvm->arch.vm_init_tsc; 2633 kvm_write_tsc(&vmx->vcpu, 0);
2666 rdtscll(tsc_this);
2667 if (tsc_this < vmx->vcpu.kvm->arch.vm_init_tsc)
2668 tsc_base = tsc_this;
2669
2670 guest_write_tsc(0, tsc_base);
2671 2634
2672 return 0; 2635 return 0;
2673} 2636}
@@ -2840,16 +2803,8 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu)
2840 2803
2841 ++vcpu->stat.irq_injections; 2804 ++vcpu->stat.irq_injections;
2842 if (vmx->rmode.vm86_active) { 2805 if (vmx->rmode.vm86_active) {
2843 vmx->rmode.irq.pending = true; 2806 if (kvm_inject_realmode_interrupt(vcpu, irq) != EMULATE_DONE)
2844 vmx->rmode.irq.vector = irq; 2807 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
2845 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
2846 if (vcpu->arch.interrupt.soft)
2847 vmx->rmode.irq.rip +=
2848 vmx->vcpu.arch.event_exit_inst_len;
2849 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2850 irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK);
2851 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
2852 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
2853 return; 2808 return;
2854 } 2809 }
2855 intr = irq | INTR_INFO_VALID_MASK; 2810 intr = irq | INTR_INFO_VALID_MASK;
@@ -2881,14 +2836,8 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
2881 2836
2882 ++vcpu->stat.nmi_injections; 2837 ++vcpu->stat.nmi_injections;
2883 if (vmx->rmode.vm86_active) { 2838 if (vmx->rmode.vm86_active) {
2884 vmx->rmode.irq.pending = true; 2839 if (kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR) != EMULATE_DONE)
2885 vmx->rmode.irq.vector = NMI_VECTOR; 2840 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
2886 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
2887 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2888 NMI_VECTOR | INTR_TYPE_SOFT_INTR |
2889 INTR_INFO_VALID_MASK);
2890 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
2891 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
2892 return; 2841 return;
2893 } 2842 }
2894 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 2843 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
@@ -3352,6 +3301,7 @@ static int handle_wrmsr(struct kvm_vcpu *vcpu)
3352 3301
3353static int handle_tpr_below_threshold(struct kvm_vcpu *vcpu) 3302static int handle_tpr_below_threshold(struct kvm_vcpu *vcpu)
3354{ 3303{
3304 kvm_make_request(KVM_REQ_EVENT, vcpu);
3355 return 1; 3305 return 1;
3356} 3306}
3357 3307
@@ -3364,6 +3314,8 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu)
3364 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING; 3314 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING;
3365 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control); 3315 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
3366 3316
3317 kvm_make_request(KVM_REQ_EVENT, vcpu);
3318
3367 ++vcpu->stat.irq_window_exits; 3319 ++vcpu->stat.irq_window_exits;
3368 3320
3369 /* 3321 /*
@@ -3620,6 +3572,7 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu)
3620 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING; 3572 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING;
3621 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control); 3573 vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, cpu_based_vm_exec_control);
3622 ++vcpu->stat.nmi_window_exits; 3574 ++vcpu->stat.nmi_window_exits;
3575 kvm_make_request(KVM_REQ_EVENT, vcpu);
3623 3576
3624 return 1; 3577 return 1;
3625} 3578}
@@ -3629,8 +3582,17 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
3629 struct vcpu_vmx *vmx = to_vmx(vcpu); 3582 struct vcpu_vmx *vmx = to_vmx(vcpu);
3630 enum emulation_result err = EMULATE_DONE; 3583 enum emulation_result err = EMULATE_DONE;
3631 int ret = 1; 3584 int ret = 1;
3585 u32 cpu_exec_ctrl;
3586 bool intr_window_requested;
3587
3588 cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
3589 intr_window_requested = cpu_exec_ctrl & CPU_BASED_VIRTUAL_INTR_PENDING;
3632 3590
3633 while (!guest_state_valid(vcpu)) { 3591 while (!guest_state_valid(vcpu)) {
3592 if (intr_window_requested
3593 && (kvm_get_rflags(&vmx->vcpu) & X86_EFLAGS_IF))
3594 return handle_interrupt_window(&vmx->vcpu);
3595
3634 err = emulate_instruction(vcpu, 0, 0, 0); 3596 err = emulate_instruction(vcpu, 0, 0, 0);
3635 3597
3636 if (err == EMULATE_DO_MMIO) { 3598 if (err == EMULATE_DO_MMIO) {
@@ -3796,18 +3758,9 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr)
3796 vmcs_write32(TPR_THRESHOLD, irr); 3758 vmcs_write32(TPR_THRESHOLD, irr);
3797} 3759}
3798 3760
3799static void vmx_complete_interrupts(struct vcpu_vmx *vmx) 3761static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx)
3800{ 3762{
3801 u32 exit_intr_info; 3763 u32 exit_intr_info = vmx->exit_intr_info;
3802 u32 idt_vectoring_info = vmx->idt_vectoring_info;
3803 bool unblock_nmi;
3804 u8 vector;
3805 int type;
3806 bool idtv_info_valid;
3807
3808 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
3809
3810 vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
3811 3764
3812 /* Handle machine checks before interrupts are enabled */ 3765 /* Handle machine checks before interrupts are enabled */
3813 if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY) 3766 if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY)
@@ -3822,8 +3775,16 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3822 asm("int $2"); 3775 asm("int $2");
3823 kvm_after_handle_nmi(&vmx->vcpu); 3776 kvm_after_handle_nmi(&vmx->vcpu);
3824 } 3777 }
3778}
3825 3779
3826 idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK; 3780static void vmx_recover_nmi_blocking(struct vcpu_vmx *vmx)
3781{
3782 u32 exit_intr_info = vmx->exit_intr_info;
3783 bool unblock_nmi;
3784 u8 vector;
3785 bool idtv_info_valid;
3786
3787 idtv_info_valid = vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK;
3827 3788
3828 if (cpu_has_virtual_nmis()) { 3789 if (cpu_has_virtual_nmis()) {
3829 unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0; 3790 unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
@@ -3845,6 +3806,18 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3845 } else if (unlikely(vmx->soft_vnmi_blocked)) 3806 } else if (unlikely(vmx->soft_vnmi_blocked))
3846 vmx->vnmi_blocked_time += 3807 vmx->vnmi_blocked_time +=
3847 ktime_to_ns(ktime_sub(ktime_get(), vmx->entry_time)); 3808 ktime_to_ns(ktime_sub(ktime_get(), vmx->entry_time));
3809}
3810
3811static void __vmx_complete_interrupts(struct vcpu_vmx *vmx,
3812 u32 idt_vectoring_info,
3813 int instr_len_field,
3814 int error_code_field)
3815{
3816 u8 vector;
3817 int type;
3818 bool idtv_info_valid;
3819
3820 idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
3848 3821
3849 vmx->vcpu.arch.nmi_injected = false; 3822 vmx->vcpu.arch.nmi_injected = false;
3850 kvm_clear_exception_queue(&vmx->vcpu); 3823 kvm_clear_exception_queue(&vmx->vcpu);
@@ -3853,6 +3826,8 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3853 if (!idtv_info_valid) 3826 if (!idtv_info_valid)
3854 return; 3827 return;
3855 3828
3829 kvm_make_request(KVM_REQ_EVENT, &vmx->vcpu);
3830
3856 vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK; 3831 vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK;
3857 type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK; 3832 type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK;
3858 3833
@@ -3869,18 +3844,18 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3869 break; 3844 break;
3870 case INTR_TYPE_SOFT_EXCEPTION: 3845 case INTR_TYPE_SOFT_EXCEPTION:
3871 vmx->vcpu.arch.event_exit_inst_len = 3846 vmx->vcpu.arch.event_exit_inst_len =
3872 vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 3847 vmcs_read32(instr_len_field);
3873 /* fall through */ 3848 /* fall through */
3874 case INTR_TYPE_HARD_EXCEPTION: 3849 case INTR_TYPE_HARD_EXCEPTION:
3875 if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) { 3850 if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) {
3876 u32 err = vmcs_read32(IDT_VECTORING_ERROR_CODE); 3851 u32 err = vmcs_read32(error_code_field);
3877 kvm_queue_exception_e(&vmx->vcpu, vector, err); 3852 kvm_queue_exception_e(&vmx->vcpu, vector, err);
3878 } else 3853 } else
3879 kvm_queue_exception(&vmx->vcpu, vector); 3854 kvm_queue_exception(&vmx->vcpu, vector);
3880 break; 3855 break;
3881 case INTR_TYPE_SOFT_INTR: 3856 case INTR_TYPE_SOFT_INTR:
3882 vmx->vcpu.arch.event_exit_inst_len = 3857 vmx->vcpu.arch.event_exit_inst_len =
3883 vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 3858 vmcs_read32(instr_len_field);
3884 /* fall through */ 3859 /* fall through */
3885 case INTR_TYPE_EXT_INTR: 3860 case INTR_TYPE_EXT_INTR:
3886 kvm_queue_interrupt(&vmx->vcpu, vector, 3861 kvm_queue_interrupt(&vmx->vcpu, vector,
@@ -3891,27 +3866,21 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3891 } 3866 }
3892} 3867}
3893 3868
3894/* 3869static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3895 * Failure to inject an interrupt should give us the information
3896 * in IDT_VECTORING_INFO_FIELD. However, if the failure occurs
3897 * when fetching the interrupt redirection bitmap in the real-mode
3898 * tss, this doesn't happen. So we do it ourselves.
3899 */
3900static void fixup_rmode_irq(struct vcpu_vmx *vmx)
3901{ 3870{
3902 vmx->rmode.irq.pending = 0; 3871 __vmx_complete_interrupts(vmx, vmx->idt_vectoring_info,
3903 if (kvm_rip_read(&vmx->vcpu) + 1 != vmx->rmode.irq.rip) 3872 VM_EXIT_INSTRUCTION_LEN,
3904 return; 3873 IDT_VECTORING_ERROR_CODE);
3905 kvm_rip_write(&vmx->vcpu, vmx->rmode.irq.rip); 3874}
3906 if (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) { 3875
3907 vmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK; 3876static void vmx_cancel_injection(struct kvm_vcpu *vcpu)
3908 vmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR; 3877{
3909 return; 3878 __vmx_complete_interrupts(to_vmx(vcpu),
3910 } 3879 vmcs_read32(VM_ENTRY_INTR_INFO_FIELD),
3911 vmx->idt_vectoring_info = 3880 VM_ENTRY_INSTRUCTION_LEN,
3912 VECTORING_INFO_VALID_MASK 3881 VM_ENTRY_EXCEPTION_ERROR_CODE);
3913 | INTR_TYPE_EXT_INTR 3882
3914 | vmx->rmode.irq.vector; 3883 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0);
3915} 3884}
3916 3885
3917#ifdef CONFIG_X86_64 3886#ifdef CONFIG_X86_64
@@ -4038,7 +4007,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
4038#endif 4007#endif
4039 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)) 4008 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2))
4040 : "cc", "memory" 4009 : "cc", "memory"
4041 , R"bx", R"di", R"si" 4010 , R"ax", R"bx", R"di", R"si"
4042#ifdef CONFIG_X86_64 4011#ifdef CONFIG_X86_64
4043 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" 4012 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
4044#endif 4013#endif
@@ -4049,12 +4018,15 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
4049 vcpu->arch.regs_dirty = 0; 4018 vcpu->arch.regs_dirty = 0;
4050 4019
4051 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); 4020 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
4052 if (vmx->rmode.irq.pending)
4053 fixup_rmode_irq(vmx);
4054 4021
4055 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); 4022 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
4056 vmx->launched = 1; 4023 vmx->launched = 1;
4057 4024
4025 vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
4026 vmx->exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
4027
4028 vmx_complete_atomic_exit(vmx);
4029 vmx_recover_nmi_blocking(vmx);
4058 vmx_complete_interrupts(vmx); 4030 vmx_complete_interrupts(vmx);
4059} 4031}
4060 4032
@@ -4125,6 +4097,7 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
4125 4097
4126 cpu = get_cpu(); 4098 cpu = get_cpu();
4127 vmx_vcpu_load(&vmx->vcpu, cpu); 4099 vmx_vcpu_load(&vmx->vcpu, cpu);
4100 vmx->vcpu.cpu = cpu;
4128 err = vmx_vcpu_setup(vmx); 4101 err = vmx_vcpu_setup(vmx);
4129 vmx_vcpu_put(&vmx->vcpu); 4102 vmx_vcpu_put(&vmx->vcpu);
4130 put_cpu(); 4103 put_cpu();
@@ -4340,6 +4313,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
4340 .set_irq = vmx_inject_irq, 4313 .set_irq = vmx_inject_irq,
4341 .set_nmi = vmx_inject_nmi, 4314 .set_nmi = vmx_inject_nmi,
4342 .queue_exception = vmx_queue_exception, 4315 .queue_exception = vmx_queue_exception,
4316 .cancel_injection = vmx_cancel_injection,
4343 .interrupt_allowed = vmx_interrupt_allowed, 4317 .interrupt_allowed = vmx_interrupt_allowed,
4344 .nmi_allowed = vmx_nmi_allowed, 4318 .nmi_allowed = vmx_nmi_allowed,
4345 .get_nmi_mask = vmx_get_nmi_mask, 4319 .get_nmi_mask = vmx_get_nmi_mask,
@@ -4362,6 +4336,11 @@ static struct kvm_x86_ops vmx_x86_ops = {
4362 .set_supported_cpuid = vmx_set_supported_cpuid, 4336 .set_supported_cpuid = vmx_set_supported_cpuid,
4363 4337
4364 .has_wbinvd_exit = cpu_has_vmx_wbinvd_exit, 4338 .has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,
4339
4340 .write_tsc_offset = vmx_write_tsc_offset,
4341 .adjust_tsc_offset = vmx_adjust_tsc_offset,
4342
4343 .set_tdp_cr3 = vmx_set_cr3,
4365}; 4344};
4366 4345
4367static int __init vmx_init(void) 4346static int __init vmx_init(void)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 3a09c625d526..2288ad829b32 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6,7 +6,7 @@
6 * Copyright (C) 2006 Qumranet, Inc. 6 * Copyright (C) 2006 Qumranet, Inc.
7 * Copyright (C) 2008 Qumranet, Inc. 7 * Copyright (C) 2008 Qumranet, Inc.
8 * Copyright IBM Corporation, 2008 8 * Copyright IBM Corporation, 2008
9 * Copyright 2010 Red Hat, Inc. and/or its affilates. 9 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
10 * 10 *
11 * Authors: 11 * Authors:
12 * Avi Kivity <avi@qumranet.com> 12 * Avi Kivity <avi@qumranet.com>
@@ -55,6 +55,8 @@
55#include <asm/mce.h> 55#include <asm/mce.h>
56#include <asm/i387.h> 56#include <asm/i387.h>
57#include <asm/xcr.h> 57#include <asm/xcr.h>
58#include <asm/pvclock.h>
59#include <asm/div64.h>
58 60
59#define MAX_IO_MSRS 256 61#define MAX_IO_MSRS 256
60#define CR0_RESERVED_BITS \ 62#define CR0_RESERVED_BITS \
@@ -71,7 +73,7 @@
71#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR) 73#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
72 74
73#define KVM_MAX_MCE_BANKS 32 75#define KVM_MAX_MCE_BANKS 32
74#define KVM_MCE_CAP_SUPPORTED MCG_CTL_P 76#define KVM_MCE_CAP_SUPPORTED (MCG_CTL_P | MCG_SER_P)
75 77
76/* EFER defaults: 78/* EFER defaults:
77 * - enable syscall per default because its emulated by KVM 79 * - enable syscall per default because its emulated by KVM
@@ -282,6 +284,8 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu,
282 u32 prev_nr; 284 u32 prev_nr;
283 int class1, class2; 285 int class1, class2;
284 286
287 kvm_make_request(KVM_REQ_EVENT, vcpu);
288
285 if (!vcpu->arch.exception.pending) { 289 if (!vcpu->arch.exception.pending) {
286 queue: 290 queue:
287 vcpu->arch.exception.pending = true; 291 vcpu->arch.exception.pending = true;
@@ -327,16 +331,28 @@ void kvm_requeue_exception(struct kvm_vcpu *vcpu, unsigned nr)
327} 331}
328EXPORT_SYMBOL_GPL(kvm_requeue_exception); 332EXPORT_SYMBOL_GPL(kvm_requeue_exception);
329 333
330void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr, 334void kvm_inject_page_fault(struct kvm_vcpu *vcpu)
331 u32 error_code)
332{ 335{
336 unsigned error_code = vcpu->arch.fault.error_code;
337
333 ++vcpu->stat.pf_guest; 338 ++vcpu->stat.pf_guest;
334 vcpu->arch.cr2 = addr; 339 vcpu->arch.cr2 = vcpu->arch.fault.address;
335 kvm_queue_exception_e(vcpu, PF_VECTOR, error_code); 340 kvm_queue_exception_e(vcpu, PF_VECTOR, error_code);
336} 341}
337 342
343void kvm_propagate_fault(struct kvm_vcpu *vcpu)
344{
345 if (mmu_is_nested(vcpu) && !vcpu->arch.fault.nested)
346 vcpu->arch.nested_mmu.inject_page_fault(vcpu);
347 else
348 vcpu->arch.mmu.inject_page_fault(vcpu);
349
350 vcpu->arch.fault.nested = false;
351}
352
338void kvm_inject_nmi(struct kvm_vcpu *vcpu) 353void kvm_inject_nmi(struct kvm_vcpu *vcpu)
339{ 354{
355 kvm_make_request(KVM_REQ_EVENT, vcpu);
340 vcpu->arch.nmi_pending = 1; 356 vcpu->arch.nmi_pending = 1;
341} 357}
342EXPORT_SYMBOL_GPL(kvm_inject_nmi); 358EXPORT_SYMBOL_GPL(kvm_inject_nmi);
@@ -367,18 +383,49 @@ bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl)
367EXPORT_SYMBOL_GPL(kvm_require_cpl); 383EXPORT_SYMBOL_GPL(kvm_require_cpl);
368 384
369/* 385/*
386 * This function will be used to read from the physical memory of the currently
387 * running guest. The difference to kvm_read_guest_page is that this function
388 * can read from guest physical or from the guest's guest physical memory.
389 */
390int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
391 gfn_t ngfn, void *data, int offset, int len,
392 u32 access)
393{
394 gfn_t real_gfn;
395 gpa_t ngpa;
396
397 ngpa = gfn_to_gpa(ngfn);
398 real_gfn = mmu->translate_gpa(vcpu, ngpa, access);
399 if (real_gfn == UNMAPPED_GVA)
400 return -EFAULT;
401
402 real_gfn = gpa_to_gfn(real_gfn);
403
404 return kvm_read_guest_page(vcpu->kvm, real_gfn, data, offset, len);
405}
406EXPORT_SYMBOL_GPL(kvm_read_guest_page_mmu);
407
408int kvm_read_nested_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn,
409 void *data, int offset, int len, u32 access)
410{
411 return kvm_read_guest_page_mmu(vcpu, vcpu->arch.walk_mmu, gfn,
412 data, offset, len, access);
413}
414
415/*
370 * Load the pae pdptrs. Return true is they are all valid. 416 * Load the pae pdptrs. Return true is they are all valid.
371 */ 417 */
372int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3) 418int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)
373{ 419{
374 gfn_t pdpt_gfn = cr3 >> PAGE_SHIFT; 420 gfn_t pdpt_gfn = cr3 >> PAGE_SHIFT;
375 unsigned offset = ((cr3 & (PAGE_SIZE-1)) >> 5) << 2; 421 unsigned offset = ((cr3 & (PAGE_SIZE-1)) >> 5) << 2;
376 int i; 422 int i;
377 int ret; 423 int ret;
378 u64 pdpte[ARRAY_SIZE(vcpu->arch.pdptrs)]; 424 u64 pdpte[ARRAY_SIZE(mmu->pdptrs)];
379 425
380 ret = kvm_read_guest_page(vcpu->kvm, pdpt_gfn, pdpte, 426 ret = kvm_read_guest_page_mmu(vcpu, mmu, pdpt_gfn, pdpte,
381 offset * sizeof(u64), sizeof(pdpte)); 427 offset * sizeof(u64), sizeof(pdpte),
428 PFERR_USER_MASK|PFERR_WRITE_MASK);
382 if (ret < 0) { 429 if (ret < 0) {
383 ret = 0; 430 ret = 0;
384 goto out; 431 goto out;
@@ -392,7 +439,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
392 } 439 }
393 ret = 1; 440 ret = 1;
394 441
395 memcpy(vcpu->arch.pdptrs, pdpte, sizeof(vcpu->arch.pdptrs)); 442 memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs));
396 __set_bit(VCPU_EXREG_PDPTR, 443 __set_bit(VCPU_EXREG_PDPTR,
397 (unsigned long *)&vcpu->arch.regs_avail); 444 (unsigned long *)&vcpu->arch.regs_avail);
398 __set_bit(VCPU_EXREG_PDPTR, 445 __set_bit(VCPU_EXREG_PDPTR,
@@ -405,8 +452,10 @@ EXPORT_SYMBOL_GPL(load_pdptrs);
405 452
406static bool pdptrs_changed(struct kvm_vcpu *vcpu) 453static bool pdptrs_changed(struct kvm_vcpu *vcpu)
407{ 454{
408 u64 pdpte[ARRAY_SIZE(vcpu->arch.pdptrs)]; 455 u64 pdpte[ARRAY_SIZE(vcpu->arch.walk_mmu->pdptrs)];
409 bool changed = true; 456 bool changed = true;
457 int offset;
458 gfn_t gfn;
410 int r; 459 int r;
411 460
412 if (is_long_mode(vcpu) || !is_pae(vcpu)) 461 if (is_long_mode(vcpu) || !is_pae(vcpu))
@@ -416,10 +465,13 @@ static bool pdptrs_changed(struct kvm_vcpu *vcpu)
416 (unsigned long *)&vcpu->arch.regs_avail)) 465 (unsigned long *)&vcpu->arch.regs_avail))
417 return true; 466 return true;
418 467
419 r = kvm_read_guest(vcpu->kvm, vcpu->arch.cr3 & ~31u, pdpte, sizeof(pdpte)); 468 gfn = (vcpu->arch.cr3 & ~31u) >> PAGE_SHIFT;
469 offset = (vcpu->arch.cr3 & ~31u) & (PAGE_SIZE - 1);
470 r = kvm_read_nested_guest_page(vcpu, gfn, pdpte, offset, sizeof(pdpte),
471 PFERR_USER_MASK | PFERR_WRITE_MASK);
420 if (r < 0) 472 if (r < 0)
421 goto out; 473 goto out;
422 changed = memcmp(pdpte, vcpu->arch.pdptrs, sizeof(pdpte)) != 0; 474 changed = memcmp(pdpte, vcpu->arch.walk_mmu->pdptrs, sizeof(pdpte)) != 0;
423out: 475out:
424 476
425 return changed; 477 return changed;
@@ -458,7 +510,8 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
458 return 1; 510 return 1;
459 } else 511 } else
460#endif 512#endif
461 if (is_pae(vcpu) && !load_pdptrs(vcpu, vcpu->arch.cr3)) 513 if (is_pae(vcpu) && !load_pdptrs(vcpu, vcpu->arch.walk_mmu,
514 vcpu->arch.cr3))
462 return 1; 515 return 1;
463 } 516 }
464 517
@@ -547,7 +600,7 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
547 return 1; 600 return 1;
548 } else if (is_paging(vcpu) && (cr4 & X86_CR4_PAE) 601 } else if (is_paging(vcpu) && (cr4 & X86_CR4_PAE)
549 && ((cr4 ^ old_cr4) & pdptr_bits) 602 && ((cr4 ^ old_cr4) & pdptr_bits)
550 && !load_pdptrs(vcpu, vcpu->arch.cr3)) 603 && !load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3))
551 return 1; 604 return 1;
552 605
553 if (cr4 & X86_CR4_VMXE) 606 if (cr4 & X86_CR4_VMXE)
@@ -580,7 +633,8 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
580 if (is_pae(vcpu)) { 633 if (is_pae(vcpu)) {
581 if (cr3 & CR3_PAE_RESERVED_BITS) 634 if (cr3 & CR3_PAE_RESERVED_BITS)
582 return 1; 635 return 1;
583 if (is_paging(vcpu) && !load_pdptrs(vcpu, cr3)) 636 if (is_paging(vcpu) &&
637 !load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3))
584 return 1; 638 return 1;
585 } 639 }
586 /* 640 /*
@@ -737,7 +791,7 @@ static u32 msrs_to_save[] = {
737#ifdef CONFIG_X86_64 791#ifdef CONFIG_X86_64
738 MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, 792 MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR,
739#endif 793#endif
740 MSR_IA32_TSC, MSR_IA32_PERF_STATUS, MSR_IA32_CR_PAT, MSR_VM_HSAVE_PA 794 MSR_IA32_TSC, MSR_IA32_CR_PAT, MSR_VM_HSAVE_PA
741}; 795};
742 796
743static unsigned num_msrs_to_save; 797static unsigned num_msrs_to_save;
@@ -838,7 +892,7 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
838 892
839 /* 893 /*
840 * The guest calculates current wall clock time by adding 894 * The guest calculates current wall clock time by adding
841 * system time (updated by kvm_write_guest_time below) to the 895 * system time (updated by kvm_guest_time_update below) to the
842 * wall clock specified here. guest system time equals host 896 * wall clock specified here. guest system time equals host
843 * system time for us, thus we must fill in host boot time here. 897 * system time for us, thus we must fill in host boot time here.
844 */ 898 */
@@ -866,65 +920,229 @@ static uint32_t div_frac(uint32_t dividend, uint32_t divisor)
866 return quotient; 920 return quotient;
867} 921}
868 922
869static void kvm_set_time_scale(uint32_t tsc_khz, struct pvclock_vcpu_time_info *hv_clock) 923static void kvm_get_time_scale(uint32_t scaled_khz, uint32_t base_khz,
924 s8 *pshift, u32 *pmultiplier)
870{ 925{
871 uint64_t nsecs = 1000000000LL; 926 uint64_t scaled64;
872 int32_t shift = 0; 927 int32_t shift = 0;
873 uint64_t tps64; 928 uint64_t tps64;
874 uint32_t tps32; 929 uint32_t tps32;
875 930
876 tps64 = tsc_khz * 1000LL; 931 tps64 = base_khz * 1000LL;
877 while (tps64 > nsecs*2) { 932 scaled64 = scaled_khz * 1000LL;
933 while (tps64 > scaled64*2 || tps64 & 0xffffffff00000000ULL) {
878 tps64 >>= 1; 934 tps64 >>= 1;
879 shift--; 935 shift--;
880 } 936 }
881 937
882 tps32 = (uint32_t)tps64; 938 tps32 = (uint32_t)tps64;
883 while (tps32 <= (uint32_t)nsecs) { 939 while (tps32 <= scaled64 || scaled64 & 0xffffffff00000000ULL) {
884 tps32 <<= 1; 940 if (scaled64 & 0xffffffff00000000ULL || tps32 & 0x80000000)
941 scaled64 >>= 1;
942 else
943 tps32 <<= 1;
885 shift++; 944 shift++;
886 } 945 }
887 946
888 hv_clock->tsc_shift = shift; 947 *pshift = shift;
889 hv_clock->tsc_to_system_mul = div_frac(nsecs, tps32); 948 *pmultiplier = div_frac(scaled64, tps32);
890 949
891 pr_debug("%s: tsc_khz %u, tsc_shift %d, tsc_mul %u\n", 950 pr_debug("%s: base_khz %u => %u, shift %d, mul %u\n",
892 __func__, tsc_khz, hv_clock->tsc_shift, 951 __func__, base_khz, scaled_khz, shift, *pmultiplier);
893 hv_clock->tsc_to_system_mul); 952}
953
954static inline u64 get_kernel_ns(void)
955{
956 struct timespec ts;
957
958 WARN_ON(preemptible());
959 ktime_get_ts(&ts);
960 monotonic_to_bootbased(&ts);
961 return timespec_to_ns(&ts);
894} 962}
895 963
896static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz); 964static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz);
965unsigned long max_tsc_khz;
897 966
898static void kvm_write_guest_time(struct kvm_vcpu *v) 967static inline int kvm_tsc_changes_freq(void)
968{
969 int cpu = get_cpu();
970 int ret = !boot_cpu_has(X86_FEATURE_CONSTANT_TSC) &&
971 cpufreq_quick_get(cpu) != 0;
972 put_cpu();
973 return ret;
974}
975
976static inline u64 nsec_to_cycles(u64 nsec)
977{
978 u64 ret;
979
980 WARN_ON(preemptible());
981 if (kvm_tsc_changes_freq())
982 printk_once(KERN_WARNING
983 "kvm: unreliable cycle conversion on adjustable rate TSC\n");
984 ret = nsec * __get_cpu_var(cpu_tsc_khz);
985 do_div(ret, USEC_PER_SEC);
986 return ret;
987}
988
989static void kvm_arch_set_tsc_khz(struct kvm *kvm, u32 this_tsc_khz)
990{
991 /* Compute a scale to convert nanoseconds in TSC cycles */
992 kvm_get_time_scale(this_tsc_khz, NSEC_PER_SEC / 1000,
993 &kvm->arch.virtual_tsc_shift,
994 &kvm->arch.virtual_tsc_mult);
995 kvm->arch.virtual_tsc_khz = this_tsc_khz;
996}
997
998static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns)
999{
1000 u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.last_tsc_nsec,
1001 vcpu->kvm->arch.virtual_tsc_mult,
1002 vcpu->kvm->arch.virtual_tsc_shift);
1003 tsc += vcpu->arch.last_tsc_write;
1004 return tsc;
1005}
1006
1007void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data)
1008{
1009 struct kvm *kvm = vcpu->kvm;
1010 u64 offset, ns, elapsed;
1011 unsigned long flags;
1012 s64 sdiff;
1013
1014 spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags);
1015 offset = data - native_read_tsc();
1016 ns = get_kernel_ns();
1017 elapsed = ns - kvm->arch.last_tsc_nsec;
1018 sdiff = data - kvm->arch.last_tsc_write;
1019 if (sdiff < 0)
1020 sdiff = -sdiff;
1021
1022 /*
1023 * Special case: close write to TSC within 5 seconds of
1024 * another CPU is interpreted as an attempt to synchronize
1025 * The 5 seconds is to accomodate host load / swapping as
1026 * well as any reset of TSC during the boot process.
1027 *
1028 * In that case, for a reliable TSC, we can match TSC offsets,
1029 * or make a best guest using elapsed value.
1030 */
1031 if (sdiff < nsec_to_cycles(5ULL * NSEC_PER_SEC) &&
1032 elapsed < 5ULL * NSEC_PER_SEC) {
1033 if (!check_tsc_unstable()) {
1034 offset = kvm->arch.last_tsc_offset;
1035 pr_debug("kvm: matched tsc offset for %llu\n", data);
1036 } else {
1037 u64 delta = nsec_to_cycles(elapsed);
1038 offset += delta;
1039 pr_debug("kvm: adjusted tsc offset by %llu\n", delta);
1040 }
1041 ns = kvm->arch.last_tsc_nsec;
1042 }
1043 kvm->arch.last_tsc_nsec = ns;
1044 kvm->arch.last_tsc_write = data;
1045 kvm->arch.last_tsc_offset = offset;
1046 kvm_x86_ops->write_tsc_offset(vcpu, offset);
1047 spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
1048
1049 /* Reset of TSC must disable overshoot protection below */
1050 vcpu->arch.hv_clock.tsc_timestamp = 0;
1051 vcpu->arch.last_tsc_write = data;
1052 vcpu->arch.last_tsc_nsec = ns;
1053}
1054EXPORT_SYMBOL_GPL(kvm_write_tsc);
1055
1056static int kvm_guest_time_update(struct kvm_vcpu *v)
899{ 1057{
900 struct timespec ts;
901 unsigned long flags; 1058 unsigned long flags;
902 struct kvm_vcpu_arch *vcpu = &v->arch; 1059 struct kvm_vcpu_arch *vcpu = &v->arch;
903 void *shared_kaddr; 1060 void *shared_kaddr;
904 unsigned long this_tsc_khz; 1061 unsigned long this_tsc_khz;
1062 s64 kernel_ns, max_kernel_ns;
1063 u64 tsc_timestamp;
905 1064
906 if ((!vcpu->time_page)) 1065 /* Keep irq disabled to prevent changes to the clock */
907 return; 1066 local_irq_save(flags);
1067 kvm_get_msr(v, MSR_IA32_TSC, &tsc_timestamp);
1068 kernel_ns = get_kernel_ns();
1069 this_tsc_khz = __get_cpu_var(cpu_tsc_khz);
908 1070
909 this_tsc_khz = get_cpu_var(cpu_tsc_khz); 1071 if (unlikely(this_tsc_khz == 0)) {
910 if (unlikely(vcpu->hv_clock_tsc_khz != this_tsc_khz)) { 1072 local_irq_restore(flags);
911 kvm_set_time_scale(this_tsc_khz, &vcpu->hv_clock); 1073 kvm_make_request(KVM_REQ_CLOCK_UPDATE, v);
912 vcpu->hv_clock_tsc_khz = this_tsc_khz; 1074 return 1;
1075 }
1076
1077 /*
1078 * We may have to catch up the TSC to match elapsed wall clock
1079 * time for two reasons, even if kvmclock is used.
1080 * 1) CPU could have been running below the maximum TSC rate
1081 * 2) Broken TSC compensation resets the base at each VCPU
1082 * entry to avoid unknown leaps of TSC even when running
1083 * again on the same CPU. This may cause apparent elapsed
1084 * time to disappear, and the guest to stand still or run
1085 * very slowly.
1086 */
1087 if (vcpu->tsc_catchup) {
1088 u64 tsc = compute_guest_tsc(v, kernel_ns);
1089 if (tsc > tsc_timestamp) {
1090 kvm_x86_ops->adjust_tsc_offset(v, tsc - tsc_timestamp);
1091 tsc_timestamp = tsc;
1092 }
913 } 1093 }
914 put_cpu_var(cpu_tsc_khz);
915 1094
916 /* Keep irq disabled to prevent changes to the clock */
917 local_irq_save(flags);
918 kvm_get_msr(v, MSR_IA32_TSC, &vcpu->hv_clock.tsc_timestamp);
919 ktime_get_ts(&ts);
920 monotonic_to_bootbased(&ts);
921 local_irq_restore(flags); 1095 local_irq_restore(flags);
922 1096
923 /* With all the info we got, fill in the values */ 1097 if (!vcpu->time_page)
1098 return 0;
924 1099
925 vcpu->hv_clock.system_time = ts.tv_nsec + 1100 /*
926 (NSEC_PER_SEC * (u64)ts.tv_sec) + v->kvm->arch.kvmclock_offset; 1101 * Time as measured by the TSC may go backwards when resetting the base
1102 * tsc_timestamp. The reason for this is that the TSC resolution is
1103 * higher than the resolution of the other clock scales. Thus, many
1104 * possible measurments of the TSC correspond to one measurement of any
1105 * other clock, and so a spread of values is possible. This is not a
1106 * problem for the computation of the nanosecond clock; with TSC rates
1107 * around 1GHZ, there can only be a few cycles which correspond to one
1108 * nanosecond value, and any path through this code will inevitably
1109 * take longer than that. However, with the kernel_ns value itself,
1110 * the precision may be much lower, down to HZ granularity. If the
1111 * first sampling of TSC against kernel_ns ends in the low part of the
1112 * range, and the second in the high end of the range, we can get:
1113 *
1114 * (TSC - offset_low) * S + kns_old > (TSC - offset_high) * S + kns_new
1115 *
1116 * As the sampling errors potentially range in the thousands of cycles,
1117 * it is possible such a time value has already been observed by the
1118 * guest. To protect against this, we must compute the system time as
1119 * observed by the guest and ensure the new system time is greater.
1120 */
1121 max_kernel_ns = 0;
1122 if (vcpu->hv_clock.tsc_timestamp && vcpu->last_guest_tsc) {
1123 max_kernel_ns = vcpu->last_guest_tsc -
1124 vcpu->hv_clock.tsc_timestamp;
1125 max_kernel_ns = pvclock_scale_delta(max_kernel_ns,
1126 vcpu->hv_clock.tsc_to_system_mul,
1127 vcpu->hv_clock.tsc_shift);
1128 max_kernel_ns += vcpu->last_kernel_ns;
1129 }
927 1130
1131 if (unlikely(vcpu->hw_tsc_khz != this_tsc_khz)) {
1132 kvm_get_time_scale(NSEC_PER_SEC / 1000, this_tsc_khz,
1133 &vcpu->hv_clock.tsc_shift,
1134 &vcpu->hv_clock.tsc_to_system_mul);
1135 vcpu->hw_tsc_khz = this_tsc_khz;
1136 }
1137
1138 if (max_kernel_ns > kernel_ns)
1139 kernel_ns = max_kernel_ns;
1140
1141 /* With all the info we got, fill in the values */
1142 vcpu->hv_clock.tsc_timestamp = tsc_timestamp;
1143 vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;
1144 vcpu->last_kernel_ns = kernel_ns;
1145 vcpu->last_guest_tsc = tsc_timestamp;
928 vcpu->hv_clock.flags = 0; 1146 vcpu->hv_clock.flags = 0;
929 1147
930 /* 1148 /*
@@ -942,16 +1160,7 @@ static void kvm_write_guest_time(struct kvm_vcpu *v)
942 kunmap_atomic(shared_kaddr, KM_USER0); 1160 kunmap_atomic(shared_kaddr, KM_USER0);
943 1161
944 mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT); 1162 mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
945} 1163 return 0;
946
947static int kvm_request_guest_time_update(struct kvm_vcpu *v)
948{
949 struct kvm_vcpu_arch *vcpu = &v->arch;
950
951 if (!vcpu->time_page)
952 return 0;
953 kvm_make_request(KVM_REQ_KVMCLOCK_UPDATE, v);
954 return 1;
955} 1164}
956 1165
957static bool msr_mtrr_valid(unsigned msr) 1166static bool msr_mtrr_valid(unsigned msr)
@@ -1277,6 +1486,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1277 } 1486 }
1278 1487
1279 vcpu->arch.time = data; 1488 vcpu->arch.time = data;
1489 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
1280 1490
1281 /* we verify if the enable bit is set... */ 1491 /* we verify if the enable bit is set... */
1282 if (!(data & 1)) 1492 if (!(data & 1))
@@ -1292,8 +1502,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1292 kvm_release_page_clean(vcpu->arch.time_page); 1502 kvm_release_page_clean(vcpu->arch.time_page);
1293 vcpu->arch.time_page = NULL; 1503 vcpu->arch.time_page = NULL;
1294 } 1504 }
1295
1296 kvm_request_guest_time_update(vcpu);
1297 break; 1505 break;
1298 } 1506 }
1299 case MSR_IA32_MCG_CTL: 1507 case MSR_IA32_MCG_CTL:
@@ -1330,6 +1538,16 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1330 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: " 1538 pr_unimpl(vcpu, "unimplemented perfctr wrmsr: "
1331 "0x%x data 0x%llx\n", msr, data); 1539 "0x%x data 0x%llx\n", msr, data);
1332 break; 1540 break;
1541 case MSR_K7_CLK_CTL:
1542 /*
1543 * Ignore all writes to this no longer documented MSR.
1544 * Writes are only relevant for old K7 processors,
1545 * all pre-dating SVM, but a recommended workaround from
1546 * AMD for these chips. It is possible to speicify the
1547 * affected processor models on the command line, hence
1548 * the need to ignore the workaround.
1549 */
1550 break;
1333 case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15: 1551 case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15:
1334 if (kvm_hv_msr_partition_wide(msr)) { 1552 if (kvm_hv_msr_partition_wide(msr)) {
1335 int r; 1553 int r;
@@ -1522,6 +1740,20 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1522 case 0xcd: /* fsb frequency */ 1740 case 0xcd: /* fsb frequency */
1523 data = 3; 1741 data = 3;
1524 break; 1742 break;
1743 /*
1744 * MSR_EBC_FREQUENCY_ID
1745 * Conservative value valid for even the basic CPU models.
1746 * Models 0,1: 000 in bits 23:21 indicating a bus speed of
1747 * 100MHz, model 2 000 in bits 18:16 indicating 100MHz,
1748 * and 266MHz for model 3, or 4. Set Core Clock
1749 * Frequency to System Bus Frequency Ratio to 1 (bits
1750 * 31:24) even though these are only valid for CPU
1751 * models > 2, however guests may end up dividing or
1752 * multiplying by zero otherwise.
1753 */
1754 case MSR_EBC_FREQUENCY_ID:
1755 data = 1 << 24;
1756 break;
1525 case MSR_IA32_APICBASE: 1757 case MSR_IA32_APICBASE:
1526 data = kvm_get_apic_base(vcpu); 1758 data = kvm_get_apic_base(vcpu);
1527 break; 1759 break;
@@ -1555,6 +1787,18 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1555 case MSR_IA32_MCG_STATUS: 1787 case MSR_IA32_MCG_STATUS:
1556 case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1: 1788 case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1:
1557 return get_msr_mce(vcpu, msr, pdata); 1789 return get_msr_mce(vcpu, msr, pdata);
1790 case MSR_K7_CLK_CTL:
1791 /*
1792 * Provide expected ramp-up count for K7. All other
1793 * are set to zero, indicating minimum divisors for
1794 * every field.
1795 *
1796 * This prevents guest kernels on AMD host with CPU
1797 * type 6, model 8 and higher from exploding due to
1798 * the rdmsr failing.
1799 */
1800 data = 0x20000000;
1801 break;
1558 case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15: 1802 case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15:
1559 if (kvm_hv_msr_partition_wide(msr)) { 1803 if (kvm_hv_msr_partition_wide(msr)) {
1560 int r; 1804 int r;
@@ -1808,19 +2052,28 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
1808 } 2052 }
1809 2053
1810 kvm_x86_ops->vcpu_load(vcpu, cpu); 2054 kvm_x86_ops->vcpu_load(vcpu, cpu);
1811 if (unlikely(per_cpu(cpu_tsc_khz, cpu) == 0)) { 2055 if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) {
1812 unsigned long khz = cpufreq_quick_get(cpu); 2056 /* Make sure TSC doesn't go backwards */
1813 if (!khz) 2057 s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 :
1814 khz = tsc_khz; 2058 native_read_tsc() - vcpu->arch.last_host_tsc;
1815 per_cpu(cpu_tsc_khz, cpu) = khz; 2059 if (tsc_delta < 0)
2060 mark_tsc_unstable("KVM discovered backwards TSC");
2061 if (check_tsc_unstable()) {
2062 kvm_x86_ops->adjust_tsc_offset(vcpu, -tsc_delta);
2063 vcpu->arch.tsc_catchup = 1;
2064 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
2065 }
2066 if (vcpu->cpu != cpu)
2067 kvm_migrate_timers(vcpu);
2068 vcpu->cpu = cpu;
1816 } 2069 }
1817 kvm_request_guest_time_update(vcpu);
1818} 2070}
1819 2071
1820void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 2072void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
1821{ 2073{
1822 kvm_x86_ops->vcpu_put(vcpu); 2074 kvm_x86_ops->vcpu_put(vcpu);
1823 kvm_put_guest_fpu(vcpu); 2075 kvm_put_guest_fpu(vcpu);
2076 vcpu->arch.last_host_tsc = native_read_tsc();
1824} 2077}
1825 2078
1826static int is_efer_nx(void) 2079static int is_efer_nx(void)
@@ -1991,13 +2244,14 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1991 0 /* Reserved */ | F(CX16) | 0 /* xTPR Update, PDCM */ | 2244 0 /* Reserved */ | F(CX16) | 0 /* xTPR Update, PDCM */ |
1992 0 /* Reserved, DCA */ | F(XMM4_1) | 2245 0 /* Reserved, DCA */ | F(XMM4_1) |
1993 F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) | 2246 F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) |
1994 0 /* Reserved, AES */ | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX); 2247 0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
2248 F(F16C);
1995 /* cpuid 0x80000001.ecx */ 2249 /* cpuid 0x80000001.ecx */
1996 const u32 kvm_supported_word6_x86_features = 2250 const u32 kvm_supported_word6_x86_features =
1997 F(LAHF_LM) | F(CMP_LEGACY) | F(SVM) | 0 /* ExtApicSpace */ | 2251 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
1998 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | 2252 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
1999 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(SSE5) | 2253 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(XOP) |
2000 0 /* SKINIT */ | 0 /* WDT */; 2254 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
2001 2255
2002 /* all calls to cpuid_count() should be made on the same cpu */ 2256 /* all calls to cpuid_count() should be made on the same cpu */
2003 get_cpu(); 2257 get_cpu();
@@ -2203,6 +2457,7 @@ static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
2203 return -ENXIO; 2457 return -ENXIO;
2204 2458
2205 kvm_queue_interrupt(vcpu, irq->irq, false); 2459 kvm_queue_interrupt(vcpu, irq->irq, false);
2460 kvm_make_request(KVM_REQ_EVENT, vcpu);
2206 2461
2207 return 0; 2462 return 0;
2208} 2463}
@@ -2356,6 +2611,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
2356 if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR) 2611 if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
2357 vcpu->arch.sipi_vector = events->sipi_vector; 2612 vcpu->arch.sipi_vector = events->sipi_vector;
2358 2613
2614 kvm_make_request(KVM_REQ_EVENT, vcpu);
2615
2359 return 0; 2616 return 0;
2360} 2617}
2361 2618
@@ -2759,7 +3016,7 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm,
2759 3016
2760static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) 3017static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
2761{ 3018{
2762 return kvm->arch.n_alloc_mmu_pages; 3019 return kvm->arch.n_max_mmu_pages;
2763} 3020}
2764 3021
2765static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) 3022static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
@@ -2795,18 +3052,18 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
2795 r = 0; 3052 r = 0;
2796 switch (chip->chip_id) { 3053 switch (chip->chip_id) {
2797 case KVM_IRQCHIP_PIC_MASTER: 3054 case KVM_IRQCHIP_PIC_MASTER:
2798 raw_spin_lock(&pic_irqchip(kvm)->lock); 3055 spin_lock(&pic_irqchip(kvm)->lock);
2799 memcpy(&pic_irqchip(kvm)->pics[0], 3056 memcpy(&pic_irqchip(kvm)->pics[0],
2800 &chip->chip.pic, 3057 &chip->chip.pic,
2801 sizeof(struct kvm_pic_state)); 3058 sizeof(struct kvm_pic_state));
2802 raw_spin_unlock(&pic_irqchip(kvm)->lock); 3059 spin_unlock(&pic_irqchip(kvm)->lock);
2803 break; 3060 break;
2804 case KVM_IRQCHIP_PIC_SLAVE: 3061 case KVM_IRQCHIP_PIC_SLAVE:
2805 raw_spin_lock(&pic_irqchip(kvm)->lock); 3062 spin_lock(&pic_irqchip(kvm)->lock);
2806 memcpy(&pic_irqchip(kvm)->pics[1], 3063 memcpy(&pic_irqchip(kvm)->pics[1],
2807 &chip->chip.pic, 3064 &chip->chip.pic,
2808 sizeof(struct kvm_pic_state)); 3065 sizeof(struct kvm_pic_state));
2809 raw_spin_unlock(&pic_irqchip(kvm)->lock); 3066 spin_unlock(&pic_irqchip(kvm)->lock);
2810 break; 3067 break;
2811 case KVM_IRQCHIP_IOAPIC: 3068 case KVM_IRQCHIP_IOAPIC:
2812 r = kvm_set_ioapic(kvm, &chip->chip.ioapic); 3069 r = kvm_set_ioapic(kvm, &chip->chip.ioapic);
@@ -3200,7 +3457,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
3200 break; 3457 break;
3201 } 3458 }
3202 case KVM_SET_CLOCK: { 3459 case KVM_SET_CLOCK: {
3203 struct timespec now;
3204 struct kvm_clock_data user_ns; 3460 struct kvm_clock_data user_ns;
3205 u64 now_ns; 3461 u64 now_ns;
3206 s64 delta; 3462 s64 delta;
@@ -3214,20 +3470,21 @@ long kvm_arch_vm_ioctl(struct file *filp,
3214 goto out; 3470 goto out;
3215 3471
3216 r = 0; 3472 r = 0;
3217 ktime_get_ts(&now); 3473 local_irq_disable();
3218 now_ns = timespec_to_ns(&now); 3474 now_ns = get_kernel_ns();
3219 delta = user_ns.clock - now_ns; 3475 delta = user_ns.clock - now_ns;
3476 local_irq_enable();
3220 kvm->arch.kvmclock_offset = delta; 3477 kvm->arch.kvmclock_offset = delta;
3221 break; 3478 break;
3222 } 3479 }
3223 case KVM_GET_CLOCK: { 3480 case KVM_GET_CLOCK: {
3224 struct timespec now;
3225 struct kvm_clock_data user_ns; 3481 struct kvm_clock_data user_ns;
3226 u64 now_ns; 3482 u64 now_ns;
3227 3483
3228 ktime_get_ts(&now); 3484 local_irq_disable();
3229 now_ns = timespec_to_ns(&now); 3485 now_ns = get_kernel_ns();
3230 user_ns.clock = kvm->arch.kvmclock_offset + now_ns; 3486 user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
3487 local_irq_enable();
3231 user_ns.flags = 0; 3488 user_ns.flags = 0;
3232 3489
3233 r = -EFAULT; 3490 r = -EFAULT;
@@ -3291,30 +3548,51 @@ void kvm_get_segment(struct kvm_vcpu *vcpu,
3291 kvm_x86_ops->get_segment(vcpu, var, seg); 3548 kvm_x86_ops->get_segment(vcpu, var, seg);
3292} 3549}
3293 3550
3551static gpa_t translate_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
3552{
3553 return gpa;
3554}
3555
3556static gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
3557{
3558 gpa_t t_gpa;
3559 u32 error;
3560
3561 BUG_ON(!mmu_is_nested(vcpu));
3562
3563 /* NPT walks are always user-walks */
3564 access |= PFERR_USER_MASK;
3565 t_gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gpa, access, &error);
3566 if (t_gpa == UNMAPPED_GVA)
3567 vcpu->arch.fault.nested = true;
3568
3569 return t_gpa;
3570}
3571
3294gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3572gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3295{ 3573{
3296 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3574 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
3297 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3575 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3298} 3576}
3299 3577
3300 gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3578 gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3301{ 3579{
3302 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3580 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
3303 access |= PFERR_FETCH_MASK; 3581 access |= PFERR_FETCH_MASK;
3304 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3582 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3305} 3583}
3306 3584
3307gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3585gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3308{ 3586{
3309 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3587 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
3310 access |= PFERR_WRITE_MASK; 3588 access |= PFERR_WRITE_MASK;
3311 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3589 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3312} 3590}
3313 3591
3314/* uses this to access any guest's mapped memory without checking CPL */ 3592/* uses this to access any guest's mapped memory without checking CPL */
3315gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3593gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3316{ 3594{
3317 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, 0, error); 3595 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, 0, error);
3318} 3596}
3319 3597
3320static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes, 3598static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
@@ -3325,7 +3603,8 @@ static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
3325 int r = X86EMUL_CONTINUE; 3603 int r = X86EMUL_CONTINUE;
3326 3604
3327 while (bytes) { 3605 while (bytes) {
3328 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr, access, error); 3606 gpa_t gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr, access,
3607 error);
3329 unsigned offset = addr & (PAGE_SIZE-1); 3608 unsigned offset = addr & (PAGE_SIZE-1);
3330 unsigned toread = min(bytes, (unsigned)PAGE_SIZE - offset); 3609 unsigned toread = min(bytes, (unsigned)PAGE_SIZE - offset);
3331 int ret; 3610 int ret;
@@ -3380,8 +3659,9 @@ static int kvm_write_guest_virt_system(gva_t addr, void *val,
3380 int r = X86EMUL_CONTINUE; 3659 int r = X86EMUL_CONTINUE;
3381 3660
3382 while (bytes) { 3661 while (bytes) {
3383 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr, 3662 gpa_t gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr,
3384 PFERR_WRITE_MASK, error); 3663 PFERR_WRITE_MASK,
3664 error);
3385 unsigned offset = addr & (PAGE_SIZE-1); 3665 unsigned offset = addr & (PAGE_SIZE-1);
3386 unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset); 3666 unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset);
3387 int ret; 3667 int ret;
@@ -3623,7 +3903,7 @@ static int emulator_pio_in_emulated(int size, unsigned short port, void *val,
3623 if (vcpu->arch.pio.count) 3903 if (vcpu->arch.pio.count)
3624 goto data_avail; 3904 goto data_avail;
3625 3905
3626 trace_kvm_pio(1, port, size, 1); 3906 trace_kvm_pio(0, port, size, 1);
3627 3907
3628 vcpu->arch.pio.port = port; 3908 vcpu->arch.pio.port = port;
3629 vcpu->arch.pio.in = 1; 3909 vcpu->arch.pio.in = 1;
@@ -3651,7 +3931,7 @@ static int emulator_pio_out_emulated(int size, unsigned short port,
3651 const void *val, unsigned int count, 3931 const void *val, unsigned int count,
3652 struct kvm_vcpu *vcpu) 3932 struct kvm_vcpu *vcpu)
3653{ 3933{
3654 trace_kvm_pio(0, port, size, 1); 3934 trace_kvm_pio(1, port, size, 1);
3655 3935
3656 vcpu->arch.pio.port = port; 3936 vcpu->arch.pio.port = port;
3657 vcpu->arch.pio.in = 0; 3937 vcpu->arch.pio.in = 0;
@@ -3790,6 +4070,11 @@ static void emulator_get_gdt(struct desc_ptr *dt, struct kvm_vcpu *vcpu)
3790 kvm_x86_ops->get_gdt(vcpu, dt); 4070 kvm_x86_ops->get_gdt(vcpu, dt);
3791} 4071}
3792 4072
4073static void emulator_get_idt(struct desc_ptr *dt, struct kvm_vcpu *vcpu)
4074{
4075 kvm_x86_ops->get_idt(vcpu, dt);
4076}
4077
3793static unsigned long emulator_get_cached_segment_base(int seg, 4078static unsigned long emulator_get_cached_segment_base(int seg,
3794 struct kvm_vcpu *vcpu) 4079 struct kvm_vcpu *vcpu)
3795{ 4080{
@@ -3883,6 +4168,7 @@ static struct x86_emulate_ops emulate_ops = {
3883 .set_segment_selector = emulator_set_segment_selector, 4168 .set_segment_selector = emulator_set_segment_selector,
3884 .get_cached_segment_base = emulator_get_cached_segment_base, 4169 .get_cached_segment_base = emulator_get_cached_segment_base,
3885 .get_gdt = emulator_get_gdt, 4170 .get_gdt = emulator_get_gdt,
4171 .get_idt = emulator_get_idt,
3886 .get_cr = emulator_get_cr, 4172 .get_cr = emulator_get_cr,
3887 .set_cr = emulator_set_cr, 4173 .set_cr = emulator_set_cr,
3888 .cpl = emulator_get_cpl, 4174 .cpl = emulator_get_cpl,
@@ -3918,13 +4204,64 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu)
3918{ 4204{
3919 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; 4205 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
3920 if (ctxt->exception == PF_VECTOR) 4206 if (ctxt->exception == PF_VECTOR)
3921 kvm_inject_page_fault(vcpu, ctxt->cr2, ctxt->error_code); 4207 kvm_propagate_fault(vcpu);
3922 else if (ctxt->error_code_valid) 4208 else if (ctxt->error_code_valid)
3923 kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code); 4209 kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code);
3924 else 4210 else
3925 kvm_queue_exception(vcpu, ctxt->exception); 4211 kvm_queue_exception(vcpu, ctxt->exception);
3926} 4212}
3927 4213
4214static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
4215{
4216 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
4217 int cs_db, cs_l;
4218
4219 cache_all_regs(vcpu);
4220
4221 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
4222
4223 vcpu->arch.emulate_ctxt.vcpu = vcpu;
4224 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
4225 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
4226 vcpu->arch.emulate_ctxt.mode =
4227 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
4228 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
4229 ? X86EMUL_MODE_VM86 : cs_l
4230 ? X86EMUL_MODE_PROT64 : cs_db
4231 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
4232 memset(c, 0, sizeof(struct decode_cache));
4233 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
4234}
4235
4236int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq)
4237{
4238 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
4239 int ret;
4240
4241 init_emulate_ctxt(vcpu);
4242
4243 vcpu->arch.emulate_ctxt.decode.op_bytes = 2;
4244 vcpu->arch.emulate_ctxt.decode.ad_bytes = 2;
4245 vcpu->arch.emulate_ctxt.decode.eip = vcpu->arch.emulate_ctxt.eip;
4246 ret = emulate_int_real(&vcpu->arch.emulate_ctxt, &emulate_ops, irq);
4247
4248 if (ret != X86EMUL_CONTINUE)
4249 return EMULATE_FAIL;
4250
4251 vcpu->arch.emulate_ctxt.eip = c->eip;
4252 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4253 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4254 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4255
4256 if (irq == NMI_VECTOR)
4257 vcpu->arch.nmi_pending = false;
4258 else
4259 vcpu->arch.interrupt.pending = false;
4260
4261 return EMULATE_DONE;
4262}
4263EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt);
4264
3928static int handle_emulation_failure(struct kvm_vcpu *vcpu) 4265static int handle_emulation_failure(struct kvm_vcpu *vcpu)
3929{ 4266{
3930 ++vcpu->stat.insn_emulation_fail; 4267 ++vcpu->stat.insn_emulation_fail;
@@ -3981,24 +4318,15 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
3981 cache_all_regs(vcpu); 4318 cache_all_regs(vcpu);
3982 4319
3983 if (!(emulation_type & EMULTYPE_NO_DECODE)) { 4320 if (!(emulation_type & EMULTYPE_NO_DECODE)) {
3984 int cs_db, cs_l; 4321 init_emulate_ctxt(vcpu);
3985 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
3986
3987 vcpu->arch.emulate_ctxt.vcpu = vcpu;
3988 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
3989 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
3990 vcpu->arch.emulate_ctxt.mode =
3991 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
3992 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
3993 ? X86EMUL_MODE_VM86 : cs_l
3994 ? X86EMUL_MODE_PROT64 : cs_db
3995 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
3996 memset(c, 0, sizeof(struct decode_cache));
3997 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
3998 vcpu->arch.emulate_ctxt.interruptibility = 0; 4322 vcpu->arch.emulate_ctxt.interruptibility = 0;
3999 vcpu->arch.emulate_ctxt.exception = -1; 4323 vcpu->arch.emulate_ctxt.exception = -1;
4324 vcpu->arch.emulate_ctxt.perm_ok = false;
4325
4326 r = x86_decode_insn(&vcpu->arch.emulate_ctxt);
4327 if (r == X86EMUL_PROPAGATE_FAULT)
4328 goto done;
4000 4329
4001 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
4002 trace_kvm_emulate_insn_start(vcpu); 4330 trace_kvm_emulate_insn_start(vcpu);
4003 4331
4004 /* Only allow emulation of specific instructions on #UD 4332 /* Only allow emulation of specific instructions on #UD
@@ -4048,41 +4376,39 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
4048 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); 4376 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
4049 4377
4050restart: 4378restart:
4051 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt, &emulate_ops); 4379 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt);
4052 4380
4053 if (r) { /* emulation failed */ 4381 if (r == EMULATION_FAILED) {
4054 if (reexecute_instruction(vcpu, cr2)) 4382 if (reexecute_instruction(vcpu, cr2))
4055 return EMULATE_DONE; 4383 return EMULATE_DONE;
4056 4384
4057 return handle_emulation_failure(vcpu); 4385 return handle_emulation_failure(vcpu);
4058 } 4386 }
4059 4387
4060 toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility); 4388done:
4061 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4062 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4063 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4064
4065 if (vcpu->arch.emulate_ctxt.exception >= 0) { 4389 if (vcpu->arch.emulate_ctxt.exception >= 0) {
4066 inject_emulated_exception(vcpu); 4390 inject_emulated_exception(vcpu);
4067 return EMULATE_DONE; 4391 r = EMULATE_DONE;
4068 } 4392 } else if (vcpu->arch.pio.count) {
4069
4070 if (vcpu->arch.pio.count) {
4071 if (!vcpu->arch.pio.in) 4393 if (!vcpu->arch.pio.in)
4072 vcpu->arch.pio.count = 0; 4394 vcpu->arch.pio.count = 0;
4073 return EMULATE_DO_MMIO; 4395 r = EMULATE_DO_MMIO;
4074 } 4396 } else if (vcpu->mmio_needed) {
4075
4076 if (vcpu->mmio_needed) {
4077 if (vcpu->mmio_is_write) 4397 if (vcpu->mmio_is_write)
4078 vcpu->mmio_needed = 0; 4398 vcpu->mmio_needed = 0;
4079 return EMULATE_DO_MMIO; 4399 r = EMULATE_DO_MMIO;
4080 } 4400 } else if (r == EMULATION_RESTART)
4081
4082 if (vcpu->arch.emulate_ctxt.restart)
4083 goto restart; 4401 goto restart;
4402 else
4403 r = EMULATE_DONE;
4084 4404
4085 return EMULATE_DONE; 4405 toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility);
4406 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4407 kvm_make_request(KVM_REQ_EVENT, vcpu);
4408 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4409 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4410
4411 return r;
4086} 4412}
4087EXPORT_SYMBOL_GPL(emulate_instruction); 4413EXPORT_SYMBOL_GPL(emulate_instruction);
4088 4414
@@ -4096,9 +4422,23 @@ int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port)
4096} 4422}
4097EXPORT_SYMBOL_GPL(kvm_fast_pio_out); 4423EXPORT_SYMBOL_GPL(kvm_fast_pio_out);
4098 4424
4099static void bounce_off(void *info) 4425static void tsc_bad(void *info)
4426{
4427 __get_cpu_var(cpu_tsc_khz) = 0;
4428}
4429
4430static void tsc_khz_changed(void *data)
4100{ 4431{
4101 /* nothing */ 4432 struct cpufreq_freqs *freq = data;
4433 unsigned long khz = 0;
4434
4435 if (data)
4436 khz = freq->new;
4437 else if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
4438 khz = cpufreq_quick_get(raw_smp_processor_id());
4439 if (!khz)
4440 khz = tsc_khz;
4441 __get_cpu_var(cpu_tsc_khz) = khz;
4102} 4442}
4103 4443
4104static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 4444static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
@@ -4109,21 +4449,60 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
4109 struct kvm_vcpu *vcpu; 4449 struct kvm_vcpu *vcpu;
4110 int i, send_ipi = 0; 4450 int i, send_ipi = 0;
4111 4451
4452 /*
4453 * We allow guests to temporarily run on slowing clocks,
4454 * provided we notify them after, or to run on accelerating
4455 * clocks, provided we notify them before. Thus time never
4456 * goes backwards.
4457 *
4458 * However, we have a problem. We can't atomically update
4459 * the frequency of a given CPU from this function; it is
4460 * merely a notifier, which can be called from any CPU.
4461 * Changing the TSC frequency at arbitrary points in time
4462 * requires a recomputation of local variables related to
4463 * the TSC for each VCPU. We must flag these local variables
4464 * to be updated and be sure the update takes place with the
4465 * new frequency before any guests proceed.
4466 *
4467 * Unfortunately, the combination of hotplug CPU and frequency
4468 * change creates an intractable locking scenario; the order
4469 * of when these callouts happen is undefined with respect to
4470 * CPU hotplug, and they can race with each other. As such,
4471 * merely setting per_cpu(cpu_tsc_khz) = X during a hotadd is
4472 * undefined; you can actually have a CPU frequency change take
4473 * place in between the computation of X and the setting of the
4474 * variable. To protect against this problem, all updates of
4475 * the per_cpu tsc_khz variable are done in an interrupt
4476 * protected IPI, and all callers wishing to update the value
4477 * must wait for a synchronous IPI to complete (which is trivial
4478 * if the caller is on the CPU already). This establishes the
4479 * necessary total order on variable updates.
4480 *
4481 * Note that because a guest time update may take place
4482 * anytime after the setting of the VCPU's request bit, the
4483 * correct TSC value must be set before the request. However,
4484 * to ensure the update actually makes it to any guest which
4485 * starts running in hardware virtualization between the set
4486 * and the acquisition of the spinlock, we must also ping the
4487 * CPU after setting the request bit.
4488 *
4489 */
4490
4112 if (val == CPUFREQ_PRECHANGE && freq->old > freq->new) 4491 if (val == CPUFREQ_PRECHANGE && freq->old > freq->new)
4113 return 0; 4492 return 0;
4114 if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new) 4493 if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new)
4115 return 0; 4494 return 0;
4116 per_cpu(cpu_tsc_khz, freq->cpu) = freq->new; 4495
4496 smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
4117 4497
4118 spin_lock(&kvm_lock); 4498 spin_lock(&kvm_lock);
4119 list_for_each_entry(kvm, &vm_list, vm_list) { 4499 list_for_each_entry(kvm, &vm_list, vm_list) {
4120 kvm_for_each_vcpu(i, vcpu, kvm) { 4500 kvm_for_each_vcpu(i, vcpu, kvm) {
4121 if (vcpu->cpu != freq->cpu) 4501 if (vcpu->cpu != freq->cpu)
4122 continue; 4502 continue;
4123 if (!kvm_request_guest_time_update(vcpu)) 4503 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
4124 continue;
4125 if (vcpu->cpu != smp_processor_id()) 4504 if (vcpu->cpu != smp_processor_id())
4126 send_ipi++; 4505 send_ipi = 1;
4127 } 4506 }
4128 } 4507 }
4129 spin_unlock(&kvm_lock); 4508 spin_unlock(&kvm_lock);
@@ -4141,32 +4520,57 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
4141 * guest context is entered kvmclock will be updated, 4520 * guest context is entered kvmclock will be updated,
4142 * so the guest will not see stale values. 4521 * so the guest will not see stale values.
4143 */ 4522 */
4144 smp_call_function_single(freq->cpu, bounce_off, NULL, 1); 4523 smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
4145 } 4524 }
4146 return 0; 4525 return 0;
4147} 4526}
4148 4527
4149static struct notifier_block kvmclock_cpufreq_notifier_block = { 4528static struct notifier_block kvmclock_cpufreq_notifier_block = {
4150 .notifier_call = kvmclock_cpufreq_notifier 4529 .notifier_call = kvmclock_cpufreq_notifier
4530};
4531
4532static int kvmclock_cpu_notifier(struct notifier_block *nfb,
4533 unsigned long action, void *hcpu)
4534{
4535 unsigned int cpu = (unsigned long)hcpu;
4536
4537 switch (action) {
4538 case CPU_ONLINE:
4539 case CPU_DOWN_FAILED:
4540 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
4541 break;
4542 case CPU_DOWN_PREPARE:
4543 smp_call_function_single(cpu, tsc_bad, NULL, 1);
4544 break;
4545 }
4546 return NOTIFY_OK;
4547}
4548
4549static struct notifier_block kvmclock_cpu_notifier_block = {
4550 .notifier_call = kvmclock_cpu_notifier,
4551 .priority = -INT_MAX
4151}; 4552};
4152 4553
4153static void kvm_timer_init(void) 4554static void kvm_timer_init(void)
4154{ 4555{
4155 int cpu; 4556 int cpu;
4156 4557
4558 max_tsc_khz = tsc_khz;
4559 register_hotcpu_notifier(&kvmclock_cpu_notifier_block);
4157 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) { 4560 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
4561#ifdef CONFIG_CPU_FREQ
4562 struct cpufreq_policy policy;
4563 memset(&policy, 0, sizeof(policy));
4564 cpufreq_get_policy(&policy, get_cpu());
4565 if (policy.cpuinfo.max_freq)
4566 max_tsc_khz = policy.cpuinfo.max_freq;
4567#endif
4158 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, 4568 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
4159 CPUFREQ_TRANSITION_NOTIFIER); 4569 CPUFREQ_TRANSITION_NOTIFIER);
4160 for_each_online_cpu(cpu) {
4161 unsigned long khz = cpufreq_get(cpu);
4162 if (!khz)
4163 khz = tsc_khz;
4164 per_cpu(cpu_tsc_khz, cpu) = khz;
4165 }
4166 } else {
4167 for_each_possible_cpu(cpu)
4168 per_cpu(cpu_tsc_khz, cpu) = tsc_khz;
4169 } 4570 }
4571 pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz);
4572 for_each_online_cpu(cpu)
4573 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
4170} 4574}
4171 4575
4172static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu); 4576static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu);
@@ -4268,6 +4672,7 @@ void kvm_arch_exit(void)
4268 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 4672 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
4269 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, 4673 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block,
4270 CPUFREQ_TRANSITION_NOTIFIER); 4674 CPUFREQ_TRANSITION_NOTIFIER);
4675 unregister_hotcpu_notifier(&kvmclock_cpu_notifier_block);
4271 kvm_x86_ops = NULL; 4676 kvm_x86_ops = NULL;
4272 kvm_mmu_module_exit(); 4677 kvm_mmu_module_exit();
4273} 4678}
@@ -4683,8 +5088,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4683 kvm_mmu_unload(vcpu); 5088 kvm_mmu_unload(vcpu);
4684 if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu)) 5089 if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))
4685 __kvm_migrate_timers(vcpu); 5090 __kvm_migrate_timers(vcpu);
4686 if (kvm_check_request(KVM_REQ_KVMCLOCK_UPDATE, vcpu)) 5091 if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) {
4687 kvm_write_guest_time(vcpu); 5092 r = kvm_guest_time_update(vcpu);
5093 if (unlikely(r))
5094 goto out;
5095 }
4688 if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu)) 5096 if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu))
4689 kvm_mmu_sync_roots(vcpu); 5097 kvm_mmu_sync_roots(vcpu);
4690 if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) 5098 if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
@@ -4709,6 +5117,21 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4709 if (unlikely(r)) 5117 if (unlikely(r))
4710 goto out; 5118 goto out;
4711 5119
5120 if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
5121 inject_pending_event(vcpu);
5122
5123 /* enable NMI/IRQ window open exits if needed */
5124 if (vcpu->arch.nmi_pending)
5125 kvm_x86_ops->enable_nmi_window(vcpu);
5126 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
5127 kvm_x86_ops->enable_irq_window(vcpu);
5128
5129 if (kvm_lapic_enabled(vcpu)) {
5130 update_cr8_intercept(vcpu);
5131 kvm_lapic_sync_to_vapic(vcpu);
5132 }
5133 }
5134
4712 preempt_disable(); 5135 preempt_disable();
4713 5136
4714 kvm_x86_ops->prepare_guest_switch(vcpu); 5137 kvm_x86_ops->prepare_guest_switch(vcpu);
@@ -4727,23 +5150,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4727 smp_wmb(); 5150 smp_wmb();
4728 local_irq_enable(); 5151 local_irq_enable();
4729 preempt_enable(); 5152 preempt_enable();
5153 kvm_x86_ops->cancel_injection(vcpu);
4730 r = 1; 5154 r = 1;
4731 goto out; 5155 goto out;
4732 } 5156 }
4733 5157
4734 inject_pending_event(vcpu);
4735
4736 /* enable NMI/IRQ window open exits if needed */
4737 if (vcpu->arch.nmi_pending)
4738 kvm_x86_ops->enable_nmi_window(vcpu);
4739 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
4740 kvm_x86_ops->enable_irq_window(vcpu);
4741
4742 if (kvm_lapic_enabled(vcpu)) {
4743 update_cr8_intercept(vcpu);
4744 kvm_lapic_sync_to_vapic(vcpu);
4745 }
4746
4747 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 5158 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
4748 5159
4749 kvm_guest_enter(); 5160 kvm_guest_enter();
@@ -4769,6 +5180,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4769 if (hw_breakpoint_active()) 5180 if (hw_breakpoint_active())
4770 hw_breakpoint_restore(); 5181 hw_breakpoint_restore();
4771 5182
5183 kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
5184
4772 atomic_set(&vcpu->guest_mode, 0); 5185 atomic_set(&vcpu->guest_mode, 0);
4773 smp_wmb(); 5186 smp_wmb();
4774 local_irq_enable(); 5187 local_irq_enable();
@@ -4898,8 +5311,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
4898 if (!irqchip_in_kernel(vcpu->kvm)) 5311 if (!irqchip_in_kernel(vcpu->kvm))
4899 kvm_set_cr8(vcpu, kvm_run->cr8); 5312 kvm_set_cr8(vcpu, kvm_run->cr8);
4900 5313
4901 if (vcpu->arch.pio.count || vcpu->mmio_needed || 5314 if (vcpu->arch.pio.count || vcpu->mmio_needed) {
4902 vcpu->arch.emulate_ctxt.restart) {
4903 if (vcpu->mmio_needed) { 5315 if (vcpu->mmio_needed) {
4904 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); 5316 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
4905 vcpu->mmio_read_completed = 1; 5317 vcpu->mmio_read_completed = 1;
@@ -4980,6 +5392,8 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
4980 5392
4981 vcpu->arch.exception.pending = false; 5393 vcpu->arch.exception.pending = false;
4982 5394
5395 kvm_make_request(KVM_REQ_EVENT, vcpu);
5396
4983 return 0; 5397 return 0;
4984} 5398}
4985 5399
@@ -5043,6 +5457,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
5043 struct kvm_mp_state *mp_state) 5457 struct kvm_mp_state *mp_state)
5044{ 5458{
5045 vcpu->arch.mp_state = mp_state->mp_state; 5459 vcpu->arch.mp_state = mp_state->mp_state;
5460 kvm_make_request(KVM_REQ_EVENT, vcpu);
5046 return 0; 5461 return 0;
5047} 5462}
5048 5463
@@ -5050,24 +5465,11 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
5050 bool has_error_code, u32 error_code) 5465 bool has_error_code, u32 error_code)
5051{ 5466{
5052 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; 5467 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
5053 int cs_db, cs_l, ret; 5468 int ret;
5054 cache_all_regs(vcpu);
5055
5056 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
5057 5469
5058 vcpu->arch.emulate_ctxt.vcpu = vcpu; 5470 init_emulate_ctxt(vcpu);
5059 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
5060 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
5061 vcpu->arch.emulate_ctxt.mode =
5062 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
5063 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
5064 ? X86EMUL_MODE_VM86 : cs_l
5065 ? X86EMUL_MODE_PROT64 : cs_db
5066 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
5067 memset(c, 0, sizeof(struct decode_cache));
5068 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
5069 5471
5070 ret = emulator_task_switch(&vcpu->arch.emulate_ctxt, &emulate_ops, 5472 ret = emulator_task_switch(&vcpu->arch.emulate_ctxt,
5071 tss_selector, reason, has_error_code, 5473 tss_selector, reason, has_error_code,
5072 error_code); 5474 error_code);
5073 5475
@@ -5077,6 +5479,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
5077 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs); 5479 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
5078 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); 5480 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
5079 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); 5481 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
5482 kvm_make_request(KVM_REQ_EVENT, vcpu);
5080 return EMULATE_DONE; 5483 return EMULATE_DONE;
5081} 5484}
5082EXPORT_SYMBOL_GPL(kvm_task_switch); 5485EXPORT_SYMBOL_GPL(kvm_task_switch);
@@ -5112,7 +5515,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5112 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; 5515 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4;
5113 kvm_x86_ops->set_cr4(vcpu, sregs->cr4); 5516 kvm_x86_ops->set_cr4(vcpu, sregs->cr4);
5114 if (!is_long_mode(vcpu) && is_pae(vcpu)) { 5517 if (!is_long_mode(vcpu) && is_pae(vcpu)) {
5115 load_pdptrs(vcpu, vcpu->arch.cr3); 5518 load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3);
5116 mmu_reset_needed = 1; 5519 mmu_reset_needed = 1;
5117 } 5520 }
5118 5521
@@ -5147,6 +5550,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5147 !is_protmode(vcpu)) 5550 !is_protmode(vcpu))
5148 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 5551 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
5149 5552
5553 kvm_make_request(KVM_REQ_EVENT, vcpu);
5554
5150 return 0; 5555 return 0;
5151} 5556}
5152 5557
@@ -5333,6 +5738,10 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
5333struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, 5738struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
5334 unsigned int id) 5739 unsigned int id)
5335{ 5740{
5741 if (check_tsc_unstable() && atomic_read(&kvm->online_vcpus) != 0)
5742 printk_once(KERN_WARNING
5743 "kvm: SMP vm created on host with unstable TSC; "
5744 "guest TSC will not be reliable\n");
5336 return kvm_x86_ops->vcpu_create(kvm, id); 5745 return kvm_x86_ops->vcpu_create(kvm, id);
5337} 5746}
5338 5747
@@ -5375,22 +5784,22 @@ int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu)
5375 vcpu->arch.dr6 = DR6_FIXED_1; 5784 vcpu->arch.dr6 = DR6_FIXED_1;
5376 vcpu->arch.dr7 = DR7_FIXED_1; 5785 vcpu->arch.dr7 = DR7_FIXED_1;
5377 5786
5787 kvm_make_request(KVM_REQ_EVENT, vcpu);
5788
5378 return kvm_x86_ops->vcpu_reset(vcpu); 5789 return kvm_x86_ops->vcpu_reset(vcpu);
5379} 5790}
5380 5791
5381int kvm_arch_hardware_enable(void *garbage) 5792int kvm_arch_hardware_enable(void *garbage)
5382{ 5793{
5383 /* 5794 struct kvm *kvm;
5384 * Since this may be called from a hotplug notifcation, 5795 struct kvm_vcpu *vcpu;
5385 * we can't get the CPU frequency directly. 5796 int i;
5386 */
5387 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
5388 int cpu = raw_smp_processor_id();
5389 per_cpu(cpu_tsc_khz, cpu) = 0;
5390 }
5391 5797
5392 kvm_shared_msr_cpu_online(); 5798 kvm_shared_msr_cpu_online();
5393 5799 list_for_each_entry(kvm, &vm_list, vm_list)
5800 kvm_for_each_vcpu(i, vcpu, kvm)
5801 if (vcpu->cpu == smp_processor_id())
5802 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
5394 return kvm_x86_ops->hardware_enable(garbage); 5803 return kvm_x86_ops->hardware_enable(garbage);
5395} 5804}
5396 5805
@@ -5424,7 +5833,11 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5424 BUG_ON(vcpu->kvm == NULL); 5833 BUG_ON(vcpu->kvm == NULL);
5425 kvm = vcpu->kvm; 5834 kvm = vcpu->kvm;
5426 5835
5836 vcpu->arch.emulate_ctxt.ops = &emulate_ops;
5837 vcpu->arch.walk_mmu = &vcpu->arch.mmu;
5427 vcpu->arch.mmu.root_hpa = INVALID_PAGE; 5838 vcpu->arch.mmu.root_hpa = INVALID_PAGE;
5839 vcpu->arch.mmu.translate_gpa = translate_gpa;
5840 vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa;
5428 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) 5841 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu))
5429 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 5842 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
5430 else 5843 else
@@ -5437,6 +5850,9 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5437 } 5850 }
5438 vcpu->arch.pio_data = page_address(page); 5851 vcpu->arch.pio_data = page_address(page);
5439 5852
5853 if (!kvm->arch.virtual_tsc_khz)
5854 kvm_arch_set_tsc_khz(kvm, max_tsc_khz);
5855
5440 r = kvm_mmu_create(vcpu); 5856 r = kvm_mmu_create(vcpu);
5441 if (r < 0) 5857 if (r < 0)
5442 goto fail_free_pio_data; 5858 goto fail_free_pio_data;
@@ -5496,7 +5912,7 @@ struct kvm *kvm_arch_create_vm(void)
5496 /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */ 5912 /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */
5497 set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap); 5913 set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap);
5498 5914
5499 rdtscll(kvm->arch.vm_init_tsc); 5915 spin_lock_init(&kvm->arch.tsc_write_lock);
5500 5916
5501 return kvm; 5917 return kvm;
5502} 5918}
@@ -5683,6 +6099,7 @@ void kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
5683 kvm_is_linear_rip(vcpu, vcpu->arch.singlestep_rip)) 6099 kvm_is_linear_rip(vcpu, vcpu->arch.singlestep_rip))
5684 rflags |= X86_EFLAGS_TF; 6100 rflags |= X86_EFLAGS_TF;
5685 kvm_x86_ops->set_rflags(vcpu, rflags); 6101 kvm_x86_ops->set_rflags(vcpu, rflags);
6102 kvm_make_request(KVM_REQ_EVENT, vcpu);
5686} 6103}
5687EXPORT_SYMBOL_GPL(kvm_set_rflags); 6104EXPORT_SYMBOL_GPL(kvm_set_rflags);
5688 6105
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index b7a404722d2b..2cea414489f3 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -50,6 +50,11 @@ static inline int is_long_mode(struct kvm_vcpu *vcpu)
50#endif 50#endif
51} 51}
52 52
53static inline bool mmu_is_nested(struct kvm_vcpu *vcpu)
54{
55 return vcpu->arch.walk_mmu == &vcpu->arch.nested_mmu;
56}
57
53static inline int is_pae(struct kvm_vcpu *vcpu) 58static inline int is_pae(struct kvm_vcpu *vcpu)
54{ 59{
55 return kvm_read_cr4_bits(vcpu, X86_CR4_PAE); 60 return kvm_read_cr4_bits(vcpu, X86_CR4_PAE);
@@ -67,5 +72,8 @@ static inline int is_paging(struct kvm_vcpu *vcpu)
67 72
68void kvm_before_handle_nmi(struct kvm_vcpu *vcpu); 73void kvm_before_handle_nmi(struct kvm_vcpu *vcpu);
69void kvm_after_handle_nmi(struct kvm_vcpu *vcpu); 74void kvm_after_handle_nmi(struct kvm_vcpu *vcpu);
75int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq);
76
77void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data);
70 78
71#endif 79#endif
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 9d5f55848455..73b1e1a1f489 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -791,22 +791,22 @@ static void lguest_flush_tlb_kernel(void)
791 * simple as setting a bit. We don't actually "ack" interrupts as such, we 791 * simple as setting a bit. We don't actually "ack" interrupts as such, we
792 * just mask and unmask them. I wonder if we should be cleverer? 792 * just mask and unmask them. I wonder if we should be cleverer?
793 */ 793 */
794static void disable_lguest_irq(unsigned int irq) 794static void disable_lguest_irq(struct irq_data *data)
795{ 795{
796 set_bit(irq, lguest_data.blocked_interrupts); 796 set_bit(data->irq, lguest_data.blocked_interrupts);
797} 797}
798 798
799static void enable_lguest_irq(unsigned int irq) 799static void enable_lguest_irq(struct irq_data *data)
800{ 800{
801 clear_bit(irq, lguest_data.blocked_interrupts); 801 clear_bit(data->irq, lguest_data.blocked_interrupts);
802} 802}
803 803
804/* This structure describes the lguest IRQ controller. */ 804/* This structure describes the lguest IRQ controller. */
805static struct irq_chip lguest_irq_controller = { 805static struct irq_chip lguest_irq_controller = {
806 .name = "lguest", 806 .name = "lguest",
807 .mask = disable_lguest_irq, 807 .irq_mask = disable_lguest_irq,
808 .mask_ack = disable_lguest_irq, 808 .irq_mask_ack = disable_lguest_irq,
809 .unmask = enable_lguest_irq, 809 .irq_unmask = enable_lguest_irq,
810}; 810};
811 811
812/* 812/*
@@ -838,12 +838,12 @@ static void __init lguest_init_IRQ(void)
838 * rather than set them in lguest_init_IRQ we are called here every time an 838 * rather than set them in lguest_init_IRQ we are called here every time an
839 * lguest device needs an interrupt. 839 * lguest device needs an interrupt.
840 * 840 *
841 * FIXME: irq_to_desc_alloc_node() can fail due to lack of memory, we should 841 * FIXME: irq_alloc_desc_at() can fail due to lack of memory, we should
842 * pass that up! 842 * pass that up!
843 */ 843 */
844void lguest_setup_irq(unsigned int irq) 844void lguest_setup_irq(unsigned int irq)
845{ 845{
846 irq_to_desc_alloc_node(irq, 0); 846 irq_alloc_desc_at(irq, 0);
847 set_irq_chip_and_handler_name(irq, &lguest_irq_controller, 847 set_irq_chip_and_handler_name(irq, &lguest_irq_controller,
848 handle_level_irq, "level"); 848 handle_level_irq, "level");
849} 849}
diff --git a/arch/x86/lib/memcpy_32.c b/arch/x86/lib/memcpy_32.c
index 5415a9d06f53..b908a59eccf5 100644
--- a/arch/x86/lib/memcpy_32.c
+++ b/arch/x86/lib/memcpy_32.c
@@ -22,22 +22,187 @@ EXPORT_SYMBOL(memset);
22 22
23void *memmove(void *dest, const void *src, size_t n) 23void *memmove(void *dest, const void *src, size_t n)
24{ 24{
25 int d0, d1, d2; 25 int d0,d1,d2,d3,d4,d5;
26 26 char *ret = dest;
27 if (dest < src) { 27
28 memcpy(dest, src, n); 28 __asm__ __volatile__(
29 } else { 29 /* Handle more 16bytes in loop */
30 __asm__ __volatile__( 30 "cmp $0x10, %0\n\t"
31 "std\n\t" 31 "jb 1f\n\t"
32 "rep\n\t" 32
33 "movsb\n\t" 33 /* Decide forward/backward copy mode */
34 "cld" 34 "cmp %2, %1\n\t"
35 : "=&c" (d0), "=&S" (d1), "=&D" (d2) 35 "jb 2f\n\t"
36 :"0" (n), 36
37 "1" (n-1+src), 37 /*
38 "2" (n-1+dest) 38 * movs instruction have many startup latency
39 :"memory"); 39 * so we handle small size by general register.
40 } 40 */
41 return dest; 41 "cmp $680, %0\n\t"
42 "jb 3f\n\t"
43 /*
44 * movs instruction is only good for aligned case.
45 */
46 "mov %1, %3\n\t"
47 "xor %2, %3\n\t"
48 "and $0xff, %3\n\t"
49 "jz 4f\n\t"
50 "3:\n\t"
51 "sub $0x10, %0\n\t"
52
53 /*
54 * We gobble 16byts forward in each loop.
55 */
56 "3:\n\t"
57 "sub $0x10, %0\n\t"
58 "mov 0*4(%1), %3\n\t"
59 "mov 1*4(%1), %4\n\t"
60 "mov %3, 0*4(%2)\n\t"
61 "mov %4, 1*4(%2)\n\t"
62 "mov 2*4(%1), %3\n\t"
63 "mov 3*4(%1), %4\n\t"
64 "mov %3, 2*4(%2)\n\t"
65 "mov %4, 3*4(%2)\n\t"
66 "lea 0x10(%1), %1\n\t"
67 "lea 0x10(%2), %2\n\t"
68 "jae 3b\n\t"
69 "add $0x10, %0\n\t"
70 "jmp 1f\n\t"
71
72 /*
73 * Handle data forward by movs.
74 */
75 ".p2align 4\n\t"
76 "4:\n\t"
77 "mov -4(%1, %0), %3\n\t"
78 "lea -4(%2, %0), %4\n\t"
79 "shr $2, %0\n\t"
80 "rep movsl\n\t"
81 "mov %3, (%4)\n\t"
82 "jmp 11f\n\t"
83 /*
84 * Handle data backward by movs.
85 */
86 ".p2align 4\n\t"
87 "6:\n\t"
88 "mov (%1), %3\n\t"
89 "mov %2, %4\n\t"
90 "lea -4(%1, %0), %1\n\t"
91 "lea -4(%2, %0), %2\n\t"
92 "shr $2, %0\n\t"
93 "std\n\t"
94 "rep movsl\n\t"
95 "mov %3,(%4)\n\t"
96 "cld\n\t"
97 "jmp 11f\n\t"
98
99 /*
100 * Start to prepare for backward copy.
101 */
102 ".p2align 4\n\t"
103 "2:\n\t"
104 "cmp $680, %0\n\t"
105 "jb 5f\n\t"
106 "mov %1, %3\n\t"
107 "xor %2, %3\n\t"
108 "and $0xff, %3\n\t"
109 "jz 6b\n\t"
110
111 /*
112 * Calculate copy position to tail.
113 */
114 "5:\n\t"
115 "add %0, %1\n\t"
116 "add %0, %2\n\t"
117 "sub $0x10, %0\n\t"
118
119 /*
120 * We gobble 16byts backward in each loop.
121 */
122 "7:\n\t"
123 "sub $0x10, %0\n\t"
124
125 "mov -1*4(%1), %3\n\t"
126 "mov -2*4(%1), %4\n\t"
127 "mov %3, -1*4(%2)\n\t"
128 "mov %4, -2*4(%2)\n\t"
129 "mov -3*4(%1), %3\n\t"
130 "mov -4*4(%1), %4\n\t"
131 "mov %3, -3*4(%2)\n\t"
132 "mov %4, -4*4(%2)\n\t"
133 "lea -0x10(%1), %1\n\t"
134 "lea -0x10(%2), %2\n\t"
135 "jae 7b\n\t"
136 /*
137 * Calculate copy position to head.
138 */
139 "add $0x10, %0\n\t"
140 "sub %0, %1\n\t"
141 "sub %0, %2\n\t"
142
143 /*
144 * Move data from 8 bytes to 15 bytes.
145 */
146 ".p2align 4\n\t"
147 "1:\n\t"
148 "cmp $8, %0\n\t"
149 "jb 8f\n\t"
150 "mov 0*4(%1), %3\n\t"
151 "mov 1*4(%1), %4\n\t"
152 "mov -2*4(%1, %0), %5\n\t"
153 "mov -1*4(%1, %0), %1\n\t"
154
155 "mov %3, 0*4(%2)\n\t"
156 "mov %4, 1*4(%2)\n\t"
157 "mov %5, -2*4(%2, %0)\n\t"
158 "mov %1, -1*4(%2, %0)\n\t"
159 "jmp 11f\n\t"
160
161 /*
162 * Move data from 4 bytes to 7 bytes.
163 */
164 ".p2align 4\n\t"
165 "8:\n\t"
166 "cmp $4, %0\n\t"
167 "jb 9f\n\t"
168 "mov 0*4(%1), %3\n\t"
169 "mov -1*4(%1, %0), %4\n\t"
170 "mov %3, 0*4(%2)\n\t"
171 "mov %4, -1*4(%2, %0)\n\t"
172 "jmp 11f\n\t"
173
174 /*
175 * Move data from 2 bytes to 3 bytes.
176 */
177 ".p2align 4\n\t"
178 "9:\n\t"
179 "cmp $2, %0\n\t"
180 "jb 10f\n\t"
181 "movw 0*2(%1), %%dx\n\t"
182 "movw -1*2(%1, %0), %%bx\n\t"
183 "movw %%dx, 0*2(%2)\n\t"
184 "movw %%bx, -1*2(%2, %0)\n\t"
185 "jmp 11f\n\t"
186
187 /*
188 * Move data for 1 byte.
189 */
190 ".p2align 4\n\t"
191 "10:\n\t"
192 "cmp $1, %0\n\t"
193 "jb 11f\n\t"
194 "movb (%1), %%cl\n\t"
195 "movb %%cl, (%2)\n\t"
196 ".p2align 4\n\t"
197 "11:"
198 : "=&c" (d0), "=&S" (d1), "=&D" (d2),
199 "=r" (d3),"=r" (d4), "=r"(d5)
200 :"0" (n),
201 "1" (src),
202 "2" (dest)
203 :"memory");
204
205 return ret;
206
42} 207}
43EXPORT_SYMBOL(memmove); 208EXPORT_SYMBOL(memmove);
diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
index bcbcd1e0f7d5..75ef61e35e38 100644
--- a/arch/x86/lib/memcpy_64.S
+++ b/arch/x86/lib/memcpy_64.S
@@ -40,84 +40,132 @@
40ENTRY(__memcpy) 40ENTRY(__memcpy)
41ENTRY(memcpy) 41ENTRY(memcpy)
42 CFI_STARTPROC 42 CFI_STARTPROC
43 movq %rdi, %rax
43 44
44 /* 45 /*
45 * Put the number of full 64-byte blocks into %ecx. 46 * Use 32bit CMP here to avoid long NOP padding.
46 * Tail portion is handled at the end:
47 */ 47 */
48 movq %rdi, %rax 48 cmp $0x20, %edx
49 movl %edx, %ecx 49 jb .Lhandle_tail
50 shrl $6, %ecx
51 jz .Lhandle_tail
52 50
53 .p2align 4
54.Lloop_64:
55 /* 51 /*
56 * We decrement the loop index here - and the zero-flag is 52 * We check whether memory false dependece could occur,
57 * checked at the end of the loop (instructions inbetween do 53 * then jump to corresponding copy mode.
58 * not change the zero flag):
59 */ 54 */
60 decl %ecx 55 cmp %dil, %sil
56 jl .Lcopy_backward
57 subl $0x20, %edx
58.Lcopy_forward_loop:
59 subq $0x20, %rdx
61 60
62 /* 61 /*
63 * Move in blocks of 4x16 bytes: 62 * Move in blocks of 4x8 bytes:
64 */ 63 */
65 movq 0*8(%rsi), %r11 64 movq 0*8(%rsi), %r8
66 movq 1*8(%rsi), %r8 65 movq 1*8(%rsi), %r9
67 movq %r11, 0*8(%rdi) 66 movq 2*8(%rsi), %r10
68 movq %r8, 1*8(%rdi) 67 movq 3*8(%rsi), %r11
69 68 leaq 4*8(%rsi), %rsi
70 movq 2*8(%rsi), %r9 69
71 movq 3*8(%rsi), %r10 70 movq %r8, 0*8(%rdi)
72 movq %r9, 2*8(%rdi) 71 movq %r9, 1*8(%rdi)
73 movq %r10, 3*8(%rdi) 72 movq %r10, 2*8(%rdi)
74 73 movq %r11, 3*8(%rdi)
75 movq 4*8(%rsi), %r11 74 leaq 4*8(%rdi), %rdi
76 movq 5*8(%rsi), %r8 75 jae .Lcopy_forward_loop
77 movq %r11, 4*8(%rdi) 76 addq $0x20, %rdx
78 movq %r8, 5*8(%rdi) 77 jmp .Lhandle_tail
79 78
80 movq 6*8(%rsi), %r9 79.Lcopy_backward:
81 movq 7*8(%rsi), %r10 80 /*
82 movq %r9, 6*8(%rdi) 81 * Calculate copy position to tail.
83 movq %r10, 7*8(%rdi) 82 */
84 83 addq %rdx, %rsi
85 leaq 64(%rsi), %rsi 84 addq %rdx, %rdi
86 leaq 64(%rdi), %rdi 85 subq $0x20, %rdx
87 86 /*
88 jnz .Lloop_64 87 * At most 3 ALU operations in one cycle,
88 * so append NOPS in the same 16bytes trunk.
89 */
90 .p2align 4
91.Lcopy_backward_loop:
92 subq $0x20, %rdx
93 movq -1*8(%rsi), %r8
94 movq -2*8(%rsi), %r9
95 movq -3*8(%rsi), %r10
96 movq -4*8(%rsi), %r11
97 leaq -4*8(%rsi), %rsi
98 movq %r8, -1*8(%rdi)
99 movq %r9, -2*8(%rdi)
100 movq %r10, -3*8(%rdi)
101 movq %r11, -4*8(%rdi)
102 leaq -4*8(%rdi), %rdi
103 jae .Lcopy_backward_loop
89 104
105 /*
106 * Calculate copy position to head.
107 */
108 addq $0x20, %rdx
109 subq %rdx, %rsi
110 subq %rdx, %rdi
90.Lhandle_tail: 111.Lhandle_tail:
91 movl %edx, %ecx 112 cmpq $16, %rdx
92 andl $63, %ecx 113 jb .Lless_16bytes
93 shrl $3, %ecx
94 jz .Lhandle_7
95 114
115 /*
116 * Move data from 16 bytes to 31 bytes.
117 */
118 movq 0*8(%rsi), %r8
119 movq 1*8(%rsi), %r9
120 movq -2*8(%rsi, %rdx), %r10
121 movq -1*8(%rsi, %rdx), %r11
122 movq %r8, 0*8(%rdi)
123 movq %r9, 1*8(%rdi)
124 movq %r10, -2*8(%rdi, %rdx)
125 movq %r11, -1*8(%rdi, %rdx)
126 retq
96 .p2align 4 127 .p2align 4
97.Lloop_8: 128.Lless_16bytes:
98 decl %ecx 129 cmpq $8, %rdx
99 movq (%rsi), %r8 130 jb .Lless_8bytes
100 movq %r8, (%rdi) 131 /*
101 leaq 8(%rdi), %rdi 132 * Move data from 8 bytes to 15 bytes.
102 leaq 8(%rsi), %rsi 133 */
103 jnz .Lloop_8 134 movq 0*8(%rsi), %r8
104 135 movq -1*8(%rsi, %rdx), %r9
105.Lhandle_7: 136 movq %r8, 0*8(%rdi)
106 movl %edx, %ecx 137 movq %r9, -1*8(%rdi, %rdx)
107 andl $7, %ecx 138 retq
108 jz .Lend 139 .p2align 4
140.Lless_8bytes:
141 cmpq $4, %rdx
142 jb .Lless_3bytes
109 143
144 /*
145 * Move data from 4 bytes to 7 bytes.
146 */
147 movl (%rsi), %ecx
148 movl -4(%rsi, %rdx), %r8d
149 movl %ecx, (%rdi)
150 movl %r8d, -4(%rdi, %rdx)
151 retq
110 .p2align 4 152 .p2align 4
153.Lless_3bytes:
154 cmpl $0, %edx
155 je .Lend
156 /*
157 * Move data from 1 bytes to 3 bytes.
158 */
111.Lloop_1: 159.Lloop_1:
112 movb (%rsi), %r8b 160 movb (%rsi), %r8b
113 movb %r8b, (%rdi) 161 movb %r8b, (%rdi)
114 incq %rdi 162 incq %rdi
115 incq %rsi 163 incq %rsi
116 decl %ecx 164 decl %edx
117 jnz .Lloop_1 165 jnz .Lloop_1
118 166
119.Lend: 167.Lend:
120 ret 168 retq
121 CFI_ENDPROC 169 CFI_ENDPROC
122ENDPROC(memcpy) 170ENDPROC(memcpy)
123ENDPROC(__memcpy) 171ENDPROC(__memcpy)
diff --git a/arch/x86/lib/memmove_64.c b/arch/x86/lib/memmove_64.c
index 0a33909bf122..6d0f0ec41b34 100644
--- a/arch/x86/lib/memmove_64.c
+++ b/arch/x86/lib/memmove_64.c
@@ -8,14 +8,185 @@
8#undef memmove 8#undef memmove
9void *memmove(void *dest, const void *src, size_t count) 9void *memmove(void *dest, const void *src, size_t count)
10{ 10{
11 if (dest < src) { 11 unsigned long d0,d1,d2,d3,d4,d5,d6,d7;
12 return memcpy(dest, src, count); 12 char *ret;
13 } else { 13
14 char *p = dest + count; 14 __asm__ __volatile__(
15 const char *s = src + count; 15 /* Handle more 32bytes in loop */
16 while (count--) 16 "mov %2, %3\n\t"
17 *--p = *--s; 17 "cmp $0x20, %0\n\t"
18 } 18 "jb 1f\n\t"
19 return dest; 19
20 /* Decide forward/backward copy mode */
21 "cmp %2, %1\n\t"
22 "jb 2f\n\t"
23
24 /*
25 * movsq instruction have many startup latency
26 * so we handle small size by general register.
27 */
28 "cmp $680, %0\n\t"
29 "jb 3f\n\t"
30 /*
31 * movsq instruction is only good for aligned case.
32 */
33 "cmpb %%dil, %%sil\n\t"
34 "je 4f\n\t"
35 "3:\n\t"
36 "sub $0x20, %0\n\t"
37 /*
38 * We gobble 32byts forward in each loop.
39 */
40 "5:\n\t"
41 "sub $0x20, %0\n\t"
42 "movq 0*8(%1), %4\n\t"
43 "movq 1*8(%1), %5\n\t"
44 "movq 2*8(%1), %6\n\t"
45 "movq 3*8(%1), %7\n\t"
46 "leaq 4*8(%1), %1\n\t"
47
48 "movq %4, 0*8(%2)\n\t"
49 "movq %5, 1*8(%2)\n\t"
50 "movq %6, 2*8(%2)\n\t"
51 "movq %7, 3*8(%2)\n\t"
52 "leaq 4*8(%2), %2\n\t"
53 "jae 5b\n\t"
54 "addq $0x20, %0\n\t"
55 "jmp 1f\n\t"
56 /*
57 * Handle data forward by movsq.
58 */
59 ".p2align 4\n\t"
60 "4:\n\t"
61 "movq %0, %8\n\t"
62 "movq -8(%1, %0), %4\n\t"
63 "lea -8(%2, %0), %5\n\t"
64 "shrq $3, %8\n\t"
65 "rep movsq\n\t"
66 "movq %4, (%5)\n\t"
67 "jmp 13f\n\t"
68 /*
69 * Handle data backward by movsq.
70 */
71 ".p2align 4\n\t"
72 "7:\n\t"
73 "movq %0, %8\n\t"
74 "movq (%1), %4\n\t"
75 "movq %2, %5\n\t"
76 "leaq -8(%1, %0), %1\n\t"
77 "leaq -8(%2, %0), %2\n\t"
78 "shrq $3, %8\n\t"
79 "std\n\t"
80 "rep movsq\n\t"
81 "cld\n\t"
82 "movq %4, (%5)\n\t"
83 "jmp 13f\n\t"
84
85 /*
86 * Start to prepare for backward copy.
87 */
88 ".p2align 4\n\t"
89 "2:\n\t"
90 "cmp $680, %0\n\t"
91 "jb 6f \n\t"
92 "cmp %%dil, %%sil\n\t"
93 "je 7b \n\t"
94 "6:\n\t"
95 /*
96 * Calculate copy position to tail.
97 */
98 "addq %0, %1\n\t"
99 "addq %0, %2\n\t"
100 "subq $0x20, %0\n\t"
101 /*
102 * We gobble 32byts backward in each loop.
103 */
104 "8:\n\t"
105 "subq $0x20, %0\n\t"
106 "movq -1*8(%1), %4\n\t"
107 "movq -2*8(%1), %5\n\t"
108 "movq -3*8(%1), %6\n\t"
109 "movq -4*8(%1), %7\n\t"
110 "leaq -4*8(%1), %1\n\t"
111
112 "movq %4, -1*8(%2)\n\t"
113 "movq %5, -2*8(%2)\n\t"
114 "movq %6, -3*8(%2)\n\t"
115 "movq %7, -4*8(%2)\n\t"
116 "leaq -4*8(%2), %2\n\t"
117 "jae 8b\n\t"
118 /*
119 * Calculate copy position to head.
120 */
121 "addq $0x20, %0\n\t"
122 "subq %0, %1\n\t"
123 "subq %0, %2\n\t"
124 "1:\n\t"
125 "cmpq $16, %0\n\t"
126 "jb 9f\n\t"
127 /*
128 * Move data from 16 bytes to 31 bytes.
129 */
130 "movq 0*8(%1), %4\n\t"
131 "movq 1*8(%1), %5\n\t"
132 "movq -2*8(%1, %0), %6\n\t"
133 "movq -1*8(%1, %0), %7\n\t"
134 "movq %4, 0*8(%2)\n\t"
135 "movq %5, 1*8(%2)\n\t"
136 "movq %6, -2*8(%2, %0)\n\t"
137 "movq %7, -1*8(%2, %0)\n\t"
138 "jmp 13f\n\t"
139 ".p2align 4\n\t"
140 "9:\n\t"
141 "cmpq $8, %0\n\t"
142 "jb 10f\n\t"
143 /*
144 * Move data from 8 bytes to 15 bytes.
145 */
146 "movq 0*8(%1), %4\n\t"
147 "movq -1*8(%1, %0), %5\n\t"
148 "movq %4, 0*8(%2)\n\t"
149 "movq %5, -1*8(%2, %0)\n\t"
150 "jmp 13f\n\t"
151 "10:\n\t"
152 "cmpq $4, %0\n\t"
153 "jb 11f\n\t"
154 /*
155 * Move data from 4 bytes to 7 bytes.
156 */
157 "movl (%1), %4d\n\t"
158 "movl -4(%1, %0), %5d\n\t"
159 "movl %4d, (%2)\n\t"
160 "movl %5d, -4(%2, %0)\n\t"
161 "jmp 13f\n\t"
162 "11:\n\t"
163 "cmp $2, %0\n\t"
164 "jb 12f\n\t"
165 /*
166 * Move data from 2 bytes to 3 bytes.
167 */
168 "movw (%1), %4w\n\t"
169 "movw -2(%1, %0), %5w\n\t"
170 "movw %4w, (%2)\n\t"
171 "movw %5w, -2(%2, %0)\n\t"
172 "jmp 13f\n\t"
173 "12:\n\t"
174 "cmp $1, %0\n\t"
175 "jb 13f\n\t"
176 /*
177 * Move data for 1 byte.
178 */
179 "movb (%1), %4b\n\t"
180 "movb %4b, (%2)\n\t"
181 "13:\n\t"
182 : "=&d" (d0), "=&S" (d1), "=&D" (d2), "=&a" (ret) ,
183 "=r"(d3), "=r"(d4), "=r"(d5), "=r"(d6), "=&c" (d7)
184 :"0" (count),
185 "1" (src),
186 "2" (dest)
187 :"memory");
188
189 return ret;
190
20} 191}
21EXPORT_SYMBOL(memmove); 192EXPORT_SYMBOL(memmove);
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index a4c768397baa..55543397a8a7 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -26,4 +26,6 @@ obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o
26obj-$(CONFIG_K8_NUMA) += k8topology_64.o 26obj-$(CONFIG_K8_NUMA) += k8topology_64.o
27obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o 27obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o
28 28
29obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
30
29obj-$(CONFIG_MEMTEST) += memtest.o 31obj-$(CONFIG_MEMTEST) += memtest.o
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 4c4508e8a204..79b0b372d2d0 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -229,7 +229,16 @@ void vmalloc_sync_all(void)
229 229
230 spin_lock_irqsave(&pgd_lock, flags); 230 spin_lock_irqsave(&pgd_lock, flags);
231 list_for_each_entry(page, &pgd_list, lru) { 231 list_for_each_entry(page, &pgd_list, lru) {
232 if (!vmalloc_sync_one(page_address(page), address)) 232 spinlock_t *pgt_lock;
233 pmd_t *ret;
234
235 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
236
237 spin_lock(pgt_lock);
238 ret = vmalloc_sync_one(page_address(page), address);
239 spin_unlock(pgt_lock);
240
241 if (!ret)
233 break; 242 break;
234 } 243 }
235 spin_unlock_irqrestore(&pgd_lock, flags); 244 spin_unlock_irqrestore(&pgd_lock, flags);
@@ -251,6 +260,8 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
251 if (!(address >= VMALLOC_START && address < VMALLOC_END)) 260 if (!(address >= VMALLOC_START && address < VMALLOC_END))
252 return -1; 261 return -1;
253 262
263 WARN_ON_ONCE(in_nmi());
264
254 /* 265 /*
255 * Synchronize this task's top level page-table 266 * Synchronize this task's top level page-table
256 * with the 'reference' page table. 267 * with the 'reference' page table.
@@ -326,29 +337,7 @@ out:
326 337
327void vmalloc_sync_all(void) 338void vmalloc_sync_all(void)
328{ 339{
329 unsigned long address; 340 sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END);
330
331 for (address = VMALLOC_START & PGDIR_MASK; address <= VMALLOC_END;
332 address += PGDIR_SIZE) {
333
334 const pgd_t *pgd_ref = pgd_offset_k(address);
335 unsigned long flags;
336 struct page *page;
337
338 if (pgd_none(*pgd_ref))
339 continue;
340
341 spin_lock_irqsave(&pgd_lock, flags);
342 list_for_each_entry(page, &pgd_list, lru) {
343 pgd_t *pgd;
344 pgd = (pgd_t *)page_address(page) + pgd_index(address);
345 if (pgd_none(*pgd))
346 set_pgd(pgd, *pgd_ref);
347 else
348 BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
349 }
350 spin_unlock_irqrestore(&pgd_lock, flags);
351 }
352} 341}
353 342
354/* 343/*
@@ -369,6 +358,8 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
369 if (!(address >= VMALLOC_START && address < VMALLOC_END)) 358 if (!(address >= VMALLOC_START && address < VMALLOC_END))
370 return -1; 359 return -1;
371 360
361 WARN_ON_ONCE(in_nmi());
362
372 /* 363 /*
373 * Copy kernel mappings over when needed. This can also 364 * Copy kernel mappings over when needed. This can also
374 * happen within a race in page table update. In the later 365 * happen within a race in page table update. In the later
@@ -894,8 +885,14 @@ spurious_fault(unsigned long error_code, unsigned long address)
894 if (pmd_large(*pmd)) 885 if (pmd_large(*pmd))
895 return spurious_fault_check(error_code, (pte_t *) pmd); 886 return spurious_fault_check(error_code, (pte_t *) pmd);
896 887
888 /*
889 * Note: don't use pte_present() here, since it returns true
890 * if the _PAGE_PROTNONE bit is set. However, this aliases the
891 * _PAGE_GLOBAL bit, which for kernel pages give false positives
892 * when CONFIG_DEBUG_PAGEALLOC is used.
893 */
897 pte = pte_offset_kernel(pmd, address); 894 pte = pte_offset_kernel(pmd, address);
898 if (!pte_present(*pte)) 895 if (!(pte_flags(*pte) & _PAGE_PRESENT))
899 return 0; 896 return 0;
900 897
901 ret = spurious_fault_check(error_code, pte); 898 ret = spurious_fault_check(error_code, pte);
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index b278535b14aa..c0e28a13de7d 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -2,6 +2,7 @@
2#include <linux/initrd.h> 2#include <linux/initrd.h>
3#include <linux/ioport.h> 3#include <linux/ioport.h>
4#include <linux/swap.h> 4#include <linux/swap.h>
5#include <linux/memblock.h>
5 6
6#include <asm/cacheflush.h> 7#include <asm/cacheflush.h>
7#include <asm/e820.h> 8#include <asm/e820.h>
@@ -33,6 +34,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
33 int use_gbpages) 34 int use_gbpages)
34{ 35{
35 unsigned long puds, pmds, ptes, tables, start; 36 unsigned long puds, pmds, ptes, tables, start;
37 phys_addr_t base;
36 38
37 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT; 39 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
38 tables = roundup(puds * sizeof(pud_t), PAGE_SIZE); 40 tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
@@ -75,12 +77,12 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
75#else 77#else
76 start = 0x8000; 78 start = 0x8000;
77#endif 79#endif
78 e820_table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT, 80 base = memblock_find_in_range(start, max_pfn_mapped<<PAGE_SHIFT,
79 tables, PAGE_SIZE); 81 tables, PAGE_SIZE);
80 if (e820_table_start == -1UL) 82 if (base == MEMBLOCK_ERROR)
81 panic("Cannot find space for the kernel page tables"); 83 panic("Cannot find space for the kernel page tables");
82 84
83 e820_table_start >>= PAGE_SHIFT; 85 e820_table_start = base >> PAGE_SHIFT;
84 e820_table_end = e820_table_start; 86 e820_table_end = e820_table_start;
85 e820_table_top = e820_table_start + (tables >> PAGE_SHIFT); 87 e820_table_top = e820_table_start + (tables >> PAGE_SHIFT);
86 88
@@ -299,7 +301,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
299 __flush_tlb_all(); 301 __flush_tlb_all();
300 302
301 if (!after_bootmem && e820_table_end > e820_table_start) 303 if (!after_bootmem && e820_table_end > e820_table_start)
302 reserve_early(e820_table_start << PAGE_SHIFT, 304 memblock_x86_reserve_range(e820_table_start << PAGE_SHIFT,
303 e820_table_end << PAGE_SHIFT, "PGTABLE"); 305 e820_table_end << PAGE_SHIFT, "PGTABLE");
304 306
305 if (!after_bootmem) 307 if (!after_bootmem)
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index bca79091b9d6..0e969f9f401b 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -25,6 +25,7 @@
25#include <linux/pfn.h> 25#include <linux/pfn.h>
26#include <linux/poison.h> 26#include <linux/poison.h>
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/memblock.h>
28#include <linux/proc_fs.h> 29#include <linux/proc_fs.h>
29#include <linux/memory_hotplug.h> 30#include <linux/memory_hotplug.h>
30#include <linux/initrd.h> 31#include <linux/initrd.h>
@@ -67,7 +68,7 @@ static __init void *alloc_low_page(void)
67 panic("alloc_low_page: ran out of memory"); 68 panic("alloc_low_page: ran out of memory");
68 69
69 adr = __va(pfn * PAGE_SIZE); 70 adr = __va(pfn * PAGE_SIZE);
70 memset(adr, 0, PAGE_SIZE); 71 clear_page(adr);
71 return adr; 72 return adr;
72} 73}
73 74
@@ -422,49 +423,28 @@ static void __init add_one_highpage_init(struct page *page)
422 totalhigh_pages++; 423 totalhigh_pages++;
423} 424}
424 425
425struct add_highpages_data { 426void __init add_highpages_with_active_regions(int nid,
426 unsigned long start_pfn; 427 unsigned long start_pfn, unsigned long end_pfn)
427 unsigned long end_pfn;
428};
429
430static int __init add_highpages_work_fn(unsigned long start_pfn,
431 unsigned long end_pfn, void *datax)
432{ 428{
433 int node_pfn; 429 struct range *range;
434 struct page *page; 430 int nr_range;
435 unsigned long final_start_pfn, final_end_pfn; 431 int i;
436 struct add_highpages_data *data;
437 432
438 data = (struct add_highpages_data *)datax; 433 nr_range = __get_free_all_memory_range(&range, nid, start_pfn, end_pfn);
439 434
440 final_start_pfn = max(start_pfn, data->start_pfn); 435 for (i = 0; i < nr_range; i++) {
441 final_end_pfn = min(end_pfn, data->end_pfn); 436 struct page *page;
442 if (final_start_pfn >= final_end_pfn) 437 int node_pfn;
443 return 0;
444 438
445 for (node_pfn = final_start_pfn; node_pfn < final_end_pfn; 439 for (node_pfn = range[i].start; node_pfn < range[i].end;
446 node_pfn++) { 440 node_pfn++) {
447 if (!pfn_valid(node_pfn)) 441 if (!pfn_valid(node_pfn))
448 continue; 442 continue;
449 page = pfn_to_page(node_pfn); 443 page = pfn_to_page(node_pfn);
450 add_one_highpage_init(page); 444 add_one_highpage_init(page);
445 }
451 } 446 }
452
453 return 0;
454
455} 447}
456
457void __init add_highpages_with_active_regions(int nid, unsigned long start_pfn,
458 unsigned long end_pfn)
459{
460 struct add_highpages_data data;
461
462 data.start_pfn = start_pfn;
463 data.end_pfn = end_pfn;
464
465 work_with_active_regions(nid, add_highpages_work_fn, &data);
466}
467
468#else 448#else
469static inline void permanent_kmaps_init(pgd_t *pgd_base) 449static inline void permanent_kmaps_init(pgd_t *pgd_base)
470{ 450{
@@ -548,48 +528,6 @@ static void __init pagetable_init(void)
548 permanent_kmaps_init(pgd_base); 528 permanent_kmaps_init(pgd_base);
549} 529}
550 530
551#ifdef CONFIG_ACPI_SLEEP
552/*
553 * ACPI suspend needs this for resume, because things like the intel-agp
554 * driver might have split up a kernel 4MB mapping.
555 */
556char swsusp_pg_dir[PAGE_SIZE]
557 __attribute__ ((aligned(PAGE_SIZE)));
558
559static inline void save_pg_dir(void)
560{
561 memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
562}
563#else /* !CONFIG_ACPI_SLEEP */
564static inline void save_pg_dir(void)
565{
566}
567#endif /* !CONFIG_ACPI_SLEEP */
568
569void zap_low_mappings(bool early)
570{
571 int i;
572
573 /*
574 * Zap initial low-memory mappings.
575 *
576 * Note that "pgd_clear()" doesn't do it for
577 * us, because pgd_clear() is a no-op on i386.
578 */
579 for (i = 0; i < KERNEL_PGD_BOUNDARY; i++) {
580#ifdef CONFIG_X86_PAE
581 set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
582#else
583 set_pgd(swapper_pg_dir+i, __pgd(0));
584#endif
585 }
586
587 if (early)
588 __flush_tlb();
589 else
590 flush_tlb_all();
591}
592
593pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP); 531pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
594EXPORT_SYMBOL_GPL(__supported_pte_mask); 532EXPORT_SYMBOL_GPL(__supported_pte_mask);
595 533
@@ -712,14 +650,14 @@ void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn,
712 highstart_pfn = highend_pfn = max_pfn; 650 highstart_pfn = highend_pfn = max_pfn;
713 if (max_pfn > max_low_pfn) 651 if (max_pfn > max_low_pfn)
714 highstart_pfn = max_low_pfn; 652 highstart_pfn = max_low_pfn;
715 e820_register_active_regions(0, 0, highend_pfn); 653 memblock_x86_register_active_regions(0, 0, highend_pfn);
716 sparse_memory_present_with_active_regions(0); 654 sparse_memory_present_with_active_regions(0);
717 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", 655 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
718 pages_to_mb(highend_pfn - highstart_pfn)); 656 pages_to_mb(highend_pfn - highstart_pfn));
719 num_physpages = highend_pfn; 657 num_physpages = highend_pfn;
720 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; 658 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
721#else 659#else
722 e820_register_active_regions(0, 0, max_low_pfn); 660 memblock_x86_register_active_regions(0, 0, max_low_pfn);
723 sparse_memory_present_with_active_regions(0); 661 sparse_memory_present_with_active_regions(0);
724 num_physpages = max_low_pfn; 662 num_physpages = max_low_pfn;
725 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; 663 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
@@ -750,68 +688,12 @@ static void __init zone_sizes_init(void)
750 free_area_init_nodes(max_zone_pfns); 688 free_area_init_nodes(max_zone_pfns);
751} 689}
752 690
753#ifndef CONFIG_NO_BOOTMEM
754static unsigned long __init setup_node_bootmem(int nodeid,
755 unsigned long start_pfn,
756 unsigned long end_pfn,
757 unsigned long bootmap)
758{
759 unsigned long bootmap_size;
760
761 /* don't touch min_low_pfn */
762 bootmap_size = init_bootmem_node(NODE_DATA(nodeid),
763 bootmap >> PAGE_SHIFT,
764 start_pfn, end_pfn);
765 printk(KERN_INFO " node %d low ram: %08lx - %08lx\n",
766 nodeid, start_pfn<<PAGE_SHIFT, end_pfn<<PAGE_SHIFT);
767 printk(KERN_INFO " node %d bootmap %08lx - %08lx\n",
768 nodeid, bootmap, bootmap + bootmap_size);
769 free_bootmem_with_active_regions(nodeid, end_pfn);
770
771 return bootmap + bootmap_size;
772}
773#endif
774
775void __init setup_bootmem_allocator(void) 691void __init setup_bootmem_allocator(void)
776{ 692{
777#ifndef CONFIG_NO_BOOTMEM
778 int nodeid;
779 unsigned long bootmap_size, bootmap;
780 /*
781 * Initialize the boot-time allocator (with low memory only):
782 */
783 bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
784 bootmap = find_e820_area(0, max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
785 PAGE_SIZE);
786 if (bootmap == -1L)
787 panic("Cannot find bootmem map of size %ld\n", bootmap_size);
788 reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
789#endif
790
791 printk(KERN_INFO " mapped low ram: 0 - %08lx\n", 693 printk(KERN_INFO " mapped low ram: 0 - %08lx\n",
792 max_pfn_mapped<<PAGE_SHIFT); 694 max_pfn_mapped<<PAGE_SHIFT);
793 printk(KERN_INFO " low ram: 0 - %08lx\n", max_low_pfn<<PAGE_SHIFT); 695 printk(KERN_INFO " low ram: 0 - %08lx\n", max_low_pfn<<PAGE_SHIFT);
794 696
795#ifndef CONFIG_NO_BOOTMEM
796 for_each_online_node(nodeid) {
797 unsigned long start_pfn, end_pfn;
798
799#ifdef CONFIG_NEED_MULTIPLE_NODES
800 start_pfn = node_start_pfn[nodeid];
801 end_pfn = node_end_pfn[nodeid];
802 if (start_pfn > max_low_pfn)
803 continue;
804 if (end_pfn > max_low_pfn)
805 end_pfn = max_low_pfn;
806#else
807 start_pfn = 0;
808 end_pfn = max_low_pfn;
809#endif
810 bootmap = setup_node_bootmem(nodeid, start_pfn, end_pfn,
811 bootmap);
812 }
813#endif
814
815 after_bootmem = 1; 697 after_bootmem = 1;
816} 698}
817 699
@@ -958,9 +840,6 @@ void __init mem_init(void)
958 840
959 if (boot_cpu_data.wp_works_ok < 0) 841 if (boot_cpu_data.wp_works_ok < 0)
960 test_wp_bit(); 842 test_wp_bit();
961
962 save_pg_dir();
963 zap_low_mappings(true);
964} 843}
965 844
966#ifdef CONFIG_MEMORY_HOTPLUG 845#ifdef CONFIG_MEMORY_HOTPLUG
@@ -1070,8 +949,3 @@ void mark_rodata_ro(void)
1070} 949}
1071#endif 950#endif
1072 951
1073int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
1074 int flags)
1075{
1076 return reserve_bootmem(phys, len, flags);
1077}
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 9a6674689a20..84346200e783 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -21,6 +21,7 @@
21#include <linux/initrd.h> 21#include <linux/initrd.h>
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/memblock.h>
24#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
25#include <linux/pci.h> 26#include <linux/pci.h>
26#include <linux/pfn.h> 27#include <linux/pfn.h>
@@ -52,8 +53,6 @@
52#include <asm/init.h> 53#include <asm/init.h>
53#include <linux/bootmem.h> 54#include <linux/bootmem.h>
54 55
55static unsigned long dma_reserve __initdata;
56
57static int __init parse_direct_gbpages_off(char *arg) 56static int __init parse_direct_gbpages_off(char *arg)
58{ 57{
59 direct_gbpages = 0; 58 direct_gbpages = 0;
@@ -98,6 +97,43 @@ static int __init nonx32_setup(char *str)
98__setup("noexec32=", nonx32_setup); 97__setup("noexec32=", nonx32_setup);
99 98
100/* 99/*
100 * When memory was added/removed make sure all the processes MM have
101 * suitable PGD entries in the local PGD level page.
102 */
103void sync_global_pgds(unsigned long start, unsigned long end)
104{
105 unsigned long address;
106
107 for (address = start; address <= end; address += PGDIR_SIZE) {
108 const pgd_t *pgd_ref = pgd_offset_k(address);
109 unsigned long flags;
110 struct page *page;
111
112 if (pgd_none(*pgd_ref))
113 continue;
114
115 spin_lock_irqsave(&pgd_lock, flags);
116 list_for_each_entry(page, &pgd_list, lru) {
117 pgd_t *pgd;
118 spinlock_t *pgt_lock;
119
120 pgd = (pgd_t *)page_address(page) + pgd_index(address);
121 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
122 spin_lock(pgt_lock);
123
124 if (pgd_none(*pgd))
125 set_pgd(pgd, *pgd_ref);
126 else
127 BUG_ON(pgd_page_vaddr(*pgd)
128 != pgd_page_vaddr(*pgd_ref));
129
130 spin_unlock(pgt_lock);
131 }
132 spin_unlock_irqrestore(&pgd_lock, flags);
133 }
134}
135
136/*
101 * NOTE: This function is marked __ref because it calls __init function 137 * NOTE: This function is marked __ref because it calls __init function
102 * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0. 138 * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0.
103 */ 139 */
@@ -293,7 +329,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
293 panic("alloc_low_page: ran out of memory"); 329 panic("alloc_low_page: ran out of memory");
294 330
295 adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE); 331 adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
296 memset(adr, 0, PAGE_SIZE); 332 clear_page(adr);
297 *phys = pfn * PAGE_SIZE; 333 *phys = pfn * PAGE_SIZE;
298 return adr; 334 return adr;
299} 335}
@@ -534,11 +570,13 @@ kernel_physical_mapping_init(unsigned long start,
534 unsigned long end, 570 unsigned long end,
535 unsigned long page_size_mask) 571 unsigned long page_size_mask)
536{ 572{
537 573 bool pgd_changed = false;
538 unsigned long next, last_map_addr = end; 574 unsigned long next, last_map_addr = end;
575 unsigned long addr;
539 576
540 start = (unsigned long)__va(start); 577 start = (unsigned long)__va(start);
541 end = (unsigned long)__va(end); 578 end = (unsigned long)__va(end);
579 addr = start;
542 580
543 for (; start < end; start = next) { 581 for (; start < end; start = next) {
544 pgd_t *pgd = pgd_offset_k(start); 582 pgd_t *pgd = pgd_offset_k(start);
@@ -563,7 +601,12 @@ kernel_physical_mapping_init(unsigned long start,
563 spin_lock(&init_mm.page_table_lock); 601 spin_lock(&init_mm.page_table_lock);
564 pgd_populate(&init_mm, pgd, __va(pud_phys)); 602 pgd_populate(&init_mm, pgd, __va(pud_phys));
565 spin_unlock(&init_mm.page_table_lock); 603 spin_unlock(&init_mm.page_table_lock);
604 pgd_changed = true;
566 } 605 }
606
607 if (pgd_changed)
608 sync_global_pgds(addr, end);
609
567 __flush_tlb_all(); 610 __flush_tlb_all();
568 611
569 return last_map_addr; 612 return last_map_addr;
@@ -573,23 +616,7 @@ kernel_physical_mapping_init(unsigned long start,
573void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn, 616void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn,
574 int acpi, int k8) 617 int acpi, int k8)
575{ 618{
576#ifndef CONFIG_NO_BOOTMEM 619 memblock_x86_register_active_regions(0, start_pfn, end_pfn);
577 unsigned long bootmap_size, bootmap;
578
579 bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
580 bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size,
581 PAGE_SIZE);
582 if (bootmap == -1L)
583 panic("Cannot find bootmem map of size %ld\n", bootmap_size);
584 reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
585 /* don't touch min_low_pfn */
586 bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap >> PAGE_SHIFT,
587 0, end_pfn);
588 e820_register_active_regions(0, start_pfn, end_pfn);
589 free_bootmem_with_active_regions(0, end_pfn);
590#else
591 e820_register_active_regions(0, start_pfn, end_pfn);
592#endif
593} 620}
594#endif 621#endif
595 622
@@ -799,52 +826,6 @@ void mark_rodata_ro(void)
799 826
800#endif 827#endif
801 828
802int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
803 int flags)
804{
805#ifdef CONFIG_NUMA
806 int nid, next_nid;
807 int ret;
808#endif
809 unsigned long pfn = phys >> PAGE_SHIFT;
810
811 if (pfn >= max_pfn) {
812 /*
813 * This can happen with kdump kernels when accessing
814 * firmware tables:
815 */
816 if (pfn < max_pfn_mapped)
817 return -EFAULT;
818
819 printk(KERN_ERR "reserve_bootmem: illegal reserve %lx %lu\n",
820 phys, len);
821 return -EFAULT;
822 }
823
824 /* Should check here against the e820 map to avoid double free */
825#ifdef CONFIG_NUMA
826 nid = phys_to_nid(phys);
827 next_nid = phys_to_nid(phys + len - 1);
828 if (nid == next_nid)
829 ret = reserve_bootmem_node(NODE_DATA(nid), phys, len, flags);
830 else
831 ret = reserve_bootmem(phys, len, flags);
832
833 if (ret != 0)
834 return ret;
835
836#else
837 reserve_bootmem(phys, len, flags);
838#endif
839
840 if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
841 dma_reserve += len / PAGE_SIZE;
842 set_dma_reserve(dma_reserve);
843 }
844
845 return 0;
846}
847
848int kern_addr_valid(unsigned long addr) 829int kern_addr_valid(unsigned long addr)
849{ 830{
850 unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT; 831 unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT;
@@ -1003,6 +984,7 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)
1003 } 984 }
1004 985
1005 } 986 }
987 sync_global_pgds((unsigned long)start_page, end);
1006 return 0; 988 return 0;
1007} 989}
1008 990
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 3ba6e0608c55..0369843511dc 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -362,6 +362,11 @@ static inline pte_t * __init early_ioremap_pte(unsigned long addr)
362 return &bm_pte[pte_index(addr)]; 362 return &bm_pte[pte_index(addr)];
363} 363}
364 364
365bool __init is_early_ioremap_ptep(pte_t *ptep)
366{
367 return ptep >= &bm_pte[0] && ptep < &bm_pte[PAGE_SIZE/sizeof(pte_t)];
368}
369
365static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata; 370static unsigned long slot_virt[FIX_BTMAPS_SLOTS] __initdata;
366 371
367void __init early_ioremap_init(void) 372void __init early_ioremap_init(void)
diff --git a/arch/x86/mm/k8topology_64.c b/arch/x86/mm/k8topology_64.c
index 970ed579d4e4..804a3b6c6e14 100644
--- a/arch/x86/mm/k8topology_64.c
+++ b/arch/x86/mm/k8topology_64.c
@@ -11,6 +11,8 @@
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/nodemask.h> 13#include <linux/nodemask.h>
14#include <linux/memblock.h>
15
14#include <asm/io.h> 16#include <asm/io.h>
15#include <linux/pci_ids.h> 17#include <linux/pci_ids.h>
16#include <linux/acpi.h> 18#include <linux/acpi.h>
@@ -22,7 +24,7 @@
22#include <asm/numa.h> 24#include <asm/numa.h>
23#include <asm/mpspec.h> 25#include <asm/mpspec.h>
24#include <asm/apic.h> 26#include <asm/apic.h>
25#include <asm/k8.h> 27#include <asm/amd_nb.h>
26 28
27static struct bootnode __initdata nodes[8]; 29static struct bootnode __initdata nodes[8];
28static nodemask_t __initdata nodes_parsed = NODE_MASK_NONE; 30static nodemask_t __initdata nodes_parsed = NODE_MASK_NONE;
@@ -54,8 +56,8 @@ static __init int find_northbridge(void)
54static __init void early_get_boot_cpu_id(void) 56static __init void early_get_boot_cpu_id(void)
55{ 57{
56 /* 58 /*
57 * need to get boot_cpu_id so can use that to create apicid_to_node 59 * need to get the APIC ID of the BSP so can use that to
58 * in k8_scan_nodes() 60 * create apicid_to_node in k8_scan_nodes()
59 */ 61 */
60#ifdef CONFIG_X86_MPPARSE 62#ifdef CONFIG_X86_MPPARSE
61 /* 63 /*
@@ -212,7 +214,7 @@ int __init k8_scan_nodes(void)
212 bits = boot_cpu_data.x86_coreid_bits; 214 bits = boot_cpu_data.x86_coreid_bits;
213 cores = (1<<bits); 215 cores = (1<<bits);
214 apicid_base = 0; 216 apicid_base = 0;
215 /* need to get boot_cpu_id early for system with apicid lifting */ 217 /* get the APIC ID of the BSP early for systems with apicid lifting */
216 early_get_boot_cpu_id(); 218 early_get_boot_cpu_id();
217 if (boot_cpu_physical_apicid > 0) { 219 if (boot_cpu_physical_apicid > 0) {
218 pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid); 220 pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid);
@@ -222,7 +224,7 @@ int __init k8_scan_nodes(void)
222 for_each_node_mask(i, node_possible_map) { 224 for_each_node_mask(i, node_possible_map) {
223 int j; 225 int j;
224 226
225 e820_register_active_regions(i, 227 memblock_x86_register_active_regions(i,
226 nodes[i].start >> PAGE_SHIFT, 228 nodes[i].start >> PAGE_SHIFT,
227 nodes[i].end >> PAGE_SHIFT); 229 nodes[i].end >> PAGE_SHIFT);
228 for (j = apicid_base; j < cores + apicid_base; j++) 230 for (j = apicid_base; j < cores + apicid_base; j++)
diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
index b3b531a4f8e5..d87dd6d042d6 100644
--- a/arch/x86/mm/kmemcheck/kmemcheck.c
+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
@@ -631,6 +631,8 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
631 if (!pte) 631 if (!pte)
632 return false; 632 return false;
633 633
634 WARN_ON_ONCE(in_nmi());
635
634 if (error_code & 2) 636 if (error_code & 2)
635 kmemcheck_access(regs, address, KMEMCHECK_WRITE); 637 kmemcheck_access(regs, address, KMEMCHECK_WRITE);
636 else 638 else
diff --git a/arch/x86/mm/kmemcheck/opcode.c b/arch/x86/mm/kmemcheck/opcode.c
index 63c19e27aa6f..324aa3f07237 100644
--- a/arch/x86/mm/kmemcheck/opcode.c
+++ b/arch/x86/mm/kmemcheck/opcode.c
@@ -9,7 +9,7 @@ static bool opcode_is_prefix(uint8_t b)
9 b == 0xf0 || b == 0xf2 || b == 0xf3 9 b == 0xf0 || b == 0xf2 || b == 0xf3
10 /* Group 2 */ 10 /* Group 2 */
11 || b == 0x2e || b == 0x36 || b == 0x3e || b == 0x26 11 || b == 0x2e || b == 0x36 || b == 0x3e || b == 0x26
12 || b == 0x64 || b == 0x65 || b == 0x2e || b == 0x3e 12 || b == 0x64 || b == 0x65
13 /* Group 3 */ 13 /* Group 3 */
14 || b == 0x66 14 || b == 0x66
15 /* Group 4 */ 15 /* Group 4 */
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
new file mode 100644
index 000000000000..aa1169392b83
--- /dev/null
+++ b/arch/x86/mm/memblock.c
@@ -0,0 +1,348 @@
1#include <linux/kernel.h>
2#include <linux/types.h>
3#include <linux/init.h>
4#include <linux/bitops.h>
5#include <linux/memblock.h>
6#include <linux/bootmem.h>
7#include <linux/mm.h>
8#include <linux/range.h>
9
10/* Check for already reserved areas */
11static bool __init check_with_memblock_reserved_size(u64 *addrp, u64 *sizep, u64 align)
12{
13 struct memblock_region *r;
14 u64 addr = *addrp, last;
15 u64 size = *sizep;
16 bool changed = false;
17
18again:
19 last = addr + size;
20 for_each_memblock(reserved, r) {
21 if (last > r->base && addr < r->base) {
22 size = r->base - addr;
23 changed = true;
24 goto again;
25 }
26 if (last > (r->base + r->size) && addr < (r->base + r->size)) {
27 addr = round_up(r->base + r->size, align);
28 size = last - addr;
29 changed = true;
30 goto again;
31 }
32 if (last <= (r->base + r->size) && addr >= r->base) {
33 *sizep = 0;
34 return false;
35 }
36 }
37 if (changed) {
38 *addrp = addr;
39 *sizep = size;
40 }
41 return changed;
42}
43
44/*
45 * Find next free range after start, and size is returned in *sizep
46 */
47u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align)
48{
49 struct memblock_region *r;
50
51 for_each_memblock(memory, r) {
52 u64 ei_start = r->base;
53 u64 ei_last = ei_start + r->size;
54 u64 addr;
55
56 addr = round_up(ei_start, align);
57 if (addr < start)
58 addr = round_up(start, align);
59 if (addr >= ei_last)
60 continue;
61 *sizep = ei_last - addr;
62 while (check_with_memblock_reserved_size(&addr, sizep, align))
63 ;
64
65 if (*sizep)
66 return addr;
67 }
68
69 return MEMBLOCK_ERROR;
70}
71
72static __init struct range *find_range_array(int count)
73{
74 u64 end, size, mem;
75 struct range *range;
76
77 size = sizeof(struct range) * count;
78 end = memblock.current_limit;
79
80 mem = memblock_find_in_range(0, end, size, sizeof(struct range));
81 if (mem == MEMBLOCK_ERROR)
82 panic("can not find more space for range array");
83
84 /*
85 * This range is tempoaray, so don't reserve it, it will not be
86 * overlapped because We will not alloccate new buffer before
87 * We discard this one
88 */
89 range = __va(mem);
90 memset(range, 0, size);
91
92 return range;
93}
94
95static void __init memblock_x86_subtract_reserved(struct range *range, int az)
96{
97 u64 final_start, final_end;
98 struct memblock_region *r;
99
100 /* Take out region array itself at first*/
101 memblock_free_reserved_regions();
102
103 memblock_dbg("Subtract (%ld early reservations)\n", memblock.reserved.cnt);
104
105 for_each_memblock(reserved, r) {
106 memblock_dbg(" [%010llx-%010llx]\n", (u64)r->base, (u64)r->base + r->size - 1);
107 final_start = PFN_DOWN(r->base);
108 final_end = PFN_UP(r->base + r->size);
109 if (final_start >= final_end)
110 continue;
111 subtract_range(range, az, final_start, final_end);
112 }
113
114 /* Put region array back ? */
115 memblock_reserve_reserved_regions();
116}
117
118struct count_data {
119 int nr;
120};
121
122static int __init count_work_fn(unsigned long start_pfn,
123 unsigned long end_pfn, void *datax)
124{
125 struct count_data *data = datax;
126
127 data->nr++;
128
129 return 0;
130}
131
132static int __init count_early_node_map(int nodeid)
133{
134 struct count_data data;
135
136 data.nr = 0;
137 work_with_active_regions(nodeid, count_work_fn, &data);
138
139 return data.nr;
140}
141
142int __init __get_free_all_memory_range(struct range **rangep, int nodeid,
143 unsigned long start_pfn, unsigned long end_pfn)
144{
145 int count;
146 struct range *range;
147 int nr_range;
148
149 count = (memblock.reserved.cnt + count_early_node_map(nodeid)) * 2;
150
151 range = find_range_array(count);
152 nr_range = 0;
153
154 /*
155 * Use early_node_map[] and memblock.reserved.region to get range array
156 * at first
157 */
158 nr_range = add_from_early_node_map(range, count, nr_range, nodeid);
159 subtract_range(range, count, 0, start_pfn);
160 subtract_range(range, count, end_pfn, -1ULL);
161
162 memblock_x86_subtract_reserved(range, count);
163 nr_range = clean_sort_range(range, count);
164
165 *rangep = range;
166 return nr_range;
167}
168
169int __init get_free_all_memory_range(struct range **rangep, int nodeid)
170{
171 unsigned long end_pfn = -1UL;
172
173#ifdef CONFIG_X86_32
174 end_pfn = max_low_pfn;
175#endif
176 return __get_free_all_memory_range(rangep, nodeid, 0, end_pfn);
177}
178
179static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
180{
181 int i, count;
182 struct range *range;
183 int nr_range;
184 u64 final_start, final_end;
185 u64 free_size;
186 struct memblock_region *r;
187
188 count = (memblock.reserved.cnt + memblock.memory.cnt) * 2;
189
190 range = find_range_array(count);
191 nr_range = 0;
192
193 addr = PFN_UP(addr);
194 limit = PFN_DOWN(limit);
195
196 for_each_memblock(memory, r) {
197 final_start = PFN_UP(r->base);
198 final_end = PFN_DOWN(r->base + r->size);
199 if (final_start >= final_end)
200 continue;
201 if (final_start >= limit || final_end <= addr)
202 continue;
203
204 nr_range = add_range(range, count, nr_range, final_start, final_end);
205 }
206 subtract_range(range, count, 0, addr);
207 subtract_range(range, count, limit, -1ULL);
208
209 /* Subtract memblock.reserved.region in range ? */
210 if (!get_free)
211 goto sort_and_count_them;
212 for_each_memblock(reserved, r) {
213 final_start = PFN_DOWN(r->base);
214 final_end = PFN_UP(r->base + r->size);
215 if (final_start >= final_end)
216 continue;
217 if (final_start >= limit || final_end <= addr)
218 continue;
219
220 subtract_range(range, count, final_start, final_end);
221 }
222
223sort_and_count_them:
224 nr_range = clean_sort_range(range, count);
225
226 free_size = 0;
227 for (i = 0; i < nr_range; i++)
228 free_size += range[i].end - range[i].start;
229
230 return free_size << PAGE_SHIFT;
231}
232
233u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
234{
235 return __memblock_x86_memory_in_range(addr, limit, true);
236}
237
238u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit)
239{
240 return __memblock_x86_memory_in_range(addr, limit, false);
241}
242
243void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
244{
245 if (start == end)
246 return;
247
248 if (WARN_ONCE(start > end, "memblock_x86_reserve_range: wrong range [%#llx, %#llx)\n", start, end))
249 return;
250
251 memblock_dbg(" memblock_x86_reserve_range: [%#010llx-%#010llx] %16s\n", start, end - 1, name);
252
253 memblock_reserve(start, end - start);
254}
255
256void __init memblock_x86_free_range(u64 start, u64 end)
257{
258 if (start == end)
259 return;
260
261 if (WARN_ONCE(start > end, "memblock_x86_free_range: wrong range [%#llx, %#llx)\n", start, end))
262 return;
263
264 memblock_dbg(" memblock_x86_free_range: [%#010llx-%#010llx]\n", start, end - 1);
265
266 memblock_free(start, end - start);
267}
268
269/*
270 * Need to call this function after memblock_x86_register_active_regions,
271 * so early_node_map[] is filled already.
272 */
273u64 __init memblock_x86_find_in_range_node(int nid, u64 start, u64 end, u64 size, u64 align)
274{
275 u64 addr;
276 addr = find_memory_core_early(nid, size, align, start, end);
277 if (addr != MEMBLOCK_ERROR)
278 return addr;
279
280 /* Fallback, should already have start end within node range */
281 return memblock_find_in_range(start, end, size, align);
282}
283
284/*
285 * Finds an active region in the address range from start_pfn to last_pfn and
286 * returns its range in ei_startpfn and ei_endpfn for the memblock entry.
287 */
288static int __init memblock_x86_find_active_region(const struct memblock_region *ei,
289 unsigned long start_pfn,
290 unsigned long last_pfn,
291 unsigned long *ei_startpfn,
292 unsigned long *ei_endpfn)
293{
294 u64 align = PAGE_SIZE;
295
296 *ei_startpfn = round_up(ei->base, align) >> PAGE_SHIFT;
297 *ei_endpfn = round_down(ei->base + ei->size, align) >> PAGE_SHIFT;
298
299 /* Skip map entries smaller than a page */
300 if (*ei_startpfn >= *ei_endpfn)
301 return 0;
302
303 /* Skip if map is outside the node */
304 if (*ei_endpfn <= start_pfn || *ei_startpfn >= last_pfn)
305 return 0;
306
307 /* Check for overlaps */
308 if (*ei_startpfn < start_pfn)
309 *ei_startpfn = start_pfn;
310 if (*ei_endpfn > last_pfn)
311 *ei_endpfn = last_pfn;
312
313 return 1;
314}
315
316/* Walk the memblock.memory map and register active regions within a node */
317void __init memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
318 unsigned long last_pfn)
319{
320 unsigned long ei_startpfn;
321 unsigned long ei_endpfn;
322 struct memblock_region *r;
323
324 for_each_memblock(memory, r)
325 if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
326 &ei_startpfn, &ei_endpfn))
327 add_active_range(nid, ei_startpfn, ei_endpfn);
328}
329
330/*
331 * Find the hole size (in bytes) in the memory range.
332 * @start: starting address of the memory range to scan
333 * @end: ending address of the memory range to scan
334 */
335u64 __init memblock_x86_hole_size(u64 start, u64 end)
336{
337 unsigned long start_pfn = start >> PAGE_SHIFT;
338 unsigned long last_pfn = end >> PAGE_SHIFT;
339 unsigned long ei_startpfn, ei_endpfn, ram = 0;
340 struct memblock_region *r;
341
342 for_each_memblock(memory, r)
343 if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
344 &ei_startpfn, &ei_endpfn))
345 ram += ei_endpfn - ei_startpfn;
346
347 return end - start - ((u64)ram << PAGE_SHIFT);
348}
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 18d244f70205..92faf3a1c53e 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -6,8 +6,7 @@
6#include <linux/smp.h> 6#include <linux/smp.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/pfn.h> 8#include <linux/pfn.h>
9 9#include <linux/memblock.h>
10#include <asm/e820.h>
11 10
12static u64 patterns[] __initdata = { 11static u64 patterns[] __initdata = {
13 0, 12 0,
@@ -35,7 +34,7 @@ static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)
35 (unsigned long long) pattern, 34 (unsigned long long) pattern,
36 (unsigned long long) start_bad, 35 (unsigned long long) start_bad,
37 (unsigned long long) end_bad); 36 (unsigned long long) end_bad);
38 reserve_early(start_bad, end_bad, "BAD RAM"); 37 memblock_x86_reserve_range(start_bad, end_bad, "BAD RAM");
39} 38}
40 39
41static void __init memtest(u64 pattern, u64 start_phys, u64 size) 40static void __init memtest(u64 pattern, u64 start_phys, u64 size)
@@ -74,7 +73,7 @@ static void __init do_one_pass(u64 pattern, u64 start, u64 end)
74 u64 size = 0; 73 u64 size = 0;
75 74
76 while (start < end) { 75 while (start < end) {
77 start = find_e820_area_size(start, &size, 1); 76 start = memblock_x86_find_in_range_size(start, &size, 1);
78 77
79 /* done ? */ 78 /* done ? */
80 if (start >= end) 79 if (start >= end)
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 809baaaf48b1..84a3e4c9f277 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/bootmem.h> 26#include <linux/bootmem.h>
27#include <linux/memblock.h>
27#include <linux/mmzone.h> 28#include <linux/mmzone.h>
28#include <linux/highmem.h> 29#include <linux/highmem.h>
29#include <linux/initrd.h> 30#include <linux/initrd.h>
@@ -120,7 +121,7 @@ int __init get_memcfg_numa_flat(void)
120 121
121 node_start_pfn[0] = 0; 122 node_start_pfn[0] = 0;
122 node_end_pfn[0] = max_pfn; 123 node_end_pfn[0] = max_pfn;
123 e820_register_active_regions(0, 0, max_pfn); 124 memblock_x86_register_active_regions(0, 0, max_pfn);
124 memory_present(0, 0, max_pfn); 125 memory_present(0, 0, max_pfn);
125 node_remap_size[0] = node_memmap_size_bytes(0, 0, max_pfn); 126 node_remap_size[0] = node_memmap_size_bytes(0, 0, max_pfn);
126 127
@@ -161,14 +162,14 @@ static void __init allocate_pgdat(int nid)
161 NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid]; 162 NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid];
162 else { 163 else {
163 unsigned long pgdat_phys; 164 unsigned long pgdat_phys;
164 pgdat_phys = find_e820_area(min_low_pfn<<PAGE_SHIFT, 165 pgdat_phys = memblock_find_in_range(min_low_pfn<<PAGE_SHIFT,
165 max_pfn_mapped<<PAGE_SHIFT, 166 max_pfn_mapped<<PAGE_SHIFT,
166 sizeof(pg_data_t), 167 sizeof(pg_data_t),
167 PAGE_SIZE); 168 PAGE_SIZE);
168 NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(pgdat_phys>>PAGE_SHIFT)); 169 NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(pgdat_phys>>PAGE_SHIFT));
169 memset(buf, 0, sizeof(buf)); 170 memset(buf, 0, sizeof(buf));
170 sprintf(buf, "NODE_DATA %d", nid); 171 sprintf(buf, "NODE_DATA %d", nid);
171 reserve_early(pgdat_phys, pgdat_phys + sizeof(pg_data_t), buf); 172 memblock_x86_reserve_range(pgdat_phys, pgdat_phys + sizeof(pg_data_t), buf);
172 } 173 }
173 printk(KERN_DEBUG "allocate_pgdat: node %d NODE_DATA %08lx\n", 174 printk(KERN_DEBUG "allocate_pgdat: node %d NODE_DATA %08lx\n",
174 nid, (unsigned long)NODE_DATA(nid)); 175 nid, (unsigned long)NODE_DATA(nid));
@@ -291,15 +292,15 @@ static __init unsigned long calculate_numa_remap_pages(void)
291 PTRS_PER_PTE); 292 PTRS_PER_PTE);
292 node_kva_target <<= PAGE_SHIFT; 293 node_kva_target <<= PAGE_SHIFT;
293 do { 294 do {
294 node_kva_final = find_e820_area(node_kva_target, 295 node_kva_final = memblock_find_in_range(node_kva_target,
295 ((u64)node_end_pfn[nid])<<PAGE_SHIFT, 296 ((u64)node_end_pfn[nid])<<PAGE_SHIFT,
296 ((u64)size)<<PAGE_SHIFT, 297 ((u64)size)<<PAGE_SHIFT,
297 LARGE_PAGE_BYTES); 298 LARGE_PAGE_BYTES);
298 node_kva_target -= LARGE_PAGE_BYTES; 299 node_kva_target -= LARGE_PAGE_BYTES;
299 } while (node_kva_final == -1ULL && 300 } while (node_kva_final == MEMBLOCK_ERROR &&
300 (node_kva_target>>PAGE_SHIFT) > (node_start_pfn[nid])); 301 (node_kva_target>>PAGE_SHIFT) > (node_start_pfn[nid]));
301 302
302 if (node_kva_final == -1ULL) 303 if (node_kva_final == MEMBLOCK_ERROR)
303 panic("Can not get kva ram\n"); 304 panic("Can not get kva ram\n");
304 305
305 node_remap_size[nid] = size; 306 node_remap_size[nid] = size;
@@ -318,15 +319,13 @@ static __init unsigned long calculate_numa_remap_pages(void)
318 * but we could have some hole in high memory, and it will only 319 * but we could have some hole in high memory, and it will only
319 * check page_is_ram(pfn) && !page_is_reserved_early(pfn) to decide 320 * check page_is_ram(pfn) && !page_is_reserved_early(pfn) to decide
320 * to use it as free. 321 * to use it as free.
321 * So reserve_early here, hope we don't run out of that array 322 * So memblock_x86_reserve_range here, hope we don't run out of that array
322 */ 323 */
323 reserve_early(node_kva_final, 324 memblock_x86_reserve_range(node_kva_final,
324 node_kva_final+(((u64)size)<<PAGE_SHIFT), 325 node_kva_final+(((u64)size)<<PAGE_SHIFT),
325 "KVA RAM"); 326 "KVA RAM");
326 327
327 node_remap_start_pfn[nid] = node_kva_final>>PAGE_SHIFT; 328 node_remap_start_pfn[nid] = node_kva_final>>PAGE_SHIFT;
328 remove_active_range(nid, node_remap_start_pfn[nid],
329 node_remap_start_pfn[nid] + size);
330 } 329 }
331 printk(KERN_INFO "Reserving total of %lx pages for numa KVA remap\n", 330 printk(KERN_INFO "Reserving total of %lx pages for numa KVA remap\n",
332 reserve_pages); 331 reserve_pages);
@@ -367,14 +366,14 @@ void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn,
367 366
368 kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE); 367 kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
369 do { 368 do {
370 kva_start_pfn = find_e820_area(kva_target_pfn<<PAGE_SHIFT, 369 kva_start_pfn = memblock_find_in_range(kva_target_pfn<<PAGE_SHIFT,
371 max_low_pfn<<PAGE_SHIFT, 370 max_low_pfn<<PAGE_SHIFT,
372 kva_pages<<PAGE_SHIFT, 371 kva_pages<<PAGE_SHIFT,
373 PTRS_PER_PTE<<PAGE_SHIFT) >> PAGE_SHIFT; 372 PTRS_PER_PTE<<PAGE_SHIFT) >> PAGE_SHIFT;
374 kva_target_pfn -= PTRS_PER_PTE; 373 kva_target_pfn -= PTRS_PER_PTE;
375 } while (kva_start_pfn == -1UL && kva_target_pfn > min_low_pfn); 374 } while (kva_start_pfn == MEMBLOCK_ERROR && kva_target_pfn > min_low_pfn);
376 375
377 if (kva_start_pfn == -1UL) 376 if (kva_start_pfn == MEMBLOCK_ERROR)
378 panic("Can not get kva space\n"); 377 panic("Can not get kva space\n");
379 378
380 printk(KERN_INFO "kva_start_pfn ~ %lx max_low_pfn ~ %lx\n", 379 printk(KERN_INFO "kva_start_pfn ~ %lx max_low_pfn ~ %lx\n",
@@ -382,7 +381,7 @@ void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn,
382 printk(KERN_INFO "max_pfn = %lx\n", max_pfn); 381 printk(KERN_INFO "max_pfn = %lx\n", max_pfn);
383 382
384 /* avoid clash with initrd */ 383 /* avoid clash with initrd */
385 reserve_early(kva_start_pfn<<PAGE_SHIFT, 384 memblock_x86_reserve_range(kva_start_pfn<<PAGE_SHIFT,
386 (kva_start_pfn + kva_pages)<<PAGE_SHIFT, 385 (kva_start_pfn + kva_pages)<<PAGE_SHIFT,
387 "KVA PG"); 386 "KVA PG");
388#ifdef CONFIG_HIGHMEM 387#ifdef CONFIG_HIGHMEM
@@ -419,9 +418,6 @@ void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn,
419 for_each_online_node(nid) { 418 for_each_online_node(nid) {
420 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); 419 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
421 NODE_DATA(nid)->node_id = nid; 420 NODE_DATA(nid)->node_id = nid;
422#ifndef CONFIG_NO_BOOTMEM
423 NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
424#endif
425 } 421 }
426 422
427 setup_bootmem_allocator(); 423 setup_bootmem_allocator();
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index a7bcc23ef96c..60f498511dd6 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -7,6 +7,7 @@
7#include <linux/string.h> 7#include <linux/string.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/memblock.h>
10#include <linux/mmzone.h> 11#include <linux/mmzone.h>
11#include <linux/ctype.h> 12#include <linux/ctype.h>
12#include <linux/module.h> 13#include <linux/module.h>
@@ -18,7 +19,7 @@
18#include <asm/dma.h> 19#include <asm/dma.h>
19#include <asm/numa.h> 20#include <asm/numa.h>
20#include <asm/acpi.h> 21#include <asm/acpi.h>
21#include <asm/k8.h> 22#include <asm/amd_nb.h>
22 23
23struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 24struct pglist_data *node_data[MAX_NUMNODES] __read_mostly;
24EXPORT_SYMBOL(node_data); 25EXPORT_SYMBOL(node_data);
@@ -86,16 +87,16 @@ static int __init allocate_cachealigned_memnodemap(void)
86 87
87 addr = 0x8000; 88 addr = 0x8000;
88 nodemap_size = roundup(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES); 89 nodemap_size = roundup(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES);
89 nodemap_addr = find_e820_area(addr, max_pfn<<PAGE_SHIFT, 90 nodemap_addr = memblock_find_in_range(addr, max_pfn<<PAGE_SHIFT,
90 nodemap_size, L1_CACHE_BYTES); 91 nodemap_size, L1_CACHE_BYTES);
91 if (nodemap_addr == -1UL) { 92 if (nodemap_addr == MEMBLOCK_ERROR) {
92 printk(KERN_ERR 93 printk(KERN_ERR
93 "NUMA: Unable to allocate Memory to Node hash map\n"); 94 "NUMA: Unable to allocate Memory to Node hash map\n");
94 nodemap_addr = nodemap_size = 0; 95 nodemap_addr = nodemap_size = 0;
95 return -1; 96 return -1;
96 } 97 }
97 memnodemap = phys_to_virt(nodemap_addr); 98 memnodemap = phys_to_virt(nodemap_addr);
98 reserve_early(nodemap_addr, nodemap_addr + nodemap_size, "MEMNODEMAP"); 99 memblock_x86_reserve_range(nodemap_addr, nodemap_addr + nodemap_size, "MEMNODEMAP");
99 100
100 printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n", 101 printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n",
101 nodemap_addr, nodemap_addr + nodemap_size); 102 nodemap_addr, nodemap_addr + nodemap_size);
@@ -171,8 +172,8 @@ static void * __init early_node_mem(int nodeid, unsigned long start,
171 if (start < (MAX_DMA32_PFN<<PAGE_SHIFT) && 172 if (start < (MAX_DMA32_PFN<<PAGE_SHIFT) &&
172 end > (MAX_DMA32_PFN<<PAGE_SHIFT)) 173 end > (MAX_DMA32_PFN<<PAGE_SHIFT))
173 start = MAX_DMA32_PFN<<PAGE_SHIFT; 174 start = MAX_DMA32_PFN<<PAGE_SHIFT;
174 mem = find_e820_area(start, end, size, align); 175 mem = memblock_x86_find_in_range_node(nodeid, start, end, size, align);
175 if (mem != -1L) 176 if (mem != MEMBLOCK_ERROR)
176 return __va(mem); 177 return __va(mem);
177 178
178 /* extend the search scope */ 179 /* extend the search scope */
@@ -181,8 +182,8 @@ static void * __init early_node_mem(int nodeid, unsigned long start,
181 start = MAX_DMA32_PFN<<PAGE_SHIFT; 182 start = MAX_DMA32_PFN<<PAGE_SHIFT;
182 else 183 else
183 start = MAX_DMA_PFN<<PAGE_SHIFT; 184 start = MAX_DMA_PFN<<PAGE_SHIFT;
184 mem = find_e820_area(start, end, size, align); 185 mem = memblock_x86_find_in_range_node(nodeid, start, end, size, align);
185 if (mem != -1L) 186 if (mem != MEMBLOCK_ERROR)
186 return __va(mem); 187 return __va(mem);
187 188
188 printk(KERN_ERR "Cannot find %lu bytes in node %d\n", 189 printk(KERN_ERR "Cannot find %lu bytes in node %d\n",
@@ -198,10 +199,6 @@ setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
198 unsigned long start_pfn, last_pfn, nodedata_phys; 199 unsigned long start_pfn, last_pfn, nodedata_phys;
199 const int pgdat_size = roundup(sizeof(pg_data_t), PAGE_SIZE); 200 const int pgdat_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
200 int nid; 201 int nid;
201#ifndef CONFIG_NO_BOOTMEM
202 unsigned long bootmap_start, bootmap_pages, bootmap_size;
203 void *bootmap;
204#endif
205 202
206 if (!end) 203 if (!end)
207 return; 204 return;
@@ -226,7 +223,7 @@ setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
226 if (node_data[nodeid] == NULL) 223 if (node_data[nodeid] == NULL)
227 return; 224 return;
228 nodedata_phys = __pa(node_data[nodeid]); 225 nodedata_phys = __pa(node_data[nodeid]);
229 reserve_early(nodedata_phys, nodedata_phys + pgdat_size, "NODE_DATA"); 226 memblock_x86_reserve_range(nodedata_phys, nodedata_phys + pgdat_size, "NODE_DATA");
230 printk(KERN_INFO " NODE_DATA [%016lx - %016lx]\n", nodedata_phys, 227 printk(KERN_INFO " NODE_DATA [%016lx - %016lx]\n", nodedata_phys,
231 nodedata_phys + pgdat_size - 1); 228 nodedata_phys + pgdat_size - 1);
232 nid = phys_to_nid(nodedata_phys); 229 nid = phys_to_nid(nodedata_phys);
@@ -238,47 +235,6 @@ setup_node_bootmem(int nodeid, unsigned long start, unsigned long end)
238 NODE_DATA(nodeid)->node_start_pfn = start_pfn; 235 NODE_DATA(nodeid)->node_start_pfn = start_pfn;
239 NODE_DATA(nodeid)->node_spanned_pages = last_pfn - start_pfn; 236 NODE_DATA(nodeid)->node_spanned_pages = last_pfn - start_pfn;
240 237
241#ifndef CONFIG_NO_BOOTMEM
242 NODE_DATA(nodeid)->bdata = &bootmem_node_data[nodeid];
243
244 /*
245 * Find a place for the bootmem map
246 * nodedata_phys could be on other nodes by alloc_bootmem,
247 * so need to sure bootmap_start not to be small, otherwise
248 * early_node_mem will get that with find_e820_area instead
249 * of alloc_bootmem, that could clash with reserved range
250 */
251 bootmap_pages = bootmem_bootmap_pages(last_pfn - start_pfn);
252 bootmap_start = roundup(nodedata_phys + pgdat_size, PAGE_SIZE);
253 /*
254 * SMP_CACHE_BYTES could be enough, but init_bootmem_node like
255 * to use that to align to PAGE_SIZE
256 */
257 bootmap = early_node_mem(nodeid, bootmap_start, end,
258 bootmap_pages<<PAGE_SHIFT, PAGE_SIZE);
259 if (bootmap == NULL) {
260 free_early(nodedata_phys, nodedata_phys + pgdat_size);
261 node_data[nodeid] = NULL;
262 return;
263 }
264 bootmap_start = __pa(bootmap);
265 reserve_early(bootmap_start, bootmap_start+(bootmap_pages<<PAGE_SHIFT),
266 "BOOTMAP");
267
268 bootmap_size = init_bootmem_node(NODE_DATA(nodeid),
269 bootmap_start >> PAGE_SHIFT,
270 start_pfn, last_pfn);
271
272 printk(KERN_INFO " bootmap [%016lx - %016lx] pages %lx\n",
273 bootmap_start, bootmap_start + bootmap_size - 1,
274 bootmap_pages);
275 nid = phys_to_nid(bootmap_start);
276 if (nid != nodeid)
277 printk(KERN_INFO " bootmap(%d) on node %d\n", nodeid, nid);
278
279 free_bootmem_with_active_regions(nodeid, end);
280#endif
281
282 node_set_online(nodeid); 238 node_set_online(nodeid);
283} 239}
284 240
@@ -416,7 +372,7 @@ static int __init split_nodes_interleave(u64 addr, u64 max_addr,
416 nr_nodes = MAX_NUMNODES; 372 nr_nodes = MAX_NUMNODES;
417 } 373 }
418 374
419 size = (max_addr - addr - e820_hole_size(addr, max_addr)) / nr_nodes; 375 size = (max_addr - addr - memblock_x86_hole_size(addr, max_addr)) / nr_nodes;
420 /* 376 /*
421 * Calculate the number of big nodes that can be allocated as a result 377 * Calculate the number of big nodes that can be allocated as a result
422 * of consolidating the remainder. 378 * of consolidating the remainder.
@@ -452,7 +408,7 @@ static int __init split_nodes_interleave(u64 addr, u64 max_addr,
452 * non-reserved memory is less than the per-node size. 408 * non-reserved memory is less than the per-node size.
453 */ 409 */
454 while (end - physnodes[i].start - 410 while (end - physnodes[i].start -
455 e820_hole_size(physnodes[i].start, end) < size) { 411 memblock_x86_hole_size(physnodes[i].start, end) < size) {
456 end += FAKE_NODE_MIN_SIZE; 412 end += FAKE_NODE_MIN_SIZE;
457 if (end > physnodes[i].end) { 413 if (end > physnodes[i].end) {
458 end = physnodes[i].end; 414 end = physnodes[i].end;
@@ -466,7 +422,7 @@ static int __init split_nodes_interleave(u64 addr, u64 max_addr,
466 * this one must extend to the boundary. 422 * this one must extend to the boundary.
467 */ 423 */
468 if (end < dma32_end && dma32_end - end - 424 if (end < dma32_end && dma32_end - end -
469 e820_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) 425 memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
470 end = dma32_end; 426 end = dma32_end;
471 427
472 /* 428 /*
@@ -475,7 +431,7 @@ static int __init split_nodes_interleave(u64 addr, u64 max_addr,
475 * physical node. 431 * physical node.
476 */ 432 */
477 if (physnodes[i].end - end - 433 if (physnodes[i].end - end -
478 e820_hole_size(end, physnodes[i].end) < size) 434 memblock_x86_hole_size(end, physnodes[i].end) < size)
479 end = physnodes[i].end; 435 end = physnodes[i].end;
480 436
481 /* 437 /*
@@ -503,7 +459,7 @@ static u64 __init find_end_of_node(u64 start, u64 max_addr, u64 size)
503{ 459{
504 u64 end = start + size; 460 u64 end = start + size;
505 461
506 while (end - start - e820_hole_size(start, end) < size) { 462 while (end - start - memblock_x86_hole_size(start, end) < size) {
507 end += FAKE_NODE_MIN_SIZE; 463 end += FAKE_NODE_MIN_SIZE;
508 if (end > max_addr) { 464 if (end > max_addr) {
509 end = max_addr; 465 end = max_addr;
@@ -532,7 +488,7 @@ static int __init split_nodes_size_interleave(u64 addr, u64 max_addr, u64 size)
532 * creates a uniform distribution of node sizes across the entire 488 * creates a uniform distribution of node sizes across the entire
533 * machine (but not necessarily over physical nodes). 489 * machine (but not necessarily over physical nodes).
534 */ 490 */
535 min_size = (max_addr - addr - e820_hole_size(addr, max_addr)) / 491 min_size = (max_addr - addr - memblock_x86_hole_size(addr, max_addr)) /
536 MAX_NUMNODES; 492 MAX_NUMNODES;
537 min_size = max(min_size, FAKE_NODE_MIN_SIZE); 493 min_size = max(min_size, FAKE_NODE_MIN_SIZE);
538 if ((min_size & FAKE_NODE_MIN_HASH_MASK) < min_size) 494 if ((min_size & FAKE_NODE_MIN_HASH_MASK) < min_size)
@@ -565,7 +521,7 @@ static int __init split_nodes_size_interleave(u64 addr, u64 max_addr, u64 size)
565 * this one must extend to the boundary. 521 * this one must extend to the boundary.
566 */ 522 */
567 if (end < dma32_end && dma32_end - end - 523 if (end < dma32_end && dma32_end - end -
568 e820_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE) 524 memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
569 end = dma32_end; 525 end = dma32_end;
570 526
571 /* 527 /*
@@ -574,7 +530,7 @@ static int __init split_nodes_size_interleave(u64 addr, u64 max_addr, u64 size)
574 * physical node. 530 * physical node.
575 */ 531 */
576 if (physnodes[i].end - end - 532 if (physnodes[i].end - end -
577 e820_hole_size(end, physnodes[i].end) < size) 533 memblock_x86_hole_size(end, physnodes[i].end) < size)
578 end = physnodes[i].end; 534 end = physnodes[i].end;
579 535
580 /* 536 /*
@@ -638,7 +594,7 @@ static int __init numa_emulation(unsigned long start_pfn,
638 */ 594 */
639 remove_all_active_ranges(); 595 remove_all_active_ranges();
640 for_each_node_mask(i, node_possible_map) { 596 for_each_node_mask(i, node_possible_map) {
641 e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT, 597 memblock_x86_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
642 nodes[i].end >> PAGE_SHIFT); 598 nodes[i].end >> PAGE_SHIFT);
643 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 599 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
644 } 600 }
@@ -691,7 +647,7 @@ void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn,
691 node_set(0, node_possible_map); 647 node_set(0, node_possible_map);
692 for (i = 0; i < nr_cpu_ids; i++) 648 for (i = 0; i < nr_cpu_ids; i++)
693 numa_set_node(i, 0); 649 numa_set_node(i, 0);
694 e820_register_active_regions(0, start_pfn, last_pfn); 650 memblock_x86_register_active_regions(0, start_pfn, last_pfn);
695 setup_node_bootmem(0, start_pfn << PAGE_SHIFT, last_pfn << PAGE_SHIFT); 651 setup_node_bootmem(0, start_pfn << PAGE_SHIFT, last_pfn << PAGE_SHIFT);
696} 652}
697 653
@@ -703,9 +659,7 @@ unsigned long __init numa_free_all_bootmem(void)
703 for_each_online_node(i) 659 for_each_online_node(i)
704 pages += free_all_bootmem_node(NODE_DATA(i)); 660 pages += free_all_bootmem_node(NODE_DATA(i));
705 661
706#ifdef CONFIG_NO_BOOTMEM
707 pages += free_all_memory_core_early(MAX_NUMNODES); 662 pages += free_all_memory_core_early(MAX_NUMNODES);
708#endif
709 663
710 return pages; 664 return pages;
711} 665}
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 5c4ee422590e..8be8c7d7bc89 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -87,7 +87,19 @@ static inline void pgd_list_del(pgd_t *pgd)
87#define UNSHARED_PTRS_PER_PGD \ 87#define UNSHARED_PTRS_PER_PGD \
88 (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD) 88 (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
89 89
90static void pgd_ctor(pgd_t *pgd) 90
91static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
92{
93 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
94 virt_to_page(pgd)->index = (pgoff_t)mm;
95}
96
97struct mm_struct *pgd_page_get_mm(struct page *page)
98{
99 return (struct mm_struct *)page->index;
100}
101
102static void pgd_ctor(struct mm_struct *mm, pgd_t *pgd)
91{ 103{
92 /* If the pgd points to a shared pagetable level (either the 104 /* If the pgd points to a shared pagetable level (either the
93 ptes in non-PAE, or shared PMD in PAE), then just copy the 105 ptes in non-PAE, or shared PMD in PAE), then just copy the
@@ -98,15 +110,13 @@ static void pgd_ctor(pgd_t *pgd)
98 clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY, 110 clone_pgd_range(pgd + KERNEL_PGD_BOUNDARY,
99 swapper_pg_dir + KERNEL_PGD_BOUNDARY, 111 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
100 KERNEL_PGD_PTRS); 112 KERNEL_PGD_PTRS);
101 paravirt_alloc_pmd_clone(__pa(pgd) >> PAGE_SHIFT,
102 __pa(swapper_pg_dir) >> PAGE_SHIFT,
103 KERNEL_PGD_BOUNDARY,
104 KERNEL_PGD_PTRS);
105 } 113 }
106 114
107 /* list required to sync kernel mapping updates */ 115 /* list required to sync kernel mapping updates */
108 if (!SHARED_KERNEL_PMD) 116 if (!SHARED_KERNEL_PMD) {
117 pgd_set_mm(pgd, mm);
109 pgd_list_add(pgd); 118 pgd_list_add(pgd);
119 }
110} 120}
111 121
112static void pgd_dtor(pgd_t *pgd) 122static void pgd_dtor(pgd_t *pgd)
@@ -272,7 +282,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
272 */ 282 */
273 spin_lock_irqsave(&pgd_lock, flags); 283 spin_lock_irqsave(&pgd_lock, flags);
274 284
275 pgd_ctor(pgd); 285 pgd_ctor(mm, pgd);
276 pgd_prepopulate_pmd(mm, pgd, pmds); 286 pgd_prepopulate_pmd(mm, pgd, pmds);
277 287
278 spin_unlock_irqrestore(&pgd_lock, flags); 288 spin_unlock_irqrestore(&pgd_lock, flags);
diff --git a/arch/x86/mm/srat_32.c b/arch/x86/mm/srat_32.c
index 9324f13492d5..a17dffd136c1 100644
--- a/arch/x86/mm/srat_32.c
+++ b/arch/x86/mm/srat_32.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/memblock.h>
28#include <linux/mmzone.h> 29#include <linux/mmzone.h>
29#include <linux/acpi.h> 30#include <linux/acpi.h>
30#include <linux/nodemask.h> 31#include <linux/nodemask.h>
@@ -264,7 +265,7 @@ int __init get_memcfg_from_srat(void)
264 if (node_read_chunk(chunk->nid, chunk)) 265 if (node_read_chunk(chunk->nid, chunk))
265 continue; 266 continue;
266 267
267 e820_register_active_regions(chunk->nid, chunk->start_pfn, 268 memblock_x86_register_active_regions(chunk->nid, chunk->start_pfn,
268 min(chunk->end_pfn, max_pfn)); 269 min(chunk->end_pfn, max_pfn));
269 } 270 }
270 /* for out of order entries in SRAT */ 271 /* for out of order entries in SRAT */
diff --git a/arch/x86/mm/srat_64.c b/arch/x86/mm/srat_64.c
index f9897f7a9ef1..a35cb9d8b060 100644
--- a/arch/x86/mm/srat_64.c
+++ b/arch/x86/mm/srat_64.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/topology.h> 17#include <linux/topology.h>
18#include <linux/bootmem.h> 18#include <linux/bootmem.h>
19#include <linux/memblock.h>
19#include <linux/mm.h> 20#include <linux/mm.h>
20#include <asm/proto.h> 21#include <asm/proto.h>
21#include <asm/numa.h> 22#include <asm/numa.h>
@@ -98,15 +99,15 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
98 unsigned long phys; 99 unsigned long phys;
99 100
100 length = slit->header.length; 101 length = slit->header.length;
101 phys = find_e820_area(0, max_pfn_mapped<<PAGE_SHIFT, length, 102 phys = memblock_find_in_range(0, max_pfn_mapped<<PAGE_SHIFT, length,
102 PAGE_SIZE); 103 PAGE_SIZE);
103 104
104 if (phys == -1L) 105 if (phys == MEMBLOCK_ERROR)
105 panic(" Can not save slit!\n"); 106 panic(" Can not save slit!\n");
106 107
107 acpi_slit = __va(phys); 108 acpi_slit = __va(phys);
108 memcpy(acpi_slit, slit, length); 109 memcpy(acpi_slit, slit, length);
109 reserve_early(phys, phys + length, "ACPI SLIT"); 110 memblock_x86_reserve_range(phys, phys + length, "ACPI SLIT");
110} 111}
111 112
112/* Callback for Proximity Domain -> x2APIC mapping */ 113/* Callback for Proximity Domain -> x2APIC mapping */
@@ -324,7 +325,7 @@ static int __init nodes_cover_memory(const struct bootnode *nodes)
324 pxmram = 0; 325 pxmram = 0;
325 } 326 }
326 327
327 e820ram = max_pfn - (e820_hole_size(0, max_pfn<<PAGE_SHIFT)>>PAGE_SHIFT); 328 e820ram = max_pfn - (memblock_x86_hole_size(0, max_pfn<<PAGE_SHIFT)>>PAGE_SHIFT);
328 /* We seem to lose 3 pages somewhere. Allow 1M of slack. */ 329 /* We seem to lose 3 pages somewhere. Allow 1M of slack. */
329 if ((long)(e820ram - pxmram) >= (1<<(20 - PAGE_SHIFT))) { 330 if ((long)(e820ram - pxmram) >= (1<<(20 - PAGE_SHIFT))) {
330 printk(KERN_ERR 331 printk(KERN_ERR
@@ -420,9 +421,11 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
420 return -1; 421 return -1;
421 } 422 }
422 423
423 for_each_node_mask(i, nodes_parsed) 424 for (i = 0; i < num_node_memblks; i++)
424 e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT, 425 memblock_x86_register_active_regions(memblk_nodeid[i],
425 nodes[i].end >> PAGE_SHIFT); 426 node_memblk_range[i].start >> PAGE_SHIFT,
427 node_memblk_range[i].end >> PAGE_SHIFT);
428
426 /* for out of order entries in SRAT */ 429 /* for out of order entries in SRAT */
427 sort_node_map(); 430 sort_node_map();
428 if (!nodes_cover_memory(nodes)) { 431 if (!nodes_cover_memory(nodes)) {
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index c03f14ab6667..49358481c733 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -5,6 +5,7 @@
5#include <linux/smp.h> 5#include <linux/smp.h>
6#include <linux/interrupt.h> 6#include <linux/interrupt.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/cpu.h>
8 9
9#include <asm/tlbflush.h> 10#include <asm/tlbflush.h>
10#include <asm/mmu_context.h> 11#include <asm/mmu_context.h>
@@ -52,6 +53,8 @@ union smp_flush_state {
52 want false sharing in the per cpu data segment. */ 53 want false sharing in the per cpu data segment. */
53static union smp_flush_state flush_state[NUM_INVALIDATE_TLB_VECTORS]; 54static union smp_flush_state flush_state[NUM_INVALIDATE_TLB_VECTORS];
54 55
56static DEFINE_PER_CPU_READ_MOSTLY(int, tlb_vector_offset);
57
55/* 58/*
56 * We cannot call mmdrop() because we are in interrupt context, 59 * We cannot call mmdrop() because we are in interrupt context,
57 * instead update mm->cpu_vm_mask. 60 * instead update mm->cpu_vm_mask.
@@ -173,7 +176,7 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,
173 union smp_flush_state *f; 176 union smp_flush_state *f;
174 177
175 /* Caller has disabled preemption */ 178 /* Caller has disabled preemption */
176 sender = smp_processor_id() % NUM_INVALIDATE_TLB_VECTORS; 179 sender = this_cpu_read(tlb_vector_offset);
177 f = &flush_state[sender]; 180 f = &flush_state[sender];
178 181
179 /* 182 /*
@@ -218,6 +221,47 @@ void native_flush_tlb_others(const struct cpumask *cpumask,
218 flush_tlb_others_ipi(cpumask, mm, va); 221 flush_tlb_others_ipi(cpumask, mm, va);
219} 222}
220 223
224static void __cpuinit calculate_tlb_offset(void)
225{
226 int cpu, node, nr_node_vecs;
227 /*
228 * we are changing tlb_vector_offset for each CPU in runtime, but this
229 * will not cause inconsistency, as the write is atomic under X86. we
230 * might see more lock contentions in a short time, but after all CPU's
231 * tlb_vector_offset are changed, everything should go normal
232 *
233 * Note: if NUM_INVALIDATE_TLB_VECTORS % nr_online_nodes !=0, we might
234 * waste some vectors.
235 **/
236 if (nr_online_nodes > NUM_INVALIDATE_TLB_VECTORS)
237 nr_node_vecs = 1;
238 else
239 nr_node_vecs = NUM_INVALIDATE_TLB_VECTORS/nr_online_nodes;
240
241 for_each_online_node(node) {
242 int node_offset = (node % NUM_INVALIDATE_TLB_VECTORS) *
243 nr_node_vecs;
244 int cpu_offset = 0;
245 for_each_cpu(cpu, cpumask_of_node(node)) {
246 per_cpu(tlb_vector_offset, cpu) = node_offset +
247 cpu_offset;
248 cpu_offset++;
249 cpu_offset = cpu_offset % nr_node_vecs;
250 }
251 }
252}
253
254static int tlb_cpuhp_notify(struct notifier_block *n,
255 unsigned long action, void *hcpu)
256{
257 switch (action & 0xf) {
258 case CPU_ONLINE:
259 case CPU_DEAD:
260 calculate_tlb_offset();
261 }
262 return NOTIFY_OK;
263}
264
221static int __cpuinit init_smp_flush(void) 265static int __cpuinit init_smp_flush(void)
222{ 266{
223 int i; 267 int i;
@@ -225,6 +269,8 @@ static int __cpuinit init_smp_flush(void)
225 for (i = 0; i < ARRAY_SIZE(flush_state); i++) 269 for (i = 0; i < ARRAY_SIZE(flush_state); i++)
226 raw_spin_lock_init(&flush_state[i].tlbstate_lock); 270 raw_spin_lock_init(&flush_state[i].tlbstate_lock);
227 271
272 calculate_tlb_offset();
273 hotcpu_notifier(tlb_cpuhp_notify, 0);
228 return 0; 274 return 0;
229} 275}
230core_initcall(init_smp_flush); 276core_initcall(init_smp_flush);
diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
index 3855096c59b8..2d49d4e19a36 100644
--- a/arch/x86/oprofile/backtrace.c
+++ b/arch/x86/oprofile/backtrace.c
@@ -14,6 +14,7 @@
14#include <asm/ptrace.h> 14#include <asm/ptrace.h>
15#include <asm/uaccess.h> 15#include <asm/uaccess.h>
16#include <asm/stacktrace.h> 16#include <asm/stacktrace.h>
17#include <linux/compat.h>
17 18
18static void backtrace_warning_symbol(void *data, char *msg, 19static void backtrace_warning_symbol(void *data, char *msg,
19 unsigned long symbol) 20 unsigned long symbol)
@@ -48,14 +49,12 @@ static struct stacktrace_ops backtrace_ops = {
48 .walk_stack = print_context_stack, 49 .walk_stack = print_context_stack,
49}; 50};
50 51
51struct frame_head { 52#ifdef CONFIG_COMPAT
52 struct frame_head *bp; 53static struct stack_frame_ia32 *
53 unsigned long ret; 54dump_user_backtrace_32(struct stack_frame_ia32 *head)
54} __attribute__((packed));
55
56static struct frame_head *dump_user_backtrace(struct frame_head *head)
57{ 55{
58 struct frame_head bufhead[2]; 56 struct stack_frame_ia32 bufhead[2];
57 struct stack_frame_ia32 *fp;
59 58
60 /* Also check accessibility of one struct frame_head beyond */ 59 /* Also check accessibility of one struct frame_head beyond */
61 if (!access_ok(VERIFY_READ, head, sizeof(bufhead))) 60 if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
@@ -63,20 +62,66 @@ static struct frame_head *dump_user_backtrace(struct frame_head *head)
63 if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead))) 62 if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
64 return NULL; 63 return NULL;
65 64
66 oprofile_add_trace(bufhead[0].ret); 65 fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
66
67 oprofile_add_trace(bufhead[0].return_address);
68
69 /* frame pointers should strictly progress back up the stack
70 * (towards higher addresses) */
71 if (head >= fp)
72 return NULL;
73
74 return fp;
75}
76
77static inline int
78x86_backtrace_32(struct pt_regs * const regs, unsigned int depth)
79{
80 struct stack_frame_ia32 *head;
81
82 /* User process is 32-bit */
83 if (!current || !test_thread_flag(TIF_IA32))
84 return 0;
85
86 head = (struct stack_frame_ia32 *) regs->bp;
87 while (depth-- && head)
88 head = dump_user_backtrace_32(head);
89
90 return 1;
91}
92
93#else
94static inline int
95x86_backtrace_32(struct pt_regs * const regs, unsigned int depth)
96{
97 return 0;
98}
99#endif /* CONFIG_COMPAT */
100
101static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
102{
103 struct stack_frame bufhead[2];
104
105 /* Also check accessibility of one struct stack_frame beyond */
106 if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
107 return NULL;
108 if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
109 return NULL;
110
111 oprofile_add_trace(bufhead[0].return_address);
67 112
68 /* frame pointers should strictly progress back up the stack 113 /* frame pointers should strictly progress back up the stack
69 * (towards higher addresses) */ 114 * (towards higher addresses) */
70 if (head >= bufhead[0].bp) 115 if (head >= bufhead[0].next_frame)
71 return NULL; 116 return NULL;
72 117
73 return bufhead[0].bp; 118 return bufhead[0].next_frame;
74} 119}
75 120
76void 121void
77x86_backtrace(struct pt_regs * const regs, unsigned int depth) 122x86_backtrace(struct pt_regs * const regs, unsigned int depth)
78{ 123{
79 struct frame_head *head = (struct frame_head *)frame_pointer(regs); 124 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
80 125
81 if (!user_mode_vm(regs)) { 126 if (!user_mode_vm(regs)) {
82 unsigned long stack = kernel_stack_pointer(regs); 127 unsigned long stack = kernel_stack_pointer(regs);
@@ -86,6 +131,9 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
86 return; 131 return;
87 } 132 }
88 133
134 if (x86_backtrace_32(regs, depth))
135 return;
136
89 while (depth-- && head) 137 while (depth-- && head)
90 head = dump_user_backtrace(head); 138 head = dump_user_backtrace(head);
91} 139}
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 009b819f48d0..bd1489c3ce09 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -674,6 +674,7 @@ static int __init ppro_init(char **cpu_type)
674 case 0x0f: 674 case 0x0f:
675 case 0x16: 675 case 0x16:
676 case 0x17: 676 case 0x17:
677 case 0x1d:
677 *cpu_type = "i386/core_2"; 678 *cpu_type = "i386/core_2";
678 break; 679 break;
679 case 0x1a: 680 case 0x1a:
@@ -694,9 +695,6 @@ static int __init ppro_init(char **cpu_type)
694 return 1; 695 return 1;
695} 696}
696 697
697/* in order to get sysfs right */
698static int using_nmi;
699
700int __init op_nmi_init(struct oprofile_operations *ops) 698int __init op_nmi_init(struct oprofile_operations *ops)
701{ 699{
702 __u8 vendor = boot_cpu_data.x86_vendor; 700 __u8 vendor = boot_cpu_data.x86_vendor;
@@ -704,8 +702,6 @@ int __init op_nmi_init(struct oprofile_operations *ops)
704 char *cpu_type = NULL; 702 char *cpu_type = NULL;
705 int ret = 0; 703 int ret = 0;
706 704
707 using_nmi = 0;
708
709 if (!cpu_has_apic) 705 if (!cpu_has_apic)
710 return -ENODEV; 706 return -ENODEV;
711 707
@@ -789,13 +785,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
789 if (ret) 785 if (ret)
790 return ret; 786 return ret;
791 787
792 using_nmi = 1;
793 printk(KERN_INFO "oprofile: using NMI interrupt.\n"); 788 printk(KERN_INFO "oprofile: using NMI interrupt.\n");
794 return 0; 789 return 0;
795} 790}
796 791
797void op_nmi_exit(void) 792void op_nmi_exit(void)
798{ 793{
799 if (using_nmi) 794 exit_sysfs();
800 exit_sysfs();
801} 795}
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index b67a6b5aa8d4..42fb46f83883 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -64,15 +64,22 @@ static u64 ibs_op_ctl;
64 * IBS cpuid feature detection 64 * IBS cpuid feature detection
65 */ 65 */
66 66
67#define IBS_CPUID_FEATURES 0x8000001b 67#define IBS_CPUID_FEATURES 0x8000001b
68 68
69/* 69/*
70 * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but 70 * Same bit mask as for IBS cpuid feature flags (Fn8000_001B_EAX), but
71 * bit 0 is used to indicate the existence of IBS. 71 * bit 0 is used to indicate the existence of IBS.
72 */ 72 */
73#define IBS_CAPS_AVAIL (1LL<<0) 73#define IBS_CAPS_AVAIL (1U<<0)
74#define IBS_CAPS_RDWROPCNT (1LL<<3) 74#define IBS_CAPS_RDWROPCNT (1U<<3)
75#define IBS_CAPS_OPCNT (1LL<<4) 75#define IBS_CAPS_OPCNT (1U<<4)
76
77/*
78 * IBS APIC setup
79 */
80#define IBSCTL 0x1cc
81#define IBSCTL_LVT_OFFSET_VALID (1ULL<<8)
82#define IBSCTL_LVT_OFFSET_MASK 0x0F
76 83
77/* 84/*
78 * IBS randomization macros 85 * IBS randomization macros
@@ -266,6 +273,74 @@ static void op_amd_stop_ibs(void)
266 wrmsrl(MSR_AMD64_IBSOPCTL, 0); 273 wrmsrl(MSR_AMD64_IBSOPCTL, 0);
267} 274}
268 275
276static inline int eilvt_is_available(int offset)
277{
278 /* check if we may assign a vector */
279 return !setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_NMI, 1);
280}
281
282static inline int ibs_eilvt_valid(void)
283{
284 u64 val;
285 int offset;
286
287 rdmsrl(MSR_AMD64_IBSCTL, val);
288 if (!(val & IBSCTL_LVT_OFFSET_VALID)) {
289 pr_err(FW_BUG "cpu %d, invalid IBS "
290 "interrupt offset %d (MSR%08X=0x%016llx)",
291 smp_processor_id(), offset,
292 MSR_AMD64_IBSCTL, val);
293 return 0;
294 }
295
296 offset = val & IBSCTL_LVT_OFFSET_MASK;
297
298 if (eilvt_is_available(offset))
299 return !0;
300
301 pr_err(FW_BUG "cpu %d, IBS interrupt offset %d "
302 "not available (MSR%08X=0x%016llx)",
303 smp_processor_id(), offset,
304 MSR_AMD64_IBSCTL, val);
305
306 return 0;
307}
308
309static inline int get_ibs_offset(void)
310{
311 u64 val;
312
313 rdmsrl(MSR_AMD64_IBSCTL, val);
314 if (!(val & IBSCTL_LVT_OFFSET_VALID))
315 return -EINVAL;
316
317 return val & IBSCTL_LVT_OFFSET_MASK;
318}
319
320static void setup_APIC_ibs(void)
321{
322 int offset;
323
324 offset = get_ibs_offset();
325 if (offset < 0)
326 goto failed;
327
328 if (!setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_NMI, 0))
329 return;
330failed:
331 pr_warn("oprofile: IBS APIC setup failed on cpu #%d\n",
332 smp_processor_id());
333}
334
335static void clear_APIC_ibs(void)
336{
337 int offset;
338
339 offset = get_ibs_offset();
340 if (offset >= 0)
341 setup_APIC_eilvt(offset, 0, APIC_EILVT_MSG_FIX, 1);
342}
343
269#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX 344#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
270 345
271static void op_mux_switch_ctrl(struct op_x86_model_spec const *model, 346static void op_mux_switch_ctrl(struct op_x86_model_spec const *model,
@@ -376,13 +451,13 @@ static void op_amd_setup_ctrs(struct op_x86_model_spec const *model,
376 } 451 }
377 452
378 if (ibs_caps) 453 if (ibs_caps)
379 setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_NMI, 0); 454 setup_APIC_ibs();
380} 455}
381 456
382static void op_amd_cpu_shutdown(void) 457static void op_amd_cpu_shutdown(void)
383{ 458{
384 if (ibs_caps) 459 if (ibs_caps)
385 setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1); 460 clear_APIC_ibs();
386} 461}
387 462
388static int op_amd_check_ctrs(struct pt_regs * const regs, 463static int op_amd_check_ctrs(struct pt_regs * const regs,
@@ -445,16 +520,11 @@ static void op_amd_stop(struct op_msrs const * const msrs)
445 op_amd_stop_ibs(); 520 op_amd_stop_ibs();
446} 521}
447 522
448static int __init_ibs_nmi(void) 523static int setup_ibs_ctl(int ibs_eilvt_off)
449{ 524{
450#define IBSCTL_LVTOFFSETVAL (1 << 8)
451#define IBSCTL 0x1cc
452 struct pci_dev *cpu_cfg; 525 struct pci_dev *cpu_cfg;
453 int nodes; 526 int nodes;
454 u32 value = 0; 527 u32 value = 0;
455 u8 ibs_eilvt_off;
456
457 ibs_eilvt_off = setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1);
458 528
459 nodes = 0; 529 nodes = 0;
460 cpu_cfg = NULL; 530 cpu_cfg = NULL;
@@ -466,21 +536,60 @@ static int __init_ibs_nmi(void)
466 break; 536 break;
467 ++nodes; 537 ++nodes;
468 pci_write_config_dword(cpu_cfg, IBSCTL, ibs_eilvt_off 538 pci_write_config_dword(cpu_cfg, IBSCTL, ibs_eilvt_off
469 | IBSCTL_LVTOFFSETVAL); 539 | IBSCTL_LVT_OFFSET_VALID);
470 pci_read_config_dword(cpu_cfg, IBSCTL, &value); 540 pci_read_config_dword(cpu_cfg, IBSCTL, &value);
471 if (value != (ibs_eilvt_off | IBSCTL_LVTOFFSETVAL)) { 541 if (value != (ibs_eilvt_off | IBSCTL_LVT_OFFSET_VALID)) {
472 pci_dev_put(cpu_cfg); 542 pci_dev_put(cpu_cfg);
473 printk(KERN_DEBUG "Failed to setup IBS LVT offset, " 543 printk(KERN_DEBUG "Failed to setup IBS LVT offset, "
474 "IBSCTL = 0x%08x", value); 544 "IBSCTL = 0x%08x\n", value);
475 return 1; 545 return -EINVAL;
476 } 546 }
477 } while (1); 547 } while (1);
478 548
479 if (!nodes) { 549 if (!nodes) {
480 printk(KERN_DEBUG "No CPU node configured for IBS"); 550 printk(KERN_DEBUG "No CPU node configured for IBS\n");
481 return 1; 551 return -ENODEV;
552 }
553
554 return 0;
555}
556
557static int force_ibs_eilvt_setup(void)
558{
559 int i;
560 int ret;
561
562 /* find the next free available EILVT entry */
563 for (i = 1; i < 4; i++) {
564 if (!eilvt_is_available(i))
565 continue;
566 ret = setup_ibs_ctl(i);
567 if (ret)
568 return ret;
569 return 0;
482 } 570 }
483 571
572 printk(KERN_DEBUG "No EILVT entry available\n");
573
574 return -EBUSY;
575}
576
577static int __init_ibs_nmi(void)
578{
579 int ret;
580
581 if (ibs_eilvt_valid())
582 return 0;
583
584 ret = force_ibs_eilvt_setup();
585 if (ret)
586 return ret;
587
588 if (!ibs_eilvt_valid())
589 return -EFAULT;
590
591 pr_err(FW_BUG "workaround enabled for IBS LVT offset\n");
592
484 return 0; 593 return 0;
485} 594}
486 595
diff --git a/arch/x86/pci/olpc.c b/arch/x86/pci/olpc.c
index b34815408f58..13700ec8e2e4 100644
--- a/arch/x86/pci/olpc.c
+++ b/arch/x86/pci/olpc.c
@@ -304,7 +304,7 @@ static struct pci_raw_ops pci_olpc_conf = {
304 304
305int __init pci_olpc_init(void) 305int __init pci_olpc_init(void)
306{ 306{
307 printk(KERN_INFO "PCI: Using configuration type OLPC\n"); 307 printk(KERN_INFO "PCI: Using configuration type OLPC XO-1\n");
308 raw_pci_ops = &pci_olpc_conf; 308 raw_pci_ops = &pci_olpc_conf;
309 is_lx = is_geode_lx(); 309 is_lx = is_geode_lx();
310 return 0; 310 return 0;
diff --git a/arch/x86/xen/debugfs.c b/arch/x86/xen/debugfs.c
index 1304bcec8ee5..7c0fedd98ea0 100644
--- a/arch/x86/xen/debugfs.c
+++ b/arch/x86/xen/debugfs.c
@@ -106,6 +106,7 @@ static const struct file_operations u32_array_fops = {
106 .open = u32_array_open, 106 .open = u32_array_open,
107 .release= xen_array_release, 107 .release= xen_array_release,
108 .read = u32_array_read, 108 .read = u32_array_read,
109 .llseek = no_llseek,
109}; 110};
110 111
111struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode, 112struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode,
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 7d46c8441418..63b83ceebd1a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -30,6 +30,7 @@
30#include <linux/console.h> 30#include <linux/console.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/gfp.h> 32#include <linux/gfp.h>
33#include <linux/memblock.h>
33 34
34#include <xen/xen.h> 35#include <xen/xen.h>
35#include <xen/interface/xen.h> 36#include <xen/interface/xen.h>
@@ -1183,6 +1184,8 @@ asmlinkage void __init xen_start_kernel(void)
1183 local_irq_disable(); 1184 local_irq_disable();
1184 early_boot_irqs_off(); 1185 early_boot_irqs_off();
1185 1186
1187 memblock_init();
1188
1186 xen_raw_console_write("mapping kernel into physical memory\n"); 1189 xen_raw_console_write("mapping kernel into physical memory\n");
1187 pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); 1190 pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages);
1188 1191
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 42086ac406af..f72d18c69221 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -45,6 +45,7 @@
45#include <linux/vmalloc.h> 45#include <linux/vmalloc.h>
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/gfp.h> 47#include <linux/gfp.h>
48#include <linux/memblock.h>
48 49
49#include <asm/pgtable.h> 50#include <asm/pgtable.h>
50#include <asm/tlbflush.h> 51#include <asm/tlbflush.h>
@@ -55,6 +56,7 @@
55#include <asm/e820.h> 56#include <asm/e820.h>
56#include <asm/linkage.h> 57#include <asm/linkage.h>
57#include <asm/page.h> 58#include <asm/page.h>
59#include <asm/init.h>
58 60
59#include <asm/xen/hypercall.h> 61#include <asm/xen/hypercall.h>
60#include <asm/xen/hypervisor.h> 62#include <asm/xen/hypervisor.h>
@@ -359,7 +361,8 @@ void make_lowmem_page_readonly(void *vaddr)
359 unsigned int level; 361 unsigned int level;
360 362
361 pte = lookup_address(address, &level); 363 pte = lookup_address(address, &level);
362 BUG_ON(pte == NULL); 364 if (pte == NULL)
365 return; /* vaddr missing */
363 366
364 ptev = pte_wrprotect(*pte); 367 ptev = pte_wrprotect(*pte);
365 368
@@ -374,7 +377,8 @@ void make_lowmem_page_readwrite(void *vaddr)
374 unsigned int level; 377 unsigned int level;
375 378
376 pte = lookup_address(address, &level); 379 pte = lookup_address(address, &level);
377 BUG_ON(pte == NULL); 380 if (pte == NULL)
381 return; /* vaddr missing */
378 382
379 ptev = pte_mkwrite(*pte); 383 ptev = pte_mkwrite(*pte);
380 384
@@ -1508,13 +1512,25 @@ static void xen_pgd_free(struct mm_struct *mm, pgd_t *pgd)
1508#endif 1512#endif
1509} 1513}
1510 1514
1511#ifdef CONFIG_X86_32
1512static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte) 1515static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
1513{ 1516{
1517 unsigned long pfn = pte_pfn(pte);
1518
1519#ifdef CONFIG_X86_32
1514 /* If there's an existing pte, then don't allow _PAGE_RW to be set */ 1520 /* If there's an existing pte, then don't allow _PAGE_RW to be set */
1515 if (pte_val_ma(*ptep) & _PAGE_PRESENT) 1521 if (pte_val_ma(*ptep) & _PAGE_PRESENT)
1516 pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) & 1522 pte = __pte_ma(((pte_val_ma(*ptep) & _PAGE_RW) | ~_PAGE_RW) &
1517 pte_val_ma(pte)); 1523 pte_val_ma(pte));
1524#endif
1525
1526 /*
1527 * If the new pfn is within the range of the newly allocated
1528 * kernel pagetable, and it isn't being mapped into an
1529 * early_ioremap fixmap slot, make sure it is RO.
1530 */
1531 if (!is_early_ioremap_ptep(ptep) &&
1532 pfn >= e820_table_start && pfn < e820_table_end)
1533 pte = pte_wrprotect(pte);
1518 1534
1519 return pte; 1535 return pte;
1520} 1536}
@@ -1527,7 +1543,6 @@ static __init void xen_set_pte_init(pte_t *ptep, pte_t pte)
1527 1543
1528 xen_set_pte(ptep, pte); 1544 xen_set_pte(ptep, pte);
1529} 1545}
1530#endif
1531 1546
1532static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn) 1547static void pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
1533{ 1548{
@@ -1814,7 +1829,7 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1814 __xen_write_cr3(true, __pa(pgd)); 1829 __xen_write_cr3(true, __pa(pgd));
1815 xen_mc_issue(PARAVIRT_LAZY_CPU); 1830 xen_mc_issue(PARAVIRT_LAZY_CPU);
1816 1831
1817 reserve_early(__pa(xen_start_info->pt_base), 1832 memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
1818 __pa(xen_start_info->pt_base + 1833 __pa(xen_start_info->pt_base +
1819 xen_start_info->nr_pt_frames * PAGE_SIZE), 1834 xen_start_info->nr_pt_frames * PAGE_SIZE),
1820 "XEN PAGETABLES"); 1835 "XEN PAGETABLES");
@@ -1852,7 +1867,7 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1852 1867
1853 pin_pagetable_pfn(MMUEXT_PIN_L3_TABLE, PFN_DOWN(__pa(swapper_pg_dir))); 1868 pin_pagetable_pfn(MMUEXT_PIN_L3_TABLE, PFN_DOWN(__pa(swapper_pg_dir)));
1854 1869
1855 reserve_early(__pa(xen_start_info->pt_base), 1870 memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
1856 __pa(xen_start_info->pt_base + 1871 __pa(xen_start_info->pt_base +
1857 xen_start_info->nr_pt_frames * PAGE_SIZE), 1872 xen_start_info->nr_pt_frames * PAGE_SIZE),
1858 "XEN PAGETABLES"); 1873 "XEN PAGETABLES");
@@ -1969,14 +1984,9 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
1969 .alloc_pte = xen_alloc_pte_init, 1984 .alloc_pte = xen_alloc_pte_init,
1970 .release_pte = xen_release_pte_init, 1985 .release_pte = xen_release_pte_init,
1971 .alloc_pmd = xen_alloc_pmd_init, 1986 .alloc_pmd = xen_alloc_pmd_init,
1972 .alloc_pmd_clone = paravirt_nop,
1973 .release_pmd = xen_release_pmd_init, 1987 .release_pmd = xen_release_pmd_init,
1974 1988
1975#ifdef CONFIG_X86_64
1976 .set_pte = xen_set_pte,
1977#else
1978 .set_pte = xen_set_pte_init, 1989 .set_pte = xen_set_pte_init,
1979#endif
1980 .set_pte_at = xen_set_pte_at, 1990 .set_pte_at = xen_set_pte_at,
1981 .set_pmd = xen_set_pmd_hyper, 1991 .set_pmd = xen_set_pmd_hyper,
1982 1992
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index a013ec9d0c54..22471001b74c 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -5,6 +5,7 @@
5 5
6#include <asm/xen/hypervisor.h> 6#include <asm/xen/hypervisor.h>
7#include <xen/xen.h> 7#include <xen/xen.h>
8#include <asm/iommu_table.h>
8 9
9int xen_swiotlb __read_mostly; 10int xen_swiotlb __read_mostly;
10 11
@@ -56,3 +57,7 @@ void __init pci_xen_swiotlb_init(void)
56 dma_ops = &xen_swiotlb_dma_ops; 57 dma_ops = &xen_swiotlb_dma_ops;
57 } 58 }
58} 59}
60IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
61 0,
62 pci_xen_swiotlb_init,
63 0);
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 328b00305426..9729c903404b 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -8,6 +8,7 @@
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/pm.h> 10#include <linux/pm.h>
11#include <linux/memblock.h>
11 12
12#include <asm/elf.h> 13#include <asm/elf.h>
13#include <asm/vdso.h> 14#include <asm/vdso.h>
@@ -129,7 +130,7 @@ char * __init xen_memory_setup(void)
129 * - xen_start_info 130 * - xen_start_info
130 * See comment above "struct start_info" in <xen/interface/xen.h> 131 * See comment above "struct start_info" in <xen/interface/xen.h>
131 */ 132 */
132 reserve_early(__pa(xen_start_info->mfn_list), 133 memblock_x86_reserve_range(__pa(xen_start_info->mfn_list),
133 __pa(xen_start_info->pt_base), 134 __pa(xen_start_info->pt_base),
134 "XEN START INFO"); 135 "XEN START INFO");
135 136
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e0500646585d..23e061b9327b 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -224,7 +224,7 @@ static noinline int xen_spin_lock_slow(struct arch_spinlock *lock, bool irq_enab
224 goto out; 224 goto out;
225 } 225 }
226 226
227 flags = __raw_local_save_flags(); 227 flags = arch_local_save_flags();
228 if (irq_enable) { 228 if (irq_enable) {
229 ADD_STATS(taken_slow_irqenable, 1); 229 ADD_STATS(taken_slow_irqenable, 1);
230 raw_local_irq_enable(); 230 raw_local_irq_enable();
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 1a5353a753fc..b2bb5aa3b054 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -489,8 +489,9 @@ static void xen_hvm_setup_cpu_clockevents(void)
489__init void xen_hvm_init_time_ops(void) 489__init void xen_hvm_init_time_ops(void)
490{ 490{
491 /* vector callback is needed otherwise we cannot receive interrupts 491 /* vector callback is needed otherwise we cannot receive interrupts
492 * on cpu > 0 */ 492 * on cpu > 0 and at this point we don't know how many cpus are
493 if (!xen_have_vector_callback && num_present_cpus() > 1) 493 * available */
494 if (!xen_have_vector_callback)
494 return; 495 return;
495 if (!xen_feature(XENFEAT_hvm_safe_pvclock)) { 496 if (!xen_feature(XENFEAT_hvm_safe_pvclock)) {
496 printk(KERN_INFO "Xen doesn't support pvclock on HVM," 497 printk(KERN_INFO "Xen doesn't support pvclock on HVM,"
diff --git a/arch/xtensa/include/asm/irqflags.h b/arch/xtensa/include/asm/irqflags.h
new file mode 100644
index 000000000000..dae9a8bdcb17
--- /dev/null
+++ b/arch/xtensa/include/asm/irqflags.h
@@ -0,0 +1,58 @@
1/*
2 * Xtensa IRQ flags handling functions
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_IRQFLAGS_H
12#define _XTENSA_IRQFLAGS_H
13
14#include <linux/types.h>
15
16static inline unsigned long arch_local_save_flags(void)
17{
18 unsigned long flags;
19 asm volatile("rsr %0,"__stringify(PS) : "=a" (flags));
20 return flags;
21}
22
23static inline unsigned long arch_local_irq_save(void)
24{
25 unsigned long flags;
26 asm volatile("rsil %0, "__stringify(LOCKLEVEL)
27 : "=a" (flags) :: "memory");
28 return flags;
29}
30
31static inline void arch_local_irq_disable(void)
32{
33 arch_local_irq_save();
34}
35
36static inline void arch_local_irq_enable(void)
37{
38 unsigned long flags;
39 asm volatile("rsil %0, 0" : "=a" (flags) :: "memory");
40}
41
42static inline void arch_local_irq_restore(unsigned long flags)
43{
44 asm volatile("wsr %0, "__stringify(PS)" ; rsync"
45 :: "a" (flags) : "memory");
46}
47
48static inline bool arch_irqs_disabled_flags(unsigned long flags)
49{
50 return (flags & 0xf) != 0;
51}
52
53static inline bool arch_irqs_disabled(void)
54{
55 return arch_irqs_disabled_flags(arch_local_save_flags());
56}
57
58#endif /* _XTENSA_IRQFLAGS_H */
diff --git a/arch/xtensa/include/asm/system.h b/arch/xtensa/include/asm/system.h
index 62b1e8f3c13c..1e7e09ab6cd7 100644
--- a/arch/xtensa/include/asm/system.h
+++ b/arch/xtensa/include/asm/system.h
@@ -12,41 +12,10 @@
12#define _XTENSA_SYSTEM_H 12#define _XTENSA_SYSTEM_H
13 13
14#include <linux/stringify.h> 14#include <linux/stringify.h>
15#include <linux/irqflags.h>
15 16
16#include <asm/processor.h> 17#include <asm/processor.h>
17 18
18/* interrupt control */
19
20#define local_save_flags(x) \
21 __asm__ __volatile__ ("rsr %0,"__stringify(PS) : "=a" (x));
22#define local_irq_restore(x) do { \
23 __asm__ __volatile__ ("wsr %0, "__stringify(PS)" ; rsync" \
24 :: "a" (x) : "memory"); } while(0);
25#define local_irq_save(x) do { \
26 __asm__ __volatile__ ("rsil %0, "__stringify(LOCKLEVEL) \
27 : "=a" (x) :: "memory");} while(0);
28
29static inline void local_irq_disable(void)
30{
31 unsigned long flags;
32 __asm__ __volatile__ ("rsil %0, "__stringify(LOCKLEVEL)
33 : "=a" (flags) :: "memory");
34}
35static inline void local_irq_enable(void)
36{
37 unsigned long flags;
38 __asm__ __volatile__ ("rsil %0, 0" : "=a" (flags) :: "memory");
39
40}
41
42static inline int irqs_disabled(void)
43{
44 unsigned long flags;
45 local_save_flags(flags);
46 return flags & 0xf;
47}
48
49
50#define smp_read_barrier_depends() do { } while(0) 19#define smp_read_barrier_depends() do { } while(0)
51#define read_barrier_depends() do { } while(0) 20#define read_barrier_depends() do { } while(0)
52 21
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index b8528426ab1f..5b0c18c1cce1 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -4,7 +4,7 @@
4 * User space memory access functions 4 * User space memory access functions
5 * 5 *
6 * These routines provide basic accessing functions to the user memory 6 * These routines provide basic accessing functions to the user memory
7 * space for the kernel. This header file provides fuctions such as: 7 * space for the kernel. This header file provides functions such as:
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index c64a5d387de5..87508886cbbd 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -92,7 +92,7 @@ int show_interrupts(struct seq_file *p, void *v)
92 for_each_online_cpu(j) 92 for_each_online_cpu(j)
93 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 93 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
94#endif 94#endif
95 seq_printf(p, " %14s", irq_desc[i].chip->typename); 95 seq_printf(p, " %14s", irq_desc[i].chip->name);
96 seq_printf(p, " %s", action->name); 96 seq_printf(p, " %s", action->name);
97 97
98 for (action=action->next; action; action = action->next) 98 for (action=action->next; action; action = action->next)