aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2010-12-09 12:17:25 -0500
committerThomas Gleixner <tglx@linutronix.de>2010-12-09 12:17:25 -0500
commitd834a9dcecae834cd6b2bc5e50e1907738d9cf6a (patch)
tree0589d753465d3fe359ba451ba6cb7798df03aaa2 /arch
parenta38c5380ef9f088be9f49b6e4c5d80af8b1b5cd4 (diff)
parentf658bcfb2607bf0808966a69cf74135ce98e5c2d (diff)
Merge branch 'x86/amd-nb' into x86/apic-cleanups
Reason: apic cleanup series depends on x86/apic, x86/amd-nb x86/platform Conflicts: arch/x86/include/asm/io_apic.h Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig14
-rw-r--r--arch/alpha/Kconfig7
-rw-r--r--arch/alpha/include/asm/core_mcpcia.h2
-rw-r--r--arch/alpha/include/asm/core_t2.h54
-rw-r--r--arch/alpha/include/asm/pgtable.h2
-rw-r--r--arch/alpha/kernel/core_t2.c11
-rw-r--r--arch/alpha/kernel/machvec_impl.h3
-rw-r--r--arch/alpha/kernel/pci_iommu.c4
-rw-r--r--arch/alpha/kernel/ptrace.c7
-rw-r--r--arch/arm/Kconfig52
-rw-r--r--arch/arm/common/gic.c28
-rw-r--r--arch/arm/common/icst.c2
-rw-r--r--arch/arm/common/scoop.c12
-rw-r--r--arch/arm/common/uengine.c18
-rw-r--r--arch/arm/configs/da8xx_omapl_defconfig3
-rw-r--r--arch/arm/configs/mx51_defconfig1
-rw-r--r--arch/arm/configs/n8x0_defconfig94
-rw-r--r--arch/arm/configs/omap2plus_defconfig (renamed from arch/arm/configs/omap3_defconfig)51
-rw-r--r--arch/arm/configs/omap_4430sdp_defconfig125
-rw-r--r--arch/arm/configs/omap_generic_2420_defconfig37
-rw-r--r--arch/arm/configs/pcontrol_g20_defconfig175
-rw-r--r--arch/arm/include/asm/hardware/cache-l2x0.h13
-rw-r--r--arch/arm/include/asm/hardware/icst.h2
-rw-r--r--arch/arm/include/asm/hardware/it8152.h2
-rw-r--r--arch/arm/include/asm/highmem.h6
-rw-r--r--arch/arm/include/asm/ioctls.h83
-rw-r--r--arch/arm/include/asm/kgdb.h5
-rw-r--r--arch/arm/include/asm/memblock.h7
-rw-r--r--arch/arm/include/asm/outercache.h24
-rw-r--r--arch/arm/include/asm/pgtable.h14
-rw-r--r--arch/arm/kernel/etm.c1
-rw-r--r--arch/arm/kernel/hw_breakpoint.c3
-rw-r--r--arch/arm/kernel/kgdb.c2
-rw-r--r--arch/arm/kernel/machine_kexec.c3
-rw-r--r--arch/arm/kernel/perf_event.c2
-rw-r--r--arch/arm/kernel/ptrace.c28
-rw-r--r--arch/arm/kernel/stacktrace.c2
-rw-r--r--arch/arm/kernel/traps.c5
-rw-r--r--arch/arm/kernel/unwind.c2
-rw-r--r--arch/arm/kernel/vmlinux.lds.S1
-rw-r--r--arch/arm/mach-at91/Kconfig12
-rw-r--r--arch/arm/mach-at91/Makefile13
-rw-r--r--arch/arm/mach-at91/at91sam9260.c7
-rw-r--r--arch/arm/mach-at91/at91sam9261.c7
-rw-r--r--arch/arm/mach-at91/at91sam9263.c7
-rw-r--r--arch/arm/mach-at91/at91sam9_alt_reset.S48
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c165
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c7
-rw-r--r--arch/arm/mach-at91/board-pcontrol-g20.c322
-rw-r--r--arch/arm/mach-at91/board-sam9m10g45ek.c24
-rw-r--r--arch/arm/mach-at91/generic.h3
-rw-r--r--arch/arm/mach-at91/pm.c15
-rw-r--r--arch/arm/mach-at91/pm.h5
-rw-r--r--arch/arm/mach-at91/pm_slowclock.S1
-rw-r--r--arch/arm/mach-davinci/Kconfig76
-rw-r--r--arch/arm/mach-davinci/Makefile4
-rw-r--r--arch/arm/mach-davinci/aemif.c133
-rw-r--r--arch/arm/mach-davinci/board-da830-evm.c24
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c92
-rw-r--r--arch/arm/mach-davinci/board-dm365-evm.c11
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c20
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c21
-rw-r--r--arch/arm/mach-davinci/board-mityomapl138.c422
-rw-r--r--arch/arm/mach-davinci/board-neuros-osd2.c7
-rw-r--r--arch/arm/mach-davinci/board-omapl138-hawk.c62
-rw-r--r--arch/arm/mach-davinci/board-sffsdr.c7
-rw-r--r--arch/arm/mach-davinci/board-tnetv107x-evm.c56
-rw-r--r--arch/arm/mach-davinci/clock.c75
-rw-r--r--arch/arm/mach-davinci/clock.h5
-rw-r--r--arch/arm/mach-davinci/cpufreq.c28
-rw-r--r--arch/arm/mach-davinci/da850.c76
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c70
-rw-r--r--arch/arm/mach-davinci/devices-tnetv107x.c50
-rw-r--r--arch/arm/mach-davinci/devices.c15
-rw-r--r--arch/arm/mach-davinci/dm365.c23
-rw-r--r--arch/arm/mach-davinci/dm644x.c23
-rw-r--r--arch/arm/mach-davinci/dm646x.c22
-rw-r--r--arch/arm/mach-davinci/dma.c8
-rw-r--r--arch/arm/mach-davinci/include/mach/aemif.h36
-rw-r--r--arch/arm/mach-davinci/include/mach/da8xx.h7
-rw-r--r--arch/arm/mach-davinci/include/mach/dm365.h2
-rw-r--r--arch/arm/mach-davinci/include/mach/dm644x.h2
-rw-r--r--arch/arm/mach-davinci/include/mach/dm646x.h2
-rw-r--r--arch/arm/mach-davinci/include/mach/nand.h6
-rw-r--r--arch/arm/mach-davinci/include/mach/psc.h1
-rw-r--r--arch/arm/mach-davinci/include/mach/tnetv107x.h3
-rw-r--r--arch/arm/mach-davinci/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-davinci/tnetv107x.c11
-rw-r--r--arch/arm/mach-ep93xx/clock.c3
-rw-r--r--arch/arm/mach-ep93xx/core.c40
-rw-r--r--arch/arm/mach-ep93xx/include/mach/dma.h111
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h1
-rw-r--r--arch/arm/mach-ep93xx/simone.c1
-rw-r--r--arch/arm/mach-imx/include/mach/dma-v1.h8
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c38
-rw-r--r--arch/arm/mach-ixp2000/core.c2
-rw-r--r--arch/arm/mach-kirkwood/common.c13
-rw-r--r--arch/arm/mach-kirkwood/d2net_v2-setup.c2
-rw-r--r--arch/arm/mach-kirkwood/lacie_v2-common.c14
-rw-r--r--arch/arm/mach-kirkwood/lacie_v2-common.h2
-rw-r--r--arch/arm/mach-kirkwood/mpp.c4
-rw-r--r--arch/arm/mach-kirkwood/netspace_v2-setup.c49
-rw-r--r--arch/arm/mach-kirkwood/netxbig_v2-setup.c4
-rw-r--r--arch/arm/mach-kirkwood/ts41x-setup.c14
-rw-r--r--arch/arm/mach-mmp/include/mach/cputype.h3
-rw-r--r--arch/arm/mach-msm/Kconfig9
-rw-r--r--arch/arm/mach-msm/board-halibut.c1
-rw-r--r--arch/arm/mach-msm/include/mach/debug-macro.S15
-rw-r--r--arch/arm/mach-msm/iommu_dev.c22
-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.c2
-rw-r--r--arch/arm/mach-mv78xx0/mpp.c4
-rw-r--r--arch/arm/mach-mx25/Kconfig1
-rw-r--r--arch/arm/mach-mx25/mach-mx25_3ds.c10
-rw-r--r--arch/arm/mach-mx3/Kconfig2
-rw-r--r--arch/arm/mach-mx3/devices.c16
-rw-r--r--arch/arm/mach-mx3/mach-cpuimx35.c1
-rw-r--r--arch/arm/mach-mx3/mach-mx31_3ds.c38
-rw-r--r--arch/arm/mach-mx3/mach-mx35_3ds.c16
-rw-r--r--arch/arm/mach-mx3/mach-pcm037.c2
-rw-r--r--arch/arm/mach-mx3/mx31moboard-marxbot.c1
-rw-r--r--arch/arm/mach-mx3/mx31moboard-smartbot.c1
-rw-r--r--arch/arm/mach-mx5/Kconfig2
-rw-r--r--arch/arm/mach-mx5/Makefile1
-rw-r--r--arch/arm/mach-mx5/board-mx51_babbage.c49
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c22
-rw-r--r--arch/arm/mach-mx5/cpu_op-mx51.c29
-rw-r--r--arch/arm/mach-mx5/cpu_op-mx51.h14
-rw-r--r--arch/arm/mach-mx5/devices-imx51.h2
-rw-r--r--arch/arm/mach-omap1/Kconfig2
-rw-r--r--arch/arm/mach-omap1/Makefile2
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c69
-rw-r--r--arch/arm/mach-omap1/board-h2-mmc.c3
-rw-r--r--arch/arm/mach-omap1/board-h3-mmc.c3
-rw-r--r--arch/arm/mach-omap1/board-htcherald.c321
-rw-r--r--arch/arm/mach-omap1/board-sx1-mmc.c3
-rw-r--r--arch/arm/mach-omap1/devices.c95
-rw-r--r--arch/arm/mach-omap1/include/mach/camera.h13
-rw-r--r--arch/arm/mach-omap1/pm_bus.c98
-rw-r--r--arch/arm/mach-omap2/Kconfig54
-rw-r--r--arch/arm/mach-omap2/Makefile32
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c3
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c12
-rw-r--r--arch/arm/mach-omap2/board-3630sdp.c3
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c94
-rw-r--r--arch/arm/mach-omap2/board-am3517evm.c68
-rw-r--r--arch/arm/mach-omap2/board-apollon.c2
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c9
-rw-r--r--arch/arm/mach-omap2/board-cm-t3517.c292
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c10
-rw-r--r--arch/arm/mach-omap2/board-flash.c3
-rw-r--r--arch/arm/mach-omap2/board-flash.h (renamed from arch/arm/mach-omap2/include/mach/board-flash.h)2
-rw-r--r--arch/arm/mach-omap2/board-generic.c16
-rw-r--r--arch/arm/mach-omap2/board-h4.c2
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c369
-rw-r--r--arch/arm/mach-omap2/board-igep0030.c400
-rw-r--r--arch/arm/mach-omap2/board-ldp.c8
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c65
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c106
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c9
-rw-r--r--arch/arm/mach-omap2/board-omap3logic.c241
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c55
-rw-r--r--arch/arm/mach-omap2/board-omap3stalker.c9
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c7
-rw-r--r--arch/arm/mach-omap2/board-omap4panda.c124
-rw-r--r--arch/arm/mach-omap2/board-overo.c5
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c33
-rw-r--r--arch/arm/mach-omap2/board-rx51-sdram.c2
-rw-r--r--arch/arm/mach-omap2/board-rx51-video.c2
-rw-r--r--arch/arm/mach-omap2/board-zoom-debugboard.c2
-rw-r--r--arch/arm/mach-omap2/board-zoom-peripherals.c74
-rw-r--r--arch/arm/mach-omap2/board-zoom2.c37
-rw-r--r--arch/arm/mach-omap2/board-zoom3.c1
-rw-r--r--arch/arm/mach-omap2/clock.c2
-rw-r--r--arch/arm/mach-omap2/clock2420_data.c42
-rw-r--r--arch/arm/mach-omap2/clock2430_data.c66
-rw-r--r--arch/arm/mach-omap2/clock3xxx_data.c36
-rw-r--r--arch/arm/mach-omap2/clock44xx_data.c1312
-rw-r--r--arch/arm/mach-omap2/clockdomain.c110
-rw-r--r--arch/arm/mach-omap2/cm-regbits-34xx.h2
-rw-r--r--arch/arm/mach-omap2/cm-regbits-44xx.h1287
-rw-r--r--arch/arm/mach-omap2/cm44xx.h90
-rw-r--r--arch/arm/mach-omap2/cm4xxx.c9
-rw-r--r--arch/arm/mach-omap2/common.c135
-rw-r--r--arch/arm/mach-omap2/control.c33
-rw-r--r--arch/arm/mach-omap2/control.h (renamed from arch/arm/plat-omap/include/plat/control.h)49
-rw-r--r--arch/arm/mach-omap2/cpuidle34xx.c58
-rw-r--r--arch/arm/mach-omap2/devices.c237
-rw-r--r--arch/arm/mach-omap2/dsp.c85
-rw-r--r--arch/arm/mach-omap2/gpmc-smsc911x.c113
-rw-r--r--arch/arm/mach-omap2/hsmmc.c92
-rw-r--r--arch/arm/mach-omap2/hsmmc.h5
-rw-r--r--arch/arm/mach-omap2/id.c115
-rw-r--r--arch/arm/mach-omap2/include/mach/board-rx51.h11
-rw-r--r--arch/arm/mach-omap2/include/mach/board-zoom.h6
-rw-r--r--arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h391
-rw-r--r--arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h1409
-rw-r--r--arch/arm/mach-omap2/include/mach/ctrl_module_pad_wkup_44xx.h236
-rw-r--r--arch/arm/mach-omap2/include/mach/ctrl_module_wkup_44xx.h92
-rw-r--r--arch/arm/mach-omap2/io.c8
-rw-r--r--arch/arm/mach-omap2/io.h7
-rw-r--r--arch/arm/mach-omap2/irq.c1
-rw-r--r--arch/arm/mach-omap2/mailbox.c8
-rw-r--r--arch/arm/mach-omap2/mcbsp.c105
-rw-r--r--arch/arm/mach-omap2/mux.c23
-rw-r--r--arch/arm/mach-omap2/mux.h2
-rw-r--r--arch/arm/mach-omap2/mux2420.c2
-rw-r--r--arch/arm/mach-omap2/mux2430.c2
-rw-r--r--arch/arm/mach-omap2/mux34xx.c12
-rw-r--r--arch/arm/mach-omap2/omap4-common.c23
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c599
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2420_data.c257
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2430_data.c257
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c319
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c850
-rw-r--r--arch/arm/mach-omap2/pm-debug.c44
-rw-r--r--arch/arm/mach-omap2/pm.c75
-rw-r--r--arch/arm/mach-omap2/pm.h11
-rw-r--r--arch/arm/mach-omap2/pm24xx.c4
-rw-r--r--arch/arm/mach-omap2/pm34xx.c126
-rw-r--r--arch/arm/mach-omap2/pm_bus.c85
-rw-r--r--arch/arm/mach-omap2/powerdomains44xx.h2
-rw-r--r--arch/arm/mach-omap2/prcm-common.h5
-rw-r--r--arch/arm/mach-omap2/prcm.c33
-rw-r--r--arch/arm/mach-omap2/prm-regbits-34xx.h1
-rw-r--r--arch/arm/mach-omap2/prm-regbits-44xx.h1314
-rw-r--r--arch/arm/mach-omap2/prm.h18
-rw-r--r--arch/arm/mach-omap2/prm2xxx_3xxx.c110
-rw-r--r--arch/arm/mach-omap2/prm44xx.c116
-rw-r--r--arch/arm/mach-omap2/prm44xx.h14
-rw-r--r--arch/arm/mach-omap2/serial.c578
-rw-r--r--arch/arm/mach-omap2/sleep34xx.S2
-rw-r--r--arch/arm/mach-omap2/sram34xx.S6
-rw-r--r--arch/arm/mach-omap2/timer-gp.c8
-rw-r--r--arch/arm/mach-omap2/timer-gp.h (renamed from arch/arm/plat-omap/include/plat/timer-gp.h)3
-rw-r--r--arch/arm/mach-omap2/usb-fs.c6
-rw-r--r--arch/arm/mach-omap2/usb-musb.c4
-rw-r--r--arch/arm/mach-orion5x/mpp.c4
-rw-r--r--arch/arm/mach-orion5x/ts78xx-setup.c2
-rw-r--r--arch/arm/mach-pxa/cm-x2xx.c2
-rw-r--r--arch/arm/mach-pxa/devices.c25
-rw-r--r--arch/arm/mach-pxa/devices.h6
-rw-r--r--arch/arm/mach-pxa/em-x270.c1
-rw-r--r--arch/arm/mach-pxa/ezx.c2
-rw-r--r--arch/arm/mach-pxa/mioa701.c1
-rw-r--r--arch/arm/mach-pxa/pcm990-baseboard.c2
-rw-r--r--arch/arm/mach-pxa/pxa27x.c4
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c5
-rw-r--r--arch/arm/mach-pxa/saar.c2
-rw-r--r--arch/arm/mach-pxa/zylonite.c11
-rw-r--r--arch/arm/mach-s3c2410/h1940-bluetooth.c13
-rw-r--r--arch/arm/mach-s3c2410/include/mach/gpio.h10
-rw-r--r--arch/arm/mach-s3c2410/include/mach/h1940-latch.h57
-rw-r--r--arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h2
-rw-r--r--arch/arm/mach-s3c2410/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c169
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c3
-rw-r--r--arch/arm/mach-s3c2416/Kconfig6
-rw-r--r--arch/arm/mach-s3c2416/Makefile2
-rw-r--r--arch/arm/mach-s3c2416/irq.c2
-rw-r--r--arch/arm/mach-s3c2416/pm.c84
-rw-r--r--arch/arm/mach-s3c2416/s3c2416.c3
-rw-r--r--arch/arm/mach-s3c2440/Kconfig7
-rw-r--r--arch/arm/mach-s3c2440/mach-at2440evb.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-rx1950.c218
-rw-r--r--arch/arm/mach-s3c2440/s3c244x.c3
-rw-r--r--arch/arm/mach-s3c2443/s3c2443.c3
-rw-r--r--arch/arm/mach-s3c24a0/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s3c64xx/Kconfig24
-rw-r--r--arch/arm/mach-s3c64xx/Makefile1
-rw-r--r--arch/arm/mach-s3c64xx/dev-audio.c83
-rw-r--r--arch/arm/mach-s3c64xx/gpiolib.c8
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s3c64xx/mach-mini6410.c357
-rw-r--r--arch/arm/mach-s3c64xx/mach-real6410.c198
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-fb-24bpp.c13
-rw-r--r--arch/arm/mach-s3c64xx/setup-ide.c11
-rw-r--r--arch/arm/mach-s3c64xx/setup-keypad.c16
-rw-r--r--arch/arm/mach-s3c64xx/setup-sdhci-gpio.c41
-rw-r--r--arch/arm/mach-s5p6442/Kconfig1
-rw-r--r--arch/arm/mach-s5p6442/clock.c28
-rw-r--r--arch/arm/mach-s5p6442/dev-audio.c30
-rw-r--r--arch/arm/mach-s5p6442/dev-spi.c6
-rw-r--r--arch/arm/mach-s5p6442/dma.c2
-rw-r--r--arch/arm/mach-s5p6442/include/mach/regs-clock.h1
-rw-r--r--arch/arm/mach-s5p6442/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s5p64x0/Kconfig2
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6440.c19
-rw-r--r--arch/arm/mach-s5p64x0/clock-s5p6450.c19
-rw-r--r--arch/arm/mach-s5p64x0/clock.c18
-rw-r--r--arch/arm/mach-s5p64x0/dev-audio.c26
-rw-r--r--arch/arm/mach-s5p64x0/dev-spi.c38
-rw-r--r--arch/arm/mach-s5p64x0/dma.c2
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/regs-clock.h2
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s5p64x0/setup-i2c0.c12
-rw-r--r--arch/arm/mach-s5p64x0/setup-i2c1.c12
-rw-r--r--arch/arm/mach-s5pc100/Kconfig1
-rw-r--r--arch/arm/mach-s5pc100/Makefile2
-rw-r--r--arch/arm/mach-s5pc100/clock.c174
-rw-r--r--arch/arm/mach-s5pc100/dev-audio.c86
-rw-r--r--arch/arm/mach-s5pc100/dev-spi.c22
-rw-r--r--arch/arm/mach-s5pc100/dma.c4
-rw-r--r--arch/arm/mach-s5pc100/gpiolib.c216
-rw-r--r--arch/arm/mach-s5pc100/include/mach/gpio.h7
-rw-r--r--arch/arm/mach-s5pc100/include/mach/irqs.h13
-rw-r--r--arch/arm/mach-s5pc100/include/mach/map.h2
-rw-r--r--arch/arm/mach-s5pc100/include/mach/regs-gpio.h49
-rw-r--r--arch/arm/mach-s5pc100/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s5pc100/irq-gpio.c266
-rw-r--r--arch/arm/mach-s5pc100/mach-smdkc100.c4
-rw-r--r--arch/arm/mach-s5pc100/setup-fb-24bpp.c30
-rw-r--r--arch/arm/mach-s5pc100/setup-i2c0.c6
-rw-r--r--arch/arm/mach-s5pc100/setup-i2c1.c6
-rw-r--r--arch/arm/mach-s5pc100/setup-ide.c41
-rw-r--r--arch/arm/mach-s5pc100/setup-keypad.c15
-rw-r--r--arch/arm/mach-s5pc100/setup-sdhci-gpio.c35
-rw-r--r--arch/arm/mach-s5pv210/Kconfig37
-rw-r--r--arch/arm/mach-s5pv210/Makefile3
-rw-r--r--arch/arm/mach-s5pv210/clock.c207
-rw-r--r--arch/arm/mach-s5pv210/cpu.c15
-rw-r--r--arch/arm/mach-s5pv210/cpufreq.c484
-rw-r--r--arch/arm/mach-s5pv210/dev-audio.c86
-rw-r--r--arch/arm/mach-s5pv210/dev-spi.c19
-rw-r--r--arch/arm/mach-s5pv210/dma.c4
-rw-r--r--arch/arm/mach-s5pv210/gpiolib.c14
-rw-r--r--arch/arm/mach-s5pv210/include/mach/irqs.h12
-rw-r--r--arch/arm/mach-s5pv210/include/mach/map.h12
-rw-r--r--arch/arm/mach-s5pv210/include/mach/pm-core.h43
-rw-r--r--arch/arm/mach-s5pv210/include/mach/regs-clock.h39
-rw-r--r--arch/arm/mach-s5pv210/include/mach/regs-gpio.h7
-rw-r--r--arch/arm/mach-s5pv210/include/mach/regs-sys.h19
-rw-r--r--arch/arm/mach-s5pv210/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c169
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c381
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkc110.c4
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c4
-rw-r--r--arch/arm/mach-s5pv210/mach-torbreck.c131
-rw-r--r--arch/arm/mach-s5pv210/pm.c166
-rw-r--r--arch/arm/mach-s5pv210/setup-fb-24bpp.c34
-rw-r--r--arch/arm/mach-s5pv210/setup-i2c0.c6
-rw-r--r--arch/arm/mach-s5pv210/setup-i2c1.c6
-rw-r--r--arch/arm/mach-s5pv210/setup-i2c2.c6
-rw-r--r--arch/arm/mach-s5pv210/setup-ide.c49
-rw-r--r--arch/arm/mach-s5pv210/setup-keypad.c14
-rw-r--r--arch/arm/mach-s5pv210/setup-sdhci-gpio.c57
-rw-r--r--arch/arm/mach-s5pv210/sleep.S170
-rw-r--r--arch/arm/mach-s5pv310/Kconfig95
-rw-r--r--arch/arm/mach-s5pv310/Makefile10
-rw-r--r--arch/arm/mach-s5pv310/clock.c635
-rw-r--r--arch/arm/mach-s5pv310/cpu.c47
-rw-r--r--arch/arm/mach-s5pv310/gpiolib.c304
-rw-r--r--arch/arm/mach-s5pv310/hotplug.c144
-rw-r--r--arch/arm/mach-s5pv310/include/mach/irqs.h44
-rw-r--r--arch/arm/mach-s5pv310/include/mach/map.h19
-rw-r--r--arch/arm/mach-s5pv310/include/mach/regs-clock.h32
-rw-r--r--arch/arm/mach-s5pv310/include/mach/regs-gpio.h42
-rw-r--r--arch/arm/mach-s5pv310/include/mach/regs-srom.h50
-rw-r--r--arch/arm/mach-s5pv310/include/mach/vmalloc.h2
-rw-r--r--arch/arm/mach-s5pv310/irq-combiner.c6
-rw-r--r--arch/arm/mach-s5pv310/irq-eint.c228
-rw-r--r--arch/arm/mach-s5pv310/mach-smdkc210.c202
-rw-r--r--arch/arm/mach-s5pv310/mach-smdkv310.c121
-rw-r--r--arch/arm/mach-s5pv310/mach-universal_c210.c81
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c0.c6
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c1.c6
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c2.c6
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c3.c23
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c4.c23
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c5.c23
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c6.c23
-rw-r--r--arch/arm/mach-s5pv310/setup-i2c7.c23
-rw-r--r--arch/arm/mach-s5pv310/setup-sdhci-gpio.c152
-rw-r--r--arch/arm/mach-s5pv310/setup-sdhci.c69
-rw-r--r--arch/arm/mach-sa1100/Kconfig6
-rw-r--r--arch/arm/mach-sa1100/cpu-sa1100.c7
-rw-r--r--arch/arm/mach-shmobile/Kconfig2
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c387
-rw-r--r--arch/arm/mach-shmobile/clock-sh7367.c2
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c180
-rw-r--r--arch/arm/mach-shmobile/clock-sh7377.c2
-rw-r--r--arch/arm/mach-shmobile/include/mach/gpio.h4
-rw-r--r--arch/arm/mach-shmobile/include/mach/sh7372.h12
-rw-r--r--arch/arm/mach-shmobile/intc-sh7372.c30
-rw-r--r--arch/arm/mach-shmobile/pfc-sh7372.c8
-rw-r--r--arch/arm/mach-shmobile/setup-sh7367.c1
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c94
-rw-r--r--arch/arm/mach-shmobile/setup-sh7377.c1
-rw-r--r--arch/arm/mach-tegra/Kconfig11
-rw-r--r--arch/arm/mach-tegra/Makefile9
-rw-r--r--arch/arm/mach-tegra/board-harmony-pcie.c57
-rw-r--r--arch/arm/mach-tegra/board.h1
-rw-r--r--arch/arm/mach-tegra/clock.c267
-rw-r--r--arch/arm/mach-tegra/clock.h58
-rw-r--r--arch/arm/mach-tegra/common.c13
-rw-r--r--arch/arm/mach-tegra/cpu-tegra.c185
-rw-r--r--arch/arm/mach-tegra/dma.c752
-rw-r--r--arch/arm/mach-tegra/fuse.c84
-rw-r--r--arch/arm/mach-tegra/fuse.h24
-rw-r--r--arch/arm/mach-tegra/gpio.c104
-rw-r--r--arch/arm/mach-tegra/include/mach/clk.h5
-rw-r--r--arch/arm/mach-tegra/include/mach/dma.h155
-rw-r--r--arch/arm/mach-tegra/include/mach/gpio.h4
-rw-r--r--arch/arm/mach-tegra/include/mach/hardware.h4
-rw-r--r--arch/arm/mach-tegra/include/mach/io.h18
-rw-r--r--arch/arm/mach-tegra/include/mach/iomap.h33
-rw-r--r--arch/arm/mach-tegra/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-tegra/include/mach/legacy_irq.h31
-rw-r--r--arch/arm/mach-tegra/include/mach/pinmux-t2.h174
-rw-r--r--arch/arm/mach-tegra/include/mach/pinmux.h210
-rw-r--r--arch/arm/mach-tegra/io.c6
-rw-r--r--arch/arm/mach-tegra/irq.c137
-rw-r--r--arch/arm/mach-tegra/legacy_irq.c114
-rw-r--r--arch/arm/mach-tegra/pcie.c915
-rw-r--r--arch/arm/mach-tegra/pinmux-t2-tables.c260
-rw-r--r--arch/arm/mach-tegra/pinmux.c354
-rw-r--r--arch/arm/mach-tegra/tegra2_clocks.c826
-rw-r--r--arch/arm/mach-tegra/tegra2_dvfs.c86
-rw-r--r--arch/arm/mach-tegra/tegra2_dvfs.h20
-rw-r--r--arch/arm/mach-tegra/timer.c1
-rw-r--r--arch/arm/mach-u300/clock.c6
-rw-r--r--arch/arm/mach-u300/core.c47
-rw-r--r--arch/arm/mach-u300/include/mach/u300-regs.h2
-rw-r--r--arch/arm/mach-u300/spi.c2
-rw-r--r--arch/arm/mach-ux500/board-mop500.c129
-rw-r--r--arch/arm/mach-ux500/clock.c1
-rw-r--r--arch/arm/mach-ux500/cpu.c45
-rw-r--r--arch/arm/mach-ux500/devices-db8500.c33
-rw-r--r--arch/arm/mach-ux500/include/mach/devices.h1
-rw-r--r--arch/arm/mach-ux500/pins-db8500.h32
-rw-r--r--arch/arm/mach-vexpress/ct-ca9x4.c2
-rw-r--r--arch/arm/mm/Kconfig8
-rw-r--r--arch/arm/mm/cache-fa.S12
-rw-r--r--arch/arm/mm/cache-l2x0.c78
-rw-r--r--arch/arm/mm/cache-v3.S10
-rw-r--r--arch/arm/mm/cache-v4.S10
-rw-r--r--arch/arm/mm/cache-v4wb.S12
-rw-r--r--arch/arm/mm/cache-v4wt.S12
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm/mm/fault-armv.c32
-rw-r--r--arch/arm/mm/highmem.c24
-rw-r--r--arch/arm/mm/init.c155
-rw-r--r--arch/arm/mm/mmu.c73
-rw-r--r--arch/arm/mm/pgd.c4
-rw-r--r--arch/arm/mm/proc-arm1020.S15
-rw-r--r--arch/arm/mm/proc-arm1020e.S15
-rw-r--r--arch/arm/mm/proc-arm1022.S15
-rw-r--r--arch/arm/mm/proc-arm1026.S15
-rw-r--r--arch/arm/mm/proc-arm920.S12
-rw-r--r--arch/arm/mm/proc-arm922.S12
-rw-r--r--arch/arm/mm/proc-arm925.S12
-rw-r--r--arch/arm/mm/proc-arm926.S12
-rw-r--r--arch/arm/mm/proc-arm940.S12
-rw-r--r--arch/arm/mm/proc-arm946.S12
-rw-r--r--arch/arm/mm/proc-feroceon.S13
-rw-r--r--arch/arm/mm/proc-xsc3.S12
-rw-r--r--arch/arm/mm/proc-xscale.S12
-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/plat-mxc/Makefile1
-rw-r--r--arch/arm/plat-mxc/audmux-v2.c1
-rw-r--r--arch/arm/plat-mxc/cpufreq.c206
-rw-r--r--arch/arm/plat-mxc/devices/Kconfig6
-rw-r--r--arch/arm/plat-mxc/devices/Makefile1
-rw-r--r--arch/arm/plat-mxc/devices/platform-gpio_keys.c27
-rw-r--r--arch/arm/plat-mxc/gpio.c32
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h4
-rw-r--r--arch/arm/plat-mxc/include/mach/dma.h67
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx51.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/mx31.h1
-rw-r--r--arch/arm/plat-mxc/include/mach/mx35.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/mxc.h13
-rw-r--r--arch/arm/plat-mxc/include/mach/sdma.h17
-rw-r--r--arch/arm/plat-nomadik/include/plat/ske.h50
-rw-r--r--arch/arm/plat-nomadik/include/plat/ste_dma40.h135
-rw-r--r--arch/arm/plat-omap/Kconfig2
-rw-r--r--arch/arm/plat-omap/Makefile4
-rw-r--r--arch/arm/plat-omap/clock.c5
-rw-r--r--arch/arm/plat-omap/common.c292
-rw-r--r--arch/arm/plat-omap/counter_32k.c183
-rw-r--r--arch/arm/plat-omap/cpu-omap.c4
-rw-r--r--arch/arm/plat-omap/devices.c34
-rw-r--r--arch/arm/plat-omap/dma.c52
-rw-r--r--arch/arm/plat-omap/dmtimer.c2
-rw-r--r--arch/arm/plat-omap/fb.c16
-rw-r--r--arch/arm/plat-omap/fb.h10
-rw-r--r--arch/arm/plat-omap/gpio.c10
-rw-r--r--arch/arm/plat-omap/include/plat/common.h5
-rw-r--r--arch/arm/plat-omap/include/plat/cpu.h41
-rw-r--r--arch/arm/plat-omap/include/plat/display.h31
-rw-r--r--arch/arm/plat-omap/include/plat/dma.h6
-rw-r--r--arch/arm/plat-omap/include/plat/dmtimer.h2
-rw-r--r--arch/arm/plat-omap/include/plat/dsp.h31
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc-smsc911x.h35
-rw-r--r--arch/arm/plat-omap/include/plat/i2c.h4
-rw-r--r--arch/arm/plat-omap/include/plat/irqs.h2
-rw-r--r--arch/arm/plat-omap/include/plat/mcbsp.h29
-rw-r--r--arch/arm/plat-omap/include/plat/mmc.h12
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h128
-rw-r--r--arch/arm/plat-omap/include/plat/omap24xx.h2
-rw-r--r--arch/arm/plat-omap/include/plat/omap4-keypad.h14
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h4
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h62
-rw-r--r--arch/arm/plat-omap/include/plat/powerdomain.h2
-rw-r--r--arch/arm/plat-omap/include/plat/prcm.h2
-rw-r--r--arch/arm/plat-omap/include/plat/sdrc.h1
-rw-r--r--arch/arm/plat-omap/include/plat/sram.h1
-rw-r--r--arch/arm/plat-omap/include/plat/uncompress.h5
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h23
-rw-r--r--arch/arm/plat-omap/include/plat/vrfb.h16
-rw-r--r--arch/arm/plat-omap/iommu-debug.c2
-rw-r--r--arch/arm/plat-omap/mcbsp.c26
-rw-r--r--arch/arm/plat-omap/omap_device.c110
-rw-r--r--arch/arm/plat-omap/sram.c37
-rw-r--r--arch/arm/plat-omap/sram.h6
-rw-r--r--arch/arm/plat-orion/include/plat/pcie.h3
-rw-r--r--arch/arm/plat-orion/pcie.c5
-rw-r--r--arch/arm/plat-pxa/include/plat/pxa3xx_nand.h18
-rw-r--r--arch/arm/plat-pxa/include/plat/sdhci.h32
-rw-r--r--arch/arm/plat-s3c24xx/Kconfig1
-rw-r--r--arch/arm/plat-s3c24xx/common-smdk.c2
-rw-r--r--arch/arm/plat-s3c24xx/devs.c34
-rw-r--r--arch/arm/plat-s3c24xx/gpiolib.c10
-rw-r--r--arch/arm/plat-s5p/Kconfig5
-rw-r--r--arch/arm/plat-s5p/Makefile3
-rw-r--r--arch/arm/plat-s5p/clock.c29
-rw-r--r--arch/arm/plat-s5p/include/plat/irqs.h18
-rw-r--r--arch/arm/plat-s5p/include/plat/map-s5p.h40
-rw-r--r--arch/arm/plat-s5p/include/plat/s5p-clock.h4
-rw-r--r--arch/arm/plat-s5p/irq-eint.c10
-rw-r--r--arch/arm/plat-s5p/irq-gpioint.c237
-rw-r--r--arch/arm/plat-s5p/irq-pm.c93
-rw-r--r--arch/arm/plat-s5p/pm.c52
-rw-r--r--arch/arm/plat-samsung/Kconfig25
-rw-r--r--arch/arm/plat-samsung/Makefile5
-rw-r--r--arch/arm/plat-samsung/dev-hsmmc.c8
-rw-r--r--arch/arm/plat-samsung/dev-hsmmc1.c8
-rw-r--r--arch/arm/plat-samsung/dev-hsmmc2.c8
-rw-r--r--arch/arm/plat-samsung/dev-hsmmc3.c12
-rw-r--r--arch/arm/plat-samsung/dev-i2c2.c4
-rw-r--r--arch/arm/plat-samsung/dev-i2c3.c68
-rw-r--r--arch/arm/plat-samsung/dev-i2c4.c68
-rw-r--r--arch/arm/plat-samsung/dev-i2c5.c68
-rw-r--r--arch/arm/plat-samsung/dev-i2c6.c68
-rw-r--r--arch/arm/plat-samsung/dev-i2c7.c68
-rw-r--r--arch/arm/plat-samsung/gpio-config.c50
-rw-r--r--arch/arm/plat-samsung/gpio.c8
-rw-r--r--arch/arm/plat-samsung/include/plat/adc.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/audio.h9
-rw-r--r--arch/arm/plat-samsung/include/plat/devs.h9
-rw-r--r--arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h6
-rw-r--r--arch/arm/plat-samsung/include/plat/gpio-cfg.h56
-rw-r--r--arch/arm/plat-samsung/include/plat/gpio-core.h15
-rw-r--r--arch/arm/plat-samsung/include/plat/iic.h10
-rw-r--r--arch/arm/plat-samsung/include/plat/map-base.h4
-rw-r--r--arch/arm/plat-samsung/include/plat/nand-core.h28
-rw-r--r--arch/arm/plat-samsung/include/plat/sdhci.h64
-rw-r--r--arch/arm/plat-samsung/pm-gpio.c4
-rw-r--r--arch/arm/plat-samsung/s3c-pl330.c34
-rw-r--r--arch/avr32/Kconfig9
-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/pgtable.h2
-rw-r--r--arch/avr32/kernel/ptrace.c11
-rw-r--r--arch/blackfin/Kconfig19
-rw-r--r--arch/blackfin/Kconfig.debug11
-rw-r--r--arch/blackfin/Makefile3
-rw-r--r--arch/blackfin/configs/BF518F-EZBRD_defconfig2
-rw-r--r--arch/blackfin/configs/BF526-EZBRD_defconfig2
-rw-r--r--arch/blackfin/configs/BF527-AD7160-EVAL_defconfig105
-rw-r--r--arch/blackfin/configs/BF527-EZKIT-V2_defconfig3
-rw-r--r--arch/blackfin/configs/BF527-EZKIT_defconfig3
-rw-r--r--arch/blackfin/configs/BF527-TLL6527M_defconfig179
-rw-r--r--arch/blackfin/configs/BF533-EZKIT_defconfig2
-rw-r--r--arch/blackfin/configs/BF533-STAMP_defconfig2
-rw-r--r--arch/blackfin/configs/BF537-STAMP_defconfig3
-rw-r--r--arch/blackfin/configs/BF538-EZKIT_defconfig3
-rw-r--r--arch/blackfin/configs/BF548-EZKIT_defconfig4
-rw-r--r--arch/blackfin/configs/BF561-ACVILON_defconfig4
-rw-r--r--arch/blackfin/configs/BF561-EZKIT_defconfig1
-rw-r--r--arch/blackfin/configs/BlackStamp_defconfig3
-rw-r--r--arch/blackfin/configs/CM-BF527_defconfig4
-rw-r--r--arch/blackfin/configs/CM-BF533_defconfig3
-rw-r--r--arch/blackfin/configs/CM-BF537E_defconfig3
-rw-r--r--arch/blackfin/configs/CM-BF537U_defconfig3
-rw-r--r--arch/blackfin/configs/CM-BF548_defconfig3
-rw-r--r--arch/blackfin/configs/CM-BF561_defconfig3
-rw-r--r--arch/blackfin/configs/H8606_defconfig3
-rw-r--r--arch/blackfin/configs/IP0X_defconfig3
-rw-r--r--arch/blackfin/configs/PNAV-10_defconfig2
-rw-r--r--arch/blackfin/configs/SRV1_defconfig3
-rw-r--r--arch/blackfin/configs/TCM-BF518_defconfig1
-rw-r--r--arch/blackfin/configs/TCM-BF537_defconfig2
-rw-r--r--arch/blackfin/include/asm/Kbuild1
-rw-r--r--arch/blackfin/include/asm/bfin5xx_spi.h21
-rw-r--r--arch/blackfin/include/asm/bfin_can.h9
-rw-r--r--arch/blackfin/include/asm/bfin_ppi.h53
-rw-r--r--arch/blackfin/include/asm/bfin_twi.h45
-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/entry.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/unistd.h3
-rw-r--r--arch/blackfin/kernel/bfin_gpio.c185
-rw-r--r--arch/blackfin/kernel/kgdb.c3
-rw-r--r--arch/blackfin/kernel/kgdb_test.c1
-rw-r--r--arch/blackfin/kernel/process.c5
-rw-r--r--arch/blackfin/kernel/ptrace.c28
-rw-r--r--arch/blackfin/kernel/sys_bfin.c15
-rw-r--r--arch/blackfin/mach-bf518/boards/ezbrd.c65
-rw-r--r--arch/blackfin/mach-bf518/boards/tcm-bf518.c26
-rw-r--r--arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h32
-rw-r--r--arch/blackfin/mach-bf518/include/mach/defBF51x_base.h45
-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.c36
-rw-r--r--arch/blackfin/mach-bf527/boards/ezbrd.c30
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c49
-rw-r--r--arch/blackfin/mach-bf527/boards/tll6527m.c1008
-rw-r--r--arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h32
-rw-r--r--arch/blackfin/mach-bf527/include/mach/defBF52x_base.h45
-rw-r--r--arch/blackfin/mach-bf533/boards/H8606.c10
-rw-r--r--arch/blackfin/mach-bf533/boards/blackstamp.c4
-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.c2
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c19
-rw-r--r--arch/blackfin/mach-bf533/include/mach/defBF532.h70
-rw-r--r--arch/blackfin/mach-bf537/Kconfig4
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537e.c34
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537u.c34
-rw-r--r--arch/blackfin/mach-bf537/boards/minotaur.c24
-rw-r--r--arch/blackfin/mach-bf537/boards/pnav10.c36
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c623
-rw-r--r--arch/blackfin/mach-bf537/boards/tcm_bf537.c34
-rw-r--r--arch/blackfin/mach-bf537/include/mach/defBF534.h44
-rw-r--r--arch/blackfin/mach-bf538/boards/ezkit.c4
-rw-r--r--arch/blackfin/mach-bf538/include/mach/defBF539.h73
-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.h2
-rw-r--r--arch/blackfin/mach-bf548/include/mach/defBF54x_base.h51
-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.h76
-rw-r--r--arch/blackfin/mach-bf561/include/mach/defBF561.h94
-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/Makefile1
-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.c11
-rw-r--r--arch/blackfin/mach-common/irqpanic.c106
-rw-r--r--arch/blackfin/mm/init.c3
-rw-r--r--arch/cris/Kconfig7
-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-v10/kernel/ptrace.c20
-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/arch-v32/kernel/ptrace.c16
-rw-r--r--arch/cris/include/asm/ioctls.h84
-rw-r--r--arch/cris/include/asm/pgtable.h2
-rw-r--r--arch/cris/kernel/profile.c1
-rw-r--r--arch/frv/Kconfig6
-rw-r--r--arch/frv/include/asm/highmem.h25
-rw-r--r--arch/frv/include/asm/ioctls.h80
-rw-r--r--arch/frv/include/asm/pgtable.h9
-rw-r--r--arch/frv/kernel/ptrace.c32
-rw-r--r--arch/frv/mb93090-mb00/pci-dma.c4
-rw-r--r--arch/frv/mm/cache-page.c8
-rw-r--r--arch/frv/mm/highmem.c51
-rw-r--r--arch/h8300/Kconfig7
-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/kernel/ptrace.c33
-rw-r--r--arch/ia64/Kconfig7
-rw-r--r--arch/ia64/hp/sim/simserial.c12
-rw-r--r--arch/ia64/include/asm/cputime.h6
-rw-r--r--arch/ia64/include/asm/ioctls.h89
-rw-r--r--arch/ia64/include/asm/pgtable.h2
-rw-r--r--arch/ia64/include/asm/siginfo.h1
-rw-r--r--arch/ia64/kernel/perfmon.c9
-rw-r--r--arch/ia64/kernel/ptrace.c3
-rw-r--r--arch/ia64/kernel/salinfo.c2
-rw-r--r--arch/ia64/kvm/lapic.h1
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c1
-rw-r--r--arch/m32r/Kconfig9
-rw-r--r--arch/m32r/include/asm/ioctls.h83
-rw-r--r--arch/m32r/include/asm/pgtable.h2
-rw-r--r--arch/m32r/kernel/ptrace.c11
-rw-r--r--arch/m68k/Kconfig10
-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.h11
-rw-r--r--arch/m68k/include/asm/entry_no.h10
-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.h2
-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.h50
-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/motorola_pgtable.h2
-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/sun3_pgtable.h2
-rw-r--r--arch/m68k/include/asm/system_mm.h2
-rw-r--r--arch/m68k/include/asm/system_no.h9
-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/ptrace.c51
-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.c3
-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/Kconfig18
-rw-r--r--arch/m68knommu/Makefile3
-rw-r--r--arch/m68knommu/kernel/.gitignore1
-rw-r--r--arch/m68knommu/kernel/asm-offsets.c11
-rw-r--r--arch/m68knommu/kernel/ptrace.c104
-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/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/Kconfig22
-rw-r--r--arch/microblaze/Kconfig.debug2
-rw-r--r--arch/microblaze/Makefile11
-rw-r--r--arch/microblaze/include/asm/byteorder.h4
-rw-r--r--arch/microblaze/include/asm/checksum.h9
-rw-r--r--arch/microblaze/include/asm/cpuinfo.h5
-rw-r--r--arch/microblaze/include/asm/elf.h2
-rw-r--r--arch/microblaze/include/asm/gpio.h5
-rw-r--r--arch/microblaze/include/asm/io.h2
-rw-r--r--arch/microblaze/include/asm/page.h3
-rw-r--r--arch/microblaze/include/asm/pci.h2
-rw-r--r--arch/microblaze/include/asm/pgalloc.h3
-rw-r--r--arch/microblaze/include/asm/pgtable.h14
-rw-r--r--arch/microblaze/include/asm/prom.h1
-rw-r--r--arch/microblaze/include/asm/pvr.h14
-rw-r--r--arch/microblaze/include/asm/seccomp.h16
-rw-r--r--arch/microblaze/include/asm/setup.h6
-rw-r--r--arch/microblaze/include/asm/thread_info.h20
-rw-r--r--arch/microblaze/include/asm/unaligned.h12
-rw-r--r--arch/microblaze/include/asm/unistd.h5
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c1
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo-static.c1
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo.c2
-rw-r--r--arch/microblaze/kernel/cpu/mb.c3
-rw-r--r--arch/microblaze/kernel/cpu/pvr.c2
-rw-r--r--arch/microblaze/kernel/early_printk.c87
-rw-r--r--arch/microblaze/kernel/entry.S21
-rw-r--r--arch/microblaze/kernel/exceptions.c25
-rw-r--r--arch/microblaze/kernel/heartbeat.c11
-rw-r--r--arch/microblaze/kernel/intc.c14
-rw-r--r--arch/microblaze/kernel/kgdb.c7
-rw-r--r--arch/microblaze/kernel/microblaze_ksyms.c32
-rw-r--r--arch/microblaze/kernel/prom.c44
-rw-r--r--arch/microblaze/kernel/ptrace.c5
-rw-r--r--arch/microblaze/kernel/setup.c6
-rw-r--r--arch/microblaze/kernel/syscall_table.S3
-rw-r--r--arch/microblaze/kernel/timer.c41
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S5
-rw-r--r--arch/microblaze/lib/Makefile10
-rw-r--r--arch/microblaze/lib/ashldi3.c29
-rw-r--r--arch/microblaze/lib/ashrdi3.c31
-rw-r--r--arch/microblaze/lib/divsi3.S73
-rw-r--r--arch/microblaze/lib/libgcc.h25
-rw-r--r--arch/microblaze/lib/lshrdi3.c29
-rw-r--r--arch/microblaze/lib/memcpy.c46
-rw-r--r--arch/microblaze/lib/memmove.c59
-rw-r--r--arch/microblaze/lib/memset.c22
-rw-r--r--arch/microblaze/lib/modsi3.S73
-rw-r--r--arch/microblaze/lib/muldi3.S121
-rw-r--r--arch/microblaze/lib/mulsi3.S46
-rw-r--r--arch/microblaze/lib/udivsi3.S84
-rw-r--r--arch/microblaze/lib/umodsi3.S86
-rw-r--r--arch/microblaze/pci/pci-common.c21
-rw-r--r--arch/microblaze/platform/generic/system.dts3
-rw-r--r--arch/microblaze/platform/platform.c3
-rw-r--r--arch/mips/Kconfig100
-rw-r--r--arch/mips/Kconfig.debug9
-rw-r--r--arch/mips/Makefile4
-rw-r--r--arch/mips/alchemy/common/platform.c28
-rw-r--r--arch/mips/alchemy/common/power.c35
-rw-r--r--arch/mips/alchemy/devboards/db1200/platform.c6
-rw-r--r--arch/mips/ar7/gpio.c243
-rw-r--r--arch/mips/ar7/platform.c56
-rw-r--r--arch/mips/ar7/prom.c2
-rw-r--r--arch/mips/ar7/setup.c14
-rw-r--r--arch/mips/bcm63xx/cpu.c30
-rw-r--r--arch/mips/cavium-octeon/Kconfig23
-rw-r--r--arch/mips/cavium-octeon/csrc-octeon.c34
-rw-r--r--arch/mips/cavium-octeon/dma-octeon.c581
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-l2c.c810
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c112
-rw-r--r--arch/mips/cavium-octeon/serial.c2
-rw-r--r--arch/mips/cavium-octeon/setup.c120
-rw-r--r--arch/mips/include/asm/atomic.h208
-rw-r--r--arch/mips/include/asm/bitops.h270
-rw-r--r--arch/mips/include/asm/bootinfo.h12
-rw-r--r--arch/mips/include/asm/cmpxchg.h7
-rw-r--r--arch/mips/include/asm/cpu.h26
-rw-r--r--arch/mips/include/asm/device.h15
-rw-r--r--arch/mips/include/asm/dma-mapping.h96
-rw-r--r--arch/mips/include/asm/dma.h3
-rw-r--r--arch/mips/include/asm/highmem.h18
-rw-r--r--arch/mips/include/asm/irq.h5
-rw-r--r--arch/mips/include/asm/local.h2
-rw-r--r--arch/mips/include/asm/mach-ar7/ar7.h47
-rw-r--r--arch/mips/include/asm/mach-ar7/gpio.h3
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h97
-rw-r--r--arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h8
-rw-r--r--arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h24
-rw-r--r--arch/mips/include/asm/mach-ip27/dma-coherence.h5
-rw-r--r--arch/mips/include/asm/mach-ip32/dma-coherence.h5
-rw-r--r--arch/mips/include/asm/mach-jazz/dma-coherence.h9
-rw-r--r--arch/mips/include/asm/mipsregs.h51
-rw-r--r--arch/mips/include/asm/octeon/cvmx-agl-defs.h616
-rw-r--r--arch/mips/include/asm/octeon/cvmx-asm.h11
-rw-r--r--arch/mips/include/asm/octeon/cvmx-ciu-defs.h857
-rw-r--r--arch/mips/include/asm/octeon/cvmx-gpio-defs.h74
-rw-r--r--arch/mips/include/asm/octeon/cvmx-iob-defs.h242
-rw-r--r--arch/mips/include/asm/octeon/cvmx-ipd-defs.h314
-rw-r--r--arch/mips/include/asm/octeon/cvmx-l2c-defs.h738
-rw-r--r--arch/mips/include/asm/octeon/cvmx-l2c.h225
-rw-r--r--arch/mips/include/asm/octeon/cvmx-l2d-defs.h38
-rw-r--r--arch/mips/include/asm/octeon/cvmx-l2t-defs.h5
-rw-r--r--arch/mips/include/asm/octeon/cvmx-led-defs.h41
-rw-r--r--arch/mips/include/asm/octeon/cvmx-mio-defs.h807
-rw-r--r--arch/mips/include/asm/octeon/cvmx-mixx-defs.h200
-rw-r--r--arch/mips/include/asm/octeon/cvmx-npei-defs.h681
-rw-r--r--arch/mips/include/asm/octeon/cvmx-npi-defs.h362
-rw-r--r--arch/mips/include/asm/octeon/cvmx-pci-defs.h265
-rw-r--r--arch/mips/include/asm/octeon/cvmx-pciercx-defs.h435
-rw-r--r--arch/mips/include/asm/octeon/cvmx-pescx-defs.h50
-rw-r--r--arch/mips/include/asm/octeon/cvmx-pexp-defs.h378
-rw-r--r--arch/mips/include/asm/octeon/cvmx-pow-defs.h157
-rw-r--r--arch/mips/include/asm/octeon/cvmx-rnm-defs.h67
-rw-r--r--arch/mips/include/asm/octeon/cvmx-smix-defs.h46
-rw-r--r--arch/mips/include/asm/octeon/cvmx-uctlx-defs.h261
-rw-r--r--arch/mips/include/asm/octeon/octeon-model.h36
-rw-r--r--arch/mips/include/asm/octeon/octeon.h1
-rw-r--r--arch/mips/include/asm/octeon/pci-octeon.h10
-rw-r--r--arch/mips/include/asm/pci/bridge.h2
-rw-r--r--arch/mips/include/asm/perf_event.h25
-rw-r--r--arch/mips/include/asm/pgtable-32.h3
-rw-r--r--arch/mips/include/asm/pgtable-64.h7
-rw-r--r--arch/mips/include/asm/processor.h40
-rw-r--r--arch/mips/include/asm/prom.h31
-rw-r--r--arch/mips/include/asm/system.h52
-rw-r--r--arch/mips/include/asm/thread_info.h2
-rw-r--r--arch/mips/include/asm/uaccess.h4
-rw-r--r--arch/mips/kernel/Makefile4
-rw-r--r--arch/mips/kernel/cpu-probe.c82
-rw-r--r--arch/mips/kernel/irq.c24
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c2
-rw-r--r--arch/mips/kernel/perf_event.c601
-rw-r--r--arch/mips/kernel/perf_event_mipsxx.c1052
-rw-r--r--arch/mips/kernel/prom.c112
-rw-r--r--arch/mips/kernel/ptrace.c25
-rw-r--r--arch/mips/kernel/rtlx.c3
-rw-r--r--arch/mips/kernel/setup.c3
-rw-r--r--arch/mips/kernel/traps.c31
-rw-r--r--arch/mips/kernel/unaligned.c7
-rw-r--r--arch/mips/kernel/vpe.c3
-rw-r--r--arch/mips/loongson/Kconfig2
-rw-r--r--arch/mips/math-emu/cp1emu.c4
-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/c-octeon.c16
-rw-r--r--arch/mips/mm/c-r4k.c21
-rw-r--r--arch/mips/mm/dma-default.c165
-rw-r--r--arch/mips/mm/fault.c11
-rw-r--r--arch/mips/mm/highmem.c51
-rw-r--r--arch/mips/mm/sc-mips.c34
-rw-r--r--arch/mips/mm/tlbex.c11
-rw-r--r--arch/mips/mm/uasm.c20
-rw-r--r--arch/mips/pci/fixup-fuloong2e.c2
-rw-r--r--arch/mips/pci/pci-octeon.c60
-rw-r--r--arch/mips/pci/pcie-octeon.c5
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c3
-rw-r--r--arch/mn10300/Kconfig286
-rw-r--r--arch/mn10300/Makefile6
-rw-r--r--arch/mn10300/boot/compressed/head.S69
-rw-r--r--arch/mn10300/configs/asb2303_defconfig2
-rw-r--r--arch/mn10300/configs/asb2364_defconfig98
-rw-r--r--arch/mn10300/include/asm/atomic.h350
-rw-r--r--arch/mn10300/include/asm/bitops.h14
-rw-r--r--arch/mn10300/include/asm/cache.h14
-rw-r--r--arch/mn10300/include/asm/cacheflush.h164
-rw-r--r--arch/mn10300/include/asm/cpu-regs.h91
-rw-r--r--arch/mn10300/include/asm/dmactl-regs.h87
-rw-r--r--arch/mn10300/include/asm/elf.h12
-rw-r--r--arch/mn10300/include/asm/exceptions.h8
-rw-r--r--arch/mn10300/include/asm/fpu.h157
-rw-r--r--arch/mn10300/include/asm/frame.inc20
-rw-r--r--arch/mn10300/include/asm/gdb-stub.h2
-rw-r--r--arch/mn10300/include/asm/hardirq.h3
-rw-r--r--arch/mn10300/include/asm/highmem.h46
-rw-r--r--arch/mn10300/include/asm/intctl-regs.h37
-rw-r--r--arch/mn10300/include/asm/io.h13
-rw-r--r--arch/mn10300/include/asm/ioctls.h84
-rw-r--r--arch/mn10300/include/asm/irq.h12
-rw-r--r--arch/mn10300/include/asm/irq_regs.h6
-rw-r--r--arch/mn10300/include/asm/irqflags.h111
-rw-r--r--arch/mn10300/include/asm/mmu_context.h73
-rw-r--r--arch/mn10300/include/asm/pgalloc.h1
-rw-r--r--arch/mn10300/include/asm/pgtable.h90
-rw-r--r--arch/mn10300/include/asm/processor.h66
-rw-r--r--arch/mn10300/include/asm/ptrace.h13
-rw-r--r--arch/mn10300/include/asm/reset-regs.h2
-rw-r--r--arch/mn10300/include/asm/rtc.h11
-rw-r--r--arch/mn10300/include/asm/rwlock.h125
-rw-r--r--arch/mn10300/include/asm/serial-regs.h51
-rw-r--r--arch/mn10300/include/asm/serial.h8
-rw-r--r--arch/mn10300/include/asm/smp.h91
-rw-r--r--arch/mn10300/include/asm/smsc911x.h1
-rw-r--r--arch/mn10300/include/asm/spinlock.h179
-rw-r--r--arch/mn10300/include/asm/spinlock_types.h20
-rw-r--r--arch/mn10300/include/asm/system.h73
-rw-r--r--arch/mn10300/include/asm/thread_info.h18
-rw-r--r--arch/mn10300/include/asm/timer-regs.h191
-rw-r--r--arch/mn10300/include/asm/timex.h20
-rw-r--r--arch/mn10300/include/asm/tlbflush.h174
-rw-r--r--arch/mn10300/include/asm/uaccess.h6
-rw-r--r--arch/mn10300/kernel/Makefile15
-rw-r--r--arch/mn10300/kernel/asm-offsets.c11
-rw-r--r--arch/mn10300/kernel/cevt-mn10300.c131
-rw-r--r--arch/mn10300/kernel/csrc-mn10300.c35
-rw-r--r--arch/mn10300/kernel/entry.S146
-rw-r--r--arch/mn10300/kernel/fpu-low.S265
-rw-r--r--arch/mn10300/kernel/fpu-nofpu-low.S39
-rw-r--r--arch/mn10300/kernel/fpu-nofpu.c30
-rw-r--r--arch/mn10300/kernel/fpu.c141
-rw-r--r--arch/mn10300/kernel/gdb-io-serial-low.S5
-rw-r--r--arch/mn10300/kernel/gdb-io-serial.c37
-rw-r--r--arch/mn10300/kernel/gdb-io-ttysm.c24
-rw-r--r--arch/mn10300/kernel/gdb-stub.c17
-rw-r--r--arch/mn10300/kernel/head.S202
-rw-r--r--arch/mn10300/kernel/internal.h25
-rw-r--r--arch/mn10300/kernel/irq.c276
-rw-r--r--arch/mn10300/kernel/kprobes.c4
-rw-r--r--arch/mn10300/kernel/mn10300-serial-low.S6
-rw-r--r--arch/mn10300/kernel/mn10300-serial.c210
-rw-r--r--arch/mn10300/kernel/mn10300-watchdog-low.S9
-rw-r--r--arch/mn10300/kernel/mn10300-watchdog.c100
-rw-r--r--arch/mn10300/kernel/process.c61
-rw-r--r--arch/mn10300/kernel/profile.c2
-rw-r--r--arch/mn10300/kernel/ptrace.c20
-rw-r--r--arch/mn10300/kernel/rtc.c41
-rw-r--r--arch/mn10300/kernel/setup.c79
-rw-r--r--arch/mn10300/kernel/signal.c20
-rw-r--r--arch/mn10300/kernel/smp-low.S97
-rw-r--r--arch/mn10300/kernel/smp.c1152
-rw-r--r--arch/mn10300/kernel/switch_to.S7
-rw-r--r--arch/mn10300/kernel/time.c112
-rw-r--r--arch/mn10300/kernel/traps.c42
-rw-r--r--arch/mn10300/kernel/vmlinux.lds.S2
-rw-r--r--arch/mn10300/lib/bitops.c4
-rw-r--r--arch/mn10300/lib/delay.c8
-rw-r--r--arch/mn10300/lib/do_csum.S49
-rw-r--r--arch/mn10300/mm/Kconfig.cache101
-rw-r--r--arch/mn10300/mm/Makefile14
-rw-r--r--arch/mn10300/mm/cache-flush-by-reg.S308
-rw-r--r--arch/mn10300/mm/cache-flush-by-tag.S251
-rw-r--r--arch/mn10300/mm/cache-flush-icache.c155
-rw-r--r--arch/mn10300/mm/cache-flush-mn10300.S192
-rw-r--r--arch/mn10300/mm/cache-inv-by-reg.S356
-rw-r--r--arch/mn10300/mm/cache-inv-by-tag.S348
-rw-r--r--arch/mn10300/mm/cache-inv-icache.c129
-rw-r--r--arch/mn10300/mm/cache-mn10300.S289
-rw-r--r--arch/mn10300/mm/cache-smp-flush.c156
-rw-r--r--arch/mn10300/mm/cache-smp-inv.c153
-rw-r--r--arch/mn10300/mm/cache-smp.c105
-rw-r--r--arch/mn10300/mm/cache-smp.h69
-rw-r--r--arch/mn10300/mm/cache.c95
-rw-r--r--arch/mn10300/mm/fault.c17
-rw-r--r--arch/mn10300/mm/init.c26
-rw-r--r--arch/mn10300/mm/misalignment.c3
-rw-r--r--arch/mn10300/mm/mmu-context.c41
-rw-r--r--arch/mn10300/mm/pgtable.c2
-rw-r--r--arch/mn10300/mm/tlb-mn10300.S59
-rw-r--r--arch/mn10300/mm/tlb-smp.c214
-rw-r--r--arch/mn10300/proc-mn103e010/include/proc/cache.h9
-rw-r--r--arch/mn10300/proc-mn103e010/include/proc/clock.h2
-rw-r--r--arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h102
-rw-r--r--arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h29
-rw-r--r--arch/mn10300/proc-mn103e010/include/proc/proc.h2
-rw-r--r--arch/mn10300/proc-mn103e010/proc-init.c37
-rw-r--r--arch/mn10300/proc-mn2ws0050/Makefile5
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/cache.h48
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/clock.h20
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h103
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h29
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/irq.h49
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h120
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/proc.h18
-rw-r--r--arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h51
-rw-r--r--arch/mn10300/proc-mn2ws0050/proc-init.c134
-rw-r--r--arch/mn10300/unit-asb2303/include/unit/clock.h25
-rw-r--r--arch/mn10300/unit-asb2303/include/unit/serial.h5
-rw-r--r--arch/mn10300/unit-asb2303/include/unit/timex.h109
-rw-r--r--arch/mn10300/unit-asb2303/unit-init.c10
-rw-r--r--arch/mn10300/unit-asb2305/include/unit/clock.h25
-rw-r--r--arch/mn10300/unit-asb2305/include/unit/serial.h5
-rw-r--r--arch/mn10300/unit-asb2305/include/unit/timex.h109
-rw-r--r--arch/mn10300/unit-asb2305/pci-asb2305.c16
-rw-r--r--arch/mn10300/unit-asb2305/pci.c2
-rw-r--r--arch/mn10300/unit-asb2305/unit-init.c6
-rw-r--r--arch/mn10300/unit-asb2364/Makefile12
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/clock.h29
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/fpga-regs.h52
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/irq.h35
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/leds.h54
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/serial.h151
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/smsc911x.h171
-rw-r--r--arch/mn10300/unit-asb2364/include/unit/timex.h159
-rw-r--r--arch/mn10300/unit-asb2364/irq-fpga.c96
-rw-r--r--arch/mn10300/unit-asb2364/leds.c98
-rw-r--r--arch/mn10300/unit-asb2364/smsc911x.c58
-rw-r--r--arch/mn10300/unit-asb2364/unit-init.c88
-rw-r--r--arch/parisc/Kconfig11
-rw-r--r--arch/parisc/include/asm/cache.h2
-rw-r--r--arch/parisc/include/asm/cacheflush.h8
-rw-r--r--arch/parisc/include/asm/irq.h2
-rw-r--r--arch/parisc/include/asm/pgtable.h2
-rw-r--r--arch/parisc/include/asm/unistd.h3
-rw-r--r--arch/parisc/kernel/irq.c41
-rw-r--r--arch/parisc/kernel/pdc_cons.c141
-rw-r--r--arch/parisc/kernel/perf.c4
-rw-r--r--arch/parisc/kernel/ptrace.c13
-rw-r--r--arch/parisc/kernel/syscall_table.S1
-rw-r--r--arch/parisc/kernel/unaligned.c3
-rw-r--r--arch/parisc/kernel/unwind.c5
-rw-r--r--arch/parisc/math-emu/Makefile2
-rw-r--r--arch/powerpc/Kconfig13
-rw-r--r--arch/powerpc/boot/dts/mpc8610_hpcd.dts1
-rw-r--r--arch/powerpc/configs/mpc85xx_defconfig3
-rw-r--r--arch/powerpc/configs/mpc85xx_smp_defconfig3
-rw-r--r--arch/powerpc/include/asm/cputime.h12
-rw-r--r--arch/powerpc/include/asm/fsl_guts.h (renamed from arch/powerpc/include/asm/immap_86xx.h)111
-rw-r--r--arch/powerpc/include/asm/fsl_lbc.h34
-rw-r--r--arch/powerpc/include/asm/fsldma.h137
-rw-r--r--arch/powerpc/include/asm/highmem.h9
-rw-r--r--arch/powerpc/include/asm/hydra.h2
-rw-r--r--arch/powerpc/include/asm/kgdb.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_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/pgtable-ppc32.h8
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h2
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/asm-offsets.c25
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S6
-rw-r--r--arch/powerpc/kernel/head_64.S6
-rw-r--r--arch/powerpc/kernel/ibmebus.c11
-rw-r--r--arch/powerpc/kernel/kgdb.c188
-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.c1
-rw-r--r--arch/powerpc/kernel/prom.c12
-rw-r--r--arch/powerpc/kernel/ptrace.c66
-rw-r--r--arch/powerpc/kernel/rtas_flash.c3
-rw-r--r--arch/powerpc/kernel/rtasd.c1
-rw-r--r--arch/powerpc/kernel/vio.c4
-rw-r--r--arch/powerpc/kvm/44x.c10
-rw-r--r--arch/powerpc/kvm/44x_tlb.c9
-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.c11
-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.c9
-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.c36
-rw-r--r--arch/powerpc/kvm/powerpc.c89
-rw-r--r--arch/powerpc/kvm/timing.c2
-rw-r--r--arch/powerpc/kvm/trace.h239
-rw-r--r--arch/powerpc/mm/highmem.c37
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c211
-rw-r--r--arch/powerpc/platforms/Kconfig10
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c10
-rw-r--r--arch/powerpc/platforms/iseries/mf.c1
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c3
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c1
-rw-r--r--arch/powerpc/sysdev/fsl_lbc.c244
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c76
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c163
-rw-r--r--arch/s390/Kbuild6
-rw-r--r--arch/s390/Kconfig72
-rw-r--r--arch/s390/Makefile5
-rw-r--r--arch/s390/crypto/crypt_s390.h2
-rw-r--r--arch/s390/crypto/prng.c1
-rw-r--r--arch/s390/hypfs/hypfs_diag.c20
-rw-r--r--arch/s390/hypfs/hypfs_vm.c1
-rw-r--r--arch/s390/hypfs/inode.c9
-rw-r--r--arch/s390/include/asm/Kbuild1
-rw-r--r--arch/s390/include/asm/ccwdev.h12
-rw-r--r--arch/s390/include/asm/cpu.h2
-rw-r--r--arch/s390/include/asm/cputime.h10
-rw-r--r--arch/s390/include/asm/dasd.h40
-rw-r--r--arch/s390/include/asm/hugetlb.h26
-rw-r--r--arch/s390/include/asm/ioctls.h88
-rw-r--r--arch/s390/include/asm/kvm_virtio.h7
-rw-r--r--arch/s390/include/asm/lowcore.h11
-rw-r--r--arch/s390/include/asm/page.h8
-rw-r--r--arch/s390/include/asm/pgalloc.h4
-rw-r--r--arch/s390/include/asm/pgtable.h62
-rw-r--r--arch/s390/include/asm/processor.h2
-rw-r--r--arch/s390/include/asm/ptrace.h3
-rw-r--r--arch/s390/include/asm/qdio.h13
-rw-r--r--arch/s390/include/asm/s390_ext.h2
-rw-r--r--arch/s390/include/asm/scatterlist.h2
-rw-r--r--arch/s390/include/asm/setup.h3
-rw-r--r--arch/s390/include/asm/syscall.h4
-rw-r--r--arch/s390/include/asm/sysinfo.h40
-rw-r--r--arch/s390/include/asm/system.h51
-rw-r--r--arch/s390/include/asm/tlb.h13
-rw-r--r--arch/s390/include/asm/topology.h2
-rw-r--r--arch/s390/kernel/asm-offsets.c9
-rw-r--r--arch/s390/kernel/compat_ptrace.h3
-rw-r--r--arch/s390/kernel/debug.c1
-rw-r--r--arch/s390/kernel/dis.c145
-rw-r--r--arch/s390/kernel/early.c47
-rw-r--r--arch/s390/kernel/entry.S45
-rw-r--r--arch/s390/kernel/entry.h4
-rw-r--r--arch/s390/kernel/entry64.S46
-rw-r--r--arch/s390/kernel/head.S8
-rw-r--r--arch/s390/kernel/kprobes.c9
-rw-r--r--arch/s390/kernel/process.c10
-rw-r--r--arch/s390/kernel/processor.c2
-rw-r--r--arch/s390/kernel/ptrace.c3
-rw-r--r--arch/s390/kernel/s390_ext.c9
-rw-r--r--arch/s390/kernel/setup.c25
-rw-r--r--arch/s390/kernel/smp.c5
-rw-r--r--arch/s390/kernel/sysinfo.c43
-rw-r--r--arch/s390/kernel/time.c17
-rw-r--r--arch/s390/kernel/topology.c105
-rw-r--r--arch/s390/kernel/traps.c173
-rw-r--r--arch/s390/kernel/vdso.c6
-rw-r--r--arch/s390/kernel/vdso32/clock_getres.S6
-rw-r--r--arch/s390/kernel/vdso32/clock_gettime.S4
-rw-r--r--arch/s390/kernel/vdso64/clock_getres.S6
-rw-r--r--arch/s390/kernel/vdso64/clock_gettime.S4
-rw-r--r--arch/s390/kernel/vtime.c3
-rw-r--r--arch/s390/kvm/kvm-s390.c4
-rw-r--r--arch/s390/kvm/priv.c4
-rw-r--r--arch/s390/mm/Makefile2
-rw-r--r--arch/s390/mm/cmm.c7
-rw-r--r--arch/s390/mm/fault.c77
-rw-r--r--arch/s390/mm/gup.c225
-rw-r--r--arch/s390/mm/hugetlbpage.c2
-rw-r--r--arch/s390/mm/init.c52
-rw-r--r--arch/s390/mm/pgtable.c173
-rw-r--r--arch/score/Kconfig5
-rw-r--r--arch/score/include/asm/pgtable.h3
-rw-r--r--arch/score/kernel/ptrace.c7
-rw-r--r--arch/sh/Kconfig28
-rw-r--r--arch/sh/Makefile3
-rw-r--r--arch/sh/boards/Kconfig25
-rw-r--r--arch/sh/boards/Makefile4
-rw-r--r--arch/sh/boards/board-edosk7705.c78
-rw-r--r--arch/sh/boards/board-secureedge5410.c (renamed from arch/sh/boards/mach-snapgear/setup.c)38
-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-ap325rxa/setup.c30
-rw-r--r--arch/sh/boards/mach-cayman/irq.c16
-rw-r--r--arch/sh/boards/mach-dreamcast/irq.c17
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c70
-rw-r--r--arch/sh/boards/mach-edosk7705/Makefile5
-rw-r--r--arch/sh/boards/mach-edosk7705/io.c71
-rw-r--r--arch/sh/boards/mach-edosk7705/setup.c36
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c30
-rw-r--r--arch/sh/boards/mach-landisk/gio.c1
-rw-r--r--arch/sh/boards/mach-landisk/irq.c15
-rw-r--r--arch/sh/boards/mach-microdev/io.c246
-rw-r--r--arch/sh/boards/mach-microdev/irq.c30
-rw-r--r--arch/sh/boards/mach-microdev/setup.c23
-rw-r--r--arch/sh/boards/mach-migor/setup.c60
-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-se/7206/Makefile2
-rw-r--r--arch/sh/boards/mach-se/7206/io.c104
-rw-r--r--arch/sh/boards/mach-se/7206/irq.c24
-rw-r--r--arch/sh/boards/mach-se/7206/setup.c15
-rw-r--r--arch/sh/boards/mach-se/7343/irq.c15
-rw-r--r--arch/sh/boards/mach-se/770x/Makefile2
-rw-r--r--arch/sh/boards/mach-se/770x/io.c156
-rw-r--r--arch/sh/boards/mach-se/770x/setup.c22
-rw-r--r--arch/sh/boards/mach-se/7722/irq.c15
-rw-r--r--arch/sh/boards/mach-se/7724/irq.c13
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c55
-rw-r--r--arch/sh/boards/mach-se/7751/Makefile2
-rw-r--r--arch/sh/boards/mach-se/7751/io.c119
-rw-r--r--arch/sh/boards/mach-se/7751/setup.c18
-rw-r--r--arch/sh/boards/mach-snapgear/Makefile5
-rw-r--r--arch/sh/boards/mach-snapgear/io.c121
-rw-r--r--arch/sh/boards/mach-systemh/Makefile13
-rw-r--r--arch/sh/boards/mach-systemh/io.c158
-rw-r--r--arch/sh/boards/mach-systemh/irq.c76
-rw-r--r--arch/sh/boards/mach-systemh/setup.c57
-rw-r--r--arch/sh/boards/mach-x3proto/Makefile2
-rw-r--r--arch/sh/boards/mach-x3proto/gpio.c136
-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/cchips/hd6446x/hd64461.c19
-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/secureedge5410_defconfig (renamed from arch/sh/configs/snapgear_defconfig)1
-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/systemh_defconfig29
-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/addrspace.h8
-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/kprobes.h1
-rw-r--r--arch/sh/include/asm/pci.h2
-rw-r--r--arch/sh/include/asm/pgtable.h14
-rw-r--r--arch/sh/include/asm/pgtable_32.h5
-rw-r--r--arch/sh/include/asm/pgtable_64.h11
-rw-r--r--arch/sh/include/asm/processor.h1
-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/system.h6
-rw-r--r--arch/sh/include/asm/system_32.h51
-rw-r--r--arch/sh/include/asm/system_64.h3
-rw-r--r--arch/sh/include/asm/tlbflush.h2
-rw-r--r--arch/sh/include/asm/uncached.h40
-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/edosk7705.h7
-rw-r--r--arch/sh/include/mach-common/mach/microdev.h9
-rw-r--r--arch/sh/include/mach-common/mach/secureedge5410.h (renamed from arch/sh/include/mach-common/mach/snapgear.h)22
-rw-r--r--arch/sh/include/mach-common/mach/sh2007.h117
-rw-r--r--arch/sh/include/mach-common/mach/systemh7751.h71
-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/init.c2
-rw-r--r--arch/sh/kernel/cpu/irq/imask.c14
-rw-r--r--arch/sh/kernel/cpu/irq/intc-sh5.c49
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c29
-rw-r--r--arch/sh/kernel/cpu/sh4/perf_event.c2
-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-sh7724.c6
-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.c22
-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-sh7722.c2
-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.c39
-rw-r--r--arch/sh/kernel/irq_64.c16
-rw-r--r--arch/sh/kernel/kdebugfs.c16
-rw-r--r--arch/sh/kernel/kprobes.c100
-rw-r--r--arch/sh/kernel/ptrace.c33
-rw-r--r--arch/sh/kernel/ptrace_32.c72
-rw-r--r--arch/sh/kernel/ptrace_64.c113
-rw-r--r--arch/sh/kernel/reboot.c4
-rw-r--r--arch/sh/kernel/setup.c26
-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/Kconfig6
-rw-r--r--arch/sh/mm/Makefile5
-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.c18
-rw-r--r--arch/sh/mm/gup.c273
-rw-r--r--arch/sh/mm/init.c52
-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/mm/uncached.c2
-rw-r--r--arch/sh/oprofile/Makefile2
-rw-r--r--arch/sh/oprofile/backtrace.c2
-rw-r--r--arch/sh/oprofile/common.c35
-rw-r--r--arch/sh/tools/mach-types3
-rw-r--r--arch/sparc/Kconfig10
-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/highmem.h4
-rw-r--r--arch/sparc/include/asm/io_32.h31
-rw-r--r--arch/sparc/include/asm/io_64.h31
-rw-r--r--arch/sparc/include/asm/jump_label.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/pci_64.h2
-rw-r--r--arch/sparc/include/asm/pgtable_32.h3
-rw-r--r--arch/sparc/include/asm/pgtable_64.h2
-rw-r--r--arch/sparc/include/asm/prom.h5
-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.c4
-rw-r--r--arch/sparc/kernel/leon_kernel.c2
-rw-r--r--arch/sparc/kernel/leon_smp.c4
-rw-r--r--arch/sparc/kernel/mdesc.c1
-rw-r--r--arch/sparc/kernel/pcic.c4
-rw-r--r--arch/sparc/kernel/prom.h6
-rw-r--r--arch/sparc/kernel/prom_common.c202
-rw-r--r--arch/sparc/kernel/ptrace_32.c57
-rw-r--r--arch/sparc/kernel/ptrace_64.c15
-rw-r--r--arch/sparc/kernel/rtrap_32.S6
-rw-r--r--arch/sparc/kernel/rtrap_64.S36
-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/fault_32.c12
-rw-r--r--arch/sparc/mm/highmem.c48
-rw-r--r--arch/sparc/mm/init_64.c2
-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/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/Kconfig25
-rw-r--r--arch/tile/Makefile19
-rw-r--r--arch/tile/include/arch/sim.h619
-rw-r--r--arch/tile/include/arch/sim_def.h548
-rw-r--r--arch/tile/include/arch/spr_def.h85
-rw-r--r--arch/tile/include/arch/spr_def_32.h39
-rw-r--r--arch/tile/include/asm/backtrace.h5
-rw-r--r--arch/tile/include/asm/bitops.h1
-rw-r--r--arch/tile/include/asm/compat.h15
-rw-r--r--arch/tile/include/asm/highmem.h11
-rw-r--r--arch/tile/include/asm/irqflags.h64
-rw-r--r--arch/tile/include/asm/kmap_types.h34
-rw-r--r--arch/tile/include/asm/mman.h1
-rw-r--r--arch/tile/include/asm/page.h27
-rw-r--r--arch/tile/include/asm/pgtable.h11
-rw-r--r--arch/tile/include/asm/processor.h11
-rw-r--r--arch/tile/include/asm/ptrace.h4
-rw-r--r--arch/tile/include/asm/stat.h3
-rw-r--r--arch/tile/include/asm/syscalls.h73
-rw-r--r--arch/tile/include/asm/system.h14
-rw-r--r--arch/tile/include/asm/traps.h4
-rw-r--r--arch/tile/include/asm/unistd.h1
-rw-r--r--arch/tile/include/hv/hypervisor.h30
-rw-r--r--arch/tile/kernel/backtrace.c4
-rw-r--r--arch/tile/kernel/compat.c22
-rw-r--r--arch/tile/kernel/compat_signal.c10
-rw-r--r--arch/tile/kernel/early_printk.c2
-rw-r--r--arch/tile/kernel/entry.S34
-rw-r--r--arch/tile/kernel/hardwall.c5
-rw-r--r--arch/tile/kernel/head_32.S5
-rw-r--r--arch/tile/kernel/intvec_32.S101
-rw-r--r--arch/tile/kernel/irq.c18
-rw-r--r--arch/tile/kernel/machine_kexec.c6
-rw-r--r--arch/tile/kernel/messaging.c2
-rw-r--r--arch/tile/kernel/process.c50
-rw-r--r--arch/tile/kernel/ptrace.c108
-rw-r--r--arch/tile/kernel/reboot.c6
-rw-r--r--arch/tile/kernel/regs_32.S2
-rw-r--r--arch/tile/kernel/setup.c42
-rw-r--r--arch/tile/kernel/signal.c15
-rw-r--r--arch/tile/kernel/single_step.c73
-rw-r--r--arch/tile/kernel/smp.c4
-rw-r--r--arch/tile/kernel/stack.c35
-rw-r--r--arch/tile/kernel/sys.c9
-rw-r--r--arch/tile/kernel/time.c8
-rw-r--r--arch/tile/kernel/traps.c4
-rw-r--r--arch/tile/kvm/Kconfig38
-rw-r--r--arch/tile/lib/Makefile4
-rw-r--r--arch/tile/lib/atomic_32.c8
-rw-r--r--arch/tile/lib/exports.c3
-rw-r--r--arch/tile/lib/memcpy_32.S206
-rw-r--r--arch/tile/lib/memcpy_tile64.c11
-rw-r--r--arch/tile/lib/memmove.c (renamed from arch/tile/lib/memmove_32.c)0
-rw-r--r--arch/tile/lib/memset_32.c1
-rw-r--r--arch/tile/lib/strlen_32.c2
-rw-r--r--arch/tile/mm/fault.c12
-rw-r--r--arch/tile/mm/highmem.c88
-rw-r--r--arch/tile/mm/homecache.c11
-rw-r--r--arch/tile/mm/init.c10
-rw-r--r--arch/tile/mm/pgtable.c4
-rw-r--r--arch/um/Kconfig.common2
-rw-r--r--arch/um/Kconfig.um6
-rw-r--r--arch/um/defconfig1
-rw-r--r--arch/um/drivers/harddog_kern.c14
-rw-r--r--arch/um/drivers/hostaudio_kern.c12
-rw-r--r--arch/um/drivers/mconsole_kern.c1
-rw-r--r--arch/um/drivers/mmapper_kern.c1
-rw-r--r--arch/um/drivers/random.c1
-rw-r--r--arch/um/drivers/ubd_kern.c11
-rw-r--r--arch/um/include/asm/dma-mapping.h112
-rw-r--r--arch/um/include/asm/pgtable.h2
-rw-r--r--arch/um/include/asm/ptrace-generic.h4
-rw-r--r--arch/um/include/asm/system.h49
-rw-r--r--arch/um/kernel/dyn.lds.S14
-rw-r--r--arch/um/kernel/exec.c2
-rw-r--r--arch/um/kernel/irq.c15
-rw-r--r--arch/um/kernel/ptrace.c23
-rw-r--r--arch/um/kernel/uml.lds.S19
-rw-r--r--arch/um/os-Linux/time.c2
-rw-r--r--arch/um/sys-i386/ptrace.c4
-rw-r--r--arch/um/sys-x86_64/ptrace.c11
-rw-r--r--arch/x86/Kbuild1
-rw-r--r--arch/x86/Kconfig21
-rw-r--r--arch/x86/Kconfig.debug10
-rw-r--r--arch/x86/Makefile_32.cpu13
-rw-r--r--arch/x86/boot/compressed/misc.c29
-rw-r--r--arch/x86/include/asm/acpi.h3
-rw-r--r--arch/x86/include/asm/amd_nb.h49
-rw-r--r--arch/x86/include/asm/apic.h10
-rw-r--r--arch/x86/include/asm/bitops.h2
-rw-r--r--arch/x86/include/asm/calling.h52
-rw-r--r--arch/x86/include/asm/entry_arch.h19
-rw-r--r--arch/x86/include/asm/highmem.h11
-rw-r--r--arch/x86/include/asm/io.h13
-rw-r--r--arch/x86/include/asm/io_apic.h2
-rw-r--r--arch/x86/include/asm/iomap.h4
-rw-r--r--arch/x86/include/asm/irq.h12
-rw-r--r--arch/x86/include/asm/kvm_emulate.h30
-rw-r--r--arch/x86/include/asm/kvm_host.h81
-rw-r--r--arch/x86/include/asm/kvm_para.h6
-rw-r--r--arch/x86/include/asm/module.h7
-rw-r--r--arch/x86/include/asm/msr-index.h2
-rw-r--r--arch/x86/include/asm/olpc.h2
-rw-r--r--arch/x86/include/asm/page_32_types.h4
-rw-r--r--arch/x86/include/asm/pci.h33
-rw-r--r--arch/x86/include/asm/pci_x86.h1
-rw-r--r--arch/x86/include/asm/percpu.h14
-rw-r--r--arch/x86/include/asm/perf_event.h19
-rw-r--r--arch/x86/include/asm/pgtable_32.h16
-rw-r--r--arch/x86/include/asm/pgtable_64.h2
-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/smp.h9
-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/uv/uv_hub.h21
-rw-r--r--arch/x86/include/asm/uv/uv_mmrs.h189
-rw-r--r--arch/x86/include/asm/x86_init.h9
-rw-r--r--arch/x86/include/asm/xen/hypercall.h17
-rw-r--r--arch/x86/include/asm/xen/page.h12
-rw-r--r--arch/x86/include/asm/xen/pci.h65
-rw-r--r--arch/x86/kernel/Makefile12
-rw-r--r--arch/x86/kernel/acpi/boot.c60
-rw-r--r--arch/x86/kernel/acpi/sleep.c6
-rw-r--r--arch/x86/kernel/alternative.c71
-rw-r--r--arch/x86/kernel/amd_nb.c135
-rw-r--r--arch/x86/kernel/aperture_64.c10
-rw-r--r--arch/x86/kernel/apic/apic.c1
-rw-r--r--arch/x86/kernel/apic/io_apic.c11
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c36
-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/cpu/cpufreq/acpi-cpufreq.c1
-rw-r--r--arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c2
-rw-r--r--arch/x86/kernel/cpu/cpufreq/longrun.c4
-rw-r--r--arch/x86/kernel/cpu/intel.c4
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c148
-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/perf_event.c26
-rw-r--r--arch/x86/kernel/cpu/perf_event_amd.c4
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c216
-rw-r--r--arch/x86/kernel/crash_dump_32.c2
-rw-r--r--arch/x86/kernel/dumpstack_32.c6
-rw-r--r--arch/x86/kernel/dumpstack_64.c8
-rw-r--r--arch/x86/kernel/entry_32.S6
-rw-r--r--arch/x86/kernel/entry_64.S20
-rw-r--r--arch/x86/kernel/head32.c1
-rw-r--r--arch/x86/kernel/head_32.S55
-rw-r--r--arch/x86/kernel/hpet.c53
-rw-r--r--arch/x86/kernel/irq_32.c25
-rw-r--r--arch/x86/kernel/kdebugfs.c1
-rw-r--r--arch/x86/kernel/kgdb.c14
-rw-r--r--arch/x86/kernel/kvmclock.c6
-rw-r--r--arch/x86/kernel/microcode_amd.c2
-rw-r--r--arch/x86/kernel/microcode_core.c3
-rw-r--r--arch/x86/kernel/microcode_intel.c2
-rw-r--r--arch/x86/kernel/mmconf-fam10h_64.c7
-rw-r--r--arch/x86/kernel/pci-gart_64.c34
-rw-r--r--arch/x86/kernel/ptrace.c17
-rw-r--r--arch/x86/kernel/pvclock.c41
-rw-r--r--arch/x86/kernel/quirks.c2
-rw-r--r--arch/x86/kernel/reboot.c12
-rw-r--r--arch/x86/kernel/setup.c28
-rw-r--r--arch/x86/kernel/smp.c15
-rw-r--r--arch/x86/kernel/smpboot.c19
-rw-r--r--arch/x86/kernel/trampoline.c16
-rw-r--r--arch/x86/kernel/traps.c1
-rw-r--r--arch/x86/kernel/vm86_32.c10
-rw-r--r--arch/x86/kernel/vmlinux.lds.S2
-rw-r--r--arch/x86/kernel/x86_init.c7
-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.c15
-rw-r--r--arch/x86/kvm/mmu.c927
-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.c283
-rw-r--r--arch/x86/kvm/timer.c2
-rw-r--r--arch/x86/kvm/vmx.c219
-rw-r--r--arch/x86/kvm/x86.c796
-rw-r--r--arch/x86/kvm/x86.h8
-rw-r--r--arch/x86/mm/Makefile2
-rw-r--r--arch/x86/mm/amdtopology_64.c (renamed from arch/x86/mm/k8topology_64.c)12
-rw-r--r--arch/x86/mm/fault.c63
-rw-r--r--arch/x86/mm/highmem_32.c76
-rw-r--r--arch/x86/mm/init_32.c45
-rw-r--r--arch/x86/mm/init_64.c1
-rw-r--r--arch/x86/mm/iomap_32.c43
-rw-r--r--arch/x86/mm/numa_64.c29
-rw-r--r--arch/x86/mm/tlb.c2
-rw-r--r--arch/x86/oprofile/nmi_int.c6
-rw-r--r--arch/x86/oprofile/op_model_amd.c146
-rw-r--r--arch/x86/pci/Makefile1
-rw-r--r--arch/x86/pci/acpi.c103
-rw-r--r--arch/x86/pci/common.c17
-rw-r--r--arch/x86/pci/i386.c19
-rw-r--r--arch/x86/pci/irq.c11
-rw-r--r--arch/x86/pci/mmconfig-shared.c4
-rw-r--r--arch/x86/pci/xen.c416
-rw-r--r--arch/x86/platform/Makefile8
-rw-r--r--arch/x86/platform/efi/Makefile1
-rw-r--r--arch/x86/platform/efi/efi.c (renamed from arch/x86/kernel/efi.c)0
-rw-r--r--arch/x86/platform/efi/efi_32.c (renamed from arch/x86/kernel/efi_32.c)0
-rw-r--r--arch/x86/platform/efi/efi_64.c (renamed from arch/x86/kernel/efi_64.c)0
-rw-r--r--arch/x86/platform/efi/efi_stub_32.S (renamed from arch/x86/kernel/efi_stub_32.S)0
-rw-r--r--arch/x86/platform/efi/efi_stub_64.S (renamed from arch/x86/kernel/efi_stub_64.S)0
-rw-r--r--arch/x86/platform/mrst/Makefile1
-rw-r--r--arch/x86/platform/mrst/mrst.c (renamed from arch/x86/kernel/mrst.c)0
-rw-r--r--arch/x86/platform/olpc/Makefile3
-rw-r--r--arch/x86/platform/olpc/olpc-xo1.c (renamed from arch/x86/kernel/olpc-xo1.c)0
-rw-r--r--arch/x86/platform/olpc/olpc.c (renamed from arch/x86/kernel/olpc.c)0
-rw-r--r--arch/x86/platform/olpc/olpc_ofw.c (renamed from arch/x86/kernel/olpc_ofw.c)0
-rw-r--r--arch/x86/platform/scx200/Makefile2
-rw-r--r--arch/x86/platform/scx200/scx200_32.c (renamed from arch/x86/kernel/scx200_32.c)0
-rw-r--r--arch/x86/platform/sfi/Makefile1
-rw-r--r--arch/x86/platform/sfi/sfi.c (renamed from arch/x86/kernel/sfi.c)0
-rw-r--r--arch/x86/platform/uv/Makefile1
-rw-r--r--arch/x86/platform/uv/bios_uv.c (renamed from arch/x86/kernel/bios_uv.c)0
-rw-r--r--arch/x86/platform/uv/tlb_uv.c (renamed from arch/x86/kernel/tlb_uv.c)25
-rw-r--r--arch/x86/platform/uv/uv_irq.c (renamed from arch/x86/kernel/uv_irq.c)0
-rw-r--r--arch/x86/platform/uv/uv_sysfs.c (renamed from arch/x86/kernel/uv_sysfs.c)0
-rw-r--r--arch/x86/platform/uv/uv_time.c (renamed from arch/x86/kernel/uv_time.c)0
-rw-r--r--arch/x86/platform/visws/Makefile1
-rw-r--r--arch/x86/platform/visws/visws_quirks.c (renamed from arch/x86/kernel/visws_quirks.c)0
-rw-r--r--arch/x86/xen/Kconfig21
-rw-r--r--arch/x86/xen/debugfs.c1
-rw-r--r--arch/x86/xen/enlighten.c24
-rw-r--r--arch/x86/xen/mmu.c548
-rw-r--r--arch/x86/xen/mmu.h1
-rw-r--r--arch/x86/xen/pci-swiotlb-xen.c4
-rw-r--r--arch/x86/xen/setup.c131
-rw-r--r--arch/x86/xen/smp.c32
-rw-r--r--arch/x86/xen/xen-ops.h3
-rw-r--r--arch/xtensa/Kconfig5
-rw-r--r--arch/xtensa/include/asm/pgtable.h3
-rw-r--r--arch/xtensa/include/asm/uaccess.h2
-rw-r--r--arch/xtensa/kernel/ptrace.c14
1768 files changed, 70804 insertions, 25702 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 53d7f619a1b9..8bf0fa652eb6 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -42,6 +42,20 @@ config KPROBES
42 for kernel debugging, non-intrusive instrumentation and testing. 42 for kernel debugging, non-intrusive instrumentation and testing.
43 If in doubt, say "N". 43 If in doubt, say "N".
44 44
45config JUMP_LABEL
46 bool "Optimize trace point call sites"
47 depends on HAVE_ARCH_JUMP_LABEL
48 help
49 If it is detected that the compiler has support for "asm goto",
50 the kernel will compile trace point locations with just a
51 nop instruction. When trace points are enabled, the nop will
52 be converted to a jump to the trace function. This technique
53 lowers overhead and stress on the branch prediction of the
54 processor.
55
56 On i386, options added to the compiler flags may increase
57 the size of the kernel slightly.
58
45config OPTPROBES 59config OPTPROBES
46 def_bool y 60 def_bool y
47 depends on KPROBES && HAVE_OPTPROBES 61 depends on KPROBES && HAVE_OPTPROBES
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index d04ccd73af45..943fe6930f77 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -1,7 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5config ALPHA 1config ALPHA
6 bool 2 bool
7 default y 3 default y
@@ -55,6 +51,9 @@ config ZONE_DMA
55 bool 51 bool
56 default y 52 default y
57 53
54config ARCH_DMA_ADDR_T_64BIT
55 def_bool y
56
58config NEED_DMA_MAP_STATE 57config NEED_DMA_MAP_STATE
59 def_bool y 58 def_bool y
60 59
diff --git a/arch/alpha/include/asm/core_mcpcia.h b/arch/alpha/include/asm/core_mcpcia.h
index 21ac53383b37..9f67a056b461 100644
--- a/arch/alpha/include/asm/core_mcpcia.h
+++ b/arch/alpha/include/asm/core_mcpcia.h
@@ -247,7 +247,7 @@ struct el_MCPCIA_uncorrected_frame_mcheck {
247#define vip volatile int __force * 247#define vip volatile int __force *
248#define vuip volatile unsigned int __force * 248#define vuip volatile unsigned int __force *
249 249
250#ifdef MCPCIA_ONE_HAE_WINDOW 250#ifndef MCPCIA_ONE_HAE_WINDOW
251#define MCPCIA_FROB_MMIO \ 251#define MCPCIA_FROB_MMIO \
252 if (__mcpcia_is_mmio(hose)) { \ 252 if (__mcpcia_is_mmio(hose)) { \
253 set_hae(hose & 0xffffffff); \ 253 set_hae(hose & 0xffffffff); \
diff --git a/arch/alpha/include/asm/core_t2.h b/arch/alpha/include/asm/core_t2.h
index 471c07292e0b..91b46801b290 100644
--- a/arch/alpha/include/asm/core_t2.h
+++ b/arch/alpha/include/asm/core_t2.h
@@ -1,6 +1,9 @@
1#ifndef __ALPHA_T2__H__ 1#ifndef __ALPHA_T2__H__
2#define __ALPHA_T2__H__ 2#define __ALPHA_T2__H__
3 3
4/* Fit everything into one 128MB HAE window. */
5#define T2_ONE_HAE_WINDOW 1
6
4#include <linux/types.h> 7#include <linux/types.h>
5#include <linux/spinlock.h> 8#include <linux/spinlock.h>
6#include <asm/compiler.h> 9#include <asm/compiler.h>
@@ -19,7 +22,7 @@
19 * 22 *
20 */ 23 */
21 24
22#define T2_MEM_R1_MASK 0x07ffffff /* Mem sparse region 1 mask is 26 bits */ 25#define T2_MEM_R1_MASK 0x07ffffff /* Mem sparse region 1 mask is 27 bits */
23 26
24/* GAMMA-SABLE is a SABLE with EV5-based CPUs */ 27/* GAMMA-SABLE is a SABLE with EV5-based CPUs */
25/* All LYNX machines, EV4 or EV5, use the GAMMA bias also */ 28/* All LYNX machines, EV4 or EV5, use the GAMMA bias also */
@@ -85,7 +88,9 @@
85#define T2_DIR (IDENT_ADDR + GAMMA_BIAS + 0x38e0004a0UL) 88#define T2_DIR (IDENT_ADDR + GAMMA_BIAS + 0x38e0004a0UL)
86#define T2_ICE (IDENT_ADDR + GAMMA_BIAS + 0x38e0004c0UL) 89#define T2_ICE (IDENT_ADDR + GAMMA_BIAS + 0x38e0004c0UL)
87 90
91#ifndef T2_ONE_HAE_WINDOW
88#define T2_HAE_ADDRESS T2_HAE_1 92#define T2_HAE_ADDRESS T2_HAE_1
93#endif
89 94
90/* T2 CSRs are in the non-cachable primary IO space from 3.8000.0000 to 95/* T2 CSRs are in the non-cachable primary IO space from 3.8000.0000 to
91 3.8fff.ffff 96 3.8fff.ffff
@@ -429,13 +434,15 @@ extern inline void t2_outl(u32 b, unsigned long addr)
429 * 434 *
430 */ 435 */
431 436
437#ifdef T2_ONE_HAE_WINDOW
438#define t2_set_hae
439#else
432#define t2_set_hae { \ 440#define t2_set_hae { \
433 msb = addr >> 27; \ 441 unsigned long msb = addr >> 27; \
434 addr &= T2_MEM_R1_MASK; \ 442 addr &= T2_MEM_R1_MASK; \
435 set_hae(msb); \ 443 set_hae(msb); \
436} 444}
437 445#endif
438extern raw_spinlock_t t2_hae_lock;
439 446
440/* 447/*
441 * NOTE: take T2_DENSE_MEM off in each readX/writeX routine, since 448 * NOTE: take T2_DENSE_MEM off in each readX/writeX routine, since
@@ -446,28 +453,22 @@ extern raw_spinlock_t t2_hae_lock;
446__EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr) 453__EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr)
447{ 454{
448 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 455 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
449 unsigned long result, msb; 456 unsigned long result;
450 unsigned long flags;
451 raw_spin_lock_irqsave(&t2_hae_lock, flags);
452 457
453 t2_set_hae; 458 t2_set_hae;
454 459
455 result = *(vip) ((addr << 5) + T2_SPARSE_MEM + 0x00); 460 result = *(vip) ((addr << 5) + T2_SPARSE_MEM + 0x00);
456 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
457 return __kernel_extbl(result, addr & 3); 461 return __kernel_extbl(result, addr & 3);
458} 462}
459 463
460__EXTERN_INLINE u16 t2_readw(const volatile void __iomem *xaddr) 464__EXTERN_INLINE u16 t2_readw(const volatile void __iomem *xaddr)
461{ 465{
462 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 466 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
463 unsigned long result, msb; 467 unsigned long result;
464 unsigned long flags;
465 raw_spin_lock_irqsave(&t2_hae_lock, flags);
466 468
467 t2_set_hae; 469 t2_set_hae;
468 470
469 result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08); 471 result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08);
470 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
471 return __kernel_extwl(result, addr & 3); 472 return __kernel_extwl(result, addr & 3);
472} 473}
473 474
@@ -478,59 +479,47 @@ __EXTERN_INLINE u16 t2_readw(const volatile void __iomem *xaddr)
478__EXTERN_INLINE u32 t2_readl(const volatile void __iomem *xaddr) 479__EXTERN_INLINE u32 t2_readl(const volatile void __iomem *xaddr)
479{ 480{
480 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 481 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
481 unsigned long result, msb; 482 unsigned long result;
482 unsigned long flags;
483 raw_spin_lock_irqsave(&t2_hae_lock, flags);
484 483
485 t2_set_hae; 484 t2_set_hae;
486 485
487 result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18); 486 result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18);
488 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
489 return result & 0xffffffffUL; 487 return result & 0xffffffffUL;
490} 488}
491 489
492__EXTERN_INLINE u64 t2_readq(const volatile void __iomem *xaddr) 490__EXTERN_INLINE u64 t2_readq(const volatile void __iomem *xaddr)
493{ 491{
494 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 492 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
495 unsigned long r0, r1, work, msb; 493 unsigned long r0, r1, work;
496 unsigned long flags;
497 raw_spin_lock_irqsave(&t2_hae_lock, flags);
498 494
499 t2_set_hae; 495 t2_set_hae;
500 496
501 work = (addr << 5) + T2_SPARSE_MEM + 0x18; 497 work = (addr << 5) + T2_SPARSE_MEM + 0x18;
502 r0 = *(vuip)(work); 498 r0 = *(vuip)(work);
503 r1 = *(vuip)(work + (4 << 5)); 499 r1 = *(vuip)(work + (4 << 5));
504 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
505 return r1 << 32 | r0; 500 return r1 << 32 | r0;
506} 501}
507 502
508__EXTERN_INLINE void t2_writeb(u8 b, volatile void __iomem *xaddr) 503__EXTERN_INLINE void t2_writeb(u8 b, volatile void __iomem *xaddr)
509{ 504{
510 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 505 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
511 unsigned long msb, w; 506 unsigned long w;
512 unsigned long flags;
513 raw_spin_lock_irqsave(&t2_hae_lock, flags);
514 507
515 t2_set_hae; 508 t2_set_hae;
516 509
517 w = __kernel_insbl(b, addr & 3); 510 w = __kernel_insbl(b, addr & 3);
518 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x00) = w; 511 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x00) = w;
519 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
520} 512}
521 513
522__EXTERN_INLINE void t2_writew(u16 b, volatile void __iomem *xaddr) 514__EXTERN_INLINE void t2_writew(u16 b, volatile void __iomem *xaddr)
523{ 515{
524 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 516 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
525 unsigned long msb, w; 517 unsigned long w;
526 unsigned long flags;
527 raw_spin_lock_irqsave(&t2_hae_lock, flags);
528 518
529 t2_set_hae; 519 t2_set_hae;
530 520
531 w = __kernel_inswl(b, addr & 3); 521 w = __kernel_inswl(b, addr & 3);
532 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08) = w; 522 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08) = w;
533 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
534} 523}
535 524
536/* 525/*
@@ -540,29 +529,22 @@ __EXTERN_INLINE void t2_writew(u16 b, volatile void __iomem *xaddr)
540__EXTERN_INLINE void t2_writel(u32 b, volatile void __iomem *xaddr) 529__EXTERN_INLINE void t2_writel(u32 b, volatile void __iomem *xaddr)
541{ 530{
542 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 531 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
543 unsigned long msb;
544 unsigned long flags;
545 raw_spin_lock_irqsave(&t2_hae_lock, flags);
546 532
547 t2_set_hae; 533 t2_set_hae;
548 534
549 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18) = b; 535 *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18) = b;
550 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
551} 536}
552 537
553__EXTERN_INLINE void t2_writeq(u64 b, volatile void __iomem *xaddr) 538__EXTERN_INLINE void t2_writeq(u64 b, volatile void __iomem *xaddr)
554{ 539{
555 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM; 540 unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
556 unsigned long msb, work; 541 unsigned long work;
557 unsigned long flags;
558 raw_spin_lock_irqsave(&t2_hae_lock, flags);
559 542
560 t2_set_hae; 543 t2_set_hae;
561 544
562 work = (addr << 5) + T2_SPARSE_MEM + 0x18; 545 work = (addr << 5) + T2_SPARSE_MEM + 0x18;
563 *(vuip)work = b; 546 *(vuip)work = b;
564 *(vuip)(work + (4 << 5)) = b >> 32; 547 *(vuip)(work + (4 << 5)) = b >> 32;
565 raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
566} 548}
567 549
568__EXTERN_INLINE void __iomem *t2_ioportmap(unsigned long addr) 550__EXTERN_INLINE void __iomem *t2_ioportmap(unsigned long addr)
diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
index 71a243294142..de98a732683d 100644
--- a/arch/alpha/include/asm/pgtable.h
+++ b/arch/alpha/include/asm/pgtable.h
@@ -318,9 +318,7 @@ extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address)
318} 318}
319 319
320#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr)) 320#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr))
321#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir),(addr))
322#define pte_unmap(pte) do { } while (0) 321#define pte_unmap(pte) do { } while (0)
323#define pte_unmap_nested(pte) do { } while (0)
324 322
325extern pgd_t swapper_pg_dir[1024]; 323extern pgd_t swapper_pg_dir[1024];
326 324
diff --git a/arch/alpha/kernel/core_t2.c b/arch/alpha/kernel/core_t2.c
index e6d90568b65d..2f770e994289 100644
--- a/arch/alpha/kernel/core_t2.c
+++ b/arch/alpha/kernel/core_t2.c
@@ -74,8 +74,6 @@
74# define DBG(args) 74# define DBG(args)
75#endif 75#endif
76 76
77DEFINE_RAW_SPINLOCK(t2_hae_lock);
78
79static volatile unsigned int t2_mcheck_any_expected; 77static volatile unsigned int t2_mcheck_any_expected;
80static volatile unsigned int t2_mcheck_last_taken; 78static volatile unsigned int t2_mcheck_last_taken;
81 79
@@ -406,6 +404,7 @@ void __init
406t2_init_arch(void) 404t2_init_arch(void)
407{ 405{
408 struct pci_controller *hose; 406 struct pci_controller *hose;
407 struct resource *hae_mem;
409 unsigned long temp; 408 unsigned long temp;
410 unsigned int i; 409 unsigned int i;
411 410
@@ -433,7 +432,13 @@ t2_init_arch(void)
433 */ 432 */
434 pci_isa_hose = hose = alloc_pci_controller(); 433 pci_isa_hose = hose = alloc_pci_controller();
435 hose->io_space = &ioport_resource; 434 hose->io_space = &ioport_resource;
436 hose->mem_space = &iomem_resource; 435 hae_mem = alloc_resource();
436 hae_mem->start = 0;
437 hae_mem->end = T2_MEM_R1_MASK;
438 hae_mem->name = pci_hae0_name;
439 if (request_resource(&iomem_resource, hae_mem) < 0)
440 printk(KERN_ERR "Failed to request HAE_MEM\n");
441 hose->mem_space = hae_mem;
437 hose->index = 0; 442 hose->index = 0;
438 443
439 hose->sparse_mem_base = T2_SPARSE_MEM - IDENT_ADDR; 444 hose->sparse_mem_base = T2_SPARSE_MEM - IDENT_ADDR;
diff --git a/arch/alpha/kernel/machvec_impl.h b/arch/alpha/kernel/machvec_impl.h
index 512685f78097..7fa62488bd16 100644
--- a/arch/alpha/kernel/machvec_impl.h
+++ b/arch/alpha/kernel/machvec_impl.h
@@ -25,6 +25,9 @@
25#ifdef MCPCIA_ONE_HAE_WINDOW 25#ifdef MCPCIA_ONE_HAE_WINDOW
26#define MCPCIA_HAE_ADDRESS (&alpha_mv.hae_cache) 26#define MCPCIA_HAE_ADDRESS (&alpha_mv.hae_cache)
27#endif 27#endif
28#ifdef T2_ONE_HAE_WINDOW
29#define T2_HAE_ADDRESS (&alpha_mv.hae_cache)
30#endif
28 31
29/* Only a few systems don't define IACK_SC, handling all interrupts through 32/* Only a few systems don't define IACK_SC, handling all interrupts through
30 the SRM console. But splitting out that one case from IO() below 33 the SRM console. But splitting out that one case from IO() below
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index d1dbd9acd1df..022c2748fa41 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -223,7 +223,7 @@ iommu_arena_free(struct pci_iommu_arena *arena, long ofs, long n)
223 */ 223 */
224static int pci_dac_dma_supported(struct pci_dev *dev, u64 mask) 224static int pci_dac_dma_supported(struct pci_dev *dev, u64 mask)
225{ 225{
226 dma64_addr_t dac_offset = alpha_mv.pci_dac_offset; 226 dma_addr_t dac_offset = alpha_mv.pci_dac_offset;
227 int ok = 1; 227 int ok = 1;
228 228
229 /* If this is not set, the machine doesn't support DAC at all. */ 229 /* If this is not set, the machine doesn't support DAC at all. */
@@ -756,7 +756,7 @@ static void alpha_pci_unmap_sg(struct device *dev, struct scatterlist *sg,
756 spin_lock_irqsave(&arena->lock, flags); 756 spin_lock_irqsave(&arena->lock, flags);
757 757
758 for (end = sg + nents; sg < end; ++sg) { 758 for (end = sg + nents; sg < end; ++sg) {
759 dma64_addr_t addr; 759 dma_addr_t addr;
760 size_t size; 760 size_t size;
761 long npages, ofs; 761 long npages, ofs;
762 dma_addr_t tend; 762 dma_addr_t tend;
diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index baa903602f6a..e2af5eb59bb4 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -269,7 +269,8 @@ void ptrace_disable(struct task_struct *child)
269 user_disable_single_step(child); 269 user_disable_single_step(child);
270} 270}
271 271
272long arch_ptrace(struct task_struct *child, long request, long addr, long data) 272long arch_ptrace(struct task_struct *child, long request,
273 unsigned long addr, unsigned long data)
273{ 274{
274 unsigned long tmp; 275 unsigned long tmp;
275 size_t copied; 276 size_t copied;
@@ -292,7 +293,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
292 case PTRACE_PEEKUSR: 293 case PTRACE_PEEKUSR:
293 force_successful_syscall_return(); 294 force_successful_syscall_return();
294 ret = get_reg(child, addr); 295 ret = get_reg(child, addr);
295 DBG(DBG_MEM, ("peek $%ld->%#lx\n", addr, ret)); 296 DBG(DBG_MEM, ("peek $%lu->%#lx\n", addr, ret));
296 break; 297 break;
297 298
298 /* When I and D space are separate, this will have to be fixed. */ 299 /* When I and D space are separate, this will have to be fixed. */
@@ -302,7 +303,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
302 break; 303 break;
303 304
304 case PTRACE_POKEUSR: /* write the specified register */ 305 case PTRACE_POKEUSR: /* write the specified register */
305 DBG(DBG_MEM, ("poke $%ld<-%#lx\n", addr, data)); 306 DBG(DBG_MEM, ("poke $%lu<-%#lx\n", addr, data));
306 ret = put_reg(child, addr, data); 307 ret = put_reg(child, addr, data);
307 break; 308 break;
308 default: 309 default:
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3849887157e7..db524e75c4a2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux Kernel Configuration"
7
8config ARM 1config ARM
9 bool 2 bool
10 default y 3 default y
@@ -13,7 +6,7 @@ config ARM
13 select HAVE_MEMBLOCK 6 select HAVE_MEMBLOCK
14 select RTC_LIB 7 select RTC_LIB
15 select SYS_SUPPORTS_APM_EMULATION 8 select SYS_SUPPORTS_APM_EMULATION
16 select GENERIC_ATOMIC64 if (!CPU_32v6K) 9 select GENERIC_ATOMIC64 if (!CPU_32v6K || !AEABI)
17 select HAVE_OPROFILE if (HAVE_PERF_EVENTS) 10 select HAVE_OPROFILE if (HAVE_PERF_EVENTS)
18 select HAVE_ARCH_KGDB 11 select HAVE_ARCH_KGDB
19 select HAVE_KPROBES if (!XIP_KERNEL) 12 select HAVE_KPROBES if (!XIP_KERNEL)
@@ -573,6 +566,7 @@ config ARCH_TEGRA
573 select HAVE_CLK 566 select HAVE_CLK
574 select COMMON_CLKDEV 567 select COMMON_CLKDEV
575 select ARCH_HAS_BARRIERS if CACHE_L2X0 568 select ARCH_HAS_BARRIERS if CACHE_L2X0
569 select ARCH_HAS_CPUFREQ
576 help 570 help
577 This enables support for NVIDIA Tegra based systems (Tegra APX, 571 This enables support for NVIDIA Tegra based systems (Tegra APX,
578 Tegra 6xx and Tegra 2 series). 572 Tegra 6xx and Tegra 2 series).
@@ -652,7 +646,7 @@ config ARCH_S3C2410
652 select ARCH_HAS_CPUFREQ 646 select ARCH_HAS_CPUFREQ
653 select HAVE_CLK 647 select HAVE_CLK
654 select ARCH_USES_GETTIMEOFFSET 648 select ARCH_USES_GETTIMEOFFSET
655 select HAVE_S3C2410_I2C 649 select HAVE_S3C2410_I2C if I2C
656 help 650 help
657 Samsung S3C2410X CPU based systems, such as the Simtec Electronics 651 Samsung S3C2410X CPU based systems, such as the Simtec Electronics
658 BAST (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or 652 BAST (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or
@@ -682,8 +676,8 @@ config ARCH_S3C64XX
682 select S3C_DEV_NAND 676 select S3C_DEV_NAND
683 select USB_ARCH_HAS_OHCI 677 select USB_ARCH_HAS_OHCI
684 select SAMSUNG_GPIOLIB_4BIT 678 select SAMSUNG_GPIOLIB_4BIT
685 select HAVE_S3C2410_I2C 679 select HAVE_S3C2410_I2C if I2C
686 select HAVE_S3C2410_WATCHDOG 680 select HAVE_S3C2410_WATCHDOG if WATCHDOG
687 help 681 help
688 Samsung S3C64XX series based systems 682 Samsung S3C64XX series based systems
689 683
@@ -692,10 +686,10 @@ config ARCH_S5P64X0
692 select CPU_V6 686 select CPU_V6
693 select GENERIC_GPIO 687 select GENERIC_GPIO
694 select HAVE_CLK 688 select HAVE_CLK
695 select HAVE_S3C2410_WATCHDOG 689 select HAVE_S3C2410_WATCHDOG if WATCHDOG
696 select ARCH_USES_GETTIMEOFFSET 690 select ARCH_USES_GETTIMEOFFSET
697 select HAVE_S3C2410_I2C 691 select HAVE_S3C2410_I2C if I2C
698 select HAVE_S3C_RTC 692 select HAVE_S3C_RTC if RTC_CLASS
699 help 693 help
700 Samsung S5P64X0 CPU based systems, such as the Samsung SMDK6440, 694 Samsung S5P64X0 CPU based systems, such as the Samsung SMDK6440,
701 SMDK6450. 695 SMDK6450.
@@ -706,7 +700,7 @@ config ARCH_S5P6442
706 select GENERIC_GPIO 700 select GENERIC_GPIO
707 select HAVE_CLK 701 select HAVE_CLK
708 select ARCH_USES_GETTIMEOFFSET 702 select ARCH_USES_GETTIMEOFFSET
709 select HAVE_S3C2410_WATCHDOG 703 select HAVE_S3C2410_WATCHDOG if WATCHDOG
710 help 704 help
711 Samsung S5P6442 CPU based systems 705 Samsung S5P6442 CPU based systems
712 706
@@ -717,31 +711,37 @@ config ARCH_S5PC100
717 select CPU_V7 711 select CPU_V7
718 select ARM_L1_CACHE_SHIFT_6 712 select ARM_L1_CACHE_SHIFT_6
719 select ARCH_USES_GETTIMEOFFSET 713 select ARCH_USES_GETTIMEOFFSET
720 select HAVE_S3C2410_I2C 714 select HAVE_S3C2410_I2C if I2C
721 select HAVE_S3C_RTC 715 select HAVE_S3C_RTC if RTC_CLASS
722 select HAVE_S3C2410_WATCHDOG 716 select HAVE_S3C2410_WATCHDOG if WATCHDOG
723 help 717 help
724 Samsung S5PC100 series based systems 718 Samsung S5PC100 series based systems
725 719
726config ARCH_S5PV210 720config ARCH_S5PV210
727 bool "Samsung S5PV210/S5PC110" 721 bool "Samsung S5PV210/S5PC110"
728 select CPU_V7 722 select CPU_V7
723 select ARCH_SPARSEMEM_ENABLE
729 select GENERIC_GPIO 724 select GENERIC_GPIO
730 select HAVE_CLK 725 select HAVE_CLK
731 select ARM_L1_CACHE_SHIFT_6 726 select ARM_L1_CACHE_SHIFT_6
727 select ARCH_HAS_CPUFREQ
732 select ARCH_USES_GETTIMEOFFSET 728 select ARCH_USES_GETTIMEOFFSET
733 select HAVE_S3C2410_I2C 729 select HAVE_S3C2410_I2C if I2C
734 select HAVE_S3C_RTC 730 select HAVE_S3C_RTC if RTC_CLASS
735 select HAVE_S3C2410_WATCHDOG 731 select HAVE_S3C2410_WATCHDOG if WATCHDOG
736 help 732 help
737 Samsung S5PV210/S5PC110 series based systems 733 Samsung S5PV210/S5PC110 series based systems
738 734
739config ARCH_S5PV310 735config ARCH_S5PV310
740 bool "Samsung S5PV310/S5PC210" 736 bool "Samsung S5PV310/S5PC210"
741 select CPU_V7 737 select CPU_V7
738 select ARCH_SPARSEMEM_ENABLE
742 select GENERIC_GPIO 739 select GENERIC_GPIO
743 select HAVE_CLK 740 select HAVE_CLK
744 select GENERIC_CLOCKEVENTS 741 select GENERIC_CLOCKEVENTS
742 select HAVE_S3C_RTC if RTC_CLASS
743 select HAVE_S3C2410_I2C if I2C
744 select HAVE_S3C2410_WATCHDOG if WATCHDOG
745 help 745 help
746 Samsung S5PV310 series based systems 746 Samsung S5PV310 series based systems
747 747
@@ -831,7 +831,7 @@ config ARCH_OMAP
831 select GENERIC_CLOCKEVENTS 831 select GENERIC_CLOCKEVENTS
832 select ARCH_HAS_HOLES_MEMORYMODEL 832 select ARCH_HAS_HOLES_MEMORYMODEL
833 help 833 help
834 Support for TI's OMAP platform (OMAP1 and OMAP2). 834 Support for TI's OMAP platform (OMAP1/2/3/4).
835 835
836config PLAT_SPEAR 836config PLAT_SPEAR
837 bool "ST SPEAr" 837 bool "ST SPEAr"
@@ -1222,7 +1222,7 @@ config SMP
1222 1222
1223 See also <file:Documentation/i386/IO-APIC.txt>, 1223 See also <file:Documentation/i386/IO-APIC.txt>,
1224 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at 1224 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
1225 <http://www.linuxdoc.org/docs.html#howto>. 1225 <http://tldp.org/HOWTO/SMP-HOWTO.html>.
1226 1226
1227 If you don't know what to do here, say N. 1227 If you don't know what to do here, say N.
1228 1228
@@ -1668,6 +1668,12 @@ if ARCH_HAS_CPUFREQ
1668 1668
1669source "drivers/cpufreq/Kconfig" 1669source "drivers/cpufreq/Kconfig"
1670 1670
1671config CPU_FREQ_IMX
1672 tristate "CPUfreq driver for i.MX CPUs"
1673 depends on ARCH_MXC && CPU_FREQ
1674 help
1675 This enables the CPUfreq driver for i.MX CPUs.
1676
1671config CPU_FREQ_SA1100 1677config CPU_FREQ_SA1100
1672 bool 1678 bool
1673 1679
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index ada6359160eb..772f95f1aecd 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -251,15 +251,16 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
251 writel(cpumask, base + GIC_DIST_TARGET + i * 4 / 4); 251 writel(cpumask, base + GIC_DIST_TARGET + i * 4 / 4);
252 252
253 /* 253 /*
254 * Set priority on all interrupts. 254 * Set priority on all global interrupts.
255 */ 255 */
256 for (i = 0; i < max_irq; i += 4) 256 for (i = 32; i < max_irq; i += 4)
257 writel(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4); 257 writel(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4);
258 258
259 /* 259 /*
260 * Disable all interrupts. 260 * Disable all interrupts. Leave the PPI and SGIs alone
261 * as these enables are banked registers.
261 */ 262 */
262 for (i = 0; i < max_irq; i += 32) 263 for (i = 32; i < max_irq; i += 32)
263 writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32); 264 writel(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i * 4 / 32);
264 265
265 /* 266 /*
@@ -277,11 +278,30 @@ void __init gic_dist_init(unsigned int gic_nr, void __iomem *base,
277 278
278void __cpuinit gic_cpu_init(unsigned int gic_nr, void __iomem *base) 279void __cpuinit gic_cpu_init(unsigned int gic_nr, void __iomem *base)
279{ 280{
281 void __iomem *dist_base;
282 int i;
283
280 if (gic_nr >= MAX_GIC_NR) 284 if (gic_nr >= MAX_GIC_NR)
281 BUG(); 285 BUG();
282 286
287 dist_base = gic_data[gic_nr].dist_base;
288 BUG_ON(!dist_base);
289
283 gic_data[gic_nr].cpu_base = base; 290 gic_data[gic_nr].cpu_base = base;
284 291
292 /*
293 * Deal with the banked PPI and SGI interrupts - disable all
294 * PPI interrupts, ensure all SGI interrupts are enabled.
295 */
296 writel(0xffff0000, dist_base + GIC_DIST_ENABLE_CLEAR);
297 writel(0x0000ffff, dist_base + GIC_DIST_ENABLE_SET);
298
299 /*
300 * Set priority on PPI and SGI interrupts
301 */
302 for (i = 0; i < 32; i += 4)
303 writel(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4 / 4);
304
285 writel(0xf0, base + GIC_CPU_PRIMASK); 305 writel(0xf0, base + GIC_CPU_PRIMASK);
286 writel(1, base + GIC_CPU_CTRL); 306 writel(1, base + GIC_CPU_CTRL);
287} 307}
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/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/da8xx_omapl_defconfig b/arch/arm/configs/da8xx_omapl_defconfig
index ba6670556f78..cdc40c4b8c48 100644
--- a/arch/arm/configs/da8xx_omapl_defconfig
+++ b/arch/arm/configs/da8xx_omapl_defconfig
@@ -17,6 +17,8 @@ CONFIG_MODVERSIONS=y
17CONFIG_ARCH_DAVINCI=y 17CONFIG_ARCH_DAVINCI=y
18CONFIG_ARCH_DAVINCI_DA830=y 18CONFIG_ARCH_DAVINCI_DA830=y
19CONFIG_ARCH_DAVINCI_DA850=y 19CONFIG_ARCH_DAVINCI_DA850=y
20CONFIG_MACH_MITYOMAPL138=y
21CONFIG_MACH_OMAPL138_HAWKBOARD=y
20CONFIG_DAVINCI_RESET_CLOCKS=y 22CONFIG_DAVINCI_RESET_CLOCKS=y
21CONFIG_NO_HZ=y 23CONFIG_NO_HZ=y
22CONFIG_HIGH_RES_TIMERS=y 24CONFIG_HIGH_RES_TIMERS=y
@@ -79,6 +81,7 @@ CONFIG_I2C_DAVINCI=y
79# CONFIG_HWMON is not set 81# CONFIG_HWMON is not set
80CONFIG_WATCHDOG=y 82CONFIG_WATCHDOG=y
81CONFIG_REGULATOR=y 83CONFIG_REGULATOR=y
84CONFIG_REGULATOR_DUMMY=y
82CONFIG_REGULATOR_TPS6507X=y 85CONFIG_REGULATOR_TPS6507X=y
83CONFIG_FB=y 86CONFIG_FB=y
84CONFIG_FB_DA8XX=y 87CONFIG_FB_DA8XX=y
diff --git a/arch/arm/configs/mx51_defconfig b/arch/arm/configs/mx51_defconfig
index 163cfee7644c..5c7a87260fab 100644
--- a/arch/arm/configs/mx51_defconfig
+++ b/arch/arm/configs/mx51_defconfig
@@ -82,6 +82,7 @@ CONFIG_FEC=y
82CONFIG_INPUT_FF_MEMLESS=m 82CONFIG_INPUT_FF_MEMLESS=m
83# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 83# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
84CONFIG_INPUT_EVDEV=y 84CONFIG_INPUT_EVDEV=y
85CONFIG_KEYBOARD_GPIO=y
85CONFIG_INPUT_EVBUG=m 86CONFIG_INPUT_EVBUG=m
86CONFIG_MOUSE_PS2=m 87CONFIG_MOUSE_PS2=m
87CONFIG_MOUSE_PS2_ELANTECH=y 88CONFIG_MOUSE_PS2_ELANTECH=y
diff --git a/arch/arm/configs/n8x0_defconfig b/arch/arm/configs/n8x0_defconfig
deleted file mode 100644
index 56aebb69411d..000000000000
--- a/arch/arm/configs/n8x0_defconfig
+++ /dev/null
@@ -1,94 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y
5CONFIG_MODULES=y
6CONFIG_MODULE_UNLOAD=y
7# CONFIG_LBDAF is not set
8# CONFIG_BLK_DEV_BSG is not set
9# CONFIG_IOSCHED_DEADLINE is not set
10CONFIG_ARCH_OMAP=y
11CONFIG_ARCH_OMAP2=y
12CONFIG_OMAP_RESET_CLOCKS=y
13# CONFIG_OMAP_MUX is not set
14# CONFIG_OMAP_MCBSP is not set
15CONFIG_OMAP_MBOX_FWK=y
16CONFIG_OMAP_32K_TIMER=y
17CONFIG_ARCH_OMAP2420=y
18CONFIG_MACH_NOKIA_N8X0=y
19CONFIG_AEABI=y
20CONFIG_LEDS=y
21CONFIG_ZBOOT_ROM_TEXT=0x10C08000
22CONFIG_ZBOOT_ROM_BSS=0x10200000
23CONFIG_CMDLINE="root=/dev/mmcblk0p2 console=ttyS2,115200n8 debug earlyprintk rootwait"
24CONFIG_FPE_NWFPE=y
25CONFIG_VFP=y
26CONFIG_PM=y
27CONFIG_PM_RUNTIME=y
28CONFIG_NET=y
29CONFIG_UNIX=y
30CONFIG_INET=y
31# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
32# CONFIG_INET_XFRM_MODE_TUNNEL is not set
33# CONFIG_INET_XFRM_MODE_BEET is not set
34# CONFIG_INET_LRO is not set
35# CONFIG_IPV6 is not set
36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
37CONFIG_MTD=y
38CONFIG_MTD_CMDLINE_PARTS=y
39CONFIG_MTD_ONENAND=y
40CONFIG_MTD_ONENAND_OMAP2=y
41CONFIG_MTD_ONENAND_OTP=y
42CONFIG_BLK_DEV_RAM=y
43# CONFIG_MISC_DEVICES is not set
44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
45# CONFIG_INPUT_KEYBOARD is not set
46# CONFIG_INPUT_MOUSE is not set
47CONFIG_SERIAL_8250=y
48CONFIG_SERIAL_8250_CONSOLE=y
49# CONFIG_LEGACY_PTYS is not set
50# CONFIG_HW_RANDOM is not set
51CONFIG_I2C=y
52# CONFIG_I2C_COMPAT is not set
53# CONFIG_I2C_HELPER_AUTO is not set
54CONFIG_I2C_OMAP=y
55CONFIG_SPI=y
56CONFIG_SPI_OMAP24XX=y
57# CONFIG_HWMON is not set
58CONFIG_MENELAUS=y
59CONFIG_REGULATOR=y
60# CONFIG_VGA_CONSOLE is not set
61# CONFIG_HID_SUPPORT is not set
62CONFIG_USB=y
63CONFIG_USB_DEBUG=y
64CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
65CONFIG_USB_DEVICEFS=y
66CONFIG_USB_SUSPEND=y
67# CONFIG_USB_OTG_WHITELIST is not set
68CONFIG_USB_MUSB_HDRC=y
69CONFIG_USB_MUSB_OTG=y
70CONFIG_USB_GADGET_MUSB_HDRC=y
71# CONFIG_MUSB_PIO_ONLY is not set
72CONFIG_USB_MUSB_DEBUG=y
73CONFIG_USB_GADGET=y
74CONFIG_USB_GADGET_DEBUG=y
75CONFIG_USB_GADGET_DEBUG_FILES=y
76CONFIG_USB_ETH=m
77CONFIG_USB_ETH_EEM=y
78CONFIG_MMC=y
79CONFIG_MMC_OMAP=y
80CONFIG_EXT3_FS=y
81CONFIG_INOTIFY=y
82CONFIG_VFAT_FS=y
83CONFIG_TMPFS=y
84CONFIG_JFFS2_FS=y
85CONFIG_JFFS2_SUMMARY=y
86CONFIG_JFFS2_COMPRESSION_OPTIONS=y
87CONFIG_JFFS2_LZO=y
88CONFIG_PRINTK_TIME=y
89CONFIG_DEBUG_KERNEL=y
90CONFIG_DEBUG_INFO=y
91# CONFIG_RCU_CPU_STALL_DETECTOR is not set
92CONFIG_DEBUG_USER=y
93CONFIG_DEBUG_ERRORS=y
94CONFIG_CRC_CCITT=y
diff --git a/arch/arm/configs/omap3_defconfig b/arch/arm/configs/omap2plus_defconfig
index 5db9a6be2054..ccedde1371c3 100644
--- a/arch/arm/configs/omap3_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -53,18 +53,18 @@ CONFIG_MACH_SBC3530=y
53CONFIG_MACH_OMAP_3630SDP=y 53CONFIG_MACH_OMAP_3630SDP=y
54CONFIG_MACH_OMAP_4430SDP=y 54CONFIG_MACH_OMAP_4430SDP=y
55CONFIG_ARM_THUMBEE=y 55CONFIG_ARM_THUMBEE=y
56CONFIG_ARM_L1_CACHE_SHIFT=5
57CONFIG_ARM_ERRATA_411920=y
56CONFIG_NO_HZ=y 58CONFIG_NO_HZ=y
57CONFIG_HIGH_RES_TIMERS=y 59CONFIG_HIGH_RES_TIMERS=y
60CONFIG_SMP=y
61# CONFIG_LOCAL_TIMERS is not set
58CONFIG_AEABI=y 62CONFIG_AEABI=y
59CONFIG_LEDS=y 63CONFIG_LEDS=y
60CONFIG_ZBOOT_ROM_TEXT=0x0 64CONFIG_ZBOOT_ROM_TEXT=0x0
61CONFIG_ZBOOT_ROM_BSS=0x0 65CONFIG_ZBOOT_ROM_BSS=0x0
62CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait console=ttyS2,115200" 66CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait console=ttyO2,115200"
63CONFIG_KEXEC=y 67CONFIG_KEXEC=y
64CONFIG_CPU_FREQ=y
65CONFIG_CPU_FREQ_STAT_DETAILS=y
66CONFIG_CPU_FREQ_GOV_USERSPACE=y
67CONFIG_CPU_FREQ_GOV_ONDEMAND=y
68CONFIG_FPE_NWFPE=y 68CONFIG_FPE_NWFPE=y
69CONFIG_VFP=y 69CONFIG_VFP=y
70CONFIG_NEON=y 70CONFIG_NEON=y
@@ -87,23 +87,23 @@ CONFIG_IP_PNP_RARP=y
87# CONFIG_INET_LRO is not set 87# CONFIG_INET_LRO is not set
88# CONFIG_IPV6 is not set 88# CONFIG_IPV6 is not set
89CONFIG_NETFILTER=y 89CONFIG_NETFILTER=y
90CONFIG_BT=y 90CONFIG_BT=m
91CONFIG_BT_L2CAP=y 91CONFIG_BT_L2CAP=m
92CONFIG_BT_SCO=y 92CONFIG_BT_SCO=m
93CONFIG_BT_RFCOMM=y 93CONFIG_BT_RFCOMM=y
94CONFIG_BT_RFCOMM_TTY=y 94CONFIG_BT_RFCOMM_TTY=y
95CONFIG_BT_BNEP=y 95CONFIG_BT_BNEP=m
96CONFIG_BT_BNEP_MC_FILTER=y 96CONFIG_BT_BNEP_MC_FILTER=y
97CONFIG_BT_BNEP_PROTO_FILTER=y 97CONFIG_BT_BNEP_PROTO_FILTER=y
98CONFIG_BT_HIDP=y 98CONFIG_BT_HIDP=m
99CONFIG_BT_HCIUART=y 99CONFIG_BT_HCIUART=m
100CONFIG_BT_HCIUART_H4=y 100CONFIG_BT_HCIUART_H4=y
101CONFIG_BT_HCIUART_BCSP=y 101CONFIG_BT_HCIUART_BCSP=y
102CONFIG_BT_HCIUART_LL=y 102CONFIG_BT_HCIUART_LL=y
103CONFIG_BT_HCIBCM203X=y 103CONFIG_BT_HCIBCM203X=m
104CONFIG_BT_HCIBPA10X=y 104CONFIG_BT_HCIBPA10X=m
105CONFIG_CFG80211=y 105CONFIG_CFG80211=m
106CONFIG_MAC80211=y 106CONFIG_MAC80211=m
107CONFIG_MAC80211_RC_PID=y 107CONFIG_MAC80211_RC_PID=y
108CONFIG_MAC80211_RC_DEFAULT_PID=y 108CONFIG_MAC80211_RC_DEFAULT_PID=y
109CONFIG_MAC80211_LEDS=y 109CONFIG_MAC80211_LEDS=y
@@ -137,9 +137,11 @@ CONFIG_SMSC_PHY=y
137CONFIG_NET_ETHERNET=y 137CONFIG_NET_ETHERNET=y
138CONFIG_SMC91X=y 138CONFIG_SMC91X=y
139CONFIG_SMSC911X=y 139CONFIG_SMSC911X=y
140CONFIG_LIBERTAS=y 140CONFIG_KS8851=y
141CONFIG_LIBERTAS_USB=y 141CONFIG_KS8851_MLL=y
142CONFIG_LIBERTAS_SDIO=y 142CONFIG_LIBERTAS=m
143CONFIG_LIBERTAS_USB=m
144CONFIG_LIBERTAS_SDIO=m
143CONFIG_LIBERTAS_DEBUG=y 145CONFIG_LIBERTAS_DEBUG=y
144CONFIG_USB_USBNET=y 146CONFIG_USB_USBNET=y
145CONFIG_USB_ALI_M5632=y 147CONFIG_USB_ALI_M5632=y
@@ -201,8 +203,8 @@ CONFIG_FONTS=y
201CONFIG_FONT_8x8=y 203CONFIG_FONT_8x8=y
202CONFIG_FONT_8x16=y 204CONFIG_FONT_8x16=y
203CONFIG_LOGO=y 205CONFIG_LOGO=y
204CONFIG_SOUND=y 206CONFIG_SOUND=m
205CONFIG_SND=y 207CONFIG_SND=m
206CONFIG_SND_MIXER_OSS=y 208CONFIG_SND_MIXER_OSS=y
207CONFIG_SND_PCM_OSS=y 209CONFIG_SND_PCM_OSS=y
208CONFIG_SND_VERBOSE_PRINTK=y 210CONFIG_SND_VERBOSE_PRINTK=y
@@ -218,9 +220,9 @@ CONFIG_USB_DEVICEFS=y
218CONFIG_USB_SUSPEND=y 220CONFIG_USB_SUSPEND=y
219# CONFIG_USB_OTG_WHITELIST is not set 221# CONFIG_USB_OTG_WHITELIST is not set
220CONFIG_USB_MON=y 222CONFIG_USB_MON=y
221CONFIG_USB_MUSB_HDRC=y 223# CONFIG_USB_MUSB_HDRC is not set
222CONFIG_USB_MUSB_OTG=y 224# CONFIG_USB_MUSB_OTG is not set
223CONFIG_USB_GADGET_MUSB_HDRC=y 225# CONFIG_USB_GADGET_MUSB_HDRC is not set
224CONFIG_USB_MUSB_DEBUG=y 226CONFIG_USB_MUSB_DEBUG=y
225CONFIG_USB_WDM=y 227CONFIG_USB_WDM=y
226CONFIG_USB_STORAGE=y 228CONFIG_USB_STORAGE=y
@@ -276,12 +278,11 @@ CONFIG_DEBUG_KERNEL=y
276CONFIG_SCHEDSTATS=y 278CONFIG_SCHEDSTATS=y
277CONFIG_TIMER_STATS=y 279CONFIG_TIMER_STATS=y
278CONFIG_PROVE_LOCKING=y 280CONFIG_PROVE_LOCKING=y
279CONFIG_LOCK_STAT=y 281# CONFIG_LOCK_STAT is not set
280CONFIG_DEBUG_SPINLOCK_SLEEP=y 282CONFIG_DEBUG_SPINLOCK_SLEEP=y
281# CONFIG_DEBUG_BUGVERBOSE is not set 283# CONFIG_DEBUG_BUGVERBOSE is not set
282CONFIG_DEBUG_INFO=y 284CONFIG_DEBUG_INFO=y
283# CONFIG_RCU_CPU_STALL_DETECTOR is not set 285# CONFIG_RCU_CPU_STALL_DETECTOR is not set
284CONFIG_DEBUG_LL=y
285CONFIG_SECURITY=y 286CONFIG_SECURITY=y
286CONFIG_CRYPTO_MICHAEL_MIC=y 287CONFIG_CRYPTO_MICHAEL_MIC=y
287# CONFIG_CRYPTO_ANSI_CPRNG is not set 288# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/arm/configs/omap_4430sdp_defconfig b/arch/arm/configs/omap_4430sdp_defconfig
deleted file mode 100644
index 14c1e18c648f..000000000000
--- a/arch/arm/configs/omap_4430sdp_defconfig
+++ /dev/null
@@ -1,125 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_BSD_PROCESS_ACCT=y
4CONFIG_LOG_BUF_SHIFT=14
5CONFIG_BLK_DEV_INITRD=y
6CONFIG_EMBEDDED=y
7# CONFIG_SYSCTL_SYSCALL is not set
8# CONFIG_ELF_CORE is not set
9CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y
11CONFIG_MODVERSIONS=y
12CONFIG_MODULE_SRCVERSION_ALL=y
13# CONFIG_BLK_DEV_BSG is not set
14CONFIG_ARCH_OMAP=y
15CONFIG_ARCH_OMAP4=y
16# CONFIG_ARCH_OMAP2PLUS_TYPICAL is not set
17# CONFIG_ARCH_OMAP2 is not set
18# CONFIG_ARCH_OMAP3 is not set
19# CONFIG_OMAP_MUX is not set
20CONFIG_OMAP_32K_TIMER=y
21CONFIG_OMAP_DM_TIMER=y
22CONFIG_MACH_OMAP_4430SDP=y
23# CONFIG_ARM_THUMB is not set
24CONFIG_PL310_ERRATA_588369=y
25CONFIG_SMP=y
26CONFIG_NR_CPUS=2
27# CONFIG_LOCAL_TIMERS is not set
28CONFIG_PREEMPT=y
29CONFIG_AEABI=y
30CONFIG_ZBOOT_ROM_TEXT=0x0
31CONFIG_ZBOOT_ROM_BSS=0x0
32CONFIG_CMDLINE="root=/dev/ram0 rw mem=128M console=ttyS2,115200n8 initrd=0x81600000,20M ramdisk_size=20480"
33CONFIG_VFP=y
34CONFIG_NEON=y
35CONFIG_BINFMT_MISC=y
36CONFIG_NET=y
37CONFIG_PACKET=y
38CONFIG_INET=y
39CONFIG_IP_PNP=y
40CONFIG_IP_PNP_DHCP=y
41CONFIG_IP_PNP_BOOTP=y
42CONFIG_IP_PNP_RARP=y
43# CONFIG_IPV6 is not set
44# CONFIG_WIRELESS is not set
45CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
46# CONFIG_FW_LOADER is not set
47CONFIG_BLK_DEV_LOOP=y
48CONFIG_BLK_DEV_RAM=y
49CONFIG_BLK_DEV_RAM_SIZE=16384
50# CONFIG_MISC_DEVICES is not set
51CONFIG_NETDEVICES=y
52CONFIG_NET_ETHERNET=y
53CONFIG_KS8851=y
54# CONFIG_NETDEV_1000 is not set
55# CONFIG_NETDEV_10000 is not set
56# CONFIG_WLAN is not set
57# CONFIG_INPUT_MOUSEDEV is not set
58CONFIG_INPUT_EVDEV=y
59# CONFIG_INPUT_KEYBOARD is not set
60# CONFIG_INPUT_MOUSE is not set
61# CONFIG_SERIO is not set
62CONFIG_SERIAL_8250=y
63CONFIG_SERIAL_8250_CONSOLE=y
64CONFIG_SERIAL_8250_NR_UARTS=32
65CONFIG_SERIAL_8250_EXTENDED=y
66CONFIG_SERIAL_8250_MANY_PORTS=y
67CONFIG_SERIAL_8250_SHARE_IRQ=y
68CONFIG_SERIAL_8250_DETECT_IRQ=y
69CONFIG_SERIAL_8250_RSA=y
70# CONFIG_LEGACY_PTYS is not set
71CONFIG_HW_RANDOM=y
72CONFIG_I2C=y
73CONFIG_I2C_CHARDEV=y
74CONFIG_I2C_OMAP=y
75CONFIG_SPI=y
76CONFIG_SPI_OMAP24XX=y
77# CONFIG_HWMON is not set
78CONFIG_WATCHDOG=y
79CONFIG_OMAP_WATCHDOG=y
80CONFIG_TWL4030_CORE=y
81CONFIG_REGULATOR=y
82CONFIG_REGULATOR_TWL4030=y
83# CONFIG_VGA_CONSOLE is not set
84# CONFIG_HID_SUPPORT is not set
85# CONFIG_USB_SUPPORT is not set
86CONFIG_MMC=y
87CONFIG_MMC_OMAP_HS=y
88CONFIG_RTC_CLASS=y
89CONFIG_RTC_DRV_TWL4030=y
90CONFIG_EXT2_FS=y
91CONFIG_EXT3_FS=y
92# CONFIG_EXT3_FS_XATTR is not set
93CONFIG_INOTIFY=y
94CONFIG_QUOTA=y
95CONFIG_QFMT_V2=y
96CONFIG_MSDOS_FS=y
97CONFIG_VFAT_FS=y
98CONFIG_TMPFS=y
99CONFIG_NFS_FS=y
100CONFIG_NFS_V3=y
101CONFIG_NFS_V3_ACL=y
102CONFIG_NFS_V4=y
103CONFIG_ROOT_NFS=y
104CONFIG_PARTITION_ADVANCED=y
105CONFIG_NLS_CODEPAGE_437=y
106CONFIG_NLS_ISO8859_1=y
107# CONFIG_ENABLE_WARN_DEPRECATED is not set
108# CONFIG_ENABLE_MUST_CHECK is not set
109CONFIG_MAGIC_SYSRQ=y
110CONFIG_DEBUG_KERNEL=y
111# CONFIG_DETECT_SOFTLOCKUP is not set
112CONFIG_DETECT_HUNG_TASK=y
113# CONFIG_SCHED_DEBUG is not set
114# CONFIG_DEBUG_PREEMPT is not set
115# CONFIG_DEBUG_BUGVERBOSE is not set
116CONFIG_DEBUG_INFO=y
117# CONFIG_RCU_CPU_STALL_DETECTOR is not set
118# CONFIG_FTRACE is not set
119# CONFIG_ARM_UNWIND is not set
120CONFIG_CRYPTO_ECB=m
121CONFIG_CRYPTO_PCBC=m
122# CONFIG_CRYPTO_ANSI_CPRNG is not set
123CONFIG_CRC_CCITT=y
124CONFIG_CRC_T10DIF=y
125CONFIG_LIBCRC32C=y
diff --git a/arch/arm/configs/omap_generic_2420_defconfig b/arch/arm/configs/omap_generic_2420_defconfig
deleted file mode 100644
index ac08e51180dd..000000000000
--- a/arch/arm/configs/omap_generic_2420_defconfig
+++ /dev/null
@@ -1,37 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_LOG_BUF_SHIFT=14
4CONFIG_BLK_DEV_INITRD=y
5CONFIG_MODULES=y
6CONFIG_MODULE_UNLOAD=y
7# CONFIG_BLK_DEV_BSG is not set
8CONFIG_ARCH_OMAP=y
9CONFIG_ARCH_OMAP2=y
10# CONFIG_OMAP_MUX is not set
11CONFIG_MACH_OMAP_GENERIC=y
12CONFIG_ARCH_OMAP2420=y
13CONFIG_LEDS=y
14CONFIG_ZBOOT_ROM_TEXT=0x10C08000
15CONFIG_ZBOOT_ROM_BSS=0x10200000
16CONFIG_FPE_NWFPE=y
17CONFIG_BLK_DEV_RAM=y
18CONFIG_INPUT_EVDEV=y
19# CONFIG_INPUT_KEYBOARD is not set
20# CONFIG_INPUT_MOUSE is not set
21CONFIG_SERIAL_8250=y
22CONFIG_SERIAL_8250_CONSOLE=y
23# CONFIG_LEGACY_PTYS is not set
24CONFIG_WATCHDOG=y
25CONFIG_WATCHDOG_NOWAYOUT=y
26CONFIG_VIDEO_OUTPUT_CONTROL=m
27# CONFIG_VGA_CONSOLE is not set
28CONFIG_EXT2_FS=y
29CONFIG_EXT2_FS_XATTR=y
30CONFIG_INOTIFY=y
31CONFIG_ROMFS_FS=y
32CONFIG_DEBUG_KERNEL=y
33CONFIG_DEBUG_INFO=y
34CONFIG_DEBUG_USER=y
35CONFIG_DEBUG_ERRORS=y
36CONFIG_DEBUG_LL=y
37CONFIG_CRC_CCITT=y
diff --git a/arch/arm/configs/pcontrol_g20_defconfig b/arch/arm/configs/pcontrol_g20_defconfig
new file mode 100644
index 000000000000..b42ee62c4d77
--- /dev/null
+++ b/arch/arm/configs/pcontrol_g20_defconfig
@@ -0,0 +1,175 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_CROSS_COMPILE="/opt/arm-2010q1/bin/arm-none-linux-gnueabi-"
3# CONFIG_LOCALVERSION_AUTO is not set
4# CONFIG_SWAP is not set
5CONFIG_SYSVIPC=y
6CONFIG_POSIX_MQUEUE=y
7CONFIG_TREE_PREEMPT_RCU=y
8CONFIG_IKCONFIG=y
9CONFIG_IKCONFIG_PROC=y
10CONFIG_LOG_BUF_SHIFT=14
11CONFIG_NAMESPACES=y
12CONFIG_BLK_DEV_INITRD=y
13CONFIG_EMBEDDED=y
14# CONFIG_SYSCTL_SYSCALL is not set
15# CONFIG_KALLSYMS is not set
16# CONFIG_VM_EVENT_COUNTERS is not set
17# CONFIG_COMPAT_BRK is not set
18CONFIG_SLAB=y
19CONFIG_MODULES=y
20CONFIG_MODULE_UNLOAD=y
21# CONFIG_LBDAF is not set
22# CONFIG_BLK_DEV_BSG is not set
23CONFIG_DEFAULT_DEADLINE=y
24CONFIG_ARCH_AT91=y
25CONFIG_ARCH_AT91SAM9G20=y
26CONFIG_MACH_PCONTROL_G20=y
27CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
28CONFIG_NO_HZ=y
29CONFIG_HIGH_RES_TIMERS=y
30CONFIG_PREEMPT=y
31CONFIG_AEABI=y
32# CONFIG_OABI_COMPAT is not set
33CONFIG_ZBOOT_ROM_TEXT=0x0
34CONFIG_ZBOOT_ROM_BSS=0x0
35CONFIG_CMDLINE="console=ttyS0,115200 mem=128M mtdparts=atmel_nand:128k(bootstrap)ro,256k(uboot)ro,128k(env1)ro,128k(env2)ro,2M(linux),-(root) root=/dev/mmcblk0p1 rootwait rw"
36CONFIG_VFP=y
37CONFIG_BINFMT_MISC=y
38CONFIG_NET=y
39CONFIG_PACKET=y
40CONFIG_UNIX=y
41CONFIG_INET=y
42# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
43# CONFIG_INET_XFRM_MODE_TUNNEL is not set
44# CONFIG_INET_XFRM_MODE_BEET is not set
45# CONFIG_INET_LRO is not set
46# CONFIG_IPV6 is not set
47CONFIG_VLAN_8021Q=y
48# CONFIG_WIRELESS is not set
49CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
50# CONFIG_FW_LOADER is not set
51CONFIG_MTD=y
52CONFIG_MTD_PARTITIONS=y
53CONFIG_MTD_CMDLINE_PARTS=y
54CONFIG_MTD_CHAR=y
55CONFIG_MTD_BLOCK=y
56CONFIG_MTD_COMPLEX_MAPPINGS=y
57CONFIG_MTD_PHRAM=m
58CONFIG_MTD_NAND=y
59CONFIG_MTD_NAND_ATMEL=y
60CONFIG_BLK_DEV_LOOP=y
61CONFIG_BLK_DEV_RAM=y
62CONFIG_BLK_DEV_RAM_SIZE=8192
63CONFIG_ATMEL_TCLIB=y
64CONFIG_EEPROM_AT24=m
65CONFIG_SCSI=m
66# CONFIG_SCSI_PROC_FS is not set
67CONFIG_BLK_DEV_SD=m
68CONFIG_SCSI_MULTI_LUN=y
69# CONFIG_SCSI_LOWLEVEL is not set
70CONFIG_NETDEVICES=y
71CONFIG_MACVLAN=m
72CONFIG_TUN=m
73CONFIG_SMSC_PHY=m
74CONFIG_BROADCOM_PHY=m
75CONFIG_NET_ETHERNET=y
76CONFIG_MII=y
77CONFIG_MACB=y
78CONFIG_SMSC911X=m
79# CONFIG_NETDEV_1000 is not set
80# CONFIG_NETDEV_10000 is not set
81# CONFIG_WLAN is not set
82CONFIG_PPP=m
83CONFIG_PPP_ASYNC=m
84CONFIG_PPP_DEFLATE=m
85CONFIG_PPP_MPPE=m
86CONFIG_INPUT_POLLDEV=y
87CONFIG_INPUT_SPARSEKMAP=y
88# CONFIG_INPUT_MOUSEDEV is not set
89CONFIG_INPUT_EVDEV=m
90CONFIG_INPUT_EVBUG=m
91# CONFIG_KEYBOARD_ATKBD is not set
92CONFIG_KEYBOARD_GPIO=m
93CONFIG_KEYBOARD_MATRIX=m
94# CONFIG_INPUT_MOUSE is not set
95CONFIG_INPUT_TOUCHSCREEN=y
96CONFIG_INPUT_MISC=y
97CONFIG_INPUT_UINPUT=m
98CONFIG_INPUT_GPIO_ROTARY_ENCODER=m
99# CONFIG_SERIO is not set
100# CONFIG_DEVKMEM is not set
101CONFIG_SERIAL_ATMEL=y
102CONFIG_SERIAL_ATMEL_CONSOLE=y
103CONFIG_SERIAL_MAX3100=m
104# CONFIG_LEGACY_PTYS is not set
105# CONFIG_HW_RANDOM is not set
106CONFIG_R3964=m
107CONFIG_I2C=m
108CONFIG_I2C_CHARDEV=m
109# CONFIG_I2C_HELPER_AUTO is not set
110CONFIG_I2C_GPIO=m
111CONFIG_SPI=y
112CONFIG_SPI_ATMEL=m
113CONFIG_SPI_SPIDEV=m
114CONFIG_GPIO_SYSFS=y
115CONFIG_W1=m
116CONFIG_W1_MASTER_GPIO=m
117CONFIG_W1_SLAVE_DS2431=m
118# CONFIG_HWMON is not set
119CONFIG_WATCHDOG=y
120CONFIG_AT91SAM9X_WATCHDOG=y
121# CONFIG_MFD_SUPPORT is not set
122# CONFIG_HID_SUPPORT is not set
123CONFIG_USB=y
124# CONFIG_USB_DEVICE_CLASS is not set
125CONFIG_USB_OHCI_HCD=y
126CONFIG_USB_STORAGE=m
127CONFIG_USB_LIBUSUAL=y
128CONFIG_USB_SERIAL=m
129CONFIG_USB_SERIAL_GENERIC=y
130CONFIG_USB_SERIAL_FTDI_SIO=m
131CONFIG_USB_SERIAL_PL2303=m
132CONFIG_USB_GADGET=y
133CONFIG_USB_ZERO=m
134CONFIG_USB_ETH=m
135CONFIG_USB_FILE_STORAGE=m
136CONFIG_USB_G_SERIAL=m
137CONFIG_USB_G_HID=m
138CONFIG_MMC=y
139CONFIG_MMC_UNSAFE_RESUME=y
140CONFIG_MMC_ATMELMCI=y
141CONFIG_NEW_LEDS=y
142CONFIG_LEDS_CLASS=y
143CONFIG_LEDS_GPIO=y
144CONFIG_LEDS_TRIGGERS=y
145CONFIG_LEDS_TRIGGER_TIMER=y
146CONFIG_LEDS_TRIGGER_HEARTBEAT=y
147CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
148CONFIG_RTC_CLASS=y
149CONFIG_RTC_DRV_AT91SAM9=y
150CONFIG_AUXDISPLAY=y
151CONFIG_UIO=y
152CONFIG_UIO_PDRV=y
153CONFIG_STAGING=y
154# CONFIG_STAGING_EXCLUDE_BUILD is not set
155CONFIG_IIO=y
156CONFIG_EXT2_FS=y
157CONFIG_EXT3_FS=y
158# CONFIG_EXT3_FS_XATTR is not set
159CONFIG_VFAT_FS=y
160CONFIG_TMPFS=y
161CONFIG_JFFS2_FS=y
162CONFIG_NFS_FS=y
163CONFIG_NFS_V3=y
164CONFIG_NFS_V4=y
165CONFIG_PARTITION_ADVANCED=y
166CONFIG_NLS_CODEPAGE_437=y
167CONFIG_NLS_CODEPAGE_850=y
168CONFIG_NLS_ISO8859_1=y
169CONFIG_NLS_ISO8859_15=y
170CONFIG_NLS_UTF8=y
171# CONFIG_RCU_CPU_STALL_DETECTOR is not set
172CONFIG_CRYPTO=y
173CONFIG_CRYPTO_ANSI_CPRNG=y
174# CONFIG_CRYPTO_HW is not set
175CONFIG_CRC_CCITT=y
diff --git a/arch/arm/include/asm/hardware/cache-l2x0.h b/arch/arm/include/asm/hardware/cache-l2x0.h
index 6bcba48800fe..cc42d5fdee17 100644
--- a/arch/arm/include/asm/hardware/cache-l2x0.h
+++ b/arch/arm/include/asm/hardware/cache-l2x0.h
@@ -21,9 +21,6 @@
21#define __ASM_ARM_HARDWARE_L2X0_H 21#define __ASM_ARM_HARDWARE_L2X0_H
22 22
23#define L2X0_CACHE_ID 0x000 23#define L2X0_CACHE_ID 0x000
24#define L2X0_CACHE_ID_PART_MASK (0xf << 6)
25#define L2X0_CACHE_ID_PART_L210 (1 << 6)
26#define L2X0_CACHE_ID_PART_L310 (3 << 6)
27#define L2X0_CACHE_TYPE 0x004 24#define L2X0_CACHE_TYPE 0x004
28#define L2X0_CTRL 0x100 25#define L2X0_CTRL 0x100
29#define L2X0_AUX_CTRL 0x104 26#define L2X0_AUX_CTRL 0x104
@@ -53,6 +50,16 @@
53#define L2X0_LINE_DATA 0xF10 50#define L2X0_LINE_DATA 0xF10
54#define L2X0_LINE_TAG 0xF30 51#define L2X0_LINE_TAG 0xF30
55#define L2X0_DEBUG_CTRL 0xF40 52#define L2X0_DEBUG_CTRL 0xF40
53#define L2X0_PREFETCH_CTRL 0xF60
54#define L2X0_POWER_CTRL 0xF80
55#define L2X0_DYNAMIC_CLK_GATING_EN (1 << 1)
56#define L2X0_STNDBY_MODE_EN (1 << 0)
57
58/* Registers shifts and masks */
59#define L2X0_CACHE_ID_PART_MASK (0xf << 6)
60#define L2X0_CACHE_ID_PART_L210 (1 << 6)
61#define L2X0_CACHE_ID_PART_L310 (3 << 6)
62#define L2X0_AUX_CTRL_WAY_SIZE_MASK (0x3 << 17)
56 63
57#ifndef __ASSEMBLY__ 64#ifndef __ASSEMBLY__
58extern void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask); 65extern void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask);
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/hardware/it8152.h b/arch/arm/include/asm/hardware/it8152.h
index 6700c7fc7ebd..21fa272301f8 100644
--- a/arch/arm/include/asm/hardware/it8152.h
+++ b/arch/arm/include/asm/hardware/it8152.h
@@ -75,7 +75,7 @@ extern unsigned long it8152_base_address;
75 IT8152_PD_IRQ(1) USB (USBR) 75 IT8152_PD_IRQ(1) USB (USBR)
76 IT8152_PD_IRQ(0) Audio controller (ACR) 76 IT8152_PD_IRQ(0) Audio controller (ACR)
77 */ 77 */
78#define IT8152_IRQ(x) (IRQ_BOARD_END + (x)) 78#define IT8152_IRQ(x) (IRQ_BOARD_START + (x))
79 79
80/* IRQ-sources in 3 groups - local devices, LPC (serial), and external PCI */ 80/* IRQ-sources in 3 groups - local devices, LPC (serial), and external PCI */
81#define IT8152_LD_IRQ_COUNT 9 81#define IT8152_LD_IRQ_COUNT 9
diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
index 5aff58126602..1fc684e70ab6 100644
--- a/arch/arm/include/asm/highmem.h
+++ b/arch/arm/include/asm/highmem.h
@@ -35,9 +35,9 @@ extern void kunmap_high_l1_vipt(struct page *page, pte_t saved_pte);
35#ifdef CONFIG_HIGHMEM 35#ifdef CONFIG_HIGHMEM
36extern void *kmap(struct page *page); 36extern void *kmap(struct page *page);
37extern void kunmap(struct page *page); 37extern void kunmap(struct page *page);
38extern void *kmap_atomic(struct page *page, enum km_type type); 38extern void *__kmap_atomic(struct page *page);
39extern void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type); 39extern void __kunmap_atomic(void *kvaddr);
40extern void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); 40extern void *kmap_atomic_pfn(unsigned long pfn);
41extern struct page *kmap_atomic_to_page(const void *ptr); 41extern struct page *kmap_atomic_to_page(const void *ptr);
42#endif 42#endif
43 43
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/kgdb.h b/arch/arm/include/asm/kgdb.h
index 08265993227f..48066ce9ea34 100644
--- a/arch/arm/include/asm/kgdb.h
+++ b/arch/arm/include/asm/kgdb.h
@@ -70,7 +70,8 @@ extern int kgdb_fault_expected;
70#define _GP_REGS 16 70#define _GP_REGS 16
71#define _FP_REGS 8 71#define _FP_REGS 8
72#define _EXTRA_REGS 2 72#define _EXTRA_REGS 2
73#define DBG_MAX_REG_NUM (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS) 73#define GDB_MAX_REGS (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS)
74#define DBG_MAX_REG_NUM (_GP_REGS + _FP_REGS + _EXTRA_REGS)
74 75
75#define KGDB_MAX_NO_CPUS 1 76#define KGDB_MAX_NO_CPUS 1
76#define BUFMAX 400 77#define BUFMAX 400
@@ -93,7 +94,7 @@ extern int kgdb_fault_expected;
93#define _SPT 13 94#define _SPT 13
94#define _LR 14 95#define _LR 14
95#define _PC 15 96#define _PC 15
96#define _CPSR (DBG_MAX_REG_NUM - 1) 97#define _CPSR (GDB_MAX_REGS - 1)
97 98
98/* 99/*
99 * So that we can denote the end of a frame for tracing, 100 * So that we can denote the end of a frame for tracing,
diff --git a/arch/arm/include/asm/memblock.h b/arch/arm/include/asm/memblock.h
index fdbc43b2e6c0..b8da2e415e4e 100644
--- a/arch/arm/include/asm/memblock.h
+++ b/arch/arm/include/asm/memblock.h
@@ -1,13 +1,6 @@
1#ifndef _ASM_ARM_MEMBLOCK_H 1#ifndef _ASM_ARM_MEMBLOCK_H
2#define _ASM_ARM_MEMBLOCK_H 2#define _ASM_ARM_MEMBLOCK_H
3 3
4#ifdef CONFIG_MMU
5extern phys_addr_t lowmem_end_addr;
6#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
7#else
8#define MEMBLOCK_REAL_LIMIT 0
9#endif
10
11struct meminfo; 4struct meminfo;
12struct machine_desc; 5struct machine_desc;
13 6
diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
index 25f76bae57ab..fc1900925275 100644
--- a/arch/arm/include/asm/outercache.h
+++ b/arch/arm/include/asm/outercache.h
@@ -25,6 +25,9 @@ struct outer_cache_fns {
25 void (*inv_range)(unsigned long, unsigned long); 25 void (*inv_range)(unsigned long, unsigned long);
26 void (*clean_range)(unsigned long, unsigned long); 26 void (*clean_range)(unsigned long, unsigned long);
27 void (*flush_range)(unsigned long, unsigned long); 27 void (*flush_range)(unsigned long, unsigned long);
28 void (*flush_all)(void);
29 void (*inv_all)(void);
30 void (*disable)(void);
28#ifdef CONFIG_OUTER_CACHE_SYNC 31#ifdef CONFIG_OUTER_CACHE_SYNC
29 void (*sync)(void); 32 void (*sync)(void);
30#endif 33#endif
@@ -50,6 +53,24 @@ static inline void outer_flush_range(unsigned long start, unsigned long end)
50 outer_cache.flush_range(start, end); 53 outer_cache.flush_range(start, end);
51} 54}
52 55
56static inline void outer_flush_all(void)
57{
58 if (outer_cache.flush_all)
59 outer_cache.flush_all();
60}
61
62static inline void outer_inv_all(void)
63{
64 if (outer_cache.inv_all)
65 outer_cache.inv_all();
66}
67
68static inline void outer_disable(void)
69{
70 if (outer_cache.disable)
71 outer_cache.disable();
72}
73
53#else 74#else
54 75
55static inline void outer_inv_range(unsigned long start, unsigned long end) 76static inline void outer_inv_range(unsigned long start, unsigned long end)
@@ -58,6 +79,9 @@ static inline void outer_clean_range(unsigned long start, unsigned long end)
58{ } 79{ }
59static inline void outer_flush_range(unsigned long start, unsigned long end) 80static inline void outer_flush_range(unsigned long start, unsigned long end)
60{ } 81{ }
82static inline void outer_flush_all(void) { }
83static inline void outer_inv_all(void) { }
84static inline void outer_disable(void) { }
61 85
62#endif 86#endif
63 87
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index a9672e8406a3..b155414192da 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -263,17 +263,15 @@ extern struct page *empty_zero_page;
263#define pte_page(pte) (pfn_to_page(pte_pfn(pte))) 263#define pte_page(pte) (pfn_to_page(pte_pfn(pte)))
264#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr)) 264#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
265 265
266#define pte_offset_map(dir,addr) (__pte_map(dir, KM_PTE0) + __pte_index(addr)) 266#define pte_offset_map(dir,addr) (__pte_map(dir) + __pte_index(addr))
267#define pte_offset_map_nested(dir,addr) (__pte_map(dir, KM_PTE1) + __pte_index(addr)) 267#define pte_unmap(pte) __pte_unmap(pte)
268#define pte_unmap(pte) __pte_unmap(pte, KM_PTE0)
269#define pte_unmap_nested(pte) __pte_unmap(pte, KM_PTE1)
270 268
271#ifndef CONFIG_HIGHPTE 269#ifndef CONFIG_HIGHPTE
272#define __pte_map(dir,km) pmd_page_vaddr(*(dir)) 270#define __pte_map(dir) pmd_page_vaddr(*(dir))
273#define __pte_unmap(pte,km) do { } while (0) 271#define __pte_unmap(pte) do { } while (0)
274#else 272#else
275#define __pte_map(dir,km) ((pte_t *)kmap_atomic(pmd_page(*(dir)), km) + PTRS_PER_PTE) 273#define __pte_map(dir) ((pte_t *)kmap_atomic(pmd_page(*(dir))) + PTRS_PER_PTE)
276#define __pte_unmap(pte,km) kunmap_atomic((pte - PTRS_PER_PTE), km) 274#define __pte_unmap(pte) kunmap_atomic((pte - PTRS_PER_PTE))
277#endif 275#endif
278 276
279#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext) 277#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index a48d51257988..11db62806a1a 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -329,6 +329,7 @@ static const struct file_operations etb_fops = {
329 .read = etb_read, 329 .read = etb_read,
330 .open = etb_open, 330 .open = etb_open,
331 .release = etb_release, 331 .release = etb_release,
332 .llseek = no_llseek,
332}; 333};
333 334
334static struct miscdevice etb_miscdev = { 335static struct miscdevice etb_miscdev = {
diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
index 54593b0c241b..21e3a4ab3b8c 100644
--- a/arch/arm/kernel/hw_breakpoint.c
+++ b/arch/arm/kernel/hw_breakpoint.c
@@ -748,8 +748,7 @@ static int hw_breakpoint_pending(unsigned long addr, unsigned int fsr,
748 breakpoint_handler(addr, regs); 748 breakpoint_handler(addr, regs);
749 break; 749 break;
750 case ARM_ENTRY_ASYNC_WATCHPOINT: 750 case ARM_ENTRY_ASYNC_WATCHPOINT:
751 WARN_ON("Asynchronous watchpoint exception taken. " 751 WARN(1, "Asynchronous watchpoint exception taken. Debugging results may be unreliable\n");
752 "Debugging results may be unreliable");
753 case ARM_ENTRY_SYNC_WATCHPOINT: 752 case ARM_ENTRY_SYNC_WATCHPOINT:
754 watchpoint_handler(addr, regs); 753 watchpoint_handler(addr, regs);
755 break; 754 break;
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c
index d6e8b4d2e60d..778c2f7024ff 100644
--- a/arch/arm/kernel/kgdb.c
+++ b/arch/arm/kernel/kgdb.c
@@ -79,7 +79,7 @@ sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
79 return; 79 return;
80 80
81 /* Initialize to zero */ 81 /* Initialize to zero */
82 for (regno = 0; regno < DBG_MAX_REG_NUM; regno++) 82 for (regno = 0; regno < GDB_MAX_REGS; regno++)
83 gdb_regs[regno] = 0; 83 gdb_regs[regno] = 0;
84 84
85 /* Otherwise, we have only some registers from switch_to() */ 85 /* Otherwise, we have only some registers from switch_to() */
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 1fc74cbd1a19..3a8fd5140d7a 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -78,7 +78,10 @@ void machine_kexec(struct kimage *image)
78 local_fiq_disable(); 78 local_fiq_disable();
79 setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/ 79 setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
80 flush_cache_all(); 80 flush_cache_all();
81 outer_flush_all();
82 outer_disable();
81 cpu_proc_fin(); 83 cpu_proc_fin();
84 outer_inv_all();
82 flush_cache_all(); 85 flush_cache_all();
83 cpu_reset(reboot_code_buffer_phys); 86 cpu_reset(reboot_code_buffer_phys);
84} 87}
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 49643b1467e6..07a50357492a 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -1749,7 +1749,7 @@ static inline int armv7_pmnc_has_overflowed(unsigned long pmnc)
1749static inline int armv7_pmnc_counter_has_overflowed(unsigned long pmnc, 1749static inline int armv7_pmnc_counter_has_overflowed(unsigned long pmnc,
1750 enum armv7_counters counter) 1750 enum armv7_counters counter)
1751{ 1751{
1752 int ret; 1752 int ret = 0;
1753 1753
1754 if (counter == ARMV7_CYCLE_COUNTER) 1754 if (counter == ARMV7_CYCLE_COUNTER)
1755 ret = pmnc & ARMV7_FLAG_C; 1755 ret = pmnc & ARMV7_FLAG_C;
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index e0cb6370ed14..3e97483abcf0 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -1075,13 +1075,15 @@ out:
1075} 1075}
1076#endif 1076#endif
1077 1077
1078long arch_ptrace(struct task_struct *child, long request, long addr, long data) 1078long arch_ptrace(struct task_struct *child, long request,
1079 unsigned long addr, unsigned long data)
1079{ 1080{
1080 int ret; 1081 int ret;
1082 unsigned long __user *datap = (unsigned long __user *) data;
1081 1083
1082 switch (request) { 1084 switch (request) {
1083 case PTRACE_PEEKUSR: 1085 case PTRACE_PEEKUSR:
1084 ret = ptrace_read_user(child, addr, (unsigned long __user *)data); 1086 ret = ptrace_read_user(child, addr, datap);
1085 break; 1087 break;
1086 1088
1087 case PTRACE_POKEUSR: 1089 case PTRACE_POKEUSR:
@@ -1089,34 +1091,34 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1089 break; 1091 break;
1090 1092
1091 case PTRACE_GETREGS: 1093 case PTRACE_GETREGS:
1092 ret = ptrace_getregs(child, (void __user *)data); 1094 ret = ptrace_getregs(child, datap);
1093 break; 1095 break;
1094 1096
1095 case PTRACE_SETREGS: 1097 case PTRACE_SETREGS:
1096 ret = ptrace_setregs(child, (void __user *)data); 1098 ret = ptrace_setregs(child, datap);
1097 break; 1099 break;
1098 1100
1099 case PTRACE_GETFPREGS: 1101 case PTRACE_GETFPREGS:
1100 ret = ptrace_getfpregs(child, (void __user *)data); 1102 ret = ptrace_getfpregs(child, datap);
1101 break; 1103 break;
1102 1104
1103 case PTRACE_SETFPREGS: 1105 case PTRACE_SETFPREGS:
1104 ret = ptrace_setfpregs(child, (void __user *)data); 1106 ret = ptrace_setfpregs(child, datap);
1105 break; 1107 break;
1106 1108
1107#ifdef CONFIG_IWMMXT 1109#ifdef CONFIG_IWMMXT
1108 case PTRACE_GETWMMXREGS: 1110 case PTRACE_GETWMMXREGS:
1109 ret = ptrace_getwmmxregs(child, (void __user *)data); 1111 ret = ptrace_getwmmxregs(child, datap);
1110 break; 1112 break;
1111 1113
1112 case PTRACE_SETWMMXREGS: 1114 case PTRACE_SETWMMXREGS:
1113 ret = ptrace_setwmmxregs(child, (void __user *)data); 1115 ret = ptrace_setwmmxregs(child, datap);
1114 break; 1116 break;
1115#endif 1117#endif
1116 1118
1117 case PTRACE_GET_THREAD_AREA: 1119 case PTRACE_GET_THREAD_AREA:
1118 ret = put_user(task_thread_info(child)->tp_value, 1120 ret = put_user(task_thread_info(child)->tp_value,
1119 (unsigned long __user *) data); 1121 datap);
1120 break; 1122 break;
1121 1123
1122 case PTRACE_SET_SYSCALL: 1124 case PTRACE_SET_SYSCALL:
@@ -1126,21 +1128,21 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1126 1128
1127#ifdef CONFIG_CRUNCH 1129#ifdef CONFIG_CRUNCH
1128 case PTRACE_GETCRUNCHREGS: 1130 case PTRACE_GETCRUNCHREGS:
1129 ret = ptrace_getcrunchregs(child, (void __user *)data); 1131 ret = ptrace_getcrunchregs(child, datap);
1130 break; 1132 break;
1131 1133
1132 case PTRACE_SETCRUNCHREGS: 1134 case PTRACE_SETCRUNCHREGS:
1133 ret = ptrace_setcrunchregs(child, (void __user *)data); 1135 ret = ptrace_setcrunchregs(child, datap);
1134 break; 1136 break;
1135#endif 1137#endif
1136 1138
1137#ifdef CONFIG_VFP 1139#ifdef CONFIG_VFP
1138 case PTRACE_GETVFPREGS: 1140 case PTRACE_GETVFPREGS:
1139 ret = ptrace_getvfpregs(child, (void __user *)data); 1141 ret = ptrace_getvfpregs(child, datap);
1140 break; 1142 break;
1141 1143
1142 case PTRACE_SETVFPREGS: 1144 case PTRACE_SETVFPREGS:
1143 ret = ptrace_setvfpregs(child, (void __user *)data); 1145 ret = ptrace_setvfpregs(child, datap);
1144 break; 1146 break;
1145#endif 1147#endif
1146 1148
diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 20b7411e47fd..c2e112e1a05f 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -28,7 +28,7 @@ int notrace unwind_frame(struct stackframe *frame)
28 28
29 /* only go to a higher address on the stack */ 29 /* only go to a higher address on the stack */
30 low = frame->sp; 30 low = frame->sp;
31 high = ALIGN(low, THREAD_SIZE) + THREAD_SIZE; 31 high = ALIGN(low, THREAD_SIZE);
32 32
33 /* check current frame pointer is within bounds */ 33 /* check current frame pointer is within bounds */
34 if (fp < (low + 12) || fp + 4 >= high) 34 if (fp < (low + 12) || fp + 4 >= high)
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index cda78d59aa31..446aee97436f 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -53,10 +53,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
53void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) 53void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
54{ 54{
55#ifdef CONFIG_KALLSYMS 55#ifdef CONFIG_KALLSYMS
56 char sym1[KSYM_SYMBOL_LEN], sym2[KSYM_SYMBOL_LEN]; 56 printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
57 sprint_symbol(sym1, where);
58 sprint_symbol(sym2, from);
59 printk("[<%08lx>] (%s) from [<%08lx>] (%s)\n", where, sym1, from, sym2);
60#else 57#else
61 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from); 58 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
62#endif 59#endif
diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c
index 2a161765f6d5..d2cb0b3c9872 100644
--- a/arch/arm/kernel/unwind.c
+++ b/arch/arm/kernel/unwind.c
@@ -279,7 +279,7 @@ int unwind_frame(struct stackframe *frame)
279 279
280 /* only go to a higher address on the stack */ 280 /* only go to a higher address on the stack */
281 low = frame->sp; 281 low = frame->sp;
282 high = ALIGN(low, THREAD_SIZE) + THREAD_SIZE; 282 high = ALIGN(low, THREAD_SIZE);
283 283
284 pr_debug("%s(pc = %08lx lr = %08lx sp = %08lx)\n", __func__, 284 pr_debug("%s(pc = %08lx lr = %08lx sp = %08lx)\n", __func__,
285 frame->pc, frame->lr, frame->sp); 285 frame->pc, frame->lr, frame->sp);
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 1953e3d21abf..cead8893b46b 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -113,6 +113,7 @@ SECTIONS
113 *(.rodata.*) 113 *(.rodata.*)
114 *(.glue_7) 114 *(.glue_7)
115 *(.glue_7t) 115 *(.glue_7t)
116 . = ALIGN(4);
116 *(.got) /* Global offset table */ 117 *(.got) /* Global offset table */
117 ARM_CPU_KEEP(PROC_INFO) 118 ARM_CPU_KEEP(PROC_INFO)
118 } 119 }
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 851e8139ef9d..c015b684b4fe 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -109,7 +109,7 @@ config MACH_ONEARM
109 bool "Ajeco 1ARM Single Board Computer" 109 bool "Ajeco 1ARM Single Board Computer"
110 help 110 help
111 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.
112 <http://www.ajeco.fi/products.htm> 112 <http://www.ajeco.fi/>
113 113
114config ARCH_AT91RM9200DK 114config ARCH_AT91RM9200DK
115 bool "Atmel AT91RM9200-DK Development board" 115 bool "Atmel AT91RM9200-DK Development board"
@@ -141,7 +141,7 @@ config MACH_CARMEVA
141 bool "Conitec ARM&EVA" 141 bool "Conitec ARM&EVA"
142 help 142 help
143 Select this if you are using Conitec's AT91RM9200-MCU-Module. 143 Select this if you are using Conitec's AT91RM9200-MCU-Module.
144 <http://www.conitec.net/english/linuxboard.htm> 144 <http://www.conitec.net/english/linuxboard.php>
145 145
146config MACH_ATEB9200 146config MACH_ATEB9200
147 bool "Embest ATEB9200" 147 bool "Embest ATEB9200"
@@ -153,7 +153,7 @@ config MACH_KB9200
153 bool "KwikByte KB920x" 153 bool "KwikByte KB920x"
154 help 154 help
155 Select this if you are using KwikByte's KB920x board. 155 Select this if you are using KwikByte's KB920x board.
156 <http://kwikbyte.com/KB9202_description_new.htm> 156 <http://www.kwikbyte.com/KB9202.html>
157 157
158config MACH_PICOTUX2XX 158config MACH_PICOTUX2XX
159 bool "picotux 200" 159 bool "picotux 200"
@@ -375,6 +375,12 @@ config MACH_STAMP9G20
375 evaluation board. 375 evaluation board.
376 <http://www.taskit.de/en/> 376 <http://www.taskit.de/en/>
377 377
378config MACH_PCONTROL_G20
379 bool "PControl G20 CPU module"
380 help
381 Select this if you are using taskit's Stamp9G20 CPU module on this
382 carrier board, beeing the decentralized unit of a building automation
383 system; featuring nvram, eth-switch, iso-rs485, display, io
378endif 384endif
379 385
380if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) 386if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20)
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 412b3a471a4b..821eb842795f 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -11,12 +11,12 @@ obj-$(CONFIG_AT91_PMC_UNIT) += clock.o
11 11
12# CPU-specific support 12# CPU-specific support
13obj-$(CONFIG_ARCH_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o 13obj-$(CONFIG_ARCH_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
14obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o 14obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o
15obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o 15obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o
16obj-$(CONFIG_ARCH_AT91SAM9G10) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o 16obj-$(CONFIG_ARCH_AT91SAM9G10) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o
17obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o sam9_smc.o 17obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o sam9_smc.o at91sam9_alt_reset.o
18obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o 18obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o at91sam9_alt_reset.o
19obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o 19obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o
20obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o 20obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o
21obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o sam9_smc.o 21obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o sam9_smc.o
22obj-$(CONFIG_ARCH_AT572D940HF) += at572d940hf.o at91sam926x_time.o at572d940hf_devices.o sam9_smc.o 22obj-$(CONFIG_ARCH_AT572D940HF) += at572d940hf.o at91sam926x_time.o at572d940hf_devices.o sam9_smc.o
@@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.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
68obj-$(CONFIG_MACH_PCONTROL_G20) += board-pcontrol-g20.o
68 69
69# AT91SAM9260/AT91SAM9G20 board-specific support 70# AT91SAM9260/AT91SAM9G20 board-specific support
70obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o 71obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 0894f1077be7..195208b30024 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -279,11 +279,6 @@ static struct at91_gpio_bank at91sam9260_gpio[] = {
279 } 279 }
280}; 280};
281 281
282static void at91sam9260_reset(void)
283{
284 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
285}
286
287static void at91sam9260_poweroff(void) 282static void at91sam9260_poweroff(void)
288{ 283{
289 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); 284 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
@@ -327,7 +322,7 @@ void __init at91sam9260_initialize(unsigned long main_clock)
327 else 322 else
328 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); 323 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc));
329 324
330 at91_arch_reset = at91sam9260_reset; 325 at91_arch_reset = at91sam9_alt_reset;
331 pm_power_off = at91sam9260_poweroff; 326 pm_power_off = at91sam9260_poweroff;
332 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) 327 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
333 | (1 << AT91SAM9260_ID_IRQ2); 328 | (1 << AT91SAM9260_ID_IRQ2);
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 4ecf37996c77..fcad88668504 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -257,11 +257,6 @@ static struct at91_gpio_bank at91sam9261_gpio[] = {
257 } 257 }
258}; 258};
259 259
260static void at91sam9261_reset(void)
261{
262 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
263}
264
265static void at91sam9261_poweroff(void) 260static void at91sam9261_poweroff(void)
266{ 261{
267 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); 262 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
@@ -283,7 +278,7 @@ void __init at91sam9261_initialize(unsigned long main_clock)
283 iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc)); 278 iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc));
284 279
285 280
286 at91_arch_reset = at91sam9261_reset; 281 at91_arch_reset = at91sam9_alt_reset;
287 pm_power_off = at91sam9261_poweroff; 282 pm_power_off = at91sam9261_poweroff;
288 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) 283 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
289 | (1 << AT91SAM9261_ID_IRQ2); 284 | (1 << AT91SAM9261_ID_IRQ2);
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 942792d630d8..249f900954d8 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -269,11 +269,6 @@ static struct at91_gpio_bank at91sam9263_gpio[] = {
269 } 269 }
270}; 270};
271 271
272static void at91sam9263_reset(void)
273{
274 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
275}
276
277static void at91sam9263_poweroff(void) 272static void at91sam9263_poweroff(void)
278{ 273{
279 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); 274 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
@@ -289,7 +284,7 @@ void __init at91sam9263_initialize(unsigned long main_clock)
289 /* Map peripherals */ 284 /* Map peripherals */
290 iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc)); 285 iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc));
291 286
292 at91_arch_reset = at91sam9263_reset; 287 at91_arch_reset = at91sam9_alt_reset;
293 pm_power_off = at91sam9263_poweroff; 288 pm_power_off = at91sam9263_poweroff;
294 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1); 289 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
295 290
diff --git a/arch/arm/mach-at91/at91sam9_alt_reset.S b/arch/arm/mach-at91/at91sam9_alt_reset.S
new file mode 100644
index 000000000000..e0256deb91fb
--- /dev/null
+++ b/arch/arm/mach-at91/at91sam9_alt_reset.S
@@ -0,0 +1,48 @@
1/*
2 * reset AT91SAM9G20 as per errata
3 *
4 * (C) BitBox Ltd 2010
5 *
6 * unless the SDRAM is cleanly shutdown before we hit the
7 * reset register it can be left driving the data bus and
8 * killing the chance of a subsequent boot from NAND
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 as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#include <linux/linkage.h>
17#include <asm/system.h>
18#include <mach/hardware.h>
19#include <mach/at91sam9_sdramc.h>
20#include <mach/at91_rstc.h>
21
22 .arm
23
24 .globl at91sam9_alt_reset
25
26at91sam9_alt_reset: mrc p15, 0, r0, c1, c0, 0
27 orr r0, r0, #CR_I
28 mcr p15, 0, r0, c1, c0, 0 @ enable I-cache
29
30 ldr r0, .at91_va_base_sdramc @ preload constants
31 ldr r1, .at91_va_base_rstc_cr
32
33 mov r2, #1
34 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN
35 ldr r4, =AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST
36
37 .balign 32 @ align to cache line
38
39 str r2, [r0, #AT91_SDRAMC_TR] @ disable SDRAM access
40 str r3, [r0, #AT91_SDRAMC_LPR] @ power down SDRAM
41 str r4, [r1] @ reset processor
42
43 b .
44
45.at91_va_base_sdramc:
46 .word AT91_VA_BASE_SYS + AT91_SDRAMC0
47.at91_va_base_rstc_cr:
48 .word AT91_VA_BASE_SYS + AT91_RSTC_CR
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 1276babf84d5..1e8f275c17f6 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -15,6 +15,7 @@
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
18#include <linux/atmel-mci.h>
18 19
19#include <linux/fb.h> 20#include <linux/fb.h>
20#include <video/atmel_lcdc.h> 21#include <video/atmel_lcdc.h>
@@ -25,6 +26,7 @@
25#include <mach/at91sam9g45_matrix.h> 26#include <mach/at91sam9g45_matrix.h>
26#include <mach/at91sam9_smc.h> 27#include <mach/at91sam9_smc.h>
27#include <mach/at_hdmac.h> 28#include <mach/at_hdmac.h>
29#include <mach/atmel-mci.h>
28 30
29#include "generic.h" 31#include "generic.h"
30 32
@@ -350,6 +352,169 @@ void __init at91_add_device_eth(struct at91_eth_data *data) {}
350 352
351 353
352/* -------------------------------------------------------------------- 354/* --------------------------------------------------------------------
355 * MMC / SD
356 * -------------------------------------------------------------------- */
357
358#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
359static u64 mmc_dmamask = DMA_BIT_MASK(32);
360static struct mci_platform_data mmc0_data, mmc1_data;
361
362static struct resource mmc0_resources[] = {
363 [0] = {
364 .start = AT91SAM9G45_BASE_MCI0,
365 .end = AT91SAM9G45_BASE_MCI0 + SZ_16K - 1,
366 .flags = IORESOURCE_MEM,
367 },
368 [1] = {
369 .start = AT91SAM9G45_ID_MCI0,
370 .end = AT91SAM9G45_ID_MCI0,
371 .flags = IORESOURCE_IRQ,
372 },
373};
374
375static struct platform_device at91sam9g45_mmc0_device = {
376 .name = "atmel_mci",
377 .id = 0,
378 .dev = {
379 .dma_mask = &mmc_dmamask,
380 .coherent_dma_mask = DMA_BIT_MASK(32),
381 .platform_data = &mmc0_data,
382 },
383 .resource = mmc0_resources,
384 .num_resources = ARRAY_SIZE(mmc0_resources),
385};
386
387static struct resource mmc1_resources[] = {
388 [0] = {
389 .start = AT91SAM9G45_BASE_MCI1,
390 .end = AT91SAM9G45_BASE_MCI1 + SZ_16K - 1,
391 .flags = IORESOURCE_MEM,
392 },
393 [1] = {
394 .start = AT91SAM9G45_ID_MCI1,
395 .end = AT91SAM9G45_ID_MCI1,
396 .flags = IORESOURCE_IRQ,
397 },
398};
399
400static struct platform_device at91sam9g45_mmc1_device = {
401 .name = "atmel_mci",
402 .id = 1,
403 .dev = {
404 .dma_mask = &mmc_dmamask,
405 .coherent_dma_mask = DMA_BIT_MASK(32),
406 .platform_data = &mmc1_data,
407 },
408 .resource = mmc1_resources,
409 .num_resources = ARRAY_SIZE(mmc1_resources),
410};
411
412/* Consider only one slot : slot 0 */
413void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
414{
415
416 if (!data)
417 return;
418
419 /* Must have at least one usable slot */
420 if (!data->slot[0].bus_width)
421 return;
422
423#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
424 {
425 struct at_dma_slave *atslave;
426 struct mci_dma_data *alt_atslave;
427
428 alt_atslave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
429 atslave = &alt_atslave->sdata;
430
431 /* DMA slave channel configuration */
432 atslave->dma_dev = &at_hdmac_device.dev;
433 atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT;
434 atslave->cfg = ATC_FIFOCFG_HALFFIFO
435 | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW;
436 atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16;
437 if (mmc_id == 0) /* MCI0 */
438 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)
439 | ATC_DST_PER(AT_DMA_ID_MCI0);
440
441 else /* MCI1 */
442 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI1)
443 | ATC_DST_PER(AT_DMA_ID_MCI1);
444
445 data->dma_slave = alt_atslave;
446 }
447#endif
448
449
450 /* input/irq */
451 if (data->slot[0].detect_pin) {
452 at91_set_gpio_input(data->slot[0].detect_pin, 1);
453 at91_set_deglitch(data->slot[0].detect_pin, 1);
454 }
455 if (data->slot[0].wp_pin)
456 at91_set_gpio_input(data->slot[0].wp_pin, 1);
457
458 if (mmc_id == 0) { /* MCI0 */
459
460 /* CLK */
461 at91_set_A_periph(AT91_PIN_PA0, 0);
462
463 /* CMD */
464 at91_set_A_periph(AT91_PIN_PA1, 1);
465
466 /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
467 at91_set_A_periph(AT91_PIN_PA2, 1);
468 if (data->slot[0].bus_width == 4) {
469 at91_set_A_periph(AT91_PIN_PA3, 1);
470 at91_set_A_periph(AT91_PIN_PA4, 1);
471 at91_set_A_periph(AT91_PIN_PA5, 1);
472 if (data->slot[0].bus_width == 8) {
473 at91_set_A_periph(AT91_PIN_PA6, 1);
474 at91_set_A_periph(AT91_PIN_PA7, 1);
475 at91_set_A_periph(AT91_PIN_PA8, 1);
476 at91_set_A_periph(AT91_PIN_PA9, 1);
477 }
478 }
479
480 mmc0_data = *data;
481 at91_clock_associate("mci0_clk", &at91sam9g45_mmc0_device.dev, "mci_clk");
482 platform_device_register(&at91sam9g45_mmc0_device);
483
484 } else { /* MCI1 */
485
486 /* CLK */
487 at91_set_A_periph(AT91_PIN_PA31, 0);
488
489 /* CMD */
490 at91_set_A_periph(AT91_PIN_PA22, 1);
491
492 /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
493 at91_set_A_periph(AT91_PIN_PA23, 1);
494 if (data->slot[0].bus_width == 4) {
495 at91_set_A_periph(AT91_PIN_PA24, 1);
496 at91_set_A_periph(AT91_PIN_PA25, 1);
497 at91_set_A_periph(AT91_PIN_PA26, 1);
498 if (data->slot[0].bus_width == 8) {
499 at91_set_A_periph(AT91_PIN_PA27, 1);
500 at91_set_A_periph(AT91_PIN_PA28, 1);
501 at91_set_A_periph(AT91_PIN_PA29, 1);
502 at91_set_A_periph(AT91_PIN_PA30, 1);
503 }
504 }
505
506 mmc1_data = *data;
507 at91_clock_associate("mci1_clk", &at91sam9g45_mmc1_device.dev, "mci_clk");
508 platform_device_register(&at91sam9g45_mmc1_device);
509
510 }
511}
512#else
513void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
514#endif
515
516
517/* --------------------------------------------------------------------
353 * NAND / SmartMedia 518 * NAND / SmartMedia
354 * -------------------------------------------------------------------- */ 519 * -------------------------------------------------------------------- */
355 520
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 211c5c14a1e6..6a9d24e5ed8e 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -242,11 +242,6 @@ static struct at91_gpio_bank at91sam9rl_gpio[] = {
242 } 242 }
243}; 243};
244 244
245static void at91sam9rl_reset(void)
246{
247 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
248}
249
250static void at91sam9rl_poweroff(void) 245static void at91sam9rl_poweroff(void)
251{ 246{
252 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW); 247 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
@@ -281,7 +276,7 @@ void __init at91sam9rl_initialize(unsigned long main_clock)
281 /* Map SRAM */ 276 /* Map SRAM */
282 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc)); 277 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc));
283 278
284 at91_arch_reset = at91sam9rl_reset; 279 at91_arch_reset = at91sam9_alt_reset;
285 pm_power_off = at91sam9rl_poweroff; 280 pm_power_off = at91sam9rl_poweroff;
286 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0); 281 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
287 282
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
new file mode 100644
index 000000000000..bba5a560e02b
--- /dev/null
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -0,0 +1,322 @@
1/*
2 * Copyright (C) 2010 Christian Glindkamp <christian.glindkamp@taskit.de>
3 * taskit GmbH
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19/*
20 * copied and adjusted from board-stamp9g20.c
21 * by Peter Gsellmann <pgsellmann@portner-elektronik.at>
22 */
23
24#include <linux/mm.h>
25#include <linux/platform_device.h>
26#include <linux/gpio.h>
27#include <linux/w1-gpio.h>
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31
32#include <mach/board.h>
33#include <mach/at91sam9_smc.h>
34
35#include "sam9_smc.h"
36#include "generic.h"
37
38
39static void __init pcontrol_g20_map_io(void)
40{
41 /* Initialize processor: 18.432 MHz crystal */
42 at91sam9260_initialize(18432000);
43
44 /* DGBU on ttyS0. (Rx, Tx) only TTL -> JTAG connector X7 17,19 ) */
45 at91_register_uart(0, 0, 0);
46
47 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */
48 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
49 | ATMEL_UART_RTS);
50
51 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485 X5 */
52 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS
53 | ATMEL_UART_RTS);
54
55 /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */
56 at91_register_uart(AT91SAM9260_ID_US4, 3, 0);
57
58 /* set serial console to ttyS0 (ie, DBGU) */
59 at91_set_serial_console(0);
60}
61
62
63static void __init init_irq(void)
64{
65 at91sam9260_init_interrupts(NULL);
66}
67
68
69/*
70 * NAND flash 512MiB 1,8V 8-bit, sector size 128 KiB
71 */
72static struct atmel_nand_data __initdata nand_data = {
73 .ale = 21,
74 .cle = 22,
75 .rdy_pin = AT91_PIN_PC13,
76 .enable_pin = AT91_PIN_PC14,
77};
78
79/*
80 * Bus timings; unit = 7.57ns
81 */
82static struct sam9_smc_config __initdata nand_smc_config = {
83 .ncs_read_setup = 0,
84 .nrd_setup = 2,
85 .ncs_write_setup = 0,
86 .nwe_setup = 2,
87
88 .ncs_read_pulse = 4,
89 .nrd_pulse = 4,
90 .ncs_write_pulse = 4,
91 .nwe_pulse = 4,
92
93 .read_cycle = 7,
94 .write_cycle = 7,
95
96 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
97 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
98 .tdf_cycles = 3,
99};
100
101static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
102 .ncs_read_setup = 16,
103 .nrd_setup = 18,
104 .ncs_write_setup = 16,
105 .nwe_setup = 18,
106
107 .ncs_read_pulse = 63,
108 .nrd_pulse = 55,
109 .ncs_write_pulse = 63,
110 .nwe_pulse = 55,
111
112 .read_cycle = 127,
113 .write_cycle = 127,
114
115 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
116 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT
117 | AT91_SMC_DBW_8 | AT91_SMC_PS_4
118 | AT91_SMC_TDFMODE,
119 .tdf_cycles = 3,
120}, {
121 .ncs_read_setup = 0,
122 .nrd_setup = 0,
123 .ncs_write_setup = 0,
124 .nwe_setup = 1,
125
126 .ncs_read_pulse = 8,
127 .nrd_pulse = 8,
128 .ncs_write_pulse = 5,
129 .nwe_pulse = 4,
130
131 .read_cycle = 8,
132 .write_cycle = 7,
133
134 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE
135 | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_SELECT
136 | AT91_SMC_DBW_16 | AT91_SMC_PS_8
137 | AT91_SMC_TDFMODE,
138 .tdf_cycles = 1,
139} };
140
141static void __init add_device_nand(void)
142{
143 /* configure chip-select 3 (NAND) */
144 sam9_smc_configure(3, &nand_smc_config);
145 at91_add_device_nand(&nand_data);
146}
147
148
149static void __init add_device_pcontrol(void)
150{
151 /* configure chip-select 4 (IO compatible to 8051 X4 ) */
152 sam9_smc_configure(4, &pcontrol_smc_config[0]);
153 /* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A D4 ) */
154 sam9_smc_configure(7, &pcontrol_smc_config[1]);
155}
156
157
158/*
159 * MCI (SD/MMC)
160 * det_pin, wp_pin and vcc_pin are not connected
161 */
162#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
163static struct mci_platform_data __initdata mmc_data = {
164 .slot[0] = {
165 .bus_width = 4,
166 },
167};
168#else
169static struct at91_mmc_data __initdata mmc_data = {
170 .wire4 = 1,
171};
172#endif
173
174
175/*
176 * USB Host port
177 */
178static struct at91_usbh_data __initdata usbh_data = {
179 .ports = 2,
180};
181
182
183/*
184 * USB Device port
185 */
186static struct at91_udc_data __initdata pcontrol_g20_udc_data = {
187 .vbus_pin = AT91_PIN_PA22, /* Detect +5V bus voltage */
188 .pullup_pin = AT91_PIN_PA4, /* K-state, active low */
189};
190
191
192/*
193 * MACB Ethernet device
194 */
195static struct at91_eth_data __initdata macb_data = {
196 .phy_irq_pin = AT91_PIN_PA28,
197 .is_rmii = 1,
198};
199
200
201/*
202 * I2C devices: eeprom and phy/switch
203 */
204static struct i2c_board_info __initdata pcontrol_g20_i2c_devices[] = {
205{ /* D7 address width=2, 8KiB */
206 I2C_BOARD_INFO("24c64", 0x50)
207}, { /* D8 address width=1, 1 byte has 32 bits! */
208 I2C_BOARD_INFO("lan9303", 0x0a)
209}, };
210
211
212/*
213 * LEDs
214 */
215static struct gpio_led pcontrol_g20_leds[] = {
216 {
217 .name = "LED1", /* red H5 */
218 .gpio = AT91_PIN_PB18,
219 .active_low = 1,
220 .default_trigger = "none", /* supervisor */
221 }, {
222 .name = "LED2", /* yellow H7 */
223 .gpio = AT91_PIN_PB19,
224 .active_low = 1,
225 .default_trigger = "mmc0", /* SD-card activity */
226 }, {
227 .name = "LED3", /* green H2 */
228 .gpio = AT91_PIN_PB20,
229 .active_low = 1,
230 .default_trigger = "heartbeat", /* blinky */
231 }, {
232 .name = "LED4", /* red H3 */
233 .gpio = AT91_PIN_PC6,
234 .active_low = 1,
235 .default_trigger = "none", /* connection lost */
236 }, {
237 .name = "LED5", /* yellow H6 */
238 .gpio = AT91_PIN_PC7,
239 .active_low = 1,
240 .default_trigger = "none", /* unsent data */
241 }, {
242 .name = "LED6", /* green H1 */
243 .gpio = AT91_PIN_PC9,
244 .active_low = 1,
245 .default_trigger = "none", /* snafu */
246 }
247};
248
249
250/*
251 * SPI devices
252 */
253static struct spi_board_info pcontrol_g20_spi_devices[] = {
254 {
255 .modalias = "spidev", /* HMI port X4 */
256 .chip_select = 1,
257 .max_speed_hz = 50 * 1000 * 1000,
258 .bus_num = 0,
259 }, {
260 .modalias = "spidev", /* piggyback A2 */
261 .chip_select = 0,
262 .max_speed_hz = 50 * 1000 * 1000,
263 .bus_num = 1,
264 },
265};
266
267
268/*
269 * Dallas 1-Wire DS2431
270 */
271static struct w1_gpio_platform_data w1_gpio_pdata = {
272 .pin = AT91_PIN_PA29,
273 .is_open_drain = 1,
274};
275
276static struct platform_device w1_device = {
277 .name = "w1-gpio",
278 .id = -1,
279 .dev.platform_data = &w1_gpio_pdata,
280};
281
282static void add_wire1(void)
283{
284 at91_set_GPIO_periph(w1_gpio_pdata.pin, 1);
285 at91_set_multi_drive(w1_gpio_pdata.pin, 1);
286 platform_device_register(&w1_device);
287}
288
289
290static void __init pcontrol_g20_board_init(void)
291{
292 at91_add_device_serial();
293 add_device_nand();
294#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
295 at91_add_device_mci(0, &mmc_data);
296#else
297 at91_add_device_mmc(0, &mmc_data);
298#endif
299 at91_add_device_usbh(&usbh_data);
300 at91_add_device_eth(&macb_data);
301 at91_add_device_i2c(pcontrol_g20_i2c_devices,
302 ARRAY_SIZE(pcontrol_g20_i2c_devices));
303 add_wire1();
304 add_device_pcontrol();
305 at91_add_device_spi(pcontrol_g20_spi_devices,
306 ARRAY_SIZE(pcontrol_g20_spi_devices));
307 at91_add_device_udc(&pcontrol_g20_udc_data);
308 at91_gpio_leds(pcontrol_g20_leds,
309 ARRAY_SIZE(pcontrol_g20_leds));
310 /* piggyback A2 */
311 at91_set_gpio_output(AT91_PIN_PB31, 1);
312}
313
314
315MACHINE_START(PCONTROL_G20, "PControl G20")
316 /* Maintainer: pgsellmann@portner-elektronik.at */
317 .boot_params = AT91_SDRAM_BASE + 0x100,
318 .timer = &at91sam926x_timer,
319 .map_io = pcontrol_g20_map_io,
320 .init_irq = init_irq,
321 .init_machine = pcontrol_g20_board_init,
322MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index 7913984f6de9..86ff4b52db32 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -24,7 +24,9 @@
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/leds.h> 25#include <linux/leds.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/atmel-mci.h>
27 28
29#include <mach/hardware.h>
28#include <video/atmel_lcdc.h> 30#include <video/atmel_lcdc.h>
29 31
30#include <asm/setup.h> 32#include <asm/setup.h>
@@ -98,6 +100,25 @@ static struct spi_board_info ek_spi_devices[] = {
98 100
99 101
100/* 102/*
103 * MCI (SD/MMC)
104 */
105static struct mci_platform_data __initdata mci0_data = {
106 .slot[0] = {
107 .bus_width = 4,
108 .detect_pin = AT91_PIN_PD10,
109 },
110};
111
112static struct mci_platform_data __initdata mci1_data = {
113 .slot[0] = {
114 .bus_width = 4,
115 .detect_pin = AT91_PIN_PD11,
116 .wp_pin = AT91_PIN_PD29,
117 },
118};
119
120
121/*
101 * MACB Ethernet device 122 * MACB Ethernet device
102 */ 123 */
103static struct at91_eth_data __initdata ek_macb_data = { 124static struct at91_eth_data __initdata ek_macb_data = {
@@ -380,6 +401,9 @@ static void __init ek_board_init(void)
380 at91_add_device_usba(&ek_usba_udc_data); 401 at91_add_device_usba(&ek_usba_udc_data);
381 /* SPI */ 402 /* SPI */
382 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); 403 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
404 /* MMC */
405 at91_add_device_mci(0, &mci0_data);
406 at91_add_device_mci(1, &mci1_data);
383 /* Ethernet */ 407 /* Ethernet */
384 at91_add_device_eth(&ek_macb_data); 408 at91_add_device_eth(&ek_macb_data);
385 /* NAND */ 409 /* NAND */
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 65c3dc5ba0d0..0c66deb2db39 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -46,6 +46,9 @@ extern void __init at91_clock_associate(const char *id, struct device *dev, cons
46extern void at91_irq_suspend(void); 46extern void at91_irq_suspend(void);
47extern void at91_irq_resume(void); 47extern void at91_irq_resume(void);
48 48
49/* reset */
50extern void at91sam9_alt_reset(void);
51
49 /* GPIO */ 52 /* GPIO */
50#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */ 53#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */
51#define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */ 54#define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 615668986480..dafbacc25eb1 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -258,16 +258,23 @@ static int at91_pm_enter(suspend_state_t state)
258 * NOTE: the Wait-for-Interrupt instruction needs to be 258 * NOTE: the Wait-for-Interrupt instruction needs to be
259 * in icache so no SDRAM accesses are needed until the 259 * in icache so no SDRAM accesses are needed until the
260 * wakeup IRQ occurs and self-refresh is terminated. 260 * wakeup IRQ occurs and self-refresh is terminated.
261 * For ARM 926 based chips, this requirement is weaker
262 * as at91sam9 can access a RAM in self-refresh mode.
261 */ 263 */
262 asm("b 1f; .align 5; 1:"); 264 asm volatile ( "mov r0, #0\n\t"
263 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ 265 "b 1f\n\t"
266 ".align 5\n\t"
267 "1: mcr p15, 0, r0, c7, c10, 4\n\t"
268 : /* no output */
269 : /* no input */
270 : "r0");
264 saved_lpr = sdram_selfrefresh_enable(); 271 saved_lpr = sdram_selfrefresh_enable();
265 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */ 272 wait_for_interrupt_enable();
266 sdram_selfrefresh_disable(saved_lpr); 273 sdram_selfrefresh_disable(saved_lpr);
267 break; 274 break;
268 275
269 case PM_SUSPEND_ON: 276 case PM_SUSPEND_ON:
270 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */ 277 cpu_do_idle();
271 break; 278 break;
272 279
273 default: 280 default:
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 8c87d0c1b8f8..ce9a20699111 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -21,6 +21,8 @@ static inline u32 sdram_selfrefresh_enable(void)
21} 21}
22 22
23#define sdram_selfrefresh_disable(saved_lpr) at91_sys_write(AT91_SDRAMC_LPR, saved_lpr) 23#define sdram_selfrefresh_disable(saved_lpr) at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
24#define wait_for_interrupt_enable() asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
25 : : "r" (0))
24 26
25#elif defined(CONFIG_ARCH_AT91CAP9) 27#elif defined(CONFIG_ARCH_AT91CAP9)
26#include <mach/at91cap9_ddrsdr.h> 28#include <mach/at91cap9_ddrsdr.h>
@@ -38,6 +40,7 @@ static inline u32 sdram_selfrefresh_enable(void)
38} 40}
39 41
40#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr) 42#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
43#define wait_for_interrupt_enable() cpu_do_idle()
41 44
42#elif defined(CONFIG_ARCH_AT91SAM9G45) 45#elif defined(CONFIG_ARCH_AT91SAM9G45)
43#include <mach/at91sam9_ddrsdr.h> 46#include <mach/at91sam9_ddrsdr.h>
@@ -74,6 +77,7 @@ static inline u32 sdram_selfrefresh_enable(void)
74 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \ 77 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
75 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \ 78 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
76 } while (0) 79 } while (0)
80#define wait_for_interrupt_enable() cpu_do_idle()
77 81
78#else 82#else
79#include <mach/at91sam9_sdramc.h> 83#include <mach/at91sam9_sdramc.h>
@@ -98,5 +102,6 @@ static inline u32 sdram_selfrefresh_enable(void)
98} 102}
99 103
100#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr) 104#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
105#define wait_for_interrupt_enable() cpu_do_idle()
101 106
102#endif 107#endif
diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
index b6b00a1f6125..f7922a436172 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -124,6 +124,7 @@ ENTRY(at91_slow_clock)
124 ldr r5, .at91_va_base_ramc1 124 ldr r5, .at91_va_base_ramc1
125 125
126 /* Drain write buffer */ 126 /* Drain write buffer */
127 mov r0, #0
127 mcr p15, 0, r0, c7, c10, 4 128 mcr p15, 0, r0, c7, c10, 4
128 129
129#ifdef CONFIG_ARCH_AT91RM9200 130#ifdef CONFIG_ARCH_AT91RM9200
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 71f90f864748..b77b860b36d7 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -20,23 +20,23 @@ config ARCH_DAVINCI_DM644x
20 select ARCH_DAVINCI_DMx 20 select ARCH_DAVINCI_DMx
21 21
22config ARCH_DAVINCI_DM355 22config ARCH_DAVINCI_DM355
23 bool "DaVinci 355 based system" 23 bool "DaVinci 355 based system"
24 select AINTC 24 select AINTC
25 select ARCH_DAVINCI_DMx 25 select ARCH_DAVINCI_DMx
26 26
27config ARCH_DAVINCI_DM646x 27config ARCH_DAVINCI_DM646x
28 bool "DaVinci 646x based system" 28 bool "DaVinci 646x based system"
29 select AINTC 29 select AINTC
30 select ARCH_DAVINCI_DMx 30 select ARCH_DAVINCI_DMx
31 31
32config ARCH_DAVINCI_DA830 32config ARCH_DAVINCI_DA830
33 bool "DA830/OMAP-L137 based system" 33 bool "DA830/OMAP-L137/AM17x based system"
34 select CP_INTC 34 select CP_INTC
35 select ARCH_DAVINCI_DA8XX 35 select ARCH_DAVINCI_DA8XX
36 select CPU_DCACHE_WRITETHROUGH # needed on silicon revs 1.0, 1.1 36 select CPU_DCACHE_WRITETHROUGH # needed on silicon revs 1.0, 1.1
37 37
38config ARCH_DAVINCI_DA850 38config ARCH_DAVINCI_DA850
39 bool "DA850/OMAP-L138 based system" 39 bool "DA850/OMAP-L138/AM18x based system"
40 select CP_INTC 40 select CP_INTC
41 select ARCH_DAVINCI_DA8XX 41 select ARCH_DAVINCI_DA8XX
42 select ARCH_HAS_CPUFREQ 42 select ARCH_HAS_CPUFREQ
@@ -115,21 +115,21 @@ config MACH_DAVINCI_DM365_EVM
115 for development is a DM365 EVM 115 for development is a DM365 EVM
116 116
117config MACH_DAVINCI_DA830_EVM 117config MACH_DAVINCI_DA830_EVM
118 bool "TI DA830/OMAP-L137 Reference Platform" 118 bool "TI DA830/OMAP-L137/AM17x Reference Platform"
119 default ARCH_DAVINCI_DA830 119 default ARCH_DAVINCI_DA830
120 depends on ARCH_DAVINCI_DA830 120 depends on ARCH_DAVINCI_DA830
121 select GPIO_PCF857X 121 select GPIO_PCF857X
122 help 122 help
123 Say Y here to select the TI DA830/OMAP-L137 Evaluation Module. 123 Say Y here to select the TI DA830/OMAP-L137/AM17x Evaluation Module.
124 124
125choice 125choice
126 prompt "Select DA830/OMAP-L137 UI board peripheral" 126 prompt "Select DA830/OMAP-L137/AM17x UI board peripheral"
127 depends on MACH_DAVINCI_DA830_EVM 127 depends on MACH_DAVINCI_DA830_EVM
128 help 128 help
129 The presence of UI card on the DA830/OMAP-L137 EVM is detected 129 The presence of UI card on the DA830/OMAP-L137/AM17x EVM is
130 automatically based on successful probe of the I2C based GPIO 130 detected automatically based on successful probe of the I2C
131 expander on that board. This option selected in this menu has 131 based GPIO expander on that board. This option selected in this
132 an effect only in case of a successful UI card detection. 132 menu has an effect only in case of a successful UI card detection.
133 133
134config DA830_UI_LCD 134config DA830_UI_LCD
135 bool "LCD" 135 bool "LCD"
@@ -140,23 +140,23 @@ config DA830_UI_LCD
140config DA830_UI_NAND 140config DA830_UI_NAND
141 bool "NAND flash" 141 bool "NAND flash"
142 help 142 help
143 Say Y here to use the NAND flash. Do not forget to setup 143 Say Y here to use the NAND flash. Do not forget to setup
144 the switch correctly. 144 the switch correctly.
145endchoice 145endchoice
146 146
147config MACH_DAVINCI_DA850_EVM 147config MACH_DAVINCI_DA850_EVM
148 bool "TI DA850/OMAP-L138 Reference Platform" 148 bool "TI DA850/OMAP-L138/AM18x Reference Platform"
149 default ARCH_DAVINCI_DA850 149 default ARCH_DAVINCI_DA850
150 depends on ARCH_DAVINCI_DA850 150 depends on ARCH_DAVINCI_DA850
151 select GPIO_PCA953X 151 select GPIO_PCA953X
152 help 152 help
153 Say Y here to select the TI DA850/OMAP-L138 Evaluation Module. 153 Say Y here to select the TI DA850/OMAP-L138/AM18x Evaluation Module.
154 154
155choice 155choice
156 prompt "Select peripherals connected to expander on UI board" 156 prompt "Select peripherals connected to expander on UI board"
157 depends on MACH_DAVINCI_DA850_EVM 157 depends on MACH_DAVINCI_DA850_EVM
158 help 158 help
159 The presence of User Interface (UI) card on the DA850/OMAP-L138 159 The presence of User Interface (UI) card on the DA850/OMAP-L138/AM18x
160 EVM is detected automatically based on successful probe of the I2C 160 EVM is detected automatically based on successful probe of the I2C
161 based GPIO expander on that card. This option selected in this 161 based GPIO expander on that card. This option selected in this
162 menu has an effect only in case of a successful UI card detection. 162 menu has an effect only in case of a successful UI card detection.
@@ -165,13 +165,13 @@ config DA850_UI_NONE
165 bool "No peripheral is enabled" 165 bool "No peripheral is enabled"
166 help 166 help
167 Say Y if you do not want to enable any of the peripherals connected 167 Say Y if you do not want to enable any of the peripherals connected
168 to TCA6416 expander on DA850/OMAP-L138 EVM UI card 168 to TCA6416 expander on DA850/OMAP-L138/AM18x EVM UI card
169 169
170config DA850_UI_RMII 170config DA850_UI_RMII
171 bool "RMII Ethernet PHY" 171 bool "RMII Ethernet PHY"
172 help 172 help
173 Say Y if you want to use the RMII PHY on the DA850/OMAP-L138 EVM. 173 Say Y if you want to use the RMII PHY on the DA850/OMAP-L138/AM18x
174 This PHY is found on the UI daughter card that is supplied with 174 EVM. This PHY is found on the UI daughter card that is supplied with
175 the EVM. 175 the EVM.
176 NOTE: Please take care while choosing this option, MII PHY will 176 NOTE: Please take care while choosing this option, MII PHY will
177 not be functional if RMII mode is selected. 177 not be functional if RMII mode is selected.
@@ -185,6 +185,22 @@ config MACH_TNETV107X
185 help 185 help
186 Say Y here to select the TI TNETV107X Evaluation Module. 186 Say Y here to select the TI TNETV107X Evaluation Module.
187 187
188config MACH_MITYOMAPL138
189 bool "Critical Link MityDSP-L138/MityARM-1808 SoM"
190 depends on ARCH_DAVINCI_DA850
191 help
192 Say Y here to select the Critical Link MityDSP-L138/MityARM-1808
193 System on Module. Information on this SoM may be found at
194 http://www.mitydsp.com
195
196config MACH_OMAPL138_HAWKBOARD
197 bool "TI AM1808 / OMAPL-138 Hawkboard platform"
198 depends on ARCH_DAVINCI_DA850
199 help
200 Say Y here to select the TI AM1808 / OMAPL-138 Hawkboard platform .
201 Information of this board may be found at
202 http://www.hawkboard.org/
203
188config DAVINCI_MUX 204config DAVINCI_MUX
189 bool "DAVINCI multiplexing support" 205 bool "DAVINCI multiplexing support"
190 depends on ARCH_DAVINCI 206 depends on ARCH_DAVINCI
@@ -195,20 +211,20 @@ config DAVINCI_MUX
195 say Y. 211 say Y.
196 212
197config DAVINCI_MUX_DEBUG 213config DAVINCI_MUX_DEBUG
198 bool "Multiplexing debug output" 214 bool "Multiplexing debug output"
199 depends on DAVINCI_MUX 215 depends on DAVINCI_MUX
200 help 216 help
201 Makes the multiplexing functions print out a lot of debug info. 217 Makes the multiplexing functions print out a lot of debug info.
202 This is useful if you want to find out the correct values of the 218 This is useful if you want to find out the correct values of the
203 multiplexing registers. 219 multiplexing registers.
204 220
205config DAVINCI_MUX_WARNINGS 221config DAVINCI_MUX_WARNINGS
206 bool "Warn about pins the bootloader didn't set up" 222 bool "Warn about pins the bootloader didn't set up"
207 depends on DAVINCI_MUX 223 depends on DAVINCI_MUX
208 help 224 help
209 Choose Y here to warn whenever driver initialization logic needs 225 Choose Y here to warn whenever driver initialization logic needs
210 to change the pin multiplexing setup. When there are no warnings 226 to change the pin multiplexing setup. When there are no warnings
211 printed, it's safe to deselect DAVINCI_MUX for your product. 227 printed, it's safe to deselect DAVINCI_MUX for your product.
212 228
213config DAVINCI_RESET_CLOCKS 229config DAVINCI_RESET_CLOCKS
214 bool "Reset unused clocks during boot" 230 bool "Reset unused clocks during boot"
diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index eab4c0fd667a..0b87a1ca2bb3 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -5,7 +5,7 @@
5 5
6# Common objects 6# Common objects
7obj-y := time.o clock.o serial.o io.o psc.o \ 7obj-y := time.o clock.o serial.o io.o psc.o \
8 gpio.o dma.o usb.o common.o sram.o 8 gpio.o dma.o usb.o common.o sram.o aemif.o
9 9
10obj-$(CONFIG_DAVINCI_MUX) += mux.o 10obj-$(CONFIG_DAVINCI_MUX) += mux.o
11 11
@@ -33,6 +33,8 @@ obj-$(CONFIG_MACH_DAVINCI_DM365_EVM) += board-dm365-evm.o
33obj-$(CONFIG_MACH_DAVINCI_DA830_EVM) += board-da830-evm.o 33obj-$(CONFIG_MACH_DAVINCI_DA830_EVM) += board-da830-evm.o
34obj-$(CONFIG_MACH_DAVINCI_DA850_EVM) += board-da850-evm.o 34obj-$(CONFIG_MACH_DAVINCI_DA850_EVM) += board-da850-evm.o
35obj-$(CONFIG_MACH_TNETV107X) += board-tnetv107x-evm.o 35obj-$(CONFIG_MACH_TNETV107X) += board-tnetv107x-evm.o
36obj-$(CONFIG_MACH_MITYOMAPL138) += board-mityomapl138.o
37obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD) += board-omapl138-hawk.o
36 38
37# Power Management 39# Power Management
38obj-$(CONFIG_CPU_FREQ) += cpufreq.o 40obj-$(CONFIG_CPU_FREQ) += cpufreq.o
diff --git a/arch/arm/mach-davinci/aemif.c b/arch/arm/mach-davinci/aemif.c
new file mode 100644
index 000000000000..9c3f500fc12f
--- /dev/null
+++ b/arch/arm/mach-davinci/aemif.c
@@ -0,0 +1,133 @@
1/*
2 * AEMIF support for DaVinci SoCs
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated. http://www.ti.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/io.h>
13#include <linux/err.h>
14#include <linux/clk.h>
15#include <linux/module.h>
16#include <linux/time.h>
17
18#include <mach/aemif.h>
19
20/* Timing value configuration */
21
22#define TA(x) ((x) << 2)
23#define RHOLD(x) ((x) << 4)
24#define RSTROBE(x) ((x) << 7)
25#define RSETUP(x) ((x) << 13)
26#define WHOLD(x) ((x) << 17)
27#define WSTROBE(x) ((x) << 20)
28#define WSETUP(x) ((x) << 26)
29
30#define TA_MAX 0x3
31#define RHOLD_MAX 0x7
32#define RSTROBE_MAX 0x3f
33#define RSETUP_MAX 0xf
34#define WHOLD_MAX 0x7
35#define WSTROBE_MAX 0x3f
36#define WSETUP_MAX 0xf
37
38#define TIMING_MASK (TA(TA_MAX) | \
39 RHOLD(RHOLD_MAX) | \
40 RSTROBE(RSTROBE_MAX) | \
41 RSETUP(RSETUP_MAX) | \
42 WHOLD(WHOLD_MAX) | \
43 WSTROBE(WSTROBE_MAX) | \
44 WSETUP(WSETUP_MAX))
45
46/*
47 * aemif_calc_rate - calculate timing data.
48 * @wanted: The cycle time needed in nanoseconds.
49 * @clk: The input clock rate in kHz.
50 * @max: The maximum divider value that can be programmed.
51 *
52 * On success, returns the calculated timing value minus 1 for easy
53 * programming into AEMIF timing registers, else negative errno.
54 */
55static int aemif_calc_rate(int wanted, unsigned long clk, int max)
56{
57 int result;
58
59 result = DIV_ROUND_UP((wanted * clk), NSEC_PER_MSEC) - 1;
60
61 pr_debug("%s: result %d from %ld, %d\n", __func__, result, clk, wanted);
62
63 /* It is generally OK to have a more relaxed timing than requested... */
64 if (result < 0)
65 result = 0;
66
67 /* ... But configuring tighter timings is not an option. */
68 else if (result > max)
69 result = -EINVAL;
70
71 return result;
72}
73
74/**
75 * davinci_aemif_setup_timing - setup timing values for a given AEMIF interface
76 * @t: timing values to be progammed
77 * @base: The virtual base address of the AEMIF interface
78 * @cs: chip-select to program the timing values for
79 *
80 * This function programs the given timing values (in real clock) into the
81 * AEMIF registers taking the AEMIF clock into account.
82 *
83 * This function does not use any locking while programming the AEMIF
84 * because it is expected that there is only one user of a given
85 * chip-select.
86 *
87 * Returns 0 on success, else negative errno.
88 */
89int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,
90 void __iomem *base, unsigned cs)
91{
92 unsigned set, val;
93 unsigned ta, rhold, rstrobe, rsetup, whold, wstrobe, wsetup;
94 unsigned offset = A1CR_OFFSET + cs * 4;
95 struct clk *aemif_clk;
96 unsigned long clkrate;
97
98 if (!t)
99 return 0; /* Nothing to do */
100
101 aemif_clk = clk_get(NULL, "aemif");
102 if (IS_ERR(aemif_clk))
103 return PTR_ERR(aemif_clk);
104
105 clkrate = clk_get_rate(aemif_clk);
106
107 clkrate /= 1000; /* turn clock into kHz for ease of use */
108
109 ta = aemif_calc_rate(t->ta, clkrate, TA_MAX);
110 rhold = aemif_calc_rate(t->rhold, clkrate, RHOLD_MAX);
111 rstrobe = aemif_calc_rate(t->rstrobe, clkrate, RSTROBE_MAX);
112 rsetup = aemif_calc_rate(t->rsetup, clkrate, RSETUP_MAX);
113 whold = aemif_calc_rate(t->whold, clkrate, WHOLD_MAX);
114 wstrobe = aemif_calc_rate(t->wstrobe, clkrate, WSTROBE_MAX);
115 wsetup = aemif_calc_rate(t->wsetup, clkrate, WSETUP_MAX);
116
117 if (ta < 0 || rhold < 0 || rstrobe < 0 || rsetup < 0 ||
118 whold < 0 || wstrobe < 0 || wsetup < 0) {
119 pr_err("%s: cannot get suitable timings\n", __func__);
120 return -EINVAL;
121 }
122
123 set = TA(ta) | RHOLD(rhold) | RSTROBE(rstrobe) | RSETUP(rsetup) |
124 WHOLD(whold) | WSTROBE(wstrobe) | WSETUP(wsetup);
125
126 val = __raw_readl(base + offset);
127 val &= ~TIMING_MASK;
128 val |= set;
129 __raw_writel(val, base + offset);
130
131 return 0;
132}
133EXPORT_SYMBOL(davinci_aemif_setup_timing);
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 7f3cdbfc0fbb..b52a3a1abd94 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -29,10 +29,9 @@
29#include <mach/nand.h> 29#include <mach/nand.h>
30#include <mach/da8xx.h> 30#include <mach/da8xx.h>
31#include <mach/usb.h> 31#include <mach/usb.h>
32#include <mach/aemif.h>
32 33
33#define DA830_EVM_PHY_MASK 0x0 34#define DA830_EVM_PHY_ID ""
34#define DA830_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
35
36/* 35/*
37 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4]. 36 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
38 */ 37 */
@@ -360,6 +359,16 @@ static struct nand_bbt_descr da830_evm_nand_bbt_mirror_descr = {
360 .pattern = da830_evm_nand_mirror_pattern 359 .pattern = da830_evm_nand_mirror_pattern
361}; 360};
362 361
362static struct davinci_aemif_timing da830_evm_nandflash_timing = {
363 .wsetup = 24,
364 .wstrobe = 21,
365 .whold = 14,
366 .rsetup = 19,
367 .rstrobe = 50,
368 .rhold = 0,
369 .ta = 20,
370};
371
363static struct davinci_nand_pdata da830_evm_nand_pdata = { 372static struct davinci_nand_pdata da830_evm_nand_pdata = {
364 .parts = da830_evm_nand_partitions, 373 .parts = da830_evm_nand_partitions,
365 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions), 374 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions),
@@ -368,6 +377,7 @@ static struct davinci_nand_pdata da830_evm_nand_pdata = {
368 .options = NAND_USE_FLASH_BBT, 377 .options = NAND_USE_FLASH_BBT,
369 .bbt_td = &da830_evm_nand_bbt_main_descr, 378 .bbt_td = &da830_evm_nand_bbt_main_descr,
370 .bbt_md = &da830_evm_nand_bbt_mirror_descr, 379 .bbt_md = &da830_evm_nand_bbt_mirror_descr,
380 .timing = &da830_evm_nandflash_timing,
371}; 381};
372 382
373static struct resource da830_evm_nand_resources[] = { 383static struct resource da830_evm_nand_resources[] = {
@@ -546,9 +556,8 @@ static __init void da830_evm_init(void)
546 556
547 da830_evm_usb_init(); 557 da830_evm_usb_init();
548 558
549 soc_info->emac_pdata->phy_mask = DA830_EVM_PHY_MASK;
550 soc_info->emac_pdata->mdio_max_freq = DA830_EVM_MDIO_FREQUENCY;
551 soc_info->emac_pdata->rmii_en = 1; 559 soc_info->emac_pdata->rmii_en = 1;
560 soc_info->emac_pdata->phy_id = DA830_EVM_PHY_ID;
552 561
553 ret = davinci_cfg_reg_list(da830_cpgmac_pins); 562 ret = davinci_cfg_reg_list(da830_cpgmac_pins);
554 if (ret) 563 if (ret)
@@ -586,6 +595,9 @@ static __init void da830_evm_init(void)
586#ifdef CONFIG_SERIAL_8250_CONSOLE 595#ifdef CONFIG_SERIAL_8250_CONSOLE
587static int __init da830_evm_console_init(void) 596static int __init da830_evm_console_init(void)
588{ 597{
598 if (!machine_is_davinci_da830_evm())
599 return 0;
600
589 return add_preferred_console("ttyS", 2, "115200"); 601 return add_preferred_console("ttyS", 2, "115200");
590} 602}
591console_initcall(da830_evm_console_init); 603console_initcall(da830_evm_console_init);
@@ -596,7 +608,7 @@ static void __init da830_evm_map_io(void)
596 da830_init(); 608 da830_init();
597} 609}
598 610
599MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137 EVM") 611MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
600 .boot_params = (DA8XX_DDR_BASE + 0x100), 612 .boot_params = (DA8XX_DDR_BASE + 0x100),
601 .map_io = da830_evm_map_io, 613 .map_io = da830_evm_map_io,
602 .init_irq = cp_intc_init, 614 .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 b26f5cbfce3e..c6e11c682e4c 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -26,7 +26,6 @@
26#include <linux/mtd/physmap.h> 26#include <linux/mtd/physmap.h>
27#include <linux/regulator/machine.h> 27#include <linux/regulator/machine.h>
28#include <linux/regulator/tps6507x.h> 28#include <linux/regulator/tps6507x.h>
29#include <linux/mfd/tps6507x.h>
30#include <linux/input/tps6507x-ts.h> 29#include <linux/input/tps6507x-ts.h>
31 30
32#include <asm/mach-types.h> 31#include <asm/mach-types.h>
@@ -36,10 +35,9 @@
36#include <mach/da8xx.h> 35#include <mach/da8xx.h>
37#include <mach/nand.h> 36#include <mach/nand.h>
38#include <mach/mux.h> 37#include <mach/mux.h>
38#include <mach/aemif.h>
39 39
40#define DA850_EVM_PHY_MASK 0x1 40#define DA850_EVM_PHY_ID "0:00"
41#define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
42
43#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8) 41#define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
44#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15) 42#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
45 43
@@ -110,7 +108,7 @@ static struct platform_device da850_pm_device = {
110 * to boot, using TI's tools to install the secondary boot loader 108 * to boot, using TI's tools to install the secondary boot loader
111 * (UBL) and U-Boot. 109 * (UBL) and U-Boot.
112 */ 110 */
113struct mtd_partition da850_evm_nandflash_partition[] = { 111static struct mtd_partition da850_evm_nandflash_partition[] = {
114 { 112 {
115 .name = "u-boot env", 113 .name = "u-boot env",
116 .offset = 0, 114 .offset = 0,
@@ -143,12 +141,23 @@ struct mtd_partition da850_evm_nandflash_partition[] = {
143 }, 141 },
144}; 142};
145 143
144static struct davinci_aemif_timing da850_evm_nandflash_timing = {
145 .wsetup = 24,
146 .wstrobe = 21,
147 .whold = 14,
148 .rsetup = 19,
149 .rstrobe = 50,
150 .rhold = 0,
151 .ta = 20,
152};
153
146static struct davinci_nand_pdata da850_evm_nandflash_data = { 154static struct davinci_nand_pdata da850_evm_nandflash_data = {
147 .parts = da850_evm_nandflash_partition, 155 .parts = da850_evm_nandflash_partition,
148 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition), 156 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
149 .ecc_mode = NAND_ECC_HW, 157 .ecc_mode = NAND_ECC_HW,
150 .ecc_bits = 4, 158 .ecc_bits = 4,
151 .options = NAND_USE_FLASH_BBT, 159 .options = NAND_USE_FLASH_BBT,
160 .timing = &da850_evm_nandflash_timing,
152}; 161};
153 162
154static struct resource da850_evm_nandflash_resource[] = { 163static struct resource da850_evm_nandflash_resource[] = {
@@ -196,6 +205,30 @@ static void __init da850_evm_init_nor(void)
196 iounmap(aemif_addr); 205 iounmap(aemif_addr);
197} 206}
198 207
208static const short da850_evm_nand_pins[] = {
209 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
210 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
211 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
212 DA850_NEMA_WE, DA850_NEMA_OE,
213 -1
214};
215
216static const short da850_evm_nor_pins[] = {
217 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
218 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
219 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
220 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
221 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
222 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
223 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
224 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
225 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
226 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
227 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
228 DA850_EMA_A_22, DA850_EMA_A_23,
229 -1
230};
231
199static u32 ui_card_detected; 232static u32 ui_card_detected;
200 233
201#if defined(CONFIG_MMC_DAVINCI) || \ 234#if defined(CONFIG_MMC_DAVINCI) || \
@@ -205,17 +238,17 @@ static u32 ui_card_detected;
205#define HAS_MMC 0 238#define HAS_MMC 0
206#endif 239#endif
207 240
208static __init void da850_evm_setup_nor_nand(void) 241static inline void da850_evm_setup_nor_nand(void)
209{ 242{
210 int ret = 0; 243 int ret = 0;
211 244
212 if (ui_card_detected & !HAS_MMC) { 245 if (ui_card_detected & !HAS_MMC) {
213 ret = davinci_cfg_reg_list(da850_nand_pins); 246 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
214 if (ret) 247 if (ret)
215 pr_warning("da850_evm_init: nand mux setup failed: " 248 pr_warning("da850_evm_init: nand mux setup failed: "
216 "%d\n", ret); 249 "%d\n", ret);
217 250
218 ret = davinci_cfg_reg_list(da850_nor_pins); 251 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
219 if (ret) 252 if (ret)
220 pr_warning("da850_evm_init: nor mux setup failed: %d\n", 253 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
221 ret); 254 ret);
@@ -406,7 +439,7 @@ static int da850_lcd_hw_init(void)
406/* TPS65070 voltage regulator support */ 439/* TPS65070 voltage regulator support */
407 440
408/* 3.3V */ 441/* 3.3V */
409struct regulator_consumer_supply tps65070_dcdc1_consumers[] = { 442static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
410 { 443 {
411 .supply = "usb0_vdda33", 444 .supply = "usb0_vdda33",
412 }, 445 },
@@ -416,7 +449,7 @@ struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
416}; 449};
417 450
418/* 3.3V or 1.8V */ 451/* 3.3V or 1.8V */
419struct regulator_consumer_supply tps65070_dcdc2_consumers[] = { 452static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
420 { 453 {
421 .supply = "dvdd3318_a", 454 .supply = "dvdd3318_a",
422 }, 455 },
@@ -429,14 +462,14 @@ struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
429}; 462};
430 463
431/* 1.2V */ 464/* 1.2V */
432struct regulator_consumer_supply tps65070_dcdc3_consumers[] = { 465static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
433 { 466 {
434 .supply = "cvdd", 467 .supply = "cvdd",
435 }, 468 },
436}; 469};
437 470
438/* 1.8V LDO */ 471/* 1.8V LDO */
439struct regulator_consumer_supply tps65070_ldo1_consumers[] = { 472static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
440 { 473 {
441 .supply = "sata_vddr", 474 .supply = "sata_vddr",
442 }, 475 },
@@ -452,7 +485,7 @@ struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
452}; 485};
453 486
454/* 1.2V LDO */ 487/* 1.2V LDO */
455struct regulator_consumer_supply tps65070_ldo2_consumers[] = { 488static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
456 { 489 {
457 .supply = "sata_vdd", 490 .supply = "sata_vdd",
458 }, 491 },
@@ -475,7 +508,7 @@ static struct tps6507x_reg_platform_data tps6507x_platform_data = {
475 .defdcdc_default = true, 508 .defdcdc_default = true,
476}; 509};
477 510
478struct regulator_init_data tps65070_regulator_data[] = { 511static struct regulator_init_data tps65070_regulator_data[] = {
479 /* dcdc1 */ 512 /* dcdc1 */
480 { 513 {
481 .constraints = { 514 .constraints = {
@@ -576,6 +609,23 @@ static const short da850_evm_lcdc_pins[] = {
576 -1 609 -1
577}; 610};
578 611
612static const short da850_evm_mii_pins[] = {
613 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
614 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
615 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
616 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
617 DA850_MDIO_D,
618 -1
619};
620
621static const short da850_evm_rmii_pins[] = {
622 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
623 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
624 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
625 DA850_MDIO_D,
626 -1
627};
628
579static int __init da850_evm_config_emac(void) 629static int __init da850_evm_config_emac(void)
580{ 630{
581 void __iomem *cfg_chip3_base; 631 void __iomem *cfg_chip3_base;
@@ -593,12 +643,12 @@ static int __init da850_evm_config_emac(void)
593 643
594 if (rmii_en) { 644 if (rmii_en) {
595 val |= BIT(8); 645 val |= BIT(8);
596 ret = davinci_cfg_reg_list(da850_rmii_pins); 646 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
597 pr_info("EMAC: RMII PHY configured, MII PHY will not be" 647 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
598 " functional\n"); 648 " functional\n");
599 } else { 649 } else {
600 val &= ~BIT(8); 650 val &= ~BIT(8);
601 ret = davinci_cfg_reg_list(da850_cpgmac_pins); 651 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
602 pr_info("EMAC: MII PHY configured, RMII PHY will not be" 652 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
603 " functional\n"); 653 " functional\n");
604 } 654 }
@@ -625,8 +675,7 @@ static int __init da850_evm_config_emac(void)
625 /* Enable/Disable MII MDIO clock */ 675 /* Enable/Disable MII MDIO clock */
626 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en); 676 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
627 677
628 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK; 678 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
629 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
630 679
631 ret = da8xx_register_emac(); 680 ret = da8xx_register_emac();
632 if (ret) 681 if (ret)
@@ -787,7 +836,7 @@ static __init void da850_evm_init(void)
787 if (ret) 836 if (ret)
788 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret); 837 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
789 838
790 ret = da850_register_cpufreq(); 839 ret = da850_register_cpufreq("pll0_sysclk3");
791 if (ret) 840 if (ret)
792 pr_warning("da850_evm_init: cpufreq registration failed: %d\n", 841 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
793 ret); 842 ret);
@@ -806,6 +855,9 @@ static __init void da850_evm_init(void)
806#ifdef CONFIG_SERIAL_8250_CONSOLE 855#ifdef CONFIG_SERIAL_8250_CONSOLE
807static int __init da850_evm_console_init(void) 856static int __init da850_evm_console_init(void)
808{ 857{
858 if (!machine_is_davinci_da850_evm())
859 return 0;
860
809 return add_preferred_console("ttyS", 2, "115200"); 861 return add_preferred_console("ttyS", 2, "115200");
810} 862}
811console_initcall(da850_evm_console_init); 863console_initcall(da850_evm_console_init);
@@ -816,7 +868,7 @@ static void __init da850_evm_map_io(void)
816 da850_init(); 868 da850_init();
817} 869}
818 870
819MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM") 871MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
820 .boot_params = (DA8XX_DDR_BASE + 0x100), 872 .boot_params = (DA8XX_DDR_BASE + 0x100),
821 .map_io = da850_evm_map_io, 873 .map_io = da850_evm_map_io,
822 .init_irq = cp_intc_init, 874 .init_irq = cp_intc_init,
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 944a0cbaf5cb..c67f684ee3e5 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -54,9 +54,7 @@ static inline int have_tvp7002(void)
54 return 0; 54 return 0;
55} 55}
56 56
57#define DM365_EVM_PHY_MASK (0x2) 57#define DM365_EVM_PHY_ID "0:01"
58#define DM365_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
59
60/* 58/*
61 * A MAX-II CPLD is used for various board control functions. 59 * A MAX-II CPLD is used for various board control functions.
62 */ 60 */
@@ -175,7 +173,9 @@ static struct at24_platform_data eeprom_info = {
175 .context = (void *)0x7f00, 173 .context = (void *)0x7f00,
176}; 174};
177 175
178static struct snd_platform_data dm365_evm_snd_data; 176static struct snd_platform_data dm365_evm_snd_data = {
177 .asp_chan_q = EVENTQ_3,
178};
179 179
180static struct i2c_board_info i2c_info[] = { 180static struct i2c_board_info i2c_info[] = {
181 { 181 {
@@ -533,8 +533,7 @@ fail:
533 533
534 /* ... and ENET ... */ 534 /* ... and ENET ... */
535 dm365evm_emac_configure(); 535 dm365evm_emac_configure();
536 soc_info->emac_pdata->phy_mask = DM365_EVM_PHY_MASK; 536 soc_info->emac_pdata->phy_id = DM365_EVM_PHY_ID;
537 soc_info->emac_pdata->mdio_max_freq = DM365_EVM_MDIO_FREQUENCY;
538 resets &= ~BIT(3); 537 resets &= ~BIT(3);
539 538
540 /* ... and AIC33 */ 539 /* ... and AIC33 */
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index d59fba15ba8d..0ca90b834586 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -37,10 +37,9 @@
37#include <mach/nand.h> 37#include <mach/nand.h>
38#include <mach/mmc.h> 38#include <mach/mmc.h>
39#include <mach/usb.h> 39#include <mach/usb.h>
40#include <mach/aemif.h>
40 41
41#define DM644X_EVM_PHY_MASK (0x2) 42#define DM644X_EVM_PHY_ID "0:01"
42#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
43
44#define LXT971_PHY_ID (0x001378e2) 43#define LXT971_PHY_ID (0x001378e2)
45#define LXT971_PHY_MASK (0xfffffff0) 44#define LXT971_PHY_MASK (0xfffffff0)
46 45
@@ -137,11 +136,22 @@ static struct mtd_partition davinci_evm_nandflash_partition[] = {
137 */ 136 */
138}; 137};
139 138
139static struct davinci_aemif_timing davinci_evm_nandflash_timing = {
140 .wsetup = 20,
141 .wstrobe = 40,
142 .whold = 20,
143 .rsetup = 10,
144 .rstrobe = 40,
145 .rhold = 10,
146 .ta = 40,
147};
148
140static struct davinci_nand_pdata davinci_evm_nandflash_data = { 149static struct davinci_nand_pdata davinci_evm_nandflash_data = {
141 .parts = davinci_evm_nandflash_partition, 150 .parts = davinci_evm_nandflash_partition,
142 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), 151 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
143 .ecc_mode = NAND_ECC_HW, 152 .ecc_mode = NAND_ECC_HW,
144 .options = NAND_USE_FLASH_BBT, 153 .options = NAND_USE_FLASH_BBT,
154 .timing = &davinci_evm_nandflash_timing,
145}; 155};
146 156
147static struct resource davinci_evm_nandflash_resource[] = { 157static struct resource davinci_evm_nandflash_resource[] = {
@@ -695,9 +705,7 @@ static __init void davinci_evm_init(void)
695 davinci_serial_init(&uart_config); 705 davinci_serial_init(&uart_config);
696 dm644x_init_asp(&dm644x_evm_snd_data); 706 dm644x_init_asp(&dm644x_evm_snd_data);
697 707
698 soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK; 708 soc_info->emac_pdata->phy_id = DM644X_EVM_PHY_ID;
699 soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
700
701 /* Register the fixup for PHY on DaVinci */ 709 /* Register the fixup for PHY on DaVinci */
702 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, 710 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
703 davinci_phy_fixup); 711 davinci_phy_fixup);
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 6890488fb92b..f6ac9ba74878 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -42,6 +42,7 @@
42#include <mach/nand.h> 42#include <mach/nand.h>
43#include <mach/clock.h> 43#include <mach/clock.h>
44#include <mach/cdce949.h> 44#include <mach/cdce949.h>
45#include <mach/aemif.h>
45 46
46#include "clock.h" 47#include "clock.h"
47 48
@@ -71,6 +72,16 @@ static struct mtd_partition davinci_nand_partitions[] = {
71 } 72 }
72}; 73};
73 74
75static struct davinci_aemif_timing dm6467tevm_nandflash_timing = {
76 .wsetup = 29,
77 .wstrobe = 24,
78 .whold = 14,
79 .rsetup = 19,
80 .rstrobe = 33,
81 .rhold = 0,
82 .ta = 29,
83};
84
74static struct davinci_nand_pdata davinci_nand_data = { 85static struct davinci_nand_pdata davinci_nand_data = {
75 .mask_cle = 0x80000, 86 .mask_cle = 0x80000,
76 .mask_ale = 0x40000, 87 .mask_ale = 0x40000,
@@ -718,9 +729,7 @@ static struct davinci_uart_config uart_config __initdata = {
718 .enabled_uarts = (1 << 0), 729 .enabled_uarts = (1 << 0),
719}; 730};
720 731
721#define DM646X_EVM_PHY_MASK (0x2) 732#define DM646X_EVM_PHY_ID "0:01"
722#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
723
724/* 733/*
725 * The following EDMA channels/slots are not being used by drivers (for 734 * The following EDMA channels/slots are not being used by drivers (for
726 * example: Timer, GPIO, UART events etc) on dm646x, hence they are being 735 * example: Timer, GPIO, UART events etc) on dm646x, hence they are being
@@ -763,6 +772,9 @@ static __init void evm_init(void)
763 dm646x_init_mcasp0(&dm646x_evm_snd_data[0]); 772 dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);
764 dm646x_init_mcasp1(&dm646x_evm_snd_data[1]); 773 dm646x_init_mcasp1(&dm646x_evm_snd_data[1]);
765 774
775 if (machine_is_davinci_dm6467tevm())
776 davinci_nand_data.timing = &dm6467tevm_nandflash_timing;
777
766 platform_device_register(&davinci_nand_device); 778 platform_device_register(&davinci_nand_device);
767 779
768 dm646x_init_edma(dm646x_edma_rsv); 780 dm646x_init_edma(dm646x_edma_rsv);
@@ -770,8 +782,7 @@ static __init void evm_init(void)
770 if (HAS_ATA) 782 if (HAS_ATA)
771 davinci_init_ide(); 783 davinci_init_ide();
772 784
773 soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK; 785 soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
774 soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
775} 786}
776 787
777#define DM646X_EVM_REF_FREQ 27000000 788#define DM646X_EVM_REF_FREQ 27000000
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
new file mode 100644
index 000000000000..0bb5f0ce4fdc
--- /dev/null
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -0,0 +1,422 @@
1/*
2 * Critical Link MityOMAP-L138 SoM
3 *
4 * Copyright (C) 2010 Critical Link LLC - http://www.criticallink.com
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of
8 * any kind, whether express or implied.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/console.h>
14#include <linux/platform_device.h>
15#include <linux/mtd/partitions.h>
16#include <linux/regulator/machine.h>
17#include <linux/i2c.h>
18#include <linux/i2c/at24.h>
19#include <linux/etherdevice.h>
20
21#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23#include <mach/common.h>
24#include <mach/cp_intc.h>
25#include <mach/da8xx.h>
26#include <mach/nand.h>
27#include <mach/mux.h>
28
29#define MITYOMAPL138_PHY_ID "0:03"
30
31#define FACTORY_CONFIG_MAGIC 0x012C0138
32#define FACTORY_CONFIG_VERSION 0x00010001
33
34/* Data Held in On-Board I2C device */
35struct factory_config {
36 u32 magic;
37 u32 version;
38 u8 mac[6];
39 u32 fpga_type;
40 u32 spare;
41 u32 serialnumber;
42 char partnum[32];
43};
44
45static struct factory_config factory_config;
46
47static void read_factory_config(struct memory_accessor *a, void *context)
48{
49 int ret;
50 struct davinci_soc_info *soc_info = &davinci_soc_info;
51
52 ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config));
53 if (ret != sizeof(struct factory_config)) {
54 pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n",
55 ret);
56 return;
57 }
58
59 if (factory_config.magic != FACTORY_CONFIG_MAGIC) {
60 pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n",
61 factory_config.magic);
62 return;
63 }
64
65 if (factory_config.version != FACTORY_CONFIG_VERSION) {
66 pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n",
67 factory_config.version);
68 return;
69 }
70
71 pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac);
72 pr_info("MityOMAPL138: Part Number = %s\n", factory_config.partnum);
73 if (is_valid_ether_addr(factory_config.mac))
74 memcpy(soc_info->emac_pdata->mac_addr,
75 factory_config.mac, ETH_ALEN);
76 else
77 pr_warning("MityOMAPL138: Invalid MAC found "
78 "in factory config block\n");
79}
80
81static struct at24_platform_data mityomapl138_fd_chip = {
82 .byte_len = 256,
83 .page_size = 8,
84 .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
85 .setup = read_factory_config,
86 .context = NULL,
87};
88
89static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
90 .bus_freq = 100, /* kHz */
91 .bus_delay = 0, /* usec */
92};
93
94/* TPS65023 voltage regulator support */
95/* 1.2V Core */
96static struct regulator_consumer_supply tps65023_dcdc1_consumers[] = {
97 {
98 .supply = "cvdd",
99 },
100};
101
102/* 1.8V */
103static struct regulator_consumer_supply tps65023_dcdc2_consumers[] = {
104 {
105 .supply = "usb0_vdda18",
106 },
107 {
108 .supply = "usb1_vdda18",
109 },
110 {
111 .supply = "ddr_dvdd18",
112 },
113 {
114 .supply = "sata_vddr",
115 },
116};
117
118/* 1.2V */
119static struct regulator_consumer_supply tps65023_dcdc3_consumers[] = {
120 {
121 .supply = "sata_vdd",
122 },
123 {
124 .supply = "usb_cvdd",
125 },
126 {
127 .supply = "pll0_vdda",
128 },
129 {
130 .supply = "pll1_vdda",
131 },
132};
133
134/* 1.8V Aux LDO, not used */
135static struct regulator_consumer_supply tps65023_ldo1_consumers[] = {
136 {
137 .supply = "1.8v_aux",
138 },
139};
140
141/* FPGA VCC Aux (2.5 or 3.3) LDO */
142static struct regulator_consumer_supply tps65023_ldo2_consumers[] = {
143 {
144 .supply = "vccaux",
145 },
146};
147
148static struct regulator_init_data tps65023_regulator_data[] = {
149 /* dcdc1 */
150 {
151 .constraints = {
152 .min_uV = 1150000,
153 .max_uV = 1350000,
154 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
155 REGULATOR_CHANGE_STATUS,
156 .boot_on = 1,
157 },
158 .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc1_consumers),
159 .consumer_supplies = tps65023_dcdc1_consumers,
160 },
161 /* dcdc2 */
162 {
163 .constraints = {
164 .min_uV = 1800000,
165 .max_uV = 1800000,
166 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
167 .boot_on = 1,
168 },
169 .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc2_consumers),
170 .consumer_supplies = tps65023_dcdc2_consumers,
171 },
172 /* dcdc3 */
173 {
174 .constraints = {
175 .min_uV = 1200000,
176 .max_uV = 1200000,
177 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
178 .boot_on = 1,
179 },
180 .num_consumer_supplies = ARRAY_SIZE(tps65023_dcdc3_consumers),
181 .consumer_supplies = tps65023_dcdc3_consumers,
182 },
183 /* ldo1 */
184 {
185 .constraints = {
186 .min_uV = 1800000,
187 .max_uV = 1800000,
188 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
189 .boot_on = 1,
190 },
191 .num_consumer_supplies = ARRAY_SIZE(tps65023_ldo1_consumers),
192 .consumer_supplies = tps65023_ldo1_consumers,
193 },
194 /* ldo2 */
195 {
196 .constraints = {
197 .min_uV = 2500000,
198 .max_uV = 3300000,
199 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
200 REGULATOR_CHANGE_STATUS,
201 .boot_on = 1,
202 },
203 .num_consumer_supplies = ARRAY_SIZE(tps65023_ldo2_consumers),
204 .consumer_supplies = tps65023_ldo2_consumers,
205 },
206};
207
208static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
209 {
210 I2C_BOARD_INFO("tps65023", 0x48),
211 .platform_data = &tps65023_regulator_data[0],
212 },
213 {
214 I2C_BOARD_INFO("24c02", 0x50),
215 .platform_data = &mityomapl138_fd_chip,
216 },
217};
218
219static int __init pmic_tps65023_init(void)
220{
221 return i2c_register_board_info(1, mityomap_tps65023_info,
222 ARRAY_SIZE(mityomap_tps65023_info));
223}
224
225/*
226 * MityDSP-L138 includes a 256 MByte large-page NAND flash
227 * (128K blocks).
228 */
229static struct mtd_partition mityomapl138_nandflash_partition[] = {
230 {
231 .name = "rootfs",
232 .offset = 0,
233 .size = SZ_128M,
234 .mask_flags = 0, /* MTD_WRITEABLE, */
235 },
236 {
237 .name = "homefs",
238 .offset = MTDPART_OFS_APPEND,
239 .size = MTDPART_SIZ_FULL,
240 .mask_flags = 0,
241 },
242};
243
244static struct davinci_nand_pdata mityomapl138_nandflash_data = {
245 .parts = mityomapl138_nandflash_partition,
246 .nr_parts = ARRAY_SIZE(mityomapl138_nandflash_partition),
247 .ecc_mode = NAND_ECC_HW,
248 .options = NAND_USE_FLASH_BBT | NAND_BUSWIDTH_16,
249 .ecc_bits = 1, /* 4 bit mode is not supported with 16 bit NAND */
250};
251
252static struct resource mityomapl138_nandflash_resource[] = {
253 {
254 .start = DA8XX_AEMIF_CS3_BASE,
255 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
256 .flags = IORESOURCE_MEM,
257 },
258 {
259 .start = DA8XX_AEMIF_CTL_BASE,
260 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
261 .flags = IORESOURCE_MEM,
262 },
263};
264
265static struct platform_device mityomapl138_nandflash_device = {
266 .name = "davinci_nand",
267 .id = 0,
268 .dev = {
269 .platform_data = &mityomapl138_nandflash_data,
270 },
271 .num_resources = ARRAY_SIZE(mityomapl138_nandflash_resource),
272 .resource = mityomapl138_nandflash_resource,
273};
274
275static struct platform_device *mityomapl138_devices[] __initdata = {
276 &mityomapl138_nandflash_device,
277};
278
279static void __init mityomapl138_setup_nand(void)
280{
281 platform_add_devices(mityomapl138_devices,
282 ARRAY_SIZE(mityomapl138_devices));
283}
284
285static struct davinci_uart_config mityomapl138_uart_config __initdata = {
286 .enabled_uarts = 0x7,
287};
288
289static const short mityomap_mii_pins[] = {
290 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
291 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
292 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
293 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
294 DA850_MDIO_D,
295 -1
296};
297
298static const short mityomap_rmii_pins[] = {
299 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
300 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
301 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
302 DA850_MDIO_D,
303 -1
304};
305
306static void __init mityomapl138_config_emac(void)
307{
308 void __iomem *cfg_chip3_base;
309 int ret;
310 u32 val;
311 struct davinci_soc_info *soc_info = &davinci_soc_info;
312
313 soc_info->emac_pdata->rmii_en = 0; /* hardcoded for now */
314
315 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
316 val = __raw_readl(cfg_chip3_base);
317
318 if (soc_info->emac_pdata->rmii_en) {
319 val |= BIT(8);
320 ret = davinci_cfg_reg_list(mityomap_rmii_pins);
321 pr_info("RMII PHY configured\n");
322 } else {
323 val &= ~BIT(8);
324 ret = davinci_cfg_reg_list(mityomap_mii_pins);
325 pr_info("MII PHY configured\n");
326 }
327
328 if (ret) {
329 pr_warning("mii/rmii mux setup failed: %d\n", ret);
330 return;
331 }
332
333 /* configure the CFGCHIP3 register for RMII or MII */
334 __raw_writel(val, cfg_chip3_base);
335
336 soc_info->emac_pdata->phy_id = MITYOMAPL138_PHY_ID;
337
338 ret = da8xx_register_emac();
339 if (ret)
340 pr_warning("emac registration failed: %d\n", ret);
341}
342
343static struct davinci_pm_config da850_pm_pdata = {
344 .sleepcount = 128,
345};
346
347static struct platform_device da850_pm_device = {
348 .name = "pm-davinci",
349 .dev = {
350 .platform_data = &da850_pm_pdata,
351 },
352 .id = -1,
353};
354
355static void __init mityomapl138_init(void)
356{
357 int ret;
358
359 /* for now, no special EDMA channels are reserved */
360 ret = da850_register_edma(NULL);
361 if (ret)
362 pr_warning("edma registration failed: %d\n", ret);
363
364 ret = da8xx_register_watchdog();
365 if (ret)
366 pr_warning("watchdog registration failed: %d\n", ret);
367
368 davinci_serial_init(&mityomapl138_uart_config);
369
370 ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata);
371 if (ret)
372 pr_warning("i2c0 registration failed: %d\n", ret);
373
374 ret = pmic_tps65023_init();
375 if (ret)
376 pr_warning("TPS65023 PMIC init failed: %d\n", ret);
377
378 mityomapl138_setup_nand();
379
380 mityomapl138_config_emac();
381
382 ret = da8xx_register_rtc();
383 if (ret)
384 pr_warning("rtc setup failed: %d\n", ret);
385
386 ret = da850_register_cpufreq("pll0_sysclk3");
387 if (ret)
388 pr_warning("cpufreq registration failed: %d\n", ret);
389
390 ret = da8xx_register_cpuidle();
391 if (ret)
392 pr_warning("cpuidle registration failed: %d\n", ret);
393
394 ret = da850_register_pm(&da850_pm_device);
395 if (ret)
396 pr_warning("da850_evm_init: suspend registration failed: %d\n",
397 ret);
398}
399
400#ifdef CONFIG_SERIAL_8250_CONSOLE
401static int __init mityomapl138_console_init(void)
402{
403 if (!machine_is_mityomapl138())
404 return 0;
405
406 return add_preferred_console("ttyS", 1, "115200");
407}
408console_initcall(mityomapl138_console_init);
409#endif
410
411static void __init mityomapl138_map_io(void)
412{
413 da850_init();
414}
415
416MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808")
417 .boot_params = (DA8XX_DDR_BASE + 0x100),
418 .map_io = mityomapl138_map_io,
419 .init_irq = cp_intc_init,
420 .timer = &davinci_timer,
421 .init_machine = mityomapl138_init,
422MACHINE_END
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index a4def889275c..6c389ff1020e 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -39,9 +39,7 @@
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/usb.h> 40#include <mach/usb.h>
41 41
42#define NEUROS_OSD2_PHY_MASK 0x2 42#define NEUROS_OSD2_PHY_ID "0:01"
43#define NEUROS_OSD2_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
44
45#define LXT971_PHY_ID 0x001378e2 43#define LXT971_PHY_ID 0x001378e2
46#define LXT971_PHY_MASK 0xfffffff0 44#define LXT971_PHY_MASK 0xfffffff0
47 45
@@ -252,8 +250,7 @@ static __init void davinci_ntosd2_init(void)
252 davinci_serial_init(&uart_config); 250 davinci_serial_init(&uart_config);
253 dm644x_init_asp(&dm644x_ntosd2_snd_data); 251 dm644x_init_asp(&dm644x_ntosd2_snd_data);
254 252
255 soc_info->emac_pdata->phy_mask = NEUROS_OSD2_PHY_MASK; 253 soc_info->emac_pdata->phy_id = NEUROS_OSD2_PHY_ID;
256 soc_info->emac_pdata->mdio_max_freq = NEUROS_OSD2_MDIO_FREQUENCY;
257 254
258 davinci_setup_usb(1000, 8); 255 davinci_setup_usb(1000, 8);
259 /* 256 /*
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c
new file mode 100644
index 000000000000..0b8dbdb79fe0
--- /dev/null
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -0,0 +1,62 @@
1/*
2 * Hawkboard.org based on TI's OMAP-L138 Platform
3 *
4 * Initial code: Syed Mohammed Khasim
5 *
6 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of
10 * any kind, whether express or implied.
11 */
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/console.h>
15#include <linux/gpio.h>
16
17#include <asm/mach-types.h>
18#include <asm/mach/arch.h>
19
20#include <mach/cp_intc.h>
21#include <mach/da8xx.h>
22
23static struct davinci_uart_config omapl138_hawk_uart_config __initdata = {
24 .enabled_uarts = 0x7,
25};
26
27static __init void omapl138_hawk_init(void)
28{
29 int ret;
30
31 davinci_serial_init(&omapl138_hawk_uart_config);
32
33 ret = da8xx_register_watchdog();
34 if (ret)
35 pr_warning("omapl138_hawk_init: "
36 "watchdog registration failed: %d\n",
37 ret);
38}
39
40#ifdef CONFIG_SERIAL_8250_CONSOLE
41static int __init omapl138_hawk_console_init(void)
42{
43 if (!machine_is_omapl138_hawkboard())
44 return 0;
45
46 return add_preferred_console("ttyS", 2, "115200");
47}
48console_initcall(omapl138_hawk_console_init);
49#endif
50
51static void __init omapl138_hawk_map_io(void)
52{
53 da850_init();
54}
55
56MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
57 .boot_params = (DA8XX_DDR_BASE + 0x100),
58 .map_io = omapl138_hawk_map_io,
59 .init_irq = cp_intc_init,
60 .timer = &davinci_timer,
61 .init_machine = omapl138_hawk_init,
62MACHINE_END
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index 9bdf8aafcc84..61ac96d8f00d 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -42,9 +42,7 @@
42#include <mach/mux.h> 42#include <mach/mux.h>
43#include <mach/usb.h> 43#include <mach/usb.h>
44 44
45#define SFFSDR_PHY_MASK (0x2) 45#define SFFSDR_PHY_ID "0:01"
46#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
47
48static struct mtd_partition davinci_sffsdr_nandflash_partition[] = { 46static struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
49 /* U-Boot Environment: Block 0 47 /* U-Boot Environment: Block 0
50 * UBL: Block 1 48 * UBL: Block 1
@@ -143,8 +141,7 @@ static __init void davinci_sffsdr_init(void)
143 ARRAY_SIZE(davinci_sffsdr_devices)); 141 ARRAY_SIZE(davinci_sffsdr_devices));
144 sffsdr_init_i2c(); 142 sffsdr_init_i2c();
145 davinci_serial_init(&uart_config); 143 davinci_serial_init(&uart_config);
146 soc_info->emac_pdata->phy_mask = SFFSDR_PHY_MASK; 144 soc_info->emac_pdata->phy_id = SFFSDR_PHY_ID;
147 soc_info->emac_pdata->mdio_max_freq = SFFSDR_MDIO_FREQUENCY;
148 davinci_setup_usb(0, 0); /* We support only peripheral mode. */ 145 davinci_setup_usb(0, 0); /* We support only peripheral mode. */
149 146
150 /* mux VLYNQ pins */ 147 /* mux VLYNQ pins */
diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c b/arch/arm/mach-davinci/board-tnetv107x-evm.c
index b4de35b78904..a6db85460227 100644
--- a/arch/arm/mach-davinci/board-tnetv107x-evm.c
+++ b/arch/arm/mach-davinci/board-tnetv107x-evm.c
@@ -23,6 +23,9 @@
23#include <linux/ratelimit.h> 23#include <linux/ratelimit.h>
24#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
26#include <linux/input.h>
27#include <linux/input/matrix_keypad.h>
28
26#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
27#include <asm/mach-types.h> 30#include <asm/mach-types.h>
28 31
@@ -141,10 +144,63 @@ static struct davinci_uart_config serial_config __initconst = {
141 .enabled_uarts = BIT(1), 144 .enabled_uarts = BIT(1),
142}; 145};
143 146
147static const uint32_t keymap[] = {
148 KEY(0, 0, KEY_NUMERIC_1),
149 KEY(0, 1, KEY_NUMERIC_2),
150 KEY(0, 2, KEY_NUMERIC_3),
151 KEY(0, 3, KEY_FN_F1),
152 KEY(0, 4, KEY_MENU),
153
154 KEY(1, 0, KEY_NUMERIC_4),
155 KEY(1, 1, KEY_NUMERIC_5),
156 KEY(1, 2, KEY_NUMERIC_6),
157 KEY(1, 3, KEY_UP),
158 KEY(1, 4, KEY_FN_F2),
159
160 KEY(2, 0, KEY_NUMERIC_7),
161 KEY(2, 1, KEY_NUMERIC_8),
162 KEY(2, 2, KEY_NUMERIC_9),
163 KEY(2, 3, KEY_LEFT),
164 KEY(2, 4, KEY_ENTER),
165
166 KEY(3, 0, KEY_NUMERIC_STAR),
167 KEY(3, 1, KEY_NUMERIC_0),
168 KEY(3, 2, KEY_NUMERIC_POUND),
169 KEY(3, 3, KEY_DOWN),
170 KEY(3, 4, KEY_RIGHT),
171
172 KEY(4, 0, KEY_FN_F3),
173 KEY(4, 1, KEY_FN_F4),
174 KEY(4, 2, KEY_MUTE),
175 KEY(4, 3, KEY_HOME),
176 KEY(4, 4, KEY_BACK),
177
178 KEY(5, 0, KEY_VOLUMEDOWN),
179 KEY(5, 1, KEY_VOLUMEUP),
180 KEY(5, 2, KEY_F1),
181 KEY(5, 3, KEY_F2),
182 KEY(5, 4, KEY_F3),
183};
184
185static const struct matrix_keymap_data keymap_data = {
186 .keymap = keymap,
187 .keymap_size = ARRAY_SIZE(keymap),
188};
189
190static struct matrix_keypad_platform_data keypad_config = {
191 .keymap_data = &keymap_data,
192 .num_row_gpios = 6,
193 .num_col_gpios = 5,
194 .debounce_ms = 0, /* minimum */
195 .active_low = 0, /* pull up realization */
196 .no_autorepeat = 0,
197};
198
144static struct tnetv107x_device_info evm_device_info __initconst = { 199static struct tnetv107x_device_info evm_device_info __initconst = {
145 .serial_config = &serial_config, 200 .serial_config = &serial_config,
146 .mmc_config[1] = &mmc_config, /* controller 1 */ 201 .mmc_config[1] = &mmc_config, /* controller 1 */
147 .nand_config[0] = &nand_config, /* chip select 0 */ 202 .nand_config[0] = &nand_config, /* chip select 0 */
203 .keypad_config = &keypad_config,
148}; 204};
149 205
150static __init void tnetv107x_evm_board_init(void) 206static __init void tnetv107x_evm_board_init(void)
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 054c303caead..01ba080433db 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -236,7 +236,7 @@ static int __init clk_disable_unused(void)
236 if (!davinci_psc_is_clk_active(ck->gpsc, ck->lpsc)) 236 if (!davinci_psc_is_clk_active(ck->gpsc, ck->lpsc))
237 continue; 237 continue;
238 238
239 pr_info("Clocks: disable unused %s\n", ck->name); 239 pr_debug("Clocks: disable unused %s\n", ck->name);
240 240
241 davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc, 241 davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc,
242 (ck->flags & PSC_SWRSTDISABLE) ? 242 (ck->flags & PSC_SWRSTDISABLE) ?
@@ -287,6 +287,79 @@ static unsigned long clk_sysclk_recalc(struct clk *clk)
287 return rate; 287 return rate;
288} 288}
289 289
290int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate)
291{
292 unsigned v;
293 struct pll_data *pll;
294 unsigned long input;
295 unsigned ratio = 0;
296
297 /* If this is the PLL base clock, wrong function to call */
298 if (clk->pll_data)
299 return -EINVAL;
300
301 /* There must be a parent... */
302 if (WARN_ON(!clk->parent))
303 return -EINVAL;
304
305 /* ... the parent must be a PLL... */
306 if (WARN_ON(!clk->parent->pll_data))
307 return -EINVAL;
308
309 /* ... and this clock must have a divider. */
310 if (WARN_ON(!clk->div_reg))
311 return -EINVAL;
312
313 pll = clk->parent->pll_data;
314
315 input = clk->parent->rate;
316
317 /* If pre-PLL, source clock is before the multiplier and divider(s) */
318 if (clk->flags & PRE_PLL)
319 input = pll->input_rate;
320
321 if (input > rate) {
322 /*
323 * Can afford to provide an output little higher than requested
324 * only if maximum rate supported by hardware on this sysclk
325 * is known.
326 */
327 if (clk->maxrate) {
328 ratio = DIV_ROUND_CLOSEST(input, rate);
329 if (input / ratio > clk->maxrate)
330 ratio = 0;
331 }
332
333 if (ratio == 0)
334 ratio = DIV_ROUND_UP(input, rate);
335
336 ratio--;
337 }
338
339 if (ratio > PLLDIV_RATIO_MASK)
340 return -EINVAL;
341
342 do {
343 v = __raw_readl(pll->base + PLLSTAT);
344 } while (v & PLLSTAT_GOSTAT);
345
346 v = __raw_readl(pll->base + clk->div_reg);
347 v &= ~PLLDIV_RATIO_MASK;
348 v |= ratio | PLLDIV_EN;
349 __raw_writel(v, pll->base + clk->div_reg);
350
351 v = __raw_readl(pll->base + PLLCMD);
352 v |= PLLCMD_GOSET;
353 __raw_writel(v, pll->base + PLLCMD);
354
355 do {
356 v = __raw_readl(pll->base + PLLSTAT);
357 } while (v & PLLSTAT_GOSTAT);
358
359 return 0;
360}
361EXPORT_SYMBOL(davinci_set_sysclk_rate);
362
290static unsigned long clk_leafclk_recalc(struct clk *clk) 363static unsigned long clk_leafclk_recalc(struct clk *clk)
291{ 364{
292 if (WARN_ON(!clk->parent)) 365 if (WARN_ON(!clk->parent))
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 01e36483ac3d..11099980b58b 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -70,6 +70,9 @@
70#include <linux/list.h> 70#include <linux/list.h>
71#include <asm/clkdev.h> 71#include <asm/clkdev.h>
72 72
73#define PLLSTAT_GOSTAT BIT(0)
74#define PLLCMD_GOSET BIT(0)
75
73struct pll_data { 76struct pll_data {
74 u32 phys_base; 77 u32 phys_base;
75 void __iomem *base; 78 void __iomem *base;
@@ -86,6 +89,7 @@ struct clk {
86 struct module *owner; 89 struct module *owner;
87 const char *name; 90 const char *name;
88 unsigned long rate; 91 unsigned long rate;
92 unsigned long maxrate; /* H/W supported max rate */
89 u8 usecount; 93 u8 usecount;
90 u8 lpsc; 94 u8 lpsc;
91 u8 gpsc; 95 u8 gpsc;
@@ -118,6 +122,7 @@ struct clk {
118int davinci_clk_init(struct clk_lookup *clocks); 122int davinci_clk_init(struct clk_lookup *clocks);
119int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, 123int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
120 unsigned int mult, unsigned int postdiv); 124 unsigned int mult, unsigned int postdiv);
125int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate);
121 126
122extern struct platform_device davinci_wdt_device; 127extern struct platform_device davinci_wdt_device;
123extern void davinci_watchdog_reset(struct platform_device *); 128extern void davinci_watchdog_reset(struct platform_device *);
diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c
index d3fa6de1e20f..343de73161fa 100644
--- a/arch/arm/mach-davinci/cpufreq.c
+++ b/arch/arm/mach-davinci/cpufreq.c
@@ -34,6 +34,8 @@
34struct davinci_cpufreq { 34struct davinci_cpufreq {
35 struct device *dev; 35 struct device *dev;
36 struct clk *armclk; 36 struct clk *armclk;
37 struct clk *asyncclk;
38 unsigned long asyncrate;
37}; 39};
38static struct davinci_cpufreq cpufreq; 40static struct davinci_cpufreq cpufreq;
39 41
@@ -104,15 +106,27 @@ static int davinci_target(struct cpufreq_policy *policy,
104 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 106 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
105 107
106 /* if moving to higher frequency, up the voltage beforehand */ 108 /* if moving to higher frequency, up the voltage beforehand */
107 if (pdata->set_voltage && freqs.new > freqs.old) 109 if (pdata->set_voltage && freqs.new > freqs.old) {
108 pdata->set_voltage(idx); 110 ret = pdata->set_voltage(idx);
111 if (ret)
112 goto out;
113 }
109 114
110 ret = clk_set_rate(armclk, idx); 115 ret = clk_set_rate(armclk, idx);
116 if (ret)
117 goto out;
118
119 if (cpufreq.asyncclk) {
120 ret = clk_set_rate(cpufreq.asyncclk, cpufreq.asyncrate);
121 if (ret)
122 goto out;
123 }
111 124
112 /* if moving to lower freq, lower the voltage after lowering freq */ 125 /* if moving to lower freq, lower the voltage after lowering freq */
113 if (pdata->set_voltage && freqs.new < freqs.old) 126 if (pdata->set_voltage && freqs.new < freqs.old)
114 pdata->set_voltage(idx); 127 pdata->set_voltage(idx);
115 128
129out:
116 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 130 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
117 131
118 return ret; 132 return ret;
@@ -185,6 +199,7 @@ static struct cpufreq_driver davinci_driver = {
185static int __init davinci_cpufreq_probe(struct platform_device *pdev) 199static int __init davinci_cpufreq_probe(struct platform_device *pdev)
186{ 200{
187 struct davinci_cpufreq_config *pdata = pdev->dev.platform_data; 201 struct davinci_cpufreq_config *pdata = pdev->dev.platform_data;
202 struct clk *asyncclk;
188 203
189 if (!pdata) 204 if (!pdata)
190 return -EINVAL; 205 return -EINVAL;
@@ -199,6 +214,12 @@ static int __init davinci_cpufreq_probe(struct platform_device *pdev)
199 return PTR_ERR(cpufreq.armclk); 214 return PTR_ERR(cpufreq.armclk);
200 } 215 }
201 216
217 asyncclk = clk_get(cpufreq.dev, "async");
218 if (!IS_ERR(asyncclk)) {
219 cpufreq.asyncclk = asyncclk;
220 cpufreq.asyncrate = clk_get_rate(asyncclk);
221 }
222
202 return cpufreq_register_driver(&davinci_driver); 223 return cpufreq_register_driver(&davinci_driver);
203} 224}
204 225
@@ -206,6 +227,9 @@ static int __exit davinci_cpufreq_remove(struct platform_device *pdev)
206{ 227{
207 clk_put(cpufreq.armclk); 228 clk_put(cpufreq.armclk);
208 229
230 if (cpufreq.asyncclk)
231 clk_put(cpufreq.asyncclk);
232
209 return cpufreq_unregister_driver(&davinci_driver); 233 return cpufreq_unregister_driver(&davinci_driver);
210} 234}
211 235
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 68ed58a48252..63916b902760 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -86,6 +86,8 @@ static struct clk pll0_sysclk3 = {
86 .parent = &pll0_clk, 86 .parent = &pll0_clk,
87 .flags = CLK_PLL, 87 .flags = CLK_PLL,
88 .div_reg = PLLDIV3, 88 .div_reg = PLLDIV3,
89 .set_rate = davinci_set_sysclk_rate,
90 .maxrate = 100000000,
89}; 91};
90 92
91static struct clk pll0_sysclk4 = { 93static struct clk pll0_sysclk4 = {
@@ -323,12 +325,19 @@ static struct clk lcdc_clk = {
323 .gpsc = 1, 325 .gpsc = 1,
324}; 326};
325 327
326static struct clk mmcsd_clk = { 328static struct clk mmcsd0_clk = {
327 .name = "mmcsd", 329 .name = "mmcsd0",
328 .parent = &pll0_sysclk2, 330 .parent = &pll0_sysclk2,
329 .lpsc = DA8XX_LPSC0_MMC_SD, 331 .lpsc = DA8XX_LPSC0_MMC_SD,
330}; 332};
331 333
334static struct clk mmcsd1_clk = {
335 .name = "mmcsd1",
336 .parent = &pll0_sysclk2,
337 .lpsc = DA850_LPSC1_MMC_SD1,
338 .gpsc = 1,
339};
340
332static struct clk aemif_clk = { 341static struct clk aemif_clk = {
333 .name = "aemif", 342 .name = "aemif",
334 .parent = &pll0_sysclk3, 343 .parent = &pll0_sysclk3,
@@ -375,7 +384,8 @@ static struct clk_lookup da850_clks[] = {
375 CLK("davinci_emac.1", NULL, &emac_clk), 384 CLK("davinci_emac.1", NULL, &emac_clk),
376 CLK("davinci-mcasp.0", NULL, &mcasp_clk), 385 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
377 CLK("da8xx_lcdc.0", NULL, &lcdc_clk), 386 CLK("da8xx_lcdc.0", NULL, &lcdc_clk),
378 CLK("davinci_mmc.0", NULL, &mmcsd_clk), 387 CLK("davinci_mmc.0", NULL, &mmcsd0_clk),
388 CLK("davinci_mmc.1", NULL, &mmcsd1_clk),
379 CLK(NULL, "aemif", &aemif_clk), 389 CLK(NULL, "aemif", &aemif_clk),
380 CLK(NULL, NULL, NULL), 390 CLK(NULL, NULL, NULL),
381}; 391};
@@ -572,15 +582,9 @@ const short da850_cpgmac_pins[] __initdata = {
572 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, 582 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
573 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, 583 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
574 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, 584 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
575 DA850_MDIO_D, 585 DA850_MDIO_D, DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
576 -1 586 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1, DA850_RMII_RXER,
577}; 587 DA850_RMII_MHZ_50_CLK,
578
579const short da850_rmii_pins[] __initdata = {
580 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
581 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
582 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
583 DA850_MDIO_D,
584 -1 588 -1
585}; 589};
586 590
@@ -607,27 +611,19 @@ const short da850_mmcsd0_pins[] __initdata = {
607 -1 611 -1
608}; 612};
609 613
610const short da850_nand_pins[] __initdata = { 614const short da850_emif25_pins[] __initdata = {
611 DA850_EMA_D_7, DA850_EMA_D_6, DA850_EMA_D_5, DA850_EMA_D_4,
612 DA850_EMA_D_3, DA850_EMA_D_2, DA850_EMA_D_1, DA850_EMA_D_0,
613 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
614 DA850_NEMA_WE, DA850_NEMA_OE,
615 -1
616};
617
618const short da850_nor_pins[] __initdata = {
619 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2, 615 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
620 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1, 616 DA850_NEMA_CS_3, DA850_NEMA_CS_4, DA850_NEMA_WE, DA850_NEMA_OE,
621 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5, 617 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
622 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9, 618 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
623 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13, 619 DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11,
624 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1, 620 DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15,
625 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5, 621 DA850_EMA_A_0, DA850_EMA_A_1, DA850_EMA_A_2, DA850_EMA_A_3,
626 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9, 622 DA850_EMA_A_4, DA850_EMA_A_5, DA850_EMA_A_6, DA850_EMA_A_7,
627 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13, 623 DA850_EMA_A_8, DA850_EMA_A_9, DA850_EMA_A_10, DA850_EMA_A_11,
628 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17, 624 DA850_EMA_A_12, DA850_EMA_A_13, DA850_EMA_A_14, DA850_EMA_A_15,
629 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21, 625 DA850_EMA_A_16, DA850_EMA_A_17, DA850_EMA_A_18, DA850_EMA_A_19,
630 DA850_EMA_A_22, DA850_EMA_A_23, 626 DA850_EMA_A_20, DA850_EMA_A_21, DA850_EMA_A_22, DA850_EMA_A_23,
631 -1 627 -1
632}; 628};
633 629
@@ -851,7 +847,7 @@ static const struct da850_opp da850_opp_300 = {
851 .prediv = 1, 847 .prediv = 1,
852 .mult = 25, 848 .mult = 25,
853 .postdiv = 2, 849 .postdiv = 2,
854 .cvdd_min = 1140000, 850 .cvdd_min = 1200000,
855 .cvdd_max = 1320000, 851 .cvdd_max = 1320000,
856}; 852};
857 853
@@ -860,7 +856,7 @@ static const struct da850_opp da850_opp_200 = {
860 .prediv = 1, 856 .prediv = 1,
861 .mult = 25, 857 .mult = 25,
862 .postdiv = 3, 858 .postdiv = 3,
863 .cvdd_min = 1050000, 859 .cvdd_min = 1100000,
864 .cvdd_max = 1160000, 860 .cvdd_max = 1160000,
865}; 861};
866 862
@@ -869,7 +865,7 @@ static const struct da850_opp da850_opp_96 = {
869 .prediv = 1, 865 .prediv = 1,
870 .mult = 20, 866 .mult = 20,
871 .postdiv = 5, 867 .postdiv = 5,
872 .cvdd_min = 950000, 868 .cvdd_min = 1000000,
873 .cvdd_max = 1050000, 869 .cvdd_max = 1050000,
874}; 870};
875 871
@@ -929,10 +925,16 @@ static struct platform_device da850_cpufreq_device = {
929 .dev = { 925 .dev = {
930 .platform_data = &cpufreq_info, 926 .platform_data = &cpufreq_info,
931 }, 927 },
928 .id = -1,
932}; 929};
933 930
934int __init da850_register_cpufreq(void) 931int __init da850_register_cpufreq(char *async_clk)
935{ 932{
933 /* cpufreq driver can help keep an "async" clock constant */
934 if (async_clk)
935 clk_add_alias("async", da850_cpufreq_device.name,
936 async_clk, NULL);
937
936 return platform_device_register(&da850_cpufreq_device); 938 return platform_device_register(&da850_cpufreq_device);
937} 939}
938 940
@@ -983,7 +985,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index)
983 return 0; 985 return 0;
984} 986}
985#else 987#else
986int __init da850_register_cpufreq(void) 988int __init da850_register_cpufreq(char *async_clk)
987{ 989{
988 return 0; 990 return 0;
989} 991}
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index 52bc7b1c6ca3..9eec63070e0c 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -24,6 +24,7 @@
24#include "clock.h" 24#include "clock.h"
25 25
26#define DA8XX_TPCC_BASE 0x01c00000 26#define DA8XX_TPCC_BASE 0x01c00000
27#define DA850_MMCSD1_BASE 0x01e1b000
27#define DA850_TPCC1_BASE 0x01e30000 28#define DA850_TPCC1_BASE 0x01e30000
28#define DA8XX_TPTC0_BASE 0x01c08000 29#define DA8XX_TPTC0_BASE 0x01c08000
29#define DA8XX_TPTC1_BASE 0x01c08400 30#define DA8XX_TPTC1_BASE 0x01c08400
@@ -41,7 +42,6 @@
41#define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000 42#define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000
42#define DA8XX_EMAC_MOD_REG_OFFSET 0x2000 43#define DA8XX_EMAC_MOD_REG_OFFSET 0x2000
43#define DA8XX_EMAC_RAM_OFFSET 0x0000 44#define DA8XX_EMAC_RAM_OFFSET 0x0000
44#define DA8XX_MDIO_REG_OFFSET 0x4000
45#define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K 45#define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K
46 46
47void __iomem *da8xx_syscfg0_base; 47void __iomem *da8xx_syscfg0_base;
@@ -351,7 +351,7 @@ int __init da8xx_register_watchdog(void)
351static struct resource da8xx_emac_resources[] = { 351static struct resource da8xx_emac_resources[] = {
352 { 352 {
353 .start = DA8XX_EMAC_CPPI_PORT_BASE, 353 .start = DA8XX_EMAC_CPPI_PORT_BASE,
354 .end = DA8XX_EMAC_CPPI_PORT_BASE + 0x5000 - 1, 354 .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1,
355 .flags = IORESOURCE_MEM, 355 .flags = IORESOURCE_MEM,
356 }, 356 },
357 { 357 {
@@ -380,7 +380,6 @@ struct emac_platform_data da8xx_emac_pdata = {
380 .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET, 380 .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET,
381 .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET, 381 .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET,
382 .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET, 382 .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET,
383 .mdio_reg_offset = DA8XX_MDIO_REG_OFFSET,
384 .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE, 383 .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE,
385 .version = EMAC_VERSION_2, 384 .version = EMAC_VERSION_2,
386}; 385};
@@ -395,9 +394,34 @@ static struct platform_device da8xx_emac_device = {
395 .resource = da8xx_emac_resources, 394 .resource = da8xx_emac_resources,
396}; 395};
397 396
397static struct resource da8xx_mdio_resources[] = {
398 {
399 .start = DA8XX_EMAC_MDIO_BASE,
400 .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1,
401 .flags = IORESOURCE_MEM,
402 },
403};
404
405static struct platform_device da8xx_mdio_device = {
406 .name = "davinci_mdio",
407 .id = 0,
408 .num_resources = ARRAY_SIZE(da8xx_mdio_resources),
409 .resource = da8xx_mdio_resources,
410};
411
398int __init da8xx_register_emac(void) 412int __init da8xx_register_emac(void)
399{ 413{
400 return platform_device_register(&da8xx_emac_device); 414 int ret;
415
416 ret = platform_device_register(&da8xx_mdio_device);
417 if (ret < 0)
418 return ret;
419 ret = platform_device_register(&da8xx_emac_device);
420 if (ret < 0)
421 return ret;
422 ret = clk_add_alias(NULL, dev_name(&da8xx_mdio_device.dev),
423 NULL, &da8xx_emac_device.dev);
424 return ret;
401} 425}
402 426
403static struct resource da830_mcasp1_resources[] = { 427static struct resource da830_mcasp1_resources[] = {
@@ -566,6 +590,44 @@ int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config)
566 return platform_device_register(&da8xx_mmcsd0_device); 590 return platform_device_register(&da8xx_mmcsd0_device);
567} 591}
568 592
593#ifdef CONFIG_ARCH_DAVINCI_DA850
594static struct resource da850_mmcsd1_resources[] = {
595 { /* registers */
596 .start = DA850_MMCSD1_BASE,
597 .end = DA850_MMCSD1_BASE + SZ_4K - 1,
598 .flags = IORESOURCE_MEM,
599 },
600 { /* interrupt */
601 .start = IRQ_DA850_MMCSDINT0_1,
602 .end = IRQ_DA850_MMCSDINT0_1,
603 .flags = IORESOURCE_IRQ,
604 },
605 { /* DMA RX */
606 .start = EDMA_CTLR_CHAN(1, 28),
607 .end = EDMA_CTLR_CHAN(1, 28),
608 .flags = IORESOURCE_DMA,
609 },
610 { /* DMA TX */
611 .start = EDMA_CTLR_CHAN(1, 29),
612 .end = EDMA_CTLR_CHAN(1, 29),
613 .flags = IORESOURCE_DMA,
614 },
615};
616
617static struct platform_device da850_mmcsd1_device = {
618 .name = "davinci_mmc",
619 .id = 1,
620 .num_resources = ARRAY_SIZE(da850_mmcsd1_resources),
621 .resource = da850_mmcsd1_resources,
622};
623
624int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
625{
626 da850_mmcsd1_device.dev.platform_data = config;
627 return platform_device_register(&da850_mmcsd1_device);
628}
629#endif
630
569static struct resource da8xx_rtc_resources[] = { 631static struct resource da8xx_rtc_resources[] = {
570 { 632 {
571 .start = DA8XX_RTC_BASE, 633 .start = DA8XX_RTC_BASE,
diff --git a/arch/arm/mach-davinci/devices-tnetv107x.c b/arch/arm/mach-davinci/devices-tnetv107x.c
index 2718a3a90dff..c9a86d8130d1 100644
--- a/arch/arm/mach-davinci/devices-tnetv107x.c
+++ b/arch/arm/mach-davinci/devices-tnetv107x.c
@@ -31,8 +31,10 @@
31#define TNETV107X_TPTC0_BASE 0x01c10000 31#define TNETV107X_TPTC0_BASE 0x01c10000
32#define TNETV107X_TPTC1_BASE 0x01c10400 32#define TNETV107X_TPTC1_BASE 0x01c10400
33#define TNETV107X_WDOG_BASE 0x08086700 33#define TNETV107X_WDOG_BASE 0x08086700
34#define TNETV107X_TSC_BASE 0x08088500
34#define TNETV107X_SDIO0_BASE 0x08088700 35#define TNETV107X_SDIO0_BASE 0x08088700
35#define TNETV107X_SDIO1_BASE 0x08088800 36#define TNETV107X_SDIO1_BASE 0x08088800
37#define TNETV107X_KEYPAD_BASE 0x08088a00
36#define TNETV107X_ASYNC_EMIF_CNTRL_BASE 0x08200000 38#define TNETV107X_ASYNC_EMIF_CNTRL_BASE 0x08200000
37#define TNETV107X_ASYNC_EMIF_DATA_CE0_BASE 0x30000000 39#define TNETV107X_ASYNC_EMIF_DATA_CE0_BASE 0x30000000
38#define TNETV107X_ASYNC_EMIF_DATA_CE1_BASE 0x40000000 40#define TNETV107X_ASYNC_EMIF_DATA_CE1_BASE 0x40000000
@@ -298,12 +300,55 @@ static int __init nand_init(int chipsel, struct davinci_nand_pdata *data)
298 return platform_device_register(pdev); 300 return platform_device_register(pdev);
299} 301}
300 302
303static struct resource keypad_resources[] = {
304 {
305 .start = TNETV107X_KEYPAD_BASE,
306 .end = TNETV107X_KEYPAD_BASE + 0xff,
307 .flags = IORESOURCE_MEM,
308 },
309 {
310 .start = IRQ_TNETV107X_KEYPAD,
311 .flags = IORESOURCE_IRQ,
312 .name = "press",
313 },
314 {
315 .start = IRQ_TNETV107X_KEYPAD_FREE,
316 .flags = IORESOURCE_IRQ,
317 .name = "release",
318 },
319};
320
321static struct platform_device keypad_device = {
322 .name = "tnetv107x-keypad",
323 .num_resources = ARRAY_SIZE(keypad_resources),
324 .resource = keypad_resources,
325};
326
327static struct resource tsc_resources[] = {
328 {
329 .start = TNETV107X_TSC_BASE,
330 .end = TNETV107X_TSC_BASE + 0xff,
331 .flags = IORESOURCE_MEM,
332 },
333 {
334 .start = IRQ_TNETV107X_TSC,
335 .flags = IORESOURCE_IRQ,
336 },
337};
338
339static struct platform_device tsc_device = {
340 .name = "tnetv107x-ts",
341 .num_resources = ARRAY_SIZE(tsc_resources),
342 .resource = tsc_resources,
343};
344
301void __init tnetv107x_devices_init(struct tnetv107x_device_info *info) 345void __init tnetv107x_devices_init(struct tnetv107x_device_info *info)
302{ 346{
303 int i; 347 int i;
304 348
305 platform_device_register(&edma_device); 349 platform_device_register(&edma_device);
306 platform_device_register(&tnetv107x_wdt_device); 350 platform_device_register(&tnetv107x_wdt_device);
351 platform_device_register(&tsc_device);
307 352
308 if (info->serial_config) 353 if (info->serial_config)
309 davinci_serial_init(info->serial_config); 354 davinci_serial_init(info->serial_config);
@@ -317,4 +362,9 @@ void __init tnetv107x_devices_init(struct tnetv107x_device_info *info)
317 for (i = 0; i < 4; i++) 362 for (i = 0; i < 4; i++)
318 if (info->nand_config[i]) 363 if (info->nand_config[i])
319 nand_init(i, info->nand_config[i]); 364 nand_init(i, info->nand_config[i]);
365
366 if (info->keypad_config) {
367 keypad_device.dev.platform_data = info->keypad_config;
368 platform_device_register(&keypad_device);
369 }
320} 370}
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index 8b7201e4c79c..22ebc64bc9d9 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -213,7 +213,7 @@ void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
213 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c); 213 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c);
214 214
215 /* Configure pull down control */ 215 /* Configure pull down control */
216 __raw_writel((__raw_readl(pupdctl1) & ~0x400), 216 __raw_writel((__raw_readl(pupdctl1) & ~0xfc0),
217 pupdctl1); 217 pupdctl1);
218 218
219 mmcsd1_resources[0].start = DM365_MMCSD1_BASE; 219 mmcsd1_resources[0].start = DM365_MMCSD1_BASE;
@@ -295,6 +295,18 @@ static void davinci_init_wdt(void)
295 295
296/*-------------------------------------------------------------------------*/ 296/*-------------------------------------------------------------------------*/
297 297
298struct platform_device davinci_pcm_device = {
299 .name = "davinci-pcm-audio",
300 .id = -1,
301};
302
303static void davinci_init_pcm(void)
304{
305 platform_device_register(&davinci_pcm_device);
306}
307
308/*-------------------------------------------------------------------------*/
309
298struct davinci_timer_instance davinci_timer_instance[2] = { 310struct davinci_timer_instance davinci_timer_instance[2] = {
299 { 311 {
300 .base = DAVINCI_TIMER0_BASE, 312 .base = DAVINCI_TIMER0_BASE,
@@ -315,6 +327,7 @@ static int __init davinci_init_devices(void)
315 /* please keep these calls, and their implementations above, 327 /* please keep these calls, and their implementations above,
316 * in alphabetical order so they're easier to sort through. 328 * in alphabetical order so they're easier to sort through.
317 */ 329 */
330 davinci_init_pcm();
318 davinci_init_wdt(); 331 davinci_init_wdt();
319 332
320 return 0; 333 return 0;
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 7781e35daec3..a12065e87266 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -691,7 +691,6 @@ static struct emac_platform_data dm365_emac_pdata = {
691 .ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET, 691 .ctrl_reg_offset = DM365_EMAC_CNTRL_OFFSET,
692 .ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET, 692 .ctrl_mod_reg_offset = DM365_EMAC_CNTRL_MOD_OFFSET,
693 .ctrl_ram_offset = DM365_EMAC_CNTRL_RAM_OFFSET, 693 .ctrl_ram_offset = DM365_EMAC_CNTRL_RAM_OFFSET,
694 .mdio_reg_offset = DM365_EMAC_MDIO_OFFSET,
695 .ctrl_ram_size = DM365_EMAC_CNTRL_RAM_SIZE, 694 .ctrl_ram_size = DM365_EMAC_CNTRL_RAM_SIZE,
696 .version = EMAC_VERSION_2, 695 .version = EMAC_VERSION_2,
697}; 696};
@@ -699,7 +698,7 @@ static struct emac_platform_data dm365_emac_pdata = {
699static struct resource dm365_emac_resources[] = { 698static struct resource dm365_emac_resources[] = {
700 { 699 {
701 .start = DM365_EMAC_BASE, 700 .start = DM365_EMAC_BASE,
702 .end = DM365_EMAC_BASE + 0x47ff, 701 .end = DM365_EMAC_BASE + SZ_16K - 1,
703 .flags = IORESOURCE_MEM, 702 .flags = IORESOURCE_MEM,
704 }, 703 },
705 { 704 {
@@ -734,6 +733,21 @@ static struct platform_device dm365_emac_device = {
734 .resource = dm365_emac_resources, 733 .resource = dm365_emac_resources,
735}; 734};
736 735
736static struct resource dm365_mdio_resources[] = {
737 {
738 .start = DM365_EMAC_MDIO_BASE,
739 .end = DM365_EMAC_MDIO_BASE + SZ_4K - 1,
740 .flags = IORESOURCE_MEM,
741 },
742};
743
744static struct platform_device dm365_mdio_device = {
745 .name = "davinci_mdio",
746 .id = 0,
747 .num_resources = ARRAY_SIZE(dm365_mdio_resources),
748 .resource = dm365_mdio_resources,
749};
750
737static u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = { 751static u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = {
738 [IRQ_VDINT0] = 2, 752 [IRQ_VDINT0] = 2,
739 [IRQ_VDINT1] = 6, 753 [IRQ_VDINT1] = 6,
@@ -1219,7 +1233,12 @@ static int __init dm365_init_devices(void)
1219 1233
1220 davinci_cfg_reg(DM365_INT_EDMA_CC); 1234 davinci_cfg_reg(DM365_INT_EDMA_CC);
1221 platform_device_register(&dm365_edma_device); 1235 platform_device_register(&dm365_edma_device);
1236
1237 platform_device_register(&dm365_mdio_device);
1222 platform_device_register(&dm365_emac_device); 1238 platform_device_register(&dm365_emac_device);
1239 clk_add_alias(NULL, dev_name(&dm365_mdio_device.dev),
1240 NULL, &dm365_emac_device.dev);
1241
1223 /* Add isif clock alias */ 1242 /* Add isif clock alias */
1224 clk_add_alias("master", dm365_isif_dev.name, "vpss_master", NULL); 1243 clk_add_alias("master", dm365_isif_dev.name, "vpss_master", NULL);
1225 platform_device_register(&dm365_vpss_device); 1244 platform_device_register(&dm365_vpss_device);
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 5e5b0a7831fb..0608dd776a16 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -322,7 +322,6 @@ static struct emac_platform_data dm644x_emac_pdata = {
322 .ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET, 322 .ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET,
323 .ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET, 323 .ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET,
324 .ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET, 324 .ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET,
325 .mdio_reg_offset = DM644X_EMAC_MDIO_OFFSET,
326 .ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE, 325 .ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE,
327 .version = EMAC_VERSION_1, 326 .version = EMAC_VERSION_1,
328}; 327};
@@ -330,7 +329,7 @@ static struct emac_platform_data dm644x_emac_pdata = {
330static struct resource dm644x_emac_resources[] = { 329static struct resource dm644x_emac_resources[] = {
331 { 330 {
332 .start = DM644X_EMAC_BASE, 331 .start = DM644X_EMAC_BASE,
333 .end = DM644X_EMAC_BASE + 0x47ff, 332 .end = DM644X_EMAC_BASE + SZ_16K - 1,
334 .flags = IORESOURCE_MEM, 333 .flags = IORESOURCE_MEM,
335 }, 334 },
336 { 335 {
@@ -350,6 +349,21 @@ static struct platform_device dm644x_emac_device = {
350 .resource = dm644x_emac_resources, 349 .resource = dm644x_emac_resources,
351}; 350};
352 351
352static struct resource dm644x_mdio_resources[] = {
353 {
354 .start = DM644X_EMAC_MDIO_BASE,
355 .end = DM644X_EMAC_MDIO_BASE + SZ_4K - 1,
356 .flags = IORESOURCE_MEM,
357 },
358};
359
360static struct platform_device dm644x_mdio_device = {
361 .name = "davinci_mdio",
362 .id = 0,
363 .num_resources = ARRAY_SIZE(dm644x_mdio_resources),
364 .resource = dm644x_mdio_resources,
365};
366
353/* 367/*
354 * Device specific mux setup 368 * Device specific mux setup
355 * 369 *
@@ -776,7 +790,12 @@ static int __init dm644x_init_devices(void)
776 clk_add_alias("master", dm644x_ccdc_dev.name, "vpss_master", NULL); 790 clk_add_alias("master", dm644x_ccdc_dev.name, "vpss_master", NULL);
777 clk_add_alias("slave", dm644x_ccdc_dev.name, "vpss_slave", NULL); 791 clk_add_alias("slave", dm644x_ccdc_dev.name, "vpss_slave", NULL);
778 platform_device_register(&dm644x_edma_device); 792 platform_device_register(&dm644x_edma_device);
793
794 platform_device_register(&dm644x_mdio_device);
779 platform_device_register(&dm644x_emac_device); 795 platform_device_register(&dm644x_emac_device);
796 clk_add_alias(NULL, dev_name(&dm644x_mdio_device.dev),
797 NULL, &dm644x_emac_device.dev);
798
780 platform_device_register(&dm644x_vpss_device); 799 platform_device_register(&dm644x_vpss_device);
781 platform_device_register(&dm644x_ccdc_dev); 800 platform_device_register(&dm644x_ccdc_dev);
782 platform_device_register(&vpfe_capture_dev); 801 platform_device_register(&vpfe_capture_dev);
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 26e8a9c7f50b..1e0f809644bb 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -358,7 +358,6 @@ static struct emac_platform_data dm646x_emac_pdata = {
358 .ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET, 358 .ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET,
359 .ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET, 359 .ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET,
360 .ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET, 360 .ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET,
361 .mdio_reg_offset = DM646X_EMAC_MDIO_OFFSET,
362 .ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE, 361 .ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE,
363 .version = EMAC_VERSION_2, 362 .version = EMAC_VERSION_2,
364}; 363};
@@ -366,7 +365,7 @@ static struct emac_platform_data dm646x_emac_pdata = {
366static struct resource dm646x_emac_resources[] = { 365static struct resource dm646x_emac_resources[] = {
367 { 366 {
368 .start = DM646X_EMAC_BASE, 367 .start = DM646X_EMAC_BASE,
369 .end = DM646X_EMAC_BASE + 0x47ff, 368 .end = DM646X_EMAC_BASE + SZ_16K - 1,
370 .flags = IORESOURCE_MEM, 369 .flags = IORESOURCE_MEM,
371 }, 370 },
372 { 371 {
@@ -401,6 +400,21 @@ static struct platform_device dm646x_emac_device = {
401 .resource = dm646x_emac_resources, 400 .resource = dm646x_emac_resources,
402}; 401};
403 402
403static struct resource dm646x_mdio_resources[] = {
404 {
405 .start = DM646X_EMAC_MDIO_BASE,
406 .end = DM646X_EMAC_MDIO_BASE + SZ_4K - 1,
407 .flags = IORESOURCE_MEM,
408 },
409};
410
411static struct platform_device dm646x_mdio_device = {
412 .name = "davinci_mdio",
413 .id = 0,
414 .num_resources = ARRAY_SIZE(dm646x_mdio_resources),
415 .resource = dm646x_mdio_resources,
416};
417
404/* 418/*
405 * Device specific mux setup 419 * Device specific mux setup
406 * 420 *
@@ -896,7 +910,11 @@ static int __init dm646x_init_devices(void)
896 if (!cpu_is_davinci_dm646x()) 910 if (!cpu_is_davinci_dm646x())
897 return 0; 911 return 0;
898 912
913 platform_device_register(&dm646x_mdio_device);
899 platform_device_register(&dm646x_emac_device); 914 platform_device_register(&dm646x_emac_device);
915 clk_add_alias(NULL, dev_name(&dm646x_mdio_device.dev),
916 NULL, &dm646x_emac_device.dev);
917
900 return 0; 918 return 0;
901} 919}
902postcore_initcall(dm646x_init_devices); 920postcore_initcall(dm646x_init_devices);
diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c
index 2ede598b77dd..6b9669869c46 100644
--- a/arch/arm/mach-davinci/dma.c
+++ b/arch/arm/mach-davinci/dma.c
@@ -354,10 +354,12 @@ static int irq2ctlr(int irq)
354static irqreturn_t dma_irq_handler(int irq, void *data) 354static irqreturn_t dma_irq_handler(int irq, void *data)
355{ 355{
356 int i; 356 int i;
357 unsigned ctlr; 357 int ctlr;
358 unsigned int cnt = 0; 358 unsigned int cnt = 0;
359 359
360 ctlr = irq2ctlr(irq); 360 ctlr = irq2ctlr(irq);
361 if (ctlr < 0)
362 return IRQ_NONE;
361 363
362 dev_dbg(data, "dma_irq_handler\n"); 364 dev_dbg(data, "dma_irq_handler\n");
363 365
@@ -408,10 +410,12 @@ static irqreturn_t dma_irq_handler(int irq, void *data)
408static irqreturn_t dma_ccerr_handler(int irq, void *data) 410static irqreturn_t dma_ccerr_handler(int irq, void *data)
409{ 411{
410 int i; 412 int i;
411 unsigned ctlr; 413 int ctlr;
412 unsigned int cnt = 0; 414 unsigned int cnt = 0;
413 415
414 ctlr = irq2ctlr(irq); 416 ctlr = irq2ctlr(irq);
417 if (ctlr < 0)
418 return IRQ_NONE;
415 419
416 dev_dbg(data, "dma_ccerr_handler\n"); 420 dev_dbg(data, "dma_ccerr_handler\n");
417 421
diff --git a/arch/arm/mach-davinci/include/mach/aemif.h b/arch/arm/mach-davinci/include/mach/aemif.h
new file mode 100644
index 000000000000..05b293443097
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/aemif.h
@@ -0,0 +1,36 @@
1/*
2 * TI DaVinci AEMIF support
3 *
4 * Copyright 2010 (C) Texas Instruments, Inc. http://www.ti.com/
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10#ifndef _MACH_DAVINCI_AEMIF_H
11#define _MACH_DAVINCI_AEMIF_H
12
13#define NRCSR_OFFSET 0x00
14#define AWCCR_OFFSET 0x04
15#define A1CR_OFFSET 0x10
16
17#define ACR_ASIZE_MASK 0x3
18#define ACR_EW_MASK BIT(30)
19#define ACR_SS_MASK BIT(31)
20
21/* All timings in nanoseconds */
22struct davinci_aemif_timing {
23 u8 wsetup;
24 u8 wstrobe;
25 u8 whold;
26
27 u8 rsetup;
28 u8 rstrobe;
29 u8 rhold;
30
31 u8 ta;
32};
33
34int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,
35 void __iomem *base, unsigned cs);
36#endif
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
index 3c07059f526e..4247b3f53b33 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -76,9 +76,10 @@ int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
76int da8xx_register_emac(void); 76int da8xx_register_emac(void);
77int da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata); 77int da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata);
78int da8xx_register_mmcsd0(struct davinci_mmc_config *config); 78int da8xx_register_mmcsd0(struct davinci_mmc_config *config);
79int da850_register_mmcsd1(struct davinci_mmc_config *config);
79void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata); 80void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata);
80int da8xx_register_rtc(void); 81int da8xx_register_rtc(void);
81int da850_register_cpufreq(void); 82int da850_register_cpufreq(char *async_clk);
82int da8xx_register_cpuidle(void); 83int da8xx_register_cpuidle(void);
83void __iomem * __init da8xx_get_mem_ctlr(void); 84void __iomem * __init da8xx_get_mem_ctlr(void);
84int da850_register_pm(struct platform_device *pdev); 85int da850_register_pm(struct platform_device *pdev);
@@ -121,11 +122,9 @@ extern const short da850_uart2_pins[];
121extern const short da850_i2c0_pins[]; 122extern const short da850_i2c0_pins[];
122extern const short da850_i2c1_pins[]; 123extern const short da850_i2c1_pins[];
123extern const short da850_cpgmac_pins[]; 124extern const short da850_cpgmac_pins[];
124extern const short da850_rmii_pins[];
125extern const short da850_mcasp_pins[]; 125extern const short da850_mcasp_pins[];
126extern const short da850_lcdcntl_pins[]; 126extern const short da850_lcdcntl_pins[];
127extern const short da850_mmcsd0_pins[]; 127extern const short da850_mmcsd0_pins[];
128extern const short da850_nand_pins[]; 128extern const short da850_emif25_pins[];
129extern const short da850_nor_pins[];
130 129
131#endif /* __ASM_ARCH_DAVINCI_DA8XX_H */ 130#endif /* __ASM_ARCH_DAVINCI_DA8XX_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h
index ea5df3b49ec4..2563bf4e93a1 100644
--- a/arch/arm/mach-davinci/include/mach/dm365.h
+++ b/arch/arm/mach-davinci/include/mach/dm365.h
@@ -21,10 +21,10 @@
21#include <media/davinci/vpfe_capture.h> 21#include <media/davinci/vpfe_capture.h>
22 22
23#define DM365_EMAC_BASE (0x01D07000) 23#define DM365_EMAC_BASE (0x01D07000)
24#define DM365_EMAC_MDIO_BASE (DM365_EMAC_BASE + 0x4000)
24#define DM365_EMAC_CNTRL_OFFSET (0x0000) 25#define DM365_EMAC_CNTRL_OFFSET (0x0000)
25#define DM365_EMAC_CNTRL_MOD_OFFSET (0x3000) 26#define DM365_EMAC_CNTRL_MOD_OFFSET (0x3000)
26#define DM365_EMAC_CNTRL_RAM_OFFSET (0x1000) 27#define DM365_EMAC_CNTRL_RAM_OFFSET (0x1000)
27#define DM365_EMAC_MDIO_OFFSET (0x4000)
28#define DM365_EMAC_CNTRL_RAM_SIZE (0x2000) 28#define DM365_EMAC_CNTRL_RAM_SIZE (0x2000)
29 29
30/* Base of key scan register bank */ 30/* Base of key scan register bank */
diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h
index 6fca568a0fd2..5a1b26d4e68b 100644
--- a/arch/arm/mach-davinci/include/mach/dm644x.h
+++ b/arch/arm/mach-davinci/include/mach/dm644x.h
@@ -28,10 +28,10 @@
28#include <media/davinci/vpfe_capture.h> 28#include <media/davinci/vpfe_capture.h>
29 29
30#define DM644X_EMAC_BASE (0x01C80000) 30#define DM644X_EMAC_BASE (0x01C80000)
31#define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
31#define DM644X_EMAC_CNTRL_OFFSET (0x0000) 32#define DM644X_EMAC_CNTRL_OFFSET (0x0000)
32#define DM644X_EMAC_CNTRL_MOD_OFFSET (0x1000) 33#define DM644X_EMAC_CNTRL_MOD_OFFSET (0x1000)
33#define DM644X_EMAC_CNTRL_RAM_OFFSET (0x2000) 34#define DM644X_EMAC_CNTRL_RAM_OFFSET (0x2000)
34#define DM644X_EMAC_MDIO_OFFSET (0x4000)
35#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000) 35#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000)
36 36
37#define DM644X_ASYNC_EMIF_CONTROL_BASE 0x01E00000 37#define DM644X_ASYNC_EMIF_CONTROL_BASE 0x01E00000
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h
index 0a27ee9a70e1..7a27f3f13913 100644
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ b/arch/arm/mach-davinci/include/mach/dm646x.h
@@ -19,10 +19,10 @@
19#include <linux/davinci_emac.h> 19#include <linux/davinci_emac.h>
20 20
21#define DM646X_EMAC_BASE (0x01C80000) 21#define DM646X_EMAC_BASE (0x01C80000)
22#define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
22#define DM646X_EMAC_CNTRL_OFFSET (0x0000) 23#define DM646X_EMAC_CNTRL_OFFSET (0x0000)
23#define DM646X_EMAC_CNTRL_MOD_OFFSET (0x1000) 24#define DM646X_EMAC_CNTRL_MOD_OFFSET (0x1000)
24#define DM646X_EMAC_CNTRL_RAM_OFFSET (0x2000) 25#define DM646X_EMAC_CNTRL_RAM_OFFSET (0x2000)
25#define DM646X_EMAC_MDIO_OFFSET (0x4000)
26#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000) 26#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000)
27 27
28#define DM646X_ASYNC_EMIF_CONTROL_BASE 0x20008000 28#define DM646X_ASYNC_EMIF_CONTROL_BASE 0x20008000
diff --git a/arch/arm/mach-davinci/include/mach/nand.h b/arch/arm/mach-davinci/include/mach/nand.h
index b2ad8090bd10..025151049f05 100644
--- a/arch/arm/mach-davinci/include/mach/nand.h
+++ b/arch/arm/mach-davinci/include/mach/nand.h
@@ -30,9 +30,6 @@
30 30
31#include <linux/mtd/nand.h> 31#include <linux/mtd/nand.h>
32 32
33#define NRCSR_OFFSET 0x00
34#define AWCCR_OFFSET 0x04
35#define A1CR_OFFSET 0x10
36#define NANDFCR_OFFSET 0x60 33#define NANDFCR_OFFSET 0x60
37#define NANDFSR_OFFSET 0x64 34#define NANDFSR_OFFSET 0x64
38#define NANDF1ECC_OFFSET 0x70 35#define NANDF1ECC_OFFSET 0x70
@@ -83,6 +80,9 @@ struct davinci_nand_pdata { /* platform_data */
83 /* Main and mirror bbt descriptor overrides */ 80 /* Main and mirror bbt descriptor overrides */
84 struct nand_bbt_descr *bbt_td; 81 struct nand_bbt_descr *bbt_td;
85 struct nand_bbt_descr *bbt_md; 82 struct nand_bbt_descr *bbt_md;
83
84 /* Access timings */
85 struct davinci_aemif_timing *timing;
86}; 86};
87 87
88#endif /* __ARCH_ARM_DAVINCI_NAND_H */ 88#endif /* __ARCH_ARM_DAVINCI_NAND_H */
diff --git a/arch/arm/mach-davinci/include/mach/psc.h b/arch/arm/mach-davinci/include/mach/psc.h
index 983da6e4554c..62b0858f68ca 100644
--- a/arch/arm/mach-davinci/include/mach/psc.h
+++ b/arch/arm/mach-davinci/include/mach/psc.h
@@ -172,6 +172,7 @@
172#define DA8XX_LPSC1_UART2 13 172#define DA8XX_LPSC1_UART2 13
173#define DA8XX_LPSC1_LCDC 16 173#define DA8XX_LPSC1_LCDC 16
174#define DA8XX_LPSC1_PWM 17 174#define DA8XX_LPSC1_PWM 17
175#define DA850_LPSC1_MMC_SD1 18
175#define DA8XX_LPSC1_ECAP 20 176#define DA8XX_LPSC1_ECAP 20
176#define DA830_LPSC1_EQEP 21 177#define DA830_LPSC1_EQEP 21
177#define DA850_LPSC1_TPTC2 21 178#define DA850_LPSC1_TPTC2 21
diff --git a/arch/arm/mach-davinci/include/mach/tnetv107x.h b/arch/arm/mach-davinci/include/mach/tnetv107x.h
index c72064733123..5a681d880dcb 100644
--- a/arch/arm/mach-davinci/include/mach/tnetv107x.h
+++ b/arch/arm/mach-davinci/include/mach/tnetv107x.h
@@ -33,6 +33,8 @@
33#ifndef __ASSEMBLY__ 33#ifndef __ASSEMBLY__
34 34
35#include <linux/serial_8250.h> 35#include <linux/serial_8250.h>
36#include <linux/input/matrix_keypad.h>
37
36#include <mach/mmc.h> 38#include <mach/mmc.h>
37#include <mach/nand.h> 39#include <mach/nand.h>
38#include <mach/serial.h> 40#include <mach/serial.h>
@@ -41,6 +43,7 @@ struct tnetv107x_device_info {
41 struct davinci_uart_config *serial_config; 43 struct davinci_uart_config *serial_config;
42 struct davinci_mmc_config *mmc_config[2]; /* 2 controllers */ 44 struct davinci_mmc_config *mmc_config[2]; /* 2 controllers */
43 struct davinci_nand_pdata *nand_config[4]; /* 4 chipsels */ 45 struct davinci_nand_pdata *nand_config[4]; /* 4 chipsels */
46 struct matrix_keypad_platform_data *keypad_config;
44}; 47};
45 48
46extern struct platform_device tnetv107x_wdt_device; 49extern struct platform_device tnetv107x_wdt_device;
diff --git a/arch/arm/mach-davinci/include/mach/uncompress.h b/arch/arm/mach-davinci/include/mach/uncompress.h
index 15a6192ad6eb..47723e8d75a4 100644
--- a/arch/arm/mach-davinci/include/mach/uncompress.h
+++ b/arch/arm/mach-davinci/include/mach/uncompress.h
@@ -88,6 +88,8 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
88 /* DA8xx boards */ 88 /* DA8xx boards */
89 DEBUG_LL_DA8XX(davinci_da830_evm, 2); 89 DEBUG_LL_DA8XX(davinci_da830_evm, 2);
90 DEBUG_LL_DA8XX(davinci_da850_evm, 2); 90 DEBUG_LL_DA8XX(davinci_da850_evm, 2);
91 DEBUG_LL_DA8XX(mityomapl138, 1);
92 DEBUG_LL_DA8XX(omapl138_hawkboard, 2);
91 93
92 /* TNETV107x boards */ 94 /* TNETV107x boards */
93 DEBUG_LL_TNETV107X(tnetv107x, 1); 95 DEBUG_LL_TNETV107X(tnetv107x, 1);
diff --git a/arch/arm/mach-davinci/tnetv107x.c b/arch/arm/mach-davinci/tnetv107x.c
index 864e60482c53..daeae06430b9 100644
--- a/arch/arm/mach-davinci/tnetv107x.c
+++ b/arch/arm/mach-davinci/tnetv107x.c
@@ -104,7 +104,7 @@ static u32 pll_ext_freq[] = {
104}; 104};
105 105
106/* PSC control registers */ 106/* PSC control registers */
107static u32 psc_regs[] __initconst = { TNETV107X_PSC_BASE }; 107static u32 psc_regs[] = { TNETV107X_PSC_BASE };
108 108
109/* Host map for interrupt controller */ 109/* Host map for interrupt controller */
110static u32 intc_host_map[] = { 0x01010000, 0x01010101, -1 }; 110static u32 intc_host_map[] = { 0x01010000, 0x01010101, -1 };
@@ -581,7 +581,14 @@ static struct davinci_id ids[] = {
581 .part_no = 0xb8a1, 581 .part_no = 0xb8a1,
582 .manufacturer = 0x017, 582 .manufacturer = 0x017,
583 .cpu_id = DAVINCI_CPU_ID_TNETV107X, 583 .cpu_id = DAVINCI_CPU_ID_TNETV107X,
584 .name = "tnetv107x rev1.0", 584 .name = "tnetv107x rev 1.0",
585 },
586 {
587 .variant = 0x1,
588 .part_no = 0xb8a1,
589 .manufacturer = 0x017,
590 .cpu_id = DAVINCI_CPU_ID_TNETV107X,
591 .name = "tnetv107x rev 1.1/1.2",
585 }, 592 },
586}; 593};
587 594
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 4566bd1c8660..ef06c66a6f16 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -358,8 +358,7 @@ static int calc_clk_div(struct clk *clk, unsigned long rate,
358 int i, found = 0, __div = 0, __pdiv = 0; 358 int i, found = 0, __div = 0, __pdiv = 0;
359 359
360 /* Don't exceed the maximum rate */ 360 /* Don't exceed the maximum rate */
361 max_rate = max(max(clk_pll1.rate / 4, clk_pll2.rate / 4), 361 max_rate = max3(clk_pll1.rate / 4, clk_pll2.rate / 4, clk_xtali.rate / 4);
362 clk_xtali.rate / 4);
363 rate = min(rate, max_rate); 362 rate = min(rate, max_rate);
364 363
365 /* 364 /*
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 4cb55d3902ff..ffdf87be2958 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -776,9 +776,15 @@ static struct platform_device ep93xx_i2s_device = {
776 .resource = ep93xx_i2s_resource, 776 .resource = ep93xx_i2s_resource,
777}; 777};
778 778
779static struct platform_device ep93xx_pcm_device = {
780 .name = "ep93xx-pcm-audio",
781 .id = -1,
782};
783
779void __init ep93xx_register_i2s(void) 784void __init ep93xx_register_i2s(void)
780{ 785{
781 platform_device_register(&ep93xx_i2s_device); 786 platform_device_register(&ep93xx_i2s_device);
787 platform_device_register(&ep93xx_pcm_device);
782} 788}
783 789
784#define EP93XX_SYSCON_DEVCFG_I2S_MASK (EP93XX_SYSCON_DEVCFG_I2SONSSP | \ 790#define EP93XX_SYSCON_DEVCFG_I2S_MASK (EP93XX_SYSCON_DEVCFG_I2SONSSP | \
@@ -826,6 +832,40 @@ void ep93xx_i2s_release(void)
826} 832}
827EXPORT_SYMBOL(ep93xx_i2s_release); 833EXPORT_SYMBOL(ep93xx_i2s_release);
828 834
835/*************************************************************************
836 * EP93xx AC97 audio peripheral handling
837 *************************************************************************/
838static struct resource ep93xx_ac97_resources[] = {
839 {
840 .start = EP93XX_AAC_PHYS_BASE,
841 .end = EP93XX_AAC_PHYS_BASE + 0xb0 - 1,
842 .flags = IORESOURCE_MEM,
843 },
844 {
845 .start = IRQ_EP93XX_AACINTR,
846 .end = IRQ_EP93XX_AACINTR,
847 .flags = IORESOURCE_IRQ,
848 },
849};
850
851static struct platform_device ep93xx_ac97_device = {
852 .name = "ep93xx-ac97",
853 .id = -1,
854 .num_resources = ARRAY_SIZE(ep93xx_ac97_resources),
855 .resource = ep93xx_ac97_resources,
856};
857
858void __init ep93xx_register_ac97(void)
859{
860 /*
861 * Make sure that the AC97 pins are not used by I2S.
862 */
863 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONAC97);
864
865 platform_device_register(&ep93xx_ac97_device);
866 platform_device_register(&ep93xx_pcm_device);
867}
868
829extern void ep93xx_gpio_init(void); 869extern void ep93xx_gpio_init(void);
830 870
831void __init ep93xx_init_devices(void) 871void __init ep93xx_init_devices(void)
diff --git a/arch/arm/mach-ep93xx/include/mach/dma.h b/arch/arm/mach-ep93xx/include/mach/dma.h
index 3a5961d3f3b1..5e31b2b25da9 100644
--- a/arch/arm/mach-ep93xx/include/mach/dma.h
+++ b/arch/arm/mach-ep93xx/include/mach/dma.h
@@ -1,5 +1,13 @@
1/* 1/**
2 * arch/arm/mach-ep93xx/include/mach/dma.h 2 * DOC: EP93xx DMA M2P memory to peripheral and peripheral to memory engine
3 *
4 * The EP93xx DMA M2P subsystem handles DMA transfers between memory and
5 * peripherals. DMA M2P channels are available for audio, UARTs and IrDA.
6 * See chapter 10 of the EP93xx users guide for full details on the DMA M2P
7 * engine.
8 *
9 * See sound/soc/ep93xx/ep93xx-pcm.c for an example use of the DMA M2P code.
10 *
3 */ 11 */
4 12
5#ifndef __ASM_ARCH_DMA_H 13#ifndef __ASM_ARCH_DMA_H
@@ -8,12 +16,34 @@
8#include <linux/list.h> 16#include <linux/list.h>
9#include <linux/types.h> 17#include <linux/types.h>
10 18
19/**
20 * struct ep93xx_dma_buffer - Information about a buffer to be transferred
21 * using the DMA M2P engine
22 *
23 * @list: Entry in DMA buffer list
24 * @bus_addr: Physical address of the buffer
25 * @size: Size of the buffer in bytes
26 */
11struct ep93xx_dma_buffer { 27struct ep93xx_dma_buffer {
12 struct list_head list; 28 struct list_head list;
13 u32 bus_addr; 29 u32 bus_addr;
14 u16 size; 30 u16 size;
15}; 31};
16 32
33/**
34 * struct ep93xx_dma_m2p_client - Information about a DMA M2P client
35 *
36 * @name: Unique name for this client
37 * @flags: Client flags
38 * @cookie: User data to pass to callback functions
39 * @buffer_started: Non NULL function to call when a transfer is started.
40 * The arguments are the user data cookie and the DMA
41 * buffer which is starting.
42 * @buffer_finished: Non NULL function to call when a transfer is completed.
43 * The arguments are the user data cookie, the DMA buffer
44 * which has completed, and a boolean flag indicating if
45 * the transfer had an error.
46 */
17struct ep93xx_dma_m2p_client { 47struct ep93xx_dma_m2p_client {
18 char *name; 48 char *name;
19 u8 flags; 49 u8 flags;
@@ -24,10 +54,11 @@ struct ep93xx_dma_m2p_client {
24 struct ep93xx_dma_buffer *buf, 54 struct ep93xx_dma_buffer *buf,
25 int bytes, int error); 55 int bytes, int error);
26 56
27 /* Internal to the DMA code. */ 57 /* private: Internal use only */
28 void *channel; 58 void *channel;
29}; 59};
30 60
61/* DMA M2P ports */
31#define EP93XX_DMA_M2P_PORT_I2S1 0x00 62#define EP93XX_DMA_M2P_PORT_I2S1 0x00
32#define EP93XX_DMA_M2P_PORT_I2S2 0x01 63#define EP93XX_DMA_M2P_PORT_I2S2 0x01
33#define EP93XX_DMA_M2P_PORT_AAC1 0x02 64#define EP93XX_DMA_M2P_PORT_AAC1 0x02
@@ -39,18 +70,80 @@ struct ep93xx_dma_m2p_client {
39#define EP93XX_DMA_M2P_PORT_UART3 0x08 70#define EP93XX_DMA_M2P_PORT_UART3 0x08
40#define EP93XX_DMA_M2P_PORT_IRDA 0x09 71#define EP93XX_DMA_M2P_PORT_IRDA 0x09
41#define EP93XX_DMA_M2P_PORT_MASK 0x0f 72#define EP93XX_DMA_M2P_PORT_MASK 0x0f
42#define EP93XX_DMA_M2P_TX 0x00
43#define EP93XX_DMA_M2P_RX 0x10
44#define EP93XX_DMA_M2P_ABORT_ON_ERROR 0x20
45#define EP93XX_DMA_M2P_IGNORE_ERROR 0x40
46#define EP93XX_DMA_M2P_ERROR_MASK 0x60
47 73
48int ep93xx_dma_m2p_client_register(struct ep93xx_dma_m2p_client *m2p); 74/* DMA M2P client flags */
75#define EP93XX_DMA_M2P_TX 0x00 /* Memory to peripheral */
76#define EP93XX_DMA_M2P_RX 0x10 /* Peripheral to memory */
77
78/*
79 * DMA M2P client error handling flags. See the EP93xx users guide
80 * documentation on the DMA M2P CONTROL register for more details
81 */
82#define EP93XX_DMA_M2P_ABORT_ON_ERROR 0x20 /* Abort on peripheral error */
83#define EP93XX_DMA_M2P_IGNORE_ERROR 0x40 /* Ignore peripheral errors */
84#define EP93XX_DMA_M2P_ERROR_MASK 0x60 /* Mask of error bits */
85
86/**
87 * ep93xx_dma_m2p_client_register - Register a client with the DMA M2P
88 * subsystem
89 *
90 * @m2p: Client information to register
91 * returns 0 on success
92 *
93 * The DMA M2P subsystem allocates a channel and an interrupt line for the DMA
94 * client
95 */
96int ep93xx_dma_m2p_client_register(struct ep93xx_dma_m2p_client *m2p);
97
98/**
99 * ep93xx_dma_m2p_client_unregister - Unregister a client from the DMA M2P
100 * subsystem
101 *
102 * @m2p: Client to unregister
103 *
104 * Any transfers currently in progress will be completed in hardware, but
105 * ignored in software.
106 */
49void ep93xx_dma_m2p_client_unregister(struct ep93xx_dma_m2p_client *m2p); 107void ep93xx_dma_m2p_client_unregister(struct ep93xx_dma_m2p_client *m2p);
108
109/**
110 * ep93xx_dma_m2p_submit - Submit a DMA M2P transfer
111 *
112 * @m2p: DMA Client to submit the transfer on
113 * @buf: DMA Buffer to submit
114 *
115 * If the current or next transfer positions are free on the M2P client then
116 * the transfer is started immediately. If not, the transfer is added to the
117 * list of pending transfers. This function must not be called from the
118 * buffer_finished callback for an M2P channel.
119 *
120 */
50void ep93xx_dma_m2p_submit(struct ep93xx_dma_m2p_client *m2p, 121void ep93xx_dma_m2p_submit(struct ep93xx_dma_m2p_client *m2p,
51 struct ep93xx_dma_buffer *buf); 122 struct ep93xx_dma_buffer *buf);
123
124/**
125 * ep93xx_dma_m2p_submit_recursive - Put a DMA transfer on the pending list
126 * for an M2P channel
127 *
128 * @m2p: DMA Client to submit the transfer on
129 * @buf: DMA Buffer to submit
130 *
131 * This function must only be called from the buffer_finished callback for an
132 * M2P channel. It is commonly used to add the next transfer in a chained list
133 * of DMA transfers.
134 */
52void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p, 135void ep93xx_dma_m2p_submit_recursive(struct ep93xx_dma_m2p_client *m2p,
53 struct ep93xx_dma_buffer *buf); 136 struct ep93xx_dma_buffer *buf);
137
138/**
139 * ep93xx_dma_m2p_flush - Flush all pending transfers on a DMA M2P client
140 *
141 * @m2p: DMA client to flush transfers on
142 *
143 * Any transfers currently in progress will be completed in hardware, but
144 * ignored in software.
145 *
146 */
54void ep93xx_dma_m2p_flush(struct ep93xx_dma_m2p_client *m2p); 147void ep93xx_dma_m2p_flush(struct ep93xx_dma_m2p_client *m2p);
55 148
56#endif /* __ASM_ARCH_DMA_H */ 149#endif /* __ASM_ARCH_DMA_H */
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index c54b3e56ba63..9ac4d1055097 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -105,6 +105,7 @@
105#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc) 105#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc)
106#define EP93XX_GPIO_EEDRIVE EP93XX_GPIO_REG(0xc8) 106#define EP93XX_GPIO_EEDRIVE EP93XX_GPIO_REG(0xc8)
107 107
108#define EP93XX_AAC_PHYS_BASE EP93XX_APB_PHYS(0x00080000)
108#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000) 109#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000)
109 110
110#define EP93XX_SPI_PHYS_BASE EP93XX_APB_PHYS(0x000a0000) 111#define EP93XX_SPI_PHYS_BASE EP93XX_APB_PHYS(0x000a0000)
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index 3330b36d79e6..50660455b1d8 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -61,6 +61,7 @@ void ep93xx_keypad_release_gpio(struct platform_device *pdev);
61void ep93xx_register_i2s(void); 61void ep93xx_register_i2s(void);
62int ep93xx_i2s_acquire(unsigned i2s_pins, unsigned i2s_config); 62int ep93xx_i2s_acquire(unsigned i2s_pins, unsigned i2s_config);
63void ep93xx_i2s_release(void); 63void ep93xx_i2s_release(void);
64void ep93xx_register_ac97(void);
64 65
65void ep93xx_init_devices(void); 66void ep93xx_init_devices(void);
66extern struct sys_timer ep93xx_timer; 67extern struct sys_timer ep93xx_timer;
diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index f22ce8db7947..d96dc1c5da20 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -61,6 +61,7 @@ static void __init simone_init_machine(void)
61 ep93xx_register_fb(&simone_fb_info); 61 ep93xx_register_fb(&simone_fb_info);
62 ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info, 62 ep93xx_register_i2c(&simone_i2c_gpio_data, simone_i2c_board_info,
63 ARRAY_SIZE(simone_i2c_board_info)); 63 ARRAY_SIZE(simone_i2c_board_info));
64 ep93xx_register_ac97();
64} 65}
65 66
66MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board") 67MACHINE_START(SIM_ONE, "Simplemachines Sim.One Board")
diff --git a/arch/arm/mach-imx/include/mach/dma-v1.h b/arch/arm/mach-imx/include/mach/dma-v1.h
index 287431cc13e5..ac6fd713828a 100644
--- a/arch/arm/mach-imx/include/mach/dma-v1.h
+++ b/arch/arm/mach-imx/include/mach/dma-v1.h
@@ -27,6 +27,8 @@
27 27
28#define imx_has_dma_v1() (cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27()) 28#define imx_has_dma_v1() (cpu_is_mx1() || cpu_is_mx21() || cpu_is_mx27())
29 29
30#include <mach/dma.h>
31
30#define IMX_DMA_CHANNELS 16 32#define IMX_DMA_CHANNELS 16
31 33
32#define DMA_MODE_READ 0 34#define DMA_MODE_READ 0
@@ -96,12 +98,6 @@ int imx_dma_request(int channel, const char *name);
96 98
97void imx_dma_free(int channel); 99void imx_dma_free(int channel);
98 100
99enum imx_dma_prio {
100 DMA_PRIO_HIGH = 0,
101 DMA_PRIO_MEDIUM = 1,
102 DMA_PRIO_LOW = 2
103};
104
105int imx_dma_request_by_prio(const char *name, enum imx_dma_prio prio); 101int imx_dma_request_by_prio(const char *name, enum imx_dma_prio prio);
106 102
107#endif /* __MACH_DMA_V1_H__ */ 103#endif /* __MACH_DMA_V1_H__ */
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index b8bbd31aa850..84a5ba03f1ba 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -23,16 +23,20 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/input/matrix_keypad.h> 25#include <linux/input/matrix_keypad.h>
26#include <linux/irq.h>
26#include <asm/mach-types.h> 27#include <asm/mach-types.h>
27#include <asm/mach/arch.h> 28#include <asm/mach/arch.h>
28#include <asm/mach/time.h> 29#include <asm/mach/time.h>
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <mach/common.h> 31#include <mach/common.h>
31#include <mach/iomux-mx27.h> 32#include <mach/iomux-mx27.h>
33#include <mach/mmc.h>
32 34
33#include "devices-imx27.h" 35#include "devices-imx27.h"
34#include "devices.h" 36#include "devices.h"
35 37
38#define SD1_EN_GPIO (GPIO_PORTB + 25)
39
36static const int mx27pdk_pins[] __initconst = { 40static const int mx27pdk_pins[] __initconst = {
37 /* UART1 */ 41 /* UART1 */
38 PE12_PF_UART1_TXD, 42 PE12_PF_UART1_TXD,
@@ -58,6 +62,14 @@ static const int mx27pdk_pins[] __initconst = {
58 PD15_AOUT_FEC_COL, 62 PD15_AOUT_FEC_COL,
59 PD16_AIN_FEC_TX_ER, 63 PD16_AIN_FEC_TX_ER,
60 PF23_AIN_FEC_TX_EN, 64 PF23_AIN_FEC_TX_EN,
65 /* SDHC1 */
66 PE18_PF_SD1_D0,
67 PE19_PF_SD1_D1,
68 PE20_PF_SD1_D2,
69 PE21_PF_SD1_D3,
70 PE22_PF_SD1_CMD,
71 PE23_PF_SD1_CLK,
72 SD1_EN_GPIO | GPIO_GPIO | GPIO_OUT,
61}; 73};
62 74
63static const struct imxuart_platform_data uart_pdata __initconst = { 75static const struct imxuart_platform_data uart_pdata __initconst = {
@@ -85,13 +97,39 @@ static struct matrix_keymap_data mx27_3ds_keymap_data = {
85 .keymap_size = ARRAY_SIZE(mx27_3ds_keymap), 97 .keymap_size = ARRAY_SIZE(mx27_3ds_keymap),
86}; 98};
87 99
100static int mx27_3ds_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
101 void *data)
102{
103 return request_irq(IRQ_GPIOB(26), detect_irq, IRQF_TRIGGER_FALLING |
104 IRQF_TRIGGER_RISING, "sdhc1-card-detect", data);
105}
106
107static void mx27_3ds_sdhc1_exit(struct device *dev, void *data)
108{
109 free_irq(IRQ_GPIOB(26), data);
110}
111
112static struct imxmmc_platform_data sdhc1_pdata = {
113 .init = mx27_3ds_sdhc1_init,
114 .exit = mx27_3ds_sdhc1_exit,
115};
116
117static void mx27_3ds_sdhc1_enable_level_translator(void)
118{
119 /* Turn on TXB0108 OE pin */
120 gpio_request(SD1_EN_GPIO, "sd1_enable");
121 gpio_direction_output(SD1_EN_GPIO, 1);
122}
123
88static void __init mx27pdk_init(void) 124static void __init mx27pdk_init(void)
89{ 125{
90 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), 126 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
91 "mx27pdk"); 127 "mx27pdk");
128 mx27_3ds_sdhc1_enable_level_translator();
92 imx27_add_imx_uart0(&uart_pdata); 129 imx27_add_imx_uart0(&uart_pdata);
93 imx27_add_fec(NULL); 130 imx27_add_fec(NULL);
94 mxc_register_device(&imx_kpp_device, &mx27_3ds_keymap_data); 131 mxc_register_device(&imx_kpp_device, &mx27_3ds_keymap_data);
132 mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
95} 133}
96 134
97static void __init mx27pdk_timer_init(void) 135static void __init mx27pdk_timer_init(void)
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index babb22597163..e24e3d05397f 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -197,7 +197,7 @@ unsigned long ixp2000_gettimeoffset (void)
197 return offset / ticks_per_usec; 197 return offset / ticks_per_usec;
198} 198}
199 199
200static int ixp2000_timer_interrupt(int irq, void *dev_id) 200static irqreturn_t ixp2000_timer_interrupt(int irq, void *dev_id)
201{ 201{
202 /* clear timer 1 */ 202 /* clear timer 1 */
203 ixp2000_reg_wrb(IXP2000_T1_CLR, 1); 203 ixp2000_reg_wrb(IXP2000_T1_CLR, 1);
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 1c82d4290dad..3688123b5ad8 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -854,10 +854,9 @@ int __init kirkwood_find_tclk(void)
854 854
855 kirkwood_pcie_id(&dev, &rev); 855 kirkwood_pcie_id(&dev, &rev);
856 856
857 if ((dev == MV88F6281_DEV_ID && (rev == MV88F6281_REV_A0 || 857 if (dev == MV88F6281_DEV_ID || dev == MV88F6282_DEV_ID)
858 rev == MV88F6281_REV_A1)) || 858 if (((readl(SAMPLE_AT_RESET) >> 21) & 1) == 0)
859 (dev == MV88F6282_DEV_ID)) 859 return 200000000;
860 return 200000000;
861 860
862 return 166666667; 861 return 166666667;
863} 862}
@@ -903,10 +902,16 @@ static struct platform_device kirkwood_i2s_device = {
903 }, 902 },
904}; 903};
905 904
905static struct platform_device kirkwood_pcm_device = {
906 .name = "kirkwood-pcm-audio",
907 .id = -1,
908};
909
906void __init kirkwood_audio_init(void) 910void __init kirkwood_audio_init(void)
907{ 911{
908 kirkwood_clk_ctrl |= CGC_AUDIO; 912 kirkwood_clk_ctrl |= CGC_AUDIO;
909 platform_device_register(&kirkwood_i2s_device); 913 platform_device_register(&kirkwood_i2s_device);
914 platform_device_register(&kirkwood_pcm_device);
910} 915}
911 916
912/***************************************************************************** 917/*****************************************************************************
diff --git a/arch/arm/mach-kirkwood/d2net_v2-setup.c b/arch/arm/mach-kirkwood/d2net_v2-setup.c
index 4aa86e4a152c..a31c9499ab36 100644
--- a/arch/arm/mach-kirkwood/d2net_v2-setup.c
+++ b/arch/arm/mach-kirkwood/d2net_v2-setup.c
@@ -225,5 +225,5 @@ MACHINE_START(D2NET_V2, "LaCie d2 Network v2")
225 .init_machine = d2net_v2_init, 225 .init_machine = d2net_v2_init,
226 .map_io = kirkwood_map_io, 226 .map_io = kirkwood_map_io,
227 .init_irq = kirkwood_init_irq, 227 .init_irq = kirkwood_init_irq,
228 .timer = &lacie_v2_timer, 228 .timer = &kirkwood_timer,
229MACHINE_END 229MACHINE_END
diff --git a/arch/arm/mach-kirkwood/lacie_v2-common.c b/arch/arm/mach-kirkwood/lacie_v2-common.c
index d3ea1b6c8a02..285edab776e9 100644
--- a/arch/arm/mach-kirkwood/lacie_v2-common.c
+++ b/arch/arm/mach-kirkwood/lacie_v2-common.c
@@ -111,17 +111,3 @@ void __init lacie_v2_hdd_power_init(int hdd_num)
111 pr_err("Failed to power up HDD%d\n", i + 1); 111 pr_err("Failed to power up HDD%d\n", i + 1);
112 } 112 }
113} 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
index af521315b87b..fc64f578536e 100644
--- a/arch/arm/mach-kirkwood/lacie_v2-common.h
+++ b/arch/arm/mach-kirkwood/lacie_v2-common.h
@@ -13,6 +13,4 @@ void lacie_v2_register_flash(void);
13void lacie_v2_register_i2c_devices(void); 13void lacie_v2_register_i2c_devices(void);
14void lacie_v2_hdd_power_init(int hdd_num); 14void lacie_v2_hdd_power_init(int hdd_num);
15 15
16extern struct sys_timer lacie_v2_timer;
17
18#endif 16#endif
diff --git a/arch/arm/mach-kirkwood/mpp.c b/arch/arm/mach-kirkwood/mpp.c
index 065187d177c6..27901f702feb 100644
--- a/arch/arm/mach-kirkwood/mpp.c
+++ b/arch/arm/mach-kirkwood/mpp.c
@@ -59,7 +59,7 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list)
59 } 59 }
60 printk("\n"); 60 printk("\n");
61 61
62 while (*mpp_list) { 62 for ( ; *mpp_list; mpp_list++) {
63 unsigned int num = MPP_NUM(*mpp_list); 63 unsigned int num = MPP_NUM(*mpp_list);
64 unsigned int sel = MPP_SEL(*mpp_list); 64 unsigned int sel = MPP_SEL(*mpp_list);
65 int shift, gpio_mode; 65 int shift, gpio_mode;
@@ -88,8 +88,6 @@ void __init kirkwood_mpp_conf(unsigned int *mpp_list)
88 if (sel != 0) 88 if (sel != 0)
89 gpio_mode = 0; 89 gpio_mode = 0;
90 orion_gpio_set_valid(num, gpio_mode); 90 orion_gpio_set_valid(num, gpio_mode);
91
92 mpp_list++;
93 } 91 }
94 92
95 printk(KERN_DEBUG " final MPP regs:"); 93 printk(KERN_DEBUG " final MPP regs:");
diff --git a/arch/arm/mach-kirkwood/netspace_v2-setup.c b/arch/arm/mach-kirkwood/netspace_v2-setup.c
index 5e286441b8f4..65ee21fd2f3b 100644
--- a/arch/arm/mach-kirkwood/netspace_v2-setup.c
+++ b/arch/arm/mach-kirkwood/netspace_v2-setup.c
@@ -30,6 +30,7 @@
30#include <linux/gpio.h> 30#include <linux/gpio.h>
31#include <linux/gpio_keys.h> 31#include <linux/gpio_keys.h>
32#include <linux/leds.h> 32#include <linux/leds.h>
33#include <linux/gpio-fan.h>
33#include <asm/mach-types.h> 34#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
35#include <mach/kirkwood.h> 36#include <mach/kirkwood.h>
@@ -137,6 +138,46 @@ static struct platform_device netspace_v2_leds = {
137}; 138};
138 139
139/***************************************************************************** 140/*****************************************************************************
141 * GPIO fan
142 ****************************************************************************/
143
144/* Designed for fan 40x40x16: ADDA AD0412LB-D50 6000rpm@12v */
145static struct gpio_fan_speed netspace_max_v2_fan_speed[] = {
146 { 0, 0 },
147 { 1500, 15 },
148 { 1700, 14 },
149 { 1800, 13 },
150 { 2100, 12 },
151 { 3100, 11 },
152 { 3300, 10 },
153 { 4300, 9 },
154 { 5500, 8 },
155};
156
157static unsigned netspace_max_v2_fan_ctrl[] = { 22, 7, 33, 23 };
158
159static struct gpio_fan_alarm netspace_max_v2_fan_alarm = {
160 .gpio = 25,
161 .active_low = 1,
162};
163
164static struct gpio_fan_platform_data netspace_max_v2_fan_data = {
165 .num_ctrl = ARRAY_SIZE(netspace_max_v2_fan_ctrl),
166 .ctrl = netspace_max_v2_fan_ctrl,
167 .alarm = &netspace_max_v2_fan_alarm,
168 .num_speed = ARRAY_SIZE(netspace_max_v2_fan_speed),
169 .speed = netspace_max_v2_fan_speed,
170};
171
172static struct platform_device netspace_max_v2_gpio_fan = {
173 .name = "gpio-fan",
174 .id = -1,
175 .dev = {
176 .platform_data = &netspace_max_v2_fan_data,
177 },
178};
179
180/*****************************************************************************
140 * General Setup 181 * General Setup
141 ****************************************************************************/ 182 ****************************************************************************/
142 183
@@ -205,6 +246,8 @@ static void __init netspace_v2_init(void)
205 platform_device_register(&netspace_v2_leds); 246 platform_device_register(&netspace_v2_leds);
206 platform_device_register(&netspace_v2_gpio_leds); 247 platform_device_register(&netspace_v2_gpio_leds);
207 platform_device_register(&netspace_v2_gpio_buttons); 248 platform_device_register(&netspace_v2_gpio_buttons);
249 if (machine_is_netspace_max_v2())
250 platform_device_register(&netspace_max_v2_gpio_fan);
208 251
209 if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 && 252 if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
210 gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0) 253 gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
@@ -219,7 +262,7 @@ MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
219 .init_machine = netspace_v2_init, 262 .init_machine = netspace_v2_init,
220 .map_io = kirkwood_map_io, 263 .map_io = kirkwood_map_io,
221 .init_irq = kirkwood_init_irq, 264 .init_irq = kirkwood_init_irq,
222 .timer = &lacie_v2_timer, 265 .timer = &kirkwood_timer,
223MACHINE_END 266MACHINE_END
224#endif 267#endif
225 268
@@ -229,7 +272,7 @@ MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
229 .init_machine = netspace_v2_init, 272 .init_machine = netspace_v2_init,
230 .map_io = kirkwood_map_io, 273 .map_io = kirkwood_map_io,
231 .init_irq = kirkwood_init_irq, 274 .init_irq = kirkwood_init_irq,
232 .timer = &lacie_v2_timer, 275 .timer = &kirkwood_timer,
233MACHINE_END 276MACHINE_END
234#endif 277#endif
235 278
@@ -239,6 +282,6 @@ MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
239 .init_machine = netspace_v2_init, 282 .init_machine = netspace_v2_init,
240 .map_io = kirkwood_map_io, 283 .map_io = kirkwood_map_io,
241 .init_irq = kirkwood_init_irq, 284 .init_irq = kirkwood_init_irq,
242 .timer = &lacie_v2_timer, 285 .timer = &kirkwood_timer,
243MACHINE_END 286MACHINE_END
244#endif 287#endif
diff --git a/arch/arm/mach-kirkwood/netxbig_v2-setup.c b/arch/arm/mach-kirkwood/netxbig_v2-setup.c
index a1b45d501aef..93afd3c8bfd8 100644
--- a/arch/arm/mach-kirkwood/netxbig_v2-setup.c
+++ b/arch/arm/mach-kirkwood/netxbig_v2-setup.c
@@ -403,7 +403,7 @@ MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
403 .init_machine = netxbig_v2_init, 403 .init_machine = netxbig_v2_init,
404 .map_io = kirkwood_map_io, 404 .map_io = kirkwood_map_io,
405 .init_irq = kirkwood_init_irq, 405 .init_irq = kirkwood_init_irq,
406 .timer = &lacie_v2_timer, 406 .timer = &kirkwood_timer,
407MACHINE_END 407MACHINE_END
408#endif 408#endif
409 409
@@ -413,6 +413,6 @@ MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
413 .init_machine = netxbig_v2_init, 413 .init_machine = netxbig_v2_init,
414 .map_io = kirkwood_map_io, 414 .map_io = kirkwood_map_io,
415 .init_irq = kirkwood_init_irq, 415 .init_irq = kirkwood_init_irq,
416 .timer = &lacie_v2_timer, 416 .timer = &kirkwood_timer,
417MACHINE_END 417MACHINE_END
418#endif 418#endif
diff --git a/arch/arm/mach-kirkwood/ts41x-setup.c b/arch/arm/mach-kirkwood/ts41x-setup.c
index 8be09a0ce4ac..3587a281d993 100644
--- a/arch/arm/mach-kirkwood/ts41x-setup.c
+++ b/arch/arm/mach-kirkwood/ts41x-setup.c
@@ -27,6 +27,10 @@
27#include "mpp.h" 27#include "mpp.h"
28#include "tsx1x-common.h" 28#include "tsx1x-common.h"
29 29
30/* for the PCIe reset workaround */
31#include <plat/pcie.h>
32
33
30#define QNAP_TS41X_JUMPER_JP1 45 34#define QNAP_TS41X_JUMPER_JP1 45
31 35
32static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = { 36static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {
@@ -140,8 +144,16 @@ static void __init qnap_ts41x_init(void)
140 144
141static int __init ts41x_pci_init(void) 145static int __init ts41x_pci_init(void)
142{ 146{
143 if (machine_is_ts41x()) 147 if (machine_is_ts41x()) {
148 /*
149 * Without this explicit reset, the PCIe SATA controller
150 * (Marvell 88sx7042/sata_mv) is known to stop working
151 * after a few minutes.
152 */
153 orion_pcie_reset((void __iomem *)PCIE_VIRT_BASE);
154
144 kirkwood_pcie_init(KW_PCIE0); 155 kirkwood_pcie_init(KW_PCIE0);
156 }
145 157
146 return 0; 158 return 0;
147} 159}
diff --git a/arch/arm/mach-mmp/include/mach/cputype.h b/arch/arm/mach-mmp/include/mach/cputype.h
index f43a68b213f1..8a3b56dfd35d 100644
--- a/arch/arm/mach-mmp/include/mach/cputype.h
+++ b/arch/arm/mach-mmp/include/mach/cputype.h
@@ -46,7 +46,8 @@ static inline int cpu_is_pxa910(void)
46#ifdef CONFIG_CPU_MMP2 46#ifdef CONFIG_CPU_MMP2
47static inline int cpu_is_mmp2(void) 47static inline int cpu_is_mmp2(void)
48{ 48{
49 return (((cpu_readid_id() >> 8) & 0xff) == 0x58); 49 return (((read_cpuid_id() >> 8) & 0xff) == 0x58);
50}
50#else 51#else
51#define cpu_is_mmp2() (0) 52#define cpu_is_mmp2() (0)
52#endif 53#endif
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 3115a29dec4e..dbbcfeb919db 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -6,6 +6,7 @@ choice
6 6
7config ARCH_MSM7X00A 7config ARCH_MSM7X00A
8 bool "MSM7x00A / MSM7x01A" 8 bool "MSM7x00A / MSM7x01A"
9 select MACH_TROUT if !MACH_HALIBUT
9 select ARCH_MSM_ARM11 10 select ARCH_MSM_ARM11
10 select MSM_SMD 11 select MSM_SMD
11 select MSM_SMD_PKG3 12 select MSM_SMD_PKG3
@@ -15,34 +16,34 @@ config ARCH_MSM7X00A
15 16
16config ARCH_MSM7X30 17config ARCH_MSM7X30
17 bool "MSM7x30" 18 bool "MSM7x30"
19 select MACH_MSM7X30_SURF # if !
18 select ARCH_MSM_SCORPION 20 select ARCH_MSM_SCORPION
19 select MSM_SMD 21 select MSM_SMD
20 select MSM_VIC 22 select MSM_VIC
21 select CPU_V7 23 select CPU_V7
22 select MSM_REMOTE_SPINLOCK_DEKKERS
23 select MSM_GPIOMUX 24 select MSM_GPIOMUX
24 select MSM_PROC_COMM 25 select MSM_PROC_COMM
25 select HAS_MSM_DEBUG_UART_PHYS 26 select HAS_MSM_DEBUG_UART_PHYS
26 27
27config ARCH_QSD8X50 28config ARCH_QSD8X50
28 bool "QSD8X50" 29 bool "QSD8X50"
30 select MACH_QSD8X50_SURF if !MACH_QSD8X50A_ST1_5
29 select ARCH_MSM_SCORPION 31 select ARCH_MSM_SCORPION
30 select MSM_SMD 32 select MSM_SMD
31 select MSM_VIC 33 select MSM_VIC
32 select CPU_V7 34 select CPU_V7
33 select MSM_REMOTE_SPINLOCK_LDREX
34 select MSM_GPIOMUX 35 select MSM_GPIOMUX
35 select MSM_PROC_COMM 36 select MSM_PROC_COMM
36 select HAS_MSM_DEBUG_UART_PHYS 37 select HAS_MSM_DEBUG_UART_PHYS
37 38
38config ARCH_MSM8X60 39config ARCH_MSM8X60
39 bool "MSM8X60" 40 bool "MSM8X60"
41 select MACH_MSM8X60_SURF if (!MACH_MSM8X60_RUMI3 && !MACH_MSM8X60_SIM \
42 && !MACH_MSM8X60_FFA)
40 select ARM_GIC 43 select ARM_GIC
41 select CPU_V7 44 select CPU_V7
42 select MSM_V2_TLMM 45 select MSM_V2_TLMM
43 select MSM_GPIOMUX 46 select MSM_GPIOMUX
44 select MACH_MSM8X60_SURF if (!MACH_MSM8X60_RUMI3 && !MACH_MSM8X60_SIM \
45 && !MACH_MSM8X60_FFA)
46 47
47endchoice 48endchoice
48 49
diff --git a/arch/arm/mach-msm/board-halibut.c b/arch/arm/mach-msm/board-halibut.c
index 59edecbe126c..75dabb16c802 100644
--- a/arch/arm/mach-msm/board-halibut.c
+++ b/arch/arm/mach-msm/board-halibut.c
@@ -83,7 +83,6 @@ static void __init halibut_fixup(struct machine_desc *desc, struct tag *tags,
83{ 83{
84 mi->nr_banks=1; 84 mi->nr_banks=1;
85 mi->bank[0].start = PHYS_OFFSET; 85 mi->bank[0].start = PHYS_OFFSET;
86 mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET);
87 mi->bank[0].size = (101*1024*1024); 86 mi->bank[0].size = (101*1024*1024);
88} 87}
89 88
diff --git a/arch/arm/mach-msm/include/mach/debug-macro.S b/arch/arm/mach-msm/include/mach/debug-macro.S
index fbd5d90dcc8c..646b99ebc773 100644
--- a/arch/arm/mach-msm/include/mach/debug-macro.S
+++ b/arch/arm/mach-msm/include/mach/debug-macro.S
@@ -19,7 +19,7 @@
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_HAS_MSM_DEBUG_UART_PHYS 22#if defined(CONFIG_HAS_MSM_DEBUG_UART_PHYS) && !defined(CONFIG_MSM_DEBUG_UART_NONE)
23 .macro addruart, rp, rv 23 .macro addruart, rp, rv
24 ldr \rp, =MSM_DEBUG_UART_PHYS 24 ldr \rp, =MSM_DEBUG_UART_PHYS
25 ldr \rv, =MSM_DEBUG_UART_BASE 25 ldr \rv, =MSM_DEBUG_UART_BASE
@@ -36,7 +36,18 @@
36 tst \rd, #0x04 36 tst \rd, #0x04
37 beq 1001b 37 beq 1001b
38 .endm 38 .endm
39#else
40 .macro addruart, rp, rv
41 mov \rv, #0xff000000
42 orr \rv, \rv, #0x00f00000
43 .endm
39 44
40 .macro busyuart,rd,rx 45 .macro senduart,rd,rx
46 .endm
47
48 .macro waituart,rd,rx
41 .endm 49 .endm
42#endif 50#endif
51
52 .macro busyuart,rd,rx
53 .endm
diff --git a/arch/arm/mach-msm/iommu_dev.c b/arch/arm/mach-msm/iommu_dev.c
index c33ae786c41f..9019cee2907b 100644
--- a/arch/arm/mach-msm/iommu_dev.c
+++ b/arch/arm/mach-msm/iommu_dev.c
@@ -128,7 +128,7 @@ static void msm_iommu_reset(void __iomem *base)
128 128
129static int msm_iommu_probe(struct platform_device *pdev) 129static int msm_iommu_probe(struct platform_device *pdev)
130{ 130{
131 struct resource *r; 131 struct resource *r, *r2;
132 struct clk *iommu_clk; 132 struct clk *iommu_clk;
133 struct msm_iommu_drvdata *drvdata; 133 struct msm_iommu_drvdata *drvdata;
134 struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data; 134 struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data;
@@ -183,27 +183,27 @@ static int msm_iommu_probe(struct platform_device *pdev)
183 183
184 len = r->end - r->start + 1; 184 len = r->end - r->start + 1;
185 185
186 r = request_mem_region(r->start, len, r->name); 186 r2 = request_mem_region(r->start, len, r->name);
187 if (!r) { 187 if (!r2) {
188 pr_err("Could not request memory region: " 188 pr_err("Could not request memory region: "
189 "start=%p, len=%d\n", (void *) r->start, len); 189 "start=%p, len=%d\n", (void *) r->start, len);
190 ret = -EBUSY; 190 ret = -EBUSY;
191 goto fail; 191 goto fail;
192 } 192 }
193 193
194 regs_base = ioremap(r->start, len); 194 regs_base = ioremap(r2->start, len);
195 195
196 if (!regs_base) { 196 if (!regs_base) {
197 pr_err("Could not ioremap: start=%p, len=%d\n", 197 pr_err("Could not ioremap: start=%p, len=%d\n",
198 (void *) r->start, len); 198 (void *) r2->start, len);
199 ret = -EBUSY; 199 ret = -EBUSY;
200 goto fail; 200 goto fail_mem;
201 } 201 }
202 202
203 irq = platform_get_irq_byname(pdev, "secure_irq"); 203 irq = platform_get_irq_byname(pdev, "secure_irq");
204 if (irq < 0) { 204 if (irq < 0) {
205 ret = -ENODEV; 205 ret = -ENODEV;
206 goto fail; 206 goto fail_io;
207 } 207 }
208 208
209 mb(); 209 mb();
@@ -211,14 +211,14 @@ static int msm_iommu_probe(struct platform_device *pdev)
211 if (GET_IDR(regs_base) == 0) { 211 if (GET_IDR(regs_base) == 0) {
212 pr_err("Invalid IDR value detected\n"); 212 pr_err("Invalid IDR value detected\n");
213 ret = -ENODEV; 213 ret = -ENODEV;
214 goto fail; 214 goto fail_io;
215 } 215 }
216 216
217 ret = request_irq(irq, msm_iommu_fault_handler, 0, 217 ret = request_irq(irq, msm_iommu_fault_handler, 0,
218 "msm_iommu_secure_irpt_handler", drvdata); 218 "msm_iommu_secure_irpt_handler", drvdata);
219 if (ret) { 219 if (ret) {
220 pr_err("Request IRQ %d failed with ret=%d\n", irq, ret); 220 pr_err("Request IRQ %d failed with ret=%d\n", irq, ret);
221 goto fail; 221 goto fail_io;
222 } 222 }
223 223
224 msm_iommu_reset(regs_base); 224 msm_iommu_reset(regs_base);
@@ -237,6 +237,10 @@ static int msm_iommu_probe(struct platform_device *pdev)
237 237
238 return 0; 238 return 0;
239 239
240fail_io:
241 iounmap(regs_base);
242fail_mem:
243 release_mem_region(r->start, len);
240fail: 244fail:
241 kfree(drvdata); 245 kfree(drvdata);
242 return ret; 246 return ret;
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 7689848ec680..950100f19d07 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -137,7 +137,7 @@ static struct msm_clock msm_clocks[] = {
137 .rating = 200, 137 .rating = 200,
138 .read = msm_gpt_read, 138 .read = msm_gpt_read,
139 .mask = CLOCKSOURCE_MASK(32), 139 .mask = CLOCKSOURCE_MASK(32),
140 .shift = 24, 140 .shift = 17,
141 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 141 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
142 }, 142 },
143 .irq = { 143 .irq = {
diff --git a/arch/arm/mach-mv78xx0/mpp.c b/arch/arm/mach-mv78xx0/mpp.c
index 354ac514eb89..84db2dfc475c 100644
--- a/arch/arm/mach-mv78xx0/mpp.c
+++ b/arch/arm/mach-mv78xx0/mpp.c
@@ -54,7 +54,7 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list)
54 } 54 }
55 printk("\n"); 55 printk("\n");
56 56
57 while (*mpp_list) { 57 for ( ; *mpp_list; mpp_list++) {
58 unsigned int num = MPP_NUM(*mpp_list); 58 unsigned int num = MPP_NUM(*mpp_list);
59 unsigned int sel = MPP_SEL(*mpp_list); 59 unsigned int sel = MPP_SEL(*mpp_list);
60 int shift, gpio_mode; 60 int shift, gpio_mode;
@@ -83,8 +83,6 @@ void __init mv78xx0_mpp_conf(unsigned int *mpp_list)
83 if (sel != 0) 83 if (sel != 0)
84 gpio_mode = 0; 84 gpio_mode = 0;
85 orion_gpio_set_valid(num, gpio_mode); 85 orion_gpio_set_valid(num, gpio_mode);
86
87 mpp_list++;
88 } 86 }
89 87
90 printk(KERN_DEBUG " final MPP regs:"); 88 printk(KERN_DEBUG " final MPP regs:");
diff --git a/arch/arm/mach-mx25/Kconfig b/arch/arm/mach-mx25/Kconfig
index aa57e35ce3cd..38ca09a5df9d 100644
--- a/arch/arm/mach-mx25/Kconfig
+++ b/arch/arm/mach-mx25/Kconfig
@@ -6,6 +6,7 @@ config MACH_MX25_3DS
6 bool "Support MX25PDK (3DS) Platform" 6 bool "Support MX25PDK (3DS) Platform"
7 select IMX_HAVE_PLATFORM_IMX_UART 7 select IMX_HAVE_PLATFORM_IMX_UART
8 select IMX_HAVE_PLATFORM_MXC_NAND 8 select IMX_HAVE_PLATFORM_MXC_NAND
9 select IMX_HAVE_PLATFORM_ESDHC
9 10
10config MACH_EUKREA_CPUIMX25 11config MACH_EUKREA_CPUIMX25
11 bool "Support Eukrea CPUIMX25 Platform" 12 bool "Support Eukrea CPUIMX25 Platform"
diff --git a/arch/arm/mach-mx25/mach-mx25_3ds.c b/arch/arm/mach-mx25/mach-mx25_3ds.c
index 80805107a73e..f8be1eb0c062 100644
--- a/arch/arm/mach-mx25/mach-mx25_3ds.c
+++ b/arch/arm/mach-mx25/mach-mx25_3ds.c
@@ -96,6 +96,14 @@ static struct pad_desc mx25pdk_pads[] = {
96 MX25_PAD_KPP_COL1__KPP_COL1, 96 MX25_PAD_KPP_COL1__KPP_COL1,
97 MX25_PAD_KPP_COL2__KPP_COL2, 97 MX25_PAD_KPP_COL2__KPP_COL2,
98 MX25_PAD_KPP_COL3__KPP_COL3, 98 MX25_PAD_KPP_COL3__KPP_COL3,
99
100 /* SD1 */
101 MX25_PAD_SD1_CMD__SD1_CMD,
102 MX25_PAD_SD1_CLK__SD1_CLK,
103 MX25_PAD_SD1_DATA0__SD1_DATA0,
104 MX25_PAD_SD1_DATA1__SD1_DATA1,
105 MX25_PAD_SD1_DATA2__SD1_DATA2,
106 MX25_PAD_SD1_DATA3__SD1_DATA3,
99}; 107};
100 108
101static const struct fec_platform_data mx25_fec_pdata __initconst = { 109static const struct fec_platform_data mx25_fec_pdata __initconst = {
@@ -193,6 +201,8 @@ static void __init mx25pdk_init(void)
193 mx25pdk_fec_reset(); 201 mx25pdk_fec_reset();
194 imx25_add_fec(&mx25_fec_pdata); 202 imx25_add_fec(&mx25_fec_pdata);
195 mxc_register_device(&mx25_kpp_device, &mx25pdk_keymap_data); 203 mxc_register_device(&mx25_kpp_device, &mx25pdk_keymap_data);
204
205 imx25_add_esdhc(0, NULL);
196} 206}
197 207
198static void __init mx25pdk_timer_init(void) 208static void __init mx25pdk_timer_init(void)
diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
index 096fd33f8ab9..5000ac1f93e3 100644
--- a/arch/arm/mach-mx3/Kconfig
+++ b/arch/arm/mach-mx3/Kconfig
@@ -143,8 +143,10 @@ config MACH_ARMADILLO5X0
143config MACH_MX35_3DS 143config MACH_MX35_3DS
144 bool "Support MX35PDK platform" 144 bool "Support MX35PDK platform"
145 select ARCH_MX35 145 select ARCH_MX35
146 select MXC_DEBUG_BOARD
146 select IMX_HAVE_PLATFORM_IMX_UART 147 select IMX_HAVE_PLATFORM_IMX_UART
147 select IMX_HAVE_PLATFORM_MXC_NAND 148 select IMX_HAVE_PLATFORM_MXC_NAND
149 select IMX_HAVE_PLATFORM_ESDHC
148 default n 150 default n
149 help 151 help
150 Include support for MX35PDK platform. This includes specific 152 Include support for MX35PDK platform. This includes specific
diff --git a/arch/arm/mach-mx3/devices.c b/arch/arm/mach-mx3/devices.c
index f4dff11aaee7..d4da9496089a 100644
--- a/arch/arm/mach-mx3/devices.c
+++ b/arch/arm/mach-mx3/devices.c
@@ -72,24 +72,24 @@ struct platform_device mxc_w1_master_device = {
72#ifdef CONFIG_ARCH_MX31 72#ifdef CONFIG_ARCH_MX31
73static struct resource mxcsdhc0_resources[] = { 73static struct resource mxcsdhc0_resources[] = {
74 { 74 {
75 .start = MMC_SDHC1_BASE_ADDR, 75 .start = MX31_MMC_SDHC1_BASE_ADDR,
76 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1, 76 .end = MX31_MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
77 .flags = IORESOURCE_MEM, 77 .flags = IORESOURCE_MEM,
78 }, { 78 }, {
79 .start = MXC_INT_MMC_SDHC1, 79 .start = MX31_INT_MMC_SDHC1,
80 .end = MXC_INT_MMC_SDHC1, 80 .end = MX31_INT_MMC_SDHC1,
81 .flags = IORESOURCE_IRQ, 81 .flags = IORESOURCE_IRQ,
82 }, 82 },
83}; 83};
84 84
85static struct resource mxcsdhc1_resources[] = { 85static struct resource mxcsdhc1_resources[] = {
86 { 86 {
87 .start = MMC_SDHC2_BASE_ADDR, 87 .start = MX31_MMC_SDHC2_BASE_ADDR,
88 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1, 88 .end = MX31_MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
89 .flags = IORESOURCE_MEM, 89 .flags = IORESOURCE_MEM,
90 }, { 90 }, {
91 .start = MXC_INT_MMC_SDHC2, 91 .start = MX31_INT_MMC_SDHC2,
92 .end = MXC_INT_MMC_SDHC2, 92 .end = MX31_INT_MMC_SDHC2,
93 .flags = IORESOURCE_IRQ, 93 .flags = IORESOURCE_IRQ,
94 }, 94 },
95}; 95};
diff --git a/arch/arm/mach-mx3/mach-cpuimx35.c b/arch/arm/mach-mx3/mach-cpuimx35.c
index 8533bf04284a..9fde873f5889 100644
--- a/arch/arm/mach-mx3/mach-cpuimx35.c
+++ b/arch/arm/mach-mx3/mach-cpuimx35.c
@@ -131,6 +131,7 @@ static struct mxc_usbh_platform_data __maybe_unused usbh1_pdata = {
131static struct fsl_usb2_platform_data otg_device_pdata = { 131static struct fsl_usb2_platform_data otg_device_pdata = {
132 .operating_mode = FSL_USB2_DR_DEVICE, 132 .operating_mode = FSL_USB2_DR_DEVICE,
133 .phy_mode = FSL_USB2_PHY_UTMI, 133 .phy_mode = FSL_USB2_PHY_UTMI,
134 .workaround = FLS_USB2_WORKAROUND_ENGCM09152,
134}; 135};
135 136
136static int otg_mode_host; 137static int otg_mode_host;
diff --git a/arch/arm/mach-mx3/mach-mx31_3ds.c b/arch/arm/mach-mx3/mach-mx31_3ds.c
index 5c1d0e86c91e..0ad9e7821082 100644
--- a/arch/arm/mach-mx3/mach-mx31_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx31_3ds.c
@@ -38,39 +38,9 @@
38#include "devices-imx31.h" 38#include "devices-imx31.h"
39#include "devices.h" 39#include "devices.h"
40 40
41/* Definitions for components on the Debug board */
42
43/* Base address of CPLD controller on the Debug board */
44#define DEBUG_BASE_ADDRESS CS5_IO_ADDRESS(MX3x_CS5_BASE_ADDR)
45
46/* LAN9217 ethernet base address */
47#define LAN9217_BASE_ADDR MX3x_CS5_BASE_ADDR
48
49/* CPLD config and interrupt base address */
50#define CPLD_ADDR (DEBUG_BASE_ADDRESS + 0x20000)
51
52/* status, interrupt */
53#define CPLD_INT_STATUS_REG (CPLD_ADDR + 0x10)
54#define CPLD_INT_MASK_REG (CPLD_ADDR + 0x38)
55#define CPLD_INT_RESET_REG (CPLD_ADDR + 0x20)
56/* magic word for debug CPLD */
57#define CPLD_MAGIC_NUMBER1_REG (CPLD_ADDR + 0x40)
58#define CPLD_MAGIC_NUMBER2_REG (CPLD_ADDR + 0x48)
59/* CPLD code version */
60#define CPLD_CODE_VER_REG (CPLD_ADDR + 0x50)
61/* magic word for debug CPLD */
62#define CPLD_MAGIC_NUMBER3_REG (CPLD_ADDR + 0x58)
63
64/* CPLD IRQ line for external uart, external ethernet etc */ 41/* CPLD IRQ line for external uart, external ethernet etc */
65#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1) 42#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_1)
66 43
67#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START)
68#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
69
70#define EXPIO_INT_ENET (MXC_EXP_IO_BASE + 0)
71
72#define MXC_MAX_EXP_IO_LINES 16
73
74/* 44/*
75 * This file contains the board-specific initialization routines. 45 * This file contains the board-specific initialization routines.
76 */ 46 */
@@ -272,7 +242,7 @@ static void __init mxc_board_init(void)
272 imx31_add_imx_uart0(&uart_pdata); 242 imx31_add_imx_uart0(&uart_pdata);
273 imx31_add_mxc_nand(&mx31_3ds_nand_board_info); 243 imx31_add_mxc_nand(&mx31_3ds_nand_board_info);
274 244
275 imx31_add_spi_imx0(&spi1_pdata); 245 imx31_add_spi_imx1(&spi1_pdata);
276 spi_register_board_info(mx31_3ds_spi_devs, 246 spi_register_board_info(mx31_3ds_spi_devs,
277 ARRAY_SIZE(mx31_3ds_spi_devs)); 247 ARRAY_SIZE(mx31_3ds_spi_devs));
278 248
@@ -281,9 +251,9 @@ static void __init mxc_board_init(void)
281 mx31_3ds_usbotg_init(); 251 mx31_3ds_usbotg_init();
282 mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata); 252 mxc_register_device(&mxc_otg_udc_device, &usbotg_pdata);
283 253
284 if (!mxc_expio_init(CS5_BASE_ADDR, EXPIO_PARENT_INT)) 254 if (mxc_expio_init(MX31_CS5_BASE_ADDR, EXPIO_PARENT_INT))
285 printk(KERN_WARNING "Init of the debugboard failed, all " 255 printk(KERN_WARNING "Init of the debug board failed, all "
286 "devices on the board are unusable.\n"); 256 "devices on the debug board are unusable.\n");
287} 257}
288 258
289static void __init mx31_3ds_timer_init(void) 259static void __init mx31_3ds_timer_init(void)
diff --git a/arch/arm/mach-mx3/mach-mx35_3ds.c b/arch/arm/mach-mx3/mach-mx35_3ds.c
index 05f628d90725..b66a75aa2e88 100644
--- a/arch/arm/mach-mx3/mach-mx35_3ds.c
+++ b/arch/arm/mach-mx3/mach-mx35_3ds.c
@@ -38,11 +38,15 @@
38#include <mach/hardware.h> 38#include <mach/hardware.h>
39#include <mach/common.h> 39#include <mach/common.h>
40#include <mach/iomux-mx35.h> 40#include <mach/iomux-mx35.h>
41#include <mach/irqs.h>
42#include <mach/3ds_debugboard.h>
41#include <mach/mxc_ehci.h> 43#include <mach/mxc_ehci.h>
42 44
43#include "devices-imx35.h" 45#include "devices-imx35.h"
44#include "devices.h" 46#include "devices.h"
45 47
48#define EXPIO_PARENT_INT (MXC_INTERNAL_IRQS + GPIO_PORTA + 1)
49
46static const struct imxuart_platform_data uart_pdata __initconst = { 50static const struct imxuart_platform_data uart_pdata __initconst = {
47 .flags = IMXUART_HAVE_RTSCTS, 51 .flags = IMXUART_HAVE_RTSCTS,
48}; 52};
@@ -108,6 +112,13 @@ static struct pad_desc mx35pdk_pads[] = {
108 /* USBH1 */ 112 /* USBH1 */
109 MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR, 113 MX35_PAD_I2C2_CLK__USB_TOP_USBH2_PWR,
110 MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC, 114 MX35_PAD_I2C2_DAT__USB_TOP_USBH2_OC,
115 /* SDCARD */
116 MX35_PAD_SD1_CMD__ESDHC1_CMD,
117 MX35_PAD_SD1_CLK__ESDHC1_CLK,
118 MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
119 MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
120 MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
121 MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
111}; 122};
112 123
113/* OTG config */ 124/* OTG config */
@@ -140,6 +151,11 @@ static void __init mxc_board_init(void)
140 mxc_register_device(&mxc_usbh1, &usb_host_pdata); 151 mxc_register_device(&mxc_usbh1, &usb_host_pdata);
141 152
142 imx35_add_mxc_nand(&mx35pdk_nand_board_info); 153 imx35_add_mxc_nand(&mx35pdk_nand_board_info);
154 imx35_add_esdhc(0, NULL);
155
156 if (mxc_expio_init(MX35_CS5_BASE_ADDR, EXPIO_PARENT_INT))
157 pr_warn("Init of the debugboard failed, all "
158 "devices on the debugboard are unusable.\n");
143} 159}
144 160
145static void __init mx35pdk_timer_init(void) 161static void __init mx35pdk_timer_init(void)
diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c
index 86e86c1300d5..2ff3f661a48e 100644
--- a/arch/arm/mach-mx3/mach-pcm037.c
+++ b/arch/arm/mach-mx3/mach-pcm037.c
@@ -311,7 +311,6 @@ static struct soc_camera_link iclink_mt9v022 = {
311 .bus_id = 0, /* Must match with the camera ID */ 311 .bus_id = 0, /* Must match with the camera ID */
312 .board_info = &pcm037_i2c_camera[1], 312 .board_info = &pcm037_i2c_camera[1],
313 .i2c_adapter_id = 2, 313 .i2c_adapter_id = 2,
314 .module_name = "mt9v022",
315}; 314};
316 315
317static struct soc_camera_link iclink_mt9t031 = { 316static struct soc_camera_link iclink_mt9t031 = {
@@ -319,7 +318,6 @@ static struct soc_camera_link iclink_mt9t031 = {
319 .power = pcm037_camera_power, 318 .power = pcm037_camera_power,
320 .board_info = &pcm037_i2c_camera[0], 319 .board_info = &pcm037_i2c_camera[0],
321 .i2c_adapter_id = 2, 320 .i2c_adapter_id = 2,
322 .module_name = "mt9t031",
323}; 321};
324 322
325static struct i2c_board_info pcm037_i2c_devices[] = { 323static struct i2c_board_info pcm037_i2c_devices[] = {
diff --git a/arch/arm/mach-mx3/mx31moboard-marxbot.c b/arch/arm/mach-mx3/mx31moboard-marxbot.c
index 0551eb39d97e..18069cb7d068 100644
--- a/arch/arm/mach-mx3/mx31moboard-marxbot.c
+++ b/arch/arm/mach-mx3/mx31moboard-marxbot.c
@@ -179,7 +179,6 @@ static struct soc_camera_link base_iclink = {
179 .reset = marxbot_basecam_reset, 179 .reset = marxbot_basecam_reset,
180 .board_info = &marxbot_i2c_devices[0], 180 .board_info = &marxbot_i2c_devices[0],
181 .i2c_adapter_id = 0, 181 .i2c_adapter_id = 0,
182 .module_name = "mt9t031",
183}; 182};
184 183
185static struct platform_device marxbot_camera[] = { 184static struct platform_device marxbot_camera[] = {
diff --git a/arch/arm/mach-mx3/mx31moboard-smartbot.c b/arch/arm/mach-mx3/mx31moboard-smartbot.c
index 417757e78c65..04760a53005a 100644
--- a/arch/arm/mach-mx3/mx31moboard-smartbot.c
+++ b/arch/arm/mach-mx3/mx31moboard-smartbot.c
@@ -88,7 +88,6 @@ static struct soc_camera_link base_iclink = {
88 .reset = smartbot_cam_reset, 88 .reset = smartbot_cam_reset,
89 .board_info = &smartbot_i2c_devices[0], 89 .board_info = &smartbot_i2c_devices[0],
90 .i2c_adapter_id = 0, 90 .i2c_adapter_id = 0,
91 .module_name = "mt9t031",
92}; 91};
93 92
94static struct platform_device smartbot_camera[] = { 93static struct platform_device smartbot_camera[] = {
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
index a2df9ac37996..3ec910a7a182 100644
--- a/arch/arm/mach-mx5/Kconfig
+++ b/arch/arm/mach-mx5/Kconfig
@@ -6,6 +6,7 @@ config ARCH_MX51
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 select ARCH_MXC_AUDMUX_V2
9 select ARCH_HAS_CPUFREQ
9 10
10comment "MX5 platforms:" 11comment "MX5 platforms:"
11 12
@@ -13,6 +14,7 @@ config MACH_MX51_BABBAGE
13 bool "Support MX51 BABBAGE platforms" 14 bool "Support MX51 BABBAGE platforms"
14 select IMX_HAVE_PLATFORM_IMX_I2C 15 select IMX_HAVE_PLATFORM_IMX_I2C
15 select IMX_HAVE_PLATFORM_IMX_UART 16 select IMX_HAVE_PLATFORM_IMX_UART
17 select IMX_HAVE_PLATFORM_ESDHC
16 help 18 help
17 Include support for MX51 Babbage platform, also known as MX51EVK in 19 Include support for MX51 Babbage platform, also known as MX51EVK in
18 u-boot. This includes specific configurations for the board and its 20 u-boot. This includes specific configurations for the board and its
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile
index 1769c161a60d..462f177eddfe 100644
--- a/arch/arm/mach-mx5/Makefile
+++ b/arch/arm/mach-mx5/Makefile
@@ -5,6 +5,7 @@
5# Object file lists. 5# Object file lists.
6obj-y := cpu.o mm.o clock-mx51.o devices.o 6obj-y := cpu.o mm.o clock-mx51.o devices.o
7 7
8obj-$(CONFIG_CPU_FREQ_IMX) += cpu_op-mx51.o
8obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o 9obj-$(CONFIG_MACH_MX51_BABBAGE) += board-mx51_babbage.o
9obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o 10obj-$(CONFIG_MACH_MX51_3DS) += board-mx51_3ds.o
10obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o 11obj-$(CONFIG_MACH_EUKREA_CPUIMX51) += board-cpuimx51.o
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 0821fe9b3b27..acbe30df2e69 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2009 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com> 3 * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com>
4 * 4 *
5 * The code contained herein is licensed under the GNU General Public 5 * The code contained herein is licensed under the GNU General Public
@@ -18,6 +18,8 @@
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#include <linux/fec.h>
21#include <linux/gpio_keys.h>
22#include <linux/input.h>
21 23
22#include <mach/common.h> 24#include <mach/common.h>
23#include <mach/hardware.h> 25#include <mach/hardware.h>
@@ -32,11 +34,13 @@
32 34
33#include "devices-imx51.h" 35#include "devices-imx51.h"
34#include "devices.h" 36#include "devices.h"
37#include "cpu_op-mx51.h"
35 38
36#define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */ 39#define BABBAGE_USB_HUB_RESET (0*32 + 7) /* GPIO_1_7 */
37#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */ 40#define BABBAGE_USBH1_STP (0*32 + 27) /* GPIO_1_27 */
38#define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */ 41#define BABBAGE_PHY_RESET (1*32 + 5) /* GPIO_2_5 */
39#define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */ 42#define BABBAGE_FEC_PHY_RESET (1*32 + 14) /* GPIO_2_14 */
43#define BABBAGE_POWER_KEY (1*32 + 21) /* GPIO_2_21 */
40 44
41/* USB_CTRL_1 */ 45/* USB_CTRL_1 */
42#define MX51_USB_CTRL_1_OFFSET 0x10 46#define MX51_USB_CTRL_1_OFFSET 0x10
@@ -46,6 +50,21 @@
46#define MX51_USB_PLL_DIV_19_2_MHZ 0x01 50#define MX51_USB_PLL_DIV_19_2_MHZ 0x01
47#define MX51_USB_PLL_DIV_24_MHZ 0x02 51#define MX51_USB_PLL_DIV_24_MHZ 0x02
48 52
53static struct gpio_keys_button babbage_buttons[] = {
54 {
55 .gpio = BABBAGE_POWER_KEY,
56 .code = BTN_0,
57 .desc = "PWR",
58 .active_low = 1,
59 .wakeup = 1,
60 },
61};
62
63static const struct gpio_keys_platform_data imx_button_data __initconst = {
64 .buttons = babbage_buttons,
65 .nbuttons = ARRAY_SIZE(babbage_buttons),
66};
67
49static struct pad_desc mx51babbage_pads[] = { 68static struct pad_desc mx51babbage_pads[] = {
50 /* UART1 */ 69 /* UART1 */
51 MX51_PAD_UART1_RXD__UART1_RXD, 70 MX51_PAD_UART1_RXD__UART1_RXD,
@@ -112,6 +131,22 @@ static struct pad_desc mx51babbage_pads[] = {
112 131
113 /* FEC PHY reset line */ 132 /* FEC PHY reset line */
114 MX51_PAD_EIM_A20__GPIO_2_14, 133 MX51_PAD_EIM_A20__GPIO_2_14,
134
135 /* SD 1 */
136 MX51_PAD_SD1_CMD__SD1_CMD,
137 MX51_PAD_SD1_CLK__SD1_CLK,
138 MX51_PAD_SD1_DATA0__SD1_DATA0,
139 MX51_PAD_SD1_DATA1__SD1_DATA1,
140 MX51_PAD_SD1_DATA2__SD1_DATA2,
141 MX51_PAD_SD1_DATA3__SD1_DATA3,
142
143 /* SD 2 */
144 MX51_PAD_SD2_CMD__SD2_CMD,
145 MX51_PAD_SD2_CLK__SD2_CLK,
146 MX51_PAD_SD2_DATA0__SD2_DATA0,
147 MX51_PAD_SD2_DATA1__SD2_DATA1,
148 MX51_PAD_SD2_DATA2__SD2_DATA2,
149 MX51_PAD_SD2_DATA3__SD2_DATA3,
115}; 150};
116 151
117/* Serial ports */ 152/* Serial ports */
@@ -281,13 +316,22 @@ __setup("otg_mode=", babbage_otg_mode);
281static void __init mxc_board_init(void) 316static void __init mxc_board_init(void)
282{ 317{
283 struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP; 318 struct pad_desc usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP;
319 struct pad_desc power_key = MX51_PAD_EIM_A27__GPIO_2_21;
284 320
321#if defined(CONFIG_CPU_FREQ_IMX)
322 get_cpu_op = mx51_get_cpu_op;
323#endif
285 mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, 324 mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads,
286 ARRAY_SIZE(mx51babbage_pads)); 325 ARRAY_SIZE(mx51babbage_pads));
287 mxc_init_imx_uart(); 326 mxc_init_imx_uart();
288 babbage_fec_reset(); 327 babbage_fec_reset();
289 imx51_add_fec(NULL); 328 imx51_add_fec(NULL);
290 329
330 /* Set the PAD settings for the pwr key. */
331 power_key.pad_ctrl = MX51_GPIO_PAD_CTRL_2;
332 mxc_iomux_v3_setup_pad(&power_key);
333 imx51_add_gpio_keys(&imx_button_data);
334
291 imx51_add_imx_i2c(0, &babbage_i2c_data); 335 imx51_add_imx_i2c(0, &babbage_i2c_data);
292 imx51_add_imx_i2c(1, &babbage_i2c_data); 336 imx51_add_imx_i2c(1, &babbage_i2c_data);
293 mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data); 337 mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data);
@@ -304,6 +348,9 @@ static void __init mxc_board_init(void)
304 /* setback USBH1_STP to be function */ 348 /* setback USBH1_STP to be function */
305 mxc_iomux_v3_setup_pad(&usbh1stp); 349 mxc_iomux_v3_setup_pad(&usbh1stp);
306 babbage_usbhub_reset(); 350 babbage_usbhub_reset();
351
352 imx51_add_esdhc(0, NULL);
353 imx51_add_esdhc(1, NULL);
307} 354}
308 355
309static void __init mx51_babbage_timer_init(void) 356static void __init mx51_babbage_timer_init(void)
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index f2aae92cf0e2..8ac36d882927 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -362,7 +362,7 @@ static int _clk_lp_apm_set_parent(struct clk *clk, struct clk *parent)
362 return 0; 362 return 0;
363} 363}
364 364
365static unsigned long clk_arm_get_rate(struct clk *clk) 365static unsigned long clk_cpu_get_rate(struct clk *clk)
366{ 366{
367 u32 cacrr, div; 367 u32 cacrr, div;
368 unsigned long parent_rate; 368 unsigned long parent_rate;
@@ -374,6 +374,22 @@ static unsigned long clk_arm_get_rate(struct clk *clk)
374 return parent_rate / div; 374 return parent_rate / div;
375} 375}
376 376
377static int clk_cpu_set_rate(struct clk *clk, unsigned long rate)
378{
379 u32 reg, cpu_podf;
380 unsigned long parent_rate;
381
382 parent_rate = clk_get_rate(clk->parent);
383 cpu_podf = parent_rate / rate - 1;
384 /* use post divider to change freq */
385 reg = __raw_readl(MXC_CCM_CACRR);
386 reg &= ~MXC_CCM_CACRR_ARM_PODF_MASK;
387 reg |= cpu_podf << MXC_CCM_CACRR_ARM_PODF_OFFSET;
388 __raw_writel(reg, MXC_CCM_CACRR);
389
390 return 0;
391}
392
377static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent) 393static int _clk_periph_apm_set_parent(struct clk *clk, struct clk *parent)
378{ 394{
379 u32 reg, mux; 395 u32 reg, mux;
@@ -736,7 +752,8 @@ static struct clk periph_apm_clk = {
736 752
737static struct clk cpu_clk = { 753static struct clk cpu_clk = {
738 .parent = &pll1_sw_clk, 754 .parent = &pll1_sw_clk,
739 .get_rate = clk_arm_get_rate, 755 .get_rate = clk_cpu_get_rate,
756 .set_rate = clk_cpu_set_rate,
740}; 757};
741 758
742static struct clk ahb_clk = { 759static struct clk ahb_clk = {
@@ -1064,6 +1081,7 @@ static struct clk_lookup lookups[] = {
1064 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) 1081 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)
1065 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) 1082 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
1066 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) 1083 _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk)
1084 _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)
1067}; 1085};
1068 1086
1069static void clk_tree_init(void) 1087static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/cpu_op-mx51.c b/arch/arm/mach-mx5/cpu_op-mx51.c
new file mode 100644
index 000000000000..9d34c3d4c024
--- /dev/null
+++ b/arch/arm/mach-mx5/cpu_op-mx51.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
9 *
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
12 */
13
14#include <linux/types.h>
15#include <mach/hardware.h>
16#include <linux/kernel.h>
17
18static struct cpu_op mx51_cpu_op[] = {
19 {
20 .cpu_rate = 160000000,},
21 {
22 .cpu_rate = 800000000,},
23};
24
25struct cpu_op *mx51_get_cpu_op(int *op)
26{
27 *op = ARRAY_SIZE(mx51_cpu_op);
28 return mx51_cpu_op;
29}
diff --git a/arch/arm/mach-mx5/cpu_op-mx51.h b/arch/arm/mach-mx5/cpu_op-mx51.h
new file mode 100644
index 000000000000..97477fecb469
--- /dev/null
+++ b/arch/arm/mach-mx5/cpu_op-mx51.h
@@ -0,0 +1,14 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
9 *
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
12 */
13
14extern struct cpu_op *mx51_get_cpu_op(int *op);
diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
index 5cc910e60538..8c50cb5d05f5 100644
--- a/arch/arm/mach-mx5/devices-imx51.h
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -13,6 +13,8 @@ extern const struct imx_fec_data imx51_fec_data __initconst;
13#define imx51_add_fec(pdata) \ 13#define imx51_add_fec(pdata) \
14 imx_add_fec(&imx51_fec_data, pdata) 14 imx_add_fec(&imx51_fec_data, pdata)
15 15
16#define imx51_add_gpio_keys(pdata) imx_add_gpio_keys(pdata)
17
16extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst; 18extern const struct imx_imx_i2c_data imx51_imx_i2c_data[] __initconst;
17#define imx51_add_imx_i2c(id, pdata) \ 19#define imx51_add_imx_i2c(id, pdata) \
18 imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata) 20 imx_add_imx_i2c(&imx51_imx_i2c_data[id], pdata)
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/Makefile b/arch/arm/mach-omap1/Makefile
index facfaeb1ae5c..9a304d854e33 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_OMAP_MPU_TIMER) += time.o
12obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o 12obj-$(CONFIG_OMAP_32K_TIMER) += timer32k.o
13 13
14# Power Management 14# Power Management
15obj-$(CONFIG_PM) += pm.o sleep.o 15obj-$(CONFIG_PM) += pm.o sleep.o pm_bus.o
16 16
17# DSP 17# DSP
18obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o 18obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 73c86392fcd3..1d4163b9f0b7 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -16,9 +16,12 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/leds.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/serial_8250.h> 21#include <linux/serial_8250.h>
21 22
23#include <media/soc_camera.h>
24
22#include <asm/serial.h> 25#include <asm/serial.h>
23#include <mach/hardware.h> 26#include <mach/hardware.h>
24#include <asm/mach-types.h> 27#include <asm/mach-types.h>
@@ -32,6 +35,7 @@
32#include <plat/usb.h> 35#include <plat/usb.h>
33#include <plat/board.h> 36#include <plat/board.h>
34#include <plat/common.h> 37#include <plat/common.h>
38#include <mach/camera.h>
35 39
36#include <mach/ams-delta-fiq.h> 40#include <mach/ams-delta-fiq.h>
37 41
@@ -213,10 +217,56 @@ static struct platform_device ams_delta_led_device = {
213 .id = -1 217 .id = -1
214}; 218};
215 219
220static struct i2c_board_info ams_delta_camera_board_info[] = {
221 {
222 I2C_BOARD_INFO("ov6650", 0x60),
223 },
224};
225
226#ifdef CONFIG_LEDS_TRIGGERS
227DEFINE_LED_TRIGGER(ams_delta_camera_led_trigger);
228
229static int ams_delta_camera_power(struct device *dev, int power)
230{
231 /*
232 * turn on camera LED
233 */
234 if (power)
235 led_trigger_event(ams_delta_camera_led_trigger, LED_FULL);
236 else
237 led_trigger_event(ams_delta_camera_led_trigger, LED_OFF);
238 return 0;
239}
240#else
241#define ams_delta_camera_power NULL
242#endif
243
244static struct soc_camera_link __initdata ams_delta_iclink = {
245 .bus_id = 0, /* OMAP1 SoC camera bus */
246 .i2c_adapter_id = 1,
247 .board_info = &ams_delta_camera_board_info[0],
248 .module_name = "ov6650",
249 .power = ams_delta_camera_power,
250};
251
252static struct platform_device ams_delta_camera_device = {
253 .name = "soc-camera-pdrv",
254 .id = 0,
255 .dev = {
256 .platform_data = &ams_delta_iclink,
257 },
258};
259
260static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
261 .camexclk_khz = 12000, /* default 12MHz clock, no extra DPLL */
262 .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */
263};
264
216static struct platform_device *ams_delta_devices[] __initdata = { 265static struct platform_device *ams_delta_devices[] __initdata = {
217 &ams_delta_kp_device, 266 &ams_delta_kp_device,
218 &ams_delta_lcd_device, 267 &ams_delta_lcd_device,
219 &ams_delta_led_device, 268 &ams_delta_led_device,
269 &ams_delta_camera_device,
220}; 270};
221 271
222static void __init ams_delta_init(void) 272static void __init ams_delta_init(void)
@@ -225,6 +275,20 @@ static void __init ams_delta_init(void)
225 omap_cfg_reg(UART1_TX); 275 omap_cfg_reg(UART1_TX);
226 omap_cfg_reg(UART1_RTS); 276 omap_cfg_reg(UART1_RTS);
227 277
278 /* parallel camera interface */
279 omap_cfg_reg(H19_1610_CAM_EXCLK);
280 omap_cfg_reg(J15_1610_CAM_LCLK);
281 omap_cfg_reg(L18_1610_CAM_VS);
282 omap_cfg_reg(L15_1610_CAM_HS);
283 omap_cfg_reg(L19_1610_CAM_D0);
284 omap_cfg_reg(K14_1610_CAM_D1);
285 omap_cfg_reg(K15_1610_CAM_D2);
286 omap_cfg_reg(K19_1610_CAM_D3);
287 omap_cfg_reg(K18_1610_CAM_D4);
288 omap_cfg_reg(J14_1610_CAM_D5);
289 omap_cfg_reg(J19_1610_CAM_D6);
290 omap_cfg_reg(J18_1610_CAM_D7);
291
228 iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); 292 iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
229 293
230 omap_board_config = ams_delta_config; 294 omap_board_config = ams_delta_config;
@@ -236,6 +300,11 @@ static void __init ams_delta_init(void)
236 ams_delta_latch2_write(~0, 0); 300 ams_delta_latch2_write(~0, 0);
237 301
238 omap1_usb_init(&ams_delta_usb_config); 302 omap1_usb_init(&ams_delta_usb_config);
303 omap1_set_camera_info(&ams_delta_camera_platform_data);
304#ifdef CONFIG_LEDS_TRIGGERS
305 led_trigger_register_simple("ams_delta_camera",
306 &ams_delta_camera_led_trigger);
307#endif
239 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); 308 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
240 309
241#ifdef CONFIG_AMS_DELTA_FIQ 310#ifdef CONFIG_AMS_DELTA_FIQ
diff --git a/arch/arm/mach-omap1/board-h2-mmc.c b/arch/arm/mach-omap1/board-h2-mmc.c
index b30c4990744d..f2fc43d8382b 100644
--- a/arch/arm/mach-omap1/board-h2-mmc.c
+++ b/arch/arm/mach-omap1/board-h2-mmc.c
@@ -58,8 +58,7 @@ static struct omap_mmc_platform_data mmc1_data = {
58 .dma_mask = 0xffffffff, 58 .dma_mask = 0xffffffff,
59 .slots[0] = { 59 .slots[0] = {
60 .set_power = mmc_set_power, 60 .set_power = mmc_set_power,
61 .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 | 61 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
62 MMC_VDD_32_33 | MMC_VDD_33_34,
63 .name = "mmcblk", 62 .name = "mmcblk",
64 }, 63 },
65}; 64};
diff --git a/arch/arm/mach-omap1/board-h3-mmc.c b/arch/arm/mach-omap1/board-h3-mmc.c
index 54b0f063e263..2098525e7cc5 100644
--- a/arch/arm/mach-omap1/board-h3-mmc.c
+++ b/arch/arm/mach-omap1/board-h3-mmc.c
@@ -40,8 +40,7 @@ static struct omap_mmc_platform_data mmc1_data = {
40 .dma_mask = 0xffffffff, 40 .dma_mask = 0xffffffff,
41 .slots[0] = { 41 .slots[0] = {
42 .set_power = mmc_set_power, 42 .set_power = mmc_set_power,
43 .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 | 43 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
44 MMC_VDD_32_33 | MMC_VDD_33_34,
45 .name = "mmcblk", 44 .name = "mmcblk",
46 }, 45 },
47}; 46};
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c
index 86afb2952225..071af3e47789 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -30,6 +30,13 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/gpio_keys.h>
34#include <linux/i2c.h>
35#include <linux/i2c-gpio.h>
36#include <linux/htcpld.h>
37#include <linux/leds.h>
38#include <linux/spi/spi.h>
39#include <linux/spi/ads7846.h>
33 40
34#include <asm/mach-types.h> 41#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 42#include <asm/mach/arch.h>
@@ -39,6 +46,7 @@
39#include <plat/board.h> 46#include <plat/board.h>
40#include <plat/keypad.h> 47#include <plat/keypad.h>
41#include <plat/usb.h> 48#include <plat/usb.h>
49#include <plat/mmc.h>
42 50
43#include <mach/irqs.h> 51#include <mach/irqs.h>
44 52
@@ -52,13 +60,123 @@
52#define OMAP_LCDC_CTRL_LCD_EN (1 << 0) 60#define OMAP_LCDC_CTRL_LCD_EN (1 << 0)
53#define OMAP_LCDC_STAT_DONE (1 << 0) 61#define OMAP_LCDC_STAT_DONE (1 << 0)
54 62
55static struct omap_lcd_config htcherald_lcd_config __initdata = { 63/* GPIO definitions for the power button and keyboard slide switch */
56 .ctrl_name = "internal", 64#define HTCHERALD_GPIO_POWER 139
57}; 65#define HTCHERALD_GPIO_SLIDE 174
66#define HTCHERALD_GIRQ_BTNS 141
58 67
59static struct omap_board_config_kernel htcherald_config[] __initdata = { 68/* GPIO definitions for the touchscreen */
60 { OMAP_TAG_LCD, &htcherald_lcd_config }, 69#define HTCHERALD_GPIO_TS 76
61}; 70
71/* HTCPLD definitions */
72
73/*
74 * CPLD Logic
75 *
76 * Chip 3 - 0x03
77 *
78 * Function 7 6 5 4 3 2 1 0
79 * ------------------------------------
80 * DPAD light x x x x x x x 1
81 * SoundDev x x x x 1 x x x
82 * Screen white 1 x x x x x x x
83 * MMC power on x x x x x 1 x x
84 * Happy times (n) 0 x x x x 1 x x
85 *
86 * Chip 4 - 0x04
87 *
88 * Function 7 6 5 4 3 2 1 0
89 * ------------------------------------
90 * Keyboard light x x x x x x x 1
91 * LCD Bright (4) x x x x x 1 1 x
92 * LCD Bright (3) x x x x x 0 1 x
93 * LCD Bright (2) x x x x x 1 0 x
94 * LCD Bright (1) x x x x x 0 0 x
95 * LCD Off x x x x 0 x x x
96 * LCD image (fb) 1 x x x x x x x
97 * LCD image (white) 0 x x x x x x x
98 * Caps lock LED x x 1 x x x x x
99 *
100 * Chip 5 - 0x05
101 *
102 * Function 7 6 5 4 3 2 1 0
103 * ------------------------------------
104 * Red (solid) x x x x x 1 x x
105 * Red (flash) x x x x x x 1 x
106 * Green (GSM flash) x x x x 1 x x x
107 * Green (GSM solid) x x x 1 x x x x
108 * Green (wifi flash) x x 1 x x x x x
109 * Blue (bt flash) x 1 x x x x x x
110 * DPAD Int Enable 1 x x x x x x 0
111 *
112 * (Combinations of the above can be made for different colors.)
113 * The direction pad interrupt enable must be set each time the
114 * interrupt is handled.
115 *
116 * Chip 6 - 0x06
117 *
118 * Function 7 6 5 4 3 2 1 0
119 * ------------------------------------
120 * Vibrator x x x x 1 x x x
121 * Alt LED x x x 1 x x x x
122 * Screen white 1 x x x x x x x
123 * Screen white x x 1 x x x x x
124 * Screen white x 0 x x x x x x
125 * Enable kbd dpad x x x x x x 0 x
126 * Happy Times 0 1 0 x x x 0 x
127 */
128
129/*
130 * HTCPLD GPIO lines start 16 after OMAP_MAX_GPIO_LINES to account
131 * for the 16 MPUIO lines.
132 */
133#define HTCPLD_GPIO_START_OFFSET (OMAP_MAX_GPIO_LINES + 16)
134#define HTCPLD_IRQ(chip, offset) (OMAP_IRQ_END + 8 * (chip) + (offset))
135#define HTCPLD_BASE(chip, offset) \
136 (HTCPLD_GPIO_START_OFFSET + 8 * (chip) + (offset))
137
138#define HTCPLD_GPIO_LED_DPAD HTCPLD_BASE(0, 0)
139#define HTCPLD_GPIO_LED_KBD HTCPLD_BASE(1, 0)
140#define HTCPLD_GPIO_LED_CAPS HTCPLD_BASE(1, 5)
141#define HTCPLD_GPIO_LED_RED_FLASH HTCPLD_BASE(2, 1)
142#define HTCPLD_GPIO_LED_RED_SOLID HTCPLD_BASE(2, 2)
143#define HTCPLD_GPIO_LED_GREEN_FLASH HTCPLD_BASE(2, 3)
144#define HTCPLD_GPIO_LED_GREEN_SOLID HTCPLD_BASE(2, 4)
145#define HTCPLD_GPIO_LED_WIFI HTCPLD_BASE(2, 5)
146#define HTCPLD_GPIO_LED_BT HTCPLD_BASE(2, 6)
147#define HTCPLD_GPIO_LED_VIBRATE HTCPLD_BASE(3, 3)
148#define HTCPLD_GPIO_LED_ALT HTCPLD_BASE(3, 4)
149
150#define HTCPLD_GPIO_RIGHT_KBD HTCPLD_BASE(6, 7)
151#define HTCPLD_GPIO_UP_KBD HTCPLD_BASE(6, 6)
152#define HTCPLD_GPIO_LEFT_KBD HTCPLD_BASE(6, 5)
153#define HTCPLD_GPIO_DOWN_KBD HTCPLD_BASE(6, 4)
154
155#define HTCPLD_GPIO_RIGHT_DPAD HTCPLD_BASE(7, 7)
156#define HTCPLD_GPIO_UP_DPAD HTCPLD_BASE(7, 6)
157#define HTCPLD_GPIO_LEFT_DPAD HTCPLD_BASE(7, 5)
158#define HTCPLD_GPIO_DOWN_DPAD HTCPLD_BASE(7, 4)
159#define HTCPLD_GPIO_ENTER_DPAD HTCPLD_BASE(7, 3)
160
161/*
162 * The htcpld chip requires a gpio write to a specific line
163 * to re-enable interrupts after one has occurred.
164 */
165#define HTCPLD_GPIO_INT_RESET_HI HTCPLD_BASE(2, 7)
166#define HTCPLD_GPIO_INT_RESET_LO HTCPLD_BASE(2, 0)
167
168/* Chip 5 */
169#define HTCPLD_IRQ_RIGHT_KBD HTCPLD_IRQ(0, 7)
170#define HTCPLD_IRQ_UP_KBD HTCPLD_IRQ(0, 6)
171#define HTCPLD_IRQ_LEFT_KBD HTCPLD_IRQ(0, 5)
172#define HTCPLD_IRQ_DOWN_KBD HTCPLD_IRQ(0, 4)
173
174/* Chip 6 */
175#define HTCPLD_IRQ_RIGHT_DPAD HTCPLD_IRQ(1, 7)
176#define HTCPLD_IRQ_UP_DPAD HTCPLD_IRQ(1, 6)
177#define HTCPLD_IRQ_LEFT_DPAD HTCPLD_IRQ(1, 5)
178#define HTCPLD_IRQ_DOWN_DPAD HTCPLD_IRQ(1, 4)
179#define HTCPLD_IRQ_ENTER_DPAD HTCPLD_IRQ(1, 3)
62 180
63/* Keyboard definition */ 181/* Keyboard definition */
64 182
@@ -140,6 +258,129 @@ static struct platform_device kp_device = {
140 .resource = kp_resources, 258 .resource = kp_resources,
141}; 259};
142 260
261/* GPIO buttons for keyboard slide and power button */
262static struct gpio_keys_button herald_gpio_keys_table[] = {
263 {BTN_0, HTCHERALD_GPIO_POWER, 1, "POWER", EV_KEY, 1, 20},
264 {SW_LID, HTCHERALD_GPIO_SLIDE, 0, "SLIDE", EV_SW, 1, 20},
265
266 {KEY_LEFT, HTCPLD_GPIO_LEFT_KBD, 1, "LEFT", EV_KEY, 1, 20},
267 {KEY_RIGHT, HTCPLD_GPIO_RIGHT_KBD, 1, "RIGHT", EV_KEY, 1, 20},
268 {KEY_UP, HTCPLD_GPIO_UP_KBD, 1, "UP", EV_KEY, 1, 20},
269 {KEY_DOWN, HTCPLD_GPIO_DOWN_KBD, 1, "DOWN", EV_KEY, 1, 20},
270
271 {KEY_LEFT, HTCPLD_GPIO_LEFT_DPAD, 1, "DLEFT", EV_KEY, 1, 20},
272 {KEY_RIGHT, HTCPLD_GPIO_RIGHT_DPAD, 1, "DRIGHT", EV_KEY, 1, 20},
273 {KEY_UP, HTCPLD_GPIO_UP_DPAD, 1, "DUP", EV_KEY, 1, 20},
274 {KEY_DOWN, HTCPLD_GPIO_DOWN_DPAD, 1, "DDOWN", EV_KEY, 1, 20},
275 {KEY_ENTER, HTCPLD_GPIO_ENTER_DPAD, 1, "DENTER", EV_KEY, 1, 20},
276};
277
278static struct gpio_keys_platform_data herald_gpio_keys_data = {
279 .buttons = herald_gpio_keys_table,
280 .nbuttons = ARRAY_SIZE(herald_gpio_keys_table),
281 .rep = 1,
282};
283
284static struct platform_device herald_gpiokeys_device = {
285 .name = "gpio-keys",
286 .id = -1,
287 .dev = {
288 .platform_data = &herald_gpio_keys_data,
289 },
290};
291
292/* LEDs for the Herald. These connect to the HTCPLD GPIO device. */
293static struct gpio_led gpio_leds[] = {
294 {"dpad", NULL, HTCPLD_GPIO_LED_DPAD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
295 {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
296 {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
297 {"green_solid", NULL, HTCPLD_GPIO_LED_GREEN_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
298 {"green_flash", NULL, HTCPLD_GPIO_LED_GREEN_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
299 {"red_solid", "mmc0", HTCPLD_GPIO_LED_RED_SOLID, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
300 {"red_flash", NULL, HTCPLD_GPIO_LED_RED_FLASH, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
301 {"wifi", NULL, HTCPLD_GPIO_LED_WIFI, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
302 {"bt", NULL, HTCPLD_GPIO_LED_BT, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
303 {"caps", NULL, HTCPLD_GPIO_LED_CAPS, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
304 {"alt", NULL, HTCPLD_GPIO_LED_ALT, 0, 0, LEDS_GPIO_DEFSTATE_OFF},
305};
306
307static struct gpio_led_platform_data gpio_leds_data = {
308 .leds = gpio_leds,
309 .num_leds = ARRAY_SIZE(gpio_leds),
310};
311
312static struct platform_device gpio_leds_device = {
313 .name = "leds-gpio",
314 .id = 0,
315 .dev = {
316 .platform_data = &gpio_leds_data,
317 },
318};
319
320/* HTC PLD chips */
321
322static struct resource htcpld_resources[] = {
323 [0] = {
324 .start = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
325 .end = OMAP_GPIO_IRQ(HTCHERALD_GIRQ_BTNS),
326 .flags = IORESOURCE_IRQ,
327 },
328};
329
330struct htcpld_chip_platform_data htcpld_chips[] = {
331 [0] = {
332 .addr = 0x03,
333 .reset = 0x04,
334 .num_gpios = 8,
335 .gpio_out_base = HTCPLD_BASE(0, 0),
336 .gpio_in_base = HTCPLD_BASE(4, 0),
337 },
338 [1] = {
339 .addr = 0x04,
340 .reset = 0x8e,
341 .num_gpios = 8,
342 .gpio_out_base = HTCPLD_BASE(1, 0),
343 .gpio_in_base = HTCPLD_BASE(5, 0),
344 },
345 [2] = {
346 .addr = 0x05,
347 .reset = 0x80,
348 .num_gpios = 8,
349 .gpio_out_base = HTCPLD_BASE(2, 0),
350 .gpio_in_base = HTCPLD_BASE(6, 0),
351 .irq_base = HTCPLD_IRQ(0, 0),
352 .num_irqs = 8,
353 },
354 [3] = {
355 .addr = 0x06,
356 .reset = 0x40,
357 .num_gpios = 8,
358 .gpio_out_base = HTCPLD_BASE(3, 0),
359 .gpio_in_base = HTCPLD_BASE(7, 0),
360 .irq_base = HTCPLD_IRQ(1, 0),
361 .num_irqs = 8,
362 },
363};
364
365struct htcpld_core_platform_data htcpld_pfdata = {
366 .int_reset_gpio_hi = HTCPLD_GPIO_INT_RESET_HI,
367 .int_reset_gpio_lo = HTCPLD_GPIO_INT_RESET_LO,
368 .i2c_adapter_id = 1,
369
370 .chip = htcpld_chips,
371 .num_chip = ARRAY_SIZE(htcpld_chips),
372};
373
374static struct platform_device htcpld_device = {
375 .name = "i2c-htcpld",
376 .id = -1,
377 .resource = htcpld_resources,
378 .num_resources = ARRAY_SIZE(htcpld_resources),
379 .dev = {
380 .platform_data = &htcpld_pfdata,
381 },
382};
383
143/* USB Device */ 384/* USB Device */
144static struct omap_usb_config htcherald_usb_config __initdata = { 385static struct omap_usb_config htcherald_usb_config __initdata = {
145 .otg = 0, 386 .otg = 0,
@@ -150,14 +391,71 @@ static struct omap_usb_config htcherald_usb_config __initdata = {
150}; 391};
151 392
152/* LCD Device resources */ 393/* LCD Device resources */
394static struct omap_lcd_config htcherald_lcd_config __initdata = {
395 .ctrl_name = "internal",
396};
397
398static struct omap_board_config_kernel htcherald_config[] __initdata = {
399 { OMAP_TAG_LCD, &htcherald_lcd_config },
400};
401
153static struct platform_device lcd_device = { 402static struct platform_device lcd_device = {
154 .name = "lcd_htcherald", 403 .name = "lcd_htcherald",
155 .id = -1, 404 .id = -1,
156}; 405};
157 406
407/* MMC Card */
408#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
409static struct omap_mmc_platform_data htc_mmc1_data = {
410 .nr_slots = 1,
411 .switch_slot = NULL,
412 .slots[0] = {
413 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
414 .name = "mmcblk",
415 .nomux = 1,
416 .wires = 4,
417 .switch_pin = -1,
418 },
419};
420
421static struct omap_mmc_platform_data *htc_mmc_data[1];
422#endif
423
424
425/* Platform devices for the Herald */
158static struct platform_device *devices[] __initdata = { 426static struct platform_device *devices[] __initdata = {
159 &kp_device, 427 &kp_device,
160 &lcd_device, 428 &lcd_device,
429 &htcpld_device,
430 &gpio_leds_device,
431 &herald_gpiokeys_device,
432};
433
434/*
435 * Touchscreen
436 */
437static const struct ads7846_platform_data htcherald_ts_platform_data = {
438 .model = 7846,
439 .keep_vref_on = 1,
440 .x_plate_ohms = 496,
441 .gpio_pendown = HTCHERALD_GPIO_TS,
442 .pressure_max = 100000,
443 .pressure_min = 5000,
444 .x_min = 528,
445 .x_max = 3760,
446 .y_min = 624,
447 .y_max = 3760,
448};
449
450static struct spi_board_info __initdata htcherald_spi_board_info[] = {
451 {
452 .modalias = "ads7846",
453 .platform_data = &htcherald_ts_platform_data,
454 .irq = OMAP_GPIO_IRQ(HTCHERALD_GPIO_TS),
455 .max_speed_hz = 2500000,
456 .bus_num = 2,
457 .chip_select = 1,
458 }
161}; 459};
162 460
163/* 461/*
@@ -278,6 +576,7 @@ static void __init htcherald_init(void)
278{ 576{
279 printk(KERN_INFO "HTC Herald init.\n"); 577 printk(KERN_INFO "HTC Herald init.\n");
280 578
579 /* Do board initialization before we register all the devices */
281 omap_gpio_init(); 580 omap_gpio_init();
282 581
283 omap_board_config = htcherald_config; 582 omap_board_config = htcherald_config;
@@ -288,6 +587,16 @@ static void __init htcherald_init(void)
288 587
289 htcherald_usb_enable(); 588 htcherald_usb_enable();
290 omap1_usb_init(&htcherald_usb_config); 589 omap1_usb_init(&htcherald_usb_config);
590
591 spi_register_board_info(htcherald_spi_board_info,
592 ARRAY_SIZE(htcherald_spi_board_info));
593
594 omap_register_i2c_bus(1, 100, NULL, 0);
595
596#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
597 htc_mmc_data[0] = &htc_mmc1_data;
598 omap1_init_mmc(htc_mmc_data, 1);
599#endif
291} 600}
292 601
293static void __init htcherald_init_irq(void) 602static void __init htcherald_init_irq(void)
diff --git a/arch/arm/mach-omap1/board-sx1-mmc.c b/arch/arm/mach-omap1/board-sx1-mmc.c
index 5b33ae8141bc..e8ddd86e3fda 100644
--- a/arch/arm/mach-omap1/board-sx1-mmc.c
+++ b/arch/arm/mach-omap1/board-sx1-mmc.c
@@ -44,8 +44,7 @@ static struct omap_mmc_platform_data mmc1_data = {
44 .nr_slots = 1, 44 .nr_slots = 1,
45 .slots[0] = { 45 .slots[0] = {
46 .set_power = mmc_set_power, 46 .set_power = mmc_set_power,
47 .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 | 47 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
48 MMC_VDD_32_33 | MMC_VDD_33_34,
49 .name = "mmcblk", 48 .name = "mmcblk",
50 }, 49 },
51}; 50};
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index aa0725608fb1..e7f9ee63dce5 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -9,6 +9,7 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/dma-mapping.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <linux/init.h> 15#include <linux/init.h>
@@ -25,6 +26,7 @@
25#include <mach/gpio.h> 26#include <mach/gpio.h>
26#include <plat/mmc.h> 27#include <plat/mmc.h>
27#include <plat/omap7xx.h> 28#include <plat/omap7xx.h>
29#include <plat/mcbsp.h>
28 30
29/*-------------------------------------------------------------------------*/ 31/*-------------------------------------------------------------------------*/
30 32
@@ -191,10 +193,76 @@ static inline void omap_init_spi100k(void)
191} 193}
192#endif 194#endif
193 195
196
197#define OMAP1_CAMERA_BASE 0xfffb6800
198#define OMAP1_CAMERA_IOSIZE 0x1c
199
200static struct resource omap1_camera_resources[] = {
201 [0] = {
202 .start = OMAP1_CAMERA_BASE,
203 .end = OMAP1_CAMERA_BASE + OMAP1_CAMERA_IOSIZE - 1,
204 .flags = IORESOURCE_MEM,
205 },
206 [1] = {
207 .start = INT_CAMERA,
208 .flags = IORESOURCE_IRQ,
209 },
210};
211
212static u64 omap1_camera_dma_mask = DMA_BIT_MASK(32);
213
214static struct platform_device omap1_camera_device = {
215 .name = "omap1-camera",
216 .id = 0, /* This is used to put cameras on this interface */
217 .dev = {
218 .dma_mask = &omap1_camera_dma_mask,
219 .coherent_dma_mask = DMA_BIT_MASK(32),
220 },
221 .num_resources = ARRAY_SIZE(omap1_camera_resources),
222 .resource = omap1_camera_resources,
223};
224
225void __init omap1_camera_init(void *info)
226{
227 struct platform_device *dev = &omap1_camera_device;
228 int ret;
229
230 dev->dev.platform_data = info;
231
232 ret = platform_device_register(dev);
233 if (ret)
234 dev_err(&dev->dev, "unable to register device: %d\n", ret);
235}
236
237
194/*-------------------------------------------------------------------------*/ 238/*-------------------------------------------------------------------------*/
195 239
196static inline void omap_init_sti(void) {} 240static inline void omap_init_sti(void) {}
197 241
242#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
243
244static struct platform_device omap_pcm = {
245 .name = "omap-pcm-audio",
246 .id = -1,
247};
248
249OMAP_MCBSP_PLATFORM_DEVICE(1);
250OMAP_MCBSP_PLATFORM_DEVICE(2);
251OMAP_MCBSP_PLATFORM_DEVICE(3);
252
253static void omap_init_audio(void)
254{
255 platform_device_register(&omap_mcbsp1);
256 platform_device_register(&omap_mcbsp2);
257 if (!cpu_is_omap7xx())
258 platform_device_register(&omap_mcbsp3);
259 platform_device_register(&omap_pcm);
260}
261
262#else
263static inline void omap_init_audio(void) {}
264#endif
265
198/*-------------------------------------------------------------------------*/ 266/*-------------------------------------------------------------------------*/
199 267
200/* 268/*
@@ -227,8 +295,35 @@ static int __init omap1_init_devices(void)
227 omap_init_rtc(); 295 omap_init_rtc();
228 omap_init_spi100k(); 296 omap_init_spi100k();
229 omap_init_sti(); 297 omap_init_sti();
298 omap_init_audio();
230 299
231 return 0; 300 return 0;
232} 301}
233arch_initcall(omap1_init_devices); 302arch_initcall(omap1_init_devices);
234 303
304#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
305
306static struct resource wdt_resources[] = {
307 {
308 .start = 0xfffeb000,
309 .end = 0xfffeb07F,
310 .flags = IORESOURCE_MEM,
311 },
312};
313
314static struct platform_device omap_wdt_device = {
315 .name = "omap_wdt",
316 .id = -1,
317 .num_resources = ARRAY_SIZE(wdt_resources),
318 .resource = wdt_resources,
319};
320
321static int __init omap_init_wdt(void)
322{
323 if (!cpu_is_omap16xx())
324 return -ENODEV;
325
326 return platform_device_register(&omap_wdt_device);
327}
328subsys_initcall(omap_init_wdt);
329#endif
diff --git a/arch/arm/mach-omap1/include/mach/camera.h b/arch/arm/mach-omap1/include/mach/camera.h
new file mode 100644
index 000000000000..847d00f0bb0a
--- /dev/null
+++ b/arch/arm/mach-omap1/include/mach/camera.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_ARCH_CAMERA_H_
2#define __ASM_ARCH_CAMERA_H_
3
4#include <media/omap1_camera.h>
5
6void omap1_camera_init(void *);
7
8static inline void omap1_set_camera_info(struct omap1_cam_platform_data *info)
9{
10 omap1_camera_init(info);
11}
12
13#endif /* __ASM_ARCH_CAMERA_H_ */
diff --git a/arch/arm/mach-omap1/pm_bus.c b/arch/arm/mach-omap1/pm_bus.c
new file mode 100644
index 000000000000..8b66392be745
--- /dev/null
+++ b/arch/arm/mach-omap1/pm_bus.c
@@ -0,0 +1,98 @@
1/*
2 * Runtime PM support code for OMAP1
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/io.h>
15#include <linux/pm_runtime.h>
16#include <linux/platform_device.h>
17#include <linux/mutex.h>
18#include <linux/clk.h>
19#include <linux/err.h>
20
21#include <plat/omap_device.h>
22#include <plat/omap-pm.h>
23
24#ifdef CONFIG_PM_RUNTIME
25static int omap1_pm_runtime_suspend(struct device *dev)
26{
27 struct clk *iclk, *fclk;
28 int ret = 0;
29
30 dev_dbg(dev, "%s\n", __func__);
31
32 ret = pm_generic_runtime_suspend(dev);
33
34 fclk = clk_get(dev, "fck");
35 if (!IS_ERR(fclk)) {
36 clk_disable(fclk);
37 clk_put(fclk);
38 }
39
40 iclk = clk_get(dev, "ick");
41 if (!IS_ERR(iclk)) {
42 clk_disable(iclk);
43 clk_put(iclk);
44 }
45
46 return 0;
47};
48
49static int omap1_pm_runtime_resume(struct device *dev)
50{
51 int ret = 0;
52 struct clk *iclk, *fclk;
53
54 dev_dbg(dev, "%s\n", __func__);
55
56 iclk = clk_get(dev, "ick");
57 if (!IS_ERR(iclk)) {
58 clk_enable(iclk);
59 clk_put(iclk);
60 }
61
62 fclk = clk_get(dev, "fck");
63 if (!IS_ERR(fclk)) {
64 clk_enable(fclk);
65 clk_put(fclk);
66 }
67
68 return pm_generic_runtime_resume(dev);
69};
70
71static int __init omap1_pm_runtime_init(void)
72{
73 const struct dev_pm_ops *pm;
74 struct dev_pm_ops *omap_pm;
75
76 pm = platform_bus_get_pm_ops();
77 if (!pm) {
78 pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
79 __func__);
80 return -ENODEV;
81 }
82
83 omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL);
84 if (!omap_pm) {
85 pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
86 __func__);
87 return -ENOMEM;
88 }
89
90 omap_pm->runtime_suspend = omap1_pm_runtime_suspend;
91 omap_pm->runtime_resume = omap1_pm_runtime_resume;
92
93 platform_bus_set_pm_ops(omap_pm);
94
95 return 0;
96}
97core_initcall(omap1_pm_runtime_init);
98#endif /* CONFIG_PM_RUNTIME */
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index b48bacf0a7aa..ab784bfde908 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -11,9 +11,8 @@ config ARCH_OMAP2PLUS_TYPICAL
11 select PM_RUNTIME 11 select PM_RUNTIME
12 select VFP 12 select VFP
13 select NEON if ARCH_OMAP3 || ARCH_OMAP4 13 select NEON if ARCH_OMAP3 || ARCH_OMAP4
14 select SERIAL_8250 14 select SERIAL_OMAP
15 select SERIAL_CORE_CONSOLE 15 select SERIAL_OMAP_CONSOLE
16 select SERIAL_8250_CONSOLE
17 select I2C 16 select I2C
18 select I2C_OMAP 17 select I2C_OMAP
19 select MFD 18 select MFD
@@ -35,7 +34,7 @@ config ARCH_OMAP3
35 default y 34 default y
36 select CPU_V7 35 select CPU_V7
37 select USB_ARCH_HAS_EHCI 36 select USB_ARCH_HAS_EHCI
38 select ARM_L1_CACHE_SHIFT_6 37 select ARM_L1_CACHE_SHIFT_6 if !ARCH_OMAP4
39 38
40config ARCH_OMAP4 39config ARCH_OMAP4
41 bool "TI OMAP4" 40 bool "TI OMAP4"
@@ -43,6 +42,8 @@ config ARCH_OMAP4
43 depends on ARCH_OMAP2PLUS 42 depends on ARCH_OMAP2PLUS
44 select CPU_V7 43 select CPU_V7
45 select ARM_GIC 44 select ARM_GIC
45 select PL310_ERRATA_588369
46 select ARM_ERRATA_720789
46 47
47comment "OMAP Core Type" 48comment "OMAP Core Type"
48 depends on ARCH_OMAP2 49 depends on ARCH_OMAP2
@@ -99,20 +100,20 @@ config MACH_OMAP2_TUSB6010
99 100
100config MACH_OMAP_H4 101config MACH_OMAP_H4
101 bool "OMAP 2420 H4 board" 102 bool "OMAP 2420 H4 board"
102 depends on ARCH_OMAP2 103 depends on ARCH_OMAP2420
103 default y 104 default y
104 select OMAP_PACKAGE_ZAF 105 select OMAP_PACKAGE_ZAF
105 select OMAP_DEBUG_DEVICES 106 select OMAP_DEBUG_DEVICES
106 107
107config MACH_OMAP_APOLLON 108config MACH_OMAP_APOLLON
108 bool "OMAP 2420 Apollon board" 109 bool "OMAP 2420 Apollon board"
109 depends on ARCH_OMAP2 110 depends on ARCH_OMAP2420
110 default y 111 default y
111 select OMAP_PACKAGE_ZAC 112 select OMAP_PACKAGE_ZAC
112 113
113config MACH_OMAP_2430SDP 114config MACH_OMAP_2430SDP
114 bool "OMAP 2430 SDP board" 115 bool "OMAP 2430 SDP board"
115 depends on ARCH_OMAP2 116 depends on ARCH_OMAP2430
116 default y 117 default y
117 select OMAP_PACKAGE_ZAC 118 select OMAP_PACKAGE_ZAC
118 119
@@ -135,6 +136,26 @@ config MACH_OMAP_LDP
135 default y 136 default y
136 select OMAP_PACKAGE_CBB 137 select OMAP_PACKAGE_CBB
137 138
139config MACH_OMAP3530_LV_SOM
140 bool "OMAP3 Logic 3530 LV SOM board"
141 depends on ARCH_OMAP3
142 select OMAP_PACKAGE_CBB
143 default y
144 help
145 Support for the LogicPD OMAP3530 SOM Development kit
146 for full description please see the products webpage at
147 http://www.logicpd.com/products/development-kits/texas-instruments-zoom%E2%84%A2-omap35x-development-kit
148
149config MACH_OMAP3_TORPEDO
150 bool "OMAP3 Logic 35x Torpedo board"
151 depends on ARCH_OMAP3
152 select OMAP_PACKAGE_CBB
153 default y
154 help
155 Support for the LogicPD OMAP35x Torpedo Development kit
156 for full description please see the products webpage at
157 http://www.logicpd.com/products/development-kits/zoom-omap35x-torpedo-development-kit
158
138config MACH_OVERO 159config MACH_OVERO
139 bool "Gumstix Overo board" 160 bool "Gumstix Overo board"
140 depends on ARCH_OMAP3 161 depends on ARCH_OMAP3
@@ -200,12 +221,18 @@ config MACH_OMAP_ZOOM2
200 depends on ARCH_OMAP3 221 depends on ARCH_OMAP3
201 default y 222 default y
202 select OMAP_PACKAGE_CBB 223 select OMAP_PACKAGE_CBB
224 select SERIAL_8250
225 select SERIAL_CORE_CONSOLE
226 select SERIAL_8250_CONSOLE
203 227
204config MACH_OMAP_ZOOM3 228config MACH_OMAP_ZOOM3
205 bool "OMAP3630 Zoom3 board" 229 bool "OMAP3630 Zoom3 board"
206 depends on ARCH_OMAP3 230 depends on ARCH_OMAP3
207 default y 231 default y
208 select OMAP_PACKAGE_CBP 232 select OMAP_PACKAGE_CBP
233 select SERIAL_8250
234 select SERIAL_CORE_CONSOLE
235 select SERIAL_8250_CONSOLE
209 236
210config MACH_CM_T35 237config MACH_CM_T35
211 bool "CompuLab CM-T35 module" 238 bool "CompuLab CM-T35 module"
@@ -214,12 +241,25 @@ config MACH_CM_T35
214 select OMAP_PACKAGE_CUS 241 select OMAP_PACKAGE_CUS
215 select OMAP_MUX 242 select OMAP_MUX
216 243
244config MACH_CM_T3517
245 bool "CompuLab CM-T3517 module"
246 depends on ARCH_OMAP3
247 default y
248 select OMAP_PACKAGE_CBB
249 select OMAP_MUX
250
217config MACH_IGEP0020 251config MACH_IGEP0020
218 bool "IGEP v2 board" 252 bool "IGEP v2 board"
219 depends on ARCH_OMAP3 253 depends on ARCH_OMAP3
220 default y 254 default y
221 select OMAP_PACKAGE_CBB 255 select OMAP_PACKAGE_CBB
222 256
257config MACH_IGEP0030
258 bool "IGEP OMAP3 module"
259 depends on ARCH_OMAP3
260 default y
261 select OMAP_PACKAGE_CBB
262
223config MACH_SBC3530 263config MACH_SBC3530
224 bool "OMAP3 SBC STALKER board" 264 bool "OMAP3 SBC STALKER board"
225 depends on ARCH_OMAP3 265 depends on ARCH_OMAP3
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 88d3a1e920f5..60e51bcf53bd 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -3,9 +3,10 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o 6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o \
7 common.o
7 8
8omap-2-3-common = irq.o sdrc.o 9omap-2-3-common = irq.o sdrc.o prm2xxx_3xxx.o
9hwmod-common = omap_hwmod.o \ 10hwmod-common = omap_hwmod.o \
10 omap_hwmod_common_data.o 11 omap_hwmod_common_data.o
11prcm-common = prcm.o powerdomain.o 12prcm-common = prcm.o powerdomain.o
@@ -15,7 +16,7 @@ clock-common = clock.o clock_common_data.o \
15 16
16obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) $(hwmod-common) 17obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) $(hwmod-common)
17obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(prcm-common) $(hwmod-common) 18obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(prcm-common) $(hwmod-common)
18obj-$(CONFIG_ARCH_OMAP4) += $(prcm-common) $(hwmod-common) 19obj-$(CONFIG_ARCH_OMAP4) += $(prcm-common) prm44xx.o $(hwmod-common)
19 20
20obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o 21obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
21 22
@@ -49,14 +50,18 @@ obj-$(CONFIG_ARCH_OMAP2) += sdrc2xxx.o
49# Power Management 50# Power Management
50ifeq ($(CONFIG_PM),y) 51ifeq ($(CONFIG_PM),y)
51obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o 52obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o
52obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o 53obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o pm_bus.o
53obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o 54obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o cpuidle34xx.o pm_bus.o
54obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o 55obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o pm_bus.o
55obj-$(CONFIG_PM_DEBUG) += pm-debug.o 56obj-$(CONFIG_PM_DEBUG) += pm-debug.o
56 57
57AFLAGS_sleep24xx.o :=-Wa,-march=armv6 58AFLAGS_sleep24xx.o :=-Wa,-march=armv6
58AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a 59AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a
59 60
61ifeq ($(CONFIG_PM_VERBOSE),y)
62CFLAGS_pm_bus.o += -DDEBUG
63endif
64
60endif 65endif
61 66
62# PRCM 67# PRCM
@@ -87,6 +92,7 @@ obj-$(CONFIG_ARCH_OMAP2430) += opp2430_data.o
87obj-$(CONFIG_ARCH_OMAP2420) += omap_hwmod_2420_data.o 92obj-$(CONFIG_ARCH_OMAP2420) += omap_hwmod_2420_data.o
88obj-$(CONFIG_ARCH_OMAP2430) += omap_hwmod_2430_data.o 93obj-$(CONFIG_ARCH_OMAP2430) += omap_hwmod_2430_data.o
89obj-$(CONFIG_ARCH_OMAP3) += omap_hwmod_3xxx_data.o 94obj-$(CONFIG_ARCH_OMAP3) += omap_hwmod_3xxx_data.o
95obj-$(CONFIG_ARCH_OMAP4) += omap_hwmod_44xx_data.o
90 96
91# EMU peripherals 97# EMU peripherals
92obj-$(CONFIG_OMAP3_EMU) += emu.o 98obj-$(CONFIG_OMAP3_EMU) += emu.o
@@ -102,6 +108,10 @@ obj-y += $(iommu-m) $(iommu-y)
102i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o 108i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
103obj-y += $(i2c-omap-m) $(i2c-omap-y) 109obj-y += $(i2c-omap-m) $(i2c-omap-y)
104 110
111ifneq ($(CONFIG_TIDSPBRIDGE),)
112obj-y += dsp.o
113endif
114
105# Specific board support 115# Specific board support
106obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o 116obj-$(CONFIG_MACH_OMAP_GENERIC) += board-generic.o
107obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o 117obj-$(CONFIG_MACH_OMAP_H4) += board-h4.o
@@ -115,6 +125,10 @@ obj-$(CONFIG_MACH_DEVKIT8000) += board-devkit8000.o \
115obj-$(CONFIG_MACH_OMAP_LDP) += board-ldp.o \ 125obj-$(CONFIG_MACH_OMAP_LDP) += board-ldp.o \
116 board-flash.o \ 126 board-flash.o \
117 hsmmc.o 127 hsmmc.o
128obj-$(CONFIG_MACH_OMAP3530_LV_SOM) += board-omap3logic.o \
129 hsmmc.o
130obj-$(CONFIG_MACH_OMAP3_TORPEDO) += board-omap3logic.o \
131 hsmmc.o
118obj-$(CONFIG_MACH_OVERO) += board-overo.o \ 132obj-$(CONFIG_MACH_OVERO) += board-overo.o \
119 hsmmc.o 133 hsmmc.o
120obj-$(CONFIG_MACH_OMAP3EVM) += board-omap3evm.o \ 134obj-$(CONFIG_MACH_OMAP3EVM) += board-omap3evm.o \
@@ -146,8 +160,11 @@ obj-$(CONFIG_MACH_OMAP_3630SDP) += board-3630sdp.o \
146 hsmmc.o 160 hsmmc.o
147obj-$(CONFIG_MACH_CM_T35) += board-cm-t35.o \ 161obj-$(CONFIG_MACH_CM_T35) += board-cm-t35.o \
148 hsmmc.o 162 hsmmc.o
163obj-$(CONFIG_MACH_CM_T3517) += board-cm-t3517.o
149obj-$(CONFIG_MACH_IGEP0020) += board-igep0020.o \ 164obj-$(CONFIG_MACH_IGEP0020) += board-igep0020.o \
150 hsmmc.o 165 hsmmc.o
166obj-$(CONFIG_MACH_IGEP0030) += board-igep0030.o \
167 hsmmc.o
151obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK) += board-omap3touchbook.o \ 168obj-$(CONFIG_MACH_OMAP3_TOUCHBOOK) += board-omap3touchbook.o \
152 hsmmc.o 169 hsmmc.o
153obj-$(CONFIG_MACH_OMAP_4430SDP) += board-4430sdp.o \ 170obj-$(CONFIG_MACH_OMAP_4430SDP) += board-4430sdp.o \
@@ -174,3 +191,6 @@ obj-y += $(nand-m) $(nand-y)
174 191
175smc91x-$(CONFIG_SMC91X) := gpmc-smc91x.o 192smc91x-$(CONFIG_SMC91X) := gpmc-smc91x.o
176obj-y += $(smc91x-m) $(smc91x-y) 193obj-y += $(smc91x-m) $(smc91x-y)
194
195smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o
196obj-y += $(smsc911x-m) $(smsc911x-y)
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index b857ce484510..b527f8d187ad 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -19,6 +19,7 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
21#include <linux/mtd/physmap.h> 21#include <linux/mtd/physmap.h>
22#include <linux/mmc/host.h>
22#include <linux/delay.h> 23#include <linux/delay.h>
23#include <linux/i2c/twl.h> 24#include <linux/i2c/twl.h>
24#include <linux/err.h> 25#include <linux/err.h>
@@ -190,7 +191,7 @@ static int __init omap2430_i2c_init(void)
190static struct omap2_hsmmc_info mmc[] __initdata = { 191static struct omap2_hsmmc_info mmc[] __initdata = {
191 { 192 {
192 .mmc = 1, 193 .mmc = 1,
193 .wires = 4, 194 .caps = MMC_CAP_4_BIT_DATA,
194 .gpio_cd = -EINVAL, 195 .gpio_cd = -EINVAL,
195 .gpio_wp = -EINVAL, 196 .gpio_wp = -EINVAL,
196 .ext_clock = 1, 197 .ext_clock = 1,
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index a5b095cf2adc..4e3742c512b8 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -24,6 +24,7 @@
24#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/mmc/host.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <asm/mach-types.h> 30#include <asm/mach-types.h>
@@ -38,15 +39,14 @@
38#include <plat/gpmc.h> 39#include <plat/gpmc.h>
39#include <plat/display.h> 40#include <plat/display.h>
40 41
41#include <plat/control.h>
42#include <plat/gpmc-smc91x.h> 42#include <plat/gpmc-smc91x.h>
43 43
44#include <mach/board-flash.h> 44#include "board-flash.h"
45
46#include "mux.h" 45#include "mux.h"
47#include "sdram-qimonda-hyb18m512160af-6.h" 46#include "sdram-qimonda-hyb18m512160af-6.h"
48#include "hsmmc.h" 47#include "hsmmc.h"
49#include "pm.h" 48#include "pm.h"
49#include "control.h"
50 50
51#define CONFIG_DISABLE_HFCLK 1 51#define CONFIG_DISABLE_HFCLK 1
52 52
@@ -76,7 +76,7 @@ static struct cpuidle_params omap3_cpuidle_params_table[] = {
76 {1, 10000, 30000, 300000}, 76 {1, 10000, 30000, 300000},
77}; 77};
78 78
79static int board_keymap[] = { 79static uint32_t board_keymap[] = {
80 KEY(0, 0, KEY_LEFT), 80 KEY(0, 0, KEY_LEFT),
81 KEY(0, 1, KEY_RIGHT), 81 KEY(0, 1, KEY_RIGHT),
82 KEY(0, 2, KEY_A), 82 KEY(0, 2, KEY_A),
@@ -353,12 +353,12 @@ static struct omap2_hsmmc_info mmc[] = {
353 /* 8 bits (default) requires S6.3 == ON, 353 /* 8 bits (default) requires S6.3 == ON,
354 * so the SIM card isn't used; else 4 bits. 354 * so the SIM card isn't used; else 4 bits.
355 */ 355 */
356 .wires = 8, 356 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
357 .gpio_wp = 4, 357 .gpio_wp = 4,
358 }, 358 },
359 { 359 {
360 .mmc = 2, 360 .mmc = 2,
361 .wires = 8, 361 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
362 .gpio_wp = 7, 362 .gpio_wp = 7,
363 }, 363 },
364 {} /* Terminator */ 364 {} /* Terminator */
diff --git a/arch/arm/mach-omap2/board-3630sdp.c b/arch/arm/mach-omap2/board-3630sdp.c
index fd27ac0860b0..bbcf580fa097 100644
--- a/arch/arm/mach-omap2/board-3630sdp.c
+++ b/arch/arm/mach-omap2/board-3630sdp.c
@@ -21,8 +21,8 @@
21#include <plat/usb.h> 21#include <plat/usb.h>
22 22
23#include <mach/board-zoom.h> 23#include <mach/board-zoom.h>
24#include <mach/board-flash.h>
25 24
25#include "board-flash.h"
26#include "mux.h" 26#include "mux.h"
27#include "sdram-hynix-h8mbx00u0mer-0em.h" 27#include "sdram-hynix-h8mbx00u0mer-0em.h"
28 28
@@ -208,7 +208,6 @@ static struct flash_partitions sdp_flash_partitions[] = {
208static void __init omap_sdp_init(void) 208static void __init omap_sdp_init(void)
209{ 209{
210 omap3_mux_init(board_mux, OMAP_PACKAGE_CBP); 210 omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
211 omap_serial_init();
212 zoom_peripherals_init(); 211 zoom_peripherals_init();
213 board_smc91x_init(); 212 board_smc91x_init();
214 board_flash_init(sdp_flash_partitions, chip_sel_sdp); 213 board_flash_init(sdp_flash_partitions, chip_sel_sdp);
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 0b6a65f3a10a..df5a425a49d1 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -20,6 +20,7 @@
20#include <linux/usb/otg.h> 20#include <linux/usb/otg.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/i2c/twl.h> 22#include <linux/i2c/twl.h>
23#include <linux/gpio_keys.h>
23#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
24#include <linux/leds.h> 25#include <linux/leds.h>
25 26
@@ -31,15 +32,18 @@
31 32
32#include <plat/board.h> 33#include <plat/board.h>
33#include <plat/common.h> 34#include <plat/common.h>
34#include <plat/control.h>
35#include <plat/timer-gp.h>
36#include <plat/usb.h> 35#include <plat/usb.h>
37#include <plat/mmc.h> 36#include <plat/mmc.h>
37
38#include "hsmmc.h" 38#include "hsmmc.h"
39#include "timer-gp.h"
40#include "control.h"
39 41
40#define ETH_KS8851_IRQ 34 42#define ETH_KS8851_IRQ 34
41#define ETH_KS8851_POWER_ON 48 43#define ETH_KS8851_POWER_ON 48
42#define ETH_KS8851_QUART 138 44#define ETH_KS8851_QUART 138
45#define OMAP4_SFH7741_SENSOR_OUTPUT_GPIO 184
46#define OMAP4_SFH7741_ENABLE_GPIO 188
43 47
44static struct gpio_led sdp4430_gpio_leds[] = { 48static struct gpio_led sdp4430_gpio_leds[] = {
45 { 49 {
@@ -77,11 +81,47 @@ static struct gpio_led sdp4430_gpio_leds[] = {
77 81
78}; 82};
79 83
84static struct gpio_keys_button sdp4430_gpio_keys[] = {
85 {
86 .desc = "Proximity Sensor",
87 .type = EV_SW,
88 .code = SW_FRONT_PROXIMITY,
89 .gpio = OMAP4_SFH7741_SENSOR_OUTPUT_GPIO,
90 .active_low = 0,
91 }
92};
93
80static struct gpio_led_platform_data sdp4430_led_data = { 94static struct gpio_led_platform_data sdp4430_led_data = {
81 .leds = sdp4430_gpio_leds, 95 .leds = sdp4430_gpio_leds,
82 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds), 96 .num_leds = ARRAY_SIZE(sdp4430_gpio_leds),
83}; 97};
84 98
99static int omap_prox_activate(struct device *dev)
100{
101 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
102 return 0;
103}
104
105static void omap_prox_deactivate(struct device *dev)
106{
107 gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 0);
108}
109
110static struct gpio_keys_platform_data sdp4430_gpio_keys_data = {
111 .buttons = sdp4430_gpio_keys,
112 .nbuttons = ARRAY_SIZE(sdp4430_gpio_keys),
113 .enable = omap_prox_activate,
114 .disable = omap_prox_deactivate,
115};
116
117static struct platform_device sdp4430_gpio_keys_device = {
118 .name = "gpio-keys",
119 .id = -1,
120 .dev = {
121 .platform_data = &sdp4430_gpio_keys_data,
122 },
123};
124
85static struct platform_device sdp4430_leds_gpio = { 125static struct platform_device sdp4430_leds_gpio = {
86 .name = "leds-gpio", 126 .name = "leds-gpio",
87 .id = -1, 127 .id = -1,
@@ -161,6 +201,7 @@ static struct platform_device sdp4430_lcd_device = {
161 201
162static struct platform_device *sdp4430_devices[] __initdata = { 202static struct platform_device *sdp4430_devices[] __initdata = {
163 &sdp4430_lcd_device, 203 &sdp4430_lcd_device,
204 &sdp4430_gpio_keys_device,
164 &sdp4430_leds_gpio, 205 &sdp4430_leds_gpio,
165}; 206};
166 207
@@ -193,15 +234,16 @@ static struct omap_musb_board_data musb_board_data = {
193static struct omap2_hsmmc_info mmc[] = { 234static struct omap2_hsmmc_info mmc[] = {
194 { 235 {
195 .mmc = 1, 236 .mmc = 1,
196 .wires = 8, 237 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
197 .gpio_wp = -EINVAL, 238 .gpio_wp = -EINVAL,
198 }, 239 },
199 { 240 {
200 .mmc = 2, 241 .mmc = 2,
201 .wires = 8, 242 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
202 .gpio_cd = -EINVAL, 243 .gpio_cd = -EINVAL,
203 .gpio_wp = -EINVAL, 244 .gpio_wp = -EINVAL,
204 .nonremovable = true, 245 .nonremovable = true,
246 .ocr_mask = MMC_VDD_29_30,
205 }, 247 },
206 {} /* Terminator */ 248 {} /* Terminator */
207}; 249};
@@ -227,16 +269,27 @@ static int omap4_twl6030_hsmmc_late_init(struct device *dev)
227 struct omap_mmc_platform_data *pdata = dev->platform_data; 269 struct omap_mmc_platform_data *pdata = dev->platform_data;
228 270
229 /* Setting MMC1 Card detect Irq */ 271 /* Setting MMC1 Card detect Irq */
230 if (pdev->id == 0) 272 if (pdev->id == 0) {
273 ret = twl6030_mmc_card_detect_config();
274 if (ret)
275 pr_err("Failed configuring MMC1 card detect\n");
231 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE + 276 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE +
232 MMCDETECT_INTR_OFFSET; 277 MMCDETECT_INTR_OFFSET;
278 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
279 }
233 return ret; 280 return ret;
234} 281}
235 282
236static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) 283static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
237{ 284{
238 struct omap_mmc_platform_data *pdata = dev->platform_data; 285 struct omap_mmc_platform_data *pdata;
239 286
287 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
288 if (!dev) {
289 pr_err("Failed %s\n", __func__);
290 return;
291 }
292 pdata = dev->platform_data;
240 pdata->init = omap4_twl6030_hsmmc_late_init; 293 pdata->init = omap4_twl6030_hsmmc_late_init;
241} 294}
242 295
@@ -412,6 +465,11 @@ static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
412 I2C_BOARD_INFO("tmp105", 0x48), 465 I2C_BOARD_INFO("tmp105", 0x48),
413 }, 466 },
414}; 467};
468static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
469 {
470 I2C_BOARD_INFO("hmc5843", 0x1e),
471 },
472};
415static int __init omap4_i2c_init(void) 473static int __init omap4_i2c_init(void)
416{ 474{
417 /* 475 /*
@@ -423,14 +481,36 @@ static int __init omap4_i2c_init(void)
423 omap_register_i2c_bus(2, 400, NULL, 0); 481 omap_register_i2c_bus(2, 400, NULL, 0);
424 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo, 482 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
425 ARRAY_SIZE(sdp4430_i2c_3_boardinfo)); 483 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
426 omap_register_i2c_bus(4, 400, NULL, 0); 484 omap_register_i2c_bus(4, 400, sdp4430_i2c_4_boardinfo,
485 ARRAY_SIZE(sdp4430_i2c_4_boardinfo));
427 return 0; 486 return 0;
428} 487}
488
489static void __init omap_sfh7741prox_init(void)
490{
491 int error;
492
493 error = gpio_request(OMAP4_SFH7741_ENABLE_GPIO, "sfh7741");
494 if (error < 0) {
495 pr_err("%s:failed to request GPIO %d, error %d\n",
496 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
497 return;
498 }
499
500 error = gpio_direction_output(OMAP4_SFH7741_ENABLE_GPIO , 0);
501 if (error < 0) {
502 pr_err("%s: GPIO configuration failed: GPIO %d,error %d\n",
503 __func__, OMAP4_SFH7741_ENABLE_GPIO, error);
504 gpio_free(OMAP4_SFH7741_ENABLE_GPIO);
505 }
506}
507
429static void __init omap_4430sdp_init(void) 508static void __init omap_4430sdp_init(void)
430{ 509{
431 int status; 510 int status;
432 511
433 omap4_i2c_init(); 512 omap4_i2c_init();
513 omap_sfh7741prox_init();
434 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices)); 514 platform_add_devices(sdp4430_devices, ARRAY_SIZE(sdp4430_devices));
435 omap_serial_init(); 515 omap_serial_init();
436 omap4_twl6030_hsmmc_init(mmc); 516 omap4_twl6030_hsmmc_init(mmc);
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index f85c8da17e8b..07399505312b 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/clk.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/gpio.h> 23#include <linux/gpio.h>
23#include <linux/i2c/pca953x.h> 24#include <linux/i2c/pca953x.h>
@@ -32,25 +33,43 @@
32 33
33#include <plat/board.h> 34#include <plat/board.h>
34#include <plat/common.h> 35#include <plat/common.h>
35#include <plat/control.h>
36#include <plat/usb.h> 36#include <plat/usb.h>
37#include <plat/display.h> 37#include <plat/display.h>
38 38
39#include "mux.h" 39#include "mux.h"
40#include "control.h"
40 41
41#define AM35XX_EVM_PHY_MASK (0xF)
42#define AM35XX_EVM_MDIO_FREQUENCY (1000000) 42#define AM35XX_EVM_MDIO_FREQUENCY (1000000)
43 43
44static struct mdio_platform_data am3517_evm_mdio_pdata = {
45 .bus_freq = AM35XX_EVM_MDIO_FREQUENCY,
46};
47
48static struct resource am3517_mdio_resources[] = {
49 {
50 .start = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET,
51 .end = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET +
52 SZ_4K - 1,
53 .flags = IORESOURCE_MEM,
54 },
55};
56
57static struct platform_device am3517_mdio_device = {
58 .name = "davinci_mdio",
59 .id = 0,
60 .num_resources = ARRAY_SIZE(am3517_mdio_resources),
61 .resource = am3517_mdio_resources,
62 .dev.platform_data = &am3517_evm_mdio_pdata,
63};
64
44static struct emac_platform_data am3517_evm_emac_pdata = { 65static struct emac_platform_data am3517_evm_emac_pdata = {
45 .phy_mask = AM35XX_EVM_PHY_MASK,
46 .mdio_max_freq = AM35XX_EVM_MDIO_FREQUENCY,
47 .rmii_en = 1, 66 .rmii_en = 1,
48}; 67};
49 68
50static struct resource am3517_emac_resources[] = { 69static struct resource am3517_emac_resources[] = {
51 { 70 {
52 .start = AM35XX_IPSS_EMAC_BASE, 71 .start = AM35XX_IPSS_EMAC_BASE,
53 .end = AM35XX_IPSS_EMAC_BASE + 0x3FFFF, 72 .end = AM35XX_IPSS_EMAC_BASE + 0x2FFFF,
54 .flags = IORESOURCE_MEM, 73 .flags = IORESOURCE_MEM,
55 }, 74 },
56 { 75 {
@@ -106,14 +125,13 @@ static void am3517_disable_ethernet_int(void)
106 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); 125 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
107} 126}
108 127
109void am3517_evm_ethernet_init(struct emac_platform_data *pdata) 128static void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
110{ 129{
111 unsigned int regval; 130 unsigned int regval;
112 131
113 pdata->ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET; 132 pdata->ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET;
114 pdata->ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET; 133 pdata->ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET;
115 pdata->ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET; 134 pdata->ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET;
116 pdata->mdio_reg_offset = AM35XX_EMAC_MDIO_OFFSET;
117 pdata->ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE; 135 pdata->ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE;
118 pdata->version = EMAC_VERSION_2; 136 pdata->version = EMAC_VERSION_2;
119 pdata->hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR; 137 pdata->hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR;
@@ -121,6 +139,9 @@ void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
121 pdata->interrupt_disable = am3517_disable_ethernet_int; 139 pdata->interrupt_disable = am3517_disable_ethernet_int;
122 am3517_emac_device.dev.platform_data = pdata; 140 am3517_emac_device.dev.platform_data = pdata;
123 platform_device_register(&am3517_emac_device); 141 platform_device_register(&am3517_emac_device);
142 platform_device_register(&am3517_mdio_device);
143 clk_add_alias(NULL, dev_name(&am3517_mdio_device.dev),
144 NULL, &am3517_emac_device.dev);
124 145
125 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); 146 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
126 regval = regval & (~(AM35XX_CPGMACSS_SW_RST)); 147 regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
@@ -139,7 +160,6 @@ void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
139static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = { 160static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
140 { 161 {
141 I2C_BOARD_INFO("s35390a", 0x30), 162 I2C_BOARD_INFO("s35390a", 0x30),
142 .type = "s35390a",
143 }, 163 },
144}; 164};
145 165
@@ -347,7 +367,7 @@ static struct omap_dss_board_info am3517_evm_dss_data = {
347 .default_device = &am3517_evm_lcd_device, 367 .default_device = &am3517_evm_lcd_device,
348}; 368};
349 369
350struct platform_device am3517_evm_dss_device = { 370static struct platform_device am3517_evm_dss_device = {
351 .name = "omapdss", 371 .name = "omapdss",
352 .id = -1, 372 .id = -1,
353 .dev = { 373 .dev = {
@@ -375,6 +395,31 @@ static void __init am3517_evm_init_irq(void)
375 omap_gpio_init(); 395 omap_gpio_init();
376} 396}
377 397
398static struct omap_musb_board_data musb_board_data = {
399 .interface_type = MUSB_INTERFACE_ULPI,
400 .mode = MUSB_OTG,
401 .power = 500,
402};
403
404static __init void am3517_evm_musb_init(void)
405{
406 u32 devconf2;
407
408 /*
409 * Set up USB clock/mode in the DEVCONF2 register.
410 */
411 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
412
413 /* USB2.0 PHY reference clock is 13 MHz */
414 devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
415 devconf2 |= CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
416 | CONF2_DATPOL;
417
418 omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
419
420 usb_musb_init(&musb_board_data);
421}
422
378static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { 423static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
379 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, 424 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
380#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \ 425#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
@@ -393,6 +438,8 @@ static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
393 438
394#ifdef CONFIG_OMAP_MUX 439#ifdef CONFIG_OMAP_MUX
395static struct omap_board_mux board_mux[] __initdata = { 440static struct omap_board_mux board_mux[] __initdata = {
441 /* USB OTG DRVVBUS offset = 0x212 */
442 OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
396 { .reg_offset = OMAP_MUX_TERMINATOR }, 443 { .reg_offset = OMAP_MUX_TERMINATOR },
397}; 444};
398#else 445#else
@@ -459,6 +506,9 @@ static void __init am3517_evm_init(void)
459 ARRAY_SIZE(am3517evm_i2c1_boardinfo)); 506 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
460 /*Ethernet*/ 507 /*Ethernet*/
461 am3517_evm_ethernet_init(&am3517_evm_emac_pdata); 508 am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
509
510 /* MUSB */
511 am3517_evm_musb_init();
462} 512}
463 513
464MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") 514MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index 68f07f5f441a..2c6db1aaeb29 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -39,9 +39,9 @@
39#include <plat/board.h> 39#include <plat/board.h>
40#include <plat/common.h> 40#include <plat/common.h>
41#include <plat/gpmc.h> 41#include <plat/gpmc.h>
42#include <plat/control.h>
43 42
44#include "mux.h" 43#include "mux.h"
44#include "control.h"
45 45
46/* LED & Switch macros */ 46/* LED & Switch macros */
47#define LED0_GPIO13 13 47#define LED0_GPIO13 13
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 934d9380c372..63f764e2af3f 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -31,6 +31,7 @@
31#include <linux/i2c/at24.h> 31#include <linux/i2c/at24.h>
32#include <linux/i2c/twl.h> 32#include <linux/i2c/twl.h>
33#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
34#include <linux/mmc/host.h>
34 35
35#include <linux/spi/spi.h> 36#include <linux/spi/spi.h>
36#include <linux/spi/tdo24m.h> 37#include <linux/spi/tdo24m.h>
@@ -237,8 +238,6 @@ static inline void cm_t35_init_nand(void) {}
237 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 238 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
238#include <linux/spi/ads7846.h> 239#include <linux/spi/ads7846.h>
239 240
240#include <plat/mcspi.h>
241
242static struct omap2_mcspi_device_config ads7846_mcspi_config = { 241static struct omap2_mcspi_device_config ads7846_mcspi_config = {
243 .turbo_mode = 0, 242 .turbo_mode = 0,
244 .single_channel = 1, /* 0: slave, 1: master */ 243 .single_channel = 1, /* 0: slave, 1: master */
@@ -558,7 +557,7 @@ static struct twl4030_usb_data cm_t35_usb_data = {
558 .usb_mode = T2_USB_MODE_ULPI, 557 .usb_mode = T2_USB_MODE_ULPI,
559}; 558};
560 559
561static int cm_t35_keymap[] = { 560static uint32_t cm_t35_keymap[] = {
562 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT), 561 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT),
563 KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN), 562 KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN),
564 KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D), 563 KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D),
@@ -579,14 +578,14 @@ static struct twl4030_keypad_data cm_t35_kp_data = {
579static struct omap2_hsmmc_info mmc[] = { 578static struct omap2_hsmmc_info mmc[] = {
580 { 579 {
581 .mmc = 1, 580 .mmc = 1,
582 .wires = 4, 581 .caps = MMC_CAP_4_BIT_DATA,
583 .gpio_cd = -EINVAL, 582 .gpio_cd = -EINVAL,
584 .gpio_wp = -EINVAL, 583 .gpio_wp = -EINVAL,
585 584
586 }, 585 },
587 { 586 {
588 .mmc = 2, 587 .mmc = 2,
589 .wires = 4, 588 .caps = MMC_CAP_4_BIT_DATA,
590 .transceiver = 1, 589 .transceiver = 1,
591 .gpio_cd = -EINVAL, 590 .gpio_cd = -EINVAL,
592 .gpio_wp = -EINVAL, 591 .gpio_wp = -EINVAL,
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
new file mode 100644
index 000000000000..1dd303e9a267
--- /dev/null
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -0,0 +1,292 @@
1/*
2 * linux/arch/arm/mach-omap2/board-cm-t3517.c
3 *
4 * Support for the CompuLab CM-T3517 modules
5 *
6 * Copyright (C) 2010 CompuLab, Ltd.
7 * Author: Igor Grinberg <grinberg@compulab.co.il>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#include <linux/kernel.h>
26#include <linux/init.h>
27#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/gpio.h>
30#include <linux/leds.h>
31#include <linux/rtc-v3020.h>
32#include <linux/mtd/mtd.h>
33#include <linux/mtd/nand.h>
34#include <linux/mtd/partitions.h>
35#include <linux/can/platform/ti_hecc.h>
36
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40
41#include <plat/board.h>
42#include <plat/common.h>
43#include <plat/usb.h>
44#include <plat/nand.h>
45#include <plat/gpmc.h>
46
47#include <mach/am35xx.h>
48
49#include "mux.h"
50#include "control.h"
51
52#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
53static struct gpio_led cm_t3517_leds[] = {
54 [0] = {
55 .gpio = 186,
56 .name = "cm-t3517:green",
57 .default_trigger = "heartbeat",
58 .active_low = 0,
59 },
60};
61
62static struct gpio_led_platform_data cm_t3517_led_pdata = {
63 .num_leds = ARRAY_SIZE(cm_t3517_leds),
64 .leds = cm_t3517_leds,
65};
66
67static struct platform_device cm_t3517_led_device = {
68 .name = "leds-gpio",
69 .id = -1,
70 .dev = {
71 .platform_data = &cm_t3517_led_pdata,
72 },
73};
74
75static void __init cm_t3517_init_leds(void)
76{
77 platform_device_register(&cm_t3517_led_device);
78}
79#else
80static inline void cm_t3517_init_leds(void) {}
81#endif
82
83#if defined(CONFIG_CAN_TI_HECC) || defined(CONFIG_CAN_TI_HECC_MODULE)
84static struct resource cm_t3517_hecc_resources[] = {
85 {
86 .start = AM35XX_IPSS_HECC_BASE,
87 .end = AM35XX_IPSS_HECC_BASE + SZ_16K - 1,
88 .flags = IORESOURCE_MEM,
89 },
90 {
91 .start = INT_35XX_HECC0_IRQ,
92 .end = INT_35XX_HECC0_IRQ,
93 .flags = IORESOURCE_IRQ,
94 },
95};
96
97static struct ti_hecc_platform_data cm_t3517_hecc_pdata = {
98 .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
99 .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
100 .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
101 .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
102 .int_line = AM35XX_HECC_INT_LINE,
103 .version = AM35XX_HECC_VERSION,
104};
105
106static struct platform_device cm_t3517_hecc_device = {
107 .name = "ti_hecc",
108 .id = 1,
109 .num_resources = ARRAY_SIZE(cm_t3517_hecc_resources),
110 .resource = cm_t3517_hecc_resources,
111 .dev = {
112 .platform_data = &cm_t3517_hecc_pdata,
113 },
114};
115
116static void cm_t3517_init_hecc(void)
117{
118 platform_device_register(&cm_t3517_hecc_device);
119}
120#else
121static inline void cm_t3517_init_hecc(void) {}
122#endif
123
124#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
125#define RTC_IO_GPIO (153)
126#define RTC_WR_GPIO (154)
127#define RTC_RD_GPIO (160)
128#define RTC_CS_GPIO (163)
129
130struct v3020_platform_data cm_t3517_v3020_pdata = {
131 .use_gpio = 1,
132 .gpio_cs = RTC_CS_GPIO,
133 .gpio_wr = RTC_WR_GPIO,
134 .gpio_rd = RTC_RD_GPIO,
135 .gpio_io = RTC_IO_GPIO,
136};
137
138static struct platform_device cm_t3517_rtc_device = {
139 .name = "v3020",
140 .id = -1,
141 .dev = {
142 .platform_data = &cm_t3517_v3020_pdata,
143 }
144};
145
146static void __init cm_t3517_init_rtc(void)
147{
148 platform_device_register(&cm_t3517_rtc_device);
149}
150#else
151static inline void cm_t3517_init_rtc(void) {}
152#endif
153
154#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
155#define HSUSB1_RESET_GPIO (146)
156#define HSUSB2_RESET_GPIO (147)
157#define USB_HUB_RESET_GPIO (152)
158
159static struct ehci_hcd_omap_platform_data cm_t3517_ehci_pdata __initdata = {
160 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
161 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
162 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
163
164 .phy_reset = true,
165 .reset_gpio_port[0] = HSUSB1_RESET_GPIO,
166 .reset_gpio_port[1] = HSUSB2_RESET_GPIO,
167 .reset_gpio_port[2] = -EINVAL,
168};
169
170static int cm_t3517_init_usbh(void)
171{
172 int err;
173
174 err = gpio_request(USB_HUB_RESET_GPIO, "usb hub rst");
175 if (err) {
176 pr_err("CM-T3517: usb hub rst gpio request failed: %d\n", err);
177 } else {
178 gpio_direction_output(USB_HUB_RESET_GPIO, 0);
179 udelay(10);
180 gpio_set_value(USB_HUB_RESET_GPIO, 1);
181 msleep(1);
182 }
183
184 usb_ehci_init(&cm_t3517_ehci_pdata);
185
186 return 0;
187}
188#else
189static inline int cm_t3517_init_usbh(void)
190{
191 return 0;
192}
193#endif
194
195#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
196#define NAND_BLOCK_SIZE SZ_128K
197
198static struct mtd_partition cm_t3517_nand_partitions[] = {
199 {
200 .name = "xloader",
201 .offset = 0, /* Offset = 0x00000 */
202 .size = 4 * NAND_BLOCK_SIZE,
203 .mask_flags = MTD_WRITEABLE
204 },
205 {
206 .name = "uboot",
207 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
208 .size = 15 * NAND_BLOCK_SIZE,
209 },
210 {
211 .name = "uboot environment",
212 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
213 .size = 2 * NAND_BLOCK_SIZE,
214 },
215 {
216 .name = "linux",
217 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
218 .size = 32 * NAND_BLOCK_SIZE,
219 },
220 {
221 .name = "rootfs",
222 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
223 .size = MTDPART_SIZ_FULL,
224 },
225};
226
227static struct omap_nand_platform_data cm_t3517_nand_data = {
228 .parts = cm_t3517_nand_partitions,
229 .nr_parts = ARRAY_SIZE(cm_t3517_nand_partitions),
230 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
231 .cs = 0,
232};
233
234static void __init cm_t3517_init_nand(void)
235{
236 if (gpmc_nand_init(&cm_t3517_nand_data) < 0)
237 pr_err("CM-T3517: NAND initialization failed\n");
238}
239#else
240static inline void cm_t3517_init_nand(void) {}
241#endif
242
243static struct omap_board_config_kernel cm_t3517_config[] __initdata = {
244};
245
246static void __init cm_t3517_init_irq(void)
247{
248 omap_board_config = cm_t3517_config;
249 omap_board_config_size = ARRAY_SIZE(cm_t3517_config);
250
251 omap2_init_common_hw(NULL, NULL);
252 omap_init_irq();
253 omap_gpio_init();
254}
255
256static struct omap_board_mux board_mux[] __initdata = {
257 /* GPIO186 - Green LED */
258 OMAP3_MUX(SYS_CLKOUT2, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
259 /* RTC GPIOs: IO, WR#, RD#, CS# */
260 OMAP3_MUX(MCBSP4_DR, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
261 OMAP3_MUX(MCBSP4_DX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
262 OMAP3_MUX(MCBSP_CLKS, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
263 OMAP3_MUX(UART3_CTS_RCTX, OMAP_MUX_MODE4 | OMAP_PIN_INPUT),
264 /* HSUSB1 RESET */
265 OMAP3_MUX(UART2_TX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
266 /* HSUSB2 RESET */
267 OMAP3_MUX(UART2_RX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
268 /* CM-T3517 USB HUB nRESET */
269 OMAP3_MUX(MCBSP4_CLKX, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
270
271 { .reg_offset = OMAP_MUX_TERMINATOR },
272};
273
274static void __init cm_t3517_init(void)
275{
276 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
277 omap_serial_init();
278 cm_t3517_init_leds();
279 cm_t3517_init_nand();
280 cm_t3517_init_rtc();
281 cm_t3517_init_usbh();
282 cm_t3517_init_hecc();
283}
284
285MACHINE_START(CM_T3517, "Compulab CM-T3517")
286 .boot_params = 0x80000100,
287 .map_io = omap3_map_io,
288 .reserve = omap_reserve,
289 .init_irq = cm_t3517_init_irq,
290 .init_machine = cm_t3517_init,
291 .timer = &omap_timer,
292MACHINE_END
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 2205c20a4cdb..53ac762518bd 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -28,6 +28,7 @@
28#include <linux/mtd/mtd.h> 28#include <linux/mtd/mtd.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/mmc/host.h>
31 32
32#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
33#include <linux/i2c/twl.h> 34#include <linux/i2c/twl.h>
@@ -44,7 +45,6 @@
44#include <plat/gpmc.h> 45#include <plat/gpmc.h>
45#include <plat/nand.h> 46#include <plat/nand.h>
46#include <plat/usb.h> 47#include <plat/usb.h>
47#include <plat/timer-gp.h>
48#include <plat/display.h> 48#include <plat/display.h>
49 49
50#include <plat/mcspi.h> 50#include <plat/mcspi.h>
@@ -58,6 +58,7 @@
58 58
59#include "mux.h" 59#include "mux.h"
60#include "hsmmc.h" 60#include "hsmmc.h"
61#include "timer-gp.h"
61 62
62#define NAND_BLOCK_SIZE SZ_128K 63#define NAND_BLOCK_SIZE SZ_128K
63 64
@@ -105,7 +106,7 @@ static struct omap_nand_platform_data devkit8000_nand_data = {
105static struct omap2_hsmmc_info mmc[] = { 106static struct omap2_hsmmc_info mmc[] = {
106 { 107 {
107 .mmc = 1, 108 .mmc = 1,
108 .wires = 8, 109 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
109 .gpio_wp = 29, 110 .gpio_wp = 29,
110 }, 111 },
111 {} /* Terminator */ 112 {} /* Terminator */
@@ -198,7 +199,7 @@ static struct platform_device devkit8000_dss_device = {
198static struct regulator_consumer_supply devkit8000_vdda_dac_supply = 199static struct regulator_consumer_supply devkit8000_vdda_dac_supply =
199 REGULATOR_SUPPLY("vdda_dac", "omapdss"); 200 REGULATOR_SUPPLY("vdda_dac", "omapdss");
200 201
201static int board_keymap[] = { 202static uint32_t board_keymap[] = {
202 KEY(0, 0, KEY_1), 203 KEY(0, 0, KEY_1),
203 KEY(1, 0, KEY_2), 204 KEY(1, 0, KEY_2),
204 KEY(2, 0, KEY_3), 205 KEY(2, 0, KEY_3),
@@ -241,9 +242,6 @@ static int devkit8000_twl_gpio_setup(struct device *dev,
241 mmc[0].gpio_cd = gpio + 0; 242 mmc[0].gpio_cd = gpio + 0;
242 omap2_hsmmc_init(mmc); 243 omap2_hsmmc_init(mmc);
243 244
244 /* link regulators to MMC adapters */
245 devkit8000_vmmc1_supply.dev = mmc[0].dev;
246
247 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ 245 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
248 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; 246 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
249 247
diff --git a/arch/arm/mach-omap2/board-flash.c b/arch/arm/mach-omap2/board-flash.c
index ac834aa7abf6..fd38c05bb47f 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -21,7 +21,8 @@
21#include <plat/nand.h> 21#include <plat/nand.h>
22#include <plat/onenand.h> 22#include <plat/onenand.h>
23#include <plat/tc.h> 23#include <plat/tc.h>
24#include <mach/board-flash.h> 24
25#include "board-flash.h"
25 26
26#define REG_FPGA_REV 0x10 27#define REG_FPGA_REV 0x10
27#define REG_FPGA_DIP_SWITCH_INPUT2 0x60 28#define REG_FPGA_DIP_SWITCH_INPUT2 0x60
diff --git a/arch/arm/mach-omap2/include/mach/board-flash.h b/arch/arm/mach-omap2/board-flash.h
index b2242ae2bb6f..69befe00dd2f 100644
--- a/arch/arm/mach-omap2/include/mach/board-flash.h
+++ b/arch/arm/mach-omap2/board-flash.h
@@ -26,3 +26,5 @@ struct flash_partitions {
26 26
27extern void board_flash_init(struct flash_partitions [], 27extern void board_flash_init(struct flash_partitions [],
28 char chip_sel[][GPMC_CS_NUM]); 28 char chip_sel[][GPMC_CS_NUM]);
29extern void board_nand_init(struct mtd_partition *nand_parts,
30 u8 nr_parts, u8 cs);
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 69064b1c6a75..b1c2c9a11c38 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -48,10 +48,22 @@ static void __init omap_generic_init(void)
48 48
49static void __init omap_generic_map_io(void) 49static void __init omap_generic_map_io(void)
50{ 50{
51 omap2_set_globals_242x(); /* should be 242x, 243x, or 343x */ 51 if (cpu_is_omap242x()) {
52 omap242x_map_common_io(); 52 omap2_set_globals_242x();
53 omap242x_map_common_io();
54 } else if (cpu_is_omap243x()) {
55 omap2_set_globals_243x();
56 omap243x_map_common_io();
57 } else if (cpu_is_omap34xx()) {
58 omap2_set_globals_3xxx();
59 omap34xx_map_common_io();
60 } else if (cpu_is_omap44xx()) {
61 omap2_set_globals_443x();
62 omap44xx_map_common_io();
63 }
53} 64}
54 65
66/* XXX This machine entry name should be updated */
55MACHINE_START(OMAP_GENERIC, "Generic OMAP24xx") 67MACHINE_START(OMAP_GENERIC, "Generic OMAP24xx")
56 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ 68 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
57 .boot_params = 0x80000100, 69 .boot_params = 0x80000100,
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index cc39fc866524..929993b4bf26 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -31,7 +31,6 @@
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32#include <asm/mach/map.h> 32#include <asm/mach/map.h>
33 33
34#include <plat/control.h>
35#include <mach/gpio.h> 34#include <mach/gpio.h>
36#include <plat/usb.h> 35#include <plat/usb.h>
37#include <plat/board.h> 36#include <plat/board.h>
@@ -42,6 +41,7 @@
42#include <plat/gpmc.h> 41#include <plat/gpmc.h>
43 42
44#include "mux.h" 43#include "mux.h"
44#include "control.h"
45 45
46#define H4_FLASH_CS 0 46#define H4_FLASH_CS 0
47#define H4_SMC91X_CS 1 47#define H4_SMC91X_CS 1
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index b62a68ba069b..5e035a58b809 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
22#include <linux/i2c/twl.h> 22#include <linux/i2c/twl.h>
23#include <linux/mmc/host.h>
23 24
24#include <asm/mach-types.h> 25#include <asm/mach-types.h>
25#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
@@ -38,12 +39,61 @@
38#define IGEP2_SMSC911X_CS 5 39#define IGEP2_SMSC911X_CS 5
39#define IGEP2_SMSC911X_GPIO 176 40#define IGEP2_SMSC911X_GPIO 176
40#define IGEP2_GPIO_USBH_NRESET 24 41#define IGEP2_GPIO_USBH_NRESET 24
41#define IGEP2_GPIO_LED0_GREEN 26 42#define IGEP2_GPIO_LED0_GREEN 26
42#define IGEP2_GPIO_LED0_RED 27 43#define IGEP2_GPIO_LED0_RED 27
43#define IGEP2_GPIO_LED1_RED 28 44#define IGEP2_GPIO_LED1_RED 28
44#define IGEP2_GPIO_DVI_PUP 170 45#define IGEP2_GPIO_DVI_PUP 170
45#define IGEP2_GPIO_WIFI_NPD 94 46
46#define IGEP2_GPIO_WIFI_NRESET 95 47#define IGEP2_RB_GPIO_WIFI_NPD 94
48#define IGEP2_RB_GPIO_WIFI_NRESET 95
49#define IGEP2_RB_GPIO_BT_NRESET 137
50#define IGEP2_RC_GPIO_WIFI_NPD 138
51#define IGEP2_RC_GPIO_WIFI_NRESET 139
52#define IGEP2_RC_GPIO_BT_NRESET 137
53
54/*
55 * IGEP2 Hardware Revision Table
56 *
57 * --------------------------------------------------------------------------
58 * | Id. | Hw Rev. | HW0 (28) | WIFI_NPD | WIFI_NRESET | BT_NRESET |
59 * --------------------------------------------------------------------------
60 * | 0 | B | high | gpio94 | gpio95 | - |
61 * | 0 | B/C (B-compatible) | high | gpio94 | gpio95 | gpio137 |
62 * | 1 | C | low | gpio138 | gpio139 | gpio137 |
63 * --------------------------------------------------------------------------
64 */
65
66#define IGEP2_BOARD_HWREV_B 0
67#define IGEP2_BOARD_HWREV_C 1
68
69static u8 hwrev;
70
71static void __init igep2_get_revision(void)
72{
73 u8 ret;
74
75 omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT);
76
77 if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_HW0_REV") == 0) &&
78 (gpio_direction_input(IGEP2_GPIO_LED1_RED) == 0)) {
79 ret = gpio_get_value(IGEP2_GPIO_LED1_RED);
80 if (ret == 0) {
81 pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
82 hwrev = IGEP2_BOARD_HWREV_C;
83 } else if (ret == 1) {
84 pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
85 hwrev = IGEP2_BOARD_HWREV_B;
86 } else {
87 pr_err("IGEP2: Unknown Hardware Revision\n");
88 hwrev = -1;
89 }
90 } else {
91 pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
92 pr_err("IGEP2: Unknown Hardware Revision\n");
93 }
94
95 gpio_free(IGEP2_GPIO_LED1_RED);
96}
47 97
48#if defined(CONFIG_MTD_ONENAND_OMAP2) || \ 98#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
49 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) 99 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
@@ -107,7 +157,7 @@ static struct platform_device igep2_onenand_device = {
107 }, 157 },
108}; 158};
109 159
110void __init igep2_flash_init(void) 160static void __init igep2_flash_init(void)
111{ 161{
112 u8 cs = 0; 162 u8 cs = 0;
113 u8 onenandcs = GPMC_CS_NUM + 1; 163 u8 onenandcs = GPMC_CS_NUM + 1;
@@ -141,7 +191,7 @@ void __init igep2_flash_init(void)
141} 191}
142 192
143#else 193#else
144void __init igep2_flash_init(void) {} 194static void __init igep2_flash_init(void) {}
145#endif 195#endif
146 196
147#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 197#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
@@ -211,10 +261,6 @@ static struct regulator_consumer_supply igep2_vmmc1_supply = {
211 .supply = "vmmc", 261 .supply = "vmmc",
212}; 262};
213 263
214static struct regulator_consumer_supply igep2_vmmc2_supply = {
215 .supply = "vmmc",
216};
217
218/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */ 264/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
219static struct regulator_init_data igep2_vmmc1 = { 265static struct regulator_init_data igep2_vmmc1 = {
220 .constraints = { 266 .constraints = {
@@ -230,37 +276,95 @@ static struct regulator_init_data igep2_vmmc1 = {
230 .consumer_supplies = &igep2_vmmc1_supply, 276 .consumer_supplies = &igep2_vmmc1_supply,
231}; 277};
232 278
233/* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
234static struct regulator_init_data igep2_vmmc2 = {
235 .constraints = {
236 .min_uV = 1850000,
237 .max_uV = 3150000,
238 .valid_modes_mask = REGULATOR_MODE_NORMAL
239 | REGULATOR_MODE_STANDBY,
240 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
241 | REGULATOR_CHANGE_MODE
242 | REGULATOR_CHANGE_STATUS,
243 },
244 .num_consumer_supplies = 1,
245 .consumer_supplies = &igep2_vmmc2_supply,
246};
247
248static struct omap2_hsmmc_info mmc[] = { 279static struct omap2_hsmmc_info mmc[] = {
249 { 280 {
250 .mmc = 1, 281 .mmc = 1,
251 .wires = 4, 282 .caps = MMC_CAP_4_BIT_DATA,
252 .gpio_cd = -EINVAL, 283 .gpio_cd = -EINVAL,
253 .gpio_wp = -EINVAL, 284 .gpio_wp = -EINVAL,
254 }, 285 },
286#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
255 { 287 {
256 .mmc = 2, 288 .mmc = 2,
257 .wires = 4, 289 .caps = MMC_CAP_4_BIT_DATA,
258 .gpio_cd = -EINVAL, 290 .gpio_cd = -EINVAL,
259 .gpio_wp = -EINVAL, 291 .gpio_wp = -EINVAL,
260 }, 292 },
293#endif
261 {} /* Terminator */ 294 {} /* Terminator */
262}; 295};
263 296
297#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
298#include <linux/leds.h>
299
300static struct gpio_led igep2_gpio_leds[] = {
301 [0] = {
302 .name = "gpio-led:red:d0",
303 .gpio = IGEP2_GPIO_LED0_RED,
304 .default_trigger = "default-off"
305 },
306 [1] = {
307 .name = "gpio-led:green:d0",
308 .gpio = IGEP2_GPIO_LED0_GREEN,
309 .default_trigger = "default-off",
310 },
311 [2] = {
312 .name = "gpio-led:red:d1",
313 .gpio = IGEP2_GPIO_LED1_RED,
314 .default_trigger = "default-off",
315 },
316 [3] = {
317 .name = "gpio-led:green:d1",
318 .default_trigger = "heartbeat",
319 .gpio = -EINVAL, /* gets replaced */
320 },
321};
322
323static struct gpio_led_platform_data igep2_led_pdata = {
324 .leds = igep2_gpio_leds,
325 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
326};
327
328static struct platform_device igep2_led_device = {
329 .name = "leds-gpio",
330 .id = -1,
331 .dev = {
332 .platform_data = &igep2_led_pdata,
333 },
334};
335
336static void __init igep2_leds_init(void)
337{
338 platform_device_register(&igep2_led_device);
339}
340
341#else
342static inline void igep2_leds_init(void)
343{
344 if ((gpio_request(IGEP2_GPIO_LED0_RED, "gpio-led:red:d0") == 0) &&
345 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
346 gpio_export(IGEP2_GPIO_LED0_RED, 0);
347 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
348 } else
349 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
350
351 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
352 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
353 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
354 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
355 } else
356 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
357
358 if ((gpio_request(IGEP2_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
359 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
360 gpio_export(IGEP2_GPIO_LED1_RED, 0);
361 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
362 } else
363 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
364
365}
366#endif
367
264static int igep2_twl_gpio_setup(struct device *dev, 368static int igep2_twl_gpio_setup(struct device *dev,
265 unsigned gpio, unsigned ngpio) 369 unsigned gpio, unsigned ngpio)
266{ 370{
@@ -268,20 +372,48 @@ static int igep2_twl_gpio_setup(struct device *dev,
268 mmc[0].gpio_cd = gpio + 0; 372 mmc[0].gpio_cd = gpio + 0;
269 omap2_hsmmc_init(mmc); 373 omap2_hsmmc_init(mmc);
270 374
271 /* link regulators to MMC adapters ... we "know" the 375 /*
376 * link regulators to MMC adapters ... we "know" the
272 * regulators will be set up only *after* we return. 377 * regulators will be set up only *after* we return.
273 */ 378 */
274 igep2_vmmc1_supply.dev = mmc[0].dev; 379 igep2_vmmc1_supply.dev = mmc[0].dev;
275 igep2_vmmc2_supply.dev = mmc[1].dev; 380
381 /*
382 * REVISIT: need ehci-omap hooks for external VBUS
383 * power switch and overcurrent detect
384 */
385 if ((gpio_request(gpio + 1, "GPIO_EHCI_NOC") < 0) ||
386 (gpio_direction_input(gpio + 1) < 0))
387 pr_err("IGEP2: Could not obtain gpio for EHCI NOC");
388
389 /*
390 * TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN
391 * (out, active low)
392 */
393 if ((gpio_request(gpio + TWL4030_GPIO_MAX, "GPIO_USBH_CPEN") < 0) ||
394 (gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0) < 0))
395 pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");
396
397 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
398#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
399 if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0)
400 && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) {
401 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
402 gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0);
403 } else
404 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_GREEN\n");
405#else
406 igep2_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
407#endif
276 408
277 return 0; 409 return 0;
278}; 410};
279 411
280static struct twl4030_gpio_platform_data igep2_gpio_data = { 412static struct twl4030_gpio_platform_data igep2_twl4030_gpio_pdata = {
281 .gpio_base = OMAP_MAX_GPIO_LINES, 413 .gpio_base = OMAP_MAX_GPIO_LINES,
282 .irq_base = TWL4030_GPIO_IRQ_BASE, 414 .irq_base = TWL4030_GPIO_IRQ_BASE,
283 .irq_end = TWL4030_GPIO_IRQ_END, 415 .irq_end = TWL4030_GPIO_IRQ_END,
284 .use_leds = false, 416 .use_leds = true,
285 .setup = igep2_twl_gpio_setup, 417 .setup = igep2_twl_gpio_setup,
286}; 418};
287 419
@@ -355,47 +487,6 @@ static void __init igep2_display_init(void)
355 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n"); 487 pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
356} 488}
357 489
358#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
359#include <linux/leds.h>
360
361static struct gpio_led igep2_gpio_leds[] = {
362 {
363 .name = "led0:red",
364 .gpio = IGEP2_GPIO_LED0_RED,
365 },
366 {
367 .name = "led0:green",
368 .default_trigger = "heartbeat",
369 .gpio = IGEP2_GPIO_LED0_GREEN,
370 },
371 {
372 .name = "led1:red",
373 .gpio = IGEP2_GPIO_LED1_RED,
374 },
375};
376
377static struct gpio_led_platform_data igep2_led_pdata = {
378 .leds = igep2_gpio_leds,
379 .num_leds = ARRAY_SIZE(igep2_gpio_leds),
380};
381
382static struct platform_device igep2_led_device = {
383 .name = "leds-gpio",
384 .id = -1,
385 .dev = {
386 .platform_data = &igep2_led_pdata,
387 },
388};
389
390static void __init igep2_init_led(void)
391{
392 platform_device_register(&igep2_led_device);
393}
394
395#else
396static inline void igep2_init_led(void) {}
397#endif
398
399static struct platform_device *igep2_devices[] __initdata = { 490static struct platform_device *igep2_devices[] __initdata = {
400 &igep2_dss_device, 491 &igep2_dss_device,
401}; 492};
@@ -425,14 +516,13 @@ static struct twl4030_platform_data igep2_twldata = {
425 /* platform_data for children goes here */ 516 /* platform_data for children goes here */
426 .usb = &igep2_usb_data, 517 .usb = &igep2_usb_data,
427 .codec = &igep2_codec_data, 518 .codec = &igep2_codec_data,
428 .gpio = &igep2_gpio_data, 519 .gpio = &igep2_twl4030_gpio_pdata,
429 .vmmc1 = &igep2_vmmc1, 520 .vmmc1 = &igep2_vmmc1,
430 .vmmc2 = &igep2_vmmc2,
431 .vpll2 = &igep2_vpll2, 521 .vpll2 = &igep2_vpll2,
432 522
433}; 523};
434 524
435static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = { 525static struct i2c_board_info __initdata igep2_i2c1_boardinfo[] = {
436 { 526 {
437 I2C_BOARD_INFO("twl4030", 0x48), 527 I2C_BOARD_INFO("twl4030", 0x48),
438 .flags = I2C_CLIENT_WAKE, 528 .flags = I2C_CLIENT_WAKE,
@@ -441,14 +531,29 @@ static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
441 }, 531 },
442}; 532};
443 533
444static int __init igep2_i2c_init(void) 534static struct i2c_board_info __initdata igep2_i2c3_boardinfo[] = {
535 {
536 I2C_BOARD_INFO("eeprom", 0x50),
537 },
538};
539
540static void __init igep2_i2c_init(void)
445{ 541{
446 omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo, 542 int ret;
447 ARRAY_SIZE(igep2_i2c_boardinfo)); 543
448 /* Bus 3 is attached to the DVI port where devices like the pico DLP 544 ret = omap_register_i2c_bus(1, 2600, igep2_i2c1_boardinfo,
449 * projector don't work reliably with 400kHz */ 545 ARRAY_SIZE(igep2_i2c1_boardinfo));
450 omap_register_i2c_bus(3, 100, NULL, 0); 546 if (ret)
451 return 0; 547 pr_warning("IGEP2: Could not register I2C1 bus (%d)\n", ret);
548
549 /*
550 * Bus 3 is attached to the DVI port where devices like the pico DLP
551 * projector don't work reliably with 400kHz
552 */
553 ret = omap_register_i2c_bus(3, 100, igep2_i2c3_boardinfo,
554 ARRAY_SIZE(igep2_i2c3_boardinfo));
555 if (ret)
556 pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret);
452} 557}
453 558
454static struct omap_musb_board_data musb_board_data = { 559static struct omap_musb_board_data musb_board_data = {
@@ -476,9 +581,57 @@ static struct omap_board_mux board_mux[] __initdata = {
476#define board_mux NULL 581#define board_mux NULL
477#endif 582#endif
478 583
584#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
585
586static void __init igep2_wlan_bt_init(void)
587{
588 unsigned npd, wreset, btreset;
589
590 /* GPIO's for WLAN-BT combo depends on hardware revision */
591 if (hwrev == IGEP2_BOARD_HWREV_B) {
592 npd = IGEP2_RB_GPIO_WIFI_NPD;
593 wreset = IGEP2_RB_GPIO_WIFI_NRESET;
594 btreset = IGEP2_RB_GPIO_BT_NRESET;
595 } else if (hwrev == IGEP2_BOARD_HWREV_C) {
596 npd = IGEP2_RC_GPIO_WIFI_NPD;
597 wreset = IGEP2_RC_GPIO_WIFI_NRESET;
598 btreset = IGEP2_RC_GPIO_BT_NRESET;
599 } else
600 return;
601
602 /* Set GPIO's for WLAN-BT combo module */
603 if ((gpio_request(npd, "GPIO_WIFI_NPD") == 0) &&
604 (gpio_direction_output(npd, 1) == 0)) {
605 gpio_export(npd, 0);
606 } else
607 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NPD\n");
608
609 if ((gpio_request(wreset, "GPIO_WIFI_NRESET") == 0) &&
610 (gpio_direction_output(wreset, 1) == 0)) {
611 gpio_export(wreset, 0);
612 gpio_set_value(wreset, 0);
613 udelay(10);
614 gpio_set_value(wreset, 1);
615 } else
616 pr_warning("IGEP2: Could not obtain gpio GPIO_WIFI_NRESET\n");
617
618 if ((gpio_request(btreset, "GPIO_BT_NRESET") == 0) &&
619 (gpio_direction_output(btreset, 1) == 0)) {
620 gpio_export(btreset, 0);
621 } else
622 pr_warning("IGEP2: Could not obtain gpio GPIO_BT_NRESET\n");
623}
624#else
625static inline void __init igep2_wlan_bt_init(void) { }
626#endif
627
479static void __init igep2_init(void) 628static void __init igep2_init(void)
480{ 629{
481 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 630 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
631
632 /* Get IGEP2 hardware revision */
633 igep2_get_revision();
634 /* Register I2C busses and drivers */
482 igep2_i2c_init(); 635 igep2_i2c_init();
483 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices)); 636 platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
484 omap_serial_init(); 637 omap_serial_init();
@@ -486,50 +639,16 @@ static void __init igep2_init(void)
486 usb_ehci_init(&ehci_pdata); 639 usb_ehci_init(&ehci_pdata);
487 640
488 igep2_flash_init(); 641 igep2_flash_init();
489 igep2_init_led(); 642 igep2_leds_init();
490 igep2_display_init(); 643 igep2_display_init();
491 igep2_init_smsc911x(); 644 igep2_init_smsc911x();
492 645
493 /* GPIO userspace leds */ 646 /*
494#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) 647 * WLAN-BT combo module from MuRata wich has a Marvell WLAN
495 if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) && 648 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
496 (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) { 649 */
497 gpio_export(IGEP2_GPIO_LED0_RED, 0); 650 igep2_wlan_bt_init();
498 gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
499 } else
500 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
501
502 if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
503 (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
504 gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
505 gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
506 } else
507 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
508
509 if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
510 (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
511 gpio_export(IGEP2_GPIO_LED1_RED, 0);
512 gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
513 } else
514 pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
515#endif
516
517 /* GPIO W-LAN + Bluetooth combo module */
518 if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
519 (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
520 gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
521/* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
522 } else
523 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
524 651
525 if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
526 (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
527 gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
528 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
529 udelay(10);
530 gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
531 } else
532 pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
533} 652}
534 653
535MACHINE_START(IGEP0020, "IGEP v2 board") 654MACHINE_START(IGEP0020, "IGEP v2 board")
diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c
new file mode 100644
index 000000000000..22b0b253e16b
--- /dev/null
+++ b/arch/arm/mach-omap2/board-igep0030.c
@@ -0,0 +1,400 @@
1/*
2 * Copyright (C) 2010 - ISEE 2007 SL
3 *
4 * Modified from mach-omap2/board-generic.c
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/init.h>
13#include <linux/platform_device.h>
14#include <linux/delay.h>
15#include <linux/err.h>
16#include <linux/clk.h>
17#include <linux/io.h>
18#include <linux/gpio.h>
19#include <linux/interrupt.h>
20
21#include <linux/regulator/machine.h>
22#include <linux/i2c/twl.h>
23#include <linux/mmc/host.h>
24
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27
28#include <plat/board.h>
29#include <plat/common.h>
30#include <plat/gpmc.h>
31#include <plat/usb.h>
32#include <plat/onenand.h>
33
34#include "mux.h"
35#include "hsmmc.h"
36#include "sdram-numonyx-m65kxxxxam.h"
37
38#define IGEP3_GPIO_LED0_GREEN 54
39#define IGEP3_GPIO_LED0_RED 53
40#define IGEP3_GPIO_LED1_RED 16
41
42#define IGEP3_GPIO_WIFI_NPD 138
43#define IGEP3_GPIO_WIFI_NRESET 139
44#define IGEP3_GPIO_BT_NRESET 137
45
46#define IGEP3_GPIO_USBH_NRESET 115
47
48
49#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
50 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
51
52#define ONENAND_MAP 0x20000000
53
54/*
55 * x2 Flash built-in COMBO POP MEMORY
56 * Since the device is equipped with two DataRAMs, and two-plane NAND
57 * Flash memory array, these two component enables simultaneous program
58 * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
59 * while Plane2 has only odd blocks such as block1, block3, block5.
60 * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
61 */
62
63static struct mtd_partition igep3_onenand_partitions[] = {
64 {
65 .name = "X-Loader",
66 .offset = 0,
67 .size = 2 * (64*(2*2048))
68 },
69 {
70 .name = "U-Boot",
71 .offset = MTDPART_OFS_APPEND,
72 .size = 6 * (64*(2*2048)),
73 },
74 {
75 .name = "Environment",
76 .offset = MTDPART_OFS_APPEND,
77 .size = 2 * (64*(2*2048)),
78 },
79 {
80 .name = "Kernel",
81 .offset = MTDPART_OFS_APPEND,
82 .size = 12 * (64*(2*2048)),
83 },
84 {
85 .name = "File System",
86 .offset = MTDPART_OFS_APPEND,
87 .size = MTDPART_SIZ_FULL,
88 },
89};
90
91static struct omap_onenand_platform_data igep3_onenand_pdata = {
92 .parts = igep3_onenand_partitions,
93 .nr_parts = ARRAY_SIZE(igep3_onenand_partitions),
94 .onenand_setup = NULL,
95 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
96};
97
98static struct platform_device igep3_onenand_device = {
99 .name = "omap2-onenand",
100 .id = -1,
101 .dev = {
102 .platform_data = &igep3_onenand_pdata,
103 },
104};
105
106void __init igep3_flash_init(void)
107{
108 u8 cs = 0;
109 u8 onenandcs = GPMC_CS_NUM + 1;
110
111 for (cs = 0; cs < GPMC_CS_NUM; cs++) {
112 u32 ret;
113 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
114
115 /* Check if NAND/oneNAND is configured */
116 if ((ret & 0xC00) == 0x800)
117 /* NAND found */
118 pr_err("IGEP3: Unsupported NAND found\n");
119 else {
120 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
121
122 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
123 /* OneNAND found */
124 onenandcs = cs;
125 }
126 }
127
128 if (onenandcs > GPMC_CS_NUM) {
129 pr_err("IGEP3: Unable to find configuration in GPMC\n");
130 return;
131 }
132
133 igep3_onenand_pdata.cs = onenandcs;
134
135 if (platform_device_register(&igep3_onenand_device) < 0)
136 pr_err("IGEP3: Unable to register OneNAND device\n");
137}
138
139#else
140void __init igep3_flash_init(void) {}
141#endif
142
143static struct regulator_consumer_supply igep3_vmmc1_supply = {
144 .supply = "vmmc",
145};
146
147/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
148static struct regulator_init_data igep3_vmmc1 = {
149 .constraints = {
150 .min_uV = 1850000,
151 .max_uV = 3150000,
152 .valid_modes_mask = REGULATOR_MODE_NORMAL
153 | REGULATOR_MODE_STANDBY,
154 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
155 | REGULATOR_CHANGE_MODE
156 | REGULATOR_CHANGE_STATUS,
157 },
158 .num_consumer_supplies = 1,
159 .consumer_supplies = &igep3_vmmc1_supply,
160};
161
162static struct omap2_hsmmc_info mmc[] = {
163 [0] = {
164 .mmc = 1,
165 .caps = MMC_CAP_4_BIT_DATA,
166 .gpio_cd = -EINVAL,
167 .gpio_wp = -EINVAL,
168 },
169#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
170 [1] = {
171 .mmc = 2,
172 .caps = MMC_CAP_4_BIT_DATA,
173 .gpio_cd = -EINVAL,
174 .gpio_wp = -EINVAL,
175 },
176#endif
177 {} /* Terminator */
178};
179
180#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
181#include <linux/leds.h>
182
183static struct gpio_led igep3_gpio_leds[] = {
184 [0] = {
185 .name = "gpio-led:red:d0",
186 .gpio = IGEP3_GPIO_LED0_RED,
187 .default_trigger = "default-off"
188 },
189 [1] = {
190 .name = "gpio-led:green:d0",
191 .gpio = IGEP3_GPIO_LED0_GREEN,
192 .default_trigger = "default-off",
193 },
194 [2] = {
195 .name = "gpio-led:red:d1",
196 .gpio = IGEP3_GPIO_LED1_RED,
197 .default_trigger = "default-off",
198 },
199 [3] = {
200 .name = "gpio-led:green:d1",
201 .default_trigger = "heartbeat",
202 .gpio = -EINVAL, /* gets replaced */
203 },
204};
205
206static struct gpio_led_platform_data igep3_led_pdata = {
207 .leds = igep3_gpio_leds,
208 .num_leds = ARRAY_SIZE(igep3_gpio_leds),
209};
210
211static struct platform_device igep3_led_device = {
212 .name = "leds-gpio",
213 .id = -1,
214 .dev = {
215 .platform_data = &igep3_led_pdata,
216 },
217};
218
219static void __init igep3_leds_init(void)
220{
221 platform_device_register(&igep3_led_device);
222}
223
224#else
225static inline void igep3_leds_init(void)
226{
227 if ((gpio_request(IGEP3_GPIO_LED0_RED, "gpio-led:red:d0") == 0) &&
228 (gpio_direction_output(IGEP3_GPIO_LED0_RED, 1) == 0)) {
229 gpio_export(IGEP3_GPIO_LED0_RED, 0);
230 gpio_set_value(IGEP3_GPIO_LED0_RED, 1);
231 } else
232 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_RED\n");
233
234 if ((gpio_request(IGEP3_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
235 (gpio_direction_output(IGEP3_GPIO_LED0_GREEN, 1) == 0)) {
236 gpio_export(IGEP3_GPIO_LED0_GREEN, 0);
237 gpio_set_value(IGEP3_GPIO_LED0_GREEN, 1);
238 } else
239 pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_GREEN\n");
240
241 if ((gpio_request(IGEP3_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
242 (gpio_direction_output(IGEP3_GPIO_LED1_RED, 1) == 0)) {
243 gpio_export(IGEP3_GPIO_LED1_RED, 0);
244 gpio_set_value(IGEP3_GPIO_LED1_RED, 1);
245 } else
246 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_RED\n");
247}
248#endif
249
250static int igep3_twl4030_gpio_setup(struct device *dev,
251 unsigned gpio, unsigned ngpio)
252{
253 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
254 mmc[0].gpio_cd = gpio + 0;
255 omap2_hsmmc_init(mmc);
256
257 /*
258 * link regulators to MMC adapters ... we "know" the
259 * regulators will be set up only *after* we return.
260 */
261 igep3_vmmc1_supply.dev = mmc[0].dev;
262
263 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
264#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
265 if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0)
266 && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) {
267 gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
268 gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0);
269 } else
270 pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n");
271#else
272 igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
273#endif
274
275 return 0;
276};
277
278static struct twl4030_gpio_platform_data igep3_twl4030_gpio_pdata = {
279 .gpio_base = OMAP_MAX_GPIO_LINES,
280 .irq_base = TWL4030_GPIO_IRQ_BASE,
281 .irq_end = TWL4030_GPIO_IRQ_END,
282 .use_leds = true,
283 .setup = igep3_twl4030_gpio_setup,
284};
285
286static struct twl4030_usb_data igep3_twl4030_usb_data = {
287 .usb_mode = T2_USB_MODE_ULPI,
288};
289
290static void __init igep3_init_irq(void)
291{
292 omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
293 omap_init_irq();
294 omap_gpio_init();
295}
296
297static struct twl4030_platform_data igep3_twl4030_pdata = {
298 .irq_base = TWL4030_IRQ_BASE,
299 .irq_end = TWL4030_IRQ_END,
300
301 /* platform_data for children goes here */
302 .usb = &igep3_twl4030_usb_data,
303 .gpio = &igep3_twl4030_gpio_pdata,
304 .vmmc1 = &igep3_vmmc1,
305};
306
307static struct i2c_board_info __initdata igep3_i2c_boardinfo[] = {
308 {
309 I2C_BOARD_INFO("twl4030", 0x48),
310 .flags = I2C_CLIENT_WAKE,
311 .irq = INT_34XX_SYS_NIRQ,
312 .platform_data = &igep3_twl4030_pdata,
313 },
314};
315
316static int __init igep3_i2c_init(void)
317{
318 omap_register_i2c_bus(1, 2600, igep3_i2c_boardinfo,
319 ARRAY_SIZE(igep3_i2c_boardinfo));
320
321 return 0;
322}
323
324static struct omap_musb_board_data musb_board_data = {
325 .interface_type = MUSB_INTERFACE_ULPI,
326 .mode = MUSB_OTG,
327 .power = 100,
328};
329
330#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
331
332static void __init igep3_wifi_bt_init(void)
333{
334 /* Configure MUX values for W-LAN + Bluetooth GPIO's */
335 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT);
336 omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT);
337 omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT);
338
339 /* Set GPIO's for W-LAN + Bluetooth combo module */
340 if ((gpio_request(IGEP3_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
341 (gpio_direction_output(IGEP3_GPIO_WIFI_NPD, 1) == 0)) {
342 gpio_export(IGEP3_GPIO_WIFI_NPD, 0);
343 } else
344 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NPD\n");
345
346 if ((gpio_request(IGEP3_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
347 (gpio_direction_output(IGEP3_GPIO_WIFI_NRESET, 1) == 0)) {
348 gpio_export(IGEP3_GPIO_WIFI_NRESET, 0);
349 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0);
350 udelay(10);
351 gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1);
352 } else
353 pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NRESET\n");
354
355 if ((gpio_request(IGEP3_GPIO_BT_NRESET, "GPIO_BT_NRESET") == 0) &&
356 (gpio_direction_output(IGEP3_GPIO_BT_NRESET, 1) == 0)) {
357 gpio_export(IGEP3_GPIO_BT_NRESET, 0);
358 } else
359 pr_warning("IGEP3: Could not obtain gpio GPIO_BT_NRESET\n");
360}
361#else
362void __init igep3_wifi_bt_init(void) {}
363#endif
364
365#ifdef CONFIG_OMAP_MUX
366static struct omap_board_mux board_mux[] __initdata = {
367 { .reg_offset = OMAP_MUX_TERMINATOR },
368};
369#else
370#define board_mux NULL
371#endif
372
373static void __init igep3_init(void)
374{
375 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
376
377 /* Register I2C busses and drivers */
378 igep3_i2c_init();
379
380 omap_serial_init();
381 usb_musb_init(&musb_board_data);
382
383 igep3_flash_init();
384 igep3_leds_init();
385
386 /*
387 * WLAN-BT combo module from MuRata wich has a Marvell WLAN
388 * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
389 */
390 igep3_wifi_bt_init();
391
392}
393
394MACHINE_START(IGEP0030, "IGEP OMAP3 module")
395 .boot_params = 0x80000100,
396 .map_io = omap3_map_io,
397 .init_irq = igep3_init_irq,
398 .init_machine = igep3_init,
399 .timer = &omap_timer,
400MACHINE_END
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index f28fd77bceb3..001fd9713f39 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -27,6 +27,7 @@
27#include <linux/i2c/twl.h> 27#include <linux/i2c/twl.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/smsc911x.h> 29#include <linux/smsc911x.h>
30#include <linux/mmc/host.h>
30 31
31#include <mach/hardware.h> 32#include <mach/hardware.h>
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -41,11 +42,12 @@
41#include <mach/board-zoom.h> 42#include <mach/board-zoom.h>
42 43
43#include <asm/delay.h> 44#include <asm/delay.h>
44#include <plat/control.h>
45#include <plat/usb.h> 45#include <plat/usb.h>
46 46
47#include "board-flash.h"
47#include "mux.h" 48#include "mux.h"
48#include "hsmmc.h" 49#include "hsmmc.h"
50#include "control.h"
49 51
50#define LDP_SMSC911X_CS 1 52#define LDP_SMSC911X_CS 1
51#define LDP_SMSC911X_GPIO 152 53#define LDP_SMSC911X_GPIO 152
@@ -82,7 +84,7 @@ static struct platform_device ldp_smsc911x_device = {
82 }, 84 },
83}; 85};
84 86
85static int board_keymap[] = { 87static uint32_t board_keymap[] = {
86 KEY(0, 0, KEY_1), 88 KEY(0, 0, KEY_1),
87 KEY(1, 0, KEY_2), 89 KEY(1, 0, KEY_2),
88 KEY(2, 0, KEY_3), 90 KEY(2, 0, KEY_3),
@@ -362,7 +364,7 @@ static int __init omap_i2c_init(void)
362static struct omap2_hsmmc_info mmc[] __initdata = { 364static struct omap2_hsmmc_info mmc[] __initdata = {
363 { 365 {
364 .mmc = 1, 366 .mmc = 1,
365 .wires = 4, 367 .caps = MMC_CAP_4_BIT_DATA,
366 .gpio_cd = -EINVAL, 368 .gpio_cd = -EINVAL,
367 .gpio_wp = -EINVAL, 369 .gpio_wp = -EINVAL,
368 }, 370 },
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 3f7966873507..e823c7042ab3 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/usb/musb.h> 22#include <linux/usb/musb.h>
23#include <sound/tlv320aic3x.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/mach-types.h> 26#include <asm/mach-types.h>
@@ -383,15 +384,6 @@ static void n8x0_mmc_callback(void *data, u8 card_mask)
383 omap_mmc_notify_cover_event(mmc_device, index, *openp); 384 omap_mmc_notify_cover_event(mmc_device, index, *openp);
384} 385}
385 386
386void n8x0_mmc_slot1_cover_handler(void *arg, int closed_state)
387{
388 if (mmc_device == NULL)
389 return;
390
391 slot1_cover_open = !closed_state;
392 omap_mmc_notify_cover_event(mmc_device, 0, closed_state);
393}
394
395static int n8x0_mmc_late_init(struct device *dev) 387static int n8x0_mmc_late_init(struct device *dev)
396{ 388{
397 int r, bit, *openp; 389 int r, bit, *openp;
@@ -511,7 +503,7 @@ static struct omap_mmc_platform_data mmc1_data = {
511 503
512static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC]; 504static struct omap_mmc_platform_data *mmc_data[OMAP24XX_NR_MMC];
513 505
514void __init n8x0_mmc_init(void) 506static void __init n8x0_mmc_init(void)
515 507
516{ 508{
517 int err; 509 int err;
@@ -560,11 +552,6 @@ void __init n8x0_mmc_init(void)
560void __init n8x0_mmc_init(void) 552void __init n8x0_mmc_init(void)
561{ 553{
562} 554}
563
564void n8x0_mmc_slot1_cover_handler(void *arg, int state)
565{
566}
567
568#endif /* CONFIG_MMC_OMAP */ 555#endif /* CONFIG_MMC_OMAP */
569 556
570#ifdef CONFIG_MENELAUS 557#ifdef CONFIG_MENELAUS
@@ -614,29 +601,35 @@ static int n8x0_menelaus_late_init(struct device *dev)
614 return 0; 601 return 0;
615} 602}
616 603
617static struct i2c_board_info __initdata n8x0_i2c_board_info_1[] = { 604#else
605static int n8x0_menelaus_late_init(struct device *dev)
606{
607 return 0;
608}
609#endif
610
611static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
612 .late_init = n8x0_menelaus_late_init,
613};
614
615static struct i2c_board_info __initdata n8x0_i2c_board_info_1[] __initdata = {
618 { 616 {
619 I2C_BOARD_INFO("menelaus", 0x72), 617 I2C_BOARD_INFO("menelaus", 0x72),
620 .irq = INT_24XX_SYS_NIRQ, 618 .irq = INT_24XX_SYS_NIRQ,
619 .platform_data = &n8x0_menelaus_platform_data,
621 }, 620 },
622}; 621};
623 622
624static struct menelaus_platform_data n8x0_menelaus_platform_data = { 623static struct aic3x_pdata n810_aic33_data __initdata = {
625 .late_init = n8x0_menelaus_late_init, 624 .gpio_reset = 118,
626}; 625};
627 626
628static void __init n8x0_menelaus_init(void) 627static struct i2c_board_info n810_i2c_board_info_2[] __initdata = {
629{ 628 {
630 n8x0_i2c_board_info_1[0].platform_data = &n8x0_menelaus_platform_data; 629 I2C_BOARD_INFO("tlv320aic3x", 0x18),
631 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1, 630 .platform_data = &n810_aic33_data,
632 ARRAY_SIZE(n8x0_i2c_board_info_1)); 631 },
633} 632};
634
635#else
636static inline void __init n8x0_menelaus_init(void)
637{
638}
639#endif
640 633
641static void __init n8x0_map_io(void) 634static void __init n8x0_map_io(void)
642{ 635{
@@ -653,6 +646,11 @@ static void __init n8x0_init_irq(void)
653 646
654#ifdef CONFIG_OMAP_MUX 647#ifdef CONFIG_OMAP_MUX
655static struct omap_board_mux board_mux[] __initdata = { 648static struct omap_board_mux board_mux[] __initdata = {
649 /* I2S codec port pins for McBSP block */
650 OMAP2420_MUX(EAC_AC_SCLK, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
651 OMAP2420_MUX(EAC_AC_FS, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
652 OMAP2420_MUX(EAC_AC_DIN, OMAP_MUX_MODE1 | OMAP_PIN_INPUT),
653 OMAP2420_MUX(EAC_AC_DOUT, OMAP_MUX_MODE1 | OMAP_PIN_OUTPUT),
656 { .reg_offset = OMAP_MUX_TERMINATOR }, 654 { .reg_offset = OMAP_MUX_TERMINATOR },
657}; 655};
658#else 656#else
@@ -665,9 +663,14 @@ static void __init n8x0_init_machine(void)
665 /* FIXME: add n810 spi devices */ 663 /* FIXME: add n810 spi devices */
666 spi_register_board_info(n800_spi_board_info, 664 spi_register_board_info(n800_spi_board_info,
667 ARRAY_SIZE(n800_spi_board_info)); 665 ARRAY_SIZE(n800_spi_board_info));
666 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
667 ARRAY_SIZE(n8x0_i2c_board_info_1));
668 omap_register_i2c_bus(2, 400, NULL, 0);
669 if (machine_is_nokia_n810())
670 i2c_register_board_info(2, n810_i2c_board_info_2,
671 ARRAY_SIZE(n810_i2c_board_info_2));
668 672
669 omap_serial_init(); 673 omap_serial_init();
670 n8x0_menelaus_init();
671 n8x0_onenand_init(); 674 n8x0_onenand_init();
672 n8x0_mmc_init(); 675 n8x0_mmc_init();
673 n8x0_usb_init(); 676 n8x0_usb_init();
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 9d9f5b881ee8..14f42240ae79 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -27,6 +27,7 @@
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h> 29#include <linux/mtd/nand.h>
30#include <linux/mmc/host.h>
30 31
31#include <linux/regulator/machine.h> 32#include <linux/regulator/machine.h>
32#include <linux/i2c/twl.h> 33#include <linux/i2c/twl.h>
@@ -43,13 +44,100 @@
43#include <plat/gpmc.h> 44#include <plat/gpmc.h>
44#include <plat/nand.h> 45#include <plat/nand.h>
45#include <plat/usb.h> 46#include <plat/usb.h>
46#include <plat/timer-gp.h>
47 47
48#include "mux.h" 48#include "mux.h"
49#include "hsmmc.h" 49#include "hsmmc.h"
50#include "timer-gp.h"
50 51
51#define NAND_BLOCK_SIZE SZ_128K 52#define NAND_BLOCK_SIZE SZ_128K
52 53
54/*
55 * OMAP3 Beagle revision
56 * Run time detection of Beagle revision is done by reading GPIO.
57 * GPIO ID -
58 * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
59 * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
60 * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
61 * XM = GPIO173, GPIO172, GPIO171: 0 0 0
62 */
63enum {
64 OMAP3BEAGLE_BOARD_UNKN = 0,
65 OMAP3BEAGLE_BOARD_AXBX,
66 OMAP3BEAGLE_BOARD_C1_3,
67 OMAP3BEAGLE_BOARD_C4,
68 OMAP3BEAGLE_BOARD_XM,
69};
70
71static u8 omap3_beagle_version;
72
73static u8 omap3_beagle_get_rev(void)
74{
75 return omap3_beagle_version;
76}
77
78static void __init omap3_beagle_init_rev(void)
79{
80 int ret;
81 u16 beagle_rev = 0;
82
83 omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
84 omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
85 omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
86
87 ret = gpio_request(171, "rev_id_0");
88 if (ret < 0)
89 goto fail0;
90
91 ret = gpio_request(172, "rev_id_1");
92 if (ret < 0)
93 goto fail1;
94
95 ret = gpio_request(173, "rev_id_2");
96 if (ret < 0)
97 goto fail2;
98
99 gpio_direction_input(171);
100 gpio_direction_input(172);
101 gpio_direction_input(173);
102
103 beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
104 | (gpio_get_value(173) << 2);
105
106 switch (beagle_rev) {
107 case 7:
108 printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
109 omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
110 break;
111 case 6:
112 printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
113 omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
114 break;
115 case 5:
116 printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
117 omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
118 break;
119 case 0:
120 printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
121 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
122 break;
123 default:
124 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
125 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
126 }
127
128 return;
129
130fail2:
131 gpio_free(172);
132fail1:
133 gpio_free(171);
134fail0:
135 printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
136 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
137
138 return;
139}
140
53static struct mtd_partition omap3beagle_nand_partitions[] = { 141static struct mtd_partition omap3beagle_nand_partitions[] = {
54 /* All the partition sizes are listed in terms of NAND block size */ 142 /* All the partition sizes are listed in terms of NAND block size */
55 { 143 {
@@ -166,7 +254,7 @@ static void __init beagle_display_init(void)
166static struct omap2_hsmmc_info mmc[] = { 254static struct omap2_hsmmc_info mmc[] = {
167 { 255 {
168 .mmc = 1, 256 .mmc = 1,
169 .wires = 8, 257 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
170 .gpio_wp = 29, 258 .gpio_wp = 29,
171 }, 259 },
172 {} /* Terminator */ 260 {} /* Terminator */
@@ -185,7 +273,10 @@ static struct gpio_led gpio_leds[];
185static int beagle_twl_gpio_setup(struct device *dev, 273static int beagle_twl_gpio_setup(struct device *dev,
186 unsigned gpio, unsigned ngpio) 274 unsigned gpio, unsigned ngpio)
187{ 275{
188 if (system_rev >= 0x20 && system_rev <= 0x34301000) { 276 if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
277 mmc[0].gpio_wp = -EINVAL;
278 } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
279 (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
189 omap_mux_init_gpio(23, OMAP_PIN_INPUT); 280 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
190 mmc[0].gpio_wp = 23; 281 mmc[0].gpio_wp = 23;
191 } else { 282 } else {
@@ -322,13 +413,19 @@ static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
322 }, 413 },
323}; 414};
324 415
416static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
417 {
418 I2C_BOARD_INFO("eeprom", 0x50),
419 },
420};
421
325static int __init omap3_beagle_i2c_init(void) 422static int __init omap3_beagle_i2c_init(void)
326{ 423{
327 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo, 424 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
328 ARRAY_SIZE(beagle_i2c_boardinfo)); 425 ARRAY_SIZE(beagle_i2c_boardinfo));
329 /* Bus 3 is attached to the DVI port where devices like the pico DLP 426 /* Bus 3 is attached to the DVI port where devices like the pico DLP
330 * projector don't work reliably with 400kHz */ 427 * projector don't work reliably with 400kHz */
331 omap_register_i2c_bus(3, 100, NULL, 0); 428 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
332 return 0; 429 return 0;
333} 430}
334 431
@@ -464,6 +561,7 @@ static struct omap_musb_board_data musb_board_data = {
464static void __init omap3_beagle_init(void) 561static void __init omap3_beagle_init(void)
465{ 562{
466 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 563 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
564 omap3_beagle_init_rev();
467 omap3_beagle_i2c_init(); 565 omap3_beagle_i2c_init();
468 platform_add_devices(omap3_beagle_devices, 566 platform_add_devices(omap3_beagle_devices,
469 ARRAY_SIZE(omap3_beagle_devices)); 567 ARRAY_SIZE(omap3_beagle_devices));
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 8936e4fba334..b04365c6bb10 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -31,6 +31,7 @@
31#include <linux/smsc911x.h> 31#include <linux/smsc911x.h>
32 32
33#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
34#include <linux/mmc/host.h>
34 35
35#include <mach/hardware.h> 36#include <mach/hardware.h>
36#include <asm/mach-types.h> 37#include <asm/mach-types.h>
@@ -370,7 +371,7 @@ static struct regulator_init_data omap3evm_vsim = {
370static struct omap2_hsmmc_info mmc[] = { 371static struct omap2_hsmmc_info mmc[] = {
371 { 372 {
372 .mmc = 1, 373 .mmc = 1,
373 .wires = 4, 374 .caps = MMC_CAP_4_BIT_DATA,
374 .gpio_cd = -EINVAL, 375 .gpio_cd = -EINVAL,
375 .gpio_wp = 63, 376 .gpio_wp = 63,
376 }, 377 },
@@ -446,7 +447,7 @@ static struct twl4030_usb_data omap3evm_usb_data = {
446 .usb_mode = T2_USB_MODE_ULPI, 447 .usb_mode = T2_USB_MODE_ULPI,
447}; 448};
448 449
449static int board_keymap[] = { 450static uint32_t board_keymap[] = {
450 KEY(0, 0, KEY_LEFT), 451 KEY(0, 0, KEY_LEFT),
451 KEY(0, 1, KEY_DOWN), 452 KEY(0, 1, KEY_DOWN),
452 KEY(0, 2, KEY_ENTER), 453 KEY(0, 2, KEY_ENTER),
@@ -584,7 +585,7 @@ static int ads7846_get_pendown_state(void)
584 return !gpio_get_value(OMAP3_EVM_TS_GPIO); 585 return !gpio_get_value(OMAP3_EVM_TS_GPIO);
585} 586}
586 587
587struct ads7846_platform_data ads7846_config = { 588static struct ads7846_platform_data ads7846_config = {
588 .x_max = 0x0fff, 589 .x_max = 0x0fff,
589 .y_max = 0x0fff, 590 .y_max = 0x0fff,
590 .x_plate_ohms = 180, 591 .x_plate_ohms = 180,
@@ -603,7 +604,7 @@ static struct omap2_mcspi_device_config ads7846_mcspi_config = {
603 .single_channel = 1, /* 0: slave, 1: master */ 604 .single_channel = 1, /* 0: slave, 1: master */
604}; 605};
605 606
606struct spi_board_info omap3evm_spi_board_info[] = { 607static struct spi_board_info omap3evm_spi_board_info[] = {
607 [0] = { 608 [0] = {
608 .modalias = "ads7846", 609 .modalias = "ads7846",
609 .bus_num = 1, 610 .bus_num = 1,
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
new file mode 100644
index 000000000000..5f7d2c1e7ef5
--- /dev/null
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -0,0 +1,241 @@
1/*
2 * linux/arch/arm/mach-omap2/board-omap3logic.c
3 *
4 * Copyright (C) 2010 Li-Pro.Net
5 * Stephan Linz <linz@li-pro.net>
6 *
7 * Copyright (C) 2010 Logic Product Development, Inc.
8 * Peter Barada <peter.barada@logicpd.com>
9 *
10 * Modified from Beagle, EVM, and RX51
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/delay.h>
21#include <linux/err.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24#include <linux/gpio.h>
25
26#include <linux/regulator/machine.h>
27
28#include <linux/i2c/twl.h>
29#include <linux/mmc/host.h>
30
31#include <mach/hardware.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35
36#include "mux.h"
37#include "hsmmc.h"
38#include "timer-gp.h"
39#include "control.h"
40
41#include <plat/mux.h>
42#include <plat/board.h>
43#include <plat/common.h>
44#include <plat/gpmc-smsc911x.h>
45#include <plat/gpmc.h>
46#include <plat/sdrc.h>
47
48#define OMAP3LOGIC_SMSC911X_CS 1
49
50#define OMAP3530_LV_SOM_MMC_GPIO_CD 110
51#define OMAP3530_LV_SOM_MMC_GPIO_WP 126
52#define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
53
54#define OMAP3_TORPEDO_MMC_GPIO_CD 127
55#define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
56
57static struct regulator_consumer_supply omap3logic_vmmc1_supply = {
58 .supply = "vmmc",
59};
60
61/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
62static struct regulator_init_data omap3logic_vmmc1 = {
63 .constraints = {
64 .name = "VMMC1",
65 .min_uV = 1850000,
66 .max_uV = 3150000,
67 .valid_modes_mask = REGULATOR_MODE_NORMAL
68 | REGULATOR_MODE_STANDBY,
69 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
70 | REGULATOR_CHANGE_MODE
71 | REGULATOR_CHANGE_STATUS,
72 },
73 .num_consumer_supplies = 1,
74 .consumer_supplies = &omap3logic_vmmc1_supply,
75};
76
77static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
78 .gpio_base = OMAP_MAX_GPIO_LINES,
79 .irq_base = TWL4030_GPIO_IRQ_BASE,
80 .irq_end = TWL4030_GPIO_IRQ_END,
81 .use_leds = true,
82 .pullups = BIT(1),
83 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
84 | BIT(13) | BIT(15) | BIT(16) | BIT(17),
85};
86
87static struct twl4030_platform_data omap3logic_twldata = {
88 .irq_base = TWL4030_IRQ_BASE,
89 .irq_end = TWL4030_IRQ_END,
90
91 /* platform_data for children goes here */
92 .gpio = &omap3logic_gpio_data,
93 .vmmc1 = &omap3logic_vmmc1,
94};
95
96static struct i2c_board_info __initdata omap3logic_i2c_boardinfo[] = {
97 {
98 I2C_BOARD_INFO("twl4030", 0x48),
99 .flags = I2C_CLIENT_WAKE,
100 .irq = INT_34XX_SYS_NIRQ,
101 .platform_data = &omap3logic_twldata,
102 },
103};
104
105static int __init omap3logic_i2c_init(void)
106{
107 omap_register_i2c_bus(1, 2600, omap3logic_i2c_boardinfo,
108 ARRAY_SIZE(omap3logic_i2c_boardinfo));
109 return 0;
110}
111
112static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
113 {
114 .name = "external",
115 .mmc = 1,
116 .caps = MMC_CAP_4_BIT_DATA,
117 .gpio_cd = -EINVAL,
118 .gpio_wp = -EINVAL,
119 },
120 {} /* Terminator */
121};
122
123static void __init board_mmc_init(void)
124{
125 if (machine_is_omap3530_lv_som()) {
126 /* OMAP3530 LV SOM board */
127 board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
128 board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
129 omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
130 omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
131 } else if (machine_is_omap3_torpedo()) {
132 /* OMAP3 Torpedo board */
133 board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
134 omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
135 } else {
136 /* unsupported board */
137 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
138 return;
139 }
140
141 omap2_hsmmc_init(board_mmc_info);
142 /* link regulators to MMC adapters */
143 omap3logic_vmmc1_supply.dev = board_mmc_info[0].dev;
144}
145
146static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
147 .cs = OMAP3LOGIC_SMSC911X_CS,
148 .gpio_irq = -EINVAL,
149 .gpio_reset = -EINVAL,
150 .flags = IORESOURCE_IRQ_LOWLEVEL,
151};
152
153/* TODO/FIXME (comment by Peter Barada, LogicPD):
154 * Fix the PBIAS voltage for Torpedo MMC1 pins that
155 * are used for other needs (IRQs, etc). */
156static void omap3torpedo_fix_pbias_voltage(void)
157{
158 u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
159 u32 reg;
160
161 if (machine_is_omap3_torpedo())
162 {
163 /* Set the bias for the pin */
164 reg = omap_ctrl_readl(control_pbias_offset);
165
166 reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
167 omap_ctrl_writel(reg, control_pbias_offset);
168
169 /* 100ms delay required for PBIAS configuration */
170 msleep(100);
171
172 reg |= OMAP343X_PBIASLITEVMODE1;
173 reg |= OMAP343X_PBIASLITEPWRDNZ1;
174 omap_ctrl_writel(reg | 0x300, control_pbias_offset);
175 }
176}
177
178static inline void __init board_smsc911x_init(void)
179{
180 if (machine_is_omap3530_lv_som()) {
181 /* OMAP3530 LV SOM board */
182 board_smsc911x_data.gpio_irq =
183 OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
184 omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
185 } else if (machine_is_omap3_torpedo()) {
186 /* OMAP3 Torpedo board */
187 board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
188 omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
189 } else {
190 /* unsupported board */
191 printk(KERN_ERR "%s(): unknown machine type\n", __func__);
192 return;
193 }
194
195 gpmc_smsc911x_init(&board_smsc911x_data);
196}
197
198static void __init omap3logic_init_irq(void)
199{
200 omap2_init_common_hw(NULL, NULL);
201 omap_init_irq();
202 omap_gpio_init();
203}
204
205#ifdef CONFIG_OMAP_MUX
206static struct omap_board_mux board_mux[] __initdata = {
207 { .reg_offset = OMAP_MUX_TERMINATOR },
208};
209#else
210#define board_mux NULL
211#endif
212
213static void __init omap3logic_init(void)
214{
215 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
216 omap3torpedo_fix_pbias_voltage();
217 omap3logic_i2c_init();
218 omap_serial_init();
219 board_mmc_init();
220 board_smsc911x_init();
221
222 /* Ensure SDRC pins are mux'd for self-refresh */
223 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
224 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
225}
226
227MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
228 .boot_params = 0x80000100,
229 .map_io = omap3_map_io,
230 .init_irq = omap3logic_init_irq,
231 .init_machine = omap3logic_init,
232 .timer = &omap_timer,
233MACHINE_END
234
235MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
236 .boot_params = 0x80000100,
237 .map_io = omap3_map_io,
238 .init_irq = omap3logic_init_irq,
239 .init_machine = omap3logic_init,
240 .timer = &omap_timer,
241MACHINE_END
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index b7d6df4e3cf9..89ed1be2d62e 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -25,14 +25,16 @@
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>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/input/matrix_keypad.h> 33#include <linux/input/matrix_keypad.h>
34#include <linux/gpio_keys.h> 34#include <linux/gpio_keys.h>
35#include <linux/mmc/host.h>
35#include <linux/mmc/card.h> 36#include <linux/mmc/card.h>
37#include <linux/regulator/fixed.h>
36 38
37#include <asm/mach-types.h> 39#include <asm/mach-types.h>
38#include <asm/mach/arch.h> 40#include <asm/mach/arch.h>
@@ -276,14 +278,14 @@ static void pandora_wl1251_init_card(struct mmc_card *card)
276static struct omap2_hsmmc_info omap3pandora_mmc[] = { 278static struct omap2_hsmmc_info omap3pandora_mmc[] = {
277 { 279 {
278 .mmc = 1, 280 .mmc = 1,
279 .wires = 4, 281 .caps = MMC_CAP_4_BIT_DATA,
280 .gpio_cd = -EINVAL, 282 .gpio_cd = -EINVAL,
281 .gpio_wp = 126, 283 .gpio_wp = 126,
282 .ext_clock = 0, 284 .ext_clock = 0,
283 }, 285 },
284 { 286 {
285 .mmc = 2, 287 .mmc = 2,
286 .wires = 4, 288 .caps = MMC_CAP_4_BIT_DATA,
287 .gpio_cd = -EINVAL, 289 .gpio_cd = -EINVAL,
288 .gpio_wp = 127, 290 .gpio_wp = 127,
289 .ext_clock = 1, 291 .ext_clock = 1,
@@ -291,7 +293,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
291 }, 293 },
292 { 294 {
293 .mmc = 3, 295 .mmc = 3,
294 .wires = 4, 296 .caps = MMC_CAP_4_BIT_DATA,
295 .gpio_cd = -EINVAL, 297 .gpio_cd = -EINVAL,
296 .gpio_wp = -EINVAL, 298 .gpio_wp = -EINVAL,
297 .init_card = pandora_wl1251_init_card, 299 .init_card = pandora_wl1251_init_card,
@@ -344,6 +346,9 @@ static struct regulator_consumer_supply pandora_vmmc1_supply =
344static struct regulator_consumer_supply pandora_vmmc2_supply = 346static struct regulator_consumer_supply pandora_vmmc2_supply =
345 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1"); 347 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
346 348
349static struct regulator_consumer_supply pandora_vmmc3_supply =
350 REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.2");
351
347static struct regulator_consumer_supply pandora_vdda_dac_supply = 352static struct regulator_consumer_supply pandora_vdda_dac_supply =
348 REGULATOR_SUPPLY("vdda_dac", "omapdss"); 353 REGULATOR_SUPPLY("vdda_dac", "omapdss");
349 354
@@ -488,6 +493,33 @@ static struct regulator_init_data pandora_vsim = {
488 .consumer_supplies = &pandora_adac_supply, 493 .consumer_supplies = &pandora_adac_supply,
489}; 494};
490 495
496/* Fixed regulator internal to Wifi module */
497static struct regulator_init_data pandora_vmmc3 = {
498 .constraints = {
499 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
500 },
501 .num_consumer_supplies = 1,
502 .consumer_supplies = &pandora_vmmc3_supply,
503};
504
505static struct fixed_voltage_config pandora_vwlan = {
506 .supply_name = "vwlan",
507 .microvolts = 1800000, /* 1.8V */
508 .gpio = PANDORA_WIFI_NRESET_GPIO,
509 .startup_delay = 50000, /* 50ms */
510 .enable_high = 1,
511 .enabled_at_boot = 0,
512 .init_data = &pandora_vmmc3,
513};
514
515static struct platform_device pandora_vwlan_device = {
516 .name = "reg-fixed-voltage",
517 .id = 1,
518 .dev = {
519 .platform_data = &pandora_vwlan,
520 },
521};
522
491static struct twl4030_usb_data omap3pandora_usb_data = { 523static struct twl4030_usb_data omap3pandora_usb_data = {
492 .usb_mode = T2_USB_MODE_ULPI, 524 .usb_mode = T2_USB_MODE_ULPI,
493}; 525};
@@ -501,6 +533,8 @@ static struct twl4030_codec_data omap3pandora_codec_data = {
501 .audio = &omap3pandora_audio_data, 533 .audio = &omap3pandora_audio_data,
502}; 534};
503 535
536static struct twl4030_bci_platform_data pandora_bci_data;
537
504static struct twl4030_platform_data omap3pandora_twldata = { 538static struct twl4030_platform_data omap3pandora_twldata = {
505 .irq_base = TWL4030_IRQ_BASE, 539 .irq_base = TWL4030_IRQ_BASE,
506 .irq_end = TWL4030_IRQ_END, 540 .irq_end = TWL4030_IRQ_END,
@@ -516,6 +550,7 @@ static struct twl4030_platform_data omap3pandora_twldata = {
516 .vaux4 = &pandora_vaux4, 550 .vaux4 = &pandora_vaux4,
517 .vsim = &pandora_vsim, 551 .vsim = &pandora_vsim,
518 .keypad = &pandora_kp_data, 552 .keypad = &pandora_kp_data,
553 .bci = &pandora_bci_data,
519}; 554};
520 555
521static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = { 556static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
@@ -644,19 +679,8 @@ static void pandora_wl1251_init(void)
644 if (pandora_wl1251_pdata.irq < 0) 679 if (pandora_wl1251_pdata.irq < 0)
645 goto fail_irq; 680 goto fail_irq;
646 681
647 ret = gpio_request(PANDORA_WIFI_NRESET_GPIO, "wl1251 nreset");
648 if (ret < 0)
649 goto fail_irq;
650
651 /* start powered so that it probes with MMC subsystem */
652 ret = gpio_direction_output(PANDORA_WIFI_NRESET_GPIO, 1);
653 if (ret < 0)
654 goto fail_nreset;
655
656 return; 682 return;
657 683
658fail_nreset:
659 gpio_free(PANDORA_WIFI_NRESET_GPIO);
660fail_irq: 684fail_irq:
661 gpio_free(PANDORA_WIFI_IRQ_GPIO); 685 gpio_free(PANDORA_WIFI_IRQ_GPIO);
662fail: 686fail:
@@ -668,6 +692,7 @@ static struct platform_device *omap3pandora_devices[] __initdata = {
668 &pandora_keys_gpio, 692 &pandora_keys_gpio,
669 &pandora_dss_device, 693 &pandora_dss_device,
670 &pandora_wl1251_data, 694 &pandora_wl1251_data,
695 &pandora_vwlan_device,
671}; 696};
672 697
673static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { 698static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index bc5ac83bd4cf..f25272125413 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/regulator/machine.h> 27#include <linux/regulator/machine.h>
28#include <linux/i2c/twl.h> 28#include <linux/i2c/twl.h>
29#include <linux/mmc/host.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
@@ -38,7 +39,6 @@
38#include <plat/gpmc.h> 39#include <plat/gpmc.h>
39#include <plat/nand.h> 40#include <plat/nand.h>
40#include <plat/usb.h> 41#include <plat/usb.h>
41#include <plat/timer-gp.h>
42#include <plat/display.h> 42#include <plat/display.h>
43 43
44#include <plat/mcspi.h> 44#include <plat/mcspi.h>
@@ -52,6 +52,7 @@
52#include "sdram-micron-mt46h32m32lf-6.h" 52#include "sdram-micron-mt46h32m32lf-6.h"
53#include "mux.h" 53#include "mux.h"
54#include "hsmmc.h" 54#include "hsmmc.h"
55#include "timer-gp.h"
55 56
56#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 57#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
57#define OMAP3STALKER_ETHR_START 0x2c000000 58#define OMAP3STALKER_ETHR_START 0x2c000000
@@ -275,7 +276,7 @@ static struct regulator_init_data omap3stalker_vsim = {
275static struct omap2_hsmmc_info mmc[] = { 276static struct omap2_hsmmc_info mmc[] = {
276 { 277 {
277 .mmc = 1, 278 .mmc = 1,
278 .wires = 4, 279 .caps = MMC_CAP_4_BIT_DATA,
279 .gpio_cd = -EINVAL, 280 .gpio_cd = -EINVAL,
280 .gpio_wp = 23, 281 .gpio_wp = 23,
281 }, 282 },
@@ -389,7 +390,7 @@ static struct twl4030_usb_data omap3stalker_usb_data = {
389 .usb_mode = T2_USB_MODE_ULPI, 390 .usb_mode = T2_USB_MODE_ULPI,
390}; 391};
391 392
392static int board_keymap[] = { 393static uint32_t board_keymap[] = {
393 KEY(0, 0, KEY_LEFT), 394 KEY(0, 0, KEY_LEFT),
394 KEY(0, 1, KEY_DOWN), 395 KEY(0, 1, KEY_DOWN),
395 KEY(0, 2, KEY_ENTER), 396 KEY(0, 2, KEY_ENTER),
@@ -564,7 +565,7 @@ static struct omap2_mcspi_device_config ads7846_mcspi_config = {
564 .single_channel = 1, /* 0: slave, 1: master */ 565 .single_channel = 1, /* 0: slave, 1: master */
565}; 566};
566 567
567struct spi_board_info omap3stalker_spi_board_info[] = { 568static struct spi_board_info omap3stalker_spi_board_info[] = {
568 [0] = { 569 [0] = {
569 .modalias = "ads7846", 570 .modalias = "ads7846",
570 .bus_num = 1, 571 .bus_num = 1,
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 0e99ce584dbf..41104bb8774c 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -27,6 +27,7 @@
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h> 29#include <linux/mtd/nand.h>
30#include <linux/mmc/host.h>
30 31
31#include <plat/mcspi.h> 32#include <plat/mcspi.h>
32#include <linux/spi/spi.h> 33#include <linux/spi/spi.h>
@@ -47,10 +48,10 @@
47#include <plat/gpmc.h> 48#include <plat/gpmc.h>
48#include <plat/nand.h> 49#include <plat/nand.h>
49#include <plat/usb.h> 50#include <plat/usb.h>
50#include <plat/timer-gp.h>
51 51
52#include "mux.h" 52#include "mux.h"
53#include "hsmmc.h" 53#include "hsmmc.h"
54#include "timer-gp.h"
54 55
55#include <asm/setup.h> 56#include <asm/setup.h>
56 57
@@ -61,7 +62,7 @@
61#define TB_BL_PWM_TIMER 9 62#define TB_BL_PWM_TIMER 9
62#define TB_KILL_POWER_GPIO 168 63#define TB_KILL_POWER_GPIO 168
63 64
64unsigned long touchbook_revision; 65static unsigned long touchbook_revision;
65 66
66static struct mtd_partition omap3touchbook_nand_partitions[] = { 67static struct mtd_partition omap3touchbook_nand_partitions[] = {
67 /* All the partition sizes are listed in terms of NAND block size */ 68 /* All the partition sizes are listed in terms of NAND block size */
@@ -108,7 +109,7 @@ static struct omap_nand_platform_data omap3touchbook_nand_data = {
108static struct omap2_hsmmc_info mmc[] = { 109static struct omap2_hsmmc_info mmc[] = {
109 { 110 {
110 .mmc = 1, 111 .mmc = 1,
111 .wires = 8, 112 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
112 .gpio_wp = 29, 113 .gpio_wp = 29,
113 }, 114 },
114 {} /* Terminator */ 115 {} /* Terminator */
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index db69bcadf4c7..1ecd0a6cefb7 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/leds.h>
23#include <linux/gpio.h> 24#include <linux/gpio.h>
24#include <linux/usb/otg.h> 25#include <linux/usb/otg.h>
25#include <linux/i2c/twl.h> 26#include <linux/i2c/twl.h>
@@ -33,12 +34,45 @@
33 34
34#include <plat/board.h> 35#include <plat/board.h>
35#include <plat/common.h> 36#include <plat/common.h>
36#include <plat/control.h>
37#include <plat/timer-gp.h>
38#include <plat/usb.h> 37#include <plat/usb.h>
39#include <plat/mmc.h> 38#include <plat/mmc.h>
39#include "timer-gp.h"
40
40#include "hsmmc.h" 41#include "hsmmc.h"
42#include "control.h"
43
44#define GPIO_HUB_POWER 1
45#define GPIO_HUB_NRESET 62
46
47static struct gpio_led gpio_leds[] = {
48 {
49 .name = "pandaboard::status1",
50 .default_trigger = "heartbeat",
51 .gpio = 7,
52 },
53 {
54 .name = "pandaboard::status2",
55 .default_trigger = "mmc0",
56 .gpio = 8,
57 },
58};
41 59
60static struct gpio_led_platform_data gpio_led_info = {
61 .leds = gpio_leds,
62 .num_leds = ARRAY_SIZE(gpio_leds),
63};
64
65static struct platform_device leds_gpio = {
66 .name = "leds-gpio",
67 .id = -1,
68 .dev = {
69 .platform_data = &gpio_led_info,
70 },
71};
72
73static struct platform_device *panda_devices[] __initdata = {
74 &leds_gpio,
75};
42 76
43static void __init omap4_panda_init_irq(void) 77static void __init omap4_panda_init_irq(void)
44{ 78{
@@ -47,6 +81,56 @@ static void __init omap4_panda_init_irq(void)
47 omap_gpio_init(); 81 omap_gpio_init();
48} 82}
49 83
84static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
85 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
86 .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
87 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
88 .phy_reset = false,
89 .reset_gpio_port[0] = -EINVAL,
90 .reset_gpio_port[1] = -EINVAL,
91 .reset_gpio_port[2] = -EINVAL
92};
93
94static void __init omap4_ehci_init(void)
95{
96 int ret;
97
98
99 /* disable the power to the usb hub prior to init */
100 ret = gpio_request(GPIO_HUB_POWER, "hub_power");
101 if (ret) {
102 pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER);
103 goto error1;
104 }
105 gpio_export(GPIO_HUB_POWER, 0);
106 gpio_direction_output(GPIO_HUB_POWER, 0);
107 gpio_set_value(GPIO_HUB_POWER, 0);
108
109 /* reset phy+hub */
110 ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset");
111 if (ret) {
112 pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET);
113 goto error2;
114 }
115 gpio_export(GPIO_HUB_NRESET, 0);
116 gpio_direction_output(GPIO_HUB_NRESET, 0);
117 gpio_set_value(GPIO_HUB_NRESET, 0);
118 gpio_set_value(GPIO_HUB_NRESET, 1);
119
120 usb_ehci_init(&ehci_pdata);
121
122 /* enable power to hub */
123 gpio_set_value(GPIO_HUB_POWER, 1);
124 return;
125
126error2:
127 gpio_free(GPIO_HUB_POWER);
128error1:
129 pr_err("Unable to initialize EHCI power/reset\n");
130 return;
131
132}
133
50static struct omap_musb_board_data musb_board_data = { 134static struct omap_musb_board_data musb_board_data = {
51 .interface_type = MUSB_INTERFACE_UTMI, 135 .interface_type = MUSB_INTERFACE_UTMI,
52 .mode = MUSB_PERIPHERAL, 136 .mode = MUSB_PERIPHERAL,
@@ -56,7 +140,7 @@ static struct omap_musb_board_data musb_board_data = {
56static struct omap2_hsmmc_info mmc[] = { 140static struct omap2_hsmmc_info mmc[] = {
57 { 141 {
58 .mmc = 1, 142 .mmc = 1,
59 .wires = 8, 143 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
60 .gpio_wp = -EINVAL, 144 .gpio_wp = -EINVAL,
61 }, 145 },
62 {} /* Terminator */ 146 {} /* Terminator */
@@ -67,10 +151,6 @@ static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = {
67 .supply = "vmmc", 151 .supply = "vmmc",
68 .dev_name = "mmci-omap-hs.0", 152 .dev_name = "mmci-omap-hs.0",
69 }, 153 },
70 {
71 .supply = "vmmc",
72 .dev_name = "mmci-omap-hs.1",
73 },
74}; 154};
75 155
76static int omap4_twl6030_hsmmc_late_init(struct device *dev) 156static int omap4_twl6030_hsmmc_late_init(struct device *dev)
@@ -80,16 +160,32 @@ static int omap4_twl6030_hsmmc_late_init(struct device *dev)
80 struct platform_device, dev); 160 struct platform_device, dev);
81 struct omap_mmc_platform_data *pdata = dev->platform_data; 161 struct omap_mmc_platform_data *pdata = dev->platform_data;
82 162
163 if (!pdata) {
164 dev_err(dev, "%s: NULL platform data\n", __func__);
165 return -EINVAL;
166 }
83 /* Setting MMC1 Card detect Irq */ 167 /* Setting MMC1 Card detect Irq */
84 if (pdev->id == 0) 168 if (pdev->id == 0) {
85 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE + 169 ret = twl6030_mmc_card_detect_config();
86 MMCDETECT_INTR_OFFSET; 170 if (ret)
171 dev_err(dev, "%s: Error card detect config(%d)\n",
172 __func__, ret);
173 else
174 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
175 }
87 return ret; 176 return ret;
88} 177}
89 178
90static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) 179static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
91{ 180{
92 struct omap_mmc_platform_data *pdata = dev->platform_data; 181 struct omap_mmc_platform_data *pdata;
182
183 /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
184 if (!dev) {
185 pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n");
186 return;
187 }
188 pdata = dev->platform_data;
93 189
94 pdata->init = omap4_twl6030_hsmmc_late_init; 190 pdata->init = omap4_twl6030_hsmmc_late_init;
95} 191}
@@ -156,7 +252,7 @@ static struct regulator_init_data omap4_panda_vmmc = {
156 | REGULATOR_CHANGE_MODE 252 | REGULATOR_CHANGE_MODE
157 | REGULATOR_CHANGE_STATUS, 253 | REGULATOR_CHANGE_STATUS,
158 }, 254 },
159 .num_consumer_supplies = 2, 255 .num_consumer_supplies = 1,
160 .consumer_supplies = omap4_panda_vmmc_supply, 256 .consumer_supplies = omap4_panda_vmmc_supply,
161}; 257};
162 258
@@ -274,13 +370,13 @@ static int __init omap4_panda_i2c_init(void)
274} 370}
275static void __init omap4_panda_init(void) 371static void __init omap4_panda_init(void)
276{ 372{
277 int status;
278
279 omap4_panda_i2c_init(); 373 omap4_panda_i2c_init();
374 platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices));
280 omap_serial_init(); 375 omap_serial_init();
281 omap4_twl6030_hsmmc_init(mmc); 376 omap4_twl6030_hsmmc_init(mmc);
282 /* OMAP4 Panda uses internal transceiver so register nop transceiver */ 377 /* OMAP4 Panda uses internal transceiver so register nop transceiver */
283 usb_nop_xceiv_register(); 378 usb_nop_xceiv_register();
379 omap4_ehci_init();
284 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */ 380 /* FIXME: allow multi-omap to boot until musb is updated for omap4 */
285 if (!cpu_is_omap44xx()) 381 if (!cpu_is_omap44xx())
286 usb_musb_init(&musb_board_data); 382 usb_musb_init(&musb_board_data);
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 5e528ca015a1..7053bc0b46db 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -32,6 +32,7 @@
32#include <linux/mtd/mtd.h> 32#include <linux/mtd/mtd.h>
33#include <linux/mtd/nand.h> 33#include <linux/mtd/nand.h>
34#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
35#include <linux/mmc/host.h>
35 36
36#include <asm/mach-types.h> 37#include <asm/mach-types.h>
37#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
@@ -303,13 +304,13 @@ static void __init overo_flash_init(void)
303static struct omap2_hsmmc_info mmc[] = { 304static struct omap2_hsmmc_info mmc[] = {
304 { 305 {
305 .mmc = 1, 306 .mmc = 1,
306 .wires = 4, 307 .caps = MMC_CAP_4_BIT_DATA,
307 .gpio_cd = -EINVAL, 308 .gpio_cd = -EINVAL,
308 .gpio_wp = -EINVAL, 309 .gpio_wp = -EINVAL,
309 }, 310 },
310 { 311 {
311 .mmc = 2, 312 .mmc = 2,
312 .wires = 4, 313 .caps = MMC_CAP_4_BIT_DATA,
313 .gpio_cd = -EINVAL, 314 .gpio_cd = -EINVAL,
314 .gpio_wp = -EINVAL, 315 .gpio_wp = -EINVAL,
315 .transceiver = true, 316 .transceiver = true,
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 9a5eb87425fc..3fec4d62a91a 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>
@@ -23,6 +23,7 @@
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/gpio_keys.h> 24#include <linux/gpio_keys.h>
25#include <linux/mmc/host.h> 25#include <linux/mmc/host.h>
26#include <sound/tlv320aic3x.h>
26 27
27#include <plat/mcspi.h> 28#include <plat/mcspi.h>
28#include <plat/board.h> 29#include <plat/board.h>
@@ -32,6 +33,8 @@
32#include <plat/onenand.h> 33#include <plat/onenand.h>
33#include <plat/gpmc-smc91x.h> 34#include <plat/gpmc-smc91x.h>
34 35
36#include <mach/board-rx51.h>
37
35#include <sound/tlv320aic3x.h> 38#include <sound/tlv320aic3x.h>
36#include <sound/tpa6130a2-plat.h> 39#include <sound/tpa6130a2-plat.h>
37 40
@@ -104,6 +107,10 @@ static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
104 }, 107 },
105}; 108};
106 109
110static struct platform_device rx51_charger_device = {
111 .name = "isp1704_charger",
112};
113
107#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 114#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
108 115
109#define RX51_GPIO_CAMERA_LENS_COVER 110 116#define RX51_GPIO_CAMERA_LENS_COVER 110
@@ -184,7 +191,7 @@ static void __init rx51_add_gpio_keys(void)
184} 191}
185#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */ 192#endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
186 193
187static int board_keymap[] = { 194static uint32_t board_keymap[] = {
188 /* 195 /*
189 * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row 196 * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
190 * connected to the ground" matrix state. 197 * connected to the ground" matrix state.
@@ -302,7 +309,7 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
302 { 309 {
303 .name = "external", 310 .name = "external",
304 .mmc = 1, 311 .mmc = 1,
305 .wires = 4, 312 .caps = MMC_CAP_4_BIT_DATA,
306 .cover_only = true, 313 .cover_only = true,
307 .gpio_cd = 160, 314 .gpio_cd = 160,
308 .gpio_wp = -EINVAL, 315 .gpio_wp = -EINVAL,
@@ -311,7 +318,8 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
311 { 318 {
312 .name = "internal", 319 .name = "internal",
313 .mmc = 2, 320 .mmc = 2,
314 .wires = 8, /* See also rx51_mmc2_remux */ 321 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
322 /* See also rx51_mmc2_remux */
315 .gpio_cd = -EINVAL, 323 .gpio_cd = -EINVAL,
316 .gpio_wp = -EINVAL, 324 .gpio_wp = -EINVAL,
317 .nonremovable = true, 325 .nonremovable = true,
@@ -689,7 +697,6 @@ static struct twl4030_power_data rx51_t2scripts_data __initdata = {
689}; 697};
690 698
691 699
692
693static struct twl4030_platform_data rx51_twldata __initdata = { 700static struct twl4030_platform_data rx51_twldata __initdata = {
694 .irq_base = TWL4030_IRQ_BASE, 701 .irq_base = TWL4030_IRQ_BASE,
695 .irq_end = TWL4030_IRQ_END, 702 .irq_end = TWL4030_IRQ_END,
@@ -710,10 +717,6 @@ static struct twl4030_platform_data rx51_twldata __initdata = {
710 .vio = &rx51_vio, 717 .vio = &rx51_vio,
711}; 718};
712 719
713static struct aic3x_pdata rx51_aic3x_data __initdata = {
714 .gpio_reset = 60,
715};
716
717static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata = { 720static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata = {
718 .id = TPA6130A2, 721 .id = TPA6130A2,
719 .power_gpio = 98, 722 .power_gpio = 98,
@@ -728,6 +731,17 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
728 }, 731 },
729}; 732};
730 733
734/* Audio setup data */
735static struct aic3x_setup_data rx51_aic34_setup = {
736 .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
737 .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
738};
739
740static struct aic3x_pdata rx51_aic3x_data = {
741 .setup = &rx51_aic34_setup,
742 .gpio_reset = 60,
743};
744
731static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = { 745static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
732 { 746 {
733 I2C_BOARD_INFO("tlv320aic3x", 0x18), 747 I2C_BOARD_INFO("tlv320aic3x", 0x18),
@@ -909,5 +923,6 @@ void __init rx51_peripherals_init(void)
909 spi_register_board_info(rx51_peripherals_spi_board_info, 923 spi_register_board_info(rx51_peripherals_spi_board_info,
910 ARRAY_SIZE(rx51_peripherals_spi_board_info)); 924 ARRAY_SIZE(rx51_peripherals_spi_board_info));
911 omap2_hsmmc_init(mmc); 925 omap2_hsmmc_init(mmc);
926 platform_device_register(&rx51_charger_device);
912} 927}
913 928
diff --git a/arch/arm/mach-omap2/board-rx51-sdram.c b/arch/arm/mach-omap2/board-rx51-sdram.c
index f392844195d2..a43b2c5c838b 100644
--- a/arch/arm/mach-omap2/board-rx51-sdram.c
+++ b/arch/arm/mach-omap2/board-rx51-sdram.c
@@ -43,7 +43,7 @@ struct sdram_timings {
43 u32 tWTR; 43 u32 tWTR;
44}; 44};
45 45
46struct omap_sdrc_params rx51_sdrc_params[4]; 46static struct omap_sdrc_params rx51_sdrc_params[4];
47 47
48static const struct sdram_timings rx51_timings[] = { 48static const struct sdram_timings rx51_timings[] = {
49 { 49 {
diff --git a/arch/arm/mach-omap2/board-rx51-video.c b/arch/arm/mach-omap2/board-rx51-video.c
index 5a1005ba9815..85503fed4e13 100644
--- a/arch/arm/mach-omap2/board-rx51-video.c
+++ b/arch/arm/mach-omap2/board-rx51-video.c
@@ -20,6 +20,8 @@
20#include <plat/vram.h> 20#include <plat/vram.h>
21#include <plat/mcspi.h> 21#include <plat/mcspi.h>
22 22
23#include <mach/board-rx51.h>
24
23#include "mux.h" 25#include "mux.h"
24 26
25#define RX51_LCD_RESET_GPIO 90 27#define RX51_LCD_RESET_GPIO 90
diff --git a/arch/arm/mach-omap2/board-zoom-debugboard.c b/arch/arm/mach-omap2/board-zoom-debugboard.c
index 1d7f827b0408..007ebdc6c993 100644
--- a/arch/arm/mach-omap2/board-zoom-debugboard.c
+++ b/arch/arm/mach-omap2/board-zoom-debugboard.c
@@ -16,6 +16,8 @@
16 16
17#include <plat/gpmc.h> 17#include <plat/gpmc.h>
18 18
19#include <mach/board-zoom.h>
20
19#define ZOOM_SMSC911X_CS 7 21#define ZOOM_SMSC911X_CS 7
20#define ZOOM_SMSC911X_GPIO 158 22#define ZOOM_SMSC911X_GPIO 158
21#define ZOOM_QUADUART_CS 3 23#define ZOOM_QUADUART_CS 3
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 6b3984964cc5..86c9b2102952 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -16,6 +16,9 @@
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>
21#include <linux/mmc/host.h>
19 22
20#include <asm/mach-types.h> 23#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
@@ -24,11 +27,16 @@
24#include <plat/common.h> 27#include <plat/common.h>
25#include <plat/usb.h> 28#include <plat/usb.h>
26 29
30#include <mach/board-zoom.h>
31
27#include "mux.h" 32#include "mux.h"
28#include "hsmmc.h" 33#include "hsmmc.h"
29 34
35#define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
36#define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
37
30/* Zoom2 has Qwerty keyboard*/ 38/* Zoom2 has Qwerty keyboard*/
31static int board_keymap[] = { 39static uint32_t board_keymap[] = {
32 KEY(0, 0, KEY_E), 40 KEY(0, 0, KEY_E),
33 KEY(0, 1, KEY_R), 41 KEY(0, 1, KEY_R),
34 KEY(0, 2, KEY_T), 42 KEY(0, 2, KEY_T),
@@ -106,6 +114,11 @@ static struct regulator_consumer_supply zoom_vmmc2_supply = {
106 .supply = "vmmc", 114 .supply = "vmmc",
107}; 115};
108 116
117static struct regulator_consumer_supply zoom_vmmc3_supply = {
118 .supply = "vmmc",
119 .dev_name = "mmci-omap-hs.2",
120};
121
109/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */ 122/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
110static struct regulator_init_data zoom_vmmc1 = { 123static struct regulator_init_data zoom_vmmc1 = {
111 .constraints = { 124 .constraints = {
@@ -151,23 +164,63 @@ static struct regulator_init_data zoom_vsim = {
151 .consumer_supplies = &zoom_vsim_supply, 164 .consumer_supplies = &zoom_vsim_supply,
152}; 165};
153 166
167static struct regulator_init_data zoom_vmmc3 = {
168 .constraints = {
169 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
170 },
171 .num_consumer_supplies = 1,
172 .consumer_supplies = &zoom_vmmc3_supply,
173};
174
175static struct fixed_voltage_config zoom_vwlan = {
176 .supply_name = "vwl1271",
177 .microvolts = 1800000, /* 1.8V */
178 .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
179 .startup_delay = 70000, /* 70msec */
180 .enable_high = 1,
181 .enabled_at_boot = 0,
182 .init_data = &zoom_vmmc3,
183};
184
185static struct platform_device omap_vwlan_device = {
186 .name = "reg-fixed-voltage",
187 .id = 1,
188 .dev = {
189 .platform_data = &zoom_vwlan,
190 },
191};
192
193struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
194 .irq = OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO),
195 /* ZOOM ref clock is 26 MHz */
196 .board_ref_clock = 1,
197};
198
154static struct omap2_hsmmc_info mmc[] __initdata = { 199static struct omap2_hsmmc_info mmc[] __initdata = {
155 { 200 {
156 .name = "external", 201 .name = "external",
157 .mmc = 1, 202 .mmc = 1,
158 .wires = 4, 203 .caps = MMC_CAP_4_BIT_DATA,
159 .gpio_wp = -EINVAL, 204 .gpio_wp = -EINVAL,
160 .power_saving = true, 205 .power_saving = true,
161 }, 206 },
162 { 207 {
163 .name = "internal", 208 .name = "internal",
164 .mmc = 2, 209 .mmc = 2,
165 .wires = 8, 210 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
166 .gpio_cd = -EINVAL, 211 .gpio_cd = -EINVAL,
167 .gpio_wp = -EINVAL, 212 .gpio_wp = -EINVAL,
168 .nonremovable = true, 213 .nonremovable = true,
169 .power_saving = true, 214 .power_saving = true,
170 }, 215 },
216 {
217 .name = "wl1271",
218 .mmc = 3,
219 .caps = MMC_CAP_4_BIT_DATA,
220 .gpio_wp = -EINVAL,
221 .gpio_cd = -EINVAL,
222 .nonremovable = true,
223 },
171 {} /* Terminator */ 224 {} /* Terminator */
172}; 225};
173 226
@@ -188,6 +241,11 @@ static int zoom_twl_gpio_setup(struct device *dev,
188 return 0; 241 return 0;
189} 242}
190 243
244/* EXTMUTE callback function */
245void zoom2_set_hs_extmute(int mute)
246{
247 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
248}
191 249
192static int zoom_batt_table[] = { 250static int zoom_batt_table[] = {
193/* 0 C*/ 251/* 0 C*/
@@ -257,6 +315,11 @@ static struct i2c_board_info __initdata zoom_i2c_boardinfo[] = {
257 315
258static int __init omap_i2c_init(void) 316static int __init omap_i2c_init(void)
259{ 317{
318 if (machine_is_omap_zoom2()) {
319 zoom_audio_data.ramp_delay_value = 3; /* 161 ms */
320 zoom_audio_data.hs_extmute = 1;
321 zoom_audio_data.set_hs_extmute = zoom2_set_hs_extmute;
322 }
260 omap_register_i2c_bus(1, 2400, zoom_i2c_boardinfo, 323 omap_register_i2c_bus(1, 2400, zoom_i2c_boardinfo,
261 ARRAY_SIZE(zoom_i2c_boardinfo)); 324 ARRAY_SIZE(zoom_i2c_boardinfo));
262 omap_register_i2c_bus(2, 400, NULL, 0); 325 omap_register_i2c_bus(2, 400, NULL, 0);
@@ -279,7 +342,12 @@ static void enable_board_wakeup_source(void)
279 342
280void __init zoom_peripherals_init(void) 343void __init zoom_peripherals_init(void)
281{ 344{
345 if (wl12xx_set_platform_data(&omap_zoom_wlan_data))
346 pr_err("error setting wl12xx data\n");
347
282 omap_i2c_init(); 348 omap_i2c_init();
349 platform_device_register(&omap_vwlan_device);
283 usb_musb_init(&musb_board_data); 350 usb_musb_init(&musb_board_data);
284 enable_board_wakeup_source(); 351 enable_board_wakeup_source();
352 omap_serial_init();
285} 353}
diff --git a/arch/arm/mach-omap2/board-zoom2.c b/arch/arm/mach-omap2/board-zoom2.c
index 24bbd0def64f..2992a9f3a585 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/i2c/twl.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>
@@ -23,6 +24,7 @@
23 24
24#include <mach/board-zoom.h> 25#include <mach/board-zoom.h>
25 26
27#include "board-flash.h"
26#include "mux.h" 28#include "mux.h"
27#include "sdram-micron-mt46h32m32lf-6.h" 29#include "sdram-micron-mt46h32m32lf-6.h"
28 30
@@ -34,41 +36,6 @@ static void __init omap_zoom2_init_irq(void)
34 omap_gpio_init(); 36 omap_gpio_init();
35} 37}
36 38
37/* REVISIT: These audio entries can be removed once MFD code is merged */
38#if 0
39
40static struct twl4030_madc_platform_data zoom2_madc_data = {
41 .irq_line = 1,
42};
43
44static struct twl4030_codec_audio_data zoom2_audio_data = {
45 .audio_mclk = 26000000,
46};
47
48static struct twl4030_codec_data zoom2_codec_data = {
49 .audio_mclk = 26000000,
50 .audio = &zoom2_audio_data,
51};
52
53static struct twl4030_platform_data zoom2_twldata = {
54 .irq_base = TWL4030_IRQ_BASE,
55 .irq_end = TWL4030_IRQ_END,
56
57 /* platform_data for children goes here */
58 .bci = &zoom2_bci_data,
59 .madc = &zoom2_madc_data,
60 .usb = &zoom2_usb_data,
61 .gpio = &zoom2_gpio_data,
62 .keypad = &zoom2_kp_twl4030_data,
63 .codec = &zoom2_codec_data,
64 .vmmc1 = &zoom2_vmmc1,
65 .vmmc2 = &zoom2_vmmc2,
66 .vsim = &zoom2_vsim,
67
68};
69
70#endif
71
72#ifdef CONFIG_OMAP_MUX 39#ifdef CONFIG_OMAP_MUX
73static struct omap_board_mux board_mux[] __initdata = { 40static struct omap_board_mux board_mux[] __initdata = {
74 /* WLAN IRQ - GPIO 162 */ 41 /* WLAN IRQ - GPIO 162 */
diff --git a/arch/arm/mach-omap2/board-zoom3.c b/arch/arm/mach-omap2/board-zoom3.c
index b2bb3ff971ac..5adde12c0395 100644
--- a/arch/arm/mach-omap2/board-zoom3.c
+++ b/arch/arm/mach-omap2/board-zoom3.c
@@ -22,6 +22,7 @@
22#include <plat/board.h> 22#include <plat/board.h>
23#include <plat/usb.h> 23#include <plat/usb.h>
24 24
25#include "board-flash.h"
25#include "mux.h" 26#include "mux.h"
26#include "sdram-hynix-h8mbx00u0mer-0em.h" 27#include "sdram-hynix-h8mbx00u0mer-0em.h"
27 28
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 605f531783a8..b5babf5440e4 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -395,7 +395,7 @@ void omap2_clk_disable_unused(struct clk *clk)
395 if ((regval32 & (1 << clk->enable_bit)) == v) 395 if ((regval32 & (1 << clk->enable_bit)) == v)
396 return; 396 return;
397 397
398 printk(KERN_DEBUG "Disabling unused clock \"%s\"\n", clk->name); 398 pr_debug("Disabling unused clock \"%s\"\n", clk->name);
399 if (cpu_is_omap34xx()) { 399 if (cpu_is_omap34xx()) {
400 omap2_clk_enable(clk); 400 omap2_clk_enable(clk);
401 omap2_clk_disable(clk); 401 omap2_clk_disable(clk);
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index 37d65d62ed8f..21f856252ad8 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -27,6 +27,7 @@
27#include "prm-regbits-24xx.h" 27#include "prm-regbits-24xx.h"
28#include "cm-regbits-24xx.h" 28#include "cm-regbits-24xx.h"
29#include "sdrc.h" 29#include "sdrc.h"
30#include "control.h"
30 31
31#define OMAP_CM_REGADDR OMAP2420_CM_REGADDR 32#define OMAP_CM_REGADDR OMAP2420_CM_REGADDR
32 33
@@ -89,6 +90,12 @@ static struct clk alt_ck = { /* Typical 54M or 48M, may not exist */
89 .clkdm_name = "wkup_clkdm", 90 .clkdm_name = "wkup_clkdm",
90}; 91};
91 92
93/* Optional external clock input for McBSP CLKS */
94static struct clk mcbsp_clks = {
95 .name = "mcbsp_clks",
96 .ops = &clkops_null,
97};
98
92/* 99/*
93 * Analog domain root source clocks 100 * Analog domain root source clocks
94 */ 101 */
@@ -1135,14 +1142,34 @@ static struct clk mcbsp1_ick = {
1135 .recalc = &followparent_recalc, 1142 .recalc = &followparent_recalc,
1136}; 1143};
1137 1144
1145static const struct clksel_rate common_mcbsp_96m_rates[] = {
1146 { .div = 1, .val = 0, .flags = RATE_IN_24XX },
1147 { .div = 0 }
1148};
1149
1150static const struct clksel_rate common_mcbsp_mcbsp_rates[] = {
1151 { .div = 1, .val = 1, .flags = RATE_IN_24XX },
1152 { .div = 0 }
1153};
1154
1155static const struct clksel mcbsp_fck_clksel[] = {
1156 { .parent = &func_96m_ck, .rates = common_mcbsp_96m_rates },
1157 { .parent = &mcbsp_clks, .rates = common_mcbsp_mcbsp_rates },
1158 { .parent = NULL }
1159};
1160
1138static struct clk mcbsp1_fck = { 1161static struct clk mcbsp1_fck = {
1139 .name = "mcbsp1_fck", 1162 .name = "mcbsp1_fck",
1140 .ops = &clkops_omap2_dflt_wait, 1163 .ops = &clkops_omap2_dflt_wait,
1141 .parent = &func_96m_ck, 1164 .parent = &func_96m_ck,
1165 .init = &omap2_init_clksel_parent,
1142 .clkdm_name = "core_l4_clkdm", 1166 .clkdm_name = "core_l4_clkdm",
1143 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1167 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1144 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT, 1168 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT,
1145 .recalc = &followparent_recalc, 1169 .clksel_reg = OMAP242X_CTRL_REGADDR(OMAP2_CONTROL_DEVCONF0),
1170 .clksel_mask = OMAP2_MCBSP1_CLKS_MASK,
1171 .clksel = mcbsp_fck_clksel,
1172 .recalc = &omap2_clksel_recalc,
1146}; 1173};
1147 1174
1148static struct clk mcbsp2_ick = { 1175static struct clk mcbsp2_ick = {
@@ -1159,10 +1186,14 @@ static struct clk mcbsp2_fck = {
1159 .name = "mcbsp2_fck", 1186 .name = "mcbsp2_fck",
1160 .ops = &clkops_omap2_dflt_wait, 1187 .ops = &clkops_omap2_dflt_wait,
1161 .parent = &func_96m_ck, 1188 .parent = &func_96m_ck,
1189 .init = &omap2_init_clksel_parent,
1162 .clkdm_name = "core_l4_clkdm", 1190 .clkdm_name = "core_l4_clkdm",
1163 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1191 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1164 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT, 1192 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT,
1165 .recalc = &followparent_recalc, 1193 .clksel_reg = OMAP242X_CTRL_REGADDR(OMAP2_CONTROL_DEVCONF0),
1194 .clksel_mask = OMAP2_MCBSP2_CLKS_MASK,
1195 .clksel = mcbsp_fck_clksel,
1196 .recalc = &omap2_clksel_recalc,
1166}; 1197};
1167 1198
1168static struct clk mcspi1_ick = { 1199static struct clk mcspi1_ick = {
@@ -1721,6 +1752,9 @@ static struct omap_clk omap2420_clks[] = {
1721 CLK(NULL, "osc_ck", &osc_ck, CK_242X), 1752 CLK(NULL, "osc_ck", &osc_ck, CK_242X),
1722 CLK(NULL, "sys_ck", &sys_ck, CK_242X), 1753 CLK(NULL, "sys_ck", &sys_ck, CK_242X),
1723 CLK(NULL, "alt_ck", &alt_ck, CK_242X), 1754 CLK(NULL, "alt_ck", &alt_ck, CK_242X),
1755 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_242X),
1756 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_242X),
1757 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_242X),
1724 /* internal analog sources */ 1758 /* internal analog sources */
1725 CLK(NULL, "dpll_ck", &dpll_ck, CK_242X), 1759 CLK(NULL, "dpll_ck", &dpll_ck, CK_242X),
1726 CLK(NULL, "apll96_ck", &apll96_ck, CK_242X), 1760 CLK(NULL, "apll96_ck", &apll96_ck, CK_242X),
@@ -1728,6 +1762,8 @@ static struct omap_clk omap2420_clks[] = {
1728 /* internal prcm root sources */ 1762 /* internal prcm root sources */
1729 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_242X), 1763 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_242X),
1730 CLK(NULL, "core_ck", &core_ck, CK_242X), 1764 CLK(NULL, "core_ck", &core_ck, CK_242X),
1765 CLK("omap-mcbsp.1", "prcm_fck", &func_96m_ck, CK_242X),
1766 CLK("omap-mcbsp.2", "prcm_fck", &func_96m_ck, CK_242X),
1731 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_242X), 1767 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_242X),
1732 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_242X), 1768 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_242X),
1733 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_242X), 1769 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_242X),
@@ -1838,7 +1874,7 @@ static struct omap_clk omap2420_clks[] = {
1838 CLK(NULL, "des_ick", &des_ick, CK_242X), 1874 CLK(NULL, "des_ick", &des_ick, CK_242X),
1839 CLK("omap-sham", "ick", &sha_ick, CK_242X), 1875 CLK("omap-sham", "ick", &sha_ick, CK_242X),
1840 CLK("omap_rng", "ick", &rng_ick, CK_242X), 1876 CLK("omap_rng", "ick", &rng_ick, CK_242X),
1841 CLK(NULL, "aes_ick", &aes_ick, CK_242X), 1877 CLK("omap-aes", "ick", &aes_ick, CK_242X),
1842 CLK(NULL, "pka_ick", &pka_ick, CK_242X), 1878 CLK(NULL, "pka_ick", &pka_ick, CK_242X),
1843 CLK(NULL, "usb_fck", &usb_fck, CK_242X), 1879 CLK(NULL, "usb_fck", &usb_fck, CK_242X),
1844 CLK("musb_hdrc", "fck", &osc_ck, CK_242X), 1880 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..e32afcbdfb88 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -27,6 +27,7 @@
27#include "prm-regbits-24xx.h" 27#include "prm-regbits-24xx.h"
28#include "cm-regbits-24xx.h" 28#include "cm-regbits-24xx.h"
29#include "sdrc.h" 29#include "sdrc.h"
30#include "control.h"
30 31
31#define OMAP_CM_REGADDR OMAP2430_CM_REGADDR 32#define OMAP_CM_REGADDR OMAP2430_CM_REGADDR
32 33
@@ -89,6 +90,12 @@ static struct clk alt_ck = { /* Typical 54M or 48M, may not exist */
89 .clkdm_name = "wkup_clkdm", 90 .clkdm_name = "wkup_clkdm",
90}; 91};
91 92
93/* Optional external clock input for McBSP CLKS */
94static struct clk mcbsp_clks = {
95 .name = "mcbsp_clks",
96 .ops = &clkops_null,
97};
98
92/* 99/*
93 * Analog domain root source clocks 100 * Analog domain root source clocks
94 */ 101 */
@@ -1123,14 +1130,34 @@ static struct clk mcbsp1_ick = {
1123 .recalc = &followparent_recalc, 1130 .recalc = &followparent_recalc,
1124}; 1131};
1125 1132
1133static const struct clksel_rate common_mcbsp_96m_rates[] = {
1134 { .div = 1, .val = 0, .flags = RATE_IN_24XX },
1135 { .div = 0 }
1136};
1137
1138static const struct clksel_rate common_mcbsp_mcbsp_rates[] = {
1139 { .div = 1, .val = 1, .flags = RATE_IN_24XX },
1140 { .div = 0 }
1141};
1142
1143static const struct clksel mcbsp_fck_clksel[] = {
1144 { .parent = &func_96m_ck, .rates = common_mcbsp_96m_rates },
1145 { .parent = &mcbsp_clks, .rates = common_mcbsp_mcbsp_rates },
1146 { .parent = NULL }
1147};
1148
1126static struct clk mcbsp1_fck = { 1149static struct clk mcbsp1_fck = {
1127 .name = "mcbsp1_fck", 1150 .name = "mcbsp1_fck",
1128 .ops = &clkops_omap2_dflt_wait, 1151 .ops = &clkops_omap2_dflt_wait,
1129 .parent = &func_96m_ck, 1152 .parent = &func_96m_ck,
1153 .init = &omap2_init_clksel_parent,
1130 .clkdm_name = "core_l4_clkdm", 1154 .clkdm_name = "core_l4_clkdm",
1131 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1155 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1132 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT, 1156 .enable_bit = OMAP24XX_EN_MCBSP1_SHIFT,
1133 .recalc = &followparent_recalc, 1157 .clksel_reg = OMAP243X_CTRL_REGADDR(OMAP2_CONTROL_DEVCONF0),
1158 .clksel_mask = OMAP2_MCBSP1_CLKS_MASK,
1159 .clksel = mcbsp_fck_clksel,
1160 .recalc = &omap2_clksel_recalc,
1134}; 1161};
1135 1162
1136static struct clk mcbsp2_ick = { 1163static struct clk mcbsp2_ick = {
@@ -1147,10 +1174,14 @@ static struct clk mcbsp2_fck = {
1147 .name = "mcbsp2_fck", 1174 .name = "mcbsp2_fck",
1148 .ops = &clkops_omap2_dflt_wait, 1175 .ops = &clkops_omap2_dflt_wait,
1149 .parent = &func_96m_ck, 1176 .parent = &func_96m_ck,
1177 .init = &omap2_init_clksel_parent,
1150 .clkdm_name = "core_l4_clkdm", 1178 .clkdm_name = "core_l4_clkdm",
1151 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1), 1179 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1152 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT, 1180 .enable_bit = OMAP24XX_EN_MCBSP2_SHIFT,
1153 .recalc = &followparent_recalc, 1181 .clksel_reg = OMAP243X_CTRL_REGADDR(OMAP2_CONTROL_DEVCONF0),
1182 .clksel_mask = OMAP2_MCBSP2_CLKS_MASK,
1183 .clksel = mcbsp_fck_clksel,
1184 .recalc = &omap2_clksel_recalc,
1154}; 1185};
1155 1186
1156static struct clk mcbsp3_ick = { 1187static struct clk mcbsp3_ick = {
@@ -1167,10 +1198,14 @@ static struct clk mcbsp3_fck = {
1167 .name = "mcbsp3_fck", 1198 .name = "mcbsp3_fck",
1168 .ops = &clkops_omap2_dflt_wait, 1199 .ops = &clkops_omap2_dflt_wait,
1169 .parent = &func_96m_ck, 1200 .parent = &func_96m_ck,
1201 .init = &omap2_init_clksel_parent,
1170 .clkdm_name = "core_l4_clkdm", 1202 .clkdm_name = "core_l4_clkdm",
1171 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1203 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1172 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT, 1204 .enable_bit = OMAP2430_EN_MCBSP3_SHIFT,
1173 .recalc = &followparent_recalc, 1205 .clksel_reg = OMAP243X_CTRL_REGADDR(OMAP243X_CONTROL_DEVCONF1),
1206 .clksel_mask = OMAP2_MCBSP3_CLKS_MASK,
1207 .clksel = mcbsp_fck_clksel,
1208 .recalc = &omap2_clksel_recalc,
1174}; 1209};
1175 1210
1176static struct clk mcbsp4_ick = { 1211static struct clk mcbsp4_ick = {
@@ -1187,10 +1222,14 @@ static struct clk mcbsp4_fck = {
1187 .name = "mcbsp4_fck", 1222 .name = "mcbsp4_fck",
1188 .ops = &clkops_omap2_dflt_wait, 1223 .ops = &clkops_omap2_dflt_wait,
1189 .parent = &func_96m_ck, 1224 .parent = &func_96m_ck,
1225 .init = &omap2_init_clksel_parent,
1190 .clkdm_name = "core_l4_clkdm", 1226 .clkdm_name = "core_l4_clkdm",
1191 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1227 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1192 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT, 1228 .enable_bit = OMAP2430_EN_MCBSP4_SHIFT,
1193 .recalc = &followparent_recalc, 1229 .clksel_reg = OMAP243X_CTRL_REGADDR(OMAP243X_CONTROL_DEVCONF1),
1230 .clksel_mask = OMAP2_MCBSP4_CLKS_MASK,
1231 .clksel = mcbsp_fck_clksel,
1232 .recalc = &omap2_clksel_recalc,
1194}; 1233};
1195 1234
1196static struct clk mcbsp5_ick = { 1235static struct clk mcbsp5_ick = {
@@ -1207,10 +1246,14 @@ static struct clk mcbsp5_fck = {
1207 .name = "mcbsp5_fck", 1246 .name = "mcbsp5_fck",
1208 .ops = &clkops_omap2_dflt_wait, 1247 .ops = &clkops_omap2_dflt_wait,
1209 .parent = &func_96m_ck, 1248 .parent = &func_96m_ck,
1249 .init = &omap2_init_clksel_parent,
1210 .clkdm_name = "core_l4_clkdm", 1250 .clkdm_name = "core_l4_clkdm",
1211 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2), 1251 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP24XX_CM_FCLKEN2),
1212 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT, 1252 .enable_bit = OMAP2430_EN_MCBSP5_SHIFT,
1213 .recalc = &followparent_recalc, 1253 .clksel_reg = OMAP243X_CTRL_REGADDR(OMAP243X_CONTROL_DEVCONF1),
1254 .clksel_mask = OMAP2_MCBSP5_CLKS_MASK,
1255 .clksel = mcbsp_fck_clksel,
1256 .recalc = &omap2_clksel_recalc,
1214}; 1257};
1215 1258
1216static struct clk mcspi1_ick = { 1259static struct clk mcspi1_ick = {
@@ -1808,6 +1851,12 @@ static struct omap_clk omap2430_clks[] = {
1808 CLK(NULL, "osc_ck", &osc_ck, CK_243X), 1851 CLK(NULL, "osc_ck", &osc_ck, CK_243X),
1809 CLK(NULL, "sys_ck", &sys_ck, CK_243X), 1852 CLK(NULL, "sys_ck", &sys_ck, CK_243X),
1810 CLK(NULL, "alt_ck", &alt_ck, CK_243X), 1853 CLK(NULL, "alt_ck", &alt_ck, CK_243X),
1854 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_243X),
1855 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_243X),
1856 CLK("omap-mcbsp.3", "pad_fck", &mcbsp_clks, CK_243X),
1857 CLK("omap-mcbsp.4", "pad_fck", &mcbsp_clks, CK_243X),
1858 CLK("omap-mcbsp.5", "pad_fck", &mcbsp_clks, CK_243X),
1859 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_243X),
1811 /* internal analog sources */ 1860 /* internal analog sources */
1812 CLK(NULL, "dpll_ck", &dpll_ck, CK_243X), 1861 CLK(NULL, "dpll_ck", &dpll_ck, CK_243X),
1813 CLK(NULL, "apll96_ck", &apll96_ck, CK_243X), 1862 CLK(NULL, "apll96_ck", &apll96_ck, CK_243X),
@@ -1815,6 +1864,11 @@ static struct omap_clk omap2430_clks[] = {
1815 /* internal prcm root sources */ 1864 /* internal prcm root sources */
1816 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_243X), 1865 CLK(NULL, "func_54m_ck", &func_54m_ck, CK_243X),
1817 CLK(NULL, "core_ck", &core_ck, CK_243X), 1866 CLK(NULL, "core_ck", &core_ck, CK_243X),
1867 CLK("omap-mcbsp.1", "prcm_fck", &func_96m_ck, CK_243X),
1868 CLK("omap-mcbsp.2", "prcm_fck", &func_96m_ck, CK_243X),
1869 CLK("omap-mcbsp.3", "prcm_fck", &func_96m_ck, CK_243X),
1870 CLK("omap-mcbsp.4", "prcm_fck", &func_96m_ck, CK_243X),
1871 CLK("omap-mcbsp.5", "prcm_fck", &func_96m_ck, CK_243X),
1818 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_243X), 1872 CLK(NULL, "func_96m_ck", &func_96m_ck, CK_243X),
1819 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_243X), 1873 CLK(NULL, "func_48m_ck", &func_48m_ck, CK_243X),
1820 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_243X), 1874 CLK(NULL, "func_12m_ck", &func_12m_ck, CK_243X),
@@ -1926,7 +1980,7 @@ static struct omap_clk omap2430_clks[] = {
1926 CLK(NULL, "des_ick", &des_ick, CK_243X), 1980 CLK(NULL, "des_ick", &des_ick, CK_243X),
1927 CLK("omap-sham", "ick", &sha_ick, CK_243X), 1981 CLK("omap-sham", "ick", &sha_ick, CK_243X),
1928 CLK("omap_rng", "ick", &rng_ick, CK_243X), 1982 CLK("omap_rng", "ick", &rng_ick, CK_243X),
1929 CLK(NULL, "aes_ick", &aes_ick, CK_243X), 1983 CLK("omap-aes", "ick", &aes_ick, CK_243X),
1930 CLK(NULL, "pka_ick", &pka_ick, CK_243X), 1984 CLK(NULL, "pka_ick", &pka_ick, CK_243X),
1931 CLK(NULL, "usb_fck", &usb_fck, CK_243X), 1985 CLK(NULL, "usb_fck", &usb_fck, CK_243X),
1932 CLK("musb_hdrc", "ick", &usbhs_ick, CK_243X), 1986 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..d85ecd5aebfd 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -20,7 +20,6 @@
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/list.h> 21#include <linux/list.h>
22 22
23#include <plat/control.h>
24#include <plat/clkdev_omap.h> 23#include <plat/clkdev_omap.h>
25 24
26#include "clock.h" 25#include "clock.h"
@@ -33,6 +32,7 @@
33#include "cm-regbits-34xx.h" 32#include "cm-regbits-34xx.h"
34#include "prm.h" 33#include "prm.h"
35#include "prm-regbits-34xx.h" 34#include "prm-regbits-34xx.h"
35#include "control.h"
36 36
37/* 37/*
38 * clocks 38 * clocks
@@ -2465,6 +2465,16 @@ static struct clk uart3_fck = {
2465 .recalc = &followparent_recalc, 2465 .recalc = &followparent_recalc,
2466}; 2466};
2467 2467
2468static struct clk uart4_fck = {
2469 .name = "uart4_fck",
2470 .ops = &clkops_omap2_dflt_wait,
2471 .parent = &per_48m_fck,
2472 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
2473 .enable_bit = OMAP3630_EN_UART4_SHIFT,
2474 .clkdm_name = "per_clkdm",
2475 .recalc = &followparent_recalc,
2476};
2477
2468static struct clk gpt2_fck = { 2478static struct clk gpt2_fck = {
2469 .name = "gpt2_fck", 2479 .name = "gpt2_fck",
2470 .ops = &clkops_omap2_dflt_wait, 2480 .ops = &clkops_omap2_dflt_wait,
@@ -2715,6 +2725,16 @@ static struct clk uart3_ick = {
2715 .recalc = &followparent_recalc, 2725 .recalc = &followparent_recalc,
2716}; 2726};
2717 2727
2728static struct clk uart4_ick = {
2729 .name = "uart4_ick",
2730 .ops = &clkops_omap2_dflt_wait,
2731 .parent = &per_l4_ick,
2732 .enable_reg = OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
2733 .enable_bit = OMAP3630_EN_UART4_SHIFT,
2734 .clkdm_name = "per_clkdm",
2735 .recalc = &followparent_recalc,
2736};
2737
2718static struct clk gpt9_ick = { 2738static struct clk gpt9_ick = {
2719 .name = "gpt9_ick", 2739 .name = "gpt9_ick",
2720 .ops = &clkops_omap2_dflt_wait, 2740 .ops = &clkops_omap2_dflt_wait,
@@ -3188,6 +3208,11 @@ static struct omap_clk omap3xxx_clks[] = {
3188 CLK(NULL, "osc_sys_ck", &osc_sys_ck, CK_3XXX), 3208 CLK(NULL, "osc_sys_ck", &osc_sys_ck, CK_3XXX),
3189 CLK(NULL, "sys_ck", &sys_ck, CK_3XXX), 3209 CLK(NULL, "sys_ck", &sys_ck, CK_3XXX),
3190 CLK(NULL, "sys_altclk", &sys_altclk, CK_3XXX), 3210 CLK(NULL, "sys_altclk", &sys_altclk, CK_3XXX),
3211 CLK("omap-mcbsp.1", "pad_fck", &mcbsp_clks, CK_3XXX),
3212 CLK("omap-mcbsp.2", "pad_fck", &mcbsp_clks, CK_3XXX),
3213 CLK("omap-mcbsp.3", "pad_fck", &mcbsp_clks, CK_3XXX),
3214 CLK("omap-mcbsp.4", "pad_fck", &mcbsp_clks, CK_3XXX),
3215 CLK("omap-mcbsp.5", "pad_fck", &mcbsp_clks, CK_3XXX),
3191 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_3XXX), 3216 CLK(NULL, "mcbsp_clks", &mcbsp_clks, CK_3XXX),
3192 CLK(NULL, "sys_clkout1", &sys_clkout1, CK_3XXX), 3217 CLK(NULL, "sys_clkout1", &sys_clkout1, CK_3XXX),
3193 CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX), 3218 CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
@@ -3253,6 +3278,8 @@ static struct omap_clk omap3xxx_clks[] = {
3253 CLK(NULL, "cpefuse_fck", &cpefuse_fck, CK_3430ES2 | CK_AM35XX), 3278 CLK(NULL, "cpefuse_fck", &cpefuse_fck, CK_3430ES2 | CK_AM35XX),
3254 CLK(NULL, "ts_fck", &ts_fck, CK_3430ES2 | CK_AM35XX), 3279 CLK(NULL, "ts_fck", &ts_fck, CK_3430ES2 | CK_AM35XX),
3255 CLK(NULL, "usbtll_fck", &usbtll_fck, CK_3430ES2 | CK_AM35XX), 3280 CLK(NULL, "usbtll_fck", &usbtll_fck, CK_3430ES2 | CK_AM35XX),
3281 CLK("omap-mcbsp.1", "prcm_fck", &core_96m_fck, CK_3XXX),
3282 CLK("omap-mcbsp.5", "prcm_fck", &core_96m_fck, CK_3XXX),
3256 CLK(NULL, "core_96m_fck", &core_96m_fck, CK_3XXX), 3283 CLK(NULL, "core_96m_fck", &core_96m_fck, CK_3XXX),
3257 CLK("mmci-omap-hs.2", "fck", &mmchs3_fck, CK_3430ES2 | CK_AM35XX), 3284 CLK("mmci-omap-hs.2", "fck", &mmchs3_fck, CK_3430ES2 | CK_AM35XX),
3258 CLK("mmci-omap-hs.1", "fck", &mmchs2_fck, CK_3XXX), 3285 CLK("mmci-omap-hs.1", "fck", &mmchs2_fck, CK_3XXX),
@@ -3288,7 +3315,7 @@ static struct omap_clk omap3xxx_clks[] = {
3288 CLK(NULL, "usbtll_ick", &usbtll_ick, CK_3430ES2 | CK_AM35XX), 3315 CLK(NULL, "usbtll_ick", &usbtll_ick, CK_3430ES2 | CK_AM35XX),
3289 CLK("mmci-omap-hs.2", "ick", &mmchs3_ick, CK_3430ES2 | CK_AM35XX), 3316 CLK("mmci-omap-hs.2", "ick", &mmchs3_ick, CK_3430ES2 | CK_AM35XX),
3290 CLK(NULL, "icr_ick", &icr_ick, CK_343X), 3317 CLK(NULL, "icr_ick", &icr_ick, CK_343X),
3291 CLK(NULL, "aes2_ick", &aes2_ick, CK_343X), 3318 CLK("omap-aes", "ick", &aes2_ick, CK_343X),
3292 CLK("omap-sham", "ick", &sha12_ick, CK_343X), 3319 CLK("omap-sham", "ick", &sha12_ick, CK_343X),
3293 CLK(NULL, "des2_ick", &des2_ick, CK_343X), 3320 CLK(NULL, "des2_ick", &des2_ick, CK_343X),
3294 CLK("mmci-omap-hs.1", "ick", &mmchs2_ick, CK_3XXX), 3321 CLK("mmci-omap-hs.1", "ick", &mmchs2_ick, CK_3XXX),
@@ -3346,9 +3373,13 @@ static struct omap_clk omap3xxx_clks[] = {
3346 CLK(NULL, "omap_32ksync_ick", &omap_32ksync_ick, CK_3XXX), 3373 CLK(NULL, "omap_32ksync_ick", &omap_32ksync_ick, CK_3XXX),
3347 CLK(NULL, "gpt12_ick", &gpt12_ick, CK_3XXX), 3374 CLK(NULL, "gpt12_ick", &gpt12_ick, CK_3XXX),
3348 CLK(NULL, "gpt1_ick", &gpt1_ick, CK_3XXX), 3375 CLK(NULL, "gpt1_ick", &gpt1_ick, CK_3XXX),
3376 CLK("omap-mcbsp.2", "prcm_fck", &per_96m_fck, CK_3XXX),
3377 CLK("omap-mcbsp.3", "prcm_fck", &per_96m_fck, CK_3XXX),
3378 CLK("omap-mcbsp.4", "prcm_fck", &per_96m_fck, CK_3XXX),
3349 CLK(NULL, "per_96m_fck", &per_96m_fck, CK_3XXX), 3379 CLK(NULL, "per_96m_fck", &per_96m_fck, CK_3XXX),
3350 CLK(NULL, "per_48m_fck", &per_48m_fck, CK_3XXX), 3380 CLK(NULL, "per_48m_fck", &per_48m_fck, CK_3XXX),
3351 CLK(NULL, "uart3_fck", &uart3_fck, CK_3XXX), 3381 CLK(NULL, "uart3_fck", &uart3_fck, CK_3XXX),
3382 CLK(NULL, "uart4_fck", &uart4_fck, CK_36XX),
3352 CLK(NULL, "gpt2_fck", &gpt2_fck, CK_3XXX), 3383 CLK(NULL, "gpt2_fck", &gpt2_fck, CK_3XXX),
3353 CLK(NULL, "gpt3_fck", &gpt3_fck, CK_3XXX), 3384 CLK(NULL, "gpt3_fck", &gpt3_fck, CK_3XXX),
3354 CLK(NULL, "gpt4_fck", &gpt4_fck, CK_3XXX), 3385 CLK(NULL, "gpt4_fck", &gpt4_fck, CK_3XXX),
@@ -3372,6 +3403,7 @@ static struct omap_clk omap3xxx_clks[] = {
3372 CLK(NULL, "gpio2_ick", &gpio2_ick, CK_3XXX), 3403 CLK(NULL, "gpio2_ick", &gpio2_ick, CK_3XXX),
3373 CLK(NULL, "wdt3_ick", &wdt3_ick, CK_3XXX), 3404 CLK(NULL, "wdt3_ick", &wdt3_ick, CK_3XXX),
3374 CLK(NULL, "uart3_ick", &uart3_ick, CK_3XXX), 3405 CLK(NULL, "uart3_ick", &uart3_ick, CK_3XXX),
3406 CLK(NULL, "uart4_ick", &uart4_ick, CK_36XX),
3375 CLK(NULL, "gpt9_ick", &gpt9_ick, CK_3XXX), 3407 CLK(NULL, "gpt9_ick", &gpt9_ick, CK_3XXX),
3376 CLK(NULL, "gpt8_ick", &gpt8_ick, CK_3XXX), 3408 CLK(NULL, "gpt8_ick", &gpt8_ick, CK_3XXX),
3377 CLK(NULL, "gpt7_ick", &gpt7_ick, CK_3XXX), 3409 CLK(NULL, "gpt7_ick", &gpt7_ick, CK_3XXX),
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index e10db7a90cb2..1599836ba3d9 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -17,13 +17,15 @@
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License version 2 as 18 * it under the terms of the GNU General Public License version 2 as
19 * published by the Free Software Foundation. 19 * published by the Free Software Foundation.
20 *
21 * XXX Some of the ES1 clocks have been removed/changed; once support
22 * is added for discriminating clocks by ES level, these should be added back
23 * in.
20 */ 24 */
21 25
22#include <linux/kernel.h> 26#include <linux/kernel.h>
23#include <linux/list.h> 27#include <linux/list.h>
24#include <linux/clk.h> 28#include <linux/clk.h>
25
26#include <plat/control.h>
27#include <plat/clkdev_omap.h> 29#include <plat/clkdev_omap.h>
28 30
29#include "clock.h" 31#include "clock.h"
@@ -32,6 +34,7 @@
32#include "cm-regbits-44xx.h" 34#include "cm-regbits-44xx.h"
33#include "prm.h" 35#include "prm.h"
34#include "prm-regbits-44xx.h" 36#include "prm-regbits-44xx.h"
37#include "control.h"
35 38
36/* Root clocks */ 39/* Root clocks */
37 40
@@ -175,21 +178,27 @@ static struct clk sys_clkin_ck = {
175 .recalc = &omap2_clksel_recalc, 178 .recalc = &omap2_clksel_recalc,
176}; 179};
177 180
181static struct clk tie_low_clock_ck = {
182 .name = "tie_low_clock_ck",
183 .rate = 0,
184 .ops = &clkops_null,
185};
186
178static struct clk utmi_phy_clkout_ck = { 187static struct clk utmi_phy_clkout_ck = {
179 .name = "utmi_phy_clkout_ck", 188 .name = "utmi_phy_clkout_ck",
180 .rate = 12000000, 189 .rate = 60000000,
181 .ops = &clkops_null, 190 .ops = &clkops_null,
182}; 191};
183 192
184static struct clk xclk60mhsp1_ck = { 193static struct clk xclk60mhsp1_ck = {
185 .name = "xclk60mhsp1_ck", 194 .name = "xclk60mhsp1_ck",
186 .rate = 12000000, 195 .rate = 60000000,
187 .ops = &clkops_null, 196 .ops = &clkops_null,
188}; 197};
189 198
190static struct clk xclk60mhsp2_ck = { 199static struct clk xclk60mhsp2_ck = {
191 .name = "xclk60mhsp2_ck", 200 .name = "xclk60mhsp2_ck",
192 .rate = 12000000, 201 .rate = 60000000,
193 .ops = &clkops_null, 202 .ops = &clkops_null,
194}; 203};
195 204
@@ -201,39 +210,23 @@ static struct clk xclk60motg_ck = {
201 210
202/* Module clocks and DPLL outputs */ 211/* Module clocks and DPLL outputs */
203 212
204static const struct clksel_rate div2_1to2_rates[] = { 213static const struct clksel abe_dpll_bypass_clk_mux_sel[] = {
205 { .div = 1, .val = 0, .flags = RATE_IN_4430 }, 214 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
206 { .div = 2, .val = 1, .flags = RATE_IN_4430 }, 215 { .parent = &sys_32k_ck, .rates = div_1_1_rates },
207 { .div = 0 },
208};
209
210static const struct clksel dpll_sys_ref_clk_div[] = {
211 { .parent = &sys_clkin_ck, .rates = div2_1to2_rates },
212 { .parent = NULL }, 216 { .parent = NULL },
213}; 217};
214 218
215static struct clk dpll_sys_ref_clk = { 219static struct clk abe_dpll_bypass_clk_mux_ck = {
216 .name = "dpll_sys_ref_clk", 220 .name = "abe_dpll_bypass_clk_mux_ck",
217 .parent = &sys_clkin_ck, 221 .parent = &sys_clkin_ck,
218 .clksel = dpll_sys_ref_clk_div,
219 .clksel_reg = OMAP4430_CM_DPLL_SYS_REF_CLKSEL,
220 .clksel_mask = OMAP4430_CLKSEL_0_0_MASK,
221 .ops = &clkops_null, 222 .ops = &clkops_null,
222 .recalc = &omap2_clksel_recalc, 223 .recalc = &followparent_recalc,
223 .round_rate = &omap2_clksel_round_rate,
224 .set_rate = &omap2_clksel_set_rate,
225};
226
227static const struct clksel abe_dpll_refclk_mux_sel[] = {
228 { .parent = &dpll_sys_ref_clk, .rates = div_1_0_rates },
229 { .parent = &sys_32k_ck, .rates = div_1_1_rates },
230 { .parent = NULL },
231}; 224};
232 225
233static struct clk abe_dpll_refclk_mux_ck = { 226static struct clk abe_dpll_refclk_mux_ck = {
234 .name = "abe_dpll_refclk_mux_ck", 227 .name = "abe_dpll_refclk_mux_ck",
235 .parent = &dpll_sys_ref_clk, 228 .parent = &sys_clkin_ck,
236 .clksel = abe_dpll_refclk_mux_sel, 229 .clksel = abe_dpll_bypass_clk_mux_sel,
237 .init = &omap2_init_clksel_parent, 230 .init = &omap2_init_clksel_parent,
238 .clksel_reg = OMAP4430_CM_ABE_PLL_REF_CLKSEL, 231 .clksel_reg = OMAP4430_CM_ABE_PLL_REF_CLKSEL,
239 .clksel_mask = OMAP4430_CLKSEL_0_0_MASK, 232 .clksel_mask = OMAP4430_CLKSEL_0_0_MASK,
@@ -244,7 +237,7 @@ static struct clk abe_dpll_refclk_mux_ck = {
244/* DPLL_ABE */ 237/* DPLL_ABE */
245static struct dpll_data dpll_abe_dd = { 238static struct dpll_data dpll_abe_dd = {
246 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_ABE, 239 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_ABE,
247 .clk_bypass = &sys_clkin_ck, 240 .clk_bypass = &abe_dpll_bypass_clk_mux_ck,
248 .clk_ref = &abe_dpll_refclk_mux_ck, 241 .clk_ref = &abe_dpll_refclk_mux_ck,
249 .control_reg = OMAP4430_CM_CLKMODE_DPLL_ABE, 242 .control_reg = OMAP4430_CM_CLKMODE_DPLL_ABE,
250 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 243 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
@@ -310,6 +303,12 @@ static struct clk abe_clk = {
310 .set_rate = &omap2_clksel_set_rate, 303 .set_rate = &omap2_clksel_set_rate,
311}; 304};
312 305
306static const struct clksel_rate div2_1to2_rates[] = {
307 { .div = 1, .val = 0, .flags = RATE_IN_4430 },
308 { .div = 2, .val = 1, .flags = RATE_IN_4430 },
309 { .div = 0 },
310};
311
313static const struct clksel aess_fclk_div[] = { 312static const struct clksel aess_fclk_div[] = {
314 { .parent = &abe_clk, .rates = div2_1to2_rates }, 313 { .parent = &abe_clk, .rates = div2_1to2_rates },
315 { .parent = NULL }, 314 { .parent = NULL },
@@ -380,14 +379,14 @@ static struct clk dpll_abe_m3_ck = {
380}; 379};
381 380
382static const struct clksel core_hsd_byp_clk_mux_sel[] = { 381static const struct clksel core_hsd_byp_clk_mux_sel[] = {
383 { .parent = &dpll_sys_ref_clk, .rates = div_1_0_rates }, 382 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
384 { .parent = &dpll_abe_m3_ck, .rates = div_1_1_rates }, 383 { .parent = &dpll_abe_m3_ck, .rates = div_1_1_rates },
385 { .parent = NULL }, 384 { .parent = NULL },
386}; 385};
387 386
388static struct clk core_hsd_byp_clk_mux_ck = { 387static struct clk core_hsd_byp_clk_mux_ck = {
389 .name = "core_hsd_byp_clk_mux_ck", 388 .name = "core_hsd_byp_clk_mux_ck",
390 .parent = &dpll_sys_ref_clk, 389 .parent = &sys_clkin_ck,
391 .clksel = core_hsd_byp_clk_mux_sel, 390 .clksel = core_hsd_byp_clk_mux_sel,
392 .init = &omap2_init_clksel_parent, 391 .init = &omap2_init_clksel_parent,
393 .clksel_reg = OMAP4430_CM_CLKSEL_DPLL_CORE, 392 .clksel_reg = OMAP4430_CM_CLKSEL_DPLL_CORE,
@@ -400,7 +399,7 @@ static struct clk core_hsd_byp_clk_mux_ck = {
400static struct dpll_data dpll_core_dd = { 399static struct dpll_data dpll_core_dd = {
401 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_CORE, 400 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_CORE,
402 .clk_bypass = &core_hsd_byp_clk_mux_ck, 401 .clk_bypass = &core_hsd_byp_clk_mux_ck,
403 .clk_ref = &dpll_sys_ref_clk, 402 .clk_ref = &sys_clkin_ck,
404 .control_reg = OMAP4430_CM_CLKMODE_DPLL_CORE, 403 .control_reg = OMAP4430_CM_CLKMODE_DPLL_CORE,
405 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 404 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
406 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_CORE, 405 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_CORE,
@@ -418,7 +417,7 @@ static struct dpll_data dpll_core_dd = {
418 417
419static struct clk dpll_core_ck = { 418static struct clk dpll_core_ck = {
420 .name = "dpll_core_ck", 419 .name = "dpll_core_ck",
421 .parent = &dpll_sys_ref_clk, 420 .parent = &sys_clkin_ck,
422 .dpll_data = &dpll_core_dd, 421 .dpll_data = &dpll_core_dd,
423 .init = &omap2_init_dpll_parent, 422 .init = &omap2_init_dpll_parent,
424 .ops = &clkops_null, 423 .ops = &clkops_null,
@@ -596,14 +595,14 @@ static struct clk dpll_core_m7_ck = {
596}; 595};
597 596
598static const struct clksel iva_hsd_byp_clk_mux_sel[] = { 597static const struct clksel iva_hsd_byp_clk_mux_sel[] = {
599 { .parent = &dpll_sys_ref_clk, .rates = div_1_0_rates }, 598 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
600 { .parent = &div_iva_hs_clk, .rates = div_1_1_rates }, 599 { .parent = &div_iva_hs_clk, .rates = div_1_1_rates },
601 { .parent = NULL }, 600 { .parent = NULL },
602}; 601};
603 602
604static struct clk iva_hsd_byp_clk_mux_ck = { 603static struct clk iva_hsd_byp_clk_mux_ck = {
605 .name = "iva_hsd_byp_clk_mux_ck", 604 .name = "iva_hsd_byp_clk_mux_ck",
606 .parent = &dpll_sys_ref_clk, 605 .parent = &sys_clkin_ck,
607 .ops = &clkops_null, 606 .ops = &clkops_null,
608 .recalc = &followparent_recalc, 607 .recalc = &followparent_recalc,
609}; 608};
@@ -612,7 +611,7 @@ static struct clk iva_hsd_byp_clk_mux_ck = {
612static struct dpll_data dpll_iva_dd = { 611static struct dpll_data dpll_iva_dd = {
613 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_IVA, 612 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_IVA,
614 .clk_bypass = &iva_hsd_byp_clk_mux_ck, 613 .clk_bypass = &iva_hsd_byp_clk_mux_ck,
615 .clk_ref = &dpll_sys_ref_clk, 614 .clk_ref = &sys_clkin_ck,
616 .control_reg = OMAP4430_CM_CLKMODE_DPLL_IVA, 615 .control_reg = OMAP4430_CM_CLKMODE_DPLL_IVA,
617 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 616 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
618 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_IVA, 617 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_IVA,
@@ -630,7 +629,7 @@ static struct dpll_data dpll_iva_dd = {
630 629
631static struct clk dpll_iva_ck = { 630static struct clk dpll_iva_ck = {
632 .name = "dpll_iva_ck", 631 .name = "dpll_iva_ck",
633 .parent = &dpll_sys_ref_clk, 632 .parent = &sys_clkin_ck,
634 .dpll_data = &dpll_iva_dd, 633 .dpll_data = &dpll_iva_dd,
635 .init = &omap2_init_dpll_parent, 634 .init = &omap2_init_dpll_parent,
636 .ops = &clkops_omap3_noncore_dpll_ops, 635 .ops = &clkops_omap3_noncore_dpll_ops,
@@ -672,7 +671,7 @@ static struct clk dpll_iva_m5_ck = {
672static struct dpll_data dpll_mpu_dd = { 671static struct dpll_data dpll_mpu_dd = {
673 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_MPU, 672 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_MPU,
674 .clk_bypass = &div_mpu_hs_clk, 673 .clk_bypass = &div_mpu_hs_clk,
675 .clk_ref = &dpll_sys_ref_clk, 674 .clk_ref = &sys_clkin_ck,
676 .control_reg = OMAP4430_CM_CLKMODE_DPLL_MPU, 675 .control_reg = OMAP4430_CM_CLKMODE_DPLL_MPU,
677 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 676 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
678 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_MPU, 677 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_MPU,
@@ -690,7 +689,7 @@ static struct dpll_data dpll_mpu_dd = {
690 689
691static struct clk dpll_mpu_ck = { 690static struct clk dpll_mpu_ck = {
692 .name = "dpll_mpu_ck", 691 .name = "dpll_mpu_ck",
693 .parent = &dpll_sys_ref_clk, 692 .parent = &sys_clkin_ck,
694 .dpll_data = &dpll_mpu_dd, 693 .dpll_data = &dpll_mpu_dd,
695 .init = &omap2_init_dpll_parent, 694 .init = &omap2_init_dpll_parent,
696 .ops = &clkops_omap3_noncore_dpll_ops, 695 .ops = &clkops_omap3_noncore_dpll_ops,
@@ -724,14 +723,14 @@ static struct clk per_hs_clk_div_ck = {
724}; 723};
725 724
726static const struct clksel per_hsd_byp_clk_mux_sel[] = { 725static const struct clksel per_hsd_byp_clk_mux_sel[] = {
727 { .parent = &dpll_sys_ref_clk, .rates = div_1_0_rates }, 726 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
728 { .parent = &per_hs_clk_div_ck, .rates = div_1_1_rates }, 727 { .parent = &per_hs_clk_div_ck, .rates = div_1_1_rates },
729 { .parent = NULL }, 728 { .parent = NULL },
730}; 729};
731 730
732static struct clk per_hsd_byp_clk_mux_ck = { 731static struct clk per_hsd_byp_clk_mux_ck = {
733 .name = "per_hsd_byp_clk_mux_ck", 732 .name = "per_hsd_byp_clk_mux_ck",
734 .parent = &dpll_sys_ref_clk, 733 .parent = &sys_clkin_ck,
735 .clksel = per_hsd_byp_clk_mux_sel, 734 .clksel = per_hsd_byp_clk_mux_sel,
736 .init = &omap2_init_clksel_parent, 735 .init = &omap2_init_clksel_parent,
737 .clksel_reg = OMAP4430_CM_CLKSEL_DPLL_PER, 736 .clksel_reg = OMAP4430_CM_CLKSEL_DPLL_PER,
@@ -744,7 +743,7 @@ static struct clk per_hsd_byp_clk_mux_ck = {
744static struct dpll_data dpll_per_dd = { 743static struct dpll_data dpll_per_dd = {
745 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_PER, 744 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_PER,
746 .clk_bypass = &per_hsd_byp_clk_mux_ck, 745 .clk_bypass = &per_hsd_byp_clk_mux_ck,
747 .clk_ref = &dpll_sys_ref_clk, 746 .clk_ref = &sys_clkin_ck,
748 .control_reg = OMAP4430_CM_CLKMODE_DPLL_PER, 747 .control_reg = OMAP4430_CM_CLKMODE_DPLL_PER,
749 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 748 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
750 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_PER, 749 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_PER,
@@ -762,7 +761,7 @@ static struct dpll_data dpll_per_dd = {
762 761
763static struct clk dpll_per_ck = { 762static struct clk dpll_per_ck = {
764 .name = "dpll_per_ck", 763 .name = "dpll_per_ck",
765 .parent = &dpll_sys_ref_clk, 764 .parent = &sys_clkin_ck,
766 .dpll_data = &dpll_per_dd, 765 .dpll_data = &dpll_per_dd,
767 .init = &omap2_init_dpll_parent, 766 .init = &omap2_init_dpll_parent,
768 .ops = &clkops_omap3_noncore_dpll_ops, 767 .ops = &clkops_omap3_noncore_dpll_ops,
@@ -858,8 +857,8 @@ static struct clk dpll_per_m7_ck = {
858/* DPLL_UNIPRO */ 857/* DPLL_UNIPRO */
859static struct dpll_data dpll_unipro_dd = { 858static struct dpll_data dpll_unipro_dd = {
860 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_UNIPRO, 859 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_UNIPRO,
861 .clk_bypass = &dpll_sys_ref_clk, 860 .clk_bypass = &sys_clkin_ck,
862 .clk_ref = &dpll_sys_ref_clk, 861 .clk_ref = &sys_clkin_ck,
863 .control_reg = OMAP4430_CM_CLKMODE_DPLL_UNIPRO, 862 .control_reg = OMAP4430_CM_CLKMODE_DPLL_UNIPRO,
864 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 863 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
865 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_UNIPRO, 864 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_UNIPRO,
@@ -877,7 +876,7 @@ static struct dpll_data dpll_unipro_dd = {
877 876
878static struct clk dpll_unipro_ck = { 877static struct clk dpll_unipro_ck = {
879 .name = "dpll_unipro_ck", 878 .name = "dpll_unipro_ck",
880 .parent = &dpll_sys_ref_clk, 879 .parent = &sys_clkin_ck,
881 .dpll_data = &dpll_unipro_dd, 880 .dpll_data = &dpll_unipro_dd,
882 .init = &omap2_init_dpll_parent, 881 .init = &omap2_init_dpll_parent,
883 .ops = &clkops_omap3_noncore_dpll_ops, 882 .ops = &clkops_omap3_noncore_dpll_ops,
@@ -914,7 +913,8 @@ static struct clk usb_hs_clk_div_ck = {
914static struct dpll_data dpll_usb_dd = { 913static struct dpll_data dpll_usb_dd = {
915 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_USB, 914 .mult_div1_reg = OMAP4430_CM_CLKSEL_DPLL_USB,
916 .clk_bypass = &usb_hs_clk_div_ck, 915 .clk_bypass = &usb_hs_clk_div_ck,
917 .clk_ref = &dpll_sys_ref_clk, 916 .flags = DPLL_J_TYPE | DPLL_NO_DCO_SEL,
917 .clk_ref = &sys_clkin_ck,
918 .control_reg = OMAP4430_CM_CLKMODE_DPLL_USB, 918 .control_reg = OMAP4430_CM_CLKMODE_DPLL_USB,
919 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 919 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
920 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_USB, 920 .autoidle_reg = OMAP4430_CM_AUTOIDLE_DPLL_USB,
@@ -927,13 +927,12 @@ static struct dpll_data dpll_usb_dd = {
927 .max_multiplier = OMAP4430_MAX_DPLL_MULT, 927 .max_multiplier = OMAP4430_MAX_DPLL_MULT,
928 .max_divider = OMAP4430_MAX_DPLL_DIV, 928 .max_divider = OMAP4430_MAX_DPLL_DIV,
929 .min_divider = 1, 929 .min_divider = 1,
930 .flags = DPLL_J_TYPE | DPLL_NO_DCO_SEL
931}; 930};
932 931
933 932
934static struct clk dpll_usb_ck = { 933static struct clk dpll_usb_ck = {
935 .name = "dpll_usb_ck", 934 .name = "dpll_usb_ck",
936 .parent = &dpll_sys_ref_clk, 935 .parent = &sys_clkin_ck,
937 .dpll_data = &dpll_usb_dd, 936 .dpll_data = &dpll_usb_dd,
938 .init = &omap2_init_dpll_parent, 937 .init = &omap2_init_dpll_parent,
939 .ops = &clkops_omap3_noncore_dpll_ops, 938 .ops = &clkops_omap3_noncore_dpll_ops,
@@ -1222,7 +1221,7 @@ static struct clk per_abe_24m_fclk = {
1222static const struct clksel pmd_stm_clock_mux_sel[] = { 1221static const struct clksel pmd_stm_clock_mux_sel[] = {
1223 { .parent = &sys_clkin_ck, .rates = div_1_0_rates }, 1222 { .parent = &sys_clkin_ck, .rates = div_1_0_rates },
1224 { .parent = &dpll_core_m6_ck, .rates = div_1_1_rates }, 1223 { .parent = &dpll_core_m6_ck, .rates = div_1_1_rates },
1225 { .parent = &dpll_per_m7_ck, .rates = div_1_2_rates }, 1224 { .parent = &tie_low_clock_ck, .rates = div_1_2_rates },
1226 { .parent = NULL }, 1225 { .parent = NULL },
1227}; 1226};
1228 1227
@@ -1240,10 +1239,15 @@ static struct clk pmd_trace_clk_mux_ck = {
1240 .recalc = &followparent_recalc, 1239 .recalc = &followparent_recalc,
1241}; 1240};
1242 1241
1242static const struct clksel syc_clk_div_div[] = {
1243 { .parent = &sys_clkin_ck, .rates = div2_1to2_rates },
1244 { .parent = NULL },
1245};
1246
1243static struct clk syc_clk_div_ck = { 1247static struct clk syc_clk_div_ck = {
1244 .name = "syc_clk_div_ck", 1248 .name = "syc_clk_div_ck",
1245 .parent = &sys_clkin_ck, 1249 .parent = &sys_clkin_ck,
1246 .clksel = dpll_sys_ref_clk_div, 1250 .clksel = syc_clk_div_div,
1247 .clksel_reg = OMAP4430_CM_ABE_DSS_SYS_CLKSEL, 1251 .clksel_reg = OMAP4430_CM_ABE_DSS_SYS_CLKSEL,
1248 .clksel_mask = OMAP4430_CLKSEL_0_0_MASK, 1252 .clksel_mask = OMAP4430_CLKSEL_0_0_MASK,
1249 .ops = &clkops_null, 1253 .ops = &clkops_null,
@@ -1284,13 +1288,13 @@ static struct clk aess_fck = {
1284 .recalc = &followparent_recalc, 1288 .recalc = &followparent_recalc,
1285}; 1289};
1286 1290
1287static struct clk cust_efuse_fck = { 1291static struct clk bandgap_fclk = {
1288 .name = "cust_efuse_fck", 1292 .name = "bandgap_fclk",
1289 .ops = &clkops_omap2_dflt, 1293 .ops = &clkops_omap2_dflt,
1290 .enable_reg = OMAP4430_CM_CEFUSE_CEFUSE_CLKCTRL, 1294 .enable_reg = OMAP4430_CM_WKUP_BANDGAP_CLKCTRL,
1291 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 1295 .enable_bit = OMAP4430_OPTFCLKEN_BGAP_32K_SHIFT,
1292 .clkdm_name = "l4_cefuse_clkdm", 1296 .clkdm_name = "l4_wkup_clkdm",
1293 .parent = &sys_clkin_ck, 1297 .parent = &sys_32k_ck,
1294 .recalc = &followparent_recalc, 1298 .recalc = &followparent_recalc,
1295}; 1299};
1296 1300
@@ -1344,6 +1348,56 @@ static struct clk dmic_fck = {
1344 .clkdm_name = "abe_clkdm", 1348 .clkdm_name = "abe_clkdm",
1345}; 1349};
1346 1350
1351static struct clk dsp_fck = {
1352 .name = "dsp_fck",
1353 .ops = &clkops_omap2_dflt,
1354 .enable_reg = OMAP4430_CM_TESLA_TESLA_CLKCTRL,
1355 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
1356 .clkdm_name = "tesla_clkdm",
1357 .parent = &dpll_iva_m4_ck,
1358 .recalc = &followparent_recalc,
1359};
1360
1361static struct clk dss_sys_clk = {
1362 .name = "dss_sys_clk",
1363 .ops = &clkops_omap2_dflt,
1364 .enable_reg = OMAP4430_CM_DSS_DSS_CLKCTRL,
1365 .enable_bit = OMAP4430_OPTFCLKEN_SYS_CLK_SHIFT,
1366 .clkdm_name = "l3_dss_clkdm",
1367 .parent = &syc_clk_div_ck,
1368 .recalc = &followparent_recalc,
1369};
1370
1371static struct clk dss_tv_clk = {
1372 .name = "dss_tv_clk",
1373 .ops = &clkops_omap2_dflt,
1374 .enable_reg = OMAP4430_CM_DSS_DSS_CLKCTRL,
1375 .enable_bit = OMAP4430_OPTFCLKEN_TV_CLK_SHIFT,
1376 .clkdm_name = "l3_dss_clkdm",
1377 .parent = &extalt_clkin_ck,
1378 .recalc = &followparent_recalc,
1379};
1380
1381static struct clk dss_dss_clk = {
1382 .name = "dss_dss_clk",
1383 .ops = &clkops_omap2_dflt,
1384 .enable_reg = OMAP4430_CM_DSS_DSS_CLKCTRL,
1385 .enable_bit = OMAP4430_OPTFCLKEN_DSSCLK_SHIFT,
1386 .clkdm_name = "l3_dss_clkdm",
1387 .parent = &dpll_per_m5_ck,
1388 .recalc = &followparent_recalc,
1389};
1390
1391static struct clk dss_48mhz_clk = {
1392 .name = "dss_48mhz_clk",
1393 .ops = &clkops_omap2_dflt,
1394 .enable_reg = OMAP4430_CM_DSS_DSS_CLKCTRL,
1395 .enable_bit = OMAP4430_OPTFCLKEN_48MHZ_CLK_SHIFT,
1396 .clkdm_name = "l3_dss_clkdm",
1397 .parent = &func_48mc_fclk,
1398 .recalc = &followparent_recalc,
1399};
1400
1347static struct clk dss_fck = { 1401static struct clk dss_fck = {
1348 .name = "dss_fck", 1402 .name = "dss_fck",
1349 .ops = &clkops_omap2_dflt, 1403 .ops = &clkops_omap2_dflt,
@@ -1354,18 +1408,18 @@ static struct clk dss_fck = {
1354 .recalc = &followparent_recalc, 1408 .recalc = &followparent_recalc,
1355}; 1409};
1356 1410
1357static struct clk ducati_ick = { 1411static struct clk efuse_ctrl_cust_fck = {
1358 .name = "ducati_ick", 1412 .name = "efuse_ctrl_cust_fck",
1359 .ops = &clkops_omap2_dflt, 1413 .ops = &clkops_omap2_dflt,
1360 .enable_reg = OMAP4430_CM_DUCATI_DUCATI_CLKCTRL, 1414 .enable_reg = OMAP4430_CM_CEFUSE_CEFUSE_CLKCTRL,
1361 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1415 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1362 .clkdm_name = "ducati_clkdm", 1416 .clkdm_name = "l4_cefuse_clkdm",
1363 .parent = &ducati_clk_mux_ck, 1417 .parent = &sys_clkin_ck,
1364 .recalc = &followparent_recalc, 1418 .recalc = &followparent_recalc,
1365}; 1419};
1366 1420
1367static struct clk emif1_ick = { 1421static struct clk emif1_fck = {
1368 .name = "emif1_ick", 1422 .name = "emif1_fck",
1369 .ops = &clkops_omap2_dflt, 1423 .ops = &clkops_omap2_dflt,
1370 .enable_reg = OMAP4430_CM_MEMIF_EMIF_1_CLKCTRL, 1424 .enable_reg = OMAP4430_CM_MEMIF_EMIF_1_CLKCTRL,
1371 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1425 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -1375,8 +1429,8 @@ static struct clk emif1_ick = {
1375 .recalc = &followparent_recalc, 1429 .recalc = &followparent_recalc,
1376}; 1430};
1377 1431
1378static struct clk emif2_ick = { 1432static struct clk emif2_fck = {
1379 .name = "emif2_ick", 1433 .name = "emif2_fck",
1380 .ops = &clkops_omap2_dflt, 1434 .ops = &clkops_omap2_dflt,
1381 .enable_reg = OMAP4430_CM_MEMIF_EMIF_2_CLKCTRL, 1435 .enable_reg = OMAP4430_CM_MEMIF_EMIF_2_CLKCTRL,
1382 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1436 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -1407,42 +1461,24 @@ static struct clk fdif_fck = {
1407 .clkdm_name = "iss_clkdm", 1461 .clkdm_name = "iss_clkdm",
1408}; 1462};
1409 1463
1410static const struct clksel per_sgx_fclk_div[] = { 1464static struct clk fpka_fck = {
1411 { .parent = &dpll_per_m2x2_ck, .rates = div3_1to4_rates }, 1465 .name = "fpka_fck",
1412 { .parent = NULL }, 1466 .ops = &clkops_omap2_dflt,
1413}; 1467 .enable_reg = OMAP4430_CM_L4SEC_PKAEIP29_CLKCTRL,
1414 1468 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1415static struct clk per_sgx_fclk = { 1469 .clkdm_name = "l4_secure_clkdm",
1416 .name = "per_sgx_fclk", 1470 .parent = &l4_div_ck,
1417 .parent = &dpll_per_m2x2_ck, 1471 .recalc = &followparent_recalc,
1418 .clksel = per_sgx_fclk_div,
1419 .clksel_reg = OMAP4430_CM_GFX_GFX_CLKCTRL,
1420 .clksel_mask = OMAP4430_CLKSEL_PER_192M_MASK,
1421 .ops = &clkops_null,
1422 .recalc = &omap2_clksel_recalc,
1423 .round_rate = &omap2_clksel_round_rate,
1424 .set_rate = &omap2_clksel_set_rate,
1425};
1426
1427static const struct clksel sgx_clk_mux_sel[] = {
1428 { .parent = &dpll_core_m7_ck, .rates = div_1_0_rates },
1429 { .parent = &per_sgx_fclk, .rates = div_1_1_rates },
1430 { .parent = NULL },
1431}; 1472};
1432 1473
1433/* Merged sgx_clk_mux into gfx */ 1474static struct clk gpio1_dbclk = {
1434static struct clk gfx_fck = { 1475 .name = "gpio1_dbclk",
1435 .name = "gfx_fck",
1436 .parent = &dpll_core_m7_ck,
1437 .clksel = sgx_clk_mux_sel,
1438 .init = &omap2_init_clksel_parent,
1439 .clksel_reg = OMAP4430_CM_GFX_GFX_CLKCTRL,
1440 .clksel_mask = OMAP4430_CLKSEL_SGX_FCLK_MASK,
1441 .ops = &clkops_omap2_dflt, 1476 .ops = &clkops_omap2_dflt,
1442 .recalc = &omap2_clksel_recalc, 1477 .enable_reg = OMAP4430_CM_WKUP_GPIO1_CLKCTRL,
1443 .enable_reg = OMAP4430_CM_GFX_GFX_CLKCTRL, 1478 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1444 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 1479 .clkdm_name = "l4_wkup_clkdm",
1445 .clkdm_name = "l3_gfx_clkdm", 1480 .parent = &sys_32k_ck,
1481 .recalc = &followparent_recalc,
1446}; 1482};
1447 1483
1448static struct clk gpio1_ick = { 1484static struct clk gpio1_ick = {
@@ -1455,6 +1491,16 @@ static struct clk gpio1_ick = {
1455 .recalc = &followparent_recalc, 1491 .recalc = &followparent_recalc,
1456}; 1492};
1457 1493
1494static struct clk gpio2_dbclk = {
1495 .name = "gpio2_dbclk",
1496 .ops = &clkops_omap2_dflt,
1497 .enable_reg = OMAP4430_CM_L4PER_GPIO2_CLKCTRL,
1498 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1499 .clkdm_name = "l4_per_clkdm",
1500 .parent = &sys_32k_ck,
1501 .recalc = &followparent_recalc,
1502};
1503
1458static struct clk gpio2_ick = { 1504static struct clk gpio2_ick = {
1459 .name = "gpio2_ick", 1505 .name = "gpio2_ick",
1460 .ops = &clkops_omap2_dflt, 1506 .ops = &clkops_omap2_dflt,
@@ -1465,6 +1511,16 @@ static struct clk gpio2_ick = {
1465 .recalc = &followparent_recalc, 1511 .recalc = &followparent_recalc,
1466}; 1512};
1467 1513
1514static struct clk gpio3_dbclk = {
1515 .name = "gpio3_dbclk",
1516 .ops = &clkops_omap2_dflt,
1517 .enable_reg = OMAP4430_CM_L4PER_GPIO3_CLKCTRL,
1518 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1519 .clkdm_name = "l4_per_clkdm",
1520 .parent = &sys_32k_ck,
1521 .recalc = &followparent_recalc,
1522};
1523
1468static struct clk gpio3_ick = { 1524static struct clk gpio3_ick = {
1469 .name = "gpio3_ick", 1525 .name = "gpio3_ick",
1470 .ops = &clkops_omap2_dflt, 1526 .ops = &clkops_omap2_dflt,
@@ -1475,6 +1531,16 @@ static struct clk gpio3_ick = {
1475 .recalc = &followparent_recalc, 1531 .recalc = &followparent_recalc,
1476}; 1532};
1477 1533
1534static struct clk gpio4_dbclk = {
1535 .name = "gpio4_dbclk",
1536 .ops = &clkops_omap2_dflt,
1537 .enable_reg = OMAP4430_CM_L4PER_GPIO4_CLKCTRL,
1538 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1539 .clkdm_name = "l4_per_clkdm",
1540 .parent = &sys_32k_ck,
1541 .recalc = &followparent_recalc,
1542};
1543
1478static struct clk gpio4_ick = { 1544static struct clk gpio4_ick = {
1479 .name = "gpio4_ick", 1545 .name = "gpio4_ick",
1480 .ops = &clkops_omap2_dflt, 1546 .ops = &clkops_omap2_dflt,
@@ -1485,6 +1551,16 @@ static struct clk gpio4_ick = {
1485 .recalc = &followparent_recalc, 1551 .recalc = &followparent_recalc,
1486}; 1552};
1487 1553
1554static struct clk gpio5_dbclk = {
1555 .name = "gpio5_dbclk",
1556 .ops = &clkops_omap2_dflt,
1557 .enable_reg = OMAP4430_CM_L4PER_GPIO5_CLKCTRL,
1558 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1559 .clkdm_name = "l4_per_clkdm",
1560 .parent = &sys_32k_ck,
1561 .recalc = &followparent_recalc,
1562};
1563
1488static struct clk gpio5_ick = { 1564static struct clk gpio5_ick = {
1489 .name = "gpio5_ick", 1565 .name = "gpio5_ick",
1490 .ops = &clkops_omap2_dflt, 1566 .ops = &clkops_omap2_dflt,
@@ -1495,6 +1571,16 @@ static struct clk gpio5_ick = {
1495 .recalc = &followparent_recalc, 1571 .recalc = &followparent_recalc,
1496}; 1572};
1497 1573
1574static struct clk gpio6_dbclk = {
1575 .name = "gpio6_dbclk",
1576 .ops = &clkops_omap2_dflt,
1577 .enable_reg = OMAP4430_CM_L4PER_GPIO6_CLKCTRL,
1578 .enable_bit = OMAP4430_OPTFCLKEN_DBCLK_SHIFT,
1579 .clkdm_name = "l4_per_clkdm",
1580 .parent = &sys_32k_ck,
1581 .recalc = &followparent_recalc,
1582};
1583
1498static struct clk gpio6_ick = { 1584static struct clk gpio6_ick = {
1499 .name = "gpio6_ick", 1585 .name = "gpio6_ick",
1500 .ops = &clkops_omap2_dflt, 1586 .ops = &clkops_omap2_dflt,
@@ -1515,214 +1601,25 @@ static struct clk gpmc_ick = {
1515 .recalc = &followparent_recalc, 1601 .recalc = &followparent_recalc,
1516}; 1602};
1517 1603
1518static const struct clksel dmt1_clk_mux_sel[] = { 1604static const struct clksel sgx_clk_mux_sel[] = {
1519 { .parent = &sys_clkin_ck, .rates = div_1_0_rates }, 1605 { .parent = &dpll_core_m7_ck, .rates = div_1_0_rates },
1520 { .parent = &sys_32k_ck, .rates = div_1_1_rates }, 1606 { .parent = &dpll_per_m7_ck, .rates = div_1_1_rates },
1521 { .parent = NULL },
1522};
1523
1524/*
1525 * Merged dmt1_clk_mux into gptimer1
1526 * gptimer1 renamed temporarily into gpt1 to match OMAP3 convention
1527 */
1528static struct clk gpt1_fck = {
1529 .name = "gpt1_fck",
1530 .parent = &sys_clkin_ck,
1531 .clksel = dmt1_clk_mux_sel,
1532 .init = &omap2_init_clksel_parent,
1533 .clksel_reg = OMAP4430_CM_WKUP_TIMER1_CLKCTRL,
1534 .clksel_mask = OMAP4430_CLKSEL_MASK,
1535 .ops = &clkops_omap2_dflt,
1536 .recalc = &omap2_clksel_recalc,
1537 .enable_reg = OMAP4430_CM_WKUP_TIMER1_CLKCTRL,
1538 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1539 .clkdm_name = "l4_wkup_clkdm",
1540};
1541
1542/*
1543 * Merged cm2_dm10_mux into gptimer10
1544 * gptimer10 renamed temporarily into gpt10 to match OMAP3 convention
1545 */
1546static struct clk gpt10_fck = {
1547 .name = "gpt10_fck",
1548 .parent = &sys_clkin_ck,
1549 .clksel = dmt1_clk_mux_sel,
1550 .init = &omap2_init_clksel_parent,
1551 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER10_CLKCTRL,
1552 .clksel_mask = OMAP4430_CLKSEL_MASK,
1553 .ops = &clkops_omap2_dflt,
1554 .recalc = &omap2_clksel_recalc,
1555 .enable_reg = OMAP4430_CM_L4PER_DMTIMER10_CLKCTRL,
1556 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1557 .clkdm_name = "l4_per_clkdm",
1558};
1559
1560/*
1561 * Merged cm2_dm11_mux into gptimer11
1562 * gptimer11 renamed temporarily into gpt11 to match OMAP3 convention
1563 */
1564static struct clk gpt11_fck = {
1565 .name = "gpt11_fck",
1566 .parent = &sys_clkin_ck,
1567 .clksel = dmt1_clk_mux_sel,
1568 .init = &omap2_init_clksel_parent,
1569 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER11_CLKCTRL,
1570 .clksel_mask = OMAP4430_CLKSEL_MASK,
1571 .ops = &clkops_omap2_dflt,
1572 .recalc = &omap2_clksel_recalc,
1573 .enable_reg = OMAP4430_CM_L4PER_DMTIMER11_CLKCTRL,
1574 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1575 .clkdm_name = "l4_per_clkdm",
1576};
1577
1578/*
1579 * Merged cm2_dm2_mux into gptimer2
1580 * gptimer2 renamed temporarily into gpt2 to match OMAP3 convention
1581 */
1582static struct clk gpt2_fck = {
1583 .name = "gpt2_fck",
1584 .parent = &sys_clkin_ck,
1585 .clksel = dmt1_clk_mux_sel,
1586 .init = &omap2_init_clksel_parent,
1587 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER2_CLKCTRL,
1588 .clksel_mask = OMAP4430_CLKSEL_MASK,
1589 .ops = &clkops_omap2_dflt,
1590 .recalc = &omap2_clksel_recalc,
1591 .enable_reg = OMAP4430_CM_L4PER_DMTIMER2_CLKCTRL,
1592 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1593 .clkdm_name = "l4_per_clkdm",
1594};
1595
1596/*
1597 * Merged cm2_dm3_mux into gptimer3
1598 * gptimer3 renamed temporarily into gpt3 to match OMAP3 convention
1599 */
1600static struct clk gpt3_fck = {
1601 .name = "gpt3_fck",
1602 .parent = &sys_clkin_ck,
1603 .clksel = dmt1_clk_mux_sel,
1604 .init = &omap2_init_clksel_parent,
1605 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER3_CLKCTRL,
1606 .clksel_mask = OMAP4430_CLKSEL_MASK,
1607 .ops = &clkops_omap2_dflt,
1608 .recalc = &omap2_clksel_recalc,
1609 .enable_reg = OMAP4430_CM_L4PER_DMTIMER3_CLKCTRL,
1610 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1611 .clkdm_name = "l4_per_clkdm",
1612};
1613
1614/*
1615 * Merged cm2_dm4_mux into gptimer4
1616 * gptimer4 renamed temporarily into gpt4 to match OMAP3 convention
1617 */
1618static struct clk gpt4_fck = {
1619 .name = "gpt4_fck",
1620 .parent = &sys_clkin_ck,
1621 .clksel = dmt1_clk_mux_sel,
1622 .init = &omap2_init_clksel_parent,
1623 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER4_CLKCTRL,
1624 .clksel_mask = OMAP4430_CLKSEL_MASK,
1625 .ops = &clkops_omap2_dflt,
1626 .recalc = &omap2_clksel_recalc,
1627 .enable_reg = OMAP4430_CM_L4PER_DMTIMER4_CLKCTRL,
1628 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1629 .clkdm_name = "l4_per_clkdm",
1630};
1631
1632static const struct clksel timer5_sync_mux_sel[] = {
1633 { .parent = &syc_clk_div_ck, .rates = div_1_0_rates },
1634 { .parent = &sys_32k_ck, .rates = div_1_1_rates },
1635 { .parent = NULL }, 1607 { .parent = NULL },
1636}; 1608};
1637 1609
1638/* 1610/* Merged sgx_clk_mux into gpu */
1639 * Merged timer5_sync_mux into gptimer5 1611static struct clk gpu_fck = {
1640 * gptimer5 renamed temporarily into gpt5 to match OMAP3 convention 1612 .name = "gpu_fck",
1641 */ 1613 .parent = &dpll_core_m7_ck,
1642static struct clk gpt5_fck = { 1614 .clksel = sgx_clk_mux_sel,
1643 .name = "gpt5_fck",
1644 .parent = &syc_clk_div_ck,
1645 .clksel = timer5_sync_mux_sel,
1646 .init = &omap2_init_clksel_parent,
1647 .clksel_reg = OMAP4430_CM1_ABE_TIMER5_CLKCTRL,
1648 .clksel_mask = OMAP4430_CLKSEL_MASK,
1649 .ops = &clkops_omap2_dflt,
1650 .recalc = &omap2_clksel_recalc,
1651 .enable_reg = OMAP4430_CM1_ABE_TIMER5_CLKCTRL,
1652 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1653 .clkdm_name = "abe_clkdm",
1654};
1655
1656/*
1657 * Merged timer6_sync_mux into gptimer6
1658 * gptimer6 renamed temporarily into gpt6 to match OMAP3 convention
1659 */
1660static struct clk gpt6_fck = {
1661 .name = "gpt6_fck",
1662 .parent = &syc_clk_div_ck,
1663 .clksel = timer5_sync_mux_sel,
1664 .init = &omap2_init_clksel_parent,
1665 .clksel_reg = OMAP4430_CM1_ABE_TIMER6_CLKCTRL,
1666 .clksel_mask = OMAP4430_CLKSEL_MASK,
1667 .ops = &clkops_omap2_dflt,
1668 .recalc = &omap2_clksel_recalc,
1669 .enable_reg = OMAP4430_CM1_ABE_TIMER6_CLKCTRL,
1670 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1671 .clkdm_name = "abe_clkdm",
1672};
1673
1674/*
1675 * Merged timer7_sync_mux into gptimer7
1676 * gptimer7 renamed temporarily into gpt7 to match OMAP3 convention
1677 */
1678static struct clk gpt7_fck = {
1679 .name = "gpt7_fck",
1680 .parent = &syc_clk_div_ck,
1681 .clksel = timer5_sync_mux_sel,
1682 .init = &omap2_init_clksel_parent,
1683 .clksel_reg = OMAP4430_CM1_ABE_TIMER7_CLKCTRL,
1684 .clksel_mask = OMAP4430_CLKSEL_MASK,
1685 .ops = &clkops_omap2_dflt,
1686 .recalc = &omap2_clksel_recalc,
1687 .enable_reg = OMAP4430_CM1_ABE_TIMER7_CLKCTRL,
1688 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1689 .clkdm_name = "abe_clkdm",
1690};
1691
1692/*
1693 * Merged timer8_sync_mux into gptimer8
1694 * gptimer8 renamed temporarily into gpt8 to match OMAP3 convention
1695 */
1696static struct clk gpt8_fck = {
1697 .name = "gpt8_fck",
1698 .parent = &syc_clk_div_ck,
1699 .clksel = timer5_sync_mux_sel,
1700 .init = &omap2_init_clksel_parent,
1701 .clksel_reg = OMAP4430_CM1_ABE_TIMER8_CLKCTRL,
1702 .clksel_mask = OMAP4430_CLKSEL_MASK,
1703 .ops = &clkops_omap2_dflt,
1704 .recalc = &omap2_clksel_recalc,
1705 .enable_reg = OMAP4430_CM1_ABE_TIMER8_CLKCTRL,
1706 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1707 .clkdm_name = "abe_clkdm",
1708};
1709
1710/*
1711 * Merged cm2_dm9_mux into gptimer9
1712 * gptimer9 renamed temporarily into gpt9 to match OMAP3 convention
1713 */
1714static struct clk gpt9_fck = {
1715 .name = "gpt9_fck",
1716 .parent = &sys_clkin_ck,
1717 .clksel = dmt1_clk_mux_sel,
1718 .init = &omap2_init_clksel_parent, 1615 .init = &omap2_init_clksel_parent,
1719 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER9_CLKCTRL, 1616 .clksel_reg = OMAP4430_CM_GFX_GFX_CLKCTRL,
1720 .clksel_mask = OMAP4430_CLKSEL_MASK, 1617 .clksel_mask = OMAP4430_CLKSEL_SGX_FCLK_MASK,
1721 .ops = &clkops_omap2_dflt, 1618 .ops = &clkops_omap2_dflt,
1722 .recalc = &omap2_clksel_recalc, 1619 .recalc = &omap2_clksel_recalc,
1723 .enable_reg = OMAP4430_CM_L4PER_DMTIMER9_CLKCTRL, 1620 .enable_reg = OMAP4430_CM_GFX_GFX_CLKCTRL,
1724 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 1621 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1725 .clkdm_name = "l4_per_clkdm", 1622 .clkdm_name = "l3_gfx_clkdm",
1726}; 1623};
1727 1624
1728static struct clk hdq1w_fck = { 1625static struct clk hdq1w_fck = {
@@ -1735,11 +1632,16 @@ static struct clk hdq1w_fck = {
1735 .recalc = &followparent_recalc, 1632 .recalc = &followparent_recalc,
1736}; 1633};
1737 1634
1635static const struct clksel hsi_fclk_div[] = {
1636 { .parent = &dpll_per_m2x2_ck, .rates = div3_1to4_rates },
1637 { .parent = NULL },
1638};
1639
1738/* Merged hsi_fclk into hsi */ 1640/* Merged hsi_fclk into hsi */
1739static struct clk hsi_ick = { 1641static struct clk hsi_fck = {
1740 .name = "hsi_ick", 1642 .name = "hsi_fck",
1741 .parent = &dpll_per_m2x2_ck, 1643 .parent = &dpll_per_m2x2_ck,
1742 .clksel = per_sgx_fclk_div, 1644 .clksel = hsi_fclk_div,
1743 .clksel_reg = OMAP4430_CM_L3INIT_HSI_CLKCTRL, 1645 .clksel_reg = OMAP4430_CM_L3INIT_HSI_CLKCTRL,
1744 .clksel_mask = OMAP4430_CLKSEL_24_25_MASK, 1646 .clksel_mask = OMAP4430_CLKSEL_24_25_MASK,
1745 .ops = &clkops_omap2_dflt, 1647 .ops = &clkops_omap2_dflt,
@@ -1791,6 +1693,26 @@ static struct clk i2c4_fck = {
1791 .recalc = &followparent_recalc, 1693 .recalc = &followparent_recalc,
1792}; 1694};
1793 1695
1696static struct clk ipu_fck = {
1697 .name = "ipu_fck",
1698 .ops = &clkops_omap2_dflt,
1699 .enable_reg = OMAP4430_CM_DUCATI_DUCATI_CLKCTRL,
1700 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
1701 .clkdm_name = "ducati_clkdm",
1702 .parent = &ducati_clk_mux_ck,
1703 .recalc = &followparent_recalc,
1704};
1705
1706static struct clk iss_ctrlclk = {
1707 .name = "iss_ctrlclk",
1708 .ops = &clkops_omap2_dflt,
1709 .enable_reg = OMAP4430_CM_CAM_ISS_CLKCTRL,
1710 .enable_bit = OMAP4430_OPTFCLKEN_CTRLCLK_SHIFT,
1711 .clkdm_name = "iss_clkdm",
1712 .parent = &func_96m_fclk,
1713 .recalc = &followparent_recalc,
1714};
1715
1794static struct clk iss_fck = { 1716static struct clk iss_fck = {
1795 .name = "iss_fck", 1717 .name = "iss_fck",
1796 .ops = &clkops_omap2_dflt, 1718 .ops = &clkops_omap2_dflt,
@@ -1801,8 +1723,8 @@ static struct clk iss_fck = {
1801 .recalc = &followparent_recalc, 1723 .recalc = &followparent_recalc,
1802}; 1724};
1803 1725
1804static struct clk ivahd_ick = { 1726static struct clk iva_fck = {
1805 .name = "ivahd_ick", 1727 .name = "iva_fck",
1806 .ops = &clkops_omap2_dflt, 1728 .ops = &clkops_omap2_dflt,
1807 .enable_reg = OMAP4430_CM_IVAHD_IVAHD_CLKCTRL, 1729 .enable_reg = OMAP4430_CM_IVAHD_IVAHD_CLKCTRL,
1808 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1730 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -1811,8 +1733,8 @@ static struct clk ivahd_ick = {
1811 .recalc = &followparent_recalc, 1733 .recalc = &followparent_recalc,
1812}; 1734};
1813 1735
1814static struct clk keyboard_fck = { 1736static struct clk kbd_fck = {
1815 .name = "keyboard_fck", 1737 .name = "kbd_fck",
1816 .ops = &clkops_omap2_dflt, 1738 .ops = &clkops_omap2_dflt,
1817 .enable_reg = OMAP4430_CM_WKUP_KEYBOARD_CLKCTRL, 1739 .enable_reg = OMAP4430_CM_WKUP_KEYBOARD_CLKCTRL,
1818 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 1740 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
@@ -1821,8 +1743,8 @@ static struct clk keyboard_fck = {
1821 .recalc = &followparent_recalc, 1743 .recalc = &followparent_recalc,
1822}; 1744};
1823 1745
1824static struct clk l3_instr_interconnect_ick = { 1746static struct clk l3_instr_ick = {
1825 .name = "l3_instr_interconnect_ick", 1747 .name = "l3_instr_ick",
1826 .ops = &clkops_omap2_dflt, 1748 .ops = &clkops_omap2_dflt,
1827 .enable_reg = OMAP4430_CM_L3INSTR_L3_INSTR_CLKCTRL, 1749 .enable_reg = OMAP4430_CM_L3INSTR_L3_INSTR_CLKCTRL,
1828 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1750 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -1831,8 +1753,8 @@ static struct clk l3_instr_interconnect_ick = {
1831 .recalc = &followparent_recalc, 1753 .recalc = &followparent_recalc,
1832}; 1754};
1833 1755
1834static struct clk l3_interconnect_3_ick = { 1756static struct clk l3_main_3_ick = {
1835 .name = "l3_interconnect_3_ick", 1757 .name = "l3_main_3_ick",
1836 .ops = &clkops_omap2_dflt, 1758 .ops = &clkops_omap2_dflt,
1837 .enable_reg = OMAP4430_CM_L3INSTR_L3_3_CLKCTRL, 1759 .enable_reg = OMAP4430_CM_L3INSTR_L3_3_CLKCTRL,
1838 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 1760 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -2005,6 +1927,16 @@ static struct clk mcbsp4_fck = {
2005 .clkdm_name = "l4_per_clkdm", 1927 .clkdm_name = "l4_per_clkdm",
2006}; 1928};
2007 1929
1930static struct clk mcpdm_fck = {
1931 .name = "mcpdm_fck",
1932 .ops = &clkops_omap2_dflt,
1933 .enable_reg = OMAP4430_CM1_ABE_PDM_CLKCTRL,
1934 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
1935 .clkdm_name = "abe_clkdm",
1936 .parent = &pad_clks_ck,
1937 .recalc = &followparent_recalc,
1938};
1939
2008static struct clk mcspi1_fck = { 1940static struct clk mcspi1_fck = {
2009 .name = "mcspi1_fck", 1941 .name = "mcspi1_fck",
2010 .ops = &clkops_omap2_dflt, 1942 .ops = &clkops_omap2_dflt,
@@ -2105,33 +2037,33 @@ static struct clk mmc5_fck = {
2105 .recalc = &followparent_recalc, 2037 .recalc = &followparent_recalc,
2106}; 2038};
2107 2039
2108static struct clk ocp_wp1_ick = { 2040static struct clk ocp2scp_usb_phy_phy_48m = {
2109 .name = "ocp_wp1_ick", 2041 .name = "ocp2scp_usb_phy_phy_48m",
2110 .ops = &clkops_omap2_dflt, 2042 .ops = &clkops_omap2_dflt,
2111 .enable_reg = OMAP4430_CM_L3INSTR_OCP_WP1_CLKCTRL, 2043 .enable_reg = OMAP4430_CM_L3INIT_USBPHYOCP2SCP_CLKCTRL,
2112 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2044 .enable_bit = OMAP4430_OPTFCLKEN_PHY_48M_SHIFT,
2113 .clkdm_name = "l3_instr_clkdm", 2045 .clkdm_name = "l3_init_clkdm",
2114 .parent = &l3_div_ck, 2046 .parent = &func_48m_fclk,
2115 .recalc = &followparent_recalc, 2047 .recalc = &followparent_recalc,
2116}; 2048};
2117 2049
2118static struct clk pdm_fck = { 2050static struct clk ocp2scp_usb_phy_ick = {
2119 .name = "pdm_fck", 2051 .name = "ocp2scp_usb_phy_ick",
2120 .ops = &clkops_omap2_dflt, 2052 .ops = &clkops_omap2_dflt,
2121 .enable_reg = OMAP4430_CM1_ABE_PDM_CLKCTRL, 2053 .enable_reg = OMAP4430_CM_L3INIT_USBPHYOCP2SCP_CLKCTRL,
2122 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2054 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
2123 .clkdm_name = "abe_clkdm", 2055 .clkdm_name = "l3_init_clkdm",
2124 .parent = &pad_clks_ck, 2056 .parent = &l4_div_ck,
2125 .recalc = &followparent_recalc, 2057 .recalc = &followparent_recalc,
2126}; 2058};
2127 2059
2128static struct clk pkaeip29_fck = { 2060static struct clk ocp_wp_noc_ick = {
2129 .name = "pkaeip29_fck", 2061 .name = "ocp_wp_noc_ick",
2130 .ops = &clkops_omap2_dflt, 2062 .ops = &clkops_omap2_dflt,
2131 .enable_reg = OMAP4430_CM_L4SEC_PKAEIP29_CLKCTRL, 2063 .enable_reg = OMAP4430_CM_L3INSTR_OCP_WP1_CLKCTRL,
2132 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2064 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
2133 .clkdm_name = "l4_secure_clkdm", 2065 .clkdm_name = "l3_instr_clkdm",
2134 .parent = &l4_div_ck, 2066 .parent = &l3_div_ck,
2135 .recalc = &followparent_recalc, 2067 .recalc = &followparent_recalc,
2136}; 2068};
2137 2069
@@ -2145,8 +2077,8 @@ static struct clk rng_ick = {
2145 .recalc = &followparent_recalc, 2077 .recalc = &followparent_recalc,
2146}; 2078};
2147 2079
2148static struct clk sha2md51_fck = { 2080static struct clk sha2md5_fck = {
2149 .name = "sha2md51_fck", 2081 .name = "sha2md5_fck",
2150 .ops = &clkops_omap2_dflt, 2082 .ops = &clkops_omap2_dflt,
2151 .enable_reg = OMAP4430_CM_L4SEC_SHA2MD51_CLKCTRL, 2083 .enable_reg = OMAP4430_CM_L4SEC_SHA2MD51_CLKCTRL,
2152 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2084 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
@@ -2155,8 +2087,8 @@ static struct clk sha2md51_fck = {
2155 .recalc = &followparent_recalc, 2087 .recalc = &followparent_recalc,
2156}; 2088};
2157 2089
2158static struct clk sl2_ick = { 2090static struct clk sl2if_ick = {
2159 .name = "sl2_ick", 2091 .name = "sl2if_ick",
2160 .ops = &clkops_omap2_dflt, 2092 .ops = &clkops_omap2_dflt,
2161 .enable_reg = OMAP4430_CM_IVAHD_SL2_CLKCTRL, 2093 .enable_reg = OMAP4430_CM_IVAHD_SL2_CLKCTRL,
2162 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2094 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
@@ -2165,6 +2097,46 @@ static struct clk sl2_ick = {
2165 .recalc = &followparent_recalc, 2097 .recalc = &followparent_recalc,
2166}; 2098};
2167 2099
2100static struct clk slimbus1_fclk_1 = {
2101 .name = "slimbus1_fclk_1",
2102 .ops = &clkops_omap2_dflt,
2103 .enable_reg = OMAP4430_CM1_ABE_SLIMBUS_CLKCTRL,
2104 .enable_bit = OMAP4430_OPTFCLKEN_FCLK1_SHIFT,
2105 .clkdm_name = "abe_clkdm",
2106 .parent = &func_24m_clk,
2107 .recalc = &followparent_recalc,
2108};
2109
2110static struct clk slimbus1_fclk_0 = {
2111 .name = "slimbus1_fclk_0",
2112 .ops = &clkops_omap2_dflt,
2113 .enable_reg = OMAP4430_CM1_ABE_SLIMBUS_CLKCTRL,
2114 .enable_bit = OMAP4430_OPTFCLKEN_FCLK0_SHIFT,
2115 .clkdm_name = "abe_clkdm",
2116 .parent = &abe_24m_fclk,
2117 .recalc = &followparent_recalc,
2118};
2119
2120static struct clk slimbus1_fclk_2 = {
2121 .name = "slimbus1_fclk_2",
2122 .ops = &clkops_omap2_dflt,
2123 .enable_reg = OMAP4430_CM1_ABE_SLIMBUS_CLKCTRL,
2124 .enable_bit = OMAP4430_OPTFCLKEN_FCLK2_SHIFT,
2125 .clkdm_name = "abe_clkdm",
2126 .parent = &pad_clks_ck,
2127 .recalc = &followparent_recalc,
2128};
2129
2130static struct clk slimbus1_slimbus_clk = {
2131 .name = "slimbus1_slimbus_clk",
2132 .ops = &clkops_omap2_dflt,
2133 .enable_reg = OMAP4430_CM1_ABE_SLIMBUS_CLKCTRL,
2134 .enable_bit = OMAP4430_OPTFCLKEN_SLIMBUS_CLK_11_11_SHIFT,
2135 .clkdm_name = "abe_clkdm",
2136 .parent = &slimbus_clk,
2137 .recalc = &followparent_recalc,
2138};
2139
2168static struct clk slimbus1_fck = { 2140static struct clk slimbus1_fck = {
2169 .name = "slimbus1_fck", 2141 .name = "slimbus1_fck",
2170 .ops = &clkops_omap2_dflt, 2142 .ops = &clkops_omap2_dflt,
@@ -2175,6 +2147,36 @@ static struct clk slimbus1_fck = {
2175 .recalc = &followparent_recalc, 2147 .recalc = &followparent_recalc,
2176}; 2148};
2177 2149
2150static struct clk slimbus2_fclk_1 = {
2151 .name = "slimbus2_fclk_1",
2152 .ops = &clkops_omap2_dflt,
2153 .enable_reg = OMAP4430_CM_L4PER_SLIMBUS2_CLKCTRL,
2154 .enable_bit = OMAP4430_OPTFCLKEN_PERABE24M_GFCLK_SHIFT,
2155 .clkdm_name = "l4_per_clkdm",
2156 .parent = &per_abe_24m_fclk,
2157 .recalc = &followparent_recalc,
2158};
2159
2160static struct clk slimbus2_fclk_0 = {
2161 .name = "slimbus2_fclk_0",
2162 .ops = &clkops_omap2_dflt,
2163 .enable_reg = OMAP4430_CM_L4PER_SLIMBUS2_CLKCTRL,
2164 .enable_bit = OMAP4430_OPTFCLKEN_PER24MC_GFCLK_SHIFT,
2165 .clkdm_name = "l4_per_clkdm",
2166 .parent = &func_24mc_fclk,
2167 .recalc = &followparent_recalc,
2168};
2169
2170static struct clk slimbus2_slimbus_clk = {
2171 .name = "slimbus2_slimbus_clk",
2172 .ops = &clkops_omap2_dflt,
2173 .enable_reg = OMAP4430_CM_L4PER_SLIMBUS2_CLKCTRL,
2174 .enable_bit = OMAP4430_OPTFCLKEN_SLIMBUS_CLK_SHIFT,
2175 .clkdm_name = "l4_per_clkdm",
2176 .parent = &pad_slimbus_core_clks_ck,
2177 .recalc = &followparent_recalc,
2178};
2179
2178static struct clk slimbus2_fck = { 2180static struct clk slimbus2_fck = {
2179 .name = "slimbus2_fck", 2181 .name = "slimbus2_fck",
2180 .ops = &clkops_omap2_dflt, 2182 .ops = &clkops_omap2_dflt,
@@ -2185,8 +2187,8 @@ static struct clk slimbus2_fck = {
2185 .recalc = &followparent_recalc, 2187 .recalc = &followparent_recalc,
2186}; 2188};
2187 2189
2188static struct clk sr_core_fck = { 2190static struct clk smartreflex_core_fck = {
2189 .name = "sr_core_fck", 2191 .name = "smartreflex_core_fck",
2190 .ops = &clkops_omap2_dflt, 2192 .ops = &clkops_omap2_dflt,
2191 .enable_reg = OMAP4430_CM_ALWON_SR_CORE_CLKCTRL, 2193 .enable_reg = OMAP4430_CM_ALWON_SR_CORE_CLKCTRL,
2192 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2194 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
@@ -2195,8 +2197,8 @@ static struct clk sr_core_fck = {
2195 .recalc = &followparent_recalc, 2197 .recalc = &followparent_recalc,
2196}; 2198};
2197 2199
2198static struct clk sr_iva_fck = { 2200static struct clk smartreflex_iva_fck = {
2199 .name = "sr_iva_fck", 2201 .name = "smartreflex_iva_fck",
2200 .ops = &clkops_omap2_dflt, 2202 .ops = &clkops_omap2_dflt,
2201 .enable_reg = OMAP4430_CM_ALWON_SR_IVA_CLKCTRL, 2203 .enable_reg = OMAP4430_CM_ALWON_SR_IVA_CLKCTRL,
2202 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2204 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
@@ -2205,8 +2207,8 @@ static struct clk sr_iva_fck = {
2205 .recalc = &followparent_recalc, 2207 .recalc = &followparent_recalc,
2206}; 2208};
2207 2209
2208static struct clk sr_mpu_fck = { 2210static struct clk smartreflex_mpu_fck = {
2209 .name = "sr_mpu_fck", 2211 .name = "smartreflex_mpu_fck",
2210 .ops = &clkops_omap2_dflt, 2212 .ops = &clkops_omap2_dflt,
2211 .enable_reg = OMAP4430_CM_ALWON_SR_MPU_CLKCTRL, 2213 .enable_reg = OMAP4430_CM_ALWON_SR_MPU_CLKCTRL,
2212 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2214 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
@@ -2215,14 +2217,175 @@ static struct clk sr_mpu_fck = {
2215 .recalc = &followparent_recalc, 2217 .recalc = &followparent_recalc,
2216}; 2218};
2217 2219
2218static struct clk tesla_ick = { 2220/* Merged dmt1_clk_mux into timer1 */
2219 .name = "tesla_ick", 2221static struct clk timer1_fck = {
2222 .name = "timer1_fck",
2223 .parent = &sys_clkin_ck,
2224 .clksel = abe_dpll_bypass_clk_mux_sel,
2225 .init = &omap2_init_clksel_parent,
2226 .clksel_reg = OMAP4430_CM_WKUP_TIMER1_CLKCTRL,
2227 .clksel_mask = OMAP4430_CLKSEL_MASK,
2220 .ops = &clkops_omap2_dflt, 2228 .ops = &clkops_omap2_dflt,
2221 .enable_reg = OMAP4430_CM_TESLA_TESLA_CLKCTRL, 2229 .recalc = &omap2_clksel_recalc,
2222 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2230 .enable_reg = OMAP4430_CM_WKUP_TIMER1_CLKCTRL,
2223 .clkdm_name = "tesla_clkdm", 2231 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2224 .parent = &dpll_iva_m4_ck, 2232 .clkdm_name = "l4_wkup_clkdm",
2225 .recalc = &followparent_recalc, 2233};
2234
2235/* Merged cm2_dm10_mux into timer10 */
2236static struct clk timer10_fck = {
2237 .name = "timer10_fck",
2238 .parent = &sys_clkin_ck,
2239 .clksel = abe_dpll_bypass_clk_mux_sel,
2240 .init = &omap2_init_clksel_parent,
2241 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER10_CLKCTRL,
2242 .clksel_mask = OMAP4430_CLKSEL_MASK,
2243 .ops = &clkops_omap2_dflt,
2244 .recalc = &omap2_clksel_recalc,
2245 .enable_reg = OMAP4430_CM_L4PER_DMTIMER10_CLKCTRL,
2246 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2247 .clkdm_name = "l4_per_clkdm",
2248};
2249
2250/* Merged cm2_dm11_mux into timer11 */
2251static struct clk timer11_fck = {
2252 .name = "timer11_fck",
2253 .parent = &sys_clkin_ck,
2254 .clksel = abe_dpll_bypass_clk_mux_sel,
2255 .init = &omap2_init_clksel_parent,
2256 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER11_CLKCTRL,
2257 .clksel_mask = OMAP4430_CLKSEL_MASK,
2258 .ops = &clkops_omap2_dflt,
2259 .recalc = &omap2_clksel_recalc,
2260 .enable_reg = OMAP4430_CM_L4PER_DMTIMER11_CLKCTRL,
2261 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2262 .clkdm_name = "l4_per_clkdm",
2263};
2264
2265/* Merged cm2_dm2_mux into timer2 */
2266static struct clk timer2_fck = {
2267 .name = "timer2_fck",
2268 .parent = &sys_clkin_ck,
2269 .clksel = abe_dpll_bypass_clk_mux_sel,
2270 .init = &omap2_init_clksel_parent,
2271 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER2_CLKCTRL,
2272 .clksel_mask = OMAP4430_CLKSEL_MASK,
2273 .ops = &clkops_omap2_dflt,
2274 .recalc = &omap2_clksel_recalc,
2275 .enable_reg = OMAP4430_CM_L4PER_DMTIMER2_CLKCTRL,
2276 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2277 .clkdm_name = "l4_per_clkdm",
2278};
2279
2280/* Merged cm2_dm3_mux into timer3 */
2281static struct clk timer3_fck = {
2282 .name = "timer3_fck",
2283 .parent = &sys_clkin_ck,
2284 .clksel = abe_dpll_bypass_clk_mux_sel,
2285 .init = &omap2_init_clksel_parent,
2286 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER3_CLKCTRL,
2287 .clksel_mask = OMAP4430_CLKSEL_MASK,
2288 .ops = &clkops_omap2_dflt,
2289 .recalc = &omap2_clksel_recalc,
2290 .enable_reg = OMAP4430_CM_L4PER_DMTIMER3_CLKCTRL,
2291 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2292 .clkdm_name = "l4_per_clkdm",
2293};
2294
2295/* Merged cm2_dm4_mux into timer4 */
2296static struct clk timer4_fck = {
2297 .name = "timer4_fck",
2298 .parent = &sys_clkin_ck,
2299 .clksel = abe_dpll_bypass_clk_mux_sel,
2300 .init = &omap2_init_clksel_parent,
2301 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER4_CLKCTRL,
2302 .clksel_mask = OMAP4430_CLKSEL_MASK,
2303 .ops = &clkops_omap2_dflt,
2304 .recalc = &omap2_clksel_recalc,
2305 .enable_reg = OMAP4430_CM_L4PER_DMTIMER4_CLKCTRL,
2306 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2307 .clkdm_name = "l4_per_clkdm",
2308};
2309
2310static const struct clksel timer5_sync_mux_sel[] = {
2311 { .parent = &syc_clk_div_ck, .rates = div_1_0_rates },
2312 { .parent = &sys_32k_ck, .rates = div_1_1_rates },
2313 { .parent = NULL },
2314};
2315
2316/* Merged timer5_sync_mux into timer5 */
2317static struct clk timer5_fck = {
2318 .name = "timer5_fck",
2319 .parent = &syc_clk_div_ck,
2320 .clksel = timer5_sync_mux_sel,
2321 .init = &omap2_init_clksel_parent,
2322 .clksel_reg = OMAP4430_CM1_ABE_TIMER5_CLKCTRL,
2323 .clksel_mask = OMAP4430_CLKSEL_MASK,
2324 .ops = &clkops_omap2_dflt,
2325 .recalc = &omap2_clksel_recalc,
2326 .enable_reg = OMAP4430_CM1_ABE_TIMER5_CLKCTRL,
2327 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2328 .clkdm_name = "abe_clkdm",
2329};
2330
2331/* Merged timer6_sync_mux into timer6 */
2332static struct clk timer6_fck = {
2333 .name = "timer6_fck",
2334 .parent = &syc_clk_div_ck,
2335 .clksel = timer5_sync_mux_sel,
2336 .init = &omap2_init_clksel_parent,
2337 .clksel_reg = OMAP4430_CM1_ABE_TIMER6_CLKCTRL,
2338 .clksel_mask = OMAP4430_CLKSEL_MASK,
2339 .ops = &clkops_omap2_dflt,
2340 .recalc = &omap2_clksel_recalc,
2341 .enable_reg = OMAP4430_CM1_ABE_TIMER6_CLKCTRL,
2342 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2343 .clkdm_name = "abe_clkdm",
2344};
2345
2346/* Merged timer7_sync_mux into timer7 */
2347static struct clk timer7_fck = {
2348 .name = "timer7_fck",
2349 .parent = &syc_clk_div_ck,
2350 .clksel = timer5_sync_mux_sel,
2351 .init = &omap2_init_clksel_parent,
2352 .clksel_reg = OMAP4430_CM1_ABE_TIMER7_CLKCTRL,
2353 .clksel_mask = OMAP4430_CLKSEL_MASK,
2354 .ops = &clkops_omap2_dflt,
2355 .recalc = &omap2_clksel_recalc,
2356 .enable_reg = OMAP4430_CM1_ABE_TIMER7_CLKCTRL,
2357 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2358 .clkdm_name = "abe_clkdm",
2359};
2360
2361/* Merged timer8_sync_mux into timer8 */
2362static struct clk timer8_fck = {
2363 .name = "timer8_fck",
2364 .parent = &syc_clk_div_ck,
2365 .clksel = timer5_sync_mux_sel,
2366 .init = &omap2_init_clksel_parent,
2367 .clksel_reg = OMAP4430_CM1_ABE_TIMER8_CLKCTRL,
2368 .clksel_mask = OMAP4430_CLKSEL_MASK,
2369 .ops = &clkops_omap2_dflt,
2370 .recalc = &omap2_clksel_recalc,
2371 .enable_reg = OMAP4430_CM1_ABE_TIMER8_CLKCTRL,
2372 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2373 .clkdm_name = "abe_clkdm",
2374};
2375
2376/* Merged cm2_dm9_mux into timer9 */
2377static struct clk timer9_fck = {
2378 .name = "timer9_fck",
2379 .parent = &sys_clkin_ck,
2380 .clksel = abe_dpll_bypass_clk_mux_sel,
2381 .init = &omap2_init_clksel_parent,
2382 .clksel_reg = OMAP4430_CM_L4PER_DMTIMER9_CLKCTRL,
2383 .clksel_mask = OMAP4430_CLKSEL_MASK,
2384 .ops = &clkops_omap2_dflt,
2385 .recalc = &omap2_clksel_recalc,
2386 .enable_reg = OMAP4430_CM_L4PER_DMTIMER9_CLKCTRL,
2387 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2388 .clkdm_name = "l4_per_clkdm",
2226}; 2389};
2227 2390
2228static struct clk uart1_fck = { 2391static struct clk uart1_fck = {
@@ -2265,105 +2428,148 @@ static struct clk uart4_fck = {
2265 .recalc = &followparent_recalc, 2428 .recalc = &followparent_recalc,
2266}; 2429};
2267 2430
2268static struct clk unipro1_fck = { 2431static struct clk usb_host_fs_fck = {
2269 .name = "unipro1_fck", 2432 .name = "usb_host_fs_fck",
2270 .ops = &clkops_omap2_dflt, 2433 .ops = &clkops_omap2_dflt,
2271 .enable_reg = OMAP4430_CM_L3INIT_UNIPRO1_CLKCTRL, 2434 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_FS_CLKCTRL,
2272 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2435 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2273 .clkdm_name = "l3_init_clkdm", 2436 .clkdm_name = "l3_init_clkdm",
2274 .parent = &func_96m_fclk, 2437 .parent = &func_48mc_fclk,
2275 .recalc = &followparent_recalc, 2438 .recalc = &followparent_recalc,
2276}; 2439};
2277 2440
2278static struct clk usb_host_fck = { 2441static struct clk usb_host_hs_utmi_p3_clk = {
2279 .name = "usb_host_fck", 2442 .name = "usb_host_hs_utmi_p3_clk",
2280 .ops = &clkops_omap2_dflt, 2443 .ops = &clkops_omap2_dflt,
2281 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL, 2444 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2282 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2445 .enable_bit = OMAP4430_OPTFCLKEN_UTMI_P3_CLK_SHIFT,
2283 .clkdm_name = "l3_init_clkdm", 2446 .clkdm_name = "l3_init_clkdm",
2284 .parent = &init_60m_fclk, 2447 .parent = &init_60m_fclk,
2285 .recalc = &followparent_recalc, 2448 .recalc = &followparent_recalc,
2286}; 2449};
2287 2450
2288static struct clk usb_host_fs_fck = { 2451static struct clk usb_host_hs_hsic60m_p1_clk = {
2289 .name = "usb_host_fs_fck", 2452 .name = "usb_host_hs_hsic60m_p1_clk",
2290 .ops = &clkops_omap2_dflt, 2453 .ops = &clkops_omap2_dflt,
2291 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_FS_CLKCTRL, 2454 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2292 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2455 .enable_bit = OMAP4430_OPTFCLKEN_HSIC60M_P1_CLK_SHIFT,
2293 .clkdm_name = "l3_init_clkdm", 2456 .clkdm_name = "l3_init_clkdm",
2294 .parent = &func_48mc_fclk, 2457 .parent = &init_60m_fclk,
2295 .recalc = &followparent_recalc, 2458 .recalc = &followparent_recalc,
2296}; 2459};
2297 2460
2298static struct clk usb_otg_ick = { 2461static struct clk usb_host_hs_hsic60m_p2_clk = {
2299 .name = "usb_otg_ick", 2462 .name = "usb_host_hs_hsic60m_p2_clk",
2300 .ops = &clkops_omap2_dflt, 2463 .ops = &clkops_omap2_dflt,
2301 .enable_reg = OMAP4430_CM_L3INIT_USB_OTG_CLKCTRL, 2464 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2302 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2465 .enable_bit = OMAP4430_OPTFCLKEN_HSIC60M_P2_CLK_SHIFT,
2303 .clkdm_name = "l3_init_clkdm", 2466 .clkdm_name = "l3_init_clkdm",
2304 .parent = &l3_div_ck, 2467 .parent = &init_60m_fclk,
2305 .recalc = &followparent_recalc, 2468 .recalc = &followparent_recalc,
2306}; 2469};
2307 2470
2308static struct clk usb_tll_ick = { 2471static const struct clksel utmi_p1_gfclk_sel[] = {
2309 .name = "usb_tll_ick", 2472 { .parent = &init_60m_fclk, .rates = div_1_0_rates },
2473 { .parent = &xclk60mhsp1_ck, .rates = div_1_1_rates },
2474 { .parent = NULL },
2475};
2476
2477static struct clk utmi_p1_gfclk = {
2478 .name = "utmi_p1_gfclk",
2479 .parent = &init_60m_fclk,
2480 .clksel = utmi_p1_gfclk_sel,
2481 .init = &omap2_init_clksel_parent,
2482 .clksel_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2483 .clksel_mask = OMAP4430_CLKSEL_UTMI_P1_MASK,
2484 .ops = &clkops_null,
2485 .recalc = &omap2_clksel_recalc,
2486};
2487
2488static struct clk usb_host_hs_utmi_p1_clk = {
2489 .name = "usb_host_hs_utmi_p1_clk",
2310 .ops = &clkops_omap2_dflt, 2490 .ops = &clkops_omap2_dflt,
2311 .enable_reg = OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL, 2491 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2312 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2492 .enable_bit = OMAP4430_OPTFCLKEN_UTMI_P1_CLK_SHIFT,
2313 .clkdm_name = "l3_init_clkdm", 2493 .clkdm_name = "l3_init_clkdm",
2314 .parent = &l4_div_ck, 2494 .parent = &utmi_p1_gfclk,
2315 .recalc = &followparent_recalc, 2495 .recalc = &followparent_recalc,
2316}; 2496};
2317 2497
2318static struct clk usbphyocp2scp_ick = { 2498static const struct clksel utmi_p2_gfclk_sel[] = {
2319 .name = "usbphyocp2scp_ick", 2499 { .parent = &init_60m_fclk, .rates = div_1_0_rates },
2500 { .parent = &xclk60mhsp2_ck, .rates = div_1_1_rates },
2501 { .parent = NULL },
2502};
2503
2504static struct clk utmi_p2_gfclk = {
2505 .name = "utmi_p2_gfclk",
2506 .parent = &init_60m_fclk,
2507 .clksel = utmi_p2_gfclk_sel,
2508 .init = &omap2_init_clksel_parent,
2509 .clksel_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2510 .clksel_mask = OMAP4430_CLKSEL_UTMI_P2_MASK,
2511 .ops = &clkops_null,
2512 .recalc = &omap2_clksel_recalc,
2513};
2514
2515static struct clk usb_host_hs_utmi_p2_clk = {
2516 .name = "usb_host_hs_utmi_p2_clk",
2320 .ops = &clkops_omap2_dflt, 2517 .ops = &clkops_omap2_dflt,
2321 .enable_reg = OMAP4430_CM_L3INIT_USBPHYOCP2SCP_CLKCTRL, 2518 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2322 .enable_bit = OMAP4430_MODULEMODE_HWCTRL, 2519 .enable_bit = OMAP4430_OPTFCLKEN_UTMI_P2_CLK_SHIFT,
2323 .clkdm_name = "l3_init_clkdm", 2520 .clkdm_name = "l3_init_clkdm",
2324 .parent = &l4_div_ck, 2521 .parent = &utmi_p2_gfclk,
2325 .recalc = &followparent_recalc, 2522 .recalc = &followparent_recalc,
2326}; 2523};
2327 2524
2328static struct clk usim_fck = { 2525static struct clk usb_host_hs_hsic480m_p1_clk = {
2329 .name = "usim_fck", 2526 .name = "usb_host_hs_hsic480m_p1_clk",
2330 .ops = &clkops_omap2_dflt, 2527 .ops = &clkops_omap2_dflt,
2331 .enable_reg = OMAP4430_CM_WKUP_USIM_CLKCTRL, 2528 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2332 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2529 .enable_bit = OMAP4430_OPTFCLKEN_HSIC480M_P1_CLK_SHIFT,
2333 .clkdm_name = "l4_wkup_clkdm", 2530 .clkdm_name = "l3_init_clkdm",
2334 .parent = &sys_32k_ck, 2531 .parent = &dpll_usb_m2_ck,
2335 .recalc = &followparent_recalc, 2532 .recalc = &followparent_recalc,
2336}; 2533};
2337 2534
2338static struct clk wdt2_fck = { 2535static struct clk usb_host_hs_hsic480m_p2_clk = {
2339 .name = "wdt2_fck", 2536 .name = "usb_host_hs_hsic480m_p2_clk",
2340 .ops = &clkops_omap2_dflt, 2537 .ops = &clkops_omap2_dflt,
2341 .enable_reg = OMAP4430_CM_WKUP_WDT2_CLKCTRL, 2538 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2342 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2539 .enable_bit = OMAP4430_OPTFCLKEN_HSIC480M_P2_CLK_SHIFT,
2343 .clkdm_name = "l4_wkup_clkdm", 2540 .clkdm_name = "l3_init_clkdm",
2344 .parent = &sys_32k_ck, 2541 .parent = &dpll_usb_m2_ck,
2345 .recalc = &followparent_recalc, 2542 .recalc = &followparent_recalc,
2346}; 2543};
2347 2544
2348static struct clk wdt3_fck = { 2545static struct clk usb_host_hs_func48mclk = {
2349 .name = "wdt3_fck", 2546 .name = "usb_host_hs_func48mclk",
2350 .ops = &clkops_omap2_dflt, 2547 .ops = &clkops_omap2_dflt,
2351 .enable_reg = OMAP4430_CM1_ABE_WDT3_CLKCTRL, 2548 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2549 .enable_bit = OMAP4430_OPTFCLKEN_FUNC48MCLK_SHIFT,
2550 .clkdm_name = "l3_init_clkdm",
2551 .parent = &func_48mc_fclk,
2552 .recalc = &followparent_recalc,
2553};
2554
2555static struct clk usb_host_hs_fck = {
2556 .name = "usb_host_hs_fck",
2557 .ops = &clkops_omap2_dflt,
2558 .enable_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL,
2352 .enable_bit = OMAP4430_MODULEMODE_SWCTRL, 2559 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2353 .clkdm_name = "abe_clkdm", 2560 .clkdm_name = "l3_init_clkdm",
2354 .parent = &sys_32k_ck, 2561 .parent = &init_60m_fclk,
2355 .recalc = &followparent_recalc, 2562 .recalc = &followparent_recalc,
2356}; 2563};
2357 2564
2358/* Remaining optional clocks */
2359static const struct clksel otg_60m_gfclk_sel[] = { 2565static const struct clksel otg_60m_gfclk_sel[] = {
2360 { .parent = &utmi_phy_clkout_ck, .rates = div_1_0_rates }, 2566 { .parent = &utmi_phy_clkout_ck, .rates = div_1_0_rates },
2361 { .parent = &xclk60motg_ck, .rates = div_1_1_rates }, 2567 { .parent = &xclk60motg_ck, .rates = div_1_1_rates },
2362 { .parent = NULL }, 2568 { .parent = NULL },
2363}; 2569};
2364 2570
2365static struct clk otg_60m_gfclk_ck = { 2571static struct clk otg_60m_gfclk = {
2366 .name = "otg_60m_gfclk_ck", 2572 .name = "otg_60m_gfclk",
2367 .parent = &utmi_phy_clkout_ck, 2573 .parent = &utmi_phy_clkout_ck,
2368 .clksel = otg_60m_gfclk_sel, 2574 .clksel = otg_60m_gfclk_sel,
2369 .init = &omap2_init_clksel_parent, 2575 .init = &omap2_init_clksel_parent,
@@ -2373,38 +2579,74 @@ static struct clk otg_60m_gfclk_ck = {
2373 .recalc = &omap2_clksel_recalc, 2579 .recalc = &omap2_clksel_recalc,
2374}; 2580};
2375 2581
2376static const struct clksel stm_clk_div_div[] = { 2582static struct clk usb_otg_hs_xclk = {
2377 { .parent = &pmd_stm_clock_mux_ck, .rates = div3_1to4_rates }, 2583 .name = "usb_otg_hs_xclk",
2378 { .parent = NULL }, 2584 .ops = &clkops_omap2_dflt,
2585 .enable_reg = OMAP4430_CM_L3INIT_USB_OTG_CLKCTRL,
2586 .enable_bit = OMAP4430_OPTFCLKEN_XCLK_SHIFT,
2587 .clkdm_name = "l3_init_clkdm",
2588 .parent = &otg_60m_gfclk,
2589 .recalc = &followparent_recalc,
2379}; 2590};
2380 2591
2381static struct clk stm_clk_div_ck = { 2592static struct clk usb_otg_hs_ick = {
2382 .name = "stm_clk_div_ck", 2593 .name = "usb_otg_hs_ick",
2383 .parent = &pmd_stm_clock_mux_ck, 2594 .ops = &clkops_omap2_dflt,
2384 .clksel = stm_clk_div_div, 2595 .enable_reg = OMAP4430_CM_L3INIT_USB_OTG_CLKCTRL,
2385 .clksel_reg = OMAP4430_CM_EMU_DEBUGSS_CLKCTRL, 2596 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
2386 .clksel_mask = OMAP4430_CLKSEL_PMD_STM_CLK_MASK, 2597 .clkdm_name = "l3_init_clkdm",
2387 .ops = &clkops_null, 2598 .parent = &l3_div_ck,
2388 .recalc = &omap2_clksel_recalc, 2599 .recalc = &followparent_recalc,
2389 .round_rate = &omap2_clksel_round_rate,
2390 .set_rate = &omap2_clksel_set_rate,
2391}; 2600};
2392 2601
2393static const struct clksel trace_clk_div_div[] = { 2602static struct clk usb_phy_cm_clk32k = {
2394 { .parent = &pmd_trace_clk_mux_ck, .rates = div3_1to4_rates }, 2603 .name = "usb_phy_cm_clk32k",
2395 { .parent = NULL }, 2604 .ops = &clkops_omap2_dflt,
2605 .enable_reg = OMAP4430_CM_ALWON_USBPHY_CLKCTRL,
2606 .enable_bit = OMAP4430_OPTFCLKEN_CLK32K_SHIFT,
2607 .clkdm_name = "l4_ao_clkdm",
2608 .parent = &sys_32k_ck,
2609 .recalc = &followparent_recalc,
2396}; 2610};
2397 2611
2398static struct clk trace_clk_div_ck = { 2612static struct clk usb_tll_hs_usb_ch2_clk = {
2399 .name = "trace_clk_div_ck", 2613 .name = "usb_tll_hs_usb_ch2_clk",
2400 .parent = &pmd_trace_clk_mux_ck, 2614 .ops = &clkops_omap2_dflt,
2401 .clksel = trace_clk_div_div, 2615 .enable_reg = OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL,
2402 .clksel_reg = OMAP4430_CM_EMU_DEBUGSS_CLKCTRL, 2616 .enable_bit = OMAP4430_OPTFCLKEN_USB_CH2_CLK_SHIFT,
2403 .clksel_mask = OMAP4430_CLKSEL_PMD_TRACE_CLK_MASK, 2617 .clkdm_name = "l3_init_clkdm",
2404 .ops = &clkops_null, 2618 .parent = &init_60m_fclk,
2405 .recalc = &omap2_clksel_recalc, 2619 .recalc = &followparent_recalc,
2406 .round_rate = &omap2_clksel_round_rate, 2620};
2407 .set_rate = &omap2_clksel_set_rate, 2621
2622static struct clk usb_tll_hs_usb_ch0_clk = {
2623 .name = "usb_tll_hs_usb_ch0_clk",
2624 .ops = &clkops_omap2_dflt,
2625 .enable_reg = OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL,
2626 .enable_bit = OMAP4430_OPTFCLKEN_USB_CH0_CLK_SHIFT,
2627 .clkdm_name = "l3_init_clkdm",
2628 .parent = &init_60m_fclk,
2629 .recalc = &followparent_recalc,
2630};
2631
2632static struct clk usb_tll_hs_usb_ch1_clk = {
2633 .name = "usb_tll_hs_usb_ch1_clk",
2634 .ops = &clkops_omap2_dflt,
2635 .enable_reg = OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL,
2636 .enable_bit = OMAP4430_OPTFCLKEN_USB_CH1_CLK_SHIFT,
2637 .clkdm_name = "l3_init_clkdm",
2638 .parent = &init_60m_fclk,
2639 .recalc = &followparent_recalc,
2640};
2641
2642static struct clk usb_tll_hs_ick = {
2643 .name = "usb_tll_hs_ick",
2644 .ops = &clkops_omap2_dflt,
2645 .enable_reg = OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL,
2646 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
2647 .clkdm_name = "l3_init_clkdm",
2648 .parent = &l4_div_ck,
2649 .recalc = &followparent_recalc,
2408}; 2650};
2409 2651
2410static const struct clksel_rate div2_14to18_rates[] = { 2652static const struct clksel_rate div2_14to18_rates[] = {
@@ -2418,8 +2660,8 @@ static const struct clksel usim_fclk_div[] = {
2418 { .parent = NULL }, 2660 { .parent = NULL },
2419}; 2661};
2420 2662
2421static struct clk usim_fclk = { 2663static struct clk usim_ck = {
2422 .name = "usim_fclk", 2664 .name = "usim_ck",
2423 .parent = &dpll_per_m4_ck, 2665 .parent = &dpll_per_m4_ck,
2424 .clksel = usim_fclk_div, 2666 .clksel = usim_fclk_div,
2425 .clksel_reg = OMAP4430_CM_WKUP_USIM_CLKCTRL, 2667 .clksel_reg = OMAP4430_CM_WKUP_USIM_CLKCTRL,
@@ -2430,38 +2672,79 @@ static struct clk usim_fclk = {
2430 .set_rate = &omap2_clksel_set_rate, 2672 .set_rate = &omap2_clksel_set_rate,
2431}; 2673};
2432 2674
2433static const struct clksel utmi_p1_gfclk_sel[] = { 2675static struct clk usim_fclk = {
2434 { .parent = &init_60m_fclk, .rates = div_1_0_rates }, 2676 .name = "usim_fclk",
2435 { .parent = &xclk60mhsp1_ck, .rates = div_1_1_rates }, 2677 .ops = &clkops_omap2_dflt,
2678 .enable_reg = OMAP4430_CM_WKUP_USIM_CLKCTRL,
2679 .enable_bit = OMAP4430_OPTFCLKEN_FCLK_SHIFT,
2680 .clkdm_name = "l4_wkup_clkdm",
2681 .parent = &usim_ck,
2682 .recalc = &followparent_recalc,
2683};
2684
2685static struct clk usim_fck = {
2686 .name = "usim_fck",
2687 .ops = &clkops_omap2_dflt,
2688 .enable_reg = OMAP4430_CM_WKUP_USIM_CLKCTRL,
2689 .enable_bit = OMAP4430_MODULEMODE_HWCTRL,
2690 .clkdm_name = "l4_wkup_clkdm",
2691 .parent = &sys_32k_ck,
2692 .recalc = &followparent_recalc,
2693};
2694
2695static struct clk wd_timer2_fck = {
2696 .name = "wd_timer2_fck",
2697 .ops = &clkops_omap2_dflt,
2698 .enable_reg = OMAP4430_CM_WKUP_WDT2_CLKCTRL,
2699 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2700 .clkdm_name = "l4_wkup_clkdm",
2701 .parent = &sys_32k_ck,
2702 .recalc = &followparent_recalc,
2703};
2704
2705static struct clk wd_timer3_fck = {
2706 .name = "wd_timer3_fck",
2707 .ops = &clkops_omap2_dflt,
2708 .enable_reg = OMAP4430_CM1_ABE_WDT3_CLKCTRL,
2709 .enable_bit = OMAP4430_MODULEMODE_SWCTRL,
2710 .clkdm_name = "abe_clkdm",
2711 .parent = &sys_32k_ck,
2712 .recalc = &followparent_recalc,
2713};
2714
2715/* Remaining optional clocks */
2716static const struct clksel stm_clk_div_div[] = {
2717 { .parent = &pmd_stm_clock_mux_ck, .rates = div3_1to4_rates },
2436 { .parent = NULL }, 2718 { .parent = NULL },
2437}; 2719};
2438 2720
2439static struct clk utmi_p1_gfclk_ck = { 2721static struct clk stm_clk_div_ck = {
2440 .name = "utmi_p1_gfclk_ck", 2722 .name = "stm_clk_div_ck",
2441 .parent = &init_60m_fclk, 2723 .parent = &pmd_stm_clock_mux_ck,
2442 .clksel = utmi_p1_gfclk_sel, 2724 .clksel = stm_clk_div_div,
2443 .init = &omap2_init_clksel_parent, 2725 .clksel_reg = OMAP4430_CM_EMU_DEBUGSS_CLKCTRL,
2444 .clksel_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL, 2726 .clksel_mask = OMAP4430_CLKSEL_PMD_STM_CLK_MASK,
2445 .clksel_mask = OMAP4430_CLKSEL_UTMI_P1_MASK,
2446 .ops = &clkops_null, 2727 .ops = &clkops_null,
2447 .recalc = &omap2_clksel_recalc, 2728 .recalc = &omap2_clksel_recalc,
2729 .round_rate = &omap2_clksel_round_rate,
2730 .set_rate = &omap2_clksel_set_rate,
2448}; 2731};
2449 2732
2450static const struct clksel utmi_p2_gfclk_sel[] = { 2733static const struct clksel trace_clk_div_div[] = {
2451 { .parent = &init_60m_fclk, .rates = div_1_0_rates }, 2734 { .parent = &pmd_trace_clk_mux_ck, .rates = div3_1to4_rates },
2452 { .parent = &xclk60mhsp2_ck, .rates = div_1_1_rates },
2453 { .parent = NULL }, 2735 { .parent = NULL },
2454}; 2736};
2455 2737
2456static struct clk utmi_p2_gfclk_ck = { 2738static struct clk trace_clk_div_ck = {
2457 .name = "utmi_p2_gfclk_ck", 2739 .name = "trace_clk_div_ck",
2458 .parent = &init_60m_fclk, 2740 .parent = &pmd_trace_clk_mux_ck,
2459 .clksel = utmi_p2_gfclk_sel, 2741 .clksel = trace_clk_div_div,
2460 .init = &omap2_init_clksel_parent, 2742 .clksel_reg = OMAP4430_CM_EMU_DEBUGSS_CLKCTRL,
2461 .clksel_reg = OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL, 2743 .clksel_mask = OMAP4430_CLKSEL_PMD_TRACE_CLK_MASK,
2462 .clksel_mask = OMAP4430_CLKSEL_UTMI_P2_MASK,
2463 .ops = &clkops_null, 2744 .ops = &clkops_null,
2464 .recalc = &omap2_clksel_recalc, 2745 .recalc = &omap2_clksel_recalc,
2746 .round_rate = &omap2_clksel_round_rate,
2747 .set_rate = &omap2_clksel_set_rate,
2465}; 2748};
2466 2749
2467/* 2750/*
@@ -2483,11 +2766,12 @@ static struct omap_clk omap44xx_clks[] = {
2483 CLK(NULL, "virt_27000000_ck", &virt_27000000_ck, CK_443X), 2766 CLK(NULL, "virt_27000000_ck", &virt_27000000_ck, CK_443X),
2484 CLK(NULL, "virt_38400000_ck", &virt_38400000_ck, CK_443X), 2767 CLK(NULL, "virt_38400000_ck", &virt_38400000_ck, CK_443X),
2485 CLK(NULL, "sys_clkin_ck", &sys_clkin_ck, CK_443X), 2768 CLK(NULL, "sys_clkin_ck", &sys_clkin_ck, CK_443X),
2769 CLK(NULL, "tie_low_clock_ck", &tie_low_clock_ck, CK_443X),
2486 CLK(NULL, "utmi_phy_clkout_ck", &utmi_phy_clkout_ck, CK_443X), 2770 CLK(NULL, "utmi_phy_clkout_ck", &utmi_phy_clkout_ck, CK_443X),
2487 CLK(NULL, "xclk60mhsp1_ck", &xclk60mhsp1_ck, CK_443X), 2771 CLK(NULL, "xclk60mhsp1_ck", &xclk60mhsp1_ck, CK_443X),
2488 CLK(NULL, "xclk60mhsp2_ck", &xclk60mhsp2_ck, CK_443X), 2772 CLK(NULL, "xclk60mhsp2_ck", &xclk60mhsp2_ck, CK_443X),
2489 CLK(NULL, "xclk60motg_ck", &xclk60motg_ck, CK_443X), 2773 CLK(NULL, "xclk60motg_ck", &xclk60motg_ck, CK_443X),
2490 CLK(NULL, "dpll_sys_ref_clk", &dpll_sys_ref_clk, CK_443X), 2774 CLK(NULL, "abe_dpll_bypass_clk_mux_ck", &abe_dpll_bypass_clk_mux_ck, CK_443X),
2491 CLK(NULL, "abe_dpll_refclk_mux_ck", &abe_dpll_refclk_mux_ck, CK_443X), 2775 CLK(NULL, "abe_dpll_refclk_mux_ck", &abe_dpll_refclk_mux_ck, CK_443X),
2492 CLK(NULL, "dpll_abe_ck", &dpll_abe_ck, CK_443X), 2776 CLK(NULL, "dpll_abe_ck", &dpll_abe_ck, CK_443X),
2493 CLK(NULL, "dpll_abe_m2x2_ck", &dpll_abe_m2x2_ck, CK_443X), 2777 CLK(NULL, "dpll_abe_m2x2_ck", &dpll_abe_m2x2_ck, CK_443X),
@@ -2557,46 +2841,48 @@ static struct omap_clk omap44xx_clks[] = {
2557 CLK(NULL, "aes1_fck", &aes1_fck, CK_443X), 2841 CLK(NULL, "aes1_fck", &aes1_fck, CK_443X),
2558 CLK(NULL, "aes2_fck", &aes2_fck, CK_443X), 2842 CLK(NULL, "aes2_fck", &aes2_fck, CK_443X),
2559 CLK(NULL, "aess_fck", &aess_fck, CK_443X), 2843 CLK(NULL, "aess_fck", &aess_fck, CK_443X),
2560 CLK(NULL, "cust_efuse_fck", &cust_efuse_fck, CK_443X), 2844 CLK(NULL, "bandgap_fclk", &bandgap_fclk, CK_443X),
2561 CLK(NULL, "des3des_fck", &des3des_fck, CK_443X), 2845 CLK(NULL, "des3des_fck", &des3des_fck, CK_443X),
2562 CLK(NULL, "dmic_sync_mux_ck", &dmic_sync_mux_ck, CK_443X), 2846 CLK(NULL, "dmic_sync_mux_ck", &dmic_sync_mux_ck, CK_443X),
2563 CLK(NULL, "dmic_fck", &dmic_fck, CK_443X), 2847 CLK(NULL, "dmic_fck", &dmic_fck, CK_443X),
2848 CLK(NULL, "dsp_fck", &dsp_fck, CK_443X),
2849 CLK(NULL, "dss_sys_clk", &dss_sys_clk, CK_443X),
2850 CLK(NULL, "dss_tv_clk", &dss_tv_clk, CK_443X),
2851 CLK(NULL, "dss_dss_clk", &dss_dss_clk, CK_443X),
2852 CLK(NULL, "dss_48mhz_clk", &dss_48mhz_clk, CK_443X),
2564 CLK(NULL, "dss_fck", &dss_fck, CK_443X), 2853 CLK(NULL, "dss_fck", &dss_fck, CK_443X),
2565 CLK(NULL, "ducati_ick", &ducati_ick, CK_443X), 2854 CLK(NULL, "efuse_ctrl_cust_fck", &efuse_ctrl_cust_fck, CK_443X),
2566 CLK(NULL, "emif1_ick", &emif1_ick, CK_443X), 2855 CLK(NULL, "emif1_fck", &emif1_fck, CK_443X),
2567 CLK(NULL, "emif2_ick", &emif2_ick, CK_443X), 2856 CLK(NULL, "emif2_fck", &emif2_fck, CK_443X),
2568 CLK(NULL, "fdif_fck", &fdif_fck, CK_443X), 2857 CLK(NULL, "fdif_fck", &fdif_fck, CK_443X),
2569 CLK(NULL, "per_sgx_fclk", &per_sgx_fclk, CK_443X), 2858 CLK(NULL, "fpka_fck", &fpka_fck, CK_443X),
2570 CLK(NULL, "gfx_fck", &gfx_fck, CK_443X), 2859 CLK(NULL, "gpio1_dbck", &gpio1_dbclk, CK_443X),
2571 CLK(NULL, "gpio1_ick", &gpio1_ick, CK_443X), 2860 CLK(NULL, "gpio1_ick", &gpio1_ick, CK_443X),
2861 CLK(NULL, "gpio2_dbck", &gpio2_dbclk, CK_443X),
2572 CLK(NULL, "gpio2_ick", &gpio2_ick, CK_443X), 2862 CLK(NULL, "gpio2_ick", &gpio2_ick, CK_443X),
2863 CLK(NULL, "gpio3_dbck", &gpio3_dbclk, CK_443X),
2573 CLK(NULL, "gpio3_ick", &gpio3_ick, CK_443X), 2864 CLK(NULL, "gpio3_ick", &gpio3_ick, CK_443X),
2865 CLK(NULL, "gpio4_dbck", &gpio4_dbclk, CK_443X),
2574 CLK(NULL, "gpio4_ick", &gpio4_ick, CK_443X), 2866 CLK(NULL, "gpio4_ick", &gpio4_ick, CK_443X),
2867 CLK(NULL, "gpio5_dbck", &gpio5_dbclk, CK_443X),
2575 CLK(NULL, "gpio5_ick", &gpio5_ick, CK_443X), 2868 CLK(NULL, "gpio5_ick", &gpio5_ick, CK_443X),
2869 CLK(NULL, "gpio6_dbck", &gpio6_dbclk, CK_443X),
2576 CLK(NULL, "gpio6_ick", &gpio6_ick, CK_443X), 2870 CLK(NULL, "gpio6_ick", &gpio6_ick, CK_443X),
2577 CLK(NULL, "gpmc_ick", &gpmc_ick, CK_443X), 2871 CLK(NULL, "gpmc_ick", &gpmc_ick, CK_443X),
2578 CLK(NULL, "gpt1_fck", &gpt1_fck, CK_443X), 2872 CLK(NULL, "gpu_fck", &gpu_fck, CK_443X),
2579 CLK(NULL, "gpt10_fck", &gpt10_fck, CK_443X),
2580 CLK(NULL, "gpt11_fck", &gpt11_fck, CK_443X),
2581 CLK(NULL, "gpt2_fck", &gpt2_fck, CK_443X),
2582 CLK(NULL, "gpt3_fck", &gpt3_fck, CK_443X),
2583 CLK(NULL, "gpt4_fck", &gpt4_fck, CK_443X),
2584 CLK(NULL, "gpt5_fck", &gpt5_fck, CK_443X),
2585 CLK(NULL, "gpt6_fck", &gpt6_fck, CK_443X),
2586 CLK(NULL, "gpt7_fck", &gpt7_fck, CK_443X),
2587 CLK(NULL, "gpt8_fck", &gpt8_fck, CK_443X),
2588 CLK(NULL, "gpt9_fck", &gpt9_fck, CK_443X),
2589 CLK("omap2_hdq.0", "fck", &hdq1w_fck, CK_443X), 2873 CLK("omap2_hdq.0", "fck", &hdq1w_fck, CK_443X),
2590 CLK(NULL, "hsi_ick", &hsi_ick, CK_443X), 2874 CLK(NULL, "hsi_fck", &hsi_fck, CK_443X),
2591 CLK("i2c_omap.1", "fck", &i2c1_fck, CK_443X), 2875 CLK("i2c_omap.1", "fck", &i2c1_fck, CK_443X),
2592 CLK("i2c_omap.2", "fck", &i2c2_fck, CK_443X), 2876 CLK("i2c_omap.2", "fck", &i2c2_fck, CK_443X),
2593 CLK("i2c_omap.3", "fck", &i2c3_fck, CK_443X), 2877 CLK("i2c_omap.3", "fck", &i2c3_fck, CK_443X),
2594 CLK("i2c_omap.4", "fck", &i2c4_fck, CK_443X), 2878 CLK("i2c_omap.4", "fck", &i2c4_fck, CK_443X),
2879 CLK(NULL, "ipu_fck", &ipu_fck, CK_443X),
2880 CLK(NULL, "iss_ctrlclk", &iss_ctrlclk, CK_443X),
2595 CLK(NULL, "iss_fck", &iss_fck, CK_443X), 2881 CLK(NULL, "iss_fck", &iss_fck, CK_443X),
2596 CLK(NULL, "ivahd_ick", &ivahd_ick, CK_443X), 2882 CLK(NULL, "iva_fck", &iva_fck, CK_443X),
2597 CLK(NULL, "keyboard_fck", &keyboard_fck, CK_443X), 2883 CLK(NULL, "kbd_fck", &kbd_fck, CK_443X),
2598 CLK(NULL, "l3_instr_interconnect_ick", &l3_instr_interconnect_ick, CK_443X), 2884 CLK(NULL, "l3_instr_ick", &l3_instr_ick, CK_443X),
2599 CLK(NULL, "l3_interconnect_3_ick", &l3_interconnect_3_ick, CK_443X), 2885 CLK(NULL, "l3_main_3_ick", &l3_main_3_ick, CK_443X),
2600 CLK(NULL, "mcasp_sync_mux_ck", &mcasp_sync_mux_ck, CK_443X), 2886 CLK(NULL, "mcasp_sync_mux_ck", &mcasp_sync_mux_ck, CK_443X),
2601 CLK(NULL, "mcasp_fck", &mcasp_fck, CK_443X), 2887 CLK(NULL, "mcasp_fck", &mcasp_fck, CK_443X),
2602 CLK(NULL, "mcbsp1_sync_mux_ck", &mcbsp1_sync_mux_ck, CK_443X), 2888 CLK(NULL, "mcbsp1_sync_mux_ck", &mcbsp1_sync_mux_ck, CK_443X),
@@ -2607,6 +2893,7 @@ static struct omap_clk omap44xx_clks[] = {
2607 CLK("omap-mcbsp.3", "fck", &mcbsp3_fck, CK_443X), 2893 CLK("omap-mcbsp.3", "fck", &mcbsp3_fck, CK_443X),
2608 CLK(NULL, "mcbsp4_sync_mux_ck", &mcbsp4_sync_mux_ck, CK_443X), 2894 CLK(NULL, "mcbsp4_sync_mux_ck", &mcbsp4_sync_mux_ck, CK_443X),
2609 CLK("omap-mcbsp.4", "fck", &mcbsp4_fck, CK_443X), 2895 CLK("omap-mcbsp.4", "fck", &mcbsp4_fck, CK_443X),
2896 CLK(NULL, "mcpdm_fck", &mcpdm_fck, CK_443X),
2610 CLK("omap2_mcspi.1", "fck", &mcspi1_fck, CK_443X), 2897 CLK("omap2_mcspi.1", "fck", &mcspi1_fck, CK_443X),
2611 CLK("omap2_mcspi.2", "fck", &mcspi2_fck, CK_443X), 2898 CLK("omap2_mcspi.2", "fck", &mcspi2_fck, CK_443X),
2612 CLK("omap2_mcspi.3", "fck", &mcspi3_fck, CK_443X), 2899 CLK("omap2_mcspi.3", "fck", &mcspi3_fck, CK_443X),
@@ -2616,43 +2903,66 @@ static struct omap_clk omap44xx_clks[] = {
2616 CLK("mmci-omap-hs.2", "fck", &mmc3_fck, CK_443X), 2903 CLK("mmci-omap-hs.2", "fck", &mmc3_fck, CK_443X),
2617 CLK("mmci-omap-hs.3", "fck", &mmc4_fck, CK_443X), 2904 CLK("mmci-omap-hs.3", "fck", &mmc4_fck, CK_443X),
2618 CLK("mmci-omap-hs.4", "fck", &mmc5_fck, CK_443X), 2905 CLK("mmci-omap-hs.4", "fck", &mmc5_fck, CK_443X),
2619 CLK(NULL, "ocp_wp1_ick", &ocp_wp1_ick, CK_443X), 2906 CLK(NULL, "ocp2scp_usb_phy_phy_48m", &ocp2scp_usb_phy_phy_48m, CK_443X),
2620 CLK(NULL, "pdm_fck", &pdm_fck, CK_443X), 2907 CLK(NULL, "ocp2scp_usb_phy_ick", &ocp2scp_usb_phy_ick, CK_443X),
2621 CLK(NULL, "pkaeip29_fck", &pkaeip29_fck, CK_443X), 2908 CLK(NULL, "ocp_wp_noc_ick", &ocp_wp_noc_ick, CK_443X),
2622 CLK("omap_rng", "ick", &rng_ick, CK_443X), 2909 CLK("omap_rng", "ick", &rng_ick, CK_443X),
2623 CLK(NULL, "sha2md51_fck", &sha2md51_fck, CK_443X), 2910 CLK(NULL, "sha2md5_fck", &sha2md5_fck, CK_443X),
2624 CLK(NULL, "sl2_ick", &sl2_ick, CK_443X), 2911 CLK(NULL, "sl2if_ick", &sl2if_ick, CK_443X),
2912 CLK(NULL, "slimbus1_fclk_1", &slimbus1_fclk_1, CK_443X),
2913 CLK(NULL, "slimbus1_fclk_0", &slimbus1_fclk_0, CK_443X),
2914 CLK(NULL, "slimbus1_fclk_2", &slimbus1_fclk_2, CK_443X),
2915 CLK(NULL, "slimbus1_slimbus_clk", &slimbus1_slimbus_clk, CK_443X),
2625 CLK(NULL, "slimbus1_fck", &slimbus1_fck, CK_443X), 2916 CLK(NULL, "slimbus1_fck", &slimbus1_fck, CK_443X),
2917 CLK(NULL, "slimbus2_fclk_1", &slimbus2_fclk_1, CK_443X),
2918 CLK(NULL, "slimbus2_fclk_0", &slimbus2_fclk_0, CK_443X),
2919 CLK(NULL, "slimbus2_slimbus_clk", &slimbus2_slimbus_clk, CK_443X),
2626 CLK(NULL, "slimbus2_fck", &slimbus2_fck, CK_443X), 2920 CLK(NULL, "slimbus2_fck", &slimbus2_fck, CK_443X),
2627 CLK(NULL, "sr_core_fck", &sr_core_fck, CK_443X), 2921 CLK(NULL, "smartreflex_core_fck", &smartreflex_core_fck, CK_443X),
2628 CLK(NULL, "sr_iva_fck", &sr_iva_fck, CK_443X), 2922 CLK(NULL, "smartreflex_iva_fck", &smartreflex_iva_fck, CK_443X),
2629 CLK(NULL, "sr_mpu_fck", &sr_mpu_fck, CK_443X), 2923 CLK(NULL, "smartreflex_mpu_fck", &smartreflex_mpu_fck, CK_443X),
2630 CLK(NULL, "tesla_ick", &tesla_ick, CK_443X), 2924 CLK(NULL, "gpt1_fck", &timer1_fck, CK_443X),
2925 CLK(NULL, "gpt10_fck", &timer10_fck, CK_443X),
2926 CLK(NULL, "gpt11_fck", &timer11_fck, CK_443X),
2927 CLK(NULL, "gpt2_fck", &timer2_fck, CK_443X),
2928 CLK(NULL, "gpt3_fck", &timer3_fck, CK_443X),
2929 CLK(NULL, "gpt4_fck", &timer4_fck, CK_443X),
2930 CLK(NULL, "gpt5_fck", &timer5_fck, CK_443X),
2931 CLK(NULL, "gpt6_fck", &timer6_fck, CK_443X),
2932 CLK(NULL, "gpt7_fck", &timer7_fck, CK_443X),
2933 CLK(NULL, "gpt8_fck", &timer8_fck, CK_443X),
2934 CLK(NULL, "gpt9_fck", &timer9_fck, CK_443X),
2631 CLK(NULL, "uart1_fck", &uart1_fck, CK_443X), 2935 CLK(NULL, "uart1_fck", &uart1_fck, CK_443X),
2632 CLK(NULL, "uart2_fck", &uart2_fck, CK_443X), 2936 CLK(NULL, "uart2_fck", &uart2_fck, CK_443X),
2633 CLK(NULL, "uart3_fck", &uart3_fck, CK_443X), 2937 CLK(NULL, "uart3_fck", &uart3_fck, CK_443X),
2634 CLK(NULL, "uart4_fck", &uart4_fck, CK_443X), 2938 CLK(NULL, "uart4_fck", &uart4_fck, CK_443X),
2635 CLK(NULL, "unipro1_fck", &unipro1_fck, CK_443X),
2636 CLK(NULL, "usb_host_fck", &usb_host_fck, CK_443X),
2637 CLK(NULL, "usb_host_fs_fck", &usb_host_fs_fck, CK_443X), 2939 CLK(NULL, "usb_host_fs_fck", &usb_host_fs_fck, CK_443X),
2638 CLK("musb_hdrc", "ick", &usb_otg_ick, CK_443X), 2940 CLK(NULL, "usb_host_hs_utmi_p3_clk", &usb_host_hs_utmi_p3_clk, CK_443X),
2639 CLK(NULL, "usb_tll_ick", &usb_tll_ick, CK_443X), 2941 CLK(NULL, "usb_host_hs_hsic60m_p1_clk", &usb_host_hs_hsic60m_p1_clk, CK_443X),
2640 CLK(NULL, "usbphyocp2scp_ick", &usbphyocp2scp_ick, CK_443X), 2942 CLK(NULL, "usb_host_hs_hsic60m_p2_clk", &usb_host_hs_hsic60m_p2_clk, CK_443X),
2943 CLK(NULL, "utmi_p1_gfclk", &utmi_p1_gfclk, CK_443X),
2944 CLK(NULL, "usb_host_hs_utmi_p1_clk", &usb_host_hs_utmi_p1_clk, CK_443X),
2945 CLK(NULL, "utmi_p2_gfclk", &utmi_p2_gfclk, CK_443X),
2946 CLK(NULL, "usb_host_hs_utmi_p2_clk", &usb_host_hs_utmi_p2_clk, CK_443X),
2947 CLK(NULL, "usb_host_hs_hsic480m_p1_clk", &usb_host_hs_hsic480m_p1_clk, CK_443X),
2948 CLK(NULL, "usb_host_hs_hsic480m_p2_clk", &usb_host_hs_hsic480m_p2_clk, CK_443X),
2949 CLK(NULL, "usb_host_hs_func48mclk", &usb_host_hs_func48mclk, CK_443X),
2950 CLK(NULL, "usb_host_hs_fck", &usb_host_hs_fck, CK_443X),
2951 CLK(NULL, "otg_60m_gfclk", &otg_60m_gfclk, CK_443X),
2952 CLK(NULL, "usb_otg_hs_xclk", &usb_otg_hs_xclk, CK_443X),
2953 CLK("musb_hdrc", "ick", &usb_otg_hs_ick, CK_443X),
2954 CLK(NULL, "usb_phy_cm_clk32k", &usb_phy_cm_clk32k, CK_443X),
2955 CLK(NULL, "usb_tll_hs_usb_ch2_clk", &usb_tll_hs_usb_ch2_clk, CK_443X),
2956 CLK(NULL, "usb_tll_hs_usb_ch0_clk", &usb_tll_hs_usb_ch0_clk, CK_443X),
2957 CLK(NULL, "usb_tll_hs_usb_ch1_clk", &usb_tll_hs_usb_ch1_clk, CK_443X),
2958 CLK(NULL, "usb_tll_hs_ick", &usb_tll_hs_ick, CK_443X),
2959 CLK(NULL, "usim_ck", &usim_ck, CK_443X),
2960 CLK(NULL, "usim_fclk", &usim_fclk, CK_443X),
2641 CLK(NULL, "usim_fck", &usim_fck, CK_443X), 2961 CLK(NULL, "usim_fck", &usim_fck, CK_443X),
2642 CLK("omap_wdt", "fck", &wdt2_fck, CK_443X), 2962 CLK("omap_wdt", "fck", &wd_timer2_fck, CK_443X),
2643 CLK(NULL, "wdt3_fck", &wdt3_fck, CK_443X), 2963 CLK(NULL, "wd_timer3_fck", &wd_timer3_fck, CK_443X),
2644 CLK(NULL, "otg_60m_gfclk_ck", &otg_60m_gfclk_ck, CK_443X),
2645 CLK(NULL, "stm_clk_div_ck", &stm_clk_div_ck, CK_443X), 2964 CLK(NULL, "stm_clk_div_ck", &stm_clk_div_ck, CK_443X),
2646 CLK(NULL, "trace_clk_div_ck", &trace_clk_div_ck, CK_443X), 2965 CLK(NULL, "trace_clk_div_ck", &trace_clk_div_ck, CK_443X),
2647 CLK(NULL, "usim_fclk", &usim_fclk, CK_443X),
2648 CLK(NULL, "utmi_p1_gfclk_ck", &utmi_p1_gfclk_ck, CK_443X),
2649 CLK(NULL, "utmi_p2_gfclk_ck", &utmi_p2_gfclk_ck, CK_443X),
2650 CLK(NULL, "gpio1_dbck", &dummy_ck, CK_443X),
2651 CLK(NULL, "gpio2_dbck", &dummy_ck, CK_443X),
2652 CLK(NULL, "gpio3_dbck", &dummy_ck, CK_443X),
2653 CLK(NULL, "gpio4_dbck", &dummy_ck, CK_443X),
2654 CLK(NULL, "gpio5_dbck", &dummy_ck, CK_443X),
2655 CLK(NULL, "gpio6_dbck", &dummy_ck, CK_443X),
2656 CLK(NULL, "gpmc_ck", &dummy_ck, CK_443X), 2966 CLK(NULL, "gpmc_ck", &dummy_ck, CK_443X),
2657 CLK(NULL, "gpt1_ick", &dummy_ck, CK_443X), 2967 CLK(NULL, "gpt1_ick", &dummy_ck, CK_443X),
2658 CLK(NULL, "gpt2_ick", &dummy_ck, CK_443X), 2968 CLK(NULL, "gpt2_ick", &dummy_ck, CK_443X),
@@ -2669,19 +2979,19 @@ static struct omap_clk omap44xx_clks[] = {
2669 CLK("i2c_omap.2", "ick", &dummy_ck, CK_443X), 2979 CLK("i2c_omap.2", "ick", &dummy_ck, CK_443X),
2670 CLK("i2c_omap.3", "ick", &dummy_ck, CK_443X), 2980 CLK("i2c_omap.3", "ick", &dummy_ck, CK_443X),
2671 CLK("i2c_omap.4", "ick", &dummy_ck, CK_443X), 2981 CLK("i2c_omap.4", "ick", &dummy_ck, CK_443X),
2982 CLK("mmci-omap-hs.0", "ick", &dummy_ck, CK_443X),
2983 CLK("mmci-omap-hs.1", "ick", &dummy_ck, CK_443X),
2984 CLK("mmci-omap-hs.2", "ick", &dummy_ck, CK_443X),
2985 CLK("mmci-omap-hs.3", "ick", &dummy_ck, CK_443X),
2986 CLK("mmci-omap-hs.4", "ick", &dummy_ck, CK_443X),
2672 CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_443X), 2987 CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_443X),
2673 CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_443X), 2988 CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_443X),
2674 CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_443X), 2989 CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_443X),
2675 CLK("omap-mcbsp.4", "ick", &dummy_ck, CK_443X), 2990 CLK("omap-mcbsp.4", "ick", &dummy_ck, CK_443X),
2676 CLK("omap2_mcspi.1", "ick", &dummy_ck, CK_443X), 2991 CLK("omap2_mcspi.1", "ick", &dummy_ck, CK_443X),
2677 CLK("omap2_mcspi.2", "ick", &dummy_ck, CK_443X), 2992 CLK("omap2_mcspi.2", "ick", &dummy_ck, CK_443X),
2678 CLK("omap2_mcspi.3", "ick", &dummy_ck, CK_443X), 2993 CLK("omap2_mcspi.3", "ick", &dummy_ck, CK_443X),
2679 CLK("omap2_mcspi.4", "ick", &dummy_ck, CK_443X), 2994 CLK("omap2_mcspi.4", "ick", &dummy_ck, CK_443X),
2680 CLK("mmci-omap-hs.0", "ick", &dummy_ck, CK_443X),
2681 CLK("mmci-omap-hs.1", "ick", &dummy_ck, CK_443X),
2682 CLK("mmci-omap-hs.2", "ick", &dummy_ck, CK_443X),
2683 CLK("mmci-omap-hs.3", "ick", &dummy_ck, CK_443X),
2684 CLK("mmci-omap-hs.4", "ick", &dummy_ck, CK_443X),
2685 CLK(NULL, "uart1_ick", &dummy_ck, CK_443X), 2995 CLK(NULL, "uart1_ick", &dummy_ck, CK_443X),
2686 CLK(NULL, "uart2_ick", &dummy_ck, CK_443X), 2996 CLK(NULL, "uart2_ick", &dummy_ck, CK_443X),
2687 CLK(NULL, "uart3_ick", &dummy_ck, CK_443X), 2997 CLK(NULL, "uart3_ick", &dummy_ck, CK_443X),
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 5d80cb897489..6fb61b1a0d46 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -258,97 +258,6 @@ static void _omap2_clkdm_set_hwsup(struct clockdomain *clkdm, int enable)
258 258
259} 259}
260 260
261/**
262 * _init_wkdep_usecount - initialize wkdep usecounts to match hardware
263 * @clkdm: clockdomain to initialize wkdep usecounts
264 *
265 * Initialize the wakeup dependency usecount variables for clockdomain @clkdm.
266 * If a wakeup dependency is present in the hardware, the usecount will be
267 * set to 1; otherwise, it will be set to 0. Software should clear all
268 * software wakeup dependencies prior to calling this function if it wishes
269 * to ensure that all usecounts start at 0. No return value.
270 */
271static void _init_wkdep_usecount(struct clockdomain *clkdm)
272{
273 u32 v;
274 struct clkdm_dep *cd;
275
276 if (!clkdm->wkdep_srcs)
277 return;
278
279 for (cd = clkdm->wkdep_srcs; cd->clkdm_name; cd++) {
280 if (!omap_chip_is(cd->omap_chip))
281 continue;
282
283 if (!cd->clkdm && cd->clkdm_name)
284 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
285
286 if (!cd->clkdm) {
287 WARN(!cd->clkdm, "clockdomain: %s: wkdep clkdm %s not "
288 "found\n", clkdm->name, cd->clkdm_name);
289 continue;
290 }
291
292 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
293 PM_WKDEP,
294 (1 << cd->clkdm->dep_bit));
295
296 if (v)
297 pr_debug("clockdomain: %s: wakeup dependency already "
298 "set to wake up when %s wakes\n",
299 clkdm->name, cd->clkdm->name);
300
301 atomic_set(&cd->wkdep_usecount, (v) ? 1 : 0);
302 }
303}
304
305/**
306 * _init_sleepdep_usecount - initialize sleepdep usecounts to match hardware
307 * @clkdm: clockdomain to initialize sleepdep usecounts
308 *
309 * Initialize the sleep dependency usecount variables for clockdomain @clkdm.
310 * If a sleep dependency is present in the hardware, the usecount will be
311 * set to 1; otherwise, it will be set to 0. Software should clear all
312 * software sleep dependencies prior to calling this function if it wishes
313 * to ensure that all usecounts start at 0. No return value.
314 */
315static void _init_sleepdep_usecount(struct clockdomain *clkdm)
316{
317 u32 v;
318 struct clkdm_dep *cd;
319
320 if (!cpu_is_omap34xx())
321 return;
322
323 if (!clkdm->sleepdep_srcs)
324 return;
325
326 for (cd = clkdm->sleepdep_srcs; cd->clkdm_name; cd++) {
327 if (!omap_chip_is(cd->omap_chip))
328 continue;
329
330 if (!cd->clkdm && cd->clkdm_name)
331 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
332
333 if (!cd->clkdm) {
334 WARN(!cd->clkdm, "clockdomain: %s: sleepdep clkdm %s "
335 "not found\n", clkdm->name, cd->clkdm_name);
336 continue;
337 }
338
339 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
340 OMAP3430_CM_SLEEPDEP,
341 (1 << cd->clkdm->dep_bit));
342
343 if (v)
344 pr_debug("clockdomain: %s: sleep dependency already "
345 "set to prevent from idling until %s "
346 "idles\n", clkdm->name, cd->clkdm->name);
347
348 atomic_set(&cd->sleepdep_usecount, (v) ? 1 : 0);
349 }
350};
351
352/* Public functions */ 261/* Public functions */
353 262
354/** 263/**
@@ -379,12 +288,17 @@ void clkdm_init(struct clockdomain **clkdms,
379 _autodep_lookup(autodep); 288 _autodep_lookup(autodep);
380 289
381 /* 290 /*
382 * Ensure that the *dep_usecount registers reflect the current 291 * Put all clockdomains into software-supervised mode; PM code
383 * state of the PRCM. 292 * should later enable hardware-supervised mode as appropriate
384 */ 293 */
385 list_for_each_entry(clkdm, &clkdm_list, node) { 294 list_for_each_entry(clkdm, &clkdm_list, node) {
386 _init_wkdep_usecount(clkdm); 295 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
387 _init_sleepdep_usecount(clkdm); 296 omap2_clkdm_wakeup(clkdm);
297 else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
298 omap2_clkdm_deny_idle(clkdm);
299
300 clkdm_clear_all_wkdeps(clkdm);
301 clkdm_clear_all_sleepdeps(clkdm);
388 } 302 }
389} 303}
390 304
@@ -592,6 +506,9 @@ int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
592 if (!omap_chip_is(cd->omap_chip)) 506 if (!omap_chip_is(cd->omap_chip))
593 continue; 507 continue;
594 508
509 if (!cd->clkdm && cd->clkdm_name)
510 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
511
595 /* PRM accesses are slow, so minimize them */ 512 /* PRM accesses are slow, so minimize them */
596 mask |= 1 << cd->clkdm->dep_bit; 513 mask |= 1 << cd->clkdm->dep_bit;
597 atomic_set(&cd->wkdep_usecount, 0); 514 atomic_set(&cd->wkdep_usecount, 0);
@@ -752,6 +669,9 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
752 if (!omap_chip_is(cd->omap_chip)) 669 if (!omap_chip_is(cd->omap_chip))
753 continue; 670 continue;
754 671
672 if (!cd->clkdm && cd->clkdm_name)
673 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
674
755 /* PRM accesses are slow, so minimize them */ 675 /* PRM accesses are slow, so minimize them */
756 mask |= 1 << cd->clkdm->dep_bit; 676 mask |= 1 << cd->clkdm->dep_bit;
757 atomic_set(&cd->sleepdep_usecount, 0); 677 atomic_set(&cd->sleepdep_usecount, 0);
diff --git a/arch/arm/mach-omap2/cm-regbits-34xx.h b/arch/arm/mach-omap2/cm-regbits-34xx.h
index fe82b79d5f3b..4f959a7d881c 100644
--- a/arch/arm/mach-omap2/cm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-34xx.h
@@ -649,6 +649,8 @@
649#define OMAP3430_ST_MCBSP2_MASK (1 << 0) 649#define OMAP3430_ST_MCBSP2_MASK (1 << 0)
650 650
651/* CM_AUTOIDLE_PER */ 651/* CM_AUTOIDLE_PER */
652#define OMAP3630_AUTO_UART4_MASK (1 << 18)
653#define OMAP3630_AUTO_UART4_SHIFT 18
652#define OMAP3430_AUTO_GPIO6_MASK (1 << 17) 654#define OMAP3430_AUTO_GPIO6_MASK (1 << 17)
653#define OMAP3430_AUTO_GPIO6_SHIFT 17 655#define OMAP3430_AUTO_GPIO6_SHIFT 17
654#define OMAP3430_AUTO_GPIO5_MASK (1 << 16) 656#define OMAP3430_AUTO_GPIO5_MASK (1 << 16)
diff --git a/arch/arm/mach-omap2/cm-regbits-44xx.h b/arch/arm/mach-omap2/cm-regbits-44xx.h
index ac8458e43252..0b72be433776 100644
--- a/arch/arm/mach-omap2/cm-regbits-44xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-44xx.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * OMAP44xx Clock Management register bits 2 * OMAP44xx Clock Management register bits
3 * 3 *
4 * Copyright (C) 2009 Texas Instruments, Inc. 4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 * Copyright (C) 2009 Nokia Corporation 5 * Copyright (C) 2009-2010 Nokia Corporation
6 * 6 *
7 * Paul Walmsley (paul@pwsan.com) 7 * Paul Walmsley (paul@pwsan.com)
8 * Rajendra Nayak (rnayak@ti.com) 8 * Rajendra Nayak (rnayak@ti.com)
@@ -25,453 +25,459 @@
25#include "cm.h" 25#include "cm.h"
26 26
27 27
28/* Used by CM_L3_1_DYNAMICDEP, CM_MPU_DYNAMICDEP, CM_TESLA_DYNAMICDEP */ 28/*
29 * Used by CM_L3_1_DYNAMICDEP, CM_L3_1_DYNAMICDEP_RESTORE, CM_MPU_DYNAMICDEP,
30 * CM_TESLA_DYNAMICDEP
31 */
29#define OMAP4430_ABE_DYNDEP_SHIFT 3 32#define OMAP4430_ABE_DYNDEP_SHIFT 3
30#define OMAP4430_ABE_DYNDEP_MASK BITFIELD(3, 3) 33#define OMAP4430_ABE_DYNDEP_MASK (1 << 3)
31 34
32/* 35/*
33 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 36 * Used by CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE, CM_DUCATI_STATICDEP,
34 * CM_L3INIT_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP, 37 * CM_L3INIT_STATICDEP, CM_MPU_STATICDEP, CM_SDMA_STATICDEP,
35 * CM_TESLA_STATICDEP 38 * CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
36 */ 39 */
37#define OMAP4430_ABE_STATDEP_SHIFT 3 40#define OMAP4430_ABE_STATDEP_SHIFT 3
38#define OMAP4430_ABE_STATDEP_MASK BITFIELD(3, 3) 41#define OMAP4430_ABE_STATDEP_MASK (1 << 3)
39 42
40/* Used by CM_L4CFG_DYNAMICDEP */ 43/* Used by CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE */
41#define OMAP4430_ALWONCORE_DYNDEP_SHIFT 16 44#define OMAP4430_ALWONCORE_DYNDEP_SHIFT 16
42#define OMAP4430_ALWONCORE_DYNDEP_MASK BITFIELD(16, 16) 45#define OMAP4430_ALWONCORE_DYNDEP_MASK (1 << 16)
43 46
44/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_TESLA_STATICDEP */ 47/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_TESLA_STATICDEP */
45#define OMAP4430_ALWONCORE_STATDEP_SHIFT 16 48#define OMAP4430_ALWONCORE_STATDEP_SHIFT 16
46#define OMAP4430_ALWONCORE_STATDEP_MASK BITFIELD(16, 16) 49#define OMAP4430_ALWONCORE_STATDEP_MASK (1 << 16)
47 50
48/* 51/*
49 * Used by CM_AUTOIDLE_DPLL_PER, CM_AUTOIDLE_DPLL_UNIPRO, CM_AUTOIDLE_DPLL_USB, 52 * Used by CM_AUTOIDLE_DPLL_ABE, CM_AUTOIDLE_DPLL_CORE,
50 * CM_AUTOIDLE_DPLL_CORE_RESTORE, CM_AUTOIDLE_DPLL_ABE, CM_AUTOIDLE_DPLL_CORE, 53 * CM_AUTOIDLE_DPLL_CORE_RESTORE, CM_AUTOIDLE_DPLL_DDRPHY,
51 * CM_AUTOIDLE_DPLL_DDRPHY, CM_AUTOIDLE_DPLL_IVA, CM_AUTOIDLE_DPLL_MPU 54 * CM_AUTOIDLE_DPLL_IVA, CM_AUTOIDLE_DPLL_MPU, CM_AUTOIDLE_DPLL_PER,
55 * CM_AUTOIDLE_DPLL_UNIPRO, CM_AUTOIDLE_DPLL_USB
52 */ 56 */
53#define OMAP4430_AUTO_DPLL_MODE_SHIFT 0 57#define OMAP4430_AUTO_DPLL_MODE_SHIFT 0
54#define OMAP4430_AUTO_DPLL_MODE_MASK BITFIELD(0, 2) 58#define OMAP4430_AUTO_DPLL_MODE_MASK (0x7 << 0)
55 59
56/* Used by CM_L4CFG_DYNAMICDEP */ 60/* Used by CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE */
57#define OMAP4430_CEFUSE_DYNDEP_SHIFT 17 61#define OMAP4430_CEFUSE_DYNDEP_SHIFT 17
58#define OMAP4430_CEFUSE_DYNDEP_MASK BITFIELD(17, 17) 62#define OMAP4430_CEFUSE_DYNDEP_MASK (1 << 17)
59 63
60/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_TESLA_STATICDEP */ 64/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_TESLA_STATICDEP */
61#define OMAP4430_CEFUSE_STATDEP_SHIFT 17 65#define OMAP4430_CEFUSE_STATDEP_SHIFT 17
62#define OMAP4430_CEFUSE_STATDEP_MASK BITFIELD(17, 17) 66#define OMAP4430_CEFUSE_STATDEP_MASK (1 << 17)
63 67
64/* Used by CM1_ABE_CLKSTCTRL */ 68/* Used by CM1_ABE_CLKSTCTRL */
65#define OMAP4430_CLKACTIVITY_ABE_24M_GFCLK_SHIFT 13 69#define OMAP4430_CLKACTIVITY_ABE_24M_GFCLK_SHIFT 13
66#define OMAP4430_CLKACTIVITY_ABE_24M_GFCLK_MASK BITFIELD(13, 13) 70#define OMAP4430_CLKACTIVITY_ABE_24M_GFCLK_MASK (1 << 13)
67 71
68/* Used by CM1_ABE_CLKSTCTRL */ 72/* Used by CM1_ABE_CLKSTCTRL */
69#define OMAP4430_CLKACTIVITY_ABE_ALWON_32K_CLK_SHIFT 12 73#define OMAP4430_CLKACTIVITY_ABE_ALWON_32K_CLK_SHIFT 12
70#define OMAP4430_CLKACTIVITY_ABE_ALWON_32K_CLK_MASK BITFIELD(12, 12) 74#define OMAP4430_CLKACTIVITY_ABE_ALWON_32K_CLK_MASK (1 << 12)
71 75
72/* Used by CM_WKUP_CLKSTCTRL */ 76/* Used by CM_WKUP_CLKSTCTRL */
73#define OMAP4430_CLKACTIVITY_ABE_LP_CLK_SHIFT 9 77#define OMAP4430_CLKACTIVITY_ABE_LP_CLK_SHIFT 9
74#define OMAP4430_CLKACTIVITY_ABE_LP_CLK_MASK BITFIELD(9, 9) 78#define OMAP4430_CLKACTIVITY_ABE_LP_CLK_MASK (1 << 9)
75 79
76/* Used by CM1_ABE_CLKSTCTRL */ 80/* Used by CM1_ABE_CLKSTCTRL */
77#define OMAP4430_CLKACTIVITY_ABE_SYSCLK_SHIFT 11 81#define OMAP4430_CLKACTIVITY_ABE_SYSCLK_SHIFT 11
78#define OMAP4430_CLKACTIVITY_ABE_SYSCLK_MASK BITFIELD(11, 11) 82#define OMAP4430_CLKACTIVITY_ABE_SYSCLK_MASK (1 << 11)
79 83
80/* Used by CM1_ABE_CLKSTCTRL */ 84/* Used by CM1_ABE_CLKSTCTRL */
81#define OMAP4430_CLKACTIVITY_ABE_X2_CLK_SHIFT 8 85#define OMAP4430_CLKACTIVITY_ABE_X2_CLK_SHIFT 8
82#define OMAP4430_CLKACTIVITY_ABE_X2_CLK_MASK BITFIELD(8, 8) 86#define OMAP4430_CLKACTIVITY_ABE_X2_CLK_MASK (1 << 8)
83 87
84/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 88/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
85#define OMAP4430_CLKACTIVITY_ASYNC_DLL_CLK_SHIFT 11 89#define OMAP4430_CLKACTIVITY_ASYNC_DLL_CLK_SHIFT 11
86#define OMAP4430_CLKACTIVITY_ASYNC_DLL_CLK_MASK BITFIELD(11, 11) 90#define OMAP4430_CLKACTIVITY_ASYNC_DLL_CLK_MASK (1 << 11)
87 91
88/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 92/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
89#define OMAP4430_CLKACTIVITY_ASYNC_PHY1_CLK_SHIFT 12 93#define OMAP4430_CLKACTIVITY_ASYNC_PHY1_CLK_SHIFT 12
90#define OMAP4430_CLKACTIVITY_ASYNC_PHY1_CLK_MASK BITFIELD(12, 12) 94#define OMAP4430_CLKACTIVITY_ASYNC_PHY1_CLK_MASK (1 << 12)
91 95
92/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 96/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
93#define OMAP4430_CLKACTIVITY_ASYNC_PHY2_CLK_SHIFT 13 97#define OMAP4430_CLKACTIVITY_ASYNC_PHY2_CLK_SHIFT 13
94#define OMAP4430_CLKACTIVITY_ASYNC_PHY2_CLK_MASK BITFIELD(13, 13) 98#define OMAP4430_CLKACTIVITY_ASYNC_PHY2_CLK_MASK (1 << 13)
95 99
96/* Used by CM_CAM_CLKSTCTRL */ 100/* Used by CM_CAM_CLKSTCTRL */
97#define OMAP4430_CLKACTIVITY_CAM_PHY_CTRL_GCLK_SHIFT 9 101#define OMAP4430_CLKACTIVITY_CAM_PHY_CTRL_GCLK_SHIFT 9
98#define OMAP4430_CLKACTIVITY_CAM_PHY_CTRL_GCLK_MASK BITFIELD(9, 9) 102#define OMAP4430_CLKACTIVITY_CAM_PHY_CTRL_GCLK_MASK (1 << 9)
103
104/* Used by CM_ALWON_CLKSTCTRL */
105#define OMAP4430_CLKACTIVITY_CORE_ALWON_32K_GFCLK_SHIFT 12
106#define OMAP4430_CLKACTIVITY_CORE_ALWON_32K_GFCLK_MASK (1 << 12)
99 107
100/* Used by CM_EMU_CLKSTCTRL */ 108/* Used by CM_EMU_CLKSTCTRL */
101#define OMAP4430_CLKACTIVITY_CORE_DPLL_EMU_CLK_SHIFT 9 109#define OMAP4430_CLKACTIVITY_CORE_DPLL_EMU_CLK_SHIFT 9
102#define OMAP4430_CLKACTIVITY_CORE_DPLL_EMU_CLK_MASK BITFIELD(9, 9) 110#define OMAP4430_CLKACTIVITY_CORE_DPLL_EMU_CLK_MASK (1 << 9)
103 111
104/* Used by CM_CEFUSE_CLKSTCTRL */ 112/* Used by CM_CEFUSE_CLKSTCTRL */
105#define OMAP4430_CLKACTIVITY_CUST_EFUSE_SYS_CLK_SHIFT 9 113#define OMAP4430_CLKACTIVITY_CUST_EFUSE_SYS_CLK_SHIFT 9
106#define OMAP4430_CLKACTIVITY_CUST_EFUSE_SYS_CLK_MASK BITFIELD(9, 9) 114#define OMAP4430_CLKACTIVITY_CUST_EFUSE_SYS_CLK_MASK (1 << 9)
107 115
108/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 116/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
109#define OMAP4430_CLKACTIVITY_DLL_CLK_SHIFT 9 117#define OMAP4430_CLKACTIVITY_DLL_CLK_SHIFT 9
110#define OMAP4430_CLKACTIVITY_DLL_CLK_MASK BITFIELD(9, 9) 118#define OMAP4430_CLKACTIVITY_DLL_CLK_MASK (1 << 9)
111 119
112/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 120/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
113#define OMAP4430_CLKACTIVITY_DMT10_GFCLK_SHIFT 9 121#define OMAP4430_CLKACTIVITY_DMT10_GFCLK_SHIFT 9
114#define OMAP4430_CLKACTIVITY_DMT10_GFCLK_MASK BITFIELD(9, 9) 122#define OMAP4430_CLKACTIVITY_DMT10_GFCLK_MASK (1 << 9)
115 123
116/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 124/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
117#define OMAP4430_CLKACTIVITY_DMT11_GFCLK_SHIFT 10 125#define OMAP4430_CLKACTIVITY_DMT11_GFCLK_SHIFT 10
118#define OMAP4430_CLKACTIVITY_DMT11_GFCLK_MASK BITFIELD(10, 10) 126#define OMAP4430_CLKACTIVITY_DMT11_GFCLK_MASK (1 << 10)
119 127
120/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 128/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
121#define OMAP4430_CLKACTIVITY_DMT2_GFCLK_SHIFT 11 129#define OMAP4430_CLKACTIVITY_DMT2_GFCLK_SHIFT 11
122#define OMAP4430_CLKACTIVITY_DMT2_GFCLK_MASK BITFIELD(11, 11) 130#define OMAP4430_CLKACTIVITY_DMT2_GFCLK_MASK (1 << 11)
123 131
124/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 132/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
125#define OMAP4430_CLKACTIVITY_DMT3_GFCLK_SHIFT 12 133#define OMAP4430_CLKACTIVITY_DMT3_GFCLK_SHIFT 12
126#define OMAP4430_CLKACTIVITY_DMT3_GFCLK_MASK BITFIELD(12, 12) 134#define OMAP4430_CLKACTIVITY_DMT3_GFCLK_MASK (1 << 12)
127 135
128/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 136/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
129#define OMAP4430_CLKACTIVITY_DMT4_GFCLK_SHIFT 13 137#define OMAP4430_CLKACTIVITY_DMT4_GFCLK_SHIFT 13
130#define OMAP4430_CLKACTIVITY_DMT4_GFCLK_MASK BITFIELD(13, 13) 138#define OMAP4430_CLKACTIVITY_DMT4_GFCLK_MASK (1 << 13)
131 139
132/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 140/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
133#define OMAP4430_CLKACTIVITY_DMT9_GFCLK_SHIFT 14 141#define OMAP4430_CLKACTIVITY_DMT9_GFCLK_SHIFT 14
134#define OMAP4430_CLKACTIVITY_DMT9_GFCLK_MASK BITFIELD(14, 14) 142#define OMAP4430_CLKACTIVITY_DMT9_GFCLK_MASK (1 << 14)
135 143
136/* Used by CM_DSS_CLKSTCTRL */ 144/* Used by CM_DSS_CLKSTCTRL */
137#define OMAP4430_CLKACTIVITY_DSS_ALWON_SYS_CLK_SHIFT 10 145#define OMAP4430_CLKACTIVITY_DSS_ALWON_SYS_CLK_SHIFT 10
138#define OMAP4430_CLKACTIVITY_DSS_ALWON_SYS_CLK_MASK BITFIELD(10, 10) 146#define OMAP4430_CLKACTIVITY_DSS_ALWON_SYS_CLK_MASK (1 << 10)
139 147
140/* Used by CM_DSS_CLKSTCTRL */ 148/* Used by CM_DSS_CLKSTCTRL */
141#define OMAP4430_CLKACTIVITY_DSS_FCLK_SHIFT 9 149#define OMAP4430_CLKACTIVITY_DSS_FCLK_SHIFT 9
142#define OMAP4430_CLKACTIVITY_DSS_FCLK_MASK BITFIELD(9, 9) 150#define OMAP4430_CLKACTIVITY_DSS_FCLK_MASK (1 << 9)
143 151
144/* Used by CM_DUCATI_CLKSTCTRL */ 152/* Used by CM_DUCATI_CLKSTCTRL */
145#define OMAP4430_CLKACTIVITY_DUCATI_GCLK_SHIFT 8 153#define OMAP4430_CLKACTIVITY_DUCATI_GCLK_SHIFT 8
146#define OMAP4430_CLKACTIVITY_DUCATI_GCLK_MASK BITFIELD(8, 8) 154#define OMAP4430_CLKACTIVITY_DUCATI_GCLK_MASK (1 << 8)
147
148/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
149#define OMAP4430_CLKACTIVITY_EMAC_50MHZ_CLK_SHIFT 10
150#define OMAP4430_CLKACTIVITY_EMAC_50MHZ_CLK_MASK BITFIELD(10, 10)
151 155
152/* Used by CM_EMU_CLKSTCTRL */ 156/* Used by CM_EMU_CLKSTCTRL */
153#define OMAP4430_CLKACTIVITY_EMU_SYS_CLK_SHIFT 8 157#define OMAP4430_CLKACTIVITY_EMU_SYS_CLK_SHIFT 8
154#define OMAP4430_CLKACTIVITY_EMU_SYS_CLK_MASK BITFIELD(8, 8) 158#define OMAP4430_CLKACTIVITY_EMU_SYS_CLK_MASK (1 << 8)
155 159
156/* Used by CM_CAM_CLKSTCTRL */ 160/* Used by CM_CAM_CLKSTCTRL */
157#define OMAP4430_CLKACTIVITY_FDIF_GFCLK_SHIFT 10 161#define OMAP4430_CLKACTIVITY_FDIF_GFCLK_SHIFT 10
158#define OMAP4430_CLKACTIVITY_FDIF_GFCLK_MASK BITFIELD(10, 10) 162#define OMAP4430_CLKACTIVITY_FDIF_GFCLK_MASK (1 << 10)
159 163
160/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 164/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
161#define OMAP4430_CLKACTIVITY_FUNC_12M_GFCLK_SHIFT 15 165#define OMAP4430_CLKACTIVITY_FUNC_12M_GFCLK_SHIFT 15
162#define OMAP4430_CLKACTIVITY_FUNC_12M_GFCLK_MASK BITFIELD(15, 15) 166#define OMAP4430_CLKACTIVITY_FUNC_12M_GFCLK_MASK (1 << 15)
163 167
164/* Used by CM1_ABE_CLKSTCTRL */ 168/* Used by CM1_ABE_CLKSTCTRL */
165#define OMAP4430_CLKACTIVITY_FUNC_24M_GFCLK_SHIFT 10 169#define OMAP4430_CLKACTIVITY_FUNC_24M_GFCLK_SHIFT 10
166#define OMAP4430_CLKACTIVITY_FUNC_24M_GFCLK_MASK BITFIELD(10, 10) 170#define OMAP4430_CLKACTIVITY_FUNC_24M_GFCLK_MASK (1 << 10)
167 171
168/* Used by CM_DSS_CLKSTCTRL */ 172/* Used by CM_DSS_CLKSTCTRL */
169#define OMAP4430_CLKACTIVITY_HDMI_PHY_48MHZ_GFCLK_SHIFT 11 173#define OMAP4430_CLKACTIVITY_HDMI_PHY_48MHZ_GFCLK_SHIFT 11
170#define OMAP4430_CLKACTIVITY_HDMI_PHY_48MHZ_GFCLK_MASK BITFIELD(11, 11) 174#define OMAP4430_CLKACTIVITY_HDMI_PHY_48MHZ_GFCLK_MASK (1 << 11)
171 175
172/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 176/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
173#define OMAP4430_CLKACTIVITY_HSIC_P1_480M_GFCLK_SHIFT 20 177#define OMAP4430_CLKACTIVITY_HSIC_P1_480M_GFCLK_SHIFT 20
174#define OMAP4430_CLKACTIVITY_HSIC_P1_480M_GFCLK_MASK BITFIELD(20, 20) 178#define OMAP4430_CLKACTIVITY_HSIC_P1_480M_GFCLK_MASK (1 << 20)
175 179
176/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 180/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
177#define OMAP4430_CLKACTIVITY_HSIC_P1_GFCLK_SHIFT 26 181#define OMAP4430_CLKACTIVITY_HSIC_P1_GFCLK_SHIFT 26
178#define OMAP4430_CLKACTIVITY_HSIC_P1_GFCLK_MASK BITFIELD(26, 26) 182#define OMAP4430_CLKACTIVITY_HSIC_P1_GFCLK_MASK (1 << 26)
179 183
180/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 184/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
181#define OMAP4430_CLKACTIVITY_HSIC_P2_480M_GFCLK_SHIFT 21 185#define OMAP4430_CLKACTIVITY_HSIC_P2_480M_GFCLK_SHIFT 21
182#define OMAP4430_CLKACTIVITY_HSIC_P2_480M_GFCLK_MASK BITFIELD(21, 21) 186#define OMAP4430_CLKACTIVITY_HSIC_P2_480M_GFCLK_MASK (1 << 21)
183 187
184/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 188/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
185#define OMAP4430_CLKACTIVITY_HSIC_P2_GFCLK_SHIFT 27 189#define OMAP4430_CLKACTIVITY_HSIC_P2_GFCLK_SHIFT 27
186#define OMAP4430_CLKACTIVITY_HSIC_P2_GFCLK_MASK BITFIELD(27, 27) 190#define OMAP4430_CLKACTIVITY_HSIC_P2_GFCLK_MASK (1 << 27)
187
188/* Used by CM_L3INIT_CLKSTCTRL */
189#define OMAP4430_CLKACTIVITY_INIT_32K_GFCLK_SHIFT 31
190#define OMAP4430_CLKACTIVITY_INIT_32K_GFCLK_MASK BITFIELD(31, 31)
191 191
192/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 192/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
193#define OMAP4430_CLKACTIVITY_INIT_48MC_GFCLK_SHIFT 13 193#define OMAP4430_CLKACTIVITY_INIT_48MC_GFCLK_SHIFT 13
194#define OMAP4430_CLKACTIVITY_INIT_48MC_GFCLK_MASK BITFIELD(13, 13) 194#define OMAP4430_CLKACTIVITY_INIT_48MC_GFCLK_MASK (1 << 13)
195 195
196/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 196/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
197#define OMAP4430_CLKACTIVITY_INIT_48M_GFCLK_SHIFT 12 197#define OMAP4430_CLKACTIVITY_INIT_48M_GFCLK_SHIFT 12
198#define OMAP4430_CLKACTIVITY_INIT_48M_GFCLK_MASK BITFIELD(12, 12) 198#define OMAP4430_CLKACTIVITY_INIT_48M_GFCLK_MASK (1 << 12)
199 199
200/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 200/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
201#define OMAP4430_CLKACTIVITY_INIT_60M_P1_GFCLK_SHIFT 28 201#define OMAP4430_CLKACTIVITY_INIT_60M_P1_GFCLK_SHIFT 28
202#define OMAP4430_CLKACTIVITY_INIT_60M_P1_GFCLK_MASK BITFIELD(28, 28) 202#define OMAP4430_CLKACTIVITY_INIT_60M_P1_GFCLK_MASK (1 << 28)
203 203
204/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 204/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
205#define OMAP4430_CLKACTIVITY_INIT_60M_P2_GFCLK_SHIFT 29 205#define OMAP4430_CLKACTIVITY_INIT_60M_P2_GFCLK_SHIFT 29
206#define OMAP4430_CLKACTIVITY_INIT_60M_P2_GFCLK_MASK BITFIELD(29, 29) 206#define OMAP4430_CLKACTIVITY_INIT_60M_P2_GFCLK_MASK (1 << 29)
207 207
208/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 208/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
209#define OMAP4430_CLKACTIVITY_INIT_96M_GFCLK_SHIFT 11 209#define OMAP4430_CLKACTIVITY_INIT_96M_GFCLK_SHIFT 11
210#define OMAP4430_CLKACTIVITY_INIT_96M_GFCLK_MASK BITFIELD(11, 11) 210#define OMAP4430_CLKACTIVITY_INIT_96M_GFCLK_MASK (1 << 11)
211 211
212/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 212/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
213#define OMAP4430_CLKACTIVITY_INIT_HSI_GFCLK_SHIFT 16 213#define OMAP4430_CLKACTIVITY_INIT_HSI_GFCLK_SHIFT 16
214#define OMAP4430_CLKACTIVITY_INIT_HSI_GFCLK_MASK BITFIELD(16, 16) 214#define OMAP4430_CLKACTIVITY_INIT_HSI_GFCLK_MASK (1 << 16)
215 215
216/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 216/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
217#define OMAP4430_CLKACTIVITY_INIT_HSMMC1_GFCLK_SHIFT 17 217#define OMAP4430_CLKACTIVITY_INIT_HSMMC1_GFCLK_SHIFT 17
218#define OMAP4430_CLKACTIVITY_INIT_HSMMC1_GFCLK_MASK BITFIELD(17, 17) 218#define OMAP4430_CLKACTIVITY_INIT_HSMMC1_GFCLK_MASK (1 << 17)
219 219
220/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 220/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
221#define OMAP4430_CLKACTIVITY_INIT_HSMMC2_GFCLK_SHIFT 18 221#define OMAP4430_CLKACTIVITY_INIT_HSMMC2_GFCLK_SHIFT 18
222#define OMAP4430_CLKACTIVITY_INIT_HSMMC2_GFCLK_MASK BITFIELD(18, 18) 222#define OMAP4430_CLKACTIVITY_INIT_HSMMC2_GFCLK_MASK (1 << 18)
223 223
224/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 224/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
225#define OMAP4430_CLKACTIVITY_INIT_HSMMC6_GFCLK_SHIFT 19 225#define OMAP4430_CLKACTIVITY_INIT_HSMMC6_GFCLK_SHIFT 19
226#define OMAP4430_CLKACTIVITY_INIT_HSMMC6_GFCLK_MASK BITFIELD(19, 19) 226#define OMAP4430_CLKACTIVITY_INIT_HSMMC6_GFCLK_MASK (1 << 19)
227 227
228/* Used by CM_CAM_CLKSTCTRL */ 228/* Used by CM_CAM_CLKSTCTRL */
229#define OMAP4430_CLKACTIVITY_ISS_GCLK_SHIFT 8 229#define OMAP4430_CLKACTIVITY_ISS_GCLK_SHIFT 8
230#define OMAP4430_CLKACTIVITY_ISS_GCLK_MASK BITFIELD(8, 8) 230#define OMAP4430_CLKACTIVITY_ISS_GCLK_MASK (1 << 8)
231 231
232/* Used by CM_IVAHD_CLKSTCTRL */ 232/* Used by CM_IVAHD_CLKSTCTRL */
233#define OMAP4430_CLKACTIVITY_IVAHD_ROOT_CLK_SHIFT 8 233#define OMAP4430_CLKACTIVITY_IVAHD_ROOT_CLK_SHIFT 8
234#define OMAP4430_CLKACTIVITY_IVAHD_ROOT_CLK_MASK BITFIELD(8, 8) 234#define OMAP4430_CLKACTIVITY_IVAHD_ROOT_CLK_MASK (1 << 8)
235 235
236/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 236/* Used by CM_D2D_CLKSTCTRL */
237#define OMAP4430_CLKACTIVITY_L3INIT_DPLL_ALWON_CLK_SHIFT 14 237#define OMAP4430_CLKACTIVITY_L3X2_D2D_GICLK_SHIFT 10
238#define OMAP4430_CLKACTIVITY_L3INIT_DPLL_ALWON_CLK_MASK BITFIELD(14, 14) 238#define OMAP4430_CLKACTIVITY_L3X2_D2D_GICLK_MASK (1 << 10)
239 239
240/* Used by CM_L3_1_CLKSTCTRL, CM_L3_1_CLKSTCTRL_RESTORE */ 240/* Used by CM_L3_1_CLKSTCTRL, CM_L3_1_CLKSTCTRL_RESTORE */
241#define OMAP4430_CLKACTIVITY_L3_1_GICLK_SHIFT 8 241#define OMAP4430_CLKACTIVITY_L3_1_GICLK_SHIFT 8
242#define OMAP4430_CLKACTIVITY_L3_1_GICLK_MASK BITFIELD(8, 8) 242#define OMAP4430_CLKACTIVITY_L3_1_GICLK_MASK (1 << 8)
243 243
244/* Used by CM_L3_2_CLKSTCTRL, CM_L3_2_CLKSTCTRL_RESTORE */ 244/* Used by CM_L3_2_CLKSTCTRL, CM_L3_2_CLKSTCTRL_RESTORE */
245#define OMAP4430_CLKACTIVITY_L3_2_GICLK_SHIFT 8 245#define OMAP4430_CLKACTIVITY_L3_2_GICLK_SHIFT 8
246#define OMAP4430_CLKACTIVITY_L3_2_GICLK_MASK BITFIELD(8, 8) 246#define OMAP4430_CLKACTIVITY_L3_2_GICLK_MASK (1 << 8)
247 247
248/* Used by CM_D2D_CLKSTCTRL */ 248/* Used by CM_D2D_CLKSTCTRL */
249#define OMAP4430_CLKACTIVITY_L3_D2D_GICLK_SHIFT 8 249#define OMAP4430_CLKACTIVITY_L3_D2D_GICLK_SHIFT 8
250#define OMAP4430_CLKACTIVITY_L3_D2D_GICLK_MASK BITFIELD(8, 8) 250#define OMAP4430_CLKACTIVITY_L3_D2D_GICLK_MASK (1 << 8)
251 251
252/* Used by CM_SDMA_CLKSTCTRL */ 252/* Used by CM_SDMA_CLKSTCTRL */
253#define OMAP4430_CLKACTIVITY_L3_DMA_GICLK_SHIFT 8 253#define OMAP4430_CLKACTIVITY_L3_DMA_GICLK_SHIFT 8
254#define OMAP4430_CLKACTIVITY_L3_DMA_GICLK_MASK BITFIELD(8, 8) 254#define OMAP4430_CLKACTIVITY_L3_DMA_GICLK_MASK (1 << 8)
255 255
256/* Used by CM_DSS_CLKSTCTRL */ 256/* Used by CM_DSS_CLKSTCTRL */
257#define OMAP4430_CLKACTIVITY_L3_DSS_GICLK_SHIFT 8 257#define OMAP4430_CLKACTIVITY_L3_DSS_GICLK_SHIFT 8
258#define OMAP4430_CLKACTIVITY_L3_DSS_GICLK_MASK BITFIELD(8, 8) 258#define OMAP4430_CLKACTIVITY_L3_DSS_GICLK_MASK (1 << 8)
259 259
260/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 260/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
261#define OMAP4430_CLKACTIVITY_L3_EMIF_GICLK_SHIFT 8 261#define OMAP4430_CLKACTIVITY_L3_EMIF_GICLK_SHIFT 8
262#define OMAP4430_CLKACTIVITY_L3_EMIF_GICLK_MASK BITFIELD(8, 8) 262#define OMAP4430_CLKACTIVITY_L3_EMIF_GICLK_MASK (1 << 8)
263 263
264/* Used by CM_GFX_CLKSTCTRL */ 264/* Used by CM_GFX_CLKSTCTRL */
265#define OMAP4430_CLKACTIVITY_L3_GFX_GICLK_SHIFT 8 265#define OMAP4430_CLKACTIVITY_L3_GFX_GICLK_SHIFT 8
266#define OMAP4430_CLKACTIVITY_L3_GFX_GICLK_MASK BITFIELD(8, 8) 266#define OMAP4430_CLKACTIVITY_L3_GFX_GICLK_MASK (1 << 8)
267 267
268/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 268/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
269#define OMAP4430_CLKACTIVITY_L3_INIT_GICLK_SHIFT 8 269#define OMAP4430_CLKACTIVITY_L3_INIT_GICLK_SHIFT 8
270#define OMAP4430_CLKACTIVITY_L3_INIT_GICLK_MASK BITFIELD(8, 8) 270#define OMAP4430_CLKACTIVITY_L3_INIT_GICLK_MASK (1 << 8)
271 271
272/* Used by CM_L3INSTR_CLKSTCTRL */ 272/* Used by CM_L3INSTR_CLKSTCTRL */
273#define OMAP4430_CLKACTIVITY_L3_INSTR_GICLK_SHIFT 8 273#define OMAP4430_CLKACTIVITY_L3_INSTR_GICLK_SHIFT 8
274#define OMAP4430_CLKACTIVITY_L3_INSTR_GICLK_MASK BITFIELD(8, 8) 274#define OMAP4430_CLKACTIVITY_L3_INSTR_GICLK_MASK (1 << 8)
275 275
276/* Used by CM_L4SEC_CLKSTCTRL */ 276/* Used by CM_L4SEC_CLKSTCTRL */
277#define OMAP4430_CLKACTIVITY_L3_SECURE_GICLK_SHIFT 8 277#define OMAP4430_CLKACTIVITY_L3_SECURE_GICLK_SHIFT 8
278#define OMAP4430_CLKACTIVITY_L3_SECURE_GICLK_MASK BITFIELD(8, 8) 278#define OMAP4430_CLKACTIVITY_L3_SECURE_GICLK_MASK (1 << 8)
279 279
280/* Used by CM_ALWON_CLKSTCTRL */ 280/* Used by CM_ALWON_CLKSTCTRL */
281#define OMAP4430_CLKACTIVITY_L4_AO_ICLK_SHIFT 8 281#define OMAP4430_CLKACTIVITY_L4_AO_ICLK_SHIFT 8
282#define OMAP4430_CLKACTIVITY_L4_AO_ICLK_MASK BITFIELD(8, 8) 282#define OMAP4430_CLKACTIVITY_L4_AO_ICLK_MASK (1 << 8)
283 283
284/* Used by CM_CEFUSE_CLKSTCTRL */ 284/* Used by CM_CEFUSE_CLKSTCTRL */
285#define OMAP4430_CLKACTIVITY_L4_CEFUSE_GICLK_SHIFT 8 285#define OMAP4430_CLKACTIVITY_L4_CEFUSE_GICLK_SHIFT 8
286#define OMAP4430_CLKACTIVITY_L4_CEFUSE_GICLK_MASK BITFIELD(8, 8) 286#define OMAP4430_CLKACTIVITY_L4_CEFUSE_GICLK_MASK (1 << 8)
287 287
288/* Used by CM_L4CFG_CLKSTCTRL, CM_L4CFG_CLKSTCTRL_RESTORE */ 288/* Used by CM_L4CFG_CLKSTCTRL, CM_L4CFG_CLKSTCTRL_RESTORE */
289#define OMAP4430_CLKACTIVITY_L4_CFG_GICLK_SHIFT 8 289#define OMAP4430_CLKACTIVITY_L4_CFG_GICLK_SHIFT 8
290#define OMAP4430_CLKACTIVITY_L4_CFG_GICLK_MASK BITFIELD(8, 8) 290#define OMAP4430_CLKACTIVITY_L4_CFG_GICLK_MASK (1 << 8)
291 291
292/* Used by CM_D2D_CLKSTCTRL */ 292/* Used by CM_D2D_CLKSTCTRL */
293#define OMAP4430_CLKACTIVITY_L4_D2D_GICLK_SHIFT 9 293#define OMAP4430_CLKACTIVITY_L4_D2D_GICLK_SHIFT 9
294#define OMAP4430_CLKACTIVITY_L4_D2D_GICLK_MASK BITFIELD(9, 9) 294#define OMAP4430_CLKACTIVITY_L4_D2D_GICLK_MASK (1 << 9)
295 295
296/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 296/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
297#define OMAP4430_CLKACTIVITY_L4_INIT_GICLK_SHIFT 9 297#define OMAP4430_CLKACTIVITY_L4_INIT_GICLK_SHIFT 9
298#define OMAP4430_CLKACTIVITY_L4_INIT_GICLK_MASK BITFIELD(9, 9) 298#define OMAP4430_CLKACTIVITY_L4_INIT_GICLK_MASK (1 << 9)
299 299
300/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 300/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
301#define OMAP4430_CLKACTIVITY_L4_PER_GICLK_SHIFT 8 301#define OMAP4430_CLKACTIVITY_L4_PER_GICLK_SHIFT 8
302#define OMAP4430_CLKACTIVITY_L4_PER_GICLK_MASK BITFIELD(8, 8) 302#define OMAP4430_CLKACTIVITY_L4_PER_GICLK_MASK (1 << 8)
303 303
304/* Used by CM_L4SEC_CLKSTCTRL */ 304/* Used by CM_L4SEC_CLKSTCTRL */
305#define OMAP4430_CLKACTIVITY_L4_SECURE_GICLK_SHIFT 9 305#define OMAP4430_CLKACTIVITY_L4_SECURE_GICLK_SHIFT 9
306#define OMAP4430_CLKACTIVITY_L4_SECURE_GICLK_MASK BITFIELD(9, 9) 306#define OMAP4430_CLKACTIVITY_L4_SECURE_GICLK_MASK (1 << 9)
307 307
308/* Used by CM_WKUP_CLKSTCTRL */ 308/* Used by CM_WKUP_CLKSTCTRL */
309#define OMAP4430_CLKACTIVITY_L4_WKUP_GICLK_SHIFT 12 309#define OMAP4430_CLKACTIVITY_L4_WKUP_GICLK_SHIFT 12
310#define OMAP4430_CLKACTIVITY_L4_WKUP_GICLK_MASK BITFIELD(12, 12) 310#define OMAP4430_CLKACTIVITY_L4_WKUP_GICLK_MASK (1 << 12)
311 311
312/* Used by CM_MPU_CLKSTCTRL, CM_MPU_CLKSTCTRL_RESTORE */ 312/* Used by CM_MPU_CLKSTCTRL, CM_MPU_CLKSTCTRL_RESTORE */
313#define OMAP4430_CLKACTIVITY_MPU_DPLL_CLK_SHIFT 8 313#define OMAP4430_CLKACTIVITY_MPU_DPLL_CLK_SHIFT 8
314#define OMAP4430_CLKACTIVITY_MPU_DPLL_CLK_MASK BITFIELD(8, 8) 314#define OMAP4430_CLKACTIVITY_MPU_DPLL_CLK_MASK (1 << 8)
315 315
316/* Used by CM1_ABE_CLKSTCTRL */ 316/* Used by CM1_ABE_CLKSTCTRL */
317#define OMAP4430_CLKACTIVITY_OCP_ABE_GICLK_SHIFT 9 317#define OMAP4430_CLKACTIVITY_OCP_ABE_GICLK_SHIFT 9
318#define OMAP4430_CLKACTIVITY_OCP_ABE_GICLK_MASK BITFIELD(9, 9) 318#define OMAP4430_CLKACTIVITY_OCP_ABE_GICLK_MASK (1 << 9)
319 319
320/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 320/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
321#define OMAP4430_CLKACTIVITY_PER_24MC_GFCLK_SHIFT 16 321#define OMAP4430_CLKACTIVITY_PER_24MC_GFCLK_SHIFT 16
322#define OMAP4430_CLKACTIVITY_PER_24MC_GFCLK_MASK BITFIELD(16, 16) 322#define OMAP4430_CLKACTIVITY_PER_24MC_GFCLK_MASK (1 << 16)
323 323
324/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 324/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
325#define OMAP4430_CLKACTIVITY_PER_32K_GFCLK_SHIFT 17 325#define OMAP4430_CLKACTIVITY_PER_32K_GFCLK_SHIFT 17
326#define OMAP4430_CLKACTIVITY_PER_32K_GFCLK_MASK BITFIELD(17, 17) 326#define OMAP4430_CLKACTIVITY_PER_32K_GFCLK_MASK (1 << 17)
327 327
328/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 328/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
329#define OMAP4430_CLKACTIVITY_PER_48M_GFCLK_SHIFT 18 329#define OMAP4430_CLKACTIVITY_PER_48M_GFCLK_SHIFT 18
330#define OMAP4430_CLKACTIVITY_PER_48M_GFCLK_MASK BITFIELD(18, 18) 330#define OMAP4430_CLKACTIVITY_PER_48M_GFCLK_MASK (1 << 18)
331 331
332/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 332/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
333#define OMAP4430_CLKACTIVITY_PER_96M_GFCLK_SHIFT 19 333#define OMAP4430_CLKACTIVITY_PER_96M_GFCLK_SHIFT 19
334#define OMAP4430_CLKACTIVITY_PER_96M_GFCLK_MASK BITFIELD(19, 19) 334#define OMAP4430_CLKACTIVITY_PER_96M_GFCLK_MASK (1 << 19)
335 335
336/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 336/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
337#define OMAP4430_CLKACTIVITY_PER_ABE_24M_GFCLK_SHIFT 25 337#define OMAP4430_CLKACTIVITY_PER_ABE_24M_GFCLK_SHIFT 25
338#define OMAP4430_CLKACTIVITY_PER_ABE_24M_GFCLK_MASK BITFIELD(25, 25) 338#define OMAP4430_CLKACTIVITY_PER_ABE_24M_GFCLK_MASK (1 << 25)
339
340/* Used by CM_EMU_CLKSTCTRL */
341#define OMAP4430_CLKACTIVITY_PER_DPLL_EMU_CLK_SHIFT 10
342#define OMAP4430_CLKACTIVITY_PER_DPLL_EMU_CLK_MASK BITFIELD(10, 10)
343 339
344/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 340/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
345#define OMAP4430_CLKACTIVITY_PER_MCASP2_GFCLK_SHIFT 20 341#define OMAP4430_CLKACTIVITY_PER_MCASP2_GFCLK_SHIFT 20
346#define OMAP4430_CLKACTIVITY_PER_MCASP2_GFCLK_MASK BITFIELD(20, 20) 342#define OMAP4430_CLKACTIVITY_PER_MCASP2_GFCLK_MASK (1 << 20)
347 343
348/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 344/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
349#define OMAP4430_CLKACTIVITY_PER_MCASP3_GFCLK_SHIFT 21 345#define OMAP4430_CLKACTIVITY_PER_MCASP3_GFCLK_SHIFT 21
350#define OMAP4430_CLKACTIVITY_PER_MCASP3_GFCLK_MASK BITFIELD(21, 21) 346#define OMAP4430_CLKACTIVITY_PER_MCASP3_GFCLK_MASK (1 << 21)
351 347
352/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 348/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
353#define OMAP4430_CLKACTIVITY_PER_MCBSP4_GFCLK_SHIFT 22 349#define OMAP4430_CLKACTIVITY_PER_MCBSP4_GFCLK_SHIFT 22
354#define OMAP4430_CLKACTIVITY_PER_MCBSP4_GFCLK_MASK BITFIELD(22, 22) 350#define OMAP4430_CLKACTIVITY_PER_MCBSP4_GFCLK_MASK (1 << 22)
355 351
356/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */ 352/* Used by CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE */
357#define OMAP4430_CLKACTIVITY_PER_SYS_GFCLK_SHIFT 24 353#define OMAP4430_CLKACTIVITY_PER_SYS_GFCLK_SHIFT 24
358#define OMAP4430_CLKACTIVITY_PER_SYS_GFCLK_MASK BITFIELD(24, 24) 354#define OMAP4430_CLKACTIVITY_PER_SYS_GFCLK_MASK (1 << 24)
359 355
360/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */ 356/* Used by CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE */
361#define OMAP4430_CLKACTIVITY_PHY_ROOT_CLK_SHIFT 10 357#define OMAP4430_CLKACTIVITY_PHY_ROOT_CLK_SHIFT 10
362#define OMAP4430_CLKACTIVITY_PHY_ROOT_CLK_MASK BITFIELD(10, 10) 358#define OMAP4430_CLKACTIVITY_PHY_ROOT_CLK_MASK (1 << 10)
363 359
364/* Used by CM_GFX_CLKSTCTRL */ 360/* Used by CM_GFX_CLKSTCTRL */
365#define OMAP4430_CLKACTIVITY_SGX_GFCLK_SHIFT 9 361#define OMAP4430_CLKACTIVITY_SGX_GFCLK_SHIFT 9
366#define OMAP4430_CLKACTIVITY_SGX_GFCLK_MASK BITFIELD(9, 9) 362#define OMAP4430_CLKACTIVITY_SGX_GFCLK_MASK (1 << 9)
367 363
368/* Used by CM_ALWON_CLKSTCTRL */ 364/* Used by CM_ALWON_CLKSTCTRL */
369#define OMAP4430_CLKACTIVITY_SR_CORE_SYSCLK_SHIFT 11 365#define OMAP4430_CLKACTIVITY_SR_CORE_SYSCLK_SHIFT 11
370#define OMAP4430_CLKACTIVITY_SR_CORE_SYSCLK_MASK BITFIELD(11, 11) 366#define OMAP4430_CLKACTIVITY_SR_CORE_SYSCLK_MASK (1 << 11)
371 367
372/* Used by CM_ALWON_CLKSTCTRL */ 368/* Used by CM_ALWON_CLKSTCTRL */
373#define OMAP4430_CLKACTIVITY_SR_IVA_SYSCLK_SHIFT 10 369#define OMAP4430_CLKACTIVITY_SR_IVA_SYSCLK_SHIFT 10
374#define OMAP4430_CLKACTIVITY_SR_IVA_SYSCLK_MASK BITFIELD(10, 10) 370#define OMAP4430_CLKACTIVITY_SR_IVA_SYSCLK_MASK (1 << 10)
375 371
376/* Used by CM_ALWON_CLKSTCTRL */ 372/* Used by CM_ALWON_CLKSTCTRL */
377#define OMAP4430_CLKACTIVITY_SR_MPU_SYSCLK_SHIFT 9 373#define OMAP4430_CLKACTIVITY_SR_MPU_SYSCLK_SHIFT 9
378#define OMAP4430_CLKACTIVITY_SR_MPU_SYSCLK_MASK BITFIELD(9, 9) 374#define OMAP4430_CLKACTIVITY_SR_MPU_SYSCLK_MASK (1 << 9)
379 375
380/* Used by CM_WKUP_CLKSTCTRL */ 376/* Used by CM_WKUP_CLKSTCTRL */
381#define OMAP4430_CLKACTIVITY_SYS_CLK_SHIFT 8 377#define OMAP4430_CLKACTIVITY_SYS_CLK_SHIFT 8
382#define OMAP4430_CLKACTIVITY_SYS_CLK_MASK BITFIELD(8, 8) 378#define OMAP4430_CLKACTIVITY_SYS_CLK_MASK (1 << 8)
383 379
384/* Used by CM_TESLA_CLKSTCTRL */ 380/* Used by CM_TESLA_CLKSTCTRL */
385#define OMAP4430_CLKACTIVITY_TESLA_ROOT_CLK_SHIFT 8 381#define OMAP4430_CLKACTIVITY_TESLA_ROOT_CLK_SHIFT 8
386#define OMAP4430_CLKACTIVITY_TESLA_ROOT_CLK_MASK BITFIELD(8, 8) 382#define OMAP4430_CLKACTIVITY_TESLA_ROOT_CLK_MASK (1 << 8)
387 383
388/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 384/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
389#define OMAP4430_CLKACTIVITY_TLL_CH0_GFCLK_SHIFT 22 385#define OMAP4430_CLKACTIVITY_TLL_CH0_GFCLK_SHIFT 22
390#define OMAP4430_CLKACTIVITY_TLL_CH0_GFCLK_MASK BITFIELD(22, 22) 386#define OMAP4430_CLKACTIVITY_TLL_CH0_GFCLK_MASK (1 << 22)
391 387
392/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 388/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
393#define OMAP4430_CLKACTIVITY_TLL_CH1_GFCLK_SHIFT 23 389#define OMAP4430_CLKACTIVITY_TLL_CH1_GFCLK_SHIFT 23
394#define OMAP4430_CLKACTIVITY_TLL_CH1_GFCLK_MASK BITFIELD(23, 23) 390#define OMAP4430_CLKACTIVITY_TLL_CH1_GFCLK_MASK (1 << 23)
395 391
396/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 392/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
397#define OMAP4430_CLKACTIVITY_TLL_CH2_GFCLK_SHIFT 24 393#define OMAP4430_CLKACTIVITY_TLL_CH2_GFCLK_SHIFT 24
398#define OMAP4430_CLKACTIVITY_TLL_CH2_GFCLK_MASK BITFIELD(24, 24) 394#define OMAP4430_CLKACTIVITY_TLL_CH2_GFCLK_MASK (1 << 24)
395
396/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
397#define OMAP4430_CLKACTIVITY_UNIPRO_DPLL_CLK_SHIFT 10
398#define OMAP4430_CLKACTIVITY_UNIPRO_DPLL_CLK_MASK (1 << 10)
399
400/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
401#define OMAP4430_CLKACTIVITY_USB_DPLL_CLK_SHIFT 14
402#define OMAP4430_CLKACTIVITY_USB_DPLL_CLK_MASK (1 << 14)
399 403
400/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 404/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
401#define OMAP4430_CLKACTIVITY_USB_DPLL_HS_CLK_SHIFT 15 405#define OMAP4430_CLKACTIVITY_USB_DPLL_HS_CLK_SHIFT 15
402#define OMAP4430_CLKACTIVITY_USB_DPLL_HS_CLK_MASK BITFIELD(15, 15) 406#define OMAP4430_CLKACTIVITY_USB_DPLL_HS_CLK_MASK (1 << 15)
403 407
404/* Used by CM_WKUP_CLKSTCTRL */ 408/* Used by CM_WKUP_CLKSTCTRL */
405#define OMAP4430_CLKACTIVITY_USIM_GFCLK_SHIFT 10 409#define OMAP4430_CLKACTIVITY_USIM_GFCLK_SHIFT 10
406#define OMAP4430_CLKACTIVITY_USIM_GFCLK_MASK BITFIELD(10, 10) 410#define OMAP4430_CLKACTIVITY_USIM_GFCLK_MASK (1 << 10)
407 411
408/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 412/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
409#define OMAP4430_CLKACTIVITY_UTMI_P3_GFCLK_SHIFT 30 413#define OMAP4430_CLKACTIVITY_UTMI_P3_GFCLK_SHIFT 30
410#define OMAP4430_CLKACTIVITY_UTMI_P3_GFCLK_MASK BITFIELD(30, 30) 414#define OMAP4430_CLKACTIVITY_UTMI_P3_GFCLK_MASK (1 << 30)
411 415
412/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */ 416/* Used by CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE */
413#define OMAP4430_CLKACTIVITY_UTMI_ROOT_GFCLK_SHIFT 25 417#define OMAP4430_CLKACTIVITY_UTMI_ROOT_GFCLK_SHIFT 25
414#define OMAP4430_CLKACTIVITY_UTMI_ROOT_GFCLK_MASK BITFIELD(25, 25) 418#define OMAP4430_CLKACTIVITY_UTMI_ROOT_GFCLK_MASK (1 << 25)
415 419
416/* Used by CM_WKUP_CLKSTCTRL */ 420/* Used by CM_WKUP_CLKSTCTRL */
417#define OMAP4430_CLKACTIVITY_WKUP_32K_GFCLK_SHIFT 11 421#define OMAP4430_CLKACTIVITY_WKUP_32K_GFCLK_SHIFT 11
418#define OMAP4430_CLKACTIVITY_WKUP_32K_GFCLK_MASK BITFIELD(11, 11) 422#define OMAP4430_CLKACTIVITY_WKUP_32K_GFCLK_MASK (1 << 11)
419 423
420/* 424/*
421 * Used by CM_WKUP_TIMER1_CLKCTRL, CM_L4PER_DMTIMER10_CLKCTRL, 425 * Used by CM1_ABE_TIMER5_CLKCTRL, CM1_ABE_TIMER6_CLKCTRL,
426 * CM1_ABE_TIMER7_CLKCTRL, CM1_ABE_TIMER8_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL,
427 * CM_L3INIT_MMC2_CLKCTRL, CM_L3INIT_MMC6_CLKCTRL, CM_L4PER_DMTIMER10_CLKCTRL,
422 * CM_L4PER_DMTIMER11_CLKCTRL, CM_L4PER_DMTIMER2_CLKCTRL, 428 * CM_L4PER_DMTIMER11_CLKCTRL, CM_L4PER_DMTIMER2_CLKCTRL,
423 * CM_L4PER_DMTIMER3_CLKCTRL, CM_L4PER_DMTIMER4_CLKCTRL, 429 * CM_L4PER_DMTIMER3_CLKCTRL, CM_L4PER_DMTIMER4_CLKCTRL,
424 * CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL, 430 * CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL,
425 * CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL, CM_L3INIT_MMC6_CLKCTRL, 431 * CM_WKUP_TIMER1_CLKCTRL
426 * CM1_ABE_TIMER5_CLKCTRL, CM1_ABE_TIMER6_CLKCTRL, CM1_ABE_TIMER7_CLKCTRL,
427 * CM1_ABE_TIMER8_CLKCTRL
428 */ 432 */
429#define OMAP4430_CLKSEL_SHIFT 24 433#define OMAP4430_CLKSEL_SHIFT 24
430#define OMAP4430_CLKSEL_MASK BITFIELD(24, 24) 434#define OMAP4430_CLKSEL_MASK (1 << 24)
431 435
432/* 436/*
433 * Renamed from CLKSEL Used by CM_ABE_DSS_SYS_CLKSEL, CM_ABE_PLL_REF_CLKSEL, 437 * Renamed from CLKSEL Used by CM_ABE_DSS_SYS_CLKSEL, CM_ABE_PLL_REF_CLKSEL,
434 * CM_DPLL_SYS_REF_CLKSEL, CM_L4_WKUP_CLKSEL, CM_CLKSEL_DUCATI_ISS_ROOT, 438 * CM_L4_WKUP_CLKSEL, CM_CLKSEL_DUCATI_ISS_ROOT, CM_CLKSEL_USB_60MHZ
435 * CM_CLKSEL_USB_60MHZ
436 */ 439 */
437#define OMAP4430_CLKSEL_0_0_SHIFT 0 440#define OMAP4430_CLKSEL_0_0_SHIFT 0
438#define OMAP4430_CLKSEL_0_0_MASK BITFIELD(0, 0) 441#define OMAP4430_CLKSEL_0_0_MASK (1 << 0)
439 442
440/* Renamed from CLKSEL Used by CM_BYPCLK_DPLL_IVA, CM_BYPCLK_DPLL_MPU */ 443/* Renamed from CLKSEL Used by CM_BYPCLK_DPLL_IVA, CM_BYPCLK_DPLL_MPU */
441#define OMAP4430_CLKSEL_0_1_SHIFT 0 444#define OMAP4430_CLKSEL_0_1_SHIFT 0
442#define OMAP4430_CLKSEL_0_1_MASK BITFIELD(0, 1) 445#define OMAP4430_CLKSEL_0_1_MASK (0x3 << 0)
443 446
444/* Renamed from CLKSEL Used by CM_L3INIT_HSI_CLKCTRL */ 447/* Renamed from CLKSEL Used by CM_L3INIT_HSI_CLKCTRL */
445#define OMAP4430_CLKSEL_24_25_SHIFT 24 448#define OMAP4430_CLKSEL_24_25_SHIFT 24
446#define OMAP4430_CLKSEL_24_25_MASK BITFIELD(24, 25) 449#define OMAP4430_CLKSEL_24_25_MASK (0x3 << 24)
447 450
448/* Used by CM_L3INIT_USB_OTG_CLKCTRL */ 451/* Used by CM_L3INIT_USB_OTG_CLKCTRL */
449#define OMAP4430_CLKSEL_60M_SHIFT 24 452#define OMAP4430_CLKSEL_60M_SHIFT 24
450#define OMAP4430_CLKSEL_60M_MASK BITFIELD(24, 24) 453#define OMAP4430_CLKSEL_60M_MASK (1 << 24)
451 454
452/* Used by CM1_ABE_AESS_CLKCTRL */ 455/* Used by CM1_ABE_AESS_CLKCTRL */
453#define OMAP4430_CLKSEL_AESS_FCLK_SHIFT 24 456#define OMAP4430_CLKSEL_AESS_FCLK_SHIFT 24
454#define OMAP4430_CLKSEL_AESS_FCLK_MASK BITFIELD(24, 24) 457#define OMAP4430_CLKSEL_AESS_FCLK_MASK (1 << 24)
455 458
456/* Used by CM_CLKSEL_CORE_RESTORE, CM_CLKSEL_CORE */ 459/* Used by CM_CLKSEL_CORE, CM_CLKSEL_CORE_RESTORE */
457#define OMAP4430_CLKSEL_CORE_SHIFT 0 460#define OMAP4430_CLKSEL_CORE_SHIFT 0
458#define OMAP4430_CLKSEL_CORE_MASK BITFIELD(0, 0) 461#define OMAP4430_CLKSEL_CORE_MASK (1 << 0)
459 462
460/* Renamed from CLKSEL_CORE Used by CM_SHADOW_FREQ_CONFIG2 */ 463/*
464 * Renamed from CLKSEL_CORE Used by CM_SHADOW_FREQ_CONFIG2_RESTORE,
465 * CM_SHADOW_FREQ_CONFIG2
466 */
461#define OMAP4430_CLKSEL_CORE_1_1_SHIFT 1 467#define OMAP4430_CLKSEL_CORE_1_1_SHIFT 1
462#define OMAP4430_CLKSEL_CORE_1_1_MASK BITFIELD(1, 1) 468#define OMAP4430_CLKSEL_CORE_1_1_MASK (1 << 1)
463 469
464/* Used by CM_WKUP_USIM_CLKCTRL */ 470/* Used by CM_WKUP_USIM_CLKCTRL */
465#define OMAP4430_CLKSEL_DIV_SHIFT 24 471#define OMAP4430_CLKSEL_DIV_SHIFT 24
466#define OMAP4430_CLKSEL_DIV_MASK BITFIELD(24, 24) 472#define OMAP4430_CLKSEL_DIV_MASK (1 << 24)
467 473
468/* Used by CM_CAM_FDIF_CLKCTRL */ 474/* Used by CM_CAM_FDIF_CLKCTRL */
469#define OMAP4430_CLKSEL_FCLK_SHIFT 24 475#define OMAP4430_CLKSEL_FCLK_SHIFT 24
470#define OMAP4430_CLKSEL_FCLK_MASK BITFIELD(24, 25) 476#define OMAP4430_CLKSEL_FCLK_MASK (0x3 << 24)
471 477
472/* Used by CM_L4PER_MCBSP4_CLKCTRL */ 478/* Used by CM_L4PER_MCBSP4_CLKCTRL */
473#define OMAP4430_CLKSEL_INTERNAL_SOURCE_SHIFT 25 479#define OMAP4430_CLKSEL_INTERNAL_SOURCE_SHIFT 25
474#define OMAP4430_CLKSEL_INTERNAL_SOURCE_MASK BITFIELD(25, 25) 480#define OMAP4430_CLKSEL_INTERNAL_SOURCE_MASK (1 << 25)
475 481
476/* 482/*
477 * Renamed from CLKSEL_INTERNAL_SOURCE Used by CM1_ABE_DMIC_CLKCTRL, 483 * Renamed from CLKSEL_INTERNAL_SOURCE Used by CM1_ABE_DMIC_CLKCTRL,
@@ -479,836 +485,869 @@
479 * CM1_ABE_MCBSP3_CLKCTRL 485 * CM1_ABE_MCBSP3_CLKCTRL
480 */ 486 */
481#define OMAP4430_CLKSEL_INTERNAL_SOURCE_CM1_ABE_DMIC_SHIFT 26 487#define OMAP4430_CLKSEL_INTERNAL_SOURCE_CM1_ABE_DMIC_SHIFT 26
482#define OMAP4430_CLKSEL_INTERNAL_SOURCE_CM1_ABE_DMIC_MASK BITFIELD(26, 27) 488#define OMAP4430_CLKSEL_INTERNAL_SOURCE_CM1_ABE_DMIC_MASK (0x3 << 26)
483 489
484/* Used by CM_CLKSEL_CORE_RESTORE, CM_CLKSEL_CORE */ 490/* Used by CM_CLKSEL_CORE, CM_CLKSEL_CORE_RESTORE */
485#define OMAP4430_CLKSEL_L3_SHIFT 4 491#define OMAP4430_CLKSEL_L3_SHIFT 4
486#define OMAP4430_CLKSEL_L3_MASK BITFIELD(4, 4) 492#define OMAP4430_CLKSEL_L3_MASK (1 << 4)
487 493
488/* Renamed from CLKSEL_L3 Used by CM_SHADOW_FREQ_CONFIG2 */ 494/*
495 * Renamed from CLKSEL_L3 Used by CM_SHADOW_FREQ_CONFIG2_RESTORE,
496 * CM_SHADOW_FREQ_CONFIG2
497 */
489#define OMAP4430_CLKSEL_L3_SHADOW_SHIFT 2 498#define OMAP4430_CLKSEL_L3_SHADOW_SHIFT 2
490#define OMAP4430_CLKSEL_L3_SHADOW_MASK BITFIELD(2, 2) 499#define OMAP4430_CLKSEL_L3_SHADOW_MASK (1 << 2)
491 500
492/* Used by CM_CLKSEL_CORE_RESTORE, CM_CLKSEL_CORE */ 501/* Used by CM_CLKSEL_CORE, CM_CLKSEL_CORE_RESTORE */
493#define OMAP4430_CLKSEL_L4_SHIFT 8 502#define OMAP4430_CLKSEL_L4_SHIFT 8
494#define OMAP4430_CLKSEL_L4_MASK BITFIELD(8, 8) 503#define OMAP4430_CLKSEL_L4_MASK (1 << 8)
495 504
496/* Used by CM_CLKSEL_ABE */ 505/* Used by CM_CLKSEL_ABE */
497#define OMAP4430_CLKSEL_OPP_SHIFT 0 506#define OMAP4430_CLKSEL_OPP_SHIFT 0
498#define OMAP4430_CLKSEL_OPP_MASK BITFIELD(0, 1) 507#define OMAP4430_CLKSEL_OPP_MASK (0x3 << 0)
499
500/* Used by CM_GFX_GFX_CLKCTRL */
501#define OMAP4430_CLKSEL_PER_192M_SHIFT 25
502#define OMAP4430_CLKSEL_PER_192M_MASK BITFIELD(25, 26)
503 508
504/* Used by CM_EMU_DEBUGSS_CLKCTRL */ 509/* Used by CM_EMU_DEBUGSS_CLKCTRL */
505#define OMAP4430_CLKSEL_PMD_STM_CLK_SHIFT 27 510#define OMAP4430_CLKSEL_PMD_STM_CLK_SHIFT 27
506#define OMAP4430_CLKSEL_PMD_STM_CLK_MASK BITFIELD(27, 29) 511#define OMAP4430_CLKSEL_PMD_STM_CLK_MASK (0x7 << 27)
507 512
508/* Used by CM_EMU_DEBUGSS_CLKCTRL */ 513/* Used by CM_EMU_DEBUGSS_CLKCTRL */
509#define OMAP4430_CLKSEL_PMD_TRACE_CLK_SHIFT 24 514#define OMAP4430_CLKSEL_PMD_TRACE_CLK_SHIFT 24
510#define OMAP4430_CLKSEL_PMD_TRACE_CLK_MASK BITFIELD(24, 26) 515#define OMAP4430_CLKSEL_PMD_TRACE_CLK_MASK (0x7 << 24)
511 516
512/* Used by CM_GFX_GFX_CLKCTRL */ 517/* Used by CM_GFX_GFX_CLKCTRL */
513#define OMAP4430_CLKSEL_SGX_FCLK_SHIFT 24 518#define OMAP4430_CLKSEL_SGX_FCLK_SHIFT 24
514#define OMAP4430_CLKSEL_SGX_FCLK_MASK BITFIELD(24, 24) 519#define OMAP4430_CLKSEL_SGX_FCLK_MASK (1 << 24)
515 520
516/* 521/*
517 * Used by CM1_ABE_DMIC_CLKCTRL, CM1_ABE_MCASP_CLKCTRL, CM1_ABE_MCBSP1_CLKCTRL, 522 * Used by CM1_ABE_DMIC_CLKCTRL, CM1_ABE_MCASP_CLKCTRL, CM1_ABE_MCBSP1_CLKCTRL,
518 * CM1_ABE_MCBSP2_CLKCTRL, CM1_ABE_MCBSP3_CLKCTRL 523 * CM1_ABE_MCBSP2_CLKCTRL, CM1_ABE_MCBSP3_CLKCTRL
519 */ 524 */
520#define OMAP4430_CLKSEL_SOURCE_SHIFT 24 525#define OMAP4430_CLKSEL_SOURCE_SHIFT 24
521#define OMAP4430_CLKSEL_SOURCE_MASK BITFIELD(24, 25) 526#define OMAP4430_CLKSEL_SOURCE_MASK (0x3 << 24)
522 527
523/* Renamed from CLKSEL_SOURCE Used by CM_L4PER_MCBSP4_CLKCTRL */ 528/* Renamed from CLKSEL_SOURCE Used by CM_L4PER_MCBSP4_CLKCTRL */
524#define OMAP4430_CLKSEL_SOURCE_24_24_SHIFT 24 529#define OMAP4430_CLKSEL_SOURCE_24_24_SHIFT 24
525#define OMAP4430_CLKSEL_SOURCE_24_24_MASK BITFIELD(24, 24) 530#define OMAP4430_CLKSEL_SOURCE_24_24_MASK (1 << 24)
526 531
527/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 532/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
528#define OMAP4430_CLKSEL_UTMI_P1_SHIFT 24 533#define OMAP4430_CLKSEL_UTMI_P1_SHIFT 24
529#define OMAP4430_CLKSEL_UTMI_P1_MASK BITFIELD(24, 24) 534#define OMAP4430_CLKSEL_UTMI_P1_MASK (1 << 24)
530 535
531/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 536/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
532#define OMAP4430_CLKSEL_UTMI_P2_SHIFT 25 537#define OMAP4430_CLKSEL_UTMI_P2_SHIFT 25
533#define OMAP4430_CLKSEL_UTMI_P2_MASK BITFIELD(25, 25) 538#define OMAP4430_CLKSEL_UTMI_P2_MASK (1 << 25)
534 539
535/* 540/*
536 * Used by CM_WKUP_CLKSTCTRL, CM_EMU_CLKSTCTRL, CM_D2D_CLKSTCTRL, 541 * Used by CM1_ABE_CLKSTCTRL, CM_ALWON_CLKSTCTRL, CM_CAM_CLKSTCTRL,
537 * CM_DUCATI_CLKSTCTRL, CM_L3INSTR_CLKSTCTRL, CM_L3_1_CLKSTCTRL, 542 * CM_CEFUSE_CLKSTCTRL, CM_D2D_CLKSTCTRL, CM_DSS_CLKSTCTRL,
538 * CM_L3_2_CLKSTCTRL, CM_L4CFG_CLKSTCTRL, CM_MEMIF_CLKSTCTRL, 543 * CM_DUCATI_CLKSTCTRL, CM_EMU_CLKSTCTRL, CM_GFX_CLKSTCTRL, CM_IVAHD_CLKSTCTRL,
539 * CM_SDMA_CLKSTCTRL, CM_GFX_CLKSTCTRL, CM_L4PER_CLKSTCTRL, CM_L4SEC_CLKSTCTRL, 544 * CM_L3INIT_CLKSTCTRL, CM_L3INIT_CLKSTCTRL_RESTORE, CM_L3INSTR_CLKSTCTRL,
540 * CM_L3INIT_CLKSTCTRL, CM_CAM_CLKSTCTRL, CM_CEFUSE_CLKSTCTRL, 545 * CM_L3_1_CLKSTCTRL, CM_L3_1_CLKSTCTRL_RESTORE, CM_L3_2_CLKSTCTRL,
541 * CM_L3INIT_CLKSTCTRL_RESTORE, CM_L3_1_CLKSTCTRL_RESTORE, 546 * CM_L3_2_CLKSTCTRL_RESTORE, CM_L4CFG_CLKSTCTRL, CM_L4CFG_CLKSTCTRL_RESTORE,
542 * CM_L3_2_CLKSTCTRL_RESTORE, CM_L4CFG_CLKSTCTRL_RESTORE, 547 * CM_L4PER_CLKSTCTRL, CM_L4PER_CLKSTCTRL_RESTORE, CM_L4SEC_CLKSTCTRL,
543 * CM_L4PER_CLKSTCTRL_RESTORE, CM_MEMIF_CLKSTCTRL_RESTORE, CM_ALWON_CLKSTCTRL, 548 * CM_MEMIF_CLKSTCTRL, CM_MEMIF_CLKSTCTRL_RESTORE, CM_MPU_CLKSTCTRL,
544 * CM_IVAHD_CLKSTCTRL, CM_DSS_CLKSTCTRL, CM_MPU_CLKSTCTRL, CM_TESLA_CLKSTCTRL, 549 * CM_MPU_CLKSTCTRL_RESTORE, CM_SDMA_CLKSTCTRL, CM_TESLA_CLKSTCTRL,
545 * CM1_ABE_CLKSTCTRL, CM_MPU_CLKSTCTRL_RESTORE 550 * CM_WKUP_CLKSTCTRL
546 */ 551 */
547#define OMAP4430_CLKTRCTRL_SHIFT 0 552#define OMAP4430_CLKTRCTRL_SHIFT 0
548#define OMAP4430_CLKTRCTRL_MASK BITFIELD(0, 1) 553#define OMAP4430_CLKTRCTRL_MASK (0x3 << 0)
549 554
550/* Used by CM_EMU_OVERRIDE_DPLL_CORE */ 555/* Used by CM_EMU_OVERRIDE_DPLL_CORE */
551#define OMAP4430_CORE_DPLL_EMU_DIV_SHIFT 0 556#define OMAP4430_CORE_DPLL_EMU_DIV_SHIFT 0
552#define OMAP4430_CORE_DPLL_EMU_DIV_MASK BITFIELD(0, 6) 557#define OMAP4430_CORE_DPLL_EMU_DIV_MASK (0x7f << 0)
553 558
554/* Used by CM_EMU_OVERRIDE_DPLL_CORE */ 559/* Used by CM_EMU_OVERRIDE_DPLL_CORE */
555#define OMAP4430_CORE_DPLL_EMU_MULT_SHIFT 8 560#define OMAP4430_CORE_DPLL_EMU_MULT_SHIFT 8
556#define OMAP4430_CORE_DPLL_EMU_MULT_MASK BITFIELD(8, 18) 561#define OMAP4430_CORE_DPLL_EMU_MULT_MASK (0x7ff << 8)
562
563/* Used by REVISION_CM1, REVISION_CM2 */
564#define OMAP4430_CUSTOM_SHIFT 6
565#define OMAP4430_CUSTOM_MASK (0x3 << 6)
557 566
558/* Used by CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP */ 567/*
568 * Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
569 * CM_L4CFG_DYNAMICDEP_RESTORE
570 */
559#define OMAP4430_D2D_DYNDEP_SHIFT 18 571#define OMAP4430_D2D_DYNDEP_SHIFT 18
560#define OMAP4430_D2D_DYNDEP_MASK BITFIELD(18, 18) 572#define OMAP4430_D2D_DYNDEP_MASK (1 << 18)
561 573
562/* Used by CM_MPU_STATICDEP */ 574/* Used by CM_MPU_STATICDEP */
563#define OMAP4430_D2D_STATDEP_SHIFT 18 575#define OMAP4430_D2D_STATDEP_SHIFT 18
564#define OMAP4430_D2D_STATDEP_MASK BITFIELD(18, 18) 576#define OMAP4430_D2D_STATDEP_MASK (1 << 18)
565 577
566/* 578/*
567 * Used by CM_SSC_DELTAMSTEP_DPLL_PER, CM_SSC_DELTAMSTEP_DPLL_UNIPRO, 579 * Used by CM_SSC_DELTAMSTEP_DPLL_ABE, CM_SSC_DELTAMSTEP_DPLL_CORE,
568 * CM_SSC_DELTAMSTEP_DPLL_USB, CM_SSC_DELTAMSTEP_DPLL_CORE_RESTORE, 580 * CM_SSC_DELTAMSTEP_DPLL_CORE_RESTORE, CM_SSC_DELTAMSTEP_DPLL_DDRPHY,
569 * CM_SSC_DELTAMSTEP_DPLL_ABE, CM_SSC_DELTAMSTEP_DPLL_CORE, 581 * CM_SSC_DELTAMSTEP_DPLL_IVA, CM_SSC_DELTAMSTEP_DPLL_MPU,
570 * CM_SSC_DELTAMSTEP_DPLL_DDRPHY, CM_SSC_DELTAMSTEP_DPLL_IVA, 582 * CM_SSC_DELTAMSTEP_DPLL_PER, CM_SSC_DELTAMSTEP_DPLL_UNIPRO,
571 * CM_SSC_DELTAMSTEP_DPLL_MPU 583 * CM_SSC_DELTAMSTEP_DPLL_USB
572 */ 584 */
573#define OMAP4430_DELTAMSTEP_SHIFT 0 585#define OMAP4430_DELTAMSTEP_SHIFT 0
574#define OMAP4430_DELTAMSTEP_MASK BITFIELD(0, 19) 586#define OMAP4430_DELTAMSTEP_MASK (0xfffff << 0)
575 587
576/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */ 588/* Used by CM_SHADOW_FREQ_CONFIG1, CM_SHADOW_FREQ_CONFIG1_RESTORE */
577#define OMAP4430_DLL_OVERRIDE_SHIFT 2 589#define OMAP4430_DLL_OVERRIDE_SHIFT 2
578#define OMAP4430_DLL_OVERRIDE_MASK BITFIELD(2, 2) 590#define OMAP4430_DLL_OVERRIDE_MASK (1 << 2)
579 591
580/* Renamed from DLL_OVERRIDE Used by CM_DLL_CTRL */ 592/* Renamed from DLL_OVERRIDE Used by CM_DLL_CTRL */
581#define OMAP4430_DLL_OVERRIDE_0_0_SHIFT 0 593#define OMAP4430_DLL_OVERRIDE_0_0_SHIFT 0
582#define OMAP4430_DLL_OVERRIDE_0_0_MASK BITFIELD(0, 0) 594#define OMAP4430_DLL_OVERRIDE_0_0_MASK (1 << 0)
583 595
584/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */ 596/* Used by CM_SHADOW_FREQ_CONFIG1, CM_SHADOW_FREQ_CONFIG1_RESTORE */
585#define OMAP4430_DLL_RESET_SHIFT 3 597#define OMAP4430_DLL_RESET_SHIFT 3
586#define OMAP4430_DLL_RESET_MASK BITFIELD(3, 3) 598#define OMAP4430_DLL_RESET_MASK (1 << 3)
587 599
588/* 600/*
589 * Used by CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO, CM_CLKSEL_DPLL_USB, 601 * Used by CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE,
590 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE, 602 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA,
591 * CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA, CM_CLKSEL_DPLL_MPU 603 * CM_CLKSEL_DPLL_MPU, CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO,
604 * CM_CLKSEL_DPLL_USB
592 */ 605 */
593#define OMAP4430_DPLL_BYP_CLKSEL_SHIFT 23 606#define OMAP4430_DPLL_BYP_CLKSEL_SHIFT 23
594#define OMAP4430_DPLL_BYP_CLKSEL_MASK BITFIELD(23, 23) 607#define OMAP4430_DPLL_BYP_CLKSEL_MASK (1 << 23)
595 608
596/* Used by CM_CLKDCOLDO_DPLL_USB */ 609/* Used by CM_CLKDCOLDO_DPLL_USB */
597#define OMAP4430_DPLL_CLKDCOLDO_GATE_CTRL_SHIFT 8 610#define OMAP4430_DPLL_CLKDCOLDO_GATE_CTRL_SHIFT 8
598#define OMAP4430_DPLL_CLKDCOLDO_GATE_CTRL_MASK BITFIELD(8, 8) 611#define OMAP4430_DPLL_CLKDCOLDO_GATE_CTRL_MASK (1 << 8)
599 612
600/* Used by CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_CORE */ 613/* Used by CM_CLKSEL_DPLL_CORE, CM_CLKSEL_DPLL_CORE_RESTORE */
601#define OMAP4430_DPLL_CLKOUTHIF_CLKSEL_SHIFT 20 614#define OMAP4430_DPLL_CLKOUTHIF_CLKSEL_SHIFT 20
602#define OMAP4430_DPLL_CLKOUTHIF_CLKSEL_MASK BITFIELD(20, 20) 615#define OMAP4430_DPLL_CLKOUTHIF_CLKSEL_MASK (1 << 20)
603 616
604/* 617/*
605 * Used by CM_DIV_M3_DPLL_PER, CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_ABE, 618 * Used by CM_DIV_M3_DPLL_ABE, CM_DIV_M3_DPLL_CORE,
606 * CM_DIV_M3_DPLL_CORE 619 * CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_PER
607 */ 620 */
608#define OMAP4430_DPLL_CLKOUTHIF_DIV_SHIFT 0 621#define OMAP4430_DPLL_CLKOUTHIF_DIV_SHIFT 0
609#define OMAP4430_DPLL_CLKOUTHIF_DIV_MASK BITFIELD(0, 4) 622#define OMAP4430_DPLL_CLKOUTHIF_DIV_MASK (0x1f << 0)
610 623
611/* 624/*
612 * Used by CM_DIV_M3_DPLL_PER, CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_ABE, 625 * Used by CM_DIV_M3_DPLL_ABE, CM_DIV_M3_DPLL_CORE,
613 * CM_DIV_M3_DPLL_CORE 626 * CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_PER
614 */ 627 */
615#define OMAP4430_DPLL_CLKOUTHIF_DIVCHACK_SHIFT 5 628#define OMAP4430_DPLL_CLKOUTHIF_DIVCHACK_SHIFT 5
616#define OMAP4430_DPLL_CLKOUTHIF_DIVCHACK_MASK BITFIELD(5, 5) 629#define OMAP4430_DPLL_CLKOUTHIF_DIVCHACK_MASK (1 << 5)
617 630
618/* 631/*
619 * Used by CM_DIV_M3_DPLL_PER, CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_ABE, 632 * Used by CM_DIV_M3_DPLL_ABE, CM_DIV_M3_DPLL_CORE,
620 * CM_DIV_M3_DPLL_CORE 633 * CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_PER
621 */ 634 */
622#define OMAP4430_DPLL_CLKOUTHIF_GATE_CTRL_SHIFT 8 635#define OMAP4430_DPLL_CLKOUTHIF_GATE_CTRL_SHIFT 8
623#define OMAP4430_DPLL_CLKOUTHIF_GATE_CTRL_MASK BITFIELD(8, 8) 636#define OMAP4430_DPLL_CLKOUTHIF_GATE_CTRL_MASK (1 << 8)
624 637
625/* Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO, CM_DIV_M2_DPLL_ABE */ 638/* Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO */
626#define OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_SHIFT 10 639#define OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_SHIFT 10
627#define OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK BITFIELD(10, 10) 640#define OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK (1 << 10)
628 641
629/* 642/*
630 * Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO, 643 * Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE,
631 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE, 644 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU,
632 * CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU 645 * CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO
633 */ 646 */
634#define OMAP4430_DPLL_CLKOUT_DIV_SHIFT 0 647#define OMAP4430_DPLL_CLKOUT_DIV_SHIFT 0
635#define OMAP4430_DPLL_CLKOUT_DIV_MASK BITFIELD(0, 4) 648#define OMAP4430_DPLL_CLKOUT_DIV_MASK (0x1f << 0)
636 649
637/* Renamed from DPLL_CLKOUT_DIV Used by CM_DIV_M2_DPLL_USB */ 650/* Renamed from DPLL_CLKOUT_DIV Used by CM_DIV_M2_DPLL_USB */
638#define OMAP4430_DPLL_CLKOUT_DIV_0_6_SHIFT 0 651#define OMAP4430_DPLL_CLKOUT_DIV_0_6_SHIFT 0
639#define OMAP4430_DPLL_CLKOUT_DIV_0_6_MASK BITFIELD(0, 6) 652#define OMAP4430_DPLL_CLKOUT_DIV_0_6_MASK (0x7f << 0)
640 653
641/* 654/*
642 * Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO, 655 * Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE,
643 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE, 656 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU,
644 * CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU 657 * CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO
645 */ 658 */
646#define OMAP4430_DPLL_CLKOUT_DIVCHACK_SHIFT 5 659#define OMAP4430_DPLL_CLKOUT_DIVCHACK_SHIFT 5
647#define OMAP4430_DPLL_CLKOUT_DIVCHACK_MASK BITFIELD(5, 5) 660#define OMAP4430_DPLL_CLKOUT_DIVCHACK_MASK (1 << 5)
648 661
649/* Renamed from DPLL_CLKOUT_DIVCHACK Used by CM_DIV_M2_DPLL_USB */ 662/* Renamed from DPLL_CLKOUT_DIVCHACK Used by CM_DIV_M2_DPLL_USB */
650#define OMAP4430_DPLL_CLKOUT_DIVCHACK_M2_USB_SHIFT 7 663#define OMAP4430_DPLL_CLKOUT_DIVCHACK_M2_USB_SHIFT 7
651#define OMAP4430_DPLL_CLKOUT_DIVCHACK_M2_USB_MASK BITFIELD(7, 7) 664#define OMAP4430_DPLL_CLKOUT_DIVCHACK_M2_USB_MASK (1 << 7)
652 665
653/* 666/*
654 * Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_USB, CM_DIV_M2_DPLL_CORE_RESTORE, 667 * Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE,
655 * CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE, CM_DIV_M2_DPLL_DDRPHY, 668 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU,
656 * CM_DIV_M2_DPLL_MPU 669 * CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_USB
657 */ 670 */
658#define OMAP4430_DPLL_CLKOUT_GATE_CTRL_SHIFT 8 671#define OMAP4430_DPLL_CLKOUT_GATE_CTRL_SHIFT 8
659#define OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK BITFIELD(8, 8) 672#define OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK (1 << 8)
660 673
661/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */ 674/* Used by CM_SHADOW_FREQ_CONFIG1, CM_SHADOW_FREQ_CONFIG1_RESTORE */
662#define OMAP4430_DPLL_CORE_DPLL_EN_SHIFT 8 675#define OMAP4430_DPLL_CORE_DPLL_EN_SHIFT 8
663#define OMAP4430_DPLL_CORE_DPLL_EN_MASK BITFIELD(8, 10) 676#define OMAP4430_DPLL_CORE_DPLL_EN_MASK (0x7 << 8)
664 677
665/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */ 678/* Used by CM_SHADOW_FREQ_CONFIG1, CM_SHADOW_FREQ_CONFIG1_RESTORE */
666#define OMAP4430_DPLL_CORE_M2_DIV_SHIFT 11 679#define OMAP4430_DPLL_CORE_M2_DIV_SHIFT 11
667#define OMAP4430_DPLL_CORE_M2_DIV_MASK BITFIELD(11, 15) 680#define OMAP4430_DPLL_CORE_M2_DIV_MASK (0x1f << 11)
668 681
669/* Used by CM_SHADOW_FREQ_CONFIG2 */ 682/* Used by CM_SHADOW_FREQ_CONFIG2, CM_SHADOW_FREQ_CONFIG2_RESTORE */
670#define OMAP4430_DPLL_CORE_M5_DIV_SHIFT 3 683#define OMAP4430_DPLL_CORE_M5_DIV_SHIFT 3
671#define OMAP4430_DPLL_CORE_M5_DIV_MASK BITFIELD(3, 7) 684#define OMAP4430_DPLL_CORE_M5_DIV_MASK (0x1f << 3)
672
673/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */
674#define OMAP4430_DPLL_CORE_SYS_REF_CLKSEL_SHIFT 1
675#define OMAP4430_DPLL_CORE_SYS_REF_CLKSEL_MASK BITFIELD(1, 1)
676 685
677/* 686/*
678 * Used by CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO, 687 * Used by CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE,
679 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE, 688 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA,
680 * CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA, CM_CLKSEL_DPLL_MPU 689 * CM_CLKSEL_DPLL_MPU, CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO
681 */ 690 */
682#define OMAP4430_DPLL_DIV_SHIFT 0 691#define OMAP4430_DPLL_DIV_SHIFT 0
683#define OMAP4430_DPLL_DIV_MASK BITFIELD(0, 6) 692#define OMAP4430_DPLL_DIV_MASK (0x7f << 0)
684 693
685/* Renamed from DPLL_DIV Used by CM_CLKSEL_DPLL_USB */ 694/* Renamed from DPLL_DIV Used by CM_CLKSEL_DPLL_USB */
686#define OMAP4430_DPLL_DIV_0_7_SHIFT 0 695#define OMAP4430_DPLL_DIV_0_7_SHIFT 0
687#define OMAP4430_DPLL_DIV_0_7_MASK BITFIELD(0, 7) 696#define OMAP4430_DPLL_DIV_0_7_MASK (0xff << 0)
688 697
689/* 698/*
690 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_USB, 699 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
691 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 700 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
692 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 701 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER
693 */ 702 */
694#define OMAP4430_DPLL_DRIFTGUARD_EN_SHIFT 8 703#define OMAP4430_DPLL_DRIFTGUARD_EN_SHIFT 8
695#define OMAP4430_DPLL_DRIFTGUARD_EN_MASK BITFIELD(8, 8) 704#define OMAP4430_DPLL_DRIFTGUARD_EN_MASK (1 << 8)
696 705
697/* Renamed from DPLL_DRIFTGUARD_EN Used by CM_CLKMODE_DPLL_UNIPRO */ 706/* Renamed from DPLL_DRIFTGUARD_EN Used by CM_CLKMODE_DPLL_UNIPRO */
698#define OMAP4430_DPLL_DRIFTGUARD_EN_3_3_SHIFT 3 707#define OMAP4430_DPLL_DRIFTGUARD_EN_3_3_SHIFT 3
699#define OMAP4430_DPLL_DRIFTGUARD_EN_3_3_MASK BITFIELD(3, 3) 708#define OMAP4430_DPLL_DRIFTGUARD_EN_3_3_MASK (1 << 3)
700 709
701/* 710/*
702 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, CM_CLKMODE_DPLL_USB, 711 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
703 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 712 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
704 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 713 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO,
714 * CM_CLKMODE_DPLL_USB
705 */ 715 */
706#define OMAP4430_DPLL_EN_SHIFT 0 716#define OMAP4430_DPLL_EN_SHIFT 0
707#define OMAP4430_DPLL_EN_MASK BITFIELD(0, 2) 717#define OMAP4430_DPLL_EN_MASK (0x7 << 0)
708 718
709/* 719/*
710 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, 720 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
711 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 721 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
712 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 722 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO
713 */ 723 */
714#define OMAP4430_DPLL_LPMODE_EN_SHIFT 10 724#define OMAP4430_DPLL_LPMODE_EN_SHIFT 10
715#define OMAP4430_DPLL_LPMODE_EN_MASK BITFIELD(10, 10) 725#define OMAP4430_DPLL_LPMODE_EN_MASK (1 << 10)
716 726
717/* 727/*
718 * Used by CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO, 728 * Used by CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE,
719 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_ABE, CM_CLKSEL_DPLL_CORE, 729 * CM_CLKSEL_DPLL_CORE_RESTORE, CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA,
720 * CM_CLKSEL_DPLL_DDRPHY, CM_CLKSEL_DPLL_IVA, CM_CLKSEL_DPLL_MPU 730 * CM_CLKSEL_DPLL_MPU, CM_CLKSEL_DPLL_PER, CM_CLKSEL_DPLL_UNIPRO
721 */ 731 */
722#define OMAP4430_DPLL_MULT_SHIFT 8 732#define OMAP4430_DPLL_MULT_SHIFT 8
723#define OMAP4430_DPLL_MULT_MASK BITFIELD(8, 18) 733#define OMAP4430_DPLL_MULT_MASK (0x7ff << 8)
724 734
725/* Renamed from DPLL_MULT Used by CM_CLKSEL_DPLL_USB */ 735/* Renamed from DPLL_MULT Used by CM_CLKSEL_DPLL_USB */
726#define OMAP4430_DPLL_MULT_USB_SHIFT 8 736#define OMAP4430_DPLL_MULT_USB_SHIFT 8
727#define OMAP4430_DPLL_MULT_USB_MASK BITFIELD(8, 19) 737#define OMAP4430_DPLL_MULT_USB_MASK (0xfff << 8)
728 738
729/* 739/*
730 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, 740 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
731 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 741 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
732 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 742 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO
733 */ 743 */
734#define OMAP4430_DPLL_REGM4XEN_SHIFT 11 744#define OMAP4430_DPLL_REGM4XEN_SHIFT 11
735#define OMAP4430_DPLL_REGM4XEN_MASK BITFIELD(11, 11) 745#define OMAP4430_DPLL_REGM4XEN_MASK (1 << 11)
736 746
737/* Used by CM_CLKSEL_DPLL_USB */ 747/* Used by CM_CLKSEL_DPLL_USB */
738#define OMAP4430_DPLL_SD_DIV_SHIFT 24 748#define OMAP4430_DPLL_SD_DIV_SHIFT 24
739#define OMAP4430_DPLL_SD_DIV_MASK BITFIELD(24, 31) 749#define OMAP4430_DPLL_SD_DIV_MASK (0xff << 24)
740 750
741/* 751/*
742 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, CM_CLKMODE_DPLL_USB, 752 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
743 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 753 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
744 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 754 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO,
755 * CM_CLKMODE_DPLL_USB
745 */ 756 */
746#define OMAP4430_DPLL_SSC_ACK_SHIFT 13 757#define OMAP4430_DPLL_SSC_ACK_SHIFT 13
747#define OMAP4430_DPLL_SSC_ACK_MASK BITFIELD(13, 13) 758#define OMAP4430_DPLL_SSC_ACK_MASK (1 << 13)
748 759
749/* 760/*
750 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, CM_CLKMODE_DPLL_USB, 761 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
751 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 762 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
752 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 763 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO,
764 * CM_CLKMODE_DPLL_USB
753 */ 765 */
754#define OMAP4430_DPLL_SSC_DOWNSPREAD_SHIFT 14 766#define OMAP4430_DPLL_SSC_DOWNSPREAD_SHIFT 14
755#define OMAP4430_DPLL_SSC_DOWNSPREAD_MASK BITFIELD(14, 14) 767#define OMAP4430_DPLL_SSC_DOWNSPREAD_MASK (1 << 14)
756 768
757/* 769/*
758 * Used by CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO, CM_CLKMODE_DPLL_USB, 770 * Used by CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE,
759 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_ABE, CM_CLKMODE_DPLL_CORE, 771 * CM_CLKMODE_DPLL_CORE_RESTORE, CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA,
760 * CM_CLKMODE_DPLL_DDRPHY, CM_CLKMODE_DPLL_IVA, CM_CLKMODE_DPLL_MPU 772 * CM_CLKMODE_DPLL_MPU, CM_CLKMODE_DPLL_PER, CM_CLKMODE_DPLL_UNIPRO,
773 * CM_CLKMODE_DPLL_USB
761 */ 774 */
762#define OMAP4430_DPLL_SSC_EN_SHIFT 12 775#define OMAP4430_DPLL_SSC_EN_SHIFT 12
763#define OMAP4430_DPLL_SSC_EN_MASK BITFIELD(12, 12) 776#define OMAP4430_DPLL_SSC_EN_MASK (1 << 12)
764 777
765/* Used by CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, CM_L4PER_DYNAMICDEP */ 778/*
779 * Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
780 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_L4PER_DYNAMICDEP, CM_L4PER_DYNAMICDEP_RESTORE
781 */
766#define OMAP4430_DSS_DYNDEP_SHIFT 8 782#define OMAP4430_DSS_DYNDEP_SHIFT 8
767#define OMAP4430_DSS_DYNDEP_MASK BITFIELD(8, 8) 783#define OMAP4430_DSS_DYNDEP_MASK (1 << 8)
768 784
769/* 785/*
770 * Used by CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, 786 * Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_SDMA_STATICDEP,
771 * CM_MPU_STATICDEP 787 * CM_SDMA_STATICDEP_RESTORE
772 */ 788 */
773#define OMAP4430_DSS_STATDEP_SHIFT 8 789#define OMAP4430_DSS_STATDEP_SHIFT 8
774#define OMAP4430_DSS_STATDEP_MASK BITFIELD(8, 8) 790#define OMAP4430_DSS_STATDEP_MASK (1 << 8)
775 791
776/* Used by CM_L3_2_DYNAMICDEP */ 792/* Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE */
777#define OMAP4430_DUCATI_DYNDEP_SHIFT 0 793#define OMAP4430_DUCATI_DYNDEP_SHIFT 0
778#define OMAP4430_DUCATI_DYNDEP_MASK BITFIELD(0, 0) 794#define OMAP4430_DUCATI_DYNDEP_MASK (1 << 0)
779 795
780/* Used by CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP */ 796/* Used by CM_MPU_STATICDEP, CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE */
781#define OMAP4430_DUCATI_STATDEP_SHIFT 0 797#define OMAP4430_DUCATI_STATDEP_SHIFT 0
782#define OMAP4430_DUCATI_STATDEP_MASK BITFIELD(0, 0) 798#define OMAP4430_DUCATI_STATDEP_MASK (1 << 0)
783 799
784/* Used by CM_SHADOW_FREQ_CONFIG1_RESTORE, CM_SHADOW_FREQ_CONFIG1 */ 800/* Used by CM_SHADOW_FREQ_CONFIG1, CM_SHADOW_FREQ_CONFIG1_RESTORE */
785#define OMAP4430_FREQ_UPDATE_SHIFT 0 801#define OMAP4430_FREQ_UPDATE_SHIFT 0
786#define OMAP4430_FREQ_UPDATE_MASK BITFIELD(0, 0) 802#define OMAP4430_FREQ_UPDATE_MASK (1 << 0)
803
804/* Used by REVISION_CM1, REVISION_CM2 */
805#define OMAP4430_FUNC_SHIFT 16
806#define OMAP4430_FUNC_MASK (0xfff << 16)
787 807
788/* Used by CM_L3_2_DYNAMICDEP */ 808/* Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE */
789#define OMAP4430_GFX_DYNDEP_SHIFT 10 809#define OMAP4430_GFX_DYNDEP_SHIFT 10
790#define OMAP4430_GFX_DYNDEP_MASK BITFIELD(10, 10) 810#define OMAP4430_GFX_DYNDEP_MASK (1 << 10)
791 811
792/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */ 812/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */
793#define OMAP4430_GFX_STATDEP_SHIFT 10 813#define OMAP4430_GFX_STATDEP_SHIFT 10
794#define OMAP4430_GFX_STATDEP_MASK BITFIELD(10, 10) 814#define OMAP4430_GFX_STATDEP_MASK (1 << 10)
795 815
796/* Used by CM_SHADOW_FREQ_CONFIG2 */ 816/* Used by CM_SHADOW_FREQ_CONFIG2, CM_SHADOW_FREQ_CONFIG2_RESTORE */
797#define OMAP4430_GPMC_FREQ_UPDATE_SHIFT 0 817#define OMAP4430_GPMC_FREQ_UPDATE_SHIFT 0
798#define OMAP4430_GPMC_FREQ_UPDATE_MASK BITFIELD(0, 0) 818#define OMAP4430_GPMC_FREQ_UPDATE_MASK (1 << 0)
799 819
800/* 820/*
801 * Used by CM_DIV_M4_DPLL_PER, CM_DIV_M4_DPLL_CORE_RESTORE, 821 * Used by CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_CORE_RESTORE,
802 * CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA 822 * CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA, CM_DIV_M4_DPLL_PER
803 */ 823 */
804#define OMAP4430_HSDIVIDER_CLKOUT1_DIV_SHIFT 0 824#define OMAP4430_HSDIVIDER_CLKOUT1_DIV_SHIFT 0
805#define OMAP4430_HSDIVIDER_CLKOUT1_DIV_MASK BITFIELD(0, 4) 825#define OMAP4430_HSDIVIDER_CLKOUT1_DIV_MASK (0x1f << 0)
806 826
807/* 827/*
808 * Used by CM_DIV_M4_DPLL_PER, CM_DIV_M4_DPLL_CORE_RESTORE, 828 * Used by CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_CORE_RESTORE,
809 * CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA 829 * CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA, CM_DIV_M4_DPLL_PER
810 */ 830 */
811#define OMAP4430_HSDIVIDER_CLKOUT1_DIVCHACK_SHIFT 5 831#define OMAP4430_HSDIVIDER_CLKOUT1_DIVCHACK_SHIFT 5
812#define OMAP4430_HSDIVIDER_CLKOUT1_DIVCHACK_MASK BITFIELD(5, 5) 832#define OMAP4430_HSDIVIDER_CLKOUT1_DIVCHACK_MASK (1 << 5)
813 833
814/* 834/*
815 * Used by CM_DIV_M4_DPLL_PER, CM_DIV_M4_DPLL_CORE_RESTORE, 835 * Used by CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_CORE_RESTORE,
816 * CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA 836 * CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA, CM_DIV_M4_DPLL_PER
817 */ 837 */
818#define OMAP4430_HSDIVIDER_CLKOUT1_GATE_CTRL_SHIFT 8 838#define OMAP4430_HSDIVIDER_CLKOUT1_GATE_CTRL_SHIFT 8
819#define OMAP4430_HSDIVIDER_CLKOUT1_GATE_CTRL_MASK BITFIELD(8, 8) 839#define OMAP4430_HSDIVIDER_CLKOUT1_GATE_CTRL_MASK (1 << 8)
820 840
821/* 841/*
822 * Used by CM_DIV_M4_DPLL_PER, CM_DIV_M4_DPLL_CORE_RESTORE, 842 * Used by CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_CORE_RESTORE,
823 * CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA 843 * CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA, CM_DIV_M4_DPLL_PER
824 */ 844 */
825#define OMAP4430_HSDIVIDER_CLKOUT1_PWDN_SHIFT 12 845#define OMAP4430_HSDIVIDER_CLKOUT1_PWDN_SHIFT 12
826#define OMAP4430_HSDIVIDER_CLKOUT1_PWDN_MASK BITFIELD(12, 12) 846#define OMAP4430_HSDIVIDER_CLKOUT1_PWDN_MASK (1 << 12)
827 847
828/* 848/*
829 * Used by CM_DIV_M5_DPLL_PER, CM_DIV_M5_DPLL_CORE_RESTORE, 849 * Used by CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_CORE_RESTORE,
830 * CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA 850 * CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA, CM_DIV_M5_DPLL_PER
831 */ 851 */
832#define OMAP4430_HSDIVIDER_CLKOUT2_DIV_SHIFT 0 852#define OMAP4430_HSDIVIDER_CLKOUT2_DIV_SHIFT 0
833#define OMAP4430_HSDIVIDER_CLKOUT2_DIV_MASK BITFIELD(0, 4) 853#define OMAP4430_HSDIVIDER_CLKOUT2_DIV_MASK (0x1f << 0)
834 854
835/* 855/*
836 * Used by CM_DIV_M5_DPLL_PER, CM_DIV_M5_DPLL_CORE_RESTORE, 856 * Used by CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_CORE_RESTORE,
837 * CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA 857 * CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA, CM_DIV_M5_DPLL_PER
838 */ 858 */
839#define OMAP4430_HSDIVIDER_CLKOUT2_DIVCHACK_SHIFT 5 859#define OMAP4430_HSDIVIDER_CLKOUT2_DIVCHACK_SHIFT 5
840#define OMAP4430_HSDIVIDER_CLKOUT2_DIVCHACK_MASK BITFIELD(5, 5) 860#define OMAP4430_HSDIVIDER_CLKOUT2_DIVCHACK_MASK (1 << 5)
841 861
842/* 862/*
843 * Used by CM_DIV_M5_DPLL_PER, CM_DIV_M5_DPLL_CORE_RESTORE, 863 * Used by CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_CORE_RESTORE,
844 * CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA 864 * CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA, CM_DIV_M5_DPLL_PER
845 */ 865 */
846#define OMAP4430_HSDIVIDER_CLKOUT2_GATE_CTRL_SHIFT 8 866#define OMAP4430_HSDIVIDER_CLKOUT2_GATE_CTRL_SHIFT 8
847#define OMAP4430_HSDIVIDER_CLKOUT2_GATE_CTRL_MASK BITFIELD(8, 8) 867#define OMAP4430_HSDIVIDER_CLKOUT2_GATE_CTRL_MASK (1 << 8)
848 868
849/* 869/*
850 * Used by CM_DIV_M5_DPLL_PER, CM_DIV_M5_DPLL_CORE_RESTORE, 870 * Used by CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_CORE_RESTORE,
851 * CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA 871 * CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA, CM_DIV_M5_DPLL_PER
852 */ 872 */
853#define OMAP4430_HSDIVIDER_CLKOUT2_PWDN_SHIFT 12 873#define OMAP4430_HSDIVIDER_CLKOUT2_PWDN_SHIFT 12
854#define OMAP4430_HSDIVIDER_CLKOUT2_PWDN_MASK BITFIELD(12, 12) 874#define OMAP4430_HSDIVIDER_CLKOUT2_PWDN_MASK (1 << 12)
855 875
856/* 876/*
857 * Used by CM_DIV_M6_DPLL_PER, CM_DIV_M6_DPLL_CORE_RESTORE, 877 * Used by CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_CORE_RESTORE,
858 * CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_DDRPHY 878 * CM_DIV_M6_DPLL_DDRPHY, CM_DIV_M6_DPLL_PER
859 */ 879 */
860#define OMAP4430_HSDIVIDER_CLKOUT3_DIV_SHIFT 0 880#define OMAP4430_HSDIVIDER_CLKOUT3_DIV_SHIFT 0
861#define OMAP4430_HSDIVIDER_CLKOUT3_DIV_MASK BITFIELD(0, 4) 881#define OMAP4430_HSDIVIDER_CLKOUT3_DIV_MASK (0x1f << 0)
862 882
863/* 883/*
864 * Used by CM_DIV_M6_DPLL_PER, CM_DIV_M6_DPLL_CORE_RESTORE, 884 * Used by CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_CORE_RESTORE,
865 * CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_DDRPHY 885 * CM_DIV_M6_DPLL_DDRPHY, CM_DIV_M6_DPLL_PER
866 */ 886 */
867#define OMAP4430_HSDIVIDER_CLKOUT3_DIVCHACK_SHIFT 5 887#define OMAP4430_HSDIVIDER_CLKOUT3_DIVCHACK_SHIFT 5
868#define OMAP4430_HSDIVIDER_CLKOUT3_DIVCHACK_MASK BITFIELD(5, 5) 888#define OMAP4430_HSDIVIDER_CLKOUT3_DIVCHACK_MASK (1 << 5)
869 889
870/* 890/*
871 * Used by CM_DIV_M6_DPLL_PER, CM_DIV_M6_DPLL_CORE_RESTORE, 891 * Used by CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_CORE_RESTORE,
872 * CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_DDRPHY 892 * CM_DIV_M6_DPLL_DDRPHY, CM_DIV_M6_DPLL_PER
873 */ 893 */
874#define OMAP4430_HSDIVIDER_CLKOUT3_GATE_CTRL_SHIFT 8 894#define OMAP4430_HSDIVIDER_CLKOUT3_GATE_CTRL_SHIFT 8
875#define OMAP4430_HSDIVIDER_CLKOUT3_GATE_CTRL_MASK BITFIELD(8, 8) 895#define OMAP4430_HSDIVIDER_CLKOUT3_GATE_CTRL_MASK (1 << 8)
876 896
877/* 897/*
878 * Used by CM_DIV_M6_DPLL_PER, CM_DIV_M6_DPLL_CORE_RESTORE, 898 * Used by CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_CORE_RESTORE,
879 * CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_DDRPHY 899 * CM_DIV_M6_DPLL_DDRPHY, CM_DIV_M6_DPLL_PER
880 */ 900 */
881#define OMAP4430_HSDIVIDER_CLKOUT3_PWDN_SHIFT 12 901#define OMAP4430_HSDIVIDER_CLKOUT3_PWDN_SHIFT 12
882#define OMAP4430_HSDIVIDER_CLKOUT3_PWDN_MASK BITFIELD(12, 12) 902#define OMAP4430_HSDIVIDER_CLKOUT3_PWDN_MASK (1 << 12)
883 903
884/* 904/*
885 * Used by CM_DIV_M7_DPLL_PER, CM_DIV_M7_DPLL_CORE_RESTORE, 905 * Used by CM_DIV_M7_DPLL_CORE, CM_DIV_M7_DPLL_CORE_RESTORE,
886 * CM_DIV_M7_DPLL_CORE 906 * CM_DIV_M7_DPLL_PER
887 */ 907 */
888#define OMAP4430_HSDIVIDER_CLKOUT4_DIV_SHIFT 0 908#define OMAP4430_HSDIVIDER_CLKOUT4_DIV_SHIFT 0
889#define OMAP4430_HSDIVIDER_CLKOUT4_DIV_MASK BITFIELD(0, 4) 909#define OMAP4430_HSDIVIDER_CLKOUT4_DIV_MASK (0x1f << 0)
890 910
891/* 911/*
892 * Used by CM_DIV_M7_DPLL_PER, CM_DIV_M7_DPLL_CORE_RESTORE, 912 * Used by CM_DIV_M7_DPLL_CORE, CM_DIV_M7_DPLL_CORE_RESTORE,
893 * CM_DIV_M7_DPLL_CORE 913 * CM_DIV_M7_DPLL_PER
894 */ 914 */
895#define OMAP4430_HSDIVIDER_CLKOUT4_DIVCHACK_SHIFT 5 915#define OMAP4430_HSDIVIDER_CLKOUT4_DIVCHACK_SHIFT 5
896#define OMAP4430_HSDIVIDER_CLKOUT4_DIVCHACK_MASK BITFIELD(5, 5) 916#define OMAP4430_HSDIVIDER_CLKOUT4_DIVCHACK_MASK (1 << 5)
897 917
898/* 918/*
899 * Used by CM_DIV_M7_DPLL_PER, CM_DIV_M7_DPLL_CORE_RESTORE, 919 * Used by CM_DIV_M7_DPLL_CORE, CM_DIV_M7_DPLL_CORE_RESTORE,
900 * CM_DIV_M7_DPLL_CORE 920 * CM_DIV_M7_DPLL_PER
901 */ 921 */
902#define OMAP4430_HSDIVIDER_CLKOUT4_GATE_CTRL_SHIFT 8 922#define OMAP4430_HSDIVIDER_CLKOUT4_GATE_CTRL_SHIFT 8
903#define OMAP4430_HSDIVIDER_CLKOUT4_GATE_CTRL_MASK BITFIELD(8, 8) 923#define OMAP4430_HSDIVIDER_CLKOUT4_GATE_CTRL_MASK (1 << 8)
904 924
905/* 925/*
906 * Used by CM_DIV_M7_DPLL_PER, CM_DIV_M7_DPLL_CORE_RESTORE, 926 * Used by CM_DIV_M7_DPLL_CORE, CM_DIV_M7_DPLL_CORE_RESTORE,
907 * CM_DIV_M7_DPLL_CORE 927 * CM_DIV_M7_DPLL_PER
908 */ 928 */
909#define OMAP4430_HSDIVIDER_CLKOUT4_PWDN_SHIFT 12 929#define OMAP4430_HSDIVIDER_CLKOUT4_PWDN_SHIFT 12
910#define OMAP4430_HSDIVIDER_CLKOUT4_PWDN_MASK BITFIELD(12, 12) 930#define OMAP4430_HSDIVIDER_CLKOUT4_PWDN_MASK (1 << 12)
911 931
912/* 932/*
913 * Used by PRM_PRM_PROFILING_CLKCTRL, CM_WKUP_GPIO1_CLKCTRL, 933 * Used by CM1_ABE_AESS_CLKCTRL, CM1_ABE_DMIC_CLKCTRL, CM1_ABE_L4ABE_CLKCTRL,
914 * CM_WKUP_KEYBOARD_CLKCTRL, CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_RTC_CLKCTRL, 934 * CM1_ABE_MCASP_CLKCTRL, CM1_ABE_MCBSP1_CLKCTRL, CM1_ABE_MCBSP2_CLKCTRL,
915 * CM_WKUP_SARRAM_CLKCTRL, CM_WKUP_SYNCTIMER_CLKCTRL, CM_WKUP_TIMER12_CLKCTRL, 935 * CM1_ABE_MCBSP3_CLKCTRL, CM1_ABE_PDM_CLKCTRL, CM1_ABE_SLIMBUS_CLKCTRL,
916 * CM_WKUP_TIMER1_CLKCTRL, CM_WKUP_USIM_CLKCTRL, CM_WKUP_WDT1_CLKCTRL, 936 * CM1_ABE_TIMER5_CLKCTRL, CM1_ABE_TIMER6_CLKCTRL, CM1_ABE_TIMER7_CLKCTRL,
917 * CM_WKUP_WDT2_CLKCTRL, CM_EMU_DEBUGSS_CLKCTRL, CM_D2D_MODEM_ICR_CLKCTRL, 937 * CM1_ABE_TIMER8_CLKCTRL, CM1_ABE_WDT3_CLKCTRL, CM_ALWON_MDMINTC_CLKCTRL,
918 * CM_D2D_SAD2D_CLKCTRL, CM_D2D_SAD2D_FW_CLKCTRL, CM_DUCATI_DUCATI_CLKCTRL, 938 * CM_ALWON_SR_CORE_CLKCTRL, CM_ALWON_SR_IVA_CLKCTRL, CM_ALWON_SR_MPU_CLKCTRL,
919 * CM_L3INSTR_L3_3_CLKCTRL, CM_L3INSTR_L3_INSTR_CLKCTRL, 939 * CM_CAM_FDIF_CLKCTRL, CM_CAM_ISS_CLKCTRL, CM_CEFUSE_CEFUSE_CLKCTRL,
920 * CM_L3INSTR_OCP_WP1_CLKCTRL, CM_L3_1_L3_1_CLKCTRL, CM_L3_2_GPMC_CLKCTRL, 940 * CM_CM1_PROFILING_CLKCTRL, CM_CM1_PROFILING_CLKCTRL_RESTORE,
921 * CM_L3_2_L3_2_CLKCTRL, CM_L3_2_OCMC_RAM_CLKCTRL, CM_L4CFG_HW_SEM_CLKCTRL, 941 * CM_CM2_PROFILING_CLKCTRL, CM_CM2_PROFILING_CLKCTRL_RESTORE,
922 * CM_L4CFG_L4_CFG_CLKCTRL, CM_L4CFG_MAILBOX_CLKCTRL, CM_L4CFG_SAR_ROM_CLKCTRL, 942 * CM_D2D_MODEM_ICR_CLKCTRL, CM_D2D_SAD2D_CLKCTRL, CM_D2D_SAD2D_FW_CLKCTRL,
923 * CM_MEMIF_DMM_CLKCTRL, CM_MEMIF_EMIF_1_CLKCTRL, CM_MEMIF_EMIF_2_CLKCTRL, 943 * CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL, CM_DUCATI_DUCATI_CLKCTRL,
924 * CM_MEMIF_EMIF_FW_CLKCTRL, CM_MEMIF_EMIF_H1_CLKCTRL, 944 * CM_EMU_DEBUGSS_CLKCTRL, CM_GFX_GFX_CLKCTRL, CM_IVAHD_IVAHD_CLKCTRL,
925 * CM_MEMIF_EMIF_H2_CLKCTRL, CM_SDMA_SDMA_CLKCTRL, CM_GFX_GFX_CLKCTRL, 945 * CM_IVAHD_SL2_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL,
926 * CM_L4PER_ADC_CLKCTRL, CM_L4PER_DMTIMER10_CLKCTRL,
927 * CM_L4PER_DMTIMER11_CLKCTRL, CM_L4PER_DMTIMER2_CLKCTRL,
928 * CM_L4PER_DMTIMER3_CLKCTRL, CM_L4PER_DMTIMER4_CLKCTRL,
929 * CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_ELM_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL,
930 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL,
931 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_HDQ1W_CLKCTRL, CM_L4PER_HECC1_CLKCTRL,
932 * CM_L4PER_HECC2_CLKCTRL, CM_L4PER_I2C1_CLKCTRL, CM_L4PER_I2C2_CLKCTRL,
933 * CM_L4PER_I2C3_CLKCTRL, CM_L4PER_I2C4_CLKCTRL, CM_L4PER_I2C5_CLKCTRL,
934 * CM_L4PER_L4PER_CLKCTRL, CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL,
935 * CM_L4PER_MCBSP4_CLKCTRL, CM_L4PER_MCSPI1_CLKCTRL, CM_L4PER_MCSPI2_CLKCTRL,
936 * CM_L4PER_MCSPI3_CLKCTRL, CM_L4PER_MCSPI4_CLKCTRL, CM_L4PER_MGATE_CLKCTRL,
937 * CM_L4PER_MMCSD3_CLKCTRL, CM_L4PER_MMCSD4_CLKCTRL, CM_L4PER_MMCSD5_CLKCTRL,
938 * CM_L4PER_MSPROHG_CLKCTRL, CM_L4PER_SLIMBUS2_CLKCTRL, CM_L4PER_UART1_CLKCTRL,
939 * CM_L4PER_UART2_CLKCTRL, CM_L4PER_UART3_CLKCTRL, CM_L4PER_UART4_CLKCTRL,
940 * CM_L4SEC_AES1_CLKCTRL, CM_L4SEC_AES2_CLKCTRL, CM_L4SEC_CRYPTODMA_CLKCTRL,
941 * CM_L4SEC_DES3DES_CLKCTRL, CM_L4SEC_PKAEIP29_CLKCTRL, CM_L4SEC_RNG_CLKCTRL,
942 * CM_L4SEC_SHA2MD51_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL,
943 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL, 946 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL,
944 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL, 947 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL,
945 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL, 948 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL,
946 * CM_L3INIT_USBPHYOCP2SCP_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL, 949 * CM_L3INIT_USBPHYOCP2SCP_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL,
947 * CM_L3INIT_USB_HOST_FS_CLKCTRL, CM_L3INIT_USB_OTG_CLKCTRL, 950 * CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, CM_L3INIT_USB_HOST_FS_CLKCTRL,
948 * CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_XHPI_CLKCTRL, CM_CAM_FDIF_CLKCTRL, 951 * CM_L3INIT_USB_OTG_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL,
949 * CM_CAM_ISS_CLKCTRL, CM_CEFUSE_CEFUSE_CLKCTRL, 952 * CM_L3INIT_USB_TLL_CLKCTRL_RESTORE, CM_L3INIT_XHPI_CLKCTRL,
950 * CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE, 953 * CM_L3INSTR_L3_3_CLKCTRL, CM_L3INSTR_L3_3_CLKCTRL_RESTORE,
951 * CM_L3INSTR_L3_3_CLKCTRL_RESTORE, CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE, 954 * CM_L3INSTR_L3_INSTR_CLKCTRL, CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE,
952 * CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE, CM_L4PER_GPIO2_CLKCTRL_RESTORE, 955 * CM_L3INSTR_OCP_WP1_CLKCTRL, CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE,
953 * CM_L4PER_GPIO3_CLKCTRL_RESTORE, CM_L4PER_GPIO4_CLKCTRL_RESTORE, 956 * CM_L3_1_L3_1_CLKCTRL, CM_L3_2_GPMC_CLKCTRL, CM_L3_2_L3_2_CLKCTRL,
954 * CM_L4PER_GPIO5_CLKCTRL_RESTORE, CM_L4PER_GPIO6_CLKCTRL_RESTORE, 957 * CM_L3_2_OCMC_RAM_CLKCTRL, CM_L4CFG_HW_SEM_CLKCTRL, CM_L4CFG_L4_CFG_CLKCTRL,
955 * CM_ALWON_MDMINTC_CLKCTRL, CM_ALWON_SR_CORE_CLKCTRL, CM_ALWON_SR_IVA_CLKCTRL, 958 * CM_L4CFG_MAILBOX_CLKCTRL, CM_L4CFG_SAR_ROM_CLKCTRL, CM_L4PER_ADC_CLKCTRL,
956 * CM_ALWON_SR_MPU_CLKCTRL, CM_IVAHD_IVAHD_CLKCTRL, CM_IVAHD_SL2_CLKCTRL, 959 * CM_L4PER_DMTIMER10_CLKCTRL, CM_L4PER_DMTIMER11_CLKCTRL,
957 * CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL, CM_CM2_PROFILING_CLKCTRL, 960 * CM_L4PER_DMTIMER2_CLKCTRL, CM_L4PER_DMTIMER3_CLKCTRL,
958 * CM_MPU_MPU_CLKCTRL, CM_TESLA_TESLA_CLKCTRL, CM1_ABE_AESS_CLKCTRL, 961 * CM_L4PER_DMTIMER4_CLKCTRL, CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_ELM_CLKCTRL,
959 * CM1_ABE_DMIC_CLKCTRL, CM1_ABE_L4ABE_CLKCTRL, CM1_ABE_MCASP_CLKCTRL, 962 * CM_L4PER_GPIO2_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL_RESTORE,
960 * CM1_ABE_MCBSP1_CLKCTRL, CM1_ABE_MCBSP2_CLKCTRL, CM1_ABE_MCBSP3_CLKCTRL, 963 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO3_CLKCTRL_RESTORE,
961 * CM1_ABE_PDM_CLKCTRL, CM1_ABE_SLIMBUS_CLKCTRL, CM1_ABE_TIMER5_CLKCTRL, 964 * CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL_RESTORE,
962 * CM1_ABE_TIMER6_CLKCTRL, CM1_ABE_TIMER7_CLKCTRL, CM1_ABE_TIMER8_CLKCTRL, 965 * CM_L4PER_GPIO5_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL_RESTORE,
963 * CM1_ABE_WDT3_CLKCTRL, CM_CM1_PROFILING_CLKCTRL 966 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_GPIO6_CLKCTRL_RESTORE,
967 * CM_L4PER_HDQ1W_CLKCTRL, CM_L4PER_HECC1_CLKCTRL, CM_L4PER_HECC2_CLKCTRL,
968 * CM_L4PER_I2C1_CLKCTRL, CM_L4PER_I2C2_CLKCTRL, CM_L4PER_I2C3_CLKCTRL,
969 * CM_L4PER_I2C4_CLKCTRL, CM_L4PER_I2C5_CLKCTRL, CM_L4PER_L4PER_CLKCTRL,
970 * CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL, CM_L4PER_MCBSP4_CLKCTRL,
971 * CM_L4PER_MCSPI1_CLKCTRL, CM_L4PER_MCSPI2_CLKCTRL, CM_L4PER_MCSPI3_CLKCTRL,
972 * CM_L4PER_MCSPI4_CLKCTRL, CM_L4PER_MGATE_CLKCTRL, CM_L4PER_MMCSD3_CLKCTRL,
973 * CM_L4PER_MMCSD4_CLKCTRL, CM_L4PER_MMCSD5_CLKCTRL, CM_L4PER_MSPROHG_CLKCTRL,
974 * CM_L4PER_SLIMBUS2_CLKCTRL, CM_L4PER_UART1_CLKCTRL, CM_L4PER_UART2_CLKCTRL,
975 * CM_L4PER_UART3_CLKCTRL, CM_L4PER_UART4_CLKCTRL, CM_L4SEC_AES1_CLKCTRL,
976 * CM_L4SEC_AES2_CLKCTRL, CM_L4SEC_CRYPTODMA_CLKCTRL, CM_L4SEC_DES3DES_CLKCTRL,
977 * CM_L4SEC_PKAEIP29_CLKCTRL, CM_L4SEC_RNG_CLKCTRL, CM_L4SEC_SHA2MD51_CLKCTRL,
978 * CM_MEMIF_DMM_CLKCTRL, CM_MEMIF_EMIF_1_CLKCTRL, CM_MEMIF_EMIF_2_CLKCTRL,
979 * CM_MEMIF_EMIF_FW_CLKCTRL, CM_MEMIF_EMIF_H1_CLKCTRL,
980 * CM_MEMIF_EMIF_H2_CLKCTRL, CM_MPU_MPU_CLKCTRL, CM_SDMA_SDMA_CLKCTRL,
981 * CM_TESLA_TESLA_CLKCTRL, CM_WKUP_GPIO1_CLKCTRL, CM_WKUP_KEYBOARD_CLKCTRL,
982 * CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_RTC_CLKCTRL, CM_WKUP_SARRAM_CLKCTRL,
983 * CM_WKUP_SYNCTIMER_CLKCTRL, CM_WKUP_TIMER12_CLKCTRL, CM_WKUP_TIMER1_CLKCTRL,
984 * CM_WKUP_USIM_CLKCTRL, CM_WKUP_WDT1_CLKCTRL, CM_WKUP_WDT2_CLKCTRL
964 */ 985 */
965#define OMAP4430_IDLEST_SHIFT 16 986#define OMAP4430_IDLEST_SHIFT 16
966#define OMAP4430_IDLEST_MASK BITFIELD(16, 17) 987#define OMAP4430_IDLEST_MASK (0x3 << 16)
967 988
968/* Used by CM_DUCATI_DYNAMICDEP, CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP */ 989/*
990 * Used by CM_DUCATI_DYNAMICDEP, CM_L3_2_DYNAMICDEP,
991 * CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE
992 */
969#define OMAP4430_ISS_DYNDEP_SHIFT 9 993#define OMAP4430_ISS_DYNDEP_SHIFT 9
970#define OMAP4430_ISS_DYNDEP_MASK BITFIELD(9, 9) 994#define OMAP4430_ISS_DYNDEP_MASK (1 << 9)
971 995
972/* 996/*
973 * Used by CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, 997 * Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP, CM_SDMA_STATICDEP,
974 * CM_MPU_STATICDEP, CM_TESLA_STATICDEP 998 * CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
975 */ 999 */
976#define OMAP4430_ISS_STATDEP_SHIFT 9 1000#define OMAP4430_ISS_STATDEP_SHIFT 9
977#define OMAP4430_ISS_STATDEP_MASK BITFIELD(9, 9) 1001#define OMAP4430_ISS_STATDEP_MASK (1 << 9)
978 1002
979/* Used by CM_L3_2_DYNAMICDEP, CM_TESLA_DYNAMICDEP */ 1003/* Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_TESLA_DYNAMICDEP */
980#define OMAP4430_IVAHD_DYNDEP_SHIFT 2 1004#define OMAP4430_IVAHD_DYNDEP_SHIFT 2
981#define OMAP4430_IVAHD_DYNDEP_MASK BITFIELD(2, 2) 1005#define OMAP4430_IVAHD_DYNDEP_MASK (1 << 2)
982 1006
983/* 1007/*
984 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1008 * Used by CM_CAM_STATICDEP, CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE,
985 * CM_GFX_STATICDEP, CM_L3INIT_STATICDEP, CM_CAM_STATICDEP, 1009 * CM_DSS_STATICDEP, CM_DUCATI_STATICDEP, CM_GFX_STATICDEP,
986 * CM_SDMA_STATICDEP_RESTORE, CM_DSS_STATICDEP, CM_MPU_STATICDEP, 1010 * CM_L3INIT_STATICDEP, CM_MPU_STATICDEP, CM_SDMA_STATICDEP,
987 * CM_TESLA_STATICDEP 1011 * CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
988 */ 1012 */
989#define OMAP4430_IVAHD_STATDEP_SHIFT 2 1013#define OMAP4430_IVAHD_STATDEP_SHIFT 2
990#define OMAP4430_IVAHD_STATDEP_MASK BITFIELD(2, 2) 1014#define OMAP4430_IVAHD_STATDEP_MASK (1 << 2)
991 1015
992/* Used by CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, CM_L4PER_DYNAMICDEP */ 1016/*
1017 * Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
1018 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_L4PER_DYNAMICDEP, CM_L4PER_DYNAMICDEP_RESTORE
1019 */
993#define OMAP4430_L3INIT_DYNDEP_SHIFT 7 1020#define OMAP4430_L3INIT_DYNDEP_SHIFT 7
994#define OMAP4430_L3INIT_DYNDEP_MASK BITFIELD(7, 7) 1021#define OMAP4430_L3INIT_DYNDEP_MASK (1 << 7)
995 1022
996/* 1023/*
997 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1024 * Used by CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE, CM_DUCATI_STATICDEP,
998 * CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1025 * CM_MPU_STATICDEP, CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE,
1026 * CM_TESLA_STATICDEP
999 */ 1027 */
1000#define OMAP4430_L3INIT_STATDEP_SHIFT 7 1028#define OMAP4430_L3INIT_STATDEP_SHIFT 7
1001#define OMAP4430_L3INIT_STATDEP_MASK BITFIELD(7, 7) 1029#define OMAP4430_L3INIT_STATDEP_MASK (1 << 7)
1002 1030
1003/* 1031/*
1004 * Used by CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, CM_L3INIT_DYNAMICDEP, 1032 * Used by CM_DSS_DYNAMICDEP, CM_L3INIT_DYNAMICDEP, CM_L3_2_DYNAMICDEP,
1005 * CM_DSS_DYNAMICDEP, CM_MPU_DYNAMICDEP, CM_TESLA_DYNAMICDEP 1033 * CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
1034 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_MPU_DYNAMICDEP, CM_TESLA_DYNAMICDEP
1006 */ 1035 */
1007#define OMAP4430_L3_1_DYNDEP_SHIFT 5 1036#define OMAP4430_L3_1_DYNDEP_SHIFT 5
1008#define OMAP4430_L3_1_DYNDEP_MASK BITFIELD(5, 5) 1037#define OMAP4430_L3_1_DYNDEP_MASK (1 << 5)
1009 1038
1010/* 1039/*
1011 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1040 * Used by CM_CAM_STATICDEP, CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE,
1012 * CM_GFX_STATICDEP, CM_L4SEC_STATICDEP, CM_L3INIT_STATICDEP, CM_CAM_STATICDEP, 1041 * CM_DSS_STATICDEP, CM_DUCATI_STATICDEP, CM_GFX_STATICDEP, CM_IVAHD_STATICDEP,
1013 * CM_SDMA_STATICDEP_RESTORE, CM_IVAHD_STATICDEP, CM_DSS_STATICDEP, 1042 * CM_L3INIT_STATICDEP, CM_L4SEC_STATICDEP, CM_MPU_STATICDEP,
1014 * CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1043 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1015 */ 1044 */
1016#define OMAP4430_L3_1_STATDEP_SHIFT 5 1045#define OMAP4430_L3_1_STATDEP_SHIFT 5
1017#define OMAP4430_L3_1_STATDEP_MASK BITFIELD(5, 5) 1046#define OMAP4430_L3_1_STATDEP_MASK (1 << 5)
1018 1047
1019/* 1048/*
1020 * Used by CM_EMU_DYNAMICDEP, CM_D2D_DYNAMICDEP, CM_DUCATI_DYNAMICDEP, 1049 * Used by CM_CAM_DYNAMICDEP, CM_D2D_DYNAMICDEP, CM_D2D_DYNAMICDEP_RESTORE,
1021 * CM_L3_1_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, CM_SDMA_DYNAMICDEP, 1050 * CM_DUCATI_DYNAMICDEP, CM_EMU_DYNAMICDEP, CM_GFX_DYNAMICDEP,
1022 * CM_GFX_DYNAMICDEP, CM_L4SEC_DYNAMICDEP, CM_L3INIT_DYNAMICDEP, 1051 * CM_IVAHD_DYNAMICDEP, CM_L3INIT_DYNAMICDEP, CM_L3_1_DYNAMICDEP,
1023 * CM_CAM_DYNAMICDEP, CM_IVAHD_DYNAMICDEP 1052 * CM_L3_1_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
1053 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_L4SEC_DYNAMICDEP, CM_SDMA_DYNAMICDEP
1024 */ 1054 */
1025#define OMAP4430_L3_2_DYNDEP_SHIFT 6 1055#define OMAP4430_L3_2_DYNDEP_SHIFT 6
1026#define OMAP4430_L3_2_DYNDEP_MASK BITFIELD(6, 6) 1056#define OMAP4430_L3_2_DYNDEP_MASK (1 << 6)
1027 1057
1028/* 1058/*
1029 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1059 * Used by CM_CAM_STATICDEP, CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE,
1030 * CM_GFX_STATICDEP, CM_L4SEC_STATICDEP, CM_L3INIT_STATICDEP, CM_CAM_STATICDEP, 1060 * CM_DSS_STATICDEP, CM_DUCATI_STATICDEP, CM_GFX_STATICDEP, CM_IVAHD_STATICDEP,
1031 * CM_SDMA_STATICDEP_RESTORE, CM_IVAHD_STATICDEP, CM_DSS_STATICDEP, 1061 * CM_L3INIT_STATICDEP, CM_L4SEC_STATICDEP, CM_MPU_STATICDEP,
1032 * CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1062 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1033 */ 1063 */
1034#define OMAP4430_L3_2_STATDEP_SHIFT 6 1064#define OMAP4430_L3_2_STATDEP_SHIFT 6
1035#define OMAP4430_L3_2_STATDEP_MASK BITFIELD(6, 6) 1065#define OMAP4430_L3_2_STATDEP_MASK (1 << 6)
1036 1066
1037/* Used by CM_L3_1_DYNAMICDEP */ 1067/* Used by CM_L3_1_DYNAMICDEP, CM_L3_1_DYNAMICDEP_RESTORE */
1038#define OMAP4430_L4CFG_DYNDEP_SHIFT 12 1068#define OMAP4430_L4CFG_DYNDEP_SHIFT 12
1039#define OMAP4430_L4CFG_DYNDEP_MASK BITFIELD(12, 12) 1069#define OMAP4430_L4CFG_DYNDEP_MASK (1 << 12)
1040 1070
1041/* 1071/*
1042 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1072 * Used by CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE, CM_DUCATI_STATICDEP,
1043 * CM_L3INIT_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP, 1073 * CM_L3INIT_STATICDEP, CM_MPU_STATICDEP, CM_SDMA_STATICDEP,
1044 * CM_TESLA_STATICDEP 1074 * CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1045 */ 1075 */
1046#define OMAP4430_L4CFG_STATDEP_SHIFT 12 1076#define OMAP4430_L4CFG_STATDEP_SHIFT 12
1047#define OMAP4430_L4CFG_STATDEP_MASK BITFIELD(12, 12) 1077#define OMAP4430_L4CFG_STATDEP_MASK (1 << 12)
1048 1078
1049/* Used by CM_L3_2_DYNAMICDEP */ 1079/* Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE */
1050#define OMAP4430_L4PER_DYNDEP_SHIFT 13 1080#define OMAP4430_L4PER_DYNDEP_SHIFT 13
1051#define OMAP4430_L4PER_DYNDEP_MASK BITFIELD(13, 13) 1081#define OMAP4430_L4PER_DYNDEP_MASK (1 << 13)
1052 1082
1053/* 1083/*
1054 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1084 * Used by CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE, CM_DUCATI_STATICDEP,
1055 * CM_L4SEC_STATICDEP, CM_L3INIT_STATICDEP, CM_SDMA_STATICDEP_RESTORE, 1085 * CM_L3INIT_STATICDEP, CM_L4SEC_STATICDEP, CM_MPU_STATICDEP,
1056 * CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1086 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1057 */ 1087 */
1058#define OMAP4430_L4PER_STATDEP_SHIFT 13 1088#define OMAP4430_L4PER_STATDEP_SHIFT 13
1059#define OMAP4430_L4PER_STATDEP_MASK BITFIELD(13, 13) 1089#define OMAP4430_L4PER_STATDEP_MASK (1 << 13)
1060 1090
1061/* Used by CM_L3_2_DYNAMICDEP, CM_L4PER_DYNAMICDEP */ 1091/*
1092 * Used by CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_L4PER_DYNAMICDEP,
1093 * CM_L4PER_DYNAMICDEP_RESTORE
1094 */
1062#define OMAP4430_L4SEC_DYNDEP_SHIFT 14 1095#define OMAP4430_L4SEC_DYNDEP_SHIFT 14
1063#define OMAP4430_L4SEC_DYNDEP_MASK BITFIELD(14, 14) 1096#define OMAP4430_L4SEC_DYNDEP_MASK (1 << 14)
1064 1097
1065/* 1098/*
1066 * Used by CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, CM_L3INIT_STATICDEP, 1099 * Used by CM_DUCATI_STATICDEP, CM_L3INIT_STATICDEP, CM_MPU_STATICDEP,
1067 * CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP 1100 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE
1068 */ 1101 */
1069#define OMAP4430_L4SEC_STATDEP_SHIFT 14 1102#define OMAP4430_L4SEC_STATDEP_SHIFT 14
1070#define OMAP4430_L4SEC_STATDEP_MASK BITFIELD(14, 14) 1103#define OMAP4430_L4SEC_STATDEP_MASK (1 << 14)
1071 1104
1072/* Used by CM_L4CFG_DYNAMICDEP */ 1105/* Used by CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE */
1073#define OMAP4430_L4WKUP_DYNDEP_SHIFT 15 1106#define OMAP4430_L4WKUP_DYNDEP_SHIFT 15
1074#define OMAP4430_L4WKUP_DYNDEP_MASK BITFIELD(15, 15) 1107#define OMAP4430_L4WKUP_DYNDEP_MASK (1 << 15)
1075 1108
1076/* 1109/*
1077 * Used by CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, CM_L3INIT_STATICDEP, 1110 * Used by CM_DUCATI_STATICDEP, CM_L3INIT_STATICDEP, CM_MPU_STATICDEP,
1078 * CM_SDMA_STATICDEP_RESTORE, CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1111 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1079 */ 1112 */
1080#define OMAP4430_L4WKUP_STATDEP_SHIFT 15 1113#define OMAP4430_L4WKUP_STATDEP_SHIFT 15
1081#define OMAP4430_L4WKUP_STATDEP_MASK BITFIELD(15, 15) 1114#define OMAP4430_L4WKUP_STATDEP_MASK (1 << 15)
1082 1115
1083/* 1116/*
1084 * Used by CM_D2D_DYNAMICDEP, CM_L3_1_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, 1117 * Used by CM_D2D_DYNAMICDEP, CM_D2D_DYNAMICDEP_RESTORE, CM_L3_1_DYNAMICDEP,
1085 * CM_MPU_DYNAMICDEP 1118 * CM_L3_1_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
1119 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_MPU_DYNAMICDEP
1086 */ 1120 */
1087#define OMAP4430_MEMIF_DYNDEP_SHIFT 4 1121#define OMAP4430_MEMIF_DYNDEP_SHIFT 4
1088#define OMAP4430_MEMIF_DYNDEP_MASK BITFIELD(4, 4) 1122#define OMAP4430_MEMIF_DYNDEP_MASK (1 << 4)
1089 1123
1090/* 1124/*
1091 * Used by CM_D2D_STATICDEP, CM_DUCATI_STATICDEP, CM_SDMA_STATICDEP, 1125 * Used by CM_CAM_STATICDEP, CM_D2D_STATICDEP, CM_D2D_STATICDEP_RESTORE,
1092 * CM_GFX_STATICDEP, CM_L4SEC_STATICDEP, CM_L3INIT_STATICDEP, CM_CAM_STATICDEP, 1126 * CM_DSS_STATICDEP, CM_DUCATI_STATICDEP, CM_GFX_STATICDEP, CM_IVAHD_STATICDEP,
1093 * CM_SDMA_STATICDEP_RESTORE, CM_IVAHD_STATICDEP, CM_DSS_STATICDEP, 1127 * CM_L3INIT_STATICDEP, CM_L4SEC_STATICDEP, CM_MPU_STATICDEP,
1094 * CM_MPU_STATICDEP, CM_TESLA_STATICDEP 1128 * CM_SDMA_STATICDEP, CM_SDMA_STATICDEP_RESTORE, CM_TESLA_STATICDEP
1095 */ 1129 */
1096#define OMAP4430_MEMIF_STATDEP_SHIFT 4 1130#define OMAP4430_MEMIF_STATDEP_SHIFT 4
1097#define OMAP4430_MEMIF_STATDEP_MASK BITFIELD(4, 4) 1131#define OMAP4430_MEMIF_STATDEP_MASK (1 << 4)
1098 1132
1099/* 1133/*
1100 * Used by CM_SSC_MODFREQDIV_DPLL_PER, CM_SSC_MODFREQDIV_DPLL_UNIPRO, 1134 * Used by CM_SSC_MODFREQDIV_DPLL_ABE, CM_SSC_MODFREQDIV_DPLL_CORE,
1101 * CM_SSC_MODFREQDIV_DPLL_USB, CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE, 1135 * CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE, CM_SSC_MODFREQDIV_DPLL_DDRPHY,
1102 * CM_SSC_MODFREQDIV_DPLL_ABE, CM_SSC_MODFREQDIV_DPLL_CORE, 1136 * CM_SSC_MODFREQDIV_DPLL_IVA, CM_SSC_MODFREQDIV_DPLL_MPU,
1103 * CM_SSC_MODFREQDIV_DPLL_DDRPHY, CM_SSC_MODFREQDIV_DPLL_IVA, 1137 * CM_SSC_MODFREQDIV_DPLL_PER, CM_SSC_MODFREQDIV_DPLL_UNIPRO,
1104 * CM_SSC_MODFREQDIV_DPLL_MPU 1138 * CM_SSC_MODFREQDIV_DPLL_USB
1105 */ 1139 */
1106#define OMAP4430_MODFREQDIV_EXPONENT_SHIFT 8 1140#define OMAP4430_MODFREQDIV_EXPONENT_SHIFT 8
1107#define OMAP4430_MODFREQDIV_EXPONENT_MASK BITFIELD(8, 10) 1141#define OMAP4430_MODFREQDIV_EXPONENT_MASK (0x7 << 8)
1108 1142
1109/* 1143/*
1110 * Used by CM_SSC_MODFREQDIV_DPLL_PER, CM_SSC_MODFREQDIV_DPLL_UNIPRO, 1144 * Used by CM_SSC_MODFREQDIV_DPLL_ABE, CM_SSC_MODFREQDIV_DPLL_CORE,
1111 * CM_SSC_MODFREQDIV_DPLL_USB, CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE, 1145 * CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE, CM_SSC_MODFREQDIV_DPLL_DDRPHY,
1112 * CM_SSC_MODFREQDIV_DPLL_ABE, CM_SSC_MODFREQDIV_DPLL_CORE, 1146 * CM_SSC_MODFREQDIV_DPLL_IVA, CM_SSC_MODFREQDIV_DPLL_MPU,
1113 * CM_SSC_MODFREQDIV_DPLL_DDRPHY, CM_SSC_MODFREQDIV_DPLL_IVA, 1147 * CM_SSC_MODFREQDIV_DPLL_PER, CM_SSC_MODFREQDIV_DPLL_UNIPRO,
1114 * CM_SSC_MODFREQDIV_DPLL_MPU 1148 * CM_SSC_MODFREQDIV_DPLL_USB
1115 */ 1149 */
1116#define OMAP4430_MODFREQDIV_MANTISSA_SHIFT 0 1150#define OMAP4430_MODFREQDIV_MANTISSA_SHIFT 0
1117#define OMAP4430_MODFREQDIV_MANTISSA_MASK BITFIELD(0, 6) 1151#define OMAP4430_MODFREQDIV_MANTISSA_MASK (0x7f << 0)
1118 1152
1119/* 1153/*
1120 * Used by PRM_PRM_PROFILING_CLKCTRL, CM_WKUP_GPIO1_CLKCTRL, 1154 * Used by CM1_ABE_AESS_CLKCTRL, CM1_ABE_DMIC_CLKCTRL, CM1_ABE_L4ABE_CLKCTRL,
1121 * CM_WKUP_KEYBOARD_CLKCTRL, CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_RTC_CLKCTRL, 1155 * CM1_ABE_MCASP_CLKCTRL, CM1_ABE_MCBSP1_CLKCTRL, CM1_ABE_MCBSP2_CLKCTRL,
1122 * CM_WKUP_SARRAM_CLKCTRL, CM_WKUP_SYNCTIMER_CLKCTRL, CM_WKUP_TIMER12_CLKCTRL, 1156 * CM1_ABE_MCBSP3_CLKCTRL, CM1_ABE_PDM_CLKCTRL, CM1_ABE_SLIMBUS_CLKCTRL,
1123 * CM_WKUP_TIMER1_CLKCTRL, CM_WKUP_USIM_CLKCTRL, CM_WKUP_WDT1_CLKCTRL, 1157 * CM1_ABE_TIMER5_CLKCTRL, CM1_ABE_TIMER6_CLKCTRL, CM1_ABE_TIMER7_CLKCTRL,
1124 * CM_WKUP_WDT2_CLKCTRL, CM_EMU_DEBUGSS_CLKCTRL, CM_D2D_MODEM_ICR_CLKCTRL, 1158 * CM1_ABE_TIMER8_CLKCTRL, CM1_ABE_WDT3_CLKCTRL, CM_ALWON_MDMINTC_CLKCTRL,
1125 * CM_D2D_SAD2D_CLKCTRL, CM_D2D_SAD2D_FW_CLKCTRL, CM_DUCATI_DUCATI_CLKCTRL, 1159 * CM_ALWON_SR_CORE_CLKCTRL, CM_ALWON_SR_IVA_CLKCTRL, CM_ALWON_SR_MPU_CLKCTRL,
1126 * CM_L3INSTR_L3_3_CLKCTRL, CM_L3INSTR_L3_INSTR_CLKCTRL, 1160 * CM_CAM_FDIF_CLKCTRL, CM_CAM_ISS_CLKCTRL, CM_CEFUSE_CEFUSE_CLKCTRL,
1127 * CM_L3INSTR_OCP_WP1_CLKCTRL, CM_L3_1_L3_1_CLKCTRL, CM_L3_2_GPMC_CLKCTRL, 1161 * CM_CM1_PROFILING_CLKCTRL, CM_CM1_PROFILING_CLKCTRL_RESTORE,
1128 * CM_L3_2_L3_2_CLKCTRL, CM_L3_2_OCMC_RAM_CLKCTRL, CM_L4CFG_HW_SEM_CLKCTRL, 1162 * CM_CM2_PROFILING_CLKCTRL, CM_CM2_PROFILING_CLKCTRL_RESTORE,
1129 * CM_L4CFG_L4_CFG_CLKCTRL, CM_L4CFG_MAILBOX_CLKCTRL, CM_L4CFG_SAR_ROM_CLKCTRL, 1163 * CM_D2D_MODEM_ICR_CLKCTRL, CM_D2D_SAD2D_CLKCTRL, CM_D2D_SAD2D_FW_CLKCTRL,
1130 * CM_MEMIF_DMM_CLKCTRL, CM_MEMIF_EMIF_1_CLKCTRL, CM_MEMIF_EMIF_2_CLKCTRL, 1164 * CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL, CM_DUCATI_DUCATI_CLKCTRL,
1131 * CM_MEMIF_EMIF_FW_CLKCTRL, CM_MEMIF_EMIF_H1_CLKCTRL, 1165 * CM_EMU_DEBUGSS_CLKCTRL, CM_GFX_GFX_CLKCTRL, CM_IVAHD_IVAHD_CLKCTRL,
1132 * CM_MEMIF_EMIF_H2_CLKCTRL, CM_SDMA_SDMA_CLKCTRL, CM_GFX_GFX_CLKCTRL, 1166 * CM_IVAHD_SL2_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL,
1133 * CM_L4PER_ADC_CLKCTRL, CM_L4PER_DMTIMER10_CLKCTRL,
1134 * CM_L4PER_DMTIMER11_CLKCTRL, CM_L4PER_DMTIMER2_CLKCTRL,
1135 * CM_L4PER_DMTIMER3_CLKCTRL, CM_L4PER_DMTIMER4_CLKCTRL,
1136 * CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_ELM_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL,
1137 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL,
1138 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_HDQ1W_CLKCTRL, CM_L4PER_HECC1_CLKCTRL,
1139 * CM_L4PER_HECC2_CLKCTRL, CM_L4PER_I2C1_CLKCTRL, CM_L4PER_I2C2_CLKCTRL,
1140 * CM_L4PER_I2C3_CLKCTRL, CM_L4PER_I2C4_CLKCTRL, CM_L4PER_I2C5_CLKCTRL,
1141 * CM_L4PER_L4PER_CLKCTRL, CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL,
1142 * CM_L4PER_MCBSP4_CLKCTRL, CM_L4PER_MCSPI1_CLKCTRL, CM_L4PER_MCSPI2_CLKCTRL,
1143 * CM_L4PER_MCSPI3_CLKCTRL, CM_L4PER_MCSPI4_CLKCTRL, CM_L4PER_MGATE_CLKCTRL,
1144 * CM_L4PER_MMCSD3_CLKCTRL, CM_L4PER_MMCSD4_CLKCTRL, CM_L4PER_MMCSD5_CLKCTRL,
1145 * CM_L4PER_MSPROHG_CLKCTRL, CM_L4PER_SLIMBUS2_CLKCTRL, CM_L4PER_UART1_CLKCTRL,
1146 * CM_L4PER_UART2_CLKCTRL, CM_L4PER_UART3_CLKCTRL, CM_L4PER_UART4_CLKCTRL,
1147 * CM_L4SEC_AES1_CLKCTRL, CM_L4SEC_AES2_CLKCTRL, CM_L4SEC_CRYPTODMA_CLKCTRL,
1148 * CM_L4SEC_DES3DES_CLKCTRL, CM_L4SEC_PKAEIP29_CLKCTRL, CM_L4SEC_RNG_CLKCTRL,
1149 * CM_L4SEC_SHA2MD51_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL,
1150 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL, 1167 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL,
1151 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL, 1168 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL,
1152 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL, 1169 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL,
1153 * CM_L3INIT_USBPHYOCP2SCP_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL, 1170 * CM_L3INIT_USBPHYOCP2SCP_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL,
1154 * CM_L3INIT_USB_HOST_FS_CLKCTRL, CM_L3INIT_USB_OTG_CLKCTRL, 1171 * CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, CM_L3INIT_USB_HOST_FS_CLKCTRL,
1155 * CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_XHPI_CLKCTRL, CM_CAM_FDIF_CLKCTRL, 1172 * CM_L3INIT_USB_OTG_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL,
1156 * CM_CAM_ISS_CLKCTRL, CM_CEFUSE_CEFUSE_CLKCTRL, 1173 * CM_L3INIT_USB_TLL_CLKCTRL_RESTORE, CM_L3INIT_XHPI_CLKCTRL,
1157 * CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE, 1174 * CM_L3INSTR_L3_3_CLKCTRL, CM_L3INSTR_L3_3_CLKCTRL_RESTORE,
1158 * CM_L3INSTR_L3_3_CLKCTRL_RESTORE, CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE, 1175 * CM_L3INSTR_L3_INSTR_CLKCTRL, CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE,
1159 * CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE, CM_L4PER_GPIO2_CLKCTRL_RESTORE, 1176 * CM_L3INSTR_OCP_WP1_CLKCTRL, CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE,
1160 * CM_L4PER_GPIO3_CLKCTRL_RESTORE, CM_L4PER_GPIO4_CLKCTRL_RESTORE, 1177 * CM_L3_1_L3_1_CLKCTRL, CM_L3_2_GPMC_CLKCTRL, CM_L3_2_L3_2_CLKCTRL,
1161 * CM_L4PER_GPIO5_CLKCTRL_RESTORE, CM_L4PER_GPIO6_CLKCTRL_RESTORE, 1178 * CM_L3_2_OCMC_RAM_CLKCTRL, CM_L4CFG_HW_SEM_CLKCTRL, CM_L4CFG_L4_CFG_CLKCTRL,
1162 * CM_ALWON_MDMINTC_CLKCTRL, CM_ALWON_SR_CORE_CLKCTRL, CM_ALWON_SR_IVA_CLKCTRL, 1179 * CM_L4CFG_MAILBOX_CLKCTRL, CM_L4CFG_SAR_ROM_CLKCTRL, CM_L4PER_ADC_CLKCTRL,
1163 * CM_ALWON_SR_MPU_CLKCTRL, CM_IVAHD_IVAHD_CLKCTRL, CM_IVAHD_SL2_CLKCTRL, 1180 * CM_L4PER_DMTIMER10_CLKCTRL, CM_L4PER_DMTIMER11_CLKCTRL,
1164 * CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL, CM_CM2_PROFILING_CLKCTRL, 1181 * CM_L4PER_DMTIMER2_CLKCTRL, CM_L4PER_DMTIMER3_CLKCTRL,
1165 * CM_MPU_MPU_CLKCTRL, CM_TESLA_TESLA_CLKCTRL, CM1_ABE_AESS_CLKCTRL, 1182 * CM_L4PER_DMTIMER4_CLKCTRL, CM_L4PER_DMTIMER9_CLKCTRL, CM_L4PER_ELM_CLKCTRL,
1166 * CM1_ABE_DMIC_CLKCTRL, CM1_ABE_L4ABE_CLKCTRL, CM1_ABE_MCASP_CLKCTRL, 1183 * CM_L4PER_GPIO2_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL_RESTORE,
1167 * CM1_ABE_MCBSP1_CLKCTRL, CM1_ABE_MCBSP2_CLKCTRL, CM1_ABE_MCBSP3_CLKCTRL, 1184 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO3_CLKCTRL_RESTORE,
1168 * CM1_ABE_PDM_CLKCTRL, CM1_ABE_SLIMBUS_CLKCTRL, CM1_ABE_TIMER5_CLKCTRL, 1185 * CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL_RESTORE,
1169 * CM1_ABE_TIMER6_CLKCTRL, CM1_ABE_TIMER7_CLKCTRL, CM1_ABE_TIMER8_CLKCTRL, 1186 * CM_L4PER_GPIO5_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL_RESTORE,
1170 * CM1_ABE_WDT3_CLKCTRL, CM_CM1_PROFILING_CLKCTRL 1187 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_GPIO6_CLKCTRL_RESTORE,
1188 * CM_L4PER_HDQ1W_CLKCTRL, CM_L4PER_HECC1_CLKCTRL, CM_L4PER_HECC2_CLKCTRL,
1189 * CM_L4PER_I2C1_CLKCTRL, CM_L4PER_I2C2_CLKCTRL, CM_L4PER_I2C3_CLKCTRL,
1190 * CM_L4PER_I2C4_CLKCTRL, CM_L4PER_I2C5_CLKCTRL, CM_L4PER_L4PER_CLKCTRL,
1191 * CM_L4PER_MCASP2_CLKCTRL, CM_L4PER_MCASP3_CLKCTRL, CM_L4PER_MCBSP4_CLKCTRL,
1192 * CM_L4PER_MCSPI1_CLKCTRL, CM_L4PER_MCSPI2_CLKCTRL, CM_L4PER_MCSPI3_CLKCTRL,
1193 * CM_L4PER_MCSPI4_CLKCTRL, CM_L4PER_MGATE_CLKCTRL, CM_L4PER_MMCSD3_CLKCTRL,
1194 * CM_L4PER_MMCSD4_CLKCTRL, CM_L4PER_MMCSD5_CLKCTRL, CM_L4PER_MSPROHG_CLKCTRL,
1195 * CM_L4PER_SLIMBUS2_CLKCTRL, CM_L4PER_UART1_CLKCTRL, CM_L4PER_UART2_CLKCTRL,
1196 * CM_L4PER_UART3_CLKCTRL, CM_L4PER_UART4_CLKCTRL, CM_L4SEC_AES1_CLKCTRL,
1197 * CM_L4SEC_AES2_CLKCTRL, CM_L4SEC_CRYPTODMA_CLKCTRL, CM_L4SEC_DES3DES_CLKCTRL,
1198 * CM_L4SEC_PKAEIP29_CLKCTRL, CM_L4SEC_RNG_CLKCTRL, CM_L4SEC_SHA2MD51_CLKCTRL,
1199 * CM_MEMIF_DMM_CLKCTRL, CM_MEMIF_EMIF_1_CLKCTRL, CM_MEMIF_EMIF_2_CLKCTRL,
1200 * CM_MEMIF_EMIF_FW_CLKCTRL, CM_MEMIF_EMIF_H1_CLKCTRL,
1201 * CM_MEMIF_EMIF_H2_CLKCTRL, CM_MPU_MPU_CLKCTRL, CM_SDMA_SDMA_CLKCTRL,
1202 * CM_TESLA_TESLA_CLKCTRL, CM_WKUP_GPIO1_CLKCTRL, CM_WKUP_KEYBOARD_CLKCTRL,
1203 * CM_WKUP_L4WKUP_CLKCTRL, CM_WKUP_RTC_CLKCTRL, CM_WKUP_SARRAM_CLKCTRL,
1204 * CM_WKUP_SYNCTIMER_CLKCTRL, CM_WKUP_TIMER12_CLKCTRL, CM_WKUP_TIMER1_CLKCTRL,
1205 * CM_WKUP_USIM_CLKCTRL, CM_WKUP_WDT1_CLKCTRL, CM_WKUP_WDT2_CLKCTRL
1171 */ 1206 */
1172#define OMAP4430_MODULEMODE_SHIFT 0 1207#define OMAP4430_MODULEMODE_SHIFT 0
1173#define OMAP4430_MODULEMODE_MASK BITFIELD(0, 1) 1208#define OMAP4430_MODULEMODE_MASK (0x3 << 0)
1174 1209
1175/* Used by CM_DSS_DSS_CLKCTRL */ 1210/* Used by CM_DSS_DSS_CLKCTRL */
1176#define OMAP4430_OPTFCLKEN_48MHZ_CLK_SHIFT 9 1211#define OMAP4430_OPTFCLKEN_48MHZ_CLK_SHIFT 9
1177#define OMAP4430_OPTFCLKEN_48MHZ_CLK_MASK BITFIELD(9, 9) 1212#define OMAP4430_OPTFCLKEN_48MHZ_CLK_MASK (1 << 9)
1178 1213
1179/* Used by CM_WKUP_BANDGAP_CLKCTRL */ 1214/* Used by CM_WKUP_BANDGAP_CLKCTRL */
1180#define OMAP4430_OPTFCLKEN_BGAP_32K_SHIFT 8 1215#define OMAP4430_OPTFCLKEN_BGAP_32K_SHIFT 8
1181#define OMAP4430_OPTFCLKEN_BGAP_32K_MASK BITFIELD(8, 8) 1216#define OMAP4430_OPTFCLKEN_BGAP_32K_MASK (1 << 8)
1182 1217
1183/* Used by CM_L3INIT_USBPHYOCP2SCP_CLKCTRL */ 1218/* Used by CM_ALWON_USBPHY_CLKCTRL */
1184#define OMAP4430_OPTFCLKEN_CLK32K_SHIFT 9 1219#define OMAP4430_OPTFCLKEN_CLK32K_SHIFT 8
1185#define OMAP4430_OPTFCLKEN_CLK32K_MASK BITFIELD(9, 9) 1220#define OMAP4430_OPTFCLKEN_CLK32K_MASK (1 << 8)
1186 1221
1187/* Used by CM_CAM_ISS_CLKCTRL */ 1222/* Used by CM_CAM_ISS_CLKCTRL */
1188#define OMAP4430_OPTFCLKEN_CTRLCLK_SHIFT 8 1223#define OMAP4430_OPTFCLKEN_CTRLCLK_SHIFT 8
1189#define OMAP4430_OPTFCLKEN_CTRLCLK_MASK BITFIELD(8, 8) 1224#define OMAP4430_OPTFCLKEN_CTRLCLK_MASK (1 << 8)
1190 1225
1191/* 1226/*
1192 * Used by CM_WKUP_GPIO1_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL, 1227 * Used by CM_L4PER_GPIO2_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL_RESTORE,
1193 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL, 1228 * CM_L4PER_GPIO3_CLKCTRL, CM_L4PER_GPIO3_CLKCTRL_RESTORE,
1194 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_GPIO2_CLKCTRL_RESTORE, 1229 * CM_L4PER_GPIO4_CLKCTRL, CM_L4PER_GPIO4_CLKCTRL_RESTORE,
1195 * CM_L4PER_GPIO3_CLKCTRL_RESTORE, CM_L4PER_GPIO4_CLKCTRL_RESTORE, 1230 * CM_L4PER_GPIO5_CLKCTRL, CM_L4PER_GPIO5_CLKCTRL_RESTORE,
1196 * CM_L4PER_GPIO5_CLKCTRL_RESTORE, CM_L4PER_GPIO6_CLKCTRL_RESTORE 1231 * CM_L4PER_GPIO6_CLKCTRL, CM_L4PER_GPIO6_CLKCTRL_RESTORE, CM_WKUP_GPIO1_CLKCTRL
1197 */ 1232 */
1198#define OMAP4430_OPTFCLKEN_DBCLK_SHIFT 8 1233#define OMAP4430_OPTFCLKEN_DBCLK_SHIFT 8
1199#define OMAP4430_OPTFCLKEN_DBCLK_MASK BITFIELD(8, 8) 1234#define OMAP4430_OPTFCLKEN_DBCLK_MASK (1 << 8)
1200 1235
1201/* Used by CM_MEMIF_DLL_CLKCTRL, CM_MEMIF_DLL_H_CLKCTRL */ 1236/* Used by CM_MEMIF_DLL_CLKCTRL, CM_MEMIF_DLL_H_CLKCTRL */
1202#define OMAP4430_OPTFCLKEN_DLL_CLK_SHIFT 8 1237#define OMAP4430_OPTFCLKEN_DLL_CLK_SHIFT 8
1203#define OMAP4430_OPTFCLKEN_DLL_CLK_MASK BITFIELD(8, 8) 1238#define OMAP4430_OPTFCLKEN_DLL_CLK_MASK (1 << 8)
1204 1239
1205/* Used by CM_DSS_DSS_CLKCTRL */ 1240/* Used by CM_DSS_DSS_CLKCTRL */
1206#define OMAP4430_OPTFCLKEN_DSSCLK_SHIFT 8 1241#define OMAP4430_OPTFCLKEN_DSSCLK_SHIFT 8
1207#define OMAP4430_OPTFCLKEN_DSSCLK_MASK BITFIELD(8, 8) 1242#define OMAP4430_OPTFCLKEN_DSSCLK_MASK (1 << 8)
1243
1244/* Used by CM_WKUP_USIM_CLKCTRL */
1245#define OMAP4430_OPTFCLKEN_FCLK_SHIFT 8
1246#define OMAP4430_OPTFCLKEN_FCLK_MASK (1 << 8)
1208 1247
1209/* Used by CM1_ABE_SLIMBUS_CLKCTRL */ 1248/* Used by CM1_ABE_SLIMBUS_CLKCTRL */
1210#define OMAP4430_OPTFCLKEN_FCLK0_SHIFT 8 1249#define OMAP4430_OPTFCLKEN_FCLK0_SHIFT 8
1211#define OMAP4430_OPTFCLKEN_FCLK0_MASK BITFIELD(8, 8) 1250#define OMAP4430_OPTFCLKEN_FCLK0_MASK (1 << 8)
1212 1251
1213/* Used by CM1_ABE_SLIMBUS_CLKCTRL */ 1252/* Used by CM1_ABE_SLIMBUS_CLKCTRL */
1214#define OMAP4430_OPTFCLKEN_FCLK1_SHIFT 9 1253#define OMAP4430_OPTFCLKEN_FCLK1_SHIFT 9
1215#define OMAP4430_OPTFCLKEN_FCLK1_MASK BITFIELD(9, 9) 1254#define OMAP4430_OPTFCLKEN_FCLK1_MASK (1 << 9)
1216 1255
1217/* Used by CM1_ABE_SLIMBUS_CLKCTRL */ 1256/* Used by CM1_ABE_SLIMBUS_CLKCTRL */
1218#define OMAP4430_OPTFCLKEN_FCLK2_SHIFT 10 1257#define OMAP4430_OPTFCLKEN_FCLK2_SHIFT 10
1219#define OMAP4430_OPTFCLKEN_FCLK2_MASK BITFIELD(10, 10) 1258#define OMAP4430_OPTFCLKEN_FCLK2_MASK (1 << 10)
1220 1259
1221/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1260/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1222#define OMAP4430_OPTFCLKEN_FUNC48MCLK_SHIFT 15 1261#define OMAP4430_OPTFCLKEN_FUNC48MCLK_SHIFT 15
1223#define OMAP4430_OPTFCLKEN_FUNC48MCLK_MASK BITFIELD(15, 15) 1262#define OMAP4430_OPTFCLKEN_FUNC48MCLK_MASK (1 << 15)
1224 1263
1225/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1264/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1226#define OMAP4430_OPTFCLKEN_HSIC480M_P1_CLK_SHIFT 13 1265#define OMAP4430_OPTFCLKEN_HSIC480M_P1_CLK_SHIFT 13
1227#define OMAP4430_OPTFCLKEN_HSIC480M_P1_CLK_MASK BITFIELD(13, 13) 1266#define OMAP4430_OPTFCLKEN_HSIC480M_P1_CLK_MASK (1 << 13)
1228 1267
1229/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1268/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1230#define OMAP4430_OPTFCLKEN_HSIC480M_P2_CLK_SHIFT 14 1269#define OMAP4430_OPTFCLKEN_HSIC480M_P2_CLK_SHIFT 14
1231#define OMAP4430_OPTFCLKEN_HSIC480M_P2_CLK_MASK BITFIELD(14, 14) 1270#define OMAP4430_OPTFCLKEN_HSIC480M_P2_CLK_MASK (1 << 14)
1232 1271
1233/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1272/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1234#define OMAP4430_OPTFCLKEN_HSIC60M_P1_CLK_SHIFT 11 1273#define OMAP4430_OPTFCLKEN_HSIC60M_P1_CLK_SHIFT 11
1235#define OMAP4430_OPTFCLKEN_HSIC60M_P1_CLK_MASK BITFIELD(11, 11) 1274#define OMAP4430_OPTFCLKEN_HSIC60M_P1_CLK_MASK (1 << 11)
1236 1275
1237/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1276/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1238#define OMAP4430_OPTFCLKEN_HSIC60M_P2_CLK_SHIFT 12 1277#define OMAP4430_OPTFCLKEN_HSIC60M_P2_CLK_SHIFT 12
1239#define OMAP4430_OPTFCLKEN_HSIC60M_P2_CLK_MASK BITFIELD(12, 12) 1278#define OMAP4430_OPTFCLKEN_HSIC60M_P2_CLK_MASK (1 << 12)
1240 1279
1241/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */ 1280/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */
1242#define OMAP4430_OPTFCLKEN_PER24MC_GFCLK_SHIFT 8 1281#define OMAP4430_OPTFCLKEN_PER24MC_GFCLK_SHIFT 8
1243#define OMAP4430_OPTFCLKEN_PER24MC_GFCLK_MASK BITFIELD(8, 8) 1282#define OMAP4430_OPTFCLKEN_PER24MC_GFCLK_MASK (1 << 8)
1244 1283
1245/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */ 1284/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */
1246#define OMAP4430_OPTFCLKEN_PERABE24M_GFCLK_SHIFT 9 1285#define OMAP4430_OPTFCLKEN_PERABE24M_GFCLK_SHIFT 9
1247#define OMAP4430_OPTFCLKEN_PERABE24M_GFCLK_MASK BITFIELD(9, 9) 1286#define OMAP4430_OPTFCLKEN_PERABE24M_GFCLK_MASK (1 << 9)
1248 1287
1249/* Used by CM_L3INIT_USBPHYOCP2SCP_CLKCTRL */ 1288/* Used by CM_L3INIT_USBPHYOCP2SCP_CLKCTRL */
1250#define OMAP4430_OPTFCLKEN_PHY_48M_SHIFT 8 1289#define OMAP4430_OPTFCLKEN_PHY_48M_SHIFT 8
1251#define OMAP4430_OPTFCLKEN_PHY_48M_MASK BITFIELD(8, 8) 1290#define OMAP4430_OPTFCLKEN_PHY_48M_MASK (1 << 8)
1252 1291
1253/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */ 1292/* Used by CM_L4PER_SLIMBUS2_CLKCTRL */
1254#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_SHIFT 10 1293#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_SHIFT 10
1255#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_MASK BITFIELD(10, 10) 1294#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_MASK (1 << 10)
1256 1295
1257/* Renamed from OPTFCLKEN_SLIMBUS_CLK Used by CM1_ABE_SLIMBUS_CLKCTRL */ 1296/* Renamed from OPTFCLKEN_SLIMBUS_CLK Used by CM1_ABE_SLIMBUS_CLKCTRL */
1258#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_11_11_SHIFT 11 1297#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_11_11_SHIFT 11
1259#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_11_11_MASK BITFIELD(11, 11) 1298#define OMAP4430_OPTFCLKEN_SLIMBUS_CLK_11_11_MASK (1 << 11)
1260 1299
1261/* Used by CM_DSS_DSS_CLKCTRL */ 1300/* Used by CM_DSS_DSS_CLKCTRL */
1262#define OMAP4430_OPTFCLKEN_SYS_CLK_SHIFT 10 1301#define OMAP4430_OPTFCLKEN_SYS_CLK_SHIFT 10
1263#define OMAP4430_OPTFCLKEN_SYS_CLK_MASK BITFIELD(10, 10) 1302#define OMAP4430_OPTFCLKEN_SYS_CLK_MASK (1 << 10)
1264 1303
1265/* Used by CM_DSS_DSS_CLKCTRL */ 1304/* Used by CM_DSS_DSS_CLKCTRL */
1266#define OMAP4430_OPTFCLKEN_TV_CLK_SHIFT 11 1305#define OMAP4430_OPTFCLKEN_TV_CLK_SHIFT 11
1267#define OMAP4430_OPTFCLKEN_TV_CLK_MASK BITFIELD(11, 11) 1306#define OMAP4430_OPTFCLKEN_TV_CLK_MASK (1 << 11)
1268 1307
1269/* Used by CM_L3INIT_UNIPRO1_CLKCTRL */ 1308/* Used by CM_L3INIT_UNIPRO1_CLKCTRL */
1270#define OMAP4430_OPTFCLKEN_TXPHYCLK_SHIFT 8 1309#define OMAP4430_OPTFCLKEN_TXPHYCLK_SHIFT 8
1271#define OMAP4430_OPTFCLKEN_TXPHYCLK_MASK BITFIELD(8, 8) 1310#define OMAP4430_OPTFCLKEN_TXPHYCLK_MASK (1 << 8)
1272 1311
1273/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */ 1312/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */
1274#define OMAP4430_OPTFCLKEN_USB_CH0_CLK_SHIFT 8 1313#define OMAP4430_OPTFCLKEN_USB_CH0_CLK_SHIFT 8
1275#define OMAP4430_OPTFCLKEN_USB_CH0_CLK_MASK BITFIELD(8, 8) 1314#define OMAP4430_OPTFCLKEN_USB_CH0_CLK_MASK (1 << 8)
1276 1315
1277/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */ 1316/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */
1278#define OMAP4430_OPTFCLKEN_USB_CH1_CLK_SHIFT 9 1317#define OMAP4430_OPTFCLKEN_USB_CH1_CLK_SHIFT 9
1279#define OMAP4430_OPTFCLKEN_USB_CH1_CLK_MASK BITFIELD(9, 9) 1318#define OMAP4430_OPTFCLKEN_USB_CH1_CLK_MASK (1 << 9)
1280 1319
1281/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */ 1320/* Used by CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE */
1282#define OMAP4430_OPTFCLKEN_USB_CH2_CLK_SHIFT 10 1321#define OMAP4430_OPTFCLKEN_USB_CH2_CLK_SHIFT 10
1283#define OMAP4430_OPTFCLKEN_USB_CH2_CLK_MASK BITFIELD(10, 10) 1322#define OMAP4430_OPTFCLKEN_USB_CH2_CLK_MASK (1 << 10)
1284 1323
1285/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1324/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1286#define OMAP4430_OPTFCLKEN_UTMI_P1_CLK_SHIFT 8 1325#define OMAP4430_OPTFCLKEN_UTMI_P1_CLK_SHIFT 8
1287#define OMAP4430_OPTFCLKEN_UTMI_P1_CLK_MASK BITFIELD(8, 8) 1326#define OMAP4430_OPTFCLKEN_UTMI_P1_CLK_MASK (1 << 8)
1288 1327
1289/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1328/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1290#define OMAP4430_OPTFCLKEN_UTMI_P2_CLK_SHIFT 9 1329#define OMAP4430_OPTFCLKEN_UTMI_P2_CLK_SHIFT 9
1291#define OMAP4430_OPTFCLKEN_UTMI_P2_CLK_MASK BITFIELD(9, 9) 1330#define OMAP4430_OPTFCLKEN_UTMI_P2_CLK_MASK (1 << 9)
1292 1331
1293/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */ 1332/* Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE */
1294#define OMAP4430_OPTFCLKEN_UTMI_P3_CLK_SHIFT 10 1333#define OMAP4430_OPTFCLKEN_UTMI_P3_CLK_SHIFT 10
1295#define OMAP4430_OPTFCLKEN_UTMI_P3_CLK_MASK BITFIELD(10, 10) 1334#define OMAP4430_OPTFCLKEN_UTMI_P3_CLK_MASK (1 << 10)
1296 1335
1297/* Used by CM_L3INIT_USB_OTG_CLKCTRL */ 1336/* Used by CM_L3INIT_USB_OTG_CLKCTRL */
1298#define OMAP4430_OPTFCLKEN_XCLK_SHIFT 8 1337#define OMAP4430_OPTFCLKEN_XCLK_SHIFT 8
1299#define OMAP4430_OPTFCLKEN_XCLK_MASK BITFIELD(8, 8) 1338#define OMAP4430_OPTFCLKEN_XCLK_MASK (1 << 8)
1300 1339
1301/* Used by CM_EMU_OVERRIDE_DPLL_PER, CM_EMU_OVERRIDE_DPLL_CORE */ 1340/* Used by CM_EMU_OVERRIDE_DPLL_CORE */
1302#define OMAP4430_OVERRIDE_ENABLE_SHIFT 19 1341#define OMAP4430_OVERRIDE_ENABLE_SHIFT 19
1303#define OMAP4430_OVERRIDE_ENABLE_MASK BITFIELD(19, 19) 1342#define OMAP4430_OVERRIDE_ENABLE_MASK (1 << 19)
1304 1343
1305/* Used by CM_CLKSEL_ABE */ 1344/* Used by CM_CLKSEL_ABE */
1306#define OMAP4430_PAD_CLKS_GATE_SHIFT 8 1345#define OMAP4430_PAD_CLKS_GATE_SHIFT 8
1307#define OMAP4430_PAD_CLKS_GATE_MASK BITFIELD(8, 8) 1346#define OMAP4430_PAD_CLKS_GATE_MASK (1 << 8)
1308 1347
1309/* Used by CM_CORE_DVFS_CURRENT, CM_IVA_DVFS_CURRENT */ 1348/* Used by CM_CORE_DVFS_CURRENT, CM_IVA_DVFS_CURRENT */
1310#define OMAP4430_PERF_CURRENT_SHIFT 0 1349#define OMAP4430_PERF_CURRENT_SHIFT 0
1311#define OMAP4430_PERF_CURRENT_MASK BITFIELD(0, 7) 1350#define OMAP4430_PERF_CURRENT_MASK (0xff << 0)
1312 1351
1313/* 1352/*
1314 * Used by CM_CORE_DVFS_PERF1, CM_CORE_DVFS_PERF2, CM_CORE_DVFS_PERF3, 1353 * Used by CM_CORE_DVFS_PERF1, CM_CORE_DVFS_PERF2, CM_CORE_DVFS_PERF3,
@@ -1316,159 +1355,173 @@
1316 * CM_IVA_DVFS_PERF_TESLA 1355 * CM_IVA_DVFS_PERF_TESLA
1317 */ 1356 */
1318#define OMAP4430_PERF_REQ_SHIFT 0 1357#define OMAP4430_PERF_REQ_SHIFT 0
1319#define OMAP4430_PERF_REQ_MASK BITFIELD(0, 7) 1358#define OMAP4430_PERF_REQ_MASK (0xff << 0)
1320
1321/* Used by CM_EMU_OVERRIDE_DPLL_PER */
1322#define OMAP4430_PER_DPLL_EMU_DIV_SHIFT 0
1323#define OMAP4430_PER_DPLL_EMU_DIV_MASK BITFIELD(0, 6)
1324
1325/* Used by CM_EMU_OVERRIDE_DPLL_PER */
1326#define OMAP4430_PER_DPLL_EMU_MULT_SHIFT 8
1327#define OMAP4430_PER_DPLL_EMU_MULT_MASK BITFIELD(8, 18)
1328 1359
1329/* Used by CM_RESTORE_ST */ 1360/* Used by CM_RESTORE_ST */
1330#define OMAP4430_PHASE1_COMPLETED_SHIFT 0 1361#define OMAP4430_PHASE1_COMPLETED_SHIFT 0
1331#define OMAP4430_PHASE1_COMPLETED_MASK BITFIELD(0, 0) 1362#define OMAP4430_PHASE1_COMPLETED_MASK (1 << 0)
1332 1363
1333/* Used by CM_RESTORE_ST */ 1364/* Used by CM_RESTORE_ST */
1334#define OMAP4430_PHASE2A_COMPLETED_SHIFT 1 1365#define OMAP4430_PHASE2A_COMPLETED_SHIFT 1
1335#define OMAP4430_PHASE2A_COMPLETED_MASK BITFIELD(1, 1) 1366#define OMAP4430_PHASE2A_COMPLETED_MASK (1 << 1)
1336 1367
1337/* Used by CM_RESTORE_ST */ 1368/* Used by CM_RESTORE_ST */
1338#define OMAP4430_PHASE2B_COMPLETED_SHIFT 2 1369#define OMAP4430_PHASE2B_COMPLETED_SHIFT 2
1339#define OMAP4430_PHASE2B_COMPLETED_MASK BITFIELD(2, 2) 1370#define OMAP4430_PHASE2B_COMPLETED_MASK (1 << 2)
1340 1371
1341/* Used by CM_EMU_DEBUGSS_CLKCTRL */ 1372/* Used by CM_EMU_DEBUGSS_CLKCTRL */
1342#define OMAP4430_PMD_STM_MUX_CTRL_SHIFT 20 1373#define OMAP4430_PMD_STM_MUX_CTRL_SHIFT 20
1343#define OMAP4430_PMD_STM_MUX_CTRL_MASK BITFIELD(20, 21) 1374#define OMAP4430_PMD_STM_MUX_CTRL_MASK (0x3 << 20)
1344 1375
1345/* Used by CM_EMU_DEBUGSS_CLKCTRL */ 1376/* Used by CM_EMU_DEBUGSS_CLKCTRL */
1346#define OMAP4430_PMD_TRACE_MUX_CTRL_SHIFT 22 1377#define OMAP4430_PMD_TRACE_MUX_CTRL_SHIFT 22
1347#define OMAP4430_PMD_TRACE_MUX_CTRL_MASK BITFIELD(22, 23) 1378#define OMAP4430_PMD_TRACE_MUX_CTRL_MASK (0x3 << 22)
1348 1379
1349/* Used by CM_DYN_DEP_PRESCAL */ 1380/* Used by CM_DYN_DEP_PRESCAL, CM_DYN_DEP_PRESCAL_RESTORE */
1350#define OMAP4430_PRESCAL_SHIFT 0 1381#define OMAP4430_PRESCAL_SHIFT 0
1351#define OMAP4430_PRESCAL_MASK BITFIELD(0, 5) 1382#define OMAP4430_PRESCAL_MASK (0x3f << 0)
1352 1383
1353/* Used by REVISION_CM2, REVISION_CM1 */ 1384/* Used by REVISION_CM1, REVISION_CM2 */
1354#define OMAP4430_REV_SHIFT 0 1385#define OMAP4430_R_RTL_SHIFT 11
1355#define OMAP4430_REV_MASK BITFIELD(0, 7) 1386#define OMAP4430_R_RTL_MASK (0x1f << 11)
1356 1387
1357/* 1388/*
1358 * Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL, 1389 * Used by CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE,
1359 * CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE 1390 * CM_L3INIT_USB_TLL_CLKCTRL, CM_L3INIT_USB_TLL_CLKCTRL_RESTORE
1360 */ 1391 */
1361#define OMAP4430_SAR_MODE_SHIFT 4 1392#define OMAP4430_SAR_MODE_SHIFT 4
1362#define OMAP4430_SAR_MODE_MASK BITFIELD(4, 4) 1393#define OMAP4430_SAR_MODE_MASK (1 << 4)
1363 1394
1364/* Used by CM_SCALE_FCLK */ 1395/* Used by CM_SCALE_FCLK */
1365#define OMAP4430_SCALE_FCLK_SHIFT 0 1396#define OMAP4430_SCALE_FCLK_SHIFT 0
1366#define OMAP4430_SCALE_FCLK_MASK BITFIELD(0, 0) 1397#define OMAP4430_SCALE_FCLK_MASK (1 << 0)
1398
1399/* Used by REVISION_CM1, REVISION_CM2 */
1400#define OMAP4430_SCHEME_SHIFT 30
1401#define OMAP4430_SCHEME_MASK (0x3 << 30)
1367 1402
1368/* Used by CM_L4CFG_DYNAMICDEP */ 1403/* Used by CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE */
1369#define OMAP4430_SDMA_DYNDEP_SHIFT 11 1404#define OMAP4430_SDMA_DYNDEP_SHIFT 11
1370#define OMAP4430_SDMA_DYNDEP_MASK BITFIELD(11, 11) 1405#define OMAP4430_SDMA_DYNDEP_MASK (1 << 11)
1371 1406
1372/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */ 1407/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */
1373#define OMAP4430_SDMA_STATDEP_SHIFT 11 1408#define OMAP4430_SDMA_STATDEP_SHIFT 11
1374#define OMAP4430_SDMA_STATDEP_MASK BITFIELD(11, 11) 1409#define OMAP4430_SDMA_STATDEP_MASK (1 << 11)
1375 1410
1376/* Used by CM_CLKSEL_ABE */ 1411/* Used by CM_CLKSEL_ABE */
1377#define OMAP4430_SLIMBUS_CLK_GATE_SHIFT 10 1412#define OMAP4430_SLIMBUS_CLK_GATE_SHIFT 10
1378#define OMAP4430_SLIMBUS_CLK_GATE_MASK BITFIELD(10, 10) 1413#define OMAP4430_SLIMBUS_CLK_GATE_MASK (1 << 10)
1379 1414
1380/* 1415/*
1381 * Used by CM_EMU_DEBUGSS_CLKCTRL, CM_D2D_SAD2D_CLKCTRL, 1416 * Used by CM1_ABE_AESS_CLKCTRL, CM_CAM_FDIF_CLKCTRL, CM_CAM_ISS_CLKCTRL,
1382 * CM_DUCATI_DUCATI_CLKCTRL, CM_SDMA_SDMA_CLKCTRL, CM_GFX_GFX_CLKCTRL, 1417 * CM_D2D_SAD2D_CLKCTRL, CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL,
1383 * CM_L4SEC_CRYPTODMA_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL, 1418 * CM_DUCATI_DUCATI_CLKCTRL, CM_EMU_DEBUGSS_CLKCTRL, CM_GFX_GFX_CLKCTRL,
1419 * CM_IVAHD_IVAHD_CLKCTRL, CM_L3INIT_CCPTX_CLKCTRL, CM_L3INIT_EMAC_CLKCTRL,
1384 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL, 1420 * CM_L3INIT_HSI_CLKCTRL, CM_L3INIT_MMC1_CLKCTRL, CM_L3INIT_MMC2_CLKCTRL,
1385 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL, 1421 * CM_L3INIT_MMC6_CLKCTRL, CM_L3INIT_P1500_CLKCTRL, CM_L3INIT_PCIESS_CLKCTRL,
1386 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL, 1422 * CM_L3INIT_SATA_CLKCTRL, CM_L3INIT_TPPSS_CLKCTRL, CM_L3INIT_UNIPRO1_CLKCTRL,
1387 * CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_FS_CLKCTRL, 1423 * CM_L3INIT_USB_HOST_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE,
1388 * CM_L3INIT_USB_OTG_CLKCTRL, CM_L3INIT_XHPI_CLKCTRL, CM_CAM_FDIF_CLKCTRL, 1424 * CM_L3INIT_USB_HOST_FS_CLKCTRL, CM_L3INIT_USB_OTG_CLKCTRL,
1389 * CM_CAM_ISS_CLKCTRL, CM_L3INIT_USB_HOST_CLKCTRL_RESTORE, 1425 * CM_L3INIT_XHPI_CLKCTRL, CM_L4SEC_CRYPTODMA_CLKCTRL, CM_MPU_MPU_CLKCTRL,
1390 * CM_IVAHD_IVAHD_CLKCTRL, CM_DSS_DEISS_CLKCTRL, CM_DSS_DSS_CLKCTRL, 1426 * CM_SDMA_SDMA_CLKCTRL, CM_TESLA_TESLA_CLKCTRL
1391 * CM_MPU_MPU_CLKCTRL, CM_TESLA_TESLA_CLKCTRL, CM1_ABE_AESS_CLKCTRL
1392 */ 1427 */
1393#define OMAP4430_STBYST_SHIFT 18 1428#define OMAP4430_STBYST_SHIFT 18
1394#define OMAP4430_STBYST_MASK BITFIELD(18, 18) 1429#define OMAP4430_STBYST_MASK (1 << 18)
1395 1430
1396/* 1431/*
1397 * Used by CM_IDLEST_DPLL_PER, CM_IDLEST_DPLL_UNIPRO, CM_IDLEST_DPLL_USB, 1432 * Used by CM_IDLEST_DPLL_ABE, CM_IDLEST_DPLL_CORE, CM_IDLEST_DPLL_DDRPHY,
1398 * CM_IDLEST_DPLL_ABE, CM_IDLEST_DPLL_CORE, CM_IDLEST_DPLL_DDRPHY, 1433 * CM_IDLEST_DPLL_IVA, CM_IDLEST_DPLL_MPU, CM_IDLEST_DPLL_PER,
1399 * CM_IDLEST_DPLL_IVA, CM_IDLEST_DPLL_MPU 1434 * CM_IDLEST_DPLL_UNIPRO, CM_IDLEST_DPLL_USB
1400 */ 1435 */
1401#define OMAP4430_ST_DPLL_CLK_SHIFT 0 1436#define OMAP4430_ST_DPLL_CLK_SHIFT 0
1402#define OMAP4430_ST_DPLL_CLK_MASK BITFIELD(0, 0) 1437#define OMAP4430_ST_DPLL_CLK_MASK (1 << 0)
1403 1438
1404/* Used by CM_CLKDCOLDO_DPLL_USB */ 1439/* Used by CM_CLKDCOLDO_DPLL_USB */
1405#define OMAP4430_ST_DPLL_CLKDCOLDO_SHIFT 9 1440#define OMAP4430_ST_DPLL_CLKDCOLDO_SHIFT 9
1406#define OMAP4430_ST_DPLL_CLKDCOLDO_MASK BITFIELD(9, 9) 1441#define OMAP4430_ST_DPLL_CLKDCOLDO_MASK (1 << 9)
1407 1442
1408/* 1443/*
1409 * Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_USB, CM_DIV_M2_DPLL_CORE_RESTORE, 1444 * Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE,
1410 * CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_CORE, CM_DIV_M2_DPLL_DDRPHY, 1445 * CM_DIV_M2_DPLL_CORE_RESTORE, CM_DIV_M2_DPLL_DDRPHY, CM_DIV_M2_DPLL_MPU,
1411 * CM_DIV_M2_DPLL_MPU 1446 * CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_USB
1412 */ 1447 */
1413#define OMAP4430_ST_DPLL_CLKOUT_SHIFT 9 1448#define OMAP4430_ST_DPLL_CLKOUT_SHIFT 9
1414#define OMAP4430_ST_DPLL_CLKOUT_MASK BITFIELD(9, 9) 1449#define OMAP4430_ST_DPLL_CLKOUT_MASK (1 << 9)
1415 1450
1416/* 1451/*
1417 * Used by CM_DIV_M3_DPLL_PER, CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_ABE, 1452 * Used by CM_DIV_M3_DPLL_ABE, CM_DIV_M3_DPLL_CORE,
1418 * CM_DIV_M3_DPLL_CORE 1453 * CM_DIV_M3_DPLL_CORE_RESTORE, CM_DIV_M3_DPLL_PER
1419 */ 1454 */
1420#define OMAP4430_ST_DPLL_CLKOUTHIF_SHIFT 9 1455#define OMAP4430_ST_DPLL_CLKOUTHIF_SHIFT 9
1421#define OMAP4430_ST_DPLL_CLKOUTHIF_MASK BITFIELD(9, 9) 1456#define OMAP4430_ST_DPLL_CLKOUTHIF_MASK (1 << 9)
1422 1457
1423/* Used by CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO, CM_DIV_M2_DPLL_ABE */ 1458/* Used by CM_DIV_M2_DPLL_ABE, CM_DIV_M2_DPLL_PER, CM_DIV_M2_DPLL_UNIPRO */
1424#define OMAP4430_ST_DPLL_CLKOUTX2_SHIFT 11 1459#define OMAP4430_ST_DPLL_CLKOUTX2_SHIFT 11
1425#define OMAP4430_ST_DPLL_CLKOUTX2_MASK BITFIELD(11, 11) 1460#define OMAP4430_ST_DPLL_CLKOUTX2_MASK (1 << 11)
1426 1461
1427/* 1462/*
1428 * Used by CM_DIV_M4_DPLL_PER, CM_DIV_M4_DPLL_CORE_RESTORE, 1463 * Used by CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_CORE_RESTORE,
1429 * CM_DIV_M4_DPLL_CORE, CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA 1464 * CM_DIV_M4_DPLL_DDRPHY, CM_DIV_M4_DPLL_IVA, CM_DIV_M4_DPLL_PER
1430 */ 1465 */
1431#define OMAP4430_ST_HSDIVIDER_CLKOUT1_SHIFT 9 1466#define OMAP4430_ST_HSDIVIDER_CLKOUT1_SHIFT 9
1432#define OMAP4430_ST_HSDIVIDER_CLKOUT1_MASK BITFIELD(9, 9) 1467#define OMAP4430_ST_HSDIVIDER_CLKOUT1_MASK (1 << 9)
1433 1468
1434/* 1469/*
1435 * Used by CM_DIV_M5_DPLL_PER, CM_DIV_M5_DPLL_CORE_RESTORE, 1470 * Used by CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_CORE_RESTORE,
1436 * CM_DIV_M5_DPLL_CORE, CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA 1471 * CM_DIV_M5_DPLL_DDRPHY, CM_DIV_M5_DPLL_IVA, CM_DIV_M5_DPLL_PER
1437 */ 1472 */
1438#define OMAP4430_ST_HSDIVIDER_CLKOUT2_SHIFT 9 1473#define OMAP4430_ST_HSDIVIDER_CLKOUT2_SHIFT 9
1439#define OMAP4430_ST_HSDIVIDER_CLKOUT2_MASK BITFIELD(9, 9) 1474#define OMAP4430_ST_HSDIVIDER_CLKOUT2_MASK (1 << 9)
1440 1475
1441/* 1476/*
1442 * Used by CM_DIV_M6_DPLL_PER, CM_DIV_M6_DPLL_CORE_RESTORE, 1477 * Used by CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_CORE_RESTORE,
1443 * CM_DIV_M6_DPLL_CORE, CM_DIV_M6_DPLL_DDRPHY 1478 * CM_DIV_M6_DPLL_DDRPHY, CM_DIV_M6_DPLL_PER
1444 */ 1479 */
1445#define OMAP4430_ST_HSDIVIDER_CLKOUT3_SHIFT 9 1480#define OMAP4430_ST_HSDIVIDER_CLKOUT3_SHIFT 9
1446#define OMAP4430_ST_HSDIVIDER_CLKOUT3_MASK BITFIELD(9, 9) 1481#define OMAP4430_ST_HSDIVIDER_CLKOUT3_MASK (1 << 9)
1447 1482
1448/* 1483/*
1449 * Used by CM_DIV_M7_DPLL_PER, CM_DIV_M7_DPLL_CORE_RESTORE, 1484 * Used by CM_DIV_M7_DPLL_CORE, CM_DIV_M7_DPLL_CORE_RESTORE,
1450 * CM_DIV_M7_DPLL_CORE 1485 * CM_DIV_M7_DPLL_PER
1451 */ 1486 */
1452#define OMAP4430_ST_HSDIVIDER_CLKOUT4_SHIFT 9 1487#define OMAP4430_ST_HSDIVIDER_CLKOUT4_SHIFT 9
1453#define OMAP4430_ST_HSDIVIDER_CLKOUT4_MASK BITFIELD(9, 9) 1488#define OMAP4430_ST_HSDIVIDER_CLKOUT4_MASK (1 << 9)
1489
1490/*
1491 * Used by CM_IDLEST_DPLL_ABE, CM_IDLEST_DPLL_CORE, CM_IDLEST_DPLL_DDRPHY,
1492 * CM_IDLEST_DPLL_IVA, CM_IDLEST_DPLL_MPU, CM_IDLEST_DPLL_PER,
1493 * CM_IDLEST_DPLL_UNIPRO, CM_IDLEST_DPLL_USB
1494 */
1495#define OMAP4430_ST_MN_BYPASS_SHIFT 8
1496#define OMAP4430_ST_MN_BYPASS_MASK (1 << 8)
1454 1497
1455/* Used by CM_SYS_CLKSEL */ 1498/* Used by CM_SYS_CLKSEL */
1456#define OMAP4430_SYS_CLKSEL_SHIFT 0 1499#define OMAP4430_SYS_CLKSEL_SHIFT 0
1457#define OMAP4430_SYS_CLKSEL_MASK BITFIELD(0, 2) 1500#define OMAP4430_SYS_CLKSEL_MASK (0x7 << 0)
1458 1501
1459/* Used by CM_L4CFG_DYNAMICDEP */ 1502/* Used by CM_L4CFG_DYNAMICDEP, CM_L4CFG_DYNAMICDEP_RESTORE */
1460#define OMAP4430_TESLA_DYNDEP_SHIFT 1 1503#define OMAP4430_TESLA_DYNDEP_SHIFT 1
1461#define OMAP4430_TESLA_DYNDEP_MASK BITFIELD(1, 1) 1504#define OMAP4430_TESLA_DYNDEP_MASK (1 << 1)
1462 1505
1463/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */ 1506/* Used by CM_DUCATI_STATICDEP, CM_MPU_STATICDEP */
1464#define OMAP4430_TESLA_STATDEP_SHIFT 1 1507#define OMAP4430_TESLA_STATDEP_SHIFT 1
1465#define OMAP4430_TESLA_STATDEP_MASK BITFIELD(1, 1) 1508#define OMAP4430_TESLA_STATDEP_MASK (1 << 1)
1466 1509
1467/* 1510/*
1468 * Used by CM_EMU_DYNAMICDEP, CM_D2D_DYNAMICDEP, CM_DUCATI_DYNAMICDEP, 1511 * Used by CM_D2D_DYNAMICDEP, CM_D2D_DYNAMICDEP_RESTORE, CM_DUCATI_DYNAMICDEP,
1469 * CM_L3_1_DYNAMICDEP, CM_L3_2_DYNAMICDEP, CM_L4CFG_DYNAMICDEP, 1512 * CM_EMU_DYNAMICDEP, CM_L3_1_DYNAMICDEP, CM_L3_1_DYNAMICDEP_RESTORE,
1470 * CM_L4PER_DYNAMICDEP, CM_MPU_DYNAMICDEP, CM_TESLA_DYNAMICDEP 1513 * CM_L3_2_DYNAMICDEP, CM_L3_2_DYNAMICDEP_RESTORE, CM_L4CFG_DYNAMICDEP,
1514 * CM_L4CFG_DYNAMICDEP_RESTORE, CM_L4PER_DYNAMICDEP,
1515 * CM_L4PER_DYNAMICDEP_RESTORE, CM_MPU_DYNAMICDEP, CM_TESLA_DYNAMICDEP
1471 */ 1516 */
1472#define OMAP4430_WINDOWSIZE_SHIFT 24 1517#define OMAP4430_WINDOWSIZE_SHIFT 24
1473#define OMAP4430_WINDOWSIZE_MASK BITFIELD(24, 27) 1518#define OMAP4430_WINDOWSIZE_MASK (0xf << 24)
1519
1520/* Used by REVISION_CM1, REVISION_CM2 */
1521#define OMAP4430_X_MAJOR_SHIFT 8
1522#define OMAP4430_X_MAJOR_MASK (0x7 << 8)
1523
1524/* Used by REVISION_CM1, REVISION_CM2 */
1525#define OMAP4430_Y_MINOR_SHIFT 0
1526#define OMAP4430_Y_MINOR_MASK (0x3f << 0)
1474#endif 1527#endif
diff --git a/arch/arm/mach-omap2/cm44xx.h b/arch/arm/mach-omap2/cm44xx.h
index 336d94889e5b..3c35a87cb90c 100644
--- a/arch/arm/mach-omap2/cm44xx.h
+++ b/arch/arm/mach-omap2/cm44xx.h
@@ -195,6 +195,42 @@
195#define OMAP4_CM1_ABE_WDT3_CLKCTRL_OFFSET 0x0088 195#define OMAP4_CM1_ABE_WDT3_CLKCTRL_OFFSET 0x0088
196#define OMAP4430_CM1_ABE_WDT3_CLKCTRL OMAP44XX_CM1_REGADDR(OMAP4430_CM1_ABE_MOD, 0x0088) 196#define OMAP4430_CM1_ABE_WDT3_CLKCTRL OMAP44XX_CM1_REGADDR(OMAP4430_CM1_ABE_MOD, 0x0088)
197 197
198/* CM1.RESTORE_CM1 register offsets */
199#define OMAP4_CM_CLKSEL_CORE_RESTORE_OFFSET 0x0000
200#define OMAP4430_CM_CLKSEL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0000)
201#define OMAP4_CM_DIV_M2_DPLL_CORE_RESTORE_OFFSET 0x0004
202#define OMAP4430_CM_DIV_M2_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0004)
203#define OMAP4_CM_DIV_M3_DPLL_CORE_RESTORE_OFFSET 0x0008
204#define OMAP4430_CM_DIV_M3_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0008)
205#define OMAP4_CM_DIV_M4_DPLL_CORE_RESTORE_OFFSET 0x000c
206#define OMAP4430_CM_DIV_M4_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x000c)
207#define OMAP4_CM_DIV_M5_DPLL_CORE_RESTORE_OFFSET 0x0010
208#define OMAP4430_CM_DIV_M5_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0010)
209#define OMAP4_CM_DIV_M6_DPLL_CORE_RESTORE_OFFSET 0x0014
210#define OMAP4430_CM_DIV_M6_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0014)
211#define OMAP4_CM_DIV_M7_DPLL_CORE_RESTORE_OFFSET 0x0018
212#define OMAP4430_CM_DIV_M7_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0018)
213#define OMAP4_CM_CLKSEL_DPLL_CORE_RESTORE_OFFSET 0x001c
214#define OMAP4430_CM_CLKSEL_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x001c)
215#define OMAP4_CM_SSC_DELTAMSTEP_DPLL_CORE_RESTORE_OFFSET 0x0020
216#define OMAP4430_CM_SSC_DELTAMSTEP_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0020)
217#define OMAP4_CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE_OFFSET 0x0024
218#define OMAP4430_CM_SSC_MODFREQDIV_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0024)
219#define OMAP4_CM_CLKMODE_DPLL_CORE_RESTORE_OFFSET 0x0028
220#define OMAP4430_CM_CLKMODE_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0028)
221#define OMAP4_CM_SHADOW_FREQ_CONFIG2_RESTORE_OFFSET 0x002c
222#define OMAP4430_CM_SHADOW_FREQ_CONFIG2_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x002c)
223#define OMAP4_CM_SHADOW_FREQ_CONFIG1_RESTORE_OFFSET 0x0030
224#define OMAP4430_CM_SHADOW_FREQ_CONFIG1_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0030)
225#define OMAP4_CM_AUTOIDLE_DPLL_CORE_RESTORE_OFFSET 0x0034
226#define OMAP4430_CM_AUTOIDLE_DPLL_CORE_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0034)
227#define OMAP4_CM_MPU_CLKSTCTRL_RESTORE_OFFSET 0x0038
228#define OMAP4430_CM_MPU_CLKSTCTRL_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0038)
229#define OMAP4_CM_CM1_PROFILING_CLKCTRL_RESTORE_OFFSET 0x003c
230#define OMAP4430_CM_CM1_PROFILING_CLKCTRL_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x003c)
231#define OMAP4_CM_DYN_DEP_PRESCAL_RESTORE_OFFSET 0x0040
232#define OMAP4430_CM_DYN_DEP_PRESCAL_RESTORE OMAP44XX_CM1_REGADDR(OMAP4430_CM1_RESTORE_MOD, 0x0040)
233
198/* CM2 */ 234/* CM2 */
199 235
200/* CM2.OCP_SOCKET_CM2 register offsets */ 236/* CM2.OCP_SOCKET_CM2 register offsets */
@@ -252,8 +288,6 @@
252#define OMAP4430_CM_SSC_DELTAMSTEP_DPLL_PER OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x0068) 288#define OMAP4430_CM_SSC_DELTAMSTEP_DPLL_PER OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x0068)
253#define OMAP4_CM_SSC_MODFREQDIV_DPLL_PER_OFFSET 0x006c 289#define OMAP4_CM_SSC_MODFREQDIV_DPLL_PER_OFFSET 0x006c
254#define OMAP4430_CM_SSC_MODFREQDIV_DPLL_PER OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x006c) 290#define OMAP4430_CM_SSC_MODFREQDIV_DPLL_PER OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x006c)
255#define OMAP4_CM_EMU_OVERRIDE_DPLL_PER_OFFSET 0x0070
256#define OMAP4430_CM_EMU_OVERRIDE_DPLL_PER OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x0070)
257#define OMAP4_CM_CLKMODE_DPLL_USB_OFFSET 0x0080 291#define OMAP4_CM_CLKMODE_DPLL_USB_OFFSET 0x0080
258#define OMAP4430_CM_CLKMODE_DPLL_USB OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x0080) 292#define OMAP4430_CM_CLKMODE_DPLL_USB OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CKGEN_MOD, 0x0080)
259#define OMAP4_CM_IDLEST_DPLL_USB_OFFSET 0x0084 293#define OMAP4_CM_IDLEST_DPLL_USB_OFFSET 0x0084
@@ -296,6 +330,8 @@
296#define OMAP4430_CM_ALWON_SR_IVA_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_ALWAYS_ON_MOD, 0x0030) 330#define OMAP4430_CM_ALWON_SR_IVA_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_ALWAYS_ON_MOD, 0x0030)
297#define OMAP4_CM_ALWON_SR_CORE_CLKCTRL_OFFSET 0x0038 331#define OMAP4_CM_ALWON_SR_CORE_CLKCTRL_OFFSET 0x0038
298#define OMAP4430_CM_ALWON_SR_CORE_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_ALWAYS_ON_MOD, 0x0038) 332#define OMAP4430_CM_ALWON_SR_CORE_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_ALWAYS_ON_MOD, 0x0038)
333#define OMAP4_CM_ALWON_USBPHY_CLKCTRL_OFFSET 0x0040
334#define OMAP4430_CM_ALWON_USBPHY_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_ALWAYS_ON_MOD, 0x0040)
299 335
300/* CM2.CORE_CM2 register offsets */ 336/* CM2.CORE_CM2 register offsets */
301#define OMAP4_CM_L3_1_CLKSTCTRL_OFFSET 0x0000 337#define OMAP4_CM_L3_1_CLKSTCTRL_OFFSET 0x0000
@@ -578,4 +614,54 @@
578#define OMAP4430_CM_CEFUSE_CLKSTCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CEFUSE_MOD, 0x0000) 614#define OMAP4430_CM_CEFUSE_CLKSTCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CEFUSE_MOD, 0x0000)
579#define OMAP4_CM_CEFUSE_CEFUSE_CLKCTRL_OFFSET 0x0020 615#define OMAP4_CM_CEFUSE_CEFUSE_CLKCTRL_OFFSET 0x0020
580#define OMAP4430_CM_CEFUSE_CEFUSE_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CEFUSE_MOD, 0x0020) 616#define OMAP4430_CM_CEFUSE_CEFUSE_CLKCTRL OMAP44XX_CM2_REGADDR(OMAP4430_CM2_CEFUSE_MOD, 0x0020)
617
618/* CM2.RESTORE_CM2 register offsets */
619#define OMAP4_CM_L3_1_CLKSTCTRL_RESTORE_OFFSET 0x0000
620#define OMAP4430_CM_L3_1_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0000)
621#define OMAP4_CM_L3_2_CLKSTCTRL_RESTORE_OFFSET 0x0004
622#define OMAP4430_CM_L3_2_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0004)
623#define OMAP4_CM_L4CFG_CLKSTCTRL_RESTORE_OFFSET 0x0008
624#define OMAP4430_CM_L4CFG_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0008)
625#define OMAP4_CM_MEMIF_CLKSTCTRL_RESTORE_OFFSET 0x000c
626#define OMAP4430_CM_MEMIF_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x000c)
627#define OMAP4_CM_L4PER_CLKSTCTRL_RESTORE_OFFSET 0x0010
628#define OMAP4430_CM_L4PER_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0010)
629#define OMAP4_CM_L3INIT_CLKSTCTRL_RESTORE_OFFSET 0x0014
630#define OMAP4430_CM_L3INIT_CLKSTCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0014)
631#define OMAP4_CM_L3INSTR_L3_3_CLKCTRL_RESTORE_OFFSET 0x0018
632#define OMAP4430_CM_L3INSTR_L3_3_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0018)
633#define OMAP4_CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE_OFFSET 0x001c
634#define OMAP4430_CM_L3INSTR_L3_INSTR_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x001c)
635#define OMAP4_CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE_OFFSET 0x0020
636#define OMAP4430_CM_L3INSTR_OCP_WP1_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0020)
637#define OMAP4_CM_CM2_PROFILING_CLKCTRL_RESTORE_OFFSET 0x0024
638#define OMAP4430_CM_CM2_PROFILING_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0024)
639#define OMAP4_CM_D2D_STATICDEP_RESTORE_OFFSET 0x0028
640#define OMAP4430_CM_D2D_STATICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0028)
641#define OMAP4_CM_L3_1_DYNAMICDEP_RESTORE_OFFSET 0x002c
642#define OMAP4430_CM_L3_1_DYNAMICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x002c)
643#define OMAP4_CM_L3_2_DYNAMICDEP_RESTORE_OFFSET 0x0030
644#define OMAP4430_CM_L3_2_DYNAMICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0030)
645#define OMAP4_CM_D2D_DYNAMICDEP_RESTORE_OFFSET 0x0034
646#define OMAP4430_CM_D2D_DYNAMICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0034)
647#define OMAP4_CM_L4CFG_DYNAMICDEP_RESTORE_OFFSET 0x0038
648#define OMAP4430_CM_L4CFG_DYNAMICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0038)
649#define OMAP4_CM_L4PER_DYNAMICDEP_RESTORE_OFFSET 0x003c
650#define OMAP4430_CM_L4PER_DYNAMICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x003c)
651#define OMAP4_CM_L4PER_GPIO2_CLKCTRL_RESTORE_OFFSET 0x0040
652#define OMAP4430_CM_L4PER_GPIO2_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0040)
653#define OMAP4_CM_L4PER_GPIO3_CLKCTRL_RESTORE_OFFSET 0x0044
654#define OMAP4430_CM_L4PER_GPIO3_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0044)
655#define OMAP4_CM_L4PER_GPIO4_CLKCTRL_RESTORE_OFFSET 0x0048
656#define OMAP4430_CM_L4PER_GPIO4_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0048)
657#define OMAP4_CM_L4PER_GPIO5_CLKCTRL_RESTORE_OFFSET 0x004c
658#define OMAP4430_CM_L4PER_GPIO5_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x004c)
659#define OMAP4_CM_L4PER_GPIO6_CLKCTRL_RESTORE_OFFSET 0x0050
660#define OMAP4430_CM_L4PER_GPIO6_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0050)
661#define OMAP4_CM_L3INIT_USB_HOST_CLKCTRL_RESTORE_OFFSET 0x0054
662#define OMAP4430_CM_L3INIT_USB_HOST_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0054)
663#define OMAP4_CM_L3INIT_USB_TLL_CLKCTRL_RESTORE_OFFSET 0x0058
664#define OMAP4430_CM_L3INIT_USB_TLL_CLKCTRL_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x0058)
665#define OMAP4_CM_SDMA_STATICDEP_RESTORE_OFFSET 0x005c
666#define OMAP4430_CM_SDMA_STATICDEP_RESTORE OMAP44XX_CM2_REGADDR(OMAP4430_CM2_RESTORE_MOD, 0x005c)
581#endif 667#endif
diff --git a/arch/arm/mach-omap2/cm4xxx.c b/arch/arm/mach-omap2/cm4xxx.c
index b101091e95d6..f8a660a1a4a6 100644
--- a/arch/arm/mach-omap2/cm4xxx.c
+++ b/arch/arm/mach-omap2/cm4xxx.c
@@ -43,7 +43,6 @@
43 * using separate functional clock 43 * using separate functional clock
44 * 0x3 disabled: Module is disabled and cannot be accessed 44 * 0x3 disabled: Module is disabled and cannot be accessed
45 * 45 *
46 * TODO: Need to handle module accessible in idle state
47 */ 46 */
48int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg) 47int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
49{ 48{
@@ -52,9 +51,11 @@ int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
52 if (!clkctrl_reg) 51 if (!clkctrl_reg)
53 return 0; 52 return 0;
54 53
55 omap_test_timeout(((__raw_readl(clkctrl_reg) & 54 omap_test_timeout((
56 OMAP4430_IDLEST_MASK) == 0), 55 ((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) == 0) ||
57 MAX_MODULE_READY_TIME, i); 56 (((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) >>
57 OMAP4430_IDLEST_SHIFT) == 0x2)),
58 MAX_MODULE_READY_TIME, i);
58 59
59 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY; 60 return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
60} 61}
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
new file mode 100644
index 000000000000..778929f7e92d
--- /dev/null
+++ b/arch/arm/mach-omap2/common.c
@@ -0,0 +1,135 @@
1/*
2 * linux/arch/arm/mach-omap2/common.c
3 *
4 * Code common to all OMAP2+ machines.
5 *
6 * Copyright (C) 2009 Texas Instruments
7 * Copyright (C) 2010 Nokia Corporation
8 * Tony Lindgren <tony@atomide.com>
9 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
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#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/clk.h>
18#include <linux/io.h>
19
20#include <plat/common.h>
21#include <plat/board.h>
22#include <plat/mux.h>
23
24#include <plat/clock.h>
25
26#include "sdrc.h"
27#include "control.h"
28
29/* Global address base setup code */
30
31#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
32
33static void __init __omap2_set_globals(struct omap_globals *omap2_globals)
34{
35 omap2_set_globals_tap(omap2_globals);
36 omap2_set_globals_sdrc(omap2_globals);
37 omap2_set_globals_control(omap2_globals);
38 omap2_set_globals_prcm(omap2_globals);
39}
40
41#endif
42
43#if defined(CONFIG_ARCH_OMAP2420)
44
45static struct omap_globals omap242x_globals = {
46 .class = OMAP242X_CLASS,
47 .tap = OMAP2_L4_IO_ADDRESS(0x48014000),
48 .sdrc = OMAP2420_SDRC_BASE,
49 .sms = OMAP2420_SMS_BASE,
50 .ctrl = OMAP242X_CTRL_BASE,
51 .prm = OMAP2420_PRM_BASE,
52 .cm = OMAP2420_CM_BASE,
53 .uart1_phys = OMAP2_UART1_BASE,
54 .uart2_phys = OMAP2_UART2_BASE,
55 .uart3_phys = OMAP2_UART3_BASE,
56};
57
58void __init omap2_set_globals_242x(void)
59{
60 __omap2_set_globals(&omap242x_globals);
61}
62#endif
63
64#if defined(CONFIG_ARCH_OMAP2430)
65
66static struct omap_globals omap243x_globals = {
67 .class = OMAP243X_CLASS,
68 .tap = OMAP2_L4_IO_ADDRESS(0x4900a000),
69 .sdrc = OMAP243X_SDRC_BASE,
70 .sms = OMAP243X_SMS_BASE,
71 .ctrl = OMAP243X_CTRL_BASE,
72 .prm = OMAP2430_PRM_BASE,
73 .cm = OMAP2430_CM_BASE,
74 .uart1_phys = OMAP2_UART1_BASE,
75 .uart2_phys = OMAP2_UART2_BASE,
76 .uart3_phys = OMAP2_UART3_BASE,
77};
78
79void __init omap2_set_globals_243x(void)
80{
81 __omap2_set_globals(&omap243x_globals);
82}
83#endif
84
85#if defined(CONFIG_ARCH_OMAP3)
86
87static struct omap_globals omap3_globals = {
88 .class = OMAP343X_CLASS,
89 .tap = OMAP2_L4_IO_ADDRESS(0x4830A000),
90 .sdrc = OMAP343X_SDRC_BASE,
91 .sms = OMAP343X_SMS_BASE,
92 .ctrl = OMAP343X_CTRL_BASE,
93 .prm = OMAP3430_PRM_BASE,
94 .cm = OMAP3430_CM_BASE,
95 .uart1_phys = OMAP3_UART1_BASE,
96 .uart2_phys = OMAP3_UART2_BASE,
97 .uart3_phys = OMAP3_UART3_BASE,
98 .uart4_phys = OMAP3_UART4_BASE, /* Only on 3630 */
99};
100
101void __init omap2_set_globals_3xxx(void)
102{
103 __omap2_set_globals(&omap3_globals);
104}
105
106void __init omap3_map_io(void)
107{
108 omap2_set_globals_3xxx();
109 omap34xx_map_common_io();
110}
111#endif
112
113#if defined(CONFIG_ARCH_OMAP4)
114static struct omap_globals omap4_globals = {
115 .class = OMAP443X_CLASS,
116 .tap = OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE),
117 .ctrl = OMAP443X_SCM_BASE,
118 .ctrl_pad = OMAP443X_CTRL_BASE,
119 .prm = OMAP4430_PRM_BASE,
120 .cm = OMAP4430_CM_BASE,
121 .cm2 = OMAP4430_CM2_BASE,
122 .uart1_phys = OMAP4_UART1_BASE,
123 .uart2_phys = OMAP4_UART2_BASE,
124 .uart3_phys = OMAP4_UART3_BASE,
125 .uart4_phys = OMAP4_UART4_BASE,
126};
127
128void __init omap2_set_globals_443x(void)
129{
130 omap2_set_globals_tap(&omap4_globals);
131 omap2_set_globals_control(&omap4_globals);
132 omap2_set_globals_prcm(&omap4_globals);
133}
134#endif
135
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index a8d20eef2306..1fa3294b6048 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -16,15 +16,18 @@
16#include <linux/io.h> 16#include <linux/io.h>
17 17
18#include <plat/common.h> 18#include <plat/common.h>
19#include <plat/control.h>
20#include <plat/sdrc.h> 19#include <plat/sdrc.h>
20
21#include "cm-regbits-34xx.h" 21#include "cm-regbits-34xx.h"
22#include "prm-regbits-34xx.h" 22#include "prm-regbits-34xx.h"
23#include "cm.h" 23#include "cm.h"
24#include "prm.h" 24#include "prm.h"
25#include "sdrc.h" 25#include "sdrc.h"
26#include "pm.h"
27#include "control.h"
26 28
27static void __iomem *omap2_ctrl_base; 29static void __iomem *omap2_ctrl_base;
30static void __iomem *omap4_ctrl_pad_base;
28 31
29#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 32#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
30struct omap3_scratchpad { 33struct omap3_scratchpad {
@@ -137,6 +140,7 @@ static struct omap3_control_regs control_context;
137#endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */ 140#endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
138 141
139#define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg)) 142#define OMAP_CTRL_REGADDR(reg) (omap2_ctrl_base + (reg))
143#define OMAP4_CTRL_PAD_REGADDR(reg) (omap4_ctrl_pad_base + (reg))
140 144
141void __init omap2_set_globals_control(struct omap_globals *omap2_globals) 145void __init omap2_set_globals_control(struct omap_globals *omap2_globals)
142{ 146{
@@ -145,6 +149,12 @@ void __init omap2_set_globals_control(struct omap_globals *omap2_globals)
145 omap2_ctrl_base = ioremap(omap2_globals->ctrl, SZ_4K); 149 omap2_ctrl_base = ioremap(omap2_globals->ctrl, SZ_4K);
146 WARN_ON(!omap2_ctrl_base); 150 WARN_ON(!omap2_ctrl_base);
147 } 151 }
152
153 /* Static mapping, never released */
154 if (omap2_globals->ctrl_pad) {
155 omap4_ctrl_pad_base = ioremap(omap2_globals->ctrl_pad, SZ_4K);
156 WARN_ON(!omap4_ctrl_pad_base);
157 }
148} 158}
149 159
150void __iomem *omap_ctrl_base_get(void) 160void __iomem *omap_ctrl_base_get(void)
@@ -182,6 +192,23 @@ void omap_ctrl_writel(u32 val, u16 offset)
182 __raw_writel(val, OMAP_CTRL_REGADDR(offset)); 192 __raw_writel(val, OMAP_CTRL_REGADDR(offset));
183} 193}
184 194
195/*
196 * On OMAP4 control pad are not addressable from control
197 * core base. So the common omap_ctrl_read/write APIs breaks
198 * Hence export separate APIs to manage the omap4 pad control
199 * registers. This APIs will work only for OMAP4
200 */
201
202u32 omap4_ctrl_pad_readl(u16 offset)
203{
204 return __raw_readl(OMAP4_CTRL_PAD_REGADDR(offset));
205}
206
207void omap4_ctrl_pad_writel(u32 val, u16 offset)
208{
209 __raw_writel(val, OMAP4_CTRL_PAD_REGADDR(offset));
210}
211
185#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 212#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
186/* 213/*
187 * Clears the scratchpad contents in case of cold boot- 214 * Clears the scratchpad contents in case of cold boot-
@@ -190,7 +217,7 @@ void omap_ctrl_writel(u32 val, u16 offset)
190void omap3_clear_scratchpad_contents(void) 217void omap3_clear_scratchpad_contents(void)
191{ 218{
192 u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET; 219 u32 max_offset = OMAP343X_SCRATCHPAD_ROM_OFFSET;
193 u32 *v_addr; 220 void __iomem *v_addr;
194 u32 offset = 0; 221 u32 offset = 0;
195 v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM); 222 v_addr = OMAP2_L4_IO_ADDRESS(OMAP343X_SCRATCHPAD_ROM);
196 if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) & 223 if (prm_read_mod_reg(OMAP3430_GR_MOD, OMAP3_PRM_RSTST_OFFSET) &
@@ -206,7 +233,7 @@ void omap3_clear_scratchpad_contents(void)
206/* Populate the scratchpad structure with restore structure */ 233/* Populate the scratchpad structure with restore structure */
207void omap3_save_scratchpad_contents(void) 234void omap3_save_scratchpad_contents(void)
208{ 235{
209 void * __iomem scratchpad_address; 236 void __iomem *scratchpad_address;
210 u32 arm_context_addr; 237 u32 arm_context_addr;
211 struct omap3_scratchpad scratchpad_contents; 238 struct omap3_scratchpad scratchpad_contents;
212 struct omap3_scratchpad_prcm_block prcm_block_contents; 239 struct omap3_scratchpad_prcm_block prcm_block_contents;
diff --git a/arch/arm/plat-omap/include/plat/control.h b/arch/arm/mach-omap2/control.h
index 131bf405c2f6..b6c6b7c450b3 100644
--- a/arch/arm/plat-omap/include/plat/control.h
+++ b/arch/arm/mach-omap2/control.h
@@ -1,10 +1,10 @@
1/* 1/*
2 * arch/arm/plat-omap/include/mach/control.h 2 * arch/arm/mach-omap2/control.h
3 * 3 *
4 * OMAP2/3/4 System Control Module definitions 4 * OMAP2/3/4 System Control Module definitions
5 * 5 *
6 * Copyright (C) 2007-2009 Texas Instruments, Inc. 6 * Copyright (C) 2007-2010 Texas Instruments, Inc.
7 * Copyright (C) 2007-2008 Nokia Corporation 7 * Copyright (C) 2007-2008, 2010 Nokia Corporation
8 * 8 *
9 * Written by Paul Walmsley 9 * Written by Paul Walmsley
10 * 10 *
@@ -13,10 +13,14 @@
13 * the Free Software Foundation. 13 * the Free Software Foundation.
14 */ 14 */
15 15
16#ifndef __ASM_ARCH_CONTROL_H 16#ifndef __ARCH_ARM_MACH_OMAP2_CONTROL_H
17#define __ASM_ARCH_CONTROL_H 17#define __ARCH_ARM_MACH_OMAP2_CONTROL_H
18 18
19#include <mach/io.h> 19#include <mach/io.h>
20#include <mach/ctrl_module_core_44xx.h>
21#include <mach/ctrl_module_wkup_44xx.h>
22#include <mach/ctrl_module_pad_core_44xx.h>
23#include <mach/ctrl_module_pad_wkup_44xx.h>
20 24
21#ifndef __ASSEMBLY__ 25#ifndef __ASSEMBLY__
22#define OMAP242X_CTRL_REGADDR(reg) \ 26#define OMAP242X_CTRL_REGADDR(reg) \
@@ -204,12 +208,6 @@
204#define OMAP3_PADCONF_SAD2D_MSTANDBY 0x250 208#define OMAP3_PADCONF_SAD2D_MSTANDBY 0x250
205#define OMAP3_PADCONF_SAD2D_IDLEACK 0x254 209#define OMAP3_PADCONF_SAD2D_IDLEACK 0x254
206 210
207/* 44xx control status register offset */
208#define OMAP44XX_CONTROL_STATUS 0x2c4
209
210/* 44xx-only CONTROL_GENERAL register offsets */
211#define OMAP44XX_CONTROL_MMC1 0x628
212#define OMAP44XX_CONTROL_PBIAS_LITE 0x600
213/* 211/*
214 * REVISIT: This list of registers is not comprehensive - there are more 212 * REVISIT: This list of registers is not comprehensive - there are more
215 * that should be added. 213 * that should be added.
@@ -225,6 +223,8 @@
225#define OMAP2_MMCSDIO1ADPCLKISEL (1 << 24) /* MMC1 loop back clock */ 223#define OMAP2_MMCSDIO1ADPCLKISEL (1 << 24) /* MMC1 loop back clock */
226#define OMAP24XX_USBSTANDBYCTRL (1 << 15) 224#define OMAP24XX_USBSTANDBYCTRL (1 << 15)
227#define OMAP2_MCBSP2_CLKS_MASK (1 << 6) 225#define OMAP2_MCBSP2_CLKS_MASK (1 << 6)
226#define OMAP2_MCBSP1_FSR_MASK (1 << 4)
227#define OMAP2_MCBSP1_CLKR_MASK (1 << 3)
228#define OMAP2_MCBSP1_CLKS_MASK (1 << 2) 228#define OMAP2_MCBSP1_CLKS_MASK (1 << 2)
229 229
230/* CONTROL_DEVCONF1 bits */ 230/* CONTROL_DEVCONF1 bits */
@@ -255,23 +255,6 @@
255#define OMAP2_PBIASLITEPWRDNZ0 (1 << 1) 255#define OMAP2_PBIASLITEPWRDNZ0 (1 << 1)
256#define OMAP2_PBIASLITEVMODE0 (1 << 0) 256#define OMAP2_PBIASLITEVMODE0 (1 << 0)
257 257
258/* CONTROL_PBIAS_LITE bits for OMAP4 */
259#define OMAP4_MMC1_PWRDNZ (1 << 26)
260#define OMAP4_MMC1_PBIASLITE_HIZ_MODE (1 << 25)
261#define OMAP4_MMC1_PBIASLITE_SUPPLY_HI_OUT (1 << 24)
262#define OMAP4_MMC1_PBIASLITE_VMODE_ERROR (1 << 23)
263#define OMAP4_MMC1_PBIASLITE_PWRDNZ (1 << 22)
264#define OMAP4_MMC1_PBIASLITE_VMODE (1 << 21)
265#define OMAP4_USBC1_ICUSB_PWRDNZ (1 << 20)
266
267#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP0 (1 << 31)
268#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP1 (1 << 30)
269#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP2 (1 << 29)
270#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP3 (1 << 28)
271#define OMAP4_CONTROL_SDMMC1_DR0_SPEEDCTRL (1 << 27)
272#define OMAP4_CONTROL_SDMMC1_DR1_SPEEDCTRL (1 << 26)
273#define OMAP4_CONTROL_SDMMC1_DR2_SPEEDCTRL (1 << 25)
274
275/* CONTROL_PROG_IO1 bits */ 258/* CONTROL_PROG_IO1 bits */
276#define OMAP3630_PRG_SDMMC1_SPEEDCTRL (1 << 20) 259#define OMAP3630_PRG_SDMMC1_SPEEDCTRL (1 << 20)
277 260
@@ -338,12 +321,12 @@
338#define FEAT_L2CACHE_256KB 3 321#define FEAT_L2CACHE_256KB 3
339 322
340#define OMAP3_ISP_SHIFT 5 323#define OMAP3_ISP_SHIFT 5
341#define OMAP3_ISP_MASK (1<< OMAP3_ISP_SHIFT) 324#define OMAP3_ISP_MASK (1 << OMAP3_ISP_SHIFT)
342#define FEAT_ISP 0 325#define FEAT_ISP 0
343#define FEAT_ISP_NONE 1 326#define FEAT_ISP_NONE 1
344 327
345#define OMAP3_NEON_SHIFT 4 328#define OMAP3_NEON_SHIFT 4
346#define OMAP3_NEON_MASK (1<< OMAP3_NEON_SHIFT) 329#define OMAP3_NEON_MASK (1 << OMAP3_NEON_SHIFT)
347#define FEAT_NEON 0 330#define FEAT_NEON 0
348#define FEAT_NEON_NONE 1 331#define FEAT_NEON_NONE 1
349 332
@@ -354,9 +337,11 @@ extern void __iomem *omap_ctrl_base_get(void);
354extern u8 omap_ctrl_readb(u16 offset); 337extern u8 omap_ctrl_readb(u16 offset);
355extern u16 omap_ctrl_readw(u16 offset); 338extern u16 omap_ctrl_readw(u16 offset);
356extern u32 omap_ctrl_readl(u16 offset); 339extern u32 omap_ctrl_readl(u16 offset);
340extern u32 omap4_ctrl_pad_readl(u16 offset);
357extern void omap_ctrl_writeb(u8 val, u16 offset); 341extern void omap_ctrl_writeb(u8 val, u16 offset);
358extern void omap_ctrl_writew(u16 val, u16 offset); 342extern void omap_ctrl_writew(u16 val, u16 offset);
359extern void omap_ctrl_writel(u32 val, u16 offset); 343extern void omap_ctrl_writel(u32 val, u16 offset);
344extern void omap4_ctrl_pad_writel(u32 val, u16 offset);
360 345
361extern void omap3_save_scratchpad_contents(void); 346extern void omap3_save_scratchpad_contents(void);
362extern void omap3_clear_scratchpad_contents(void); 347extern void omap3_clear_scratchpad_contents(void);
@@ -371,11 +356,13 @@ extern void omap3_control_restore_context(void);
371#define omap_ctrl_readb(x) 0 356#define omap_ctrl_readb(x) 0
372#define omap_ctrl_readw(x) 0 357#define omap_ctrl_readw(x) 0
373#define omap_ctrl_readl(x) 0 358#define omap_ctrl_readl(x) 0
359#define omap4_ctrl_pad_readl(x) 0
374#define omap_ctrl_writeb(x, y) WARN_ON(1) 360#define omap_ctrl_writeb(x, y) WARN_ON(1)
375#define omap_ctrl_writew(x, y) WARN_ON(1) 361#define omap_ctrl_writew(x, y) WARN_ON(1)
376#define omap_ctrl_writel(x, y) WARN_ON(1) 362#define omap_ctrl_writel(x, y) WARN_ON(1)
363#define omap4_ctrl_pad_writel(x, y) WARN_ON(1)
377#endif 364#endif
378#endif /* __ASSEMBLY__ */ 365#endif /* __ASSEMBLY__ */
379 366
380#endif /* __ASM_ARCH_CONTROL_H */ 367#endif /* __ARCH_ARM_MACH_OMAP2_CONTROL_H */
381 368
diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
index 3d3d035db9af..0d50b45d041c 100644
--- a/arch/arm/mach-omap2/cpuidle34xx.c
+++ b/arch/arm/mach-omap2/cpuidle34xx.c
@@ -29,10 +29,10 @@
29#include <plat/irqs.h> 29#include <plat/irqs.h>
30#include <plat/powerdomain.h> 30#include <plat/powerdomain.h>
31#include <plat/clockdomain.h> 31#include <plat/clockdomain.h>
32#include <plat/control.h>
33#include <plat/serial.h> 32#include <plat/serial.h>
34 33
35#include "pm.h" 34#include "pm.h"
35#include "control.h"
36 36
37#ifdef CONFIG_CPU_IDLE 37#ifdef CONFIG_CPU_IDLE
38 38
@@ -60,7 +60,8 @@ struct omap3_processor_cx {
60 60
61struct omap3_processor_cx omap3_power_states[OMAP3_MAX_STATES]; 61struct omap3_processor_cx omap3_power_states[OMAP3_MAX_STATES];
62struct omap3_processor_cx current_cx_state; 62struct omap3_processor_cx current_cx_state;
63struct powerdomain *mpu_pd, *core_pd; 63struct powerdomain *mpu_pd, *core_pd, *per_pd;
64struct powerdomain *cam_pd;
64 65
65/* 66/*
66 * The latencies/thresholds for various C states have 67 * The latencies/thresholds for various C states have
@@ -233,14 +234,60 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
233 struct cpuidle_state *state) 234 struct cpuidle_state *state)
234{ 235{
235 struct cpuidle_state *new_state = next_valid_state(dev, state); 236 struct cpuidle_state *new_state = next_valid_state(dev, state);
237 u32 core_next_state, per_next_state = 0, per_saved_state = 0;
238 u32 cam_state;
239 struct omap3_processor_cx *cx;
240 int ret;
236 241
237 if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) { 242 if ((state->flags & CPUIDLE_FLAG_CHECK_BM) && omap3_idle_bm_check()) {
238 BUG_ON(!dev->safe_state); 243 BUG_ON(!dev->safe_state);
239 new_state = dev->safe_state; 244 new_state = dev->safe_state;
245 goto select_state;
240 } 246 }
241 247
248 cx = cpuidle_get_statedata(state);
249 core_next_state = cx->core_state;
250
251 /*
252 * FIXME: we currently manage device-specific idle states
253 * for PER and CORE in combination with CPU-specific
254 * idle states. This is wrong, and device-specific
255 * idle managment needs to be separated out into
256 * its own code.
257 */
258
259 /*
260 * Prevent idle completely if CAM is active.
261 * CAM does not have wakeup capability in OMAP3.
262 */
263 cam_state = pwrdm_read_pwrst(cam_pd);
264 if (cam_state == PWRDM_POWER_ON) {
265 new_state = dev->safe_state;
266 goto select_state;
267 }
268
269 /*
270 * Prevent PER off if CORE is not in retention or off as this
271 * would disable PER wakeups completely.
272 */
273 per_next_state = per_saved_state = pwrdm_read_next_pwrst(per_pd);
274 if ((per_next_state == PWRDM_POWER_OFF) &&
275 (core_next_state > PWRDM_POWER_RET))
276 per_next_state = PWRDM_POWER_RET;
277
278 /* Are we changing PER target state? */
279 if (per_next_state != per_saved_state)
280 pwrdm_set_next_pwrst(per_pd, per_next_state);
281
282select_state:
242 dev->last_state = new_state; 283 dev->last_state = new_state;
243 return omap3_enter_idle(dev, new_state); 284 ret = omap3_enter_idle(dev, new_state);
285
286 /* Restore original PER state if it was modified */
287 if (per_next_state != per_saved_state)
288 pwrdm_set_next_pwrst(per_pd, per_saved_state);
289
290 return ret;
244} 291}
245 292
246DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev); 293DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
@@ -328,7 +375,8 @@ void omap_init_power_states(void)
328 cpuidle_params_table[OMAP3_STATE_C2].threshold; 375 cpuidle_params_table[OMAP3_STATE_C2].threshold;
329 omap3_power_states[OMAP3_STATE_C2].mpu_state = PWRDM_POWER_ON; 376 omap3_power_states[OMAP3_STATE_C2].mpu_state = PWRDM_POWER_ON;
330 omap3_power_states[OMAP3_STATE_C2].core_state = PWRDM_POWER_ON; 377 omap3_power_states[OMAP3_STATE_C2].core_state = PWRDM_POWER_ON;
331 omap3_power_states[OMAP3_STATE_C2].flags = CPUIDLE_FLAG_TIME_VALID; 378 omap3_power_states[OMAP3_STATE_C2].flags = CPUIDLE_FLAG_TIME_VALID |
379 CPUIDLE_FLAG_CHECK_BM;
332 380
333 /* C3 . MPU CSWR + Core inactive */ 381 /* C3 . MPU CSWR + Core inactive */
334 omap3_power_states[OMAP3_STATE_C3].valid = 382 omap3_power_states[OMAP3_STATE_C3].valid =
@@ -426,6 +474,8 @@ int __init omap3_idle_init(void)
426 474
427 mpu_pd = pwrdm_lookup("mpu_pwrdm"); 475 mpu_pd = pwrdm_lookup("mpu_pwrdm");
428 core_pd = pwrdm_lookup("core_pwrdm"); 476 core_pd = pwrdm_lookup("core_pwrdm");
477 per_pd = pwrdm_lookup("per_pwrdm");
478 cam_pd = pwrdm_lookup("cam_pwrdm");
429 479
430 omap_init_power_states(); 480 omap_init_power_states();
431 cpuidle_register_driver(&omap3_idle_driver); 481 cpuidle_register_driver(&omap3_idle_driver);
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 2dbb265bedd4..5a0c148e23bc 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -9,12 +9,12 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/module.h>
13#include <linux/kernel.h> 12#include <linux/kernel.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
16#include <linux/io.h> 15#include <linux/io.h>
17#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/err.h>
18 18
19#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <mach/irqs.h> 20#include <mach/irqs.h>
@@ -22,14 +22,17 @@
22#include <asm/mach/map.h> 22#include <asm/mach/map.h>
23#include <asm/pmu.h> 23#include <asm/pmu.h>
24 24
25#include <plat/control.h>
26#include <plat/tc.h> 25#include <plat/tc.h>
27#include <plat/board.h> 26#include <plat/board.h>
27#include <plat/mcbsp.h>
28#include <mach/gpio.h> 28#include <mach/gpio.h>
29#include <plat/mmc.h> 29#include <plat/mmc.h>
30#include <plat/dma.h> 30#include <plat/dma.h>
31#include <plat/omap_hwmod.h>
32#include <plat/omap_device.h>
31 33
32#include "mux.h" 34#include "mux.h"
35#include "control.h"
33 36
34#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE) 37#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
35 38
@@ -235,6 +238,43 @@ static inline void omap_init_mbox(void) { }
235 238
236static inline void omap_init_sti(void) {} 239static inline void omap_init_sti(void) {}
237 240
241#if defined(CONFIG_SND_SOC) || defined(CONFIG_SND_SOC_MODULE)
242
243static struct platform_device omap_pcm = {
244 .name = "omap-pcm-audio",
245 .id = -1,
246};
247
248/*
249 * OMAP2420 has 2 McBSP ports
250 * OMAP2430 has 5 McBSP ports
251 * OMAP3 has 5 McBSP ports
252 * OMAP4 has 4 McBSP ports
253 */
254OMAP_MCBSP_PLATFORM_DEVICE(1);
255OMAP_MCBSP_PLATFORM_DEVICE(2);
256OMAP_MCBSP_PLATFORM_DEVICE(3);
257OMAP_MCBSP_PLATFORM_DEVICE(4);
258OMAP_MCBSP_PLATFORM_DEVICE(5);
259
260static void omap_init_audio(void)
261{
262 platform_device_register(&omap_mcbsp1);
263 platform_device_register(&omap_mcbsp2);
264 if (cpu_is_omap243x() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
265 platform_device_register(&omap_mcbsp3);
266 platform_device_register(&omap_mcbsp4);
267 }
268 if (cpu_is_omap243x() || cpu_is_omap34xx())
269 platform_device_register(&omap_mcbsp5);
270
271 platform_device_register(&omap_pcm);
272}
273
274#else
275static inline void omap_init_audio(void) {}
276#endif
277
238#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) 278#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
239 279
240#include <plat/mcspi.h> 280#include <plat/mcspi.h>
@@ -498,6 +538,76 @@ static void omap_init_sham(void)
498static inline void omap_init_sham(void) { } 538static inline void omap_init_sham(void) { }
499#endif 539#endif
500 540
541#if defined(CONFIG_CRYPTO_DEV_OMAP_AES) || defined(CONFIG_CRYPTO_DEV_OMAP_AES_MODULE)
542
543#ifdef CONFIG_ARCH_OMAP2
544static struct resource omap2_aes_resources[] = {
545 {
546 .start = OMAP24XX_SEC_AES_BASE,
547 .end = OMAP24XX_SEC_AES_BASE + 0x4C,
548 .flags = IORESOURCE_MEM,
549 },
550 {
551 .start = OMAP24XX_DMA_AES_TX,
552 .flags = IORESOURCE_DMA,
553 },
554 {
555 .start = OMAP24XX_DMA_AES_RX,
556 .flags = IORESOURCE_DMA,
557 }
558};
559static int omap2_aes_resources_sz = ARRAY_SIZE(omap2_aes_resources);
560#else
561#define omap2_aes_resources NULL
562#define omap2_aes_resources_sz 0
563#endif
564
565#ifdef CONFIG_ARCH_OMAP3
566static struct resource omap3_aes_resources[] = {
567 {
568 .start = OMAP34XX_SEC_AES_BASE,
569 .end = OMAP34XX_SEC_AES_BASE + 0x4C,
570 .flags = IORESOURCE_MEM,
571 },
572 {
573 .start = OMAP34XX_DMA_AES2_TX,
574 .flags = IORESOURCE_DMA,
575 },
576 {
577 .start = OMAP34XX_DMA_AES2_RX,
578 .flags = IORESOURCE_DMA,
579 }
580};
581static int omap3_aes_resources_sz = ARRAY_SIZE(omap3_aes_resources);
582#else
583#define omap3_aes_resources NULL
584#define omap3_aes_resources_sz 0
585#endif
586
587static struct platform_device aes_device = {
588 .name = "omap-aes",
589 .id = -1,
590};
591
592static void omap_init_aes(void)
593{
594 if (cpu_is_omap24xx()) {
595 aes_device.resource = omap2_aes_resources;
596 aes_device.num_resources = omap2_aes_resources_sz;
597 } else if (cpu_is_omap34xx()) {
598 aes_device.resource = omap3_aes_resources;
599 aes_device.num_resources = omap3_aes_resources_sz;
600 } else {
601 pr_err("%s: platform not supported\n", __func__);
602 return;
603 }
604 platform_device_register(&aes_device);
605}
606
607#else
608static inline void omap_init_aes(void) { }
609#endif
610
501/*-------------------------------------------------------------------------*/ 611/*-------------------------------------------------------------------------*/
502 612
503#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) 613#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
@@ -624,7 +734,7 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
624 omap_mux_init_signal("sdmmc_dat0", 0); 734 omap_mux_init_signal("sdmmc_dat0", 0);
625 omap_mux_init_signal("sdmmc_dat_dir0", 0); 735 omap_mux_init_signal("sdmmc_dat_dir0", 0);
626 omap_mux_init_signal("sdmmc_cmd_dir", 0); 736 omap_mux_init_signal("sdmmc_cmd_dir", 0);
627 if (mmc_controller->slots[0].wires == 4) { 737 if (mmc_controller->slots[0].caps & MMC_CAP_4_BIT_DATA) {
628 omap_mux_init_signal("sdmmc_dat1", 0); 738 omap_mux_init_signal("sdmmc_dat1", 0);
629 omap_mux_init_signal("sdmmc_dat2", 0); 739 omap_mux_init_signal("sdmmc_dat2", 0);
630 omap_mux_init_signal("sdmmc_dat3", 0); 740 omap_mux_init_signal("sdmmc_dat3", 0);
@@ -652,8 +762,8 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
652 OMAP_PIN_INPUT_PULLUP); 762 OMAP_PIN_INPUT_PULLUP);
653 omap_mux_init_signal("sdmmc1_dat0", 763 omap_mux_init_signal("sdmmc1_dat0",
654 OMAP_PIN_INPUT_PULLUP); 764 OMAP_PIN_INPUT_PULLUP);
655 if (mmc_controller->slots[0].wires == 4 || 765 if (mmc_controller->slots[0].caps &
656 mmc_controller->slots[0].wires == 8) { 766 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
657 omap_mux_init_signal("sdmmc1_dat1", 767 omap_mux_init_signal("sdmmc1_dat1",
658 OMAP_PIN_INPUT_PULLUP); 768 OMAP_PIN_INPUT_PULLUP);
659 omap_mux_init_signal("sdmmc1_dat2", 769 omap_mux_init_signal("sdmmc1_dat2",
@@ -661,7 +771,8 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
661 omap_mux_init_signal("sdmmc1_dat3", 771 omap_mux_init_signal("sdmmc1_dat3",
662 OMAP_PIN_INPUT_PULLUP); 772 OMAP_PIN_INPUT_PULLUP);
663 } 773 }
664 if (mmc_controller->slots[0].wires == 8) { 774 if (mmc_controller->slots[0].caps &
775 MMC_CAP_8_BIT_DATA) {
665 omap_mux_init_signal("sdmmc1_dat4", 776 omap_mux_init_signal("sdmmc1_dat4",
666 OMAP_PIN_INPUT_PULLUP); 777 OMAP_PIN_INPUT_PULLUP);
667 omap_mux_init_signal("sdmmc1_dat5", 778 omap_mux_init_signal("sdmmc1_dat5",
@@ -685,8 +796,8 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
685 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed 796 * For 8 wire configurations, Lines DAT4, 5, 6 and 7 need to be muxed
686 * in the board-*.c files 797 * in the board-*.c files
687 */ 798 */
688 if (mmc_controller->slots[0].wires == 4 || 799 if (mmc_controller->slots[0].caps &
689 mmc_controller->slots[0].wires == 8) { 800 (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)) {
690 omap_mux_init_signal("sdmmc2_dat1", 801 omap_mux_init_signal("sdmmc2_dat1",
691 OMAP_PIN_INPUT_PULLUP); 802 OMAP_PIN_INPUT_PULLUP);
692 omap_mux_init_signal("sdmmc2_dat2", 803 omap_mux_init_signal("sdmmc2_dat2",
@@ -694,7 +805,8 @@ static inline void omap2_mmc_mux(struct omap_mmc_platform_data *mmc_controller,
694 omap_mux_init_signal("sdmmc2_dat3", 805 omap_mux_init_signal("sdmmc2_dat3",
695 OMAP_PIN_INPUT_PULLUP); 806 OMAP_PIN_INPUT_PULLUP);
696 } 807 }
697 if (mmc_controller->slots[0].wires == 8) { 808 if (mmc_controller->slots[0].caps &
809 MMC_CAP_8_BIT_DATA) {
698 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4", 810 omap_mux_init_signal("sdmmc2_dat4.sdmmc2_dat4",
699 OMAP_PIN_INPUT_PULLUP); 811 OMAP_PIN_INPUT_PULLUP);
700 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5", 812 omap_mux_init_signal("sdmmc2_dat5.sdmmc2_dat5",
@@ -745,13 +857,13 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
745 case 3: 857 case 3:
746 if (!cpu_is_omap44xx()) 858 if (!cpu_is_omap44xx())
747 return; 859 return;
748 base = OMAP4_MMC4_BASE + OMAP4_MMC_REG_OFFSET; 860 base = OMAP4_MMC4_BASE;
749 irq = OMAP44XX_IRQ_MMC4; 861 irq = OMAP44XX_IRQ_MMC4;
750 break; 862 break;
751 case 4: 863 case 4:
752 if (!cpu_is_omap44xx()) 864 if (!cpu_is_omap44xx())
753 return; 865 return;
754 base = OMAP4_MMC5_BASE + OMAP4_MMC_REG_OFFSET; 866 base = OMAP4_MMC5_BASE;
755 irq = OMAP44XX_IRQ_MMC5; 867 irq = OMAP44XX_IRQ_MMC5;
756 break; 868 break;
757 default: 869 default:
@@ -762,10 +874,8 @@ void __init omap2_init_mmc(struct omap_mmc_platform_data **mmc_data,
762 size = OMAP2420_MMC_SIZE; 874 size = OMAP2420_MMC_SIZE;
763 name = "mmci-omap"; 875 name = "mmci-omap";
764 } else if (cpu_is_omap44xx()) { 876 } else if (cpu_is_omap44xx()) {
765 if (i < 3) { 877 if (i < 3)
766 base += OMAP4_MMC_REG_OFFSET;
767 irq += OMAP44XX_IRQ_GIC_START; 878 irq += OMAP44XX_IRQ_GIC_START;
768 }
769 size = OMAP4_HSMMC_SIZE; 879 size = OMAP4_HSMMC_SIZE;
770 name = "mmci-omap-hs"; 880 name = "mmci-omap-hs";
771 } else { 881 } else {
@@ -841,12 +951,74 @@ static inline void omap_init_vout(void) {}
841 951
842/*-------------------------------------------------------------------------*/ 952/*-------------------------------------------------------------------------*/
843 953
954/*
955 * Inorder to avoid any assumptions from bootloader regarding WDT
956 * settings, WDT module is reset during init. This enables the watchdog
957 * timer. Hence it is required to disable the watchdog after the WDT reset
958 * during init. Otherwise the system would reboot as per the default
959 * watchdog timer registers settings.
960 */
961#define OMAP_WDT_WPS (0x34)
962#define OMAP_WDT_SPR (0x48)
963
964static int omap2_disable_wdt(struct omap_hwmod *oh, void *unused)
965{
966 void __iomem *base;
967 int ret;
968
969 if (!oh) {
970 pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
971 return -EINVAL;
972 }
973
974 base = omap_hwmod_get_mpu_rt_va(oh);
975 if (!base) {
976 pr_err("%s: Could not get the base address for %s\n",
977 oh->name, __func__);
978 return -EINVAL;
979 }
980
981 /* Enable the clocks before accessing the WDT registers */
982 ret = omap_hwmod_enable(oh);
983 if (ret) {
984 pr_err("%s: Could not enable clocks for %s\n",
985 oh->name, __func__);
986 return ret;
987 }
988
989 /* sequence required to disable watchdog */
990 __raw_writel(0xAAAA, base + OMAP_WDT_SPR);
991 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
992 cpu_relax();
993
994 __raw_writel(0x5555, base + OMAP_WDT_SPR);
995 while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
996 cpu_relax();
997
998 ret = omap_hwmod_idle(oh);
999 if (ret)
1000 pr_err("%s: Could not disable clocks for %s\n",
1001 oh->name, __func__);
1002
1003 return ret;
1004}
1005
1006static void __init omap_disable_wdt(void)
1007{
1008 if (cpu_class_is_omap2())
1009 omap_hwmod_for_each_by_class("wd_timer",
1010 omap2_disable_wdt, NULL);
1011 return;
1012}
1013
844static int __init omap2_init_devices(void) 1014static int __init omap2_init_devices(void)
845{ 1015{
846 /* please keep these calls, and their implementations above, 1016 /* please keep these calls, and their implementations above,
847 * in alphabetical order so they're easier to sort through. 1017 * in alphabetical order so they're easier to sort through.
848 */ 1018 */
1019 omap_disable_wdt();
849 omap_hsmmc_reset(); 1020 omap_hsmmc_reset();
1021 omap_init_audio();
850 omap_init_camera(); 1022 omap_init_camera();
851 omap_init_mbox(); 1023 omap_init_mbox();
852 omap_init_mcspi(); 1024 omap_init_mcspi();
@@ -854,8 +1026,45 @@ static int __init omap2_init_devices(void)
854 omap_hdq_init(); 1026 omap_hdq_init();
855 omap_init_sti(); 1027 omap_init_sti();
856 omap_init_sham(); 1028 omap_init_sham();
1029 omap_init_aes();
857 omap_init_vout(); 1030 omap_init_vout();
858 1031
859 return 0; 1032 return 0;
860} 1033}
861arch_initcall(omap2_init_devices); 1034arch_initcall(omap2_init_devices);
1035
1036#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
1037struct omap_device_pm_latency omap_wdt_latency[] = {
1038 [0] = {
1039 .deactivate_func = omap_device_idle_hwmods,
1040 .activate_func = omap_device_enable_hwmods,
1041 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
1042 },
1043};
1044
1045static int __init omap_init_wdt(void)
1046{
1047 int id = -1;
1048 struct omap_device *od;
1049 struct omap_hwmod *oh;
1050 char *oh_name = "wd_timer2";
1051 char *dev_name = "omap_wdt";
1052
1053 if (!cpu_class_is_omap2())
1054 return 0;
1055
1056 oh = omap_hwmod_lookup(oh_name);
1057 if (!oh) {
1058 pr_err("Could not look up wd_timer%d hwmod\n", id);
1059 return -EINVAL;
1060 }
1061
1062 od = omap_device_build(dev_name, id, oh, NULL, 0,
1063 omap_wdt_latency,
1064 ARRAY_SIZE(omap_wdt_latency), 0);
1065 WARN(IS_ERR(od), "Cant build omap_device for %s:%s.\n",
1066 dev_name, oh->name);
1067 return 0;
1068}
1069subsys_initcall(omap_init_wdt);
1070#endif
diff --git a/arch/arm/mach-omap2/dsp.c b/arch/arm/mach-omap2/dsp.c
new file mode 100644
index 000000000000..6feeeae6c21b
--- /dev/null
+++ b/arch/arm/mach-omap2/dsp.c
@@ -0,0 +1,85 @@
1/*
2 * TI's OMAP DSP platform device registration
3 *
4 * Copyright (C) 2005-2006 Texas Instruments, Inc.
5 * Copyright (C) 2009 Nokia Corporation
6 *
7 * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.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 "prm.h"
16#include "cm.h"
17#ifdef CONFIG_BRIDGE_DVFS
18#include <plat/omap-pm.h>
19#endif
20
21#include <plat/dsp.h>
22
23extern phys_addr_t omap_dsp_get_mempool_base(void);
24
25static struct platform_device *omap_dsp_pdev;
26
27static struct omap_dsp_platform_data omap_dsp_pdata __initdata = {
28#ifdef CONFIG_BRIDGE_DVFS
29 .dsp_set_min_opp = omap_pm_dsp_set_min_opp,
30 .dsp_get_opp = omap_pm_dsp_get_opp,
31 .cpu_set_freq = omap_pm_cpu_set_freq,
32 .cpu_get_freq = omap_pm_cpu_get_freq,
33#endif
34 .dsp_prm_read = prm_read_mod_reg,
35 .dsp_prm_write = prm_write_mod_reg,
36 .dsp_prm_rmw_bits = prm_rmw_mod_reg_bits,
37 .dsp_cm_read = cm_read_mod_reg,
38 .dsp_cm_write = cm_write_mod_reg,
39 .dsp_cm_rmw_bits = cm_rmw_mod_reg_bits,
40};
41
42static int __init omap_dsp_init(void)
43{
44 struct platform_device *pdev;
45 int err = -ENOMEM;
46 struct omap_dsp_platform_data *pdata = &omap_dsp_pdata;
47
48 pdata->phys_mempool_base = omap_dsp_get_mempool_base();
49
50 if (pdata->phys_mempool_base) {
51 pdata->phys_mempool_size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
52 pr_info("%s: %x bytes @ %x\n", __func__,
53 pdata->phys_mempool_size, pdata->phys_mempool_base);
54 }
55
56 pdev = platform_device_alloc("omap-dsp", -1);
57 if (!pdev)
58 goto err_out;
59
60 err = platform_device_add_data(pdev, pdata, sizeof(*pdata));
61 if (err)
62 goto err_out;
63
64 err = platform_device_add(pdev);
65 if (err)
66 goto err_out;
67
68 omap_dsp_pdev = pdev;
69 return 0;
70
71err_out:
72 platform_device_put(pdev);
73 return err;
74}
75module_init(omap_dsp_init);
76
77static void __exit omap_dsp_exit(void)
78{
79 platform_device_unregister(omap_dsp_pdev);
80}
81module_exit(omap_dsp_exit);
82
83MODULE_AUTHOR("Hiroshi DOYU");
84MODULE_DESCRIPTION("TI's OMAP DSP platform device registration");
85MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c
new file mode 100644
index 000000000000..703f150dd01d
--- /dev/null
+++ b/arch/arm/mach-omap2/gpmc-smsc911x.c
@@ -0,0 +1,113 @@
1/*
2 * linux/arch/arm/mach-omap2/gpmc-smsc911x.c
3 *
4 * Copyright (C) 2009 Li-Pro.Net
5 * Stephan Linz <linz@li-pro.net>
6 *
7 * Modified from linux/arch/arm/mach-omap2/gpmc-smc91x.c
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/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/gpio.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/io.h>
20#include <linux/smsc911x.h>
21
22#include <plat/board.h>
23#include <plat/gpmc.h>
24#include <plat/gpmc-smsc911x.h>
25
26static struct omap_smsc911x_platform_data *gpmc_cfg;
27
28static struct resource gpmc_smsc911x_resources[] = {
29 [0] = {
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .flags = IORESOURCE_IRQ,
34 },
35};
36
37static struct smsc911x_platform_config gpmc_smsc911x_config = {
38 .phy_interface = PHY_INTERFACE_MODE_MII,
39 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
40 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
41 .flags = SMSC911X_USE_16BIT,
42};
43
44static struct platform_device gpmc_smsc911x_device = {
45 .name = "smsc911x",
46 .id = -1,
47 .num_resources = ARRAY_SIZE(gpmc_smsc911x_resources),
48 .resource = gpmc_smsc911x_resources,
49 .dev = {
50 .platform_data = &gpmc_smsc911x_config,
51 },
52};
53
54/*
55 * Initialize smsc911x device connected to the GPMC. Note that we
56 * assume that pin multiplexing is done in the board-*.c file,
57 * or in the bootloader.
58 */
59void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
60{
61 unsigned long cs_mem_base;
62 int ret;
63
64 gpmc_cfg = board_data;
65
66 if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
67 printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
68 return;
69 }
70
71 gpmc_smsc911x_resources[0].start = cs_mem_base + 0x0;
72 gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
73
74 if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) {
75 printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
76 gpmc_cfg->gpio_irq);
77 goto free1;
78 }
79
80 gpio_direction_input(gpmc_cfg->gpio_irq);
81 gpmc_smsc911x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq);
82 gpmc_smsc911x_resources[1].flags |=
83 (gpmc_cfg->flags & IRQF_TRIGGER_MASK);
84
85 if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
86 ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset");
87 if (ret) {
88 printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n",
89 gpmc_cfg->gpio_reset);
90 goto free2;
91 }
92
93 gpio_direction_output(gpmc_cfg->gpio_reset, 1);
94 gpio_set_value(gpmc_cfg->gpio_reset, 0);
95 msleep(100);
96 gpio_set_value(gpmc_cfg->gpio_reset, 1);
97 }
98
99 if (platform_device_register(&gpmc_smsc911x_device) < 0) {
100 printk(KERN_ERR "Unable to register smsc911x device\n");
101 gpio_free(gpmc_cfg->gpio_reset);
102 goto free2;
103 }
104
105 return;
106
107free2:
108 gpio_free(gpmc_cfg->gpio_irq);
109free1:
110 gpmc_cs_free(gpmc_cfg->cs);
111
112 printk(KERN_ERR "Could not initialize smsc911x\n");
113}
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index c8f647b6205e..34272e4863fd 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -14,11 +14,11 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <plat/control.h>
18#include <plat/mmc.h> 17#include <plat/mmc.h>
19#include <plat/omap-pm.h> 18#include <plat/omap-pm.h>
20 19
21#include "hsmmc.h" 20#include "hsmmc.h"
21#include "control.h"
22 22
23#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) 23#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
24 24
@@ -135,10 +135,11 @@ static void omap4_hsmmc1_before_set_reg(struct device *dev, int slot,
135 * 135 *
136 * FIXME handle VMMC1A as needed ... 136 * FIXME handle VMMC1A as needed ...
137 */ 137 */
138 reg = omap_ctrl_readl(control_pbias_offset); 138 reg = omap4_ctrl_pad_readl(control_pbias_offset);
139 reg &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ | OMAP4_MMC1_PWRDNZ | 139 reg &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
140 OMAP4_USBC1_ICUSB_PWRDNZ); 140 OMAP4_MMC1_PWRDNZ_MASK |
141 omap_ctrl_writel(reg, control_pbias_offset); 141 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
142 omap4_ctrl_pad_writel(reg, control_pbias_offset);
142} 143}
143 144
144static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot, 145static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot,
@@ -147,30 +148,33 @@ static void omap4_hsmmc1_after_set_reg(struct device *dev, int slot,
147 u32 reg; 148 u32 reg;
148 149
149 if (power_on) { 150 if (power_on) {
150 reg = omap_ctrl_readl(control_pbias_offset); 151 reg = omap4_ctrl_pad_readl(control_pbias_offset);
151 reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ; 152 reg |= OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK;
152 if ((1 << vdd) <= MMC_VDD_165_195) 153 if ((1 << vdd) <= MMC_VDD_165_195)
153 reg &= ~OMAP4_MMC1_PBIASLITE_VMODE; 154 reg &= ~OMAP4_MMC1_PBIASLITE_VMODE_MASK;
154 else 155 else
155 reg |= OMAP4_MMC1_PBIASLITE_VMODE; 156 reg |= OMAP4_MMC1_PBIASLITE_VMODE_MASK;
156 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ | OMAP4_MMC1_PWRDNZ | 157 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
157 OMAP4_USBC1_ICUSB_PWRDNZ); 158 OMAP4_MMC1_PWRDNZ_MASK |
158 omap_ctrl_writel(reg, control_pbias_offset); 159 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
160 omap4_ctrl_pad_writel(reg, control_pbias_offset);
159 /* 4 microsec delay for comparator to generate an error*/ 161 /* 4 microsec delay for comparator to generate an error*/
160 udelay(4); 162 udelay(4);
161 reg = omap_ctrl_readl(control_pbias_offset); 163 reg = omap4_ctrl_pad_readl(control_pbias_offset);
162 if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR) { 164 if (reg & OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK) {
163 pr_err("Pbias Voltage is not same as LDO\n"); 165 pr_err("Pbias Voltage is not same as LDO\n");
164 /* Caution : On VMODE_ERROR Power Down MMC IO */ 166 /* Caution : On VMODE_ERROR Power Down MMC IO */
165 reg &= ~(OMAP4_MMC1_PWRDNZ | OMAP4_USBC1_ICUSB_PWRDNZ); 167 reg &= ~(OMAP4_MMC1_PWRDNZ_MASK |
166 omap_ctrl_writel(reg, control_pbias_offset); 168 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
169 omap4_ctrl_pad_writel(reg, control_pbias_offset);
167 } 170 }
168 } else { 171 } else {
169 reg = omap_ctrl_readl(control_pbias_offset); 172 reg = omap4_ctrl_pad_readl(control_pbias_offset);
170 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ | 173 reg |= (OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK |
171 OMAP4_MMC1_PBIASLITE_VMODE | OMAP4_MMC1_PWRDNZ | 174 OMAP4_MMC1_PWRDNZ_MASK |
172 OMAP4_USBC1_ICUSB_PWRDNZ); 175 OMAP4_MMC1_PBIASLITE_VMODE_MASK |
173 omap_ctrl_writel(reg, control_pbias_offset); 176 OMAP4_USBC1_ICUSB_PWRDNZ_MASK);
177 omap4_ctrl_pad_writel(reg, control_pbias_offset);
174 } 178 }
175} 179}
176 180
@@ -218,17 +222,18 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
218 control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1; 222 control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1;
219 } 223 }
220 } else { 224 } else {
221 control_pbias_offset = OMAP44XX_CONTROL_PBIAS_LITE; 225 control_pbias_offset =
222 control_mmc1 = OMAP44XX_CONTROL_MMC1; 226 OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PBIASLITE;
223 reg = omap_ctrl_readl(control_mmc1); 227 control_mmc1 = OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MMC1;
224 reg |= (OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP0 | 228 reg = omap4_ctrl_pad_readl(control_mmc1);
225 OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP1); 229 reg |= (OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK |
226 reg &= ~(OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP2 | 230 OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK);
227 OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP3); 231 reg &= ~(OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK |
228 reg |= (OMAP4_CONTROL_SDMMC1_DR0_SPEEDCTRL | 232 OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK);
229 OMAP4_CONTROL_SDMMC1_DR1_SPEEDCTRL | 233 reg |= (OMAP4_USBC1_DR0_SPEEDCTRL_MASK|
230 OMAP4_CONTROL_SDMMC1_DR2_SPEEDCTRL); 234 OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK |
231 omap_ctrl_writel(reg, control_mmc1); 235 OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK);
236 omap4_ctrl_pad_writel(reg, control_mmc1);
232 } 237 }
233 238
234 for (c = controllers; c->mmc; c++) { 239 for (c = controllers; c->mmc; c++) {
@@ -258,9 +263,13 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
258 "mmc%islot%i", c->mmc, 1); 263 "mmc%islot%i", c->mmc, 1);
259 mmc->slots[0].name = hc->name; 264 mmc->slots[0].name = hc->name;
260 mmc->nr_slots = 1; 265 mmc->nr_slots = 1;
261 mmc->slots[0].wires = c->wires; 266 mmc->slots[0].caps = c->caps;
262 mmc->slots[0].internal_clock = !c->ext_clock; 267 mmc->slots[0].internal_clock = !c->ext_clock;
263 mmc->dma_mask = 0xffffffff; 268 mmc->dma_mask = 0xffffffff;
269 if (cpu_is_omap44xx())
270 mmc->reg_offset = OMAP4_MMC_REG_OFFSET;
271 else
272 mmc->reg_offset = 0;
264 273
265 mmc->get_context_loss_count = hsmmc_get_context_loss; 274 mmc->get_context_loss_count = hsmmc_get_context_loss;
266 275
@@ -298,6 +307,9 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
298 else 307 else
299 mmc->slots[0].features |= HSMMC_HAS_PBIAS; 308 mmc->slots[0].features |= HSMMC_HAS_PBIAS;
300 309
310 if (cpu_is_omap44xx() && (omap_rev() > OMAP4430_REV_ES1_0))
311 mmc->slots[0].features |= HSMMC_HAS_UPDATED_RESET;
312
301 switch (c->mmc) { 313 switch (c->mmc) {
302 case 1: 314 case 1:
303 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) { 315 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
@@ -316,16 +328,20 @@ void __init omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
316 } 328 }
317 329
318 /* Omap3630 HSMMC1 supports only 4-bit */ 330 /* Omap3630 HSMMC1 supports only 4-bit */
319 if (cpu_is_omap3630() && c->wires > 4) { 331 if (cpu_is_omap3630() &&
320 c->wires = 4; 332 (c->caps & MMC_CAP_8_BIT_DATA)) {
321 mmc->slots[0].wires = c->wires; 333 c->caps &= ~MMC_CAP_8_BIT_DATA;
334 c->caps |= MMC_CAP_4_BIT_DATA;
335 mmc->slots[0].caps = c->caps;
322 } 336 }
323 break; 337 break;
324 case 2: 338 case 2:
325 if (c->ext_clock) 339 if (c->ext_clock)
326 c->transceiver = 1; 340 c->transceiver = 1;
327 if (c->transceiver && c->wires > 4) 341 if (c->transceiver && (c->caps & MMC_CAP_8_BIT_DATA)) {
328 c->wires = 4; 342 c->caps &= ~MMC_CAP_8_BIT_DATA;
343 c->caps |= MMC_CAP_4_BIT_DATA;
344 }
329 /* FALLTHROUGH */ 345 /* FALLTHROUGH */
330 case 3: 346 case 3:
331 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) { 347 if (mmc->slots[0].features & HSMMC_HAS_PBIAS) {
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index 1fe6f0187177..f119348827d4 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -10,7 +10,8 @@ struct mmc_card;
10 10
11struct omap2_hsmmc_info { 11struct omap2_hsmmc_info {
12 u8 mmc; /* controller 1/2/3 */ 12 u8 mmc; /* controller 1/2/3 */
13 u8 wires; /* 1/4/8 wires */ 13 u32 caps; /* 4/8 wires and any additional host
14 * capabilities OR'd (ref. linux/mmc/host.h) */
14 bool transceiver; /* MMC-2 option */ 15 bool transceiver; /* MMC-2 option */
15 bool ext_clock; /* use external pin for input clock */ 16 bool ext_clock; /* use external pin for input clock */
16 bool cover_only; /* No card detect - just cover switch */ 17 bool cover_only; /* No card detect - just cover switch */
@@ -23,7 +24,7 @@ struct omap2_hsmmc_info {
23 char *name; /* or NULL for default */ 24 char *name; /* or NULL for default */
24 struct device *dev; /* returned: pointer to mmc adapter */ 25 struct device *dev; /* returned: pointer to mmc adapter */
25 int ocr_mask; /* temporary HACK */ 26 int ocr_mask; /* temporary HACK */
26 /* Remux (pad configuation) when powering on/off */ 27 /* Remux (pad configuration) when powering on/off */
27 void (*remux)(struct device *dev, int slot, int power_on); 28 void (*remux)(struct device *dev, int slot, int power_on);
28 /* init some special card */ 29 /* init some special card */
29 void (*init_card)(struct mmc_card *card); 30 void (*init_card)(struct mmc_card *card);
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 9a879f959509..5f9086c65e48 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -22,11 +22,12 @@
22#include <asm/cputype.h> 22#include <asm/cputype.h>
23 23
24#include <plat/common.h> 24#include <plat/common.h>
25#include <plat/control.h>
26#include <plat/cpu.h> 25#include <plat/cpu.h>
27 26
28#include <mach/id.h> 27#include <mach/id.h>
29 28
29#include "control.h"
30
30static struct omap_chip_id omap_chip; 31static struct omap_chip_id omap_chip;
31static unsigned int omap_revision; 32static unsigned int omap_revision;
32 33
@@ -60,7 +61,7 @@ int omap_type(void)
60 } else if (cpu_is_omap34xx()) { 61 } else if (cpu_is_omap34xx()) {
61 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS); 62 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
62 } else if (cpu_is_omap44xx()) { 63 } else if (cpu_is_omap44xx()) {
63 val = omap_ctrl_readl(OMAP44XX_CONTROL_STATUS); 64 val = omap_ctrl_readl(OMAP4_CTRL_MODULE_CORE_STATUS);
64 } else { 65 } else {
65 pr_err("Cannot detect omap type!\n"); 66 pr_err("Cannot detect omap type!\n");
66 goto out; 67 goto out;
@@ -298,7 +299,6 @@ static void __init omap4_check_revision(void)
298 u32 idcode; 299 u32 idcode;
299 u16 hawkeye; 300 u16 hawkeye;
300 u8 rev; 301 u8 rev;
301 char *rev_name = "ES1.0";
302 302
303 /* 303 /*
304 * The IC rev detection is done with hawkeye and rev. 304 * The IC rev detection is done with hawkeye and rev.
@@ -309,14 +309,39 @@ static void __init omap4_check_revision(void)
309 hawkeye = (idcode >> 12) & 0xffff; 309 hawkeye = (idcode >> 12) & 0xffff;
310 rev = (idcode >> 28) & 0xff; 310 rev = (idcode >> 28) & 0xff;
311 311
312 if ((hawkeye == 0xb852) && (rev == 0x0)) { 312 /*
313 omap_revision = OMAP4430_REV_ES1_0; 313 * Few initial ES2.0 samples IDCODE is same as ES1.0
314 omap_chip.oc |= CHIP_IS_OMAP4430ES1; 314 * Use ARM register to detect the correct ES version
315 pr_info("OMAP%04x %s\n", omap_rev() >> 16, rev_name); 315 */
316 return; 316 if (!rev) {
317 idcode = read_cpuid(CPUID_ID);
318 rev = (idcode & 0xf) - 1;
319 }
320
321 switch (hawkeye) {
322 case 0xb852:
323 switch (rev) {
324 case 0:
325 omap_revision = OMAP4430_REV_ES1_0;
326 omap_chip.oc |= CHIP_IS_OMAP4430ES1;
327 break;
328 case 1:
329 omap_revision = OMAP4430_REV_ES2_0;
330 omap_chip.oc |= CHIP_IS_OMAP4430ES2;
331 break;
332 default:
333 omap_revision = OMAP4430_REV_ES2_0;
334 omap_chip.oc |= CHIP_IS_OMAP4430ES2;
335 }
336 break;
337 default:
338 /* Unknown default to latest silicon rev as default*/
339 omap_revision = OMAP4430_REV_ES2_0;
340 omap_chip.oc |= CHIP_IS_OMAP4430ES2;
317 } 341 }
318 342
319 pr_err("Unknown OMAP4 CPU id\n"); 343 pr_info("OMAP%04x ES%d.0\n",
344 omap_rev() >> 16, ((omap_rev() >> 12) & 0xf) + 1);
320} 345}
321 346
322#define OMAP3_SHOW_FEATURE(feat) \ 347#define OMAP3_SHOW_FEATURE(feat) \
@@ -361,30 +386,54 @@ static void __init omap3_cpuinfo(void)
361 strcpy(cpu_name, "OMAP3503"); 386 strcpy(cpu_name, "OMAP3503");
362 } 387 }
363 388
364 switch (rev) { 389 if (cpu_is_omap3630()) {
365 case OMAP_REVBITS_00: 390 switch (rev) {
366 strcpy(cpu_rev, "1.0"); 391 case OMAP_REVBITS_00:
367 break; 392 strcpy(cpu_rev, "1.0");
368 case OMAP_REVBITS_01: 393 break;
369 strcpy(cpu_rev, "1.1"); 394 case OMAP_REVBITS_01:
370 break; 395 strcpy(cpu_rev, "1.1");
371 case OMAP_REVBITS_02: 396 break;
372 strcpy(cpu_rev, "1.2"); 397 case OMAP_REVBITS_02:
373 break; 398 /* FALLTHROUGH */
374 case OMAP_REVBITS_10: 399 default:
375 strcpy(cpu_rev, "2.0"); 400 /* Use the latest known revision as default */
376 break; 401 strcpy(cpu_rev, "1.2");
377 case OMAP_REVBITS_20: 402 }
378 strcpy(cpu_rev, "2.1"); 403 } else if (cpu_is_omap3505() || cpu_is_omap3517()) {
379 break; 404 switch (rev) {
380 case OMAP_REVBITS_30: 405 case OMAP_REVBITS_00:
381 strcpy(cpu_rev, "3.0"); 406 strcpy(cpu_rev, "1.0");
382 break; 407 break;
383 case OMAP_REVBITS_40: 408 case OMAP_REVBITS_01:
384 /* FALLTHROUGH */ 409 /* FALLTHROUGH */
385 default: 410 default:
386 /* Use the latest known revision as default */ 411 /* Use the latest known revision as default */
387 strcpy(cpu_rev, "3.1"); 412 strcpy(cpu_rev, "1.1");
413 }
414 } else {
415 switch (rev) {
416 case OMAP_REVBITS_00:
417 strcpy(cpu_rev, "1.0");
418 break;
419 case OMAP_REVBITS_01:
420 strcpy(cpu_rev, "2.0");
421 break;
422 case OMAP_REVBITS_02:
423 strcpy(cpu_rev, "2.1");
424 break;
425 case OMAP_REVBITS_03:
426 strcpy(cpu_rev, "3.0");
427 break;
428 case OMAP_REVBITS_04:
429 strcpy(cpu_rev, "3.1");
430 break;
431 case OMAP_REVBITS_05:
432 /* FALLTHROUGH */
433 default:
434 /* Use the latest known revision as default */
435 strcpy(cpu_rev, "3.1.2");
436 }
388 } 437 }
389 438
390 /* Print verbose information */ 439 /* Print verbose information */
diff --git a/arch/arm/mach-omap2/include/mach/board-rx51.h b/arch/arm/mach-omap2/include/mach/board-rx51.h
new file mode 100644
index 000000000000..b76f49e7eed5
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/board-rx51.h
@@ -0,0 +1,11 @@
1/*
2 * Defines for rx51 boards
3 */
4
5#ifndef _OMAP_BOARD_RX51_H
6#define _OMAP_BOARD_RX51_H
7
8extern void __init rx51_peripherals_init(void);
9extern void __init rx51_video_mem_init(void);
10
11#endif
diff --git a/arch/arm/mach-omap2/include/mach/board-zoom.h b/arch/arm/mach-omap2/include/mach/board-zoom.h
index 3af69d2c3dcd..f93ca3928c3b 100644
--- a/arch/arm/mach-omap2/include/mach/board-zoom.h
+++ b/arch/arm/mach-omap2/include/mach/board-zoom.h
@@ -1,11 +1,9 @@
1/* 1/*
2 * Defines for zoom boards 2 * Defines for zoom boards
3 */ 3 */
4#include <linux/mtd/mtd.h>
5#include <linux/mtd/partitions.h>
6
7#define ZOOM_NAND_CS 0 4#define ZOOM_NAND_CS 0
8 5
9extern void __init board_nand_init(struct mtd_partition *, u8 nr_parts, u8 cs);
10extern int __init zoom_debugboard_init(void); 6extern int __init zoom_debugboard_init(void);
11extern void __init zoom_peripherals_init(void); 7extern void __init zoom_peripherals_init(void);
8
9#define ZOOM2_HEADSET_EXTMUTE_GPIO 153
diff --git a/arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h b/arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h
new file mode 100644
index 000000000000..2f7ac70a20d8
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/ctrl_module_core_44xx.h
@@ -0,0 +1,391 @@
1/*
2 * OMAP44xx CTRL_MODULE_CORE registers and bitfields
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 *
6 * Benoit Cousson (b-cousson@ti.com)
7 * Santosh Shilimkar (santosh.shilimkar@ti.com)
8 *
9 * This file is automatically generated from the OMAP hardware databases.
10 * We respectfully ask that any modifications to this file be coordinated
11 * with the public linux-omap@vger.kernel.org mailing list and the
12 * authors above to ensure that the autogeneration scripts are kept
13 * up-to-date with the file contents.
14 *
15 * 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
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_CORE_44XX_H
21#define __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_CORE_44XX_H
22
23
24/* Base address */
25#define OMAP4_CTRL_MODULE_CORE 0x4a002000
26
27/* Registers offset */
28#define OMAP4_CTRL_MODULE_CORE_IP_REVISION 0x0000
29#define OMAP4_CTRL_MODULE_CORE_IP_HWINFO 0x0004
30#define OMAP4_CTRL_MODULE_CORE_IP_SYSCONFIG 0x0010
31#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_DIE_ID_0 0x0200
32#define OMAP4_CTRL_MODULE_CORE_ID_CODE 0x0204
33#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_DIE_ID_1 0x0208
34#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_DIE_ID_2 0x020c
35#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_DIE_ID_3 0x0210
36#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_0 0x0214
37#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_PROD_ID_1 0x0218
38#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_USB_CONF 0x021c
39#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_VDD_WKUP 0x0228
40#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_BGAP 0x0260
41#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_DPLL_0 0x0264
42#define OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_DPLL_1 0x0268
43#define OMAP4_CTRL_MODULE_CORE_STATUS 0x02c4
44#define OMAP4_CTRL_MODULE_CORE_DEV_CONF 0x0300
45#define OMAP4_CTRL_MODULE_CORE_LDOVBB_IVA_VOLTAGE_CTRL 0x0314
46#define OMAP4_CTRL_MODULE_CORE_LDOVBB_MPU_VOLTAGE_CTRL 0x0318
47#define OMAP4_CTRL_MODULE_CORE_LDOSRAM_IVA_VOLTAGE_CTRL 0x0320
48#define OMAP4_CTRL_MODULE_CORE_LDOSRAM_MPU_VOLTAGE_CTRL 0x0324
49#define OMAP4_CTRL_MODULE_CORE_LDOSRAM_CORE_VOLTAGE_CTRL 0x0328
50#define OMAP4_CTRL_MODULE_CORE_TEMP_SENSOR 0x032c
51#define OMAP4_CTRL_MODULE_CORE_DPLL_NWELL_TRIM_0 0x0330
52#define OMAP4_CTRL_MODULE_CORE_DPLL_NWELL_TRIM_1 0x0334
53#define OMAP4_CTRL_MODULE_CORE_USBOTGHS_CONTROL 0x033c
54#define OMAP4_CTRL_MODULE_CORE_DSS_CONTROL 0x0340
55#define OMAP4_CTRL_MODULE_CORE_HWOBS_CONTROL 0x0350
56#define OMAP4_CTRL_MODULE_CORE_DEBOBS_FINAL_MUX_SEL 0x0400
57#define OMAP4_CTRL_MODULE_CORE_DEBOBS_MMR_MPU 0x0408
58#define OMAP4_CTRL_MODULE_CORE_CONF_SDMA_REQ_SEL0 0x042c
59#define OMAP4_CTRL_MODULE_CORE_CONF_SDMA_REQ_SEL1 0x0430
60#define OMAP4_CTRL_MODULE_CORE_CONF_SDMA_REQ_SEL2 0x0434
61#define OMAP4_CTRL_MODULE_CORE_CONF_SDMA_REQ_SEL3 0x0438
62#define OMAP4_CTRL_MODULE_CORE_CONF_CLK_SEL0 0x0440
63#define OMAP4_CTRL_MODULE_CORE_CONF_CLK_SEL1 0x0444
64#define OMAP4_CTRL_MODULE_CORE_CONF_CLK_SEL2 0x0448
65#define OMAP4_CTRL_MODULE_CORE_CONF_DPLL_FREQLOCK_SEL 0x044c
66#define OMAP4_CTRL_MODULE_CORE_CONF_DPLL_TINITZ_SEL 0x0450
67#define OMAP4_CTRL_MODULE_CORE_CONF_DPLL_PHASELOCK_SEL 0x0454
68#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_0 0x0480
69#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_1 0x0484
70#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_2 0x0488
71#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_3 0x048c
72#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_4 0x0490
73#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_5 0x0494
74#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_6 0x0498
75#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_7 0x049c
76#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_8 0x04a0
77#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_9 0x04a4
78#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_10 0x04a8
79#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_11 0x04ac
80#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_12 0x04b0
81#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_13 0x04b4
82#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_14 0x04b8
83#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_15 0x04bc
84#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_16 0x04c0
85#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_17 0x04c4
86#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_18 0x04c8
87#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_19 0x04cc
88#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_20 0x04d0
89#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_21 0x04d4
90#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_22 0x04d8
91#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_23 0x04dc
92#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_24 0x04e0
93#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_25 0x04e4
94#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_26 0x04e8
95#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_27 0x04ec
96#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_28 0x04f0
97#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_29 0x04f4
98#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_30 0x04f8
99#define OMAP4_CTRL_MODULE_CORE_CONF_DEBUG_SEL_TST_31 0x04fc
100
101/* Registers shifts and masks */
102
103/* IP_REVISION */
104#define OMAP4_IP_REV_SCHEME_SHIFT 30
105#define OMAP4_IP_REV_SCHEME_MASK (0x3 << 30)
106#define OMAP4_IP_REV_FUNC_SHIFT 16
107#define OMAP4_IP_REV_FUNC_MASK (0xfff << 16)
108#define OMAP4_IP_REV_RTL_SHIFT 11
109#define OMAP4_IP_REV_RTL_MASK (0x1f << 11)
110#define OMAP4_IP_REV_MAJOR_SHIFT 8
111#define OMAP4_IP_REV_MAJOR_MASK (0x7 << 8)
112#define OMAP4_IP_REV_CUSTOM_SHIFT 6
113#define OMAP4_IP_REV_CUSTOM_MASK (0x3 << 6)
114#define OMAP4_IP_REV_MINOR_SHIFT 0
115#define OMAP4_IP_REV_MINOR_MASK (0x3f << 0)
116
117/* IP_HWINFO */
118#define OMAP4_IP_HWINFO_SHIFT 0
119#define OMAP4_IP_HWINFO_MASK (0xffffffff << 0)
120
121/* IP_SYSCONFIG */
122#define OMAP4_IP_SYSCONFIG_IDLEMODE_SHIFT 2
123#define OMAP4_IP_SYSCONFIG_IDLEMODE_MASK (0x3 << 2)
124
125/* STD_FUSE_DIE_ID_0 */
126#define OMAP4_STD_FUSE_DIE_ID_0_SHIFT 0
127#define OMAP4_STD_FUSE_DIE_ID_0_MASK (0xffffffff << 0)
128
129/* ID_CODE */
130#define OMAP4_STD_FUSE_IDCODE_SHIFT 0
131#define OMAP4_STD_FUSE_IDCODE_MASK (0xffffffff << 0)
132
133/* STD_FUSE_DIE_ID_1 */
134#define OMAP4_STD_FUSE_DIE_ID_1_SHIFT 0
135#define OMAP4_STD_FUSE_DIE_ID_1_MASK (0xffffffff << 0)
136
137/* STD_FUSE_DIE_ID_2 */
138#define OMAP4_STD_FUSE_DIE_ID_2_SHIFT 0
139#define OMAP4_STD_FUSE_DIE_ID_2_MASK (0xffffffff << 0)
140
141/* STD_FUSE_DIE_ID_3 */
142#define OMAP4_STD_FUSE_DIE_ID_3_SHIFT 0
143#define OMAP4_STD_FUSE_DIE_ID_3_MASK (0xffffffff << 0)
144
145/* STD_FUSE_PROD_ID_0 */
146#define OMAP4_STD_FUSE_PROD_ID_0_SHIFT 0
147#define OMAP4_STD_FUSE_PROD_ID_0_MASK (0xffffffff << 0)
148
149/* STD_FUSE_PROD_ID_1 */
150#define OMAP4_STD_FUSE_PROD_ID_1_SHIFT 0
151#define OMAP4_STD_FUSE_PROD_ID_1_MASK (0xffffffff << 0)
152
153/* STD_FUSE_USB_CONF */
154#define OMAP4_USB_PROD_ID_SHIFT 16
155#define OMAP4_USB_PROD_ID_MASK (0xffff << 16)
156#define OMAP4_USB_VENDOR_ID_SHIFT 0
157#define OMAP4_USB_VENDOR_ID_MASK (0xffff << 0)
158
159/* STD_FUSE_OPP_VDD_WKUP */
160#define OMAP4_STD_FUSE_OPP_VDD_WKUP_SHIFT 0
161#define OMAP4_STD_FUSE_OPP_VDD_WKUP_MASK (0xffffffff << 0)
162
163/* STD_FUSE_OPP_BGAP */
164#define OMAP4_STD_FUSE_OPP_BGAP_SHIFT 0
165#define OMAP4_STD_FUSE_OPP_BGAP_MASK (0xffffffff << 0)
166
167/* STD_FUSE_OPP_DPLL_0 */
168#define OMAP4_STD_FUSE_OPP_DPLL_0_SHIFT 0
169#define OMAP4_STD_FUSE_OPP_DPLL_0_MASK (0xffffffff << 0)
170
171/* STD_FUSE_OPP_DPLL_1 */
172#define OMAP4_STD_FUSE_OPP_DPLL_1_SHIFT 0
173#define OMAP4_STD_FUSE_OPP_DPLL_1_MASK (0xffffffff << 0)
174
175/* STATUS */
176#define OMAP4_ATTILA_CONF_SHIFT 11
177#define OMAP4_ATTILA_CONF_MASK (0x3 << 11)
178#define OMAP4_DEVICE_TYPE_SHIFT 8
179#define OMAP4_DEVICE_TYPE_MASK (0x7 << 8)
180#define OMAP4_SYS_BOOT_SHIFT 0
181#define OMAP4_SYS_BOOT_MASK (0xff << 0)
182
183/* DEV_CONF */
184#define OMAP4_DEV_CONF_SHIFT 1
185#define OMAP4_DEV_CONF_MASK (0x7fffffff << 1)
186#define OMAP4_USBPHY_PD_SHIFT 0
187#define OMAP4_USBPHY_PD_MASK (1 << 0)
188
189/* LDOVBB_IVA_VOLTAGE_CTRL */
190#define OMAP4_LDOVBBIVA_RBB_MUX_CTRL_SHIFT 26
191#define OMAP4_LDOVBBIVA_RBB_MUX_CTRL_MASK (1 << 26)
192#define OMAP4_LDOVBBIVA_RBB_VSET_IN_SHIFT 21
193#define OMAP4_LDOVBBIVA_RBB_VSET_IN_MASK (0x1f << 21)
194#define OMAP4_LDOVBBIVA_RBB_VSET_OUT_SHIFT 16
195#define OMAP4_LDOVBBIVA_RBB_VSET_OUT_MASK (0x1f << 16)
196#define OMAP4_LDOVBBIVA_FBB_MUX_CTRL_SHIFT 10
197#define OMAP4_LDOVBBIVA_FBB_MUX_CTRL_MASK (1 << 10)
198#define OMAP4_LDOVBBIVA_FBB_VSET_IN_SHIFT 5
199#define OMAP4_LDOVBBIVA_FBB_VSET_IN_MASK (0x1f << 5)
200#define OMAP4_LDOVBBIVA_FBB_VSET_OUT_SHIFT 0
201#define OMAP4_LDOVBBIVA_FBB_VSET_OUT_MASK (0x1f << 0)
202
203/* LDOVBB_MPU_VOLTAGE_CTRL */
204#define OMAP4_LDOVBBMPU_RBB_MUX_CTRL_SHIFT 26
205#define OMAP4_LDOVBBMPU_RBB_MUX_CTRL_MASK (1 << 26)
206#define OMAP4_LDOVBBMPU_RBB_VSET_IN_SHIFT 21
207#define OMAP4_LDOVBBMPU_RBB_VSET_IN_MASK (0x1f << 21)
208#define OMAP4_LDOVBBMPU_RBB_VSET_OUT_SHIFT 16
209#define OMAP4_LDOVBBMPU_RBB_VSET_OUT_MASK (0x1f << 16)
210#define OMAP4_LDOVBBMPU_FBB_MUX_CTRL_SHIFT 10
211#define OMAP4_LDOVBBMPU_FBB_MUX_CTRL_MASK (1 << 10)
212#define OMAP4_LDOVBBMPU_FBB_VSET_IN_SHIFT 5
213#define OMAP4_LDOVBBMPU_FBB_VSET_IN_MASK (0x1f << 5)
214#define OMAP4_LDOVBBMPU_FBB_VSET_OUT_SHIFT 0
215#define OMAP4_LDOVBBMPU_FBB_VSET_OUT_MASK (0x1f << 0)
216
217/* LDOSRAM_IVA_VOLTAGE_CTRL */
218#define OMAP4_LDOSRAMIVA_RETMODE_MUX_CTRL_SHIFT 26
219#define OMAP4_LDOSRAMIVA_RETMODE_MUX_CTRL_MASK (1 << 26)
220#define OMAP4_LDOSRAMIVA_RETMODE_VSET_IN_SHIFT 21
221#define OMAP4_LDOSRAMIVA_RETMODE_VSET_IN_MASK (0x1f << 21)
222#define OMAP4_LDOSRAMIVA_RETMODE_VSET_OUT_SHIFT 16
223#define OMAP4_LDOSRAMIVA_RETMODE_VSET_OUT_MASK (0x1f << 16)
224#define OMAP4_LDOSRAMIVA_ACTMODE_MUX_CTRL_SHIFT 10
225#define OMAP4_LDOSRAMIVA_ACTMODE_MUX_CTRL_MASK (1 << 10)
226#define OMAP4_LDOSRAMIVA_ACTMODE_VSET_IN_SHIFT 5
227#define OMAP4_LDOSRAMIVA_ACTMODE_VSET_IN_MASK (0x1f << 5)
228#define OMAP4_LDOSRAMIVA_ACTMODE_VSET_OUT_SHIFT 0
229#define OMAP4_LDOSRAMIVA_ACTMODE_VSET_OUT_MASK (0x1f << 0)
230
231/* LDOSRAM_MPU_VOLTAGE_CTRL */
232#define OMAP4_LDOSRAMMPU_RETMODE_MUX_CTRL_SHIFT 26
233#define OMAP4_LDOSRAMMPU_RETMODE_MUX_CTRL_MASK (1 << 26)
234#define OMAP4_LDOSRAMMPU_RETMODE_VSET_IN_SHIFT 21
235#define OMAP4_LDOSRAMMPU_RETMODE_VSET_IN_MASK (0x1f << 21)
236#define OMAP4_LDOSRAMMPU_RETMODE_VSET_OUT_SHIFT 16
237#define OMAP4_LDOSRAMMPU_RETMODE_VSET_OUT_MASK (0x1f << 16)
238#define OMAP4_LDOSRAMMPU_ACTMODE_MUX_CTRL_SHIFT 10
239#define OMAP4_LDOSRAMMPU_ACTMODE_MUX_CTRL_MASK (1 << 10)
240#define OMAP4_LDOSRAMMPU_ACTMODE_VSET_IN_SHIFT 5
241#define OMAP4_LDOSRAMMPU_ACTMODE_VSET_IN_MASK (0x1f << 5)
242#define OMAP4_LDOSRAMMPU_ACTMODE_VSET_OUT_SHIFT 0
243#define OMAP4_LDOSRAMMPU_ACTMODE_VSET_OUT_MASK (0x1f << 0)
244
245/* LDOSRAM_CORE_VOLTAGE_CTRL */
246#define OMAP4_LDOSRAMCORE_RETMODE_MUX_CTRL_SHIFT 26
247#define OMAP4_LDOSRAMCORE_RETMODE_MUX_CTRL_MASK (1 << 26)
248#define OMAP4_LDOSRAMCORE_RETMODE_VSET_IN_SHIFT 21
249#define OMAP4_LDOSRAMCORE_RETMODE_VSET_IN_MASK (0x1f << 21)
250#define OMAP4_LDOSRAMCORE_RETMODE_VSET_OUT_SHIFT 16
251#define OMAP4_LDOSRAMCORE_RETMODE_VSET_OUT_MASK (0x1f << 16)
252#define OMAP4_LDOSRAMCORE_ACTMODE_MUX_CTRL_SHIFT 10
253#define OMAP4_LDOSRAMCORE_ACTMODE_MUX_CTRL_MASK (1 << 10)
254#define OMAP4_LDOSRAMCORE_ACTMODE_VSET_IN_SHIFT 5
255#define OMAP4_LDOSRAMCORE_ACTMODE_VSET_IN_MASK (0x1f << 5)
256#define OMAP4_LDOSRAMCORE_ACTMODE_VSET_OUT_SHIFT 0
257#define OMAP4_LDOSRAMCORE_ACTMODE_VSET_OUT_MASK (0x1f << 0)
258
259/* TEMP_SENSOR */
260#define OMAP4_BGAP_TEMPSOFF_SHIFT 12
261#define OMAP4_BGAP_TEMPSOFF_MASK (1 << 12)
262#define OMAP4_BGAP_TSHUT_SHIFT 11
263#define OMAP4_BGAP_TSHUT_MASK (1 << 11)
264#define OMAP4_BGAP_TEMP_SENSOR_CONTCONV_SHIFT 10
265#define OMAP4_BGAP_TEMP_SENSOR_CONTCONV_MASK (1 << 10)
266#define OMAP4_BGAP_TEMP_SENSOR_SOC_SHIFT 9
267#define OMAP4_BGAP_TEMP_SENSOR_SOC_MASK (1 << 9)
268#define OMAP4_BGAP_TEMP_SENSOR_EOCZ_SHIFT 8
269#define OMAP4_BGAP_TEMP_SENSOR_EOCZ_MASK (1 << 8)
270#define OMAP4_BGAP_TEMP_SENSOR_DTEMP_SHIFT 0
271#define OMAP4_BGAP_TEMP_SENSOR_DTEMP_MASK (0xff << 0)
272
273/* DPLL_NWELL_TRIM_0 */
274#define OMAP4_DPLL_ABE_NWELL_TRIM_MUX_CTRL_SHIFT 29
275#define OMAP4_DPLL_ABE_NWELL_TRIM_MUX_CTRL_MASK (1 << 29)
276#define OMAP4_DPLL_ABE_NWELL_TRIM_SHIFT 24
277#define OMAP4_DPLL_ABE_NWELL_TRIM_MASK (0x1f << 24)
278#define OMAP4_DPLL_PER_NWELL_TRIM_MUX_CTRL_SHIFT 23
279#define OMAP4_DPLL_PER_NWELL_TRIM_MUX_CTRL_MASK (1 << 23)
280#define OMAP4_DPLL_PER_NWELL_TRIM_SHIFT 18
281#define OMAP4_DPLL_PER_NWELL_TRIM_MASK (0x1f << 18)
282#define OMAP4_DPLL_CORE_NWELL_TRIM_MUX_CTRL_SHIFT 17
283#define OMAP4_DPLL_CORE_NWELL_TRIM_MUX_CTRL_MASK (1 << 17)
284#define OMAP4_DPLL_CORE_NWELL_TRIM_SHIFT 12
285#define OMAP4_DPLL_CORE_NWELL_TRIM_MASK (0x1f << 12)
286#define OMAP4_DPLL_IVA_NWELL_TRIM_MUX_CTRL_SHIFT 11
287#define OMAP4_DPLL_IVA_NWELL_TRIM_MUX_CTRL_MASK (1 << 11)
288#define OMAP4_DPLL_IVA_NWELL_TRIM_SHIFT 6
289#define OMAP4_DPLL_IVA_NWELL_TRIM_MASK (0x1f << 6)
290#define OMAP4_DPLL_MPU_NWELL_TRIM_MUX_CTRL_SHIFT 5
291#define OMAP4_DPLL_MPU_NWELL_TRIM_MUX_CTRL_MASK (1 << 5)
292#define OMAP4_DPLL_MPU_NWELL_TRIM_SHIFT 0
293#define OMAP4_DPLL_MPU_NWELL_TRIM_MASK (0x1f << 0)
294
295/* DPLL_NWELL_TRIM_1 */
296#define OMAP4_DPLL_UNIPRO_NWELL_TRIM_MUX_CTRL_SHIFT 29
297#define OMAP4_DPLL_UNIPRO_NWELL_TRIM_MUX_CTRL_MASK (1 << 29)
298#define OMAP4_DPLL_UNIPRO_NWELL_TRIM_SHIFT 24
299#define OMAP4_DPLL_UNIPRO_NWELL_TRIM_MASK (0x1f << 24)
300#define OMAP4_DPLL_USB_NWELL_TRIM_MUX_CTRL_SHIFT 23
301#define OMAP4_DPLL_USB_NWELL_TRIM_MUX_CTRL_MASK (1 << 23)
302#define OMAP4_DPLL_USB_NWELL_TRIM_SHIFT 18
303#define OMAP4_DPLL_USB_NWELL_TRIM_MASK (0x1f << 18)
304#define OMAP4_DPLL_HDMI_NWELL_TRIM_MUX_CTRL_SHIFT 17
305#define OMAP4_DPLL_HDMI_NWELL_TRIM_MUX_CTRL_MASK (1 << 17)
306#define OMAP4_DPLL_HDMI_NWELL_TRIM_SHIFT 12
307#define OMAP4_DPLL_HDMI_NWELL_TRIM_MASK (0x1f << 12)
308#define OMAP4_DPLL_DSI2_NWELL_TRIM_MUX_CTRL_SHIFT 11
309#define OMAP4_DPLL_DSI2_NWELL_TRIM_MUX_CTRL_MASK (1 << 11)
310#define OMAP4_DPLL_DSI2_NWELL_TRIM_SHIFT 6
311#define OMAP4_DPLL_DSI2_NWELL_TRIM_MASK (0x1f << 6)
312#define OMAP4_DPLL_DSI1_NWELL_TRIM_MUX_CTRL_SHIFT 5
313#define OMAP4_DPLL_DSI1_NWELL_TRIM_MUX_CTRL_MASK (1 << 5)
314#define OMAP4_DPLL_DSI1_NWELL_TRIM_SHIFT 0
315#define OMAP4_DPLL_DSI1_NWELL_TRIM_MASK (0x1f << 0)
316
317/* USBOTGHS_CONTROL */
318#define OMAP4_DISCHRGVBUS_SHIFT 8
319#define OMAP4_DISCHRGVBUS_MASK (1 << 8)
320#define OMAP4_CHRGVBUS_SHIFT 7
321#define OMAP4_CHRGVBUS_MASK (1 << 7)
322#define OMAP4_DRVVBUS_SHIFT 6
323#define OMAP4_DRVVBUS_MASK (1 << 6)
324#define OMAP4_IDPULLUP_SHIFT 5
325#define OMAP4_IDPULLUP_MASK (1 << 5)
326#define OMAP4_IDDIG_SHIFT 4
327#define OMAP4_IDDIG_MASK (1 << 4)
328#define OMAP4_SESSEND_SHIFT 3
329#define OMAP4_SESSEND_MASK (1 << 3)
330#define OMAP4_VBUSVALID_SHIFT 2
331#define OMAP4_VBUSVALID_MASK (1 << 2)
332#define OMAP4_BVALID_SHIFT 1
333#define OMAP4_BVALID_MASK (1 << 1)
334#define OMAP4_AVALID_SHIFT 0
335#define OMAP4_AVALID_MASK (1 << 0)
336
337/* DSS_CONTROL */
338#define OMAP4_DSS_MUX6_SELECT_SHIFT 0
339#define OMAP4_DSS_MUX6_SELECT_MASK (1 << 0)
340
341/* HWOBS_CONTROL */
342#define OMAP4_HWOBS_CLKDIV_SEL_SHIFT 3
343#define OMAP4_HWOBS_CLKDIV_SEL_MASK (0x1f << 3)
344#define OMAP4_HWOBS_ALL_ZERO_MODE_SHIFT 2
345#define OMAP4_HWOBS_ALL_ZERO_MODE_MASK (1 << 2)
346#define OMAP4_HWOBS_ALL_ONE_MODE_SHIFT 1
347#define OMAP4_HWOBS_ALL_ONE_MODE_MASK (1 << 1)
348#define OMAP4_HWOBS_MACRO_ENABLE_SHIFT 0
349#define OMAP4_HWOBS_MACRO_ENABLE_MASK (1 << 0)
350
351/* DEBOBS_FINAL_MUX_SEL */
352#define OMAP4_SELECT_SHIFT 0
353#define OMAP4_SELECT_MASK (0xffffffff << 0)
354
355/* DEBOBS_MMR_MPU */
356#define OMAP4_SELECT_DEBOBS_MMR_MPU_SHIFT 0
357#define OMAP4_SELECT_DEBOBS_MMR_MPU_MASK (0xf << 0)
358
359/* CONF_SDMA_REQ_SEL0 */
360#define OMAP4_MULT_SHIFT 0
361#define OMAP4_MULT_MASK (0x7f << 0)
362
363/* CONF_CLK_SEL0 */
364#define OMAP4_MULT_CONF_CLK_SEL0_SHIFT 0
365#define OMAP4_MULT_CONF_CLK_SEL0_MASK (0x7 << 0)
366
367/* CONF_CLK_SEL1 */
368#define OMAP4_MULT_CONF_CLK_SEL1_SHIFT 0
369#define OMAP4_MULT_CONF_CLK_SEL1_MASK (0x7 << 0)
370
371/* CONF_CLK_SEL2 */
372#define OMAP4_MULT_CONF_CLK_SEL2_SHIFT 0
373#define OMAP4_MULT_CONF_CLK_SEL2_MASK (0x7 << 0)
374
375/* CONF_DPLL_FREQLOCK_SEL */
376#define OMAP4_MULT_CONF_DPLL_FREQLOCK_SEL_SHIFT 0
377#define OMAP4_MULT_CONF_DPLL_FREQLOCK_SEL_MASK (0x7 << 0)
378
379/* CONF_DPLL_TINITZ_SEL */
380#define OMAP4_MULT_CONF_DPLL_TINITZ_SEL_SHIFT 0
381#define OMAP4_MULT_CONF_DPLL_TINITZ_SEL_MASK (0x7 << 0)
382
383/* CONF_DPLL_PHASELOCK_SEL */
384#define OMAP4_MULT_CONF_DPLL_PHASELOCK_SEL_SHIFT 0
385#define OMAP4_MULT_CONF_DPLL_PHASELOCK_SEL_MASK (0x7 << 0)
386
387/* CONF_DEBUG_SEL_TST_0 */
388#define OMAP4_MODE_SHIFT 0
389#define OMAP4_MODE_MASK (0xf << 0)
390
391#endif
diff --git a/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h
new file mode 100644
index 000000000000..c88420de1151
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_core_44xx.h
@@ -0,0 +1,1409 @@
1/*
2 * OMAP44xx CTRL_MODULE_PAD_CORE registers and bitfields
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 *
6 * Benoit Cousson (b-cousson@ti.com)
7 * Santosh Shilimkar (santosh.shilimkar@ti.com)
8 *
9 * This file is automatically generated from the OMAP hardware databases.
10 * We respectfully ask that any modifications to this file be coordinated
11 * with the public linux-omap@vger.kernel.org mailing list and the
12 * authors above to ensure that the autogeneration scripts are kept
13 * up-to-date with the file contents.
14 *
15 * 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
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_PAD_CORE_44XX_H
21#define __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_PAD_CORE_44XX_H
22
23
24/* Base address */
25#define OMAP4_CTRL_MODULE_PAD_CORE 0x4a100000
26
27/* Registers offset */
28#define OMAP4_CTRL_MODULE_PAD_CORE_IP_REVISION 0x0000
29#define OMAP4_CTRL_MODULE_PAD_CORE_IP_HWINFO 0x0004
30#define OMAP4_CTRL_MODULE_PAD_CORE_IP_SYSCONFIG 0x0010
31#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_0 0x01d8
32#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_1 0x01dc
33#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_2 0x01e0
34#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_3 0x01e4
35#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_4 0x01e8
36#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_5 0x01ec
37#define OMAP4_CTRL_MODULE_PAD_CORE_PADCONF_WAKEUPEVENT_6 0x01f0
38#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PADCONF_GLOBAL 0x05a0
39#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PADCONF_MODE 0x05a4
40#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART1IO_PADCONF_0 0x05a8
41#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART1IO_PADCONF_1 0x05ac
42#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART2IO_PADCONF_0 0x05b0
43#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART2IO_PADCONF_1 0x05b4
44#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART3IO_PADCONF_0 0x05b8
45#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART3IO_PADCONF_1 0x05bc
46#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SMART3IO_PADCONF_2 0x05c0
47#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_USBB_HSIC 0x05c4
48#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_SLIMBUS 0x05c8
49#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_PBIASLITE 0x0600
50#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_I2C_0 0x0604
51#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_CAMERA_RX 0x0608
52#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_AVDAC 0x060c
53#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_HDMI_TX_PHY 0x0610
54#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MMC2 0x0614
55#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY 0x0618
56#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MCBSPLP 0x061c
57#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_USB2PHYCORE 0x0620
58#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_I2C_1 0x0624
59#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_MMC1 0x0628
60#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_HSI 0x062c
61#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_USB 0x0630
62#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_HDQ 0x0634
63#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO1_0 0x0638
64#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO1_1 0x063c
65#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO1_2 0x0640
66#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO1_3 0x0644
67#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO2_0 0x0648
68#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO2_1 0x064c
69#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO2_2 0x0650
70#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_LPDDR2IO2_3 0x0654
71#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_BUS_HOLD 0x0658
72#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_C2C 0x065c
73#define OMAP4_CTRL_MODULE_PAD_CORE_CORE_CONTROL_SPARE_RW 0x0660
74#define OMAP4_CTRL_MODULE_PAD_CORE_CORE_CONTROL_SPARE_R 0x0664
75#define OMAP4_CTRL_MODULE_PAD_CORE_CORE_CONTROL_SPARE_R_C0 0x0668
76#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_EFUSE_1 0x0700
77#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_EFUSE_2 0x0704
78#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_EFUSE_3 0x0708
79#define OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_EFUSE_4 0x070c
80
81/* Registers shifts and masks */
82
83/* IP_REVISION */
84#define OMAP4_IP_REV_SCHEME_SHIFT 30
85#define OMAP4_IP_REV_SCHEME_MASK (0x3 << 30)
86#define OMAP4_IP_REV_FUNC_SHIFT 16
87#define OMAP4_IP_REV_FUNC_MASK (0xfff << 16)
88#define OMAP4_IP_REV_RTL_SHIFT 11
89#define OMAP4_IP_REV_RTL_MASK (0x1f << 11)
90#define OMAP4_IP_REV_MAJOR_SHIFT 8
91#define OMAP4_IP_REV_MAJOR_MASK (0x7 << 8)
92#define OMAP4_IP_REV_CUSTOM_SHIFT 6
93#define OMAP4_IP_REV_CUSTOM_MASK (0x3 << 6)
94#define OMAP4_IP_REV_MINOR_SHIFT 0
95#define OMAP4_IP_REV_MINOR_MASK (0x3f << 0)
96
97/* IP_HWINFO */
98#define OMAP4_IP_HWINFO_SHIFT 0
99#define OMAP4_IP_HWINFO_MASK (0xffffffff << 0)
100
101/* IP_SYSCONFIG */
102#define OMAP4_IP_SYSCONFIG_IDLEMODE_SHIFT 2
103#define OMAP4_IP_SYSCONFIG_IDLEMODE_MASK (0x3 << 2)
104
105/* PADCONF_WAKEUPEVENT_0 */
106#define OMAP4_GPMC_CLK_DUPLICATEWAKEUPEVENT_SHIFT 31
107#define OMAP4_GPMC_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
108#define OMAP4_GPMC_NWP_DUPLICATEWAKEUPEVENT_SHIFT 30
109#define OMAP4_GPMC_NWP_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
110#define OMAP4_GPMC_NCS3_DUPLICATEWAKEUPEVENT_SHIFT 29
111#define OMAP4_GPMC_NCS3_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
112#define OMAP4_GPMC_NCS2_DUPLICATEWAKEUPEVENT_SHIFT 28
113#define OMAP4_GPMC_NCS2_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
114#define OMAP4_GPMC_NCS1_DUPLICATEWAKEUPEVENT_SHIFT 27
115#define OMAP4_GPMC_NCS1_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
116#define OMAP4_GPMC_NCS0_DUPLICATEWAKEUPEVENT_SHIFT 26
117#define OMAP4_GPMC_NCS0_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
118#define OMAP4_GPMC_A25_DUPLICATEWAKEUPEVENT_SHIFT 25
119#define OMAP4_GPMC_A25_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
120#define OMAP4_GPMC_A24_DUPLICATEWAKEUPEVENT_SHIFT 24
121#define OMAP4_GPMC_A24_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
122#define OMAP4_GPMC_A23_DUPLICATEWAKEUPEVENT_SHIFT 23
123#define OMAP4_GPMC_A23_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
124#define OMAP4_GPMC_A22_DUPLICATEWAKEUPEVENT_SHIFT 22
125#define OMAP4_GPMC_A22_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
126#define OMAP4_GPMC_A21_DUPLICATEWAKEUPEVENT_SHIFT 21
127#define OMAP4_GPMC_A21_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
128#define OMAP4_GPMC_A20_DUPLICATEWAKEUPEVENT_SHIFT 20
129#define OMAP4_GPMC_A20_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
130#define OMAP4_GPMC_A19_DUPLICATEWAKEUPEVENT_SHIFT 19
131#define OMAP4_GPMC_A19_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
132#define OMAP4_GPMC_A18_DUPLICATEWAKEUPEVENT_SHIFT 18
133#define OMAP4_GPMC_A18_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
134#define OMAP4_GPMC_A17_DUPLICATEWAKEUPEVENT_SHIFT 17
135#define OMAP4_GPMC_A17_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
136#define OMAP4_GPMC_A16_DUPLICATEWAKEUPEVENT_SHIFT 16
137#define OMAP4_GPMC_A16_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
138#define OMAP4_GPMC_AD15_DUPLICATEWAKEUPEVENT_SHIFT 15
139#define OMAP4_GPMC_AD15_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
140#define OMAP4_GPMC_AD14_DUPLICATEWAKEUPEVENT_SHIFT 14
141#define OMAP4_GPMC_AD14_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
142#define OMAP4_GPMC_AD13_DUPLICATEWAKEUPEVENT_SHIFT 13
143#define OMAP4_GPMC_AD13_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
144#define OMAP4_GPMC_AD12_DUPLICATEWAKEUPEVENT_SHIFT 12
145#define OMAP4_GPMC_AD12_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
146#define OMAP4_GPMC_AD11_DUPLICATEWAKEUPEVENT_SHIFT 11
147#define OMAP4_GPMC_AD11_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
148#define OMAP4_GPMC_AD10_DUPLICATEWAKEUPEVENT_SHIFT 10
149#define OMAP4_GPMC_AD10_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
150#define OMAP4_GPMC_AD9_DUPLICATEWAKEUPEVENT_SHIFT 9
151#define OMAP4_GPMC_AD9_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
152#define OMAP4_GPMC_AD8_DUPLICATEWAKEUPEVENT_SHIFT 8
153#define OMAP4_GPMC_AD8_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
154#define OMAP4_GPMC_AD7_DUPLICATEWAKEUPEVENT_SHIFT 7
155#define OMAP4_GPMC_AD7_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
156#define OMAP4_GPMC_AD6_DUPLICATEWAKEUPEVENT_SHIFT 6
157#define OMAP4_GPMC_AD6_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
158#define OMAP4_GPMC_AD5_DUPLICATEWAKEUPEVENT_SHIFT 5
159#define OMAP4_GPMC_AD5_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
160#define OMAP4_GPMC_AD4_DUPLICATEWAKEUPEVENT_SHIFT 4
161#define OMAP4_GPMC_AD4_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
162#define OMAP4_GPMC_AD3_DUPLICATEWAKEUPEVENT_SHIFT 3
163#define OMAP4_GPMC_AD3_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
164#define OMAP4_GPMC_AD2_DUPLICATEWAKEUPEVENT_SHIFT 2
165#define OMAP4_GPMC_AD2_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
166#define OMAP4_GPMC_AD1_DUPLICATEWAKEUPEVENT_SHIFT 1
167#define OMAP4_GPMC_AD1_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
168#define OMAP4_GPMC_AD0_DUPLICATEWAKEUPEVENT_SHIFT 0
169#define OMAP4_GPMC_AD0_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
170
171/* PADCONF_WAKEUPEVENT_1 */
172#define OMAP4_CAM_STROBE_DUPLICATEWAKEUPEVENT_SHIFT 31
173#define OMAP4_CAM_STROBE_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
174#define OMAP4_CAM_SHUTTER_DUPLICATEWAKEUPEVENT_SHIFT 30
175#define OMAP4_CAM_SHUTTER_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
176#define OMAP4_CSI22_DY1_DUPLICATEWAKEUPEVENT_SHIFT 29
177#define OMAP4_CSI22_DY1_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
178#define OMAP4_CSI22_DX1_DUPLICATEWAKEUPEVENT_SHIFT 28
179#define OMAP4_CSI22_DX1_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
180#define OMAP4_CSI22_DY0_DUPLICATEWAKEUPEVENT_SHIFT 27
181#define OMAP4_CSI22_DY0_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
182#define OMAP4_CSI22_DX0_DUPLICATEWAKEUPEVENT_SHIFT 26
183#define OMAP4_CSI22_DX0_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
184#define OMAP4_CSI21_DY4_DUPLICATEWAKEUPEVENT_SHIFT 25
185#define OMAP4_CSI21_DY4_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
186#define OMAP4_CSI21_DX4_DUPLICATEWAKEUPEVENT_SHIFT 24
187#define OMAP4_CSI21_DX4_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
188#define OMAP4_CSI21_DY3_DUPLICATEWAKEUPEVENT_SHIFT 23
189#define OMAP4_CSI21_DY3_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
190#define OMAP4_CSI21_DX3_DUPLICATEWAKEUPEVENT_SHIFT 22
191#define OMAP4_CSI21_DX3_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
192#define OMAP4_CSI21_DY2_DUPLICATEWAKEUPEVENT_SHIFT 21
193#define OMAP4_CSI21_DY2_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
194#define OMAP4_CSI21_DX2_DUPLICATEWAKEUPEVENT_SHIFT 20
195#define OMAP4_CSI21_DX2_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
196#define OMAP4_CSI21_DY1_DUPLICATEWAKEUPEVENT_SHIFT 19
197#define OMAP4_CSI21_DY1_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
198#define OMAP4_CSI21_DX1_DUPLICATEWAKEUPEVENT_SHIFT 18
199#define OMAP4_CSI21_DX1_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
200#define OMAP4_CSI21_DY0_DUPLICATEWAKEUPEVENT_SHIFT 17
201#define OMAP4_CSI21_DY0_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
202#define OMAP4_CSI21_DX0_DUPLICATEWAKEUPEVENT_SHIFT 16
203#define OMAP4_CSI21_DX0_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
204#define OMAP4_HDMI_DDC_SDA_DUPLICATEWAKEUPEVENT_SHIFT 15
205#define OMAP4_HDMI_DDC_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
206#define OMAP4_HDMI_DDC_SCL_DUPLICATEWAKEUPEVENT_SHIFT 14
207#define OMAP4_HDMI_DDC_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
208#define OMAP4_HDMI_CEC_DUPLICATEWAKEUPEVENT_SHIFT 13
209#define OMAP4_HDMI_CEC_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
210#define OMAP4_HDMI_HPD_DUPLICATEWAKEUPEVENT_SHIFT 12
211#define OMAP4_HDMI_HPD_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
212#define OMAP4_C2C_DATA15_DUPLICATEWAKEUPEVENT_SHIFT 11
213#define OMAP4_C2C_DATA15_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
214#define OMAP4_C2C_DATA14_DUPLICATEWAKEUPEVENT_SHIFT 10
215#define OMAP4_C2C_DATA14_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
216#define OMAP4_C2C_DATA13_DUPLICATEWAKEUPEVENT_SHIFT 9
217#define OMAP4_C2C_DATA13_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
218#define OMAP4_C2C_DATA12_DUPLICATEWAKEUPEVENT_SHIFT 8
219#define OMAP4_C2C_DATA12_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
220#define OMAP4_C2C_DATA11_DUPLICATEWAKEUPEVENT_SHIFT 7
221#define OMAP4_C2C_DATA11_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
222#define OMAP4_GPMC_WAIT1_DUPLICATEWAKEUPEVENT_SHIFT 6
223#define OMAP4_GPMC_WAIT1_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
224#define OMAP4_GPMC_WAIT0_DUPLICATEWAKEUPEVENT_SHIFT 5
225#define OMAP4_GPMC_WAIT0_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
226#define OMAP4_GPMC_NBE1_DUPLICATEWAKEUPEVENT_SHIFT 4
227#define OMAP4_GPMC_NBE1_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
228#define OMAP4_GPMC_NBE0_CLE_DUPLICATEWAKEUPEVENT_SHIFT 3
229#define OMAP4_GPMC_NBE0_CLE_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
230#define OMAP4_GPMC_NWE_DUPLICATEWAKEUPEVENT_SHIFT 2
231#define OMAP4_GPMC_NWE_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
232#define OMAP4_GPMC_NOE_DUPLICATEWAKEUPEVENT_SHIFT 1
233#define OMAP4_GPMC_NOE_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
234#define OMAP4_GPMC_NADV_ALE_DUPLICATEWAKEUPEVENT_SHIFT 0
235#define OMAP4_GPMC_NADV_ALE_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
236
237/* PADCONF_WAKEUPEVENT_2 */
238#define OMAP4_ABE_MCBSP1_CLKX_DUPLICATEWAKEUPEVENT_SHIFT 31
239#define OMAP4_ABE_MCBSP1_CLKX_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
240#define OMAP4_ABE_MCBSP2_FSX_DUPLICATEWAKEUPEVENT_SHIFT 30
241#define OMAP4_ABE_MCBSP2_FSX_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
242#define OMAP4_ABE_MCBSP2_DX_DUPLICATEWAKEUPEVENT_SHIFT 29
243#define OMAP4_ABE_MCBSP2_DX_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
244#define OMAP4_ABE_MCBSP2_DR_DUPLICATEWAKEUPEVENT_SHIFT 28
245#define OMAP4_ABE_MCBSP2_DR_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
246#define OMAP4_ABE_MCBSP2_CLKX_DUPLICATEWAKEUPEVENT_SHIFT 27
247#define OMAP4_ABE_MCBSP2_CLKX_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
248#define OMAP4_SDMMC1_DAT7_DUPLICATEWAKEUPEVENT_SHIFT 26
249#define OMAP4_SDMMC1_DAT7_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
250#define OMAP4_SDMMC1_DAT6_DUPLICATEWAKEUPEVENT_SHIFT 25
251#define OMAP4_SDMMC1_DAT6_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
252#define OMAP4_SDMMC1_DAT5_DUPLICATEWAKEUPEVENT_SHIFT 24
253#define OMAP4_SDMMC1_DAT5_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
254#define OMAP4_SDMMC1_DAT4_DUPLICATEWAKEUPEVENT_SHIFT 23
255#define OMAP4_SDMMC1_DAT4_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
256#define OMAP4_SDMMC1_DAT3_DUPLICATEWAKEUPEVENT_SHIFT 22
257#define OMAP4_SDMMC1_DAT3_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
258#define OMAP4_SDMMC1_DAT2_DUPLICATEWAKEUPEVENT_SHIFT 21
259#define OMAP4_SDMMC1_DAT2_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
260#define OMAP4_SDMMC1_DAT1_DUPLICATEWAKEUPEVENT_SHIFT 20
261#define OMAP4_SDMMC1_DAT1_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
262#define OMAP4_SDMMC1_DAT0_DUPLICATEWAKEUPEVENT_SHIFT 19
263#define OMAP4_SDMMC1_DAT0_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
264#define OMAP4_SDMMC1_CMD_DUPLICATEWAKEUPEVENT_SHIFT 18
265#define OMAP4_SDMMC1_CMD_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
266#define OMAP4_SDMMC1_CLK_DUPLICATEWAKEUPEVENT_SHIFT 17
267#define OMAP4_SDMMC1_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
268#define OMAP4_USBC1_ICUSB_DM_DUPLICATEWAKEUPEVENT_SHIFT 16
269#define OMAP4_USBC1_ICUSB_DM_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
270#define OMAP4_USBC1_ICUSB_DP_DUPLICATEWAKEUPEVENT_SHIFT 15
271#define OMAP4_USBC1_ICUSB_DP_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
272#define OMAP4_USBB1_HSIC_STROBE_DUPLICATEWAKEUPEVENT_SHIFT 14
273#define OMAP4_USBB1_HSIC_STROBE_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
274#define OMAP4_USBB1_HSIC_DATA_DUPLICATEWAKEUPEVENT_SHIFT 13
275#define OMAP4_USBB1_HSIC_DATA_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
276#define OMAP4_USBB1_ULPITLL_DAT7_DUPLICATEWAKEUPEVENT_SHIFT 12
277#define OMAP4_USBB1_ULPITLL_DAT7_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
278#define OMAP4_USBB1_ULPITLL_DAT6_DUPLICATEWAKEUPEVENT_SHIFT 11
279#define OMAP4_USBB1_ULPITLL_DAT6_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
280#define OMAP4_USBB1_ULPITLL_DAT5_DUPLICATEWAKEUPEVENT_SHIFT 10
281#define OMAP4_USBB1_ULPITLL_DAT5_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
282#define OMAP4_USBB1_ULPITLL_DAT4_DUPLICATEWAKEUPEVENT_SHIFT 9
283#define OMAP4_USBB1_ULPITLL_DAT4_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
284#define OMAP4_USBB1_ULPITLL_DAT3_DUPLICATEWAKEUPEVENT_SHIFT 8
285#define OMAP4_USBB1_ULPITLL_DAT3_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
286#define OMAP4_USBB1_ULPITLL_DAT2_DUPLICATEWAKEUPEVENT_SHIFT 7
287#define OMAP4_USBB1_ULPITLL_DAT2_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
288#define OMAP4_USBB1_ULPITLL_DAT1_DUPLICATEWAKEUPEVENT_SHIFT 6
289#define OMAP4_USBB1_ULPITLL_DAT1_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
290#define OMAP4_USBB1_ULPITLL_DAT0_DUPLICATEWAKEUPEVENT_SHIFT 5
291#define OMAP4_USBB1_ULPITLL_DAT0_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
292#define OMAP4_USBB1_ULPITLL_NXT_DUPLICATEWAKEUPEVENT_SHIFT 4
293#define OMAP4_USBB1_ULPITLL_NXT_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
294#define OMAP4_USBB1_ULPITLL_DIR_DUPLICATEWAKEUPEVENT_SHIFT 3
295#define OMAP4_USBB1_ULPITLL_DIR_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
296#define OMAP4_USBB1_ULPITLL_STP_DUPLICATEWAKEUPEVENT_SHIFT 2
297#define OMAP4_USBB1_ULPITLL_STP_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
298#define OMAP4_USBB1_ULPITLL_CLK_DUPLICATEWAKEUPEVENT_SHIFT 1
299#define OMAP4_USBB1_ULPITLL_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
300#define OMAP4_CAM_GLOBALRESET_DUPLICATEWAKEUPEVENT_SHIFT 0
301#define OMAP4_CAM_GLOBALRESET_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
302
303/* PADCONF_WAKEUPEVENT_3 */
304#define OMAP4_MCSPI1_CS3_DUPLICATEWAKEUPEVENT_SHIFT 31
305#define OMAP4_MCSPI1_CS3_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
306#define OMAP4_MCSPI1_CS2_DUPLICATEWAKEUPEVENT_SHIFT 30
307#define OMAP4_MCSPI1_CS2_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
308#define OMAP4_MCSPI1_CS1_DUPLICATEWAKEUPEVENT_SHIFT 29
309#define OMAP4_MCSPI1_CS1_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
310#define OMAP4_MCSPI1_CS0_DUPLICATEWAKEUPEVENT_SHIFT 28
311#define OMAP4_MCSPI1_CS0_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
312#define OMAP4_MCSPI1_SIMO_DUPLICATEWAKEUPEVENT_SHIFT 27
313#define OMAP4_MCSPI1_SIMO_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
314#define OMAP4_MCSPI1_SOMI_DUPLICATEWAKEUPEVENT_SHIFT 26
315#define OMAP4_MCSPI1_SOMI_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
316#define OMAP4_MCSPI1_CLK_DUPLICATEWAKEUPEVENT_SHIFT 25
317#define OMAP4_MCSPI1_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
318#define OMAP4_I2C4_SDA_DUPLICATEWAKEUPEVENT_SHIFT 24
319#define OMAP4_I2C4_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
320#define OMAP4_I2C4_SCL_DUPLICATEWAKEUPEVENT_SHIFT 23
321#define OMAP4_I2C4_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
322#define OMAP4_I2C3_SDA_DUPLICATEWAKEUPEVENT_SHIFT 22
323#define OMAP4_I2C3_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
324#define OMAP4_I2C3_SCL_DUPLICATEWAKEUPEVENT_SHIFT 21
325#define OMAP4_I2C3_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
326#define OMAP4_I2C2_SDA_DUPLICATEWAKEUPEVENT_SHIFT 20
327#define OMAP4_I2C2_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
328#define OMAP4_I2C2_SCL_DUPLICATEWAKEUPEVENT_SHIFT 19
329#define OMAP4_I2C2_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
330#define OMAP4_I2C1_SDA_DUPLICATEWAKEUPEVENT_SHIFT 18
331#define OMAP4_I2C1_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
332#define OMAP4_I2C1_SCL_DUPLICATEWAKEUPEVENT_SHIFT 17
333#define OMAP4_I2C1_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
334#define OMAP4_HDQ_SIO_DUPLICATEWAKEUPEVENT_SHIFT 16
335#define OMAP4_HDQ_SIO_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
336#define OMAP4_UART2_TX_DUPLICATEWAKEUPEVENT_SHIFT 15
337#define OMAP4_UART2_TX_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
338#define OMAP4_UART2_RX_DUPLICATEWAKEUPEVENT_SHIFT 14
339#define OMAP4_UART2_RX_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
340#define OMAP4_UART2_RTS_DUPLICATEWAKEUPEVENT_SHIFT 13
341#define OMAP4_UART2_RTS_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
342#define OMAP4_UART2_CTS_DUPLICATEWAKEUPEVENT_SHIFT 12
343#define OMAP4_UART2_CTS_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
344#define OMAP4_ABE_DMIC_DIN3_DUPLICATEWAKEUPEVENT_SHIFT 11
345#define OMAP4_ABE_DMIC_DIN3_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
346#define OMAP4_ABE_DMIC_DIN2_DUPLICATEWAKEUPEVENT_SHIFT 10
347#define OMAP4_ABE_DMIC_DIN2_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
348#define OMAP4_ABE_DMIC_DIN1_DUPLICATEWAKEUPEVENT_SHIFT 9
349#define OMAP4_ABE_DMIC_DIN1_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
350#define OMAP4_ABE_DMIC_CLK1_DUPLICATEWAKEUPEVENT_SHIFT 8
351#define OMAP4_ABE_DMIC_CLK1_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
352#define OMAP4_ABE_CLKS_DUPLICATEWAKEUPEVENT_SHIFT 7
353#define OMAP4_ABE_CLKS_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
354#define OMAP4_ABE_PDM_LB_CLK_DUPLICATEWAKEUPEVENT_SHIFT 6
355#define OMAP4_ABE_PDM_LB_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
356#define OMAP4_ABE_PDM_FRAME_DUPLICATEWAKEUPEVENT_SHIFT 5
357#define OMAP4_ABE_PDM_FRAME_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
358#define OMAP4_ABE_PDM_DL_DATA_DUPLICATEWAKEUPEVENT_SHIFT 4
359#define OMAP4_ABE_PDM_DL_DATA_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
360#define OMAP4_ABE_PDM_UL_DATA_DUPLICATEWAKEUPEVENT_SHIFT 3
361#define OMAP4_ABE_PDM_UL_DATA_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
362#define OMAP4_ABE_MCBSP1_FSX_DUPLICATEWAKEUPEVENT_SHIFT 2
363#define OMAP4_ABE_MCBSP1_FSX_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
364#define OMAP4_ABE_MCBSP1_DX_DUPLICATEWAKEUPEVENT_SHIFT 1
365#define OMAP4_ABE_MCBSP1_DX_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
366#define OMAP4_ABE_MCBSP1_DR_DUPLICATEWAKEUPEVENT_SHIFT 0
367#define OMAP4_ABE_MCBSP1_DR_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
368
369/* PADCONF_WAKEUPEVENT_4 */
370#define OMAP4_UNIPRO_TY0_DUPLICATEWAKEUPEVENT_SHIFT 31
371#define OMAP4_UNIPRO_TY0_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
372#define OMAP4_UNIPRO_TX0_DUPLICATEWAKEUPEVENT_SHIFT 30
373#define OMAP4_UNIPRO_TX0_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
374#define OMAP4_USBB2_HSIC_STROBE_DUPLICATEWAKEUPEVENT_SHIFT 29
375#define OMAP4_USBB2_HSIC_STROBE_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
376#define OMAP4_USBB2_HSIC_DATA_DUPLICATEWAKEUPEVENT_SHIFT 28
377#define OMAP4_USBB2_HSIC_DATA_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
378#define OMAP4_USBB2_ULPITLL_DAT7_DUPLICATEWAKEUPEVENT_SHIFT 27
379#define OMAP4_USBB2_ULPITLL_DAT7_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
380#define OMAP4_USBB2_ULPITLL_DAT6_DUPLICATEWAKEUPEVENT_SHIFT 26
381#define OMAP4_USBB2_ULPITLL_DAT6_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
382#define OMAP4_USBB2_ULPITLL_DAT5_DUPLICATEWAKEUPEVENT_SHIFT 25
383#define OMAP4_USBB2_ULPITLL_DAT5_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
384#define OMAP4_USBB2_ULPITLL_DAT4_DUPLICATEWAKEUPEVENT_SHIFT 24
385#define OMAP4_USBB2_ULPITLL_DAT4_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
386#define OMAP4_USBB2_ULPITLL_DAT3_DUPLICATEWAKEUPEVENT_SHIFT 23
387#define OMAP4_USBB2_ULPITLL_DAT3_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
388#define OMAP4_USBB2_ULPITLL_DAT2_DUPLICATEWAKEUPEVENT_SHIFT 22
389#define OMAP4_USBB2_ULPITLL_DAT2_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
390#define OMAP4_USBB2_ULPITLL_DAT1_DUPLICATEWAKEUPEVENT_SHIFT 21
391#define OMAP4_USBB2_ULPITLL_DAT1_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
392#define OMAP4_USBB2_ULPITLL_DAT0_DUPLICATEWAKEUPEVENT_SHIFT 20
393#define OMAP4_USBB2_ULPITLL_DAT0_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
394#define OMAP4_USBB2_ULPITLL_NXT_DUPLICATEWAKEUPEVENT_SHIFT 19
395#define OMAP4_USBB2_ULPITLL_NXT_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
396#define OMAP4_USBB2_ULPITLL_DIR_DUPLICATEWAKEUPEVENT_SHIFT 18
397#define OMAP4_USBB2_ULPITLL_DIR_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
398#define OMAP4_USBB2_ULPITLL_STP_DUPLICATEWAKEUPEVENT_SHIFT 17
399#define OMAP4_USBB2_ULPITLL_STP_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
400#define OMAP4_USBB2_ULPITLL_CLK_DUPLICATEWAKEUPEVENT_SHIFT 16
401#define OMAP4_USBB2_ULPITLL_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
402#define OMAP4_UART4_TX_DUPLICATEWAKEUPEVENT_SHIFT 15
403#define OMAP4_UART4_TX_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
404#define OMAP4_UART4_RX_DUPLICATEWAKEUPEVENT_SHIFT 14
405#define OMAP4_UART4_RX_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
406#define OMAP4_MCSPI4_CS0_DUPLICATEWAKEUPEVENT_SHIFT 13
407#define OMAP4_MCSPI4_CS0_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
408#define OMAP4_MCSPI4_SOMI_DUPLICATEWAKEUPEVENT_SHIFT 12
409#define OMAP4_MCSPI4_SOMI_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
410#define OMAP4_MCSPI4_SIMO_DUPLICATEWAKEUPEVENT_SHIFT 11
411#define OMAP4_MCSPI4_SIMO_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
412#define OMAP4_MCSPI4_CLK_DUPLICATEWAKEUPEVENT_SHIFT 10
413#define OMAP4_MCSPI4_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
414#define OMAP4_SDMMC5_DAT3_DUPLICATEWAKEUPEVENT_SHIFT 9
415#define OMAP4_SDMMC5_DAT3_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
416#define OMAP4_SDMMC5_DAT2_DUPLICATEWAKEUPEVENT_SHIFT 8
417#define OMAP4_SDMMC5_DAT2_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
418#define OMAP4_SDMMC5_DAT1_DUPLICATEWAKEUPEVENT_SHIFT 7
419#define OMAP4_SDMMC5_DAT1_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
420#define OMAP4_SDMMC5_DAT0_DUPLICATEWAKEUPEVENT_SHIFT 6
421#define OMAP4_SDMMC5_DAT0_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
422#define OMAP4_SDMMC5_CMD_DUPLICATEWAKEUPEVENT_SHIFT 5
423#define OMAP4_SDMMC5_CMD_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
424#define OMAP4_SDMMC5_CLK_DUPLICATEWAKEUPEVENT_SHIFT 4
425#define OMAP4_SDMMC5_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
426#define OMAP4_UART3_TX_IRTX_DUPLICATEWAKEUPEVENT_SHIFT 3
427#define OMAP4_UART3_TX_IRTX_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
428#define OMAP4_UART3_RX_IRRX_DUPLICATEWAKEUPEVENT_SHIFT 2
429#define OMAP4_UART3_RX_IRRX_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
430#define OMAP4_UART3_RTS_SD_DUPLICATEWAKEUPEVENT_SHIFT 1
431#define OMAP4_UART3_RTS_SD_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
432#define OMAP4_UART3_CTS_RCTX_DUPLICATEWAKEUPEVENT_SHIFT 0
433#define OMAP4_UART3_CTS_RCTX_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
434
435/* PADCONF_WAKEUPEVENT_5 */
436#define OMAP4_DPM_EMU11_DUPLICATEWAKEUPEVENT_SHIFT 31
437#define OMAP4_DPM_EMU11_DUPLICATEWAKEUPEVENT_MASK (1 << 31)
438#define OMAP4_DPM_EMU10_DUPLICATEWAKEUPEVENT_SHIFT 30
439#define OMAP4_DPM_EMU10_DUPLICATEWAKEUPEVENT_MASK (1 << 30)
440#define OMAP4_DPM_EMU9_DUPLICATEWAKEUPEVENT_SHIFT 29
441#define OMAP4_DPM_EMU9_DUPLICATEWAKEUPEVENT_MASK (1 << 29)
442#define OMAP4_DPM_EMU8_DUPLICATEWAKEUPEVENT_SHIFT 28
443#define OMAP4_DPM_EMU8_DUPLICATEWAKEUPEVENT_MASK (1 << 28)
444#define OMAP4_DPM_EMU7_DUPLICATEWAKEUPEVENT_SHIFT 27
445#define OMAP4_DPM_EMU7_DUPLICATEWAKEUPEVENT_MASK (1 << 27)
446#define OMAP4_DPM_EMU6_DUPLICATEWAKEUPEVENT_SHIFT 26
447#define OMAP4_DPM_EMU6_DUPLICATEWAKEUPEVENT_MASK (1 << 26)
448#define OMAP4_DPM_EMU5_DUPLICATEWAKEUPEVENT_SHIFT 25
449#define OMAP4_DPM_EMU5_DUPLICATEWAKEUPEVENT_MASK (1 << 25)
450#define OMAP4_DPM_EMU4_DUPLICATEWAKEUPEVENT_SHIFT 24
451#define OMAP4_DPM_EMU4_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
452#define OMAP4_DPM_EMU3_DUPLICATEWAKEUPEVENT_SHIFT 23
453#define OMAP4_DPM_EMU3_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
454#define OMAP4_DPM_EMU2_DUPLICATEWAKEUPEVENT_SHIFT 22
455#define OMAP4_DPM_EMU2_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
456#define OMAP4_DPM_EMU1_DUPLICATEWAKEUPEVENT_SHIFT 21
457#define OMAP4_DPM_EMU1_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
458#define OMAP4_DPM_EMU0_DUPLICATEWAKEUPEVENT_SHIFT 20
459#define OMAP4_DPM_EMU0_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
460#define OMAP4_SYS_BOOT5_DUPLICATEWAKEUPEVENT_SHIFT 19
461#define OMAP4_SYS_BOOT5_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
462#define OMAP4_SYS_BOOT4_DUPLICATEWAKEUPEVENT_SHIFT 18
463#define OMAP4_SYS_BOOT4_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
464#define OMAP4_SYS_BOOT3_DUPLICATEWAKEUPEVENT_SHIFT 17
465#define OMAP4_SYS_BOOT3_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
466#define OMAP4_SYS_BOOT2_DUPLICATEWAKEUPEVENT_SHIFT 16
467#define OMAP4_SYS_BOOT2_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
468#define OMAP4_SYS_BOOT1_DUPLICATEWAKEUPEVENT_SHIFT 15
469#define OMAP4_SYS_BOOT1_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
470#define OMAP4_SYS_BOOT0_DUPLICATEWAKEUPEVENT_SHIFT 14
471#define OMAP4_SYS_BOOT0_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
472#define OMAP4_SYS_NIRQ2_DUPLICATEWAKEUPEVENT_SHIFT 13
473#define OMAP4_SYS_NIRQ2_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
474#define OMAP4_SYS_NIRQ1_DUPLICATEWAKEUPEVENT_SHIFT 12
475#define OMAP4_SYS_NIRQ1_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
476#define OMAP4_FREF_CLK2_OUT_DUPLICATEWAKEUPEVENT_SHIFT 11
477#define OMAP4_FREF_CLK2_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
478#define OMAP4_FREF_CLK1_OUT_DUPLICATEWAKEUPEVENT_SHIFT 10
479#define OMAP4_FREF_CLK1_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
480#define OMAP4_UNIPRO_RY2_DUPLICATEWAKEUPEVENT_SHIFT 9
481#define OMAP4_UNIPRO_RY2_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
482#define OMAP4_UNIPRO_RX2_DUPLICATEWAKEUPEVENT_SHIFT 8
483#define OMAP4_UNIPRO_RX2_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
484#define OMAP4_UNIPRO_RY1_DUPLICATEWAKEUPEVENT_SHIFT 7
485#define OMAP4_UNIPRO_RY1_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
486#define OMAP4_UNIPRO_RX1_DUPLICATEWAKEUPEVENT_SHIFT 6
487#define OMAP4_UNIPRO_RX1_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
488#define OMAP4_UNIPRO_RY0_DUPLICATEWAKEUPEVENT_SHIFT 5
489#define OMAP4_UNIPRO_RY0_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
490#define OMAP4_UNIPRO_RX0_DUPLICATEWAKEUPEVENT_SHIFT 4
491#define OMAP4_UNIPRO_RX0_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
492#define OMAP4_UNIPRO_TY2_DUPLICATEWAKEUPEVENT_SHIFT 3
493#define OMAP4_UNIPRO_TY2_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
494#define OMAP4_UNIPRO_TX2_DUPLICATEWAKEUPEVENT_SHIFT 2
495#define OMAP4_UNIPRO_TX2_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
496#define OMAP4_UNIPRO_TY1_DUPLICATEWAKEUPEVENT_SHIFT 1
497#define OMAP4_UNIPRO_TY1_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
498#define OMAP4_UNIPRO_TX1_DUPLICATEWAKEUPEVENT_SHIFT 0
499#define OMAP4_UNIPRO_TX1_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
500
501/* PADCONF_WAKEUPEVENT_6 */
502#define OMAP4_DPM_EMU19_DUPLICATEWAKEUPEVENT_SHIFT 7
503#define OMAP4_DPM_EMU19_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
504#define OMAP4_DPM_EMU18_DUPLICATEWAKEUPEVENT_SHIFT 6
505#define OMAP4_DPM_EMU18_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
506#define OMAP4_DPM_EMU17_DUPLICATEWAKEUPEVENT_SHIFT 5
507#define OMAP4_DPM_EMU17_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
508#define OMAP4_DPM_EMU16_DUPLICATEWAKEUPEVENT_SHIFT 4
509#define OMAP4_DPM_EMU16_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
510#define OMAP4_DPM_EMU15_DUPLICATEWAKEUPEVENT_SHIFT 3
511#define OMAP4_DPM_EMU15_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
512#define OMAP4_DPM_EMU14_DUPLICATEWAKEUPEVENT_SHIFT 2
513#define OMAP4_DPM_EMU14_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
514#define OMAP4_DPM_EMU13_DUPLICATEWAKEUPEVENT_SHIFT 1
515#define OMAP4_DPM_EMU13_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
516#define OMAP4_DPM_EMU12_DUPLICATEWAKEUPEVENT_SHIFT 0
517#define OMAP4_DPM_EMU12_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
518
519/* CONTROL_PADCONF_GLOBAL */
520#define OMAP4_FORCE_OFFMODE_EN_SHIFT 31
521#define OMAP4_FORCE_OFFMODE_EN_MASK (1 << 31)
522
523/* CONTROL_PADCONF_MODE */
524#define OMAP4_VDDS_DV_BANK0_SHIFT 31
525#define OMAP4_VDDS_DV_BANK0_MASK (1 << 31)
526#define OMAP4_VDDS_DV_BANK1_SHIFT 30
527#define OMAP4_VDDS_DV_BANK1_MASK (1 << 30)
528#define OMAP4_VDDS_DV_BANK3_SHIFT 29
529#define OMAP4_VDDS_DV_BANK3_MASK (1 << 29)
530#define OMAP4_VDDS_DV_BANK4_SHIFT 28
531#define OMAP4_VDDS_DV_BANK4_MASK (1 << 28)
532#define OMAP4_VDDS_DV_BANK5_SHIFT 27
533#define OMAP4_VDDS_DV_BANK5_MASK (1 << 27)
534#define OMAP4_VDDS_DV_BANK6_SHIFT 26
535#define OMAP4_VDDS_DV_BANK6_MASK (1 << 26)
536#define OMAP4_VDDS_DV_C2C_SHIFT 25
537#define OMAP4_VDDS_DV_C2C_MASK (1 << 25)
538#define OMAP4_VDDS_DV_CAM_SHIFT 24
539#define OMAP4_VDDS_DV_CAM_MASK (1 << 24)
540#define OMAP4_VDDS_DV_GPMC_SHIFT 23
541#define OMAP4_VDDS_DV_GPMC_MASK (1 << 23)
542#define OMAP4_VDDS_DV_SDMMC2_SHIFT 22
543#define OMAP4_VDDS_DV_SDMMC2_MASK (1 << 22)
544
545/* CONTROL_SMART1IO_PADCONF_0 */
546#define OMAP4_ABE_DR0_SC_SHIFT 30
547#define OMAP4_ABE_DR0_SC_MASK (0x3 << 30)
548#define OMAP4_CAM_DR0_SC_SHIFT 28
549#define OMAP4_CAM_DR0_SC_MASK (0x3 << 28)
550#define OMAP4_FREF_DR2_SC_SHIFT 26
551#define OMAP4_FREF_DR2_SC_MASK (0x3 << 26)
552#define OMAP4_FREF_DR3_SC_SHIFT 24
553#define OMAP4_FREF_DR3_SC_MASK (0x3 << 24)
554#define OMAP4_GPIO_DR8_SC_SHIFT 22
555#define OMAP4_GPIO_DR8_SC_MASK (0x3 << 22)
556#define OMAP4_GPIO_DR9_SC_SHIFT 20
557#define OMAP4_GPIO_DR9_SC_MASK (0x3 << 20)
558#define OMAP4_GPMC_DR2_SC_SHIFT 18
559#define OMAP4_GPMC_DR2_SC_MASK (0x3 << 18)
560#define OMAP4_GPMC_DR3_SC_SHIFT 16
561#define OMAP4_GPMC_DR3_SC_MASK (0x3 << 16)
562#define OMAP4_GPMC_DR6_SC_SHIFT 14
563#define OMAP4_GPMC_DR6_SC_MASK (0x3 << 14)
564#define OMAP4_HDMI_DR0_SC_SHIFT 12
565#define OMAP4_HDMI_DR0_SC_MASK (0x3 << 12)
566#define OMAP4_MCSPI1_DR0_SC_SHIFT 10
567#define OMAP4_MCSPI1_DR0_SC_MASK (0x3 << 10)
568#define OMAP4_UART1_DR0_SC_SHIFT 8
569#define OMAP4_UART1_DR0_SC_MASK (0x3 << 8)
570#define OMAP4_UART3_DR0_SC_SHIFT 6
571#define OMAP4_UART3_DR0_SC_MASK (0x3 << 6)
572#define OMAP4_UART3_DR1_SC_SHIFT 4
573#define OMAP4_UART3_DR1_SC_MASK (0x3 << 4)
574#define OMAP4_UNIPRO_DR0_SC_SHIFT 2
575#define OMAP4_UNIPRO_DR0_SC_MASK (0x3 << 2)
576#define OMAP4_UNIPRO_DR1_SC_SHIFT 0
577#define OMAP4_UNIPRO_DR1_SC_MASK (0x3 << 0)
578
579/* CONTROL_SMART1IO_PADCONF_1 */
580#define OMAP4_ABE_DR0_LB_SHIFT 30
581#define OMAP4_ABE_DR0_LB_MASK (0x3 << 30)
582#define OMAP4_CAM_DR0_LB_SHIFT 28
583#define OMAP4_CAM_DR0_LB_MASK (0x3 << 28)
584#define OMAP4_FREF_DR2_LB_SHIFT 26
585#define OMAP4_FREF_DR2_LB_MASK (0x3 << 26)
586#define OMAP4_FREF_DR3_LB_SHIFT 24
587#define OMAP4_FREF_DR3_LB_MASK (0x3 << 24)
588#define OMAP4_GPIO_DR8_LB_SHIFT 22
589#define OMAP4_GPIO_DR8_LB_MASK (0x3 << 22)
590#define OMAP4_GPIO_DR9_LB_SHIFT 20
591#define OMAP4_GPIO_DR9_LB_MASK (0x3 << 20)
592#define OMAP4_GPMC_DR2_LB_SHIFT 18
593#define OMAP4_GPMC_DR2_LB_MASK (0x3 << 18)
594#define OMAP4_GPMC_DR3_LB_SHIFT 16
595#define OMAP4_GPMC_DR3_LB_MASK (0x3 << 16)
596#define OMAP4_GPMC_DR6_LB_SHIFT 14
597#define OMAP4_GPMC_DR6_LB_MASK (0x3 << 14)
598#define OMAP4_HDMI_DR0_LB_SHIFT 12
599#define OMAP4_HDMI_DR0_LB_MASK (0x3 << 12)
600#define OMAP4_MCSPI1_DR0_LB_SHIFT 10
601#define OMAP4_MCSPI1_DR0_LB_MASK (0x3 << 10)
602#define OMAP4_UART1_DR0_LB_SHIFT 8
603#define OMAP4_UART1_DR0_LB_MASK (0x3 << 8)
604#define OMAP4_UART3_DR0_LB_SHIFT 6
605#define OMAP4_UART3_DR0_LB_MASK (0x3 << 6)
606#define OMAP4_UART3_DR1_LB_SHIFT 4
607#define OMAP4_UART3_DR1_LB_MASK (0x3 << 4)
608#define OMAP4_UNIPRO_DR0_LB_SHIFT 2
609#define OMAP4_UNIPRO_DR0_LB_MASK (0x3 << 2)
610#define OMAP4_UNIPRO_DR1_LB_SHIFT 0
611#define OMAP4_UNIPRO_DR1_LB_MASK (0x3 << 0)
612
613/* CONTROL_SMART2IO_PADCONF_0 */
614#define OMAP4_C2C_DR0_LB_SHIFT 31
615#define OMAP4_C2C_DR0_LB_MASK (1 << 31)
616#define OMAP4_DPM_DR1_LB_SHIFT 30
617#define OMAP4_DPM_DR1_LB_MASK (1 << 30)
618#define OMAP4_DPM_DR2_LB_SHIFT 29
619#define OMAP4_DPM_DR2_LB_MASK (1 << 29)
620#define OMAP4_DPM_DR3_LB_SHIFT 28
621#define OMAP4_DPM_DR3_LB_MASK (1 << 28)
622#define OMAP4_GPIO_DR0_LB_SHIFT 27
623#define OMAP4_GPIO_DR0_LB_MASK (1 << 27)
624#define OMAP4_GPIO_DR1_LB_SHIFT 26
625#define OMAP4_GPIO_DR1_LB_MASK (1 << 26)
626#define OMAP4_GPIO_DR10_LB_SHIFT 25
627#define OMAP4_GPIO_DR10_LB_MASK (1 << 25)
628#define OMAP4_GPIO_DR2_LB_SHIFT 24
629#define OMAP4_GPIO_DR2_LB_MASK (1 << 24)
630#define OMAP4_GPMC_DR0_LB_SHIFT 23
631#define OMAP4_GPMC_DR0_LB_MASK (1 << 23)
632#define OMAP4_GPMC_DR1_LB_SHIFT 22
633#define OMAP4_GPMC_DR1_LB_MASK (1 << 22)
634#define OMAP4_GPMC_DR4_LB_SHIFT 21
635#define OMAP4_GPMC_DR4_LB_MASK (1 << 21)
636#define OMAP4_GPMC_DR5_LB_SHIFT 20
637#define OMAP4_GPMC_DR5_LB_MASK (1 << 20)
638#define OMAP4_GPMC_DR7_LB_SHIFT 19
639#define OMAP4_GPMC_DR7_LB_MASK (1 << 19)
640#define OMAP4_HSI2_DR0_LB_SHIFT 18
641#define OMAP4_HSI2_DR0_LB_MASK (1 << 18)
642#define OMAP4_HSI2_DR1_LB_SHIFT 17
643#define OMAP4_HSI2_DR1_LB_MASK (1 << 17)
644#define OMAP4_HSI2_DR2_LB_SHIFT 16
645#define OMAP4_HSI2_DR2_LB_MASK (1 << 16)
646#define OMAP4_KPD_DR0_LB_SHIFT 15
647#define OMAP4_KPD_DR0_LB_MASK (1 << 15)
648#define OMAP4_KPD_DR1_LB_SHIFT 14
649#define OMAP4_KPD_DR1_LB_MASK (1 << 14)
650#define OMAP4_PDM_DR0_LB_SHIFT 13
651#define OMAP4_PDM_DR0_LB_MASK (1 << 13)
652#define OMAP4_SDMMC2_DR0_LB_SHIFT 12
653#define OMAP4_SDMMC2_DR0_LB_MASK (1 << 12)
654#define OMAP4_SDMMC3_DR0_LB_SHIFT 11
655#define OMAP4_SDMMC3_DR0_LB_MASK (1 << 11)
656#define OMAP4_SDMMC4_DR0_LB_SHIFT 10
657#define OMAP4_SDMMC4_DR0_LB_MASK (1 << 10)
658#define OMAP4_SDMMC4_DR1_LB_SHIFT 9
659#define OMAP4_SDMMC4_DR1_LB_MASK (1 << 9)
660#define OMAP4_SPI3_DR0_LB_SHIFT 8
661#define OMAP4_SPI3_DR0_LB_MASK (1 << 8)
662#define OMAP4_SPI3_DR1_LB_SHIFT 7
663#define OMAP4_SPI3_DR1_LB_MASK (1 << 7)
664#define OMAP4_UART3_DR2_LB_SHIFT 6
665#define OMAP4_UART3_DR2_LB_MASK (1 << 6)
666#define OMAP4_UART3_DR3_LB_SHIFT 5
667#define OMAP4_UART3_DR3_LB_MASK (1 << 5)
668#define OMAP4_UART3_DR4_LB_SHIFT 4
669#define OMAP4_UART3_DR4_LB_MASK (1 << 4)
670#define OMAP4_UART3_DR5_LB_SHIFT 3
671#define OMAP4_UART3_DR5_LB_MASK (1 << 3)
672#define OMAP4_USBA0_DR1_LB_SHIFT 2
673#define OMAP4_USBA0_DR1_LB_MASK (1 << 2)
674#define OMAP4_USBA_DR2_LB_SHIFT 1
675#define OMAP4_USBA_DR2_LB_MASK (1 << 1)
676
677/* CONTROL_SMART2IO_PADCONF_1 */
678#define OMAP4_USBB1_DR0_LB_SHIFT 31
679#define OMAP4_USBB1_DR0_LB_MASK (1 << 31)
680#define OMAP4_USBB2_DR0_LB_SHIFT 30
681#define OMAP4_USBB2_DR0_LB_MASK (1 << 30)
682#define OMAP4_USBA0_DR0_LB_SHIFT 29
683#define OMAP4_USBA0_DR0_LB_MASK (1 << 29)
684
685/* CONTROL_SMART3IO_PADCONF_0 */
686#define OMAP4_DMIC_DR0_MB_SHIFT 30
687#define OMAP4_DMIC_DR0_MB_MASK (0x3 << 30)
688#define OMAP4_GPIO_DR3_MB_SHIFT 28
689#define OMAP4_GPIO_DR3_MB_MASK (0x3 << 28)
690#define OMAP4_GPIO_DR4_MB_SHIFT 26
691#define OMAP4_GPIO_DR4_MB_MASK (0x3 << 26)
692#define OMAP4_GPIO_DR5_MB_SHIFT 24
693#define OMAP4_GPIO_DR5_MB_MASK (0x3 << 24)
694#define OMAP4_GPIO_DR6_MB_SHIFT 22
695#define OMAP4_GPIO_DR6_MB_MASK (0x3 << 22)
696#define OMAP4_HSI_DR1_MB_SHIFT 20
697#define OMAP4_HSI_DR1_MB_MASK (0x3 << 20)
698#define OMAP4_HSI_DR2_MB_SHIFT 18
699#define OMAP4_HSI_DR2_MB_MASK (0x3 << 18)
700#define OMAP4_HSI_DR3_MB_SHIFT 16
701#define OMAP4_HSI_DR3_MB_MASK (0x3 << 16)
702#define OMAP4_MCBSP2_DR0_MB_SHIFT 14
703#define OMAP4_MCBSP2_DR0_MB_MASK (0x3 << 14)
704#define OMAP4_MCSPI4_DR0_MB_SHIFT 12
705#define OMAP4_MCSPI4_DR0_MB_MASK (0x3 << 12)
706#define OMAP4_MCSPI4_DR1_MB_SHIFT 10
707#define OMAP4_MCSPI4_DR1_MB_MASK (0x3 << 10)
708#define OMAP4_SDMMC3_DR0_MB_SHIFT 8
709#define OMAP4_SDMMC3_DR0_MB_MASK (0x3 << 8)
710#define OMAP4_SPI2_DR0_MB_SHIFT 0
711#define OMAP4_SPI2_DR0_MB_MASK (0x3 << 0)
712
713/* CONTROL_SMART3IO_PADCONF_1 */
714#define OMAP4_SPI2_DR1_MB_SHIFT 30
715#define OMAP4_SPI2_DR1_MB_MASK (0x3 << 30)
716#define OMAP4_SPI2_DR2_MB_SHIFT 28
717#define OMAP4_SPI2_DR2_MB_MASK (0x3 << 28)
718#define OMAP4_UART2_DR0_MB_SHIFT 26
719#define OMAP4_UART2_DR0_MB_MASK (0x3 << 26)
720#define OMAP4_UART2_DR1_MB_SHIFT 24
721#define OMAP4_UART2_DR1_MB_MASK (0x3 << 24)
722#define OMAP4_UART4_DR0_MB_SHIFT 22
723#define OMAP4_UART4_DR0_MB_MASK (0x3 << 22)
724#define OMAP4_HSI_DR0_MB_SHIFT 20
725#define OMAP4_HSI_DR0_MB_MASK (0x3 << 20)
726
727/* CONTROL_SMART3IO_PADCONF_2 */
728#define OMAP4_DMIC_DR0_LB_SHIFT 31
729#define OMAP4_DMIC_DR0_LB_MASK (1 << 31)
730#define OMAP4_GPIO_DR3_LB_SHIFT 30
731#define OMAP4_GPIO_DR3_LB_MASK (1 << 30)
732#define OMAP4_GPIO_DR4_LB_SHIFT 29
733#define OMAP4_GPIO_DR4_LB_MASK (1 << 29)
734#define OMAP4_GPIO_DR5_LB_SHIFT 28
735#define OMAP4_GPIO_DR5_LB_MASK (1 << 28)
736#define OMAP4_GPIO_DR6_LB_SHIFT 27
737#define OMAP4_GPIO_DR6_LB_MASK (1 << 27)
738#define OMAP4_HSI_DR1_LB_SHIFT 26
739#define OMAP4_HSI_DR1_LB_MASK (1 << 26)
740#define OMAP4_HSI_DR2_LB_SHIFT 25
741#define OMAP4_HSI_DR2_LB_MASK (1 << 25)
742#define OMAP4_HSI_DR3_LB_SHIFT 24
743#define OMAP4_HSI_DR3_LB_MASK (1 << 24)
744#define OMAP4_MCBSP2_DR0_LB_SHIFT 23
745#define OMAP4_MCBSP2_DR0_LB_MASK (1 << 23)
746#define OMAP4_MCSPI4_DR0_LB_SHIFT 22
747#define OMAP4_MCSPI4_DR0_LB_MASK (1 << 22)
748#define OMAP4_MCSPI4_DR1_LB_SHIFT 21
749#define OMAP4_MCSPI4_DR1_LB_MASK (1 << 21)
750#define OMAP4_SLIMBUS2_DR0_LB_SHIFT 18
751#define OMAP4_SLIMBUS2_DR0_LB_MASK (1 << 18)
752#define OMAP4_SPI2_DR0_LB_SHIFT 16
753#define OMAP4_SPI2_DR0_LB_MASK (1 << 16)
754#define OMAP4_SPI2_DR1_LB_SHIFT 15
755#define OMAP4_SPI2_DR1_LB_MASK (1 << 15)
756#define OMAP4_SPI2_DR2_LB_SHIFT 14
757#define OMAP4_SPI2_DR2_LB_MASK (1 << 14)
758#define OMAP4_UART2_DR0_LB_SHIFT 13
759#define OMAP4_UART2_DR0_LB_MASK (1 << 13)
760#define OMAP4_UART2_DR1_LB_SHIFT 12
761#define OMAP4_UART2_DR1_LB_MASK (1 << 12)
762#define OMAP4_UART4_DR0_LB_SHIFT 11
763#define OMAP4_UART4_DR0_LB_MASK (1 << 11)
764#define OMAP4_HSI_DR0_LB_SHIFT 10
765#define OMAP4_HSI_DR0_LB_MASK (1 << 10)
766
767/* CONTROL_USBB_HSIC */
768#define OMAP4_USBB2_DR1_SR_SHIFT 30
769#define OMAP4_USBB2_DR1_SR_MASK (0x3 << 30)
770#define OMAP4_USBB2_DR1_I_SHIFT 27
771#define OMAP4_USBB2_DR1_I_MASK (0x7 << 27)
772#define OMAP4_USBB1_DR1_SR_SHIFT 25
773#define OMAP4_USBB1_DR1_SR_MASK (0x3 << 25)
774#define OMAP4_USBB1_DR1_I_SHIFT 22
775#define OMAP4_USBB1_DR1_I_MASK (0x7 << 22)
776#define OMAP4_USBB1_HSIC_DATA_WD_SHIFT 20
777#define OMAP4_USBB1_HSIC_DATA_WD_MASK (0x3 << 20)
778#define OMAP4_USBB1_HSIC_STROBE_WD_SHIFT 18
779#define OMAP4_USBB1_HSIC_STROBE_WD_MASK (0x3 << 18)
780#define OMAP4_USBB2_HSIC_DATA_WD_SHIFT 16
781#define OMAP4_USBB2_HSIC_DATA_WD_MASK (0x3 << 16)
782#define OMAP4_USBB2_HSIC_STROBE_WD_SHIFT 14
783#define OMAP4_USBB2_HSIC_STROBE_WD_MASK (0x3 << 14)
784#define OMAP4_USBB1_HSIC_DATA_OFFMODE_WD_ENABLE_SHIFT 13
785#define OMAP4_USBB1_HSIC_DATA_OFFMODE_WD_ENABLE_MASK (1 << 13)
786#define OMAP4_USBB1_HSIC_DATA_OFFMODE_WD_SHIFT 11
787#define OMAP4_USBB1_HSIC_DATA_OFFMODE_WD_MASK (0x3 << 11)
788#define OMAP4_USBB1_HSIC_STROBE_OFFMODE_WD_ENABLE_SHIFT 10
789#define OMAP4_USBB1_HSIC_STROBE_OFFMODE_WD_ENABLE_MASK (1 << 10)
790#define OMAP4_USBB1_HSIC_STROBE_OFFMODE_WD_SHIFT 8
791#define OMAP4_USBB1_HSIC_STROBE_OFFMODE_WD_MASK (0x3 << 8)
792#define OMAP4_USBB2_HSIC_DATA_OFFMODE_WD_ENABLE_SHIFT 7
793#define OMAP4_USBB2_HSIC_DATA_OFFMODE_WD_ENABLE_MASK (1 << 7)
794#define OMAP4_USBB2_HSIC_DATA_OFFMODE_WD_SHIFT 5
795#define OMAP4_USBB2_HSIC_DATA_OFFMODE_WD_MASK (0x3 << 5)
796#define OMAP4_USBB2_HSIC_STROBE_OFFMODE_WD_ENABLE_SHIFT 4
797#define OMAP4_USBB2_HSIC_STROBE_OFFMODE_WD_ENABLE_MASK (1 << 4)
798#define OMAP4_USBB2_HSIC_STROBE_OFFMODE_WD_SHIFT 2
799#define OMAP4_USBB2_HSIC_STROBE_OFFMODE_WD_MASK (0x3 << 2)
800
801/* CONTROL_SLIMBUS */
802#define OMAP4_SLIMBUS1_DR0_MB_SHIFT 30
803#define OMAP4_SLIMBUS1_DR0_MB_MASK (0x3 << 30)
804#define OMAP4_SLIMBUS1_DR1_MB_SHIFT 28
805#define OMAP4_SLIMBUS1_DR1_MB_MASK (0x3 << 28)
806#define OMAP4_SLIMBUS2_DR0_MB_SHIFT 26
807#define OMAP4_SLIMBUS2_DR0_MB_MASK (0x3 << 26)
808#define OMAP4_SLIMBUS2_DR1_MB_SHIFT 24
809#define OMAP4_SLIMBUS2_DR1_MB_MASK (0x3 << 24)
810#define OMAP4_SLIMBUS2_DR2_MB_SHIFT 22
811#define OMAP4_SLIMBUS2_DR2_MB_MASK (0x3 << 22)
812#define OMAP4_SLIMBUS2_DR3_MB_SHIFT 20
813#define OMAP4_SLIMBUS2_DR3_MB_MASK (0x3 << 20)
814#define OMAP4_SLIMBUS1_DR0_LB_SHIFT 19
815#define OMAP4_SLIMBUS1_DR0_LB_MASK (1 << 19)
816#define OMAP4_SLIMBUS2_DR1_LB_SHIFT 18
817#define OMAP4_SLIMBUS2_DR1_LB_MASK (1 << 18)
818
819/* CONTROL_PBIASLITE */
820#define OMAP4_USIM_PBIASLITE_HIZ_MODE_SHIFT 31
821#define OMAP4_USIM_PBIASLITE_HIZ_MODE_MASK (1 << 31)
822#define OMAP4_USIM_PBIASLITE_SUPPLY_HI_OUT_SHIFT 30
823#define OMAP4_USIM_PBIASLITE_SUPPLY_HI_OUT_MASK (1 << 30)
824#define OMAP4_USIM_PBIASLITE_VMODE_ERROR_SHIFT 29
825#define OMAP4_USIM_PBIASLITE_VMODE_ERROR_MASK (1 << 29)
826#define OMAP4_USIM_PBIASLITE_PWRDNZ_SHIFT 28
827#define OMAP4_USIM_PBIASLITE_PWRDNZ_MASK (1 << 28)
828#define OMAP4_USIM_PBIASLITE_VMODE_SHIFT 27
829#define OMAP4_USIM_PBIASLITE_VMODE_MASK (1 << 27)
830#define OMAP4_MMC1_PWRDNZ_SHIFT 26
831#define OMAP4_MMC1_PWRDNZ_MASK (1 << 26)
832#define OMAP4_MMC1_PBIASLITE_HIZ_MODE_SHIFT 25
833#define OMAP4_MMC1_PBIASLITE_HIZ_MODE_MASK (1 << 25)
834#define OMAP4_MMC1_PBIASLITE_SUPPLY_HI_OUT_SHIFT 24
835#define OMAP4_MMC1_PBIASLITE_SUPPLY_HI_OUT_MASK (1 << 24)
836#define OMAP4_MMC1_PBIASLITE_VMODE_ERROR_SHIFT 23
837#define OMAP4_MMC1_PBIASLITE_VMODE_ERROR_MASK (1 << 23)
838#define OMAP4_MMC1_PBIASLITE_PWRDNZ_SHIFT 22
839#define OMAP4_MMC1_PBIASLITE_PWRDNZ_MASK (1 << 22)
840#define OMAP4_MMC1_PBIASLITE_VMODE_SHIFT 21
841#define OMAP4_MMC1_PBIASLITE_VMODE_MASK (1 << 21)
842#define OMAP4_USBC1_ICUSB_PWRDNZ_SHIFT 20
843#define OMAP4_USBC1_ICUSB_PWRDNZ_MASK (1 << 20)
844
845/* CONTROL_I2C_0 */
846#define OMAP4_I2C4_SDA_GLFENB_SHIFT 31
847#define OMAP4_I2C4_SDA_GLFENB_MASK (1 << 31)
848#define OMAP4_I2C4_SDA_LOAD_BITS_SHIFT 29
849#define OMAP4_I2C4_SDA_LOAD_BITS_MASK (0x3 << 29)
850#define OMAP4_I2C4_SDA_PULLUPRESX_SHIFT 28
851#define OMAP4_I2C4_SDA_PULLUPRESX_MASK (1 << 28)
852#define OMAP4_I2C3_SDA_GLFENB_SHIFT 27
853#define OMAP4_I2C3_SDA_GLFENB_MASK (1 << 27)
854#define OMAP4_I2C3_SDA_LOAD_BITS_SHIFT 25
855#define OMAP4_I2C3_SDA_LOAD_BITS_MASK (0x3 << 25)
856#define OMAP4_I2C3_SDA_PULLUPRESX_SHIFT 24
857#define OMAP4_I2C3_SDA_PULLUPRESX_MASK (1 << 24)
858#define OMAP4_I2C2_SDA_GLFENB_SHIFT 23
859#define OMAP4_I2C2_SDA_GLFENB_MASK (1 << 23)
860#define OMAP4_I2C2_SDA_LOAD_BITS_SHIFT 21
861#define OMAP4_I2C2_SDA_LOAD_BITS_MASK (0x3 << 21)
862#define OMAP4_I2C2_SDA_PULLUPRESX_SHIFT 20
863#define OMAP4_I2C2_SDA_PULLUPRESX_MASK (1 << 20)
864#define OMAP4_I2C1_SDA_GLFENB_SHIFT 19
865#define OMAP4_I2C1_SDA_GLFENB_MASK (1 << 19)
866#define OMAP4_I2C1_SDA_LOAD_BITS_SHIFT 17
867#define OMAP4_I2C1_SDA_LOAD_BITS_MASK (0x3 << 17)
868#define OMAP4_I2C1_SDA_PULLUPRESX_SHIFT 16
869#define OMAP4_I2C1_SDA_PULLUPRESX_MASK (1 << 16)
870#define OMAP4_I2C4_SCL_GLFENB_SHIFT 15
871#define OMAP4_I2C4_SCL_GLFENB_MASK (1 << 15)
872#define OMAP4_I2C4_SCL_LOAD_BITS_SHIFT 13
873#define OMAP4_I2C4_SCL_LOAD_BITS_MASK (0x3 << 13)
874#define OMAP4_I2C4_SCL_PULLUPRESX_SHIFT 12
875#define OMAP4_I2C4_SCL_PULLUPRESX_MASK (1 << 12)
876#define OMAP4_I2C3_SCL_GLFENB_SHIFT 11
877#define OMAP4_I2C3_SCL_GLFENB_MASK (1 << 11)
878#define OMAP4_I2C3_SCL_LOAD_BITS_SHIFT 9
879#define OMAP4_I2C3_SCL_LOAD_BITS_MASK (0x3 << 9)
880#define OMAP4_I2C3_SCL_PULLUPRESX_SHIFT 8
881#define OMAP4_I2C3_SCL_PULLUPRESX_MASK (1 << 8)
882#define OMAP4_I2C2_SCL_GLFENB_SHIFT 7
883#define OMAP4_I2C2_SCL_GLFENB_MASK (1 << 7)
884#define OMAP4_I2C2_SCL_LOAD_BITS_SHIFT 5
885#define OMAP4_I2C2_SCL_LOAD_BITS_MASK (0x3 << 5)
886#define OMAP4_I2C2_SCL_PULLUPRESX_SHIFT 4
887#define OMAP4_I2C2_SCL_PULLUPRESX_MASK (1 << 4)
888#define OMAP4_I2C1_SCL_GLFENB_SHIFT 3
889#define OMAP4_I2C1_SCL_GLFENB_MASK (1 << 3)
890#define OMAP4_I2C1_SCL_LOAD_BITS_SHIFT 1
891#define OMAP4_I2C1_SCL_LOAD_BITS_MASK (0x3 << 1)
892#define OMAP4_I2C1_SCL_PULLUPRESX_SHIFT 0
893#define OMAP4_I2C1_SCL_PULLUPRESX_MASK (1 << 0)
894
895/* CONTROL_CAMERA_RX */
896#define OMAP4_CAMERARX_UNIPRO_CTRLCLKEN_SHIFT 31
897#define OMAP4_CAMERARX_UNIPRO_CTRLCLKEN_MASK (1 << 31)
898#define OMAP4_CAMERARX_CSI22_LANEENABLE_SHIFT 29
899#define OMAP4_CAMERARX_CSI22_LANEENABLE_MASK (0x3 << 29)
900#define OMAP4_CAMERARX_CSI21_LANEENABLE_SHIFT 24
901#define OMAP4_CAMERARX_CSI21_LANEENABLE_MASK (0x1f << 24)
902#define OMAP4_CAMERARX_UNIPRO_CAMMODE_SHIFT 22
903#define OMAP4_CAMERARX_UNIPRO_CAMMODE_MASK (0x3 << 22)
904#define OMAP4_CAMERARX_CSI22_CTRLCLKEN_SHIFT 21
905#define OMAP4_CAMERARX_CSI22_CTRLCLKEN_MASK (1 << 21)
906#define OMAP4_CAMERARX_CSI22_CAMMODE_SHIFT 19
907#define OMAP4_CAMERARX_CSI22_CAMMODE_MASK (0x3 << 19)
908#define OMAP4_CAMERARX_CSI21_CTRLCLKEN_SHIFT 18
909#define OMAP4_CAMERARX_CSI21_CTRLCLKEN_MASK (1 << 18)
910#define OMAP4_CAMERARX_CSI21_CAMMODE_SHIFT 16
911#define OMAP4_CAMERARX_CSI21_CAMMODE_MASK (0x3 << 16)
912
913/* CONTROL_AVDAC */
914#define OMAP4_AVDAC_ACEN_SHIFT 31
915#define OMAP4_AVDAC_ACEN_MASK (1 << 31)
916#define OMAP4_AVDAC_TVOUTBYPASS_SHIFT 30
917#define OMAP4_AVDAC_TVOUTBYPASS_MASK (1 << 30)
918#define OMAP4_AVDAC_INPUTINV_SHIFT 29
919#define OMAP4_AVDAC_INPUTINV_MASK (1 << 29)
920#define OMAP4_AVDAC_CTL_SHIFT 13
921#define OMAP4_AVDAC_CTL_MASK (0xffff << 13)
922#define OMAP4_AVDAC_CTL_WR_ACK_SHIFT 12
923#define OMAP4_AVDAC_CTL_WR_ACK_MASK (1 << 12)
924
925/* CONTROL_HDMI_TX_PHY */
926#define OMAP4_HDMITXPHY_PADORDER_SHIFT 31
927#define OMAP4_HDMITXPHY_PADORDER_MASK (1 << 31)
928#define OMAP4_HDMITXPHY_TXVALID_SHIFT 30
929#define OMAP4_HDMITXPHY_TXVALID_MASK (1 << 30)
930#define OMAP4_HDMITXPHY_ENBYPASSCLK_SHIFT 29
931#define OMAP4_HDMITXPHY_ENBYPASSCLK_MASK (1 << 29)
932#define OMAP4_HDMITXPHY_PD_PULLUPDET_SHIFT 28
933#define OMAP4_HDMITXPHY_PD_PULLUPDET_MASK (1 << 28)
934
935/* CONTROL_MMC2 */
936#define OMAP4_MMC2_FEEDBACK_CLK_SEL_SHIFT 31
937#define OMAP4_MMC2_FEEDBACK_CLK_SEL_MASK (1 << 31)
938
939/* CONTROL_DSIPHY */
940#define OMAP4_DSI2_LANEENABLE_SHIFT 29
941#define OMAP4_DSI2_LANEENABLE_MASK (0x7 << 29)
942#define OMAP4_DSI1_LANEENABLE_SHIFT 24
943#define OMAP4_DSI1_LANEENABLE_MASK (0x1f << 24)
944#define OMAP4_DSI1_PIPD_SHIFT 19
945#define OMAP4_DSI1_PIPD_MASK (0x1f << 19)
946#define OMAP4_DSI2_PIPD_SHIFT 14
947#define OMAP4_DSI2_PIPD_MASK (0x1f << 14)
948
949/* CONTROL_MCBSPLP */
950#define OMAP4_ALBCTRLRX_FSX_SHIFT 31
951#define OMAP4_ALBCTRLRX_FSX_MASK (1 << 31)
952#define OMAP4_ALBCTRLRX_CLKX_SHIFT 30
953#define OMAP4_ALBCTRLRX_CLKX_MASK (1 << 30)
954#define OMAP4_ABE_MCBSP1_DR_EN_SHIFT 29
955#define OMAP4_ABE_MCBSP1_DR_EN_MASK (1 << 29)
956
957/* CONTROL_USB2PHYCORE */
958#define OMAP4_USB2PHY_AUTORESUME_EN_SHIFT 31
959#define OMAP4_USB2PHY_AUTORESUME_EN_MASK (1 << 31)
960#define OMAP4_USB2PHY_DISCHGDET_SHIFT 30
961#define OMAP4_USB2PHY_DISCHGDET_MASK (1 << 30)
962#define OMAP4_USB2PHY_GPIOMODE_SHIFT 29
963#define OMAP4_USB2PHY_GPIOMODE_MASK (1 << 29)
964#define OMAP4_USB2PHY_CHG_DET_EXT_CTL_SHIFT 28
965#define OMAP4_USB2PHY_CHG_DET_EXT_CTL_MASK (1 << 28)
966#define OMAP4_USB2PHY_RDM_PD_CHGDET_EN_SHIFT 27
967#define OMAP4_USB2PHY_RDM_PD_CHGDET_EN_MASK (1 << 27)
968#define OMAP4_USB2PHY_RDP_PU_CHGDET_EN_SHIFT 26
969#define OMAP4_USB2PHY_RDP_PU_CHGDET_EN_MASK (1 << 26)
970#define OMAP4_USB2PHY_CHG_VSRC_EN_SHIFT 25
971#define OMAP4_USB2PHY_CHG_VSRC_EN_MASK (1 << 25)
972#define OMAP4_USB2PHY_CHG_ISINK_EN_SHIFT 24
973#define OMAP4_USB2PHY_CHG_ISINK_EN_MASK (1 << 24)
974#define OMAP4_USB2PHY_CHG_DET_STATUS_SHIFT 21
975#define OMAP4_USB2PHY_CHG_DET_STATUS_MASK (0x7 << 21)
976#define OMAP4_USB2PHY_CHG_DET_DM_COMP_SHIFT 20
977#define OMAP4_USB2PHY_CHG_DET_DM_COMP_MASK (1 << 20)
978#define OMAP4_USB2PHY_CHG_DET_DP_COMP_SHIFT 19
979#define OMAP4_USB2PHY_CHG_DET_DP_COMP_MASK (1 << 19)
980#define OMAP4_USB2PHY_DATADET_SHIFT 18
981#define OMAP4_USB2PHY_DATADET_MASK (1 << 18)
982#define OMAP4_USB2PHY_SINKONDP_SHIFT 17
983#define OMAP4_USB2PHY_SINKONDP_MASK (1 << 17)
984#define OMAP4_USB2PHY_SRCONDM_SHIFT 16
985#define OMAP4_USB2PHY_SRCONDM_MASK (1 << 16)
986#define OMAP4_USB2PHY_RESTARTCHGDET_SHIFT 15
987#define OMAP4_USB2PHY_RESTARTCHGDET_MASK (1 << 15)
988#define OMAP4_USB2PHY_CHGDETDONE_SHIFT 14
989#define OMAP4_USB2PHY_CHGDETDONE_MASK (1 << 14)
990#define OMAP4_USB2PHY_CHGDETECTED_SHIFT 13
991#define OMAP4_USB2PHY_CHGDETECTED_MASK (1 << 13)
992#define OMAP4_USB2PHY_MCPCPUEN_SHIFT 12
993#define OMAP4_USB2PHY_MCPCPUEN_MASK (1 << 12)
994#define OMAP4_USB2PHY_MCPCMODEEN_SHIFT 11
995#define OMAP4_USB2PHY_MCPCMODEEN_MASK (1 << 11)
996#define OMAP4_USB2PHY_RESETDONEMCLK_SHIFT 10
997#define OMAP4_USB2PHY_RESETDONEMCLK_MASK (1 << 10)
998#define OMAP4_USB2PHY_UTMIRESETDONE_SHIFT 9
999#define OMAP4_USB2PHY_UTMIRESETDONE_MASK (1 << 9)
1000#define OMAP4_USB2PHY_TXBITSTUFFENABLE_SHIFT 8
1001#define OMAP4_USB2PHY_TXBITSTUFFENABLE_MASK (1 << 8)
1002#define OMAP4_USB2PHY_DATAPOLARITYN_SHIFT 7
1003#define OMAP4_USB2PHY_DATAPOLARITYN_MASK (1 << 7)
1004#define OMAP4_USBDPLL_FREQLOCK_SHIFT 6
1005#define OMAP4_USBDPLL_FREQLOCK_MASK (1 << 6)
1006#define OMAP4_USB2PHY_RESETDONETCLK_SHIFT 5
1007#define OMAP4_USB2PHY_RESETDONETCLK_MASK (1 << 5)
1008
1009/* CONTROL_I2C_1 */
1010#define OMAP4_HDMI_DDC_SDA_GLFENB_SHIFT 31
1011#define OMAP4_HDMI_DDC_SDA_GLFENB_MASK (1 << 31)
1012#define OMAP4_HDMI_DDC_SDA_LOAD_BITS_SHIFT 29
1013#define OMAP4_HDMI_DDC_SDA_LOAD_BITS_MASK (0x3 << 29)
1014#define OMAP4_HDMI_DDC_SDA_PULLUPRESX_SHIFT 28
1015#define OMAP4_HDMI_DDC_SDA_PULLUPRESX_MASK (1 << 28)
1016#define OMAP4_HDMI_DDC_SCL_GLFENB_SHIFT 27
1017#define OMAP4_HDMI_DDC_SCL_GLFENB_MASK (1 << 27)
1018#define OMAP4_HDMI_DDC_SCL_LOAD_BITS_SHIFT 25
1019#define OMAP4_HDMI_DDC_SCL_LOAD_BITS_MASK (0x3 << 25)
1020#define OMAP4_HDMI_DDC_SCL_PULLUPRESX_SHIFT 24
1021#define OMAP4_HDMI_DDC_SCL_PULLUPRESX_MASK (1 << 24)
1022#define OMAP4_HDMI_DDC_SDA_HSMODE_SHIFT 23
1023#define OMAP4_HDMI_DDC_SDA_HSMODE_MASK (1 << 23)
1024#define OMAP4_HDMI_DDC_SDA_NMODE_SHIFT 22
1025#define OMAP4_HDMI_DDC_SDA_NMODE_MASK (1 << 22)
1026#define OMAP4_HDMI_DDC_SCL_HSMODE_SHIFT 21
1027#define OMAP4_HDMI_DDC_SCL_HSMODE_MASK (1 << 21)
1028#define OMAP4_HDMI_DDC_SCL_NMODE_SHIFT 20
1029#define OMAP4_HDMI_DDC_SCL_NMODE_MASK (1 << 20)
1030
1031/* CONTROL_MMC1 */
1032#define OMAP4_SDMMC1_PUSTRENGTH_GRP0_SHIFT 31
1033#define OMAP4_SDMMC1_PUSTRENGTH_GRP0_MASK (1 << 31)
1034#define OMAP4_SDMMC1_PUSTRENGTH_GRP1_SHIFT 30
1035#define OMAP4_SDMMC1_PUSTRENGTH_GRP1_MASK (1 << 30)
1036#define OMAP4_SDMMC1_PUSTRENGTH_GRP2_SHIFT 29
1037#define OMAP4_SDMMC1_PUSTRENGTH_GRP2_MASK (1 << 29)
1038#define OMAP4_SDMMC1_PUSTRENGTH_GRP3_SHIFT 28
1039#define OMAP4_SDMMC1_PUSTRENGTH_GRP3_MASK (1 << 28)
1040#define OMAP4_SDMMC1_DR0_SPEEDCTRL_SHIFT 27
1041#define OMAP4_SDMMC1_DR0_SPEEDCTRL_MASK (1 << 27)
1042#define OMAP4_SDMMC1_DR1_SPEEDCTRL_SHIFT 26
1043#define OMAP4_SDMMC1_DR1_SPEEDCTRL_MASK (1 << 26)
1044#define OMAP4_SDMMC1_DR2_SPEEDCTRL_SHIFT 25
1045#define OMAP4_SDMMC1_DR2_SPEEDCTRL_MASK (1 << 25)
1046#define OMAP4_USBC1_DR0_SPEEDCTRL_SHIFT 24
1047#define OMAP4_USBC1_DR0_SPEEDCTRL_MASK (1 << 24)
1048#define OMAP4_USB_FD_CDEN_SHIFT 23
1049#define OMAP4_USB_FD_CDEN_MASK (1 << 23)
1050#define OMAP4_USBC1_ICUSB_DP_PDDIS_SHIFT 22
1051#define OMAP4_USBC1_ICUSB_DP_PDDIS_MASK (1 << 22)
1052#define OMAP4_USBC1_ICUSB_DM_PDDIS_SHIFT 21
1053#define OMAP4_USBC1_ICUSB_DM_PDDIS_MASK (1 << 21)
1054
1055/* CONTROL_HSI */
1056#define OMAP4_HSI1_CALLOOP_SEL_SHIFT 31
1057#define OMAP4_HSI1_CALLOOP_SEL_MASK (1 << 31)
1058#define OMAP4_HSI1_CALMUX_SEL_SHIFT 30
1059#define OMAP4_HSI1_CALMUX_SEL_MASK (1 << 30)
1060#define OMAP4_HSI2_CALLOOP_SEL_SHIFT 29
1061#define OMAP4_HSI2_CALLOOP_SEL_MASK (1 << 29)
1062#define OMAP4_HSI2_CALMUX_SEL_SHIFT 28
1063#define OMAP4_HSI2_CALMUX_SEL_MASK (1 << 28)
1064
1065/* CONTROL_USB */
1066#define OMAP4_CARKIT_USBA0_ULPIPHY_DAT0_AUTO_EN_SHIFT 31
1067#define OMAP4_CARKIT_USBA0_ULPIPHY_DAT0_AUTO_EN_MASK (1 << 31)
1068#define OMAP4_CARKIT_USBA0_ULPIPHY_DAT1_AUTO_EN_SHIFT 30
1069#define OMAP4_CARKIT_USBA0_ULPIPHY_DAT1_AUTO_EN_MASK (1 << 30)
1070
1071/* CONTROL_HDQ */
1072#define OMAP4_HDQ_SIO_PWRDNZ_SHIFT 31
1073#define OMAP4_HDQ_SIO_PWRDNZ_MASK (1 << 31)
1074
1075/* CONTROL_LPDDR2IO1_0 */
1076#define OMAP4_LPDDR2IO1_GR4_SR_SHIFT 30
1077#define OMAP4_LPDDR2IO1_GR4_SR_MASK (0x3 << 30)
1078#define OMAP4_LPDDR2IO1_GR4_I_SHIFT 27
1079#define OMAP4_LPDDR2IO1_GR4_I_MASK (0x7 << 27)
1080#define OMAP4_LPDDR2IO1_GR4_WD_SHIFT 25
1081#define OMAP4_LPDDR2IO1_GR4_WD_MASK (0x3 << 25)
1082#define OMAP4_LPDDR2IO1_GR3_SR_SHIFT 22
1083#define OMAP4_LPDDR2IO1_GR3_SR_MASK (0x3 << 22)
1084#define OMAP4_LPDDR2IO1_GR3_I_SHIFT 19
1085#define OMAP4_LPDDR2IO1_GR3_I_MASK (0x7 << 19)
1086#define OMAP4_LPDDR2IO1_GR3_WD_SHIFT 17
1087#define OMAP4_LPDDR2IO1_GR3_WD_MASK (0x3 << 17)
1088#define OMAP4_LPDDR2IO1_GR2_SR_SHIFT 14
1089#define OMAP4_LPDDR2IO1_GR2_SR_MASK (0x3 << 14)
1090#define OMAP4_LPDDR2IO1_GR2_I_SHIFT 11
1091#define OMAP4_LPDDR2IO1_GR2_I_MASK (0x7 << 11)
1092#define OMAP4_LPDDR2IO1_GR2_WD_SHIFT 9
1093#define OMAP4_LPDDR2IO1_GR2_WD_MASK (0x3 << 9)
1094#define OMAP4_LPDDR2IO1_GR1_SR_SHIFT 6
1095#define OMAP4_LPDDR2IO1_GR1_SR_MASK (0x3 << 6)
1096#define OMAP4_LPDDR2IO1_GR1_I_SHIFT 3
1097#define OMAP4_LPDDR2IO1_GR1_I_MASK (0x7 << 3)
1098#define OMAP4_LPDDR2IO1_GR1_WD_SHIFT 1
1099#define OMAP4_LPDDR2IO1_GR1_WD_MASK (0x3 << 1)
1100
1101/* CONTROL_LPDDR2IO1_1 */
1102#define OMAP4_LPDDR2IO1_GR8_SR_SHIFT 30
1103#define OMAP4_LPDDR2IO1_GR8_SR_MASK (0x3 << 30)
1104#define OMAP4_LPDDR2IO1_GR8_I_SHIFT 27
1105#define OMAP4_LPDDR2IO1_GR8_I_MASK (0x7 << 27)
1106#define OMAP4_LPDDR2IO1_GR8_WD_SHIFT 25
1107#define OMAP4_LPDDR2IO1_GR8_WD_MASK (0x3 << 25)
1108#define OMAP4_LPDDR2IO1_GR7_SR_SHIFT 22
1109#define OMAP4_LPDDR2IO1_GR7_SR_MASK (0x3 << 22)
1110#define OMAP4_LPDDR2IO1_GR7_I_SHIFT 19
1111#define OMAP4_LPDDR2IO1_GR7_I_MASK (0x7 << 19)
1112#define OMAP4_LPDDR2IO1_GR7_WD_SHIFT 17
1113#define OMAP4_LPDDR2IO1_GR7_WD_MASK (0x3 << 17)
1114#define OMAP4_LPDDR2IO1_GR6_SR_SHIFT 14
1115#define OMAP4_LPDDR2IO1_GR6_SR_MASK (0x3 << 14)
1116#define OMAP4_LPDDR2IO1_GR6_I_SHIFT 11
1117#define OMAP4_LPDDR2IO1_GR6_I_MASK (0x7 << 11)
1118#define OMAP4_LPDDR2IO1_GR6_WD_SHIFT 9
1119#define OMAP4_LPDDR2IO1_GR6_WD_MASK (0x3 << 9)
1120#define OMAP4_LPDDR2IO1_GR5_SR_SHIFT 6
1121#define OMAP4_LPDDR2IO1_GR5_SR_MASK (0x3 << 6)
1122#define OMAP4_LPDDR2IO1_GR5_I_SHIFT 3
1123#define OMAP4_LPDDR2IO1_GR5_I_MASK (0x7 << 3)
1124#define OMAP4_LPDDR2IO1_GR5_WD_SHIFT 1
1125#define OMAP4_LPDDR2IO1_GR5_WD_MASK (0x3 << 1)
1126
1127/* CONTROL_LPDDR2IO1_2 */
1128#define OMAP4_LPDDR2IO1_GR11_SR_SHIFT 30
1129#define OMAP4_LPDDR2IO1_GR11_SR_MASK (0x3 << 30)
1130#define OMAP4_LPDDR2IO1_GR11_I_SHIFT 27
1131#define OMAP4_LPDDR2IO1_GR11_I_MASK (0x7 << 27)
1132#define OMAP4_LPDDR2IO1_GR11_WD_SHIFT 25
1133#define OMAP4_LPDDR2IO1_GR11_WD_MASK (0x3 << 25)
1134#define OMAP4_LPDDR2IO1_GR10_SR_SHIFT 22
1135#define OMAP4_LPDDR2IO1_GR10_SR_MASK (0x3 << 22)
1136#define OMAP4_LPDDR2IO1_GR10_I_SHIFT 19
1137#define OMAP4_LPDDR2IO1_GR10_I_MASK (0x7 << 19)
1138#define OMAP4_LPDDR2IO1_GR10_WD_SHIFT 17
1139#define OMAP4_LPDDR2IO1_GR10_WD_MASK (0x3 << 17)
1140#define OMAP4_LPDDR2IO1_GR9_SR_SHIFT 14
1141#define OMAP4_LPDDR2IO1_GR9_SR_MASK (0x3 << 14)
1142#define OMAP4_LPDDR2IO1_GR9_I_SHIFT 11
1143#define OMAP4_LPDDR2IO1_GR9_I_MASK (0x7 << 11)
1144#define OMAP4_LPDDR2IO1_GR9_WD_SHIFT 9
1145#define OMAP4_LPDDR2IO1_GR9_WD_MASK (0x3 << 9)
1146
1147/* CONTROL_LPDDR2IO1_3 */
1148#define OMAP4_LPDDR21_VREF_CA_CCAP0_SHIFT 31
1149#define OMAP4_LPDDR21_VREF_CA_CCAP0_MASK (1 << 31)
1150#define OMAP4_LPDDR21_VREF_CA_CCAP1_SHIFT 30
1151#define OMAP4_LPDDR21_VREF_CA_CCAP1_MASK (1 << 30)
1152#define OMAP4_LPDDR21_VREF_CA_INT_CCAP0_SHIFT 29
1153#define OMAP4_LPDDR21_VREF_CA_INT_CCAP0_MASK (1 << 29)
1154#define OMAP4_LPDDR21_VREF_CA_INT_CCAP1_SHIFT 28
1155#define OMAP4_LPDDR21_VREF_CA_INT_CCAP1_MASK (1 << 28)
1156#define OMAP4_LPDDR21_VREF_CA_INT_TAP0_SHIFT 27
1157#define OMAP4_LPDDR21_VREF_CA_INT_TAP0_MASK (1 << 27)
1158#define OMAP4_LPDDR21_VREF_CA_INT_TAP1_SHIFT 26
1159#define OMAP4_LPDDR21_VREF_CA_INT_TAP1_MASK (1 << 26)
1160#define OMAP4_LPDDR21_VREF_CA_TAP0_SHIFT 25
1161#define OMAP4_LPDDR21_VREF_CA_TAP0_MASK (1 << 25)
1162#define OMAP4_LPDDR21_VREF_CA_TAP1_SHIFT 24
1163#define OMAP4_LPDDR21_VREF_CA_TAP1_MASK (1 << 24)
1164#define OMAP4_LPDDR21_VREF_DQ0_INT_CCAP0_SHIFT 23
1165#define OMAP4_LPDDR21_VREF_DQ0_INT_CCAP0_MASK (1 << 23)
1166#define OMAP4_LPDDR21_VREF_DQ0_INT_CCAP1_SHIFT 22
1167#define OMAP4_LPDDR21_VREF_DQ0_INT_CCAP1_MASK (1 << 22)
1168#define OMAP4_LPDDR21_VREF_DQ0_INT_TAP0_SHIFT 21
1169#define OMAP4_LPDDR21_VREF_DQ0_INT_TAP0_MASK (1 << 21)
1170#define OMAP4_LPDDR21_VREF_DQ0_INT_TAP1_SHIFT 20
1171#define OMAP4_LPDDR21_VREF_DQ0_INT_TAP1_MASK (1 << 20)
1172#define OMAP4_LPDDR21_VREF_DQ1_INT_CCAP0_SHIFT 19
1173#define OMAP4_LPDDR21_VREF_DQ1_INT_CCAP0_MASK (1 << 19)
1174#define OMAP4_LPDDR21_VREF_DQ1_INT_CCAP1_SHIFT 18
1175#define OMAP4_LPDDR21_VREF_DQ1_INT_CCAP1_MASK (1 << 18)
1176#define OMAP4_LPDDR21_VREF_DQ1_INT_TAP0_SHIFT 17
1177#define OMAP4_LPDDR21_VREF_DQ1_INT_TAP0_MASK (1 << 17)
1178#define OMAP4_LPDDR21_VREF_DQ1_INT_TAP1_SHIFT 16
1179#define OMAP4_LPDDR21_VREF_DQ1_INT_TAP1_MASK (1 << 16)
1180#define OMAP4_LPDDR21_VREF_DQ_CCAP0_SHIFT 15
1181#define OMAP4_LPDDR21_VREF_DQ_CCAP0_MASK (1 << 15)
1182#define OMAP4_LPDDR21_VREF_DQ_CCAP1_SHIFT 14
1183#define OMAP4_LPDDR21_VREF_DQ_CCAP1_MASK (1 << 14)
1184#define OMAP4_LPDDR21_VREF_DQ_TAP0_SHIFT 13
1185#define OMAP4_LPDDR21_VREF_DQ_TAP0_MASK (1 << 13)
1186#define OMAP4_LPDDR21_VREF_DQ_TAP1_SHIFT 12
1187#define OMAP4_LPDDR21_VREF_DQ_TAP1_MASK (1 << 12)
1188
1189/* CONTROL_LPDDR2IO2_0 */
1190#define OMAP4_LPDDR2IO2_GR4_SR_SHIFT 30
1191#define OMAP4_LPDDR2IO2_GR4_SR_MASK (0x3 << 30)
1192#define OMAP4_LPDDR2IO2_GR4_I_SHIFT 27
1193#define OMAP4_LPDDR2IO2_GR4_I_MASK (0x7 << 27)
1194#define OMAP4_LPDDR2IO2_GR4_WD_SHIFT 25
1195#define OMAP4_LPDDR2IO2_GR4_WD_MASK (0x3 << 25)
1196#define OMAP4_LPDDR2IO2_GR3_SR_SHIFT 22
1197#define OMAP4_LPDDR2IO2_GR3_SR_MASK (0x3 << 22)
1198#define OMAP4_LPDDR2IO2_GR3_I_SHIFT 19
1199#define OMAP4_LPDDR2IO2_GR3_I_MASK (0x7 << 19)
1200#define OMAP4_LPDDR2IO2_GR3_WD_SHIFT 17
1201#define OMAP4_LPDDR2IO2_GR3_WD_MASK (0x3 << 17)
1202#define OMAP4_LPDDR2IO2_GR2_SR_SHIFT 14
1203#define OMAP4_LPDDR2IO2_GR2_SR_MASK (0x3 << 14)
1204#define OMAP4_LPDDR2IO2_GR2_I_SHIFT 11
1205#define OMAP4_LPDDR2IO2_GR2_I_MASK (0x7 << 11)
1206#define OMAP4_LPDDR2IO2_GR2_WD_SHIFT 9
1207#define OMAP4_LPDDR2IO2_GR2_WD_MASK (0x3 << 9)
1208#define OMAP4_LPDDR2IO2_GR1_SR_SHIFT 6
1209#define OMAP4_LPDDR2IO2_GR1_SR_MASK (0x3 << 6)
1210#define OMAP4_LPDDR2IO2_GR1_I_SHIFT 3
1211#define OMAP4_LPDDR2IO2_GR1_I_MASK (0x7 << 3)
1212#define OMAP4_LPDDR2IO2_GR1_WD_SHIFT 1
1213#define OMAP4_LPDDR2IO2_GR1_WD_MASK (0x3 << 1)
1214
1215/* CONTROL_LPDDR2IO2_1 */
1216#define OMAP4_LPDDR2IO2_GR8_SR_SHIFT 30
1217#define OMAP4_LPDDR2IO2_GR8_SR_MASK (0x3 << 30)
1218#define OMAP4_LPDDR2IO2_GR8_I_SHIFT 27
1219#define OMAP4_LPDDR2IO2_GR8_I_MASK (0x7 << 27)
1220#define OMAP4_LPDDR2IO2_GR8_WD_SHIFT 25
1221#define OMAP4_LPDDR2IO2_GR8_WD_MASK (0x3 << 25)
1222#define OMAP4_LPDDR2IO2_GR7_SR_SHIFT 22
1223#define OMAP4_LPDDR2IO2_GR7_SR_MASK (0x3 << 22)
1224#define OMAP4_LPDDR2IO2_GR7_I_SHIFT 19
1225#define OMAP4_LPDDR2IO2_GR7_I_MASK (0x7 << 19)
1226#define OMAP4_LPDDR2IO2_GR7_WD_SHIFT 17
1227#define OMAP4_LPDDR2IO2_GR7_WD_MASK (0x3 << 17)
1228#define OMAP4_LPDDR2IO2_GR6_SR_SHIFT 14
1229#define OMAP4_LPDDR2IO2_GR6_SR_MASK (0x3 << 14)
1230#define OMAP4_LPDDR2IO2_GR6_I_SHIFT 11
1231#define OMAP4_LPDDR2IO2_GR6_I_MASK (0x7 << 11)
1232#define OMAP4_LPDDR2IO2_GR6_WD_SHIFT 9
1233#define OMAP4_LPDDR2IO2_GR6_WD_MASK (0x3 << 9)
1234#define OMAP4_LPDDR2IO2_GR5_SR_SHIFT 6
1235#define OMAP4_LPDDR2IO2_GR5_SR_MASK (0x3 << 6)
1236#define OMAP4_LPDDR2IO2_GR5_I_SHIFT 3
1237#define OMAP4_LPDDR2IO2_GR5_I_MASK (0x7 << 3)
1238#define OMAP4_LPDDR2IO2_GR5_WD_SHIFT 1
1239#define OMAP4_LPDDR2IO2_GR5_WD_MASK (0x3 << 1)
1240
1241/* CONTROL_LPDDR2IO2_2 */
1242#define OMAP4_LPDDR2IO2_GR11_SR_SHIFT 30
1243#define OMAP4_LPDDR2IO2_GR11_SR_MASK (0x3 << 30)
1244#define OMAP4_LPDDR2IO2_GR11_I_SHIFT 27
1245#define OMAP4_LPDDR2IO2_GR11_I_MASK (0x7 << 27)
1246#define OMAP4_LPDDR2IO2_GR11_WD_SHIFT 25
1247#define OMAP4_LPDDR2IO2_GR11_WD_MASK (0x3 << 25)
1248#define OMAP4_LPDDR2IO2_GR10_SR_SHIFT 22
1249#define OMAP4_LPDDR2IO2_GR10_SR_MASK (0x3 << 22)
1250#define OMAP4_LPDDR2IO2_GR10_I_SHIFT 19
1251#define OMAP4_LPDDR2IO2_GR10_I_MASK (0x7 << 19)
1252#define OMAP4_LPDDR2IO2_GR10_WD_SHIFT 17
1253#define OMAP4_LPDDR2IO2_GR10_WD_MASK (0x3 << 17)
1254#define OMAP4_LPDDR2IO2_GR9_SR_SHIFT 14
1255#define OMAP4_LPDDR2IO2_GR9_SR_MASK (0x3 << 14)
1256#define OMAP4_LPDDR2IO2_GR9_I_SHIFT 11
1257#define OMAP4_LPDDR2IO2_GR9_I_MASK (0x7 << 11)
1258#define OMAP4_LPDDR2IO2_GR9_WD_SHIFT 9
1259#define OMAP4_LPDDR2IO2_GR9_WD_MASK (0x3 << 9)
1260
1261/* CONTROL_LPDDR2IO2_3 */
1262#define OMAP4_LPDDR22_VREF_CA_CCAP0_SHIFT 31
1263#define OMAP4_LPDDR22_VREF_CA_CCAP0_MASK (1 << 31)
1264#define OMAP4_LPDDR22_VREF_CA_CCAP1_SHIFT 30
1265#define OMAP4_LPDDR22_VREF_CA_CCAP1_MASK (1 << 30)
1266#define OMAP4_LPDDR22_VREF_CA_INT_CCAP0_SHIFT 29
1267#define OMAP4_LPDDR22_VREF_CA_INT_CCAP0_MASK (1 << 29)
1268#define OMAP4_LPDDR22_VREF_CA_INT_CCAP1_SHIFT 28
1269#define OMAP4_LPDDR22_VREF_CA_INT_CCAP1_MASK (1 << 28)
1270#define OMAP4_LPDDR22_VREF_CA_INT_TAP0_SHIFT 27
1271#define OMAP4_LPDDR22_VREF_CA_INT_TAP0_MASK (1 << 27)
1272#define OMAP4_LPDDR22_VREF_CA_INT_TAP1_SHIFT 26
1273#define OMAP4_LPDDR22_VREF_CA_INT_TAP1_MASK (1 << 26)
1274#define OMAP4_LPDDR22_VREF_CA_TAP0_SHIFT 25
1275#define OMAP4_LPDDR22_VREF_CA_TAP0_MASK (1 << 25)
1276#define OMAP4_LPDDR22_VREF_CA_TAP1_SHIFT 24
1277#define OMAP4_LPDDR22_VREF_CA_TAP1_MASK (1 << 24)
1278#define OMAP4_LPDDR22_VREF_DQ0_INT_CCAP0_SHIFT 23
1279#define OMAP4_LPDDR22_VREF_DQ0_INT_CCAP0_MASK (1 << 23)
1280#define OMAP4_LPDDR22_VREF_DQ0_INT_CCAP1_SHIFT 22
1281#define OMAP4_LPDDR22_VREF_DQ0_INT_CCAP1_MASK (1 << 22)
1282#define OMAP4_LPDDR22_VREF_DQ0_INT_TAP0_SHIFT 21
1283#define OMAP4_LPDDR22_VREF_DQ0_INT_TAP0_MASK (1 << 21)
1284#define OMAP4_LPDDR22_VREF_DQ0_INT_TAP1_SHIFT 20
1285#define OMAP4_LPDDR22_VREF_DQ0_INT_TAP1_MASK (1 << 20)
1286#define OMAP4_LPDDR22_VREF_DQ1_INT_CCAP0_SHIFT 19
1287#define OMAP4_LPDDR22_VREF_DQ1_INT_CCAP0_MASK (1 << 19)
1288#define OMAP4_LPDDR22_VREF_DQ1_INT_CCAP1_SHIFT 18
1289#define OMAP4_LPDDR22_VREF_DQ1_INT_CCAP1_MASK (1 << 18)
1290#define OMAP4_LPDDR22_VREF_DQ1_INT_TAP0_SHIFT 17
1291#define OMAP4_LPDDR22_VREF_DQ1_INT_TAP0_MASK (1 << 17)
1292#define OMAP4_LPDDR22_VREF_DQ1_INT_TAP1_SHIFT 16
1293#define OMAP4_LPDDR22_VREF_DQ1_INT_TAP1_MASK (1 << 16)
1294#define OMAP4_LPDDR22_VREF_DQ_CCAP0_SHIFT 15
1295#define OMAP4_LPDDR22_VREF_DQ_CCAP0_MASK (1 << 15)
1296#define OMAP4_LPDDR22_VREF_DQ_CCAP1_SHIFT 14
1297#define OMAP4_LPDDR22_VREF_DQ_CCAP1_MASK (1 << 14)
1298#define OMAP4_LPDDR22_VREF_DQ_TAP0_SHIFT 13
1299#define OMAP4_LPDDR22_VREF_DQ_TAP0_MASK (1 << 13)
1300#define OMAP4_LPDDR22_VREF_DQ_TAP1_SHIFT 12
1301#define OMAP4_LPDDR22_VREF_DQ_TAP1_MASK (1 << 12)
1302
1303/* CONTROL_BUS_HOLD */
1304#define OMAP4_ABE_DMIC_DIN3_EN_SHIFT 31
1305#define OMAP4_ABE_DMIC_DIN3_EN_MASK (1 << 31)
1306#define OMAP4_MCSPI1_CS3_EN_SHIFT 30
1307#define OMAP4_MCSPI1_CS3_EN_MASK (1 << 30)
1308
1309/* CONTROL_C2C */
1310#define OMAP4_MIRROR_MODE_EN_SHIFT 31
1311#define OMAP4_MIRROR_MODE_EN_MASK (1 << 31)
1312#define OMAP4_C2C_SPARE_SHIFT 24
1313#define OMAP4_C2C_SPARE_MASK (0x7f << 24)
1314
1315/* CORE_CONTROL_SPARE_RW */
1316#define OMAP4_CORE_CONTROL_SPARE_RW_SHIFT 0
1317#define OMAP4_CORE_CONTROL_SPARE_RW_MASK (0xffffffff << 0)
1318
1319/* CORE_CONTROL_SPARE_R */
1320#define OMAP4_CORE_CONTROL_SPARE_R_SHIFT 0
1321#define OMAP4_CORE_CONTROL_SPARE_R_MASK (0xffffffff << 0)
1322
1323/* CORE_CONTROL_SPARE_R_C0 */
1324#define OMAP4_CORE_CONTROL_SPARE_R_C0_SHIFT 31
1325#define OMAP4_CORE_CONTROL_SPARE_R_C0_MASK (1 << 31)
1326#define OMAP4_CORE_CONTROL_SPARE_R_C1_SHIFT 30
1327#define OMAP4_CORE_CONTROL_SPARE_R_C1_MASK (1 << 30)
1328#define OMAP4_CORE_CONTROL_SPARE_R_C2_SHIFT 29
1329#define OMAP4_CORE_CONTROL_SPARE_R_C2_MASK (1 << 29)
1330#define OMAP4_CORE_CONTROL_SPARE_R_C3_SHIFT 28
1331#define OMAP4_CORE_CONTROL_SPARE_R_C3_MASK (1 << 28)
1332#define OMAP4_CORE_CONTROL_SPARE_R_C4_SHIFT 27
1333#define OMAP4_CORE_CONTROL_SPARE_R_C4_MASK (1 << 27)
1334#define OMAP4_CORE_CONTROL_SPARE_R_C5_SHIFT 26
1335#define OMAP4_CORE_CONTROL_SPARE_R_C5_MASK (1 << 26)
1336#define OMAP4_CORE_CONTROL_SPARE_R_C6_SHIFT 25
1337#define OMAP4_CORE_CONTROL_SPARE_R_C6_MASK (1 << 25)
1338#define OMAP4_CORE_CONTROL_SPARE_R_C7_SHIFT 24
1339#define OMAP4_CORE_CONTROL_SPARE_R_C7_MASK (1 << 24)
1340
1341/* CONTROL_EFUSE_1 */
1342#define OMAP4_AVDAC_TRIM_BYTE3_SHIFT 24
1343#define OMAP4_AVDAC_TRIM_BYTE3_MASK (0x7f << 24)
1344#define OMAP4_AVDAC_TRIM_BYTE2_SHIFT 16
1345#define OMAP4_AVDAC_TRIM_BYTE2_MASK (0xff << 16)
1346#define OMAP4_AVDAC_TRIM_BYTE1_SHIFT 8
1347#define OMAP4_AVDAC_TRIM_BYTE1_MASK (0xff << 8)
1348#define OMAP4_AVDAC_TRIM_BYTE0_SHIFT 0
1349#define OMAP4_AVDAC_TRIM_BYTE0_MASK (0xff << 0)
1350
1351/* CONTROL_EFUSE_2 */
1352#define OMAP4_EFUSE_SMART2TEST_P0_SHIFT 31
1353#define OMAP4_EFUSE_SMART2TEST_P0_MASK (1 << 31)
1354#define OMAP4_EFUSE_SMART2TEST_P1_SHIFT 30
1355#define OMAP4_EFUSE_SMART2TEST_P1_MASK (1 << 30)
1356#define OMAP4_EFUSE_SMART2TEST_P2_SHIFT 29
1357#define OMAP4_EFUSE_SMART2TEST_P2_MASK (1 << 29)
1358#define OMAP4_EFUSE_SMART2TEST_P3_SHIFT 28
1359#define OMAP4_EFUSE_SMART2TEST_P3_MASK (1 << 28)
1360#define OMAP4_EFUSE_SMART2TEST_N0_SHIFT 27
1361#define OMAP4_EFUSE_SMART2TEST_N0_MASK (1 << 27)
1362#define OMAP4_EFUSE_SMART2TEST_N1_SHIFT 26
1363#define OMAP4_EFUSE_SMART2TEST_N1_MASK (1 << 26)
1364#define OMAP4_EFUSE_SMART2TEST_N2_SHIFT 25
1365#define OMAP4_EFUSE_SMART2TEST_N2_MASK (1 << 25)
1366#define OMAP4_EFUSE_SMART2TEST_N3_SHIFT 24
1367#define OMAP4_EFUSE_SMART2TEST_N3_MASK (1 << 24)
1368#define OMAP4_LPDDR2_PTV_N1_SHIFT 23
1369#define OMAP4_LPDDR2_PTV_N1_MASK (1 << 23)
1370#define OMAP4_LPDDR2_PTV_N2_SHIFT 22
1371#define OMAP4_LPDDR2_PTV_N2_MASK (1 << 22)
1372#define OMAP4_LPDDR2_PTV_N3_SHIFT 21
1373#define OMAP4_LPDDR2_PTV_N3_MASK (1 << 21)
1374#define OMAP4_LPDDR2_PTV_N4_SHIFT 20
1375#define OMAP4_LPDDR2_PTV_N4_MASK (1 << 20)
1376#define OMAP4_LPDDR2_PTV_N5_SHIFT 19
1377#define OMAP4_LPDDR2_PTV_N5_MASK (1 << 19)
1378#define OMAP4_LPDDR2_PTV_P1_SHIFT 18
1379#define OMAP4_LPDDR2_PTV_P1_MASK (1 << 18)
1380#define OMAP4_LPDDR2_PTV_P2_SHIFT 17
1381#define OMAP4_LPDDR2_PTV_P2_MASK (1 << 17)
1382#define OMAP4_LPDDR2_PTV_P3_SHIFT 16
1383#define OMAP4_LPDDR2_PTV_P3_MASK (1 << 16)
1384#define OMAP4_LPDDR2_PTV_P4_SHIFT 15
1385#define OMAP4_LPDDR2_PTV_P4_MASK (1 << 15)
1386#define OMAP4_LPDDR2_PTV_P5_SHIFT 14
1387#define OMAP4_LPDDR2_PTV_P5_MASK (1 << 14)
1388
1389/* CONTROL_EFUSE_3 */
1390#define OMAP4_STD_FUSE_SPARE_1_SHIFT 24
1391#define OMAP4_STD_FUSE_SPARE_1_MASK (0xff << 24)
1392#define OMAP4_STD_FUSE_SPARE_2_SHIFT 16
1393#define OMAP4_STD_FUSE_SPARE_2_MASK (0xff << 16)
1394#define OMAP4_STD_FUSE_SPARE_3_SHIFT 8
1395#define OMAP4_STD_FUSE_SPARE_3_MASK (0xff << 8)
1396#define OMAP4_STD_FUSE_SPARE_4_SHIFT 0
1397#define OMAP4_STD_FUSE_SPARE_4_MASK (0xff << 0)
1398
1399/* CONTROL_EFUSE_4 */
1400#define OMAP4_STD_FUSE_SPARE_5_SHIFT 24
1401#define OMAP4_STD_FUSE_SPARE_5_MASK (0xff << 24)
1402#define OMAP4_STD_FUSE_SPARE_6_SHIFT 16
1403#define OMAP4_STD_FUSE_SPARE_6_MASK (0xff << 16)
1404#define OMAP4_STD_FUSE_SPARE_7_SHIFT 8
1405#define OMAP4_STD_FUSE_SPARE_7_MASK (0xff << 8)
1406#define OMAP4_STD_FUSE_SPARE_8_SHIFT 0
1407#define OMAP4_STD_FUSE_SPARE_8_MASK (0xff << 0)
1408
1409#endif
diff --git a/arch/arm/mach-omap2/include/mach/ctrl_module_pad_wkup_44xx.h b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_wkup_44xx.h
new file mode 100644
index 000000000000..17c9b37042c0
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/ctrl_module_pad_wkup_44xx.h
@@ -0,0 +1,236 @@
1/*
2 * OMAP44xx CTRL_MODULE_PAD_WKUP registers and bitfields
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 *
6 * Benoit Cousson (b-cousson@ti.com)
7 * Santosh Shilimkar (santosh.shilimkar@ti.com)
8 *
9 * This file is automatically generated from the OMAP hardware databases.
10 * We respectfully ask that any modifications to this file be coordinated
11 * with the public linux-omap@vger.kernel.org mailing list and the
12 * authors above to ensure that the autogeneration scripts are kept
13 * up-to-date with the file contents.
14 *
15 * 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
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_PAD_WKUP_44XX_H
21#define __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_PAD_WKUP_44XX_H
22
23
24/* Base address */
25#define OMAP4_CTRL_MODULE_PAD_WKUP 0x4a31e000
26
27/* Registers offset */
28#define OMAP4_CTRL_MODULE_PAD_WKUP_IP_REVISION 0x0000
29#define OMAP4_CTRL_MODULE_PAD_WKUP_IP_HWINFO 0x0004
30#define OMAP4_CTRL_MODULE_PAD_WKUP_IP_SYSCONFIG 0x0010
31#define OMAP4_CTRL_MODULE_PAD_WKUP_PADCONF_WAKEUPEVENT_0 0x007c
32#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_SMART1NOPMIO_PADCONF_0 0x05a0
33#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_SMART1NOPMIO_PADCONF_1 0x05a4
34#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_PADCONF_MODE 0x05a8
35#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_XTAL_OSCILLATOR 0x05ac
36#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_USIMIO 0x0600
37#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_I2C_2 0x0604
38#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_JTAG 0x0608
39#define OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_SYS 0x060c
40#define OMAP4_CTRL_MODULE_PAD_WKUP_WKUP_CONTROL_SPARE_RW 0x0614
41#define OMAP4_CTRL_MODULE_PAD_WKUP_WKUP_CONTROL_SPARE_R 0x0618
42#define OMAP4_CTRL_MODULE_PAD_WKUP_WKUP_CONTROL_SPARE_R_C0 0x061c
43
44/* Registers shifts and masks */
45
46/* IP_REVISION */
47#define OMAP4_IP_REV_SCHEME_SHIFT 30
48#define OMAP4_IP_REV_SCHEME_MASK (0x3 << 30)
49#define OMAP4_IP_REV_FUNC_SHIFT 16
50#define OMAP4_IP_REV_FUNC_MASK (0xfff << 16)
51#define OMAP4_IP_REV_RTL_SHIFT 11
52#define OMAP4_IP_REV_RTL_MASK (0x1f << 11)
53#define OMAP4_IP_REV_MAJOR_SHIFT 8
54#define OMAP4_IP_REV_MAJOR_MASK (0x7 << 8)
55#define OMAP4_IP_REV_CUSTOM_SHIFT 6
56#define OMAP4_IP_REV_CUSTOM_MASK (0x3 << 6)
57#define OMAP4_IP_REV_MINOR_SHIFT 0
58#define OMAP4_IP_REV_MINOR_MASK (0x3f << 0)
59
60/* IP_HWINFO */
61#define OMAP4_IP_HWINFO_SHIFT 0
62#define OMAP4_IP_HWINFO_MASK (0xffffffff << 0)
63
64/* IP_SYSCONFIG */
65#define OMAP4_IP_SYSCONFIG_IDLEMODE_SHIFT 2
66#define OMAP4_IP_SYSCONFIG_IDLEMODE_MASK (0x3 << 2)
67
68/* PADCONF_WAKEUPEVENT_0 */
69#define OMAP4_JTAG_TDO_DUPLICATEWAKEUPEVENT_SHIFT 24
70#define OMAP4_JTAG_TDO_DUPLICATEWAKEUPEVENT_MASK (1 << 24)
71#define OMAP4_JTAG_TDI_DUPLICATEWAKEUPEVENT_SHIFT 23
72#define OMAP4_JTAG_TDI_DUPLICATEWAKEUPEVENT_MASK (1 << 23)
73#define OMAP4_JTAG_TMS_TMSC_DUPLICATEWAKEUPEVENT_SHIFT 22
74#define OMAP4_JTAG_TMS_TMSC_DUPLICATEWAKEUPEVENT_MASK (1 << 22)
75#define OMAP4_JTAG_RTCK_DUPLICATEWAKEUPEVENT_SHIFT 21
76#define OMAP4_JTAG_RTCK_DUPLICATEWAKEUPEVENT_MASK (1 << 21)
77#define OMAP4_JTAG_TCK_DUPLICATEWAKEUPEVENT_SHIFT 20
78#define OMAP4_JTAG_TCK_DUPLICATEWAKEUPEVENT_MASK (1 << 20)
79#define OMAP4_JTAG_NTRST_DUPLICATEWAKEUPEVENT_SHIFT 19
80#define OMAP4_JTAG_NTRST_DUPLICATEWAKEUPEVENT_MASK (1 << 19)
81#define OMAP4_SYS_BOOT7_DUPLICATEWAKEUPEVENT_SHIFT 18
82#define OMAP4_SYS_BOOT7_DUPLICATEWAKEUPEVENT_MASK (1 << 18)
83#define OMAP4_SYS_BOOT6_DUPLICATEWAKEUPEVENT_SHIFT 17
84#define OMAP4_SYS_BOOT6_DUPLICATEWAKEUPEVENT_MASK (1 << 17)
85#define OMAP4_SYS_PWRON_RESET_OUT_DUPLICATEWAKEUPEVENT_SHIFT 16
86#define OMAP4_SYS_PWRON_RESET_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 16)
87#define OMAP4_SYS_PWR_REQ_DUPLICATEWAKEUPEVENT_SHIFT 15
88#define OMAP4_SYS_PWR_REQ_DUPLICATEWAKEUPEVENT_MASK (1 << 15)
89#define OMAP4_SYS_NRESWARM_DUPLICATEWAKEUPEVENT_SHIFT 14
90#define OMAP4_SYS_NRESWARM_DUPLICATEWAKEUPEVENT_MASK (1 << 14)
91#define OMAP4_SYS_32K_DUPLICATEWAKEUPEVENT_SHIFT 13
92#define OMAP4_SYS_32K_DUPLICATEWAKEUPEVENT_MASK (1 << 13)
93#define OMAP4_FREF_CLK4_OUT_DUPLICATEWAKEUPEVENT_SHIFT 12
94#define OMAP4_FREF_CLK4_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 12)
95#define OMAP4_FREF_CLK4_REQ_DUPLICATEWAKEUPEVENT_SHIFT 11
96#define OMAP4_FREF_CLK4_REQ_DUPLICATEWAKEUPEVENT_MASK (1 << 11)
97#define OMAP4_FREF_CLK3_OUT_DUPLICATEWAKEUPEVENT_SHIFT 10
98#define OMAP4_FREF_CLK3_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 10)
99#define OMAP4_FREF_CLK3_REQ_DUPLICATEWAKEUPEVENT_SHIFT 9
100#define OMAP4_FREF_CLK3_REQ_DUPLICATEWAKEUPEVENT_MASK (1 << 9)
101#define OMAP4_FREF_CLK0_OUT_DUPLICATEWAKEUPEVENT_SHIFT 8
102#define OMAP4_FREF_CLK0_OUT_DUPLICATEWAKEUPEVENT_MASK (1 << 8)
103#define OMAP4_FREF_CLK_IOREQ_DUPLICATEWAKEUPEVENT_SHIFT 7
104#define OMAP4_FREF_CLK_IOREQ_DUPLICATEWAKEUPEVENT_MASK (1 << 7)
105#define OMAP4_SR_SDA_DUPLICATEWAKEUPEVENT_SHIFT 6
106#define OMAP4_SR_SDA_DUPLICATEWAKEUPEVENT_MASK (1 << 6)
107#define OMAP4_SR_SCL_DUPLICATEWAKEUPEVENT_SHIFT 5
108#define OMAP4_SR_SCL_DUPLICATEWAKEUPEVENT_MASK (1 << 5)
109#define OMAP4_SIM_PWRCTRL_DUPLICATEWAKEUPEVENT_SHIFT 4
110#define OMAP4_SIM_PWRCTRL_DUPLICATEWAKEUPEVENT_MASK (1 << 4)
111#define OMAP4_SIM_CD_DUPLICATEWAKEUPEVENT_SHIFT 3
112#define OMAP4_SIM_CD_DUPLICATEWAKEUPEVENT_MASK (1 << 3)
113#define OMAP4_SIM_RESET_DUPLICATEWAKEUPEVENT_SHIFT 2
114#define OMAP4_SIM_RESET_DUPLICATEWAKEUPEVENT_MASK (1 << 2)
115#define OMAP4_SIM_CLK_DUPLICATEWAKEUPEVENT_SHIFT 1
116#define OMAP4_SIM_CLK_DUPLICATEWAKEUPEVENT_MASK (1 << 1)
117#define OMAP4_SIM_IO_DUPLICATEWAKEUPEVENT_SHIFT 0
118#define OMAP4_SIM_IO_DUPLICATEWAKEUPEVENT_MASK (1 << 0)
119
120/* CONTROL_SMART1NOPMIO_PADCONF_0 */
121#define OMAP4_FREF_DR0_SC_SHIFT 30
122#define OMAP4_FREF_DR0_SC_MASK (0x3 << 30)
123#define OMAP4_FREF_DR1_SC_SHIFT 28
124#define OMAP4_FREF_DR1_SC_MASK (0x3 << 28)
125#define OMAP4_FREF_DR4_SC_SHIFT 26
126#define OMAP4_FREF_DR4_SC_MASK (0x3 << 26)
127#define OMAP4_FREF_DR5_SC_SHIFT 24
128#define OMAP4_FREF_DR5_SC_MASK (0x3 << 24)
129#define OMAP4_FREF_DR6_SC_SHIFT 22
130#define OMAP4_FREF_DR6_SC_MASK (0x3 << 22)
131#define OMAP4_FREF_DR7_SC_SHIFT 20
132#define OMAP4_FREF_DR7_SC_MASK (0x3 << 20)
133#define OMAP4_GPIO_DR7_SC_SHIFT 18
134#define OMAP4_GPIO_DR7_SC_MASK (0x3 << 18)
135#define OMAP4_DPM_DR0_SC_SHIFT 14
136#define OMAP4_DPM_DR0_SC_MASK (0x3 << 14)
137#define OMAP4_SIM_DR0_SC_SHIFT 12
138#define OMAP4_SIM_DR0_SC_MASK (0x3 << 12)
139
140/* CONTROL_SMART1NOPMIO_PADCONF_1 */
141#define OMAP4_FREF_DR0_LB_SHIFT 30
142#define OMAP4_FREF_DR0_LB_MASK (0x3 << 30)
143#define OMAP4_FREF_DR1_LB_SHIFT 28
144#define OMAP4_FREF_DR1_LB_MASK (0x3 << 28)
145#define OMAP4_FREF_DR4_LB_SHIFT 26
146#define OMAP4_FREF_DR4_LB_MASK (0x3 << 26)
147#define OMAP4_FREF_DR5_LB_SHIFT 24
148#define OMAP4_FREF_DR5_LB_MASK (0x3 << 24)
149#define OMAP4_FREF_DR6_LB_SHIFT 22
150#define OMAP4_FREF_DR6_LB_MASK (0x3 << 22)
151#define OMAP4_FREF_DR7_LB_SHIFT 20
152#define OMAP4_FREF_DR7_LB_MASK (0x3 << 20)
153#define OMAP4_GPIO_DR7_LB_SHIFT 18
154#define OMAP4_GPIO_DR7_LB_MASK (0x3 << 18)
155#define OMAP4_DPM_DR0_LB_SHIFT 14
156#define OMAP4_DPM_DR0_LB_MASK (0x3 << 14)
157#define OMAP4_SIM_DR0_LB_SHIFT 12
158#define OMAP4_SIM_DR0_LB_MASK (0x3 << 12)
159
160/* CONTROL_PADCONF_MODE */
161#define OMAP4_VDDS_DV_FREF_SHIFT 31
162#define OMAP4_VDDS_DV_FREF_MASK (1 << 31)
163#define OMAP4_VDDS_DV_BANK2_SHIFT 30
164#define OMAP4_VDDS_DV_BANK2_MASK (1 << 30)
165
166/* CONTROL_XTAL_OSCILLATOR */
167#define OMAP4_OSCILLATOR_BOOST_SHIFT 31
168#define OMAP4_OSCILLATOR_BOOST_MASK (1 << 31)
169#define OMAP4_OSCILLATOR_OS_OUT_SHIFT 30
170#define OMAP4_OSCILLATOR_OS_OUT_MASK (1 << 30)
171
172/* CONTROL_USIMIO */
173#define OMAP4_PAD_USIM_CLK_LOW_SHIFT 31
174#define OMAP4_PAD_USIM_CLK_LOW_MASK (1 << 31)
175#define OMAP4_PAD_USIM_RST_LOW_SHIFT 29
176#define OMAP4_PAD_USIM_RST_LOW_MASK (1 << 29)
177#define OMAP4_USIM_PWRDNZ_SHIFT 28
178#define OMAP4_USIM_PWRDNZ_MASK (1 << 28)
179
180/* CONTROL_I2C_2 */
181#define OMAP4_SR_SDA_GLFENB_SHIFT 31
182#define OMAP4_SR_SDA_GLFENB_MASK (1 << 31)
183#define OMAP4_SR_SDA_LOAD_BITS_SHIFT 29
184#define OMAP4_SR_SDA_LOAD_BITS_MASK (0x3 << 29)
185#define OMAP4_SR_SDA_PULLUPRESX_SHIFT 28
186#define OMAP4_SR_SDA_PULLUPRESX_MASK (1 << 28)
187#define OMAP4_SR_SCL_GLFENB_SHIFT 27
188#define OMAP4_SR_SCL_GLFENB_MASK (1 << 27)
189#define OMAP4_SR_SCL_LOAD_BITS_SHIFT 25
190#define OMAP4_SR_SCL_LOAD_BITS_MASK (0x3 << 25)
191#define OMAP4_SR_SCL_PULLUPRESX_SHIFT 24
192#define OMAP4_SR_SCL_PULLUPRESX_MASK (1 << 24)
193
194/* CONTROL_JTAG */
195#define OMAP4_JTAG_NTRST_EN_SHIFT 31
196#define OMAP4_JTAG_NTRST_EN_MASK (1 << 31)
197#define OMAP4_JTAG_TCK_EN_SHIFT 30
198#define OMAP4_JTAG_TCK_EN_MASK (1 << 30)
199#define OMAP4_JTAG_RTCK_EN_SHIFT 29
200#define OMAP4_JTAG_RTCK_EN_MASK (1 << 29)
201#define OMAP4_JTAG_TDI_EN_SHIFT 28
202#define OMAP4_JTAG_TDI_EN_MASK (1 << 28)
203#define OMAP4_JTAG_TDO_EN_SHIFT 27
204#define OMAP4_JTAG_TDO_EN_MASK (1 << 27)
205
206/* CONTROL_SYS */
207#define OMAP4_SYS_NRESWARM_PIPU_SHIFT 31
208#define OMAP4_SYS_NRESWARM_PIPU_MASK (1 << 31)
209
210/* WKUP_CONTROL_SPARE_RW */
211#define OMAP4_WKUP_CONTROL_SPARE_RW_SHIFT 0
212#define OMAP4_WKUP_CONTROL_SPARE_RW_MASK (0xffffffff << 0)
213
214/* WKUP_CONTROL_SPARE_R */
215#define OMAP4_WKUP_CONTROL_SPARE_R_SHIFT 0
216#define OMAP4_WKUP_CONTROL_SPARE_R_MASK (0xffffffff << 0)
217
218/* WKUP_CONTROL_SPARE_R_C0 */
219#define OMAP4_WKUP_CONTROL_SPARE_R_C0_SHIFT 31
220#define OMAP4_WKUP_CONTROL_SPARE_R_C0_MASK (1 << 31)
221#define OMAP4_WKUP_CONTROL_SPARE_R_C1_SHIFT 30
222#define OMAP4_WKUP_CONTROL_SPARE_R_C1_MASK (1 << 30)
223#define OMAP4_WKUP_CONTROL_SPARE_R_C2_SHIFT 29
224#define OMAP4_WKUP_CONTROL_SPARE_R_C2_MASK (1 << 29)
225#define OMAP4_WKUP_CONTROL_SPARE_R_C3_SHIFT 28
226#define OMAP4_WKUP_CONTROL_SPARE_R_C3_MASK (1 << 28)
227#define OMAP4_WKUP_CONTROL_SPARE_R_C4_SHIFT 27
228#define OMAP4_WKUP_CONTROL_SPARE_R_C4_MASK (1 << 27)
229#define OMAP4_WKUP_CONTROL_SPARE_R_C5_SHIFT 26
230#define OMAP4_WKUP_CONTROL_SPARE_R_C5_MASK (1 << 26)
231#define OMAP4_WKUP_CONTROL_SPARE_R_C6_SHIFT 25
232#define OMAP4_WKUP_CONTROL_SPARE_R_C6_MASK (1 << 25)
233#define OMAP4_WKUP_CONTROL_SPARE_R_C7_SHIFT 24
234#define OMAP4_WKUP_CONTROL_SPARE_R_C7_MASK (1 << 24)
235
236#endif
diff --git a/arch/arm/mach-omap2/include/mach/ctrl_module_wkup_44xx.h b/arch/arm/mach-omap2/include/mach/ctrl_module_wkup_44xx.h
new file mode 100644
index 000000000000..a0af9baec3f7
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/ctrl_module_wkup_44xx.h
@@ -0,0 +1,92 @@
1/*
2 * OMAP44xx CTRL_MODULE_WKUP registers and bitfields
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 *
6 * Benoit Cousson (b-cousson@ti.com)
7 * Santosh Shilimkar (santosh.shilimkar@ti.com)
8 *
9 * This file is automatically generated from the OMAP hardware databases.
10 * We respectfully ask that any modifications to this file be coordinated
11 * with the public linux-omap@vger.kernel.org mailing list and the
12 * authors above to ensure that the autogeneration scripts are kept
13 * up-to-date with the file contents.
14 *
15 * 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
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_WKUP_44XX_H
21#define __ARCH_ARM_MACH_OMAP2_CTRL_MODULE_WKUP_44XX_H
22
23
24/* Base address */
25#define OMAP4_CTRL_MODULE_WKUP 0x4a30c000
26
27/* Registers offset */
28#define OMAP4_CTRL_MODULE_WKUP_IP_REVISION 0x0000
29#define OMAP4_CTRL_MODULE_WKUP_IP_HWINFO 0x0004
30#define OMAP4_CTRL_MODULE_WKUP_IP_SYSCONFIG 0x0010
31#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_0 0x0460
32#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_1 0x0464
33#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_2 0x0468
34#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_3 0x046c
35#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_4 0x0470
36#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_5 0x0474
37#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_6 0x0478
38#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_7 0x047c
39#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_8 0x0480
40#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_9 0x0484
41#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_10 0x0488
42#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_11 0x048c
43#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_12 0x0490
44#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_13 0x0494
45#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_14 0x0498
46#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_15 0x049c
47#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_16 0x04a0
48#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_17 0x04a4
49#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_18 0x04a8
50#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_19 0x04ac
51#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_20 0x04b0
52#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_21 0x04b4
53#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_22 0x04b8
54#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_23 0x04bc
55#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_24 0x04c0
56#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_25 0x04c4
57#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_26 0x04c8
58#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_27 0x04cc
59#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_28 0x04d0
60#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_29 0x04d4
61#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_30 0x04d8
62#define OMAP4_CTRL_MODULE_WKUP_CONF_DEBUG_SEL_TST_31 0x04dc
63
64/* Registers shifts and masks */
65
66/* IP_REVISION */
67#define OMAP4_IP_REV_SCHEME_SHIFT 30
68#define OMAP4_IP_REV_SCHEME_MASK (0x3 << 30)
69#define OMAP4_IP_REV_FUNC_SHIFT 16
70#define OMAP4_IP_REV_FUNC_MASK (0xfff << 16)
71#define OMAP4_IP_REV_RTL_SHIFT 11
72#define OMAP4_IP_REV_RTL_MASK (0x1f << 11)
73#define OMAP4_IP_REV_MAJOR_SHIFT 8
74#define OMAP4_IP_REV_MAJOR_MASK (0x7 << 8)
75#define OMAP4_IP_REV_CUSTOM_SHIFT 6
76#define OMAP4_IP_REV_CUSTOM_MASK (0x3 << 6)
77#define OMAP4_IP_REV_MINOR_SHIFT 0
78#define OMAP4_IP_REV_MINOR_MASK (0x3f << 0)
79
80/* IP_HWINFO */
81#define OMAP4_IP_HWINFO_SHIFT 0
82#define OMAP4_IP_HWINFO_MASK (0xffffffff << 0)
83
84/* IP_SYSCONFIG */
85#define OMAP4_IP_SYSCONFIG_IDLEMODE_SHIFT 2
86#define OMAP4_IP_SYSCONFIG_IDLEMODE_MASK (0x3 << 2)
87
88/* CONF_DEBUG_SEL_TST_0 */
89#define OMAP4_WKUP_MODE_SHIFT 0
90#define OMAP4_WKUP_MODE_MASK (1 << 0)
91
92#endif
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index b9ea70bce563..40562ddd3ee4 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -36,6 +36,7 @@
36#include "clock2xxx.h" 36#include "clock2xxx.h"
37#include "clock3xxx.h" 37#include "clock3xxx.h"
38#include "clock44xx.h" 38#include "clock44xx.h"
39#include "io.h"
39 40
40#include <plat/omap-pm.h> 41#include <plat/omap-pm.h>
41#include <plat/powerdomain.h> 42#include <plat/powerdomain.h>
@@ -323,6 +324,9 @@ void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
323 omap2430_hwmod_init(); 324 omap2430_hwmod_init();
324 else if (cpu_is_omap34xx()) 325 else if (cpu_is_omap34xx())
325 omap3xxx_hwmod_init(); 326 omap3xxx_hwmod_init();
327 else if (cpu_is_omap44xx())
328 omap44xx_hwmod_init();
329
326 /* The OPP tables have to be registered before a clk init */ 330 /* The OPP tables have to be registered before a clk init */
327 omap_pm_if_early_init(mpu_opps, dsp_opps, l3_opps); 331 omap_pm_if_early_init(mpu_opps, dsp_opps, l3_opps);
328 332
@@ -342,9 +346,7 @@ void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
342#ifndef CONFIG_PM_RUNTIME 346#ifndef CONFIG_PM_RUNTIME
343 skip_setup_idle = 1; 347 skip_setup_idle = 1;
344#endif 348#endif
345 if (cpu_is_omap24xx() || cpu_is_omap34xx()) /* FIXME: OMAP4 */ 349 omap_hwmod_late_init(skip_setup_idle);
346 omap_hwmod_late_init(skip_setup_idle);
347
348 if (cpu_is_omap24xx() || cpu_is_omap34xx()) { 350 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
349 omap2_sdrc_init(sdrc_cs0, sdrc_cs1); 351 omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
350 _omap2_init_reprogram_sdrc(); 352 _omap2_init_reprogram_sdrc();
diff --git a/arch/arm/mach-omap2/io.h b/arch/arm/mach-omap2/io.h
new file mode 100644
index 000000000000..fd230c6cded5
--- /dev/null
+++ b/arch/arm/mach-omap2/io.h
@@ -0,0 +1,7 @@
1
2#ifndef __MACH_OMAP2_IO_H__
3#define __MACH_OMAP2_IO_H__
4
5extern int __init omap_sram_init(void);
6
7#endif /* __MACH_OMAP2_IO_H__ */
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 26aeef560aa3..32eeabe9d2ab 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -47,7 +47,6 @@ static struct omap_irq_bank {
47} __attribute__ ((aligned(4))) irq_banks[] = { 47} __attribute__ ((aligned(4))) irq_banks[] = {
48 { 48 {
49 /* MPU INTC */ 49 /* MPU INTC */
50 .base_reg = 0,
51 .nr_irqs = 96, 50 .nr_irqs = 96,
52 }, 51 },
53}; 52};
diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c
index 42dbfa46e656..40ddecab93a9 100644
--- a/arch/arm/mach-omap2/mailbox.c
+++ b/arch/arm/mach-omap2/mailbox.c
@@ -181,7 +181,7 @@ static int omap2_mbox_fifo_full(struct omap_mbox *mbox)
181static void omap2_mbox_enable_irq(struct omap_mbox *mbox, 181static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
182 omap_mbox_type_t irq) 182 omap_mbox_type_t irq)
183{ 183{
184 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; 184 struct omap_mbox2_priv *p = mbox->priv;
185 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 185 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
186 186
187 l = mbox_read_reg(p->irqenable); 187 l = mbox_read_reg(p->irqenable);
@@ -192,7 +192,7 @@ static void omap2_mbox_enable_irq(struct omap_mbox *mbox,
192static void omap2_mbox_disable_irq(struct omap_mbox *mbox, 192static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
193 omap_mbox_type_t irq) 193 omap_mbox_type_t irq)
194{ 194{
195 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; 195 struct omap_mbox2_priv *p = mbox->priv;
196 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 196 u32 l, bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
197 l = mbox_read_reg(p->irqdisable); 197 l = mbox_read_reg(p->irqdisable);
198 l &= ~bit; 198 l &= ~bit;
@@ -202,7 +202,7 @@ static void omap2_mbox_disable_irq(struct omap_mbox *mbox,
202static void omap2_mbox_ack_irq(struct omap_mbox *mbox, 202static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
203 omap_mbox_type_t irq) 203 omap_mbox_type_t irq)
204{ 204{
205 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; 205 struct omap_mbox2_priv *p = mbox->priv;
206 u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 206 u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
207 207
208 mbox_write_reg(bit, p->irqstatus); 208 mbox_write_reg(bit, p->irqstatus);
@@ -214,7 +214,7 @@ static void omap2_mbox_ack_irq(struct omap_mbox *mbox,
214static int omap2_mbox_is_irq(struct omap_mbox *mbox, 214static int omap2_mbox_is_irq(struct omap_mbox *mbox,
215 omap_mbox_type_t irq) 215 omap_mbox_type_t irq)
216{ 216{
217 struct omap_mbox2_priv *p = (struct omap_mbox2_priv *)mbox->priv; 217 struct omap_mbox2_priv *p = mbox->priv;
218 u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit; 218 u32 bit = (irq == IRQ_TX) ? p->notfull_bit : p->newmsg_bit;
219 u32 enable = mbox_read_reg(p->irqenable); 219 u32 enable = mbox_read_reg(p->irqenable);
220 u32 status = mbox_read_reg(p->irqstatus); 220 u32 status = mbox_read_reg(p->irqstatus);
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index 467aae245781..f9c9df5b5ff1 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -23,29 +23,86 @@
23#include <plat/cpu.h> 23#include <plat/cpu.h>
24#include <plat/mcbsp.h> 24#include <plat/mcbsp.h>
25 25
26#include "mux.h" 26#include "control.h"
27 27
28static void omap2_mcbsp2_mux_setup(void) 28
29/* McBSP internal signal muxing functions */
30
31void omap2_mcbsp1_mux_clkr_src(u8 mux)
29{ 32{
30 omap_mux_init_signal("eac_ac_sclk.mcbsp2_clkx", OMAP_PULL_ENA); 33 u32 v;
31 omap_mux_init_signal("eac_ac_fs.mcbsp2_fsx", OMAP_PULL_ENA); 34
32 omap_mux_init_signal("eac_ac_din.mcbsp2_dr", OMAP_PULL_ENA); 35 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
33 omap_mux_init_signal("eac_ac_dout.mcbsp2_dx", OMAP_PULL_ENA); 36 if (mux == CLKR_SRC_CLKR)
34 omap_mux_init_gpio(117, OMAP_PULL_ENA); 37 v &= ~OMAP2_MCBSP1_CLKR_MASK;
35 /* 38 else if (mux == CLKR_SRC_CLKX)
36 * TODO: Need to add MUX settings for OMAP 2430 SDP 39 v |= OMAP2_MCBSP1_CLKR_MASK;
37 */ 40 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
38} 41}
42EXPORT_SYMBOL(omap2_mcbsp1_mux_clkr_src);
39 43
40static void omap2_mcbsp_request(unsigned int id) 44void omap2_mcbsp1_mux_fsr_src(u8 mux)
41{ 45{
42 if (cpu_is_omap2420() && (id == OMAP_MCBSP2)) 46 u32 v;
43 omap2_mcbsp2_mux_setup(); 47
48 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
49 if (mux == FSR_SRC_FSR)
50 v &= ~OMAP2_MCBSP1_FSR_MASK;
51 else if (mux == FSR_SRC_FSX)
52 v |= OMAP2_MCBSP1_FSR_MASK;
53 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
44} 54}
55EXPORT_SYMBOL(omap2_mcbsp1_mux_fsr_src);
45 56
46static struct omap_mcbsp_ops omap2_mcbsp_ops = { 57/* McBSP CLKS source switching function */
47 .request = omap2_mcbsp_request, 58
48}; 59int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id)
60{
61 struct omap_mcbsp *mcbsp;
62 struct clk *fck_src;
63 char *fck_src_name;
64 int r;
65
66 if (!omap_mcbsp_check_valid_id(id)) {
67 pr_err("%s: Invalid id (%d)\n", __func__, id + 1);
68 return -EINVAL;
69 }
70 mcbsp = id_to_mcbsp_ptr(id);
71
72 if (fck_src_id == MCBSP_CLKS_PAD_SRC)
73 fck_src_name = "pad_fck";
74 else if (fck_src_id == MCBSP_CLKS_PRCM_SRC)
75 fck_src_name = "prcm_fck";
76 else
77 return -EINVAL;
78
79 fck_src = clk_get(mcbsp->dev, fck_src_name);
80 if (IS_ERR_OR_NULL(fck_src)) {
81 pr_err("omap-mcbsp: %s: could not clk_get() %s\n", "clks",
82 fck_src_name);
83 return -EINVAL;
84 }
85
86 clk_disable(mcbsp->fclk);
87
88 r = clk_set_parent(mcbsp->fclk, fck_src);
89 if (IS_ERR_VALUE(r)) {
90 pr_err("omap-mcbsp: %s: could not clk_set_parent() to %s\n",
91 "clks", fck_src_name);
92 clk_put(fck_src);
93 return -EINVAL;
94 }
95
96 clk_enable(mcbsp->fclk);
97
98 clk_put(fck_src);
99
100 return 0;
101}
102EXPORT_SYMBOL(omap2_mcbsp_set_clks_src);
103
104
105/* Platform data */
49 106
50#ifdef CONFIG_ARCH_OMAP2420 107#ifdef CONFIG_ARCH_OMAP2420
51static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = { 108static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
@@ -55,7 +112,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
55 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 112 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
56 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 113 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
57 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 114 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
58 .ops = &omap2_mcbsp_ops,
59 }, 115 },
60 { 116 {
61 .phys_base = OMAP24XX_MCBSP2_BASE, 117 .phys_base = OMAP24XX_MCBSP2_BASE,
@@ -63,7 +119,6 @@ static struct omap_mcbsp_platform_data omap2420_mcbsp_pdata[] = {
63 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 119 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
64 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 120 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
65 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 121 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
66 .ops = &omap2_mcbsp_ops,
67 }, 122 },
68}; 123};
69#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata) 124#define OMAP2420_MCBSP_PDATA_SZ ARRAY_SIZE(omap2420_mcbsp_pdata)
@@ -82,7 +137,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
82 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 137 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
83 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 138 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
84 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 139 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
85 .ops = &omap2_mcbsp_ops,
86 }, 140 },
87 { 141 {
88 .phys_base = OMAP24XX_MCBSP2_BASE, 142 .phys_base = OMAP24XX_MCBSP2_BASE,
@@ -90,7 +144,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
90 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 144 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
91 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 145 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
92 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 146 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
93 .ops = &omap2_mcbsp_ops,
94 }, 147 },
95 { 148 {
96 .phys_base = OMAP2430_MCBSP3_BASE, 149 .phys_base = OMAP2430_MCBSP3_BASE,
@@ -98,7 +151,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
98 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, 151 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
99 .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 152 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
100 .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 153 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
101 .ops = &omap2_mcbsp_ops,
102 }, 154 },
103 { 155 {
104 .phys_base = OMAP2430_MCBSP4_BASE, 156 .phys_base = OMAP2430_MCBSP4_BASE,
@@ -106,7 +158,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
106 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, 158 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
107 .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 159 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
108 .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 160 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
109 .ops = &omap2_mcbsp_ops,
110 }, 161 },
111 { 162 {
112 .phys_base = OMAP2430_MCBSP5_BASE, 163 .phys_base = OMAP2430_MCBSP5_BASE,
@@ -114,7 +165,6 @@ static struct omap_mcbsp_platform_data omap2430_mcbsp_pdata[] = {
114 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, 165 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
115 .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 166 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
116 .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 167 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
117 .ops = &omap2_mcbsp_ops,
118 }, 168 },
119}; 169};
120#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata) 170#define OMAP2430_MCBSP_PDATA_SZ ARRAY_SIZE(omap2430_mcbsp_pdata)
@@ -133,7 +183,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
133 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX, 183 .dma_tx_sync = OMAP24XX_DMA_MCBSP1_TX,
134 .rx_irq = INT_24XX_MCBSP1_IRQ_RX, 184 .rx_irq = INT_24XX_MCBSP1_IRQ_RX,
135 .tx_irq = INT_24XX_MCBSP1_IRQ_TX, 185 .tx_irq = INT_24XX_MCBSP1_IRQ_TX,
136 .ops = &omap2_mcbsp_ops,
137 .buffer_size = 0x80, /* The FIFO has 128 locations */ 186 .buffer_size = 0x80, /* The FIFO has 128 locations */
138 }, 187 },
139 { 188 {
@@ -143,7 +192,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
143 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX, 192 .dma_tx_sync = OMAP24XX_DMA_MCBSP2_TX,
144 .rx_irq = INT_24XX_MCBSP2_IRQ_RX, 193 .rx_irq = INT_24XX_MCBSP2_IRQ_RX,
145 .tx_irq = INT_24XX_MCBSP2_IRQ_TX, 194 .tx_irq = INT_24XX_MCBSP2_IRQ_TX,
146 .ops = &omap2_mcbsp_ops,
147 .buffer_size = 0x500, /* The FIFO has 1024 + 256 locations */ 195 .buffer_size = 0x500, /* The FIFO has 1024 + 256 locations */
148 }, 196 },
149 { 197 {
@@ -153,7 +201,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
153 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX, 201 .dma_tx_sync = OMAP24XX_DMA_MCBSP3_TX,
154 .rx_irq = INT_24XX_MCBSP3_IRQ_RX, 202 .rx_irq = INT_24XX_MCBSP3_IRQ_RX,
155 .tx_irq = INT_24XX_MCBSP3_IRQ_TX, 203 .tx_irq = INT_24XX_MCBSP3_IRQ_TX,
156 .ops = &omap2_mcbsp_ops,
157 .buffer_size = 0x80, /* The FIFO has 128 locations */ 204 .buffer_size = 0x80, /* The FIFO has 128 locations */
158 }, 205 },
159 { 206 {
@@ -162,7 +209,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
162 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX, 209 .dma_tx_sync = OMAP24XX_DMA_MCBSP4_TX,
163 .rx_irq = INT_24XX_MCBSP4_IRQ_RX, 210 .rx_irq = INT_24XX_MCBSP4_IRQ_RX,
164 .tx_irq = INT_24XX_MCBSP4_IRQ_TX, 211 .tx_irq = INT_24XX_MCBSP4_IRQ_TX,
165 .ops = &omap2_mcbsp_ops,
166 .buffer_size = 0x80, /* The FIFO has 128 locations */ 212 .buffer_size = 0x80, /* The FIFO has 128 locations */
167 }, 213 },
168 { 214 {
@@ -171,7 +217,6 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
171 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX, 217 .dma_tx_sync = OMAP24XX_DMA_MCBSP5_TX,
172 .rx_irq = INT_24XX_MCBSP5_IRQ_RX, 218 .rx_irq = INT_24XX_MCBSP5_IRQ_RX,
173 .tx_irq = INT_24XX_MCBSP5_IRQ_TX, 219 .tx_irq = INT_24XX_MCBSP5_IRQ_TX,
174 .ops = &omap2_mcbsp_ops,
175 .buffer_size = 0x80, /* The FIFO has 128 locations */ 220 .buffer_size = 0x80, /* The FIFO has 128 locations */
176 }, 221 },
177}; 222};
@@ -189,28 +234,24 @@ static struct omap_mcbsp_platform_data omap44xx_mcbsp_pdata[] = {
189 .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX, 234 .dma_rx_sync = OMAP44XX_DMA_MCBSP1_RX,
190 .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX, 235 .dma_tx_sync = OMAP44XX_DMA_MCBSP1_TX,
191 .tx_irq = OMAP44XX_IRQ_MCBSP1, 236 .tx_irq = OMAP44XX_IRQ_MCBSP1,
192 .ops = &omap2_mcbsp_ops,
193 }, 237 },
194 { 238 {
195 .phys_base = OMAP44XX_MCBSP2_BASE, 239 .phys_base = OMAP44XX_MCBSP2_BASE,
196 .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX, 240 .dma_rx_sync = OMAP44XX_DMA_MCBSP2_RX,
197 .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX, 241 .dma_tx_sync = OMAP44XX_DMA_MCBSP2_TX,
198 .tx_irq = OMAP44XX_IRQ_MCBSP2, 242 .tx_irq = OMAP44XX_IRQ_MCBSP2,
199 .ops = &omap2_mcbsp_ops,
200 }, 243 },
201 { 244 {
202 .phys_base = OMAP44XX_MCBSP3_BASE, 245 .phys_base = OMAP44XX_MCBSP3_BASE,
203 .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX, 246 .dma_rx_sync = OMAP44XX_DMA_MCBSP3_RX,
204 .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX, 247 .dma_tx_sync = OMAP44XX_DMA_MCBSP3_TX,
205 .tx_irq = OMAP44XX_IRQ_MCBSP3, 248 .tx_irq = OMAP44XX_IRQ_MCBSP3,
206 .ops = &omap2_mcbsp_ops,
207 }, 249 },
208 { 250 {
209 .phys_base = OMAP44XX_MCBSP4_BASE, 251 .phys_base = OMAP44XX_MCBSP4_BASE,
210 .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX, 252 .dma_rx_sync = OMAP44XX_DMA_MCBSP4_RX,
211 .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX, 253 .dma_tx_sync = OMAP44XX_DMA_MCBSP4_TX,
212 .tx_irq = OMAP44XX_IRQ_MCBSP4, 254 .tx_irq = OMAP44XX_IRQ_MCBSP4,
213 .ops = &omap2_mcbsp_ops,
214 }, 255 },
215}; 256};
216#define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata) 257#define OMAP44XX_MCBSP_PDATA_SZ ARRAY_SIZE(omap44xx_mcbsp_pdata)
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index ab403b2ed26b..074536ae401f 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -23,12 +23,11 @@
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 24 *
25 */ 25 */
26#include <linux/module.h> 26#include <linux/kernel.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/slab.h>
30#include <linux/spinlock.h>
31#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/slab.h>
32#include <linux/ctype.h> 31#include <linux/ctype.h>
33#include <linux/debugfs.h> 32#include <linux/debugfs.h>
34#include <linux/seq_file.h> 33#include <linux/seq_file.h>
@@ -36,8 +35,7 @@
36 35
37#include <asm/system.h> 36#include <asm/system.h>
38 37
39#include <plat/control.h> 38#include "control.h"
40
41#include "mux.h" 39#include "mux.h"
42 40
43#define OMAP_MUX_BASE_OFFSET 0x30 /* Offset from CTRL_BASE */ 41#define OMAP_MUX_BASE_OFFSET 0x30 /* Offset from CTRL_BASE */
@@ -87,7 +85,7 @@ static char *omap_mux_options;
87int __init omap_mux_init_gpio(int gpio, int val) 85int __init omap_mux_init_gpio(int gpio, int val)
88{ 86{
89 struct omap_mux_entry *e; 87 struct omap_mux_entry *e;
90 struct omap_mux *gpio_mux; 88 struct omap_mux *gpio_mux = NULL;
91 u16 old_mode; 89 u16 old_mode;
92 u16 mux_mode; 90 u16 mux_mode;
93 int found = 0; 91 int found = 0;
@@ -127,17 +125,16 @@ int __init omap_mux_init_gpio(int gpio, int val)
127 return 0; 125 return 0;
128} 126}
129 127
130int __init omap_mux_init_signal(char *muxname, int val) 128int __init omap_mux_init_signal(const char *muxname, int val)
131{ 129{
132 struct omap_mux_entry *e; 130 struct omap_mux_entry *e;
133 char *m0_name = NULL, *mode_name = NULL; 131 const char *mode_name;
134 int found = 0; 132 int found = 0, mode0_len = 0;
135 133
136 mode_name = strchr(muxname, '.'); 134 mode_name = strchr(muxname, '.');
137 if (mode_name) { 135 if (mode_name) {
138 *mode_name = '\0'; 136 mode0_len = strlen(muxname) - strlen(mode_name);
139 mode_name++; 137 mode_name++;
140 m0_name = muxname;
141 } else { 138 } else {
142 mode_name = muxname; 139 mode_name = muxname;
143 } 140 }
@@ -147,9 +144,11 @@ int __init omap_mux_init_signal(char *muxname, int val)
147 char *m0_entry = m->muxnames[0]; 144 char *m0_entry = m->muxnames[0];
148 int i; 145 int i;
149 146
150 if (m0_name && strcmp(m0_name, m0_entry)) 147 /* First check for full name in mode0.muxmode format */
148 if (mode0_len && strncmp(muxname, m0_entry, mode0_len))
151 continue; 149 continue;
152 150
151 /* Then check for muxmode only */
153 for (i = 0; i < OMAP_MUX_NR_MODES; i++) { 152 for (i = 0; i < OMAP_MUX_NR_MODES; i++) {
154 char *mode_cur = m->muxnames[i]; 153 char *mode_cur = m->muxnames[i];
155 154
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index a8e040c2c7e9..350c04f27383 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -120,7 +120,7 @@ int omap_mux_init_gpio(int gpio, int val);
120 * @muxname: Mux name in mode0_name.signal_name format 120 * @muxname: Mux name in mode0_name.signal_name format
121 * @val: Options for the mux register value 121 * @val: Options for the mux register value
122 */ 122 */
123int omap_mux_init_signal(char *muxname, int val); 123int omap_mux_init_signal(const char *muxname, int val);
124 124
125#else 125#else
126 126
diff --git a/arch/arm/mach-omap2/mux2420.c b/arch/arm/mach-omap2/mux2420.c
index fdb04a7eb8aa..414af5434456 100644
--- a/arch/arm/mach-omap2/mux2420.c
+++ b/arch/arm/mach-omap2/mux2420.c
@@ -507,7 +507,7 @@ static struct omap_mux __initdata omap2420_muxmodes[] = {
507 * Balls for 447-pin POP package 507 * Balls for 447-pin POP package
508 */ 508 */
509#ifdef CONFIG_DEBUG_FS 509#ifdef CONFIG_DEBUG_FS
510struct omap_ball __initdata omap2420_pop_ball[] = { 510static struct omap_ball __initdata omap2420_pop_ball[] = {
511 _OMAP2420_BALLENTRY(CAM_D0, "y4", NULL), 511 _OMAP2420_BALLENTRY(CAM_D0, "y4", NULL),
512 _OMAP2420_BALLENTRY(CAM_D1, "y3", NULL), 512 _OMAP2420_BALLENTRY(CAM_D1, "y3", NULL),
513 _OMAP2420_BALLENTRY(CAM_D2, "u7", NULL), 513 _OMAP2420_BALLENTRY(CAM_D2, "u7", NULL),
diff --git a/arch/arm/mach-omap2/mux2430.c b/arch/arm/mach-omap2/mux2430.c
index 7dcaaa8af32a..84d2c5a7ecd7 100644
--- a/arch/arm/mach-omap2/mux2430.c
+++ b/arch/arm/mach-omap2/mux2430.c
@@ -586,7 +586,7 @@ static struct omap_mux __initdata omap2430_muxmodes[] = {
586 * 447-pin s-PBGA Package, 0.00mm Ball Pitch (Bottom) 586 * 447-pin s-PBGA Package, 0.00mm Ball Pitch (Bottom)
587 */ 587 */
588#ifdef CONFIG_DEBUG_FS 588#ifdef CONFIG_DEBUG_FS
589struct omap_ball __initdata omap2430_pop_ball[] = { 589static struct omap_ball __initdata omap2430_pop_ball[] = {
590 _OMAP2430_BALLENTRY(CAM_D0, "t8", NULL), 590 _OMAP2430_BALLENTRY(CAM_D0, "t8", NULL),
591 _OMAP2430_BALLENTRY(CAM_D1, "t4", NULL), 591 _OMAP2430_BALLENTRY(CAM_D1, "t4", NULL),
592 _OMAP2430_BALLENTRY(CAM_D10, "r4", NULL), 592 _OMAP2430_BALLENTRY(CAM_D10, "r4", NULL),
diff --git a/arch/arm/mach-omap2/mux34xx.c b/arch/arm/mach-omap2/mux34xx.c
index f64d7eea3451..574e54ea3ab7 100644
--- a/arch/arm/mach-omap2/mux34xx.c
+++ b/arch/arm/mach-omap2/mux34xx.c
@@ -931,7 +931,7 @@ struct omap_ball __initdata omap3_cbc_ball[] = {
931 * Signals different on CUS package compared to superset 931 * Signals different on CUS package compared to superset
932 */ 932 */
933#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CUS) 933#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CUS)
934struct omap_mux __initdata omap3_cus_subset[] = { 934static struct omap_mux __initdata omap3_cus_subset[] = {
935 _OMAP3_MUXENTRY(CAM_D10, 109, 935 _OMAP3_MUXENTRY(CAM_D10, 109,
936 "cam_d10", NULL, NULL, NULL, 936 "cam_d10", NULL, NULL, NULL,
937 "gpio_109", NULL, NULL, "safe_mode"), 937 "gpio_109", NULL, NULL, "safe_mode"),
@@ -1077,7 +1077,7 @@ struct omap_mux __initdata omap3_cus_subset[] = {
1077 */ 1077 */
1078#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \ 1078#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \
1079 && defined(CONFIG_OMAP_PACKAGE_CUS) 1079 && defined(CONFIG_OMAP_PACKAGE_CUS)
1080struct omap_ball __initdata omap3_cus_ball[] = { 1080static struct omap_ball __initdata omap3_cus_ball[] = {
1081 _OMAP3_BALLENTRY(CAM_D0, "ab18", NULL), 1081 _OMAP3_BALLENTRY(CAM_D0, "ab18", NULL),
1082 _OMAP3_BALLENTRY(CAM_D1, "ac18", NULL), 1082 _OMAP3_BALLENTRY(CAM_D1, "ac18", NULL),
1083 _OMAP3_BALLENTRY(CAM_D10, "f21", NULL), 1083 _OMAP3_BALLENTRY(CAM_D10, "f21", NULL),
@@ -1269,7 +1269,7 @@ struct omap_ball __initdata omap3_cus_ball[] = {
1269 * Signals different on CBB package comapared to superset 1269 * Signals different on CBB package comapared to superset
1270 */ 1270 */
1271#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CBB) 1271#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CBB)
1272struct omap_mux __initdata omap3_cbb_subset[] = { 1272static struct omap_mux __initdata omap3_cbb_subset[] = {
1273 _OMAP3_MUXENTRY(CAM_D10, 109, 1273 _OMAP3_MUXENTRY(CAM_D10, 109,
1274 "cam_d10", NULL, NULL, NULL, 1274 "cam_d10", NULL, NULL, NULL,
1275 "gpio_109", NULL, NULL, "safe_mode"), 1275 "gpio_109", NULL, NULL, "safe_mode"),
@@ -1390,7 +1390,7 @@ struct omap_mux __initdata omap3_cbb_subset[] = {
1390 */ 1390 */
1391#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \ 1391#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \
1392 && defined(CONFIG_OMAP_PACKAGE_CBB) 1392 && defined(CONFIG_OMAP_PACKAGE_CBB)
1393struct omap_ball __initdata omap3_cbb_ball[] = { 1393static struct omap_ball __initdata omap3_cbb_ball[] = {
1394 _OMAP3_BALLENTRY(CAM_D0, "ag17", NULL), 1394 _OMAP3_BALLENTRY(CAM_D0, "ag17", NULL),
1395 _OMAP3_BALLENTRY(CAM_D1, "ah17", NULL), 1395 _OMAP3_BALLENTRY(CAM_D1, "ah17", NULL),
1396 _OMAP3_BALLENTRY(CAM_D10, "b25", NULL), 1396 _OMAP3_BALLENTRY(CAM_D10, "b25", NULL),
@@ -1600,7 +1600,7 @@ struct omap_ball __initdata omap3_cbb_ball[] = {
1600 * Signals different on 36XX CBP package comapared to 34XX CBC package 1600 * Signals different on 36XX CBP package comapared to 34XX CBC package
1601 */ 1601 */
1602#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CBP) 1602#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_OMAP_PACKAGE_CBP)
1603struct omap_mux __initdata omap36xx_cbp_subset[] = { 1603static struct omap_mux __initdata omap36xx_cbp_subset[] = {
1604 _OMAP3_MUXENTRY(CAM_D0, 99, 1604 _OMAP3_MUXENTRY(CAM_D0, 99,
1605 "cam_d0", NULL, "csi2_dx2", NULL, 1605 "cam_d0", NULL, "csi2_dx2", NULL,
1606 "gpio_99", NULL, NULL, "safe_mode"), 1606 "gpio_99", NULL, NULL, "safe_mode"),
@@ -1818,7 +1818,7 @@ struct omap_mux __initdata omap36xx_cbp_subset[] = {
1818 */ 1818 */
1819#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \ 1819#if defined(CONFIG_OMAP_MUX) && defined(CONFIG_DEBUG_FS) \
1820 && defined (CONFIG_OMAP_PACKAGE_CBP) 1820 && defined (CONFIG_OMAP_PACKAGE_CBP)
1821struct omap_ball __initdata omap36xx_cbp_ball[] = { 1821static struct omap_ball __initdata omap36xx_cbp_ball[] = {
1822 _OMAP3_BALLENTRY(CAM_D0, "ag17", NULL), 1822 _OMAP3_BALLENTRY(CAM_D0, "ag17", NULL),
1823 _OMAP3_BALLENTRY(CAM_D1, "ah17", NULL), 1823 _OMAP3_BALLENTRY(CAM_D1, "ah17", NULL),
1824 _OMAP3_BALLENTRY(CAM_D10, "b25", NULL), 1824 _OMAP3_BALLENTRY(CAM_D10, "b25", NULL),
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index 13dc9794dcc2..2f895553e6a8 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -44,6 +44,13 @@ void __init gic_init_irq(void)
44} 44}
45 45
46#ifdef CONFIG_CACHE_L2X0 46#ifdef CONFIG_CACHE_L2X0
47
48static void omap4_l2x0_disable(void)
49{
50 /* Disable PL310 L2 Cache controller */
51 omap_smc1(0x102, 0x0);
52}
53
47static int __init omap_l2_cache_init(void) 54static int __init omap_l2_cache_init(void)
48{ 55{
49 /* 56 /*
@@ -61,10 +68,20 @@ static int __init omap_l2_cache_init(void)
61 omap_smc1(0x102, 0x1); 68 omap_smc1(0x102, 0x1);
62 69
63 /* 70 /*
64 * 32KB way size, 16-way associativity, 71 * 16-way associativity, parity disabled
65 * parity disabled 72 * Way size - 32KB (es1.0)
73 * Way size - 64KB (es2.0 +)
66 */ 74 */
67 l2x0_init(l2cache_base, 0x0e050000, 0xc0000fff); 75 if (omap_rev() == OMAP4430_REV_ES1_0)
76 l2x0_init(l2cache_base, 0x0e050000, 0xc0000fff);
77 else
78 l2x0_init(l2cache_base, 0x0e070000, 0xc0000fff);
79
80 /*
81 * Override default outer_cache.disable with a OMAP4
82 * specific one
83 */
84 outer_cache.disable = omap4_l2x0_disable;
68 85
69 return 0; 86 return 0;
70} 87}
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index cb911d7d1a3c..5a30658444d0 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -13,10 +13,102 @@
13 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation. 14 * published by the Free Software Foundation.
15 * 15 *
16 * This code manages "OMAP modules" (on-chip devices) and their 16 * Introduction
17 * integration with Linux device driver and bus code. 17 * ------------
18 * 18 * One way to view an OMAP SoC is as a collection of largely unrelated
19 * References: 19 * IP blocks connected by interconnects. The IP blocks include
20 * devices such as ARM processors, audio serial interfaces, UARTs,
21 * etc. Some of these devices, like the DSP, are created by TI;
22 * others, like the SGX, largely originate from external vendors. In
23 * TI's documentation, on-chip devices are referred to as "OMAP
24 * modules." Some of these IP blocks are identical across several
25 * OMAP versions. Others are revised frequently.
26 *
27 * These OMAP modules are tied together by various interconnects.
28 * Most of the address and data flow between modules is via OCP-based
29 * interconnects such as the L3 and L4 buses; but there are other
30 * interconnects that distribute the hardware clock tree, handle idle
31 * and reset signaling, supply power, and connect the modules to
32 * various pads or balls on the OMAP package.
33 *
34 * OMAP hwmod provides a consistent way to describe the on-chip
35 * hardware blocks and their integration into the rest of the chip.
36 * This description can be automatically generated from the TI
37 * hardware database. OMAP hwmod provides a standard, consistent API
38 * to reset, enable, idle, and disable these hardware blocks. And
39 * hwmod provides a way for other core code, such as the Linux device
40 * code or the OMAP power management and address space mapping code,
41 * to query the hardware database.
42 *
43 * Using hwmod
44 * -----------
45 * Drivers won't call hwmod functions directly. That is done by the
46 * omap_device code, and in rare occasions, by custom integration code
47 * in arch/arm/ *omap*. The omap_device code includes functions to
48 * build a struct platform_device using omap_hwmod data, and that is
49 * currently how hwmod data is communicated to drivers and to the
50 * Linux driver model. Most drivers will call omap_hwmod functions only
51 * indirectly, via pm_runtime*() functions.
52 *
53 * From a layering perspective, here is where the OMAP hwmod code
54 * fits into the kernel software stack:
55 *
56 * +-------------------------------+
57 * | Device driver code |
58 * | (e.g., drivers/) |
59 * +-------------------------------+
60 * | Linux driver model |
61 * | (platform_device / |
62 * | platform_driver data/code) |
63 * +-------------------------------+
64 * | OMAP core-driver integration |
65 * |(arch/arm/mach-omap2/devices.c)|
66 * +-------------------------------+
67 * | omap_device code |
68 * | (../plat-omap/omap_device.c) |
69 * +-------------------------------+
70 * ----> | omap_hwmod code/data | <-----
71 * | (../mach-omap2/omap_hwmod*) |
72 * +-------------------------------+
73 * | OMAP clock/PRCM/register fns |
74 * | (__raw_{read,write}l, clk*) |
75 * +-------------------------------+
76 *
77 * Device drivers should not contain any OMAP-specific code or data in
78 * them. They should only contain code to operate the IP block that
79 * the driver is responsible for. This is because these IP blocks can
80 * also appear in other SoCs, either from TI (such as DaVinci) or from
81 * other manufacturers; and drivers should be reusable across other
82 * platforms.
83 *
84 * The OMAP hwmod code also will attempt to reset and idle all on-chip
85 * devices upon boot. The goal here is for the kernel to be
86 * completely self-reliant and independent from bootloaders. This is
87 * to ensure a repeatable configuration, both to ensure consistent
88 * runtime behavior, and to make it easier for others to reproduce
89 * bugs.
90 *
91 * OMAP module activity states
92 * ---------------------------
93 * The hwmod code considers modules to be in one of several activity
94 * states. IP blocks start out in an UNKNOWN state, then once they
95 * are registered via the hwmod code, proceed to the REGISTERED state.
96 * Once their clock names are resolved to clock pointers, the module
97 * enters the CLKS_INITED state; and finally, once the module has been
98 * reset and the integration registers programmed, the INITIALIZED state
99 * is entered. The hwmod code will then place the module into either
100 * the IDLE state to save power, or in the case of a critical system
101 * module, the ENABLED state.
102 *
103 * OMAP core integration code can then call omap_hwmod*() functions
104 * directly to move the module between the IDLE, ENABLED, and DISABLED
105 * states, as needed. This is done during both the PM idle loop, and
106 * in the OMAP core integration code's implementation of the PM runtime
107 * functions.
108 *
109 * References
110 * ----------
111 * This is a partial list.
20 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064) 112 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064)
21 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090) 113 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
22 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108) 114 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
@@ -50,11 +142,13 @@
50#include <plat/powerdomain.h> 142#include <plat/powerdomain.h>
51#include <plat/clock.h> 143#include <plat/clock.h>
52#include <plat/omap_hwmod.h> 144#include <plat/omap_hwmod.h>
145#include <plat/prcm.h>
53 146
54#include "cm.h" 147#include "cm.h"
148#include "prm.h"
55 149
56/* Maximum microseconds to wait for OMAP module to reset */ 150/* Maximum microseconds to wait for OMAP module to softreset */
57#define MAX_MODULE_RESET_WAIT 10000 151#define MAX_MODULE_SOFTRESET_WAIT 10000
58 152
59/* Name of the OMAP hwmod for the MPU */ 153/* Name of the OMAP hwmod for the MPU */
60#define MPU_INITIATOR_NAME "mpu" 154#define MPU_INITIATOR_NAME "mpu"
@@ -90,7 +184,7 @@ static int _update_sysc_cache(struct omap_hwmod *oh)
90 184
91 /* XXX ensure module interface clock is up */ 185 /* XXX ensure module interface clock is up */
92 186
93 oh->_sysc_cache = omap_hwmod_readl(oh, oh->class->sysc->sysc_offs); 187 oh->_sysc_cache = omap_hwmod_read(oh, oh->class->sysc->sysc_offs);
94 188
95 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) 189 if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE))
96 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; 190 oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED;
@@ -117,7 +211,7 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
117 211
118 if (oh->_sysc_cache != v) { 212 if (oh->_sysc_cache != v) {
119 oh->_sysc_cache = v; 213 oh->_sysc_cache = v;
120 omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs); 214 omap_hwmod_write(v, oh, oh->class->sysc->sysc_offs);
121 } 215 }
122} 216}
123 217
@@ -544,6 +638,36 @@ static int _disable_clocks(struct omap_hwmod *oh)
544 return 0; 638 return 0;
545} 639}
546 640
641static void _enable_optional_clocks(struct omap_hwmod *oh)
642{
643 struct omap_hwmod_opt_clk *oc;
644 int i;
645
646 pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name);
647
648 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
649 if (oc->_clk) {
650 pr_debug("omap_hwmod: enable %s:%s\n", oc->role,
651 oc->_clk->name);
652 clk_enable(oc->_clk);
653 }
654}
655
656static void _disable_optional_clocks(struct omap_hwmod *oh)
657{
658 struct omap_hwmod_opt_clk *oc;
659 int i;
660
661 pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name);
662
663 for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
664 if (oc->_clk) {
665 pr_debug("omap_hwmod: disable %s:%s\n", oc->role,
666 oc->_clk->name);
667 clk_disable(oc->_clk);
668 }
669}
670
547/** 671/**
548 * _find_mpu_port_index - find hwmod OCP slave port ID intended for MPU use 672 * _find_mpu_port_index - find hwmod OCP slave port ID intended for MPU use
549 * @oh: struct omap_hwmod * 673 * @oh: struct omap_hwmod *
@@ -622,7 +746,7 @@ static void __iomem *_find_mpu_rt_base(struct omap_hwmod *oh, u8 index)
622} 746}
623 747
624/** 748/**
625 * _sysc_enable - try to bring a module out of idle via OCP_SYSCONFIG 749 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG
626 * @oh: struct omap_hwmod * 750 * @oh: struct omap_hwmod *
627 * 751 *
628 * If module is marked as SWSUP_SIDLE, force the module out of slave 752 * If module is marked as SWSUP_SIDLE, force the module out of slave
@@ -630,7 +754,7 @@ static void __iomem *_find_mpu_rt_base(struct omap_hwmod *oh, u8 index)
630 * as SWSUP_MSUSPEND, force the module out of master standby; 754 * as SWSUP_MSUSPEND, force the module out of master standby;
631 * otherwise, configure it for smart-standby. No return value. 755 * otherwise, configure it for smart-standby. No return value.
632 */ 756 */
633static void _sysc_enable(struct omap_hwmod *oh) 757static void _enable_sysc(struct omap_hwmod *oh)
634{ 758{
635 u8 idlemode, sf; 759 u8 idlemode, sf;
636 u32 v; 760 u32 v;
@@ -653,14 +777,6 @@ static void _sysc_enable(struct omap_hwmod *oh)
653 _set_master_standbymode(oh, idlemode, &v); 777 _set_master_standbymode(oh, idlemode, &v);
654 } 778 }
655 779
656 if (sf & SYSC_HAS_AUTOIDLE) {
657 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ?
658 0 : 1;
659 _set_module_autoidle(oh, idlemode, &v);
660 }
661
662 /* XXX OCP ENAWAKEUP bit? */
663
664 /* 780 /*
665 * XXX The clock framework should handle this, by 781 * XXX The clock framework should handle this, by
666 * calling into this code. But this must wait until the 782 * calling into this code. But this must wait until the
@@ -671,10 +787,25 @@ static void _sysc_enable(struct omap_hwmod *oh)
671 _set_clockactivity(oh, oh->class->sysc->clockact, &v); 787 _set_clockactivity(oh, oh->class->sysc->clockact, &v);
672 788
673 _write_sysconfig(v, oh); 789 _write_sysconfig(v, oh);
790
791 /* If slave is in SMARTIDLE, also enable wakeup */
792 if ((sf & SYSC_HAS_SIDLEMODE) && !(oh->flags & HWMOD_SWSUP_SIDLE))
793 _enable_wakeup(oh);
794
795 /*
796 * Set the autoidle bit only after setting the smartidle bit
797 * Setting this will not have any impact on the other modules.
798 */
799 if (sf & SYSC_HAS_AUTOIDLE) {
800 idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ?
801 0 : 1;
802 _set_module_autoidle(oh, idlemode, &v);
803 _write_sysconfig(v, oh);
804 }
674} 805}
675 806
676/** 807/**
677 * _sysc_idle - try to put a module into idle via OCP_SYSCONFIG 808 * _idle_sysc - try to put a module into idle via OCP_SYSCONFIG
678 * @oh: struct omap_hwmod * 809 * @oh: struct omap_hwmod *
679 * 810 *
680 * If module is marked as SWSUP_SIDLE, force the module into slave 811 * If module is marked as SWSUP_SIDLE, force the module into slave
@@ -682,7 +813,7 @@ static void _sysc_enable(struct omap_hwmod *oh)
682 * as SWSUP_MSUSPEND, force the module into master standby; otherwise, 813 * as SWSUP_MSUSPEND, force the module into master standby; otherwise,
683 * configure it for smart-standby. No return value. 814 * configure it for smart-standby. No return value.
684 */ 815 */
685static void _sysc_idle(struct omap_hwmod *oh) 816static void _idle_sysc(struct omap_hwmod *oh)
686{ 817{
687 u8 idlemode, sf; 818 u8 idlemode, sf;
688 u32 v; 819 u32 v;
@@ -709,13 +840,13 @@ static void _sysc_idle(struct omap_hwmod *oh)
709} 840}
710 841
711/** 842/**
712 * _sysc_shutdown - force a module into idle via OCP_SYSCONFIG 843 * _shutdown_sysc - force a module into idle via OCP_SYSCONFIG
713 * @oh: struct omap_hwmod * 844 * @oh: struct omap_hwmod *
714 * 845 *
715 * Force the module into slave idle and master suspend. No return 846 * Force the module into slave idle and master suspend. No return
716 * value. 847 * value.
717 */ 848 */
718static void _sysc_shutdown(struct omap_hwmod *oh) 849static void _shutdown_sysc(struct omap_hwmod *oh)
719{ 850{
720 u32 v; 851 u32 v;
721 u8 sf; 852 u8 sf;
@@ -767,10 +898,10 @@ static struct omap_hwmod *_lookup(const char *name)
767 * @data: not used; pass NULL 898 * @data: not used; pass NULL
768 * 899 *
769 * Called by omap_hwmod_late_init() (after omap2_clk_init()). 900 * Called by omap_hwmod_late_init() (after omap2_clk_init()).
770 * Resolves all clock names embedded in the hwmod. Must be called 901 * Resolves all clock names embedded in the hwmod. Returns -EINVAL if
771 * with omap_hwmod_mutex held. Returns -EINVAL if the omap_hwmod 902 * the omap_hwmod has not yet been registered or if the clocks have
772 * has not yet been registered or if the clocks have already been 903 * already been initialized, 0 on success, or a non-zero error on
773 * initialized, 0 on success, or a non-zero error on failure. 904 * failure.
774 */ 905 */
775static int _init_clocks(struct omap_hwmod *oh, void *data) 906static int _init_clocks(struct omap_hwmod *oh, void *data)
776{ 907{
@@ -834,56 +965,202 @@ static int _wait_target_ready(struct omap_hwmod *oh)
834} 965}
835 966
836/** 967/**
968 * _lookup_hardreset - return the register bit shift for this hwmod/reset line
969 * @oh: struct omap_hwmod *
970 * @name: name of the reset line in the context of this hwmod
971 *
972 * Return the bit position of the reset line that match the
973 * input name. Return -ENOENT if not found.
974 */
975static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name)
976{
977 int i;
978
979 for (i = 0; i < oh->rst_lines_cnt; i++) {
980 const char *rst_line = oh->rst_lines[i].name;
981 if (!strcmp(rst_line, name)) {
982 u8 shift = oh->rst_lines[i].rst_shift;
983 pr_debug("omap_hwmod: %s: _lookup_hardreset: %s: %d\n",
984 oh->name, rst_line, shift);
985
986 return shift;
987 }
988 }
989
990 return -ENOENT;
991}
992
993/**
994 * _assert_hardreset - assert the HW reset line of submodules
995 * contained in the hwmod module.
996 * @oh: struct omap_hwmod *
997 * @name: name of the reset line to lookup and assert
998 *
999 * Some IP like dsp, ipu or iva contain processor that require
1000 * an HW reset line to be assert / deassert in order to enable fully
1001 * the IP.
1002 */
1003static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
1004{
1005 u8 shift;
1006
1007 if (!oh)
1008 return -EINVAL;
1009
1010 shift = _lookup_hardreset(oh, name);
1011 if (IS_ERR_VALUE(shift))
1012 return shift;
1013
1014 if (cpu_is_omap24xx() || cpu_is_omap34xx())
1015 return omap2_prm_assert_hardreset(oh->prcm.omap2.module_offs,
1016 shift);
1017 else if (cpu_is_omap44xx())
1018 return omap4_prm_assert_hardreset(oh->prcm.omap4.rstctrl_reg,
1019 shift);
1020 else
1021 return -EINVAL;
1022}
1023
1024/**
1025 * _deassert_hardreset - deassert the HW reset line of submodules contained
1026 * in the hwmod module.
1027 * @oh: struct omap_hwmod *
1028 * @name: name of the reset line to look up and deassert
1029 *
1030 * Some IP like dsp, ipu or iva contain processor that require
1031 * an HW reset line to be assert / deassert in order to enable fully
1032 * the IP.
1033 */
1034static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
1035{
1036 u8 shift;
1037 int r;
1038
1039 if (!oh)
1040 return -EINVAL;
1041
1042 shift = _lookup_hardreset(oh, name);
1043 if (IS_ERR_VALUE(shift))
1044 return shift;
1045
1046 if (cpu_is_omap24xx() || cpu_is_omap34xx())
1047 r = omap2_prm_deassert_hardreset(oh->prcm.omap2.module_offs,
1048 shift);
1049 else if (cpu_is_omap44xx())
1050 r = omap4_prm_deassert_hardreset(oh->prcm.omap4.rstctrl_reg,
1051 shift);
1052 else
1053 return -EINVAL;
1054
1055 if (r == -EBUSY)
1056 pr_warning("omap_hwmod: %s: failed to hardreset\n", oh->name);
1057
1058 return r;
1059}
1060
1061/**
1062 * _read_hardreset - read the HW reset line state of submodules
1063 * contained in the hwmod module
1064 * @oh: struct omap_hwmod *
1065 * @name: name of the reset line to look up and read
1066 *
1067 * Return the state of the reset line.
1068 */
1069static int _read_hardreset(struct omap_hwmod *oh, const char *name)
1070{
1071 u8 shift;
1072
1073 if (!oh)
1074 return -EINVAL;
1075
1076 shift = _lookup_hardreset(oh, name);
1077 if (IS_ERR_VALUE(shift))
1078 return shift;
1079
1080 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
1081 return omap2_prm_is_hardreset_asserted(oh->prcm.omap2.module_offs,
1082 shift);
1083 } else if (cpu_is_omap44xx()) {
1084 return omap4_prm_is_hardreset_asserted(oh->prcm.omap4.rstctrl_reg,
1085 shift);
1086 } else {
1087 return -EINVAL;
1088 }
1089}
1090
1091/**
837 * _reset - reset an omap_hwmod 1092 * _reset - reset an omap_hwmod
838 * @oh: struct omap_hwmod * 1093 * @oh: struct omap_hwmod *
839 * 1094 *
840 * Resets an omap_hwmod @oh via the OCP_SYSCONFIG bit. hwmod must be 1095 * Resets an omap_hwmod @oh via the OCP_SYSCONFIG bit. hwmod must be
841 * enabled for this to work. Must be called with omap_hwmod_mutex 1096 * enabled for this to work. Returns -EINVAL if the hwmod cannot be
842 * held. Returns -EINVAL if the hwmod cannot be reset this way or if 1097 * reset this way or if the hwmod is in the wrong state, -ETIMEDOUT if
843 * the hwmod is in the wrong state, -ETIMEDOUT if the module did not 1098 * the module did not reset in time, or 0 upon success.
844 * reset in time, or 0 upon success. 1099 *
1100 * In OMAP3 a specific SYSSTATUS register is used to get the reset status.
1101 * Starting in OMAP4, some IPs does not have SYSSTATUS register and instead
1102 * use the SYSCONFIG softreset bit to provide the status.
1103 *
1104 * Note that some IP like McBSP does have a reset control but no reset status.
845 */ 1105 */
846static int _reset(struct omap_hwmod *oh) 1106static int _reset(struct omap_hwmod *oh)
847{ 1107{
848 u32 r, v; 1108 u32 v;
849 int c = 0; 1109 int c = 0;
1110 int ret = 0;
850 1111
851 if (!oh->class->sysc || 1112 if (!oh->class->sysc ||
852 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET) || 1113 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
853 (oh->class->sysc->sysc_flags & SYSS_MISSING))
854 return -EINVAL; 1114 return -EINVAL;
855 1115
856 /* clocks must be on for this operation */ 1116 /* clocks must be on for this operation */
857 if (oh->_state != _HWMOD_STATE_ENABLED) { 1117 if (oh->_state != _HWMOD_STATE_ENABLED) {
858 WARN(1, "omap_hwmod: %s: reset can only be entered from " 1118 pr_warning("omap_hwmod: %s: reset can only be entered from "
859 "enabled state\n", oh->name); 1119 "enabled state\n", oh->name);
860 return -EINVAL; 1120 return -EINVAL;
861 } 1121 }
862 1122
1123 /* For some modules, all optionnal clocks need to be enabled as well */
1124 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1125 _enable_optional_clocks(oh);
1126
863 pr_debug("omap_hwmod: %s: resetting\n", oh->name); 1127 pr_debug("omap_hwmod: %s: resetting\n", oh->name);
864 1128
865 v = oh->_sysc_cache; 1129 v = oh->_sysc_cache;
866 r = _set_softreset(oh, &v); 1130 ret = _set_softreset(oh, &v);
867 if (r) 1131 if (ret)
868 return r; 1132 goto dis_opt_clks;
869 _write_sysconfig(v, oh); 1133 _write_sysconfig(v, oh);
870 1134
871 omap_test_timeout((omap_hwmod_readl(oh, oh->class->sysc->syss_offs) & 1135 if (oh->class->sysc->sysc_flags & SYSS_HAS_RESET_STATUS)
872 SYSS_RESETDONE_MASK), 1136 omap_test_timeout((omap_hwmod_read(oh,
873 MAX_MODULE_RESET_WAIT, c); 1137 oh->class->sysc->syss_offs)
874 1138 & SYSS_RESETDONE_MASK),
875 if (c == MAX_MODULE_RESET_WAIT) 1139 MAX_MODULE_SOFTRESET_WAIT, c);
876 WARN(1, "omap_hwmod: %s: failed to reset in %d usec\n", 1140 else if (oh->class->sysc->sysc_flags & SYSC_HAS_RESET_STATUS)
877 oh->name, MAX_MODULE_RESET_WAIT); 1141 omap_test_timeout(!(omap_hwmod_read(oh,
1142 oh->class->sysc->sysc_offs)
1143 & SYSC_TYPE2_SOFTRESET_MASK),
1144 MAX_MODULE_SOFTRESET_WAIT, c);
1145
1146 if (c == MAX_MODULE_SOFTRESET_WAIT)
1147 pr_warning("omap_hwmod: %s: softreset failed (waited %d usec)\n",
1148 oh->name, MAX_MODULE_SOFTRESET_WAIT);
878 else 1149 else
879 pr_debug("omap_hwmod: %s: reset in %d usec\n", oh->name, c); 1150 pr_debug("omap_hwmod: %s: softreset in %d usec\n", oh->name, c);
880 1151
881 /* 1152 /*
882 * XXX add _HWMOD_STATE_WEDGED for modules that don't come back from 1153 * XXX add _HWMOD_STATE_WEDGED for modules that don't come back from
883 * _wait_target_ready() or _reset() 1154 * _wait_target_ready() or _reset()
884 */ 1155 */
885 1156
886 return (c == MAX_MODULE_RESET_WAIT) ? -ETIMEDOUT : 0; 1157 ret = (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT : 0;
1158
1159dis_opt_clks:
1160 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1161 _disable_optional_clocks(oh);
1162
1163 return ret;
887} 1164}
888 1165
889/** 1166/**
@@ -891,9 +1168,11 @@ static int _reset(struct omap_hwmod *oh)
891 * @oh: struct omap_hwmod * 1168 * @oh: struct omap_hwmod *
892 * 1169 *
893 * Enables an omap_hwmod @oh such that the MPU can access the hwmod's 1170 * Enables an omap_hwmod @oh such that the MPU can access the hwmod's
894 * register target. Must be called with omap_hwmod_mutex held. 1171 * register target. (This function has a full name --
895 * Returns -EINVAL if the hwmod is in the wrong state or passes along 1172 * _omap_hwmod_enable() rather than simply _enable() -- because it is
896 * the return value of _wait_target_ready(). 1173 * currently required by the pm34xx.c idle loop.) Returns -EINVAL if
1174 * the hwmod is in the wrong state or passes along the return value of
1175 * _wait_target_ready().
897 */ 1176 */
898int _omap_hwmod_enable(struct omap_hwmod *oh) 1177int _omap_hwmod_enable(struct omap_hwmod *oh)
899{ 1178{
@@ -909,6 +1188,15 @@ int _omap_hwmod_enable(struct omap_hwmod *oh)
909 1188
910 pr_debug("omap_hwmod: %s: enabling\n", oh->name); 1189 pr_debug("omap_hwmod: %s: enabling\n", oh->name);
911 1190
1191 /*
1192 * If an IP contains only one HW reset line, then de-assert it in order
1193 * to allow to enable the clocks. Otherwise the PRCM will return
1194 * Intransition status, and the init will failed.
1195 */
1196 if ((oh->_state == _HWMOD_STATE_INITIALIZED ||
1197 oh->_state == _HWMOD_STATE_DISABLED) && oh->rst_lines_cnt == 1)
1198 _deassert_hardreset(oh, oh->rst_lines[0].name);
1199
912 /* XXX mux balls */ 1200 /* XXX mux balls */
913 1201
914 _add_initiator_dep(oh, mpu_oh); 1202 _add_initiator_dep(oh, mpu_oh);
@@ -922,7 +1210,7 @@ int _omap_hwmod_enable(struct omap_hwmod *oh)
922 if (oh->class->sysc) { 1210 if (oh->class->sysc) {
923 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) 1211 if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED))
924 _update_sysc_cache(oh); 1212 _update_sysc_cache(oh);
925 _sysc_enable(oh); 1213 _enable_sysc(oh);
926 } 1214 }
927 } else { 1215 } else {
928 pr_debug("omap_hwmod: %s: _wait_target_ready: %d\n", 1216 pr_debug("omap_hwmod: %s: _wait_target_ready: %d\n",
@@ -933,12 +1221,14 @@ int _omap_hwmod_enable(struct omap_hwmod *oh)
933} 1221}
934 1222
935/** 1223/**
936 * _idle - idle an omap_hwmod 1224 * _omap_hwmod_idle - idle an omap_hwmod
937 * @oh: struct omap_hwmod * 1225 * @oh: struct omap_hwmod *
938 * 1226 *
939 * Idles an omap_hwmod @oh. This should be called once the hwmod has 1227 * Idles an omap_hwmod @oh. This should be called once the hwmod has
940 * no further work. Returns -EINVAL if the hwmod is in the wrong 1228 * no further work. (This function has a full name --
941 * state or returns 0. 1229 * _omap_hwmod_idle() rather than simply _idle() -- because it is
1230 * currently required by the pm34xx.c idle loop.) Returns -EINVAL if
1231 * the hwmod is in the wrong state or returns 0.
942 */ 1232 */
943int _omap_hwmod_idle(struct omap_hwmod *oh) 1233int _omap_hwmod_idle(struct omap_hwmod *oh)
944{ 1234{
@@ -951,7 +1241,7 @@ int _omap_hwmod_idle(struct omap_hwmod *oh)
951 pr_debug("omap_hwmod: %s: idling\n", oh->name); 1241 pr_debug("omap_hwmod: %s: idling\n", oh->name);
952 1242
953 if (oh->class->sysc) 1243 if (oh->class->sysc)
954 _sysc_idle(oh); 1244 _idle_sysc(oh);
955 _del_initiator_dep(oh, mpu_oh); 1245 _del_initiator_dep(oh, mpu_oh);
956 _disable_clocks(oh); 1246 _disable_clocks(oh);
957 1247
@@ -981,10 +1271,21 @@ static int _shutdown(struct omap_hwmod *oh)
981 pr_debug("omap_hwmod: %s: disabling\n", oh->name); 1271 pr_debug("omap_hwmod: %s: disabling\n", oh->name);
982 1272
983 if (oh->class->sysc) 1273 if (oh->class->sysc)
984 _sysc_shutdown(oh); 1274 _shutdown_sysc(oh);
985 _del_initiator_dep(oh, mpu_oh); 1275
986 /* XXX what about the other system initiators here? DMA, tesla, d2d */ 1276 /*
987 _disable_clocks(oh); 1277 * If an IP contains only one HW reset line, then assert it
1278 * before disabling the clocks and shutting down the IP.
1279 */
1280 if (oh->rst_lines_cnt == 1)
1281 _assert_hardreset(oh, oh->rst_lines[0].name);
1282
1283 /* clocks and deps are already disabled in idle */
1284 if (oh->_state == _HWMOD_STATE_ENABLED) {
1285 _del_initiator_dep(oh, mpu_oh);
1286 /* XXX what about the other system initiators here? dma, dsp */
1287 _disable_clocks(oh);
1288 }
988 /* XXX Should this code also force-disable the optional clocks? */ 1289 /* XXX Should this code also force-disable the optional clocks? */
989 1290
990 /* XXX mux any associated balls to safe mode */ 1291 /* XXX mux any associated balls to safe mode */
@@ -1000,11 +1301,10 @@ static int _shutdown(struct omap_hwmod *oh)
1000 * @skip_setup_idle_p: do not idle hwmods at the end of the fn if 1 1301 * @skip_setup_idle_p: do not idle hwmods at the end of the fn if 1
1001 * 1302 *
1002 * Writes the CLOCKACTIVITY bits @clockact to the hwmod @oh 1303 * Writes the CLOCKACTIVITY bits @clockact to the hwmod @oh
1003 * OCP_SYSCONFIG register. Must be called with omap_hwmod_mutex held. 1304 * OCP_SYSCONFIG register. @skip_setup_idle is intended to be used on
1004 * @skip_setup_idle is intended to be used on a system that will not 1305 * a system that will not call omap_hwmod_enable() to enable devices
1005 * call omap_hwmod_enable() to enable devices (e.g., a system without 1306 * (e.g., a system without PM runtime). Returns -EINVAL if the hwmod
1006 * PM runtime). Returns -EINVAL if the hwmod is in the wrong state or 1307 * is in the wrong state or returns 0.
1007 * returns 0.
1008 */ 1308 */
1009static int _setup(struct omap_hwmod *oh, void *data) 1309static int _setup(struct omap_hwmod *oh, void *data)
1010{ 1310{
@@ -1034,8 +1334,19 @@ static int _setup(struct omap_hwmod *oh, void *data)
1034 } 1334 }
1035 } 1335 }
1036 1336
1337 mutex_init(&oh->_mutex);
1037 oh->_state = _HWMOD_STATE_INITIALIZED; 1338 oh->_state = _HWMOD_STATE_INITIALIZED;
1038 1339
1340 /*
1341 * In the case of hwmod with hardreset that should not be
1342 * de-assert at boot time, we have to keep the module
1343 * initialized, because we cannot enable it properly with the
1344 * reset asserted. Exit without warning because that behavior is
1345 * expected.
1346 */
1347 if ((oh->flags & HWMOD_INIT_NO_RESET) && oh->rst_lines_cnt == 1)
1348 return 0;
1349
1039 r = _omap_hwmod_enable(oh); 1350 r = _omap_hwmod_enable(oh);
1040 if (r) { 1351 if (r) {
1041 pr_warning("omap_hwmod: %s: cannot be enabled (%d)\n", 1352 pr_warning("omap_hwmod: %s: cannot be enabled (%d)\n",
@@ -1044,16 +1355,16 @@ static int _setup(struct omap_hwmod *oh, void *data)
1044 } 1355 }
1045 1356
1046 if (!(oh->flags & HWMOD_INIT_NO_RESET)) { 1357 if (!(oh->flags & HWMOD_INIT_NO_RESET)) {
1358 _reset(oh);
1359
1047 /* 1360 /*
1048 * XXX Do the OCP_SYSCONFIG bits need to be 1361 * OCP_SYSCONFIG bits need to be reprogrammed after a softreset.
1049 * reprogrammed after a reset? If not, then this can 1362 * The _omap_hwmod_enable() function should be split to
1050 * be removed. If they do, then probably the 1363 * avoid the rewrite of the OCP_SYSCONFIG register.
1051 * _omap_hwmod_enable() function should be split to avoid the
1052 * rewrite of the OCP_SYSCONFIG register.
1053 */ 1364 */
1054 if (oh->class->sysc) { 1365 if (oh->class->sysc) {
1055 _update_sysc_cache(oh); 1366 _update_sysc_cache(oh);
1056 _sysc_enable(oh); 1367 _enable_sysc(oh);
1057 } 1368 }
1058 } 1369 }
1059 1370
@@ -1067,14 +1378,20 @@ static int _setup(struct omap_hwmod *oh, void *data)
1067 1378
1068/* Public functions */ 1379/* Public functions */
1069 1380
1070u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs) 1381u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs)
1071{ 1382{
1072 return __raw_readl(oh->_mpu_rt_va + reg_offs); 1383 if (oh->flags & HWMOD_16BIT_REG)
1384 return __raw_readw(oh->_mpu_rt_va + reg_offs);
1385 else
1386 return __raw_readl(oh->_mpu_rt_va + reg_offs);
1073} 1387}
1074 1388
1075void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs) 1389void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs)
1076{ 1390{
1077 __raw_writel(v, oh->_mpu_rt_va + reg_offs); 1391 if (oh->flags & HWMOD_16BIT_REG)
1392 __raw_writew(v, oh->_mpu_rt_va + reg_offs);
1393 else
1394 __raw_writel(v, oh->_mpu_rt_va + reg_offs);
1078} 1395}
1079 1396
1080/** 1397/**
@@ -1309,7 +1626,7 @@ int omap_hwmod_unregister(struct omap_hwmod *oh)
1309 * omap_hwmod_enable - enable an omap_hwmod 1626 * omap_hwmod_enable - enable an omap_hwmod
1310 * @oh: struct omap_hwmod * 1627 * @oh: struct omap_hwmod *
1311 * 1628 *
1312 * Enable an omap_hwomd @oh. Intended to be called by omap_device_enable(). 1629 * Enable an omap_hwmod @oh. Intended to be called by omap_device_enable().
1313 * Returns -EINVAL on error or passes along the return value from _enable(). 1630 * Returns -EINVAL on error or passes along the return value from _enable().
1314 */ 1631 */
1315int omap_hwmod_enable(struct omap_hwmod *oh) 1632int omap_hwmod_enable(struct omap_hwmod *oh)
@@ -1319,9 +1636,9 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
1319 if (!oh) 1636 if (!oh)
1320 return -EINVAL; 1637 return -EINVAL;
1321 1638
1322 mutex_lock(&omap_hwmod_mutex); 1639 mutex_lock(&oh->_mutex);
1323 r = _omap_hwmod_enable(oh); 1640 r = _omap_hwmod_enable(oh);
1324 mutex_unlock(&omap_hwmod_mutex); 1641 mutex_unlock(&oh->_mutex);
1325 1642
1326 return r; 1643 return r;
1327} 1644}
@@ -1331,7 +1648,7 @@ int omap_hwmod_enable(struct omap_hwmod *oh)
1331 * omap_hwmod_idle - idle an omap_hwmod 1648 * omap_hwmod_idle - idle an omap_hwmod
1332 * @oh: struct omap_hwmod * 1649 * @oh: struct omap_hwmod *
1333 * 1650 *
1334 * Idle an omap_hwomd @oh. Intended to be called by omap_device_idle(). 1651 * Idle an omap_hwmod @oh. Intended to be called by omap_device_idle().
1335 * Returns -EINVAL on error or passes along the return value from _idle(). 1652 * Returns -EINVAL on error or passes along the return value from _idle().
1336 */ 1653 */
1337int omap_hwmod_idle(struct omap_hwmod *oh) 1654int omap_hwmod_idle(struct omap_hwmod *oh)
@@ -1339,9 +1656,9 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
1339 if (!oh) 1656 if (!oh)
1340 return -EINVAL; 1657 return -EINVAL;
1341 1658
1342 mutex_lock(&omap_hwmod_mutex); 1659 mutex_lock(&oh->_mutex);
1343 _omap_hwmod_idle(oh); 1660 _omap_hwmod_idle(oh);
1344 mutex_unlock(&omap_hwmod_mutex); 1661 mutex_unlock(&oh->_mutex);
1345 1662
1346 return 0; 1663 return 0;
1347} 1664}
@@ -1350,7 +1667,7 @@ int omap_hwmod_idle(struct omap_hwmod *oh)
1350 * omap_hwmod_shutdown - shutdown an omap_hwmod 1667 * omap_hwmod_shutdown - shutdown an omap_hwmod
1351 * @oh: struct omap_hwmod * 1668 * @oh: struct omap_hwmod *
1352 * 1669 *
1353 * Shutdown an omap_hwomd @oh. Intended to be called by 1670 * Shutdown an omap_hwmod @oh. Intended to be called by
1354 * omap_device_shutdown(). Returns -EINVAL on error or passes along 1671 * omap_device_shutdown(). Returns -EINVAL on error or passes along
1355 * the return value from _shutdown(). 1672 * the return value from _shutdown().
1356 */ 1673 */
@@ -1359,9 +1676,9 @@ int omap_hwmod_shutdown(struct omap_hwmod *oh)
1359 if (!oh) 1676 if (!oh)
1360 return -EINVAL; 1677 return -EINVAL;
1361 1678
1362 mutex_lock(&omap_hwmod_mutex); 1679 mutex_lock(&oh->_mutex);
1363 _shutdown(oh); 1680 _shutdown(oh);
1364 mutex_unlock(&omap_hwmod_mutex); 1681 mutex_unlock(&oh->_mutex);
1365 1682
1366 return 0; 1683 return 0;
1367} 1684}
@@ -1374,9 +1691,9 @@ int omap_hwmod_shutdown(struct omap_hwmod *oh)
1374 */ 1691 */
1375int omap_hwmod_enable_clocks(struct omap_hwmod *oh) 1692int omap_hwmod_enable_clocks(struct omap_hwmod *oh)
1376{ 1693{
1377 mutex_lock(&omap_hwmod_mutex); 1694 mutex_lock(&oh->_mutex);
1378 _enable_clocks(oh); 1695 _enable_clocks(oh);
1379 mutex_unlock(&omap_hwmod_mutex); 1696 mutex_unlock(&oh->_mutex);
1380 1697
1381 return 0; 1698 return 0;
1382} 1699}
@@ -1389,9 +1706,9 @@ int omap_hwmod_enable_clocks(struct omap_hwmod *oh)
1389 */ 1706 */
1390int omap_hwmod_disable_clocks(struct omap_hwmod *oh) 1707int omap_hwmod_disable_clocks(struct omap_hwmod *oh)
1391{ 1708{
1392 mutex_lock(&omap_hwmod_mutex); 1709 mutex_lock(&oh->_mutex);
1393 _disable_clocks(oh); 1710 _disable_clocks(oh);
1394 mutex_unlock(&omap_hwmod_mutex); 1711 mutex_unlock(&oh->_mutex);
1395 1712
1396 return 0; 1713 return 0;
1397} 1714}
@@ -1421,7 +1738,7 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh)
1421 * Forces posted writes to complete on the OCP thread handling 1738 * Forces posted writes to complete on the OCP thread handling
1422 * register writes 1739 * register writes
1423 */ 1740 */
1424 omap_hwmod_readl(oh, oh->class->sysc->sysc_offs); 1741 omap_hwmod_read(oh, oh->class->sysc->sysc_offs);
1425} 1742}
1426 1743
1427/** 1744/**
@@ -1430,20 +1747,18 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh)
1430 * 1747 *
1431 * Under some conditions, a driver may wish to reset the entire device. 1748 * Under some conditions, a driver may wish to reset the entire device.
1432 * Called from omap_device code. Returns -EINVAL on error or passes along 1749 * Called from omap_device code. Returns -EINVAL on error or passes along
1433 * the return value from _reset()/_enable(). 1750 * the return value from _reset().
1434 */ 1751 */
1435int omap_hwmod_reset(struct omap_hwmod *oh) 1752int omap_hwmod_reset(struct omap_hwmod *oh)
1436{ 1753{
1437 int r; 1754 int r;
1438 1755
1439 if (!oh || !(oh->_state & _HWMOD_STATE_ENABLED)) 1756 if (!oh)
1440 return -EINVAL; 1757 return -EINVAL;
1441 1758
1442 mutex_lock(&omap_hwmod_mutex); 1759 mutex_lock(&oh->_mutex);
1443 r = _reset(oh); 1760 r = _reset(oh);
1444 if (!r) 1761 mutex_unlock(&oh->_mutex);
1445 r = _omap_hwmod_enable(oh);
1446 mutex_unlock(&omap_hwmod_mutex);
1447 1762
1448 return r; 1763 return r;
1449} 1764}
@@ -1468,7 +1783,7 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh)
1468{ 1783{
1469 int ret, i; 1784 int ret, i;
1470 1785
1471 ret = oh->mpu_irqs_cnt + oh->sdma_chs_cnt; 1786 ret = oh->mpu_irqs_cnt + oh->sdma_reqs_cnt;
1472 1787
1473 for (i = 0; i < oh->slaves_cnt; i++) 1788 for (i = 0; i < oh->slaves_cnt; i++)
1474 ret += oh->slaves[i]->addr_cnt; 1789 ret += oh->slaves[i]->addr_cnt;
@@ -1501,10 +1816,10 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
1501 r++; 1816 r++;
1502 } 1817 }
1503 1818
1504 for (i = 0; i < oh->sdma_chs_cnt; i++) { 1819 for (i = 0; i < oh->sdma_reqs_cnt; i++) {
1505 (res + r)->name = (oh->sdma_chs + i)->name; 1820 (res + r)->name = (oh->sdma_reqs + i)->name;
1506 (res + r)->start = (oh->sdma_chs + i)->dma_ch; 1821 (res + r)->start = (oh->sdma_reqs + i)->dma_req;
1507 (res + r)->end = (oh->sdma_chs + i)->dma_ch; 1822 (res + r)->end = (oh->sdma_reqs + i)->dma_req;
1508 (res + r)->flags = IORESOURCE_DMA; 1823 (res + r)->flags = IORESOURCE_DMA;
1509 r++; 1824 r++;
1510 } 1825 }
@@ -1644,9 +1959,9 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh)
1644 !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) 1959 !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP))
1645 return -EINVAL; 1960 return -EINVAL;
1646 1961
1647 mutex_lock(&omap_hwmod_mutex); 1962 mutex_lock(&oh->_mutex);
1648 _enable_wakeup(oh); 1963 _enable_wakeup(oh);
1649 mutex_unlock(&omap_hwmod_mutex); 1964 mutex_unlock(&oh->_mutex);
1650 1965
1651 return 0; 1966 return 0;
1652} 1967}
@@ -1669,14 +1984,92 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh)
1669 !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) 1984 !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP))
1670 return -EINVAL; 1985 return -EINVAL;
1671 1986
1672 mutex_lock(&omap_hwmod_mutex); 1987 mutex_lock(&oh->_mutex);
1673 _disable_wakeup(oh); 1988 _disable_wakeup(oh);
1674 mutex_unlock(&omap_hwmod_mutex); 1989 mutex_unlock(&oh->_mutex);
1675 1990
1676 return 0; 1991 return 0;
1677} 1992}
1678 1993
1679/** 1994/**
1995 * omap_hwmod_assert_hardreset - assert the HW reset line of submodules
1996 * contained in the hwmod module.
1997 * @oh: struct omap_hwmod *
1998 * @name: name of the reset line to lookup and assert
1999 *
2000 * Some IP like dsp, ipu or iva contain processor that require
2001 * an HW reset line to be assert / deassert in order to enable fully
2002 * the IP. Returns -EINVAL if @oh is null or if the operation is not
2003 * yet supported on this OMAP; otherwise, passes along the return value
2004 * from _assert_hardreset().
2005 */
2006int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name)
2007{
2008 int ret;
2009
2010 if (!oh)
2011 return -EINVAL;
2012
2013 mutex_lock(&oh->_mutex);
2014 ret = _assert_hardreset(oh, name);
2015 mutex_unlock(&oh->_mutex);
2016
2017 return ret;
2018}
2019
2020/**
2021 * omap_hwmod_deassert_hardreset - deassert the HW reset line of submodules
2022 * contained in the hwmod module.
2023 * @oh: struct omap_hwmod *
2024 * @name: name of the reset line to look up and deassert
2025 *
2026 * Some IP like dsp, ipu or iva contain processor that require
2027 * an HW reset line to be assert / deassert in order to enable fully
2028 * the IP. Returns -EINVAL if @oh is null or if the operation is not
2029 * yet supported on this OMAP; otherwise, passes along the return value
2030 * from _deassert_hardreset().
2031 */
2032int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name)
2033{
2034 int ret;
2035
2036 if (!oh)
2037 return -EINVAL;
2038
2039 mutex_lock(&oh->_mutex);
2040 ret = _deassert_hardreset(oh, name);
2041 mutex_unlock(&oh->_mutex);
2042
2043 return ret;
2044}
2045
2046/**
2047 * omap_hwmod_read_hardreset - read the HW reset line state of submodules
2048 * contained in the hwmod module
2049 * @oh: struct omap_hwmod *
2050 * @name: name of the reset line to look up and read
2051 *
2052 * Return the current state of the hwmod @oh's reset line named @name:
2053 * returns -EINVAL upon parameter error or if this operation
2054 * is unsupported on the current OMAP; otherwise, passes along the return
2055 * value from _read_hardreset().
2056 */
2057int omap_hwmod_read_hardreset(struct omap_hwmod *oh, const char *name)
2058{
2059 int ret;
2060
2061 if (!oh)
2062 return -EINVAL;
2063
2064 mutex_lock(&oh->_mutex);
2065 ret = _read_hardreset(oh, name);
2066 mutex_unlock(&oh->_mutex);
2067
2068 return ret;
2069}
2070
2071
2072/**
1680 * omap_hwmod_for_each_by_class - call @fn for each hwmod of class @classname 2073 * omap_hwmod_for_each_by_class - call @fn for each hwmod of class @classname
1681 * @classname: struct omap_hwmod_class name to search for 2074 * @classname: struct omap_hwmod_class name to search for
1682 * @fn: callback function pointer to call for each hwmod in class @classname 2075 * @fn: callback function pointer to call for each hwmod in class @classname
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index 3cc768e8bc04..adf6e3632a2b 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -15,10 +15,12 @@
15#include <mach/irqs.h> 15#include <mach/irqs.h>
16#include <plat/cpu.h> 16#include <plat/cpu.h>
17#include <plat/dma.h> 17#include <plat/dma.h>
18#include <plat/serial.h>
18 19
19#include "omap_hwmod_common_data.h" 20#include "omap_hwmod_common_data.h"
20 21
21#include "prm-regbits-24xx.h" 22#include "prm-regbits-24xx.h"
23#include "cm-regbits-24xx.h"
22 24
23/* 25/*
24 * OMAP2420 hardware module integration data 26 * OMAP2420 hardware module integration data
@@ -33,6 +35,7 @@ static struct omap_hwmod omap2420_mpu_hwmod;
33static struct omap_hwmod omap2420_iva_hwmod; 35static struct omap_hwmod omap2420_iva_hwmod;
34static struct omap_hwmod omap2420_l3_main_hwmod; 36static struct omap_hwmod omap2420_l3_main_hwmod;
35static struct omap_hwmod omap2420_l4_core_hwmod; 37static struct omap_hwmod omap2420_l4_core_hwmod;
38static struct omap_hwmod omap2420_wd_timer2_hwmod;
36 39
37/* L3 -> L4_CORE interface */ 40/* L3 -> L4_CORE interface */
38static struct omap_hwmod_ocp_if omap2420_l3_main__l4_core = { 41static struct omap_hwmod_ocp_if omap2420_l3_main__l4_core = {
@@ -71,6 +74,9 @@ static struct omap_hwmod omap2420_l3_main_hwmod = {
71}; 74};
72 75
73static struct omap_hwmod omap2420_l4_wkup_hwmod; 76static struct omap_hwmod omap2420_l4_wkup_hwmod;
77static struct omap_hwmod omap2420_uart1_hwmod;
78static struct omap_hwmod omap2420_uart2_hwmod;
79static struct omap_hwmod omap2420_uart3_hwmod;
74 80
75/* L4_CORE -> L4_WKUP interface */ 81/* L4_CORE -> L4_WKUP interface */
76static struct omap_hwmod_ocp_if omap2420_l4_core__l4_wkup = { 82static struct omap_hwmod_ocp_if omap2420_l4_core__l4_wkup = {
@@ -79,6 +85,60 @@ static struct omap_hwmod_ocp_if omap2420_l4_core__l4_wkup = {
79 .user = OCP_USER_MPU | OCP_USER_SDMA, 85 .user = OCP_USER_MPU | OCP_USER_SDMA,
80}; 86};
81 87
88/* L4 CORE -> UART1 interface */
89static struct omap_hwmod_addr_space omap2420_uart1_addr_space[] = {
90 {
91 .pa_start = OMAP2_UART1_BASE,
92 .pa_end = OMAP2_UART1_BASE + SZ_8K - 1,
93 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
94 },
95};
96
97static struct omap_hwmod_ocp_if omap2_l4_core__uart1 = {
98 .master = &omap2420_l4_core_hwmod,
99 .slave = &omap2420_uart1_hwmod,
100 .clk = "uart1_ick",
101 .addr = omap2420_uart1_addr_space,
102 .addr_cnt = ARRAY_SIZE(omap2420_uart1_addr_space),
103 .user = OCP_USER_MPU | OCP_USER_SDMA,
104};
105
106/* L4 CORE -> UART2 interface */
107static struct omap_hwmod_addr_space omap2420_uart2_addr_space[] = {
108 {
109 .pa_start = OMAP2_UART2_BASE,
110 .pa_end = OMAP2_UART2_BASE + SZ_1K - 1,
111 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
112 },
113};
114
115static struct omap_hwmod_ocp_if omap2_l4_core__uart2 = {
116 .master = &omap2420_l4_core_hwmod,
117 .slave = &omap2420_uart2_hwmod,
118 .clk = "uart2_ick",
119 .addr = omap2420_uart2_addr_space,
120 .addr_cnt = ARRAY_SIZE(omap2420_uart2_addr_space),
121 .user = OCP_USER_MPU | OCP_USER_SDMA,
122};
123
124/* L4 PER -> UART3 interface */
125static struct omap_hwmod_addr_space omap2420_uart3_addr_space[] = {
126 {
127 .pa_start = OMAP2_UART3_BASE,
128 .pa_end = OMAP2_UART3_BASE + SZ_1K - 1,
129 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
130 },
131};
132
133static struct omap_hwmod_ocp_if omap2_l4_core__uart3 = {
134 .master = &omap2420_l4_core_hwmod,
135 .slave = &omap2420_uart3_hwmod,
136 .clk = "uart3_ick",
137 .addr = omap2420_uart3_addr_space,
138 .addr_cnt = ARRAY_SIZE(omap2420_uart3_addr_space),
139 .user = OCP_USER_MPU | OCP_USER_SDMA,
140};
141
82/* Slave interfaces on the L4_CORE interconnect */ 142/* Slave interfaces on the L4_CORE interconnect */
83static struct omap_hwmod_ocp_if *omap2420_l4_core_slaves[] = { 143static struct omap_hwmod_ocp_if *omap2420_l4_core_slaves[] = {
84 &omap2420_l3_main__l4_core, 144 &omap2420_l3_main__l4_core,
@@ -87,6 +147,9 @@ static struct omap_hwmod_ocp_if *omap2420_l4_core_slaves[] = {
87/* Master interfaces on the L4_CORE interconnect */ 147/* Master interfaces on the L4_CORE interconnect */
88static struct omap_hwmod_ocp_if *omap2420_l4_core_masters[] = { 148static struct omap_hwmod_ocp_if *omap2420_l4_core_masters[] = {
89 &omap2420_l4_core__l4_wkup, 149 &omap2420_l4_core__l4_wkup,
150 &omap2_l4_core__uart1,
151 &omap2_l4_core__uart2,
152 &omap2_l4_core__uart3,
90}; 153};
91 154
92/* L4 CORE */ 155/* L4 CORE */
@@ -165,12 +228,206 @@ static struct omap_hwmod omap2420_iva_hwmod = {
165 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420) 228 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420)
166}; 229};
167 230
231/* l4_wkup -> wd_timer2 */
232static struct omap_hwmod_addr_space omap2420_wd_timer2_addrs[] = {
233 {
234 .pa_start = 0x48022000,
235 .pa_end = 0x4802207f,
236 .flags = ADDR_TYPE_RT
237 },
238};
239
240static struct omap_hwmod_ocp_if omap2420_l4_wkup__wd_timer2 = {
241 .master = &omap2420_l4_wkup_hwmod,
242 .slave = &omap2420_wd_timer2_hwmod,
243 .clk = "mpu_wdt_ick",
244 .addr = omap2420_wd_timer2_addrs,
245 .addr_cnt = ARRAY_SIZE(omap2420_wd_timer2_addrs),
246 .user = OCP_USER_MPU | OCP_USER_SDMA,
247};
248
249/*
250 * 'wd_timer' class
251 * 32-bit watchdog upward counter that generates a pulse on the reset pin on
252 * overflow condition
253 */
254
255static struct omap_hwmod_class_sysconfig omap2420_wd_timer_sysc = {
256 .rev_offs = 0x0000,
257 .sysc_offs = 0x0010,
258 .syss_offs = 0x0014,
259 .sysc_flags = (SYSC_HAS_EMUFREE | SYSC_HAS_SOFTRESET |
260 SYSC_HAS_AUTOIDLE),
261 .sysc_fields = &omap_hwmod_sysc_type1,
262};
263
264static struct omap_hwmod_class omap2420_wd_timer_hwmod_class = {
265 .name = "wd_timer",
266 .sysc = &omap2420_wd_timer_sysc,
267};
268
269/* wd_timer2 */
270static struct omap_hwmod_ocp_if *omap2420_wd_timer2_slaves[] = {
271 &omap2420_l4_wkup__wd_timer2,
272};
273
274static struct omap_hwmod omap2420_wd_timer2_hwmod = {
275 .name = "wd_timer2",
276 .class = &omap2420_wd_timer_hwmod_class,
277 .main_clk = "mpu_wdt_fck",
278 .prcm = {
279 .omap2 = {
280 .prcm_reg_id = 1,
281 .module_bit = OMAP24XX_EN_MPU_WDT_SHIFT,
282 .module_offs = WKUP_MOD,
283 .idlest_reg_id = 1,
284 .idlest_idle_bit = OMAP24XX_ST_MPU_WDT_SHIFT,
285 },
286 },
287 .slaves = omap2420_wd_timer2_slaves,
288 .slaves_cnt = ARRAY_SIZE(omap2420_wd_timer2_slaves),
289 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
290};
291
292/* UART */
293
294static struct omap_hwmod_class_sysconfig uart_sysc = {
295 .rev_offs = 0x50,
296 .sysc_offs = 0x54,
297 .syss_offs = 0x58,
298 .sysc_flags = (SYSC_HAS_SIDLEMODE |
299 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
300 SYSC_HAS_AUTOIDLE),
301 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
302 .sysc_fields = &omap_hwmod_sysc_type1,
303};
304
305static struct omap_hwmod_class uart_class = {
306 .name = "uart",
307 .sysc = &uart_sysc,
308};
309
310/* UART1 */
311
312static struct omap_hwmod_irq_info uart1_mpu_irqs[] = {
313 { .irq = INT_24XX_UART1_IRQ, },
314};
315
316static struct omap_hwmod_dma_info uart1_sdma_reqs[] = {
317 { .name = "rx", .dma_req = OMAP24XX_DMA_UART1_RX, },
318 { .name = "tx", .dma_req = OMAP24XX_DMA_UART1_TX, },
319};
320
321static struct omap_hwmod_ocp_if *omap2420_uart1_slaves[] = {
322 &omap2_l4_core__uart1,
323};
324
325static struct omap_hwmod omap2420_uart1_hwmod = {
326 .name = "uart1",
327 .mpu_irqs = uart1_mpu_irqs,
328 .mpu_irqs_cnt = ARRAY_SIZE(uart1_mpu_irqs),
329 .sdma_reqs = uart1_sdma_reqs,
330 .sdma_reqs_cnt = ARRAY_SIZE(uart1_sdma_reqs),
331 .main_clk = "uart1_fck",
332 .prcm = {
333 .omap2 = {
334 .module_offs = CORE_MOD,
335 .prcm_reg_id = 1,
336 .module_bit = OMAP24XX_EN_UART1_SHIFT,
337 .idlest_reg_id = 1,
338 .idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
339 },
340 },
341 .slaves = omap2420_uart1_slaves,
342 .slaves_cnt = ARRAY_SIZE(omap2420_uart1_slaves),
343 .class = &uart_class,
344 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
345};
346
347/* UART2 */
348
349static struct omap_hwmod_irq_info uart2_mpu_irqs[] = {
350 { .irq = INT_24XX_UART2_IRQ, },
351};
352
353static struct omap_hwmod_dma_info uart2_sdma_reqs[] = {
354 { .name = "rx", .dma_req = OMAP24XX_DMA_UART2_RX, },
355 { .name = "tx", .dma_req = OMAP24XX_DMA_UART2_TX, },
356};
357
358static struct omap_hwmod_ocp_if *omap2420_uart2_slaves[] = {
359 &omap2_l4_core__uart2,
360};
361
362static struct omap_hwmod omap2420_uart2_hwmod = {
363 .name = "uart2",
364 .mpu_irqs = uart2_mpu_irqs,
365 .mpu_irqs_cnt = ARRAY_SIZE(uart2_mpu_irqs),
366 .sdma_reqs = uart2_sdma_reqs,
367 .sdma_reqs_cnt = ARRAY_SIZE(uart2_sdma_reqs),
368 .main_clk = "uart2_fck",
369 .prcm = {
370 .omap2 = {
371 .module_offs = CORE_MOD,
372 .prcm_reg_id = 1,
373 .module_bit = OMAP24XX_EN_UART2_SHIFT,
374 .idlest_reg_id = 1,
375 .idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
376 },
377 },
378 .slaves = omap2420_uart2_slaves,
379 .slaves_cnt = ARRAY_SIZE(omap2420_uart2_slaves),
380 .class = &uart_class,
381 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
382};
383
384/* UART3 */
385
386static struct omap_hwmod_irq_info uart3_mpu_irqs[] = {
387 { .irq = INT_24XX_UART3_IRQ, },
388};
389
390static struct omap_hwmod_dma_info uart3_sdma_reqs[] = {
391 { .name = "rx", .dma_req = OMAP24XX_DMA_UART3_RX, },
392 { .name = "tx", .dma_req = OMAP24XX_DMA_UART3_TX, },
393};
394
395static struct omap_hwmod_ocp_if *omap2420_uart3_slaves[] = {
396 &omap2_l4_core__uart3,
397};
398
399static struct omap_hwmod omap2420_uart3_hwmod = {
400 .name = "uart3",
401 .mpu_irqs = uart3_mpu_irqs,
402 .mpu_irqs_cnt = ARRAY_SIZE(uart3_mpu_irqs),
403 .sdma_reqs = uart3_sdma_reqs,
404 .sdma_reqs_cnt = ARRAY_SIZE(uart3_sdma_reqs),
405 .main_clk = "uart3_fck",
406 .prcm = {
407 .omap2 = {
408 .module_offs = CORE_MOD,
409 .prcm_reg_id = 2,
410 .module_bit = OMAP24XX_EN_UART3_SHIFT,
411 .idlest_reg_id = 2,
412 .idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
413 },
414 },
415 .slaves = omap2420_uart3_slaves,
416 .slaves_cnt = ARRAY_SIZE(omap2420_uart3_slaves),
417 .class = &uart_class,
418 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
419};
420
168static __initdata struct omap_hwmod *omap2420_hwmods[] = { 421static __initdata struct omap_hwmod *omap2420_hwmods[] = {
169 &omap2420_l3_main_hwmod, 422 &omap2420_l3_main_hwmod,
170 &omap2420_l4_core_hwmod, 423 &omap2420_l4_core_hwmod,
171 &omap2420_l4_wkup_hwmod, 424 &omap2420_l4_wkup_hwmod,
172 &omap2420_mpu_hwmod, 425 &omap2420_mpu_hwmod,
173 &omap2420_iva_hwmod, 426 &omap2420_iva_hwmod,
427 &omap2420_wd_timer2_hwmod,
428 &omap2420_uart1_hwmod,
429 &omap2420_uart2_hwmod,
430 &omap2420_uart3_hwmod,
174 NULL, 431 NULL,
175}; 432};
176 433
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index 4526628ed287..12d939e456cf 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -15,10 +15,12 @@
15#include <mach/irqs.h> 15#include <mach/irqs.h>
16#include <plat/cpu.h> 16#include <plat/cpu.h>
17#include <plat/dma.h> 17#include <plat/dma.h>
18#include <plat/serial.h>
18 19
19#include "omap_hwmod_common_data.h" 20#include "omap_hwmod_common_data.h"
20 21
21#include "prm-regbits-24xx.h" 22#include "prm-regbits-24xx.h"
23#include "cm-regbits-24xx.h"
22 24
23/* 25/*
24 * OMAP2430 hardware module integration data 26 * OMAP2430 hardware module integration data
@@ -33,6 +35,7 @@ static struct omap_hwmod omap2430_mpu_hwmod;
33static struct omap_hwmod omap2430_iva_hwmod; 35static struct omap_hwmod omap2430_iva_hwmod;
34static struct omap_hwmod omap2430_l3_main_hwmod; 36static struct omap_hwmod omap2430_l3_main_hwmod;
35static struct omap_hwmod omap2430_l4_core_hwmod; 37static struct omap_hwmod omap2430_l4_core_hwmod;
38static struct omap_hwmod omap2430_wd_timer2_hwmod;
36 39
37/* L3 -> L4_CORE interface */ 40/* L3 -> L4_CORE interface */
38static struct omap_hwmod_ocp_if omap2430_l3_main__l4_core = { 41static struct omap_hwmod_ocp_if omap2430_l3_main__l4_core = {
@@ -71,6 +74,9 @@ static struct omap_hwmod omap2430_l3_main_hwmod = {
71}; 74};
72 75
73static struct omap_hwmod omap2430_l4_wkup_hwmod; 76static struct omap_hwmod omap2430_l4_wkup_hwmod;
77static struct omap_hwmod omap2430_uart1_hwmod;
78static struct omap_hwmod omap2430_uart2_hwmod;
79static struct omap_hwmod omap2430_uart3_hwmod;
74 80
75/* L4_CORE -> L4_WKUP interface */ 81/* L4_CORE -> L4_WKUP interface */
76static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = { 82static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = {
@@ -79,6 +85,60 @@ static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = {
79 .user = OCP_USER_MPU | OCP_USER_SDMA, 85 .user = OCP_USER_MPU | OCP_USER_SDMA,
80}; 86};
81 87
88/* L4 CORE -> UART1 interface */
89static struct omap_hwmod_addr_space omap2430_uart1_addr_space[] = {
90 {
91 .pa_start = OMAP2_UART1_BASE,
92 .pa_end = OMAP2_UART1_BASE + SZ_8K - 1,
93 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
94 },
95};
96
97static struct omap_hwmod_ocp_if omap2_l4_core__uart1 = {
98 .master = &omap2430_l4_core_hwmod,
99 .slave = &omap2430_uart1_hwmod,
100 .clk = "uart1_ick",
101 .addr = omap2430_uart1_addr_space,
102 .addr_cnt = ARRAY_SIZE(omap2430_uart1_addr_space),
103 .user = OCP_USER_MPU | OCP_USER_SDMA,
104};
105
106/* L4 CORE -> UART2 interface */
107static struct omap_hwmod_addr_space omap2430_uart2_addr_space[] = {
108 {
109 .pa_start = OMAP2_UART2_BASE,
110 .pa_end = OMAP2_UART2_BASE + SZ_1K - 1,
111 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
112 },
113};
114
115static struct omap_hwmod_ocp_if omap2_l4_core__uart2 = {
116 .master = &omap2430_l4_core_hwmod,
117 .slave = &omap2430_uart2_hwmod,
118 .clk = "uart2_ick",
119 .addr = omap2430_uart2_addr_space,
120 .addr_cnt = ARRAY_SIZE(omap2430_uart2_addr_space),
121 .user = OCP_USER_MPU | OCP_USER_SDMA,
122};
123
124/* L4 PER -> UART3 interface */
125static struct omap_hwmod_addr_space omap2430_uart3_addr_space[] = {
126 {
127 .pa_start = OMAP2_UART3_BASE,
128 .pa_end = OMAP2_UART3_BASE + SZ_1K - 1,
129 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
130 },
131};
132
133static struct omap_hwmod_ocp_if omap2_l4_core__uart3 = {
134 .master = &omap2430_l4_core_hwmod,
135 .slave = &omap2430_uart3_hwmod,
136 .clk = "uart3_ick",
137 .addr = omap2430_uart3_addr_space,
138 .addr_cnt = ARRAY_SIZE(omap2430_uart3_addr_space),
139 .user = OCP_USER_MPU | OCP_USER_SDMA,
140};
141
82/* Slave interfaces on the L4_CORE interconnect */ 142/* Slave interfaces on the L4_CORE interconnect */
83static struct omap_hwmod_ocp_if *omap2430_l4_core_slaves[] = { 143static struct omap_hwmod_ocp_if *omap2430_l4_core_slaves[] = {
84 &omap2430_l3_main__l4_core, 144 &omap2430_l3_main__l4_core,
@@ -104,6 +164,9 @@ static struct omap_hwmod omap2430_l4_core_hwmod = {
104/* Slave interfaces on the L4_WKUP interconnect */ 164/* Slave interfaces on the L4_WKUP interconnect */
105static struct omap_hwmod_ocp_if *omap2430_l4_wkup_slaves[] = { 165static struct omap_hwmod_ocp_if *omap2430_l4_wkup_slaves[] = {
106 &omap2430_l4_core__l4_wkup, 166 &omap2430_l4_core__l4_wkup,
167 &omap2_l4_core__uart1,
168 &omap2_l4_core__uart2,
169 &omap2_l4_core__uart3,
107}; 170};
108 171
109/* Master interfaces on the L4_WKUP interconnect */ 172/* Master interfaces on the L4_WKUP interconnect */
@@ -165,12 +228,206 @@ static struct omap_hwmod omap2430_iva_hwmod = {
165 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430) 228 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430)
166}; 229};
167 230
231/* l4_wkup -> wd_timer2 */
232static struct omap_hwmod_addr_space omap2430_wd_timer2_addrs[] = {
233 {
234 .pa_start = 0x49016000,
235 .pa_end = 0x4901607f,
236 .flags = ADDR_TYPE_RT
237 },
238};
239
240static struct omap_hwmod_ocp_if omap2430_l4_wkup__wd_timer2 = {
241 .master = &omap2430_l4_wkup_hwmod,
242 .slave = &omap2430_wd_timer2_hwmod,
243 .clk = "mpu_wdt_ick",
244 .addr = omap2430_wd_timer2_addrs,
245 .addr_cnt = ARRAY_SIZE(omap2430_wd_timer2_addrs),
246 .user = OCP_USER_MPU | OCP_USER_SDMA,
247};
248
249/*
250 * 'wd_timer' class
251 * 32-bit watchdog upward counter that generates a pulse on the reset pin on
252 * overflow condition
253 */
254
255static struct omap_hwmod_class_sysconfig omap2430_wd_timer_sysc = {
256 .rev_offs = 0x0,
257 .sysc_offs = 0x0010,
258 .syss_offs = 0x0014,
259 .sysc_flags = (SYSC_HAS_EMUFREE | SYSC_HAS_SOFTRESET |
260 SYSC_HAS_AUTOIDLE),
261 .sysc_fields = &omap_hwmod_sysc_type1,
262};
263
264static struct omap_hwmod_class omap2430_wd_timer_hwmod_class = {
265 .name = "wd_timer",
266 .sysc = &omap2430_wd_timer_sysc,
267};
268
269/* wd_timer2 */
270static struct omap_hwmod_ocp_if *omap2430_wd_timer2_slaves[] = {
271 &omap2430_l4_wkup__wd_timer2,
272};
273
274static struct omap_hwmod omap2430_wd_timer2_hwmod = {
275 .name = "wd_timer2",
276 .class = &omap2430_wd_timer_hwmod_class,
277 .main_clk = "mpu_wdt_fck",
278 .prcm = {
279 .omap2 = {
280 .prcm_reg_id = 1,
281 .module_bit = OMAP24XX_EN_MPU_WDT_SHIFT,
282 .module_offs = WKUP_MOD,
283 .idlest_reg_id = 1,
284 .idlest_idle_bit = OMAP24XX_ST_MPU_WDT_SHIFT,
285 },
286 },
287 .slaves = omap2430_wd_timer2_slaves,
288 .slaves_cnt = ARRAY_SIZE(omap2430_wd_timer2_slaves),
289 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
290};
291
292/* UART */
293
294static struct omap_hwmod_class_sysconfig uart_sysc = {
295 .rev_offs = 0x50,
296 .sysc_offs = 0x54,
297 .syss_offs = 0x58,
298 .sysc_flags = (SYSC_HAS_SIDLEMODE |
299 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
300 SYSC_HAS_AUTOIDLE),
301 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
302 .sysc_fields = &omap_hwmod_sysc_type1,
303};
304
305static struct omap_hwmod_class uart_class = {
306 .name = "uart",
307 .sysc = &uart_sysc,
308};
309
310/* UART1 */
311
312static struct omap_hwmod_irq_info uart1_mpu_irqs[] = {
313 { .irq = INT_24XX_UART1_IRQ, },
314};
315
316static struct omap_hwmod_dma_info uart1_sdma_reqs[] = {
317 { .name = "rx", .dma_req = OMAP24XX_DMA_UART1_RX, },
318 { .name = "tx", .dma_req = OMAP24XX_DMA_UART1_TX, },
319};
320
321static struct omap_hwmod_ocp_if *omap2430_uart1_slaves[] = {
322 &omap2_l4_core__uart1,
323};
324
325static struct omap_hwmod omap2430_uart1_hwmod = {
326 .name = "uart1",
327 .mpu_irqs = uart1_mpu_irqs,
328 .mpu_irqs_cnt = ARRAY_SIZE(uart1_mpu_irqs),
329 .sdma_reqs = uart1_sdma_reqs,
330 .sdma_reqs_cnt = ARRAY_SIZE(uart1_sdma_reqs),
331 .main_clk = "uart1_fck",
332 .prcm = {
333 .omap2 = {
334 .module_offs = CORE_MOD,
335 .prcm_reg_id = 1,
336 .module_bit = OMAP24XX_EN_UART1_SHIFT,
337 .idlest_reg_id = 1,
338 .idlest_idle_bit = OMAP24XX_EN_UART1_SHIFT,
339 },
340 },
341 .slaves = omap2430_uart1_slaves,
342 .slaves_cnt = ARRAY_SIZE(omap2430_uart1_slaves),
343 .class = &uart_class,
344 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
345};
346
347/* UART2 */
348
349static struct omap_hwmod_irq_info uart2_mpu_irqs[] = {
350 { .irq = INT_24XX_UART2_IRQ, },
351};
352
353static struct omap_hwmod_dma_info uart2_sdma_reqs[] = {
354 { .name = "rx", .dma_req = OMAP24XX_DMA_UART2_RX, },
355 { .name = "tx", .dma_req = OMAP24XX_DMA_UART2_TX, },
356};
357
358static struct omap_hwmod_ocp_if *omap2430_uart2_slaves[] = {
359 &omap2_l4_core__uart2,
360};
361
362static struct omap_hwmod omap2430_uart2_hwmod = {
363 .name = "uart2",
364 .mpu_irqs = uart2_mpu_irqs,
365 .mpu_irqs_cnt = ARRAY_SIZE(uart2_mpu_irqs),
366 .sdma_reqs = uart2_sdma_reqs,
367 .sdma_reqs_cnt = ARRAY_SIZE(uart2_sdma_reqs),
368 .main_clk = "uart2_fck",
369 .prcm = {
370 .omap2 = {
371 .module_offs = CORE_MOD,
372 .prcm_reg_id = 1,
373 .module_bit = OMAP24XX_EN_UART2_SHIFT,
374 .idlest_reg_id = 1,
375 .idlest_idle_bit = OMAP24XX_EN_UART2_SHIFT,
376 },
377 },
378 .slaves = omap2430_uart2_slaves,
379 .slaves_cnt = ARRAY_SIZE(omap2430_uart2_slaves),
380 .class = &uart_class,
381 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
382};
383
384/* UART3 */
385
386static struct omap_hwmod_irq_info uart3_mpu_irqs[] = {
387 { .irq = INT_24XX_UART3_IRQ, },
388};
389
390static struct omap_hwmod_dma_info uart3_sdma_reqs[] = {
391 { .name = "rx", .dma_req = OMAP24XX_DMA_UART3_RX, },
392 { .name = "tx", .dma_req = OMAP24XX_DMA_UART3_TX, },
393};
394
395static struct omap_hwmod_ocp_if *omap2430_uart3_slaves[] = {
396 &omap2_l4_core__uart3,
397};
398
399static struct omap_hwmod omap2430_uart3_hwmod = {
400 .name = "uart3",
401 .mpu_irqs = uart3_mpu_irqs,
402 .mpu_irqs_cnt = ARRAY_SIZE(uart3_mpu_irqs),
403 .sdma_reqs = uart3_sdma_reqs,
404 .sdma_reqs_cnt = ARRAY_SIZE(uart3_sdma_reqs),
405 .main_clk = "uart3_fck",
406 .prcm = {
407 .omap2 = {
408 .module_offs = CORE_MOD,
409 .prcm_reg_id = 2,
410 .module_bit = OMAP24XX_EN_UART3_SHIFT,
411 .idlest_reg_id = 2,
412 .idlest_idle_bit = OMAP24XX_EN_UART3_SHIFT,
413 },
414 },
415 .slaves = omap2430_uart3_slaves,
416 .slaves_cnt = ARRAY_SIZE(omap2430_uart3_slaves),
417 .class = &uart_class,
418 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
419};
420
168static __initdata struct omap_hwmod *omap2430_hwmods[] = { 421static __initdata struct omap_hwmod *omap2430_hwmods[] = {
169 &omap2430_l3_main_hwmod, 422 &omap2430_l3_main_hwmod,
170 &omap2430_l4_core_hwmod, 423 &omap2430_l4_core_hwmod,
171 &omap2430_l4_wkup_hwmod, 424 &omap2430_l4_wkup_hwmod,
172 &omap2430_mpu_hwmod, 425 &omap2430_mpu_hwmod,
173 &omap2430_iva_hwmod, 426 &omap2430_iva_hwmod,
427 &omap2430_wd_timer2_hwmod,
428 &omap2430_uart1_hwmod,
429 &omap2430_uart2_hwmod,
430 &omap2430_uart3_hwmod,
174 NULL, 431 NULL,
175}; 432};
176 433
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 5d8eb58ba5e3..cb97ecf0a3f6 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -17,10 +17,12 @@
17#include <mach/irqs.h> 17#include <mach/irqs.h>
18#include <plat/cpu.h> 18#include <plat/cpu.h>
19#include <plat/dma.h> 19#include <plat/dma.h>
20#include <plat/serial.h>
20 21
21#include "omap_hwmod_common_data.h" 22#include "omap_hwmod_common_data.h"
22 23
23#include "prm-regbits-34xx.h" 24#include "prm-regbits-34xx.h"
25#include "cm-regbits-34xx.h"
24 26
25/* 27/*
26 * OMAP3xxx hardware module integration data 28 * OMAP3xxx hardware module integration data
@@ -36,6 +38,7 @@ static struct omap_hwmod omap3xxx_iva_hwmod;
36static struct omap_hwmod omap3xxx_l3_main_hwmod; 38static struct omap_hwmod omap3xxx_l3_main_hwmod;
37static struct omap_hwmod omap3xxx_l4_core_hwmod; 39static struct omap_hwmod omap3xxx_l4_core_hwmod;
38static struct omap_hwmod omap3xxx_l4_per_hwmod; 40static struct omap_hwmod omap3xxx_l4_per_hwmod;
41static struct omap_hwmod omap3xxx_wd_timer2_hwmod;
39 42
40/* L3 -> L4_CORE interface */ 43/* L3 -> L4_CORE interface */
41static struct omap_hwmod_ocp_if omap3xxx_l3_main__l4_core = { 44static struct omap_hwmod_ocp_if omap3xxx_l3_main__l4_core = {
@@ -82,6 +85,10 @@ static struct omap_hwmod omap3xxx_l3_main_hwmod = {
82}; 85};
83 86
84static struct omap_hwmod omap3xxx_l4_wkup_hwmod; 87static struct omap_hwmod omap3xxx_l4_wkup_hwmod;
88static struct omap_hwmod omap3xxx_uart1_hwmod;
89static struct omap_hwmod omap3xxx_uart2_hwmod;
90static struct omap_hwmod omap3xxx_uart3_hwmod;
91static struct omap_hwmod omap3xxx_uart4_hwmod;
85 92
86/* L4_CORE -> L4_WKUP interface */ 93/* L4_CORE -> L4_WKUP interface */
87static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = { 94static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = {
@@ -90,6 +97,78 @@ static struct omap_hwmod_ocp_if omap3xxx_l4_core__l4_wkup = {
90 .user = OCP_USER_MPU | OCP_USER_SDMA, 97 .user = OCP_USER_MPU | OCP_USER_SDMA,
91}; 98};
92 99
100/* L4 CORE -> UART1 interface */
101static struct omap_hwmod_addr_space omap3xxx_uart1_addr_space[] = {
102 {
103 .pa_start = OMAP3_UART1_BASE,
104 .pa_end = OMAP3_UART1_BASE + SZ_8K - 1,
105 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
106 },
107};
108
109static struct omap_hwmod_ocp_if omap3_l4_core__uart1 = {
110 .master = &omap3xxx_l4_core_hwmod,
111 .slave = &omap3xxx_uart1_hwmod,
112 .clk = "uart1_ick",
113 .addr = omap3xxx_uart1_addr_space,
114 .addr_cnt = ARRAY_SIZE(omap3xxx_uart1_addr_space),
115 .user = OCP_USER_MPU | OCP_USER_SDMA,
116};
117
118/* L4 CORE -> UART2 interface */
119static struct omap_hwmod_addr_space omap3xxx_uart2_addr_space[] = {
120 {
121 .pa_start = OMAP3_UART2_BASE,
122 .pa_end = OMAP3_UART2_BASE + SZ_1K - 1,
123 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
124 },
125};
126
127static struct omap_hwmod_ocp_if omap3_l4_core__uart2 = {
128 .master = &omap3xxx_l4_core_hwmod,
129 .slave = &omap3xxx_uart2_hwmod,
130 .clk = "uart2_ick",
131 .addr = omap3xxx_uart2_addr_space,
132 .addr_cnt = ARRAY_SIZE(omap3xxx_uart2_addr_space),
133 .user = OCP_USER_MPU | OCP_USER_SDMA,
134};
135
136/* L4 PER -> UART3 interface */
137static struct omap_hwmod_addr_space omap3xxx_uart3_addr_space[] = {
138 {
139 .pa_start = OMAP3_UART3_BASE,
140 .pa_end = OMAP3_UART3_BASE + SZ_1K - 1,
141 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
142 },
143};
144
145static struct omap_hwmod_ocp_if omap3_l4_per__uart3 = {
146 .master = &omap3xxx_l4_per_hwmod,
147 .slave = &omap3xxx_uart3_hwmod,
148 .clk = "uart3_ick",
149 .addr = omap3xxx_uart3_addr_space,
150 .addr_cnt = ARRAY_SIZE(omap3xxx_uart3_addr_space),
151 .user = OCP_USER_MPU | OCP_USER_SDMA,
152};
153
154/* L4 PER -> UART4 interface */
155static struct omap_hwmod_addr_space omap3xxx_uart4_addr_space[] = {
156 {
157 .pa_start = OMAP3_UART4_BASE,
158 .pa_end = OMAP3_UART4_BASE + SZ_1K - 1,
159 .flags = ADDR_MAP_ON_INIT | ADDR_TYPE_RT,
160 },
161};
162
163static struct omap_hwmod_ocp_if omap3_l4_per__uart4 = {
164 .master = &omap3xxx_l4_per_hwmod,
165 .slave = &omap3xxx_uart4_hwmod,
166 .clk = "uart4_ick",
167 .addr = omap3xxx_uart4_addr_space,
168 .addr_cnt = ARRAY_SIZE(omap3xxx_uart4_addr_space),
169 .user = OCP_USER_MPU | OCP_USER_SDMA,
170};
171
93/* Slave interfaces on the L4_CORE interconnect */ 172/* Slave interfaces on the L4_CORE interconnect */
94static struct omap_hwmod_ocp_if *omap3xxx_l4_core_slaves[] = { 173static struct omap_hwmod_ocp_if *omap3xxx_l4_core_slaves[] = {
95 &omap3xxx_l3_main__l4_core, 174 &omap3xxx_l3_main__l4_core,
@@ -98,6 +177,8 @@ static struct omap_hwmod_ocp_if *omap3xxx_l4_core_slaves[] = {
98/* Master interfaces on the L4_CORE interconnect */ 177/* Master interfaces on the L4_CORE interconnect */
99static struct omap_hwmod_ocp_if *omap3xxx_l4_core_masters[] = { 178static struct omap_hwmod_ocp_if *omap3xxx_l4_core_masters[] = {
100 &omap3xxx_l4_core__l4_wkup, 179 &omap3xxx_l4_core__l4_wkup,
180 &omap3_l4_core__uart1,
181 &omap3_l4_core__uart2,
101}; 182};
102 183
103/* L4 CORE */ 184/* L4 CORE */
@@ -119,6 +200,8 @@ static struct omap_hwmod_ocp_if *omap3xxx_l4_per_slaves[] = {
119 200
120/* Master interfaces on the L4_PER interconnect */ 201/* Master interfaces on the L4_PER interconnect */
121static struct omap_hwmod_ocp_if *omap3xxx_l4_per_masters[] = { 202static struct omap_hwmod_ocp_if *omap3xxx_l4_per_masters[] = {
203 &omap3_l4_per__uart3,
204 &omap3_l4_per__uart4,
122}; 205};
123 206
124/* L4 PER */ 207/* L4 PER */
@@ -197,6 +280,235 @@ static struct omap_hwmod omap3xxx_iva_hwmod = {
197 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430) 280 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430)
198}; 281};
199 282
283/* l4_wkup -> wd_timer2 */
284static struct omap_hwmod_addr_space omap3xxx_wd_timer2_addrs[] = {
285 {
286 .pa_start = 0x48314000,
287 .pa_end = 0x4831407f,
288 .flags = ADDR_TYPE_RT
289 },
290};
291
292static struct omap_hwmod_ocp_if omap3xxx_l4_wkup__wd_timer2 = {
293 .master = &omap3xxx_l4_wkup_hwmod,
294 .slave = &omap3xxx_wd_timer2_hwmod,
295 .clk = "wdt2_ick",
296 .addr = omap3xxx_wd_timer2_addrs,
297 .addr_cnt = ARRAY_SIZE(omap3xxx_wd_timer2_addrs),
298 .user = OCP_USER_MPU | OCP_USER_SDMA,
299};
300
301/*
302 * 'wd_timer' class
303 * 32-bit watchdog upward counter that generates a pulse on the reset pin on
304 * overflow condition
305 */
306
307static struct omap_hwmod_class_sysconfig omap3xxx_wd_timer_sysc = {
308 .rev_offs = 0x0000,
309 .sysc_offs = 0x0010,
310 .syss_offs = 0x0014,
311 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_EMUFREE |
312 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
313 SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY),
314 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
315 .sysc_fields = &omap_hwmod_sysc_type1,
316};
317
318static struct omap_hwmod_class omap3xxx_wd_timer_hwmod_class = {
319 .name = "wd_timer",
320 .sysc = &omap3xxx_wd_timer_sysc,
321};
322
323/* wd_timer2 */
324static struct omap_hwmod_ocp_if *omap3xxx_wd_timer2_slaves[] = {
325 &omap3xxx_l4_wkup__wd_timer2,
326};
327
328static struct omap_hwmod omap3xxx_wd_timer2_hwmod = {
329 .name = "wd_timer2",
330 .class = &omap3xxx_wd_timer_hwmod_class,
331 .main_clk = "wdt2_fck",
332 .prcm = {
333 .omap2 = {
334 .prcm_reg_id = 1,
335 .module_bit = OMAP3430_EN_WDT2_SHIFT,
336 .module_offs = WKUP_MOD,
337 .idlest_reg_id = 1,
338 .idlest_idle_bit = OMAP3430_ST_WDT2_SHIFT,
339 },
340 },
341 .slaves = omap3xxx_wd_timer2_slaves,
342 .slaves_cnt = ARRAY_SIZE(omap3xxx_wd_timer2_slaves),
343 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
344};
345
346/* UART common */
347
348static struct omap_hwmod_class_sysconfig uart_sysc = {
349 .rev_offs = 0x50,
350 .sysc_offs = 0x54,
351 .syss_offs = 0x58,
352 .sysc_flags = (SYSC_HAS_SIDLEMODE |
353 SYSC_HAS_ENAWAKEUP | SYSC_HAS_SOFTRESET |
354 SYSC_HAS_AUTOIDLE),
355 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
356 .sysc_fields = &omap_hwmod_sysc_type1,
357};
358
359static struct omap_hwmod_class uart_class = {
360 .name = "uart",
361 .sysc = &uart_sysc,
362};
363
364/* UART1 */
365
366static struct omap_hwmod_irq_info uart1_mpu_irqs[] = {
367 { .irq = INT_24XX_UART1_IRQ, },
368};
369
370static struct omap_hwmod_dma_info uart1_sdma_reqs[] = {
371 { .name = "tx", .dma_req = OMAP24XX_DMA_UART1_TX, },
372 { .name = "rx", .dma_req = OMAP24XX_DMA_UART1_RX, },
373};
374
375static struct omap_hwmod_ocp_if *omap3xxx_uart1_slaves[] = {
376 &omap3_l4_core__uart1,
377};
378
379static struct omap_hwmod omap3xxx_uart1_hwmod = {
380 .name = "uart1",
381 .mpu_irqs = uart1_mpu_irqs,
382 .mpu_irqs_cnt = ARRAY_SIZE(uart1_mpu_irqs),
383 .sdma_reqs = uart1_sdma_reqs,
384 .sdma_reqs_cnt = ARRAY_SIZE(uart1_sdma_reqs),
385 .main_clk = "uart1_fck",
386 .prcm = {
387 .omap2 = {
388 .module_offs = CORE_MOD,
389 .prcm_reg_id = 1,
390 .module_bit = OMAP3430_EN_UART1_SHIFT,
391 .idlest_reg_id = 1,
392 .idlest_idle_bit = OMAP3430_EN_UART1_SHIFT,
393 },
394 },
395 .slaves = omap3xxx_uart1_slaves,
396 .slaves_cnt = ARRAY_SIZE(omap3xxx_uart1_slaves),
397 .class = &uart_class,
398 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
399};
400
401/* UART2 */
402
403static struct omap_hwmod_irq_info uart2_mpu_irqs[] = {
404 { .irq = INT_24XX_UART2_IRQ, },
405};
406
407static struct omap_hwmod_dma_info uart2_sdma_reqs[] = {
408 { .name = "tx", .dma_req = OMAP24XX_DMA_UART2_TX, },
409 { .name = "rx", .dma_req = OMAP24XX_DMA_UART2_RX, },
410};
411
412static struct omap_hwmod_ocp_if *omap3xxx_uart2_slaves[] = {
413 &omap3_l4_core__uart2,
414};
415
416static struct omap_hwmod omap3xxx_uart2_hwmod = {
417 .name = "uart2",
418 .mpu_irqs = uart2_mpu_irqs,
419 .mpu_irqs_cnt = ARRAY_SIZE(uart2_mpu_irqs),
420 .sdma_reqs = uart2_sdma_reqs,
421 .sdma_reqs_cnt = ARRAY_SIZE(uart2_sdma_reqs),
422 .main_clk = "uart2_fck",
423 .prcm = {
424 .omap2 = {
425 .module_offs = CORE_MOD,
426 .prcm_reg_id = 1,
427 .module_bit = OMAP3430_EN_UART2_SHIFT,
428 .idlest_reg_id = 1,
429 .idlest_idle_bit = OMAP3430_EN_UART2_SHIFT,
430 },
431 },
432 .slaves = omap3xxx_uart2_slaves,
433 .slaves_cnt = ARRAY_SIZE(omap3xxx_uart2_slaves),
434 .class = &uart_class,
435 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
436};
437
438/* UART3 */
439
440static struct omap_hwmod_irq_info uart3_mpu_irqs[] = {
441 { .irq = INT_24XX_UART3_IRQ, },
442};
443
444static struct omap_hwmod_dma_info uart3_sdma_reqs[] = {
445 { .name = "tx", .dma_req = OMAP24XX_DMA_UART3_TX, },
446 { .name = "rx", .dma_req = OMAP24XX_DMA_UART3_RX, },
447};
448
449static struct omap_hwmod_ocp_if *omap3xxx_uart3_slaves[] = {
450 &omap3_l4_per__uart3,
451};
452
453static struct omap_hwmod omap3xxx_uart3_hwmod = {
454 .name = "uart3",
455 .mpu_irqs = uart3_mpu_irqs,
456 .mpu_irqs_cnt = ARRAY_SIZE(uart3_mpu_irqs),
457 .sdma_reqs = uart3_sdma_reqs,
458 .sdma_reqs_cnt = ARRAY_SIZE(uart3_sdma_reqs),
459 .main_clk = "uart3_fck",
460 .prcm = {
461 .omap2 = {
462 .module_offs = OMAP3430_PER_MOD,
463 .prcm_reg_id = 1,
464 .module_bit = OMAP3430_EN_UART3_SHIFT,
465 .idlest_reg_id = 1,
466 .idlest_idle_bit = OMAP3430_EN_UART3_SHIFT,
467 },
468 },
469 .slaves = omap3xxx_uart3_slaves,
470 .slaves_cnt = ARRAY_SIZE(omap3xxx_uart3_slaves),
471 .class = &uart_class,
472 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
473};
474
475/* UART4 */
476
477static struct omap_hwmod_irq_info uart4_mpu_irqs[] = {
478 { .irq = INT_36XX_UART4_IRQ, },
479};
480
481static struct omap_hwmod_dma_info uart4_sdma_reqs[] = {
482 { .name = "rx", .dma_req = OMAP36XX_DMA_UART4_RX, },
483 { .name = "tx", .dma_req = OMAP36XX_DMA_UART4_TX, },
484};
485
486static struct omap_hwmod_ocp_if *omap3xxx_uart4_slaves[] = {
487 &omap3_l4_per__uart4,
488};
489
490static struct omap_hwmod omap3xxx_uart4_hwmod = {
491 .name = "uart4",
492 .mpu_irqs = uart4_mpu_irqs,
493 .mpu_irqs_cnt = ARRAY_SIZE(uart4_mpu_irqs),
494 .sdma_reqs = uart4_sdma_reqs,
495 .sdma_reqs_cnt = ARRAY_SIZE(uart4_sdma_reqs),
496 .main_clk = "uart4_fck",
497 .prcm = {
498 .omap2 = {
499 .module_offs = OMAP3430_PER_MOD,
500 .prcm_reg_id = 1,
501 .module_bit = OMAP3630_EN_UART4_SHIFT,
502 .idlest_reg_id = 1,
503 .idlest_idle_bit = OMAP3630_EN_UART4_SHIFT,
504 },
505 },
506 .slaves = omap3xxx_uart4_slaves,
507 .slaves_cnt = ARRAY_SIZE(omap3xxx_uart4_slaves),
508 .class = &uart_class,
509 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3630ES1),
510};
511
200static __initdata struct omap_hwmod *omap3xxx_hwmods[] = { 512static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
201 &omap3xxx_l3_main_hwmod, 513 &omap3xxx_l3_main_hwmod,
202 &omap3xxx_l4_core_hwmod, 514 &omap3xxx_l4_core_hwmod,
@@ -204,6 +516,11 @@ static __initdata struct omap_hwmod *omap3xxx_hwmods[] = {
204 &omap3xxx_l4_wkup_hwmod, 516 &omap3xxx_l4_wkup_hwmod,
205 &omap3xxx_mpu_hwmod, 517 &omap3xxx_mpu_hwmod,
206 &omap3xxx_iva_hwmod, 518 &omap3xxx_iva_hwmod,
519 &omap3xxx_wd_timer2_hwmod,
520 &omap3xxx_uart1_hwmod,
521 &omap3xxx_uart2_hwmod,
522 &omap3xxx_uart3_hwmod,
523 &omap3xxx_uart4_hwmod,
207 NULL, 524 NULL,
208}; 525};
209 526
@@ -211,5 +528,3 @@ int __init omap3xxx_hwmod_init(void)
211{ 528{
212 return omap_hwmod_init(omap3xxx_hwmods); 529 return omap_hwmod_init(omap3xxx_hwmods);
213} 530}
214
215
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
new file mode 100644
index 000000000000..7274db4de487
--- /dev/null
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -0,0 +1,850 @@
1/*
2 * Hardware modules present on the OMAP44xx chips
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 * Copyright (C) 2009-2010 Nokia Corporation
6 *
7 * Paul Walmsley
8 * Benoit Cousson
9 *
10 * This file is automatically generated from the OMAP hardware databases.
11 * We respectfully ask that any modifications to this file be coordinated
12 * with the public linux-omap@vger.kernel.org mailing list and the
13 * authors above to ensure that the autogeneration scripts are kept
14 * up-to-date with the file contents.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
19 */
20
21#include <linux/io.h>
22
23#include <plat/omap_hwmod.h>
24#include <plat/cpu.h>
25
26#include "omap_hwmod_common_data.h"
27
28#include "cm.h"
29#include "prm-regbits-44xx.h"
30
31/* Base offset for all OMAP4 interrupts external to MPUSS */
32#define OMAP44XX_IRQ_GIC_START 32
33
34/* Base offset for all OMAP4 dma requests */
35#define OMAP44XX_DMA_REQ_START 1
36
37/* Backward references (IPs with Bus Master capability) */
38static struct omap_hwmod omap44xx_dmm_hwmod;
39static struct omap_hwmod omap44xx_emif_fw_hwmod;
40static struct omap_hwmod omap44xx_l3_instr_hwmod;
41static struct omap_hwmod omap44xx_l3_main_1_hwmod;
42static struct omap_hwmod omap44xx_l3_main_2_hwmod;
43static struct omap_hwmod omap44xx_l3_main_3_hwmod;
44static struct omap_hwmod omap44xx_l4_abe_hwmod;
45static struct omap_hwmod omap44xx_l4_cfg_hwmod;
46static struct omap_hwmod omap44xx_l4_per_hwmod;
47static struct omap_hwmod omap44xx_l4_wkup_hwmod;
48static struct omap_hwmod omap44xx_mpu_hwmod;
49static struct omap_hwmod omap44xx_mpu_private_hwmod;
50
51/*
52 * Interconnects omap_hwmod structures
53 * hwmods that compose the global OMAP interconnect
54 */
55
56/*
57 * 'dmm' class
58 * instance(s): dmm
59 */
60static struct omap_hwmod_class omap44xx_dmm_hwmod_class = {
61 .name = "dmm",
62};
63
64/* dmm interface data */
65/* l3_main_1 -> dmm */
66static struct omap_hwmod_ocp_if omap44xx_l3_main_1__dmm = {
67 .master = &omap44xx_l3_main_1_hwmod,
68 .slave = &omap44xx_dmm_hwmod,
69 .clk = "l3_div_ck",
70 .user = OCP_USER_MPU | OCP_USER_SDMA,
71};
72
73/* mpu -> dmm */
74static struct omap_hwmod_ocp_if omap44xx_mpu__dmm = {
75 .master = &omap44xx_mpu_hwmod,
76 .slave = &omap44xx_dmm_hwmod,
77 .clk = "l3_div_ck",
78 .user = OCP_USER_MPU | OCP_USER_SDMA,
79};
80
81/* dmm slave ports */
82static struct omap_hwmod_ocp_if *omap44xx_dmm_slaves[] = {
83 &omap44xx_l3_main_1__dmm,
84 &omap44xx_mpu__dmm,
85};
86
87static struct omap_hwmod_irq_info omap44xx_dmm_irqs[] = {
88 { .irq = 113 + OMAP44XX_IRQ_GIC_START },
89};
90
91static struct omap_hwmod omap44xx_dmm_hwmod = {
92 .name = "dmm",
93 .class = &omap44xx_dmm_hwmod_class,
94 .slaves = omap44xx_dmm_slaves,
95 .slaves_cnt = ARRAY_SIZE(omap44xx_dmm_slaves),
96 .mpu_irqs = omap44xx_dmm_irqs,
97 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_dmm_irqs),
98 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
99};
100
101/*
102 * 'emif_fw' class
103 * instance(s): emif_fw
104 */
105static struct omap_hwmod_class omap44xx_emif_fw_hwmod_class = {
106 .name = "emif_fw",
107};
108
109/* emif_fw interface data */
110/* dmm -> emif_fw */
111static struct omap_hwmod_ocp_if omap44xx_dmm__emif_fw = {
112 .master = &omap44xx_dmm_hwmod,
113 .slave = &omap44xx_emif_fw_hwmod,
114 .clk = "l3_div_ck",
115 .user = OCP_USER_MPU | OCP_USER_SDMA,
116};
117
118/* l4_cfg -> emif_fw */
119static struct omap_hwmod_ocp_if omap44xx_l4_cfg__emif_fw = {
120 .master = &omap44xx_l4_cfg_hwmod,
121 .slave = &omap44xx_emif_fw_hwmod,
122 .clk = "l4_div_ck",
123 .user = OCP_USER_MPU | OCP_USER_SDMA,
124};
125
126/* emif_fw slave ports */
127static struct omap_hwmod_ocp_if *omap44xx_emif_fw_slaves[] = {
128 &omap44xx_dmm__emif_fw,
129 &omap44xx_l4_cfg__emif_fw,
130};
131
132static struct omap_hwmod omap44xx_emif_fw_hwmod = {
133 .name = "emif_fw",
134 .class = &omap44xx_emif_fw_hwmod_class,
135 .slaves = omap44xx_emif_fw_slaves,
136 .slaves_cnt = ARRAY_SIZE(omap44xx_emif_fw_slaves),
137 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
138};
139
140/*
141 * 'l3' class
142 * instance(s): l3_instr, l3_main_1, l3_main_2, l3_main_3
143 */
144static struct omap_hwmod_class omap44xx_l3_hwmod_class = {
145 .name = "l3",
146};
147
148/* l3_instr interface data */
149/* l3_main_3 -> l3_instr */
150static struct omap_hwmod_ocp_if omap44xx_l3_main_3__l3_instr = {
151 .master = &omap44xx_l3_main_3_hwmod,
152 .slave = &omap44xx_l3_instr_hwmod,
153 .clk = "l3_div_ck",
154 .user = OCP_USER_MPU | OCP_USER_SDMA,
155};
156
157/* l3_instr slave ports */
158static struct omap_hwmod_ocp_if *omap44xx_l3_instr_slaves[] = {
159 &omap44xx_l3_main_3__l3_instr,
160};
161
162static struct omap_hwmod omap44xx_l3_instr_hwmod = {
163 .name = "l3_instr",
164 .class = &omap44xx_l3_hwmod_class,
165 .slaves = omap44xx_l3_instr_slaves,
166 .slaves_cnt = ARRAY_SIZE(omap44xx_l3_instr_slaves),
167 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
168};
169
170/* l3_main_2 -> l3_main_1 */
171static struct omap_hwmod_ocp_if omap44xx_l3_main_2__l3_main_1 = {
172 .master = &omap44xx_l3_main_2_hwmod,
173 .slave = &omap44xx_l3_main_1_hwmod,
174 .clk = "l3_div_ck",
175 .user = OCP_USER_MPU | OCP_USER_SDMA,
176};
177
178/* l4_cfg -> l3_main_1 */
179static struct omap_hwmod_ocp_if omap44xx_l4_cfg__l3_main_1 = {
180 .master = &omap44xx_l4_cfg_hwmod,
181 .slave = &omap44xx_l3_main_1_hwmod,
182 .clk = "l4_div_ck",
183 .user = OCP_USER_MPU | OCP_USER_SDMA,
184};
185
186/* mpu -> l3_main_1 */
187static struct omap_hwmod_ocp_if omap44xx_mpu__l3_main_1 = {
188 .master = &omap44xx_mpu_hwmod,
189 .slave = &omap44xx_l3_main_1_hwmod,
190 .clk = "l3_div_ck",
191 .user = OCP_USER_MPU | OCP_USER_SDMA,
192};
193
194/* l3_main_1 slave ports */
195static struct omap_hwmod_ocp_if *omap44xx_l3_main_1_slaves[] = {
196 &omap44xx_l3_main_2__l3_main_1,
197 &omap44xx_l4_cfg__l3_main_1,
198 &omap44xx_mpu__l3_main_1,
199};
200
201static struct omap_hwmod omap44xx_l3_main_1_hwmod = {
202 .name = "l3_main_1",
203 .class = &omap44xx_l3_hwmod_class,
204 .slaves = omap44xx_l3_main_1_slaves,
205 .slaves_cnt = ARRAY_SIZE(omap44xx_l3_main_1_slaves),
206 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
207};
208
209/* l3_main_2 interface data */
210/* l3_main_1 -> l3_main_2 */
211static struct omap_hwmod_ocp_if omap44xx_l3_main_1__l3_main_2 = {
212 .master = &omap44xx_l3_main_1_hwmod,
213 .slave = &omap44xx_l3_main_2_hwmod,
214 .clk = "l3_div_ck",
215 .user = OCP_USER_MPU | OCP_USER_SDMA,
216};
217
218/* l4_cfg -> l3_main_2 */
219static struct omap_hwmod_ocp_if omap44xx_l4_cfg__l3_main_2 = {
220 .master = &omap44xx_l4_cfg_hwmod,
221 .slave = &omap44xx_l3_main_2_hwmod,
222 .clk = "l4_div_ck",
223 .user = OCP_USER_MPU | OCP_USER_SDMA,
224};
225
226/* l3_main_2 slave ports */
227static struct omap_hwmod_ocp_if *omap44xx_l3_main_2_slaves[] = {
228 &omap44xx_l3_main_1__l3_main_2,
229 &omap44xx_l4_cfg__l3_main_2,
230};
231
232static struct omap_hwmod omap44xx_l3_main_2_hwmod = {
233 .name = "l3_main_2",
234 .class = &omap44xx_l3_hwmod_class,
235 .slaves = omap44xx_l3_main_2_slaves,
236 .slaves_cnt = ARRAY_SIZE(omap44xx_l3_main_2_slaves),
237 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
238};
239
240/* l3_main_3 interface data */
241/* l3_main_1 -> l3_main_3 */
242static struct omap_hwmod_ocp_if omap44xx_l3_main_1__l3_main_3 = {
243 .master = &omap44xx_l3_main_1_hwmod,
244 .slave = &omap44xx_l3_main_3_hwmod,
245 .clk = "l3_div_ck",
246 .user = OCP_USER_MPU | OCP_USER_SDMA,
247};
248
249/* l3_main_2 -> l3_main_3 */
250static struct omap_hwmod_ocp_if omap44xx_l3_main_2__l3_main_3 = {
251 .master = &omap44xx_l3_main_2_hwmod,
252 .slave = &omap44xx_l3_main_3_hwmod,
253 .clk = "l3_div_ck",
254 .user = OCP_USER_MPU | OCP_USER_SDMA,
255};
256
257/* l4_cfg -> l3_main_3 */
258static struct omap_hwmod_ocp_if omap44xx_l4_cfg__l3_main_3 = {
259 .master = &omap44xx_l4_cfg_hwmod,
260 .slave = &omap44xx_l3_main_3_hwmod,
261 .clk = "l4_div_ck",
262 .user = OCP_USER_MPU | OCP_USER_SDMA,
263};
264
265/* l3_main_3 slave ports */
266static struct omap_hwmod_ocp_if *omap44xx_l3_main_3_slaves[] = {
267 &omap44xx_l3_main_1__l3_main_3,
268 &omap44xx_l3_main_2__l3_main_3,
269 &omap44xx_l4_cfg__l3_main_3,
270};
271
272static struct omap_hwmod omap44xx_l3_main_3_hwmod = {
273 .name = "l3_main_3",
274 .class = &omap44xx_l3_hwmod_class,
275 .slaves = omap44xx_l3_main_3_slaves,
276 .slaves_cnt = ARRAY_SIZE(omap44xx_l3_main_3_slaves),
277 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
278};
279
280/*
281 * 'l4' class
282 * instance(s): l4_abe, l4_cfg, l4_per, l4_wkup
283 */
284static struct omap_hwmod_class omap44xx_l4_hwmod_class = {
285 .name = "l4",
286};
287
288/* l4_abe interface data */
289/* l3_main_1 -> l4_abe */
290static struct omap_hwmod_ocp_if omap44xx_l3_main_1__l4_abe = {
291 .master = &omap44xx_l3_main_1_hwmod,
292 .slave = &omap44xx_l4_abe_hwmod,
293 .clk = "l3_div_ck",
294 .user = OCP_USER_MPU | OCP_USER_SDMA,
295};
296
297/* mpu -> l4_abe */
298static struct omap_hwmod_ocp_if omap44xx_mpu__l4_abe = {
299 .master = &omap44xx_mpu_hwmod,
300 .slave = &omap44xx_l4_abe_hwmod,
301 .clk = "ocp_abe_iclk",
302 .user = OCP_USER_MPU | OCP_USER_SDMA,
303};
304
305/* l4_abe slave ports */
306static struct omap_hwmod_ocp_if *omap44xx_l4_abe_slaves[] = {
307 &omap44xx_l3_main_1__l4_abe,
308 &omap44xx_mpu__l4_abe,
309};
310
311static struct omap_hwmod omap44xx_l4_abe_hwmod = {
312 .name = "l4_abe",
313 .class = &omap44xx_l4_hwmod_class,
314 .slaves = omap44xx_l4_abe_slaves,
315 .slaves_cnt = ARRAY_SIZE(omap44xx_l4_abe_slaves),
316 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
317};
318
319/* l4_cfg interface data */
320/* l3_main_1 -> l4_cfg */
321static struct omap_hwmod_ocp_if omap44xx_l3_main_1__l4_cfg = {
322 .master = &omap44xx_l3_main_1_hwmod,
323 .slave = &omap44xx_l4_cfg_hwmod,
324 .clk = "l3_div_ck",
325 .user = OCP_USER_MPU | OCP_USER_SDMA,
326};
327
328/* l4_cfg slave ports */
329static struct omap_hwmod_ocp_if *omap44xx_l4_cfg_slaves[] = {
330 &omap44xx_l3_main_1__l4_cfg,
331};
332
333static struct omap_hwmod omap44xx_l4_cfg_hwmod = {
334 .name = "l4_cfg",
335 .class = &omap44xx_l4_hwmod_class,
336 .slaves = omap44xx_l4_cfg_slaves,
337 .slaves_cnt = ARRAY_SIZE(omap44xx_l4_cfg_slaves),
338 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
339};
340
341/* l4_per interface data */
342/* l3_main_2 -> l4_per */
343static struct omap_hwmod_ocp_if omap44xx_l3_main_2__l4_per = {
344 .master = &omap44xx_l3_main_2_hwmod,
345 .slave = &omap44xx_l4_per_hwmod,
346 .clk = "l3_div_ck",
347 .user = OCP_USER_MPU | OCP_USER_SDMA,
348};
349
350/* l4_per slave ports */
351static struct omap_hwmod_ocp_if *omap44xx_l4_per_slaves[] = {
352 &omap44xx_l3_main_2__l4_per,
353};
354
355static struct omap_hwmod omap44xx_l4_per_hwmod = {
356 .name = "l4_per",
357 .class = &omap44xx_l4_hwmod_class,
358 .slaves = omap44xx_l4_per_slaves,
359 .slaves_cnt = ARRAY_SIZE(omap44xx_l4_per_slaves),
360 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
361};
362
363/* l4_wkup interface data */
364/* l4_cfg -> l4_wkup */
365static struct omap_hwmod_ocp_if omap44xx_l4_cfg__l4_wkup = {
366 .master = &omap44xx_l4_cfg_hwmod,
367 .slave = &omap44xx_l4_wkup_hwmod,
368 .clk = "l4_div_ck",
369 .user = OCP_USER_MPU | OCP_USER_SDMA,
370};
371
372/* l4_wkup slave ports */
373static struct omap_hwmod_ocp_if *omap44xx_l4_wkup_slaves[] = {
374 &omap44xx_l4_cfg__l4_wkup,
375};
376
377static struct omap_hwmod omap44xx_l4_wkup_hwmod = {
378 .name = "l4_wkup",
379 .class = &omap44xx_l4_hwmod_class,
380 .slaves = omap44xx_l4_wkup_slaves,
381 .slaves_cnt = ARRAY_SIZE(omap44xx_l4_wkup_slaves),
382 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
383};
384
385/*
386 * 'mpu_bus' class
387 * instance(s): mpu_private
388 */
389static struct omap_hwmod_class omap44xx_mpu_bus_hwmod_class = {
390 .name = "mpu_bus",
391};
392
393/* mpu_private interface data */
394/* mpu -> mpu_private */
395static struct omap_hwmod_ocp_if omap44xx_mpu__mpu_private = {
396 .master = &omap44xx_mpu_hwmod,
397 .slave = &omap44xx_mpu_private_hwmod,
398 .clk = "l3_div_ck",
399 .user = OCP_USER_MPU | OCP_USER_SDMA,
400};
401
402/* mpu_private slave ports */
403static struct omap_hwmod_ocp_if *omap44xx_mpu_private_slaves[] = {
404 &omap44xx_mpu__mpu_private,
405};
406
407static struct omap_hwmod omap44xx_mpu_private_hwmod = {
408 .name = "mpu_private",
409 .class = &omap44xx_mpu_bus_hwmod_class,
410 .slaves = omap44xx_mpu_private_slaves,
411 .slaves_cnt = ARRAY_SIZE(omap44xx_mpu_private_slaves),
412 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
413};
414
415/*
416 * 'mpu' class
417 * mpu sub-system
418 */
419
420static struct omap_hwmod_class omap44xx_mpu_hwmod_class = {
421 .name = "mpu",
422};
423
424/* mpu */
425static struct omap_hwmod_irq_info omap44xx_mpu_irqs[] = {
426 { .name = "pl310", .irq = 0 + OMAP44XX_IRQ_GIC_START },
427 { .name = "cti0", .irq = 1 + OMAP44XX_IRQ_GIC_START },
428 { .name = "cti1", .irq = 2 + OMAP44XX_IRQ_GIC_START },
429};
430
431/* mpu master ports */
432static struct omap_hwmod_ocp_if *omap44xx_mpu_masters[] = {
433 &omap44xx_mpu__l3_main_1,
434 &omap44xx_mpu__l4_abe,
435 &omap44xx_mpu__dmm,
436};
437
438static struct omap_hwmod omap44xx_mpu_hwmod = {
439 .name = "mpu",
440 .class = &omap44xx_mpu_hwmod_class,
441 .flags = (HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET),
442 .mpu_irqs = omap44xx_mpu_irqs,
443 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_mpu_irqs),
444 .main_clk = "dpll_mpu_m2_ck",
445 .prcm = {
446 .omap4 = {
447 .clkctrl_reg = OMAP4430_CM_MPU_MPU_CLKCTRL,
448 },
449 },
450 .masters = omap44xx_mpu_masters,
451 .masters_cnt = ARRAY_SIZE(omap44xx_mpu_masters),
452 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
453};
454
455/*
456 * 'wd_timer' class
457 * 32-bit watchdog upward counter that generates a pulse on the reset pin on
458 * overflow condition
459 */
460
461static struct omap_hwmod_class_sysconfig omap44xx_wd_timer_sysc = {
462 .rev_offs = 0x0000,
463 .sysc_offs = 0x0010,
464 .syss_offs = 0x0014,
465 .sysc_flags = (SYSC_HAS_SIDLEMODE | SYSC_HAS_EMUFREE |
466 SYSC_HAS_SOFTRESET),
467 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
468 .sysc_fields = &omap_hwmod_sysc_type1,
469};
470
471/*
472 * 'uart' class
473 * universal asynchronous receiver/transmitter (uart)
474 */
475
476static struct omap_hwmod_class_sysconfig omap44xx_uart_sysc = {
477 .rev_offs = 0x0050,
478 .sysc_offs = 0x0054,
479 .syss_offs = 0x0058,
480 .sysc_flags = (SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE |
481 SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE),
482 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
483 .sysc_fields = &omap_hwmod_sysc_type1,
484};
485
486static struct omap_hwmod_class omap44xx_wd_timer_hwmod_class = {
487 .name = "wd_timer",
488 .sysc = &omap44xx_wd_timer_sysc,
489};
490
491/* wd_timer2 */
492static struct omap_hwmod omap44xx_wd_timer2_hwmod;
493static struct omap_hwmod_irq_info omap44xx_wd_timer2_irqs[] = {
494 { .irq = 80 + OMAP44XX_IRQ_GIC_START },
495};
496
497static struct omap_hwmod_addr_space omap44xx_wd_timer2_addrs[] = {
498 {
499 .pa_start = 0x4a314000,
500 .pa_end = 0x4a31407f,
501 .flags = ADDR_TYPE_RT
502 },
503};
504
505static struct omap_hwmod_class omap44xx_uart_hwmod_class = {
506 .name = "uart",
507 .sysc = &omap44xx_uart_sysc,
508};
509
510/* uart1 */
511static struct omap_hwmod omap44xx_uart1_hwmod;
512static struct omap_hwmod_irq_info omap44xx_uart1_irqs[] = {
513 { .irq = 72 + OMAP44XX_IRQ_GIC_START },
514};
515
516static struct omap_hwmod_dma_info omap44xx_uart1_sdma_reqs[] = {
517 { .name = "tx", .dma_req = 48 + OMAP44XX_DMA_REQ_START },
518 { .name = "rx", .dma_req = 49 + OMAP44XX_DMA_REQ_START },
519};
520
521static struct omap_hwmod_addr_space omap44xx_uart1_addrs[] = {
522 {
523 .pa_start = 0x4806a000,
524 .pa_end = 0x4806a0ff,
525 .flags = ADDR_TYPE_RT
526 },
527};
528
529/* l4_per -> uart1 */
530static struct omap_hwmod_ocp_if omap44xx_l4_per__uart1 = {
531 .master = &omap44xx_l4_per_hwmod,
532 .slave = &omap44xx_uart1_hwmod,
533 .clk = "l4_div_ck",
534 .addr = omap44xx_uart1_addrs,
535 .addr_cnt = ARRAY_SIZE(omap44xx_uart1_addrs),
536 .user = OCP_USER_MPU | OCP_USER_SDMA,
537};
538
539/* uart1 slave ports */
540static struct omap_hwmod_ocp_if *omap44xx_uart1_slaves[] = {
541 &omap44xx_l4_per__uart1,
542};
543
544static struct omap_hwmod omap44xx_uart1_hwmod = {
545 .name = "uart1",
546 .class = &omap44xx_uart_hwmod_class,
547 .mpu_irqs = omap44xx_uart1_irqs,
548 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_uart1_irqs),
549 .sdma_reqs = omap44xx_uart1_sdma_reqs,
550 .sdma_reqs_cnt = ARRAY_SIZE(omap44xx_uart1_sdma_reqs),
551 .main_clk = "uart1_fck",
552 .prcm = {
553 .omap4 = {
554 .clkctrl_reg = OMAP4430_CM_L4PER_UART1_CLKCTRL,
555 },
556 },
557 .slaves = omap44xx_uart1_slaves,
558 .slaves_cnt = ARRAY_SIZE(omap44xx_uart1_slaves),
559 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
560};
561
562/* uart2 */
563static struct omap_hwmod omap44xx_uart2_hwmod;
564static struct omap_hwmod_irq_info omap44xx_uart2_irqs[] = {
565 { .irq = 73 + OMAP44XX_IRQ_GIC_START },
566};
567
568static struct omap_hwmod_dma_info omap44xx_uart2_sdma_reqs[] = {
569 { .name = "tx", .dma_req = 50 + OMAP44XX_DMA_REQ_START },
570 { .name = "rx", .dma_req = 51 + OMAP44XX_DMA_REQ_START },
571};
572
573static struct omap_hwmod_addr_space omap44xx_uart2_addrs[] = {
574 {
575 .pa_start = 0x4806c000,
576 .pa_end = 0x4806c0ff,
577 .flags = ADDR_TYPE_RT
578 },
579};
580
581/* l4_wkup -> wd_timer2 */
582static struct omap_hwmod_ocp_if omap44xx_l4_wkup__wd_timer2 = {
583 .master = &omap44xx_l4_wkup_hwmod,
584 .slave = &omap44xx_wd_timer2_hwmod,
585 .clk = "l4_wkup_clk_mux_ck",
586 .addr = omap44xx_wd_timer2_addrs,
587 .addr_cnt = ARRAY_SIZE(omap44xx_wd_timer2_addrs),
588 .user = OCP_USER_MPU | OCP_USER_SDMA,
589};
590
591/* wd_timer2 slave ports */
592static struct omap_hwmod_ocp_if *omap44xx_wd_timer2_slaves[] = {
593 &omap44xx_l4_wkup__wd_timer2,
594};
595
596static struct omap_hwmod omap44xx_wd_timer2_hwmod = {
597 .name = "wd_timer2",
598 .class = &omap44xx_wd_timer_hwmod_class,
599 .mpu_irqs = omap44xx_wd_timer2_irqs,
600 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_wd_timer2_irqs),
601 .main_clk = "wd_timer2_fck",
602 .prcm = {
603 .omap4 = {
604 .clkctrl_reg = OMAP4430_CM_WKUP_WDT2_CLKCTRL,
605 },
606 },
607 .slaves = omap44xx_wd_timer2_slaves,
608 .slaves_cnt = ARRAY_SIZE(omap44xx_wd_timer2_slaves),
609 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
610};
611
612/* wd_timer3 */
613static struct omap_hwmod omap44xx_wd_timer3_hwmod;
614static struct omap_hwmod_irq_info omap44xx_wd_timer3_irqs[] = {
615 { .irq = 36 + OMAP44XX_IRQ_GIC_START },
616};
617
618static struct omap_hwmod_addr_space omap44xx_wd_timer3_addrs[] = {
619 {
620 .pa_start = 0x40130000,
621 .pa_end = 0x4013007f,
622 .flags = ADDR_TYPE_RT
623 },
624};
625
626/* l4_per -> uart2 */
627static struct omap_hwmod_ocp_if omap44xx_l4_per__uart2 = {
628 .master = &omap44xx_l4_per_hwmod,
629 .slave = &omap44xx_uart2_hwmod,
630 .clk = "l4_div_ck",
631 .addr = omap44xx_uart2_addrs,
632 .addr_cnt = ARRAY_SIZE(omap44xx_uart2_addrs),
633 .user = OCP_USER_MPU | OCP_USER_SDMA,
634};
635
636/* uart2 slave ports */
637static struct omap_hwmod_ocp_if *omap44xx_uart2_slaves[] = {
638 &omap44xx_l4_per__uart2,
639};
640
641static struct omap_hwmod omap44xx_uart2_hwmod = {
642 .name = "uart2",
643 .class = &omap44xx_uart_hwmod_class,
644 .mpu_irqs = omap44xx_uart2_irqs,
645 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_uart2_irqs),
646 .sdma_reqs = omap44xx_uart2_sdma_reqs,
647 .sdma_reqs_cnt = ARRAY_SIZE(omap44xx_uart2_sdma_reqs),
648 .main_clk = "uart2_fck",
649 .prcm = {
650 .omap4 = {
651 .clkctrl_reg = OMAP4430_CM_L4PER_UART2_CLKCTRL,
652 },
653 },
654 .slaves = omap44xx_uart2_slaves,
655 .slaves_cnt = ARRAY_SIZE(omap44xx_uart2_slaves),
656 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
657};
658
659/* uart3 */
660static struct omap_hwmod omap44xx_uart3_hwmod;
661static struct omap_hwmod_irq_info omap44xx_uart3_irqs[] = {
662 { .irq = 74 + OMAP44XX_IRQ_GIC_START },
663};
664
665static struct omap_hwmod_dma_info omap44xx_uart3_sdma_reqs[] = {
666 { .name = "tx", .dma_req = 52 + OMAP44XX_DMA_REQ_START },
667 { .name = "rx", .dma_req = 53 + OMAP44XX_DMA_REQ_START },
668};
669
670static struct omap_hwmod_addr_space omap44xx_uart3_addrs[] = {
671 {
672 .pa_start = 0x48020000,
673 .pa_end = 0x480200ff,
674 .flags = ADDR_TYPE_RT
675 },
676};
677
678/* l4_abe -> wd_timer3 */
679static struct omap_hwmod_ocp_if omap44xx_l4_abe__wd_timer3 = {
680 .master = &omap44xx_l4_abe_hwmod,
681 .slave = &omap44xx_wd_timer3_hwmod,
682 .clk = "ocp_abe_iclk",
683 .addr = omap44xx_wd_timer3_addrs,
684 .addr_cnt = ARRAY_SIZE(omap44xx_wd_timer3_addrs),
685 .user = OCP_USER_MPU,
686};
687
688/* l4_abe -> wd_timer3 (dma) */
689static struct omap_hwmod_addr_space omap44xx_wd_timer3_dma_addrs[] = {
690 {
691 .pa_start = 0x49030000,
692 .pa_end = 0x4903007f,
693 .flags = ADDR_TYPE_RT
694 },
695};
696
697/* l4_per -> uart3 */
698static struct omap_hwmod_ocp_if omap44xx_l4_per__uart3 = {
699 .master = &omap44xx_l4_per_hwmod,
700 .slave = &omap44xx_uart3_hwmod,
701 .clk = "l4_div_ck",
702 .addr = omap44xx_uart3_addrs,
703 .addr_cnt = ARRAY_SIZE(omap44xx_uart3_addrs),
704 .user = OCP_USER_MPU | OCP_USER_SDMA,
705};
706
707/* uart3 slave ports */
708static struct omap_hwmod_ocp_if *omap44xx_uart3_slaves[] = {
709 &omap44xx_l4_per__uart3,
710};
711
712static struct omap_hwmod omap44xx_uart3_hwmod = {
713 .name = "uart3",
714 .class = &omap44xx_uart_hwmod_class,
715 .flags = (HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET),
716 .mpu_irqs = omap44xx_uart3_irqs,
717 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_uart3_irqs),
718 .sdma_reqs = omap44xx_uart3_sdma_reqs,
719 .sdma_reqs_cnt = ARRAY_SIZE(omap44xx_uart3_sdma_reqs),
720 .main_clk = "uart3_fck",
721 .prcm = {
722 .omap4 = {
723 .clkctrl_reg = OMAP4430_CM_L4PER_UART3_CLKCTRL,
724 },
725 },
726 .slaves = omap44xx_uart3_slaves,
727 .slaves_cnt = ARRAY_SIZE(omap44xx_uart3_slaves),
728 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
729};
730
731/* uart4 */
732static struct omap_hwmod omap44xx_uart4_hwmod;
733static struct omap_hwmod_irq_info omap44xx_uart4_irqs[] = {
734 { .irq = 70 + OMAP44XX_IRQ_GIC_START },
735};
736
737static struct omap_hwmod_dma_info omap44xx_uart4_sdma_reqs[] = {
738 { .name = "tx", .dma_req = 54 + OMAP44XX_DMA_REQ_START },
739 { .name = "rx", .dma_req = 55 + OMAP44XX_DMA_REQ_START },
740};
741
742static struct omap_hwmod_addr_space omap44xx_uart4_addrs[] = {
743 {
744 .pa_start = 0x4806e000,
745 .pa_end = 0x4806e0ff,
746 .flags = ADDR_TYPE_RT
747 },
748};
749
750static struct omap_hwmod_ocp_if omap44xx_l4_abe__wd_timer3_dma = {
751 .master = &omap44xx_l4_abe_hwmod,
752 .slave = &omap44xx_wd_timer3_hwmod,
753 .clk = "ocp_abe_iclk",
754 .addr = omap44xx_wd_timer3_dma_addrs,
755 .addr_cnt = ARRAY_SIZE(omap44xx_wd_timer3_dma_addrs),
756 .user = OCP_USER_SDMA,
757};
758
759/* wd_timer3 slave ports */
760static struct omap_hwmod_ocp_if *omap44xx_wd_timer3_slaves[] = {
761 &omap44xx_l4_abe__wd_timer3,
762 &omap44xx_l4_abe__wd_timer3_dma,
763};
764
765static struct omap_hwmod omap44xx_wd_timer3_hwmod = {
766 .name = "wd_timer3",
767 .class = &omap44xx_wd_timer_hwmod_class,
768 .mpu_irqs = omap44xx_wd_timer3_irqs,
769 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_wd_timer3_irqs),
770 .main_clk = "wd_timer3_fck",
771 .prcm = {
772 .omap4 = {
773 .clkctrl_reg = OMAP4430_CM1_ABE_WDT3_CLKCTRL,
774 },
775 },
776 .slaves = omap44xx_wd_timer3_slaves,
777 .slaves_cnt = ARRAY_SIZE(omap44xx_wd_timer3_slaves),
778 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
779};
780
781/* l4_per -> uart4 */
782static struct omap_hwmod_ocp_if omap44xx_l4_per__uart4 = {
783 .master = &omap44xx_l4_per_hwmod,
784 .slave = &omap44xx_uart4_hwmod,
785 .clk = "l4_div_ck",
786 .addr = omap44xx_uart4_addrs,
787 .addr_cnt = ARRAY_SIZE(omap44xx_uart4_addrs),
788 .user = OCP_USER_MPU | OCP_USER_SDMA,
789};
790
791/* uart4 slave ports */
792static struct omap_hwmod_ocp_if *omap44xx_uart4_slaves[] = {
793 &omap44xx_l4_per__uart4,
794};
795
796static struct omap_hwmod omap44xx_uart4_hwmod = {
797 .name = "uart4",
798 .class = &omap44xx_uart_hwmod_class,
799 .mpu_irqs = omap44xx_uart4_irqs,
800 .mpu_irqs_cnt = ARRAY_SIZE(omap44xx_uart4_irqs),
801 .sdma_reqs = omap44xx_uart4_sdma_reqs,
802 .sdma_reqs_cnt = ARRAY_SIZE(omap44xx_uart4_sdma_reqs),
803 .main_clk = "uart4_fck",
804 .prcm = {
805 .omap4 = {
806 .clkctrl_reg = OMAP4430_CM_L4PER_UART4_CLKCTRL,
807 },
808 },
809 .slaves = omap44xx_uart4_slaves,
810 .slaves_cnt = ARRAY_SIZE(omap44xx_uart4_slaves),
811 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
812};
813
814static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
815 /* dmm class */
816 &omap44xx_dmm_hwmod,
817 /* emif_fw class */
818 &omap44xx_emif_fw_hwmod,
819 /* l3 class */
820 &omap44xx_l3_instr_hwmod,
821 &omap44xx_l3_main_1_hwmod,
822 &omap44xx_l3_main_2_hwmod,
823 &omap44xx_l3_main_3_hwmod,
824 /* l4 class */
825 &omap44xx_l4_abe_hwmod,
826 &omap44xx_l4_cfg_hwmod,
827 &omap44xx_l4_per_hwmod,
828 &omap44xx_l4_wkup_hwmod,
829 /* mpu_bus class */
830 &omap44xx_mpu_private_hwmod,
831
832 /* mpu class */
833 &omap44xx_mpu_hwmod,
834 /* wd_timer class */
835 &omap44xx_wd_timer2_hwmod,
836 &omap44xx_wd_timer3_hwmod,
837
838 /* uart class */
839 &omap44xx_uart1_hwmod,
840 &omap44xx_uart2_hwmod,
841 &omap44xx_uart3_hwmod,
842 &omap44xx_uart4_hwmod,
843 NULL,
844};
845
846int __init omap44xx_hwmod_init(void)
847{
848 return omap_hwmod_init(omap44xx_hwmods);
849}
850
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 723b44e252fd..5e81517a7af2 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -31,12 +31,17 @@
31#include <plat/board.h> 31#include <plat/board.h>
32#include <plat/powerdomain.h> 32#include <plat/powerdomain.h>
33#include <plat/clockdomain.h> 33#include <plat/clockdomain.h>
34#include <plat/dmtimer.h>
34 35
35#include "prm.h" 36#include "prm.h"
36#include "cm.h" 37#include "cm.h"
37#include "pm.h" 38#include "pm.h"
38 39
39int omap2_pm_debug; 40int omap2_pm_debug;
41u32 enable_off_mode;
42u32 sleep_while_idle;
43u32 wakeup_timer_seconds;
44u32 wakeup_timer_milliseconds;
40 45
41#define DUMP_PRM_MOD_REG(mod, reg) \ 46#define DUMP_PRM_MOD_REG(mod, reg) \
42 regs[reg_count].name = #mod "." #reg; \ 47 regs[reg_count].name = #mod "." #reg; \
@@ -162,7 +167,7 @@ void omap2_pm_dump(int mode, int resume, unsigned int us)
162 167
163static void pm_dbg_regset_store(u32 *ptr); 168static void pm_dbg_regset_store(u32 *ptr);
164 169
165struct dentry *pm_dbg_dir; 170static struct dentry *pm_dbg_dir;
166 171
167static int pm_dbg_init_done; 172static int pm_dbg_init_done;
168 173
@@ -349,6 +354,23 @@ void pm_dbg_update_time(struct powerdomain *pwrdm, int prev)
349 pwrdm->timer = t; 354 pwrdm->timer = t;
350} 355}
351 356
357void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
358{
359 u32 tick_rate, cycles;
360
361 if (!seconds && !milliseconds)
362 return;
363
364 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
365 cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
366 omap_dm_timer_stop(gptimer_wakeup);
367 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
368
369 pr_info("PM: Resume timer in %u.%03u secs"
370 " (%d ticks at %d ticks/sec.)\n",
371 seconds, milliseconds, cycles, tick_rate);
372}
373
352static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user) 374static int clkdm_dbg_show_counter(struct clockdomain *clkdm, void *user)
353{ 375{
354 struct seq_file *s = (struct seq_file *)user; 376 struct seq_file *s = (struct seq_file *)user;
@@ -494,8 +516,10 @@ int pm_dbg_regset_init(int reg_set)
494 516
495static int pwrdm_suspend_get(void *data, u64 *val) 517static int pwrdm_suspend_get(void *data, u64 *val)
496{ 518{
497 int ret; 519 int ret = -EINVAL;
498 ret = omap3_pm_get_suspend_state((struct powerdomain *)data); 520
521 if (cpu_is_omap34xx())
522 ret = omap3_pm_get_suspend_state((struct powerdomain *)data);
499 *val = ret; 523 *val = ret;
500 524
501 if (ret >= 0) 525 if (ret >= 0)
@@ -505,7 +529,10 @@ static int pwrdm_suspend_get(void *data, u64 *val)
505 529
506static int pwrdm_suspend_set(void *data, u64 val) 530static int pwrdm_suspend_set(void *data, u64 val)
507{ 531{
508 return omap3_pm_set_suspend_state((struct powerdomain *)data, (int)val); 532 if (cpu_is_omap34xx())
533 return omap3_pm_set_suspend_state(
534 (struct powerdomain *)data, (int)val);
535 return -EINVAL;
509} 536}
510 537
511DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get, 538DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get,
@@ -553,8 +580,10 @@ static int option_set(void *data, u64 val)
553 580
554 *option = val; 581 *option = val;
555 582
556 if (option == &enable_off_mode) 583 if (option == &enable_off_mode) {
557 omap3_pm_off_mode_enable(val); 584 if (cpu_is_omap34xx())
585 omap3_pm_off_mode_enable(val);
586 }
558 587
559 return 0; 588 return 0;
560} 589}
@@ -609,6 +638,9 @@ static int __init pm_dbg_init(void)
609 &sleep_while_idle, &pm_dbg_option_fops); 638 &sleep_while_idle, &pm_dbg_option_fops);
610 (void) debugfs_create_file("wakeup_timer_seconds", S_IRUGO | S_IWUGO, d, 639 (void) debugfs_create_file("wakeup_timer_seconds", S_IRUGO | S_IWUGO, d,
611 &wakeup_timer_seconds, &pm_dbg_option_fops); 640 &wakeup_timer_seconds, &pm_dbg_option_fops);
641 (void) debugfs_create_file("wakeup_timer_milliseconds",
642 S_IRUGO | S_IWUGO, d, &wakeup_timer_milliseconds,
643 &pm_dbg_option_fops);
612 pm_dbg_init_done = 1; 644 pm_dbg_init_done = 1;
613 645
614 return 0; 646 return 0;
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 68f9f2e95891..59ca03b0e691 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -18,11 +18,15 @@
18#include <plat/omap_device.h> 18#include <plat/omap_device.h>
19#include <plat/common.h> 19#include <plat/common.h>
20 20
21#include <plat/powerdomain.h>
22#include <plat/clockdomain.h>
23
21static struct omap_device_pm_latency *pm_lats; 24static struct omap_device_pm_latency *pm_lats;
22 25
23static struct device *mpu_dev; 26static struct device *mpu_dev;
24static struct device *dsp_dev; 27static struct device *iva_dev;
25static struct device *l3_dev; 28static struct device *l3_dev;
29static struct device *dsp_dev;
26 30
27struct device *omap2_get_mpuss_device(void) 31struct device *omap2_get_mpuss_device(void)
28{ 32{
@@ -30,10 +34,10 @@ struct device *omap2_get_mpuss_device(void)
30 return mpu_dev; 34 return mpu_dev;
31} 35}
32 36
33struct device *omap2_get_dsp_device(void) 37struct device *omap2_get_iva_device(void)
34{ 38{
35 WARN_ON_ONCE(!dsp_dev); 39 WARN_ON_ONCE(!iva_dev);
36 return dsp_dev; 40 return iva_dev;
37} 41}
38 42
39struct device *omap2_get_l3_device(void) 43struct device *omap2_get_l3_device(void)
@@ -42,6 +46,13 @@ struct device *omap2_get_l3_device(void)
42 return l3_dev; 46 return l3_dev;
43} 47}
44 48
49struct device *omap4_get_dsp_device(void)
50{
51 WARN_ON_ONCE(!dsp_dev);
52 return dsp_dev;
53}
54EXPORT_SYMBOL(omap4_get_dsp_device);
55
45/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */ 56/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
46static int _init_omap_device(char *name, struct device **new_dev) 57static int _init_omap_device(char *name, struct device **new_dev)
47{ 58{
@@ -69,8 +80,60 @@ static int _init_omap_device(char *name, struct device **new_dev)
69static void omap2_init_processor_devices(void) 80static void omap2_init_processor_devices(void)
70{ 81{
71 _init_omap_device("mpu", &mpu_dev); 82 _init_omap_device("mpu", &mpu_dev);
72 _init_omap_device("iva", &dsp_dev); 83 _init_omap_device("iva", &iva_dev);
73 _init_omap_device("l3_main", &l3_dev); 84 if (cpu_is_omap44xx()) {
85 _init_omap_device("l3_main_1", &l3_dev);
86 _init_omap_device("dsp", &dsp_dev);
87 } else {
88 _init_omap_device("l3_main", &l3_dev);
89 }
90}
91
92/*
93 * This sets pwrdm state (other than mpu & core. Currently only ON &
94 * RET are supported. Function is assuming that clkdm doesn't have
95 * hw_sup mode enabled.
96 */
97int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
98{
99 u32 cur_state;
100 int sleep_switch = 0;
101 int ret = 0;
102
103 if (pwrdm == NULL || IS_ERR(pwrdm))
104 return -EINVAL;
105
106 while (!(pwrdm->pwrsts & (1 << state))) {
107 if (state == PWRDM_POWER_OFF)
108 return ret;
109 state--;
110 }
111
112 cur_state = pwrdm_read_next_pwrst(pwrdm);
113 if (cur_state == state)
114 return ret;
115
116 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
117 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
118 sleep_switch = 1;
119 pwrdm_wait_transition(pwrdm);
120 }
121
122 ret = pwrdm_set_next_pwrst(pwrdm, state);
123 if (ret) {
124 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
125 pwrdm->name);
126 goto err;
127 }
128
129 if (sleep_switch) {
130 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
131 pwrdm_wait_transition(pwrdm);
132 pwrdm_state_switch(pwrdm);
133 }
134
135err:
136 return ret;
74} 137}
75 138
76static int __init omap2_common_pm_init(void) 139static int __init omap2_common_pm_init(void)
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 3de6ece23fc8..0d75bfd1fdbe 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -13,14 +13,11 @@
13 13
14#include <plat/powerdomain.h> 14#include <plat/powerdomain.h>
15 15
16extern u32 enable_off_mode;
17extern u32 sleep_while_idle;
18
19extern void *omap3_secure_ram_storage; 16extern void *omap3_secure_ram_storage;
20extern void omap3_pm_off_mode_enable(int); 17extern void omap3_pm_off_mode_enable(int);
21extern void omap_sram_idle(void); 18extern void omap_sram_idle(void);
22extern int omap3_can_sleep(void); 19extern int omap3_can_sleep(void);
23extern int set_pwrdm_state(struct powerdomain *pwrdm, u32 state); 20extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
24extern int omap3_idle_init(void); 21extern int omap3_idle_init(void);
25 22
26struct cpuidle_params { 23struct cpuidle_params {
@@ -48,10 +45,16 @@ extern struct omap_dm_timer *gptimer_wakeup;
48 45
49#ifdef CONFIG_PM_DEBUG 46#ifdef CONFIG_PM_DEBUG
50extern void omap2_pm_dump(int mode, int resume, unsigned int us); 47extern void omap2_pm_dump(int mode, int resume, unsigned int us);
48extern void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds);
51extern int omap2_pm_debug; 49extern int omap2_pm_debug;
50extern u32 enable_off_mode;
51extern u32 sleep_while_idle;
52#else 52#else
53#define omap2_pm_dump(mode, resume, us) do {} while (0); 53#define omap2_pm_dump(mode, resume, us) do {} while (0);
54#define omap2_pm_wakeup_on_timer(seconds, milliseconds) do {} while (0);
54#define omap2_pm_debug 0 55#define omap2_pm_debug 0
56#define enable_off_mode 0
57#define sleep_while_idle 0
55#endif 58#endif
56 59
57#if defined(CONFIG_CPU_IDLE) 60#if defined(CONFIG_CPU_IDLE)
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 6aeedeacdad8..a40457d81927 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -38,7 +38,6 @@
38#include <mach/irqs.h> 38#include <mach/irqs.h>
39#include <plat/clock.h> 39#include <plat/clock.h>
40#include <plat/sram.h> 40#include <plat/sram.h>
41#include <plat/control.h>
42#include <plat/dma.h> 41#include <plat/dma.h>
43#include <plat/board.h> 42#include <plat/board.h>
44 43
@@ -48,6 +47,7 @@
48#include "cm-regbits-24xx.h" 47#include "cm-regbits-24xx.h"
49#include "sdrc.h" 48#include "sdrc.h"
50#include "pm.h" 49#include "pm.h"
50#include "control.h"
51 51
52#include <plat/powerdomain.h> 52#include <plat/powerdomain.h>
53#include <plat/clockdomain.h> 53#include <plat/clockdomain.h>
@@ -245,6 +245,8 @@ static int omap2_can_sleep(void)
245{ 245{
246 if (omap2_fclks_active()) 246 if (omap2_fclks_active())
247 return 0; 247 return 0;
248 if (!omap_uart_can_sleep())
249 return 0;
248 if (osc_ck->usecount > 1) 250 if (osc_ck->usecount > 1)
249 return 0; 251 return 0;
250 if (omap_dma_running()) 252 if (omap_dma_running())
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 7b03426c72a3..75c0cd13ad8e 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -32,13 +32,11 @@
32#include <plat/sram.h> 32#include <plat/sram.h>
33#include <plat/clockdomain.h> 33#include <plat/clockdomain.h>
34#include <plat/powerdomain.h> 34#include <plat/powerdomain.h>
35#include <plat/control.h>
36#include <plat/serial.h> 35#include <plat/serial.h>
37#include <plat/sdrc.h> 36#include <plat/sdrc.h>
38#include <plat/prcm.h> 37#include <plat/prcm.h>
39#include <plat/gpmc.h> 38#include <plat/gpmc.h>
40#include <plat/dma.h> 39#include <plat/dma.h>
41#include <plat/dmtimer.h>
42 40
43#include <asm/tlbflush.h> 41#include <asm/tlbflush.h>
44 42
@@ -49,16 +47,12 @@
49#include "prm.h" 47#include "prm.h"
50#include "pm.h" 48#include "pm.h"
51#include "sdrc.h" 49#include "sdrc.h"
50#include "control.h"
52 51
53/* Scratchpad offsets */ 52/* Scratchpad offsets */
54#define OMAP343X_TABLE_ADDRESS_OFFSET 0x31 53#define OMAP343X_TABLE_ADDRESS_OFFSET 0xc4
55#define OMAP343X_TABLE_VALUE_OFFSET 0x30 54#define OMAP343X_TABLE_VALUE_OFFSET 0xc0
56#define OMAP343X_CONTROL_REG_VALUE_OFFSET 0x32 55#define OMAP343X_CONTROL_REG_VALUE_OFFSET 0xc8
57
58u32 enable_off_mode;
59u32 sleep_while_idle;
60u32 wakeup_timer_seconds;
61u32 wakeup_timer_milliseconds;
62 56
63struct power_state { 57struct power_state {
64 struct powerdomain *pwrdm; 58 struct powerdomain *pwrdm;
@@ -316,7 +310,7 @@ static void restore_control_register(u32 val)
316/* Function to restore the table entry that was modified for enabling MMU */ 310/* Function to restore the table entry that was modified for enabling MMU */
317static void restore_table_entry(void) 311static void restore_table_entry(void)
318{ 312{
319 u32 *scratchpad_address; 313 void __iomem *scratchpad_address;
320 u32 previous_value, control_reg_value; 314 u32 previous_value, control_reg_value;
321 u32 *address; 315 u32 *address;
322 316
@@ -351,7 +345,6 @@ void omap_sram_idle(void)
351 int core_next_state = PWRDM_POWER_ON; 345 int core_next_state = PWRDM_POWER_ON;
352 int core_prev_state, per_prev_state; 346 int core_prev_state, per_prev_state;
353 u32 sdrc_pwr = 0; 347 u32 sdrc_pwr = 0;
354 int per_state_modified = 0;
355 348
356 if (!_omap_sram_idle) 349 if (!_omap_sram_idle)
357 return; 350 return;
@@ -385,9 +378,9 @@ void omap_sram_idle(void)
385 /* Enable IO-PAD and IO-CHAIN wakeups */ 378 /* Enable IO-PAD and IO-CHAIN wakeups */
386 per_next_state = pwrdm_read_next_pwrst(per_pwrdm); 379 per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
387 core_next_state = pwrdm_read_next_pwrst(core_pwrdm); 380 core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
388 if (omap3_has_io_wakeup() && \ 381 if (omap3_has_io_wakeup() &&
389 (per_next_state < PWRDM_POWER_ON || 382 (per_next_state < PWRDM_POWER_ON ||
390 core_next_state < PWRDM_POWER_ON)) { 383 core_next_state < PWRDM_POWER_ON)) {
391 prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN); 384 prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD, PM_WKEN);
392 omap3_enable_io_chain(); 385 omap3_enable_io_chain();
393 } 386 }
@@ -395,20 +388,12 @@ void omap_sram_idle(void)
395 /* PER */ 388 /* PER */
396 if (per_next_state < PWRDM_POWER_ON) { 389 if (per_next_state < PWRDM_POWER_ON) {
397 omap_uart_prepare_idle(2); 390 omap_uart_prepare_idle(2);
391 omap_uart_prepare_idle(3);
398 omap2_gpio_prepare_for_idle(per_next_state); 392 omap2_gpio_prepare_for_idle(per_next_state);
399 if (per_next_state == PWRDM_POWER_OFF) { 393 if (per_next_state == PWRDM_POWER_OFF)
400 if (core_next_state == PWRDM_POWER_ON) {
401 per_next_state = PWRDM_POWER_RET;
402 pwrdm_set_next_pwrst(per_pwrdm, per_next_state);
403 per_state_modified = 1;
404 } else
405 omap3_per_save_context(); 394 omap3_per_save_context();
406 }
407 } 395 }
408 396
409 if (pwrdm_read_pwrst(cam_pwrdm) == PWRDM_POWER_ON)
410 omap2_clkdm_deny_idle(mpu_pwrdm->pwrdm_clkdms[0]);
411
412 /* CORE */ 397 /* CORE */
413 if (core_next_state < PWRDM_POWER_ON) { 398 if (core_next_state < PWRDM_POWER_ON) {
414 omap_uart_prepare_idle(0); 399 omap_uart_prepare_idle(0);
@@ -475,8 +460,7 @@ void omap_sram_idle(void)
475 if (per_prev_state == PWRDM_POWER_OFF) 460 if (per_prev_state == PWRDM_POWER_OFF)
476 omap3_per_restore_context(); 461 omap3_per_restore_context();
477 omap_uart_resume_idle(2); 462 omap_uart_resume_idle(2);
478 if (per_state_modified) 463 omap_uart_resume_idle(3);
479 pwrdm_set_next_pwrst(per_pwrdm, PWRDM_POWER_OFF);
480 } 464 }
481 465
482 /* Disable IO-PAD and IO-CHAIN wakeup */ 466 /* Disable IO-PAD and IO-CHAIN wakeup */
@@ -501,51 +485,6 @@ int omap3_can_sleep(void)
501 return 1; 485 return 1;
502} 486}
503 487
504/* This sets pwrdm state (other than mpu & core. Currently only ON &
505 * RET are supported. Function is assuming that clkdm doesn't have
506 * hw_sup mode enabled. */
507int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
508{
509 u32 cur_state;
510 int sleep_switch = 0;
511 int ret = 0;
512
513 if (pwrdm == NULL || IS_ERR(pwrdm))
514 return -EINVAL;
515
516 while (!(pwrdm->pwrsts & (1 << state))) {
517 if (state == PWRDM_POWER_OFF)
518 return ret;
519 state--;
520 }
521
522 cur_state = pwrdm_read_next_pwrst(pwrdm);
523 if (cur_state == state)
524 return ret;
525
526 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
527 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
528 sleep_switch = 1;
529 pwrdm_wait_transition(pwrdm);
530 }
531
532 ret = pwrdm_set_next_pwrst(pwrdm, state);
533 if (ret) {
534 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
535 pwrdm->name);
536 goto err;
537 }
538
539 if (sleep_switch) {
540 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
541 pwrdm_wait_transition(pwrdm);
542 pwrdm_state_switch(pwrdm);
543 }
544
545err:
546 return ret;
547}
548
549static void omap3_pm_idle(void) 488static void omap3_pm_idle(void)
550{ 489{
551 local_irq_disable(); 490 local_irq_disable();
@@ -567,23 +506,6 @@ out:
567#ifdef CONFIG_SUSPEND 506#ifdef CONFIG_SUSPEND
568static suspend_state_t suspend_state; 507static suspend_state_t suspend_state;
569 508
570static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds)
571{
572 u32 tick_rate, cycles;
573
574 if (!seconds && !milliseconds)
575 return;
576
577 tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup));
578 cycles = tick_rate * seconds + tick_rate * milliseconds / 1000;
579 omap_dm_timer_stop(gptimer_wakeup);
580 omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles);
581
582 pr_info("PM: Resume timer in %u.%03u secs"
583 " (%d ticks at %d ticks/sec.)\n",
584 seconds, milliseconds, cycles, tick_rate);
585}
586
587static int omap3_pm_prepare(void) 509static int omap3_pm_prepare(void)
588{ 510{
589 disable_hlt(); 511 disable_hlt();
@@ -604,7 +526,7 @@ static int omap3_pm_suspend(void)
604 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm); 526 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm);
605 /* Set ones wanted by suspend */ 527 /* Set ones wanted by suspend */
606 list_for_each_entry(pwrst, &pwrst_list, node) { 528 list_for_each_entry(pwrst, &pwrst_list, node) {
607 if (set_pwrdm_state(pwrst->pwrdm, pwrst->next_state)) 529 if (omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state))
608 goto restore; 530 goto restore;
609 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm)) 531 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm))
610 goto restore; 532 goto restore;
@@ -625,7 +547,7 @@ restore:
625 pwrst->pwrdm->name, pwrst->next_state); 547 pwrst->pwrdm->name, pwrst->next_state);
626 ret = -1; 548 ret = -1;
627 } 549 }
628 set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state); 550 omap_set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
629 } 551 }
630 if (ret) 552 if (ret)
631 printk(KERN_ERR "Could not enter target state in pm_suspend\n"); 553 printk(KERN_ERR "Could not enter target state in pm_suspend\n");
@@ -756,6 +678,14 @@ static void __init omap3_d2d_idle(void)
756 678
757static void __init prcm_setup_regs(void) 679static void __init prcm_setup_regs(void)
758{ 680{
681 u32 omap3630_auto_uart4_mask = cpu_is_omap3630() ?
682 OMAP3630_AUTO_UART4_MASK : 0;
683 u32 omap3630_en_uart4_mask = cpu_is_omap3630() ?
684 OMAP3630_EN_UART4_MASK : 0;
685 u32 omap3630_grpsel_uart4_mask = cpu_is_omap3630() ?
686 OMAP3630_GRPSEL_UART4_MASK : 0;
687
688
759 /* XXX Reset all wkdeps. This should be done when initializing 689 /* XXX Reset all wkdeps. This should be done when initializing
760 * powerdomains */ 690 * powerdomains */
761 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP); 691 prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP);
@@ -842,6 +772,7 @@ static void __init prcm_setup_regs(void)
842 CM_AUTOIDLE); 772 CM_AUTOIDLE);
843 773
844 cm_write_mod_reg( 774 cm_write_mod_reg(
775 omap3630_auto_uart4_mask |
845 OMAP3430_AUTO_GPIO6_MASK | 776 OMAP3430_AUTO_GPIO6_MASK |
846 OMAP3430_AUTO_GPIO5_MASK | 777 OMAP3430_AUTO_GPIO5_MASK |
847 OMAP3430_AUTO_GPIO4_MASK | 778 OMAP3430_AUTO_GPIO4_MASK |
@@ -918,14 +849,16 @@ static void __init prcm_setup_regs(void)
918 OMAP3430_DSS_MOD, PM_WKEN); 849 OMAP3430_DSS_MOD, PM_WKEN);
919 850
920 /* Enable wakeups in PER */ 851 /* Enable wakeups in PER */
921 prm_write_mod_reg(OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK | 852 prm_write_mod_reg(omap3630_en_uart4_mask |
853 OMAP3430_EN_GPIO2_MASK | OMAP3430_EN_GPIO3_MASK |
922 OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK | 854 OMAP3430_EN_GPIO4_MASK | OMAP3430_EN_GPIO5_MASK |
923 OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK | 855 OMAP3430_EN_GPIO6_MASK | OMAP3430_EN_UART3_MASK |
924 OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK | 856 OMAP3430_EN_MCBSP2_MASK | OMAP3430_EN_MCBSP3_MASK |
925 OMAP3430_EN_MCBSP4_MASK, 857 OMAP3430_EN_MCBSP4_MASK,
926 OMAP3430_PER_MOD, PM_WKEN); 858 OMAP3430_PER_MOD, PM_WKEN);
927 /* and allow them to wake up MPU */ 859 /* and allow them to wake up MPU */
928 prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2_MASK | 860 prm_write_mod_reg(omap3630_grpsel_uart4_mask |
861 OMAP3430_GRPSEL_GPIO2_MASK |
929 OMAP3430_GRPSEL_GPIO3_MASK | 862 OMAP3430_GRPSEL_GPIO3_MASK |
930 OMAP3430_GRPSEL_GPIO4_MASK | 863 OMAP3430_GRPSEL_GPIO4_MASK |
931 OMAP3430_GRPSEL_GPIO5_MASK | 864 OMAP3430_GRPSEL_GPIO5_MASK |
@@ -974,7 +907,7 @@ void omap3_pm_off_mode_enable(int enable)
974 907
975 list_for_each_entry(pwrst, &pwrst_list, node) { 908 list_for_each_entry(pwrst, &pwrst_list, node) {
976 pwrst->next_state = state; 909 pwrst->next_state = state;
977 set_pwrdm_state(pwrst->pwrdm, state); 910 omap_set_pwrdm_state(pwrst->pwrdm, state);
978 } 911 }
979} 912}
980 913
@@ -1019,7 +952,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
1019 if (pwrdm_has_hdwr_sar(pwrdm)) 952 if (pwrdm_has_hdwr_sar(pwrdm))
1020 pwrdm_enable_hdwr_sar(pwrdm); 953 pwrdm_enable_hdwr_sar(pwrdm);
1021 954
1022 return set_pwrdm_state(pwrst->pwrdm, pwrst->next_state); 955 return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
1023} 956}
1024 957
1025/* 958/*
@@ -1029,9 +962,6 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
1029 */ 962 */
1030static int __init clkdms_setup(struct clockdomain *clkdm, void *unused) 963static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
1031{ 964{
1032 clkdm_clear_all_wkdeps(clkdm);
1033 clkdm_clear_all_sleepdeps(clkdm);
1034
1035 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO) 965 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
1036 omap2_clkdm_allow_idle(clkdm); 966 omap2_clkdm_allow_idle(clkdm);
1037 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP && 967 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
diff --git a/arch/arm/mach-omap2/pm_bus.c b/arch/arm/mach-omap2/pm_bus.c
new file mode 100644
index 000000000000..784989f8f2f5
--- /dev/null
+++ b/arch/arm/mach-omap2/pm_bus.c
@@ -0,0 +1,85 @@
1/*
2 * Runtime PM support code for OMAP
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/io.h>
15#include <linux/pm_runtime.h>
16#include <linux/platform_device.h>
17#include <linux/mutex.h>
18
19#include <plat/omap_device.h>
20#include <plat/omap-pm.h>
21
22#ifdef CONFIG_PM_RUNTIME
23int omap_pm_runtime_suspend(struct device *dev)
24{
25 struct platform_device *pdev = to_platform_device(dev);
26 int r, ret = 0;
27
28 dev_dbg(dev, "%s\n", __func__);
29
30 ret = pm_generic_runtime_suspend(dev);
31
32 if (!ret && dev->parent == &omap_device_parent) {
33 r = omap_device_idle(pdev);
34 WARN_ON(r);
35 }
36
37 return ret;
38};
39
40int omap_pm_runtime_resume(struct device *dev)
41{
42 struct platform_device *pdev = to_platform_device(dev);
43 int r;
44
45 dev_dbg(dev, "%s\n", __func__);
46
47 if (dev->parent == &omap_device_parent) {
48 r = omap_device_enable(pdev);
49 WARN_ON(r);
50 }
51
52 return pm_generic_runtime_resume(dev);
53};
54#else
55#define omap_pm_runtime_suspend NULL
56#define omap_pm_runtime_resume NULL
57#endif /* CONFIG_PM_RUNTIME */
58
59static int __init omap_pm_runtime_init(void)
60{
61 const struct dev_pm_ops *pm;
62 struct dev_pm_ops *omap_pm;
63
64 pm = platform_bus_get_pm_ops();
65 if (!pm) {
66 pr_err("%s: unable to get dev_pm_ops from platform_bus\n",
67 __func__);
68 return -ENODEV;
69 }
70
71 omap_pm = kmemdup(pm, sizeof(struct dev_pm_ops), GFP_KERNEL);
72 if (!omap_pm) {
73 pr_err("%s: unable to alloc memory for new dev_pm_ops\n",
74 __func__);
75 return -ENOMEM;
76 }
77
78 omap_pm->runtime_suspend = omap_pm_runtime_suspend;
79 omap_pm->runtime_resume = omap_pm_runtime_resume;
80
81 platform_bus_set_pm_ops(omap_pm);
82
83 return 0;
84}
85core_initcall(omap_pm_runtime_init);
diff --git a/arch/arm/mach-omap2/powerdomains44xx.h b/arch/arm/mach-omap2/powerdomains44xx.h
index c7219513472a..9c01b55d6102 100644
--- a/arch/arm/mach-omap2/powerdomains44xx.h
+++ b/arch/arm/mach-omap2/powerdomains44xx.h
@@ -98,7 +98,7 @@ static struct powerdomain dss_44xx_pwrdm = {
98 .prcm_offs = OMAP4430_PRM_DSS_MOD, 98 .prcm_offs = OMAP4430_PRM_DSS_MOD,
99 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430), 99 .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
100 .pwrsts = PWRSTS_OFF_RET_ON, 100 .pwrsts = PWRSTS_OFF_RET_ON,
101 .pwrsts_logic_ret = PWRSTS_OFF_RET, 101 .pwrsts_logic_ret = PWRSTS_OFF,
102 .banks = 1, 102 .banks = 1,
103 .pwrsts_mem_ret = { 103 .pwrsts_mem_ret = {
104 [0] = PWRDM_POWER_OFF, /* dss_mem */ 104 [0] = PWRDM_POWER_OFF, /* dss_mem */
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index 995b7edbf18d..298a22a754e2 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -382,6 +382,9 @@
382#define OMAP3430_EN_MPU_SHIFT 1 382#define OMAP3430_EN_MPU_SHIFT 1
383 383
384/* CM_FCLKEN_PER, CM_ICLKEN_PER, PM_WKEN_PER shared bits */ 384/* CM_FCLKEN_PER, CM_ICLKEN_PER, PM_WKEN_PER shared bits */
385
386#define OMAP3630_EN_UART4_MASK (1 << 18)
387#define OMAP3630_EN_UART4_SHIFT 18
385#define OMAP3430_EN_GPIO6_MASK (1 << 17) 388#define OMAP3430_EN_GPIO6_MASK (1 << 17)
386#define OMAP3430_EN_GPIO6_SHIFT 17 389#define OMAP3430_EN_GPIO6_SHIFT 17
387#define OMAP3430_EN_GPIO5_MASK (1 << 16) 390#define OMAP3430_EN_GPIO5_MASK (1 << 16)
@@ -422,6 +425,8 @@
422#define OMAP3430_EN_MCBSP2_SHIFT 0 425#define OMAP3430_EN_MCBSP2_SHIFT 0
423 426
424/* CM_IDLEST_PER, PM_WKST_PER shared bits */ 427/* CM_IDLEST_PER, PM_WKST_PER shared bits */
428#define OMAP3630_ST_UART4_SHIFT 18
429#define OMAP3630_ST_UART4_MASK (1 << 18)
425#define OMAP3430_ST_GPIO6_SHIFT 17 430#define OMAP3430_ST_GPIO6_SHIFT 17
426#define OMAP3430_ST_GPIO6_MASK (1 << 17) 431#define OMAP3430_ST_GPIO6_MASK (1 << 17)
427#define OMAP3430_ST_GPIO5_SHIFT 16 432#define OMAP3430_ST_GPIO5_SHIFT 16
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
index c20137497c92..a51846e3a6fa 100644
--- a/arch/arm/mach-omap2/prcm.c
+++ b/arch/arm/mach-omap2/prcm.c
@@ -26,13 +26,14 @@
26#include <plat/common.h> 26#include <plat/common.h>
27#include <plat/prcm.h> 27#include <plat/prcm.h>
28#include <plat/irqs.h> 28#include <plat/irqs.h>
29#include <plat/control.h>
30 29
31#include "clock.h" 30#include "clock.h"
32#include "clock2xxx.h" 31#include "clock2xxx.h"
33#include "cm.h" 32#include "cm.h"
34#include "prm.h" 33#include "prm.h"
35#include "prm-regbits-24xx.h" 34#include "prm-regbits-24xx.h"
35#include "prm-regbits-44xx.h"
36#include "control.h"
36 37
37static void __iomem *prm_base; 38static void __iomem *prm_base;
38static void __iomem *cm_base; 39static void __iomem *cm_base;
@@ -118,7 +119,7 @@ struct omap3_prcm_regs {
118 u32 wkup_pm_wken; 119 u32 wkup_pm_wken;
119}; 120};
120 121
121struct omap3_prcm_regs prcm_context; 122static struct omap3_prcm_regs prcm_context;
122 123
123u32 omap_prcm_get_reset_sources(void) 124u32 omap_prcm_get_reset_sources(void)
124{ 125{
@@ -161,8 +162,8 @@ void omap_prcm_arch_reset(char mode, const char *cmd)
161 prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, prcm_offs, 162 prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, prcm_offs,
162 OMAP2_RM_RSTCTRL); 163 OMAP2_RM_RSTCTRL);
163 if (cpu_is_omap44xx()) 164 if (cpu_is_omap44xx())
164 prm_set_mod_reg_bits(OMAP_RST_DPLL3_MASK, prcm_offs, 165 prm_set_mod_reg_bits(OMAP4430_RST_GLOBAL_WARM_SW_MASK,
165 OMAP4_RM_RSTCTRL); 166 prcm_offs, OMAP4_RM_RSTCTRL);
166} 167}
167 168
168static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg) 169static inline u32 __omap_prcm_read(void __iomem *base, s16 module, u16 reg)
@@ -215,6 +216,30 @@ u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask)
215 return v; 216 return v;
216} 217}
217 218
219/* Read a PRM register, AND it, and shift the result down to bit 0 */
220u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask)
221{
222 u32 v;
223
224 v = __raw_readl(reg);
225 v &= mask;
226 v >>= __ffs(mask);
227
228 return v;
229}
230
231/* Read-modify-write a register in a PRM module. Caller must lock */
232u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg)
233{
234 u32 v;
235
236 v = __raw_readl(reg);
237 v &= ~mask;
238 v |= bits;
239 __raw_writel(v, reg);
240
241 return v;
242}
218/* Read a register in a CM module */ 243/* Read a register in a CM module */
219u32 cm_read_mod_reg(s16 module, u16 idx) 244u32 cm_read_mod_reg(s16 module, u16 idx)
220{ 245{
diff --git a/arch/arm/mach-omap2/prm-regbits-34xx.h b/arch/arm/mach-omap2/prm-regbits-34xx.h
index 7fd6023edf96..9e63cb743a97 100644
--- a/arch/arm/mach-omap2/prm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-34xx.h
@@ -122,6 +122,7 @@
122#define OMAP3430_MEMRETSTATE_MASK (1 << 8) 122#define OMAP3430_MEMRETSTATE_MASK (1 << 8)
123 123
124/* PM_MPUGRPSEL_PER, PM_IVA2GRPSEL_PER shared bits */ 124/* PM_MPUGRPSEL_PER, PM_IVA2GRPSEL_PER shared bits */
125#define OMAP3630_GRPSEL_UART4_MASK (1 << 18)
125#define OMAP3430_GRPSEL_GPIO6_MASK (1 << 17) 126#define OMAP3430_GRPSEL_GPIO6_MASK (1 << 17)
126#define OMAP3430_GRPSEL_GPIO5_MASK (1 << 16) 127#define OMAP3430_GRPSEL_GPIO5_MASK (1 << 16)
127#define OMAP3430_GRPSEL_GPIO4_MASK (1 << 15) 128#define OMAP3430_GRPSEL_GPIO4_MASK (1 << 15)
diff --git a/arch/arm/mach-omap2/prm-regbits-44xx.h b/arch/arm/mach-omap2/prm-regbits-44xx.h
index 597be4a2b9ff..25b19b610177 100644
--- a/arch/arm/mach-omap2/prm-regbits-44xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-44xx.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * OMAP44xx Power Management register bits 2 * OMAP44xx Power Management register bits
3 * 3 *
4 * Copyright (C) 2009 Texas Instruments, Inc. 4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 * Copyright (C) 2009 Nokia Corporation 5 * Copyright (C) 2009-2010 Nokia Corporation
6 * 6 *
7 * Paul Walmsley (paul@pwsan.com) 7 * Paul Walmsley (paul@pwsan.com)
8 * Rajendra Nayak (rnayak@ti.com) 8 * Rajendra Nayak (rnayak@ti.com)
@@ -30,587 +30,611 @@
30 * PRM_LDO_SRAM_MPU_SETUP 30 * PRM_LDO_SRAM_MPU_SETUP
31 */ 31 */
32#define OMAP4430_ABBOFF_ACT_EXPORT_SHIFT 1 32#define OMAP4430_ABBOFF_ACT_EXPORT_SHIFT 1
33#define OMAP4430_ABBOFF_ACT_EXPORT_MASK BITFIELD(1, 1) 33#define OMAP4430_ABBOFF_ACT_EXPORT_MASK (1 << 1)
34 34
35/* 35/*
36 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 36 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
37 * PRM_LDO_SRAM_MPU_SETUP 37 * PRM_LDO_SRAM_MPU_SETUP
38 */ 38 */
39#define OMAP4430_ABBOFF_SLEEP_EXPORT_SHIFT 2 39#define OMAP4430_ABBOFF_SLEEP_EXPORT_SHIFT 2
40#define OMAP4430_ABBOFF_SLEEP_EXPORT_MASK BITFIELD(2, 2) 40#define OMAP4430_ABBOFF_SLEEP_EXPORT_MASK (1 << 2)
41 41
42/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 42/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
43#define OMAP4430_ABB_IVA_DONE_EN_SHIFT 31 43#define OMAP4430_ABB_IVA_DONE_EN_SHIFT 31
44#define OMAP4430_ABB_IVA_DONE_EN_MASK BITFIELD(31, 31) 44#define OMAP4430_ABB_IVA_DONE_EN_MASK (1 << 31)
45 45
46/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 46/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
47#define OMAP4430_ABB_IVA_DONE_ST_SHIFT 31 47#define OMAP4430_ABB_IVA_DONE_ST_SHIFT 31
48#define OMAP4430_ABB_IVA_DONE_ST_MASK BITFIELD(31, 31) 48#define OMAP4430_ABB_IVA_DONE_ST_MASK (1 << 31)
49 49
50/* Used by PRM_IRQENABLE_MPU_2 */ 50/* Used by PRM_IRQENABLE_MPU_2 */
51#define OMAP4430_ABB_MPU_DONE_EN_SHIFT 7 51#define OMAP4430_ABB_MPU_DONE_EN_SHIFT 7
52#define OMAP4430_ABB_MPU_DONE_EN_MASK BITFIELD(7, 7) 52#define OMAP4430_ABB_MPU_DONE_EN_MASK (1 << 7)
53 53
54/* Used by PRM_IRQSTATUS_MPU_2 */ 54/* Used by PRM_IRQSTATUS_MPU_2 */
55#define OMAP4430_ABB_MPU_DONE_ST_SHIFT 7 55#define OMAP4430_ABB_MPU_DONE_ST_SHIFT 7
56#define OMAP4430_ABB_MPU_DONE_ST_MASK BITFIELD(7, 7) 56#define OMAP4430_ABB_MPU_DONE_ST_MASK (1 << 7)
57 57
58/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */ 58/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */
59#define OMAP4430_ACTIVE_FBB_SEL_SHIFT 2 59#define OMAP4430_ACTIVE_FBB_SEL_SHIFT 2
60#define OMAP4430_ACTIVE_FBB_SEL_MASK BITFIELD(2, 2) 60#define OMAP4430_ACTIVE_FBB_SEL_MASK (1 << 2)
61 61
62/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */ 62/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */
63#define OMAP4430_ACTIVE_RBB_SEL_SHIFT 1 63#define OMAP4430_ACTIVE_RBB_SEL_SHIFT 1
64#define OMAP4430_ACTIVE_RBB_SEL_MASK BITFIELD(1, 1) 64#define OMAP4430_ACTIVE_RBB_SEL_MASK (1 << 1)
65 65
66/* Used by PM_ABE_PWRSTCTRL */ 66/* Used by PM_ABE_PWRSTCTRL */
67#define OMAP4430_AESSMEM_ONSTATE_SHIFT 16 67#define OMAP4430_AESSMEM_ONSTATE_SHIFT 16
68#define OMAP4430_AESSMEM_ONSTATE_MASK BITFIELD(16, 17) 68#define OMAP4430_AESSMEM_ONSTATE_MASK (0x3 << 16)
69 69
70/* Used by PM_ABE_PWRSTCTRL */ 70/* Used by PM_ABE_PWRSTCTRL */
71#define OMAP4430_AESSMEM_RETSTATE_SHIFT 8 71#define OMAP4430_AESSMEM_RETSTATE_SHIFT 8
72#define OMAP4430_AESSMEM_RETSTATE_MASK BITFIELD(8, 8) 72#define OMAP4430_AESSMEM_RETSTATE_MASK (1 << 8)
73 73
74/* Used by PM_ABE_PWRSTST */ 74/* Used by PM_ABE_PWRSTST */
75#define OMAP4430_AESSMEM_STATEST_SHIFT 4 75#define OMAP4430_AESSMEM_STATEST_SHIFT 4
76#define OMAP4430_AESSMEM_STATEST_MASK BITFIELD(4, 5) 76#define OMAP4430_AESSMEM_STATEST_MASK (0x3 << 4)
77 77
78/* 78/*
79 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 79 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
80 * PRM_LDO_SRAM_MPU_SETUP 80 * PRM_LDO_SRAM_MPU_SETUP
81 */ 81 */
82#define OMAP4430_AIPOFF_SHIFT 8 82#define OMAP4430_AIPOFF_SHIFT 8
83#define OMAP4430_AIPOFF_MASK BITFIELD(8, 8) 83#define OMAP4430_AIPOFF_MASK (1 << 8)
84 84
85/* Used by PRM_VOLTCTRL */ 85/* Used by PRM_VOLTCTRL */
86#define OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT 0 86#define OMAP4430_AUTO_CTRL_VDD_CORE_L_SHIFT 0
87#define OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK BITFIELD(0, 1) 87#define OMAP4430_AUTO_CTRL_VDD_CORE_L_MASK (0x3 << 0)
88 88
89/* Used by PRM_VOLTCTRL */ 89/* Used by PRM_VOLTCTRL */
90#define OMAP4430_AUTO_CTRL_VDD_IVA_L_SHIFT 4 90#define OMAP4430_AUTO_CTRL_VDD_IVA_L_SHIFT 4
91#define OMAP4430_AUTO_CTRL_VDD_IVA_L_MASK BITFIELD(4, 5) 91#define OMAP4430_AUTO_CTRL_VDD_IVA_L_MASK (0x3 << 4)
92 92
93/* Used by PRM_VOLTCTRL */ 93/* Used by PRM_VOLTCTRL */
94#define OMAP4430_AUTO_CTRL_VDD_MPU_L_SHIFT 2 94#define OMAP4430_AUTO_CTRL_VDD_MPU_L_SHIFT 2
95#define OMAP4430_AUTO_CTRL_VDD_MPU_L_MASK BITFIELD(2, 3) 95#define OMAP4430_AUTO_CTRL_VDD_MPU_L_MASK (0x3 << 2)
96
97/* Used by PRM_VC_ERRST */
98#define OMAP4430_BYPS_RA_ERR_SHIFT 25
99#define OMAP4430_BYPS_RA_ERR_MASK (1 << 25)
100
101/* Used by PRM_VC_ERRST */
102#define OMAP4430_BYPS_SA_ERR_SHIFT 24
103#define OMAP4430_BYPS_SA_ERR_MASK (1 << 24)
104
105/* Used by PRM_VC_ERRST */
106#define OMAP4430_BYPS_TIMEOUT_ERR_SHIFT 26
107#define OMAP4430_BYPS_TIMEOUT_ERR_MASK (1 << 26)
108
109/* Used by PRM_RSTST */
110#define OMAP4430_C2C_RST_SHIFT 10
111#define OMAP4430_C2C_RST_MASK (1 << 10)
96 112
97/* Used by PM_CAM_PWRSTCTRL */ 113/* Used by PM_CAM_PWRSTCTRL */
98#define OMAP4430_CAM_MEM_ONSTATE_SHIFT 16 114#define OMAP4430_CAM_MEM_ONSTATE_SHIFT 16
99#define OMAP4430_CAM_MEM_ONSTATE_MASK BITFIELD(16, 17) 115#define OMAP4430_CAM_MEM_ONSTATE_MASK (0x3 << 16)
100 116
101/* Used by PM_CAM_PWRSTST */ 117/* Used by PM_CAM_PWRSTST */
102#define OMAP4430_CAM_MEM_STATEST_SHIFT 4 118#define OMAP4430_CAM_MEM_STATEST_SHIFT 4
103#define OMAP4430_CAM_MEM_STATEST_MASK BITFIELD(4, 5) 119#define OMAP4430_CAM_MEM_STATEST_MASK (0x3 << 4)
104 120
105/* Used by PRM_CLKREQCTRL */ 121/* Used by PRM_CLKREQCTRL */
106#define OMAP4430_CLKREQ_COND_SHIFT 0 122#define OMAP4430_CLKREQ_COND_SHIFT 0
107#define OMAP4430_CLKREQ_COND_MASK BITFIELD(0, 2) 123#define OMAP4430_CLKREQ_COND_MASK (0x7 << 0)
108 124
109/* Used by PRM_VC_VAL_SMPS_RA_CMD */ 125/* Used by PRM_VC_VAL_SMPS_RA_CMD */
110#define OMAP4430_CMDRA_VDD_CORE_L_SHIFT 0 126#define OMAP4430_CMDRA_VDD_CORE_L_SHIFT 0
111#define OMAP4430_CMDRA_VDD_CORE_L_MASK BITFIELD(0, 7) 127#define OMAP4430_CMDRA_VDD_CORE_L_MASK (0xff << 0)
112 128
113/* Used by PRM_VC_VAL_SMPS_RA_CMD */ 129/* Used by PRM_VC_VAL_SMPS_RA_CMD */
114#define OMAP4430_CMDRA_VDD_IVA_L_SHIFT 8 130#define OMAP4430_CMDRA_VDD_IVA_L_SHIFT 8
115#define OMAP4430_CMDRA_VDD_IVA_L_MASK BITFIELD(8, 15) 131#define OMAP4430_CMDRA_VDD_IVA_L_MASK (0xff << 8)
116 132
117/* Used by PRM_VC_VAL_SMPS_RA_CMD */ 133/* Used by PRM_VC_VAL_SMPS_RA_CMD */
118#define OMAP4430_CMDRA_VDD_MPU_L_SHIFT 16 134#define OMAP4430_CMDRA_VDD_MPU_L_SHIFT 16
119#define OMAP4430_CMDRA_VDD_MPU_L_MASK BITFIELD(16, 23) 135#define OMAP4430_CMDRA_VDD_MPU_L_MASK (0xff << 16)
120 136
121/* Used by PRM_VC_CFG_CHANNEL */ 137/* Used by PRM_VC_CFG_CHANNEL */
122#define OMAP4430_CMD_VDD_CORE_L_SHIFT 4 138#define OMAP4430_CMD_VDD_CORE_L_SHIFT 4
123#define OMAP4430_CMD_VDD_CORE_L_MASK BITFIELD(4, 4) 139#define OMAP4430_CMD_VDD_CORE_L_MASK (1 << 4)
124 140
125/* Used by PRM_VC_CFG_CHANNEL */ 141/* Used by PRM_VC_CFG_CHANNEL */
126#define OMAP4430_CMD_VDD_IVA_L_SHIFT 12 142#define OMAP4430_CMD_VDD_IVA_L_SHIFT 12
127#define OMAP4430_CMD_VDD_IVA_L_MASK BITFIELD(12, 12) 143#define OMAP4430_CMD_VDD_IVA_L_MASK (1 << 12)
128 144
129/* Used by PRM_VC_CFG_CHANNEL */ 145/* Used by PRM_VC_CFG_CHANNEL */
130#define OMAP4430_CMD_VDD_MPU_L_SHIFT 17 146#define OMAP4430_CMD_VDD_MPU_L_SHIFT 17
131#define OMAP4430_CMD_VDD_MPU_L_MASK BITFIELD(17, 17) 147#define OMAP4430_CMD_VDD_MPU_L_MASK (1 << 17)
132 148
133/* Used by PM_CORE_PWRSTCTRL */ 149/* Used by PM_CORE_PWRSTCTRL */
134#define OMAP4430_CORE_OCMRAM_ONSTATE_SHIFT 18 150#define OMAP4430_CORE_OCMRAM_ONSTATE_SHIFT 18
135#define OMAP4430_CORE_OCMRAM_ONSTATE_MASK BITFIELD(18, 19) 151#define OMAP4430_CORE_OCMRAM_ONSTATE_MASK (0x3 << 18)
136 152
137/* Used by PM_CORE_PWRSTCTRL */ 153/* Used by PM_CORE_PWRSTCTRL */
138#define OMAP4430_CORE_OCMRAM_RETSTATE_SHIFT 9 154#define OMAP4430_CORE_OCMRAM_RETSTATE_SHIFT 9
139#define OMAP4430_CORE_OCMRAM_RETSTATE_MASK BITFIELD(9, 9) 155#define OMAP4430_CORE_OCMRAM_RETSTATE_MASK (1 << 9)
140 156
141/* Used by PM_CORE_PWRSTST */ 157/* Used by PM_CORE_PWRSTST */
142#define OMAP4430_CORE_OCMRAM_STATEST_SHIFT 6 158#define OMAP4430_CORE_OCMRAM_STATEST_SHIFT 6
143#define OMAP4430_CORE_OCMRAM_STATEST_MASK BITFIELD(6, 7) 159#define OMAP4430_CORE_OCMRAM_STATEST_MASK (0x3 << 6)
144 160
145/* Used by PM_CORE_PWRSTCTRL */ 161/* Used by PM_CORE_PWRSTCTRL */
146#define OMAP4430_CORE_OTHER_BANK_ONSTATE_SHIFT 16 162#define OMAP4430_CORE_OTHER_BANK_ONSTATE_SHIFT 16
147#define OMAP4430_CORE_OTHER_BANK_ONSTATE_MASK BITFIELD(16, 17) 163#define OMAP4430_CORE_OTHER_BANK_ONSTATE_MASK (0x3 << 16)
148 164
149/* Used by PM_CORE_PWRSTCTRL */ 165/* Used by PM_CORE_PWRSTCTRL */
150#define OMAP4430_CORE_OTHER_BANK_RETSTATE_SHIFT 8 166#define OMAP4430_CORE_OTHER_BANK_RETSTATE_SHIFT 8
151#define OMAP4430_CORE_OTHER_BANK_RETSTATE_MASK BITFIELD(8, 8) 167#define OMAP4430_CORE_OTHER_BANK_RETSTATE_MASK (1 << 8)
152 168
153/* Used by PM_CORE_PWRSTST */ 169/* Used by PM_CORE_PWRSTST */
154#define OMAP4430_CORE_OTHER_BANK_STATEST_SHIFT 4 170#define OMAP4430_CORE_OTHER_BANK_STATEST_SHIFT 4
155#define OMAP4430_CORE_OTHER_BANK_STATEST_MASK BITFIELD(4, 5) 171#define OMAP4430_CORE_OTHER_BANK_STATEST_MASK (0x3 << 4)
172
173/* Used by REVISION_PRM */
174#define OMAP4430_CUSTOM_SHIFT 6
175#define OMAP4430_CUSTOM_MASK (0x3 << 6)
156 176
157/* Used by PRM_VC_VAL_BYPASS */ 177/* Used by PRM_VC_VAL_BYPASS */
158#define OMAP4430_DATA_SHIFT 16 178#define OMAP4430_DATA_SHIFT 16
159#define OMAP4430_DATA_MASK BITFIELD(16, 23) 179#define OMAP4430_DATA_MASK (0xff << 16)
160 180
161/* Used by PRM_DEVICE_OFF_CTRL */ 181/* Used by PRM_DEVICE_OFF_CTRL */
162#define OMAP4430_DEVICE_OFF_ENABLE_SHIFT 0 182#define OMAP4430_DEVICE_OFF_ENABLE_SHIFT 0
163#define OMAP4430_DEVICE_OFF_ENABLE_MASK BITFIELD(0, 0) 183#define OMAP4430_DEVICE_OFF_ENABLE_MASK (1 << 0)
164 184
165/* Used by PRM_VC_CFG_I2C_MODE */ 185/* Used by PRM_VC_CFG_I2C_MODE */
166#define OMAP4430_DFILTEREN_SHIFT 6 186#define OMAP4430_DFILTEREN_SHIFT 6
167#define OMAP4430_DFILTEREN_MASK BITFIELD(6, 6) 187#define OMAP4430_DFILTEREN_MASK (1 << 6)
168 188
169/* Used by PRM_IRQENABLE_MPU, PRM_IRQENABLE_TESLA */ 189/*
190 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
191 * PRM_LDO_SRAM_MPU_SETUP, PRM_SRAM_WKUP_SETUP
192 */
193#define OMAP4430_DISABLE_RTA_EXPORT_SHIFT 0
194#define OMAP4430_DISABLE_RTA_EXPORT_MASK (1 << 0)
195
196/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU, PRM_IRQENABLE_TESLA */
170#define OMAP4430_DPLL_ABE_RECAL_EN_SHIFT 4 197#define OMAP4430_DPLL_ABE_RECAL_EN_SHIFT 4
171#define OMAP4430_DPLL_ABE_RECAL_EN_MASK BITFIELD(4, 4) 198#define OMAP4430_DPLL_ABE_RECAL_EN_MASK (1 << 4)
172 199
173/* Used by PRM_IRQSTATUS_MPU, PRM_IRQSTATUS_TESLA */ 200/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU, PRM_IRQSTATUS_TESLA */
174#define OMAP4430_DPLL_ABE_RECAL_ST_SHIFT 4 201#define OMAP4430_DPLL_ABE_RECAL_ST_SHIFT 4
175#define OMAP4430_DPLL_ABE_RECAL_ST_MASK BITFIELD(4, 4) 202#define OMAP4430_DPLL_ABE_RECAL_ST_MASK (1 << 4)
176 203
177/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 204/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
178#define OMAP4430_DPLL_CORE_RECAL_EN_SHIFT 0 205#define OMAP4430_DPLL_CORE_RECAL_EN_SHIFT 0
179#define OMAP4430_DPLL_CORE_RECAL_EN_MASK BITFIELD(0, 0) 206#define OMAP4430_DPLL_CORE_RECAL_EN_MASK (1 << 0)
180 207
181/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 208/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
182#define OMAP4430_DPLL_CORE_RECAL_ST_SHIFT 0 209#define OMAP4430_DPLL_CORE_RECAL_ST_SHIFT 0
183#define OMAP4430_DPLL_CORE_RECAL_ST_MASK BITFIELD(0, 0) 210#define OMAP4430_DPLL_CORE_RECAL_ST_MASK (1 << 0)
184 211
185/* Used by PRM_IRQENABLE_MPU */ 212/* Used by PRM_IRQENABLE_MPU */
186#define OMAP4430_DPLL_DDRPHY_RECAL_EN_SHIFT 6 213#define OMAP4430_DPLL_DDRPHY_RECAL_EN_SHIFT 6
187#define OMAP4430_DPLL_DDRPHY_RECAL_EN_MASK BITFIELD(6, 6) 214#define OMAP4430_DPLL_DDRPHY_RECAL_EN_MASK (1 << 6)
188 215
189/* Used by PRM_IRQSTATUS_MPU */ 216/* Used by PRM_IRQSTATUS_MPU */
190#define OMAP4430_DPLL_DDRPHY_RECAL_ST_SHIFT 6 217#define OMAP4430_DPLL_DDRPHY_RECAL_ST_SHIFT 6
191#define OMAP4430_DPLL_DDRPHY_RECAL_ST_MASK BITFIELD(6, 6) 218#define OMAP4430_DPLL_DDRPHY_RECAL_ST_MASK (1 << 6)
192 219
193/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU, PRM_IRQENABLE_TESLA */ 220/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU, PRM_IRQENABLE_TESLA */
194#define OMAP4430_DPLL_IVA_RECAL_EN_SHIFT 2 221#define OMAP4430_DPLL_IVA_RECAL_EN_SHIFT 2
195#define OMAP4430_DPLL_IVA_RECAL_EN_MASK BITFIELD(2, 2) 222#define OMAP4430_DPLL_IVA_RECAL_EN_MASK (1 << 2)
196 223
197/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU, PRM_IRQSTATUS_TESLA */ 224/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU, PRM_IRQSTATUS_TESLA */
198#define OMAP4430_DPLL_IVA_RECAL_ST_SHIFT 2 225#define OMAP4430_DPLL_IVA_RECAL_ST_SHIFT 2
199#define OMAP4430_DPLL_IVA_RECAL_ST_MASK BITFIELD(2, 2) 226#define OMAP4430_DPLL_IVA_RECAL_ST_MASK (1 << 2)
200 227
201/* Used by PRM_IRQENABLE_MPU */ 228/* Used by PRM_IRQENABLE_MPU */
202#define OMAP4430_DPLL_MPU_RECAL_EN_SHIFT 1 229#define OMAP4430_DPLL_MPU_RECAL_EN_SHIFT 1
203#define OMAP4430_DPLL_MPU_RECAL_EN_MASK BITFIELD(1, 1) 230#define OMAP4430_DPLL_MPU_RECAL_EN_MASK (1 << 1)
204 231
205/* Used by PRM_IRQSTATUS_MPU */ 232/* Used by PRM_IRQSTATUS_MPU */
206#define OMAP4430_DPLL_MPU_RECAL_ST_SHIFT 1 233#define OMAP4430_DPLL_MPU_RECAL_ST_SHIFT 1
207#define OMAP4430_DPLL_MPU_RECAL_ST_MASK BITFIELD(1, 1) 234#define OMAP4430_DPLL_MPU_RECAL_ST_MASK (1 << 1)
208 235
209/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 236/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
210#define OMAP4430_DPLL_PER_RECAL_EN_SHIFT 3 237#define OMAP4430_DPLL_PER_RECAL_EN_SHIFT 3
211#define OMAP4430_DPLL_PER_RECAL_EN_MASK BITFIELD(3, 3) 238#define OMAP4430_DPLL_PER_RECAL_EN_MASK (1 << 3)
212 239
213/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 240/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
214#define OMAP4430_DPLL_PER_RECAL_ST_SHIFT 3 241#define OMAP4430_DPLL_PER_RECAL_ST_SHIFT 3
215#define OMAP4430_DPLL_PER_RECAL_ST_MASK BITFIELD(3, 3) 242#define OMAP4430_DPLL_PER_RECAL_ST_MASK (1 << 3)
216 243
217/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 244/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
218#define OMAP4430_DPLL_UNIPRO_RECAL_EN_SHIFT 7 245#define OMAP4430_DPLL_UNIPRO_RECAL_EN_SHIFT 7
219#define OMAP4430_DPLL_UNIPRO_RECAL_EN_MASK BITFIELD(7, 7) 246#define OMAP4430_DPLL_UNIPRO_RECAL_EN_MASK (1 << 7)
220 247
221/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 248/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
222#define OMAP4430_DPLL_UNIPRO_RECAL_ST_SHIFT 7 249#define OMAP4430_DPLL_UNIPRO_RECAL_ST_SHIFT 7
223#define OMAP4430_DPLL_UNIPRO_RECAL_ST_MASK BITFIELD(7, 7) 250#define OMAP4430_DPLL_UNIPRO_RECAL_ST_MASK (1 << 7)
224
225/* Used by PRM_IRQENABLE_MPU */
226#define OMAP4430_DPLL_USB_RECAL_EN_SHIFT 5
227#define OMAP4430_DPLL_USB_RECAL_EN_MASK BITFIELD(5, 5)
228
229/* Used by PRM_IRQSTATUS_MPU */
230#define OMAP4430_DPLL_USB_RECAL_ST_SHIFT 5
231#define OMAP4430_DPLL_USB_RECAL_ST_MASK BITFIELD(5, 5)
232 251
233/* Used by PM_DSS_PWRSTCTRL */ 252/* Used by PM_DSS_PWRSTCTRL */
234#define OMAP4430_DSS_MEM_ONSTATE_SHIFT 16 253#define OMAP4430_DSS_MEM_ONSTATE_SHIFT 16
235#define OMAP4430_DSS_MEM_ONSTATE_MASK BITFIELD(16, 17) 254#define OMAP4430_DSS_MEM_ONSTATE_MASK (0x3 << 16)
236 255
237/* Used by PM_DSS_PWRSTCTRL */ 256/* Used by PM_DSS_PWRSTCTRL */
238#define OMAP4430_DSS_MEM_RETSTATE_SHIFT 8 257#define OMAP4430_DSS_MEM_RETSTATE_SHIFT 8
239#define OMAP4430_DSS_MEM_RETSTATE_MASK BITFIELD(8, 8) 258#define OMAP4430_DSS_MEM_RETSTATE_MASK (1 << 8)
240 259
241/* Used by PM_DSS_PWRSTST */ 260/* Used by PM_DSS_PWRSTST */
242#define OMAP4430_DSS_MEM_STATEST_SHIFT 4 261#define OMAP4430_DSS_MEM_STATEST_SHIFT 4
243#define OMAP4430_DSS_MEM_STATEST_MASK BITFIELD(4, 5) 262#define OMAP4430_DSS_MEM_STATEST_MASK (0x3 << 4)
244 263
245/* Used by PM_CORE_PWRSTCTRL */ 264/* Used by PM_CORE_PWRSTCTRL */
246#define OMAP4430_DUCATI_L2RAM_ONSTATE_SHIFT 20 265#define OMAP4430_DUCATI_L2RAM_ONSTATE_SHIFT 20
247#define OMAP4430_DUCATI_L2RAM_ONSTATE_MASK BITFIELD(20, 21) 266#define OMAP4430_DUCATI_L2RAM_ONSTATE_MASK (0x3 << 20)
248 267
249/* Used by PM_CORE_PWRSTCTRL */ 268/* Used by PM_CORE_PWRSTCTRL */
250#define OMAP4430_DUCATI_L2RAM_RETSTATE_SHIFT 10 269#define OMAP4430_DUCATI_L2RAM_RETSTATE_SHIFT 10
251#define OMAP4430_DUCATI_L2RAM_RETSTATE_MASK BITFIELD(10, 10) 270#define OMAP4430_DUCATI_L2RAM_RETSTATE_MASK (1 << 10)
252 271
253/* Used by PM_CORE_PWRSTST */ 272/* Used by PM_CORE_PWRSTST */
254#define OMAP4430_DUCATI_L2RAM_STATEST_SHIFT 8 273#define OMAP4430_DUCATI_L2RAM_STATEST_SHIFT 8
255#define OMAP4430_DUCATI_L2RAM_STATEST_MASK BITFIELD(8, 9) 274#define OMAP4430_DUCATI_L2RAM_STATEST_MASK (0x3 << 8)
256 275
257/* Used by PM_CORE_PWRSTCTRL */ 276/* Used by PM_CORE_PWRSTCTRL */
258#define OMAP4430_DUCATI_UNICACHE_ONSTATE_SHIFT 22 277#define OMAP4430_DUCATI_UNICACHE_ONSTATE_SHIFT 22
259#define OMAP4430_DUCATI_UNICACHE_ONSTATE_MASK BITFIELD(22, 23) 278#define OMAP4430_DUCATI_UNICACHE_ONSTATE_MASK (0x3 << 22)
260 279
261/* Used by PM_CORE_PWRSTCTRL */ 280/* Used by PM_CORE_PWRSTCTRL */
262#define OMAP4430_DUCATI_UNICACHE_RETSTATE_SHIFT 11 281#define OMAP4430_DUCATI_UNICACHE_RETSTATE_SHIFT 11
263#define OMAP4430_DUCATI_UNICACHE_RETSTATE_MASK BITFIELD(11, 11) 282#define OMAP4430_DUCATI_UNICACHE_RETSTATE_MASK (1 << 11)
264 283
265/* Used by PM_CORE_PWRSTST */ 284/* Used by PM_CORE_PWRSTST */
266#define OMAP4430_DUCATI_UNICACHE_STATEST_SHIFT 10 285#define OMAP4430_DUCATI_UNICACHE_STATEST_SHIFT 10
267#define OMAP4430_DUCATI_UNICACHE_STATEST_MASK BITFIELD(10, 11) 286#define OMAP4430_DUCATI_UNICACHE_STATEST_MASK (0x3 << 10)
268 287
269/* Used by RM_MPU_RSTST */ 288/* Used by RM_MPU_RSTST */
270#define OMAP4430_EMULATION_RST_SHIFT 0 289#define OMAP4430_EMULATION_RST_SHIFT 0
271#define OMAP4430_EMULATION_RST_MASK BITFIELD(0, 0) 290#define OMAP4430_EMULATION_RST_MASK (1 << 0)
272 291
273/* Used by RM_DUCATI_RSTST */ 292/* Used by RM_DUCATI_RSTST */
274#define OMAP4430_EMULATION_RST1ST_SHIFT 3 293#define OMAP4430_EMULATION_RST1ST_SHIFT 3
275#define OMAP4430_EMULATION_RST1ST_MASK BITFIELD(3, 3) 294#define OMAP4430_EMULATION_RST1ST_MASK (1 << 3)
276 295
277/* Used by RM_DUCATI_RSTST */ 296/* Used by RM_DUCATI_RSTST */
278#define OMAP4430_EMULATION_RST2ST_SHIFT 4 297#define OMAP4430_EMULATION_RST2ST_SHIFT 4
279#define OMAP4430_EMULATION_RST2ST_MASK BITFIELD(4, 4) 298#define OMAP4430_EMULATION_RST2ST_MASK (1 << 4)
280 299
281/* Used by RM_IVAHD_RSTST */ 300/* Used by RM_IVAHD_RSTST */
282#define OMAP4430_EMULATION_SEQ1_RST1ST_SHIFT 3 301#define OMAP4430_EMULATION_SEQ1_RST1ST_SHIFT 3
283#define OMAP4430_EMULATION_SEQ1_RST1ST_MASK BITFIELD(3, 3) 302#define OMAP4430_EMULATION_SEQ1_RST1ST_MASK (1 << 3)
284 303
285/* Used by RM_IVAHD_RSTST */ 304/* Used by RM_IVAHD_RSTST */
286#define OMAP4430_EMULATION_SEQ2_RST2ST_SHIFT 4 305#define OMAP4430_EMULATION_SEQ2_RST2ST_SHIFT 4
287#define OMAP4430_EMULATION_SEQ2_RST2ST_MASK BITFIELD(4, 4) 306#define OMAP4430_EMULATION_SEQ2_RST2ST_MASK (1 << 4)
288 307
289/* Used by PM_EMU_PWRSTCTRL */ 308/* Used by PM_EMU_PWRSTCTRL */
290#define OMAP4430_EMU_BANK_ONSTATE_SHIFT 16 309#define OMAP4430_EMU_BANK_ONSTATE_SHIFT 16
291#define OMAP4430_EMU_BANK_ONSTATE_MASK BITFIELD(16, 17) 310#define OMAP4430_EMU_BANK_ONSTATE_MASK (0x3 << 16)
292 311
293/* Used by PM_EMU_PWRSTST */ 312/* Used by PM_EMU_PWRSTST */
294#define OMAP4430_EMU_BANK_STATEST_SHIFT 4 313#define OMAP4430_EMU_BANK_STATEST_SHIFT 4
295#define OMAP4430_EMU_BANK_STATEST_MASK BITFIELD(4, 5) 314#define OMAP4430_EMU_BANK_STATEST_MASK (0x3 << 4)
296
297/*
298 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
299 * PRM_LDO_SRAM_MPU_SETUP, PRM_SRAM_WKUP_SETUP
300 */
301#define OMAP4430_ENABLE_RTA_EXPORT_SHIFT 0
302#define OMAP4430_ENABLE_RTA_EXPORT_MASK BITFIELD(0, 0)
303 315
304/* 316/*
305 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 317 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
306 * PRM_LDO_SRAM_MPU_SETUP 318 * PRM_LDO_SRAM_MPU_SETUP
307 */ 319 */
308#define OMAP4430_ENFUNC1_SHIFT 3 320#define OMAP4430_ENFUNC1_EXPORT_SHIFT 3
309#define OMAP4430_ENFUNC1_MASK BITFIELD(3, 3) 321#define OMAP4430_ENFUNC1_EXPORT_MASK (1 << 3)
310 322
311/* 323/*
312 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 324 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
313 * PRM_LDO_SRAM_MPU_SETUP 325 * PRM_LDO_SRAM_MPU_SETUP
314 */ 326 */
315#define OMAP4430_ENFUNC3_SHIFT 5 327#define OMAP4430_ENFUNC3_EXPORT_SHIFT 5
316#define OMAP4430_ENFUNC3_MASK BITFIELD(5, 5) 328#define OMAP4430_ENFUNC3_EXPORT_MASK (1 << 5)
317 329
318/* 330/*
319 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 331 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
320 * PRM_LDO_SRAM_MPU_SETUP 332 * PRM_LDO_SRAM_MPU_SETUP
321 */ 333 */
322#define OMAP4430_ENFUNC4_SHIFT 6 334#define OMAP4430_ENFUNC4_SHIFT 6
323#define OMAP4430_ENFUNC4_MASK BITFIELD(6, 6) 335#define OMAP4430_ENFUNC4_MASK (1 << 6)
324 336
325/* 337/*
326 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP, 338 * Used by PRM_LDO_SRAM_CORE_SETUP, PRM_LDO_SRAM_IVA_SETUP,
327 * PRM_LDO_SRAM_MPU_SETUP 339 * PRM_LDO_SRAM_MPU_SETUP
328 */ 340 */
329#define OMAP4430_ENFUNC5_SHIFT 7 341#define OMAP4430_ENFUNC5_SHIFT 7
330#define OMAP4430_ENFUNC5_MASK BITFIELD(7, 7) 342#define OMAP4430_ENFUNC5_MASK (1 << 7)
331 343
332/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 344/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
333#define OMAP4430_ERRORGAIN_SHIFT 16 345#define OMAP4430_ERRORGAIN_SHIFT 16
334#define OMAP4430_ERRORGAIN_MASK BITFIELD(16, 23) 346#define OMAP4430_ERRORGAIN_MASK (0xff << 16)
335 347
336/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 348/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
337#define OMAP4430_ERROROFFSET_SHIFT 24 349#define OMAP4430_ERROROFFSET_SHIFT 24
338#define OMAP4430_ERROROFFSET_MASK BITFIELD(24, 31) 350#define OMAP4430_ERROROFFSET_MASK (0xff << 24)
339 351
340/* Used by PRM_RSTST */ 352/* Used by PRM_RSTST */
341#define OMAP4430_EXTERNAL_WARM_RST_SHIFT 5 353#define OMAP4430_EXTERNAL_WARM_RST_SHIFT 5
342#define OMAP4430_EXTERNAL_WARM_RST_MASK BITFIELD(5, 5) 354#define OMAP4430_EXTERNAL_WARM_RST_MASK (1 << 5)
343 355
344/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 356/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
345#define OMAP4430_FORCEUPDATE_SHIFT 1 357#define OMAP4430_FORCEUPDATE_SHIFT 1
346#define OMAP4430_FORCEUPDATE_MASK BITFIELD(1, 1) 358#define OMAP4430_FORCEUPDATE_MASK (1 << 1)
347 359
348/* Used by PRM_VP_CORE_VOLTAGE, PRM_VP_IVA_VOLTAGE, PRM_VP_MPU_VOLTAGE */ 360/* Used by PRM_VP_CORE_VOLTAGE, PRM_VP_IVA_VOLTAGE, PRM_VP_MPU_VOLTAGE */
349#define OMAP4430_FORCEUPDATEWAIT_SHIFT 8 361#define OMAP4430_FORCEUPDATEWAIT_SHIFT 8
350#define OMAP4430_FORCEUPDATEWAIT_MASK BITFIELD(8, 31) 362#define OMAP4430_FORCEUPDATEWAIT_MASK (0xffffff << 8)
351 363
352/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_TESLA */ 364/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_TESLA */
353#define OMAP4430_FORCEWKUP_EN_SHIFT 10 365#define OMAP4430_FORCEWKUP_EN_SHIFT 10
354#define OMAP4430_FORCEWKUP_EN_MASK BITFIELD(10, 10) 366#define OMAP4430_FORCEWKUP_EN_MASK (1 << 10)
355 367
356/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_TESLA */ 368/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_TESLA */
357#define OMAP4430_FORCEWKUP_ST_SHIFT 10 369#define OMAP4430_FORCEWKUP_ST_SHIFT 10
358#define OMAP4430_FORCEWKUP_ST_MASK BITFIELD(10, 10) 370#define OMAP4430_FORCEWKUP_ST_MASK (1 << 10)
371
372/* Used by REVISION_PRM */
373#define OMAP4430_FUNC_SHIFT 16
374#define OMAP4430_FUNC_MASK (0xfff << 16)
359 375
360/* Used by PM_GFX_PWRSTCTRL */ 376/* Used by PM_GFX_PWRSTCTRL */
361#define OMAP4430_GFX_MEM_ONSTATE_SHIFT 16 377#define OMAP4430_GFX_MEM_ONSTATE_SHIFT 16
362#define OMAP4430_GFX_MEM_ONSTATE_MASK BITFIELD(16, 17) 378#define OMAP4430_GFX_MEM_ONSTATE_MASK (0x3 << 16)
363 379
364/* Used by PM_GFX_PWRSTST */ 380/* Used by PM_GFX_PWRSTST */
365#define OMAP4430_GFX_MEM_STATEST_SHIFT 4 381#define OMAP4430_GFX_MEM_STATEST_SHIFT 4
366#define OMAP4430_GFX_MEM_STATEST_MASK BITFIELD(4, 5) 382#define OMAP4430_GFX_MEM_STATEST_MASK (0x3 << 4)
367 383
368/* Used by PRM_RSTST */ 384/* Used by PRM_RSTST */
369#define OMAP4430_GLOBAL_COLD_RST_SHIFT 0 385#define OMAP4430_GLOBAL_COLD_RST_SHIFT 0
370#define OMAP4430_GLOBAL_COLD_RST_MASK BITFIELD(0, 0) 386#define OMAP4430_GLOBAL_COLD_RST_MASK (1 << 0)
371 387
372/* Used by PRM_RSTST */ 388/* Used by PRM_RSTST */
373#define OMAP4430_GLOBAL_WARM_SW_RST_SHIFT 1 389#define OMAP4430_GLOBAL_WARM_SW_RST_SHIFT 1
374#define OMAP4430_GLOBAL_WARM_SW_RST_MASK BITFIELD(1, 1) 390#define OMAP4430_GLOBAL_WARM_SW_RST_MASK (1 << 1)
375 391
376/* Used by PRM_IO_PMCTRL */ 392/* Used by PRM_IO_PMCTRL */
377#define OMAP4430_GLOBAL_WUEN_SHIFT 16 393#define OMAP4430_GLOBAL_WUEN_SHIFT 16
378#define OMAP4430_GLOBAL_WUEN_MASK BITFIELD(16, 16) 394#define OMAP4430_GLOBAL_WUEN_MASK (1 << 16)
379 395
380/* Used by PRM_VC_CFG_I2C_MODE */ 396/* Used by PRM_VC_CFG_I2C_MODE */
381#define OMAP4430_HSMCODE_SHIFT 0 397#define OMAP4430_HSMCODE_SHIFT 0
382#define OMAP4430_HSMCODE_MASK BITFIELD(0, 2) 398#define OMAP4430_HSMCODE_MASK (0x7 << 0)
383 399
384/* Used by PRM_VC_CFG_I2C_MODE */ 400/* Used by PRM_VC_CFG_I2C_MODE */
385#define OMAP4430_HSMODEEN_SHIFT 3 401#define OMAP4430_HSMODEEN_SHIFT 3
386#define OMAP4430_HSMODEEN_MASK BITFIELD(3, 3) 402#define OMAP4430_HSMODEEN_MASK (1 << 3)
387 403
388/* Used by PRM_VC_CFG_I2C_CLK */ 404/* Used by PRM_VC_CFG_I2C_CLK */
389#define OMAP4430_HSSCLH_SHIFT 16 405#define OMAP4430_HSSCLH_SHIFT 16
390#define OMAP4430_HSSCLH_MASK BITFIELD(16, 23) 406#define OMAP4430_HSSCLH_MASK (0xff << 16)
391 407
392/* Used by PRM_VC_CFG_I2C_CLK */ 408/* Used by PRM_VC_CFG_I2C_CLK */
393#define OMAP4430_HSSCLL_SHIFT 24 409#define OMAP4430_HSSCLL_SHIFT 24
394#define OMAP4430_HSSCLL_MASK BITFIELD(24, 31) 410#define OMAP4430_HSSCLL_MASK (0xff << 24)
395 411
396/* Used by PM_IVAHD_PWRSTCTRL */ 412/* Used by PM_IVAHD_PWRSTCTRL */
397#define OMAP4430_HWA_MEM_ONSTATE_SHIFT 16 413#define OMAP4430_HWA_MEM_ONSTATE_SHIFT 16
398#define OMAP4430_HWA_MEM_ONSTATE_MASK BITFIELD(16, 17) 414#define OMAP4430_HWA_MEM_ONSTATE_MASK (0x3 << 16)
399 415
400/* Used by PM_IVAHD_PWRSTCTRL */ 416/* Used by PM_IVAHD_PWRSTCTRL */
401#define OMAP4430_HWA_MEM_RETSTATE_SHIFT 8 417#define OMAP4430_HWA_MEM_RETSTATE_SHIFT 8
402#define OMAP4430_HWA_MEM_RETSTATE_MASK BITFIELD(8, 8) 418#define OMAP4430_HWA_MEM_RETSTATE_MASK (1 << 8)
403 419
404/* Used by PM_IVAHD_PWRSTST */ 420/* Used by PM_IVAHD_PWRSTST */
405#define OMAP4430_HWA_MEM_STATEST_SHIFT 4 421#define OMAP4430_HWA_MEM_STATEST_SHIFT 4
406#define OMAP4430_HWA_MEM_STATEST_MASK BITFIELD(4, 5) 422#define OMAP4430_HWA_MEM_STATEST_MASK (0x3 << 4)
407 423
408/* Used by RM_MPU_RSTST */ 424/* Used by RM_MPU_RSTST */
409#define OMAP4430_ICECRUSHER_MPU_RST_SHIFT 1 425#define OMAP4430_ICECRUSHER_MPU_RST_SHIFT 1
410#define OMAP4430_ICECRUSHER_MPU_RST_MASK BITFIELD(1, 1) 426#define OMAP4430_ICECRUSHER_MPU_RST_MASK (1 << 1)
411 427
412/* Used by RM_DUCATI_RSTST */ 428/* Used by RM_DUCATI_RSTST */
413#define OMAP4430_ICECRUSHER_RST1ST_SHIFT 5 429#define OMAP4430_ICECRUSHER_RST1ST_SHIFT 5
414#define OMAP4430_ICECRUSHER_RST1ST_MASK BITFIELD(5, 5) 430#define OMAP4430_ICECRUSHER_RST1ST_MASK (1 << 5)
415 431
416/* Used by RM_DUCATI_RSTST */ 432/* Used by RM_DUCATI_RSTST */
417#define OMAP4430_ICECRUSHER_RST2ST_SHIFT 6 433#define OMAP4430_ICECRUSHER_RST2ST_SHIFT 6
418#define OMAP4430_ICECRUSHER_RST2ST_MASK BITFIELD(6, 6) 434#define OMAP4430_ICECRUSHER_RST2ST_MASK (1 << 6)
419 435
420/* Used by RM_IVAHD_RSTST */ 436/* Used by RM_IVAHD_RSTST */
421#define OMAP4430_ICECRUSHER_SEQ1_RST1ST_SHIFT 5 437#define OMAP4430_ICECRUSHER_SEQ1_RST1ST_SHIFT 5
422#define OMAP4430_ICECRUSHER_SEQ1_RST1ST_MASK BITFIELD(5, 5) 438#define OMAP4430_ICECRUSHER_SEQ1_RST1ST_MASK (1 << 5)
423 439
424/* Used by RM_IVAHD_RSTST */ 440/* Used by RM_IVAHD_RSTST */
425#define OMAP4430_ICECRUSHER_SEQ2_RST2ST_SHIFT 6 441#define OMAP4430_ICECRUSHER_SEQ2_RST2ST_SHIFT 6
426#define OMAP4430_ICECRUSHER_SEQ2_RST2ST_MASK BITFIELD(6, 6) 442#define OMAP4430_ICECRUSHER_SEQ2_RST2ST_MASK (1 << 6)
427 443
428/* Used by PRM_RSTST */ 444/* Used by PRM_RSTST */
429#define OMAP4430_ICEPICK_RST_SHIFT 9 445#define OMAP4430_ICEPICK_RST_SHIFT 9
430#define OMAP4430_ICEPICK_RST_MASK BITFIELD(9, 9) 446#define OMAP4430_ICEPICK_RST_MASK (1 << 9)
431 447
432/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 448/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
433#define OMAP4430_INITVDD_SHIFT 2 449#define OMAP4430_INITVDD_SHIFT 2
434#define OMAP4430_INITVDD_MASK BITFIELD(2, 2) 450#define OMAP4430_INITVDD_MASK (1 << 2)
435 451
436/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 452/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
437#define OMAP4430_INITVOLTAGE_SHIFT 8 453#define OMAP4430_INITVOLTAGE_SHIFT 8
438#define OMAP4430_INITVOLTAGE_MASK BITFIELD(8, 15) 454#define OMAP4430_INITVOLTAGE_MASK (0xff << 8)
439 455
440/* 456/*
441 * Used by PM_EMU_PWRSTST, PM_CORE_PWRSTST, PM_CAM_PWRSTST, PM_L3INIT_PWRSTST, 457 * Used by PM_ABE_PWRSTST, PM_CAM_PWRSTST, PM_CEFUSE_PWRSTST, PM_CORE_PWRSTST,
442 * PM_ABE_PWRSTST, PM_GFX_PWRSTST, PM_MPU_PWRSTST, PM_CEFUSE_PWRSTST, 458 * PM_DSS_PWRSTST, PM_EMU_PWRSTST, PM_GFX_PWRSTST, PM_IVAHD_PWRSTST,
443 * PM_DSS_PWRSTST, PM_L4PER_PWRSTST, PM_TESLA_PWRSTST, PM_IVAHD_PWRSTST 459 * PM_L3INIT_PWRSTST, PM_L4PER_PWRSTST, PM_MPU_PWRSTST, PM_TESLA_PWRSTST
444 */ 460 */
445#define OMAP4430_INTRANSITION_SHIFT 20 461#define OMAP4430_INTRANSITION_SHIFT 20
446#define OMAP4430_INTRANSITION_MASK BITFIELD(20, 20) 462#define OMAP4430_INTRANSITION_MASK (1 << 20)
447 463
448/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 464/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
449#define OMAP4430_IO_EN_SHIFT 9 465#define OMAP4430_IO_EN_SHIFT 9
450#define OMAP4430_IO_EN_MASK BITFIELD(9, 9) 466#define OMAP4430_IO_EN_MASK (1 << 9)
451 467
452/* Used by PRM_IO_PMCTRL */ 468/* Used by PRM_IO_PMCTRL */
453#define OMAP4430_IO_ON_STATUS_SHIFT 5 469#define OMAP4430_IO_ON_STATUS_SHIFT 5
454#define OMAP4430_IO_ON_STATUS_MASK BITFIELD(5, 5) 470#define OMAP4430_IO_ON_STATUS_MASK (1 << 5)
455 471
456/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 472/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
457#define OMAP4430_IO_ST_SHIFT 9 473#define OMAP4430_IO_ST_SHIFT 9
458#define OMAP4430_IO_ST_MASK BITFIELD(9, 9) 474#define OMAP4430_IO_ST_MASK (1 << 9)
459 475
460/* Used by PRM_IO_PMCTRL */ 476/* Used by PRM_IO_PMCTRL */
461#define OMAP4430_ISOCLK_OVERRIDE_SHIFT 0 477#define OMAP4430_ISOCLK_OVERRIDE_SHIFT 0
462#define OMAP4430_ISOCLK_OVERRIDE_MASK BITFIELD(0, 0) 478#define OMAP4430_ISOCLK_OVERRIDE_MASK (1 << 0)
463 479
464/* Used by PRM_IO_PMCTRL */ 480/* Used by PRM_IO_PMCTRL */
465#define OMAP4430_ISOCLK_STATUS_SHIFT 1 481#define OMAP4430_ISOCLK_STATUS_SHIFT 1
466#define OMAP4430_ISOCLK_STATUS_MASK BITFIELD(1, 1) 482#define OMAP4430_ISOCLK_STATUS_MASK (1 << 1)
467 483
468/* Used by PRM_IO_PMCTRL */ 484/* Used by PRM_IO_PMCTRL */
469#define OMAP4430_ISOOVR_EXTEND_SHIFT 4 485#define OMAP4430_ISOOVR_EXTEND_SHIFT 4
470#define OMAP4430_ISOOVR_EXTEND_MASK BITFIELD(4, 4) 486#define OMAP4430_ISOOVR_EXTEND_MASK (1 << 4)
471 487
472/* Used by PRM_IO_COUNT */ 488/* Used by PRM_IO_COUNT */
473#define OMAP4430_ISO_2_ON_TIME_SHIFT 0 489#define OMAP4430_ISO_2_ON_TIME_SHIFT 0
474#define OMAP4430_ISO_2_ON_TIME_MASK BITFIELD(0, 7) 490#define OMAP4430_ISO_2_ON_TIME_MASK (0xff << 0)
475 491
476/* Used by PM_L3INIT_PWRSTCTRL */ 492/* Used by PM_L3INIT_PWRSTCTRL */
477#define OMAP4430_L3INIT_BANK1_ONSTATE_SHIFT 16 493#define OMAP4430_L3INIT_BANK1_ONSTATE_SHIFT 16
478#define OMAP4430_L3INIT_BANK1_ONSTATE_MASK BITFIELD(16, 17) 494#define OMAP4430_L3INIT_BANK1_ONSTATE_MASK (0x3 << 16)
479 495
480/* Used by PM_L3INIT_PWRSTCTRL */ 496/* Used by PM_L3INIT_PWRSTCTRL */
481#define OMAP4430_L3INIT_BANK1_RETSTATE_SHIFT 8 497#define OMAP4430_L3INIT_BANK1_RETSTATE_SHIFT 8
482#define OMAP4430_L3INIT_BANK1_RETSTATE_MASK BITFIELD(8, 8) 498#define OMAP4430_L3INIT_BANK1_RETSTATE_MASK (1 << 8)
483 499
484/* Used by PM_L3INIT_PWRSTST */ 500/* Used by PM_L3INIT_PWRSTST */
485#define OMAP4430_L3INIT_BANK1_STATEST_SHIFT 4 501#define OMAP4430_L3INIT_BANK1_STATEST_SHIFT 4
486#define OMAP4430_L3INIT_BANK1_STATEST_MASK BITFIELD(4, 5) 502#define OMAP4430_L3INIT_BANK1_STATEST_MASK (0x3 << 4)
503
504/*
505 * Used by PM_ABE_PWRSTST, PM_CORE_PWRSTST, PM_IVAHD_PWRSTST,
506 * PM_L3INIT_PWRSTST, PM_L4PER_PWRSTST, PM_MPU_PWRSTST, PM_TESLA_PWRSTST
507 */
508#define OMAP4430_LASTPOWERSTATEENTERED_SHIFT 24
509#define OMAP4430_LASTPOWERSTATEENTERED_MASK (0x3 << 24)
487 510
488/* 511/*
489 * Used by PM_CORE_PWRSTCTRL, PM_L3INIT_PWRSTCTRL, PM_ABE_PWRSTCTRL, 512 * Used by PM_ABE_PWRSTCTRL, PM_CORE_PWRSTCTRL, PM_DSS_PWRSTCTRL,
490 * PM_MPU_PWRSTCTRL, PM_DSS_PWRSTCTRL, PM_L4PER_PWRSTCTRL, PM_TESLA_PWRSTCTRL, 513 * PM_IVAHD_PWRSTCTRL, PM_L3INIT_PWRSTCTRL, PM_L4PER_PWRSTCTRL,
491 * PM_IVAHD_PWRSTCTRL 514 * PM_MPU_PWRSTCTRL, PM_TESLA_PWRSTCTRL
492 */ 515 */
493#define OMAP4430_LOGICRETSTATE_SHIFT 2 516#define OMAP4430_LOGICRETSTATE_SHIFT 2
494#define OMAP4430_LOGICRETSTATE_MASK BITFIELD(2, 2) 517#define OMAP4430_LOGICRETSTATE_MASK (1 << 2)
495 518
496/* 519/*
497 * Used by PM_EMU_PWRSTST, PM_CORE_PWRSTST, PM_CAM_PWRSTST, PM_L3INIT_PWRSTST, 520 * Used by PM_ABE_PWRSTST, PM_CAM_PWRSTST, PM_CEFUSE_PWRSTST, PM_CORE_PWRSTST,
498 * PM_ABE_PWRSTST, PM_GFX_PWRSTST, PM_MPU_PWRSTST, PM_CEFUSE_PWRSTST, 521 * PM_DSS_PWRSTST, PM_EMU_PWRSTST, PM_GFX_PWRSTST, PM_IVAHD_PWRSTST,
499 * PM_DSS_PWRSTST, PM_L4PER_PWRSTST, PM_TESLA_PWRSTST, PM_IVAHD_PWRSTST 522 * PM_L3INIT_PWRSTST, PM_L4PER_PWRSTST, PM_MPU_PWRSTST, PM_TESLA_PWRSTST
500 */ 523 */
501#define OMAP4430_LOGICSTATEST_SHIFT 2 524#define OMAP4430_LOGICSTATEST_SHIFT 2
502#define OMAP4430_LOGICSTATEST_MASK BITFIELD(2, 2) 525#define OMAP4430_LOGICSTATEST_MASK (1 << 2)
503 526
504/* 527/*
505 * Used by RM_WKUP_GPIO1_CONTEXT, RM_WKUP_KEYBOARD_CONTEXT, 528 * Used by RM_ABE_AESS_CONTEXT, RM_ABE_DMIC_CONTEXT, RM_ABE_MCASP_CONTEXT,
506 * RM_WKUP_L4WKUP_CONTEXT, RM_WKUP_RTC_CONTEXT, RM_WKUP_SARRAM_CONTEXT,
507 * RM_WKUP_SYNCTIMER_CONTEXT, RM_WKUP_TIMER12_CONTEXT, RM_WKUP_TIMER1_CONTEXT,
508 * RM_WKUP_USIM_CONTEXT, RM_WKUP_WDT1_CONTEXT, RM_WKUP_WDT2_CONTEXT,
509 * RM_EMU_DEBUGSS_CONTEXT, RM_D2D_SAD2D_CONTEXT, RM_D2D_SAD2D_FW_CONTEXT,
510 * RM_DUCATI_DUCATI_CONTEXT, RM_L3INSTR_L3_3_CONTEXT,
511 * RM_L3INSTR_L3_INSTR_CONTEXT, RM_L3INSTR_OCP_WP1_CONTEXT,
512 * RM_L3_1_L3_1_CONTEXT, RM_L3_2_L3_2_CONTEXT, RM_L3_2_OCMC_RAM_CONTEXT,
513 * RM_L4CFG_L4_CFG_CONTEXT, RM_L4CFG_SAR_ROM_CONTEXT, RM_MEMIF_DLL_CONTEXT,
514 * RM_MEMIF_DLL_H_CONTEXT, RM_MEMIF_DMM_CONTEXT, RM_MEMIF_EMIF_FW_CONTEXT,
515 * RM_CAM_FDIF_CONTEXT, RM_CAM_ISS_CONTEXT, RM_L3INIT_CCPTX_CONTEXT,
516 * RM_L3INIT_EMAC_CONTEXT, RM_L3INIT_P1500_CONTEXT, RM_L3INIT_PCIESS_CONTEXT,
517 * RM_L3INIT_SATA_CONTEXT, RM_L3INIT_TPPSS_CONTEXT, RM_L3INIT_UNIPRO1_CONTEXT,
518 * RM_L3INIT_USBPHYOCP2SCP_CONTEXT, RM_L3INIT_XHPI_CONTEXT,
519 * RM_ABE_AESS_CONTEXT, RM_ABE_DMIC_CONTEXT, RM_ABE_MCASP_CONTEXT,
520 * RM_ABE_MCBSP1_CONTEXT, RM_ABE_MCBSP2_CONTEXT, RM_ABE_MCBSP3_CONTEXT, 529 * RM_ABE_MCBSP1_CONTEXT, RM_ABE_MCBSP2_CONTEXT, RM_ABE_MCBSP3_CONTEXT,
521 * RM_ABE_PDM_CONTEXT, RM_ABE_SLIMBUS_CONTEXT, RM_ABE_TIMER5_CONTEXT, 530 * RM_ABE_PDM_CONTEXT, RM_ABE_SLIMBUS_CONTEXT, RM_ABE_TIMER5_CONTEXT,
522 * RM_ABE_TIMER6_CONTEXT, RM_ABE_TIMER7_CONTEXT, RM_ABE_TIMER8_CONTEXT, 531 * RM_ABE_TIMER6_CONTEXT, RM_ABE_TIMER7_CONTEXT, RM_ABE_TIMER8_CONTEXT,
523 * RM_ABE_WDT3_CONTEXT, RM_GFX_GFX_CONTEXT, RM_MPU_MPU_CONTEXT, 532 * RM_ABE_WDT3_CONTEXT, RM_ALWON_MDMINTC_CONTEXT, RM_ALWON_SR_CORE_CONTEXT,
524 * RM_CEFUSE_CEFUSE_CONTEXT, RM_ALWON_MDMINTC_CONTEXT, 533 * RM_ALWON_SR_IVA_CONTEXT, RM_ALWON_SR_MPU_CONTEXT, RM_CAM_FDIF_CONTEXT,
525 * RM_ALWON_SR_CORE_CONTEXT, RM_ALWON_SR_IVA_CONTEXT, RM_ALWON_SR_MPU_CONTEXT, 534 * RM_CAM_ISS_CONTEXT, RM_CEFUSE_CEFUSE_CONTEXT, RM_D2D_SAD2D_CONTEXT,
526 * RM_DSS_DEISS_CONTEXT, RM_DSS_DSS_CONTEXT, RM_L4PER_ADC_CONTEXT, 535 * RM_D2D_SAD2D_FW_CONTEXT, RM_DSS_DEISS_CONTEXT, RM_DSS_DSS_CONTEXT,
527 * RM_L4PER_DMTIMER10_CONTEXT, RM_L4PER_DMTIMER11_CONTEXT, 536 * RM_DUCATI_DUCATI_CONTEXT, RM_EMU_DEBUGSS_CONTEXT, RM_GFX_GFX_CONTEXT,
528 * RM_L4PER_DMTIMER2_CONTEXT, RM_L4PER_DMTIMER3_CONTEXT, 537 * RM_IVAHD_IVAHD_CONTEXT, RM_IVAHD_SL2_CONTEXT, RM_L3INIT_CCPTX_CONTEXT,
529 * RM_L4PER_DMTIMER4_CONTEXT, RM_L4PER_DMTIMER9_CONTEXT, RM_L4PER_ELM_CONTEXT, 538 * RM_L3INIT_EMAC_CONTEXT, RM_L3INIT_P1500_CONTEXT, RM_L3INIT_PCIESS_CONTEXT,
530 * RM_L4PER_HDQ1W_CONTEXT, RM_L4PER_HECC1_CONTEXT, RM_L4PER_HECC2_CONTEXT, 539 * RM_L3INIT_SATA_CONTEXT, RM_L3INIT_TPPSS_CONTEXT, RM_L3INIT_UNIPRO1_CONTEXT,
531 * RM_L4PER_I2C2_CONTEXT, RM_L4PER_I2C3_CONTEXT, RM_L4PER_I2C4_CONTEXT, 540 * RM_L3INIT_USBPHYOCP2SCP_CONTEXT, RM_L3INIT_XHPI_CONTEXT,
532 * RM_L4PER_I2C5_CONTEXT, RM_L4PER_L4_PER_CONTEXT, RM_L4PER_MCASP2_CONTEXT, 541 * RM_L3INSTR_L3_3_CONTEXT, RM_L3INSTR_L3_INSTR_CONTEXT,
533 * RM_L4PER_MCASP3_CONTEXT, RM_L4PER_MCBSP4_CONTEXT, RM_L4PER_MCSPI1_CONTEXT, 542 * RM_L3INSTR_OCP_WP1_CONTEXT, RM_L3_1_L3_1_CONTEXT, RM_L3_2_L3_2_CONTEXT,
534 * RM_L4PER_MCSPI2_CONTEXT, RM_L4PER_MCSPI3_CONTEXT, RM_L4PER_MCSPI4_CONTEXT, 543 * RM_L3_2_OCMC_RAM_CONTEXT, RM_L4CFG_L4_CFG_CONTEXT, RM_L4CFG_SAR_ROM_CONTEXT,
535 * RM_L4PER_MGATE_CONTEXT, RM_L4PER_MMCSD3_CONTEXT, RM_L4PER_MMCSD4_CONTEXT, 544 * RM_L4PER_ADC_CONTEXT, RM_L4PER_DMTIMER10_CONTEXT,
536 * RM_L4PER_MMCSD5_CONTEXT, RM_L4PER_MSPROHG_CONTEXT, 545 * RM_L4PER_DMTIMER11_CONTEXT, RM_L4PER_DMTIMER2_CONTEXT,
537 * RM_L4PER_SLIMBUS2_CONTEXT, RM_L4SEC_PKAEIP29_CONTEXT, 546 * RM_L4PER_DMTIMER3_CONTEXT, RM_L4PER_DMTIMER4_CONTEXT,
538 * RM_TESLA_TESLA_CONTEXT, RM_IVAHD_IVAHD_CONTEXT, RM_IVAHD_SL2_CONTEXT 547 * RM_L4PER_DMTIMER9_CONTEXT, RM_L4PER_ELM_CONTEXT, RM_L4PER_HDQ1W_CONTEXT,
548 * RM_L4PER_HECC1_CONTEXT, RM_L4PER_HECC2_CONTEXT, RM_L4PER_I2C2_CONTEXT,
549 * RM_L4PER_I2C3_CONTEXT, RM_L4PER_I2C4_CONTEXT, RM_L4PER_I2C5_CONTEXT,
550 * RM_L4PER_L4_PER_CONTEXT, RM_L4PER_MCASP2_CONTEXT, RM_L4PER_MCASP3_CONTEXT,
551 * RM_L4PER_MCBSP4_CONTEXT, RM_L4PER_MCSPI1_CONTEXT, RM_L4PER_MCSPI2_CONTEXT,
552 * RM_L4PER_MCSPI3_CONTEXT, RM_L4PER_MCSPI4_CONTEXT, RM_L4PER_MGATE_CONTEXT,
553 * RM_L4PER_MMCSD3_CONTEXT, RM_L4PER_MMCSD4_CONTEXT, RM_L4PER_MMCSD5_CONTEXT,
554 * RM_L4PER_MSPROHG_CONTEXT, RM_L4PER_SLIMBUS2_CONTEXT,
555 * RM_L4SEC_PKAEIP29_CONTEXT, RM_MEMIF_DLL_CONTEXT, RM_MEMIF_DLL_H_CONTEXT,
556 * RM_MEMIF_DMM_CONTEXT, RM_MEMIF_EMIF_1_CONTEXT, RM_MEMIF_EMIF_2_CONTEXT,
557 * RM_MEMIF_EMIF_FW_CONTEXT, RM_MPU_MPU_CONTEXT, RM_TESLA_TESLA_CONTEXT,
558 * RM_WKUP_GPIO1_CONTEXT, RM_WKUP_KEYBOARD_CONTEXT, RM_WKUP_L4WKUP_CONTEXT,
559 * RM_WKUP_RTC_CONTEXT, RM_WKUP_SARRAM_CONTEXT, RM_WKUP_SYNCTIMER_CONTEXT,
560 * RM_WKUP_TIMER12_CONTEXT, RM_WKUP_TIMER1_CONTEXT, RM_WKUP_USIM_CONTEXT,
561 * RM_WKUP_WDT1_CONTEXT, RM_WKUP_WDT2_CONTEXT
539 */ 562 */
540#define OMAP4430_LOSTCONTEXT_DFF_SHIFT 0 563#define OMAP4430_LOSTCONTEXT_DFF_SHIFT 0
541#define OMAP4430_LOSTCONTEXT_DFF_MASK BITFIELD(0, 0) 564#define OMAP4430_LOSTCONTEXT_DFF_MASK (1 << 0)
542 565
543/* 566/*
544 * Used by RM_D2D_MODEM_ICR_CONTEXT, RM_D2D_SAD2D_CONTEXT, 567 * Used by RM_D2D_MODEM_ICR_CONTEXT, RM_D2D_SAD2D_CONTEXT,
545 * RM_D2D_SAD2D_FW_CONTEXT, RM_DUCATI_DUCATI_CONTEXT, RM_L3INSTR_L3_3_CONTEXT, 568 * RM_D2D_SAD2D_FW_CONTEXT, RM_DSS_DSS_CONTEXT, RM_DUCATI_DUCATI_CONTEXT,
569 * RM_L3INIT_HSI_CONTEXT, RM_L3INIT_MMC1_CONTEXT, RM_L3INIT_MMC2_CONTEXT,
570 * RM_L3INIT_MMC6_CONTEXT, RM_L3INIT_USB_HOST_CONTEXT,
571 * RM_L3INIT_USB_HOST_FS_CONTEXT, RM_L3INIT_USB_OTG_CONTEXT,
572 * RM_L3INIT_USB_TLL_CONTEXT, RM_L3INSTR_L3_3_CONTEXT,
546 * RM_L3INSTR_OCP_WP1_CONTEXT, RM_L3_1_L3_1_CONTEXT, RM_L3_2_GPMC_CONTEXT, 573 * RM_L3INSTR_OCP_WP1_CONTEXT, RM_L3_1_L3_1_CONTEXT, RM_L3_2_GPMC_CONTEXT,
547 * RM_L3_2_L3_2_CONTEXT, RM_L4CFG_HW_SEM_CONTEXT, RM_L4CFG_L4_CFG_CONTEXT, 574 * RM_L3_2_L3_2_CONTEXT, RM_L4CFG_HW_SEM_CONTEXT, RM_L4CFG_L4_CFG_CONTEXT,
548 * RM_L4CFG_MAILBOX_CONTEXT, RM_MEMIF_DMM_CONTEXT, RM_MEMIF_EMIF_1_CONTEXT, 575 * RM_L4CFG_MAILBOX_CONTEXT, RM_L4PER_GPIO2_CONTEXT, RM_L4PER_GPIO3_CONTEXT,
549 * RM_MEMIF_EMIF_2_CONTEXT, RM_MEMIF_EMIF_FW_CONTEXT, RM_MEMIF_EMIF_H1_CONTEXT, 576 * RM_L4PER_GPIO4_CONTEXT, RM_L4PER_GPIO5_CONTEXT, RM_L4PER_GPIO6_CONTEXT,
550 * RM_MEMIF_EMIF_H2_CONTEXT, RM_SDMA_SDMA_CONTEXT, RM_L3INIT_HSI_CONTEXT, 577 * RM_L4PER_I2C1_CONTEXT, RM_L4PER_L4_PER_CONTEXT, RM_L4PER_UART1_CONTEXT,
551 * RM_L3INIT_MMC1_CONTEXT, RM_L3INIT_MMC2_CONTEXT, RM_L3INIT_MMC6_CONTEXT, 578 * RM_L4PER_UART2_CONTEXT, RM_L4PER_UART3_CONTEXT, RM_L4PER_UART4_CONTEXT,
552 * RM_L3INIT_USB_HOST_CONTEXT, RM_L3INIT_USB_HOST_FS_CONTEXT, 579 * RM_L4SEC_AES1_CONTEXT, RM_L4SEC_AES2_CONTEXT, RM_L4SEC_CRYPTODMA_CONTEXT,
553 * RM_L3INIT_USB_OTG_CONTEXT, RM_L3INIT_USB_TLL_CONTEXT, RM_DSS_DSS_CONTEXT, 580 * RM_L4SEC_DES3DES_CONTEXT, RM_L4SEC_RNG_CONTEXT, RM_L4SEC_SHA2MD51_CONTEXT,
554 * RM_L4PER_GPIO2_CONTEXT, RM_L4PER_GPIO3_CONTEXT, RM_L4PER_GPIO4_CONTEXT, 581 * RM_MEMIF_DMM_CONTEXT, RM_MEMIF_EMIF_1_CONTEXT, RM_MEMIF_EMIF_2_CONTEXT,
555 * RM_L4PER_GPIO5_CONTEXT, RM_L4PER_GPIO6_CONTEXT, RM_L4PER_I2C1_CONTEXT, 582 * RM_MEMIF_EMIF_FW_CONTEXT, RM_MEMIF_EMIF_H1_CONTEXT,
556 * RM_L4PER_L4_PER_CONTEXT, RM_L4PER_UART1_CONTEXT, RM_L4PER_UART2_CONTEXT, 583 * RM_MEMIF_EMIF_H2_CONTEXT, RM_SDMA_SDMA_CONTEXT, RM_TESLA_TESLA_CONTEXT
557 * RM_L4PER_UART3_CONTEXT, RM_L4PER_UART4_CONTEXT, RM_L4SEC_AES1_CONTEXT,
558 * RM_L4SEC_AES2_CONTEXT, RM_L4SEC_CRYPTODMA_CONTEXT, RM_L4SEC_DES3DES_CONTEXT,
559 * RM_L4SEC_RNG_CONTEXT, RM_L4SEC_SHA2MD51_CONTEXT, RM_TESLA_TESLA_CONTEXT
560 */ 584 */
561#define OMAP4430_LOSTCONTEXT_RFF_SHIFT 1 585#define OMAP4430_LOSTCONTEXT_RFF_SHIFT 1
562#define OMAP4430_LOSTCONTEXT_RFF_MASK BITFIELD(1, 1) 586#define OMAP4430_LOSTCONTEXT_RFF_MASK (1 << 1)
563 587
564/* Used by RM_ABE_AESS_CONTEXT */ 588/* Used by RM_ABE_AESS_CONTEXT */
565#define OMAP4430_LOSTMEM_AESSMEM_SHIFT 8 589#define OMAP4430_LOSTMEM_AESSMEM_SHIFT 8
566#define OMAP4430_LOSTMEM_AESSMEM_MASK BITFIELD(8, 8) 590#define OMAP4430_LOSTMEM_AESSMEM_MASK (1 << 8)
567 591
568/* Used by RM_CAM_FDIF_CONTEXT, RM_CAM_ISS_CONTEXT */ 592/* Used by RM_CAM_FDIF_CONTEXT, RM_CAM_ISS_CONTEXT */
569#define OMAP4430_LOSTMEM_CAM_MEM_SHIFT 8 593#define OMAP4430_LOSTMEM_CAM_MEM_SHIFT 8
570#define OMAP4430_LOSTMEM_CAM_MEM_MASK BITFIELD(8, 8) 594#define OMAP4430_LOSTMEM_CAM_MEM_MASK (1 << 8)
571 595
572/* Used by RM_L3INSTR_OCP_WP1_CONTEXT */ 596/* Used by RM_L3INSTR_OCP_WP1_CONTEXT */
573#define OMAP4430_LOSTMEM_CORE_NRET_BANK_SHIFT 8 597#define OMAP4430_LOSTMEM_CORE_NRET_BANK_SHIFT 8
574#define OMAP4430_LOSTMEM_CORE_NRET_BANK_MASK BITFIELD(8, 8) 598#define OMAP4430_LOSTMEM_CORE_NRET_BANK_MASK (1 << 8)
575 599
576/* Renamed from LOSTMEM_CORE_NRET_BANK Used by RM_MEMIF_DMM_CONTEXT */ 600/* Renamed from LOSTMEM_CORE_NRET_BANK Used by RM_MEMIF_DMM_CONTEXT */
577#define OMAP4430_LOSTMEM_CORE_NRET_BANK_9_9_SHIFT 9 601#define OMAP4430_LOSTMEM_CORE_NRET_BANK_9_9_SHIFT 9
578#define OMAP4430_LOSTMEM_CORE_NRET_BANK_9_9_MASK BITFIELD(9, 9) 602#define OMAP4430_LOSTMEM_CORE_NRET_BANK_9_9_MASK (1 << 9)
579 603
580/* Used by RM_L3_2_OCMC_RAM_CONTEXT */ 604/* Used by RM_L3_2_OCMC_RAM_CONTEXT */
581#define OMAP4430_LOSTMEM_CORE_OCMRAM_SHIFT 8 605#define OMAP4430_LOSTMEM_CORE_OCMRAM_SHIFT 8
582#define OMAP4430_LOSTMEM_CORE_OCMRAM_MASK BITFIELD(8, 8) 606#define OMAP4430_LOSTMEM_CORE_OCMRAM_MASK (1 << 8)
583 607
584/* 608/*
585 * Used by RM_D2D_MODEM_ICR_CONTEXT, RM_MEMIF_DMM_CONTEXT, 609 * Used by RM_D2D_MODEM_ICR_CONTEXT, RM_MEMIF_DMM_CONTEXT,
586 * RM_SDMA_SDMA_CONTEXT 610 * RM_SDMA_SDMA_CONTEXT
587 */ 611 */
588#define OMAP4430_LOSTMEM_CORE_OTHER_BANK_SHIFT 8 612#define OMAP4430_LOSTMEM_CORE_OTHER_BANK_SHIFT 8
589#define OMAP4430_LOSTMEM_CORE_OTHER_BANK_MASK BITFIELD(8, 8) 613#define OMAP4430_LOSTMEM_CORE_OTHER_BANK_MASK (1 << 8)
590 614
591/* Used by RM_DSS_DEISS_CONTEXT, RM_DSS_DSS_CONTEXT */ 615/* Used by RM_DSS_DEISS_CONTEXT, RM_DSS_DSS_CONTEXT */
592#define OMAP4430_LOSTMEM_DSS_MEM_SHIFT 8 616#define OMAP4430_LOSTMEM_DSS_MEM_SHIFT 8
593#define OMAP4430_LOSTMEM_DSS_MEM_MASK BITFIELD(8, 8) 617#define OMAP4430_LOSTMEM_DSS_MEM_MASK (1 << 8)
594 618
595/* Used by RM_DUCATI_DUCATI_CONTEXT */ 619/* Used by RM_DUCATI_DUCATI_CONTEXT */
596#define OMAP4430_LOSTMEM_DUCATI_L2RAM_SHIFT 9 620#define OMAP4430_LOSTMEM_DUCATI_L2RAM_SHIFT 9
597#define OMAP4430_LOSTMEM_DUCATI_L2RAM_MASK BITFIELD(9, 9) 621#define OMAP4430_LOSTMEM_DUCATI_L2RAM_MASK (1 << 9)
598 622
599/* Used by RM_DUCATI_DUCATI_CONTEXT */ 623/* Used by RM_DUCATI_DUCATI_CONTEXT */
600#define OMAP4430_LOSTMEM_DUCATI_UNICACHE_SHIFT 8 624#define OMAP4430_LOSTMEM_DUCATI_UNICACHE_SHIFT 8
601#define OMAP4430_LOSTMEM_DUCATI_UNICACHE_MASK BITFIELD(8, 8) 625#define OMAP4430_LOSTMEM_DUCATI_UNICACHE_MASK (1 << 8)
602 626
603/* Used by RM_EMU_DEBUGSS_CONTEXT */ 627/* Used by RM_EMU_DEBUGSS_CONTEXT */
604#define OMAP4430_LOSTMEM_EMU_BANK_SHIFT 8 628#define OMAP4430_LOSTMEM_EMU_BANK_SHIFT 8
605#define OMAP4430_LOSTMEM_EMU_BANK_MASK BITFIELD(8, 8) 629#define OMAP4430_LOSTMEM_EMU_BANK_MASK (1 << 8)
606 630
607/* Used by RM_GFX_GFX_CONTEXT */ 631/* Used by RM_GFX_GFX_CONTEXT */
608#define OMAP4430_LOSTMEM_GFX_MEM_SHIFT 8 632#define OMAP4430_LOSTMEM_GFX_MEM_SHIFT 8
609#define OMAP4430_LOSTMEM_GFX_MEM_MASK BITFIELD(8, 8) 633#define OMAP4430_LOSTMEM_GFX_MEM_MASK (1 << 8)
610 634
611/* Used by RM_IVAHD_IVAHD_CONTEXT */ 635/* Used by RM_IVAHD_IVAHD_CONTEXT */
612#define OMAP4430_LOSTMEM_HWA_MEM_SHIFT 10 636#define OMAP4430_LOSTMEM_HWA_MEM_SHIFT 10
613#define OMAP4430_LOSTMEM_HWA_MEM_MASK BITFIELD(10, 10) 637#define OMAP4430_LOSTMEM_HWA_MEM_MASK (1 << 10)
614 638
615/* 639/*
616 * Used by RM_L3INIT_CCPTX_CONTEXT, RM_L3INIT_EMAC_CONTEXT, 640 * Used by RM_L3INIT_CCPTX_CONTEXT, RM_L3INIT_EMAC_CONTEXT,
@@ -620,19 +644,19 @@
620 * RM_L3INIT_USB_OTG_CONTEXT, RM_L3INIT_XHPI_CONTEXT 644 * RM_L3INIT_USB_OTG_CONTEXT, RM_L3INIT_XHPI_CONTEXT
621 */ 645 */
622#define OMAP4430_LOSTMEM_L3INIT_BANK1_SHIFT 8 646#define OMAP4430_LOSTMEM_L3INIT_BANK1_SHIFT 8
623#define OMAP4430_LOSTMEM_L3INIT_BANK1_MASK BITFIELD(8, 8) 647#define OMAP4430_LOSTMEM_L3INIT_BANK1_MASK (1 << 8)
624 648
625/* Used by RM_MPU_MPU_CONTEXT */ 649/* Used by RM_MPU_MPU_CONTEXT */
626#define OMAP4430_LOSTMEM_MPU_L1_SHIFT 8 650#define OMAP4430_LOSTMEM_MPU_L1_SHIFT 8
627#define OMAP4430_LOSTMEM_MPU_L1_MASK BITFIELD(8, 8) 651#define OMAP4430_LOSTMEM_MPU_L1_MASK (1 << 8)
628 652
629/* Used by RM_MPU_MPU_CONTEXT */ 653/* Used by RM_MPU_MPU_CONTEXT */
630#define OMAP4430_LOSTMEM_MPU_L2_SHIFT 9 654#define OMAP4430_LOSTMEM_MPU_L2_SHIFT 9
631#define OMAP4430_LOSTMEM_MPU_L2_MASK BITFIELD(9, 9) 655#define OMAP4430_LOSTMEM_MPU_L2_MASK (1 << 9)
632 656
633/* Used by RM_MPU_MPU_CONTEXT */ 657/* Used by RM_MPU_MPU_CONTEXT */
634#define OMAP4430_LOSTMEM_MPU_RAM_SHIFT 10 658#define OMAP4430_LOSTMEM_MPU_RAM_SHIFT 10
635#define OMAP4430_LOSTMEM_MPU_RAM_MASK BITFIELD(10, 10) 659#define OMAP4430_LOSTMEM_MPU_RAM_MASK (1 << 10)
636 660
637/* 661/*
638 * Used by RM_L4PER_HECC1_CONTEXT, RM_L4PER_HECC2_CONTEXT, 662 * Used by RM_L4PER_HECC1_CONTEXT, RM_L4PER_HECC2_CONTEXT,
@@ -640,14 +664,14 @@
640 * RM_L4PER_MMCSD5_CONTEXT, RM_L4PER_SLIMBUS2_CONTEXT, RM_L4SEC_PKAEIP29_CONTEXT 664 * RM_L4PER_MMCSD5_CONTEXT, RM_L4PER_SLIMBUS2_CONTEXT, RM_L4SEC_PKAEIP29_CONTEXT
641 */ 665 */
642#define OMAP4430_LOSTMEM_NONRETAINED_BANK_SHIFT 8 666#define OMAP4430_LOSTMEM_NONRETAINED_BANK_SHIFT 8
643#define OMAP4430_LOSTMEM_NONRETAINED_BANK_MASK BITFIELD(8, 8) 667#define OMAP4430_LOSTMEM_NONRETAINED_BANK_MASK (1 << 8)
644 668
645/* 669/*
646 * Used by RM_ABE_DMIC_CONTEXT, RM_ABE_MCBSP1_CONTEXT, RM_ABE_MCBSP2_CONTEXT, 670 * Used by RM_ABE_DMIC_CONTEXT, RM_ABE_MCBSP1_CONTEXT, RM_ABE_MCBSP2_CONTEXT,
647 * RM_ABE_MCBSP3_CONTEXT, RM_ABE_PDM_CONTEXT, RM_ABE_SLIMBUS_CONTEXT 671 * RM_ABE_MCBSP3_CONTEXT, RM_ABE_PDM_CONTEXT, RM_ABE_SLIMBUS_CONTEXT
648 */ 672 */
649#define OMAP4430_LOSTMEM_PERIHPMEM_SHIFT 8 673#define OMAP4430_LOSTMEM_PERIHPMEM_SHIFT 8
650#define OMAP4430_LOSTMEM_PERIHPMEM_MASK BITFIELD(8, 8) 674#define OMAP4430_LOSTMEM_PERIHPMEM_MASK (1 << 8)
651 675
652/* 676/*
653 * Used by RM_L4PER_MSPROHG_CONTEXT, RM_L4PER_UART1_CONTEXT, 677 * Used by RM_L4PER_MSPROHG_CONTEXT, RM_L4PER_UART1_CONTEXT,
@@ -655,245 +679,237 @@
655 * RM_L4SEC_CRYPTODMA_CONTEXT 679 * RM_L4SEC_CRYPTODMA_CONTEXT
656 */ 680 */
657#define OMAP4430_LOSTMEM_RETAINED_BANK_SHIFT 8 681#define OMAP4430_LOSTMEM_RETAINED_BANK_SHIFT 8
658#define OMAP4430_LOSTMEM_RETAINED_BANK_MASK BITFIELD(8, 8) 682#define OMAP4430_LOSTMEM_RETAINED_BANK_MASK (1 << 8)
659 683
660/* Used by RM_IVAHD_SL2_CONTEXT */ 684/* Used by RM_IVAHD_SL2_CONTEXT */
661#define OMAP4430_LOSTMEM_SL2_MEM_SHIFT 8 685#define OMAP4430_LOSTMEM_SL2_MEM_SHIFT 8
662#define OMAP4430_LOSTMEM_SL2_MEM_MASK BITFIELD(8, 8) 686#define OMAP4430_LOSTMEM_SL2_MEM_MASK (1 << 8)
663 687
664/* Used by RM_IVAHD_IVAHD_CONTEXT */ 688/* Used by RM_IVAHD_IVAHD_CONTEXT */
665#define OMAP4430_LOSTMEM_TCM1_MEM_SHIFT 8 689#define OMAP4430_LOSTMEM_TCM1_MEM_SHIFT 8
666#define OMAP4430_LOSTMEM_TCM1_MEM_MASK BITFIELD(8, 8) 690#define OMAP4430_LOSTMEM_TCM1_MEM_MASK (1 << 8)
667 691
668/* Used by RM_IVAHD_IVAHD_CONTEXT */ 692/* Used by RM_IVAHD_IVAHD_CONTEXT */
669#define OMAP4430_LOSTMEM_TCM2_MEM_SHIFT 9 693#define OMAP4430_LOSTMEM_TCM2_MEM_SHIFT 9
670#define OMAP4430_LOSTMEM_TCM2_MEM_MASK BITFIELD(9, 9) 694#define OMAP4430_LOSTMEM_TCM2_MEM_MASK (1 << 9)
671 695
672/* Used by RM_TESLA_TESLA_CONTEXT */ 696/* Used by RM_TESLA_TESLA_CONTEXT */
673#define OMAP4430_LOSTMEM_TESLA_EDMA_SHIFT 10 697#define OMAP4430_LOSTMEM_TESLA_EDMA_SHIFT 10
674#define OMAP4430_LOSTMEM_TESLA_EDMA_MASK BITFIELD(10, 10) 698#define OMAP4430_LOSTMEM_TESLA_EDMA_MASK (1 << 10)
675 699
676/* Used by RM_TESLA_TESLA_CONTEXT */ 700/* Used by RM_TESLA_TESLA_CONTEXT */
677#define OMAP4430_LOSTMEM_TESLA_L1_SHIFT 8 701#define OMAP4430_LOSTMEM_TESLA_L1_SHIFT 8
678#define OMAP4430_LOSTMEM_TESLA_L1_MASK BITFIELD(8, 8) 702#define OMAP4430_LOSTMEM_TESLA_L1_MASK (1 << 8)
679 703
680/* Used by RM_TESLA_TESLA_CONTEXT */ 704/* Used by RM_TESLA_TESLA_CONTEXT */
681#define OMAP4430_LOSTMEM_TESLA_L2_SHIFT 9 705#define OMAP4430_LOSTMEM_TESLA_L2_SHIFT 9
682#define OMAP4430_LOSTMEM_TESLA_L2_MASK BITFIELD(9, 9) 706#define OMAP4430_LOSTMEM_TESLA_L2_MASK (1 << 9)
683 707
684/* Used by RM_WKUP_SARRAM_CONTEXT */ 708/* Used by RM_WKUP_SARRAM_CONTEXT */
685#define OMAP4430_LOSTMEM_WKUP_BANK_SHIFT 8 709#define OMAP4430_LOSTMEM_WKUP_BANK_SHIFT 8
686#define OMAP4430_LOSTMEM_WKUP_BANK_MASK BITFIELD(8, 8) 710#define OMAP4430_LOSTMEM_WKUP_BANK_MASK (1 << 8)
687 711
688/* 712/*
689 * Used by PM_CORE_PWRSTCTRL, PM_CAM_PWRSTCTRL, PM_L3INIT_PWRSTCTRL, 713 * Used by PM_ABE_PWRSTCTRL, PM_CAM_PWRSTCTRL, PM_CEFUSE_PWRSTCTRL,
690 * PM_ABE_PWRSTCTRL, PM_GFX_PWRSTCTRL, PM_MPU_PWRSTCTRL, PM_CEFUSE_PWRSTCTRL, 714 * PM_CORE_PWRSTCTRL, PM_DSS_PWRSTCTRL, PM_GFX_PWRSTCTRL, PM_IVAHD_PWRSTCTRL,
691 * PM_DSS_PWRSTCTRL, PM_L4PER_PWRSTCTRL, PM_TESLA_PWRSTCTRL, PM_IVAHD_PWRSTCTRL 715 * PM_L3INIT_PWRSTCTRL, PM_L4PER_PWRSTCTRL, PM_MPU_PWRSTCTRL, PM_TESLA_PWRSTCTRL
692 */ 716 */
693#define OMAP4430_LOWPOWERSTATECHANGE_SHIFT 4 717#define OMAP4430_LOWPOWERSTATECHANGE_SHIFT 4
694#define OMAP4430_LOWPOWERSTATECHANGE_MASK BITFIELD(4, 4) 718#define OMAP4430_LOWPOWERSTATECHANGE_MASK (1 << 4)
695
696/* Used by PM_CORE_PWRSTCTRL */
697#define OMAP4430_MEMORYCHANGE_SHIFT 3
698#define OMAP4430_MEMORYCHANGE_MASK BITFIELD(3, 3)
699 719
700/* Used by PRM_MODEM_IF_CTRL */ 720/* Used by PRM_MODEM_IF_CTRL */
701#define OMAP4430_MODEM_READY_SHIFT 1 721#define OMAP4430_MODEM_READY_SHIFT 1
702#define OMAP4430_MODEM_READY_MASK BITFIELD(1, 1) 722#define OMAP4430_MODEM_READY_MASK (1 << 1)
703 723
704/* Used by PRM_MODEM_IF_CTRL */ 724/* Used by PRM_MODEM_IF_CTRL */
705#define OMAP4430_MODEM_SHUTDOWN_IRQ_SHIFT 9 725#define OMAP4430_MODEM_SHUTDOWN_IRQ_SHIFT 9
706#define OMAP4430_MODEM_SHUTDOWN_IRQ_MASK BITFIELD(9, 9) 726#define OMAP4430_MODEM_SHUTDOWN_IRQ_MASK (1 << 9)
707 727
708/* Used by PRM_MODEM_IF_CTRL */ 728/* Used by PRM_MODEM_IF_CTRL */
709#define OMAP4430_MODEM_SLEEP_ST_SHIFT 16 729#define OMAP4430_MODEM_SLEEP_ST_SHIFT 16
710#define OMAP4430_MODEM_SLEEP_ST_MASK BITFIELD(16, 16) 730#define OMAP4430_MODEM_SLEEP_ST_MASK (1 << 16)
711 731
712/* Used by PRM_MODEM_IF_CTRL */ 732/* Used by PRM_MODEM_IF_CTRL */
713#define OMAP4430_MODEM_WAKE_IRQ_SHIFT 8 733#define OMAP4430_MODEM_WAKE_IRQ_SHIFT 8
714#define OMAP4430_MODEM_WAKE_IRQ_MASK BITFIELD(8, 8) 734#define OMAP4430_MODEM_WAKE_IRQ_MASK (1 << 8)
715 735
716/* Used by PM_MPU_PWRSTCTRL */ 736/* Used by PM_MPU_PWRSTCTRL */
717#define OMAP4430_MPU_L1_ONSTATE_SHIFT 16 737#define OMAP4430_MPU_L1_ONSTATE_SHIFT 16
718#define OMAP4430_MPU_L1_ONSTATE_MASK BITFIELD(16, 17) 738#define OMAP4430_MPU_L1_ONSTATE_MASK (0x3 << 16)
719 739
720/* Used by PM_MPU_PWRSTCTRL */ 740/* Used by PM_MPU_PWRSTCTRL */
721#define OMAP4430_MPU_L1_RETSTATE_SHIFT 8 741#define OMAP4430_MPU_L1_RETSTATE_SHIFT 8
722#define OMAP4430_MPU_L1_RETSTATE_MASK BITFIELD(8, 8) 742#define OMAP4430_MPU_L1_RETSTATE_MASK (1 << 8)
723 743
724/* Used by PM_MPU_PWRSTST */ 744/* Used by PM_MPU_PWRSTST */
725#define OMAP4430_MPU_L1_STATEST_SHIFT 4 745#define OMAP4430_MPU_L1_STATEST_SHIFT 4
726#define OMAP4430_MPU_L1_STATEST_MASK BITFIELD(4, 5) 746#define OMAP4430_MPU_L1_STATEST_MASK (0x3 << 4)
727 747
728/* Used by PM_MPU_PWRSTCTRL */ 748/* Used by PM_MPU_PWRSTCTRL */
729#define OMAP4430_MPU_L2_ONSTATE_SHIFT 18 749#define OMAP4430_MPU_L2_ONSTATE_SHIFT 18
730#define OMAP4430_MPU_L2_ONSTATE_MASK BITFIELD(18, 19) 750#define OMAP4430_MPU_L2_ONSTATE_MASK (0x3 << 18)
731 751
732/* Used by PM_MPU_PWRSTCTRL */ 752/* Used by PM_MPU_PWRSTCTRL */
733#define OMAP4430_MPU_L2_RETSTATE_SHIFT 9 753#define OMAP4430_MPU_L2_RETSTATE_SHIFT 9
734#define OMAP4430_MPU_L2_RETSTATE_MASK BITFIELD(9, 9) 754#define OMAP4430_MPU_L2_RETSTATE_MASK (1 << 9)
735 755
736/* Used by PM_MPU_PWRSTST */ 756/* Used by PM_MPU_PWRSTST */
737#define OMAP4430_MPU_L2_STATEST_SHIFT 6 757#define OMAP4430_MPU_L2_STATEST_SHIFT 6
738#define OMAP4430_MPU_L2_STATEST_MASK BITFIELD(6, 7) 758#define OMAP4430_MPU_L2_STATEST_MASK (0x3 << 6)
739 759
740/* Used by PM_MPU_PWRSTCTRL */ 760/* Used by PM_MPU_PWRSTCTRL */
741#define OMAP4430_MPU_RAM_ONSTATE_SHIFT 20 761#define OMAP4430_MPU_RAM_ONSTATE_SHIFT 20
742#define OMAP4430_MPU_RAM_ONSTATE_MASK BITFIELD(20, 21) 762#define OMAP4430_MPU_RAM_ONSTATE_MASK (0x3 << 20)
743 763
744/* Used by PM_MPU_PWRSTCTRL */ 764/* Used by PM_MPU_PWRSTCTRL */
745#define OMAP4430_MPU_RAM_RETSTATE_SHIFT 10 765#define OMAP4430_MPU_RAM_RETSTATE_SHIFT 10
746#define OMAP4430_MPU_RAM_RETSTATE_MASK BITFIELD(10, 10) 766#define OMAP4430_MPU_RAM_RETSTATE_MASK (1 << 10)
747 767
748/* Used by PM_MPU_PWRSTST */ 768/* Used by PM_MPU_PWRSTST */
749#define OMAP4430_MPU_RAM_STATEST_SHIFT 8 769#define OMAP4430_MPU_RAM_STATEST_SHIFT 8
750#define OMAP4430_MPU_RAM_STATEST_MASK BITFIELD(8, 9) 770#define OMAP4430_MPU_RAM_STATEST_MASK (0x3 << 8)
751 771
752/* Used by PRM_RSTST */ 772/* Used by PRM_RSTST */
753#define OMAP4430_MPU_SECURITY_VIOL_RST_SHIFT 2 773#define OMAP4430_MPU_SECURITY_VIOL_RST_SHIFT 2
754#define OMAP4430_MPU_SECURITY_VIOL_RST_MASK BITFIELD(2, 2) 774#define OMAP4430_MPU_SECURITY_VIOL_RST_MASK (1 << 2)
755 775
756/* Used by PRM_RSTST */ 776/* Used by PRM_RSTST */
757#define OMAP4430_MPU_WDT_RST_SHIFT 3 777#define OMAP4430_MPU_WDT_RST_SHIFT 3
758#define OMAP4430_MPU_WDT_RST_MASK BITFIELD(3, 3) 778#define OMAP4430_MPU_WDT_RST_MASK (1 << 3)
759 779
760/* Used by PM_L4PER_PWRSTCTRL */ 780/* Used by PM_L4PER_PWRSTCTRL */
761#define OMAP4430_NONRETAINED_BANK_ONSTATE_SHIFT 18 781#define OMAP4430_NONRETAINED_BANK_ONSTATE_SHIFT 18
762#define OMAP4430_NONRETAINED_BANK_ONSTATE_MASK BITFIELD(18, 19) 782#define OMAP4430_NONRETAINED_BANK_ONSTATE_MASK (0x3 << 18)
763 783
764/* Used by PM_L4PER_PWRSTCTRL */ 784/* Used by PM_L4PER_PWRSTCTRL */
765#define OMAP4430_NONRETAINED_BANK_RETSTATE_SHIFT 9 785#define OMAP4430_NONRETAINED_BANK_RETSTATE_SHIFT 9
766#define OMAP4430_NONRETAINED_BANK_RETSTATE_MASK BITFIELD(9, 9) 786#define OMAP4430_NONRETAINED_BANK_RETSTATE_MASK (1 << 9)
767 787
768/* Used by PM_L4PER_PWRSTST */ 788/* Used by PM_L4PER_PWRSTST */
769#define OMAP4430_NONRETAINED_BANK_STATEST_SHIFT 6 789#define OMAP4430_NONRETAINED_BANK_STATEST_SHIFT 6
770#define OMAP4430_NONRETAINED_BANK_STATEST_MASK BITFIELD(6, 7) 790#define OMAP4430_NONRETAINED_BANK_STATEST_MASK (0x3 << 6)
771 791
772/* Used by PM_CORE_PWRSTCTRL */ 792/* Used by PM_CORE_PWRSTCTRL */
773#define OMAP4430_OCP_NRET_BANK_ONSTATE_SHIFT 24 793#define OMAP4430_OCP_NRET_BANK_ONSTATE_SHIFT 24
774#define OMAP4430_OCP_NRET_BANK_ONSTATE_MASK BITFIELD(24, 25) 794#define OMAP4430_OCP_NRET_BANK_ONSTATE_MASK (0x3 << 24)
775 795
776/* Used by PM_CORE_PWRSTCTRL */ 796/* Used by PM_CORE_PWRSTCTRL */
777#define OMAP4430_OCP_NRET_BANK_RETSTATE_SHIFT 12 797#define OMAP4430_OCP_NRET_BANK_RETSTATE_SHIFT 12
778#define OMAP4430_OCP_NRET_BANK_RETSTATE_MASK BITFIELD(12, 12) 798#define OMAP4430_OCP_NRET_BANK_RETSTATE_MASK (1 << 12)
779 799
780/* Used by PM_CORE_PWRSTST */ 800/* Used by PM_CORE_PWRSTST */
781#define OMAP4430_OCP_NRET_BANK_STATEST_SHIFT 12 801#define OMAP4430_OCP_NRET_BANK_STATEST_SHIFT 12
782#define OMAP4430_OCP_NRET_BANK_STATEST_MASK BITFIELD(12, 13) 802#define OMAP4430_OCP_NRET_BANK_STATEST_MASK (0x3 << 12)
783 803
784/* 804/*
785 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L, 805 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L,
786 * PRM_VC_VAL_CMD_VDD_MPU_L 806 * PRM_VC_VAL_CMD_VDD_MPU_L
787 */ 807 */
788#define OMAP4430_OFF_SHIFT 0 808#define OMAP4430_OFF_SHIFT 0
789#define OMAP4430_OFF_MASK BITFIELD(0, 7) 809#define OMAP4430_OFF_MASK (0xff << 0)
790
791/* Used by PRM_LDO_BANDGAP_CTRL */
792#define OMAP4430_OFF_ENABLE_SHIFT 0
793#define OMAP4430_OFF_ENABLE_MASK BITFIELD(0, 0)
794 810
795/* 811/*
796 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L, 812 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L,
797 * PRM_VC_VAL_CMD_VDD_MPU_L 813 * PRM_VC_VAL_CMD_VDD_MPU_L
798 */ 814 */
799#define OMAP4430_ON_SHIFT 24 815#define OMAP4430_ON_SHIFT 24
800#define OMAP4430_ON_MASK BITFIELD(24, 31) 816#define OMAP4430_ON_MASK (0xff << 24)
801 817
802/* 818/*
803 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L, 819 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L,
804 * PRM_VC_VAL_CMD_VDD_MPU_L 820 * PRM_VC_VAL_CMD_VDD_MPU_L
805 */ 821 */
806#define OMAP4430_ONLP_SHIFT 16 822#define OMAP4430_ONLP_SHIFT 16
807#define OMAP4430_ONLP_MASK BITFIELD(16, 23) 823#define OMAP4430_ONLP_MASK (0xff << 16)
808 824
809/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */ 825/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */
810#define OMAP4430_OPP_CHANGE_SHIFT 2 826#define OMAP4430_OPP_CHANGE_SHIFT 2
811#define OMAP4430_OPP_CHANGE_MASK BITFIELD(2, 2) 827#define OMAP4430_OPP_CHANGE_MASK (1 << 2)
812 828
813/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */ 829/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */
814#define OMAP4430_OPP_SEL_SHIFT 0 830#define OMAP4430_OPP_SEL_SHIFT 0
815#define OMAP4430_OPP_SEL_MASK BITFIELD(0, 1) 831#define OMAP4430_OPP_SEL_MASK (0x3 << 0)
816 832
817/* Used by PRM_SRAM_COUNT */ 833/* Used by PRM_SRAM_COUNT */
818#define OMAP4430_PCHARGECNT_VALUE_SHIFT 0 834#define OMAP4430_PCHARGECNT_VALUE_SHIFT 0
819#define OMAP4430_PCHARGECNT_VALUE_MASK BITFIELD(0, 5) 835#define OMAP4430_PCHARGECNT_VALUE_MASK (0x3f << 0)
820 836
821/* Used by PRM_PSCON_COUNT */ 837/* Used by PRM_PSCON_COUNT */
822#define OMAP4430_PCHARGE_TIME_SHIFT 0 838#define OMAP4430_PCHARGE_TIME_SHIFT 0
823#define OMAP4430_PCHARGE_TIME_MASK BITFIELD(0, 7) 839#define OMAP4430_PCHARGE_TIME_MASK (0xff << 0)
824 840
825/* Used by PM_ABE_PWRSTCTRL */ 841/* Used by PM_ABE_PWRSTCTRL */
826#define OMAP4430_PERIPHMEM_ONSTATE_SHIFT 20 842#define OMAP4430_PERIPHMEM_ONSTATE_SHIFT 20
827#define OMAP4430_PERIPHMEM_ONSTATE_MASK BITFIELD(20, 21) 843#define OMAP4430_PERIPHMEM_ONSTATE_MASK (0x3 << 20)
828 844
829/* Used by PM_ABE_PWRSTCTRL */ 845/* Used by PM_ABE_PWRSTCTRL */
830#define OMAP4430_PERIPHMEM_RETSTATE_SHIFT 10 846#define OMAP4430_PERIPHMEM_RETSTATE_SHIFT 10
831#define OMAP4430_PERIPHMEM_RETSTATE_MASK BITFIELD(10, 10) 847#define OMAP4430_PERIPHMEM_RETSTATE_MASK (1 << 10)
832 848
833/* Used by PM_ABE_PWRSTST */ 849/* Used by PM_ABE_PWRSTST */
834#define OMAP4430_PERIPHMEM_STATEST_SHIFT 8 850#define OMAP4430_PERIPHMEM_STATEST_SHIFT 8
835#define OMAP4430_PERIPHMEM_STATEST_MASK BITFIELD(8, 9) 851#define OMAP4430_PERIPHMEM_STATEST_MASK (0x3 << 8)
836 852
837/* Used by PRM_PHASE1_CNDP */ 853/* Used by PRM_PHASE1_CNDP */
838#define OMAP4430_PHASE1_CNDP_SHIFT 0 854#define OMAP4430_PHASE1_CNDP_SHIFT 0
839#define OMAP4430_PHASE1_CNDP_MASK BITFIELD(0, 31) 855#define OMAP4430_PHASE1_CNDP_MASK (0xffffffff << 0)
840 856
841/* Used by PRM_PHASE2A_CNDP */ 857/* Used by PRM_PHASE2A_CNDP */
842#define OMAP4430_PHASE2A_CNDP_SHIFT 0 858#define OMAP4430_PHASE2A_CNDP_SHIFT 0
843#define OMAP4430_PHASE2A_CNDP_MASK BITFIELD(0, 31) 859#define OMAP4430_PHASE2A_CNDP_MASK (0xffffffff << 0)
844 860
845/* Used by PRM_PHASE2B_CNDP */ 861/* Used by PRM_PHASE2B_CNDP */
846#define OMAP4430_PHASE2B_CNDP_SHIFT 0 862#define OMAP4430_PHASE2B_CNDP_SHIFT 0
847#define OMAP4430_PHASE2B_CNDP_MASK BITFIELD(0, 31) 863#define OMAP4430_PHASE2B_CNDP_MASK (0xffffffff << 0)
848 864
849/* Used by PRM_PSCON_COUNT */ 865/* Used by PRM_PSCON_COUNT */
850#define OMAP4430_PONOUT_2_PGOODIN_TIME_SHIFT 8 866#define OMAP4430_PONOUT_2_PGOODIN_TIME_SHIFT 8
851#define OMAP4430_PONOUT_2_PGOODIN_TIME_MASK BITFIELD(8, 15) 867#define OMAP4430_PONOUT_2_PGOODIN_TIME_MASK (0xff << 8)
852 868
853/* 869/*
854 * Used by PM_EMU_PWRSTCTRL, PM_CORE_PWRSTCTRL, PM_CAM_PWRSTCTRL, 870 * Used by PM_ABE_PWRSTCTRL, PM_CAM_PWRSTCTRL, PM_CEFUSE_PWRSTCTRL,
855 * PM_L3INIT_PWRSTCTRL, PM_ABE_PWRSTCTRL, PM_GFX_PWRSTCTRL, PM_MPU_PWRSTCTRL, 871 * PM_CORE_PWRSTCTRL, PM_DSS_PWRSTCTRL, PM_EMU_PWRSTCTRL, PM_GFX_PWRSTCTRL,
856 * PM_CEFUSE_PWRSTCTRL, PM_DSS_PWRSTCTRL, PM_L4PER_PWRSTCTRL, 872 * PM_IVAHD_PWRSTCTRL, PM_L3INIT_PWRSTCTRL, PM_L4PER_PWRSTCTRL,
857 * PM_TESLA_PWRSTCTRL, PM_IVAHD_PWRSTCTRL 873 * PM_MPU_PWRSTCTRL, PM_TESLA_PWRSTCTRL
858 */ 874 */
859#define OMAP4430_POWERSTATE_SHIFT 0 875#define OMAP4430_POWERSTATE_SHIFT 0
860#define OMAP4430_POWERSTATE_MASK BITFIELD(0, 1) 876#define OMAP4430_POWERSTATE_MASK (0x3 << 0)
861 877
862/* 878/*
863 * Used by PM_EMU_PWRSTST, PM_CORE_PWRSTST, PM_CAM_PWRSTST, PM_L3INIT_PWRSTST, 879 * Used by PM_ABE_PWRSTST, PM_CAM_PWRSTST, PM_CEFUSE_PWRSTST, PM_CORE_PWRSTST,
864 * PM_ABE_PWRSTST, PM_GFX_PWRSTST, PM_MPU_PWRSTST, PM_CEFUSE_PWRSTST, 880 * PM_DSS_PWRSTST, PM_EMU_PWRSTST, PM_GFX_PWRSTST, PM_IVAHD_PWRSTST,
865 * PM_DSS_PWRSTST, PM_L4PER_PWRSTST, PM_TESLA_PWRSTST, PM_IVAHD_PWRSTST 881 * PM_L3INIT_PWRSTST, PM_L4PER_PWRSTST, PM_MPU_PWRSTST, PM_TESLA_PWRSTST
866 */ 882 */
867#define OMAP4430_POWERSTATEST_SHIFT 0 883#define OMAP4430_POWERSTATEST_SHIFT 0
868#define OMAP4430_POWERSTATEST_MASK BITFIELD(0, 1) 884#define OMAP4430_POWERSTATEST_MASK (0x3 << 0)
869 885
870/* Used by PRM_PWRREQCTRL */ 886/* Used by PRM_PWRREQCTRL */
871#define OMAP4430_PWRREQ_COND_SHIFT 0 887#define OMAP4430_PWRREQ_COND_SHIFT 0
872#define OMAP4430_PWRREQ_COND_MASK BITFIELD(0, 1) 888#define OMAP4430_PWRREQ_COND_MASK (0x3 << 0)
873 889
874/* Used by PRM_VC_CFG_CHANNEL */ 890/* Used by PRM_VC_CFG_CHANNEL */
875#define OMAP4430_RACEN_VDD_CORE_L_SHIFT 3 891#define OMAP4430_RACEN_VDD_CORE_L_SHIFT 3
876#define OMAP4430_RACEN_VDD_CORE_L_MASK BITFIELD(3, 3) 892#define OMAP4430_RACEN_VDD_CORE_L_MASK (1 << 3)
877 893
878/* Used by PRM_VC_CFG_CHANNEL */ 894/* Used by PRM_VC_CFG_CHANNEL */
879#define OMAP4430_RACEN_VDD_IVA_L_SHIFT 11 895#define OMAP4430_RACEN_VDD_IVA_L_SHIFT 11
880#define OMAP4430_RACEN_VDD_IVA_L_MASK BITFIELD(11, 11) 896#define OMAP4430_RACEN_VDD_IVA_L_MASK (1 << 11)
881 897
882/* Used by PRM_VC_CFG_CHANNEL */ 898/* Used by PRM_VC_CFG_CHANNEL */
883#define OMAP4430_RACEN_VDD_MPU_L_SHIFT 20 899#define OMAP4430_RACEN_VDD_MPU_L_SHIFT 20
884#define OMAP4430_RACEN_VDD_MPU_L_MASK BITFIELD(20, 20) 900#define OMAP4430_RACEN_VDD_MPU_L_MASK (1 << 20)
885 901
886/* Used by PRM_VC_CFG_CHANNEL */ 902/* Used by PRM_VC_CFG_CHANNEL */
887#define OMAP4430_RAC_VDD_CORE_L_SHIFT 2 903#define OMAP4430_RAC_VDD_CORE_L_SHIFT 2
888#define OMAP4430_RAC_VDD_CORE_L_MASK BITFIELD(2, 2) 904#define OMAP4430_RAC_VDD_CORE_L_MASK (1 << 2)
889 905
890/* Used by PRM_VC_CFG_CHANNEL */ 906/* Used by PRM_VC_CFG_CHANNEL */
891#define OMAP4430_RAC_VDD_IVA_L_SHIFT 10 907#define OMAP4430_RAC_VDD_IVA_L_SHIFT 10
892#define OMAP4430_RAC_VDD_IVA_L_MASK BITFIELD(10, 10) 908#define OMAP4430_RAC_VDD_IVA_L_MASK (1 << 10)
893 909
894/* Used by PRM_VC_CFG_CHANNEL */ 910/* Used by PRM_VC_CFG_CHANNEL */
895#define OMAP4430_RAC_VDD_MPU_L_SHIFT 19 911#define OMAP4430_RAC_VDD_MPU_L_SHIFT 19
896#define OMAP4430_RAC_VDD_MPU_L_MASK BITFIELD(19, 19) 912#define OMAP4430_RAC_VDD_MPU_L_MASK (1 << 19)
897 913
898/* 914/*
899 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP, 915 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP,
@@ -901,7 +917,7 @@
901 * PRM_VOLTSETUP_MPU_RET_SLEEP 917 * PRM_VOLTSETUP_MPU_RET_SLEEP
902 */ 918 */
903#define OMAP4430_RAMP_DOWN_COUNT_SHIFT 16 919#define OMAP4430_RAMP_DOWN_COUNT_SHIFT 16
904#define OMAP4430_RAMP_DOWN_COUNT_MASK BITFIELD(16, 21) 920#define OMAP4430_RAMP_DOWN_COUNT_MASK (0x3f << 16)
905 921
906/* 922/*
907 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP, 923 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP,
@@ -909,7 +925,7 @@
909 * PRM_VOLTSETUP_MPU_RET_SLEEP 925 * PRM_VOLTSETUP_MPU_RET_SLEEP
910 */ 926 */
911#define OMAP4430_RAMP_DOWN_PRESCAL_SHIFT 24 927#define OMAP4430_RAMP_DOWN_PRESCAL_SHIFT 24
912#define OMAP4430_RAMP_DOWN_PRESCAL_MASK BITFIELD(24, 25) 928#define OMAP4430_RAMP_DOWN_PRESCAL_MASK (0x3 << 24)
913 929
914/* 930/*
915 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP, 931 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP,
@@ -917,7 +933,7 @@
917 * PRM_VOLTSETUP_MPU_RET_SLEEP 933 * PRM_VOLTSETUP_MPU_RET_SLEEP
918 */ 934 */
919#define OMAP4430_RAMP_UP_COUNT_SHIFT 0 935#define OMAP4430_RAMP_UP_COUNT_SHIFT 0
920#define OMAP4430_RAMP_UP_COUNT_MASK BITFIELD(0, 5) 936#define OMAP4430_RAMP_UP_COUNT_MASK (0x3f << 0)
921 937
922/* 938/*
923 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP, 939 * Used by PRM_VOLTSETUP_CORE_OFF, PRM_VOLTSETUP_CORE_RET_SLEEP,
@@ -925,1281 +941,1381 @@
925 * PRM_VOLTSETUP_MPU_RET_SLEEP 941 * PRM_VOLTSETUP_MPU_RET_SLEEP
926 */ 942 */
927#define OMAP4430_RAMP_UP_PRESCAL_SHIFT 8 943#define OMAP4430_RAMP_UP_PRESCAL_SHIFT 8
928#define OMAP4430_RAMP_UP_PRESCAL_MASK BITFIELD(8, 9) 944#define OMAP4430_RAMP_UP_PRESCAL_MASK (0x3 << 8)
929 945
930/* Used by PRM_VC_CFG_CHANNEL */ 946/* Used by PRM_VC_CFG_CHANNEL */
931#define OMAP4430_RAV_VDD_CORE_L_SHIFT 1 947#define OMAP4430_RAV_VDD_CORE_L_SHIFT 1
932#define OMAP4430_RAV_VDD_CORE_L_MASK BITFIELD(1, 1) 948#define OMAP4430_RAV_VDD_CORE_L_MASK (1 << 1)
933 949
934/* Used by PRM_VC_CFG_CHANNEL */ 950/* Used by PRM_VC_CFG_CHANNEL */
935#define OMAP4430_RAV_VDD_IVA_L_SHIFT 9 951#define OMAP4430_RAV_VDD_IVA_L_SHIFT 9
936#define OMAP4430_RAV_VDD_IVA_L_MASK BITFIELD(9, 9) 952#define OMAP4430_RAV_VDD_IVA_L_MASK (1 << 9)
937 953
938/* Used by PRM_VC_CFG_CHANNEL */ 954/* Used by PRM_VC_CFG_CHANNEL */
939#define OMAP4430_RAV_VDD_MPU_L_SHIFT 18 955#define OMAP4430_RAV_VDD_MPU_L_SHIFT 18
940#define OMAP4430_RAV_VDD_MPU_L_MASK BITFIELD(18, 18) 956#define OMAP4430_RAV_VDD_MPU_L_MASK (1 << 18)
941 957
942/* Used by PRM_VC_VAL_BYPASS */ 958/* Used by PRM_VC_VAL_BYPASS */
943#define OMAP4430_REGADDR_SHIFT 8 959#define OMAP4430_REGADDR_SHIFT 8
944#define OMAP4430_REGADDR_MASK BITFIELD(8, 15) 960#define OMAP4430_REGADDR_MASK (0xff << 8)
945 961
946/* 962/*
947 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L, 963 * Used by PRM_VC_VAL_CMD_VDD_CORE_L, PRM_VC_VAL_CMD_VDD_IVA_L,
948 * PRM_VC_VAL_CMD_VDD_MPU_L 964 * PRM_VC_VAL_CMD_VDD_MPU_L
949 */ 965 */
950#define OMAP4430_RET_SHIFT 8 966#define OMAP4430_RET_SHIFT 8
951#define OMAP4430_RET_MASK BITFIELD(8, 15) 967#define OMAP4430_RET_MASK (0xff << 8)
952 968
953/* Used by PM_L4PER_PWRSTCTRL */ 969/* Used by PM_L4PER_PWRSTCTRL */
954#define OMAP4430_RETAINED_BANK_ONSTATE_SHIFT 16 970#define OMAP4430_RETAINED_BANK_ONSTATE_SHIFT 16
955#define OMAP4430_RETAINED_BANK_ONSTATE_MASK BITFIELD(16, 17) 971#define OMAP4430_RETAINED_BANK_ONSTATE_MASK (0x3 << 16)
956 972
957/* Used by PM_L4PER_PWRSTCTRL */ 973/* Used by PM_L4PER_PWRSTCTRL */
958#define OMAP4430_RETAINED_BANK_RETSTATE_SHIFT 8 974#define OMAP4430_RETAINED_BANK_RETSTATE_SHIFT 8
959#define OMAP4430_RETAINED_BANK_RETSTATE_MASK BITFIELD(8, 8) 975#define OMAP4430_RETAINED_BANK_RETSTATE_MASK (1 << 8)
960 976
961/* Used by PM_L4PER_PWRSTST */ 977/* Used by PM_L4PER_PWRSTST */
962#define OMAP4430_RETAINED_BANK_STATEST_SHIFT 4 978#define OMAP4430_RETAINED_BANK_STATEST_SHIFT 4
963#define OMAP4430_RETAINED_BANK_STATEST_MASK BITFIELD(4, 5) 979#define OMAP4430_RETAINED_BANK_STATEST_MASK (0x3 << 4)
964 980
965/* 981/*
966 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL, 982 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL,
967 * PRM_LDO_SRAM_MPU_CTRL 983 * PRM_LDO_SRAM_MPU_CTRL
968 */ 984 */
969#define OMAP4430_RETMODE_ENABLE_SHIFT 0 985#define OMAP4430_RETMODE_ENABLE_SHIFT 0
970#define OMAP4430_RETMODE_ENABLE_MASK BITFIELD(0, 0) 986#define OMAP4430_RETMODE_ENABLE_MASK (1 << 0)
971 987
972/* Used by REVISION_PRM */ 988/* Used by RM_DUCATI_RSTCTRL, RM_IVAHD_RSTCTRL, RM_TESLA_RSTCTRL */
973#define OMAP4430_REV_SHIFT 0
974#define OMAP4430_REV_MASK BITFIELD(0, 7)
975
976/* Used by RM_DUCATI_RSTCTRL, RM_TESLA_RSTCTRL, RM_IVAHD_RSTCTRL */
977#define OMAP4430_RST1_SHIFT 0 989#define OMAP4430_RST1_SHIFT 0
978#define OMAP4430_RST1_MASK BITFIELD(0, 0) 990#define OMAP4430_RST1_MASK (1 << 0)
979 991
980/* Used by RM_DUCATI_RSTST, RM_TESLA_RSTST, RM_IVAHD_RSTST */ 992/* Used by RM_DUCATI_RSTST, RM_IVAHD_RSTST, RM_TESLA_RSTST */
981#define OMAP4430_RST1ST_SHIFT 0 993#define OMAP4430_RST1ST_SHIFT 0
982#define OMAP4430_RST1ST_MASK BITFIELD(0, 0) 994#define OMAP4430_RST1ST_MASK (1 << 0)
983 995
984/* Used by RM_DUCATI_RSTCTRL, RM_TESLA_RSTCTRL, RM_IVAHD_RSTCTRL */ 996/* Used by RM_DUCATI_RSTCTRL, RM_IVAHD_RSTCTRL, RM_TESLA_RSTCTRL */
985#define OMAP4430_RST2_SHIFT 1 997#define OMAP4430_RST2_SHIFT 1
986#define OMAP4430_RST2_MASK BITFIELD(1, 1) 998#define OMAP4430_RST2_MASK (1 << 1)
987 999
988/* Used by RM_DUCATI_RSTST, RM_TESLA_RSTST, RM_IVAHD_RSTST */ 1000/* Used by RM_DUCATI_RSTST, RM_IVAHD_RSTST, RM_TESLA_RSTST */
989#define OMAP4430_RST2ST_SHIFT 1 1001#define OMAP4430_RST2ST_SHIFT 1
990#define OMAP4430_RST2ST_MASK BITFIELD(1, 1) 1002#define OMAP4430_RST2ST_MASK (1 << 1)
991 1003
992/* Used by RM_DUCATI_RSTCTRL, RM_IVAHD_RSTCTRL */ 1004/* Used by RM_DUCATI_RSTCTRL, RM_IVAHD_RSTCTRL */
993#define OMAP4430_RST3_SHIFT 2 1005#define OMAP4430_RST3_SHIFT 2
994#define OMAP4430_RST3_MASK BITFIELD(2, 2) 1006#define OMAP4430_RST3_MASK (1 << 2)
995 1007
996/* Used by RM_DUCATI_RSTST, RM_IVAHD_RSTST */ 1008/* Used by RM_DUCATI_RSTST, RM_IVAHD_RSTST */
997#define OMAP4430_RST3ST_SHIFT 2 1009#define OMAP4430_RST3ST_SHIFT 2
998#define OMAP4430_RST3ST_MASK BITFIELD(2, 2) 1010#define OMAP4430_RST3ST_MASK (1 << 2)
999 1011
1000/* Used by PRM_RSTTIME */ 1012/* Used by PRM_RSTTIME */
1001#define OMAP4430_RSTTIME1_SHIFT 0 1013#define OMAP4430_RSTTIME1_SHIFT 0
1002#define OMAP4430_RSTTIME1_MASK BITFIELD(0, 9) 1014#define OMAP4430_RSTTIME1_MASK (0x3ff << 0)
1003 1015
1004/* Used by PRM_RSTTIME */ 1016/* Used by PRM_RSTTIME */
1005#define OMAP4430_RSTTIME2_SHIFT 10 1017#define OMAP4430_RSTTIME2_SHIFT 10
1006#define OMAP4430_RSTTIME2_MASK BITFIELD(10, 14) 1018#define OMAP4430_RSTTIME2_MASK (0x1f << 10)
1007 1019
1008/* Used by PRM_RSTCTRL */ 1020/* Used by PRM_RSTCTRL */
1009#define OMAP4430_RST_GLOBAL_COLD_SW_SHIFT 1 1021#define OMAP4430_RST_GLOBAL_COLD_SW_SHIFT 1
1010#define OMAP4430_RST_GLOBAL_COLD_SW_MASK BITFIELD(1, 1) 1022#define OMAP4430_RST_GLOBAL_COLD_SW_MASK (1 << 1)
1011 1023
1012/* Used by PRM_RSTCTRL */ 1024/* Used by PRM_RSTCTRL */
1013#define OMAP4430_RST_GLOBAL_WARM_SW_SHIFT 0 1025#define OMAP4430_RST_GLOBAL_WARM_SW_SHIFT 0
1014#define OMAP4430_RST_GLOBAL_WARM_SW_MASK BITFIELD(0, 0) 1026#define OMAP4430_RST_GLOBAL_WARM_SW_MASK (1 << 0)
1027
1028/* Used by REVISION_PRM */
1029#define OMAP4430_R_RTL_SHIFT 11
1030#define OMAP4430_R_RTL_MASK (0x1f << 11)
1015 1031
1016/* Used by PRM_VC_CFG_CHANNEL */ 1032/* Used by PRM_VC_CFG_CHANNEL */
1017#define OMAP4430_SA_VDD_CORE_L_SHIFT 0 1033#define OMAP4430_SA_VDD_CORE_L_SHIFT 0
1018#define OMAP4430_SA_VDD_CORE_L_MASK BITFIELD(0, 0) 1034#define OMAP4430_SA_VDD_CORE_L_MASK (1 << 0)
1019 1035
1020/* Renamed from SA_VDD_CORE_L Used by PRM_VC_SMPS_SA */ 1036/* Renamed from SA_VDD_CORE_L Used by PRM_VC_SMPS_SA */
1021#define OMAP4430_SA_VDD_CORE_L_0_6_SHIFT 0 1037#define OMAP4430_SA_VDD_CORE_L_0_6_SHIFT 0
1022#define OMAP4430_SA_VDD_CORE_L_0_6_MASK BITFIELD(0, 6) 1038#define OMAP4430_SA_VDD_CORE_L_0_6_MASK (0x7f << 0)
1023 1039
1024/* Used by PRM_VC_CFG_CHANNEL */ 1040/* Used by PRM_VC_CFG_CHANNEL */
1025#define OMAP4430_SA_VDD_IVA_L_SHIFT 8 1041#define OMAP4430_SA_VDD_IVA_L_SHIFT 8
1026#define OMAP4430_SA_VDD_IVA_L_MASK BITFIELD(8, 8) 1042#define OMAP4430_SA_VDD_IVA_L_MASK (1 << 8)
1027 1043
1028/* Renamed from SA_VDD_IVA_L Used by PRM_VC_SMPS_SA */ 1044/* Renamed from SA_VDD_IVA_L Used by PRM_VC_SMPS_SA */
1029#define OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_SHIFT 8 1045#define OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_SHIFT 8
1030#define OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK BITFIELD(8, 14) 1046#define OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK (0x7f << 8)
1031 1047
1032/* Used by PRM_VC_CFG_CHANNEL */ 1048/* Used by PRM_VC_CFG_CHANNEL */
1033#define OMAP4430_SA_VDD_MPU_L_SHIFT 16 1049#define OMAP4430_SA_VDD_MPU_L_SHIFT 16
1034#define OMAP4430_SA_VDD_MPU_L_MASK BITFIELD(16, 16) 1050#define OMAP4430_SA_VDD_MPU_L_MASK (1 << 16)
1035 1051
1036/* Renamed from SA_VDD_MPU_L Used by PRM_VC_SMPS_SA */ 1052/* Renamed from SA_VDD_MPU_L Used by PRM_VC_SMPS_SA */
1037#define OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_SHIFT 16 1053#define OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_SHIFT 16
1038#define OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK BITFIELD(16, 22) 1054#define OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK (0x7f << 16)
1055
1056/* Used by REVISION_PRM */
1057#define OMAP4430_SCHEME_SHIFT 30
1058#define OMAP4430_SCHEME_MASK (0x3 << 30)
1039 1059
1040/* Used by PRM_VC_CFG_I2C_CLK */ 1060/* Used by PRM_VC_CFG_I2C_CLK */
1041#define OMAP4430_SCLH_SHIFT 0 1061#define OMAP4430_SCLH_SHIFT 0
1042#define OMAP4430_SCLH_MASK BITFIELD(0, 7) 1062#define OMAP4430_SCLH_MASK (0xff << 0)
1043 1063
1044/* Used by PRM_VC_CFG_I2C_CLK */ 1064/* Used by PRM_VC_CFG_I2C_CLK */
1045#define OMAP4430_SCLL_SHIFT 8 1065#define OMAP4430_SCLL_SHIFT 8
1046#define OMAP4430_SCLL_MASK BITFIELD(8, 15) 1066#define OMAP4430_SCLL_MASK (0xff << 8)
1047 1067
1048/* Used by PRM_RSTST */ 1068/* Used by PRM_RSTST */
1049#define OMAP4430_SECURE_WDT_RST_SHIFT 4 1069#define OMAP4430_SECURE_WDT_RST_SHIFT 4
1050#define OMAP4430_SECURE_WDT_RST_MASK BITFIELD(4, 4) 1070#define OMAP4430_SECURE_WDT_RST_MASK (1 << 4)
1051 1071
1052/* Used by PM_IVAHD_PWRSTCTRL */ 1072/* Used by PM_IVAHD_PWRSTCTRL */
1053#define OMAP4430_SL2_MEM_ONSTATE_SHIFT 18 1073#define OMAP4430_SL2_MEM_ONSTATE_SHIFT 18
1054#define OMAP4430_SL2_MEM_ONSTATE_MASK BITFIELD(18, 19) 1074#define OMAP4430_SL2_MEM_ONSTATE_MASK (0x3 << 18)
1055 1075
1056/* Used by PM_IVAHD_PWRSTCTRL */ 1076/* Used by PM_IVAHD_PWRSTCTRL */
1057#define OMAP4430_SL2_MEM_RETSTATE_SHIFT 9 1077#define OMAP4430_SL2_MEM_RETSTATE_SHIFT 9
1058#define OMAP4430_SL2_MEM_RETSTATE_MASK BITFIELD(9, 9) 1078#define OMAP4430_SL2_MEM_RETSTATE_MASK (1 << 9)
1059 1079
1060/* Used by PM_IVAHD_PWRSTST */ 1080/* Used by PM_IVAHD_PWRSTST */
1061#define OMAP4430_SL2_MEM_STATEST_SHIFT 6 1081#define OMAP4430_SL2_MEM_STATEST_SHIFT 6
1062#define OMAP4430_SL2_MEM_STATEST_MASK BITFIELD(6, 7) 1082#define OMAP4430_SL2_MEM_STATEST_MASK (0x3 << 6)
1063 1083
1064/* Used by PRM_VC_VAL_BYPASS */ 1084/* Used by PRM_VC_VAL_BYPASS */
1065#define OMAP4430_SLAVEADDR_SHIFT 0 1085#define OMAP4430_SLAVEADDR_SHIFT 0
1066#define OMAP4430_SLAVEADDR_MASK BITFIELD(0, 6) 1086#define OMAP4430_SLAVEADDR_MASK (0x7f << 0)
1067 1087
1068/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */ 1088/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */
1069#define OMAP4430_SLEEP_RBB_SEL_SHIFT 3 1089#define OMAP4430_SLEEP_RBB_SEL_SHIFT 3
1070#define OMAP4430_SLEEP_RBB_SEL_MASK BITFIELD(3, 3) 1090#define OMAP4430_SLEEP_RBB_SEL_MASK (1 << 3)
1071 1091
1072/* Used by PRM_SRAM_COUNT */ 1092/* Used by PRM_SRAM_COUNT */
1073#define OMAP4430_SLPCNT_VALUE_SHIFT 16 1093#define OMAP4430_SLPCNT_VALUE_SHIFT 16
1074#define OMAP4430_SLPCNT_VALUE_MASK BITFIELD(16, 23) 1094#define OMAP4430_SLPCNT_VALUE_MASK (0xff << 16)
1075 1095
1076/* Used by PRM_VP_CORE_VSTEPMAX, PRM_VP_IVA_VSTEPMAX, PRM_VP_MPU_VSTEPMAX */ 1096/* Used by PRM_VP_CORE_VSTEPMAX, PRM_VP_IVA_VSTEPMAX, PRM_VP_MPU_VSTEPMAX */
1077#define OMAP4430_SMPSWAITTIMEMAX_SHIFT 8 1097#define OMAP4430_SMPSWAITTIMEMAX_SHIFT 8
1078#define OMAP4430_SMPSWAITTIMEMAX_MASK BITFIELD(8, 23) 1098#define OMAP4430_SMPSWAITTIMEMAX_MASK (0xffff << 8)
1079 1099
1080/* Used by PRM_VP_CORE_VSTEPMIN, PRM_VP_IVA_VSTEPMIN, PRM_VP_MPU_VSTEPMIN */ 1100/* Used by PRM_VP_CORE_VSTEPMIN, PRM_VP_IVA_VSTEPMIN, PRM_VP_MPU_VSTEPMIN */
1081#define OMAP4430_SMPSWAITTIMEMIN_SHIFT 8 1101#define OMAP4430_SMPSWAITTIMEMIN_SHIFT 8
1082#define OMAP4430_SMPSWAITTIMEMIN_MASK BITFIELD(8, 23) 1102#define OMAP4430_SMPSWAITTIMEMIN_MASK (0xffff << 8)
1103
1104/* Used by PRM_VC_ERRST */
1105#define OMAP4430_SMPS_RA_ERR_CORE_SHIFT 1
1106#define OMAP4430_SMPS_RA_ERR_CORE_MASK (1 << 1)
1107
1108/* Used by PRM_VC_ERRST */
1109#define OMAP4430_SMPS_RA_ERR_IVA_SHIFT 9
1110#define OMAP4430_SMPS_RA_ERR_IVA_MASK (1 << 9)
1111
1112/* Used by PRM_VC_ERRST */
1113#define OMAP4430_SMPS_RA_ERR_MPU_SHIFT 17
1114#define OMAP4430_SMPS_RA_ERR_MPU_MASK (1 << 17)
1115
1116/* Used by PRM_VC_ERRST */
1117#define OMAP4430_SMPS_SA_ERR_CORE_SHIFT 0
1118#define OMAP4430_SMPS_SA_ERR_CORE_MASK (1 << 0)
1119
1120/* Used by PRM_VC_ERRST */
1121#define OMAP4430_SMPS_SA_ERR_IVA_SHIFT 8
1122#define OMAP4430_SMPS_SA_ERR_IVA_MASK (1 << 8)
1123
1124/* Used by PRM_VC_ERRST */
1125#define OMAP4430_SMPS_SA_ERR_MPU_SHIFT 16
1126#define OMAP4430_SMPS_SA_ERR_MPU_MASK (1 << 16)
1127
1128/* Used by PRM_VC_ERRST */
1129#define OMAP4430_SMPS_TIMEOUT_ERR_CORE_SHIFT 2
1130#define OMAP4430_SMPS_TIMEOUT_ERR_CORE_MASK (1 << 2)
1131
1132/* Used by PRM_VC_ERRST */
1133#define OMAP4430_SMPS_TIMEOUT_ERR_IVA_SHIFT 10
1134#define OMAP4430_SMPS_TIMEOUT_ERR_IVA_MASK (1 << 10)
1135
1136/* Used by PRM_VC_ERRST */
1137#define OMAP4430_SMPS_TIMEOUT_ERR_MPU_SHIFT 18
1138#define OMAP4430_SMPS_TIMEOUT_ERR_MPU_MASK (1 << 18)
1083 1139
1084/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */ 1140/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */
1085#define OMAP4430_SR2EN_SHIFT 0 1141#define OMAP4430_SR2EN_SHIFT 0
1086#define OMAP4430_SR2EN_MASK BITFIELD(0, 0) 1142#define OMAP4430_SR2EN_MASK (1 << 0)
1087 1143
1088/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */ 1144/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */
1089#define OMAP4430_SR2_IN_TRANSITION_SHIFT 6 1145#define OMAP4430_SR2_IN_TRANSITION_SHIFT 6
1090#define OMAP4430_SR2_IN_TRANSITION_MASK BITFIELD(6, 6) 1146#define OMAP4430_SR2_IN_TRANSITION_MASK (1 << 6)
1091 1147
1092/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */ 1148/* Used by PRM_LDO_ABB_IVA_CTRL, PRM_LDO_ABB_MPU_CTRL */
1093#define OMAP4430_SR2_STATUS_SHIFT 3 1149#define OMAP4430_SR2_STATUS_SHIFT 3
1094#define OMAP4430_SR2_STATUS_MASK BITFIELD(3, 4) 1150#define OMAP4430_SR2_STATUS_MASK (0x3 << 3)
1095 1151
1096/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */ 1152/* Used by PRM_LDO_ABB_IVA_SETUP, PRM_LDO_ABB_MPU_SETUP */
1097#define OMAP4430_SR2_WTCNT_VALUE_SHIFT 8 1153#define OMAP4430_SR2_WTCNT_VALUE_SHIFT 8
1098#define OMAP4430_SR2_WTCNT_VALUE_MASK BITFIELD(8, 15) 1154#define OMAP4430_SR2_WTCNT_VALUE_MASK (0xff << 8)
1099 1155
1100/* 1156/*
1101 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL, 1157 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL,
1102 * PRM_LDO_SRAM_MPU_CTRL 1158 * PRM_LDO_SRAM_MPU_CTRL
1103 */ 1159 */
1104#define OMAP4430_SRAMLDO_STATUS_SHIFT 8 1160#define OMAP4430_SRAMLDO_STATUS_SHIFT 8
1105#define OMAP4430_SRAMLDO_STATUS_MASK BITFIELD(8, 8) 1161#define OMAP4430_SRAMLDO_STATUS_MASK (1 << 8)
1106 1162
1107/* 1163/*
1108 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL, 1164 * Used by PRM_LDO_SRAM_CORE_CTRL, PRM_LDO_SRAM_IVA_CTRL,
1109 * PRM_LDO_SRAM_MPU_CTRL 1165 * PRM_LDO_SRAM_MPU_CTRL
1110 */ 1166 */
1111#define OMAP4430_SRAM_IN_TRANSITION_SHIFT 9 1167#define OMAP4430_SRAM_IN_TRANSITION_SHIFT 9
1112#define OMAP4430_SRAM_IN_TRANSITION_MASK BITFIELD(9, 9) 1168#define OMAP4430_SRAM_IN_TRANSITION_MASK (1 << 9)
1113 1169
1114/* Used by PRM_VC_CFG_I2C_MODE */ 1170/* Used by PRM_VC_CFG_I2C_MODE */
1115#define OMAP4430_SRMODEEN_SHIFT 4 1171#define OMAP4430_SRMODEEN_SHIFT 4
1116#define OMAP4430_SRMODEEN_MASK BITFIELD(4, 4) 1172#define OMAP4430_SRMODEEN_MASK (1 << 4)
1117 1173
1118/* Used by PRM_VOLTSETUP_WARMRESET */ 1174/* Used by PRM_VOLTSETUP_WARMRESET */
1119#define OMAP4430_STABLE_COUNT_SHIFT 0 1175#define OMAP4430_STABLE_COUNT_SHIFT 0
1120#define OMAP4430_STABLE_COUNT_MASK BITFIELD(0, 5) 1176#define OMAP4430_STABLE_COUNT_MASK (0x3f << 0)
1121 1177
1122/* Used by PRM_VOLTSETUP_WARMRESET */ 1178/* Used by PRM_VOLTSETUP_WARMRESET */
1123#define OMAP4430_STABLE_PRESCAL_SHIFT 8 1179#define OMAP4430_STABLE_PRESCAL_SHIFT 8
1124#define OMAP4430_STABLE_PRESCAL_MASK BITFIELD(8, 9) 1180#define OMAP4430_STABLE_PRESCAL_MASK (0x3 << 8)
1181
1182/* Used by PRM_LDO_BANDGAP_SETUP */
1183#define OMAP4430_STARTUP_COUNT_SHIFT 0
1184#define OMAP4430_STARTUP_COUNT_MASK (0xff << 0)
1185
1186/* Renamed from STARTUP_COUNT Used by PRM_SRAM_COUNT */
1187#define OMAP4430_STARTUP_COUNT_24_31_SHIFT 24
1188#define OMAP4430_STARTUP_COUNT_24_31_MASK (0xff << 24)
1125 1189
1126/* Used by PM_IVAHD_PWRSTCTRL */ 1190/* Used by PM_IVAHD_PWRSTCTRL */
1127#define OMAP4430_TCM1_MEM_ONSTATE_SHIFT 20 1191#define OMAP4430_TCM1_MEM_ONSTATE_SHIFT 20
1128#define OMAP4430_TCM1_MEM_ONSTATE_MASK BITFIELD(20, 21) 1192#define OMAP4430_TCM1_MEM_ONSTATE_MASK (0x3 << 20)
1129 1193
1130/* Used by PM_IVAHD_PWRSTCTRL */ 1194/* Used by PM_IVAHD_PWRSTCTRL */
1131#define OMAP4430_TCM1_MEM_RETSTATE_SHIFT 10 1195#define OMAP4430_TCM1_MEM_RETSTATE_SHIFT 10
1132#define OMAP4430_TCM1_MEM_RETSTATE_MASK BITFIELD(10, 10) 1196#define OMAP4430_TCM1_MEM_RETSTATE_MASK (1 << 10)
1133 1197
1134/* Used by PM_IVAHD_PWRSTST */ 1198/* Used by PM_IVAHD_PWRSTST */
1135#define OMAP4430_TCM1_MEM_STATEST_SHIFT 8 1199#define OMAP4430_TCM1_MEM_STATEST_SHIFT 8
1136#define OMAP4430_TCM1_MEM_STATEST_MASK BITFIELD(8, 9) 1200#define OMAP4430_TCM1_MEM_STATEST_MASK (0x3 << 8)
1137 1201
1138/* Used by PM_IVAHD_PWRSTCTRL */ 1202/* Used by PM_IVAHD_PWRSTCTRL */
1139#define OMAP4430_TCM2_MEM_ONSTATE_SHIFT 22 1203#define OMAP4430_TCM2_MEM_ONSTATE_SHIFT 22
1140#define OMAP4430_TCM2_MEM_ONSTATE_MASK BITFIELD(22, 23) 1204#define OMAP4430_TCM2_MEM_ONSTATE_MASK (0x3 << 22)
1141 1205
1142/* Used by PM_IVAHD_PWRSTCTRL */ 1206/* Used by PM_IVAHD_PWRSTCTRL */
1143#define OMAP4430_TCM2_MEM_RETSTATE_SHIFT 11 1207#define OMAP4430_TCM2_MEM_RETSTATE_SHIFT 11
1144#define OMAP4430_TCM2_MEM_RETSTATE_MASK BITFIELD(11, 11) 1208#define OMAP4430_TCM2_MEM_RETSTATE_MASK (1 << 11)
1145 1209
1146/* Used by PM_IVAHD_PWRSTST */ 1210/* Used by PM_IVAHD_PWRSTST */
1147#define OMAP4430_TCM2_MEM_STATEST_SHIFT 10 1211#define OMAP4430_TCM2_MEM_STATEST_SHIFT 10
1148#define OMAP4430_TCM2_MEM_STATEST_MASK BITFIELD(10, 11) 1212#define OMAP4430_TCM2_MEM_STATEST_MASK (0x3 << 10)
1149 1213
1150/* Used by RM_TESLA_RSTST */ 1214/* Used by RM_TESLA_RSTST */
1151#define OMAP4430_TESLASS_EMU_RSTST_SHIFT 2 1215#define OMAP4430_TESLASS_EMU_RSTST_SHIFT 2
1152#define OMAP4430_TESLASS_EMU_RSTST_MASK BITFIELD(2, 2) 1216#define OMAP4430_TESLASS_EMU_RSTST_MASK (1 << 2)
1153 1217
1154/* Used by RM_TESLA_RSTST */ 1218/* Used by RM_TESLA_RSTST */
1155#define OMAP4430_TESLA_DSP_EMU_REQ_RSTST_SHIFT 3 1219#define OMAP4430_TESLA_DSP_EMU_REQ_RSTST_SHIFT 3
1156#define OMAP4430_TESLA_DSP_EMU_REQ_RSTST_MASK BITFIELD(3, 3) 1220#define OMAP4430_TESLA_DSP_EMU_REQ_RSTST_MASK (1 << 3)
1157 1221
1158/* Used by PM_TESLA_PWRSTCTRL */ 1222/* Used by PM_TESLA_PWRSTCTRL */
1159#define OMAP4430_TESLA_EDMA_ONSTATE_SHIFT 20 1223#define OMAP4430_TESLA_EDMA_ONSTATE_SHIFT 20
1160#define OMAP4430_TESLA_EDMA_ONSTATE_MASK BITFIELD(20, 21) 1224#define OMAP4430_TESLA_EDMA_ONSTATE_MASK (0x3 << 20)
1161 1225
1162/* Used by PM_TESLA_PWRSTCTRL */ 1226/* Used by PM_TESLA_PWRSTCTRL */
1163#define OMAP4430_TESLA_EDMA_RETSTATE_SHIFT 10 1227#define OMAP4430_TESLA_EDMA_RETSTATE_SHIFT 10
1164#define OMAP4430_TESLA_EDMA_RETSTATE_MASK BITFIELD(10, 10) 1228#define OMAP4430_TESLA_EDMA_RETSTATE_MASK (1 << 10)
1165 1229
1166/* Used by PM_TESLA_PWRSTST */ 1230/* Used by PM_TESLA_PWRSTST */
1167#define OMAP4430_TESLA_EDMA_STATEST_SHIFT 8 1231#define OMAP4430_TESLA_EDMA_STATEST_SHIFT 8
1168#define OMAP4430_TESLA_EDMA_STATEST_MASK BITFIELD(8, 9) 1232#define OMAP4430_TESLA_EDMA_STATEST_MASK (0x3 << 8)
1169 1233
1170/* Used by PM_TESLA_PWRSTCTRL */ 1234/* Used by PM_TESLA_PWRSTCTRL */
1171#define OMAP4430_TESLA_L1_ONSTATE_SHIFT 16 1235#define OMAP4430_TESLA_L1_ONSTATE_SHIFT 16
1172#define OMAP4430_TESLA_L1_ONSTATE_MASK BITFIELD(16, 17) 1236#define OMAP4430_TESLA_L1_ONSTATE_MASK (0x3 << 16)
1173 1237
1174/* Used by PM_TESLA_PWRSTCTRL */ 1238/* Used by PM_TESLA_PWRSTCTRL */
1175#define OMAP4430_TESLA_L1_RETSTATE_SHIFT 8 1239#define OMAP4430_TESLA_L1_RETSTATE_SHIFT 8
1176#define OMAP4430_TESLA_L1_RETSTATE_MASK BITFIELD(8, 8) 1240#define OMAP4430_TESLA_L1_RETSTATE_MASK (1 << 8)
1177 1241
1178/* Used by PM_TESLA_PWRSTST */ 1242/* Used by PM_TESLA_PWRSTST */
1179#define OMAP4430_TESLA_L1_STATEST_SHIFT 4 1243#define OMAP4430_TESLA_L1_STATEST_SHIFT 4
1180#define OMAP4430_TESLA_L1_STATEST_MASK BITFIELD(4, 5) 1244#define OMAP4430_TESLA_L1_STATEST_MASK (0x3 << 4)
1181 1245
1182/* Used by PM_TESLA_PWRSTCTRL */ 1246/* Used by PM_TESLA_PWRSTCTRL */
1183#define OMAP4430_TESLA_L2_ONSTATE_SHIFT 18 1247#define OMAP4430_TESLA_L2_ONSTATE_SHIFT 18
1184#define OMAP4430_TESLA_L2_ONSTATE_MASK BITFIELD(18, 19) 1248#define OMAP4430_TESLA_L2_ONSTATE_MASK (0x3 << 18)
1185 1249
1186/* Used by PM_TESLA_PWRSTCTRL */ 1250/* Used by PM_TESLA_PWRSTCTRL */
1187#define OMAP4430_TESLA_L2_RETSTATE_SHIFT 9 1251#define OMAP4430_TESLA_L2_RETSTATE_SHIFT 9
1188#define OMAP4430_TESLA_L2_RETSTATE_MASK BITFIELD(9, 9) 1252#define OMAP4430_TESLA_L2_RETSTATE_MASK (1 << 9)
1189 1253
1190/* Used by PM_TESLA_PWRSTST */ 1254/* Used by PM_TESLA_PWRSTST */
1191#define OMAP4430_TESLA_L2_STATEST_SHIFT 6 1255#define OMAP4430_TESLA_L2_STATEST_SHIFT 6
1192#define OMAP4430_TESLA_L2_STATEST_MASK BITFIELD(6, 7) 1256#define OMAP4430_TESLA_L2_STATEST_MASK (0x3 << 6)
1193 1257
1194/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */ 1258/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */
1195#define OMAP4430_TIMEOUT_SHIFT 0 1259#define OMAP4430_TIMEOUT_SHIFT 0
1196#define OMAP4430_TIMEOUT_MASK BITFIELD(0, 15) 1260#define OMAP4430_TIMEOUT_MASK (0xffff << 0)
1197 1261
1198/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 1262/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
1199#define OMAP4430_TIMEOUTEN_SHIFT 3 1263#define OMAP4430_TIMEOUTEN_SHIFT 3
1200#define OMAP4430_TIMEOUTEN_MASK BITFIELD(3, 3) 1264#define OMAP4430_TIMEOUTEN_MASK (1 << 3)
1201 1265
1202/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1266/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1203#define OMAP4430_TRANSITION_EN_SHIFT 8 1267#define OMAP4430_TRANSITION_EN_SHIFT 8
1204#define OMAP4430_TRANSITION_EN_MASK BITFIELD(8, 8) 1268#define OMAP4430_TRANSITION_EN_MASK (1 << 8)
1205 1269
1206/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1270/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1207#define OMAP4430_TRANSITION_ST_SHIFT 8 1271#define OMAP4430_TRANSITION_ST_SHIFT 8
1208#define OMAP4430_TRANSITION_ST_MASK BITFIELD(8, 8) 1272#define OMAP4430_TRANSITION_ST_MASK (1 << 8)
1209 1273
1210/* Used by PRM_VC_VAL_BYPASS */ 1274/* Used by PRM_VC_VAL_BYPASS */
1211#define OMAP4430_VALID_SHIFT 24 1275#define OMAP4430_VALID_SHIFT 24
1212#define OMAP4430_VALID_MASK BITFIELD(24, 24) 1276#define OMAP4430_VALID_MASK (1 << 24)
1213 1277
1214/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1278/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1215#define OMAP4430_VC_BYPASSACK_EN_SHIFT 14 1279#define OMAP4430_VC_BYPASSACK_EN_SHIFT 14
1216#define OMAP4430_VC_BYPASSACK_EN_MASK BITFIELD(14, 14) 1280#define OMAP4430_VC_BYPASSACK_EN_MASK (1 << 14)
1217 1281
1218/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1282/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1219#define OMAP4430_VC_BYPASSACK_ST_SHIFT 14 1283#define OMAP4430_VC_BYPASSACK_ST_SHIFT 14
1220#define OMAP4430_VC_BYPASSACK_ST_MASK BITFIELD(14, 14) 1284#define OMAP4430_VC_BYPASSACK_ST_MASK (1 << 14)
1285
1286/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1287#define OMAP4430_VC_CORE_VPACK_EN_SHIFT 22
1288#define OMAP4430_VC_CORE_VPACK_EN_MASK (1 << 22)
1289
1290/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1291#define OMAP4430_VC_CORE_VPACK_ST_SHIFT 22
1292#define OMAP4430_VC_CORE_VPACK_ST_MASK (1 << 22)
1221 1293
1222/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1294/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1223#define OMAP4430_VC_IVA_VPACK_EN_SHIFT 30 1295#define OMAP4430_VC_IVA_VPACK_EN_SHIFT 30
1224#define OMAP4430_VC_IVA_VPACK_EN_MASK BITFIELD(30, 30) 1296#define OMAP4430_VC_IVA_VPACK_EN_MASK (1 << 30)
1225 1297
1226/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1298/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1227#define OMAP4430_VC_IVA_VPACK_ST_SHIFT 30 1299#define OMAP4430_VC_IVA_VPACK_ST_SHIFT 30
1228#define OMAP4430_VC_IVA_VPACK_ST_MASK BITFIELD(30, 30) 1300#define OMAP4430_VC_IVA_VPACK_ST_MASK (1 << 30)
1229 1301
1230/* Used by PRM_IRQENABLE_MPU_2 */ 1302/* Used by PRM_IRQENABLE_MPU_2 */
1231#define OMAP4430_VC_MPU_VPACK_EN_SHIFT 6 1303#define OMAP4430_VC_MPU_VPACK_EN_SHIFT 6
1232#define OMAP4430_VC_MPU_VPACK_EN_MASK BITFIELD(6, 6) 1304#define OMAP4430_VC_MPU_VPACK_EN_MASK (1 << 6)
1233 1305
1234/* Used by PRM_IRQSTATUS_MPU_2 */ 1306/* Used by PRM_IRQSTATUS_MPU_2 */
1235#define OMAP4430_VC_MPU_VPACK_ST_SHIFT 6 1307#define OMAP4430_VC_MPU_VPACK_ST_SHIFT 6
1236#define OMAP4430_VC_MPU_VPACK_ST_MASK BITFIELD(6, 6) 1308#define OMAP4430_VC_MPU_VPACK_ST_MASK (1 << 6)
1237 1309
1238/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1310/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1239#define OMAP4430_VC_RAERR_EN_SHIFT 12 1311#define OMAP4430_VC_RAERR_EN_SHIFT 12
1240#define OMAP4430_VC_RAERR_EN_MASK BITFIELD(12, 12) 1312#define OMAP4430_VC_RAERR_EN_MASK (1 << 12)
1241 1313
1242/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1314/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1243#define OMAP4430_VC_RAERR_ST_SHIFT 12 1315#define OMAP4430_VC_RAERR_ST_SHIFT 12
1244#define OMAP4430_VC_RAERR_ST_MASK BITFIELD(12, 12) 1316#define OMAP4430_VC_RAERR_ST_MASK (1 << 12)
1245 1317
1246/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1318/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1247#define OMAP4430_VC_SAERR_EN_SHIFT 11 1319#define OMAP4430_VC_SAERR_EN_SHIFT 11
1248#define OMAP4430_VC_SAERR_EN_MASK BITFIELD(11, 11) 1320#define OMAP4430_VC_SAERR_EN_MASK (1 << 11)
1249 1321
1250/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1322/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1251#define OMAP4430_VC_SAERR_ST_SHIFT 11 1323#define OMAP4430_VC_SAERR_ST_SHIFT 11
1252#define OMAP4430_VC_SAERR_ST_MASK BITFIELD(11, 11) 1324#define OMAP4430_VC_SAERR_ST_MASK (1 << 11)
1253 1325
1254/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1326/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1255#define OMAP4430_VC_TOERR_EN_SHIFT 13 1327#define OMAP4430_VC_TOERR_EN_SHIFT 13
1256#define OMAP4430_VC_TOERR_EN_MASK BITFIELD(13, 13) 1328#define OMAP4430_VC_TOERR_EN_MASK (1 << 13)
1257 1329
1258/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1330/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1259#define OMAP4430_VC_TOERR_ST_SHIFT 13 1331#define OMAP4430_VC_TOERR_ST_SHIFT 13
1260#define OMAP4430_VC_TOERR_ST_MASK BITFIELD(13, 13) 1332#define OMAP4430_VC_TOERR_ST_MASK (1 << 13)
1261 1333
1262/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */ 1334/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */
1263#define OMAP4430_VDDMAX_SHIFT 24 1335#define OMAP4430_VDDMAX_SHIFT 24
1264#define OMAP4430_VDDMAX_MASK BITFIELD(24, 31) 1336#define OMAP4430_VDDMAX_MASK (0xff << 24)
1265 1337
1266/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */ 1338/* Used by PRM_VP_CORE_VLIMITTO, PRM_VP_IVA_VLIMITTO, PRM_VP_MPU_VLIMITTO */
1267#define OMAP4430_VDDMIN_SHIFT 16 1339#define OMAP4430_VDDMIN_SHIFT 16
1268#define OMAP4430_VDDMIN_MASK BITFIELD(16, 23) 1340#define OMAP4430_VDDMIN_MASK (0xff << 16)
1269 1341
1270/* Used by PRM_VOLTCTRL */ 1342/* Used by PRM_VOLTCTRL */
1271#define OMAP4430_VDD_CORE_I2C_DISABLE_SHIFT 12 1343#define OMAP4430_VDD_CORE_I2C_DISABLE_SHIFT 12
1272#define OMAP4430_VDD_CORE_I2C_DISABLE_MASK BITFIELD(12, 12) 1344#define OMAP4430_VDD_CORE_I2C_DISABLE_MASK (1 << 12)
1273 1345
1274/* Used by PRM_RSTST */ 1346/* Used by PRM_RSTST */
1275#define OMAP4430_VDD_CORE_VOLT_MGR_RST_SHIFT 8 1347#define OMAP4430_VDD_CORE_VOLT_MGR_RST_SHIFT 8
1276#define OMAP4430_VDD_CORE_VOLT_MGR_RST_MASK BITFIELD(8, 8) 1348#define OMAP4430_VDD_CORE_VOLT_MGR_RST_MASK (1 << 8)
1277 1349
1278/* Used by PRM_VOLTCTRL */ 1350/* Used by PRM_VOLTCTRL */
1279#define OMAP4430_VDD_IVA_I2C_DISABLE_SHIFT 14 1351#define OMAP4430_VDD_IVA_I2C_DISABLE_SHIFT 14
1280#define OMAP4430_VDD_IVA_I2C_DISABLE_MASK BITFIELD(14, 14) 1352#define OMAP4430_VDD_IVA_I2C_DISABLE_MASK (1 << 14)
1281 1353
1282/* Used by PRM_VOLTCTRL */ 1354/* Used by PRM_VOLTCTRL */
1283#define OMAP4430_VDD_IVA_PRESENCE_SHIFT 9 1355#define OMAP4430_VDD_IVA_PRESENCE_SHIFT 9
1284#define OMAP4430_VDD_IVA_PRESENCE_MASK BITFIELD(9, 9) 1356#define OMAP4430_VDD_IVA_PRESENCE_MASK (1 << 9)
1285 1357
1286/* Used by PRM_RSTST */ 1358/* Used by PRM_RSTST */
1287#define OMAP4430_VDD_IVA_VOLT_MGR_RST_SHIFT 7 1359#define OMAP4430_VDD_IVA_VOLT_MGR_RST_SHIFT 7
1288#define OMAP4430_VDD_IVA_VOLT_MGR_RST_MASK BITFIELD(7, 7) 1360#define OMAP4430_VDD_IVA_VOLT_MGR_RST_MASK (1 << 7)
1289 1361
1290/* Used by PRM_VOLTCTRL */ 1362/* Used by PRM_VOLTCTRL */
1291#define OMAP4430_VDD_MPU_I2C_DISABLE_SHIFT 13 1363#define OMAP4430_VDD_MPU_I2C_DISABLE_SHIFT 13
1292#define OMAP4430_VDD_MPU_I2C_DISABLE_MASK BITFIELD(13, 13) 1364#define OMAP4430_VDD_MPU_I2C_DISABLE_MASK (1 << 13)
1293 1365
1294/* Used by PRM_VOLTCTRL */ 1366/* Used by PRM_VOLTCTRL */
1295#define OMAP4430_VDD_MPU_PRESENCE_SHIFT 8 1367#define OMAP4430_VDD_MPU_PRESENCE_SHIFT 8
1296#define OMAP4430_VDD_MPU_PRESENCE_MASK BITFIELD(8, 8) 1368#define OMAP4430_VDD_MPU_PRESENCE_MASK (1 << 8)
1297 1369
1298/* Used by PRM_RSTST */ 1370/* Used by PRM_RSTST */
1299#define OMAP4430_VDD_MPU_VOLT_MGR_RST_SHIFT 6 1371#define OMAP4430_VDD_MPU_VOLT_MGR_RST_SHIFT 6
1300#define OMAP4430_VDD_MPU_VOLT_MGR_RST_MASK BITFIELD(6, 6) 1372#define OMAP4430_VDD_MPU_VOLT_MGR_RST_MASK (1 << 6)
1373
1374/* Used by PRM_VC_ERRST */
1375#define OMAP4430_VFSM_RA_ERR_CORE_SHIFT 4
1376#define OMAP4430_VFSM_RA_ERR_CORE_MASK (1 << 4)
1377
1378/* Used by PRM_VC_ERRST */
1379#define OMAP4430_VFSM_RA_ERR_IVA_SHIFT 12
1380#define OMAP4430_VFSM_RA_ERR_IVA_MASK (1 << 12)
1381
1382/* Used by PRM_VC_ERRST */
1383#define OMAP4430_VFSM_RA_ERR_MPU_SHIFT 20
1384#define OMAP4430_VFSM_RA_ERR_MPU_MASK (1 << 20)
1385
1386/* Used by PRM_VC_ERRST */
1387#define OMAP4430_VFSM_SA_ERR_CORE_SHIFT 3
1388#define OMAP4430_VFSM_SA_ERR_CORE_MASK (1 << 3)
1389
1390/* Used by PRM_VC_ERRST */
1391#define OMAP4430_VFSM_SA_ERR_IVA_SHIFT 11
1392#define OMAP4430_VFSM_SA_ERR_IVA_MASK (1 << 11)
1393
1394/* Used by PRM_VC_ERRST */
1395#define OMAP4430_VFSM_SA_ERR_MPU_SHIFT 19
1396#define OMAP4430_VFSM_SA_ERR_MPU_MASK (1 << 19)
1397
1398/* Used by PRM_VC_ERRST */
1399#define OMAP4430_VFSM_TIMEOUT_ERR_CORE_SHIFT 5
1400#define OMAP4430_VFSM_TIMEOUT_ERR_CORE_MASK (1 << 5)
1401
1402/* Used by PRM_VC_ERRST */
1403#define OMAP4430_VFSM_TIMEOUT_ERR_IVA_SHIFT 13
1404#define OMAP4430_VFSM_TIMEOUT_ERR_IVA_MASK (1 << 13)
1405
1406/* Used by PRM_VC_ERRST */
1407#define OMAP4430_VFSM_TIMEOUT_ERR_MPU_SHIFT 21
1408#define OMAP4430_VFSM_TIMEOUT_ERR_MPU_MASK (1 << 21)
1301 1409
1302/* Used by PRM_VC_VAL_SMPS_RA_VOL */ 1410/* Used by PRM_VC_VAL_SMPS_RA_VOL */
1303#define OMAP4430_VOLRA_VDD_CORE_L_SHIFT 0 1411#define OMAP4430_VOLRA_VDD_CORE_L_SHIFT 0
1304#define OMAP4430_VOLRA_VDD_CORE_L_MASK BITFIELD(0, 7) 1412#define OMAP4430_VOLRA_VDD_CORE_L_MASK (0xff << 0)
1305 1413
1306/* Used by PRM_VC_VAL_SMPS_RA_VOL */ 1414/* Used by PRM_VC_VAL_SMPS_RA_VOL */
1307#define OMAP4430_VOLRA_VDD_IVA_L_SHIFT 8 1415#define OMAP4430_VOLRA_VDD_IVA_L_SHIFT 8
1308#define OMAP4430_VOLRA_VDD_IVA_L_MASK BITFIELD(8, 15) 1416#define OMAP4430_VOLRA_VDD_IVA_L_MASK (0xff << 8)
1309 1417
1310/* Used by PRM_VC_VAL_SMPS_RA_VOL */ 1418/* Used by PRM_VC_VAL_SMPS_RA_VOL */
1311#define OMAP4430_VOLRA_VDD_MPU_L_SHIFT 16 1419#define OMAP4430_VOLRA_VDD_MPU_L_SHIFT 16
1312#define OMAP4430_VOLRA_VDD_MPU_L_MASK BITFIELD(16, 23) 1420#define OMAP4430_VOLRA_VDD_MPU_L_MASK (0xff << 16)
1313 1421
1314/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */ 1422/* Used by PRM_VP_CORE_CONFIG, PRM_VP_IVA_CONFIG, PRM_VP_MPU_CONFIG */
1315#define OMAP4430_VPENABLE_SHIFT 0 1423#define OMAP4430_VPENABLE_SHIFT 0
1316#define OMAP4430_VPENABLE_MASK BITFIELD(0, 0) 1424#define OMAP4430_VPENABLE_MASK (1 << 0)
1317 1425
1318/* Used by PRM_VP_CORE_STATUS, PRM_VP_IVA_STATUS, PRM_VP_MPU_STATUS */ 1426/* Used by PRM_VP_CORE_STATUS, PRM_VP_IVA_STATUS, PRM_VP_MPU_STATUS */
1319#define OMAP4430_VPINIDLE_SHIFT 0 1427#define OMAP4430_VPINIDLE_SHIFT 0
1320#define OMAP4430_VPINIDLE_MASK BITFIELD(0, 0) 1428#define OMAP4430_VPINIDLE_MASK (1 << 0)
1321 1429
1322/* Used by PRM_VP_CORE_VOLTAGE, PRM_VP_IVA_VOLTAGE, PRM_VP_MPU_VOLTAGE */ 1430/* Used by PRM_VP_CORE_VOLTAGE, PRM_VP_IVA_VOLTAGE, PRM_VP_MPU_VOLTAGE */
1323#define OMAP4430_VPVOLTAGE_SHIFT 0 1431#define OMAP4430_VPVOLTAGE_SHIFT 0
1324#define OMAP4430_VPVOLTAGE_MASK BITFIELD(0, 7) 1432#define OMAP4430_VPVOLTAGE_MASK (0xff << 0)
1325 1433
1326/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1434/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1327#define OMAP4430_VP_CORE_EQVALUE_EN_SHIFT 20 1435#define OMAP4430_VP_CORE_EQVALUE_EN_SHIFT 20
1328#define OMAP4430_VP_CORE_EQVALUE_EN_MASK BITFIELD(20, 20) 1436#define OMAP4430_VP_CORE_EQVALUE_EN_MASK (1 << 20)
1329 1437
1330/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1438/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1331#define OMAP4430_VP_CORE_EQVALUE_ST_SHIFT 20 1439#define OMAP4430_VP_CORE_EQVALUE_ST_SHIFT 20
1332#define OMAP4430_VP_CORE_EQVALUE_ST_MASK BITFIELD(20, 20) 1440#define OMAP4430_VP_CORE_EQVALUE_ST_MASK (1 << 20)
1333 1441
1334/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1442/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1335#define OMAP4430_VP_CORE_MAXVDD_EN_SHIFT 18 1443#define OMAP4430_VP_CORE_MAXVDD_EN_SHIFT 18
1336#define OMAP4430_VP_CORE_MAXVDD_EN_MASK BITFIELD(18, 18) 1444#define OMAP4430_VP_CORE_MAXVDD_EN_MASK (1 << 18)
1337 1445
1338/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1446/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1339#define OMAP4430_VP_CORE_MAXVDD_ST_SHIFT 18 1447#define OMAP4430_VP_CORE_MAXVDD_ST_SHIFT 18
1340#define OMAP4430_VP_CORE_MAXVDD_ST_MASK BITFIELD(18, 18) 1448#define OMAP4430_VP_CORE_MAXVDD_ST_MASK (1 << 18)
1341 1449
1342/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1450/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1343#define OMAP4430_VP_CORE_MINVDD_EN_SHIFT 17 1451#define OMAP4430_VP_CORE_MINVDD_EN_SHIFT 17
1344#define OMAP4430_VP_CORE_MINVDD_EN_MASK BITFIELD(17, 17) 1452#define OMAP4430_VP_CORE_MINVDD_EN_MASK (1 << 17)
1345 1453
1346/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1454/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1347#define OMAP4430_VP_CORE_MINVDD_ST_SHIFT 17 1455#define OMAP4430_VP_CORE_MINVDD_ST_SHIFT 17
1348#define OMAP4430_VP_CORE_MINVDD_ST_MASK BITFIELD(17, 17) 1456#define OMAP4430_VP_CORE_MINVDD_ST_MASK (1 << 17)
1349 1457
1350/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1458/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1351#define OMAP4430_VP_CORE_NOSMPSACK_EN_SHIFT 19 1459#define OMAP4430_VP_CORE_NOSMPSACK_EN_SHIFT 19
1352#define OMAP4430_VP_CORE_NOSMPSACK_EN_MASK BITFIELD(19, 19) 1460#define OMAP4430_VP_CORE_NOSMPSACK_EN_MASK (1 << 19)
1353 1461
1354/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1462/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1355#define OMAP4430_VP_CORE_NOSMPSACK_ST_SHIFT 19 1463#define OMAP4430_VP_CORE_NOSMPSACK_ST_SHIFT 19
1356#define OMAP4430_VP_CORE_NOSMPSACK_ST_MASK BITFIELD(19, 19) 1464#define OMAP4430_VP_CORE_NOSMPSACK_ST_MASK (1 << 19)
1357 1465
1358/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1466/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1359#define OMAP4430_VP_CORE_OPPCHANGEDONE_EN_SHIFT 16 1467#define OMAP4430_VP_CORE_OPPCHANGEDONE_EN_SHIFT 16
1360#define OMAP4430_VP_CORE_OPPCHANGEDONE_EN_MASK BITFIELD(16, 16) 1468#define OMAP4430_VP_CORE_OPPCHANGEDONE_EN_MASK (1 << 16)
1361 1469
1362/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1470/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1363#define OMAP4430_VP_CORE_OPPCHANGEDONE_ST_SHIFT 16 1471#define OMAP4430_VP_CORE_OPPCHANGEDONE_ST_SHIFT 16
1364#define OMAP4430_VP_CORE_OPPCHANGEDONE_ST_MASK BITFIELD(16, 16) 1472#define OMAP4430_VP_CORE_OPPCHANGEDONE_ST_MASK (1 << 16)
1365 1473
1366/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1474/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1367#define OMAP4430_VP_CORE_TRANXDONE_EN_SHIFT 21 1475#define OMAP4430_VP_CORE_TRANXDONE_EN_SHIFT 21
1368#define OMAP4430_VP_CORE_TRANXDONE_EN_MASK BITFIELD(21, 21) 1476#define OMAP4430_VP_CORE_TRANXDONE_EN_MASK (1 << 21)
1369 1477
1370/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1478/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1371#define OMAP4430_VP_CORE_TRANXDONE_ST_SHIFT 21 1479#define OMAP4430_VP_CORE_TRANXDONE_ST_SHIFT 21
1372#define OMAP4430_VP_CORE_TRANXDONE_ST_MASK BITFIELD(21, 21) 1480#define OMAP4430_VP_CORE_TRANXDONE_ST_MASK (1 << 21)
1373 1481
1374/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1482/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1375#define OMAP4430_VP_IVA_EQVALUE_EN_SHIFT 28 1483#define OMAP4430_VP_IVA_EQVALUE_EN_SHIFT 28
1376#define OMAP4430_VP_IVA_EQVALUE_EN_MASK BITFIELD(28, 28) 1484#define OMAP4430_VP_IVA_EQVALUE_EN_MASK (1 << 28)
1377 1485
1378/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1486/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1379#define OMAP4430_VP_IVA_EQVALUE_ST_SHIFT 28 1487#define OMAP4430_VP_IVA_EQVALUE_ST_SHIFT 28
1380#define OMAP4430_VP_IVA_EQVALUE_ST_MASK BITFIELD(28, 28) 1488#define OMAP4430_VP_IVA_EQVALUE_ST_MASK (1 << 28)
1381 1489
1382/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1490/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1383#define OMAP4430_VP_IVA_MAXVDD_EN_SHIFT 26 1491#define OMAP4430_VP_IVA_MAXVDD_EN_SHIFT 26
1384#define OMAP4430_VP_IVA_MAXVDD_EN_MASK BITFIELD(26, 26) 1492#define OMAP4430_VP_IVA_MAXVDD_EN_MASK (1 << 26)
1385 1493
1386/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1494/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1387#define OMAP4430_VP_IVA_MAXVDD_ST_SHIFT 26 1495#define OMAP4430_VP_IVA_MAXVDD_ST_SHIFT 26
1388#define OMAP4430_VP_IVA_MAXVDD_ST_MASK BITFIELD(26, 26) 1496#define OMAP4430_VP_IVA_MAXVDD_ST_MASK (1 << 26)
1389 1497
1390/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1498/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1391#define OMAP4430_VP_IVA_MINVDD_EN_SHIFT 25 1499#define OMAP4430_VP_IVA_MINVDD_EN_SHIFT 25
1392#define OMAP4430_VP_IVA_MINVDD_EN_MASK BITFIELD(25, 25) 1500#define OMAP4430_VP_IVA_MINVDD_EN_MASK (1 << 25)
1393 1501
1394/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1502/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1395#define OMAP4430_VP_IVA_MINVDD_ST_SHIFT 25 1503#define OMAP4430_VP_IVA_MINVDD_ST_SHIFT 25
1396#define OMAP4430_VP_IVA_MINVDD_ST_MASK BITFIELD(25, 25) 1504#define OMAP4430_VP_IVA_MINVDD_ST_MASK (1 << 25)
1397 1505
1398/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1506/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1399#define OMAP4430_VP_IVA_NOSMPSACK_EN_SHIFT 27 1507#define OMAP4430_VP_IVA_NOSMPSACK_EN_SHIFT 27
1400#define OMAP4430_VP_IVA_NOSMPSACK_EN_MASK BITFIELD(27, 27) 1508#define OMAP4430_VP_IVA_NOSMPSACK_EN_MASK (1 << 27)
1401 1509
1402/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1510/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1403#define OMAP4430_VP_IVA_NOSMPSACK_ST_SHIFT 27 1511#define OMAP4430_VP_IVA_NOSMPSACK_ST_SHIFT 27
1404#define OMAP4430_VP_IVA_NOSMPSACK_ST_MASK BITFIELD(27, 27) 1512#define OMAP4430_VP_IVA_NOSMPSACK_ST_MASK (1 << 27)
1405 1513
1406/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1514/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1407#define OMAP4430_VP_IVA_OPPCHANGEDONE_EN_SHIFT 24 1515#define OMAP4430_VP_IVA_OPPCHANGEDONE_EN_SHIFT 24
1408#define OMAP4430_VP_IVA_OPPCHANGEDONE_EN_MASK BITFIELD(24, 24) 1516#define OMAP4430_VP_IVA_OPPCHANGEDONE_EN_MASK (1 << 24)
1409 1517
1410/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1518/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1411#define OMAP4430_VP_IVA_OPPCHANGEDONE_ST_SHIFT 24 1519#define OMAP4430_VP_IVA_OPPCHANGEDONE_ST_SHIFT 24
1412#define OMAP4430_VP_IVA_OPPCHANGEDONE_ST_MASK BITFIELD(24, 24) 1520#define OMAP4430_VP_IVA_OPPCHANGEDONE_ST_MASK (1 << 24)
1413 1521
1414/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */ 1522/* Used by PRM_IRQENABLE_DUCATI, PRM_IRQENABLE_MPU */
1415#define OMAP4430_VP_IVA_TRANXDONE_EN_SHIFT 29 1523#define OMAP4430_VP_IVA_TRANXDONE_EN_SHIFT 29
1416#define OMAP4430_VP_IVA_TRANXDONE_EN_MASK BITFIELD(29, 29) 1524#define OMAP4430_VP_IVA_TRANXDONE_EN_MASK (1 << 29)
1417 1525
1418/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */ 1526/* Used by PRM_IRQSTATUS_DUCATI, PRM_IRQSTATUS_MPU */
1419#define OMAP4430_VP_IVA_TRANXDONE_ST_SHIFT 29 1527#define OMAP4430_VP_IVA_TRANXDONE_ST_SHIFT 29
1420#define OMAP4430_VP_IVA_TRANXDONE_ST_MASK BITFIELD(29, 29) 1528#define OMAP4430_VP_IVA_TRANXDONE_ST_MASK (1 << 29)
1421 1529
1422/* Used by PRM_IRQENABLE_MPU_2 */ 1530/* Used by PRM_IRQENABLE_MPU_2 */
1423#define OMAP4430_VP_MPU_EQVALUE_EN_SHIFT 4 1531#define OMAP4430_VP_MPU_EQVALUE_EN_SHIFT 4
1424#define OMAP4430_VP_MPU_EQVALUE_EN_MASK BITFIELD(4, 4) 1532#define OMAP4430_VP_MPU_EQVALUE_EN_MASK (1 << 4)
1425 1533
1426/* Used by PRM_IRQSTATUS_MPU_2 */ 1534/* Used by PRM_IRQSTATUS_MPU_2 */
1427#define OMAP4430_VP_MPU_EQVALUE_ST_SHIFT 4 1535#define OMAP4430_VP_MPU_EQVALUE_ST_SHIFT 4
1428#define OMAP4430_VP_MPU_EQVALUE_ST_MASK BITFIELD(4, 4) 1536#define OMAP4430_VP_MPU_EQVALUE_ST_MASK (1 << 4)
1429 1537
1430/* Used by PRM_IRQENABLE_MPU_2 */ 1538/* Used by PRM_IRQENABLE_MPU_2 */
1431#define OMAP4430_VP_MPU_MAXVDD_EN_SHIFT 2 1539#define OMAP4430_VP_MPU_MAXVDD_EN_SHIFT 2
1432#define OMAP4430_VP_MPU_MAXVDD_EN_MASK BITFIELD(2, 2) 1540#define OMAP4430_VP_MPU_MAXVDD_EN_MASK (1 << 2)
1433 1541
1434/* Used by PRM_IRQSTATUS_MPU_2 */ 1542/* Used by PRM_IRQSTATUS_MPU_2 */
1435#define OMAP4430_VP_MPU_MAXVDD_ST_SHIFT 2 1543#define OMAP4430_VP_MPU_MAXVDD_ST_SHIFT 2
1436#define OMAP4430_VP_MPU_MAXVDD_ST_MASK BITFIELD(2, 2) 1544#define OMAP4430_VP_MPU_MAXVDD_ST_MASK (1 << 2)
1437 1545
1438/* Used by PRM_IRQENABLE_MPU_2 */ 1546/* Used by PRM_IRQENABLE_MPU_2 */
1439#define OMAP4430_VP_MPU_MINVDD_EN_SHIFT 1 1547#define OMAP4430_VP_MPU_MINVDD_EN_SHIFT 1
1440#define OMAP4430_VP_MPU_MINVDD_EN_MASK BITFIELD(1, 1) 1548#define OMAP4430_VP_MPU_MINVDD_EN_MASK (1 << 1)
1441 1549
1442/* Used by PRM_IRQSTATUS_MPU_2 */ 1550/* Used by PRM_IRQSTATUS_MPU_2 */
1443#define OMAP4430_VP_MPU_MINVDD_ST_SHIFT 1 1551#define OMAP4430_VP_MPU_MINVDD_ST_SHIFT 1
1444#define OMAP4430_VP_MPU_MINVDD_ST_MASK BITFIELD(1, 1) 1552#define OMAP4430_VP_MPU_MINVDD_ST_MASK (1 << 1)
1445 1553
1446/* Used by PRM_IRQENABLE_MPU_2 */ 1554/* Used by PRM_IRQENABLE_MPU_2 */
1447#define OMAP4430_VP_MPU_NOSMPSACK_EN_SHIFT 3 1555#define OMAP4430_VP_MPU_NOSMPSACK_EN_SHIFT 3
1448#define OMAP4430_VP_MPU_NOSMPSACK_EN_MASK BITFIELD(3, 3) 1556#define OMAP4430_VP_MPU_NOSMPSACK_EN_MASK (1 << 3)
1449 1557
1450/* Used by PRM_IRQSTATUS_MPU_2 */ 1558/* Used by PRM_IRQSTATUS_MPU_2 */
1451#define OMAP4430_VP_MPU_NOSMPSACK_ST_SHIFT 3 1559#define OMAP4430_VP_MPU_NOSMPSACK_ST_SHIFT 3
1452#define OMAP4430_VP_MPU_NOSMPSACK_ST_MASK BITFIELD(3, 3) 1560#define OMAP4430_VP_MPU_NOSMPSACK_ST_MASK (1 << 3)
1453 1561
1454/* Used by PRM_IRQENABLE_MPU_2 */ 1562/* Used by PRM_IRQENABLE_MPU_2 */
1455#define OMAP4430_VP_MPU_OPPCHANGEDONE_EN_SHIFT 0 1563#define OMAP4430_VP_MPU_OPPCHANGEDONE_EN_SHIFT 0
1456#define OMAP4430_VP_MPU_OPPCHANGEDONE_EN_MASK BITFIELD(0, 0) 1564#define OMAP4430_VP_MPU_OPPCHANGEDONE_EN_MASK (1 << 0)
1457 1565
1458/* Used by PRM_IRQSTATUS_MPU_2 */ 1566/* Used by PRM_IRQSTATUS_MPU_2 */
1459#define OMAP4430_VP_MPU_OPPCHANGEDONE_ST_SHIFT 0 1567#define OMAP4430_VP_MPU_OPPCHANGEDONE_ST_SHIFT 0
1460#define OMAP4430_VP_MPU_OPPCHANGEDONE_ST_MASK BITFIELD(0, 0) 1568#define OMAP4430_VP_MPU_OPPCHANGEDONE_ST_MASK (1 << 0)
1461 1569
1462/* Used by PRM_IRQENABLE_MPU_2 */ 1570/* Used by PRM_IRQENABLE_MPU_2 */
1463#define OMAP4430_VP_MPU_TRANXDONE_EN_SHIFT 5 1571#define OMAP4430_VP_MPU_TRANXDONE_EN_SHIFT 5
1464#define OMAP4430_VP_MPU_TRANXDONE_EN_MASK BITFIELD(5, 5) 1572#define OMAP4430_VP_MPU_TRANXDONE_EN_MASK (1 << 5)
1465 1573
1466/* Used by PRM_IRQSTATUS_MPU_2 */ 1574/* Used by PRM_IRQSTATUS_MPU_2 */
1467#define OMAP4430_VP_MPU_TRANXDONE_ST_SHIFT 5 1575#define OMAP4430_VP_MPU_TRANXDONE_ST_SHIFT 5
1468#define OMAP4430_VP_MPU_TRANXDONE_ST_MASK BITFIELD(5, 5) 1576#define OMAP4430_VP_MPU_TRANXDONE_ST_MASK (1 << 5)
1469 1577
1470/* Used by PRM_SRAM_COUNT */ 1578/* Used by PRM_SRAM_COUNT */
1471#define OMAP4430_VSETUPCNT_VALUE_SHIFT 8 1579#define OMAP4430_VSETUPCNT_VALUE_SHIFT 8
1472#define OMAP4430_VSETUPCNT_VALUE_MASK BITFIELD(8, 15) 1580#define OMAP4430_VSETUPCNT_VALUE_MASK (0xff << 8)
1473 1581
1474/* Used by PRM_VP_CORE_VSTEPMAX, PRM_VP_IVA_VSTEPMAX, PRM_VP_MPU_VSTEPMAX */ 1582/* Used by PRM_VP_CORE_VSTEPMAX, PRM_VP_IVA_VSTEPMAX, PRM_VP_MPU_VSTEPMAX */
1475#define OMAP4430_VSTEPMAX_SHIFT 0 1583#define OMAP4430_VSTEPMAX_SHIFT 0
1476#define OMAP4430_VSTEPMAX_MASK BITFIELD(0, 7) 1584#define OMAP4430_VSTEPMAX_MASK (0xff << 0)
1477 1585
1478/* Used by PRM_VP_CORE_VSTEPMIN, PRM_VP_IVA_VSTEPMIN, PRM_VP_MPU_VSTEPMIN */ 1586/* Used by PRM_VP_CORE_VSTEPMIN, PRM_VP_IVA_VSTEPMIN, PRM_VP_MPU_VSTEPMIN */
1479#define OMAP4430_VSTEPMIN_SHIFT 0 1587#define OMAP4430_VSTEPMIN_SHIFT 0
1480#define OMAP4430_VSTEPMIN_MASK BITFIELD(0, 7) 1588#define OMAP4430_VSTEPMIN_MASK (0xff << 0)
1481 1589
1482/* Used by PRM_MODEM_IF_CTRL */ 1590/* Used by PRM_MODEM_IF_CTRL */
1483#define OMAP4430_WAKE_MODEM_SHIFT 0 1591#define OMAP4430_WAKE_MODEM_SHIFT 0
1484#define OMAP4430_WAKE_MODEM_MASK BITFIELD(0, 0) 1592#define OMAP4430_WAKE_MODEM_MASK (1 << 0)
1485 1593
1486/* Used by PM_DSS_DSS_WKDEP */ 1594/* Used by PM_DSS_DSS_WKDEP */
1487#define OMAP4430_WKUPDEP_DISPC_DUCATI_SHIFT 1 1595#define OMAP4430_WKUPDEP_DISPC_DUCATI_SHIFT 1
1488#define OMAP4430_WKUPDEP_DISPC_DUCATI_MASK BITFIELD(1, 1) 1596#define OMAP4430_WKUPDEP_DISPC_DUCATI_MASK (1 << 1)
1489 1597
1490/* Used by PM_DSS_DSS_WKDEP */ 1598/* Used by PM_DSS_DSS_WKDEP */
1491#define OMAP4430_WKUPDEP_DISPC_MPU_SHIFT 0 1599#define OMAP4430_WKUPDEP_DISPC_MPU_SHIFT 0
1492#define OMAP4430_WKUPDEP_DISPC_MPU_MASK BITFIELD(0, 0) 1600#define OMAP4430_WKUPDEP_DISPC_MPU_MASK (1 << 0)
1493 1601
1494/* Used by PM_DSS_DSS_WKDEP */ 1602/* Used by PM_DSS_DSS_WKDEP */
1495#define OMAP4430_WKUPDEP_DISPC_SDMA_SHIFT 3 1603#define OMAP4430_WKUPDEP_DISPC_SDMA_SHIFT 3
1496#define OMAP4430_WKUPDEP_DISPC_SDMA_MASK BITFIELD(3, 3) 1604#define OMAP4430_WKUPDEP_DISPC_SDMA_MASK (1 << 3)
1497 1605
1498/* Used by PM_DSS_DSS_WKDEP */ 1606/* Used by PM_DSS_DSS_WKDEP */
1499#define OMAP4430_WKUPDEP_DISPC_TESLA_SHIFT 2 1607#define OMAP4430_WKUPDEP_DISPC_TESLA_SHIFT 2
1500#define OMAP4430_WKUPDEP_DISPC_TESLA_MASK BITFIELD(2, 2) 1608#define OMAP4430_WKUPDEP_DISPC_TESLA_MASK (1 << 2)
1501 1609
1502/* Used by PM_ABE_DMIC_WKDEP */ 1610/* Used by PM_ABE_DMIC_WKDEP */
1503#define OMAP4430_WKUPDEP_DMIC_DMA_SDMA_SHIFT 7 1611#define OMAP4430_WKUPDEP_DMIC_DMA_SDMA_SHIFT 7
1504#define OMAP4430_WKUPDEP_DMIC_DMA_SDMA_MASK BITFIELD(7, 7) 1612#define OMAP4430_WKUPDEP_DMIC_DMA_SDMA_MASK (1 << 7)
1505 1613
1506/* Used by PM_ABE_DMIC_WKDEP */ 1614/* Used by PM_ABE_DMIC_WKDEP */
1507#define OMAP4430_WKUPDEP_DMIC_DMA_TESLA_SHIFT 6 1615#define OMAP4430_WKUPDEP_DMIC_DMA_TESLA_SHIFT 6
1508#define OMAP4430_WKUPDEP_DMIC_DMA_TESLA_MASK BITFIELD(6, 6) 1616#define OMAP4430_WKUPDEP_DMIC_DMA_TESLA_MASK (1 << 6)
1509 1617
1510/* Used by PM_ABE_DMIC_WKDEP */ 1618/* Used by PM_ABE_DMIC_WKDEP */
1511#define OMAP4430_WKUPDEP_DMIC_IRQ_MPU_SHIFT 0 1619#define OMAP4430_WKUPDEP_DMIC_IRQ_MPU_SHIFT 0
1512#define OMAP4430_WKUPDEP_DMIC_IRQ_MPU_MASK BITFIELD(0, 0) 1620#define OMAP4430_WKUPDEP_DMIC_IRQ_MPU_MASK (1 << 0)
1513 1621
1514/* Used by PM_ABE_DMIC_WKDEP */ 1622/* Used by PM_ABE_DMIC_WKDEP */
1515#define OMAP4430_WKUPDEP_DMIC_IRQ_TESLA_SHIFT 2 1623#define OMAP4430_WKUPDEP_DMIC_IRQ_TESLA_SHIFT 2
1516#define OMAP4430_WKUPDEP_DMIC_IRQ_TESLA_MASK BITFIELD(2, 2) 1624#define OMAP4430_WKUPDEP_DMIC_IRQ_TESLA_MASK (1 << 2)
1517 1625
1518/* Used by PM_L4PER_DMTIMER10_WKDEP */ 1626/* Used by PM_L4PER_DMTIMER10_WKDEP */
1519#define OMAP4430_WKUPDEP_DMTIMER10_MPU_SHIFT 0 1627#define OMAP4430_WKUPDEP_DMTIMER10_MPU_SHIFT 0
1520#define OMAP4430_WKUPDEP_DMTIMER10_MPU_MASK BITFIELD(0, 0) 1628#define OMAP4430_WKUPDEP_DMTIMER10_MPU_MASK (1 << 0)
1521 1629
1522/* Used by PM_L4PER_DMTIMER11_WKDEP */ 1630/* Used by PM_L4PER_DMTIMER11_WKDEP */
1523#define OMAP4430_WKUPDEP_DMTIMER11_DUCATI_SHIFT 1 1631#define OMAP4430_WKUPDEP_DMTIMER11_DUCATI_SHIFT 1
1524#define OMAP4430_WKUPDEP_DMTIMER11_DUCATI_MASK BITFIELD(1, 1) 1632#define OMAP4430_WKUPDEP_DMTIMER11_DUCATI_MASK (1 << 1)
1525 1633
1526/* Used by PM_L4PER_DMTIMER11_WKDEP */ 1634/* Used by PM_L4PER_DMTIMER11_WKDEP */
1527#define OMAP4430_WKUPDEP_DMTIMER11_MPU_SHIFT 0 1635#define OMAP4430_WKUPDEP_DMTIMER11_MPU_SHIFT 0
1528#define OMAP4430_WKUPDEP_DMTIMER11_MPU_MASK BITFIELD(0, 0) 1636#define OMAP4430_WKUPDEP_DMTIMER11_MPU_MASK (1 << 0)
1529 1637
1530/* Used by PM_L4PER_DMTIMER2_WKDEP */ 1638/* Used by PM_L4PER_DMTIMER2_WKDEP */
1531#define OMAP4430_WKUPDEP_DMTIMER2_MPU_SHIFT 0 1639#define OMAP4430_WKUPDEP_DMTIMER2_MPU_SHIFT 0
1532#define OMAP4430_WKUPDEP_DMTIMER2_MPU_MASK BITFIELD(0, 0) 1640#define OMAP4430_WKUPDEP_DMTIMER2_MPU_MASK (1 << 0)
1533 1641
1534/* Used by PM_L4PER_DMTIMER3_WKDEP */ 1642/* Used by PM_L4PER_DMTIMER3_WKDEP */
1535#define OMAP4430_WKUPDEP_DMTIMER3_DUCATI_SHIFT 1 1643#define OMAP4430_WKUPDEP_DMTIMER3_DUCATI_SHIFT 1
1536#define OMAP4430_WKUPDEP_DMTIMER3_DUCATI_MASK BITFIELD(1, 1) 1644#define OMAP4430_WKUPDEP_DMTIMER3_DUCATI_MASK (1 << 1)
1537 1645
1538/* Used by PM_L4PER_DMTIMER3_WKDEP */ 1646/* Used by PM_L4PER_DMTIMER3_WKDEP */
1539#define OMAP4430_WKUPDEP_DMTIMER3_MPU_SHIFT 0 1647#define OMAP4430_WKUPDEP_DMTIMER3_MPU_SHIFT 0
1540#define OMAP4430_WKUPDEP_DMTIMER3_MPU_MASK BITFIELD(0, 0) 1648#define OMAP4430_WKUPDEP_DMTIMER3_MPU_MASK (1 << 0)
1541 1649
1542/* Used by PM_L4PER_DMTIMER4_WKDEP */ 1650/* Used by PM_L4PER_DMTIMER4_WKDEP */
1543#define OMAP4430_WKUPDEP_DMTIMER4_DUCATI_SHIFT 1 1651#define OMAP4430_WKUPDEP_DMTIMER4_DUCATI_SHIFT 1
1544#define OMAP4430_WKUPDEP_DMTIMER4_DUCATI_MASK BITFIELD(1, 1) 1652#define OMAP4430_WKUPDEP_DMTIMER4_DUCATI_MASK (1 << 1)
1545 1653
1546/* Used by PM_L4PER_DMTIMER4_WKDEP */ 1654/* Used by PM_L4PER_DMTIMER4_WKDEP */
1547#define OMAP4430_WKUPDEP_DMTIMER4_MPU_SHIFT 0 1655#define OMAP4430_WKUPDEP_DMTIMER4_MPU_SHIFT 0
1548#define OMAP4430_WKUPDEP_DMTIMER4_MPU_MASK BITFIELD(0, 0) 1656#define OMAP4430_WKUPDEP_DMTIMER4_MPU_MASK (1 << 0)
1549 1657
1550/* Used by PM_L4PER_DMTIMER9_WKDEP */ 1658/* Used by PM_L4PER_DMTIMER9_WKDEP */
1551#define OMAP4430_WKUPDEP_DMTIMER9_DUCATI_SHIFT 1 1659#define OMAP4430_WKUPDEP_DMTIMER9_DUCATI_SHIFT 1
1552#define OMAP4430_WKUPDEP_DMTIMER9_DUCATI_MASK BITFIELD(1, 1) 1660#define OMAP4430_WKUPDEP_DMTIMER9_DUCATI_MASK (1 << 1)
1553 1661
1554/* Used by PM_L4PER_DMTIMER9_WKDEP */ 1662/* Used by PM_L4PER_DMTIMER9_WKDEP */
1555#define OMAP4430_WKUPDEP_DMTIMER9_MPU_SHIFT 0 1663#define OMAP4430_WKUPDEP_DMTIMER9_MPU_SHIFT 0
1556#define OMAP4430_WKUPDEP_DMTIMER9_MPU_MASK BITFIELD(0, 0) 1664#define OMAP4430_WKUPDEP_DMTIMER9_MPU_MASK (1 << 0)
1557 1665
1558/* Used by PM_DSS_DSS_WKDEP */ 1666/* Used by PM_DSS_DSS_WKDEP */
1559#define OMAP4430_WKUPDEP_DSI1_DUCATI_SHIFT 5 1667#define OMAP4430_WKUPDEP_DSI1_DUCATI_SHIFT 5
1560#define OMAP4430_WKUPDEP_DSI1_DUCATI_MASK BITFIELD(5, 5) 1668#define OMAP4430_WKUPDEP_DSI1_DUCATI_MASK (1 << 5)
1561 1669
1562/* Used by PM_DSS_DSS_WKDEP */ 1670/* Used by PM_DSS_DSS_WKDEP */
1563#define OMAP4430_WKUPDEP_DSI1_MPU_SHIFT 4 1671#define OMAP4430_WKUPDEP_DSI1_MPU_SHIFT 4
1564#define OMAP4430_WKUPDEP_DSI1_MPU_MASK BITFIELD(4, 4) 1672#define OMAP4430_WKUPDEP_DSI1_MPU_MASK (1 << 4)
1565 1673
1566/* Used by PM_DSS_DSS_WKDEP */ 1674/* Used by PM_DSS_DSS_WKDEP */
1567#define OMAP4430_WKUPDEP_DSI1_SDMA_SHIFT 7 1675#define OMAP4430_WKUPDEP_DSI1_SDMA_SHIFT 7
1568#define OMAP4430_WKUPDEP_DSI1_SDMA_MASK BITFIELD(7, 7) 1676#define OMAP4430_WKUPDEP_DSI1_SDMA_MASK (1 << 7)
1569 1677
1570/* Used by PM_DSS_DSS_WKDEP */ 1678/* Used by PM_DSS_DSS_WKDEP */
1571#define OMAP4430_WKUPDEP_DSI1_TESLA_SHIFT 6 1679#define OMAP4430_WKUPDEP_DSI1_TESLA_SHIFT 6
1572#define OMAP4430_WKUPDEP_DSI1_TESLA_MASK BITFIELD(6, 6) 1680#define OMAP4430_WKUPDEP_DSI1_TESLA_MASK (1 << 6)
1573 1681
1574/* Used by PM_DSS_DSS_WKDEP */ 1682/* Used by PM_DSS_DSS_WKDEP */
1575#define OMAP4430_WKUPDEP_DSI2_DUCATI_SHIFT 9 1683#define OMAP4430_WKUPDEP_DSI2_DUCATI_SHIFT 9
1576#define OMAP4430_WKUPDEP_DSI2_DUCATI_MASK BITFIELD(9, 9) 1684#define OMAP4430_WKUPDEP_DSI2_DUCATI_MASK (1 << 9)
1577 1685
1578/* Used by PM_DSS_DSS_WKDEP */ 1686/* Used by PM_DSS_DSS_WKDEP */
1579#define OMAP4430_WKUPDEP_DSI2_MPU_SHIFT 8 1687#define OMAP4430_WKUPDEP_DSI2_MPU_SHIFT 8
1580#define OMAP4430_WKUPDEP_DSI2_MPU_MASK BITFIELD(8, 8) 1688#define OMAP4430_WKUPDEP_DSI2_MPU_MASK (1 << 8)
1581 1689
1582/* Used by PM_DSS_DSS_WKDEP */ 1690/* Used by PM_DSS_DSS_WKDEP */
1583#define OMAP4430_WKUPDEP_DSI2_SDMA_SHIFT 11 1691#define OMAP4430_WKUPDEP_DSI2_SDMA_SHIFT 11
1584#define OMAP4430_WKUPDEP_DSI2_SDMA_MASK BITFIELD(11, 11) 1692#define OMAP4430_WKUPDEP_DSI2_SDMA_MASK (1 << 11)
1585 1693
1586/* Used by PM_DSS_DSS_WKDEP */ 1694/* Used by PM_DSS_DSS_WKDEP */
1587#define OMAP4430_WKUPDEP_DSI2_TESLA_SHIFT 10 1695#define OMAP4430_WKUPDEP_DSI2_TESLA_SHIFT 10
1588#define OMAP4430_WKUPDEP_DSI2_TESLA_MASK BITFIELD(10, 10) 1696#define OMAP4430_WKUPDEP_DSI2_TESLA_MASK (1 << 10)
1589 1697
1590/* Used by PM_WKUP_GPIO1_WKDEP */ 1698/* Used by PM_WKUP_GPIO1_WKDEP */
1591#define OMAP4430_WKUPDEP_GPIO1_IRQ1_DUCATI_SHIFT 1 1699#define OMAP4430_WKUPDEP_GPIO1_IRQ1_DUCATI_SHIFT 1
1592#define OMAP4430_WKUPDEP_GPIO1_IRQ1_DUCATI_MASK BITFIELD(1, 1) 1700#define OMAP4430_WKUPDEP_GPIO1_IRQ1_DUCATI_MASK (1 << 1)
1593 1701
1594/* Used by PM_WKUP_GPIO1_WKDEP */ 1702/* Used by PM_WKUP_GPIO1_WKDEP */
1595#define OMAP4430_WKUPDEP_GPIO1_IRQ1_MPU_SHIFT 0 1703#define OMAP4430_WKUPDEP_GPIO1_IRQ1_MPU_SHIFT 0
1596#define OMAP4430_WKUPDEP_GPIO1_IRQ1_MPU_MASK BITFIELD(0, 0) 1704#define OMAP4430_WKUPDEP_GPIO1_IRQ1_MPU_MASK (1 << 0)
1597 1705
1598/* Used by PM_WKUP_GPIO1_WKDEP */ 1706/* Used by PM_WKUP_GPIO1_WKDEP */
1599#define OMAP4430_WKUPDEP_GPIO1_IRQ2_TESLA_SHIFT 6 1707#define OMAP4430_WKUPDEP_GPIO1_IRQ2_TESLA_SHIFT 6
1600#define OMAP4430_WKUPDEP_GPIO1_IRQ2_TESLA_MASK BITFIELD(6, 6) 1708#define OMAP4430_WKUPDEP_GPIO1_IRQ2_TESLA_MASK (1 << 6)
1601 1709
1602/* Used by PM_L4PER_GPIO2_WKDEP */ 1710/* Used by PM_L4PER_GPIO2_WKDEP */
1603#define OMAP4430_WKUPDEP_GPIO2_IRQ1_DUCATI_SHIFT 1 1711#define OMAP4430_WKUPDEP_GPIO2_IRQ1_DUCATI_SHIFT 1
1604#define OMAP4430_WKUPDEP_GPIO2_IRQ1_DUCATI_MASK BITFIELD(1, 1) 1712#define OMAP4430_WKUPDEP_GPIO2_IRQ1_DUCATI_MASK (1 << 1)
1605 1713
1606/* Used by PM_L4PER_GPIO2_WKDEP */ 1714/* Used by PM_L4PER_GPIO2_WKDEP */
1607#define OMAP4430_WKUPDEP_GPIO2_IRQ1_MPU_SHIFT 0 1715#define OMAP4430_WKUPDEP_GPIO2_IRQ1_MPU_SHIFT 0
1608#define OMAP4430_WKUPDEP_GPIO2_IRQ1_MPU_MASK BITFIELD(0, 0) 1716#define OMAP4430_WKUPDEP_GPIO2_IRQ1_MPU_MASK (1 << 0)
1609 1717
1610/* Used by PM_L4PER_GPIO2_WKDEP */ 1718/* Used by PM_L4PER_GPIO2_WKDEP */
1611#define OMAP4430_WKUPDEP_GPIO2_IRQ2_TESLA_SHIFT 6 1719#define OMAP4430_WKUPDEP_GPIO2_IRQ2_TESLA_SHIFT 6
1612#define OMAP4430_WKUPDEP_GPIO2_IRQ2_TESLA_MASK BITFIELD(6, 6) 1720#define OMAP4430_WKUPDEP_GPIO2_IRQ2_TESLA_MASK (1 << 6)
1613 1721
1614/* Used by PM_L4PER_GPIO3_WKDEP */ 1722/* Used by PM_L4PER_GPIO3_WKDEP */
1615#define OMAP4430_WKUPDEP_GPIO3_IRQ1_MPU_SHIFT 0 1723#define OMAP4430_WKUPDEP_GPIO3_IRQ1_MPU_SHIFT 0
1616#define OMAP4430_WKUPDEP_GPIO3_IRQ1_MPU_MASK BITFIELD(0, 0) 1724#define OMAP4430_WKUPDEP_GPIO3_IRQ1_MPU_MASK (1 << 0)
1617 1725
1618/* Used by PM_L4PER_GPIO3_WKDEP */ 1726/* Used by PM_L4PER_GPIO3_WKDEP */
1619#define OMAP4430_WKUPDEP_GPIO3_IRQ2_TESLA_SHIFT 6 1727#define OMAP4430_WKUPDEP_GPIO3_IRQ2_TESLA_SHIFT 6
1620#define OMAP4430_WKUPDEP_GPIO3_IRQ2_TESLA_MASK BITFIELD(6, 6) 1728#define OMAP4430_WKUPDEP_GPIO3_IRQ2_TESLA_MASK (1 << 6)
1621 1729
1622/* Used by PM_L4PER_GPIO4_WKDEP */ 1730/* Used by PM_L4PER_GPIO4_WKDEP */
1623#define OMAP4430_WKUPDEP_GPIO4_IRQ1_MPU_SHIFT 0 1731#define OMAP4430_WKUPDEP_GPIO4_IRQ1_MPU_SHIFT 0
1624#define OMAP4430_WKUPDEP_GPIO4_IRQ1_MPU_MASK BITFIELD(0, 0) 1732#define OMAP4430_WKUPDEP_GPIO4_IRQ1_MPU_MASK (1 << 0)
1625 1733
1626/* Used by PM_L4PER_GPIO4_WKDEP */ 1734/* Used by PM_L4PER_GPIO4_WKDEP */
1627#define OMAP4430_WKUPDEP_GPIO4_IRQ2_TESLA_SHIFT 6 1735#define OMAP4430_WKUPDEP_GPIO4_IRQ2_TESLA_SHIFT 6
1628#define OMAP4430_WKUPDEP_GPIO4_IRQ2_TESLA_MASK BITFIELD(6, 6) 1736#define OMAP4430_WKUPDEP_GPIO4_IRQ2_TESLA_MASK (1 << 6)
1629 1737
1630/* Used by PM_L4PER_GPIO5_WKDEP */ 1738/* Used by PM_L4PER_GPIO5_WKDEP */
1631#define OMAP4430_WKUPDEP_GPIO5_IRQ1_MPU_SHIFT 0 1739#define OMAP4430_WKUPDEP_GPIO5_IRQ1_MPU_SHIFT 0
1632#define OMAP4430_WKUPDEP_GPIO5_IRQ1_MPU_MASK BITFIELD(0, 0) 1740#define OMAP4430_WKUPDEP_GPIO5_IRQ1_MPU_MASK (1 << 0)
1633 1741
1634/* Used by PM_L4PER_GPIO5_WKDEP */ 1742/* Used by PM_L4PER_GPIO5_WKDEP */
1635#define OMAP4430_WKUPDEP_GPIO5_IRQ2_TESLA_SHIFT 6 1743#define OMAP4430_WKUPDEP_GPIO5_IRQ2_TESLA_SHIFT 6
1636#define OMAP4430_WKUPDEP_GPIO5_IRQ2_TESLA_MASK BITFIELD(6, 6) 1744#define OMAP4430_WKUPDEP_GPIO5_IRQ2_TESLA_MASK (1 << 6)
1637 1745
1638/* Used by PM_L4PER_GPIO6_WKDEP */ 1746/* Used by PM_L4PER_GPIO6_WKDEP */
1639#define OMAP4430_WKUPDEP_GPIO6_IRQ1_MPU_SHIFT 0 1747#define OMAP4430_WKUPDEP_GPIO6_IRQ1_MPU_SHIFT 0
1640#define OMAP4430_WKUPDEP_GPIO6_IRQ1_MPU_MASK BITFIELD(0, 0) 1748#define OMAP4430_WKUPDEP_GPIO6_IRQ1_MPU_MASK (1 << 0)
1641 1749
1642/* Used by PM_L4PER_GPIO6_WKDEP */ 1750/* Used by PM_L4PER_GPIO6_WKDEP */
1643#define OMAP4430_WKUPDEP_GPIO6_IRQ2_TESLA_SHIFT 6 1751#define OMAP4430_WKUPDEP_GPIO6_IRQ2_TESLA_SHIFT 6
1644#define OMAP4430_WKUPDEP_GPIO6_IRQ2_TESLA_MASK BITFIELD(6, 6) 1752#define OMAP4430_WKUPDEP_GPIO6_IRQ2_TESLA_MASK (1 << 6)
1645 1753
1646/* Used by PM_DSS_DSS_WKDEP */ 1754/* Used by PM_DSS_DSS_WKDEP */
1647#define OMAP4430_WKUPDEP_HDMIDMA_SDMA_SHIFT 19 1755#define OMAP4430_WKUPDEP_HDMIDMA_SDMA_SHIFT 19
1648#define OMAP4430_WKUPDEP_HDMIDMA_SDMA_MASK BITFIELD(19, 19) 1756#define OMAP4430_WKUPDEP_HDMIDMA_SDMA_MASK (1 << 19)
1649 1757
1650/* Used by PM_DSS_DSS_WKDEP */ 1758/* Used by PM_DSS_DSS_WKDEP */
1651#define OMAP4430_WKUPDEP_HDMIIRQ_DUCATI_SHIFT 13 1759#define OMAP4430_WKUPDEP_HDMIIRQ_DUCATI_SHIFT 13
1652#define OMAP4430_WKUPDEP_HDMIIRQ_DUCATI_MASK BITFIELD(13, 13) 1760#define OMAP4430_WKUPDEP_HDMIIRQ_DUCATI_MASK (1 << 13)
1653 1761
1654/* Used by PM_DSS_DSS_WKDEP */ 1762/* Used by PM_DSS_DSS_WKDEP */
1655#define OMAP4430_WKUPDEP_HDMIIRQ_MPU_SHIFT 12 1763#define OMAP4430_WKUPDEP_HDMIIRQ_MPU_SHIFT 12
1656#define OMAP4430_WKUPDEP_HDMIIRQ_MPU_MASK BITFIELD(12, 12) 1764#define OMAP4430_WKUPDEP_HDMIIRQ_MPU_MASK (1 << 12)
1657 1765
1658/* Used by PM_DSS_DSS_WKDEP */ 1766/* Used by PM_DSS_DSS_WKDEP */
1659#define OMAP4430_WKUPDEP_HDMIIRQ_TESLA_SHIFT 14 1767#define OMAP4430_WKUPDEP_HDMIIRQ_TESLA_SHIFT 14
1660#define OMAP4430_WKUPDEP_HDMIIRQ_TESLA_MASK BITFIELD(14, 14) 1768#define OMAP4430_WKUPDEP_HDMIIRQ_TESLA_MASK (1 << 14)
1661 1769
1662/* Used by PM_L4PER_HECC1_WKDEP */ 1770/* Used by PM_L4PER_HECC1_WKDEP */
1663#define OMAP4430_WKUPDEP_HECC1_MPU_SHIFT 0 1771#define OMAP4430_WKUPDEP_HECC1_MPU_SHIFT 0
1664#define OMAP4430_WKUPDEP_HECC1_MPU_MASK BITFIELD(0, 0) 1772#define OMAP4430_WKUPDEP_HECC1_MPU_MASK (1 << 0)
1665 1773
1666/* Used by PM_L4PER_HECC2_WKDEP */ 1774/* Used by PM_L4PER_HECC2_WKDEP */
1667#define OMAP4430_WKUPDEP_HECC2_MPU_SHIFT 0 1775#define OMAP4430_WKUPDEP_HECC2_MPU_SHIFT 0
1668#define OMAP4430_WKUPDEP_HECC2_MPU_MASK BITFIELD(0, 0) 1776#define OMAP4430_WKUPDEP_HECC2_MPU_MASK (1 << 0)
1669 1777
1670/* Used by PM_L3INIT_HSI_WKDEP */ 1778/* Used by PM_L3INIT_HSI_WKDEP */
1671#define OMAP4430_WKUPDEP_HSI_DSP_TESLA_SHIFT 6 1779#define OMAP4430_WKUPDEP_HSI_DSP_TESLA_SHIFT 6
1672#define OMAP4430_WKUPDEP_HSI_DSP_TESLA_MASK BITFIELD(6, 6) 1780#define OMAP4430_WKUPDEP_HSI_DSP_TESLA_MASK (1 << 6)
1673 1781
1674/* Used by PM_L3INIT_HSI_WKDEP */ 1782/* Used by PM_L3INIT_HSI_WKDEP */
1675#define OMAP4430_WKUPDEP_HSI_MCU_DUCATI_SHIFT 1 1783#define OMAP4430_WKUPDEP_HSI_MCU_DUCATI_SHIFT 1
1676#define OMAP4430_WKUPDEP_HSI_MCU_DUCATI_MASK BITFIELD(1, 1) 1784#define OMAP4430_WKUPDEP_HSI_MCU_DUCATI_MASK (1 << 1)
1677 1785
1678/* Used by PM_L3INIT_HSI_WKDEP */ 1786/* Used by PM_L3INIT_HSI_WKDEP */
1679#define OMAP4430_WKUPDEP_HSI_MCU_MPU_SHIFT 0 1787#define OMAP4430_WKUPDEP_HSI_MCU_MPU_SHIFT 0
1680#define OMAP4430_WKUPDEP_HSI_MCU_MPU_MASK BITFIELD(0, 0) 1788#define OMAP4430_WKUPDEP_HSI_MCU_MPU_MASK (1 << 0)
1681 1789
1682/* Used by PM_L4PER_I2C1_WKDEP */ 1790/* Used by PM_L4PER_I2C1_WKDEP */
1683#define OMAP4430_WKUPDEP_I2C1_DMA_SDMA_SHIFT 7 1791#define OMAP4430_WKUPDEP_I2C1_DMA_SDMA_SHIFT 7
1684#define OMAP4430_WKUPDEP_I2C1_DMA_SDMA_MASK BITFIELD(7, 7) 1792#define OMAP4430_WKUPDEP_I2C1_DMA_SDMA_MASK (1 << 7)
1685 1793
1686/* Used by PM_L4PER_I2C1_WKDEP */ 1794/* Used by PM_L4PER_I2C1_WKDEP */
1687#define OMAP4430_WKUPDEP_I2C1_IRQ_DUCATI_SHIFT 1 1795#define OMAP4430_WKUPDEP_I2C1_IRQ_DUCATI_SHIFT 1
1688#define OMAP4430_WKUPDEP_I2C1_IRQ_DUCATI_MASK BITFIELD(1, 1) 1796#define OMAP4430_WKUPDEP_I2C1_IRQ_DUCATI_MASK (1 << 1)
1689 1797
1690/* Used by PM_L4PER_I2C1_WKDEP */ 1798/* Used by PM_L4PER_I2C1_WKDEP */
1691#define OMAP4430_WKUPDEP_I2C1_IRQ_MPU_SHIFT 0 1799#define OMAP4430_WKUPDEP_I2C1_IRQ_MPU_SHIFT 0
1692#define OMAP4430_WKUPDEP_I2C1_IRQ_MPU_MASK BITFIELD(0, 0) 1800#define OMAP4430_WKUPDEP_I2C1_IRQ_MPU_MASK (1 << 0)
1693 1801
1694/* Used by PM_L4PER_I2C2_WKDEP */ 1802/* Used by PM_L4PER_I2C2_WKDEP */
1695#define OMAP4430_WKUPDEP_I2C2_DMA_SDMA_SHIFT 7 1803#define OMAP4430_WKUPDEP_I2C2_DMA_SDMA_SHIFT 7
1696#define OMAP4430_WKUPDEP_I2C2_DMA_SDMA_MASK BITFIELD(7, 7) 1804#define OMAP4430_WKUPDEP_I2C2_DMA_SDMA_MASK (1 << 7)
1697 1805
1698/* Used by PM_L4PER_I2C2_WKDEP */ 1806/* Used by PM_L4PER_I2C2_WKDEP */
1699#define OMAP4430_WKUPDEP_I2C2_IRQ_DUCATI_SHIFT 1 1807#define OMAP4430_WKUPDEP_I2C2_IRQ_DUCATI_SHIFT 1
1700#define OMAP4430_WKUPDEP_I2C2_IRQ_DUCATI_MASK BITFIELD(1, 1) 1808#define OMAP4430_WKUPDEP_I2C2_IRQ_DUCATI_MASK (1 << 1)
1701 1809
1702/* Used by PM_L4PER_I2C2_WKDEP */ 1810/* Used by PM_L4PER_I2C2_WKDEP */
1703#define OMAP4430_WKUPDEP_I2C2_IRQ_MPU_SHIFT 0 1811#define OMAP4430_WKUPDEP_I2C2_IRQ_MPU_SHIFT 0
1704#define OMAP4430_WKUPDEP_I2C2_IRQ_MPU_MASK BITFIELD(0, 0) 1812#define OMAP4430_WKUPDEP_I2C2_IRQ_MPU_MASK (1 << 0)
1705 1813
1706/* Used by PM_L4PER_I2C3_WKDEP */ 1814/* Used by PM_L4PER_I2C3_WKDEP */
1707#define OMAP4430_WKUPDEP_I2C3_DMA_SDMA_SHIFT 7 1815#define OMAP4430_WKUPDEP_I2C3_DMA_SDMA_SHIFT 7
1708#define OMAP4430_WKUPDEP_I2C3_DMA_SDMA_MASK BITFIELD(7, 7) 1816#define OMAP4430_WKUPDEP_I2C3_DMA_SDMA_MASK (1 << 7)
1709 1817
1710/* Used by PM_L4PER_I2C3_WKDEP */ 1818/* Used by PM_L4PER_I2C3_WKDEP */
1711#define OMAP4430_WKUPDEP_I2C3_IRQ_DUCATI_SHIFT 1 1819#define OMAP4430_WKUPDEP_I2C3_IRQ_DUCATI_SHIFT 1
1712#define OMAP4430_WKUPDEP_I2C3_IRQ_DUCATI_MASK BITFIELD(1, 1) 1820#define OMAP4430_WKUPDEP_I2C3_IRQ_DUCATI_MASK (1 << 1)
1713 1821
1714/* Used by PM_L4PER_I2C3_WKDEP */ 1822/* Used by PM_L4PER_I2C3_WKDEP */
1715#define OMAP4430_WKUPDEP_I2C3_IRQ_MPU_SHIFT 0 1823#define OMAP4430_WKUPDEP_I2C3_IRQ_MPU_SHIFT 0
1716#define OMAP4430_WKUPDEP_I2C3_IRQ_MPU_MASK BITFIELD(0, 0) 1824#define OMAP4430_WKUPDEP_I2C3_IRQ_MPU_MASK (1 << 0)
1717 1825
1718/* Used by PM_L4PER_I2C4_WKDEP */ 1826/* Used by PM_L4PER_I2C4_WKDEP */
1719#define OMAP4430_WKUPDEP_I2C4_DMA_SDMA_SHIFT 7 1827#define OMAP4430_WKUPDEP_I2C4_DMA_SDMA_SHIFT 7
1720#define OMAP4430_WKUPDEP_I2C4_DMA_SDMA_MASK BITFIELD(7, 7) 1828#define OMAP4430_WKUPDEP_I2C4_DMA_SDMA_MASK (1 << 7)
1721 1829
1722/* Used by PM_L4PER_I2C4_WKDEP */ 1830/* Used by PM_L4PER_I2C4_WKDEP */
1723#define OMAP4430_WKUPDEP_I2C4_IRQ_DUCATI_SHIFT 1 1831#define OMAP4430_WKUPDEP_I2C4_IRQ_DUCATI_SHIFT 1
1724#define OMAP4430_WKUPDEP_I2C4_IRQ_DUCATI_MASK BITFIELD(1, 1) 1832#define OMAP4430_WKUPDEP_I2C4_IRQ_DUCATI_MASK (1 << 1)
1725 1833
1726/* Used by PM_L4PER_I2C4_WKDEP */ 1834/* Used by PM_L4PER_I2C4_WKDEP */
1727#define OMAP4430_WKUPDEP_I2C4_IRQ_MPU_SHIFT 0 1835#define OMAP4430_WKUPDEP_I2C4_IRQ_MPU_SHIFT 0
1728#define OMAP4430_WKUPDEP_I2C4_IRQ_MPU_MASK BITFIELD(0, 0) 1836#define OMAP4430_WKUPDEP_I2C4_IRQ_MPU_MASK (1 << 0)
1729 1837
1730/* Used by PM_L4PER_I2C5_WKDEP */ 1838/* Used by PM_L4PER_I2C5_WKDEP */
1731#define OMAP4430_WKUPDEP_I2C5_DMA_SDMA_SHIFT 7 1839#define OMAP4430_WKUPDEP_I2C5_DMA_SDMA_SHIFT 7
1732#define OMAP4430_WKUPDEP_I2C5_DMA_SDMA_MASK BITFIELD(7, 7) 1840#define OMAP4430_WKUPDEP_I2C5_DMA_SDMA_MASK (1 << 7)
1733 1841
1734/* Used by PM_L4PER_I2C5_WKDEP */ 1842/* Used by PM_L4PER_I2C5_WKDEP */
1735#define OMAP4430_WKUPDEP_I2C5_IRQ_MPU_SHIFT 0 1843#define OMAP4430_WKUPDEP_I2C5_IRQ_MPU_SHIFT 0
1736#define OMAP4430_WKUPDEP_I2C5_IRQ_MPU_MASK BITFIELD(0, 0) 1844#define OMAP4430_WKUPDEP_I2C5_IRQ_MPU_MASK (1 << 0)
1737 1845
1738/* Used by PM_WKUP_KEYBOARD_WKDEP */ 1846/* Used by PM_WKUP_KEYBOARD_WKDEP */
1739#define OMAP4430_WKUPDEP_KEYBOARD_MPU_SHIFT 0 1847#define OMAP4430_WKUPDEP_KEYBOARD_MPU_SHIFT 0
1740#define OMAP4430_WKUPDEP_KEYBOARD_MPU_MASK BITFIELD(0, 0) 1848#define OMAP4430_WKUPDEP_KEYBOARD_MPU_MASK (1 << 0)
1741 1849
1742/* Used by PM_ABE_MCASP_WKDEP */ 1850/* Used by PM_ABE_MCASP_WKDEP */
1743#define OMAP4430_WKUPDEP_MCASP1_DMA_SDMA_SHIFT 7 1851#define OMAP4430_WKUPDEP_MCASP1_DMA_SDMA_SHIFT 7
1744#define OMAP4430_WKUPDEP_MCASP1_DMA_SDMA_MASK BITFIELD(7, 7) 1852#define OMAP4430_WKUPDEP_MCASP1_DMA_SDMA_MASK (1 << 7)
1745 1853
1746/* Used by PM_ABE_MCASP_WKDEP */ 1854/* Used by PM_ABE_MCASP_WKDEP */
1747#define OMAP4430_WKUPDEP_MCASP1_DMA_TESLA_SHIFT 6 1855#define OMAP4430_WKUPDEP_MCASP1_DMA_TESLA_SHIFT 6
1748#define OMAP4430_WKUPDEP_MCASP1_DMA_TESLA_MASK BITFIELD(6, 6) 1856#define OMAP4430_WKUPDEP_MCASP1_DMA_TESLA_MASK (1 << 6)
1749 1857
1750/* Used by PM_ABE_MCASP_WKDEP */ 1858/* Used by PM_ABE_MCASP_WKDEP */
1751#define OMAP4430_WKUPDEP_MCASP1_IRQ_MPU_SHIFT 0 1859#define OMAP4430_WKUPDEP_MCASP1_IRQ_MPU_SHIFT 0
1752#define OMAP4430_WKUPDEP_MCASP1_IRQ_MPU_MASK BITFIELD(0, 0) 1860#define OMAP4430_WKUPDEP_MCASP1_IRQ_MPU_MASK (1 << 0)
1753 1861
1754/* Used by PM_ABE_MCASP_WKDEP */ 1862/* Used by PM_ABE_MCASP_WKDEP */
1755#define OMAP4430_WKUPDEP_MCASP1_IRQ_TESLA_SHIFT 2 1863#define OMAP4430_WKUPDEP_MCASP1_IRQ_TESLA_SHIFT 2
1756#define OMAP4430_WKUPDEP_MCASP1_IRQ_TESLA_MASK BITFIELD(2, 2) 1864#define OMAP4430_WKUPDEP_MCASP1_IRQ_TESLA_MASK (1 << 2)
1757 1865
1758/* Used by PM_L4PER_MCASP2_WKDEP */ 1866/* Used by PM_L4PER_MCASP2_WKDEP */
1759#define OMAP4430_WKUPDEP_MCASP2_DMA_SDMA_SHIFT 7 1867#define OMAP4430_WKUPDEP_MCASP2_DMA_SDMA_SHIFT 7
1760#define OMAP4430_WKUPDEP_MCASP2_DMA_SDMA_MASK BITFIELD(7, 7) 1868#define OMAP4430_WKUPDEP_MCASP2_DMA_SDMA_MASK (1 << 7)
1761 1869
1762/* Used by PM_L4PER_MCASP2_WKDEP */ 1870/* Used by PM_L4PER_MCASP2_WKDEP */
1763#define OMAP4430_WKUPDEP_MCASP2_DMA_TESLA_SHIFT 6 1871#define OMAP4430_WKUPDEP_MCASP2_DMA_TESLA_SHIFT 6
1764#define OMAP4430_WKUPDEP_MCASP2_DMA_TESLA_MASK BITFIELD(6, 6) 1872#define OMAP4430_WKUPDEP_MCASP2_DMA_TESLA_MASK (1 << 6)
1765 1873
1766/* Used by PM_L4PER_MCASP2_WKDEP */ 1874/* Used by PM_L4PER_MCASP2_WKDEP */
1767#define OMAP4430_WKUPDEP_MCASP2_IRQ_MPU_SHIFT 0 1875#define OMAP4430_WKUPDEP_MCASP2_IRQ_MPU_SHIFT 0
1768#define OMAP4430_WKUPDEP_MCASP2_IRQ_MPU_MASK BITFIELD(0, 0) 1876#define OMAP4430_WKUPDEP_MCASP2_IRQ_MPU_MASK (1 << 0)
1769 1877
1770/* Used by PM_L4PER_MCASP2_WKDEP */ 1878/* Used by PM_L4PER_MCASP2_WKDEP */
1771#define OMAP4430_WKUPDEP_MCASP2_IRQ_TESLA_SHIFT 2 1879#define OMAP4430_WKUPDEP_MCASP2_IRQ_TESLA_SHIFT 2
1772#define OMAP4430_WKUPDEP_MCASP2_IRQ_TESLA_MASK BITFIELD(2, 2) 1880#define OMAP4430_WKUPDEP_MCASP2_IRQ_TESLA_MASK (1 << 2)
1773 1881
1774/* Used by PM_L4PER_MCASP3_WKDEP */ 1882/* Used by PM_L4PER_MCASP3_WKDEP */
1775#define OMAP4430_WKUPDEP_MCASP3_DMA_SDMA_SHIFT 7 1883#define OMAP4430_WKUPDEP_MCASP3_DMA_SDMA_SHIFT 7
1776#define OMAP4430_WKUPDEP_MCASP3_DMA_SDMA_MASK BITFIELD(7, 7) 1884#define OMAP4430_WKUPDEP_MCASP3_DMA_SDMA_MASK (1 << 7)
1777 1885
1778/* Used by PM_L4PER_MCASP3_WKDEP */ 1886/* Used by PM_L4PER_MCASP3_WKDEP */
1779#define OMAP4430_WKUPDEP_MCASP3_DMA_TESLA_SHIFT 6 1887#define OMAP4430_WKUPDEP_MCASP3_DMA_TESLA_SHIFT 6
1780#define OMAP4430_WKUPDEP_MCASP3_DMA_TESLA_MASK BITFIELD(6, 6) 1888#define OMAP4430_WKUPDEP_MCASP3_DMA_TESLA_MASK (1 << 6)
1781 1889
1782/* Used by PM_L4PER_MCASP3_WKDEP */ 1890/* Used by PM_L4PER_MCASP3_WKDEP */
1783#define OMAP4430_WKUPDEP_MCASP3_IRQ_MPU_SHIFT 0 1891#define OMAP4430_WKUPDEP_MCASP3_IRQ_MPU_SHIFT 0
1784#define OMAP4430_WKUPDEP_MCASP3_IRQ_MPU_MASK BITFIELD(0, 0) 1892#define OMAP4430_WKUPDEP_MCASP3_IRQ_MPU_MASK (1 << 0)
1785 1893
1786/* Used by PM_L4PER_MCASP3_WKDEP */ 1894/* Used by PM_L4PER_MCASP3_WKDEP */
1787#define OMAP4430_WKUPDEP_MCASP3_IRQ_TESLA_SHIFT 2 1895#define OMAP4430_WKUPDEP_MCASP3_IRQ_TESLA_SHIFT 2
1788#define OMAP4430_WKUPDEP_MCASP3_IRQ_TESLA_MASK BITFIELD(2, 2) 1896#define OMAP4430_WKUPDEP_MCASP3_IRQ_TESLA_MASK (1 << 2)
1789 1897
1790/* Used by PM_ABE_MCBSP1_WKDEP */ 1898/* Used by PM_ABE_MCBSP1_WKDEP */
1791#define OMAP4430_WKUPDEP_MCBSP1_MPU_SHIFT 0 1899#define OMAP4430_WKUPDEP_MCBSP1_MPU_SHIFT 0
1792#define OMAP4430_WKUPDEP_MCBSP1_MPU_MASK BITFIELD(0, 0) 1900#define OMAP4430_WKUPDEP_MCBSP1_MPU_MASK (1 << 0)
1793 1901
1794/* Used by PM_ABE_MCBSP1_WKDEP */ 1902/* Used by PM_ABE_MCBSP1_WKDEP */
1795#define OMAP4430_WKUPDEP_MCBSP1_SDMA_SHIFT 3 1903#define OMAP4430_WKUPDEP_MCBSP1_SDMA_SHIFT 3
1796#define OMAP4430_WKUPDEP_MCBSP1_SDMA_MASK BITFIELD(3, 3) 1904#define OMAP4430_WKUPDEP_MCBSP1_SDMA_MASK (1 << 3)
1797 1905
1798/* Used by PM_ABE_MCBSP1_WKDEP */ 1906/* Used by PM_ABE_MCBSP1_WKDEP */
1799#define OMAP4430_WKUPDEP_MCBSP1_TESLA_SHIFT 2 1907#define OMAP4430_WKUPDEP_MCBSP1_TESLA_SHIFT 2
1800#define OMAP4430_WKUPDEP_MCBSP1_TESLA_MASK BITFIELD(2, 2) 1908#define OMAP4430_WKUPDEP_MCBSP1_TESLA_MASK (1 << 2)
1801 1909
1802/* Used by PM_ABE_MCBSP2_WKDEP */ 1910/* Used by PM_ABE_MCBSP2_WKDEP */
1803#define OMAP4430_WKUPDEP_MCBSP2_MPU_SHIFT 0 1911#define OMAP4430_WKUPDEP_MCBSP2_MPU_SHIFT 0
1804#define OMAP4430_WKUPDEP_MCBSP2_MPU_MASK BITFIELD(0, 0) 1912#define OMAP4430_WKUPDEP_MCBSP2_MPU_MASK (1 << 0)
1805 1913
1806/* Used by PM_ABE_MCBSP2_WKDEP */ 1914/* Used by PM_ABE_MCBSP2_WKDEP */
1807#define OMAP4430_WKUPDEP_MCBSP2_SDMA_SHIFT 3 1915#define OMAP4430_WKUPDEP_MCBSP2_SDMA_SHIFT 3
1808#define OMAP4430_WKUPDEP_MCBSP2_SDMA_MASK BITFIELD(3, 3) 1916#define OMAP4430_WKUPDEP_MCBSP2_SDMA_MASK (1 << 3)
1809 1917
1810/* Used by PM_ABE_MCBSP2_WKDEP */ 1918/* Used by PM_ABE_MCBSP2_WKDEP */
1811#define OMAP4430_WKUPDEP_MCBSP2_TESLA_SHIFT 2 1919#define OMAP4430_WKUPDEP_MCBSP2_TESLA_SHIFT 2
1812#define OMAP4430_WKUPDEP_MCBSP2_TESLA_MASK BITFIELD(2, 2) 1920#define OMAP4430_WKUPDEP_MCBSP2_TESLA_MASK (1 << 2)
1813 1921
1814/* Used by PM_ABE_MCBSP3_WKDEP */ 1922/* Used by PM_ABE_MCBSP3_WKDEP */
1815#define OMAP4430_WKUPDEP_MCBSP3_MPU_SHIFT 0 1923#define OMAP4430_WKUPDEP_MCBSP3_MPU_SHIFT 0
1816#define OMAP4430_WKUPDEP_MCBSP3_MPU_MASK BITFIELD(0, 0) 1924#define OMAP4430_WKUPDEP_MCBSP3_MPU_MASK (1 << 0)
1817 1925
1818/* Used by PM_ABE_MCBSP3_WKDEP */ 1926/* Used by PM_ABE_MCBSP3_WKDEP */
1819#define OMAP4430_WKUPDEP_MCBSP3_SDMA_SHIFT 3 1927#define OMAP4430_WKUPDEP_MCBSP3_SDMA_SHIFT 3
1820#define OMAP4430_WKUPDEP_MCBSP3_SDMA_MASK BITFIELD(3, 3) 1928#define OMAP4430_WKUPDEP_MCBSP3_SDMA_MASK (1 << 3)
1821 1929
1822/* Used by PM_ABE_MCBSP3_WKDEP */ 1930/* Used by PM_ABE_MCBSP3_WKDEP */
1823#define OMAP4430_WKUPDEP_MCBSP3_TESLA_SHIFT 2 1931#define OMAP4430_WKUPDEP_MCBSP3_TESLA_SHIFT 2
1824#define OMAP4430_WKUPDEP_MCBSP3_TESLA_MASK BITFIELD(2, 2) 1932#define OMAP4430_WKUPDEP_MCBSP3_TESLA_MASK (1 << 2)
1825 1933
1826/* Used by PM_L4PER_MCBSP4_WKDEP */ 1934/* Used by PM_L4PER_MCBSP4_WKDEP */
1827#define OMAP4430_WKUPDEP_MCBSP4_MPU_SHIFT 0 1935#define OMAP4430_WKUPDEP_MCBSP4_MPU_SHIFT 0
1828#define OMAP4430_WKUPDEP_MCBSP4_MPU_MASK BITFIELD(0, 0) 1936#define OMAP4430_WKUPDEP_MCBSP4_MPU_MASK (1 << 0)
1829 1937
1830/* Used by PM_L4PER_MCBSP4_WKDEP */ 1938/* Used by PM_L4PER_MCBSP4_WKDEP */
1831#define OMAP4430_WKUPDEP_MCBSP4_SDMA_SHIFT 3 1939#define OMAP4430_WKUPDEP_MCBSP4_SDMA_SHIFT 3
1832#define OMAP4430_WKUPDEP_MCBSP4_SDMA_MASK BITFIELD(3, 3) 1940#define OMAP4430_WKUPDEP_MCBSP4_SDMA_MASK (1 << 3)
1833 1941
1834/* Used by PM_L4PER_MCBSP4_WKDEP */ 1942/* Used by PM_L4PER_MCBSP4_WKDEP */
1835#define OMAP4430_WKUPDEP_MCBSP4_TESLA_SHIFT 2 1943#define OMAP4430_WKUPDEP_MCBSP4_TESLA_SHIFT 2
1836#define OMAP4430_WKUPDEP_MCBSP4_TESLA_MASK BITFIELD(2, 2) 1944#define OMAP4430_WKUPDEP_MCBSP4_TESLA_MASK (1 << 2)
1837 1945
1838/* Used by PM_L4PER_MCSPI1_WKDEP */ 1946/* Used by PM_L4PER_MCSPI1_WKDEP */
1839#define OMAP4430_WKUPDEP_MCSPI1_DUCATI_SHIFT 1 1947#define OMAP4430_WKUPDEP_MCSPI1_DUCATI_SHIFT 1
1840#define OMAP4430_WKUPDEP_MCSPI1_DUCATI_MASK BITFIELD(1, 1) 1948#define OMAP4430_WKUPDEP_MCSPI1_DUCATI_MASK (1 << 1)
1841 1949
1842/* Used by PM_L4PER_MCSPI1_WKDEP */ 1950/* Used by PM_L4PER_MCSPI1_WKDEP */
1843#define OMAP4430_WKUPDEP_MCSPI1_MPU_SHIFT 0 1951#define OMAP4430_WKUPDEP_MCSPI1_MPU_SHIFT 0
1844#define OMAP4430_WKUPDEP_MCSPI1_MPU_MASK BITFIELD(0, 0) 1952#define OMAP4430_WKUPDEP_MCSPI1_MPU_MASK (1 << 0)
1845 1953
1846/* Used by PM_L4PER_MCSPI1_WKDEP */ 1954/* Used by PM_L4PER_MCSPI1_WKDEP */
1847#define OMAP4430_WKUPDEP_MCSPI1_SDMA_SHIFT 3 1955#define OMAP4430_WKUPDEP_MCSPI1_SDMA_SHIFT 3
1848#define OMAP4430_WKUPDEP_MCSPI1_SDMA_MASK BITFIELD(3, 3) 1956#define OMAP4430_WKUPDEP_MCSPI1_SDMA_MASK (1 << 3)
1849 1957
1850/* Used by PM_L4PER_MCSPI1_WKDEP */ 1958/* Used by PM_L4PER_MCSPI1_WKDEP */
1851#define OMAP4430_WKUPDEP_MCSPI1_TESLA_SHIFT 2 1959#define OMAP4430_WKUPDEP_MCSPI1_TESLA_SHIFT 2
1852#define OMAP4430_WKUPDEP_MCSPI1_TESLA_MASK BITFIELD(2, 2) 1960#define OMAP4430_WKUPDEP_MCSPI1_TESLA_MASK (1 << 2)
1853 1961
1854/* Used by PM_L4PER_MCSPI2_WKDEP */ 1962/* Used by PM_L4PER_MCSPI2_WKDEP */
1855#define OMAP4430_WKUPDEP_MCSPI2_DUCATI_SHIFT 1 1963#define OMAP4430_WKUPDEP_MCSPI2_DUCATI_SHIFT 1
1856#define OMAP4430_WKUPDEP_MCSPI2_DUCATI_MASK BITFIELD(1, 1) 1964#define OMAP4430_WKUPDEP_MCSPI2_DUCATI_MASK (1 << 1)
1857 1965
1858/* Used by PM_L4PER_MCSPI2_WKDEP */ 1966/* Used by PM_L4PER_MCSPI2_WKDEP */
1859#define OMAP4430_WKUPDEP_MCSPI2_MPU_SHIFT 0 1967#define OMAP4430_WKUPDEP_MCSPI2_MPU_SHIFT 0
1860#define OMAP4430_WKUPDEP_MCSPI2_MPU_MASK BITFIELD(0, 0) 1968#define OMAP4430_WKUPDEP_MCSPI2_MPU_MASK (1 << 0)
1861 1969
1862/* Used by PM_L4PER_MCSPI2_WKDEP */ 1970/* Used by PM_L4PER_MCSPI2_WKDEP */
1863#define OMAP4430_WKUPDEP_MCSPI2_SDMA_SHIFT 3 1971#define OMAP4430_WKUPDEP_MCSPI2_SDMA_SHIFT 3
1864#define OMAP4430_WKUPDEP_MCSPI2_SDMA_MASK BITFIELD(3, 3) 1972#define OMAP4430_WKUPDEP_MCSPI2_SDMA_MASK (1 << 3)
1865 1973
1866/* Used by PM_L4PER_MCSPI3_WKDEP */ 1974/* Used by PM_L4PER_MCSPI3_WKDEP */
1867#define OMAP4430_WKUPDEP_MCSPI3_MPU_SHIFT 0 1975#define OMAP4430_WKUPDEP_MCSPI3_MPU_SHIFT 0
1868#define OMAP4430_WKUPDEP_MCSPI3_MPU_MASK BITFIELD(0, 0) 1976#define OMAP4430_WKUPDEP_MCSPI3_MPU_MASK (1 << 0)
1869 1977
1870/* Used by PM_L4PER_MCSPI3_WKDEP */ 1978/* Used by PM_L4PER_MCSPI3_WKDEP */
1871#define OMAP4430_WKUPDEP_MCSPI3_SDMA_SHIFT 3 1979#define OMAP4430_WKUPDEP_MCSPI3_SDMA_SHIFT 3
1872#define OMAP4430_WKUPDEP_MCSPI3_SDMA_MASK BITFIELD(3, 3) 1980#define OMAP4430_WKUPDEP_MCSPI3_SDMA_MASK (1 << 3)
1873 1981
1874/* Used by PM_L4PER_MCSPI4_WKDEP */ 1982/* Used by PM_L4PER_MCSPI4_WKDEP */
1875#define OMAP4430_WKUPDEP_MCSPI4_MPU_SHIFT 0 1983#define OMAP4430_WKUPDEP_MCSPI4_MPU_SHIFT 0
1876#define OMAP4430_WKUPDEP_MCSPI4_MPU_MASK BITFIELD(0, 0) 1984#define OMAP4430_WKUPDEP_MCSPI4_MPU_MASK (1 << 0)
1877 1985
1878/* Used by PM_L4PER_MCSPI4_WKDEP */ 1986/* Used by PM_L4PER_MCSPI4_WKDEP */
1879#define OMAP4430_WKUPDEP_MCSPI4_SDMA_SHIFT 3 1987#define OMAP4430_WKUPDEP_MCSPI4_SDMA_SHIFT 3
1880#define OMAP4430_WKUPDEP_MCSPI4_SDMA_MASK BITFIELD(3, 3) 1988#define OMAP4430_WKUPDEP_MCSPI4_SDMA_MASK (1 << 3)
1881 1989
1882/* Used by PM_L3INIT_MMC1_WKDEP */ 1990/* Used by PM_L3INIT_MMC1_WKDEP */
1883#define OMAP4430_WKUPDEP_MMC1_DUCATI_SHIFT 1 1991#define OMAP4430_WKUPDEP_MMC1_DUCATI_SHIFT 1
1884#define OMAP4430_WKUPDEP_MMC1_DUCATI_MASK BITFIELD(1, 1) 1992#define OMAP4430_WKUPDEP_MMC1_DUCATI_MASK (1 << 1)
1885 1993
1886/* Used by PM_L3INIT_MMC1_WKDEP */ 1994/* Used by PM_L3INIT_MMC1_WKDEP */
1887#define OMAP4430_WKUPDEP_MMC1_MPU_SHIFT 0 1995#define OMAP4430_WKUPDEP_MMC1_MPU_SHIFT 0
1888#define OMAP4430_WKUPDEP_MMC1_MPU_MASK BITFIELD(0, 0) 1996#define OMAP4430_WKUPDEP_MMC1_MPU_MASK (1 << 0)
1889 1997
1890/* Used by PM_L3INIT_MMC1_WKDEP */ 1998/* Used by PM_L3INIT_MMC1_WKDEP */
1891#define OMAP4430_WKUPDEP_MMC1_SDMA_SHIFT 3 1999#define OMAP4430_WKUPDEP_MMC1_SDMA_SHIFT 3
1892#define OMAP4430_WKUPDEP_MMC1_SDMA_MASK BITFIELD(3, 3) 2000#define OMAP4430_WKUPDEP_MMC1_SDMA_MASK (1 << 3)
1893 2001
1894/* Used by PM_L3INIT_MMC1_WKDEP */ 2002/* Used by PM_L3INIT_MMC1_WKDEP */
1895#define OMAP4430_WKUPDEP_MMC1_TESLA_SHIFT 2 2003#define OMAP4430_WKUPDEP_MMC1_TESLA_SHIFT 2
1896#define OMAP4430_WKUPDEP_MMC1_TESLA_MASK BITFIELD(2, 2) 2004#define OMAP4430_WKUPDEP_MMC1_TESLA_MASK (1 << 2)
1897 2005
1898/* Used by PM_L3INIT_MMC2_WKDEP */ 2006/* Used by PM_L3INIT_MMC2_WKDEP */
1899#define OMAP4430_WKUPDEP_MMC2_DUCATI_SHIFT 1 2007#define OMAP4430_WKUPDEP_MMC2_DUCATI_SHIFT 1
1900#define OMAP4430_WKUPDEP_MMC2_DUCATI_MASK BITFIELD(1, 1) 2008#define OMAP4430_WKUPDEP_MMC2_DUCATI_MASK (1 << 1)
1901 2009
1902/* Used by PM_L3INIT_MMC2_WKDEP */ 2010/* Used by PM_L3INIT_MMC2_WKDEP */
1903#define OMAP4430_WKUPDEP_MMC2_MPU_SHIFT 0 2011#define OMAP4430_WKUPDEP_MMC2_MPU_SHIFT 0
1904#define OMAP4430_WKUPDEP_MMC2_MPU_MASK BITFIELD(0, 0) 2012#define OMAP4430_WKUPDEP_MMC2_MPU_MASK (1 << 0)
1905 2013
1906/* Used by PM_L3INIT_MMC2_WKDEP */ 2014/* Used by PM_L3INIT_MMC2_WKDEP */
1907#define OMAP4430_WKUPDEP_MMC2_SDMA_SHIFT 3 2015#define OMAP4430_WKUPDEP_MMC2_SDMA_SHIFT 3
1908#define OMAP4430_WKUPDEP_MMC2_SDMA_MASK BITFIELD(3, 3) 2016#define OMAP4430_WKUPDEP_MMC2_SDMA_MASK (1 << 3)
1909 2017
1910/* Used by PM_L3INIT_MMC2_WKDEP */ 2018/* Used by PM_L3INIT_MMC2_WKDEP */
1911#define OMAP4430_WKUPDEP_MMC2_TESLA_SHIFT 2 2019#define OMAP4430_WKUPDEP_MMC2_TESLA_SHIFT 2
1912#define OMAP4430_WKUPDEP_MMC2_TESLA_MASK BITFIELD(2, 2) 2020#define OMAP4430_WKUPDEP_MMC2_TESLA_MASK (1 << 2)
1913 2021
1914/* Used by PM_L3INIT_MMC6_WKDEP */ 2022/* Used by PM_L3INIT_MMC6_WKDEP */
1915#define OMAP4430_WKUPDEP_MMC6_DUCATI_SHIFT 1 2023#define OMAP4430_WKUPDEP_MMC6_DUCATI_SHIFT 1
1916#define OMAP4430_WKUPDEP_MMC6_DUCATI_MASK BITFIELD(1, 1) 2024#define OMAP4430_WKUPDEP_MMC6_DUCATI_MASK (1 << 1)
1917 2025
1918/* Used by PM_L3INIT_MMC6_WKDEP */ 2026/* Used by PM_L3INIT_MMC6_WKDEP */
1919#define OMAP4430_WKUPDEP_MMC6_MPU_SHIFT 0 2027#define OMAP4430_WKUPDEP_MMC6_MPU_SHIFT 0
1920#define OMAP4430_WKUPDEP_MMC6_MPU_MASK BITFIELD(0, 0) 2028#define OMAP4430_WKUPDEP_MMC6_MPU_MASK (1 << 0)
1921 2029
1922/* Used by PM_L3INIT_MMC6_WKDEP */ 2030/* Used by PM_L3INIT_MMC6_WKDEP */
1923#define OMAP4430_WKUPDEP_MMC6_TESLA_SHIFT 2 2031#define OMAP4430_WKUPDEP_MMC6_TESLA_SHIFT 2
1924#define OMAP4430_WKUPDEP_MMC6_TESLA_MASK BITFIELD(2, 2) 2032#define OMAP4430_WKUPDEP_MMC6_TESLA_MASK (1 << 2)
1925 2033
1926/* Used by PM_L4PER_MMCSD3_WKDEP */ 2034/* Used by PM_L4PER_MMCSD3_WKDEP */
1927#define OMAP4430_WKUPDEP_MMCSD3_DUCATI_SHIFT 1 2035#define OMAP4430_WKUPDEP_MMCSD3_DUCATI_SHIFT 1
1928#define OMAP4430_WKUPDEP_MMCSD3_DUCATI_MASK BITFIELD(1, 1) 2036#define OMAP4430_WKUPDEP_MMCSD3_DUCATI_MASK (1 << 1)
1929 2037
1930/* Used by PM_L4PER_MMCSD3_WKDEP */ 2038/* Used by PM_L4PER_MMCSD3_WKDEP */
1931#define OMAP4430_WKUPDEP_MMCSD3_MPU_SHIFT 0 2039#define OMAP4430_WKUPDEP_MMCSD3_MPU_SHIFT 0
1932#define OMAP4430_WKUPDEP_MMCSD3_MPU_MASK BITFIELD(0, 0) 2040#define OMAP4430_WKUPDEP_MMCSD3_MPU_MASK (1 << 0)
1933 2041
1934/* Used by PM_L4PER_MMCSD3_WKDEP */ 2042/* Used by PM_L4PER_MMCSD3_WKDEP */
1935#define OMAP4430_WKUPDEP_MMCSD3_SDMA_SHIFT 3 2043#define OMAP4430_WKUPDEP_MMCSD3_SDMA_SHIFT 3
1936#define OMAP4430_WKUPDEP_MMCSD3_SDMA_MASK BITFIELD(3, 3) 2044#define OMAP4430_WKUPDEP_MMCSD3_SDMA_MASK (1 << 3)
1937 2045
1938/* Used by PM_L4PER_MMCSD4_WKDEP */ 2046/* Used by PM_L4PER_MMCSD4_WKDEP */
1939#define OMAP4430_WKUPDEP_MMCSD4_DUCATI_SHIFT 1 2047#define OMAP4430_WKUPDEP_MMCSD4_DUCATI_SHIFT 1
1940#define OMAP4430_WKUPDEP_MMCSD4_DUCATI_MASK BITFIELD(1, 1) 2048#define OMAP4430_WKUPDEP_MMCSD4_DUCATI_MASK (1 << 1)
1941 2049
1942/* Used by PM_L4PER_MMCSD4_WKDEP */ 2050/* Used by PM_L4PER_MMCSD4_WKDEP */
1943#define OMAP4430_WKUPDEP_MMCSD4_MPU_SHIFT 0 2051#define OMAP4430_WKUPDEP_MMCSD4_MPU_SHIFT 0
1944#define OMAP4430_WKUPDEP_MMCSD4_MPU_MASK BITFIELD(0, 0) 2052#define OMAP4430_WKUPDEP_MMCSD4_MPU_MASK (1 << 0)
1945 2053
1946/* Used by PM_L4PER_MMCSD4_WKDEP */ 2054/* Used by PM_L4PER_MMCSD4_WKDEP */
1947#define OMAP4430_WKUPDEP_MMCSD4_SDMA_SHIFT 3 2055#define OMAP4430_WKUPDEP_MMCSD4_SDMA_SHIFT 3
1948#define OMAP4430_WKUPDEP_MMCSD4_SDMA_MASK BITFIELD(3, 3) 2056#define OMAP4430_WKUPDEP_MMCSD4_SDMA_MASK (1 << 3)
1949 2057
1950/* Used by PM_L4PER_MMCSD5_WKDEP */ 2058/* Used by PM_L4PER_MMCSD5_WKDEP */
1951#define OMAP4430_WKUPDEP_MMCSD5_DUCATI_SHIFT 1 2059#define OMAP4430_WKUPDEP_MMCSD5_DUCATI_SHIFT 1
1952#define OMAP4430_WKUPDEP_MMCSD5_DUCATI_MASK BITFIELD(1, 1) 2060#define OMAP4430_WKUPDEP_MMCSD5_DUCATI_MASK (1 << 1)
1953 2061
1954/* Used by PM_L4PER_MMCSD5_WKDEP */ 2062/* Used by PM_L4PER_MMCSD5_WKDEP */
1955#define OMAP4430_WKUPDEP_MMCSD5_MPU_SHIFT 0 2063#define OMAP4430_WKUPDEP_MMCSD5_MPU_SHIFT 0
1956#define OMAP4430_WKUPDEP_MMCSD5_MPU_MASK BITFIELD(0, 0) 2064#define OMAP4430_WKUPDEP_MMCSD5_MPU_MASK (1 << 0)
1957 2065
1958/* Used by PM_L4PER_MMCSD5_WKDEP */ 2066/* Used by PM_L4PER_MMCSD5_WKDEP */
1959#define OMAP4430_WKUPDEP_MMCSD5_SDMA_SHIFT 3 2067#define OMAP4430_WKUPDEP_MMCSD5_SDMA_SHIFT 3
1960#define OMAP4430_WKUPDEP_MMCSD5_SDMA_MASK BITFIELD(3, 3) 2068#define OMAP4430_WKUPDEP_MMCSD5_SDMA_MASK (1 << 3)
1961 2069
1962/* Used by PM_L3INIT_PCIESS_WKDEP */ 2070/* Used by PM_L3INIT_PCIESS_WKDEP */
1963#define OMAP4430_WKUPDEP_PCIESS_MPU_SHIFT 0 2071#define OMAP4430_WKUPDEP_PCIESS_MPU_SHIFT 0
1964#define OMAP4430_WKUPDEP_PCIESS_MPU_MASK BITFIELD(0, 0) 2072#define OMAP4430_WKUPDEP_PCIESS_MPU_MASK (1 << 0)
1965 2073
1966/* Used by PM_L3INIT_PCIESS_WKDEP */ 2074/* Used by PM_L3INIT_PCIESS_WKDEP */
1967#define OMAP4430_WKUPDEP_PCIESS_TESLA_SHIFT 2 2075#define OMAP4430_WKUPDEP_PCIESS_TESLA_SHIFT 2
1968#define OMAP4430_WKUPDEP_PCIESS_TESLA_MASK BITFIELD(2, 2) 2076#define OMAP4430_WKUPDEP_PCIESS_TESLA_MASK (1 << 2)
1969 2077
1970/* Used by PM_ABE_PDM_WKDEP */ 2078/* Used by PM_ABE_PDM_WKDEP */
1971#define OMAP4430_WKUPDEP_PDM_DMA_SDMA_SHIFT 7 2079#define OMAP4430_WKUPDEP_PDM_DMA_SDMA_SHIFT 7
1972#define OMAP4430_WKUPDEP_PDM_DMA_SDMA_MASK BITFIELD(7, 7) 2080#define OMAP4430_WKUPDEP_PDM_DMA_SDMA_MASK (1 << 7)
1973 2081
1974/* Used by PM_ABE_PDM_WKDEP */ 2082/* Used by PM_ABE_PDM_WKDEP */
1975#define OMAP4430_WKUPDEP_PDM_DMA_TESLA_SHIFT 6 2083#define OMAP4430_WKUPDEP_PDM_DMA_TESLA_SHIFT 6
1976#define OMAP4430_WKUPDEP_PDM_DMA_TESLA_MASK BITFIELD(6, 6) 2084#define OMAP4430_WKUPDEP_PDM_DMA_TESLA_MASK (1 << 6)
1977 2085
1978/* Used by PM_ABE_PDM_WKDEP */ 2086/* Used by PM_ABE_PDM_WKDEP */
1979#define OMAP4430_WKUPDEP_PDM_IRQ_MPU_SHIFT 0 2087#define OMAP4430_WKUPDEP_PDM_IRQ_MPU_SHIFT 0
1980#define OMAP4430_WKUPDEP_PDM_IRQ_MPU_MASK BITFIELD(0, 0) 2088#define OMAP4430_WKUPDEP_PDM_IRQ_MPU_MASK (1 << 0)
1981 2089
1982/* Used by PM_ABE_PDM_WKDEP */ 2090/* Used by PM_ABE_PDM_WKDEP */
1983#define OMAP4430_WKUPDEP_PDM_IRQ_TESLA_SHIFT 2 2091#define OMAP4430_WKUPDEP_PDM_IRQ_TESLA_SHIFT 2
1984#define OMAP4430_WKUPDEP_PDM_IRQ_TESLA_MASK BITFIELD(2, 2) 2092#define OMAP4430_WKUPDEP_PDM_IRQ_TESLA_MASK (1 << 2)
1985 2093
1986/* Used by PM_WKUP_RTC_WKDEP */ 2094/* Used by PM_WKUP_RTC_WKDEP */
1987#define OMAP4430_WKUPDEP_RTC_MPU_SHIFT 0 2095#define OMAP4430_WKUPDEP_RTC_MPU_SHIFT 0
1988#define OMAP4430_WKUPDEP_RTC_MPU_MASK BITFIELD(0, 0) 2096#define OMAP4430_WKUPDEP_RTC_MPU_MASK (1 << 0)
1989 2097
1990/* Used by PM_L3INIT_SATA_WKDEP */ 2098/* Used by PM_L3INIT_SATA_WKDEP */
1991#define OMAP4430_WKUPDEP_SATA_MPU_SHIFT 0 2099#define OMAP4430_WKUPDEP_SATA_MPU_SHIFT 0
1992#define OMAP4430_WKUPDEP_SATA_MPU_MASK BITFIELD(0, 0) 2100#define OMAP4430_WKUPDEP_SATA_MPU_MASK (1 << 0)
1993 2101
1994/* Used by PM_L3INIT_SATA_WKDEP */ 2102/* Used by PM_L3INIT_SATA_WKDEP */
1995#define OMAP4430_WKUPDEP_SATA_TESLA_SHIFT 2 2103#define OMAP4430_WKUPDEP_SATA_TESLA_SHIFT 2
1996#define OMAP4430_WKUPDEP_SATA_TESLA_MASK BITFIELD(2, 2) 2104#define OMAP4430_WKUPDEP_SATA_TESLA_MASK (1 << 2)
1997 2105
1998/* Used by PM_ABE_SLIMBUS_WKDEP */ 2106/* Used by PM_ABE_SLIMBUS_WKDEP */
1999#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_SDMA_SHIFT 7 2107#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_SDMA_SHIFT 7
2000#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_SDMA_MASK BITFIELD(7, 7) 2108#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_SDMA_MASK (1 << 7)
2001 2109
2002/* Used by PM_ABE_SLIMBUS_WKDEP */ 2110/* Used by PM_ABE_SLIMBUS_WKDEP */
2003#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_TESLA_SHIFT 6 2111#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_TESLA_SHIFT 6
2004#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_TESLA_MASK BITFIELD(6, 6) 2112#define OMAP4430_WKUPDEP_SLIMBUS1_DMA_TESLA_MASK (1 << 6)
2005 2113
2006/* Used by PM_ABE_SLIMBUS_WKDEP */ 2114/* Used by PM_ABE_SLIMBUS_WKDEP */
2007#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_MPU_SHIFT 0 2115#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_MPU_SHIFT 0
2008#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_MPU_MASK BITFIELD(0, 0) 2116#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_MPU_MASK (1 << 0)
2009 2117
2010/* Used by PM_ABE_SLIMBUS_WKDEP */ 2118/* Used by PM_ABE_SLIMBUS_WKDEP */
2011#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_TESLA_SHIFT 2 2119#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_TESLA_SHIFT 2
2012#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_TESLA_MASK BITFIELD(2, 2) 2120#define OMAP4430_WKUPDEP_SLIMBUS1_IRQ_TESLA_MASK (1 << 2)
2013 2121
2014/* Used by PM_L4PER_SLIMBUS2_WKDEP */ 2122/* Used by PM_L4PER_SLIMBUS2_WKDEP */
2015#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_SDMA_SHIFT 7 2123#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_SDMA_SHIFT 7
2016#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_SDMA_MASK BITFIELD(7, 7) 2124#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_SDMA_MASK (1 << 7)
2017 2125
2018/* Used by PM_L4PER_SLIMBUS2_WKDEP */ 2126/* Used by PM_L4PER_SLIMBUS2_WKDEP */
2019#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_TESLA_SHIFT 6 2127#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_TESLA_SHIFT 6
2020#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_TESLA_MASK BITFIELD(6, 6) 2128#define OMAP4430_WKUPDEP_SLIMBUS2_DMA_TESLA_MASK (1 << 6)
2021 2129
2022/* Used by PM_L4PER_SLIMBUS2_WKDEP */ 2130/* Used by PM_L4PER_SLIMBUS2_WKDEP */
2023#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_MPU_SHIFT 0 2131#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_MPU_SHIFT 0
2024#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_MPU_MASK BITFIELD(0, 0) 2132#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_MPU_MASK (1 << 0)
2025 2133
2026/* Used by PM_L4PER_SLIMBUS2_WKDEP */ 2134/* Used by PM_L4PER_SLIMBUS2_WKDEP */
2027#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_TESLA_SHIFT 2 2135#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_TESLA_SHIFT 2
2028#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_TESLA_MASK BITFIELD(2, 2) 2136#define OMAP4430_WKUPDEP_SLIMBUS2_IRQ_TESLA_MASK (1 << 2)
2029 2137
2030/* Used by PM_ALWON_SR_CORE_WKDEP */ 2138/* Used by PM_ALWON_SR_CORE_WKDEP */
2031#define OMAP4430_WKUPDEP_SR_CORE_DUCATI_SHIFT 1 2139#define OMAP4430_WKUPDEP_SR_CORE_DUCATI_SHIFT 1
2032#define OMAP4430_WKUPDEP_SR_CORE_DUCATI_MASK BITFIELD(1, 1) 2140#define OMAP4430_WKUPDEP_SR_CORE_DUCATI_MASK (1 << 1)
2033 2141
2034/* Used by PM_ALWON_SR_CORE_WKDEP */ 2142/* Used by PM_ALWON_SR_CORE_WKDEP */
2035#define OMAP4430_WKUPDEP_SR_CORE_MPU_SHIFT 0 2143#define OMAP4430_WKUPDEP_SR_CORE_MPU_SHIFT 0
2036#define OMAP4430_WKUPDEP_SR_CORE_MPU_MASK BITFIELD(0, 0) 2144#define OMAP4430_WKUPDEP_SR_CORE_MPU_MASK (1 << 0)
2037 2145
2038/* Used by PM_ALWON_SR_IVA_WKDEP */ 2146/* Used by PM_ALWON_SR_IVA_WKDEP */
2039#define OMAP4430_WKUPDEP_SR_IVA_DUCATI_SHIFT 1 2147#define OMAP4430_WKUPDEP_SR_IVA_DUCATI_SHIFT 1
2040#define OMAP4430_WKUPDEP_SR_IVA_DUCATI_MASK BITFIELD(1, 1) 2148#define OMAP4430_WKUPDEP_SR_IVA_DUCATI_MASK (1 << 1)
2041 2149
2042/* Used by PM_ALWON_SR_IVA_WKDEP */ 2150/* Used by PM_ALWON_SR_IVA_WKDEP */
2043#define OMAP4430_WKUPDEP_SR_IVA_MPU_SHIFT 0 2151#define OMAP4430_WKUPDEP_SR_IVA_MPU_SHIFT 0
2044#define OMAP4430_WKUPDEP_SR_IVA_MPU_MASK BITFIELD(0, 0) 2152#define OMAP4430_WKUPDEP_SR_IVA_MPU_MASK (1 << 0)
2045 2153
2046/* Used by PM_ALWON_SR_MPU_WKDEP */ 2154/* Used by PM_ALWON_SR_MPU_WKDEP */
2047#define OMAP4430_WKUPDEP_SR_MPU_MPU_SHIFT 0 2155#define OMAP4430_WKUPDEP_SR_MPU_MPU_SHIFT 0
2048#define OMAP4430_WKUPDEP_SR_MPU_MPU_MASK BITFIELD(0, 0) 2156#define OMAP4430_WKUPDEP_SR_MPU_MPU_MASK (1 << 0)
2049 2157
2050/* Used by PM_WKUP_TIMER12_WKDEP */ 2158/* Used by PM_WKUP_TIMER12_WKDEP */
2051#define OMAP4430_WKUPDEP_TIMER12_MPU_SHIFT 0 2159#define OMAP4430_WKUPDEP_TIMER12_MPU_SHIFT 0
2052#define OMAP4430_WKUPDEP_TIMER12_MPU_MASK BITFIELD(0, 0) 2160#define OMAP4430_WKUPDEP_TIMER12_MPU_MASK (1 << 0)
2053 2161
2054/* Used by PM_WKUP_TIMER1_WKDEP */ 2162/* Used by PM_WKUP_TIMER1_WKDEP */
2055#define OMAP4430_WKUPDEP_TIMER1_MPU_SHIFT 0 2163#define OMAP4430_WKUPDEP_TIMER1_MPU_SHIFT 0
2056#define OMAP4430_WKUPDEP_TIMER1_MPU_MASK BITFIELD(0, 0) 2164#define OMAP4430_WKUPDEP_TIMER1_MPU_MASK (1 << 0)
2057 2165
2058/* Used by PM_ABE_TIMER5_WKDEP */ 2166/* Used by PM_ABE_TIMER5_WKDEP */
2059#define OMAP4430_WKUPDEP_TIMER5_MPU_SHIFT 0 2167#define OMAP4430_WKUPDEP_TIMER5_MPU_SHIFT 0
2060#define OMAP4430_WKUPDEP_TIMER5_MPU_MASK BITFIELD(0, 0) 2168#define OMAP4430_WKUPDEP_TIMER5_MPU_MASK (1 << 0)
2061 2169
2062/* Used by PM_ABE_TIMER5_WKDEP */ 2170/* Used by PM_ABE_TIMER5_WKDEP */
2063#define OMAP4430_WKUPDEP_TIMER5_TESLA_SHIFT 2 2171#define OMAP4430_WKUPDEP_TIMER5_TESLA_SHIFT 2
2064#define OMAP4430_WKUPDEP_TIMER5_TESLA_MASK BITFIELD(2, 2) 2172#define OMAP4430_WKUPDEP_TIMER5_TESLA_MASK (1 << 2)
2065 2173
2066/* Used by PM_ABE_TIMER6_WKDEP */ 2174/* Used by PM_ABE_TIMER6_WKDEP */
2067#define OMAP4430_WKUPDEP_TIMER6_MPU_SHIFT 0 2175#define OMAP4430_WKUPDEP_TIMER6_MPU_SHIFT 0
2068#define OMAP4430_WKUPDEP_TIMER6_MPU_MASK BITFIELD(0, 0) 2176#define OMAP4430_WKUPDEP_TIMER6_MPU_MASK (1 << 0)
2069 2177
2070/* Used by PM_ABE_TIMER6_WKDEP */ 2178/* Used by PM_ABE_TIMER6_WKDEP */
2071#define OMAP4430_WKUPDEP_TIMER6_TESLA_SHIFT 2 2179#define OMAP4430_WKUPDEP_TIMER6_TESLA_SHIFT 2
2072#define OMAP4430_WKUPDEP_TIMER6_TESLA_MASK BITFIELD(2, 2) 2180#define OMAP4430_WKUPDEP_TIMER6_TESLA_MASK (1 << 2)
2073 2181
2074/* Used by PM_ABE_TIMER7_WKDEP */ 2182/* Used by PM_ABE_TIMER7_WKDEP */
2075#define OMAP4430_WKUPDEP_TIMER7_MPU_SHIFT 0 2183#define OMAP4430_WKUPDEP_TIMER7_MPU_SHIFT 0
2076#define OMAP4430_WKUPDEP_TIMER7_MPU_MASK BITFIELD(0, 0) 2184#define OMAP4430_WKUPDEP_TIMER7_MPU_MASK (1 << 0)
2077 2185
2078/* Used by PM_ABE_TIMER7_WKDEP */ 2186/* Used by PM_ABE_TIMER7_WKDEP */
2079#define OMAP4430_WKUPDEP_TIMER7_TESLA_SHIFT 2 2187#define OMAP4430_WKUPDEP_TIMER7_TESLA_SHIFT 2
2080#define OMAP4430_WKUPDEP_TIMER7_TESLA_MASK BITFIELD(2, 2) 2188#define OMAP4430_WKUPDEP_TIMER7_TESLA_MASK (1 << 2)
2081 2189
2082/* Used by PM_ABE_TIMER8_WKDEP */ 2190/* Used by PM_ABE_TIMER8_WKDEP */
2083#define OMAP4430_WKUPDEP_TIMER8_MPU_SHIFT 0 2191#define OMAP4430_WKUPDEP_TIMER8_MPU_SHIFT 0
2084#define OMAP4430_WKUPDEP_TIMER8_MPU_MASK BITFIELD(0, 0) 2192#define OMAP4430_WKUPDEP_TIMER8_MPU_MASK (1 << 0)
2085 2193
2086/* Used by PM_ABE_TIMER8_WKDEP */ 2194/* Used by PM_ABE_TIMER8_WKDEP */
2087#define OMAP4430_WKUPDEP_TIMER8_TESLA_SHIFT 2 2195#define OMAP4430_WKUPDEP_TIMER8_TESLA_SHIFT 2
2088#define OMAP4430_WKUPDEP_TIMER8_TESLA_MASK BITFIELD(2, 2) 2196#define OMAP4430_WKUPDEP_TIMER8_TESLA_MASK (1 << 2)
2089 2197
2090/* Used by PM_L4PER_UART1_WKDEP */ 2198/* Used by PM_L4PER_UART1_WKDEP */
2091#define OMAP4430_WKUPDEP_UART1_MPU_SHIFT 0 2199#define OMAP4430_WKUPDEP_UART1_MPU_SHIFT 0
2092#define OMAP4430_WKUPDEP_UART1_MPU_MASK BITFIELD(0, 0) 2200#define OMAP4430_WKUPDEP_UART1_MPU_MASK (1 << 0)
2093 2201
2094/* Used by PM_L4PER_UART1_WKDEP */ 2202/* Used by PM_L4PER_UART1_WKDEP */
2095#define OMAP4430_WKUPDEP_UART1_SDMA_SHIFT 3 2203#define OMAP4430_WKUPDEP_UART1_SDMA_SHIFT 3
2096#define OMAP4430_WKUPDEP_UART1_SDMA_MASK BITFIELD(3, 3) 2204#define OMAP4430_WKUPDEP_UART1_SDMA_MASK (1 << 3)
2097 2205
2098/* Used by PM_L4PER_UART2_WKDEP */ 2206/* Used by PM_L4PER_UART2_WKDEP */
2099#define OMAP4430_WKUPDEP_UART2_MPU_SHIFT 0 2207#define OMAP4430_WKUPDEP_UART2_MPU_SHIFT 0
2100#define OMAP4430_WKUPDEP_UART2_MPU_MASK BITFIELD(0, 0) 2208#define OMAP4430_WKUPDEP_UART2_MPU_MASK (1 << 0)
2101 2209
2102/* Used by PM_L4PER_UART2_WKDEP */ 2210/* Used by PM_L4PER_UART2_WKDEP */
2103#define OMAP4430_WKUPDEP_UART2_SDMA_SHIFT 3 2211#define OMAP4430_WKUPDEP_UART2_SDMA_SHIFT 3
2104#define OMAP4430_WKUPDEP_UART2_SDMA_MASK BITFIELD(3, 3) 2212#define OMAP4430_WKUPDEP_UART2_SDMA_MASK (1 << 3)
2105 2213
2106/* Used by PM_L4PER_UART3_WKDEP */ 2214/* Used by PM_L4PER_UART3_WKDEP */
2107#define OMAP4430_WKUPDEP_UART3_DUCATI_SHIFT 1 2215#define OMAP4430_WKUPDEP_UART3_DUCATI_SHIFT 1
2108#define OMAP4430_WKUPDEP_UART3_DUCATI_MASK BITFIELD(1, 1) 2216#define OMAP4430_WKUPDEP_UART3_DUCATI_MASK (1 << 1)
2109 2217
2110/* Used by PM_L4PER_UART3_WKDEP */ 2218/* Used by PM_L4PER_UART3_WKDEP */
2111#define OMAP4430_WKUPDEP_UART3_MPU_SHIFT 0 2219#define OMAP4430_WKUPDEP_UART3_MPU_SHIFT 0
2112#define OMAP4430_WKUPDEP_UART3_MPU_MASK BITFIELD(0, 0) 2220#define OMAP4430_WKUPDEP_UART3_MPU_MASK (1 << 0)
2113 2221
2114/* Used by PM_L4PER_UART3_WKDEP */ 2222/* Used by PM_L4PER_UART3_WKDEP */
2115#define OMAP4430_WKUPDEP_UART3_SDMA_SHIFT 3 2223#define OMAP4430_WKUPDEP_UART3_SDMA_SHIFT 3
2116#define OMAP4430_WKUPDEP_UART3_SDMA_MASK BITFIELD(3, 3) 2224#define OMAP4430_WKUPDEP_UART3_SDMA_MASK (1 << 3)
2117 2225
2118/* Used by PM_L4PER_UART3_WKDEP */ 2226/* Used by PM_L4PER_UART3_WKDEP */
2119#define OMAP4430_WKUPDEP_UART3_TESLA_SHIFT 2 2227#define OMAP4430_WKUPDEP_UART3_TESLA_SHIFT 2
2120#define OMAP4430_WKUPDEP_UART3_TESLA_MASK BITFIELD(2, 2) 2228#define OMAP4430_WKUPDEP_UART3_TESLA_MASK (1 << 2)
2121 2229
2122/* Used by PM_L4PER_UART4_WKDEP */ 2230/* Used by PM_L4PER_UART4_WKDEP */
2123#define OMAP4430_WKUPDEP_UART4_MPU_SHIFT 0 2231#define OMAP4430_WKUPDEP_UART4_MPU_SHIFT 0
2124#define OMAP4430_WKUPDEP_UART4_MPU_MASK BITFIELD(0, 0) 2232#define OMAP4430_WKUPDEP_UART4_MPU_MASK (1 << 0)
2125 2233
2126/* Used by PM_L4PER_UART4_WKDEP */ 2234/* Used by PM_L4PER_UART4_WKDEP */
2127#define OMAP4430_WKUPDEP_UART4_SDMA_SHIFT 3 2235#define OMAP4430_WKUPDEP_UART4_SDMA_SHIFT 3
2128#define OMAP4430_WKUPDEP_UART4_SDMA_MASK BITFIELD(3, 3) 2236#define OMAP4430_WKUPDEP_UART4_SDMA_MASK (1 << 3)
2129 2237
2130/* Used by PM_L3INIT_UNIPRO1_WKDEP */ 2238/* Used by PM_L3INIT_UNIPRO1_WKDEP */
2131#define OMAP4430_WKUPDEP_UNIPRO1_DUCATI_SHIFT 1 2239#define OMAP4430_WKUPDEP_UNIPRO1_DUCATI_SHIFT 1
2132#define OMAP4430_WKUPDEP_UNIPRO1_DUCATI_MASK BITFIELD(1, 1) 2240#define OMAP4430_WKUPDEP_UNIPRO1_DUCATI_MASK (1 << 1)
2133 2241
2134/* Used by PM_L3INIT_UNIPRO1_WKDEP */ 2242/* Used by PM_L3INIT_UNIPRO1_WKDEP */
2135#define OMAP4430_WKUPDEP_UNIPRO1_MPU_SHIFT 0 2243#define OMAP4430_WKUPDEP_UNIPRO1_MPU_SHIFT 0
2136#define OMAP4430_WKUPDEP_UNIPRO1_MPU_MASK BITFIELD(0, 0) 2244#define OMAP4430_WKUPDEP_UNIPRO1_MPU_MASK (1 << 0)
2137 2245
2138/* Used by PM_L3INIT_USB_HOST_WKDEP */ 2246/* Used by PM_L3INIT_USB_HOST_WKDEP */
2139#define OMAP4430_WKUPDEP_USB_HOST_DUCATI_SHIFT 1 2247#define OMAP4430_WKUPDEP_USB_HOST_DUCATI_SHIFT 1
2140#define OMAP4430_WKUPDEP_USB_HOST_DUCATI_MASK BITFIELD(1, 1) 2248#define OMAP4430_WKUPDEP_USB_HOST_DUCATI_MASK (1 << 1)
2141 2249
2142/* Used by PM_L3INIT_USB_HOST_FS_WKDEP */ 2250/* Used by PM_L3INIT_USB_HOST_FS_WKDEP */
2143#define OMAP4430_WKUPDEP_USB_HOST_FS_DUCATI_SHIFT 1 2251#define OMAP4430_WKUPDEP_USB_HOST_FS_DUCATI_SHIFT 1
2144#define OMAP4430_WKUPDEP_USB_HOST_FS_DUCATI_MASK BITFIELD(1, 1) 2252#define OMAP4430_WKUPDEP_USB_HOST_FS_DUCATI_MASK (1 << 1)
2145 2253
2146/* Used by PM_L3INIT_USB_HOST_FS_WKDEP */ 2254/* Used by PM_L3INIT_USB_HOST_FS_WKDEP */
2147#define OMAP4430_WKUPDEP_USB_HOST_FS_MPU_SHIFT 0 2255#define OMAP4430_WKUPDEP_USB_HOST_FS_MPU_SHIFT 0
2148#define OMAP4430_WKUPDEP_USB_HOST_FS_MPU_MASK BITFIELD(0, 0) 2256#define OMAP4430_WKUPDEP_USB_HOST_FS_MPU_MASK (1 << 0)
2149 2257
2150/* Used by PM_L3INIT_USB_HOST_WKDEP */ 2258/* Used by PM_L3INIT_USB_HOST_WKDEP */
2151#define OMAP4430_WKUPDEP_USB_HOST_MPU_SHIFT 0 2259#define OMAP4430_WKUPDEP_USB_HOST_MPU_SHIFT 0
2152#define OMAP4430_WKUPDEP_USB_HOST_MPU_MASK BITFIELD(0, 0) 2260#define OMAP4430_WKUPDEP_USB_HOST_MPU_MASK (1 << 0)
2153 2261
2154/* Used by PM_L3INIT_USB_OTG_WKDEP */ 2262/* Used by PM_L3INIT_USB_OTG_WKDEP */
2155#define OMAP4430_WKUPDEP_USB_OTG_DUCATI_SHIFT 1 2263#define OMAP4430_WKUPDEP_USB_OTG_DUCATI_SHIFT 1
2156#define OMAP4430_WKUPDEP_USB_OTG_DUCATI_MASK BITFIELD(1, 1) 2264#define OMAP4430_WKUPDEP_USB_OTG_DUCATI_MASK (1 << 1)
2157 2265
2158/* Used by PM_L3INIT_USB_OTG_WKDEP */ 2266/* Used by PM_L3INIT_USB_OTG_WKDEP */
2159#define OMAP4430_WKUPDEP_USB_OTG_MPU_SHIFT 0 2267#define OMAP4430_WKUPDEP_USB_OTG_MPU_SHIFT 0
2160#define OMAP4430_WKUPDEP_USB_OTG_MPU_MASK BITFIELD(0, 0) 2268#define OMAP4430_WKUPDEP_USB_OTG_MPU_MASK (1 << 0)
2161 2269
2162/* Used by PM_L3INIT_USB_TLL_WKDEP */ 2270/* Used by PM_L3INIT_USB_TLL_WKDEP */
2163#define OMAP4430_WKUPDEP_USB_TLL_DUCATI_SHIFT 1 2271#define OMAP4430_WKUPDEP_USB_TLL_DUCATI_SHIFT 1
2164#define OMAP4430_WKUPDEP_USB_TLL_DUCATI_MASK BITFIELD(1, 1) 2272#define OMAP4430_WKUPDEP_USB_TLL_DUCATI_MASK (1 << 1)
2165 2273
2166/* Used by PM_L3INIT_USB_TLL_WKDEP */ 2274/* Used by PM_L3INIT_USB_TLL_WKDEP */
2167#define OMAP4430_WKUPDEP_USB_TLL_MPU_SHIFT 0 2275#define OMAP4430_WKUPDEP_USB_TLL_MPU_SHIFT 0
2168#define OMAP4430_WKUPDEP_USB_TLL_MPU_MASK BITFIELD(0, 0) 2276#define OMAP4430_WKUPDEP_USB_TLL_MPU_MASK (1 << 0)
2169 2277
2170/* Used by PM_WKUP_USIM_WKDEP */ 2278/* Used by PM_WKUP_USIM_WKDEP */
2171#define OMAP4430_WKUPDEP_USIM_MPU_SHIFT 0 2279#define OMAP4430_WKUPDEP_USIM_MPU_SHIFT 0
2172#define OMAP4430_WKUPDEP_USIM_MPU_MASK BITFIELD(0, 0) 2280#define OMAP4430_WKUPDEP_USIM_MPU_MASK (1 << 0)
2173 2281
2174/* Used by PM_WKUP_USIM_WKDEP */ 2282/* Used by PM_WKUP_USIM_WKDEP */
2175#define OMAP4430_WKUPDEP_USIM_SDMA_SHIFT 3 2283#define OMAP4430_WKUPDEP_USIM_SDMA_SHIFT 3
2176#define OMAP4430_WKUPDEP_USIM_SDMA_MASK BITFIELD(3, 3) 2284#define OMAP4430_WKUPDEP_USIM_SDMA_MASK (1 << 3)
2177 2285
2178/* Used by PM_WKUP_WDT2_WKDEP */ 2286/* Used by PM_WKUP_WDT2_WKDEP */
2179#define OMAP4430_WKUPDEP_WDT2_DUCATI_SHIFT 1 2287#define OMAP4430_WKUPDEP_WDT2_DUCATI_SHIFT 1
2180#define OMAP4430_WKUPDEP_WDT2_DUCATI_MASK BITFIELD(1, 1) 2288#define OMAP4430_WKUPDEP_WDT2_DUCATI_MASK (1 << 1)
2181 2289
2182/* Used by PM_WKUP_WDT2_WKDEP */ 2290/* Used by PM_WKUP_WDT2_WKDEP */
2183#define OMAP4430_WKUPDEP_WDT2_MPU_SHIFT 0 2291#define OMAP4430_WKUPDEP_WDT2_MPU_SHIFT 0
2184#define OMAP4430_WKUPDEP_WDT2_MPU_MASK BITFIELD(0, 0) 2292#define OMAP4430_WKUPDEP_WDT2_MPU_MASK (1 << 0)
2185 2293
2186/* Used by PM_ABE_WDT3_WKDEP */ 2294/* Used by PM_ABE_WDT3_WKDEP */
2187#define OMAP4430_WKUPDEP_WDT3_MPU_SHIFT 0 2295#define OMAP4430_WKUPDEP_WDT3_MPU_SHIFT 0
2188#define OMAP4430_WKUPDEP_WDT3_MPU_MASK BITFIELD(0, 0) 2296#define OMAP4430_WKUPDEP_WDT3_MPU_MASK (1 << 0)
2189 2297
2190/* Used by PM_L3INIT_HSI_WKDEP */ 2298/* Used by PM_L3INIT_HSI_WKDEP */
2191#define OMAP4430_WKUPDEP_WGM_HSI_WAKE_MPU_SHIFT 8 2299#define OMAP4430_WKUPDEP_WGM_HSI_WAKE_MPU_SHIFT 8
2192#define OMAP4430_WKUPDEP_WGM_HSI_WAKE_MPU_MASK BITFIELD(8, 8) 2300#define OMAP4430_WKUPDEP_WGM_HSI_WAKE_MPU_MASK (1 << 8)
2193 2301
2194/* Used by PM_L3INIT_XHPI_WKDEP */ 2302/* Used by PM_L3INIT_XHPI_WKDEP */
2195#define OMAP4430_WKUPDEP_XHPI_DUCATI_SHIFT 1 2303#define OMAP4430_WKUPDEP_XHPI_DUCATI_SHIFT 1
2196#define OMAP4430_WKUPDEP_XHPI_DUCATI_MASK BITFIELD(1, 1) 2304#define OMAP4430_WKUPDEP_XHPI_DUCATI_MASK (1 << 1)
2197 2305
2198/* Used by PRM_IO_PMCTRL */ 2306/* Used by PRM_IO_PMCTRL */
2199#define OMAP4430_WUCLK_CTRL_SHIFT 8 2307#define OMAP4430_WUCLK_CTRL_SHIFT 8
2200#define OMAP4430_WUCLK_CTRL_MASK BITFIELD(8, 8) 2308#define OMAP4430_WUCLK_CTRL_MASK (1 << 8)
2201 2309
2202/* Used by PRM_IO_PMCTRL */ 2310/* Used by PRM_IO_PMCTRL */
2203#define OMAP4430_WUCLK_STATUS_SHIFT 9 2311#define OMAP4430_WUCLK_STATUS_SHIFT 9
2204#define OMAP4430_WUCLK_STATUS_MASK BITFIELD(9, 9) 2312#define OMAP4430_WUCLK_STATUS_MASK (1 << 9)
2313
2314/* Used by REVISION_PRM */
2315#define OMAP4430_X_MAJOR_SHIFT 8
2316#define OMAP4430_X_MAJOR_MASK (0x7 << 8)
2317
2318/* Used by REVISION_PRM */
2319#define OMAP4430_Y_MINOR_SHIFT 0
2320#define OMAP4430_Y_MINOR_MASK (0x3f << 0)
2205#endif 2321#endif
diff --git a/arch/arm/mach-omap2/prm.h b/arch/arm/mach-omap2/prm.h
index 588873b9303a..7be040b2fdab 100644
--- a/arch/arm/mach-omap2/prm.h
+++ b/arch/arm/mach-omap2/prm.h
@@ -5,7 +5,7 @@
5 * OMAP2/3 Power/Reset Management (PRM) register definitions 5 * OMAP2/3 Power/Reset Management (PRM) register definitions
6 * 6 *
7 * Copyright (C) 2007-2009 Texas Instruments, Inc. 7 * Copyright (C) 2007-2009 Texas Instruments, Inc.
8 * Copyright (C) 2009 Nokia Corporation 8 * Copyright (C) 2010 Nokia Corporation
9 * 9 *
10 * Written by Paul Walmsley 10 * Written by Paul Walmsley
11 * 11 *
@@ -246,6 +246,15 @@ static inline u32 prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
246 return prm_rmw_mod_reg_bits(bits, 0x0, module, idx); 246 return prm_rmw_mod_reg_bits(bits, 0x0, module, idx);
247} 247}
248 248
249/* These omap2_ PRM functions apply to both OMAP2 and 3 */
250int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift);
251int omap2_prm_assert_hardreset(s16 prm_mod, u8 shift);
252int omap2_prm_deassert_hardreset(s16 prm_mod, u8 shift);
253
254int omap4_prm_is_hardreset_asserted(void __iomem *rstctrl_reg, u8 shift);
255int omap4_prm_assert_hardreset(void __iomem *rstctrl_reg, u8 shift);
256int omap4_prm_deassert_hardreset(void __iomem *rstctrl_reg, u8 shift);
257
249#endif 258#endif
250 259
251/* 260/*
@@ -398,4 +407,11 @@ static inline u32 prm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx)
398#define OMAP_POWERSTATE_MASK (0x3 << 0) 407#define OMAP_POWERSTATE_MASK (0x3 << 0)
399 408
400 409
410/*
411 * MAX_MODULE_HARDRESET_WAIT: Maximum microseconds to wait for an OMAP
412 * submodule to exit hardreset
413 */
414#define MAX_MODULE_HARDRESET_WAIT 10000
415
416
401#endif 417#endif
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c
new file mode 100644
index 000000000000..421771eee450
--- /dev/null
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -0,0 +1,110 @@
1/*
2 * OMAP2/3 PRM module functions
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
6 * Benoît Cousson
7 * Paul Walmsley
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/kernel.h>
15#include <linux/delay.h>
16#include <linux/errno.h>
17#include <linux/err.h>
18
19#include <plat/common.h>
20#include <plat/cpu.h>
21#include <plat/prcm.h>
22
23#include "prm.h"
24#include "prm-regbits-24xx.h"
25#include "prm-regbits-34xx.h"
26
27/**
28 * omap2_prm_is_hardreset_asserted - read the HW reset line state of
29 * submodules contained in the hwmod module
30 * @prm_mod: PRM submodule base (e.g. CORE_MOD)
31 * @shift: register bit shift corresponding to the reset line to check
32 *
33 * Returns 1 if the (sub)module hardreset line is currently asserted,
34 * 0 if the (sub)module hardreset line is not currently asserted, or
35 * -EINVAL if called while running on a non-OMAP2/3 chip.
36 */
37int omap2_prm_is_hardreset_asserted(s16 prm_mod, u8 shift)
38{
39 if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
40 return -EINVAL;
41
42 return prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL,
43 (1 << shift));
44}
45
46/**
47 * omap2_prm_assert_hardreset - assert the HW reset line of a submodule
48 * @prm_mod: PRM submodule base (e.g. CORE_MOD)
49 * @shift: register bit shift corresponding to the reset line to assert
50 *
51 * Some IPs like dsp or iva contain processors that require an HW
52 * reset line to be asserted / deasserted in order to fully enable the
53 * IP. These modules may have multiple hard-reset lines that reset
54 * different 'submodules' inside the IP block. This function will
55 * place the submodule into reset. Returns 0 upon success or -EINVAL
56 * upon an argument error.
57 */
58int omap2_prm_assert_hardreset(s16 prm_mod, u8 shift)
59{
60 u32 mask;
61
62 if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
63 return -EINVAL;
64
65 mask = 1 << shift;
66 prm_rmw_mod_reg_bits(mask, mask, prm_mod, OMAP2_RM_RSTCTRL);
67
68 return 0;
69}
70
71/**
72 * omap2_prm_deassert_hardreset - deassert a submodule hardreset line and wait
73 * @prm_mod: PRM submodule base (e.g. CORE_MOD)
74 * @shift: register bit shift corresponding to the reset line to deassert
75 *
76 * Some IPs like dsp or iva contain processors that require an HW
77 * reset line to be asserted / deasserted in order to fully enable the
78 * IP. These modules may have multiple hard-reset lines that reset
79 * different 'submodules' inside the IP block. This function will
80 * take the submodule out of reset and wait until the PRCM indicates
81 * that the reset has completed before returning. Returns 0 upon success or
82 * -EINVAL upon an argument error, -EEXIST if the submodule was already out
83 * of reset, or -EBUSY if the submodule did not exit reset promptly.
84 */
85int omap2_prm_deassert_hardreset(s16 prm_mod, u8 shift)
86{
87 u32 mask;
88 int c;
89
90 if (!(cpu_is_omap24xx() || cpu_is_omap34xx()))
91 return -EINVAL;
92
93 mask = 1 << shift;
94
95 /* Check the current status to avoid de-asserting the line twice */
96 if (prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTCTRL, mask) == 0)
97 return -EEXIST;
98
99 /* Clear the reset status by writing 1 to the status bit */
100 prm_rmw_mod_reg_bits(0xffffffff, mask, prm_mod, OMAP2_RM_RSTST);
101 /* de-assert the reset control line */
102 prm_rmw_mod_reg_bits(mask, 0, prm_mod, OMAP2_RM_RSTCTRL);
103 /* wait the status to be set */
104 omap_test_timeout(prm_read_mod_bits_shift(prm_mod, OMAP2_RM_RSTST,
105 mask),
106 MAX_MODULE_HARDRESET_WAIT, c);
107
108 return (c == MAX_MODULE_HARDRESET_WAIT) ? -EBUSY : 0;
109}
110
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
new file mode 100644
index 000000000000..a1ff918d9bed
--- /dev/null
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -0,0 +1,116 @@
1/*
2 * OMAP4 PRM module functions
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
6 * Benoît Cousson
7 * Paul Walmsley
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/kernel.h>
15#include <linux/delay.h>
16#include <linux/errno.h>
17#include <linux/err.h>
18
19#include <plat/common.h>
20#include <plat/cpu.h>
21#include <plat/prcm.h>
22
23#include "prm.h"
24#include "prm-regbits-44xx.h"
25
26/*
27 * Address offset (in bytes) between the reset control and the reset
28 * status registers: 4 bytes on OMAP4
29 */
30#define OMAP4_RST_CTRL_ST_OFFSET 4
31
32/**
33 * omap4_prm_is_hardreset_asserted - read the HW reset line state of
34 * submodules contained in the hwmod module
35 * @rstctrl_reg: RM_RSTCTRL register address for this module
36 * @shift: register bit shift corresponding to the reset line to check
37 *
38 * Returns 1 if the (sub)module hardreset line is currently asserted,
39 * 0 if the (sub)module hardreset line is not currently asserted, or
40 * -EINVAL upon parameter error.
41 */
42int omap4_prm_is_hardreset_asserted(void __iomem *rstctrl_reg, u8 shift)
43{
44 if (!cpu_is_omap44xx() || !rstctrl_reg)
45 return -EINVAL;
46
47 return omap4_prm_read_bits_shift(rstctrl_reg, (1 << shift));
48}
49
50/**
51 * omap4_prm_assert_hardreset - assert the HW reset line of a submodule
52 * @rstctrl_reg: RM_RSTCTRL register address for this module
53 * @shift: register bit shift corresponding to the reset line to assert
54 *
55 * Some IPs like dsp, ipu or iva contain processors that require an HW
56 * reset line to be asserted / deasserted in order to fully enable the
57 * IP. These modules may have multiple hard-reset lines that reset
58 * different 'submodules' inside the IP block. This function will
59 * place the submodule into reset. Returns 0 upon success or -EINVAL
60 * upon an argument error.
61 */
62int omap4_prm_assert_hardreset(void __iomem *rstctrl_reg, u8 shift)
63{
64 u32 mask;
65
66 if (!cpu_is_omap44xx() || !rstctrl_reg)
67 return -EINVAL;
68
69 mask = 1 << shift;
70 omap4_prm_rmw_reg_bits(mask, mask, rstctrl_reg);
71
72 return 0;
73}
74
75/**
76 * omap4_prm_deassert_hardreset - deassert a submodule hardreset line and wait
77 * @rstctrl_reg: RM_RSTCTRL register address for this module
78 * @shift: register bit shift corresponding to the reset line to deassert
79 *
80 * Some IPs like dsp, ipu or iva contain processors that require an HW
81 * reset line to be asserted / deasserted in order to fully enable the
82 * IP. These modules may have multiple hard-reset lines that reset
83 * different 'submodules' inside the IP block. This function will
84 * take the submodule out of reset and wait until the PRCM indicates
85 * that the reset has completed before returning. Returns 0 upon success or
86 * -EINVAL upon an argument error, -EEXIST if the submodule was already out
87 * of reset, or -EBUSY if the submodule did not exit reset promptly.
88 */
89int omap4_prm_deassert_hardreset(void __iomem *rstctrl_reg, u8 shift)
90{
91 u32 mask;
92 void __iomem *rstst_reg;
93 int c;
94
95 if (!cpu_is_omap44xx() || !rstctrl_reg)
96 return -EINVAL;
97
98 rstst_reg = rstctrl_reg + OMAP4_RST_CTRL_ST_OFFSET;
99
100 mask = 1 << shift;
101
102 /* Check the current status to avoid de-asserting the line twice */
103 if (omap4_prm_read_bits_shift(rstctrl_reg, mask) == 0)
104 return -EEXIST;
105
106 /* Clear the reset status by writing 1 to the status bit */
107 omap4_prm_rmw_reg_bits(0xffffffff, mask, rstst_reg);
108 /* de-assert the reset control line */
109 omap4_prm_rmw_reg_bits(mask, 0, rstctrl_reg);
110 /* wait the status to be set */
111 omap_test_timeout(omap4_prm_read_bits_shift(rstst_reg, mask),
112 MAX_MODULE_HARDRESET_WAIT, c);
113
114 return (c == MAX_MODULE_HARDRESET_WAIT) ? -EBUSY : 0;
115}
116
diff --git a/arch/arm/mach-omap2/prm44xx.h b/arch/arm/mach-omap2/prm44xx.h
index fe8ef26431e5..59839dbabd84 100644
--- a/arch/arm/mach-omap2/prm44xx.h
+++ b/arch/arm/mach-omap2/prm44xx.h
@@ -44,14 +44,12 @@
44#define OMAP4430_PRM_IRQSTATUS_TESLA OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0030) 44#define OMAP4430_PRM_IRQSTATUS_TESLA OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0030)
45#define OMAP4_PRM_IRQENABLE_TESLA_OFFSET 0x0038 45#define OMAP4_PRM_IRQENABLE_TESLA_OFFSET 0x0038
46#define OMAP4430_PRM_IRQENABLE_TESLA OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0038) 46#define OMAP4430_PRM_IRQENABLE_TESLA OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0038)
47#define OMAP4_PRM_PRM_PROFILING_CLKCTRL_OFFSET 0x0040 47#define OMAP4_CM_PRM_PROFILING_CLKCTRL_OFFSET 0x0040
48#define OMAP4430_PRM_PRM_PROFILING_CLKCTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0040) 48#define OMAP4430_CM_PRM_PROFILING_CLKCTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_OCP_SOCKET_MOD, 0x0040)
49 49
50/* PRM.CKGEN_PRM register offsets */ 50/* PRM.CKGEN_PRM register offsets */
51#define OMAP4_CM_ABE_DSS_SYS_CLKSEL_OFFSET 0x0000 51#define OMAP4_CM_ABE_DSS_SYS_CLKSEL_OFFSET 0x0000
52#define OMAP4430_CM_ABE_DSS_SYS_CLKSEL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_CKGEN_MOD, 0x0000) 52#define OMAP4430_CM_ABE_DSS_SYS_CLKSEL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_CKGEN_MOD, 0x0000)
53#define OMAP4_CM_DPLL_SYS_REF_CLKSEL_OFFSET 0x0004
54#define OMAP4430_CM_DPLL_SYS_REF_CLKSEL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_CKGEN_MOD, 0x0004)
55#define OMAP4_CM_L4_WKUP_CLKSEL_OFFSET 0x0008 53#define OMAP4_CM_L4_WKUP_CLKSEL_OFFSET 0x0008
56#define OMAP4430_CM_L4_WKUP_CLKSEL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_CKGEN_MOD, 0x0008) 54#define OMAP4430_CM_L4_WKUP_CLKSEL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_CKGEN_MOD, 0x0008)
57#define OMAP4_CM_ABE_PLL_REF_CLKSEL_OFFSET 0x000c 55#define OMAP4_CM_ABE_PLL_REF_CLKSEL_OFFSET 0x000c
@@ -686,8 +684,8 @@
686#define OMAP4430_PRM_LDO_ABB_IVA_SETUP OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00d8) 684#define OMAP4430_PRM_LDO_ABB_IVA_SETUP OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00d8)
687#define OMAP4_PRM_LDO_ABB_IVA_CTRL_OFFSET 0x00dc 685#define OMAP4_PRM_LDO_ABB_IVA_CTRL_OFFSET 0x00dc
688#define OMAP4430_PRM_LDO_ABB_IVA_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00dc) 686#define OMAP4430_PRM_LDO_ABB_IVA_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00dc)
689#define OMAP4_PRM_LDO_BANDGAP_CTRL_OFFSET 0x00e0 687#define OMAP4_PRM_LDO_BANDGAP_SETUP_OFFSET 0x00e0
690#define OMAP4430_PRM_LDO_BANDGAP_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00e0) 688#define OMAP4430_PRM_LDO_BANDGAP_SETUP OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00e0)
691#define OMAP4_PRM_DEVICE_OFF_CTRL_OFFSET 0x00e4 689#define OMAP4_PRM_DEVICE_OFF_CTRL_OFFSET 0x00e4
692#define OMAP4430_PRM_DEVICE_OFF_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00e4) 690#define OMAP4430_PRM_DEVICE_OFF_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00e4)
693#define OMAP4_PRM_PHASE1_CNDP_OFFSET 0x00e8 691#define OMAP4_PRM_PHASE1_CNDP_OFFSET 0x00e8
@@ -698,6 +696,8 @@
698#define OMAP4430_PRM_PHASE2B_CNDP OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00f0) 696#define OMAP4430_PRM_PHASE2B_CNDP OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00f0)
699#define OMAP4_PRM_MODEM_IF_CTRL_OFFSET 0x00f4 697#define OMAP4_PRM_MODEM_IF_CTRL_OFFSET 0x00f4
700#define OMAP4430_PRM_MODEM_IF_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00f4) 698#define OMAP4430_PRM_MODEM_IF_CTRL OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00f4)
699#define OMAP4_PRM_VC_ERRST_OFFSET 0x00f8
700#define OMAP4430_PRM_VC_ERRST OMAP44XX_PRM_REGADDR(OMAP4430_PRM_DEVICE_MOD, 0x00f8)
701 701
702/* 702/*
703 * PRCM_MPU 703 * PRCM_MPU
@@ -715,6 +715,8 @@
715/* PRCM_MPU.DEVICE_PRM register offsets */ 715/* PRCM_MPU.DEVICE_PRM register offsets */
716#define OMAP4_PRCM_MPU_PRM_RSTST_OFFSET 0x0000 716#define OMAP4_PRCM_MPU_PRM_RSTST_OFFSET 0x0000
717#define OMAP4430_PRCM_MPU_PRM_RSTST OMAP44XX_PRCM_MPU_REGADDR(OMAP4430_PRCM_MPU_DEVICE_PRM_MOD, 0x0000) 717#define OMAP4430_PRCM_MPU_PRM_RSTST OMAP44XX_PRCM_MPU_REGADDR(OMAP4430_PRCM_MPU_DEVICE_PRM_MOD, 0x0000)
718#define OMAP4_PRCM_MPU_PRM_PSCON_COUNT_OFFSET 0x0004
719#define OMAP4430_PRCM_MPU_PRM_PSCON_COUNT OMAP44XX_PRCM_MPU_REGADDR(OMAP4430_PRCM_MPU_DEVICE_PRM_MOD, 0x0004)
718 720
719/* PRCM_MPU.CPU0 register offsets */ 721/* PRCM_MPU.CPU0 register offsets */
720#define OMAP4_PM_CPU0_PWRSTCTRL_OFFSET 0x0000 722#define OMAP4_PM_CPU0_PWRSTCTRL_OFFSET 0x0000
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 566e991ede81..becf0e38ef7e 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -19,20 +19,31 @@
19 */ 19 */
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/serial_8250.h>
23#include <linux/serial_reg.h> 22#include <linux/serial_reg.h>
24#include <linux/clk.h> 23#include <linux/clk.h>
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/platform_device.h>
27#include <linux/slab.h>
28#include <linux/serial_8250.h>
29#include <linux/pm_runtime.h>
30
31#ifdef CONFIG_SERIAL_OMAP
32#include <plat/omap-serial.h>
33#endif
27 34
28#include <plat/common.h> 35#include <plat/common.h>
29#include <plat/board.h> 36#include <plat/board.h>
30#include <plat/clock.h> 37#include <plat/clock.h>
31#include <plat/control.h> 38#include <plat/dma.h>
39#include <plat/omap_hwmod.h>
40#include <plat/omap_device.h>
32 41
33#include "prm.h" 42#include "prm.h"
34#include "pm.h" 43#include "pm.h"
44#include "cm.h"
35#include "prm-regbits-34xx.h" 45#include "prm-regbits-34xx.h"
46#include "control.h"
36 47
37#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV 0x52 48#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV 0x52
38#define UART_OMAP_WER 0x17 /* Wake-up enable register */ 49#define UART_OMAP_WER 0x17 /* Wake-up enable register */
@@ -48,6 +59,8 @@
48 */ 59 */
49#define DEFAULT_TIMEOUT 0 60#define DEFAULT_TIMEOUT 0
50 61
62#define MAX_UART_HWMOD_NAME_LEN 16
63
51struct omap_uart_state { 64struct omap_uart_state {
52 int num; 65 int num;
53 int can_sleep; 66 int can_sleep;
@@ -58,14 +71,21 @@ struct omap_uart_state {
58 void __iomem *wk_en; 71 void __iomem *wk_en;
59 u32 wk_mask; 72 u32 wk_mask;
60 u32 padconf; 73 u32 padconf;
74 u32 dma_enabled;
61 75
62 struct clk *ick; 76 struct clk *ick;
63 struct clk *fck; 77 struct clk *fck;
64 int clocked; 78 int clocked;
65 79
66 struct plat_serial8250_port *p; 80 int irq;
81 int regshift;
82 int irqflags;
83 void __iomem *membase;
84 resource_size_t mapbase;
85
67 struct list_head node; 86 struct list_head node;
68 struct platform_device pdev; 87 struct omap_hwmod *oh;
88 struct platform_device *pdev;
69 89
70 u32 errata; 90 u32 errata;
71#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM) 91#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
@@ -83,75 +103,47 @@ struct omap_uart_state {
83}; 103};
84 104
85static LIST_HEAD(uart_list); 105static LIST_HEAD(uart_list);
106static u8 num_uarts;
86 107
87static struct plat_serial8250_port serial_platform_data0[] = { 108/*
88 { 109 * Since these idle/enable hooks are used in the idle path itself
89 .irq = 72, 110 * which has interrupts disabled, use the non-locking versions of
90 .flags = UPF_BOOT_AUTOCONF, 111 * the hwmod enable/disable functions.
91 .iotype = UPIO_MEM, 112 */
92 .regshift = 2, 113static int uart_idle_hwmod(struct omap_device *od)
93 .uartclk = OMAP24XX_BASE_BAUD * 16, 114{
94 }, { 115 _omap_hwmod_idle(od->hwmods[0]);
95 .flags = 0
96 }
97};
98 116
99static struct plat_serial8250_port serial_platform_data1[] = { 117 return 0;
100 { 118}
101 .irq = 73,
102 .flags = UPF_BOOT_AUTOCONF,
103 .iotype = UPIO_MEM,
104 .regshift = 2,
105 .uartclk = OMAP24XX_BASE_BAUD * 16,
106 }, {
107 .flags = 0
108 }
109};
110 119
111static struct plat_serial8250_port serial_platform_data2[] = { 120static int uart_enable_hwmod(struct omap_device *od)
112 { 121{
113 .irq = 74, 122 _omap_hwmod_enable(od->hwmods[0]);
114 .flags = UPF_BOOT_AUTOCONF,
115 .iotype = UPIO_MEM,
116 .regshift = 2,
117 .uartclk = OMAP24XX_BASE_BAUD * 16,
118 }, {
119 .flags = 0
120 }
121};
122 123
123static struct plat_serial8250_port serial_platform_data3[] = { 124 return 0;
125}
126
127static struct omap_device_pm_latency omap_uart_latency[] = {
124 { 128 {
125 .irq = 70, 129 .deactivate_func = uart_idle_hwmod,
126 .flags = UPF_BOOT_AUTOCONF, 130 .activate_func = uart_enable_hwmod,
127 .iotype = UPIO_MEM, 131 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
128 .regshift = 2, 132 },
129 .uartclk = OMAP24XX_BASE_BAUD * 16,
130 }, {
131 .flags = 0
132 }
133}; 133};
134 134
135void __init omap2_set_globals_uart(struct omap_globals *omap2_globals)
136{
137 serial_platform_data0[0].mapbase = omap2_globals->uart1_phys;
138 serial_platform_data1[0].mapbase = omap2_globals->uart2_phys;
139 serial_platform_data2[0].mapbase = omap2_globals->uart3_phys;
140 serial_platform_data3[0].mapbase = omap2_globals->uart4_phys;
141}
142
143static inline unsigned int __serial_read_reg(struct uart_port *up, 135static inline unsigned int __serial_read_reg(struct uart_port *up,
144 int offset) 136 int offset)
145{ 137{
146 offset <<= up->regshift; 138 offset <<= up->regshift;
147 return (unsigned int)__raw_readb(up->membase + offset); 139 return (unsigned int)__raw_readb(up->membase + offset);
148} 140}
149 141
150static inline unsigned int serial_read_reg(struct plat_serial8250_port *up, 142static inline unsigned int serial_read_reg(struct omap_uart_state *uart,
151 int offset) 143 int offset)
152{ 144{
153 offset <<= up->regshift; 145 offset <<= uart->regshift;
154 return (unsigned int)__raw_readb(up->membase + offset); 146 return (unsigned int)__raw_readb(uart->membase + offset);
155} 147}
156 148
157static inline void __serial_write_reg(struct uart_port *up, int offset, 149static inline void __serial_write_reg(struct uart_port *up, int offset,
@@ -161,11 +153,11 @@ static inline void __serial_write_reg(struct uart_port *up, int offset,
161 __raw_writeb(value, up->membase + offset); 153 __raw_writeb(value, up->membase + offset);
162} 154}
163 155
164static inline void serial_write_reg(struct plat_serial8250_port *p, int offset, 156static inline void serial_write_reg(struct omap_uart_state *uart, int offset,
165 int value) 157 int value)
166{ 158{
167 offset <<= p->regshift; 159 offset <<= uart->regshift;
168 __raw_writeb(value, p->membase + offset); 160 __raw_writeb(value, uart->membase + offset);
169} 161}
170 162
171/* 163/*
@@ -173,14 +165,12 @@ static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
173 * properly. Note that the TX watermark initialization may not be needed 165 * properly. Note that the TX watermark initialization may not be needed
174 * once the 8250.c watermark handling code is merged. 166 * once the 8250.c watermark handling code is merged.
175 */ 167 */
168
176static inline void __init omap_uart_reset(struct omap_uart_state *uart) 169static inline void __init omap_uart_reset(struct omap_uart_state *uart)
177{ 170{
178 struct plat_serial8250_port *p = uart->p; 171 serial_write_reg(uart, UART_OMAP_MDR1, 0x07);
179 172 serial_write_reg(uart, UART_OMAP_SCR, 0x08);
180 serial_write_reg(p, UART_OMAP_MDR1, 0x07); 173 serial_write_reg(uart, UART_OMAP_MDR1, 0x00);
181 serial_write_reg(p, UART_OMAP_SCR, 0x08);
182 serial_write_reg(p, UART_OMAP_MDR1, 0x00);
183 serial_write_reg(p, UART_OMAP_SYSC, (0x02 << 3) | (1 << 2) | (1 << 0));
184} 174}
185 175
186#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) 176#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
@@ -197,24 +187,23 @@ static inline void __init omap_uart_reset(struct omap_uart_state *uart)
197static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val, 187static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val,
198 u8 fcr_val) 188 u8 fcr_val)
199{ 189{
200 struct plat_serial8250_port *p = uart->p;
201 u8 timeout = 255; 190 u8 timeout = 255;
202 191
203 serial_write_reg(p, UART_OMAP_MDR1, mdr1_val); 192 serial_write_reg(uart, UART_OMAP_MDR1, mdr1_val);
204 udelay(2); 193 udelay(2);
205 serial_write_reg(p, UART_FCR, fcr_val | UART_FCR_CLEAR_XMIT | 194 serial_write_reg(uart, UART_FCR, fcr_val | UART_FCR_CLEAR_XMIT |
206 UART_FCR_CLEAR_RCVR); 195 UART_FCR_CLEAR_RCVR);
207 /* 196 /*
208 * Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and 197 * Wait for FIFO to empty: when empty, RX_FIFO_E bit is 0 and
209 * TX_FIFO_E bit is 1. 198 * TX_FIFO_E bit is 1.
210 */ 199 */
211 while (UART_LSR_THRE != (serial_read_reg(p, UART_LSR) & 200 while (UART_LSR_THRE != (serial_read_reg(uart, UART_LSR) &
212 (UART_LSR_THRE | UART_LSR_DR))) { 201 (UART_LSR_THRE | UART_LSR_DR))) {
213 timeout--; 202 timeout--;
214 if (!timeout) { 203 if (!timeout) {
215 /* Should *never* happen. we warn and carry on */ 204 /* Should *never* happen. we warn and carry on */
216 dev_crit(&uart->pdev.dev, "Errata i202: timedout %x\n", 205 dev_crit(&uart->pdev->dev, "Errata i202: timedout %x\n",
217 serial_read_reg(p, UART_LSR)); 206 serial_read_reg(uart, UART_LSR));
218 break; 207 break;
219 } 208 }
220 udelay(1); 209 udelay(1);
@@ -224,23 +213,22 @@ static void omap_uart_mdr1_errataset(struct omap_uart_state *uart, u8 mdr1_val,
224static void omap_uart_save_context(struct omap_uart_state *uart) 213static void omap_uart_save_context(struct omap_uart_state *uart)
225{ 214{
226 u16 lcr = 0; 215 u16 lcr = 0;
227 struct plat_serial8250_port *p = uart->p;
228 216
229 if (!enable_off_mode) 217 if (!enable_off_mode)
230 return; 218 return;
231 219
232 lcr = serial_read_reg(p, UART_LCR); 220 lcr = serial_read_reg(uart, UART_LCR);
233 serial_write_reg(p, UART_LCR, 0xBF); 221 serial_write_reg(uart, UART_LCR, 0xBF);
234 uart->dll = serial_read_reg(p, UART_DLL); 222 uart->dll = serial_read_reg(uart, UART_DLL);
235 uart->dlh = serial_read_reg(p, UART_DLM); 223 uart->dlh = serial_read_reg(uart, UART_DLM);
236 serial_write_reg(p, UART_LCR, lcr); 224 serial_write_reg(uart, UART_LCR, lcr);
237 uart->ier = serial_read_reg(p, UART_IER); 225 uart->ier = serial_read_reg(uart, UART_IER);
238 uart->sysc = serial_read_reg(p, UART_OMAP_SYSC); 226 uart->sysc = serial_read_reg(uart, UART_OMAP_SYSC);
239 uart->scr = serial_read_reg(p, UART_OMAP_SCR); 227 uart->scr = serial_read_reg(uart, UART_OMAP_SCR);
240 uart->wer = serial_read_reg(p, UART_OMAP_WER); 228 uart->wer = serial_read_reg(uart, UART_OMAP_WER);
241 serial_write_reg(p, UART_LCR, 0x80); 229 serial_write_reg(uart, UART_LCR, 0x80);
242 uart->mcr = serial_read_reg(p, UART_MCR); 230 uart->mcr = serial_read_reg(uart, UART_MCR);
243 serial_write_reg(p, UART_LCR, lcr); 231 serial_write_reg(uart, UART_LCR, lcr);
244 232
245 uart->context_valid = 1; 233 uart->context_valid = 1;
246} 234}
@@ -248,7 +236,6 @@ static void omap_uart_save_context(struct omap_uart_state *uart)
248static void omap_uart_restore_context(struct omap_uart_state *uart) 236static void omap_uart_restore_context(struct omap_uart_state *uart)
249{ 237{
250 u16 efr = 0; 238 u16 efr = 0;
251 struct plat_serial8250_port *p = uart->p;
252 239
253 if (!enable_off_mode) 240 if (!enable_off_mode)
254 return; 241 return;
@@ -261,29 +248,30 @@ static void omap_uart_restore_context(struct omap_uart_state *uart)
261 if (uart->errata & UART_ERRATA_i202_MDR1_ACCESS) 248 if (uart->errata & UART_ERRATA_i202_MDR1_ACCESS)
262 omap_uart_mdr1_errataset(uart, 0x07, 0xA0); 249 omap_uart_mdr1_errataset(uart, 0x07, 0xA0);
263 else 250 else
264 serial_write_reg(p, UART_OMAP_MDR1, 0x7); 251 serial_write_reg(uart, UART_OMAP_MDR1, 0x7);
265 serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */ 252 serial_write_reg(uart, UART_LCR, 0xBF); /* Config B mode */
266 efr = serial_read_reg(p, UART_EFR); 253 efr = serial_read_reg(uart, UART_EFR);
267 serial_write_reg(p, UART_EFR, UART_EFR_ECB); 254 serial_write_reg(uart, UART_EFR, UART_EFR_ECB);
268 serial_write_reg(p, UART_LCR, 0x0); /* Operational mode */ 255 serial_write_reg(uart, UART_LCR, 0x0); /* Operational mode */
269 serial_write_reg(p, UART_IER, 0x0); 256 serial_write_reg(uart, UART_IER, 0x0);
270 serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */ 257 serial_write_reg(uart, UART_LCR, 0xBF); /* Config B mode */
271 serial_write_reg(p, UART_DLL, uart->dll); 258 serial_write_reg(uart, UART_DLL, uart->dll);
272 serial_write_reg(p, UART_DLM, uart->dlh); 259 serial_write_reg(uart, UART_DLM, uart->dlh);
273 serial_write_reg(p, UART_LCR, 0x0); /* Operational mode */ 260 serial_write_reg(uart, UART_LCR, 0x0); /* Operational mode */
274 serial_write_reg(p, UART_IER, uart->ier); 261 serial_write_reg(uart, UART_IER, uart->ier);
275 serial_write_reg(p, UART_LCR, 0x80); 262 serial_write_reg(uart, UART_LCR, 0x80);
276 serial_write_reg(p, UART_MCR, uart->mcr); 263 serial_write_reg(uart, UART_MCR, uart->mcr);
277 serial_write_reg(p, UART_LCR, 0xBF); /* Config B mode */ 264 serial_write_reg(uart, UART_LCR, 0xBF); /* Config B mode */
278 serial_write_reg(p, UART_EFR, efr); 265 serial_write_reg(uart, UART_EFR, efr);
279 serial_write_reg(p, UART_LCR, UART_LCR_WLEN8); 266 serial_write_reg(uart, UART_LCR, UART_LCR_WLEN8);
280 serial_write_reg(p, UART_OMAP_SCR, uart->scr); 267 serial_write_reg(uart, UART_OMAP_SCR, uart->scr);
281 serial_write_reg(p, UART_OMAP_WER, uart->wer); 268 serial_write_reg(uart, UART_OMAP_WER, uart->wer);
282 serial_write_reg(p, UART_OMAP_SYSC, uart->sysc); 269 serial_write_reg(uart, UART_OMAP_SYSC, uart->sysc);
283 if (uart->errata & UART_ERRATA_i202_MDR1_ACCESS) 270 if (uart->errata & UART_ERRATA_i202_MDR1_ACCESS)
284 omap_uart_mdr1_errataset(uart, 0x00, 0xA1); 271 omap_uart_mdr1_errataset(uart, 0x00, 0xA1);
285 else 272 else
286 serial_write_reg(p, UART_OMAP_MDR1, 0x00); /* UART 16x mode */ 273 /* UART 16x mode */
274 serial_write_reg(uart, UART_OMAP_MDR1, 0x00);
287} 275}
288#else 276#else
289static inline void omap_uart_save_context(struct omap_uart_state *uart) {} 277static inline void omap_uart_save_context(struct omap_uart_state *uart) {}
@@ -295,8 +283,7 @@ static inline void omap_uart_enable_clocks(struct omap_uart_state *uart)
295 if (uart->clocked) 283 if (uart->clocked)
296 return; 284 return;
297 285
298 clk_enable(uart->ick); 286 omap_device_enable(uart->pdev);
299 clk_enable(uart->fck);
300 uart->clocked = 1; 287 uart->clocked = 1;
301 omap_uart_restore_context(uart); 288 omap_uart_restore_context(uart);
302} 289}
@@ -310,8 +297,7 @@ static inline void omap_uart_disable_clocks(struct omap_uart_state *uart)
310 297
311 omap_uart_save_context(uart); 298 omap_uart_save_context(uart);
312 uart->clocked = 0; 299 uart->clocked = 0;
313 clk_disable(uart->ick); 300 omap_device_idle(uart->pdev);
314 clk_disable(uart->fck);
315} 301}
316 302
317static void omap_uart_enable_wakeup(struct omap_uart_state *uart) 303static void omap_uart_enable_wakeup(struct omap_uart_state *uart)
@@ -349,18 +335,24 @@ static void omap_uart_disable_wakeup(struct omap_uart_state *uart)
349} 335}
350 336
351static void omap_uart_smart_idle_enable(struct omap_uart_state *uart, 337static void omap_uart_smart_idle_enable(struct omap_uart_state *uart,
352 int enable) 338 int enable)
353{ 339{
354 struct plat_serial8250_port *p = uart->p; 340 u8 idlemode;
355 u16 sysc;
356 341
357 sysc = serial_read_reg(p, UART_OMAP_SYSC) & 0x7; 342 if (enable) {
358 if (enable) 343 /**
359 sysc |= 0x2 << 3; 344 * Errata 2.15: [UART]:Cannot Acknowledge Idle Requests
360 else 345 * in Smartidle Mode When Configured for DMA Operations.
361 sysc |= 0x1 << 3; 346 */
347 if (uart->dma_enabled)
348 idlemode = HWMOD_IDLEMODE_FORCE;
349 else
350 idlemode = HWMOD_IDLEMODE_SMART;
351 } else {
352 idlemode = HWMOD_IDLEMODE_NO;
353 }
362 354
363 serial_write_reg(p, UART_OMAP_SYSC, sysc); 355 omap_hwmod_set_slave_idlemode(uart->oh, idlemode);
364} 356}
365 357
366static void omap_uart_block_sleep(struct omap_uart_state *uart) 358static void omap_uart_block_sleep(struct omap_uart_state *uart)
@@ -377,7 +369,7 @@ static void omap_uart_block_sleep(struct omap_uart_state *uart)
377 369
378static void omap_uart_allow_sleep(struct omap_uart_state *uart) 370static void omap_uart_allow_sleep(struct omap_uart_state *uart)
379{ 371{
380 if (device_may_wakeup(&uart->pdev.dev)) 372 if (device_may_wakeup(&uart->pdev->dev))
381 omap_uart_enable_wakeup(uart); 373 omap_uart_enable_wakeup(uart);
382 else 374 else
383 omap_uart_disable_wakeup(uart); 375 omap_uart_disable_wakeup(uart);
@@ -472,6 +464,7 @@ int omap_uart_can_sleep(void)
472 * UART will not idle or sleep for its timeout period. 464 * UART will not idle or sleep for its timeout period.
473 * 465 *
474 **/ 466 **/
467/* static int first_interrupt; */
475static irqreturn_t omap_uart_interrupt(int irq, void *dev_id) 468static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
476{ 469{
477 struct omap_uart_state *uart = dev_id; 470 struct omap_uart_state *uart = dev_id;
@@ -483,7 +476,6 @@ static irqreturn_t omap_uart_interrupt(int irq, void *dev_id)
483 476
484static void omap_uart_idle_init(struct omap_uart_state *uart) 477static void omap_uart_idle_init(struct omap_uart_state *uart)
485{ 478{
486 struct plat_serial8250_port *p = uart->p;
487 int ret; 479 int ret;
488 480
489 uart->can_sleep = 0; 481 uart->can_sleep = 0;
@@ -495,7 +487,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
495 omap_uart_smart_idle_enable(uart, 0); 487 omap_uart_smart_idle_enable(uart, 0);
496 488
497 if (cpu_is_omap34xx()) { 489 if (cpu_is_omap34xx()) {
498 u32 mod = (uart->num == 2) ? OMAP3430_PER_MOD : CORE_MOD; 490 u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
499 u32 wk_mask = 0; 491 u32 wk_mask = 0;
500 u32 padconf = 0; 492 u32 padconf = 0;
501 493
@@ -514,19 +506,17 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
514 wk_mask = OMAP3430_ST_UART3_MASK; 506 wk_mask = OMAP3430_ST_UART3_MASK;
515 padconf = 0x19e; 507 padconf = 0x19e;
516 break; 508 break;
509 case 3:
510 wk_mask = OMAP3630_ST_UART4_MASK;
511 padconf = 0x0d2;
512 break;
517 } 513 }
518 uart->wk_mask = wk_mask; 514 uart->wk_mask = wk_mask;
519 uart->padconf = padconf; 515 uart->padconf = padconf;
520 } else if (cpu_is_omap24xx()) { 516 } else if (cpu_is_omap24xx()) {
521 u32 wk_mask = 0; 517 u32 wk_mask = 0;
518 u32 wk_en = PM_WKEN1, wk_st = PM_WKST1;
522 519
523 if (cpu_is_omap2430()) {
524 uart->wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, PM_WKEN1);
525 uart->wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, PM_WKST1);
526 } else if (cpu_is_omap2420()) {
527 uart->wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, PM_WKEN1);
528 uart->wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, PM_WKST1);
529 }
530 switch (uart->num) { 520 switch (uart->num) {
531 case 0: 521 case 0:
532 wk_mask = OMAP24XX_ST_UART1_MASK; 522 wk_mask = OMAP24XX_ST_UART1_MASK;
@@ -535,10 +525,19 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
535 wk_mask = OMAP24XX_ST_UART2_MASK; 525 wk_mask = OMAP24XX_ST_UART2_MASK;
536 break; 526 break;
537 case 2: 527 case 2:
528 wk_en = OMAP24XX_PM_WKEN2;
529 wk_st = OMAP24XX_PM_WKST2;
538 wk_mask = OMAP24XX_ST_UART3_MASK; 530 wk_mask = OMAP24XX_ST_UART3_MASK;
539 break; 531 break;
540 } 532 }
541 uart->wk_mask = wk_mask; 533 uart->wk_mask = wk_mask;
534 if (cpu_is_omap2430()) {
535 uart->wk_en = OMAP2430_PRM_REGADDR(CORE_MOD, wk_en);
536 uart->wk_st = OMAP2430_PRM_REGADDR(CORE_MOD, wk_st);
537 } else if (cpu_is_omap2420()) {
538 uart->wk_en = OMAP2420_PRM_REGADDR(CORE_MOD, wk_en);
539 uart->wk_st = OMAP2420_PRM_REGADDR(CORE_MOD, wk_st);
540 }
542 } else { 541 } else {
543 uart->wk_en = NULL; 542 uart->wk_en = NULL;
544 uart->wk_st = NULL; 543 uart->wk_st = NULL;
@@ -546,9 +545,9 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
546 uart->padconf = 0; 545 uart->padconf = 0;
547 } 546 }
548 547
549 p->irqflags |= IRQF_SHARED; 548 uart->irqflags |= IRQF_SHARED;
550 ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED, 549 ret = request_threaded_irq(uart->irq, NULL, omap_uart_interrupt,
551 "serial idle", (void *)uart); 550 IRQF_SHARED, "serial idle", (void *)uart);
552 WARN_ON(ret); 551 WARN_ON(ret);
553} 552}
554 553
@@ -558,11 +557,17 @@ void omap_uart_enable_irqs(int enable)
558 struct omap_uart_state *uart; 557 struct omap_uart_state *uart;
559 558
560 list_for_each_entry(uart, &uart_list, node) { 559 list_for_each_entry(uart, &uart_list, node) {
561 if (enable) 560 if (enable) {
562 ret = request_irq(uart->p->irq, omap_uart_interrupt, 561 pm_runtime_put_sync(&uart->pdev->dev);
563 IRQF_SHARED, "serial idle", (void *)uart); 562 ret = request_threaded_irq(uart->irq, NULL,
564 else 563 omap_uart_interrupt,
565 free_irq(uart->p->irq, (void *)uart); 564 IRQF_SHARED,
565 "serial idle",
566 (void *)uart);
567 } else {
568 pm_runtime_get_noresume(&uart->pdev->dev);
569 free_irq(uart->irq, (void *)uart);
570 }
566 } 571 }
567} 572}
568 573
@@ -570,10 +575,9 @@ static ssize_t sleep_timeout_show(struct device *dev,
570 struct device_attribute *attr, 575 struct device_attribute *attr,
571 char *buf) 576 char *buf)
572{ 577{
573 struct platform_device *pdev = container_of(dev, 578 struct platform_device *pdev = to_platform_device(dev);
574 struct platform_device, dev); 579 struct omap_device *odev = to_omap_device(pdev);
575 struct omap_uart_state *uart = container_of(pdev, 580 struct omap_uart_state *uart = odev->hwmods[0]->dev_attr;
576 struct omap_uart_state, pdev);
577 581
578 return sprintf(buf, "%u\n", uart->timeout / HZ); 582 return sprintf(buf, "%u\n", uart->timeout / HZ);
579} 583}
@@ -582,10 +586,9 @@ static ssize_t sleep_timeout_store(struct device *dev,
582 struct device_attribute *attr, 586 struct device_attribute *attr,
583 const char *buf, size_t n) 587 const char *buf, size_t n)
584{ 588{
585 struct platform_device *pdev = container_of(dev, 589 struct platform_device *pdev = to_platform_device(dev);
586 struct platform_device, dev); 590 struct omap_device *odev = to_omap_device(pdev);
587 struct omap_uart_state *uart = container_of(pdev, 591 struct omap_uart_state *uart = odev->hwmods[0]->dev_attr;
588 struct omap_uart_state, pdev);
589 unsigned int value; 592 unsigned int value;
590 593
591 if (sscanf(buf, "%u", &value) != 1) { 594 if (sscanf(buf, "%u", &value) != 1) {
@@ -608,48 +611,15 @@ static DEVICE_ATTR(sleep_timeout, 0644, sleep_timeout_show,
608#define DEV_CREATE_FILE(dev, attr) WARN_ON(device_create_file(dev, attr)) 611#define DEV_CREATE_FILE(dev, attr) WARN_ON(device_create_file(dev, attr))
609#else 612#else
610static inline void omap_uart_idle_init(struct omap_uart_state *uart) {} 613static inline void omap_uart_idle_init(struct omap_uart_state *uart) {}
614static void omap_uart_block_sleep(struct omap_uart_state *uart)
615{
616 /* Needed to enable UART clocks when built without CONFIG_PM */
617 omap_uart_enable_clocks(uart);
618}
611#define DEV_CREATE_FILE(dev, attr) 619#define DEV_CREATE_FILE(dev, attr)
612#endif /* CONFIG_PM */ 620#endif /* CONFIG_PM */
613 621
614static struct omap_uart_state omap_uart[] = { 622#ifndef CONFIG_SERIAL_OMAP
615 {
616 .pdev = {
617 .name = "serial8250",
618 .id = PLAT8250_DEV_PLATFORM,
619 .dev = {
620 .platform_data = serial_platform_data0,
621 },
622 },
623 }, {
624 .pdev = {
625 .name = "serial8250",
626 .id = PLAT8250_DEV_PLATFORM1,
627 .dev = {
628 .platform_data = serial_platform_data1,
629 },
630 },
631 }, {
632 .pdev = {
633 .name = "serial8250",
634 .id = PLAT8250_DEV_PLATFORM2,
635 .dev = {
636 .platform_data = serial_platform_data2,
637 },
638 },
639 },
640#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
641 {
642 .pdev = {
643 .name = "serial8250",
644 .id = 3,
645 .dev = {
646 .platform_data = serial_platform_data3,
647 },
648 },
649 },
650#endif
651};
652
653/* 623/*
654 * Override the default 8250 read handler: mem_serial_in() 624 * Override the default 8250 read handler: mem_serial_in()
655 * Empty RX fifo read causes an abort on omap3630 and omap4 625 * Empty RX fifo read causes an abort on omap3630 and omap4
@@ -682,71 +652,44 @@ static void serial_out_override(struct uart_port *up, int offset, int value)
682 } 652 }
683 __serial_write_reg(up, offset, value); 653 __serial_write_reg(up, offset, value);
684} 654}
655#endif
656
685void __init omap_serial_early_init(void) 657void __init omap_serial_early_init(void)
686{ 658{
687 int i, nr_ports; 659 int i = 0;
688 char name[16];
689 660
690 if (!(cpu_is_omap3630() || cpu_is_omap4430())) 661 do {
691 nr_ports = 3; 662 char oh_name[MAX_UART_HWMOD_NAME_LEN];
692 else 663 struct omap_hwmod *oh;
693 nr_ports = ARRAY_SIZE(omap_uart); 664 struct omap_uart_state *uart;
694 665
695 /* 666 snprintf(oh_name, MAX_UART_HWMOD_NAME_LEN,
696 * Make sure the serial ports are muxed on at this point. 667 "uart%d", i + 1);
697 * You have to mux them off in device drivers later on 668 oh = omap_hwmod_lookup(oh_name);
698 * if not needed. 669 if (!oh)
699 */ 670 break;
700 671
701 for (i = 0; i < nr_ports; i++) { 672 uart = kzalloc(sizeof(struct omap_uart_state), GFP_KERNEL);
702 struct omap_uart_state *uart = &omap_uart[i]; 673 if (WARN_ON(!uart))
703 struct platform_device *pdev = &uart->pdev; 674 return;
704 struct device *dev = &pdev->dev; 675
705 struct plat_serial8250_port *p = dev->platform_data; 676 uart->oh = oh;
677 uart->num = i++;
678 list_add_tail(&uart->node, &uart_list);
679 num_uarts++;
706 680
707 /* Don't map zero-based physical address */
708 if (p->mapbase == 0) {
709 dev_warn(dev, "no physical address for uart#%d,"
710 " so skipping early_init...\n", i);
711 continue;
712 }
713 /* 681 /*
714 * Module 4KB + L4 interconnect 4KB 682 * NOTE: omap_hwmod_init() has not yet been called,
715 * Static mapping, never released 683 * so no hwmod functions will work yet.
716 */ 684 */
717 p->membase = ioremap(p->mapbase, SZ_8K);
718 if (!p->membase) {
719 dev_err(dev, "ioremap failed for uart%i\n", i + 1);
720 continue;
721 }
722
723 sprintf(name, "uart%d_ick", i + 1);
724 uart->ick = clk_get(NULL, name);
725 if (IS_ERR(uart->ick)) {
726 dev_err(dev, "Could not get uart%d_ick\n", i + 1);
727 uart->ick = NULL;
728 }
729 685
730 sprintf(name, "uart%d_fck", i+1); 686 /*
731 uart->fck = clk_get(NULL, name); 687 * During UART early init, device need to be probed
732 if (IS_ERR(uart->fck)) { 688 * to determine SoC specific init before omap_device
733 dev_err(dev, "Could not get uart%d_fck\n", i + 1); 689 * is ready. Therefore, don't allow idle here
734 uart->fck = NULL; 690 */
735 } 691 uart->oh->flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
736 692 } while (1);
737 /* FIXME: Remove this once the clkdev is ready */
738 if (!cpu_is_omap44xx()) {
739 if (!uart->ick || !uart->fck)
740 continue;
741 }
742
743 uart->num = i;
744 p->private_data = uart;
745 uart->p = p;
746
747 if (cpu_is_omap44xx())
748 p->irq += 32;
749 }
750} 693}
751 694
752/** 695/**
@@ -763,53 +706,135 @@ void __init omap_serial_early_init(void)
763void __init omap_serial_init_port(int port) 706void __init omap_serial_init_port(int port)
764{ 707{
765 struct omap_uart_state *uart; 708 struct omap_uart_state *uart;
766 struct platform_device *pdev; 709 struct omap_hwmod *oh;
767 struct device *dev; 710 struct omap_device *od;
768 711 void *pdata = NULL;
769 BUG_ON(port < 0); 712 u32 pdata_size = 0;
770 BUG_ON(port >= ARRAY_SIZE(omap_uart)); 713 char *name;
771 714#ifndef CONFIG_SERIAL_OMAP
772 uart = &omap_uart[port]; 715 struct plat_serial8250_port ports[2] = {
773 pdev = &uart->pdev; 716 {},
774 dev = &pdev->dev; 717 {.flags = 0},
718 };
719 struct plat_serial8250_port *p = &ports[0];
720#else
721 struct omap_uart_port_info omap_up;
722#endif
775 723
776 /* Don't proceed if there's no clocks available */ 724 if (WARN_ON(port < 0))
777 if (unlikely(!uart->ick || !uart->fck)) { 725 return;
778 WARN(1, "%s: can't init uart%d, no clocks available\n", 726 if (WARN_ON(port >= num_uarts))
779 kobject_name(&dev->kobj), port);
780 return; 727 return;
781 }
782
783 omap_uart_enable_clocks(uart);
784
785 omap_uart_reset(uart);
786 omap_uart_idle_init(uart);
787 728
788 list_add_tail(&uart->node, &uart_list); 729 list_for_each_entry(uart, &uart_list, node)
730 if (port == uart->num)
731 break;
789 732
790 if (WARN_ON(platform_device_register(pdev))) 733 oh = uart->oh;
791 return; 734 uart->dma_enabled = 0;
735#ifndef CONFIG_SERIAL_OMAP
736 name = "serial8250";
792 737
793 if ((cpu_is_omap34xx() && uart->padconf) || 738 /*
794 (uart->wk_en && uart->wk_mask)) { 739 * !! 8250 driver does not use standard IORESOURCE* It
795 device_init_wakeup(dev, true); 740 * has it's own custom pdata that can be taken from
796 DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout); 741 * the hwmod resource data. But, this needs to be
797 } 742 * done after the build.
743 *
744 * ?? does it have to be done before the register ??
745 * YES, because platform_device_data_add() copies
746 * pdata, it does not use a pointer.
747 */
748 p->flags = UPF_BOOT_AUTOCONF;
749 p->iotype = UPIO_MEM;
750 p->regshift = 2;
751 p->uartclk = OMAP24XX_BASE_BAUD * 16;
752 p->irq = oh->mpu_irqs[0].irq;
753 p->mapbase = oh->slaves[0]->addr->pa_start;
754 p->membase = omap_hwmod_get_mpu_rt_va(oh);
755 p->irqflags = IRQF_SHARED;
756 p->private_data = uart;
798 757
799 /* 758 /*
800 * omap44xx: Never read empty UART fifo 759 * omap44xx: Never read empty UART fifo
801 * omap3xxx: Never read empty UART fifo on UARTs 760 * omap3xxx: Never read empty UART fifo on UARTs
802 * with IP rev >=0x52 761 * with IP rev >=0x52
803 */ 762 */
763 uart->regshift = p->regshift;
764 uart->membase = p->membase;
804 if (cpu_is_omap44xx()) 765 if (cpu_is_omap44xx())
805 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT; 766 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
806 else if ((serial_read_reg(uart->p, UART_OMAP_MVER) & 0xFF) 767 else if ((serial_read_reg(uart, UART_OMAP_MVER) & 0xFF)
807 >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV) 768 >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
808 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT; 769 uart->errata |= UART_ERRATA_FIFO_FULL_ABORT;
809 770
810 if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) { 771 if (uart->errata & UART_ERRATA_FIFO_FULL_ABORT) {
811 uart->p->serial_in = serial_in_override; 772 p->serial_in = serial_in_override;
812 uart->p->serial_out = serial_out_override; 773 p->serial_out = serial_out_override;
774 }
775
776 pdata = &ports[0];
777 pdata_size = 2 * sizeof(struct plat_serial8250_port);
778#else
779
780 name = DRIVER_NAME;
781
782 omap_up.dma_enabled = uart->dma_enabled;
783 omap_up.uartclk = OMAP24XX_BASE_BAUD * 16;
784 omap_up.mapbase = oh->slaves[0]->addr->pa_start;
785 omap_up.membase = omap_hwmod_get_mpu_rt_va(oh);
786 omap_up.irqflags = IRQF_SHARED;
787 omap_up.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
788
789 pdata = &omap_up;
790 pdata_size = sizeof(struct omap_uart_port_info);
791#endif
792
793 if (WARN_ON(!oh))
794 return;
795
796 od = omap_device_build(name, uart->num, oh, pdata, pdata_size,
797 omap_uart_latency,
798 ARRAY_SIZE(omap_uart_latency), false);
799 WARN(IS_ERR(od), "Could not build omap_device for %s: %s.\n",
800 name, oh->name);
801
802 uart->irq = oh->mpu_irqs[0].irq;
803 uart->regshift = 2;
804 uart->mapbase = oh->slaves[0]->addr->pa_start;
805 uart->membase = omap_hwmod_get_mpu_rt_va(oh);
806 uart->pdev = &od->pdev;
807
808 oh->dev_attr = uart;
809
810 /*
811 * Because of early UART probing, UART did not get idled
812 * on init. Now that omap_device is ready, ensure full idle
813 * before doing omap_device_enable().
814 */
815 omap_hwmod_idle(uart->oh);
816
817 omap_device_enable(uart->pdev);
818 omap_uart_idle_init(uart);
819 omap_uart_reset(uart);
820 omap_hwmod_enable_wakeup(uart->oh);
821 omap_device_idle(uart->pdev);
822
823 /*
824 * Need to block sleep long enough for interrupt driven
825 * driver to start. Console driver is in polling mode
826 * so device needs to be kept enabled while polling driver
827 * is in use.
828 */
829 if (uart->timeout)
830 uart->timeout = (30 * HZ);
831 omap_uart_block_sleep(uart);
832 uart->timeout = DEFAULT_TIMEOUT;
833
834 if ((cpu_is_omap34xx() && uart->padconf) ||
835 (uart->wk_en && uart->wk_mask)) {
836 device_init_wakeup(&od->pdev.dev, true);
837 DEV_CREATE_FILE(&od->pdev.dev, &dev_attr_sleep_timeout);
813 } 838 }
814 839
815 /* Enable the MDR1 errata for OMAP3 */ 840 /* Enable the MDR1 errata for OMAP3 */
@@ -826,13 +851,8 @@ void __init omap_serial_init_port(int port)
826 */ 851 */
827void __init omap_serial_init(void) 852void __init omap_serial_init(void)
828{ 853{
829 int i, nr_ports; 854 struct omap_uart_state *uart;
830
831 if (!(cpu_is_omap3630() || cpu_is_omap4430()))
832 nr_ports = 3;
833 else
834 nr_ports = ARRAY_SIZE(omap_uart);
835 855
836 for (i = 0; i < nr_ports; i++) 856 list_for_each_entry(uart, &uart_list, node)
837 omap_serial_init_port(i); 857 omap_serial_init_port(uart->num);
838} 858}
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index ba53191ae4c5..2fb205a7f285 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -27,11 +27,11 @@
27#include <linux/linkage.h> 27#include <linux/linkage.h>
28#include <asm/assembler.h> 28#include <asm/assembler.h>
29#include <mach/io.h> 29#include <mach/io.h>
30#include <plat/control.h>
31 30
32#include "cm.h" 31#include "cm.h"
33#include "prm.h" 32#include "prm.h"
34#include "sdrc.h" 33#include "sdrc.h"
34#include "control.h"
35 35
36#define SDRC_SCRATCHPAD_SEM_V 0xfa00291c 36#define SDRC_SCRATCHPAD_SEM_V 0xfa00291c
37 37
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S
index de99ba2a57ab..3637274af5be 100644
--- a/arch/arm/mach-omap2/sram34xx.S
+++ b/arch/arm/mach-omap2/sram34xx.S
@@ -129,8 +129,11 @@ ENTRY(omap3_sram_configure_core_dpll)
129 ldr r4, [sp, #80] 129 ldr r4, [sp, #80]
130 str r4, omap_sdrc_mr_1_val 130 str r4, omap_sdrc_mr_1_val
131skip_cs1_params: 131skip_cs1_params:
132 mrc p15, 0, r8, c1, c0, 0 @ read ctrl register
133 bic r10, r8, #0x800 @ clear Z-bit, disable branch prediction
134 mcr p15, 0, r10, c1, c0, 0 @ write ctrl register
132 dsb @ flush buffered writes to interconnect 135 dsb @ flush buffered writes to interconnect
133 136 isb @ prevent speculative exec past here
134 cmp r3, #1 @ if increasing SDRC clk rate, 137 cmp r3, #1 @ if increasing SDRC clk rate,
135 bleq configure_sdrc @ program the SDRC regs early (for RFR) 138 bleq configure_sdrc @ program the SDRC regs early (for RFR)
136 cmp r1, #SDRC_UNLOCK_DLL @ set the intended DLL state 139 cmp r1, #SDRC_UNLOCK_DLL @ set the intended DLL state
@@ -148,6 +151,7 @@ skip_cs1_params:
148 beq return_to_sdram @ return to SDRAM code, otherwise, 151 beq return_to_sdram @ return to SDRAM code, otherwise,
149 bl configure_sdrc @ reprogram SDRC regs now 152 bl configure_sdrc @ reprogram SDRC regs now
150return_to_sdram: 153return_to_sdram:
154 mcr p15, 0, r8, c1, c0, 0 @ restore ctrl register
151 isb @ prevent speculative exec past here 155 isb @ prevent speculative exec past here
152 mov r0, #0 @ return value 156 mov r0, #0 @ return value
153 ldmfd sp!, {r1-r12, pc} @ restore regs and return 157 ldmfd sp!, {r1-r12, pc} @ restore regs and return
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 74fbed8491f2..e13c29eecf2b 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -40,6 +40,8 @@
40#include <plat/dmtimer.h> 40#include <plat/dmtimer.h>
41#include <asm/localtimer.h> 41#include <asm/localtimer.h>
42 42
43#include "timer-gp.h"
44
43/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */ 45/* MAX_GPTIMER_ID: number of GPTIMERs on the chip */
44#define MAX_GPTIMER_ID 12 46#define MAX_GPTIMER_ID 12
45 47
@@ -228,8 +230,10 @@ static void __init omap2_gp_clocksource_init(void)
228static void __init omap2_gp_timer_init(void) 230static void __init omap2_gp_timer_init(void)
229{ 231{
230#ifdef CONFIG_LOCAL_TIMERS 232#ifdef CONFIG_LOCAL_TIMERS
231 twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256); 233 if (cpu_is_omap44xx()) {
232 BUG_ON(!twd_base); 234 twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256);
235 BUG_ON(!twd_base);
236 }
233#endif 237#endif
234 omap_dm_timer_init(); 238 omap_dm_timer_init();
235 239
diff --git a/arch/arm/plat-omap/include/plat/timer-gp.h b/arch/arm/mach-omap2/timer-gp.h
index c88d346b59d9..5c1072c6783b 100644
--- a/arch/arm/plat-omap/include/plat/timer-gp.h
+++ b/arch/arm/mach-omap2/timer-gp.h
@@ -11,7 +11,6 @@
11#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H 11#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
12#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H 12#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
13 13
14int __init omap2_gp_clockevent_set_gptimer(u8 id); 14extern int __init omap2_gp_clockevent_set_gptimer(u8 id);
15 15
16#endif 16#endif
17
diff --git a/arch/arm/mach-omap2/usb-fs.c b/arch/arm/mach-omap2/usb-fs.c
index a216d88b04b5..1481078763b8 100644
--- a/arch/arm/mach-omap2/usb-fs.c
+++ b/arch/arm/mach-omap2/usb-fs.c
@@ -29,18 +29,18 @@
29 29
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <plat/control.h>
33#include <plat/usb.h> 32#include <plat/usb.h>
34#include <plat/board.h> 33#include <plat/board.h>
35 34
35#include "control.h"
36#include "mux.h"
37
36#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN 38#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN
37#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO 39#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO
38#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO 40#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO
39#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN 41#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
40#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG 42#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
41 43
42#include "mux.h"
43
44#if defined(CONFIG_ARCH_OMAP2) 44#if defined(CONFIG_ARCH_OMAP2)
45 45
46#ifdef CONFIG_USB_GADGET_OMAP 46#ifdef CONFIG_USB_GADGET_OMAP
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/mpp.c b/arch/arm/mach-orion5x/mpp.c
index bc4c3b9aaf83..db485d3b8144 100644
--- a/arch/arm/mach-orion5x/mpp.c
+++ b/arch/arm/mach-orion5x/mpp.c
@@ -127,7 +127,7 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)
127 /* Initialize gpiolib. */ 127 /* Initialize gpiolib. */
128 orion_gpio_init(); 128 orion_gpio_init();
129 129
130 while (mode->mpp >= 0) { 130 for ( ; mode->mpp >= 0; mode++) {
131 u32 *reg; 131 u32 *reg;
132 int num_type; 132 int num_type;
133 int shift; 133 int shift;
@@ -160,8 +160,6 @@ void __init orion5x_mpp_conf(struct orion5x_mpp_mode *mode)
160 orion_gpio_set_unused(mode->mpp); 160 orion_gpio_set_unused(mode->mpp);
161 161
162 orion_gpio_set_valid(mode->mpp, !!(mode->type == MPP_GPIO)); 162 orion_gpio_set_valid(mode->mpp, !!(mode->type == MPP_GPIO));
163
164 mode++;
165 } 163 }
166 164
167 writel(mpp_0_7_ctrl, MPP_0_7_CTRL); 165 writel(mpp_0_7_ctrl, MPP_0_7_CTRL);
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c
index 16f1bd5324be..c1c1cd04bdde 100644
--- a/arch/arm/mach-orion5x/ts78xx-setup.c
+++ b/arch/arm/mach-orion5x/ts78xx-setup.c
@@ -239,7 +239,7 @@ static struct platform_nand_data ts78xx_ts_nand_data = {
239static struct resource ts78xx_ts_nand_resources = { 239static struct resource ts78xx_ts_nand_resources = {
240 .start = TS_NAND_DATA, 240 .start = TS_NAND_DATA,
241 .end = TS_NAND_DATA + 4, 241 .end = TS_NAND_DATA + 4,
242 .flags = IORESOURCE_IO, 242 .flags = IORESOURCE_MEM,
243}; 243};
244 244
245static struct platform_device ts78xx_ts_nand_device = { 245static struct platform_device ts78xx_ts_nand_device = {
diff --git a/arch/arm/mach-pxa/cm-x2xx.c b/arch/arm/mach-pxa/cm-x2xx.c
index ac5598ce9724..d34b99febeb9 100644
--- a/arch/arm/mach-pxa/cm-x2xx.c
+++ b/arch/arm/mach-pxa/cm-x2xx.c
@@ -476,8 +476,6 @@ static void __init cmx2xx_init(void)
476 476
477static void __init cmx2xx_init_irq(void) 477static void __init cmx2xx_init_irq(void)
478{ 478{
479 pxa27x_init_irq();
480
481 if (cpu_is_pxa25x()) { 479 if (cpu_is_pxa25x()) {
482 pxa25x_init_irq(); 480 pxa25x_init_irq();
483 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ); 481 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 08b410343870..aaa1166df964 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -382,6 +382,31 @@ struct platform_device pxa_device_i2s = {
382 .num_resources = ARRAY_SIZE(pxai2s_resources), 382 .num_resources = ARRAY_SIZE(pxai2s_resources),
383}; 383};
384 384
385struct platform_device pxa_device_asoc_ssp1 = {
386 .name = "pxa-ssp-dai",
387 .id = 0,
388};
389
390struct platform_device pxa_device_asoc_ssp2= {
391 .name = "pxa-ssp-dai",
392 .id = 1,
393};
394
395struct platform_device pxa_device_asoc_ssp3 = {
396 .name = "pxa-ssp-dai",
397 .id = 2,
398};
399
400struct platform_device pxa_device_asoc_ssp4 = {
401 .name = "pxa-ssp-dai",
402 .id = 3,
403};
404
405struct platform_device pxa_device_asoc_platform = {
406 .name = "pxa-pcm-audio",
407 .id = -1,
408};
409
385static u64 pxaficp_dmamask = ~(u32)0; 410static u64 pxaficp_dmamask = ~(u32)0;
386 411
387struct platform_device pxa_device_ficp = { 412struct platform_device pxa_device_ficp = {
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 715e8bd02e24..2fd5a8b35757 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -39,4 +39,10 @@ extern struct platform_device pxa3xx_device_i2c_power;
39 39
40extern struct platform_device pxa3xx_device_gcu; 40extern struct platform_device pxa3xx_device_gcu;
41 41
42extern struct platform_device pxa_device_asoc_platform;
43extern struct platform_device pxa_device_asoc_ssp1;
44extern struct platform_device pxa_device_asoc_ssp2;
45extern struct platform_device pxa_device_asoc_ssp3;
46extern struct platform_device pxa_device_asoc_ssp4;
47
42void __init pxa_register_device(struct platform_device *dev, void *data); 48void __init pxa_register_device(struct platform_device *dev, void *data);
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index ab48bb81b570..ed0dbfdb22ed 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -1015,7 +1015,6 @@ static struct soc_camera_link iclink = {
1015 .power = em_x270_sensor_power, 1015 .power = em_x270_sensor_power,
1016 .board_info = &em_x270_i2c_cam_info[0], 1016 .board_info = &em_x270_i2c_cam_info[0],
1017 .i2c_adapter_id = 0, 1017 .i2c_adapter_id = 0,
1018 .module_name = "mt9m111",
1019}; 1018};
1020 1019
1021static struct platform_device em_x270_camera = { 1020static struct platform_device em_x270_camera = {
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 80a9352d43f3..142c711f4cda 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -755,7 +755,6 @@ static struct soc_camera_link a780_iclink = {
755 .flags = SOCAM_SENSOR_INVERT_PCLK, 755 .flags = SOCAM_SENSOR_INVERT_PCLK,
756 .i2c_adapter_id = 0, 756 .i2c_adapter_id = 0,
757 .board_info = &a780_camera_i2c_board_info, 757 .board_info = &a780_camera_i2c_board_info,
758 .module_name = "mt9m111",
759 .power = a780_camera_power, 758 .power = a780_camera_power,
760 .reset = a780_camera_reset, 759 .reset = a780_camera_reset,
761}; 760};
@@ -1024,7 +1023,6 @@ static struct soc_camera_link a910_iclink = {
1024 .bus_id = 0, 1023 .bus_id = 0,
1025 .i2c_adapter_id = 0, 1024 .i2c_adapter_id = 0,
1026 .board_info = &a910_camera_i2c_board_info, 1025 .board_info = &a910_camera_i2c_board_info,
1027 .module_name = "mt9m111",
1028 .power = a910_camera_power, 1026 .power = a910_camera_power,
1029 .reset = a910_camera_reset, 1027 .reset = a910_camera_reset,
1030}; 1028};
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 0c31fabfc7fd..f5fb915e1315 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -711,7 +711,6 @@ static struct soc_camera_link iclink = {
711 .bus_id = 0, /* Match id in pxa27x_device_camera in device.c */ 711 .bus_id = 0, /* Match id in pxa27x_device_camera in device.c */
712 .board_info = &mioa701_i2c_devices[0], 712 .board_info = &mioa701_i2c_devices[0],
713 .i2c_adapter_id = 0, 713 .i2c_adapter_id = 0,
714 .module_name = "mt9m111",
715}; 714};
716 715
717struct i2c_pxa_platform_data i2c_pdata = { 716struct i2c_pxa_platform_data i2c_pdata = {
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index f56ae1008759..f33647a8e0b7 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -453,7 +453,6 @@ static struct soc_camera_link iclink[] = {
453 .query_bus_param = pcm990_camera_query_bus_param, 453 .query_bus_param = pcm990_camera_query_bus_param,
454 .set_bus_param = pcm990_camera_set_bus_param, 454 .set_bus_param = pcm990_camera_set_bus_param,
455 .free_bus = pcm990_camera_free_bus, 455 .free_bus = pcm990_camera_free_bus,
456 .module_name = "mt9v022",
457 }, { 456 }, {
458 .bus_id = 0, /* Must match with the camera ID */ 457 .bus_id = 0, /* Must match with the camera ID */
459 .board_info = &pcm990_camera_i2c[1], 458 .board_info = &pcm990_camera_i2c[1],
@@ -461,7 +460,6 @@ static struct soc_camera_link iclink[] = {
461 .query_bus_param = pcm990_camera_query_bus_param, 460 .query_bus_param = pcm990_camera_query_bus_param,
462 .set_bus_param = pcm990_camera_set_bus_param, 461 .set_bus_param = pcm990_camera_set_bus_param,
463 .free_bus = pcm990_camera_free_bus, 462 .free_bus = pcm990_camera_free_bus,
464 .module_name = "mt9m001",
465 }, 463 },
466}; 464};
467 465
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 12e5b9f01e6f..d1fbf29d561c 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -385,6 +385,10 @@ static struct platform_device *devices[] __initdata = {
385 &pxa27x_device_udc, 385 &pxa27x_device_udc,
386 &pxa_device_pmu, 386 &pxa_device_pmu,
387 &pxa_device_i2s, 387 &pxa_device_i2s,
388 &pxa_device_asoc_ssp1,
389 &pxa_device_asoc_ssp2,
390 &pxa_device_asoc_ssp3,
391 &pxa_device_asoc_platform,
388 &sa1100_device_rtc, 392 &sa1100_device_rtc,
389 &pxa_device_rtc, 393 &pxa_device_rtc,
390 &pxa27x_device_ssp1, 394 &pxa27x_device_ssp1,
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index c85c3a7abd31..d1c747cdacf8 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -593,6 +593,11 @@ static struct platform_device *devices[] __initdata = {
593 &pxa27x_device_udc, 593 &pxa27x_device_udc,
594 &pxa_device_pmu, 594 &pxa_device_pmu,
595 &pxa_device_i2s, 595 &pxa_device_i2s,
596 &pxa_device_asoc_ssp1,
597 &pxa_device_asoc_ssp2,
598 &pxa_device_asoc_ssp3,
599 &pxa_device_asoc_ssp4,
600 &pxa_device_asoc_platform,
596 &sa1100_device_rtc, 601 &sa1100_device_rtc,
597 &pxa_device_rtc, 602 &pxa_device_rtc,
598 &pxa27x_device_ssp1, 603 &pxa27x_device_ssp1,
diff --git a/arch/arm/mach-pxa/saar.c b/arch/arm/mach-pxa/saar.c
index 4b521e045d75..ffa50e633ee6 100644
--- a/arch/arm/mach-pxa/saar.c
+++ b/arch/arm/mach-pxa/saar.c
@@ -116,7 +116,7 @@ static struct platform_device smc91x_device = {
116 }, 116 },
117}; 117};
118 118
119#if defined(CONFIG_FB_PXA) || (CONFIG_FB_PXA_MODULE) 119#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
120static uint16_t lcd_power_on[] = { 120static uint16_t lcd_power_on[] = {
121 /* single frame */ 121 /* single frame */
122 SMART_CMD_NOOP, 122 SMART_CMD_NOOP,
diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index f25fb6245bd7..702f7a68e87d 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -45,6 +45,16 @@ int wm9713_irq;
45int lcd_id; 45int lcd_id;
46int lcd_orientation; 46int lcd_orientation;
47 47
48struct platform_device pxa_device_wm9713_audio = {
49 .name = "wm9713-codec",
50 .id = -1,
51};
52
53static void __init zylonite_init_wm9713_audio(void)
54{
55 platform_device_register(&pxa_device_wm9713_audio);
56}
57
48static struct resource smc91x_resources[] = { 58static struct resource smc91x_resources[] = {
49 [0] = { 59 [0] = {
50 .start = ZYLONITE_ETH_PHYS + 0x300, 60 .start = ZYLONITE_ETH_PHYS + 0x300,
@@ -408,6 +418,7 @@ static void __init zylonite_init(void)
408 zylonite_init_nand(); 418 zylonite_init_nand();
409 zylonite_init_leds(); 419 zylonite_init_leds();
410 zylonite_init_ohci(); 420 zylonite_init_ohci();
421 zylonite_init_wm9713_audio();
411} 422}
412 423
413MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)") 424MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index 8cdeb14af592..8aa2f1902a94 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -30,7 +30,7 @@ static void h1940bt_enable(int on)
30{ 30{
31 if (on) { 31 if (on) {
32 /* Power on the chip */ 32 /* Power on the chip */
33 h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER); 33 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1);
34 /* Reset the chip */ 34 /* Reset the chip */
35 mdelay(10); 35 mdelay(10);
36 36
@@ -43,7 +43,7 @@ static void h1940bt_enable(int on)
43 mdelay(10); 43 mdelay(10);
44 gpio_set_value(S3C2410_GPH(1), 0); 44 gpio_set_value(S3C2410_GPH(1), 0);
45 mdelay(10); 45 mdelay(10);
46 h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0); 46 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
47 } 47 }
48} 48}
49 49
@@ -64,7 +64,14 @@ static int __devinit h1940bt_probe(struct platform_device *pdev)
64 64
65 ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev)); 65 ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev));
66 if (ret) { 66 if (ret) {
67 dev_err(&pdev->dev, "could not get GPH1\n");\ 67 dev_err(&pdev->dev, "could not get GPH1\n");
68 return ret;
69 }
70
71 ret = gpio_request(H1940_LATCH_BLUETOOTH_POWER, dev_name(&pdev->dev));
72 if (ret) {
73 gpio_free(S3C2410_GPH(1));
74 dev_err(&pdev->dev, "could not get BT_POWER\n");
68 return ret; 75 return ret;
69 } 76 }
70 77
diff --git a/arch/arm/mach-s3c2410/include/mach/gpio.h b/arch/arm/mach-s3c2410/include/mach/gpio.h
index b649bf2ccd5c..f7f6b07df30e 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio.h
+++ b/arch/arm/mach-s3c2410/include/mach/gpio.h
@@ -22,6 +22,8 @@
22 22
23#ifdef CONFIG_CPU_S3C244X 23#ifdef CONFIG_CPU_S3C244X
24#define ARCH_NR_GPIOS (32 * 9 + CONFIG_S3C24XX_GPIO_EXTRA) 24#define ARCH_NR_GPIOS (32 * 9 + CONFIG_S3C24XX_GPIO_EXTRA)
25#elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
26#define ARCH_NR_GPIOS (32 * 12 + CONFIG_S3C24XX_GPIO_EXTRA)
25#else 27#else
26#define ARCH_NR_GPIOS (256 + CONFIG_S3C24XX_GPIO_EXTRA) 28#define ARCH_NR_GPIOS (256 + CONFIG_S3C24XX_GPIO_EXTRA)
27#endif 29#endif
@@ -30,8 +32,10 @@
30#include <mach/gpio-nrs.h> 32#include <mach/gpio-nrs.h>
31#include <mach/gpio-fns.h> 33#include <mach/gpio-fns.h>
32 34
33#ifdef CONFIG_CPU_S3C24XX 35#ifdef CONFIG_CPU_S3C244X
34#define S3C_GPIO_END (S3C2410_GPIO_BANKJ + 32) 36#define S3C_GPIO_END (S3C2410_GPJ(0) + 32)
37#elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
38#define S3C_GPIO_END (S3C2410_GPM(0) + 32)
35#else 39#else
36#define S3C_GPIO_END (S3C2410_GPIO_BANKH + 32) 40#define S3C_GPIO_END (S3C2410_GPH(0) + 32)
37#endif 41#endif
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h b/arch/arm/mach-s3c2410/include/mach/h1940-latch.h
index d8a832729a8a..97e42bfce81e 100644
--- a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h
+++ b/arch/arm/mach-s3c2410/include/mach/h1940-latch.h
@@ -14,51 +14,30 @@
14#ifndef __ASM_ARCH_H1940_LATCH_H 14#ifndef __ASM_ARCH_H1940_LATCH_H
15#define __ASM_ARCH_H1940_LATCH_H 15#define __ASM_ARCH_H1940_LATCH_H
16 16
17#include <mach/gpio.h>
17 18
18#ifndef __ASSEMBLY__ 19#define H1940_LATCH_GPIO(x) (S3C_GPIO_END + (x))
19#define H1940_LATCH ((void __force __iomem *)0xF8000000)
20#else
21#define H1940_LATCH 0xF8000000
22#endif
23
24#define H1940_PA_LATCH (S3C2410_CS2)
25 20
26/* SD layer latch */ 21/* SD layer latch */
27 22
28#define H1940_LATCH_SDQ1 (1<<16) 23#define H1940_LATCH_LCD_P0 H1940_LATCH_GPIO(0)
29#define H1940_LATCH_LCD_P1 (1<<17) 24#define H1940_LATCH_LCD_P1 H1940_LATCH_GPIO(1)
30#define H1940_LATCH_LCD_P2 (1<<18) 25#define H1940_LATCH_LCD_P2 H1940_LATCH_GPIO(2)
31#define H1940_LATCH_LCD_P3 (1<<19) 26#define H1940_LATCH_LCD_P3 H1940_LATCH_GPIO(3)
32#define H1940_LATCH_MAX1698_nSHUTDOWN (1<<20) /* LCD backlight */ 27#define H1940_LATCH_MAX1698_nSHUTDOWN H1940_LATCH_GPIO(4)
33#define H1940_LATCH_LED_RED (1<<21) 28#define H1940_LATCH_LED_RED H1940_LATCH_GPIO(5)
34#define H1940_LATCH_SDQ7 (1<<22) 29#define H1940_LATCH_SDQ7 H1940_LATCH_GPIO(6)
35#define H1940_LATCH_USB_DP (1<<23) 30#define H1940_LATCH_USB_DP H1940_LATCH_GPIO(7)
36 31
37/* CPU layer latch */ 32/* CPU layer latch */
38 33
39#define H1940_LATCH_UDA_POWER (1<<24) 34#define H1940_LATCH_UDA_POWER H1940_LATCH_GPIO(8)
40#define H1940_LATCH_AUDIO_POWER (1<<25) 35#define H1940_LATCH_AUDIO_POWER H1940_LATCH_GPIO(9)
41#define H1940_LATCH_SM803_ENABLE (1<<26) 36#define H1940_LATCH_SM803_ENABLE H1940_LATCH_GPIO(10)
42#define H1940_LATCH_LCD_P4 (1<<27) 37#define H1940_LATCH_LCD_P4 H1940_LATCH_GPIO(11)
43#define H1940_LATCH_CPUQ5 (1<<28) /* untraced */ 38#define H1940_LATCH_SD_POWER H1940_LATCH_GPIO(12)
44#define H1940_LATCH_BLUETOOTH_POWER (1<<29) /* active high */ 39#define H1940_LATCH_BLUETOOTH_POWER H1940_LATCH_GPIO(13)
45#define H1940_LATCH_LED_GREEN (1<<30) 40#define H1940_LATCH_LED_GREEN H1940_LATCH_GPIO(14)
46#define H1940_LATCH_LED_FLASH (1<<31) 41#define H1940_LATCH_LED_FLASH H1940_LATCH_GPIO(15)
47
48/* default settings */
49
50#define H1940_LATCH_DEFAULT \
51 H1940_LATCH_LCD_P4 | \
52 H1940_LATCH_SM803_ENABLE | \
53 H1940_LATCH_SDQ1 | \
54 H1940_LATCH_LCD_P1 | \
55 H1940_LATCH_LCD_P2 | \
56 H1940_LATCH_LCD_P3 | \
57 H1940_LATCH_MAX1698_nSHUTDOWN | \
58 H1940_LATCH_CPUQ5
59
60/* control functions */
61
62extern void h1940_latch_control(unsigned int clear, unsigned int set);
63 42
64#endif /* __ASM_ARCH_H1940_LATCH_H */ 43#endif /* __ASM_ARCH_H1940_LATCH_H */
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h b/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h
index 08ab9dfb6ae6..101aeea22310 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h
+++ b/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h
@@ -118,6 +118,8 @@
118#define S3C2443_SCLKCON_UARTCLK (1<<8) 118#define S3C2443_SCLKCON_UARTCLK (1<<8)
119#define S3C2443_SCLKCON_USBHOST (1<<1) 119#define S3C2443_SCLKCON_USBHOST (1<<1)
120 120
121#define S3C2443_PWRCFG_SLEEP (1<<15)
122
121#include <asm/div64.h> 123#include <asm/div64.h>
122 124
123static inline unsigned int 125static inline unsigned int
diff --git a/arch/arm/mach-s3c2410/include/mach/vmalloc.h b/arch/arm/mach-s3c2410/include/mach/vmalloc.h
index 54297eb0bf5e..7a311e8dddba 100644
--- a/arch/arm/mach-s3c2410/include/mach/vmalloc.h
+++ b/arch/arm/mach-s3c2410/include/mach/vmalloc.h
@@ -15,6 +15,6 @@
15#ifndef __ASM_ARCH_VMALLOC_H 15#ifndef __ASM_ARCH_VMALLOC_H
16#define __ASM_ARCH_VMALLOC_H 16#define __ASM_ARCH_VMALLOC_H
17 17
18#define VMALLOC_END 0xE0000000UL 18#define VMALLOC_END 0xF6000000UL
19 19
20#endif /* __ASM_ARCH_VMALLOC_H */ 20#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 98c5c9e81ee9..d7ada8c7e41f 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -24,6 +24,7 @@
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/pwm_backlight.h> 26#include <linux/pwm_backlight.h>
27#include <linux/i2c.h>
27#include <video/platform_lcd.h> 28#include <video/platform_lcd.h>
28 29
29#include <linux/mmc/host.h> 30#include <linux/mmc/host.h>
@@ -59,6 +60,14 @@
59#include <plat/mci.h> 60#include <plat/mci.h>
60#include <plat/ts.h> 61#include <plat/ts.h>
61 62
63#include <sound/uda1380.h>
64
65#define H1940_LATCH ((void __force __iomem *)0xF8000000)
66
67#define H1940_PA_LATCH S3C2410_CS2
68
69#define H1940_LATCH_BIT(x) (1 << ((x) + 16 - S3C_GPIO_END))
70
62static struct map_desc h1940_iodesc[] __initdata = { 71static struct map_desc h1940_iodesc[] __initdata = {
63 [0] = { 72 [0] = {
64 .virtual = (unsigned long)H1940_LATCH, 73 .virtual = (unsigned long)H1940_LATCH,
@@ -100,9 +109,9 @@ static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {
100 109
101/* Board control latch control */ 110/* Board control latch control */
102 111
103static unsigned int latch_state = H1940_LATCH_DEFAULT; 112static unsigned int latch_state;
104 113
105void h1940_latch_control(unsigned int clear, unsigned int set) 114static void h1940_latch_control(unsigned int clear, unsigned int set)
106{ 115{
107 unsigned long flags; 116 unsigned long flags;
108 117
@@ -116,7 +125,42 @@ void h1940_latch_control(unsigned int clear, unsigned int set)
116 local_irq_restore(flags); 125 local_irq_restore(flags);
117} 126}
118 127
119EXPORT_SYMBOL_GPL(h1940_latch_control); 128static inline int h1940_gpiolib_to_latch(int offset)
129{
130 return 1 << (offset + 16);
131}
132
133static void h1940_gpiolib_latch_set(struct gpio_chip *chip,
134 unsigned offset, int value)
135{
136 int latch_bit = h1940_gpiolib_to_latch(offset);
137
138 h1940_latch_control(value ? 0 : latch_bit,
139 value ? latch_bit : 0);
140}
141
142static int h1940_gpiolib_latch_output(struct gpio_chip *chip,
143 unsigned offset, int value)
144{
145 h1940_gpiolib_latch_set(chip, offset, value);
146 return 0;
147}
148
149static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
150 unsigned offset)
151{
152 return (latch_state >> (offset + 16)) & 1;
153}
154
155struct gpio_chip h1940_latch_gpiochip = {
156 .base = H1940_LATCH_GPIO(0),
157 .owner = THIS_MODULE,
158 .label = "H1940_LATCH",
159 .ngpio = 16,
160 .direction_output = h1940_gpiolib_latch_output,
161 .set = h1940_gpiolib_latch_set,
162 .get = h1940_gpiolib_latch_get,
163};
120 164
121static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd) 165static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
122{ 166{
@@ -125,10 +169,10 @@ static void h1940_udc_pullup(enum s3c2410_udc_cmd_e cmd)
125 switch (cmd) 169 switch (cmd)
126 { 170 {
127 case S3C2410_UDC_P_ENABLE : 171 case S3C2410_UDC_P_ENABLE :
128 h1940_latch_control(0, H1940_LATCH_USB_DP); 172 gpio_set_value(H1940_LATCH_USB_DP, 1);
129 break; 173 break;
130 case S3C2410_UDC_P_DISABLE : 174 case S3C2410_UDC_P_DISABLE :
131 h1940_latch_control(H1940_LATCH_USB_DP, 0); 175 gpio_set_value(H1940_LATCH_USB_DP, 0);
132 break; 176 break;
133 case S3C2410_UDC_P_RESET : 177 case S3C2410_UDC_P_RESET :
134 break; 178 break;
@@ -199,10 +243,25 @@ static struct platform_device h1940_device_bluetooth = {
199 .id = -1, 243 .id = -1,
200}; 244};
201 245
246static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
247{
248 switch (power_mode) {
249 case MMC_POWER_OFF:
250 gpio_set_value(H1940_LATCH_SD_POWER, 0);
251 break;
252 case MMC_POWER_UP:
253 case MMC_POWER_ON:
254 gpio_set_value(H1940_LATCH_SD_POWER, 1);
255 break;
256 default:
257 break;
258 };
259}
260
202static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = { 261static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = {
203 .gpio_detect = S3C2410_GPF(5), 262 .gpio_detect = S3C2410_GPF(5),
204 .gpio_wprotect = S3C2410_GPH(8), 263 .gpio_wprotect = S3C2410_GPH(8),
205 .set_power = NULL, 264 .set_power = h1940_set_mmc_power,
206 .ocr_avail = MMC_VDD_32_33, 265 .ocr_avail = MMC_VDD_32_33,
207}; 266};
208 267
@@ -213,15 +272,32 @@ static int h1940_backlight_init(struct device *dev)
213 gpio_direction_output(S3C2410_GPB(0), 0); 272 gpio_direction_output(S3C2410_GPB(0), 0);
214 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE); 273 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
215 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0); 274 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
275 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
216 276
217 return 0; 277 return 0;
218} 278}
219 279
280static int h1940_backlight_notify(struct device *dev, int brightness)
281{
282 if (!brightness) {
283 gpio_direction_output(S3C2410_GPB(0), 1);
284 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
285 } else {
286 gpio_direction_output(S3C2410_GPB(0), 0);
287 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
288 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
289 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
290 }
291 return brightness;
292}
293
220static void h1940_backlight_exit(struct device *dev) 294static void h1940_backlight_exit(struct device *dev)
221{ 295{
222 gpio_direction_output(S3C2410_GPB(0), 1); 296 gpio_direction_output(S3C2410_GPB(0), 1);
297 gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
223} 298}
224 299
300
225static struct platform_pwm_backlight_data backlight_data = { 301static struct platform_pwm_backlight_data backlight_data = {
226 .pwm_id = 0, 302 .pwm_id = 0,
227 .max_brightness = 100, 303 .max_brightness = 100,
@@ -229,6 +305,7 @@ static struct platform_pwm_backlight_data backlight_data = {
229 /* tcnt = 0x31 */ 305 /* tcnt = 0x31 */
230 .pwm_period_ns = 36296, 306 .pwm_period_ns = 36296,
231 .init = h1940_backlight_init, 307 .init = h1940_backlight_init,
308 .notify = h1940_backlight_notify,
232 .exit = h1940_backlight_exit, 309 .exit = h1940_backlight_exit,
233}; 310};
234 311
@@ -247,19 +324,37 @@ static void h1940_lcd_power_set(struct plat_lcd_data *pd,
247 int value; 324 int value;
248 325
249 if (!power) { 326 if (!power) {
250 /* set to 3ec */ 327 gpio_set_value(S3C2410_GPC(0), 0);
251 gpio_direction_output(S3C2410_GPC(0), 0);
252 /* wait for 3ac */ 328 /* wait for 3ac */
253 do { 329 do {
254 value = gpio_get_value(S3C2410_GPC(6)); 330 value = gpio_get_value(S3C2410_GPC(6));
255 } while (value); 331 } while (value);
256 /* set to 38c */ 332
257 gpio_direction_output(S3C2410_GPC(5), 0); 333 gpio_set_value(H1940_LATCH_LCD_P2, 0);
334 gpio_set_value(H1940_LATCH_LCD_P3, 0);
335 gpio_set_value(H1940_LATCH_LCD_P4, 0);
336
337 gpio_direction_output(S3C2410_GPC(1), 0);
338 gpio_direction_output(S3C2410_GPC(4), 0);
339
340 gpio_set_value(H1940_LATCH_LCD_P1, 0);
341 gpio_set_value(H1940_LATCH_LCD_P0, 0);
342
343 gpio_set_value(S3C2410_GPC(5), 0);
344
258 } else { 345 } else {
259 /* Set to 3ac */ 346 gpio_set_value(H1940_LATCH_LCD_P0, 1);
260 gpio_direction_output(S3C2410_GPC(5), 1); 347 gpio_set_value(H1940_LATCH_LCD_P1, 1);
261 /* Set to 3ad */ 348
262 gpio_direction_output(S3C2410_GPC(0), 1); 349 s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
350 s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));
351
352 gpio_set_value(S3C2410_GPC(5), 1);
353 gpio_set_value(S3C2410_GPC(0), 1);
354
355 gpio_set_value(H1940_LATCH_LCD_P3, 1);
356 gpio_set_value(H1940_LATCH_LCD_P2, 1);
357 gpio_set_value(H1940_LATCH_LCD_P4, 1);
263 } 358 }
264} 359}
265 360
@@ -273,12 +368,26 @@ static struct platform_device h1940_lcd_powerdev = {
273 .dev.platform_data = &h1940_lcd_power_data, 368 .dev.platform_data = &h1940_lcd_power_data,
274}; 369};
275 370
371static struct uda1380_platform_data uda1380_info = {
372 .gpio_power = H1940_LATCH_UDA_POWER,
373 .gpio_reset = S3C2410_GPA(12),
374 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
375};
376
377static struct i2c_board_info h1940_i2c_devices[] = {
378 {
379 I2C_BOARD_INFO("uda1380", 0x1a),
380 .platform_data = &uda1380_info,
381 },
382};
383
276static struct platform_device *h1940_devices[] __initdata = { 384static struct platform_device *h1940_devices[] __initdata = {
277 &s3c_device_ohci, 385 &s3c_device_ohci,
278 &s3c_device_lcd, 386 &s3c_device_lcd,
279 &s3c_device_wdt, 387 &s3c_device_wdt,
280 &s3c_device_i2c0, 388 &s3c_device_i2c0,
281 &s3c_device_iis, 389 &s3c_device_iis,
390 &s3c_device_pcm,
282 &s3c_device_usbgadget, 391 &s3c_device_usbgadget,
283 &h1940_device_leds, 392 &h1940_device_leds,
284 &h1940_device_bluetooth, 393 &h1940_device_bluetooth,
@@ -303,6 +412,10 @@ static void __init h1940_map_io(void)
303 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024); 412 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 1024);
304#endif 413#endif
305 s3c_pm_init(); 414 s3c_pm_init();
415
416 /* Add latch gpio chip, set latch initial value */
417 h1940_latch_control(0, 0);
418 WARN_ON(gpiochip_add(&h1940_latch_gpiochip));
306} 419}
307 420
308/* H1940 and RX3715 need to reserve this for suspend */ 421/* H1940 and RX3715 need to reserve this for suspend */
@@ -340,12 +453,38 @@ static void __init h1940_init(void)
340 writel(tmp, S3C2410_UPLLCON); 453 writel(tmp, S3C2410_UPLLCON);
341 454
342 gpio_request(S3C2410_GPC(0), "LCD power"); 455 gpio_request(S3C2410_GPC(0), "LCD power");
456 gpio_request(S3C2410_GPC(1), "LCD power");
457 gpio_request(S3C2410_GPC(4), "LCD power");
343 gpio_request(S3C2410_GPC(5), "LCD power"); 458 gpio_request(S3C2410_GPC(5), "LCD power");
344 gpio_request(S3C2410_GPC(6), "LCD power"); 459 gpio_request(S3C2410_GPC(6), "LCD power");
345 460 gpio_request(H1940_LATCH_LCD_P0, "LCD power");
461 gpio_request(H1940_LATCH_LCD_P1, "LCD power");
462 gpio_request(H1940_LATCH_LCD_P2, "LCD power");
463 gpio_request(H1940_LATCH_LCD_P3, "LCD power");
464 gpio_request(H1940_LATCH_LCD_P4, "LCD power");
465 gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
466 gpio_direction_output(S3C2410_GPC(0), 0);
467 gpio_direction_output(S3C2410_GPC(1), 0);
468 gpio_direction_output(S3C2410_GPC(4), 0);
469 gpio_direction_output(S3C2410_GPC(5), 0);
346 gpio_direction_input(S3C2410_GPC(6)); 470 gpio_direction_input(S3C2410_GPC(6));
471 gpio_direction_output(H1940_LATCH_LCD_P0, 0);
472 gpio_direction_output(H1940_LATCH_LCD_P1, 0);
473 gpio_direction_output(H1940_LATCH_LCD_P2, 0);
474 gpio_direction_output(H1940_LATCH_LCD_P3, 0);
475 gpio_direction_output(H1940_LATCH_LCD_P4, 0);
476 gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
477
478 gpio_request(H1940_LATCH_USB_DP, "USB pullup");
479 gpio_direction_output(H1940_LATCH_USB_DP, 0);
480
481 gpio_request(H1940_LATCH_SD_POWER, "SD power");
482 gpio_direction_output(H1940_LATCH_SD_POWER, 0);
347 483
348 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); 484 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
485
486 i2c_register_board_info(0, h1940_i2c_devices,
487 ARRAY_SIZE(h1940_i2c_devices));
349} 488}
350 489
351MACHINE_START(H1940, "IPAQ-H1940") 490MACHINE_START(H1940, "IPAQ-H1940")
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index bef39f77729d..4c6df51ddf33 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -51,6 +51,7 @@
51#include <plat/clock.h> 51#include <plat/clock.h>
52#include <plat/pm.h> 52#include <plat/pm.h>
53#include <plat/pll.h> 53#include <plat/pll.h>
54#include <plat/nand-core.h>
54 55
55#ifndef CONFIG_CPU_S3C2412_ONLY 56#ifndef CONFIG_CPU_S3C2412_ONLY
56void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; 57void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO;
@@ -92,7 +93,7 @@ void __init s3c2412_init_uarts(struct s3c2410_uartcfg *cfg, int no)
92 /* rename devices that are s3c2412/s3c2413 specific */ 93 /* rename devices that are s3c2412/s3c2413 specific */
93 s3c_device_sdi.name = "s3c2412-sdi"; 94 s3c_device_sdi.name = "s3c2412-sdi";
94 s3c_device_lcd.name = "s3c2412-lcd"; 95 s3c_device_lcd.name = "s3c2412-lcd";
95 s3c_device_nand.name = "s3c2412-nand"; 96 s3c_nand_setname("s3c2412-nand");
96 97
97 /* alter IRQ of SDI controller */ 98 /* alter IRQ of SDI controller */
98 99
diff --git a/arch/arm/mach-s3c2416/Kconfig b/arch/arm/mach-s3c2416/Kconfig
index 657e4fe17f39..87b9c9f003bd 100644
--- a/arch/arm/mach-s3c2416/Kconfig
+++ b/arch/arm/mach-s3c2416/Kconfig
@@ -25,6 +25,11 @@ config S3C2416_DMA
25 help 25 help
26 Internal config node for S3C2416 DMA support 26 Internal config node for S3C2416 DMA support
27 27
28config S3C2416_PM
29 bool
30 help
31 Internal config node to apply S3C2416 power management
32
28menu "S3C2416 Machines" 33menu "S3C2416 Machines"
29 34
30config MACH_SMDK2416 35config MACH_SMDK2416
@@ -33,6 +38,7 @@ config MACH_SMDK2416
33 select S3C_DEV_FB 38 select S3C_DEV_FB
34 select S3C_DEV_HSMMC 39 select S3C_DEV_HSMMC
35 select S3C_DEV_HSMMC1 40 select S3C_DEV_HSMMC1
41 select S3C2416_PM if PM
36 help 42 help
37 Say Y here if you are using an SMDK2416 43 Say Y here if you are using an SMDK2416
38 44
diff --git a/arch/arm/mach-s3c2416/Makefile b/arch/arm/mach-s3c2416/Makefile
index 6c12c7bf40ad..ef038d62ffdb 100644
--- a/arch/arm/mach-s3c2416/Makefile
+++ b/arch/arm/mach-s3c2416/Makefile
@@ -11,7 +11,7 @@ obj- :=
11 11
12obj-$(CONFIG_CPU_S3C2416) += s3c2416.o clock.o 12obj-$(CONFIG_CPU_S3C2416) += s3c2416.o clock.o
13obj-$(CONFIG_CPU_S3C2416) += irq.o 13obj-$(CONFIG_CPU_S3C2416) += irq.o
14 14obj-$(CONFIG_S3C2416_PM) += pm.o
15#obj-$(CONFIG_S3C2416_DMA) += dma.o 15#obj-$(CONFIG_S3C2416_DMA) += dma.o
16 16
17# Machine support 17# Machine support
diff --git a/arch/arm/mach-s3c2416/irq.c b/arch/arm/mach-s3c2416/irq.c
index 89f521d59d06..084d121f368c 100644
--- a/arch/arm/mach-s3c2416/irq.c
+++ b/arch/arm/mach-s3c2416/irq.c
@@ -243,6 +243,8 @@ static int __init s3c2416_irq_add(struct sys_device *sysdev)
243 243
244static struct sysdev_driver s3c2416_irq_driver = { 244static struct sysdev_driver s3c2416_irq_driver = {
245 .add = s3c2416_irq_add, 245 .add = s3c2416_irq_add,
246 .suspend = s3c24xx_irq_suspend,
247 .resume = s3c24xx_irq_resume,
246}; 248};
247 249
248static int __init s3c2416_irq_init(void) 250static int __init s3c2416_irq_init(void)
diff --git a/arch/arm/mach-s3c2416/pm.c b/arch/arm/mach-s3c2416/pm.c
new file mode 100644
index 000000000000..4a04205b04d5
--- /dev/null
+++ b/arch/arm/mach-s3c2416/pm.c
@@ -0,0 +1,84 @@
1/* linux/arch/arm/mach-s3c2416/pm.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM 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/sysdev.h>
14#include <linux/io.h>
15
16#include <asm/cacheflush.h>
17
18#include <mach/regs-power.h>
19#include <mach/regs-s3c2443-clock.h>
20
21#include <plat/cpu.h>
22#include <plat/pm.h>
23
24extern void s3c2412_sleep_enter(void);
25
26static void s3c2416_cpu_suspend(void)
27{
28 flush_cache_all();
29
30 /* enable wakeup sources regardless of battery state */
31 __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
32
33 /* set the mode as sleep, 2BED represents "Go to BED" */
34 __raw_writel(0x2BED, S3C2443_PWRMODE);
35
36 s3c2412_sleep_enter();
37}
38
39static void s3c2416_pm_prepare(void)
40{
41 /*
42 * write the magic value u-boot uses to check for resume into
43 * the INFORM0 register, and ensure INFORM1 is set to the
44 * correct address to resume from.
45 */
46 __raw_writel(0x2BED, S3C2412_INFORM0);
47 __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
48}
49
50static int s3c2416_pm_add(struct sys_device *sysdev)
51{
52 pm_cpu_prep = s3c2416_pm_prepare;
53 pm_cpu_sleep = s3c2416_cpu_suspend;
54
55 return 0;
56}
57
58static int s3c2416_pm_suspend(struct sys_device *dev, pm_message_t state)
59{
60 return 0;
61}
62
63static int s3c2416_pm_resume(struct sys_device *dev)
64{
65 /* unset the return-from-sleep amd inform flags */
66 __raw_writel(0x0, S3C2443_PWRMODE);
67 __raw_writel(0x0, S3C2412_INFORM0);
68 __raw_writel(0x0, S3C2412_INFORM1);
69
70 return 0;
71}
72
73static struct sysdev_driver s3c2416_pm_driver = {
74 .add = s3c2416_pm_add,
75 .suspend = s3c2416_pm_suspend,
76 .resume = s3c2416_pm_resume,
77};
78
79static __init int s3c2416_pm_init(void)
80{
81 return sysdev_driver_register(&s3c2416_sysclass, &s3c2416_pm_driver);
82}
83
84arch_initcall(s3c2416_pm_init);
diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c2416/s3c2416.c
index bc30245e133b..63f39cdc0972 100644
--- a/arch/arm/mach-s3c2416/s3c2416.c
+++ b/arch/arm/mach-s3c2416/s3c2416.c
@@ -56,6 +56,7 @@
56 56
57#include <plat/iic-core.h> 57#include <plat/iic-core.h>
58#include <plat/fb-core.h> 58#include <plat/fb-core.h>
59#include <plat/nand-core.h>
59 60
60static struct map_desc s3c2416_iodesc[] __initdata = { 61static struct map_desc s3c2416_iodesc[] __initdata = {
61 IODESC_ENT(WATCHDOG), 62 IODESC_ENT(WATCHDOG),
@@ -100,7 +101,7 @@ void __init s3c2416_init_uarts(struct s3c2410_uartcfg *cfg, int no)
100{ 101{
101 s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no); 102 s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no);
102 103
103 s3c_device_nand.name = "s3c2416-nand"; 104 s3c_nand_setname("s3c2412-nand");
104} 105}
105 106
106/* s3c2416_map_io 107/* s3c2416_map_io
diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index cd8e7de388f0..ff024a6c0f85 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -4,7 +4,6 @@
4 4
5config CPU_S3C2440 5config CPU_S3C2440
6 bool 6 bool
7 depends on ARCH_S3C2410
8 select CPU_ARM920T 7 select CPU_ARM920T
9 select S3C_GPIO_PULL_UP 8 select S3C_GPIO_PULL_UP
10 select S3C2410_CLOCK 9 select S3C2410_CLOCK
@@ -18,7 +17,6 @@ config CPU_S3C2440
18 17
19config CPU_S3C2442 18config CPU_S3C2442
20 bool 19 bool
21 depends on ARCH_S3C2410
22 select CPU_ARM920T 20 select CPU_ARM920T
23 select S3C2410_CLOCK 21 select S3C2410_CLOCK
24 select S3C2410_GPIO 22 select S3C2410_GPIO
@@ -30,7 +28,7 @@ config CPU_S3C2442
30 28
31config CPU_S3C244X 29config CPU_S3C244X
32 bool 30 bool
33 depends on ARCH_S3C2410 && (CPU_S3C2440 || CPU_S3C2442) 31 depends on CPU_S3C2440 || CPU_S3C2442
34 help 32 help
35 Support for S3C2440 and S3C2442 Samsung Mobile CPU based systems. 33 Support for S3C2440 and S3C2442 Samsung Mobile CPU based systems.
36 34
@@ -72,7 +70,7 @@ config S3C2440_PLL_16934400
72 70
73config S3C2440_DMA 71config S3C2440_DMA
74 bool 72 bool
75 depends on ARCH_S3C2410 && CPU_S3C24405B 73 depends on CPU_S3C2440
76 help 74 help
77 Support for S3C2440 specific DMA code5A 75 Support for S3C2440 specific DMA code5A
78 76
@@ -181,7 +179,6 @@ config MACH_MINI2440
181 select CPU_S3C2440 179 select CPU_S3C2440
182 select EEPROM_AT24 180 select EEPROM_AT24
183 select LEDS_TRIGGER_BACKLIGHT 181 select LEDS_TRIGGER_BACKLIGHT
184 select SND_S3C24XX_SOC_S3C24XX_UDA134X
185 select S3C_DEV_NAND 182 select S3C_DEV_NAND
186 select S3C_DEV_USB_HOST 183 select S3C_DEV_USB_HOST
187 help 184 help
diff --git a/arch/arm/mach-s3c2440/mach-at2440evb.c b/arch/arm/mach-s3c2440/mach-at2440evb.c
index e3810c86a5e6..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
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 32019bd9db3b..e0622bbb6dfa 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -25,8 +25,12 @@
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/gpio_keys.h> 26#include <linux/gpio_keys.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/pda_power.h>
28#include <linux/pwm_backlight.h> 29#include <linux/pwm_backlight.h>
29#include <linux/pwm.h> 30#include <linux/pwm.h>
31#include <linux/s3c_adc_battery.h>
32#include <linux/leds.h>
33#include <linux/i2c.h>
30 34
31#include <linux/mtd/mtd.h> 35#include <linux/mtd/mtd.h>
32#include <linux/mtd/partitions.h> 36#include <linux/mtd/partitions.h>
@@ -55,6 +59,8 @@
55#include <plat/irq.h> 59#include <plat/irq.h>
56#include <plat/ts.h> 60#include <plat/ts.h>
57 61
62#include <sound/uda1380.h>
63
58#define LCD_PWM_PERIOD 192960 64#define LCD_PWM_PERIOD 192960
59#define LCD_PWM_DUTY 127353 65#define LCD_PWM_DUTY 127353
60 66
@@ -127,6 +133,193 @@ static struct s3c2410fb_display rx1950_display = {
127 133
128}; 134};
129 135
136static int power_supply_init(struct device *dev)
137{
138 return gpio_request(S3C2410_GPF(2), "cable plugged");
139}
140
141static int rx1950_is_ac_online(void)
142{
143 return !gpio_get_value(S3C2410_GPF(2));
144}
145
146static void power_supply_exit(struct device *dev)
147{
148 gpio_free(S3C2410_GPF(2));
149}
150
151static char *rx1950_supplicants[] = {
152 "main-battery"
153};
154
155static struct pda_power_pdata power_supply_info = {
156 .init = power_supply_init,
157 .is_ac_online = rx1950_is_ac_online,
158 .exit = power_supply_exit,
159 .supplied_to = rx1950_supplicants,
160 .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
161};
162
163static struct resource power_supply_resources[] = {
164 [0] = {
165 .name = "ac",
166 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
167 IORESOURCE_IRQ_HIGHEDGE,
168 .start = IRQ_EINT2,
169 .end = IRQ_EINT2,
170 },
171};
172
173static struct platform_device power_supply = {
174 .name = "pda-power",
175 .id = -1,
176 .dev = {
177 .platform_data =
178 &power_supply_info,
179 },
180 .resource = power_supply_resources,
181 .num_resources = ARRAY_SIZE(power_supply_resources),
182};
183
184static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
185 { .volt = 4100, .cur = 156, .level = 100},
186 { .volt = 4050, .cur = 156, .level = 95},
187 { .volt = 4025, .cur = 141, .level = 90},
188 { .volt = 3995, .cur = 144, .level = 85},
189 { .volt = 3957, .cur = 162, .level = 80},
190 { .volt = 3931, .cur = 147, .level = 75},
191 { .volt = 3902, .cur = 147, .level = 70},
192 { .volt = 3863, .cur = 153, .level = 65},
193 { .volt = 3838, .cur = 150, .level = 60},
194 { .volt = 3800, .cur = 153, .level = 55},
195 { .volt = 3765, .cur = 153, .level = 50},
196 { .volt = 3748, .cur = 172, .level = 45},
197 { .volt = 3740, .cur = 153, .level = 40},
198 { .volt = 3714, .cur = 175, .level = 35},
199 { .volt = 3710, .cur = 156, .level = 30},
200 { .volt = 3963, .cur = 156, .level = 25},
201 { .volt = 3672, .cur = 178, .level = 20},
202 { .volt = 3651, .cur = 178, .level = 15},
203 { .volt = 3629, .cur = 178, .level = 10},
204 { .volt = 3612, .cur = 162, .level = 5},
205 { .volt = 3605, .cur = 162, .level = 0},
206};
207
208static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
209 { .volt = 4200, .cur = 0, .level = 100},
210 { .volt = 4190, .cur = 0, .level = 99},
211 { .volt = 4178, .cur = 0, .level = 95},
212 { .volt = 4110, .cur = 0, .level = 70},
213 { .volt = 4076, .cur = 0, .level = 65},
214 { .volt = 4046, .cur = 0, .level = 60},
215 { .volt = 4021, .cur = 0, .level = 55},
216 { .volt = 3999, .cur = 0, .level = 50},
217 { .volt = 3982, .cur = 0, .level = 45},
218 { .volt = 3965, .cur = 0, .level = 40},
219 { .volt = 3957, .cur = 0, .level = 35},
220 { .volt = 3948, .cur = 0, .level = 30},
221 { .volt = 3936, .cur = 0, .level = 25},
222 { .volt = 3927, .cur = 0, .level = 20},
223 { .volt = 3906, .cur = 0, .level = 15},
224 { .volt = 3880, .cur = 0, .level = 10},
225 { .volt = 3829, .cur = 0, .level = 5},
226 { .volt = 3820, .cur = 0, .level = 0},
227};
228
229int rx1950_bat_init(void)
230{
231 int ret;
232
233 ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
234 if (ret)
235 goto err_gpio1;
236 ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
237 if (ret)
238 goto err_gpio2;
239
240 return 0;
241
242err_gpio2:
243 gpio_free(S3C2410_GPJ(2));
244err_gpio1:
245 return ret;
246}
247
248void rx1950_bat_exit(void)
249{
250 gpio_free(S3C2410_GPJ(2));
251 gpio_free(S3C2410_GPJ(3));
252}
253
254void rx1950_enable_charger(void)
255{
256 gpio_direction_output(S3C2410_GPJ(2), 1);
257 gpio_direction_output(S3C2410_GPJ(3), 1);
258}
259
260void rx1950_disable_charger(void)
261{
262 gpio_direction_output(S3C2410_GPJ(2), 0);
263 gpio_direction_output(S3C2410_GPJ(3), 0);
264}
265
266static struct gpio_led rx1950_leds_desc[] = {
267 {
268 .name = "Green",
269 .default_trigger = "main-battery-charging-or-full",
270 .gpio = S3C2410_GPA(6),
271 },
272 {
273 .name = "Red",
274 .default_trigger = "main-battery-full",
275 .gpio = S3C2410_GPA(7),
276 },
277 {
278 .name = "Blue",
279 .default_trigger = "rx1950-acx-mem",
280 .gpio = S3C2410_GPA(11),
281 },
282};
283
284static struct gpio_led_platform_data rx1950_leds_pdata = {
285 .num_leds = ARRAY_SIZE(rx1950_leds_desc),
286 .leds = rx1950_leds_desc,
287};
288
289static struct platform_device rx1950_leds = {
290 .name = "leds-gpio",
291 .id = -1,
292 .dev = {
293 .platform_data = &rx1950_leds_pdata,
294 },
295};
296
297static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
298 .init = rx1950_bat_init,
299 .exit = rx1950_bat_exit,
300 .enable_charger = rx1950_enable_charger,
301 .disable_charger = rx1950_disable_charger,
302 .gpio_charge_finished = S3C2410_GPF(3),
303 .lut_noac = bat_lut_noac,
304 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
305 .lut_acin = bat_lut_acin,
306 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
307 .volt_channel = 0,
308 .current_channel = 1,
309 .volt_mult = 4235,
310 .current_mult = 2900,
311 .internal_impedance = 200,
312};
313
314static struct platform_device rx1950_battery = {
315 .name = "s3c-adc-battery",
316 .id = -1,
317 .dev = {
318 .parent = &s3c_device_adc.dev,
319 .platform_data = &rx1950_bat_cfg,
320 },
321};
322
130static struct s3c2410fb_mach_info rx1950_lcd_cfg = { 323static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
131 .displays = &rx1950_display, 324 .displays = &rx1950_display,
132 .num_displays = 1, 325 .num_displays = 1,
@@ -481,11 +674,17 @@ static struct platform_device rx1950_device_gpiokeys = {
481 .dev.platform_data = &rx1950_gpio_keys_data, 674 .dev.platform_data = &rx1950_gpio_keys_data,
482}; 675};
483 676
484static struct s3c2410_platform_i2c rx1950_i2c_data = { 677static struct uda1380_platform_data uda1380_info = {
485 .flags = 0, 678 .gpio_power = S3C2410_GPJ(0),
486 .slave_addr = 0x42, 679 .gpio_reset = S3C2410_GPD(0),
487 .frequency = 400 * 1000, 680 .dac_clk = UDA1380_DAC_CLK_SYSCLK,
488 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON, 681};
682
683static struct i2c_board_info rx1950_i2c_devices[] = {
684 {
685 I2C_BOARD_INFO("uda1380", 0x1a),
686 .platform_data = &uda1380_info,
687 },
489}; 688};
490 689
491static struct platform_device *rx1950_devices[] __initdata = { 690static struct platform_device *rx1950_devices[] __initdata = {
@@ -493,6 +692,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
493 &s3c_device_wdt, 692 &s3c_device_wdt,
494 &s3c_device_i2c0, 693 &s3c_device_i2c0,
495 &s3c_device_iis, 694 &s3c_device_iis,
695 &s3c_device_pcm,
496 &s3c_device_usbgadget, 696 &s3c_device_usbgadget,
497 &s3c_device_rtc, 697 &s3c_device_rtc,
498 &s3c_device_nand, 698 &s3c_device_nand,
@@ -503,6 +703,9 @@ static struct platform_device *rx1950_devices[] __initdata = {
503 &s3c_device_timer[1], 703 &s3c_device_timer[1],
504 &rx1950_backlight, 704 &rx1950_backlight,
505 &rx1950_device_gpiokeys, 705 &rx1950_device_gpiokeys,
706 &power_supply,
707 &rx1950_battery,
708 &rx1950_leds,
506}; 709};
507 710
508static struct clk *rx1950_clocks[] __initdata = { 711static struct clk *rx1950_clocks[] __initdata = {
@@ -538,7 +741,7 @@ static void __init rx1950_init_machine(void)
538 s3c24xx_udc_set_platdata(&rx1950_udc_cfg); 741 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
539 s3c24xx_ts_set_platdata(&rx1950_ts_cfg); 742 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
540 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); 743 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
541 s3c_i2c0_set_platdata(&rx1950_i2c_data); 744 s3c_i2c0_set_platdata(NULL);
542 s3c_nand_set_platdata(&rx1950_nand_info); 745 s3c_nand_set_platdata(&rx1950_nand_info);
543 746
544 /* Turn off suspend on both USB ports, and switch the 747 /* Turn off suspend on both USB ports, and switch the
@@ -569,6 +772,9 @@ static void __init rx1950_init_machine(void)
569 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power")); 772 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
570 773
571 platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); 774 platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
775
776 i2c_register_board_info(0, rx1950_i2c_devices,
777 ARRAY_SIZE(rx1950_i2c_devices));
572} 778}
573 779
574/* H1940 and RX3715 need to reserve this for suspend */ 780/* H1940 and RX3715 need to reserve this for suspend */
diff --git a/arch/arm/mach-s3c2440/s3c244x.c b/arch/arm/mach-s3c2440/s3c244x.c
index 5e4a97e76533..90c1707b9c95 100644
--- a/arch/arm/mach-s3c2440/s3c244x.c
+++ b/arch/arm/mach-s3c2440/s3c244x.c
@@ -44,6 +44,7 @@
44#include <plat/cpu.h> 44#include <plat/cpu.h>
45#include <plat/pm.h> 45#include <plat/pm.h>
46#include <plat/pll.h> 46#include <plat/pll.h>
47#include <plat/nand-core.h>
47 48
48static struct map_desc s3c244x_iodesc[] __initdata = { 49static struct map_desc s3c244x_iodesc[] __initdata = {
49 IODESC_ENT(CLKPWR), 50 IODESC_ENT(CLKPWR),
@@ -68,7 +69,7 @@ void __init s3c244x_map_io(void)
68 69
69 s3c_device_sdi.name = "s3c2440-sdi"; 70 s3c_device_sdi.name = "s3c2440-sdi";
70 s3c_device_i2c0.name = "s3c2440-i2c"; 71 s3c_device_i2c0.name = "s3c2440-i2c";
71 s3c_device_nand.name = "s3c2440-nand"; 72 s3c_nand_setname("s3c2440-nand");
72 s3c_device_ts.name = "s3c2440-ts"; 73 s3c_device_ts.name = "s3c2440-ts";
73 s3c_device_usbgadget.name = "s3c2440-usbgadget"; 74 s3c_device_usbgadget.name = "s3c2440-usbgadget";
74} 75}
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c2443/s3c2443.c
index 839b6b2ced74..33d18dd1ebd5 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c2443/s3c2443.c
@@ -36,6 +36,7 @@
36#include <plat/devs.h> 36#include <plat/devs.h>
37#include <plat/cpu.h> 37#include <plat/cpu.h>
38#include <plat/fb-core.h> 38#include <plat/fb-core.h>
39#include <plat/nand-core.h>
39 40
40static struct map_desc s3c2443_iodesc[] __initdata = { 41static struct map_desc s3c2443_iodesc[] __initdata = {
41 IODESC_ENT(WATCHDOG), 42 IODESC_ENT(WATCHDOG),
@@ -62,7 +63,7 @@ int __init s3c2443_init(void)
62 63
63 s3c24xx_reset_hook = s3c2443_hard_reset; 64 s3c24xx_reset_hook = s3c2443_hard_reset;
64 65
65 s3c_device_nand.name = "s3c2412-nand"; 66 s3c_nand_setname("s3c2412-nand");
66 s3c_fb_setname("s3c2443-fb"); 67 s3c_fb_setname("s3c2443-fb");
67 68
68 /* change WDT IRQ number */ 69 /* change WDT IRQ number */
diff --git a/arch/arm/mach-s3c24a0/include/mach/vmalloc.h b/arch/arm/mach-s3c24a0/include/mach/vmalloc.h
index 914656820794..6480b15277f3 100644
--- a/arch/arm/mach-s3c24a0/include/mach/vmalloc.h
+++ b/arch/arm/mach-s3c24a0/include/mach/vmalloc.h
@@ -12,6 +12,6 @@
12#ifndef __ASM_ARCH_VMALLOC_H 12#ifndef __ASM_ARCH_VMALLOC_H
13#define __ASM_ARCH_VMALLOC_H 13#define __ASM_ARCH_VMALLOC_H
14 14
15#define VMALLOC_END (0xe0000000UL) 15#define VMALLOC_END 0xF6000000UL
16 16
17#endif /* __ASM_ARCH_VMALLOC_H */ 17#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index 1e4d78af7d84..579d2f0f4dd0 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -98,12 +98,33 @@ config MACH_ANW6410
98 help 98 help
99 Machine support for the A&W6410 99 Machine support for the A&W6410
100 100
101config MACH_MINI6410
102 bool "MINI6410"
103 select CPU_S3C6410
104 select S3C_DEV_HSMMC
105 select S3C_DEV_HSMMC1
106 select S3C64XX_SETUP_SDHCI
107 select S3C_DEV_USB_HOST
108 select S3C_DEV_NAND
109 select S3C_DEV_FB
110 select S3C64XX_SETUP_FB_24BPP
111 select SAMSUNG_DEV_ADC
112 select SAMSUNG_DEV_TS
113 help
114 Machine support for the FriendlyARM MINI6410
115
101config MACH_REAL6410 116config MACH_REAL6410
102 bool "REAL6410" 117 bool "REAL6410"
103 select CPU_S3C6410 118 select CPU_S3C6410
104 select S3C_DEV_HSMMC 119 select S3C_DEV_HSMMC
105 select S3C_DEV_HSMMC1 120 select S3C_DEV_HSMMC1
106 select S3C64XX_SETUP_SDHCI 121 select S3C64XX_SETUP_SDHCI
122 select S3C_DEV_FB
123 select S3C64XX_SETUP_FB_24BPP
124 select S3C_DEV_NAND
125 select SAMSUNG_DEV_ADC
126 select SAMSUNG_DEV_TS
127 select S3C_DEV_USB_HOST
107 help 128 help
108 Machine support for the CoreWind REAL6410 129 Machine support for the CoreWind REAL6410
109 130
@@ -122,7 +143,7 @@ config MACH_SMDK6410
122 select S3C_DEV_USB_HSOTG 143 select S3C_DEV_USB_HSOTG
123 select S3C_DEV_WDT 144 select S3C_DEV_WDT
124 select SAMSUNG_DEV_KEYPAD 145 select SAMSUNG_DEV_KEYPAD
125 select HAVE_S3C2410_WATCHDOG 146 select HAVE_S3C2410_WATCHDOG if WATCHDOG
126 select S3C64XX_SETUP_SDHCI 147 select S3C64XX_SETUP_SDHCI
127 select S3C64XX_SETUP_I2C1 148 select S3C64XX_SETUP_I2C1
128 select S3C64XX_SETUP_IDE 149 select S3C64XX_SETUP_IDE
@@ -185,6 +206,7 @@ config SMDK6410_WM1192_EV1
185 select REGULATOR_WM831X 206 select REGULATOR_WM831X
186 select S3C24XX_GPIO_EXTRA64 207 select S3C24XX_GPIO_EXTRA64
187 select MFD_WM831X 208 select MFD_WM831X
209 select MFD_WM831X_I2C
188 help 210 help
189 The Wolfson Microelectronics 1192-EV1 is a WM831x based PMIC 211 The Wolfson Microelectronics 1192-EV1 is a WM831x based PMIC
190 daughtercard for the Samsung SMDK6410 reference platform. 212 daughtercard for the Samsung SMDK6410 reference platform.
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile
index 90221a2e0c55..4657363f0674 100644
--- a/arch/arm/mach-s3c64xx/Makefile
+++ b/arch/arm/mach-s3c64xx/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_MACH_ANW6410) += mach-anw6410.o
53obj-$(CONFIG_MACH_SMDK6400) += mach-smdk6400.o 53obj-$(CONFIG_MACH_SMDK6400) += mach-smdk6400.o
54obj-$(CONFIG_MACH_SMDK6410) += mach-smdk6410.o 54obj-$(CONFIG_MACH_SMDK6410) += mach-smdk6410.o
55obj-$(CONFIG_MACH_REAL6410) += mach-real6410.o 55obj-$(CONFIG_MACH_REAL6410) += mach-real6410.o
56obj-$(CONFIG_MACH_MINI6410) += mach-mini6410.o
56obj-$(CONFIG_MACH_NCP) += mach-ncp.o 57obj-$(CONFIG_MACH_NCP) += mach-ncp.o
57obj-$(CONFIG_MACH_HMT) += mach-hmt.o 58obj-$(CONFIG_MACH_HMT) += mach-hmt.o
58obj-$(CONFIG_MACH_SMARTQ) += mach-smartq.o 59obj-$(CONFIG_MACH_SMARTQ) += mach-smartq.o
diff --git a/arch/arm/mach-s3c64xx/dev-audio.c b/arch/arm/mach-s3c64xx/dev-audio.c
index 9648fbc36eec..76426a32c013 100644
--- a/arch/arm/mach-s3c64xx/dev-audio.c
+++ b/arch/arm/mach-s3c64xx/dev-audio.c
@@ -22,44 +22,34 @@
22#include <plat/audio.h> 22#include <plat/audio.h>
23#include <plat/gpio-cfg.h> 23#include <plat/gpio-cfg.h>
24 24
25#include <mach/gpio-bank-c.h>
26#include <mach/gpio-bank-d.h>
27#include <mach/gpio-bank-e.h>
28#include <mach/gpio-bank-h.h>
29
30static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev) 25static int s3c64xx_i2sv3_cfg_gpio(struct platform_device *pdev)
31{ 26{
27 unsigned int base;
28
32 switch (pdev->id) { 29 switch (pdev->id) {
33 case 0: 30 case 0:
34 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); 31 base = S3C64XX_GPD(0);
35 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK);
36 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK);
37 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI);
38 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0);
39 break; 32 break;
40 case 1: 33 case 1:
41 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK); 34 base = S3C64XX_GPE(0);
42 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK); 35 break;
43 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK);
44 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI);
45 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0);
46 default: 36 default:
47 printk(KERN_DEBUG "Invalid I2S Controller number!"); 37 printk(KERN_DEBUG "Invalid I2S Controller number: %d\n",
38 pdev->id);
48 return -EINVAL; 39 return -EINVAL;
49 } 40 }
50 41
42 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
43
51 return 0; 44 return 0;
52} 45}
53 46
54static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev) 47static int s3c64xx_i2sv4_cfg_gpio(struct platform_device *pdev)
55{ 48{
56 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C64XX_GPC4_I2S_V40_DO0); 49 s3c_gpio_cfgpin(S3C64XX_GPC(4), S3C_GPIO_SFN(5));
57 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C64XX_GPC5_I2S_V40_DO1); 50 s3c_gpio_cfgpin(S3C64XX_GPC(5), S3C_GPIO_SFN(5));
58 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C64XX_GPC7_I2S_V40_DO2); 51 s3c_gpio_cfgpin(S3C64XX_GPC(7), S3C_GPIO_SFN(5));
59 s3c_gpio_cfgpin(S3C64XX_GPH(6), S3C64XX_GPH6_I2S_V40_BCLK); 52 s3c_gpio_cfgpin_range(S3C64XX_GPH(6), 4, S3C_GPIO_SFN(5));
60 s3c_gpio_cfgpin(S3C64XX_GPH(7), S3C64XX_GPH7_I2S_V40_CDCLK);
61 s3c_gpio_cfgpin(S3C64XX_GPH(8), S3C64XX_GPH8_I2S_V40_LRCLK);
62 s3c_gpio_cfgpin(S3C64XX_GPH(9), S3C64XX_GPH9_I2S_V40_DI);
63 53
64 return 0; 54 return 0;
65} 55}
@@ -168,26 +158,22 @@ EXPORT_SYMBOL(s3c64xx_device_iisv4);
168 158
169static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) 159static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)
170{ 160{
161 unsigned int base;
162
171 switch (pdev->id) { 163 switch (pdev->id) {
172 case 0: 164 case 0:
173 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_PCM0_SCLK); 165 base = S3C64XX_GPD(0);
174 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_PCM0_EXTCLK);
175 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_PCM0_FSYNC);
176 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_PCM0_SIN);
177 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_PCM0_SOUT);
178 break; 166 break;
179 case 1: 167 case 1:
180 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_PCM1_SCLK); 168 base = S3C64XX_GPE(0);
181 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_PCM1_EXTCLK);
182 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_PCM1_FSYNC);
183 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_PCM1_SIN);
184 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_PCM1_SOUT);
185 break; 169 break;
186 default: 170 default:
187 printk(KERN_DEBUG "Invalid PCM Controller number!"); 171 printk(KERN_DEBUG "Invalid PCM Controller number: %d\n",
172 pdev->id);
188 return -EINVAL; 173 return -EINVAL;
189 } 174 }
190 175
176 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
191 return 0; 177 return 0;
192} 178}
193 179
@@ -261,24 +247,12 @@ EXPORT_SYMBOL(s3c64xx_device_pcm1);
261 247
262static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev) 248static int s3c64xx_ac97_cfg_gpd(struct platform_device *pdev)
263{ 249{
264 s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_AC97_BITCLK); 250 return s3c_gpio_cfgpin_range(S3C64XX_GPD(0), 5, S3C_GPIO_SFN(4));
265 s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_AC97_nRESET);
266 s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_AC97_SYNC);
267 s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_AC97_SDI);
268 s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_AC97_SDO);
269
270 return 0;
271} 251}
272 252
273static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev) 253static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)
274{ 254{
275 s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_AC97_BITCLK); 255 return s3c_gpio_cfgpin_range(S3C64XX_GPE(0), 5, S3C_GPIO_SFN(4));
276 s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_AC97_nRESET);
277 s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_AC97_SYNC);
278 s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_AC97_SDI);
279 s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_AC97_SDO);
280
281 return 0;
282} 256}
283 257
284static struct resource s3c64xx_ac97_resource[] = { 258static struct resource s3c64xx_ac97_resource[] = {
@@ -333,3 +307,16 @@ void __init s3c64xx_ac97_setup_gpio(int num)
333 else 307 else
334 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe; 308 s3c_ac97_pdata.cfg_gpio = s3c64xx_ac97_cfg_gpe;
335} 309}
310
311static u64 s3c_device_audio_dmamask = 0xffffffffUL;
312
313struct platform_device s3c_device_pcm = {
314 .name = "s3c24xx-pcm-audio",
315 .id = -1,
316 .dev = {
317 .dma_mask = &s3c_device_audio_dmamask,
318 .coherent_dma_mask = 0xffffffffUL
319 }
320};
321EXPORT_SYMBOL(s3c_device_pcm);
322
diff --git a/arch/arm/mach-s3c64xx/gpiolib.c b/arch/arm/mach-s3c64xx/gpiolib.c
index 300dee4a667b..fd99a82e82c4 100644
--- a/arch/arm/mach-s3c64xx/gpiolib.c
+++ b/arch/arm/mach-s3c64xx/gpiolib.c
@@ -195,11 +195,6 @@ static struct s3c_gpio_cfg gpio_2bit_cfg_eint11 = {
195 .get_pull = s3c_gpio_getpull_updown, 195 .get_pull = s3c_gpio_getpull_updown,
196}; 196};
197 197
198int s3c64xx_gpio2int_gpn(struct gpio_chip *chip, unsigned pin)
199{
200 return IRQ_EINT(0) + pin;
201}
202
203static struct s3c_gpio_chip gpio_2bit[] = { 198static struct s3c_gpio_chip gpio_2bit[] = {
204 { 199 {
205 .base = S3C64XX_GPF_BASE, 200 .base = S3C64XX_GPF_BASE,
@@ -227,12 +222,13 @@ static struct s3c_gpio_chip gpio_2bit[] = {
227 }, 222 },
228 }, { 223 }, {
229 .base = S3C64XX_GPN_BASE, 224 .base = S3C64XX_GPN_BASE,
225 .irq_base = IRQ_EINT(0),
230 .config = &gpio_2bit_cfg_eint10, 226 .config = &gpio_2bit_cfg_eint10,
231 .chip = { 227 .chip = {
232 .base = S3C64XX_GPN(0), 228 .base = S3C64XX_GPN(0),
233 .ngpio = S3C64XX_GPIO_N_NR, 229 .ngpio = S3C64XX_GPIO_N_NR,
234 .label = "GPN", 230 .label = "GPN",
235 .to_irq = s3c64xx_gpio2int_gpn, 231 .to_irq = samsung_gpiolib_to_irq,
236 }, 232 },
237 }, { 233 }, {
238 .base = S3C64XX_GPO_BASE, 234 .base = S3C64XX_GPO_BASE,
diff --git a/arch/arm/mach-s3c64xx/include/mach/vmalloc.h b/arch/arm/mach-s3c64xx/include/mach/vmalloc.h
index bc0e91389864..23f75e556a30 100644
--- a/arch/arm/mach-s3c64xx/include/mach/vmalloc.h
+++ b/arch/arm/mach-s3c64xx/include/mach/vmalloc.h
@@ -15,6 +15,6 @@
15#ifndef __ASM_ARCH_VMALLOC_H 15#ifndef __ASM_ARCH_VMALLOC_H
16#define __ASM_ARCH_VMALLOC_H 16#define __ASM_ARCH_VMALLOC_H
17 17
18#define VMALLOC_END 0xE0000000UL 18#define VMALLOC_END 0xF6000000UL
19 19
20#endif /* __ASM_ARCH_VMALLOC_H */ 20#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s3c64xx/mach-mini6410.c b/arch/arm/mach-s3c64xx/mach-mini6410.c
new file mode 100644
index 000000000000..249c62956471
--- /dev/null
+++ b/arch/arm/mach-s3c64xx/mach-mini6410.c
@@ -0,0 +1,357 @@
1/* linux/arch/arm/mach-s3c64xx/mach-mini6410.c
2 *
3 * Copyright 2010 Darius Augulis <augulis.darius@gmail.com>
4 * Copyright 2008 Openmoko, Inc.
5 * Copyright 2008 Simtec Electronics
6 * Ben Dooks <ben@simtec.co.uk>
7 * http://armlinux.simtec.co.uk/
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
15#include <linux/init.h>
16#include <linux/interrupt.h>
17#include <linux/fb.h>
18#include <linux/gpio.h>
19#include <linux/kernel.h>
20#include <linux/list.h>
21#include <linux/dm9000.h>
22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
24#include <linux/serial_core.h>
25#include <linux/types.h>
26
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30
31#include <mach/map.h>
32#include <mach/regs-fb.h>
33#include <mach/regs-gpio.h>
34#include <mach/regs-modem.h>
35#include <mach/regs-srom.h>
36#include <mach/s3c6410.h>
37
38#include <plat/adc.h>
39#include <plat/cpu.h>
40#include <plat/devs.h>
41#include <plat/fb.h>
42#include <plat/nand.h>
43#include <plat/regs-serial.h>
44#include <plat/ts.h>
45
46#include <video/platform_lcd.h>
47
48#define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
49#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
50#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
51
52static struct s3c2410_uartcfg mini6410_uartcfgs[] __initdata = {
53 [0] = {
54 .hwport = 0,
55 .flags = 0,
56 .ucon = UCON,
57 .ulcon = ULCON,
58 .ufcon = UFCON,
59 },
60 [1] = {
61 .hwport = 1,
62 .flags = 0,
63 .ucon = UCON,
64 .ulcon = ULCON,
65 .ufcon = UFCON,
66 },
67 [2] = {
68 .hwport = 2,
69 .flags = 0,
70 .ucon = UCON,
71 .ulcon = ULCON,
72 .ufcon = UFCON,
73 },
74 [3] = {
75 .hwport = 3,
76 .flags = 0,
77 .ucon = UCON,
78 .ulcon = ULCON,
79 .ufcon = UFCON,
80 },
81};
82
83/* DM9000AEP 10/100 ethernet controller */
84
85static struct resource mini6410_dm9k_resource[] = {
86 [0] = {
87 .start = S3C64XX_PA_XM0CSN1,
88 .end = S3C64XX_PA_XM0CSN1 + 1,
89 .flags = IORESOURCE_MEM
90 },
91 [1] = {
92 .start = S3C64XX_PA_XM0CSN1 + 4,
93 .end = S3C64XX_PA_XM0CSN1 + 5,
94 .flags = IORESOURCE_MEM
95 },
96 [2] = {
97 .start = S3C_EINT(7),
98 .end = S3C_EINT(7),
99 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL
100 }
101};
102
103static struct dm9000_plat_data mini6410_dm9k_pdata = {
104 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
105};
106
107static struct platform_device mini6410_device_eth = {
108 .name = "dm9000",
109 .id = -1,
110 .num_resources = ARRAY_SIZE(mini6410_dm9k_resource),
111 .resource = mini6410_dm9k_resource,
112 .dev = {
113 .platform_data = &mini6410_dm9k_pdata,
114 },
115};
116
117static struct mtd_partition mini6410_nand_part[] = {
118 [0] = {
119 .name = "uboot",
120 .size = SZ_1M,
121 .offset = 0,
122 },
123 [1] = {
124 .name = "kernel",
125 .size = SZ_2M,
126 .offset = SZ_1M,
127 },
128 [2] = {
129 .name = "rootfs",
130 .size = MTDPART_SIZ_FULL,
131 .offset = SZ_1M + SZ_2M,
132 },
133};
134
135static struct s3c2410_nand_set mini6410_nand_sets[] = {
136 [0] = {
137 .name = "nand",
138 .nr_chips = 1,
139 .nr_partitions = ARRAY_SIZE(mini6410_nand_part),
140 .partitions = mini6410_nand_part,
141 },
142};
143
144static struct s3c2410_platform_nand mini6410_nand_info = {
145 .tacls = 25,
146 .twrph0 = 55,
147 .twrph1 = 40,
148 .nr_sets = ARRAY_SIZE(mini6410_nand_sets),
149 .sets = mini6410_nand_sets,
150};
151
152static struct s3c_fb_pd_win mini6410_fb_win[] = {
153 {
154 .win_mode = { /* 4.3" 480x272 */
155 .left_margin = 3,
156 .right_margin = 2,
157 .upper_margin = 1,
158 .lower_margin = 1,
159 .hsync_len = 40,
160 .vsync_len = 1,
161 .xres = 480,
162 .yres = 272,
163 },
164 .max_bpp = 32,
165 .default_bpp = 16,
166 }, {
167 .win_mode = { /* 7.0" 800x480 */
168 .left_margin = 8,
169 .right_margin = 13,
170 .upper_margin = 7,
171 .lower_margin = 5,
172 .hsync_len = 3,
173 .vsync_len = 1,
174 .xres = 800,
175 .yres = 480,
176 },
177 .max_bpp = 32,
178 .default_bpp = 16,
179 },
180};
181
182static struct s3c_fb_platdata mini6410_lcd_pdata __initdata = {
183 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
184 .win[0] = &mini6410_fb_win[0],
185 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
186 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
187};
188
189static void mini6410_lcd_power_set(struct plat_lcd_data *pd,
190 unsigned int power)
191{
192 if (power)
193 gpio_direction_output(S3C64XX_GPE(0), 1);
194 else
195 gpio_direction_output(S3C64XX_GPE(0), 0);
196}
197
198static struct plat_lcd_data mini6410_lcd_power_data = {
199 .set_power = mini6410_lcd_power_set,
200};
201
202static struct platform_device mini6410_lcd_powerdev = {
203 .name = "platform-lcd",
204 .dev.parent = &s3c_device_fb.dev,
205 .dev.platform_data = &mini6410_lcd_power_data,
206};
207
208static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
209 .delay = 10000,
210 .presc = 49,
211 .oversampling_shift = 2,
212};
213
214static struct platform_device *mini6410_devices[] __initdata = {
215 &mini6410_device_eth,
216 &s3c_device_hsmmc0,
217 &s3c_device_hsmmc1,
218 &s3c_device_ohci,
219 &s3c_device_nand,
220 &s3c_device_fb,
221 &mini6410_lcd_powerdev,
222 &s3c_device_adc,
223 &s3c_device_ts,
224};
225
226static void __init mini6410_map_io(void)
227{
228 u32 tmp;
229
230 s3c64xx_init_io(NULL, 0);
231 s3c24xx_init_clocks(12000000);
232 s3c24xx_init_uarts(mini6410_uartcfgs, ARRAY_SIZE(mini6410_uartcfgs));
233
234 /* set the LCD type */
235 tmp = __raw_readl(S3C64XX_SPCON);
236 tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
237 tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
238 __raw_writel(tmp, S3C64XX_SPCON);
239
240 /* remove the LCD bypass */
241 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
242 tmp &= ~MIFPCON_LCD_BYPASS;
243 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
244}
245
246/*
247 * mini6410_features string
248 *
249 * 0-9 LCD configuration
250 *
251 */
252static char mini6410_features_str[12] __initdata = "0";
253
254static int __init mini6410_features_setup(char *str)
255{
256 if (str)
257 strlcpy(mini6410_features_str, str,
258 sizeof(mini6410_features_str));
259 return 1;
260}
261
262__setup("mini6410=", mini6410_features_setup);
263
264#define FEATURE_SCREEN (1 << 0)
265
266struct mini6410_features_t {
267 int done;
268 int lcd_index;
269};
270
271static void mini6410_parse_features(
272 struct mini6410_features_t *features,
273 const char *features_str)
274{
275 const char *fp = features_str;
276
277 features->done = 0;
278 features->lcd_index = 0;
279
280 while (*fp) {
281 char f = *fp++;
282
283 switch (f) {
284 case '0'...'9': /* tft screen */
285 if (features->done & FEATURE_SCREEN) {
286 printk(KERN_INFO "MINI6410: '%c' ignored, "
287 "screen type already set\n", f);
288 } else {
289 int li = f - '0';
290 if (li >= ARRAY_SIZE(mini6410_fb_win))
291 printk(KERN_INFO "MINI6410: '%c' out "
292 "of range LCD mode\n", f);
293 else {
294 features->lcd_index = li;
295 }
296 }
297 features->done |= FEATURE_SCREEN;
298 break;
299 }
300 }
301}
302
303static void __init mini6410_machine_init(void)
304{
305 u32 cs1;
306 struct mini6410_features_t features = { 0 };
307
308 printk(KERN_INFO "MINI6410: Option string mini6410=%s\n",
309 mini6410_features_str);
310
311 /* Parse the feature string */
312 mini6410_parse_features(&features, mini6410_features_str);
313
314 mini6410_lcd_pdata.win[0] = &mini6410_fb_win[features.lcd_index];
315
316 printk(KERN_INFO "MINI6410: selected LCD display is %dx%d\n",
317 mini6410_lcd_pdata.win[0]->win_mode.xres,
318 mini6410_lcd_pdata.win[0]->win_mode.yres);
319
320 s3c_nand_set_platdata(&mini6410_nand_info);
321 s3c_fb_set_platdata(&mini6410_lcd_pdata);
322 s3c24xx_ts_set_platdata(&s3c_ts_platform);
323
324 /* configure nCS1 width to 16 bits */
325
326 cs1 = __raw_readl(S3C64XX_SROM_BW) &
327 ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
328 cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
329 (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
330 (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
331 S3C64XX_SROM_BW__NCS1__SHIFT;
332 __raw_writel(cs1, S3C64XX_SROM_BW);
333
334 /* set timing for nCS1 suitable for ethernet chip */
335
336 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
337 (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
338 (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
339 (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
340 (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
341 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
342 (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
343
344 gpio_request(S3C64XX_GPF(15), "LCD power");
345 gpio_request(S3C64XX_GPE(0), "LCD power");
346
347 platform_add_devices(mini6410_devices, ARRAY_SIZE(mini6410_devices));
348}
349
350MACHINE_START(MINI6410, "MINI6410")
351 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
352 .boot_params = S3C64XX_PA_SDRAM + 0x100,
353 .init_irq = s3c6410_init_irq,
354 .map_io = mini6410_map_io,
355 .init_machine = mini6410_machine_init,
356 .timer = &s3c24xx_timer,
357MACHINE_END
diff --git a/arch/arm/mach-s3c64xx/mach-real6410.c b/arch/arm/mach-s3c64xx/mach-real6410.c
index 4b4475da8ec6..f9ef9b5c5f5a 100644
--- a/arch/arm/mach-s3c64xx/mach-real6410.c
+++ b/arch/arm/mach-s3c64xx/mach-real6410.c
@@ -12,23 +12,39 @@
12 * 12 *
13*/ 13*/
14 14
15#include <linux/kernel.h> 15#include <linux/init.h>
16#include <linux/types.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/fb.h>
18#include <linux/gpio.h>
19#include <linux/kernel.h>
18#include <linux/list.h> 20#include <linux/list.h>
19#include <linux/init.h>
20#include <linux/dm9000.h> 21#include <linux/dm9000.h>
21#include <linux/serial_core.h> 22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
22#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/serial_core.h>
26#include <linux/types.h>
27
23#include <asm/mach-types.h> 28#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 30#include <asm/mach/map.h>
31
26#include <mach/map.h> 32#include <mach/map.h>
27#include <mach/s3c6410.h> 33#include <mach/regs-fb.h>
34#include <mach/regs-gpio.h>
35#include <mach/regs-modem.h>
28#include <mach/regs-srom.h> 36#include <mach/regs-srom.h>
37#include <mach/s3c6410.h>
38
39#include <plat/adc.h>
29#include <plat/cpu.h> 40#include <plat/cpu.h>
30#include <plat/devs.h> 41#include <plat/devs.h>
42#include <plat/fb.h>
43#include <plat/nand.h>
31#include <plat/regs-serial.h> 44#include <plat/regs-serial.h>
45#include <plat/ts.h>
46
47#include <video/platform_lcd.h>
32 48
33#define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK) 49#define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK)
34#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB) 50#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
@@ -99,22 +115,192 @@ static struct platform_device real6410_device_eth = {
99 }, 115 },
100}; 116};
101 117
118static struct s3c_fb_pd_win real6410_fb_win[] = {
119 {
120 .win_mode = { /* 4.3" 480x272 */
121 .left_margin = 3,
122 .right_margin = 2,
123 .upper_margin = 1,
124 .lower_margin = 1,
125 .hsync_len = 40,
126 .vsync_len = 1,
127 .xres = 480,
128 .yres = 272,
129 },
130 .max_bpp = 32,
131 .default_bpp = 16,
132 }, {
133 .win_mode = { /* 7.0" 800x480 */
134 .left_margin = 8,
135 .right_margin = 13,
136 .upper_margin = 7,
137 .lower_margin = 5,
138 .hsync_len = 3,
139 .vsync_len = 1,
140 .xres = 800,
141 .yres = 480,
142 },
143 .max_bpp = 32,
144 .default_bpp = 16,
145 },
146};
147
148static struct s3c_fb_platdata real6410_lcd_pdata __initdata = {
149 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
150 .win[0] = &real6410_fb_win[0],
151 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
152 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
153};
154
155static struct mtd_partition real6410_nand_part[] = {
156 [0] = {
157 .name = "uboot",
158 .size = SZ_1M,
159 .offset = 0,
160 },
161 [1] = {
162 .name = "kernel",
163 .size = SZ_2M,
164 .offset = SZ_1M,
165 },
166 [2] = {
167 .name = "rootfs",
168 .size = MTDPART_SIZ_FULL,
169 .offset = SZ_1M + SZ_2M,
170 },
171};
172
173static struct s3c2410_nand_set real6410_nand_sets[] = {
174 [0] = {
175 .name = "nand",
176 .nr_chips = 1,
177 .nr_partitions = ARRAY_SIZE(real6410_nand_part),
178 .partitions = real6410_nand_part,
179 },
180};
181
182static struct s3c2410_platform_nand real6410_nand_info = {
183 .tacls = 25,
184 .twrph0 = 55,
185 .twrph1 = 40,
186 .nr_sets = ARRAY_SIZE(real6410_nand_sets),
187 .sets = real6410_nand_sets,
188};
189
102static struct platform_device *real6410_devices[] __initdata = { 190static struct platform_device *real6410_devices[] __initdata = {
103 &real6410_device_eth, 191 &real6410_device_eth,
104 &s3c_device_hsmmc0, 192 &s3c_device_hsmmc0,
105 &s3c_device_hsmmc1, 193 &s3c_device_hsmmc1,
194 &s3c_device_fb,
195 &s3c_device_nand,
196 &s3c_device_adc,
197 &s3c_device_ts,
198 &s3c_device_ohci,
199};
200
201static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
202 .delay = 10000,
203 .presc = 49,
204 .oversampling_shift = 2,
106}; 205};
107 206
108static void __init real6410_map_io(void) 207static void __init real6410_map_io(void)
109{ 208{
209 u32 tmp;
210
110 s3c64xx_init_io(NULL, 0); 211 s3c64xx_init_io(NULL, 0);
111 s3c24xx_init_clocks(12000000); 212 s3c24xx_init_clocks(12000000);
112 s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs)); 213 s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs));
214
215 /* set the LCD type */
216 tmp = __raw_readl(S3C64XX_SPCON);
217 tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
218 tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
219 __raw_writel(tmp, S3C64XX_SPCON);
220
221 /* remove the LCD bypass */
222 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
223 tmp &= ~MIFPCON_LCD_BYPASS;
224 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
225}
226
227/*
228 * real6410_features string
229 *
230 * 0-9 LCD configuration
231 *
232 */
233static char real6410_features_str[12] __initdata = "0";
234
235static int __init real6410_features_setup(char *str)
236{
237 if (str)
238 strlcpy(real6410_features_str, str,
239 sizeof(real6410_features_str));
240 return 1;
241}
242
243__setup("real6410=", real6410_features_setup);
244
245#define FEATURE_SCREEN (1 << 0)
246
247struct real6410_features_t {
248 int done;
249 int lcd_index;
250};
251
252static void real6410_parse_features(
253 struct real6410_features_t *features,
254 const char *features_str)
255{
256 const char *fp = features_str;
257
258 features->done = 0;
259 features->lcd_index = 0;
260
261 while (*fp) {
262 char f = *fp++;
263
264 switch (f) {
265 case '0'...'9': /* tft screen */
266 if (features->done & FEATURE_SCREEN) {
267 printk(KERN_INFO "REAL6410: '%c' ignored, "
268 "screen type already set\n", f);
269 } else {
270 int li = f - '0';
271 if (li >= ARRAY_SIZE(real6410_fb_win))
272 printk(KERN_INFO "REAL6410: '%c' out "
273 "of range LCD mode\n", f);
274 else {
275 features->lcd_index = li;
276 }
277 }
278 features->done |= FEATURE_SCREEN;
279 break;
280 }
281 }
113} 282}
114 283
115static void __init real6410_machine_init(void) 284static void __init real6410_machine_init(void)
116{ 285{
117 u32 cs1; 286 u32 cs1;
287 struct real6410_features_t features = { 0 };
288
289 printk(KERN_INFO "REAL6410: Option string real6410=%s\n",
290 real6410_features_str);
291
292 /* Parse the feature string */
293 real6410_parse_features(&features, real6410_features_str);
294
295 real6410_lcd_pdata.win[0] = &real6410_fb_win[features.lcd_index];
296
297 printk(KERN_INFO "REAL6410: selected LCD display is %dx%d\n",
298 real6410_lcd_pdata.win[0]->win_mode.xres,
299 real6410_lcd_pdata.win[0]->win_mode.yres);
300
301 s3c_fb_set_platdata(&real6410_lcd_pdata);
302 s3c_nand_set_platdata(&real6410_nand_info);
303 s3c24xx_ts_set_platdata(&s3c_ts_platform);
118 304
119 /* configure nCS1 width to 16 bits */ 305 /* configure nCS1 width to 16 bits */
120 306
@@ -136,6 +322,8 @@ static void __init real6410_machine_init(void)
136 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) | 322 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
137 (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1); 323 (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
138 324
325 gpio_request(S3C64XX_GPF(15), "LCD power");
326
139 platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices)); 327 platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices));
140} 328}
141 329
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index ec8865c03a19..77488facfe4c 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -283,6 +283,7 @@ static struct platform_device *smdk6410_devices[] __initdata = {
283 &s3c_device_fb, 283 &s3c_device_fb,
284 &s3c_device_ohci, 284 &s3c_device_ohci,
285 &s3c_device_usb_hsotg, 285 &s3c_device_usb_hsotg,
286 &s3c_device_pcm,
286 &s3c64xx_device_iisv4, 287 &s3c64xx_device_iisv4,
287 &samsung_device_keypad, 288 &samsung_device_keypad,
288 289
diff --git a/arch/arm/mach-s3c64xx/setup-fb-24bpp.c b/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
index 000736877df2..8f3091182f9c 100644
--- a/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
+++ b/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
@@ -23,15 +23,6 @@
23 23
24extern void s3c64xx_fb_gpio_setup_24bpp(void) 24extern void s3c64xx_fb_gpio_setup_24bpp(void)
25{ 25{
26 unsigned int gpio; 26 s3c_gpio_cfgrange_nopull(S3C64XX_GPI(0), 16, S3C_GPIO_SFN(2));
27 27 s3c_gpio_cfgrange_nopull(S3C64XX_GPJ(0), 12, S3C_GPIO_SFN(2));
28 for (gpio = S3C64XX_GPI(0); gpio <= S3C64XX_GPI(15); gpio++) {
29 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
30 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
31 }
32
33 for (gpio = S3C64XX_GPJ(0); gpio <= S3C64XX_GPJ(11); gpio++) {
34 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
35 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
36 }
37} 28}
diff --git a/arch/arm/mach-s3c64xx/setup-ide.c b/arch/arm/mach-s3c64xx/setup-ide.c
index c12c315f33bc..41b425602d88 100644
--- a/arch/arm/mach-s3c64xx/setup-ide.c
+++ b/arch/arm/mach-s3c64xx/setup-ide.c
@@ -17,11 +17,11 @@
17#include <mach/map.h> 17#include <mach/map.h>
18#include <mach/regs-clock.h> 18#include <mach/regs-clock.h>
19#include <plat/gpio-cfg.h> 19#include <plat/gpio-cfg.h>
20#include <plat/ata.h>
20 21
21void s3c64xx_ide_setup_gpio(void) 22void s3c64xx_ide_setup_gpio(void)
22{ 23{
23 u32 reg; 24 u32 reg;
24 u32 gpio = 0;
25 25
26 reg = readl(S3C_MEM_SYS_CFG) & (~0x3f); 26 reg = readl(S3C_MEM_SYS_CFG) & (~0x3f);
27 27
@@ -32,15 +32,12 @@ void s3c64xx_ide_setup_gpio(void)
32 s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4)); 32 s3c_gpio_cfgpin(S3C64XX_GPB(4), S3C_GPIO_SFN(4));
33 33
34 /* Set XhiDATA[15:0] pins as CF Data[15:0] */ 34 /* Set XhiDATA[15:0] pins as CF Data[15:0] */
35 for (gpio = S3C64XX_GPK(0); gpio <= S3C64XX_GPK(15); gpio++) 35 s3c_gpio_cfgpin_range(S3C64XX_GPK(0), 16, S3C_GPIO_SFN(5));
36 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(5));
37 36
38 /* Set XhiADDR[2:0] pins as CF ADDR[2:0] */ 37 /* Set XhiADDR[2:0] pins as CF ADDR[2:0] */
39 for (gpio = S3C64XX_GPL(0); gpio <= S3C64XX_GPL(2); gpio++) 38 s3c_gpio_cfgpin_range(S3C64XX_GPL(0), 3, S3C_GPIO_SFN(6));
40 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));
41 39
42 /* Set Xhi ctrl pins as CF ctrl pins(IORDY, IOWR, IORD, CE[0:1]) */ 40 /* Set Xhi ctrl pins as CF ctrl pins(IORDY, IOWR, IORD, CE[0:1]) */
43 s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1)); 41 s3c_gpio_cfgpin(S3C64XX_GPM(5), S3C_GPIO_SFN(1));
44 for (gpio = S3C64XX_GPM(0); gpio <= S3C64XX_GPM(4); gpio++) 42 s3c_gpio_cfgpin_range(S3C64XX_GPM(0), 5, S3C_GPIO_SFN(6));
45 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(6));
46} 43}
diff --git a/arch/arm/mach-s3c64xx/setup-keypad.c b/arch/arm/mach-s3c64xx/setup-keypad.c
index abc34e4e1a93..f8ed0d22db70 100644
--- a/arch/arm/mach-s3c64xx/setup-keypad.c
+++ b/arch/arm/mach-s3c64xx/setup-keypad.c
@@ -12,23 +12,13 @@
12 12
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <plat/gpio-cfg.h> 14#include <plat/gpio-cfg.h>
15#include <plat/keypad.h>
15 16
16void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) 17void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols)
17{ 18{
18 unsigned int gpio;
19 unsigned int end;
20
21 /* Set all the necessary GPK pins to special-function 3: KP_ROW[x] */ 19 /* Set all the necessary GPK pins to special-function 3: KP_ROW[x] */
22 end = S3C64XX_GPK(8 + rows); 20 s3c_gpio_cfgrange_nopull(S3C64XX_GPK(8), 8 + rows, S3C_GPIO_SFN(3));
23 for (gpio = S3C64XX_GPK(8); gpio < end; gpio++) {
24 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
25 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
26 }
27 21
28 /* Set all the necessary GPL pins to special-function 3: KP_COL[x] */ 22 /* Set all the necessary GPL pins to special-function 3: KP_COL[x] */
29 end = S3C64XX_GPL(0 + cols); 23 s3c_gpio_cfgrange_nopull(S3C64XX_GPL(0), cols, S3C_GPIO_SFN(3));
30 for (gpio = S3C64XX_GPL(0); gpio < end; gpio++) {
31 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
32 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
33 }
34} 24}
diff --git a/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c b/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
index 322359591374..6eac071afae2 100644
--- a/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
@@ -24,16 +24,9 @@
24void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) 24void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
25{ 25{
26 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 26 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
27 unsigned int gpio;
28 unsigned int end;
29 27
30 end = S3C64XX_GPG(2 + width); 28 /* Set all the necessary GPG pins to special-function 2 */
31 29 s3c_gpio_cfgrange_nopull(S3C64XX_GPG(0), 2 + width, S3C_GPIO_SFN(2));
32 /* Set all the necessary GPG pins to special-function 0 */
33 for (gpio = S3C64XX_GPG(0); gpio < end; gpio++) {
34 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
35 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
36 }
37 30
38 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 31 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
39 s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP); 32 s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
@@ -44,16 +37,9 @@ void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
44void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) 37void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
45{ 38{
46 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 39 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
47 unsigned int gpio;
48 unsigned int end;
49 40
50 end = S3C64XX_GPH(2 + width); 41 /* Set all the necessary GPH pins to special-function 2 */
51 42 s3c_gpio_cfgrange_nopull(S3C64XX_GPH(0), 2 + width, S3C_GPIO_SFN(2));
52 /* Set all the necessary GPG pins to special-function 0 */
53 for (gpio = S3C64XX_GPH(0); gpio < end; gpio++) {
54 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
55 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
56 }
57 43
58 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 44 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
59 s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP); 45 s3c_gpio_setpull(S3C64XX_GPG(6), S3C_GPIO_PULL_UP);
@@ -63,20 +49,9 @@ void s3c64xx_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
63 49
64void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) 50void s3c64xx_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
65{ 51{
66 unsigned int gpio; 52 /* Set all the necessary GPH pins to special-function 3 */
67 unsigned int end; 53 s3c_gpio_cfgrange_nopull(S3C64XX_GPH(6), width, S3C_GPIO_SFN(3));
68 54
69 end = S3C64XX_GPH(6 + width); 55 /* Set all the necessary GPC pins to special-function 3 */
70 56 s3c_gpio_cfgrange_nopull(S3C64XX_GPC(4), 2, S3C_GPIO_SFN(3));
71 /* Set all the necessary GPH pins to special-function 1 */
72 for (gpio = S3C64XX_GPH(6); gpio < end; gpio++) {
73 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
74 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
75 }
76
77 /* Set all the necessary GPC pins to special-function 1 */
78 for (gpio = S3C64XX_GPC(4); gpio < S3C64XX_GPC(6); gpio++) {
79 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
80 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
81 }
82} 57}
diff --git a/arch/arm/mach-s5p6442/Kconfig b/arch/arm/mach-s5p6442/Kconfig
index 0fda0a5df968..33569e4007c4 100644
--- a/arch/arm/mach-s5p6442/Kconfig
+++ b/arch/arm/mach-s5p6442/Kconfig
@@ -11,7 +11,6 @@ if ARCH_S5P6442
11 11
12config CPU_S5P6442 12config CPU_S5P6442
13 bool 13 bool
14 select PLAT_S5P
15 select S3C_PL330_DMA 14 select S3C_PL330_DMA
16 help 15 help
17 Enable S5P6442 CPU support 16 Enable S5P6442 CPU support
diff --git a/arch/arm/mach-s5p6442/clock.c b/arch/arm/mach-s5p6442/clock.c
index dcd20f17212a..16d6e7e61b50 100644
--- a/arch/arm/mach-s5p6442/clock.c
+++ b/arch/arm/mach-s5p6442/clock.c
@@ -192,6 +192,11 @@ static struct clk clk_pclkd1 = {
192 .parent = &clk_hclkd1, 192 .parent = &clk_hclkd1,
193}; 193};
194 194
195int s5p6442_clk_ip0_ctrl(struct clk *clk, int enable)
196{
197 return s5p_gatectrl(S5P_CLKGATE_IP0, clk, enable);
198}
199
195int s5p6442_clk_ip3_ctrl(struct clk *clk, int enable) 200int s5p6442_clk_ip3_ctrl(struct clk *clk, int enable)
196{ 201{
197 return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable); 202 return s5p_gatectrl(S5P_CLKGATE_IP3, clk, enable);
@@ -335,6 +340,16 @@ void __init_or_cpufreq s5p6442_setup_clocks(void)
335 clk_pclkd1.rate = pclkd1; 340 clk_pclkd1.rate = pclkd1;
336} 341}
337 342
343static struct clk init_clocks_disable[] = {
344 {
345 .name = "pdma",
346 .id = -1,
347 .parent = &clk_pclkd1,
348 .enable = s5p6442_clk_ip0_ctrl,
349 .ctrlbit = (1 << 3),
350 },
351};
352
338static struct clk init_clocks[] = { 353static struct clk init_clocks[] = {
339 { 354 {
340 .name = "systimer", 355 .name = "systimer",
@@ -393,10 +408,23 @@ static struct clk *clks[] __initdata = {
393 408
394void __init s5p6442_register_clocks(void) 409void __init s5p6442_register_clocks(void)
395{ 410{
411 struct clk *clkptr;
412 int i, ret;
413
396 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); 414 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
397 415
398 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs)); 416 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
399 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks)); 417 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
400 418
419 clkptr = init_clocks_disable;
420 for (i = 0; i < ARRAY_SIZE(init_clocks_disable); i++, clkptr++) {
421 ret = s3c24xx_register_clock(clkptr);
422 if (ret < 0) {
423 printk(KERN_ERR "Fail to register clock %s (%d)\n",
424 clkptr->name, ret);
425 } else
426 (clkptr->enable)(clkptr, 0);
427 }
428
401 s3c_pwmclk_init(); 429 s3c_pwmclk_init();
402} 430}
diff --git a/arch/arm/mach-s5p6442/dev-audio.c b/arch/arm/mach-s5p6442/dev-audio.c
index 7a4e34720b7b..3462197ff352 100644
--- a/arch/arm/mach-s5p6442/dev-audio.c
+++ b/arch/arm/mach-s5p6442/dev-audio.c
@@ -21,22 +21,16 @@
21 21
22static int s5p6442_cfg_i2s(struct platform_device *pdev) 22static int s5p6442_cfg_i2s(struct platform_device *pdev)
23{ 23{
24 unsigned int base;
25
24 /* configure GPIO for i2s port */ 26 /* configure GPIO for i2s port */
25 switch (pdev->id) { 27 switch (pdev->id) {
26 case 1: 28 case 1:
27 s3c_gpio_cfgpin(S5P6442_GPC1(0), S3C_GPIO_SFN(2)); 29 base = S5P6442_GPC1(0);
28 s3c_gpio_cfgpin(S5P6442_GPC1(1), S3C_GPIO_SFN(2));
29 s3c_gpio_cfgpin(S5P6442_GPC1(2), S3C_GPIO_SFN(2));
30 s3c_gpio_cfgpin(S5P6442_GPC1(3), S3C_GPIO_SFN(2));
31 s3c_gpio_cfgpin(S5P6442_GPC1(4), S3C_GPIO_SFN(2));
32 break; 30 break;
33 31
34 case -1: 32 case -1:
35 s3c_gpio_cfgpin(S5P6442_GPC0(0), S3C_GPIO_SFN(2)); 33 base = S5P6442_GPC0(0);
36 s3c_gpio_cfgpin(S5P6442_GPC0(1), S3C_GPIO_SFN(2));
37 s3c_gpio_cfgpin(S5P6442_GPC0(2), S3C_GPIO_SFN(2));
38 s3c_gpio_cfgpin(S5P6442_GPC0(3), S3C_GPIO_SFN(2));
39 s3c_gpio_cfgpin(S5P6442_GPC0(4), S3C_GPIO_SFN(2));
40 break; 34 break;
41 35
42 default: 36 default:
@@ -44,6 +38,7 @@ static int s5p6442_cfg_i2s(struct platform_device *pdev)
44 return -EINVAL; 38 return -EINVAL;
45 } 39 }
46 40
41 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(2));
47 return 0; 42 return 0;
48} 43}
49 44
@@ -111,21 +106,15 @@ struct platform_device s5p6442_device_iis1 = {
111 106
112static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev) 107static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
113{ 108{
109 unsigned int base;
110
114 switch (pdev->id) { 111 switch (pdev->id) {
115 case 0: 112 case 0:
116 s3c_gpio_cfgpin(S5P6442_GPC0(0), S3C_GPIO_SFN(3)); 113 base = S5P6442_GPC0(0);
117 s3c_gpio_cfgpin(S5P6442_GPC0(1), S3C_GPIO_SFN(3));
118 s3c_gpio_cfgpin(S5P6442_GPC0(2), S3C_GPIO_SFN(3));
119 s3c_gpio_cfgpin(S5P6442_GPC0(3), S3C_GPIO_SFN(3));
120 s3c_gpio_cfgpin(S5P6442_GPC0(4), S3C_GPIO_SFN(3));
121 break; 114 break;
122 115
123 case 1: 116 case 1:
124 s3c_gpio_cfgpin(S5P6442_GPC1(0), S3C_GPIO_SFN(3)); 117 base = S5P6442_GPC1(0);
125 s3c_gpio_cfgpin(S5P6442_GPC1(1), S3C_GPIO_SFN(3));
126 s3c_gpio_cfgpin(S5P6442_GPC1(2), S3C_GPIO_SFN(3));
127 s3c_gpio_cfgpin(S5P6442_GPC1(3), S3C_GPIO_SFN(3));
128 s3c_gpio_cfgpin(S5P6442_GPC1(4), S3C_GPIO_SFN(3));
129 break; 118 break;
130 119
131 default: 120 default:
@@ -133,6 +122,7 @@ static int s5p6442_pcm_cfg_gpio(struct platform_device *pdev)
133 return -EINVAL; 122 return -EINVAL;
134 } 123 }
135 124
125 s3c_gpio_cfgpin_range(base, 5, S3C_GPIO_SFN(3));
136 return 0; 126 return 0;
137} 127}
138 128
diff --git a/arch/arm/mach-s5p6442/dev-spi.c b/arch/arm/mach-s5p6442/dev-spi.c
index e894651a88bd..cce8c2470709 100644
--- a/arch/arm/mach-s5p6442/dev-spi.c
+++ b/arch/arm/mach-s5p6442/dev-spi.c
@@ -38,11 +38,9 @@ static int s5p6442_spi_cfg_gpio(struct platform_device *pdev)
38 switch (pdev->id) { 38 switch (pdev->id) {
39 case 0: 39 case 0:
40 s3c_gpio_cfgpin(S5P6442_GPB(0), S3C_GPIO_SFN(2)); 40 s3c_gpio_cfgpin(S5P6442_GPB(0), S3C_GPIO_SFN(2));
41 s3c_gpio_cfgpin(S5P6442_GPB(2), S3C_GPIO_SFN(2));
42 s3c_gpio_cfgpin(S5P6442_GPB(3), S3C_GPIO_SFN(2));
43 s3c_gpio_setpull(S5P6442_GPB(0), S3C_GPIO_PULL_UP); 41 s3c_gpio_setpull(S5P6442_GPB(0), S3C_GPIO_PULL_UP);
44 s3c_gpio_setpull(S5P6442_GPB(2), S3C_GPIO_PULL_UP); 42 s3c_gpio_cfgall_range(S5P6442_GPB(2), 2,
45 s3c_gpio_setpull(S5P6442_GPB(3), S3C_GPIO_PULL_UP); 43 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
46 break; 44 break;
47 45
48 default: 46 default:
diff --git a/arch/arm/mach-s5p6442/dma.c b/arch/arm/mach-s5p6442/dma.c
index ad4f8704b93d..7dfb13654f8a 100644
--- a/arch/arm/mach-s5p6442/dma.c
+++ b/arch/arm/mach-s5p6442/dma.c
@@ -82,7 +82,7 @@ static struct s3c_pl330_platdata s5p6442_pdma_pdata = {
82 82
83static struct platform_device s5p6442_device_pdma = { 83static struct platform_device s5p6442_device_pdma = {
84 .name = "s3c-pl330", 84 .name = "s3c-pl330",
85 .id = 1, 85 .id = -1,
86 .num_resources = ARRAY_SIZE(s5p6442_pdma_resource), 86 .num_resources = ARRAY_SIZE(s5p6442_pdma_resource),
87 .resource = s5p6442_pdma_resource, 87 .resource = s5p6442_pdma_resource,
88 .dev = { 88 .dev = {
diff --git a/arch/arm/mach-s5p6442/include/mach/regs-clock.h b/arch/arm/mach-s5p6442/include/mach/regs-clock.h
index d8360b5d4ece..00828a336991 100644
--- a/arch/arm/mach-s5p6442/include/mach/regs-clock.h
+++ b/arch/arm/mach-s5p6442/include/mach/regs-clock.h
@@ -46,6 +46,7 @@
46#define S5P_CLK_DIV5 S5P_CLKREG(0x314) 46#define S5P_CLK_DIV5 S5P_CLKREG(0x314)
47#define S5P_CLK_DIV6 S5P_CLKREG(0x318) 47#define S5P_CLK_DIV6 S5P_CLKREG(0x318)
48 48
49#define S5P_CLKGATE_IP0 S5P_CLKREG(0x460)
49#define S5P_CLKGATE_IP3 S5P_CLKREG(0x46C) 50#define S5P_CLKGATE_IP3 S5P_CLKREG(0x46C)
50 51
51/* CLK_OUT */ 52/* CLK_OUT */
diff --git a/arch/arm/mach-s5p6442/include/mach/vmalloc.h b/arch/arm/mach-s5p6442/include/mach/vmalloc.h
index f5c83f02c18e..4aa55e55ac47 100644
--- a/arch/arm/mach-s5p6442/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5p6442/include/mach/vmalloc.h
@@ -12,6 +12,6 @@
12#ifndef __ASM_ARCH_VMALLOC_H 12#ifndef __ASM_ARCH_VMALLOC_H
13#define __ASM_ARCH_VMALLOC_H 13#define __ASM_ARCH_VMALLOC_H
14 14
15#define VMALLOC_END 0xE0000000UL 15#define VMALLOC_END 0xF6000000UL
16 16
17#endif /* __ASM_ARCH_VMALLOC_H */ 17#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s5p64x0/Kconfig b/arch/arm/mach-s5p64x0/Kconfig
index fbcae9352022..164d2783d381 100644
--- a/arch/arm/mach-s5p64x0/Kconfig
+++ b/arch/arm/mach-s5p64x0/Kconfig
@@ -9,14 +9,12 @@ if ARCH_S5P64X0
9 9
10config CPU_S5P6440 10config CPU_S5P6440
11 bool 11 bool
12 select PLAT_S5P
13 select S3C_PL330_DMA 12 select S3C_PL330_DMA
14 help 13 help
15 Enable S5P6440 CPU support 14 Enable S5P6440 CPU support
16 15
17config CPU_S5P6450 16config CPU_S5P6450
18 bool 17 bool
19 select PLAT_S5P
20 select S3C_PL330_DMA 18 select S3C_PL330_DMA
21 help 19 help
22 Enable S5P6450 CPU support 20 Enable S5P6450 CPU support
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c
index f93dcd8b4d6a..e4883dc1c8d7 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6440.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c
@@ -79,13 +79,16 @@ static int s5p6440_epll_set_rate(struct clk *clk, unsigned long rate)
79 __raw_writel(epll_con, S5P64X0_EPLL_CON); 79 __raw_writel(epll_con, S5P64X0_EPLL_CON);
80 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K); 80 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
81 81
82 printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
83 clk->rate, rate);
84
82 clk->rate = rate; 85 clk->rate = rate;
83 86
84 return 0; 87 return 0;
85} 88}
86 89
87static struct clk_ops s5p6440_epll_ops = { 90static struct clk_ops s5p6440_epll_ops = {
88 .get_rate = s5p64x0_epll_get_rate, 91 .get_rate = s5p_epll_get_rate,
89 .set_rate = s5p6440_epll_set_rate, 92 .set_rate = s5p6440_epll_set_rate,
90}; 93};
91 94
@@ -150,6 +153,12 @@ static struct clk init_clocks_disable[] = {
150 .enable = s5p64x0_hclk0_ctrl, 153 .enable = s5p64x0_hclk0_ctrl,
151 .ctrlbit = (1 << 8), 154 .ctrlbit = (1 << 8),
152 }, { 155 }, {
156 .name = "pdma",
157 .id = -1,
158 .parent = &clk_hclk_low.clk,
159 .enable = s5p64x0_hclk0_ctrl,
160 .ctrlbit = (1 << 12),
161 }, {
153 .name = "hsmmc", 162 .name = "hsmmc",
154 .id = 0, 163 .id = 0,
155 .parent = &clk_hclk_low.clk, 164 .parent = &clk_hclk_low.clk,
@@ -331,12 +340,6 @@ static struct clk init_clocks[] = {
331 .enable = s5p64x0_hclk0_ctrl, 340 .enable = s5p64x0_hclk0_ctrl,
332 .ctrlbit = (1 << 21), 341 .ctrlbit = (1 << 21),
333 }, { 342 }, {
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", 343 .name = "uart",
341 .id = 0, 344 .id = 0,
342 .parent = &clk_pclk_low.clk, 345 .parent = &clk_pclk_low.clk,
@@ -548,7 +551,7 @@ void __init_or_cpufreq s5p6440_setup_clocks(void)
548 551
549 /* Set S5P6440 functions for clk_fout_epll */ 552 /* Set S5P6440 functions for clk_fout_epll */
550 553
551 clk_fout_epll.enable = s5p64x0_epll_enable; 554 clk_fout_epll.enable = s5p_epll_enable;
552 clk_fout_epll.ops = &s5p6440_epll_ops; 555 clk_fout_epll.ops = &s5p6440_epll_ops;
553 556
554 clk_48m.enable = s5p64x0_clk48m_ctrl; 557 clk_48m.enable = s5p64x0_clk48m_ctrl;
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c
index f9afb05b217c..7dbf3c968f53 100644
--- a/arch/arm/mach-s5p64x0/clock-s5p6450.c
+++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c
@@ -80,13 +80,16 @@ static int s5p6450_epll_set_rate(struct clk *clk, unsigned long rate)
80 __raw_writel(epll_con, S5P64X0_EPLL_CON); 80 __raw_writel(epll_con, S5P64X0_EPLL_CON);
81 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K); 81 __raw_writel(epll_con_k, S5P64X0_EPLL_CON_K);
82 82
83 printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
84 clk->rate, rate);
85
83 clk->rate = rate; 86 clk->rate = rate;
84 87
85 return 0; 88 return 0;
86} 89}
87 90
88static struct clk_ops s5p6450_epll_ops = { 91static struct clk_ops s5p6450_epll_ops = {
89 .get_rate = s5p64x0_epll_get_rate, 92 .get_rate = s5p_epll_get_rate,
90 .set_rate = s5p6450_epll_set_rate, 93 .set_rate = s5p6450_epll_set_rate,
91}; 94};
92 95
@@ -186,6 +189,12 @@ static struct clk init_clocks_disable[] = {
186 .enable = s5p64x0_hclk0_ctrl, 189 .enable = s5p64x0_hclk0_ctrl,
187 .ctrlbit = (1 << 3), 190 .ctrlbit = (1 << 3),
188 }, { 191 }, {
192 .name = "pdma",
193 .id = -1,
194 .parent = &clk_hclk_low.clk,
195 .enable = s5p64x0_hclk0_ctrl,
196 .ctrlbit = (1 << 12),
197 }, {
189 .name = "hsmmc", 198 .name = "hsmmc",
190 .id = 0, 199 .id = 0,
191 .parent = &clk_hclk_low.clk, 200 .parent = &clk_hclk_low.clk,
@@ -283,12 +292,6 @@ static struct clk init_clocks[] = {
283 .enable = s5p64x0_hclk0_ctrl, 292 .enable = s5p64x0_hclk0_ctrl,
284 .ctrlbit = (1 << 21), 293 .ctrlbit = (1 << 21),
285 }, { 294 }, {
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", 295 .name = "uart",
293 .id = 0, 296 .id = 0,
294 .parent = &clk_pclk_low.clk, 297 .parent = &clk_pclk_low.clk,
@@ -581,7 +584,7 @@ void __init_or_cpufreq s5p6450_setup_clocks(void)
581 584
582 /* Set S5P6450 functions for clk_fout_epll */ 585 /* Set S5P6450 functions for clk_fout_epll */
583 586
584 clk_fout_epll.enable = s5p64x0_epll_enable; 587 clk_fout_epll.enable = s5p_epll_enable;
585 clk_fout_epll.ops = &s5p6450_epll_ops; 588 clk_fout_epll.ops = &s5p6450_epll_ops;
586 589
587 clk_48m.enable = s5p64x0_clk48m_ctrl; 590 clk_48m.enable = s5p64x0_clk48m_ctrl;
diff --git a/arch/arm/mach-s5p64x0/clock.c b/arch/arm/mach-s5p64x0/clock.c
index 523ba8039ac2..b52c6e2f37a6 100644
--- a/arch/arm/mach-s5p64x0/clock.c
+++ b/arch/arm/mach-s5p64x0/clock.c
@@ -73,24 +73,6 @@ static const u32 clock_table[][3] = {
73 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)}, 73 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)},
74}; 74};
75 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) 76unsigned long s5p64x0_armclk_get_rate(struct clk *clk)
95{ 77{
96 unsigned long rate = clk_get_rate(clk->parent); 78 unsigned long rate = clk_get_rate(clk->parent);
diff --git a/arch/arm/mach-s5p64x0/dev-audio.c b/arch/arm/mach-s5p64x0/dev-audio.c
index fa097bd68ca4..396bacc0a39a 100644
--- a/arch/arm/mach-s5p64x0/dev-audio.c
+++ b/arch/arm/mach-s5p64x0/dev-audio.c
@@ -24,13 +24,8 @@ static int s5p6440_cfg_i2s(struct platform_device *pdev)
24 /* configure GPIO for i2s port */ 24 /* configure GPIO for i2s port */
25 switch (pdev->id) { 25 switch (pdev->id) {
26 case -1: 26 case -1:
27 s3c_gpio_cfgpin(S5P6440_GPR(4), S3C_GPIO_SFN(5)); 27 s3c_gpio_cfgpin_range(S5P6440_GPR(4), 5, S3C_GPIO_SFN(5));
28 s3c_gpio_cfgpin(S5P6440_GPR(5), S3C_GPIO_SFN(5)); 28 s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, 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; 29 break;
35 30
36 default: 31 default:
@@ -47,13 +42,9 @@ static int s5p6450_cfg_i2s(struct platform_device *pdev)
47 switch (pdev->id) { 42 switch (pdev->id) {
48 case -1: 43 case -1:
49 s3c_gpio_cfgpin(S5P6450_GPB(4), S3C_GPIO_SFN(5)); 44 s3c_gpio_cfgpin(S5P6450_GPB(4), S3C_GPIO_SFN(5));
50 s3c_gpio_cfgpin(S5P6450_GPR(4), S3C_GPIO_SFN(5)); 45 s3c_gpio_cfgpin_range(S5P6450_GPR(4), 5, S3C_GPIO_SFN(5));
51 s3c_gpio_cfgpin(S5P6450_GPR(5), S3C_GPIO_SFN(5)); 46 s3c_gpio_cfgpin_range(S5P6450_GPR(13), 2, S3C_GPIO_SFN(5));
52 s3c_gpio_cfgpin(S5P6450_GPR(6), S3C_GPIO_SFN(5)); 47
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; 48 break;
58 49
59 default: 50 default:
@@ -116,11 +107,8 @@ static int s5p6440_pcm_cfg_gpio(struct platform_device *pdev)
116{ 107{
117 switch (pdev->id) { 108 switch (pdev->id) {
118 case 0: 109 case 0:
119 s3c_gpio_cfgpin(S5P6440_GPR(7), S3C_GPIO_SFN(2)); 110 s3c_gpio_cfgpin_range(S5P6440_GPR(6), 3, S3C_GPIO_SFN(2));
120 s3c_gpio_cfgpin(S5P6440_GPR(13), S3C_GPIO_SFN(2)); 111 s3c_gpio_cfgpin_range(S5P6440_GPR(13), 2, 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; 112 break;
125 113
126 default: 114 default:
diff --git a/arch/arm/mach-s5p64x0/dev-spi.c b/arch/arm/mach-s5p64x0/dev-spi.c
index 5b69ec4c8af3..e78ee18c76e3 100644
--- a/arch/arm/mach-s5p64x0/dev-spi.c
+++ b/arch/arm/mach-s5p64x0/dev-spi.c
@@ -39,23 +39,15 @@ static char *s5p64x0_spi_src_clks[] = {
39 */ 39 */
40static int s5p6440_spi_cfg_gpio(struct platform_device *pdev) 40static int s5p6440_spi_cfg_gpio(struct platform_device *pdev)
41{ 41{
42 unsigned int base;
43
42 switch (pdev->id) { 44 switch (pdev->id) {
43 case 0: 45 case 0:
44 s3c_gpio_cfgpin(S5P6440_GPC(0), S3C_GPIO_SFN(2)); 46 base = S5P6440_GPC(0);
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; 47 break;
51 48
52 case 1: 49 case 1:
53 s3c_gpio_cfgpin(S5P6440_GPC(4), S3C_GPIO_SFN(2)); 50 base = S5P6440_GPC(4);
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; 51 break;
60 52
61 default: 53 default:
@@ -63,28 +55,23 @@ static int s5p6440_spi_cfg_gpio(struct platform_device *pdev)
63 return -EINVAL; 55 return -EINVAL;
64 } 56 }
65 57
58 s3c_gpio_cfgall_range(base, 3,
59 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
60
66 return 0; 61 return 0;
67} 62}
68 63
69static int s5p6450_spi_cfg_gpio(struct platform_device *pdev) 64static int s5p6450_spi_cfg_gpio(struct platform_device *pdev)
70{ 65{
66 unsigned int base;
67
71 switch (pdev->id) { 68 switch (pdev->id) {
72 case 0: 69 case 0:
73 s3c_gpio_cfgpin(S5P6450_GPC(0), S3C_GPIO_SFN(2)); 70 base = S5P6450_GPC(0);
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; 71 break;
80 72
81 case 1: 73 case 1:
82 s3c_gpio_cfgpin(S5P6450_GPC(4), S3C_GPIO_SFN(2)); 74 base = S5P6450_GPC(4);
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; 75 break;
89 76
90 default: 77 default:
@@ -92,6 +79,9 @@ static int s5p6450_spi_cfg_gpio(struct platform_device *pdev)
92 return -EINVAL; 79 return -EINVAL;
93 } 80 }
94 81
82 s3c_gpio_cfgall_range(base, 3,
83 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
84
95 return 0; 85 return 0;
96} 86}
97 87
diff --git a/arch/arm/mach-s5p64x0/dma.c b/arch/arm/mach-s5p64x0/dma.c
index 29a8c2410049..d7ad944b3475 100644
--- a/arch/arm/mach-s5p64x0/dma.c
+++ b/arch/arm/mach-s5p64x0/dma.c
@@ -122,7 +122,7 @@ static struct s3c_pl330_platdata s5p6450_pdma_pdata = {
122 122
123static struct platform_device s5p64x0_device_pdma = { 123static struct platform_device s5p64x0_device_pdma = {
124 .name = "s3c-pl330", 124 .name = "s3c-pl330",
125 .id = 0, 125 .id = -1,
126 .num_resources = ARRAY_SIZE(s5p64x0_pdma_resource), 126 .num_resources = ARRAY_SIZE(s5p64x0_pdma_resource),
127 .resource = s5p64x0_pdma_resource, 127 .resource = s5p64x0_pdma_resource,
128 .dev = { 128 .dev = {
diff --git a/arch/arm/mach-s5p64x0/include/mach/regs-clock.h b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
index 58e1bc813804..a133f22fa155 100644
--- a/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
+++ b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h
@@ -60,4 +60,6 @@
60#define ARM_DIV_RATIO_SHIFT 0 60#define ARM_DIV_RATIO_SHIFT 0
61#define ARM_DIV_MASK (0xF << ARM_DIV_RATIO_SHIFT) 61#define ARM_DIV_MASK (0xF << ARM_DIV_RATIO_SHIFT)
62 62
63#define S5P_EPLL_CON S5P64X0_EPLL_CON
64
63#endif /* __ASM_ARCH_REGS_CLOCK_H */ 65#endif /* __ASM_ARCH_REGS_CLOCK_H */
diff --git a/arch/arm/mach-s5p64x0/include/mach/vmalloc.h b/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
index 97a9df38f1cf..38dcc71a03cc 100644
--- a/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5p64x0/include/mach/vmalloc.h
@@ -15,6 +15,6 @@
15#ifndef __ASM_ARCH_VMALLOC_H 15#ifndef __ASM_ARCH_VMALLOC_H
16#define __ASM_ARCH_VMALLOC_H 16#define __ASM_ARCH_VMALLOC_H
17 17
18#define VMALLOC_END 0xE0000000UL 18#define VMALLOC_END 0xF6000000UL
19 19
20#endif /* __ASM_ARCH_VMALLOC_H */ 20#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s5p64x0/setup-i2c0.c b/arch/arm/mach-s5p64x0/setup-i2c0.c
index dc4cc65a5019..46b463917c54 100644
--- a/arch/arm/mach-s5p64x0/setup-i2c0.c
+++ b/arch/arm/mach-s5p64x0/setup-i2c0.c
@@ -25,18 +25,14 @@ struct platform_device; /* don't need the contents */
25 25
26void s5p6440_i2c0_cfg_gpio(struct platform_device *dev) 26void s5p6440_i2c0_cfg_gpio(struct platform_device *dev)
27{ 27{
28 s3c_gpio_cfgpin(S5P6440_GPB(5), S3C_GPIO_SFN(2)); 28 s3c_gpio_cfgall_range(S5P6440_GPB(5), 2,
29 s3c_gpio_setpull(S5P6440_GPB(5), S3C_GPIO_PULL_UP); 29 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
30 s3c_gpio_cfgpin(S5P6440_GPB(6), S3C_GPIO_SFN(2));
31 s3c_gpio_setpull(S5P6440_GPB(6), S3C_GPIO_PULL_UP);
32} 30}
33 31
34void s5p6450_i2c0_cfg_gpio(struct platform_device *dev) 32void s5p6450_i2c0_cfg_gpio(struct platform_device *dev)
35{ 33{
36 s3c_gpio_cfgpin(S5P6450_GPB(5), S3C_GPIO_SFN(2)); 34 s3c_gpio_cfgall_range(S5P6450_GPB(5), 2,
37 s3c_gpio_setpull(S5P6450_GPB(5), S3C_GPIO_PULL_UP); 35 S3C_GPIO_SFN(2), 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} 36}
41 37
42void s3c_i2c0_cfg_gpio(struct platform_device *dev) { } 38void s3c_i2c0_cfg_gpio(struct platform_device *dev) { }
diff --git a/arch/arm/mach-s5p64x0/setup-i2c1.c b/arch/arm/mach-s5p64x0/setup-i2c1.c
index 2edd7912f8e4..6ad3b986021c 100644
--- a/arch/arm/mach-s5p64x0/setup-i2c1.c
+++ b/arch/arm/mach-s5p64x0/setup-i2c1.c
@@ -25,18 +25,14 @@ struct platform_device; /* don't need the contents */
25 25
26void s5p6440_i2c1_cfg_gpio(struct platform_device *dev) 26void s5p6440_i2c1_cfg_gpio(struct platform_device *dev)
27{ 27{
28 s3c_gpio_cfgpin(S5P6440_GPR(9), S3C_GPIO_SFN(6)); 28 s3c_gpio_cfgall_range(S5P6440_GPR(9), 2,
29 s3c_gpio_setpull(S5P6440_GPR(9), S3C_GPIO_PULL_UP); 29 S3C_GPIO_SFN(6), S3C_GPIO_PULL_UP);
30 s3c_gpio_cfgpin(S5P6440_GPR(10), S3C_GPIO_SFN(6));
31 s3c_gpio_setpull(S5P6440_GPR(10), S3C_GPIO_PULL_UP);
32} 30}
33 31
34void s5p6450_i2c1_cfg_gpio(struct platform_device *dev) 32void s5p6450_i2c1_cfg_gpio(struct platform_device *dev)
35{ 33{
36 s3c_gpio_cfgpin(S5P6450_GPR(9), S3C_GPIO_SFN(6)); 34 s3c_gpio_cfgall_range(S5P6450_GPR(9), 2,
37 s3c_gpio_setpull(S5P6450_GPR(9), S3C_GPIO_PULL_UP); 35 S3C_GPIO_SFN(6), 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} 36}
41 37
42void s3c_i2c1_cfg_gpio(struct platform_device *dev) { } 38void s3c_i2c1_cfg_gpio(struct platform_device *dev) { }
diff --git a/arch/arm/mach-s5pc100/Kconfig b/arch/arm/mach-s5pc100/Kconfig
index 77ae4bfb74ba..b8fbf2fcba6f 100644
--- a/arch/arm/mach-s5pc100/Kconfig
+++ b/arch/arm/mach-s5pc100/Kconfig
@@ -9,7 +9,6 @@ if ARCH_S5PC100
9 9
10config CPU_S5PC100 10config CPU_S5PC100
11 bool 11 bool
12 select PLAT_S5P
13 select S5P_EXT_INT 12 select S5P_EXT_INT
14 select S3C_PL330_DMA 13 select S3C_PL330_DMA
15 help 14 help
diff --git a/arch/arm/mach-s5pc100/Makefile b/arch/arm/mach-s5pc100/Makefile
index a021ed1fb4b6..eecab57d2e5d 100644
--- a/arch/arm/mach-s5pc100/Makefile
+++ b/arch/arm/mach-s5pc100/Makefile
@@ -11,7 +11,7 @@ obj- :=
11 11
12# Core support for S5PC100 system 12# Core support for S5PC100 system
13 13
14obj-$(CONFIG_CPU_S5PC100) += cpu.o init.o clock.o gpiolib.o irq-gpio.o 14obj-$(CONFIG_CPU_S5PC100) += cpu.o init.o clock.o gpiolib.o
15obj-$(CONFIG_CPU_S5PC100) += setup-i2c0.o 15obj-$(CONFIG_CPU_S5PC100) += setup-i2c0.o
16obj-$(CONFIG_CPU_S5PC100) += dma.o 16obj-$(CONFIG_CPU_S5PC100) += dma.o
17 17
diff --git a/arch/arm/mach-s5pc100/clock.c b/arch/arm/mach-s5pc100/clock.c
index 084abd13b0a5..2d4a761a5163 100644
--- a/arch/arm/mach-s5pc100/clock.c
+++ b/arch/arm/mach-s5pc100/clock.c
@@ -273,24 +273,6 @@ static struct clksrc_clk clk_div_hdmi = {
273 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 28, .size = 4 }, 273 .reg_div = { .reg = S5P_CLK_DIV3, .shift = 28, .size = 4 },
274}; 274};
275 275
276static int s5pc100_epll_enable(struct clk *clk, int enable)
277{
278 unsigned int ctrlbit = clk->ctrlbit;
279 unsigned int epll_con = __raw_readl(S5P_EPLL_CON) & ~ctrlbit;
280
281 if (enable)
282 __raw_writel(epll_con | ctrlbit, S5P_EPLL_CON);
283 else
284 __raw_writel(epll_con, S5P_EPLL_CON);
285
286 return 0;
287}
288
289static unsigned long s5pc100_epll_get_rate(struct clk *clk)
290{
291 return clk->rate;
292}
293
294static u32 epll_div[][4] = { 276static u32 epll_div[][4] = {
295 { 32750000, 131, 3, 4 }, 277 { 32750000, 131, 3, 4 },
296 { 32768000, 131, 3, 4 }, 278 { 32768000, 131, 3, 4 },
@@ -341,13 +323,16 @@ static int s5pc100_epll_set_rate(struct clk *clk, unsigned long rate)
341 323
342 __raw_writel(epll_con, S5P_EPLL_CON); 324 __raw_writel(epll_con, S5P_EPLL_CON);
343 325
326 printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
327 clk->rate, rate);
328
344 clk->rate = rate; 329 clk->rate = rate;
345 330
346 return 0; 331 return 0;
347} 332}
348 333
349static struct clk_ops s5pc100_epll_ops = { 334static struct clk_ops s5pc100_epll_ops = {
350 .get_rate = s5pc100_epll_get_rate, 335 .get_rate = s5p_epll_get_rate,
351 .set_rate = s5pc100_epll_set_rate, 336 .set_rate = s5pc100_epll_set_rate,
352}; 337};
353 338
@@ -691,55 +676,55 @@ static struct clk init_clocks_disable[] = {
691 }, { 676 }, {
692 .name = "iis", 677 .name = "iis",
693 .id = 0, 678 .id = 0,
694 .parent = &clk_div_d1_bus.clk, 679 .parent = &clk_div_pclkd1.clk,
695 .enable = s5pc100_d1_5_ctrl, 680 .enable = s5pc100_d1_5_ctrl,
696 .ctrlbit = (1 << 0), 681 .ctrlbit = (1 << 0),
697 }, { 682 }, {
698 .name = "iis", 683 .name = "iis",
699 .id = 1, 684 .id = 1,
700 .parent = &clk_div_d1_bus.clk, 685 .parent = &clk_div_pclkd1.clk,
701 .enable = s5pc100_d1_5_ctrl, 686 .enable = s5pc100_d1_5_ctrl,
702 .ctrlbit = (1 << 1), 687 .ctrlbit = (1 << 1),
703 }, { 688 }, {
704 .name = "iis", 689 .name = "iis",
705 .id = 2, 690 .id = 2,
706 .parent = &clk_div_d1_bus.clk, 691 .parent = &clk_div_pclkd1.clk,
707 .enable = s5pc100_d1_5_ctrl, 692 .enable = s5pc100_d1_5_ctrl,
708 .ctrlbit = (1 << 2), 693 .ctrlbit = (1 << 2),
709 }, { 694 }, {
710 .name = "ac97", 695 .name = "ac97",
711 .id = -1, 696 .id = -1,
712 .parent = &clk_div_d1_bus.clk, 697 .parent = &clk_div_pclkd1.clk,
713 .enable = s5pc100_d1_5_ctrl, 698 .enable = s5pc100_d1_5_ctrl,
714 .ctrlbit = (1 << 3), 699 .ctrlbit = (1 << 3),
715 }, { 700 }, {
716 .name = "pcm", 701 .name = "pcm",
717 .id = 0, 702 .id = 0,
718 .parent = &clk_div_d1_bus.clk, 703 .parent = &clk_div_pclkd1.clk,
719 .enable = s5pc100_d1_5_ctrl, 704 .enable = s5pc100_d1_5_ctrl,
720 .ctrlbit = (1 << 4), 705 .ctrlbit = (1 << 4),
721 }, { 706 }, {
722 .name = "pcm", 707 .name = "pcm",
723 .id = 1, 708 .id = 1,
724 .parent = &clk_div_d1_bus.clk, 709 .parent = &clk_div_pclkd1.clk,
725 .enable = s5pc100_d1_5_ctrl, 710 .enable = s5pc100_d1_5_ctrl,
726 .ctrlbit = (1 << 5), 711 .ctrlbit = (1 << 5),
727 }, { 712 }, {
728 .name = "spdif", 713 .name = "spdif",
729 .id = -1, 714 .id = -1,
730 .parent = &clk_div_d1_bus.clk, 715 .parent = &clk_div_pclkd1.clk,
731 .enable = s5pc100_d1_5_ctrl, 716 .enable = s5pc100_d1_5_ctrl,
732 .ctrlbit = (1 << 6), 717 .ctrlbit = (1 << 6),
733 }, { 718 }, {
734 .name = "adc", 719 .name = "adc",
735 .id = -1, 720 .id = -1,
736 .parent = &clk_div_d1_bus.clk, 721 .parent = &clk_div_pclkd1.clk,
737 .enable = s5pc100_d1_5_ctrl, 722 .enable = s5pc100_d1_5_ctrl,
738 .ctrlbit = (1 << 7), 723 .ctrlbit = (1 << 7),
739 }, { 724 }, {
740 .name = "keypad", 725 .name = "keypad",
741 .id = -1, 726 .id = -1,
742 .parent = &clk_div_d1_bus.clk, 727 .parent = &clk_div_pclkd1.clk,
743 .enable = s5pc100_d1_5_ctrl, 728 .enable = s5pc100_d1_5_ctrl,
744 .ctrlbit = (1 << 8), 729 .ctrlbit = (1 << 8),
745 }, { 730 }, {
@@ -848,6 +833,18 @@ struct clksrc_sources clk_src_group3 = {
848 .nr_sources = ARRAY_SIZE(clk_src_group3_list), 833 .nr_sources = ARRAY_SIZE(clk_src_group3_list),
849}; 834};
850 835
836static struct clksrc_clk clk_sclk_audio0 = {
837 .clk = {
838 .name = "sclk_audio",
839 .id = 0,
840 .ctrlbit = (1 << 8),
841 .enable = s5pc100_sclk1_ctrl,
842 },
843 .sources = &clk_src_group3,
844 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 3 },
845 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 12, .size = 4 },
846};
847
851static struct clk *clk_src_group4_list[] = { 848static struct clk *clk_src_group4_list[] = {
852 [0] = &clk_mout_epll.clk, 849 [0] = &clk_mout_epll.clk,
853 [1] = &clk_div_mpll.clk, 850 [1] = &clk_div_mpll.clk,
@@ -862,6 +859,18 @@ struct clksrc_sources clk_src_group4 = {
862 .nr_sources = ARRAY_SIZE(clk_src_group4_list), 859 .nr_sources = ARRAY_SIZE(clk_src_group4_list),
863}; 860};
864 861
862static struct clksrc_clk clk_sclk_audio1 = {
863 .clk = {
864 .name = "sclk_audio",
865 .id = 1,
866 .ctrlbit = (1 << 9),
867 .enable = s5pc100_sclk1_ctrl,
868 },
869 .sources = &clk_src_group4,
870 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 3 },
871 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 16, .size = 4 },
872};
873
865static struct clk *clk_src_group5_list[] = { 874static struct clk *clk_src_group5_list[] = {
866 [0] = &clk_mout_epll.clk, 875 [0] = &clk_mout_epll.clk,
867 [1] = &clk_div_mpll.clk, 876 [1] = &clk_div_mpll.clk,
@@ -875,6 +884,18 @@ struct clksrc_sources clk_src_group5 = {
875 .nr_sources = ARRAY_SIZE(clk_src_group5_list), 884 .nr_sources = ARRAY_SIZE(clk_src_group5_list),
876}; 885};
877 886
887static struct clksrc_clk clk_sclk_audio2 = {
888 .clk = {
889 .name = "sclk_audio",
890 .id = 2,
891 .ctrlbit = (1 << 10),
892 .enable = s5pc100_sclk1_ctrl,
893 },
894 .sources = &clk_src_group5,
895 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 3 },
896 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 20, .size = 4 },
897};
898
878static struct clk *clk_src_group6_list[] = { 899static struct clk *clk_src_group6_list[] = {
879 [0] = &s5p_clk_27m, 900 [0] = &s5p_clk_27m,
880 [1] = &clk_vclk54m, 901 [1] = &clk_vclk54m,
@@ -944,6 +965,64 @@ struct clksrc_sources clk_src_pwi = {
944 .nr_sources = ARRAY_SIZE(clk_src_pwi_list), 965 .nr_sources = ARRAY_SIZE(clk_src_pwi_list),
945}; 966};
946 967
968static struct clk *clk_sclk_spdif_list[] = {
969 [0] = &clk_sclk_audio0.clk,
970 [1] = &clk_sclk_audio1.clk,
971 [2] = &clk_sclk_audio2.clk,
972};
973
974struct clksrc_sources clk_src_sclk_spdif = {
975 .sources = clk_sclk_spdif_list,
976 .nr_sources = ARRAY_SIZE(clk_sclk_spdif_list),
977};
978
979static int s5pc100_spdif_set_rate(struct clk *clk, unsigned long rate)
980{
981 struct clk *pclk;
982 int ret;
983
984 pclk = clk_get_parent(clk);
985 if (IS_ERR(pclk))
986 return -EINVAL;
987
988 ret = pclk->ops->set_rate(pclk, rate);
989 clk_put(pclk);
990
991 return ret;
992}
993
994static unsigned long s5pc100_spdif_get_rate(struct clk *clk)
995{
996 struct clk *pclk;
997 int rate;
998
999 pclk = clk_get_parent(clk);
1000 if (IS_ERR(pclk))
1001 return -EINVAL;
1002
1003 rate = pclk->ops->get_rate(clk);
1004 clk_put(pclk);
1005
1006 return rate;
1007}
1008
1009static struct clk_ops s5pc100_sclk_spdif_ops = {
1010 .set_rate = s5pc100_spdif_set_rate,
1011 .get_rate = s5pc100_spdif_get_rate,
1012};
1013
1014static struct clksrc_clk clk_sclk_spdif = {
1015 .clk = {
1016 .name = "sclk_spdif",
1017 .id = -1,
1018 .ctrlbit = (1 << 11),
1019 .enable = s5pc100_sclk1_ctrl,
1020 .ops = &s5pc100_sclk_spdif_ops,
1021 },
1022 .sources = &clk_src_sclk_spdif,
1023 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 24, .size = 2 },
1024};
1025
947static struct clksrc_clk clksrcs[] = { 1026static struct clksrc_clk clksrcs[] = {
948 { 1027 {
949 .clk = { 1028 .clk = {
@@ -1001,39 +1080,6 @@ static struct clksrc_clk clksrcs[] = {
1001 .reg_src = { .reg = S5P_CLK_SRC2, .shift = 28, .size = 2 }, 1080 .reg_src = { .reg = S5P_CLK_SRC2, .shift = 28, .size = 2 },
1002 }, { 1081 }, {
1003 .clk = { 1082 .clk = {
1004 .name = "sclk_audio",
1005 .id = 0,
1006 .ctrlbit = (1 << 8),
1007 .enable = s5pc100_sclk1_ctrl,
1008
1009 },
1010 .sources = &clk_src_group3,
1011 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 12, .size = 3 },
1012 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 12, .size = 4 },
1013 }, {
1014 .clk = {
1015 .name = "sclk_audio",
1016 .id = 1,
1017 .ctrlbit = (1 << 9),
1018 .enable = s5pc100_sclk1_ctrl,
1019
1020 },
1021 .sources = &clk_src_group4,
1022 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 16, .size = 3 },
1023 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 16, .size = 4 },
1024 }, {
1025 .clk = {
1026 .name = "sclk_audio",
1027 .id = 2,
1028 .ctrlbit = (1 << 10),
1029 .enable = s5pc100_sclk1_ctrl,
1030
1031 },
1032 .sources = &clk_src_group5,
1033 .reg_src = { .reg = S5P_CLK_SRC3, .shift = 20, .size = 3 },
1034 .reg_div = { .reg = S5P_CLK_DIV4, .shift = 20, .size = 4 },
1035 }, {
1036 .clk = {
1037 .name = "sclk_lcd", 1083 .name = "sclk_lcd",
1038 .id = -1, 1084 .id = -1,
1039 .ctrlbit = (1 << 0), 1085 .ctrlbit = (1 << 0),
@@ -1179,6 +1225,10 @@ static struct clksrc_clk *sysclks[] = {
1179 &clk_div_pclkd1, 1225 &clk_div_pclkd1,
1180 &clk_div_cam, 1226 &clk_div_cam,
1181 &clk_div_hdmi, 1227 &clk_div_hdmi,
1228 &clk_sclk_audio0,
1229 &clk_sclk_audio1,
1230 &clk_sclk_audio2,
1231 &clk_sclk_spdif,
1182}; 1232};
1183 1233
1184void __init_or_cpufreq s5pc100_setup_clocks(void) 1234void __init_or_cpufreq s5pc100_setup_clocks(void)
@@ -1196,7 +1246,7 @@ void __init_or_cpufreq s5pc100_setup_clocks(void)
1196 unsigned int ptr; 1246 unsigned int ptr;
1197 1247
1198 /* Set S5PC100 functions for clk_fout_epll */ 1248 /* Set S5PC100 functions for clk_fout_epll */
1199 clk_fout_epll.enable = s5pc100_epll_enable; 1249 clk_fout_epll.enable = s5p_epll_enable;
1200 clk_fout_epll.ops = &s5pc100_epll_ops; 1250 clk_fout_epll.ops = &s5pc100_epll_ops;
1201 1251
1202 printk(KERN_DEBUG "%s: registering clocks\n", __func__); 1252 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
diff --git a/arch/arm/mach-s5pc100/dev-audio.c b/arch/arm/mach-s5pc100/dev-audio.c
index a699ed6acc23..564e195ec493 100644
--- a/arch/arm/mach-s5pc100/dev-audio.c
+++ b/arch/arm/mach-s5pc100/dev-audio.c
@@ -24,19 +24,11 @@ static int s5pc100_cfg_i2s(struct platform_device *pdev)
24 /* configure GPIO for i2s port */ 24 /* configure GPIO for i2s port */
25 switch (pdev->id) { 25 switch (pdev->id) {
26 case 1: 26 case 1:
27 s3c_gpio_cfgpin(S5PC100_GPC(0), S3C_GPIO_SFN(2)); 27 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(2));
28 s3c_gpio_cfgpin(S5PC100_GPC(1), S3C_GPIO_SFN(2));
29 s3c_gpio_cfgpin(S5PC100_GPC(2), S3C_GPIO_SFN(2));
30 s3c_gpio_cfgpin(S5PC100_GPC(3), S3C_GPIO_SFN(2));
31 s3c_gpio_cfgpin(S5PC100_GPC(4), S3C_GPIO_SFN(2));
32 break; 28 break;
33 29
34 case 2: 30 case 2:
35 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(4)); 31 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(4));
36 s3c_gpio_cfgpin(S5PC100_GPG3(1), S3C_GPIO_SFN(4));
37 s3c_gpio_cfgpin(S5PC100_GPG3(2), S3C_GPIO_SFN(4));
38 s3c_gpio_cfgpin(S5PC100_GPG3(3), S3C_GPIO_SFN(4));
39 s3c_gpio_cfgpin(S5PC100_GPG3(4), S3C_GPIO_SFN(4));
40 break; 32 break;
41 33
42 case -1: /* Dedicated pins */ 34 case -1: /* Dedicated pins */
@@ -144,19 +136,11 @@ static int s5pc100_pcm_cfg_gpio(struct platform_device *pdev)
144{ 136{
145 switch (pdev->id) { 137 switch (pdev->id) {
146 case 0: 138 case 0:
147 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(5)); 139 s3c_gpio_cfgpin_range(S5PC100_GPG3(0), 5, S3C_GPIO_SFN(5));
148 s3c_gpio_cfgpin(S5PC100_GPG3(1), S3C_GPIO_SFN(5));
149 s3c_gpio_cfgpin(S5PC100_GPG3(2), S3C_GPIO_SFN(5));
150 s3c_gpio_cfgpin(S5PC100_GPG3(3), S3C_GPIO_SFN(5));
151 s3c_gpio_cfgpin(S5PC100_GPG3(4), S3C_GPIO_SFN(5));
152 break; 140 break;
153 141
154 case 1: 142 case 1:
155 s3c_gpio_cfgpin(S5PC100_GPC(0), S3C_GPIO_SFN(3)); 143 s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(3));
156 s3c_gpio_cfgpin(S5PC100_GPC(1), S3C_GPIO_SFN(3));
157 s3c_gpio_cfgpin(S5PC100_GPC(2), S3C_GPIO_SFN(3));
158 s3c_gpio_cfgpin(S5PC100_GPC(3), S3C_GPIO_SFN(3));
159 s3c_gpio_cfgpin(S5PC100_GPC(4), S3C_GPIO_SFN(3));
160 break; 144 break;
161 145
162 default: 146 default:
@@ -231,13 +215,7 @@ struct platform_device s5pc100_device_pcm1 = {
231 215
232static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev) 216static int s5pc100_ac97_cfg_gpio(struct platform_device *pdev)
233{ 217{
234 s3c_gpio_cfgpin(S5PC100_GPC(0), S3C_GPIO_SFN(4)); 218 return s3c_gpio_cfgpin_range(S5PC100_GPC(0), 5, S3C_GPIO_SFN(4));
235 s3c_gpio_cfgpin(S5PC100_GPC(1), S3C_GPIO_SFN(4));
236 s3c_gpio_cfgpin(S5PC100_GPC(2), S3C_GPIO_SFN(4));
237 s3c_gpio_cfgpin(S5PC100_GPC(3), S3C_GPIO_SFN(4));
238 s3c_gpio_cfgpin(S5PC100_GPC(4), S3C_GPIO_SFN(4));
239
240 return 0;
241} 219}
242 220
243static struct resource s5pc100_ac97_resource[] = { 221static struct resource s5pc100_ac97_resource[] = {
@@ -285,3 +263,57 @@ struct platform_device s5pc100_device_ac97 = {
285 .coherent_dma_mask = DMA_BIT_MASK(32), 263 .coherent_dma_mask = DMA_BIT_MASK(32),
286 }, 264 },
287}; 265};
266
267/* S/PDIF Controller platform_device */
268static int s5pc100_spdif_cfg_gpd(struct platform_device *pdev)
269{
270 s3c_gpio_cfgpin_range(S5PC100_GPD(5), 2, S3C_GPIO_SFN(3));
271
272 return 0;
273}
274
275static int s5pc100_spdif_cfg_gpg3(struct platform_device *pdev)
276{
277 s3c_gpio_cfgpin_range(S5PC100_GPG3(5), 2, S3C_GPIO_SFN(3));
278
279 return 0;
280}
281
282static struct resource s5pc100_spdif_resource[] = {
283 [0] = {
284 .start = S5PC100_PA_SPDIF,
285 .end = S5PC100_PA_SPDIF + 0x100 - 1,
286 .flags = IORESOURCE_MEM,
287 },
288 [1] = {
289 .start = DMACH_SPDIF,
290 .end = DMACH_SPDIF,
291 .flags = IORESOURCE_DMA,
292 },
293};
294
295static struct s3c_audio_pdata s5p_spdif_pdata = {
296 .cfg_gpio = s5pc100_spdif_cfg_gpd,
297};
298
299static u64 s5pc100_spdif_dmamask = DMA_BIT_MASK(32);
300
301struct platform_device s5pc100_device_spdif = {
302 .name = "samsung-spdif",
303 .id = -1,
304 .num_resources = ARRAY_SIZE(s5pc100_spdif_resource),
305 .resource = s5pc100_spdif_resource,
306 .dev = {
307 .platform_data = &s5p_spdif_pdata,
308 .dma_mask = &s5pc100_spdif_dmamask,
309 .coherent_dma_mask = DMA_BIT_MASK(32),
310 },
311};
312
313void __init s5pc100_spdif_setup_gpio(int gpio)
314{
315 if (gpio == S5PC100_SPDIF_GPD)
316 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpd;
317 else
318 s5p_spdif_pdata.cfg_gpio = s5pc100_spdif_cfg_gpg3;
319}
diff --git a/arch/arm/mach-s5pc100/dev-spi.c b/arch/arm/mach-s5pc100/dev-spi.c
index a0ef7c302c16..57b19794d9bb 100644
--- a/arch/arm/mach-s5pc100/dev-spi.c
+++ b/arch/arm/mach-s5pc100/dev-spi.c
@@ -38,30 +38,20 @@ static int s5pc100_spi_cfg_gpio(struct platform_device *pdev)
38{ 38{
39 switch (pdev->id) { 39 switch (pdev->id) {
40 case 0: 40 case 0:
41 s3c_gpio_cfgpin(S5PC100_GPB(0), S3C_GPIO_SFN(2)); 41 s3c_gpio_cfgall_range(S5PC100_GPB(0), 3,
42 s3c_gpio_cfgpin(S5PC100_GPB(1), S3C_GPIO_SFN(2)); 42 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
43 s3c_gpio_cfgpin(S5PC100_GPB(2), S3C_GPIO_SFN(2));
44 s3c_gpio_setpull(S5PC100_GPB(0), S3C_GPIO_PULL_UP);
45 s3c_gpio_setpull(S5PC100_GPB(1), S3C_GPIO_PULL_UP);
46 s3c_gpio_setpull(S5PC100_GPB(2), S3C_GPIO_PULL_UP);
47 break; 43 break;
48 44
49 case 1: 45 case 1:
50 s3c_gpio_cfgpin(S5PC100_GPB(4), S3C_GPIO_SFN(2)); 46 s3c_gpio_cfgall_range(S5PC100_GPB(4), 3,
51 s3c_gpio_cfgpin(S5PC100_GPB(5), S3C_GPIO_SFN(2)); 47 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
52 s3c_gpio_cfgpin(S5PC100_GPB(6), S3C_GPIO_SFN(2));
53 s3c_gpio_setpull(S5PC100_GPB(4), S3C_GPIO_PULL_UP);
54 s3c_gpio_setpull(S5PC100_GPB(5), S3C_GPIO_PULL_UP);
55 s3c_gpio_setpull(S5PC100_GPB(6), S3C_GPIO_PULL_UP);
56 break; 48 break;
57 49
58 case 2: 50 case 2:
59 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(3)); 51 s3c_gpio_cfgpin(S5PC100_GPG3(0), S3C_GPIO_SFN(3));
60 s3c_gpio_cfgpin(S5PC100_GPG3(2), S3C_GPIO_SFN(3));
61 s3c_gpio_cfgpin(S5PC100_GPG3(3), S3C_GPIO_SFN(3));
62 s3c_gpio_setpull(S5PC100_GPG3(0), S3C_GPIO_PULL_UP); 52 s3c_gpio_setpull(S5PC100_GPG3(0), S3C_GPIO_PULL_UP);
63 s3c_gpio_setpull(S5PC100_GPG3(2), S3C_GPIO_PULL_UP); 53 s3c_gpio_cfgall_range(S5PC100_GPB(2), 2,
64 s3c_gpio_setpull(S5PC100_GPG3(3), S3C_GPIO_PULL_UP); 54 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
65 break; 55 break;
66 56
67 default: 57 default:
diff --git a/arch/arm/mach-s5pc100/dma.c b/arch/arm/mach-s5pc100/dma.c
index 0f5517571e2c..bf4cd0fb97c6 100644
--- a/arch/arm/mach-s5pc100/dma.c
+++ b/arch/arm/mach-s5pc100/dma.c
@@ -81,7 +81,7 @@ static struct s3c_pl330_platdata s5pc100_pdma0_pdata = {
81 81
82static struct platform_device s5pc100_device_pdma0 = { 82static struct platform_device s5pc100_device_pdma0 = {
83 .name = "s3c-pl330", 83 .name = "s3c-pl330",
84 .id = 1, 84 .id = 0,
85 .num_resources = ARRAY_SIZE(s5pc100_pdma0_resource), 85 .num_resources = ARRAY_SIZE(s5pc100_pdma0_resource),
86 .resource = s5pc100_pdma0_resource, 86 .resource = s5pc100_pdma0_resource,
87 .dev = { 87 .dev = {
@@ -143,7 +143,7 @@ static struct s3c_pl330_platdata s5pc100_pdma1_pdata = {
143 143
144static struct platform_device s5pc100_device_pdma1 = { 144static struct platform_device s5pc100_device_pdma1 = {
145 .name = "s3c-pl330", 145 .name = "s3c-pl330",
146 .id = 2, 146 .id = 1,
147 .num_resources = ARRAY_SIZE(s5pc100_pdma1_resource), 147 .num_resources = ARRAY_SIZE(s5pc100_pdma1_resource),
148 .resource = s5pc100_pdma1_resource, 148 .resource = s5pc100_pdma1_resource,
149 .dev = { 149 .dev = {
diff --git a/arch/arm/mach-s5pc100/gpiolib.c b/arch/arm/mach-s5pc100/gpiolib.c
index 0fab7f2cd8bf..20856eb7dd51 100644
--- a/arch/arm/mach-s5pc100/gpiolib.c
+++ b/arch/arm/mach-s5pc100/gpiolib.c
@@ -1,5 +1,7 @@
1/* 1/* linux/arch/arm/mach-s5pc100/gpiolib.c
2 * arch/arm/plat-s5pc100/gpiolib.c 2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
3 * 5 *
4 * Copyright 2009 Samsung Electronics Co 6 * Copyright 2009 Samsung Electronics Co
5 * Kyungmin Park <kyungmin.park@samsung.com> 7 * Kyungmin Park <kyungmin.park@samsung.com>
@@ -61,30 +63,6 @@
61 * L3 8 4Bit None 63 * L3 8 4Bit None
62 */ 64 */
63 65
64static int s5pc100_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
65{
66 return S3C_IRQ_GPIO(chip->base + offset);
67}
68
69static int s5pc100_gpiolib_to_eint(struct gpio_chip *chip, unsigned int offset)
70{
71 int base;
72
73 base = chip->base - S5PC100_GPH0(0);
74 if (base == 0)
75 return IRQ_EINT(offset);
76 base = chip->base - S5PC100_GPH1(0);
77 if (base == 0)
78 return IRQ_EINT(8 + offset);
79 base = chip->base - S5PC100_GPH2(0);
80 if (base == 0)
81 return IRQ_EINT(16 + offset);
82 base = chip->base - S5PC100_GPH3(0);
83 if (base == 0)
84 return IRQ_EINT(24 + offset);
85 return -EINVAL;
86}
87
88static struct s3c_gpio_cfg gpio_cfg = { 66static struct s3c_gpio_cfg gpio_cfg = {
89 .set_config = s3c_gpio_setcfg_s3c64xx_4bit, 67 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
90 .set_pull = s3c_gpio_setpull_updown, 68 .set_pull = s3c_gpio_setpull_updown,
@@ -104,209 +82,150 @@ static struct s3c_gpio_cfg gpio_cfg_noint = {
104 .get_pull = s3c_gpio_getpull_updown, 82 .get_pull = s3c_gpio_getpull_updown,
105}; 83};
106 84
85/*
86 * GPIO bank's base address given the index of the bank in the
87 * list of all gpio banks.
88 */
89#define S5PC100_BANK_BASE(bank_nr) (S5P_VA_GPIO + ((bank_nr) * 0x20))
90
91/*
92 * Following are the gpio banks in S5PC100.
93 *
94 * The 'config' member when left to NULL, is initialized to the default
95 * structure gpio_cfg in the init function below.
96 *
97 * The 'base' member is also initialized in the init function below.
98 * Note: The initialization of 'base' member of s3c_gpio_chip structure
99 * uses the above macro and depends on the banks being listed in order here.
100 */
107static struct s3c_gpio_chip s5pc100_gpio_chips[] = { 101static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
108 { 102 {
109 .base = S5PC100_GPA0_BASE,
110 .config = &gpio_cfg,
111 .chip = { 103 .chip = {
112 .base = S5PC100_GPA0(0), 104 .base = S5PC100_GPA0(0),
113 .ngpio = S5PC100_GPIO_A0_NR, 105 .ngpio = S5PC100_GPIO_A0_NR,
114 .label = "GPA0", 106 .label = "GPA0",
115 }, 107 },
116 }, { 108 }, {
117 .base = S5PC100_GPA1_BASE,
118 .config = &gpio_cfg,
119 .chip = { 109 .chip = {
120 .base = S5PC100_GPA1(0), 110 .base = S5PC100_GPA1(0),
121 .ngpio = S5PC100_GPIO_A1_NR, 111 .ngpio = S5PC100_GPIO_A1_NR,
122 .label = "GPA1", 112 .label = "GPA1",
123 }, 113 },
124 }, { 114 }, {
125 .base = S5PC100_GPB_BASE,
126 .config = &gpio_cfg,
127 .chip = { 115 .chip = {
128 .base = S5PC100_GPB(0), 116 .base = S5PC100_GPB(0),
129 .ngpio = S5PC100_GPIO_B_NR, 117 .ngpio = S5PC100_GPIO_B_NR,
130 .label = "GPB", 118 .label = "GPB",
131 }, 119 },
132 }, { 120 }, {
133 .base = S5PC100_GPC_BASE,
134 .config = &gpio_cfg,
135 .chip = { 121 .chip = {
136 .base = S5PC100_GPC(0), 122 .base = S5PC100_GPC(0),
137 .ngpio = S5PC100_GPIO_C_NR, 123 .ngpio = S5PC100_GPIO_C_NR,
138 .label = "GPC", 124 .label = "GPC",
139 }, 125 },
140 }, { 126 }, {
141 .base = S5PC100_GPD_BASE,
142 .config = &gpio_cfg,
143 .chip = { 127 .chip = {
144 .base = S5PC100_GPD(0), 128 .base = S5PC100_GPD(0),
145 .ngpio = S5PC100_GPIO_D_NR, 129 .ngpio = S5PC100_GPIO_D_NR,
146 .label = "GPD", 130 .label = "GPD",
147 }, 131 },
148 }, { 132 }, {
149 .base = S5PC100_GPE0_BASE,
150 .config = &gpio_cfg,
151 .chip = { 133 .chip = {
152 .base = S5PC100_GPE0(0), 134 .base = S5PC100_GPE0(0),
153 .ngpio = S5PC100_GPIO_E0_NR, 135 .ngpio = S5PC100_GPIO_E0_NR,
154 .label = "GPE0", 136 .label = "GPE0",
155 }, 137 },
156 }, { 138 }, {
157 .base = S5PC100_GPE1_BASE,
158 .config = &gpio_cfg,
159 .chip = { 139 .chip = {
160 .base = S5PC100_GPE1(0), 140 .base = S5PC100_GPE1(0),
161 .ngpio = S5PC100_GPIO_E1_NR, 141 .ngpio = S5PC100_GPIO_E1_NR,
162 .label = "GPE1", 142 .label = "GPE1",
163 }, 143 },
164 }, { 144 }, {
165 .base = S5PC100_GPF0_BASE,
166 .config = &gpio_cfg,
167 .chip = { 145 .chip = {
168 .base = S5PC100_GPF0(0), 146 .base = S5PC100_GPF0(0),
169 .ngpio = S5PC100_GPIO_F0_NR, 147 .ngpio = S5PC100_GPIO_F0_NR,
170 .label = "GPF0", 148 .label = "GPF0",
171 }, 149 },
172 }, { 150 }, {
173 .base = S5PC100_GPF1_BASE,
174 .config = &gpio_cfg,
175 .chip = { 151 .chip = {
176 .base = S5PC100_GPF1(0), 152 .base = S5PC100_GPF1(0),
177 .ngpio = S5PC100_GPIO_F1_NR, 153 .ngpio = S5PC100_GPIO_F1_NR,
178 .label = "GPF1", 154 .label = "GPF1",
179 }, 155 },
180 }, { 156 }, {
181 .base = S5PC100_GPF2_BASE,
182 .config = &gpio_cfg,
183 .chip = { 157 .chip = {
184 .base = S5PC100_GPF2(0), 158 .base = S5PC100_GPF2(0),
185 .ngpio = S5PC100_GPIO_F2_NR, 159 .ngpio = S5PC100_GPIO_F2_NR,
186 .label = "GPF2", 160 .label = "GPF2",
187 }, 161 },
188 }, { 162 }, {
189 .base = S5PC100_GPF3_BASE,
190 .config = &gpio_cfg,
191 .chip = { 163 .chip = {
192 .base = S5PC100_GPF3(0), 164 .base = S5PC100_GPF3(0),
193 .ngpio = S5PC100_GPIO_F3_NR, 165 .ngpio = S5PC100_GPIO_F3_NR,
194 .label = "GPF3", 166 .label = "GPF3",
195 }, 167 },
196 }, { 168 }, {
197 .base = S5PC100_GPG0_BASE,
198 .config = &gpio_cfg,
199 .chip = { 169 .chip = {
200 .base = S5PC100_GPG0(0), 170 .base = S5PC100_GPG0(0),
201 .ngpio = S5PC100_GPIO_G0_NR, 171 .ngpio = S5PC100_GPIO_G0_NR,
202 .label = "GPG0", 172 .label = "GPG0",
203 }, 173 },
204 }, { 174 }, {
205 .base = S5PC100_GPG1_BASE,
206 .config = &gpio_cfg,
207 .chip = { 175 .chip = {
208 .base = S5PC100_GPG1(0), 176 .base = S5PC100_GPG1(0),
209 .ngpio = S5PC100_GPIO_G1_NR, 177 .ngpio = S5PC100_GPIO_G1_NR,
210 .label = "GPG1", 178 .label = "GPG1",
211 }, 179 },
212 }, { 180 }, {
213 .base = S5PC100_GPG2_BASE,
214 .config = &gpio_cfg,
215 .chip = { 181 .chip = {
216 .base = S5PC100_GPG2(0), 182 .base = S5PC100_GPG2(0),
217 .ngpio = S5PC100_GPIO_G2_NR, 183 .ngpio = S5PC100_GPIO_G2_NR,
218 .label = "GPG2", 184 .label = "GPG2",
219 }, 185 },
220 }, { 186 }, {
221 .base = S5PC100_GPG3_BASE,
222 .config = &gpio_cfg,
223 .chip = { 187 .chip = {
224 .base = S5PC100_GPG3(0), 188 .base = S5PC100_GPG3(0),
225 .ngpio = S5PC100_GPIO_G3_NR, 189 .ngpio = S5PC100_GPIO_G3_NR,
226 .label = "GPG3", 190 .label = "GPG3",
227 }, 191 },
228 }, { 192 }, {
229 .base = S5PC100_GPH0_BASE,
230 .config = &gpio_cfg_eint,
231 .chip = {
232 .base = S5PC100_GPH0(0),
233 .ngpio = S5PC100_GPIO_H0_NR,
234 .label = "GPH0",
235 },
236 }, {
237 .base = S5PC100_GPH1_BASE,
238 .config = &gpio_cfg_eint,
239 .chip = {
240 .base = S5PC100_GPH1(0),
241 .ngpio = S5PC100_GPIO_H1_NR,
242 .label = "GPH1",
243 },
244 }, {
245 .base = S5PC100_GPH2_BASE,
246 .config = &gpio_cfg_eint,
247 .chip = {
248 .base = S5PC100_GPH2(0),
249 .ngpio = S5PC100_GPIO_H2_NR,
250 .label = "GPH2",
251 },
252 }, {
253 .base = S5PC100_GPH3_BASE,
254 .config = &gpio_cfg_eint,
255 .chip = {
256 .base = S5PC100_GPH3(0),
257 .ngpio = S5PC100_GPIO_H3_NR,
258 .label = "GPH3",
259 },
260 }, {
261 .base = S5PC100_GPI_BASE,
262 .config = &gpio_cfg,
263 .chip = { 193 .chip = {
264 .base = S5PC100_GPI(0), 194 .base = S5PC100_GPI(0),
265 .ngpio = S5PC100_GPIO_I_NR, 195 .ngpio = S5PC100_GPIO_I_NR,
266 .label = "GPI", 196 .label = "GPI",
267 }, 197 },
268 }, { 198 }, {
269 .base = S5PC100_GPJ0_BASE,
270 .config = &gpio_cfg,
271 .chip = { 199 .chip = {
272 .base = S5PC100_GPJ0(0), 200 .base = S5PC100_GPJ0(0),
273 .ngpio = S5PC100_GPIO_J0_NR, 201 .ngpio = S5PC100_GPIO_J0_NR,
274 .label = "GPJ0", 202 .label = "GPJ0",
275 }, 203 },
276 }, { 204 }, {
277 .base = S5PC100_GPJ1_BASE,
278 .config = &gpio_cfg,
279 .chip = { 205 .chip = {
280 .base = S5PC100_GPJ1(0), 206 .base = S5PC100_GPJ1(0),
281 .ngpio = S5PC100_GPIO_J1_NR, 207 .ngpio = S5PC100_GPIO_J1_NR,
282 .label = "GPJ1", 208 .label = "GPJ1",
283 }, 209 },
284 }, { 210 }, {
285 .base = S5PC100_GPJ2_BASE,
286 .config = &gpio_cfg,
287 .chip = { 211 .chip = {
288 .base = S5PC100_GPJ2(0), 212 .base = S5PC100_GPJ2(0),
289 .ngpio = S5PC100_GPIO_J2_NR, 213 .ngpio = S5PC100_GPIO_J2_NR,
290 .label = "GPJ2", 214 .label = "GPJ2",
291 }, 215 },
292 }, { 216 }, {
293 .base = S5PC100_GPJ3_BASE,
294 .config = &gpio_cfg,
295 .chip = { 217 .chip = {
296 .base = S5PC100_GPJ3(0), 218 .base = S5PC100_GPJ3(0),
297 .ngpio = S5PC100_GPIO_J3_NR, 219 .ngpio = S5PC100_GPIO_J3_NR,
298 .label = "GPJ3", 220 .label = "GPJ3",
299 }, 221 },
300 }, { 222 }, {
301 .base = S5PC100_GPJ4_BASE,
302 .config = &gpio_cfg,
303 .chip = { 223 .chip = {
304 .base = S5PC100_GPJ4(0), 224 .base = S5PC100_GPJ4(0),
305 .ngpio = S5PC100_GPIO_J4_NR, 225 .ngpio = S5PC100_GPIO_J4_NR,
306 .label = "GPJ4", 226 .label = "GPJ4",
307 }, 227 },
308 }, { 228 }, {
309 .base = S5PC100_GPK0_BASE,
310 .config = &gpio_cfg_noint, 229 .config = &gpio_cfg_noint,
311 .chip = { 230 .chip = {
312 .base = S5PC100_GPK0(0), 231 .base = S5PC100_GPK0(0),
@@ -314,7 +233,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
314 .label = "GPK0", 233 .label = "GPK0",
315 }, 234 },
316 }, { 235 }, {
317 .base = S5PC100_GPK1_BASE,
318 .config = &gpio_cfg_noint, 236 .config = &gpio_cfg_noint,
319 .chip = { 237 .chip = {
320 .base = S5PC100_GPK1(0), 238 .base = S5PC100_GPK1(0),
@@ -322,7 +240,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
322 .label = "GPK1", 240 .label = "GPK1",
323 }, 241 },
324 }, { 242 }, {
325 .base = S5PC100_GPK2_BASE,
326 .config = &gpio_cfg_noint, 243 .config = &gpio_cfg_noint,
327 .chip = { 244 .chip = {
328 .base = S5PC100_GPK2(0), 245 .base = S5PC100_GPK2(0),
@@ -330,7 +247,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
330 .label = "GPK2", 247 .label = "GPK2",
331 }, 248 },
332 }, { 249 }, {
333 .base = S5PC100_GPK3_BASE,
334 .config = &gpio_cfg_noint, 250 .config = &gpio_cfg_noint,
335 .chip = { 251 .chip = {
336 .base = S5PC100_GPK3(0), 252 .base = S5PC100_GPK3(0),
@@ -338,7 +254,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
338 .label = "GPK3", 254 .label = "GPK3",
339 }, 255 },
340 }, { 256 }, {
341 .base = S5PC100_GPL0_BASE,
342 .config = &gpio_cfg_noint, 257 .config = &gpio_cfg_noint,
343 .chip = { 258 .chip = {
344 .base = S5PC100_GPL0(0), 259 .base = S5PC100_GPL0(0),
@@ -346,7 +261,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
346 .label = "GPL0", 261 .label = "GPL0",
347 }, 262 },
348 }, { 263 }, {
349 .base = S5PC100_GPL1_BASE,
350 .config = &gpio_cfg_noint, 264 .config = &gpio_cfg_noint,
351 .chip = { 265 .chip = {
352 .base = S5PC100_GPL1(0), 266 .base = S5PC100_GPL1(0),
@@ -354,7 +268,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
354 .label = "GPL1", 268 .label = "GPL1",
355 }, 269 },
356 }, { 270 }, {
357 .base = S5PC100_GPL2_BASE,
358 .config = &gpio_cfg_noint, 271 .config = &gpio_cfg_noint,
359 .chip = { 272 .chip = {
360 .base = S5PC100_GPL2(0), 273 .base = S5PC100_GPL2(0),
@@ -362,7 +275,6 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
362 .label = "GPL2", 275 .label = "GPL2",
363 }, 276 },
364 }, { 277 }, {
365 .base = S5PC100_GPL3_BASE,
366 .config = &gpio_cfg_noint, 278 .config = &gpio_cfg_noint,
367 .chip = { 279 .chip = {
368 .base = S5PC100_GPL3(0), 280 .base = S5PC100_GPL3(0),
@@ -370,56 +282,72 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
370 .label = "GPL3", 282 .label = "GPL3",
371 }, 283 },
372 }, { 284 }, {
373 .base = S5PC100_GPL4_BASE,
374 .config = &gpio_cfg_noint, 285 .config = &gpio_cfg_noint,
375 .chip = { 286 .chip = {
376 .base = S5PC100_GPL4(0), 287 .base = S5PC100_GPL4(0),
377 .ngpio = S5PC100_GPIO_L4_NR, 288 .ngpio = S5PC100_GPIO_L4_NR,
378 .label = "GPL4", 289 .label = "GPL4",
379 }, 290 },
291 }, {
292 .base = (S5P_VA_GPIO + 0xC00),
293 .config = &gpio_cfg_eint,
294 .irq_base = IRQ_EINT(0),
295 .chip = {
296 .base = S5PC100_GPH0(0),
297 .ngpio = S5PC100_GPIO_H0_NR,
298 .label = "GPH0",
299 .to_irq = samsung_gpiolib_to_irq,
300 },
301 }, {
302 .base = (S5P_VA_GPIO + 0xC20),
303 .config = &gpio_cfg_eint,
304 .irq_base = IRQ_EINT(8),
305 .chip = {
306 .base = S5PC100_GPH1(0),
307 .ngpio = S5PC100_GPIO_H1_NR,
308 .label = "GPH1",
309 .to_irq = samsung_gpiolib_to_irq,
310 },
311 }, {
312 .base = (S5P_VA_GPIO + 0xC40),
313 .config = &gpio_cfg_eint,
314 .irq_base = IRQ_EINT(16),
315 .chip = {
316 .base = S5PC100_GPH2(0),
317 .ngpio = S5PC100_GPIO_H2_NR,
318 .label = "GPH2",
319 .to_irq = samsung_gpiolib_to_irq,
320 },
321 }, {
322 .base = (S5P_VA_GPIO + 0xC60),
323 .config = &gpio_cfg_eint,
324 .irq_base = IRQ_EINT(24),
325 .chip = {
326 .base = S5PC100_GPH3(0),
327 .ngpio = S5PC100_GPIO_H3_NR,
328 .label = "GPH3",
329 .to_irq = samsung_gpiolib_to_irq,
330 },
380 }, 331 },
381}; 332};
382 333
383/* FIXME move from irq-gpio.c */ 334static __init int s5pc100_gpiolib_init(void)
384extern struct irq_chip s5pc100_gpioint;
385extern void s5pc100_irq_gpioint_handler(unsigned int irq, struct irq_desc *desc);
386
387static __init void s5pc100_gpiolib_link(struct s3c_gpio_chip *chip)
388{ 335{
389 /* Interrupt */ 336 struct s3c_gpio_chip *chip = s5pc100_gpio_chips;
390 if (chip->config == &gpio_cfg) { 337 int nr_chips = ARRAY_SIZE(s5pc100_gpio_chips);
391 int i, irq; 338 int gpioint_group = 0;
392 339 int i;
393 chip->chip.to_irq = s5pc100_gpiolib_to_irq;
394 340
395 for (i = 0; i < chip->chip.ngpio; i++) { 341 for (i = 0; i < nr_chips; i++, chip++) {
396 irq = S3C_IRQ_GPIO_BASE + chip->chip.base + i; 342 if (chip->config == NULL) {
397 set_irq_chip(irq, &s5pc100_gpioint); 343 chip->config = &gpio_cfg;
398 set_irq_data(irq, &chip->chip); 344 chip->group = gpioint_group++;
399 set_irq_handler(irq, handle_level_irq);
400 set_irq_flags(irq, IRQF_VALID);
401 } 345 }
402 } else if (chip->config == &gpio_cfg_eint) { 346 if (chip->base == NULL)
403 chip->chip.to_irq = s5pc100_gpiolib_to_eint; 347 chip->base = S5PC100_BANK_BASE(i);
404 } 348 }
405}
406
407static __init int s5pc100_gpiolib_init(void)
408{
409 struct s3c_gpio_chip *chip;
410 int nr_chips;
411
412 chip = s5pc100_gpio_chips;
413 nr_chips = ARRAY_SIZE(s5pc100_gpio_chips);
414
415 for (; nr_chips > 0; nr_chips--, chip++)
416 s5pc100_gpiolib_link(chip);
417
418 samsung_gpiolib_add_4bit_chips(s5pc100_gpio_chips,
419 ARRAY_SIZE(s5pc100_gpio_chips));
420 349
421 /* Interrupt */ 350 samsung_gpiolib_add_4bit_chips(s5pc100_gpio_chips, nr_chips);
422 set_irq_chained_handler(IRQ_GPIOINT, s5pc100_irq_gpioint_handler);
423 351
424 return 0; 352 return 0;
425} 353}
diff --git a/arch/arm/mach-s5pc100/include/mach/gpio.h b/arch/arm/mach-s5pc100/include/mach/gpio.h
index 71ae1f52df1d..29a8a12d9b4f 100644
--- a/arch/arm/mach-s5pc100/include/mach/gpio.h
+++ b/arch/arm/mach-s5pc100/include/mach/gpio.h
@@ -146,13 +146,6 @@ enum s5p_gpio_number {
146/* define the number of gpios we need to the one after the MP04() range */ 146/* define the number of gpios we need to the one after the MP04() range */
147#define ARCH_NR_GPIOS (S5PC100_GPIO_END + 1) 147#define ARCH_NR_GPIOS (S5PC100_GPIO_END + 1)
148 148
149#define EINT_MODE S3C_GPIO_SFN(0x2)
150
151#define EINT_GPIO_0(x) S5PC100_GPH0(x)
152#define EINT_GPIO_1(x) S5PC100_GPH1(x)
153#define EINT_GPIO_2(x) S5PC100_GPH2(x)
154#define EINT_GPIO_3(x) S5PC100_GPH3(x)
155
156#include <asm-generic/gpio.h> 149#include <asm-generic/gpio.h>
157 150
158#endif /* __ASM_ARCH_GPIO_H */ 151#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-s5pc100/include/mach/irqs.h b/arch/arm/mach-s5pc100/include/mach/irqs.h
index 06513e647242..d2eb4757381f 100644
--- a/arch/arm/mach-s5pc100/include/mach/irqs.h
+++ b/arch/arm/mach-s5pc100/include/mach/irqs.h
@@ -48,8 +48,8 @@
48#define IRQ_SPI1 S5P_IRQ_VIC1(16) 48#define IRQ_SPI1 S5P_IRQ_VIC1(16)
49#define IRQ_SPI2 S5P_IRQ_VIC1(17) 49#define IRQ_SPI2 S5P_IRQ_VIC1(17)
50#define IRQ_IRDA S5P_IRQ_VIC1(18) 50#define IRQ_IRDA S5P_IRQ_VIC1(18)
51#define IRQ_CAN0 S5P_IRQ_VIC1(19) 51#define IRQ_IIC2 S5P_IRQ_VIC1(19)
52#define IRQ_CAN1 S5P_IRQ_VIC1(20) 52#define IRQ_IIC3 S5P_IRQ_VIC1(20)
53#define IRQ_HSIRX S5P_IRQ_VIC1(21) 53#define IRQ_HSIRX S5P_IRQ_VIC1(21)
54#define IRQ_HSITX S5P_IRQ_VIC1(22) 54#define IRQ_HSITX S5P_IRQ_VIC1(22)
55#define IRQ_UHOST S5P_IRQ_VIC1(23) 55#define IRQ_UHOST S5P_IRQ_VIC1(23)
@@ -100,11 +100,12 @@
100#define S5P_EINT_BASE1 (S5P_IRQ_VIC0(0)) 100#define S5P_EINT_BASE1 (S5P_IRQ_VIC0(0))
101#define S5P_EINT_BASE2 (IRQ_VIC_END + 1) 101#define S5P_EINT_BASE2 (IRQ_VIC_END + 1)
102 102
103#define S3C_IRQ_GPIO_BASE (IRQ_EINT(31) + 1) 103/* GPIO interrupt */
104#define S3C_IRQ_GPIO(x) (S3C_IRQ_GPIO_BASE + (x)) 104#define S5P_GPIOINT_BASE (IRQ_EINT(31) + 1)
105#define S5P_GPIOINT_GROUP_MAXNR 21
105 106
106/* Until MP04 Groups -> 40 (exactly 39) Groups * 8 ~= 320 GPIOs */ 107/* Set the default NR_IRQS */
107#define NR_IRQS (S3C_IRQ_GPIO(320) + 1) 108#define NR_IRQS (IRQ_EINT(31) + S5P_GPIOINT_COUNT + 1)
108 109
109/* Compatibility */ 110/* Compatibility */
110#define IRQ_LCD_FIFO IRQ_LCD0 111#define IRQ_LCD_FIFO IRQ_LCD0
diff --git a/arch/arm/mach-s5pc100/include/mach/map.h b/arch/arm/mach-s5pc100/include/mach/map.h
index 8751ef4a6804..32e9cab5c864 100644
--- a/arch/arm/mach-s5pc100/include/mach/map.h
+++ b/arch/arm/mach-s5pc100/include/mach/map.h
@@ -110,6 +110,8 @@
110#define S5PC100_PA_PCM0 0xF2400000 110#define S5PC100_PA_PCM0 0xF2400000
111#define S5PC100_PA_PCM1 0xF2500000 111#define S5PC100_PA_PCM1 0xF2500000
112 112
113#define S5PC100_PA_SPDIF 0xF2600000
114
113#define S5PC100_PA_TSADC (0xF3000000) 115#define S5PC100_PA_TSADC (0xF3000000)
114 116
115/* KEYPAD */ 117/* KEYPAD */
diff --git a/arch/arm/mach-s5pc100/include/mach/regs-gpio.h b/arch/arm/mach-s5pc100/include/mach/regs-gpio.h
index dd6295e1251d..0bf73209ec7b 100644
--- a/arch/arm/mach-s5pc100/include/mach/regs-gpio.h
+++ b/arch/arm/mach-s5pc100/include/mach/regs-gpio.h
@@ -11,43 +11,6 @@
11 11
12#include <mach/map.h> 12#include <mach/map.h>
13 13
14/* S5PC100 */
15#define S5PC100_GPIO_BASE S5P_VA_GPIO
16#define S5PC100_GPA0_BASE (S5PC100_GPIO_BASE + 0x0000)
17#define S5PC100_GPA1_BASE (S5PC100_GPIO_BASE + 0x0020)
18#define S5PC100_GPB_BASE (S5PC100_GPIO_BASE + 0x0040)
19#define S5PC100_GPC_BASE (S5PC100_GPIO_BASE + 0x0060)
20#define S5PC100_GPD_BASE (S5PC100_GPIO_BASE + 0x0080)
21#define S5PC100_GPE0_BASE (S5PC100_GPIO_BASE + 0x00A0)
22#define S5PC100_GPE1_BASE (S5PC100_GPIO_BASE + 0x00C0)
23#define S5PC100_GPF0_BASE (S5PC100_GPIO_BASE + 0x00E0)
24#define S5PC100_GPF1_BASE (S5PC100_GPIO_BASE + 0x0100)
25#define S5PC100_GPF2_BASE (S5PC100_GPIO_BASE + 0x0120)
26#define S5PC100_GPF3_BASE (S5PC100_GPIO_BASE + 0x0140)
27#define S5PC100_GPG0_BASE (S5PC100_GPIO_BASE + 0x0160)
28#define S5PC100_GPG1_BASE (S5PC100_GPIO_BASE + 0x0180)
29#define S5PC100_GPG2_BASE (S5PC100_GPIO_BASE + 0x01A0)
30#define S5PC100_GPG3_BASE (S5PC100_GPIO_BASE + 0x01C0)
31#define S5PC100_GPH0_BASE (S5PC100_GPIO_BASE + 0x0C00)
32#define S5PC100_GPH1_BASE (S5PC100_GPIO_BASE + 0x0C20)
33#define S5PC100_GPH2_BASE (S5PC100_GPIO_BASE + 0x0C40)
34#define S5PC100_GPH3_BASE (S5PC100_GPIO_BASE + 0x0C60)
35#define S5PC100_GPI_BASE (S5PC100_GPIO_BASE + 0x01E0)
36#define S5PC100_GPJ0_BASE (S5PC100_GPIO_BASE + 0x0200)
37#define S5PC100_GPJ1_BASE (S5PC100_GPIO_BASE + 0x0220)
38#define S5PC100_GPJ2_BASE (S5PC100_GPIO_BASE + 0x0240)
39#define S5PC100_GPJ3_BASE (S5PC100_GPIO_BASE + 0x0260)
40#define S5PC100_GPJ4_BASE (S5PC100_GPIO_BASE + 0x0280)
41#define S5PC100_GPK0_BASE (S5PC100_GPIO_BASE + 0x02A0)
42#define S5PC100_GPK1_BASE (S5PC100_GPIO_BASE + 0x02C0)
43#define S5PC100_GPK2_BASE (S5PC100_GPIO_BASE + 0x02E0)
44#define S5PC100_GPK3_BASE (S5PC100_GPIO_BASE + 0x0300)
45#define S5PC100_GPL0_BASE (S5PC100_GPIO_BASE + 0x0320)
46#define S5PC100_GPL1_BASE (S5PC100_GPIO_BASE + 0x0340)
47#define S5PC100_GPL2_BASE (S5PC100_GPIO_BASE + 0x0360)
48#define S5PC100_GPL3_BASE (S5PC100_GPIO_BASE + 0x0380)
49#define S5PC100_GPL4_BASE (S5PC100_GPIO_BASE + 0x03A0)
50
51#define S5PC100EINT30CON (S5P_VA_GPIO + 0xE00) 14#define S5PC100EINT30CON (S5P_VA_GPIO + 0xE00)
52#define S5P_EINT_CON(x) (S5PC100EINT30CON + ((x) * 0x4)) 15#define S5P_EINT_CON(x) (S5PC100EINT30CON + ((x) * 0x4))
53 16
@@ -64,12 +27,12 @@
64 27
65#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7)) 28#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7))
66 29
67/* values for S5P_EXTINT0 */ 30#define EINT_MODE S3C_GPIO_SFN(0x2)
68#define S5P_EXTINT_LOWLEV (0x00) 31
69#define S5P_EXTINT_HILEV (0x01) 32#define EINT_GPIO_0(x) S5PC100_GPH0(x)
70#define S5P_EXTINT_FALLEDGE (0x02) 33#define EINT_GPIO_1(x) S5PC100_GPH1(x)
71#define S5P_EXTINT_RISEEDGE (0x03) 34#define EINT_GPIO_2(x) S5PC100_GPH2(x)
72#define S5P_EXTINT_BOTHEDGE (0x04) 35#define EINT_GPIO_3(x) S5PC100_GPH3(x)
73 36
74#endif /* __ASM_MACH_S5PC100_REGS_GPIO_H */ 37#endif /* __ASM_MACH_S5PC100_REGS_GPIO_H */
75 38
diff --git a/arch/arm/mach-s5pc100/include/mach/vmalloc.h b/arch/arm/mach-s5pc100/include/mach/vmalloc.h
index be9df79903ed..44c8e5726d9d 100644
--- a/arch/arm/mach-s5pc100/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5pc100/include/mach/vmalloc.h
@@ -12,6 +12,6 @@
12#ifndef __ASM_ARCH_VMALLOC_H 12#ifndef __ASM_ARCH_VMALLOC_H
13#define __ASM_ARCH_VMALLOC_H 13#define __ASM_ARCH_VMALLOC_H
14 14
15#define VMALLOC_END (0xe0000000UL) 15#define VMALLOC_END 0xF6000000UL
16 16
17#endif /* __ASM_ARCH_VMALLOC_H */ 17#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s5pc100/irq-gpio.c b/arch/arm/mach-s5pc100/irq-gpio.c
deleted file mode 100644
index 2bf86c18bc73..000000000000
--- a/arch/arm/mach-s5pc100/irq-gpio.c
+++ /dev/null
@@ -1,266 +0,0 @@
1/*
2 * arch/arm/mach-s5pc100/irq-gpio.c
3 *
4 * Copyright (C) 2009 Samsung Electronics
5 *
6 * S5PC100 - Interrupt handling for IRQ_GPIO${group}(x)
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/interrupt.h>
15#include <linux/irq.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18
19#include <mach/map.h>
20#include <plat/gpio-cfg.h>
21
22#define S5P_GPIOREG(x) (S5P_VA_GPIO + (x))
23
24#define CON_OFFSET 0x700
25#define MASK_OFFSET 0x900
26#define PEND_OFFSET 0xA00
27#define CON_OFFSET_2 0xE00
28#define MASK_OFFSET_2 0xF00
29#define PEND_OFFSET_2 0xF40
30
31#define GPIOINT_LEVEL_LOW 0x0
32#define GPIOINT_LEVEL_HIGH 0x1
33#define GPIOINT_EDGE_FALLING 0x2
34#define GPIOINT_EDGE_RISING 0x3
35#define GPIOINT_EDGE_BOTH 0x4
36
37static int group_to_con_offset(int group)
38{
39 return group << 2;
40}
41
42static int group_to_mask_offset(int group)
43{
44 return group << 2;
45}
46
47static int group_to_pend_offset(int group)
48{
49 return group << 2;
50}
51
52static int s5pc100_get_start(unsigned int group)
53{
54 switch (group) {
55 case 0: return S5PC100_GPIO_A0_START;
56 case 1: return S5PC100_GPIO_A1_START;
57 case 2: return S5PC100_GPIO_B_START;
58 case 3: return S5PC100_GPIO_C_START;
59 case 4: return S5PC100_GPIO_D_START;
60 case 5: return S5PC100_GPIO_E0_START;
61 case 6: return S5PC100_GPIO_E1_START;
62 case 7: return S5PC100_GPIO_F0_START;
63 case 8: return S5PC100_GPIO_F1_START;
64 case 9: return S5PC100_GPIO_F2_START;
65 case 10: return S5PC100_GPIO_F3_START;
66 case 11: return S5PC100_GPIO_G0_START;
67 case 12: return S5PC100_GPIO_G1_START;
68 case 13: return S5PC100_GPIO_G2_START;
69 case 14: return S5PC100_GPIO_G3_START;
70 case 15: return S5PC100_GPIO_I_START;
71 case 16: return S5PC100_GPIO_J0_START;
72 case 17: return S5PC100_GPIO_J1_START;
73 case 18: return S5PC100_GPIO_J2_START;
74 case 19: return S5PC100_GPIO_J3_START;
75 case 20: return S5PC100_GPIO_J4_START;
76 default:
77 BUG();
78 }
79
80 return -EINVAL;
81}
82
83static int s5pc100_get_group(unsigned int irq)
84{
85 irq -= S3C_IRQ_GPIO(0);
86
87 switch (irq) {
88 case S5PC100_GPIO_A0_START ... S5PC100_GPIO_A1_START - 1:
89 return 0;
90 case S5PC100_GPIO_A1_START ... S5PC100_GPIO_B_START - 1:
91 return 1;
92 case S5PC100_GPIO_B_START ... S5PC100_GPIO_C_START - 1:
93 return 2;
94 case S5PC100_GPIO_C_START ... S5PC100_GPIO_D_START - 1:
95 return 3;
96 case S5PC100_GPIO_D_START ... S5PC100_GPIO_E0_START - 1:
97 return 4;
98 case S5PC100_GPIO_E0_START ... S5PC100_GPIO_E1_START - 1:
99 return 5;
100 case S5PC100_GPIO_E1_START ... S5PC100_GPIO_F0_START - 1:
101 return 6;
102 case S5PC100_GPIO_F0_START ... S5PC100_GPIO_F1_START - 1:
103 return 7;
104 case S5PC100_GPIO_F1_START ... S5PC100_GPIO_F2_START - 1:
105 return 8;
106 case S5PC100_GPIO_F2_START ... S5PC100_GPIO_F3_START - 1:
107 return 9;
108 case S5PC100_GPIO_F3_START ... S5PC100_GPIO_G0_START - 1:
109 return 10;
110 case S5PC100_GPIO_G0_START ... S5PC100_GPIO_G1_START - 1:
111 return 11;
112 case S5PC100_GPIO_G1_START ... S5PC100_GPIO_G2_START - 1:
113 return 12;
114 case S5PC100_GPIO_G2_START ... S5PC100_GPIO_G3_START - 1:
115 return 13;
116 case S5PC100_GPIO_G3_START ... S5PC100_GPIO_H0_START - 1:
117 return 14;
118 case S5PC100_GPIO_I_START ... S5PC100_GPIO_J0_START - 1:
119 return 15;
120 case S5PC100_GPIO_J0_START ... S5PC100_GPIO_J1_START - 1:
121 return 16;
122 case S5PC100_GPIO_J1_START ... S5PC100_GPIO_J2_START - 1:
123 return 17;
124 case S5PC100_GPIO_J2_START ... S5PC100_GPIO_J3_START - 1:
125 return 18;
126 case S5PC100_GPIO_J3_START ... S5PC100_GPIO_J4_START - 1:
127 return 19;
128 case S5PC100_GPIO_J4_START ... S5PC100_GPIO_K0_START - 1:
129 return 20;
130 default:
131 BUG();
132 }
133
134 return -EINVAL;
135}
136
137static int s5pc100_get_offset(unsigned int irq)
138{
139 struct gpio_chip *chip = get_irq_data(irq);
140 return irq - S3C_IRQ_GPIO(chip->base);
141}
142
143static void s5pc100_gpioint_ack(unsigned int irq)
144{
145 int group, offset, pend_offset;
146 unsigned int value;
147
148 group = s5pc100_get_group(irq);
149 offset = s5pc100_get_offset(irq);
150 pend_offset = group_to_pend_offset(group);
151
152 value = __raw_readl(S5P_GPIOREG(PEND_OFFSET) + pend_offset);
153 value |= 1 << offset;
154 __raw_writel(value, S5P_GPIOREG(PEND_OFFSET) + pend_offset);
155}
156
157static void s5pc100_gpioint_mask(unsigned int irq)
158{
159 int group, offset, mask_offset;
160 unsigned int value;
161
162 group = s5pc100_get_group(irq);
163 offset = s5pc100_get_offset(irq);
164 mask_offset = group_to_mask_offset(group);
165
166 value = __raw_readl(S5P_GPIOREG(MASK_OFFSET) + mask_offset);
167 value |= 1 << offset;
168 __raw_writel(value, S5P_GPIOREG(MASK_OFFSET) + mask_offset);
169}
170
171static void s5pc100_gpioint_unmask(unsigned int irq)
172{
173 int group, offset, mask_offset;
174 unsigned int value;
175
176 group = s5pc100_get_group(irq);
177 offset = s5pc100_get_offset(irq);
178 mask_offset = group_to_mask_offset(group);
179
180 value = __raw_readl(S5P_GPIOREG(MASK_OFFSET) + mask_offset);
181 value &= ~(1 << offset);
182 __raw_writel(value, S5P_GPIOREG(MASK_OFFSET) + mask_offset);
183}
184
185static void s5pc100_gpioint_mask_ack(unsigned int irq)
186{
187 s5pc100_gpioint_mask(irq);
188 s5pc100_gpioint_ack(irq);
189}
190
191static int s5pc100_gpioint_set_type(unsigned int irq, unsigned int type)
192{
193 int group, offset, con_offset;
194 unsigned int value;
195
196 group = s5pc100_get_group(irq);
197 offset = s5pc100_get_offset(irq);
198 con_offset = group_to_con_offset(group);
199
200 switch (type) {
201 case IRQ_TYPE_NONE:
202 printk(KERN_WARNING "No irq type\n");
203 return -EINVAL;
204 case IRQ_TYPE_EDGE_RISING:
205 type = GPIOINT_EDGE_RISING;
206 break;
207 case IRQ_TYPE_EDGE_FALLING:
208 type = GPIOINT_EDGE_FALLING;
209 break;
210 case IRQ_TYPE_EDGE_BOTH:
211 type = GPIOINT_EDGE_BOTH;
212 break;
213 case IRQ_TYPE_LEVEL_HIGH:
214 type = GPIOINT_LEVEL_HIGH;
215 break;
216 case IRQ_TYPE_LEVEL_LOW:
217 type = GPIOINT_LEVEL_LOW;
218 break;
219 default:
220 BUG();
221 }
222
223
224 value = __raw_readl(S5P_GPIOREG(CON_OFFSET) + con_offset);
225 value &= ~(0xf << (offset * 0x4));
226 value |= (type << (offset * 0x4));
227 __raw_writel(value, S5P_GPIOREG(CON_OFFSET) + con_offset);
228
229 return 0;
230}
231
232struct irq_chip s5pc100_gpioint = {
233 .name = "GPIO",
234 .ack = s5pc100_gpioint_ack,
235 .mask = s5pc100_gpioint_mask,
236 .mask_ack = s5pc100_gpioint_mask_ack,
237 .unmask = s5pc100_gpioint_unmask,
238 .set_type = s5pc100_gpioint_set_type,
239};
240
241void s5pc100_irq_gpioint_handler(unsigned int irq, struct irq_desc *desc)
242{
243 int group, offset, pend_offset, mask_offset;
244 int real_irq, group_end;
245 unsigned int pend, mask;
246
247 group_end = 21;
248
249 for (group = 0; group < group_end; group++) {
250 pend_offset = group_to_pend_offset(group);
251 pend = __raw_readl(S5P_GPIOREG(PEND_OFFSET) + pend_offset);
252 if (!pend)
253 continue;
254
255 mask_offset = group_to_mask_offset(group);
256 mask = __raw_readl(S5P_GPIOREG(MASK_OFFSET) + mask_offset);
257 pend &= ~mask;
258
259 for (offset = 0; offset < 8; offset++) {
260 if (pend & (1 << offset)) {
261 real_irq = s5pc100_get_start(group) + offset;
262 generic_handle_irq(S3C_IRQ_GPIO(real_irq));
263 }
264 }
265 }
266}
diff --git a/arch/arm/mach-s5pc100/mach-smdkc100.c b/arch/arm/mach-s5pc100/mach-smdkc100.c
index 880fb075092c..18b405d514d6 100644
--- a/arch/arm/mach-s5pc100/mach-smdkc100.c
+++ b/arch/arm/mach-s5pc100/mach-smdkc100.c
@@ -47,6 +47,7 @@
47#include <plat/adc.h> 47#include <plat/adc.h>
48#include <plat/keypad.h> 48#include <plat/keypad.h>
49#include <plat/ts.h> 49#include <plat/ts.h>
50#include <plat/audio.h>
50 51
51/* Following are default values for UCON, ULCON and UFCON UART registers */ 52/* Following are default values for UCON, ULCON and UFCON UART registers */
52#define SMDKC100_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 53#define SMDKC100_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -196,6 +197,7 @@ static struct platform_device *smdkc100_devices[] __initdata = {
196 &s5p_device_fimc0, 197 &s5p_device_fimc0,
197 &s5p_device_fimc1, 198 &s5p_device_fimc1,
198 &s5p_device_fimc2, 199 &s5p_device_fimc2,
200 &s5pc100_device_spdif,
199}; 201};
200 202
201static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = { 203static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
@@ -226,6 +228,8 @@ static void __init smdkc100_machine_init(void)
226 228
227 samsung_keypad_set_platdata(&smdkc100_keypad_data); 229 samsung_keypad_set_platdata(&smdkc100_keypad_data);
228 230
231 s5pc100_spdif_setup_gpio(S5PC100_SPDIF_GPD);
232
229 /* LCD init */ 233 /* LCD init */
230 gpio_request(S5PC100_GPD(0), "GPD"); 234 gpio_request(S5PC100_GPD(0), "GPD");
231 gpio_request(S5PC100_GPH0(6), "GPH0"); 235 gpio_request(S5PC100_GPH0(6), "GPH0");
diff --git a/arch/arm/mach-s5pc100/setup-fb-24bpp.c b/arch/arm/mach-s5pc100/setup-fb-24bpp.c
index 6eba6cb8e2f4..d31c0f3fe222 100644
--- a/arch/arm/mach-s5pc100/setup-fb-24bpp.c
+++ b/arch/arm/mach-s5pc100/setup-fb-24bpp.c
@@ -22,27 +22,15 @@
22 22
23#define DISR_OFFSET 0x7008 23#define DISR_OFFSET 0x7008
24 24
25void s5pc100_fb_gpio_setup_24bpp(void) 25static void s5pc100_fb_setgpios(unsigned int base, unsigned int nr)
26{ 26{
27 unsigned int gpio = 0; 27 s3c_gpio_cfgrange_nopull(base, nr, S3C_GPIO_SFN(2));
28 28}
29 for (gpio = S5PC100_GPF0(0); gpio <= S5PC100_GPF0(7); gpio++) {
30 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
31 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
32 }
33
34 for (gpio = S5PC100_GPF1(0); gpio <= S5PC100_GPF1(7); gpio++) {
35 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
36 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
37 }
38
39 for (gpio = S5PC100_GPF2(0); gpio <= S5PC100_GPF2(7); gpio++) {
40 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
41 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
42 }
43 29
44 for (gpio = S5PC100_GPF3(0); gpio <= S5PC100_GPF3(3); gpio++) { 30void s5pc100_fb_gpio_setup_24bpp(void)
45 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); 31{
46 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); 32 s5pc100_fb_setgpios(S5PC100_GPF0(0), 8);
47 } 33 s5pc100_fb_setgpios(S5PC100_GPF1(0), 8);
34 s5pc100_fb_setgpios(S5PC100_GPF2(0), 8);
35 s5pc100_fb_setgpios(S5PC100_GPF3(0), 4);
48} 36}
diff --git a/arch/arm/mach-s5pc100/setup-i2c0.c b/arch/arm/mach-s5pc100/setup-i2c0.c
index dd3174e6ecc5..eaef7a3bda49 100644
--- a/arch/arm/mach-s5pc100/setup-i2c0.c
+++ b/arch/arm/mach-s5pc100/setup-i2c0.c
@@ -23,8 +23,6 @@ struct platform_device; /* don't need the contents */
23 23
24void s3c_i2c0_cfg_gpio(struct platform_device *dev) 24void s3c_i2c0_cfg_gpio(struct platform_device *dev)
25{ 25{
26 s3c_gpio_cfgpin(S5PC100_GPD(3), S3C_GPIO_SFN(2)); 26 s3c_gpio_cfgall_range(S5PC100_GPD(3), 2,
27 s3c_gpio_setpull(S5PC100_GPD(3), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5PC100_GPD(4), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5PC100_GPD(4), S3C_GPIO_PULL_UP);
30} 28}
diff --git a/arch/arm/mach-s5pc100/setup-i2c1.c b/arch/arm/mach-s5pc100/setup-i2c1.c
index d1fec26b69ee..aaff74a90dee 100644
--- a/arch/arm/mach-s5pc100/setup-i2c1.c
+++ b/arch/arm/mach-s5pc100/setup-i2c1.c
@@ -23,8 +23,6 @@ struct platform_device; /* don't need the contents */
23 23
24void s3c_i2c1_cfg_gpio(struct platform_device *dev) 24void s3c_i2c1_cfg_gpio(struct platform_device *dev)
25{ 25{
26 s3c_gpio_cfgpin(S5PC100_GPD(5), S3C_GPIO_SFN(2)); 26 s3c_gpio_cfgall_range(S5PC100_GPD(5), 2,
27 s3c_gpio_setpull(S5PC100_GPD(5), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5PC100_GPD(6), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5PC100_GPD(6), S3C_GPIO_PULL_UP);
30} 28}
diff --git a/arch/arm/mach-s5pc100/setup-ide.c b/arch/arm/mach-s5pc100/setup-ide.c
index 83575671fb59..223aae044466 100644
--- a/arch/arm/mach-s5pc100/setup-ide.c
+++ b/arch/arm/mach-s5pc100/setup-ide.c
@@ -17,52 +17,39 @@
17#include <mach/regs-clock.h> 17#include <mach/regs-clock.h>
18#include <plat/gpio-cfg.h> 18#include <plat/gpio-cfg.h>
19 19
20static void s5pc100_ide_cfg_gpios(unsigned int base, unsigned int nr)
21{
22 s3c_gpio_cfgrange_nopull(base, nr, S3C_GPIO_SFN(4));
23
24 for (; nr > 0; nr--, base++)
25 s5p_gpio_set_drvstr(base, S5P_GPIO_DRVSTR_LV4);
26}
27
20void s5pc100_ide_setup_gpio(void) 28void s5pc100_ide_setup_gpio(void)
21{ 29{
22 u32 reg; 30 u32 reg;
23 u32 gpio = 0;
24 31
25 /* Independent CF interface, CF chip select configuration */ 32 /* Independent CF interface, CF chip select configuration */
26 reg = readl(S5PC100_MEM_SYS_CFG) & (~0x3f); 33 reg = readl(S5PC100_MEM_SYS_CFG) & (~0x3f);
27 writel(reg | MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S5PC100_MEM_SYS_CFG); 34 writel(reg | MEM_SYS_CFG_EBI_FIX_PRI_CFCON, S5PC100_MEM_SYS_CFG);
28 35
29 /* CF_Add[0 - 2], CF_IORDY, CF_INTRQ, CF_DMARQ, CF_DMARST, CF_DMACK */ 36 /* CF_Add[0 - 2], CF_IORDY, CF_INTRQ, CF_DMARQ, CF_DMARST, CF_DMACK */
30 for (gpio = S5PC100_GPJ0(0); gpio <= S5PC100_GPJ0(7); gpio++) { 37 s5pc100_ide_cfg_gpios(S5PC100_GPJ0(0), 8);
31 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
32 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
33 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
34 }
35 38
36 /*CF_Data[0 - 7] */ 39 /*CF_Data[0 - 7] */
37 for (gpio = S5PC100_GPJ2(0); gpio <= S5PC100_GPJ2(7); gpio++) { 40 s5pc100_ide_cfg_gpios(S5PC100_GPJ2(0), 8);
38 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
39 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
40 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
41 }
42 41
43 /* CF_Data[8 - 15] */ 42 /* CF_Data[8 - 15] */
44 for (gpio = S5PC100_GPJ3(0); gpio <= S5PC100_GPJ3(7); gpio++) { 43 s5pc100_ide_cfg_gpios(S5PC100_GPJ3(0), 8);
45 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
46 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
47 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
48 }
49 44
50 /* CF_CS0, CF_CS1, CF_IORD, CF_IOWR */ 45 /* CF_CS0, CF_CS1, CF_IORD, CF_IOWR */
51 for (gpio = S5PC100_GPJ4(0); gpio <= S5PC100_GPJ4(3); gpio++) { 46 s5pc100_ide_cfg_gpios(S5PC100_GPJ4(0), 4);
52 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
53 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
54 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
55 }
56 47
57 /* EBI_OE, EBI_WE */ 48 /* EBI_OE, EBI_WE */
58 for (gpio = S5PC100_GPK0(6); gpio <= S5PC100_GPK0(7); gpio++) 49 s3c_gpio_cfgpin_range(S5PC100_GPK0(6), 2, S3C_GPIO_SFN(0));
59 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0));
60 50
61 /* CF_OE, CF_WE */ 51 /* CF_OE, CF_WE */
62 for (gpio = S5PC100_GPK1(6); gpio <= S5PC100_GPK1(7); gpio++) { 52 s3c_gpio_cfgrange_nopull(S5PC100_GPK1(6), 8, S3C_GPIO_SFN(2));
63 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
64 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
65 }
66 53
67 /* CF_CD */ 54 /* CF_CD */
68 s3c_gpio_cfgpin(S5PC100_GPK3(5), S3C_GPIO_SFN(2)); 55 s3c_gpio_cfgpin(S5PC100_GPK3(5), S3C_GPIO_SFN(2));
diff --git a/arch/arm/mach-s5pc100/setup-keypad.c b/arch/arm/mach-s5pc100/setup-keypad.c
index d0837a72a58e..ada377f0c206 100644
--- a/arch/arm/mach-s5pc100/setup-keypad.c
+++ b/arch/arm/mach-s5pc100/setup-keypad.c
@@ -15,20 +15,9 @@
15 15
16void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) 16void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols)
17{ 17{
18 unsigned int gpio;
19 unsigned int end;
20
21 /* Set all the necessary GPH3 pins to special-function 3: KP_ROW[x] */ 18 /* Set all the necessary GPH3 pins to special-function 3: KP_ROW[x] */
22 end = S5PC100_GPH3(rows); 19 s3c_gpio_cfgrange_nopull(S5PC100_GPH3(0), rows, S3C_GPIO_SFN(3));
23 for (gpio = S5PC100_GPH3(0); gpio < end; gpio++) {
24 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
25 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
26 }
27 20
28 /* Set all the necessary GPH2 pins to special-function 3: KP_COL[x] */ 21 /* Set all the necessary GPH2 pins to special-function 3: KP_COL[x] */
29 end = S5PC100_GPH2(cols); 22 s3c_gpio_cfgrange_nopull(S5PC100_GPH2(0), cols, S3C_GPIO_SFN(3));
30 for (gpio = S5PC100_GPH2(0); gpio < end; gpio++) {
31 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
32 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
33 }
34} 23}
diff --git a/arch/arm/mach-s5pc100/setup-sdhci-gpio.c b/arch/arm/mach-s5pc100/setup-sdhci-gpio.c
index dc7208c639ea..03c02d04c68c 100644
--- a/arch/arm/mach-s5pc100/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s5pc100/setup-sdhci-gpio.c
@@ -25,8 +25,6 @@
25void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) 25void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
26{ 26{
27 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 27 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
28 unsigned int gpio;
29 unsigned int end;
30 unsigned int num; 28 unsigned int num;
31 29
32 num = width; 30 num = width;
@@ -34,20 +32,11 @@ void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
34 if (width == 8) 32 if (width == 8)
35 num = width - 2; 33 num = width - 2;
36 34
37 end = S5PC100_GPG0(2 + num);
38
39 /* Set all the necessary GPG0/GPG1 pins to special-function 0 */ 35 /* Set all the necessary GPG0/GPG1 pins to special-function 0 */
40 for (gpio = S5PC100_GPG0(0); gpio < end; gpio++) { 36 s3c_gpio_cfgrange_nopull(S5PC100_GPG0(0), 2 + num, S3C_GPIO_SFN(2));
41 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
42 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
43 }
44 37
45 if (width == 8) { 38 if (width == 8)
46 for (gpio = S5PC100_GPG1(0); gpio <= S5PC100_GPG1(1); gpio++) { 39 s3c_gpio_cfgrange_nopull(S5PC100_GPG1(0), 2, S3C_GPIO_SFN(2));
47 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
48 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
49 }
50 }
51 40
52 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 41 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
53 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP); 42 s3c_gpio_setpull(S5PC100_GPG1(2), S3C_GPIO_PULL_UP);
@@ -58,16 +47,9 @@ void s5pc100_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
58void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) 47void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
59{ 48{
60 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 49 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
61 unsigned int gpio;
62 unsigned int end;
63
64 end = S5PC100_GPG2(2 + width);
65 50
66 /* Set all the necessary GPG2 pins to special-function 2 */ 51 /* Set all the necessary GPG2 pins to special-function 2 */
67 for (gpio = S5PC100_GPG2(0); gpio < end; gpio++) { 52 s3c_gpio_cfgrange_nopull(S5PC100_GPG2(0), 2 + width, S3C_GPIO_SFN(2));
68 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
69 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
70 }
71 53
72 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 54 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
73 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP); 55 s3c_gpio_setpull(S5PC100_GPG2(6), S3C_GPIO_PULL_UP);
@@ -78,16 +60,9 @@ void s5pc100_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
78void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) 60void s5pc100_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
79{ 61{
80 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 62 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
81 unsigned int gpio;
82 unsigned int end;
83
84 end = S5PC100_GPG3(2 + width);
85 63
86 /* Set all the necessary GPG3 pins to special-function 2 */ 64 /* Set all the necessary GPG3 pins to special-function 2 */
87 for (gpio = S5PC100_GPG3(0); gpio < end; gpio++) { 65 s3c_gpio_cfgrange_nopull(S5PC100_GPG3(0), 2 + width, S3C_GPIO_SFN(2));
88 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
89 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
90 }
91 66
92 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 67 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
93 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP); 68 s3c_gpio_setpull(S5PC100_GPG3(6), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index 5315fec3db86..862f239a0fdb 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -11,9 +11,9 @@ if ARCH_S5PV210
11 11
12config CPU_S5PV210 12config CPU_S5PV210
13 bool 13 bool
14 select PLAT_S5P
15 select S3C_PL330_DMA 14 select S3C_PL330_DMA
16 select S5P_EXT_INT 15 select S5P_EXT_INT
16 select S5PV210_PM if PM
17 help 17 help
18 Enable S5PV210 CPU support 18 Enable S5PV210 CPU support
19 19
@@ -58,7 +58,6 @@ menu "S5PC110 Machines"
58config MACH_AQUILA 58config MACH_AQUILA
59 bool "Aquila" 59 bool "Aquila"
60 select CPU_S5PV210 60 select CPU_S5PV210
61 select ARCH_SPARSEMEM_ENABLE
62 select S3C_DEV_FB 61 select S3C_DEV_FB
63 select S5P_DEV_FIMC0 62 select S5P_DEV_FIMC0
64 select S5P_DEV_FIMC1 63 select S5P_DEV_FIMC1
@@ -75,7 +74,7 @@ config MACH_AQUILA
75config MACH_GONI 74config MACH_GONI
76 bool "GONI" 75 bool "GONI"
77 select CPU_S5PV210 76 select CPU_S5PV210
78 select ARCH_SPARSEMEM_ENABLE 77 select S5P_GPIO_INT
79 select S3C_DEV_FB 78 select S3C_DEV_FB
80 select S5P_DEV_FIMC0 79 select S5P_DEV_FIMC0
81 select S5P_DEV_FIMC1 80 select S5P_DEV_FIMC1
@@ -83,8 +82,15 @@ config MACH_GONI
83 select S3C_DEV_HSMMC 82 select S3C_DEV_HSMMC
84 select S3C_DEV_HSMMC1 83 select S3C_DEV_HSMMC1
85 select S3C_DEV_HSMMC2 84 select S3C_DEV_HSMMC2
85 select S3C_DEV_I2C1
86 select S3C_DEV_I2C2
87 select S3C_DEV_USB_HSOTG
86 select S5P_DEV_ONENAND 88 select S5P_DEV_ONENAND
89 select SAMSUNG_DEV_KEYPAD
87 select S5PV210_SETUP_FB_24BPP 90 select S5PV210_SETUP_FB_24BPP
91 select S5PV210_SETUP_I2C1
92 select S5PV210_SETUP_I2C2
93 select S5PV210_SETUP_KEYPAD
88 select S5PV210_SETUP_SDHCI 94 select S5PV210_SETUP_SDHCI
89 help 95 help
90 Machine support for Samsung GONI board 96 Machine support for Samsung GONI board
@@ -93,7 +99,6 @@ config MACH_GONI
93config MACH_SMDKC110 99config MACH_SMDKC110
94 bool "SMDKC110" 100 bool "SMDKC110"
95 select CPU_S5PV210 101 select CPU_S5PV210
96 select ARCH_SPARSEMEM_ENABLE
97 select S3C_DEV_I2C1 102 select S3C_DEV_I2C1
98 select S3C_DEV_I2C2 103 select S3C_DEV_I2C2
99 select S3C_DEV_RTC 104 select S3C_DEV_RTC
@@ -113,7 +118,6 @@ menu "S5PV210 Machines"
113config MACH_SMDKV210 118config MACH_SMDKV210
114 bool "SMDKV210" 119 bool "SMDKV210"
115 select CPU_S5PV210 120 select CPU_S5PV210
116 select ARCH_SPARSEMEM_ENABLE
117 select S3C_DEV_HSMMC 121 select S3C_DEV_HSMMC
118 select S3C_DEV_HSMMC1 122 select S3C_DEV_HSMMC1
119 select S3C_DEV_HSMMC2 123 select S3C_DEV_HSMMC2
@@ -134,6 +138,29 @@ config MACH_SMDKV210
134 help 138 help
135 Machine support for Samsung SMDKV210 139 Machine support for Samsung SMDKV210
136 140
141config MACH_TORBRECK
142 bool "Torbreck"
143 select CPU_S5PV210
144 select ARCH_SPARSEMEM_ENABLE
145 select S3C_DEV_HSMMC
146 select S3C_DEV_HSMMC1
147 select S3C_DEV_HSMMC2
148 select S3C_DEV_HSMMC3
149 select S3C_DEV_I2C1
150 select S3C_DEV_I2C2
151 select S3C_DEV_RTC
152 select S3C_DEV_WDT
153 select S5PV210_SETUP_I2C1
154 select S5PV210_SETUP_I2C2
155 select S5PV210_SETUP_SDHCI
156 help
157 Machine support for aESOP Torbreck
158
137endmenu 159endmenu
138 160
161config S5PV210_PM
162 bool
163 help
164 Power Management code common to S5PV210
165
139endif 166endif
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index 704548912408..ff1a0db57a2f 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -14,6 +14,8 @@ obj- :=
14 14
15obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o gpiolib.o 15obj-$(CONFIG_CPU_S5PV210) += cpu.o init.o clock.o dma.o gpiolib.o
16obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o 16obj-$(CONFIG_CPU_S5PV210) += setup-i2c0.o
17obj-$(CONFIG_S5PV210_PM) += pm.o sleep.o
18obj-$(CONFIG_CPU_FREQ) += cpufreq.o
17 19
18# machine support 20# machine support
19 21
@@ -21,6 +23,7 @@ obj-$(CONFIG_MACH_AQUILA) += mach-aquila.o
21obj-$(CONFIG_MACH_SMDKV210) += mach-smdkv210.o 23obj-$(CONFIG_MACH_SMDKV210) += mach-smdkv210.o
22obj-$(CONFIG_MACH_SMDKC110) += mach-smdkc110.o 24obj-$(CONFIG_MACH_SMDKC110) += mach-smdkc110.o
23obj-$(CONFIG_MACH_GONI) += mach-goni.o 25obj-$(CONFIG_MACH_GONI) += mach-goni.o
26obj-$(CONFIG_MACH_TORBRECK) += mach-torbreck.o
24 27
25# device support 28# device support
26 29
diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c
index d562670e1b0b..019c3a69b0e4 100644
--- a/arch/arm/mach-s5pv210/clock.c
+++ b/arch/arm/mach-s5pv210/clock.c
@@ -31,6 +31,8 @@
31#include <plat/clock-clksrc.h> 31#include <plat/clock-clksrc.h>
32#include <plat/s5pv210.h> 32#include <plat/s5pv210.h>
33 33
34static unsigned long xtal;
35
34static struct clksrc_clk clk_mout_apll = { 36static struct clksrc_clk clk_mout_apll = {
35 .clk = { 37 .clk = {
36 .name = "mout_apll", 38 .name = "mout_apll",
@@ -259,6 +261,36 @@ static struct clksrc_clk clk_sclk_vpll = {
259 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 12, .size = 1 }, 261 .reg_src = { .reg = S5P_CLK_SRC0, .shift = 12, .size = 1 },
260}; 262};
261 263
264static struct clk *clkset_moutdmc0src_list[] = {
265 [0] = &clk_sclk_a2m.clk,
266 [1] = &clk_mout_mpll.clk,
267 [2] = NULL,
268 [3] = NULL,
269};
270
271static struct clksrc_sources clkset_moutdmc0src = {
272 .sources = clkset_moutdmc0src_list,
273 .nr_sources = ARRAY_SIZE(clkset_moutdmc0src_list),
274};
275
276static struct clksrc_clk clk_mout_dmc0 = {
277 .clk = {
278 .name = "mout_dmc0",
279 .id = -1,
280 },
281 .sources = &clkset_moutdmc0src,
282 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 24, .size = 2 },
283};
284
285static struct clksrc_clk clk_sclk_dmc0 = {
286 .clk = {
287 .name = "sclk_dmc0",
288 .id = -1,
289 .parent = &clk_mout_dmc0.clk,
290 },
291 .reg_div = { .reg = S5P_CLK_DIV6, .shift = 28, .size = 4 },
292};
293
262static unsigned long s5pv210_clk_imem_get_rate(struct clk *clk) 294static unsigned long s5pv210_clk_imem_get_rate(struct clk *clk)
263{ 295{
264 return clk_get_rate(clk->parent) / 2; 296 return clk_get_rate(clk->parent) / 2;
@@ -268,8 +300,29 @@ static struct clk_ops clk_hclk_imem_ops = {
268 .get_rate = s5pv210_clk_imem_get_rate, 300 .get_rate = s5pv210_clk_imem_get_rate,
269}; 301};
270 302
303static unsigned long s5pv210_clk_fout_apll_get_rate(struct clk *clk)
304{
305 return s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
306}
307
308static struct clk_ops clk_fout_apll_ops = {
309 .get_rate = s5pv210_clk_fout_apll_get_rate,
310};
311
271static struct clk init_clocks_disable[] = { 312static struct clk init_clocks_disable[] = {
272 { 313 {
314 .name = "pdma",
315 .id = 0,
316 .parent = &clk_hclk_psys.clk,
317 .enable = s5pv210_clk_ip0_ctrl,
318 .ctrlbit = (1 << 3),
319 }, {
320 .name = "pdma",
321 .id = 1,
322 .parent = &clk_hclk_psys.clk,
323 .enable = s5pv210_clk_ip0_ctrl,
324 .ctrlbit = (1 << 4),
325 }, {
273 .name = "rot", 326 .name = "rot",
274 .id = -1, 327 .id = -1,
275 .parent = &clk_hclk_dsys.clk, 328 .parent = &clk_hclk_dsys.clk,
@@ -431,6 +484,12 @@ static struct clk init_clocks_disable[] = {
431 .parent = &clk_p, 484 .parent = &clk_p,
432 .enable = s5pv210_clk_ip3_ctrl, 485 .enable = s5pv210_clk_ip3_ctrl,
433 .ctrlbit = (1 << 6), 486 .ctrlbit = (1 << 6),
487 }, {
488 .name = "spdif",
489 .id = -1,
490 .parent = &clk_p,
491 .enable = s5pv210_clk_ip3_ctrl,
492 .ctrlbit = (1 << 0),
434 }, 493 },
435}; 494};
436 495
@@ -660,6 +719,53 @@ static struct clksrc_sources clkset_sclk_spdif = {
660 .nr_sources = ARRAY_SIZE(clkset_sclk_spdif_list), 719 .nr_sources = ARRAY_SIZE(clkset_sclk_spdif_list),
661}; 720};
662 721
722static int s5pv210_spdif_set_rate(struct clk *clk, unsigned long rate)
723{
724 struct clk *pclk;
725 int ret;
726
727 pclk = clk_get_parent(clk);
728 if (IS_ERR(pclk))
729 return -EINVAL;
730
731 ret = pclk->ops->set_rate(pclk, rate);
732 clk_put(pclk);
733
734 return ret;
735}
736
737static unsigned long s5pv210_spdif_get_rate(struct clk *clk)
738{
739 struct clk *pclk;
740 int rate;
741
742 pclk = clk_get_parent(clk);
743 if (IS_ERR(pclk))
744 return -EINVAL;
745
746 rate = pclk->ops->get_rate(clk);
747 clk_put(pclk);
748
749 return rate;
750}
751
752static struct clk_ops s5pv210_sclk_spdif_ops = {
753 .set_rate = s5pv210_spdif_set_rate,
754 .get_rate = s5pv210_spdif_get_rate,
755};
756
757static struct clksrc_clk clk_sclk_spdif = {
758 .clk = {
759 .name = "sclk_spdif",
760 .id = -1,
761 .enable = s5pv210_clk_mask0_ctrl,
762 .ctrlbit = (1 << 27),
763 .ops = &s5pv210_sclk_spdif_ops,
764 },
765 .sources = &clkset_sclk_spdif,
766 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
767};
768
663static struct clk *clkset_group2_list[] = { 769static struct clk *clkset_group2_list[] = {
664 [0] = &clk_ext_xtal_mux, 770 [0] = &clk_ext_xtal_mux,
665 [1] = &clk_xusbxti, 771 [1] = &clk_xusbxti,
@@ -744,15 +850,6 @@ static struct clksrc_clk clksrcs[] = {
744 .sources = &clkset_sclk_mixer, 850 .sources = &clkset_sclk_mixer,
745 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 }, 851 .reg_src = { .reg = S5P_CLK_SRC1, .shift = 4, .size = 1 },
746 }, { 852 }, {
747 .clk = {
748 .name = "sclk_spdif",
749 .id = -1,
750 .enable = s5pv210_clk_mask0_ctrl,
751 .ctrlbit = (1 << 27),
752 },
753 .sources = &clkset_sclk_spdif,
754 .reg_src = { .reg = S5P_CLK_SRC6, .shift = 12, .size = 2 },
755 }, {
756 .clk = { 853 .clk = {
757 .name = "sclk_fimc", 854 .name = "sclk_fimc",
758 .id = 0, 855 .id = 0,
@@ -953,12 +1050,93 @@ static struct clksrc_clk *sysclks[] = {
953 &clk_sclk_dac, 1050 &clk_sclk_dac,
954 &clk_sclk_pixel, 1051 &clk_sclk_pixel,
955 &clk_sclk_hdmi, 1052 &clk_sclk_hdmi,
1053 &clk_mout_dmc0,
1054 &clk_sclk_dmc0,
1055 &clk_sclk_audio0,
1056 &clk_sclk_audio1,
1057 &clk_sclk_audio2,
1058 &clk_sclk_spdif,
1059};
1060
1061static u32 epll_div[][6] = {
1062 { 48000000, 0, 48, 3, 3, 0 },
1063 { 96000000, 0, 48, 3, 2, 0 },
1064 { 144000000, 1, 72, 3, 2, 0 },
1065 { 192000000, 0, 48, 3, 1, 0 },
1066 { 288000000, 1, 72, 3, 1, 0 },
1067 { 32750000, 1, 65, 3, 4, 35127 },
1068 { 32768000, 1, 65, 3, 4, 35127 },
1069 { 45158400, 0, 45, 3, 3, 10355 },
1070 { 45000000, 0, 45, 3, 3, 10355 },
1071 { 45158000, 0, 45, 3, 3, 10355 },
1072 { 49125000, 0, 49, 3, 3, 9961 },
1073 { 49152000, 0, 49, 3, 3, 9961 },
1074 { 67737600, 1, 67, 3, 3, 48366 },
1075 { 67738000, 1, 67, 3, 3, 48366 },
1076 { 73800000, 1, 73, 3, 3, 47710 },
1077 { 73728000, 1, 73, 3, 3, 47710 },
1078 { 36000000, 1, 32, 3, 4, 0 },
1079 { 60000000, 1, 60, 3, 3, 0 },
1080 { 72000000, 1, 72, 3, 3, 0 },
1081 { 80000000, 1, 80, 3, 3, 0 },
1082 { 84000000, 0, 42, 3, 2, 0 },
1083 { 50000000, 0, 50, 3, 3, 0 },
1084};
1085
1086static int s5pv210_epll_set_rate(struct clk *clk, unsigned long rate)
1087{
1088 unsigned int epll_con, epll_con_k;
1089 unsigned int i;
1090
1091 /* Return if nothing changed */
1092 if (clk->rate == rate)
1093 return 0;
1094
1095 epll_con = __raw_readl(S5P_EPLL_CON);
1096 epll_con_k = __raw_readl(S5P_EPLL_CON1);
1097
1098 epll_con_k &= ~PLL46XX_KDIV_MASK;
1099 epll_con &= ~(1 << 27 |
1100 PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |
1101 PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |
1102 PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
1103
1104 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
1105 if (epll_div[i][0] == rate) {
1106 epll_con_k |= epll_div[i][5] << 0;
1107 epll_con |= (epll_div[i][1] << 27 |
1108 epll_div[i][2] << PLL46XX_MDIV_SHIFT |
1109 epll_div[i][3] << PLL46XX_PDIV_SHIFT |
1110 epll_div[i][4] << PLL46XX_SDIV_SHIFT);
1111 break;
1112 }
1113 }
1114
1115 if (i == ARRAY_SIZE(epll_div)) {
1116 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
1117 __func__);
1118 return -EINVAL;
1119 }
1120
1121 __raw_writel(epll_con, S5P_EPLL_CON);
1122 __raw_writel(epll_con_k, S5P_EPLL_CON1);
1123
1124 printk(KERN_WARNING "EPLL Rate changes from %lu to %lu\n",
1125 clk->rate, rate);
1126
1127 clk->rate = rate;
1128
1129 return 0;
1130}
1131
1132static struct clk_ops s5pv210_epll_ops = {
1133 .set_rate = s5pv210_epll_set_rate,
1134 .get_rate = s5p_epll_get_rate,
956}; 1135};
957 1136
958void __init_or_cpufreq s5pv210_setup_clocks(void) 1137void __init_or_cpufreq s5pv210_setup_clocks(void)
959{ 1138{
960 struct clk *xtal_clk; 1139 struct clk *xtal_clk;
961 unsigned long xtal;
962 unsigned long vpllsrc; 1140 unsigned long vpllsrc;
963 unsigned long armclk; 1141 unsigned long armclk;
964 unsigned long hclk_msys; 1142 unsigned long hclk_msys;
@@ -974,6 +1152,10 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
974 unsigned int ptr; 1152 unsigned int ptr;
975 u32 clkdiv0, clkdiv1; 1153 u32 clkdiv0, clkdiv1;
976 1154
1155 /* Set functions for clk_fout_epll */
1156 clk_fout_epll.enable = s5p_epll_enable;
1157 clk_fout_epll.ops = &s5pv210_epll_ops;
1158
977 printk(KERN_DEBUG "%s: registering clocks\n", __func__); 1159 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
978 1160
979 clkdiv0 = __raw_readl(S5P_CLK_DIV0); 1161 clkdiv0 = __raw_readl(S5P_CLK_DIV0);
@@ -992,11 +1174,12 @@ void __init_or_cpufreq s5pv210_setup_clocks(void)
992 1174
993 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508); 1175 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON), pll_4508);
994 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502); 1176 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON), pll_4502);
995 epll = s5p_get_pll45xx(xtal, __raw_readl(S5P_EPLL_CON), pll_4500); 1177 epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON),
1178 __raw_readl(S5P_EPLL_CON1), pll_4600);
996 vpllsrc = clk_get_rate(&clk_vpllsrc.clk); 1179 vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
997 vpll = s5p_get_pll45xx(vpllsrc, __raw_readl(S5P_VPLL_CON), pll_4502); 1180 vpll = s5p_get_pll45xx(vpllsrc, __raw_readl(S5P_VPLL_CON), pll_4502);
998 1181
999 clk_fout_apll.rate = apll; 1182 clk_fout_apll.ops = &clk_fout_apll_ops;
1000 clk_fout_mpll.rate = mpll; 1183 clk_fout_mpll.rate = mpll;
1001 clk_fout_epll.rate = epll; 1184 clk_fout_epll.rate = epll;
1002 clk_fout_vpll.rate = vpll; 1185 clk_fout_vpll.rate = vpll;
diff --git a/arch/arm/mach-s5pv210/cpu.c b/arch/arm/mach-s5pv210/cpu.c
index 2f16bfc0a116..8eb480e201b0 100644
--- a/arch/arm/mach-s5pv210/cpu.c
+++ b/arch/arm/mach-s5pv210/cpu.c
@@ -85,6 +85,21 @@ static struct map_desc s5pv210_iodesc[] __initdata = {
85 .pfn = __phys_to_pfn(S5PV210_PA_SROMC), 85 .pfn = __phys_to_pfn(S5PV210_PA_SROMC),
86 .length = SZ_4K, 86 .length = SZ_4K,
87 .type = MT_DEVICE, 87 .type = MT_DEVICE,
88 }, {
89 .virtual = (unsigned long)S5P_VA_DMC0,
90 .pfn = __phys_to_pfn(S5PV210_PA_DMC0),
91 .length = SZ_4K,
92 .type = MT_DEVICE,
93 }, {
94 .virtual = (unsigned long)S5P_VA_DMC1,
95 .pfn = __phys_to_pfn(S5PV210_PA_DMC1),
96 .length = SZ_4K,
97 .type = MT_DEVICE,
98 }, {
99 .virtual = (unsigned long)S3C_VA_USB_HSPHY,
100 .pfn =__phys_to_pfn(S5PV210_PA_HSPHY),
101 .length = SZ_4K,
102 .type = MT_DEVICE,
88 } 103 }
89}; 104};
90 105
diff --git a/arch/arm/mach-s5pv210/cpufreq.c b/arch/arm/mach-s5pv210/cpufreq.c
new file mode 100644
index 000000000000..a6f22920a2c2
--- /dev/null
+++ b/arch/arm/mach-s5pv210/cpufreq.c
@@ -0,0 +1,484 @@
1/* linux/arch/arm/mach-s5pv210/cpufreq.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * CPU frequency scaling for S5PC110/S5PV210
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/types.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/err.h>
17#include <linux/clk.h>
18#include <linux/io.h>
19#include <linux/cpufreq.h>
20
21#include <mach/map.h>
22#include <mach/regs-clock.h>
23
24static struct clk *cpu_clk;
25static struct clk *dmc0_clk;
26static struct clk *dmc1_clk;
27static struct cpufreq_freqs freqs;
28
29/* APLL M,P,S values for 1G/800Mhz */
30#define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1)
31#define APLL_VAL_800 ((1 << 31) | (100 << 16) | (3 << 8) | 1)
32
33/*
34 * DRAM configurations to calculate refresh counter for changing
35 * frequency of memory.
36 */
37struct dram_conf {
38 unsigned long freq; /* HZ */
39 unsigned long refresh; /* DRAM refresh counter * 1000 */
40};
41
42/* DRAM configuration (DMC0 and DMC1) */
43static struct dram_conf s5pv210_dram_conf[2];
44
45enum perf_level {
46 L0, L1, L2, L3, L4,
47};
48
49enum s5pv210_mem_type {
50 LPDDR = 0x1,
51 LPDDR2 = 0x2,
52 DDR2 = 0x4,
53};
54
55enum s5pv210_dmc_port {
56 DMC0 = 0,
57 DMC1,
58};
59
60static struct cpufreq_frequency_table s5pv210_freq_table[] = {
61 {L0, 1000*1000},
62 {L1, 800*1000},
63 {L2, 400*1000},
64 {L3, 200*1000},
65 {L4, 100*1000},
66 {0, CPUFREQ_TABLE_END},
67};
68
69static u32 clkdiv_val[5][11] = {
70 /*
71 * Clock divider value for following
72 * { APLL, A2M, HCLK_MSYS, PCLK_MSYS,
73 * HCLK_DSYS, PCLK_DSYS, HCLK_PSYS, PCLK_PSYS,
74 * ONEDRAM, MFC, G3D }
75 */
76
77 /* L0 : [1000/200/100][166/83][133/66][200/200] */
78 {0, 4, 4, 1, 3, 1, 4, 1, 3, 0, 0},
79
80 /* L1 : [800/200/100][166/83][133/66][200/200] */
81 {0, 3, 3, 1, 3, 1, 4, 1, 3, 0, 0},
82
83 /* L2 : [400/200/100][166/83][133/66][200/200] */
84 {1, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
85
86 /* L3 : [200/200/100][166/83][133/66][200/200] */
87 {3, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
88
89 /* L4 : [100/100/100][83/83][66/66][100/100] */
90 {7, 7, 0, 0, 7, 0, 9, 0, 7, 0, 0},
91};
92
93/*
94 * This function set DRAM refresh counter
95 * accoriding to operating frequency of DRAM
96 * ch: DMC port number 0 or 1
97 * freq: Operating frequency of DRAM(KHz)
98 */
99static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)
100{
101 unsigned long tmp, tmp1;
102 void __iomem *reg = NULL;
103
104 if (ch == DMC0)
105 reg = (S5P_VA_DMC0 + 0x30);
106 else if (ch == DMC1)
107 reg = (S5P_VA_DMC1 + 0x30);
108 else
109 printk(KERN_ERR "Cannot find DMC port\n");
110
111 /* Find current DRAM frequency */
112 tmp = s5pv210_dram_conf[ch].freq;
113
114 do_div(tmp, freq);
115
116 tmp1 = s5pv210_dram_conf[ch].refresh;
117
118 do_div(tmp1, tmp);
119
120 __raw_writel(tmp1, reg);
121}
122
123int s5pv210_verify_speed(struct cpufreq_policy *policy)
124{
125 if (policy->cpu)
126 return -EINVAL;
127
128 return cpufreq_frequency_table_verify(policy, s5pv210_freq_table);
129}
130
131unsigned int s5pv210_getspeed(unsigned int cpu)
132{
133 if (cpu)
134 return 0;
135
136 return clk_get_rate(cpu_clk) / 1000;
137}
138
139static int s5pv210_target(struct cpufreq_policy *policy,
140 unsigned int target_freq,
141 unsigned int relation)
142{
143 unsigned long reg;
144 unsigned int index, priv_index;
145 unsigned int pll_changing = 0;
146 unsigned int bus_speed_changing = 0;
147
148 freqs.old = s5pv210_getspeed(0);
149
150 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
151 target_freq, relation, &index))
152 return -EINVAL;
153
154 freqs.new = s5pv210_freq_table[index].frequency;
155 freqs.cpu = 0;
156
157 if (freqs.new == freqs.old)
158 return 0;
159
160 /* Finding current running level index */
161 if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
162 freqs.old, relation, &priv_index))
163 return -EINVAL;
164
165 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
166
167 if (freqs.new > freqs.old) {
168 /* Voltage up: will be implemented */
169 }
170
171 /* Check if there need to change PLL */
172 if ((index == L0) || (priv_index == L0))
173 pll_changing = 1;
174
175 /* Check if there need to change System bus clock */
176 if ((index == L4) || (priv_index == L4))
177 bus_speed_changing = 1;
178
179 if (bus_speed_changing) {
180 /*
181 * Reconfigure DRAM refresh counter value for minimum
182 * temporary clock while changing divider.
183 * expected clock is 83Mhz : 7.8usec/(1/83Mhz) = 0x287
184 */
185 if (pll_changing)
186 s5pv210_set_refresh(DMC1, 83000);
187 else
188 s5pv210_set_refresh(DMC1, 100000);
189
190 s5pv210_set_refresh(DMC0, 83000);
191 }
192
193 /*
194 * APLL should be changed in this level
195 * APLL -> MPLL(for stable transition) -> APLL
196 * Some clock source's clock API are not prepared.
197 * Do not use clock API in below code.
198 */
199 if (pll_changing) {
200 /*
201 * 1. Temporary Change divider for MFC and G3D
202 * SCLKA2M(200/1=200)->(200/4=50)Mhz
203 */
204 reg = __raw_readl(S5P_CLK_DIV2);
205 reg &= ~(S5P_CLKDIV2_G3D_MASK | S5P_CLKDIV2_MFC_MASK);
206 reg |= (3 << S5P_CLKDIV2_G3D_SHIFT) |
207 (3 << S5P_CLKDIV2_MFC_SHIFT);
208 __raw_writel(reg, S5P_CLK_DIV2);
209
210 /* For MFC, G3D dividing */
211 do {
212 reg = __raw_readl(S5P_CLKDIV_STAT0);
213 } while (reg & ((1 << 16) | (1 << 17)));
214
215 /*
216 * 2. Change SCLKA2M(200Mhz)to SCLKMPLL in MFC_MUX, G3D MUX
217 * (200/4=50)->(667/4=166)Mhz
218 */
219 reg = __raw_readl(S5P_CLK_SRC2);
220 reg &= ~(S5P_CLKSRC2_G3D_MASK | S5P_CLKSRC2_MFC_MASK);
221 reg |= (1 << S5P_CLKSRC2_G3D_SHIFT) |
222 (1 << S5P_CLKSRC2_MFC_SHIFT);
223 __raw_writel(reg, S5P_CLK_SRC2);
224
225 do {
226 reg = __raw_readl(S5P_CLKMUX_STAT1);
227 } while (reg & ((1 << 7) | (1 << 3)));
228
229 /*
230 * 3. DMC1 refresh count for 133Mhz if (index == L4) is
231 * true refresh counter is already programed in upper
232 * code. 0x287@83Mhz
233 */
234 if (!bus_speed_changing)
235 s5pv210_set_refresh(DMC1, 133000);
236
237 /* 4. SCLKAPLL -> SCLKMPLL */
238 reg = __raw_readl(S5P_CLK_SRC0);
239 reg &= ~(S5P_CLKSRC0_MUX200_MASK);
240 reg |= (0x1 << S5P_CLKSRC0_MUX200_SHIFT);
241 __raw_writel(reg, S5P_CLK_SRC0);
242
243 do {
244 reg = __raw_readl(S5P_CLKMUX_STAT0);
245 } while (reg & (0x1 << 18));
246
247 }
248
249 /* Change divider */
250 reg = __raw_readl(S5P_CLK_DIV0);
251
252 reg &= ~(S5P_CLKDIV0_APLL_MASK | S5P_CLKDIV0_A2M_MASK |
253 S5P_CLKDIV0_HCLK200_MASK | S5P_CLKDIV0_PCLK100_MASK |
254 S5P_CLKDIV0_HCLK166_MASK | S5P_CLKDIV0_PCLK83_MASK |
255 S5P_CLKDIV0_HCLK133_MASK | S5P_CLKDIV0_PCLK66_MASK);
256
257 reg |= ((clkdiv_val[index][0] << S5P_CLKDIV0_APLL_SHIFT) |
258 (clkdiv_val[index][1] << S5P_CLKDIV0_A2M_SHIFT) |
259 (clkdiv_val[index][2] << S5P_CLKDIV0_HCLK200_SHIFT) |
260 (clkdiv_val[index][3] << S5P_CLKDIV0_PCLK100_SHIFT) |
261 (clkdiv_val[index][4] << S5P_CLKDIV0_HCLK166_SHIFT) |
262 (clkdiv_val[index][5] << S5P_CLKDIV0_PCLK83_SHIFT) |
263 (clkdiv_val[index][6] << S5P_CLKDIV0_HCLK133_SHIFT) |
264 (clkdiv_val[index][7] << S5P_CLKDIV0_PCLK66_SHIFT));
265
266 __raw_writel(reg, S5P_CLK_DIV0);
267
268 do {
269 reg = __raw_readl(S5P_CLKDIV_STAT0);
270 } while (reg & 0xff);
271
272 /* ARM MCS value changed */
273 reg = __raw_readl(S5P_ARM_MCS_CON);
274 reg &= ~0x3;
275 if (index >= L3)
276 reg |= 0x3;
277 else
278 reg |= 0x1;
279
280 __raw_writel(reg, S5P_ARM_MCS_CON);
281
282 if (pll_changing) {
283 /* 5. Set Lock time = 30us*24Mhz = 0x2cf */
284 __raw_writel(0x2cf, S5P_APLL_LOCK);
285
286 /*
287 * 6. Turn on APLL
288 * 6-1. Set PMS values
289 * 6-2. Wait untile the PLL is locked
290 */
291 if (index == L0)
292 __raw_writel(APLL_VAL_1000, S5P_APLL_CON);
293 else
294 __raw_writel(APLL_VAL_800, S5P_APLL_CON);
295
296 do {
297 reg = __raw_readl(S5P_APLL_CON);
298 } while (!(reg & (0x1 << 29)));
299
300 /*
301 * 7. Change souce clock from SCLKMPLL(667Mhz)
302 * to SCLKA2M(200Mhz) in MFC_MUX and G3D MUX
303 * (667/4=166)->(200/4=50)Mhz
304 */
305 reg = __raw_readl(S5P_CLK_SRC2);
306 reg &= ~(S5P_CLKSRC2_G3D_MASK | S5P_CLKSRC2_MFC_MASK);
307 reg |= (0 << S5P_CLKSRC2_G3D_SHIFT) |
308 (0 << S5P_CLKSRC2_MFC_SHIFT);
309 __raw_writel(reg, S5P_CLK_SRC2);
310
311 do {
312 reg = __raw_readl(S5P_CLKMUX_STAT1);
313 } while (reg & ((1 << 7) | (1 << 3)));
314
315 /*
316 * 8. Change divider for MFC and G3D
317 * (200/4=50)->(200/1=200)Mhz
318 */
319 reg = __raw_readl(S5P_CLK_DIV2);
320 reg &= ~(S5P_CLKDIV2_G3D_MASK | S5P_CLKDIV2_MFC_MASK);
321 reg |= (clkdiv_val[index][10] << S5P_CLKDIV2_G3D_SHIFT) |
322 (clkdiv_val[index][9] << S5P_CLKDIV2_MFC_SHIFT);
323 __raw_writel(reg, S5P_CLK_DIV2);
324
325 /* For MFC, G3D dividing */
326 do {
327 reg = __raw_readl(S5P_CLKDIV_STAT0);
328 } while (reg & ((1 << 16) | (1 << 17)));
329
330 /* 9. Change MPLL to APLL in MSYS_MUX */
331 reg = __raw_readl(S5P_CLK_SRC0);
332 reg &= ~(S5P_CLKSRC0_MUX200_MASK);
333 reg |= (0x0 << S5P_CLKSRC0_MUX200_SHIFT);
334 __raw_writel(reg, S5P_CLK_SRC0);
335
336 do {
337 reg = __raw_readl(S5P_CLKMUX_STAT0);
338 } while (reg & (0x1 << 18));
339
340 /*
341 * 10. DMC1 refresh counter
342 * L4 : DMC1 = 100Mhz 7.8us/(1/100) = 0x30c
343 * Others : DMC1 = 200Mhz 7.8us/(1/200) = 0x618
344 */
345 if (!bus_speed_changing)
346 s5pv210_set_refresh(DMC1, 200000);
347 }
348
349 /*
350 * L4 level need to change memory bus speed, hence onedram clock divier
351 * and memory refresh parameter should be changed
352 */
353 if (bus_speed_changing) {
354 reg = __raw_readl(S5P_CLK_DIV6);
355 reg &= ~S5P_CLKDIV6_ONEDRAM_MASK;
356 reg |= (clkdiv_val[index][8] << S5P_CLKDIV6_ONEDRAM_SHIFT);
357 __raw_writel(reg, S5P_CLK_DIV6);
358
359 do {
360 reg = __raw_readl(S5P_CLKDIV_STAT1);
361 } while (reg & (1 << 15));
362
363 /* Reconfigure DRAM refresh counter value */
364 if (index != L4) {
365 /*
366 * DMC0 : 166Mhz
367 * DMC1 : 200Mhz
368 */
369 s5pv210_set_refresh(DMC0, 166000);
370 s5pv210_set_refresh(DMC1, 200000);
371 } else {
372 /*
373 * DMC0 : 83Mhz
374 * DMC1 : 100Mhz
375 */
376 s5pv210_set_refresh(DMC0, 83000);
377 s5pv210_set_refresh(DMC1, 100000);
378 }
379 }
380
381 if (freqs.new < freqs.old) {
382 /* Voltage down: will be implemented */
383 }
384
385 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
386
387 printk(KERN_DEBUG "Perf changed[L%d]\n", index);
388
389 return 0;
390}
391
392#ifdef CONFIG_PM
393static int s5pv210_cpufreq_suspend(struct cpufreq_policy *policy,
394 pm_message_t pmsg)
395{
396 return 0;
397}
398
399static int s5pv210_cpufreq_resume(struct cpufreq_policy *policy)
400{
401 return 0;
402}
403#endif
404
405static int check_mem_type(void __iomem *dmc_reg)
406{
407 unsigned long val;
408
409 val = __raw_readl(dmc_reg + 0x4);
410 val = (val & (0xf << 8));
411
412 return val >> 8;
413}
414
415static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)
416{
417 unsigned long mem_type;
418
419 cpu_clk = clk_get(NULL, "armclk");
420 if (IS_ERR(cpu_clk))
421 return PTR_ERR(cpu_clk);
422
423 dmc0_clk = clk_get(NULL, "sclk_dmc0");
424 if (IS_ERR(dmc0_clk)) {
425 clk_put(cpu_clk);
426 return PTR_ERR(dmc0_clk);
427 }
428
429 dmc1_clk = clk_get(NULL, "hclk_msys");
430 if (IS_ERR(dmc1_clk)) {
431 clk_put(dmc0_clk);
432 clk_put(cpu_clk);
433 return PTR_ERR(dmc1_clk);
434 }
435
436 if (policy->cpu != 0)
437 return -EINVAL;
438
439 /*
440 * check_mem_type : This driver only support LPDDR & LPDDR2.
441 * other memory type is not supported.
442 */
443 mem_type = check_mem_type(S5P_VA_DMC0);
444
445 if ((mem_type != LPDDR) && (mem_type != LPDDR2)) {
446 printk(KERN_ERR "CPUFreq doesn't support this memory type\n");
447 return -EINVAL;
448 }
449
450 /* Find current refresh counter and frequency each DMC */
451 s5pv210_dram_conf[0].refresh = (__raw_readl(S5P_VA_DMC0 + 0x30) * 1000);
452 s5pv210_dram_conf[0].freq = clk_get_rate(dmc0_clk);
453
454 s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000);
455 s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);
456
457 policy->cur = policy->min = policy->max = s5pv210_getspeed(0);
458
459 cpufreq_frequency_table_get_attr(s5pv210_freq_table, policy->cpu);
460
461 policy->cpuinfo.transition_latency = 40000;
462
463 return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table);
464}
465
466static struct cpufreq_driver s5pv210_driver = {
467 .flags = CPUFREQ_STICKY,
468 .verify = s5pv210_verify_speed,
469 .target = s5pv210_target,
470 .get = s5pv210_getspeed,
471 .init = s5pv210_cpu_init,
472 .name = "s5pv210",
473#ifdef CONFIG_PM
474 .suspend = s5pv210_cpufreq_suspend,
475 .resume = s5pv210_cpufreq_resume,
476#endif
477};
478
479static int __init s5pv210_cpufreq_init(void)
480{
481 return cpufreq_register_driver(&s5pv210_driver);
482}
483
484late_initcall(s5pv210_cpufreq_init);
diff --git a/arch/arm/mach-s5pv210/dev-audio.c b/arch/arm/mach-s5pv210/dev-audio.c
index 21dc6cf955c3..1303fcb12b51 100644
--- a/arch/arm/mach-s5pv210/dev-audio.c
+++ b/arch/arm/mach-s5pv210/dev-audio.c
@@ -24,29 +24,15 @@ static int s5pv210_cfg_i2s(struct platform_device *pdev)
24 /* configure GPIO for i2s port */ 24 /* configure GPIO for i2s port */
25 switch (pdev->id) { 25 switch (pdev->id) {
26 case 1: 26 case 1:
27 s3c_gpio_cfgpin(S5PV210_GPC0(0), S3C_GPIO_SFN(2)); 27 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(2));
28 s3c_gpio_cfgpin(S5PV210_GPC0(1), S3C_GPIO_SFN(2));
29 s3c_gpio_cfgpin(S5PV210_GPC0(2), S3C_GPIO_SFN(2));
30 s3c_gpio_cfgpin(S5PV210_GPC0(3), S3C_GPIO_SFN(2));
31 s3c_gpio_cfgpin(S5PV210_GPC0(4), S3C_GPIO_SFN(2));
32 break; 28 break;
33 29
34 case 2: 30 case 2:
35 s3c_gpio_cfgpin(S5PV210_GPC1(0), S3C_GPIO_SFN(4)); 31 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(4));
36 s3c_gpio_cfgpin(S5PV210_GPC1(1), S3C_GPIO_SFN(4));
37 s3c_gpio_cfgpin(S5PV210_GPC1(2), S3C_GPIO_SFN(4));
38 s3c_gpio_cfgpin(S5PV210_GPC1(3), S3C_GPIO_SFN(4));
39 s3c_gpio_cfgpin(S5PV210_GPC1(4), S3C_GPIO_SFN(4));
40 break; 32 break;
41 33
42 case -1: 34 case -1:
43 s3c_gpio_cfgpin(S5PV210_GPI(0), S3C_GPIO_SFN(2)); 35 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 7, S3C_GPIO_SFN(2));
44 s3c_gpio_cfgpin(S5PV210_GPI(1), S3C_GPIO_SFN(2));
45 s3c_gpio_cfgpin(S5PV210_GPI(2), S3C_GPIO_SFN(2));
46 s3c_gpio_cfgpin(S5PV210_GPI(3), S3C_GPIO_SFN(2));
47 s3c_gpio_cfgpin(S5PV210_GPI(4), S3C_GPIO_SFN(2));
48 s3c_gpio_cfgpin(S5PV210_GPI(5), S3C_GPIO_SFN(2));
49 s3c_gpio_cfgpin(S5PV210_GPI(6), S3C_GPIO_SFN(2));
50 break; 36 break;
51 37
52 default: 38 default:
@@ -151,25 +137,13 @@ static int s5pv210_pcm_cfg_gpio(struct platform_device *pdev)
151{ 137{
152 switch (pdev->id) { 138 switch (pdev->id) {
153 case 0: 139 case 0:
154 s3c_gpio_cfgpin(S5PV210_GPI(0), S3C_GPIO_SFN(3)); 140 s3c_gpio_cfgpin_range(S5PV210_GPI(0), 5, S3C_GPIO_SFN(3));
155 s3c_gpio_cfgpin(S5PV210_GPI(1), S3C_GPIO_SFN(3));
156 s3c_gpio_cfgpin(S5PV210_GPI(2), S3C_GPIO_SFN(3));
157 s3c_gpio_cfgpin(S5PV210_GPI(3), S3C_GPIO_SFN(3));
158 s3c_gpio_cfgpin(S5PV210_GPI(4), S3C_GPIO_SFN(3));
159 break; 141 break;
160 case 1: 142 case 1:
161 s3c_gpio_cfgpin(S5PV210_GPC0(0), S3C_GPIO_SFN(3)); 143 s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(3));
162 s3c_gpio_cfgpin(S5PV210_GPC0(1), S3C_GPIO_SFN(3));
163 s3c_gpio_cfgpin(S5PV210_GPC0(2), S3C_GPIO_SFN(3));
164 s3c_gpio_cfgpin(S5PV210_GPC0(3), S3C_GPIO_SFN(3));
165 s3c_gpio_cfgpin(S5PV210_GPC0(4), S3C_GPIO_SFN(3));
166 break; 144 break;
167 case 2: 145 case 2:
168 s3c_gpio_cfgpin(S5PV210_GPC1(0), S3C_GPIO_SFN(2)); 146 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 5, S3C_GPIO_SFN(2));
169 s3c_gpio_cfgpin(S5PV210_GPC1(1), S3C_GPIO_SFN(2));
170 s3c_gpio_cfgpin(S5PV210_GPC1(2), S3C_GPIO_SFN(2));
171 s3c_gpio_cfgpin(S5PV210_GPC1(3), S3C_GPIO_SFN(2));
172 s3c_gpio_cfgpin(S5PV210_GPC1(4), S3C_GPIO_SFN(2));
173 break; 147 break;
174 default: 148 default:
175 printk(KERN_DEBUG "Invalid PCM Controller number!"); 149 printk(KERN_DEBUG "Invalid PCM Controller number!");
@@ -271,13 +245,7 @@ struct platform_device s5pv210_device_pcm2 = {
271 245
272static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev) 246static int s5pv210_ac97_cfg_gpio(struct platform_device *pdev)
273{ 247{
274 s3c_gpio_cfgpin(S5PV210_GPC0(0), S3C_GPIO_SFN(4)); 248 return s3c_gpio_cfgpin_range(S5PV210_GPC0(0), 5, S3C_GPIO_SFN(4));
275 s3c_gpio_cfgpin(S5PV210_GPC0(1), S3C_GPIO_SFN(4));
276 s3c_gpio_cfgpin(S5PV210_GPC0(2), S3C_GPIO_SFN(4));
277 s3c_gpio_cfgpin(S5PV210_GPC0(3), S3C_GPIO_SFN(4));
278 s3c_gpio_cfgpin(S5PV210_GPC0(4), S3C_GPIO_SFN(4));
279
280 return 0;
281} 249}
282 250
283static struct resource s5pv210_ac97_resource[] = { 251static struct resource s5pv210_ac97_resource[] = {
@@ -325,3 +293,43 @@ struct platform_device s5pv210_device_ac97 = {
325 .coherent_dma_mask = DMA_BIT_MASK(32), 293 .coherent_dma_mask = DMA_BIT_MASK(32),
326 }, 294 },
327}; 295};
296
297/* S/PDIF Controller platform_device */
298
299static int s5pv210_spdif_cfg_gpio(struct platform_device *pdev)
300{
301 s3c_gpio_cfgpin_range(S5PV210_GPC1(0), 2, S3C_GPIO_SFN(3));
302
303 return 0;
304}
305
306static struct resource s5pv210_spdif_resource[] = {
307 [0] = {
308 .start = S5PV210_PA_SPDIF,
309 .end = S5PV210_PA_SPDIF + 0x100 - 1,
310 .flags = IORESOURCE_MEM,
311 },
312 [1] = {
313 .start = DMACH_SPDIF,
314 .end = DMACH_SPDIF,
315 .flags = IORESOURCE_DMA,
316 },
317};
318
319static struct s3c_audio_pdata samsung_spdif_pdata = {
320 .cfg_gpio = s5pv210_spdif_cfg_gpio,
321};
322
323static u64 s5pv210_spdif_dmamask = DMA_BIT_MASK(32);
324
325struct platform_device s5pv210_device_spdif = {
326 .name = "samsung-spdif",
327 .id = -1,
328 .num_resources = ARRAY_SIZE(s5pv210_spdif_resource),
329 .resource = s5pv210_spdif_resource,
330 .dev = {
331 .platform_data = &samsung_spdif_pdata,
332 .dma_mask = &s5pv210_spdif_dmamask,
333 .coherent_dma_mask = DMA_BIT_MASK(32),
334 },
335};
diff --git a/arch/arm/mach-s5pv210/dev-spi.c b/arch/arm/mach-s5pv210/dev-spi.c
index 826cdbc43e20..e3249a47e3b1 100644
--- a/arch/arm/mach-s5pv210/dev-spi.c
+++ b/arch/arm/mach-s5pv210/dev-spi.c
@@ -35,23 +35,15 @@ static char *spi_src_clks[] = {
35 */ 35 */
36static int s5pv210_spi_cfg_gpio(struct platform_device *pdev) 36static int s5pv210_spi_cfg_gpio(struct platform_device *pdev)
37{ 37{
38 unsigned int base;
39
38 switch (pdev->id) { 40 switch (pdev->id) {
39 case 0: 41 case 0:
40 s3c_gpio_cfgpin(S5PV210_GPB(0), S3C_GPIO_SFN(2)); 42 base = S5PV210_GPB(0);
41 s3c_gpio_cfgpin(S5PV210_GPB(1), S3C_GPIO_SFN(2));
42 s3c_gpio_cfgpin(S5PV210_GPB(2), S3C_GPIO_SFN(2));
43 s3c_gpio_setpull(S5PV210_GPB(0), S3C_GPIO_PULL_UP);
44 s3c_gpio_setpull(S5PV210_GPB(1), S3C_GPIO_PULL_UP);
45 s3c_gpio_setpull(S5PV210_GPB(2), S3C_GPIO_PULL_UP);
46 break; 43 break;
47 44
48 case 1: 45 case 1:
49 s3c_gpio_cfgpin(S5PV210_GPB(4), S3C_GPIO_SFN(2)); 46 base = S5PV210_GPB(4);
50 s3c_gpio_cfgpin(S5PV210_GPB(5), S3C_GPIO_SFN(2));
51 s3c_gpio_cfgpin(S5PV210_GPB(6), S3C_GPIO_SFN(2));
52 s3c_gpio_setpull(S5PV210_GPB(4), S3C_GPIO_PULL_UP);
53 s3c_gpio_setpull(S5PV210_GPB(5), S3C_GPIO_PULL_UP);
54 s3c_gpio_setpull(S5PV210_GPB(6), S3C_GPIO_PULL_UP);
55 break; 47 break;
56 48
57 default: 49 default:
@@ -59,6 +51,9 @@ static int s5pv210_spi_cfg_gpio(struct platform_device *pdev)
59 return -EINVAL; 51 return -EINVAL;
60 } 52 }
61 53
54 s3c_gpio_cfgall_range(base, 3,
55 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
56
62 return 0; 57 return 0;
63} 58}
64 59
diff --git a/arch/arm/mach-s5pv210/dma.c b/arch/arm/mach-s5pv210/dma.c
index 778ad5fe231a..497d3439a142 100644
--- a/arch/arm/mach-s5pv210/dma.c
+++ b/arch/arm/mach-s5pv210/dma.c
@@ -82,7 +82,7 @@ static struct s3c_pl330_platdata s5pv210_pdma0_pdata = {
82 82
83static struct platform_device s5pv210_device_pdma0 = { 83static struct platform_device s5pv210_device_pdma0 = {
84 .name = "s3c-pl330", 84 .name = "s3c-pl330",
85 .id = 1, 85 .id = 0,
86 .num_resources = ARRAY_SIZE(s5pv210_pdma0_resource), 86 .num_resources = ARRAY_SIZE(s5pv210_pdma0_resource),
87 .resource = s5pv210_pdma0_resource, 87 .resource = s5pv210_pdma0_resource,
88 .dev = { 88 .dev = {
@@ -144,7 +144,7 @@ static struct s3c_pl330_platdata s5pv210_pdma1_pdata = {
144 144
145static struct platform_device s5pv210_device_pdma1 = { 145static struct platform_device s5pv210_device_pdma1 = {
146 .name = "s3c-pl330", 146 .name = "s3c-pl330",
147 .id = 2, 147 .id = 1,
148 .num_resources = ARRAY_SIZE(s5pv210_pdma1_resource), 148 .num_resources = ARRAY_SIZE(s5pv210_pdma1_resource),
149 .resource = s5pv210_pdma1_resource, 149 .resource = s5pv210_pdma1_resource,
150 .dev = { 150 .dev = {
diff --git a/arch/arm/mach-s5pv210/gpiolib.c b/arch/arm/mach-s5pv210/gpiolib.c
index 0d459112d039..ab673effd767 100644
--- a/arch/arm/mach-s5pv210/gpiolib.c
+++ b/arch/arm/mach-s5pv210/gpiolib.c
@@ -150,6 +150,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
150 .label = "GPG3", 150 .label = "GPG3",
151 }, 151 },
152 }, { 152 }, {
153 .config = &gpio_cfg_noint,
153 .chip = { 154 .chip = {
154 .base = S5PV210_GPI(0), 155 .base = S5PV210_GPI(0),
155 .ngpio = S5PV210_GPIO_I_NR, 156 .ngpio = S5PV210_GPIO_I_NR,
@@ -223,34 +224,42 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
223 }, { 224 }, {
224 .base = (S5P_VA_GPIO + 0xC00), 225 .base = (S5P_VA_GPIO + 0xC00),
225 .config = &gpio_cfg_noint, 226 .config = &gpio_cfg_noint,
227 .irq_base = IRQ_EINT(0),
226 .chip = { 228 .chip = {
227 .base = S5PV210_GPH0(0), 229 .base = S5PV210_GPH0(0),
228 .ngpio = S5PV210_GPIO_H0_NR, 230 .ngpio = S5PV210_GPIO_H0_NR,
229 .label = "GPH0", 231 .label = "GPH0",
232 .to_irq = samsung_gpiolib_to_irq,
230 }, 233 },
231 }, { 234 }, {
232 .base = (S5P_VA_GPIO + 0xC20), 235 .base = (S5P_VA_GPIO + 0xC20),
233 .config = &gpio_cfg_noint, 236 .config = &gpio_cfg_noint,
237 .irq_base = IRQ_EINT(8),
234 .chip = { 238 .chip = {
235 .base = S5PV210_GPH1(0), 239 .base = S5PV210_GPH1(0),
236 .ngpio = S5PV210_GPIO_H1_NR, 240 .ngpio = S5PV210_GPIO_H1_NR,
237 .label = "GPH1", 241 .label = "GPH1",
242 .to_irq = samsung_gpiolib_to_irq,
238 }, 243 },
239 }, { 244 }, {
240 .base = (S5P_VA_GPIO + 0xC40), 245 .base = (S5P_VA_GPIO + 0xC40),
241 .config = &gpio_cfg_noint, 246 .config = &gpio_cfg_noint,
247 .irq_base = IRQ_EINT(16),
242 .chip = { 248 .chip = {
243 .base = S5PV210_GPH2(0), 249 .base = S5PV210_GPH2(0),
244 .ngpio = S5PV210_GPIO_H2_NR, 250 .ngpio = S5PV210_GPIO_H2_NR,
245 .label = "GPH2", 251 .label = "GPH2",
252 .to_irq = samsung_gpiolib_to_irq,
246 }, 253 },
247 }, { 254 }, {
248 .base = (S5P_VA_GPIO + 0xC60), 255 .base = (S5P_VA_GPIO + 0xC60),
249 .config = &gpio_cfg_noint, 256 .config = &gpio_cfg_noint,
257 .irq_base = IRQ_EINT(24),
250 .chip = { 258 .chip = {
251 .base = S5PV210_GPH3(0), 259 .base = S5PV210_GPH3(0),
252 .ngpio = S5PV210_GPIO_H3_NR, 260 .ngpio = S5PV210_GPIO_H3_NR,
253 .label = "GPH3", 261 .label = "GPH3",
262 .to_irq = samsung_gpiolib_to_irq,
254 }, 263 },
255 }, 264 },
256}; 265};
@@ -259,11 +268,14 @@ static __init int s5pv210_gpiolib_init(void)
259{ 268{
260 struct s3c_gpio_chip *chip = s5pv210_gpio_4bit; 269 struct s3c_gpio_chip *chip = s5pv210_gpio_4bit;
261 int nr_chips = ARRAY_SIZE(s5pv210_gpio_4bit); 270 int nr_chips = ARRAY_SIZE(s5pv210_gpio_4bit);
271 int gpioint_group = 0;
262 int i = 0; 272 int i = 0;
263 273
264 for (i = 0; i < nr_chips; i++, chip++) { 274 for (i = 0; i < nr_chips; i++, chip++) {
265 if (chip->config == NULL) 275 if (chip->config == NULL) {
266 chip->config = &gpio_cfg; 276 chip->config = &gpio_cfg;
277 chip->group = gpioint_group++;
278 }
267 if (chip->base == NULL) 279 if (chip->base == NULL)
268 chip->base = S5PV210_BANK_BASE(i); 280 chip->base = S5PV210_BANK_BASE(i);
269 } 281 }
diff --git a/arch/arm/mach-s5pv210/include/mach/irqs.h b/arch/arm/mach-s5pv210/include/mach/irqs.h
index e1c020e5a49b..119b95fdc3ce 100644
--- a/arch/arm/mach-s5pv210/include/mach/irqs.h
+++ b/arch/arm/mach-s5pv210/include/mach/irqs.h
@@ -55,8 +55,8 @@
55#define IRQ_SPI1 S5P_IRQ_VIC1(16) 55#define IRQ_SPI1 S5P_IRQ_VIC1(16)
56#define IRQ_SPI2 S5P_IRQ_VIC1(17) 56#define IRQ_SPI2 S5P_IRQ_VIC1(17)
57#define IRQ_IRDA S5P_IRQ_VIC1(18) 57#define IRQ_IRDA S5P_IRQ_VIC1(18)
58#define IRQ_CAN0 S5P_IRQ_VIC1(19) 58#define IRQ_IIC2 S5P_IRQ_VIC1(19)
59#define IRQ_CAN1 S5P_IRQ_VIC1(20) 59#define IRQ_IIC3 S5P_IRQ_VIC1(20)
60#define IRQ_HSIRX S5P_IRQ_VIC1(21) 60#define IRQ_HSIRX S5P_IRQ_VIC1(21)
61#define IRQ_HSITX S5P_IRQ_VIC1(22) 61#define IRQ_HSITX S5P_IRQ_VIC1(22)
62#define IRQ_UHOST S5P_IRQ_VIC1(23) 62#define IRQ_UHOST S5P_IRQ_VIC1(23)
@@ -109,7 +109,7 @@
109 109
110#define IRQ_IPC S5P_IRQ_VIC3(0) 110#define IRQ_IPC S5P_IRQ_VIC3(0)
111#define IRQ_HOSTIF S5P_IRQ_VIC3(1) 111#define IRQ_HOSTIF S5P_IRQ_VIC3(1)
112#define IRQ_MMC3 S5P_IRQ_VIC3(2) 112#define IRQ_HSMMC3 S5P_IRQ_VIC3(2)
113#define IRQ_CEC S5P_IRQ_VIC3(3) 113#define IRQ_CEC S5P_IRQ_VIC3(3)
114#define IRQ_TSI S5P_IRQ_VIC3(4) 114#define IRQ_TSI S5P_IRQ_VIC3(4)
115#define IRQ_MDNIE0 S5P_IRQ_VIC3(5) 115#define IRQ_MDNIE0 S5P_IRQ_VIC3(5)
@@ -121,8 +121,12 @@
121#define S5P_EINT_BASE1 (S5P_IRQ_VIC0(0)) 121#define S5P_EINT_BASE1 (S5P_IRQ_VIC0(0))
122#define S5P_EINT_BASE2 (IRQ_VIC_END + 1) 122#define S5P_EINT_BASE2 (IRQ_VIC_END + 1)
123 123
124/* GPIO interrupt */
125#define S5P_GPIOINT_BASE (IRQ_EINT(31) + 1)
126#define S5P_GPIOINT_GROUP_MAXNR 22
127
124/* Set the default NR_IRQS */ 128/* Set the default NR_IRQS */
125#define NR_IRQS (IRQ_EINT(31) + 1) 129#define NR_IRQS (IRQ_EINT(31) + S5P_GPIOINT_COUNT + 1)
126 130
127/* Compatibility */ 131/* Compatibility */
128#define IRQ_LCD_FIFO IRQ_LCD0 132#define IRQ_LCD_FIFO IRQ_LCD0
diff --git a/arch/arm/mach-s5pv210/include/mach/map.h b/arch/arm/mach-s5pv210/include/mach/map.h
index bd9afd52466a..861d7fe11fc9 100644
--- a/arch/arm/mach-s5pv210/include/mach/map.h
+++ b/arch/arm/mach-s5pv210/include/mach/map.h
@@ -57,6 +57,8 @@
57 57
58#define S5P_SZ_UART SZ_256 58#define S5P_SZ_UART SZ_256
59 59
60#define S3C_VA_UARTx(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET))
61
60#define S5PV210_PA_SROMC (0xE8000000) 62#define S5PV210_PA_SROMC (0xE8000000)
61 63
62#define S5PV210_PA_CFCON (0xE8200000) 64#define S5PV210_PA_CFCON (0xE8200000)
@@ -73,6 +75,9 @@
73 75
74#define S5PV210_PA_HSMMC(x) (0xEB000000 + ((x) * 0x100000)) 76#define S5PV210_PA_HSMMC(x) (0xEB000000 + ((x) * 0x100000))
75 77
78#define S5PV210_PA_HSOTG (0xEC000000)
79#define S5PV210_PA_HSPHY (0xEC100000)
80
76#define S5PV210_PA_VIC0 (0xF2000000) 81#define S5PV210_PA_VIC0 (0xF2000000)
77#define S5PV210_PA_VIC1 (0xF2100000) 82#define S5PV210_PA_VIC1 (0xF2100000)
78#define S5PV210_PA_VIC2 (0xF2200000) 83#define S5PV210_PA_VIC2 (0xF2200000)
@@ -81,6 +86,9 @@
81#define S5PV210_PA_SDRAM (0x20000000) 86#define S5PV210_PA_SDRAM (0x20000000)
82#define S5P_PA_SDRAM S5PV210_PA_SDRAM 87#define S5P_PA_SDRAM S5PV210_PA_SDRAM
83 88
89/* S/PDIF */
90#define S5PV210_PA_SPDIF 0xE1100000
91
84/* I2S */ 92/* I2S */
85#define S5PV210_PA_IIS0 0xEEE30000 93#define S5PV210_PA_IIS0 0xEEE30000
86#define S5PV210_PA_IIS1 0xE2100000 94#define S5PV210_PA_IIS1 0xE2100000
@@ -96,6 +104,9 @@
96 104
97#define S5PV210_PA_ADC (0xE1700000) 105#define S5PV210_PA_ADC (0xE1700000)
98 106
107#define S5PV210_PA_DMC0 (0xF0000000)
108#define S5PV210_PA_DMC1 (0xF1400000)
109
99/* compatibiltiy defines. */ 110/* compatibiltiy defines. */
100#define S3C_PA_UART S5PV210_PA_UART 111#define S3C_PA_UART S5PV210_PA_UART
101#define S3C_PA_HSMMC0 S5PV210_PA_HSMMC(0) 112#define S3C_PA_HSMMC0 S5PV210_PA_HSMMC(0)
@@ -108,6 +119,7 @@
108#define S3C_PA_FB S5PV210_PA_FB 119#define S3C_PA_FB S5PV210_PA_FB
109#define S3C_PA_RTC S5PV210_PA_RTC 120#define S3C_PA_RTC S5PV210_PA_RTC
110#define S3C_PA_WDT S5PV210_PA_WATCHDOG 121#define S3C_PA_WDT S5PV210_PA_WATCHDOG
122#define S3C_PA_USB_HSOTG S5PV210_PA_HSOTG
111#define S5P_PA_FIMC0 S5PV210_PA_FIMC0 123#define S5P_PA_FIMC0 S5PV210_PA_FIMC0
112#define S5P_PA_FIMC1 S5PV210_PA_FIMC1 124#define S5P_PA_FIMC1 S5PV210_PA_FIMC1
113#define S5P_PA_FIMC2 S5PV210_PA_FIMC2 125#define S5P_PA_FIMC2 S5PV210_PA_FIMC2
diff --git a/arch/arm/mach-s5pv210/include/mach/pm-core.h b/arch/arm/mach-s5pv210/include/mach/pm-core.h
new file mode 100644
index 000000000000..e8d394f8b057
--- /dev/null
+++ b/arch/arm/mach-s5pv210/include/mach/pm-core.h
@@ -0,0 +1,43 @@
1/* linux/arch/arm/mach-s5pv210/include/mach/pm-core.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Based on arch/arm/mach-s3c2410/include/mach/pm-core.h,
7 * Copyright 2008 Simtec Electronics
8 * Ben Dooks <ben@simtec.co.uk>
9 * http://armlinux.simtec.co.uk/
10 *
11 * S5PV210 - PM core support for arch/arm/plat-s5p/pm.c
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16*/
17
18static inline void s3c_pm_debug_init_uart(void)
19{
20 /* nothing here yet */
21}
22
23static inline void s3c_pm_arch_prepare_irqs(void)
24{
25 __raw_writel(s3c_irqwake_intmask, S5P_WAKEUP_MASK);
26 __raw_writel(s3c_irqwake_eintmask, S5P_EINT_WAKEUP_MASK);
27}
28
29static inline void s3c_pm_arch_stop_clocks(void)
30{
31 /* nothing here yet */
32}
33
34static inline void s3c_pm_arch_show_resume_irqs(void)
35{
36 /* nothing here yet */
37}
38
39static inline void s3c_pm_arch_update_uart(void __iomem *regs,
40 struct pm_uart_save *save)
41{
42 /* nothing here yet */
43}
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-clock.h b/arch/arm/mach-s5pv210/include/mach/regs-clock.h
index 499aef737476..ebaabe021af9 100644
--- a/arch/arm/mach-s5pv210/include/mach/regs-clock.h
+++ b/arch/arm/mach-s5pv210/include/mach/regs-clock.h
@@ -25,6 +25,7 @@
25#define S5P_APLL_CON S5P_CLKREG(0x100) 25#define S5P_APLL_CON S5P_CLKREG(0x100)
26#define S5P_MPLL_CON S5P_CLKREG(0x108) 26#define S5P_MPLL_CON S5P_CLKREG(0x108)
27#define S5P_EPLL_CON S5P_CLKREG(0x110) 27#define S5P_EPLL_CON S5P_CLKREG(0x110)
28#define S5P_EPLL_CON1 S5P_CLKREG(0x114)
28#define S5P_VPLL_CON S5P_CLKREG(0x120) 29#define S5P_VPLL_CON S5P_CLKREG(0x120)
29 30
30#define S5P_CLK_SRC0 S5P_CLKREG(0x200) 31#define S5P_CLK_SRC0 S5P_CLKREG(0x200)
@@ -67,11 +68,28 @@
67#define S5P_CLKGATE_BUS1 S5P_CLKREG(0x488) 68#define S5P_CLKGATE_BUS1 S5P_CLKREG(0x488)
68#define S5P_CLK_OUT S5P_CLKREG(0x500) 69#define S5P_CLK_OUT S5P_CLKREG(0x500)
69 70
71/* DIV/MUX STATUS */
72#define S5P_CLKDIV_STAT0 S5P_CLKREG(0x1000)
73#define S5P_CLKDIV_STAT1 S5P_CLKREG(0x1004)
74#define S5P_CLKMUX_STAT0 S5P_CLKREG(0x1100)
75#define S5P_CLKMUX_STAT1 S5P_CLKREG(0x1104)
76
70/* CLKSRC0 */ 77/* CLKSRC0 */
71#define S5P_CLKSRC0_MUX200_MASK (0x1<<16) 78#define S5P_CLKSRC0_MUX200_SHIFT (16)
79#define S5P_CLKSRC0_MUX200_MASK (0x1 << S5P_CLKSRC0_MUX200_SHIFT)
72#define S5P_CLKSRC0_MUX166_MASK (0x1<<20) 80#define S5P_CLKSRC0_MUX166_MASK (0x1<<20)
73#define S5P_CLKSRC0_MUX133_MASK (0x1<<24) 81#define S5P_CLKSRC0_MUX133_MASK (0x1<<24)
74 82
83/* CLKSRC2 */
84#define S5P_CLKSRC2_G3D_SHIFT (0)
85#define S5P_CLKSRC2_G3D_MASK (0x3 << S5P_CLKSRC2_G3D_SHIFT)
86#define S5P_CLKSRC2_MFC_SHIFT (4)
87#define S5P_CLKSRC2_MFC_MASK (0x3 << S5P_CLKSRC2_MFC_SHIFT)
88
89/* CLKSRC6*/
90#define S5P_CLKSRC6_ONEDRAM_SHIFT (24)
91#define S5P_CLKSRC6_ONEDRAM_MASK (0x3 << S5P_CLKSRC6_ONEDRAM_SHIFT)
92
75/* CLKDIV0 */ 93/* CLKDIV0 */
76#define S5P_CLKDIV0_APLL_SHIFT (0) 94#define S5P_CLKDIV0_APLL_SHIFT (0)
77#define S5P_CLKDIV0_APLL_MASK (0x7 << S5P_CLKDIV0_APLL_SHIFT) 95#define S5P_CLKDIV0_APLL_MASK (0x7 << S5P_CLKDIV0_APLL_SHIFT)
@@ -90,12 +108,24 @@
90#define S5P_CLKDIV0_PCLK66_SHIFT (28) 108#define S5P_CLKDIV0_PCLK66_SHIFT (28)
91#define S5P_CLKDIV0_PCLK66_MASK (0x7 << S5P_CLKDIV0_PCLK66_SHIFT) 109#define S5P_CLKDIV0_PCLK66_MASK (0x7 << S5P_CLKDIV0_PCLK66_SHIFT)
92 110
111/* CLKDIV2 */
112#define S5P_CLKDIV2_G3D_SHIFT (0)
113#define S5P_CLKDIV2_G3D_MASK (0xF << S5P_CLKDIV2_G3D_SHIFT)
114#define S5P_CLKDIV2_MFC_SHIFT (4)
115#define S5P_CLKDIV2_MFC_MASK (0xF << S5P_CLKDIV2_MFC_SHIFT)
116
117/* CLKDIV6 */
118#define S5P_CLKDIV6_ONEDRAM_SHIFT (28)
119#define S5P_CLKDIV6_ONEDRAM_MASK (0xF << S5P_CLKDIV6_ONEDRAM_SHIFT)
120
93#define S5P_SWRESET S5P_CLKREG(0x2000) 121#define S5P_SWRESET S5P_CLKREG(0x2000)
94 122
123#define S5P_ARM_MCS_CON S5P_CLKREG(0x6100)
124
95/* Registers related to power management */ 125/* Registers related to power management */
96#define S5P_PWR_CFG S5P_CLKREG(0xC000) 126#define S5P_PWR_CFG S5P_CLKREG(0xC000)
97#define S5P_EINT_WAKEUP_MASK S5P_CLKREG(0xC004) 127#define S5P_EINT_WAKEUP_MASK S5P_CLKREG(0xC004)
98#define S5P_WAKEUP_MASK S5P_CLKREG(0xC008) 128#define S5P_WAKEUP_MASK S5P_CLKREG(0xC008)
99#define S5P_PWR_MODE S5P_CLKREG(0xC00C) 129#define S5P_PWR_MODE S5P_CLKREG(0xC00C)
100#define S5P_NORMAL_CFG S5P_CLKREG(0xC010) 130#define S5P_NORMAL_CFG S5P_CLKREG(0xC010)
101#define S5P_IDLE_CFG S5P_CLKREG(0xC020) 131#define S5P_IDLE_CFG S5P_CLKREG(0xC020)
@@ -159,8 +189,11 @@
159#define S5P_SLEEP_CFG_USBOSC_EN (1 << 1) 189#define S5P_SLEEP_CFG_USBOSC_EN (1 << 1)
160 190
161/* OTHERS Resgister */ 191/* OTHERS Resgister */
192#define S5P_OTHERS_RET_IO (1 << 31)
193#define S5P_OTHERS_RET_CF (1 << 30)
194#define S5P_OTHERS_RET_MMC (1 << 29)
195#define S5P_OTHERS_RET_UART (1 << 28)
162#define S5P_OTHERS_USB_SIG_MASK (1 << 16) 196#define S5P_OTHERS_USB_SIG_MASK (1 << 16)
163#define S5P_OTHERS_MIPI_DPHY_EN (1 << 28)
164 197
165/* MIPI */ 198/* MIPI */
166#define S5P_MIPI_DPHY_EN (3) 199#define S5P_MIPI_DPHY_EN (3)
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-gpio.h b/arch/arm/mach-s5pv210/include/mach/regs-gpio.h
index 49e029b4978a..de0c89976078 100644
--- a/arch/arm/mach-s5pv210/include/mach/regs-gpio.h
+++ b/arch/arm/mach-s5pv210/include/mach/regs-gpio.h
@@ -31,13 +31,6 @@
31 31
32#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7)) 32#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7))
33 33
34/* values for S5P_EXTINT0 */
35#define S5P_EXTINT_LOWLEV (0x00)
36#define S5P_EXTINT_HILEV (0x01)
37#define S5P_EXTINT_FALLEDGE (0x02)
38#define S5P_EXTINT_RISEEDGE (0x03)
39#define S5P_EXTINT_BOTHEDGE (0x04)
40
41#define EINT_MODE S3C_GPIO_SFN(0xf) 34#define EINT_MODE S3C_GPIO_SFN(0xf)
42 35
43#define EINT_GPIO_0(x) S5PV210_GPH0(x) 36#define EINT_GPIO_0(x) S5PV210_GPH0(x)
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-sys.h b/arch/arm/mach-s5pv210/include/mach/regs-sys.h
new file mode 100644
index 000000000000..26691d39d0f4
--- /dev/null
+++ b/arch/arm/mach-s5pv210/include/mach/regs-sys.h
@@ -0,0 +1,19 @@
1/* arch/arm/mach-s5pv210/include/mach/regs-sys.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV210 - System registers 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#define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C)
14#define S5PV210_USB_PHY0_EN (1 << 0)
15#define S5PV210_USB_PHY1_EN (1 << 1)
16
17/* compatibility defines for s3c-hsotg driver */
18#define S3C64XX_OTHERS S5PV210_USB_PHY_CON
19#define S3C64XX_OTHERS_USBMASK S5PV210_USB_PHY0_EN
diff --git a/arch/arm/mach-s5pv210/include/mach/vmalloc.h b/arch/arm/mach-s5pv210/include/mach/vmalloc.h
index df9a28808323..a6c659d68a5d 100644
--- a/arch/arm/mach-s5pv210/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5pv210/include/mach/vmalloc.h
@@ -17,6 +17,6 @@
17#ifndef __ASM_ARCH_VMALLOC_H 17#ifndef __ASM_ARCH_VMALLOC_H
18#define __ASM_ARCH_VMALLOC_H __FILE__ 18#define __ASM_ARCH_VMALLOC_H __FILE__
19 19
20#define VMALLOC_END (0xE0000000UL) 20#define VMALLOC_END 0xF6000000UL
21 21
22#endif /* __ASM_ARCH_VMALLOC_H */ 22#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index 00883087363c..28677caf3613 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -16,6 +16,8 @@
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
18#include <linux/mfd/max8998.h> 18#include <linux/mfd/max8998.h>
19#include <linux/mfd/wm8994/pdata.h>
20#include <linux/regulator/fixed.h>
19#include <linux/gpio_keys.h> 21#include <linux/gpio_keys.h>
20#include <linux/input.h> 22#include <linux/input.h>
21#include <linux/gpio.h> 23#include <linux/gpio.h>
@@ -379,6 +381,119 @@ static struct max8998_platform_data aquila_max8998_pdata = {
379}; 381};
380#endif 382#endif
381 383
384static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = {
385 {
386 .dev_name = "5-001a",
387 .supply = "DBVDD",
388 }, {
389 .dev_name = "5-001a",
390 .supply = "AVDD2",
391 }, {
392 .dev_name = "5-001a",
393 .supply = "CPVDD",
394 },
395};
396
397static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = {
398 {
399 .dev_name = "5-001a",
400 .supply = "SPKVDD1",
401 }, {
402 .dev_name = "5-001a",
403 .supply = "SPKVDD2",
404 },
405};
406
407static struct regulator_init_data wm8994_fixed_voltage0_init_data = {
408 .constraints = {
409 .always_on = 1,
410 },
411 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage0_supplies),
412 .consumer_supplies = wm8994_fixed_voltage0_supplies,
413};
414
415static struct regulator_init_data wm8994_fixed_voltage1_init_data = {
416 .constraints = {
417 .always_on = 1,
418 },
419 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage1_supplies),
420 .consumer_supplies = wm8994_fixed_voltage1_supplies,
421};
422
423static struct fixed_voltage_config wm8994_fixed_voltage0_config = {
424 .supply_name = "VCC_1.8V_PDA",
425 .microvolts = 1800000,
426 .gpio = -EINVAL,
427 .init_data = &wm8994_fixed_voltage0_init_data,
428};
429
430static struct fixed_voltage_config wm8994_fixed_voltage1_config = {
431 .supply_name = "V_BAT",
432 .microvolts = 3700000,
433 .gpio = -EINVAL,
434 .init_data = &wm8994_fixed_voltage1_init_data,
435};
436
437static struct platform_device wm8994_fixed_voltage0 = {
438 .name = "reg-fixed-voltage",
439 .id = 0,
440 .dev = {
441 .platform_data = &wm8994_fixed_voltage0_config,
442 },
443};
444
445static struct platform_device wm8994_fixed_voltage1 = {
446 .name = "reg-fixed-voltage",
447 .id = 1,
448 .dev = {
449 .platform_data = &wm8994_fixed_voltage1_config,
450 },
451};
452
453static struct regulator_consumer_supply wm8994_avdd1_supply = {
454 .dev_name = "5-001a",
455 .supply = "AVDD1",
456};
457
458static struct regulator_consumer_supply wm8994_dcvdd_supply = {
459 .dev_name = "5-001a",
460 .supply = "DCVDD",
461};
462
463static struct regulator_init_data wm8994_ldo1_data = {
464 .constraints = {
465 .name = "AVDD1_3.0V",
466 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
467 },
468 .num_consumer_supplies = 1,
469 .consumer_supplies = &wm8994_avdd1_supply,
470};
471
472static struct regulator_init_data wm8994_ldo2_data = {
473 .constraints = {
474 .name = "DCVDD_1.0V",
475 },
476 .num_consumer_supplies = 1,
477 .consumer_supplies = &wm8994_dcvdd_supply,
478};
479
480static struct wm8994_pdata wm8994_platform_data = {
481 /* configure gpio1 function: 0x0001(Logic level input/output) */
482 .gpio_defaults[0] = 0x0001,
483 /* configure gpio3/4/5/7 function for AIF2 voice */
484 .gpio_defaults[2] = 0x8100,
485 .gpio_defaults[3] = 0x8100,
486 .gpio_defaults[4] = 0x8100,
487 .gpio_defaults[6] = 0x0100,
488 /* configure gpio8/9/10/11 function for AIF3 BT */
489 .gpio_defaults[7] = 0x8100,
490 .gpio_defaults[8] = 0x0100,
491 .gpio_defaults[9] = 0x0100,
492 .gpio_defaults[10] = 0x0100,
493 .ldo[0] = { S5PV210_MP03(6), NULL, &wm8994_ldo1_data }, /* XM0FRNB_2 */
494 .ldo[1] = { 0, NULL, &wm8994_ldo2_data },
495};
496
382/* GPIO I2C PMIC */ 497/* GPIO I2C PMIC */
383#define AP_I2C_GPIO_PMIC_BUS_4 4 498#define AP_I2C_GPIO_PMIC_BUS_4 4
384static struct i2c_gpio_platform_data aquila_i2c_gpio_pmic_data = { 499static struct i2c_gpio_platform_data aquila_i2c_gpio_pmic_data = {
@@ -404,6 +519,29 @@ static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = {
404#endif 519#endif
405}; 520};
406 521
522/* GPIO I2C AP 1.8V */
523#define AP_I2C_GPIO_BUS_5 5
524static struct i2c_gpio_platform_data aquila_i2c_gpio5_data = {
525 .sda_pin = S5PV210_MP05(3), /* XM0ADDR_11 */
526 .scl_pin = S5PV210_MP05(2), /* XM0ADDR_10 */
527};
528
529static struct platform_device aquila_i2c_gpio5 = {
530 .name = "i2c-gpio",
531 .id = AP_I2C_GPIO_BUS_5,
532 .dev = {
533 .platform_data = &aquila_i2c_gpio5_data,
534 },
535};
536
537static struct i2c_board_info i2c_gpio5_devs[] __initdata = {
538 {
539 /* CS/ADDR = low 0x34 (FYI: high = 0x36) */
540 I2C_BOARD_INFO("wm8994", 0x1a),
541 .platform_data = &wm8994_platform_data,
542 },
543};
544
407/* PMIC Power button */ 545/* PMIC Power button */
408static struct gpio_keys_button aquila_gpio_keys_table[] = { 546static struct gpio_keys_button aquila_gpio_keys_table[] = {
409 { 547 {
@@ -475,6 +613,7 @@ static void aquila_setup_sdhci(void)
475 613
476static struct platform_device *aquila_devices[] __initdata = { 614static struct platform_device *aquila_devices[] __initdata = {
477 &aquila_i2c_gpio_pmic, 615 &aquila_i2c_gpio_pmic,
616 &aquila_i2c_gpio5,
478 &aquila_device_gpiokeys, 617 &aquila_device_gpiokeys,
479 &s3c_device_fb, 618 &s3c_device_fb,
480 &s5p_device_onenand, 619 &s5p_device_onenand,
@@ -484,8 +623,33 @@ static struct platform_device *aquila_devices[] __initdata = {
484 &s5p_device_fimc0, 623 &s5p_device_fimc0,
485 &s5p_device_fimc1, 624 &s5p_device_fimc1,
486 &s5p_device_fimc2, 625 &s5p_device_fimc2,
626 &s5pv210_device_iis0,
627 &wm8994_fixed_voltage0,
628 &wm8994_fixed_voltage1,
487}; 629};
488 630
631static void __init aquila_sound_init(void)
632{
633 unsigned int gpio;
634
635 /* CODEC_XTAL_EN
636 *
637 * The Aquila board have a oscillator which provide main clock
638 * to WM8994 codec. The oscillator provide 24MHz clock to WM8994
639 * clock. Set gpio setting of "CODEC_XTAL_EN" to enable a oscillator.
640 * */
641 gpio = S5PV210_GPH3(2); /* XEINT_26 */
642 gpio_request(gpio, "CODEC_XTAL_EN");
643 s3c_gpio_cfgpin(gpio, S3C_GPIO_OUTPUT);
644 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
645
646 /* Ths main clock of WM8994 codec uses the output of CLKOUT pin.
647 * The CLKOUT[9:8] set to 0x3(XUSBXTI) of 0xE010E000(OTHERS)
648 * because it needs 24MHz clock to operate WM8994 codec.
649 */
650 __raw_writel(__raw_readl(S5P_OTHERS) | (0x3 << 8), S5P_OTHERS);
651}
652
489static void __init aquila_map_io(void) 653static void __init aquila_map_io(void)
490{ 654{
491 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 655 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -506,6 +670,11 @@ static void __init aquila_machine_init(void)
506 s3c_fimc_setname(1, "s5p-fimc"); 670 s3c_fimc_setname(1, "s5p-fimc");
507 s3c_fimc_setname(2, "s5p-fimc"); 671 s3c_fimc_setname(2, "s5p-fimc");
508 672
673 /* SOUND */
674 aquila_sound_init();
675 i2c_register_board_info(AP_I2C_GPIO_BUS_5, i2c_gpio5_devs,
676 ARRAY_SIZE(i2c_gpio5_devs));
677
509 /* FB */ 678 /* FB */
510 s3c_fb_set_platdata(&aquila_lcd_pdata); 679 s3c_fb_set_platdata(&aquila_lcd_pdata);
511 680
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index d9ecf57fc2a5..b1dcf964a768 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -15,7 +15,13 @@
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
18#include <linux/i2c/qt602240_ts.h>
18#include <linux/mfd/max8998.h> 19#include <linux/mfd/max8998.h>
20#include <linux/mfd/wm8994/pdata.h>
21#include <linux/regulator/fixed.h>
22#include <linux/spi/spi.h>
23#include <linux/spi/spi_gpio.h>
24#include <linux/lcd.h>
19#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
20#include <linux/input.h> 26#include <linux/input.h>
21#include <linux/gpio.h> 27#include <linux/gpio.h>
@@ -35,7 +41,10 @@
35#include <plat/devs.h> 41#include <plat/devs.h>
36#include <plat/cpu.h> 42#include <plat/cpu.h>
37#include <plat/fb.h> 43#include <plat/fb.h>
44#include <plat/iic.h>
45#include <plat/keypad.h>
38#include <plat/sdhci.h> 46#include <plat/sdhci.h>
47#include <plat/clock.h>
39 48
40/* Following are default values for UCON, ULCON and UFCON UART registers */ 49/* Following are default values for UCON, ULCON and UFCON UART registers */
41#define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 50#define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -87,13 +96,12 @@ static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = {
87/* Frame Buffer */ 96/* Frame Buffer */
88static struct s3c_fb_pd_win goni_fb_win0 = { 97static struct s3c_fb_pd_win goni_fb_win0 = {
89 .win_mode = { 98 .win_mode = {
90 .pixclock = 1000000000000ULL / ((16+16+2+480)*(28+3+2+800)*55),
91 .left_margin = 16, 99 .left_margin = 16,
92 .right_margin = 16, 100 .right_margin = 16,
93 .upper_margin = 3, 101 .upper_margin = 2,
94 .lower_margin = 28, 102 .lower_margin = 28,
95 .hsync_len = 2, 103 .hsync_len = 2,
96 .vsync_len = 2, 104 .vsync_len = 1,
97 .xres = 480, 105 .xres = 480,
98 .yres = 800, 106 .yres = 800,
99 .refresh = 55, 107 .refresh = 55,
@@ -111,9 +119,160 @@ static struct s3c_fb_platdata goni_lcd_pdata __initdata = {
111 .setup_gpio = s5pv210_fb_gpio_setup_24bpp, 119 .setup_gpio = s5pv210_fb_gpio_setup_24bpp,
112}; 120};
113 121
122static int lcd_power_on(struct lcd_device *ld, int enable)
123{
124 return 1;
125}
126
127static int reset_lcd(struct lcd_device *ld)
128{
129 static unsigned int first = 1;
130 int reset_gpio = -1;
131
132 reset_gpio = S5PV210_MP05(5);
133
134 if (first) {
135 gpio_request(reset_gpio, "MLCD_RST");
136 first = 0;
137 }
138
139 gpio_direction_output(reset_gpio, 1);
140 return 1;
141}
142
143static struct lcd_platform_data goni_lcd_platform_data = {
144 .reset = reset_lcd,
145 .power_on = lcd_power_on,
146 .lcd_enabled = 0,
147 .reset_delay = 120, /* 120ms */
148 .power_on_delay = 25, /* 25ms */
149 .power_off_delay = 200, /* 200ms */
150};
151
152#define LCD_BUS_NUM 3
153static struct spi_board_info spi_board_info[] __initdata = {
154 {
155 .modalias = "s6e63m0",
156 .platform_data = &goni_lcd_platform_data,
157 .max_speed_hz = 1200000,
158 .bus_num = LCD_BUS_NUM,
159 .chip_select = 0,
160 .mode = SPI_MODE_3,
161 .controller_data = (void *)S5PV210_MP01(1), /* DISPLAY_CS */
162 },
163};
164
165static struct spi_gpio_platform_data lcd_spi_gpio_data = {
166 .sck = S5PV210_MP04(1), /* DISPLAY_CLK */
167 .mosi = S5PV210_MP04(3), /* DISPLAY_SI */
168 .miso = SPI_GPIO_NO_MISO,
169 .num_chipselect = 1,
170};
171
172static struct platform_device goni_spi_gpio = {
173 .name = "spi_gpio",
174 .id = LCD_BUS_NUM,
175 .dev = {
176 .parent = &s3c_device_fb.dev,
177 .platform_data = &lcd_spi_gpio_data,
178 },
179};
180
181/* KEYPAD */
182static uint32_t keymap[] __initdata = {
183 /* KEY(row, col, keycode) */
184 KEY(0, 1, KEY_MENU), /* Send */
185 KEY(0, 2, KEY_BACK), /* End */
186 KEY(1, 1, KEY_CONFIG), /* Half shot */
187 KEY(1, 2, KEY_VOLUMEUP),
188 KEY(2, 1, KEY_CAMERA), /* Full shot */
189 KEY(2, 2, KEY_VOLUMEDOWN),
190};
191
192static struct matrix_keymap_data keymap_data __initdata = {
193 .keymap = keymap,
194 .keymap_size = ARRAY_SIZE(keymap),
195};
196
197static struct samsung_keypad_platdata keypad_data __initdata = {
198 .keymap_data = &keymap_data,
199 .rows = 3,
200 .cols = 3,
201};
202
203/* Radio */
204static struct i2c_board_info i2c1_devs[] __initdata = {
205 {
206 I2C_BOARD_INFO("si470x", 0x10),
207 },
208};
209
210static void __init goni_radio_init(void)
211{
212 int gpio;
213
214 gpio = S5PV210_GPJ2(4); /* XMSMDATA_4 */
215 gpio_request(gpio, "FM_INT");
216 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
217 i2c1_devs[0].irq = gpio_to_irq(gpio);
218
219 gpio = S5PV210_GPJ2(5); /* XMSMDATA_5 */
220 gpio_request(gpio, "FM_RST");
221 gpio_direction_output(gpio, 1);
222}
223
224/* TSP */
225static struct qt602240_platform_data qt602240_platform_data = {
226 .x_line = 17,
227 .y_line = 11,
228 .x_size = 800,
229 .y_size = 480,
230 .blen = 0x21,
231 .threshold = 0x28,
232 .voltage = 2800000, /* 2.8V */
233 .orient = QT602240_DIAGONAL,
234};
235
236static struct s3c2410_platform_i2c i2c2_data __initdata = {
237 .flags = 0,
238 .bus_num = 2,
239 .slave_addr = 0x10,
240 .frequency = 400 * 1000,
241 .sda_delay = 100,
242};
243
244static struct i2c_board_info i2c2_devs[] __initdata = {
245 {
246 I2C_BOARD_INFO("qt602240_ts", 0x4a),
247 .platform_data = &qt602240_platform_data,
248 },
249};
250
251static void __init goni_tsp_init(void)
252{
253 int gpio;
254
255 gpio = S5PV210_GPJ1(3); /* XMSMADDR_11 */
256 gpio_request(gpio, "TSP_LDO_ON");
257 gpio_direction_output(gpio, 1);
258 gpio_export(gpio, 0);
259
260 gpio = S5PV210_GPJ0(5); /* XMSMADDR_5 */
261 gpio_request(gpio, "TSP_INT");
262
263 s5p_register_gpio_interrupt(gpio);
264 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
265 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
266 i2c2_devs[0].irq = gpio_to_irq(gpio);
267}
268
114/* MAX8998 regulators */ 269/* MAX8998 regulators */
115#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE) 270#if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
116 271
272static struct regulator_consumer_supply goni_ldo5_consumers[] = {
273 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
274};
275
117static struct regulator_init_data goni_ldo2_data = { 276static struct regulator_init_data goni_ldo2_data = {
118 .constraints = { 277 .constraints = {
119 .name = "VALIVE_1.1V", 278 .name = "VALIVE_1.1V",
@@ -153,6 +312,8 @@ static struct regulator_init_data goni_ldo5_data = {
153 .max_uV = 2800000, 312 .max_uV = 2800000,
154 .apply_uV = 1, 313 .apply_uV = 1,
155 }, 314 },
315 .num_consumer_supplies = ARRAY_SIZE(goni_ldo5_consumers),
316 .consumer_supplies = goni_ldo5_consumers,
156}; 317};
157 318
158static struct regulator_init_data goni_ldo6_data = { 319static struct regulator_init_data goni_ldo6_data = {
@@ -360,6 +521,119 @@ static struct max8998_platform_data goni_max8998_pdata = {
360}; 521};
361#endif 522#endif
362 523
524static struct regulator_consumer_supply wm8994_fixed_voltage0_supplies[] = {
525 {
526 .dev_name = "5-001a",
527 .supply = "DBVDD",
528 }, {
529 .dev_name = "5-001a",
530 .supply = "AVDD2",
531 }, {
532 .dev_name = "5-001a",
533 .supply = "CPVDD",
534 },
535};
536
537static struct regulator_consumer_supply wm8994_fixed_voltage1_supplies[] = {
538 {
539 .dev_name = "5-001a",
540 .supply = "SPKVDD1",
541 }, {
542 .dev_name = "5-001a",
543 .supply = "SPKVDD2",
544 },
545};
546
547static struct regulator_init_data wm8994_fixed_voltage0_init_data = {
548 .constraints = {
549 .always_on = 1,
550 },
551 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage0_supplies),
552 .consumer_supplies = wm8994_fixed_voltage0_supplies,
553};
554
555static struct regulator_init_data wm8994_fixed_voltage1_init_data = {
556 .constraints = {
557 .always_on = 1,
558 },
559 .num_consumer_supplies = ARRAY_SIZE(wm8994_fixed_voltage1_supplies),
560 .consumer_supplies = wm8994_fixed_voltage1_supplies,
561};
562
563static struct fixed_voltage_config wm8994_fixed_voltage0_config = {
564 .supply_name = "VCC_1.8V_PDA",
565 .microvolts = 1800000,
566 .gpio = -EINVAL,
567 .init_data = &wm8994_fixed_voltage0_init_data,
568};
569
570static struct fixed_voltage_config wm8994_fixed_voltage1_config = {
571 .supply_name = "V_BAT",
572 .microvolts = 3700000,
573 .gpio = -EINVAL,
574 .init_data = &wm8994_fixed_voltage1_init_data,
575};
576
577static struct platform_device wm8994_fixed_voltage0 = {
578 .name = "reg-fixed-voltage",
579 .id = 0,
580 .dev = {
581 .platform_data = &wm8994_fixed_voltage0_config,
582 },
583};
584
585static struct platform_device wm8994_fixed_voltage1 = {
586 .name = "reg-fixed-voltage",
587 .id = 1,
588 .dev = {
589 .platform_data = &wm8994_fixed_voltage1_config,
590 },
591};
592
593static struct regulator_consumer_supply wm8994_avdd1_supply = {
594 .dev_name = "5-001a",
595 .supply = "AVDD1",
596};
597
598static struct regulator_consumer_supply wm8994_dcvdd_supply = {
599 .dev_name = "5-001a",
600 .supply = "DCVDD",
601};
602
603static struct regulator_init_data wm8994_ldo1_data = {
604 .constraints = {
605 .name = "AVDD1_3.0V",
606 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
607 },
608 .num_consumer_supplies = 1,
609 .consumer_supplies = &wm8994_avdd1_supply,
610};
611
612static struct regulator_init_data wm8994_ldo2_data = {
613 .constraints = {
614 .name = "DCVDD_1.0V",
615 },
616 .num_consumer_supplies = 1,
617 .consumer_supplies = &wm8994_dcvdd_supply,
618};
619
620static struct wm8994_pdata wm8994_platform_data = {
621 /* configure gpio1 function: 0x0001(Logic level input/output) */
622 .gpio_defaults[0] = 0x0001,
623 /* configure gpio3/4/5/7 function for AIF2 voice */
624 .gpio_defaults[2] = 0x8100,
625 .gpio_defaults[3] = 0x8100,
626 .gpio_defaults[4] = 0x8100,
627 .gpio_defaults[6] = 0x0100,
628 /* configure gpio8/9/10/11 function for AIF3 BT */
629 .gpio_defaults[7] = 0x8100,
630 .gpio_defaults[8] = 0x0100,
631 .gpio_defaults[9] = 0x0100,
632 .gpio_defaults[10] = 0x0100,
633 .ldo[0] = { S5PV210_MP03(6), NULL, &wm8994_ldo1_data }, /* XM0FRNB_2 */
634 .ldo[1] = { 0, NULL, &wm8994_ldo2_data },
635};
636
363/* GPIO I2C PMIC */ 637/* GPIO I2C PMIC */
364#define AP_I2C_GPIO_PMIC_BUS_4 4 638#define AP_I2C_GPIO_PMIC_BUS_4 4
365static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = { 639static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = {
@@ -385,6 +659,29 @@ static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = {
385#endif 659#endif
386}; 660};
387 661
662/* GPIO I2C AP 1.8V */
663#define AP_I2C_GPIO_BUS_5 5
664static struct i2c_gpio_platform_data goni_i2c_gpio5_data = {
665 .sda_pin = S5PV210_MP05(3), /* XM0ADDR_11 */
666 .scl_pin = S5PV210_MP05(2), /* XM0ADDR_10 */
667};
668
669static struct platform_device goni_i2c_gpio5 = {
670 .name = "i2c-gpio",
671 .id = AP_I2C_GPIO_BUS_5,
672 .dev = {
673 .platform_data = &goni_i2c_gpio5_data,
674 },
675};
676
677static struct i2c_board_info i2c_gpio5_devs[] __initdata = {
678 {
679 /* CS/ADDR = low 0x34 (FYI: high = 0x36) */
680 I2C_BOARD_INFO("wm8994", 0x1a),
681 .platform_data = &wm8994_platform_data,
682 },
683};
684
388/* PMIC Power button */ 685/* PMIC Power button */
389static struct gpio_keys_button goni_gpio_keys_table[] = { 686static struct gpio_keys_button goni_gpio_keys_table[] = {
390 { 687 {
@@ -444,11 +741,37 @@ static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = {
444 .ext_cd_gpio_invert = 1, 741 .ext_cd_gpio_invert = 1,
445}; 742};
446 743
744static struct regulator_consumer_supply mmc2_supplies[] = {
745 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"),
746};
747
748static struct regulator_init_data mmc2_fixed_voltage_init_data = {
749 .constraints = {
750 .name = "V_TF_2.8V",
751 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
752 },
753 .num_consumer_supplies = ARRAY_SIZE(mmc2_supplies),
754 .consumer_supplies = mmc2_supplies,
755};
756
757static struct fixed_voltage_config mmc2_fixed_voltage_config = {
758 .supply_name = "EXT_FLASH_EN",
759 .microvolts = 2800000,
760 .gpio = GONI_EXT_FLASH_EN,
761 .enable_high = true,
762 .init_data = &mmc2_fixed_voltage_init_data,
763};
764
765static struct platform_device mmc2_fixed_voltage = {
766 .name = "reg-fixed-voltage",
767 .id = 2,
768 .dev = {
769 .platform_data = &mmc2_fixed_voltage_config,
770 },
771};
772
447static void goni_setup_sdhci(void) 773static void goni_setup_sdhci(void)
448{ 774{
449 gpio_request(GONI_EXT_FLASH_EN, "FLASH_EN");
450 gpio_direction_output(GONI_EXT_FLASH_EN, 1);
451
452 s3c_sdhci0_set_platdata(&goni_hsmmc0_data); 775 s3c_sdhci0_set_platdata(&goni_hsmmc0_data);
453 s3c_sdhci1_set_platdata(&goni_hsmmc1_data); 776 s3c_sdhci1_set_platdata(&goni_hsmmc1_data);
454 s3c_sdhci2_set_platdata(&goni_hsmmc2_data); 777 s3c_sdhci2_set_platdata(&goni_hsmmc2_data);
@@ -457,7 +780,10 @@ static void goni_setup_sdhci(void)
457static struct platform_device *goni_devices[] __initdata = { 780static struct platform_device *goni_devices[] __initdata = {
458 &s3c_device_fb, 781 &s3c_device_fb,
459 &s5p_device_onenand, 782 &s5p_device_onenand,
783 &goni_spi_gpio,
460 &goni_i2c_gpio_pmic, 784 &goni_i2c_gpio_pmic,
785 &goni_i2c_gpio5,
786 &mmc2_fixed_voltage,
461 &goni_device_gpiokeys, 787 &goni_device_gpiokeys,
462 &s5p_device_fimc0, 788 &s5p_device_fimc0,
463 &s5p_device_fimc1, 789 &s5p_device_fimc1,
@@ -465,8 +791,24 @@ static struct platform_device *goni_devices[] __initdata = {
465 &s3c_device_hsmmc0, 791 &s3c_device_hsmmc0,
466 &s3c_device_hsmmc1, 792 &s3c_device_hsmmc1,
467 &s3c_device_hsmmc2, 793 &s3c_device_hsmmc2,
794 &s5pv210_device_iis0,
795 &s3c_device_usb_hsotg,
796 &samsung_device_keypad,
797 &s3c_device_i2c1,
798 &s3c_device_i2c2,
799 &wm8994_fixed_voltage0,
800 &wm8994_fixed_voltage1,
468}; 801};
469 802
803static void __init goni_sound_init(void)
804{
805 /* Ths main clock of WM8994 codec uses the output of CLKOUT pin.
806 * The CLKOUT[9:8] set to 0x3(XUSBXTI) of 0xE010E000(OTHERS)
807 * because it needs 24MHz clock to operate WM8994 codec.
808 */
809 __raw_writel(__raw_readl(S5P_OTHERS) | (0x3 << 8), S5P_OTHERS);
810}
811
470static void __init goni_map_io(void) 812static void __init goni_map_io(void)
471{ 813{
472 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 814 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -476,6 +818,20 @@ static void __init goni_map_io(void)
476 818
477static void __init goni_machine_init(void) 819static void __init goni_machine_init(void)
478{ 820{
821 /* Radio: call before I2C 1 registeration */
822 goni_radio_init();
823
824 /* I2C1 */
825 s3c_i2c1_set_platdata(NULL);
826 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
827
828 /* TSP: call before I2C 2 registeration */
829 goni_tsp_init();
830
831 /* I2C2 */
832 s3c_i2c2_set_platdata(&i2c2_data);
833 i2c_register_board_info(2, i2c2_devs, ARRAY_SIZE(i2c2_devs));
834
479 /* PMIC */ 835 /* PMIC */
480 goni_pmic_init(); 836 goni_pmic_init();
481 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs, 837 i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs,
@@ -483,9 +839,22 @@ static void __init goni_machine_init(void)
483 /* SDHCI */ 839 /* SDHCI */
484 goni_setup_sdhci(); 840 goni_setup_sdhci();
485 841
842 /* SOUND */
843 goni_sound_init();
844 i2c_register_board_info(AP_I2C_GPIO_BUS_5, i2c_gpio5_devs,
845 ARRAY_SIZE(i2c_gpio5_devs));
846
486 /* FB */ 847 /* FB */
487 s3c_fb_set_platdata(&goni_lcd_pdata); 848 s3c_fb_set_platdata(&goni_lcd_pdata);
488 849
850 /* SPI */
851 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
852
853 /* KEYPAD */
854 samsung_keypad_set_platdata(&keypad_data);
855
856 clk_xusbxti.rate = 24000000;
857
489 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices)); 858 platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
490} 859}
491 860
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index cea9bca79d88..0ad7924fe62e 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -28,6 +28,7 @@
28#include <plat/cpu.h> 28#include <plat/cpu.h>
29#include <plat/ata.h> 29#include <plat/ata.h>
30#include <plat/iic.h> 30#include <plat/iic.h>
31#include <plat/pm.h>
31 32
32/* Following are default values for UCON, ULCON and UFCON UART registers */ 33/* Following are default values for UCON, ULCON and UFCON UART registers */
33#define SMDKC110_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 34#define SMDKC110_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -81,6 +82,7 @@ static struct s3c_ide_platdata smdkc110_ide_pdata __initdata = {
81static struct platform_device *smdkc110_devices[] __initdata = { 82static struct platform_device *smdkc110_devices[] __initdata = {
82 &s5pv210_device_iis0, 83 &s5pv210_device_iis0,
83 &s5pv210_device_ac97, 84 &s5pv210_device_ac97,
85 &s5pv210_device_spdif,
84 &s3c_device_cfcon, 86 &s3c_device_cfcon,
85 &s3c_device_i2c0, 87 &s3c_device_i2c0,
86 &s3c_device_i2c1, 88 &s3c_device_i2c1,
@@ -110,6 +112,8 @@ static void __init smdkc110_map_io(void)
110 112
111static void __init smdkc110_machine_init(void) 113static void __init smdkc110_machine_init(void)
112{ 114{
115 s3c_pm_init();
116
113 s3c_i2c0_set_platdata(NULL); 117 s3c_i2c0_set_platdata(NULL);
114 s3c_i2c1_set_platdata(NULL); 118 s3c_i2c1_set_platdata(NULL);
115 s3c_i2c2_set_platdata(NULL); 119 s3c_i2c2_set_platdata(NULL);
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index 83189ae9da9a..bcd7a5d53401 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -31,6 +31,7 @@
31#include <plat/ata.h> 31#include <plat/ata.h>
32#include <plat/iic.h> 32#include <plat/iic.h>
33#include <plat/keypad.h> 33#include <plat/keypad.h>
34#include <plat/pm.h>
34 35
35/* Following are default values for UCON, ULCON and UFCON UART registers */ 36/* Following are default values for UCON, ULCON and UFCON UART registers */
36#define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 37#define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -103,6 +104,7 @@ static struct samsung_keypad_platdata smdkv210_keypad_data __initdata = {
103static struct platform_device *smdkv210_devices[] __initdata = { 104static struct platform_device *smdkv210_devices[] __initdata = {
104 &s5pv210_device_iis0, 105 &s5pv210_device_iis0,
105 &s5pv210_device_ac97, 106 &s5pv210_device_ac97,
107 &s5pv210_device_spdif,
106 &s3c_device_adc, 108 &s3c_device_adc,
107 &s3c_device_cfcon, 109 &s3c_device_cfcon,
108 &s3c_device_hsmmc0, 110 &s3c_device_hsmmc0,
@@ -145,6 +147,8 @@ static void __init smdkv210_map_io(void)
145 147
146static void __init smdkv210_machine_init(void) 148static void __init smdkv210_machine_init(void)
147{ 149{
150 s3c_pm_init();
151
148 samsung_keypad_set_platdata(&smdkv210_keypad_data); 152 samsung_keypad_set_platdata(&smdkv210_keypad_data);
149 s3c24xx_ts_set_platdata(&s3c_ts_platform); 153 s3c24xx_ts_set_platdata(&s3c_ts_platform);
150 154
diff --git a/arch/arm/mach-s5pv210/mach-torbreck.c b/arch/arm/mach-s5pv210/mach-torbreck.c
new file mode 100644
index 000000000000..043c938806b0
--- /dev/null
+++ b/arch/arm/mach-s5pv210/mach-torbreck.c
@@ -0,0 +1,131 @@
1/* linux/arch/arm/mach-s5pv210/mach-torbreck.c
2 *
3 * Copyright (c) 2010 aESOP Community
4 * http://www.aesop.or.kr/
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/i2c.h>
14#include <linux/init.h>
15#include <linux/serial_core.h>
16
17#include <asm/mach/arch.h>
18#include <asm/mach/map.h>
19#include <asm/setup.h>
20#include <asm/mach-types.h>
21
22#include <mach/map.h>
23#include <mach/regs-clock.h>
24
25#include <plat/regs-serial.h>
26#include <plat/s5pv210.h>
27#include <plat/devs.h>
28#include <plat/cpu.h>
29#include <plat/iic.h>
30
31/* Following are default values for UCON, ULCON and UFCON UART registers */
32#define TORBRECK_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
33 S3C2410_UCON_RXILEVEL | \
34 S3C2410_UCON_TXIRQMODE | \
35 S3C2410_UCON_RXIRQMODE | \
36 S3C2410_UCON_RXFIFO_TOI | \
37 S3C2443_UCON_RXERR_IRQEN)
38
39#define TORBRECK_ULCON_DEFAULT S3C2410_LCON_CS8
40
41#define TORBRECK_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
42 S5PV210_UFCON_TXTRIG4 | \
43 S5PV210_UFCON_RXTRIG4)
44
45static struct s3c2410_uartcfg torbreck_uartcfgs[] __initdata = {
46 [0] = {
47 .hwport = 0,
48 .flags = 0,
49 .ucon = TORBRECK_UCON_DEFAULT,
50 .ulcon = TORBRECK_ULCON_DEFAULT,
51 .ufcon = TORBRECK_UFCON_DEFAULT,
52 },
53 [1] = {
54 .hwport = 1,
55 .flags = 0,
56 .ucon = TORBRECK_UCON_DEFAULT,
57 .ulcon = TORBRECK_ULCON_DEFAULT,
58 .ufcon = TORBRECK_UFCON_DEFAULT,
59 },
60 [2] = {
61 .hwport = 2,
62 .flags = 0,
63 .ucon = TORBRECK_UCON_DEFAULT,
64 .ulcon = TORBRECK_ULCON_DEFAULT,
65 .ufcon = TORBRECK_UFCON_DEFAULT,
66 },
67 [3] = {
68 .hwport = 3,
69 .flags = 0,
70 .ucon = TORBRECK_UCON_DEFAULT,
71 .ulcon = TORBRECK_ULCON_DEFAULT,
72 .ufcon = TORBRECK_UFCON_DEFAULT,
73 },
74};
75
76static struct platform_device *torbreck_devices[] __initdata = {
77 &s5pv210_device_iis0,
78 &s3c_device_cfcon,
79 &s3c_device_hsmmc0,
80 &s3c_device_hsmmc1,
81 &s3c_device_hsmmc2,
82 &s3c_device_hsmmc3,
83 &s3c_device_i2c0,
84 &s3c_device_i2c1,
85 &s3c_device_i2c2,
86 &s3c_device_rtc,
87 &s3c_device_wdt,
88};
89
90static struct i2c_board_info torbreck_i2c_devs0[] __initdata = {
91 /* To Be Updated */
92};
93
94static struct i2c_board_info torbreck_i2c_devs1[] __initdata = {
95 /* To Be Updated */
96};
97
98static struct i2c_board_info torbreck_i2c_devs2[] __initdata = {
99 /* To Be Updated */
100};
101
102static void __init torbreck_map_io(void)
103{
104 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
105 s3c24xx_init_clocks(24000000);
106 s3c24xx_init_uarts(torbreck_uartcfgs, ARRAY_SIZE(torbreck_uartcfgs));
107}
108
109static void __init torbreck_machine_init(void)
110{
111 s3c_i2c0_set_platdata(NULL);
112 s3c_i2c1_set_platdata(NULL);
113 s3c_i2c2_set_platdata(NULL);
114 i2c_register_board_info(0, torbreck_i2c_devs0,
115 ARRAY_SIZE(torbreck_i2c_devs0));
116 i2c_register_board_info(1, torbreck_i2c_devs1,
117 ARRAY_SIZE(torbreck_i2c_devs1));
118 i2c_register_board_info(2, torbreck_i2c_devs2,
119 ARRAY_SIZE(torbreck_i2c_devs2));
120
121 platform_add_devices(torbreck_devices, ARRAY_SIZE(torbreck_devices));
122}
123
124MACHINE_START(TORBRECK, "TORBRECK")
125 /* Maintainer: Hyunchul Ko <ghcstop@gmail.com> */
126 .boot_params = S5P_PA_SDRAM + 0x100,
127 .init_irq = s5pv210_init_irq,
128 .map_io = torbreck_map_io,
129 .init_machine = torbreck_machine_init,
130 .timer = &s3c24xx_timer,
131MACHINE_END
diff --git a/arch/arm/mach-s5pv210/pm.c b/arch/arm/mach-s5pv210/pm.c
new file mode 100644
index 000000000000..549d7924fd4c
--- /dev/null
+++ b/arch/arm/mach-s5pv210/pm.c
@@ -0,0 +1,166 @@
1/* linux/arch/arm/mach-s5pv210/pm.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV210 - Power Management support
7 *
8 * Based on arch/arm/mach-s3c2410/pm.c
9 * Copyright (c) 2006 Simtec Electronics
10 * Ben Dooks <ben@simtec.co.uk>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15*/
16
17#include <linux/init.h>
18#include <linux/suspend.h>
19#include <linux/io.h>
20
21#include <plat/cpu.h>
22#include <plat/pm.h>
23#include <plat/regs-timer.h>
24
25#include <mach/regs-irq.h>
26#include <mach/regs-clock.h>
27
28static struct sleep_save s5pv210_core_save[] = {
29 /* Clock source */
30 SAVE_ITEM(S5P_CLK_SRC0),
31 SAVE_ITEM(S5P_CLK_SRC1),
32 SAVE_ITEM(S5P_CLK_SRC2),
33 SAVE_ITEM(S5P_CLK_SRC3),
34 SAVE_ITEM(S5P_CLK_SRC4),
35 SAVE_ITEM(S5P_CLK_SRC5),
36 SAVE_ITEM(S5P_CLK_SRC6),
37
38 /* Clock source Mask */
39 SAVE_ITEM(S5P_CLK_SRC_MASK0),
40 SAVE_ITEM(S5P_CLK_SRC_MASK1),
41
42 /* Clock Divider */
43 SAVE_ITEM(S5P_CLK_DIV0),
44 SAVE_ITEM(S5P_CLK_DIV1),
45 SAVE_ITEM(S5P_CLK_DIV2),
46 SAVE_ITEM(S5P_CLK_DIV3),
47 SAVE_ITEM(S5P_CLK_DIV4),
48 SAVE_ITEM(S5P_CLK_DIV5),
49 SAVE_ITEM(S5P_CLK_DIV6),
50 SAVE_ITEM(S5P_CLK_DIV7),
51
52 /* Clock Main Gate */
53 SAVE_ITEM(S5P_CLKGATE_MAIN0),
54 SAVE_ITEM(S5P_CLKGATE_MAIN1),
55 SAVE_ITEM(S5P_CLKGATE_MAIN2),
56
57 /* Clock source Peri Gate */
58 SAVE_ITEM(S5P_CLKGATE_PERI0),
59 SAVE_ITEM(S5P_CLKGATE_PERI1),
60
61 /* Clock source SCLK Gate */
62 SAVE_ITEM(S5P_CLKGATE_SCLK0),
63 SAVE_ITEM(S5P_CLKGATE_SCLK1),
64
65 /* Clock IP Clock gate */
66 SAVE_ITEM(S5P_CLKGATE_IP0),
67 SAVE_ITEM(S5P_CLKGATE_IP1),
68 SAVE_ITEM(S5P_CLKGATE_IP2),
69 SAVE_ITEM(S5P_CLKGATE_IP3),
70 SAVE_ITEM(S5P_CLKGATE_IP4),
71
72 /* Clock Blcok and Bus gate */
73 SAVE_ITEM(S5P_CLKGATE_BLOCK),
74 SAVE_ITEM(S5P_CLKGATE_BUS0),
75
76 /* Clock ETC */
77 SAVE_ITEM(S5P_CLK_OUT),
78 SAVE_ITEM(S5P_MDNIE_SEL),
79
80 /* PWM Register */
81 SAVE_ITEM(S3C2410_TCFG0),
82 SAVE_ITEM(S3C2410_TCFG1),
83 SAVE_ITEM(S3C64XX_TINT_CSTAT),
84 SAVE_ITEM(S3C2410_TCON),
85 SAVE_ITEM(S3C2410_TCNTB(0)),
86 SAVE_ITEM(S3C2410_TCMPB(0)),
87 SAVE_ITEM(S3C2410_TCNTO(0)),
88};
89
90void s5pv210_cpu_suspend(void)
91{
92 unsigned long tmp;
93
94 /* issue the standby signal into the pm unit. Note, we
95 * issue a write-buffer drain just in case */
96
97 tmp = 0;
98
99 asm("b 1f\n\t"
100 ".align 5\n\t"
101 "1:\n\t"
102 "mcr p15, 0, %0, c7, c10, 5\n\t"
103 "mcr p15, 0, %0, c7, c10, 4\n\t"
104 "wfi" : : "r" (tmp));
105
106 /* we should never get past here */
107 panic("sleep resumed to originator?");
108}
109
110static void s5pv210_pm_prepare(void)
111{
112 unsigned int tmp;
113
114 /* ensure at least INFORM0 has the resume address */
115 __raw_writel(virt_to_phys(s3c_cpu_resume), S5P_INFORM0);
116
117 tmp = __raw_readl(S5P_SLEEP_CFG);
118 tmp &= ~(S5P_SLEEP_CFG_OSC_EN | S5P_SLEEP_CFG_USBOSC_EN);
119 __raw_writel(tmp, S5P_SLEEP_CFG);
120
121 /* WFI for SLEEP mode configuration by SYSCON */
122 tmp = __raw_readl(S5P_PWR_CFG);
123 tmp &= S5P_CFG_WFI_CLEAN;
124 tmp |= S5P_CFG_WFI_SLEEP;
125 __raw_writel(tmp, S5P_PWR_CFG);
126
127 /* SYSCON interrupt handling disable */
128 tmp = __raw_readl(S5P_OTHERS);
129 tmp |= S5P_OTHER_SYSC_INTOFF;
130 __raw_writel(tmp, S5P_OTHERS);
131
132 s3c_pm_do_save(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save));
133}
134
135static int s5pv210_pm_add(struct sys_device *sysdev)
136{
137 pm_cpu_prep = s5pv210_pm_prepare;
138 pm_cpu_sleep = s5pv210_cpu_suspend;
139
140 return 0;
141}
142
143static int s5pv210_pm_resume(struct sys_device *dev)
144{
145 u32 tmp;
146
147 tmp = __raw_readl(S5P_OTHERS);
148 tmp |= (S5P_OTHERS_RET_IO | S5P_OTHERS_RET_CF |\
149 S5P_OTHERS_RET_MMC | S5P_OTHERS_RET_UART);
150 __raw_writel(tmp , S5P_OTHERS);
151
152 s3c_pm_do_restore_core(s5pv210_core_save, ARRAY_SIZE(s5pv210_core_save));
153
154 return 0;
155}
156
157static struct sysdev_driver s5pv210_pm_driver = {
158 .add = s5pv210_pm_add,
159 .resume = s5pv210_pm_resume,
160};
161
162static __init int s5pv210_pm_drvinit(void)
163{
164 return sysdev_driver_register(&s5pv210_sysclass, &s5pv210_pm_driver);
165}
166arch_initcall(s5pv210_pm_drvinit);
diff --git a/arch/arm/mach-s5pv210/setup-fb-24bpp.c b/arch/arm/mach-s5pv210/setup-fb-24bpp.c
index 928cf1f125fa..e932ebfac56d 100644
--- a/arch/arm/mach-s5pv210/setup-fb-24bpp.c
+++ b/arch/arm/mach-s5pv210/setup-fb-24bpp.c
@@ -21,33 +21,21 @@
21#include <mach/regs-clock.h> 21#include <mach/regs-clock.h>
22#include <plat/gpio-cfg.h> 22#include <plat/gpio-cfg.h>
23 23
24void s5pv210_fb_gpio_setup_24bpp(void) 24static void s5pv210_fb_cfg_gpios(unsigned int base, unsigned int nr)
25{ 25{
26 unsigned int gpio = 0; 26 s3c_gpio_cfgrange_nopull(base, nr, S3C_GPIO_SFN(2));
27
28 for (gpio = S5PV210_GPF0(0); gpio <= S5PV210_GPF0(7); gpio++) {
29 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
30 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
31 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
32 }
33 27
34 for (gpio = S5PV210_GPF1(0); gpio <= S5PV210_GPF1(7); gpio++) { 28 for (; nr > 0; nr--, base++)
35 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); 29 s5p_gpio_set_drvstr(base, S5P_GPIO_DRVSTR_LV4);
36 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); 30}
37 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
38 }
39 31
40 for (gpio = S5PV210_GPF2(0); gpio <= S5PV210_GPF2(7); gpio++) {
41 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
42 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
43 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
44 }
45 32
46 for (gpio = S5PV210_GPF3(0); gpio <= S5PV210_GPF3(3); gpio++) { 33void s5pv210_fb_gpio_setup_24bpp(void)
47 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); 34{
48 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); 35 s5pv210_fb_cfg_gpios(S5PV210_GPF0(0), 8);
49 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); 36 s5pv210_fb_cfg_gpios(S5PV210_GPF1(0), 8);
50 } 37 s5pv210_fb_cfg_gpios(S5PV210_GPF2(0), 8);
38 s5pv210_fb_cfg_gpios(S5PV210_GPF3(0), 4);
51 39
52 /* Set DISPLAY_CONTROL register for Display path selection. 40 /* Set DISPLAY_CONTROL register for Display path selection.
53 * 41 *
diff --git a/arch/arm/mach-s5pv210/setup-i2c0.c b/arch/arm/mach-s5pv210/setup-i2c0.c
index d38f7cb7e662..0f1cc3a1c1e8 100644
--- a/arch/arm/mach-s5pv210/setup-i2c0.c
+++ b/arch/arm/mach-s5pv210/setup-i2c0.c
@@ -23,8 +23,6 @@ struct platform_device; /* don't need the contents */
23 23
24void s3c_i2c0_cfg_gpio(struct platform_device *dev) 24void s3c_i2c0_cfg_gpio(struct platform_device *dev)
25{ 25{
26 s3c_gpio_cfgpin(S5PV210_GPD1(0), S3C_GPIO_SFN(2)); 26 s3c_gpio_cfgall_range(S5PV210_GPD1(0), 2,
27 s3c_gpio_setpull(S5PV210_GPD1(0), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5PV210_GPD1(1), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5PV210_GPD1(1), S3C_GPIO_PULL_UP);
30} 28}
diff --git a/arch/arm/mach-s5pv210/setup-i2c1.c b/arch/arm/mach-s5pv210/setup-i2c1.c
index 148bb7857d89..f61365a34c56 100644
--- a/arch/arm/mach-s5pv210/setup-i2c1.c
+++ b/arch/arm/mach-s5pv210/setup-i2c1.c
@@ -23,8 +23,6 @@ struct platform_device; /* don't need the contents */
23 23
24void s3c_i2c1_cfg_gpio(struct platform_device *dev) 24void s3c_i2c1_cfg_gpio(struct platform_device *dev)
25{ 25{
26 s3c_gpio_cfgpin(S5PV210_GPD1(2), S3C_GPIO_SFN(2)); 26 s3c_gpio_cfgall_range(S5PV210_GPD1(2), 2,
27 s3c_gpio_setpull(S5PV210_GPD1(2), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5PV210_GPD1(3), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5PV210_GPD1(3), S3C_GPIO_PULL_UP);
30} 28}
diff --git a/arch/arm/mach-s5pv210/setup-i2c2.c b/arch/arm/mach-s5pv210/setup-i2c2.c
index 2396cb8c373e..2f91b5cefbc6 100644
--- a/arch/arm/mach-s5pv210/setup-i2c2.c
+++ b/arch/arm/mach-s5pv210/setup-i2c2.c
@@ -23,8 +23,6 @@ struct platform_device; /* don't need the contents */
23 23
24void s3c_i2c2_cfg_gpio(struct platform_device *dev) 24void s3c_i2c2_cfg_gpio(struct platform_device *dev)
25{ 25{
26 s3c_gpio_cfgpin(S5PV210_GPD1(4), S3C_GPIO_SFN(2)); 26 s3c_gpio_cfgall_range(S5PV210_GPD1(4), 2,
27 s3c_gpio_setpull(S5PV210_GPD1(4), S3C_GPIO_PULL_UP); 27 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
28 s3c_gpio_cfgpin(S5PV210_GPD1(5), S3C_GPIO_SFN(2));
29 s3c_gpio_setpull(S5PV210_GPD1(5), S3C_GPIO_PULL_UP);
30} 28}
diff --git a/arch/arm/mach-s5pv210/setup-ide.c b/arch/arm/mach-s5pv210/setup-ide.c
index b558b1cc8d60..ea123d546bd2 100644
--- a/arch/arm/mach-s5pv210/setup-ide.c
+++ b/arch/arm/mach-s5pv210/setup-ide.c
@@ -15,36 +15,25 @@
15 15
16#include <plat/gpio-cfg.h> 16#include <plat/gpio-cfg.h>
17 17
18static void s5pv210_ide_cfg_gpios(unsigned int base, unsigned int nr)
19{
20 s3c_gpio_cfgrange_nopull(base, nr, S3C_GPIO_SFN(4));
21
22 for (; nr > 0; nr--, base++)
23 s5p_gpio_set_drvstr(base, S5P_GPIO_DRVSTR_LV4);
24}
25
18void s5pv210_ide_setup_gpio(void) 26void s5pv210_ide_setup_gpio(void)
19{ 27{
20 unsigned int gpio = 0; 28 /* CF_Add[0 - 2], CF_IORDY, CF_INTRQ, CF_DMARQ, CF_DMARST, CF_DMACK */
21 29 s5pv210_ide_cfg_gpios(S5PV210_GPJ0(0), 8);
22 for (gpio = S5PV210_GPJ0(0); gpio <= S5PV210_GPJ0(7); gpio++) { 30
23 /* CF_Add[0 - 2], CF_IORDY, CF_INTRQ, CF_DMARQ, CF_DMARST, 31 /* CF_Data[0 - 7] */
24 CF_DMACK */ 32 s5pv210_ide_cfg_gpios(S5PV210_GPJ2(0), 8);
25 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4)); 33
26 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE); 34 /* CF_Data[8 - 15] */
27 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4); 35 s5pv210_ide_cfg_gpios(S5PV210_GPJ3(0), 8);
28 } 36
29 37 /* CF_CS0, CF_CS1, CF_IORD, CF_IOWR */
30 for (gpio = S5PV210_GPJ2(0); gpio <= S5PV210_GPJ2(7); gpio++) { 38 s5pv210_ide_cfg_gpios(S5PV210_GPJ4(0), 4);
31 /*CF_Data[0 - 7] */
32 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
33 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
34 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
35 }
36
37 for (gpio = S5PV210_GPJ3(0); gpio <= S5PV210_GPJ3(7); gpio++) {
38 /* CF_Data[8 - 15] */
39 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
40 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
41 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
42 }
43
44 for (gpio = S5PV210_GPJ4(0); gpio <= S5PV210_GPJ4(3); gpio++) {
45 /* CF_CS0, CF_CS1, CF_IORD, CF_IOWR */
46 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
47 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
48 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
49 }
50} 39}
diff --git a/arch/arm/mach-s5pv210/setup-keypad.c b/arch/arm/mach-s5pv210/setup-keypad.c
index 37b2790aafc3..c56420a52f48 100644
--- a/arch/arm/mach-s5pv210/setup-keypad.c
+++ b/arch/arm/mach-s5pv210/setup-keypad.c
@@ -16,19 +16,9 @@
16 16
17void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) 17void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols)
18{ 18{
19 unsigned int gpio, end;
20
21 /* Set all the necessary GPH3 pins to special-function 3: KP_ROW[x] */ 19 /* Set all the necessary GPH3 pins to special-function 3: KP_ROW[x] */
22 end = S5PV210_GPH3(rows); 20 s3c_gpio_cfgrange_nopull(S5PV210_GPH3(0), rows, S3C_GPIO_SFN(3));
23 for (gpio = S5PV210_GPH3(0); gpio < end; gpio++) {
24 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
25 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
26 }
27 21
28 /* Set all the necessary GPH2 pins to special-function 3: KP_COL[x] */ 22 /* Set all the necessary GPH2 pins to special-function 3: KP_COL[x] */
29 end = S5PV210_GPH2(cols); 23 s3c_gpio_cfgrange_nopull(S5PV210_GPH2(0), cols, S3C_GPIO_SFN(3));
30 for (gpio = S5PV210_GPH2(0); gpio < end; gpio++) {
31 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
32 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
33 }
34} 24}
diff --git a/arch/arm/mach-s5pv210/setup-sdhci-gpio.c b/arch/arm/mach-s5pv210/setup-sdhci-gpio.c
index b18587b1ec58..746777d56df9 100644
--- a/arch/arm/mach-s5pv210/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s5pv210/setup-sdhci-gpio.c
@@ -26,26 +26,17 @@
26void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) 26void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27{ 27{
28 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 28 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
29 unsigned int gpio;
30 29
31 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */ 30 /* Set all the necessary GPG0/GPG1 pins to special-function 2 */
32 for (gpio = S5PV210_GPG0(0); gpio < S5PV210_GPG0(2); gpio++) { 31 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(0), 2, S3C_GPIO_SFN(2));
33 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2)); 32
34 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
35 }
36 switch (width) { 33 switch (width) {
37 case 8: 34 case 8:
38 /* GPG1[3:6] special-funtion 3 */ 35 /* GPG1[3:6] special-funtion 3 */
39 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { 36 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(3));
40 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
41 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
42 }
43 case 4: 37 case 4:
44 /* GPG0[3:6] special-funtion 2 */ 38 /* GPG0[3:6] special-funtion 2 */
45 for (gpio = S5PV210_GPG0(3); gpio <= S5PV210_GPG0(6); gpio++) { 39 s3c_gpio_cfgrange_nopull(S5PV210_GPG0(3), 4, S3C_GPIO_SFN(2));
46 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
47 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
48 }
49 default: 40 default:
50 break; 41 break;
51 } 42 }
@@ -59,19 +50,12 @@ void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
59void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width) 50void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
60{ 51{
61 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 52 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
62 unsigned int gpio;
63 53
64 /* Set all the necessary GPG1[0:1] pins to special-function 2 */ 54 /* Set all the necessary GPG1[0:1] pins to special-function 2 */
65 for (gpio = S5PV210_GPG1(0); gpio < S5PV210_GPG1(2); gpio++) { 55 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(0), 2, S3C_GPIO_SFN(2));
66 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
67 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
68 }
69 56
70 /* Data pin GPG1[3:6] to special-function 2 */ 57 /* Data pin GPG1[3:6] to special-function 2 */
71 for (gpio = S5PV210_GPG1(3); gpio <= S5PV210_GPG1(6); gpio++) { 58 s3c_gpio_cfgrange_nopull(S5PV210_GPG1(3), 4, S3C_GPIO_SFN(2));
72 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
73 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
74 }
75 59
76 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 60 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
77 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP); 61 s3c_gpio_setpull(S5PV210_GPG1(2), S3C_GPIO_PULL_UP);
@@ -82,27 +66,17 @@ void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
82void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width) 66void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
83{ 67{
84 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 68 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
85 unsigned int gpio;
86 69
87 /* Set all the necessary GPG2[0:1] pins to special-function 2 */ 70 /* Set all the necessary GPG2[0:1] pins to special-function 2 */
88 for (gpio = S5PV210_GPG2(0); gpio < S5PV210_GPG2(2); gpio++) { 71 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(0), 2, S3C_GPIO_SFN(2));
89 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
90 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
91 }
92 72
93 switch (width) { 73 switch (width) {
94 case 8: 74 case 8:
95 /* Data pin GPG3[3:6] to special-function 3 */ 75 /* Data pin GPG3[3:6] to special-function 3 */
96 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) { 76 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(3));
97 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
98 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
99 }
100 case 4: 77 case 4:
101 /* Data pin GPG2[3:6] to special-function 2 */ 78 /* Data pin GPG2[3:6] to special-function 2 */
102 for (gpio = S5PV210_GPG2(3); gpio <= S5PV210_GPG2(6); gpio++) { 79 s3c_gpio_cfgrange_nopull(S5PV210_GPG2(3), 4, S3C_GPIO_SFN(2));
103 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
104 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
105 }
106 default: 80 default:
107 break; 81 break;
108 } 82 }
@@ -116,19 +90,12 @@ void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
116void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width) 90void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
117{ 91{
118 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data; 92 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
119 unsigned int gpio;
120 93
121 /* Set all the necessary GPG3[0:2] pins to special-function 2 */ 94 /* Set all the necessary GPG3[0:1] pins to special-function 2 */
122 for (gpio = S5PV210_GPG3(0); gpio < S5PV210_GPG3(2); gpio++) { 95 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(0), 2, S3C_GPIO_SFN(2));
123 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
124 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
125 }
126 96
127 /* Data pin GPG3[3:6] to special-function 2 */ 97 /* Data pin GPG3[3:6] to special-function 2 */
128 for (gpio = S5PV210_GPG3(3); gpio <= S5PV210_GPG3(6); gpio++) { 98 s3c_gpio_cfgrange_nopull(S5PV210_GPG3(3), 4, S3C_GPIO_SFN(2));
129 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
130 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
131 }
132 99
133 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { 100 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
134 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP); 101 s3c_gpio_setpull(S5PV210_GPG3(2), S3C_GPIO_PULL_UP);
diff --git a/arch/arm/mach-s5pv210/sleep.S b/arch/arm/mach-s5pv210/sleep.S
new file mode 100644
index 000000000000..d4d222b716b4
--- /dev/null
+++ b/arch/arm/mach-s5pv210/sleep.S
@@ -0,0 +1,170 @@
1/* linux/arch/arm/plat-s5p/sleep.S
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV210 power Manager (Suspend-To-RAM) support
7 * Based on S3C2410 sleep code by:
8 * Ben Dooks, (c) 2004 Simtec Electronics
9 *
10 * Based on PXA/SA1100 sleep code by:
11 * Nicolas Pitre, (c) 2002 Monta Vista Software Inc
12 * Cliff Brake, (c) 2001
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27*/
28
29#include <linux/linkage.h>
30#include <asm/assembler.h>
31#include <asm/memory.h>
32
33 .text
34
35 /* s3c_cpu_save
36 *
37 * entry:
38 * r0 = save address (virtual addr of s3c_sleep_save_phys)
39 */
40
41ENTRY(s3c_cpu_save)
42
43 stmfd sp!, { r3 - r12, lr }
44
45 mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
46 mrc p15, 0, r5, c3, c0, 0 @ Domain ID
47 mrc p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
48 mrc p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
49 mrc p15, 0, r8, c2, c0, 2 @ Translation Table Control
50 mrc p15, 0, r9, c1, c0, 0 @ Control register
51 mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register
52 mrc p15, 0, r11, c1, c0, 2 @ Co-processor access controls
53 mrc p15, 0, r12, c10, c2, 0 @ Read PRRR
54 mrc p15, 0, r3, c10, c2, 1 @ READ NMRR
55
56 stmia r0, { r3 - r13 }
57
58 bl s3c_pm_cb_flushcache
59
60 ldr r0, =pm_cpu_sleep
61 ldr r0, [ r0 ]
62 mov pc, r0
63
64resume_with_mmu:
65 /*
66 * After MMU is turned on, restore the previous MMU table.
67 */
68 ldr r9 , =(PAGE_OFFSET - PHYS_OFFSET)
69 add r4, r4, r9
70 str r12, [r4]
71
72 ldmfd sp!, { r3 - r12, pc }
73
74 .ltorg
75
76 .data
77
78 .global s3c_sleep_save_phys
79s3c_sleep_save_phys:
80 .word 0
81
82 /* sleep magic, to allow the bootloader to check for an valid
83 * image to resume to. Must be the first word before the
84 * s3c_cpu_resume entry.
85 */
86
87 .word 0x2bedf00d
88
89 /* s3c_cpu_resume
90 *
91 * resume code entry for bootloader to call
92 *
93 * we must put this code here in the data segment as we have no
94 * other way of restoring the stack pointer after sleep, and we
95 * must not write to the code segment (code is read-only)
96 */
97
98ENTRY(s3c_cpu_resume)
99 mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
100 msr cpsr_c, r0
101
102 mov r1, #0
103 mcr p15, 0, r1, c8, c7, 0 @ invalidate TLBs
104 mcr p15, 0, r1, c7, c5, 0 @ invalidate I Cache
105
106 ldr r0, s3c_sleep_save_phys @ address of restore block
107 ldmia r0, { r3 - r13 }
108
109 mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
110 mcr p15, 0, r5, c3, c0, 0 @ Domain ID
111
112 mcr p15, 0, r8, c2, c0, 2 @ Translation Table Control
113 mcr p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
114 mcr p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
115
116 mcr p15, 0, r10, c1, c0, 1 @ Auxiliary control register
117
118 mov r0, #0
119 mcr p15, 0, r0, c8, c7, 0 @ Invalidate I & D TLB
120
121 mov r0, #0 @ restore copro access
122 mcr p15, 0, r11, c1, c0, 2 @ Co-processor access
123 mcr p15, 0, r0, c7, c5, 4
124
125 mcr p15, 0, r12, c10, c2, 0 @ write PRRR
126 mcr p15, 0, r3, c10, c2, 1 @ write NMRR
127
128 /*
129 * In Cortex-A8, when MMU is turned on, the pipeline is flushed.
130 * And there are no valid entries in the MMU table at this point.
131 * So before turning on the MMU, the MMU entry for the DRAM address
132 * range is added. After the MMU is turned on, the other entries
133 * in the MMU table will be restored.
134 */
135
136 /* r6 = Translation Table BASE0 */
137 mov r4, r6
138 mov r4, r4, LSR #14
139 mov r4, r4, LSL #14
140
141 /* Load address for adding to MMU table list */
142 ldr r11, =0xE010F000 @ INFORM0 reg.
143 ldr r10, [r11, #0]
144 mov r10, r10, LSR #18
145 bic r10, r10, #0x3
146 orr r4, r4, r10
147
148 /* Calculate MMU table entry */
149 mov r10, r10, LSL #18
150 ldr r5, =0x40E
151 orr r10, r10, r5
152
153 /* Back up originally data */
154 ldr r12, [r4]
155
156 /* Add calculated MMU table entry into MMU table list */
157 str r10, [r4]
158
159 ldr r2, =resume_with_mmu
160 mcr p15, 0, r9, c1, c0, 0 @ turn on MMU, etc
161
162 nop
163 nop
164 nop
165 nop
166 nop @ second-to-last before mmu
167
168 mov pc, r2 @ go back to virtual address
169
170 .ltorg
diff --git a/arch/arm/mach-s5pv310/Kconfig b/arch/arm/mach-s5pv310/Kconfig
index 331b5bd97aba..1150b360f38c 100644
--- a/arch/arm/mach-s5pv310/Kconfig
+++ b/arch/arm/mach-s5pv310/Kconfig
@@ -11,7 +11,6 @@ if ARCH_S5PV310
11 11
12config CPU_S5PV310 12config CPU_S5PV310
13 bool 13 bool
14 select PLAT_S5P
15 help 14 help
16 Enable S5PV310 CPU support 15 Enable S5PV310 CPU support
17 16
@@ -25,21 +24,105 @@ config S5PV310_SETUP_I2C2
25 help 24 help
26 Common setup code for i2c bus 2. 25 Common setup code for i2c bus 2.
27 26
27config S5PV310_SETUP_I2C3
28 bool
29 help
30 Common setup code for i2c bus 3.
31
32config S5PV310_SETUP_I2C4
33 bool
34 help
35 Common setup code for i2c bus 4.
36
37config S5PV310_SETUP_I2C5
38 bool
39 help
40 Common setup code for i2c bus 5.
41
42config S5PV310_SETUP_I2C6
43 bool
44 help
45 Common setup code for i2c bus 6.
46
47config S5PV310_SETUP_I2C7
48 bool
49 help
50 Common setup code for i2c bus 7.
51
52config S5PV310_SETUP_SDHCI
53 bool
54 select S5PV310_SETUP_SDHCI_GPIO
55 help
56 Internal helper functions for S5PV310 based SDHCI systems.
57
58config S5PV310_SETUP_SDHCI_GPIO
59 bool
60 help
61 Common setup code for SDHCI gpio.
62
28# machine support 63# machine support
29 64
30config MACH_SMDKV310 65menu "S5PC210 Machines"
31 bool "SMDKV310" 66
67config MACH_SMDKC210
68 bool "SMDKC210"
32 select CPU_S5PV310 69 select CPU_S5PV310
33 select ARCH_SPARSEMEM_ENABLE 70 select S3C_DEV_RTC
71 select S3C_DEV_WDT
72 select S3C_DEV_HSMMC
73 select S3C_DEV_HSMMC1
74 select S3C_DEV_HSMMC2
75 select S3C_DEV_HSMMC3
76 select S5PV310_SETUP_SDHCI
34 help 77 help
35 Machine support for Samsung SMDKV310 78 Machine support for Samsung SMDKC210
79 S5PC210(MCP) is one of package option of S5PV310
36 80
37config MACH_UNIVERSAL_C210 81config MACH_UNIVERSAL_C210
38 bool "Mobile UNIVERSAL_C210 Board" 82 bool "Mobile UNIVERSAL_C210 Board"
39 select CPU_S5PV310 83 select CPU_S5PV310
40 select ARCH_SPARSEMEM_ENABLE 84 select S5P_DEV_ONENAND
85 select S3C_DEV_I2C1
86 select S5PV310_SETUP_I2C1
41 help 87 help
42 Machine support for Samsung Mobile Universal S5PC210 Reference 88 Machine support for Samsung Mobile Universal S5PC210 Reference
43 Board. S5PC210(MCP) is one of package option of S5PV310 89 Board. S5PC210(MCP) is one of package option of S5PV310
44 90
91endmenu
92
93menu "S5PV310 Machines"
94
95config MACH_SMDKV310
96 bool "SMDKV310"
97 select CPU_S5PV310
98 select S3C_DEV_RTC
99 select S3C_DEV_WDT
100 select S3C_DEV_HSMMC
101 select S3C_DEV_HSMMC1
102 select S3C_DEV_HSMMC2
103 select S3C_DEV_HSMMC3
104 select S5PV310_SETUP_SDHCI
105 help
106 Machine support for Samsung SMDKV310
107
108endmenu
109
110comment "Configuration for HSMMC bus width"
111
112menu "Use 8-bit bus width"
113
114config S5PV310_SDHCI_CH0_8BIT
115 bool "Channel 0 with 8-bit bus"
116 help
117 Support HSMMC Channel 0 8-bit bus.
118 If selected, Channel 1 is disabled.
119
120config S5PV310_SDHCI_CH2_8BIT
121 bool "Channel 2 with 8-bit bus"
122 help
123 Support HSMMC Channel 2 8-bit bus.
124 If selected, Channel 3 is disabled.
125
126endmenu
127
45endif 128endif
diff --git a/arch/arm/mach-s5pv310/Makefile b/arch/arm/mach-s5pv310/Makefile
index d5b51c72340f..84afc64e7c01 100644
--- a/arch/arm/mach-s5pv310/Makefile
+++ b/arch/arm/mach-s5pv310/Makefile
@@ -13,7 +13,7 @@ obj- :=
13# Core support for S5PV310 system 13# Core support for S5PV310 system
14 14
15obj-$(CONFIG_CPU_S5PV310) += cpu.o init.o clock.o irq-combiner.o 15obj-$(CONFIG_CPU_S5PV310) += cpu.o init.o clock.o irq-combiner.o
16obj-$(CONFIG_CPU_S5PV310) += setup-i2c0.o time.o 16obj-$(CONFIG_CPU_S5PV310) += setup-i2c0.o time.o gpiolib.o irq-eint.o
17 17
18obj-$(CONFIG_SMP) += platsmp.o headsmp.o 18obj-$(CONFIG_SMP) += platsmp.o headsmp.o
19obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o 19obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
@@ -21,6 +21,7 @@ obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
21 21
22# machine support 22# machine support
23 23
24obj-$(CONFIG_MACH_SMDKC210) += mach-smdkc210.o
24obj-$(CONFIG_MACH_SMDKV310) += mach-smdkv310.o 25obj-$(CONFIG_MACH_SMDKV310) += mach-smdkv310.o
25obj-$(CONFIG_MACH_UNIVERSAL_C210) += mach-universal_c210.o 26obj-$(CONFIG_MACH_UNIVERSAL_C210) += mach-universal_c210.o
26 27
@@ -28,3 +29,10 @@ obj-$(CONFIG_MACH_UNIVERSAL_C210) += mach-universal_c210.o
28 29
29obj-$(CONFIG_S5PV310_SETUP_I2C1) += setup-i2c1.o 30obj-$(CONFIG_S5PV310_SETUP_I2C1) += setup-i2c1.o
30obj-$(CONFIG_S5PV310_SETUP_I2C2) += setup-i2c2.o 31obj-$(CONFIG_S5PV310_SETUP_I2C2) += setup-i2c2.o
32obj-$(CONFIG_S5PV310_SETUP_I2C3) += setup-i2c3.o
33obj-$(CONFIG_S5PV310_SETUP_I2C4) += setup-i2c4.o
34obj-$(CONFIG_S5PV310_SETUP_I2C5) += setup-i2c5.o
35obj-$(CONFIG_S5PV310_SETUP_I2C6) += setup-i2c6.o
36obj-$(CONFIG_S5PV310_SETUP_I2C7) += setup-i2c7.o
37obj-$(CONFIG_S5PV310_SETUP_SDHCI) += setup-sdhci.o
38obj-$(CONFIG_S5PV310_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
diff --git a/arch/arm/mach-s5pv310/clock.c b/arch/arm/mach-s5pv310/clock.c
index 26a0f03df8ea..58c9d33f36fe 100644
--- a/arch/arm/mach-s5pv310/clock.c
+++ b/arch/arm/mach-s5pv310/clock.c
@@ -30,16 +30,92 @@ static struct clk clk_sclk_hdmi27m = {
30 .rate = 27000000, 30 .rate = 27000000,
31}; 31};
32 32
33static struct clk clk_sclk_hdmiphy = {
34 .name = "sclk_hdmiphy",
35 .id = -1,
36};
37
38static struct clk clk_sclk_usbphy0 = {
39 .name = "sclk_usbphy0",
40 .id = -1,
41 .rate = 27000000,
42};
43
44static struct clk clk_sclk_usbphy1 = {
45 .name = "sclk_usbphy1",
46 .id = -1,
47};
48
49static int s5pv310_clksrc_mask_top_ctrl(struct clk *clk, int enable)
50{
51 return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
52}
53
54static int s5pv310_clksrc_mask_cam_ctrl(struct clk *clk, int enable)
55{
56 return s5p_gatectrl(S5P_CLKSRC_MASK_CAM, clk, enable);
57}
58
59static int s5pv310_clksrc_mask_lcd0_ctrl(struct clk *clk, int enable)
60{
61 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD0, clk, enable);
62}
63
64static int s5pv310_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
65{
66 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD1, clk, enable);
67}
68
69static int s5pv310_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
70{
71 return s5p_gatectrl(S5P_CLKSRC_MASK_FSYS, clk, enable);
72}
73
33static int s5pv310_clksrc_mask_peril0_ctrl(struct clk *clk, int enable) 74static int s5pv310_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
34{ 75{
35 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable); 76 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable);
36} 77}
37 78
79static int s5pv310_clksrc_mask_peril1_ctrl(struct clk *clk, int enable)
80{
81 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL1, clk, enable);
82}
83
84static int s5pv310_clk_ip_cam_ctrl(struct clk *clk, int enable)
85{
86 return s5p_gatectrl(S5P_CLKGATE_IP_CAM, clk, enable);
87}
88
89static int s5pv310_clk_ip_image_ctrl(struct clk *clk, int enable)
90{
91 return s5p_gatectrl(S5P_CLKGATE_IP_IMAGE, clk, enable);
92}
93
94static int s5pv310_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
95{
96 return s5p_gatectrl(S5P_CLKGATE_IP_LCD0, clk, enable);
97}
98
99static int s5pv310_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
100{
101 return s5p_gatectrl(S5P_CLKGATE_IP_LCD1, clk, enable);
102}
103
104static int s5pv310_clk_ip_fsys_ctrl(struct clk *clk, int enable)
105{
106 return s5p_gatectrl(S5P_CLKGATE_IP_FSYS, clk, enable);
107}
108
38static int s5pv310_clk_ip_peril_ctrl(struct clk *clk, int enable) 109static int s5pv310_clk_ip_peril_ctrl(struct clk *clk, int enable)
39{ 110{
40 return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable); 111 return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable);
41} 112}
42 113
114static int s5pv310_clk_ip_perir_ctrl(struct clk *clk, int enable)
115{
116 return s5p_gatectrl(S5P_CLKGATE_IP_PERIR, clk, enable);
117}
118
43/* Core list of CMU_CPU side */ 119/* Core list of CMU_CPU side */
44 120
45static struct clksrc_clk clk_mout_apll = { 121static struct clksrc_clk clk_mout_apll = {
@@ -79,7 +155,7 @@ static struct clksrc_clk clk_mout_mpll = {
79}; 155};
80 156
81static struct clk *clkset_moutcore_list[] = { 157static struct clk *clkset_moutcore_list[] = {
82 [0] = &clk_sclk_apll.clk, 158 [0] = &clk_mout_apll.clk,
83 [1] = &clk_mout_mpll.clk, 159 [1] = &clk_mout_mpll.clk,
84}; 160};
85 161
@@ -150,24 +226,6 @@ static struct clksrc_clk clk_periphclk = {
150 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 }, 226 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 },
151}; 227};
152 228
153static struct clksrc_clk clk_atclk = {
154 .clk = {
155 .name = "atclk",
156 .id = -1,
157 .parent = &clk_moutcore.clk,
158 },
159 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 16, .size = 3 },
160};
161
162static struct clksrc_clk clk_pclk_dbg = {
163 .clk = {
164 .name = "pclk_dbg",
165 .id = -1,
166 .parent = &clk_atclk.clk,
167 },
168 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 20, .size = 3 },
169};
170
171/* Core list of CMU_CORE side */ 229/* Core list of CMU_CORE side */
172 230
173static struct clk *clkset_corebus_list[] = { 231static struct clk *clkset_corebus_list[] = {
@@ -241,7 +299,7 @@ static struct clk *clkset_aclk_top_list[] = {
241 [1] = &clk_sclk_apll.clk, 299 [1] = &clk_sclk_apll.clk,
242}; 300};
243 301
244static struct clksrc_sources clkset_aclk_200 = { 302static struct clksrc_sources clkset_aclk = {
245 .sources = clkset_aclk_top_list, 303 .sources = clkset_aclk_top_list,
246 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list), 304 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
247}; 305};
@@ -251,52 +309,37 @@ static struct clksrc_clk clk_aclk_200 = {
251 .name = "aclk_200", 309 .name = "aclk_200",
252 .id = -1, 310 .id = -1,
253 }, 311 },
254 .sources = &clkset_aclk_200, 312 .sources = &clkset_aclk,
255 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 }, 313 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 },
256 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 }, 314 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 },
257}; 315};
258 316
259static struct clksrc_sources clkset_aclk_100 = {
260 .sources = clkset_aclk_top_list,
261 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
262};
263
264static struct clksrc_clk clk_aclk_100 = { 317static struct clksrc_clk clk_aclk_100 = {
265 .clk = { 318 .clk = {
266 .name = "aclk_100", 319 .name = "aclk_100",
267 .id = -1, 320 .id = -1,
268 }, 321 },
269 .sources = &clkset_aclk_100, 322 .sources = &clkset_aclk,
270 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 }, 323 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 },
271 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 }, 324 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 },
272}; 325};
273 326
274static struct clksrc_sources clkset_aclk_160 = {
275 .sources = clkset_aclk_top_list,
276 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
277};
278
279static struct clksrc_clk clk_aclk_160 = { 327static struct clksrc_clk clk_aclk_160 = {
280 .clk = { 328 .clk = {
281 .name = "aclk_160", 329 .name = "aclk_160",
282 .id = -1, 330 .id = -1,
283 }, 331 },
284 .sources = &clkset_aclk_160, 332 .sources = &clkset_aclk,
285 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 }, 333 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 },
286 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 }, 334 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 },
287}; 335};
288 336
289static struct clksrc_sources clkset_aclk_133 = {
290 .sources = clkset_aclk_top_list,
291 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
292};
293
294static struct clksrc_clk clk_aclk_133 = { 337static struct clksrc_clk clk_aclk_133 = {
295 .clk = { 338 .clk = {
296 .name = "aclk_133", 339 .name = "aclk_133",
297 .id = -1, 340 .id = -1,
298 }, 341 },
299 .sources = &clkset_aclk_133, 342 .sources = &clkset_aclk,
300 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 }, 343 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 },
301 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 }, 344 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 },
302}; 345};
@@ -315,6 +358,8 @@ static struct clksrc_clk clk_vpllsrc = {
315 .clk = { 358 .clk = {
316 .name = "vpll_src", 359 .name = "vpll_src",
317 .id = -1, 360 .id = -1,
361 .enable = s5pv310_clksrc_mask_top_ctrl,
362 .ctrlbit = (1 << 0),
318 }, 363 },
319 .sources = &clkset_vpllsrc, 364 .sources = &clkset_vpllsrc,
320 .reg_src = { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 }, 365 .reg_src = { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 },
@@ -346,7 +391,175 @@ static struct clk init_clocks_disable[] = {
346 .parent = &clk_aclk_100.clk, 391 .parent = &clk_aclk_100.clk,
347 .enable = s5pv310_clk_ip_peril_ctrl, 392 .enable = s5pv310_clk_ip_peril_ctrl,
348 .ctrlbit = (1<<24), 393 .ctrlbit = (1<<24),
349 } 394 }, {
395 .name = "csis",
396 .id = 0,
397 .enable = s5pv310_clk_ip_cam_ctrl,
398 .ctrlbit = (1 << 4),
399 }, {
400 .name = "csis",
401 .id = 1,
402 .enable = s5pv310_clk_ip_cam_ctrl,
403 .ctrlbit = (1 << 5),
404 }, {
405 .name = "fimc",
406 .id = 0,
407 .enable = s5pv310_clk_ip_cam_ctrl,
408 .ctrlbit = (1 << 0),
409 }, {
410 .name = "fimc",
411 .id = 1,
412 .enable = s5pv310_clk_ip_cam_ctrl,
413 .ctrlbit = (1 << 1),
414 }, {
415 .name = "fimc",
416 .id = 2,
417 .enable = s5pv310_clk_ip_cam_ctrl,
418 .ctrlbit = (1 << 2),
419 }, {
420 .name = "fimc",
421 .id = 3,
422 .enable = s5pv310_clk_ip_cam_ctrl,
423 .ctrlbit = (1 << 3),
424 }, {
425 .name = "fimd",
426 .id = 0,
427 .enable = s5pv310_clk_ip_lcd0_ctrl,
428 .ctrlbit = (1 << 0),
429 }, {
430 .name = "fimd",
431 .id = 1,
432 .enable = s5pv310_clk_ip_lcd1_ctrl,
433 .ctrlbit = (1 << 0),
434 }, {
435 .name = "hsmmc",
436 .id = 0,
437 .parent = &clk_aclk_133.clk,
438 .enable = s5pv310_clk_ip_fsys_ctrl,
439 .ctrlbit = (1 << 5),
440 }, {
441 .name = "hsmmc",
442 .id = 1,
443 .parent = &clk_aclk_133.clk,
444 .enable = s5pv310_clk_ip_fsys_ctrl,
445 .ctrlbit = (1 << 6),
446 }, {
447 .name = "hsmmc",
448 .id = 2,
449 .parent = &clk_aclk_133.clk,
450 .enable = s5pv310_clk_ip_fsys_ctrl,
451 .ctrlbit = (1 << 7),
452 }, {
453 .name = "hsmmc",
454 .id = 3,
455 .parent = &clk_aclk_133.clk,
456 .enable = s5pv310_clk_ip_fsys_ctrl,
457 .ctrlbit = (1 << 8),
458 }, {
459 .name = "hsmmc",
460 .id = 4,
461 .parent = &clk_aclk_133.clk,
462 .enable = s5pv310_clk_ip_fsys_ctrl,
463 .ctrlbit = (1 << 9),
464 }, {
465 .name = "sata",
466 .id = -1,
467 .enable = s5pv310_clk_ip_fsys_ctrl,
468 .ctrlbit = (1 << 10),
469 }, {
470 .name = "adc",
471 .id = -1,
472 .enable = s5pv310_clk_ip_peril_ctrl,
473 .ctrlbit = (1 << 15),
474 }, {
475 .name = "rtc",
476 .id = -1,
477 .enable = s5pv310_clk_ip_perir_ctrl,
478 .ctrlbit = (1 << 15),
479 }, {
480 .name = "watchdog",
481 .id = -1,
482 .enable = s5pv310_clk_ip_perir_ctrl,
483 .ctrlbit = (1 << 14),
484 }, {
485 .name = "usbhost",
486 .id = -1,
487 .enable = s5pv310_clk_ip_fsys_ctrl ,
488 .ctrlbit = (1 << 12),
489 }, {
490 .name = "otg",
491 .id = -1,
492 .enable = s5pv310_clk_ip_fsys_ctrl,
493 .ctrlbit = (1 << 13),
494 }, {
495 .name = "spi",
496 .id = 0,
497 .enable = s5pv310_clk_ip_peril_ctrl,
498 .ctrlbit = (1 << 16),
499 }, {
500 .name = "spi",
501 .id = 1,
502 .enable = s5pv310_clk_ip_peril_ctrl,
503 .ctrlbit = (1 << 17),
504 }, {
505 .name = "spi",
506 .id = 2,
507 .enable = s5pv310_clk_ip_peril_ctrl,
508 .ctrlbit = (1 << 18),
509 }, {
510 .name = "fimg2d",
511 .id = -1,
512 .enable = s5pv310_clk_ip_image_ctrl,
513 .ctrlbit = (1 << 0),
514 }, {
515 .name = "i2c",
516 .id = 0,
517 .parent = &clk_aclk_100.clk,
518 .enable = s5pv310_clk_ip_peril_ctrl,
519 .ctrlbit = (1 << 6),
520 }, {
521 .name = "i2c",
522 .id = 1,
523 .parent = &clk_aclk_100.clk,
524 .enable = s5pv310_clk_ip_peril_ctrl,
525 .ctrlbit = (1 << 7),
526 }, {
527 .name = "i2c",
528 .id = 2,
529 .parent = &clk_aclk_100.clk,
530 .enable = s5pv310_clk_ip_peril_ctrl,
531 .ctrlbit = (1 << 8),
532 }, {
533 .name = "i2c",
534 .id = 3,
535 .parent = &clk_aclk_100.clk,
536 .enable = s5pv310_clk_ip_peril_ctrl,
537 .ctrlbit = (1 << 9),
538 }, {
539 .name = "i2c",
540 .id = 4,
541 .parent = &clk_aclk_100.clk,
542 .enable = s5pv310_clk_ip_peril_ctrl,
543 .ctrlbit = (1 << 10),
544 }, {
545 .name = "i2c",
546 .id = 5,
547 .parent = &clk_aclk_100.clk,
548 .enable = s5pv310_clk_ip_peril_ctrl,
549 .ctrlbit = (1 << 11),
550 }, {
551 .name = "i2c",
552 .id = 6,
553 .parent = &clk_aclk_100.clk,
554 .enable = s5pv310_clk_ip_peril_ctrl,
555 .ctrlbit = (1 << 12),
556 }, {
557 .name = "i2c",
558 .id = 7,
559 .parent = &clk_aclk_100.clk,
560 .enable = s5pv310_clk_ip_peril_ctrl,
561 .ctrlbit = (1 << 13),
562 },
350}; 563};
351 564
352static struct clk init_clocks[] = { 565static struct clk init_clocks[] = {
@@ -387,6 +600,9 @@ static struct clk *clkset_group_list[] = {
387 [0] = &clk_ext_xtal_mux, 600 [0] = &clk_ext_xtal_mux,
388 [1] = &clk_xusbxti, 601 [1] = &clk_xusbxti,
389 [2] = &clk_sclk_hdmi27m, 602 [2] = &clk_sclk_hdmi27m,
603 [3] = &clk_sclk_usbphy0,
604 [4] = &clk_sclk_usbphy1,
605 [5] = &clk_sclk_hdmiphy,
390 [6] = &clk_mout_mpll.clk, 606 [6] = &clk_mout_mpll.clk,
391 [7] = &clk_mout_epll.clk, 607 [7] = &clk_mout_epll.clk,
392 [8] = &clk_sclk_vpll.clk, 608 [8] = &clk_sclk_vpll.clk,
@@ -397,6 +613,104 @@ static struct clksrc_sources clkset_group = {
397 .nr_sources = ARRAY_SIZE(clkset_group_list), 613 .nr_sources = ARRAY_SIZE(clkset_group_list),
398}; 614};
399 615
616static struct clk *clkset_mout_g2d0_list[] = {
617 [0] = &clk_mout_mpll.clk,
618 [1] = &clk_sclk_apll.clk,
619};
620
621static struct clksrc_sources clkset_mout_g2d0 = {
622 .sources = clkset_mout_g2d0_list,
623 .nr_sources = ARRAY_SIZE(clkset_mout_g2d0_list),
624};
625
626static struct clksrc_clk clk_mout_g2d0 = {
627 .clk = {
628 .name = "mout_g2d0",
629 .id = -1,
630 },
631 .sources = &clkset_mout_g2d0,
632 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 0, .size = 1 },
633};
634
635static struct clk *clkset_mout_g2d1_list[] = {
636 [0] = &clk_mout_epll.clk,
637 [1] = &clk_sclk_vpll.clk,
638};
639
640static struct clksrc_sources clkset_mout_g2d1 = {
641 .sources = clkset_mout_g2d1_list,
642 .nr_sources = ARRAY_SIZE(clkset_mout_g2d1_list),
643};
644
645static struct clksrc_clk clk_mout_g2d1 = {
646 .clk = {
647 .name = "mout_g2d1",
648 .id = -1,
649 },
650 .sources = &clkset_mout_g2d1,
651 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 4, .size = 1 },
652};
653
654static struct clk *clkset_mout_g2d_list[] = {
655 [0] = &clk_mout_g2d0.clk,
656 [1] = &clk_mout_g2d1.clk,
657};
658
659static struct clksrc_sources clkset_mout_g2d = {
660 .sources = clkset_mout_g2d_list,
661 .nr_sources = ARRAY_SIZE(clkset_mout_g2d_list),
662};
663
664static struct clksrc_clk clk_dout_mmc0 = {
665 .clk = {
666 .name = "dout_mmc0",
667 .id = -1,
668 },
669 .sources = &clkset_group,
670 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 0, .size = 4 },
671 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 0, .size = 4 },
672};
673
674static struct clksrc_clk clk_dout_mmc1 = {
675 .clk = {
676 .name = "dout_mmc1",
677 .id = -1,
678 },
679 .sources = &clkset_group,
680 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 4, .size = 4 },
681 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 16, .size = 4 },
682};
683
684static struct clksrc_clk clk_dout_mmc2 = {
685 .clk = {
686 .name = "dout_mmc2",
687 .id = -1,
688 },
689 .sources = &clkset_group,
690 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 8, .size = 4 },
691 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 0, .size = 4 },
692};
693
694static struct clksrc_clk clk_dout_mmc3 = {
695 .clk = {
696 .name = "dout_mmc3",
697 .id = -1,
698 },
699 .sources = &clkset_group,
700 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 12, .size = 4 },
701 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 16, .size = 4 },
702};
703
704static struct clksrc_clk clk_dout_mmc4 = {
705 .clk = {
706 .name = "dout_mmc4",
707 .id = -1,
708 },
709 .sources = &clkset_group,
710 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 16, .size = 4 },
711 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 0, .size = 4 },
712};
713
400static struct clksrc_clk clksrcs[] = { 714static struct clksrc_clk clksrcs[] = {
401 { 715 {
402 .clk = { 716 .clk = {
@@ -448,7 +762,200 @@ static struct clksrc_clk clksrcs[] = {
448 .sources = &clkset_group, 762 .sources = &clkset_group,
449 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 }, 763 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 },
450 .reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 }, 764 .reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 },
451 }, 765 }, {
766 .clk = {
767 .name = "sclk_csis",
768 .id = 0,
769 .enable = s5pv310_clksrc_mask_cam_ctrl,
770 .ctrlbit = (1 << 24),
771 },
772 .sources = &clkset_group,
773 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 24, .size = 4 },
774 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 24, .size = 4 },
775 }, {
776 .clk = {
777 .name = "sclk_csis",
778 .id = 1,
779 .enable = s5pv310_clksrc_mask_cam_ctrl,
780 .ctrlbit = (1 << 28),
781 },
782 .sources = &clkset_group,
783 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 28, .size = 4 },
784 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 28, .size = 4 },
785 }, {
786 .clk = {
787 .name = "sclk_cam",
788 .id = 0,
789 .enable = s5pv310_clksrc_mask_cam_ctrl,
790 .ctrlbit = (1 << 16),
791 },
792 .sources = &clkset_group,
793 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 16, .size = 4 },
794 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 16, .size = 4 },
795 }, {
796 .clk = {
797 .name = "sclk_cam",
798 .id = 1,
799 .enable = s5pv310_clksrc_mask_cam_ctrl,
800 .ctrlbit = (1 << 20),
801 },
802 .sources = &clkset_group,
803 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 20, .size = 4 },
804 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 20, .size = 4 },
805 }, {
806 .clk = {
807 .name = "sclk_fimc",
808 .id = 0,
809 .enable = s5pv310_clksrc_mask_cam_ctrl,
810 .ctrlbit = (1 << 0),
811 },
812 .sources = &clkset_group,
813 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 0, .size = 4 },
814 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 0, .size = 4 },
815 }, {
816 .clk = {
817 .name = "sclk_fimc",
818 .id = 1,
819 .enable = s5pv310_clksrc_mask_cam_ctrl,
820 .ctrlbit = (1 << 4),
821 },
822 .sources = &clkset_group,
823 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 4, .size = 4 },
824 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 4, .size = 4 },
825 }, {
826 .clk = {
827 .name = "sclk_fimc",
828 .id = 2,
829 .enable = s5pv310_clksrc_mask_cam_ctrl,
830 .ctrlbit = (1 << 8),
831 },
832 .sources = &clkset_group,
833 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 8, .size = 4 },
834 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 8, .size = 4 },
835 }, {
836 .clk = {
837 .name = "sclk_fimc",
838 .id = 3,
839 .enable = s5pv310_clksrc_mask_cam_ctrl,
840 .ctrlbit = (1 << 12),
841 },
842 .sources = &clkset_group,
843 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 12, .size = 4 },
844 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 12, .size = 4 },
845 }, {
846 .clk = {
847 .name = "sclk_fimd",
848 .id = 0,
849 .enable = s5pv310_clksrc_mask_lcd0_ctrl,
850 .ctrlbit = (1 << 0),
851 },
852 .sources = &clkset_group,
853 .reg_src = { .reg = S5P_CLKSRC_LCD0, .shift = 0, .size = 4 },
854 .reg_div = { .reg = S5P_CLKDIV_LCD0, .shift = 0, .size = 4 },
855 }, {
856 .clk = {
857 .name = "sclk_fimd",
858 .id = 1,
859 .enable = s5pv310_clksrc_mask_lcd1_ctrl,
860 .ctrlbit = (1 << 0),
861 },
862 .sources = &clkset_group,
863 .reg_src = { .reg = S5P_CLKSRC_LCD1, .shift = 0, .size = 4 },
864 .reg_div = { .reg = S5P_CLKDIV_LCD1, .shift = 0, .size = 4 },
865 }, {
866 .clk = {
867 .name = "sclk_sata",
868 .id = -1,
869 .enable = s5pv310_clksrc_mask_fsys_ctrl,
870 .ctrlbit = (1 << 24),
871 },
872 .sources = &clkset_mout_corebus,
873 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 24, .size = 1 },
874 .reg_div = { .reg = S5P_CLKDIV_FSYS0, .shift = 20, .size = 4 },
875 }, {
876 .clk = {
877 .name = "sclk_spi",
878 .id = 0,
879 .enable = s5pv310_clksrc_mask_peril1_ctrl,
880 .ctrlbit = (1 << 16),
881 },
882 .sources = &clkset_group,
883 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 16, .size = 4 },
884 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 0, .size = 4 },
885 }, {
886 .clk = {
887 .name = "sclk_spi",
888 .id = 1,
889 .enable = s5pv310_clksrc_mask_peril1_ctrl,
890 .ctrlbit = (1 << 20),
891 },
892 .sources = &clkset_group,
893 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 20, .size = 4 },
894 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 16, .size = 4 },
895 }, {
896 .clk = {
897 .name = "sclk_spi",
898 .id = 2,
899 .enable = s5pv310_clksrc_mask_peril1_ctrl,
900 .ctrlbit = (1 << 24),
901 },
902 .sources = &clkset_group,
903 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 24, .size = 4 },
904 .reg_div = { .reg = S5P_CLKDIV_PERIL2, .shift = 0, .size = 4 },
905 }, {
906 .clk = {
907 .name = "sclk_fimg2d",
908 .id = -1,
909 },
910 .sources = &clkset_mout_g2d,
911 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 8, .size = 1 },
912 .reg_div = { .reg = S5P_CLKDIV_IMAGE, .shift = 0, .size = 4 },
913 }, {
914 .clk = {
915 .name = "sclk_mmc",
916 .id = 0,
917 .parent = &clk_dout_mmc0.clk,
918 .enable = s5pv310_clksrc_mask_fsys_ctrl,
919 .ctrlbit = (1 << 0),
920 },
921 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 8, .size = 8 },
922 }, {
923 .clk = {
924 .name = "sclk_mmc",
925 .id = 1,
926 .parent = &clk_dout_mmc1.clk,
927 .enable = s5pv310_clksrc_mask_fsys_ctrl,
928 .ctrlbit = (1 << 4),
929 },
930 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 24, .size = 8 },
931 }, {
932 .clk = {
933 .name = "sclk_mmc",
934 .id = 2,
935 .parent = &clk_dout_mmc2.clk,
936 .enable = s5pv310_clksrc_mask_fsys_ctrl,
937 .ctrlbit = (1 << 8),
938 },
939 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 8, .size = 8 },
940 }, {
941 .clk = {
942 .name = "sclk_mmc",
943 .id = 3,
944 .parent = &clk_dout_mmc3.clk,
945 .enable = s5pv310_clksrc_mask_fsys_ctrl,
946 .ctrlbit = (1 << 12),
947 },
948 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 24, .size = 8 },
949 }, {
950 .clk = {
951 .name = "sclk_mmc",
952 .id = 4,
953 .parent = &clk_dout_mmc4.clk,
954 .enable = s5pv310_clksrc_mask_fsys_ctrl,
955 .ctrlbit = (1 << 16),
956 },
957 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
958 }
452}; 959};
453 960
454/* Clock initialization code */ 961/* Clock initialization code */
@@ -464,8 +971,6 @@ static struct clksrc_clk *sysclks[] = {
464 &clk_aclk_cores, 971 &clk_aclk_cores,
465 &clk_aclk_corem1, 972 &clk_aclk_corem1,
466 &clk_periphclk, 973 &clk_periphclk,
467 &clk_atclk,
468 &clk_pclk_dbg,
469 &clk_mout_corebus, 974 &clk_mout_corebus,
470 &clk_sclk_dmc, 975 &clk_sclk_dmc,
471 &clk_aclk_cored, 976 &clk_aclk_cored,
@@ -478,6 +983,11 @@ static struct clksrc_clk *sysclks[] = {
478 &clk_aclk_100, 983 &clk_aclk_100,
479 &clk_aclk_160, 984 &clk_aclk_160,
480 &clk_aclk_133, 985 &clk_aclk_133,
986 &clk_dout_mmc0,
987 &clk_dout_mmc1,
988 &clk_dout_mmc2,
989 &clk_dout_mmc3,
990 &clk_dout_mmc4,
481}; 991};
482 992
483void __init_or_cpufreq s5pv310_setup_clocks(void) 993void __init_or_cpufreq s5pv310_setup_clocks(void)
@@ -490,15 +1000,11 @@ void __init_or_cpufreq s5pv310_setup_clocks(void)
490 unsigned long vpllsrc; 1000 unsigned long vpllsrc;
491 unsigned long xtal; 1001 unsigned long xtal;
492 unsigned long armclk; 1002 unsigned long armclk;
493 unsigned long aclk_corem0;
494 unsigned long aclk_cores;
495 unsigned long aclk_corem1;
496 unsigned long periphclk;
497 unsigned long sclk_dmc; 1003 unsigned long sclk_dmc;
498 unsigned long aclk_cored; 1004 unsigned long aclk_200;
499 unsigned long aclk_corep; 1005 unsigned long aclk_100;
500 unsigned long aclk_acp; 1006 unsigned long aclk_160;
501 unsigned long pclk_acp; 1007 unsigned long aclk_133;
502 unsigned int ptr; 1008 unsigned int ptr;
503 1009
504 printk(KERN_DEBUG "%s: registering clocks\n", __func__); 1010 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
@@ -529,26 +1035,21 @@ void __init_or_cpufreq s5pv310_setup_clocks(void)
529 apll, mpll, epll, vpll); 1035 apll, mpll, epll, vpll);
530 1036
531 armclk = clk_get_rate(&clk_armclk.clk); 1037 armclk = clk_get_rate(&clk_armclk.clk);
532 aclk_corem0 = clk_get_rate(&clk_aclk_corem0.clk);
533 aclk_cores = clk_get_rate(&clk_aclk_cores.clk);
534 aclk_corem1 = clk_get_rate(&clk_aclk_corem1.clk);
535 periphclk = clk_get_rate(&clk_periphclk.clk);
536 sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk); 1038 sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk);
537 aclk_cored = clk_get_rate(&clk_aclk_cored.clk); 1039
538 aclk_corep = clk_get_rate(&clk_aclk_corep.clk); 1040 aclk_200 = clk_get_rate(&clk_aclk_200.clk);
539 aclk_acp = clk_get_rate(&clk_aclk_acp.clk); 1041 aclk_100 = clk_get_rate(&clk_aclk_100.clk);
540 pclk_acp = clk_get_rate(&clk_pclk_acp.clk); 1042 aclk_160 = clk_get_rate(&clk_aclk_160.clk);
541 1043 aclk_133 = clk_get_rate(&clk_aclk_133.clk);
542 printk(KERN_INFO "S5PV310: ARMCLK=%ld, COREM0=%ld, CORES=%ld\n" 1044
543 "COREM1=%ld, PERI=%ld, DMC=%ld, CORED=%ld\n" 1045 printk(KERN_INFO "S5PV310: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
544 "COREP=%ld, ACLK_ACP=%ld, PCLK_ACP=%ld", 1046 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
545 armclk, aclk_corem0, aclk_cores, aclk_corem1, 1047 armclk, sclk_dmc, aclk_200,
546 periphclk, sclk_dmc, aclk_cored, aclk_corep, 1048 aclk_100, aclk_160, aclk_133);
547 aclk_acp, pclk_acp);
548 1049
549 clk_f.rate = armclk; 1050 clk_f.rate = armclk;
550 clk_h.rate = sclk_dmc; 1051 clk_h.rate = sclk_dmc;
551 clk_p.rate = periphclk; 1052 clk_p.rate = aclk_100;
552 1053
553 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) 1054 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
554 s3c_set_clksrc(&clksrcs[ptr], true); 1055 s3c_set_clksrc(&clksrcs[ptr], true);
diff --git a/arch/arm/mach-s5pv310/cpu.c b/arch/arm/mach-s5pv310/cpu.c
index 4add39853ff9..82ce4aa6d61a 100644
--- a/arch/arm/mach-s5pv310/cpu.c
+++ b/arch/arm/mach-s5pv310/cpu.c
@@ -15,10 +15,12 @@
15#include <asm/mach/irq.h> 15#include <asm/mach/irq.h>
16 16
17#include <asm/proc-fns.h> 17#include <asm/proc-fns.h>
18#include <asm/hardware/cache-l2x0.h>
18 19
19#include <plat/cpu.h> 20#include <plat/cpu.h>
20#include <plat/clock.h> 21#include <plat/clock.h>
21#include <plat/s5pv310.h> 22#include <plat/s5pv310.h>
23#include <plat/sdhci.h>
22 24
23#include <mach/regs-irq.h> 25#include <mach/regs-irq.h>
24 26
@@ -56,15 +58,30 @@ static struct map_desc s5pv310_iodesc[] __initdata = {
56 .length = SZ_4K, 58 .length = SZ_4K,
57 .type = MT_DEVICE, 59 .type = MT_DEVICE,
58 }, { 60 }, {
59 .virtual = (unsigned long)S5P_VA_GPIO, 61 .virtual = (unsigned long)S5P_VA_GPIO1,
60 .pfn = __phys_to_pfn(S5PV310_PA_GPIO1), 62 .pfn = __phys_to_pfn(S5PV310_PA_GPIO1),
61 .length = SZ_4K, 63 .length = SZ_4K,
62 .type = MT_DEVICE, 64 .type = MT_DEVICE,
63 }, { 65 }, {
66 .virtual = (unsigned long)S5P_VA_GPIO2,
67 .pfn = __phys_to_pfn(S5PV310_PA_GPIO2),
68 .length = SZ_4K,
69 .type = MT_DEVICE,
70 }, {
71 .virtual = (unsigned long)S5P_VA_GPIO3,
72 .pfn = __phys_to_pfn(S5PV310_PA_GPIO3),
73 .length = SZ_256,
74 .type = MT_DEVICE,
75 }, {
64 .virtual = (unsigned long)S3C_VA_UART, 76 .virtual = (unsigned long)S3C_VA_UART,
65 .pfn = __phys_to_pfn(S3C_PA_UART), 77 .pfn = __phys_to_pfn(S3C_PA_UART),
66 .length = SZ_512K, 78 .length = SZ_512K,
67 .type = MT_DEVICE, 79 .type = MT_DEVICE,
80 }, {
81 .virtual = (unsigned long)S5P_VA_SROMC,
82 .pfn = __phys_to_pfn(S5PV310_PA_SROMC),
83 .length = SZ_4K,
84 .type = MT_DEVICE,
68 }, 85 },
69}; 86};
70 87
@@ -83,6 +100,12 @@ static void s5pv310_idle(void)
83void __init s5pv310_map_io(void) 100void __init s5pv310_map_io(void)
84{ 101{
85 iotable_init(s5pv310_iodesc, ARRAY_SIZE(s5pv310_iodesc)); 102 iotable_init(s5pv310_iodesc, ARRAY_SIZE(s5pv310_iodesc));
103
104 /* initialize device information early */
105 s5pv310_default_sdhci0();
106 s5pv310_default_sdhci1();
107 s5pv310_default_sdhci2();
108 s5pv310_default_sdhci3();
86} 109}
87 110
88void __init s5pv310_init_clocks(int xtal) 111void __init s5pv310_init_clocks(int xtal)
@@ -131,6 +154,28 @@ static int __init s5pv310_core_init(void)
131 154
132core_initcall(s5pv310_core_init); 155core_initcall(s5pv310_core_init);
133 156
157#ifdef CONFIG_CACHE_L2X0
158static int __init s5pv310_l2x0_cache_init(void)
159{
160 /* TAG, Data Latency Control: 2cycle */
161 __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
162 __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
163
164 /* L2X0 Prefetch Control */
165 __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
166
167 /* L2X0 Power Control */
168 __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
169 S5P_VA_L2CC + L2X0_POWER_CTRL);
170
171 l2x0_init(S5P_VA_L2CC, 0x7C070001, 0xC200ffff);
172
173 return 0;
174}
175
176early_initcall(s5pv310_l2x0_cache_init);
177#endif
178
134int __init s5pv310_init(void) 179int __init s5pv310_init(void)
135{ 180{
136 printk(KERN_INFO "S5PV310: Initializing architecture\n"); 181 printk(KERN_INFO "S5PV310: Initializing architecture\n");
diff --git a/arch/arm/mach-s5pv310/gpiolib.c b/arch/arm/mach-s5pv310/gpiolib.c
new file mode 100644
index 000000000000..55217b8923ec
--- /dev/null
+++ b/arch/arm/mach-s5pv310/gpiolib.c
@@ -0,0 +1,304 @@
1/* linux/arch/arm/mach-s5pv310/gpiolib.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV310 - GPIOlib 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/irq.h>
15#include <linux/io.h>
16#include <linux/gpio.h>
17
18#include <mach/map.h>
19
20#include <plat/gpio-core.h>
21#include <plat/gpio-cfg.h>
22#include <plat/gpio-cfg-helpers.h>
23
24static struct s3c_gpio_cfg gpio_cfg = {
25 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
26 .set_pull = s3c_gpio_setpull_updown,
27 .get_pull = s3c_gpio_getpull_updown,
28};
29
30static struct s3c_gpio_cfg gpio_cfg_noint = {
31 .set_config = s3c_gpio_setcfg_s3c64xx_4bit,
32 .set_pull = s3c_gpio_setpull_updown,
33 .get_pull = s3c_gpio_getpull_updown,
34};
35
36/*
37 * Following are the gpio banks in v310.
38 *
39 * The 'config' member when left to NULL, is initialized to the default
40 * structure gpio_cfg in the init function below.
41 *
42 * The 'base' member is also initialized in the init function below.
43 * Note: The initialization of 'base' member of s3c_gpio_chip structure
44 * uses the above macro and depends on the banks being listed in order here.
45 */
46static struct s3c_gpio_chip s5pv310_gpio_part1_4bit[] = {
47 {
48 .chip = {
49 .base = S5PV310_GPA0(0),
50 .ngpio = S5PV310_GPIO_A0_NR,
51 .label = "GPA0",
52 },
53 }, {
54 .chip = {
55 .base = S5PV310_GPA1(0),
56 .ngpio = S5PV310_GPIO_A1_NR,
57 .label = "GPA1",
58 },
59 }, {
60 .chip = {
61 .base = S5PV310_GPB(0),
62 .ngpio = S5PV310_GPIO_B_NR,
63 .label = "GPB",
64 },
65 }, {
66 .chip = {
67 .base = S5PV310_GPC0(0),
68 .ngpio = S5PV310_GPIO_C0_NR,
69 .label = "GPC0",
70 },
71 }, {
72 .chip = {
73 .base = S5PV310_GPC1(0),
74 .ngpio = S5PV310_GPIO_C1_NR,
75 .label = "GPC1",
76 },
77 }, {
78 .chip = {
79 .base = S5PV310_GPD0(0),
80 .ngpio = S5PV310_GPIO_D0_NR,
81 .label = "GPD0",
82 },
83 }, {
84 .chip = {
85 .base = S5PV310_GPD1(0),
86 .ngpio = S5PV310_GPIO_D1_NR,
87 .label = "GPD1",
88 },
89 }, {
90 .chip = {
91 .base = S5PV310_GPE0(0),
92 .ngpio = S5PV310_GPIO_E0_NR,
93 .label = "GPE0",
94 },
95 }, {
96 .chip = {
97 .base = S5PV310_GPE1(0),
98 .ngpio = S5PV310_GPIO_E1_NR,
99 .label = "GPE1",
100 },
101 }, {
102 .chip = {
103 .base = S5PV310_GPE2(0),
104 .ngpio = S5PV310_GPIO_E2_NR,
105 .label = "GPE2",
106 },
107 }, {
108 .chip = {
109 .base = S5PV310_GPE3(0),
110 .ngpio = S5PV310_GPIO_E3_NR,
111 .label = "GPE3",
112 },
113 }, {
114 .chip = {
115 .base = S5PV310_GPE4(0),
116 .ngpio = S5PV310_GPIO_E4_NR,
117 .label = "GPE4",
118 },
119 }, {
120 .chip = {
121 .base = S5PV310_GPF0(0),
122 .ngpio = S5PV310_GPIO_F0_NR,
123 .label = "GPF0",
124 },
125 }, {
126 .chip = {
127 .base = S5PV310_GPF1(0),
128 .ngpio = S5PV310_GPIO_F1_NR,
129 .label = "GPF1",
130 },
131 }, {
132 .chip = {
133 .base = S5PV310_GPF2(0),
134 .ngpio = S5PV310_GPIO_F2_NR,
135 .label = "GPF2",
136 },
137 }, {
138 .chip = {
139 .base = S5PV310_GPF3(0),
140 .ngpio = S5PV310_GPIO_F3_NR,
141 .label = "GPF3",
142 },
143 },
144};
145
146static struct s3c_gpio_chip s5pv310_gpio_part2_4bit[] = {
147 {
148 .chip = {
149 .base = S5PV310_GPJ0(0),
150 .ngpio = S5PV310_GPIO_J0_NR,
151 .label = "GPJ0",
152 },
153 }, {
154 .chip = {
155 .base = S5PV310_GPJ1(0),
156 .ngpio = S5PV310_GPIO_J1_NR,
157 .label = "GPJ1",
158 },
159 }, {
160 .chip = {
161 .base = S5PV310_GPK0(0),
162 .ngpio = S5PV310_GPIO_K0_NR,
163 .label = "GPK0",
164 },
165 }, {
166 .chip = {
167 .base = S5PV310_GPK1(0),
168 .ngpio = S5PV310_GPIO_K1_NR,
169 .label = "GPK1",
170 },
171 }, {
172 .chip = {
173 .base = S5PV310_GPK2(0),
174 .ngpio = S5PV310_GPIO_K2_NR,
175 .label = "GPK2",
176 },
177 }, {
178 .chip = {
179 .base = S5PV310_GPK3(0),
180 .ngpio = S5PV310_GPIO_K3_NR,
181 .label = "GPK3",
182 },
183 }, {
184 .chip = {
185 .base = S5PV310_GPL0(0),
186 .ngpio = S5PV310_GPIO_L0_NR,
187 .label = "GPL0",
188 },
189 }, {
190 .chip = {
191 .base = S5PV310_GPL1(0),
192 .ngpio = S5PV310_GPIO_L1_NR,
193 .label = "GPL1",
194 },
195 }, {
196 .chip = {
197 .base = S5PV310_GPL2(0),
198 .ngpio = S5PV310_GPIO_L2_NR,
199 .label = "GPL2",
200 },
201 }, {
202 .base = (S5P_VA_GPIO2 + 0xC00),
203 .config = &gpio_cfg_noint,
204 .irq_base = IRQ_EINT(0),
205 .chip = {
206 .base = S5PV310_GPX0(0),
207 .ngpio = S5PV310_GPIO_X0_NR,
208 .label = "GPX0",
209 .to_irq = samsung_gpiolib_to_irq,
210 },
211 }, {
212 .base = (S5P_VA_GPIO2 + 0xC20),
213 .config = &gpio_cfg_noint,
214 .irq_base = IRQ_EINT(8),
215 .chip = {
216 .base = S5PV310_GPX1(0),
217 .ngpio = S5PV310_GPIO_X1_NR,
218 .label = "GPX1",
219 .to_irq = samsung_gpiolib_to_irq,
220 },
221 }, {
222 .base = (S5P_VA_GPIO2 + 0xC40),
223 .config = &gpio_cfg_noint,
224 .irq_base = IRQ_EINT(16),
225 .chip = {
226 .base = S5PV310_GPX2(0),
227 .ngpio = S5PV310_GPIO_X2_NR,
228 .label = "GPX2",
229 .to_irq = samsung_gpiolib_to_irq,
230 },
231 }, {
232 .base = (S5P_VA_GPIO2 + 0xC60),
233 .config = &gpio_cfg_noint,
234 .irq_base = IRQ_EINT(24),
235 .chip = {
236 .base = S5PV310_GPX3(0),
237 .ngpio = S5PV310_GPIO_X3_NR,
238 .label = "GPX3",
239 .to_irq = samsung_gpiolib_to_irq,
240 },
241 },
242};
243
244static struct s3c_gpio_chip s5pv310_gpio_part3_4bit[] = {
245 {
246 .chip = {
247 .base = S5PV310_GPZ(0),
248 .ngpio = S5PV310_GPIO_Z_NR,
249 .label = "GPZ",
250 },
251 },
252};
253
254static __init int s5pv310_gpiolib_init(void)
255{
256 struct s3c_gpio_chip *chip;
257 int i;
258 int nr_chips;
259
260 /* GPIO part 1 */
261
262 chip = s5pv310_gpio_part1_4bit;
263 nr_chips = ARRAY_SIZE(s5pv310_gpio_part1_4bit);
264
265 for (i = 0; i < nr_chips; i++, chip++) {
266 if (chip->config == NULL)
267 chip->config = &gpio_cfg;
268 if (chip->base == NULL)
269 chip->base = S5P_VA_GPIO1 + (i) * 0x20;
270 }
271
272 samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part1_4bit, nr_chips);
273
274 /* GPIO part 2 */
275
276 chip = s5pv310_gpio_part2_4bit;
277 nr_chips = ARRAY_SIZE(s5pv310_gpio_part2_4bit);
278
279 for (i = 0; i < nr_chips; i++, chip++) {
280 if (chip->config == NULL)
281 chip->config = &gpio_cfg;
282 if (chip->base == NULL)
283 chip->base = S5P_VA_GPIO2 + (i) * 0x20;
284 }
285
286 samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part2_4bit, nr_chips);
287
288 /* GPIO part 3 */
289
290 chip = s5pv310_gpio_part3_4bit;
291 nr_chips = ARRAY_SIZE(s5pv310_gpio_part3_4bit);
292
293 for (i = 0; i < nr_chips; i++, chip++) {
294 if (chip->config == NULL)
295 chip->config = &gpio_cfg;
296 if (chip->base == NULL)
297 chip->base = S5P_VA_GPIO3 + (i) * 0x20;
298 }
299
300 samsung_gpiolib_add_4bit_chips(s5pv310_gpio_part3_4bit, nr_chips);
301
302 return 0;
303}
304core_initcall(s5pv310_gpiolib_init);
diff --git a/arch/arm/mach-s5pv310/hotplug.c b/arch/arm/mach-s5pv310/hotplug.c
new file mode 100644
index 000000000000..03652c3605f6
--- /dev/null
+++ b/arch/arm/mach-s5pv310/hotplug.c
@@ -0,0 +1,144 @@
1/* linux arch/arm/mach-s5pv310/hotplug.c
2 *
3 * Cloned from linux/arch/arm/mach-realview/hotplug.c
4 *
5 * Copyright (C) 2002 ARM Ltd.
6 * All Rights Reserved
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/errno.h>
15#include <linux/smp.h>
16#include <linux/completion.h>
17
18#include <asm/cacheflush.h>
19
20extern volatile int pen_release;
21
22static DECLARE_COMPLETION(cpu_killed);
23
24static inline void cpu_enter_lowpower(void)
25{
26 unsigned int v;
27
28 flush_cache_all();
29 asm volatile(
30 " mcr p15, 0, %1, c7, c5, 0\n"
31 " mcr p15, 0, %1, c7, c10, 4\n"
32 /*
33 * Turn off coherency
34 */
35 " mrc p15, 0, %0, c1, c0, 1\n"
36 " bic %0, %0, #0x20\n"
37 " mcr p15, 0, %0, c1, c0, 1\n"
38 " mrc p15, 0, %0, c1, c0, 0\n"
39 " bic %0, %0, #0x04\n"
40 " mcr p15, 0, %0, c1, c0, 0\n"
41 : "=&r" (v)
42 : "r" (0)
43 : "cc");
44}
45
46static inline void cpu_leave_lowpower(void)
47{
48 unsigned int v;
49
50 asm volatile(
51 "mrc p15, 0, %0, c1, c0, 0\n"
52 " orr %0, %0, #0x04\n"
53 " mcr p15, 0, %0, c1, c0, 0\n"
54 " mrc p15, 0, %0, c1, c0, 1\n"
55 " orr %0, %0, #0x20\n"
56 " mcr p15, 0, %0, c1, c0, 1\n"
57 : "=&r" (v)
58 :
59 : "cc");
60}
61
62static inline void platform_do_lowpower(unsigned int cpu)
63{
64 /*
65 * there is no power-control hardware on this platform, so all
66 * we can do is put the core into WFI; this is safe as the calling
67 * code will have already disabled interrupts
68 */
69 for (;;) {
70 /*
71 * here's the WFI
72 */
73 asm(".word 0xe320f003\n"
74 :
75 :
76 : "memory", "cc");
77
78 if (pen_release == cpu) {
79 /*
80 * OK, proper wakeup, we're done
81 */
82 break;
83 }
84
85 /*
86 * getting here, means that we have come out of WFI without
87 * having been woken up - this shouldn't happen
88 *
89 * The trouble is, letting people know about this is not really
90 * possible, since we are currently running incoherently, and
91 * therefore cannot safely call printk() or anything else
92 */
93#ifdef DEBUG
94 printk(KERN_WARN "CPU%u: spurious wakeup call\n", cpu);
95#endif
96 }
97}
98
99int platform_cpu_kill(unsigned int cpu)
100{
101 return wait_for_completion_timeout(&cpu_killed, 5000);
102}
103
104/*
105 * platform-specific code to shutdown a CPU
106 *
107 * Called with IRQs disabled
108 */
109void platform_cpu_die(unsigned int cpu)
110{
111#ifdef DEBUG
112 unsigned int this_cpu = hard_smp_processor_id();
113
114 if (cpu != this_cpu) {
115 printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
116 this_cpu, cpu);
117 BUG();
118 }
119#endif
120
121 printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
122 complete(&cpu_killed);
123
124 /*
125 * we're ready for shutdown now, so do it
126 */
127 cpu_enter_lowpower();
128 platform_do_lowpower(cpu);
129
130 /*
131 * bring this CPU back into the world of cache
132 * coherency, and then restore interrupts
133 */
134 cpu_leave_lowpower();
135}
136
137int platform_cpu_disable(unsigned int cpu)
138{
139 /*
140 * we don't allow CPU 0 to be shutdown (it is still too special
141 * e.g. clock tick interrupts)
142 */
143 return cpu == 0 ? -EPERM : 0;
144}
diff --git a/arch/arm/mach-s5pv310/include/mach/irqs.h b/arch/arm/mach-s5pv310/include/mach/irqs.h
index 471fc3bb199a..99e7dad8a85a 100644
--- a/arch/arm/mach-s5pv310/include/mach/irqs.h
+++ b/arch/arm/mach-s5pv310/include/mach/irqs.h
@@ -3,7 +3,7 @@
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 * S5PV210 - IRQ definitions 6 * S5PV310 - 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
@@ -60,6 +60,9 @@
60#define IRQ_TIMER3_VIC COMBINER_IRQ(22, 3) 60#define IRQ_TIMER3_VIC COMBINER_IRQ(22, 3)
61#define IRQ_TIMER4_VIC COMBINER_IRQ(22, 4) 61#define IRQ_TIMER4_VIC COMBINER_IRQ(22, 4)
62 62
63#define IRQ_RTC_ALARM COMBINER_IRQ(23, 0)
64#define IRQ_RTC_TIC COMBINER_IRQ(23, 1)
65
63#define IRQ_UART0 COMBINER_IRQ(26, 0) 66#define IRQ_UART0 COMBINER_IRQ(26, 0)
64#define IRQ_UART1 COMBINER_IRQ(26, 1) 67#define IRQ_UART1 COMBINER_IRQ(26, 1)
65#define IRQ_UART2 COMBINER_IRQ(26, 2) 68#define IRQ_UART2 COMBINER_IRQ(26, 2)
@@ -67,13 +70,46 @@
67#define IRQ_UART4 COMBINER_IRQ(26, 4) 70#define IRQ_UART4 COMBINER_IRQ(26, 4)
68 71
69#define IRQ_IIC COMBINER_IRQ(27, 0) 72#define IRQ_IIC COMBINER_IRQ(27, 0)
73#define IRQ_IIC1 COMBINER_IRQ(27, 1)
74#define IRQ_IIC2 COMBINER_IRQ(27, 2)
75#define IRQ_IIC3 COMBINER_IRQ(27, 3)
76#define IRQ_IIC4 COMBINER_IRQ(27, 4)
77#define IRQ_IIC5 COMBINER_IRQ(27, 5)
78#define IRQ_IIC6 COMBINER_IRQ(27, 6)
79#define IRQ_IIC7 COMBINER_IRQ(27, 7)
80
81#define IRQ_HSMMC0 COMBINER_IRQ(29, 0)
82#define IRQ_HSMMC1 COMBINER_IRQ(29, 1)
83#define IRQ_HSMMC2 COMBINER_IRQ(29, 2)
84#define IRQ_HSMMC3 COMBINER_IRQ(29, 3)
70 85
71#define IRQ_ONENAND_AUDI COMBINER_IRQ(34, 0) 86#define IRQ_ONENAND_AUDI COMBINER_IRQ(34, 0)
72 87
73/* Set the default NR_IRQS */ 88#define IRQ_EINT4 COMBINER_IRQ(37, 0)
89#define IRQ_EINT5 COMBINER_IRQ(37, 1)
90#define IRQ_EINT6 COMBINER_IRQ(37, 2)
91#define IRQ_EINT7 COMBINER_IRQ(37, 3)
92#define IRQ_EINT8 COMBINER_IRQ(38, 0)
93
94#define IRQ_EINT9 COMBINER_IRQ(38, 1)
95#define IRQ_EINT10 COMBINER_IRQ(38, 2)
96#define IRQ_EINT11 COMBINER_IRQ(38, 3)
97#define IRQ_EINT12 COMBINER_IRQ(38, 4)
98#define IRQ_EINT13 COMBINER_IRQ(38, 5)
99#define IRQ_EINT14 COMBINER_IRQ(38, 6)
100#define IRQ_EINT15 COMBINER_IRQ(38, 7)
101
102#define IRQ_EINT16_31 COMBINER_IRQ(39, 0)
74 103
75#define NR_IRQS COMBINER_IRQ(MAX_COMBINER_NR, 0) 104#define MAX_COMBINER_NR 40
105
106#define S5P_IRQ_EINT_BASE COMBINER_IRQ(MAX_COMBINER_NR, 0)
107
108#define S5P_EINT_BASE1 (S5P_IRQ_EINT_BASE + 0)
109#define S5P_EINT_BASE2 (S5P_IRQ_EINT_BASE + 16)
110
111/* Set the default NR_IRQS */
76 112
77#define MAX_COMBINER_NR 39 113#define NR_IRQS (S5P_IRQ_EINT_BASE + 32)
78 114
79#endif /* __ASM_ARCH_IRQS_H */ 115#endif /* __ASM_ARCH_IRQS_H */
diff --git a/arch/arm/mach-s5pv310/include/mach/map.h b/arch/arm/mach-s5pv310/include/mach/map.h
index aff6d23624bb..7acf4e77e92e 100644
--- a/arch/arm/mach-s5pv310/include/mach/map.h
+++ b/arch/arm/mach-s5pv310/include/mach/map.h
@@ -25,6 +25,8 @@
25 25
26#define S5PV310_PA_SYSRAM (0x02025000) 26#define S5PV310_PA_SYSRAM (0x02025000)
27 27
28#define S5PV310_PA_SROM_BANK(x) (0x04000000 + ((x) * 0x01000000))
29
28#define S5PC210_PA_ONENAND (0x0C000000) 30#define S5PC210_PA_ONENAND (0x0C000000)
29#define S5P_PA_ONENAND S5PC210_PA_ONENAND 31#define S5P_PA_ONENAND S5PC210_PA_ONENAND
30 32
@@ -34,12 +36,13 @@
34#define S5PV310_PA_CHIPID (0x10000000) 36#define S5PV310_PA_CHIPID (0x10000000)
35#define S5P_PA_CHIPID S5PV310_PA_CHIPID 37#define S5P_PA_CHIPID S5PV310_PA_CHIPID
36 38
37#define S5PV310_PA_SYSCON (0x10020000) 39#define S5PV310_PA_SYSCON (0x10010000)
38#define S5P_PA_SYSCON S5PV310_PA_SYSCON 40#define S5P_PA_SYSCON S5PV310_PA_SYSCON
39 41
40#define S5PV310_PA_CMU (0x10030000) 42#define S5PV310_PA_CMU (0x10030000)
41 43
42#define S5PV310_PA_WATCHDOG (0x10060000) 44#define S5PV310_PA_WATCHDOG (0x10060000)
45#define S5PV310_PA_RTC (0x10070000)
43 46
44#define S5PV310_PA_COMBINER (0x10448000) 47#define S5PV310_PA_COMBINER (0x10448000)
45 48
@@ -55,6 +58,8 @@
55 58
56#define S5PV310_PA_HSMMC(x) (0x12510000 + ((x) * 0x10000)) 59#define S5PV310_PA_HSMMC(x) (0x12510000 + ((x) * 0x10000))
57 60
61#define S5PV310_PA_SROMC (0x12570000)
62
58#define S5PV310_PA_UART (0x13800000) 63#define S5PV310_PA_UART (0x13800000)
59 64
60#define S5P_PA_UART(x) (S5PV310_PA_UART + ((x) * S3C_UART_OFFSET)) 65#define S5P_PA_UART(x) (S5PV310_PA_UART + ((x) * S3C_UART_OFFSET))
@@ -66,7 +71,7 @@
66 71
67#define S5P_SZ_UART SZ_256 72#define S5P_SZ_UART SZ_256
68 73
69#define S5PV310_PA_IIC0 (0x13860000) 74#define S5PV310_PA_IIC(x) (0x13860000 + ((x) * 0x10000))
70 75
71#define S5PV310_PA_TIMER (0x139D0000) 76#define S5PV310_PA_TIMER (0x139D0000)
72#define S5P_PA_TIMER S5PV310_PA_TIMER 77#define S5P_PA_TIMER S5PV310_PA_TIMER
@@ -80,7 +85,15 @@
80#define S3C_PA_HSMMC1 S5PV310_PA_HSMMC(1) 85#define S3C_PA_HSMMC1 S5PV310_PA_HSMMC(1)
81#define S3C_PA_HSMMC2 S5PV310_PA_HSMMC(2) 86#define S3C_PA_HSMMC2 S5PV310_PA_HSMMC(2)
82#define S3C_PA_HSMMC3 S5PV310_PA_HSMMC(3) 87#define S3C_PA_HSMMC3 S5PV310_PA_HSMMC(3)
83#define S3C_PA_IIC S5PV310_PA_IIC0 88#define S3C_PA_IIC S5PV310_PA_IIC(0)
89#define S3C_PA_IIC1 S5PV310_PA_IIC(1)
90#define S3C_PA_IIC2 S5PV310_PA_IIC(2)
91#define S3C_PA_IIC3 S5PV310_PA_IIC(3)
92#define S3C_PA_IIC4 S5PV310_PA_IIC(4)
93#define S3C_PA_IIC5 S5PV310_PA_IIC(5)
94#define S3C_PA_IIC6 S5PV310_PA_IIC(6)
95#define S3C_PA_IIC7 S5PV310_PA_IIC(7)
96#define S3C_PA_RTC S5PV310_PA_RTC
84#define S3C_PA_WDT S5PV310_PA_WATCHDOG 97#define S3C_PA_WDT S5PV310_PA_WATCHDOG
85 98
86#endif /* __ASM_ARCH_MAP_H */ 99#endif /* __ASM_ARCH_MAP_H */
diff --git a/arch/arm/mach-s5pv310/include/mach/regs-clock.h b/arch/arm/mach-s5pv310/include/mach/regs-clock.h
index 4013553cd9be..f1028cad9788 100644
--- a/arch/arm/mach-s5pv310/include/mach/regs-clock.h
+++ b/arch/arm/mach-s5pv310/include/mach/regs-clock.h
@@ -26,11 +26,23 @@
26 26
27#define S5P_CLKSRC_TOP0 S5P_CLKREG(0x0C210) 27#define S5P_CLKSRC_TOP0 S5P_CLKREG(0x0C210)
28#define S5P_CLKSRC_TOP1 S5P_CLKREG(0x0C214) 28#define S5P_CLKSRC_TOP1 S5P_CLKREG(0x0C214)
29 29#define S5P_CLKSRC_CAM S5P_CLKREG(0x0C220)
30#define S5P_CLKSRC_IMAGE S5P_CLKREG(0x0C230)
31#define S5P_CLKSRC_LCD0 S5P_CLKREG(0x0C234)
32#define S5P_CLKSRC_LCD1 S5P_CLKREG(0x0C238)
33#define S5P_CLKSRC_FSYS S5P_CLKREG(0x0C240)
30#define S5P_CLKSRC_PERIL0 S5P_CLKREG(0x0C250) 34#define S5P_CLKSRC_PERIL0 S5P_CLKREG(0x0C250)
35#define S5P_CLKSRC_PERIL1 S5P_CLKREG(0x0C254)
31 36
32#define S5P_CLKDIV_TOP S5P_CLKREG(0x0C510) 37#define S5P_CLKDIV_TOP S5P_CLKREG(0x0C510)
33 38#define S5P_CLKDIV_CAM S5P_CLKREG(0x0C520)
39#define S5P_CLKDIV_IMAGE S5P_CLKREG(0x0C530)
40#define S5P_CLKDIV_LCD0 S5P_CLKREG(0x0C534)
41#define S5P_CLKDIV_LCD1 S5P_CLKREG(0x0C538)
42#define S5P_CLKDIV_FSYS0 S5P_CLKREG(0x0C540)
43#define S5P_CLKDIV_FSYS1 S5P_CLKREG(0x0C544)
44#define S5P_CLKDIV_FSYS2 S5P_CLKREG(0x0C548)
45#define S5P_CLKDIV_FSYS3 S5P_CLKREG(0x0C54C)
34#define S5P_CLKDIV_PERIL0 S5P_CLKREG(0x0C550) 46#define S5P_CLKDIV_PERIL0 S5P_CLKREG(0x0C550)
35#define S5P_CLKDIV_PERIL1 S5P_CLKREG(0x0C554) 47#define S5P_CLKDIV_PERIL1 S5P_CLKREG(0x0C554)
36#define S5P_CLKDIV_PERIL2 S5P_CLKREG(0x0C558) 48#define S5P_CLKDIV_PERIL2 S5P_CLKREG(0x0C558)
@@ -38,9 +50,21 @@
38#define S5P_CLKDIV_PERIL4 S5P_CLKREG(0x0C560) 50#define S5P_CLKDIV_PERIL4 S5P_CLKREG(0x0C560)
39#define S5P_CLKDIV_PERIL5 S5P_CLKREG(0x0C564) 51#define S5P_CLKDIV_PERIL5 S5P_CLKREG(0x0C564)
40 52
53#define S5P_CLKSRC_MASK_TOP S5P_CLKREG(0x0C310)
54#define S5P_CLKSRC_MASK_CAM S5P_CLKREG(0x0C320)
55#define S5P_CLKSRC_MASK_LCD0 S5P_CLKREG(0x0C334)
56#define S5P_CLKSRC_MASK_LCD1 S5P_CLKREG(0x0C338)
57#define S5P_CLKSRC_MASK_FSYS S5P_CLKREG(0x0C340)
41#define S5P_CLKSRC_MASK_PERIL0 S5P_CLKREG(0x0C350) 58#define S5P_CLKSRC_MASK_PERIL0 S5P_CLKREG(0x0C350)
59#define S5P_CLKSRC_MASK_PERIL1 S5P_CLKREG(0x0C354)
42 60
61#define S5P_CLKGATE_IP_CAM S5P_CLKREG(0x0C920)
62#define S5P_CLKGATE_IP_IMAGE S5P_CLKREG(0x0C930)
63#define S5P_CLKGATE_IP_LCD0 S5P_CLKREG(0x0C934)
64#define S5P_CLKGATE_IP_LCD1 S5P_CLKREG(0x0C938)
65#define S5P_CLKGATE_IP_FSYS S5P_CLKREG(0x0C940)
43#define S5P_CLKGATE_IP_PERIL S5P_CLKREG(0x0C950) 66#define S5P_CLKGATE_IP_PERIL S5P_CLKREG(0x0C950)
67#define S5P_CLKGATE_IP_PERIR S5P_CLKREG(0x0C960)
44 68
45#define S5P_CLKSRC_CORE S5P_CLKREG(0x10200) 69#define S5P_CLKSRC_CORE S5P_CLKREG(0x10200)
46#define S5P_CLKDIV_CORE0 S5P_CLKREG(0x10500) 70#define S5P_CLKDIV_CORE0 S5P_CLKREG(0x10500)
@@ -60,4 +84,8 @@
60 84
61#define S5P_CLKGATE_SCLKCPU S5P_CLKREG(0x14800) 85#define S5P_CLKGATE_SCLKCPU S5P_CLKREG(0x14800)
62 86
87/* Compatibility defines */
88
89#define S5P_EPLL_CON S5P_EPLL_CON0
90
63#endif /* __ASM_ARCH_REGS_CLOCK_H */ 91#endif /* __ASM_ARCH_REGS_CLOCK_H */
diff --git a/arch/arm/mach-s5pv310/include/mach/regs-gpio.h b/arch/arm/mach-s5pv310/include/mach/regs-gpio.h
new file mode 100644
index 000000000000..82e9e0c9d452
--- /dev/null
+++ b/arch/arm/mach-s5pv310/include/mach/regs-gpio.h
@@ -0,0 +1,42 @@
1/* linux/arch/arm/mach-s5pv310/include/mach/regs-gpio.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV310 - GPIO (including EINT) 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_GPIO_H
14#define __ASM_ARCH_REGS_GPIO_H __FILE__
15
16#include <mach/map.h>
17#include <mach/irqs.h>
18
19#define S5PV310_EINT40CON (S5P_VA_GPIO2 + 0xE00)
20#define S5P_EINT_CON(x) (S5PV310_EINT40CON + ((x) * 0x4))
21
22#define S5PV310_EINT40FLTCON0 (S5P_VA_GPIO2 + 0xE80)
23#define S5P_EINT_FLTCON(x) (S5PV310_EINT40FLTCON0 + ((x) * 0x4))
24
25#define S5PV310_EINT40MASK (S5P_VA_GPIO2 + 0xF00)
26#define S5P_EINT_MASK(x) (S5PV310_EINT40MASK + ((x) * 0x4))
27
28#define S5PV310_EINT40PEND (S5P_VA_GPIO2 + 0xF40)
29#define S5P_EINT_PEND(x) (S5PV310_EINT40PEND + ((x) * 0x4))
30
31#define EINT_REG_NR(x) (EINT_OFFSET(x) >> 3)
32
33#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7))
34
35#define EINT_MODE S3C_GPIO_SFN(0xf)
36
37#define EINT_GPIO_0(x) S5PV310_GPX0(x)
38#define EINT_GPIO_1(x) S5PV310_GPX1(x)
39#define EINT_GPIO_2(x) S5PV310_GPX2(x)
40#define EINT_GPIO_3(x) S5PV310_GPX3(x)
41
42#endif /* __ASM_ARCH_REGS_GPIO_H */
diff --git a/arch/arm/mach-s5pv310/include/mach/regs-srom.h b/arch/arm/mach-s5pv310/include/mach/regs-srom.h
new file mode 100644
index 000000000000..1898b3e10550
--- /dev/null
+++ b/arch/arm/mach-s5pv310/include/mach/regs-srom.h
@@ -0,0 +1,50 @@
1/* linux/arch/arm/mach-s5pv310/include/mach/regs-srom.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV310 - SROMC 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_SROM_H
14#define __ASM_ARCH_REGS_SROM_H __FILE__
15
16#include <mach/map.h>
17
18#define S5PV310_SROMREG(x) (S5P_VA_SROMC + (x))
19
20#define S5PV310_SROM_BW S5PV310_SROMREG(0x0)
21#define S5PV310_SROM_BC0 S5PV310_SROMREG(0x4)
22#define S5PV310_SROM_BC1 S5PV310_SROMREG(0x8)
23#define S5PV310_SROM_BC2 S5PV310_SROMREG(0xc)
24#define S5PV310_SROM_BC3 S5PV310_SROMREG(0x10)
25
26/* one register BW holds 4 x 4-bit packed settings for NCS0 - NCS3 */
27
28#define S5PV310_SROM_BW__DATAWIDTH__SHIFT 0
29#define S5PV310_SROM_BW__ADDRMODE__SHIFT 1
30#define S5PV310_SROM_BW__WAITENABLE__SHIFT 2
31#define S5PV310_SROM_BW__BYTEENABLE__SHIFT 3
32
33#define S5PV310_SROM_BW__CS_MASK 0xf
34
35#define S5PV310_SROM_BW__NCS0__SHIFT 0
36#define S5PV310_SROM_BW__NCS1__SHIFT 4
37#define S5PV310_SROM_BW__NCS2__SHIFT 8
38#define S5PV310_SROM_BW__NCS3__SHIFT 12
39
40/* applies to same to BCS0 - BCS3 */
41
42#define S5PV310_SROM_BCX__PMC__SHIFT 0
43#define S5PV310_SROM_BCX__TACP__SHIFT 4
44#define S5PV310_SROM_BCX__TCAH__SHIFT 8
45#define S5PV310_SROM_BCX__TCOH__SHIFT 12
46#define S5PV310_SROM_BCX__TACC__SHIFT 16
47#define S5PV310_SROM_BCX__TCOS__SHIFT 24
48#define S5PV310_SROM_BCX__TACS__SHIFT 28
49
50#endif /* __ASM_ARCH_REGS_SROM_H */
diff --git a/arch/arm/mach-s5pv310/include/mach/vmalloc.h b/arch/arm/mach-s5pv310/include/mach/vmalloc.h
index 256f221edf3a..65759fb97581 100644
--- a/arch/arm/mach-s5pv310/include/mach/vmalloc.h
+++ b/arch/arm/mach-s5pv310/include/mach/vmalloc.h
@@ -17,6 +17,6 @@
17#ifndef __ASM_ARCH_VMALLOC_H 17#ifndef __ASM_ARCH_VMALLOC_H
18#define __ASM_ARCH_VMALLOC_H __FILE__ 18#define __ASM_ARCH_VMALLOC_H __FILE__
19 19
20#define VMALLOC_END (0xF0000000UL) 20#define VMALLOC_END 0xF6000000UL
21 21
22#endif /* __ASM_ARCH_VMALLOC_H */ 22#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/arch/arm/mach-s5pv310/irq-combiner.c b/arch/arm/mach-s5pv310/irq-combiner.c
index 0f7052164f23..c3f88c3faf6c 100644
--- a/arch/arm/mach-s5pv310/irq-combiner.c
+++ b/arch/arm/mach-s5pv310/irq-combiner.c
@@ -66,11 +66,7 @@ static void combiner_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
66 if (status == 0) 66 if (status == 0)
67 goto out; 67 goto out;
68 68
69 for (combiner_irq = 0; combiner_irq < 32; combiner_irq++) { 69 combiner_irq = __ffs(status);
70 if (status & 0x1)
71 break;
72 status >>= 1;
73 }
74 70
75 cascade_irq = combiner_irq + (chip_data->irq_offset & ~31); 71 cascade_irq = combiner_irq + (chip_data->irq_offset & ~31);
76 if (unlikely(cascade_irq >= NR_IRQS)) 72 if (unlikely(cascade_irq >= NR_IRQS))
diff --git a/arch/arm/mach-s5pv310/irq-eint.c b/arch/arm/mach-s5pv310/irq-eint.c
new file mode 100644
index 000000000000..5877503e92c3
--- /dev/null
+++ b/arch/arm/mach-s5pv310/irq-eint.c
@@ -0,0 +1,228 @@
1/* linux/arch/arm/mach-s5pv310/irq-eint.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5PV310 - IRQ EINT 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/interrupt.h>
15#include <linux/irq.h>
16#include <linux/io.h>
17#include <linux/sysdev.h>
18#include <linux/gpio.h>
19
20#include <plat/pm.h>
21#include <plat/cpu.h>
22#include <plat/gpio-cfg.h>
23
24#include <mach/regs-gpio.h>
25
26static DEFINE_SPINLOCK(eint_lock);
27
28static unsigned int eint0_15_data[16];
29
30static unsigned int s5pv310_get_irq_nr(unsigned int number)
31{
32 u32 ret = 0;
33
34 switch (number) {
35 case 0 ... 3:
36 ret = (number + IRQ_EINT0);
37 break;
38 case 4 ... 7:
39 ret = (number + (IRQ_EINT4 - 4));
40 break;
41 case 8 ... 15:
42 ret = (number + (IRQ_EINT8 - 8));
43 break;
44 default:
45 printk(KERN_ERR "number available : %d\n", number);
46 }
47
48 return ret;
49}
50
51static inline void s5pv310_irq_eint_mask(unsigned int irq)
52{
53 u32 mask;
54
55 spin_lock(&eint_lock);
56 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(irq)));
57 mask |= eint_irq_to_bit(irq);
58 __raw_writel(mask, S5P_EINT_MASK(EINT_REG_NR(irq)));
59 spin_unlock(&eint_lock);
60}
61
62static void s5pv310_irq_eint_unmask(unsigned int irq)
63{
64 u32 mask;
65
66 spin_lock(&eint_lock);
67 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(irq)));
68 mask &= ~(eint_irq_to_bit(irq));
69 __raw_writel(mask, S5P_EINT_MASK(EINT_REG_NR(irq)));
70 spin_unlock(&eint_lock);
71}
72
73static inline void s5pv310_irq_eint_ack(unsigned int irq)
74{
75 __raw_writel(eint_irq_to_bit(irq), S5P_EINT_PEND(EINT_REG_NR(irq)));
76}
77
78static void s5pv310_irq_eint_maskack(unsigned int irq)
79{
80 s5pv310_irq_eint_mask(irq);
81 s5pv310_irq_eint_ack(irq);
82}
83
84static int s5pv310_irq_eint_set_type(unsigned int irq, unsigned int type)
85{
86 int offs = EINT_OFFSET(irq);
87 int shift;
88 u32 ctrl, mask;
89 u32 newvalue = 0;
90
91 switch (type) {
92 case IRQ_TYPE_EDGE_RISING:
93 newvalue = S5P_IRQ_TYPE_EDGE_RISING;
94 break;
95
96 case IRQ_TYPE_EDGE_FALLING:
97 newvalue = S5P_IRQ_TYPE_EDGE_FALLING;
98 break;
99
100 case IRQ_TYPE_EDGE_BOTH:
101 newvalue = S5P_IRQ_TYPE_EDGE_BOTH;
102 break;
103
104 case IRQ_TYPE_LEVEL_LOW:
105 newvalue = S5P_IRQ_TYPE_LEVEL_LOW;
106 break;
107
108 case IRQ_TYPE_LEVEL_HIGH:
109 newvalue = S5P_IRQ_TYPE_LEVEL_HIGH;
110 break;
111
112 default:
113 printk(KERN_ERR "No such irq type %d", type);
114 return -EINVAL;
115 }
116
117 shift = (offs & 0x7) * 4;
118 mask = 0x7 << shift;
119
120 spin_lock(&eint_lock);
121 ctrl = __raw_readl(S5P_EINT_CON(EINT_REG_NR(irq)));
122 ctrl &= ~mask;
123 ctrl |= newvalue << shift;
124 __raw_writel(ctrl, S5P_EINT_CON(EINT_REG_NR(irq)));
125 spin_unlock(&eint_lock);
126
127 switch (offs) {
128 case 0 ... 7:
129 s3c_gpio_cfgpin(EINT_GPIO_0(offs & 0x7), EINT_MODE);
130 break;
131 case 8 ... 15:
132 s3c_gpio_cfgpin(EINT_GPIO_1(offs & 0x7), EINT_MODE);
133 break;
134 case 16 ... 23:
135 s3c_gpio_cfgpin(EINT_GPIO_2(offs & 0x7), EINT_MODE);
136 break;
137 case 24 ... 31:
138 s3c_gpio_cfgpin(EINT_GPIO_3(offs & 0x7), EINT_MODE);
139 break;
140 default:
141 printk(KERN_ERR "No such irq number %d", offs);
142 }
143
144 return 0;
145}
146
147static struct irq_chip s5pv310_irq_eint = {
148 .name = "s5pv310-eint",
149 .mask = s5pv310_irq_eint_mask,
150 .unmask = s5pv310_irq_eint_unmask,
151 .mask_ack = s5pv310_irq_eint_maskack,
152 .ack = s5pv310_irq_eint_ack,
153 .set_type = s5pv310_irq_eint_set_type,
154#ifdef CONFIG_PM
155 .set_wake = s3c_irqext_wake,
156#endif
157};
158
159/* s5pv310_irq_demux_eint
160 *
161 * This function demuxes the IRQ from from EINTs 16 to 31.
162 * It is designed to be inlined into the specific handler
163 * s5p_irq_demux_eintX_Y.
164 *
165 * Each EINT pend/mask registers handle eight of them.
166 */
167static inline void s5pv310_irq_demux_eint(unsigned int start)
168{
169 unsigned int irq;
170
171 u32 status = __raw_readl(S5P_EINT_PEND(EINT_REG_NR(start)));
172 u32 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(start)));
173
174 status &= ~mask;
175 status &= 0xff;
176
177 while (status) {
178 irq = fls(status) - 1;
179 generic_handle_irq(irq + start);
180 status &= ~(1 << irq);
181 }
182}
183
184static void s5pv310_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc)
185{
186 s5pv310_irq_demux_eint(IRQ_EINT(16));
187 s5pv310_irq_demux_eint(IRQ_EINT(24));
188}
189
190static void s5pv310_irq_eint0_15(unsigned int irq, struct irq_desc *desc)
191{
192 u32 *irq_data = get_irq_data(irq);
193 struct irq_chip *chip = get_irq_chip(irq);
194
195 chip->mask(irq);
196
197 if (chip->ack)
198 chip->ack(irq);
199
200 generic_handle_irq(*irq_data);
201
202 chip->unmask(irq);
203}
204
205int __init s5pv310_init_irq_eint(void)
206{
207 int irq;
208
209 for (irq = 0 ; irq <= 31 ; irq++) {
210 set_irq_chip(IRQ_EINT(irq), &s5pv310_irq_eint);
211 set_irq_handler(IRQ_EINT(irq), handle_level_irq);
212 set_irq_flags(IRQ_EINT(irq), IRQF_VALID);
213 }
214
215 set_irq_chained_handler(IRQ_EINT16_31, s5pv310_irq_demux_eint16_31);
216
217 for (irq = 0 ; irq <= 15 ; irq++) {
218 eint0_15_data[irq] = IRQ_EINT(irq);
219
220 set_irq_data(s5pv310_get_irq_nr(irq), &eint0_15_data[irq]);
221 set_irq_chained_handler(s5pv310_get_irq_nr(irq),
222 s5pv310_irq_eint0_15);
223 }
224
225 return 0;
226}
227
228arch_initcall(s5pv310_init_irq_eint);
diff --git a/arch/arm/mach-s5pv310/mach-smdkc210.c b/arch/arm/mach-s5pv310/mach-smdkc210.c
new file mode 100644
index 000000000000..2b8d4fc52d7c
--- /dev/null
+++ b/arch/arm/mach-s5pv310/mach-smdkc210.c
@@ -0,0 +1,202 @@
1/* linux/arch/arm/mach-s5pv310/mach-smdkc210.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/serial_core.h>
12#include <linux/gpio.h>
13#include <linux/mmc/host.h>
14#include <linux/platform_device.h>
15#include <linux/smsc911x.h>
16#include <linux/io.h>
17
18#include <asm/mach/arch.h>
19#include <asm/mach-types.h>
20
21#include <plat/regs-serial.h>
22#include <plat/s5pv310.h>
23#include <plat/cpu.h>
24#include <plat/devs.h>
25#include <plat/sdhci.h>
26
27#include <mach/map.h>
28#include <mach/regs-srom.h>
29
30/* Following are default values for UCON, ULCON and UFCON UART registers */
31#define SMDKC210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
32 S3C2410_UCON_RXILEVEL | \
33 S3C2410_UCON_TXIRQMODE | \
34 S3C2410_UCON_RXIRQMODE | \
35 S3C2410_UCON_RXFIFO_TOI | \
36 S3C2443_UCON_RXERR_IRQEN)
37
38#define SMDKC210_ULCON_DEFAULT S3C2410_LCON_CS8
39
40#define SMDKC210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
41 S5PV210_UFCON_TXTRIG4 | \
42 S5PV210_UFCON_RXTRIG4)
43
44static struct s3c2410_uartcfg smdkc210_uartcfgs[] __initdata = {
45 [0] = {
46 .hwport = 0,
47 .flags = 0,
48 .ucon = SMDKC210_UCON_DEFAULT,
49 .ulcon = SMDKC210_ULCON_DEFAULT,
50 .ufcon = SMDKC210_UFCON_DEFAULT,
51 },
52 [1] = {
53 .hwport = 1,
54 .flags = 0,
55 .ucon = SMDKC210_UCON_DEFAULT,
56 .ulcon = SMDKC210_ULCON_DEFAULT,
57 .ufcon = SMDKC210_UFCON_DEFAULT,
58 },
59 [2] = {
60 .hwport = 2,
61 .flags = 0,
62 .ucon = SMDKC210_UCON_DEFAULT,
63 .ulcon = SMDKC210_ULCON_DEFAULT,
64 .ufcon = SMDKC210_UFCON_DEFAULT,
65 },
66 [3] = {
67 .hwport = 3,
68 .flags = 0,
69 .ucon = SMDKC210_UCON_DEFAULT,
70 .ulcon = SMDKC210_ULCON_DEFAULT,
71 .ufcon = SMDKC210_UFCON_DEFAULT,
72 },
73};
74
75static struct s3c_sdhci_platdata smdkc210_hsmmc0_pdata __initdata = {
76 .cd_type = S3C_SDHCI_CD_GPIO,
77 .ext_cd_gpio = S5PV310_GPK0(2),
78 .ext_cd_gpio_invert = 1,
79 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
80#ifdef CONFIG_S5PV310_SDHCI_CH0_8BIT
81 .max_width = 8,
82 .host_caps = MMC_CAP_8_BIT_DATA,
83#endif
84};
85
86static struct s3c_sdhci_platdata smdkc210_hsmmc1_pdata __initdata = {
87 .cd_type = S3C_SDHCI_CD_GPIO,
88 .ext_cd_gpio = S5PV310_GPK0(2),
89 .ext_cd_gpio_invert = 1,
90 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
91};
92
93static struct s3c_sdhci_platdata smdkc210_hsmmc2_pdata __initdata = {
94 .cd_type = S3C_SDHCI_CD_GPIO,
95 .ext_cd_gpio = S5PV310_GPK2(2),
96 .ext_cd_gpio_invert = 1,
97 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
98#ifdef CONFIG_S5PV310_SDHCI_CH2_8BIT
99 .max_width = 8,
100 .host_caps = MMC_CAP_8_BIT_DATA,
101#endif
102};
103
104static struct s3c_sdhci_platdata smdkc210_hsmmc3_pdata __initdata = {
105 .cd_type = S3C_SDHCI_CD_GPIO,
106 .ext_cd_gpio = S5PV310_GPK2(2),
107 .ext_cd_gpio_invert = 1,
108 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
109};
110
111static struct resource smdkc210_smsc911x_resources[] = {
112 [0] = {
113 .start = S5PV310_PA_SROM_BANK(1),
114 .end = S5PV310_PA_SROM_BANK(1) + SZ_64K - 1,
115 .flags = IORESOURCE_MEM,
116 },
117 [1] = {
118 .start = IRQ_EINT(5),
119 .end = IRQ_EINT(5),
120 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
121 },
122};
123
124static struct smsc911x_platform_config smsc9215_config = {
125 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
126 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
127 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
128 .phy_interface = PHY_INTERFACE_MODE_MII,
129 .mac = {0x00, 0x80, 0x00, 0x23, 0x45, 0x67},
130};
131
132static struct platform_device smdkc210_smsc911x = {
133 .name = "smsc911x",
134 .id = -1,
135 .num_resources = ARRAY_SIZE(smdkc210_smsc911x_resources),
136 .resource = smdkc210_smsc911x_resources,
137 .dev = {
138 .platform_data = &smsc9215_config,
139 },
140};
141
142static struct platform_device *smdkc210_devices[] __initdata = {
143 &s3c_device_hsmmc0,
144 &s3c_device_hsmmc1,
145 &s3c_device_hsmmc2,
146 &s3c_device_hsmmc3,
147 &s3c_device_rtc,
148 &s3c_device_wdt,
149 &smdkc210_smsc911x,
150};
151
152static void __init smdkc210_smsc911x_init(void)
153{
154 u32 cs1;
155
156 /* configure nCS1 width to 16 bits */
157 cs1 = __raw_readl(S5PV310_SROM_BW) &
158 ~(S5PV310_SROM_BW__CS_MASK <<
159 S5PV310_SROM_BW__NCS1__SHIFT);
160 cs1 |= ((1 << S5PV310_SROM_BW__DATAWIDTH__SHIFT) |
161 (1 << S5PV310_SROM_BW__WAITENABLE__SHIFT) |
162 (1 << S5PV310_SROM_BW__BYTEENABLE__SHIFT)) <<
163 S5PV310_SROM_BW__NCS1__SHIFT;
164 __raw_writel(cs1, S5PV310_SROM_BW);
165
166 /* set timing for nCS1 suitable for ethernet chip */
167 __raw_writel((0x1 << S5PV310_SROM_BCX__PMC__SHIFT) |
168 (0x9 << S5PV310_SROM_BCX__TACP__SHIFT) |
169 (0xc << S5PV310_SROM_BCX__TCAH__SHIFT) |
170 (0x1 << S5PV310_SROM_BCX__TCOH__SHIFT) |
171 (0x6 << S5PV310_SROM_BCX__TACC__SHIFT) |
172 (0x1 << S5PV310_SROM_BCX__TCOS__SHIFT) |
173 (0x1 << S5PV310_SROM_BCX__TACS__SHIFT), S5PV310_SROM_BC1);
174}
175
176static void __init smdkc210_map_io(void)
177{
178 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
179 s3c24xx_init_clocks(24000000);
180 s3c24xx_init_uarts(smdkc210_uartcfgs, ARRAY_SIZE(smdkc210_uartcfgs));
181}
182
183static void __init smdkc210_machine_init(void)
184{
185 smdkc210_smsc911x_init();
186
187 s3c_sdhci0_set_platdata(&smdkc210_hsmmc0_pdata);
188 s3c_sdhci1_set_platdata(&smdkc210_hsmmc1_pdata);
189 s3c_sdhci2_set_platdata(&smdkc210_hsmmc2_pdata);
190 s3c_sdhci3_set_platdata(&smdkc210_hsmmc3_pdata);
191
192 platform_add_devices(smdkc210_devices, ARRAY_SIZE(smdkc210_devices));
193}
194
195MACHINE_START(SMDKC210, "SMDKC210")
196 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
197 .boot_params = S5P_PA_SDRAM + 0x100,
198 .init_irq = s5pv310_init_irq,
199 .map_io = smdkc210_map_io,
200 .init_machine = smdkc210_machine_init,
201 .timer = &s5pv310_timer,
202MACHINE_END
diff --git a/arch/arm/mach-s5pv310/mach-smdkv310.c b/arch/arm/mach-s5pv310/mach-smdkv310.c
index 46215a14b3bb..35826d66632c 100644
--- a/arch/arm/mach-s5pv310/mach-smdkv310.c
+++ b/arch/arm/mach-s5pv310/mach-smdkv310.c
@@ -9,16 +9,23 @@
9*/ 9*/
10 10
11#include <linux/serial_core.h> 11#include <linux/serial_core.h>
12#include <linux/gpio.h>
13#include <linux/mmc/host.h>
14#include <linux/platform_device.h>
15#include <linux/smsc911x.h>
16#include <linux/io.h>
12 17
13#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
14#include <asm/mach-types.h> 19#include <asm/mach-types.h>
15#include <asm/hardware/cache-l2x0.h>
16 20
17#include <plat/regs-serial.h> 21#include <plat/regs-serial.h>
18#include <plat/s5pv310.h> 22#include <plat/s5pv310.h>
19#include <plat/cpu.h> 23#include <plat/cpu.h>
24#include <plat/devs.h>
25#include <plat/sdhci.h>
20 26
21#include <mach/map.h> 27#include <mach/map.h>
28#include <mach/regs-srom.h>
22 29
23/* Following are default values for UCON, ULCON and UFCON UART registers */ 30/* Following are default values for UCON, ULCON and UFCON UART registers */
24#define SMDKV310_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \ 31#define SMDKV310_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
@@ -65,6 +72,107 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
65 }, 72 },
66}; 73};
67 74
75static struct s3c_sdhci_platdata smdkv310_hsmmc0_pdata __initdata = {
76 .cd_type = S3C_SDHCI_CD_GPIO,
77 .ext_cd_gpio = S5PV310_GPK0(2),
78 .ext_cd_gpio_invert = 1,
79 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
80#ifdef CONFIG_S5PV310_SDHCI_CH0_8BIT
81 .max_width = 8,
82 .host_caps = MMC_CAP_8_BIT_DATA,
83#endif
84};
85
86static struct s3c_sdhci_platdata smdkv310_hsmmc1_pdata __initdata = {
87 .cd_type = S3C_SDHCI_CD_GPIO,
88 .ext_cd_gpio = S5PV310_GPK0(2),
89 .ext_cd_gpio_invert = 1,
90 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
91};
92
93static struct s3c_sdhci_platdata smdkv310_hsmmc2_pdata __initdata = {
94 .cd_type = S3C_SDHCI_CD_GPIO,
95 .ext_cd_gpio = S5PV310_GPK2(2),
96 .ext_cd_gpio_invert = 1,
97 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
98#ifdef CONFIG_S5PV310_SDHCI_CH2_8BIT
99 .max_width = 8,
100 .host_caps = MMC_CAP_8_BIT_DATA,
101#endif
102};
103
104static struct s3c_sdhci_platdata smdkv310_hsmmc3_pdata __initdata = {
105 .cd_type = S3C_SDHCI_CD_GPIO,
106 .ext_cd_gpio = S5PV310_GPK2(2),
107 .ext_cd_gpio_invert = 1,
108 .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
109};
110
111static struct resource smdkv310_smsc911x_resources[] = {
112 [0] = {
113 .start = S5PV310_PA_SROM_BANK(1),
114 .end = S5PV310_PA_SROM_BANK(1) + SZ_64K - 1,
115 .flags = IORESOURCE_MEM,
116 },
117 [1] = {
118 .start = IRQ_EINT(5),
119 .end = IRQ_EINT(5),
120 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
121 },
122};
123
124static struct smsc911x_platform_config smsc9215_config = {
125 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
126 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
127 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
128 .phy_interface = PHY_INTERFACE_MODE_MII,
129 .mac = {0x00, 0x80, 0x00, 0x23, 0x45, 0x67},
130};
131
132static struct platform_device smdkv310_smsc911x = {
133 .name = "smsc911x",
134 .id = -1,
135 .num_resources = ARRAY_SIZE(smdkv310_smsc911x_resources),
136 .resource = smdkv310_smsc911x_resources,
137 .dev = {
138 .platform_data = &smsc9215_config,
139 },
140};
141
142static struct platform_device *smdkv310_devices[] __initdata = {
143 &s3c_device_hsmmc0,
144 &s3c_device_hsmmc1,
145 &s3c_device_hsmmc2,
146 &s3c_device_hsmmc3,
147 &s3c_device_rtc,
148 &s3c_device_wdt,
149 &smdkv310_smsc911x,
150};
151
152static void __init smdkv310_smsc911x_init(void)
153{
154 u32 cs1;
155
156 /* configure nCS1 width to 16 bits */
157 cs1 = __raw_readl(S5PV310_SROM_BW) &
158 ~(S5PV310_SROM_BW__CS_MASK <<
159 S5PV310_SROM_BW__NCS1__SHIFT);
160 cs1 |= ((1 << S5PV310_SROM_BW__DATAWIDTH__SHIFT) |
161 (1 << S5PV310_SROM_BW__WAITENABLE__SHIFT) |
162 (1 << S5PV310_SROM_BW__BYTEENABLE__SHIFT)) <<
163 S5PV310_SROM_BW__NCS1__SHIFT;
164 __raw_writel(cs1, S5PV310_SROM_BW);
165
166 /* set timing for nCS1 suitable for ethernet chip */
167 __raw_writel((0x1 << S5PV310_SROM_BCX__PMC__SHIFT) |
168 (0x9 << S5PV310_SROM_BCX__TACP__SHIFT) |
169 (0xc << S5PV310_SROM_BCX__TCAH__SHIFT) |
170 (0x1 << S5PV310_SROM_BCX__TCOH__SHIFT) |
171 (0x6 << S5PV310_SROM_BCX__TACC__SHIFT) |
172 (0x1 << S5PV310_SROM_BCX__TCOS__SHIFT) |
173 (0x1 << S5PV310_SROM_BCX__TACS__SHIFT), S5PV310_SROM_BC1);
174}
175
68static void __init smdkv310_map_io(void) 176static void __init smdkv310_map_io(void)
69{ 177{
70 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 178 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -74,9 +182,14 @@ static void __init smdkv310_map_io(void)
74 182
75static void __init smdkv310_machine_init(void) 183static void __init smdkv310_machine_init(void)
76{ 184{
77#ifdef CONFIG_CACHE_L2X0 185 smdkv310_smsc911x_init();
78 l2x0_init(S5P_VA_L2CC, 1 << 28, 0xffffffff); 186
79#endif 187 s3c_sdhci0_set_platdata(&smdkv310_hsmmc0_pdata);
188 s3c_sdhci1_set_platdata(&smdkv310_hsmmc1_pdata);
189 s3c_sdhci2_set_platdata(&smdkv310_hsmmc2_pdata);
190 s3c_sdhci3_set_platdata(&smdkv310_hsmmc3_pdata);
191
192 platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices));
80} 193}
81 194
82MACHINE_START(SMDKV310, "SMDKV310") 195MACHINE_START(SMDKV310, "SMDKV310")
diff --git a/arch/arm/mach-s5pv310/mach-universal_c210.c b/arch/arm/mach-s5pv310/mach-universal_c210.c
index d7c2ec770f88..16d8fc00cafd 100644
--- a/arch/arm/mach-s5pv310/mach-universal_c210.c
+++ b/arch/arm/mach-s5pv310/mach-universal_c210.c
@@ -7,15 +7,20 @@
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8*/ 8*/
9 9
10#include <linux/platform_device.h>
10#include <linux/serial_core.h> 11#include <linux/serial_core.h>
12#include <linux/input.h>
13#include <linux/i2c.h>
14#include <linux/gpio_keys.h>
15#include <linux/gpio.h>
11 16
12#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
13#include <asm/mach-types.h> 18#include <asm/mach-types.h>
14#include <asm/hardware/cache-l2x0.h>
15 19
16#include <plat/regs-serial.h> 20#include <plat/regs-serial.h>
17#include <plat/s5pv310.h> 21#include <plat/s5pv310.h>
18#include <plat/cpu.h> 22#include <plat/cpu.h>
23#include <plat/devs.h>
19 24
20#include <mach/map.h> 25#include <mach/map.h>
21 26
@@ -60,6 +65,72 @@ static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
60 }, 65 },
61}; 66};
62 67
68static struct gpio_keys_button universal_gpio_keys_tables[] = {
69 {
70 .code = KEY_VOLUMEUP,
71 .gpio = S5PV310_GPX2(0), /* XEINT16 */
72 .desc = "gpio-keys: KEY_VOLUMEUP",
73 .type = EV_KEY,
74 .active_low = 1,
75 .debounce_interval = 1,
76 }, {
77 .code = KEY_VOLUMEDOWN,
78 .gpio = S5PV310_GPX2(1), /* XEINT17 */
79 .desc = "gpio-keys: KEY_VOLUMEDOWN",
80 .type = EV_KEY,
81 .active_low = 1,
82 .debounce_interval = 1,
83 }, {
84 .code = KEY_CONFIG,
85 .gpio = S5PV310_GPX2(2), /* XEINT18 */
86 .desc = "gpio-keys: KEY_CONFIG",
87 .type = EV_KEY,
88 .active_low = 1,
89 .debounce_interval = 1,
90 }, {
91 .code = KEY_CAMERA,
92 .gpio = S5PV310_GPX2(3), /* XEINT19 */
93 .desc = "gpio-keys: KEY_CAMERA",
94 .type = EV_KEY,
95 .active_low = 1,
96 .debounce_interval = 1,
97 }, {
98 .code = KEY_OK,
99 .gpio = S5PV310_GPX3(5), /* XEINT29 */
100 .desc = "gpio-keys: KEY_OK",
101 .type = EV_KEY,
102 .active_low = 1,
103 .debounce_interval = 1,
104 },
105};
106
107static struct gpio_keys_platform_data universal_gpio_keys_data = {
108 .buttons = universal_gpio_keys_tables,
109 .nbuttons = ARRAY_SIZE(universal_gpio_keys_tables),
110};
111
112static struct platform_device universal_gpio_keys = {
113 .name = "gpio-keys",
114 .dev = {
115 .platform_data = &universal_gpio_keys_data,
116 },
117};
118
119/* I2C0 */
120static struct i2c_board_info i2c0_devs[] __initdata = {
121 /* Camera, To be updated */
122};
123
124/* I2C1 */
125static struct i2c_board_info i2c1_devs[] __initdata = {
126 /* Gyro, To be updated */
127};
128
129static struct platform_device *universal_devices[] __initdata = {
130 &universal_gpio_keys,
131 &s5p_device_onenand,
132};
133
63static void __init universal_map_io(void) 134static void __init universal_map_io(void)
64{ 135{
65 s5p_init_io(NULL, 0, S5P_VA_CHIPID); 136 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
@@ -69,9 +140,11 @@ static void __init universal_map_io(void)
69 140
70static void __init universal_machine_init(void) 141static void __init universal_machine_init(void)
71{ 142{
72#ifdef CONFIG_CACHE_L2X0 143 i2c_register_board_info(0, i2c0_devs, ARRAY_SIZE(i2c0_devs));
73 l2x0_init(S5P_VA_L2CC, 1 << 28, 0xffffffff); 144 i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
74#endif 145
146 /* Last */
147 platform_add_devices(universal_devices, ARRAY_SIZE(universal_devices));
75} 148}
76 149
77MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210") 150MACHINE_START(UNIVERSAL_C210, "UNIVERSAL_C210")
diff --git a/arch/arm/mach-s5pv310/setup-i2c0.c b/arch/arm/mach-s5pv310/setup-i2c0.c
index 436712807383..f47f8f3152ec 100644
--- a/arch/arm/mach-s5pv310/setup-i2c0.c
+++ b/arch/arm/mach-s5pv310/setup-i2c0.c
@@ -21,8 +21,6 @@ struct platform_device; /* don't need the contents */
21 21
22void s3c_i2c0_cfg_gpio(struct platform_device *dev) 22void s3c_i2c0_cfg_gpio(struct platform_device *dev)
23{ 23{
24 s3c_gpio_cfgpin(S5PV310_GPD1(0), S3C_GPIO_SFN(2)); 24 s3c_gpio_cfgall_range(S5PV310_GPD1(0), 2,
25 s3c_gpio_setpull(S5PV310_GPD1(0), S3C_GPIO_PULL_UP); 25 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
26 s3c_gpio_cfgpin(S5PV310_GPD1(1), S3C_GPIO_SFN(2));
27 s3c_gpio_setpull(S5PV310_GPD1(1), S3C_GPIO_PULL_UP);
28} 26}
diff --git a/arch/arm/mach-s5pv310/setup-i2c1.c b/arch/arm/mach-s5pv310/setup-i2c1.c
index 1ecd5bc35b5a..9d07e4e2f14c 100644
--- a/arch/arm/mach-s5pv310/setup-i2c1.c
+++ b/arch/arm/mach-s5pv310/setup-i2c1.c
@@ -18,8 +18,6 @@ struct platform_device; /* don't need the contents */
18 18
19void s3c_i2c1_cfg_gpio(struct platform_device *dev) 19void s3c_i2c1_cfg_gpio(struct platform_device *dev)
20{ 20{
21 s3c_gpio_cfgpin(S5PV310_GPD1(2), S3C_GPIO_SFN(2)); 21 s3c_gpio_cfgall_range(S5PV310_GPD1(2), 2,
22 s3c_gpio_setpull(S5PV310_GPD1(2), S3C_GPIO_PULL_UP); 22 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
23 s3c_gpio_cfgpin(S5PV310_GPD1(3), S3C_GPIO_SFN(2));
24 s3c_gpio_setpull(S5PV310_GPD1(3), S3C_GPIO_PULL_UP);
25} 23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c2.c b/arch/arm/mach-s5pv310/setup-i2c2.c
index 4c0d8def660a..4163b1233daf 100644
--- a/arch/arm/mach-s5pv310/setup-i2c2.c
+++ b/arch/arm/mach-s5pv310/setup-i2c2.c
@@ -18,8 +18,6 @@ struct platform_device; /* don't need the contents */
18 18
19void s3c_i2c2_cfg_gpio(struct platform_device *dev) 19void s3c_i2c2_cfg_gpio(struct platform_device *dev)
20{ 20{
21 s3c_gpio_cfgpin(S5PV310_GPA0(6), S3C_GPIO_SFN(3)); 21 s3c_gpio_cfgall_range(S5PV310_GPA0(6), 2,
22 s3c_gpio_setpull(S5PV310_GPA0(6), S3C_GPIO_PULL_UP); 22 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
23 s3c_gpio_cfgpin(S5PV310_GPA0(7), S3C_GPIO_SFN(3));
24 s3c_gpio_setpull(S5PV310_GPA0(7), S3C_GPIO_PULL_UP);
25} 23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c3.c b/arch/arm/mach-s5pv310/setup-i2c3.c
new file mode 100644
index 000000000000..180f153d2a20
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-i2c3.c
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-s5pv310/setup-i2c3.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 *
6 * I2C3 GPIO 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
13struct platform_device; /* don't need the contents */
14
15#include <linux/gpio.h>
16#include <plat/iic.h>
17#include <plat/gpio-cfg.h>
18
19void s3c_i2c3_cfg_gpio(struct platform_device *dev)
20{
21 s3c_gpio_cfgall_range(S5PV310_GPA1(2), 2,
22 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c4.c b/arch/arm/mach-s5pv310/setup-i2c4.c
new file mode 100644
index 000000000000..909e8dfc5316
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-i2c4.c
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-s5pv310/setup-i2c4.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 *
6 * I2C4 GPIO 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
13struct platform_device; /* don't need the contents */
14
15#include <linux/gpio.h>
16#include <plat/iic.h>
17#include <plat/gpio-cfg.h>
18
19void s3c_i2c4_cfg_gpio(struct platform_device *dev)
20{
21 s3c_gpio_cfgall_range(S5PV310_GPB(2), 2,
22 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c5.c b/arch/arm/mach-s5pv310/setup-i2c5.c
new file mode 100644
index 000000000000..5d0fa4ac0283
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-i2c5.c
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-s5pv310/setup-i2c5.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 *
6 * I2C5 GPIO 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
13struct platform_device; /* don't need the contents */
14
15#include <linux/gpio.h>
16#include <plat/iic.h>
17#include <plat/gpio-cfg.h>
18
19void s3c_i2c5_cfg_gpio(struct platform_device *dev)
20{
21 s3c_gpio_cfgall_range(S5PV310_GPB(6), 2,
22 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c6.c b/arch/arm/mach-s5pv310/setup-i2c6.c
new file mode 100644
index 000000000000..34aafab92ac4
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-i2c6.c
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-s5pv310/setup-i2c6.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 *
6 * I2C6 GPIO 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
13struct platform_device; /* don't need the contents */
14
15#include <linux/gpio.h>
16#include <plat/iic.h>
17#include <plat/gpio-cfg.h>
18
19void s3c_i2c6_cfg_gpio(struct platform_device *dev)
20{
21 s3c_gpio_cfgall_range(S5PV310_GPC1(3), 2,
22 S3C_GPIO_SFN(4), S3C_GPIO_PULL_UP);
23}
diff --git a/arch/arm/mach-s5pv310/setup-i2c7.c b/arch/arm/mach-s5pv310/setup-i2c7.c
new file mode 100644
index 000000000000..9b25b8d18920
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-i2c7.c
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-s5pv310/setup-i2c7.c
3 *
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 *
6 * I2C7 GPIO 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
13struct platform_device; /* don't need the contents */
14
15#include <linux/gpio.h>
16#include <plat/iic.h>
17#include <plat/gpio-cfg.h>
18
19void s3c_i2c7_cfg_gpio(struct platform_device *dev)
20{
21 s3c_gpio_cfgall_range(S5PV310_GPD0(2), 2,
22 S3C_GPIO_SFN(3), S3C_GPIO_PULL_UP);
23}
diff --git a/arch/arm/mach-s5pv310/setup-sdhci-gpio.c b/arch/arm/mach-s5pv310/setup-sdhci-gpio.c
new file mode 100644
index 000000000000..86d38cc49135
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-sdhci-gpio.c
@@ -0,0 +1,152 @@
1/* linux/arch/arm/mach-s5pv310/setup-sdhci-gpio.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV310 - Helper functions for setting up SDHCI device(s) GPIO (HSMMC)
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/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18#include <linux/gpio.h>
19#include <linux/mmc/host.h>
20#include <linux/mmc/card.h>
21
22#include <plat/gpio-cfg.h>
23#include <plat/regs-sdhci.h>
24#include <plat/sdhci.h>
25
26void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
27{
28 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
29 unsigned int gpio;
30
31 /* Set all the necessary GPK0[0:1] pins to special-function 2 */
32 for (gpio = S5PV310_GPK0(0); gpio < S5PV310_GPK0(2); gpio++) {
33 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
34 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
35 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
36 }
37
38 switch (width) {
39 case 8:
40 for (gpio = S5PV310_GPK1(3); gpio <= S5PV310_GPK1(6); gpio++) {
41 /* Data pin GPK1[3:6] to special-funtion 3 */
42 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
43 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
44 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
45 }
46 case 4:
47 for (gpio = S5PV310_GPK0(3); gpio <= S5PV310_GPK0(6); gpio++) {
48 /* Data pin GPK0[3:6] to special-funtion 2 */
49 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
50 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
51 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
52 }
53 default:
54 break;
55 }
56
57 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
58 s3c_gpio_cfgpin(S5PV310_GPK0(2), S3C_GPIO_SFN(2));
59 s3c_gpio_setpull(S5PV310_GPK0(2), S3C_GPIO_PULL_UP);
60 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
61 }
62}
63
64void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *dev, int width)
65{
66 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
67 unsigned int gpio;
68
69 /* Set all the necessary GPK1[0:1] pins to special-function 2 */
70 for (gpio = S5PV310_GPK1(0); gpio < S5PV310_GPK1(2); gpio++) {
71 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
72 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
73 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
74 }
75
76 for (gpio = S5PV310_GPK1(3); gpio <= S5PV310_GPK1(6); gpio++) {
77 /* Data pin GPK1[3:6] to special-function 2 */
78 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
79 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
80 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
81 }
82
83 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
84 s3c_gpio_cfgpin(S5PV310_GPK1(2), S3C_GPIO_SFN(2));
85 s3c_gpio_setpull(S5PV310_GPK1(2), S3C_GPIO_PULL_UP);
86 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
87 }
88}
89
90void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *dev, int width)
91{
92 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
93 unsigned int gpio;
94
95 /* Set all the necessary GPK2[0:1] pins to special-function 2 */
96 for (gpio = S5PV310_GPK2(0); gpio < S5PV310_GPK2(2); gpio++) {
97 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
98 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
99 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
100 }
101
102 switch (width) {
103 case 8:
104 for (gpio = S5PV310_GPK3(3); gpio <= S5PV310_GPK3(6); gpio++) {
105 /* Data pin GPK3[3:6] to special-function 3 */
106 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
107 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
108 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
109 }
110 case 4:
111 for (gpio = S5PV310_GPK2(3); gpio <= S5PV310_GPK2(6); gpio++) {
112 /* Data pin GPK2[3:6] to special-function 2 */
113 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
114 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
115 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
116 }
117 default:
118 break;
119 }
120
121 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
122 s3c_gpio_cfgpin(S5PV310_GPK2(2), S3C_GPIO_SFN(2));
123 s3c_gpio_setpull(S5PV310_GPK2(2), S3C_GPIO_PULL_UP);
124 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
125 }
126}
127
128void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *dev, int width)
129{
130 struct s3c_sdhci_platdata *pdata = dev->dev.platform_data;
131 unsigned int gpio;
132
133 /* Set all the necessary GPK3[0:1] pins to special-function 2 */
134 for (gpio = S5PV310_GPK3(0); gpio < S5PV310_GPK3(2); gpio++) {
135 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
136 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
137 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
138 }
139
140 for (gpio = S5PV310_GPK3(3); gpio <= S5PV310_GPK3(6); gpio++) {
141 /* Data pin GPK3[3:6] to special-function 2 */
142 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
143 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
144 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
145 }
146
147 if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) {
148 s3c_gpio_cfgpin(S5PV310_GPK3(2), S3C_GPIO_SFN(2));
149 s3c_gpio_setpull(S5PV310_GPK3(2), S3C_GPIO_PULL_UP);
150 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
151 }
152}
diff --git a/arch/arm/mach-s5pv310/setup-sdhci.c b/arch/arm/mach-s5pv310/setup-sdhci.c
new file mode 100644
index 000000000000..db8358fc4662
--- /dev/null
+++ b/arch/arm/mach-s5pv310/setup-sdhci.c
@@ -0,0 +1,69 @@
1/* linux/arch/arm/mach-s5pv310/setup-sdhci.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV310 - Helper functions for settign up SDHCI device(s) (HSMMC)
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/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18
19#include <linux/mmc/card.h>
20#include <linux/mmc/host.h>
21
22#include <plat/regs-sdhci.h>
23
24/* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
25
26char *s5pv310_hsmmc_clksrcs[4] = {
27 [0] = NULL,
28 [1] = NULL,
29 [2] = "sclk_mmc", /* mmc_bus */
30 [3] = NULL,
31};
32
33void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev, void __iomem *r,
34 struct mmc_ios *ios, struct mmc_card *card)
35{
36 u32 ctrl2, ctrl3;
37
38 /* don't need to alter anything acording to card-type */
39
40 ctrl2 = readl(r + S3C_SDHCI_CONTROL2);
41
42 /* select base clock source to HCLK */
43
44 ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
45
46 /*
47 * clear async mode, enable conflict mask, rx feedback ctrl, SD
48 * clk hold and no use debounce count
49 */
50
51 ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
52 S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
53 S3C_SDHCI_CTRL2_ENFBCLKRX |
54 S3C_SDHCI_CTRL2_DFCNT_NONE |
55 S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
56
57 /* Tx and Rx feedback clock delay control */
58
59 if (ios->clock < 25 * 1000000)
60 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
61 S3C_SDHCI_CTRL3_FCSEL2 |
62 S3C_SDHCI_CTRL3_FCSEL1 |
63 S3C_SDHCI_CTRL3_FCSEL0);
64 else
65 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
66
67 writel(ctrl2, r + S3C_SDHCI_CONTROL2);
68 writel(ctrl3, r + S3C_SDHCI_CONTROL3);
69}
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/cpu-sa1100.c b/arch/arm/mach-sa1100/cpu-sa1100.c
index ef817876a5d6..96f7dc103b59 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:
@@ -184,16 +184,15 @@ static int sa1100_target(struct cpufreq_policy *policy,
184{ 184{
185 unsigned int cur = sa11x0_getspeed(0); 185 unsigned int cur = sa11x0_getspeed(0);
186 unsigned int new_ppcr; 186 unsigned int new_ppcr;
187
188 struct cpufreq_freqs freqs; 187 struct cpufreq_freqs freqs;
188
189 new_ppcr = sa11x0_freq_to_ppcr(target_freq);
189 switch(relation){ 190 switch(relation){
190 case CPUFREQ_RELATION_L: 191 case CPUFREQ_RELATION_L:
191 new_ppcr = sa11x0_freq_to_ppcr(target_freq);
192 if (sa11x0_ppcr_to_freq(new_ppcr) > policy->max) 192 if (sa11x0_ppcr_to_freq(new_ppcr) > policy->max)
193 new_ppcr--; 193 new_ppcr--;
194 break; 194 break;
195 case CPUFREQ_RELATION_H: 195 case CPUFREQ_RELATION_H:
196 new_ppcr = sa11x0_freq_to_ppcr(target_freq);
197 if ((sa11x0_ppcr_to_freq(new_ppcr) > target_freq) && 196 if ((sa11x0_ppcr_to_freq(new_ppcr) > target_freq) &&
198 (sa11x0_ppcr_to_freq(new_ppcr - 1) >= policy->min)) 197 (sa11x0_ppcr_to_freq(new_ppcr - 1) >= policy->min))
199 new_ppcr--; 198 new_ppcr--;
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 54b479c35ee0..51dcd59eda6a 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -116,4 +116,6 @@ endmenu
116config SH_CLK_CPG 116config SH_CLK_CPG
117 bool 117 bool
118 118
119source "drivers/sh/Kconfig"
120
119endif 121endif
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 14923989ea05..d3260542b943 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -30,7 +30,6 @@
30#include <linux/mtd/mtd.h> 30#include <linux/mtd/mtd.h>
31#include <linux/mtd/partitions.h> 31#include <linux/mtd/partitions.h>
32#include <linux/mtd/physmap.h> 32#include <linux/mtd/physmap.h>
33#include <linux/mmc/host.h>
34#include <linux/mmc/sh_mmcif.h> 33#include <linux/mmc/sh_mmcif.h>
35#include <linux/i2c.h> 34#include <linux/i2c.h>
36#include <linux/i2c/tsc2007.h> 35#include <linux/i2c/tsc2007.h>
@@ -44,6 +43,10 @@
44#include <linux/input/sh_keysc.h> 43#include <linux/input/sh_keysc.h>
45#include <linux/usb/r8a66597.h> 44#include <linux/usb/r8a66597.h>
46 45
46#include <media/sh_mobile_ceu.h>
47#include <media/sh_mobile_csi2.h>
48#include <media/soc_camera.h>
49
47#include <sound/sh_fsi.h> 50#include <sound/sh_fsi.h>
48 51
49#include <video/sh_mobile_hdmi.h> 52#include <video/sh_mobile_hdmi.h>
@@ -160,11 +163,13 @@ static struct mtd_partition nor_flash_partitions[] = {
160 .name = "loader", 163 .name = "loader",
161 .offset = 0x00000000, 164 .offset = 0x00000000,
162 .size = 512 * 1024, 165 .size = 512 * 1024,
166 .mask_flags = MTD_WRITEABLE,
163 }, 167 },
164 { 168 {
165 .name = "bootenv", 169 .name = "bootenv",
166 .offset = MTDPART_OFS_APPEND, 170 .offset = MTDPART_OFS_APPEND,
167 .size = 512 * 1024, 171 .size = 512 * 1024,
172 .mask_flags = MTD_WRITEABLE,
168 }, 173 },
169 { 174 {
170 .name = "kernel_ro", 175 .name = "kernel_ro",
@@ -235,10 +240,22 @@ static struct platform_device smc911x_device = {
235 }, 240 },
236}; 241};
237 242
243/*
244 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
245 * connected to GPIO A22 of SH7372 (GPIO_PORT41).
246 */
247static int slot_cn7_get_cd(struct platform_device *pdev)
248{
249 if (gpio_is_valid(GPIO_PORT41))
250 return !gpio_get_value(GPIO_PORT41);
251 else
252 return -ENXIO;
253}
254
238/* SH_MMCIF */ 255/* SH_MMCIF */
239static struct resource sh_mmcif_resources[] = { 256static struct resource sh_mmcif_resources[] = {
240 [0] = { 257 [0] = {
241 .name = "SH_MMCIF", 258 .name = "MMCIF",
242 .start = 0xE6BD0000, 259 .start = 0xE6BD0000,
243 .end = 0xE6BD00FF, 260 .end = 0xE6BD00FF,
244 .flags = IORESOURCE_MEM, 261 .flags = IORESOURCE_MEM,
@@ -261,6 +278,7 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
261 .caps = MMC_CAP_4_BIT_DATA | 278 .caps = MMC_CAP_4_BIT_DATA |
262 MMC_CAP_8_BIT_DATA | 279 MMC_CAP_8_BIT_DATA |
263 MMC_CAP_NEEDS_POLL, 280 MMC_CAP_NEEDS_POLL,
281 .get_cd = slot_cn7_get_cd,
264}; 282};
265 283
266static struct platform_device sh_mmcif_device = { 284static struct platform_device sh_mmcif_device = {
@@ -310,6 +328,8 @@ static struct sh_mobile_sdhi_info sdhi1_info = {
310 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, 328 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
311 .tmio_ocr_mask = MMC_VDD_165_195, 329 .tmio_ocr_mask = MMC_VDD_165_195,
312 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, 330 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
331 .tmio_caps = MMC_CAP_NEEDS_POLL,
332 .get_cd = slot_cn7_get_cd,
313}; 333};
314 334
315static struct resource sdhi1_resources[] = { 335static struct resource sdhi1_resources[] = {
@@ -375,10 +395,40 @@ static struct platform_device usb1_host_device = {
375 .resource = usb1_host_resources, 395 .resource = usb1_host_resources,
376}; 396};
377 397
398const static struct fb_videomode ap4evb_lcdc_modes[] = {
399 {
400#ifdef CONFIG_AP4EVB_QHD
401 .name = "R63302(QHD)",
402 .xres = 544,
403 .yres = 961,
404 .left_margin = 72,
405 .right_margin = 600,
406 .hsync_len = 16,
407 .upper_margin = 8,
408 .lower_margin = 8,
409 .vsync_len = 2,
410 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
411#else
412 .name = "WVGA Panel",
413 .xres = 800,
414 .yres = 480,
415 .left_margin = 220,
416 .right_margin = 110,
417 .hsync_len = 70,
418 .upper_margin = 20,
419 .lower_margin = 5,
420 .vsync_len = 5,
421 .sync = 0,
422#endif
423 },
424};
425
378static struct sh_mobile_lcdc_info lcdc_info = { 426static struct sh_mobile_lcdc_info lcdc_info = {
379 .ch[0] = { 427 .ch[0] = {
380 .chan = LCDC_CHAN_MAINLCD, 428 .chan = LCDC_CHAN_MAINLCD,
381 .bpp = 16, 429 .bpp = 16,
430 .lcd_cfg = ap4evb_lcdc_modes,
431 .num_cfg = ARRAY_SIZE(ap4evb_lcdc_modes),
382 } 432 }
383}; 433};
384 434
@@ -517,26 +567,41 @@ static struct platform_device *qhd_devices[] __initdata = {
517 567
518/* FSI */ 568/* FSI */
519#define IRQ_FSI evt2irq(0x1840) 569#define IRQ_FSI evt2irq(0x1840)
520#define FSIACKCR 0xE6150018 570
521static void fsiackcr_init(struct clk *clk) 571static int fsi_set_rate(int is_porta, int rate)
522{ 572{
523 u32 status = __raw_readl(clk->enable_reg); 573 struct clk *fsib_clk;
574 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
575 int ret;
524 576
525 /* use external clock */ 577 /* set_rate is not needed if port A */
526 status &= ~0x000000ff; 578 if (is_porta)
527 status |= 0x00000080; 579 return 0;
528 __raw_writel(status, clk->enable_reg); 580
529} 581 fsib_clk = clk_get(NULL, "fsib_clk");
582 if (IS_ERR(fsib_clk))
583 return -EINVAL;
584
585 switch (rate) {
586 case 44100:
587 clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 11283000));
588 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
589 break;
590 case 48000:
591 clk_set_rate(fsib_clk, clk_round_rate(fsib_clk, 85428000));
592 clk_set_rate(fdiv_clk, clk_round_rate(fdiv_clk, 12204000));
593 ret = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64;
594 break;
595 default:
596 pr_err("unsupported rate in FSI2 port B\n");
597 ret = -EINVAL;
598 break;
599 }
530 600
531static struct clk_ops fsiackcr_clk_ops = { 601 clk_put(fsib_clk);
532 .init = fsiackcr_init,
533};
534 602
535static struct clk fsiackcr_clk = { 603 return ret;
536 .ops = &fsiackcr_clk_ops, 604}
537 .enable_reg = (void __iomem *)FSIACKCR,
538 .rate = 0, /* unknown */
539};
540 605
541static struct sh_fsi_platform_info fsi_info = { 606static struct sh_fsi_platform_info fsi_info = {
542 .porta_flags = SH_FSI_BRS_INV | 607 .porta_flags = SH_FSI_BRS_INV |
@@ -544,6 +609,12 @@ static struct sh_fsi_platform_info fsi_info = {
544 SH_FSI_IN_SLAVE_MODE | 609 SH_FSI_IN_SLAVE_MODE |
545 SH_FSI_OFMT(PCM) | 610 SH_FSI_OFMT(PCM) |
546 SH_FSI_IFMT(PCM), 611 SH_FSI_IFMT(PCM),
612
613 .portb_flags = SH_FSI_BRS_INV |
614 SH_FSI_BRM_INV |
615 SH_FSI_LRS_INV |
616 SH_FSI_OFMT(SPDIF),
617 .set_rate = fsi_set_rate,
547}; 618};
548 619
549static struct resource fsi_resources[] = { 620static struct resource fsi_resources[] = {
@@ -577,26 +648,6 @@ static struct sh_mobile_lcdc_info sh_mobile_lcdc1_info = {
577 .interface_type = RGB24, 648 .interface_type = RGB24,
578 .clock_divider = 1, 649 .clock_divider = 1,
579 .flags = LCDC_FLAGS_DWPOL, 650 .flags = LCDC_FLAGS_DWPOL,
580 .lcd_cfg = {
581 .name = "HDMI",
582 /* So far only 720p is supported */
583 .xres = 1280,
584 .yres = 720,
585 /*
586 * If left and right margins are not multiples of 8,
587 * LDHAJR will be adjusted accordingly by the LCDC
588 * driver. Until we start using EDID, these values
589 * might have to be adjusted for different monitors.
590 */
591 .left_margin = 200,
592 .right_margin = 88,
593 .hsync_len = 48,
594 .upper_margin = 20,
595 .lower_margin = 5,
596 .vsync_len = 5,
597 .pixclock = 13468,
598 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
599 },
600 } 651 }
601}; 652};
602 653
@@ -608,7 +659,7 @@ static struct resource lcdc1_resources[] = {
608 .flags = IORESOURCE_MEM, 659 .flags = IORESOURCE_MEM,
609 }, 660 },
610 [1] = { 661 [1] = {
611 .start = intcs_evt2irq(0x17a0), 662 .start = intcs_evt2irq(0x1780),
612 .flags = IORESOURCE_IRQ, 663 .flags = IORESOURCE_IRQ,
613 }, 664 },
614}; 665};
@@ -627,6 +678,7 @@ static struct platform_device lcdc1_device = {
627static struct sh_mobile_hdmi_info hdmi_info = { 678static struct sh_mobile_hdmi_info hdmi_info = {
628 .lcd_chan = &sh_mobile_lcdc1_info.ch[0], 679 .lcd_chan = &sh_mobile_lcdc1_info.ch[0],
629 .lcd_dev = &lcdc1_device.dev, 680 .lcd_dev = &lcdc1_device.dev,
681 .flags = HDMI_SND_SRC_SPDIF,
630}; 682};
631 683
632static struct resource hdmi_resources[] = { 684static struct resource hdmi_resources[] = {
@@ -689,6 +741,95 @@ static struct platform_device leds_device = {
689 }, 741 },
690}; 742};
691 743
744static struct i2c_board_info imx074_info = {
745 I2C_BOARD_INFO("imx074", 0x1a),
746};
747
748struct soc_camera_link imx074_link = {
749 .bus_id = 0,
750 .board_info = &imx074_info,
751 .i2c_adapter_id = 0,
752 .module_name = "imx074",
753};
754
755static struct platform_device ap4evb_camera = {
756 .name = "soc-camera-pdrv",
757 .id = 0,
758 .dev = {
759 .platform_data = &imx074_link,
760 },
761};
762
763static struct sh_csi2_client_config csi2_clients[] = {
764 {
765 .phy = SH_CSI2_PHY_MAIN,
766 .lanes = 3,
767 .channel = 0,
768 .pdev = &ap4evb_camera,
769 },
770};
771
772static struct sh_csi2_pdata csi2_info = {
773 .type = SH_CSI2C,
774 .clients = csi2_clients,
775 .num_clients = ARRAY_SIZE(csi2_clients),
776 .flags = SH_CSI2_ECC | SH_CSI2_CRC,
777};
778
779static struct resource csi2_resources[] = {
780 [0] = {
781 .name = "CSI2",
782 .start = 0xffc90000,
783 .end = 0xffc90fff,
784 .flags = IORESOURCE_MEM,
785 },
786 [1] = {
787 .start = intcs_evt2irq(0x17a0),
788 .flags = IORESOURCE_IRQ,
789 },
790};
791
792static struct platform_device csi2_device = {
793 .name = "sh-mobile-csi2",
794 .id = 0,
795 .num_resources = ARRAY_SIZE(csi2_resources),
796 .resource = csi2_resources,
797 .dev = {
798 .platform_data = &csi2_info,
799 },
800};
801
802static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
803 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
804 .csi2_dev = &csi2_device.dev,
805};
806
807static struct resource ceu_resources[] = {
808 [0] = {
809 .name = "CEU",
810 .start = 0xfe910000,
811 .end = 0xfe91009f,
812 .flags = IORESOURCE_MEM,
813 },
814 [1] = {
815 .start = intcs_evt2irq(0x880),
816 .flags = IORESOURCE_IRQ,
817 },
818 [2] = {
819 /* place holder for contiguous memory */
820 },
821};
822
823static struct platform_device ceu_device = {
824 .name = "sh_mobile_ceu",
825 .id = 0, /* "ceu0" clock */
826 .num_resources = ARRAY_SIZE(ceu_resources),
827 .resource = ceu_resources,
828 .dev = {
829 .platform_data = &sh_mobile_ceu_info,
830 },
831};
832
692static struct platform_device *ap4evb_devices[] __initdata = { 833static struct platform_device *ap4evb_devices[] __initdata = {
693 &leds_device, 834 &leds_device,
694 &nor_flash_device, 835 &nor_flash_device,
@@ -701,6 +842,9 @@ static struct platform_device *ap4evb_devices[] __initdata = {
701 &lcdc1_device, 842 &lcdc1_device,
702 &lcdc_device, 843 &lcdc_device,
703 &hdmi_device, 844 &hdmi_device,
845 &csi2_device,
846 &ceu_device,
847 &ap4evb_camera,
704}; 848};
705 849
706static int __init hdmi_init_pm_clock(void) 850static int __init hdmi_init_pm_clock(void)
@@ -715,22 +859,22 @@ static int __init hdmi_init_pm_clock(void)
715 goto out; 859 goto out;
716 } 860 }
717 861
718 ret = clk_set_parent(&pllc2_clk, &dv_clki_div2_clk); 862 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
719 if (ret < 0) { 863 if (ret < 0) {
720 pr_err("Cannot set PLLC2 parent: %d, %d users\n", ret, pllc2_clk.usecount); 864 pr_err("Cannot set PLLC2 parent: %d, %d users\n", ret, sh7372_pllc2_clk.usecount);
721 goto out; 865 goto out;
722 } 866 }
723 867
724 pr_debug("PLLC2 initial frequency %lu\n", clk_get_rate(&pllc2_clk)); 868 pr_debug("PLLC2 initial frequency %lu\n", clk_get_rate(&sh7372_pllc2_clk));
725 869
726 rate = clk_round_rate(&pllc2_clk, 594000000); 870 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
727 if (rate < 0) { 871 if (rate < 0) {
728 pr_err("Cannot get suitable rate: %ld\n", rate); 872 pr_err("Cannot get suitable rate: %ld\n", rate);
729 ret = rate; 873 ret = rate;
730 goto out; 874 goto out;
731 } 875 }
732 876
733 ret = clk_set_rate(&pllc2_clk, rate); 877 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
734 if (ret < 0) { 878 if (ret < 0) {
735 pr_err("Cannot set rate %ld: %d\n", rate, ret); 879 pr_err("Cannot set rate %ld: %d\n", rate, ret);
736 goto out; 880 goto out;
@@ -738,7 +882,7 @@ static int __init hdmi_init_pm_clock(void)
738 882
739 pr_debug("PLLC2 set frequency %lu\n", rate); 883 pr_debug("PLLC2 set frequency %lu\n", rate);
740 884
741 ret = clk_set_parent(hdmi_ick, &pllc2_clk); 885 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
742 if (ret < 0) { 886 if (ret < 0) {
743 pr_err("Cannot set HDMI parent: %d\n", ret); 887 pr_err("Cannot set HDMI parent: %d\n", ret);
744 goto out; 888 goto out;
@@ -752,11 +896,51 @@ out:
752 896
753device_initcall(hdmi_init_pm_clock); 897device_initcall(hdmi_init_pm_clock);
754 898
899#define FSIACK_DUMMY_RATE 48000
900static int __init fsi_init_pm_clock(void)
901{
902 struct clk *fsia_ick;
903 int ret;
904
905 /*
906 * FSIACK is connected to AK4642,
907 * and the rate is depend on playing sound rate.
908 * So, set dummy rate (= 48k) here
909 */
910 ret = clk_set_rate(&sh7372_fsiack_clk, FSIACK_DUMMY_RATE);
911 if (ret < 0) {
912 pr_err("Cannot set FSIACK dummy rate: %d\n", ret);
913 return ret;
914 }
915
916 fsia_ick = clk_get(&fsi_device.dev, "icka");
917 if (IS_ERR(fsia_ick)) {
918 ret = PTR_ERR(fsia_ick);
919 pr_err("Cannot get FSI ICK: %d\n", ret);
920 return ret;
921 }
922
923 ret = clk_set_parent(fsia_ick, &sh7372_fsiack_clk);
924 if (ret < 0) {
925 pr_err("Cannot set FSI-A parent: %d\n", ret);
926 goto out;
927 }
928
929 ret = clk_set_rate(fsia_ick, FSIACK_DUMMY_RATE);
930 if (ret < 0)
931 pr_err("Cannot set FSI-A rate: %d\n", ret);
932
933out:
934 clk_put(fsia_ick);
935
936 return ret;
937}
938device_initcall(fsi_init_pm_clock);
939
755/* 940/*
756 * FIXME !! 941 * FIXME !!
757 * 942 *
758 * gpio_no_direction 943 * gpio_no_direction
759 * gpio_pull_up
760 * are quick_hack. 944 * are quick_hack.
761 * 945 *
762 * current gpio frame work doesn't have 946 * current gpio frame work doesn't have
@@ -768,49 +952,37 @@ static void __init gpio_no_direction(u32 addr)
768 __raw_writeb(0x00, addr); 952 __raw_writeb(0x00, addr);
769} 953}
770 954
771static void __init gpio_pull_up(u32 addr)
772{
773 u8 data = __raw_readb(addr);
774
775 data &= 0x0F;
776 data |= 0xC0;
777 __raw_writeb(data, addr);
778}
779
780/* TouchScreen */ 955/* TouchScreen */
956#ifdef CONFIG_AP4EVB_QHD
957# define GPIO_TSC_IRQ GPIO_FN_IRQ28_123
958# define GPIO_TSC_PORT GPIO_PORT123
959#else /* WVGA */
960# define GPIO_TSC_IRQ GPIO_FN_IRQ7_40
961# define GPIO_TSC_PORT GPIO_PORT40
962#endif
963
781#define IRQ28 evt2irq(0x3380) /* IRQ28A */ 964#define IRQ28 evt2irq(0x3380) /* IRQ28A */
782#define IRQ7 evt2irq(0x02e0) /* IRQ7A */ 965#define IRQ7 evt2irq(0x02e0) /* IRQ7A */
783static int ts_get_pendown_state(void) 966static int ts_get_pendown_state(void)
784{ 967{
785 int val1, val2; 968 int val;
786 969
787 gpio_free(GPIO_FN_IRQ28_123); 970 gpio_free(GPIO_TSC_IRQ);
788 gpio_free(GPIO_FN_IRQ7_40);
789 971
790 gpio_request(GPIO_PORT123, NULL); 972 gpio_request(GPIO_TSC_PORT, NULL);
791 gpio_request(GPIO_PORT40, NULL);
792 973
793 gpio_direction_input(GPIO_PORT123); 974 gpio_direction_input(GPIO_TSC_PORT);
794 gpio_direction_input(GPIO_PORT40);
795 975
796 val1 = gpio_get_value(GPIO_PORT123); 976 val = gpio_get_value(GPIO_TSC_PORT);
797 val2 = gpio_get_value(GPIO_PORT40);
798 977
799 gpio_request(GPIO_FN_IRQ28_123, NULL); /* for QHD */ 978 gpio_request(GPIO_TSC_IRQ, NULL);
800 gpio_request(GPIO_FN_IRQ7_40, NULL); /* for WVGA */
801 979
802 return val1 ^ val2; 980 return !val;
803} 981}
804 982
805#define PORT40CR 0xE6051028
806#define PORT123CR 0xE605007B
807static int ts_init(void) 983static int ts_init(void)
808{ 984{
809 gpio_request(GPIO_FN_IRQ28_123, NULL); /* for QHD */ 985 gpio_request(GPIO_TSC_IRQ, NULL);
810 gpio_request(GPIO_FN_IRQ7_40, NULL); /* for WVGA */
811
812 gpio_pull_up(PORT40CR);
813 gpio_pull_up(PORT123CR);
814 986
815 return 0; 987 return 0;
816} 988}
@@ -865,6 +1037,7 @@ static void __init ap4evb_map_io(void)
865 1037
866#define GPIO_PORT9CR 0xE6051009 1038#define GPIO_PORT9CR 0xE6051009
867#define GPIO_PORT10CR 0xE605100A 1039#define GPIO_PORT10CR 0xE605100A
1040#define USCCR1 0xE6058144
868static void __init ap4evb_init(void) 1041static void __init ap4evb_init(void)
869{ 1042{
870 u32 srcr4; 1043 u32 srcr4;
@@ -935,7 +1108,7 @@ static void __init ap4evb_init(void)
935 /* setup USB phy */ 1108 /* setup USB phy */
936 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */ 1109 __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */
937 1110
938 /* enable FSI2 */ 1111 /* enable FSI2 port A (ak4643) */
939 gpio_request(GPIO_FN_FSIAIBT, NULL); 1112 gpio_request(GPIO_FN_FSIAIBT, NULL);
940 gpio_request(GPIO_FN_FSIAILR, NULL); 1113 gpio_request(GPIO_FN_FSIAILR, NULL);
941 gpio_request(GPIO_FN_FSIAISLD, NULL); 1114 gpio_request(GPIO_FN_FSIAISLD, NULL);
@@ -948,6 +1121,14 @@ static void __init ap4evb_init(void)
948 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ 1121 gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */
949 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ 1122 gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */
950 1123
1124 /* card detect pin for MMC slot (CN7) */
1125 gpio_request(GPIO_PORT41, NULL);
1126 gpio_direction_input(GPIO_PORT41);
1127
1128 /* setup FSI2 port B (HDMI) */
1129 gpio_request(GPIO_FN_FSIBCK, NULL);
1130 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1131
951 /* set SPU2 clock to 119.6 MHz */ 1132 /* set SPU2 clock to 119.6 MHz */
952 clk = clk_get(NULL, "spu_clk"); 1133 clk = clk_get(NULL, "spu_clk");
953 if (!IS_ERR(clk)) { 1134 if (!IS_ERR(clk)) {
@@ -955,14 +1136,6 @@ static void __init ap4evb_init(void)
955 clk_put(clk); 1136 clk_put(clk);
956 } 1137 }
957 1138
958 /* change parent of FSI A */
959 clk = clk_get(NULL, "fsia_clk");
960 if (!IS_ERR(clk)) {
961 clk_register(&fsiackcr_clk);
962 clk_set_parent(clk, &fsiackcr_clk);
963 clk_put(clk);
964 }
965
966 /* 1139 /*
967 * set irq priority, to avoid sound chopping 1140 * set irq priority, to avoid sound chopping
968 * when NFS rootfs is used 1141 * when NFS rootfs is used
@@ -977,8 +1150,10 @@ static void __init ap4evb_init(void)
977 ARRAY_SIZE(i2c1_devices)); 1150 ARRAY_SIZE(i2c1_devices));
978 1151
979#ifdef CONFIG_AP4EVB_QHD 1152#ifdef CONFIG_AP4EVB_QHD
1153
980 /* 1154 /*
981 * QHD 1155 * For QHD Panel (MIPI-DSI, CONFIG_AP4EVB_QHD=y) and
1156 * IRQ28 for Touch Panel, set dip switches S3, S43 as OFF, ON.
982 */ 1157 */
983 1158
984 /* enable KEYSC */ 1159 /* enable KEYSC */
@@ -1004,17 +1179,6 @@ static void __init ap4evb_init(void)
1004 lcdc_info.ch[0].interface_type = RGB24; 1179 lcdc_info.ch[0].interface_type = RGB24;
1005 lcdc_info.ch[0].clock_divider = 1; 1180 lcdc_info.ch[0].clock_divider = 1;
1006 lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL; 1181 lcdc_info.ch[0].flags = LCDC_FLAGS_DWPOL;
1007 lcdc_info.ch[0].lcd_cfg.name = "R63302(QHD)";
1008 lcdc_info.ch[0].lcd_cfg.xres = 544;
1009 lcdc_info.ch[0].lcd_cfg.yres = 961;
1010 lcdc_info.ch[0].lcd_cfg.left_margin = 72;
1011 lcdc_info.ch[0].lcd_cfg.right_margin = 600;
1012 lcdc_info.ch[0].lcd_cfg.hsync_len = 16;
1013 lcdc_info.ch[0].lcd_cfg.upper_margin = 8;
1014 lcdc_info.ch[0].lcd_cfg.lower_margin = 8;
1015 lcdc_info.ch[0].lcd_cfg.vsync_len = 2;
1016 lcdc_info.ch[0].lcd_cfg.sync = FB_SYNC_VERT_HIGH_ACT |
1017 FB_SYNC_HOR_HIGH_ACT;
1018 lcdc_info.ch[0].lcd_size_cfg.width = 44; 1182 lcdc_info.ch[0].lcd_size_cfg.width = 44;
1019 lcdc_info.ch[0].lcd_size_cfg.height = 79; 1183 lcdc_info.ch[0].lcd_size_cfg.height = 79;
1020 1184
@@ -1022,8 +1186,10 @@ static void __init ap4evb_init(void)
1022 1186
1023#else 1187#else
1024 /* 1188 /*
1025 * WVGA 1189 * For WVGA Panel (18-bit RGB, CONFIG_AP4EVB_WVGA=y) and
1190 * IRQ7 for Touch Panel, set dip switches S3, S43 to ON, OFF.
1026 */ 1191 */
1192
1027 gpio_request(GPIO_FN_LCDD17, NULL); 1193 gpio_request(GPIO_FN_LCDD17, NULL);
1028 gpio_request(GPIO_FN_LCDD16, NULL); 1194 gpio_request(GPIO_FN_LCDD16, NULL);
1029 gpio_request(GPIO_FN_LCDD15, NULL); 1195 gpio_request(GPIO_FN_LCDD15, NULL);
@@ -1055,16 +1221,6 @@ static void __init ap4evb_init(void)
1055 lcdc_info.ch[0].interface_type = RGB18; 1221 lcdc_info.ch[0].interface_type = RGB18;
1056 lcdc_info.ch[0].clock_divider = 2; 1222 lcdc_info.ch[0].clock_divider = 2;
1057 lcdc_info.ch[0].flags = 0; 1223 lcdc_info.ch[0].flags = 0;
1058 lcdc_info.ch[0].lcd_cfg.name = "WVGA Panel";
1059 lcdc_info.ch[0].lcd_cfg.xres = 800;
1060 lcdc_info.ch[0].lcd_cfg.yres = 480;
1061 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
1062 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
1063 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
1064 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
1065 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
1066 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
1067 lcdc_info.ch[0].lcd_cfg.sync = 0;
1068 lcdc_info.ch[0].lcd_size_cfg.width = 152; 1224 lcdc_info.ch[0].lcd_size_cfg.width = 152;
1069 lcdc_info.ch[0].lcd_size_cfg.height = 91; 1225 lcdc_info.ch[0].lcd_size_cfg.height = 91;
1070 1226
@@ -1075,6 +1231,23 @@ static void __init ap4evb_init(void)
1075 i2c_register_board_info(0, &tsc_device, 1); 1231 i2c_register_board_info(0, &tsc_device, 1);
1076#endif /* CONFIG_AP4EVB_QHD */ 1232#endif /* CONFIG_AP4EVB_QHD */
1077 1233
1234 /* CEU */
1235
1236 /*
1237 * TODO: reserve memory for V4L2 DMA buffers, when a suitable API
1238 * becomes available
1239 */
1240
1241 /* MIPI-CSI stuff */
1242 gpio_request(GPIO_FN_VIO_CKO, NULL);
1243
1244 clk = clk_get(NULL, "vck1_clk");
1245 if (!IS_ERR(clk)) {
1246 clk_set_rate(clk, clk_round_rate(clk, 13000000));
1247 clk_enable(clk);
1248 clk_put(clk);
1249 }
1250
1078 sh7372_add_standard_devices(); 1251 sh7372_add_standard_devices();
1079 1252
1080 /* HDMI */ 1253 /* HDMI */
@@ -1097,7 +1270,7 @@ static void __init ap4evb_timer_init(void)
1097 shmobile_timer.init(); 1270 shmobile_timer.init();
1098 1271
1099 /* External clock source */ 1272 /* External clock source */
1100 clk_set_rate(&dv_clki_clk, 27000000); 1273 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1101} 1274}
1102 1275
1103static struct sys_timer ap4evb_timer = { 1276static struct sys_timer ap4evb_timer = {
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index b6454c9f2abb..9f78729098f2 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -321,7 +321,7 @@ static struct clk_lookup lookups[] = {
321 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[SYMSTP001]), /* SCIFA3 */ 321 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[SYMSTP001]), /* SCIFA3 */
322 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[SYMSTP000]), /* SCIFA4 */ 322 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[SYMSTP000]), /* SCIFA4 */
323 CLKDEV_DEV_ID("sh_siu", &mstp_clks[SYMSTP231]), /* SIU */ 323 CLKDEV_DEV_ID("sh_siu", &mstp_clks[SYMSTP231]), /* SIU */
324 CLKDEV_CON_ID("cmt1", &mstp_clks[SYMSTP229]), /* CMT10 */ 324 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[SYMSTP229]), /* CMT10 */
325 CLKDEV_DEV_ID("sh_irda", &mstp_clks[SYMSTP225]), /* IRDA */ 325 CLKDEV_DEV_ID("sh_irda", &mstp_clks[SYMSTP225]), /* IRDA */
326 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[SYMSTP223]), /* IIC1 */ 326 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[SYMSTP223]), /* IIC1 */
327 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[SYMSTP222]), /* USBHS */ 327 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[SYMSTP222]), /* USBHS */
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 759468992ad2..7db31e6c6bf2 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -50,8 +50,11 @@
50#define SMSTPCR3 0xe615013c 50#define SMSTPCR3 0xe615013c
51#define SMSTPCR4 0xe6150140 51#define SMSTPCR4 0xe6150140
52 52
53#define FSIDIVA 0xFE1F8000
54#define FSIDIVB 0xFE1F8008
55
53/* Platforms must set frequency on their DV_CLKI pin */ 56/* Platforms must set frequency on their DV_CLKI pin */
54struct clk dv_clki_clk = { 57struct clk sh7372_dv_clki_clk = {
55}; 58};
56 59
57/* Fixed 32 KHz root clock from EXTALR pin */ 60/* Fixed 32 KHz root clock from EXTALR pin */
@@ -86,9 +89,9 @@ static struct clk_ops div2_clk_ops = {
86}; 89};
87 90
88/* Divide dv_clki by two */ 91/* Divide dv_clki by two */
89struct clk dv_clki_div2_clk = { 92struct clk sh7372_dv_clki_div2_clk = {
90 .ops = &div2_clk_ops, 93 .ops = &div2_clk_ops,
91 .parent = &dv_clki_clk, 94 .parent = &sh7372_dv_clki_clk,
92}; 95};
93 96
94/* Divide extal1 by two */ 97/* Divide extal1 by two */
@@ -150,7 +153,7 @@ static struct clk pllc1_div2_clk = {
150static struct clk *pllc2_parent[] = { 153static struct clk *pllc2_parent[] = {
151 [0] = &extal1_div2_clk, 154 [0] = &extal1_div2_clk,
152 [1] = &extal2_div2_clk, 155 [1] = &extal2_div2_clk,
153 [2] = &dv_clki_div2_clk, 156 [2] = &sh7372_dv_clki_div2_clk,
154}; 157};
155 158
156/* Only multipliers 20 * 2 to 46 * 2 are valid, last entry for CPUFREQ_TABLE_END */ 159/* Only multipliers 20 * 2 to 46 * 2 are valid, last entry for CPUFREQ_TABLE_END */
@@ -284,27 +287,37 @@ static struct clk_ops pllc2_clk_ops = {
284 .set_parent = pllc2_set_parent, 287 .set_parent = pllc2_set_parent,
285}; 288};
286 289
287struct clk pllc2_clk = { 290struct clk sh7372_pllc2_clk = {
288 .ops = &pllc2_clk_ops, 291 .ops = &pllc2_clk_ops,
289 .parent = &extal1_div2_clk, 292 .parent = &extal1_div2_clk,
290 .freq_table = pllc2_freq_table, 293 .freq_table = pllc2_freq_table,
294 .nr_freqs = ARRAY_SIZE(pllc2_freq_table) - 1,
291 .parent_table = pllc2_parent, 295 .parent_table = pllc2_parent,
292 .parent_num = ARRAY_SIZE(pllc2_parent), 296 .parent_num = ARRAY_SIZE(pllc2_parent),
293}; 297};
294 298
299/* External input clock (pin name: FSIACK/FSIBCK ) */
300struct clk sh7372_fsiack_clk = {
301};
302
303struct clk sh7372_fsibck_clk = {
304};
305
295static struct clk *main_clks[] = { 306static struct clk *main_clks[] = {
296 &dv_clki_clk, 307 &sh7372_dv_clki_clk,
297 &r_clk, 308 &r_clk,
298 &sh7372_extal1_clk, 309 &sh7372_extal1_clk,
299 &sh7372_extal2_clk, 310 &sh7372_extal2_clk,
300 &dv_clki_div2_clk, 311 &sh7372_dv_clki_div2_clk,
301 &extal1_div2_clk, 312 &extal1_div2_clk,
302 &extal2_div2_clk, 313 &extal2_div2_clk,
303 &extal2_div4_clk, 314 &extal2_div4_clk,
304 &pllc0_clk, 315 &pllc0_clk,
305 &pllc1_clk, 316 &pllc1_clk,
306 &pllc1_div2_clk, 317 &pllc1_div2_clk,
307 &pllc2_clk, 318 &sh7372_pllc2_clk,
319 &sh7372_fsiack_clk,
320 &sh7372_fsibck_clk,
308}; 321};
309 322
310static void div4_kick(struct clk *clk) 323static void div4_kick(struct clk *clk)
@@ -357,7 +370,7 @@ static struct clk div4_clks[DIV4_NR] = {
357}; 370};
358 371
359enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_FMSI, DIV6_FMSO, 372enum { DIV6_VCK1, DIV6_VCK2, DIV6_VCK3, DIV6_FMSI, DIV6_FMSO,
360 DIV6_FSIA, DIV6_FSIB, DIV6_SUB, DIV6_SPU, 373 DIV6_SUB, DIV6_SPU,
361 DIV6_VOU, DIV6_DSIT, DIV6_DSI0P, DIV6_DSI1P, 374 DIV6_VOU, DIV6_DSIT, DIV6_DSI0P, DIV6_DSI1P,
362 DIV6_NR }; 375 DIV6_NR };
363 376
@@ -367,8 +380,6 @@ static struct clk div6_clks[DIV6_NR] = {
367 [DIV6_VCK3] = SH_CLK_DIV6(&pllc1_div2_clk, VCLKCR3, 0), 380 [DIV6_VCK3] = SH_CLK_DIV6(&pllc1_div2_clk, VCLKCR3, 0),
368 [DIV6_FMSI] = SH_CLK_DIV6(&pllc1_div2_clk, FMSICKCR, 0), 381 [DIV6_FMSI] = SH_CLK_DIV6(&pllc1_div2_clk, FMSICKCR, 0),
369 [DIV6_FMSO] = SH_CLK_DIV6(&pllc1_div2_clk, FMSOCKCR, 0), 382 [DIV6_FMSO] = SH_CLK_DIV6(&pllc1_div2_clk, FMSOCKCR, 0),
370 [DIV6_FSIA] = SH_CLK_DIV6(&pllc1_div2_clk, FSIACKCR, 0),
371 [DIV6_FSIB] = SH_CLK_DIV6(&pllc1_div2_clk, FSIBCKCR, 0),
372 [DIV6_SUB] = SH_CLK_DIV6(&sh7372_extal2_clk, SUBCKCR, 0), 383 [DIV6_SUB] = SH_CLK_DIV6(&sh7372_extal2_clk, SUBCKCR, 0),
373 [DIV6_SPU] = SH_CLK_DIV6(&pllc1_div2_clk, SPUCKCR, 0), 384 [DIV6_SPU] = SH_CLK_DIV6(&pllc1_div2_clk, SPUCKCR, 0),
374 [DIV6_VOU] = SH_CLK_DIV6(&pllc1_div2_clk, VOUCKCR, 0), 385 [DIV6_VOU] = SH_CLK_DIV6(&pllc1_div2_clk, VOUCKCR, 0),
@@ -377,24 +388,137 @@ static struct clk div6_clks[DIV6_NR] = {
377 [DIV6_DSI1P] = SH_CLK_DIV6(&pllc1_div2_clk, DSI1PCKCR, 0), 388 [DIV6_DSI1P] = SH_CLK_DIV6(&pllc1_div2_clk, DSI1PCKCR, 0),
378}; 389};
379 390
380enum { DIV6_HDMI, DIV6_REPARENT_NR }; 391enum { DIV6_HDMI, DIV6_FSIA, DIV6_FSIB, DIV6_REPARENT_NR };
381 392
382/* Indices are important - they are the actual src selecting values */ 393/* Indices are important - they are the actual src selecting values */
383static struct clk *hdmi_parent[] = { 394static struct clk *hdmi_parent[] = {
384 [0] = &pllc1_div2_clk, 395 [0] = &pllc1_div2_clk,
385 [1] = &pllc2_clk, 396 [1] = &sh7372_pllc2_clk,
386 [2] = &dv_clki_clk, 397 [2] = &sh7372_dv_clki_clk,
387 [3] = NULL, /* pllc2_div4 not implemented yet */ 398 [3] = NULL, /* pllc2_div4 not implemented yet */
388}; 399};
389 400
401static struct clk *fsiackcr_parent[] = {
402 [0] = &pllc1_div2_clk,
403 [1] = &sh7372_pllc2_clk,
404 [2] = &sh7372_fsiack_clk, /* external input for FSI A */
405 [3] = NULL, /* setting prohibited */
406};
407
408static struct clk *fsibckcr_parent[] = {
409 [0] = &pllc1_div2_clk,
410 [1] = &sh7372_pllc2_clk,
411 [2] = &sh7372_fsibck_clk, /* external input for FSI B */
412 [3] = NULL, /* setting prohibited */
413};
414
390static struct clk div6_reparent_clks[DIV6_REPARENT_NR] = { 415static struct clk div6_reparent_clks[DIV6_REPARENT_NR] = {
391 [DIV6_HDMI] = SH_CLK_DIV6_EXT(&pllc1_div2_clk, HDMICKCR, 0, 416 [DIV6_HDMI] = SH_CLK_DIV6_EXT(&pllc1_div2_clk, HDMICKCR, 0,
392 hdmi_parent, ARRAY_SIZE(hdmi_parent), 6, 2), 417 hdmi_parent, ARRAY_SIZE(hdmi_parent), 6, 2),
418 [DIV6_FSIA] = SH_CLK_DIV6_EXT(&pllc1_div2_clk, FSIACKCR, 0,
419 fsiackcr_parent, ARRAY_SIZE(fsiackcr_parent), 6, 2),
420 [DIV6_FSIB] = SH_CLK_DIV6_EXT(&pllc1_div2_clk, FSIBCKCR, 0,
421 fsibckcr_parent, ARRAY_SIZE(fsibckcr_parent), 6, 2),
422};
423
424/* FSI DIV */
425static unsigned long fsidiv_recalc(struct clk *clk)
426{
427 unsigned long value;
428
429 value = __raw_readl(clk->mapping->base);
430
431 if ((value & 0x3) != 0x3)
432 return 0;
433
434 value >>= 16;
435 if (value < 2)
436 return 0;
437
438 return clk->parent->rate / value;
439}
440
441static long fsidiv_round_rate(struct clk *clk, unsigned long rate)
442{
443 return clk_rate_div_range_round(clk, 2, 0xffff, rate);
444}
445
446static void fsidiv_disable(struct clk *clk)
447{
448 __raw_writel(0, clk->mapping->base);
449}
450
451static int fsidiv_enable(struct clk *clk)
452{
453 unsigned long value;
454
455 value = __raw_readl(clk->mapping->base) >> 16;
456 if (value < 2) {
457 fsidiv_disable(clk);
458 return -ENOENT;
459 }
460
461 __raw_writel((value << 16) | 0x3, clk->mapping->base);
462
463 return 0;
464}
465
466static int fsidiv_set_rate(struct clk *clk,
467 unsigned long rate, int algo_id)
468{
469 int idx;
470
471 if (clk->parent->rate == rate) {
472 fsidiv_disable(clk);
473 return 0;
474 }
475
476 idx = (clk->parent->rate / rate) & 0xffff;
477 if (idx < 2)
478 return -ENOENT;
479
480 __raw_writel(idx << 16, clk->mapping->base);
481 return fsidiv_enable(clk);
482}
483
484static struct clk_ops fsidiv_clk_ops = {
485 .recalc = fsidiv_recalc,
486 .round_rate = fsidiv_round_rate,
487 .set_rate = fsidiv_set_rate,
488 .enable = fsidiv_enable,
489 .disable = fsidiv_disable,
490};
491
492static struct clk_mapping sh7372_fsidiva_clk_mapping = {
493 .phys = FSIDIVA,
494 .len = 8,
495};
496
497struct clk sh7372_fsidiva_clk = {
498 .ops = &fsidiv_clk_ops,
499 .parent = &div6_reparent_clks[DIV6_FSIA], /* late install */
500 .mapping = &sh7372_fsidiva_clk_mapping,
501};
502
503static struct clk_mapping sh7372_fsidivb_clk_mapping = {
504 .phys = FSIDIVB,
505 .len = 8,
506};
507
508struct clk sh7372_fsidivb_clk = {
509 .ops = &fsidiv_clk_ops,
510 .parent = &div6_reparent_clks[DIV6_FSIB], /* late install */
511 .mapping = &sh7372_fsidivb_clk_mapping,
512};
513
514static struct clk *late_main_clks[] = {
515 &sh7372_fsidiva_clk,
516 &sh7372_fsidivb_clk,
393}; 517};
394 518
395enum { MSTP001, 519enum { MSTP001,
396 MSTP131, MSTP130, 520 MSTP131, MSTP130,
397 MSTP129, MSTP128, MSTP127, MSTP126, 521 MSTP129, MSTP128, MSTP127, MSTP126, MSTP125,
398 MSTP118, MSTP117, MSTP116, 522 MSTP118, MSTP117, MSTP116,
399 MSTP106, MSTP101, MSTP100, 523 MSTP106, MSTP101, MSTP100,
400 MSTP223, 524 MSTP223,
@@ -414,6 +538,7 @@ static struct clk mstp_clks[MSTP_NR] = {
414 [MSTP128] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 28, 0), /* VEU0 */ 538 [MSTP128] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 28, 0), /* VEU0 */
415 [MSTP127] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 27, 0), /* CEU */ 539 [MSTP127] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 27, 0), /* CEU */
416 [MSTP126] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 26, 0), /* CSI2 */ 540 [MSTP126] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 26, 0), /* CSI2 */
541 [MSTP125] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
417 [MSTP118] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 18, 0), /* DSITX */ 542 [MSTP118] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 18, 0), /* DSITX */
418 [MSTP117] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */ 543 [MSTP117] = MSTP(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */
419 [MSTP116] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */ 544 [MSTP116] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */
@@ -429,7 +554,7 @@ static struct clk mstp_clks[MSTP_NR] = {
429 [MSTP201] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 1, 0), /* SCIFA3 */ 554 [MSTP201] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 1, 0), /* SCIFA3 */
430 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */ 555 [MSTP200] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR2, 0, 0), /* SCIFA4 */
431 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */ 556 [MSTP329] = MSTP(&r_clk, SMSTPCR3, 29, 0), /* CMT10 */
432 [MSTP328] = MSTP(&div6_clks[DIV6_SPU], SMSTPCR3, 28, 0), /* FSIA */ 557 [MSTP328] = MSTP(&div6_clks[DIV6_SPU], SMSTPCR3, 28, 0), /* FSI2 */
433 [MSTP323] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 23, 0), /* IIC1 */ 558 [MSTP323] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 23, 0), /* IIC1 */
434 [MSTP322] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 22, 0), /* USB0 */ 559 [MSTP322] = MSTP(&div6_clks[DIV6_SUB], SMSTPCR3, 22, 0), /* USB0 */
435 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */ 560 [MSTP314] = MSTP(&div4_clks[DIV4_HP], SMSTPCR3, 14, 0), /* SDHI0 */
@@ -445,10 +570,11 @@ static struct clk mstp_clks[MSTP_NR] = {
445 570
446#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk } 571#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
447#define CLKDEV_DEV_ID(_id, _clk) { .dev_id = _id, .clk = _clk } 572#define CLKDEV_DEV_ID(_id, _clk) { .dev_id = _id, .clk = _clk }
573#define CLKDEV_ICK_ID(_cid, _did, _clk) { .con_id = _cid, .dev_id = _did, .clk = _clk }
448 574
449static struct clk_lookup lookups[] = { 575static struct clk_lookup lookups[] = {
450 /* main clocks */ 576 /* main clocks */
451 CLKDEV_CON_ID("dv_clki_div2_clk", &dv_clki_div2_clk), 577 CLKDEV_CON_ID("dv_clki_div2_clk", &sh7372_dv_clki_div2_clk),
452 CLKDEV_CON_ID("r_clk", &r_clk), 578 CLKDEV_CON_ID("r_clk", &r_clk),
453 CLKDEV_CON_ID("extal1", &sh7372_extal1_clk), 579 CLKDEV_CON_ID("extal1", &sh7372_extal1_clk),
454 CLKDEV_CON_ID("extal2", &sh7372_extal2_clk), 580 CLKDEV_CON_ID("extal2", &sh7372_extal2_clk),
@@ -458,7 +584,7 @@ static struct clk_lookup lookups[] = {
458 CLKDEV_CON_ID("pllc0_clk", &pllc0_clk), 584 CLKDEV_CON_ID("pllc0_clk", &pllc0_clk),
459 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk), 585 CLKDEV_CON_ID("pllc1_clk", &pllc1_clk),
460 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk), 586 CLKDEV_CON_ID("pllc1_div2_clk", &pllc1_div2_clk),
461 CLKDEV_CON_ID("pllc2_clk", &pllc2_clk), 587 CLKDEV_CON_ID("pllc2_clk", &sh7372_pllc2_clk),
462 588
463 /* DIV4 clocks */ 589 /* DIV4 clocks */
464 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]), 590 CLKDEV_CON_ID("i_clk", &div4_clks[DIV4_I]),
@@ -483,8 +609,8 @@ static struct clk_lookup lookups[] = {
483 CLKDEV_CON_ID("vck3_clk", &div6_clks[DIV6_VCK3]), 609 CLKDEV_CON_ID("vck3_clk", &div6_clks[DIV6_VCK3]),
484 CLKDEV_CON_ID("fmsi_clk", &div6_clks[DIV6_FMSI]), 610 CLKDEV_CON_ID("fmsi_clk", &div6_clks[DIV6_FMSI]),
485 CLKDEV_CON_ID("fmso_clk", &div6_clks[DIV6_FMSO]), 611 CLKDEV_CON_ID("fmso_clk", &div6_clks[DIV6_FMSO]),
486 CLKDEV_CON_ID("fsia_clk", &div6_clks[DIV6_FSIA]), 612 CLKDEV_CON_ID("fsia_clk", &div6_reparent_clks[DIV6_FSIA]),
487 CLKDEV_CON_ID("fsib_clk", &div6_clks[DIV6_FSIB]), 613 CLKDEV_CON_ID("fsib_clk", &div6_reparent_clks[DIV6_FSIB]),
488 CLKDEV_CON_ID("sub_clk", &div6_clks[DIV6_SUB]), 614 CLKDEV_CON_ID("sub_clk", &div6_clks[DIV6_SUB]),
489 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]), 615 CLKDEV_CON_ID("spu_clk", &div6_clks[DIV6_SPU]),
490 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]), 616 CLKDEV_CON_ID("vou_clk", &div6_clks[DIV6_VOU]),
@@ -501,6 +627,8 @@ static struct clk_lookup lookups[] = {
501 CLKDEV_DEV_ID("uio_pdrv_genirq.1", &mstp_clks[MSTP128]), /* VEU0 */ 627 CLKDEV_DEV_ID("uio_pdrv_genirq.1", &mstp_clks[MSTP128]), /* VEU0 */
502 CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU */ 628 CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU */
503 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */ 629 CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */
630 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
631 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
504 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */ 632 CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */
505 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */ 633 CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */
506 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */ 634 CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */
@@ -516,7 +644,7 @@ static struct clk_lookup lookups[] = {
516 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP202]), /* SCIFA2 */ 644 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP202]), /* SCIFA2 */
517 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */ 645 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */
518 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ 646 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
519 CLKDEV_CON_ID("cmt1", &mstp_clks[MSTP329]), /* CMT10 */ 647 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
520 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI2 */ 648 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI2 */
521 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */ 649 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */
522 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP323]), /* USB0 */ 650 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP323]), /* USB0 */
@@ -531,7 +659,10 @@ static struct clk_lookup lookups[] = {
531 CLKDEV_DEV_ID("r8a66597_hcd.1", &mstp_clks[MSTP406]), /* USB1 */ 659 CLKDEV_DEV_ID("r8a66597_hcd.1", &mstp_clks[MSTP406]), /* USB1 */
532 CLKDEV_DEV_ID("r8a66597_udc.1", &mstp_clks[MSTP406]), /* USB1 */ 660 CLKDEV_DEV_ID("r8a66597_udc.1", &mstp_clks[MSTP406]), /* USB1 */
533 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */ 661 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */
534 {.con_id = "ick", .dev_id = "sh-mobile-hdmi", .clk = &div6_reparent_clks[DIV6_HDMI]}, 662
663 CLKDEV_ICK_ID("ick", "sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]),
664 CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]),
665 CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]),
535}; 666};
536 667
537void __init sh7372_clock_init(void) 668void __init sh7372_clock_init(void)
@@ -548,11 +679,14 @@ void __init sh7372_clock_init(void)
548 ret = sh_clk_div6_register(div6_clks, DIV6_NR); 679 ret = sh_clk_div6_register(div6_clks, DIV6_NR);
549 680
550 if (!ret) 681 if (!ret)
551 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_NR); 682 ret = sh_clk_div6_reparent_register(div6_reparent_clks, DIV6_REPARENT_NR);
552 683
553 if (!ret) 684 if (!ret)
554 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); 685 ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);
555 686
687 for (k = 0; !ret && (k < ARRAY_SIZE(late_main_clks)); k++)
688 ret = clk_register(late_main_clks[k]);
689
556 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 690 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
557 691
558 if (!ret) 692 if (!ret)
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index e007c28cf0a8..f91395aeb9ab 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -333,7 +333,7 @@ static struct clk_lookup lookups[] = {
333 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */ 333 CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */
334 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */ 334 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
335 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ 335 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
336 CLKDEV_CON_ID("cmt1", &mstp_clks[MSTP329]), /* CMT10 */ 336 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
337 CLKDEV_DEV_ID("sh_irda", &mstp_clks[MSTP325]), /* IRDA */ 337 CLKDEV_DEV_ID("sh_irda", &mstp_clks[MSTP325]), /* IRDA */
338 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */ 338 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* IIC1 */
339 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP322]), /* USBHS */ 339 CLKDEV_DEV_ID("r8a66597_hcd.0", &mstp_clks[MSTP322]), /* USBHS */
diff --git a/arch/arm/mach-shmobile/include/mach/gpio.h b/arch/arm/mach-shmobile/include/mach/gpio.h
index 5bc6bd444d72..2b1bb9e43dda 100644
--- a/arch/arm/mach-shmobile/include/mach/gpio.h
+++ b/arch/arm/mach-shmobile/include/mach/gpio.h
@@ -35,12 +35,12 @@ static inline int gpio_cansleep(unsigned gpio)
35 35
36static inline int gpio_to_irq(unsigned gpio) 36static inline int gpio_to_irq(unsigned gpio)
37{ 37{
38 return -ENOSYS; 38 return __gpio_to_irq(gpio);
39} 39}
40 40
41static inline int irq_to_gpio(unsigned int irq) 41static inline int irq_to_gpio(unsigned int irq)
42{ 42{
43 return -EINVAL; 43 return -ENOSYS;
44} 44}
45 45
46#endif /* CONFIG_GPIOLIB */ 46#endif /* CONFIG_GPIOLIB */
diff --git a/arch/arm/mach-shmobile/include/mach/sh7372.h b/arch/arm/mach-shmobile/include/mach/sh7372.h
index 33e9700ded7e..e4f9004e7103 100644
--- a/arch/arm/mach-shmobile/include/mach/sh7372.h
+++ b/arch/arm/mach-shmobile/include/mach/sh7372.h
@@ -457,8 +457,14 @@ enum {
457 SHDMA_SLAVE_SDHI2_TX, 457 SHDMA_SLAVE_SDHI2_TX,
458}; 458};
459 459
460extern struct clk dv_clki_clk; 460extern struct clk sh7372_extal1_clk;
461extern struct clk dv_clki_div2_clk; 461extern struct clk sh7372_extal2_clk;
462extern struct clk pllc2_clk; 462extern struct clk sh7372_dv_clki_clk;
463extern struct clk sh7372_dv_clki_div2_clk;
464extern struct clk sh7372_pllc2_clk;
465extern struct clk sh7372_fsiack_clk;
466extern struct clk sh7372_fsibck_clk;
467extern struct clk sh7372_fsidiva_clk;
468extern struct clk sh7372_fsidivb_clk;
463 469
464#endif /* __ASM_SH7372_H__ */ 470#endif /* __ASM_SH7372_H__ */
diff --git a/arch/arm/mach-shmobile/intc-sh7372.c b/arch/arm/mach-shmobile/intc-sh7372.c
index e3551b56cd03..30b2f400666a 100644
--- a/arch/arm/mach-shmobile/intc-sh7372.c
+++ b/arch/arm/mach-shmobile/intc-sh7372.c
@@ -98,7 +98,7 @@ static struct intc_vect intca_vectors[] __initdata = {
98 INTC_VECT(IRQ14A, 0x03c0), INTC_VECT(IRQ15A, 0x03e0), 98 INTC_VECT(IRQ14A, 0x03c0), INTC_VECT(IRQ15A, 0x03e0),
99 INTC_VECT(IRQ16A, 0x3200), INTC_VECT(IRQ17A, 0x3220), 99 INTC_VECT(IRQ16A, 0x3200), INTC_VECT(IRQ17A, 0x3220),
100 INTC_VECT(IRQ18A, 0x3240), INTC_VECT(IRQ19A, 0x3260), 100 INTC_VECT(IRQ18A, 0x3240), INTC_VECT(IRQ19A, 0x3260),
101 INTC_VECT(IRQ20A, 0x3280), INTC_VECT(IRQ31A, 0x32a0), 101 INTC_VECT(IRQ20A, 0x3280), INTC_VECT(IRQ21A, 0x32a0),
102 INTC_VECT(IRQ22A, 0x32c0), INTC_VECT(IRQ23A, 0x32e0), 102 INTC_VECT(IRQ22A, 0x32c0), INTC_VECT(IRQ23A, 0x32e0),
103 INTC_VECT(IRQ24A, 0x3300), INTC_VECT(IRQ25A, 0x3320), 103 INTC_VECT(IRQ24A, 0x3300), INTC_VECT(IRQ25A, 0x3320),
104 INTC_VECT(IRQ26A, 0x3340), INTC_VECT(IRQ27A, 0x3360), 104 INTC_VECT(IRQ26A, 0x3340), INTC_VECT(IRQ27A, 0x3360),
@@ -369,9 +369,13 @@ enum {
369 INTCS, 369 INTCS,
370 370
371 /* interrupt sources INTCS */ 371 /* interrupt sources INTCS */
372
373 /* IRQ0S - IRQ31S */
372 VEU_VEU0, VEU_VEU1, VEU_VEU2, VEU_VEU3, 374 VEU_VEU0, VEU_VEU1, VEU_VEU2, VEU_VEU3,
373 RTDMAC_1_DEI0, RTDMAC_1_DEI1, RTDMAC_1_DEI2, RTDMAC_1_DEI3, 375 RTDMAC_1_DEI0, RTDMAC_1_DEI1, RTDMAC_1_DEI2, RTDMAC_1_DEI3,
374 CEU, BEU_BEU0, BEU_BEU1, BEU_BEU2, 376 CEU, BEU_BEU0, BEU_BEU1, BEU_BEU2,
377 /* MFI */
378 /* BBIF2 */
375 VPU, 379 VPU,
376 TSIF1, 380 TSIF1,
377 _3DG_SGX530, 381 _3DG_SGX530,
@@ -379,13 +383,17 @@ enum {
379 IIC2_ALI2, IIC2_TACKI2, IIC2_WAITI2, IIC2_DTEI2, 383 IIC2_ALI2, IIC2_TACKI2, IIC2_WAITI2, IIC2_DTEI2,
380 IPMMU_IPMMUR, IPMMU_IPMMUR2, 384 IPMMU_IPMMUR, IPMMU_IPMMUR2,
381 RTDMAC_2_DEI4, RTDMAC_2_DEI5, RTDMAC_2_DADERR, 385 RTDMAC_2_DEI4, RTDMAC_2_DEI5, RTDMAC_2_DADERR,
386 /* KEYSC */
387 /* TTI20 */
382 MSIOF, 388 MSIOF,
383 IIC0_ALI0, IIC0_TACKI0, IIC0_WAITI0, IIC0_DTEI0, 389 IIC0_ALI0, IIC0_TACKI0, IIC0_WAITI0, IIC0_DTEI0,
384 TMU_TUNI0, TMU_TUNI1, TMU_TUNI2, 390 TMU_TUNI0, TMU_TUNI1, TMU_TUNI2,
385 CMT0, 391 CMT0,
386 TSIF0, 392 TSIF0,
393 /* CMT2 */
387 LMB, 394 LMB,
388 CTI, 395 CTI,
396 /* RWDT0 */
389 ICB, 397 ICB,
390 JPU_JPEG, 398 JPU_JPEG,
391 LCDC, 399 LCDC,
@@ -397,11 +405,17 @@ enum {
397 CSIRX, 405 CSIRX,
398 DSITX_DSITX0, 406 DSITX_DSITX0,
399 DSITX_DSITX1, 407 DSITX_DSITX1,
408 /* SPU2 */
409 /* FSI */
410 /* FMSI */
411 /* HDMI */
400 TMU1_TUNI0, TMU1_TUNI1, TMU1_TUNI2, 412 TMU1_TUNI0, TMU1_TUNI1, TMU1_TUNI2,
401 CMT4, 413 CMT4,
402 DSITX1_DSITX1_0, 414 DSITX1_DSITX1_0,
403 DSITX1_DSITX1_1, 415 DSITX1_DSITX1_1,
416 /* MFIS2 */
404 CPORTS2R, 417 CPORTS2R,
418 /* CEC */
405 JPU6E, 419 JPU6E,
406 420
407 /* interrupt groups INTCS */ 421 /* interrupt groups INTCS */
@@ -410,12 +424,15 @@ enum {
410}; 424};
411 425
412static struct intc_vect intcs_vectors[] = { 426static struct intc_vect intcs_vectors[] = {
427 /* IRQ0S - IRQ31S */
413 INTCS_VECT(VEU_VEU0, 0x700), INTCS_VECT(VEU_VEU1, 0x720), 428 INTCS_VECT(VEU_VEU0, 0x700), INTCS_VECT(VEU_VEU1, 0x720),
414 INTCS_VECT(VEU_VEU2, 0x740), INTCS_VECT(VEU_VEU3, 0x760), 429 INTCS_VECT(VEU_VEU2, 0x740), INTCS_VECT(VEU_VEU3, 0x760),
415 INTCS_VECT(RTDMAC_1_DEI0, 0x800), INTCS_VECT(RTDMAC_1_DEI1, 0x820), 430 INTCS_VECT(RTDMAC_1_DEI0, 0x800), INTCS_VECT(RTDMAC_1_DEI1, 0x820),
416 INTCS_VECT(RTDMAC_1_DEI2, 0x840), INTCS_VECT(RTDMAC_1_DEI3, 0x860), 431 INTCS_VECT(RTDMAC_1_DEI2, 0x840), INTCS_VECT(RTDMAC_1_DEI3, 0x860),
417 INTCS_VECT(CEU, 0x880), INTCS_VECT(BEU_BEU0, 0x8a0), 432 INTCS_VECT(CEU, 0x880), INTCS_VECT(BEU_BEU0, 0x8a0),
418 INTCS_VECT(BEU_BEU1, 0x8c0), INTCS_VECT(BEU_BEU2, 0x8e0), 433 INTCS_VECT(BEU_BEU1, 0x8c0), INTCS_VECT(BEU_BEU2, 0x8e0),
434 /* MFI */
435 /* BBIF2 */
419 INTCS_VECT(VPU, 0x980), 436 INTCS_VECT(VPU, 0x980),
420 INTCS_VECT(TSIF1, 0x9a0), 437 INTCS_VECT(TSIF1, 0x9a0),
421 INTCS_VECT(_3DG_SGX530, 0x9e0), 438 INTCS_VECT(_3DG_SGX530, 0x9e0),
@@ -425,14 +442,19 @@ static struct intc_vect intcs_vectors[] = {
425 INTCS_VECT(IPMMU_IPMMUR, 0xb00), INTCS_VECT(IPMMU_IPMMUR2, 0xb20), 442 INTCS_VECT(IPMMU_IPMMUR, 0xb00), INTCS_VECT(IPMMU_IPMMUR2, 0xb20),
426 INTCS_VECT(RTDMAC_2_DEI4, 0xb80), INTCS_VECT(RTDMAC_2_DEI5, 0xba0), 443 INTCS_VECT(RTDMAC_2_DEI4, 0xb80), INTCS_VECT(RTDMAC_2_DEI5, 0xba0),
427 INTCS_VECT(RTDMAC_2_DADERR, 0xbc0), 444 INTCS_VECT(RTDMAC_2_DADERR, 0xbc0),
445 /* KEYSC */
446 /* TTI20 */
447 INTCS_VECT(MSIOF, 0x0d20),
428 INTCS_VECT(IIC0_ALI0, 0xe00), INTCS_VECT(IIC0_TACKI0, 0xe20), 448 INTCS_VECT(IIC0_ALI0, 0xe00), INTCS_VECT(IIC0_TACKI0, 0xe20),
429 INTCS_VECT(IIC0_WAITI0, 0xe40), INTCS_VECT(IIC0_DTEI0, 0xe60), 449 INTCS_VECT(IIC0_WAITI0, 0xe40), INTCS_VECT(IIC0_DTEI0, 0xe60),
430 INTCS_VECT(TMU_TUNI0, 0xe80), INTCS_VECT(TMU_TUNI1, 0xea0), 450 INTCS_VECT(TMU_TUNI0, 0xe80), INTCS_VECT(TMU_TUNI1, 0xea0),
431 INTCS_VECT(TMU_TUNI2, 0xec0), 451 INTCS_VECT(TMU_TUNI2, 0xec0),
432 INTCS_VECT(CMT0, 0xf00), 452 INTCS_VECT(CMT0, 0xf00),
433 INTCS_VECT(TSIF0, 0xf20), 453 INTCS_VECT(TSIF0, 0xf20),
454 /* CMT2 */
434 INTCS_VECT(LMB, 0xf60), 455 INTCS_VECT(LMB, 0xf60),
435 INTCS_VECT(CTI, 0x400), 456 INTCS_VECT(CTI, 0x400),
457 /* RWDT0 */
436 INTCS_VECT(ICB, 0x480), 458 INTCS_VECT(ICB, 0x480),
437 INTCS_VECT(JPU_JPEG, 0x560), 459 INTCS_VECT(JPU_JPEG, 0x560),
438 INTCS_VECT(LCDC, 0x580), 460 INTCS_VECT(LCDC, 0x580),
@@ -446,12 +468,18 @@ static struct intc_vect intcs_vectors[] = {
446 INTCS_VECT(CSIRX, 0x17a0), 468 INTCS_VECT(CSIRX, 0x17a0),
447 INTCS_VECT(DSITX_DSITX0, 0x17c0), 469 INTCS_VECT(DSITX_DSITX0, 0x17c0),
448 INTCS_VECT(DSITX_DSITX1, 0x17e0), 470 INTCS_VECT(DSITX_DSITX1, 0x17e0),
471 /* SPU2 */
472 /* FSI */
473 /* FMSI */
474 /* HDMI */
449 INTCS_VECT(TMU1_TUNI0, 0x1900), INTCS_VECT(TMU1_TUNI1, 0x1920), 475 INTCS_VECT(TMU1_TUNI0, 0x1900), INTCS_VECT(TMU1_TUNI1, 0x1920),
450 INTCS_VECT(TMU1_TUNI2, 0x1940), 476 INTCS_VECT(TMU1_TUNI2, 0x1940),
451 INTCS_VECT(CMT4, 0x1980), 477 INTCS_VECT(CMT4, 0x1980),
452 INTCS_VECT(DSITX1_DSITX1_0, 0x19a0), 478 INTCS_VECT(DSITX1_DSITX1_0, 0x19a0),
453 INTCS_VECT(DSITX1_DSITX1_1, 0x19c0), 479 INTCS_VECT(DSITX1_DSITX1_1, 0x19c0),
480 /* MFIS2 */
454 INTCS_VECT(CPORTS2R, 0x1a20), 481 INTCS_VECT(CPORTS2R, 0x1a20),
482 /* CEC */
455 INTCS_VECT(JPU6E, 0x1a80), 483 INTCS_VECT(JPU6E, 0x1a80),
456 484
457 INTC_VECT(INTCS, 0xf80), 485 INTC_VECT(INTCS, 0xf80),
diff --git a/arch/arm/mach-shmobile/pfc-sh7372.c b/arch/arm/mach-shmobile/pfc-sh7372.c
index ec420353f8e3..9c265dae138a 100644
--- a/arch/arm/mach-shmobile/pfc-sh7372.c
+++ b/arch/arm/mach-shmobile/pfc-sh7372.c
@@ -166,12 +166,12 @@ enum {
166 MSIOF2_TSYNC_MARK, MSIOF2_TSCK_MARK, MSIOF2_RXD_MARK, 166 MSIOF2_TSYNC_MARK, MSIOF2_TSCK_MARK, MSIOF2_RXD_MARK,
167 MSIOF2_TXD_MARK, 167 MSIOF2_TXD_MARK,
168 168
169 /* MSIOF3 */ 169 /* BBIF1 */
170 BBIF1_RXD_MARK, BBIF1_TSYNC_MARK, BBIF1_TSCK_MARK, 170 BBIF1_RXD_MARK, BBIF1_TSYNC_MARK, BBIF1_TSCK_MARK,
171 BBIF1_TXD_MARK, BBIF1_RSCK_MARK, BBIF1_RSYNC_MARK, 171 BBIF1_TXD_MARK, BBIF1_RSCK_MARK, BBIF1_RSYNC_MARK,
172 BBIF1_FLOW_MARK, BB_RX_FLOW_N_MARK, 172 BBIF1_FLOW_MARK, BB_RX_FLOW_N_MARK,
173 173
174 /* MSIOF4 */ 174 /* BBIF2 */
175 BBIF2_TSCK1_MARK, BBIF2_TSYNC1_MARK, 175 BBIF2_TSCK1_MARK, BBIF2_TSYNC1_MARK,
176 BBIF2_TXD1_MARK, BBIF2_RXD_MARK, 176 BBIF2_TXD1_MARK, BBIF2_RXD_MARK,
177 177
@@ -976,12 +976,12 @@ static struct pinmux_gpio pinmux_gpios[] = {
976 GPIO_FN(MSIOF2_TSYNC), GPIO_FN(MSIOF2_TSCK), GPIO_FN(MSIOF2_RXD), 976 GPIO_FN(MSIOF2_TSYNC), GPIO_FN(MSIOF2_TSCK), GPIO_FN(MSIOF2_RXD),
977 GPIO_FN(MSIOF2_TXD), 977 GPIO_FN(MSIOF2_TXD),
978 978
979 /* MSIOF3 */ 979 /* BBIF1 */
980 GPIO_FN(BBIF1_RXD), GPIO_FN(BBIF1_TSYNC), GPIO_FN(BBIF1_TSCK), 980 GPIO_FN(BBIF1_RXD), GPIO_FN(BBIF1_TSYNC), GPIO_FN(BBIF1_TSCK),
981 GPIO_FN(BBIF1_TXD), GPIO_FN(BBIF1_RSCK), GPIO_FN(BBIF1_RSYNC), 981 GPIO_FN(BBIF1_TXD), GPIO_FN(BBIF1_RSCK), GPIO_FN(BBIF1_RSYNC),
982 GPIO_FN(BBIF1_FLOW), GPIO_FN(BB_RX_FLOW_N), 982 GPIO_FN(BBIF1_FLOW), GPIO_FN(BB_RX_FLOW_N),
983 983
984 /* MSIOF4 */ 984 /* BBIF2 */
985 GPIO_FN(BBIF2_TSCK1), GPIO_FN(BBIF2_TSYNC1), 985 GPIO_FN(BBIF2_TSCK1), GPIO_FN(BBIF2_TSYNC1),
986 GPIO_FN(BBIF2_TXD1), GPIO_FN(BBIF2_RXD), 986 GPIO_FN(BBIF2_TXD1), GPIO_FN(BBIF2_RXD),
987 987
diff --git a/arch/arm/mach-shmobile/setup-sh7367.c b/arch/arm/mach-shmobile/setup-sh7367.c
index 3148c11a550e..003008c18360 100644
--- a/arch/arm/mach-shmobile/setup-sh7367.c
+++ b/arch/arm/mach-shmobile/setup-sh7367.c
@@ -154,7 +154,6 @@ static struct sh_timer_config cmt10_platform_data = {
154 .name = "CMT10", 154 .name = "CMT10",
155 .channel_offset = 0x10, 155 .channel_offset = 0x10,
156 .timer_bit = 0, 156 .timer_bit = 0,
157 .clk = "r_clk",
158 .clockevent_rating = 125, 157 .clockevent_rating = 125,
159 .clocksource_rating = 125, 158 .clocksource_rating = 125,
160}; 159};
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index e26686c9d0b6..564a6d0be473 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -158,7 +158,6 @@ static struct sh_timer_config cmt10_platform_data = {
158 .name = "CMT10", 158 .name = "CMT10",
159 .channel_offset = 0x10, 159 .channel_offset = 0x10,
160 .timer_bit = 0, 160 .timer_bit = 0,
161 .clk = "cmt1",
162 .clockevent_rating = 125, 161 .clockevent_rating = 125,
163 .clocksource_rating = 125, 162 .clocksource_rating = 125,
164}; 163};
@@ -186,6 +185,67 @@ static struct platform_device cmt10_device = {
186 .num_resources = ARRAY_SIZE(cmt10_resources), 185 .num_resources = ARRAY_SIZE(cmt10_resources),
187}; 186};
188 187
188/* TMU */
189static struct sh_timer_config tmu00_platform_data = {
190 .name = "TMU00",
191 .channel_offset = 0x4,
192 .timer_bit = 0,
193 .clockevent_rating = 200,
194};
195
196static struct resource tmu00_resources[] = {
197 [0] = {
198 .name = "TMU00",
199 .start = 0xfff60008,
200 .end = 0xfff60013,
201 .flags = IORESOURCE_MEM,
202 },
203 [1] = {
204 .start = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
205 .flags = IORESOURCE_IRQ,
206 },
207};
208
209static struct platform_device tmu00_device = {
210 .name = "sh_tmu",
211 .id = 0,
212 .dev = {
213 .platform_data = &tmu00_platform_data,
214 },
215 .resource = tmu00_resources,
216 .num_resources = ARRAY_SIZE(tmu00_resources),
217};
218
219static struct sh_timer_config tmu01_platform_data = {
220 .name = "TMU01",
221 .channel_offset = 0x10,
222 .timer_bit = 1,
223 .clocksource_rating = 200,
224};
225
226static struct resource tmu01_resources[] = {
227 [0] = {
228 .name = "TMU01",
229 .start = 0xfff60014,
230 .end = 0xfff6001f,
231 .flags = IORESOURCE_MEM,
232 },
233 [1] = {
234 .start = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
235 .flags = IORESOURCE_IRQ,
236 },
237};
238
239static struct platform_device tmu01_device = {
240 .name = "sh_tmu",
241 .id = 1,
242 .dev = {
243 .platform_data = &tmu01_platform_data,
244 },
245 .resource = tmu01_resources,
246 .num_resources = ARRAY_SIZE(tmu01_resources),
247};
248
189/* I2C */ 249/* I2C */
190static struct resource iic0_resources[] = { 250static struct resource iic0_resources[] = {
191 [0] = { 251 [0] = {
@@ -419,14 +479,14 @@ static struct resource sh7372_dmae0_resources[] = {
419 }, 479 },
420 { 480 {
421 /* DMA error IRQ */ 481 /* DMA error IRQ */
422 .start = 246, 482 .start = evt2irq(0x20c0),
423 .end = 246, 483 .end = evt2irq(0x20c0),
424 .flags = IORESOURCE_IRQ, 484 .flags = IORESOURCE_IRQ,
425 }, 485 },
426 { 486 {
427 /* IRQ for channels 0-5 */ 487 /* IRQ for channels 0-5 */
428 .start = 240, 488 .start = evt2irq(0x2000),
429 .end = 245, 489 .end = evt2irq(0x20a0),
430 .flags = IORESOURCE_IRQ, 490 .flags = IORESOURCE_IRQ,
431 }, 491 },
432}; 492};
@@ -447,14 +507,14 @@ static struct resource sh7372_dmae1_resources[] = {
447 }, 507 },
448 { 508 {
449 /* DMA error IRQ */ 509 /* DMA error IRQ */
450 .start = 254, 510 .start = evt2irq(0x21c0),
451 .end = 254, 511 .end = evt2irq(0x21c0),
452 .flags = IORESOURCE_IRQ, 512 .flags = IORESOURCE_IRQ,
453 }, 513 },
454 { 514 {
455 /* IRQ for channels 0-5 */ 515 /* IRQ for channels 0-5 */
456 .start = 248, 516 .start = evt2irq(0x2100),
457 .end = 253, 517 .end = evt2irq(0x21a0),
458 .flags = IORESOURCE_IRQ, 518 .flags = IORESOURCE_IRQ,
459 }, 519 },
460}; 520};
@@ -475,14 +535,14 @@ static struct resource sh7372_dmae2_resources[] = {
475 }, 535 },
476 { 536 {
477 /* DMA error IRQ */ 537 /* DMA error IRQ */
478 .start = 262, 538 .start = evt2irq(0x22c0),
479 .end = 262, 539 .end = evt2irq(0x22c0),
480 .flags = IORESOURCE_IRQ, 540 .flags = IORESOURCE_IRQ,
481 }, 541 },
482 { 542 {
483 /* IRQ for channels 0-5 */ 543 /* IRQ for channels 0-5 */
484 .start = 256, 544 .start = evt2irq(0x2200),
485 .end = 261, 545 .end = evt2irq(0x22a0),
486 .flags = IORESOURCE_IRQ, 546 .flags = IORESOURCE_IRQ,
487 }, 547 },
488}; 548};
@@ -526,6 +586,11 @@ static struct platform_device *sh7372_early_devices[] __initdata = {
526 &scif5_device, 586 &scif5_device,
527 &scif6_device, 587 &scif6_device,
528 &cmt10_device, 588 &cmt10_device,
589 &tmu00_device,
590 &tmu01_device,
591};
592
593static struct platform_device *sh7372_late_devices[] __initdata = {
529 &iic0_device, 594 &iic0_device,
530 &iic1_device, 595 &iic1_device,
531 &dma0_device, 596 &dma0_device,
@@ -537,6 +602,9 @@ void __init sh7372_add_standard_devices(void)
537{ 602{
538 platform_add_devices(sh7372_early_devices, 603 platform_add_devices(sh7372_early_devices,
539 ARRAY_SIZE(sh7372_early_devices)); 604 ARRAY_SIZE(sh7372_early_devices));
605
606 platform_add_devices(sh7372_late_devices,
607 ARRAY_SIZE(sh7372_late_devices));
540} 608}
541 609
542void __init sh7372_add_early_devices(void) 610void __init sh7372_add_early_devices(void)
diff --git a/arch/arm/mach-shmobile/setup-sh7377.c b/arch/arm/mach-shmobile/setup-sh7377.c
index bb4adf17dbf4..575dbd6c2f1d 100644
--- a/arch/arm/mach-shmobile/setup-sh7377.c
+++ b/arch/arm/mach-shmobile/setup-sh7377.c
@@ -172,7 +172,6 @@ static struct sh_timer_config cmt10_platform_data = {
172 .name = "CMT10", 172 .name = "CMT10",
173 .channel_offset = 0x10, 173 .channel_offset = 0x10,
174 .timer_bit = 0, 174 .timer_bit = 0,
175 .clk = "r_clk",
176 .clockevent_rating = 125, 175 .clockevent_rating = 125,
177 .clocksource_rating = 125, 176 .clocksource_rating = 125,
178}; 177};
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index a57713c1954a..acd9552f8ada 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -16,6 +16,10 @@ config ARCH_TEGRA_2x_SOC
16 16
17endchoice 17endchoice
18 18
19config TEGRA_PCI
20 bool "PCI Express support"
21 select PCI
22
19comment "Tegra board type" 23comment "Tegra board type"
20 24
21config MACH_HARMONY 25config MACH_HARMONY
@@ -47,4 +51,11 @@ config TEGRA_DEBUG_UARTE
47 51
48endchoice 52endchoice
49 53
54config TEGRA_SYSTEM_DMA
55 bool "Enable system DMA driver for NVIDIA Tegra SoCs"
56 default y
57 help
58 Adds system DMA functionality for NVIDIA Tegra SoCs, used by
59 several Tegra device drivers
60
50endif 61endif
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 51e9370eed99..cdbc68e4c0ca 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -1,14 +1,21 @@
1obj-y += common.o 1obj-y += common.o
2obj-y += io.o 2obj-y += io.o
3obj-y += irq.o 3obj-y += irq.o legacy_irq.o
4obj-y += clock.o 4obj-y += clock.o
5obj-y += timer.o 5obj-y += timer.o
6obj-y += gpio.o 6obj-y += gpio.o
7obj-y += pinmux.o 7obj-y += pinmux.o
8obj-y += fuse.o
8obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clock.o 9obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clock.o
9obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o 10obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o
11obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_dvfs.o
12obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-t2-tables.o
10obj-$(CONFIG_SMP) += platsmp.o localtimer.o headsmp.o 13obj-$(CONFIG_SMP) += platsmp.o localtimer.o headsmp.o
11obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 14obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
15obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o
16obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o
17obj-$(CONFIG_TEGRA_PCI) += pcie.o
12 18
13obj-${CONFIG_MACH_HARMONY} += board-harmony.o 19obj-${CONFIG_MACH_HARMONY} += board-harmony.o
14obj-${CONFIG_MACH_HARMONY} += board-harmony-pinmux.o 20obj-${CONFIG_MACH_HARMONY} += board-harmony-pinmux.o
21obj-${CONFIG_MACH_HARMONY} += board-harmony-pcie.o
diff --git a/arch/arm/mach-tegra/board-harmony-pcie.c b/arch/arm/mach-tegra/board-harmony-pcie.c
new file mode 100644
index 000000000000..f7e7d4514b6a
--- /dev/null
+++ b/arch/arm/mach-tegra/board-harmony-pcie.c
@@ -0,0 +1,57 @@
1/*
2 * arch/arm/mach-tegra/board-harmony-pcie.c
3 *
4 * Copyright (C) 2010 CompuLab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
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#include <linux/kernel.h>
19#include <linux/gpio.h>
20#include <linux/err.h>
21#include <linux/regulator/consumer.h>
22
23#include <asm/mach-types.h>
24
25#include <mach/pinmux.h>
26#include "board.h"
27
28#ifdef CONFIG_TEGRA_PCI
29
30static int __init harmony_pcie_init(void)
31{
32 int err;
33
34 if (!machine_is_harmony())
35 return 0;
36
37 tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_NORMAL);
38 tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_NORMAL);
39 tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_NORMAL);
40
41 err = tegra_pcie_init(true, true);
42 if (err)
43 goto err_pcie;
44
45 return 0;
46
47err_pcie:
48 tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_TRISTATE);
49 tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_TRISTATE);
50 tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_TRISTATE);
51
52 return err;
53}
54
55subsys_initcall(harmony_pcie_init);
56
57#endif
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h
index 3d06354136f2..0de565ca37c5 100644
--- a/arch/arm/mach-tegra/board.h
+++ b/arch/arm/mach-tegra/board.h
@@ -27,6 +27,7 @@ void __init tegra_common_init(void);
27void __init tegra_map_common_io(void); 27void __init tegra_map_common_io(void);
28void __init tegra_init_irq(void); 28void __init tegra_init_irq(void);
29void __init tegra_init_clock(void); 29void __init tegra_init_clock(void);
30int __init tegra_pcie_init(bool init_port0, bool init_port1);
30 31
31extern struct sys_timer tegra_timer; 32extern struct sys_timer tegra_timer;
32#endif 33#endif
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 03ad578349b9..ae19f95585be 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -24,13 +24,80 @@
24#include <linux/debugfs.h> 24#include <linux/debugfs.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/regulator/consumer.h>
27#include <asm/clkdev.h> 28#include <asm/clkdev.h>
28 29
29#include "clock.h" 30#include "clock.h"
31#include "board.h"
32#include "fuse.h"
30 33
31static LIST_HEAD(clocks); 34static LIST_HEAD(clocks);
32 35
33static DEFINE_SPINLOCK(clock_lock); 36static DEFINE_SPINLOCK(clock_lock);
37static DEFINE_MUTEX(dvfs_lock);
38
39static int clk_is_dvfs(struct clk *c)
40{
41 return (c->dvfs != NULL);
42};
43
44static int dvfs_set_rate(struct dvfs *d, unsigned long rate)
45{
46 struct dvfs_table *t;
47
48 if (d->table == NULL)
49 return -ENODEV;
50
51 for (t = d->table; t->rate != 0; t++) {
52 if (rate <= t->rate) {
53 if (!d->reg)
54 return 0;
55
56 return regulator_set_voltage(d->reg,
57 t->millivolts * 1000,
58 d->max_millivolts * 1000);
59 }
60 }
61
62 return -EINVAL;
63}
64
65static void dvfs_init(struct clk *c)
66{
67 int process_id;
68 int i;
69 struct dvfs_table *table;
70
71 process_id = c->dvfs->cpu ? tegra_core_process_id() :
72 tegra_cpu_process_id();
73
74 for (i = 0; i < c->dvfs->process_id_table_length; i++)
75 if (process_id == c->dvfs->process_id_table[i].process_id)
76 c->dvfs->table = c->dvfs->process_id_table[i].table;
77
78 if (c->dvfs->table == NULL) {
79 pr_err("Failed to find dvfs table for clock %s process %d\n",
80 c->name, process_id);
81 return;
82 }
83
84 c->dvfs->max_millivolts = 0;
85 for (table = c->dvfs->table; table->rate != 0; table++)
86 if (c->dvfs->max_millivolts < table->millivolts)
87 c->dvfs->max_millivolts = table->millivolts;
88
89 c->dvfs->reg = regulator_get(NULL, c->dvfs->reg_id);
90
91 if (IS_ERR(c->dvfs->reg)) {
92 pr_err("Failed to get regulator %s for clock %s\n",
93 c->dvfs->reg_id, c->name);
94 c->dvfs->reg = NULL;
95 return;
96 }
97
98 if (c->refcnt > 0)
99 dvfs_set_rate(c->dvfs, c->rate);
100}
34 101
35struct clk *tegra_get_clock_by_name(const char *name) 102struct clk *tegra_get_clock_by_name(const char *name)
36{ 103{
@@ -48,14 +115,31 @@ struct clk *tegra_get_clock_by_name(const char *name)
48 return ret; 115 return ret;
49} 116}
50 117
118static void clk_recalculate_rate(struct clk *c)
119{
120 u64 rate;
121
122 if (!c->parent)
123 return;
124
125 rate = c->parent->rate;
126
127 if (c->mul != 0 && c->div != 0) {
128 rate = rate * c->mul;
129 do_div(rate, c->div);
130 }
131
132 if (rate > c->max_rate)
133 pr_warn("clocks: Set clock %s to rate %llu, max is %lu\n",
134 c->name, rate, c->max_rate);
135
136 c->rate = rate;
137}
138
51int clk_reparent(struct clk *c, struct clk *parent) 139int clk_reparent(struct clk *c, struct clk *parent)
52{ 140{
53 pr_debug("%s: %s\n", __func__, c->name); 141 pr_debug("%s: %s\n", __func__, c->name);
54 if (c->refcnt && c->parent)
55 clk_disable_locked(c->parent);
56 c->parent = parent; 142 c->parent = parent;
57 if (c->refcnt && c->parent)
58 clk_enable_locked(c->parent);
59 list_del(&c->sibling); 143 list_del(&c->sibling);
60 list_add_tail(&c->sibling, &parent->children); 144 list_add_tail(&c->sibling, &parent->children);
61 return 0; 145 return 0;
@@ -67,8 +151,7 @@ static void propagate_rate(struct clk *c)
67 pr_debug("%s: %s\n", __func__, c->name); 151 pr_debug("%s: %s\n", __func__, c->name);
68 list_for_each_entry(clkp, &c->children, sibling) { 152 list_for_each_entry(clkp, &c->children, sibling) {
69 pr_debug(" %s\n", clkp->name); 153 pr_debug(" %s\n", clkp->name);
70 if (clkp->ops->recalculate_rate) 154 clk_recalculate_rate(clkp);
71 clkp->ops->recalculate_rate(clkp);
72 propagate_rate(clkp); 155 propagate_rate(clkp);
73 } 156 }
74} 157}
@@ -77,6 +160,8 @@ void clk_init(struct clk *c)
77{ 160{
78 unsigned long flags; 161 unsigned long flags;
79 162
163 pr_debug("%s: %s\n", __func__, c->name);
164
80 spin_lock_irqsave(&clock_lock, flags); 165 spin_lock_irqsave(&clock_lock, flags);
81 166
82 INIT_LIST_HEAD(&c->children); 167 INIT_LIST_HEAD(&c->children);
@@ -85,6 +170,8 @@ void clk_init(struct clk *c)
85 if (c->ops && c->ops->init) 170 if (c->ops && c->ops->init)
86 c->ops->init(c); 171 c->ops->init(c);
87 172
173 clk_recalculate_rate(c);
174
88 list_add(&c->node, &clocks); 175 list_add(&c->node, &clocks);
89 176
90 if (c->parent) 177 if (c->parent)
@@ -122,13 +209,38 @@ int clk_enable_locked(struct clk *c)
122 return 0; 209 return 0;
123} 210}
124 211
212int clk_enable_cansleep(struct clk *c)
213{
214 int ret;
215 unsigned long flags;
216
217 mutex_lock(&dvfs_lock);
218
219 if (clk_is_dvfs(c) && c->refcnt > 0)
220 dvfs_set_rate(c->dvfs, c->rate);
221
222 spin_lock_irqsave(&clock_lock, flags);
223 ret = clk_enable_locked(c);
224 spin_unlock_irqrestore(&clock_lock, flags);
225
226 mutex_unlock(&dvfs_lock);
227
228 return ret;
229}
230EXPORT_SYMBOL(clk_enable_cansleep);
231
125int clk_enable(struct clk *c) 232int clk_enable(struct clk *c)
126{ 233{
127 int ret; 234 int ret;
128 unsigned long flags; 235 unsigned long flags;
236
237 if (clk_is_dvfs(c))
238 BUG();
239
129 spin_lock_irqsave(&clock_lock, flags); 240 spin_lock_irqsave(&clock_lock, flags);
130 ret = clk_enable_locked(c); 241 ret = clk_enable_locked(c);
131 spin_unlock_irqrestore(&clock_lock, flags); 242 spin_unlock_irqrestore(&clock_lock, flags);
243
132 return ret; 244 return ret;
133} 245}
134EXPORT_SYMBOL(clk_enable); 246EXPORT_SYMBOL(clk_enable);
@@ -152,9 +264,30 @@ void clk_disable_locked(struct clk *c)
152 c->refcnt--; 264 c->refcnt--;
153} 265}
154 266
267void clk_disable_cansleep(struct clk *c)
268{
269 unsigned long flags;
270
271 mutex_lock(&dvfs_lock);
272
273 spin_lock_irqsave(&clock_lock, flags);
274 clk_disable_locked(c);
275 spin_unlock_irqrestore(&clock_lock, flags);
276
277 if (clk_is_dvfs(c) && c->refcnt == 0)
278 dvfs_set_rate(c->dvfs, c->rate);
279
280 mutex_unlock(&dvfs_lock);
281}
282EXPORT_SYMBOL(clk_disable_cansleep);
283
155void clk_disable(struct clk *c) 284void clk_disable(struct clk *c)
156{ 285{
157 unsigned long flags; 286 unsigned long flags;
287
288 if (clk_is_dvfs(c))
289 BUG();
290
158 spin_lock_irqsave(&clock_lock, flags); 291 spin_lock_irqsave(&clock_lock, flags);
159 clk_disable_locked(c); 292 clk_disable_locked(c);
160 spin_unlock_irqrestore(&clock_lock, flags); 293 spin_unlock_irqrestore(&clock_lock, flags);
@@ -175,6 +308,8 @@ int clk_set_parent_locked(struct clk *c, struct clk *parent)
175 if (ret) 308 if (ret)
176 return ret; 309 return ret;
177 310
311 clk_recalculate_rate(c);
312
178 propagate_rate(c); 313 propagate_rate(c);
179 314
180 return 0; 315 return 0;
@@ -197,22 +332,69 @@ struct clk *clk_get_parent(struct clk *c)
197} 332}
198EXPORT_SYMBOL(clk_get_parent); 333EXPORT_SYMBOL(clk_get_parent);
199 334
200int clk_set_rate(struct clk *c, unsigned long rate) 335int clk_set_rate_locked(struct clk *c, unsigned long rate)
336{
337 int ret;
338
339 if (rate > c->max_rate)
340 rate = c->max_rate;
341
342 if (!c->ops || !c->ops->set_rate)
343 return -ENOSYS;
344
345 ret = c->ops->set_rate(c, rate);
346
347 if (ret)
348 return ret;
349
350 clk_recalculate_rate(c);
351
352 propagate_rate(c);
353
354 return 0;
355}
356
357int clk_set_rate_cansleep(struct clk *c, unsigned long rate)
201{ 358{
202 int ret = 0; 359 int ret = 0;
203 unsigned long flags; 360 unsigned long flags;
204 361
362 pr_debug("%s: %s\n", __func__, c->name);
363
364 mutex_lock(&dvfs_lock);
365
366 if (rate > c->rate)
367 ret = dvfs_set_rate(c->dvfs, rate);
368 if (ret)
369 goto out;
370
205 spin_lock_irqsave(&clock_lock, flags); 371 spin_lock_irqsave(&clock_lock, flags);
372 ret = clk_set_rate_locked(c, rate);
373 spin_unlock_irqrestore(&clock_lock, flags);
206 374
207 pr_debug("%s: %s\n", __func__, c->name); 375 if (ret)
376 goto out;
208 377
209 if (c->ops && c->ops->set_rate) 378 ret = dvfs_set_rate(c->dvfs, rate);
210 ret = c->ops->set_rate(c, rate);
211 else
212 ret = -ENOSYS;
213 379
214 propagate_rate(c); 380out:
381 mutex_unlock(&dvfs_lock);
382 return ret;
383}
384EXPORT_SYMBOL(clk_set_rate_cansleep);
385
386int clk_set_rate(struct clk *c, unsigned long rate)
387{
388 int ret = 0;
389 unsigned long flags;
390
391 pr_debug("%s: %s\n", __func__, c->name);
392
393 if (clk_is_dvfs(c))
394 BUG();
215 395
396 spin_lock_irqsave(&clock_lock, flags);
397 ret = clk_set_rate_locked(c, rate);
216 spin_unlock_irqrestore(&clock_lock, flags); 398 spin_unlock_irqrestore(&clock_lock, flags);
217 399
218 return ret; 400 return ret;
@@ -235,6 +417,20 @@ unsigned long clk_get_rate(struct clk *c)
235} 417}
236EXPORT_SYMBOL(clk_get_rate); 418EXPORT_SYMBOL(clk_get_rate);
237 419
420long clk_round_rate(struct clk *c, unsigned long rate)
421{
422 pr_debug("%s: %s\n", __func__, c->name);
423
424 if (!c->ops || !c->ops->round_rate)
425 return -ENOSYS;
426
427 if (rate > c->max_rate)
428 rate = c->max_rate;
429
430 return c->ops->round_rate(c, rate);
431}
432EXPORT_SYMBOL(clk_round_rate);
433
238static int tegra_clk_init_one_from_table(struct tegra_clk_init_table *table) 434static int tegra_clk_init_one_from_table(struct tegra_clk_init_table *table)
239{ 435{
240 struct clk *c; 436 struct clk *c;
@@ -308,13 +504,28 @@ void tegra_periph_reset_assert(struct clk *c)
308} 504}
309EXPORT_SYMBOL(tegra_periph_reset_assert); 505EXPORT_SYMBOL(tegra_periph_reset_assert);
310 506
311int __init tegra_init_clock(void) 507void __init tegra_init_clock(void)
312{ 508{
313 tegra2_init_clocks(); 509 tegra2_init_clocks();
510}
511
512int __init tegra_init_dvfs(void)
513{
514 struct clk *c, *safe;
515
516 mutex_lock(&dvfs_lock);
517
518 list_for_each_entry_safe(c, safe, &clocks, node)
519 if (c->dvfs)
520 dvfs_init(c);
521
522 mutex_unlock(&dvfs_lock);
314 523
315 return 0; 524 return 0;
316} 525}
317 526
527late_initcall(tegra_init_dvfs);
528
318#ifdef CONFIG_DEBUG_FS 529#ifdef CONFIG_DEBUG_FS
319static struct dentry *clk_debugfs_root; 530static struct dentry *clk_debugfs_root;
320 531
@@ -324,7 +535,7 @@ static void clock_tree_show_one(struct seq_file *s, struct clk *c, int level)
324 struct clk *child; 535 struct clk *child;
325 struct clk *safe; 536 struct clk *safe;
326 const char *state = "uninit"; 537 const char *state = "uninit";
327 char div[5] = {0}; 538 char div[8] = {0};
328 539
329 if (c->state == ON) 540 if (c->state == ON)
330 state = "on"; 541 state = "on";
@@ -332,16 +543,26 @@ static void clock_tree_show_one(struct seq_file *s, struct clk *c, int level)
332 state = "off"; 543 state = "off";
333 544
334 if (c->mul != 0 && c->div != 0) { 545 if (c->mul != 0 && c->div != 0) {
335 BUG_ON(c->mul > 2); 546 if (c->mul > c->div) {
336 if (c->mul > c->div) 547 int mul = c->mul / c->div;
337 snprintf(div, sizeof(div), "x%d", c->mul / c->div); 548 int mul2 = (c->mul * 10 / c->div) % 10;
338 else 549 int mul3 = (c->mul * 10) % c->div;
550 if (mul2 == 0 && mul3 == 0)
551 snprintf(div, sizeof(div), "x%d", mul);
552 else if (mul3 == 0)
553 snprintf(div, sizeof(div), "x%d.%d", mul, mul2);
554 else
555 snprintf(div, sizeof(div), "x%d.%d..", mul, mul2);
556 } else {
339 snprintf(div, sizeof(div), "%d%s", c->div / c->mul, 557 snprintf(div, sizeof(div), "%d%s", c->div / c->mul,
340 (c->div % c->mul) ? ".5" : ""); 558 (c->div % c->mul) ? ".5" : "");
559 }
341 } 560 }
342 561
343 seq_printf(s, "%*s%-*s %-6s %-3d %-5s %-10lu\n", 562 seq_printf(s, "%*s%c%c%-*s %-6s %-3d %-8s %-10lu\n",
344 level * 3 + 1, c->set ? "" : "*", 563 level * 3 + 1, "",
564 c->rate > c->max_rate ? '!' : ' ',
565 !c->set ? '*' : ' ',
345 30 - level * 3, c->name, 566 30 - level * 3, c->name,
346 state, c->refcnt, div, c->rate); 567 state, c->refcnt, div, c->rate);
347 list_for_each_entry_safe(child, safe, &c->children, sibling) { 568 list_for_each_entry_safe(child, safe, &c->children, sibling) {
@@ -353,8 +574,8 @@ static int clock_tree_show(struct seq_file *s, void *data)
353{ 574{
354 struct clk *c; 575 struct clk *c;
355 unsigned long flags; 576 unsigned long flags;
356 seq_printf(s, " clock state ref div rate \n"); 577 seq_printf(s, " clock state ref div rate\n");
357 seq_printf(s, "-----------------------------------------------------------\n"); 578 seq_printf(s, "--------------------------------------------------------------\n");
358 spin_lock_irqsave(&clock_lock, flags); 579 spin_lock_irqsave(&clock_lock, flags);
359 list_for_each_entry(c, &clocks, node) 580 list_for_each_entry(c, &clocks, node)
360 if (c->parent == NULL) 581 if (c->parent == NULL)
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index af7c70e2a3ba..94fd859770f1 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -27,18 +27,43 @@
27#define DIV_U71 (1 << 1) 27#define DIV_U71 (1 << 1)
28#define DIV_U71_FIXED (1 << 2) 28#define DIV_U71_FIXED (1 << 2)
29#define DIV_2 (1 << 3) 29#define DIV_2 (1 << 3)
30#define PLL_FIXED (1 << 4) 30#define DIV_U16 (1 << 4)
31#define PLL_HAS_CPCON (1 << 5) 31#define PLL_FIXED (1 << 5)
32#define MUX (1 << 6) 32#define PLL_HAS_CPCON (1 << 6)
33#define PLLD (1 << 7) 33#define MUX (1 << 7)
34#define PERIPH_NO_RESET (1 << 8) 34#define PLLD (1 << 8)
35#define PERIPH_NO_ENB (1 << 9) 35#define PERIPH_NO_RESET (1 << 9)
36#define PERIPH_EMC_ENB (1 << 10) 36#define PERIPH_NO_ENB (1 << 10)
37#define PERIPH_MANUAL_RESET (1 << 11) 37#define PERIPH_EMC_ENB (1 << 11)
38#define PLL_ALT_MISC_REG (1 << 12) 38#define PERIPH_MANUAL_RESET (1 << 12)
39#define PLL_ALT_MISC_REG (1 << 13)
40#define PLLU (1 << 14)
39#define ENABLE_ON_INIT (1 << 28) 41#define ENABLE_ON_INIT (1 << 28)
40 42
41struct clk; 43struct clk;
44struct regulator;
45
46struct dvfs_table {
47 unsigned long rate;
48 int millivolts;
49};
50
51struct dvfs_process_id_table {
52 int process_id;
53 struct dvfs_table *table;
54};
55
56
57struct dvfs {
58 struct regulator *reg;
59 struct dvfs_table *table;
60 int max_millivolts;
61
62 int process_id_table_length;
63 const char *reg_id;
64 bool cpu;
65 struct dvfs_process_id_table process_id_table[];
66};
42 67
43struct clk_mux_sel { 68struct clk_mux_sel {
44 struct clk *input; 69 struct clk *input;
@@ -58,12 +83,9 @@ struct clk_ops {
58 void (*init)(struct clk *); 83 void (*init)(struct clk *);
59 int (*enable)(struct clk *); 84 int (*enable)(struct clk *);
60 void (*disable)(struct clk *); 85 void (*disable)(struct clk *);
61 void (*recalc)(struct clk *);
62 int (*set_parent)(struct clk *, struct clk *); 86 int (*set_parent)(struct clk *, struct clk *);
63 int (*set_rate)(struct clk *, unsigned long); 87 int (*set_rate)(struct clk *, unsigned long);
64 unsigned long (*get_rate)(struct clk *);
65 long (*round_rate)(struct clk *, unsigned long); 88 long (*round_rate)(struct clk *, unsigned long);
66 unsigned long (*recalculate_rate)(struct clk *);
67}; 89};
68 90
69enum clk_state { 91enum clk_state {
@@ -85,6 +107,7 @@ struct clk {
85 struct clk *parent; 107 struct clk *parent;
86 struct clk_lookup lookup; 108 struct clk_lookup lookup;
87 unsigned long rate; 109 unsigned long rate;
110 unsigned long max_rate;
88 u32 flags; 111 u32 flags;
89 u32 refcnt; 112 u32 refcnt;
90 const char *name; 113 const char *name;
@@ -103,10 +126,6 @@ struct clk {
103 unsigned long cf_max; 126 unsigned long cf_max;
104 unsigned long vco_min; 127 unsigned long vco_min;
105 unsigned long vco_max; 128 unsigned long vco_max;
106 u32 m;
107 u32 n;
108 u32 p;
109 u32 cpcon;
110 const struct clk_pll_table *pll_table; 129 const struct clk_pll_table *pll_table;
111 130
112 /* DIV */ 131 /* DIV */
@@ -117,6 +136,12 @@ struct clk {
117 const struct clk_mux_sel *inputs; 136 const struct clk_mux_sel *inputs;
118 u32 sel; 137 u32 sel;
119 u32 reg_mask; 138 u32 reg_mask;
139
140 /* Virtual cpu clock */
141 struct clk *main;
142 struct clk *backup;
143
144 struct dvfs *dvfs;
120}; 145};
121 146
122 147
@@ -141,6 +166,7 @@ unsigned long clk_measure_input_freq(void);
141void clk_disable_locked(struct clk *c); 166void clk_disable_locked(struct clk *c);
142int clk_enable_locked(struct clk *c); 167int clk_enable_locked(struct clk *c);
143int clk_set_parent_locked(struct clk *c, struct clk *parent); 168int clk_set_parent_locked(struct clk *c, struct clk *parent);
169int clk_set_rate_locked(struct clk *c, unsigned long rate);
144int clk_reparent(struct clk *c, struct clk *parent); 170int clk_reparent(struct clk *c, struct clk *parent);
145void tegra_clk_init_from_table(struct tegra_clk_init_table *table); 171void tegra_clk_init_from_table(struct tegra_clk_init_table *table);
146 172
diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c
index 039a514b61ef..7c91e2b9d643 100644
--- a/arch/arm/mach-tegra/common.c
+++ b/arch/arm/mach-tegra/common.c
@@ -19,13 +19,17 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/clk.h>
23#include <linux/delay.h>
22 24
23#include <asm/hardware/cache-l2x0.h> 25#include <asm/hardware/cache-l2x0.h>
24 26
25#include <mach/iomap.h> 27#include <mach/iomap.h>
28#include <mach/dma.h>
26 29
27#include "board.h" 30#include "board.h"
28#include "clock.h" 31#include "clock.h"
32#include "fuse.h"
29 33
30static __initdata struct tegra_clk_init_table common_clk_init_table[] = { 34static __initdata struct tegra_clk_init_table common_clk_init_table[] = {
31 /* name parent rate enabled */ 35 /* name parent rate enabled */
@@ -35,8 +39,8 @@ static __initdata struct tegra_clk_init_table common_clk_init_table[] = {
35 { "pll_p_out2", "pll_p", 48000000, true }, 39 { "pll_p_out2", "pll_p", 48000000, true },
36 { "pll_p_out3", "pll_p", 72000000, true }, 40 { "pll_p_out3", "pll_p", 72000000, true },
37 { "pll_p_out4", "pll_p", 108000000, true }, 41 { "pll_p_out4", "pll_p", 108000000, true },
38 { "sys", "pll_p_out4", 108000000, true }, 42 { "sclk", "pll_p_out4", 108000000, true },
39 { "hclk", "sys", 108000000, true }, 43 { "hclk", "sclk", 108000000, true },
40 { "pclk", "hclk", 54000000, true }, 44 { "pclk", "hclk", 54000000, true },
41 { NULL, NULL, 0, 0}, 45 { NULL, NULL, 0, 0},
42}; 46};
@@ -51,11 +55,16 @@ void __init tegra_init_cache(void)
51 55
52 l2x0_init(p, 0x6C080001, 0x8200c3fe); 56 l2x0_init(p, 0x6C080001, 0x8200c3fe);
53#endif 57#endif
58
54} 59}
55 60
56void __init tegra_common_init(void) 61void __init tegra_common_init(void)
57{ 62{
63 tegra_init_fuse();
58 tegra_init_clock(); 64 tegra_init_clock();
59 tegra_clk_init_from_table(common_clk_init_table); 65 tegra_clk_init_from_table(common_clk_init_table);
60 tegra_init_cache(); 66 tegra_init_cache();
67#ifdef CONFIG_TEGRA_SYSTEM_DMA
68 tegra_dma_init();
69#endif
61} 70}
diff --git a/arch/arm/mach-tegra/cpu-tegra.c b/arch/arm/mach-tegra/cpu-tegra.c
new file mode 100644
index 000000000000..fea5719c7072
--- /dev/null
+++ b/arch/arm/mach-tegra/cpu-tegra.c
@@ -0,0 +1,185 @@
1/*
2 * arch/arm/mach-tegra/cpu-tegra.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * Author:
7 * Colin Cross <ccross@google.com>
8 * Based on arch/arm/plat-omap/cpu-omap.c, (C) 2005 Nokia Corporation
9 *
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/sched.h>
25#include <linux/cpufreq.h>
26#include <linux/delay.h>
27#include <linux/init.h>
28#include <linux/err.h>
29#include <linux/clk.h>
30#include <linux/io.h>
31
32#include <asm/system.h>
33
34#include <mach/hardware.h>
35#include <mach/clk.h>
36
37/* Frequency table index must be sequential starting at 0 */
38static struct cpufreq_frequency_table freq_table[] = {
39 { 0, 312000 },
40 { 1, 456000 },
41 { 2, 608000 },
42 { 3, 760000 },
43 { 4, 816000 },
44 { 5, 912000 },
45 { 6, 1000000 },
46 { 7, CPUFREQ_TABLE_END },
47};
48
49#define NUM_CPUS 2
50
51static struct clk *cpu_clk;
52
53static unsigned long target_cpu_speed[NUM_CPUS];
54
55int tegra_verify_speed(struct cpufreq_policy *policy)
56{
57 return cpufreq_frequency_table_verify(policy, freq_table);
58}
59
60unsigned int tegra_getspeed(unsigned int cpu)
61{
62 unsigned long rate;
63
64 if (cpu >= NUM_CPUS)
65 return 0;
66
67 rate = clk_get_rate(cpu_clk) / 1000;
68 return rate;
69}
70
71static int tegra_update_cpu_speed(void)
72{
73 int i;
74 unsigned long rate = 0;
75 int ret = 0;
76 struct cpufreq_freqs freqs;
77
78 for_each_online_cpu(i)
79 rate = max(rate, target_cpu_speed[i]);
80
81 freqs.old = tegra_getspeed(0);
82 freqs.new = rate;
83
84 if (freqs.old == freqs.new)
85 return ret;
86
87 for_each_online_cpu(freqs.cpu)
88 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
89
90#ifdef CONFIG_CPU_FREQ_DEBUG
91 printk(KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n",
92 freqs.old, freqs.new);
93#endif
94
95 ret = clk_set_rate_cansleep(cpu_clk, freqs.new * 1000);
96 if (ret) {
97 pr_err("cpu-tegra: Failed to set cpu frequency to %d kHz\n",
98 freqs.new);
99 return ret;
100 }
101
102 for_each_online_cpu(freqs.cpu)
103 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
104
105 return 0;
106}
107
108static int tegra_target(struct cpufreq_policy *policy,
109 unsigned int target_freq,
110 unsigned int relation)
111{
112 int idx;
113 unsigned int freq;
114
115 cpufreq_frequency_table_target(policy, freq_table, target_freq,
116 relation, &idx);
117
118 freq = freq_table[idx].frequency;
119
120 target_cpu_speed[policy->cpu] = freq;
121
122 return tegra_update_cpu_speed();
123}
124
125static int tegra_cpu_init(struct cpufreq_policy *policy)
126{
127 if (policy->cpu >= NUM_CPUS)
128 return -EINVAL;
129
130 cpu_clk = clk_get_sys(NULL, "cpu");
131 if (IS_ERR(cpu_clk))
132 return PTR_ERR(cpu_clk);
133
134 cpufreq_frequency_table_cpuinfo(policy, freq_table);
135 cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
136 policy->cur = tegra_getspeed(policy->cpu);
137 target_cpu_speed[policy->cpu] = policy->cur;
138
139 /* FIXME: what's the actual transition time? */
140 policy->cpuinfo.transition_latency = 300 * 1000;
141
142 policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
143 cpumask_copy(policy->related_cpus, cpu_possible_mask);
144
145 return 0;
146}
147
148static int tegra_cpu_exit(struct cpufreq_policy *policy)
149{
150 cpufreq_frequency_table_cpuinfo(policy, freq_table);
151 clk_put(cpu_clk);
152 return 0;
153}
154
155static struct freq_attr *tegra_cpufreq_attr[] = {
156 &cpufreq_freq_attr_scaling_available_freqs,
157 NULL,
158};
159
160static struct cpufreq_driver tegra_cpufreq_driver = {
161 .verify = tegra_verify_speed,
162 .target = tegra_target,
163 .get = tegra_getspeed,
164 .init = tegra_cpu_init,
165 .exit = tegra_cpu_exit,
166 .name = "tegra",
167 .attr = tegra_cpufreq_attr,
168};
169
170static int __init tegra_cpufreq_init(void)
171{
172 return cpufreq_register_driver(&tegra_cpufreq_driver);
173}
174
175static void __exit tegra_cpufreq_exit(void)
176{
177 cpufreq_unregister_driver(&tegra_cpufreq_driver);
178}
179
180
181MODULE_AUTHOR("Colin Cross <ccross@android.com>");
182MODULE_DESCRIPTION("cpufreq driver for Nvidia Tegra2");
183MODULE_LICENSE("GPL");
184module_init(tegra_cpufreq_init);
185module_exit(tegra_cpufreq_exit);
diff --git a/arch/arm/mach-tegra/dma.c b/arch/arm/mach-tegra/dma.c
new file mode 100644
index 000000000000..edda6ec5e925
--- /dev/null
+++ b/arch/arm/mach-tegra/dma.c
@@ -0,0 +1,752 @@
1/*
2 * arch/arm/mach-tegra/dma.c
3 *
4 * System DMA driver for NVIDIA Tegra SoCs
5 *
6 * Copyright (c) 2008-2009, NVIDIA Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#include <linux/io.h>
24#include <linux/interrupt.h>
25#include <linux/module.h>
26#include <linux/spinlock.h>
27#include <linux/err.h>
28#include <linux/irq.h>
29#include <linux/delay.h>
30#include <mach/dma.h>
31#include <mach/irqs.h>
32#include <mach/iomap.h>
33
34#define APB_DMA_GEN 0x000
35#define GEN_ENABLE (1<<31)
36
37#define APB_DMA_CNTRL 0x010
38
39#define APB_DMA_IRQ_MASK 0x01c
40
41#define APB_DMA_IRQ_MASK_SET 0x020
42
43#define APB_DMA_CHAN_CSR 0x000
44#define CSR_ENB (1<<31)
45#define CSR_IE_EOC (1<<30)
46#define CSR_HOLD (1<<29)
47#define CSR_DIR (1<<28)
48#define CSR_ONCE (1<<27)
49#define CSR_FLOW (1<<21)
50#define CSR_REQ_SEL_SHIFT 16
51#define CSR_REQ_SEL_MASK (0x1F<<CSR_REQ_SEL_SHIFT)
52#define CSR_REQ_SEL_INVALID (31<<CSR_REQ_SEL_SHIFT)
53#define CSR_WCOUNT_SHIFT 2
54#define CSR_WCOUNT_MASK 0xFFFC
55
56#define APB_DMA_CHAN_STA 0x004
57#define STA_BUSY (1<<31)
58#define STA_ISE_EOC (1<<30)
59#define STA_HALT (1<<29)
60#define STA_PING_PONG (1<<28)
61#define STA_COUNT_SHIFT 2
62#define STA_COUNT_MASK 0xFFFC
63
64#define APB_DMA_CHAN_AHB_PTR 0x010
65
66#define APB_DMA_CHAN_AHB_SEQ 0x014
67#define AHB_SEQ_INTR_ENB (1<<31)
68#define AHB_SEQ_BUS_WIDTH_SHIFT 28
69#define AHB_SEQ_BUS_WIDTH_MASK (0x7<<AHB_SEQ_BUS_WIDTH_SHIFT)
70#define AHB_SEQ_BUS_WIDTH_8 (0<<AHB_SEQ_BUS_WIDTH_SHIFT)
71#define AHB_SEQ_BUS_WIDTH_16 (1<<AHB_SEQ_BUS_WIDTH_SHIFT)
72#define AHB_SEQ_BUS_WIDTH_32 (2<<AHB_SEQ_BUS_WIDTH_SHIFT)
73#define AHB_SEQ_BUS_WIDTH_64 (3<<AHB_SEQ_BUS_WIDTH_SHIFT)
74#define AHB_SEQ_BUS_WIDTH_128 (4<<AHB_SEQ_BUS_WIDTH_SHIFT)
75#define AHB_SEQ_DATA_SWAP (1<<27)
76#define AHB_SEQ_BURST_MASK (0x7<<24)
77#define AHB_SEQ_BURST_1 (4<<24)
78#define AHB_SEQ_BURST_4 (5<<24)
79#define AHB_SEQ_BURST_8 (6<<24)
80#define AHB_SEQ_DBL_BUF (1<<19)
81#define AHB_SEQ_WRAP_SHIFT 16
82#define AHB_SEQ_WRAP_MASK (0x7<<AHB_SEQ_WRAP_SHIFT)
83
84#define APB_DMA_CHAN_APB_PTR 0x018
85
86#define APB_DMA_CHAN_APB_SEQ 0x01c
87#define APB_SEQ_BUS_WIDTH_SHIFT 28
88#define APB_SEQ_BUS_WIDTH_MASK (0x7<<APB_SEQ_BUS_WIDTH_SHIFT)
89#define APB_SEQ_BUS_WIDTH_8 (0<<APB_SEQ_BUS_WIDTH_SHIFT)
90#define APB_SEQ_BUS_WIDTH_16 (1<<APB_SEQ_BUS_WIDTH_SHIFT)
91#define APB_SEQ_BUS_WIDTH_32 (2<<APB_SEQ_BUS_WIDTH_SHIFT)
92#define APB_SEQ_BUS_WIDTH_64 (3<<APB_SEQ_BUS_WIDTH_SHIFT)
93#define APB_SEQ_BUS_WIDTH_128 (4<<APB_SEQ_BUS_WIDTH_SHIFT)
94#define APB_SEQ_DATA_SWAP (1<<27)
95#define APB_SEQ_WRAP_SHIFT 16
96#define APB_SEQ_WRAP_MASK (0x7<<APB_SEQ_WRAP_SHIFT)
97
98#define TEGRA_SYSTEM_DMA_CH_NR 16
99#define TEGRA_SYSTEM_DMA_AVP_CH_NUM 4
100#define TEGRA_SYSTEM_DMA_CH_MIN 0
101#define TEGRA_SYSTEM_DMA_CH_MAX \
102 (TEGRA_SYSTEM_DMA_CH_NR - TEGRA_SYSTEM_DMA_AVP_CH_NUM - 1)
103
104#define NV_DMA_MAX_TRASFER_SIZE 0x10000
105
106const unsigned int ahb_addr_wrap_table[8] = {
107 0, 32, 64, 128, 256, 512, 1024, 2048
108};
109
110const unsigned int apb_addr_wrap_table[8] = {0, 1, 2, 4, 8, 16, 32, 64};
111
112const unsigned int bus_width_table[5] = {8, 16, 32, 64, 128};
113
114#define TEGRA_DMA_NAME_SIZE 16
115struct tegra_dma_channel {
116 struct list_head list;
117 int id;
118 spinlock_t lock;
119 char name[TEGRA_DMA_NAME_SIZE];
120 void __iomem *addr;
121 int mode;
122 int irq;
123
124 /* Register shadow */
125 u32 csr;
126 u32 ahb_seq;
127 u32 ahb_ptr;
128 u32 apb_seq;
129 u32 apb_ptr;
130};
131
132#define NV_DMA_MAX_CHANNELS 32
133
134static DECLARE_BITMAP(channel_usage, NV_DMA_MAX_CHANNELS);
135static struct tegra_dma_channel dma_channels[NV_DMA_MAX_CHANNELS];
136
137static void tegra_dma_update_hw(struct tegra_dma_channel *ch,
138 struct tegra_dma_req *req);
139static void tegra_dma_update_hw_partial(struct tegra_dma_channel *ch,
140 struct tegra_dma_req *req);
141static void tegra_dma_init_hw(struct tegra_dma_channel *ch);
142static void tegra_dma_stop(struct tegra_dma_channel *ch);
143
144void tegra_dma_flush(struct tegra_dma_channel *ch)
145{
146}
147EXPORT_SYMBOL(tegra_dma_flush);
148
149void tegra_dma_dequeue(struct tegra_dma_channel *ch)
150{
151 struct tegra_dma_req *req;
152
153 req = list_entry(ch->list.next, typeof(*req), node);
154
155 tegra_dma_dequeue_req(ch, req);
156 return;
157}
158
159void tegra_dma_stop(struct tegra_dma_channel *ch)
160{
161 unsigned int csr;
162 unsigned int status;
163
164 csr = ch->csr;
165 csr &= ~CSR_IE_EOC;
166 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
167
168 csr &= ~CSR_ENB;
169 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
170
171 status = readl(ch->addr + APB_DMA_CHAN_STA);
172 if (status & STA_ISE_EOC)
173 writel(status, ch->addr + APB_DMA_CHAN_STA);
174}
175
176int tegra_dma_cancel(struct tegra_dma_channel *ch)
177{
178 unsigned int csr;
179 unsigned long irq_flags;
180
181 spin_lock_irqsave(&ch->lock, irq_flags);
182 while (!list_empty(&ch->list))
183 list_del(ch->list.next);
184
185 csr = ch->csr;
186 csr &= ~CSR_REQ_SEL_MASK;
187 csr |= CSR_REQ_SEL_INVALID;
188
189 /* Set the enable as that is not shadowed */
190 csr |= CSR_ENB;
191 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
192
193 tegra_dma_stop(ch);
194
195 spin_unlock_irqrestore(&ch->lock, irq_flags);
196 return 0;
197}
198
199int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
200 struct tegra_dma_req *_req)
201{
202 unsigned int csr;
203 unsigned int status;
204 struct tegra_dma_req *req = NULL;
205 int found = 0;
206 unsigned long irq_flags;
207 int to_transfer;
208 int req_transfer_count;
209
210 spin_lock_irqsave(&ch->lock, irq_flags);
211 list_for_each_entry(req, &ch->list, node) {
212 if (req == _req) {
213 list_del(&req->node);
214 found = 1;
215 break;
216 }
217 }
218 if (!found) {
219 spin_unlock_irqrestore(&ch->lock, irq_flags);
220 return 0;
221 }
222
223 /* STOP the DMA and get the transfer count.
224 * Getting the transfer count is tricky.
225 * - Change the source selector to invalid to stop the DMA from
226 * FIFO to memory.
227 * - Read the status register to know the number of pending
228 * bytes to be transfered.
229 * - Finally stop or program the DMA to the next buffer in the
230 * list.
231 */
232 csr = ch->csr;
233 csr &= ~CSR_REQ_SEL_MASK;
234 csr |= CSR_REQ_SEL_INVALID;
235
236 /* Set the enable as that is not shadowed */
237 csr |= CSR_ENB;
238 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
239
240 /* Get the transfer count */
241 status = readl(ch->addr + APB_DMA_CHAN_STA);
242 to_transfer = (status & STA_COUNT_MASK) >> STA_COUNT_SHIFT;
243 req_transfer_count = (ch->csr & CSR_WCOUNT_MASK) >> CSR_WCOUNT_SHIFT;
244 req_transfer_count += 1;
245 to_transfer += 1;
246
247 req->bytes_transferred = req_transfer_count;
248
249 if (status & STA_BUSY)
250 req->bytes_transferred -= to_transfer;
251
252 /* In continous transfer mode, DMA only tracks the count of the
253 * half DMA buffer. So, if the DMA already finished half the DMA
254 * then add the half buffer to the completed count.
255 *
256 * FIXME: There can be a race here. What if the req to
257 * dequue happens at the same time as the DMA just moved to
258 * the new buffer and SW didn't yet received the interrupt?
259 */
260 if (ch->mode & TEGRA_DMA_MODE_CONTINOUS)
261 if (req->buffer_status == TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL)
262 req->bytes_transferred += req_transfer_count;
263
264 req->bytes_transferred *= 4;
265
266 tegra_dma_stop(ch);
267 if (!list_empty(&ch->list)) {
268 /* if the list is not empty, queue the next request */
269 struct tegra_dma_req *next_req;
270 next_req = list_entry(ch->list.next,
271 typeof(*next_req), node);
272 tegra_dma_update_hw(ch, next_req);
273 }
274 req->status = -TEGRA_DMA_REQ_ERROR_ABORTED;
275
276 spin_unlock_irqrestore(&ch->lock, irq_flags);
277
278 /* Callback should be called without any lock */
279 req->complete(req);
280 return 0;
281}
282EXPORT_SYMBOL(tegra_dma_dequeue_req);
283
284bool tegra_dma_is_empty(struct tegra_dma_channel *ch)
285{
286 unsigned long irq_flags;
287 bool is_empty;
288
289 spin_lock_irqsave(&ch->lock, irq_flags);
290 if (list_empty(&ch->list))
291 is_empty = true;
292 else
293 is_empty = false;
294 spin_unlock_irqrestore(&ch->lock, irq_flags);
295 return is_empty;
296}
297EXPORT_SYMBOL(tegra_dma_is_empty);
298
299bool tegra_dma_is_req_inflight(struct tegra_dma_channel *ch,
300 struct tegra_dma_req *_req)
301{
302 unsigned long irq_flags;
303 struct tegra_dma_req *req;
304
305 spin_lock_irqsave(&ch->lock, irq_flags);
306 list_for_each_entry(req, &ch->list, node) {
307 if (req == _req) {
308 spin_unlock_irqrestore(&ch->lock, irq_flags);
309 return true;
310 }
311 }
312 spin_unlock_irqrestore(&ch->lock, irq_flags);
313 return false;
314}
315EXPORT_SYMBOL(tegra_dma_is_req_inflight);
316
317int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,
318 struct tegra_dma_req *req)
319{
320 unsigned long irq_flags;
321 int start_dma = 0;
322
323 if (req->size > NV_DMA_MAX_TRASFER_SIZE ||
324 req->source_addr & 0x3 || req->dest_addr & 0x3) {
325 pr_err("Invalid DMA request for channel %d\n", ch->id);
326 return -EINVAL;
327 }
328
329 spin_lock_irqsave(&ch->lock, irq_flags);
330
331 req->bytes_transferred = 0;
332 req->status = 0;
333 req->buffer_status = 0;
334 if (list_empty(&ch->list))
335 start_dma = 1;
336
337 list_add_tail(&req->node, &ch->list);
338
339 if (start_dma)
340 tegra_dma_update_hw(ch, req);
341
342 spin_unlock_irqrestore(&ch->lock, irq_flags);
343
344 return 0;
345}
346EXPORT_SYMBOL(tegra_dma_enqueue_req);
347
348struct tegra_dma_channel *tegra_dma_allocate_channel(int mode)
349{
350 int channel;
351 struct tegra_dma_channel *ch;
352
353 /* first channel is the shared channel */
354 if (mode & TEGRA_DMA_SHARED) {
355 channel = TEGRA_SYSTEM_DMA_CH_MIN;
356 } else {
357 channel = find_first_zero_bit(channel_usage,
358 ARRAY_SIZE(dma_channels));
359 if (channel >= ARRAY_SIZE(dma_channels))
360 return NULL;
361 }
362 __set_bit(channel, channel_usage);
363 ch = &dma_channels[channel];
364 ch->mode = mode;
365 return ch;
366}
367EXPORT_SYMBOL(tegra_dma_allocate_channel);
368
369void tegra_dma_free_channel(struct tegra_dma_channel *ch)
370{
371 if (ch->mode & TEGRA_DMA_SHARED)
372 return;
373 tegra_dma_cancel(ch);
374 __clear_bit(ch->id, channel_usage);
375}
376EXPORT_SYMBOL(tegra_dma_free_channel);
377
378static void tegra_dma_update_hw_partial(struct tegra_dma_channel *ch,
379 struct tegra_dma_req *req)
380{
381 if (req->to_memory) {
382 ch->apb_ptr = req->source_addr;
383 ch->ahb_ptr = req->dest_addr;
384 } else {
385 ch->apb_ptr = req->dest_addr;
386 ch->ahb_ptr = req->source_addr;
387 }
388 writel(ch->apb_ptr, ch->addr + APB_DMA_CHAN_APB_PTR);
389 writel(ch->ahb_ptr, ch->addr + APB_DMA_CHAN_AHB_PTR);
390
391 req->status = TEGRA_DMA_REQ_INFLIGHT;
392 return;
393}
394
395static void tegra_dma_update_hw(struct tegra_dma_channel *ch,
396 struct tegra_dma_req *req)
397{
398 int ahb_addr_wrap;
399 int apb_addr_wrap;
400 int ahb_bus_width;
401 int apb_bus_width;
402 int index;
403 unsigned long csr;
404
405
406 ch->csr |= CSR_FLOW;
407 ch->csr &= ~CSR_REQ_SEL_MASK;
408 ch->csr |= req->req_sel << CSR_REQ_SEL_SHIFT;
409 ch->ahb_seq &= ~AHB_SEQ_BURST_MASK;
410 ch->ahb_seq |= AHB_SEQ_BURST_1;
411
412 /* One shot mode is always single buffered,
413 * continuous mode is always double buffered
414 * */
415 if (ch->mode & TEGRA_DMA_MODE_ONESHOT) {
416 ch->csr |= CSR_ONCE;
417 ch->ahb_seq &= ~AHB_SEQ_DBL_BUF;
418 ch->csr &= ~CSR_WCOUNT_MASK;
419 ch->csr |= ((req->size>>2) - 1) << CSR_WCOUNT_SHIFT;
420 } else {
421 ch->csr &= ~CSR_ONCE;
422 ch->ahb_seq |= AHB_SEQ_DBL_BUF;
423
424 /* In double buffered mode, we set the size to half the
425 * requested size and interrupt when half the buffer
426 * is full */
427 ch->csr &= ~CSR_WCOUNT_MASK;
428 ch->csr |= ((req->size>>3) - 1) << CSR_WCOUNT_SHIFT;
429 }
430
431 if (req->to_memory) {
432 ch->csr &= ~CSR_DIR;
433 ch->apb_ptr = req->source_addr;
434 ch->ahb_ptr = req->dest_addr;
435
436 apb_addr_wrap = req->source_wrap;
437 ahb_addr_wrap = req->dest_wrap;
438 apb_bus_width = req->source_bus_width;
439 ahb_bus_width = req->dest_bus_width;
440
441 } else {
442 ch->csr |= CSR_DIR;
443 ch->apb_ptr = req->dest_addr;
444 ch->ahb_ptr = req->source_addr;
445
446 apb_addr_wrap = req->dest_wrap;
447 ahb_addr_wrap = req->source_wrap;
448 apb_bus_width = req->dest_bus_width;
449 ahb_bus_width = req->source_bus_width;
450 }
451
452 apb_addr_wrap >>= 2;
453 ahb_addr_wrap >>= 2;
454
455 /* set address wrap for APB size */
456 index = 0;
457 do {
458 if (apb_addr_wrap_table[index] == apb_addr_wrap)
459 break;
460 index++;
461 } while (index < ARRAY_SIZE(apb_addr_wrap_table));
462 BUG_ON(index == ARRAY_SIZE(apb_addr_wrap_table));
463 ch->apb_seq &= ~APB_SEQ_WRAP_MASK;
464 ch->apb_seq |= index << APB_SEQ_WRAP_SHIFT;
465
466 /* set address wrap for AHB size */
467 index = 0;
468 do {
469 if (ahb_addr_wrap_table[index] == ahb_addr_wrap)
470 break;
471 index++;
472 } while (index < ARRAY_SIZE(ahb_addr_wrap_table));
473 BUG_ON(index == ARRAY_SIZE(ahb_addr_wrap_table));
474 ch->ahb_seq &= ~AHB_SEQ_WRAP_MASK;
475 ch->ahb_seq |= index << AHB_SEQ_WRAP_SHIFT;
476
477 for (index = 0; index < ARRAY_SIZE(bus_width_table); index++) {
478 if (bus_width_table[index] == ahb_bus_width)
479 break;
480 }
481 BUG_ON(index == ARRAY_SIZE(bus_width_table));
482 ch->ahb_seq &= ~AHB_SEQ_BUS_WIDTH_MASK;
483 ch->ahb_seq |= index << AHB_SEQ_BUS_WIDTH_SHIFT;
484
485 for (index = 0; index < ARRAY_SIZE(bus_width_table); index++) {
486 if (bus_width_table[index] == apb_bus_width)
487 break;
488 }
489 BUG_ON(index == ARRAY_SIZE(bus_width_table));
490 ch->apb_seq &= ~APB_SEQ_BUS_WIDTH_MASK;
491 ch->apb_seq |= index << APB_SEQ_BUS_WIDTH_SHIFT;
492
493 ch->csr |= CSR_IE_EOC;
494
495 /* update hw registers with the shadow */
496 writel(ch->csr, ch->addr + APB_DMA_CHAN_CSR);
497 writel(ch->apb_seq, ch->addr + APB_DMA_CHAN_APB_SEQ);
498 writel(ch->apb_ptr, ch->addr + APB_DMA_CHAN_APB_PTR);
499 writel(ch->ahb_seq, ch->addr + APB_DMA_CHAN_AHB_SEQ);
500 writel(ch->ahb_ptr, ch->addr + APB_DMA_CHAN_AHB_PTR);
501
502 csr = ch->csr | CSR_ENB;
503 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
504
505 req->status = TEGRA_DMA_REQ_INFLIGHT;
506}
507
508static void tegra_dma_init_hw(struct tegra_dma_channel *ch)
509{
510 /* One shot with an interrupt to CPU after transfer */
511 ch->csr = CSR_ONCE | CSR_IE_EOC;
512 ch->ahb_seq = AHB_SEQ_BUS_WIDTH_32 | AHB_SEQ_INTR_ENB;
513 ch->apb_seq = APB_SEQ_BUS_WIDTH_32 | 1 << APB_SEQ_WRAP_SHIFT;
514}
515
516static void handle_oneshot_dma(struct tegra_dma_channel *ch)
517{
518 struct tegra_dma_req *req;
519
520 spin_lock(&ch->lock);
521 if (list_empty(&ch->list)) {
522 spin_unlock(&ch->lock);
523 return;
524 }
525
526 req = list_entry(ch->list.next, typeof(*req), node);
527 if (req) {
528 int bytes_transferred;
529
530 bytes_transferred =
531 (ch->csr & CSR_WCOUNT_MASK) >> CSR_WCOUNT_SHIFT;
532 bytes_transferred += 1;
533 bytes_transferred <<= 2;
534
535 list_del(&req->node);
536 req->bytes_transferred = bytes_transferred;
537 req->status = TEGRA_DMA_REQ_SUCCESS;
538
539 spin_unlock(&ch->lock);
540 /* Callback should be called without any lock */
541 pr_debug("%s: transferred %d bytes\n", __func__,
542 req->bytes_transferred);
543 req->complete(req);
544 spin_lock(&ch->lock);
545 }
546
547 if (!list_empty(&ch->list)) {
548 req = list_entry(ch->list.next, typeof(*req), node);
549 /* the complete function we just called may have enqueued
550 another req, in which case dma has already started */
551 if (req->status != TEGRA_DMA_REQ_INFLIGHT)
552 tegra_dma_update_hw(ch, req);
553 }
554 spin_unlock(&ch->lock);
555}
556
557static void handle_continuous_dma(struct tegra_dma_channel *ch)
558{
559 struct tegra_dma_req *req;
560
561 spin_lock(&ch->lock);
562 if (list_empty(&ch->list)) {
563 spin_unlock(&ch->lock);
564 return;
565 }
566
567 req = list_entry(ch->list.next, typeof(*req), node);
568 if (req) {
569 if (req->buffer_status == TEGRA_DMA_REQ_BUF_STATUS_EMPTY) {
570 /* Load the next request into the hardware, if available
571 * */
572 if (!list_is_last(&req->node, &ch->list)) {
573 struct tegra_dma_req *next_req;
574
575 next_req = list_entry(req->node.next,
576 typeof(*next_req), node);
577 tegra_dma_update_hw_partial(ch, next_req);
578 }
579 req->buffer_status = TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL;
580 req->status = TEGRA_DMA_REQ_SUCCESS;
581 /* DMA lock is NOT held when callback is called */
582 spin_unlock(&ch->lock);
583 if (likely(req->threshold))
584 req->threshold(req);
585 return;
586
587 } else if (req->buffer_status ==
588 TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL) {
589 /* Callback when the buffer is completely full (i.e on
590 * the second interrupt */
591 int bytes_transferred;
592
593 bytes_transferred =
594 (ch->csr & CSR_WCOUNT_MASK) >> CSR_WCOUNT_SHIFT;
595 bytes_transferred += 1;
596 bytes_transferred <<= 3;
597
598 req->buffer_status = TEGRA_DMA_REQ_BUF_STATUS_FULL;
599 req->bytes_transferred = bytes_transferred;
600 req->status = TEGRA_DMA_REQ_SUCCESS;
601 list_del(&req->node);
602
603 /* DMA lock is NOT held when callbak is called */
604 spin_unlock(&ch->lock);
605 req->complete(req);
606 return;
607
608 } else {
609 BUG();
610 }
611 }
612 spin_unlock(&ch->lock);
613}
614
615static irqreturn_t dma_isr(int irq, void *data)
616{
617 struct tegra_dma_channel *ch = data;
618 unsigned long status;
619
620 status = readl(ch->addr + APB_DMA_CHAN_STA);
621 if (status & STA_ISE_EOC)
622 writel(status, ch->addr + APB_DMA_CHAN_STA);
623 else {
624 pr_warning("Got a spurious ISR for DMA channel %d\n", ch->id);
625 return IRQ_HANDLED;
626 }
627 return IRQ_WAKE_THREAD;
628}
629
630static irqreturn_t dma_thread_fn(int irq, void *data)
631{
632 struct tegra_dma_channel *ch = data;
633
634 if (ch->mode & TEGRA_DMA_MODE_ONESHOT)
635 handle_oneshot_dma(ch);
636 else
637 handle_continuous_dma(ch);
638
639
640 return IRQ_HANDLED;
641}
642
643int __init tegra_dma_init(void)
644{
645 int ret = 0;
646 int i;
647 unsigned int irq;
648 void __iomem *addr;
649
650 addr = IO_ADDRESS(TEGRA_APB_DMA_BASE);
651 writel(GEN_ENABLE, addr + APB_DMA_GEN);
652 writel(0, addr + APB_DMA_CNTRL);
653 writel(0xFFFFFFFFul >> (31 - TEGRA_SYSTEM_DMA_CH_MAX),
654 addr + APB_DMA_IRQ_MASK_SET);
655
656 memset(channel_usage, 0, sizeof(channel_usage));
657 memset(dma_channels, 0, sizeof(dma_channels));
658
659 /* Reserve all the channels we are not supposed to touch */
660 for (i = 0; i < TEGRA_SYSTEM_DMA_CH_MIN; i++)
661 __set_bit(i, channel_usage);
662
663 for (i = TEGRA_SYSTEM_DMA_CH_MIN; i <= TEGRA_SYSTEM_DMA_CH_MAX; i++) {
664 struct tegra_dma_channel *ch = &dma_channels[i];
665
666 __clear_bit(i, channel_usage);
667
668 ch->id = i;
669 snprintf(ch->name, TEGRA_DMA_NAME_SIZE, "dma_channel_%d", i);
670
671 ch->addr = IO_ADDRESS(TEGRA_APB_DMA_CH0_BASE +
672 TEGRA_APB_DMA_CH0_SIZE * i);
673
674 spin_lock_init(&ch->lock);
675 INIT_LIST_HEAD(&ch->list);
676 tegra_dma_init_hw(ch);
677
678 irq = INT_APB_DMA_CH0 + i;
679 ret = request_threaded_irq(irq, dma_isr, dma_thread_fn, 0,
680 dma_channels[i].name, ch);
681 if (ret) {
682 pr_err("Failed to register IRQ %d for DMA %d\n",
683 irq, i);
684 goto fail;
685 }
686 ch->irq = irq;
687 }
688 /* mark the shared channel allocated */
689 __set_bit(TEGRA_SYSTEM_DMA_CH_MIN, channel_usage);
690
691 for (i = TEGRA_SYSTEM_DMA_CH_MAX+1; i < NV_DMA_MAX_CHANNELS; i++)
692 __set_bit(i, channel_usage);
693
694 return ret;
695fail:
696 writel(0, addr + APB_DMA_GEN);
697 for (i = TEGRA_SYSTEM_DMA_CH_MIN; i <= TEGRA_SYSTEM_DMA_CH_MAX; i++) {
698 struct tegra_dma_channel *ch = &dma_channels[i];
699 if (ch->irq)
700 free_irq(ch->irq, ch);
701 }
702 return ret;
703}
704
705#ifdef CONFIG_PM
706static u32 apb_dma[5*TEGRA_SYSTEM_DMA_CH_NR + 3];
707
708void tegra_dma_suspend(void)
709{
710 void __iomem *addr = IO_ADDRESS(TEGRA_APB_DMA_BASE);
711 u32 *ctx = apb_dma;
712 int i;
713
714 *ctx++ = readl(addr + APB_DMA_GEN);
715 *ctx++ = readl(addr + APB_DMA_CNTRL);
716 *ctx++ = readl(addr + APB_DMA_IRQ_MASK);
717
718 for (i = 0; i < TEGRA_SYSTEM_DMA_CH_NR; i++) {
719 addr = IO_ADDRESS(TEGRA_APB_DMA_CH0_BASE +
720 TEGRA_APB_DMA_CH0_SIZE * i);
721
722 *ctx++ = readl(addr + APB_DMA_CHAN_CSR);
723 *ctx++ = readl(addr + APB_DMA_CHAN_AHB_PTR);
724 *ctx++ = readl(addr + APB_DMA_CHAN_AHB_SEQ);
725 *ctx++ = readl(addr + APB_DMA_CHAN_APB_PTR);
726 *ctx++ = readl(addr + APB_DMA_CHAN_APB_SEQ);
727 }
728}
729
730void tegra_dma_resume(void)
731{
732 void __iomem *addr = IO_ADDRESS(TEGRA_APB_DMA_BASE);
733 u32 *ctx = apb_dma;
734 int i;
735
736 writel(*ctx++, addr + APB_DMA_GEN);
737 writel(*ctx++, addr + APB_DMA_CNTRL);
738 writel(*ctx++, addr + APB_DMA_IRQ_MASK);
739
740 for (i = 0; i < TEGRA_SYSTEM_DMA_CH_NR; i++) {
741 addr = IO_ADDRESS(TEGRA_APB_DMA_CH0_BASE +
742 TEGRA_APB_DMA_CH0_SIZE * i);
743
744 writel(*ctx++, addr + APB_DMA_CHAN_CSR);
745 writel(*ctx++, addr + APB_DMA_CHAN_AHB_PTR);
746 writel(*ctx++, addr + APB_DMA_CHAN_AHB_SEQ);
747 writel(*ctx++, addr + APB_DMA_CHAN_APB_PTR);
748 writel(*ctx++, addr + APB_DMA_CHAN_APB_SEQ);
749 }
750}
751
752#endif
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c
new file mode 100644
index 000000000000..1fa26d9a1a68
--- /dev/null
+++ b/arch/arm/mach-tegra/fuse.c
@@ -0,0 +1,84 @@
1/*
2 * arch/arm/mach-tegra/fuse.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * Author:
7 * Colin Cross <ccross@android.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
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 */
19
20#include <linux/kernel.h>
21#include <linux/io.h>
22
23#include <mach/iomap.h>
24
25#include "fuse.h"
26
27#define FUSE_UID_LOW 0x108
28#define FUSE_UID_HIGH 0x10c
29#define FUSE_SKU_INFO 0x110
30#define FUSE_SPARE_BIT 0x200
31
32static inline u32 fuse_readl(unsigned long offset)
33{
34 return readl(IO_TO_VIRT(TEGRA_FUSE_BASE + offset));
35}
36
37static inline void fuse_writel(u32 value, unsigned long offset)
38{
39 writel(value, IO_TO_VIRT(TEGRA_FUSE_BASE + offset));
40}
41
42void tegra_init_fuse(void)
43{
44 u32 reg = readl(IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
45 reg |= 1 << 28;
46 writel(reg, IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
47
48 pr_info("Tegra SKU: %d CPU Process: %d Core Process: %d\n",
49 tegra_sku_id(), tegra_cpu_process_id(),
50 tegra_core_process_id());
51}
52
53unsigned long long tegra_chip_uid(void)
54{
55 unsigned long long lo, hi;
56
57 lo = fuse_readl(FUSE_UID_LOW);
58 hi = fuse_readl(FUSE_UID_HIGH);
59 return (hi << 32ull) | lo;
60}
61
62int tegra_sku_id(void)
63{
64 int sku_id;
65 u32 reg = fuse_readl(FUSE_SKU_INFO);
66 sku_id = reg & 0xFF;
67 return sku_id;
68}
69
70int tegra_cpu_process_id(void)
71{
72 int cpu_process_id;
73 u32 reg = fuse_readl(FUSE_SPARE_BIT);
74 cpu_process_id = (reg >> 6) & 3;
75 return cpu_process_id;
76}
77
78int tegra_core_process_id(void)
79{
80 int core_process_id;
81 u32 reg = fuse_readl(FUSE_SPARE_BIT);
82 core_process_id = (reg >> 12) & 3;
83 return core_process_id;
84}
diff --git a/arch/arm/mach-tegra/fuse.h b/arch/arm/mach-tegra/fuse.h
new file mode 100644
index 000000000000..584b2e27dbda
--- /dev/null
+++ b/arch/arm/mach-tegra/fuse.h
@@ -0,0 +1,24 @@
1/*
2 * arch/arm/mach-tegra/fuse.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * Author:
7 * Colin Cross <ccross@android.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
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 */
19
20unsigned long long tegra_chip_uid(void);
21int tegra_sku_id(void);
22int tegra_cpu_process_id(void);
23int tegra_core_process_id(void);
24void tegra_init_fuse(void);
diff --git a/arch/arm/mach-tegra/gpio.c b/arch/arm/mach-tegra/gpio.c
index fe78fba25f3c..0775265e69f5 100644
--- a/arch/arm/mach-tegra/gpio.c
+++ b/arch/arm/mach-tegra/gpio.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/irq.h> 21#include <linux/irq.h>
22#include <linux/interrupt.h>
22 23
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/gpio.h> 25#include <linux/gpio.h>
@@ -60,6 +61,13 @@ struct tegra_gpio_bank {
60 int bank; 61 int bank;
61 int irq; 62 int irq;
62 spinlock_t lvl_lock[4]; 63 spinlock_t lvl_lock[4];
64#ifdef CONFIG_PM
65 u32 cnf[4];
66 u32 out[4];
67 u32 oe[4];
68 u32 int_enb[4];
69 u32 int_lvl[4];
70#endif
63}; 71};
64 72
65 73
@@ -131,7 +139,7 @@ static struct gpio_chip tegra_gpio_chip = {
131 .direction_output = tegra_gpio_direction_output, 139 .direction_output = tegra_gpio_direction_output,
132 .set = tegra_gpio_set, 140 .set = tegra_gpio_set,
133 .base = 0, 141 .base = 0,
134 .ngpio = ARCH_NR_GPIOS, 142 .ngpio = TEGRA_NR_GPIOS,
135}; 143};
136 144
137static void tegra_gpio_irq_ack(unsigned int irq) 145static void tegra_gpio_irq_ack(unsigned int irq)
@@ -244,6 +252,76 @@ static void tegra_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
244 252
245} 253}
246 254
255#ifdef CONFIG_PM
256void tegra_gpio_resume(void)
257{
258 unsigned long flags;
259 int b, p, i;
260
261 local_irq_save(flags);
262
263 for (b = 0; b < ARRAY_SIZE(tegra_gpio_banks); b++) {
264 struct tegra_gpio_bank *bank = &tegra_gpio_banks[b];
265
266 for (p = 0; p < ARRAY_SIZE(bank->oe); p++) {
267 unsigned int gpio = (b<<5) | (p<<3);
268 __raw_writel(bank->cnf[p], GPIO_CNF(gpio));
269 __raw_writel(bank->out[p], GPIO_OUT(gpio));
270 __raw_writel(bank->oe[p], GPIO_OE(gpio));
271 __raw_writel(bank->int_lvl[p], GPIO_INT_LVL(gpio));
272 __raw_writel(bank->int_enb[p], GPIO_INT_ENB(gpio));
273 }
274 }
275
276 local_irq_restore(flags);
277
278 for (i = INT_GPIO_BASE; i < (INT_GPIO_BASE + TEGRA_NR_GPIOS); i++) {
279 struct irq_desc *desc = irq_to_desc(i);
280 if (!desc || (desc->status & IRQ_WAKEUP))
281 continue;
282 enable_irq(i);
283 }
284}
285
286void tegra_gpio_suspend(void)
287{
288 unsigned long flags;
289 int b, p, i;
290
291 for (i = INT_GPIO_BASE; i < (INT_GPIO_BASE + TEGRA_NR_GPIOS); i++) {
292 struct irq_desc *desc = irq_to_desc(i);
293 if (!desc)
294 continue;
295 if (desc->status & IRQ_WAKEUP) {
296 int gpio = i - INT_GPIO_BASE;
297 pr_debug("gpio %d.%d is wakeup\n", gpio/8, gpio&7);
298 continue;
299 }
300 disable_irq(i);
301 }
302
303 local_irq_save(flags);
304 for (b = 0; b < ARRAY_SIZE(tegra_gpio_banks); b++) {
305 struct tegra_gpio_bank *bank = &tegra_gpio_banks[b];
306
307 for (p = 0; p < ARRAY_SIZE(bank->oe); p++) {
308 unsigned int gpio = (b<<5) | (p<<3);
309 bank->cnf[p] = __raw_readl(GPIO_CNF(gpio));
310 bank->out[p] = __raw_readl(GPIO_OUT(gpio));
311 bank->oe[p] = __raw_readl(GPIO_OE(gpio));
312 bank->int_enb[p] = __raw_readl(GPIO_INT_ENB(gpio));
313 bank->int_lvl[p] = __raw_readl(GPIO_INT_LVL(gpio));
314 }
315 }
316 local_irq_restore(flags);
317}
318
319static int tegra_gpio_wake_enable(unsigned int irq, unsigned int enable)
320{
321 struct tegra_gpio_bank *bank = get_irq_chip_data(irq);
322 return set_irq_wake(bank->irq, enable);
323}
324#endif
247 325
248static struct irq_chip tegra_gpio_irq_chip = { 326static struct irq_chip tegra_gpio_irq_chip = {
249 .name = "GPIO", 327 .name = "GPIO",
@@ -251,6 +329,9 @@ static struct irq_chip tegra_gpio_irq_chip = {
251 .mask = tegra_gpio_irq_mask, 329 .mask = tegra_gpio_irq_mask,
252 .unmask = tegra_gpio_irq_unmask, 330 .unmask = tegra_gpio_irq_unmask,
253 .set_type = tegra_gpio_irq_set_type, 331 .set_type = tegra_gpio_irq_set_type,
332#ifdef CONFIG_PM
333 .set_wake = tegra_gpio_wake_enable,
334#endif
254}; 335};
255 336
256 337
@@ -274,7 +355,7 @@ static int __init tegra_gpio_init(void)
274 355
275 gpiochip_add(&tegra_gpio_chip); 356 gpiochip_add(&tegra_gpio_chip);
276 357
277 for (i = INT_GPIO_BASE; i < (INT_GPIO_BASE + ARCH_NR_GPIOS); i++) { 358 for (i = INT_GPIO_BASE; i < (INT_GPIO_BASE + TEGRA_NR_GPIOS); i++) {
278 bank = &tegra_gpio_banks[GPIO_BANK(irq_to_gpio(i))]; 359 bank = &tegra_gpio_banks[GPIO_BANK(irq_to_gpio(i))];
279 360
280 lockdep_set_class(&irq_desc[i].lock, &gpio_lock_class); 361 lockdep_set_class(&irq_desc[i].lock, &gpio_lock_class);
@@ -312,15 +393,16 @@ static int dbg_gpio_show(struct seq_file *s, void *unused)
312 for (i = 0; i < 7; i++) { 393 for (i = 0; i < 7; i++) {
313 for (j = 0; j < 4; j++) { 394 for (j = 0; j < 4; j++) {
314 int gpio = tegra_gpio_compose(i, j, 0); 395 int gpio = tegra_gpio_compose(i, j, 0);
315 seq_printf(s, "%d:%d %02x %02x %02x %02x %02x %02x %06x\n", 396 seq_printf(s,
316 i, j, 397 "%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
317 __raw_readl(GPIO_CNF(gpio)), 398 i, j,
318 __raw_readl(GPIO_OE(gpio)), 399 __raw_readl(GPIO_CNF(gpio)),
319 __raw_readl(GPIO_OUT(gpio)), 400 __raw_readl(GPIO_OE(gpio)),
320 __raw_readl(GPIO_IN(gpio)), 401 __raw_readl(GPIO_OUT(gpio)),
321 __raw_readl(GPIO_INT_STA(gpio)), 402 __raw_readl(GPIO_IN(gpio)),
322 __raw_readl(GPIO_INT_ENB(gpio)), 403 __raw_readl(GPIO_INT_STA(gpio)),
323 __raw_readl(GPIO_INT_LVL(gpio))); 404 __raw_readl(GPIO_INT_ENB(gpio)),
405 __raw_readl(GPIO_INT_LVL(gpio)));
324 } 406 }
325 } 407 }
326 return 0; 408 return 0;
diff --git a/arch/arm/mach-tegra/include/mach/clk.h b/arch/arm/mach-tegra/include/mach/clk.h
index 2896f25ebfb5..d7723955dac7 100644
--- a/arch/arm/mach-tegra/include/mach/clk.h
+++ b/arch/arm/mach-tegra/include/mach/clk.h
@@ -23,4 +23,9 @@
23void tegra_periph_reset_deassert(struct clk *c); 23void tegra_periph_reset_deassert(struct clk *c);
24void tegra_periph_reset_assert(struct clk *c); 24void tegra_periph_reset_assert(struct clk *c);
25 25
26int clk_enable_cansleep(struct clk *clk);
27void clk_disable_cansleep(struct clk *clk);
28int clk_set_rate_cansleep(struct clk *clk, unsigned long rate);
29int clk_set_parent_cansleep(struct clk *clk, struct clk *parent);
30
26#endif 31#endif
diff --git a/arch/arm/mach-tegra/include/mach/dma.h b/arch/arm/mach-tegra/include/mach/dma.h
new file mode 100644
index 000000000000..39011bd9a925
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/dma.h
@@ -0,0 +1,155 @@
1/*
2 * arch/arm/mach-tegra/include/mach/dma.h
3 *
4 * Copyright (c) 2008-2009, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __MACH_TEGRA_DMA_H
22#define __MACH_TEGRA_DMA_H
23
24#include <linux/list.h>
25
26#if defined(CONFIG_TEGRA_SYSTEM_DMA)
27
28struct tegra_dma_req;
29struct tegra_dma_channel;
30
31#define TEGRA_DMA_REQ_SEL_CNTR 0
32#define TEGRA_DMA_REQ_SEL_I2S_2 1
33#define TEGRA_DMA_REQ_SEL_I2S_1 2
34#define TEGRA_DMA_REQ_SEL_SPD_I 3
35#define TEGRA_DMA_REQ_SEL_UI_I 4
36#define TEGRA_DMA_REQ_SEL_MIPI 5
37#define TEGRA_DMA_REQ_SEL_I2S2_2 6
38#define TEGRA_DMA_REQ_SEL_I2S2_1 7
39#define TEGRA_DMA_REQ_SEL_UARTA 8
40#define TEGRA_DMA_REQ_SEL_UARTB 9
41#define TEGRA_DMA_REQ_SEL_UARTC 10
42#define TEGRA_DMA_REQ_SEL_SPI 11
43#define TEGRA_DMA_REQ_SEL_AC97 12
44#define TEGRA_DMA_REQ_SEL_ACMODEM 13
45#define TEGRA_DMA_REQ_SEL_SL4B 14
46#define TEGRA_DMA_REQ_SEL_SL2B1 15
47#define TEGRA_DMA_REQ_SEL_SL2B2 16
48#define TEGRA_DMA_REQ_SEL_SL2B3 17
49#define TEGRA_DMA_REQ_SEL_SL2B4 18
50#define TEGRA_DMA_REQ_SEL_UARTD 19
51#define TEGRA_DMA_REQ_SEL_UARTE 20
52#define TEGRA_DMA_REQ_SEL_I2C 21
53#define TEGRA_DMA_REQ_SEL_I2C2 22
54#define TEGRA_DMA_REQ_SEL_I2C3 23
55#define TEGRA_DMA_REQ_SEL_DVC_I2C 24
56#define TEGRA_DMA_REQ_SEL_OWR 25
57#define TEGRA_DMA_REQ_SEL_INVALID 31
58
59enum tegra_dma_mode {
60 TEGRA_DMA_SHARED = 1,
61 TEGRA_DMA_MODE_CONTINOUS = 2,
62 TEGRA_DMA_MODE_ONESHOT = 4,
63};
64
65enum tegra_dma_req_error {
66 TEGRA_DMA_REQ_SUCCESS = 0,
67 TEGRA_DMA_REQ_ERROR_ABORTED,
68 TEGRA_DMA_REQ_INFLIGHT,
69};
70
71enum tegra_dma_req_buff_status {
72 TEGRA_DMA_REQ_BUF_STATUS_EMPTY = 0,
73 TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL,
74 TEGRA_DMA_REQ_BUF_STATUS_FULL,
75};
76
77struct tegra_dma_req {
78 struct list_head node;
79 unsigned int modid;
80 int instance;
81
82 /* Called when the req is complete and from the DMA ISR context.
83 * When this is called the req structure is no longer queued by
84 * the DMA channel.
85 *
86 * State of the DMA depends on the number of req it has. If there are
87 * no DMA requests queued up, then it will STOP the DMA. It there are
88 * more requests in the DMA, then it will queue the next request.
89 */
90 void (*complete)(struct tegra_dma_req *req);
91
92 /* This is a called from the DMA ISR context when the DMA is still in
93 * progress and is actively filling same buffer.
94 *
95 * In case of continous mode receive, this threshold is 1/2 the buffer
96 * size. In other cases, this will not even be called as there is no
97 * hardware support for it.
98 *
99 * In the case of continous mode receive, if there is next req already
100 * queued, DMA programs the HW to use that req when this req is
101 * completed. If there is no "next req" queued, then DMA ISR doesn't do
102 * anything before calling this callback.
103 *
104 * This is mainly used by the cases, where the clients has queued
105 * only one req and want to get some sort of DMA threshold
106 * callback to program the next buffer.
107 *
108 */
109 void (*threshold)(struct tegra_dma_req *req);
110
111 /* 1 to copy to memory.
112 * 0 to copy from the memory to device FIFO */
113 int to_memory;
114
115 void *virt_addr;
116
117 unsigned long source_addr;
118 unsigned long dest_addr;
119 unsigned long dest_wrap;
120 unsigned long source_wrap;
121 unsigned long source_bus_width;
122 unsigned long dest_bus_width;
123 unsigned long req_sel;
124 unsigned int size;
125
126 /* Updated by the DMA driver on the conpletion of the request. */
127 int bytes_transferred;
128 int status;
129
130 /* DMA completion tracking information */
131 int buffer_status;
132
133 /* Client specific data */
134 void *dev;
135};
136
137int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,
138 struct tegra_dma_req *req);
139int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
140 struct tegra_dma_req *req);
141void tegra_dma_dequeue(struct tegra_dma_channel *ch);
142void tegra_dma_flush(struct tegra_dma_channel *ch);
143
144bool tegra_dma_is_req_inflight(struct tegra_dma_channel *ch,
145 struct tegra_dma_req *req);
146bool tegra_dma_is_empty(struct tegra_dma_channel *ch);
147
148struct tegra_dma_channel *tegra_dma_allocate_channel(int mode);
149void tegra_dma_free_channel(struct tegra_dma_channel *ch);
150
151int __init tegra_dma_init(void);
152
153#endif
154
155#endif
diff --git a/arch/arm/mach-tegra/include/mach/gpio.h b/arch/arm/mach-tegra/include/mach/gpio.h
index 540e822e50f7..e31f486d69a2 100644
--- a/arch/arm/mach-tegra/include/mach/gpio.h
+++ b/arch/arm/mach-tegra/include/mach/gpio.h
@@ -22,7 +22,7 @@
22 22
23#include <mach/irqs.h> 23#include <mach/irqs.h>
24 24
25#define ARCH_NR_GPIOS INT_GPIO_NR 25#define TEGRA_NR_GPIOS INT_GPIO_NR
26 26
27#include <asm-generic/gpio.h> 27#include <asm-generic/gpio.h>
28 28
@@ -35,7 +35,7 @@
35 35
36static inline int gpio_to_irq(unsigned int gpio) 36static inline int gpio_to_irq(unsigned int gpio)
37{ 37{
38 if (gpio < ARCH_NR_GPIOS) 38 if (gpio < TEGRA_NR_GPIOS)
39 return INT_GPIO_BASE + gpio; 39 return INT_GPIO_BASE + gpio;
40 return -EINVAL; 40 return -EINVAL;
41} 41}
diff --git a/arch/arm/mach-tegra/include/mach/hardware.h b/arch/arm/mach-tegra/include/mach/hardware.h
index 6014edf60d93..56e43b3a5b97 100644
--- a/arch/arm/mach-tegra/include/mach/hardware.h
+++ b/arch/arm/mach-tegra/include/mach/hardware.h
@@ -21,4 +21,8 @@
21#ifndef __MACH_TEGRA_HARDWARE_H 21#ifndef __MACH_TEGRA_HARDWARE_H
22#define __MACH_TEGRA_HARDWARE_H 22#define __MACH_TEGRA_HARDWARE_H
23 23
24#define PCIBIOS_MIN_IO 0x1000
25#define PCIBIOS_MIN_MEM 0
26#define pcibios_assign_all_busses() 1
27
24#endif 28#endif
diff --git a/arch/arm/mach-tegra/include/mach/io.h b/arch/arm/mach-tegra/include/mach/io.h
index 35edfc32ffc9..f0981b1ac59e 100644
--- a/arch/arm/mach-tegra/include/mach/io.h
+++ b/arch/arm/mach-tegra/include/mach/io.h
@@ -21,7 +21,7 @@
21#ifndef __MACH_TEGRA_IO_H 21#ifndef __MACH_TEGRA_IO_H
22#define __MACH_TEGRA_IO_H 22#define __MACH_TEGRA_IO_H
23 23
24#define IO_SPACE_LIMIT 0xffffffff 24#define IO_SPACE_LIMIT 0xffff
25 25
26/* On TEGRA, many peripherals are very closely packed in 26/* On TEGRA, many peripherals are very closely packed in
27 * two 256MB io windows (that actually only use about 64KB 27 * two 256MB io windows (that actually only use about 64KB
@@ -33,6 +33,10 @@
33 * 33 *
34 */ 34 */
35 35
36#define IO_IRAM_PHYS 0x40000000
37#define IO_IRAM_VIRT 0xFE400000
38#define IO_IRAM_SIZE SZ_256K
39
36#define IO_CPU_PHYS 0x50040000 40#define IO_CPU_PHYS 0x50040000
37#define IO_CPU_VIRT 0xFE000000 41#define IO_CPU_VIRT 0xFE000000
38#define IO_CPU_SIZE SZ_16K 42#define IO_CPU_SIZE SZ_16K
@@ -55,6 +59,8 @@
55 IO_TO_VIRT_XLATE((n), IO_APB_PHYS, IO_APB_VIRT) : \ 59 IO_TO_VIRT_XLATE((n), IO_APB_PHYS, IO_APB_VIRT) : \
56 IO_TO_VIRT_BETWEEN((n), IO_CPU_PHYS, IO_CPU_SIZE) ? \ 60 IO_TO_VIRT_BETWEEN((n), IO_CPU_PHYS, IO_CPU_SIZE) ? \
57 IO_TO_VIRT_XLATE((n), IO_CPU_PHYS, IO_CPU_VIRT) : \ 61 IO_TO_VIRT_XLATE((n), IO_CPU_PHYS, IO_CPU_VIRT) : \
62 IO_TO_VIRT_BETWEEN((n), IO_IRAM_PHYS, IO_IRAM_SIZE) ? \
63 IO_TO_VIRT_XLATE((n), IO_IRAM_PHYS, IO_IRAM_VIRT) : \
58 0) 64 0)
59 65
60#ifndef __ASSEMBLER__ 66#ifndef __ASSEMBLER__
@@ -67,10 +73,20 @@ void tegra_iounmap(volatile void __iomem *addr);
67 73
68#define IO_ADDRESS(n) ((void __iomem *) IO_TO_VIRT(n)) 74#define IO_ADDRESS(n) ((void __iomem *) IO_TO_VIRT(n))
69 75
76#ifdef CONFIG_TEGRA_PCI
77extern void __iomem *tegra_pcie_io_base;
78
79static inline void __iomem *__io(unsigned long addr)
80{
81 return tegra_pcie_io_base + (addr & IO_SPACE_LIMIT);
82}
83#else
70static inline void __iomem *__io(unsigned long addr) 84static inline void __iomem *__io(unsigned long addr)
71{ 85{
72 return (void __iomem *)addr; 86 return (void __iomem *)addr;
73} 87}
88#endif
89
74#define __io(a) __io(a) 90#define __io(a) __io(a)
75#define __mem_pci(a) (a) 91#define __mem_pci(a) (a)
76 92
diff --git a/arch/arm/mach-tegra/include/mach/iomap.h b/arch/arm/mach-tegra/include/mach/iomap.h
index 1741f7dd7a9b..44a4f4bcf91f 100644
--- a/arch/arm/mach-tegra/include/mach/iomap.h
+++ b/arch/arm/mach-tegra/include/mach/iomap.h
@@ -23,9 +23,15 @@
23 23
24#include <asm/sizes.h> 24#include <asm/sizes.h>
25 25
26#define TEGRA_IRAM_BASE 0x40000000
27#define TEGRA_IRAM_SIZE SZ_256K
28
26#define TEGRA_ARM_PERIF_BASE 0x50040000 29#define TEGRA_ARM_PERIF_BASE 0x50040000
27#define TEGRA_ARM_PERIF_SIZE SZ_8K 30#define TEGRA_ARM_PERIF_SIZE SZ_8K
28 31
32#define TEGRA_ARM_PL310_BASE 0x50043000
33#define TEGRA_ARM_PL310_SIZE SZ_4K
34
29#define TEGRA_ARM_INT_DIST_BASE 0x50041000 35#define TEGRA_ARM_INT_DIST_BASE 0x50041000
30#define TEGRA_ARM_INT_DIST_SIZE SZ_4K 36#define TEGRA_ARM_INT_DIST_SIZE SZ_4K
31 37
@@ -68,7 +74,22 @@
68#define TEGRA_FLOW_CTRL_BASE 0x60007000 74#define TEGRA_FLOW_CTRL_BASE 0x60007000
69#define TEGRA_FLOW_CTRL_SIZE 20 75#define TEGRA_FLOW_CTRL_SIZE 20
70 76
71#define TEGRA_STATMON_BASE 0x6000C4000 77#define TEGRA_AHB_DMA_BASE 0x60008000
78#define TEGRA_AHB_DMA_SIZE SZ_4K
79
80#define TEGRA_AHB_DMA_CH0_BASE 0x60009000
81#define TEGRA_AHB_DMA_CH0_SIZE 32
82
83#define TEGRA_APB_DMA_BASE 0x6000A000
84#define TEGRA_APB_DMA_SIZE SZ_4K
85
86#define TEGRA_APB_DMA_CH0_BASE 0x6000B000
87#define TEGRA_APB_DMA_CH0_SIZE 32
88
89#define TEGRA_AHB_GIZMO_BASE 0x6000C004
90#define TEGRA_AHB_GIZMO_SIZE 0x10C
91
92#define TEGRA_STATMON_BASE 0x6000C400
72#define TEGRA_STATMON_SIZE SZ_1K 93#define TEGRA_STATMON_SIZE SZ_1K
73 94
74#define TEGRA_GPIO_BASE 0x6000D000 95#define TEGRA_GPIO_BASE 0x6000D000
@@ -137,7 +158,7 @@
137#define TEGRA_I2C3_BASE 0x7000C500 158#define TEGRA_I2C3_BASE 0x7000C500
138#define TEGRA_I2C3_SIZE SZ_256 159#define TEGRA_I2C3_SIZE SZ_256
139 160
140#define TEGRA_OWR_BASE 0x7000D000 161#define TEGRA_OWR_BASE 0x7000C600
141#define TEGRA_OWR_SIZE 80 162#define TEGRA_OWR_SIZE 80
142 163
143#define TEGRA_DVC_BASE 0x7000D000 164#define TEGRA_DVC_BASE 0x7000D000
@@ -182,12 +203,12 @@
182#define TEGRA_USB_BASE 0xC5000000 203#define TEGRA_USB_BASE 0xC5000000
183#define TEGRA_USB_SIZE SZ_16K 204#define TEGRA_USB_SIZE SZ_16K
184 205
185#define TEGRA_USB1_BASE 0xC5004000 206#define TEGRA_USB2_BASE 0xC5004000
186#define TEGRA_USB1_SIZE SZ_16K
187
188#define TEGRA_USB2_BASE 0xC5008000
189#define TEGRA_USB2_SIZE SZ_16K 207#define TEGRA_USB2_SIZE SZ_16K
190 208
209#define TEGRA_USB3_BASE 0xC5008000
210#define TEGRA_USB3_SIZE SZ_16K
211
191#define TEGRA_SDMMC1_BASE 0xC8000000 212#define TEGRA_SDMMC1_BASE 0xC8000000
192#define TEGRA_SDMMC1_SIZE SZ_512 213#define TEGRA_SDMMC1_SIZE SZ_512
193 214
diff --git a/arch/arm/mach-tegra/include/mach/irqs.h b/arch/arm/mach-tegra/include/mach/irqs.h
index 20f640edaa0d..71bbf3422953 100644
--- a/arch/arm/mach-tegra/include/mach/irqs.h
+++ b/arch/arm/mach-tegra/include/mach/irqs.h
@@ -25,6 +25,7 @@
25 25
26#define IRQ_LOCALTIMER 29 26#define IRQ_LOCALTIMER 29
27 27
28#ifdef CONFIG_ARCH_TEGRA_2x_SOC
28/* Primary Interrupt Controller */ 29/* Primary Interrupt Controller */
29#define INT_PRI_BASE (INT_GIC_BASE + 32) 30#define INT_PRI_BASE (INT_GIC_BASE + 32)
30#define INT_TMR1 (INT_PRI_BASE + 0) 31#define INT_TMR1 (INT_PRI_BASE + 0)
@@ -169,5 +170,6 @@
169#define INT_GPIO_NR (28 * 8) 170#define INT_GPIO_NR (28 * 8)
170 171
171#define NR_IRQS (INT_GPIO_BASE + INT_GPIO_NR) 172#define NR_IRQS (INT_GPIO_BASE + INT_GPIO_NR)
173#endif
172 174
173#endif 175#endif
diff --git a/arch/arm/mach-tegra/include/mach/legacy_irq.h b/arch/arm/mach-tegra/include/mach/legacy_irq.h
new file mode 100644
index 000000000000..db1eb3dd04c8
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/legacy_irq.h
@@ -0,0 +1,31 @@
1/*
2 * arch/arm/mach-tegra/include/mach/legacy_irq.h
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Colin Cross <ccross@android.com>
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_TEGRA_LEGARY_IRQ_H
19#define _ARCH_ARM_MACH_TEGRA_LEGARY_IRQ_H
20
21void tegra_legacy_mask_irq(unsigned int irq);
22void tegra_legacy_unmask_irq(unsigned int irq);
23void tegra_legacy_select_fiq(unsigned int irq, bool fiq);
24void tegra_legacy_force_irq_set(unsigned int irq);
25void tegra_legacy_force_irq_clr(unsigned int irq);
26int tegra_legacy_force_irq_status(unsigned int irq);
27void tegra_legacy_select_fiq(unsigned int irq, bool fiq);
28unsigned long tegra_legacy_vfiq(int nr);
29unsigned long tegra_legacy_class(int nr);
30
31#endif
diff --git a/arch/arm/mach-tegra/include/mach/pinmux-t2.h b/arch/arm/mach-tegra/include/mach/pinmux-t2.h
new file mode 100644
index 000000000000..e5b9d740f973
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/pinmux-t2.h
@@ -0,0 +1,174 @@
1/*
2 * linux/arch/arm/mach-tegra/include/mach/pinmux-t2.h
3 *
4 * Copyright (C) 2010 Google, Inc.
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
17#ifndef __MACH_TEGRA_PINMUX_T2_H
18#define __MACH_TEGRA_PINMUX_T2_H
19
20enum tegra_pingroup {
21 TEGRA_PINGROUP_ATA = 0,
22 TEGRA_PINGROUP_ATB,
23 TEGRA_PINGROUP_ATC,
24 TEGRA_PINGROUP_ATD,
25 TEGRA_PINGROUP_ATE,
26 TEGRA_PINGROUP_CDEV1,
27 TEGRA_PINGROUP_CDEV2,
28 TEGRA_PINGROUP_CRTP,
29 TEGRA_PINGROUP_CSUS,
30 TEGRA_PINGROUP_DAP1,
31 TEGRA_PINGROUP_DAP2,
32 TEGRA_PINGROUP_DAP3,
33 TEGRA_PINGROUP_DAP4,
34 TEGRA_PINGROUP_DDC,
35 TEGRA_PINGROUP_DTA,
36 TEGRA_PINGROUP_DTB,
37 TEGRA_PINGROUP_DTC,
38 TEGRA_PINGROUP_DTD,
39 TEGRA_PINGROUP_DTE,
40 TEGRA_PINGROUP_DTF,
41 TEGRA_PINGROUP_GMA,
42 TEGRA_PINGROUP_GMB,
43 TEGRA_PINGROUP_GMC,
44 TEGRA_PINGROUP_GMD,
45 TEGRA_PINGROUP_GME,
46 TEGRA_PINGROUP_GPU,
47 TEGRA_PINGROUP_GPU7,
48 TEGRA_PINGROUP_GPV,
49 TEGRA_PINGROUP_HDINT,
50 TEGRA_PINGROUP_I2CP,
51 TEGRA_PINGROUP_IRRX,
52 TEGRA_PINGROUP_IRTX,
53 TEGRA_PINGROUP_KBCA,
54 TEGRA_PINGROUP_KBCB,
55 TEGRA_PINGROUP_KBCC,
56 TEGRA_PINGROUP_KBCD,
57 TEGRA_PINGROUP_KBCE,
58 TEGRA_PINGROUP_KBCF,
59 TEGRA_PINGROUP_LCSN,
60 TEGRA_PINGROUP_LD0,
61 TEGRA_PINGROUP_LD1,
62 TEGRA_PINGROUP_LD10,
63 TEGRA_PINGROUP_LD11,
64 TEGRA_PINGROUP_LD12,
65 TEGRA_PINGROUP_LD13,
66 TEGRA_PINGROUP_LD14,
67 TEGRA_PINGROUP_LD15,
68 TEGRA_PINGROUP_LD16,
69 TEGRA_PINGROUP_LD17,
70 TEGRA_PINGROUP_LD2,
71 TEGRA_PINGROUP_LD3,
72 TEGRA_PINGROUP_LD4,
73 TEGRA_PINGROUP_LD5,
74 TEGRA_PINGROUP_LD6,
75 TEGRA_PINGROUP_LD7,
76 TEGRA_PINGROUP_LD8,
77 TEGRA_PINGROUP_LD9,
78 TEGRA_PINGROUP_LDC,
79 TEGRA_PINGROUP_LDI,
80 TEGRA_PINGROUP_LHP0,
81 TEGRA_PINGROUP_LHP1,
82 TEGRA_PINGROUP_LHP2,
83 TEGRA_PINGROUP_LHS,
84 TEGRA_PINGROUP_LM0,
85 TEGRA_PINGROUP_LM1,
86 TEGRA_PINGROUP_LPP,
87 TEGRA_PINGROUP_LPW0,
88 TEGRA_PINGROUP_LPW1,
89 TEGRA_PINGROUP_LPW2,
90 TEGRA_PINGROUP_LSC0,
91 TEGRA_PINGROUP_LSC1,
92 TEGRA_PINGROUP_LSCK,
93 TEGRA_PINGROUP_LSDA,
94 TEGRA_PINGROUP_LSDI,
95 TEGRA_PINGROUP_LSPI,
96 TEGRA_PINGROUP_LVP0,
97 TEGRA_PINGROUP_LVP1,
98 TEGRA_PINGROUP_LVS,
99 TEGRA_PINGROUP_OWC,
100 TEGRA_PINGROUP_PMC,
101 TEGRA_PINGROUP_PTA,
102 TEGRA_PINGROUP_RM,
103 TEGRA_PINGROUP_SDB,
104 TEGRA_PINGROUP_SDC,
105 TEGRA_PINGROUP_SDD,
106 TEGRA_PINGROUP_SDIO1,
107 TEGRA_PINGROUP_SLXA,
108 TEGRA_PINGROUP_SLXC,
109 TEGRA_PINGROUP_SLXD,
110 TEGRA_PINGROUP_SLXK,
111 TEGRA_PINGROUP_SPDI,
112 TEGRA_PINGROUP_SPDO,
113 TEGRA_PINGROUP_SPIA,
114 TEGRA_PINGROUP_SPIB,
115 TEGRA_PINGROUP_SPIC,
116 TEGRA_PINGROUP_SPID,
117 TEGRA_PINGROUP_SPIE,
118 TEGRA_PINGROUP_SPIF,
119 TEGRA_PINGROUP_SPIG,
120 TEGRA_PINGROUP_SPIH,
121 TEGRA_PINGROUP_UAA,
122 TEGRA_PINGROUP_UAB,
123 TEGRA_PINGROUP_UAC,
124 TEGRA_PINGROUP_UAD,
125 TEGRA_PINGROUP_UCA,
126 TEGRA_PINGROUP_UCB,
127 TEGRA_PINGROUP_UDA,
128 /* these pin groups only have pullup and pull down control */
129 TEGRA_PINGROUP_CK32,
130 TEGRA_PINGROUP_DDRC,
131 TEGRA_PINGROUP_PMCA,
132 TEGRA_PINGROUP_PMCB,
133 TEGRA_PINGROUP_PMCC,
134 TEGRA_PINGROUP_PMCD,
135 TEGRA_PINGROUP_PMCE,
136 TEGRA_PINGROUP_XM2C,
137 TEGRA_PINGROUP_XM2D,
138 TEGRA_MAX_PINGROUP,
139};
140
141enum tegra_drive_pingroup {
142 TEGRA_DRIVE_PINGROUP_AO1 = 0,
143 TEGRA_DRIVE_PINGROUP_AO2,
144 TEGRA_DRIVE_PINGROUP_AT1,
145 TEGRA_DRIVE_PINGROUP_AT2,
146 TEGRA_DRIVE_PINGROUP_CDEV1,
147 TEGRA_DRIVE_PINGROUP_CDEV2,
148 TEGRA_DRIVE_PINGROUP_CSUS,
149 TEGRA_DRIVE_PINGROUP_DAP1,
150 TEGRA_DRIVE_PINGROUP_DAP2,
151 TEGRA_DRIVE_PINGROUP_DAP3,
152 TEGRA_DRIVE_PINGROUP_DAP4,
153 TEGRA_DRIVE_PINGROUP_DBG,
154 TEGRA_DRIVE_PINGROUP_LCD1,
155 TEGRA_DRIVE_PINGROUP_LCD2,
156 TEGRA_DRIVE_PINGROUP_SDMMC2,
157 TEGRA_DRIVE_PINGROUP_SDMMC3,
158 TEGRA_DRIVE_PINGROUP_SPI,
159 TEGRA_DRIVE_PINGROUP_UAA,
160 TEGRA_DRIVE_PINGROUP_UAB,
161 TEGRA_DRIVE_PINGROUP_UART2,
162 TEGRA_DRIVE_PINGROUP_UART3,
163 TEGRA_DRIVE_PINGROUP_VI1,
164 TEGRA_DRIVE_PINGROUP_VI2,
165 TEGRA_DRIVE_PINGROUP_XM2A,
166 TEGRA_DRIVE_PINGROUP_XM2C,
167 TEGRA_DRIVE_PINGROUP_XM2D,
168 TEGRA_DRIVE_PINGROUP_XM2CLK,
169 TEGRA_DRIVE_PINGROUP_MEMCOMP,
170 TEGRA_MAX_DRIVE_PINGROUP,
171};
172
173#endif
174
diff --git a/arch/arm/mach-tegra/include/mach/pinmux.h b/arch/arm/mach-tegra/include/mach/pinmux.h
index 41c8ce5b7c27..defd8775defa 100644
--- a/arch/arm/mach-tegra/include/mach/pinmux.h
+++ b/arch/arm/mach-tegra/include/mach/pinmux.h
@@ -17,126 +17,11 @@
17#ifndef __MACH_TEGRA_PINMUX_H 17#ifndef __MACH_TEGRA_PINMUX_H
18#define __MACH_TEGRA_PINMUX_H 18#define __MACH_TEGRA_PINMUX_H
19 19
20enum tegra_pingroup { 20#if defined(CONFIG_ARCH_TEGRA_2x_SOC)
21 TEGRA_PINGROUP_ATA = 0, 21#include "pinmux-t2.h"
22 TEGRA_PINGROUP_ATB, 22#else
23 TEGRA_PINGROUP_ATC, 23#error "Undefined Tegra architecture"
24 TEGRA_PINGROUP_ATD, 24#endif
25 TEGRA_PINGROUP_ATE,
26 TEGRA_PINGROUP_CDEV1,
27 TEGRA_PINGROUP_CDEV2,
28 TEGRA_PINGROUP_CRTP,
29 TEGRA_PINGROUP_CSUS,
30 TEGRA_PINGROUP_DAP1,
31 TEGRA_PINGROUP_DAP2,
32 TEGRA_PINGROUP_DAP3,
33 TEGRA_PINGROUP_DAP4,
34 TEGRA_PINGROUP_DDC,
35 TEGRA_PINGROUP_DTA,
36 TEGRA_PINGROUP_DTB,
37 TEGRA_PINGROUP_DTC,
38 TEGRA_PINGROUP_DTD,
39 TEGRA_PINGROUP_DTE,
40 TEGRA_PINGROUP_DTF,
41 TEGRA_PINGROUP_GMA,
42 TEGRA_PINGROUP_GMB,
43 TEGRA_PINGROUP_GMC,
44 TEGRA_PINGROUP_GMD,
45 TEGRA_PINGROUP_GME,
46 TEGRA_PINGROUP_GPU,
47 TEGRA_PINGROUP_GPU7,
48 TEGRA_PINGROUP_GPV,
49 TEGRA_PINGROUP_HDINT,
50 TEGRA_PINGROUP_I2CP,
51 TEGRA_PINGROUP_IRRX,
52 TEGRA_PINGROUP_IRTX,
53 TEGRA_PINGROUP_KBCA,
54 TEGRA_PINGROUP_KBCB,
55 TEGRA_PINGROUP_KBCC,
56 TEGRA_PINGROUP_KBCD,
57 TEGRA_PINGROUP_KBCE,
58 TEGRA_PINGROUP_KBCF,
59 TEGRA_PINGROUP_LCSN,
60 TEGRA_PINGROUP_LD0,
61 TEGRA_PINGROUP_LD1,
62 TEGRA_PINGROUP_LD10,
63 TEGRA_PINGROUP_LD11,
64 TEGRA_PINGROUP_LD12,
65 TEGRA_PINGROUP_LD13,
66 TEGRA_PINGROUP_LD14,
67 TEGRA_PINGROUP_LD15,
68 TEGRA_PINGROUP_LD16,
69 TEGRA_PINGROUP_LD17,
70 TEGRA_PINGROUP_LD2,
71 TEGRA_PINGROUP_LD3,
72 TEGRA_PINGROUP_LD4,
73 TEGRA_PINGROUP_LD5,
74 TEGRA_PINGROUP_LD6,
75 TEGRA_PINGROUP_LD7,
76 TEGRA_PINGROUP_LD8,
77 TEGRA_PINGROUP_LD9,
78 TEGRA_PINGROUP_LDC,
79 TEGRA_PINGROUP_LDI,
80 TEGRA_PINGROUP_LHP0,
81 TEGRA_PINGROUP_LHP1,
82 TEGRA_PINGROUP_LHP2,
83 TEGRA_PINGROUP_LHS,
84 TEGRA_PINGROUP_LM0,
85 TEGRA_PINGROUP_LM1,
86 TEGRA_PINGROUP_LPP,
87 TEGRA_PINGROUP_LPW0,
88 TEGRA_PINGROUP_LPW1,
89 TEGRA_PINGROUP_LPW2,
90 TEGRA_PINGROUP_LSC0,
91 TEGRA_PINGROUP_LSC1,
92 TEGRA_PINGROUP_LSCK,
93 TEGRA_PINGROUP_LSDA,
94 TEGRA_PINGROUP_LSDI,
95 TEGRA_PINGROUP_LSPI,
96 TEGRA_PINGROUP_LVP0,
97 TEGRA_PINGROUP_LVP1,
98 TEGRA_PINGROUP_LVS,
99 TEGRA_PINGROUP_OWC,
100 TEGRA_PINGROUP_PMC,
101 TEGRA_PINGROUP_PTA,
102 TEGRA_PINGROUP_RM,
103 TEGRA_PINGROUP_SDB,
104 TEGRA_PINGROUP_SDC,
105 TEGRA_PINGROUP_SDD,
106 TEGRA_PINGROUP_SDIO1,
107 TEGRA_PINGROUP_SLXA,
108 TEGRA_PINGROUP_SLXC,
109 TEGRA_PINGROUP_SLXD,
110 TEGRA_PINGROUP_SLXK,
111 TEGRA_PINGROUP_SPDI,
112 TEGRA_PINGROUP_SPDO,
113 TEGRA_PINGROUP_SPIA,
114 TEGRA_PINGROUP_SPIB,
115 TEGRA_PINGROUP_SPIC,
116 TEGRA_PINGROUP_SPID,
117 TEGRA_PINGROUP_SPIE,
118 TEGRA_PINGROUP_SPIF,
119 TEGRA_PINGROUP_SPIG,
120 TEGRA_PINGROUP_SPIH,
121 TEGRA_PINGROUP_UAA,
122 TEGRA_PINGROUP_UAB,
123 TEGRA_PINGROUP_UAC,
124 TEGRA_PINGROUP_UAD,
125 TEGRA_PINGROUP_UCA,
126 TEGRA_PINGROUP_UCB,
127 TEGRA_PINGROUP_UDA,
128 /* these pin groups only have pullup and pull down control */
129 TEGRA_PINGROUP_CK32,
130 TEGRA_PINGROUP_DDRC,
131 TEGRA_PINGROUP_PMCA,
132 TEGRA_PINGROUP_PMCB,
133 TEGRA_PINGROUP_PMCC,
134 TEGRA_PINGROUP_PMCD,
135 TEGRA_PINGROUP_PMCE,
136 TEGRA_PINGROUP_XM2C,
137 TEGRA_PINGROUP_XM2D,
138 TEGRA_MAX_PINGROUP,
139};
140 25
141enum tegra_mux_func { 26enum tegra_mux_func {
142 TEGRA_MUX_RSVD = 0x8000, 27 TEGRA_MUX_RSVD = 0x8000,
@@ -205,6 +90,7 @@ enum tegra_mux_func {
205 TEGRA_MUX_VI, 90 TEGRA_MUX_VI,
206 TEGRA_MUX_VI_SENSOR_CLK, 91 TEGRA_MUX_VI_SENSOR_CLK,
207 TEGRA_MUX_XIO, 92 TEGRA_MUX_XIO,
93 TEGRA_MUX_SAFE,
208 TEGRA_MAX_MUX, 94 TEGRA_MAX_MUX,
209}; 95};
210 96
@@ -219,6 +105,18 @@ enum tegra_tristate {
219 TEGRA_TRI_TRISTATE = 1, 105 TEGRA_TRI_TRISTATE = 1,
220}; 106};
221 107
108enum tegra_vddio {
109 TEGRA_VDDIO_BB = 0,
110 TEGRA_VDDIO_LCD,
111 TEGRA_VDDIO_VI,
112 TEGRA_VDDIO_UART,
113 TEGRA_VDDIO_DDR,
114 TEGRA_VDDIO_NAND,
115 TEGRA_VDDIO_SYS,
116 TEGRA_VDDIO_AUDIO,
117 TEGRA_VDDIO_SD,
118};
119
222struct tegra_pingroup_config { 120struct tegra_pingroup_config {
223 enum tegra_pingroup pingroup; 121 enum tegra_pingroup pingroup;
224 enum tegra_mux_func func; 122 enum tegra_mux_func func;
@@ -270,38 +168,6 @@ enum tegra_pull_strength {
270 TEGRA_MAX_PULL, 168 TEGRA_MAX_PULL,
271}; 169};
272 170
273enum tegra_drive_pingroup {
274 TEGRA_DRIVE_PINGROUP_AO1 = 0,
275 TEGRA_DRIVE_PINGROUP_AO2,
276 TEGRA_DRIVE_PINGROUP_AT1,
277 TEGRA_DRIVE_PINGROUP_AT2,
278 TEGRA_DRIVE_PINGROUP_CDEV1,
279 TEGRA_DRIVE_PINGROUP_CDEV2,
280 TEGRA_DRIVE_PINGROUP_CSUS,
281 TEGRA_DRIVE_PINGROUP_DAP1,
282 TEGRA_DRIVE_PINGROUP_DAP2,
283 TEGRA_DRIVE_PINGROUP_DAP3,
284 TEGRA_DRIVE_PINGROUP_DAP4,
285 TEGRA_DRIVE_PINGROUP_DBG,
286 TEGRA_DRIVE_PINGROUP_LCD1,
287 TEGRA_DRIVE_PINGROUP_LCD2,
288 TEGRA_DRIVE_PINGROUP_SDMMC2,
289 TEGRA_DRIVE_PINGROUP_SDMMC3,
290 TEGRA_DRIVE_PINGROUP_SPI,
291 TEGRA_DRIVE_PINGROUP_UAA,
292 TEGRA_DRIVE_PINGROUP_UAB,
293 TEGRA_DRIVE_PINGROUP_UART2,
294 TEGRA_DRIVE_PINGROUP_UART3,
295 TEGRA_DRIVE_PINGROUP_VI1,
296 TEGRA_DRIVE_PINGROUP_VI2,
297 TEGRA_DRIVE_PINGROUP_XM2A,
298 TEGRA_DRIVE_PINGROUP_XM2C,
299 TEGRA_DRIVE_PINGROUP_XM2D,
300 TEGRA_DRIVE_PINGROUP_XM2CLK,
301 TEGRA_DRIVE_PINGROUP_MEMCOMP,
302 TEGRA_MAX_DRIVE_PINGROUP,
303};
304
305enum tegra_drive { 171enum tegra_drive {
306 TEGRA_DRIVE_DIV_8 = 0, 172 TEGRA_DRIVE_DIV_8 = 0,
307 TEGRA_DRIVE_DIV_4, 173 TEGRA_DRIVE_DIV_4,
@@ -331,18 +197,44 @@ struct tegra_drive_pingroup_config {
331 enum tegra_slew slew_falling; 197 enum tegra_slew slew_falling;
332}; 198};
333 199
334int tegra_pinmux_set_func(enum tegra_pingroup pg, enum tegra_mux_func func); 200struct tegra_drive_pingroup_desc {
335int tegra_pinmux_set_tristate(enum tegra_pingroup pg, enum tegra_tristate tristate); 201 const char *name;
336int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg, enum tegra_pullupdown pupd); 202 s16 reg;
203};
204
205struct tegra_pingroup_desc {
206 const char *name;
207 int funcs[4];
208 int func_safe;
209 int vddio;
210 s16 tri_reg; /* offset into the TRISTATE_REG_* register bank */
211 s16 mux_reg; /* offset into the PIN_MUX_CTL_* register bank */
212 s16 pupd_reg; /* offset into the PULL_UPDOWN_REG_* register bank */
213 s8 tri_bit; /* offset into the TRISTATE_REG_* register bit */
214 s8 mux_bit; /* offset into the PIN_MUX_CTL_* register bit */
215 s8 pupd_bit; /* offset into the PULL_UPDOWN_REG_* register bit */
216};
217
218extern const struct tegra_pingroup_desc tegra_soc_pingroups[];
219extern const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[];
337 220
338void tegra_pinmux_config_pingroup(enum tegra_pingroup pingroup, 221int tegra_pinmux_set_tristate(enum tegra_pingroup pg,
339 enum tegra_mux_func func, enum tegra_pullupdown pupd,
340 enum tegra_tristate tristate); 222 enum tegra_tristate tristate);
223int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg,
224 enum tegra_pullupdown pupd);
341 225
342void tegra_pinmux_config_table(struct tegra_pingroup_config *config, int len); 226void tegra_pinmux_config_table(const struct tegra_pingroup_config *config,
227 int len);
343 228
344void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config *config, 229void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config *config,
345 int len); 230 int len);
346 231void tegra_pinmux_set_safe_pinmux_table(const struct tegra_pingroup_config *config,
232 int len);
233void tegra_pinmux_config_pinmux_table(const struct tegra_pingroup_config *config,
234 int len);
235void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config *config,
236 int len, enum tegra_tristate tristate);
237void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *config,
238 int len, enum tegra_pullupdown pupd);
347#endif 239#endif
348 240
diff --git a/arch/arm/mach-tegra/io.c b/arch/arm/mach-tegra/io.c
index 9fe2c5c683d4..31848a9592f8 100644
--- a/arch/arm/mach-tegra/io.c
+++ b/arch/arm/mach-tegra/io.c
@@ -49,6 +49,12 @@ static struct map_desc tegra_io_desc[] __initdata = {
49 .length = IO_CPU_SIZE, 49 .length = IO_CPU_SIZE,
50 .type = MT_DEVICE, 50 .type = MT_DEVICE,
51 }, 51 },
52 {
53 .virtual = IO_IRAM_VIRT,
54 .pfn = __phys_to_pfn(IO_IRAM_PHYS),
55 .length = IO_IRAM_SIZE,
56 .type = MT_DEVICE,
57 },
52}; 58};
53 59
54void __init tegra_map_common_io(void) 60void __init tegra_map_common_io(void)
diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
index 1fdbe708d43d..50a8dfb9a0cf 100644
--- a/arch/arm/mach-tegra/irq.c
+++ b/arch/arm/mach-tegra/irq.c
@@ -4,6 +4,8 @@
4 * Author: 4 * Author:
5 * Colin Cross <ccross@google.com> 5 * Colin Cross <ccross@google.com>
6 * 6 *
7 * Copyright (C) 2010, NVIDIA Corporation
8 *
7 * This software is licensed under the terms of the GNU General Public 9 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and 10 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms. 11 * may be copied, distributed, and modified under those terms.
@@ -27,8 +29,143 @@
27 29
28#include "board.h" 30#include "board.h"
29 31
32#define INT_SYS_NR (INT_GPIO_BASE - INT_PRI_BASE)
33#define INT_SYS_SZ (INT_SEC_BASE - INT_PRI_BASE)
34#define PPI_NR ((INT_SYS_NR+INT_SYS_SZ-1)/INT_SYS_SZ)
35
36#define APBDMA_IRQ_STA_CPU 0x14
37#define APBDMA_IRQ_MASK_SET 0x20
38#define APBDMA_IRQ_MASK_CLR 0x24
39
40#define ICTLR_CPU_IER 0x20
41#define ICTLR_CPU_IER_SET 0x24
42#define ICTLR_CPU_IER_CLR 0x28
43#define ICTLR_CPU_IEP_CLASS 0x2c
44#define ICTLR_COP_IER 0x30
45#define ICTLR_COP_IER_SET 0x34
46#define ICTLR_COP_IER_CLR 0x38
47#define ICTLR_COP_IEP_CLASS 0x3c
48
49static void (*gic_mask_irq)(unsigned int irq);
50static void (*gic_unmask_irq)(unsigned int irq);
51
52#define irq_to_ictlr(irq) (((irq)-32) >> 5)
53static void __iomem *tegra_ictlr_base = IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE);
54#define ictlr_to_virt(ictlr) (tegra_ictlr_base + (ictlr)*0x100)
55
56static void tegra_mask(unsigned int irq)
57{
58 void __iomem *addr = ictlr_to_virt(irq_to_ictlr(irq));
59 gic_mask_irq(irq);
60 writel(1<<(irq&31), addr+ICTLR_CPU_IER_CLR);
61}
62
63static void tegra_unmask(unsigned int irq)
64{
65 void __iomem *addr = ictlr_to_virt(irq_to_ictlr(irq));
66 gic_unmask_irq(irq);
67 writel(1<<(irq&31), addr+ICTLR_CPU_IER_SET);
68}
69
70#ifdef CONFIG_PM
71
72static int tegra_set_wake(unsigned int irq, unsigned int on)
73{
74 return 0;
75}
76#endif
77
78static struct irq_chip tegra_irq = {
79 .name = "PPI",
80 .mask = tegra_mask,
81 .unmask = tegra_unmask,
82#ifdef CONFIG_PM
83 .set_wake = tegra_set_wake,
84#endif
85};
86
30void __init tegra_init_irq(void) 87void __init tegra_init_irq(void)
31{ 88{
89 struct irq_chip *gic;
90 unsigned int i;
91
92 for (i = 0; i < PPI_NR; i++) {
93 writel(~0, ictlr_to_virt(i) + ICTLR_CPU_IER_CLR);
94 writel(0, ictlr_to_virt(i) + ICTLR_CPU_IEP_CLASS);
95 }
96
32 gic_dist_init(0, IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE), 29); 97 gic_dist_init(0, IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE), 29);
33 gic_cpu_init(0, IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100)); 98 gic_cpu_init(0, IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100));
99
100 gic = get_irq_chip(29);
101 gic_unmask_irq = gic->unmask;
102 gic_mask_irq = gic->mask;
103 tegra_irq.ack = gic->ack;
104#ifdef CONFIG_SMP
105 tegra_irq.set_affinity = gic->set_affinity;
106#endif
107
108 for (i = INT_PRI_BASE; i < INT_GPIO_BASE; i++) {
109 set_irq_chip(i, &tegra_irq);
110 set_irq_handler(i, handle_level_irq);
111 set_irq_flags(i, IRQF_VALID);
112 }
113}
114
115#ifdef CONFIG_PM
116static u32 cop_ier[PPI_NR];
117static u32 cpu_ier[PPI_NR];
118static u32 cpu_iep[PPI_NR];
119
120void tegra_irq_suspend(void)
121{
122 unsigned long flags;
123 int i;
124
125 for (i = INT_PRI_BASE; i < INT_GPIO_BASE; i++) {
126 struct irq_desc *desc = irq_to_desc(i);
127 if (!desc)
128 continue;
129 if (desc->status & IRQ_WAKEUP) {
130 pr_debug("irq %d is wakeup\n", i);
131 continue;
132 }
133 disable_irq(i);
134 }
135
136 local_irq_save(flags);
137 for (i = 0; i < PPI_NR; i++) {
138 void __iomem *ictlr = ictlr_to_virt(i);
139 cpu_ier[i] = readl(ictlr + ICTLR_CPU_IER);
140 cpu_iep[i] = readl(ictlr + ICTLR_CPU_IEP_CLASS);
141 cop_ier[i] = readl(ictlr + ICTLR_COP_IER);
142 writel(~0, ictlr + ICTLR_COP_IER_CLR);
143 }
144 local_irq_restore(flags);
145}
146
147void tegra_irq_resume(void)
148{
149 unsigned long flags;
150 int i;
151
152 local_irq_save(flags);
153 for (i = 0; i < PPI_NR; i++) {
154 void __iomem *ictlr = ictlr_to_virt(i);
155 writel(cpu_iep[i], ictlr + ICTLR_CPU_IEP_CLASS);
156 writel(~0ul, ictlr + ICTLR_CPU_IER_CLR);
157 writel(cpu_ier[i], ictlr + ICTLR_CPU_IER_SET);
158 writel(0, ictlr + ICTLR_COP_IEP_CLASS);
159 writel(~0ul, ictlr + ICTLR_COP_IER_CLR);
160 writel(cop_ier[i], ictlr + ICTLR_COP_IER_SET);
161 }
162 local_irq_restore(flags);
163
164 for (i = INT_PRI_BASE; i < INT_GPIO_BASE; i++) {
165 struct irq_desc *desc = irq_to_desc(i);
166 if (!desc || (desc->status & IRQ_WAKEUP))
167 continue;
168 enable_irq(i);
169 }
34} 170}
171#endif
diff --git a/arch/arm/mach-tegra/legacy_irq.c b/arch/arm/mach-tegra/legacy_irq.c
new file mode 100644
index 000000000000..7cc8601c19ff
--- /dev/null
+++ b/arch/arm/mach-tegra/legacy_irq.c
@@ -0,0 +1,114 @@
1/*
2 * arch/arm/mach-tegra/legacy_irq.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Colin Cross <ccross@android.com>
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#include <linux/io.h>
19#include <linux/kernel.h>
20#include <mach/iomap.h>
21#include <mach/legacy_irq.h>
22
23#define ICTLR_CPU_IER 0x20
24#define ICTLR_CPU_IER_SET 0x24
25#define ICTLR_CPU_IER_CLR 0x28
26#define ICTLR_CPU_IEP_CLASS 0x2C
27#define ICTLR_CPU_IEP_VFIQ 0x08
28#define ICTLR_CPU_IEP_FIR 0x14
29#define ICTLR_CPU_IEP_FIR_SET 0x18
30#define ICTLR_CPU_IEP_FIR_CLR 0x1c
31
32static void __iomem *ictlr_reg_base[] = {
33 IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE),
34 IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE),
35 IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE),
36 IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE),
37};
38
39/* When going into deep sleep, the CPU is powered down, taking the GIC with it
40 In order to wake, the wake interrupts need to be enabled in the legacy
41 interrupt controller. */
42void tegra_legacy_unmask_irq(unsigned int irq)
43{
44 void __iomem *base;
45 pr_debug("%s: %d\n", __func__, irq);
46
47 irq -= 32;
48 base = ictlr_reg_base[irq>>5];
49 writel(1 << (irq & 31), base + ICTLR_CPU_IER_SET);
50}
51
52void tegra_legacy_mask_irq(unsigned int irq)
53{
54 void __iomem *base;
55 pr_debug("%s: %d\n", __func__, irq);
56
57 irq -= 32;
58 base = ictlr_reg_base[irq>>5];
59 writel(1 << (irq & 31), base + ICTLR_CPU_IER_CLR);
60}
61
62void tegra_legacy_force_irq_set(unsigned int irq)
63{
64 void __iomem *base;
65 pr_debug("%s: %d\n", __func__, irq);
66
67 irq -= 32;
68 base = ictlr_reg_base[irq>>5];
69 writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_SET);
70}
71
72void tegra_legacy_force_irq_clr(unsigned int irq)
73{
74 void __iomem *base;
75 pr_debug("%s: %d\n", __func__, irq);
76
77 irq -= 32;
78 base = ictlr_reg_base[irq>>5];
79 writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_CLR);
80}
81
82int tegra_legacy_force_irq_status(unsigned int irq)
83{
84 void __iomem *base;
85 pr_debug("%s: %d\n", __func__, irq);
86
87 irq -= 32;
88 base = ictlr_reg_base[irq>>5];
89 return !!(readl(base + ICTLR_CPU_IEP_FIR) & (1 << (irq & 31)));
90}
91
92void tegra_legacy_select_fiq(unsigned int irq, bool fiq)
93{
94 void __iomem *base;
95 pr_debug("%s: %d\n", __func__, irq);
96
97 irq -= 32;
98 base = ictlr_reg_base[irq>>5];
99 writel(fiq << (irq & 31), base + ICTLR_CPU_IEP_CLASS);
100}
101
102unsigned long tegra_legacy_vfiq(int nr)
103{
104 void __iomem *base;
105 base = ictlr_reg_base[nr];
106 return readl(base + ICTLR_CPU_IEP_VFIQ);
107}
108
109unsigned long tegra_legacy_class(int nr)
110{
111 void __iomem *base;
112 base = ictlr_reg_base[nr];
113 return readl(base + ICTLR_CPU_IEP_CLASS);
114}
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c
new file mode 100644
index 000000000000..53f5fa37014a
--- /dev/null
+++ b/arch/arm/mach-tegra/pcie.c
@@ -0,0 +1,915 @@
1/*
2 * arch/arm/mach-tegra/pci.c
3 *
4 * PCIe host controller driver for TEGRA(2) SOCs
5 *
6 * Copyright (c) 2010, CompuLab, Ltd.
7 * Author: Mike Rapoport <mike@compulab.co.il>
8 *
9 * Based on NVIDIA PCIe driver
10 * Copyright (c) 2008-2009, NVIDIA Corporation.
11 *
12 * Bits taken from arch/arm/mach-dove/pcie.c
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but WITHOUT
20 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22 * more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28
29#include <linux/kernel.h>
30#include <linux/pci.h>
31#include <linux/interrupt.h>
32#include <linux/irq.h>
33#include <linux/clk.h>
34#include <linux/delay.h>
35
36#include <asm/sizes.h>
37#include <asm/mach/pci.h>
38
39#include <mach/pinmux.h>
40#include <mach/iomap.h>
41#include <mach/clk.h>
42
43/* register definitions */
44#define AFI_OFFSET 0x3800
45#define PADS_OFFSET 0x3000
46#define RP0_OFFSET 0x0000
47#define RP1_OFFSET 0x1000
48
49#define AFI_AXI_BAR0_SZ 0x00
50#define AFI_AXI_BAR1_SZ 0x04
51#define AFI_AXI_BAR2_SZ 0x08
52#define AFI_AXI_BAR3_SZ 0x0c
53#define AFI_AXI_BAR4_SZ 0x10
54#define AFI_AXI_BAR5_SZ 0x14
55
56#define AFI_AXI_BAR0_START 0x18
57#define AFI_AXI_BAR1_START 0x1c
58#define AFI_AXI_BAR2_START 0x20
59#define AFI_AXI_BAR3_START 0x24
60#define AFI_AXI_BAR4_START 0x28
61#define AFI_AXI_BAR5_START 0x2c
62
63#define AFI_FPCI_BAR0 0x30
64#define AFI_FPCI_BAR1 0x34
65#define AFI_FPCI_BAR2 0x38
66#define AFI_FPCI_BAR3 0x3c
67#define AFI_FPCI_BAR4 0x40
68#define AFI_FPCI_BAR5 0x44
69
70#define AFI_CACHE_BAR0_SZ 0x48
71#define AFI_CACHE_BAR0_ST 0x4c
72#define AFI_CACHE_BAR1_SZ 0x50
73#define AFI_CACHE_BAR1_ST 0x54
74
75#define AFI_MSI_BAR_SZ 0x60
76#define AFI_MSI_FPCI_BAR_ST 0x64
77#define AFI_MSI_AXI_BAR_ST 0x68
78
79#define AFI_CONFIGURATION 0xac
80#define AFI_CONFIGURATION_EN_FPCI (1 << 0)
81
82#define AFI_FPCI_ERROR_MASKS 0xb0
83
84#define AFI_INTR_MASK 0xb4
85#define AFI_INTR_MASK_INT_MASK (1 << 0)
86#define AFI_INTR_MASK_MSI_MASK (1 << 8)
87
88#define AFI_INTR_CODE 0xb8
89#define AFI_INTR_CODE_MASK 0xf
90#define AFI_INTR_MASTER_ABORT 4
91#define AFI_INTR_LEGACY 6
92
93#define AFI_INTR_SIGNATURE 0xbc
94#define AFI_SM_INTR_ENABLE 0xc4
95
96#define AFI_AFI_INTR_ENABLE 0xc8
97#define AFI_INTR_EN_INI_SLVERR (1 << 0)
98#define AFI_INTR_EN_INI_DECERR (1 << 1)
99#define AFI_INTR_EN_TGT_SLVERR (1 << 2)
100#define AFI_INTR_EN_TGT_DECERR (1 << 3)
101#define AFI_INTR_EN_TGT_WRERR (1 << 4)
102#define AFI_INTR_EN_DFPCI_DECERR (1 << 5)
103#define AFI_INTR_EN_AXI_DECERR (1 << 6)
104#define AFI_INTR_EN_FPCI_TIMEOUT (1 << 7)
105
106#define AFI_PCIE_CONFIG 0x0f8
107#define AFI_PCIE_CONFIG_PCIEC0_DISABLE_DEVICE (1 << 1)
108#define AFI_PCIE_CONFIG_PCIEC1_DISABLE_DEVICE (1 << 2)
109#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK (0xf << 20)
110#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE (0x0 << 20)
111#define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL (0x1 << 20)
112
113#define AFI_FUSE 0x104
114#define AFI_FUSE_PCIE_T0_GEN2_DIS (1 << 2)
115
116#define AFI_PEX0_CTRL 0x110
117#define AFI_PEX1_CTRL 0x118
118#define AFI_PEX_CTRL_RST (1 << 0)
119#define AFI_PEX_CTRL_REFCLK_EN (1 << 3)
120
121#define RP_VEND_XP 0x00000F00
122#define RP_VEND_XP_DL_UP (1 << 30)
123
124#define RP_LINK_CONTROL_STATUS 0x00000090
125#define RP_LINK_CONTROL_STATUS_LINKSTAT_MASK 0x3fff0000
126
127#define PADS_CTL_SEL 0x0000009C
128
129#define PADS_CTL 0x000000A0
130#define PADS_CTL_IDDQ_1L (1 << 0)
131#define PADS_CTL_TX_DATA_EN_1L (1 << 6)
132#define PADS_CTL_RX_DATA_EN_1L (1 << 10)
133
134#define PADS_PLL_CTL 0x000000B8
135#define PADS_PLL_CTL_RST_B4SM (1 << 1)
136#define PADS_PLL_CTL_LOCKDET (1 << 8)
137#define PADS_PLL_CTL_REFCLK_MASK (0x3 << 16)
138#define PADS_PLL_CTL_REFCLK_INTERNAL_CML (0 << 16)
139#define PADS_PLL_CTL_REFCLK_INTERNAL_CMOS (1 << 16)
140#define PADS_PLL_CTL_REFCLK_EXTERNAL (2 << 16)
141#define PADS_PLL_CTL_TXCLKREF_MASK (0x1 << 20)
142#define PADS_PLL_CTL_TXCLKREF_DIV10 (0 << 20)
143#define PADS_PLL_CTL_TXCLKREF_DIV5 (1 << 20)
144
145/* PMC access is required for PCIE xclk (un)clamping */
146#define PMC_SCRATCH42 0x144
147#define PMC_SCRATCH42_PCX_CLAMP (1 << 0)
148
149static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE);
150
151#define pmc_writel(value, reg) \
152 __raw_writel(value, (u32)reg_pmc_base + (reg))
153#define pmc_readl(reg) \
154 __raw_readl((u32)reg_pmc_base + (reg))
155
156/*
157 * Tegra2 defines 1GB in the AXI address map for PCIe.
158 *
159 * That address space is split into different regions, with sizes and
160 * offsets as follows:
161 *
162 * 0x80000000 - 0x80003fff - PCI controller registers
163 * 0x80004000 - 0x80103fff - PCI configuration space
164 * 0x80104000 - 0x80203fff - PCI extended configuration space
165 * 0x80203fff - 0x803fffff - unused
166 * 0x80400000 - 0x8040ffff - downstream IO
167 * 0x80410000 - 0x8fffffff - unused
168 * 0x90000000 - 0x9fffffff - non-prefetchable memory
169 * 0xa0000000 - 0xbfffffff - prefetchable memory
170 */
171#define TEGRA_PCIE_BASE 0x80000000
172
173#define PCIE_REGS_SZ SZ_16K
174#define PCIE_CFG_OFF PCIE_REGS_SZ
175#define PCIE_CFG_SZ SZ_1M
176#define PCIE_EXT_CFG_OFF (PCIE_CFG_SZ + PCIE_CFG_OFF)
177#define PCIE_EXT_CFG_SZ SZ_1M
178#define PCIE_IOMAP_SZ (PCIE_REGS_SZ + PCIE_CFG_SZ + PCIE_EXT_CFG_SZ)
179
180#define MMIO_BASE (TEGRA_PCIE_BASE + SZ_4M)
181#define MMIO_SIZE SZ_64K
182#define MEM_BASE_0 (TEGRA_PCIE_BASE + SZ_256M)
183#define MEM_SIZE_0 SZ_128M
184#define MEM_BASE_1 (MEM_BASE_0 + MEM_SIZE_0)
185#define MEM_SIZE_1 SZ_128M
186#define PREFETCH_MEM_BASE_0 (MEM_BASE_1 + MEM_SIZE_1)
187#define PREFETCH_MEM_SIZE_0 SZ_128M
188#define PREFETCH_MEM_BASE_1 (PREFETCH_MEM_BASE_0 + PREFETCH_MEM_SIZE_0)
189#define PREFETCH_MEM_SIZE_1 SZ_128M
190
191#define PCIE_CONF_BUS(b) ((b) << 16)
192#define PCIE_CONF_DEV(d) ((d) << 11)
193#define PCIE_CONF_FUNC(f) ((f) << 8)
194#define PCIE_CONF_REG(r) \
195 (((r) & ~0x3) | (((r) < 256) ? PCIE_CFG_OFF : PCIE_EXT_CFG_OFF))
196
197struct tegra_pcie_port {
198 int index;
199 u8 root_bus_nr;
200 void __iomem *base;
201
202 bool link_up;
203
204 char io_space_name[16];
205 char mem_space_name[16];
206 char prefetch_space_name[20];
207 struct resource res[3];
208};
209
210struct tegra_pcie_info {
211 struct tegra_pcie_port port[2];
212 int num_ports;
213
214 void __iomem *regs;
215 struct resource res_mmio;
216
217 struct clk *pex_clk;
218 struct clk *afi_clk;
219 struct clk *pcie_xclk;
220 struct clk *pll_e;
221};
222
223static struct tegra_pcie_info tegra_pcie = {
224 .res_mmio = {
225 .name = "PCI IO",
226 .start = MMIO_BASE,
227 .end = MMIO_BASE + MMIO_SIZE - 1,
228 .flags = IORESOURCE_MEM,
229 },
230};
231
232void __iomem *tegra_pcie_io_base;
233EXPORT_SYMBOL(tegra_pcie_io_base);
234
235static inline void afi_writel(u32 value, unsigned long offset)
236{
237 writel(value, offset + AFI_OFFSET + tegra_pcie.regs);
238}
239
240static inline u32 afi_readl(unsigned long offset)
241{
242 return readl(offset + AFI_OFFSET + tegra_pcie.regs);
243}
244
245static inline void pads_writel(u32 value, unsigned long offset)
246{
247 writel(value, offset + PADS_OFFSET + tegra_pcie.regs);
248}
249
250static inline u32 pads_readl(unsigned long offset)
251{
252 return readl(offset + PADS_OFFSET + tegra_pcie.regs);
253}
254
255static struct tegra_pcie_port *bus_to_port(int bus)
256{
257 int i;
258
259 for (i = tegra_pcie.num_ports - 1; i >= 0; i--) {
260 int rbus = tegra_pcie.port[i].root_bus_nr;
261 if (rbus != -1 && rbus == bus)
262 break;
263 }
264
265 return i >= 0 ? tegra_pcie.port + i : NULL;
266}
267
268static int tegra_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
269 int where, int size, u32 *val)
270{
271 struct tegra_pcie_port *pp = bus_to_port(bus->number);
272 void __iomem *addr;
273
274 if (pp) {
275 if (devfn != 0) {
276 *val = 0xffffffff;
277 return PCIBIOS_DEVICE_NOT_FOUND;
278 }
279
280 addr = pp->base + (where & ~0x3);
281 } else {
282 addr = tegra_pcie.regs + (PCIE_CONF_BUS(bus->number) +
283 PCIE_CONF_DEV(PCI_SLOT(devfn)) +
284 PCIE_CONF_FUNC(PCI_FUNC(devfn)) +
285 PCIE_CONF_REG(where));
286 }
287
288 *val = readl(addr);
289
290 if (size == 1)
291 *val = (*val >> (8 * (where & 3))) & 0xff;
292 else if (size == 2)
293 *val = (*val >> (8 * (where & 3))) & 0xffff;
294
295 return PCIBIOS_SUCCESSFUL;
296}
297
298static int tegra_pcie_write_conf(struct pci_bus *bus, unsigned int devfn,
299 int where, int size, u32 val)
300{
301 struct tegra_pcie_port *pp = bus_to_port(bus->number);
302 void __iomem *addr;
303
304 u32 mask;
305 u32 tmp;
306
307 if (pp) {
308 if (devfn != 0)
309 return PCIBIOS_DEVICE_NOT_FOUND;
310
311 addr = pp->base + (where & ~0x3);
312 } else {
313 addr = tegra_pcie.regs + (PCIE_CONF_BUS(bus->number) +
314 PCIE_CONF_DEV(PCI_SLOT(devfn)) +
315 PCIE_CONF_FUNC(PCI_FUNC(devfn)) +
316 PCIE_CONF_REG(where));
317 }
318
319 if (size == 4) {
320 writel(val, addr);
321 return PCIBIOS_SUCCESSFUL;
322 }
323
324 if (size == 2)
325 mask = ~(0xffff << ((where & 0x3) * 8));
326 else if (size == 1)
327 mask = ~(0xff << ((where & 0x3) * 8));
328 else
329 return PCIBIOS_BAD_REGISTER_NUMBER;
330
331 tmp = readl(addr) & mask;
332 tmp |= val << ((where & 0x3) * 8);
333 writel(tmp, addr);
334
335 return PCIBIOS_SUCCESSFUL;
336}
337
338static struct pci_ops tegra_pcie_ops = {
339 .read = tegra_pcie_read_conf,
340 .write = tegra_pcie_write_conf,
341};
342
343static void __devinit tegra_pcie_fixup_bridge(struct pci_dev *dev)
344{
345 u16 reg;
346
347 if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) {
348 pci_read_config_word(dev, PCI_COMMAND, &reg);
349 reg |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
350 PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
351 pci_write_config_word(dev, PCI_COMMAND, reg);
352 }
353}
354DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_fixup_bridge);
355
356/* Tegra PCIE root complex wrongly reports device class */
357static void __devinit tegra_pcie_fixup_class(struct pci_dev *dev)
358{
359 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
360}
361DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf0, tegra_pcie_fixup_class);
362DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, tegra_pcie_fixup_class);
363
364/* Tegra PCIE requires relaxed ordering */
365static void __devinit tegra_pcie_relax_enable(struct pci_dev *dev)
366{
367 u16 val16;
368 int pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
369
370 if (pos <= 0) {
371 dev_err(&dev->dev, "skipping relaxed ordering fixup\n");
372 return;
373 }
374
375 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &val16);
376 val16 |= PCI_EXP_DEVCTL_RELAX_EN;
377 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, val16);
378}
379DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, tegra_pcie_relax_enable);
380
381static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
382{
383 struct tegra_pcie_port *pp;
384
385 if (nr >= tegra_pcie.num_ports)
386 return 0;
387
388 pp = tegra_pcie.port + nr;
389 pp->root_bus_nr = sys->busnr;
390
391 /*
392 * IORESOURCE_IO
393 */
394 snprintf(pp->io_space_name, sizeof(pp->io_space_name),
395 "PCIe %d I/O", pp->index);
396 pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0;
397 pp->res[0].name = pp->io_space_name;
398 if (pp->index == 0) {
399 pp->res[0].start = PCIBIOS_MIN_IO;
400 pp->res[0].end = pp->res[0].start + SZ_32K - 1;
401 } else {
402 pp->res[0].start = PCIBIOS_MIN_IO + SZ_32K;
403 pp->res[0].end = IO_SPACE_LIMIT;
404 }
405 pp->res[0].flags = IORESOURCE_IO;
406 if (request_resource(&ioport_resource, &pp->res[0]))
407 panic("Request PCIe IO resource failed\n");
408 sys->resource[0] = &pp->res[0];
409
410 /*
411 * IORESOURCE_MEM
412 */
413 snprintf(pp->mem_space_name, sizeof(pp->mem_space_name),
414 "PCIe %d MEM", pp->index);
415 pp->mem_space_name[sizeof(pp->mem_space_name) - 1] = 0;
416 pp->res[1].name = pp->mem_space_name;
417 if (pp->index == 0) {
418 pp->res[1].start = MEM_BASE_0;
419 pp->res[1].end = pp->res[1].start + MEM_SIZE_0 - 1;
420 } else {
421 pp->res[1].start = MEM_BASE_1;
422 pp->res[1].end = pp->res[1].start + MEM_SIZE_1 - 1;
423 }
424 pp->res[1].flags = IORESOURCE_MEM;
425 if (request_resource(&iomem_resource, &pp->res[1]))
426 panic("Request PCIe Memory resource failed\n");
427 sys->resource[1] = &pp->res[1];
428
429 /*
430 * IORESOURCE_MEM | IORESOURCE_PREFETCH
431 */
432 snprintf(pp->prefetch_space_name, sizeof(pp->prefetch_space_name),
433 "PCIe %d PREFETCH MEM", pp->index);
434 pp->prefetch_space_name[sizeof(pp->prefetch_space_name) - 1] = 0;
435 pp->res[2].name = pp->prefetch_space_name;
436 if (pp->index == 0) {
437 pp->res[2].start = PREFETCH_MEM_BASE_0;
438 pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_0 - 1;
439 } else {
440 pp->res[2].start = PREFETCH_MEM_BASE_1;
441 pp->res[2].end = pp->res[2].start + PREFETCH_MEM_SIZE_1 - 1;
442 }
443 pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
444 if (request_resource(&iomem_resource, &pp->res[2]))
445 panic("Request PCIe Prefetch Memory resource failed\n");
446 sys->resource[2] = &pp->res[2];
447
448 return 1;
449}
450
451static int tegra_pcie_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
452{
453 return INT_PCIE_INTR;
454}
455
456static struct pci_bus __init *tegra_pcie_scan_bus(int nr,
457 struct pci_sys_data *sys)
458{
459 struct tegra_pcie_port *pp;
460
461 if (nr >= tegra_pcie.num_ports)
462 return 0;
463
464 pp = tegra_pcie.port + nr;
465 pp->root_bus_nr = sys->busnr;
466
467 return pci_scan_bus(sys->busnr, &tegra_pcie_ops, sys);
468}
469
470static struct hw_pci tegra_pcie_hw __initdata = {
471 .nr_controllers = 2,
472 .setup = tegra_pcie_setup,
473 .scan = tegra_pcie_scan_bus,
474 .swizzle = pci_std_swizzle,
475 .map_irq = tegra_pcie_map_irq,
476};
477
478
479static irqreturn_t tegra_pcie_isr(int irq, void *arg)
480{
481 const char *err_msg[] = {
482 "Unknown",
483 "AXI slave error",
484 "AXI decode error",
485 "Target abort",
486 "Master abort",
487 "Invalid write",
488 "Response decoding error",
489 "AXI response decoding error",
490 "Transcation timeout",
491 };
492
493 u32 code, signature;
494
495 code = afi_readl(AFI_INTR_CODE) & AFI_INTR_CODE_MASK;
496 signature = afi_readl(AFI_INTR_SIGNATURE);
497 afi_writel(0, AFI_INTR_CODE);
498
499 if (code == AFI_INTR_LEGACY)
500 return IRQ_NONE;
501
502 if (code >= ARRAY_SIZE(err_msg))
503 code = 0;
504
505 /*
506 * do not pollute kernel log with master abort reports since they
507 * happen a lot during enumeration
508 */
509 if (code == AFI_INTR_MASTER_ABORT)
510 pr_debug("PCIE: %s, signature: %08x\n", err_msg[code], signature);
511 else
512 pr_err("PCIE: %s, signature: %08x\n", err_msg[code], signature);
513
514 return IRQ_HANDLED;
515}
516
517static void tegra_pcie_setup_translations(void)
518{
519 u32 fpci_bar;
520 u32 size;
521 u32 axi_address;
522
523 /* Bar 0: config Bar */
524 fpci_bar = ((u32)0xfdff << 16);
525 size = PCIE_CFG_SZ;
526 axi_address = TEGRA_PCIE_BASE + PCIE_CFG_OFF;
527 afi_writel(axi_address, AFI_AXI_BAR0_START);
528 afi_writel(size >> 12, AFI_AXI_BAR0_SZ);
529 afi_writel(fpci_bar, AFI_FPCI_BAR0);
530
531 /* Bar 1: extended config Bar */
532 fpci_bar = ((u32)0xfe1 << 20);
533 size = PCIE_EXT_CFG_SZ;
534 axi_address = TEGRA_PCIE_BASE + PCIE_EXT_CFG_OFF;
535 afi_writel(axi_address, AFI_AXI_BAR1_START);
536 afi_writel(size >> 12, AFI_AXI_BAR1_SZ);
537 afi_writel(fpci_bar, AFI_FPCI_BAR1);
538
539 /* Bar 2: downstream IO bar */
540 fpci_bar = ((__u32)0xfdfc << 16);
541 size = MMIO_SIZE;
542 axi_address = MMIO_BASE;
543 afi_writel(axi_address, AFI_AXI_BAR2_START);
544 afi_writel(size >> 12, AFI_AXI_BAR2_SZ);
545 afi_writel(fpci_bar, AFI_FPCI_BAR2);
546
547 /* Bar 3: prefetchable memory BAR */
548 fpci_bar = (((PREFETCH_MEM_BASE_0 >> 12) & 0x0fffffff) << 4) | 0x1;
549 size = PREFETCH_MEM_SIZE_0 + PREFETCH_MEM_SIZE_1;
550 axi_address = PREFETCH_MEM_BASE_0;
551 afi_writel(axi_address, AFI_AXI_BAR3_START);
552 afi_writel(size >> 12, AFI_AXI_BAR3_SZ);
553 afi_writel(fpci_bar, AFI_FPCI_BAR3);
554
555 /* Bar 4: non prefetchable memory BAR */
556 fpci_bar = (((MEM_BASE_0 >> 12) & 0x0FFFFFFF) << 4) | 0x1;
557 size = MEM_SIZE_0 + MEM_SIZE_1;
558 axi_address = MEM_BASE_0;
559 afi_writel(axi_address, AFI_AXI_BAR4_START);
560 afi_writel(size >> 12, AFI_AXI_BAR4_SZ);
561 afi_writel(fpci_bar, AFI_FPCI_BAR4);
562
563 /* Bar 5: NULL out the remaining BAR as it is not used */
564 fpci_bar = 0;
565 size = 0;
566 axi_address = 0;
567 afi_writel(axi_address, AFI_AXI_BAR5_START);
568 afi_writel(size >> 12, AFI_AXI_BAR5_SZ);
569 afi_writel(fpci_bar, AFI_FPCI_BAR5);
570
571 /* map all upstream transactions as uncached */
572 afi_writel(PHYS_OFFSET, AFI_CACHE_BAR0_ST);
573 afi_writel(0, AFI_CACHE_BAR0_SZ);
574 afi_writel(0, AFI_CACHE_BAR1_ST);
575 afi_writel(0, AFI_CACHE_BAR1_SZ);
576
577 /* No MSI */
578 afi_writel(0, AFI_MSI_FPCI_BAR_ST);
579 afi_writel(0, AFI_MSI_BAR_SZ);
580 afi_writel(0, AFI_MSI_AXI_BAR_ST);
581 afi_writel(0, AFI_MSI_BAR_SZ);
582}
583
584static void tegra_pcie_enable_controller(void)
585{
586 u32 val, reg;
587 int i;
588
589 /* Enable slot clock and pulse the reset signals */
590 for (i = 0, reg = AFI_PEX0_CTRL; i < 2; i++, reg += 0x8) {
591 val = afi_readl(reg) | AFI_PEX_CTRL_REFCLK_EN;
592 afi_writel(val, reg);
593 val &= ~AFI_PEX_CTRL_RST;
594 afi_writel(val, reg);
595
596 val = afi_readl(reg) | AFI_PEX_CTRL_RST;
597 afi_writel(val, reg);
598 }
599
600 /* Enable dual controller and both ports */
601 val = afi_readl(AFI_PCIE_CONFIG);
602 val &= ~(AFI_PCIE_CONFIG_PCIEC0_DISABLE_DEVICE |
603 AFI_PCIE_CONFIG_PCIEC1_DISABLE_DEVICE |
604 AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK);
605 val |= AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL;
606 afi_writel(val, AFI_PCIE_CONFIG);
607
608 val = afi_readl(AFI_FUSE) & ~AFI_FUSE_PCIE_T0_GEN2_DIS;
609 afi_writel(val, AFI_FUSE);
610
611 /* Initialze internal PHY, enable up to 16 PCIE lanes */
612 pads_writel(0x0, PADS_CTL_SEL);
613
614 /* override IDDQ to 1 on all 4 lanes */
615 val = pads_readl(PADS_CTL) | PADS_CTL_IDDQ_1L;
616 pads_writel(val, PADS_CTL);
617
618 /*
619 * set up PHY PLL inputs select PLLE output as refclock,
620 * set TX ref sel to div10 (not div5)
621 */
622 val = pads_readl(PADS_PLL_CTL);
623 val &= ~(PADS_PLL_CTL_REFCLK_MASK | PADS_PLL_CTL_TXCLKREF_MASK);
624 val |= (PADS_PLL_CTL_REFCLK_INTERNAL_CML | PADS_PLL_CTL_TXCLKREF_DIV10);
625 pads_writel(val, PADS_PLL_CTL);
626
627 /* take PLL out of reset */
628 val = pads_readl(PADS_PLL_CTL) | PADS_PLL_CTL_RST_B4SM;
629 pads_writel(val, PADS_PLL_CTL);
630
631 /*
632 * Hack, set the clock voltage to the DEFAULT provided by hw folks.
633 * This doesn't exist in the documentation
634 */
635 pads_writel(0xfa5cfa5c, 0xc8);
636
637 /* Wait for the PLL to lock */
638 do {
639 val = pads_readl(PADS_PLL_CTL);
640 } while (!(val & PADS_PLL_CTL_LOCKDET));
641
642 /* turn off IDDQ override */
643 val = pads_readl(PADS_CTL) & ~PADS_CTL_IDDQ_1L;
644 pads_writel(val, PADS_CTL);
645
646 /* enable TX/RX data */
647 val = pads_readl(PADS_CTL);
648 val |= (PADS_CTL_TX_DATA_EN_1L | PADS_CTL_RX_DATA_EN_1L);
649 pads_writel(val, PADS_CTL);
650
651 /* Take the PCIe interface module out of reset */
652 tegra_periph_reset_deassert(tegra_pcie.pcie_xclk);
653
654 /* Finally enable PCIe */
655 val = afi_readl(AFI_CONFIGURATION) | AFI_CONFIGURATION_EN_FPCI;
656 afi_writel(val, AFI_CONFIGURATION);
657
658 val = (AFI_INTR_EN_INI_SLVERR | AFI_INTR_EN_INI_DECERR |
659 AFI_INTR_EN_TGT_SLVERR | AFI_INTR_EN_TGT_DECERR |
660 AFI_INTR_EN_TGT_WRERR | AFI_INTR_EN_DFPCI_DECERR);
661 afi_writel(val, AFI_AFI_INTR_ENABLE);
662 afi_writel(0xffffffff, AFI_SM_INTR_ENABLE);
663
664 /* FIXME: No MSI for now, only INT */
665 afi_writel(AFI_INTR_MASK_INT_MASK, AFI_INTR_MASK);
666
667 /* Disable all execptions */
668 afi_writel(0, AFI_FPCI_ERROR_MASKS);
669
670 return;
671}
672
673static void tegra_pcie_xclk_clamp(bool clamp)
674{
675 u32 reg;
676
677 reg = pmc_readl(PMC_SCRATCH42) & ~PMC_SCRATCH42_PCX_CLAMP;
678
679 if (clamp)
680 reg |= PMC_SCRATCH42_PCX_CLAMP;
681
682 pmc_writel(reg, PMC_SCRATCH42);
683}
684
685static int tegra_pcie_power_on(void)
686{
687 tegra_pcie_xclk_clamp(true);
688 tegra_periph_reset_assert(tegra_pcie.pcie_xclk);
689 tegra_pcie_xclk_clamp(false);
690
691 clk_enable(tegra_pcie.afi_clk);
692 clk_enable(tegra_pcie.pex_clk);
693 return clk_enable(tegra_pcie.pll_e);
694}
695
696static void tegra_pcie_power_off(void)
697{
698 tegra_periph_reset_assert(tegra_pcie.pcie_xclk);
699 tegra_periph_reset_assert(tegra_pcie.afi_clk);
700 tegra_periph_reset_assert(tegra_pcie.pex_clk);
701
702 tegra_pcie_xclk_clamp(true);
703}
704
705static int tegra_pcie_clocks_get(void)
706{
707 int err;
708
709 tegra_pcie.pex_clk = clk_get(NULL, "pex");
710 if (IS_ERR(tegra_pcie.pex_clk))
711 return PTR_ERR(tegra_pcie.pex_clk);
712
713 tegra_pcie.afi_clk = clk_get(NULL, "afi");
714 if (IS_ERR(tegra_pcie.afi_clk)) {
715 err = PTR_ERR(tegra_pcie.afi_clk);
716 goto err_afi_clk;
717 }
718
719 tegra_pcie.pcie_xclk = clk_get(NULL, "pcie_xclk");
720 if (IS_ERR(tegra_pcie.pcie_xclk)) {
721 err = PTR_ERR(tegra_pcie.pcie_xclk);
722 goto err_pcie_xclk;
723 }
724
725 tegra_pcie.pll_e = clk_get_sys(NULL, "pll_e");
726 if (IS_ERR(tegra_pcie.pll_e)) {
727 err = PTR_ERR(tegra_pcie.pll_e);
728 goto err_pll_e;
729 }
730
731 return 0;
732
733err_pll_e:
734 clk_put(tegra_pcie.pcie_xclk);
735err_pcie_xclk:
736 clk_put(tegra_pcie.afi_clk);
737err_afi_clk:
738 clk_put(tegra_pcie.pex_clk);
739
740 return err;
741}
742
743static void tegra_pcie_clocks_put(void)
744{
745 clk_put(tegra_pcie.pll_e);
746 clk_put(tegra_pcie.pcie_xclk);
747 clk_put(tegra_pcie.afi_clk);
748 clk_put(tegra_pcie.pex_clk);
749}
750
751static int __init tegra_pcie_get_resources(void)
752{
753 struct resource *res_mmio = &tegra_pcie.res_mmio;
754 int err;
755
756 err = tegra_pcie_clocks_get();
757 if (err) {
758 pr_err("PCIE: failed to get clocks: %d\n", err);
759 return err;
760 }
761
762 err = tegra_pcie_power_on();
763 if (err) {
764 pr_err("PCIE: failed to power up: %d\n", err);
765 goto err_pwr_on;
766 }
767
768 tegra_pcie.regs = ioremap_nocache(TEGRA_PCIE_BASE, PCIE_IOMAP_SZ);
769 if (tegra_pcie.regs == NULL) {
770 pr_err("PCIE: Failed to map PCI/AFI registers\n");
771 err = -ENOMEM;
772 goto err_map_reg;
773 }
774
775 err = request_resource(&iomem_resource, res_mmio);
776 if (err) {
777 pr_err("PCIE: Failed to request resources: %d\n", err);
778 goto err_req_io;
779 }
780
781 tegra_pcie_io_base = ioremap_nocache(res_mmio->start,
782 resource_size(res_mmio));
783 if (tegra_pcie_io_base == NULL) {
784 pr_err("PCIE: Failed to map IO\n");
785 err = -ENOMEM;
786 goto err_map_io;
787 }
788
789 err = request_irq(INT_PCIE_INTR, tegra_pcie_isr,
790 IRQF_SHARED, "PCIE", &tegra_pcie);
791 if (err) {
792 pr_err("PCIE: Failed to register IRQ: %d\n", err);
793 goto err_irq;
794 }
795 set_irq_flags(INT_PCIE_INTR, IRQF_VALID);
796
797 return 0;
798
799err_irq:
800 iounmap(tegra_pcie_io_base);
801err_map_io:
802 release_resource(&tegra_pcie.res_mmio);
803err_req_io:
804 iounmap(tegra_pcie.regs);
805err_map_reg:
806 tegra_pcie_power_off();
807err_pwr_on:
808 tegra_pcie_clocks_put();
809
810 return err;
811}
812
813/*
814 * FIXME: If there are no PCIe cards attached, then calling this function
815 * can result in the increase of the bootup time as there are big timeout
816 * loops.
817 */
818#define TEGRA_PCIE_LINKUP_TIMEOUT 200 /* up to 1.2 seconds */
819static bool tegra_pcie_check_link(struct tegra_pcie_port *pp, int idx,
820 u32 reset_reg)
821{
822 u32 reg;
823 int retries = 3;
824 int timeout;
825
826 do {
827 timeout = TEGRA_PCIE_LINKUP_TIMEOUT;
828 while (timeout) {
829 reg = readl(pp->base + RP_VEND_XP);
830
831 if (reg & RP_VEND_XP_DL_UP)
832 break;
833
834 mdelay(1);
835 timeout--;
836 }
837
838 if (!timeout) {
839 pr_err("PCIE: port %d: link down, retrying\n", idx);
840 goto retry;
841 }
842
843 timeout = TEGRA_PCIE_LINKUP_TIMEOUT;
844 while (timeout) {
845 reg = readl(pp->base + RP_LINK_CONTROL_STATUS);
846
847 if (reg & 0x20000000)
848 return true;
849
850 mdelay(1);
851 timeout--;
852 }
853
854retry:
855 /* Pulse the PEX reset */
856 reg = afi_readl(reset_reg) | AFI_PEX_CTRL_RST;
857 afi_writel(reg, reset_reg);
858 mdelay(1);
859 reg = afi_readl(reset_reg) & ~AFI_PEX_CTRL_RST;
860 afi_writel(reg, reset_reg);
861
862 retries--;
863 } while (retries);
864
865 return false;
866}
867
868static void __init tegra_pcie_add_port(int index, u32 offset, u32 reset_reg)
869{
870 struct tegra_pcie_port *pp;
871
872 pp = tegra_pcie.port + tegra_pcie.num_ports;
873
874 pp->index = -1;
875 pp->base = tegra_pcie.regs + offset;
876 pp->link_up = tegra_pcie_check_link(pp, index, reset_reg);
877
878 if (!pp->link_up) {
879 pp->base = NULL;
880 printk(KERN_INFO "PCIE: port %d: link down, ignoring\n", index);
881 return;
882 }
883
884 tegra_pcie.num_ports++;
885 pp->index = index;
886 pp->root_bus_nr = -1;
887 memset(pp->res, 0, sizeof(pp->res));
888}
889
890int __init tegra_pcie_init(bool init_port0, bool init_port1)
891{
892 int err;
893
894 if (!(init_port0 || init_port1))
895 return -ENODEV;
896
897 err = tegra_pcie_get_resources();
898 if (err)
899 return err;
900
901 tegra_pcie_enable_controller();
902
903 /* setup the AFI address translations */
904 tegra_pcie_setup_translations();
905
906 if (init_port0)
907 tegra_pcie_add_port(0, RP0_OFFSET, AFI_PEX0_CTRL);
908
909 if (init_port1)
910 tegra_pcie_add_port(1, RP1_OFFSET, AFI_PEX1_CTRL);
911
912 pci_common_init(&tegra_pcie_hw);
913
914 return 0;
915}
diff --git a/arch/arm/mach-tegra/pinmux-t2-tables.c b/arch/arm/mach-tegra/pinmux-t2-tables.c
new file mode 100644
index 000000000000..a6ea34e782dc
--- /dev/null
+++ b/arch/arm/mach-tegra/pinmux-t2-tables.c
@@ -0,0 +1,260 @@
1/*
2 * linux/arch/arm/mach-tegra/pinmux-t2-tables.c
3 *
4 * Common pinmux configurations for Tegra 2 SoCs
5 *
6 * Copyright (C) 2010 NVIDIA Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#include <linux/kernel.h>
24#include <linux/errno.h>
25#include <linux/spinlock.h>
26#include <linux/io.h>
27#include <linux/init.h>
28#include <linux/string.h>
29
30#include <mach/iomap.h>
31#include <mach/pinmux.h>
32
33#define DRIVE_PINGROUP(pg_name, r) \
34 [TEGRA_DRIVE_PINGROUP_ ## pg_name] = { \
35 .name = #pg_name, \
36 .reg = r \
37 }
38
39const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[TEGRA_MAX_DRIVE_PINGROUP] = {
40 DRIVE_PINGROUP(AO1, 0x868),
41 DRIVE_PINGROUP(AO2, 0x86c),
42 DRIVE_PINGROUP(AT1, 0x870),
43 DRIVE_PINGROUP(AT2, 0x874),
44 DRIVE_PINGROUP(CDEV1, 0x878),
45 DRIVE_PINGROUP(CDEV2, 0x87c),
46 DRIVE_PINGROUP(CSUS, 0x880),
47 DRIVE_PINGROUP(DAP1, 0x884),
48 DRIVE_PINGROUP(DAP2, 0x888),
49 DRIVE_PINGROUP(DAP3, 0x88c),
50 DRIVE_PINGROUP(DAP4, 0x890),
51 DRIVE_PINGROUP(DBG, 0x894),
52 DRIVE_PINGROUP(LCD1, 0x898),
53 DRIVE_PINGROUP(LCD2, 0x89c),
54 DRIVE_PINGROUP(SDMMC2, 0x8a0),
55 DRIVE_PINGROUP(SDMMC3, 0x8a4),
56 DRIVE_PINGROUP(SPI, 0x8a8),
57 DRIVE_PINGROUP(UAA, 0x8ac),
58 DRIVE_PINGROUP(UAB, 0x8b0),
59 DRIVE_PINGROUP(UART2, 0x8b4),
60 DRIVE_PINGROUP(UART3, 0x8b8),
61 DRIVE_PINGROUP(VI1, 0x8bc),
62 DRIVE_PINGROUP(VI2, 0x8c0),
63 DRIVE_PINGROUP(XM2A, 0x8c4),
64 DRIVE_PINGROUP(XM2C, 0x8c8),
65 DRIVE_PINGROUP(XM2D, 0x8cc),
66 DRIVE_PINGROUP(XM2CLK, 0x8d0),
67 DRIVE_PINGROUP(MEMCOMP, 0x8d4),
68};
69
70#define PINGROUP(pg_name, vdd, f0, f1, f2, f3, f_safe, \
71 tri_r, tri_b, mux_r, mux_b, pupd_r, pupd_b) \
72 [TEGRA_PINGROUP_ ## pg_name] = { \
73 .name = #pg_name, \
74 .vddio = TEGRA_VDDIO_ ## vdd, \
75 .funcs = { \
76 TEGRA_MUX_ ## f0, \
77 TEGRA_MUX_ ## f1, \
78 TEGRA_MUX_ ## f2, \
79 TEGRA_MUX_ ## f3, \
80 }, \
81 .func_safe = TEGRA_MUX_ ## f_safe, \
82 .tri_reg = tri_r, \
83 .tri_bit = tri_b, \
84 .mux_reg = mux_r, \
85 .mux_bit = mux_b, \
86 .pupd_reg = pupd_r, \
87 .pupd_bit = pupd_b, \
88 }
89
90const struct tegra_pingroup_desc tegra_soc_pingroups[TEGRA_MAX_PINGROUP] = {
91 PINGROUP(ATA, NAND, IDE, NAND, GMI, RSVD, IDE, 0x14, 0, 0x80, 24, 0xA0, 0),
92 PINGROUP(ATB, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 1, 0x80, 16, 0xA0, 2),
93 PINGROUP(ATC, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 2, 0x80, 22, 0xA0, 4),
94 PINGROUP(ATD, NAND, IDE, NAND, GMI, SDIO4, IDE, 0x14, 3, 0x80, 20, 0xA0, 6),
95 PINGROUP(ATE, NAND, IDE, NAND, GMI, RSVD, IDE, 0x18, 25, 0x80, 12, 0xA0, 8),
96 PINGROUP(CDEV1, AUDIO, OSC, PLLA_OUT, PLLM_OUT1, AUDIO_SYNC, OSC, 0x14, 4, 0x88, 2, 0xA8, 0),
97 PINGROUP(CDEV2, AUDIO, OSC, AHB_CLK, APB_CLK, PLLP_OUT4, OSC, 0x14, 5, 0x88, 4, 0xA8, 2),
98 PINGROUP(CRTP, LCD, CRT, RSVD, RSVD, RSVD, RSVD, 0x20, 14, 0x98, 20, 0xA4, 24),
99 PINGROUP(CSUS, VI, PLLC_OUT1, PLLP_OUT2, PLLP_OUT3, VI_SENSOR_CLK, PLLC_OUT1, 0x14, 6, 0x88, 6, 0xAC, 24),
100 PINGROUP(DAP1, AUDIO, DAP1, RSVD, GMI, SDIO2, DAP1, 0x14, 7, 0x88, 20, 0xA0, 10),
101 PINGROUP(DAP2, AUDIO, DAP2, TWC, RSVD, GMI, DAP2, 0x14, 8, 0x88, 22, 0xA0, 12),
102 PINGROUP(DAP3, BB, DAP3, RSVD, RSVD, RSVD, DAP3, 0x14, 9, 0x88, 24, 0xA0, 14),
103 PINGROUP(DAP4, UART, DAP4, RSVD, GMI, RSVD, DAP4, 0x14, 10, 0x88, 26, 0xA0, 16),
104 PINGROUP(DDC, LCD, I2C2, RSVD, RSVD, RSVD, RSVD4, 0x18, 31, 0x88, 0, 0xB0, 28),
105 PINGROUP(DTA, VI, RSVD, SDIO2, VI, RSVD, RSVD4, 0x14, 11, 0x84, 20, 0xA0, 18),
106 PINGROUP(DTB, VI, RSVD, RSVD, VI, SPI1, RSVD1, 0x14, 12, 0x84, 22, 0xA0, 20),
107 PINGROUP(DTC, VI, RSVD, RSVD, VI, RSVD, RSVD1, 0x14, 13, 0x84, 26, 0xA0, 22),
108 PINGROUP(DTD, VI, RSVD, SDIO2, VI, RSVD, RSVD1, 0x14, 14, 0x84, 28, 0xA0, 24),
109 PINGROUP(DTE, VI, RSVD, RSVD, VI, SPI1, RSVD1, 0x14, 15, 0x84, 30, 0xA0, 26),
110 PINGROUP(DTF, VI, I2C3, RSVD, VI, RSVD, RSVD4, 0x20, 12, 0x98, 30, 0xA0, 28),
111 PINGROUP(GMA, NAND, UARTE, SPI3, GMI, SDIO4, SPI3, 0x14, 28, 0x84, 0, 0xB0, 20),
112 PINGROUP(GMB, NAND, IDE, NAND, GMI, GMI_INT, GMI, 0x18, 29, 0x88, 28, 0xB0, 22),
113 PINGROUP(GMC, NAND, UARTD, SPI4, GMI, SFLASH, SPI4, 0x14, 29, 0x84, 2, 0xB0, 24),
114 PINGROUP(GMD, NAND, RSVD, NAND, GMI, SFLASH, GMI, 0x18, 30, 0x88, 30, 0xB0, 26),
115 PINGROUP(GME, NAND, RSVD, DAP5, GMI, SDIO4, GMI, 0x18, 0, 0x8C, 0, 0xA8, 24),
116 PINGROUP(GPU, UART, PWM, UARTA, GMI, RSVD, RSVD4, 0x14, 16, 0x8C, 4, 0xA4, 20),
117 PINGROUP(GPU7, SYS, RTCK, RSVD, RSVD, RSVD, RTCK, 0x20, 11, 0x98, 28, 0xA4, 6),
118 PINGROUP(GPV, SD, PCIE, RSVD, RSVD, RSVD, PCIE, 0x14, 17, 0x8C, 2, 0xA0, 30),
119 PINGROUP(HDINT, LCD, HDMI, RSVD, RSVD, RSVD, HDMI, 0x1C, 23, 0x84, 4, 0xAC, 22),
120 PINGROUP(I2CP, SYS, I2C, RSVD, RSVD, RSVD, RSVD4, 0x14, 18, 0x88, 8, 0xA4, 2),
121 PINGROUP(IRRX, UART, UARTA, UARTB, GMI, SPI4, UARTB, 0x14, 20, 0x88, 18, 0xA8, 22),
122 PINGROUP(IRTX, UART, UARTA, UARTB, GMI, SPI4, UARTB, 0x14, 19, 0x88, 16, 0xA8, 20),
123 PINGROUP(KBCA, SYS, KBC, NAND, SDIO2, EMC_TEST0_DLL, KBC, 0x14, 22, 0x88, 10, 0xA4, 8),
124 PINGROUP(KBCB, SYS, KBC, NAND, SDIO2, MIO, KBC, 0x14, 21, 0x88, 12, 0xA4, 10),
125 PINGROUP(KBCC, SYS, KBC, NAND, TRACE, EMC_TEST1_DLL, KBC, 0x18, 26, 0x88, 14, 0xA4, 12),
126 PINGROUP(KBCD, SYS, KBC, NAND, SDIO2, MIO, KBC, 0x20, 10, 0x98, 26, 0xA4, 14),
127 PINGROUP(KBCE, SYS, KBC, NAND, OWR, RSVD, KBC, 0x14, 26, 0x80, 28, 0xB0, 2),
128 PINGROUP(KBCF, SYS, KBC, NAND, TRACE, MIO, KBC, 0x14, 27, 0x80, 26, 0xB0, 0),
129 PINGROUP(LCSN, LCD, DISPLAYA, DISPLAYB, SPI3, RSVD, RSVD4, 0x1C, 31, 0x90, 12, 0xAC, 20),
130 PINGROUP(LD0, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 0, 0x94, 0, 0xAC, 12),
131 PINGROUP(LD1, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 1, 0x94, 2, 0xAC, 12),
132 PINGROUP(LD10, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 10, 0x94, 20, 0xAC, 12),
133 PINGROUP(LD11, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 11, 0x94, 22, 0xAC, 12),
134 PINGROUP(LD12, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 12, 0x94, 24, 0xAC, 12),
135 PINGROUP(LD13, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 13, 0x94, 26, 0xAC, 12),
136 PINGROUP(LD14, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 14, 0x94, 28, 0xAC, 12),
137 PINGROUP(LD15, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 15, 0x94, 30, 0xAC, 12),
138 PINGROUP(LD16, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 16, 0x98, 0, 0xAC, 12),
139 PINGROUP(LD17, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 17, 0x98, 2, 0xAC, 12),
140 PINGROUP(LD2, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 2, 0x94, 4, 0xAC, 12),
141 PINGROUP(LD3, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 3, 0x94, 6, 0xAC, 12),
142 PINGROUP(LD4, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 4, 0x94, 8, 0xAC, 12),
143 PINGROUP(LD5, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 5, 0x94, 10, 0xAC, 12),
144 PINGROUP(LD6, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 6, 0x94, 12, 0xAC, 12),
145 PINGROUP(LD7, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 7, 0x94, 14, 0xAC, 12),
146 PINGROUP(LD8, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 8, 0x94, 16, 0xAC, 12),
147 PINGROUP(LD9, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 9, 0x94, 18, 0xAC, 12),
148 PINGROUP(LDC, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 30, 0x90, 14, 0xAC, 20),
149 PINGROUP(LDI, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x20, 6, 0x98, 16, 0xAC, 18),
150 PINGROUP(LHP0, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 18, 0x98, 10, 0xAC, 16),
151 PINGROUP(LHP1, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 19, 0x98, 4, 0xAC, 14),
152 PINGROUP(LHP2, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 20, 0x98, 6, 0xAC, 14),
153 PINGROUP(LHS, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x20, 7, 0x90, 22, 0xAC, 22),
154 PINGROUP(LM0, LCD, DISPLAYA, DISPLAYB, SPI3, RSVD, RSVD4, 0x1C, 24, 0x90, 26, 0xAC, 22),
155 PINGROUP(LM1, LCD, DISPLAYA, DISPLAYB, RSVD, CRT, RSVD3, 0x1C, 25, 0x90, 28, 0xAC, 22),
156 PINGROUP(LPP, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x20, 8, 0x98, 14, 0xAC, 18),
157 PINGROUP(LPW0, LCD, DISPLAYA, DISPLAYB, SPI3, HDMI, DISPLAYA, 0x20, 3, 0x90, 0, 0xAC, 20),
158 PINGROUP(LPW1, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x20, 4, 0x90, 2, 0xAC, 20),
159 PINGROUP(LPW2, LCD, DISPLAYA, DISPLAYB, SPI3, HDMI, DISPLAYA, 0x20, 5, 0x90, 4, 0xAC, 20),
160 PINGROUP(LSC0, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 27, 0x90, 18, 0xAC, 22),
161 PINGROUP(LSC1, LCD, DISPLAYA, DISPLAYB, SPI3, HDMI, DISPLAYA, 0x1C, 28, 0x90, 20, 0xAC, 20),
162 PINGROUP(LSCK, LCD, DISPLAYA, DISPLAYB, SPI3, HDMI, DISPLAYA, 0x1C, 29, 0x90, 16, 0xAC, 20),
163 PINGROUP(LSDA, LCD, DISPLAYA, DISPLAYB, SPI3, HDMI, DISPLAYA, 0x20, 1, 0x90, 8, 0xAC, 20),
164 PINGROUP(LSDI, LCD, DISPLAYA, DISPLAYB, SPI3, RSVD, DISPLAYA, 0x20, 2, 0x90, 6, 0xAC, 20),
165 PINGROUP(LSPI, LCD, DISPLAYA, DISPLAYB, XIO, HDMI, DISPLAYA, 0x20, 0, 0x90, 10, 0xAC, 22),
166 PINGROUP(LVP0, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 21, 0x90, 30, 0xAC, 22),
167 PINGROUP(LVP1, LCD, DISPLAYA, DISPLAYB, RSVD, RSVD, RSVD4, 0x1C, 22, 0x98, 8, 0xAC, 16),
168 PINGROUP(LVS, LCD, DISPLAYA, DISPLAYB, XIO, RSVD, RSVD4, 0x1C, 26, 0x90, 24, 0xAC, 22),
169 PINGROUP(OWC, SYS, OWR, RSVD, RSVD, RSVD, OWR, 0x14, 31, 0x84, 8, 0xB0, 30),
170 PINGROUP(PMC, SYS, PWR_ON, PWR_INTR, RSVD, RSVD, PWR_ON, 0x14, 23, 0x98, 18, -1, -1),
171 PINGROUP(PTA, NAND, I2C2, HDMI, GMI, RSVD, RSVD4, 0x14, 24, 0x98, 22, 0xA4, 4),
172 PINGROUP(RM, UART, I2C, RSVD, RSVD, RSVD, RSVD4, 0x14, 25, 0x80, 14, 0xA4, 0),
173 PINGROUP(SDB, SD, UARTA, PWM, SDIO3, SPI2, PWM, 0x20, 15, 0x8C, 10, -1, -1),
174 PINGROUP(SDC, SD, PWM, TWC, SDIO3, SPI3, TWC, 0x18, 1, 0x8C, 12, 0xAC, 28),
175 PINGROUP(SDD, SD, UARTA, PWM, SDIO3, SPI3, PWM, 0x18, 2, 0x8C, 14, 0xAC, 30),
176 PINGROUP(SDIO1, BB, SDIO1, RSVD, UARTE, UARTA, RSVD2, 0x14, 30, 0x80, 30, 0xB0, 18),
177 PINGROUP(SLXA, SD, PCIE, SPI4, SDIO3, SPI2, PCIE, 0x18, 3, 0x84, 6, 0xA4, 22),
178 PINGROUP(SLXC, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4, 0x18, 5, 0x84, 10, 0xA4, 26),
179 PINGROUP(SLXD, SD, SPDIF, SPI4, SDIO3, SPI2, SPI4, 0x18, 6, 0x84, 12, 0xA4, 28),
180 PINGROUP(SLXK, SD, PCIE, SPI4, SDIO3, SPI2, PCIE, 0x18, 7, 0x84, 14, 0xA4, 30),
181 PINGROUP(SPDI, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2, 0x18, 8, 0x8C, 8, 0xA4, 16),
182 PINGROUP(SPDO, AUDIO, SPDIF, RSVD, I2C, SDIO2, RSVD2, 0x18, 9, 0x8C, 6, 0xA4, 18),
183 PINGROUP(SPIA, AUDIO, SPI1, SPI2, SPI3, GMI, GMI, 0x18, 10, 0x8C, 30, 0xA8, 4),
184 PINGROUP(SPIB, AUDIO, SPI1, SPI2, SPI3, GMI, GMI, 0x18, 11, 0x8C, 28, 0xA8, 6),
185 PINGROUP(SPIC, AUDIO, SPI1, SPI2, SPI3, GMI, GMI, 0x18, 12, 0x8C, 26, 0xA8, 8),
186 PINGROUP(SPID, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI, 0x18, 13, 0x8C, 24, 0xA8, 10),
187 PINGROUP(SPIE, AUDIO, SPI2, SPI1, SPI2_ALT, GMI, GMI, 0x18, 14, 0x8C, 22, 0xA8, 12),
188 PINGROUP(SPIF, AUDIO, SPI3, SPI1, SPI2, RSVD, RSVD4, 0x18, 15, 0x8C, 20, 0xA8, 14),
189 PINGROUP(SPIG, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT, 0x18, 16, 0x8C, 18, 0xA8, 16),
190 PINGROUP(SPIH, AUDIO, SPI3, SPI2, SPI2_ALT, I2C, SPI2_ALT, 0x18, 17, 0x8C, 16, 0xA8, 18),
191 PINGROUP(UAA, BB, SPI3, MIPI_HS, UARTA, ULPI, MIPI_HS, 0x18, 18, 0x80, 0, 0xAC, 0),
192 PINGROUP(UAB, BB, SPI2, MIPI_HS, UARTA, ULPI, MIPI_HS, 0x18, 19, 0x80, 2, 0xAC, 2),
193 PINGROUP(UAC, BB, OWR, RSVD, RSVD, RSVD, RSVD4, 0x18, 20, 0x80, 4, 0xAC, 4),
194 PINGROUP(UAD, UART, IRDA, SPDIF, UARTA, SPI4, SPDIF, 0x18, 21, 0x80, 6, 0xAC, 6),
195 PINGROUP(UCA, UART, UARTC, RSVD, GMI, RSVD, RSVD4, 0x18, 22, 0x84, 16, 0xAC, 8),
196 PINGROUP(UCB, UART, UARTC, PWM, GMI, RSVD, RSVD4, 0x18, 23, 0x84, 18, 0xAC, 10),
197 PINGROUP(UDA, BB, SPI1, RSVD, UARTD, ULPI, RSVD2, 0x20, 13, 0x80, 8, 0xB0, 16),
198 /* these pin groups only have pullup and pull down control */
199 PINGROUP(CK32, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 14),
200 PINGROUP(DDRC, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xAC, 26),
201 PINGROUP(PMCA, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 4),
202 PINGROUP(PMCB, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 6),
203 PINGROUP(PMCC, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 8),
204 PINGROUP(PMCD, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 10),
205 PINGROUP(PMCE, SYS, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xB0, 12),
206 PINGROUP(XM2C, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 30),
207 PINGROUP(XM2D, DDR, RSVD, RSVD, RSVD, RSVD, RSVD, -1, -1, -1, -1, 0xA8, 28),
208};
209
210#ifdef CONFIG_PM
211#define TRISTATE_REG_A 0x14
212#define TRISTATE_REG_NUM 4
213#define PIN_MUX_CTL_REG_A 0x80
214#define PIN_MUX_CTL_REG_NUM 8
215#define PULLUPDOWN_REG_A 0xa0
216#define PULLUPDOWN_REG_NUM 5
217
218static u32 pinmux_reg[TRISTATE_REG_NUM + PIN_MUX_CTL_REG_NUM +
219 PULLUPDOWN_REG_NUM];
220
221static inline unsigned long pg_readl(unsigned long offset)
222{
223 return readl(IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
224}
225
226static inline void pg_writel(unsigned long value, unsigned long offset)
227{
228 writel(value, IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
229}
230
231void tegra_pinmux_suspend(void)
232{
233 unsigned int i;
234 u32 *ctx = pinmux_reg;
235
236 for (i = 0; i < TRISTATE_REG_NUM; i++)
237 *ctx++ = pg_readl(TRISTATE_REG_A + i*4);
238
239 for (i = 0; i < PIN_MUX_CTL_REG_NUM; i++)
240 *ctx++ = pg_readl(PIN_MUX_CTL_REG_A + i*4);
241
242 for (i = 0; i < PULLUPDOWN_REG_NUM; i++)
243 *ctx++ = pg_readl(PULLUPDOWN_REG_A + i*4);
244}
245
246void tegra_pinmux_resume(void)
247{
248 unsigned int i;
249 u32 *ctx = pinmux_reg;
250
251 for (i = 0; i < PIN_MUX_CTL_REG_NUM; i++)
252 pg_writel(*ctx++, PIN_MUX_CTL_REG_A + i*4);
253
254 for (i = 0; i < PULLUPDOWN_REG_NUM; i++)
255 pg_writel(*ctx++, PULLUPDOWN_REG_A + i*4);
256
257 for (i = 0; i < TRISTATE_REG_NUM; i++)
258 pg_writel(*ctx++, TRISTATE_REG_A + i*4);
259}
260#endif
diff --git a/arch/arm/mach-tegra/pinmux.c b/arch/arm/mach-tegra/pinmux.c
index 13ae10237e84..f80d507671bc 100644
--- a/arch/arm/mach-tegra/pinmux.c
+++ b/arch/arm/mach-tegra/pinmux.c
@@ -14,7 +14,8 @@
14 * 14 *
15 */ 15 */
16 16
17 17#include <linux/init.h>
18#include <linux/module.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/errno.h> 20#include <linux/errno.h>
20#include <linux/spinlock.h> 21#include <linux/spinlock.h>
@@ -23,21 +24,6 @@
23#include <mach/iomap.h> 24#include <mach/iomap.h>
24#include <mach/pinmux.h> 25#include <mach/pinmux.h>
25 26
26
27#define TEGRA_TRI_STATE(x) (0x14 + (4 * (x)))
28#define TEGRA_PP_MUX_CTL(x) (0x80 + (4 * (x)))
29#define TEGRA_PP_PU_PD(x) (0xa0 + (4 * (x)))
30
31#define REG_A 0
32#define REG_B 1
33#define REG_C 2
34#define REG_D 3
35#define REG_E 4
36#define REG_F 5
37#define REG_G 6
38
39#define REG_N -1
40
41#define HSM_EN(reg) (((reg) >> 2) & 0x1) 27#define HSM_EN(reg) (((reg) >> 2) & 0x1)
42#define SCHMT_EN(reg) (((reg) >> 3) & 0x1) 28#define SCHMT_EN(reg) (((reg) >> 3) & 0x1)
43#define LPMD(reg) (((reg) >> 4) & 0x3) 29#define LPMD(reg) (((reg) >> 4) & 0x3)
@@ -46,154 +32,8 @@
46#define SLWR(reg) (((reg) >> 28) & 0x3) 32#define SLWR(reg) (((reg) >> 28) & 0x3)
47#define SLWF(reg) (((reg) >> 30) & 0x3) 33#define SLWF(reg) (((reg) >> 30) & 0x3)
48 34
49struct tegra_pingroup_desc { 35static const struct tegra_pingroup_desc *const pingroups = tegra_soc_pingroups;
50 const char *name; 36static const struct tegra_drive_pingroup_desc *const drive_pingroups = tegra_soc_drive_pingroups;
51 int funcs[4];
52 s8 tri_reg; /* offset into the TRISTATE_REG_* register bank */
53 s8 tri_bit; /* offset into the TRISTATE_REG_* register bit */
54 s8 mux_reg; /* offset into the PIN_MUX_CTL_* register bank */
55 s8 mux_bit; /* offset into the PIN_MUX_CTL_* register bit */
56 s8 pupd_reg; /* offset into the PULL_UPDOWN_REG_* register bank */
57 s8 pupd_bit; /* offset into the PULL_UPDOWN_REG_* register bit */
58};
59
60#define PINGROUP(pg_name, f0, f1, f2, f3, \
61 tri_r, tri_b, mux_r, mux_b, pupd_r, pupd_b) \
62 [TEGRA_PINGROUP_ ## pg_name] = { \
63 .name = #pg_name, \
64 .funcs = { \
65 TEGRA_MUX_ ## f0, \
66 TEGRA_MUX_ ## f1, \
67 TEGRA_MUX_ ## f2, \
68 TEGRA_MUX_ ## f3, \
69 }, \
70 .tri_reg = REG_ ## tri_r, \
71 .tri_bit = tri_b, \
72 .mux_reg = REG_ ## mux_r, \
73 .mux_bit = mux_b, \
74 .pupd_reg = REG_ ## pupd_r, \
75 .pupd_bit = pupd_b, \
76 }
77
78static const struct tegra_pingroup_desc pingroups[TEGRA_MAX_PINGROUP] = {
79 PINGROUP(ATA, IDE, NAND, GMI, RSVD, A, 0, A, 24, A, 0),
80 PINGROUP(ATB, IDE, NAND, GMI, SDIO4, A, 1, A, 16, A, 2),
81 PINGROUP(ATC, IDE, NAND, GMI, SDIO4, A, 2, A, 22, A, 4),
82 PINGROUP(ATD, IDE, NAND, GMI, SDIO4, A, 3, A, 20, A, 6),
83 PINGROUP(ATE, IDE, NAND, GMI, RSVD, B, 25, A, 12, A, 8),
84 PINGROUP(CDEV1, OSC, PLLA_OUT, PLLM_OUT1, AUDIO_SYNC, A, 4, C, 2, C, 0),
85 PINGROUP(CDEV2, OSC, AHB_CLK, APB_CLK, PLLP_OUT4, A, 5, C, 4, C, 2),
86 PINGROUP(CRTP, CRT, RSVD, RSVD, RSVD, D, 14, G, 20, B, 24),
87 PINGROUP(CSUS, PLLC_OUT1, PLLP_OUT2, PLLP_OUT3, VI_SENSOR_CLK, A, 6, C, 6, D, 24),
88 PINGROUP(DAP1, DAP1, RSVD, GMI, SDIO2, A, 7, C, 20, A, 10),
89 PINGROUP(DAP2, DAP2, TWC, RSVD, GMI, A, 8, C, 22, A, 12),
90 PINGROUP(DAP3, DAP3, RSVD, RSVD, RSVD, A, 9, C, 24, A, 14),
91 PINGROUP(DAP4, DAP4, RSVD, GMI, RSVD, A, 10, C, 26, A, 16),
92 PINGROUP(DDC, I2C2, RSVD, RSVD, RSVD, B, 31, C, 0, E, 28),
93 PINGROUP(DTA, RSVD, SDIO2, VI, RSVD, A, 11, B, 20, A, 18),
94 PINGROUP(DTB, RSVD, RSVD, VI, SPI1, A, 12, B, 22, A, 20),
95 PINGROUP(DTC, RSVD, RSVD, VI, RSVD, A, 13, B, 26, A, 22),
96 PINGROUP(DTD, RSVD, SDIO2, VI, RSVD, A, 14, B, 28, A, 24),
97 PINGROUP(DTE, RSVD, RSVD, VI, SPI1, A, 15, B, 30, A, 26),
98 PINGROUP(DTF, I2C3, RSVD, VI, RSVD, D, 12, G, 30, A, 28),
99 PINGROUP(GMA, UARTE, SPI3, GMI, SDIO4, A, 28, B, 0, E, 20),
100 PINGROUP(GMB, IDE, NAND, GMI, GMI_INT, B, 29, C, 28, E, 22),
101 PINGROUP(GMC, UARTD, SPI4, GMI, SFLASH, A, 29, B, 2, E, 24),
102 PINGROUP(GMD, RSVD, NAND, GMI, SFLASH, B, 30, C, 30, E, 26),
103 PINGROUP(GME, RSVD, DAP5, GMI, SDIO4, B, 0, D, 0, C, 24),
104 PINGROUP(GPU, PWM, UARTA, GMI, RSVD, A, 16, D, 4, B, 20),
105 PINGROUP(GPU7, RTCK, RSVD, RSVD, RSVD, D, 11, G, 28, B, 6),
106 PINGROUP(GPV, PCIE, RSVD, RSVD, RSVD, A, 17, D, 2, A, 30),
107 PINGROUP(HDINT, HDMI, RSVD, RSVD, RSVD, C, 23, B, 4, D, 22),
108 PINGROUP(I2CP, I2C, RSVD, RSVD, RSVD, A, 18, C, 8, B, 2),
109 PINGROUP(IRRX, UARTA, UARTB, GMI, SPI4, A, 20, C, 18, C, 22),
110 PINGROUP(IRTX, UARTA, UARTB, GMI, SPI4, A, 19, C, 16, C, 20),
111 PINGROUP(KBCA, KBC, NAND, SDIO2, EMC_TEST0_DLL, A, 22, C, 10, B, 8),
112 PINGROUP(KBCB, KBC, NAND, SDIO2, MIO, A, 21, C, 12, B, 10),
113 PINGROUP(KBCC, KBC, NAND, TRACE, EMC_TEST1_DLL, B, 26, C, 14, B, 12),
114 PINGROUP(KBCD, KBC, NAND, SDIO2, MIO, D, 10, G, 26, B, 14),
115 PINGROUP(KBCE, KBC, NAND, OWR, RSVD, A, 26, A, 28, E, 2),
116 PINGROUP(KBCF, KBC, NAND, TRACE, MIO, A, 27, A, 26, E, 0),
117 PINGROUP(LCSN, DISPLAYA, DISPLAYB, SPI3, RSVD, C, 31, E, 12, D, 20),
118 PINGROUP(LD0, DISPLAYA, DISPLAYB, XIO, RSVD, C, 0, F, 0, D, 12),
119 PINGROUP(LD1, DISPLAYA, DISPLAYB, XIO, RSVD, C, 1, F, 2, D, 12),
120 PINGROUP(LD10, DISPLAYA, DISPLAYB, XIO, RSVD, C, 10, F, 20, D, 12),
121 PINGROUP(LD11, DISPLAYA, DISPLAYB, XIO, RSVD, C, 11, F, 22, D, 12),
122 PINGROUP(LD12, DISPLAYA, DISPLAYB, XIO, RSVD, C, 12, F, 24, D, 12),
123 PINGROUP(LD13, DISPLAYA, DISPLAYB, XIO, RSVD, C, 13, F, 26, D, 12),
124 PINGROUP(LD14, DISPLAYA, DISPLAYB, XIO, RSVD, C, 14, F, 28, D, 12),
125 PINGROUP(LD15, DISPLAYA, DISPLAYB, XIO, RSVD, C, 15, F, 30, D, 12),
126 PINGROUP(LD16, DISPLAYA, DISPLAYB, XIO, RSVD, C, 16, G, 0, D, 12),
127 PINGROUP(LD17, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 17, G, 2, D, 12),
128 PINGROUP(LD2, DISPLAYA, DISPLAYB, XIO, RSVD, C, 2, F, 4, D, 12),
129 PINGROUP(LD3, DISPLAYA, DISPLAYB, XIO, RSVD, C, 3, F, 6, D, 12),
130 PINGROUP(LD4, DISPLAYA, DISPLAYB, XIO, RSVD, C, 4, F, 8, D, 12),
131 PINGROUP(LD5, DISPLAYA, DISPLAYB, XIO, RSVD, C, 5, F, 10, D, 12),
132 PINGROUP(LD6, DISPLAYA, DISPLAYB, XIO, RSVD, C, 6, F, 12, D, 12),
133 PINGROUP(LD7, DISPLAYA, DISPLAYB, XIO, RSVD, C, 7, F, 14, D, 12),
134 PINGROUP(LD8, DISPLAYA, DISPLAYB, XIO, RSVD, C, 8, F, 16, D, 12),
135 PINGROUP(LD9, DISPLAYA, DISPLAYB, XIO, RSVD, C, 9, F, 18, D, 12),
136 PINGROUP(LDC, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 30, E, 14, D, 20),
137 PINGROUP(LDI, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 6, G, 16, D, 18),
138 PINGROUP(LHP0, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 18, G, 10, D, 16),
139 PINGROUP(LHP1, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 19, G, 4, D, 14),
140 PINGROUP(LHP2, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 20, G, 6, D, 14),
141 PINGROUP(LHS, DISPLAYA, DISPLAYB, XIO, RSVD, D, 7, E, 22, D, 22),
142 PINGROUP(LM0, DISPLAYA, DISPLAYB, SPI3, RSVD, C, 24, E, 26, D, 22),
143 PINGROUP(LM1, DISPLAYA, DISPLAYB, RSVD, CRT, C, 25, E, 28, D, 22),
144 PINGROUP(LPP, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 8, G, 14, D, 18),
145 PINGROUP(LPW0, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 3, E, 0, D, 20),
146 PINGROUP(LPW1, DISPLAYA, DISPLAYB, RSVD, RSVD, D, 4, E, 2, D, 20),
147 PINGROUP(LPW2, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 5, E, 4, D, 20),
148 PINGROUP(LSC0, DISPLAYA, DISPLAYB, XIO, RSVD, C, 27, E, 18, D, 22),
149 PINGROUP(LSC1, DISPLAYA, DISPLAYB, SPI3, HDMI, C, 28, E, 20, D, 20),
150 PINGROUP(LSCK, DISPLAYA, DISPLAYB, SPI3, HDMI, C, 29, E, 16, D, 20),
151 PINGROUP(LSDA, DISPLAYA, DISPLAYB, SPI3, HDMI, D, 1, E, 8, D, 20),
152 PINGROUP(LSDI, DISPLAYA, DISPLAYB, SPI3, RSVD, D, 2, E, 6, D, 20),
153 PINGROUP(LSPI, DISPLAYA, DISPLAYB, XIO, HDMI, D, 0, E, 10, D, 22),
154 PINGROUP(LVP0, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 21, E, 30, D, 22),
155 PINGROUP(LVP1, DISPLAYA, DISPLAYB, RSVD, RSVD, C, 22, G, 8, D, 16),
156 PINGROUP(LVS, DISPLAYA, DISPLAYB, XIO, RSVD, C, 26, E, 24, D, 22),
157 PINGROUP(OWC, OWR, RSVD, RSVD, RSVD, A, 31, B, 8, E, 30),
158 PINGROUP(PMC, PWR_ON, PWR_INTR, RSVD, RSVD, A, 23, G, 18, N, -1),
159 PINGROUP(PTA, I2C2, HDMI, GMI, RSVD, A, 24, G, 22, B, 4),
160 PINGROUP(RM, I2C, RSVD, RSVD, RSVD, A, 25, A, 14, B, 0),
161 PINGROUP(SDB, UARTA, PWM, SDIO3, SPI2, D, 15, D, 10, N, -1),
162 PINGROUP(SDC, PWM, TWC, SDIO3, SPI3, B, 1, D, 12, D, 28),
163 PINGROUP(SDD, UARTA, PWM, SDIO3, SPI3, B, 2, D, 14, D, 30),
164 PINGROUP(SDIO1, SDIO1, RSVD, UARTE, UARTA, A, 30, A, 30, E, 18),
165 PINGROUP(SLXA, PCIE, SPI4, SDIO3, SPI2, B, 3, B, 6, B, 22),
166 PINGROUP(SLXC, SPDIF, SPI4, SDIO3, SPI2, B, 5, B, 10, B, 26),
167 PINGROUP(SLXD, SPDIF, SPI4, SDIO3, SPI2, B, 6, B, 12, B, 28),
168 PINGROUP(SLXK, PCIE, SPI4, SDIO3, SPI2, B, 7, B, 14, B, 30),
169 PINGROUP(SPDI, SPDIF, RSVD, I2C, SDIO2, B, 8, D, 8, B, 16),
170 PINGROUP(SPDO, SPDIF, RSVD, I2C, SDIO2, B, 9, D, 6, B, 18),
171 PINGROUP(SPIA, SPI1, SPI2, SPI3, GMI, B, 10, D, 30, C, 4),
172 PINGROUP(SPIB, SPI1, SPI2, SPI3, GMI, B, 11, D, 28, C, 6),
173 PINGROUP(SPIC, SPI1, SPI2, SPI3, GMI, B, 12, D, 26, C, 8),
174 PINGROUP(SPID, SPI2, SPI1, SPI2_ALT, GMI, B, 13, D, 24, C, 10),
175 PINGROUP(SPIE, SPI2, SPI1, SPI2_ALT, GMI, B, 14, D, 22, C, 12),
176 PINGROUP(SPIF, SPI3, SPI1, SPI2, RSVD, B, 15, D, 20, C, 14),
177 PINGROUP(SPIG, SPI3, SPI2, SPI2_ALT, I2C, B, 16, D, 18, C, 16),
178 PINGROUP(SPIH, SPI3, SPI2, SPI2_ALT, I2C, B, 17, D, 16, C, 18),
179 PINGROUP(UAA, SPI3, MIPI_HS, UARTA, ULPI, B, 18, A, 0, D, 0),
180 PINGROUP(UAB, SPI2, MIPI_HS, UARTA, ULPI, B, 19, A, 2, D, 2),
181 PINGROUP(UAC, OWR, RSVD, RSVD, RSVD, B, 20, A, 4, D, 4),
182 PINGROUP(UAD, IRDA, SPDIF, UARTA, SPI4, B, 21, A, 6, D, 6),
183 PINGROUP(UCA, UARTC, RSVD, GMI, RSVD, B, 22, B, 16, D, 8),
184 PINGROUP(UCB, UARTC, PWM, GMI, RSVD, B, 23, B, 18, D, 10),
185 PINGROUP(UDA, SPI1, RSVD, UARTD, ULPI, D, 13, A, 8, E, 16),
186 /* these pin groups only have pullup and pull down control */
187 PINGROUP(CK32, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 14),
188 PINGROUP(DDRC, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, D, 26),
189 PINGROUP(PMCA, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 4),
190 PINGROUP(PMCB, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 6),
191 PINGROUP(PMCC, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 8),
192 PINGROUP(PMCD, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 10),
193 PINGROUP(PMCE, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, E, 12),
194 PINGROUP(XM2C, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, C, 30),
195 PINGROUP(XM2D, RSVD, RSVD, RSVD, RSVD, N, -1, N, -1, C, 28),
196};
197 37
198static char *tegra_mux_names[TEGRA_MAX_MUX] = { 38static char *tegra_mux_names[TEGRA_MAX_MUX] = {
199 [TEGRA_MUX_AHB_CLK] = "AHB_CLK", 39 [TEGRA_MUX_AHB_CLK] = "AHB_CLK",
@@ -256,48 +96,7 @@ static char *tegra_mux_names[TEGRA_MAX_MUX] = {
256 [TEGRA_MUX_VI] = "VI", 96 [TEGRA_MUX_VI] = "VI",
257 [TEGRA_MUX_VI_SENSOR_CLK] = "VI_SENSOR_CLK", 97 [TEGRA_MUX_VI_SENSOR_CLK] = "VI_SENSOR_CLK",
258 [TEGRA_MUX_XIO] = "XIO", 98 [TEGRA_MUX_XIO] = "XIO",
259}; 99 [TEGRA_MUX_SAFE] = "<safe>",
260
261struct tegra_drive_pingroup_desc {
262 const char *name;
263 s16 reg;
264};
265
266#define DRIVE_PINGROUP(pg_name, r) \
267 [TEGRA_DRIVE_PINGROUP_ ## pg_name] = { \
268 .name = #pg_name, \
269 .reg = r \
270 }
271
272static const struct tegra_drive_pingroup_desc drive_pingroups[TEGRA_MAX_PINGROUP] = {
273 DRIVE_PINGROUP(AO1, 0x868),
274 DRIVE_PINGROUP(AO2, 0x86c),
275 DRIVE_PINGROUP(AT1, 0x870),
276 DRIVE_PINGROUP(AT2, 0x874),
277 DRIVE_PINGROUP(CDEV1, 0x878),
278 DRIVE_PINGROUP(CDEV2, 0x87c),
279 DRIVE_PINGROUP(CSUS, 0x880),
280 DRIVE_PINGROUP(DAP1, 0x884),
281 DRIVE_PINGROUP(DAP2, 0x888),
282 DRIVE_PINGROUP(DAP3, 0x88c),
283 DRIVE_PINGROUP(DAP4, 0x890),
284 DRIVE_PINGROUP(DBG, 0x894),
285 DRIVE_PINGROUP(LCD1, 0x898),
286 DRIVE_PINGROUP(LCD2, 0x89c),
287 DRIVE_PINGROUP(SDMMC2, 0x8a0),
288 DRIVE_PINGROUP(SDMMC3, 0x8a4),
289 DRIVE_PINGROUP(SPI, 0x8a8),
290 DRIVE_PINGROUP(UAA, 0x8ac),
291 DRIVE_PINGROUP(UAB, 0x8b0),
292 DRIVE_PINGROUP(UART2, 0x8b4),
293 DRIVE_PINGROUP(UART3, 0x8b8),
294 DRIVE_PINGROUP(VI1, 0x8bc),
295 DRIVE_PINGROUP(VI2, 0x8c0),
296 DRIVE_PINGROUP(XM2A, 0x8c4),
297 DRIVE_PINGROUP(XM2C, 0x8c8),
298 DRIVE_PINGROUP(XM2D, 0x8cc),
299 DRIVE_PINGROUP(XM2CLK, 0x8d0),
300 DRIVE_PINGROUP(MEMCOMP, 0x8d4),
301}; 100};
302 101
303static const char *tegra_drive_names[TEGRA_MAX_DRIVE] = { 102static const char *tegra_drive_names[TEGRA_MAX_DRIVE] = {
@@ -381,22 +180,27 @@ static inline void pg_writel(unsigned long value, unsigned long offset)
381 writel(value, IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset)); 180 writel(value, IO_TO_VIRT(TEGRA_APB_MISC_BASE + offset));
382} 181}
383 182
384int tegra_pinmux_set_func(enum tegra_pingroup pg, enum tegra_mux_func func) 183static int tegra_pinmux_set_func(const struct tegra_pingroup_config *config)
385{ 184{
386 int mux = -1; 185 int mux = -1;
387 int i; 186 int i;
388 unsigned long reg; 187 unsigned long reg;
389 unsigned long flags; 188 unsigned long flags;
189 enum tegra_pingroup pg = config->pingroup;
190 enum tegra_mux_func func = config->func;
390 191
391 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) 192 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
392 return -ERANGE; 193 return -ERANGE;
393 194
394 if (pingroups[pg].mux_reg == REG_N) 195 if (pingroups[pg].mux_reg < 0)
395 return -EINVAL; 196 return -EINVAL;
396 197
397 if (func < 0) 198 if (func < 0)
398 return -ERANGE; 199 return -ERANGE;
399 200
201 if (func == TEGRA_MUX_SAFE)
202 func = pingroups[pg].func_safe;
203
400 if (func & TEGRA_MUX_RSVD) { 204 if (func & TEGRA_MUX_RSVD) {
401 mux = func & 0x3; 205 mux = func & 0x3;
402 } else { 206 } else {
@@ -413,10 +217,10 @@ int tegra_pinmux_set_func(enum tegra_pingroup pg, enum tegra_mux_func func)
413 217
414 spin_lock_irqsave(&mux_lock, flags); 218 spin_lock_irqsave(&mux_lock, flags);
415 219
416 reg = pg_readl(TEGRA_PP_MUX_CTL(pingroups[pg].mux_reg)); 220 reg = pg_readl(pingroups[pg].mux_reg);
417 reg &= ~(0x3 << pingroups[pg].mux_bit); 221 reg &= ~(0x3 << pingroups[pg].mux_bit);
418 reg |= mux << pingroups[pg].mux_bit; 222 reg |= mux << pingroups[pg].mux_bit;
419 pg_writel(reg, TEGRA_PP_MUX_CTL(pingroups[pg].mux_reg)); 223 pg_writel(reg, pingroups[pg].mux_reg);
420 224
421 spin_unlock_irqrestore(&mux_lock, flags); 225 spin_unlock_irqrestore(&mux_lock, flags);
422 226
@@ -432,16 +236,16 @@ int tegra_pinmux_set_tristate(enum tegra_pingroup pg,
432 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) 236 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
433 return -ERANGE; 237 return -ERANGE;
434 238
435 if (pingroups[pg].tri_reg == REG_N) 239 if (pingroups[pg].tri_reg < 0)
436 return -EINVAL; 240 return -EINVAL;
437 241
438 spin_lock_irqsave(&mux_lock, flags); 242 spin_lock_irqsave(&mux_lock, flags);
439 243
440 reg = pg_readl(TEGRA_TRI_STATE(pingroups[pg].tri_reg)); 244 reg = pg_readl(pingroups[pg].tri_reg);
441 reg &= ~(0x1 << pingroups[pg].tri_bit); 245 reg &= ~(0x1 << pingroups[pg].tri_bit);
442 if (tristate) 246 if (tristate)
443 reg |= 1 << pingroups[pg].tri_bit; 247 reg |= 1 << pingroups[pg].tri_bit;
444 pg_writel(reg, TEGRA_TRI_STATE(pingroups[pg].tri_reg)); 248 pg_writel(reg, pingroups[pg].tri_reg);
445 249
446 spin_unlock_irqrestore(&mux_lock, flags); 250 spin_unlock_irqrestore(&mux_lock, flags);
447 251
@@ -457,7 +261,7 @@ int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg,
457 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP) 261 if (pg < 0 || pg >= TEGRA_MAX_PINGROUP)
458 return -ERANGE; 262 return -ERANGE;
459 263
460 if (pingroups[pg].pupd_reg == REG_N) 264 if (pingroups[pg].pupd_reg < 0)
461 return -EINVAL; 265 return -EINVAL;
462 266
463 if (pupd != TEGRA_PUPD_NORMAL && 267 if (pupd != TEGRA_PUPD_NORMAL &&
@@ -468,38 +272,39 @@ int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg,
468 272
469 spin_lock_irqsave(&mux_lock, flags); 273 spin_lock_irqsave(&mux_lock, flags);
470 274
471 reg = pg_readl(TEGRA_PP_PU_PD(pingroups[pg].pupd_reg)); 275 reg = pg_readl(pingroups[pg].pupd_reg);
472 reg &= ~(0x3 << pingroups[pg].pupd_bit); 276 reg &= ~(0x3 << pingroups[pg].pupd_bit);
473 reg |= pupd << pingroups[pg].pupd_bit; 277 reg |= pupd << pingroups[pg].pupd_bit;
474 pg_writel(reg, TEGRA_PP_PU_PD(pingroups[pg].pupd_reg)); 278 pg_writel(reg, pingroups[pg].pupd_reg);
475 279
476 spin_unlock_irqrestore(&mux_lock, flags); 280 spin_unlock_irqrestore(&mux_lock, flags);
477 281
478 return 0; 282 return 0;
479} 283}
480 284
481void tegra_pinmux_config_pingroup(enum tegra_pingroup pingroup, 285static void tegra_pinmux_config_pingroup(const struct tegra_pingroup_config *config)
482 enum tegra_mux_func func,
483 enum tegra_pullupdown pupd,
484 enum tegra_tristate tristate)
485{ 286{
287 enum tegra_pingroup pingroup = config->pingroup;
288 enum tegra_mux_func func = config->func;
289 enum tegra_pullupdown pupd = config->pupd;
290 enum tegra_tristate tristate = config->tristate;
486 int err; 291 int err;
487 292
488 if (pingroups[pingroup].mux_reg != REG_N) { 293 if (pingroups[pingroup].mux_reg >= 0) {
489 err = tegra_pinmux_set_func(pingroup, func); 294 err = tegra_pinmux_set_func(config);
490 if (err < 0) 295 if (err < 0)
491 pr_err("pinmux: can't set pingroup %s func to %s: %d\n", 296 pr_err("pinmux: can't set pingroup %s func to %s: %d\n",
492 pingroup_name(pingroup), func_name(func), err); 297 pingroup_name(pingroup), func_name(func), err);
493 } 298 }
494 299
495 if (pingroups[pingroup].pupd_reg != REG_N) { 300 if (pingroups[pingroup].pupd_reg >= 0) {
496 err = tegra_pinmux_set_pullupdown(pingroup, pupd); 301 err = tegra_pinmux_set_pullupdown(pingroup, pupd);
497 if (err < 0) 302 if (err < 0)
498 pr_err("pinmux: can't set pingroup %s pullupdown to %s: %d\n", 303 pr_err("pinmux: can't set pingroup %s pullupdown to %s: %d\n",
499 pingroup_name(pingroup), pupd_name(pupd), err); 304 pingroup_name(pingroup), pupd_name(pupd), err);
500 } 305 }
501 306
502 if (pingroups[pingroup].tri_reg != REG_N) { 307 if (pingroups[pingroup].tri_reg >= 0) {
503 err = tegra_pinmux_set_tristate(pingroup, tristate); 308 err = tegra_pinmux_set_tristate(pingroup, tristate);
504 if (err < 0) 309 if (err < 0)
505 pr_err("pinmux: can't set pingroup %s tristate to %s: %d\n", 310 pr_err("pinmux: can't set pingroup %s tristate to %s: %d\n",
@@ -507,17 +312,12 @@ void tegra_pinmux_config_pingroup(enum tegra_pingroup pingroup,
507 } 312 }
508} 313}
509 314
510 315void tegra_pinmux_config_table(const struct tegra_pingroup_config *config, int len)
511
512void tegra_pinmux_config_table(struct tegra_pingroup_config *config, int len)
513{ 316{
514 int i; 317 int i;
515 318
516 for (i = 0; i < len; i++) 319 for (i = 0; i < len; i++)
517 tegra_pinmux_config_pingroup(config[i].pingroup, 320 tegra_pinmux_config_pingroup(&config[i]);
518 config[i].func,
519 config[i].pupd,
520 config[i].tristate);
521} 321}
522 322
523static const char *drive_pinmux_name(enum tegra_drive_pingroup pg) 323static const char *drive_pinmux_name(enum tegra_drive_pingroup pg)
@@ -784,6 +584,86 @@ void tegra_drive_pinmux_config_table(struct tegra_drive_pingroup_config *config,
784 config[i].slew_falling); 584 config[i].slew_falling);
785} 585}
786 586
587void tegra_pinmux_set_safe_pinmux_table(const struct tegra_pingroup_config *config,
588 int len)
589{
590 int i;
591 struct tegra_pingroup_config c;
592
593 for (i = 0; i < len; i++) {
594 int err;
595 c = config[i];
596 if (c.pingroup < 0 || c.pingroup >= TEGRA_MAX_PINGROUP) {
597 WARN_ON(1);
598 continue;
599 }
600 c.func = pingroups[c.pingroup].func_safe;
601 err = tegra_pinmux_set_func(&c);
602 if (err < 0)
603 pr_err("%s: tegra_pinmux_set_func returned %d setting "
604 "%s to %s\n", __func__, err,
605 pingroup_name(c.pingroup), func_name(c.func));
606 }
607}
608
609void tegra_pinmux_config_pinmux_table(const struct tegra_pingroup_config *config,
610 int len)
611{
612 int i;
613
614 for (i = 0; i < len; i++) {
615 int err;
616 if (config[i].pingroup < 0 ||
617 config[i].pingroup >= TEGRA_MAX_PINGROUP) {
618 WARN_ON(1);
619 continue;
620 }
621 err = tegra_pinmux_set_func(&config[i]);
622 if (err < 0)
623 pr_err("%s: tegra_pinmux_set_func returned %d setting "
624 "%s to %s\n", __func__, err,
625 pingroup_name(config[i].pingroup),
626 func_name(config[i].func));
627 }
628}
629
630void tegra_pinmux_config_tristate_table(const struct tegra_pingroup_config *config,
631 int len, enum tegra_tristate tristate)
632{
633 int i;
634 int err;
635 enum tegra_pingroup pingroup;
636
637 for (i = 0; i < len; i++) {
638 pingroup = config[i].pingroup;
639 if (pingroups[pingroup].tri_reg >= 0) {
640 err = tegra_pinmux_set_tristate(pingroup, tristate);
641 if (err < 0)
642 pr_err("pinmux: can't set pingroup %s tristate"
643 " to %s: %d\n", pingroup_name(pingroup),
644 tri_name(tristate), err);
645 }
646 }
647}
648
649void tegra_pinmux_config_pullupdown_table(const struct tegra_pingroup_config *config,
650 int len, enum tegra_pullupdown pupd)
651{
652 int i;
653 int err;
654 enum tegra_pingroup pingroup;
655
656 for (i = 0; i < len; i++) {
657 pingroup = config[i].pingroup;
658 if (pingroups[pingroup].pupd_reg >= 0) {
659 err = tegra_pinmux_set_pullupdown(pingroup, pupd);
660 if (err < 0)
661 pr_err("pinmux: can't set pingroup %s pullupdown"
662 " to %s: %d\n", pingroup_name(pingroup),
663 pupd_name(pupd), err);
664 }
665 }
666}
787 667
788#ifdef CONFIG_DEBUG_FS 668#ifdef CONFIG_DEBUG_FS
789 669
@@ -812,11 +692,11 @@ static int dbg_pinmux_show(struct seq_file *s, void *unused)
812 len = strlen(pingroups[i].name); 692 len = strlen(pingroups[i].name);
813 dbg_pad_field(s, 5 - len); 693 dbg_pad_field(s, 5 - len);
814 694
815 if (pingroups[i].mux_reg == REG_N) { 695 if (pingroups[i].mux_reg < 0) {
816 seq_printf(s, "TEGRA_MUX_NONE"); 696 seq_printf(s, "TEGRA_MUX_NONE");
817 len = strlen("NONE"); 697 len = strlen("NONE");
818 } else { 698 } else {
819 mux = (pg_readl(TEGRA_PP_MUX_CTL(pingroups[i].mux_reg)) >> 699 mux = (pg_readl(pingroups[i].mux_reg) >>
820 pingroups[i].mux_bit) & 0x3; 700 pingroups[i].mux_bit) & 0x3;
821 if (pingroups[i].funcs[mux] == TEGRA_MUX_RSVD) { 701 if (pingroups[i].funcs[mux] == TEGRA_MUX_RSVD) {
822 seq_printf(s, "TEGRA_MUX_RSVD%1lu", mux+1); 702 seq_printf(s, "TEGRA_MUX_RSVD%1lu", mux+1);
@@ -829,21 +709,21 @@ static int dbg_pinmux_show(struct seq_file *s, void *unused)
829 } 709 }
830 dbg_pad_field(s, 13-len); 710 dbg_pad_field(s, 13-len);
831 711
832 if (pingroups[i].mux_reg == REG_N) { 712 if (pingroups[i].pupd_reg < 0) {
833 seq_printf(s, "TEGRA_PUPD_NORMAL"); 713 seq_printf(s, "TEGRA_PUPD_NORMAL");
834 len = strlen("NORMAL"); 714 len = strlen("NORMAL");
835 } else { 715 } else {
836 pupd = (pg_readl(TEGRA_PP_PU_PD(pingroups[i].pupd_reg)) >> 716 pupd = (pg_readl(pingroups[i].pupd_reg) >>
837 pingroups[i].pupd_bit) & 0x3; 717 pingroups[i].pupd_bit) & 0x3;
838 seq_printf(s, "TEGRA_PUPD_%s", pupd_name(pupd)); 718 seq_printf(s, "TEGRA_PUPD_%s", pupd_name(pupd));
839 len = strlen(pupd_name(pupd)); 719 len = strlen(pupd_name(pupd));
840 } 720 }
841 dbg_pad_field(s, 9 - len); 721 dbg_pad_field(s, 9 - len);
842 722
843 if (pingroups[i].tri_reg == REG_N) { 723 if (pingroups[i].tri_reg < 0) {
844 seq_printf(s, "TEGRA_TRI_NORMAL"); 724 seq_printf(s, "TEGRA_TRI_NORMAL");
845 } else { 725 } else {
846 tri = (pg_readl(TEGRA_TRI_STATE(pingroups[i].tri_reg)) >> 726 tri = (pg_readl(pingroups[i].tri_reg) >>
847 pingroups[i].tri_bit) & 0x1; 727 pingroups[i].tri_bit) & 0x1;
848 728
849 seq_printf(s, "TEGRA_TRI_%s", tri_name(tri)); 729 seq_printf(s, "TEGRA_TRI_%s", tri_name(tri));
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 426163231fff..ae3b308e22a4 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -30,14 +30,21 @@
30#include <mach/iomap.h> 30#include <mach/iomap.h>
31 31
32#include "clock.h" 32#include "clock.h"
33#include "fuse.h"
34#include "tegra2_dvfs.h"
33 35
34#define RST_DEVICES 0x004 36#define RST_DEVICES 0x004
35#define RST_DEVICES_SET 0x300 37#define RST_DEVICES_SET 0x300
36#define RST_DEVICES_CLR 0x304 38#define RST_DEVICES_CLR 0x304
39#define RST_DEVICES_NUM 3
37 40
38#define CLK_OUT_ENB 0x010 41#define CLK_OUT_ENB 0x010
39#define CLK_OUT_ENB_SET 0x320 42#define CLK_OUT_ENB_SET 0x320
40#define CLK_OUT_ENB_CLR 0x324 43#define CLK_OUT_ENB_CLR 0x324
44#define CLK_OUT_ENB_NUM 3
45
46#define CLK_MASK_ARM 0x44
47#define MISC_CLK_ENB 0x48
41 48
42#define OSC_CTRL 0x50 49#define OSC_CTRL 0x50
43#define OSC_CTRL_OSC_FREQ_MASK (3<<30) 50#define OSC_CTRL_OSC_FREQ_MASK (3<<30)
@@ -45,6 +52,7 @@
45#define OSC_CTRL_OSC_FREQ_19_2MHZ (1<<30) 52#define OSC_CTRL_OSC_FREQ_19_2MHZ (1<<30)
46#define OSC_CTRL_OSC_FREQ_12MHZ (2<<30) 53#define OSC_CTRL_OSC_FREQ_12MHZ (2<<30)
47#define OSC_CTRL_OSC_FREQ_26MHZ (3<<30) 54#define OSC_CTRL_OSC_FREQ_26MHZ (3<<30)
55#define OSC_CTRL_MASK 0x3f2
48 56
49#define OSC_FREQ_DET 0x58 57#define OSC_FREQ_DET 0x58
50#define OSC_FREQ_DET_TRIG (1<<31) 58#define OSC_FREQ_DET_TRIG (1<<31)
@@ -53,10 +61,17 @@
53#define OSC_FREQ_DET_BUSY (1<<31) 61#define OSC_FREQ_DET_BUSY (1<<31)
54#define OSC_FREQ_DET_CNT_MASK 0xFFFF 62#define OSC_FREQ_DET_CNT_MASK 0xFFFF
55 63
64#define PERIPH_CLK_SOURCE_I2S1 0x100
65#define PERIPH_CLK_SOURCE_EMC 0x19c
66#define PERIPH_CLK_SOURCE_OSC 0x1fc
67#define PERIPH_CLK_SOURCE_NUM \
68 ((PERIPH_CLK_SOURCE_OSC - PERIPH_CLK_SOURCE_I2S1) / 4)
69
56#define PERIPH_CLK_SOURCE_MASK (3<<30) 70#define PERIPH_CLK_SOURCE_MASK (3<<30)
57#define PERIPH_CLK_SOURCE_SHIFT 30 71#define PERIPH_CLK_SOURCE_SHIFT 30
58#define PERIPH_CLK_SOURCE_ENABLE (1<<28) 72#define PERIPH_CLK_SOURCE_ENABLE (1<<28)
59#define PERIPH_CLK_SOURCE_DIV_MASK 0xFF 73#define PERIPH_CLK_SOURCE_DIVU71_MASK 0xFF
74#define PERIPH_CLK_SOURCE_DIVU16_MASK 0xFFFF
60#define PERIPH_CLK_SOURCE_DIV_SHIFT 0 75#define PERIPH_CLK_SOURCE_DIV_SHIFT 0
61 76
62#define PLL_BASE 0x0 77#define PLL_BASE 0x0
@@ -79,8 +94,9 @@
79#define PLL_OUT_RESET_DISABLE (1<<0) 94#define PLL_OUT_RESET_DISABLE (1<<0)
80 95
81#define PLL_MISC(c) (((c)->flags & PLL_ALT_MISC_REG) ? 0x4 : 0xc) 96#define PLL_MISC(c) (((c)->flags & PLL_ALT_MISC_REG) ? 0x4 : 0xc)
97#define PLL_MISC_LOCK_ENABLE(c) (((c)->flags & PLLU) ? (1<<22) : (1<<18))
98
82#define PLL_MISC_DCCON_SHIFT 20 99#define PLL_MISC_DCCON_SHIFT 20
83#define PLL_MISC_LOCK_ENABLE (1<<18)
84#define PLL_MISC_CPCON_SHIFT 8 100#define PLL_MISC_CPCON_SHIFT 8
85#define PLL_MISC_CPCON_MASK (0xF<<PLL_MISC_CPCON_SHIFT) 101#define PLL_MISC_CPCON_MASK (0xF<<PLL_MISC_CPCON_SHIFT)
86#define PLL_MISC_LFCON_SHIFT 4 102#define PLL_MISC_LFCON_SHIFT 4
@@ -88,10 +104,14 @@
88#define PLL_MISC_VCOCON_SHIFT 0 104#define PLL_MISC_VCOCON_SHIFT 0
89#define PLL_MISC_VCOCON_MASK (0xF<<PLL_MISC_VCOCON_SHIFT) 105#define PLL_MISC_VCOCON_MASK (0xF<<PLL_MISC_VCOCON_SHIFT)
90 106
107#define PLLU_BASE_POST_DIV (1<<20)
108
91#define PLLD_MISC_CLKENABLE (1<<30) 109#define PLLD_MISC_CLKENABLE (1<<30)
92#define PLLD_MISC_DIV_RST (1<<23) 110#define PLLD_MISC_DIV_RST (1<<23)
93#define PLLD_MISC_DCCON_SHIFT 12 111#define PLLD_MISC_DCCON_SHIFT 12
94 112
113#define PLLE_MISC_READY (1 << 15)
114
95#define PERIPH_CLK_TO_ENB_REG(c) ((c->clk_num / 32) * 4) 115#define PERIPH_CLK_TO_ENB_REG(c) ((c->clk_num / 32) * 4)
96#define PERIPH_CLK_TO_ENB_SET_REG(c) ((c->clk_num / 32) * 8) 116#define PERIPH_CLK_TO_ENB_SET_REG(c) ((c->clk_num / 32) * 8)
97#define PERIPH_CLK_TO_ENB_BIT(c) (1 << (c->clk_num % 32)) 117#define PERIPH_CLK_TO_ENB_BIT(c) (1 << (c->clk_num % 32))
@@ -143,30 +163,37 @@ unsigned long clk_measure_input_freq(void)
143 } 163 }
144} 164}
145 165
146static int clk_div71_get_divider(struct clk *c, unsigned long rate) 166static int clk_div71_get_divider(unsigned long parent_rate, unsigned long rate)
147{ 167{
148 unsigned long divider_u71; 168 s64 divider_u71 = parent_rate * 2;
169 divider_u71 += rate - 1;
170 do_div(divider_u71, rate);
149 171
150 divider_u71 = DIV_ROUND_UP(c->rate * 2, rate); 172 if (divider_u71 - 2 < 0)
173 return 0;
151 174
152 if (divider_u71 - 2 > 255 || divider_u71 - 2 < 0) 175 if (divider_u71 - 2 > 255)
153 return -EINVAL; 176 return -EINVAL;
154 177
155 return divider_u71 - 2; 178 return divider_u71 - 2;
156} 179}
157 180
158static unsigned long tegra2_clk_recalculate_rate(struct clk *c) 181static int clk_div16_get_divider(unsigned long parent_rate, unsigned long rate)
159{ 182{
160 unsigned long rate; 183 s64 divider_u16;
161 rate = c->parent->rate;
162 184
163 if (c->mul != 0 && c->div != 0) 185 divider_u16 = parent_rate;
164 c->rate = rate * c->mul / c->div; 186 divider_u16 += rate - 1;
165 else 187 do_div(divider_u16, rate);
166 c->rate = rate; 188
167 return c->rate; 189 if (divider_u16 - 1 < 0)
168} 190 return 0;
169 191
192 if (divider_u16 - 1 > 255)
193 return -EINVAL;
194
195 return divider_u16 - 1;
196}
170 197
171/* clk_m functions */ 198/* clk_m functions */
172static unsigned long tegra2_clk_m_autodetect_rate(struct clk *c) 199static unsigned long tegra2_clk_m_autodetect_rate(struct clk *c)
@@ -244,7 +271,6 @@ static void tegra2_super_clk_init(struct clk *c)
244 } 271 }
245 BUG_ON(sel->input == NULL); 272 BUG_ON(sel->input == NULL);
246 c->parent = sel->input; 273 c->parent = sel->input;
247 tegra2_clk_recalculate_rate(c);
248} 274}
249 275
250static int tegra2_super_clk_enable(struct clk *c) 276static int tegra2_super_clk_enable(struct clk *c)
@@ -266,6 +292,7 @@ static int tegra2_super_clk_set_parent(struct clk *c, struct clk *p)
266 u32 val; 292 u32 val;
267 const struct clk_mux_sel *sel; 293 const struct clk_mux_sel *sel;
268 int shift; 294 int shift;
295
269 val = clk_readl(c->reg + SUPER_CLK_MUX);; 296 val = clk_readl(c->reg + SUPER_CLK_MUX);;
270 BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) && 297 BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) &&
271 ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE)); 298 ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE));
@@ -273,11 +300,18 @@ static int tegra2_super_clk_set_parent(struct clk *c, struct clk *p)
273 SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT; 300 SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT;
274 for (sel = c->inputs; sel->input != NULL; sel++) { 301 for (sel = c->inputs; sel->input != NULL; sel++) {
275 if (sel->input == p) { 302 if (sel->input == p) {
276 clk_reparent(c, p);
277 val &= ~(SUPER_SOURCE_MASK << shift); 303 val &= ~(SUPER_SOURCE_MASK << shift);
278 val |= sel->value << shift; 304 val |= sel->value << shift;
305
306 if (c->refcnt)
307 clk_enable_locked(p);
308
279 clk_writel(val, c->reg); 309 clk_writel(val, c->reg);
280 c->rate = c->parent->rate; 310
311 if (c->refcnt && c->parent)
312 clk_disable_locked(c->parent);
313
314 clk_reparent(c, p);
281 return 0; 315 return 0;
282 } 316 }
283 } 317 }
@@ -289,7 +323,61 @@ static struct clk_ops tegra_super_ops = {
289 .enable = tegra2_super_clk_enable, 323 .enable = tegra2_super_clk_enable,
290 .disable = tegra2_super_clk_disable, 324 .disable = tegra2_super_clk_disable,
291 .set_parent = tegra2_super_clk_set_parent, 325 .set_parent = tegra2_super_clk_set_parent,
292 .recalculate_rate = tegra2_clk_recalculate_rate, 326};
327
328/* virtual cpu clock functions */
329/* some clocks can not be stopped (cpu, memory bus) while the SoC is running.
330 To change the frequency of these clocks, the parent pll may need to be
331 reprogrammed, so the clock must be moved off the pll, the pll reprogrammed,
332 and then the clock moved back to the pll. To hide this sequence, a virtual
333 clock handles it.
334 */
335static void tegra2_cpu_clk_init(struct clk *c)
336{
337}
338
339static int tegra2_cpu_clk_enable(struct clk *c)
340{
341 return 0;
342}
343
344static void tegra2_cpu_clk_disable(struct clk *c)
345{
346 pr_debug("%s on clock %s\n", __func__, c->name);
347
348 /* oops - don't disable the CPU clock! */
349 BUG();
350}
351
352static int tegra2_cpu_clk_set_rate(struct clk *c, unsigned long rate)
353{
354 int ret;
355 ret = clk_set_parent_locked(c->parent, c->backup);
356 if (ret) {
357 pr_err("Failed to switch cpu to clock %s\n", c->backup->name);
358 return ret;
359 }
360
361 ret = clk_set_rate_locked(c->main, rate);
362 if (ret) {
363 pr_err("Failed to change cpu pll to %lu\n", rate);
364 return ret;
365 }
366
367 ret = clk_set_parent_locked(c->parent, c->main);
368 if (ret) {
369 pr_err("Failed to switch cpu to clock %s\n", c->main->name);
370 return ret;
371 }
372
373 return 0;
374}
375
376static struct clk_ops tegra_cpu_ops = {
377 .init = tegra2_cpu_clk_init,
378 .enable = tegra2_cpu_clk_enable,
379 .disable = tegra2_cpu_clk_disable,
380 .set_rate = tegra2_cpu_clk_set_rate,
293}; 381};
294 382
295/* bus clock functions */ 383/* bus clock functions */
@@ -299,7 +387,6 @@ static void tegra2_bus_clk_init(struct clk *c)
299 c->state = ((val >> c->reg_shift) & BUS_CLK_DISABLE) ? OFF : ON; 387 c->state = ((val >> c->reg_shift) & BUS_CLK_DISABLE) ? OFF : ON;
300 c->div = ((val >> c->reg_shift) & BUS_CLK_DIV_MASK) + 1; 388 c->div = ((val >> c->reg_shift) & BUS_CLK_DIV_MASK) + 1;
301 c->mul = 1; 389 c->mul = 1;
302 tegra2_clk_recalculate_rate(c);
303} 390}
304 391
305static int tegra2_bus_clk_enable(struct clk *c) 392static int tegra2_bus_clk_enable(struct clk *c)
@@ -340,27 +427,15 @@ static struct clk_ops tegra_bus_ops = {
340 .enable = tegra2_bus_clk_enable, 427 .enable = tegra2_bus_clk_enable,
341 .disable = tegra2_bus_clk_disable, 428 .disable = tegra2_bus_clk_disable,
342 .set_rate = tegra2_bus_clk_set_rate, 429 .set_rate = tegra2_bus_clk_set_rate,
343 .recalculate_rate = tegra2_clk_recalculate_rate,
344}; 430};
345 431
346/* PLL Functions */ 432/* PLL Functions */
347static unsigned long tegra2_pll_clk_recalculate_rate(struct clk *c)
348{
349 u64 rate;
350 rate = c->parent->rate;
351 rate *= c->n;
352 do_div(rate, c->m);
353 if (c->p == 2)
354 rate >>= 1;
355 c->rate = rate;
356 return c->rate;
357}
358
359static int tegra2_pll_clk_wait_for_lock(struct clk *c) 433static int tegra2_pll_clk_wait_for_lock(struct clk *c)
360{ 434{
361 ktime_t before; 435 ktime_t before;
362 436
363 before = ktime_get(); 437 before = ktime_get();
438
364 while (!(clk_readl(c->reg + PLL_BASE) & PLL_BASE_LOCK)) { 439 while (!(clk_readl(c->reg + PLL_BASE) & PLL_BASE_LOCK)) {
365 if (ktime_us_delta(ktime_get(), before) > 5000) { 440 if (ktime_us_delta(ktime_get(), before) > 5000) {
366 pr_err("Timed out waiting for lock bit on pll %s", 441 pr_err("Timed out waiting for lock bit on pll %s",
@@ -380,24 +455,19 @@ static void tegra2_pll_clk_init(struct clk *c)
380 455
381 if (c->flags & PLL_FIXED && !(val & PLL_BASE_OVERRIDE)) { 456 if (c->flags & PLL_FIXED && !(val & PLL_BASE_OVERRIDE)) {
382 pr_warning("Clock %s has unknown fixed frequency\n", c->name); 457 pr_warning("Clock %s has unknown fixed frequency\n", c->name);
383 c->n = 1; 458 c->mul = 1;
384 c->m = 0; 459 c->div = 1;
385 c->p = 1;
386 } else if (val & PLL_BASE_BYPASS) { 460 } else if (val & PLL_BASE_BYPASS) {
387 c->n = 1; 461 c->mul = 1;
388 c->m = 1; 462 c->div = 1;
389 c->p = 1;
390 } else { 463 } else {
391 c->n = (val & PLL_BASE_DIVN_MASK) >> PLL_BASE_DIVN_SHIFT; 464 c->mul = (val & PLL_BASE_DIVN_MASK) >> PLL_BASE_DIVN_SHIFT;
392 c->m = (val & PLL_BASE_DIVM_MASK) >> PLL_BASE_DIVM_SHIFT; 465 c->div = (val & PLL_BASE_DIVM_MASK) >> PLL_BASE_DIVM_SHIFT;
393 c->p = (val & PLL_BASE_DIVP_MASK) ? 2 : 1; 466 if (c->flags & PLLU)
467 c->div *= (val & PLLU_BASE_POST_DIV) ? 1 : 2;
468 else
469 c->div *= (val & PLL_BASE_DIVP_MASK) ? 2 : 1;
394 } 470 }
395
396 val = clk_readl(c->reg + PLL_MISC(c));
397 if (c->flags & PLL_HAS_CPCON)
398 c->cpcon = (val & PLL_MISC_CPCON_MASK) >> PLL_MISC_CPCON_SHIFT;
399
400 tegra2_pll_clk_recalculate_rate(c);
401} 471}
402 472
403static int tegra2_pll_clk_enable(struct clk *c) 473static int tegra2_pll_clk_enable(struct clk *c)
@@ -411,7 +481,7 @@ static int tegra2_pll_clk_enable(struct clk *c)
411 clk_writel(val, c->reg + PLL_BASE); 481 clk_writel(val, c->reg + PLL_BASE);
412 482
413 val = clk_readl(c->reg + PLL_MISC(c)); 483 val = clk_readl(c->reg + PLL_MISC(c));
414 val |= PLL_MISC_LOCK_ENABLE; 484 val |= PLL_MISC_LOCK_ENABLE(c);
415 clk_writel(val, c->reg + PLL_MISC(c)); 485 clk_writel(val, c->reg + PLL_MISC(c));
416 486
417 tegra2_pll_clk_wait_for_lock(c); 487 tegra2_pll_clk_wait_for_lock(c);
@@ -441,33 +511,36 @@ static int tegra2_pll_clk_set_rate(struct clk *c, unsigned long rate)
441 input_rate = c->parent->rate; 511 input_rate = c->parent->rate;
442 for (sel = c->pll_table; sel->input_rate != 0; sel++) { 512 for (sel = c->pll_table; sel->input_rate != 0; sel++) {
443 if (sel->input_rate == input_rate && sel->output_rate == rate) { 513 if (sel->input_rate == input_rate && sel->output_rate == rate) {
444 c->n = sel->n; 514 c->mul = sel->n;
445 c->m = sel->m; 515 c->div = sel->m * sel->p;
446 c->p = sel->p;
447 c->cpcon = sel->cpcon;
448 516
449 val = clk_readl(c->reg + PLL_BASE); 517 val = clk_readl(c->reg + PLL_BASE);
450 if (c->flags & PLL_FIXED) 518 if (c->flags & PLL_FIXED)
451 val |= PLL_BASE_OVERRIDE; 519 val |= PLL_BASE_OVERRIDE;
452 val &= ~(PLL_BASE_DIVP_MASK | PLL_BASE_DIVN_MASK | 520 val &= ~(PLL_BASE_DIVP_MASK | PLL_BASE_DIVN_MASK |
453 PLL_BASE_DIVM_MASK); 521 PLL_BASE_DIVM_MASK);
454 val |= (c->m << PLL_BASE_DIVM_SHIFT) | 522 val |= (sel->m << PLL_BASE_DIVM_SHIFT) |
455 (c->n << PLL_BASE_DIVN_SHIFT); 523 (sel->n << PLL_BASE_DIVN_SHIFT);
456 BUG_ON(c->p > 2); 524 BUG_ON(sel->p < 1 || sel->p > 2);
457 if (c->p == 2) 525 if (c->flags & PLLU) {
458 val |= 1 << PLL_BASE_DIVP_SHIFT; 526 if (sel->p == 1)
527 val |= PLLU_BASE_POST_DIV;
528 } else {
529 if (sel->p == 2)
530 val |= 1 << PLL_BASE_DIVP_SHIFT;
531 }
459 clk_writel(val, c->reg + PLL_BASE); 532 clk_writel(val, c->reg + PLL_BASE);
460 533
461 if (c->flags & PLL_HAS_CPCON) { 534 if (c->flags & PLL_HAS_CPCON) {
462 val = c->cpcon << PLL_MISC_CPCON_SHIFT; 535 val = clk_readl(c->reg + PLL_MISC(c));
463 val |= PLL_MISC_LOCK_ENABLE; 536 val &= ~PLL_MISC_CPCON_MASK;
537 val |= sel->cpcon << PLL_MISC_CPCON_SHIFT;
464 clk_writel(val, c->reg + PLL_MISC(c)); 538 clk_writel(val, c->reg + PLL_MISC(c));
465 } 539 }
466 540
467 if (c->state == ON) 541 if (c->state == ON)
468 tegra2_pll_clk_enable(c); 542 tegra2_pll_clk_enable(c);
469 543
470 c->rate = rate;
471 return 0; 544 return 0;
472 } 545 }
473 } 546 }
@@ -479,7 +552,46 @@ static struct clk_ops tegra_pll_ops = {
479 .enable = tegra2_pll_clk_enable, 552 .enable = tegra2_pll_clk_enable,
480 .disable = tegra2_pll_clk_disable, 553 .disable = tegra2_pll_clk_disable,
481 .set_rate = tegra2_pll_clk_set_rate, 554 .set_rate = tegra2_pll_clk_set_rate,
482 .recalculate_rate = tegra2_pll_clk_recalculate_rate, 555};
556
557static void tegra2_pllx_clk_init(struct clk *c)
558{
559 tegra2_pll_clk_init(c);
560
561 if (tegra_sku_id() == 7)
562 c->max_rate = 750000000;
563}
564
565static struct clk_ops tegra_pllx_ops = {
566 .init = tegra2_pllx_clk_init,
567 .enable = tegra2_pll_clk_enable,
568 .disable = tegra2_pll_clk_disable,
569 .set_rate = tegra2_pll_clk_set_rate,
570};
571
572static int tegra2_plle_clk_enable(struct clk *c)
573{
574 u32 val;
575
576 pr_debug("%s on clock %s\n", __func__, c->name);
577
578 mdelay(1);
579
580 val = clk_readl(c->reg + PLL_BASE);
581 if (!(val & PLLE_MISC_READY))
582 return -EBUSY;
583
584 val = clk_readl(c->reg + PLL_BASE);
585 val |= PLL_BASE_ENABLE | PLL_BASE_BYPASS;
586 clk_writel(val, c->reg + PLL_BASE);
587
588 return 0;
589}
590
591static struct clk_ops tegra_plle_ops = {
592 .init = tegra2_pll_clk_init,
593 .enable = tegra2_plle_clk_enable,
594 .set_rate = tegra2_pll_clk_set_rate,
483}; 595};
484 596
485/* Clock divider ops */ 597/* Clock divider ops */
@@ -503,8 +615,6 @@ static void tegra2_pll_div_clk_init(struct clk *c)
503 c->div = 1; 615 c->div = 1;
504 c->mul = 1; 616 c->mul = 1;
505 } 617 }
506
507 tegra2_clk_recalculate_rate(c);
508} 618}
509 619
510static int tegra2_pll_div_clk_enable(struct clk *c) 620static int tegra2_pll_div_clk_enable(struct clk *c)
@@ -565,7 +675,7 @@ static int tegra2_pll_div_clk_set_rate(struct clk *c, unsigned long rate)
565 int divider_u71; 675 int divider_u71;
566 pr_debug("%s: %s %lu\n", __func__, c->name, rate); 676 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
567 if (c->flags & DIV_U71) { 677 if (c->flags & DIV_U71) {
568 divider_u71 = clk_div71_get_divider(c->parent, rate); 678 divider_u71 = clk_div71_get_divider(c->parent->rate, rate);
569 if (divider_u71 >= 0) { 679 if (divider_u71 >= 0) {
570 val = clk_readl(c->reg); 680 val = clk_readl(c->reg);
571 new_val = val >> c->reg_shift; 681 new_val = val >> c->reg_shift;
@@ -580,25 +690,37 @@ static int tegra2_pll_div_clk_set_rate(struct clk *c, unsigned long rate)
580 clk_writel(val, c->reg); 690 clk_writel(val, c->reg);
581 c->div = divider_u71 + 2; 691 c->div = divider_u71 + 2;
582 c->mul = 2; 692 c->mul = 2;
583 tegra2_clk_recalculate_rate(c);
584 return 0; 693 return 0;
585 } 694 }
586 } else if (c->flags & DIV_2) { 695 } else if (c->flags & DIV_2) {
587 if (c->parent->rate == rate * 2) { 696 if (c->parent->rate == rate * 2)
588 c->rate = rate;
589 return 0; 697 return 0;
590 }
591 } 698 }
592 return -EINVAL; 699 return -EINVAL;
593} 700}
594 701
702static long tegra2_pll_div_clk_round_rate(struct clk *c, unsigned long rate)
703{
704 int divider;
705 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
706
707 if (c->flags & DIV_U71) {
708 divider = clk_div71_get_divider(c->parent->rate, rate);
709 if (divider < 0)
710 return divider;
711 return c->parent->rate * 2 / (divider + 2);
712 } else if (c->flags & DIV_2) {
713 return c->parent->rate / 2;
714 }
715 return -EINVAL;
716}
595 717
596static struct clk_ops tegra_pll_div_ops = { 718static struct clk_ops tegra_pll_div_ops = {
597 .init = tegra2_pll_div_clk_init, 719 .init = tegra2_pll_div_clk_init,
598 .enable = tegra2_pll_div_clk_enable, 720 .enable = tegra2_pll_div_clk_enable,
599 .disable = tegra2_pll_div_clk_disable, 721 .disable = tegra2_pll_div_clk_disable,
600 .set_rate = tegra2_pll_div_clk_set_rate, 722 .set_rate = tegra2_pll_div_clk_set_rate,
601 .recalculate_rate = tegra2_clk_recalculate_rate, 723 .round_rate = tegra2_pll_div_clk_round_rate,
602}; 724};
603 725
604/* Periph clk ops */ 726/* Periph clk ops */
@@ -621,9 +743,13 @@ static void tegra2_periph_clk_init(struct clk *c)
621 } 743 }
622 744
623 if (c->flags & DIV_U71) { 745 if (c->flags & DIV_U71) {
624 u32 divu71 = val & PERIPH_CLK_SOURCE_DIV_MASK; 746 u32 divu71 = val & PERIPH_CLK_SOURCE_DIVU71_MASK;
625 c->div = divu71 + 2; 747 c->div = divu71 + 2;
626 c->mul = 2; 748 c->mul = 2;
749 } else if (c->flags & DIV_U16) {
750 u32 divu16 = val & PERIPH_CLK_SOURCE_DIVU16_MASK;
751 c->div = divu16 + 1;
752 c->mul = 1;
627 } else { 753 } else {
628 c->div = 1; 754 c->div = 1;
629 c->mul = 1; 755 c->mul = 1;
@@ -637,7 +763,6 @@ static void tegra2_periph_clk_init(struct clk *c)
637 if (clk_readl(RST_DEVICES + PERIPH_CLK_TO_ENB_REG(c)) & 763 if (clk_readl(RST_DEVICES + PERIPH_CLK_TO_ENB_REG(c)) &
638 PERIPH_CLK_TO_ENB_BIT(c)) 764 PERIPH_CLK_TO_ENB_BIT(c))
639 c->state = OFF; 765 c->state = OFF;
640 tegra2_clk_recalculate_rate(c);
641} 766}
642 767
643static int tegra2_periph_clk_enable(struct clk *c) 768static int tegra2_periph_clk_enable(struct clk *c)
@@ -692,12 +817,19 @@ static int tegra2_periph_clk_set_parent(struct clk *c, struct clk *p)
692 pr_debug("%s: %s %s\n", __func__, c->name, p->name); 817 pr_debug("%s: %s %s\n", __func__, c->name, p->name);
693 for (sel = c->inputs; sel->input != NULL; sel++) { 818 for (sel = c->inputs; sel->input != NULL; sel++) {
694 if (sel->input == p) { 819 if (sel->input == p) {
695 clk_reparent(c, p);
696 val = clk_readl(c->reg); 820 val = clk_readl(c->reg);
697 val &= ~PERIPH_CLK_SOURCE_MASK; 821 val &= ~PERIPH_CLK_SOURCE_MASK;
698 val |= (sel->value) << PERIPH_CLK_SOURCE_SHIFT; 822 val |= (sel->value) << PERIPH_CLK_SOURCE_SHIFT;
823
824 if (c->refcnt)
825 clk_enable_locked(p);
826
699 clk_writel(val, c->reg); 827 clk_writel(val, c->reg);
700 c->rate = c->parent->rate; 828
829 if (c->refcnt && c->parent)
830 clk_disable_locked(c->parent);
831
832 clk_reparent(c, p);
701 return 0; 833 return 0;
702 } 834 }
703 } 835 }
@@ -708,20 +840,55 @@ static int tegra2_periph_clk_set_parent(struct clk *c, struct clk *p)
708static int tegra2_periph_clk_set_rate(struct clk *c, unsigned long rate) 840static int tegra2_periph_clk_set_rate(struct clk *c, unsigned long rate)
709{ 841{
710 u32 val; 842 u32 val;
711 int divider_u71; 843 int divider;
712 pr_debug("%s: %lu\n", __func__, rate); 844 pr_debug("%s: %lu\n", __func__, rate);
713 if (c->flags & DIV_U71) { 845 if (c->flags & DIV_U71) {
714 divider_u71 = clk_div71_get_divider(c->parent, rate); 846 divider = clk_div71_get_divider(c->parent->rate, rate);
715 if (divider_u71 >= 0) { 847 if (divider >= 0) {
716 val = clk_readl(c->reg); 848 val = clk_readl(c->reg);
717 val &= ~PERIPH_CLK_SOURCE_DIV_MASK; 849 val &= ~PERIPH_CLK_SOURCE_DIVU71_MASK;
718 val |= divider_u71; 850 val |= divider;
719 clk_writel(val, c->reg); 851 clk_writel(val, c->reg);
720 c->div = divider_u71 + 2; 852 c->div = divider + 2;
721 c->mul = 2; 853 c->mul = 2;
722 tegra2_clk_recalculate_rate(c);
723 return 0; 854 return 0;
724 } 855 }
856 } else if (c->flags & DIV_U16) {
857 divider = clk_div16_get_divider(c->parent->rate, rate);
858 if (divider >= 0) {
859 val = clk_readl(c->reg);
860 val &= ~PERIPH_CLK_SOURCE_DIVU16_MASK;
861 val |= divider;
862 clk_writel(val, c->reg);
863 c->div = divider + 1;
864 c->mul = 1;
865 return 0;
866 }
867 } else if (c->parent->rate <= rate) {
868 c->div = 1;
869 c->mul = 1;
870 return 0;
871 }
872 return -EINVAL;
873}
874
875static long tegra2_periph_clk_round_rate(struct clk *c,
876 unsigned long rate)
877{
878 int divider;
879 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
880
881 if (c->flags & DIV_U71) {
882 divider = clk_div71_get_divider(c->parent->rate, rate);
883 if (divider < 0)
884 return divider;
885
886 return c->parent->rate * 2 / (divider + 2);
887 } else if (c->flags & DIV_U16) {
888 divider = clk_div16_get_divider(c->parent->rate, rate);
889 if (divider < 0)
890 return divider;
891 return c->parent->rate / (divider + 1);
725 } 892 }
726 return -EINVAL; 893 return -EINVAL;
727} 894}
@@ -732,7 +899,7 @@ static struct clk_ops tegra_periph_clk_ops = {
732 .disable = &tegra2_periph_clk_disable, 899 .disable = &tegra2_periph_clk_disable,
733 .set_parent = &tegra2_periph_clk_set_parent, 900 .set_parent = &tegra2_periph_clk_set_parent,
734 .set_rate = &tegra2_periph_clk_set_rate, 901 .set_rate = &tegra2_periph_clk_set_rate,
735 .recalculate_rate = &tegra2_clk_recalculate_rate, 902 .round_rate = &tegra2_periph_clk_round_rate,
736}; 903};
737 904
738/* Clock doubler ops */ 905/* Clock doubler ops */
@@ -744,21 +911,108 @@ static void tegra2_clk_double_init(struct clk *c)
744 if (!(clk_readl(CLK_OUT_ENB + PERIPH_CLK_TO_ENB_REG(c)) & 911 if (!(clk_readl(CLK_OUT_ENB + PERIPH_CLK_TO_ENB_REG(c)) &
745 PERIPH_CLK_TO_ENB_BIT(c))) 912 PERIPH_CLK_TO_ENB_BIT(c)))
746 c->state = OFF; 913 c->state = OFF;
747 tegra2_clk_recalculate_rate(c);
748}; 914};
749 915
916static int tegra2_clk_double_set_rate(struct clk *c, unsigned long rate)
917{
918 if (rate != 2 * c->parent->rate)
919 return -EINVAL;
920 c->mul = 2;
921 c->div = 1;
922 return 0;
923}
924
750static struct clk_ops tegra_clk_double_ops = { 925static struct clk_ops tegra_clk_double_ops = {
751 .init = &tegra2_clk_double_init, 926 .init = &tegra2_clk_double_init,
752 .enable = &tegra2_periph_clk_enable, 927 .enable = &tegra2_periph_clk_enable,
753 .disable = &tegra2_periph_clk_disable, 928 .disable = &tegra2_periph_clk_disable,
754 .recalculate_rate = &tegra2_clk_recalculate_rate, 929 .set_rate = &tegra2_clk_double_set_rate,
930};
931
932static void tegra2_audio_sync_clk_init(struct clk *c)
933{
934 int source;
935 const struct clk_mux_sel *sel;
936 u32 val = clk_readl(c->reg);
937 c->state = (val & (1<<4)) ? OFF : ON;
938 source = val & 0xf;
939 for (sel = c->inputs; sel->input != NULL; sel++)
940 if (sel->value == source)
941 break;
942 BUG_ON(sel->input == NULL);
943 c->parent = sel->input;
944}
945
946static int tegra2_audio_sync_clk_enable(struct clk *c)
947{
948 clk_writel(0, c->reg);
949 return 0;
950}
951
952static void tegra2_audio_sync_clk_disable(struct clk *c)
953{
954 clk_writel(1, c->reg);
955}
956
957static int tegra2_audio_sync_clk_set_parent(struct clk *c, struct clk *p)
958{
959 u32 val;
960 const struct clk_mux_sel *sel;
961 for (sel = c->inputs; sel->input != NULL; sel++) {
962 if (sel->input == p) {
963 val = clk_readl(c->reg);
964 val &= ~0xf;
965 val |= sel->value;
966
967 if (c->refcnt)
968 clk_enable_locked(p);
969
970 clk_writel(val, c->reg);
971
972 if (c->refcnt && c->parent)
973 clk_disable_locked(c->parent);
974
975 clk_reparent(c, p);
976 return 0;
977 }
978 }
979
980 return -EINVAL;
981}
982
983static int tegra2_audio_sync_clk_set_rate(struct clk *c, unsigned long rate)
984{
985 unsigned long parent_rate;
986 if (!c->parent) {
987 pr_err("%s: clock has no parent\n", __func__);
988 return -EINVAL;
989 }
990 parent_rate = c->parent->rate;
991 if (rate != parent_rate) {
992 pr_err("%s: %s/%ld differs from parent %s/%ld\n",
993 __func__,
994 c->name, rate,
995 c->parent->name, parent_rate);
996 return -EINVAL;
997 }
998 c->rate = parent_rate;
999 return 0;
1000}
1001
1002static struct clk_ops tegra_audio_sync_clk_ops = {
1003 .init = tegra2_audio_sync_clk_init,
1004 .enable = tegra2_audio_sync_clk_enable,
1005 .disable = tegra2_audio_sync_clk_disable,
1006 .set_rate = tegra2_audio_sync_clk_set_rate,
1007 .set_parent = tegra2_audio_sync_clk_set_parent,
755}; 1008};
756 1009
757/* Clock definitions */ 1010/* Clock definitions */
758static struct clk tegra_clk_32k = { 1011static struct clk tegra_clk_32k = {
759 .name = "clk_32k", 1012 .name = "clk_32k",
760 .rate = 32678, 1013 .rate = 32768,
761 .ops = NULL, 1014 .ops = NULL,
1015 .max_rate = 32768,
762}; 1016};
763 1017
764static struct clk_pll_table tegra_pll_s_table[] = { 1018static struct clk_pll_table tegra_pll_s_table[] = {
@@ -782,6 +1036,7 @@ static struct clk tegra_pll_s = {
782 .vco_min = 12000000, 1036 .vco_min = 12000000,
783 .vco_max = 26000000, 1037 .vco_max = 26000000,
784 .pll_table = tegra_pll_s_table, 1038 .pll_table = tegra_pll_s_table,
1039 .max_rate = 26000000,
785}; 1040};
786 1041
787static struct clk_mux_sel tegra_clk_m_sel[] = { 1042static struct clk_mux_sel tegra_clk_m_sel[] = {
@@ -797,6 +1052,7 @@ static struct clk tegra_clk_m = {
797 .reg = 0x1fc, 1052 .reg = 0x1fc,
798 .reg_mask = (1<<28), 1053 .reg_mask = (1<<28),
799 .reg_shift = 28, 1054 .reg_shift = 28,
1055 .max_rate = 26000000,
800}; 1056};
801 1057
802static struct clk_pll_table tegra_pll_c_table[] = { 1058static struct clk_pll_table tegra_pll_c_table[] = {
@@ -816,6 +1072,7 @@ static struct clk tegra_pll_c = {
816 .vco_min = 20000000, 1072 .vco_min = 20000000,
817 .vco_max = 1400000000, 1073 .vco_max = 1400000000,
818 .pll_table = tegra_pll_c_table, 1074 .pll_table = tegra_pll_c_table,
1075 .max_rate = 600000000,
819}; 1076};
820 1077
821static struct clk tegra_pll_c_out1 = { 1078static struct clk tegra_pll_c_out1 = {
@@ -825,9 +1082,18 @@ static struct clk tegra_pll_c_out1 = {
825 .parent = &tegra_pll_c, 1082 .parent = &tegra_pll_c,
826 .reg = 0x84, 1083 .reg = 0x84,
827 .reg_shift = 0, 1084 .reg_shift = 0,
1085 .max_rate = 600000000,
828}; 1086};
829 1087
830static struct clk_pll_table tegra_pll_m_table[] = { 1088static struct clk_pll_table tegra_pll_m_table[] = {
1089 { 12000000, 666000000, 666, 12, 1, 8},
1090 { 13000000, 666000000, 666, 13, 1, 8},
1091 { 19200000, 666000000, 555, 16, 1, 8},
1092 { 26000000, 666000000, 666, 26, 1, 8},
1093 { 12000000, 600000000, 600, 12, 1, 8},
1094 { 13000000, 600000000, 600, 13, 1, 8},
1095 { 19200000, 600000000, 375, 12, 1, 6},
1096 { 26000000, 600000000, 600, 26, 1, 8},
831 { 0, 0, 0, 0, 0, 0 }, 1097 { 0, 0, 0, 0, 0, 0 },
832}; 1098};
833 1099
@@ -844,6 +1110,7 @@ static struct clk tegra_pll_m = {
844 .vco_min = 20000000, 1110 .vco_min = 20000000,
845 .vco_max = 1200000000, 1111 .vco_max = 1200000000,
846 .pll_table = tegra_pll_m_table, 1112 .pll_table = tegra_pll_m_table,
1113 .max_rate = 800000000,
847}; 1114};
848 1115
849static struct clk tegra_pll_m_out1 = { 1116static struct clk tegra_pll_m_out1 = {
@@ -853,6 +1120,7 @@ static struct clk tegra_pll_m_out1 = {
853 .parent = &tegra_pll_m, 1120 .parent = &tegra_pll_m,
854 .reg = 0x94, 1121 .reg = 0x94,
855 .reg_shift = 0, 1122 .reg_shift = 0,
1123 .max_rate = 600000000,
856}; 1124};
857 1125
858static struct clk_pll_table tegra_pll_p_table[] = { 1126static struct clk_pll_table tegra_pll_p_table[] = {
@@ -880,6 +1148,7 @@ static struct clk tegra_pll_p = {
880 .vco_min = 20000000, 1148 .vco_min = 20000000,
881 .vco_max = 1400000000, 1149 .vco_max = 1400000000,
882 .pll_table = tegra_pll_p_table, 1150 .pll_table = tegra_pll_p_table,
1151 .max_rate = 432000000,
883}; 1152};
884 1153
885static struct clk tegra_pll_p_out1 = { 1154static struct clk tegra_pll_p_out1 = {
@@ -889,6 +1158,7 @@ static struct clk tegra_pll_p_out1 = {
889 .parent = &tegra_pll_p, 1158 .parent = &tegra_pll_p,
890 .reg = 0xa4, 1159 .reg = 0xa4,
891 .reg_shift = 0, 1160 .reg_shift = 0,
1161 .max_rate = 432000000,
892}; 1162};
893 1163
894static struct clk tegra_pll_p_out2 = { 1164static struct clk tegra_pll_p_out2 = {
@@ -898,6 +1168,7 @@ static struct clk tegra_pll_p_out2 = {
898 .parent = &tegra_pll_p, 1168 .parent = &tegra_pll_p,
899 .reg = 0xa4, 1169 .reg = 0xa4,
900 .reg_shift = 16, 1170 .reg_shift = 16,
1171 .max_rate = 432000000,
901}; 1172};
902 1173
903static struct clk tegra_pll_p_out3 = { 1174static struct clk tegra_pll_p_out3 = {
@@ -907,6 +1178,7 @@ static struct clk tegra_pll_p_out3 = {
907 .parent = &tegra_pll_p, 1178 .parent = &tegra_pll_p,
908 .reg = 0xa8, 1179 .reg = 0xa8,
909 .reg_shift = 0, 1180 .reg_shift = 0,
1181 .max_rate = 432000000,
910}; 1182};
911 1183
912static struct clk tegra_pll_p_out4 = { 1184static struct clk tegra_pll_p_out4 = {
@@ -916,6 +1188,7 @@ static struct clk tegra_pll_p_out4 = {
916 .parent = &tegra_pll_p, 1188 .parent = &tegra_pll_p,
917 .reg = 0xa8, 1189 .reg = 0xa8,
918 .reg_shift = 16, 1190 .reg_shift = 16,
1191 .max_rate = 432000000,
919}; 1192};
920 1193
921static struct clk_pll_table tegra_pll_a_table[] = { 1194static struct clk_pll_table tegra_pll_a_table[] = {
@@ -923,6 +1196,7 @@ static struct clk_pll_table tegra_pll_a_table[] = {
923 { 28800000, 73728000, 64, 25, 1, 1}, 1196 { 28800000, 73728000, 64, 25, 1, 1},
924 { 28800000, 11289600, 49, 25, 1, 1}, 1197 { 28800000, 11289600, 49, 25, 1, 1},
925 { 28800000, 12288000, 64, 25, 1, 1}, 1198 { 28800000, 12288000, 64, 25, 1, 1},
1199 { 28800000, 24000000, 5, 6, 1, 1},
926 { 0, 0, 0, 0, 0, 0 }, 1200 { 0, 0, 0, 0, 0, 0 },
927}; 1201};
928 1202
@@ -939,6 +1213,7 @@ static struct clk tegra_pll_a = {
939 .vco_min = 20000000, 1213 .vco_min = 20000000,
940 .vco_max = 1400000000, 1214 .vco_max = 1400000000,
941 .pll_table = tegra_pll_a_table, 1215 .pll_table = tegra_pll_a_table,
1216 .max_rate = 56448000,
942}; 1217};
943 1218
944static struct clk tegra_pll_a_out0 = { 1219static struct clk tegra_pll_a_out0 = {
@@ -948,6 +1223,7 @@ static struct clk tegra_pll_a_out0 = {
948 .parent = &tegra_pll_a, 1223 .parent = &tegra_pll_a,
949 .reg = 0xb4, 1224 .reg = 0xb4,
950 .reg_shift = 0, 1225 .reg_shift = 0,
1226 .max_rate = 56448000,
951}; 1227};
952 1228
953static struct clk_pll_table tegra_pll_d_table[] = { 1229static struct clk_pll_table tegra_pll_d_table[] = {
@@ -971,6 +1247,7 @@ static struct clk tegra_pll_d = {
971 .vco_min = 40000000, 1247 .vco_min = 40000000,
972 .vco_max = 1000000000, 1248 .vco_max = 1000000000,
973 .pll_table = tegra_pll_d_table, 1249 .pll_table = tegra_pll_d_table,
1250 .max_rate = 1000000000,
974}; 1251};
975 1252
976static struct clk tegra_pll_d_out0 = { 1253static struct clk tegra_pll_d_out0 = {
@@ -978,19 +1255,20 @@ static struct clk tegra_pll_d_out0 = {
978 .ops = &tegra_pll_div_ops, 1255 .ops = &tegra_pll_div_ops,
979 .flags = DIV_2 | PLLD, 1256 .flags = DIV_2 | PLLD,
980 .parent = &tegra_pll_d, 1257 .parent = &tegra_pll_d,
1258 .max_rate = 500000000,
981}; 1259};
982 1260
983static struct clk_pll_table tegra_pll_u_table[] = { 1261static struct clk_pll_table tegra_pll_u_table[] = {
984 { 12000000, 480000000, 960, 12, 1, 0}, 1262 { 12000000, 480000000, 960, 12, 2, 0},
985 { 13000000, 480000000, 960, 13, 1, 0}, 1263 { 13000000, 480000000, 960, 13, 2, 0},
986 { 19200000, 480000000, 200, 4, 1, 0}, 1264 { 19200000, 480000000, 200, 4, 2, 0},
987 { 26000000, 480000000, 960, 26, 1, 0}, 1265 { 26000000, 480000000, 960, 26, 2, 0},
988 { 0, 0, 0, 0, 0, 0 }, 1266 { 0, 0, 0, 0, 0, 0 },
989}; 1267};
990 1268
991static struct clk tegra_pll_u = { 1269static struct clk tegra_pll_u = {
992 .name = "pll_u", 1270 .name = "pll_u",
993 .flags = 0, 1271 .flags = PLLU,
994 .ops = &tegra_pll_ops, 1272 .ops = &tegra_pll_ops,
995 .reg = 0xc0, 1273 .reg = 0xc0,
996 .input_min = 2000000, 1274 .input_min = 2000000,
@@ -1001,24 +1279,59 @@ static struct clk tegra_pll_u = {
1001 .vco_min = 480000000, 1279 .vco_min = 480000000,
1002 .vco_max = 960000000, 1280 .vco_max = 960000000,
1003 .pll_table = tegra_pll_u_table, 1281 .pll_table = tegra_pll_u_table,
1282 .max_rate = 480000000,
1004}; 1283};
1005 1284
1006static struct clk_pll_table tegra_pll_x_table[] = { 1285static struct clk_pll_table tegra_pll_x_table[] = {
1286 /* 1 GHz */
1007 { 12000000, 1000000000, 1000, 12, 1, 12}, 1287 { 12000000, 1000000000, 1000, 12, 1, 12},
1008 { 13000000, 1000000000, 1000, 13, 1, 12}, 1288 { 13000000, 1000000000, 1000, 13, 1, 12},
1009 { 19200000, 1000000000, 625, 12, 1, 8}, 1289 { 19200000, 1000000000, 625, 12, 1, 8},
1010 { 26000000, 1000000000, 1000, 26, 1, 12}, 1290 { 26000000, 1000000000, 1000, 26, 1, 12},
1011 { 12000000, 750000000, 750, 12, 1, 12}, 1291
1012 { 13000000, 750000000, 750, 13, 1, 12}, 1292 /* 912 MHz */
1013 { 19200000, 750000000, 625, 16, 1, 8}, 1293 { 12000000, 912000000, 912, 12, 1, 12},
1014 { 26000000, 750000000, 750, 26, 1, 12}, 1294 { 13000000, 912000000, 912, 13, 1, 12},
1295 { 19200000, 912000000, 760, 16, 1, 8},
1296 { 26000000, 912000000, 912, 26, 1, 12},
1297
1298 /* 816 MHz */
1299 { 12000000, 816000000, 816, 12, 1, 12},
1300 { 13000000, 816000000, 816, 13, 1, 12},
1301 { 19200000, 816000000, 680, 16, 1, 8},
1302 { 26000000, 816000000, 816, 26, 1, 12},
1303
1304 /* 760 MHz */
1305 { 12000000, 760000000, 760, 12, 1, 12},
1306 { 13000000, 760000000, 760, 13, 1, 12},
1307 { 19200000, 760000000, 950, 24, 1, 8},
1308 { 26000000, 760000000, 760, 26, 1, 12},
1309
1310 /* 608 MHz */
1311 { 12000000, 608000000, 760, 12, 1, 12},
1312 { 13000000, 608000000, 760, 13, 1, 12},
1313 { 19200000, 608000000, 380, 12, 1, 8},
1314 { 26000000, 608000000, 760, 26, 1, 12},
1315
1316 /* 456 MHz */
1317 { 12000000, 456000000, 456, 12, 1, 12},
1318 { 13000000, 456000000, 456, 13, 1, 12},
1319 { 19200000, 456000000, 380, 16, 1, 8},
1320 { 26000000, 456000000, 456, 26, 1, 12},
1321
1322 /* 312 MHz */
1323 { 12000000, 312000000, 312, 12, 1, 12},
1324 { 13000000, 312000000, 312, 13, 1, 12},
1325 { 19200000, 312000000, 260, 16, 1, 8},
1326 { 26000000, 312000000, 312, 26, 1, 12},
1327
1015 { 0, 0, 0, 0, 0, 0 }, 1328 { 0, 0, 0, 0, 0, 0 },
1016}; 1329};
1017 1330
1018static struct clk tegra_pll_x = { 1331static struct clk tegra_pll_x = {
1019 .name = "pll_x", 1332 .name = "pll_x",
1020 .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG, 1333 .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG,
1021 .ops = &tegra_pll_ops, 1334 .ops = &tegra_pllx_ops,
1022 .reg = 0xe0, 1335 .reg = 0xe0,
1023 .input_min = 2000000, 1336 .input_min = 2000000,
1024 .input_max = 31000000, 1337 .input_max = 31000000,
@@ -1028,6 +1341,24 @@ static struct clk tegra_pll_x = {
1028 .vco_min = 20000000, 1341 .vco_min = 20000000,
1029 .vco_max = 1200000000, 1342 .vco_max = 1200000000,
1030 .pll_table = tegra_pll_x_table, 1343 .pll_table = tegra_pll_x_table,
1344 .max_rate = 1000000000,
1345};
1346
1347static struct clk_pll_table tegra_pll_e_table[] = {
1348 { 12000000, 100000000, 200, 24, 1, 0 },
1349 { 0, 0, 0, 0, 0, 0 },
1350};
1351
1352static struct clk tegra_pll_e = {
1353 .name = "pll_e",
1354 .flags = PLL_ALT_MISC_REG,
1355 .ops = &tegra_plle_ops,
1356 .input_min = 12000000,
1357 .input_max = 12000000,
1358 .max_rate = 100000000,
1359 .parent = &tegra_clk_m,
1360 .reg = 0xe8,
1361 .pll_table = tegra_pll_e_table,
1031}; 1362};
1032 1363
1033static struct clk tegra_clk_d = { 1364static struct clk tegra_clk_d = {
@@ -1038,19 +1369,77 @@ static struct clk tegra_clk_d = {
1038 .reg = 0x34, 1369 .reg = 0x34,
1039 .reg_shift = 12, 1370 .reg_shift = 12,
1040 .parent = &tegra_clk_m, 1371 .parent = &tegra_clk_m,
1372 .max_rate = 52000000,
1373};
1374
1375/* initialized before peripheral clocks */
1376static struct clk_mux_sel mux_audio_sync_clk[8+1];
1377static const struct audio_sources {
1378 const char *name;
1379 int value;
1380} mux_audio_sync_clk_sources[] = {
1381 { .name = "spdif_in", .value = 0 },
1382 { .name = "i2s1", .value = 1 },
1383 { .name = "i2s2", .value = 2 },
1384 { .name = "pll_a_out0", .value = 4 },
1385#if 0 /* FIXME: not implemented */
1386 { .name = "ac97", .value = 3 },
1387 { .name = "ext_audio_clk2", .value = 5 },
1388 { .name = "ext_audio_clk1", .value = 6 },
1389 { .name = "ext_vimclk", .value = 7 },
1390#endif
1391 { 0, 0 }
1392};
1393
1394static struct clk tegra_clk_audio = {
1395 .name = "audio",
1396 .inputs = mux_audio_sync_clk,
1397 .reg = 0x38,
1398 .max_rate = 24000000,
1399 .ops = &tegra_audio_sync_clk_ops
1041}; 1400};
1042 1401
1043/* FIXME: need tegra_audio
1044static struct clk tegra_clk_audio_2x = { 1402static struct clk tegra_clk_audio_2x = {
1045 .name = "clk_d", 1403 .name = "audio_2x",
1046 .flags = PERIPH_NO_RESET, 1404 .flags = PERIPH_NO_RESET,
1405 .max_rate = 48000000,
1047 .ops = &tegra_clk_double_ops, 1406 .ops = &tegra_clk_double_ops,
1048 .clk_num = 89, 1407 .clk_num = 89,
1049 .reg = 0x34, 1408 .reg = 0x34,
1050 .reg_shift = 8, 1409 .reg_shift = 8,
1051 .parent = &tegra_audio, 1410 .parent = &tegra_clk_audio,
1411};
1412
1413struct clk_lookup tegra_audio_clk_lookups[] = {
1414 { .con_id = "audio", .clk = &tegra_clk_audio },
1415 { .con_id = "audio_2x", .clk = &tegra_clk_audio_2x }
1416};
1417
1418/* This is called after peripheral clocks are initialized, as the
1419 * audio_sync clock depends on some of the peripheral clocks.
1420 */
1421
1422static void init_audio_sync_clock_mux(void)
1423{
1424 int i;
1425 struct clk_mux_sel *sel = mux_audio_sync_clk;
1426 const struct audio_sources *src = mux_audio_sync_clk_sources;
1427 struct clk_lookup *lookup;
1428
1429 for (i = 0; src->name; i++, sel++, src++) {
1430 sel->input = tegra_get_clock_by_name(src->name);
1431 if (!sel->input)
1432 pr_err("%s: could not find clk %s\n", __func__,
1433 src->name);
1434 sel->value = src->value;
1435 }
1436
1437 lookup = tegra_audio_clk_lookups;
1438 for (i = 0; i < ARRAY_SIZE(tegra_audio_clk_lookups); i++, lookup++) {
1439 clk_init(lookup->clk);
1440 clkdev_add(lookup);
1441 }
1052} 1442}
1053*/
1054 1443
1055static struct clk_mux_sel mux_cclk[] = { 1444static struct clk_mux_sel mux_cclk[] = {
1056 { .input = &tegra_clk_m, .value = 0}, 1445 { .input = &tegra_clk_m, .value = 0},
@@ -1077,27 +1466,40 @@ static struct clk_mux_sel mux_sclk[] = {
1077 { 0, 0}, 1466 { 0, 0},
1078}; 1467};
1079 1468
1080static struct clk tegra_clk_cpu = { 1469static struct clk tegra_clk_cclk = {
1081 .name = "cpu", 1470 .name = "cclk",
1082 .inputs = mux_cclk, 1471 .inputs = mux_cclk,
1083 .reg = 0x20, 1472 .reg = 0x20,
1084 .ops = &tegra_super_ops, 1473 .ops = &tegra_super_ops,
1474 .max_rate = 1000000000,
1085}; 1475};
1086 1476
1087static struct clk tegra_clk_sys = { 1477static struct clk tegra_clk_sclk = {
1088 .name = "sys", 1478 .name = "sclk",
1089 .inputs = mux_sclk, 1479 .inputs = mux_sclk,
1090 .reg = 0x28, 1480 .reg = 0x28,
1091 .ops = &tegra_super_ops, 1481 .ops = &tegra_super_ops,
1482 .max_rate = 600000000,
1483};
1484
1485static struct clk tegra_clk_virtual_cpu = {
1486 .name = "cpu",
1487 .parent = &tegra_clk_cclk,
1488 .main = &tegra_pll_x,
1489 .backup = &tegra_clk_m,
1490 .ops = &tegra_cpu_ops,
1491 .max_rate = 1000000000,
1492 .dvfs = &tegra_dvfs_virtual_cpu_dvfs,
1092}; 1493};
1093 1494
1094static struct clk tegra_clk_hclk = { 1495static struct clk tegra_clk_hclk = {
1095 .name = "hclk", 1496 .name = "hclk",
1096 .flags = DIV_BUS, 1497 .flags = DIV_BUS,
1097 .parent = &tegra_clk_sys, 1498 .parent = &tegra_clk_sclk,
1098 .reg = 0x30, 1499 .reg = 0x30,
1099 .reg_shift = 4, 1500 .reg_shift = 4,
1100 .ops = &tegra_bus_ops, 1501 .ops = &tegra_bus_ops,
1502 .max_rate = 240000000,
1101}; 1503};
1102 1504
1103static struct clk tegra_clk_pclk = { 1505static struct clk tegra_clk_pclk = {
@@ -1107,6 +1509,7 @@ static struct clk tegra_clk_pclk = {
1107 .reg = 0x30, 1509 .reg = 0x30,
1108 .reg_shift = 0, 1510 .reg_shift = 0,
1109 .ops = &tegra_bus_ops, 1511 .ops = &tegra_bus_ops,
1512 .max_rate = 108000000,
1110}; 1513};
1111 1514
1112static struct clk_mux_sel mux_pllm_pllc_pllp_plla[] = { 1515static struct clk_mux_sel mux_pllm_pllc_pllp_plla[] = {
@@ -1133,10 +1536,9 @@ static struct clk_mux_sel mux_pllp_pllc_pllm_clkm[] = {
1133 { 0, 0}, 1536 { 0, 0},
1134}; 1537};
1135 1538
1136static struct clk_mux_sel mux_plla_audio_pllp_clkm[] = { 1539static struct clk_mux_sel mux_pllaout0_audio2x_pllp_clkm[] = {
1137 {.input = &tegra_pll_a, .value = 0}, 1540 {.input = &tegra_pll_a_out0, .value = 0},
1138 /* FIXME: no mux defined for tegra_audio 1541 {.input = &tegra_clk_audio_2x, .value = 1},
1139 {.input = &tegra_audio, .value = 1},*/
1140 {.input = &tegra_pll_p, .value = 2}, 1542 {.input = &tegra_pll_p, .value = 2},
1141 {.input = &tegra_clk_m, .value = 3}, 1543 {.input = &tegra_clk_m, .value = 3},
1142 { 0, 0}, 1544 { 0, 0},
@@ -1153,8 +1555,7 @@ static struct clk_mux_sel mux_pllp_plld_pllc_clkm[] = {
1153static struct clk_mux_sel mux_pllp_pllc_audio_clkm_clk32[] = { 1555static struct clk_mux_sel mux_pllp_pllc_audio_clkm_clk32[] = {
1154 {.input = &tegra_pll_p, .value = 0}, 1556 {.input = &tegra_pll_p, .value = 0},
1155 {.input = &tegra_pll_c, .value = 1}, 1557 {.input = &tegra_pll_c, .value = 1},
1156 /* FIXME: no mux defined for tegra_audio 1558 {.input = &tegra_clk_audio, .value = 2},
1157 {.input = &tegra_audio, .value = 2},*/
1158 {.input = &tegra_clk_m, .value = 3}, 1559 {.input = &tegra_clk_m, .value = 3},
1159 {.input = &tegra_clk_32k, .value = 4}, 1560 {.input = &tegra_clk_32k, .value = 4},
1160 { 0, 0}, 1561 { 0, 0},
@@ -1187,7 +1588,7 @@ static struct clk_mux_sel mux_clk_32k[] = {
1187 { 0, 0}, 1588 { 0, 0},
1188}; 1589};
1189 1590
1190#define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, _inputs, _flags) \ 1591#define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, _max, _inputs, _flags) \
1191 { \ 1592 { \
1192 .name = _name, \ 1593 .name = _name, \
1193 .lookup = { \ 1594 .lookup = { \
@@ -1199,72 +1600,79 @@ static struct clk_mux_sel mux_clk_32k[] = {
1199 .reg = _reg, \ 1600 .reg = _reg, \
1200 .inputs = _inputs, \ 1601 .inputs = _inputs, \
1201 .flags = _flags, \ 1602 .flags = _flags, \
1603 .max_rate = _max, \
1202 } 1604 }
1203 1605
1204struct clk tegra_periph_clks[] = { 1606struct clk tegra_periph_clks[] = {
1205 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, mux_clk_32k, PERIPH_NO_RESET), 1607 PERIPH_CLK("rtc", "rtc-tegra", NULL, 4, 0, 32768, mux_clk_32k, PERIPH_NO_RESET),
1206 PERIPH_CLK("timer", "timer", NULL, 5, 0, mux_clk_m, 0), 1608 PERIPH_CLK("timer", "timer", NULL, 5, 0, 26000000, mux_clk_m, 0),
1207 PERIPH_CLK("i2s1", "i2s.0", NULL, 11, 0x100, mux_plla_audio_pllp_clkm, MUX | DIV_U71), 1609 PERIPH_CLK("i2s1", "i2s.0", NULL, 11, 0x100, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
1208 PERIPH_CLK("i2s2", "i2s.1", NULL, 18, 0x104, mux_plla_audio_pllp_clkm, MUX | DIV_U71), 1610 PERIPH_CLK("i2s2", "i2s.1", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
1209 /* FIXME: spdif has 2 clocks but 1 enable */ 1611 /* FIXME: spdif has 2 clocks but 1 enable */
1210 PERIPH_CLK("spdif_out", "spdif_out", NULL, 10, 0x108, mux_plla_audio_pllp_clkm, MUX | DIV_U71), 1612 PERIPH_CLK("spdif_out", "spdif_out", NULL, 10, 0x108, 100000000, mux_pllaout0_audio2x_pllp_clkm, MUX | DIV_U71),
1211 PERIPH_CLK("spdif_in", "spdif_in", NULL, 10, 0x10c, mux_pllp_pllc_pllm, MUX | DIV_U71), 1613 PERIPH_CLK("spdif_in", "spdif_in", NULL, 10, 0x10c, 100000000, mux_pllp_pllc_pllm, MUX | DIV_U71),
1212 PERIPH_CLK("pwm", "pwm", NULL, 17, 0x110, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71), 1614 PERIPH_CLK("pwm", "pwm", NULL, 17, 0x110, 432000000, mux_pllp_pllc_audio_clkm_clk32, MUX | DIV_U71),
1213 PERIPH_CLK("spi", "spi", NULL, 43, 0x114, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1615 PERIPH_CLK("spi", "spi", NULL, 43, 0x114, 40000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1214 PERIPH_CLK("xio", "xio", NULL, 45, 0x120, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1616 PERIPH_CLK("xio", "xio", NULL, 45, 0x120, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1215 PERIPH_CLK("twc", "twc", NULL, 16, 0x12c, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1617 PERIPH_CLK("twc", "twc", NULL, 16, 0x12c, 150000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1216 PERIPH_CLK("sbc1", "spi_tegra.0", NULL, 41, 0x134, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1618 PERIPH_CLK("sbc1", "spi_tegra.0", NULL, 41, 0x134, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1217 PERIPH_CLK("sbc2", "spi_tegra.1", NULL, 44, 0x118, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1619 PERIPH_CLK("sbc2", "spi_tegra.1", NULL, 44, 0x118, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1218 PERIPH_CLK("sbc3", "spi_tegra.2", NULL, 46, 0x11c, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1620 PERIPH_CLK("sbc3", "spi_tegra.2", NULL, 46, 0x11c, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1219 PERIPH_CLK("sbc4", "spi_tegra.3", NULL, 68, 0x1b4, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1621 PERIPH_CLK("sbc4", "spi_tegra.3", NULL, 68, 0x1b4, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1220 PERIPH_CLK("ide", "ide", NULL, 25, 0x144, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1622 PERIPH_CLK("ide", "ide", NULL, 25, 0x144, 100000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* requires min voltage */
1221 PERIPH_CLK("ndflash", "tegra_nand", NULL, 13, 0x160, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1623 PERIPH_CLK("ndflash", "tegra_nand", NULL, 13, 0x160, 164000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1222 /* FIXME: vfir shares an enable with uartb */ 1624 /* FIXME: vfir shares an enable with uartb */
1223 PERIPH_CLK("vfir", "vfir", NULL, 7, 0x168, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1625 PERIPH_CLK("vfir", "vfir", NULL, 7, 0x168, 72000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1224 PERIPH_CLK("sdmmc1", "sdhci-tegra.0", NULL, 14, 0x150, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1626 PERIPH_CLK("sdmmc1", "sdhci-tegra.0", NULL, 14, 0x150, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1225 PERIPH_CLK("sdmmc2", "sdhci-tegra.1", NULL, 9, 0x154, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1627 PERIPH_CLK("sdmmc2", "sdhci-tegra.1", NULL, 9, 0x154, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1226 PERIPH_CLK("sdmmc3", "sdhci-tegra.2", NULL, 69, 0x1bc, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1628 PERIPH_CLK("sdmmc3", "sdhci-tegra.2", NULL, 69, 0x1bc, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1227 PERIPH_CLK("sdmmc4", "sdhci-tegra.3", NULL, 15, 0x160, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1629 PERIPH_CLK("sdmmc4", "sdhci-tegra.3", NULL, 15, 0x160, 52000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1228 PERIPH_CLK("vde", "vde", NULL, 61, 0x1c8, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1630 PERIPH_CLK("vde", "vde", NULL, 61, 0x1c8, 250000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage and process_id */
1229 PERIPH_CLK("csite", "csite", NULL, 73, 0x1d4, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1631 PERIPH_CLK("csite", "csite", NULL, 73, 0x1d4, 144000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* max rate ??? */
1230 /* FIXME: what is la? */ 1632 /* FIXME: what is la? */
1231 PERIPH_CLK("la", "la", NULL, 76, 0x1f8, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1633 PERIPH_CLK("la", "la", NULL, 76, 0x1f8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1232 PERIPH_CLK("owr", "owr", NULL, 71, 0x1cc, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1634 PERIPH_CLK("owr", "tegra_w1", NULL, 71, 0x1cc, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
1233 PERIPH_CLK("nor", "nor", NULL, 42, 0x1d0, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1635 PERIPH_CLK("nor", "nor", NULL, 42, 0x1d0, 92000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* requires min voltage */
1234 PERIPH_CLK("mipi", "mipi", NULL, 50, 0x174, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1636 PERIPH_CLK("mipi", "mipi", NULL, 50, 0x174, 60000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
1235 PERIPH_CLK("i2c1", "tegra-i2c.0", NULL, 12, 0x124, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1637 PERIPH_CLK("i2c1", "tegra-i2c.0", NULL, 12, 0x124, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16),
1236 PERIPH_CLK("i2c2", "tegra-i2c.1", NULL, 54, 0x198, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1638 PERIPH_CLK("i2c2", "tegra-i2c.1", NULL, 54, 0x198, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16),
1237 PERIPH_CLK("i2c3", "tegra-i2c.2", NULL, 67, 0x1b8, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1639 PERIPH_CLK("i2c3", "tegra-i2c.2", NULL, 67, 0x1b8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16),
1238 PERIPH_CLK("dvc", "tegra-i2c.3", NULL, 47, 0x128, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1640 PERIPH_CLK("dvc", "tegra-i2c.3", NULL, 47, 0x128, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U16),
1239 PERIPH_CLK("i2c1_i2c", "tegra-i2c.0", "i2c", 0, 0, mux_pllp_out3, 0), 1641 PERIPH_CLK("i2c1_i2c", "tegra-i2c.0", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
1240 PERIPH_CLK("i2c2_i2c", "tegra-i2c.1", "i2c", 0, 0, mux_pllp_out3, 0), 1642 PERIPH_CLK("i2c2_i2c", "tegra-i2c.1", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
1241 PERIPH_CLK("i2c3_i2c", "tegra-i2c.2", "i2c", 0, 0, mux_pllp_out3, 0), 1643 PERIPH_CLK("i2c3_i2c", "tegra-i2c.2", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
1242 PERIPH_CLK("dvc_i2c", "tegra-i2c.3", "i2c", 0, 0, mux_pllp_out3, 0), 1644 PERIPH_CLK("dvc_i2c", "tegra-i2c.3", "i2c", 0, 0, 72000000, mux_pllp_out3, 0),
1243 PERIPH_CLK("uarta", "uart.0", NULL, 6, 0x178, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1645 PERIPH_CLK("uarta", "uart.0", NULL, 6, 0x178, 216000000, mux_pllp_pllc_pllm_clkm, MUX),
1244 PERIPH_CLK("uartb", "uart.1", NULL, 7, 0x17c, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1646 PERIPH_CLK("uartb", "uart.1", NULL, 7, 0x17c, 216000000, mux_pllp_pllc_pllm_clkm, MUX),
1245 PERIPH_CLK("uartc", "uart.2", NULL, 55, 0x1a0, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1647 PERIPH_CLK("uartc", "uart.2", NULL, 55, 0x1a0, 216000000, mux_pllp_pllc_pllm_clkm, MUX),
1246 PERIPH_CLK("uartd", "uart.3", NULL, 65, 0x1c0, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1648 PERIPH_CLK("uartd", "uart.3", NULL, 65, 0x1c0, 216000000, mux_pllp_pllc_pllm_clkm, MUX),
1247 PERIPH_CLK("uarte", "uart.4", NULL, 66, 0x1c4, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), 1649 PERIPH_CLK("uarte", "uart.4", NULL, 66, 0x1c4, 216000000, mux_pllp_pllc_pllm_clkm, MUX),
1248 PERIPH_CLK("3d", "3d", NULL, 24, 0x158, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_MANUAL_RESET), 1650 PERIPH_CLK("3d", "3d", NULL, 24, 0x158, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_MANUAL_RESET), /* scales with voltage and process_id */
1249 PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1651 PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
1250 /* FIXME: vi and vi_sensor share an enable */ 1652 /* FIXME: vi and vi_sensor share an enable */
1251 PERIPH_CLK("vi", "vi", NULL, 20, 0x148, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1653 PERIPH_CLK("vi", "vi", NULL, 20, 0x148, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
1252 PERIPH_CLK("vi_sensor", "vi_sensor", NULL, 20, 0x1a8, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1654 PERIPH_CLK("vi_sensor", "vi_sensor", NULL, 20, 0x1a8, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_NO_RESET), /* scales with voltage and process_id */
1253 PERIPH_CLK("epp", "epp", NULL, 19, 0x16c, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1655 PERIPH_CLK("epp", "epp", NULL, 19, 0x16c, 300000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
1254 PERIPH_CLK("mpe", "mpe", NULL, 60, 0x170, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1656 PERIPH_CLK("mpe", "mpe", NULL, 60, 0x170, 250000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
1255 PERIPH_CLK("host1x", "host1x", NULL, 28, 0x180, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), 1657 PERIPH_CLK("host1x", "host1x", NULL, 28, 0x180, 166000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71), /* scales with voltage and process_id */
1256 /* FIXME: cve and tvo share an enable */ 1658 /* FIXME: cve and tvo share an enable */
1257 PERIPH_CLK("cve", "cve", NULL, 49, 0x140, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1659 PERIPH_CLK("cve", "cve", NULL, 49, 0x140, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
1258 PERIPH_CLK("tvo", "tvo", NULL, 49, 0x188, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1660 PERIPH_CLK("tvo", "tvo", NULL, 49, 0x188, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
1259 PERIPH_CLK("hdmi", "hdmi", NULL, 51, 0x18c, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1661 PERIPH_CLK("hdmi", "hdmi", NULL, 51, 0x18c, 148500000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
1260 PERIPH_CLK("tvdac", "tvdac", NULL, 53, 0x194, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1662 PERIPH_CLK("tvdac", "tvdac", NULL, 53, 0x194, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
1261 PERIPH_CLK("disp1", "tegrafb.0", NULL, 27, 0x138, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1663 PERIPH_CLK("disp1", "tegrafb.0", NULL, 27, 0x138, 190000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* scales with voltage and process_id */
1262 PERIPH_CLK("disp2", "tegrafb.1", NULL, 26, 0x13c, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), 1664 PERIPH_CLK("disp2", "tegrafb.1", NULL, 26, 0x13c, 190000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* scales with voltage and process_id */
1263 PERIPH_CLK("usbd", "fsl-tegra-udc", NULL, 22, 0, mux_clk_m, 0), 1665 PERIPH_CLK("usbd", "fsl-tegra-udc", NULL, 22, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
1264 PERIPH_CLK("usb2", "usb.1", NULL, 58, 0, mux_clk_m, 0), 1666 PERIPH_CLK("usb2", "tegra-ehci.1", NULL, 58, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
1265 PERIPH_CLK("usb3", "usb.2", NULL, 59, 0, mux_clk_m, 0), 1667 PERIPH_CLK("usb3", "tegra-ehci.2", NULL, 59, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
1266 PERIPH_CLK("emc", "emc", NULL, 57, 0x19c, mux_pllm_pllc_pllp_clkm, MUX | DIV_U71 | PERIPH_EMC_ENB), 1668 PERIPH_CLK("emc", "emc", NULL, 57, 0x19c, 800000000, mux_pllm_pllc_pllp_clkm, MUX | DIV_U71 | PERIPH_EMC_ENB),
1267 PERIPH_CLK("dsi", "dsi", NULL, 48, 0, mux_plld, 0), 1669 PERIPH_CLK("dsi", "dsi", NULL, 48, 0, 500000000, mux_plld, 0), /* scales with voltage */
1670 PERIPH_CLK("csi", "csi", NULL, 52, 0, 72000000, mux_pllp_out3, 0),
1671 PERIPH_CLK("isp", "isp", NULL, 23, 0, 150000000, mux_clk_m, 0), /* same frequency as VI */
1672 PERIPH_CLK("csus", "csus", NULL, 92, 0, 150000000, mux_clk_m, PERIPH_NO_RESET),
1673 PERIPH_CLK("pex", NULL, "pex", 70, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET),
1674 PERIPH_CLK("afi", NULL, "afi", 72, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET),
1675 PERIPH_CLK("pcie_xclk", NULL, "pcie_xclk", 74, 0, 26000000, mux_clk_m, PERIPH_MANUAL_RESET),
1268}; 1676};
1269 1677
1270#define CLK_DUPLICATE(_name, _dev, _con) \ 1678#define CLK_DUPLICATE(_name, _dev, _con) \
@@ -1286,6 +1694,9 @@ struct clk_duplicate tegra_clk_duplicates[] = {
1286 CLK_DUPLICATE("uartc", "tegra_uart.2", NULL), 1694 CLK_DUPLICATE("uartc", "tegra_uart.2", NULL),
1287 CLK_DUPLICATE("uartd", "tegra_uart.3", NULL), 1695 CLK_DUPLICATE("uartd", "tegra_uart.3", NULL),
1288 CLK_DUPLICATE("uarte", "tegra_uart.4", NULL), 1696 CLK_DUPLICATE("uarte", "tegra_uart.4", NULL),
1697 CLK_DUPLICATE("host1x", "tegrafb.0", "host1x"),
1698 CLK_DUPLICATE("host1x", "tegrafb.1", "host1x"),
1699 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
1289}; 1700};
1290 1701
1291#define CLK(dev, con, ck) \ 1702#define CLK(dev, con, ck) \
@@ -1315,11 +1726,13 @@ struct clk_lookup tegra_clk_lookups[] = {
1315 CLK(NULL, "pll_d_out0", &tegra_pll_d_out0), 1726 CLK(NULL, "pll_d_out0", &tegra_pll_d_out0),
1316 CLK(NULL, "pll_u", &tegra_pll_u), 1727 CLK(NULL, "pll_u", &tegra_pll_u),
1317 CLK(NULL, "pll_x", &tegra_pll_x), 1728 CLK(NULL, "pll_x", &tegra_pll_x),
1318 CLK(NULL, "cpu", &tegra_clk_cpu), 1729 CLK(NULL, "pll_e", &tegra_pll_e),
1319 CLK(NULL, "sys", &tegra_clk_sys), 1730 CLK(NULL, "cclk", &tegra_clk_cclk),
1731 CLK(NULL, "sclk", &tegra_clk_sclk),
1320 CLK(NULL, "hclk", &tegra_clk_hclk), 1732 CLK(NULL, "hclk", &tegra_clk_hclk),
1321 CLK(NULL, "pclk", &tegra_clk_pclk), 1733 CLK(NULL, "pclk", &tegra_clk_pclk),
1322 CLK(NULL, "clk_d", &tegra_clk_d), 1734 CLK(NULL, "clk_d", &tegra_clk_d),
1735 CLK(NULL, "cpu", &tegra_clk_virtual_cpu),
1323}; 1736};
1324 1737
1325void __init tegra2_init_clocks(void) 1738void __init tegra2_init_clocks(void)
@@ -1356,4 +1769,75 @@ void __init tegra2_init_clocks(void)
1356 cd->name); 1769 cd->name);
1357 } 1770 }
1358 } 1771 }
1772
1773 init_audio_sync_clock_mux();
1774}
1775
1776#ifdef CONFIG_PM
1777static u32 clk_rst_suspend[RST_DEVICES_NUM + CLK_OUT_ENB_NUM +
1778 PERIPH_CLK_SOURCE_NUM + 3];
1779
1780void tegra_clk_suspend(void)
1781{
1782 unsigned long off, i;
1783 u32 *ctx = clk_rst_suspend;
1784
1785 *ctx++ = clk_readl(OSC_CTRL) & OSC_CTRL_MASK;
1786
1787 for (off = PERIPH_CLK_SOURCE_I2S1; off <= PERIPH_CLK_SOURCE_OSC;
1788 off += 4) {
1789 if (off == PERIPH_CLK_SOURCE_EMC)
1790 continue;
1791 *ctx++ = clk_readl(off);
1792 }
1793
1794 off = RST_DEVICES;
1795 for (i = 0; i < RST_DEVICES_NUM; i++, off += 4)
1796 *ctx++ = clk_readl(off);
1797
1798 off = CLK_OUT_ENB;
1799 for (i = 0; i < CLK_OUT_ENB_NUM; i++, off += 4)
1800 *ctx++ = clk_readl(off);
1801
1802 *ctx++ = clk_readl(MISC_CLK_ENB);
1803 *ctx++ = clk_readl(CLK_MASK_ARM);
1804}
1805
1806void tegra_clk_resume(void)
1807{
1808 unsigned long off, i;
1809 const u32 *ctx = clk_rst_suspend;
1810 u32 val;
1811
1812 val = clk_readl(OSC_CTRL) & ~OSC_CTRL_MASK;
1813 val |= *ctx++;
1814 clk_writel(val, OSC_CTRL);
1815
1816 /* enable all clocks before configuring clock sources */
1817 clk_writel(0xbffffff9ul, CLK_OUT_ENB);
1818 clk_writel(0xfefffff7ul, CLK_OUT_ENB + 4);
1819 clk_writel(0x77f01bfful, CLK_OUT_ENB + 8);
1820 wmb();
1821
1822 for (off = PERIPH_CLK_SOURCE_I2S1; off <= PERIPH_CLK_SOURCE_OSC;
1823 off += 4) {
1824 if (off == PERIPH_CLK_SOURCE_EMC)
1825 continue;
1826 clk_writel(*ctx++, off);
1827 }
1828 wmb();
1829
1830 off = RST_DEVICES;
1831 for (i = 0; i < RST_DEVICES_NUM; i++, off += 4)
1832 clk_writel(*ctx++, off);
1833 wmb();
1834
1835 off = CLK_OUT_ENB;
1836 for (i = 0; i < CLK_OUT_ENB_NUM; i++, off += 4)
1837 clk_writel(*ctx++, off);
1838 wmb();
1839
1840 clk_writel(*ctx++, MISC_CLK_ENB);
1841 clk_writel(*ctx++, CLK_MASK_ARM);
1359} 1842}
1843#endif
diff --git a/arch/arm/mach-tegra/tegra2_dvfs.c b/arch/arm/mach-tegra/tegra2_dvfs.c
new file mode 100644
index 000000000000..5529c238dd77
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra2_dvfs.c
@@ -0,0 +1,86 @@
1/*
2 * arch/arm/mach-tegra/tegra2_dvfs.c
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * Author:
7 * Colin Cross <ccross@google.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
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 */
19
20#include <linux/kernel.h>
21
22#include "clock.h"
23#include "tegra2_dvfs.h"
24
25static struct dvfs_table virtual_cpu_process_0[] = {
26 {314000000, 750},
27 {456000000, 825},
28 {608000000, 900},
29 {760000000, 975},
30 {817000000, 1000},
31 {912000000, 1050},
32 {1000000000, 1100},
33 {0, 0},
34};
35
36static struct dvfs_table virtual_cpu_process_1[] = {
37 {314000000, 750},
38 {456000000, 825},
39 {618000000, 900},
40 {770000000, 975},
41 {827000000, 1000},
42 {922000000, 1050},
43 {1000000000, 1100},
44 {0, 0},
45};
46
47static struct dvfs_table virtual_cpu_process_2[] = {
48 {494000000, 750},
49 {675000000, 825},
50 {817000000, 875},
51 {922000000, 925},
52 {1000000000, 975},
53 {0, 0},
54};
55
56static struct dvfs_table virtual_cpu_process_3[] = {
57 {730000000, 750},
58 {760000000, 775},
59 {845000000, 800},
60 {1000000000, 875},
61 {0, 0},
62};
63
64struct dvfs tegra_dvfs_virtual_cpu_dvfs = {
65 .reg_id = "vdd_cpu",
66 .process_id_table = {
67 {
68 .process_id = 0,
69 .table = virtual_cpu_process_0,
70 },
71 {
72 .process_id = 1,
73 .table = virtual_cpu_process_1,
74 },
75 {
76 .process_id = 2,
77 .table = virtual_cpu_process_2,
78 },
79 {
80 .process_id = 3,
81 .table = virtual_cpu_process_3,
82 },
83 },
84 .process_id_table_length = 4,
85 .cpu = 1,
86};
diff --git a/arch/arm/mach-tegra/tegra2_dvfs.h b/arch/arm/mach-tegra/tegra2_dvfs.h
new file mode 100644
index 000000000000..f8c1adba96a6
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra2_dvfs.h
@@ -0,0 +1,20 @@
1/*
2 * arch/arm/mach-tegra/tegra2_dvfs.h
3 *
4 * Copyright (C) 2010 Google, Inc.
5 *
6 * Author:
7 * Colin Cross <ccross@google.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
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 */
19
20extern struct dvfs tegra_dvfs_virtual_cpu_dvfs;
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index 2f420210d406..9057d6fd1d31 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -28,7 +28,6 @@
28#include <linux/cnt32_to_63.h> 28#include <linux/cnt32_to_63.h>
29 29
30#include <asm/mach/time.h> 30#include <asm/mach/time.h>
31#include <asm/mach/time.h>
32#include <asm/localtimer.h> 31#include <asm/localtimer.h>
33 32
34#include <mach/iomap.h> 33#include <mach/iomap.h>
diff --git a/arch/arm/mach-u300/clock.c b/arch/arm/mach-u300/clock.c
index 60acf9e708ae..7458fc6df5c6 100644
--- a/arch/arm/mach-u300/clock.c
+++ b/arch/arm/mach-u300/clock.c
@@ -66,7 +66,7 @@ static DEFINE_SPINLOCK(syscon_resetreg_lock);
66 * AMBA bus 66 * AMBA bus
67 * | 67 * |
68 * +- CPU 68 * +- CPU
69 * +- NANDIF NAND Flash interface 69 * +- FSMC NANDIF NAND Flash interface
70 * +- SEMI Shared Memory interface 70 * +- SEMI Shared Memory interface
71 * +- ISP Image Signal Processor (U335 only) 71 * +- ISP Image Signal Processor (U335 only)
72 * +- CDS (U335 only) 72 * +- CDS (U335 only)
@@ -726,7 +726,7 @@ static struct clk cpu_clk = {
726}; 726};
727 727
728static struct clk nandif_clk = { 728static struct clk nandif_clk = {
729 .name = "NANDIF", 729 .name = "FSMC",
730 .parent = &amba_clk, 730 .parent = &amba_clk,
731 .hw_ctrld = false, 731 .hw_ctrld = false,
732 .reset = true, 732 .reset = true,
@@ -1259,7 +1259,7 @@ static struct clk_lookup lookups[] = {
1259 /* Connected directly to the AMBA bus */ 1259 /* Connected directly to the AMBA bus */
1260 DEF_LOOKUP("amba", &amba_clk), 1260 DEF_LOOKUP("amba", &amba_clk),
1261 DEF_LOOKUP("cpu", &cpu_clk), 1261 DEF_LOOKUP("cpu", &cpu_clk),
1262 DEF_LOOKUP("fsmc", &nandif_clk), 1262 DEF_LOOKUP("fsmc-nand", &nandif_clk),
1263 DEF_LOOKUP("semi", &semi_clk), 1263 DEF_LOOKUP("semi", &semi_clk),
1264#ifdef CONFIG_MACH_U300_BS335 1264#ifdef CONFIG_MACH_U300_BS335
1265 DEF_LOOKUP("isp", &isp_clk), 1265 DEF_LOOKUP("isp", &isp_clk),
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index ea41c236be0f..aa53ee22438f 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -21,7 +21,8 @@
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <mach/coh901318.h> 24#include <linux/mtd/nand.h>
25#include <linux/mtd/fsmc.h>
25 26
26#include <asm/types.h> 27#include <asm/types.h>
27#include <asm/setup.h> 28#include <asm/setup.h>
@@ -30,6 +31,7 @@
30#include <asm/mach/map.h> 31#include <asm/mach/map.h>
31#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
32 33
34#include <mach/coh901318.h>
33#include <mach/hardware.h> 35#include <mach/hardware.h>
34#include <mach/syscon.h> 36#include <mach/syscon.h>
35#include <mach/dma_channels.h> 37#include <mach/dma_channels.h>
@@ -285,6 +287,13 @@ static struct resource rtc_resources[] = {
285 */ 287 */
286static struct resource fsmc_resources[] = { 288static struct resource fsmc_resources[] = {
287 { 289 {
290 .name = "nand_data",
291 .start = U300_NAND_CS0_PHYS_BASE,
292 .end = U300_NAND_CS0_PHYS_BASE + SZ_16K - 1,
293 .flags = IORESOURCE_MEM,
294 },
295 {
296 .name = "fsmc_regs",
288 .start = U300_NAND_IF_PHYS_BASE, 297 .start = U300_NAND_IF_PHYS_BASE,
289 .end = U300_NAND_IF_PHYS_BASE + SZ_4K - 1, 298 .end = U300_NAND_IF_PHYS_BASE + SZ_4K - 1,
290 .flags = IORESOURCE_MEM, 299 .flags = IORESOURCE_MEM,
@@ -1429,11 +1438,39 @@ static struct platform_device rtc_device = {
1429 .resource = rtc_resources, 1438 .resource = rtc_resources,
1430}; 1439};
1431 1440
1432static struct platform_device fsmc_device = { 1441static struct mtd_partition u300_partitions[] = {
1433 .name = "nandif", 1442 {
1443 .name = "bootrecords",
1444 .offset = 0,
1445 .size = SZ_128K,
1446 },
1447 {
1448 .name = "free",
1449 .offset = SZ_128K,
1450 .size = 8064 * SZ_1K,
1451 },
1452 {
1453 .name = "platform",
1454 .offset = 8192 * SZ_1K,
1455 .size = 253952 * SZ_1K,
1456 },
1457};
1458
1459static struct fsmc_nand_platform_data nand_platform_data = {
1460 .partitions = u300_partitions,
1461 .nr_partitions = ARRAY_SIZE(u300_partitions),
1462 .options = NAND_SKIP_BBTSCAN,
1463 .width = FSMC_NAND_BW8,
1464};
1465
1466static struct platform_device nand_device = {
1467 .name = "fsmc-nand",
1434 .id = -1, 1468 .id = -1,
1435 .num_resources = ARRAY_SIZE(fsmc_resources),
1436 .resource = fsmc_resources, 1469 .resource = fsmc_resources,
1470 .num_resources = ARRAY_SIZE(fsmc_resources),
1471 .dev = {
1472 .platform_data = &nand_platform_data,
1473 },
1437}; 1474};
1438 1475
1439static struct platform_device ave_device = { 1476static struct platform_device ave_device = {
@@ -1465,7 +1502,7 @@ static struct platform_device *platform_devs[] __initdata = {
1465 &keypad_device, 1502 &keypad_device,
1466 &rtc_device, 1503 &rtc_device,
1467 &gpio_device, 1504 &gpio_device,
1468 &fsmc_device, 1505 &nand_device,
1469 &wdog_device, 1506 &wdog_device,
1470 &ave_device 1507 &ave_device
1471}; 1508};
diff --git a/arch/arm/mach-u300/include/mach/u300-regs.h b/arch/arm/mach-u300/include/mach/u300-regs.h
index 56721a0cd2af..8b85df4c8d8f 100644
--- a/arch/arm/mach-u300/include/mach/u300-regs.h
+++ b/arch/arm/mach-u300/include/mach/u300-regs.h
@@ -20,11 +20,9 @@
20 20
21/* NAND Flash CS0 */ 21/* NAND Flash CS0 */
22#define U300_NAND_CS0_PHYS_BASE 0x80000000 22#define U300_NAND_CS0_PHYS_BASE 0x80000000
23#define U300_NAND_CS0_VIRT_BASE 0xff040000
24 23
25/* NFIF */ 24/* NFIF */
26#define U300_NAND_IF_PHYS_BASE 0x9f800000 25#define U300_NAND_IF_PHYS_BASE 0x9f800000
27#define U300_NAND_IF_VIRT_BASE 0xff030000
28 26
29/* AHB Peripherals */ 27/* AHB Peripherals */
30#define U300_AHB_PER_PHYS_BASE 0xa0000000 28#define U300_AHB_PER_PHYS_BASE 0xa0000000
diff --git a/arch/arm/mach-u300/spi.c b/arch/arm/mach-u300/spi.c
index edb2c0d255c2..00869def5420 100644
--- a/arch/arm/mach-u300/spi.c
+++ b/arch/arm/mach-u300/spi.c
@@ -67,7 +67,7 @@ static struct spi_board_info u300_spi_devices[] = {
67 .bus_num = 0, /* Only one bus on this chip */ 67 .bus_num = 0, /* Only one bus on this chip */
68 .chip_select = 0, 68 .chip_select = 0,
69 /* Means SPI_CS_HIGH, change if e.g low CS */ 69 /* Means SPI_CS_HIGH, change if e.g low CS */
70 .mode = SPI_MODE_1 | SPI_LSB_FIRST | SPI_LOOP, 70 .mode = SPI_MODE_1 | SPI_LOOP,
71 }, 71 },
72#endif 72#endif
73}; 73};
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index fcb587f825cc..cac83a694880 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -18,12 +18,14 @@
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>
@@ -49,6 +51,24 @@ static pin_cfg_t mop500_pins[] = {
49 GPIO11_I2C2_SCL, 51 GPIO11_I2C2_SCL,
50 GPIO229_I2C3_SDA, 52 GPIO229_I2C3_SDA,
51 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,
52}; 72};
53 73
54static void ab4500_spi_cs_control(u32 command) 74static void ab4500_spi_cs_control(u32 command)
@@ -148,12 +168,120 @@ static struct amba_device *amba_devs[] __initdata = {
148 &u8500_ssp0_device, 168 &u8500_ssp0_device,
149}; 169};
150 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
151/* add any platform devices here - TODO */ 278/* add any platform devices here - TODO */
152static struct platform_device *platform_devs[] __initdata = { 279static struct platform_device *platform_devs[] __initdata = {
153 &u8500_i2c0_device, 280 &u8500_i2c0_device,
154 &ux500_i2c1_device, 281 &ux500_i2c1_device,
155 &ux500_i2c2_device, 282 &ux500_i2c2_device,
156 &ux500_i2c3_device, 283 &ux500_i2c3_device,
284 &ux500_ske_keypad_device,
157}; 285};
158 286
159static void __init u8500_init_machine(void) 287static void __init u8500_init_machine(void)
@@ -168,6 +296,7 @@ static void __init u8500_init_machine(void)
168 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data; 296 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
169 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data; 297 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
170 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;
171 300
172 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data; 301 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
173 302
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.c b/arch/arm/mach-ux500/cpu.c
index e0fd747e447a..73fb1a551ec6 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -10,6 +10,7 @@
10#include <linux/io.h> 10#include <linux/io.h>
11#include <linux/clk.h> 11#include <linux/clk.h>
12 12
13#include <asm/cacheflush.h>
13#include <asm/hardware/cache-l2x0.h> 14#include <asm/hardware/cache-l2x0.h>
14#include <asm/hardware/gic.h> 15#include <asm/hardware/gic.h>
15#include <asm/mach/map.h> 16#include <asm/mach/map.h>
@@ -71,6 +72,46 @@ void __init ux500_init_irq(void)
71} 72}
72 73
73#ifdef CONFIG_CACHE_L2X0 74#ifdef CONFIG_CACHE_L2X0
75static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
76{
77 /* wait for the operation to complete */
78 while (readl(reg) & mask)
79 ;
80}
81
82static inline void ux500_cache_sync(void)
83{
84 void __iomem *base = __io_address(UX500_L2CC_BASE);
85 writel(0, base + L2X0_CACHE_SYNC);
86 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
87}
88
89/*
90 * The L2 cache cannot be turned off in the non-secure world.
91 * Dummy until a secure service is in place.
92 */
93static void ux500_l2x0_disable(void)
94{
95}
96
97/*
98 * This is only called when doing a kexec, just after turning off the L2
99 * and L1 cache, and it is surrounded by a spinlock in the generic version.
100 * However, we're not really turning off the L2 cache right now and the
101 * PL310 does not support exclusive accesses (used to implement the spinlock).
102 * So, the invalidation needs to be done without the spinlock.
103 */
104static void ux500_l2x0_inv_all(void)
105{
106 void __iomem *l2x0_base = __io_address(UX500_L2CC_BASE);
107 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
108
109 /* invalidate all ways */
110 writel(l2x0_way_mask, l2x0_base + L2X0_INV_WAY);
111 ux500_cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask);
112 ux500_cache_sync();
113}
114
74static int ux500_l2x0_init(void) 115static int ux500_l2x0_init(void)
75{ 116{
76 void __iomem *l2x0_base; 117 void __iomem *l2x0_base;
@@ -80,6 +121,10 @@ static int ux500_l2x0_init(void)
80 /* 64KB way size, 8 way associativity, force WA */ 121 /* 64KB way size, 8 way associativity, force WA */
81 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff); 122 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
82 123
124 /* Override invalidate function */
125 outer_cache.disable = ux500_l2x0_disable;
126 outer_cache.inv_all = ux500_l2x0_inv_all;
127
83 return 0; 128 return 0;
84} 129}
85early_initcall(ux500_l2x0_init); 130early_initcall(ux500_l2x0_init);
diff --git a/arch/arm/mach-ux500/devices-db8500.c b/arch/arm/mach-ux500/devices-db8500.c
index 40032fecbc16..4a94be3304b9 100644
--- a/arch/arm/mach-ux500/devices-db8500.c
+++ b/arch/arm/mach-ux500/devices-db8500.c
@@ -208,35 +208,25 @@ static struct resource dma40_resources[] = {
208 208
209/* Default configuration for physcial memcpy */ 209/* Default configuration for physcial memcpy */
210struct stedma40_chan_cfg dma40_memcpy_conf_phy = { 210struct stedma40_chan_cfg dma40_memcpy_conf_phy = {
211 .channel_type = (STEDMA40_CHANNEL_IN_PHY_MODE | 211 .mode = STEDMA40_MODE_PHYSICAL,
212 STEDMA40_LOW_PRIORITY_CHANNEL |
213 STEDMA40_PCHAN_BASIC_MODE),
214 .dir = STEDMA40_MEM_TO_MEM, 212 .dir = STEDMA40_MEM_TO_MEM,
215 213
216 .src_info.endianess = STEDMA40_LITTLE_ENDIAN,
217 .src_info.data_width = STEDMA40_BYTE_WIDTH, 214 .src_info.data_width = STEDMA40_BYTE_WIDTH,
218 .src_info.psize = STEDMA40_PSIZE_PHY_1, 215 .src_info.psize = STEDMA40_PSIZE_PHY_1,
219 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, 216 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
220 217
221 .dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
222 .dst_info.data_width = STEDMA40_BYTE_WIDTH, 218 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
223 .dst_info.psize = STEDMA40_PSIZE_PHY_1, 219 .dst_info.psize = STEDMA40_PSIZE_PHY_1,
224 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, 220 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
225}; 221};
226/* Default configuration for logical memcpy */ 222/* Default configuration for logical memcpy */
227struct stedma40_chan_cfg dma40_memcpy_conf_log = { 223struct stedma40_chan_cfg dma40_memcpy_conf_log = {
228 .channel_type = (STEDMA40_CHANNEL_IN_LOG_MODE |
229 STEDMA40_LOW_PRIORITY_CHANNEL |
230 STEDMA40_LCHAN_SRC_LOG_DST_LOG |
231 STEDMA40_NO_TIM_FOR_LINK),
232 .dir = STEDMA40_MEM_TO_MEM, 224 .dir = STEDMA40_MEM_TO_MEM,
233 225
234 .src_info.endianess = STEDMA40_LITTLE_ENDIAN,
235 .src_info.data_width = STEDMA40_BYTE_WIDTH, 226 .src_info.data_width = STEDMA40_BYTE_WIDTH,
236 .src_info.psize = STEDMA40_PSIZE_LOG_1, 227 .src_info.psize = STEDMA40_PSIZE_LOG_1,
237 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, 228 .src_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
238 229
239 .dst_info.endianess = STEDMA40_LITTLE_ENDIAN,
240 .dst_info.data_width = STEDMA40_BYTE_WIDTH, 230 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
241 .dst_info.psize = STEDMA40_PSIZE_LOG_1, 231 .dst_info.psize = STEDMA40_PSIZE_LOG_1,
242 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL, 232 .dst_info.flow_ctrl = STEDMA40_NO_FLOW_CTRL,
@@ -269,7 +259,6 @@ static struct stedma40_platform_data dma40_plat_data = {
269 .memcpy_len = ARRAY_SIZE(dma40_memcpy_event), 259 .memcpy_len = ARRAY_SIZE(dma40_memcpy_event),
270 .memcpy_conf_phy = &dma40_memcpy_conf_phy, 260 .memcpy_conf_phy = &dma40_memcpy_conf_phy,
271 .memcpy_conf_log = &dma40_memcpy_conf_log, 261 .memcpy_conf_log = &dma40_memcpy_conf_log,
272 .llis_per_log = 8,
273 .disabled_channels = {-1}, 262 .disabled_channels = {-1},
274}; 263};
275 264
@@ -292,3 +281,23 @@ void dma40_u8500ed_fixup(void)
292 dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED; 281 dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
293 dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1; 282 dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
294} 283}
284
285struct resource keypad_resources[] = {
286 [0] = {
287 .start = U8500_SKE_BASE,
288 .end = U8500_SKE_BASE + SZ_4K - 1,
289 .flags = IORESOURCE_MEM,
290 },
291 [1] = {
292 .start = IRQ_DB8500_KB,
293 .end = IRQ_DB8500_KB,
294 .flags = IORESOURCE_IRQ,
295 },
296};
297
298struct platform_device ux500_ske_keypad_device = {
299 .name = "nmk-ske-keypad",
300 .id = -1,
301 .num_resources = ARRAY_SIZE(keypad_resources),
302 .resource = keypad_resources,
303};
diff --git a/arch/arm/mach-ux500/include/mach/devices.h b/arch/arm/mach-ux500/include/mach/devices.h
index 33a120c2e82e..b91a4d1211a2 100644
--- a/arch/arm/mach-ux500/include/mach/devices.h
+++ b/arch/arm/mach-ux500/include/mach/devices.h
@@ -26,6 +26,7 @@ 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;
29 30
30extern struct amba_device u8500_sdi0_device; 31extern struct amba_device u8500_sdi0_device;
31extern struct amba_device u8500_sdi1_device; 32extern struct amba_device u8500_sdi1_device;
diff --git a/arch/arm/mach-ux500/pins-db8500.h b/arch/arm/mach-ux500/pins-db8500.h
index 66f8761cc823..f923764ee16c 100644
--- a/arch/arm/mach-ux500/pins-db8500.h
+++ b/arch/arm/mach-ux500/pins-db8500.h
@@ -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
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index c2e405a9e025..fd25ccd7272f 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -54,7 +54,9 @@ static struct map_desc ct_ca9x4_io_desc[] __initdata = {
54 54
55static void __init ct_ca9x4_map_io(void) 55static void __init ct_ca9x4_map_io(void)
56{ 56{
57#ifdef CONFIG_LOCAL_TIMERS
57 twd_base = MMIO_P2V(A9_MPCORE_TWD); 58 twd_base = MMIO_P2V(A9_MPCORE_TWD);
59#endif
58 v2m_map_io(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc)); 60 v2m_map_io(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
59} 61}
60 62
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index a0a2928ae4dd..4414a01e1e8a 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -779,6 +779,14 @@ config CACHE_L2X0
779 help 779 help
780 This option enables the L2x0 PrimeCell. 780 This option enables the L2x0 PrimeCell.
781 781
782config CACHE_PL310
783 bool
784 depends on CACHE_L2X0
785 default y if CPU_V7 && !CPU_V6
786 help
787 This option enables optimisations for the PL310 cache
788 controller.
789
782config CACHE_TAUROS2 790config CACHE_TAUROS2
783 bool "Enable the Tauros2 L2 cache controller" 791 bool "Enable the Tauros2 L2 cache controller"
784 depends on (ARCH_DOVE || ARCH_MMP) 792 depends on (ARCH_DOVE || ARCH_MMP)
diff --git a/arch/arm/mm/cache-fa.S b/arch/arm/mm/cache-fa.S
index 7148e53e6078..1fa6f71470de 100644
--- a/arch/arm/mm/cache-fa.S
+++ b/arch/arm/mm/cache-fa.S
@@ -38,6 +38,17 @@
38#define CACHE_DLIMIT (CACHE_DSIZE * 2) 38#define CACHE_DLIMIT (CACHE_DSIZE * 2)
39 39
40/* 40/*
41 * flush_icache_all()
42 *
43 * Unconditionally clean and invalidate the entire icache.
44 */
45ENTRY(fa_flush_icache_all)
46 mov r0, #0
47 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
48 mov pc, lr
49ENDPROC(fa_flush_icache_all)
50
51/*
41 * flush_user_cache_all() 52 * flush_user_cache_all()
42 * 53 *
43 * Clean and invalidate all cache entries in a particular address 54 * Clean and invalidate all cache entries in a particular address
@@ -233,6 +244,7 @@ ENDPROC(fa_dma_unmap_area)
233 244
234 .type fa_cache_fns, #object 245 .type fa_cache_fns, #object
235ENTRY(fa_cache_fns) 246ENTRY(fa_cache_fns)
247 .long fa_flush_icache_all
236 .long fa_flush_kern_cache_all 248 .long fa_flush_kern_cache_all
237 .long fa_flush_user_cache_all 249 .long fa_flush_user_cache_all
238 .long fa_flush_user_cache_range 250 .long fa_flush_user_cache_range
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 9982eb385c0f..170c9bb95866 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -28,14 +28,24 @@
28static void __iomem *l2x0_base; 28static void __iomem *l2x0_base;
29static DEFINE_SPINLOCK(l2x0_lock); 29static DEFINE_SPINLOCK(l2x0_lock);
30static uint32_t l2x0_way_mask; /* Bitmask of active ways */ 30static uint32_t l2x0_way_mask; /* Bitmask of active ways */
31static uint32_t l2x0_size;
31 32
32static inline void cache_wait(void __iomem *reg, unsigned long mask) 33static inline void cache_wait_way(void __iomem *reg, unsigned long mask)
33{ 34{
34 /* wait for the operation to complete */ 35 /* wait for cache operation by line or way to complete */
35 while (readl_relaxed(reg) & mask) 36 while (readl_relaxed(reg) & mask)
36 ; 37 ;
37} 38}
38 39
40#ifdef CONFIG_CACHE_PL310
41static inline void cache_wait(void __iomem *reg, unsigned long mask)
42{
43 /* cache operations by line are atomic on PL310 */
44}
45#else
46#define cache_wait cache_wait_way
47#endif
48
39static inline void cache_sync(void) 49static inline void cache_sync(void)
40{ 50{
41 void __iomem *base = l2x0_base; 51 void __iomem *base = l2x0_base;
@@ -103,14 +113,40 @@ static void l2x0_cache_sync(void)
103 spin_unlock_irqrestore(&l2x0_lock, flags); 113 spin_unlock_irqrestore(&l2x0_lock, flags);
104} 114}
105 115
106static inline void l2x0_inv_all(void) 116static void l2x0_flush_all(void)
117{
118 unsigned long flags;
119
120 /* clean all ways */
121 spin_lock_irqsave(&l2x0_lock, flags);
122 writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY);
123 cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask);
124 cache_sync();
125 spin_unlock_irqrestore(&l2x0_lock, flags);
126}
127
128static void l2x0_clean_all(void)
129{
130 unsigned long flags;
131
132 /* clean all ways */
133 spin_lock_irqsave(&l2x0_lock, flags);
134 writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_WAY);
135 cache_wait_way(l2x0_base + L2X0_CLEAN_WAY, l2x0_way_mask);
136 cache_sync();
137 spin_unlock_irqrestore(&l2x0_lock, flags);
138}
139
140static void l2x0_inv_all(void)
107{ 141{
108 unsigned long flags; 142 unsigned long flags;
109 143
110 /* invalidate all ways */ 144 /* invalidate all ways */
111 spin_lock_irqsave(&l2x0_lock, flags); 145 spin_lock_irqsave(&l2x0_lock, flags);
146 /* Invalidating when L2 is enabled is a nono */
147 BUG_ON(readl(l2x0_base + L2X0_CTRL) & 1);
112 writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY); 148 writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY);
113 cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask); 149 cache_wait_way(l2x0_base + L2X0_INV_WAY, l2x0_way_mask);
114 cache_sync(); 150 cache_sync();
115 spin_unlock_irqrestore(&l2x0_lock, flags); 151 spin_unlock_irqrestore(&l2x0_lock, flags);
116} 152}
@@ -159,6 +195,11 @@ static void l2x0_clean_range(unsigned long start, unsigned long end)
159 void __iomem *base = l2x0_base; 195 void __iomem *base = l2x0_base;
160 unsigned long flags; 196 unsigned long flags;
161 197
198 if ((end - start) >= l2x0_size) {
199 l2x0_clean_all();
200 return;
201 }
202
162 spin_lock_irqsave(&l2x0_lock, flags); 203 spin_lock_irqsave(&l2x0_lock, flags);
163 start &= ~(CACHE_LINE_SIZE - 1); 204 start &= ~(CACHE_LINE_SIZE - 1);
164 while (start < end) { 205 while (start < end) {
@@ -184,6 +225,11 @@ static void l2x0_flush_range(unsigned long start, unsigned long end)
184 void __iomem *base = l2x0_base; 225 void __iomem *base = l2x0_base;
185 unsigned long flags; 226 unsigned long flags;
186 227
228 if ((end - start) >= l2x0_size) {
229 l2x0_flush_all();
230 return;
231 }
232
187 spin_lock_irqsave(&l2x0_lock, flags); 233 spin_lock_irqsave(&l2x0_lock, flags);
188 start &= ~(CACHE_LINE_SIZE - 1); 234 start &= ~(CACHE_LINE_SIZE - 1);
189 while (start < end) { 235 while (start < end) {
@@ -206,10 +252,20 @@ static void l2x0_flush_range(unsigned long start, unsigned long end)
206 spin_unlock_irqrestore(&l2x0_lock, flags); 252 spin_unlock_irqrestore(&l2x0_lock, flags);
207} 253}
208 254
255static void l2x0_disable(void)
256{
257 unsigned long flags;
258
259 spin_lock_irqsave(&l2x0_lock, flags);
260 writel(0, l2x0_base + L2X0_CTRL);
261 spin_unlock_irqrestore(&l2x0_lock, flags);
262}
263
209void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask) 264void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
210{ 265{
211 __u32 aux; 266 __u32 aux;
212 __u32 cache_id; 267 __u32 cache_id;
268 __u32 way_size = 0;
213 int ways; 269 int ways;
214 const char *type; 270 const char *type;
215 271
@@ -244,6 +300,13 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
244 l2x0_way_mask = (1 << ways) - 1; 300 l2x0_way_mask = (1 << ways) - 1;
245 301
246 /* 302 /*
303 * L2 cache Size = Way size * Number of ways
304 */
305 way_size = (aux & L2X0_AUX_CTRL_WAY_SIZE_MASK) >> 17;
306 way_size = 1 << (way_size + 3);
307 l2x0_size = ways * way_size * SZ_1K;
308
309 /*
247 * Check if l2x0 controller is already enabled. 310 * Check if l2x0 controller is already enabled.
248 * If you are booting from non-secure mode 311 * If you are booting from non-secure mode
249 * accessing the below registers will fault. 312 * accessing the below registers will fault.
@@ -263,8 +326,11 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
263 outer_cache.clean_range = l2x0_clean_range; 326 outer_cache.clean_range = l2x0_clean_range;
264 outer_cache.flush_range = l2x0_flush_range; 327 outer_cache.flush_range = l2x0_flush_range;
265 outer_cache.sync = l2x0_cache_sync; 328 outer_cache.sync = l2x0_cache_sync;
329 outer_cache.flush_all = l2x0_flush_all;
330 outer_cache.inv_all = l2x0_inv_all;
331 outer_cache.disable = l2x0_disable;
266 332
267 printk(KERN_INFO "%s cache controller enabled\n", type); 333 printk(KERN_INFO "%s cache controller enabled\n", type);
268 printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x\n", 334 printk(KERN_INFO "l2x0: %d ways, CACHE_ID 0x%08x, AUX_CTRL 0x%08x, Cache size: %d B\n",
269 ways, cache_id, aux); 335 ways, cache_id, aux, l2x0_size);
270} 336}
diff --git a/arch/arm/mm/cache-v3.S b/arch/arm/mm/cache-v3.S
index c2ff3c599fee..2e2bc406a18d 100644
--- a/arch/arm/mm/cache-v3.S
+++ b/arch/arm/mm/cache-v3.S
@@ -13,6 +13,15 @@
13#include "proc-macros.S" 13#include "proc-macros.S"
14 14
15/* 15/*
16 * flush_icache_all()
17 *
18 * Unconditionally clean and invalidate the entire icache.
19 */
20ENTRY(v3_flush_icache_all)
21 mov pc, lr
22ENDPROC(v3_flush_icache_all)
23
24/*
16 * flush_user_cache_all() 25 * flush_user_cache_all()
17 * 26 *
18 * Invalidate all cache entries in a particular address 27 * Invalidate all cache entries in a particular address
@@ -122,6 +131,7 @@ ENDPROC(v3_dma_map_area)
122 131
123 .type v3_cache_fns, #object 132 .type v3_cache_fns, #object
124ENTRY(v3_cache_fns) 133ENTRY(v3_cache_fns)
134 .long v3_flush_icache_all
125 .long v3_flush_kern_cache_all 135 .long v3_flush_kern_cache_all
126 .long v3_flush_user_cache_all 136 .long v3_flush_user_cache_all
127 .long v3_flush_user_cache_range 137 .long v3_flush_user_cache_range
diff --git a/arch/arm/mm/cache-v4.S b/arch/arm/mm/cache-v4.S
index 4810f7e3e813..a8fefb523f19 100644
--- a/arch/arm/mm/cache-v4.S
+++ b/arch/arm/mm/cache-v4.S
@@ -13,6 +13,15 @@
13#include "proc-macros.S" 13#include "proc-macros.S"
14 14
15/* 15/*
16 * flush_icache_all()
17 *
18 * Unconditionally clean and invalidate the entire icache.
19 */
20ENTRY(v4_flush_icache_all)
21 mov pc, lr
22ENDPROC(v4_flush_icache_all)
23
24/*
16 * flush_user_cache_all() 25 * flush_user_cache_all()
17 * 26 *
18 * Invalidate all cache entries in a particular address 27 * Invalidate all cache entries in a particular address
@@ -134,6 +143,7 @@ ENDPROC(v4_dma_map_area)
134 143
135 .type v4_cache_fns, #object 144 .type v4_cache_fns, #object
136ENTRY(v4_cache_fns) 145ENTRY(v4_cache_fns)
146 .long v4_flush_icache_all
137 .long v4_flush_kern_cache_all 147 .long v4_flush_kern_cache_all
138 .long v4_flush_user_cache_all 148 .long v4_flush_user_cache_all
139 .long v4_flush_user_cache_range 149 .long v4_flush_user_cache_range
diff --git a/arch/arm/mm/cache-v4wb.S b/arch/arm/mm/cache-v4wb.S
index df8368afa102..d3644db467b7 100644
--- a/arch/arm/mm/cache-v4wb.S
+++ b/arch/arm/mm/cache-v4wb.S
@@ -51,6 +51,17 @@ flush_base:
51 .text 51 .text
52 52
53/* 53/*
54 * flush_icache_all()
55 *
56 * Unconditionally clean and invalidate the entire icache.
57 */
58ENTRY(v4wb_flush_icache_all)
59 mov r0, #0
60 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
61 mov pc, lr
62ENDPROC(v4wb_flush_icache_all)
63
64/*
54 * flush_user_cache_all() 65 * flush_user_cache_all()
55 * 66 *
56 * Clean and invalidate all cache entries in a particular address 67 * Clean and invalidate all cache entries in a particular address
@@ -244,6 +255,7 @@ ENDPROC(v4wb_dma_unmap_area)
244 255
245 .type v4wb_cache_fns, #object 256 .type v4wb_cache_fns, #object
246ENTRY(v4wb_cache_fns) 257ENTRY(v4wb_cache_fns)
258 .long v4wb_flush_icache_all
247 .long v4wb_flush_kern_cache_all 259 .long v4wb_flush_kern_cache_all
248 .long v4wb_flush_user_cache_all 260 .long v4wb_flush_user_cache_all
249 .long v4wb_flush_user_cache_range 261 .long v4wb_flush_user_cache_range
diff --git a/arch/arm/mm/cache-v4wt.S b/arch/arm/mm/cache-v4wt.S
index 45c70312f43b..49c2b66cf3dd 100644
--- a/arch/arm/mm/cache-v4wt.S
+++ b/arch/arm/mm/cache-v4wt.S
@@ -41,6 +41,17 @@
41#define CACHE_DLIMIT 16384 41#define CACHE_DLIMIT 16384
42 42
43/* 43/*
44 * flush_icache_all()
45 *
46 * Unconditionally clean and invalidate the entire icache.
47 */
48ENTRY(v4wt_flush_icache_all)
49 mov r0, #0
50 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
51 mov pc, lr
52ENDPROC(v4wt_flush_icache_all)
53
54/*
44 * flush_user_cache_all() 55 * flush_user_cache_all()
45 * 56 *
46 * Invalidate all cache entries in a particular address 57 * Invalidate all cache entries in a particular address
@@ -188,6 +199,7 @@ ENDPROC(v4wt_dma_map_area)
188 199
189 .type v4wt_cache_fns, #object 200 .type v4wt_cache_fns, #object
190ENTRY(v4wt_cache_fns) 201ENTRY(v4wt_cache_fns)
202 .long v4wt_flush_icache_all
191 .long v4wt_flush_kern_cache_all 203 .long v4wt_flush_kern_cache_all
192 .long v4wt_flush_user_cache_all 204 .long v4wt_flush_user_cache_all
193 .long v4wt_flush_user_cache_range 205 .long v4wt_flush_user_cache_range
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index e4dd0646e859..ac6a36142fcd 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -198,7 +198,7 @@ __dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot)
198 * fragmentation of the DMA space, and also prevents allocations 198 * fragmentation of the DMA space, and also prevents allocations
199 * smaller than a section from crossing a section boundary. 199 * smaller than a section from crossing a section boundary.
200 */ 200 */
201 bit = fls(size - 1) + 1; 201 bit = fls(size - 1);
202 if (bit > SECTION_SHIFT) 202 if (bit > SECTION_SHIFT)
203 bit = SECTION_SHIFT; 203 bit = SECTION_SHIFT;
204 align = 1 << bit; 204 align = 1 << bit;
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 8440d952ba6d..83e59f870426 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -66,6 +66,30 @@ static int do_adjust_pte(struct vm_area_struct *vma, unsigned long address,
66 return ret; 66 return ret;
67} 67}
68 68
69#if USE_SPLIT_PTLOCKS
70/*
71 * If we are using split PTE locks, then we need to take the page
72 * lock here. Otherwise we are using shared mm->page_table_lock
73 * which is already locked, thus cannot take it.
74 */
75static inline void do_pte_lock(spinlock_t *ptl)
76{
77 /*
78 * Use nested version here to indicate that we are already
79 * holding one similar spinlock.
80 */
81 spin_lock_nested(ptl, SINGLE_DEPTH_NESTING);
82}
83
84static inline void do_pte_unlock(spinlock_t *ptl)
85{
86 spin_unlock(ptl);
87}
88#else /* !USE_SPLIT_PTLOCKS */
89static inline void do_pte_lock(spinlock_t *ptl) {}
90static inline void do_pte_unlock(spinlock_t *ptl) {}
91#endif /* USE_SPLIT_PTLOCKS */
92
69static int adjust_pte(struct vm_area_struct *vma, unsigned long address, 93static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
70 unsigned long pfn) 94 unsigned long pfn)
71{ 95{
@@ -89,13 +113,13 @@ static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
89 * open-code the spin-locking. 113 * open-code the spin-locking.
90 */ 114 */
91 ptl = pte_lockptr(vma->vm_mm, pmd); 115 ptl = pte_lockptr(vma->vm_mm, pmd);
92 pte = pte_offset_map_nested(pmd, address); 116 pte = pte_offset_map(pmd, address);
93 spin_lock(ptl); 117 do_pte_lock(ptl);
94 118
95 ret = do_adjust_pte(vma, address, pfn, pte); 119 ret = do_adjust_pte(vma, address, pfn, pte);
96 120
97 spin_unlock(ptl); 121 do_pte_unlock(ptl);
98 pte_unmap_nested(pte); 122 pte_unmap(pte);
99 123
100 return ret; 124 return ret;
101} 125}
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index 1fbdb55bfd1b..c435fd9e1da9 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -36,18 +36,17 @@ void kunmap(struct page *page)
36} 36}
37EXPORT_SYMBOL(kunmap); 37EXPORT_SYMBOL(kunmap);
38 38
39void *kmap_atomic(struct page *page, enum km_type type) 39void *__kmap_atomic(struct page *page)
40{ 40{
41 unsigned int idx; 41 unsigned int idx;
42 unsigned long vaddr; 42 unsigned long vaddr;
43 void *kmap; 43 void *kmap;
44 int type;
44 45
45 pagefault_disable(); 46 pagefault_disable();
46 if (!PageHighMem(page)) 47 if (!PageHighMem(page))
47 return page_address(page); 48 return page_address(page);
48 49
49 debug_kmap_atomic(type);
50
51#ifdef CONFIG_DEBUG_HIGHMEM 50#ifdef CONFIG_DEBUG_HIGHMEM
52 /* 51 /*
53 * There is no cache coherency issue when non VIVT, so force the 52 * There is no cache coherency issue when non VIVT, so force the
@@ -61,6 +60,8 @@ void *kmap_atomic(struct page *page, enum km_type type)
61 if (kmap) 60 if (kmap)
62 return kmap; 61 return kmap;
63 62
63 type = kmap_atomic_idx_push();
64
64 idx = type + KM_TYPE_NR * smp_processor_id(); 65 idx = type + KM_TYPE_NR * smp_processor_id();
65 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 66 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
66#ifdef CONFIG_DEBUG_HIGHMEM 67#ifdef CONFIG_DEBUG_HIGHMEM
@@ -80,14 +81,17 @@ void *kmap_atomic(struct page *page, enum km_type type)
80 81
81 return (void *)vaddr; 82 return (void *)vaddr;
82} 83}
83EXPORT_SYMBOL(kmap_atomic); 84EXPORT_SYMBOL(__kmap_atomic);
84 85
85void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 86void __kunmap_atomic(void *kvaddr)
86{ 87{
87 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 88 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
88 unsigned int idx = type + KM_TYPE_NR * smp_processor_id(); 89 int idx, type;
89 90
90 if (kvaddr >= (void *)FIXADDR_START) { 91 if (kvaddr >= (void *)FIXADDR_START) {
92 type = kmap_atomic_idx();
93 idx = type + KM_TYPE_NR * smp_processor_id();
94
91 if (cache_is_vivt()) 95 if (cache_is_vivt())
92 __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE); 96 __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
93#ifdef CONFIG_DEBUG_HIGHMEM 97#ifdef CONFIG_DEBUG_HIGHMEM
@@ -97,21 +101,23 @@ void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type)
97#else 101#else
98 (void) idx; /* to kill a warning */ 102 (void) idx; /* to kill a warning */
99#endif 103#endif
104 kmap_atomic_idx_pop();
100 } else if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) { 105 } else if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
101 /* this address was obtained through kmap_high_get() */ 106 /* this address was obtained through kmap_high_get() */
102 kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)])); 107 kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
103 } 108 }
104 pagefault_enable(); 109 pagefault_enable();
105} 110}
106EXPORT_SYMBOL(kunmap_atomic_notypecheck); 111EXPORT_SYMBOL(__kunmap_atomic);
107 112
108void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) 113void *kmap_atomic_pfn(unsigned long pfn)
109{ 114{
110 unsigned int idx;
111 unsigned long vaddr; 115 unsigned long vaddr;
116 int idx, type;
112 117
113 pagefault_disable(); 118 pagefault_disable();
114 119
120 type = kmap_atomic_idx_push();
115 idx = type + KM_TYPE_NR * smp_processor_id(); 121 idx = type + KM_TYPE_NR * smp_processor_id();
116 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 122 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
117#ifdef CONFIG_DEBUG_HIGHMEM 123#ifdef CONFIG_DEBUG_HIGHMEM
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 7fd9b5eb177f..5164069ced42 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -18,6 +18,7 @@
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/gfp.h> 19#include <linux/gfp.h>
20#include <linux/memblock.h> 20#include <linux/memblock.h>
21#include <linux/sort.h>
21 22
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/sections.h> 24#include <asm/sections.h>
@@ -121,9 +122,10 @@ void show_mem(void)
121 printk("%d pages swap cached\n", cached); 122 printk("%d pages swap cached\n", cached);
122} 123}
123 124
124static void __init find_limits(struct meminfo *mi, 125static void __init find_limits(unsigned long *min, unsigned long *max_low,
125 unsigned long *min, unsigned long *max_low, unsigned long *max_high) 126 unsigned long *max_high)
126{ 127{
128 struct meminfo *mi = &meminfo;
127 int i; 129 int i;
128 130
129 *min = -1UL; 131 *min = -1UL;
@@ -147,14 +149,13 @@ static void __init find_limits(struct meminfo *mi,
147 } 149 }
148} 150}
149 151
150static void __init arm_bootmem_init(struct meminfo *mi, 152static void __init arm_bootmem_init(unsigned long start_pfn,
151 unsigned long start_pfn, unsigned long end_pfn) 153 unsigned long end_pfn)
152{ 154{
153 struct memblock_region *reg; 155 struct memblock_region *reg;
154 unsigned int boot_pages; 156 unsigned int boot_pages;
155 phys_addr_t bitmap; 157 phys_addr_t bitmap;
156 pg_data_t *pgdat; 158 pg_data_t *pgdat;
157 int i;
158 159
159 /* 160 /*
160 * Allocate the bootmem bitmap page. This must be in a region 161 * Allocate the bootmem bitmap page. This must be in a region
@@ -172,30 +173,39 @@ static void __init arm_bootmem_init(struct meminfo *mi,
172 pgdat = NODE_DATA(0); 173 pgdat = NODE_DATA(0);
173 init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn); 174 init_bootmem_node(pgdat, __phys_to_pfn(bitmap), start_pfn, end_pfn);
174 175
175 for_each_bank(i, mi) { 176 /* Free the lowmem regions from memblock into bootmem. */
176 struct membank *bank = &mi->bank[i]; 177 for_each_memblock(memory, reg) {
177 if (!bank->highmem) 178 unsigned long start = memblock_region_memory_base_pfn(reg);
178 free_bootmem(bank_phys_start(bank), bank_phys_size(bank)); 179 unsigned long end = memblock_region_memory_end_pfn(reg);
180
181 if (end >= end_pfn)
182 end = end_pfn;
183 if (start >= end)
184 break;
185
186 free_bootmem(__pfn_to_phys(start), (end - start) << PAGE_SHIFT);
179 } 187 }
180 188
181 /* 189 /* Reserve the lowmem memblock reserved regions in bootmem. */
182 * Reserve the memblock reserved regions in bootmem.
183 */
184 for_each_memblock(reserved, reg) { 190 for_each_memblock(reserved, reg) {
185 phys_addr_t start = memblock_region_reserved_base_pfn(reg); 191 unsigned long start = memblock_region_reserved_base_pfn(reg);
186 phys_addr_t end = memblock_region_reserved_end_pfn(reg); 192 unsigned long end = memblock_region_reserved_end_pfn(reg);
187 if (start >= start_pfn && end <= end_pfn) 193
188 reserve_bootmem_node(pgdat, __pfn_to_phys(start), 194 if (end >= end_pfn)
189 (end - start) << PAGE_SHIFT, 195 end = end_pfn;
190 BOOTMEM_DEFAULT); 196 if (start >= end)
197 break;
198
199 reserve_bootmem(__pfn_to_phys(start),
200 (end - start) << PAGE_SHIFT, BOOTMEM_DEFAULT);
191 } 201 }
192} 202}
193 203
194static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min, 204static void __init arm_bootmem_free(unsigned long min, unsigned long max_low,
195 unsigned long max_low, unsigned long max_high) 205 unsigned long max_high)
196{ 206{
197 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; 207 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
198 int i; 208 struct memblock_region *reg;
199 209
200 /* 210 /*
201 * initialise the zones. 211 * initialise the zones.
@@ -217,13 +227,20 @@ static void __init arm_bootmem_free(struct meminfo *mi, unsigned long min,
217 * holes = node_size - sum(bank_sizes) 227 * holes = node_size - sum(bank_sizes)
218 */ 228 */
219 memcpy(zhole_size, zone_size, sizeof(zhole_size)); 229 memcpy(zhole_size, zone_size, sizeof(zhole_size));
220 for_each_bank(i, mi) { 230 for_each_memblock(memory, reg) {
221 int idx = 0; 231 unsigned long start = memblock_region_memory_base_pfn(reg);
232 unsigned long end = memblock_region_memory_end_pfn(reg);
233
234 if (start < max_low) {
235 unsigned long low_end = min(end, max_low);
236 zhole_size[0] -= low_end - start;
237 }
222#ifdef CONFIG_HIGHMEM 238#ifdef CONFIG_HIGHMEM
223 if (mi->bank[i].highmem) 239 if (end > max_low) {
224 idx = ZONE_HIGHMEM; 240 unsigned long high_start = max(start, max_low);
241 zhole_size[ZONE_HIGHMEM] -= end - high_start;
242 }
225#endif 243#endif
226 zhole_size[idx] -= bank_pfn_size(&mi->bank[i]);
227 } 244 }
228 245
229 /* 246 /*
@@ -256,10 +273,19 @@ static void arm_memory_present(void)
256} 273}
257#endif 274#endif
258 275
276static int __init meminfo_cmp(const void *_a, const void *_b)
277{
278 const struct membank *a = _a, *b = _b;
279 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
280 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
281}
282
259void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) 283void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
260{ 284{
261 int i; 285 int i;
262 286
287 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
288
263 memblock_init(); 289 memblock_init();
264 for (i = 0; i < mi->nr_banks; i++) 290 for (i = 0; i < mi->nr_banks; i++)
265 memblock_add(mi->bank[i].start, mi->bank[i].size); 291 memblock_add(mi->bank[i].start, mi->bank[i].size);
@@ -292,14 +318,13 @@ void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc)
292 318
293void __init bootmem_init(void) 319void __init bootmem_init(void)
294{ 320{
295 struct meminfo *mi = &meminfo;
296 unsigned long min, max_low, max_high; 321 unsigned long min, max_low, max_high;
297 322
298 max_low = max_high = 0; 323 max_low = max_high = 0;
299 324
300 find_limits(mi, &min, &max_low, &max_high); 325 find_limits(&min, &max_low, &max_high);
301 326
302 arm_bootmem_init(mi, min, max_low); 327 arm_bootmem_init(min, max_low);
303 328
304 /* 329 /*
305 * Sparsemem tries to allocate bootmem in memory_present(), 330 * Sparsemem tries to allocate bootmem in memory_present(),
@@ -317,7 +342,7 @@ void __init bootmem_init(void)
317 * the sparse mem_map arrays initialized by sparse_init() 342 * the sparse mem_map arrays initialized by sparse_init()
318 * for memmap_init_zone(), otherwise all PFNs are invalid. 343 * for memmap_init_zone(), otherwise all PFNs are invalid.
319 */ 344 */
320 arm_bootmem_free(mi, min, max_low, max_high); 345 arm_bootmem_free(min, max_low, max_high);
321 346
322 high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1; 347 high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
323 348
@@ -411,6 +436,56 @@ static void __init free_unused_memmap(struct meminfo *mi)
411 } 436 }
412} 437}
413 438
439static void __init free_highpages(void)
440{
441#ifdef CONFIG_HIGHMEM
442 unsigned long max_low = max_low_pfn + PHYS_PFN_OFFSET;
443 struct memblock_region *mem, *res;
444
445 /* set highmem page free */
446 for_each_memblock(memory, mem) {
447 unsigned long start = memblock_region_memory_base_pfn(mem);
448 unsigned long end = memblock_region_memory_end_pfn(mem);
449
450 /* Ignore complete lowmem entries */
451 if (end <= max_low)
452 continue;
453
454 /* Truncate partial highmem entries */
455 if (start < max_low)
456 start = max_low;
457
458 /* Find and exclude any reserved regions */
459 for_each_memblock(reserved, res) {
460 unsigned long res_start, res_end;
461
462 res_start = memblock_region_reserved_base_pfn(res);
463 res_end = memblock_region_reserved_end_pfn(res);
464
465 if (res_end < start)
466 continue;
467 if (res_start < start)
468 res_start = start;
469 if (res_start > end)
470 res_start = end;
471 if (res_end > end)
472 res_end = end;
473 if (res_start != start)
474 totalhigh_pages += free_area(start, res_start,
475 NULL);
476 start = res_end;
477 if (start == end)
478 break;
479 }
480
481 /* And now free anything which remains */
482 if (start < end)
483 totalhigh_pages += free_area(start, end, NULL);
484 }
485 totalram_pages += totalhigh_pages;
486#endif
487}
488
414/* 489/*
415 * mem_init() marks the free areas in the mem_map and tells us how much 490 * mem_init() marks the free areas in the mem_map and tells us how much
416 * memory is free. This is done after various parts of the system have 491 * memory is free. This is done after various parts of the system have
@@ -419,6 +494,7 @@ static void __init free_unused_memmap(struct meminfo *mi)
419void __init mem_init(void) 494void __init mem_init(void)
420{ 495{
421 unsigned long reserved_pages, free_pages; 496 unsigned long reserved_pages, free_pages;
497 struct memblock_region *reg;
422 int i; 498 int i;
423#ifdef CONFIG_HAVE_TCM 499#ifdef CONFIG_HAVE_TCM
424 /* These pointers are filled in on TCM detection */ 500 /* These pointers are filled in on TCM detection */
@@ -439,16 +515,7 @@ void __init mem_init(void)
439 __phys_to_pfn(__pa(swapper_pg_dir)), NULL); 515 __phys_to_pfn(__pa(swapper_pg_dir)), NULL);
440#endif 516#endif
441 517
442#ifdef CONFIG_HIGHMEM 518 free_highpages();
443 /* set highmem page free */
444 for_each_bank (i, &meminfo) {
445 unsigned long start = bank_pfn_start(&meminfo.bank[i]);
446 unsigned long end = bank_pfn_end(&meminfo.bank[i]);
447 if (start >= max_low_pfn + PHYS_PFN_OFFSET)
448 totalhigh_pages += free_area(start, end, NULL);
449 }
450 totalram_pages += totalhigh_pages;
451#endif
452 519
453 reserved_pages = free_pages = 0; 520 reserved_pages = free_pages = 0;
454 521
@@ -478,9 +545,11 @@ void __init mem_init(void)
478 */ 545 */
479 printk(KERN_INFO "Memory:"); 546 printk(KERN_INFO "Memory:");
480 num_physpages = 0; 547 num_physpages = 0;
481 for (i = 0; i < meminfo.nr_banks; i++) { 548 for_each_memblock(memory, reg) {
482 num_physpages += bank_pfn_size(&meminfo.bank[i]); 549 unsigned long pages = memblock_region_memory_end_pfn(reg) -
483 printk(" %ldMB", bank_phys_size(&meminfo.bank[i]) >> 20); 550 memblock_region_memory_base_pfn(reg);
551 num_physpages += pages;
552 printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
484 } 553 }
485 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT)); 554 printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
486 555
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index c32f731d56d3..72ad3e1f56cf 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -14,7 +14,6 @@
14#include <linux/mman.h> 14#include <linux/mman.h>
15#include <linux/nodemask.h> 15#include <linux/nodemask.h>
16#include <linux/memblock.h> 16#include <linux/memblock.h>
17#include <linux/sort.h>
18#include <linux/fs.h> 17#include <linux/fs.h>
19 18
20#include <asm/cputype.h> 19#include <asm/cputype.h>
@@ -265,17 +264,17 @@ static struct mem_type mem_types[] = {
265 .domain = DOMAIN_KERNEL, 264 .domain = DOMAIN_KERNEL,
266 }, 265 },
267 [MT_MEMORY_DTCM] = { 266 [MT_MEMORY_DTCM] = {
268 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | 267 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
269 L_PTE_DIRTY | L_PTE_WRITE, 268 L_PTE_WRITE,
270 .prot_l1 = PMD_TYPE_TABLE, 269 .prot_l1 = PMD_TYPE_TABLE,
271 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN, 270 .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
272 .domain = DOMAIN_KERNEL, 271 .domain = DOMAIN_KERNEL,
273 }, 272 },
274 [MT_MEMORY_ITCM] = { 273 [MT_MEMORY_ITCM] = {
275 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | 274 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
276 L_PTE_USER | L_PTE_EXEC, 275 L_PTE_WRITE | L_PTE_EXEC,
277 .prot_l1 = PMD_TYPE_TABLE, 276 .prot_l1 = PMD_TYPE_TABLE,
278 .domain = DOMAIN_IO, 277 .domain = DOMAIN_KERNEL,
279 }, 278 },
280}; 279};
281 280
@@ -745,13 +744,14 @@ static int __init early_vmalloc(char *arg)
745} 744}
746early_param("vmalloc", early_vmalloc); 745early_param("vmalloc", early_vmalloc);
747 746
748phys_addr_t lowmem_end_addr; 747static phys_addr_t lowmem_limit __initdata = 0;
749 748
750static void __init sanity_check_meminfo(void) 749static void __init sanity_check_meminfo(void)
751{ 750{
752 int i, j, highmem = 0; 751 int i, j, highmem = 0;
753 752
754 lowmem_end_addr = __pa(vmalloc_min - 1) + 1; 753 lowmem_limit = __pa(vmalloc_min - 1) + 1;
754 memblock_set_current_limit(lowmem_limit);
755 755
756 for (i = 0, j = 0; i < meminfo.nr_banks; i++) { 756 for (i = 0, j = 0; i < meminfo.nr_banks; i++) {
757 struct membank *bank = &meminfo.bank[j]; 757 struct membank *bank = &meminfo.bank[j];
@@ -852,6 +852,7 @@ static void __init sanity_check_meminfo(void)
852static inline void prepare_page_table(void) 852static inline void prepare_page_table(void)
853{ 853{
854 unsigned long addr; 854 unsigned long addr;
855 phys_addr_t end;
855 856
856 /* 857 /*
857 * Clear out all the mappings below the kernel image. 858 * Clear out all the mappings below the kernel image.
@@ -867,10 +868,17 @@ static inline void prepare_page_table(void)
867 pmd_clear(pmd_off_k(addr)); 868 pmd_clear(pmd_off_k(addr));
868 869
869 /* 870 /*
871 * Find the end of the first block of lowmem.
872 */
873 end = memblock.memory.regions[0].base + memblock.memory.regions[0].size;
874 if (end >= lowmem_limit)
875 end = lowmem_limit;
876
877 /*
870 * Clear out all the kernel space mappings, except for the first 878 * Clear out all the kernel space mappings, except for the first
871 * memory bank, up to the end of the vmalloc region. 879 * memory bank, up to the end of the vmalloc region.
872 */ 880 */
873 for (addr = __phys_to_virt(bank_phys_end(&meminfo.bank[0])); 881 for (addr = __phys_to_virt(end);
874 addr < VMALLOC_END; addr += PGDIR_SIZE) 882 addr < VMALLOC_END; addr += PGDIR_SIZE)
875 pmd_clear(pmd_off_k(addr)); 883 pmd_clear(pmd_off_k(addr));
876} 884}
@@ -987,37 +995,28 @@ static void __init kmap_init(void)
987#endif 995#endif
988} 996}
989 997
990static inline void map_memory_bank(struct membank *bank)
991{
992 struct map_desc map;
993
994 map.pfn = bank_pfn_start(bank);
995 map.virtual = __phys_to_virt(bank_phys_start(bank));
996 map.length = bank_phys_size(bank);
997 map.type = MT_MEMORY;
998
999 create_mapping(&map);
1000}
1001
1002static void __init map_lowmem(void) 998static void __init map_lowmem(void)
1003{ 999{
1004 struct meminfo *mi = &meminfo; 1000 struct memblock_region *reg;
1005 int i;
1006 1001
1007 /* Map all the lowmem memory banks. */ 1002 /* Map all the lowmem memory banks. */
1008 for (i = 0; i < mi->nr_banks; i++) { 1003 for_each_memblock(memory, reg) {
1009 struct membank *bank = &mi->bank[i]; 1004 phys_addr_t start = reg->base;
1005 phys_addr_t end = start + reg->size;
1006 struct map_desc map;
1007
1008 if (end > lowmem_limit)
1009 end = lowmem_limit;
1010 if (start >= end)
1011 break;
1010 1012
1011 if (!bank->highmem) 1013 map.pfn = __phys_to_pfn(start);
1012 map_memory_bank(bank); 1014 map.virtual = __phys_to_virt(start);
1013 } 1015 map.length = end - start;
1014} 1016 map.type = MT_MEMORY;
1015 1017
1016static int __init meminfo_cmp(const void *_a, const void *_b) 1018 create_mapping(&map);
1017{ 1019 }
1018 const struct membank *a = _a, *b = _b;
1019 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
1020 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
1021} 1020}
1022 1021
1023/* 1022/*
@@ -1028,8 +1027,6 @@ void __init paging_init(struct machine_desc *mdesc)
1028{ 1027{
1029 void *zero_page; 1028 void *zero_page;
1030 1029
1031 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
1032
1033 build_mem_type_table(); 1030 build_mem_type_table();
1034 sanity_check_meminfo(); 1031 sanity_check_meminfo();
1035 prepare_page_table(); 1032 prepare_page_table();
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c
index be5f58e153bf..69bbfc6645a6 100644
--- a/arch/arm/mm/pgd.c
+++ b/arch/arm/mm/pgd.c
@@ -57,9 +57,9 @@ pgd_t *get_pgd_slow(struct mm_struct *mm)
57 goto no_pte; 57 goto no_pte;
58 58
59 init_pmd = pmd_offset(init_pgd, 0); 59 init_pmd = pmd_offset(init_pgd, 0);
60 init_pte = pte_offset_map_nested(init_pmd, 0); 60 init_pte = pte_offset_map(init_pmd, 0);
61 set_pte_ext(new_pte, *init_pte, 0); 61 set_pte_ext(new_pte, *init_pte, 0);
62 pte_unmap_nested(init_pte); 62 pte_unmap(init_pte);
63 pte_unmap(new_pte); 63 pte_unmap(new_pte);
64 } 64 }
65 65
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index a6f5f8475b96..bcf748d9f4e2 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -119,6 +119,20 @@ ENTRY(cpu_arm1020_do_idle)
119/* ================================= CACHE ================================ */ 119/* ================================= CACHE ================================ */
120 120
121 .align 5 121 .align 5
122
123/*
124 * flush_icache_all()
125 *
126 * Unconditionally clean and invalidate the entire icache.
127 */
128ENTRY(arm1020_flush_icache_all)
129#ifndef CONFIG_CPU_ICACHE_DISABLE
130 mov r0, #0
131 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
132#endif
133 mov pc, lr
134ENDPROC(arm1020_flush_icache_all)
135
122/* 136/*
123 * flush_user_cache_all() 137 * flush_user_cache_all()
124 * 138 *
@@ -351,6 +365,7 @@ ENTRY(arm1020_dma_unmap_area)
351ENDPROC(arm1020_dma_unmap_area) 365ENDPROC(arm1020_dma_unmap_area)
352 366
353ENTRY(arm1020_cache_fns) 367ENTRY(arm1020_cache_fns)
368 .long arm1020_flush_icache_all
354 .long arm1020_flush_kern_cache_all 369 .long arm1020_flush_kern_cache_all
355 .long arm1020_flush_user_cache_all 370 .long arm1020_flush_user_cache_all
356 .long arm1020_flush_user_cache_range 371 .long arm1020_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index afc06b9c3133..ab7ec26657ea 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -119,6 +119,20 @@ ENTRY(cpu_arm1020e_do_idle)
119/* ================================= CACHE ================================ */ 119/* ================================= CACHE ================================ */
120 120
121 .align 5 121 .align 5
122
123/*
124 * flush_icache_all()
125 *
126 * Unconditionally clean and invalidate the entire icache.
127 */
128ENTRY(arm1020e_flush_icache_all)
129#ifndef CONFIG_CPU_ICACHE_DISABLE
130 mov r0, #0
131 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
132#endif
133 mov pc, lr
134ENDPROC(arm1020e_flush_icache_all)
135
122/* 136/*
123 * flush_user_cache_all() 137 * flush_user_cache_all()
124 * 138 *
@@ -337,6 +351,7 @@ ENTRY(arm1020e_dma_unmap_area)
337ENDPROC(arm1020e_dma_unmap_area) 351ENDPROC(arm1020e_dma_unmap_area)
338 352
339ENTRY(arm1020e_cache_fns) 353ENTRY(arm1020e_cache_fns)
354 .long arm1020e_flush_icache_all
340 .long arm1020e_flush_kern_cache_all 355 .long arm1020e_flush_kern_cache_all
341 .long arm1020e_flush_user_cache_all 356 .long arm1020e_flush_user_cache_all
342 .long arm1020e_flush_user_cache_range 357 .long arm1020e_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm1022.S b/arch/arm/mm/proc-arm1022.S
index 8915e0ba3fe5..831c5e54e22f 100644
--- a/arch/arm/mm/proc-arm1022.S
+++ b/arch/arm/mm/proc-arm1022.S
@@ -108,6 +108,20 @@ ENTRY(cpu_arm1022_do_idle)
108/* ================================= CACHE ================================ */ 108/* ================================= CACHE ================================ */
109 109
110 .align 5 110 .align 5
111
112/*
113 * flush_icache_all()
114 *
115 * Unconditionally clean and invalidate the entire icache.
116 */
117ENTRY(arm1022_flush_icache_all)
118#ifndef CONFIG_CPU_ICACHE_DISABLE
119 mov r0, #0
120 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
121#endif
122 mov pc, lr
123ENDPROC(arm1022_flush_icache_all)
124
111/* 125/*
112 * flush_user_cache_all() 126 * flush_user_cache_all()
113 * 127 *
@@ -326,6 +340,7 @@ ENTRY(arm1022_dma_unmap_area)
326ENDPROC(arm1022_dma_unmap_area) 340ENDPROC(arm1022_dma_unmap_area)
327 341
328ENTRY(arm1022_cache_fns) 342ENTRY(arm1022_cache_fns)
343 .long arm1022_flush_icache_all
329 .long arm1022_flush_kern_cache_all 344 .long arm1022_flush_kern_cache_all
330 .long arm1022_flush_user_cache_all 345 .long arm1022_flush_user_cache_all
331 .long arm1022_flush_user_cache_range 346 .long arm1022_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm1026.S b/arch/arm/mm/proc-arm1026.S
index ff446c5d476f..e3f7e9a166bf 100644
--- a/arch/arm/mm/proc-arm1026.S
+++ b/arch/arm/mm/proc-arm1026.S
@@ -108,6 +108,20 @@ ENTRY(cpu_arm1026_do_idle)
108/* ================================= CACHE ================================ */ 108/* ================================= CACHE ================================ */
109 109
110 .align 5 110 .align 5
111
112/*
113 * flush_icache_all()
114 *
115 * Unconditionally clean and invalidate the entire icache.
116 */
117ENTRY(arm1026_flush_icache_all)
118#ifndef CONFIG_CPU_ICACHE_DISABLE
119 mov r0, #0
120 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
121#endif
122 mov pc, lr
123ENDPROC(arm1026_flush_icache_all)
124
111/* 125/*
112 * flush_user_cache_all() 126 * flush_user_cache_all()
113 * 127 *
@@ -320,6 +334,7 @@ ENTRY(arm1026_dma_unmap_area)
320ENDPROC(arm1026_dma_unmap_area) 334ENDPROC(arm1026_dma_unmap_area)
321 335
322ENTRY(arm1026_cache_fns) 336ENTRY(arm1026_cache_fns)
337 .long arm1026_flush_icache_all
323 .long arm1026_flush_kern_cache_all 338 .long arm1026_flush_kern_cache_all
324 .long arm1026_flush_user_cache_all 339 .long arm1026_flush_user_cache_all
325 .long arm1026_flush_user_cache_range 340 .long arm1026_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index fecf570939f3..6109f278a904 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -110,6 +110,17 @@ ENTRY(cpu_arm920_do_idle)
110#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH 110#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
111 111
112/* 112/*
113 * flush_icache_all()
114 *
115 * Unconditionally clean and invalidate the entire icache.
116 */
117ENTRY(arm920_flush_icache_all)
118 mov r0, #0
119 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
120 mov pc, lr
121ENDPROC(arm920_flush_icache_all)
122
123/*
113 * flush_user_cache_all() 124 * flush_user_cache_all()
114 * 125 *
115 * Invalidate all cache entries in a particular address 126 * Invalidate all cache entries in a particular address
@@ -305,6 +316,7 @@ ENTRY(arm920_dma_unmap_area)
305ENDPROC(arm920_dma_unmap_area) 316ENDPROC(arm920_dma_unmap_area)
306 317
307ENTRY(arm920_cache_fns) 318ENTRY(arm920_cache_fns)
319 .long arm920_flush_icache_all
308 .long arm920_flush_kern_cache_all 320 .long arm920_flush_kern_cache_all
309 .long arm920_flush_user_cache_all 321 .long arm920_flush_user_cache_all
310 .long arm920_flush_user_cache_range 322 .long arm920_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index e3cbf87c9480..bb2f0f46a5e6 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -112,6 +112,17 @@ ENTRY(cpu_arm922_do_idle)
112#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH 112#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
113 113
114/* 114/*
115 * flush_icache_all()
116 *
117 * Unconditionally clean and invalidate the entire icache.
118 */
119ENTRY(arm922_flush_icache_all)
120 mov r0, #0
121 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
122 mov pc, lr
123ENDPROC(arm922_flush_icache_all)
124
125/*
115 * flush_user_cache_all() 126 * flush_user_cache_all()
116 * 127 *
117 * Clean and invalidate all cache entries in a particular 128 * Clean and invalidate all cache entries in a particular
@@ -307,6 +318,7 @@ ENTRY(arm922_dma_unmap_area)
307ENDPROC(arm922_dma_unmap_area) 318ENDPROC(arm922_dma_unmap_area)
308 319
309ENTRY(arm922_cache_fns) 320ENTRY(arm922_cache_fns)
321 .long arm922_flush_icache_all
310 .long arm922_flush_kern_cache_all 322 .long arm922_flush_kern_cache_all
311 .long arm922_flush_user_cache_all 323 .long arm922_flush_user_cache_all
312 .long arm922_flush_user_cache_range 324 .long arm922_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index 572424c867b5..c13e01accfe2 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -145,6 +145,17 @@ ENTRY(cpu_arm925_do_idle)
145 mov pc, lr 145 mov pc, lr
146 146
147/* 147/*
148 * flush_icache_all()
149 *
150 * Unconditionally clean and invalidate the entire icache.
151 */
152ENTRY(arm925_flush_icache_all)
153 mov r0, #0
154 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
155 mov pc, lr
156ENDPROC(arm925_flush_icache_all)
157
158/*
148 * flush_user_cache_all() 159 * flush_user_cache_all()
149 * 160 *
150 * Clean and invalidate all cache entries in a particular 161 * Clean and invalidate all cache entries in a particular
@@ -362,6 +373,7 @@ ENTRY(arm925_dma_unmap_area)
362ENDPROC(arm925_dma_unmap_area) 373ENDPROC(arm925_dma_unmap_area)
363 374
364ENTRY(arm925_cache_fns) 375ENTRY(arm925_cache_fns)
376 .long arm925_flush_icache_all
365 .long arm925_flush_kern_cache_all 377 .long arm925_flush_kern_cache_all
366 .long arm925_flush_user_cache_all 378 .long arm925_flush_user_cache_all
367 .long arm925_flush_user_cache_range 379 .long arm925_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 63d168b4ebe6..42eb4315740b 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -111,6 +111,17 @@ ENTRY(cpu_arm926_do_idle)
111 mov pc, lr 111 mov pc, lr
112 112
113/* 113/*
114 * flush_icache_all()
115 *
116 * Unconditionally clean and invalidate the entire icache.
117 */
118ENTRY(arm926_flush_icache_all)
119 mov r0, #0
120 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
121 mov pc, lr
122ENDPROC(arm926_flush_icache_all)
123
124/*
114 * flush_user_cache_all() 125 * flush_user_cache_all()
115 * 126 *
116 * Clean and invalidate all cache entries in a particular 127 * Clean and invalidate all cache entries in a particular
@@ -325,6 +336,7 @@ ENTRY(arm926_dma_unmap_area)
325ENDPROC(arm926_dma_unmap_area) 336ENDPROC(arm926_dma_unmap_area)
326 337
327ENTRY(arm926_cache_fns) 338ENTRY(arm926_cache_fns)
339 .long arm926_flush_icache_all
328 .long arm926_flush_kern_cache_all 340 .long arm926_flush_kern_cache_all
329 .long arm926_flush_user_cache_all 341 .long arm926_flush_user_cache_all
330 .long arm926_flush_user_cache_range 342 .long arm926_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm940.S b/arch/arm/mm/proc-arm940.S
index f6a62822418e..7b11cdb9935f 100644
--- a/arch/arm/mm/proc-arm940.S
+++ b/arch/arm/mm/proc-arm940.S
@@ -68,6 +68,17 @@ ENTRY(cpu_arm940_do_idle)
68 mov pc, lr 68 mov pc, lr
69 69
70/* 70/*
71 * flush_icache_all()
72 *
73 * Unconditionally clean and invalidate the entire icache.
74 */
75ENTRY(arm940_flush_icache_all)
76 mov r0, #0
77 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
78 mov pc, lr
79ENDPROC(arm940_flush_icache_all)
80
81/*
71 * flush_user_cache_all() 82 * flush_user_cache_all()
72 */ 83 */
73ENTRY(arm940_flush_user_cache_all) 84ENTRY(arm940_flush_user_cache_all)
@@ -254,6 +265,7 @@ ENTRY(arm940_dma_unmap_area)
254ENDPROC(arm940_dma_unmap_area) 265ENDPROC(arm940_dma_unmap_area)
255 266
256ENTRY(arm940_cache_fns) 267ENTRY(arm940_cache_fns)
268 .long arm940_flush_icache_all
257 .long arm940_flush_kern_cache_all 269 .long arm940_flush_kern_cache_all
258 .long arm940_flush_user_cache_all 270 .long arm940_flush_user_cache_all
259 .long arm940_flush_user_cache_range 271 .long arm940_flush_user_cache_range
diff --git a/arch/arm/mm/proc-arm946.S b/arch/arm/mm/proc-arm946.S
index ea2e7f2eb95b..1a5bbf080342 100644
--- a/arch/arm/mm/proc-arm946.S
+++ b/arch/arm/mm/proc-arm946.S
@@ -75,6 +75,17 @@ ENTRY(cpu_arm946_do_idle)
75 mov pc, lr 75 mov pc, lr
76 76
77/* 77/*
78 * flush_icache_all()
79 *
80 * Unconditionally clean and invalidate the entire icache.
81 */
82ENTRY(arm946_flush_icache_all)
83 mov r0, #0
84 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
85 mov pc, lr
86ENDPROC(arm946_flush_icache_all)
87
88/*
78 * flush_user_cache_all() 89 * flush_user_cache_all()
79 */ 90 */
80ENTRY(arm946_flush_user_cache_all) 91ENTRY(arm946_flush_user_cache_all)
@@ -296,6 +307,7 @@ ENTRY(arm946_dma_unmap_area)
296ENDPROC(arm946_dma_unmap_area) 307ENDPROC(arm946_dma_unmap_area)
297 308
298ENTRY(arm946_cache_fns) 309ENTRY(arm946_cache_fns)
310 .long arm946_flush_icache_all
299 .long arm946_flush_kern_cache_all 311 .long arm946_flush_kern_cache_all
300 .long arm946_flush_user_cache_all 312 .long arm946_flush_user_cache_all
301 .long arm946_flush_user_cache_range 313 .long arm946_flush_user_cache_range
diff --git a/arch/arm/mm/proc-feroceon.S b/arch/arm/mm/proc-feroceon.S
index 578da69200cf..b4597edbff97 100644
--- a/arch/arm/mm/proc-feroceon.S
+++ b/arch/arm/mm/proc-feroceon.S
@@ -124,6 +124,17 @@ ENTRY(cpu_feroceon_do_idle)
124 mov pc, lr 124 mov pc, lr
125 125
126/* 126/*
127 * flush_icache_all()
128 *
129 * Unconditionally clean and invalidate the entire icache.
130 */
131ENTRY(feroceon_flush_icache_all)
132 mov r0, #0
133 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
134 mov pc, lr
135ENDPROC(feroceon_flush_icache_all)
136
137/*
127 * flush_user_cache_all() 138 * flush_user_cache_all()
128 * 139 *
129 * Clean and invalidate all cache entries in a particular 140 * Clean and invalidate all cache entries in a particular
@@ -401,6 +412,7 @@ ENTRY(feroceon_dma_unmap_area)
401ENDPROC(feroceon_dma_unmap_area) 412ENDPROC(feroceon_dma_unmap_area)
402 413
403ENTRY(feroceon_cache_fns) 414ENTRY(feroceon_cache_fns)
415 .long feroceon_flush_icache_all
404 .long feroceon_flush_kern_cache_all 416 .long feroceon_flush_kern_cache_all
405 .long feroceon_flush_user_cache_all 417 .long feroceon_flush_user_cache_all
406 .long feroceon_flush_user_cache_range 418 .long feroceon_flush_user_cache_range
@@ -412,6 +424,7 @@ ENTRY(feroceon_cache_fns)
412 .long feroceon_dma_flush_range 424 .long feroceon_dma_flush_range
413 425
414ENTRY(feroceon_range_cache_fns) 426ENTRY(feroceon_range_cache_fns)
427 .long feroceon_flush_icache_all
415 .long feroceon_flush_kern_cache_all 428 .long feroceon_flush_kern_cache_all
416 .long feroceon_flush_user_cache_all 429 .long feroceon_flush_user_cache_all
417 .long feroceon_flush_user_cache_range 430 .long feroceon_flush_user_cache_range
diff --git a/arch/arm/mm/proc-xsc3.S b/arch/arm/mm/proc-xsc3.S
index cad07e403044..ec26355cb7c2 100644
--- a/arch/arm/mm/proc-xsc3.S
+++ b/arch/arm/mm/proc-xsc3.S
@@ -141,6 +141,17 @@ ENTRY(cpu_xsc3_do_idle)
141/* ================================= CACHE ================================ */ 141/* ================================= CACHE ================================ */
142 142
143/* 143/*
144 * flush_icache_all()
145 *
146 * Unconditionally clean and invalidate the entire icache.
147 */
148ENTRY(xsc3_flush_icache_all)
149 mov r0, #0
150 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
151 mov pc, lr
152ENDPROC(xsc3_flush_icache_all)
153
154/*
144 * flush_user_cache_all() 155 * flush_user_cache_all()
145 * 156 *
146 * Invalidate all cache entries in a particular address 157 * Invalidate all cache entries in a particular address
@@ -325,6 +336,7 @@ ENTRY(xsc3_dma_unmap_area)
325ENDPROC(xsc3_dma_unmap_area) 336ENDPROC(xsc3_dma_unmap_area)
326 337
327ENTRY(xsc3_cache_fns) 338ENTRY(xsc3_cache_fns)
339 .long xsc3_flush_icache_all
328 .long xsc3_flush_kern_cache_all 340 .long xsc3_flush_kern_cache_all
329 .long xsc3_flush_user_cache_all 341 .long xsc3_flush_user_cache_all
330 .long xsc3_flush_user_cache_range 342 .long xsc3_flush_user_cache_range
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index cb245edb2c2b..523408c0bb38 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -181,6 +181,17 @@ ENTRY(cpu_xscale_do_idle)
181/* ================================= CACHE ================================ */ 181/* ================================= CACHE ================================ */
182 182
183/* 183/*
184 * flush_icache_all()
185 *
186 * Unconditionally clean and invalidate the entire icache.
187 */
188ENTRY(xscale_flush_icache_all)
189 mov r0, #0
190 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
191 mov pc, lr
192ENDPROC(xscale_flush_icache_all)
193
194/*
184 * flush_user_cache_all() 195 * flush_user_cache_all()
185 * 196 *
186 * Invalidate all cache entries in a particular address 197 * Invalidate all cache entries in a particular address
@@ -397,6 +408,7 @@ ENTRY(xscale_dma_unmap_area)
397ENDPROC(xscale_dma_unmap_area) 408ENDPROC(xscale_dma_unmap_area)
398 409
399ENTRY(xscale_cache_fns) 410ENTRY(xscale_cache_fns)
411 .long xscale_flush_icache_all
400 .long xscale_flush_kern_cache_all 412 .long xscale_flush_kern_cache_all
401 .long xscale_flush_user_cache_all 413 .long xscale_flush_user_cache_all
402 .long xscale_flush_user_cache_range 414 .long xscale_flush_user_cache_range
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/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
index 06875b4dd70f..372670952789 100644
--- a/arch/arm/plat-mxc/Makefile
+++ b/arch/arm/plat-mxc/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_MXC_USE_EPIT) += epit.o
18obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o 18obj-$(CONFIG_ARCH_MXC_AUDMUX_V1) += audmux-v1.o
19obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o 19obj-$(CONFIG_ARCH_MXC_AUDMUX_V2) += audmux-v2.o
20obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o 20obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
21obj-$(CONFIG_CPU_FREQ_IMX) += cpufreq.o
21ifdef CONFIG_SND_IMX_SOC 22ifdef CONFIG_SND_IMX_SOC
22obj-y += ssi-fiq.o 23obj-y += ssi-fiq.o
23obj-y += ssi-fiq-ksym.o 24obj-y += ssi-fiq-ksym.o
diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index 62920490c0d6..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)
diff --git a/arch/arm/plat-mxc/cpufreq.c b/arch/arm/plat-mxc/cpufreq.c
new file mode 100644
index 000000000000..039538e68793
--- /dev/null
+++ b/arch/arm/plat-mxc/cpufreq.c
@@ -0,0 +1,206 @@
1/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * The code contained herein is licensed under the GNU General Public
7 * License. You may obtain a copy of the GNU General Public License
8 * Version 2 or later at the following locations:
9 *
10 * http://www.opensource.org/licenses/gpl-license.html
11 * http://www.gnu.org/copyleft/gpl.html
12 */
13
14/*
15 * A driver for the Freescale Semiconductor i.MXC CPUfreq module.
16 * The CPUFREQ driver is for controling CPU frequency. It allows you to change
17 * the CPU clock speed on the fly.
18 */
19
20#include <linux/cpufreq.h>
21#include <linux/clk.h>
22#include <linux/err.h>
23#include <linux/slab.h>
24#include <mach/hardware.h>
25#include <mach/clock.h>
26
27#define CLK32_FREQ 32768
28#define NANOSECOND (1000 * 1000 * 1000)
29
30struct cpu_op *(*get_cpu_op)(int *op);
31
32static int cpu_freq_khz_min;
33static int cpu_freq_khz_max;
34
35static struct clk *cpu_clk;
36static struct cpufreq_frequency_table *imx_freq_table;
37
38static int cpu_op_nr;
39static struct cpu_op *cpu_op_tbl;
40
41static int set_cpu_freq(int freq)
42{
43 int ret = 0;
44 int org_cpu_rate;
45
46 org_cpu_rate = clk_get_rate(cpu_clk);
47 if (org_cpu_rate == freq)
48 return ret;
49
50 ret = clk_set_rate(cpu_clk, freq);
51 if (ret != 0) {
52 printk(KERN_DEBUG "cannot set CPU clock rate\n");
53 return ret;
54 }
55
56 return ret;
57}
58
59static int mxc_verify_speed(struct cpufreq_policy *policy)
60{
61 if (policy->cpu != 0)
62 return -EINVAL;
63
64 return cpufreq_frequency_table_verify(policy, imx_freq_table);
65}
66
67static unsigned int mxc_get_speed(unsigned int cpu)
68{
69 if (cpu)
70 return 0;
71
72 return clk_get_rate(cpu_clk) / 1000;
73}
74
75static int mxc_set_target(struct cpufreq_policy *policy,
76 unsigned int target_freq, unsigned int relation)
77{
78 struct cpufreq_freqs freqs;
79 int freq_Hz;
80 int ret = 0;
81 unsigned int index;
82
83 cpufreq_frequency_table_target(policy, imx_freq_table,
84 target_freq, relation, &index);
85 freq_Hz = imx_freq_table[index].frequency * 1000;
86
87 freqs.old = clk_get_rate(cpu_clk) / 1000;
88 freqs.new = freq_Hz / 1000;
89 freqs.cpu = 0;
90 freqs.flags = 0;
91 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
92
93 ret = set_cpu_freq(freq_Hz);
94
95 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
96
97 return ret;
98}
99
100static int __init mxc_cpufreq_init(struct cpufreq_policy *policy)
101{
102 int ret;
103 int i;
104
105 printk(KERN_INFO "i.MXC CPU frequency driver\n");
106
107 if (policy->cpu != 0)
108 return -EINVAL;
109
110 if (!get_cpu_op)
111 return -EINVAL;
112
113 cpu_clk = clk_get(NULL, "cpu_clk");
114 if (IS_ERR(cpu_clk)) {
115 printk(KERN_ERR "%s: failed to get cpu clock\n", __func__);
116 return PTR_ERR(cpu_clk);
117 }
118
119 cpu_op_tbl = get_cpu_op(&cpu_op_nr);
120
121 cpu_freq_khz_min = cpu_op_tbl[0].cpu_rate / 1000;
122 cpu_freq_khz_max = cpu_op_tbl[0].cpu_rate / 1000;
123
124 imx_freq_table = kmalloc(
125 sizeof(struct cpufreq_frequency_table) * (cpu_op_nr + 1),
126 GFP_KERNEL);
127 if (!imx_freq_table) {
128 ret = -ENOMEM;
129 goto err1;
130 }
131
132 for (i = 0; i < cpu_op_nr; i++) {
133 imx_freq_table[i].index = i;
134 imx_freq_table[i].frequency = cpu_op_tbl[i].cpu_rate / 1000;
135
136 if ((cpu_op_tbl[i].cpu_rate / 1000) < cpu_freq_khz_min)
137 cpu_freq_khz_min = cpu_op_tbl[i].cpu_rate / 1000;
138
139 if ((cpu_op_tbl[i].cpu_rate / 1000) > cpu_freq_khz_max)
140 cpu_freq_khz_max = cpu_op_tbl[i].cpu_rate / 1000;
141 }
142
143 imx_freq_table[i].index = i;
144 imx_freq_table[i].frequency = CPUFREQ_TABLE_END;
145
146 policy->cur = clk_get_rate(cpu_clk) / 1000;
147 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
148 policy->min = policy->cpuinfo.min_freq = cpu_freq_khz_min;
149 policy->max = policy->cpuinfo.max_freq = cpu_freq_khz_max;
150
151 /* Manual states, that PLL stabilizes in two CLK32 periods */
152 policy->cpuinfo.transition_latency = 2 * NANOSECOND / CLK32_FREQ;
153
154 ret = cpufreq_frequency_table_cpuinfo(policy, imx_freq_table);
155
156 if (ret < 0) {
157 printk(KERN_ERR "%s: failed to register i.MXC CPUfreq \
158 with error code %d\n", __func__, ret);
159 goto err;
160 }
161
162 cpufreq_frequency_table_get_attr(imx_freq_table, policy->cpu);
163 return 0;
164err:
165 kfree(imx_freq_table);
166err1:
167 clk_put(cpu_clk);
168 return ret;
169}
170
171static int mxc_cpufreq_exit(struct cpufreq_policy *policy)
172{
173 cpufreq_frequency_table_put_attr(policy->cpu);
174
175 set_cpu_freq(cpu_freq_khz_max * 1000);
176 clk_put(cpu_clk);
177 kfree(imx_freq_table);
178 return 0;
179}
180
181static struct cpufreq_driver mxc_driver = {
182 .flags = CPUFREQ_STICKY,
183 .verify = mxc_verify_speed,
184 .target = mxc_set_target,
185 .get = mxc_get_speed,
186 .init = mxc_cpufreq_init,
187 .exit = mxc_cpufreq_exit,
188 .name = "imx",
189};
190
191static int __devinit mxc_cpufreq_driver_init(void)
192{
193 return cpufreq_register_driver(&mxc_driver);
194}
195
196static void mxc_cpufreq_driver_exit(void)
197{
198 cpufreq_unregister_driver(&mxc_driver);
199}
200
201module_init(mxc_cpufreq_driver_init);
202module_exit(mxc_cpufreq_driver_exit);
203
204MODULE_AUTHOR("Freescale Semiconductor Inc. Yong Shen <yong.shen@linaro.org>");
205MODULE_DESCRIPTION("CPUfreq driver for i.MX");
206MODULE_LICENSE("GPL");
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 404799487f17..9aa6f3ea9012 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -6,9 +6,13 @@ config IMX_HAVE_PLATFORM_FEC
6 default y if ARCH_MX25 || SOC_IMX27 || ARCH_MX35 || ARCH_MX51 6 default y if ARCH_MX25 || SOC_IMX27 || ARCH_MX35 || ARCH_MX51
7 7
8config IMX_HAVE_PLATFORM_FLEXCAN 8config IMX_HAVE_PLATFORM_FLEXCAN
9 select HAVE_CAN_FLEXCAN 9 select HAVE_CAN_FLEXCAN if CAN
10 bool 10 bool
11 11
12config IMX_HAVE_PLATFORM_GPIO_KEYS
13 bool
14 default y if ARCH_MX51
15
12config IMX_HAVE_PLATFORM_IMX_I2C 16config IMX_HAVE_PLATFORM_IMX_I2C
13 bool 17 bool
14 18
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 0a3c1f089413..45aefeb283ba 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -1,6 +1,7 @@
1obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o 1obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
2obj-$(CONFIG_IMX_HAVE_PLATFORM_FEC) += platform-fec.o 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
4obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
4obj-y += platform-imx-dma.o 5obj-y += platform-imx-dma.o
5obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o 6obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
6obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o 7obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
diff --git a/arch/arm/plat-mxc/devices/platform-gpio_keys.c b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
new file mode 100644
index 000000000000..1c53a532ea0e
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-gpio_keys.c
@@ -0,0 +1,27 @@
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 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18#include <asm/sizes.h>
19#include <mach/hardware.h>
20#include <mach/devices-common.h>
21
22struct platform_device *__init imx_add_gpio_keys(
23 const struct gpio_keys_platform_data *pdata)
24{
25 return imx_add_platform_device("gpio-keys", -1, NULL,
26 0, pdata, sizeof(*pdata));
27}
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 9d38da077edb..9c3e36232b5b 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h>
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/irq.h> 25#include <linux/irq.h>
25#include <linux/gpio.h> 26#include <linux/gpio.h>
@@ -201,11 +202,42 @@ static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc)
201 } 202 }
202} 203}
203 204
205/*
206 * Set interrupt number "irq" in the GPIO as a wake-up source.
207 * While system is running, all registered GPIO interrupts need to have
208 * wake-up enabled. When system is suspended, only selected GPIO interrupts
209 * need to have wake-up enabled.
210 * @param irq interrupt source number
211 * @param enable enable as wake-up if equal to non-zero
212 * @return This function returns 0 on success.
213 */
214static int gpio_set_wake_irq(u32 irq, u32 enable)
215{
216 u32 gpio = irq_to_gpio(irq);
217 u32 gpio_idx = gpio & 0x1F;
218 struct mxc_gpio_port *port = &mxc_gpio_ports[gpio / 32];
219
220 if (enable) {
221 if (port->irq_high && (gpio_idx >= 16))
222 enable_irq_wake(port->irq_high);
223 else
224 enable_irq_wake(port->irq);
225 } else {
226 if (port->irq_high && (gpio_idx >= 16))
227 disable_irq_wake(port->irq_high);
228 else
229 disable_irq_wake(port->irq);
230 }
231
232 return 0;
233}
234
204static struct irq_chip gpio_irq_chip = { 235static struct irq_chip gpio_irq_chip = {
205 .ack = gpio_ack_irq, 236 .ack = gpio_ack_irq,
206 .mask = gpio_mask_irq, 237 .mask = gpio_mask_irq,
207 .unmask = gpio_unmask_irq, 238 .unmask = gpio_unmask_irq,
208 .set_type = gpio_set_irq_type, 239 .set_type = gpio_set_irq_type,
240 .set_wake = gpio_set_wake_irq,
209}; 241};
210 242
211static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset, 243static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 86d7575a564d..8c6896fd1e5f 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -29,6 +29,10 @@ struct platform_device *__init imx_add_flexcan(int id,
29 resource_size_t irq, 29 resource_size_t irq,
30 const struct flexcan_platform_data *pdata); 30 const struct flexcan_platform_data *pdata);
31 31
32#include <linux/gpio_keys.h>
33struct platform_device *__init imx_add_gpio_keys(
34 const struct gpio_keys_platform_data *pdata);
35
32#include <mach/i2c.h> 36#include <mach/i2c.h>
33struct imx_imx_i2c_data { 37struct imx_imx_i2c_data {
34 int id; 38 int id;
diff --git a/arch/arm/plat-mxc/include/mach/dma.h b/arch/arm/plat-mxc/include/mach/dma.h
new file mode 100644
index 000000000000..ef7751546f5f
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/dma.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
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#ifndef __ASM_ARCH_MXC_DMA_H__
10#define __ASM_ARCH_MXC_DMA_H__
11
12#include <linux/scatterlist.h>
13#include <linux/device.h>
14#include <linux/dmaengine.h>
15
16/*
17 * This enumerates peripheral types. Used for SDMA.
18 */
19enum sdma_peripheral_type {
20 IMX_DMATYPE_SSI, /* MCU domain SSI */
21 IMX_DMATYPE_SSI_SP, /* Shared SSI */
22 IMX_DMATYPE_MMC, /* MMC */
23 IMX_DMATYPE_SDHC, /* SDHC */
24 IMX_DMATYPE_UART, /* MCU domain UART */
25 IMX_DMATYPE_UART_SP, /* Shared UART */
26 IMX_DMATYPE_FIRI, /* FIRI */
27 IMX_DMATYPE_CSPI, /* MCU domain CSPI */
28 IMX_DMATYPE_CSPI_SP, /* Shared CSPI */
29 IMX_DMATYPE_SIM, /* SIM */
30 IMX_DMATYPE_ATA, /* ATA */
31 IMX_DMATYPE_CCM, /* CCM */
32 IMX_DMATYPE_EXT, /* External peripheral */
33 IMX_DMATYPE_MSHC, /* Memory Stick Host Controller */
34 IMX_DMATYPE_MSHC_SP, /* Shared Memory Stick Host Controller */
35 IMX_DMATYPE_DSP, /* DSP */
36 IMX_DMATYPE_MEMORY, /* Memory */
37 IMX_DMATYPE_FIFO_MEMORY,/* FIFO type Memory */
38 IMX_DMATYPE_SPDIF, /* SPDIF */
39 IMX_DMATYPE_IPU_MEMORY, /* IPU Memory */
40 IMX_DMATYPE_ASRC, /* ASRC */
41 IMX_DMATYPE_ESAI, /* ESAI */
42};
43
44enum imx_dma_prio {
45 DMA_PRIO_HIGH = 0,
46 DMA_PRIO_MEDIUM = 1,
47 DMA_PRIO_LOW = 2
48};
49
50struct imx_dma_data {
51 int dma_request; /* DMA request line */
52 enum sdma_peripheral_type peripheral_type;
53 int priority;
54};
55
56static inline int imx_dma_is_ipu(struct dma_chan *chan)
57{
58 return !strcmp(dev_name(chan->device->dev), "ipu-core");
59}
60
61static inline int imx_dma_is_general_purpose(struct dma_chan *chan)
62{
63 return !strcmp(dev_name(chan->device->dev), "imx-sdma") ||
64 !strcmp(dev_name(chan->device->dev), "imx-dma");
65}
66
67#endif
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index e46b1c2836d4..d7a41e9a2605 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -45,6 +45,8 @@ 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_GPIO_PAD_CTRL_2 (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
49 PAD_CTL_PUS_100K_UP)
48#define MX51_ECSPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \ 50#define MX51_ECSPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \
49 PAD_CTL_SRE_FAST) 51 PAD_CTL_SRE_FAST)
50#define MX51_SDHCI_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PUS_47K_UP | \ 52#define MX51_SDHCI_PAD_CTRL (PAD_CTL_DSE_HIGH | PAD_CTL_PUS_47K_UP | \
diff --git a/arch/arm/plat-mxc/include/mach/mx31.h b/arch/arm/plat-mxc/include/mach/mx31.h
index 03e2afabc9fc..61cfe827498b 100644
--- a/arch/arm/plat-mxc/include/mach/mx31.h
+++ b/arch/arm/plat-mxc/include/mach/mx31.h
@@ -240,7 +240,6 @@ static inline void mx31_setup_weimcs(size_t cs,
240#define MPEG4_ENC_BASE_ADDR MX31_MPEG4_ENC_BASE_ADDR 240#define MPEG4_ENC_BASE_ADDR MX31_MPEG4_ENC_BASE_ADDR
241#define MXC_INT_MPEG4_ENCODER MX31_INT_MPEG4_ENCODER 241#define MXC_INT_MPEG4_ENCODER MX31_INT_MPEG4_ENCODER
242#define MXC_INT_FIRI MX31_INT_FIRI 242#define MXC_INT_FIRI MX31_INT_FIRI
243#define MXC_INT_MMC_SDHC1 MX31_INT_MMC_SDHC1
244#define MXC_INT_MBX MX31_INT_MBX 243#define MXC_INT_MBX MX31_INT_MBX
245#define MXC_INT_CSPI3 MX31_INT_CSPI3 244#define MXC_INT_CSPI3 MX31_INT_CSPI3
246#define MXC_INT_SIM2 MX31_INT_SIM2 245#define MXC_INT_SIM2 MX31_INT_SIM2
diff --git a/arch/arm/plat-mxc/include/mach/mx35.h b/arch/arm/plat-mxc/include/mach/mx35.h
index ff905cb32458..6267cff6035d 100644
--- a/arch/arm/plat-mxc/include/mach/mx35.h
+++ b/arch/arm/plat-mxc/include/mach/mx35.h
@@ -197,8 +197,6 @@
197/* these should go away */ 197/* these should go away */
198#define MXC_FEC_BASE_ADDR MX35_FEC_BASE_ADDR 198#define MXC_FEC_BASE_ADDR MX35_FEC_BASE_ADDR
199#define MXC_INT_OWIRE MX35_INT_OWIRE 199#define MXC_INT_OWIRE MX35_INT_OWIRE
200#define MXC_INT_MMC_SDHC2 MX35_INT_MMC_SDHC2
201#define MXC_INT_MMC_SDHC3 MX35_INT_MMC_SDHC3
202#define MXC_INT_GPU2D MX35_INT_GPU2D 200#define MXC_INT_GPU2D MX35_INT_GPU2D
203#define MXC_INT_ASRC MX35_INT_ASRC 201#define MXC_INT_ASRC MX35_INT_ASRC
204#define MXC_INT_USBHS MX35_INT_USBHS 202#define MXC_INT_USBHS MX35_INT_USBHS
diff --git a/arch/arm/plat-mxc/include/mach/mxc.h b/arch/arm/plat-mxc/include/mach/mxc.h
index a790bf212972..a42c7207082d 100644
--- a/arch/arm/plat-mxc/include/mach/mxc.h
+++ b/arch/arm/plat-mxc/include/mach/mxc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2007, 2010 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) 3 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
@@ -20,6 +20,8 @@
20#ifndef __ASM_ARCH_MXC_H__ 20#ifndef __ASM_ARCH_MXC_H__
21#define __ASM_ARCH_MXC_H__ 21#define __ASM_ARCH_MXC_H__
22 22
23#include <linux/types.h>
24
23#ifndef __ASM_ARCH_MXC_HARDWARE_H__ 25#ifndef __ASM_ARCH_MXC_HARDWARE_H__
24#error "Do not include directly." 26#error "Do not include directly."
25#endif 27#endif
@@ -133,6 +135,15 @@ extern unsigned int __mxc_cpu_type;
133# define cpu_is_mxc91231() (0) 135# define cpu_is_mxc91231() (0)
134#endif 136#endif
135 137
138#ifndef __ASSEMBLY__
139
140struct cpu_op {
141 u32 cpu_rate;
142};
143
144extern struct cpu_op *(*get_cpu_op)(int *op);
145#endif
146
136#if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2) 147#if defined(CONFIG_ARCH_MX3) || defined(CONFIG_ARCH_MX2)
137/* These are deprecated, use mx[23][157]_setup_weimcs instead. */ 148/* These are deprecated, use mx[23][157]_setup_weimcs instead. */
138#define CSCR_U(n) (IO_ADDRESS(WEIM_BASE_ADDR + n * 0x10)) 149#define CSCR_U(n) (IO_ADDRESS(WEIM_BASE_ADDR + n * 0x10))
diff --git a/arch/arm/plat-mxc/include/mach/sdma.h b/arch/arm/plat-mxc/include/mach/sdma.h
new file mode 100644
index 000000000000..9be112227ac4
--- /dev/null
+++ b/arch/arm/plat-mxc/include/mach/sdma.h
@@ -0,0 +1,17 @@
1#ifndef __MACH_MXC_SDMA_H__
2#define __MACH_MXC_SDMA_H__
3
4/**
5 * struct sdma_platform_data - platform specific data for SDMA engine
6 *
7 * @sdma_version The version of this SDMA engine
8 * @cpu_name used to generate the firmware name
9 * @to_version CPU Tape out version
10 */
11struct sdma_platform_data {
12 int sdma_version;
13 char *cpu_name;
14 int to_version;
15};
16
17#endif /* __MACH_MXC_SDMA_H__ */
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-nomadik/include/plat/ste_dma40.h b/arch/arm/plat-nomadik/include/plat/ste_dma40.h
index 5fbde4b8dc12..74b62f10d07f 100644
--- a/arch/arm/plat-nomadik/include/plat/ste_dma40.h
+++ b/arch/arm/plat-nomadik/include/plat/ste_dma40.h
@@ -1,10 +1,8 @@
1/* 1/*
2 * arch/arm/plat-nomadik/include/plat/ste_dma40.h 2 * Copyright (C) ST-Ericsson SA 2007-2010
3 * 3 * Author: Per Forlin <per.forlin@stericsson.com> for ST-Ericsson
4 * Copyright (C) ST-Ericsson 2007-2010 4 * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2 5 * License terms: GNU General Public License (GPL) version 2
6 * Author: Per Friden <per.friden@stericsson.com>
7 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
8 */ 6 */
9 7
10 8
@@ -14,43 +12,25 @@
14#include <linux/dmaengine.h> 12#include <linux/dmaengine.h>
15#include <linux/workqueue.h> 13#include <linux/workqueue.h>
16#include <linux/interrupt.h> 14#include <linux/interrupt.h>
17#include <linux/dmaengine.h>
18 15
19/* dev types for memcpy */ 16/* dev types for memcpy */
20#define STEDMA40_DEV_DST_MEMORY (-1) 17#define STEDMA40_DEV_DST_MEMORY (-1)
21#define STEDMA40_DEV_SRC_MEMORY (-1) 18#define STEDMA40_DEV_SRC_MEMORY (-1)
22 19
23/* 20enum stedma40_mode {
24 * Description of bitfields of channel_type variable is available in 21 STEDMA40_MODE_LOGICAL = 0,
25 * the info structure. 22 STEDMA40_MODE_PHYSICAL,
26 */ 23 STEDMA40_MODE_OPERATION,
24};
27 25
28/* Priority */ 26enum stedma40_mode_opt {
29#define STEDMA40_INFO_PRIO_TYPE_POS 2 27 STEDMA40_PCHAN_BASIC_MODE = 0,
30#define STEDMA40_HIGH_PRIORITY_CHANNEL (0x1 << STEDMA40_INFO_PRIO_TYPE_POS) 28 STEDMA40_LCHAN_SRC_LOG_DST_LOG = 0,
31#define STEDMA40_LOW_PRIORITY_CHANNEL (0x2 << STEDMA40_INFO_PRIO_TYPE_POS) 29 STEDMA40_PCHAN_MODULO_MODE,
32 30 STEDMA40_PCHAN_DOUBLE_DST_MODE,
33/* Mode */ 31 STEDMA40_LCHAN_SRC_PHY_DST_LOG,
34#define STEDMA40_INFO_CH_MODE_TYPE_POS 6 32 STEDMA40_LCHAN_SRC_LOG_DST_PHY,
35#define STEDMA40_CHANNEL_IN_PHY_MODE (0x1 << STEDMA40_INFO_CH_MODE_TYPE_POS) 33};
36#define STEDMA40_CHANNEL_IN_LOG_MODE (0x2 << STEDMA40_INFO_CH_MODE_TYPE_POS)
37#define STEDMA40_CHANNEL_IN_OPER_MODE (0x3 << STEDMA40_INFO_CH_MODE_TYPE_POS)
38
39/* Mode options */
40#define STEDMA40_INFO_CH_MODE_OPT_POS 8
41#define STEDMA40_PCHAN_BASIC_MODE (0x1 << STEDMA40_INFO_CH_MODE_OPT_POS)
42#define STEDMA40_PCHAN_MODULO_MODE (0x2 << STEDMA40_INFO_CH_MODE_OPT_POS)
43#define STEDMA40_PCHAN_DOUBLE_DST_MODE (0x3 << STEDMA40_INFO_CH_MODE_OPT_POS)
44#define STEDMA40_LCHAN_SRC_PHY_DST_LOG (0x1 << STEDMA40_INFO_CH_MODE_OPT_POS)
45#define STEDMA40_LCHAN_SRC_LOG_DST_PHS (0x2 << STEDMA40_INFO_CH_MODE_OPT_POS)
46#define STEDMA40_LCHAN_SRC_LOG_DST_LOG (0x3 << STEDMA40_INFO_CH_MODE_OPT_POS)
47
48/* Interrupt */
49#define STEDMA40_INFO_TIM_POS 10
50#define STEDMA40_NO_TIM_FOR_LINK (0x0 << STEDMA40_INFO_TIM_POS)
51#define STEDMA40_TIM_FOR_LINK (0x1 << STEDMA40_INFO_TIM_POS)
52
53/* End of channel_type configuration */
54 34
55#define STEDMA40_ESIZE_8_BIT 0x0 35#define STEDMA40_ESIZE_8_BIT 0x0
56#define STEDMA40_ESIZE_16_BIT 0x1 36#define STEDMA40_ESIZE_16_BIT 0x1
@@ -73,16 +53,14 @@
73#define STEDMA40_PSIZE_LOG_8 STEDMA40_PSIZE_PHY_8 53#define STEDMA40_PSIZE_LOG_8 STEDMA40_PSIZE_PHY_8
74#define STEDMA40_PSIZE_LOG_16 STEDMA40_PSIZE_PHY_16 54#define STEDMA40_PSIZE_LOG_16 STEDMA40_PSIZE_PHY_16
75 55
56/* Maximum number of possible physical channels */
57#define STEDMA40_MAX_PHYS 32
58
76enum stedma40_flow_ctrl { 59enum stedma40_flow_ctrl {
77 STEDMA40_NO_FLOW_CTRL, 60 STEDMA40_NO_FLOW_CTRL,
78 STEDMA40_FLOW_CTRL, 61 STEDMA40_FLOW_CTRL,
79}; 62};
80 63
81enum stedma40_endianess {
82 STEDMA40_LITTLE_ENDIAN,
83 STEDMA40_BIG_ENDIAN
84};
85
86enum stedma40_periph_data_width { 64enum stedma40_periph_data_width {
87 STEDMA40_BYTE_WIDTH = STEDMA40_ESIZE_8_BIT, 65 STEDMA40_BYTE_WIDTH = STEDMA40_ESIZE_8_BIT,
88 STEDMA40_HALFWORD_WIDTH = STEDMA40_ESIZE_16_BIT, 66 STEDMA40_HALFWORD_WIDTH = STEDMA40_ESIZE_16_BIT,
@@ -90,15 +68,8 @@ enum stedma40_periph_data_width {
90 STEDMA40_DOUBLEWORD_WIDTH = STEDMA40_ESIZE_64_BIT 68 STEDMA40_DOUBLEWORD_WIDTH = STEDMA40_ESIZE_64_BIT
91}; 69};
92 70
93struct stedma40_half_channel_info {
94 enum stedma40_endianess endianess;
95 enum stedma40_periph_data_width data_width;
96 int psize;
97 enum stedma40_flow_ctrl flow_ctrl;
98};
99
100enum stedma40_xfer_dir { 71enum stedma40_xfer_dir {
101 STEDMA40_MEM_TO_MEM, 72 STEDMA40_MEM_TO_MEM = 1,
102 STEDMA40_MEM_TO_PERIPH, 73 STEDMA40_MEM_TO_PERIPH,
103 STEDMA40_PERIPH_TO_MEM, 74 STEDMA40_PERIPH_TO_MEM,
104 STEDMA40_PERIPH_TO_PERIPH 75 STEDMA40_PERIPH_TO_PERIPH
@@ -106,18 +77,31 @@ enum stedma40_xfer_dir {
106 77
107 78
108/** 79/**
80 * struct stedma40_chan_cfg - dst/src channel configuration
81 *
82 * @big_endian: true if the src/dst should be read as big endian
83 * @data_width: Data width of the src/dst hardware
84 * @p_size: Burst size
85 * @flow_ctrl: Flow control on/off.
86 */
87struct stedma40_half_channel_info {
88 bool big_endian;
89 enum stedma40_periph_data_width data_width;
90 int psize;
91 enum stedma40_flow_ctrl flow_ctrl;
92};
93
94/**
109 * struct stedma40_chan_cfg - Structure to be filled by client drivers. 95 * struct stedma40_chan_cfg - Structure to be filled by client drivers.
110 * 96 *
111 * @dir: MEM 2 MEM, PERIPH 2 MEM , MEM 2 PERIPH, PERIPH 2 PERIPH 97 * @dir: MEM 2 MEM, PERIPH 2 MEM , MEM 2 PERIPH, PERIPH 2 PERIPH
112 * @channel_type: priority, mode, mode options and interrupt configuration. 98 * @high_priority: true if high-priority
99 * @mode: channel mode: physical, logical, or operation
100 * @mode_opt: options for the chosen channel mode
113 * @src_dev_type: Src device type 101 * @src_dev_type: Src device type
114 * @dst_dev_type: Dst device type 102 * @dst_dev_type: Dst device type
115 * @src_info: Parameters for dst half channel 103 * @src_info: Parameters for dst half channel
116 * @dst_info: Parameters for dst half channel 104 * @dst_info: Parameters for dst half channel
117 * @pre_transfer_data: Data to be passed on to the pre_transfer() function.
118 * @pre_transfer: Callback used if needed before preparation of transfer.
119 * Only called if device is set. size of bytes to transfer
120 * (in case of multiple element transfer size is size of the first element).
121 * 105 *
122 * 106 *
123 * This structure has to be filled by the client drivers. 107 * This structure has to be filled by the client drivers.
@@ -126,15 +110,13 @@ enum stedma40_xfer_dir {
126 */ 110 */
127struct stedma40_chan_cfg { 111struct stedma40_chan_cfg {
128 enum stedma40_xfer_dir dir; 112 enum stedma40_xfer_dir dir;
129 unsigned int channel_type; 113 bool high_priority;
114 enum stedma40_mode mode;
115 enum stedma40_mode_opt mode_opt;
130 int src_dev_type; 116 int src_dev_type;
131 int dst_dev_type; 117 int dst_dev_type;
132 struct stedma40_half_channel_info src_info; 118 struct stedma40_half_channel_info src_info;
133 struct stedma40_half_channel_info dst_info; 119 struct stedma40_half_channel_info dst_info;
134 void *pre_transfer_data;
135 int (*pre_transfer) (struct dma_chan *chan,
136 void *data,
137 int size);
138}; 120};
139 121
140/** 122/**
@@ -147,7 +129,6 @@ struct stedma40_chan_cfg {
147 * @memcpy_len: length of memcpy 129 * @memcpy_len: length of memcpy
148 * @memcpy_conf_phy: default configuration of physical channel memcpy 130 * @memcpy_conf_phy: default configuration of physical channel memcpy
149 * @memcpy_conf_log: default configuration of logical channel memcpy 131 * @memcpy_conf_log: default configuration of logical channel memcpy
150 * @llis_per_log: number of max linked list items per logical channel
151 * @disabled_channels: A vector, ending with -1, that marks physical channels 132 * @disabled_channels: A vector, ending with -1, that marks physical channels
152 * that are for different reasons not available for the driver. 133 * that are for different reasons not available for the driver.
153 */ 134 */
@@ -159,23 +140,10 @@ struct stedma40_platform_data {
159 u32 memcpy_len; 140 u32 memcpy_len;
160 struct stedma40_chan_cfg *memcpy_conf_phy; 141 struct stedma40_chan_cfg *memcpy_conf_phy;
161 struct stedma40_chan_cfg *memcpy_conf_log; 142 struct stedma40_chan_cfg *memcpy_conf_log;
162 unsigned int llis_per_log; 143 int disabled_channels[STEDMA40_MAX_PHYS];
163 int disabled_channels[8];
164}; 144};
165 145
166/** 146#ifdef CONFIG_STE_DMA40
167 * setdma40_set_psize() - Used for changing the package size of an
168 * already configured dma channel.
169 *
170 * @chan: dmaengine handle
171 * @src_psize: new package side for src. (STEDMA40_PSIZE*)
172 * @src_psize: new package side for dst. (STEDMA40_PSIZE*)
173 *
174 * returns 0 on ok, otherwise negative error number.
175 */
176int stedma40_set_psize(struct dma_chan *chan,
177 int src_psize,
178 int dst_psize);
179 147
180/** 148/**
181 * stedma40_filter() - Provides stedma40_chan_cfg to the 149 * stedma40_filter() - Provides stedma40_chan_cfg to the
@@ -238,4 +206,21 @@ dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan,
238 direction, flags); 206 direction, flags);
239} 207}
240 208
209#else
210static inline bool stedma40_filter(struct dma_chan *chan, void *data)
211{
212 return false;
213}
214
215static inline struct
216dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan,
217 dma_addr_t addr,
218 unsigned int size,
219 enum dma_data_direction direction,
220 unsigned long flags)
221{
222 return NULL;
223}
224#endif
225
241#endif 226#endif
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index a92cb499313f..92c5bb7909f5 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -19,7 +19,7 @@ config ARCH_OMAP2PLUS
19 bool "TI OMAP2/3/4" 19 bool "TI OMAP2/3/4"
20 select COMMON_CLKDEV 20 select COMMON_CLKDEV
21 help 21 help
22 "Systems based on omap24xx, omap34xx or omap44xx" 22 "Systems based on OMAP2, OMAP3 or OMAP4"
23 23
24endchoice 24endchoice
25 25
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 9405831b746a..a4a12859fdd5 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -4,7 +4,7 @@
4 4
5# Common support 5# Common support
6obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \ 6obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \
7 usb.o fb.o io.o 7 usb.o fb.o io.o counter_32k.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
@@ -31,4 +31,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
31# OMAP mailbox framework 31# OMAP mailbox framework
32obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o 32obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
33 33
34obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o \ No newline at end of file 34obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 7190cbd92620..fc62fb5fc20b 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -60,7 +60,7 @@ void clk_disable(struct clk *clk)
60 60
61 spin_lock_irqsave(&clockfw_lock, flags); 61 spin_lock_irqsave(&clockfw_lock, flags);
62 if (clk->usecount == 0) { 62 if (clk->usecount == 0) {
63 printk(KERN_ERR "Trying disable clock %s with 0 usecount\n", 63 pr_err("Trying disable clock %s with 0 usecount\n",
64 clk->name); 64 clk->name);
65 WARN_ON(1); 65 WARN_ON(1);
66 goto out; 66 goto out;
@@ -397,6 +397,7 @@ static int __init clk_disable_unused(void)
397 struct clk *ck; 397 struct clk *ck;
398 unsigned long flags; 398 unsigned long flags;
399 399
400 pr_info("clock: disabling unused clocks to save power\n");
400 list_for_each_entry(ck, &clocks, node) { 401 list_for_each_entry(ck, &clocks, node) {
401 if (ck->ops == &clkops_null) 402 if (ck->ops == &clkops_null)
402 continue; 403 continue;
@@ -418,7 +419,7 @@ late_initcall(clk_disable_unused);
418int __init clk_init(struct clk_functions * custom_clocks) 419int __init clk_init(struct clk_functions * custom_clocks)
419{ 420{
420 if (!custom_clocks) { 421 if (!custom_clocks) {
421 printk(KERN_ERR "No custom clock functions registered\n"); 422 pr_err("No custom clock functions registered\n");
422 BUG(); 423 BUG();
423 } 424 }
424 425
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 3008e7104487..f04731820301 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -11,38 +11,16 @@
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
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/module.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/console.h>
19#include <linux/serial.h>
20#include <linux/tty.h>
21#include <linux/serial_8250.h>
22#include <linux/serial_reg.h>
23#include <linux/clk.h>
24#include <linux/io.h> 16#include <linux/io.h>
25#include <linux/omapfb.h> 17#include <linux/omapfb.h>
26 18
27#include <mach/hardware.h>
28#include <asm/system.h>
29#include <asm/pgtable.h>
30#include <asm/mach/map.h>
31#include <asm/setup.h>
32
33#include <plat/common.h> 19#include <plat/common.h>
34#include <plat/board.h> 20#include <plat/board.h>
35#include <plat/control.h>
36#include <plat/mux.h>
37#include <plat/fpga.h>
38#include <plat/serial.h>
39#include <plat/vram.h> 21#include <plat/vram.h>
22#include <plat/dsp.h>
40 23
41#include <plat/clock.h>
42
43#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
44# include "../mach-omap2/sdrc.h"
45#endif
46 24
47#define NO_LENGTH_CHECK 0xffffffff 25#define NO_LENGTH_CHECK 0xffffffff
48 26
@@ -87,271 +65,5 @@ void __init omap_reserve(void)
87{ 65{
88 omapfb_reserve_sdram_memblock(); 66 omapfb_reserve_sdram_memblock();
89 omap_vram_reserve_sdram_memblock(); 67 omap_vram_reserve_sdram_memblock();
68 omap_dsp_reserve_sdram_memblock();
90} 69}
91
92/*
93 * 32KHz clocksource ... always available, on pretty most chips except
94 * OMAP 730 and 1510. Other timers could be used as clocksources, with
95 * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
96 * but systems won't necessarily want to spend resources that way.
97 */
98
99#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
100
101#if !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX))
102
103#include <linux/clocksource.h>
104
105/*
106 * offset_32k holds the init time counter value. It is then subtracted
107 * from every counter read to achieve a counter that counts time from the
108 * kernel boot (needed for sched_clock()).
109 */
110static u32 offset_32k __read_mostly;
111
112#ifdef CONFIG_ARCH_OMAP16XX
113static cycle_t omap16xx_32k_read(struct clocksource *cs)
114{
115 return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED) - offset_32k;
116}
117#else
118#define omap16xx_32k_read NULL
119#endif
120
121#ifdef CONFIG_ARCH_OMAP2420
122static cycle_t omap2420_32k_read(struct clocksource *cs)
123{
124 return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10) - offset_32k;
125}
126#else
127#define omap2420_32k_read NULL
128#endif
129
130#ifdef CONFIG_ARCH_OMAP2430
131static cycle_t omap2430_32k_read(struct clocksource *cs)
132{
133 return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10) - offset_32k;
134}
135#else
136#define omap2430_32k_read NULL
137#endif
138
139#ifdef CONFIG_ARCH_OMAP3
140static cycle_t omap34xx_32k_read(struct clocksource *cs)
141{
142 return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10) - offset_32k;
143}
144#else
145#define omap34xx_32k_read NULL
146#endif
147
148#ifdef CONFIG_ARCH_OMAP4
149static cycle_t omap44xx_32k_read(struct clocksource *cs)
150{
151 return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10) - offset_32k;
152}
153#else
154#define omap44xx_32k_read NULL
155#endif
156
157/*
158 * Kernel assumes that sched_clock can be called early but may not have
159 * things ready yet.
160 */
161static cycle_t omap_32k_read_dummy(struct clocksource *cs)
162{
163 return 0;
164}
165
166static struct clocksource clocksource_32k = {
167 .name = "32k_counter",
168 .rating = 250,
169 .read = omap_32k_read_dummy,
170 .mask = CLOCKSOURCE_MASK(32),
171 .shift = 10,
172 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
173};
174
175/*
176 * Returns current time from boot in nsecs. It's OK for this to wrap
177 * around for now, as it's just a relative time stamp.
178 */
179unsigned long long sched_clock(void)
180{
181 return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k),
182 clocksource_32k.mult, clocksource_32k.shift);
183}
184
185/**
186 * read_persistent_clock - Return time from a persistent clock.
187 *
188 * Reads the time from a source which isn't disabled during PM, the
189 * 32k sync timer. Convert the cycles elapsed since last read into
190 * nsecs and adds to a monotonically increasing timespec.
191 */
192static struct timespec persistent_ts;
193static cycles_t cycles, last_cycles;
194void read_persistent_clock(struct timespec *ts)
195{
196 unsigned long long nsecs;
197 cycles_t delta;
198 struct timespec *tsp = &persistent_ts;
199
200 last_cycles = cycles;
201 cycles = clocksource_32k.read(&clocksource_32k);
202 delta = cycles - last_cycles;
203
204 nsecs = clocksource_cyc2ns(delta,
205 clocksource_32k.mult, clocksource_32k.shift);
206
207 timespec_add_ns(tsp, nsecs);
208 *ts = *tsp;
209}
210
211static int __init omap_init_clocksource_32k(void)
212{
213 static char err[] __initdata = KERN_ERR
214 "%s: can't register clocksource!\n";
215
216 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
217 struct clk *sync_32k_ick;
218
219 if (cpu_is_omap16xx())
220 clocksource_32k.read = omap16xx_32k_read;
221 else if (cpu_is_omap2420())
222 clocksource_32k.read = omap2420_32k_read;
223 else if (cpu_is_omap2430())
224 clocksource_32k.read = omap2430_32k_read;
225 else if (cpu_is_omap34xx())
226 clocksource_32k.read = omap34xx_32k_read;
227 else if (cpu_is_omap44xx())
228 clocksource_32k.read = omap44xx_32k_read;
229 else
230 return -ENODEV;
231
232 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
233 if (sync_32k_ick)
234 clk_enable(sync_32k_ick);
235
236 clocksource_32k.mult = clocksource_hz2mult(32768,
237 clocksource_32k.shift);
238
239 offset_32k = clocksource_32k.read(&clocksource_32k);
240
241 if (clocksource_register(&clocksource_32k))
242 printk(err, clocksource_32k.name);
243 }
244 return 0;
245}
246arch_initcall(omap_init_clocksource_32k);
247
248#endif /* !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX)) */
249
250/* Global address base setup code */
251
252#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
253
254static void __init __omap2_set_globals(struct omap_globals *omap2_globals)
255{
256 omap2_set_globals_tap(omap2_globals);
257 omap2_set_globals_sdrc(omap2_globals);
258 omap2_set_globals_control(omap2_globals);
259 omap2_set_globals_prcm(omap2_globals);
260 omap2_set_globals_uart(omap2_globals);
261}
262
263#endif
264
265#if defined(CONFIG_ARCH_OMAP2420)
266
267static struct omap_globals omap242x_globals = {
268 .class = OMAP242X_CLASS,
269 .tap = OMAP2_L4_IO_ADDRESS(0x48014000),
270 .sdrc = OMAP2420_SDRC_BASE,
271 .sms = OMAP2420_SMS_BASE,
272 .ctrl = OMAP2420_CTRL_BASE,
273 .prm = OMAP2420_PRM_BASE,
274 .cm = OMAP2420_CM_BASE,
275 .uart1_phys = OMAP2_UART1_BASE,
276 .uart2_phys = OMAP2_UART2_BASE,
277 .uart3_phys = OMAP2_UART3_BASE,
278};
279
280void __init omap2_set_globals_242x(void)
281{
282 __omap2_set_globals(&omap242x_globals);
283}
284#endif
285
286#if defined(CONFIG_ARCH_OMAP2430)
287
288static struct omap_globals omap243x_globals = {
289 .class = OMAP243X_CLASS,
290 .tap = OMAP2_L4_IO_ADDRESS(0x4900a000),
291 .sdrc = OMAP243X_SDRC_BASE,
292 .sms = OMAP243X_SMS_BASE,
293 .ctrl = OMAP243X_CTRL_BASE,
294 .prm = OMAP2430_PRM_BASE,
295 .cm = OMAP2430_CM_BASE,
296 .uart1_phys = OMAP2_UART1_BASE,
297 .uart2_phys = OMAP2_UART2_BASE,
298 .uart3_phys = OMAP2_UART3_BASE,
299};
300
301void __init omap2_set_globals_243x(void)
302{
303 __omap2_set_globals(&omap243x_globals);
304}
305#endif
306
307#if defined(CONFIG_ARCH_OMAP3)
308
309static struct omap_globals omap3_globals = {
310 .class = OMAP343X_CLASS,
311 .tap = OMAP2_L4_IO_ADDRESS(0x4830A000),
312 .sdrc = OMAP343X_SDRC_BASE,
313 .sms = OMAP343X_SMS_BASE,
314 .ctrl = OMAP343X_CTRL_BASE,
315 .prm = OMAP3430_PRM_BASE,
316 .cm = OMAP3430_CM_BASE,
317 .uart1_phys = OMAP3_UART1_BASE,
318 .uart2_phys = OMAP3_UART2_BASE,
319 .uart3_phys = OMAP3_UART3_BASE,
320 .uart4_phys = OMAP3_UART4_BASE, /* Only on 3630 */
321};
322
323void __init omap2_set_globals_3xxx(void)
324{
325 __omap2_set_globals(&omap3_globals);
326}
327
328void __init omap3_map_io(void)
329{
330 omap2_set_globals_3xxx();
331 omap34xx_map_common_io();
332}
333#endif
334
335#if defined(CONFIG_ARCH_OMAP4)
336static struct omap_globals omap4_globals = {
337 .class = OMAP443X_CLASS,
338 .tap = OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE),
339 .ctrl = OMAP443X_CTRL_BASE,
340 .prm = OMAP4430_PRM_BASE,
341 .cm = OMAP4430_CM_BASE,
342 .cm2 = OMAP4430_CM2_BASE,
343 .uart1_phys = OMAP4_UART1_BASE,
344 .uart2_phys = OMAP4_UART2_BASE,
345 .uart3_phys = OMAP4_UART3_BASE,
346 .uart4_phys = OMAP4_UART4_BASE,
347};
348
349void __init omap2_set_globals_443x(void)
350{
351 omap2_set_globals_tap(&omap4_globals);
352 omap2_set_globals_control(&omap4_globals);
353 omap2_set_globals_prcm(&omap4_globals);
354 omap2_set_globals_uart(&omap4_globals);
355}
356#endif
357
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
new file mode 100644
index 000000000000..155fe43a672b
--- /dev/null
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -0,0 +1,183 @@
1/*
2 * OMAP 32ksynctimer/counter_32k-related code
3 *
4 * Copyright (C) 2009 Texas Instruments
5 * Copyright (C) 2010 Nokia Corporation
6 * Tony Lindgren <tony@atomide.com>
7 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.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 * NOTE: This timer is not the same timer as the old OMAP1 MPU timer.
14 */
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/clk.h>
18#include <linux/io.h>
19
20#include <plat/common.h>
21#include <plat/board.h>
22
23#include <plat/clock.h>
24
25
26/*
27 * 32KHz clocksource ... always available, on pretty most chips except
28 * OMAP 730 and 1510. Other timers could be used as clocksources, with
29 * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
30 * but systems won't necessarily want to spend resources that way.
31 */
32
33#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
34
35#if !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX))
36
37#include <linux/clocksource.h>
38
39/*
40 * offset_32k holds the init time counter value. It is then subtracted
41 * from every counter read to achieve a counter that counts time from the
42 * kernel boot (needed for sched_clock()).
43 */
44static u32 offset_32k __read_mostly;
45
46#ifdef CONFIG_ARCH_OMAP16XX
47static cycle_t omap16xx_32k_read(struct clocksource *cs)
48{
49 return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED) - offset_32k;
50}
51#else
52#define omap16xx_32k_read NULL
53#endif
54
55#ifdef CONFIG_ARCH_OMAP2420
56static cycle_t omap2420_32k_read(struct clocksource *cs)
57{
58 return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10) - offset_32k;
59}
60#else
61#define omap2420_32k_read NULL
62#endif
63
64#ifdef CONFIG_ARCH_OMAP2430
65static cycle_t omap2430_32k_read(struct clocksource *cs)
66{
67 return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10) - offset_32k;
68}
69#else
70#define omap2430_32k_read NULL
71#endif
72
73#ifdef CONFIG_ARCH_OMAP3
74static cycle_t omap34xx_32k_read(struct clocksource *cs)
75{
76 return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10) - offset_32k;
77}
78#else
79#define omap34xx_32k_read NULL
80#endif
81
82#ifdef CONFIG_ARCH_OMAP4
83static cycle_t omap44xx_32k_read(struct clocksource *cs)
84{
85 return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10) - offset_32k;
86}
87#else
88#define omap44xx_32k_read NULL
89#endif
90
91/*
92 * Kernel assumes that sched_clock can be called early but may not have
93 * things ready yet.
94 */
95static cycle_t omap_32k_read_dummy(struct clocksource *cs)
96{
97 return 0;
98}
99
100static struct clocksource clocksource_32k = {
101 .name = "32k_counter",
102 .rating = 250,
103 .read = omap_32k_read_dummy,
104 .mask = CLOCKSOURCE_MASK(32),
105 .shift = 10,
106 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
107};
108
109/*
110 * Returns current time from boot in nsecs. It's OK for this to wrap
111 * around for now, as it's just a relative time stamp.
112 */
113unsigned long long sched_clock(void)
114{
115 return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k),
116 clocksource_32k.mult, clocksource_32k.shift);
117}
118
119/**
120 * read_persistent_clock - Return time from a persistent clock.
121 *
122 * Reads the time from a source which isn't disabled during PM, the
123 * 32k sync timer. Convert the cycles elapsed since last read into
124 * nsecs and adds to a monotonically increasing timespec.
125 */
126static struct timespec persistent_ts;
127static cycles_t cycles, last_cycles;
128void read_persistent_clock(struct timespec *ts)
129{
130 unsigned long long nsecs;
131 cycles_t delta;
132 struct timespec *tsp = &persistent_ts;
133
134 last_cycles = cycles;
135 cycles = clocksource_32k.read(&clocksource_32k);
136 delta = cycles - last_cycles;
137
138 nsecs = clocksource_cyc2ns(delta,
139 clocksource_32k.mult, clocksource_32k.shift);
140
141 timespec_add_ns(tsp, nsecs);
142 *ts = *tsp;
143}
144
145static int __init omap_init_clocksource_32k(void)
146{
147 static char err[] __initdata = KERN_ERR
148 "%s: can't register clocksource!\n";
149
150 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
151 struct clk *sync_32k_ick;
152
153 if (cpu_is_omap16xx())
154 clocksource_32k.read = omap16xx_32k_read;
155 else if (cpu_is_omap2420())
156 clocksource_32k.read = omap2420_32k_read;
157 else if (cpu_is_omap2430())
158 clocksource_32k.read = omap2430_32k_read;
159 else if (cpu_is_omap34xx())
160 clocksource_32k.read = omap34xx_32k_read;
161 else if (cpu_is_omap44xx())
162 clocksource_32k.read = omap44xx_32k_read;
163 else
164 return -ENODEV;
165
166 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
167 if (sync_32k_ick)
168 clk_enable(sync_32k_ick);
169
170 clocksource_32k.mult = clocksource_hz2mult(32768,
171 clocksource_32k.shift);
172
173 offset_32k = clocksource_32k.read(&clocksource_32k);
174
175 if (clocksource_register(&clocksource_32k))
176 printk(err, clocksource_32k.name);
177 }
178 return 0;
179}
180arch_initcall(omap_init_clocksource_32k);
181
182#endif /* !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX)) */
183
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index 6d3d33360056..11c54ec8d47f 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -40,7 +40,7 @@ static struct clk *mpu_clk;
40 40
41/* TODO: Add support for SDRAM timing changes */ 41/* TODO: Add support for SDRAM timing changes */
42 42
43int omap_verify_speed(struct cpufreq_policy *policy) 43static int omap_verify_speed(struct cpufreq_policy *policy)
44{ 44{
45 if (freq_table) 45 if (freq_table)
46 return cpufreq_frequency_table_verify(policy, freq_table); 46 return cpufreq_frequency_table_verify(policy, freq_table);
@@ -58,7 +58,7 @@ int omap_verify_speed(struct cpufreq_policy *policy)
58 return 0; 58 return 0;
59} 59}
60 60
61unsigned int omap_getspeed(unsigned int cpu) 61static unsigned int omap_getspeed(unsigned int cpu)
62{ 62{
63 unsigned long rate; 63 unsigned long rate;
64 64
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index d1920be7833b..fc819120978d 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -15,13 +15,13 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/memblock.h>
18 19
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
21#include <asm/mach/map.h> 22#include <asm/mach/map.h>
22 23
23#include <plat/tc.h> 24#include <plat/tc.h>
24#include <plat/control.h>
25#include <plat/board.h> 25#include <plat/board.h>
26#include <plat/mmc.h> 26#include <plat/mmc.h>
27#include <mach/gpio.h> 27#include <mach/gpio.h>
@@ -272,6 +272,37 @@ static void omap_init_wdt(void)
272static inline void omap_init_wdt(void) {} 272static inline void omap_init_wdt(void) {}
273#endif 273#endif
274 274
275#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
276
277static phys_addr_t omap_dsp_phys_mempool_base;
278
279void __init omap_dsp_reserve_sdram_memblock(void)
280{
281 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
282 phys_addr_t paddr;
283
284 if (!size)
285 return;
286
287 paddr = memblock_alloc(size, SZ_1M);
288 if (!paddr) {
289 pr_err("%s: failed to reserve %x bytes\n",
290 __func__, size);
291 return;
292 }
293 memblock_free(paddr, size);
294 memblock_remove(paddr, size);
295
296 omap_dsp_phys_mempool_base = paddr;
297}
298
299phys_addr_t omap_dsp_get_mempool_base(void)
300{
301 return omap_dsp_phys_mempool_base;
302}
303EXPORT_SYMBOL(omap_dsp_get_mempool_base);
304#endif
305
275/* 306/*
276 * This gets called after board-specific INIT_MACHINE, and initializes most 307 * This gets called after board-specific INIT_MACHINE, and initializes most
277 * on-chip peripherals accessible on this board (except for few like USB): 308 * on-chip peripherals accessible on this board (except for few like USB):
@@ -300,7 +331,6 @@ static int __init omap_init_devices(void)
300 omap_init_rng(); 331 omap_init_rng();
301 omap_init_mcpdm(); 332 omap_init_mcpdm();
302 omap_init_uwire(); 333 omap_init_uwire();
303 omap_init_wdt();
304 return 0; 334 return 0;
305} 335}
306arch_initcall(omap_init_devices); 336arch_initcall(omap_init_devices);
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index ec7eddf9e525..2c2826571d45 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -30,6 +30,7 @@
30#include <linux/irq.h> 30#include <linux/irq.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/delay.h>
33 34
34#include <asm/system.h> 35#include <asm/system.h>
35#include <mach/hardware.h> 36#include <mach/hardware.h>
@@ -996,11 +997,17 @@ void omap_start_dma(int lch)
996 l = dma_read(CCR(lch)); 997 l = dma_read(CCR(lch));
997 998
998 /* 999 /*
999 * Errata: On ES2.0 BUFFERING disable must be set. 1000 * Errata: Inter Frame DMA buffering issue (All OMAP2420 and
1000 * This will always fail on ES1.0 1001 * OMAP2430ES1.0): DMA will wrongly buffer elements if packing and
1002 * bursting is enabled. This might result in data gets stalled in
1003 * FIFO at the end of the block.
1004 * Workaround: DMA channels must have BUFFERING_DISABLED bit set to
1005 * guarantee no data will stay in the DMA FIFO in case inter frame
1006 * buffering occurs.
1001 */ 1007 */
1002 if (cpu_is_omap24xx()) 1008 if (cpu_is_omap2420() ||
1003 l |= OMAP_DMA_CCR_EN; 1009 (cpu_is_omap2430() && (omap_type() == OMAP2430_REV_ES1_0)))
1010 l |= OMAP_DMA_CCR_BUFFERING_DISABLE;
1004 1011
1005 l |= OMAP_DMA_CCR_EN; 1012 l |= OMAP_DMA_CCR_EN;
1006 dma_write(l, CCR(lch)); 1013 dma_write(l, CCR(lch));
@@ -1018,8 +1025,39 @@ void omap_stop_dma(int lch)
1018 dma_write(0, CICR(lch)); 1025 dma_write(0, CICR(lch));
1019 1026
1020 l = dma_read(CCR(lch)); 1027 l = dma_read(CCR(lch));
1021 l &= ~OMAP_DMA_CCR_EN; 1028 /* OMAP3 Errata i541: sDMA FIFO draining does not finish */
1022 dma_write(l, CCR(lch)); 1029 if (cpu_is_omap34xx() && (l & OMAP_DMA_CCR_SEL_SRC_DST_SYNC)) {
1030 int i = 0;
1031 u32 sys_cf;
1032
1033 /* Configure No-Standby */
1034 l = dma_read(OCP_SYSCONFIG);
1035 sys_cf = l;
1036 l &= ~DMA_SYSCONFIG_MIDLEMODE_MASK;
1037 l |= DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_NO_IDLE);
1038 dma_write(l , OCP_SYSCONFIG);
1039
1040 l = dma_read(CCR(lch));
1041 l &= ~OMAP_DMA_CCR_EN;
1042 dma_write(l, CCR(lch));
1043
1044 /* Wait for sDMA FIFO drain */
1045 l = dma_read(CCR(lch));
1046 while (i < 100 && (l & (OMAP_DMA_CCR_RD_ACTIVE |
1047 OMAP_DMA_CCR_WR_ACTIVE))) {
1048 udelay(5);
1049 i++;
1050 l = dma_read(CCR(lch));
1051 }
1052 if (i >= 100)
1053 printk(KERN_ERR "DMA drain did not complete on "
1054 "lch %d\n", lch);
1055 /* Restore OCP_SYSCONFIG */
1056 dma_write(sys_cf, OCP_SYSCONFIG);
1057 } else {
1058 l &= ~OMAP_DMA_CCR_EN;
1059 dma_write(l, CCR(lch));
1060 }
1023 1061
1024 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 1062 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
1025 int next_lch, cur_lch = lch; 1063 int next_lch, cur_lch = lch;
@@ -1945,6 +1983,8 @@ static int omap2_dma_handle_ch(int ch)
1945 1983
1946 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch)); 1984 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch));
1947 dma_write(1 << ch, IRQSTATUS_L0); 1985 dma_write(1 << ch, IRQSTATUS_L0);
1986 /* read back the register to flush the write */
1987 dma_read(IRQSTATUS_L0);
1948 1988
1949 /* If the ch is not chained then chain_id will be -1 */ 1989 /* If the ch is not chained then chain_id will be -1 */
1950 if (dma_chan[ch].chain_id != -1) { 1990 if (dma_chan[ch].chain_id != -1) {
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 44bafdab2dce..1d706cf63ca0 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -581,7 +581,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
581 * When the functional clock disappears, too quick writes seem 581 * When the functional clock disappears, too quick writes seem
582 * to cause an abort. XXX Is this still necessary? 582 * to cause an abort. XXX Is this still necessary?
583 */ 583 */
584 __delay(150000); 584 __delay(300000);
585 585
586 return ret; 586 return ret;
587} 587}
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 71934817e172..c9e5d7298c40 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -36,6 +36,8 @@
36#include <plat/board.h> 36#include <plat/board.h>
37#include <plat/sram.h> 37#include <plat/sram.h>
38 38
39#include "fb.h"
40
39#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE) 41#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
40 42
41static struct omapfb_platform_data omapfb_config; 43static struct omapfb_platform_data omapfb_config;
@@ -94,7 +96,7 @@ static int fbmem_region_reserved(unsigned long start, size_t size)
94 * Get the region_idx`th region from board config/ATAG and convert it to 96 * Get the region_idx`th region from board config/ATAG and convert it to
95 * our internal format. 97 * our internal format.
96 */ 98 */
97static int get_fbmem_region(int region_idx, struct omapfb_mem_region *rg) 99static int __init get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
98{ 100{
99 const struct omap_fbmem_config *conf; 101 const struct omap_fbmem_config *conf;
100 u32 paddr; 102 u32 paddr;
@@ -126,7 +128,7 @@ static int set_fbmem_region_type(struct omapfb_mem_region *rg, int mem_type,
126 * type = 0 && paddr = 0, a default don't care case maps to 128 * type = 0 && paddr = 0, a default don't care case maps to
127 * the SDRAM type. 129 * the SDRAM type.
128 */ 130 */
129 if (rg->type || (!rg->type && !rg->paddr)) 131 if (rg->type || !rg->paddr)
130 return 0; 132 return 0;
131 if (ranges_overlap(rg->paddr, rg->size, mem_start, mem_size)) { 133 if (ranges_overlap(rg->paddr, rg->size, mem_start, mem_size)) {
132 rg->type = mem_type; 134 rg->type = mem_type;
@@ -258,7 +260,7 @@ void __init omapfb_reserve_sdram_memblock(void)
258 * this point, since the driver built as a module would have problem with 260 * this point, since the driver built as a module would have problem with
259 * freeing / reallocating the regions. 261 * freeing / reallocating the regions.
260 */ 262 */
261unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 263unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
262 unsigned long sram_vstart, 264 unsigned long sram_vstart,
263 unsigned long sram_size, 265 unsigned long sram_size,
264 unsigned long pstart_avail, 266 unsigned long pstart_avail,
@@ -332,7 +334,7 @@ void omapfb_set_ctrl_platform_data(void *data)
332 omapfb_config.ctrl_platform_data = data; 334 omapfb_config.ctrl_platform_data = data;
333} 335}
334 336
335static inline int omap_init_fb(void) 337static int __init omap_init_fb(void)
336{ 338{
337 const struct omap_lcd_config *conf; 339 const struct omap_lcd_config *conf;
338 340
@@ -377,7 +379,7 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data)
377 omapfb_config = *data; 379 omapfb_config = *data;
378} 380}
379 381
380static inline int omap_init_fb(void) 382static int __init omap_init_fb(void)
381{ 383{
382 return platform_device_register(&omap_fb_device); 384 return platform_device_register(&omap_fb_device);
383} 385}
@@ -388,7 +390,7 @@ void omapfb_reserve_sdram_memblock(void)
388{ 390{
389} 391}
390 392
391unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 393unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
392 unsigned long sram_vstart, 394 unsigned long sram_vstart,
393 unsigned long sram_size, 395 unsigned long sram_size,
394 unsigned long start_avail, 396 unsigned long start_avail,
@@ -407,7 +409,7 @@ void omapfb_reserve_sdram_memblock(void)
407{ 409{
408} 410}
409 411
410unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 412unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
411 unsigned long sram_vstart, 413 unsigned long sram_vstart,
412 unsigned long sram_size, 414 unsigned long sram_size,
413 unsigned long start_avail, 415 unsigned long start_avail,
diff --git a/arch/arm/plat-omap/fb.h b/arch/arm/plat-omap/fb.h
new file mode 100644
index 000000000000..d765d0bd8520
--- /dev/null
+++ b/arch/arm/plat-omap/fb.h
@@ -0,0 +1,10 @@
1#ifndef __PLAT_OMAP_FB_H__
2#define __PLAT_OMAP_FB_H__
3
4extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
5 unsigned long sram_vstart,
6 unsigned long sram_size,
7 unsigned long pstart_avail,
8 unsigned long size_avail);
9
10#endif /* __PLAT_OMAP_FB_H__ */
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 7951eefe1a0e..c05c653d1674 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -2084,9 +2084,10 @@ void omap2_gpio_prepare_for_idle(int power_state)
2084 2084
2085 for (i = min; i < gpio_bank_count; i++) { 2085 for (i = min; i < gpio_bank_count; i++) {
2086 struct gpio_bank *bank = &gpio_bank[i]; 2086 struct gpio_bank *bank = &gpio_bank[i];
2087 u32 l1, l2; 2087 u32 l1 = 0, l2 = 0;
2088 int j;
2088 2089
2089 if (bank->dbck_enable_mask) 2090 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
2090 clk_disable(bank->dbck); 2091 clk_disable(bank->dbck);
2091 2092
2092 if (power_state > PWRDM_POWER_OFF) 2093 if (power_state > PWRDM_POWER_OFF)
@@ -2151,9 +2152,10 @@ void omap2_gpio_resume_after_idle(void)
2151 min = 1; 2152 min = 1;
2152 for (i = min; i < gpio_bank_count; i++) { 2153 for (i = min; i < gpio_bank_count; i++) {
2153 struct gpio_bank *bank = &gpio_bank[i]; 2154 struct gpio_bank *bank = &gpio_bank[i];
2154 u32 l, gen, gen0, gen1; 2155 u32 l = 0, gen, gen0, gen1;
2156 int j;
2155 2157
2156 if (bank->dbck_enable_mask) 2158 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
2157 clk_enable(bank->dbck); 2159 clk_enable(bank->dbck);
2158 2160
2159 if (!workaround_enabled) 2161 if (!workaround_enabled)
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index 9776b41ad76f..a9d69a09920d 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -47,6 +47,7 @@ struct omap_globals {
47 unsigned long sdrc; /* SDRAM Controller */ 47 unsigned long sdrc; /* SDRAM Controller */
48 unsigned long sms; /* SDRAM Memory Scheduler */ 48 unsigned long sms; /* SDRAM Memory Scheduler */
49 unsigned long ctrl; /* System Control Module */ 49 unsigned long ctrl; /* System Control Module */
50 unsigned long ctrl_pad; /* PAD Control Module */
50 unsigned long prm; /* Power and Reset Management */ 51 unsigned long prm; /* Power and Reset Management */
51 unsigned long cm; /* Clock Management */ 52 unsigned long cm; /* Clock Management */
52 unsigned long cm2; 53 unsigned long cm2;
@@ -66,7 +67,6 @@ void omap2_set_globals_tap(struct omap_globals *);
66void omap2_set_globals_sdrc(struct omap_globals *); 67void omap2_set_globals_sdrc(struct omap_globals *);
67void omap2_set_globals_control(struct omap_globals *); 68void omap2_set_globals_control(struct omap_globals *);
68void omap2_set_globals_prcm(struct omap_globals *); 69void omap2_set_globals_prcm(struct omap_globals *);
69void omap2_set_globals_uart(struct omap_globals *);
70 70
71void omap3_map_io(void); 71void omap3_map_io(void);
72 72
@@ -91,7 +91,8 @@ void omap3_map_io(void);
91}) 91})
92 92
93extern struct device *omap2_get_mpuss_device(void); 93extern struct device *omap2_get_mpuss_device(void);
94extern struct device *omap2_get_dsp_device(void); 94extern struct device *omap2_get_iva_device(void);
95extern struct device *omap2_get_l3_device(void); 95extern struct device *omap2_get_l3_device(void);
96extern struct device *omap4_get_dsp_device(void);
96 97
97#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */ 98#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index 2e2ae530fced..3fd8b4055727 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -68,10 +68,9 @@ unsigned int omap_rev(void);
68#define OMAP_REVBITS_00 0x00 68#define OMAP_REVBITS_00 0x00
69#define OMAP_REVBITS_01 0x01 69#define OMAP_REVBITS_01 0x01
70#define OMAP_REVBITS_02 0x02 70#define OMAP_REVBITS_02 0x02
71#define OMAP_REVBITS_10 0x10 71#define OMAP_REVBITS_03 0x03
72#define OMAP_REVBITS_20 0x20 72#define OMAP_REVBITS_04 0x04
73#define OMAP_REVBITS_30 0x30 73#define OMAP_REVBITS_05 0x05
74#define OMAP_REVBITS_40 0x40
75 74
76/* 75/*
77 * Get the CPU revision for OMAP devices 76 * Get the CPU revision for OMAP devices
@@ -363,23 +362,24 @@ IS_OMAP_TYPE(3517, 0x3517)
363 362
364/* Various silicon revisions for omap2 */ 363/* Various silicon revisions for omap2 */
365#define OMAP242X_CLASS 0x24200024 364#define OMAP242X_CLASS 0x24200024
366#define OMAP2420_REV_ES1_0 0x24200024 365#define OMAP2420_REV_ES1_0 OMAP242X_CLASS
367#define OMAP2420_REV_ES2_0 0x24201024 366#define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (OMAP_REVBITS_01 << 8))
368 367
369#define OMAP243X_CLASS 0x24300024 368#define OMAP243X_CLASS 0x24300024
370#define OMAP2430_REV_ES1_0 0x24300024 369#define OMAP2430_REV_ES1_0 OMAP243X_CLASS
371 370
372#define OMAP343X_CLASS 0x34300034 371#define OMAP343X_CLASS 0x34300034
373#define OMAP3430_REV_ES1_0 0x34300034 372#define OMAP3430_REV_ES1_0 OMAP343X_CLASS
374#define OMAP3430_REV_ES2_0 0x34301034 373#define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (OMAP_REVBITS_01 << 8))
375#define OMAP3430_REV_ES2_1 0x34302034 374#define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (OMAP_REVBITS_02 << 8))
376#define OMAP3430_REV_ES3_0 0x34303034 375#define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (OMAP_REVBITS_03 << 8))
377#define OMAP3430_REV_ES3_1 0x34304034 376#define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (OMAP_REVBITS_04 << 8))
378#define OMAP3430_REV_ES3_1_2 0x34305034 377#define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (OMAP_REVBITS_05 << 8))
379 378
380#define OMAP3630_REV_ES1_0 0x36300034 379#define OMAP363X_CLASS 0x36300034
381#define OMAP3630_REV_ES1_1 0x36300134 380#define OMAP3630_REV_ES1_0 OMAP363X_CLASS
382#define OMAP3630_REV_ES1_2 0x36300234 381#define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (OMAP_REVBITS_01 << 8))
382#define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (OMAP_REVBITS_02 << 8))
383 383
384#define OMAP35XX_CLASS 0x35000034 384#define OMAP35XX_CLASS 0x35000034
385#define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8)) 385#define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8))
@@ -390,7 +390,8 @@ IS_OMAP_TYPE(3517, 0x3517)
390#define OMAP3517_REV(v) (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8)) 390#define OMAP3517_REV(v) (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8))
391 391
392#define OMAP443X_CLASS 0x44300044 392#define OMAP443X_CLASS 0x44300044
393#define OMAP4430_REV_ES1_0 0x44300044 393#define OMAP4430_REV_ES1_0 OMAP443X_CLASS
394#define OMAP4430_REV_ES2_0 0x44301044
394 395
395/* 396/*
396 * omap_chip bits 397 * omap_chip bits
@@ -417,10 +418,12 @@ IS_OMAP_TYPE(3517, 0x3517)
417#define CHIP_IS_OMAP4430ES1 (1 << 8) 418#define CHIP_IS_OMAP4430ES1 (1 << 8)
418#define CHIP_IS_OMAP3630ES1_1 (1 << 9) 419#define CHIP_IS_OMAP3630ES1_1 (1 << 9)
419#define CHIP_IS_OMAP3630ES1_2 (1 << 10) 420#define CHIP_IS_OMAP3630ES1_2 (1 << 10)
421#define CHIP_IS_OMAP4430ES2 (1 << 11)
420 422
421#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430) 423#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
422 424
423#define CHIP_IS_OMAP4430 (CHIP_IS_OMAP4430ES1) 425#define CHIP_IS_OMAP4430 (CHIP_IS_OMAP4430ES1 | \
426 CHIP_IS_OMAP4430ES2)
424 427
425/* 428/*
426 * "GE" here represents "greater than or equal to" in terms of ES 429 * "GE" here represents "greater than or equal to" in terms of ES
diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h
index 8bd15bdb4132..c915a661f1f5 100644
--- a/arch/arm/plat-omap/include/plat/display.h
+++ b/arch/arm/plat-omap/include/plat/display.h
@@ -81,37 +81,6 @@ enum omap_color_mode {
81 OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */ 81 OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
82 OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */ 82 OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
83 OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */ 83 OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
84
85 OMAP_DSS_COLOR_GFX_OMAP2 =
86 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
87 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
88 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
89 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
90
91 OMAP_DSS_COLOR_VID_OMAP2 =
92 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
93 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
94 OMAP_DSS_COLOR_UYVY,
95
96 OMAP_DSS_COLOR_GFX_OMAP3 =
97 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
98 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
99 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
100 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
101 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
102 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
103
104 OMAP_DSS_COLOR_VID1_OMAP3 =
105 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
106 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
107 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
108
109 OMAP_DSS_COLOR_VID2_OMAP3 =
110 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
111 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
112 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
113 OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
114 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
115}; 84};
116 85
117enum omap_lcd_display_type { 86enum omap_lcd_display_type {
diff --git a/arch/arm/plat-omap/include/plat/dma.h b/arch/arm/plat-omap/include/plat/dma.h
index af3a03941add..0cce4ca83aa0 100644
--- a/arch/arm/plat-omap/include/plat/dma.h
+++ b/arch/arm/plat-omap/include/plat/dma.h
@@ -319,6 +319,8 @@
319#define OMAP34XX_DMA_USIM_TX 79 /* S_DMA_78 */ 319#define OMAP34XX_DMA_USIM_TX 79 /* S_DMA_78 */
320#define OMAP34XX_DMA_USIM_RX 80 /* S_DMA_79 */ 320#define OMAP34XX_DMA_USIM_RX 80 /* S_DMA_79 */
321 321
322#define OMAP36XX_DMA_UART4_TX 81 /* S_DMA_80 */
323#define OMAP36XX_DMA_UART4_RX 82 /* S_DMA_81 */
322/*----------------------------------------------------------------------------*/ 324/*----------------------------------------------------------------------------*/
323 325
324#define OMAP1_DMA_TOUT_IRQ (1 << 0) 326#define OMAP1_DMA_TOUT_IRQ (1 << 0)
@@ -335,6 +337,10 @@
335#define OMAP2_DMA_MISALIGNED_ERR_IRQ (1 << 11) 337#define OMAP2_DMA_MISALIGNED_ERR_IRQ (1 << 11)
336 338
337#define OMAP_DMA_CCR_EN (1 << 7) 339#define OMAP_DMA_CCR_EN (1 << 7)
340#define OMAP_DMA_CCR_RD_ACTIVE (1 << 9)
341#define OMAP_DMA_CCR_WR_ACTIVE (1 << 10)
342#define OMAP_DMA_CCR_SEL_SRC_DST_SYNC (1 << 24)
343#define OMAP_DMA_CCR_BUFFERING_DISABLE (1 << 25)
338 344
339#define OMAP_DMA_DATA_TYPE_S8 0x00 345#define OMAP_DMA_DATA_TYPE_S8 0x00
340#define OMAP_DMA_DATA_TYPE_S16 0x01 346#define OMAP_DMA_DATA_TYPE_S16 0x01
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index 20f1054c0a80..dfa3aff9761b 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -45,6 +45,8 @@
45#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02 45#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02
46 46
47struct omap_dm_timer; 47struct omap_dm_timer;
48extern struct omap_dm_timer *gptimer_wakeup;
49extern struct sys_timer omap_timer;
48struct clk; 50struct clk;
49 51
50int omap_dm_timer_init(void); 52int omap_dm_timer_init(void);
diff --git a/arch/arm/plat-omap/include/plat/dsp.h b/arch/arm/plat-omap/include/plat/dsp.h
new file mode 100644
index 000000000000..9c604b390f9f
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/dsp.h
@@ -0,0 +1,31 @@
1#ifndef __OMAP_DSP_H__
2#define __OMAP_DSP_H__
3
4#include <linux/types.h>
5
6struct omap_dsp_platform_data {
7 void (*dsp_set_min_opp) (u8 opp_id);
8 u8 (*dsp_get_opp) (void);
9 void (*cpu_set_freq) (unsigned long f);
10 unsigned long (*cpu_get_freq) (void);
11 unsigned long mpu_speed[6];
12
13 /* functions to write and read PRCM registers */
14 void (*dsp_prm_write)(u32, s16 , u16);
15 u32 (*dsp_prm_read)(s16 , u16);
16 u32 (*dsp_prm_rmw_bits)(u32, u32, s16, s16);
17 void (*dsp_cm_write)(u32, s16 , u16);
18 u32 (*dsp_cm_read)(s16 , u16);
19 u32 (*dsp_cm_rmw_bits)(u32, u32, s16, s16);
20
21 phys_addr_t phys_mempool_base;
22 phys_addr_t phys_mempool_size;
23};
24
25#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
26extern void omap_dsp_reserve_sdram_memblock(void);
27#else
28static inline void omap_dsp_reserve_sdram_memblock(void) { }
29#endif
30
31#endif
diff --git a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
new file mode 100644
index 000000000000..872de0bf1e6b
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
@@ -0,0 +1,35 @@
1/*
2 * arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
3 *
4 * Copyright (C) 2009 Li-Pro.Net
5 * Stephan Linz <linz@li-pro.net>
6 *
7 * Modified from arch/arm/plat-omap/include/plat/gpmc-smc91x.h
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_OMAP_GPMC_SMSC911X_H__
15
16struct omap_smsc911x_platform_data {
17 int cs;
18 int gpio_irq;
19 int gpio_reset;
20 u32 flags;
21};
22
23#if defined(CONFIG_SMSC911X) || \
24 defined(CONFIG_SMSC911X_MODULE)
25
26extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
27
28#else
29
30static inline void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d)
31{
32}
33
34#endif
35#endif
diff --git a/arch/arm/plat-omap/include/plat/i2c.h b/arch/arm/plat-omap/include/plat/i2c.h
index 87f6bf2ea4fa..36a0befd6168 100644
--- a/arch/arm/plat-omap/include/plat/i2c.h
+++ b/arch/arm/plat-omap/include/plat/i2c.h
@@ -18,6 +18,8 @@
18 * 02110-1301 USA 18 * 02110-1301 USA
19 * 19 *
20 */ 20 */
21#ifndef __ASM__ARCH_OMAP_I2C_H
22#define __ASM__ARCH_OMAP_I2C_H
21 23
22#include <linux/i2c.h> 24#include <linux/i2c.h>
23 25
@@ -36,3 +38,5 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
36 38
37void __init omap1_i2c_mux_pins(int bus_id); 39void __init omap1_i2c_mux_pins(int bus_id);
38void __init omap2_i2c_mux_pins(int bus_id); 40void __init omap2_i2c_mux_pins(int bus_id);
41
42#endif /* __ASM__ARCH_OMAP_I2C_H */
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h
index c01d9f08a198..65e20a686713 100644
--- a/arch/arm/plat-omap/include/plat/irqs.h
+++ b/arch/arm/plat-omap/include/plat/irqs.h
@@ -345,6 +345,8 @@
345#define INT_34XX_MMC3_IRQ 94 345#define INT_34XX_MMC3_IRQ 94
346#define INT_34XX_GPT12_IRQ 95 346#define INT_34XX_GPT12_IRQ 95
347 347
348#define INT_36XX_UART4_IRQ 80
349
348#define INT_35XX_HECC0_IRQ 24 350#define INT_35XX_HECC0_IRQ 24
349#define INT_35XX_HECC1_IRQ 28 351#define INT_35XX_HECC1_IRQ 28
350#define INT_35XX_EMAC_C0_RXTHRESH_IRQ 67 352#define INT_35XX_EMAC_C0_RXTHRESH_IRQ 67
diff --git a/arch/arm/plat-omap/include/plat/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h
index b4ff6a11a8f2..b87d83ccd545 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -30,6 +30,13 @@
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <plat/clock.h> 31#include <plat/clock.h>
32 32
33/* macro for building platform_device for McBSP ports */
34#define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
35static struct platform_device omap_mcbsp##port_nr = { \
36 .name = "omap-mcbsp-dai", \
37 .id = OMAP_MCBSP##port_nr, \
38}
39
33#define OMAP7XX_MCBSP1_BASE 0xfffb1000 40#define OMAP7XX_MCBSP1_BASE 0xfffb1000
34#define OMAP7XX_MCBSP2_BASE 0xfffb1800 41#define OMAP7XX_MCBSP2_BASE 0xfffb1800
35 42
@@ -312,6 +319,18 @@
312#define RFSREN 0x0002 319#define RFSREN 0x0002
313#define RSYNCERREN 0x0001 320#define RSYNCERREN 0x0001
314 321
322/* CLKR signal muxing options */
323#define CLKR_SRC_CLKR 0
324#define CLKR_SRC_CLKX 1
325
326/* FSR signal muxing options */
327#define FSR_SRC_FSR 0
328#define FSR_SRC_FSX 1
329
330/* McBSP functional clock sources */
331#define MCBSP_CLKS_PRCM_SRC 0
332#define MCBSP_CLKS_PAD_SRC 1
333
315/* we don't do multichannel for now */ 334/* we don't do multichannel for now */
316struct omap_mcbsp_reg_cfg { 335struct omap_mcbsp_reg_cfg {
317 u16 spcr2; 336 u16 spcr2;
@@ -398,6 +417,7 @@ struct omap_mcbsp_spi_cfg {
398struct omap_mcbsp_ops { 417struct omap_mcbsp_ops {
399 void (*request)(unsigned int); 418 void (*request)(unsigned int);
400 void (*free)(unsigned int); 419 void (*free)(unsigned int);
420 int (*set_clks_src)(u8, u8);
401}; 421};
402 422
403struct omap_mcbsp_platform_data { 423struct omap_mcbsp_platform_data {
@@ -464,6 +484,9 @@ struct omap_mcbsp {
464extern struct omap_mcbsp **mcbsp_ptr; 484extern struct omap_mcbsp **mcbsp_ptr;
465extern int omap_mcbsp_count, omap_mcbsp_cache_size; 485extern int omap_mcbsp_count, omap_mcbsp_cache_size;
466 486
487#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
488#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
489
467int omap_mcbsp_init(void); 490int omap_mcbsp_init(void);
468void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, 491void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
469 int size); 492 int size);
@@ -502,6 +525,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
502int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word); 525int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
503 526
504 527
528/* McBSP functional clock source changing function */
529extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
505/* SPI specific API */ 530/* SPI specific API */
506void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg); 531void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
507 532
@@ -510,6 +535,10 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
510int omap_mcbsp_pollwrite(unsigned int id, u16 buf); 535int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
511int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type); 536int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
512 537
538/* McBSP signal muxing API */
539void omap2_mcbsp1_mux_clkr_src(u8 mux);
540void omap2_mcbsp1_mux_fsr_src(u8 mux);
541
513#ifdef CONFIG_ARCH_OMAP3 542#ifdef CONFIG_ARCH_OMAP3
514/* Sidetone specific API */ 543/* Sidetone specific API */
515int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); 544int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
diff --git a/arch/arm/plat-omap/include/plat/mmc.h b/arch/arm/plat-omap/include/plat/mmc.h
index 9b89ec601ee2..f57f36abb07e 100644
--- a/arch/arm/plat-omap/include/plat/mmc.h
+++ b/arch/arm/plat-omap/include/plat/mmc.h
@@ -71,12 +71,17 @@ struct omap_mmc_platform_data {
71 71
72 u64 dma_mask; 72 u64 dma_mask;
73 73
74 /* Register offset deviation */
75 u16 reg_offset;
76
74 struct omap_mmc_slot_data { 77 struct omap_mmc_slot_data {
75 78
76 /* 4 wire signaling is optional, and is used for SD/SDIO/HSMMC; 79 /*
77 * 8 wire signaling is also optional, and is used with HSMMC 80 * 4/8 wires and any additional host capabilities
81 * need to OR'd all capabilities (ref. linux/mmc/host.h)
78 */ 82 */
79 u8 wires; 83 u8 wires; /* Used for the MMC driver on omap1 and 2420 */
84 u32 caps; /* Used for the MMC driver on 2430 and later */
80 85
81 /* 86 /*
82 * nomux means "standard" muxing is wrong on this board, and 87 * nomux means "standard" muxing is wrong on this board, and
@@ -104,6 +109,7 @@ struct omap_mmc_platform_data {
104 109
105 /* we can put the features above into this variable */ 110 /* we can put the features above into this variable */
106#define HSMMC_HAS_PBIAS (1 << 0) 111#define HSMMC_HAS_PBIAS (1 << 0)
112#define HSMMC_HAS_UPDATED_RESET (1 << 1)
107 unsigned features; 113 unsigned features;
108 114
109 int switch_pin; /* gpio (card detect) */ 115 int switch_pin; /* gpio (card detect) */
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h
new file mode 100644
index 000000000000..c8dae02f0704
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -0,0 +1,128 @@
1/*
2 * Driver for OMAP-UART controller.
3 * Based on drivers/serial/8250.c
4 *
5 * Copyright (C) 2010 Texas Instruments.
6 *
7 * Authors:
8 * Govindraj R <govindraj.raja@ti.com>
9 * Thara Gopinath <thara@ti.com>
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 as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef __OMAP_SERIAL_H__
18#define __OMAP_SERIAL_H__
19
20#include <linux/serial_core.h>
21#include <linux/platform_device.h>
22
23#include <plat/mux.h>
24
25#define DRIVER_NAME "omap-hsuart"
26
27/*
28 * Use tty device name as ttyO, [O -> OMAP]
29 * in bootargs we specify as console=ttyO0 if uart1
30 * is used as console uart.
31 */
32#define OMAP_SERIAL_NAME "ttyO"
33
34#define OMAP_MDR1_DISABLE 0x07
35#define OMAP_MDR1_MODE13X 0x03
36#define OMAP_MDR1_MODE16X 0x00
37#define OMAP_MODE13X_SPEED 230400
38
39/*
40 * LCR = 0XBF: Switch to Configuration Mode B.
41 * In configuration mode b allow access
42 * to EFR,DLL,DLH.
43 * Reference OMAP TRM Chapter 17
44 * Section: 1.4.3 Mode Selection
45 */
46#define OMAP_UART_LCR_CONF_MDB 0XBF
47
48/* WER = 0x7F
49 * Enable module level wakeup in WER reg
50 */
51#define OMAP_UART_WER_MOD_WKUP 0X7F
52
53/* Enable XON/XOFF flow control on output */
54#define OMAP_UART_SW_TX 0x04
55
56/* Enable XON/XOFF flow control on input */
57#define OMAP_UART_SW_RX 0x04
58
59#define OMAP_UART_SYSC_RESET 0X07
60#define OMAP_UART_TCR_TRIG 0X0F
61#define OMAP_UART_SW_CLR 0XF0
62#define OMAP_UART_FIFO_CLR 0X06
63
64#define OMAP_UART_DMA_CH_FREE -1
65
66#define RX_TIMEOUT (3 * HZ)
67#define OMAP_MAX_HSUART_PORTS 4
68
69#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
70
71struct omap_uart_port_info {
72 bool dma_enabled; /* To specify DMA Mode */
73 unsigned int uartclk; /* UART clock rate */
74 void __iomem *membase; /* ioremap cookie or NULL */
75 resource_size_t mapbase; /* resource base */
76 unsigned long irqflags; /* request_irq flags */
77 upf_t flags; /* UPF_* flags */
78};
79
80struct uart_omap_dma {
81 u8 uart_dma_tx;
82 u8 uart_dma_rx;
83 int rx_dma_channel;
84 int tx_dma_channel;
85 dma_addr_t rx_buf_dma_phys;
86 dma_addr_t tx_buf_dma_phys;
87 unsigned int uart_base;
88 /*
89 * Buffer for rx dma.It is not required for tx because the buffer
90 * comes from port structure.
91 */
92 unsigned char *rx_buf;
93 unsigned int prev_rx_dma_pos;
94 int tx_buf_size;
95 int tx_dma_used;
96 int rx_dma_used;
97 spinlock_t tx_lock;
98 spinlock_t rx_lock;
99 /* timer to poll activity on rx dma */
100 struct timer_list rx_timer;
101 int rx_buf_size;
102 int rx_timeout;
103};
104
105struct uart_omap_port {
106 struct uart_port port;
107 struct uart_omap_dma uart_dma;
108 struct platform_device *pdev;
109
110 unsigned char ier;
111 unsigned char lcr;
112 unsigned char mcr;
113 unsigned char fcr;
114 unsigned char efr;
115
116 int use_dma;
117 /*
118 * Some bits in registers are cleared on a read, so they must
119 * be saved whenever the register is read but the bits will not
120 * be immediately processed.
121 */
122 unsigned int lsr_break_flag;
123 unsigned char msr_saved_flags;
124 char name[20];
125 unsigned long port_activity;
126};
127
128#endif /* __OMAP_SERIAL_H__ */
diff --git a/arch/arm/plat-omap/include/plat/omap24xx.h b/arch/arm/plat-omap/include/plat/omap24xx.h
index 7055672a8c68..92df9e27cc5c 100644
--- a/arch/arm/plat-omap/include/plat/omap24xx.h
+++ b/arch/arm/plat-omap/include/plat/omap24xx.h
@@ -40,7 +40,7 @@
40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000) 40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000)
41#define OMAP24XX_IVA_INTC_BASE 0x40000000 41#define OMAP24XX_IVA_INTC_BASE 0x40000000
42 42
43#define OMAP2420_CTRL_BASE L4_24XX_BASE 43#define OMAP242X_CTRL_BASE L4_24XX_BASE
44#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000) 44#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000)
45#define OMAP2420_PRCM_BASE (L4_24XX_BASE + 0x8000) 45#define OMAP2420_PRCM_BASE (L4_24XX_BASE + 0x8000)
46#define OMAP2420_CM_BASE (L4_24XX_BASE + 0x8000) 46#define OMAP2420_CM_BASE (L4_24XX_BASE + 0x8000)
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/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 25cd9ac3b095..28e2d1a78433 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -36,6 +36,8 @@
36 36
37#include <plat/omap_hwmod.h> 37#include <plat/omap_hwmod.h>
38 38
39extern struct device omap_device_parent;
40
39/* omap_device._state values */ 41/* omap_device._state values */
40#define OMAP_DEVICE_STATE_UNKNOWN 0 42#define OMAP_DEVICE_STATE_UNKNOWN 0
41#define OMAP_DEVICE_STATE_ENABLED 1 43#define OMAP_DEVICE_STATE_ENABLED 1
@@ -62,7 +64,6 @@
62 * 64 *
63 */ 65 */
64struct omap_device { 66struct omap_device {
65 u32 magic;
66 struct platform_device pdev; 67 struct platform_device pdev;
67 struct omap_hwmod **hwmods; 68 struct omap_hwmod **hwmods;
68 struct omap_device_pm_latency *pm_lats; 69 struct omap_device_pm_latency *pm_lats;
@@ -82,7 +83,6 @@ int omap_device_shutdown(struct platform_device *pdev);
82 83
83/* Core code interface */ 84/* Core code interface */
84 85
85bool omap_device_is_valid(struct omap_device *od);
86int omap_device_count_resources(struct omap_device *od); 86int omap_device_count_resources(struct omap_device *od);
87int omap_device_fill_resources(struct omap_device *od, struct resource *res); 87int omap_device_fill_resources(struct omap_device *od, struct resource *res);
88 88
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index a4e508dfaba2..7eaa8edf3b14 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -14,19 +14,16 @@
14 * 14 *
15 * These headers and macros are used to define OMAP on-chip module 15 * These headers and macros are used to define OMAP on-chip module
16 * data and their integration with other OMAP modules and Linux. 16 * data and their integration with other OMAP modules and Linux.
17 * 17 * Copious documentation and references can also be found in the
18 * References: 18 * omap_hwmod code, in arch/arm/mach-omap2/omap_hwmod.c (as of this
19 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064) 19 * writing).
20 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
21 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
22 * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140)
23 * - Open Core Protocol Specification 2.2
24 * 20 *
25 * To do: 21 * To do:
26 * - add interconnect error log structures 22 * - add interconnect error log structures
27 * - add pinmuxing 23 * - add pinmuxing
28 * - init_conn_id_bit (CONNID_BIT_VECTOR) 24 * - init_conn_id_bit (CONNID_BIT_VECTOR)
29 * - implement default hwmod SMS/SDRC flags? 25 * - implement default hwmod SMS/SDRC flags?
26 * - remove unused fields
30 * 27 *
31 */ 28 */
32#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H 29#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
@@ -35,6 +32,7 @@
35#include <linux/kernel.h> 32#include <linux/kernel.h>
36#include <linux/list.h> 33#include <linux/list.h>
37#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/mutex.h>
38#include <plat/cpu.h> 36#include <plat/cpu.h>
39 37
40struct omap_device; 38struct omap_device;
@@ -96,7 +94,7 @@ struct omap_hwmod_irq_info {
96/** 94/**
97 * struct omap_hwmod_dma_info - DMA channels used by the hwmod 95 * struct omap_hwmod_dma_info - DMA channels used by the hwmod
98 * @name: name of the DMA channel (module local name) 96 * @name: name of the DMA channel (module local name)
99 * @dma_ch: DMA channel ID 97 * @dma_req: DMA request ID
100 * 98 *
101 * @name should be something short, e.g., "tx" or "rx". It is for use 99 * @name should be something short, e.g., "tx" or "rx". It is for use
102 * by platform_get_resource_byname(). It is defined locally to the 100 * by platform_get_resource_byname(). It is defined locally to the
@@ -104,7 +102,20 @@ struct omap_hwmod_irq_info {
104 */ 102 */
105struct omap_hwmod_dma_info { 103struct omap_hwmod_dma_info {
106 const char *name; 104 const char *name;
107 u16 dma_ch; 105 u16 dma_req;
106};
107
108/**
109 * struct omap_hwmod_rst_info - IPs reset lines use by hwmod
110 * @name: name of the reset line (module local name)
111 * @rst_shift: Offset of the reset bit
112 *
113 * @name should be something short, e.g., "cpu0" or "rst". It is defined
114 * locally to the hwmod.
115 */
116struct omap_hwmod_rst_info {
117 const char *name;
118 u8 rst_shift;
108}; 119};
109 120
110/** 121/**
@@ -237,8 +248,9 @@ struct omap_hwmod_ocp_if {
237#define SYSC_HAS_CLOCKACTIVITY (1 << 4) 248#define SYSC_HAS_CLOCKACTIVITY (1 << 4)
238#define SYSC_HAS_SIDLEMODE (1 << 5) 249#define SYSC_HAS_SIDLEMODE (1 << 5)
239#define SYSC_HAS_MIDLEMODE (1 << 6) 250#define SYSC_HAS_MIDLEMODE (1 << 6)
240#define SYSS_MISSING (1 << 7) 251#define SYSS_HAS_RESET_STATUS (1 << 7)
241#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */ 252#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */
253#define SYSC_HAS_RESET_STATUS (1 << 9)
242 254
243/* omap_hwmod_sysconfig.clockact flags */ 255/* omap_hwmod_sysconfig.clockact flags */
244#define CLOCKACT_TEST_BOTH 0x0 256#define CLOCKACT_TEST_BOTH 0x0
@@ -327,10 +339,12 @@ struct omap_hwmod_omap2_prcm {
327/** 339/**
328 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data 340 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
329 * @clkctrl_reg: PRCM address of the clock control register 341 * @clkctrl_reg: PRCM address of the clock control register
342 * @rstctrl_reg: adress of the XXX_RSTCTRL register located in the PRM
330 * @submodule_wkdep_bit: bit shift of the WKDEP range 343 * @submodule_wkdep_bit: bit shift of the WKDEP range
331 */ 344 */
332struct omap_hwmod_omap4_prcm { 345struct omap_hwmod_omap4_prcm {
333 void __iomem *clkctrl_reg; 346 void __iomem *clkctrl_reg;
347 void __iomem *rstctrl_reg;
334 u8 submodule_wkdep_bit; 348 u8 submodule_wkdep_bit;
335}; 349};
336 350
@@ -352,6 +366,11 @@ struct omap_hwmod_omap4_prcm {
352 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup 366 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup
353 * HWMOD_NO_IDLEST : this module does not have idle status - this is the case 367 * HWMOD_NO_IDLEST : this module does not have idle status - this is the case
354 * only for few initiator modules on OMAP2 & 3. 368 * only for few initiator modules on OMAP2 & 3.
369 * HWMOD_CONTROL_OPT_CLKS_IN_RESET: Enable all optional clocks during reset.
370 * This is needed for devices like DSS that require optional clocks enabled
371 * in order to complete the reset. Optional clocks will be disabled
372 * again after the reset.
373 * HWMOD_16BIT_REG: Module has 16bit registers
355 */ 374 */
356#define HWMOD_SWSUP_SIDLE (1 << 0) 375#define HWMOD_SWSUP_SIDLE (1 << 0)
357#define HWMOD_SWSUP_MSTANDBY (1 << 1) 376#define HWMOD_SWSUP_MSTANDBY (1 << 1)
@@ -360,6 +379,8 @@ struct omap_hwmod_omap4_prcm {
360#define HWMOD_NO_OCP_AUTOIDLE (1 << 4) 379#define HWMOD_NO_OCP_AUTOIDLE (1 << 4)
361#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 5) 380#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 5)
362#define HWMOD_NO_IDLEST (1 << 6) 381#define HWMOD_NO_IDLEST (1 << 6)
382#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7)
383#define HWMOD_16BIT_REG (1 << 8)
363 384
364/* 385/*
365 * omap_hwmod._int_flags definitions 386 * omap_hwmod._int_flags definitions
@@ -410,7 +431,7 @@ struct omap_hwmod_class {
410 * @class: struct omap_hwmod_class * to the class of this hwmod 431 * @class: struct omap_hwmod_class * to the class of this hwmod
411 * @od: struct omap_device currently associated with this hwmod (internal use) 432 * @od: struct omap_device currently associated with this hwmod (internal use)
412 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt) 433 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt)
413 * @sdma_chs: ptr to an array of SDMA channel IDs (see also sdma_chs_cnt) 434 * @sdma_reqs: ptr to an array of System DMA request IDs (see sdma_reqs_cnt)
414 * @prcm: PRCM data pertaining to this hwmod 435 * @prcm: PRCM data pertaining to this hwmod
415 * @main_clk: main clock: OMAP clock name 436 * @main_clk: main clock: OMAP clock name
416 * @_clk: pointer to the main struct clk (filled in at runtime) 437 * @_clk: pointer to the main struct clk (filled in at runtime)
@@ -424,7 +445,7 @@ struct omap_hwmod_class {
424 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6) 445 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6)
425 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift 446 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift
426 * @mpu_irqs_cnt: number of @mpu_irqs 447 * @mpu_irqs_cnt: number of @mpu_irqs
427 * @sdma_chs_cnt: number of @sdma_chs 448 * @sdma_reqs_cnt: number of @sdma_reqs
428 * @opt_clks_cnt: number of @opt_clks 449 * @opt_clks_cnt: number of @opt_clks
429 * @master_cnt: number of @master entries 450 * @master_cnt: number of @master entries
430 * @slaves_cnt: number of @slave entries 451 * @slaves_cnt: number of @slave entries
@@ -433,6 +454,7 @@ struct omap_hwmod_class {
433 * @_state: internal-use hwmod state 454 * @_state: internal-use hwmod state
434 * @flags: hwmod flags (documented below) 455 * @flags: hwmod flags (documented below)
435 * @omap_chip: OMAP chips this hwmod is present on 456 * @omap_chip: OMAP chips this hwmod is present on
457 * @_mutex: mutex serializing operations on this hwmod
436 * @node: list node for hwmod list (internal use) 458 * @node: list node for hwmod list (internal use)
437 * 459 *
438 * @main_clk refers to this module's "main clock," which for our 460 * @main_clk refers to this module's "main clock," which for our
@@ -448,7 +470,8 @@ struct omap_hwmod {
448 struct omap_hwmod_class *class; 470 struct omap_hwmod_class *class;
449 struct omap_device *od; 471 struct omap_device *od;
450 struct omap_hwmod_irq_info *mpu_irqs; 472 struct omap_hwmod_irq_info *mpu_irqs;
451 struct omap_hwmod_dma_info *sdma_chs; 473 struct omap_hwmod_dma_info *sdma_reqs;
474 struct omap_hwmod_rst_info *rst_lines;
452 union { 475 union {
453 struct omap_hwmod_omap2_prcm omap2; 476 struct omap_hwmod_omap2_prcm omap2;
454 struct omap_hwmod_omap4_prcm omap4; 477 struct omap_hwmod_omap4_prcm omap4;
@@ -461,6 +484,7 @@ struct omap_hwmod {
461 void *dev_attr; 484 void *dev_attr;
462 u32 _sysc_cache; 485 u32 _sysc_cache;
463 void __iomem *_mpu_rt_va; 486 void __iomem *_mpu_rt_va;
487 struct mutex _mutex;
464 struct list_head node; 488 struct list_head node;
465 u16 flags; 489 u16 flags;
466 u8 _mpu_port_index; 490 u8 _mpu_port_index;
@@ -468,7 +492,8 @@ struct omap_hwmod {
468 u8 msuspendmux_shift; 492 u8 msuspendmux_shift;
469 u8 response_lat; 493 u8 response_lat;
470 u8 mpu_irqs_cnt; 494 u8 mpu_irqs_cnt;
471 u8 sdma_chs_cnt; 495 u8 sdma_reqs_cnt;
496 u8 rst_lines_cnt;
472 u8 opt_clks_cnt; 497 u8 opt_clks_cnt;
473 u8 masters_cnt; 498 u8 masters_cnt;
474 u8 slaves_cnt; 499 u8 slaves_cnt;
@@ -492,6 +517,10 @@ int omap_hwmod_idle(struct omap_hwmod *oh);
492int _omap_hwmod_idle(struct omap_hwmod *oh); 517int _omap_hwmod_idle(struct omap_hwmod *oh);
493int omap_hwmod_shutdown(struct omap_hwmod *oh); 518int omap_hwmod_shutdown(struct omap_hwmod *oh);
494 519
520int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name);
521int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name);
522int omap_hwmod_read_hardreset(struct omap_hwmod *oh, const char *name);
523
495int omap_hwmod_enable_clocks(struct omap_hwmod *oh); 524int omap_hwmod_enable_clocks(struct omap_hwmod *oh);
496int omap_hwmod_disable_clocks(struct omap_hwmod *oh); 525int omap_hwmod_disable_clocks(struct omap_hwmod *oh);
497 526
@@ -500,8 +529,8 @@ int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode);
500int omap_hwmod_reset(struct omap_hwmod *oh); 529int omap_hwmod_reset(struct omap_hwmod *oh);
501void omap_hwmod_ocp_barrier(struct omap_hwmod *oh); 530void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
502 531
503void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs); 532void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs);
504u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs); 533u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs);
505 534
506int omap_hwmod_count_resources(struct omap_hwmod *oh); 535int omap_hwmod_count_resources(struct omap_hwmod *oh);
507int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); 536int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res);
@@ -534,5 +563,6 @@ int omap_hwmod_for_each_by_class(const char *classname,
534extern int omap2420_hwmod_init(void); 563extern int omap2420_hwmod_init(void);
535extern int omap2430_hwmod_init(void); 564extern int omap2430_hwmod_init(void);
536extern int omap3xxx_hwmod_init(void); 565extern int omap3xxx_hwmod_init(void);
566extern int omap44xx_hwmod_init(void);
537 567
538#endif 568#endif
diff --git a/arch/arm/plat-omap/include/plat/powerdomain.h b/arch/arm/plat-omap/include/plat/powerdomain.h
index fb6ec74fe39e..9ca420dcd2f8 100644
--- a/arch/arm/plat-omap/include/plat/powerdomain.h
+++ b/arch/arm/plat-omap/include/plat/powerdomain.h
@@ -32,6 +32,7 @@
32 32
33/* Powerdomain allowable state bitfields */ 33/* Powerdomain allowable state bitfields */
34#define PWRSTS_ON (1 << PWRDM_POWER_ON) 34#define PWRSTS_ON (1 << PWRDM_POWER_ON)
35#define PWRSTS_OFF (1 << PWRDM_POWER_OFF)
35#define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \ 36#define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \
36 (1 << PWRDM_POWER_ON)) 37 (1 << PWRDM_POWER_ON))
37 38
@@ -161,5 +162,6 @@ int pwrdm_state_switch(struct powerdomain *pwrdm);
161int pwrdm_clkdm_state_switch(struct clockdomain *clkdm); 162int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
162int pwrdm_pre_transition(void); 163int pwrdm_pre_transition(void);
163int pwrdm_post_transition(void); 164int pwrdm_post_transition(void);
165int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
164 166
165#endif 167#endif
diff --git a/arch/arm/plat-omap/include/plat/prcm.h b/arch/arm/plat-omap/include/plat/prcm.h
index 9fbd91419cd1..ab77442e42ab 100644
--- a/arch/arm/plat-omap/include/plat/prcm.h
+++ b/arch/arm/plat-omap/include/plat/prcm.h
@@ -38,6 +38,8 @@ u32 prm_read_mod_reg(s16 module, u16 idx);
38void prm_write_mod_reg(u32 val, s16 module, u16 idx); 38void prm_write_mod_reg(u32 val, s16 module, u16 idx);
39u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx); 39u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx);
40u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask); 40u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask);
41u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask);
42u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg);
41u32 cm_read_mod_reg(s16 module, u16 idx); 43u32 cm_read_mod_reg(s16 module, u16 idx);
42void cm_write_mod_reg(u32 val, s16 module, u16 idx); 44void cm_write_mod_reg(u32 val, s16 module, u16 idx);
43u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx); 45u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx);
diff --git a/arch/arm/plat-omap/include/plat/sdrc.h b/arch/arm/plat-omap/include/plat/sdrc.h
index 7b76f50564ba..efd87c8dda69 100644
--- a/arch/arm/plat-omap/include/plat/sdrc.h
+++ b/arch/arm/plat-omap/include/plat/sdrc.h
@@ -147,6 +147,7 @@ struct memory_timings {
147}; 147};
148 148
149extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode); 149extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);
150struct omap_sdrc_params *rx51_get_sdram_timings(void);
150 151
151u32 omap2xxx_sdrc_dll_is_unlocked(void); 152u32 omap2xxx_sdrc_dll_is_unlocked(void);
152u32 omap2xxx_sdrc_reprogram(u32 level, u32 force); 153u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h
index 16a1b458d53c..5905100b29a1 100644
--- a/arch/arm/plat-omap/include/plat/sram.h
+++ b/arch/arm/plat-omap/include/plat/sram.h
@@ -11,7 +11,6 @@
11#ifndef __ARCH_ARM_OMAP_SRAM_H 11#ifndef __ARCH_ARM_OMAP_SRAM_H
12#define __ARCH_ARM_OMAP_SRAM_H 12#define __ARCH_ARM_OMAP_SRAM_H
13 13
14extern int __init omap_sram_init(void);
15extern void * omap_sram_push(void * start, unsigned long size); 14extern void * omap_sram_push(void * start, unsigned long size);
16extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl); 15extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl);
17 16
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index ddf723be48dc..9036e374e0ac 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -139,10 +139,14 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
139 DEBUG_LL_OMAP2(1, omap3evm); 139 DEBUG_LL_OMAP2(1, omap3evm);
140 DEBUG_LL_OMAP3(1, omap_3430sdp); 140 DEBUG_LL_OMAP3(1, omap_3430sdp);
141 DEBUG_LL_OMAP3(1, omap_3630sdp); 141 DEBUG_LL_OMAP3(1, omap_3630sdp);
142 DEBUG_LL_OMAP3(1, omap3530_lv_som);
143 DEBUG_LL_OMAP3(1, omap3_torpedo);
142 144
143 /* omap3 based boards using UART3 */ 145 /* omap3 based boards using UART3 */
144 DEBUG_LL_OMAP3(3, cm_t35); 146 DEBUG_LL_OMAP3(3, cm_t35);
147 DEBUG_LL_OMAP3(3, cm_t3517);
145 DEBUG_LL_OMAP3(3, igep0020); 148 DEBUG_LL_OMAP3(3, igep0020);
149 DEBUG_LL_OMAP3(3, igep0030);
146 DEBUG_LL_OMAP3(3, nokia_rx51); 150 DEBUG_LL_OMAP3(3, nokia_rx51);
147 DEBUG_LL_OMAP3(3, omap3517evm); 151 DEBUG_LL_OMAP3(3, omap3517evm);
148 DEBUG_LL_OMAP3(3, omap3_beagle); 152 DEBUG_LL_OMAP3(3, omap3_beagle);
@@ -153,6 +157,7 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
153 157
154 /* omap4 based boards using UART3 */ 158 /* omap4 based boards using UART3 */
155 DEBUG_LL_OMAP4(3, omap_4430sdp); 159 DEBUG_LL_OMAP4(3, omap_4430sdp);
160 DEBUG_LL_OMAP4(3, omap4_panda);
156 161
157 /* zoom2/3 external uart */ 162 /* zoom2/3 external uart */
158 DEBUG_LL_ZOOM(omap_zoom2); 163 DEBUG_LL_ZOOM(omap_zoom2);
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 2a9427c8cc48..59c7fe731f28 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -105,7 +105,7 @@ static inline void omap1_usb_init(struct omap_usb_config *pdata)
105#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE) 105#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE)
106void omap2_usbfs_init(struct omap_usb_config *pdata); 106void omap2_usbfs_init(struct omap_usb_config *pdata);
107#else 107#else
108static inline omap2_usbfs_init(struct omap_usb_config *pdata) 108static inline void omap2_usbfs_init(struct omap_usb_config *pdata)
109{ 109{
110} 110}
111#endif 111#endif
@@ -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/include/plat/vrfb.h b/arch/arm/plat-omap/include/plat/vrfb.h
index d8a03ced3b10..3792bdea2f6d 100644
--- a/arch/arm/plat-omap/include/plat/vrfb.h
+++ b/arch/arm/plat-omap/include/plat/vrfb.h
@@ -35,6 +35,7 @@ struct vrfb {
35 bool yuv_mode; 35 bool yuv_mode;
36}; 36};
37 37
38#ifdef CONFIG_OMAP2_VRFB
38extern int omap_vrfb_request_ctx(struct vrfb *vrfb); 39extern int omap_vrfb_request_ctx(struct vrfb *vrfb);
39extern void omap_vrfb_release_ctx(struct vrfb *vrfb); 40extern void omap_vrfb_release_ctx(struct vrfb *vrfb);
40extern void omap_vrfb_adjust_size(u16 *width, u16 *height, 41extern void omap_vrfb_adjust_size(u16 *width, u16 *height,
@@ -47,4 +48,19 @@ extern void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
47extern int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot); 48extern int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot);
48extern void omap_vrfb_restore_context(void); 49extern void omap_vrfb_restore_context(void);
49 50
51#else
52static inline int omap_vrfb_request_ctx(struct vrfb *vrfb) { return 0; }
53static inline void omap_vrfb_release_ctx(struct vrfb *vrfb) {}
54static inline void omap_vrfb_adjust_size(u16 *width, u16 *height,
55 u8 bytespp) {}
56static inline u32 omap_vrfb_min_phys_size(u16 width, u16 height, u8 bytespp)
57 { return 0; }
58static inline u16 omap_vrfb_max_height(u32 phys_size, u16 width, u8 bytespp)
59 { return 0; }
60static inline void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
61 u16 width, u16 height, unsigned bytespp, bool yuv_mode) {}
62static inline int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot)
63 { return 0; }
64static inline void omap_vrfb_restore_context(void) {}
65#endif
50#endif /* __VRFB_H */ 66#endif /* __VRFB_H */
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/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 0c8612fd8312..eac4b978e9fd 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -33,7 +33,7 @@
33struct omap_mcbsp **mcbsp_ptr; 33struct omap_mcbsp **mcbsp_ptr;
34int omap_mcbsp_count, omap_mcbsp_cache_size; 34int omap_mcbsp_count, omap_mcbsp_cache_size;
35 35
36void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 36static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
37{ 37{
38 if (cpu_class_is_omap1()) { 38 if (cpu_class_is_omap1()) {
39 ((u16 *)mcbsp->reg_cache)[reg / sizeof(u16)] = (u16)val; 39 ((u16 *)mcbsp->reg_cache)[reg / sizeof(u16)] = (u16)val;
@@ -47,7 +47,7 @@ void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
47 } 47 }
48} 48}
49 49
50int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache) 50static int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache)
51{ 51{
52 if (cpu_class_is_omap1()) { 52 if (cpu_class_is_omap1()) {
53 return !from_cache ? __raw_readw(mcbsp->io_base + reg) : 53 return !from_cache ? __raw_readw(mcbsp->io_base + reg) :
@@ -62,12 +62,12 @@ int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache)
62} 62}
63 63
64#ifdef CONFIG_ARCH_OMAP3 64#ifdef CONFIG_ARCH_OMAP3
65void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 65static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
66{ 66{
67 __raw_writel(val, mcbsp->st_data->io_base_st + reg); 67 __raw_writel(val, mcbsp->st_data->io_base_st + reg);
68} 68}
69 69
70int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) 70static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg)
71{ 71{
72 return __raw_readl(mcbsp->st_data->io_base_st + reg); 72 return __raw_readl(mcbsp->st_data->io_base_st + reg);
73} 73}
@@ -80,9 +80,6 @@ int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg)
80#define MCBSP_READ_CACHE(mcbsp, reg) \ 80#define MCBSP_READ_CACHE(mcbsp, reg) \
81 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1) 81 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1)
82 82
83#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
84#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
85
86#define MCBSP_ST_READ(mcbsp, reg) \ 83#define MCBSP_ST_READ(mcbsp, reg) \
87 omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg) 84 omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg)
88#define MCBSP_ST_WRITE(mcbsp, reg, val) \ 85#define MCBSP_ST_WRITE(mcbsp, reg, val) \
@@ -878,7 +875,7 @@ EXPORT_SYMBOL(omap_mcbsp_free);
878void omap_mcbsp_start(unsigned int id, int tx, int rx) 875void omap_mcbsp_start(unsigned int id, int tx, int rx)
879{ 876{
880 struct omap_mcbsp *mcbsp; 877 struct omap_mcbsp *mcbsp;
881 int idle; 878 int enable_srg = 0;
882 u16 w; 879 u16 w;
883 880
884 if (!omap_mcbsp_check_valid_id(id)) { 881 if (!omap_mcbsp_check_valid_id(id)) {
@@ -893,10 +890,13 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
893 mcbsp->rx_word_length = (MCBSP_READ_CACHE(mcbsp, RCR1) >> 5) & 0x7; 890 mcbsp->rx_word_length = (MCBSP_READ_CACHE(mcbsp, RCR1) >> 5) & 0x7;
894 mcbsp->tx_word_length = (MCBSP_READ_CACHE(mcbsp, XCR1) >> 5) & 0x7; 891 mcbsp->tx_word_length = (MCBSP_READ_CACHE(mcbsp, XCR1) >> 5) & 0x7;
895 892
896 idle = !((MCBSP_READ_CACHE(mcbsp, SPCR2) | 893 /* Only enable SRG, if McBSP is master */
897 MCBSP_READ_CACHE(mcbsp, SPCR1)) & 1); 894 w = MCBSP_READ_CACHE(mcbsp, PCR0);
895 if (w & (FSXM | FSRM | CLKXM | CLKRM))
896 enable_srg = !((MCBSP_READ_CACHE(mcbsp, SPCR2) |
897 MCBSP_READ_CACHE(mcbsp, SPCR1)) & 1);
898 898
899 if (idle) { 899 if (enable_srg) {
900 /* Start the sample generator */ 900 /* Start the sample generator */
901 w = MCBSP_READ_CACHE(mcbsp, SPCR2); 901 w = MCBSP_READ_CACHE(mcbsp, SPCR2);
902 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 6)); 902 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 6));
@@ -919,7 +919,7 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
919 */ 919 */
920 udelay(500); 920 udelay(500);
921 921
922 if (idle) { 922 if (enable_srg) {
923 /* Start frame sync */ 923 /* Start frame sync */
924 w = MCBSP_READ_CACHE(mcbsp, SPCR2); 924 w = MCBSP_READ_CACHE(mcbsp, SPCR2);
925 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 7)); 925 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 7));
@@ -1645,7 +1645,7 @@ static const struct attribute_group sidetone_attr_group = {
1645 .attrs = (struct attribute **)sidetone_attrs, 1645 .attrs = (struct attribute **)sidetone_attrs,
1646}; 1646};
1647 1647
1648int __devinit omap_st_add(struct omap_mcbsp *mcbsp) 1648static int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1649{ 1649{
1650 struct omap_mcbsp_platform_data *pdata = mcbsp->pdata; 1650 struct omap_mcbsp_platform_data *pdata = mcbsp->pdata;
1651 struct omap_mcbsp_st_data *st_data; 1651 struct omap_mcbsp_st_data *st_data;
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index d2b160942ccc..abe933cd8f09 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -82,6 +82,7 @@
82#include <linux/slab.h> 82#include <linux/slab.h>
83#include <linux/err.h> 83#include <linux/err.h>
84#include <linux/io.h> 84#include <linux/io.h>
85#include <linux/clk.h>
85 86
86#include <plat/omap_device.h> 87#include <plat/omap_device.h>
87#include <plat/omap_hwmod.h> 88#include <plat/omap_hwmod.h>
@@ -90,12 +91,6 @@
90#define USE_WAKEUP_LAT 0 91#define USE_WAKEUP_LAT 0
91#define IGNORE_WAKEUP_LAT 1 92#define IGNORE_WAKEUP_LAT 1
92 93
93/*
94 * OMAP_DEVICE_MAGIC: used to determine whether a struct omap_device
95 * obtained via container_of() is in fact a struct omap_device
96 */
97#define OMAP_DEVICE_MAGIC 0xf00dcafe
98
99/* Private functions */ 94/* Private functions */
100 95
101/** 96/**
@@ -243,6 +238,44 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
243 return container_of(pdev, struct omap_device, pdev); 238 return container_of(pdev, struct omap_device, pdev);
244} 239}
245 240
241/**
242 * _add_optional_clock_alias - Add clock alias for hwmod optional clocks
243 * @od: struct omap_device *od
244 *
245 * For every optional clock present per hwmod per omap_device, this function
246 * adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role>
247 * if an entry is already present in it with the form <dev-id=NULL, con-id=role>
248 *
249 * The function is called from inside omap_device_build_ss(), after
250 * omap_device_register.
251 *
252 * This allows drivers to get a pointer to its optional clocks based on its role
253 * by calling clk_get(<dev*>, <role>).
254 *
255 * No return value.
256 */
257static void _add_optional_clock_alias(struct omap_device *od,
258 struct omap_hwmod *oh)
259{
260 int i;
261
262 for (i = 0; i < oh->opt_clks_cnt; i++) {
263 struct omap_hwmod_opt_clk *oc;
264 int r;
265
266 oc = &oh->opt_clks[i];
267
268 if (!oc->_clk)
269 continue;
270
271 r = clk_add_alias(oc->role, dev_name(&od->pdev.dev),
272 (char *)oc->clk, &od->pdev.dev);
273 if (r)
274 pr_err("omap_device: %s: clk_add_alias for %s failed\n",
275 dev_name(&od->pdev.dev), oc->role);
276 }
277}
278
246 279
247/* Public functions for use by core code */ 280/* Public functions for use by core code */
248 281
@@ -257,12 +290,11 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
257 */ 290 */
258int omap_device_count_resources(struct omap_device *od) 291int omap_device_count_resources(struct omap_device *od)
259{ 292{
260 struct omap_hwmod *oh;
261 int c = 0; 293 int c = 0;
262 int i; 294 int i;
263 295
264 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 296 for (i = 0; i < od->hwmods_cnt; i++)
265 c += omap_hwmod_count_resources(oh); 297 c += omap_hwmod_count_resources(od->hwmods[i]);
266 298
267 pr_debug("omap_device: %s: counted %d total resources across %d " 299 pr_debug("omap_device: %s: counted %d total resources across %d "
268 "hwmods\n", od->pdev.name, c, od->hwmods_cnt); 300 "hwmods\n", od->pdev.name, c, od->hwmods_cnt);
@@ -289,12 +321,11 @@ int omap_device_count_resources(struct omap_device *od)
289 */ 321 */
290int omap_device_fill_resources(struct omap_device *od, struct resource *res) 322int omap_device_fill_resources(struct omap_device *od, struct resource *res)
291{ 323{
292 struct omap_hwmod *oh;
293 int c = 0; 324 int c = 0;
294 int i, r; 325 int i, r;
295 326
296 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) { 327 for (i = 0; i < od->hwmods_cnt; i++) {
297 r = omap_hwmod_fill_resources(oh, res); 328 r = omap_hwmod_fill_resources(od->hwmods[i], res);
298 res += r; 329 res += r;
299 c += r; 330 c += r;
300 } 331 }
@@ -414,15 +445,15 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
414 od->pm_lats = pm_lats; 445 od->pm_lats = pm_lats;
415 od->pm_lats_cnt = pm_lats_cnt; 446 od->pm_lats_cnt = pm_lats_cnt;
416 447
417 od->magic = OMAP_DEVICE_MAGIC;
418
419 if (is_early_device) 448 if (is_early_device)
420 ret = omap_early_device_register(od); 449 ret = omap_early_device_register(od);
421 else 450 else
422 ret = omap_device_register(od); 451 ret = omap_device_register(od);
423 452
424 for (i = 0; i < oh_cnt; i++) 453 for (i = 0; i < oh_cnt; i++) {
425 hwmods[i]->od = od; 454 hwmods[i]->od = od;
455 _add_optional_clock_alias(od, hwmods[i]);
456 }
426 457
427 if (ret) 458 if (ret)
428 goto odbs_exit4; 459 goto odbs_exit4;
@@ -473,6 +504,7 @@ int omap_device_register(struct omap_device *od)
473{ 504{
474 pr_debug("omap_device: %s: registering\n", od->pdev.name); 505 pr_debug("omap_device: %s: registering\n", od->pdev.name);
475 506
507 od->pdev.dev.parent = &omap_device_parent;
476 return platform_device_register(&od->pdev); 508 return platform_device_register(&od->pdev);
477} 509}
478 510
@@ -566,7 +598,6 @@ int omap_device_shutdown(struct platform_device *pdev)
566{ 598{
567 int ret, i; 599 int ret, i;
568 struct omap_device *od; 600 struct omap_device *od;
569 struct omap_hwmod *oh;
570 601
571 od = _find_by_pdev(pdev); 602 od = _find_by_pdev(pdev);
572 603
@@ -579,8 +610,8 @@ int omap_device_shutdown(struct platform_device *pdev)
579 610
580 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT); 611 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
581 612
582 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 613 for (i = 0; i < od->hwmods_cnt; i++)
583 omap_hwmod_shutdown(oh); 614 omap_hwmod_shutdown(od->hwmods[i]);
584 615
585 od->_state = OMAP_DEVICE_STATE_SHUTDOWN; 616 od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
586 617
@@ -627,18 +658,6 @@ int omap_device_align_pm_lat(struct platform_device *pdev,
627} 658}
628 659
629/** 660/**
630 * omap_device_is_valid - Check if pointer is a valid omap_device
631 * @od: struct omap_device *
632 *
633 * Return whether struct omap_device pointer @od points to a valid
634 * omap_device.
635 */
636bool omap_device_is_valid(struct omap_device *od)
637{
638 return (od && od->magic == OMAP_DEVICE_MAGIC);
639}
640
641/**
642 * omap_device_get_pwrdm - return the powerdomain * associated with @od 661 * omap_device_get_pwrdm - return the powerdomain * associated with @od
643 * @od: struct omap_device * 662 * @od: struct omap_device *
644 * 663 *
@@ -692,11 +711,10 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od)
692 */ 711 */
693int omap_device_enable_hwmods(struct omap_device *od) 712int omap_device_enable_hwmods(struct omap_device *od)
694{ 713{
695 struct omap_hwmod *oh;
696 int i; 714 int i;
697 715
698 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 716 for (i = 0; i < od->hwmods_cnt; i++)
699 omap_hwmod_enable(oh); 717 omap_hwmod_enable(od->hwmods[i]);
700 718
701 /* XXX pass along return value here? */ 719 /* XXX pass along return value here? */
702 return 0; 720 return 0;
@@ -710,11 +728,10 @@ int omap_device_enable_hwmods(struct omap_device *od)
710 */ 728 */
711int omap_device_idle_hwmods(struct omap_device *od) 729int omap_device_idle_hwmods(struct omap_device *od)
712{ 730{
713 struct omap_hwmod *oh;
714 int i; 731 int i;
715 732
716 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 733 for (i = 0; i < od->hwmods_cnt; i++)
717 omap_hwmod_idle(oh); 734 omap_hwmod_idle(od->hwmods[i]);
718 735
719 /* XXX pass along return value here? */ 736 /* XXX pass along return value here? */
720 return 0; 737 return 0;
@@ -729,11 +746,10 @@ int omap_device_idle_hwmods(struct omap_device *od)
729 */ 746 */
730int omap_device_disable_clocks(struct omap_device *od) 747int omap_device_disable_clocks(struct omap_device *od)
731{ 748{
732 struct omap_hwmod *oh;
733 int i; 749 int i;
734 750
735 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 751 for (i = 0; i < od->hwmods_cnt; i++)
736 omap_hwmod_disable_clocks(oh); 752 omap_hwmod_disable_clocks(od->hwmods[i]);
737 753
738 /* XXX pass along return value here? */ 754 /* XXX pass along return value here? */
739 return 0; 755 return 0;
@@ -748,12 +764,22 @@ int omap_device_disable_clocks(struct omap_device *od)
748 */ 764 */
749int omap_device_enable_clocks(struct omap_device *od) 765int omap_device_enable_clocks(struct omap_device *od)
750{ 766{
751 struct omap_hwmod *oh;
752 int i; 767 int i;
753 768
754 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 769 for (i = 0; i < od->hwmods_cnt; i++)
755 omap_hwmod_enable_clocks(oh); 770 omap_hwmod_enable_clocks(od->hwmods[i]);
756 771
757 /* XXX pass along return value here? */ 772 /* XXX pass along return value here? */
758 return 0; 773 return 0;
759} 774}
775
776struct device omap_device_parent = {
777 .init_name = "omap",
778 .parent = &platform_bus,
779};
780
781static int __init omap_device_init(void)
782{
783 return device_register(&omap_device_parent);
784}
785core_initcall(omap_device_init);
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 10b3b4c63372..e2c8eebe6b3a 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/omapfb.h>
22 23
23#include <asm/tlb.h> 24#include <asm/tlb.h>
24#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
@@ -30,8 +31,8 @@
30#include <plat/cpu.h> 31#include <plat/cpu.h>
31#include <plat/vram.h> 32#include <plat/vram.h>
32 33
33#include <plat/control.h> 34#include "sram.h"
34 35#include "fb.h"
35#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 36#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
36# include "../mach-omap2/prm.h" 37# include "../mach-omap2/prm.h"
37# include "../mach-omap2/cm.h" 38# include "../mach-omap2/cm.h"
@@ -53,7 +54,7 @@
53#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) 54#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
54#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000) 55#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000)
55 56
56#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 57#if defined(CONFIG_ARCH_OMAP2PLUS)
57#define SRAM_BOOTLOADER_SZ 0x00 58#define SRAM_BOOTLOADER_SZ 0x00
58#else 59#else
59#define SRAM_BOOTLOADER_SZ 0x80 60#define SRAM_BOOTLOADER_SZ 0x80
@@ -68,7 +69,6 @@
68#define OMAP34XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68012858) 69#define OMAP34XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68012858)
69#define OMAP34XX_VA_ADDR_MATCH2 OMAP2_L3_IO_ADDRESS(0x68012880) 70#define OMAP34XX_VA_ADDR_MATCH2 OMAP2_L3_IO_ADDRESS(0x68012880)
70#define OMAP34XX_VA_SMS_RG_ATT0 OMAP2_L3_IO_ADDRESS(0x6C000048) 71#define OMAP34XX_VA_SMS_RG_ATT0 OMAP2_L3_IO_ADDRESS(0x6C000048)
71#define OMAP34XX_VA_CONTROL_STAT OMAP2_L4_IO_ADDRESS(0x480022F0)
72 72
73#define GP_DEVICE 0x300 73#define GP_DEVICE 0x300
74 74
@@ -79,12 +79,6 @@ static unsigned long omap_sram_base;
79static unsigned long omap_sram_size; 79static unsigned long omap_sram_size;
80static unsigned long omap_sram_ceil; 80static unsigned long omap_sram_ceil;
81 81
82extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
83 unsigned long sram_vstart,
84 unsigned long sram_size,
85 unsigned long pstart_avail,
86 unsigned long size_avail);
87
88/* 82/*
89 * Depending on the target RAMFS firewall setup, the public usable amount of 83 * Depending on the target RAMFS firewall setup, the public usable amount of
90 * SRAM varies. The default accessible size for all device types is 2k. A GP 84 * SRAM varies. The default accessible size for all device types is 2k. A GP
@@ -93,16 +87,7 @@ extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
93 */ 87 */
94static int is_sram_locked(void) 88static int is_sram_locked(void)
95{ 89{
96 int type = 0; 90 if (OMAP2_DEVICE_TYPE_GP == omap_type()) {
97
98 if (cpu_is_omap44xx())
99 /* Not yet supported */
100 return 0;
101
102 if (cpu_is_omap242x())
103 type = omap_rev() & OMAP2_DEVICETYPE_MASK;
104
105 if (type == GP_DEVICE) {
106 /* RAMFW: R/W access to all initiators for all qualifier sets */ 91 /* RAMFW: R/W access to all initiators for all qualifier sets */
107 if (cpu_is_omap242x()) { 92 if (cpu_is_omap242x()) {
108 __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */ 93 __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */
@@ -127,7 +112,7 @@ static int is_sram_locked(void)
127 * to secure SRAM will hang the system. Also the SRAM is not 112 * to secure SRAM will hang the system. Also the SRAM is not
128 * yet mapped at this point. 113 * yet mapped at this point.
129 */ 114 */
130void __init omap_detect_sram(void) 115static void __init omap_detect_sram(void)
131{ 116{
132 unsigned long reserved; 117 unsigned long reserved;
133 118
@@ -213,7 +198,7 @@ static struct map_desc omap_sram_io_desc[] __initdata = {
213/* 198/*
214 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. 199 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
215 */ 200 */
216void __init omap_map_sram(void) 201static void __init omap_map_sram(void)
217{ 202{
218 unsigned long base; 203 unsigned long base;
219 204
@@ -330,7 +315,7 @@ u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass)
330#endif 315#endif
331 316
332#ifdef CONFIG_ARCH_OMAP2420 317#ifdef CONFIG_ARCH_OMAP2420
333int __init omap242x_sram_init(void) 318static int __init omap242x_sram_init(void)
334{ 319{
335 _omap2_sram_ddr_init = omap_sram_push(omap242x_sram_ddr_init, 320 _omap2_sram_ddr_init = omap_sram_push(omap242x_sram_ddr_init,
336 omap242x_sram_ddr_init_sz); 321 omap242x_sram_ddr_init_sz);
@@ -351,7 +336,7 @@ static inline int omap242x_sram_init(void)
351#endif 336#endif
352 337
353#ifdef CONFIG_ARCH_OMAP2430 338#ifdef CONFIG_ARCH_OMAP2430
354int __init omap243x_sram_init(void) 339static int __init omap243x_sram_init(void)
355{ 340{
356 _omap2_sram_ddr_init = omap_sram_push(omap243x_sram_ddr_init, 341 _omap2_sram_ddr_init = omap_sram_push(omap243x_sram_ddr_init,
357 omap243x_sram_ddr_init_sz); 342 omap243x_sram_ddr_init_sz);
@@ -407,7 +392,7 @@ void omap3_sram_restore_context(void)
407} 392}
408#endif /* CONFIG_PM */ 393#endif /* CONFIG_PM */
409 394
410int __init omap34xx_sram_init(void) 395static int __init omap34xx_sram_init(void)
411{ 396{
412 _omap3_sram_configure_core_dpll = 397 _omap3_sram_configure_core_dpll =
413 omap_sram_push(omap3_sram_configure_core_dpll, 398 omap_sram_push(omap3_sram_configure_core_dpll,
@@ -423,7 +408,7 @@ static inline int omap34xx_sram_init(void)
423#endif 408#endif
424 409
425#ifdef CONFIG_ARCH_OMAP4 410#ifdef CONFIG_ARCH_OMAP4
426int __init omap44xx_sram_init(void) 411static int __init omap44xx_sram_init(void)
427{ 412{
428 printk(KERN_ERR "FIXME: %s not implemented\n", __func__); 413 printk(KERN_ERR "FIXME: %s not implemented\n", __func__);
429 414
diff --git a/arch/arm/plat-omap/sram.h b/arch/arm/plat-omap/sram.h
new file mode 100644
index 000000000000..29b43ef97f20
--- /dev/null
+++ b/arch/arm/plat-omap/sram.h
@@ -0,0 +1,6 @@
1#ifndef __PLAT_OMAP_SRAM_H__
2#define __PLAT_OMAP_SRAM_H__
3
4extern int __init omap_sram_init(void);
5
6#endif /* __PLAT_OMAP_SRAM_H__ */
diff --git a/arch/arm/plat-orion/include/plat/pcie.h b/arch/arm/plat-orion/include/plat/pcie.h
index 3ebfef72b4e7..cc99163e73fd 100644
--- a/arch/arm/plat-orion/include/plat/pcie.h
+++ b/arch/arm/plat-orion/include/plat/pcie.h
@@ -11,12 +11,15 @@
11#ifndef __PLAT_PCIE_H 11#ifndef __PLAT_PCIE_H
12#define __PLAT_PCIE_H 12#define __PLAT_PCIE_H
13 13
14struct pci_bus;
15
14u32 orion_pcie_dev_id(void __iomem *base); 16u32 orion_pcie_dev_id(void __iomem *base);
15u32 orion_pcie_rev(void __iomem *base); 17u32 orion_pcie_rev(void __iomem *base);
16int orion_pcie_link_up(void __iomem *base); 18int orion_pcie_link_up(void __iomem *base);
17int orion_pcie_x4_mode(void __iomem *base); 19int orion_pcie_x4_mode(void __iomem *base);
18int orion_pcie_get_local_bus_nr(void __iomem *base); 20int orion_pcie_get_local_bus_nr(void __iomem *base);
19void orion_pcie_set_local_bus_nr(void __iomem *base, int nr); 21void orion_pcie_set_local_bus_nr(void __iomem *base, int nr);
22void orion_pcie_reset(void __iomem *base);
20void orion_pcie_setup(void __iomem *base, 23void orion_pcie_setup(void __iomem *base,
21 struct mbus_dram_target_info *dram); 24 struct mbus_dram_target_info *dram);
22int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus, 25int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,
diff --git a/arch/arm/plat-orion/pcie.c b/arch/arm/plat-orion/pcie.c
index 779553a1595e..af2d733c50b5 100644
--- a/arch/arm/plat-orion/pcie.c
+++ b/arch/arm/plat-orion/pcie.c
@@ -182,11 +182,6 @@ void __init orion_pcie_setup(void __iomem *base,
182 u32 mask; 182 u32 mask;
183 183
184 /* 184 /*
185 * soft reset PCIe unit
186 */
187 orion_pcie_reset(base);
188
189 /*
190 * Point PCIe unit MBUS decode windows to DRAM space. 185 * Point PCIe unit MBUS decode windows to DRAM space.
191 */ 186 */
192 orion_pcie_setup_wins(base, dram); 187 orion_pcie_setup_wins(base, dram);
diff --git a/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h b/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h
index 3478eae32d8a..01a8448e471c 100644
--- a/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h
+++ b/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h
@@ -30,15 +30,15 @@ struct pxa3xx_nand_cmdset {
30}; 30};
31 31
32struct pxa3xx_nand_flash { 32struct pxa3xx_nand_flash {
33 const struct pxa3xx_nand_timing *timing; /* NAND Flash timing */ 33 uint32_t chip_id;
34 const struct pxa3xx_nand_cmdset *cmdset; 34 unsigned int page_per_block; /* Pages per block (PG_PER_BLK) */
35 35 unsigned int page_size; /* Page size in bytes (PAGE_SZ) */
36 uint32_t page_per_block;/* Pages per block (PG_PER_BLK) */ 36 unsigned int flash_width; /* Width of Flash memory (DWIDTH_M) */
37 uint32_t page_size; /* Page size in bytes (PAGE_SZ) */ 37 unsigned int dfc_width; /* Width of flash controller(DWIDTH_C) */
38 uint32_t flash_width; /* Width of Flash memory (DWIDTH_M) */ 38 unsigned int num_blocks; /* Number of physical blocks in Flash */
39 uint32_t dfc_width; /* Width of flash controller(DWIDTH_C) */ 39
40 uint32_t num_blocks; /* Number of physical blocks in Flash */ 40 struct pxa3xx_nand_cmdset *cmdset; /* NAND command set */
41 uint32_t chip_id; 41 struct pxa3xx_nand_timing *timing; /* NAND Flash timing */
42}; 42};
43 43
44struct pxa3xx_nand_platform_data { 44struct pxa3xx_nand_platform_data {
diff --git a/arch/arm/plat-pxa/include/plat/sdhci.h b/arch/arm/plat-pxa/include/plat/sdhci.h
new file mode 100644
index 000000000000..e49c5b6fc4e2
--- /dev/null
+++ b/arch/arm/plat-pxa/include/plat/sdhci.h
@@ -0,0 +1,32 @@
1/* linux/arch/arm/plat-pxa/include/plat/sdhci.h
2 *
3 * Copyright 2010 Marvell
4 * Zhangfei Gao <zhangfei.gao@marvell.com>
5 *
6 * PXA Platform - SDHCI platform data 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 __PLAT_PXA_SDHCI_H
14#define __PLAT_PXA_SDHCI_H
15
16/* pxa specific flag */
17/* Require clock free running */
18#define PXA_FLAG_DISABLE_CLOCK_GATING (1<<0)
19
20/*
21 * struct pxa_sdhci_platdata() - Platform device data for PXA SDHCI
22 * @max_speed: the maximum speed supported
23 * @quirks: quirks of specific device
24 * @flags: flags for platform requirement
25 */
26struct sdhci_pxa_platdata {
27 unsigned int max_speed;
28 unsigned int quirks;
29 unsigned int flags;
30};
31
32#endif /* __PLAT_PXA_SDHCI_H */
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index 984bf66826d2..5a27b1b538f2 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -69,6 +69,7 @@ config S3C24XX_GPIO_EXTRA
69 int 69 int
70 default 128 if S3C24XX_GPIO_EXTRA128 70 default 128 if S3C24XX_GPIO_EXTRA128
71 default 64 if S3C24XX_GPIO_EXTRA64 71 default 64 if S3C24XX_GPIO_EXTRA64
72 default 16 if ARCH_H1940
72 default 0 73 default 0
73 74
74config S3C24XX_GPIO_EXTRA64 75config S3C24XX_GPIO_EXTRA64
diff --git a/arch/arm/plat-s3c24xx/common-smdk.c b/arch/arm/plat-s3c24xx/common-smdk.c
index 7b44d0c592b5..bcc43f346272 100644
--- a/arch/arm/plat-s3c24xx/common-smdk.c
+++ b/arch/arm/plat-s3c24xx/common-smdk.c
@@ -147,7 +147,7 @@ static struct mtd_partition smdk_default_nand_part[] = {
147 [7] = { 147 [7] = {
148 .name = "S3C2410 flash partition 7", 148 .name = "S3C2410 flash partition 7",
149 .offset = SZ_1M * 48, 149 .offset = SZ_1M * 48,
150 .size = SZ_16M, 150 .size = MTDPART_SIZ_FULL,
151 } 151 }
152}; 152};
153 153
diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c
index 452e18438b41..2f91057a0c02 100644
--- a/arch/arm/plat-s3c24xx/devs.c
+++ b/arch/arm/plat-s3c24xx/devs.c
@@ -247,7 +247,7 @@ static struct resource s3c_iis_resource[] = {
247static u64 s3c_device_iis_dmamask = 0xffffffffUL; 247static u64 s3c_device_iis_dmamask = 0xffffffffUL;
248 248
249struct platform_device s3c_device_iis = { 249struct platform_device s3c_device_iis = {
250 .name = "s3c2410-iis", 250 .name = "s3c24xx-iis",
251 .id = -1, 251 .id = -1,
252 .num_resources = ARRAY_SIZE(s3c_iis_resource), 252 .num_resources = ARRAY_SIZE(s3c_iis_resource),
253 .resource = s3c_iis_resource, 253 .resource = s3c_iis_resource,
@@ -259,6 +259,21 @@ struct platform_device s3c_device_iis = {
259 259
260EXPORT_SYMBOL(s3c_device_iis); 260EXPORT_SYMBOL(s3c_device_iis);
261 261
262/* ASoC PCM DMA */
263
264static u64 s3c_device_audio_dmamask = 0xffffffffUL;
265
266struct platform_device s3c_device_pcm = {
267 .name = "s3c24xx-pcm-audio",
268 .id = -1,
269 .dev = {
270 .dma_mask = &s3c_device_audio_dmamask,
271 .coherent_dma_mask = 0xffffffffUL
272 }
273};
274
275EXPORT_SYMBOL(s3c_device_pcm);
276
262/* RTC */ 277/* RTC */
263 278
264static struct resource s3c_rtc_resource[] = { 279static struct resource s3c_rtc_resource[] = {
@@ -481,19 +496,30 @@ static struct resource s3c_ac97_resource[] = {
481 }, 496 },
482}; 497};
483 498
484static u64 s3c_device_ac97_dmamask = 0xffffffffUL;
485
486struct platform_device s3c_device_ac97 = { 499struct platform_device s3c_device_ac97 = {
487 .name = "s3c-ac97", 500 .name = "s3c-ac97",
488 .id = -1, 501 .id = -1,
489 .num_resources = ARRAY_SIZE(s3c_ac97_resource), 502 .num_resources = ARRAY_SIZE(s3c_ac97_resource),
490 .resource = s3c_ac97_resource, 503 .resource = s3c_ac97_resource,
491 .dev = { 504 .dev = {
492 .dma_mask = &s3c_device_ac97_dmamask, 505 .dma_mask = &s3c_device_audio_dmamask,
493 .coherent_dma_mask = 0xffffffffUL 506 .coherent_dma_mask = 0xffffffffUL
494 } 507 }
495}; 508};
496 509
497EXPORT_SYMBOL(s3c_device_ac97); 510EXPORT_SYMBOL(s3c_device_ac97);
498 511
512/* ASoC I2S */
513
514struct platform_device s3c2412_device_iis = {
515 .name = "s3c2412-iis",
516 .id = -1,
517 .dev = {
518 .dma_mask = &s3c_device_audio_dmamask,
519 .coherent_dma_mask = 0xffffffffUL
520 }
521};
522
523EXPORT_SYMBOL(s3c2412_device_iis);
524
499#endif // CONFIG_CPU_S32440 525#endif // CONFIG_CPU_S32440
diff --git a/arch/arm/plat-s3c24xx/gpiolib.c b/arch/arm/plat-s3c24xx/gpiolib.c
index 4c0896f2572d..24c6f5a30596 100644
--- a/arch/arm/plat-s3c24xx/gpiolib.c
+++ b/arch/arm/plat-s3c24xx/gpiolib.c
@@ -74,11 +74,6 @@ static int s3c24xx_gpiolib_bankf_toirq(struct gpio_chip *chip, unsigned offset)
74 return -EINVAL; 74 return -EINVAL;
75} 75}
76 76
77static int s3c24xx_gpiolib_bankg_toirq(struct gpio_chip *chip, unsigned offset)
78{
79 return IRQ_EINT8 + offset;
80}
81
82static struct s3c_gpio_cfg s3c24xx_gpiocfg_banka = { 77static struct s3c_gpio_cfg s3c24xx_gpiocfg_banka = {
83 .set_config = s3c_gpio_setcfg_s3c24xx_a, 78 .set_config = s3c_gpio_setcfg_s3c24xx_a,
84 .get_config = s3c_gpio_getcfg_s3c24xx_a, 79 .get_config = s3c_gpio_getcfg_s3c24xx_a,
@@ -87,6 +82,8 @@ static struct s3c_gpio_cfg s3c24xx_gpiocfg_banka = {
87struct s3c_gpio_cfg s3c24xx_gpiocfg_default = { 82struct s3c_gpio_cfg s3c24xx_gpiocfg_default = {
88 .set_config = s3c_gpio_setcfg_s3c24xx, 83 .set_config = s3c_gpio_setcfg_s3c24xx,
89 .get_config = s3c_gpio_getcfg_s3c24xx, 84 .get_config = s3c_gpio_getcfg_s3c24xx,
85 .set_pull = s3c_gpio_setpull_1up,
86 .get_pull = s3c_gpio_getpull_1up,
90}; 87};
91 88
92struct s3c_gpio_chip s3c24xx_gpios[] = { 89struct s3c_gpio_chip s3c24xx_gpios[] = {
@@ -157,12 +154,13 @@ struct s3c_gpio_chip s3c24xx_gpios[] = {
157 [6] = { 154 [6] = {
158 .base = S3C2410_GPGCON, 155 .base = S3C2410_GPGCON,
159 .pm = __gpio_pm(&s3c_gpio_pm_2bit), 156 .pm = __gpio_pm(&s3c_gpio_pm_2bit),
157 .irq_base = IRQ_EINT8,
160 .chip = { 158 .chip = {
161 .base = S3C2410_GPG(0), 159 .base = S3C2410_GPG(0),
162 .owner = THIS_MODULE, 160 .owner = THIS_MODULE,
163 .label = "GPIOG", 161 .label = "GPIOG",
164 .ngpio = 16, 162 .ngpio = 16,
165 .to_irq = s3c24xx_gpiolib_bankg_toirq, 163 .to_irq = samsung_gpiolib_to_irq,
166 }, 164 },
167 }, { 165 }, {
168 .base = S3C2410_GPHCON, 166 .base = S3C2410_GPHCON,
diff --git a/arch/arm/plat-s5p/Kconfig b/arch/arm/plat-s5p/Kconfig
index 25960966af7c..65dbfa8e0a86 100644
--- a/arch/arm/plat-s5p/Kconfig
+++ b/arch/arm/plat-s5p/Kconfig
@@ -32,6 +32,11 @@ config S5P_EXT_INT
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 and S5P6450. 33 Note: Do not choose this for S5P6440 and S5P6450.
34 34
35config S5P_GPIO_INT
36 bool
37 help
38 Common code for the GPIO interrupts (other than external interrupts.)
39
35config S5P_DEV_FIMC0 40config S5P_DEV_FIMC0
36 bool 41 bool
37 help 42 help
diff --git a/arch/arm/plat-s5p/Makefile b/arch/arm/plat-s5p/Makefile
index f3e917e27da8..de65238a7aef 100644
--- a/arch/arm/plat-s5p/Makefile
+++ b/arch/arm/plat-s5p/Makefile
@@ -18,6 +18,9 @@ obj-y += cpu.o
18obj-y += clock.o 18obj-y += clock.o
19obj-y += irq.o 19obj-y += irq.o
20obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o 20obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o
21obj-$(CONFIG_S5P_GPIO_INT) += irq-gpioint.o
22obj-$(CONFIG_PM) += pm.o
23obj-$(CONFIG_PM) += irq-pm.o
21 24
22# devices 25# devices
23 26
diff --git a/arch/arm/plat-s5p/clock.c b/arch/arm/plat-s5p/clock.c
index 8aaf4e6b60c3..8d081d968c58 100644
--- a/arch/arm/plat-s5p/clock.c
+++ b/arch/arm/plat-s5p/clock.c
@@ -21,6 +21,8 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <asm/div64.h> 22#include <asm/div64.h>
23 23
24#include <mach/regs-clock.h>
25
24#include <plat/clock.h> 26#include <plat/clock.h>
25#include <plat/clock-clksrc.h> 27#include <plat/clock-clksrc.h>
26#include <plat/s5p-clock.h> 28#include <plat/s5p-clock.h>
@@ -88,14 +90,6 @@ struct clk clk_fout_vpll = {
88 .ctrlbit = (1 << 31), 90 .ctrlbit = (1 << 31),
89}; 91};
90 92
91/* ARM clock */
92struct clk clk_arm = {
93 .name = "armclk",
94 .id = -1,
95 .rate = 0,
96 .ctrlbit = 0,
97};
98
99/* Possible clock sources for APLL Mux */ 93/* Possible clock sources for APLL Mux */
100static struct clk *clk_src_apll_list[] = { 94static struct clk *clk_src_apll_list[] = {
101 [0] = &clk_fin_apll, 95 [0] = &clk_fin_apll,
@@ -156,6 +150,24 @@ int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable)
156 return 0; 150 return 0;
157} 151}
158 152
153int s5p_epll_enable(struct clk *clk, int enable)
154{
155 unsigned int ctrlbit = clk->ctrlbit;
156 unsigned int epll_con = __raw_readl(S5P_EPLL_CON) & ~ctrlbit;
157
158 if (enable)
159 __raw_writel(epll_con | ctrlbit, S5P_EPLL_CON);
160 else
161 __raw_writel(epll_con, S5P_EPLL_CON);
162
163 return 0;
164}
165
166unsigned long s5p_epll_get_rate(struct clk *clk)
167{
168 return clk->rate;
169}
170
159static struct clk *s5p_clks[] __initdata = { 171static struct clk *s5p_clks[] __initdata = {
160 &clk_ext_xtal_mux, 172 &clk_ext_xtal_mux,
161 &clk_48m, 173 &clk_48m,
@@ -165,7 +177,6 @@ static struct clk *s5p_clks[] __initdata = {
165 &clk_fout_epll, 177 &clk_fout_epll,
166 &clk_fout_dpll, 178 &clk_fout_dpll,
167 &clk_fout_vpll, 179 &clk_fout_vpll,
168 &clk_arm,
169 &clk_vpll, 180 &clk_vpll,
170 &clk_xusbxti, 181 &clk_xusbxti,
171}; 182};
diff --git a/arch/arm/plat-s5p/include/plat/irqs.h b/arch/arm/plat-s5p/include/plat/irqs.h
index 3fb3a3a17465..ba9121c60a2a 100644
--- a/arch/arm/plat-s5p/include/plat/irqs.h
+++ b/arch/arm/plat-s5p/include/plat/irqs.h
@@ -94,4 +94,22 @@
94 ((irq) - S5P_EINT_BASE1) : \ 94 ((irq) - S5P_EINT_BASE1) : \
95 ((irq) + 16 - S5P_EINT_BASE2)) 95 ((irq) + 16 - S5P_EINT_BASE2))
96 96
97#define IRQ_EINT_BIT(x) EINT_OFFSET(x)
98
99/* Typically only a few gpio chips require gpio interrupt support.
100 To avoid memory waste irq descriptors are allocated only for
101 S5P_GPIOINT_GROUP_COUNT chips, each with total number of
102 S5P_GPIOINT_GROUP_SIZE pins/irqs. Each GPIOINT group can be assiged
103 to any gpio chip with the s5p_register_gpio_interrupt() function */
104#define S5P_GPIOINT_GROUP_COUNT 4
105#define S5P_GPIOINT_GROUP_SIZE 8
106#define S5P_GPIOINT_COUNT (S5P_GPIOINT_GROUP_COUNT * S5P_GPIOINT_GROUP_SIZE)
107
108/* IRQ types common for all s5p platforms */
109#define S5P_IRQ_TYPE_LEVEL_LOW (0x00)
110#define S5P_IRQ_TYPE_LEVEL_HIGH (0x01)
111#define S5P_IRQ_TYPE_EDGE_FALLING (0x02)
112#define S5P_IRQ_TYPE_EDGE_RISING (0x03)
113#define S5P_IRQ_TYPE_EDGE_BOTH (0x04)
114
97#endif /* __ASM_PLAT_S5P_IRQS_H */ 115#endif /* __ASM_PLAT_S5P_IRQS_H */
diff --git a/arch/arm/plat-s5p/include/plat/map-s5p.h b/arch/arm/plat-s5p/include/plat/map-s5p.h
index c4ff88bf6477..fef353d44513 100644
--- a/arch/arm/plat-s5p/include/plat/map-s5p.h
+++ b/arch/arm/plat-s5p/include/plat/map-s5p.h
@@ -13,24 +13,38 @@
13#ifndef __ASM_PLAT_MAP_S5P_H 13#ifndef __ASM_PLAT_MAP_S5P_H
14#define __ASM_PLAT_MAP_S5P_H __FILE__ 14#define __ASM_PLAT_MAP_S5P_H __FILE__
15 15
16#define S5P_VA_CHIPID S3C_ADDR(0x00700000) 16#define S5P_VA_CHIPID S3C_ADDR(0x02000000)
17#define S5P_VA_GPIO S3C_ADDR(0x00500000) 17#define S5P_VA_CMU S3C_ADDR(0x02100000)
18#define S5P_VA_SYSTIMER S3C_ADDR(0x01200000) 18#define S5P_VA_GPIO S3C_ADDR(0x02200000)
19#define S5P_VA_SROMC S3C_ADDR(0x01100000) 19#define S5P_VA_GPIO1 S5P_VA_GPIO
20#define S5P_VA_SYSRAM S3C_ADDR(0x01180000) 20#define S5P_VA_GPIO2 S3C_ADDR(0x02240000)
21 21#define S5P_VA_GPIO3 S3C_ADDR(0x02280000)
22#define S5P_VA_COMBINER_BASE S3C_ADDR(0x00600000) 22
23#define S5P_VA_SYSRAM S3C_ADDR(0x02400000)
24#define S5P_VA_DMC0 S3C_ADDR(0x02440000)
25#define S5P_VA_DMC1 S3C_ADDR(0x02480000)
26#define S5P_VA_SROMC S3C_ADDR(0x024C0000)
27
28#define S5P_VA_SYSTIMER S3C_ADDR(0x02500000)
29#define S5P_VA_L2CC S3C_ADDR(0x02600000)
30
31#define S5P_VA_COMBINER_BASE S3C_ADDR(0x02700000)
23#define S5P_VA_COMBINER(x) (S5P_VA_COMBINER_BASE + ((x) >> 2) * 0x10) 32#define S5P_VA_COMBINER(x) (S5P_VA_COMBINER_BASE + ((x) >> 2) * 0x10)
24 33
25#define S5P_VA_COREPERI_BASE S3C_ADDR(0x00800000) 34#define S5P_VA_COREPERI_BASE S3C_ADDR(0x02800000)
26#define S5P_VA_COREPERI(x) (S5P_VA_COREPERI_BASE + (x)) 35#define S5P_VA_COREPERI(x) (S5P_VA_COREPERI_BASE + (x))
27#define S5P_VA_SCU S5P_VA_COREPERI(0x0) 36#define S5P_VA_SCU S5P_VA_COREPERI(0x0)
28#define S5P_VA_GIC_CPU S5P_VA_COREPERI(0x100) 37#define S5P_VA_GIC_CPU S5P_VA_COREPERI(0x100)
29#define S5P_VA_TWD S5P_VA_COREPERI(0x600) 38#define S5P_VA_TWD S5P_VA_COREPERI(0x600)
30#define S5P_VA_GIC_DIST S5P_VA_COREPERI(0x1000) 39#define S5P_VA_GIC_DIST S5P_VA_COREPERI(0x1000)
31 40
32#define S5P_VA_L2CC S3C_ADDR(0x00900000) 41#define S3C_VA_USB_HSPHY S3C_ADDR(0x02900000)
33#define S5P_VA_CMU S3C_ADDR(0x00920000) 42
43#define VA_VIC(x) (S3C_VA_IRQ + ((x) * 0x10000))
44#define VA_VIC0 VA_VIC(0)
45#define VA_VIC1 VA_VIC(1)
46#define VA_VIC2 VA_VIC(2)
47#define VA_VIC3 VA_VIC(3)
34 48
35#define S5P_VA_UART(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET)) 49#define S5P_VA_UART(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET))
36#define S5P_VA_UART0 S5P_VA_UART(0) 50#define S5P_VA_UART0 S5P_VA_UART(0)
@@ -42,10 +56,4 @@
42#define S3C_UART_OFFSET (0x400) 56#define S3C_UART_OFFSET (0x400)
43#endif 57#endif
44 58
45#define VA_VIC(x) (S3C_VA_IRQ + ((x) * 0x10000))
46#define VA_VIC0 VA_VIC(0)
47#define VA_VIC1 VA_VIC(1)
48#define VA_VIC2 VA_VIC(2)
49#define VA_VIC3 VA_VIC(3)
50
51#endif /* __ASM_PLAT_MAP_S5P_H */ 59#endif /* __ASM_PLAT_MAP_S5P_H */
diff --git a/arch/arm/plat-s5p/include/plat/s5p-clock.h b/arch/arm/plat-s5p/include/plat/s5p-clock.h
index 17036c898409..2b6dcff8ab2b 100644
--- a/arch/arm/plat-s5p/include/plat/s5p-clock.h
+++ b/arch/arm/plat-s5p/include/plat/s5p-clock.h
@@ -43,4 +43,8 @@ extern struct clksrc_sources clk_src_dpll;
43 43
44extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable); 44extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable);
45 45
46/* Common EPLL operations for S5P platform */
47extern int s5p_epll_enable(struct clk *clk, int enable);
48extern unsigned long s5p_epll_get_rate(struct clk *clk);
49
46#endif /* __ASM_PLAT_S5P_CLOCK_H */ 50#endif /* __ASM_PLAT_S5P_CLOCK_H */
diff --git a/arch/arm/plat-s5p/irq-eint.c b/arch/arm/plat-s5p/irq-eint.c
index f36cd3327025..752f1a645f9d 100644
--- a/arch/arm/plat-s5p/irq-eint.c
+++ b/arch/arm/plat-s5p/irq-eint.c
@@ -67,23 +67,23 @@ static int s5p_irq_eint_set_type(unsigned int irq, unsigned int type)
67 67
68 switch (type) { 68 switch (type) {
69 case IRQ_TYPE_EDGE_RISING: 69 case IRQ_TYPE_EDGE_RISING:
70 newvalue = S5P_EXTINT_RISEEDGE; 70 newvalue = S5P_IRQ_TYPE_EDGE_RISING;
71 break; 71 break;
72 72
73 case IRQ_TYPE_EDGE_FALLING: 73 case IRQ_TYPE_EDGE_FALLING:
74 newvalue = S5P_EXTINT_FALLEDGE; 74 newvalue = S5P_IRQ_TYPE_EDGE_FALLING;
75 break; 75 break;
76 76
77 case IRQ_TYPE_EDGE_BOTH: 77 case IRQ_TYPE_EDGE_BOTH:
78 newvalue = S5P_EXTINT_BOTHEDGE; 78 newvalue = S5P_IRQ_TYPE_EDGE_BOTH;
79 break; 79 break;
80 80
81 case IRQ_TYPE_LEVEL_LOW: 81 case IRQ_TYPE_LEVEL_LOW:
82 newvalue = S5P_EXTINT_LOWLEV; 82 newvalue = S5P_IRQ_TYPE_LEVEL_LOW;
83 break; 83 break;
84 84
85 case IRQ_TYPE_LEVEL_HIGH: 85 case IRQ_TYPE_LEVEL_HIGH:
86 newvalue = S5P_EXTINT_HILEV; 86 newvalue = S5P_IRQ_TYPE_LEVEL_HIGH;
87 break; 87 break;
88 88
89 default: 89 default:
diff --git a/arch/arm/plat-s5p/irq-gpioint.c b/arch/arm/plat-s5p/irq-gpioint.c
new file mode 100644
index 000000000000..0e5dc8cbf5e3
--- /dev/null
+++ b/arch/arm/plat-s5p/irq-gpioint.c
@@ -0,0 +1,237 @@
1/* linux/arch/arm/plat-s5p/irq-gpioint.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * Author: Kyungmin Park <kyungmin.park@samsung.com>
5 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
6 * Author: Marek Szyprowski <m.szyprowski@samsung.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 */
14
15#include <linux/kernel.h>
16#include <linux/interrupt.h>
17#include <linux/irq.h>
18#include <linux/io.h>
19#include <linux/gpio.h>
20
21#include <mach/map.h>
22#include <plat/gpio-core.h>
23#include <plat/gpio-cfg.h>
24
25#define S5P_GPIOREG(x) (S5P_VA_GPIO + (x))
26
27#define GPIOINT_CON_OFFSET 0x700
28#define GPIOINT_MASK_OFFSET 0x900
29#define GPIOINT_PEND_OFFSET 0xA00
30
31static struct s3c_gpio_chip *irq_chips[S5P_GPIOINT_GROUP_MAXNR];
32
33static int s5p_gpioint_get_group(unsigned int irq)
34{
35 struct gpio_chip *chip = get_irq_data(irq);
36 struct s3c_gpio_chip *s3c_chip = container_of(chip,
37 struct s3c_gpio_chip, chip);
38 int group;
39
40 for (group = 0; group < S5P_GPIOINT_GROUP_MAXNR; group++)
41 if (s3c_chip == irq_chips[group])
42 break;
43
44 return group;
45}
46
47static int s5p_gpioint_get_offset(unsigned int irq)
48{
49 struct gpio_chip *chip = get_irq_data(irq);
50 struct s3c_gpio_chip *s3c_chip = container_of(chip,
51 struct s3c_gpio_chip, chip);
52
53 return irq - s3c_chip->irq_base;
54}
55
56static void s5p_gpioint_ack(unsigned int irq)
57{
58 int group, offset, pend_offset;
59 unsigned int value;
60
61 group = s5p_gpioint_get_group(irq);
62 offset = s5p_gpioint_get_offset(irq);
63 pend_offset = group << 2;
64
65 value = __raw_readl(S5P_GPIOREG(GPIOINT_PEND_OFFSET) + pend_offset);
66 value |= 1 << offset;
67 __raw_writel(value, S5P_GPIOREG(GPIOINT_PEND_OFFSET) + pend_offset);
68}
69
70static void s5p_gpioint_mask(unsigned int irq)
71{
72 int group, offset, mask_offset;
73 unsigned int value;
74
75 group = s5p_gpioint_get_group(irq);
76 offset = s5p_gpioint_get_offset(irq);
77 mask_offset = group << 2;
78
79 value = __raw_readl(S5P_GPIOREG(GPIOINT_MASK_OFFSET) + mask_offset);
80 value |= 1 << offset;
81 __raw_writel(value, S5P_GPIOREG(GPIOINT_MASK_OFFSET) + mask_offset);
82}
83
84static void s5p_gpioint_unmask(unsigned int irq)
85{
86 int group, offset, mask_offset;
87 unsigned int value;
88
89 group = s5p_gpioint_get_group(irq);
90 offset = s5p_gpioint_get_offset(irq);
91 mask_offset = group << 2;
92
93 value = __raw_readl(S5P_GPIOREG(GPIOINT_MASK_OFFSET) + mask_offset);
94 value &= ~(1 << offset);
95 __raw_writel(value, S5P_GPIOREG(GPIOINT_MASK_OFFSET) + mask_offset);
96}
97
98static void s5p_gpioint_mask_ack(unsigned int irq)
99{
100 s5p_gpioint_mask(irq);
101 s5p_gpioint_ack(irq);
102}
103
104static int s5p_gpioint_set_type(unsigned int irq, unsigned int type)
105{
106 int group, offset, con_offset;
107 unsigned int value;
108
109 group = s5p_gpioint_get_group(irq);
110 offset = s5p_gpioint_get_offset(irq);
111 con_offset = group << 2;
112
113 switch (type) {
114 case IRQ_TYPE_EDGE_RISING:
115 type = S5P_IRQ_TYPE_EDGE_RISING;
116 break;
117 case IRQ_TYPE_EDGE_FALLING:
118 type = S5P_IRQ_TYPE_EDGE_FALLING;
119 break;
120 case IRQ_TYPE_EDGE_BOTH:
121 type = S5P_IRQ_TYPE_EDGE_BOTH;
122 break;
123 case IRQ_TYPE_LEVEL_HIGH:
124 type = S5P_IRQ_TYPE_LEVEL_HIGH;
125 break;
126 case IRQ_TYPE_LEVEL_LOW:
127 type = S5P_IRQ_TYPE_LEVEL_LOW;
128 break;
129 case IRQ_TYPE_NONE:
130 default:
131 printk(KERN_WARNING "No irq type\n");
132 return -EINVAL;
133 }
134
135 value = __raw_readl(S5P_GPIOREG(GPIOINT_CON_OFFSET) + con_offset);
136 value &= ~(0x7 << (offset * 0x4));
137 value |= (type << (offset * 0x4));
138 __raw_writel(value, S5P_GPIOREG(GPIOINT_CON_OFFSET) + con_offset);
139
140 return 0;
141}
142
143struct irq_chip s5p_gpioint = {
144 .name = "s5p_gpioint",
145 .ack = s5p_gpioint_ack,
146 .mask = s5p_gpioint_mask,
147 .mask_ack = s5p_gpioint_mask_ack,
148 .unmask = s5p_gpioint_unmask,
149 .set_type = s5p_gpioint_set_type,
150};
151
152static void s5p_gpioint_handler(unsigned int irq, struct irq_desc *desc)
153{
154 int group, offset, pend_offset, mask_offset;
155 int real_irq;
156 unsigned int pend, mask;
157
158 for (group = 0; group < S5P_GPIOINT_GROUP_MAXNR; group++) {
159 pend_offset = group << 2;
160 pend = __raw_readl(S5P_GPIOREG(GPIOINT_PEND_OFFSET) +
161 pend_offset);
162 if (!pend)
163 continue;
164
165 mask_offset = group << 2;
166 mask = __raw_readl(S5P_GPIOREG(GPIOINT_MASK_OFFSET) +
167 mask_offset);
168 pend &= ~mask;
169
170 for (offset = 0; offset < 8; offset++) {
171 if (pend & (1 << offset)) {
172 struct s3c_gpio_chip *chip = irq_chips[group];
173 if (chip) {
174 real_irq = chip->irq_base + offset;
175 generic_handle_irq(real_irq);
176 }
177 }
178 }
179 }
180}
181
182static __init int s5p_gpioint_add(struct s3c_gpio_chip *chip)
183{
184 static int used_gpioint_groups = 0;
185 static bool handler_registered = 0;
186 int irq, group = chip->group;
187 int i;
188
189 if (used_gpioint_groups >= S5P_GPIOINT_GROUP_COUNT)
190 return -ENOMEM;
191
192 chip->irq_base = S5P_GPIOINT_BASE +
193 used_gpioint_groups * S5P_GPIOINT_GROUP_SIZE;
194 used_gpioint_groups++;
195
196 if (!handler_registered) {
197 set_irq_chained_handler(IRQ_GPIOINT, s5p_gpioint_handler);
198 handler_registered = 1;
199 }
200
201 irq_chips[group] = chip;
202 for (i = 0; i < chip->chip.ngpio; i++) {
203 irq = chip->irq_base + i;
204 set_irq_chip(irq, &s5p_gpioint);
205 set_irq_data(irq, &chip->chip);
206 set_irq_handler(irq, handle_level_irq);
207 set_irq_flags(irq, IRQF_VALID);
208 }
209 return 0;
210}
211
212int __init s5p_register_gpio_interrupt(int pin)
213{
214 struct s3c_gpio_chip *my_chip = s3c_gpiolib_getchip(pin);
215 int offset, group;
216 int ret;
217
218 if (!my_chip)
219 return -EINVAL;
220
221 offset = pin - my_chip->chip.base;
222 group = my_chip->group;
223
224 /* check if the group has been already registered */
225 if (my_chip->irq_base)
226 return my_chip->irq_base + offset;
227
228 /* register gpio group */
229 ret = s5p_gpioint_add(my_chip);
230 if (ret == 0) {
231 my_chip->chip.to_irq = samsung_gpiolib_to_irq;
232 printk(KERN_INFO "Registered interrupt support for gpio group %d.\n",
233 group);
234 return my_chip->irq_base + offset;
235 }
236 return ret;
237}
diff --git a/arch/arm/plat-s5p/irq-pm.c b/arch/arm/plat-s5p/irq-pm.c
new file mode 100644
index 000000000000..dc33b9ecda45
--- /dev/null
+++ b/arch/arm/plat-s5p/irq-pm.c
@@ -0,0 +1,93 @@
1/* linux/arch/arm/plat-s5p/irq-pm.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Based on arch/arm/plat-s3c24xx/irq-pm.c,
7 * Copyright (c) 2003,2004 Simtec Electronics
8 * Ben Dooks <ben@simtec.co.uk>
9 * http://armlinux.simtec.co.uk/
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/init.h>
17#include <linux/module.h>
18#include <linux/interrupt.h>
19#include <linux/sysdev.h>
20
21#include <plat/cpu.h>
22#include <plat/irqs.h>
23#include <plat/pm.h>
24#include <mach/map.h>
25
26#include <mach/regs-gpio.h>
27#include <mach/regs-irq.h>
28
29/* state for IRQs over sleep */
30
31/* default is to allow for EINT0..EINT31, and IRQ_RTC_TIC, IRQ_RTC_ALARM,
32 * as wakeup sources
33 *
34 * set bit to 1 in allow bitfield to enable the wakeup settings on it
35*/
36
37unsigned long s3c_irqwake_intallow = 0x00000006L;
38unsigned long s3c_irqwake_eintallow = 0xffffffffL;
39
40int s3c_irq_wake(unsigned int irqno, unsigned int state)
41{
42 unsigned long irqbit;
43
44 switch (irqno) {
45 case IRQ_RTC_TIC:
46 case IRQ_RTC_ALARM:
47 irqbit = 1 << (irqno + 1 - IRQ_RTC_ALARM);
48 if (!state)
49 s3c_irqwake_intmask |= irqbit;
50 else
51 s3c_irqwake_intmask &= ~irqbit;
52 break;
53 default:
54 return -ENOENT;
55 }
56 return 0;
57}
58
59static struct sleep_save eint_save[] = {
60 SAVE_ITEM(S5P_EINT_CON(0)),
61 SAVE_ITEM(S5P_EINT_CON(1)),
62 SAVE_ITEM(S5P_EINT_CON(2)),
63 SAVE_ITEM(S5P_EINT_CON(3)),
64
65 SAVE_ITEM(S5P_EINT_FLTCON(0)),
66 SAVE_ITEM(S5P_EINT_FLTCON(1)),
67 SAVE_ITEM(S5P_EINT_FLTCON(2)),
68 SAVE_ITEM(S5P_EINT_FLTCON(3)),
69 SAVE_ITEM(S5P_EINT_FLTCON(4)),
70 SAVE_ITEM(S5P_EINT_FLTCON(5)),
71 SAVE_ITEM(S5P_EINT_FLTCON(6)),
72 SAVE_ITEM(S5P_EINT_FLTCON(7)),
73
74 SAVE_ITEM(S5P_EINT_MASK(0)),
75 SAVE_ITEM(S5P_EINT_MASK(1)),
76 SAVE_ITEM(S5P_EINT_MASK(2)),
77 SAVE_ITEM(S5P_EINT_MASK(3)),
78};
79
80int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state)
81{
82 s3c_pm_do_save(eint_save, ARRAY_SIZE(eint_save));
83
84 return 0;
85}
86
87int s3c24xx_irq_resume(struct sys_device *dev)
88{
89 s3c_pm_do_restore(eint_save, ARRAY_SIZE(eint_save));
90
91 return 0;
92}
93
diff --git a/arch/arm/plat-s5p/pm.c b/arch/arm/plat-s5p/pm.c
new file mode 100644
index 000000000000..d592b6304b48
--- /dev/null
+++ b/arch/arm/plat-s5p/pm.c
@@ -0,0 +1,52 @@
1/* linux/arch/arm/plat-s5p/pm.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P Power Manager (Suspend-To-RAM) support
7 *
8 * Based on arch/arm/plat-s3c24xx/pm.c
9 * Copyright (c) 2004,2006 Simtec Electronics
10 * Ben Dooks <ben@simtec.co.uk>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15*/
16
17#include <linux/suspend.h>
18#include <plat/pm.h>
19
20#define PFX "s5p pm: "
21
22/* s3c_pm_check_resume_pin
23 *
24 * check to see if the pin is configured correctly for sleep mode, and
25 * make any necessary adjustments if it is not
26*/
27
28static void s3c_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs)
29{
30 /* nothing here yet */
31}
32
33/* s3c_pm_configure_extint
34 *
35 * configure all external interrupt pins
36*/
37
38void s3c_pm_configure_extint(void)
39{
40 /* nothing here yet */
41}
42
43void s3c_pm_restore_core(void)
44{
45 /* nothing here yet */
46}
47
48void s3c_pm_save_core(void)
49{
50 /* nothing here yet */
51}
52
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 7c0bde781167..dcd6eff4ee53 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -180,6 +180,31 @@ config S3C_DEV_I2C2
180 help 180 help
181 Compile in platform device definitions for I2C channel 2 181 Compile in platform device definitions for I2C channel 2
182 182
183config S3C_DEV_I2C3
184 bool
185 help
186 Compile in platform device definition for I2C controller 3
187
188config S3C_DEV_I2C4
189 bool
190 help
191 Compile in platform device definition for I2C controller 4
192
193config S3C_DEV_I2C5
194 bool
195 help
196 Compile in platform device definition for I2C controller 5
197
198config S3C_DEV_I2C6
199 bool
200 help
201 Compile in platform device definition for I2C controller 6
202
203config S3C_DEV_I2C7
204 bool
205 help
206 Compile in platform device definition for I2C controller 7
207
183config S3C_DEV_FB 208config S3C_DEV_FB
184 bool 209 bool
185 help 210 help
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 4d8ff923207a..afcce474af8e 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -40,6 +40,11 @@ obj-$(CONFIG_S3C_DEV_HWMON) += dev-hwmon.o
40obj-y += dev-i2c0.o 40obj-y += dev-i2c0.o
41obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o 41obj-$(CONFIG_S3C_DEV_I2C1) += dev-i2c1.o
42obj-$(CONFIG_S3C_DEV_I2C2) += dev-i2c2.o 42obj-$(CONFIG_S3C_DEV_I2C2) += dev-i2c2.o
43obj-$(CONFIG_S3C_DEV_I2C3) += dev-i2c3.o
44obj-$(CONFIG_S3C_DEV_I2C4) += dev-i2c4.o
45obj-$(CONFIG_S3C_DEV_I2C5) += dev-i2c5.o
46obj-$(CONFIG_S3C_DEV_I2C6) += dev-i2c6.o
47obj-$(CONFIG_S3C_DEV_I2C7) += dev-i2c7.o
43obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o 48obj-$(CONFIG_S3C_DEV_FB) += dev-fb.o
44obj-y += dev-uart.o 49obj-y += dev-uart.o
45obj-$(CONFIG_S3C_DEV_USB_HOST) += dev-usb.o 50obj-$(CONFIG_S3C_DEV_USB_HOST) += dev-usb.o
diff --git a/arch/arm/plat-samsung/dev-hsmmc.c b/arch/arm/plat-samsung/dev-hsmmc.c
index 9d2be0941410..db7a65c7f127 100644
--- a/arch/arm/plat-samsung/dev-hsmmc.c
+++ b/arch/arm/plat-samsung/dev-hsmmc.c
@@ -41,6 +41,7 @@ struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = {
41 .max_width = 4, 41 .max_width = 4,
42 .host_caps = (MMC_CAP_4_BIT_DATA | 42 .host_caps = (MMC_CAP_4_BIT_DATA |
43 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), 43 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
44 .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
44}; 45};
45 46
46struct platform_device s3c_device_hsmmc0 = { 47struct platform_device s3c_device_hsmmc0 = {
@@ -59,17 +60,20 @@ void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd)
59{ 60{
60 struct s3c_sdhci_platdata *set = &s3c_hsmmc0_def_platdata; 61 struct s3c_sdhci_platdata *set = &s3c_hsmmc0_def_platdata;
61 62
62 set->max_width = pd->max_width;
63 set->cd_type = pd->cd_type; 63 set->cd_type = pd->cd_type;
64 set->ext_cd_init = pd->ext_cd_init; 64 set->ext_cd_init = pd->ext_cd_init;
65 set->ext_cd_cleanup = pd->ext_cd_cleanup; 65 set->ext_cd_cleanup = pd->ext_cd_cleanup;
66 set->ext_cd_gpio = pd->ext_cd_gpio; 66 set->ext_cd_gpio = pd->ext_cd_gpio;
67 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert; 67 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
68 68
69 if (pd->max_width)
70 set->max_width = pd->max_width;
69 if (pd->cfg_gpio) 71 if (pd->cfg_gpio)
70 set->cfg_gpio = pd->cfg_gpio; 72 set->cfg_gpio = pd->cfg_gpio;
71 if (pd->cfg_card) 73 if (pd->cfg_card)
72 set->cfg_card = pd->cfg_card; 74 set->cfg_card = pd->cfg_card;
73 if (pd->host_caps) 75 if (pd->host_caps)
74 set->host_caps = pd->host_caps; 76 set->host_caps |= pd->host_caps;
77 if (pd->clk_type)
78 set->clk_type = pd->clk_type;
75} 79}
diff --git a/arch/arm/plat-samsung/dev-hsmmc1.c b/arch/arm/plat-samsung/dev-hsmmc1.c
index a6c8295840af..2497321f08d7 100644
--- a/arch/arm/plat-samsung/dev-hsmmc1.c
+++ b/arch/arm/plat-samsung/dev-hsmmc1.c
@@ -41,6 +41,7 @@ struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata = {
41 .max_width = 4, 41 .max_width = 4,
42 .host_caps = (MMC_CAP_4_BIT_DATA | 42 .host_caps = (MMC_CAP_4_BIT_DATA |
43 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), 43 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
44 .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
44}; 45};
45 46
46struct platform_device s3c_device_hsmmc1 = { 47struct platform_device s3c_device_hsmmc1 = {
@@ -59,17 +60,20 @@ void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd)
59{ 60{
60 struct s3c_sdhci_platdata *set = &s3c_hsmmc1_def_platdata; 61 struct s3c_sdhci_platdata *set = &s3c_hsmmc1_def_platdata;
61 62
62 set->max_width = pd->max_width;
63 set->cd_type = pd->cd_type; 63 set->cd_type = pd->cd_type;
64 set->ext_cd_init = pd->ext_cd_init; 64 set->ext_cd_init = pd->ext_cd_init;
65 set->ext_cd_cleanup = pd->ext_cd_cleanup; 65 set->ext_cd_cleanup = pd->ext_cd_cleanup;
66 set->ext_cd_gpio = pd->ext_cd_gpio; 66 set->ext_cd_gpio = pd->ext_cd_gpio;
67 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert; 67 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
68 68
69 if (pd->max_width)
70 set->max_width = pd->max_width;
69 if (pd->cfg_gpio) 71 if (pd->cfg_gpio)
70 set->cfg_gpio = pd->cfg_gpio; 72 set->cfg_gpio = pd->cfg_gpio;
71 if (pd->cfg_card) 73 if (pd->cfg_card)
72 set->cfg_card = pd->cfg_card; 74 set->cfg_card = pd->cfg_card;
73 if (pd->host_caps) 75 if (pd->host_caps)
74 set->host_caps = pd->host_caps; 76 set->host_caps |= pd->host_caps;
77 if (pd->clk_type)
78 set->clk_type = pd->clk_type;
75} 79}
diff --git a/arch/arm/plat-samsung/dev-hsmmc2.c b/arch/arm/plat-samsung/dev-hsmmc2.c
index cb0d7143381a..f60aedba417c 100644
--- a/arch/arm/plat-samsung/dev-hsmmc2.c
+++ b/arch/arm/plat-samsung/dev-hsmmc2.c
@@ -42,6 +42,7 @@ struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = {
42 .max_width = 4, 42 .max_width = 4,
43 .host_caps = (MMC_CAP_4_BIT_DATA | 43 .host_caps = (MMC_CAP_4_BIT_DATA |
44 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), 44 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
45 .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
45}; 46};
46 47
47struct platform_device s3c_device_hsmmc2 = { 48struct platform_device s3c_device_hsmmc2 = {
@@ -60,17 +61,20 @@ void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd)
60{ 61{
61 struct s3c_sdhci_platdata *set = &s3c_hsmmc2_def_platdata; 62 struct s3c_sdhci_platdata *set = &s3c_hsmmc2_def_platdata;
62 63
63 set->max_width = pd->max_width;
64 set->cd_type = pd->cd_type; 64 set->cd_type = pd->cd_type;
65 set->ext_cd_init = pd->ext_cd_init; 65 set->ext_cd_init = pd->ext_cd_init;
66 set->ext_cd_cleanup = pd->ext_cd_cleanup; 66 set->ext_cd_cleanup = pd->ext_cd_cleanup;
67 set->ext_cd_gpio = pd->ext_cd_gpio; 67 set->ext_cd_gpio = pd->ext_cd_gpio;
68 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert; 68 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
69 69
70 if (pd->max_width)
71 set->max_width = pd->max_width;
70 if (pd->cfg_gpio) 72 if (pd->cfg_gpio)
71 set->cfg_gpio = pd->cfg_gpio; 73 set->cfg_gpio = pd->cfg_gpio;
72 if (pd->cfg_card) 74 if (pd->cfg_card)
73 set->cfg_card = pd->cfg_card; 75 set->cfg_card = pd->cfg_card;
74 if (pd->host_caps) 76 if (pd->host_caps)
75 set->host_caps = pd->host_caps; 77 set->host_caps |= pd->host_caps;
78 if (pd->clk_type)
79 set->clk_type = pd->clk_type;
76} 80}
diff --git a/arch/arm/plat-samsung/dev-hsmmc3.c b/arch/arm/plat-samsung/dev-hsmmc3.c
index 85aaf0f2842f..ede776f20e62 100644
--- a/arch/arm/plat-samsung/dev-hsmmc3.c
+++ b/arch/arm/plat-samsung/dev-hsmmc3.c
@@ -33,8 +33,8 @@ static struct resource s3c_hsmmc3_resource[] = {
33 .flags = IORESOURCE_MEM, 33 .flags = IORESOURCE_MEM,
34 }, 34 },
35 [1] = { 35 [1] = {
36 .start = IRQ_MMC3, 36 .start = IRQ_HSMMC3,
37 .end = IRQ_MMC3, 37 .end = IRQ_HSMMC3,
38 .flags = IORESOURCE_IRQ, 38 .flags = IORESOURCE_IRQ,
39 } 39 }
40}; 40};
@@ -45,6 +45,7 @@ struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata = {
45 .max_width = 4, 45 .max_width = 4,
46 .host_caps = (MMC_CAP_4_BIT_DATA | 46 .host_caps = (MMC_CAP_4_BIT_DATA |
47 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), 47 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
48 .clk_type = S3C_SDHCI_CLK_DIV_INTERNAL,
48}; 49};
49 50
50struct platform_device s3c_device_hsmmc3 = { 51struct platform_device s3c_device_hsmmc3 = {
@@ -63,15 +64,20 @@ void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd)
63{ 64{
64 struct s3c_sdhci_platdata *set = &s3c_hsmmc3_def_platdata; 65 struct s3c_sdhci_platdata *set = &s3c_hsmmc3_def_platdata;
65 66
66 set->max_width = pd->max_width;
67 set->cd_type = pd->cd_type; 67 set->cd_type = pd->cd_type;
68 set->ext_cd_init = pd->ext_cd_init; 68 set->ext_cd_init = pd->ext_cd_init;
69 set->ext_cd_cleanup = pd->ext_cd_cleanup; 69 set->ext_cd_cleanup = pd->ext_cd_cleanup;
70 set->ext_cd_gpio = pd->ext_cd_gpio; 70 set->ext_cd_gpio = pd->ext_cd_gpio;
71 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert; 71 set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
72 72
73 if (pd->max_width)
74 set->max_width = pd->max_width;
73 if (pd->cfg_gpio) 75 if (pd->cfg_gpio)
74 set->cfg_gpio = pd->cfg_gpio; 76 set->cfg_gpio = pd->cfg_gpio;
75 if (pd->cfg_card) 77 if (pd->cfg_card)
76 set->cfg_card = pd->cfg_card; 78 set->cfg_card = pd->cfg_card;
79 if (pd->host_caps)
80 set->host_caps |= pd->host_caps;
81 if (pd->clk_type)
82 set->clk_type = pd->clk_type;
77} 83}
diff --git a/arch/arm/plat-samsung/dev-i2c2.c b/arch/arm/plat-samsung/dev-i2c2.c
index 07036dee09e7..ff4ba69b6830 100644
--- a/arch/arm/plat-samsung/dev-i2c2.c
+++ b/arch/arm/plat-samsung/dev-i2c2.c
@@ -32,8 +32,8 @@ static struct resource s3c_i2c_resource[] = {
32 .flags = IORESOURCE_MEM, 32 .flags = IORESOURCE_MEM,
33 }, 33 },
34 [1] = { 34 [1] = {
35 .start = IRQ_CAN0, 35 .start = IRQ_IIC2,
36 .end = IRQ_CAN0, 36 .end = IRQ_IIC2,
37 .flags = IORESOURCE_IRQ, 37 .flags = IORESOURCE_IRQ,
38 }, 38 },
39}; 39};
diff --git a/arch/arm/plat-samsung/dev-i2c3.c b/arch/arm/plat-samsung/dev-i2c3.c
new file mode 100644
index 000000000000..8586a10014b7
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-i2c3.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-samsung/dev-i2c3.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P series device definition for i2c device 3
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/gfp.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/irqs.h>
19#include <mach/map.h>
20
21#include <plat/regs-iic.h>
22#include <plat/iic.h>
23#include <plat/devs.h>
24#include <plat/cpu.h>
25
26static struct resource s3c_i2c_resource[] = {
27 [0] = {
28 .start = S3C_PA_IIC3,
29 .end = S3C_PA_IIC3 + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_IIC3,
34 .end = IRQ_IIC3,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39struct platform_device s3c_device_i2c3 = {
40 .name = "s3c2440-i2c",
41 .id = 3,
42 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
43 .resource = s3c_i2c_resource,
44};
45
46static struct s3c2410_platform_i2c default_i2c_data3 __initdata = {
47 .flags = 0,
48 .bus_num = 3,
49 .slave_addr = 0x10,
50 .frequency = 100*1000,
51 .sda_delay = 100,
52};
53
54void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data3;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c3_cfg_gpio;
66
67 s3c_device_i2c3.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-samsung/dev-i2c4.c b/arch/arm/plat-samsung/dev-i2c4.c
new file mode 100644
index 000000000000..df2159e2daa6
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-i2c4.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-samsung/dev-i2c4.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P series device definition for i2c device 3
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/gfp.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/irqs.h>
19#include <mach/map.h>
20
21#include <plat/regs-iic.h>
22#include <plat/iic.h>
23#include <plat/devs.h>
24#include <plat/cpu.h>
25
26static struct resource s3c_i2c_resource[] = {
27 [0] = {
28 .start = S3C_PA_IIC4,
29 .end = S3C_PA_IIC4 + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_IIC4,
34 .end = IRQ_IIC4,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39struct platform_device s3c_device_i2c4 = {
40 .name = "s3c2440-i2c",
41 .id = 4,
42 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
43 .resource = s3c_i2c_resource,
44};
45
46static struct s3c2410_platform_i2c default_i2c_data4 __initdata = {
47 .flags = 0,
48 .bus_num = 4,
49 .slave_addr = 0x10,
50 .frequency = 100*1000,
51 .sda_delay = 100,
52};
53
54void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data4;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c4_cfg_gpio;
66
67 s3c_device_i2c4.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-samsung/dev-i2c5.c b/arch/arm/plat-samsung/dev-i2c5.c
new file mode 100644
index 000000000000..0499c2c3877b
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-i2c5.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-samsung/dev-i2c3.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P series device definition for i2c device 3
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/gfp.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/irqs.h>
19#include <mach/map.h>
20
21#include <plat/regs-iic.h>
22#include <plat/iic.h>
23#include <plat/devs.h>
24#include <plat/cpu.h>
25
26static struct resource s3c_i2c_resource[] = {
27 [0] = {
28 .start = S3C_PA_IIC5,
29 .end = S3C_PA_IIC5 + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_IIC5,
34 .end = IRQ_IIC5,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39struct platform_device s3c_device_i2c5 = {
40 .name = "s3c2440-i2c",
41 .id = 5,
42 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
43 .resource = s3c_i2c_resource,
44};
45
46static struct s3c2410_platform_i2c default_i2c_data5 __initdata = {
47 .flags = 0,
48 .bus_num = 5,
49 .slave_addr = 0x10,
50 .frequency = 100*1000,
51 .sda_delay = 100,
52};
53
54void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data5;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c5_cfg_gpio;
66
67 s3c_device_i2c5.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-samsung/dev-i2c6.c b/arch/arm/plat-samsung/dev-i2c6.c
new file mode 100644
index 000000000000..4083108908a8
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-i2c6.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-samsung/dev-i2c6.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P series device definition for i2c device 6
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/gfp.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/irqs.h>
19#include <mach/map.h>
20
21#include <plat/regs-iic.h>
22#include <plat/iic.h>
23#include <plat/devs.h>
24#include <plat/cpu.h>
25
26static struct resource s3c_i2c_resource[] = {
27 [0] = {
28 .start = S3C_PA_IIC6,
29 .end = S3C_PA_IIC6 + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_IIC6,
34 .end = IRQ_IIC6,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39struct platform_device s3c_device_i2c6 = {
40 .name = "s3c2440-i2c",
41 .id = 6,
42 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
43 .resource = s3c_i2c_resource,
44};
45
46static struct s3c2410_platform_i2c default_i2c_data6 __initdata = {
47 .flags = 0,
48 .bus_num = 6,
49 .slave_addr = 0x10,
50 .frequency = 100*1000,
51 .sda_delay = 100,
52};
53
54void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data6;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c6_cfg_gpio;
66
67 s3c_device_i2c6.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-samsung/dev-i2c7.c b/arch/arm/plat-samsung/dev-i2c7.c
new file mode 100644
index 000000000000..1182451d7dce
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-i2c7.c
@@ -0,0 +1,68 @@
1/* linux/arch/arm/plat-samsung/dev-i2c7.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P series device definition for i2c device 7
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/gfp.h>
14#include <linux/kernel.h>
15#include <linux/string.h>
16#include <linux/platform_device.h>
17
18#include <mach/irqs.h>
19#include <mach/map.h>
20
21#include <plat/regs-iic.h>
22#include <plat/iic.h>
23#include <plat/devs.h>
24#include <plat/cpu.h>
25
26static struct resource s3c_i2c_resource[] = {
27 [0] = {
28 .start = S3C_PA_IIC7,
29 .end = S3C_PA_IIC7 + SZ_4K - 1,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = IRQ_IIC7,
34 .end = IRQ_IIC7,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39struct platform_device s3c_device_i2c7 = {
40 .name = "s3c2440-i2c",
41 .id = 7,
42 .num_resources = ARRAY_SIZE(s3c_i2c_resource),
43 .resource = s3c_i2c_resource,
44};
45
46static struct s3c2410_platform_i2c default_i2c_data7 __initdata = {
47 .flags = 0,
48 .bus_num = 7,
49 .slave_addr = 0x10,
50 .frequency = 100*1000,
51 .sda_delay = 100,
52};
53
54void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd)
55{
56 struct s3c2410_platform_i2c *npd;
57
58 if (!pd)
59 pd = &default_i2c_data7;
60
61 npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
62 if (!npd)
63 printk(KERN_ERR "%s: no memory for platform data\n", __func__);
64 else if (!npd->cfg_gpio)
65 npd->cfg_gpio = s3c_i2c7_cfg_gpio;
66
67 s3c_device_i2c7.dev.platform_data = npd;
68}
diff --git a/arch/arm/plat-samsung/gpio-config.c b/arch/arm/plat-samsung/gpio-config.c
index e3d41eaed1ff..b732b773b9af 100644
--- a/arch/arm/plat-samsung/gpio-config.c
+++ b/arch/arm/plat-samsung/gpio-config.c
@@ -41,6 +41,37 @@ int s3c_gpio_cfgpin(unsigned int pin, unsigned int config)
41} 41}
42EXPORT_SYMBOL(s3c_gpio_cfgpin); 42EXPORT_SYMBOL(s3c_gpio_cfgpin);
43 43
44int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr,
45 unsigned int cfg)
46{
47 int ret;
48
49 for (; nr > 0; nr--, start++) {
50 ret = s3c_gpio_cfgpin(start, cfg);
51 if (ret != 0)
52 return ret;
53 }
54
55 return 0;
56}
57EXPORT_SYMBOL_GPL(s3c_gpio_cfgpin_range);
58
59int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr,
60 unsigned int cfg, s3c_gpio_pull_t pull)
61{
62 int ret;
63
64 for (; nr > 0; nr--, start++) {
65 s3c_gpio_setpull(start, pull);
66 ret = s3c_gpio_cfgpin(start, cfg);
67 if (ret != 0)
68 return ret;
69 }
70
71 return 0;
72}
73EXPORT_SYMBOL_GPL(s3c_gpio_cfgall_range);
74
44unsigned s3c_gpio_getcfg(unsigned int pin) 75unsigned s3c_gpio_getcfg(unsigned int pin)
45{ 76{
46 struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin); 77 struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
@@ -80,6 +111,25 @@ int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull)
80} 111}
81EXPORT_SYMBOL(s3c_gpio_setpull); 112EXPORT_SYMBOL(s3c_gpio_setpull);
82 113
114s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin)
115{
116 struct s3c_gpio_chip *chip = s3c_gpiolib_getchip(pin);
117 unsigned long flags;
118 int offset;
119 u32 pup = 0;
120
121 if (chip) {
122 offset = pin - chip->chip.base;
123
124 s3c_gpio_lock(chip, flags);
125 pup = s3c_gpio_do_getpull(chip, offset);
126 s3c_gpio_unlock(chip, flags);
127 }
128
129 return (__force s3c_gpio_pull_t)pup;
130}
131EXPORT_SYMBOL(s3c_gpio_getpull);
132
83#ifdef CONFIG_S3C_GPIO_CFG_S3C24XX 133#ifdef CONFIG_S3C_GPIO_CFG_S3C24XX
84int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip, 134int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip,
85 unsigned int off, unsigned int cfg) 135 unsigned int off, unsigned int cfg)
diff --git a/arch/arm/plat-samsung/gpio.c b/arch/arm/plat-samsung/gpio.c
index b83a83351cea..7743c4b8b2fb 100644
--- a/arch/arm/plat-samsung/gpio.c
+++ b/arch/arm/plat-samsung/gpio.c
@@ -157,3 +157,11 @@ __init void s3c_gpiolib_add(struct s3c_gpio_chip *chip)
157 if (ret >= 0) 157 if (ret >= 0)
158 s3c_gpiolib_track(chip); 158 s3c_gpiolib_track(chip);
159} 159}
160
161int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
162{
163 struct s3c_gpio_chip *s3c_chip = container_of(chip,
164 struct s3c_gpio_chip, chip);
165
166 return s3c_chip->irq_base + offset;
167}
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/audio.h b/arch/arm/plat-samsung/include/plat/audio.h
index e32f9edfd4b7..7712ff6336f4 100644
--- a/arch/arm/plat-samsung/include/plat/audio.h
+++ b/arch/arm/plat-samsung/include/plat/audio.h
@@ -16,6 +16,15 @@
16#define S3C64XX_AC97_GPE 1 16#define S3C64XX_AC97_GPE 1
17extern void s3c64xx_ac97_setup_gpio(int); 17extern void s3c64xx_ac97_setup_gpio(int);
18 18
19/*
20 * The machine init code calls s5p*_spdif_setup_gpio with
21 * one of these defines in order to select appropriate bank
22 * of GPIO for S/PDIF pins
23 */
24#define S5PC100_SPDIF_GPD 0
25#define S5PC100_SPDIF_GPG3 1
26extern void s5pc100_spdif_setup_gpio(int);
27
19/** 28/**
20 * struct s3c_audio_pdata - common platform data for audio device drivers 29 * struct s3c_audio_pdata - common platform data for audio device drivers
21 * @cfg_gpio: Callback function to setup mux'ed pins in I2S/PCM/AC97 mode 30 * @cfg_gpio: Callback function to setup mux'ed pins in I2S/PCM/AC97 mode
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 7d448e138792..2d82a6cb1444 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -32,6 +32,8 @@ extern struct platform_device s3c64xx_device_iisv4;
32extern struct platform_device s3c64xx_device_spi0; 32extern struct platform_device s3c64xx_device_spi0;
33extern struct platform_device s3c64xx_device_spi1; 33extern struct platform_device s3c64xx_device_spi1;
34 34
35extern struct platform_device s3c_device_pcm;
36
35extern struct platform_device s3c64xx_device_pcm0; 37extern struct platform_device s3c64xx_device_pcm0;
36extern struct platform_device s3c64xx_device_pcm1; 38extern struct platform_device s3c64xx_device_pcm1;
37 39
@@ -46,6 +48,11 @@ extern struct platform_device s3c_device_wdt;
46extern struct platform_device s3c_device_i2c0; 48extern struct platform_device s3c_device_i2c0;
47extern struct platform_device s3c_device_i2c1; 49extern struct platform_device s3c_device_i2c1;
48extern struct platform_device s3c_device_i2c2; 50extern struct platform_device s3c_device_i2c2;
51extern struct platform_device s3c_device_i2c3;
52extern struct platform_device s3c_device_i2c4;
53extern struct platform_device s3c_device_i2c5;
54extern struct platform_device s3c_device_i2c6;
55extern struct platform_device s3c_device_i2c7;
49extern struct platform_device s3c_device_rtc; 56extern struct platform_device s3c_device_rtc;
50extern struct platform_device s3c_device_adc; 57extern struct platform_device s3c_device_adc;
51extern struct platform_device s3c_device_sdi; 58extern struct platform_device s3c_device_sdi;
@@ -87,6 +94,7 @@ extern struct platform_device s5pv210_device_pcm2;
87extern struct platform_device s5pv210_device_iis0; 94extern struct platform_device s5pv210_device_iis0;
88extern struct platform_device s5pv210_device_iis1; 95extern struct platform_device s5pv210_device_iis1;
89extern struct platform_device s5pv210_device_iis2; 96extern struct platform_device s5pv210_device_iis2;
97extern struct platform_device s5pv210_device_spdif;
90 98
91extern struct platform_device s5p6442_device_pcm0; 99extern struct platform_device s5p6442_device_pcm0;
92extern struct platform_device s5p6442_device_pcm1; 100extern struct platform_device s5p6442_device_pcm1;
@@ -106,6 +114,7 @@ extern struct platform_device s5pc100_device_pcm1;
106extern struct platform_device s5pc100_device_iis0; 114extern struct platform_device s5pc100_device_iis0;
107extern struct platform_device s5pc100_device_iis1; 115extern struct platform_device s5pc100_device_iis1;
108extern struct platform_device s5pc100_device_iis2; 116extern struct platform_device s5pc100_device_iis2;
117extern struct platform_device s5pc100_device_spdif;
109 118
110extern struct platform_device samsung_device_keypad; 119extern struct platform_device samsung_device_keypad;
111 120
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
index 3e21c75feefa..8fd65d8b5863 100644
--- a/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
+++ b/arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h
@@ -42,6 +42,12 @@ static inline int s3c_gpio_do_setpull(struct s3c_gpio_chip *chip,
42 return (chip->config->set_pull)(chip, off, pull); 42 return (chip->config->set_pull)(chip, off, pull);
43} 43}
44 44
45static inline s3c_gpio_pull_t s3c_gpio_do_getpull(struct s3c_gpio_chip *chip,
46 unsigned int off)
47{
48 return chip->config->get_pull(chip, off);
49}
50
45/** 51/**
46 * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration. 52 * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration.
47 * @chip: The gpio chip that is being configured. 53 * @chip: The gpio chip that is being configured.
diff --git a/arch/arm/plat-samsung/include/plat/gpio-cfg.h b/arch/arm/plat-samsung/include/plat/gpio-cfg.h
index 1c6b92947c5d..e4b5cf126fa9 100644
--- a/arch/arm/plat-samsung/include/plat/gpio-cfg.h
+++ b/arch/arm/plat-samsung/include/plat/gpio-cfg.h
@@ -108,6 +108,19 @@ extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);
108 */ 108 */
109extern unsigned s3c_gpio_getcfg(unsigned int pin); 109extern unsigned s3c_gpio_getcfg(unsigned int pin);
110 110
111/**
112 * s3c_gpio_cfgpin_range() - Change the GPIO function for configuring pin range
113 * @start: The pin number to start at
114 * @nr: The number of pins to configure from @start.
115 * @cfg: The configuration for the pin's function
116 *
117 * Call s3c_gpio_cfgpin() for the @nr pins starting at @start.
118 *
119 * @sa s3c_gpio_cfgpin.
120 */
121extern int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr,
122 unsigned int cfg);
123
111/* Define values for the pull-{up,down} available for each gpio pin. 124/* Define values for the pull-{up,down} available for each gpio pin.
112 * 125 *
113 * These values control the state of the weak pull-{up,down} resistors 126 * These values control the state of the weak pull-{up,down} resistors
@@ -140,6 +153,31 @@ extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull);
140*/ 153*/
141extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin); 154extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin);
142 155
156/* configure `all` aspects of an gpio */
157
158/**
159 * s3c_gpio_cfgall_range() - configure range of gpio functtion and pull.
160 * @start: The gpio number to start at.
161 * @nr: The number of gpio to configure from @start.
162 * @cfg: The configuration to use
163 * @pull: The pull setting to use.
164 *
165 * Run s3c_gpio_cfgpin() and s3c_gpio_setpull() over the gpio range starting
166 * @gpio and running for @size.
167 *
168 * @sa s3c_gpio_cfgpin
169 * @sa s3c_gpio_setpull
170 * @sa s3c_gpio_cfgpin_range
171 */
172extern int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr,
173 unsigned int cfg, s3c_gpio_pull_t pull);
174
175static inline int s3c_gpio_cfgrange_nopull(unsigned int pin, unsigned int size,
176 unsigned int cfg)
177{
178 return s3c_gpio_cfgall_range(pin, size, cfg, S3C_GPIO_PULL_NONE);
179}
180
143/* Define values for the drvstr available for each gpio pin. 181/* Define values for the drvstr available for each gpio pin.
144 * 182 *
145 * These values control the value of the output signal driver strength, 183 * These values control the value of the output signal driver strength,
@@ -169,4 +207,22 @@ extern s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin);
169*/ 207*/
170extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr); 208extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr);
171 209
210/**
211 * s5p_register_gpio_interrupt() - register interrupt support for a gpio group
212 * @pin: The pin number from the group to be registered
213 *
214 * This function registers gpio interrupt support for the group that the
215 * specified pin belongs to.
216 *
217 * The total number of gpio pins is quite large ob s5p series. Registering
218 * irq support for all of them would be a resource waste. Because of that the
219 * interrupt support for standard gpio pins is registered dynamically.
220 *
221 * It will return the irq number of the interrupt that has been registered
222 * or -ENOMEM if no more gpio interrupts can be registered. It is allowed
223 * to call this function more than once for the same gpio group (the group
224 * will be registered only once).
225 */
226extern int s5p_register_gpio_interrupt(int pin);
227
172#endif /* __PLAT_GPIO_CFG_H */ 228#endif /* __PLAT_GPIO_CFG_H */
diff --git a/arch/arm/plat-samsung/include/plat/gpio-core.h b/arch/arm/plat-samsung/include/plat/gpio-core.h
index e358c7da8480..13a22b8861ef 100644
--- a/arch/arm/plat-samsung/include/plat/gpio-core.h
+++ b/arch/arm/plat-samsung/include/plat/gpio-core.h
@@ -43,6 +43,8 @@ struct s3c_gpio_cfg;
43 * struct s3c_gpio_chip - wrapper for specific implementation of gpio 43 * struct s3c_gpio_chip - wrapper for specific implementation of gpio
44 * @chip: The chip structure to be exported via gpiolib. 44 * @chip: The chip structure to be exported via gpiolib.
45 * @base: The base pointer to the gpio configuration registers. 45 * @base: The base pointer to the gpio configuration registers.
46 * @group: The group register number for gpio interrupt support.
47 * @irq_base: The base irq number.
46 * @config: special function and pull-resistor control information. 48 * @config: special function and pull-resistor control information.
47 * @lock: Lock for exclusive access to this gpio bank. 49 * @lock: Lock for exclusive access to this gpio bank.
48 * @pm_save: Save information for suspend/resume support. 50 * @pm_save: Save information for suspend/resume support.
@@ -63,6 +65,8 @@ struct s3c_gpio_chip {
63 struct s3c_gpio_cfg *config; 65 struct s3c_gpio_cfg *config;
64 struct s3c_gpio_pm *pm; 66 struct s3c_gpio_pm *pm;
65 void __iomem *base; 67 void __iomem *base;
68 int irq_base;
69 int group;
66 spinlock_t lock; 70 spinlock_t lock;
67#ifdef CONFIG_PM 71#ifdef CONFIG_PM
68 u32 pm_save[4]; 72 u32 pm_save[4];
@@ -118,6 +122,17 @@ extern void samsung_gpiolib_add_4bit2_chips(struct s3c_gpio_chip *chip,
118extern void samsung_gpiolib_add_4bit(struct s3c_gpio_chip *chip); 122extern void samsung_gpiolib_add_4bit(struct s3c_gpio_chip *chip);
119extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip); 123extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
120 124
125
126/**
127 * samsung_gpiolib_to_irq - convert gpio pin to irq number
128 * @chip: The gpio chip that the pin belongs to.
129 * @offset: The offset of the pin in the chip.
130 *
131 * This helper returns the irq number calculated from the chip->irq_base and
132 * the provided offset.
133 */
134extern int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset);
135
121/* exported for core SoC support to change */ 136/* exported for core SoC support to change */
122extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default; 137extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
123 138
diff --git a/arch/arm/plat-samsung/include/plat/iic.h b/arch/arm/plat-samsung/include/plat/iic.h
index 133308bf595d..1543da8f85c1 100644
--- a/arch/arm/plat-samsung/include/plat/iic.h
+++ b/arch/arm/plat-samsung/include/plat/iic.h
@@ -55,10 +55,20 @@ struct s3c2410_platform_i2c {
55extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c); 55extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c);
56extern void s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *i2c); 56extern void s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *i2c);
57extern void s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *i2c); 57extern void s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *i2c);
58extern void s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *i2c);
59extern void s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *i2c);
60extern void s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *i2c);
61extern void s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *i2c);
62extern void s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *i2c);
58 63
59/* defined by architecture to configure gpio */ 64/* defined by architecture to configure gpio */
60extern void s3c_i2c0_cfg_gpio(struct platform_device *dev); 65extern void s3c_i2c0_cfg_gpio(struct platform_device *dev);
61extern void s3c_i2c1_cfg_gpio(struct platform_device *dev); 66extern void s3c_i2c1_cfg_gpio(struct platform_device *dev);
62extern void s3c_i2c2_cfg_gpio(struct platform_device *dev); 67extern void s3c_i2c2_cfg_gpio(struct platform_device *dev);
68extern void s3c_i2c3_cfg_gpio(struct platform_device *dev);
69extern void s3c_i2c4_cfg_gpio(struct platform_device *dev);
70extern void s3c_i2c5_cfg_gpio(struct platform_device *dev);
71extern void s3c_i2c6_cfg_gpio(struct platform_device *dev);
72extern void s3c_i2c7_cfg_gpio(struct platform_device *dev);
63 73
64#endif /* __ASM_ARCH_IIC_H */ 74#endif /* __ASM_ARCH_IIC_H */
diff --git a/arch/arm/plat-samsung/include/plat/map-base.h b/arch/arm/plat-samsung/include/plat/map-base.h
index 250be311c85b..3ffac4d2e4f0 100644
--- a/arch/arm/plat-samsung/include/plat/map-base.h
+++ b/arch/arm/plat-samsung/include/plat/map-base.h
@@ -14,7 +14,7 @@
14#ifndef __ASM_PLAT_MAP_H 14#ifndef __ASM_PLAT_MAP_H
15#define __ASM_PLAT_MAP_H __FILE__ 15#define __ASM_PLAT_MAP_H __FILE__
16 16
17/* Fit all our registers in at 0xF4000000 upwards, trying to use as 17/* Fit all our registers in at 0xF6000000 upwards, trying to use as
18 * little of the VA space as possible so vmalloc and friends have a 18 * little of the VA space as possible so vmalloc and friends have a
19 * better chance of getting memory. 19 * better chance of getting memory.
20 * 20 *
@@ -22,7 +22,7 @@
22 * an single MOVS instruction (ie, only 8 bits of set data) 22 * an single MOVS instruction (ie, only 8 bits of set data)
23 */ 23 */
24 24
25#define S3C_ADDR_BASE (0xF4000000) 25#define S3C_ADDR_BASE 0xF6000000
26 26
27#ifndef __ASSEMBLY__ 27#ifndef __ASSEMBLY__
28#define S3C_ADDR(x) ((void __iomem __force *)S3C_ADDR_BASE + (x)) 28#define S3C_ADDR(x) ((void __iomem __force *)S3C_ADDR_BASE + (x))
diff --git a/arch/arm/plat-samsung/include/plat/nand-core.h b/arch/arm/plat-samsung/include/plat/nand-core.h
new file mode 100644
index 000000000000..6de20789a95e
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/nand-core.h
@@ -0,0 +1,28 @@
1/* arch/arm/plat-samsung/include/plat/nand-core.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S3C - Nand Controller core functions
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_NAND_CORE_H
14#define __ASM_ARCH_NAND_CORE_H __FILE__
15
16/* These functions are only for use with the core support code, such as
17 * the cpu specific initialisation code
18 */
19
20/* re-define device name depending on support. */
21static inline void s3c_nand_setname(char *name)
22{
23#ifdef CONFIG_S3C_DEV_NAND
24 s3c_device_nand.name = name;
25#endif
26}
27
28#endif /* __ASM_ARCH_NAND_CORE_H */
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h
index 30844c263d03..85853f8c4c5d 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -28,11 +28,17 @@ enum cd_types {
28 S3C_SDHCI_CD_PERMANENT, /* no CD line, card permanently wired to host */ 28 S3C_SDHCI_CD_PERMANENT, /* no CD line, card permanently wired to host */
29}; 29};
30 30
31enum clk_types {
32 S3C_SDHCI_CLK_DIV_INTERNAL, /* use mmc internal clock divider */
33 S3C_SDHCI_CLK_DIV_EXTERNAL, /* use external clock divider */
34};
35
31/** 36/**
32 * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI 37 * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
33 * @max_width: The maximum number of data bits supported. 38 * @max_width: The maximum number of data bits supported.
34 * @host_caps: Standard MMC host capabilities bit field. 39 * @host_caps: Standard MMC host capabilities bit field.
35 * @cd_type: Type of Card Detection method (see cd_types enum above) 40 * @cd_type: Type of Card Detection method (see cd_types enum above)
41 * @clk_type: Type of clock divider method (see clk_types enum above)
36 * @ext_cd_init: Initialize external card detect subsystem. Called on 42 * @ext_cd_init: Initialize external card detect subsystem. Called on
37 * sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL. 43 * sdhci-s3c driver probe when cd_type == S3C_SDHCI_CD_EXTERNAL.
38 * notify_func argument is a callback to the sdhci-s3c driver 44 * notify_func argument is a callback to the sdhci-s3c driver
@@ -59,6 +65,7 @@ struct s3c_sdhci_platdata {
59 unsigned int max_width; 65 unsigned int max_width;
60 unsigned int host_caps; 66 unsigned int host_caps;
61 enum cd_types cd_type; 67 enum cd_types cd_type;
68 enum clk_types clk_type;
62 69
63 char **clocks; /* set of clock sources */ 70 char **clocks; /* set of clock sources */
64 71
@@ -110,6 +117,10 @@ extern void s5pv210_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
110extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w); 117extern void s5pv210_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
111extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w); 118extern void s5pv210_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
112extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w); 119extern void s5pv210_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
120extern void s5pv310_setup_sdhci0_cfg_gpio(struct platform_device *, int w);
121extern void s5pv310_setup_sdhci1_cfg_gpio(struct platform_device *, int w);
122extern void s5pv310_setup_sdhci2_cfg_gpio(struct platform_device *, int w);
123extern void s5pv310_setup_sdhci3_cfg_gpio(struct platform_device *, int w);
113 124
114/* S3C64XX SDHCI setup */ 125/* S3C64XX SDHCI setup */
115 126
@@ -288,4 +299,57 @@ static inline void s5pv210_default_sdhci3(void) { }
288 299
289#endif /* CONFIG_S5PV210_SETUP_SDHCI */ 300#endif /* CONFIG_S5PV210_SETUP_SDHCI */
290 301
302/* S5PV310 SDHCI setup */
303#ifdef CONFIG_S5PV310_SETUP_SDHCI
304extern char *s5pv310_hsmmc_clksrcs[4];
305
306extern void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
307 void __iomem *r,
308 struct mmc_ios *ios,
309 struct mmc_card *card);
310
311static inline void s5pv310_default_sdhci0(void)
312{
313#ifdef CONFIG_S3C_DEV_HSMMC
314 s3c_hsmmc0_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
315 s3c_hsmmc0_def_platdata.cfg_gpio = s5pv310_setup_sdhci0_cfg_gpio;
316 s3c_hsmmc0_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
317#endif
318}
319
320static inline void s5pv310_default_sdhci1(void)
321{
322#ifdef CONFIG_S3C_DEV_HSMMC1
323 s3c_hsmmc1_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
324 s3c_hsmmc1_def_platdata.cfg_gpio = s5pv310_setup_sdhci1_cfg_gpio;
325 s3c_hsmmc1_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
326#endif
327}
328
329static inline void s5pv310_default_sdhci2(void)
330{
331#ifdef CONFIG_S3C_DEV_HSMMC2
332 s3c_hsmmc2_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
333 s3c_hsmmc2_def_platdata.cfg_gpio = s5pv310_setup_sdhci2_cfg_gpio;
334 s3c_hsmmc2_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
335#endif
336}
337
338static inline void s5pv310_default_sdhci3(void)
339{
340#ifdef CONFIG_S3C_DEV_HSMMC3
341 s3c_hsmmc3_def_platdata.clocks = s5pv310_hsmmc_clksrcs;
342 s3c_hsmmc3_def_platdata.cfg_gpio = s5pv310_setup_sdhci3_cfg_gpio;
343 s3c_hsmmc3_def_platdata.cfg_card = s5pv310_setup_sdhci_cfg_card;
344#endif
345}
346
347#else
348static inline void s5pv310_default_sdhci0(void) { }
349static inline void s5pv310_default_sdhci1(void) { }
350static inline void s5pv310_default_sdhci2(void) { }
351static inline void s5pv310_default_sdhci3(void) { }
352
353#endif /* CONFIG_S5PV310_SETUP_SDHCI */
354
291#endif /* __PLAT_S3C_SDHCI_H */ 355#endif /* __PLAT_S3C_SDHCI_H */
diff --git a/arch/arm/plat-samsung/pm-gpio.c b/arch/arm/plat-samsung/pm-gpio.c
index 7df03f87fbfa..96528200eb79 100644
--- a/arch/arm/plat-samsung/pm-gpio.c
+++ b/arch/arm/plat-samsung/pm-gpio.c
@@ -192,7 +192,7 @@ struct s3c_gpio_pm s3c_gpio_pm_2bit = {
192 .resume = s3c_gpio_pm_2bit_resume, 192 .resume = s3c_gpio_pm_2bit_resume,
193}; 193};
194 194
195#ifdef CONFIG_ARCH_S3C64XX 195#if defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_PLAT_S5P)
196static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip) 196static void s3c_gpio_pm_4bit_save(struct s3c_gpio_chip *chip)
197{ 197{
198 chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON); 198 chip->pm_save[1] = __raw_readl(chip->base + OFFS_CON);
@@ -302,7 +302,7 @@ struct s3c_gpio_pm s3c_gpio_pm_4bit = {
302 .save = s3c_gpio_pm_4bit_save, 302 .save = s3c_gpio_pm_4bit_save,
303 .resume = s3c_gpio_pm_4bit_resume, 303 .resume = s3c_gpio_pm_4bit_resume,
304}; 304};
305#endif /* CONFIG_ARCH_S3C64XX */ 305#endif /* CONFIG_ARCH_S3C64XX || CONFIG_PLAT_S5P */
306 306
307/** 307/**
308 * s3c_pm_save_gpio() - save gpio chip data for suspend 308 * s3c_pm_save_gpio() - save gpio chip data for suspend
diff --git a/arch/arm/plat-samsung/s3c-pl330.c b/arch/arm/plat-samsung/s3c-pl330.c
index a91305a60aed..b4ff8d74ac40 100644
--- a/arch/arm/plat-samsung/s3c-pl330.c
+++ b/arch/arm/plat-samsung/s3c-pl330.c
@@ -15,6 +15,8 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/clk.h>
19#include <linux/err.h>
18 20
19#include <asm/hardware/pl330.h> 21#include <asm/hardware/pl330.h>
20 22
@@ -27,6 +29,7 @@
27 * @node: To attach to the global list of DMACs. 29 * @node: To attach to the global list of DMACs.
28 * @pi: PL330 configuration info for the DMAC. 30 * @pi: PL330 configuration info for the DMAC.
29 * @kmcache: Pool to quickly allocate xfers for all channels in the dmac. 31 * @kmcache: Pool to quickly allocate xfers for all channels in the dmac.
32 * @clk: Pointer of DMAC operation clock.
30 */ 33 */
31struct s3c_pl330_dmac { 34struct s3c_pl330_dmac {
32 unsigned busy_chan; 35 unsigned busy_chan;
@@ -34,6 +37,7 @@ struct s3c_pl330_dmac {
34 struct list_head node; 37 struct list_head node;
35 struct pl330_info *pi; 38 struct pl330_info *pi;
36 struct kmem_cache *kmcache; 39 struct kmem_cache *kmcache;
40 struct clk *clk;
37}; 41};
38 42
39/** 43/**
@@ -1072,16 +1076,25 @@ static int pl330_probe(struct platform_device *pdev)
1072 if (ret) 1076 if (ret)
1073 goto probe_err4; 1077 goto probe_err4;
1074 1078
1075 ret = pl330_add(pl330_info);
1076 if (ret)
1077 goto probe_err5;
1078
1079 /* Allocate a new DMAC */ 1079 /* Allocate a new DMAC */
1080 s3c_pl330_dmac = kmalloc(sizeof(*s3c_pl330_dmac), GFP_KERNEL); 1080 s3c_pl330_dmac = kmalloc(sizeof(*s3c_pl330_dmac), GFP_KERNEL);
1081 if (!s3c_pl330_dmac) { 1081 if (!s3c_pl330_dmac) {
1082 ret = -ENOMEM; 1082 ret = -ENOMEM;
1083 goto probe_err5;
1084 }
1085
1086 /* Get operation clock and enable it */
1087 s3c_pl330_dmac->clk = clk_get(&pdev->dev, "pdma");
1088 if (IS_ERR(s3c_pl330_dmac->clk)) {
1089 dev_err(&pdev->dev, "Cannot get operation clock.\n");
1090 ret = -EINVAL;
1083 goto probe_err6; 1091 goto probe_err6;
1084 } 1092 }
1093 clk_enable(s3c_pl330_dmac->clk);
1094
1095 ret = pl330_add(pl330_info);
1096 if (ret)
1097 goto probe_err7;
1085 1098
1086 /* Hook the info */ 1099 /* Hook the info */
1087 s3c_pl330_dmac->pi = pl330_info; 1100 s3c_pl330_dmac->pi = pl330_info;
@@ -1094,7 +1107,7 @@ static int pl330_probe(struct platform_device *pdev)
1094 1107
1095 if (!s3c_pl330_dmac->kmcache) { 1108 if (!s3c_pl330_dmac->kmcache) {
1096 ret = -ENOMEM; 1109 ret = -ENOMEM;
1097 goto probe_err7; 1110 goto probe_err8;
1098 } 1111 }
1099 1112
1100 /* Get the list of peripherals */ 1113 /* Get the list of peripherals */
@@ -1120,10 +1133,13 @@ static int pl330_probe(struct platform_device *pdev)
1120 1133
1121 return 0; 1134 return 0;
1122 1135
1136probe_err8:
1137 pl330_del(pl330_info);
1123probe_err7: 1138probe_err7:
1124 kfree(s3c_pl330_dmac); 1139 clk_disable(s3c_pl330_dmac->clk);
1140 clk_put(s3c_pl330_dmac->clk);
1125probe_err6: 1141probe_err6:
1126 pl330_del(pl330_info); 1142 kfree(s3c_pl330_dmac);
1127probe_err5: 1143probe_err5:
1128 free_irq(irq, pl330_info); 1144 free_irq(irq, pl330_info);
1129probe_err4: 1145probe_err4:
@@ -1188,6 +1204,10 @@ static int pl330_remove(struct platform_device *pdev)
1188 } 1204 }
1189 } 1205 }
1190 1206
1207 /* Disable operation clock */
1208 clk_disable(dmac->clk);
1209 clk_put(dmac->clk);
1210
1191 /* Remove the DMAC */ 1211 /* Remove the DMAC */
1192 list_del(&dmac->node); 1212 list_del(&dmac->node);
1193 kfree(dmac); 1213 kfree(dmac);
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 9ac87255a03a..313b13073c54 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux Kernel Configuration"
7
8config AVR32 1config AVR32
9 def_bool y 2 def_bool y
10 # With EMBEDDED=n, we get lots of stuff automatically selected 3 # With EMBEDDED=n, we get lots of stuff automatically selected
@@ -146,7 +139,7 @@ config BOARD_HAMMERHEAD
146 will cover even the most exceptional need of memory bandwidth. Together with the onboard 139 will cover even the most exceptional need of memory bandwidth. Together with the onboard
147 video decoder the board is ready for video processing. 140 video decoder the board is ready for video processing.
148 141
149 For more information see: http://www.miromico.com/hammerhead 142 For more information see: http://www.miromico.ch/index.php/hammerhead.html
150 143
151config BOARD_FAVR_32 144config BOARD_FAVR_32
152 bool "Favr-32 LCD-board" 145 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/pgtable.h b/arch/avr32/include/asm/pgtable.h
index a9ae30c41e74..6fbfea61f7bb 100644
--- a/arch/avr32/include/asm/pgtable.h
+++ b/arch/avr32/include/asm/pgtable.h
@@ -319,9 +319,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
319#define pte_offset_kernel(dir, address) \ 319#define pte_offset_kernel(dir, address) \
320 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) 320 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
321#define pte_offset_map(dir, address) pte_offset_kernel(dir, address) 321#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
322#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
323#define pte_unmap(pte) do { } while (0) 322#define pte_unmap(pte) do { } while (0)
324#define pte_unmap_nested(pte) do { } while (0)
325 323
326struct vm_area_struct; 324struct vm_area_struct;
327extern void update_mmu_cache(struct vm_area_struct * vma, 325extern void update_mmu_cache(struct vm_area_struct * vma,
diff --git a/arch/avr32/kernel/ptrace.c b/arch/avr32/kernel/ptrace.c
index 5e73c25f8f85..4aedcab7cd4b 100644
--- a/arch/avr32/kernel/ptrace.c
+++ b/arch/avr32/kernel/ptrace.c
@@ -146,9 +146,11 @@ static int ptrace_setregs(struct task_struct *tsk, const void __user *uregs)
146 return ret; 146 return ret;
147} 147}
148 148
149long arch_ptrace(struct task_struct *child, long request, long addr, long data) 149long arch_ptrace(struct task_struct *child, long request,
150 unsigned long addr, unsigned long data)
150{ 151{
151 int ret; 152 int ret;
153 void __user *datap = (void __user *) data;
152 154
153 switch (request) { 155 switch (request) {
154 /* Read the word at location addr in the child process */ 156 /* Read the word at location addr in the child process */
@@ -158,8 +160,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
158 break; 160 break;
159 161
160 case PTRACE_PEEKUSR: 162 case PTRACE_PEEKUSR:
161 ret = ptrace_read_user(child, addr, 163 ret = ptrace_read_user(child, addr, datap);
162 (unsigned long __user *)data);
163 break; 164 break;
164 165
165 /* Write the word in data at location addr */ 166 /* Write the word in data at location addr */
@@ -173,11 +174,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
173 break; 174 break;
174 175
175 case PTRACE_GETREGS: 176 case PTRACE_GETREGS:
176 ret = ptrace_getregs(child, (void __user *)data); 177 ret = ptrace_getregs(child, datap);
177 break; 178 break;
178 179
179 case PTRACE_SETREGS: 180 case PTRACE_SETREGS:
180 ret = ptrace_setregs(child, (const void __user *)data); 181 ret = ptrace_setregs(child, datap);
181 break; 182 break;
182 183
183 default: 184 default:
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 5a3152b75cdb..0a221d48152d 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Blackfin Kernel Configuration"
7
8config SYMBOL_PREFIX 1config SYMBOL_PREFIX
9 string 2 string
10 default "_" 3 default "_"
@@ -300,7 +293,7 @@ config BF_REV_0_1
300 293
301config BF_REV_0_2 294config BF_REV_0_2
302 bool "0.2" 295 bool "0.2"
303 depends on (BF52x || BF537 || BF536 || BF534 || (BF54x && !BF54xM)) 296 depends on (BF51x || BF52x || BF537 || BF536 || BF534 || (BF54x && !BF54xM))
304 297
305config BF_REV_0_3 298config BF_REV_0_3
306 bool "0.3" 299 bool "0.3"
@@ -356,7 +349,7 @@ config MEM_MT48LC8M32B2B5_7
356 349
357config MEM_MT48LC32M16A2TG_75 350config MEM_MT48LC32M16A2TG_75
358 bool 351 bool
359 depends on (BFIN527_EZKIT || BFIN527_EZKIT_V2 || BFIN532_IP0X || BLACKSTAMP) 352 depends on (BFIN527_EZKIT || BFIN527_EZKIT_V2 || BFIN532_IP0X || BLACKSTAMP || BFIN527_AD7160EVAL)
360 default y 353 default y
361 354
362config MEM_MT48H32M16LFCJ_75 355config MEM_MT48H32M16LFCJ_75
@@ -426,6 +419,7 @@ config CLKIN_HZ
426 default "25000000" # most people use this 419 default "25000000" # most people use this
427 default "27000000" if BFIN533_EZKIT 420 default "27000000" if BFIN533_EZKIT
428 default "30000000" if BFIN561_EZKIT 421 default "30000000" if BFIN561_EZKIT
422 default "24000000" if BFIN527_AD7160EVAL
429 help 423 help
430 The frequency of CLKIN crystal oscillator on the board in Hz. 424 The frequency of CLKIN crystal oscillator on the board in Hz.
431 Warning: This value should match the crystal on the board. Otherwise, 425 Warning: This value should match the crystal on the board. Otherwise,
@@ -463,6 +457,7 @@ config VCO_MULT
463 default "20" if (BFIN537_BLUETECHNIX_CM_E || BFIN537_BLUETECHNIX_CM_U || BFIN527_BLUETECHNIX_CM || BFIN561_BLUETECHNIX_CM) 457 default "20" if (BFIN537_BLUETECHNIX_CM_E || BFIN537_BLUETECHNIX_CM_U || BFIN527_BLUETECHNIX_CM || BFIN561_BLUETECHNIX_CM)
464 default "20" if BFIN561_EZKIT 458 default "20" if BFIN561_EZKIT
465 default "16" if (H8606_HVSISTEMAS || BLACKSTAMP || BFIN526_EZBRD || BFIN518F_EZBRD) 459 default "16" if (H8606_HVSISTEMAS || BLACKSTAMP || BFIN526_EZBRD || BFIN518F_EZBRD)
460 default "25" if BFIN527_AD7160EVAL
466 help 461 help
467 This controls the frequency of the on-chip PLL. This can be between 1 and 64. 462 This controls the frequency of the on-chip PLL. This can be between 1 and 64.
468 PLL Frequency = (Crystal Frequency) * (this setting) 463 PLL Frequency = (Crystal Frequency) * (this setting)
@@ -926,6 +921,12 @@ config ROMKERNEL
926 921
927endchoice 922endchoice
928 923
924# Common code uses "ROMKERNEL" or "XIP_KERNEL", so define both
925config XIP_KERNEL
926 bool
927 default y
928 depends on ROMKERNEL
929
929source "mm/Kconfig" 930source "mm/Kconfig"
930 931
931config BFIN_GPTIMERS 932config BFIN_GPTIMERS
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug
index d1825cb24768..acb83799a215 100644
--- a/arch/blackfin/Kconfig.debug
+++ b/arch/blackfin/Kconfig.debug
@@ -102,17 +102,6 @@ config DEBUG_DOUBLEFAULT_RESET
102 102
103endchoice 103endchoice
104 104
105config DEBUG_ICACHE_CHECK
106 bool "Check Instruction cache coherency"
107 depends on DEBUG_KERNEL
108 depends on DEBUG_HWERR
109 help
110 Say Y here if you are getting weird unexplained errors. This will
111 ensure that icache is what SDRAM says it should be by doing a
112 byte wise comparison between SDRAM and instruction cache. This
113 also relocates the irq_panic() function to L1 memory, (which is
114 un-cached).
115
116config DEBUG_HUNT_FOR_ZERO 105config DEBUG_HUNT_FOR_ZERO
117 bool "Catch NULL pointer reads/writes" 106 bool "Catch NULL pointer reads/writes"
118 default y 107 default y
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/BF518F-EZBRD_defconfig b/arch/blackfin/configs/BF518F-EZBRD_defconfig
index 46fac1bf0605..c0b988ee30df 100644
--- a/arch/blackfin/configs/BF518F-EZBRD_defconfig
+++ b/arch/blackfin/configs/BF518F-EZBRD_defconfig
@@ -35,6 +35,7 @@ CONFIG_C_CDPRIO=y
35CONFIG_BANK_3=0x99B2 35CONFIG_BANK_3=0x99B2
36CONFIG_BINFMT_FLAT=y 36CONFIG_BINFMT_FLAT=y
37CONFIG_BINFMT_ZFLAT=y 37CONFIG_BINFMT_ZFLAT=y
38CONFIG_PM=y
38CONFIG_NET=y 39CONFIG_NET=y
39CONFIG_PACKET=y 40CONFIG_PACKET=y
40CONFIG_UNIX=y 41CONFIG_UNIX=y
@@ -114,7 +115,6 @@ CONFIG_DEBUG_DOUBLEFAULT=y
114CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 115CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
115CONFIG_EARLY_PRINTK=y 116CONFIG_EARLY_PRINTK=y
116CONFIG_CPLB_INFO=y 117CONFIG_CPLB_INFO=y
117CONFIG_SECURITY=y
118CONFIG_CRYPTO=y 118CONFIG_CRYPTO=y
119# CONFIG_CRYPTO_ANSI_CPRNG is not set 119# CONFIG_CRYPTO_ANSI_CPRNG is not set
120CONFIG_CRC_CCITT=m 120CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/BF526-EZBRD_defconfig b/arch/blackfin/configs/BF526-EZBRD_defconfig
index 80240806cf9e..864af5b68874 100644
--- a/arch/blackfin/configs/BF526-EZBRD_defconfig
+++ b/arch/blackfin/configs/BF526-EZBRD_defconfig
@@ -40,6 +40,7 @@ CONFIG_C_CDPRIO=y
40CONFIG_BANK_3=0x99B2 40CONFIG_BANK_3=0x99B2
41CONFIG_BINFMT_FLAT=y 41CONFIG_BINFMT_FLAT=y
42CONFIG_BINFMT_ZFLAT=y 42CONFIG_BINFMT_ZFLAT=y
43CONFIG_PM=y
43CONFIG_NET=y 44CONFIG_NET=y
44CONFIG_PACKET=y 45CONFIG_PACKET=y
45CONFIG_UNIX=y 46CONFIG_UNIX=y
@@ -152,7 +153,6 @@ CONFIG_DEBUG_DOUBLEFAULT=y
152CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 153CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
153CONFIG_EARLY_PRINTK=y 154CONFIG_EARLY_PRINTK=y
154CONFIG_CPLB_INFO=y 155CONFIG_CPLB_INFO=y
155CONFIG_SECURITY=y
156CONFIG_CRYPTO=y 156CONFIG_CRYPTO=y
157# CONFIG_CRYPTO_ANSI_CPRNG is not set 157# CONFIG_CRYPTO_ANSI_CPRNG is not set
158CONFIG_CRC_CCITT=m 158CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/BF527-AD7160-EVAL_defconfig b/arch/blackfin/configs/BF527-AD7160-EVAL_defconfig
new file mode 100644
index 000000000000..7b6a3370dbe2
--- /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_MMAP_ALLOW_UNINITIALIZED=y
13CONFIG_MODULES=y
14CONFIG_MODULE_UNLOAD=y
15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set
17CONFIG_PREEMPT=y
18CONFIG_BF527=y
19CONFIG_BF_REV_0_2=y
20CONFIG_IRQ_TWI=7
21CONFIG_IRQ_PORTH_INTA=7
22CONFIG_IRQ_PORTH_INTB=7
23CONFIG_BFIN527_AD7160EVAL=y
24CONFIG_BF527_SPORT0_PORTF=y
25CONFIG_BF527_UART1_PORTG=y
26CONFIG_IRQ_USB_INT0=11
27CONFIG_IRQ_USB_INT1=11
28CONFIG_IRQ_USB_INT2=11
29CONFIG_IRQ_USB_DMA=11
30CONFIG_CMDLINE_BOOL=y
31CONFIG_CMDLINE="bootargs=root=/dev/mtdblock0 rw clkin_hz=24000000 earlyprintk=serial,uart0,57600 console=tty0 console=ttyBF0,57600"
32CONFIG_CLKIN_HZ=24000000
33CONFIG_HZ_300=y
34# CONFIG_CYCLES_CLOCKSOURCE is not set
35CONFIG_IP_CHECKSUM_L1=y
36CONFIG_SYSCALL_TAB_L1=y
37CONFIG_CPLB_SWITCH_TAB_L1=y
38CONFIG_BFIN_GPTIMERS=y
39CONFIG_C_CDPRIO=y
40CONFIG_BANK_1=0x5554
41CONFIG_BANK_3=0xFFC0
42CONFIG_BINFMT_FLAT=y
43CONFIG_BINFMT_ZFLAT=y
44CONFIG_NET=y
45CONFIG_UNIX=y
46# CONFIG_WIRELESS is not set
47CONFIG_BLK_DEV_LOOP=y
48CONFIG_BLK_DEV_RAM=y
49# CONFIG_MISC_DEVICES is not set
50# CONFIG_INPUT_MOUSEDEV is not set
51CONFIG_INPUT_EVDEV=y
52# CONFIG_INPUT_KEYBOARD is not set
53# CONFIG_INPUT_MOUSE is not set
54CONFIG_INPUT_TOUCHSCREEN=y
55CONFIG_TOUCHSCREEN_AD7160=y
56CONFIG_TOUCHSCREEN_AD7160_FW=y
57# CONFIG_SERIO is not set
58# CONFIG_BFIN_DMA_INTERFACE is not set
59# CONFIG_DEVKMEM is not set
60CONFIG_SERIAL_BFIN=y
61CONFIG_SERIAL_BFIN_CONSOLE=y
62CONFIG_SERIAL_BFIN_UART0=y
63# CONFIG_LEGACY_PTYS is not set
64# CONFIG_BFIN_OTP is not set
65# CONFIG_HW_RANDOM is not set
66CONFIG_I2C=y
67# CONFIG_I2C_HELPER_AUTO is not set
68CONFIG_I2C_ALGOBIT=y
69CONFIG_I2C_BLACKFIN_TWI=y
70CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=400
71CONFIG_SPI=y
72CONFIG_SPI_BFIN=y
73CONFIG_GPIOLIB=y
74CONFIG_GPIO_SYSFS=y
75# CONFIG_HWMON is not set
76CONFIG_FB=y
77CONFIG_FRAMEBUFFER_CONSOLE=y
78CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
79CONFIG_LOGO=y
80# CONFIG_LOGO_LINUX_MONO is not set
81# CONFIG_LOGO_LINUX_VGA16 is not set
82# CONFIG_LOGO_LINUX_CLUT224 is not set
83# CONFIG_LOGO_BLACKFIN_VGA16 is not set
84# CONFIG_HID_SUPPORT is not set
85CONFIG_USB_MUSB_HDRC=y
86CONFIG_USB_GADGET_MUSB_HDRC=y
87CONFIG_USB_GADGET=y
88CONFIG_USB_GADGET_VBUS_DRAW=500
89CONFIG_USB_G_SERIAL=y
90CONFIG_MMC=y
91CONFIG_MMC_SPI=y
92CONFIG_EXT2_FS=y
93# CONFIG_DNOTIFY is not set
94CONFIG_MSDOS_FS=y
95CONFIG_VFAT_FS=y
96CONFIG_NLS_CODEPAGE_437=y
97CONFIG_NLS_ISO8859_1=y
98CONFIG_DEBUG_KERNEL=y
99CONFIG_DETECT_HUNG_TASK=y
100# CONFIG_SCHED_DEBUG is not set
101# CONFIG_DEBUG_BUGVERBOSE is not set
102# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
103CONFIG_EARLY_PRINTK=y
104CONFIG_CPLB_INFO=y
105CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/BF527-EZKIT-V2_defconfig b/arch/blackfin/configs/BF527-EZKIT-V2_defconfig
index 4a9125558fcf..4faa6b46a352 100644
--- a/arch/blackfin/configs/BF527-EZKIT-V2_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT-V2_defconfig
@@ -20,6 +20,7 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_BF527=y 25CONFIG_BF527=y
25CONFIG_BF_REV_0_2=y 26CONFIG_BF_REV_0_2=y
@@ -38,6 +39,7 @@ CONFIG_C_CDPRIO=y
38CONFIG_BANK_3=0x99B2 39CONFIG_BANK_3=0x99B2
39CONFIG_BINFMT_FLAT=y 40CONFIG_BINFMT_FLAT=y
40CONFIG_BINFMT_ZFLAT=y 41CONFIG_BINFMT_ZFLAT=y
42CONFIG_PM=y
41CONFIG_NET=y 43CONFIG_NET=y
42CONFIG_PACKET=y 44CONFIG_PACKET=y
43CONFIG_UNIX=y 45CONFIG_UNIX=y
@@ -181,6 +183,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
181CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 183CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
182CONFIG_EARLY_PRINTK=y 184CONFIG_EARLY_PRINTK=y
183CONFIG_CPLB_INFO=y 185CONFIG_CPLB_INFO=y
184CONFIG_SECURITY=y
185CONFIG_CRYPTO=y 186CONFIG_CRYPTO=y
186# CONFIG_CRYPTO_ANSI_CPRNG is not set 187# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF527-EZKIT_defconfig b/arch/blackfin/configs/BF527-EZKIT_defconfig
index 8ccf3cec7534..9d893eb68243 100644
--- a/arch/blackfin/configs/BF527-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF527-EZKIT_defconfig
@@ -20,6 +20,7 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_BF527=y 25CONFIG_BF527=y
25CONFIG_BF_REV_0_1=y 26CONFIG_BF_REV_0_1=y
@@ -37,6 +38,7 @@ CONFIG_C_CDPRIO=y
37CONFIG_BANK_3=0x99B2 38CONFIG_BANK_3=0x99B2
38CONFIG_BINFMT_FLAT=y 39CONFIG_BINFMT_FLAT=y
39CONFIG_BINFMT_ZFLAT=y 40CONFIG_BINFMT_ZFLAT=y
41CONFIG_PM=y
40CONFIG_NET=y 42CONFIG_NET=y
41CONFIG_PACKET=y 43CONFIG_PACKET=y
42CONFIG_UNIX=y 44CONFIG_UNIX=y
@@ -173,6 +175,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
173CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 175CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
174CONFIG_EARLY_PRINTK=y 176CONFIG_EARLY_PRINTK=y
175CONFIG_CPLB_INFO=y 177CONFIG_CPLB_INFO=y
176CONFIG_SECURITY=y
177CONFIG_CRYPTO=y 178CONFIG_CRYPTO=y
178# CONFIG_CRYPTO_ANSI_CPRNG is not set 179# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF527-TLL6527M_defconfig b/arch/blackfin/configs/BF527-TLL6527M_defconfig
new file mode 100644
index 000000000000..97a2767c80f8
--- /dev/null
+++ b/arch/blackfin/configs/BF527-TLL6527M_defconfig
@@ -0,0 +1,179 @@
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_CRYPTO=y
178# CONFIG_CRYPTO_ANSI_CPRNG is not set
179CONFIG_CRC7=m
diff --git a/arch/blackfin/configs/BF533-EZKIT_defconfig b/arch/blackfin/configs/BF533-EZKIT_defconfig
index c40e0f1c7eac..f84774360c5b 100644
--- a/arch/blackfin/configs/BF533-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF533-EZKIT_defconfig
@@ -20,6 +20,7 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_BFIN533_EZKIT=y 25CONFIG_BFIN533_EZKIT=y
25CONFIG_TIMER0=11 26CONFIG_TIMER0=11
@@ -107,6 +108,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
107CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 108CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
108CONFIG_EARLY_PRINTK=y 109CONFIG_EARLY_PRINTK=y
109CONFIG_CPLB_INFO=y 110CONFIG_CPLB_INFO=y
110CONFIG_SECURITY=y
111CONFIG_CRYPTO=y 111CONFIG_CRYPTO=y
112# CONFIG_CRYPTO_ANSI_CPRNG is not set 112# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF533-STAMP_defconfig b/arch/blackfin/configs/BF533-STAMP_defconfig
index aa8c1d7453ba..0e7262c04cc2 100644
--- a/arch/blackfin/configs/BF533-STAMP_defconfig
+++ b/arch/blackfin/configs/BF533-STAMP_defconfig
@@ -20,6 +20,7 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_TIMER0=11 25CONFIG_TIMER0=11
25CONFIG_HIGH_RES_TIMERS=y 26CONFIG_HIGH_RES_TIMERS=y
@@ -121,6 +122,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
121CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 122CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
122CONFIG_EARLY_PRINTK=y 123CONFIG_EARLY_PRINTK=y
123CONFIG_CPLB_INFO=y 124CONFIG_CPLB_INFO=y
124CONFIG_SECURITY=y
125CONFIG_CRYPTO=y 125CONFIG_CRYPTO=y
126# CONFIG_CRYPTO_ANSI_CPRNG is not set 126# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF537-STAMP_defconfig b/arch/blackfin/configs/BF537-STAMP_defconfig
index f245c0b427e4..4d14a002e7bd 100644
--- a/arch/blackfin/configs/BF537-STAMP_defconfig
+++ b/arch/blackfin/configs/BF537-STAMP_defconfig
@@ -20,9 +20,9 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_BF537=y 25CONFIG_BF537=y
25CONFIG_IRQ_ERROR=11
26CONFIG_HIGH_RES_TIMERS=y 26CONFIG_HIGH_RES_TIMERS=y
27CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0 27CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
28CONFIG_BFIN_GPTIMERS=m 28CONFIG_BFIN_GPTIMERS=m
@@ -133,6 +133,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
133CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 133CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
134CONFIG_EARLY_PRINTK=y 134CONFIG_EARLY_PRINTK=y
135CONFIG_CPLB_INFO=y 135CONFIG_CPLB_INFO=y
136CONFIG_SECURITY=y
137CONFIG_CRYPTO=y 136CONFIG_CRYPTO=y
138# CONFIG_CRYPTO_ANSI_CPRNG is not set 137# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF538-EZKIT_defconfig b/arch/blackfin/configs/BF538-EZKIT_defconfig
index 74a330cca9b4..fbee9d776f56 100644
--- a/arch/blackfin/configs/BF538-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF538-EZKIT_defconfig
@@ -20,6 +20,7 @@ CONFIG_MODULE_UNLOAD=y
20# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
23# CONFIG_IOSCHED_CFQ is not set
23CONFIG_PREEMPT_VOLUNTARY=y 24CONFIG_PREEMPT_VOLUNTARY=y
24CONFIG_BF538=y 25CONFIG_BF538=y
25CONFIG_IRQ_TIMER0=12 26CONFIG_IRQ_TIMER0=12
@@ -31,6 +32,7 @@ CONFIG_C_CDPRIO=y
31CONFIG_BANK_3=0x99B2 32CONFIG_BANK_3=0x99B2
32CONFIG_BINFMT_FLAT=y 33CONFIG_BINFMT_FLAT=y
33CONFIG_BINFMT_ZFLAT=y 34CONFIG_BINFMT_ZFLAT=y
35CONFIG_PM=y
34CONFIG_NET=y 36CONFIG_NET=y
35CONFIG_PACKET=y 37CONFIG_PACKET=y
36CONFIG_UNIX=y 38CONFIG_UNIX=y
@@ -129,6 +131,5 @@ CONFIG_DEBUG_DOUBLEFAULT=y
129CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 131CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
130CONFIG_EARLY_PRINTK=y 132CONFIG_EARLY_PRINTK=y
131CONFIG_CPLB_INFO=y 133CONFIG_CPLB_INFO=y
132CONFIG_SECURITY=y
133CONFIG_CRYPTO=y 134CONFIG_CRYPTO=y
134# CONFIG_CRYPTO_ANSI_CPRNG is not set 135# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF548-EZKIT_defconfig b/arch/blackfin/configs/BF548-EZKIT_defconfig
index 29373cbba227..05dd11db2f7d 100644
--- a/arch/blackfin/configs/BF548-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF548-EZKIT_defconfig
@@ -40,6 +40,7 @@ CONFIG_EBIU_MODEVAL=0x1
40CONFIG_EBIU_FCTLVAL=0x6 40CONFIG_EBIU_FCTLVAL=0x6
41CONFIG_BINFMT_FLAT=y 41CONFIG_BINFMT_FLAT=y
42CONFIG_BINFMT_ZFLAT=y 42CONFIG_BINFMT_ZFLAT=y
43CONFIG_PM=y
43CONFIG_NET=y 44CONFIG_NET=y
44CONFIG_PACKET=y 45CONFIG_PACKET=y
45CONFIG_UNIX=y 46CONFIG_UNIX=y
@@ -62,7 +63,7 @@ CONFIG_IRCOMM=m
62CONFIG_IRTTY_SIR=m 63CONFIG_IRTTY_SIR=m
63CONFIG_BFIN_SIR=m 64CONFIG_BFIN_SIR=m
64CONFIG_BFIN_SIR3=y 65CONFIG_BFIN_SIR3=y
65CONFIG_LIB80211=m 66# CONFIG_WIRELESS is not set
66CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 67CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
67CONFIG_FW_LOADER=m 68CONFIG_FW_LOADER=m
68CONFIG_MTD=y 69CONFIG_MTD=y
@@ -92,6 +93,7 @@ CONFIG_NET_ETHERNET=y
92CONFIG_SMSC911X=y 93CONFIG_SMSC911X=y
93# CONFIG_NETDEV_1000 is not set 94# CONFIG_NETDEV_1000 is not set
94# CONFIG_NETDEV_10000 is not set 95# CONFIG_NETDEV_10000 is not set
96# CONFIG_WLAN is not set
95CONFIG_INPUT_FF_MEMLESS=m 97CONFIG_INPUT_FF_MEMLESS=m
96# CONFIG_INPUT_MOUSEDEV is not set 98# CONFIG_INPUT_MOUSEDEV is not set
97CONFIG_INPUT_EVDEV=m 99CONFIG_INPUT_EVDEV=m
diff --git a/arch/blackfin/configs/BF561-ACVILON_defconfig b/arch/blackfin/configs/BF561-ACVILON_defconfig
index 1f12034f5610..bcb14d1c5664 100644
--- a/arch/blackfin/configs/BF561-ACVILON_defconfig
+++ b/arch/blackfin/configs/BF561-ACVILON_defconfig
@@ -14,6 +14,7 @@ CONFIG_EMBEDDED=y
14# CONFIG_EVENTFD is not set 14# CONFIG_EVENTFD is not set
15# CONFIG_AIO is not set 15# CONFIG_AIO is not set
16CONFIG_SLAB=y 16CONFIG_SLAB=y
17CONFIG_MMAP_ALLOW_UNINITIALIZED=y
17CONFIG_MODULES=y 18CONFIG_MODULES=y
18CONFIG_MODULE_UNLOAD=y 19CONFIG_MODULE_UNLOAD=y
19# CONFIG_LBDAF is not set 20# CONFIG_LBDAF is not set
@@ -44,6 +45,7 @@ CONFIG_IP_PNP=y
44CONFIG_SYN_COOKIES=y 45CONFIG_SYN_COOKIES=y
45# CONFIG_INET_LRO is not set 46# CONFIG_INET_LRO is not set
46# CONFIG_IPV6 is not set 47# CONFIG_IPV6 is not set
48# CONFIG_WIRELESS is not set
47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 49CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
48# CONFIG_FW_LOADER is not set 50# CONFIG_FW_LOADER is not set
49CONFIG_MTD=y 51CONFIG_MTD=y
@@ -71,6 +73,7 @@ CONFIG_NET_ETHERNET=y
71CONFIG_SMSC911X=y 73CONFIG_SMSC911X=y
72# CONFIG_NETDEV_1000 is not set 74# CONFIG_NETDEV_1000 is not set
73# CONFIG_NETDEV_10000 is not set 75# CONFIG_NETDEV_10000 is not set
76# CONFIG_WLAN is not set
74# CONFIG_INPUT is not set 77# CONFIG_INPUT is not set
75# CONFIG_SERIO is not set 78# CONFIG_SERIO is not set
76# CONFIG_VT is not set 79# CONFIG_VT is not set
@@ -147,5 +150,4 @@ CONFIG_DEBUG_INFO=y
147CONFIG_DEBUG_MMRS=y 150CONFIG_DEBUG_MMRS=y
148# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 151# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
149CONFIG_CPLB_INFO=y 152CONFIG_CPLB_INFO=y
150CONFIG_SECURITY=y
151# CONFIG_CRYPTO_ANSI_CPRNG is not set 153# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/blackfin/configs/BF561-EZKIT_defconfig b/arch/blackfin/configs/BF561-EZKIT_defconfig
index 8913d997fa47..843aaa54a9e3 100644
--- a/arch/blackfin/configs/BF561-EZKIT_defconfig
+++ b/arch/blackfin/configs/BF561-EZKIT_defconfig
@@ -35,6 +35,7 @@ CONFIG_C_CDPRIO=y
35CONFIG_BANK_3=0xAAC2 35CONFIG_BANK_3=0xAAC2
36CONFIG_BINFMT_FLAT=y 36CONFIG_BINFMT_FLAT=y
37CONFIG_BINFMT_ZFLAT=y 37CONFIG_BINFMT_ZFLAT=y
38CONFIG_PM=y
38CONFIG_NET=y 39CONFIG_NET=y
39CONFIG_PACKET=y 40CONFIG_PACKET=y
40CONFIG_UNIX=y 41CONFIG_UNIX=y
diff --git a/arch/blackfin/configs/BlackStamp_defconfig b/arch/blackfin/configs/BlackStamp_defconfig
index 0242917b69c9..dae7adf3b2a2 100644
--- a/arch/blackfin/configs/BlackStamp_defconfig
+++ b/arch/blackfin/configs/BlackStamp_defconfig
@@ -40,6 +40,7 @@ CONFIG_INET=y
40CONFIG_IP_PNP=y 40CONFIG_IP_PNP=y
41# CONFIG_INET_LRO is not set 41# CONFIG_INET_LRO is not set
42# CONFIG_IPV6 is not set 42# CONFIG_IPV6 is not set
43# CONFIG_WIRELESS is not set
43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
44# CONFIG_FW_LOADER is not set 45# CONFIG_FW_LOADER is not set
45CONFIG_MTD=y 46CONFIG_MTD=y
@@ -63,6 +64,7 @@ CONFIG_NET_ETHERNET=y
63CONFIG_SMC91X=y 64CONFIG_SMC91X=y
64# CONFIG_NETDEV_1000 is not set 65# CONFIG_NETDEV_1000 is not set
65# CONFIG_NETDEV_10000 is not set 66# CONFIG_NETDEV_10000 is not set
67# CONFIG_WLAN is not set
66# CONFIG_INPUT_MOUSEDEV is not set 68# CONFIG_INPUT_MOUSEDEV is not set
67CONFIG_INPUT_EVDEV=m 69CONFIG_INPUT_EVDEV=m
68# CONFIG_INPUT_KEYBOARD is not set 70# CONFIG_INPUT_KEYBOARD is not set
@@ -104,5 +106,4 @@ CONFIG_DEBUG_MMRS=y
104# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 106# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
105CONFIG_EARLY_PRINTK=y 107CONFIG_EARLY_PRINTK=y
106CONFIG_CPLB_INFO=y 108CONFIG_CPLB_INFO=y
107CONFIG_SECURITY=y
108CONFIG_CRC_CCITT=m 109CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/CM-BF527_defconfig b/arch/blackfin/configs/CM-BF527_defconfig
index 0512fef3d55a..f3414244bfed 100644
--- a/arch/blackfin/configs/CM-BF527_defconfig
+++ b/arch/blackfin/configs/CM-BF527_defconfig
@@ -50,6 +50,7 @@ CONFIG_IP_PNP=y
50# CONFIG_INET_LRO is not set 50# CONFIG_INET_LRO is not set
51# CONFIG_INET_DIAG is not set 51# CONFIG_INET_DIAG is not set
52# CONFIG_IPV6 is not set 52# CONFIG_IPV6 is not set
53# CONFIG_WIRELESS is not set
53CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 54CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
54# CONFIG_FW_LOADER is not set 55# CONFIG_FW_LOADER is not set
55CONFIG_MTD=y 56CONFIG_MTD=y
@@ -70,9 +71,9 @@ CONFIG_BLK_DEV_SD=y
70CONFIG_NETDEVICES=y 71CONFIG_NETDEVICES=y
71CONFIG_NET_ETHERNET=y 72CONFIG_NET_ETHERNET=y
72CONFIG_BFIN_MAC=y 73CONFIG_BFIN_MAC=y
73CONFIG_BFIN_MAC_RMII=y
74# CONFIG_NETDEV_1000 is not set 74# CONFIG_NETDEV_1000 is not set
75# CONFIG_NETDEV_10000 is not set 75# CONFIG_NETDEV_10000 is not set
76# CONFIG_WLAN is not set
76# CONFIG_INPUT is not set 77# CONFIG_INPUT is not set
77# CONFIG_SERIO is not set 78# CONFIG_SERIO is not set
78# CONFIG_VT is not set 79# CONFIG_VT is not set
@@ -124,7 +125,6 @@ CONFIG_DEBUG_FS=y
124# CONFIG_RCU_CPU_STALL_DETECTOR is not set 125# CONFIG_RCU_CPU_STALL_DETECTOR is not set
125# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 126# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
126CONFIG_EARLY_PRINTK=y 127CONFIG_EARLY_PRINTK=y
127CONFIG_SECURITY=y
128CONFIG_CRYPTO=y 128CONFIG_CRYPTO=y
129# CONFIG_CRYPTO_ANSI_CPRNG is not set 129# CONFIG_CRYPTO_ANSI_CPRNG is not set
130CONFIG_CRC_CCITT=m 130CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/CM-BF533_defconfig b/arch/blackfin/configs/CM-BF533_defconfig
index 05e09be8b4c5..8c7e08f173d4 100644
--- a/arch/blackfin/configs/CM-BF533_defconfig
+++ b/arch/blackfin/configs/CM-BF533_defconfig
@@ -33,6 +33,7 @@ CONFIG_BINFMT_SHARED_FLAT=y
33CONFIG_NET=y 33CONFIG_NET=y
34CONFIG_PACKET=y 34CONFIG_PACKET=y
35CONFIG_UNIX=y 35CONFIG_UNIX=y
36# CONFIG_WIRELESS is not set
36CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 37CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
37CONFIG_MTD=y 38CONFIG_MTD=y
38CONFIG_MTD_PARTITIONS=y 39CONFIG_MTD_PARTITIONS=y
@@ -47,6 +48,7 @@ CONFIG_MTD_PHYSMAP=y
47CONFIG_NETDEVICES=y 48CONFIG_NETDEVICES=y
48# CONFIG_NETDEV_1000 is not set 49# CONFIG_NETDEV_1000 is not set
49# CONFIG_NETDEV_10000 is not set 50# CONFIG_NETDEV_10000 is not set
51# CONFIG_WLAN is not set
50# CONFIG_INPUT is not set 52# CONFIG_INPUT is not set
51# CONFIG_SERIO is not set 53# CONFIG_SERIO is not set
52# CONFIG_VT is not set 54# CONFIG_VT is not set
@@ -72,7 +74,6 @@ CONFIG_DEBUG_MMRS=y
72# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 74# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
73CONFIG_EARLY_PRINTK=y 75CONFIG_EARLY_PRINTK=y
74CONFIG_CPLB_INFO=y 76CONFIG_CPLB_INFO=y
75CONFIG_SECURITY=y
76CONFIG_CRC_CCITT=y 77CONFIG_CRC_CCITT=y
77CONFIG_CRC_ITU_T=y 78CONFIG_CRC_ITU_T=y
78CONFIG_CRC7=y 79CONFIG_CRC7=y
diff --git a/arch/blackfin/configs/CM-BF537E_defconfig b/arch/blackfin/configs/CM-BF537E_defconfig
index d2eb5325b9c3..bd3cb766d078 100644
--- a/arch/blackfin/configs/CM-BF537E_defconfig
+++ b/arch/blackfin/configs/CM-BF537E_defconfig
@@ -48,6 +48,7 @@ CONFIG_IP_PNP=y
48# CONFIG_INET_LRO is not set 48# CONFIG_INET_LRO is not set
49# CONFIG_INET_DIAG is not set 49# CONFIG_INET_DIAG is not set
50# CONFIG_IPV6 is not set 50# CONFIG_IPV6 is not set
51# CONFIG_WIRELESS is not set
51CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 52CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
52CONFIG_MTD=y 53CONFIG_MTD=y
53CONFIG_MTD_CMDLINE_PARTS=y 54CONFIG_MTD_CMDLINE_PARTS=y
@@ -65,6 +66,7 @@ CONFIG_NET_ETHERNET=y
65CONFIG_BFIN_MAC=y 66CONFIG_BFIN_MAC=y
66# CONFIG_NETDEV_1000 is not set 67# CONFIG_NETDEV_1000 is not set
67# CONFIG_NETDEV_10000 is not set 68# CONFIG_NETDEV_10000 is not set
69# CONFIG_WLAN is not set
68# CONFIG_INPUT is not set 70# CONFIG_INPUT is not set
69# CONFIG_SERIO is not set 71# CONFIG_SERIO is not set
70# CONFIG_VT is not set 72# CONFIG_VT is not set
@@ -99,7 +101,6 @@ CONFIG_DEBUG_MMRS=y
99# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 101# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
100CONFIG_EARLY_PRINTK=y 102CONFIG_EARLY_PRINTK=y
101CONFIG_CPLB_INFO=y 103CONFIG_CPLB_INFO=y
102CONFIG_SECURITY=y
103CONFIG_CRYPTO=y 104CONFIG_CRYPTO=y
104# CONFIG_CRYPTO_ANSI_CPRNG is not set 105# CONFIG_CRYPTO_ANSI_CPRNG is not set
105CONFIG_CRC_CCITT=m 106CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/CM-BF537U_defconfig b/arch/blackfin/configs/CM-BF537U_defconfig
index 9d52c443eb09..82224f37c04e 100644
--- a/arch/blackfin/configs/CM-BF537U_defconfig
+++ b/arch/blackfin/configs/CM-BF537U_defconfig
@@ -44,6 +44,7 @@ CONFIG_INET=y
44# CONFIG_INET_XFRM_MODE_BEET is not set 44# CONFIG_INET_XFRM_MODE_BEET is not set
45# CONFIG_INET_DIAG is not set 45# CONFIG_INET_DIAG is not set
46# CONFIG_IPV6 is not set 46# CONFIG_IPV6 is not set
47# CONFIG_WIRELESS is not set
47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 48CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
48CONFIG_MTD=y 49CONFIG_MTD=y
49CONFIG_MTD_CMDLINE_PARTS=y 50CONFIG_MTD_CMDLINE_PARTS=y
@@ -59,6 +60,7 @@ CONFIG_BLK_DEV_RAM=y
59CONFIG_NETDEVICES=y 60CONFIG_NETDEVICES=y
60# CONFIG_NETDEV_1000 is not set 61# CONFIG_NETDEV_1000 is not set
61# CONFIG_NETDEV_10000 is not set 62# CONFIG_NETDEV_10000 is not set
63# CONFIG_WLAN is not set
62# CONFIG_INPUT is not set 64# CONFIG_INPUT is not set
63# CONFIG_SERIO is not set 65# CONFIG_SERIO is not set
64# CONFIG_VT is not set 66# CONFIG_VT is not set
@@ -90,7 +92,6 @@ CONFIG_DEBUG_MMRS=y
90# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 92# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
91CONFIG_EARLY_PRINTK=y 93CONFIG_EARLY_PRINTK=y
92CONFIG_CPLB_INFO=y 94CONFIG_CPLB_INFO=y
93CONFIG_SECURITY=y
94CONFIG_CRC_CCITT=m 95CONFIG_CRC_CCITT=m
95CONFIG_CRC_ITU_T=y 96CONFIG_CRC_ITU_T=y
96CONFIG_CRC7=y 97CONFIG_CRC7=y
diff --git a/arch/blackfin/configs/CM-BF548_defconfig b/arch/blackfin/configs/CM-BF548_defconfig
index 9de13cf2cdda..433598c6e773 100644
--- a/arch/blackfin/configs/CM-BF548_defconfig
+++ b/arch/blackfin/configs/CM-BF548_defconfig
@@ -49,6 +49,7 @@ CONFIG_INET_XFRM_MODE_BEET=m
49# CONFIG_INET_LRO is not set 49# CONFIG_INET_LRO is not set
50# CONFIG_INET_DIAG is not set 50# CONFIG_INET_DIAG is not set
51# CONFIG_IPV6 is not set 51# CONFIG_IPV6 is not set
52# CONFIG_WIRELESS is not set
52CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 53CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
53# CONFIG_FW_LOADER is not set 54# CONFIG_FW_LOADER is not set
54CONFIG_MTD=y 55CONFIG_MTD=y
@@ -71,6 +72,7 @@ CONFIG_NET_ETHERNET=y
71CONFIG_SMSC911X=y 72CONFIG_SMSC911X=y
72# CONFIG_NETDEV_1000 is not set 73# CONFIG_NETDEV_1000 is not set
73# CONFIG_NETDEV_10000 is not set 74# CONFIG_NETDEV_10000 is not set
75# CONFIG_WLAN is not set
74# CONFIG_INPUT_MOUSEDEV is not set 76# CONFIG_INPUT_MOUSEDEV is not set
75CONFIG_INPUT_EVDEV=m 77CONFIG_INPUT_EVDEV=m
76CONFIG_INPUT_EVBUG=m 78CONFIG_INPUT_EVBUG=m
@@ -167,7 +169,6 @@ CONFIG_DEBUG_FS=y
167# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 169# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
168CONFIG_EARLY_PRINTK=y 170CONFIG_EARLY_PRINTK=y
169CONFIG_CPLB_INFO=y 171CONFIG_CPLB_INFO=y
170CONFIG_SECURITY=y
171# CONFIG_CRYPTO_ANSI_CPRNG is not set 172# CONFIG_CRYPTO_ANSI_CPRNG is not set
172# CONFIG_CRYPTO_HW is not set 173# CONFIG_CRYPTO_HW is not set
173CONFIG_CRC_CCITT=m 174CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/CM-BF561_defconfig b/arch/blackfin/configs/CM-BF561_defconfig
index 238353a53bf0..ded7d845cb39 100644
--- a/arch/blackfin/configs/CM-BF561_defconfig
+++ b/arch/blackfin/configs/CM-BF561_defconfig
@@ -48,6 +48,7 @@ CONFIG_INET=y
48# CONFIG_INET_LRO is not set 48# CONFIG_INET_LRO is not set
49# CONFIG_INET_DIAG is not set 49# CONFIG_INET_DIAG is not set
50# CONFIG_IPV6 is not set 50# CONFIG_IPV6 is not set
51# CONFIG_WIRELESS is not set
51CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 52CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
52CONFIG_MTD=y 53CONFIG_MTD=y
53CONFIG_MTD_PARTITIONS=y 54CONFIG_MTD_PARTITIONS=y
@@ -67,6 +68,7 @@ CONFIG_MII=y
67CONFIG_SMSC911X=m 68CONFIG_SMSC911X=m
68# CONFIG_NETDEV_1000 is not set 69# CONFIG_NETDEV_1000 is not set
69# CONFIG_NETDEV_10000 is not set 70# CONFIG_NETDEV_10000 is not set
71# CONFIG_WLAN is not set
70# CONFIG_INPUT is not set 72# CONFIG_INPUT is not set
71# CONFIG_SERIO is not set 73# CONFIG_SERIO is not set
72# CONFIG_VT is not set 74# CONFIG_VT is not set
@@ -99,7 +101,6 @@ CONFIG_DEBUG_MMRS=y
99# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 101# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
100CONFIG_EARLY_PRINTK=y 102CONFIG_EARLY_PRINTK=y
101CONFIG_CPLB_INFO=y 103CONFIG_CPLB_INFO=y
102CONFIG_SECURITY=y
103CONFIG_CRC_CCITT=m 104CONFIG_CRC_CCITT=m
104CONFIG_CRC_ITU_T=y 105CONFIG_CRC_ITU_T=y
105CONFIG_CRC7=y 106CONFIG_CRC7=y
diff --git a/arch/blackfin/configs/H8606_defconfig b/arch/blackfin/configs/H8606_defconfig
index 0cb524e8947f..700fb701c121 100644
--- a/arch/blackfin/configs/H8606_defconfig
+++ b/arch/blackfin/configs/H8606_defconfig
@@ -33,6 +33,7 @@ CONFIG_IRLAN=m
33CONFIG_IRCOMM=m 33CONFIG_IRCOMM=m
34CONFIG_IRDA_CACHE_LAST_LSAP=y 34CONFIG_IRDA_CACHE_LAST_LSAP=y
35CONFIG_IRTTY_SIR=m 35CONFIG_IRTTY_SIR=m
36# CONFIG_WIRELESS is not set
36# CONFIG_FW_LOADER is not set 37# CONFIG_FW_LOADER is not set
37CONFIG_MTD=y 38CONFIG_MTD=y
38CONFIG_MTD_PARTITIONS=y 39CONFIG_MTD_PARTITIONS=y
@@ -50,6 +51,7 @@ CONFIG_NET_ETHERNET=y
50CONFIG_DM9000=y 51CONFIG_DM9000=y
51# CONFIG_NETDEV_1000 is not set 52# CONFIG_NETDEV_1000 is not set
52# CONFIG_NETDEV_10000 is not set 53# CONFIG_NETDEV_10000 is not set
54# CONFIG_WLAN is not set
53# CONFIG_INPUT_MOUSEDEV is not set 55# CONFIG_INPUT_MOUSEDEV is not set
54CONFIG_INPUT_EVDEV=y 56CONFIG_INPUT_EVDEV=y
55# CONFIG_KEYBOARD_ATKBD is not set 57# CONFIG_KEYBOARD_ATKBD is not set
@@ -84,4 +86,3 @@ CONFIG_NFS_V3=y
84CONFIG_NLS=m 86CONFIG_NLS=m
85# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 87# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
86CONFIG_CPLB_INFO=y 88CONFIG_CPLB_INFO=y
87CONFIG_SECURITY=y
diff --git a/arch/blackfin/configs/IP0X_defconfig b/arch/blackfin/configs/IP0X_defconfig
index 2a3411ef19fd..b40156d217e3 100644
--- a/arch/blackfin/configs/IP0X_defconfig
+++ b/arch/blackfin/configs/IP0X_defconfig
@@ -41,6 +41,7 @@ CONFIG_IP_NF_IPTABLES=y
41CONFIG_IP_NF_FILTER=y 41CONFIG_IP_NF_FILTER=y
42CONFIG_IP_NF_TARGET_REJECT=y 42CONFIG_IP_NF_TARGET_REJECT=y
43CONFIG_IP_NF_MANGLE=y 43CONFIG_IP_NF_MANGLE=y
44# CONFIG_WIRELESS is not set
44CONFIG_MTD=y 45CONFIG_MTD=y
45CONFIG_MTD_PARTITIONS=y 46CONFIG_MTD_PARTITIONS=y
46CONFIG_MTD_CHAR=y 47CONFIG_MTD_CHAR=y
@@ -60,6 +61,7 @@ CONFIG_NET_ETHERNET=y
60CONFIG_DM9000=y 61CONFIG_DM9000=y
61# CONFIG_NETDEV_1000 is not set 62# CONFIG_NETDEV_1000 is not set
62# CONFIG_NETDEV_10000 is not set 63# CONFIG_NETDEV_10000 is not set
64# CONFIG_WLAN is not set
63# CONFIG_INPUT is not set 65# CONFIG_INPUT is not set
64# CONFIG_SERIO is not set 66# CONFIG_SERIO is not set
65# CONFIG_VT is not set 67# CONFIG_VT is not set
@@ -89,5 +91,4 @@ CONFIG_NLS_CODEPAGE_437=y
89CONFIG_NLS_ISO8859_1=y 91CONFIG_NLS_ISO8859_1=y
90# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 92# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
91CONFIG_CPLB_INFO=y 93CONFIG_CPLB_INFO=y
92CONFIG_SECURITY=y
93CONFIG_CRC_CCITT=y 94CONFIG_CRC_CCITT=y
diff --git a/arch/blackfin/configs/PNAV-10_defconfig b/arch/blackfin/configs/PNAV-10_defconfig
index fea303386548..be866d95ed76 100644
--- a/arch/blackfin/configs/PNAV-10_defconfig
+++ b/arch/blackfin/configs/PNAV-10_defconfig
@@ -14,6 +14,7 @@ CONFIG_MODULE_UNLOAD=y
14# CONFIG_LBDAF is not set 14# CONFIG_LBDAF is not set
15# CONFIG_BLK_DEV_BSG is not set 15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set 16# CONFIG_IOSCHED_DEADLINE is not set
17# CONFIG_IOSCHED_CFQ is not set
17CONFIG_PREEMPT_VOLUNTARY=y 18CONFIG_PREEMPT_VOLUNTARY=y
18CONFIG_BF537=y 19CONFIG_BF537=y
19CONFIG_IRQ_TIMER0=12 20CONFIG_IRQ_TIMER0=12
@@ -107,7 +108,6 @@ CONFIG_SMB_FS=m
107# CONFIG_DEBUG_HUNT_FOR_ZERO is not set 108# CONFIG_DEBUG_HUNT_FOR_ZERO is not set
108# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 109# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
109# CONFIG_ACCESS_CHECK is not set 110# CONFIG_ACCESS_CHECK is not set
110CONFIG_SECURITY=y
111CONFIG_CRYPTO=y 111CONFIG_CRYPTO=y
112# CONFIG_CRYPTO_ANSI_CPRNG is not set 112# CONFIG_CRYPTO_ANSI_CPRNG is not set
113CONFIG_CRC_CCITT=m 113CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/SRV1_defconfig b/arch/blackfin/configs/SRV1_defconfig
index 9811b3186847..b64bdf759b82 100644
--- a/arch/blackfin/configs/SRV1_defconfig
+++ b/arch/blackfin/configs/SRV1_defconfig
@@ -35,6 +35,7 @@ CONFIG_IRLAN=m
35CONFIG_IRCOMM=m 35CONFIG_IRCOMM=m
36CONFIG_IRDA_CACHE_LAST_LSAP=y 36CONFIG_IRDA_CACHE_LAST_LSAP=y
37CONFIG_IRTTY_SIR=m 37CONFIG_IRTTY_SIR=m
38# CONFIG_WIRELESS is not set
38# CONFIG_FW_LOADER is not set 39# CONFIG_FW_LOADER is not set
39CONFIG_MTD=y 40CONFIG_MTD=y
40CONFIG_MTD_PARTITIONS=y 41CONFIG_MTD_PARTITIONS=y
@@ -51,6 +52,7 @@ CONFIG_EEPROM_AT25=m
51CONFIG_NETDEVICES=y 52CONFIG_NETDEVICES=y
52# CONFIG_NETDEV_1000 is not set 53# CONFIG_NETDEV_1000 is not set
53# CONFIG_NETDEV_10000 is not set 54# CONFIG_NETDEV_10000 is not set
55# CONFIG_WLAN is not set
54# CONFIG_INPUT_MOUSEDEV is not set 56# CONFIG_INPUT_MOUSEDEV is not set
55CONFIG_INPUT_EVDEV=m 57CONFIG_INPUT_EVDEV=m
56# CONFIG_INPUT_KEYBOARD is not set 58# CONFIG_INPUT_KEYBOARD is not set
@@ -85,4 +87,3 @@ CONFIG_DEBUG_KERNEL=y
85CONFIG_DEBUG_INFO=y 87CONFIG_DEBUG_INFO=y
86# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set 88# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
87CONFIG_CPLB_INFO=y 89CONFIG_CPLB_INFO=y
88CONFIG_SECURITY=y
diff --git a/arch/blackfin/configs/TCM-BF518_defconfig b/arch/blackfin/configs/TCM-BF518_defconfig
index 412bf79b9724..1bccd9a50986 100644
--- a/arch/blackfin/configs/TCM-BF518_defconfig
+++ b/arch/blackfin/configs/TCM-BF518_defconfig
@@ -128,7 +128,6 @@ CONFIG_DEBUG_DOUBLEFAULT=y
128CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y 128CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE=y
129CONFIG_EARLY_PRINTK=y 129CONFIG_EARLY_PRINTK=y
130CONFIG_CPLB_INFO=y 130CONFIG_CPLB_INFO=y
131CONFIG_SECURITY=y
132CONFIG_CRYPTO=y 131CONFIG_CRYPTO=y
133# CONFIG_CRYPTO_ANSI_CPRNG is not set 132# CONFIG_CRYPTO_ANSI_CPRNG is not set
134CONFIG_CRC_CCITT=m 133CONFIG_CRC_CCITT=m
diff --git a/arch/blackfin/configs/TCM-BF537_defconfig b/arch/blackfin/configs/TCM-BF537_defconfig
index 04bf52c4cf12..00ce899e9e5d 100644
--- a/arch/blackfin/configs/TCM-BF537_defconfig
+++ b/arch/blackfin/configs/TCM-BF537_defconfig
@@ -40,6 +40,7 @@ CONFIG_UNIX=y
40CONFIG_INET=y 40CONFIG_INET=y
41# CONFIG_INET_DIAG is not set 41# CONFIG_INET_DIAG is not set
42# CONFIG_IPV6 is not set 42# CONFIG_IPV6 is not set
43# CONFIG_WIRELESS is not set
43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
44CONFIG_MTD=y 45CONFIG_MTD=y
45CONFIG_MTD_CMDLINE_PARTS=y 46CONFIG_MTD_CMDLINE_PARTS=y
@@ -57,6 +58,7 @@ CONFIG_NET_ETHERNET=y
57CONFIG_BFIN_MAC=y 58CONFIG_BFIN_MAC=y
58# CONFIG_NETDEV_1000 is not set 59# CONFIG_NETDEV_1000 is not set
59# CONFIG_NETDEV_10000 is not set 60# CONFIG_NETDEV_10000 is not set
61# CONFIG_WLAN is not set
60# CONFIG_INPUT is not set 62# CONFIG_INPUT is not set
61# CONFIG_SERIO is not set 63# CONFIG_SERIO is not set
62# CONFIG_VT is not set 64# CONFIG_VT is not set
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 4223cf08ce83..5392583d0253 100644
--- a/arch/blackfin/include/asm/bfin5xx_spi.h
+++ b/arch/blackfin/include/asm/bfin5xx_spi.h
@@ -41,6 +41,27 @@
41#define BIT_STU_SENDOVER 0x0001 41#define BIT_STU_SENDOVER 0x0001
42#define BIT_STU_RECVFULL 0x0020 42#define BIT_STU_RECVFULL 0x0020
43 43
44/*
45 * All Blackfin system MMRs are padded to 32bits even if the register
46 * itself is only 16bits. So use a helper macro to streamline this.
47 */
48#define __BFP(m) u16 m; u16 __pad_##m
49
50/*
51 * bfin spi registers layout
52 */
53struct bfin_spi_regs {
54 __BFP(ctl);
55 __BFP(flg);
56 __BFP(stat);
57 __BFP(tdbr);
58 __BFP(rdbr);
59 __BFP(baud);
60 __BFP(shadow);
61};
62
63#undef __BFP
64
44#define MAX_CTRL_CS 8 /* cs in spi controller */ 65#define MAX_CTRL_CS 8 /* cs in spi controller */
45 66
46/* device.platform_data for SSP controller devices */ 67/* device.platform_data for SSP controller devices */
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..3be05faa2c65
--- /dev/null
+++ b/arch/blackfin/include/asm/bfin_ppi.h
@@ -0,0 +1,53 @@
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#undef __BFP
52
53#endif
diff --git a/arch/blackfin/include/asm/bfin_twi.h b/arch/blackfin/include/asm/bfin_twi.h
new file mode 100644
index 000000000000..e767d649dfc4
--- /dev/null
+++ b/arch/blackfin/include/asm/bfin_twi.h
@@ -0,0 +1,45 @@
1/*
2 * bfin_twi.h - interface to Blackfin TWIs
3 *
4 * Copyright 2005-2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __ASM_BFIN_TWI_H__
10#define __ASM_BFIN_TWI_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 twi registers layout
22 */
23struct bfin_twi_regs {
24 __BFP(clkdiv);
25 __BFP(control);
26 __BFP(slave_ctl);
27 __BFP(slave_stat);
28 __BFP(slave_addr);
29 __BFP(master_ctl);
30 __BFP(master_stat);
31 __BFP(master_addr);
32 __BFP(int_stat);
33 __BFP(int_mask);
34 __BFP(fifo_ctl);
35 __BFP(fifo_stat);
36 u32 __pad[20];
37 __BFP(xmt_data8);
38 __BFP(xmt_data16);
39 __BFP(rcv_data8);
40 __BFP(rcv_data16);
41};
42
43#undef __BFP
44
45#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..59af63c0c2be 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/entry.h b/arch/blackfin/include/asm/entry.h
index a6886f6e4819..4104d5783e2c 100644
--- a/arch/blackfin/include/asm/entry.h
+++ b/arch/blackfin/include/asm/entry.h
@@ -15,14 +15,6 @@
15#define LFLUSH_I_AND_D 0x00000808 15#define LFLUSH_I_AND_D 0x00000808
16#define LSIGTRAP 5 16#define LSIGTRAP 5
17 17
18/* process bits for task_struct.flags */
19#define PF_TRACESYS_OFF 3
20#define PF_TRACESYS_BIT 5
21#define PF_PTRACED_OFF 3
22#define PF_PTRACED_BIT 4
23#define PF_DTRACE_OFF 1
24#define PF_DTRACE_BIT 5
25
26/* 18/*
27 * NOTE! The single-stepping code assumes that all interrupt handlers 19 * NOTE! The single-stepping code assumes that all interrupt handlers
28 * start by saving SYSCFG on the stack with their first instruction. 20 * start by saving SYSCFG on the stack with their first instruction.
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/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 ca1c1f9debd6..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
@@ -735,6 +782,10 @@ int peripheral_request(unsigned short per, const char *label)
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
diff --git a/arch/blackfin/kernel/kgdb.c b/arch/blackfin/kernel/kgdb.c
index 08bc44ea6883..edae461b1c54 100644
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -320,7 +320,7 @@ static void bfin_correct_hw_break(void)
320 } 320 }
321} 321}
322 322
323void kgdb_disable_hw_debug(struct pt_regs *regs) 323static void bfin_disable_hw_debug(struct pt_regs *regs)
324{ 324{
325 /* Disable hardware debugging while we are in kgdb */ 325 /* Disable hardware debugging while we are in kgdb */
326 bfin_write_WPIACTL(0); 326 bfin_write_WPIACTL(0);
@@ -406,6 +406,7 @@ struct kgdb_arch arch_kgdb_ops = {
406#endif 406#endif
407 .set_hw_breakpoint = bfin_set_hw_break, 407 .set_hw_breakpoint = bfin_set_hw_break,
408 .remove_hw_breakpoint = bfin_remove_hw_break, 408 .remove_hw_breakpoint = bfin_remove_hw_break,
409 .disable_hw_break = bfin_disable_hw_debug,
409 .remove_all_hw_break = bfin_remove_all_hw_break, 410 .remove_all_hw_break = bfin_remove_all_hw_break,
410 .correct_hw_break = bfin_correct_hw_break, 411 .correct_hw_break = bfin_correct_hw_break,
411}; 412};
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 c86a3ed5f48f..cd0c090ebc54 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -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..75089f80855d 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.
@@ -37,12 +38,13 @@
37 * Get contents of register REGNO in task TASK. 38 * Get contents of register REGNO in task TASK.
38 */ 39 */
39static inline long 40static inline long
40get_reg(struct task_struct *task, long regno, unsigned long __user *datap) 41get_reg(struct task_struct *task, unsigned long regno,
42 unsigned long __user *datap)
41{ 43{
42 long tmp; 44 long tmp;
43 struct pt_regs *regs = task_pt_regs(task); 45 struct pt_regs *regs = task_pt_regs(task);
44 46
45 if (regno & 3 || regno > PT_LAST_PSEUDO || regno < 0) 47 if (regno & 3 || regno > PT_LAST_PSEUDO)
46 return -EIO; 48 return -EIO;
47 49
48 switch (regno) { 50 switch (regno) {
@@ -73,11 +75,11 @@ get_reg(struct task_struct *task, long regno, unsigned long __user *datap)
73 * Write contents of register REGNO in task TASK. 75 * Write contents of register REGNO in task TASK.
74 */ 76 */
75static inline int 77static inline int
76put_reg(struct task_struct *task, long regno, unsigned long data) 78put_reg(struct task_struct *task, unsigned long regno, unsigned long data)
77{ 79{
78 struct pt_regs *regs = task_pt_regs(task); 80 struct pt_regs *regs = task_pt_regs(task);
79 81
80 if (regno & 3 || regno > PT_LAST_PSEUDO || regno < 0) 82 if (regno & 3 || regno > PT_LAST_PSEUDO)
81 return -EIO; 83 return -EIO;
82 84
83 switch (regno) { 85 switch (regno) {
@@ -113,8 +115,8 @@ put_reg(struct task_struct *task, long regno, unsigned long data)
113/* 115/*
114 * check that an address falls within the bounds of the target process's memory mappings 116 * check that an address falls within the bounds of the target process's memory mappings
115 */ 117 */
116static inline int is_user_addr_valid(struct task_struct *child, 118int
117 unsigned long start, unsigned long len) 119is_user_addr_valid(struct task_struct *child, unsigned long start, unsigned long len)
118{ 120{
119 struct vm_area_struct *vma; 121 struct vm_area_struct *vma;
120 struct sram_list_struct *sraml; 122 struct sram_list_struct *sraml;
@@ -135,6 +137,13 @@ static inline int is_user_addr_valid(struct task_struct *child,
135 if (start >= FIXED_CODE_START && start + len < FIXED_CODE_END) 137 if (start >= FIXED_CODE_START && start + len < FIXED_CODE_END)
136 return 0; 138 return 0;
137 139
140#ifdef CONFIG_APP_STACK_L1
141 if (child->mm->context.l1_stack_save)
142 if (start >= (unsigned long)l1_stack_base &&
143 start + len < (unsigned long)l1_stack_base + l1_stack_len)
144 return 0;
145#endif
146
138 return -EIO; 147 return -EIO;
139} 148}
140 149
@@ -232,7 +241,8 @@ void user_disable_single_step(struct task_struct *child)
232 clear_tsk_thread_flag(child, TIF_SINGLESTEP); 241 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
233} 242}
234 243
235long arch_ptrace(struct task_struct *child, long request, long addr, long data) 244long arch_ptrace(struct task_struct *child, long request,
245 unsigned long addr, unsigned long data)
236{ 246{
237 int ret; 247 int ret;
238 unsigned long __user *datap = (unsigned long __user *)data; 248 unsigned long __user *datap = (unsigned long __user *)data;
@@ -360,14 +370,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
360 return copy_regset_to_user(child, &user_bfin_native_view, 370 return copy_regset_to_user(child, &user_bfin_native_view,
361 REGSET_GENERAL, 371 REGSET_GENERAL,
362 0, sizeof(struct pt_regs), 372 0, sizeof(struct pt_regs),
363 (void __user *)data); 373 datap);
364 374
365 case PTRACE_SETREGS: 375 case PTRACE_SETREGS:
366 pr_debug("ptrace: PTRACE_SETREGS\n"); 376 pr_debug("ptrace: PTRACE_SETREGS\n");
367 return copy_regset_from_user(child, &user_bfin_native_view, 377 return copy_regset_from_user(child, &user_bfin_native_view,
368 REGSET_GENERAL, 378 REGSET_GENERAL,
369 0, sizeof(struct pt_regs), 379 0, sizeof(struct pt_regs),
370 (const void __user *)data); 380 datap);
371 381
372 case_default: 382 case_default:
373 default: 383 default:
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/mach-bf518/boards/ezbrd.c b/arch/blackfin/mach-bf518/boards/ezbrd.c
index 44d6d5299022..b894c8abe7ec 100644
--- a/arch/blackfin/mach-bf518/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf518/boards/ezbrd.c
@@ -87,13 +87,55 @@ static struct platform_device rtc_device = {
87#endif 87#endif
88 88
89#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 89#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
90#include <linux/bfin_mac.h>
91static const unsigned short bfin_mac_peripherals[] = {
92 P_MII0_ETxD0,
93 P_MII0_ETxD1,
94 P_MII0_ETxEN,
95 P_MII0_ERxD0,
96 P_MII0_ERxD1,
97 P_MII0_TxCLK,
98 P_MII0_PHYINT,
99 P_MII0_CRS,
100 P_MII0_MDC,
101 P_MII0_MDIO,
102 0
103};
104
105static struct bfin_phydev_platform_data bfin_phydev_data[] = {
106 {
107 .addr = 1,
108 .irq = IRQ_MAC_PHYINT,
109 },
110 {
111 .addr = 2,
112 .irq = IRQ_MAC_PHYINT,
113 },
114 {
115 .addr = 3,
116 .irq = IRQ_MAC_PHYINT,
117 },
118};
119
120static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
121 .phydev_number = 3,
122 .phydev_data = bfin_phydev_data,
123 .phy_mode = PHY_INTERFACE_MODE_MII,
124 .mac_peripherals = bfin_mac_peripherals,
125};
126
90static struct platform_device bfin_mii_bus = { 127static struct platform_device bfin_mii_bus = {
91 .name = "bfin_mii_bus", 128 .name = "bfin_mii_bus",
129 .dev = {
130 .platform_data = &bfin_mii_bus_data,
131 }
92}; 132};
93 133
94static struct platform_device bfin_mac_device = { 134static struct platform_device bfin_mac_device = {
95 .name = "bfin_mac", 135 .name = "bfin_mac",
96 .dev.platform_data = &bfin_mii_bus, 136 .dev = {
137 .platform_data = &bfin_mii_bus,
138 }
97}; 139};
98 140
99#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE) 141#if defined(CONFIG_NET_DSA_KSZ8893M) || defined(CONFIG_NET_DSA_KSZ8893M_MODULE)
@@ -312,7 +354,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
312#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 354#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
313/* SPI (0) */ 355/* SPI (0) */
314static struct bfin5xx_spi_master bfin_spi0_info = { 356static struct bfin5xx_spi_master bfin_spi0_info = {
315 .num_chipselect = 5, 357 .num_chipselect = 6,
316 .enable_dma = 1, /* master has the ability to do dma transfer */ 358 .enable_dma = 1, /* master has the ability to do dma transfer */
317 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 359 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
318}; 360};
@@ -347,7 +389,7 @@ static struct platform_device bfin_spi0_device = {
347 389
348/* SPI (1) */ 390/* SPI (1) */
349static struct bfin5xx_spi_master bfin_spi1_info = { 391static struct bfin5xx_spi_master bfin_spi1_info = {
350 .num_chipselect = 5, 392 .num_chipselect = 6,
351 .enable_dma = 1, /* master has the ability to do dma transfer */ 393 .enable_dma = 1, /* master has the ability to do dma transfer */
352 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 394 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
353}; 395};
@@ -525,6 +567,14 @@ static struct platform_device bfin_sir1_device = {
525#endif 567#endif
526#endif 568#endif
527 569
570#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
571static struct platform_device bfin_i2s = {
572 .name = "bfin-i2s",
573 .id = CONFIG_SND_BF5XX_SPORT_NUM,
574 /* TODO: add platform data here */
575};
576#endif
577
528#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE) 578#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
529static struct resource bfin_twi0_resource[] = { 579static struct resource bfin_twi0_resource[] = {
530 [0] = { 580 [0] = {
@@ -559,6 +609,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
559 .irq = IRQ_PF8, 609 .irq = IRQ_PF8,
560 }, 610 },
561#endif 611#endif
612#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
613 {
614 I2C_BOARD_INFO("ssm2602", 0x1b),
615 },
616#endif
562}; 617};
563 618
564#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 619#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -736,6 +791,10 @@ static struct platform_device *stamp_devices[] __initdata = {
736 &i2c_bfin_twi_device, 791 &i2c_bfin_twi_device,
737#endif 792#endif
738 793
794#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
795 &bfin_i2s,
796#endif
797
739#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 798#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
740#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 799#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
741 &bfin_sport0_uart_device, 800 &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..e6ce1d7c523a 100644
--- a/arch/blackfin/mach-bf518/boards/tcm-bf518.c
+++ b/arch/blackfin/mach-bf518/boards/tcm-bf518.c
@@ -81,13 +81,35 @@ static struct platform_device rtc_device = {
81#endif 81#endif
82 82
83#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 83#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
84#include <linux/bfin_mac.h>
85static const unsigned short bfin_mac_peripherals[] = P_MII0;
86
87static struct bfin_phydev_platform_data bfin_phydev_data[] = {
88 {
89 .addr = 1,
90 .irq = IRQ_MAC_PHYINT,
91 },
92};
93
94static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
95 .phydev_number = 1,
96 .phydev_data = bfin_phydev_data,
97 .phy_mode = PHY_INTERFACE_MODE_MII,
98 .mac_peripherals = bfin_mac_peripherals,
99};
100
84static struct platform_device bfin_mii_bus = { 101static struct platform_device bfin_mii_bus = {
85 .name = "bfin_mii_bus", 102 .name = "bfin_mii_bus",
103 .dev = {
104 .platform_data = &bfin_mii_bus_data,
105 }
86}; 106};
87 107
88static struct platform_device bfin_mac_device = { 108static struct platform_device bfin_mac_device = {
89 .name = "bfin_mac", 109 .name = "bfin_mac",
90 .dev.platform_data = &bfin_mii_bus, 110 .dev = {
111 .platform_data = &bfin_mii_bus,
112 }
91}; 113};
92#endif 114#endif
93 115
@@ -291,7 +313,7 @@ static struct platform_device bfin_spi0_device = {
291 313
292/* SPI (1) */ 314/* SPI (1) */
293static struct bfin5xx_spi_master bfin_spi1_info = { 315static struct bfin5xx_spi_master bfin_spi1_info = {
294 .num_chipselect = 5, 316 .num_chipselect = 6,
295 .enable_dma = 1, /* master has the ability to do dma transfer */ 317 .enable_dma = 1, /* master has the ability to do dma transfer */
296 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, 318 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
297}; 319};
diff --git a/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h b/arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h
index 29498e59e71f..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)
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-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..2c31af7a320a 100644
--- a/arch/blackfin/mach-bf527/boards/cm_bf527.c
+++ b/arch/blackfin/mach-bf527/boards/cm_bf527.c
@@ -273,13 +273,35 @@ static struct platform_device dm9000_device = {
273#endif 273#endif
274 274
275#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 275#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
276#include <linux/bfin_mac.h>
277static const unsigned short bfin_mac_peripherals[] = P_RMII0;
278
279static struct bfin_phydev_platform_data bfin_phydev_data[] = {
280 {
281 .addr = 1,
282 .irq = IRQ_MAC_PHYINT,
283 },
284};
285
286static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
287 .phydev_number = 1,
288 .phydev_data = bfin_phydev_data,
289 .phy_mode = PHY_INTERFACE_MODE_RMII,
290 .mac_peripherals = bfin_mac_peripherals,
291};
292
276static struct platform_device bfin_mii_bus = { 293static struct platform_device bfin_mii_bus = {
277 .name = "bfin_mii_bus", 294 .name = "bfin_mii_bus",
295 .dev = {
296 .platform_data = &bfin_mii_bus_data,
297 }
278}; 298};
279 299
280static struct platform_device bfin_mac_device = { 300static struct platform_device bfin_mac_device = {
281 .name = "bfin_mac", 301 .name = "bfin_mac",
282 .dev.platform_data = &bfin_mii_bus, 302 .dev = {
303 .platform_data = &bfin_mii_bus,
304 }
283}; 305};
284#endif 306#endif
285 307
@@ -342,8 +364,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
342}; 364};
343#endif 365#endif
344 366
345#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 367#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
346 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 368 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
347static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 369static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
348 .enable_dma = 0, 370 .enable_dma = 0,
349 .bits_per_word = 16, 371 .bits_per_word = 16,
@@ -420,13 +442,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
420 }, 442 },
421#endif 443#endif
422 444
423#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 445#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
424 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 446 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
425 { 447 {
426 .modalias = "ad1836", 448 .modalias = "ad183x",
427 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 449 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
428 .bus_num = 0, 450 .bus_num = 0,
429 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 451 .chip_select = 4,
430 .controller_data = &ad1836_spi_chip_info, 452 .controller_data = &ad1836_spi_chip_info,
431 }, 453 },
432#endif 454#endif
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index c975fe88eba3..9a736a850c5c 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 {
@@ -189,13 +193,35 @@ static struct platform_device rtc_device = {
189 193
190 194
191#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 195#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
196#include <linux/bfin_mac.h>
197static const unsigned short bfin_mac_peripherals[] = P_RMII0;
198
199static struct bfin_phydev_platform_data bfin_phydev_data[] = {
200 {
201 .addr = 1,
202 .irq = IRQ_MAC_PHYINT,
203 },
204};
205
206static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
207 .phydev_number = 1,
208 .phydev_data = bfin_phydev_data,
209 .phy_mode = PHY_INTERFACE_MODE_RMII,
210 .mac_peripherals = bfin_mac_peripherals,
211};
212
192static struct platform_device bfin_mii_bus = { 213static struct platform_device bfin_mii_bus = {
193 .name = "bfin_mii_bus", 214 .name = "bfin_mii_bus",
215 .dev = {
216 .platform_data = &bfin_mii_bus_data,
217 }
194}; 218};
195 219
196static struct platform_device bfin_mac_device = { 220static struct platform_device bfin_mac_device = {
197 .name = "bfin_mac", 221 .name = "bfin_mac",
198 .dev.platform_data = &bfin_mii_bus, 222 .dev = {
223 .platform_data = &bfin_mii_bus,
224 }
199}; 225};
200#endif 226#endif
201 227
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 87b41e994ba3..9222bc00bbd3 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 {
@@ -362,13 +366,35 @@ static struct platform_device dm9000_device = {
362#endif 366#endif
363 367
364#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 368#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
369#include <linux/bfin_mac.h>
370static const unsigned short bfin_mac_peripherals[] = P_RMII0;
371
372static struct bfin_phydev_platform_data bfin_phydev_data[] = {
373 {
374 .addr = 1,
375 .irq = IRQ_MAC_PHYINT,
376 },
377};
378
379static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
380 .phydev_number = 1,
381 .phydev_data = bfin_phydev_data,
382 .phy_mode = PHY_INTERFACE_MODE_RMII,
383 .mac_peripherals = bfin_mac_peripherals,
384};
385
365static struct platform_device bfin_mii_bus = { 386static struct platform_device bfin_mii_bus = {
366 .name = "bfin_mii_bus", 387 .name = "bfin_mii_bus",
388 .dev = {
389 .platform_data = &bfin_mii_bus_data,
390 }
367}; 391};
368 392
369static struct platform_device bfin_mac_device = { 393static struct platform_device bfin_mac_device = {
370 .name = "bfin_mac", 394 .name = "bfin_mac",
371 .dev.platform_data = &bfin_mii_bus, 395 .dev = {
396 .platform_data = &bfin_mii_bus,
397 }
372}; 398};
373#endif 399#endif
374 400
@@ -431,8 +457,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
431}; 457};
432#endif 458#endif
433 459
434#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 460#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
435 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 461 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
436static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 462static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
437 .enable_dma = 0, 463 .enable_dma = 0,
438 .bits_per_word = 16, 464 .bits_per_word = 16,
@@ -547,13 +573,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
547 }, 573 },
548#endif 574#endif
549 575
550#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 576#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
551 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 577 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
552 { 578 {
553 .modalias = "ad1836", 579 .modalias = "ad183x",
554 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 580 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
555 .bus_num = 0, 581 .bus_num = 0,
556 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 582 .chip_select = 4,
557 .controller_data = &ad1836_spi_chip_info, 583 .controller_data = &ad1836_spi_chip_info,
558 }, 584 },
559#endif 585#endif
@@ -883,7 +909,7 @@ static struct adp5520_keys_platform_data adp5520_keys_data = {
883}; 909};
884 910
885 /* 911 /*
886 * ADP5520/5501 Multifuction Device Init Data 912 * ADP5520/5501 Multifunction Device Init Data
887 */ 913 */
888 914
889static struct adp5520_platform_data adp5520_pdev_data = { 915static struct adp5520_platform_data adp5520_pdev_data = {
@@ -929,6 +955,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
929 I2C_BOARD_INFO("ssm2602", 0x1b), 955 I2C_BOARD_INFO("ssm2602", 0x1b),
930 }, 956 },
931#endif 957#endif
958#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
959 {
960 I2C_BOARD_INFO("ad5252", 0x2f),
961 },
962#endif
932}; 963};
933 964
934#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 965#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..9ec575729e2c
--- /dev/null
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -0,0 +1,1008 @@
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)
260#include <linux/bfin_mac.h>
261static const unsigned short bfin_mac_peripherals[] = P_RMII0;
262
263static struct bfin_phydev_platform_data bfin_phydev_data[] = {
264 {
265 .addr = 1,
266 .irq = IRQ_MAC_PHYINT,
267 },
268};
269
270static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
271 .phydev_number = 1,
272 .phydev_data = bfin_phydev_data,
273 .phy_mode = PHY_INTERFACE_MODE_RMII,
274 .mac_peripherals = bfin_mac_peripherals,
275};
276
277static struct platform_device bfin_mii_bus = {
278 .name = "bfin_mii_bus",
279 .dev = {
280 .platform_data = &bfin_mii_bus_data,
281 }
282};
283
284static struct platform_device bfin_mac_device = {
285 .name = "bfin_mac",
286 .dev = {
287 .platform_data = &bfin_mii_bus,
288 }
289};
290#endif
291
292#if defined(CONFIG_MTD_M25P80) \
293 || defined(CONFIG_MTD_M25P80_MODULE)
294static struct mtd_partition bfin_spi_flash_partitions[] = {
295 {
296 .name = "bootloader(spi)",
297 .size = 0x00040000,
298 .offset = 0,
299 .mask_flags = MTD_CAP_ROM
300 }, {
301 .name = "linux kernel(spi)",
302 .size = MTDPART_SIZ_FULL,
303 .offset = MTDPART_OFS_APPEND,
304 }
305};
306
307static struct flash_platform_data bfin_spi_flash_data = {
308 .name = "m25p80",
309 .parts = bfin_spi_flash_partitions,
310 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
311 .type = "m25p16",
312};
313
314/* SPI flash chip (m25p64) */
315static struct bfin5xx_spi_chip spi_flash_chip_info = {
316 .enable_dma = 0, /* use dma transfer with this chip*/
317 .bits_per_word = 8,
318};
319#endif
320
321#if defined(CONFIG_BFIN_SPI_ADC) \
322 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
323/* SPI ADC chip */
324static struct bfin5xx_spi_chip spi_adc_chip_info = {
325 .enable_dma = 0, /* use dma transfer with this chip*/
326/*
327 * tll6527m V1.0 does not support native spi slave selects
328 * hence DMA mode will not be useful since the ADC needs
329 * CS to toggle for each sample and cs_change_per_word
330 * seems to be removed from spi_bfin5xx.c
331 */
332 .bits_per_word = 16,
333};
334#endif
335
336#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
337static struct bfin5xx_spi_chip mmc_spi_chip_info = {
338 .enable_dma = 0,
339 .bits_per_word = 8,
340};
341#endif
342
343#if defined(CONFIG_TOUCHSCREEN_AD7879) \
344 || defined(CONFIG_TOUCHSCREEN_AD7879_MODULE)
345static const struct ad7879_platform_data bfin_ad7879_ts_info = {
346 .model = 7879, /* Model = AD7879 */
347 .x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
348 .pressure_max = 10000,
349 .pressure_min = 0,
350 .first_conversion_delay = 3,
351 /* wait 512us before do a first conversion */
352 .acquisition_time = 1, /* 4us acquisition time per sample */
353 .median = 2, /* do 8 measurements */
354 .averaging = 1,
355 /* take the average of 4 middle samples */
356 .pen_down_acc_interval = 255, /* 9.4 ms */
357 .gpio_export = 1, /* configure AUX as GPIO output*/
358 .gpio_base = LCD_BACKLIGHT_GPIO,
359};
360#endif
361
362#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
363 || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
364static struct bfin5xx_spi_chip spi_ad7879_chip_info = {
365 .enable_dma = 0,
366 .bits_per_word = 16,
367};
368#endif
369
370#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
371static struct bfin5xx_spi_chip spidev_chip_info = {
372 .enable_dma = 0,
373 .bits_per_word = 8,
374};
375#endif
376
377#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
378static struct platform_device bfin_i2s = {
379 .name = "bfin-i2s",
380 .id = CONFIG_SND_BF5XX_SPORT_NUM,
381 /* TODO: add platform data here */
382};
383#endif
384
385#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
386static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
387 .enable_dma = 0,
388 .bits_per_word = 8,
389};
390#endif
391
392#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
393static struct bfin5xx_spi_chip spi_mcp23s08_sys_chip_info = {
394 .enable_dma = 0,
395 .bits_per_word = 8,
396};
397
398static struct bfin5xx_spi_chip spi_mcp23s08_usr_chip_info = {
399 .enable_dma = 0,
400 .bits_per_word = 8,
401};
402
403#include <linux/spi/mcp23s08.h>
404static const struct mcp23s08_platform_data bfin_mcp23s08_sys_gpio_info = {
405 .chip[0].is_present = true,
406 .base = 0x30,
407};
408static const struct mcp23s08_platform_data bfin_mcp23s08_usr_gpio_info = {
409 .chip[2].is_present = true,
410 .base = 0x38,
411};
412#endif
413
414static struct spi_board_info bfin_spi_board_info[] __initdata = {
415#if defined(CONFIG_MTD_M25P80) \
416 || defined(CONFIG_MTD_M25P80_MODULE)
417 {
418 /* the modalias must be the same as spi device driver name */
419 .modalias = "m25p80", /* Name of spi_driver for this device */
420 .max_speed_hz = 25000000,
421 /* max spi clock (SCK) speed in HZ */
422 .bus_num = 0, /* Framework bus number */
423 .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
424 /* Can be connected to TLL6527M GPIO connector */
425 /* Either SPI_ADC or M25P80 FLASH can be installed at a time */
426 .platform_data = &bfin_spi_flash_data,
427 .controller_data = &spi_flash_chip_info,
428 .mode = SPI_MODE_3,
429 },
430#endif
431
432#if defined(CONFIG_BFIN_SPI_ADC)
433 || defined(CONFIG_BFIN_SPI_ADC_MODULE)
434 {
435 .modalias = "bfin_spi_adc",
436 /* Name of spi_driver for this device */
437 .max_speed_hz = 10000000,
438 /* max spi clock (SCK) speed in HZ */
439 .bus_num = 0, /* Framework bus number */
440 .chip_select = EXP_GPIO_SPISEL_BASE + 0x04 + MAX_CTRL_CS,
441 /* Framework chip select. */
442 .platform_data = NULL, /* No spi_driver specific config */
443 .controller_data = &spi_adc_chip_info,
444 .mode = SPI_MODE_0,
445 },
446#endif
447
448#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
449 {
450 .modalias = "mmc_spi",
451/*
452 * TLL6527M V1.0 does not support SD Card at SPI Clock > 10 MHz due to
453 * SPI buffer limitations
454 */
455 .max_speed_hz = 10000000,
456 /* max spi clock (SCK) speed in HZ */
457 .bus_num = 0,
458 .chip_select = EXP_GPIO_SPISEL_BASE + 0x05 + MAX_CTRL_CS,
459 .controller_data = &mmc_spi_chip_info,
460 .mode = SPI_MODE_0,
461 },
462#endif
463#if defined(CONFIG_TOUCHSCREEN_AD7879_SPI) \
464 || defined(CONFIG_TOUCHSCREEN_AD7879_SPI_MODULE)
465 {
466 .modalias = "ad7879",
467 .platform_data = &bfin_ad7879_ts_info,
468 .irq = IRQ_PH14,
469 .max_speed_hz = 5000000,
470 /* max spi clock (SCK) speed in HZ */
471 .bus_num = 0,
472 .chip_select = EXP_GPIO_SPISEL_BASE + 0x07 + MAX_CTRL_CS,
473 .controller_data = &spi_ad7879_chip_info,
474 .mode = SPI_CPHA | SPI_CPOL,
475 },
476#endif
477#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
478 {
479 .modalias = "spidev",
480 .max_speed_hz = 10000000,
481 /* TLL6527Mv1-0 supports max spi clock (SCK) speed = 10 MHz */
482 .bus_num = 0,
483 .chip_select = EXP_GPIO_SPISEL_BASE + 0x03 + MAX_CTRL_CS,
484 .mode = SPI_CPHA | SPI_CPOL,
485 .controller_data = &spidev_chip_info,
486 },
487#endif
488#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
489 {
490 .modalias = "bfin-lq035q1-spi",
491 .max_speed_hz = 20000000,
492 .bus_num = 0,
493 .chip_select = EXP_GPIO_SPISEL_BASE + 0x06 + MAX_CTRL_CS,
494 .controller_data = &lq035q1_spi_chip_info,
495 .mode = SPI_CPHA | SPI_CPOL,
496 },
497#endif
498#if defined(CONFIG_GPIO_MCP23S08) || defined(CONFIG_GPIO_MCP23S08_MODULE)
499 {
500 .modalias = "mcp23s08",
501 .platform_data = &bfin_mcp23s08_sys_gpio_info,
502 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
503 .bus_num = 0,
504 .chip_select = EXP_GPIO_SPISEL_BASE + 0x01 + MAX_CTRL_CS,
505 .controller_data = &spi_mcp23s08_sys_chip_info,
506 .mode = SPI_CPHA | SPI_CPOL,
507 },
508 {
509 .modalias = "mcp23s08",
510 .platform_data = &bfin_mcp23s08_usr_gpio_info,
511 .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
512 .bus_num = 0,
513 .chip_select = EXP_GPIO_SPISEL_BASE + 0x02 + MAX_CTRL_CS,
514 .controller_data = &spi_mcp23s08_usr_chip_info,
515 .mode = SPI_CPHA | SPI_CPOL,
516 },
517#endif
518};
519
520#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
521/* SPI controller data */
522static struct bfin5xx_spi_master bfin_spi0_info = {
523 .num_chipselect = EXP_GPIO_SPISEL_BASE + 8 + MAX_CTRL_CS,
524 /* EXP_GPIO_SPISEL_BASE will be > MAX_BLACKFIN_GPIOS */
525 .enable_dma = 1, /* master has the ability to do dma transfer */
526 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
527};
528
529/* SPI (0) */
530static struct resource bfin_spi0_resource[] = {
531 [0] = {
532 .start = SPI0_REGBASE,
533 .end = SPI0_REGBASE + 0xFF,
534 .flags = IORESOURCE_MEM,
535 },
536 [1] = {
537 .start = CH_SPI,
538 .end = CH_SPI,
539 .flags = IORESOURCE_DMA,
540 },
541 [2] = {
542 .start = IRQ_SPI,
543 .end = IRQ_SPI,
544 .flags = IORESOURCE_IRQ,
545 },
546};
547
548static struct platform_device bfin_spi0_device = {
549 .name = "bfin-spi",
550 .id = 0, /* Bus number */
551 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
552 .resource = bfin_spi0_resource,
553 .dev = {
554 .platform_data = &bfin_spi0_info, /* Passed to driver */
555 },
556};
557#endif /* spi master and devices */
558
559#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
560#ifdef CONFIG_SERIAL_BFIN_UART0
561static struct resource bfin_uart0_resources[] = {
562 {
563 .start = UART0_THR,
564 .end = UART0_GCTL+2,
565 .flags = IORESOURCE_MEM,
566 },
567 {
568 .start = IRQ_UART0_RX,
569 .end = IRQ_UART0_RX+1,
570 .flags = IORESOURCE_IRQ,
571 },
572 {
573 .start = IRQ_UART0_ERROR,
574 .end = IRQ_UART0_ERROR,
575 .flags = IORESOURCE_IRQ,
576 },
577 {
578 .start = CH_UART0_TX,
579 .end = CH_UART0_TX,
580 .flags = IORESOURCE_DMA,
581 },
582 {
583 .start = CH_UART0_RX,
584 .end = CH_UART0_RX,
585 .flags = IORESOURCE_DMA,
586 },
587};
588
589unsigned short bfin_uart0_peripherals[] = {
590 P_UART0_TX, P_UART0_RX, 0
591};
592
593static struct platform_device bfin_uart0_device = {
594 .name = "bfin-uart",
595 .id = 0,
596 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
597 .resource = bfin_uart0_resources,
598 .dev = {
599 .platform_data = &bfin_uart0_peripherals,
600 /* Passed to driver */
601 },
602};
603#endif
604#ifdef CONFIG_SERIAL_BFIN_UART1
605static struct resource bfin_uart1_resources[] = {
606 {
607 .start = UART1_THR,
608 .end = UART1_GCTL+2,
609 .flags = IORESOURCE_MEM,
610 },
611 {
612 .start = IRQ_UART1_RX,
613 .end = IRQ_UART1_RX+1,
614 .flags = IORESOURCE_IRQ,
615 },
616 {
617 .start = IRQ_UART1_ERROR,
618 .end = IRQ_UART1_ERROR,
619 .flags = IORESOURCE_IRQ,
620 },
621 {
622 .start = CH_UART1_TX,
623 .end = CH_UART1_TX,
624 .flags = IORESOURCE_DMA,
625 },
626 {
627 .start = CH_UART1_RX,
628 .end = CH_UART1_RX,
629 .flags = IORESOURCE_DMA,
630 },
631#ifdef CONFIG_BFIN_UART1_CTSRTS
632 { /* CTS pin */
633 .start = GPIO_PF9,
634 .end = GPIO_PF9,
635 .flags = IORESOURCE_IO,
636 },
637 { /* RTS pin */
638 .start = GPIO_PF10,
639 .end = GPIO_PF10,
640 .flags = IORESOURCE_IO,
641 },
642#endif
643};
644
645unsigned short bfin_uart1_peripherals[] = {
646 P_UART1_TX, P_UART1_RX, 0
647};
648
649static struct platform_device bfin_uart1_device = {
650 .name = "bfin-uart",
651 .id = 1,
652 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
653 .resource = bfin_uart1_resources,
654 .dev = {
655 .platform_data = &bfin_uart1_peripherals,
656 /* Passed to driver */
657 },
658};
659#endif
660#endif
661
662#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
663#ifdef CONFIG_BFIN_SIR0
664static struct resource bfin_sir0_resources[] = {
665 {
666 .start = 0xFFC00400,
667 .end = 0xFFC004FF,
668 .flags = IORESOURCE_MEM,
669 },
670 {
671 .start = IRQ_UART0_RX,
672 .end = IRQ_UART0_RX+1,
673 .flags = IORESOURCE_IRQ,
674 },
675 {
676 .start = CH_UART0_RX,
677 .end = CH_UART0_RX+1,
678 .flags = IORESOURCE_DMA,
679 },
680};
681
682static struct platform_device bfin_sir0_device = {
683 .name = "bfin_sir",
684 .id = 0,
685 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
686 .resource = bfin_sir0_resources,
687};
688#endif
689#ifdef CONFIG_BFIN_SIR1
690static struct resource bfin_sir1_resources[] = {
691 {
692 .start = 0xFFC02000,
693 .end = 0xFFC020FF,
694 .flags = IORESOURCE_MEM,
695 },
696 {
697 .start = IRQ_UART1_RX,
698 .end = IRQ_UART1_RX+1,
699 .flags = IORESOURCE_IRQ,
700 },
701 {
702 .start = CH_UART1_RX,
703 .end = CH_UART1_RX+1,
704 .flags = IORESOURCE_DMA,
705 },
706};
707
708static struct platform_device bfin_sir1_device = {
709 .name = "bfin_sir",
710 .id = 1,
711 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
712 .resource = bfin_sir1_resources,
713};
714#endif
715#endif
716
717#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
718static struct resource bfin_twi0_resource[] = {
719 [0] = {
720 .start = TWI0_REGBASE,
721 .end = TWI0_REGBASE,
722 .flags = IORESOURCE_MEM,
723 },
724 [1] = {
725 .start = IRQ_TWI,
726 .end = IRQ_TWI,
727 .flags = IORESOURCE_IRQ,
728 },
729};
730
731static struct platform_device i2c_bfin_twi_device = {
732 .name = "i2c-bfin-twi",
733 .id = 0,
734 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
735 .resource = bfin_twi0_resource,
736};
737#endif
738
739static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
740#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
741 {
742 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
743 },
744#endif
745
746#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
747 {
748 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
749 },
750#endif
751#if defined(CONFIG_TOUCHSCREEN_AD7879_I2C) \
752 || defined(CONFIG_TOUCHSCREEN_AD7879_I2C_MODULE)
753 {
754 I2C_BOARD_INFO("ad7879", 0x2C),
755 .irq = IRQ_PH14,
756 .platform_data = (void *)&bfin_ad7879_ts_info,
757 },
758#endif
759#if defined(CONFIG_SND_SOC_SSM2602) || defined(CONFIG_SND_SOC_SSM2602_MODULE)
760 {
761 I2C_BOARD_INFO("ssm2602", 0x1b),
762 },
763#endif
764 {
765 I2C_BOARD_INFO("adm1192", 0x2e),
766 },
767
768 {
769 I2C_BOARD_INFO("ltc3576", 0x09),
770 },
771#if defined(CONFIG_INPUT_ADXL34X_I2C) \
772 || defined(CONFIG_INPUT_ADXL34X_I2C_MODULE)
773 {
774 I2C_BOARD_INFO("adxl34x", 0x53),
775 .irq = IRQ_PH13,
776 .platform_data = (void *)&adxl345_info,
777 },
778#endif
779};
780
781#if defined(CONFIG_SERIAL_BFIN_SPORT) \
782 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
783#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
784static struct resource bfin_sport0_uart_resources[] = {
785 {
786 .start = SPORT0_TCR1,
787 .end = SPORT0_MRCS3+4,
788 .flags = IORESOURCE_MEM,
789 },
790 {
791 .start = IRQ_SPORT0_RX,
792 .end = IRQ_SPORT0_RX+1,
793 .flags = IORESOURCE_IRQ,
794 },
795 {
796 .start = IRQ_SPORT0_ERROR,
797 .end = IRQ_SPORT0_ERROR,
798 .flags = IORESOURCE_IRQ,
799 },
800};
801
802unsigned short bfin_sport0_peripherals[] = {
803 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
804 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0
805};
806
807static struct platform_device bfin_sport0_uart_device = {
808 .name = "bfin-sport-uart",
809 .id = 0,
810 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
811 .resource = bfin_sport0_uart_resources,
812 .dev = {
813 .platform_data = &bfin_sport0_peripherals,
814 /* Passed to driver */
815 },
816};
817#endif
818#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
819static struct resource bfin_sport1_uart_resources[] = {
820 {
821 .start = SPORT1_TCR1,
822 .end = SPORT1_MRCS3+4,
823 .flags = IORESOURCE_MEM,
824 },
825 {
826 .start = IRQ_SPORT1_RX,
827 .end = IRQ_SPORT1_RX+1,
828 .flags = IORESOURCE_IRQ,
829 },
830 {
831 .start = IRQ_SPORT1_ERROR,
832 .end = IRQ_SPORT1_ERROR,
833 .flags = IORESOURCE_IRQ,
834 },
835};
836
837unsigned short bfin_sport1_peripherals[] = {
838 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
839 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0
840};
841
842static struct platform_device bfin_sport1_uart_device = {
843 .name = "bfin-sport-uart",
844 .id = 1,
845 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
846 .resource = bfin_sport1_uart_resources,
847 .dev = {
848 .platform_data = &bfin_sport1_peripherals,
849 /* Passed to driver */
850 },
851};
852#endif
853#endif
854
855static const unsigned int cclk_vlev_datasheet[] = {
856 VRPAIR(VLEV_100, 400000000),
857 VRPAIR(VLEV_105, 426000000),
858 VRPAIR(VLEV_110, 500000000),
859 VRPAIR(VLEV_115, 533000000),
860 VRPAIR(VLEV_120, 600000000),
861};
862
863static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
864 .tuple_tab = cclk_vlev_datasheet,
865 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
866 .vr_settling_time = 25 /* us */,
867};
868
869static struct platform_device bfin_dpmc = {
870 .name = "bfin dpmc",
871 .dev = {
872 .platform_data = &bfin_dmpc_vreg_data,
873 },
874};
875
876static struct platform_device *tll6527m_devices[] __initdata = {
877
878 &bfin_dpmc,
879
880#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
881 &rtc_device,
882#endif
883
884#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
885 &musb_device,
886#endif
887
888#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
889 &bfin_mii_bus,
890 &bfin_mac_device,
891#endif
892
893#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
894 &bfin_spi0_device,
895#endif
896
897#if defined(CONFIG_FB_BFIN_LQ035Q1) || defined(CONFIG_FB_BFIN_LQ035Q1_MODULE)
898 &bfin_lq035q1_device,
899#endif
900
901#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
902#ifdef CONFIG_SERIAL_BFIN_UART0
903 &bfin_uart0_device,
904#endif
905#ifdef CONFIG_SERIAL_BFIN_UART1
906 &bfin_uart1_device,
907#endif
908#endif
909
910#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
911#ifdef CONFIG_BFIN_SIR0
912 &bfin_sir0_device,
913#endif
914#ifdef CONFIG_BFIN_SIR1
915 &bfin_sir1_device,
916#endif
917#endif
918
919#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
920 &i2c_bfin_twi_device,
921#endif
922
923#if defined(CONFIG_SERIAL_BFIN_SPORT) \
924 || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
925#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
926 &bfin_sport0_uart_device,
927#endif
928#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
929 &bfin_sport1_uart_device,
930#endif
931#endif
932
933#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)
934 &tll6527m_flash_device,
935#endif
936
937#if defined(CONFIG_SND_BF5XX_I2S) || defined(CONFIG_SND_BF5XX_I2S_MODULE)
938 &bfin_i2s,
939#endif
940
941#if defined(CONFIG_GPIO_DECODER) || defined(CONFIG_GPIO_DECODER_MODULE)
942 &spi_decoded_gpio,
943#endif
944};
945
946static int __init tll6527m_init(void)
947{
948 printk(KERN_INFO "%s(): registering device resources\n", __func__);
949 i2c_register_board_info(0, bfin_i2c_board_info,
950 ARRAY_SIZE(bfin_i2c_board_info));
951 platform_add_devices(tll6527m_devices, ARRAY_SIZE(tll6527m_devices));
952 spi_register_board_info(bfin_spi_board_info,
953 ARRAY_SIZE(bfin_spi_board_info));
954 return 0;
955}
956
957arch_initcall(tll6527m_init);
958
959static struct platform_device *tll6527m_early_devices[] __initdata = {
960#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
961#ifdef CONFIG_SERIAL_BFIN_UART0
962 &bfin_uart0_device,
963#endif
964#ifdef CONFIG_SERIAL_BFIN_UART1
965 &bfin_uart1_device,
966#endif
967#endif
968
969#if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
970#ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
971 &bfin_sport0_uart_device,
972#endif
973#ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
974 &bfin_sport1_uart_device,
975#endif
976#endif
977};
978
979void __init native_machine_early_platform_add_devices(void)
980{
981 printk(KERN_INFO "register early platform devices\n");
982 early_platform_add_devices(tll6527m_early_devices,
983 ARRAY_SIZE(tll6527m_early_devices));
984}
985
986void native_machine_restart(char *cmd)
987{
988 /* workaround reboot hang when booting from SPI */
989 if ((bfin_read_SYSCR() & 0x7) == 0x3)
990 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
991}
992
993void bfin_get_ether_addr(char *addr)
994{
995 /* the MAC is stored in OTP memory page 0xDF */
996 u32 ret;
997 u64 otp_mac;
998 u32 (*otp_read)(u32 page, u32 flags,
999 u64 *page_content) = (void *)0xEF00001A;
1000
1001 ret = otp_read(0xDF, 0x00, &otp_mac);
1002 if (!(ret & 0x1)) {
1003 char *otp_mac_p = (char *)&otp_mac;
1004 for (ret = 0; ret < 6; ++ret)
1005 addr[ret] = otp_mac_p[5 - ret];
1006 }
1007}
1008EXPORT_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 11fb27bc427d..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)
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-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 84a06f677dff..20c102285bef 100644
--- a/arch/blackfin/mach-bf533/boards/blackstamp.c
+++ b/arch/blackfin/mach-bf533/boards/blackstamp.c
@@ -368,8 +368,8 @@ static struct platform_device bfin_device_gpiokeys = {
368#include <linux/i2c-gpio.h> 368#include <linux/i2c-gpio.h>
369 369
370static struct i2c_gpio_platform_data i2c_gpio_data = { 370static struct i2c_gpio_platform_data i2c_gpio_data = {
371 .sda_pin = 8, 371 .sda_pin = GPIO_PF8,
372 .scl_pin = 9, 372 .scl_pin = GPIO_PF9,
373 .sda_is_open_drain = 0, 373 .sda_is_open_drain = 0,
374 .scl_is_open_drain = 0, 374 .scl_is_open_drain = 0,
375 .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 b8474cac6b03..5ba4b02a12eb 100644
--- a/arch/blackfin/mach-bf533/boards/ip0x.c
+++ b/arch/blackfin/mach-bf533/boards/ip0x.c
@@ -232,7 +232,7 @@ static struct resource isp1362_hcd_resources[] = {
232 },{ 232 },{
233 .start = IRQ_PF11, 233 .start = IRQ_PF11,
234 .end = IRQ_PF11, 234 .end = IRQ_PF11,
235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, 235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
236 }, 236 },
237}; 237};
238 238
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index 29c219eff2ff..b3b1cdea2703 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -185,7 +185,7 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
185}; 185};
186#endif 186#endif
187 187
188#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)
189static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 189static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
190 .enable_dma = 0, 190 .enable_dma = 0,
191 .bits_per_word = 16, 191 .bits_per_word = 16,
@@ -252,13 +252,15 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
252 }, 252 },
253#endif 253#endif
254 254
255#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)
256 { 256 {
257 .modalias = "ad1836", 257 .modalias = "ad183x",
258 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 258 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
259 .bus_num = 0, 259 .bus_num = 0,
260 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 260 .chip_select = 4,
261 .platform_data = "ad1836", /* only includes chip name for the moment */
261 .controller_data = &ad1836_spi_chip_info, 262 .controller_data = &ad1836_spi_chip_info,
263 .mode = SPI_MODE_3,
262 }, 264 },
263#endif 265#endif
264 266
@@ -495,8 +497,8 @@ static struct platform_device bfin_device_gpiokeys = {
495#include <linux/i2c-gpio.h> 497#include <linux/i2c-gpio.h>
496 498
497static struct i2c_gpio_platform_data i2c_gpio_data = { 499static struct i2c_gpio_platform_data i2c_gpio_data = {
498 .sda_pin = 2, 500 .sda_pin = GPIO_PF2,
499 .scl_pin = 3, 501 .scl_pin = GPIO_PF3,
500 .sda_is_open_drain = 0, 502 .sda_is_open_drain = 0,
501 .scl_is_open_drain = 0, 503 .scl_is_open_drain = 0,
502 .udelay = 40, 504 .udelay = 40,
@@ -534,6 +536,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
534 I2C_BOARD_INFO("bfin-adv7393", 0x2B), 536 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
535 }, 537 },
536#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
537}; 544};
538 545
539static const unsigned int cclk_vlev_datasheet[] = 546static const unsigned int cclk_vlev_datasheet[] =
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-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..836698c4ee54 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
@@ -597,13 +597,35 @@ static struct platform_device bfin_sport1_uart_device = {
597#endif 597#endif
598 598
599#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 599#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
600#include <linux/bfin_mac.h>
601static const unsigned short bfin_mac_peripherals[] = P_MII0;
602
603static struct bfin_phydev_platform_data bfin_phydev_data[] = {
604 {
605 .addr = 1,
606 .irq = IRQ_MAC_PHYINT,
607 },
608};
609
610static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
611 .phydev_number = 1,
612 .phydev_data = bfin_phydev_data,
613 .phy_mode = PHY_INTERFACE_MODE_MII,
614 .mac_peripherals = bfin_mac_peripherals,
615};
616
600static struct platform_device bfin_mii_bus = { 617static struct platform_device bfin_mii_bus = {
601 .name = "bfin_mii_bus", 618 .name = "bfin_mii_bus",
619 .dev = {
620 .platform_data = &bfin_mii_bus_data,
621 }
602}; 622};
603 623
604static struct platform_device bfin_mac_device = { 624static struct platform_device bfin_mac_device = {
605 .name = "bfin_mac", 625 .name = "bfin_mac",
606 .dev.platform_data = &bfin_mii_bus, 626 .dev = {
627 .platform_data = &bfin_mii_bus,
628 }
607}; 629};
608#endif 630#endif
609 631
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c
index d464ad5b72b2..2a85670273cb 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
@@ -562,13 +562,35 @@ static struct platform_device bfin_sport1_uart_device = {
562#endif 562#endif
563 563
564#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 564#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
565#include <linux/bfin_mac.h>
566static const unsigned short bfin_mac_peripherals[] = P_MII0;
567
568static struct bfin_phydev_platform_data bfin_phydev_data[] = {
569 {
570 .addr = 1,
571 .irq = IRQ_MAC_PHYINT,
572 },
573};
574
575static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
576 .phydev_number = 1,
577 .phydev_data = bfin_phydev_data,
578 .phy_mode = PHY_INTERFACE_MODE_MII,
579 .mac_peripherals = bfin_mac_peripherals,
580};
581
565static struct platform_device bfin_mii_bus = { 582static struct platform_device bfin_mii_bus = {
566 .name = "bfin_mii_bus", 583 .name = "bfin_mii_bus",
584 .dev = {
585 .platform_data = &bfin_mii_bus_data,
586 }
567}; 587};
568 588
569static struct platform_device bfin_mac_device = { 589static struct platform_device bfin_mac_device = {
570 .name = "bfin_mac", 590 .name = "bfin_mac",
571 .dev.platform_data = &bfin_mii_bus, 591 .dev = {
592 .platform_data = &bfin_mii_bus,
593 }
572}; 594};
573#endif 595#endif
574 596
diff --git a/arch/blackfin/mach-bf537/boards/minotaur.c b/arch/blackfin/mach-bf537/boards/minotaur.c
index 05d45994480e..49800518412c 100644
--- a/arch/blackfin/mach-bf537/boards/minotaur.c
+++ b/arch/blackfin/mach-bf537/boards/minotaur.c
@@ -68,13 +68,35 @@ static struct platform_device rtc_device = {
68#endif 68#endif
69 69
70#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 70#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
71#include <linux/bfin_mac.h>
72static const unsigned short bfin_mac_peripherals[] = P_MII0;
73
74static struct bfin_phydev_platform_data bfin_phydev_data[] = {
75 {
76 .addr = 1,
77 .irq = IRQ_MAC_PHYINT,
78 },
79};
80
81static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
82 .phydev_number = 1,
83 .phydev_data = bfin_phydev_data,
84 .phy_mode = PHY_INTERFACE_MODE_MII,
85 .mac_peripherals = bfin_mac_peripherals,
86};
87
71static struct platform_device bfin_mii_bus = { 88static struct platform_device bfin_mii_bus = {
72 .name = "bfin_mii_bus", 89 .name = "bfin_mii_bus",
90 .dev = {
91 .platform_data = &bfin_mii_bus_data,
92 }
73}; 93};
74 94
75static struct platform_device bfin_mac_device = { 95static struct platform_device bfin_mac_device = {
76 .name = "bfin_mac", 96 .name = "bfin_mac",
77 .dev.platform_data = &bfin_mii_bus, 97 .dev = {
98 .platform_data = &bfin_mii_bus,
99 }
78}; 100};
79#endif 101#endif
80 102
diff --git a/arch/blackfin/mach-bf537/boards/pnav10.c b/arch/blackfin/mach-bf537/boards/pnav10.c
index 812e8f991601..b95807894e25 100644
--- a/arch/blackfin/mach-bf537/boards/pnav10.c
+++ b/arch/blackfin/mach-bf537/boards/pnav10.c
@@ -99,13 +99,35 @@ static struct platform_device smc91x_device = {
99#endif 99#endif
100 100
101#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 101#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
102#include <linux/bfin_mac.h>
103static const unsigned short bfin_mac_peripherals[] = P_RMII0;
104
105static struct bfin_phydev_platform_data bfin_phydev_data[] = {
106 {
107 .addr = 1,
108 .irq = IRQ_MAC_PHYINT,
109 },
110};
111
112static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
113 .phydev_number = 1,
114 .phydev_data = bfin_phydev_data,
115 .phy_mode = PHY_INTERFACE_MODE_RMII,
116 .mac_peripherals = bfin_mac_peripherals,
117};
118
102static struct platform_device bfin_mii_bus = { 119static struct platform_device bfin_mii_bus = {
103 .name = "bfin_mii_bus", 120 .name = "bfin_mii_bus",
121 .dev = {
122 .platform_data = &bfin_mii_bus_data,
123 }
104}; 124};
105 125
106static struct platform_device bfin_mac_device = { 126static struct platform_device bfin_mac_device = {
107 .name = "bfin_mac", 127 .name = "bfin_mac",
108 .dev.platform_data = &bfin_mii_bus, 128 .dev = {
129 .platform_data = &bfin_mii_bus,
130 }
109}; 131};
110#endif 132#endif
111 133
@@ -175,8 +197,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
175}; 197};
176#endif 198#endif
177 199
178#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 200#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
179 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 201 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
180static struct bfin5xx_spi_chip ad1836_spi_chip_info = { 202static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
181 .enable_dma = 0, 203 .enable_dma = 0,
182 .bits_per_word = 16, 204 .bits_per_word = 16,
@@ -238,13 +260,13 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
238 }, 260 },
239#endif 261#endif
240 262
241#if defined(CONFIG_SND_BLACKFIN_AD183X) \ 263#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
242 || defined(CONFIG_SND_BLACKFIN_AD183X_MODULE) 264 || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
243 { 265 {
244 .modalias = "ad1836", 266 .modalias = "ad183x",
245 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 267 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
246 .bus_num = 0, 268 .bus_num = 0,
247 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT, 269 .chip_select = 4,
248 .controller_data = &ad1836_spi_chip_info, 270 .controller_data = &ad1836_spi_chip_info,
249 }, 271 },
250#endif 272#endif
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index 68a27bccc7d4..3aa344ce8e52 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
@@ -329,13 +327,35 @@ static struct platform_device bfin_can_device = {
329#endif 327#endif
330 328
331#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 329#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
330#include <linux/bfin_mac.h>
331static const unsigned short bfin_mac_peripherals[] = P_MII0;
332
333static struct bfin_phydev_platform_data bfin_phydev_data[] = {
334 {
335 .addr = 1,
336 .irq = PHY_POLL, /* IRQ_MAC_PHYINT */
337 },
338};
339
340static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
341 .phydev_number = 1,
342 .phydev_data = bfin_phydev_data,
343 .phy_mode = PHY_INTERFACE_MODE_MII,
344 .mac_peripherals = bfin_mac_peripherals,
345};
346
332static struct platform_device bfin_mii_bus = { 347static struct platform_device bfin_mii_bus = {
333 .name = "bfin_mii_bus", 348 .name = "bfin_mii_bus",
349 .dev = {
350 .platform_data = &bfin_mii_bus_data,
351 }
334}; 352};
335 353
336static struct platform_device bfin_mac_device = { 354static struct platform_device bfin_mac_device = {
337 .name = "bfin_mac", 355 .name = "bfin_mac",
338 .dev.platform_data = &bfin_mii_bus, 356 .dev = {
357 .platform_data = &bfin_mii_bus,
358 }
339}; 359};
340#endif 360#endif
341 361
@@ -418,7 +438,7 @@ static struct platform_nand_data bfin_plat_nand_data = {
418static struct resource bfin_plat_nand_resources = { 438static struct resource bfin_plat_nand_resources = {
419 .start = 0x20212000, 439 .start = 0x20212000,
420 .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)), 440 .end = 0x20212000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
421 .flags = IORESOURCE_IO, 441 .flags = IORESOURCE_MEM,
422}; 442};
423 443
424static struct platform_device bfin_async_nand_device = { 444static struct platform_device bfin_async_nand_device = {
@@ -545,6 +565,14 @@ static struct bfin5xx_spi_chip ad1938_spi_chip_info = {
545}; 565};
546#endif 566#endif
547 567
568#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) \
569 || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
570static struct bfin5xx_spi_chip adav801_spi_chip_info = {
571 .enable_dma = 0,
572 .bits_per_word = 8,
573};
574#endif
575
548#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 576#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
549#include <linux/input/ad714x.h> 577#include <linux/input/ad714x.h>
550static struct bfin5xx_spi_chip ad7147_spi_chip_info = { 578static struct bfin5xx_spi_chip ad7147_spi_chip_info = {
@@ -693,6 +721,65 @@ static struct bfin5xx_spi_chip ad2s1210_spi_chip_info = {
693}; 721};
694#endif 722#endif
695 723
724#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE)
725static struct bfin5xx_spi_chip ad7314_spi_chip_info = {
726 .enable_dma = 0,
727 .bits_per_word = 16,
728};
729#endif
730
731#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE)
732static unsigned short ad7816_platform_data[] = {
733 GPIO_PF4, /* rdwr_pin */
734 GPIO_PF5, /* convert_pin */
735 GPIO_PF7, /* busy_pin */
736 0,
737};
738
739static struct bfin5xx_spi_chip ad7816_spi_chip_info = {
740 .enable_dma = 0,
741 .bits_per_word = 8,
742};
743#endif
744
745#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE)
746static unsigned long adt7310_platform_data[3] = {
747/* INT bound temperature alarm event. line 1 */
748 IRQ_PG4, IRQF_TRIGGER_LOW,
749/* CT bound temperature alarm event irq_flags. line 0 */
750 IRQF_TRIGGER_LOW,
751};
752
753static struct bfin5xx_spi_chip adt7310_spi_chip_info = {
754 .enable_dma = 0,
755 .bits_per_word = 8,
756};
757#endif
758
759#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE)
760static unsigned short ad7298_platform_data[] = {
761 GPIO_PF7, /* busy_pin */
762 0,
763};
764
765static struct bfin5xx_spi_chip ad7298_spi_chip_info = {
766 .enable_dma = 0,
767 .bits_per_word = 16,
768};
769#endif
770
771#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE)
772static unsigned long adt7316_spi_data[2] = {
773 IRQF_TRIGGER_LOW, /* interrupt flags */
774 GPIO_PF7, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */
775};
776
777static struct bfin5xx_spi_chip adt7316_spi_chip_info = {
778 .enable_dma = 0,
779 .bits_per_word = 8,
780};
781#endif
782
696#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 783#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
697#define MMC_SPI_CARD_DETECT_INT IRQ_PF5 784#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
698 785
@@ -824,14 +911,12 @@ static struct bfin5xx_spi_chip lq035q1_spi_chip_info = {
824static struct bfin5xx_spi_chip enc28j60_spi_chip_info = { 911static struct bfin5xx_spi_chip enc28j60_spi_chip_info = {
825 .enable_dma = 1, 912 .enable_dma = 1,
826 .bits_per_word = 8, 913 .bits_per_word = 8,
827 .cs_gpio = GPIO_PF10,
828}; 914};
829#endif 915#endif
830 916
831#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE) 917#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE)
832static struct bfin5xx_spi_chip adf7021_spi_chip_info = { 918static struct bfin5xx_spi_chip adf7021_spi_chip_info = {
833 .bits_per_word = 16, 919 .bits_per_word = 16,
834 .cs_gpio = GPIO_PF10,
835}; 920};
836 921
837#include <linux/spi/adf702x.h> 922#include <linux/spi/adf702x.h>
@@ -938,6 +1023,13 @@ static struct bfin5xx_spi_chip spi_adxl34x_chip_info = {
938}; 1023};
939#endif 1024#endif
940 1025
1026#if defined(CONFIG_AD7476) || defined(CONFIG_AD7476_MODULE)
1027static struct bfin5xx_spi_chip spi_ad7476_chip_info = {
1028 .enable_dma = 0, /* use dma transfer with this chip*/
1029 .bits_per_word = 8,
1030};
1031#endif
1032
941static struct spi_board_info bfin_spi_board_info[] __initdata = { 1033static struct spi_board_info bfin_spi_board_info[] __initdata = {
942#if defined(CONFIG_MTD_M25P80) \ 1034#if defined(CONFIG_MTD_M25P80) \
943 || defined(CONFIG_MTD_M25P80_MODULE) 1035 || defined(CONFIG_MTD_M25P80_MODULE)
@@ -982,7 +1074,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
982 .modalias = "ad183x", 1074 .modalias = "ad183x",
983 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */ 1075 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
984 .bus_num = 0, 1076 .bus_num = 0,
985 .chip_select = 4,/* CONFIG_SND_BLACKFIN_SPI_PFBIT */ 1077 .chip_select = 4,
986 .platform_data = "ad1836", /* only includes chip name for the moment */ 1078 .platform_data = "ad1836", /* only includes chip name for the moment */
987 .controller_data = &ad1836_spi_chip_info, 1079 .controller_data = &ad1836_spi_chip_info,
988 .mode = SPI_MODE_3, 1080 .mode = SPI_MODE_3,
@@ -1000,6 +1092,17 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1000 }, 1092 },
1001#endif 1093#endif
1002 1094
1095#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
1096 {
1097 .modalias = "adav80x",
1098 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
1099 .bus_num = 0,
1100 .chip_select = 1,
1101 .controller_data = &adav801_spi_chip_info,
1102 .mode = SPI_MODE_3,
1103 },
1104#endif
1105
1003#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE) 1106#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
1004 { 1107 {
1005 .modalias = "ad714x_captouch", 1108 .modalias = "ad714x_captouch",
@@ -1018,6 +1121,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1018 .modalias = "ad2s90", 1121 .modalias = "ad2s90",
1019 .bus_num = 0, 1122 .bus_num = 0,
1020 .chip_select = 3, /* change it for your board */ 1123 .chip_select = 3, /* change it for your board */
1124 .mode = SPI_MODE_3,
1021 .platform_data = NULL, 1125 .platform_data = NULL,
1022 .controller_data = &ad2s90_spi_chip_info, 1126 .controller_data = &ad2s90_spi_chip_info,
1023 }, 1127 },
@@ -1044,6 +1148,67 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1044 }, 1148 },
1045#endif 1149#endif
1046 1150
1151#if defined(CONFIG_AD7314) || defined(CONFIG_AD7314_MODULE)
1152 {
1153 .modalias = "ad7314",
1154 .max_speed_hz = 1000000,
1155 .bus_num = 0,
1156 .chip_select = 4, /* CS, change it for your board */
1157 .controller_data = &ad7314_spi_chip_info,
1158 .mode = SPI_MODE_1,
1159 },
1160#endif
1161
1162#if defined(CONFIG_AD7816) || defined(CONFIG_AD7816_MODULE)
1163 {
1164 .modalias = "ad7818",
1165 .max_speed_hz = 1000000,
1166 .bus_num = 0,
1167 .chip_select = 4, /* CS, change it for your board */
1168 .platform_data = ad7816_platform_data,
1169 .controller_data = &ad7816_spi_chip_info,
1170 .mode = SPI_MODE_3,
1171 },
1172#endif
1173
1174#if defined(CONFIG_ADT7310) || defined(CONFIG_ADT7310_MODULE)
1175 {
1176 .modalias = "adt7310",
1177 .max_speed_hz = 1000000,
1178 .irq = IRQ_PG5, /* CT alarm event. Line 0 */
1179 .bus_num = 0,
1180 .chip_select = 4, /* CS, change it for your board */
1181 .platform_data = adt7310_platform_data,
1182 .controller_data = &adt7310_spi_chip_info,
1183 .mode = SPI_MODE_3,
1184 },
1185#endif
1186
1187#if defined(CONFIG_AD7298) || defined(CONFIG_AD7298_MODULE)
1188 {
1189 .modalias = "ad7298",
1190 .max_speed_hz = 1000000,
1191 .bus_num = 0,
1192 .chip_select = 4, /* CS, change it for your board */
1193 .platform_data = ad7298_platform_data,
1194 .controller_data = &ad7298_spi_chip_info,
1195 .mode = SPI_MODE_3,
1196 },
1197#endif
1198
1199#if defined(CONFIG_ADT7316_SPI) || defined(CONFIG_ADT7316_SPI_MODULE)
1200 {
1201 .modalias = "adt7316",
1202 .max_speed_hz = 1000000,
1203 .irq = IRQ_PG5, /* interrupt line */
1204 .bus_num = 0,
1205 .chip_select = 4, /* CS, change it for your board */
1206 .platform_data = adt7316_spi_data,
1207 .controller_data = &adt7316_spi_chip_info,
1208 .mode = SPI_MODE_3,
1209 },
1210#endif
1211
1047#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) 1212#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
1048 { 1213 {
1049 .modalias = "mmc_spi", 1214 .modalias = "mmc_spi",
@@ -1103,7 +1268,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1103 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */ 1268 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
1104 .irq = IRQ_PF6, 1269 .irq = IRQ_PF6,
1105 .bus_num = 0, 1270 .bus_num = 0,
1106 .chip_select = 0, /* GPIO controlled SSEL */ 1271 .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* GPIO controlled SSEL */
1107 .controller_data = &enc28j60_spi_chip_info, 1272 .controller_data = &enc28j60_spi_chip_info,
1108 .mode = SPI_MODE_0, 1273 .mode = SPI_MODE_0,
1109 }, 1274 },
@@ -1125,7 +1290,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1125 .modalias = "adf702x", 1290 .modalias = "adf702x",
1126 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */ 1291 .max_speed_hz = 16000000, /* max spi clock (SCK) speed in HZ */
1127 .bus_num = 0, 1292 .bus_num = 0,
1128 .chip_select = 0, /* GPIO controlled SSEL */ 1293 .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* GPIO controlled SSEL */
1129 .controller_data = &adf7021_spi_chip_info, 1294 .controller_data = &adf7021_spi_chip_info,
1130 .platform_data = &adf7021_platform_data, 1295 .platform_data = &adf7021_platform_data,
1131 .mode = SPI_MODE_0, 1296 .mode = SPI_MODE_0,
@@ -1143,12 +1308,239 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
1143 .mode = SPI_MODE_0, 1308 .mode = SPI_MODE_0,
1144 }, 1309 },
1145#endif 1310#endif
1311#if defined(CONFIG_AD7476) \
1312 || defined(CONFIG_AD7476_MODULE)
1313 {
1314 .modalias = "ad7476", /* Name of spi_driver for this device */
1315 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
1316 .bus_num = 0, /* Framework bus number */
1317 .chip_select = 1, /* Framework chip select. */
1318 .platform_data = NULL, /* No spi_driver specific config */
1319 .controller_data = &spi_ad7476_chip_info,
1320 .mode = SPI_MODE_3,
1321 },
1322#endif
1323#if defined(CONFIG_ADE7753) \
1324 || defined(CONFIG_ADE7753_MODULE)
1325 {
1326 .modalias = "ade7753",
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_ADE7754) \
1335 || defined(CONFIG_ADE7754_MODULE)
1336 {
1337 .modalias = "ade7754",
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_ADE7758) \
1346 || defined(CONFIG_ADE7758_MODULE)
1347 {
1348 .modalias = "ade7758",
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_1,
1354 },
1355#endif
1356#if defined(CONFIG_ADE7759) \
1357 || defined(CONFIG_ADE7759_MODULE)
1358 {
1359 .modalias = "ade7759",
1360 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1361 .bus_num = 0,
1362 .chip_select = 1, /* CS, change it for your board */
1363 .platform_data = NULL, /* No spi_driver specific config */
1364 .mode = SPI_MODE_1,
1365 },
1366#endif
1367#if defined(CONFIG_ADE7854_SPI) \
1368 || defined(CONFIG_ADE7854_SPI_MODULE)
1369 {
1370 .modalias = "ade7854",
1371 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1372 .bus_num = 0,
1373 .chip_select = 1, /* CS, change it for your board */
1374 .platform_data = NULL, /* No spi_driver specific config */
1375 .mode = SPI_MODE_3,
1376 },
1377#endif
1378#if defined(CONFIG_ADIS16060) \
1379 || defined(CONFIG_ADIS16060_MODULE)
1380 {
1381 .modalias = "adis16060_r",
1382 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */
1383 .bus_num = 0,
1384 .chip_select = MAX_CTRL_CS + 1, /* CS for read, change it for your board */
1385 .platform_data = NULL, /* No spi_driver specific config */
1386 .mode = SPI_MODE_0,
1387 },
1388 {
1389 .modalias = "adis16060_w",
1390 .max_speed_hz = 2900000, /* max spi clock (SCK) speed in HZ */
1391 .bus_num = 0,
1392 .chip_select = 2, /* CS for write, change it for your board */
1393 .platform_data = NULL, /* No spi_driver specific config */
1394 .mode = SPI_MODE_1,
1395 },
1396#endif
1397#if defined(CONFIG_ADIS16130) \
1398 || defined(CONFIG_ADIS16130_MODULE)
1399 {
1400 .modalias = "adis16130",
1401 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1402 .bus_num = 0,
1403 .chip_select = 1, /* CS for read, change it for your board */
1404 .platform_data = NULL, /* No spi_driver specific config */
1405 .mode = SPI_MODE_3,
1406 },
1407#endif
1408#if defined(CONFIG_ADIS16201) \
1409 || defined(CONFIG_ADIS16201_MODULE)
1410 {
1411 .modalias = "adis16201",
1412 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1413 .bus_num = 0,
1414 .chip_select = 5, /* CS, change it for your board */
1415 .platform_data = NULL, /* No spi_driver specific config */
1416 .mode = SPI_MODE_3,
1417 .irq = IRQ_PF4,
1418 },
1419#endif
1420#if defined(CONFIG_ADIS16203) \
1421 || defined(CONFIG_ADIS16203_MODULE)
1422 {
1423 .modalias = "adis16203",
1424 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1425 .bus_num = 0,
1426 .chip_select = 5, /* CS, change it for your board */
1427 .platform_data = NULL, /* No spi_driver specific config */
1428 .mode = SPI_MODE_3,
1429 .irq = IRQ_PF4,
1430 },
1431#endif
1432#if defined(CONFIG_ADIS16204) \
1433 || defined(CONFIG_ADIS16204_MODULE)
1434 {
1435 .modalias = "adis16204",
1436 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1437 .bus_num = 0,
1438 .chip_select = 5, /* CS, change it for your board */
1439 .platform_data = NULL, /* No spi_driver specific config */
1440 .mode = SPI_MODE_3,
1441 .irq = IRQ_PF4,
1442 },
1443#endif
1444#if defined(CONFIG_ADIS16209) \
1445 || defined(CONFIG_ADIS16209_MODULE)
1446 {
1447 .modalias = "adis16209",
1448 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1449 .bus_num = 0,
1450 .chip_select = 5, /* CS, change it for your board */
1451 .platform_data = NULL, /* No spi_driver specific config */
1452 .mode = SPI_MODE_3,
1453 .irq = IRQ_PF4,
1454 },
1455#endif
1456#if defined(CONFIG_ADIS16220) \
1457 || defined(CONFIG_ADIS16220_MODULE)
1458 {
1459 .modalias = "adis16220",
1460 .max_speed_hz = 2000000, /* max spi clock (SCK) speed in HZ */
1461 .bus_num = 0,
1462 .chip_select = 5, /* CS, change it for your board */
1463 .platform_data = NULL, /* No spi_driver specific config */
1464 .mode = SPI_MODE_3,
1465 .irq = IRQ_PF4,
1466 },
1467#endif
1468#if defined(CONFIG_ADIS16240) \
1469 || defined(CONFIG_ADIS16240_MODULE)
1470 {
1471 .modalias = "adis16240",
1472 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
1473 .bus_num = 0,
1474 .chip_select = 5, /* CS, change it for your board */
1475 .platform_data = NULL, /* No spi_driver specific config */
1476 .mode = SPI_MODE_3,
1477 .irq = IRQ_PF4,
1478 },
1479#endif
1480#if defined(CONFIG_ADIS16260) \
1481 || defined(CONFIG_ADIS16260_MODULE)
1482 {
1483 .modalias = "adis16260",
1484 .max_speed_hz = 1500000, /* max spi clock (SCK) speed in HZ */
1485 .bus_num = 0,
1486 .chip_select = 5, /* CS, change it for your board */
1487 .platform_data = NULL, /* No spi_driver specific config */
1488 .mode = SPI_MODE_3,
1489 .irq = IRQ_PF4,
1490 },
1491#endif
1492#if defined(CONFIG_ADIS16261) \
1493 || defined(CONFIG_ADIS16261_MODULE)
1494 {
1495 .modalias = "adis16261",
1496 .max_speed_hz = 2500000, /* max spi clock (SCK) speed in HZ */
1497 .bus_num = 0,
1498 .chip_select = 1, /* CS, change it for your board */
1499 .platform_data = NULL, /* No spi_driver specific config */
1500 .mode = SPI_MODE_3,
1501 },
1502#endif
1503#if defined(CONFIG_ADIS16300) \
1504 || defined(CONFIG_ADIS16300_MODULE)
1505 {
1506 .modalias = "adis16300",
1507 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1508 .bus_num = 0,
1509 .chip_select = 5, /* CS, change it for your board */
1510 .platform_data = NULL, /* No spi_driver specific config */
1511 .mode = SPI_MODE_3,
1512 .irq = IRQ_PF4,
1513 },
1514#endif
1515#if defined(CONFIG_ADIS16350) \
1516 || defined(CONFIG_ADIS16350_MODULE)
1517 {
1518 .modalias = "adis16364",
1519 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1520 .bus_num = 0,
1521 .chip_select = 5, /* CS, change it for your board */
1522 .platform_data = NULL, /* No spi_driver specific config */
1523 .mode = SPI_MODE_3,
1524 .irq = IRQ_PF4,
1525 },
1526#endif
1527#if defined(CONFIG_ADIS16400) \
1528 || defined(CONFIG_ADIS16400_MODULE)
1529 {
1530 .modalias = "adis16400",
1531 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
1532 .bus_num = 0,
1533 .chip_select = 1, /* CS, change it for your board */
1534 .platform_data = NULL, /* No spi_driver specific config */
1535 .mode = SPI_MODE_3,
1536 },
1537#endif
1146}; 1538};
1147 1539
1148#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 1540#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1149/* SPI controller data */ 1541/* SPI controller data */
1150static struct bfin5xx_spi_master bfin_spi0_info = { 1542static struct bfin5xx_spi_master bfin_spi0_info = {
1151 .num_chipselect = 8, 1543 .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS,
1152 .enable_dma = 1, /* master has the ability to do dma transfer */ 1544 .enable_dma = 1, /* master has the ability to do dma transfer */
1153 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, 1545 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1154}; 1546};
@@ -1645,7 +2037,7 @@ static struct adp5520_keys_platform_data adp5520_keys_data = {
1645}; 2037};
1646 2038
1647 /* 2039 /*
1648 * ADP5520/5501 Multifuction Device Init Data 2040 * ADP5520/5501 Multifunction Device Init Data
1649 */ 2041 */
1650 2042
1651static struct adp5520_platform_data adp5520_pdev_data = { 2043static struct adp5520_platform_data adp5520_pdev_data = {
@@ -1773,12 +2165,6 @@ static struct regulator_init_data ad5398_regulator_data = {
1773 .consumer_supplies = &ad5398_consumer, 2165 .consumer_supplies = &ad5398_consumer,
1774}; 2166};
1775 2167
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) || \ 2168#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \
1783 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE) 2169 defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
1784static struct platform_device ad5398_virt_consumer_device = { 2170static struct platform_device ad5398_virt_consumer_device = {
@@ -1811,7 +2197,34 @@ static struct platform_device ad5398_userspace_consumer_device = {
1811#endif 2197#endif
1812#endif 2198#endif
1813 2199
2200#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE)
2201/* INT bound temperature alarm event. line 1 */
2202static unsigned long adt7410_platform_data[2] = {
2203 IRQ_PG4, IRQF_TRIGGER_LOW,
2204};
2205#endif
2206
2207#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE)
2208/* INT bound temperature alarm event. line 1 */
2209static unsigned long adt7316_i2c_data[2] = {
2210 IRQF_TRIGGER_LOW, /* interrupt flags */
2211 GPIO_PF4, /* ldac_pin, 0 means DAC/LDAC registers control DAC update */
2212};
2213#endif
2214
1814static struct i2c_board_info __initdata bfin_i2c_board_info[] = { 2215static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
2216#if defined(CONFIG_SND_BF5XX_SOC_AD193X) || defined(CONFIG_SND_BF5XX_SOC_AD193X_MODULE)
2217 {
2218 I2C_BOARD_INFO("ad1937", 0x04),
2219 },
2220#endif
2221
2222#if defined(CONFIG_SND_BF5XX_SOC_ADAV80X) || defined(CONFIG_SND_BF5XX_SOC_ADAV80X_MODULE)
2223 {
2224 I2C_BOARD_INFO("adav803", 0x10),
2225 },
2226#endif
2227
1815#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE) 2228#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE)
1816 { 2229 {
1817 I2C_BOARD_INFO("ad7142_captouch", 0x2C), 2230 I2C_BOARD_INFO("ad7142_captouch", 0x2C),
@@ -1843,12 +2256,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1843 { 2256 {
1844 I2C_BOARD_INFO("ad7414", 0x9), 2257 I2C_BOARD_INFO("ad7414", 0x9),
1845 .irq = IRQ_PG5, 2258 .irq = IRQ_PG5,
1846 /* 2259 .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 }, 2260 },
1853#endif 2261#endif
1854 2262
@@ -1856,12 +2264,56 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1856 { 2264 {
1857 I2C_BOARD_INFO("ad7417", 0xb), 2265 I2C_BOARD_INFO("ad7417", 0xb),
1858 .irq = IRQ_PG5, 2266 .irq = IRQ_PG5,
1859 /* 2267 .irq_flags = IRQF_TRIGGER_LOW,
1860 * platform_data pointer is borrwoed by the driver to 2268 .platform_data = (void *)GPIO_PF4,
1861 * store custimer defined IRQ ALART level mode. 2269 },
1862 * only IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW are valid. 2270#endif
1863 */ 2271
1864 .platform_data = (void *)IRQF_TRIGGER_LOW, 2272#if defined(CONFIG_ADE7854_I2C) || defined(CONFIG_ADE7854_I2C_MODULE)
2273 {
2274 I2C_BOARD_INFO("ade7854", 0x38),
2275 },
2276#endif
2277
2278#if defined(CONFIG_ADT75) || defined(CONFIG_ADT75_MODULE)
2279 {
2280 I2C_BOARD_INFO("adt75", 0x9),
2281 .irq = IRQ_PG5,
2282 .irq_flags = IRQF_TRIGGER_LOW,
2283 },
2284#endif
2285
2286#if defined(CONFIG_ADT7408) || defined(CONFIG_ADT7408_MODULE)
2287 {
2288 I2C_BOARD_INFO("adt7408", 0x18),
2289 .irq = IRQ_PG5,
2290 .irq_flags = IRQF_TRIGGER_LOW,
2291 },
2292#endif
2293
2294#if defined(CONFIG_ADT7410) || defined(CONFIG_ADT7410_MODULE)
2295 {
2296 I2C_BOARD_INFO("adt7410", 0x48),
2297 /* CT critical temperature event. line 0 */
2298 .irq = IRQ_PG5,
2299 .irq_flags = IRQF_TRIGGER_LOW,
2300 .platform_data = (void *)&adt7410_platform_data,
2301 },
2302#endif
2303
2304#if defined(CONFIG_AD7291) || defined(CONFIG_AD7291_MODULE)
2305 {
2306 I2C_BOARD_INFO("ad7291", 0x20),
2307 .irq = IRQ_PG5,
2308 .irq_flags = IRQF_TRIGGER_LOW,
2309 },
2310#endif
2311
2312#if defined(CONFIG_ADT7316_I2C) || defined(CONFIG_ADT7316_I2C_MODULE)
2313 {
2314 I2C_BOARD_INFO("adt7316", 0x48),
2315 .irq = IRQ_PG6,
2316 .platform_data = (void *)&adt7316_i2c_data,
1865 }, 2317 },
1866#endif 2318#endif
1867 2319
@@ -1917,7 +2369,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1917#endif 2369#endif
1918#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE) 2370#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
1919 { 2371 {
1920 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2C), 2372 I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2F),
1921 }, 2373 },
1922#endif 2374#endif
1923#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE) 2375#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE)
@@ -1954,7 +2406,7 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1954#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE) 2406#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
1955 { 2407 {
1956 I2C_BOARD_INFO("ad5398", 0xC), 2408 I2C_BOARD_INFO("ad5398", 0xC),
1957 .platform_data = (void *)&ad5398_i2c_platform_data, 2409 .platform_data = (void *)&ad5398_regulator_data,
1958 }, 2410 },
1959#endif 2411#endif
1960#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE) 2412#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE)
@@ -1963,6 +2415,16 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
1963 .platform_data = (void *)&adp8860_pdata, 2415 .platform_data = (void *)&adp8860_pdata,
1964 }, 2416 },
1965#endif 2417#endif
2418#if defined(CONFIG_SND_SOC_ADAU1373) || defined(CONFIG_SND_SOC_ADAU1373_MODULE)
2419 {
2420 I2C_BOARD_INFO("adau1373", 0x1A),
2421 },
2422#endif
2423#if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
2424 {
2425 I2C_BOARD_INFO("ad5252", 0x2e),
2426 },
2427#endif
1966}; 2428};
1967 2429
1968#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 2430#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -2147,50 +2609,38 @@ static struct platform_device bfin_ac97 = {
2147}; 2609};
2148#endif 2610#endif
2149 2611
2150#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE) 2612#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
2151#define REGULATOR_ADP122 "adp122" 2613#define REGULATOR_ADP122 "adp122"
2152#define REGULATOR_ADP150 "adp150" 2614#define REGULATOR_ADP122_UV 2500000
2153 2615
2154static struct regulator_consumer_supply adp122_consumers = { 2616static struct regulator_consumer_supply adp122_consumers = {
2155 .supply = REGULATOR_ADP122, 2617 .supply = REGULATOR_ADP122,
2156}; 2618};
2157 2619
2158static struct regulator_consumer_supply adp150_consumers = { 2620static struct regulator_init_data adp_switch_regulator_data = {
2159 .supply = REGULATOR_ADP150, 2621 .constraints = {
2160}; 2622 .name = REGULATOR_ADP122,
2161 2623 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
2162static struct regulator_init_data adp_switch_regulator_data[] = { 2624 .min_uV = REGULATOR_ADP122_UV,
2163 { 2625 .max_uV = REGULATOR_ADP122_UV,
2164 .constraints = { 2626 .min_uA = 0,
2165 .name = REGULATOR_ADP122, 2627 .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 }, 2628 },
2629 .num_consumer_supplies = 1, /* only 1 */
2630 .consumer_supplies = &adp122_consumers,
2185}; 2631};
2186 2632
2187static struct adp_switch_platform_data adp_switch_pdata = { 2633static struct fixed_voltage_config adp_switch_pdata = {
2188 .regulator_num = ARRAY_SIZE(adp_switch_regulator_data), 2634 .supply_name = REGULATOR_ADP122,
2189 .regulator_data = adp_switch_regulator_data, 2635 .microvolts = REGULATOR_ADP122_UV,
2636 .gpio = GPIO_PF2,
2637 .enable_high = 1,
2638 .enabled_at_boot = 0,
2639 .init_data = &adp_switch_regulator_data,
2190}; 2640};
2191 2641
2192static struct platform_device adp_switch_device = { 2642static struct platform_device adp_switch_device = {
2193 .name = "adp_switch", 2643 .name = "reg-fixed-voltage",
2194 .id = 0, 2644 .id = 0,
2195 .dev = { 2645 .dev = {
2196 .platform_data = &adp_switch_pdata, 2646 .platform_data = &adp_switch_pdata,
@@ -2216,27 +2666,26 @@ static struct platform_device adp122_userspace_consumer_device = {
2216 .platform_data = &adp122_userspace_comsumer_data, 2666 .platform_data = &adp122_userspace_comsumer_data,
2217 }, 2667 },
2218}; 2668};
2669#endif
2670#endif
2219 2671
2220static struct regulator_bulk_data adp150_bulk_data = { 2672#if defined(CONFIG_IIO_GPIO_TRIGGER) || \
2221 .supply = REGULATOR_ADP150, 2673 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2222};
2223 2674
2224static struct regulator_userspace_consumer_data adp150_userspace_comsumer_data = { 2675static struct resource iio_gpio_trigger_resources[] = {
2225 .name = REGULATOR_ADP150, 2676 [0] = {
2226 .num_supplies = 1, 2677 .start = IRQ_PF5,
2227 .supplies = &adp150_bulk_data, 2678 .end = IRQ_PF5,
2679 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
2680 },
2228}; 2681};
2229 2682
2230static struct platform_device adp150_userspace_consumer_device = { 2683static struct platform_device iio_gpio_trigger = {
2231 .name = "reg-userspace-consumer", 2684 .name = "iio_gpio_trigger",
2232 .id = 1, 2685 .num_resources = ARRAY_SIZE(iio_gpio_trigger_resources),
2233 .dev = { 2686 .resource = iio_gpio_trigger_resources,
2234 .platform_data = &adp150_userspace_comsumer_data,
2235 },
2236}; 2687};
2237#endif 2688#endif
2238#endif
2239
2240 2689
2241static struct platform_device *stamp_devices[] __initdata = { 2690static struct platform_device *stamp_devices[] __initdata = {
2242 2691
@@ -2369,14 +2818,18 @@ static struct platform_device *stamp_devices[] __initdata = {
2369#endif 2818#endif
2370#endif 2819#endif
2371 2820
2372#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE) 2821#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
2373 &adp_switch_device, 2822 &adp_switch_device,
2374#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \ 2823#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
2375 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE) 2824 defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
2376 &adp122_userspace_consumer_device, 2825 &adp122_userspace_consumer_device,
2377 &adp150_userspace_consumer_device,
2378#endif 2826#endif
2379#endif 2827#endif
2828
2829#if defined(CONFIG_IIO_GPIO_TRIGGER) || \
2830 defined(CONFIG_IIO_GPIO_TRIGGER_MODULE)
2831 &iio_gpio_trigger,
2832#endif
2380}; 2833};
2381 2834
2382static int __init stamp_init(void) 2835static 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..31498add1a42 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
@@ -564,13 +564,35 @@ static struct platform_device bfin_sport1_uart_device = {
564#endif 564#endif
565 565
566#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE) 566#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
567#include <linux/bfin_mac.h>
568static const unsigned short bfin_mac_peripherals[] = P_MII0;
569
570static struct bfin_phydev_platform_data bfin_phydev_data[] = {
571 {
572 .addr = 1,
573 .irq = IRQ_MAC_PHYINT,
574 },
575};
576
577static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
578 .phydev_number = 1,
579 .phydev_data = bfin_phydev_data,
580 .phy_mode = PHY_INTERFACE_MODE_MII,
581 .mac_peripherals = bfin_mac_peripherals,
582};
583
567static struct platform_device bfin_mii_bus = { 584static struct platform_device bfin_mii_bus = {
568 .name = "bfin_mii_bus", 585 .name = "bfin_mii_bus",
586 .dev = {
587 .platform_data = &bfin_mii_bus_data,
588 }
569}; 589};
570 590
571static struct platform_device bfin_mac_device = { 591static struct platform_device bfin_mac_device = {
572 .name = "bfin_mac", 592 .name = "bfin_mac",
573 .dev.platform_data = &bfin_mii_bus, 593 .dev = {
594 .platform_data = &bfin_mii_bus,
595 }
574}; 596};
575#endif 597#endif
576 598
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-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/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-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 0c16067df4f3..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)
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-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 cc0416a5fa02..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)
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/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/Makefile b/arch/blackfin/mach-common/Makefile
index 814cb483853b..ff299f24aba0 100644
--- a/arch/blackfin/mach-common/Makefile
+++ b/arch/blackfin/mach-common/Makefile
@@ -11,4 +11,3 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq.o
11obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o 11obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o
12obj-$(CONFIG_SMP) += smp.o 12obj-$(CONFIG_SMP) += smp.o
13obj-$(CONFIG_BFIN_KERNEL_CLOCK) += clocks-init.o 13obj-$(CONFIG_BFIN_KERNEL_CLOCK) += clocks-init.o
14obj-$(CONFIG_DEBUG_ICACHE_CHECK) += irqpanic.o
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 eaece5f84e42..da7e3c63746b 100644
--- a/arch/blackfin/mach-common/ints-priority.c
+++ b/arch/blackfin/mach-common/ints-priority.c
@@ -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/irqpanic.c b/arch/blackfin/mach-common/irqpanic.c
deleted file mode 100644
index c6496249e2bc..000000000000
--- a/arch/blackfin/mach-common/irqpanic.c
+++ /dev/null
@@ -1,106 +0,0 @@
1/*
2 * panic kernel with dump information
3 *
4 * Copyright 2005-2009 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel_stat.h>
11#include <linux/sched.h>
12#include <asm/blackfin.h>
13
14#define L1_ICACHE_START 0xffa10000
15#define L1_ICACHE_END 0xffa13fff
16
17/*
18 * irq_panic - calls panic with string setup
19 */
20__attribute__ ((l1_text))
21asmlinkage void irq_panic(int reason, struct pt_regs *regs)
22{
23 unsigned int cmd, tag, ca, cache_hi, cache_lo, *pa;
24 unsigned short i, j, die;
25 unsigned int bad[10][6];
26
27 /* check entire cache for coherency
28 * Since printk is in cacheable memory,
29 * don't call it until you have checked everything
30 */
31
32 die = 0;
33 i = 0;
34
35 /* check icache */
36
37 for (ca = L1_ICACHE_START; ca <= L1_ICACHE_END && i < 10; ca += 32) {
38
39 /* Grab various address bits for the itest_cmd fields */
40 cmd = (((ca & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
41 ((ca & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
42 ((ca & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
43 0); /* Access Tag, Read access */
44
45 SSYNC();
46 bfin_write_ITEST_COMMAND(cmd);
47 SSYNC();
48 tag = bfin_read_ITEST_DATA0();
49 SSYNC();
50
51 /* if tag is marked as valid, check it */
52 if (tag & 1) {
53 /* The icache is arranged in 4 groups of 64-bits */
54 for (j = 0; j < 32; j += 8) {
55 cmd = ((((ca + j) & 0x3000) << 4) | /* ca[13:12] for SBNK[1:0] */
56 (((ca + j) & 0x0c00) << 16) | /* ca[11:10] for WAYSEL[1:0] */
57 (((ca + j) & 0x3f8)) | /* ca[09:03] for SET[4:0] and DW[1:0] */
58 4); /* Access Data, Read access */
59
60 SSYNC();
61 bfin_write_ITEST_COMMAND(cmd);
62 SSYNC();
63
64 cache_hi = bfin_read_ITEST_DATA1();
65 cache_lo = bfin_read_ITEST_DATA0();
66
67 pa = ((unsigned int *)((tag & 0xffffcc00) |
68 ((ca + j) & ~(0xffffcc00))));
69
70 /*
71 * Debugging this, enable
72 *
73 * printk("addr: %08x %08x%08x | %08x%08x\n",
74 * ((unsigned int *)((tag & 0xffffcc00) | ((ca+j) & ~(0xffffcc00)))),
75 * cache_hi, cache_lo, *(pa+1), *pa);
76 */
77
78 if (cache_hi != *(pa + 1) || cache_lo != *pa) {
79 /* Since icache is not working, stay out of it, by not printing */
80 die = 1;
81 bad[i][0] = (ca + j);
82 bad[i][1] = cache_hi;
83 bad[i][2] = cache_lo;
84 bad[i][3] = ((tag & 0xffffcc00) |
85 ((ca + j) & ~(0xffffcc00)));
86 bad[i][4] = *(pa + 1);
87 bad[i][5] = *(pa);
88 i++;
89 }
90 }
91 }
92 }
93 if (die) {
94 printk(KERN_EMERG "icache coherency error\n");
95 for (j = 0; j <= i; j++) {
96 printk(KERN_EMERG
97 "cache address : %08x cache value : %08x%08x\n",
98 bad[j][0], bad[j][1], bad[j][2]);
99 printk(KERN_EMERG
100 "physical address: %08x SDRAM value : %08x%08x\n",
101 bad[j][3], bad[j][4], bad[j][5]);
102 }
103 panic("icache coherency error");
104 } else
105 printk(KERN_EMERG "icache checked, and OK\n");
106}
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/Kconfig b/arch/cris/Kconfig
index aefe3b18a074..613e62831c55 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see the Configure script.
4#
5
6mainmenu "Linux/CRIS Kernel Configuration"
7
8config MMU 1config MMU
9 bool 2 bool
10 default y 3 default y
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-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c
index e70c804e9377..320065f3cbe5 100644
--- a/arch/cris/arch-v10/kernel/ptrace.c
+++ b/arch/cris/arch-v10/kernel/ptrace.c
@@ -76,9 +76,11 @@ ptrace_disable(struct task_struct *child)
76 * (in user space) where the result of the ptrace call is written (instead of 76 * (in user space) where the result of the ptrace call is written (instead of
77 * being returned). 77 * being returned).
78 */ 78 */
79long arch_ptrace(struct task_struct *child, long request, long addr, long data) 79long arch_ptrace(struct task_struct *child, long request,
80 unsigned long addr, unsigned long data)
80{ 81{
81 int ret; 82 int ret;
83 unsigned int regno = addr >> 2;
82 unsigned long __user *datap = (unsigned long __user *)data; 84 unsigned long __user *datap = (unsigned long __user *)data;
83 85
84 switch (request) { 86 switch (request) {
@@ -93,10 +95,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
93 unsigned long tmp; 95 unsigned long tmp;
94 96
95 ret = -EIO; 97 ret = -EIO;
96 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 98 if ((addr & 3) || regno > PT_MAX)
97 break; 99 break;
98 100
99 tmp = get_reg(child, addr >> 2); 101 tmp = get_reg(child, regno);
100 ret = put_user(tmp, datap); 102 ret = put_user(tmp, datap);
101 break; 103 break;
102 } 104 }
@@ -110,19 +112,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
110 /* Write the word at location address in the USER area. */ 112 /* Write the word at location address in the USER area. */
111 case PTRACE_POKEUSR: 113 case PTRACE_POKEUSR:
112 ret = -EIO; 114 ret = -EIO;
113 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 115 if ((addr & 3) || regno > PT_MAX)
114 break; 116 break;
115 117
116 addr >>= 2; 118 if (regno == PT_DCCR) {
117
118 if (addr == PT_DCCR) {
119 /* don't allow the tracing process to change stuff like 119 /* don't allow the tracing process to change stuff like
120 * interrupt enable, kernel/user bit, dma enables etc. 120 * interrupt enable, kernel/user bit, dma enables etc.
121 */ 121 */
122 data &= DCCR_MASK; 122 data &= DCCR_MASK;
123 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK; 123 data |= get_reg(child, PT_DCCR) & ~DCCR_MASK;
124 } 124 }
125 if (put_reg(child, addr, data)) 125 if (put_reg(child, regno, data))
126 break; 126 break;
127 ret = 0; 127 ret = 0;
128 break; 128 break;
@@ -141,7 +141,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
141 break; 141 break;
142 } 142 }
143 143
144 data += sizeof(long); 144 datap++;
145 } 145 }
146 146
147 break; 147 break;
@@ -165,7 +165,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
165 } 165 }
166 166
167 put_reg(child, i, tmp); 167 put_reg(child, i, tmp);
168 data += sizeof(long); 168 datap++;
169 } 169 }
170 170
171 break; 171 break;
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/arch-v32/kernel/ptrace.c b/arch/cris/arch-v32/kernel/ptrace.c
index f4ebd1e7d0f5..511ece94a574 100644
--- a/arch/cris/arch-v32/kernel/ptrace.c
+++ b/arch/cris/arch-v32/kernel/ptrace.c
@@ -126,9 +126,11 @@ ptrace_disable(struct task_struct *child)
126} 126}
127 127
128 128
129long arch_ptrace(struct task_struct *child, long request, long addr, long data) 129long arch_ptrace(struct task_struct *child, long request,
130 unsigned long addr, unsigned long data)
130{ 131{
131 int ret; 132 int ret;
133 unsigned int regno = addr >> 2;
132 unsigned long __user *datap = (unsigned long __user *)data; 134 unsigned long __user *datap = (unsigned long __user *)data;
133 135
134 switch (request) { 136 switch (request) {
@@ -163,10 +165,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
163 unsigned long tmp; 165 unsigned long tmp;
164 166
165 ret = -EIO; 167 ret = -EIO;
166 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 168 if ((addr & 3) || regno > PT_MAX)
167 break; 169 break;
168 170
169 tmp = get_reg(child, addr >> 2); 171 tmp = get_reg(child, regno);
170 ret = put_user(tmp, datap); 172 ret = put_user(tmp, datap);
171 break; 173 break;
172 } 174 }
@@ -180,19 +182,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
180 /* Write the word at location address in the USER area. */ 182 /* Write the word at location address in the USER area. */
181 case PTRACE_POKEUSR: 183 case PTRACE_POKEUSR:
182 ret = -EIO; 184 ret = -EIO;
183 if ((addr & 3) || addr < 0 || addr > PT_MAX << 2) 185 if ((addr & 3) || regno > PT_MAX)
184 break; 186 break;
185 187
186 addr >>= 2; 188 if (regno == PT_CCS) {
187
188 if (addr == PT_CCS) {
189 /* don't allow the tracing process to change stuff like 189 /* don't allow the tracing process to change stuff like
190 * interrupt enable, kernel/user bit, dma enables etc. 190 * interrupt enable, kernel/user bit, dma enables etc.
191 */ 191 */
192 data &= CCS_MASK; 192 data &= CCS_MASK;
193 data |= get_reg(child, PT_CCS) & ~CCS_MASK; 193 data |= get_reg(child, PT_CCS) & ~CCS_MASK;
194 } 194 }
195 if (put_reg(child, addr, data)) 195 if (put_reg(child, regno, data))
196 break; 196 break;
197 ret = 0; 197 ret = 0;
198 break; 198 break;
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/pgtable.h b/arch/cris/include/asm/pgtable.h
index f63d6fccbc6c..9eaae217b21b 100644
--- a/arch/cris/include/asm/pgtable.h
+++ b/arch/cris/include/asm/pgtable.h
@@ -248,10 +248,8 @@ static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long addre
248 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 248 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
249#define pte_offset_map(dir, address) \ 249#define pte_offset_map(dir, address) \
250 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 250 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
251#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
252 251
253#define pte_unmap(pte) do { } while (0) 252#define pte_unmap(pte) do { } while (0)
254#define pte_unmap_nested(pte) do { } while (0)
255#define pte_pfn(x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT) 253#define pte_pfn(x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)
256#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 254#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
257 255
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 0f2417df6323..f6bcb039cd6d 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -1,7 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5config FRV 1config FRV
6 bool 2 bool
7 default y 3 default y
@@ -61,8 +57,6 @@ config HZ
61 int 57 int
62 default 1000 58 default 1000
63 59
64mainmenu "Fujitsu FR-V Kernel Configuration"
65
66source "init/Kconfig" 60source "init/Kconfig"
67 61
68source "kernel/Kconfig.freezer" 62source "kernel/Kconfig.freezer"
diff --git a/arch/frv/include/asm/highmem.h b/arch/frv/include/asm/highmem.h
index cb4c317eaecc..a8d6565d415d 100644
--- a/arch/frv/include/asm/highmem.h
+++ b/arch/frv/include/asm/highmem.h
@@ -112,12 +112,11 @@ extern struct page *kmap_atomic_to_page(void *ptr);
112 (void *) damlr; \ 112 (void *) damlr; \
113}) 113})
114 114
115static inline void *kmap_atomic(struct page *page, enum km_type type) 115static inline void *kmap_atomic_primary(struct page *page, enum km_type type)
116{ 116{
117 unsigned long paddr; 117 unsigned long paddr;
118 118
119 pagefault_disable(); 119 pagefault_disable();
120 debug_kmap_atomic(type);
121 paddr = page_to_phys(page); 120 paddr = page_to_phys(page);
122 121
123 switch (type) { 122 switch (type) {
@@ -125,14 +124,6 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
125 case 1: return __kmap_atomic_primary(1, paddr, 3); 124 case 1: return __kmap_atomic_primary(1, paddr, 3);
126 case 2: return __kmap_atomic_primary(2, paddr, 4); 125 case 2: return __kmap_atomic_primary(2, paddr, 4);
127 case 3: return __kmap_atomic_primary(3, paddr, 5); 126 case 3: return __kmap_atomic_primary(3, paddr, 5);
128 case 4: return __kmap_atomic_primary(4, paddr, 6);
129 case 5: return __kmap_atomic_primary(5, paddr, 7);
130 case 6: return __kmap_atomic_primary(6, paddr, 8);
131 case 7: return __kmap_atomic_primary(7, paddr, 9);
132 case 8: return __kmap_atomic_primary(8, paddr, 10);
133
134 case 9 ... 9 + NR_TLB_LINES - 1:
135 return __kmap_atomic_secondary(type - 9, paddr);
136 127
137 default: 128 default:
138 BUG(); 129 BUG();
@@ -152,22 +143,13 @@ do { \
152 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \ 143 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr) : "memory"); \
153} while(0) 144} while(0)
154 145
155static inline void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 146static inline void kunmap_atomic_primary(void *kvaddr, enum km_type type)
156{ 147{
157 switch (type) { 148 switch (type) {
158 case 0: __kunmap_atomic_primary(0, 2); break; 149 case 0: __kunmap_atomic_primary(0, 2); break;
159 case 1: __kunmap_atomic_primary(1, 3); break; 150 case 1: __kunmap_atomic_primary(1, 3); break;
160 case 2: __kunmap_atomic_primary(2, 4); break; 151 case 2: __kunmap_atomic_primary(2, 4); break;
161 case 3: __kunmap_atomic_primary(3, 5); break; 152 case 3: __kunmap_atomic_primary(3, 5); break;
162 case 4: __kunmap_atomic_primary(4, 6); break;
163 case 5: __kunmap_atomic_primary(5, 7); break;
164 case 6: __kunmap_atomic_primary(6, 8); break;
165 case 7: __kunmap_atomic_primary(7, 9); break;
166 case 8: __kunmap_atomic_primary(8, 10); break;
167
168 case 9 ... 9 + NR_TLB_LINES - 1:
169 __kunmap_atomic_secondary(type - 9, kvaddr);
170 break;
171 153
172 default: 154 default:
173 BUG(); 155 BUG();
@@ -175,6 +157,9 @@ static inline void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type)
175 pagefault_enable(); 157 pagefault_enable();
176} 158}
177 159
160void *__kmap_atomic(struct page *page);
161void __kunmap_atomic(void *kvaddr);
162
178#endif /* !__ASSEMBLY__ */ 163#endif /* !__ASSEMBLY__ */
179 164
180#endif /* __KERNEL__ */ 165#endif /* __KERNEL__ */
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/pgtable.h b/arch/frv/include/asm/pgtable.h
index c18b0d32e636..6bc241e4b4f8 100644
--- a/arch/frv/include/asm/pgtable.h
+++ b/arch/frv/include/asm/pgtable.h
@@ -451,17 +451,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
451 451
452#if defined(CONFIG_HIGHPTE) 452#if defined(CONFIG_HIGHPTE)
453#define pte_offset_map(dir, address) \ 453#define pte_offset_map(dir, address) \
454 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) 454 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + pte_index(address))
455#define pte_offset_map_nested(dir, address) \ 455#define pte_unmap(pte) kunmap_atomic(pte)
456 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE1) + pte_index(address))
457#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
458#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
459#else 456#else
460#define pte_offset_map(dir, address) \ 457#define pte_offset_map(dir, address) \
461 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) 458 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
462#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
463#define pte_unmap(pte) do { } while (0) 459#define pte_unmap(pte) do { } while (0)
464#define pte_unmap_nested(pte) do { } while (0)
465#endif 460#endif
466 461
467/* 462/*
diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c
index fac028936a04..9d68f7fac730 100644
--- a/arch/frv/kernel/ptrace.c
+++ b/arch/frv/kernel/ptrace.c
@@ -254,23 +254,26 @@ void ptrace_disable(struct task_struct *child)
254 user_disable_single_step(child); 254 user_disable_single_step(child);
255} 255}
256 256
257long arch_ptrace(struct task_struct *child, long request, long addr, long data) 257long arch_ptrace(struct task_struct *child, long request,
258 unsigned long addr, unsigned long data)
258{ 259{
259 unsigned long tmp; 260 unsigned long tmp;
260 int ret; 261 int ret;
262 int regno = addr >> 2;
263 unsigned long __user *datap = (unsigned long __user *) data;
261 264
262 switch (request) { 265 switch (request) {
263 /* read the word at location addr in the USER area. */ 266 /* read the word at location addr in the USER area. */
264 case PTRACE_PEEKUSR: { 267 case PTRACE_PEEKUSR: {
265 tmp = 0; 268 tmp = 0;
266 ret = -EIO; 269 ret = -EIO;
267 if ((addr & 3) || addr < 0) 270 if (addr & 3)
268 break; 271 break;
269 272
270 ret = 0; 273 ret = 0;
271 switch (addr >> 2) { 274 switch (regno) {
272 case 0 ... PT__END - 1: 275 case 0 ... PT__END - 1:
273 tmp = get_reg(child, addr >> 2); 276 tmp = get_reg(child, regno);
274 break; 277 break;
275 278
276 case PT__END + 0: 279 case PT__END + 0:
@@ -299,23 +302,18 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
299 } 302 }
300 303
301 if (ret == 0) 304 if (ret == 0)
302 ret = put_user(tmp, (unsigned long *) data); 305 ret = put_user(tmp, datap);
303 break; 306 break;
304 } 307 }
305 308
306 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 309 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
307 ret = -EIO; 310 ret = -EIO;
308 if ((addr & 3) || addr < 0) 311 if (addr & 3)
309 break; 312 break;
310 313
311 ret = 0; 314 switch (regno) {
312 switch (addr >> 2) {
313 case 0 ... PT__END - 1: 315 case 0 ... PT__END - 1:
314 ret = put_reg(child, addr >> 2, data); 316 ret = put_reg(child, regno, data);
315 break;
316
317 default:
318 ret = -EIO;
319 break; 317 break;
320 } 318 }
321 break; 319 break;
@@ -324,25 +322,25 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
324 return copy_regset_to_user(child, &user_frv_native_view, 322 return copy_regset_to_user(child, &user_frv_native_view,
325 REGSET_GENERAL, 323 REGSET_GENERAL,
326 0, sizeof(child->thread.user->i), 324 0, sizeof(child->thread.user->i),
327 (void __user *)data); 325 datap);
328 326
329 case PTRACE_SETREGS: /* Set all integer regs in the child. */ 327 case PTRACE_SETREGS: /* Set all integer regs in the child. */
330 return copy_regset_from_user(child, &user_frv_native_view, 328 return copy_regset_from_user(child, &user_frv_native_view,
331 REGSET_GENERAL, 329 REGSET_GENERAL,
332 0, sizeof(child->thread.user->i), 330 0, sizeof(child->thread.user->i),
333 (const void __user *)data); 331 datap);
334 332
335 case PTRACE_GETFPREGS: /* Get the child FP/Media state. */ 333 case PTRACE_GETFPREGS: /* Get the child FP/Media state. */
336 return copy_regset_to_user(child, &user_frv_native_view, 334 return copy_regset_to_user(child, &user_frv_native_view,
337 REGSET_FPMEDIA, 335 REGSET_FPMEDIA,
338 0, sizeof(child->thread.user->f), 336 0, sizeof(child->thread.user->f),
339 (void __user *)data); 337 datap);
340 338
341 case PTRACE_SETFPREGS: /* Set the child FP/Media state. */ 339 case PTRACE_SETFPREGS: /* Set the child FP/Media state. */
342 return copy_regset_from_user(child, &user_frv_native_view, 340 return copy_regset_from_user(child, &user_frv_native_view,
343 REGSET_FPMEDIA, 341 REGSET_FPMEDIA,
344 0, sizeof(child->thread.user->f), 342 0, sizeof(child->thread.user->f),
345 (const void __user *)data); 343 datap);
346 344
347 default: 345 default:
348 ret = ptrace_request(child, request, addr, data); 346 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index 85d110b71cf7..41098a3803a2 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -61,14 +61,14 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
61 dampr2 = __get_DAMPR(2); 61 dampr2 = __get_DAMPR(2);
62 62
63 for (i = 0; i < nents; i++) { 63 for (i = 0; i < nents; i++) {
64 vaddr = kmap_atomic(sg_page(&sg[i]), __KM_CACHE); 64 vaddr = kmap_atomic_primary(sg_page(&sg[i]), __KM_CACHE);
65 65
66 frv_dcache_writeback((unsigned long) vaddr, 66 frv_dcache_writeback((unsigned long) vaddr,
67 (unsigned long) vaddr + PAGE_SIZE); 67 (unsigned long) vaddr + PAGE_SIZE);
68 68
69 } 69 }
70 70
71 kunmap_atomic(vaddr, __KM_CACHE); 71 kunmap_atomic_primary(vaddr, __KM_CACHE);
72 if (dampr2) { 72 if (dampr2) {
73 __set_DAMPR(2, dampr2); 73 __set_DAMPR(2, dampr2);
74 __set_IAMPR(2, dampr2); 74 __set_IAMPR(2, dampr2);
diff --git a/arch/frv/mm/cache-page.c b/arch/frv/mm/cache-page.c
index 0261cbe153b5..b24ade27a0f0 100644
--- a/arch/frv/mm/cache-page.c
+++ b/arch/frv/mm/cache-page.c
@@ -26,11 +26,11 @@ void flush_dcache_page(struct page *page)
26 26
27 dampr2 = __get_DAMPR(2); 27 dampr2 = __get_DAMPR(2);
28 28
29 vaddr = kmap_atomic(page, __KM_CACHE); 29 vaddr = kmap_atomic_primary(page, __KM_CACHE);
30 30
31 frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE); 31 frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
32 32
33 kunmap_atomic(vaddr, __KM_CACHE); 33 kunmap_atomic_primary(vaddr, __KM_CACHE);
34 34
35 if (dampr2) { 35 if (dampr2) {
36 __set_DAMPR(2, dampr2); 36 __set_DAMPR(2, dampr2);
@@ -54,12 +54,12 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
54 54
55 dampr2 = __get_DAMPR(2); 55 dampr2 = __get_DAMPR(2);
56 56
57 vaddr = kmap_atomic(page, __KM_CACHE); 57 vaddr = kmap_atomic_primary(page, __KM_CACHE);
58 58
59 start = (start & ~PAGE_MASK) | (unsigned long) vaddr; 59 start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
60 frv_cache_wback_inv(start, start + len); 60 frv_cache_wback_inv(start, start + len);
61 61
62 kunmap_atomic(vaddr, __KM_CACHE); 62 kunmap_atomic_primary(vaddr, __KM_CACHE);
63 63
64 if (dampr2) { 64 if (dampr2) {
65 __set_DAMPR(2, dampr2); 65 __set_DAMPR(2, dampr2);
diff --git a/arch/frv/mm/highmem.c b/arch/frv/mm/highmem.c
index eadd07658075..fd7fcd4c2e33 100644
--- a/arch/frv/mm/highmem.c
+++ b/arch/frv/mm/highmem.c
@@ -36,3 +36,54 @@ struct page *kmap_atomic_to_page(void *ptr)
36{ 36{
37 return virt_to_page(ptr); 37 return virt_to_page(ptr);
38} 38}
39
40void *__kmap_atomic(struct page *page)
41{
42 unsigned long paddr;
43 int type;
44
45 pagefault_disable();
46 type = kmap_atomic_idx_push();
47 paddr = page_to_phys(page);
48
49 switch (type) {
50 /*
51 * The first 4 primary maps are reserved for architecture code
52 */
53 case 0: return __kmap_atomic_primary(4, paddr, 6);
54 case 1: return __kmap_atomic_primary(5, paddr, 7);
55 case 2: return __kmap_atomic_primary(6, paddr, 8);
56 case 3: return __kmap_atomic_primary(7, paddr, 9);
57 case 4: return __kmap_atomic_primary(8, paddr, 10);
58
59 case 5 ... 5 + NR_TLB_LINES - 1:
60 return __kmap_atomic_secondary(type - 5, paddr);
61
62 default:
63 BUG();
64 return NULL;
65 }
66}
67EXPORT_SYMBOL(__kmap_atomic);
68
69void __kunmap_atomic(void *kvaddr)
70{
71 int type = kmap_atomic_idx();
72 switch (type) {
73 case 0: __kunmap_atomic_primary(4, 6); break;
74 case 1: __kunmap_atomic_primary(5, 7); break;
75 case 2: __kunmap_atomic_primary(6, 8); break;
76 case 3: __kunmap_atomic_primary(7, 9); break;
77 case 4: __kunmap_atomic_primary(8, 10); break;
78
79 case 5 ... 5 + NR_TLB_LINES - 1:
80 __kunmap_atomic_secondary(type - 5, kvaddr);
81 break;
82
83 default:
84 BUG();
85 }
86 kmap_atomic_idx_pop();
87 pagefault_enable();
88}
89EXPORT_SYMBOL(__kunmap_atomic);
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 988b6ff34cc4..65f897d8c1e9 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "uClinux/h8300 (w/o MMU) Kernel Configuration"
7
8config H8300 1config H8300
9 bool 2 bool
10 default y 3 default y
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/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
index df114122ebdf..497fa89b5df4 100644
--- a/arch/h8300/kernel/ptrace.c
+++ b/arch/h8300/kernel/ptrace.c
@@ -50,27 +50,29 @@ void ptrace_disable(struct task_struct *child)
50 user_disable_single_step(child); 50 user_disable_single_step(child);
51} 51}
52 52
53long arch_ptrace(struct task_struct *child, long request, long addr, long data) 53long arch_ptrace(struct task_struct *child, long request,
54 unsigned long addr, unsigned long data)
54{ 55{
55 int ret; 56 int ret;
57 int regno = addr >> 2;
58 unsigned long __user *datap = (unsigned long __user *) data;
56 59
57 switch (request) { 60 switch (request) {
58 /* read the word at location addr in the USER area. */ 61 /* read the word at location addr in the USER area. */
59 case PTRACE_PEEKUSR: { 62 case PTRACE_PEEKUSR: {
60 unsigned long tmp = 0; 63 unsigned long tmp = 0;
61 64
62 if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) { 65 if ((addr & 3) || addr >= sizeof(struct user)) {
63 ret = -EIO; 66 ret = -EIO;
64 break ; 67 break ;
65 } 68 }
66 69
67 ret = 0; /* Default return condition */ 70 ret = 0; /* Default return condition */
68 addr = addr >> 2; /* temporary hack. */
69 71
70 if (addr < H8300_REGS_NO) 72 if (regno < H8300_REGS_NO)
71 tmp = h8300_get_reg(child, addr); 73 tmp = h8300_get_reg(child, regno);
72 else { 74 else {
73 switch(addr) { 75 switch (regno) {
74 case 49: 76 case 49:
75 tmp = child->mm->start_code; 77 tmp = child->mm->start_code;
76 break ; 78 break ;
@@ -88,24 +90,23 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
88 } 90 }
89 } 91 }
90 if (!ret) 92 if (!ret)
91 ret = put_user(tmp,(unsigned long *) data); 93 ret = put_user(tmp, datap);
92 break ; 94 break ;
93 } 95 }
94 96
95 /* when I and D space are separate, this will have to be fixed. */ 97 /* when I and D space are separate, this will have to be fixed. */
96 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 98 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
97 if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) { 99 if ((addr & 3) || addr >= sizeof(struct user)) {
98 ret = -EIO; 100 ret = -EIO;
99 break ; 101 break ;
100 } 102 }
101 addr = addr >> 2; /* temporary hack. */
102 103
103 if (addr == PT_ORIG_ER0) { 104 if (regno == PT_ORIG_ER0) {
104 ret = -EIO; 105 ret = -EIO;
105 break ; 106 break ;
106 } 107 }
107 if (addr < H8300_REGS_NO) { 108 if (regno < H8300_REGS_NO) {
108 ret = h8300_put_reg(child, addr, data); 109 ret = h8300_put_reg(child, regno, data);
109 break ; 110 break ;
110 } 111 }
111 ret = -EIO; 112 ret = -EIO;
@@ -116,11 +117,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
116 unsigned long tmp; 117 unsigned long tmp;
117 for (i = 0; i < H8300_REGS_NO; i++) { 118 for (i = 0; i < H8300_REGS_NO; i++) {
118 tmp = h8300_get_reg(child, i); 119 tmp = h8300_get_reg(child, i);
119 if (put_user(tmp, (unsigned long *) data)) { 120 if (put_user(tmp, datap)) {
120 ret = -EFAULT; 121 ret = -EFAULT;
121 break; 122 break;
122 } 123 }
123 data += sizeof(long); 124 datap++;
124 } 125 }
125 ret = 0; 126 ret = 0;
126 break; 127 break;
@@ -130,12 +131,12 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
130 int i; 131 int i;
131 unsigned long tmp; 132 unsigned long tmp;
132 for (i = 0; i < H8300_REGS_NO; i++) { 133 for (i = 0; i < H8300_REGS_NO; i++) {
133 if (get_user(tmp, (unsigned long *) data)) { 134 if (get_user(tmp, datap)) {
134 ret = -EFAULT; 135 ret = -EFAULT;
135 break; 136 break;
136 } 137 }
137 h8300_put_reg(child, i, tmp); 138 h8300_put_reg(child, i, tmp);
138 data += sizeof(long); 139 datap++;
139 } 140 }
140 ret = 0; 141 ret = 0;
141 break; 142 break;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 7c82fa1fc911..e0f5b6d7f849 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "IA-64 Linux Kernel Configuration"
7
8source "init/Kconfig" 1source "init/Kconfig"
9 2
10source "kernel/Kconfig.freezer" 3source "kernel/Kconfig.freezer"
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/cputime.h b/arch/ia64/include/asm/cputime.h
index 7fa8a8594660..6073b187528a 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -56,10 +56,10 @@ typedef u64 cputime64_t;
56#define jiffies64_to_cputime64(__jif) ((__jif) * (NSEC_PER_SEC / HZ)) 56#define jiffies64_to_cputime64(__jif) ((__jif) * (NSEC_PER_SEC / HZ))
57 57
58/* 58/*
59 * Convert cputime <-> milliseconds 59 * Convert cputime <-> microseconds
60 */ 60 */
61#define cputime_to_msecs(__ct) ((__ct) / NSEC_PER_MSEC) 61#define cputime_to_usecs(__ct) ((__ct) / NSEC_PER_USEC)
62#define msecs_to_cputime(__msecs) ((__msecs) * NSEC_PER_MSEC) 62#define usecs_to_cputime(__usecs) ((__usecs) * NSEC_PER_USEC)
63 63
64/* 64/*
65 * Convert cputime <-> seconds 65 * Convert cputime <-> seconds
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/pgtable.h b/arch/ia64/include/asm/pgtable.h
index c3286f42e501..1a97af31ef17 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -406,9 +406,7 @@ pgd_offset (const struct mm_struct *mm, unsigned long address)
406#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 406#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
407#define pte_offset_kernel(dir,addr) ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr)) 407#define pte_offset_kernel(dir,addr) ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
408#define pte_offset_map(dir,addr) pte_offset_kernel(dir, addr) 408#define pte_offset_map(dir,addr) pte_offset_kernel(dir, addr)
409#define pte_offset_map_nested(dir,addr) pte_offset_map(dir, addr)
410#define pte_unmap(pte) do { } while (0) 409#define pte_unmap(pte) do { } while (0)
411#define pte_unmap_nested(pte) do { } while (0)
412 410
413/* atomic versions of the some PTE manipulations: */ 411/* atomic versions of the some PTE manipulations: */
414 412
diff --git a/arch/ia64/include/asm/siginfo.h b/arch/ia64/include/asm/siginfo.h
index 118d42979003..c8fcaa2ac48f 100644
--- a/arch/ia64/include/asm/siginfo.h
+++ b/arch/ia64/include/asm/siginfo.h
@@ -62,6 +62,7 @@ typedef struct siginfo {
62 int _imm; /* immediate value for "break" */ 62 int _imm; /* immediate value for "break" */
63 unsigned int _flags; /* see below */ 63 unsigned int _flags; /* see below */
64 unsigned long _isr; /* isr */ 64 unsigned long _isr; /* isr */
65 short _addr_lsb; /* lsb of faulting address */
65 } _sigfault; 66 } _sigfault;
66 67
67 /* SIGPOLL */ 68 /* SIGPOLL */
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 6b1852f7f972..39e534f5a3b0 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -618,16 +618,15 @@ pfm_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
618} 618}
619 619
620 620
621static int 621static struct dentry *
622pfmfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, 622pfmfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
623 struct vfsmount *mnt)
624{ 623{
625 return get_sb_pseudo(fs_type, "pfm:", NULL, PFMFS_MAGIC, mnt); 624 return mount_pseudo(fs_type, "pfm:", NULL, PFMFS_MAGIC);
626} 625}
627 626
628static struct file_system_type pfm_fs_type = { 627static struct file_system_type pfm_fs_type = {
629 .name = "pfmfs", 628 .name = "pfmfs",
630 .get_sb = pfmfs_get_sb, 629 .mount = pfmfs_mount,
631 .kill_sb = kill_anon_super, 630 .kill_sb = kill_anon_super,
632}; 631};
633 632
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 7c7909f9bc93..8848f43d819e 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -1177,7 +1177,8 @@ ptrace_disable (struct task_struct *child)
1177} 1177}
1178 1178
1179long 1179long
1180arch_ptrace (struct task_struct *child, long request, long addr, long data) 1180arch_ptrace (struct task_struct *child, long request,
1181 unsigned long addr, unsigned long data)
1181{ 1182{
1182 switch (request) { 1183 switch (request) {
1183 case PTRACE_PEEKTEXT: 1184 case PTRACE_PEEKTEXT:
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 45d7543b69cc..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
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/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/m32r/Kconfig b/arch/m32r/Kconfig
index 836abbbc9c04..5c291d65196b 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux/M32R Kernel Configuration"
7
8config M32R 1config M32R
9 bool 2 bool
10 default y 3 default y
@@ -315,7 +308,7 @@ config SMP
315 Management" code will be disabled if you say Y here. 308 Management" code will be disabled if you say Y here.
316 309
317 See also the SMP-HOWTO available at 310 See also the SMP-HOWTO available at
318 <http://www.linuxdoc.org/docs.html#howto>. 311 <http://tldp.org/HOWTO/SMP-HOWTO.html>.
319 312
320 If you don't know what to do here, say N. 313 If you don't know what to do here, say N.
321 314
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/pgtable.h b/arch/m32r/include/asm/pgtable.h
index e6359c566b50..8a28cfea2729 100644
--- a/arch/m32r/include/asm/pgtable.h
+++ b/arch/m32r/include/asm/pgtable.h
@@ -332,9 +332,7 @@ static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
332 ((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address)) 332 ((pte_t *)pmd_page_vaddr(*(dir)) + pte_index(address))
333#define pte_offset_map(dir, address) \ 333#define pte_offset_map(dir, address) \
334 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) 334 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
335#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
336#define pte_unmap(pte) do { } while (0) 335#define pte_unmap(pte) do { } while (0)
337#define pte_unmap_nested(pte) do { } while (0)
338 336
339/* Encode and de-code a swap entry */ 337/* Encode and de-code a swap entry */
340#define __swp_type(x) (((x).val >> 2) & 0x1f) 338#define __swp_type(x) (((x).val >> 2) & 0x1f)
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index 0021ade4cba8..20743754f2b2 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -622,9 +622,11 @@ void ptrace_disable(struct task_struct *child)
622} 622}
623 623
624long 624long
625arch_ptrace(struct task_struct *child, long request, long addr, long data) 625arch_ptrace(struct task_struct *child, long request,
626 unsigned long addr, unsigned long data)
626{ 627{
627 int ret; 628 int ret;
629 unsigned long __user *datap = (unsigned long __user *) data;
628 630
629 switch (request) { 631 switch (request) {
630 /* 632 /*
@@ -639,8 +641,7 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data)
639 * read the word at location addr in the USER area. 641 * read the word at location addr in the USER area.
640 */ 642 */
641 case PTRACE_PEEKUSR: 643 case PTRACE_PEEKUSR:
642 ret = ptrace_read_user(child, addr, 644 ret = ptrace_read_user(child, addr, datap);
643 (unsigned long __user *)data);
644 break; 645 break;
645 646
646 /* 647 /*
@@ -661,11 +662,11 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data)
661 break; 662 break;
662 663
663 case PTRACE_GETREGS: 664 case PTRACE_GETREGS:
664 ret = ptrace_getregs(child, (void __user *)data); 665 ret = ptrace_getregs(child, datap);
665 break; 666 break;
666 667
667 case PTRACE_SETREGS: 668 case PTRACE_SETREGS:
668 ret = ptrace_setregs(child, (void __user *)data); 669 ret = ptrace_setregs(child, datap);
669 break; 670 break;
670 671
671 default: 672 default:
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 8030e2481d97..bc9271b85759 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -1,7 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5config M68K 1config M68K
6 bool 2 bool
7 default y 3 default y
@@ -62,8 +58,6 @@ config HZ
62config ARCH_USES_GETTIMEOFFSET 58config ARCH_USES_GETTIMEOFFSET
63 def_bool y 59 def_bool y
64 60
65mainmenu "Linux/68k Kernel Configuration"
66
67source "init/Kconfig" 61source "init/Kconfig"
68 62
69source "kernel/Kconfig.freezer" 63source "kernel/Kconfig.freezer"
@@ -434,7 +428,7 @@ config PROC_HARDWARE
434 428
435config ISA 429config ISA
436 bool 430 bool
437 depends on Q40 || AMIGA_PCMCIA || GG2 431 depends on Q40 || AMIGA_PCMCIA
438 default y 432 default y
439 help 433 help
440 Find out whether you have ISA slots on your motherboard. ISA is the 434 Find out whether you have ISA slots on your motherboard. ISA is the
@@ -445,7 +439,7 @@ config ISA
445 439
446config GENERIC_ISA_DMA 440config GENERIC_ISA_DMA
447 bool 441 bool
448 depends on Q40 || AMIGA_PCMCIA || GG2 442 depends on Q40 || AMIGA_PCMCIA
449 default y 443 default y
450 444
451config ZONE_DMA 445config 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..73b8c8fbed9c 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':
@@ -47,14 +50,6 @@
47 50
48LFLUSH_I_AND_D = 0x00000808 51LFLUSH_I_AND_D = 0x00000808
49 52
50/* process bits for task_struct.ptrace */
51PT_TRACESYS_OFF = 3
52PT_TRACESYS_BIT = 1
53PT_PTRACED_OFF = 3
54PT_PTRACED_BIT = 0
55PT_DTRACE_OFF = 3
56PT_DTRACE_BIT = 2
57
58#define SAVE_ALL_INT save_all_int 53#define SAVE_ALL_INT save_all_int
59#define SAVE_ALL_SYS save_all_sys 54#define SAVE_ALL_SYS save_all_sys
60#define RESTORE_ALL restore_all 55#define RESTORE_ALL restore_all
diff --git a/arch/m68k/include/asm/entry_no.h b/arch/m68k/include/asm/entry_no.h
index 80e41492aa2a..26be277394f9 100644
--- a/arch/m68k/include/asm/entry_no.h
+++ b/arch/m68k/include/asm/entry_no.h
@@ -32,16 +32,6 @@
32 32
33#ifdef __ASSEMBLY__ 33#ifdef __ASSEMBLY__
34 34
35/* process bits for task_struct.flags */
36PF_TRACESYS_OFF = 3
37PF_TRACESYS_BIT = 5
38PF_PTRACED_OFF = 3
39PF_PTRACED_BIT = 4
40PF_DTRACE_OFF = 1
41PF_DTRACE_BIT = 5
42
43LENOSYS = 38
44
45#define SWITCH_STACK_SIZE (6*4+4) /* Includes return address */ 35#define SWITCH_STACK_SIZE (6*4+4) /* Includes return address */
46 36
47/* 37/*
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
index 4a5b284a1550..7ef4115b8c4a 100644
--- a/arch/m68k/include/asm/irqflags.h
+++ b/arch/m68k/include/asm/irqflags.h
@@ -2,7 +2,9 @@
2#define _M68K_IRQFLAGS_H 2#define _M68K_IRQFLAGS_H
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#ifdef CONFIG_MMU
5#include <linux/hardirq.h> 6#include <linux/hardirq.h>
7#endif
6#include <linux/preempt.h> 8#include <linux/preempt.h>
7#include <asm/thread_info.h> 9#include <asm/thread_info.h>
8#include <asm/entry.h> 10#include <asm/entry.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..415d5484916c 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -1,5 +1,45 @@
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);
43extern void do_IRQ(int irq, struct pt_regs *fp);
44
45#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/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h
index 8e9a8a754dde..45bd3f589bf0 100644
--- a/arch/m68k/include/asm/motorola_pgtable.h
+++ b/arch/m68k/include/asm/motorola_pgtable.h
@@ -221,9 +221,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmdp, unsigned long address)
221} 221}
222 222
223#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) 223#define pte_offset_map(pmdp,address) ((pte_t *)__pmd_page(*pmdp) + (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
224#define pte_offset_map_nested(pmdp, address) pte_offset_map(pmdp, address)
225#define pte_unmap(pte) ((void)0) 224#define pte_unmap(pte) ((void)0)
226#define pte_unmap_nested(pte) ((void)0)
227 225
228/* 226/*
229 * Allocate and free page tables. The xxx_kernel() versions are 227 * Allocate and free page tables. The xxx_kernel() versions are
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/sun3_pgtable.h b/arch/m68k/include/asm/sun3_pgtable.h
index f847ec732d62..cf5fad9b5250 100644
--- a/arch/m68k/include/asm/sun3_pgtable.h
+++ b/arch/m68k/include/asm/sun3_pgtable.h
@@ -219,9 +219,7 @@ static inline pte_t pgoff_to_pte(unsigned off)
219#define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address)) 219#define pte_offset_kernel(pmd, address) ((pte_t *) __pmd_page(*pmd) + pte_index(address))
220/* FIXME: should we bother with kmap() here? */ 220/* FIXME: should we bother with kmap() here? */
221#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address)) 221#define pte_offset_map(pmd, address) ((pte_t *)kmap(pmd_page(*pmd)) + pte_index(address))
222#define pte_offset_map_nested(pmd, address) pte_offset_map(pmd, address)
223#define pte_unmap(pte) kunmap(pte) 222#define pte_unmap(pte) kunmap(pte)
224#define pte_unmap_nested(pte) kunmap(pte)
225 223
226/* Macros to (de)construct the fake PTEs representing swap pages. */ 224/* Macros to (de)construct the fake PTEs representing swap pages. */
227#define __swp_type(x) ((x).val & 0x7F) 225#define __swp_type(x) ((x).val & 0x7F)
diff --git a/arch/m68k/include/asm/system_mm.h b/arch/m68k/include/asm/system_mm.h
index 12053c44cccf..47b01f4726bc 100644
--- a/arch/m68k/include/asm/system_mm.h
+++ b/arch/m68k/include/asm/system_mm.h
@@ -182,9 +182,7 @@ static inline unsigned long __cmpxchg(volatile void *p, unsigned long old,
182 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ 182 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
183 (unsigned long)(n), sizeof(*(ptr)))) 183 (unsigned long)(n), sizeof(*(ptr))))
184 184
185#ifndef CONFIG_SMP
186#include <asm-generic/cmpxchg.h> 185#include <asm-generic/cmpxchg.h>
187#endif
188 186
189#endif 187#endif
190 188
diff --git a/arch/m68k/include/asm/system_no.h b/arch/m68k/include/asm/system_no.h
index 20126c09794e..6fe9f93bc3ff 100644
--- a/arch/m68k/include/asm/system_no.h
+++ b/arch/m68k/include/asm/system_no.h
@@ -59,17 +59,10 @@ asmlinkage void resume(void);
59#define wmb() asm volatile ("" : : :"memory") 59#define wmb() asm volatile ("" : : :"memory")
60#define set_mb(var, value) ({ (var) = (value); wmb(); }) 60#define set_mb(var, value) ({ (var) = (value); wmb(); })
61 61
62#ifdef CONFIG_SMP
63#define smp_mb() mb()
64#define smp_rmb() rmb()
65#define smp_wmb() wmb()
66#define smp_read_barrier_depends() read_barrier_depends()
67#else
68#define smp_mb() barrier() 62#define smp_mb() barrier()
69#define smp_rmb() barrier() 63#define smp_rmb() barrier()
70#define smp_wmb() barrier() 64#define smp_wmb() barrier()
71#define smp_read_barrier_depends() do { } while(0) 65#define smp_read_barrier_depends() do { } while(0)
72#endif
73 66
74#define read_barrier_depends() ((void)0) 67#define read_barrier_depends() ((void)0)
75 68
@@ -152,9 +145,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
152 (unsigned long)(n), sizeof(*(ptr)))) 145 (unsigned long)(n), sizeof(*(ptr))))
153#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))
154 147
155#ifndef CONFIG_SMP
156#include <asm-generic/cmpxchg.h> 148#include <asm-generic/cmpxchg.h>
157#endif
158 149
159#define arch_align_stack(x) (x) 150#define arch_align_stack(x) (x)
160 151
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/ptrace.c b/arch/m68k/kernel/ptrace.c
index 616e59752c29..0b252683cefb 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -156,55 +156,57 @@ void user_disable_single_step(struct task_struct *child)
156 singlestep_disable(child); 156 singlestep_disable(child);
157} 157}
158 158
159long arch_ptrace(struct task_struct *child, long request, long addr, long data) 159long arch_ptrace(struct task_struct *child, long request,
160 unsigned long addr, unsigned long data)
160{ 161{
161 unsigned long tmp; 162 unsigned long tmp;
162 int i, ret = 0; 163 int i, ret = 0;
164 int regno = addr >> 2; /* temporary hack. */
165 unsigned long __user *datap = (unsigned long __user *) data;
163 166
164 switch (request) { 167 switch (request) {
165 /* read the word at location addr in the USER area. */ 168 /* read the word at location addr in the USER area. */
166 case PTRACE_PEEKUSR: 169 case PTRACE_PEEKUSR:
167 if (addr & 3) 170 if (addr & 3)
168 goto out_eio; 171 goto out_eio;
169 addr >>= 2; /* temporary hack. */
170 172
171 if (addr >= 0 && addr < 19) { 173 if (regno >= 0 && regno < 19) {
172 tmp = get_reg(child, addr); 174 tmp = get_reg(child, regno);
173 } else if (addr >= 21 && addr < 49) { 175 } else if (regno >= 21 && regno < 49) {
174 tmp = child->thread.fp[addr - 21]; 176 tmp = child->thread.fp[regno - 21];
175 /* Convert internal fpu reg representation 177 /* Convert internal fpu reg representation
176 * into long double format 178 * into long double format
177 */ 179 */
178 if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) 180 if (FPU_IS_EMU && (regno < 45) && !(regno % 3))
179 tmp = ((tmp & 0xffff0000) << 15) | 181 tmp = ((tmp & 0xffff0000) << 15) |
180 ((tmp & 0x0000ffff) << 16); 182 ((tmp & 0x0000ffff) << 16);
181 } else 183 } else
182 goto out_eio; 184 goto out_eio;
183 ret = put_user(tmp, (unsigned long *)data); 185 ret = put_user(tmp, datap);
184 break; 186 break;
185 187
186 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 188 case PTRACE_POKEUSR:
189 /* write the word at location addr in the USER area */
187 if (addr & 3) 190 if (addr & 3)
188 goto out_eio; 191 goto out_eio;
189 addr >>= 2; /* temporary hack. */
190 192
191 if (addr == PT_SR) { 193 if (regno == PT_SR) {
192 data &= SR_MASK; 194 data &= SR_MASK;
193 data |= get_reg(child, PT_SR) & ~SR_MASK; 195 data |= get_reg(child, PT_SR) & ~SR_MASK;
194 } 196 }
195 if (addr >= 0 && addr < 19) { 197 if (regno >= 0 && regno < 19) {
196 if (put_reg(child, addr, data)) 198 if (put_reg(child, regno, data))
197 goto out_eio; 199 goto out_eio;
198 } else if (addr >= 21 && addr < 48) { 200 } else if (regno >= 21 && regno < 48) {
199 /* Convert long double format 201 /* Convert long double format
200 * into internal fpu reg representation 202 * into internal fpu reg representation
201 */ 203 */
202 if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { 204 if (FPU_IS_EMU && (regno < 45) && !(regno % 3)) {
203 data = (unsigned long)data << 15; 205 data <<= 15;
204 data = (data & 0xffff0000) | 206 data = (data & 0xffff0000) |
205 ((data & 0x0000ffff) >> 1); 207 ((data & 0x0000ffff) >> 1);
206 } 208 }
207 child->thread.fp[addr - 21] = data; 209 child->thread.fp[regno - 21] = data;
208 } else 210 } else
209 goto out_eio; 211 goto out_eio;
210 break; 212 break;
@@ -212,16 +214,16 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
212 case PTRACE_GETREGS: /* Get all gp regs from the child. */ 214 case PTRACE_GETREGS: /* Get all gp regs from the child. */
213 for (i = 0; i < 19; i++) { 215 for (i = 0; i < 19; i++) {
214 tmp = get_reg(child, i); 216 tmp = get_reg(child, i);
215 ret = put_user(tmp, (unsigned long *)data); 217 ret = put_user(tmp, datap);
216 if (ret) 218 if (ret)
217 break; 219 break;
218 data += sizeof(long); 220 datap++;
219 } 221 }
220 break; 222 break;
221 223
222 case PTRACE_SETREGS: /* Set all gp regs in the child. */ 224 case PTRACE_SETREGS: /* Set all gp regs in the child. */
223 for (i = 0; i < 19; i++) { 225 for (i = 0; i < 19; i++) {
224 ret = get_user(tmp, (unsigned long *)data); 226 ret = get_user(tmp, datap);
225 if (ret) 227 if (ret)
226 break; 228 break;
227 if (i == PT_SR) { 229 if (i == PT_SR) {
@@ -229,25 +231,24 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
229 tmp |= get_reg(child, PT_SR) & ~SR_MASK; 231 tmp |= get_reg(child, PT_SR) & ~SR_MASK;
230 } 232 }
231 put_reg(child, i, tmp); 233 put_reg(child, i, tmp);
232 data += sizeof(long); 234 datap++;
233 } 235 }
234 break; 236 break;
235 237
236 case PTRACE_GETFPREGS: /* Get the child FPU state. */ 238 case PTRACE_GETFPREGS: /* Get the child FPU state. */
237 if (copy_to_user((void *)data, &child->thread.fp, 239 if (copy_to_user(datap, &child->thread.fp,
238 sizeof(struct user_m68kfp_struct))) 240 sizeof(struct user_m68kfp_struct)))
239 ret = -EFAULT; 241 ret = -EFAULT;
240 break; 242 break;
241 243
242 case PTRACE_SETFPREGS: /* Set the child FPU state. */ 244 case PTRACE_SETFPREGS: /* Set the child FPU state. */
243 if (copy_from_user(&child->thread.fp, (void *)data, 245 if (copy_from_user(&child->thread.fp, datap,
244 sizeof(struct user_m68kfp_struct))) 246 sizeof(struct user_m68kfp_struct)))
245 ret = -EFAULT; 247 ret = -EFAULT;
246 break; 248 break;
247 249
248 case PTRACE_GET_THREAD_AREA: 250 case PTRACE_GET_THREAD_AREA:
249 ret = put_user(task_thread_info(child)->tp_value, 251 ret = put_user(task_thread_info(child)->tp_value, datap);
250 (unsigned long __user *)data);
251 break; 252 break;
252 253
253 default: 254 default:
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 05285d08e547..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 */
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..fa9f746cf4ae 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "uClinux/68k (w/o MMU) Kernel Configuration"
7
8config M68K 1config M68K
9 bool 2 bool
10 default y 3 default y
@@ -59,6 +52,10 @@ config GENERIC_HARDIRQS
59 bool 52 bool
60 default y 53 default y
61 54
55config GENERIC_HARDIRQS_NO__DO_IRQ
56 bool
57 default y
58
62config GENERIC_CALIBRATE_DELAY 59config GENERIC_CALIBRATE_DELAY
63 bool 60 bool
64 default y 61 default y
@@ -171,6 +168,11 @@ config M5407
171 help 168 help
172 Motorola ColdFire 5407 processor support. 169 Motorola ColdFire 5407 processor support.
173 170
171config M548x
172 bool "MCF548x"
173 help
174 Freescale ColdFire 5480/5481/5482/5483/5484/5485 processor support.
175
174endchoice 176endchoice
175 177
176config M527x 178config M527x
@@ -181,7 +183,7 @@ config M527x
181 183
182config COLDFIRE 184config COLDFIRE
183 bool 185 bool
184 depends on (M5206 || M5206e || M520x || M523x || M5249 || M527x || M5272 || M528x || M5307 || M532x || M5407) 186 depends on (M5206 || M5206e || M520x || M523x || M5249 || M527x || M5272 || M528x || M5307 || M532x || M5407 || M548x)
185 select GENERIC_GPIO 187 select GENERIC_GPIO
186 select ARCH_REQUIRE_GPIOLIB 188 select ARCH_REQUIRE_GPIOLIB
187 default y 189 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 24335022fa2c..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 */
@@ -75,11 +69,8 @@ int main(void)
75 DEFINE(PT_PTRACED, PT_PTRACED); 69 DEFINE(PT_PTRACED, PT_PTRACED);
76 70
77 /* Offsets in thread_info structure */ 71 /* Offsets in thread_info structure */
78 DEFINE(TI_TASK, offsetof(struct thread_info, task));
79 DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
80 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); 72 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
81 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count)); 73 DEFINE(TI_PREEMPTCOUNT, offsetof(struct thread_info, preempt_count));
82 DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
83 74
84 return 0; 75 return 0;
85} 76}
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index f6be1248d216..6709fb707335 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>
@@ -111,9 +112,12 @@ void ptrace_disable(struct task_struct *child)
111 user_disable_single_step(child); 112 user_disable_single_step(child);
112} 113}
113 114
114long arch_ptrace(struct task_struct *child, long request, long addr, long data) 115long arch_ptrace(struct task_struct *child, long request,
116 unsigned long addr, unsigned long data)
115{ 117{
116 int ret; 118 int ret;
119 int regno = addr >> 2;
120 unsigned long __user *datap = (unsigned long __user *) data;
117 121
118 switch (request) { 122 switch (request) {
119 /* read the word at location addr in the USER area. */ 123 /* read the word at location addr in the USER area. */
@@ -121,71 +125,48 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
121 unsigned long tmp; 125 unsigned long tmp;
122 126
123 ret = -EIO; 127 ret = -EIO;
124 if ((addr & 3) || addr < 0 || 128 if ((addr & 3) || addr > sizeof(struct user) - 3)
125 addr > sizeof(struct user) - 3)
126 break; 129 break;
127 130
128 tmp = 0; /* Default return condition */ 131 tmp = 0; /* Default return condition */
129 addr = addr >> 2; /* temporary hack. */
130 ret = -EIO; 132 ret = -EIO;
131 if (addr < 19) { 133 if (regno < 19) {
132 tmp = get_reg(child, addr); 134 tmp = get_reg(child, regno);
133 if (addr == PT_SR) 135 if (regno == PT_SR)
134 tmp >>= 16; 136 tmp >>= 16;
135 } else if (addr >= 21 && addr < 49) { 137 } else if (regno >= 21 && regno < 49) {
136 tmp = child->thread.fp[addr - 21]; 138 tmp = child->thread.fp[regno - 21];
137#ifdef CONFIG_M68KFPU_EMU 139 } else if (regno == 49) {
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) {
146 tmp = child->mm->start_code; 140 tmp = child->mm->start_code;
147 } else if (addr == 50) { 141 } else if (regno == 50) {
148 tmp = child->mm->start_data; 142 tmp = child->mm->start_data;
149 } else if (addr == 51) { 143 } else if (regno == 51) {
150 tmp = child->mm->end_code; 144 tmp = child->mm->end_code;
151 } else 145 } else
152 break; 146 break;
153 ret = put_user(tmp,(unsigned long *) data); 147 ret = put_user(tmp, datap);
154 break; 148 break;
155 } 149 }
156 150
157 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 151 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
158 ret = -EIO; 152 ret = -EIO;
159 if ((addr & 3) || addr < 0 || 153 if ((addr & 3) || addr > sizeof(struct user) - 3)
160 addr > sizeof(struct user) - 3)
161 break; 154 break;
162 155
163 addr = addr >> 2; /* temporary hack. */ 156 if (regno == PT_SR) {
164
165 if (addr == PT_SR) {
166 data &= SR_MASK; 157 data &= SR_MASK;
167 data <<= 16; 158 data <<= 16;
168 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); 159 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
169 } 160 }
170 if (addr < 19) { 161 if (regno < 19) {
171 if (put_reg(child, addr, data)) 162 if (put_reg(child, regno, data))
172 break; 163 break;
173 ret = 0; 164 ret = 0;
174 break; 165 break;
175 } 166 }
176 if (addr >= 21 && addr < 48) 167 if (regno >= 21 && regno < 48)
177 { 168 {
178#ifdef CONFIG_M68KFPU_EMU 169 child->thread.fp[regno - 21] = data;
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;
189 ret = 0; 170 ret = 0;
190 } 171 }
191 break; 172 break;
@@ -197,11 +178,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
197 tmp = get_reg(child, i); 178 tmp = get_reg(child, i);
198 if (i == PT_SR) 179 if (i == PT_SR)
199 tmp >>= 16; 180 tmp >>= 16;
200 if (put_user(tmp, (unsigned long *) data)) { 181 if (put_user(tmp, datap)) {
201 ret = -EFAULT; 182 ret = -EFAULT;
202 break; 183 break;
203 } 184 }
204 data += sizeof(long); 185 datap++;
205 } 186 }
206 ret = 0; 187 ret = 0;
207 break; 188 break;
@@ -211,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
211 int i; 192 int i;
212 unsigned long tmp; 193 unsigned long tmp;
213 for (i = 0; i < 19; i++) { 194 for (i = 0; i < 19; i++) {
214 if (get_user(tmp, (unsigned long *) data)) { 195 if (get_user(tmp, datap)) {
215 ret = -EFAULT; 196 ret = -EFAULT;
216 break; 197 break;
217 } 198 }
@@ -221,7 +202,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
221 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); 202 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
222 } 203 }
223 put_reg(child, i, tmp); 204 put_reg(child, i, tmp);
224 data += sizeof(long); 205 datap++;
225 } 206 }
226 ret = 0; 207 ret = 0;
227 break; 208 break;
@@ -230,7 +211,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
230#ifdef PTRACE_GETFPREGS 211#ifdef PTRACE_GETFPREGS
231 case PTRACE_GETFPREGS: { /* Get the child FPU state. */ 212 case PTRACE_GETFPREGS: { /* Get the child FPU state. */
232 ret = 0; 213 ret = 0;
233 if (copy_to_user((void *)data, &child->thread.fp, 214 if (copy_to_user(datap, &child->thread.fp,
234 sizeof(struct user_m68kfp_struct))) 215 sizeof(struct user_m68kfp_struct)))
235 ret = -EFAULT; 216 ret = -EFAULT;
236 break; 217 break;
@@ -240,7 +221,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
240#ifdef PTRACE_SETFPREGS 221#ifdef PTRACE_SETFPREGS
241 case PTRACE_SETFPREGS: { /* Set the child FPU state. */ 222 case PTRACE_SETFPREGS: { /* Set the child FPU state. */
242 ret = 0; 223 ret = 0;
243 if (copy_from_user(&child->thread.fp, (void *)data, 224 if (copy_from_user(&child->thread.fp, datap,
244 sizeof(struct user_m68kfp_struct))) 225 sizeof(struct user_m68kfp_struct)))
245 ret = -EFAULT; 226 ret = -EFAULT;
246 break; 227 break;
@@ -248,8 +229,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
248#endif 229#endif
249 230
250 case PTRACE_GET_THREAD_AREA: 231 case PTRACE_GET_THREAD_AREA:
251 ret = put_user(task_thread_info(child)->tp_value, 232 ret = put_user(task_thread_info(child)->tp_value, datap);
252 (unsigned long __user *)data);
253 break; 233 break;
254 234
255 default: 235 default:
@@ -259,21 +239,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
259 return ret; 239 return ret;
260} 240}
261 241
262asmlinkage void syscall_trace(void) 242asmlinkage int syscall_trace_enter(void)
263{ 243{
264 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 244 int ret = 0;
265 return; 245
266 if (!(current->ptrace & PT_PTRACED)) 246 if (test_thread_flag(TIF_SYSCALL_TRACE))
267 return; 247 ret = tracehook_report_syscall_entry(task_pt_regs(current));
268 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) 248 return ret;
269 ? 0x80 : 0)); 249}
270 /* 250
271 * this isn't the same as continuing with a signal, but it will do 251asmlinkage void syscall_trace_leave(void)
272 * for normal use. strace only continues with a signal if the 252{
273 * stopping signal is not SIGTRAP. -brl 253 if (test_thread_flag(TIF_SYSCALL_TRACE))
274 */ 254 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} 255}
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/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/Kconfig b/arch/microblaze/Kconfig
index 692fdfce2a23..387d5ffdfd3a 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -1,8 +1,3 @@
1# For a description of the syntax of this configuration file,
2# see Documentation/kbuild/kconfig-language.txt.
3
4mainmenu "Linux/Microblaze Kernel Configuration"
5
6config MICROBLAZE 1config MICROBLAZE
7 def_bool y 2 def_bool y
8 select HAVE_MEMBLOCK 3 select HAVE_MEMBLOCK
@@ -121,6 +116,23 @@ config CMDLINE_FORCE
121 Set this to have arguments from the default kernel command string 116 Set this to have arguments from the default kernel command string
122 override those passed by the boot loader. 117 override those passed by the boot loader.
123 118
119config SECCOMP
120 bool "Enable seccomp to safely compute untrusted bytecode"
121 depends on PROC_FS
122 default y
123 help
124 This kernel feature is useful for number crunching applications
125 that may need to compute untrusted bytecode during their
126 execution. By using pipes or other transports made available to
127 the process as file descriptors supporting the read/write
128 syscalls, it's possible to isolate those applications in
129 their own address space using seccomp. Once seccomp is
130 enabled via /proc/<pid>/seccomp, it cannot be disabled
131 and the task is only allowed to execute a few safe syscalls
132 defined by each seccomp mode.
133
134 If unsure, say Y. Only embedded should say N here.
135
124endmenu 136endmenu
125 137
126menu "Advanced setup" 138menu "Advanced setup"
diff --git a/arch/microblaze/Kconfig.debug b/arch/microblaze/Kconfig.debug
index e6e5e0da28c3..e66e25c4b0b2 100644
--- a/arch/microblaze/Kconfig.debug
+++ b/arch/microblaze/Kconfig.debug
@@ -10,7 +10,7 @@ source "lib/Kconfig.debug"
10 10
11config EARLY_PRINTK 11config EARLY_PRINTK
12 bool "Early printk function for kernel" 12 bool "Early printk function for kernel"
13 depends on SERIAL_UARTLITE_CONSOLE 13 depends on SERIAL_UARTLITE_CONSOLE || SERIAL_8250_CONSOLE
14 default n 14 default n
15 help 15 help
16 This option turns on/off early printk messages to console. 16 This option turns on/off early printk messages to console.
diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index 592c7079de88..15f1f1d1840d 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -42,11 +42,8 @@ KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-1) $(CPUFLAGS-2)
42LDFLAGS := 42LDFLAGS :=
43LDFLAGS_vmlinux := 43LDFLAGS_vmlinux :=
44 44
45LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
46
47head-y := arch/microblaze/kernel/head.o 45head-y := arch/microblaze/kernel/head.o
48libs-y += arch/microblaze/lib/ 46libs-y += arch/microblaze/lib/
49libs-y += $(LIBGCC)
50core-y += arch/microblaze/kernel/ 47core-y += arch/microblaze/kernel/
51core-y += arch/microblaze/mm/ 48core-y += arch/microblaze/mm/
52core-y += arch/microblaze/platform/ 49core-y += arch/microblaze/platform/
@@ -72,12 +69,16 @@ export MMU DTB
72 69
73all: linux.bin 70all: linux.bin
74 71
75BOOT_TARGETS = linux.bin linux.bin.gz simpleImage.% 72# With make 3.82 we cannot mix normal and wildcard targets
73BOOT_TARGETS1 = linux.bin linux.bin.gz
74BOOT_TARGETS2 = simpleImage.%
76 75
77archclean: 76archclean:
78 $(Q)$(MAKE) $(clean)=$(boot) 77 $(Q)$(MAKE) $(clean)=$(boot)
79 78
80$(BOOT_TARGETS): vmlinux 79$(BOOT_TARGETS1): vmlinux
80 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
81$(BOOT_TARGETS2): vmlinux
81 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 82 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
82 83
83define archhelp 84define archhelp
diff --git a/arch/microblaze/include/asm/byteorder.h b/arch/microblaze/include/asm/byteorder.h
index ce9c58732ffc..31902762a426 100644
--- a/arch/microblaze/include/asm/byteorder.h
+++ b/arch/microblaze/include/asm/byteorder.h
@@ -1,6 +1,10 @@
1#ifndef _ASM_MICROBLAZE_BYTEORDER_H 1#ifndef _ASM_MICROBLAZE_BYTEORDER_H
2#define _ASM_MICROBLAZE_BYTEORDER_H 2#define _ASM_MICROBLAZE_BYTEORDER_H
3 3
4#ifdef __MICROBLAZEEL__
5#include <linux/byteorder/little_endian.h>
6#else
4#include <linux/byteorder/big_endian.h> 7#include <linux/byteorder/big_endian.h>
8#endif
5 9
6#endif /* _ASM_MICROBLAZE_BYTEORDER_H */ 10#endif /* _ASM_MICROBLAZE_BYTEORDER_H */
diff --git a/arch/microblaze/include/asm/checksum.h b/arch/microblaze/include/asm/checksum.h
index 128bf03b54b7..0185cbefdda4 100644
--- a/arch/microblaze/include/asm/checksum.h
+++ b/arch/microblaze/include/asm/checksum.h
@@ -24,8 +24,13 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
24 "addc %0, %0, %3\n\t" 24 "addc %0, %0, %3\n\t"
25 "addc %0, %0, r0\n\t" 25 "addc %0, %0, r0\n\t"
26 : "+&d" (sum) 26 : "+&d" (sum)
27 : "d" (saddr), "d" (daddr), "d" (len + proto)); 27 : "d" (saddr), "d" (daddr),
28 28#ifdef __MICROBLAZEEL__
29 "d" ((len + proto) << 8)
30#else
31 "d" (len + proto)
32#endif
33);
29 return sum; 34 return sum;
30} 35}
31 36
diff --git a/arch/microblaze/include/asm/cpuinfo.h b/arch/microblaze/include/asm/cpuinfo.h
index b4f5ca33aebf..cd257537ae54 100644
--- a/arch/microblaze/include/asm/cpuinfo.h
+++ b/arch/microblaze/include/asm/cpuinfo.h
@@ -38,6 +38,7 @@ struct cpuinfo {
38 u32 use_exc; 38 u32 use_exc;
39 u32 ver_code; 39 u32 ver_code;
40 u32 mmu; 40 u32 mmu;
41 u32 endian;
41 42
42 /* CPU caches */ 43 /* CPU caches */
43 u32 use_icache; 44 u32 use_icache;
@@ -76,7 +77,6 @@ struct cpuinfo {
76 u32 num_rd_brk; 77 u32 num_rd_brk;
77 u32 num_wr_brk; 78 u32 num_wr_brk;
78 u32 cpu_clock_freq; /* store real freq of cpu */ 79 u32 cpu_clock_freq; /* store real freq of cpu */
79 u32 freq_div_hz; /* store freq/HZ */
80 80
81 /* FPGA family */ 81 /* FPGA family */
82 u32 fpga_family_code; 82 u32 fpga_family_code;
@@ -97,7 +97,8 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu);
97static inline unsigned int fcpu(struct device_node *cpu, char *n) 97static inline unsigned int fcpu(struct device_node *cpu, char *n)
98{ 98{
99 int *val; 99 int *val;
100 return (val = (int *) of_get_property(cpu, n, NULL)) ? *val : 0; 100 return (val = (int *) of_get_property(cpu, n, NULL)) ?
101 be32_to_cpup(val) : 0;
101} 102}
102 103
103#endif /* _ASM_MICROBLAZE_CPUINFO_H */ 104#endif /* _ASM_MICROBLAZE_CPUINFO_H */
diff --git a/arch/microblaze/include/asm/elf.h b/arch/microblaze/include/asm/elf.h
index 732caf1be741..098dfdde4b06 100644
--- a/arch/microblaze/include/asm/elf.h
+++ b/arch/microblaze/include/asm/elf.h
@@ -71,7 +71,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
71 71
72#define ELF_ET_DYN_BASE (0x08000000) 72#define ELF_ET_DYN_BASE (0x08000000)
73 73
74#ifdef __LITTLE_ENDIAN__ 74#ifdef __MICROBLAZEEL__
75#define ELF_DATA ELFDATA2LSB 75#define ELF_DATA ELFDATA2LSB
76#else 76#else
77#define ELF_DATA ELFDATA2MSB 77#define ELF_DATA ELFDATA2MSB
diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h
index 2345ac354d9b..2b2c18be71c6 100644
--- a/arch/microblaze/include/asm/gpio.h
+++ b/arch/microblaze/include/asm/gpio.h
@@ -38,12 +38,9 @@ static inline int gpio_cansleep(unsigned int gpio)
38 return __gpio_cansleep(gpio); 38 return __gpio_cansleep(gpio);
39} 39}
40 40
41/*
42 * Not implemented, yet.
43 */
44static inline int gpio_to_irq(unsigned int gpio) 41static inline int gpio_to_irq(unsigned int gpio)
45{ 42{
46 return -ENOSYS; 43 return __gpio_to_irq(gpio);
47} 44}
48 45
49static inline int irq_to_gpio(unsigned int irq) 46static inline int irq_to_gpio(unsigned int irq)
diff --git a/arch/microblaze/include/asm/io.h b/arch/microblaze/include/asm/io.h
index 00b5398d08c7..eae32220f447 100644
--- a/arch/microblaze/include/asm/io.h
+++ b/arch/microblaze/include/asm/io.h
@@ -243,6 +243,8 @@ static inline void __iomem *__ioremap(phys_addr_t address, unsigned long size,
243#define out_8(a, v) __raw_writeb((v), (a)) 243#define out_8(a, v) __raw_writeb((v), (a))
244#define in_8(a) __raw_readb(a) 244#define in_8(a) __raw_readb(a)
245 245
246#define mmiowb()
247
246#define ioport_map(port, nr) ((void __iomem *)(port)) 248#define ioport_map(port, nr) ((void __iomem *)(port))
247#define ioport_unmap(addr) 249#define ioport_unmap(addr)
248 250
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index cf377d91da71..ed9d0f6e2cdb 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -205,9 +205,6 @@ extern int page_is_ram(unsigned long pfn);
205#define TOPHYS(addr) __virt_to_phys(addr) 205#define TOPHYS(addr) __virt_to_phys(addr)
206 206
207#ifdef CONFIG_MMU 207#ifdef CONFIG_MMU
208#ifdef CONFIG_CONTIGUOUS_PAGE_ALLOC
209#define WANT_PAGE_VIRTUAL 1 /* page alloc 2 relies on this */
210#endif
211 208
212#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 209#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
213 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 210 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index 5a388eeeb28f..2232ff942ba9 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -165,5 +165,7 @@ extern void __init xilinx_pci_init(void);
165static inline void __init xilinx_pci_init(void) { return; } 165static inline void __init xilinx_pci_init(void) { return; }
166#endif 166#endif
167 167
168#include <asm-generic/pci-dma-compat.h>
169
168#endif /* __KERNEL__ */ 170#endif /* __KERNEL__ */
169#endif /* __ASM_MICROBLAZE_PCI_H */ 171#endif /* __ASM_MICROBLAZE_PCI_H */
diff --git a/arch/microblaze/include/asm/pgalloc.h b/arch/microblaze/include/asm/pgalloc.h
index c614a893f8a3..ebd35792482c 100644
--- a/arch/microblaze/include/asm/pgalloc.h
+++ b/arch/microblaze/include/asm/pgalloc.h
@@ -165,7 +165,8 @@ extern inline void pte_free(struct mm_struct *mm, struct page *ptepage)
165 165
166#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte)) 166#define __pte_free_tlb(tlb, pte, addr) pte_free((tlb)->mm, (pte))
167 167
168#define pmd_populate(mm, pmd, pte) (pmd_val(*(pmd)) = page_address(pte)) 168#define pmd_populate(mm, pmd, pte) \
169 (pmd_val(*(pmd)) = (unsigned long)page_address(pte))
169 170
170#define pmd_populate_kernel(mm, pmd, pte) \ 171#define pmd_populate_kernel(mm, pmd, pte) \
171 (pmd_val(*(pmd)) = (unsigned long) (pte)) 172 (pmd_val(*(pmd)) = (unsigned long) (pte))
diff --git a/arch/microblaze/include/asm/pgtable.h b/arch/microblaze/include/asm/pgtable.h
index ca2d92871545..cae268c22ba2 100644
--- a/arch/microblaze/include/asm/pgtable.h
+++ b/arch/microblaze/include/asm/pgtable.h
@@ -57,6 +57,13 @@ static inline int pte_file(pte_t pte) { return 0; }
57 57
58#define pgprot_noncached_wc(prot) prot 58#define pgprot_noncached_wc(prot) prot
59 59
60/*
61 * All 32bit addresses are effectively valid for vmalloc...
62 * Sort of meaningless for non-VM targets.
63 */
64#define VMALLOC_START 0
65#define VMALLOC_END 0xffffffff
66
60#else /* CONFIG_MMU */ 67#else /* CONFIG_MMU */
61 68
62#include <asm-generic/4level-fixup.h> 69#include <asm-generic/4level-fixup.h>
@@ -497,12 +504,9 @@ static inline pmd_t *pmd_offset(pgd_t *dir, unsigned long address)
497#define pte_offset_kernel(dir, addr) \ 504#define pte_offset_kernel(dir, addr) \
498 ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr)) 505 ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(addr))
499#define pte_offset_map(dir, addr) \ 506#define pte_offset_map(dir, addr) \
500 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) 507 ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
501#define pte_offset_map_nested(dir, addr) \
502 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
503 508
504#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0) 509#define pte_unmap(pte) kunmap_atomic(pte)
505#define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1)
506 510
507/* Encode and decode a nonlinear file mapping entry */ 511/* Encode and decode a nonlinear file mapping entry */
508#define PTE_FILE_MAX_BITS 29 512#define PTE_FILE_MAX_BITS 29
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index 101fa098f62a..bdc38312ae4a 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -27,6 +27,7 @@
27 27
28/* Other Prototypes */ 28/* Other Prototypes */
29extern int early_uartlite_console(void); 29extern int early_uartlite_console(void);
30extern int early_uart16550_console(void);
30 31
31#ifdef CONFIG_PCI 32#ifdef CONFIG_PCI
32/* 33/*
diff --git a/arch/microblaze/include/asm/pvr.h b/arch/microblaze/include/asm/pvr.h
index 9578666e98ba..37db96a15b45 100644
--- a/arch/microblaze/include/asm/pvr.h
+++ b/arch/microblaze/include/asm/pvr.h
@@ -30,7 +30,9 @@ struct pvr_s {
30#define PVR0_USE_EXC_MASK 0x04000000 30#define PVR0_USE_EXC_MASK 0x04000000
31#define PVR0_USE_ICACHE_MASK 0x02000000 31#define PVR0_USE_ICACHE_MASK 0x02000000
32#define PVR0_USE_DCACHE_MASK 0x01000000 32#define PVR0_USE_DCACHE_MASK 0x01000000
33#define PVR0_USE_MMU 0x00800000 /* new */ 33#define PVR0_USE_MMU 0x00800000
34#define PVR0_USE_BTC 0x00400000
35#define PVR0_ENDI 0x00200000
34#define PVR0_VERSION_MASK 0x0000FF00 36#define PVR0_VERSION_MASK 0x0000FF00
35#define PVR0_USER1_MASK 0x000000FF 37#define PVR0_USER1_MASK 0x000000FF
36 38
@@ -38,9 +40,9 @@ struct pvr_s {
38#define PVR1_USER2_MASK 0xFFFFFFFF 40#define PVR1_USER2_MASK 0xFFFFFFFF
39 41
40/* Configuration PVR masks */ 42/* Configuration PVR masks */
41#define PVR2_D_OPB_MASK 0x80000000 43#define PVR2_D_OPB_MASK 0x80000000 /* or AXI */
42#define PVR2_D_LMB_MASK 0x40000000 44#define PVR2_D_LMB_MASK 0x40000000
43#define PVR2_I_OPB_MASK 0x20000000 45#define PVR2_I_OPB_MASK 0x20000000 /* or AXI */
44#define PVR2_I_LMB_MASK 0x10000000 46#define PVR2_I_LMB_MASK 0x10000000
45#define PVR2_INTERRUPT_IS_EDGE_MASK 0x08000000 47#define PVR2_INTERRUPT_IS_EDGE_MASK 0x08000000
46#define PVR2_EDGE_IS_POSITIVE_MASK 0x04000000 48#define PVR2_EDGE_IS_POSITIVE_MASK 0x04000000
@@ -63,8 +65,8 @@ struct pvr_s {
63#define PVR2_OPCODE_0x0_ILL_MASK 0x00000040 65#define PVR2_OPCODE_0x0_ILL_MASK 0x00000040
64#define PVR2_UNALIGNED_EXC_MASK 0x00000020 66#define PVR2_UNALIGNED_EXC_MASK 0x00000020
65#define PVR2_ILL_OPCODE_EXC_MASK 0x00000010 67#define PVR2_ILL_OPCODE_EXC_MASK 0x00000010
66#define PVR2_IOPB_BUS_EXC_MASK 0x00000008 68#define PVR2_IOPB_BUS_EXC_MASK 0x00000008 /* or AXI */
67#define PVR2_DOPB_BUS_EXC_MASK 0x00000004 69#define PVR2_DOPB_BUS_EXC_MASK 0x00000004 /* or AXI */
68#define PVR2_DIV_ZERO_EXC_MASK 0x00000002 70#define PVR2_DIV_ZERO_EXC_MASK 0x00000002
69#define PVR2_FPU_EXC_MASK 0x00000001 71#define PVR2_FPU_EXC_MASK 0x00000001
70 72
@@ -208,6 +210,8 @@ struct pvr_s {
208#define PVR_MMU_TLB_ACCESS(pvr) (pvr.pvr[11] & PVR11_MMU_TLB_ACCESS) 210#define PVR_MMU_TLB_ACCESS(pvr) (pvr.pvr[11] & PVR11_MMU_TLB_ACCESS)
209#define PVR_MMU_ZONES(pvr) (pvr.pvr[11] & PVR11_MMU_ZONES) 211#define PVR_MMU_ZONES(pvr) (pvr.pvr[11] & PVR11_MMU_ZONES)
210 212
213/* endian */
214#define PVR_ENDIAN(pvr) (pvr.pvr[0] & PVR0_ENDI)
211 215
212int cpu_has_pvr(void); 216int cpu_has_pvr(void);
213void get_pvr(struct pvr_s *pvr); 217void get_pvr(struct pvr_s *pvr);
diff --git a/arch/microblaze/include/asm/seccomp.h b/arch/microblaze/include/asm/seccomp.h
new file mode 100644
index 000000000000..0d912758a0d7
--- /dev/null
+++ b/arch/microblaze/include/asm/seccomp.h
@@ -0,0 +1,16 @@
1#ifndef _ASM_MICROBLAZE_SECCOMP_H
2#define _ASM_MICROBLAZE_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_sigreturn
10
11#define __NR_seccomp_read_32 __NR_read
12#define __NR_seccomp_write_32 __NR_write
13#define __NR_seccomp_exit_32 __NR_exit
14#define __NR_seccomp_sigreturn_32 __NR_sigreturn
15
16#endif /* _ASM_MICROBLAZE_SECCOMP_H */
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index 782b5c89248e..8f3968971e4e 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -25,6 +25,12 @@ void early_printk(const char *fmt, ...);
25int setup_early_printk(char *opt); 25int setup_early_printk(char *opt);
26void disable_early_printk(void); 26void disable_early_printk(void);
27 27
28#if defined(CONFIG_EARLY_PRINTK)
29#define eprintk early_printk
30#else
31#define eprintk printk
32#endif
33
28void heartbeat(void); 34void heartbeat(void);
29void setup_heartbeat(void); 35void setup_heartbeat(void);
30 36
diff --git a/arch/microblaze/include/asm/thread_info.h b/arch/microblaze/include/asm/thread_info.h
index 8a8e9fc6e0c0..b73da2ac21b3 100644
--- a/arch/microblaze/include/asm/thread_info.h
+++ b/arch/microblaze/include/asm/thread_info.h
@@ -127,23 +127,19 @@ static inline struct thread_info *current_thread_info(void)
127#define TIF_SECCOMP 10 /* secure computing */ 127#define TIF_SECCOMP 10 /* secure computing */
128#define TIF_FREEZE 14 /* Freezing for suspend */ 128#define TIF_FREEZE 14 /* Freezing for suspend */
129 129
130/* FIXME change in entry.S */
131#define TIF_KERNEL_TRACE 8 /* kernel trace active */
132
133/* true if poll_idle() is polling TIF_NEED_RESCHED */ 130/* true if poll_idle() is polling TIF_NEED_RESCHED */
134#define TIF_POLLING_NRFLAG 16 131#define TIF_POLLING_NRFLAG 16
135 132
136#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 133#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
137#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 134#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
138#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 135#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
139#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 136#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
140#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 137#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
141#define _TIF_IRET (1<<TIF_IRET) 138#define _TIF_IRET (1 << TIF_IRET)
142#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 139#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
143#define _TIF_FREEZE (1<<TIF_FREEZE) 140#define _TIF_FREEZE (1 << TIF_FREEZE)
144#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 141#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
145#define _TIF_SECCOMP (1 << TIF_SECCOMP) 142#define _TIF_SECCOMP (1 << TIF_SECCOMP)
146#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)
147 143
148/* work to do in syscall trace */ 144/* work to do in syscall trace */
149#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ 145#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
diff --git a/arch/microblaze/include/asm/unaligned.h b/arch/microblaze/include/asm/unaligned.h
index 3658d91ac0fb..2b97cbe500e9 100644
--- a/arch/microblaze/include/asm/unaligned.h
+++ b/arch/microblaze/include/asm/unaligned.h
@@ -12,12 +12,18 @@
12 12
13# ifdef __KERNEL__ 13# ifdef __KERNEL__
14 14
15# include <linux/unaligned/be_struct.h> 15# include <linux/unaligned/be_byteshift.h>
16# include <linux/unaligned/le_byteshift.h> 16# include <linux/unaligned/le_byteshift.h>
17# include <linux/unaligned/generic.h> 17# include <linux/unaligned/generic.h>
18 18
19# define get_unaligned __get_unaligned_be 19
20# define put_unaligned __put_unaligned_be 20# ifdef __MICROBLAZEEL__
21# define get_unaligned __get_unaligned_le
22# define put_unaligned __put_unaligned_le
23# else
24# define get_unaligned __get_unaligned_be
25# define put_unaligned __put_unaligned_be
26# endif
21 27
22# endif /* __KERNEL__ */ 28# endif /* __KERNEL__ */
23#endif /* _ASM_MICROBLAZE_UNALIGNED_H */ 29#endif /* _ASM_MICROBLAZE_UNALIGNED_H */
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index 2b67e92a773c..d770b00ec6b1 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -383,8 +383,11 @@
383#define __NR_rt_tgsigqueueinfo 365 /* new */ 383#define __NR_rt_tgsigqueueinfo 365 /* new */
384#define __NR_perf_event_open 366 /* new */ 384#define __NR_perf_event_open 366 /* new */
385#define __NR_recvmmsg 367 /* new */ 385#define __NR_recvmmsg 367 /* new */
386#define __NR_fanotify_init 368
387#define __NR_fanotify_mark 369
388#define __NR_prlimit64 370
386 389
387#define __NR_syscalls 368 390#define __NR_syscalls 371
388 391
389#ifdef __KERNEL__ 392#ifdef __KERNEL__
390#ifndef __ASSEMBLY__ 393#ifndef __ASSEMBLY__
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
index f72dbd66c844..f70a6047f08e 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
@@ -72,6 +72,7 @@ void set_cpuinfo_pvr_full(struct cpuinfo *ci, struct device_node *cpu)
72 CI(pvr_user2, USER2); 72 CI(pvr_user2, USER2);
73 73
74 CI(mmu, USE_MMU); 74 CI(mmu, USE_MMU);
75 CI(endian, ENDIAN);
75 76
76 CI(use_icache, USE_ICACHE); 77 CI(use_icache, USE_ICACHE);
77 CI(icache_tagbits, ICACHE_ADDR_TAG_BITS); 78 CI(icache_tagbits, ICACHE_ADDR_TAG_BITS);
diff --git a/arch/microblaze/kernel/cpu/cpuinfo-static.c b/arch/microblaze/kernel/cpu/cpuinfo-static.c
index 6095aa6b5c88..b16b994ca3d2 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo-static.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo-static.c
@@ -119,6 +119,7 @@ void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
119 ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); 119 ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2");
120 120
121 ci->mmu = fcpu(cpu, "xlnx,use-mmu"); 121 ci->mmu = fcpu(cpu, "xlnx,use-mmu");
122 ci->endian = fcpu(cpu, "xlnx,endianness");
122 123
123 ci->ver_code = 0; 124 ci->ver_code = 0;
124 ci->fpga_family_code = 0; 125 ci->fpga_family_code = 0;
diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c
index 255ef880351e..87c79fa275c3 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo.c
@@ -30,6 +30,8 @@ const struct cpu_ver_key cpu_ver_lookup[] = {
30 {"7.20.c", 0x0e}, 30 {"7.20.c", 0x0e},
31 {"7.20.d", 0x0f}, 31 {"7.20.d", 0x0f},
32 {"7.30.a", 0x10}, 32 {"7.30.a", 0x10},
33 {"7.30.b", 0x11},
34 {"8.00.a", 0x12},
33 {NULL, 0}, 35 {NULL, 0},
34}; 36};
35 37
diff --git a/arch/microblaze/kernel/cpu/mb.c b/arch/microblaze/kernel/cpu/mb.c
index 7086e3564281..b4048af02615 100644
--- a/arch/microblaze/kernel/cpu/mb.c
+++ b/arch/microblaze/kernel/cpu/mb.c
@@ -51,11 +51,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
51 count = seq_printf(m, 51 count = seq_printf(m,
52 "CPU-Family: MicroBlaze\n" 52 "CPU-Family: MicroBlaze\n"
53 "FPGA-Arch: %s\n" 53 "FPGA-Arch: %s\n"
54 "CPU-Ver: %s\n" 54 "CPU-Ver: %s, %s endian\n"
55 "CPU-MHz: %d.%02d\n" 55 "CPU-MHz: %d.%02d\n"
56 "BogoMips: %lu.%02lu\n", 56 "BogoMips: %lu.%02lu\n",
57 fpga_family, 57 fpga_family,
58 cpu_ver, 58 cpu_ver,
59 cpuinfo.endian ? "little" : "big",
59 cpuinfo.cpu_clock_freq / 60 cpuinfo.cpu_clock_freq /
60 1000000, 61 1000000,
61 cpuinfo.cpu_clock_freq % 62 cpuinfo.cpu_clock_freq %
diff --git a/arch/microblaze/kernel/cpu/pvr.c b/arch/microblaze/kernel/cpu/pvr.c
index 9bee9382bf74..e01afa68273e 100644
--- a/arch/microblaze/kernel/cpu/pvr.c
+++ b/arch/microblaze/kernel/cpu/pvr.c
@@ -27,7 +27,7 @@
27 register unsigned tmp __asm__("r3"); \ 27 register unsigned tmp __asm__("r3"); \
28 tmp = 0x0; /* Prevent warning about unused */ \ 28 tmp = 0x0; /* Prevent warning about unused */ \
29 __asm__ __volatile__ ( \ 29 __asm__ __volatile__ ( \
30 ".byte 0x94,0x60,0xa0, " #pvrid "\n\t" \ 30 "mfs %0, rpvr" #pvrid ";" \
31 : "=r" (tmp) : : "memory"); \ 31 : "=r" (tmp) : : "memory"); \
32 val = tmp; \ 32 val = tmp; \
33} 33}
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c
index 7de84923ba07..c3616a080ebf 100644
--- a/arch/microblaze/kernel/early_printk.c
+++ b/arch/microblaze/kernel/early_printk.c
@@ -24,7 +24,8 @@
24static u32 early_console_initialized; 24static u32 early_console_initialized;
25static u32 base_addr; 25static u32 base_addr;
26 26
27static void early_printk_putc(char c) 27#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
28static void early_printk_uartlite_putc(char c)
28{ 29{
29 /* 30 /*
30 * Limit how many times we'll spin waiting for TX FIFO status. 31 * Limit how many times we'll spin waiting for TX FIFO status.
@@ -45,25 +46,70 @@ static void early_printk_putc(char c)
45 out_be32(base_addr + 4, c & 0xff); 46 out_be32(base_addr + 4, c & 0xff);
46} 47}
47 48
48static void early_printk_write(struct console *unused, 49static void early_printk_uartlite_write(struct console *unused,
49 const char *s, unsigned n) 50 const char *s, unsigned n)
50{ 51{
51 while (*s && n-- > 0) { 52 while (*s && n-- > 0) {
52 early_printk_putc(*s); 53 early_printk_uartlite_putc(*s);
53 if (*s == '\n') 54 if (*s == '\n')
54 early_printk_putc('\r'); 55 early_printk_uartlite_putc('\r');
55 s++; 56 s++;
56 } 57 }
57} 58}
58 59
59static struct console early_serial_console = { 60static struct console early_serial_uartlite_console = {
60 .name = "earlyser", 61 .name = "earlyser",
61 .write = early_printk_write, 62 .write = early_printk_uartlite_write,
62 .flags = CON_PRINTBUFFER, 63 .flags = CON_PRINTBUFFER,
63 .index = -1, 64 .index = -1,
64}; 65};
66#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
65 67
66static struct console *early_console = &early_serial_console; 68#ifdef CONFIG_SERIAL_8250_CONSOLE
69static void early_printk_uart16550_putc(char c)
70{
71 /*
72 * Limit how many times we'll spin waiting for TX FIFO status.
73 * This will prevent lockups if the base address is incorrectly
74 * set, or any other issue on the UARTLITE.
75 * This limit is pretty arbitrary, unless we are at about 10 baud
76 * we'll never timeout on a working UART.
77 */
78
79 #define UART_LSR_TEMT 0x40 /* Transmitter empty */
80 #define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
81 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
82
83 unsigned retries = 10000;
84
85 while (--retries &&
86 !((in_be32(base_addr + 0x14) & BOTH_EMPTY) == BOTH_EMPTY))
87 ;
88
89 if (retries)
90 out_be32(base_addr, c & 0xff);
91}
92
93static void early_printk_uart16550_write(struct console *unused,
94 const char *s, unsigned n)
95{
96 while (*s && n-- > 0) {
97 early_printk_uart16550_putc(*s);
98 if (*s == '\n')
99 early_printk_uart16550_putc('\r');
100 s++;
101 }
102}
103
104static struct console early_serial_uart16550_console = {
105 .name = "earlyser",
106 .write = early_printk_uart16550_write,
107 .flags = CON_PRINTBUFFER,
108 .index = -1,
109};
110#endif /* CONFIG_SERIAL_8250_CONSOLE */
111
112static struct console *early_console;
67 113
68void early_printk(const char *fmt, ...) 114void early_printk(const char *fmt, ...)
69{ 115{
@@ -84,20 +130,43 @@ int __init setup_early_printk(char *opt)
84 if (early_console_initialized) 130 if (early_console_initialized)
85 return 1; 131 return 1;
86 132
133#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
87 base_addr = early_uartlite_console(); 134 base_addr = early_uartlite_console();
88 if (base_addr) { 135 if (base_addr) {
89 early_console_initialized = 1; 136 early_console_initialized = 1;
90#ifdef CONFIG_MMU 137#ifdef CONFIG_MMU
91 early_console_reg_tlb_alloc(base_addr); 138 early_console_reg_tlb_alloc(base_addr);
92#endif 139#endif
140 early_console = &early_serial_uartlite_console;
93 early_printk("early_printk_console is enabled at 0x%08x\n", 141 early_printk("early_printk_console is enabled at 0x%08x\n",
94 base_addr); 142 base_addr);
95 143
96 /* register_console(early_console); */ 144 /* register_console(early_console); */
97 145
98 return 0; 146 return 0;
99 } else 147 }
100 return 1; 148#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
149
150#ifdef CONFIG_SERIAL_8250_CONSOLE
151 base_addr = early_uart16550_console();
152 base_addr &= ~3; /* clear register offset */
153 if (base_addr) {
154 early_console_initialized = 1;
155#ifdef CONFIG_MMU
156 early_console_reg_tlb_alloc(base_addr);
157#endif
158 early_console = &early_serial_uart16550_console;
159
160 early_printk("early_printk_console is enabled at 0x%08x\n",
161 base_addr);
162
163 /* register_console(early_console); */
164
165 return 0;
166 }
167#endif /* CONFIG_SERIAL_8250_CONSOLE */
168
169 return 1;
101} 170}
102 171
103void __init disable_early_printk(void) 172void __init disable_early_printk(void)
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index 304882e56459..819238b8a429 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -186,6 +186,8 @@
186 swi r13, r1, PTO+PT_R13; /* Save SDA2 */ \ 186 swi r13, r1, PTO+PT_R13; /* Save SDA2 */ \
187 swi r14, r1, PTO+PT_PC; /* PC, before IRQ/trap */ \ 187 swi r14, r1, PTO+PT_PC; /* PC, before IRQ/trap */ \
188 swi r15, r1, PTO+PT_R15; /* Save LP */ \ 188 swi r15, r1, PTO+PT_R15; /* Save LP */ \
189 swi r16, r1, PTO+PT_R16; \
190 swi r17, r1, PTO+PT_R17; \
189 swi r18, r1, PTO+PT_R18; /* Save asm scratch reg */ \ 191 swi r18, r1, PTO+PT_R18; /* Save asm scratch reg */ \
190 swi r19, r1, PTO+PT_R19; \ 192 swi r19, r1, PTO+PT_R19; \
191 swi r20, r1, PTO+PT_R20; \ 193 swi r20, r1, PTO+PT_R20; \
@@ -220,6 +222,8 @@
220 lwi r13, r1, PTO+PT_R13; /* restore SDA2 */ \ 222 lwi r13, r1, PTO+PT_R13; /* restore SDA2 */ \
221 lwi r14, r1, PTO+PT_PC; /* RESTORE_LINK PC, before IRQ/trap */\ 223 lwi r14, r1, PTO+PT_PC; /* RESTORE_LINK PC, before IRQ/trap */\
222 lwi r15, r1, PTO+PT_R15; /* restore LP */ \ 224 lwi r15, r1, PTO+PT_R15; /* restore LP */ \
225 lwi r16, r1, PTO+PT_R16; \
226 lwi r17, r1, PTO+PT_R17; \
223 lwi r18, r1, PTO+PT_R18; /* restore asm scratch reg */ \ 227 lwi r18, r1, PTO+PT_R18; /* restore asm scratch reg */ \
224 lwi r19, r1, PTO+PT_R19; \ 228 lwi r19, r1, PTO+PT_R19; \
225 lwi r20, r1, PTO+PT_R20; \ 229 lwi r20, r1, PTO+PT_R20; \
@@ -295,6 +299,8 @@ C_ENTRY(_user_exception):
295 /* addik r1, r1, -STATE_SAVE_SIZE; */ 299 /* addik r1, r1, -STATE_SAVE_SIZE; */
296 addik r1, r1, THREAD_SIZE + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - STATE_SAVE_SIZE; 300 addik r1, r1, THREAD_SIZE + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START - STATE_SAVE_SIZE;
297 SAVE_REGS 301 SAVE_REGS
302 swi r0, r1, PTO + PT_R3
303 swi r0, r1, PTO + PT_R4
298 304
299 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 305 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
300 swi r11, r1, PTO+PT_R1; /* Store user SP. */ 306 swi r11, r1, PTO+PT_R1; /* Store user SP. */
@@ -458,14 +464,8 @@ C_ENTRY(sys_execve):
458 addik r8, r1, PTO; /* add user context as 4th arg */ 464 addik r8, r1, PTO; /* add user context as 4th arg */
459 465
460C_ENTRY(sys_rt_sigreturn_wrapper): 466C_ENTRY(sys_rt_sigreturn_wrapper):
461 swi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */ 467 brid sys_rt_sigreturn /* Do real work */
462 swi r4, r1, PTO+PT_R4;
463 brlid r15, sys_rt_sigreturn /* Do real work */
464 addik r5, r1, PTO; /* add user context as 1st arg */ 468 addik r5, r1, PTO; /* add user context as 1st arg */
465 lwi r3, r1, PTO+PT_R3; /* restore saved r3, r4 registers */
466 lwi r4, r1, PTO+PT_R4;
467 bri ret_from_trap /* fall through will not work here due to align */
468 nop;
469 469
470/* 470/*
471 * HW EXCEPTION rutine start 471 * HW EXCEPTION rutine start
@@ -765,9 +765,7 @@ C_ENTRY(_debug_exception):
765 /* save all regs to pt_reg structure */ 765 /* save all regs to pt_reg structure */
766 swi r0, r1, PTO+PT_R0; /* R0 must be saved too */ 766 swi r0, r1, PTO+PT_R0; /* R0 must be saved too */
767 swi r14, r1, PTO+PT_R14 /* rewrite saved R14 value */ 767 swi r14, r1, PTO+PT_R14 /* rewrite saved R14 value */
768 swi r16, r1, PTO+PT_R16
769 swi r16, r1, PTO+PT_PC; /* PC and r16 are the same */ 768 swi r16, r1, PTO+PT_PC; /* PC and r16 are the same */
770 swi r17, r1, PTO+PT_R17
771 /* save special purpose registers to pt_regs */ 769 /* save special purpose registers to pt_regs */
772 mfs r11, rear; 770 mfs r11, rear;
773 swi r11, r1, PTO+PT_EAR; 771 swi r11, r1, PTO+PT_EAR;
@@ -801,8 +799,6 @@ C_ENTRY(_debug_exception):
801 799
802 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */ 800 addik r1, r1, -STATE_SAVE_SIZE; /* Make room on the stack. */
803 SAVE_REGS; 801 SAVE_REGS;
804 swi r17, r1, PTO+PT_R17;
805 swi r16, r1, PTO+PT_R16;
806 swi r16, r1, PTO+PT_PC; /* Save LP */ 802 swi r16, r1, PTO+PT_PC; /* Save LP */
807 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */ 803 swi r0, r1, PTO + PT_MODE; /* Was in user-mode. */
808 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP)); 804 lwi r11, r0, TOPHYS(PER_CPU(ENTRY_SP));
@@ -848,8 +844,6 @@ dbtrap_call: /* Return point for kernel/user entry + 8 because of rtsd r15, 8 */
848 tophys(r1,r1); 844 tophys(r1,r1);
849 /* MS: Restore all regs */ 845 /* MS: Restore all regs */
850 RESTORE_REGS 846 RESTORE_REGS
851 lwi r17, r1, PTO+PT_R17;
852 lwi r16, r1, PTO+PT_R16;
853 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space */ 847 addik r1, r1, STATE_SAVE_SIZE /* Clean up stack space */
854 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer */ 848 lwi r1, r1, PT_R1 - PT_SIZE; /* Restore user stack pointer */
855DBTRAP_return_user: /* MS: Make global symbol for debugging */ 849DBTRAP_return_user: /* MS: Make global symbol for debugging */
@@ -863,7 +857,6 @@ DBTRAP_return_user: /* MS: Make global symbol for debugging */
863 RESTORE_REGS 857 RESTORE_REGS
864 lwi r14, r1, PTO+PT_R14; 858 lwi r14, r1, PTO+PT_R14;
865 lwi r16, r1, PTO+PT_PC; 859 lwi r16, r1, PTO+PT_PC;
866 lwi r17, r1, PTO+PT_R17;
867 addik r1, r1, STATE_SAVE_SIZE; /* MS: Clean up stack space */ 860 addik r1, r1, STATE_SAVE_SIZE; /* MS: Clean up stack space */
868 tovirt(r1,r1); 861 tovirt(r1,r1);
869DBTRAP_return_kernel: /* MS: Make global symbol for debugging */ 862DBTRAP_return_kernel: /* MS: Make global symbol for debugging */
diff --git a/arch/microblaze/kernel/exceptions.c b/arch/microblaze/kernel/exceptions.c
index b98ee8d0c1cd..478f2943ede7 100644
--- a/arch/microblaze/kernel/exceptions.c
+++ b/arch/microblaze/kernel/exceptions.c
@@ -72,7 +72,6 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
72 int fsr, int addr) 72 int fsr, int addr)
73{ 73{
74#ifdef CONFIG_MMU 74#ifdef CONFIG_MMU
75 int code;
76 addr = regs->pc; 75 addr = regs->pc;
77#endif 76#endif
78 77
@@ -86,8 +85,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
86 switch (type & 0x1F) { 85 switch (type & 0x1F) {
87 case MICROBLAZE_ILL_OPCODE_EXCEPTION: 86 case MICROBLAZE_ILL_OPCODE_EXCEPTION:
88 if (user_mode(regs)) { 87 if (user_mode(regs)) {
89 pr_debug(KERN_WARNING "Illegal opcode exception " \ 88 pr_debug("Illegal opcode exception in user mode\n");
90 "in user mode.\n");
91 _exception(SIGILL, regs, ILL_ILLOPC, addr); 89 _exception(SIGILL, regs, ILL_ILLOPC, addr);
92 return; 90 return;
93 } 91 }
@@ -97,8 +95,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
97 break; 95 break;
98 case MICROBLAZE_IBUS_EXCEPTION: 96 case MICROBLAZE_IBUS_EXCEPTION:
99 if (user_mode(regs)) { 97 if (user_mode(regs)) {
100 pr_debug(KERN_WARNING "Instruction bus error " \ 98 pr_debug("Instruction bus error exception in user mode\n");
101 "exception in user mode.\n");
102 _exception(SIGBUS, regs, BUS_ADRERR, addr); 99 _exception(SIGBUS, regs, BUS_ADRERR, addr);
103 return; 100 return;
104 } 101 }
@@ -108,8 +105,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
108 break; 105 break;
109 case MICROBLAZE_DBUS_EXCEPTION: 106 case MICROBLAZE_DBUS_EXCEPTION:
110 if (user_mode(regs)) { 107 if (user_mode(regs)) {
111 pr_debug(KERN_WARNING "Data bus error exception " \ 108 pr_debug("Data bus error exception in user mode\n");
112 "in user mode.\n");
113 _exception(SIGBUS, regs, BUS_ADRERR, addr); 109 _exception(SIGBUS, regs, BUS_ADRERR, addr);
114 return; 110 return;
115 } 111 }
@@ -119,8 +115,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
119 break; 115 break;
120 case MICROBLAZE_DIV_ZERO_EXCEPTION: 116 case MICROBLAZE_DIV_ZERO_EXCEPTION:
121 if (user_mode(regs)) { 117 if (user_mode(regs)) {
122 pr_debug(KERN_WARNING "Divide by zero exception " \ 118 pr_debug("Divide by zero exception in user mode\n");
123 "in user mode\n");
124 _exception(SIGILL, regs, FPE_INTDIV, addr); 119 _exception(SIGILL, regs, FPE_INTDIV, addr);
125 return; 120 return;
126 } 121 }
@@ -129,7 +124,7 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
129 die("Divide by zero exception", regs, SIGBUS); 124 die("Divide by zero exception", regs, SIGBUS);
130 break; 125 break;
131 case MICROBLAZE_FPU_EXCEPTION: 126 case MICROBLAZE_FPU_EXCEPTION:
132 pr_debug(KERN_WARNING "FPU exception\n"); 127 pr_debug("FPU exception\n");
133 /* IEEE FP exception */ 128 /* IEEE FP exception */
134 /* I removed fsr variable and use code var for storing fsr */ 129 /* I removed fsr variable and use code var for storing fsr */
135 if (fsr & FSR_IO) 130 if (fsr & FSR_IO)
@@ -147,14 +142,8 @@ asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
147 142
148#ifdef CONFIG_MMU 143#ifdef CONFIG_MMU
149 case MICROBLAZE_PRIVILEGED_EXCEPTION: 144 case MICROBLAZE_PRIVILEGED_EXCEPTION:
150 pr_debug(KERN_WARNING "Privileged exception\n"); 145 pr_debug("Privileged exception\n");
151 /* "brk r0,r0" - used as debug breakpoint - old toolchain */ 146 _exception(SIGILL, regs, ILL_PRVOPC, addr);
152 if (get_user(code, (unsigned long *)regs->pc) == 0
153 && code == 0x980c0000) {
154 _exception(SIGTRAP, regs, TRAP_BRKPT, addr);
155 } else {
156 _exception(SIGILL, regs, ILL_PRVOPC, addr);
157 }
158 break; 147 break;
159#endif 148#endif
160 default: 149 default:
diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
index 522751737cfa..154756f3c694 100644
--- a/arch/microblaze/kernel/heartbeat.c
+++ b/arch/microblaze/kernel/heartbeat.c
@@ -47,11 +47,10 @@ void setup_heartbeat(void)
47 struct device_node *gpio = NULL; 47 struct device_node *gpio = NULL;
48 int *prop; 48 int *prop;
49 int j; 49 int j;
50 char *gpio_list[] = { 50 const char * const gpio_list[] = {
51 "xlnx,xps-gpio-1.00.a", 51 "xlnx,xps-gpio-1.00.a",
52 "xlnx,opb-gpio-1.00.a", 52 NULL
53 NULL 53 };
54 };
55 54
56 for (j = 0; gpio_list[j] != NULL; j++) { 55 for (j = 0; gpio_list[j] != NULL; j++) {
57 gpio = of_find_compatible_node(NULL, NULL, gpio_list[j]); 56 gpio = of_find_compatible_node(NULL, NULL, gpio_list[j]);
@@ -60,7 +59,7 @@ void setup_heartbeat(void)
60 } 59 }
61 60
62 if (gpio) { 61 if (gpio) {
63 base_addr = *(int *) of_get_property(gpio, "reg", NULL); 62 base_addr = be32_to_cpup(of_get_property(gpio, "reg", NULL));
64 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE); 63 base_addr = (unsigned long) ioremap(base_addr, PAGE_SIZE);
65 printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr); 64 printk(KERN_NOTICE "Heartbeat GPIO at 0x%x\n", base_addr);
66 65
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index 03172c1da770..d61ea33aff7c 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -126,11 +126,8 @@ void __init init_IRQ(void)
126 0 126 0
127 }; 127 };
128#endif 128#endif
129 static char *intc_list[] = { 129 const char * const intc_list[] = {
130 "xlnx,xps-intc-1.00.a", 130 "xlnx,xps-intc-1.00.a",
131 "xlnx,opb-intc-1.00.c",
132 "xlnx,opb-intc-1.00.b",
133 "xlnx,opb-intc-1.00.a",
134 NULL 131 NULL
135 }; 132 };
136 133
@@ -141,12 +138,15 @@ void __init init_IRQ(void)
141 } 138 }
142 BUG_ON(!intc); 139 BUG_ON(!intc);
143 140
144 intc_baseaddr = *(int *) of_get_property(intc, "reg", NULL); 141 intc_baseaddr = be32_to_cpup(of_get_property(intc,
142 "reg", NULL));
145 intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE); 143 intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE);
146 nr_irq = *(int *) of_get_property(intc, "xlnx,num-intr-inputs", NULL); 144 nr_irq = be32_to_cpup(of_get_property(intc,
145 "xlnx,num-intr-inputs", NULL));
147 146
148 intr_type = 147 intr_type =
149 *(int *) of_get_property(intc, "xlnx,kind-of-intr", NULL); 148 be32_to_cpup(of_get_property(intc,
149 "xlnx,kind-of-intr", NULL));
150 if (intr_type >= (1 << (nr_irq + 1))) 150 if (intr_type >= (1 << (nr_irq + 1)))
151 printk(KERN_INFO " ERROR: Mismatch in kind-of-intr param\n"); 151 printk(KERN_INFO " ERROR: Mismatch in kind-of-intr param\n");
152 152
diff --git a/arch/microblaze/kernel/kgdb.c b/arch/microblaze/kernel/kgdb.c
index bfc006b7f2d8..09a5e8286137 100644
--- a/arch/microblaze/kernel/kgdb.c
+++ b/arch/microblaze/kernel/kgdb.c
@@ -80,7 +80,7 @@ void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
80void microblaze_kgdb_break(struct pt_regs *regs) 80void microblaze_kgdb_break(struct pt_regs *regs)
81{ 81{
82 if (kgdb_handle_exception(1, SIGTRAP, 0, regs) != 0) 82 if (kgdb_handle_exception(1, SIGTRAP, 0, regs) != 0)
83 return 0; 83 return;
84 84
85 /* Jump over the first arch_kgdb_breakpoint which is barrier to 85 /* Jump over the first arch_kgdb_breakpoint which is barrier to
86 * get kgdb work. The same solution is used for powerpc */ 86 * get kgdb work. The same solution is used for powerpc */
@@ -114,7 +114,6 @@ int kgdb_arch_handle_exception(int vector, int signo, int err_code,
114{ 114{
115 char *ptr; 115 char *ptr;
116 unsigned long address; 116 unsigned long address;
117 int cpu = smp_processor_id();
118 117
119 switch (remcom_in_buffer[0]) { 118 switch (remcom_in_buffer[0]) {
120 case 'c': 119 case 'c':
@@ -143,5 +142,9 @@ void kgdb_arch_exit(void)
143 * Global data 142 * Global data
144 */ 143 */
145struct kgdb_arch arch_kgdb_ops = { 144struct kgdb_arch arch_kgdb_ops = {
145#ifdef __MICROBLAZEEL__
146 .gdb_bpt_instr = {0x18, 0x00, 0x0c, 0xba}, /* brki r16, 0x18 */
147#else
146 .gdb_bpt_instr = {0xba, 0x0c, 0x00, 0x18}, /* brki r16, 0x18 */ 148 .gdb_bpt_instr = {0xba, 0x0c, 0x00, 0x18}, /* brki r16, 0x18 */
149#endif
147}; 150};
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index ff85f7718035..5cb034174005 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -15,37 +15,13 @@
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16 16
17#include <asm/checksum.h> 17#include <asm/checksum.h>
18#include <asm/cacheflush.h>
18#include <linux/io.h> 19#include <linux/io.h>
19#include <asm/page.h> 20#include <asm/page.h>
20#include <asm/system.h> 21#include <asm/system.h>
21#include <linux/ftrace.h> 22#include <linux/ftrace.h>
22#include <linux/uaccess.h> 23#include <linux/uaccess.h>
23 24
24/*
25 * libgcc functions - functions that are used internally by the
26 * compiler... (prototypes are not correct though, but that
27 * doesn't really matter since they're not versioned).
28 */
29extern void __ashldi3(void);
30EXPORT_SYMBOL(__ashldi3);
31extern void __ashrdi3(void);
32EXPORT_SYMBOL(__ashrdi3);
33extern void __divsi3(void);
34EXPORT_SYMBOL(__divsi3);
35extern void __lshrdi3(void);
36EXPORT_SYMBOL(__lshrdi3);
37extern void __modsi3(void);
38EXPORT_SYMBOL(__modsi3);
39extern void __mulsi3(void);
40EXPORT_SYMBOL(__mulsi3);
41extern void __muldi3(void);
42EXPORT_SYMBOL(__muldi3);
43extern void __ucmpdi2(void);
44EXPORT_SYMBOL(__ucmpdi2);
45extern void __udivsi3(void);
46EXPORT_SYMBOL(__udivsi3);
47extern void __umodsi3(void);
48EXPORT_SYMBOL(__umodsi3);
49extern char *_ebss; 25extern char *_ebss;
50EXPORT_SYMBOL_GPL(_ebss); 26EXPORT_SYMBOL_GPL(_ebss);
51#ifdef CONFIG_FUNCTION_TRACER 27#ifdef CONFIG_FUNCTION_TRACER
@@ -63,3 +39,9 @@ EXPORT_SYMBOL(__strncpy_user);
63EXPORT_SYMBOL(memcpy); 39EXPORT_SYMBOL(memcpy);
64EXPORT_SYMBOL(memmove); 40EXPORT_SYMBOL(memmove);
65#endif 41#endif
42
43#ifdef CONFIG_MMU
44EXPORT_SYMBOL(empty_zero_page);
45#endif
46
47EXPORT_SYMBOL(mbc);
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 427b13b4740f..a105301e2b7f 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);
@@ -77,11 +72,12 @@ static int __init early_init_dt_scan_serial(unsigned long node,
77/* find compatible node with uartlite */ 72/* find compatible node with uartlite */
78 p = of_get_flat_dt_prop(node, "compatible", &l); 73 p = of_get_flat_dt_prop(node, "compatible", &l);
79 if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) && 74 if ((strncmp(p, "xlnx,xps-uartlite", 17) != 0) &&
80 (strncmp(p, "xlnx,opb-uartlite", 17) != 0)) 75 (strncmp(p, "xlnx,opb-uartlite", 17) != 0) &&
76 (strncmp(p, "xlnx,axi-uartlite", 17) != 0))
81 return 0; 77 return 0;
82 78
83 addr = of_get_flat_dt_prop(node, "reg", &l); 79 addr = of_get_flat_dt_prop(node, "reg", &l);
84 return *addr; /* return address */ 80 return be32_to_cpup(addr); /* return address */
85} 81}
86 82
87/* this function is looking for early uartlite console - Microblaze specific */ 83/* this function is looking for early uartlite console - Microblaze specific */
@@ -89,6 +85,40 @@ int __init early_uartlite_console(void)
89{ 85{
90 return of_scan_flat_dt(early_init_dt_scan_serial, NULL); 86 return of_scan_flat_dt(early_init_dt_scan_serial, NULL);
91} 87}
88
89/* MS this is Microblaze specifig function */
90static int __init early_init_dt_scan_serial_full(unsigned long node,
91 const char *uname, int depth, void *data)
92{
93 unsigned long l;
94 char *p;
95 unsigned int addr;
96
97 pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
98
99/* find all serial nodes */
100 if (strncmp(uname, "serial", 6) != 0)
101 return 0;
102
103 early_init_dt_check_for_initrd(node);
104
105/* find compatible node with uartlite */
106 p = of_get_flat_dt_prop(node, "compatible", &l);
107
108 if ((strncmp(p, "xlnx,xps-uart16550", 18) != 0) &&
109 (strncmp(p, "xlnx,axi-uart16550", 18) != 0))
110 return 0;
111
112 addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
113 addr += *(u32 *)of_get_flat_dt_prop(node, "reg-offset", &l);
114 return be32_to_cpu(addr); /* return address */
115}
116
117/* this function is looking for early uartlite console - Microblaze specific */
118int __init early_uart16550_console(void)
119{
120 return of_scan_flat_dt(early_init_dt_scan_serial_full, NULL);
121}
92#endif 122#endif
93 123
94void __init early_init_devtree(void *params) 124void __init early_init_devtree(void *params)
diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrace.c
index dc03ffc8174a..05ac8cc975d5 100644
--- a/arch/microblaze/kernel/ptrace.c
+++ b/arch/microblaze/kernel/ptrace.c
@@ -73,7 +73,8 @@ static microblaze_reg_t *reg_save_addr(unsigned reg_offs,
73 return (microblaze_reg_t *)((char *)regs + reg_offs); 73 return (microblaze_reg_t *)((char *)regs + reg_offs);
74} 74}
75 75
76long arch_ptrace(struct task_struct *child, long request, long addr, long data) 76long arch_ptrace(struct task_struct *child, long request,
77 unsigned long addr, unsigned long data)
77{ 78{
78 int rval; 79 int rval;
79 unsigned long val = 0; 80 unsigned long val = 0;
@@ -99,7 +100,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
99 } else { 100 } else {
100 rval = -EIO; 101 rval = -EIO;
101 } 102 }
102 } else if (addr >= 0 && addr < PT_SIZE && (addr & 0x3) == 0) { 103 } else if (addr < PT_SIZE && (addr & 0x3) == 0) {
103 microblaze_reg_t *reg_addr = reg_save_addr(addr, child); 104 microblaze_reg_t *reg_addr = reg_save_addr(addr, child);
104 if (request == PTRACE_PEEKUSR) 105 if (request == PTRACE_PEEKUSR)
105 val = *reg_addr; 106 val = *reg_addr;
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index f5f768842354..bb1558e4b283 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -92,12 +92,6 @@ inline unsigned get_romfs_len(unsigned *addr)
92} 92}
93#endif /* CONFIG_MTD_UCLINUX_EBSS */ 93#endif /* CONFIG_MTD_UCLINUX_EBSS */
94 94
95#if defined(CONFIG_EARLY_PRINTK) && defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
96#define eprintk early_printk
97#else
98#define eprintk printk
99#endif
100
101void __init machine_early_init(const char *cmdline, unsigned int ram, 95void __init machine_early_init(const char *cmdline, unsigned int ram,
102 unsigned int fdt, unsigned int msr) 96 unsigned int fdt, unsigned int msr)
103{ 97{
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index 03376dc814c9..e88a930fd1e3 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -372,3 +372,6 @@ ENTRY(sys_call_table)
372 .long sys_rt_tgsigqueueinfo /* 365 */ 372 .long sys_rt_tgsigqueueinfo /* 365 */
373 .long sys_perf_event_open 373 .long sys_perf_event_open
374 .long sys_recvmmsg 374 .long sys_recvmmsg
375 .long sys_fanotify_init
376 .long sys_fanotify_mark
377 .long sys_prlimit64 /* 370 */
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index b1380ae93ae1..a5aa33db1df3 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -38,6 +38,9 @@ static unsigned int timer_baseaddr;
38#define TIMER_BASE timer_baseaddr 38#define TIMER_BASE timer_baseaddr
39#endif 39#endif
40 40
41unsigned int freq_div_hz;
42unsigned int timer_clock_freq;
43
41#define TCSR0 (0x00) 44#define TCSR0 (0x00)
42#define TLR0 (0x04) 45#define TLR0 (0x04)
43#define TCR0 (0x08) 46#define TCR0 (0x08)
@@ -115,7 +118,7 @@ static void microblaze_timer_set_mode(enum clock_event_mode mode,
115 switch (mode) { 118 switch (mode) {
116 case CLOCK_EVT_MODE_PERIODIC: 119 case CLOCK_EVT_MODE_PERIODIC:
117 printk(KERN_INFO "%s: periodic\n", __func__); 120 printk(KERN_INFO "%s: periodic\n", __func__);
118 microblaze_timer0_start_periodic(cpuinfo.freq_div_hz); 121 microblaze_timer0_start_periodic(freq_div_hz);
119 break; 122 break;
120 case CLOCK_EVT_MODE_ONESHOT: 123 case CLOCK_EVT_MODE_ONESHOT:
121 printk(KERN_INFO "%s: oneshot\n", __func__); 124 printk(KERN_INFO "%s: oneshot\n", __func__);
@@ -168,7 +171,7 @@ static struct irqaction timer_irqaction = {
168static __init void microblaze_clockevent_init(void) 171static __init void microblaze_clockevent_init(void)
169{ 172{
170 clockevent_microblaze_timer.mult = 173 clockevent_microblaze_timer.mult =
171 div_sc(cpuinfo.cpu_clock_freq, NSEC_PER_SEC, 174 div_sc(timer_clock_freq, NSEC_PER_SEC,
172 clockevent_microblaze_timer.shift); 175 clockevent_microblaze_timer.shift);
173 clockevent_microblaze_timer.max_delta_ns = 176 clockevent_microblaze_timer.max_delta_ns =
174 clockevent_delta2ns((u32)~0, &clockevent_microblaze_timer); 177 clockevent_delta2ns((u32)~0, &clockevent_microblaze_timer);
@@ -201,7 +204,7 @@ static struct cyclecounter microblaze_cc = {
201 204
202int __init init_microblaze_timecounter(void) 205int __init init_microblaze_timecounter(void)
203{ 206{
204 microblaze_cc.mult = div_sc(cpuinfo.cpu_clock_freq, NSEC_PER_SEC, 207 microblaze_cc.mult = div_sc(timer_clock_freq, NSEC_PER_SEC,
205 microblaze_cc.shift); 208 microblaze_cc.shift);
206 209
207 timecounter_init(&microblaze_tc, &microblaze_cc, sched_clock()); 210 timecounter_init(&microblaze_tc, &microblaze_cc, sched_clock());
@@ -221,7 +224,7 @@ static struct clocksource clocksource_microblaze = {
221static int __init microblaze_clocksource_init(void) 224static int __init microblaze_clocksource_init(void)
222{ 225{
223 clocksource_microblaze.mult = 226 clocksource_microblaze.mult =
224 clocksource_hz2mult(cpuinfo.cpu_clock_freq, 227 clocksource_hz2mult(timer_clock_freq,
225 clocksource_microblaze.shift); 228 clocksource_microblaze.shift);
226 if (clocksource_register(&clocksource_microblaze)) 229 if (clocksource_register(&clocksource_microblaze))
227 panic("failed to register clocksource"); 230 panic("failed to register clocksource");
@@ -247,6 +250,7 @@ void __init time_init(void)
247 u32 irq, i = 0; 250 u32 irq, i = 0;
248 u32 timer_num = 1; 251 u32 timer_num = 1;
249 struct device_node *timer = NULL; 252 struct device_node *timer = NULL;
253 const void *prop;
250#ifdef CONFIG_SELFMOD_TIMER 254#ifdef CONFIG_SELFMOD_TIMER
251 unsigned int timer_baseaddr = 0; 255 unsigned int timer_baseaddr = 0;
252 int arr_func[] = { 256 int arr_func[] = {
@@ -258,12 +262,10 @@ void __init time_init(void)
258 0 262 0
259 }; 263 };
260#endif 264#endif
261 char *timer_list[] = { 265 const char * const timer_list[] = {
262 "xlnx,xps-timer-1.00.a", 266 "xlnx,xps-timer-1.00.a",
263 "xlnx,opb-timer-1.00.b", 267 NULL
264 "xlnx,opb-timer-1.00.a", 268 };
265 NULL
266 };
267 269
268 for (i = 0; timer_list[i] != NULL; i++) { 270 for (i = 0; timer_list[i] != NULL; i++) {
269 timer = of_find_compatible_node(NULL, NULL, timer_list[i]); 271 timer = of_find_compatible_node(NULL, NULL, timer_list[i]);
@@ -272,13 +274,13 @@ void __init time_init(void)
272 } 274 }
273 BUG_ON(!timer); 275 BUG_ON(!timer);
274 276
275 timer_baseaddr = *(int *) of_get_property(timer, "reg", NULL); 277 timer_baseaddr = be32_to_cpup(of_get_property(timer, "reg", NULL));
276 timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); 278 timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE);
277 irq = *(int *) of_get_property(timer, "interrupts", NULL); 279 irq = be32_to_cpup(of_get_property(timer, "interrupts", NULL));
278 timer_num = 280 timer_num = be32_to_cpup(of_get_property(timer,
279 *(int *) of_get_property(timer, "xlnx,one-timer-only", NULL); 281 "xlnx,one-timer-only", NULL));
280 if (timer_num) { 282 if (timer_num) {
281 printk(KERN_EMERG "Please enable two timers in HW\n"); 283 eprintk(KERN_EMERG "Please enable two timers in HW\n");
282 BUG(); 284 BUG();
283 } 285 }
284 286
@@ -288,7 +290,14 @@ void __init time_init(void)
288 printk(KERN_INFO "%s #0 at 0x%08x, irq=%d\n", 290 printk(KERN_INFO "%s #0 at 0x%08x, irq=%d\n",
289 timer_list[i], timer_baseaddr, irq); 291 timer_list[i], timer_baseaddr, irq);
290 292
291 cpuinfo.freq_div_hz = cpuinfo.cpu_clock_freq / HZ; 293 /* If there is clock-frequency property than use it */
294 prop = of_get_property(timer, "clock-frequency", NULL);
295 if (prop)
296 timer_clock_freq = be32_to_cpup(prop);
297 else
298 timer_clock_freq = cpuinfo.cpu_clock_freq;
299
300 freq_div_hz = timer_clock_freq / HZ;
292 301
293 setup_irq(irq, &timer_irqaction); 302 setup_irq(irq, &timer_irqaction);
294#ifdef CONFIG_HEART_BEAT 303#ifdef CONFIG_HEART_BEAT
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index a09f2962fbec..96a88c31fe48 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -8,7 +8,6 @@
8 * for more details. 8 * for more details.
9 */ 9 */
10 10
11OUTPUT_FORMAT("elf32-microblaze", "elf32-microblaze", "elf32-microblaze")
12OUTPUT_ARCH(microblaze) 11OUTPUT_ARCH(microblaze)
13ENTRY(microblaze_start) 12ENTRY(microblaze_start)
14 13
@@ -16,7 +15,11 @@ ENTRY(microblaze_start)
16#include <asm-generic/vmlinux.lds.h> 15#include <asm-generic/vmlinux.lds.h>
17#include <asm/thread_info.h> 16#include <asm/thread_info.h>
18 17
18#ifdef __MICROBLAZEEL__
19jiffies = jiffies_64;
20#else
19jiffies = jiffies_64 + 4; 21jiffies = jiffies_64 + 4;
22#endif
20 23
21SECTIONS { 24SECTIONS {
22 . = CONFIG_KERNEL_START; 25 . = CONFIG_KERNEL_START;
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index 4dfe47d3cd91..f1fcbff3da25 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -11,3 +11,13 @@ lib-y += memcpy.o memmove.o
11endif 11endif
12 12
13lib-y += uaccess_old.o 13lib-y += uaccess_old.o
14
15lib-y += ashldi3.o
16lib-y += ashrdi3.o
17lib-y += divsi3.o
18lib-y += lshrdi3.o
19lib-y += modsi3.o
20lib-y += muldi3.o
21lib-y += mulsi3.o
22lib-y += udivsi3.o
23lib-y += umodsi3.o
diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c
new file mode 100644
index 000000000000..beb80f316095
--- /dev/null
+++ b/arch/microblaze/lib/ashldi3.c
@@ -0,0 +1,29 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __ashldi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 w.s.low = 0;
18 w.s.high = (unsigned int) uu.s.low << -bm;
19 } else {
20 const unsigned int carries = (unsigned int) uu.s.low >> bm;
21
22 w.s.low = (unsigned int) uu.s.low << b;
23 w.s.high = ((unsigned int) uu.s.high << b) | carries;
24 }
25
26 return w.ll;
27}
28
29EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c
new file mode 100644
index 000000000000..c884a912b660
--- /dev/null
+++ b/arch/microblaze/lib/ashrdi3.c
@@ -0,0 +1,31 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __ashrdi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 /* w.s.high = 1..1 or 0..0 */
18 w.s.high =
19 uu.s.high >> 31;
20 w.s.low = uu.s.high >> -bm;
21 } else {
22 const unsigned int carries = (unsigned int) uu.s.high << bm;
23
24 w.s.high = uu.s.high >> b;
25 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
26 }
27
28 return w.ll;
29}
30
31EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/microblaze/lib/divsi3.S b/arch/microblaze/lib/divsi3.S
new file mode 100644
index 000000000000..595b02d6e86b
--- /dev/null
+++ b/arch/microblaze/lib/divsi3.S
@@ -0,0 +1,73 @@
1#include <linux/linkage.h>
2
3/*
4* Divide operation for 32 bit integers.
5* Input : Dividend in Reg r5
6* Divisor in Reg r6
7* Output: Result in Reg r3
8*/
9 .text
10 .globl __divsi3
11 .type __divsi3, @function
12 .ent __divsi3
13__divsi3:
14 .frame r1, 0, r15
15
16 addik r1, r1, -16
17 swi r28, r1, 0
18 swi r29, r1, 4
19 swi r30, r1, 8
20 swi r31, r1, 12
21
22 beqi r6, div_by_zero /* div_by_zero - division error */
23 beqi r5, result_is_zero /* result is zero */
24 bgeid r5, r5_pos
25 xor r28, r5, r6 /* get the sign of the result */
26 rsubi r5, r5, 0 /* make r5 positive */
27r5_pos:
28 bgei r6, r6_pos
29 rsubi r6, r6, 0 /* make r6 positive */
30r6_pos:
31 addik r30, r0, 0 /* clear mod */
32 addik r3, r0, 0 /* clear div */
33 addik r29, r0, 32 /* initialize the loop count */
34
35 /* first part try to find the first '1' in the r5 */
36div0:
37 blti r5, div2 /* this traps r5 == 0x80000000 */
38div1:
39 add r5, r5, r5 /* left shift logical r5 */
40 bgtid r5, div1
41 addik r29, r29, -1
42div2:
43 /* left shift logical r5 get the '1' into the carry */
44 add r5, r5, r5
45 addc r30, r30, r30 /* move that bit into the mod register */
46 rsub r31, r6, r30 /* try to subtract (r30 a r6) */
47 blti r31, mod_too_small
48 /* move the r31 to mod since the result was positive */
49 or r30, r0, r31
50 addik r3, r3, 1
51mod_too_small:
52 addik r29, r29, -1
53 beqi r29, loop_end
54 add r3, r3, r3 /* shift in the '1' into div */
55 bri div2 /* div2 */
56loop_end:
57 bgei r28, return_here
58 brid return_here
59 rsubi r3, r3, 0 /* negate the result */
60div_by_zero:
61result_is_zero:
62 or r3, r0, r0 /* set result to 0 */
63return_here:
64/* restore values of csrs and that of r3 and the divisor and the dividend */
65 lwi r28, r1, 0
66 lwi r29, r1, 4
67 lwi r30, r1, 8
68 lwi r31, r1, 12
69 rtsd r15, 8
70 addik r1, r1, 16
71
72.size __divsi3, . - __divsi3
73.end __divsi3
diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h
new file mode 100644
index 000000000000..05909d58e2fe
--- /dev/null
+++ b/arch/microblaze/lib/libgcc.h
@@ -0,0 +1,25 @@
1#ifndef __ASM_LIBGCC_H
2#define __ASM_LIBGCC_H
3
4#include <asm/byteorder.h>
5
6typedef int word_type __attribute__ ((mode (__word__)));
7
8#ifdef __BIG_ENDIAN
9struct DWstruct {
10 int high, low;
11};
12#elif defined(__LITTLE_ENDIAN)
13struct DWstruct {
14 int low, high;
15};
16#else
17#error I feel sick.
18#endif
19
20typedef union {
21 struct DWstruct s;
22 long long ll;
23} DWunion;
24
25#endif /* __ASM_LIBGCC_H */
diff --git a/arch/microblaze/lib/lshrdi3.c b/arch/microblaze/lib/lshrdi3.c
new file mode 100644
index 000000000000..dcf8d6810b7c
--- /dev/null
+++ b/arch/microblaze/lib/lshrdi3.c
@@ -0,0 +1,29 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __lshrdi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 w.s.high = 0;
18 w.s.low = (unsigned int) uu.s.high >> -bm;
19 } else {
20 const unsigned int carries = (unsigned int) uu.s.high << bm;
21
22 w.s.high = (unsigned int) uu.s.high >> b;
23 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
24 }
25
26 return w.ll;
27}
28
29EXPORT_SYMBOL(__lshrdi3);
diff --git a/arch/microblaze/lib/memcpy.c b/arch/microblaze/lib/memcpy.c
index 014bac92bdff..cc495d7d99cc 100644
--- a/arch/microblaze/lib/memcpy.c
+++ b/arch/microblaze/lib/memcpy.c
@@ -33,17 +33,24 @@
33#include <asm/system.h> 33#include <asm/system.h>
34 34
35#ifdef __HAVE_ARCH_MEMCPY 35#ifdef __HAVE_ARCH_MEMCPY
36#ifndef CONFIG_OPT_LIB_FUNCTION
36void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) 37void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
37{ 38{
38 const char *src = v_src; 39 const char *src = v_src;
39 char *dst = v_dst; 40 char *dst = v_dst;
40#ifndef CONFIG_OPT_LIB_FUNCTION 41
41 /* Simple, byte oriented memcpy. */ 42 /* Simple, byte oriented memcpy. */
42 while (c--) 43 while (c--)
43 *dst++ = *src++; 44 *dst++ = *src++;
44 45
45 return v_dst; 46 return v_dst;
46#else 47}
48#else /* CONFIG_OPT_LIB_FUNCTION */
49void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
50{
51 const char *src = v_src;
52 char *dst = v_dst;
53
47 /* The following code tries to optimize the copy by using unsigned 54 /* The following code tries to optimize the copy by using unsigned
48 * alignment. This will work fine if both source and destination are 55 * alignment. This will work fine if both source and destination are
49 * aligned on the same boundary. However, if they are aligned on 56 * aligned on the same boundary. However, if they are aligned on
@@ -86,7 +93,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
86 case 0x1: /* Unaligned - Off by 1 */ 93 case 0x1: /* Unaligned - Off by 1 */
87 /* Word align the source */ 94 /* Word align the source */
88 i_src = (const void *) ((unsigned)src & ~3); 95 i_src = (const void *) ((unsigned)src & ~3);
89 96#ifndef __MICROBLAZEEL__
90 /* Load the holding buffer */ 97 /* Load the holding buffer */
91 buf_hold = *i_src++ << 8; 98 buf_hold = *i_src++ << 8;
92 99
@@ -95,7 +102,16 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
95 *i_dst++ = buf_hold | value >> 24; 102 *i_dst++ = buf_hold | value >> 24;
96 buf_hold = value << 8; 103 buf_hold = value << 8;
97 } 104 }
105#else
106 /* Load the holding buffer */
107 buf_hold = (*i_src++ & 0xFFFFFF00) >>8;
98 108
109 for (; c >= 4; c -= 4) {
110 value = *i_src++;
111 *i_dst++ = buf_hold | ((value & 0xFF) << 24);
112 buf_hold = (value & 0xFFFFFF00) >>8;
113 }
114#endif
99 /* Realign the source */ 115 /* Realign the source */
100 src = (const void *)i_src; 116 src = (const void *)i_src;
101 src -= 3; 117 src -= 3;
@@ -103,7 +119,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
103 case 0x2: /* Unaligned - Off by 2 */ 119 case 0x2: /* Unaligned - Off by 2 */
104 /* Word align the source */ 120 /* Word align the source */
105 i_src = (const void *) ((unsigned)src & ~3); 121 i_src = (const void *) ((unsigned)src & ~3);
106 122#ifndef __MICROBLAZEEL__
107 /* Load the holding buffer */ 123 /* Load the holding buffer */
108 buf_hold = *i_src++ << 16; 124 buf_hold = *i_src++ << 16;
109 125
@@ -112,7 +128,16 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
112 *i_dst++ = buf_hold | value >> 16; 128 *i_dst++ = buf_hold | value >> 16;
113 buf_hold = value << 16; 129 buf_hold = value << 16;
114 } 130 }
131#else
132 /* Load the holding buffer */
133 buf_hold = (*i_src++ & 0xFFFF0000 )>>16;
115 134
135 for (; c >= 4; c -= 4) {
136 value = *i_src++;
137 *i_dst++ = buf_hold | ((value & 0xFFFF)<<16);
138 buf_hold = (value & 0xFFFF0000) >>16;
139 }
140#endif
116 /* Realign the source */ 141 /* Realign the source */
117 src = (const void *)i_src; 142 src = (const void *)i_src;
118 src -= 2; 143 src -= 2;
@@ -120,7 +145,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
120 case 0x3: /* Unaligned - Off by 3 */ 145 case 0x3: /* Unaligned - Off by 3 */
121 /* Word align the source */ 146 /* Word align the source */
122 i_src = (const void *) ((unsigned)src & ~3); 147 i_src = (const void *) ((unsigned)src & ~3);
123 148#ifndef __MICROBLAZEEL__
124 /* Load the holding buffer */ 149 /* Load the holding buffer */
125 buf_hold = *i_src++ << 24; 150 buf_hold = *i_src++ << 24;
126 151
@@ -129,7 +154,16 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
129 *i_dst++ = buf_hold | value >> 8; 154 *i_dst++ = buf_hold | value >> 8;
130 buf_hold = value << 24; 155 buf_hold = value << 24;
131 } 156 }
157#else
158 /* Load the holding buffer */
159 buf_hold = (*i_src++ & 0xFF000000) >> 24;
132 160
161 for (; c >= 4; c -= 4) {
162 value = *i_src++;
163 *i_dst++ = buf_hold | ((value & 0xFFFFFF) << 8);
164 buf_hold = (value & 0xFF000000) >> 24;
165 }
166#endif
133 /* Realign the source */ 167 /* Realign the source */
134 src = (const void *)i_src; 168 src = (const void *)i_src;
135 src -= 1; 169 src -= 1;
@@ -150,7 +184,7 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
150 } 184 }
151 185
152 return v_dst; 186 return v_dst;
153#endif
154} 187}
188#endif /* CONFIG_OPT_LIB_FUNCTION */
155EXPORT_SYMBOL(memcpy); 189EXPORT_SYMBOL(memcpy);
156#endif /* __HAVE_ARCH_MEMCPY */ 190#endif /* __HAVE_ARCH_MEMCPY */
diff --git a/arch/microblaze/lib/memmove.c b/arch/microblaze/lib/memmove.c
index 0929198c5e68..123e3616f2dd 100644
--- a/arch/microblaze/lib/memmove.c
+++ b/arch/microblaze/lib/memmove.c
@@ -31,16 +31,12 @@
31#include <linux/string.h> 31#include <linux/string.h>
32 32
33#ifdef __HAVE_ARCH_MEMMOVE 33#ifdef __HAVE_ARCH_MEMMOVE
34#ifndef CONFIG_OPT_LIB_FUNCTION
34void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) 35void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
35{ 36{
36 const char *src = v_src; 37 const char *src = v_src;
37 char *dst = v_dst; 38 char *dst = v_dst;
38 39
39#ifdef CONFIG_OPT_LIB_FUNCTION
40 const uint32_t *i_src;
41 uint32_t *i_dst;
42#endif
43
44 if (!c) 40 if (!c)
45 return v_dst; 41 return v_dst;
46 42
@@ -48,7 +44,6 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
48 if (v_dst <= v_src) 44 if (v_dst <= v_src)
49 return memcpy(v_dst, v_src, c); 45 return memcpy(v_dst, v_src, c);
50 46
51#ifndef CONFIG_OPT_LIB_FUNCTION
52 /* copy backwards, from end to beginning */ 47 /* copy backwards, from end to beginning */
53 src += c; 48 src += c;
54 dst += c; 49 dst += c;
@@ -58,7 +53,22 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
58 *--dst = *--src; 53 *--dst = *--src;
59 54
60 return v_dst; 55 return v_dst;
61#else 56}
57#else /* CONFIG_OPT_LIB_FUNCTION */
58void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
59{
60 const char *src = v_src;
61 char *dst = v_dst;
62 const uint32_t *i_src;
63 uint32_t *i_dst;
64
65 if (!c)
66 return v_dst;
67
68 /* Use memcpy when source is higher than dest */
69 if (v_dst <= v_src)
70 return memcpy(v_dst, v_src, c);
71
62 /* The following code tries to optimize the copy by using unsigned 72 /* The following code tries to optimize the copy by using unsigned
63 * alignment. This will work fine if both source and destination are 73 * alignment. This will work fine if both source and destination are
64 * aligned on the same boundary. However, if they are aligned on 74 * aligned on the same boundary. However, if they are aligned on
@@ -104,7 +114,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
104 case 0x1: /* Unaligned - Off by 1 */ 114 case 0x1: /* Unaligned - Off by 1 */
105 /* Word align the source */ 115 /* Word align the source */
106 i_src = (const void *) (((unsigned)src + 4) & ~3); 116 i_src = (const void *) (((unsigned)src + 4) & ~3);
107 117#ifndef __MICROBLAZEEL__
108 /* Load the holding buffer */ 118 /* Load the holding buffer */
109 buf_hold = *--i_src >> 24; 119 buf_hold = *--i_src >> 24;
110 120
@@ -113,7 +123,16 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
113 *--i_dst = buf_hold << 8 | value; 123 *--i_dst = buf_hold << 8 | value;
114 buf_hold = value >> 24; 124 buf_hold = value >> 24;
115 } 125 }
126#else
127 /* Load the holding buffer */
128 buf_hold = (*--i_src & 0xFF) << 24;
116 129
130 for (; c >= 4; c -= 4) {
131 value = *--i_src;
132 *--i_dst = buf_hold | ((value & 0xFFFFFF00)>>8);
133 buf_hold = (value & 0xFF) << 24;
134 }
135#endif
117 /* Realign the source */ 136 /* Realign the source */
118 src = (const void *)i_src; 137 src = (const void *)i_src;
119 src += 1; 138 src += 1;
@@ -121,7 +140,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
121 case 0x2: /* Unaligned - Off by 2 */ 140 case 0x2: /* Unaligned - Off by 2 */
122 /* Word align the source */ 141 /* Word align the source */
123 i_src = (const void *) (((unsigned)src + 4) & ~3); 142 i_src = (const void *) (((unsigned)src + 4) & ~3);
124 143#ifndef __MICROBLAZEEL__
125 /* Load the holding buffer */ 144 /* Load the holding buffer */
126 buf_hold = *--i_src >> 16; 145 buf_hold = *--i_src >> 16;
127 146
@@ -130,7 +149,16 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
130 *--i_dst = buf_hold << 16 | value; 149 *--i_dst = buf_hold << 16 | value;
131 buf_hold = value >> 16; 150 buf_hold = value >> 16;
132 } 151 }
152#else
153 /* Load the holding buffer */
154 buf_hold = (*--i_src & 0xFFFF) << 16;
133 155
156 for (; c >= 4; c -= 4) {
157 value = *--i_src;
158 *--i_dst = buf_hold | ((value & 0xFFFF0000)>>16);
159 buf_hold = (value & 0xFFFF) << 16;
160 }
161#endif
134 /* Realign the source */ 162 /* Realign the source */
135 src = (const void *)i_src; 163 src = (const void *)i_src;
136 src += 2; 164 src += 2;
@@ -138,7 +166,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
138 case 0x3: /* Unaligned - Off by 3 */ 166 case 0x3: /* Unaligned - Off by 3 */
139 /* Word align the source */ 167 /* Word align the source */
140 i_src = (const void *) (((unsigned)src + 4) & ~3); 168 i_src = (const void *) (((unsigned)src + 4) & ~3);
141 169#ifndef __MICROBLAZEEL__
142 /* Load the holding buffer */ 170 /* Load the holding buffer */
143 buf_hold = *--i_src >> 8; 171 buf_hold = *--i_src >> 8;
144 172
@@ -147,7 +175,16 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
147 *--i_dst = buf_hold << 24 | value; 175 *--i_dst = buf_hold << 24 | value;
148 buf_hold = value >> 8; 176 buf_hold = value >> 8;
149 } 177 }
178#else
179 /* Load the holding buffer */
180 buf_hold = (*--i_src & 0xFFFFFF) << 8;
150 181
182 for (; c >= 4; c -= 4) {
183 value = *--i_src;
184 *--i_dst = buf_hold | ((value & 0xFF000000)>> 24);
185 buf_hold = (value & 0xFFFFFF) << 8;;
186 }
187#endif
151 /* Realign the source */ 188 /* Realign the source */
152 src = (const void *)i_src; 189 src = (const void *)i_src;
153 src += 3; 190 src += 3;
@@ -169,7 +206,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c)
169 *--dst = *--src; 206 *--dst = *--src;
170 } 207 }
171 return v_dst; 208 return v_dst;
172#endif
173} 209}
210#endif /* CONFIG_OPT_LIB_FUNCTION */
174EXPORT_SYMBOL(memmove); 211EXPORT_SYMBOL(memmove);
175#endif /* __HAVE_ARCH_MEMMOVE */ 212#endif /* __HAVE_ARCH_MEMMOVE */
diff --git a/arch/microblaze/lib/memset.c b/arch/microblaze/lib/memset.c
index ecfb663e1fc1..834565d1607e 100644
--- a/arch/microblaze/lib/memset.c
+++ b/arch/microblaze/lib/memset.c
@@ -31,17 +31,30 @@
31#include <linux/string.h> 31#include <linux/string.h>
32 32
33#ifdef __HAVE_ARCH_MEMSET 33#ifdef __HAVE_ARCH_MEMSET
34#ifndef CONFIG_OPT_LIB_FUNCTION
35void *memset(void *v_src, int c, __kernel_size_t n)
36{
37 char *src = v_src;
38
39 /* Truncate c to 8 bits */
40 c = (c & 0xFF);
41
42 /* Simple, byte oriented memset or the rest of count. */
43 while (n--)
44 *src++ = c;
45
46 return v_src;
47}
48#else /* CONFIG_OPT_LIB_FUNCTION */
34void *memset(void *v_src, int c, __kernel_size_t n) 49void *memset(void *v_src, int c, __kernel_size_t n)
35{ 50{
36 char *src = v_src; 51 char *src = v_src;
37#ifdef CONFIG_OPT_LIB_FUNCTION
38 uint32_t *i_src; 52 uint32_t *i_src;
39 uint32_t w32 = 0; 53 uint32_t w32 = 0;
40#endif 54
41 /* Truncate c to 8 bits */ 55 /* Truncate c to 8 bits */
42 c = (c & 0xFF); 56 c = (c & 0xFF);
43 57
44#ifdef CONFIG_OPT_LIB_FUNCTION
45 if (unlikely(c)) { 58 if (unlikely(c)) {
46 /* Make a repeating word out of it */ 59 /* Make a repeating word out of it */
47 w32 = c; 60 w32 = c;
@@ -72,12 +85,13 @@ void *memset(void *v_src, int c, __kernel_size_t n)
72 85
73 src = (void *)i_src; 86 src = (void *)i_src;
74 } 87 }
75#endif 88
76 /* Simple, byte oriented memset or the rest of count. */ 89 /* Simple, byte oriented memset or the rest of count. */
77 while (n--) 90 while (n--)
78 *src++ = c; 91 *src++ = c;
79 92
80 return v_src; 93 return v_src;
81} 94}
95#endif /* CONFIG_OPT_LIB_FUNCTION */
82EXPORT_SYMBOL(memset); 96EXPORT_SYMBOL(memset);
83#endif /* __HAVE_ARCH_MEMSET */ 97#endif /* __HAVE_ARCH_MEMSET */
diff --git a/arch/microblaze/lib/modsi3.S b/arch/microblaze/lib/modsi3.S
new file mode 100644
index 000000000000..84e0bee6e8c7
--- /dev/null
+++ b/arch/microblaze/lib/modsi3.S
@@ -0,0 +1,73 @@
1#include <linux/linkage.h>
2
3/*
4* modulo operation for 32 bit integers.
5* Input : op1 in Reg r5
6* op2 in Reg r6
7* Output: op1 mod op2 in Reg r3
8*/
9
10 .text
11 .globl __modsi3
12 .type __modsi3, @function
13 .ent __modsi3
14
15__modsi3:
16 .frame r1, 0, r15
17
18 addik r1, r1, -16
19 swi r28, r1, 0
20 swi r29, r1, 4
21 swi r30, r1, 8
22 swi r31, r1, 12
23
24 beqi r6, div_by_zero /* div_by_zero division error */
25 beqi r5, result_is_zero /* result is zero */
26 bgeid r5, r5_pos
27 /* get the sign of the result [ depends only on the first arg] */
28 add r28, r5, r0
29 rsubi r5, r5, 0 /* make r5 positive */
30r5_pos:
31 bgei r6, r6_pos
32 rsubi r6, r6, 0 /* make r6 positive */
33r6_pos:
34 addik r3, r0, 0 /* clear mod */
35 addik r30, r0, 0 /* clear div */
36 addik r29, r0, 32 /* initialize the loop count */
37/* first part try to find the first '1' in the r5 */
38div1:
39 add r5, r5, r5 /* left shift logical r5 */
40 bgeid r5, div1
41 addik r29, r29, -1
42div2:
43 /* left shift logical r5 get the '1' into the carry */
44 add r5, r5, r5
45 addc r3, r3, r3 /* move that bit into the mod register */
46 rsub r31, r6, r3 /* try to subtract (r30 a r6) */
47 blti r31, mod_too_small
48 /* move the r31 to mod since the result was positive */
49 or r3, r0, r31
50 addik r30, r30, 1
51mod_too_small:
52 addik r29, r29, -1
53 beqi r29, loop_end
54 add r30, r30, r30 /* shift in the '1' into div */
55 bri div2 /* div2 */
56loop_end:
57 bgei r28, return_here
58 brid return_here
59 rsubi r3, r3, 0 /* negate the result */
60div_by_zero:
61result_is_zero:
62 or r3, r0, r0 /* set result to 0 [both mod as well as div are 0] */
63return_here:
64/* restore values of csrs and that of r3 and the divisor and the dividend */
65 lwi r28, r1, 0
66 lwi r29, r1, 4
67 lwi r30, r1, 8
68 lwi r31, r1, 12
69 rtsd r15, 8
70 addik r1, r1, 16
71
72.size __modsi3, . - __modsi3
73.end __modsi3
diff --git a/arch/microblaze/lib/muldi3.S b/arch/microblaze/lib/muldi3.S
new file mode 100644
index 000000000000..ceeaa8c407f2
--- /dev/null
+++ b/arch/microblaze/lib/muldi3.S
@@ -0,0 +1,121 @@
1#include <linux/linkage.h>
2
3/*
4 * Multiply operation for 64 bit integers, for devices with hard multiply
5 * Input : Operand1[H] in Reg r5
6 * Operand1[L] in Reg r6
7 * Operand2[H] in Reg r7
8 * Operand2[L] in Reg r8
9 * Output: Result[H] in Reg r3
10 * Result[L] in Reg r4
11 *
12 * Explaination:
13 *
14 * Both the input numbers are divided into 16 bit number as follows
15 * op1 = A B C D
16 * op2 = E F G H
17 * result = D * H
18 * + (C * H + D * G) << 16
19 * + (B * H + C * G + D * F) << 32
20 * + (A * H + B * G + C * F + D * E) << 48
21 *
22 * Only 64 bits of the output are considered
23 */
24
25 .text
26 .globl __muldi3
27 .type __muldi3, @function
28 .ent __muldi3
29
30__muldi3:
31 addi r1, r1, -40
32
33/* Save the input operands on the caller's stack */
34 swi r5, r1, 44
35 swi r6, r1, 48
36 swi r7, r1, 52
37 swi r8, r1, 56
38
39/* Store all the callee saved registers */
40 sw r20, r1, r0
41 swi r21, r1, 4
42 swi r22, r1, 8
43 swi r23, r1, 12
44 swi r24, r1, 16
45 swi r25, r1, 20
46 swi r26, r1, 24
47 swi r27, r1, 28
48
49/* Load all the 16 bit values for A thru H */
50 lhui r20, r1, 44 /* A */
51 lhui r21, r1, 46 /* B */
52 lhui r22, r1, 48 /* C */
53 lhui r23, r1, 50 /* D */
54 lhui r24, r1, 52 /* E */
55 lhui r25, r1, 54 /* F */
56 lhui r26, r1, 56 /* G */
57 lhui r27, r1, 58 /* H */
58
59/* D * H ==> LSB of the result on stack ==> Store1 */
60 mul r9, r23, r27
61 swi r9, r1, 36 /* Pos2 and Pos3 */
62
63/* Hi (Store1) + C * H + D * G ==> Store2 ==> Pos1 and Pos2 */
64/* Store the carry generated in position 2 for Pos 3 */
65 lhui r11, r1, 36 /* Pos2 */
66 mul r9, r22, r27 /* C * H */
67 mul r10, r23, r26 /* D * G */
68 add r9, r9, r10
69 addc r12, r0, r0
70 add r9, r9, r11
71 addc r12, r12, r0 /* Store the Carry */
72 shi r9, r1, 36 /* Store Pos2 */
73 swi r9, r1, 32
74 lhui r11, r1, 32
75 shi r11, r1, 34 /* Store Pos1 */
76
77/* Hi (Store2) + B * H + C * G + D * F ==> Store3 ==> Pos0 and Pos1 */
78 mul r9, r21, r27 /* B * H */
79 mul r10, r22, r26 /* C * G */
80 mul r7, r23, r25 /* D * F */
81 add r9, r9, r11
82 add r9, r9, r10
83 add r9, r9, r7
84 swi r9, r1, 32 /* Pos0 and Pos1 */
85
86/* Hi (Store3) + A * H + B * G + C * F + D * E ==> Store3 ==> Pos0 */
87 lhui r11, r1, 32 /* Pos0 */
88 mul r9, r20, r27 /* A * H */
89 mul r10, r21, r26 /* B * G */
90 mul r7, r22, r25 /* C * F */
91 mul r8, r23, r24 /* D * E */
92 add r9, r9, r11
93 add r9, r9, r10
94 add r9, r9, r7
95 add r9, r9, r8
96 sext16 r9, r9 /* Sign extend the MSB */
97 shi r9, r1, 32
98
99/* Move results to r3 and r4 */
100 lhui r3, r1, 32
101 add r3, r3, r12
102 shi r3, r1, 32
103 lwi r3, r1, 32 /* Hi Part */
104 lwi r4, r1, 36 /* Lo Part */
105
106/* Restore Callee saved registers */
107 lw r20, r1, r0
108 lwi r21, r1, 4
109 lwi r22, r1, 8
110 lwi r23, r1, 12
111 lwi r24, r1, 16
112 lwi r25, r1, 20
113 lwi r26, r1, 24
114 lwi r27, r1, 28
115
116/* Restore Frame and return */
117 rtsd r15, 8
118 addi r1, r1, 40
119
120.size __muldi3, . - __muldi3
121.end __muldi3
diff --git a/arch/microblaze/lib/mulsi3.S b/arch/microblaze/lib/mulsi3.S
new file mode 100644
index 000000000000..90bd7b93afe6
--- /dev/null
+++ b/arch/microblaze/lib/mulsi3.S
@@ -0,0 +1,46 @@
1#include <linux/linkage.h>
2
3/*
4 * Multiply operation for 32 bit integers.
5 * Input : Operand1 in Reg r5
6 * Operand2 in Reg r6
7 * Output: Result [op1 * op2] in Reg r3
8 */
9 .text
10 .globl __mulsi3
11 .type __mulsi3, @function
12 .ent __mulsi3
13
14__mulsi3:
15 .frame r1, 0, r15
16 add r3, r0, r0
17 beqi r5, result_is_zero /* multiply by zero */
18 beqi r6, result_is_zero /* multiply by zero */
19 bgeid r5, r5_pos
20 xor r4, r5, r6 /* get the sign of the result */
21 rsubi r5, r5, 0 /* make r5 positive */
22r5_pos:
23 bgei r6, r6_pos
24 rsubi r6, r6, 0 /* make r6 positive */
25r6_pos:
26 bri l1
27l2:
28 add r5, r5, r5
29l1:
30 srl r6, r6
31 addc r7, r0, r0
32 beqi r7, l2
33 bneid r6, l2
34 add r3, r3, r5
35 blti r4, negateresult
36 rtsd r15, 8
37 nop
38negateresult:
39 rtsd r15, 8
40 rsub r3, r3, r0
41result_is_zero:
42 rtsd r15, 8
43 addi r3, r0, 0
44
45.size __mulsi3, . - __mulsi3
46.end __mulsi3
diff --git a/arch/microblaze/lib/udivsi3.S b/arch/microblaze/lib/udivsi3.S
new file mode 100644
index 000000000000..64cf57e4bb85
--- /dev/null
+++ b/arch/microblaze/lib/udivsi3.S
@@ -0,0 +1,84 @@
1#include <linux/linkage.h>
2
3/*
4* Unsigned divide operation.
5* Input : Divisor in Reg r5
6* Dividend in Reg r6
7* Output: Result in Reg r3
8*/
9
10 .text
11 .globl __udivsi3
12 .type __udivsi3, @function
13 .ent __udivsi3
14
15__udivsi3:
16
17 .frame r1, 0, r15
18
19 addik r1, r1, -12
20 swi r29, r1, 0
21 swi r30, r1, 4
22 swi r31, r1, 8
23
24 beqi r6, div_by_zero /* div_by_zero /* division error */
25 beqid r5, result_is_zero /* result is zero */
26 addik r30, r0, 0 /* clear mod */
27 addik r29, r0, 32 /* initialize the loop count */
28
29/* check if r6 and r5 are equal - if yes, return 1 */
30 rsub r18, r5, r6
31 beqid r18, return_here
32 addik r3, r0, 1
33
34/* check if (uns)r6 is greater than (uns)r5. in that case, just return 0 */
35 xor r18, r5, r6
36 bgeid r18, 16
37 add r3, r0, r0 /* we would anyways clear r3 */
38 blti r6, return_here /* r6[bit 31 = 1] hence is greater */
39 bri checkr6
40 rsub r18, r6, r5 /* microblazecmp */
41 blti r18, return_here
42
43/* if r6 [bit 31] is set, then return result as 1 */
44checkr6:
45 bgti r6, div0
46 brid return_here
47 addik r3, r0, 1
48
49/* first part try to find the first '1' in the r5 */
50div0:
51 blti r5, div2
52div1:
53 add r5, r5, r5 /* left shift logical r5 */
54 bgtid r5, div1
55 addik r29, r29, -1
56div2:
57/* left shift logical r5 get the '1' into the carry */
58 add r5, r5, r5
59 addc r30, r30, r30 /* move that bit into the mod register */
60 rsub r31, r6, r30 /* try to subtract (r30 a r6) */
61 blti r31, mod_too_small
62/* move the r31 to mod since the result was positive */
63 or r30, r0, r31
64 addik r3, r3, 1
65mod_too_small:
66 addik r29, r29, -1
67 beqi r29, loop_end
68 add r3, r3, r3 /* shift in the '1' into div */
69 bri div2 /* div2 */
70loop_end:
71 bri return_here
72div_by_zero:
73result_is_zero:
74 or r3, r0, r0 /* set result to 0 */
75return_here:
76/* restore values of csrs and that of r3 and the divisor and the dividend */
77 lwi r29, r1, 0
78 lwi r30, r1, 4
79 lwi r31, r1, 8
80 rtsd r15, 8
81 addik r1, r1, 12
82
83.size __udivsi3, . - __udivsi3
84.end __udivsi3
diff --git a/arch/microblaze/lib/umodsi3.S b/arch/microblaze/lib/umodsi3.S
new file mode 100644
index 000000000000..17d16bafae58
--- /dev/null
+++ b/arch/microblaze/lib/umodsi3.S
@@ -0,0 +1,86 @@
1#include <linux/linkage.h>
2
3/*
4 * Unsigned modulo operation for 32 bit integers.
5 * Input : op1 in Reg r5
6 * op2 in Reg r6
7 * Output: op1 mod op2 in Reg r3
8 */
9
10 .text
11 .globl __umodsi3
12 .type __umodsi3, @function
13 .ent __umodsi3
14
15__umodsi3:
16 .frame r1, 0, r15
17
18 addik r1, r1, -12
19 swi r29, r1, 0
20 swi r30, r1, 4
21 swi r31, r1, 8
22
23 beqi r6, div_by_zero /* div_by_zero - division error */
24 beqid r5, result_is_zero /* result is zero */
25 addik r3, r0, 0 /* clear div */
26 addik r30, r0, 0 /* clear mod */
27 addik r29, r0, 32 /* initialize the loop count */
28
29/* check if r6 and r5 are equal /* if yes, return 0 */
30 rsub r18, r5, r6
31 beqi r18, return_here
32
33/* check if (uns)r6 is greater than (uns)r5. in that case, just return r5 */
34 xor r18, r5, r6
35 bgeid r18, 16
36 addik r3, r5, 0
37 blti r6, return_here
38 bri $lcheckr6
39 rsub r18, r5, r6 /* microblazecmp */
40 bgti r18, return_here
41
42/* if r6 [bit 31] is set, then return result as r5-r6 */
43$lcheckr6:
44 bgtid r6, div0
45 addik r3, r0, 0
46 addik r18, r0, 0x7fffffff
47 and r5, r5, r18
48 and r6, r6, r18
49 brid return_here
50 rsub r3, r6, r5
51/* first part: try to find the first '1' in the r5 */
52div0:
53 blti r5, div2
54div1:
55 add r5, r5, r5 /* left shift logical r5 */
56 bgeid r5, div1
57 addik r29, r29, -1
58div2:
59 /* left shift logical r5 get the '1' into the carry */
60 add r5, r5, r5
61 addc r3, r3, r3 /* move that bit into the mod register */
62 rsub r31, r6, r3 /* try to subtract (r3 a r6) */
63 blti r31, mod_too_small
64 /* move the r31 to mod since the result was positive */
65 or r3, r0, r31
66 addik r30, r30, 1
67mod_too_small:
68 addik r29, r29, -1
69 beqi r29, loop_end
70 add r30, r30, r30 /* shift in the '1' into div */
71 bri div2 /* div2 */
72loop_end:
73 bri return_here
74div_by_zero:
75result_is_zero:
76 or r3, r0, r0 /* set result to 0 */
77return_here:
78/* restore values of csrs and that of r3 and the divisor and the dividend */
79 lwi r29, r1, 0
80 lwi r30, r1, 4
81 lwi r31, r1, 8
82 rtsd r15, 8
83 addik r1, r1, 12
84
85.size __umodsi3, . - __umodsi3
86.end __umodsi3
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 55ef532f32be..e363615d6798 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -60,21 +60,6 @@ struct dma_map_ops *get_pci_dma_ops(void)
60} 60}
61EXPORT_SYMBOL(get_pci_dma_ops); 61EXPORT_SYMBOL(get_pci_dma_ops);
62 62
63int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
64{
65 return dma_set_mask(&dev->dev, mask);
66}
67
68int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
69{
70 int rc;
71
72 rc = dma_set_mask(&dev->dev, mask);
73 dev->dev.coherent_dma_mask = dev->dma_mask;
74
75 return rc;
76}
77
78struct pci_controller *pcibios_alloc_controller(struct device_node *dev) 63struct pci_controller *pcibios_alloc_controller(struct device_node *dev)
79{ 64{
80 struct pci_controller *phb; 65 struct pci_controller *phb;
@@ -1075,8 +1060,6 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
1075 bus->number, bus->self ? pci_name(bus->self) : "PHB"); 1060 bus->number, bus->self ? pci_name(bus->self) : "PHB");
1076 1061
1077 list_for_each_entry(dev, &bus->devices, bus_list) { 1062 list_for_each_entry(dev, &bus->devices, bus_list) {
1078 struct dev_archdata *sd = &dev->dev.archdata;
1079
1080 /* Setup OF node pointer in archdata */ 1063 /* Setup OF node pointer in archdata */
1081 dev->dev.of_node = pci_device_to_OF_node(dev); 1064 dev->dev.of_node = pci_device_to_OF_node(dev);
1082 1065
@@ -1086,8 +1069,8 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
1086 set_dev_node(&dev->dev, pcibus_to_node(dev->bus)); 1069 set_dev_node(&dev->dev, pcibus_to_node(dev->bus));
1087 1070
1088 /* Hook up default DMA ops */ 1071 /* Hook up default DMA ops */
1089 sd->dma_ops = pci_dma_ops; 1072 set_dma_ops(&dev->dev, pci_dma_ops);
1090 sd->dma_data = (void *)PCI_DRAM_OFFSET; 1073 dev->dev.archdata.dma_data = (void *)PCI_DRAM_OFFSET;
1091 1074
1092 /* Read default IRQs and fixup if necessary */ 1075 /* Read default IRQs and fixup if necessary */
1093 pci_read_irq_line(dev); 1076 pci_read_irq_line(dev);
diff --git a/arch/microblaze/platform/generic/system.dts b/arch/microblaze/platform/generic/system.dts
index 2d5c41767cd0..3f85df2b73b3 100644
--- a/arch/microblaze/platform/generic/system.dts
+++ b/arch/microblaze/platform/generic/system.dts
@@ -85,6 +85,7 @@
85 xlnx,dynamic-bus-sizing = <0x1>; 85 xlnx,dynamic-bus-sizing = <0x1>;
86 xlnx,edge-is-positive = <0x1>; 86 xlnx,edge-is-positive = <0x1>;
87 xlnx,family = "virtex5"; 87 xlnx,family = "virtex5";
88 xlnx,endianness = <0x1>;
88 xlnx,fpu-exception = <0x1>; 89 xlnx,fpu-exception = <0x1>;
89 xlnx,fsl-data-size = <0x20>; 90 xlnx,fsl-data-size = <0x20>;
90 xlnx,fsl-exception = <0x0>; 91 xlnx,fsl-exception = <0x0>;
@@ -218,6 +219,7 @@
218 #address-cells = <1>; 219 #address-cells = <1>;
219 #size-cells = <1>; 220 #size-cells = <1>;
220 compatible = "xlnx,compound"; 221 compatible = "xlnx,compound";
222 ranges ;
221 ethernet@81c00000 { 223 ethernet@81c00000 {
222 compatible = "xlnx,xps-ll-temac-1.01.b", "xlnx,xps-ll-temac-1.00.a"; 224 compatible = "xlnx,xps-ll-temac-1.01.b", "xlnx,xps-ll-temac-1.00.a";
223 device_type = "network"; 225 device_type = "network";
@@ -332,6 +334,7 @@
332 #address-cells = <1>; 334 #address-cells = <1>;
333 #size-cells = <1>; 335 #size-cells = <1>;
334 compatible = "xlnx,mpmc-4.02.a"; 336 compatible = "xlnx,mpmc-4.02.a";
337 ranges ;
335 PIM3: sdma@84600180 { 338 PIM3: sdma@84600180 {
336 compatible = "xlnx,ll-dma-1.00.a"; 339 compatible = "xlnx,ll-dma-1.00.a";
337 interrupt-parent = <&xps_intc_0>; 340 interrupt-parent = <&xps_intc_0>;
diff --git a/arch/microblaze/platform/platform.c b/arch/microblaze/platform/platform.c
index 5b89b58c5aed..b9529caa507a 100644
--- a/arch/microblaze/platform/platform.c
+++ b/arch/microblaze/platform/platform.c
@@ -17,9 +17,6 @@
17 17
18static struct of_device_id xilinx_of_bus_ids[] __initdata = { 18static struct of_device_id xilinx_of_bus_ids[] __initdata = {
19 { .compatible = "simple-bus", }, 19 { .compatible = "simple-bus", },
20 { .compatible = "xlnx,plb-v46-1.00.a", },
21 { .compatible = "xlnx,opb-v20-1.10.c", },
22 { .compatible = "xlnx,opb-v20-1.10.b", },
23 { .compatible = "xlnx,compound", }, 20 { .compatible = "xlnx,compound", },
24 {} 21 {}
25}; 22};
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 4c9f402295dd..67a2fa2caa49 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -4,18 +4,21 @@ config MIPS
4 select HAVE_GENERIC_DMA_COHERENT 4 select HAVE_GENERIC_DMA_COHERENT
5 select HAVE_IDE 5 select HAVE_IDE
6 select HAVE_OPROFILE 6 select HAVE_OPROFILE
7 select HAVE_PERF_EVENTS
8 select PERF_USE_VMALLOC
7 select HAVE_ARCH_KGDB 9 select HAVE_ARCH_KGDB
8 select HAVE_FUNCTION_TRACER 10 select HAVE_FUNCTION_TRACER
9 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 11 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
10 select HAVE_DYNAMIC_FTRACE 12 select HAVE_DYNAMIC_FTRACE
11 select HAVE_FTRACE_MCOUNT_RECORD 13 select HAVE_FTRACE_MCOUNT_RECORD
14 select HAVE_C_RECORDMCOUNT
12 select HAVE_FUNCTION_GRAPH_TRACER 15 select HAVE_FUNCTION_GRAPH_TRACER
13 select HAVE_KPROBES 16 select HAVE_KPROBES
14 select HAVE_KRETPROBES 17 select HAVE_KRETPROBES
15 select RTC_LIB if !MACH_LOONGSON 18 select RTC_LIB if !MACH_LOONGSON
16 select GENERIC_ATOMIC64 if !64BIT 19 select GENERIC_ATOMIC64 if !64BIT
17 20 select HAVE_DMA_ATTRS
18mainmenu "Linux/MIPS Kernel Configuration" 21 select HAVE_DMA_API_DEBUG
19 22
20menu "Machine selection" 23menu "Machine selection"
21 24
@@ -693,6 +696,9 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
693 select SWAP_IO_SPACE 696 select SWAP_IO_SPACE
694 select HW_HAS_PCI 697 select HW_HAS_PCI
695 select ARCH_SUPPORTS_MSI 698 select ARCH_SUPPORTS_MSI
699 select ZONE_DMA32
700 select USB_ARCH_HAS_OHCI
701 select USB_ARCH_HAS_EHCI
696 help 702 help
697 This option supports all of the Octeon reference boards from Cavium 703 This option supports all of the Octeon reference boards from Cavium
698 Networks. It builds a kernel that dynamically determines the Octeon 704 Networks. It builds a kernel that dynamically determines the Octeon
@@ -1336,6 +1342,57 @@ config CPU_CAVIUM_OCTEON
1336 can have up to 16 Mips64v2 cores and 8 integrated gigabit ethernets. 1342 can have up to 16 Mips64v2 cores and 8 integrated gigabit ethernets.
1337 Full details can be found at http://www.caviumnetworks.com. 1343 Full details can be found at http://www.caviumnetworks.com.
1338 1344
1345config CPU_BMIPS3300
1346 bool "BMIPS3300"
1347 depends on SYS_HAS_CPU_BMIPS3300
1348 select DMA_NONCOHERENT
1349 select IRQ_CPU
1350 select SWAP_IO_SPACE
1351 select SYS_SUPPORTS_32BIT_KERNEL
1352 select WEAK_ORDERING
1353 help
1354 Broadcom BMIPS3300 processors.
1355
1356config CPU_BMIPS4350
1357 bool "BMIPS4350"
1358 depends on SYS_HAS_CPU_BMIPS4350
1359 select CPU_SUPPORTS_32BIT_KERNEL
1360 select DMA_NONCOHERENT
1361 select IRQ_CPU
1362 select SWAP_IO_SPACE
1363 select SYS_SUPPORTS_SMP
1364 select SYS_SUPPORTS_HOTPLUG_CPU
1365 select WEAK_ORDERING
1366 help
1367 Broadcom BMIPS4350 ("VIPER") processors.
1368
1369config CPU_BMIPS4380
1370 bool "BMIPS4380"
1371 depends on SYS_HAS_CPU_BMIPS4380
1372 select CPU_SUPPORTS_32BIT_KERNEL
1373 select DMA_NONCOHERENT
1374 select IRQ_CPU
1375 select SWAP_IO_SPACE
1376 select SYS_SUPPORTS_SMP
1377 select SYS_SUPPORTS_HOTPLUG_CPU
1378 select WEAK_ORDERING
1379 help
1380 Broadcom BMIPS4380 processors.
1381
1382config CPU_BMIPS5000
1383 bool "BMIPS5000"
1384 depends on SYS_HAS_CPU_BMIPS5000
1385 select CPU_SUPPORTS_32BIT_KERNEL
1386 select CPU_SUPPORTS_HIGHMEM
1387 select DMA_NONCOHERENT
1388 select IRQ_CPU
1389 select SWAP_IO_SPACE
1390 select SYS_SUPPORTS_SMP
1391 select SYS_SUPPORTS_HOTPLUG_CPU
1392 select WEAK_ORDERING
1393 help
1394 Broadcom BMIPS5000 processors.
1395
1339endchoice 1396endchoice
1340 1397
1341if CPU_LOONGSON2F 1398if CPU_LOONGSON2F
@@ -1454,6 +1511,18 @@ config SYS_HAS_CPU_SB1
1454config SYS_HAS_CPU_CAVIUM_OCTEON 1511config SYS_HAS_CPU_CAVIUM_OCTEON
1455 bool 1512 bool
1456 1513
1514config SYS_HAS_CPU_BMIPS3300
1515 bool
1516
1517config SYS_HAS_CPU_BMIPS4350
1518 bool
1519
1520config SYS_HAS_CPU_BMIPS4380
1521 bool
1522
1523config SYS_HAS_CPU_BMIPS5000
1524 bool
1525
1457# 1526#
1458# CPU may reorder R->R, R->W, W->R, W->W 1527# CPU may reorder R->R, R->W, W->R, W->W
1459# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC 1528# Reordering beyond LL and SC is handled in WEAK_REORDERING_BEYOND_LLSC
@@ -1930,6 +1999,14 @@ config NODES_SHIFT
1930 default "6" 1999 default "6"
1931 depends on NEED_MULTIPLE_NODES 2000 depends on NEED_MULTIPLE_NODES
1932 2001
2002config HW_PERF_EVENTS
2003 bool "Enable hardware performance counter support for perf events"
2004 depends on PERF_EVENTS && !MIPS_MT_SMTC && OPROFILE=n && CPU_MIPS32
2005 default y
2006 help
2007 Enable hardware performance counter support for perf events. If
2008 disabled, perf events will use software events only.
2009
1933source "mm/Kconfig" 2010source "mm/Kconfig"
1934 2011
1935config SMP 2012config SMP
@@ -2128,6 +2205,13 @@ config SECCOMP
2128 2205
2129 If unsure, say Y. Only embedded should say N here. 2206 If unsure, say Y. Only embedded should say N here.
2130 2207
2208config USE_OF
2209 bool "Flattened Device Tree support"
2210 select OF
2211 select OF_FLATTREE
2212 help
2213 Include support for flattened device tree machine descriptions.
2214
2131endmenu 2215endmenu
2132 2216
2133config LOCKDEP_SUPPORT 2217config LOCKDEP_SUPPORT
@@ -2196,10 +2280,14 @@ config TC
2196 bool "TURBOchannel support" 2280 bool "TURBOchannel support"
2197 depends on MACH_DECSTATION 2281 depends on MACH_DECSTATION
2198 help 2282 help
2199 TurboChannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS 2283 TURBOchannel is a DEC (now Compaq (now HP)) bus for Alpha and MIPS
2200 processors. Documentation on writing device drivers for TurboChannel 2284 processors. TURBOchannel programming specifications are available
2201 is available at: 2285 at:
2202 <http://www.cs.arizona.edu/computer.help/policy/DIGITAL_unix/AA-PS3HD-TET1_html/TITLE.html>. 2286 <ftp://ftp.hp.com/pub/alphaserver/archive/triadd/>
2287 and:
2288 <http://www.computer-refuge.org/classiccmp/ftp.digital.com/pub/DEC/TriAdd/>
2289 Linux driver support status is documented at:
2290 <http://www.linux-mips.org/wiki/DECstation>
2203 2291
2204#config ACCESSBUS 2292#config ACCESSBUS
2205# bool "Access.Bus support" 2293# bool "Access.Bus support"
diff --git a/arch/mips/Kconfig.debug b/arch/mips/Kconfig.debug
index 43dc27997730..f437cd1fafb8 100644
--- a/arch/mips/Kconfig.debug
+++ b/arch/mips/Kconfig.debug
@@ -67,6 +67,15 @@ config CMDLINE_OVERRIDE
67 67
68 Normally, you will choose 'N' here. 68 Normally, you will choose 'N' here.
69 69
70config DEBUG_STACKOVERFLOW
71 bool "Check for stack overflows"
72 depends on DEBUG_KERNEL
73 help
74 This option will cause messages to be printed if free stack space
75 drops below a certain limit(2GB on MIPS). The debugging option
76 provides another way to check stack overflow happened on kernel mode
77 stack usually caused by nested interruption.
78
70config DEBUG_STACK_USAGE 79config DEBUG_STACK_USAGE
71 bool "Enable stack utilization instrumentation" 80 bool "Enable stack utilization instrumentation"
72 depends on DEBUG_KERNEL 81 depends on DEBUG_KERNEL
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index f4a4b663ebb3..7c1102e41fe2 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -48,9 +48,6 @@ ifneq ($(SUBARCH),$(ARCH))
48 endif 48 endif
49endif 49endif
50 50
51ifndef CONFIG_FUNCTION_TRACER
52cflags-y := -ffunction-sections
53endif
54ifdef CONFIG_FUNCTION_GRAPH_TRACER 51ifdef CONFIG_FUNCTION_GRAPH_TRACER
55 ifndef KBUILD_MCOUNT_RA_ADDRESS 52 ifndef KBUILD_MCOUNT_RA_ADDRESS
56 ifeq ($(call cc-option-yn,-mmcount-ra-address), y) 53 ifeq ($(call cc-option-yn,-mmcount-ra-address), y)
@@ -159,6 +156,7 @@ cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap
159ifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON)))) 156ifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON))))
160cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon 157cflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
161endif 158endif
159cflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
162 160
163cflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,) 161cflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,)
164cflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,) 162cflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,)
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/devboards/db1200/platform.c b/arch/mips/alchemy/devboards/db1200/platform.c
index 3fa34c3abc04..fbb55935b99e 100644
--- a/arch/mips/alchemy/devboards/db1200/platform.c
+++ b/arch/mips/alchemy/devboards/db1200/platform.c
@@ -429,6 +429,11 @@ static struct platform_device db1200_audio_dev = {
429 .resource = au1200_psc1_res, 429 .resource = au1200_psc1_res,
430}; 430};
431 431
432static struct platform_device db1200_stac_dev = {
433 .name = "ac97-codec",
434 .id = 1, /* on PSC1 */
435};
436
432static struct platform_device *db1200_devs[] __initdata = { 437static struct platform_device *db1200_devs[] __initdata = {
433 NULL, /* PSC0, selected by S6.8 */ 438 NULL, /* PSC0, selected by S6.8 */
434 &db1200_ide_dev, 439 &db1200_ide_dev,
@@ -436,6 +441,7 @@ static struct platform_device *db1200_devs[] __initdata = {
436 &db1200_rtc_dev, 441 &db1200_rtc_dev,
437 &db1200_nand_dev, 442 &db1200_nand_dev,
438 &db1200_audio_dev, 443 &db1200_audio_dev,
444 &db1200_stac_dev,
439}; 445};
440 446
441static int __init db1200_dev_init(void) 447static int __init db1200_dev_init(void)
diff --git a/arch/mips/ar7/gpio.c b/arch/mips/ar7/gpio.c
index c32fbb57441a..425dfa5d6e12 100644
--- a/arch/mips/ar7/gpio.c
+++ b/arch/mips/ar7/gpio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org> 2 * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2007 Eugene Konev <ejka@openwrt.org> 3 * Copyright (C) 2007 Eugene Konev <ejka@openwrt.org>
4 * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org> 4 * Copyright (C) 2009-2010 Florian Fainelli <florian@openwrt.org>
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
@@ -37,6 +37,16 @@ static int ar7_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
37 return readl(gpio_in) & (1 << gpio); 37 return readl(gpio_in) & (1 << gpio);
38} 38}
39 39
40static int titan_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
41{
42 struct ar7_gpio_chip *gpch =
43 container_of(chip, struct ar7_gpio_chip, chip);
44 void __iomem *gpio_in0 = gpch->regs + TITAN_GPIO_INPUT_0;
45 void __iomem *gpio_in1 = gpch->regs + TITAN_GPIO_INPUT_1;
46
47 return readl(gpio >> 5 ? gpio_in1 : gpio_in0) & (1 << (gpio & 0x1f));
48}
49
40static void ar7_gpio_set_value(struct gpio_chip *chip, 50static void ar7_gpio_set_value(struct gpio_chip *chip,
41 unsigned gpio, int value) 51 unsigned gpio, int value)
42{ 52{
@@ -51,6 +61,21 @@ static void ar7_gpio_set_value(struct gpio_chip *chip,
51 writel(tmp, gpio_out); 61 writel(tmp, gpio_out);
52} 62}
53 63
64static void titan_gpio_set_value(struct gpio_chip *chip,
65 unsigned gpio, int value)
66{
67 struct ar7_gpio_chip *gpch =
68 container_of(chip, struct ar7_gpio_chip, chip);
69 void __iomem *gpio_out0 = gpch->regs + TITAN_GPIO_OUTPUT_0;
70 void __iomem *gpio_out1 = gpch->regs + TITAN_GPIO_OUTPUT_1;
71 unsigned tmp;
72
73 tmp = readl(gpio >> 5 ? gpio_out1 : gpio_out0) & ~(1 << (gpio & 0x1f));
74 if (value)
75 tmp |= 1 << (gpio & 0x1f);
76 writel(tmp, gpio >> 5 ? gpio_out1 : gpio_out0);
77}
78
54static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) 79static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
55{ 80{
56 struct ar7_gpio_chip *gpch = 81 struct ar7_gpio_chip *gpch =
@@ -62,6 +87,21 @@ static int ar7_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
62 return 0; 87 return 0;
63} 88}
64 89
90static int titan_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
91{
92 struct ar7_gpio_chip *gpch =
93 container_of(chip, struct ar7_gpio_chip, chip);
94 void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0;
95 void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1;
96
97 if (gpio >= TITAN_GPIO_MAX)
98 return -EINVAL;
99
100 writel(readl(gpio >> 5 ? gpio_dir1 : gpio_dir0) | (1 << (gpio & 0x1f)),
101 gpio >> 5 ? gpio_dir1 : gpio_dir0);
102 return 0;
103}
104
65static int ar7_gpio_direction_output(struct gpio_chip *chip, 105static int ar7_gpio_direction_output(struct gpio_chip *chip,
66 unsigned gpio, int value) 106 unsigned gpio, int value)
67{ 107{
@@ -75,6 +115,24 @@ static int ar7_gpio_direction_output(struct gpio_chip *chip,
75 return 0; 115 return 0;
76} 116}
77 117
118static int titan_gpio_direction_output(struct gpio_chip *chip,
119 unsigned gpio, int value)
120{
121 struct ar7_gpio_chip *gpch =
122 container_of(chip, struct ar7_gpio_chip, chip);
123 void __iomem *gpio_dir0 = gpch->regs + TITAN_GPIO_DIR_0;
124 void __iomem *gpio_dir1 = gpch->regs + TITAN_GPIO_DIR_1;
125
126 if (gpio >= TITAN_GPIO_MAX)
127 return -EINVAL;
128
129 titan_gpio_set_value(chip, gpio, value);
130 writel(readl(gpio >> 5 ? gpio_dir1 : gpio_dir0) & ~(1 <<
131 (gpio & 0x1f)), gpio >> 5 ? gpio_dir1 : gpio_dir0);
132
133 return 0;
134}
135
78static struct ar7_gpio_chip ar7_gpio_chip = { 136static struct ar7_gpio_chip ar7_gpio_chip = {
79 .chip = { 137 .chip = {
80 .label = "ar7-gpio", 138 .label = "ar7-gpio",
@@ -87,7 +145,19 @@ static struct ar7_gpio_chip ar7_gpio_chip = {
87 } 145 }
88}; 146};
89 147
90int ar7_gpio_enable(unsigned gpio) 148static struct ar7_gpio_chip titan_gpio_chip = {
149 .chip = {
150 .label = "titan-gpio",
151 .direction_input = titan_gpio_direction_input,
152 .direction_output = titan_gpio_direction_output,
153 .set = titan_gpio_set_value,
154 .get = titan_gpio_get_value,
155 .base = 0,
156 .ngpio = TITAN_GPIO_MAX,
157 }
158};
159
160static inline int ar7_gpio_enable_ar7(unsigned gpio)
91{ 161{
92 void __iomem *gpio_en = ar7_gpio_chip.regs + AR7_GPIO_ENABLE; 162 void __iomem *gpio_en = ar7_gpio_chip.regs + AR7_GPIO_ENABLE;
93 163
@@ -95,9 +165,26 @@ int ar7_gpio_enable(unsigned gpio)
95 165
96 return 0; 166 return 0;
97} 167}
168
169static inline int ar7_gpio_enable_titan(unsigned gpio)
170{
171 void __iomem *gpio_en0 = titan_gpio_chip.regs + TITAN_GPIO_ENBL_0;
172 void __iomem *gpio_en1 = titan_gpio_chip.regs + TITAN_GPIO_ENBL_1;
173
174 writel(readl(gpio >> 5 ? gpio_en1 : gpio_en0) | (1 << (gpio & 0x1f)),
175 gpio >> 5 ? gpio_en1 : gpio_en0);
176
177 return 0;
178}
179
180int ar7_gpio_enable(unsigned gpio)
181{
182 return ar7_is_titan() ? ar7_gpio_enable_titan(gpio) :
183 ar7_gpio_enable_ar7(gpio);
184}
98EXPORT_SYMBOL(ar7_gpio_enable); 185EXPORT_SYMBOL(ar7_gpio_enable);
99 186
100int ar7_gpio_disable(unsigned gpio) 187static inline int ar7_gpio_disable_ar7(unsigned gpio)
101{ 188{
102 void __iomem *gpio_en = ar7_gpio_chip.regs + AR7_GPIO_ENABLE; 189 void __iomem *gpio_en = ar7_gpio_chip.regs + AR7_GPIO_ENABLE;
103 190
@@ -105,27 +192,159 @@ int ar7_gpio_disable(unsigned gpio)
105 192
106 return 0; 193 return 0;
107} 194}
195
196static inline int ar7_gpio_disable_titan(unsigned gpio)
197{
198 void __iomem *gpio_en0 = titan_gpio_chip.regs + TITAN_GPIO_ENBL_0;
199 void __iomem *gpio_en1 = titan_gpio_chip.regs + TITAN_GPIO_ENBL_1;
200
201 writel(readl(gpio >> 5 ? gpio_en1 : gpio_en0) & ~(1 << (gpio & 0x1f)),
202 gpio >> 5 ? gpio_en1 : gpio_en0);
203
204 return 0;
205}
206
207int ar7_gpio_disable(unsigned gpio)
208{
209 return ar7_is_titan() ? ar7_gpio_disable_titan(gpio) :
210 ar7_gpio_disable_ar7(gpio);
211}
108EXPORT_SYMBOL(ar7_gpio_disable); 212EXPORT_SYMBOL(ar7_gpio_disable);
109 213
110static int __init ar7_gpio_init(void) 214struct titan_gpio_cfg {
215 u32 reg;
216 u32 shift;
217 u32 func;
218};
219
220static struct titan_gpio_cfg titan_gpio_table[] = {
221 /* reg, start bit, mux value */
222 {4, 24, 1},
223 {4, 26, 1},
224 {4, 28, 1},
225 {4, 30, 1},
226 {5, 6, 1},
227 {5, 8, 1},
228 {5, 10, 1},
229 {5, 12, 1},
230 {7, 14, 3},
231 {7, 16, 3},
232 {7, 18, 3},
233 {7, 20, 3},
234 {7, 22, 3},
235 {7, 26, 3},
236 {7, 28, 3},
237 {7, 30, 3},
238 {8, 0, 3},
239 {8, 2, 3},
240 {8, 4, 3},
241 {8, 10, 3},
242 {8, 14, 3},
243 {8, 16, 3},
244 {8, 18, 3},
245 {8, 20, 3},
246 {9, 8, 3},
247 {9, 10, 3},
248 {9, 12, 3},
249 {9, 14, 3},
250 {9, 18, 3},
251 {9, 20, 3},
252 {9, 24, 3},
253 {9, 26, 3},
254 {9, 28, 3},
255 {9, 30, 3},
256 {10, 0, 3},
257 {10, 2, 3},
258 {10, 8, 3},
259 {10, 10, 3},
260 {10, 12, 3},
261 {10, 14, 3},
262 {13, 12, 3},
263 {13, 14, 3},
264 {13, 16, 3},
265 {13, 18, 3},
266 {13, 24, 3},
267 {13, 26, 3},
268 {13, 28, 3},
269 {13, 30, 3},
270 {14, 2, 3},
271 {14, 6, 3},
272 {14, 8, 3},
273 {14, 12, 3}
274};
275
276static int titan_gpio_pinsel(unsigned gpio)
277{
278 struct titan_gpio_cfg gpio_cfg;
279 u32 mux_status, pin_sel_reg, tmp;
280 void __iomem *pin_sel = (void __iomem *)KSEG1ADDR(AR7_REGS_PINSEL);
281
282 if (gpio >= ARRAY_SIZE(titan_gpio_table))
283 return -EINVAL;
284
285 gpio_cfg = titan_gpio_table[gpio];
286 pin_sel_reg = gpio_cfg.reg - 1;
287
288 mux_status = (readl(pin_sel + pin_sel_reg) >> gpio_cfg.shift) & 0x3;
289
290 /* Check the mux status */
291 if (!((mux_status == 0) || (mux_status == gpio_cfg.func)))
292 return 0;
293
294 /* Set the pin sel value */
295 tmp = readl(pin_sel + pin_sel_reg);
296 tmp |= ((gpio_cfg.func & 0x3) << gpio_cfg.shift);
297 writel(tmp, pin_sel + pin_sel_reg);
298
299 return 0;
300}
301
302/* Perform minimal Titan GPIO configuration */
303static void titan_gpio_init(void)
304{
305 unsigned i;
306
307 for (i = 44; i < 48; i++) {
308 titan_gpio_pinsel(i);
309 ar7_gpio_enable_titan(i);
310 titan_gpio_direction_input(&titan_gpio_chip.chip, i);
311 }
312}
313
314int __init ar7_gpio_init(void)
111{ 315{
112 int ret; 316 int ret;
317 struct ar7_gpio_chip *gpch;
318 unsigned size;
319
320 if (!ar7_is_titan()) {
321 gpch = &ar7_gpio_chip;
322 size = 0x10;
323 } else {
324 gpch = &titan_gpio_chip;
325 size = 0x1f;
326 }
113 327
114 ar7_gpio_chip.regs = ioremap_nocache(AR7_REGS_GPIO, 328 gpch->regs = ioremap_nocache(AR7_REGS_GPIO,
115 AR7_REGS_GPIO + 0x10); 329 AR7_REGS_GPIO + 0x10);
116 330
117 if (!ar7_gpio_chip.regs) { 331 if (!gpch->regs) {
118 printk(KERN_ERR "ar7-gpio: failed to ioremap regs\n"); 332 printk(KERN_ERR "%s: failed to ioremap regs\n",
333 gpch->chip.label);
119 return -ENOMEM; 334 return -ENOMEM;
120 } 335 }
121 336
122 ret = gpiochip_add(&ar7_gpio_chip.chip); 337 ret = gpiochip_add(&gpch->chip);
123 if (ret) { 338 if (ret) {
124 printk(KERN_ERR "ar7-gpio: failed to add gpiochip\n"); 339 printk(KERN_ERR "%s: failed to add gpiochip\n",
340 gpch->chip.label);
125 return ret; 341 return ret;
126 } 342 }
127 printk(KERN_INFO "ar7-gpio: registered %d GPIOs\n", 343 printk(KERN_INFO "%s: registered %d GPIOs\n",
128 ar7_gpio_chip.chip.ngpio); 344 gpch->chip.label, gpch->chip.ngpio);
345
346 if (ar7_is_titan())
347 titan_gpio_init();
348
129 return ret; 349 return ret;
130} 350}
131arch_initcall(ar7_gpio_init);
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 0da5b2b8dd88..7d2fab392327 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -357,6 +357,11 @@ static struct gpio_led default_leds[] = {
357 }, 357 },
358}; 358};
359 359
360static struct gpio_led titan_leds[] = {
361 { .name = "status", .gpio = 8, .active_low = 1, },
362 { .name = "wifi", .gpio = 13, .active_low = 1, },
363};
364
360static struct gpio_led dsl502t_leds[] = { 365static struct gpio_led dsl502t_leds[] = {
361 { 366 {
362 .name = "status", 367 .name = "status",
@@ -495,6 +500,9 @@ static void __init detect_leds(void)
495 } else if (strstr(prid, "DG834")) { 500 } else if (strstr(prid, "DG834")) {
496 ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds); 501 ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds);
497 ar7_led_data.leds = dg834g_leds; 502 ar7_led_data.leds = dg834g_leds;
503 } else if (strstr(prid, "CYWM") || strstr(prid, "CYWL")) {
504 ar7_led_data.num_leds = ARRAY_SIZE(titan_leds);
505 ar7_led_data.leds = titan_leds;
498 } 506 }
499} 507}
500 508
@@ -560,6 +568,51 @@ static int __init ar7_register_uarts(void)
560 return 0; 568 return 0;
561} 569}
562 570
571static void __init titan_fixup_devices(void)
572{
573 /* Set vlynq0 data */
574 vlynq_low_data.reset_bit = 15;
575 vlynq_low_data.gpio_bit = 14;
576
577 /* Set vlynq1 data */
578 vlynq_high_data.reset_bit = 16;
579 vlynq_high_data.gpio_bit = 7;
580
581 /* Set vlynq0 resources */
582 vlynq_low_res[0].start = TITAN_REGS_VLYNQ0;
583 vlynq_low_res[0].end = TITAN_REGS_VLYNQ0 + 0xff;
584 vlynq_low_res[1].start = 33;
585 vlynq_low_res[1].end = 33;
586 vlynq_low_res[2].start = 0x0c000000;
587 vlynq_low_res[2].end = 0x0fffffff;
588 vlynq_low_res[3].start = 80;
589 vlynq_low_res[3].end = 111;
590
591 /* Set vlynq1 resources */
592 vlynq_high_res[0].start = TITAN_REGS_VLYNQ1;
593 vlynq_high_res[0].end = TITAN_REGS_VLYNQ1 + 0xff;
594 vlynq_high_res[1].start = 34;
595 vlynq_high_res[1].end = 34;
596 vlynq_high_res[2].start = 0x40000000;
597 vlynq_high_res[2].end = 0x43ffffff;
598 vlynq_high_res[3].start = 112;
599 vlynq_high_res[3].end = 143;
600
601 /* Set cpmac0 data */
602 cpmac_low_data.phy_mask = 0x40000000;
603
604 /* Set cpmac1 data */
605 cpmac_high_data.phy_mask = 0x80000000;
606
607 /* Set cpmac0 resources */
608 cpmac_low_res[0].start = TITAN_REGS_MAC0;
609 cpmac_low_res[0].end = TITAN_REGS_MAC0 + 0x7ff;
610
611 /* Set cpmac1 resources */
612 cpmac_high_res[0].start = TITAN_REGS_MAC1;
613 cpmac_high_res[0].end = TITAN_REGS_MAC1 + 0x7ff;
614}
615
563static int __init ar7_register_devices(void) 616static int __init ar7_register_devices(void)
564{ 617{
565 void __iomem *bootcr; 618 void __iomem *bootcr;
@@ -574,6 +627,9 @@ static int __init ar7_register_devices(void)
574 if (res) 627 if (res)
575 pr_warning("unable to register physmap-flash: %d\n", res); 628 pr_warning("unable to register physmap-flash: %d\n", res);
576 629
630 if (ar7_is_titan())
631 titan_fixup_devices();
632
577 ar7_device_disable(vlynq_low_data.reset_bit); 633 ar7_device_disable(vlynq_low_data.reset_bit);
578 res = platform_device_register(&vlynq_low); 634 res = platform_device_register(&vlynq_low);
579 if (res) 635 if (res)
diff --git a/arch/mips/ar7/prom.c b/arch/mips/ar7/prom.c
index 52385790e5c1..23818d299127 100644
--- a/arch/mips/ar7/prom.c
+++ b/arch/mips/ar7/prom.c
@@ -246,6 +246,8 @@ void __init prom_init(void)
246 ar7_init_cmdline(fw_arg0, (char **)fw_arg1); 246 ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
247 ar7_init_env((struct env_var *)fw_arg2); 247 ar7_init_env((struct env_var *)fw_arg2);
248 console_config(); 248 console_config();
249
250 ar7_gpio_init();
249} 251}
250 252
251#define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4))) 253#define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))
diff --git a/arch/mips/ar7/setup.c b/arch/mips/ar7/setup.c
index 3a801d2cb6e5..f20b53e597c4 100644
--- a/arch/mips/ar7/setup.c
+++ b/arch/mips/ar7/setup.c
@@ -23,6 +23,7 @@
23#include <asm/reboot.h> 23#include <asm/reboot.h>
24#include <asm/mach-ar7/ar7.h> 24#include <asm/mach-ar7/ar7.h>
25#include <asm/mach-ar7/prom.h> 25#include <asm/mach-ar7/prom.h>
26#include <asm/mach-ar7/gpio.h>
26 27
27static void ar7_machine_restart(char *command) 28static void ar7_machine_restart(char *command)
28{ 29{
@@ -49,6 +50,8 @@ static void ar7_machine_power_off(void)
49const char *get_system_type(void) 50const char *get_system_type(void)
50{ 51{
51 u16 chip_id = ar7_chip_id(); 52 u16 chip_id = ar7_chip_id();
53 u16 titan_variant_id = titan_chip_id();
54
52 switch (chip_id) { 55 switch (chip_id) {
53 case AR7_CHIP_7100: 56 case AR7_CHIP_7100:
54 return "TI AR7 (TNETD7100)"; 57 return "TI AR7 (TNETD7100)";
@@ -56,6 +59,17 @@ const char *get_system_type(void)
56 return "TI AR7 (TNETD7200)"; 59 return "TI AR7 (TNETD7200)";
57 case AR7_CHIP_7300: 60 case AR7_CHIP_7300:
58 return "TI AR7 (TNETD7300)"; 61 return "TI AR7 (TNETD7300)";
62 case AR7_CHIP_TITAN:
63 switch (titan_variant_id) {
64 case TITAN_CHIP_1050:
65 return "TI AR7 (TNETV1050)";
66 case TITAN_CHIP_1055:
67 return "TI AR7 (TNETV1055)";
68 case TITAN_CHIP_1056:
69 return "TI AR7 (TNETV1056)";
70 case TITAN_CHIP_1060:
71 return "TI AR7 (TNETV1060)";
72 }
59 default: 73 default:
60 return "TI AR7 (unknown)"; 74 return "TI AR7 (unknown)";
61 } 75 }
diff --git a/arch/mips/bcm63xx/cpu.c b/arch/mips/bcm63xx/cpu.c
index cbb7caf86d77..7c7e4d4486ce 100644
--- a/arch/mips/bcm63xx/cpu.c
+++ b/arch/mips/bcm63xx/cpu.c
@@ -10,7 +10,9 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/cpu.h> 12#include <linux/cpu.h>
13#include <asm/cpu.h>
13#include <asm/cpu-info.h> 14#include <asm/cpu-info.h>
15#include <asm/mipsregs.h>
14#include <bcm63xx_cpu.h> 16#include <bcm63xx_cpu.h>
15#include <bcm63xx_regs.h> 17#include <bcm63xx_regs.h>
16#include <bcm63xx_io.h> 18#include <bcm63xx_io.h>
@@ -296,26 +298,24 @@ void __init bcm63xx_cpu_init(void)
296 expected_cpu_id = 0; 298 expected_cpu_id = 0;
297 299
298 switch (c->cputype) { 300 switch (c->cputype) {
299 /* 301 case CPU_BMIPS3300:
300 * BCM6338 as the same PrId as BCM3302 see arch/mips/kernel/cpu-probe.c 302 if ((read_c0_prid() & 0xff00) == PRID_IMP_BMIPS3300_ALT) {
301 */ 303 expected_cpu_id = BCM6348_CPU_ID;
302 case CPU_BCM3302: 304 bcm63xx_regs_base = bcm96348_regs_base;
303 __cpu_name[cpu] = "Broadcom BCM6338"; 305 bcm63xx_irqs = bcm96348_irqs;
304 expected_cpu_id = BCM6338_CPU_ID; 306 } else {
305 bcm63xx_regs_base = bcm96338_regs_base; 307 __cpu_name[cpu] = "Broadcom BCM6338";
306 bcm63xx_irqs = bcm96338_irqs; 308 expected_cpu_id = BCM6338_CPU_ID;
309 bcm63xx_regs_base = bcm96338_regs_base;
310 bcm63xx_irqs = bcm96338_irqs;
311 }
307 break; 312 break;
308 case CPU_BCM6345: 313 case CPU_BMIPS32:
309 expected_cpu_id = BCM6345_CPU_ID; 314 expected_cpu_id = BCM6345_CPU_ID;
310 bcm63xx_regs_base = bcm96345_regs_base; 315 bcm63xx_regs_base = bcm96345_regs_base;
311 bcm63xx_irqs = bcm96345_irqs; 316 bcm63xx_irqs = bcm96345_irqs;
312 break; 317 break;
313 case CPU_BCM6348: 318 case CPU_BMIPS4350:
314 expected_cpu_id = BCM6348_CPU_ID;
315 bcm63xx_regs_base = bcm96348_regs_base;
316 bcm63xx_irqs = bcm96348_irqs;
317 break;
318 case CPU_BCM6358:
319 expected_cpu_id = BCM6358_CPU_ID; 319 expected_cpu_id = BCM6358_CPU_ID;
320 bcm63xx_regs_base = bcm96358_regs_base; 320 bcm63xx_regs_base = bcm96358_regs_base;
321 bcm63xx_irqs = bcm96358_irqs; 321 bcm63xx_irqs = bcm96358_irqs;
diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig
index 47323ca452dc..caae22858163 100644
--- a/arch/mips/cavium-octeon/Kconfig
+++ b/arch/mips/cavium-octeon/Kconfig
@@ -3,6 +3,17 @@ config CAVIUM_OCTEON_SPECIFIC_OPTIONS
3 depends on CPU_CAVIUM_OCTEON 3 depends on CPU_CAVIUM_OCTEON
4 default "y" 4 default "y"
5 5
6config CAVIUM_CN63XXP1
7 bool "Enable CN63XXP1 errata worarounds"
8 depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS
9 default "n"
10 help
11 The CN63XXP1 chip requires build time workarounds to
12 function reliably, select this option to enable them. These
13 workarounds will cause a slight decrease in performance on
14 non-CN63XXP1 hardware, so it is recommended to select "n"
15 unless it is known the workarounds are needed.
16
6config CAVIUM_OCTEON_2ND_KERNEL 17config CAVIUM_OCTEON_2ND_KERNEL
7 bool "Build the kernel to be used as a 2nd kernel on the same chip" 18 bool "Build the kernel to be used as a 2nd kernel on the same chip"
8 depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS 19 depends on CAVIUM_OCTEON_SPECIFIC_OPTIONS
@@ -87,3 +98,15 @@ config ARCH_SPARSEMEM_ENABLE
87config CAVIUM_OCTEON_HELPER 98config CAVIUM_OCTEON_HELPER
88 def_bool y 99 def_bool y
89 depends on OCTEON_ETHERNET || PCI 100 depends on OCTEON_ETHERNET || PCI
101
102config IOMMU_HELPER
103 bool
104
105config NEED_SG_DMA_LENGTH
106 bool
107
108config SWIOTLB
109 def_bool y
110 depends on CPU_CAVIUM_OCTEON
111 select IOMMU_HELPER
112 select NEED_SG_DMA_LENGTH
diff --git a/arch/mips/cavium-octeon/csrc-octeon.c b/arch/mips/cavium-octeon/csrc-octeon.c
index b6847c8e0ddd..26bf71130bf8 100644
--- a/arch/mips/cavium-octeon/csrc-octeon.c
+++ b/arch/mips/cavium-octeon/csrc-octeon.c
@@ -4,14 +4,18 @@
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2007 by Ralf Baechle 6 * Copyright (C) 2007 by Ralf Baechle
7 * Copyright (C) 2009, 2010 Cavium Networks, Inc.
7 */ 8 */
8#include <linux/clocksource.h> 9#include <linux/clocksource.h>
9#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/smp.h>
10 12
13#include <asm/cpu-info.h>
11#include <asm/time.h> 14#include <asm/time.h>
12 15
13#include <asm/octeon/octeon.h> 16#include <asm/octeon/octeon.h>
14#include <asm/octeon/cvmx-ipd-defs.h> 17#include <asm/octeon/cvmx-ipd-defs.h>
18#include <asm/octeon/cvmx-mio-defs.h>
15 19
16/* 20/*
17 * Set the current core's cvmcount counter to the value of the 21 * Set the current core's cvmcount counter to the value of the
@@ -19,11 +23,23 @@
19 * on-line. This allows for a read from a local cpu register to 23 * on-line. This allows for a read from a local cpu register to
20 * access a synchronized counter. 24 * access a synchronized counter.
21 * 25 *
26 * On CPU_CAVIUM_OCTEON2 the IPD_CLK_COUNT is scaled by rdiv/sdiv.
22 */ 27 */
23void octeon_init_cvmcount(void) 28void octeon_init_cvmcount(void)
24{ 29{
25 unsigned long flags; 30 unsigned long flags;
26 unsigned loops = 2; 31 unsigned loops = 2;
32 u64 f = 0;
33 u64 rdiv = 0;
34 u64 sdiv = 0;
35 if (current_cpu_type() == CPU_CAVIUM_OCTEON2) {
36 union cvmx_mio_rst_boot rst_boot;
37 rst_boot.u64 = cvmx_read_csr(CVMX_MIO_RST_BOOT);
38 rdiv = rst_boot.s.c_mul; /* CPU clock */
39 sdiv = rst_boot.s.pnr_mul; /* I/O clock */
40 f = (0x8000000000000000ull / sdiv) * 2;
41 }
42
27 43
28 /* Clobber loops so GCC will not unroll the following while loop. */ 44 /* Clobber loops so GCC will not unroll the following while loop. */
29 asm("" : "+r" (loops)); 45 asm("" : "+r" (loops));
@@ -33,8 +49,20 @@ void octeon_init_cvmcount(void)
33 * Loop several times so we are executing from the cache, 49 * Loop several times so we are executing from the cache,
34 * which should give more deterministic timing. 50 * which should give more deterministic timing.
35 */ 51 */
36 while (loops--) 52 while (loops--) {
37 write_c0_cvmcount(cvmx_read_csr(CVMX_IPD_CLK_COUNT)); 53 u64 ipd_clk_count = cvmx_read_csr(CVMX_IPD_CLK_COUNT);
54 if (rdiv != 0) {
55 ipd_clk_count *= rdiv;
56 if (f != 0) {
57 asm("dmultu\t%[cnt],%[f]\n\t"
58 "mfhi\t%[cnt]"
59 : [cnt] "+r" (ipd_clk_count),
60 [f] "=r" (f)
61 : : "hi", "lo");
62 }
63 }
64 write_c0_cvmcount(ipd_clk_count);
65 }
38 local_irq_restore(flags); 66 local_irq_restore(flags);
39} 67}
40 68
@@ -77,7 +105,7 @@ unsigned long long notrace sched_clock(void)
77void __init plat_time_init(void) 105void __init plat_time_init(void)
78{ 106{
79 clocksource_mips.rating = 300; 107 clocksource_mips.rating = 300;
80 clocksource_set_clock(&clocksource_mips, mips_hpt_frequency); 108 clocksource_set_clock(&clocksource_mips, octeon_get_clock_rate());
81 clocksource_register(&clocksource_mips); 109 clocksource_register(&clocksource_mips);
82} 110}
83 111
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
index d22b5a2d64f4..1abb66caaa1d 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -8,335 +8,342 @@
8 * Copyright (C) 2005 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com> 8 * Copyright (C) 2005 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com>
9 * swiped from i386, and cloned for MIPS by Geert, polished by Ralf. 9 * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
10 * IP32 changes by Ilya. 10 * IP32 changes by Ilya.
11 * Cavium Networks: Create new dma setup for Cavium Networks Octeon based on 11 * Copyright (C) 2010 Cavium Networks, Inc.
12 * the kernels original.
13 */ 12 */
14#include <linux/types.h>
15#include <linux/mm.h>
16#include <linux/module.h>
17#include <linux/string.h>
18#include <linux/dma-mapping.h> 13#include <linux/dma-mapping.h>
19#include <linux/platform_device.h>
20#include <linux/scatterlist.h> 14#include <linux/scatterlist.h>
15#include <linux/bootmem.h>
16#include <linux/swiotlb.h>
17#include <linux/types.h>
18#include <linux/init.h>
19#include <linux/mm.h>
21 20
22#include <linux/cache.h> 21#include <asm/bootinfo.h>
23#include <linux/io.h>
24 22
25#include <asm/octeon/octeon.h> 23#include <asm/octeon/octeon.h>
24
25#ifdef CONFIG_PCI
26#include <asm/octeon/pci-octeon.h>
26#include <asm/octeon/cvmx-npi-defs.h> 27#include <asm/octeon/cvmx-npi-defs.h>
27#include <asm/octeon/cvmx-pci-defs.h> 28#include <asm/octeon/cvmx-pci-defs.h>
28 29
29#include <dma-coherence.h> 30static dma_addr_t octeon_hole_phys_to_dma(phys_addr_t paddr)
31{
32 if (paddr >= CVMX_PCIE_BAR1_PHYS_BASE && paddr < (CVMX_PCIE_BAR1_PHYS_BASE + CVMX_PCIE_BAR1_PHYS_SIZE))
33 return paddr - CVMX_PCIE_BAR1_PHYS_BASE + CVMX_PCIE_BAR1_RC_BASE;
34 else
35 return paddr;
36}
30 37
31#ifdef CONFIG_PCI 38static phys_addr_t octeon_hole_dma_to_phys(dma_addr_t daddr)
32#include <asm/octeon/pci-octeon.h> 39{
33#endif 40 if (daddr >= CVMX_PCIE_BAR1_RC_BASE)
41 return daddr + CVMX_PCIE_BAR1_PHYS_BASE - CVMX_PCIE_BAR1_RC_BASE;
42 else
43 return daddr;
44}
45
46static dma_addr_t octeon_gen1_phys_to_dma(struct device *dev, phys_addr_t paddr)
47{
48 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
49 paddr -= 0x400000000ull;
50 return octeon_hole_phys_to_dma(paddr);
51}
34 52
35#define BAR2_PCI_ADDRESS 0x8000000000ul 53static phys_addr_t octeon_gen1_dma_to_phys(struct device *dev, dma_addr_t daddr)
54{
55 daddr = octeon_hole_dma_to_phys(daddr);
36 56
37struct bar1_index_state { 57 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
38 int16_t ref_count; /* Number of PCI mappings using this index */ 58 daddr += 0x400000000ull;
39 uint16_t address_bits; /* Upper bits of physical address. This is
40 shifted 22 bits */
41};
42 59
43#ifdef CONFIG_PCI 60 return daddr;
44static DEFINE_RAW_SPINLOCK(bar1_lock); 61}
45static struct bar1_index_state bar1_state[32];
46#endif
47 62
48dma_addr_t octeon_map_dma_mem(struct device *dev, void *ptr, size_t size) 63static dma_addr_t octeon_big_phys_to_dma(struct device *dev, phys_addr_t paddr)
49{ 64{
50#ifndef CONFIG_PCI 65 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
51 /* Without PCI/PCIe this function can be called for Octeon internal 66 paddr -= 0x400000000ull;
52 devices such as USB. These devices all support 64bit addressing */ 67
68 /* Anything in the BAR1 hole or above goes via BAR2 */
69 if (paddr >= 0xf0000000ull)
70 paddr = OCTEON_BAR2_PCI_ADDRESS + paddr;
71
72 return paddr;
73}
74
75static phys_addr_t octeon_big_dma_to_phys(struct device *dev, dma_addr_t daddr)
76{
77 if (daddr >= OCTEON_BAR2_PCI_ADDRESS)
78 daddr -= OCTEON_BAR2_PCI_ADDRESS;
79
80 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
81 daddr += 0x400000000ull;
82 return daddr;
83}
84
85static dma_addr_t octeon_small_phys_to_dma(struct device *dev,
86 phys_addr_t paddr)
87{
88 if (paddr >= 0x410000000ull && paddr < 0x420000000ull)
89 paddr -= 0x400000000ull;
90
91 /* Anything not in the BAR1 range goes via BAR2 */
92 if (paddr >= octeon_bar1_pci_phys && paddr < octeon_bar1_pci_phys + 0x8000000ull)
93 paddr = paddr - octeon_bar1_pci_phys;
94 else
95 paddr = OCTEON_BAR2_PCI_ADDRESS + paddr;
96
97 return paddr;
98}
99
100static phys_addr_t octeon_small_dma_to_phys(struct device *dev,
101 dma_addr_t daddr)
102{
103 if (daddr >= OCTEON_BAR2_PCI_ADDRESS)
104 daddr -= OCTEON_BAR2_PCI_ADDRESS;
105 else
106 daddr += octeon_bar1_pci_phys;
107
108 if (daddr >= 0x10000000ull && daddr < 0x20000000ull)
109 daddr += 0x400000000ull;
110 return daddr;
111}
112
113#endif /* CONFIG_PCI */
114
115static dma_addr_t octeon_dma_map_page(struct device *dev, struct page *page,
116 unsigned long offset, size_t size, enum dma_data_direction direction,
117 struct dma_attrs *attrs)
118{
119 dma_addr_t daddr = swiotlb_map_page(dev, page, offset, size,
120 direction, attrs);
53 mb(); 121 mb();
54 return virt_to_phys(ptr);
55#else
56 unsigned long flags;
57 uint64_t dma_mask;
58 int64_t start_index;
59 dma_addr_t result = -1;
60 uint64_t physical = virt_to_phys(ptr);
61 int64_t index;
62 122
123 return daddr;
124}
125
126static int octeon_dma_map_sg(struct device *dev, struct scatterlist *sg,
127 int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
128{
129 int r = swiotlb_map_sg_attrs(dev, sg, nents, direction, attrs);
63 mb(); 130 mb();
64 /* 131 return r;
65 * Use the DMA masks to determine the allowed memory 132}
66 * region. For us it doesn't limit the actual memory, just the
67 * address visible over PCI. Devices with limits need to use
68 * lower indexed Bar1 entries.
69 */
70 if (dev) {
71 dma_mask = dev->coherent_dma_mask;
72 if (dev->dma_mask)
73 dma_mask = *dev->dma_mask;
74 } else {
75 dma_mask = 0xfffffffful;
76 }
77 133
78 /* 134static void octeon_dma_sync_single_for_device(struct device *dev,
79 * Platform devices, such as the internal USB, skip all 135 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
80 * translation and use Octeon physical addresses directly. 136{
81 */ 137 swiotlb_sync_single_for_device(dev, dma_handle, size, direction);
82 if (!dev || dev->bus == &platform_bus_type) 138 mb();
83 return physical; 139}
84 140
85 switch (octeon_dma_bar_type) { 141static void octeon_dma_sync_sg_for_device(struct device *dev,
86 case OCTEON_DMA_BAR_TYPE_PCIE: 142 struct scatterlist *sg, int nelems, enum dma_data_direction direction)
87 if (unlikely(physical < (16ul << 10))) 143{
88 panic("dma_map_single: Not allowed to map first 16KB." 144 swiotlb_sync_sg_for_device(dev, sg, nelems, direction);
89 " It interferes with BAR0 special area\n"); 145 mb();
90 else if ((physical + size >= (256ul << 20)) && 146}
91 (physical < (512ul << 20)))
92 panic("dma_map_single: Not allowed to map bootbus\n");
93 else if ((physical + size >= 0x400000000ull) &&
94 physical < 0x410000000ull)
95 panic("dma_map_single: "
96 "Attempt to map illegal memory address 0x%llx\n",
97 physical);
98 else if (physical >= 0x420000000ull)
99 panic("dma_map_single: "
100 "Attempt to map illegal memory address 0x%llx\n",
101 physical);
102 else if (physical >= CVMX_PCIE_BAR1_PHYS_BASE &&
103 physical + size < (CVMX_PCIE_BAR1_PHYS_BASE + CVMX_PCIE_BAR1_PHYS_SIZE)) {
104 result = physical - CVMX_PCIE_BAR1_PHYS_BASE + CVMX_PCIE_BAR1_RC_BASE;
105
106 if (((result+size-1) & dma_mask) != result+size-1)
107 panic("dma_map_single: Attempt to map address 0x%llx-0x%llx, which can't be accessed according to the dma mask 0x%llx\n",
108 physical, physical+size-1, dma_mask);
109 goto done;
110 }
111
112 /* The 2nd 256MB is mapped at 256<<20 instead of 0x410000000 */
113 if ((physical >= 0x410000000ull) && physical < 0x420000000ull)
114 result = physical - 0x400000000ull;
115 else
116 result = physical;
117 if (((result+size-1) & dma_mask) != result+size-1)
118 panic("dma_map_single: Attempt to map address "
119 "0x%llx-0x%llx, which can't be accessed "
120 "according to the dma mask 0x%llx\n",
121 physical, physical+size-1, dma_mask);
122 goto done;
123 147
124 case OCTEON_DMA_BAR_TYPE_BIG: 148static void *octeon_dma_alloc_coherent(struct device *dev, size_t size,
125#ifdef CONFIG_64BIT 149 dma_addr_t *dma_handle, gfp_t gfp)
126 /* If the device supports 64bit addressing, then use BAR2 */ 150{
127 if (dma_mask > BAR2_PCI_ADDRESS) { 151 void *ret;
128 result = physical + BAR2_PCI_ADDRESS;
129 goto done;
130 }
131#endif
132 if (unlikely(physical < (4ul << 10))) {
133 panic("dma_map_single: Not allowed to map first 4KB. "
134 "It interferes with BAR0 special area\n");
135 } else if (physical < (256ul << 20)) {
136 if (unlikely(physical + size > (256ul << 20)))
137 panic("dma_map_single: Requested memory spans "
138 "Bar0 0:256MB and bootbus\n");
139 result = physical;
140 goto done;
141 } else if (unlikely(physical < (512ul << 20))) {
142 panic("dma_map_single: Not allowed to map bootbus\n");
143 } else if (physical < (2ul << 30)) {
144 if (unlikely(physical + size > (2ul << 30)))
145 panic("dma_map_single: Requested memory spans "
146 "Bar0 512MB:2GB and BAR1\n");
147 result = physical;
148 goto done;
149 } else if (physical < (2ul << 30) + (128 << 20)) {
150 /* Fall through */
151 } else if (physical <
152 (4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20)) {
153 if (unlikely
154 (physical + size >
155 (4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20)))
156 panic("dma_map_single: Requested memory "
157 "extends past Bar1 (4GB-%luMB)\n",
158 OCTEON_PCI_BAR1_HOLE_SIZE);
159 result = physical;
160 goto done;
161 } else if ((physical >= 0x410000000ull) &&
162 (physical < 0x420000000ull)) {
163 if (unlikely(physical + size > 0x420000000ull))
164 panic("dma_map_single: Requested memory spans "
165 "non existant memory\n");
166 /* BAR0 fixed mapping 256MB:512MB ->
167 * 16GB+256MB:16GB+512MB */
168 result = physical - 0x400000000ull;
169 goto done;
170 } else {
171 /* Continued below switch statement */
172 }
173 break;
174 152
175 case OCTEON_DMA_BAR_TYPE_SMALL: 153 if (dma_alloc_from_coherent(dev, size, dma_handle, &ret))
176#ifdef CONFIG_64BIT 154 return ret;
177 /* If the device supports 64bit addressing, then use BAR2 */ 155
178 if (dma_mask > BAR2_PCI_ADDRESS) { 156 /* ignore region specifiers */
179 result = physical + BAR2_PCI_ADDRESS; 157 gfp &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM);
180 goto done; 158
181 } 159#ifdef CONFIG_ZONE_DMA
160 if (dev == NULL)
161 gfp |= __GFP_DMA;
162 else if (dev->coherent_dma_mask <= DMA_BIT_MASK(24))
163 gfp |= __GFP_DMA;
164 else
182#endif 165#endif
183 /* Continued below switch statement */ 166#ifdef CONFIG_ZONE_DMA32
184 break; 167 if (dev->coherent_dma_mask <= DMA_BIT_MASK(32))
168 gfp |= __GFP_DMA32;
169 else
170#endif
171 ;
185 172
186 default: 173 /* Don't invoke OOM killer */
187 panic("dma_map_single: Invalid octeon_dma_bar_type\n"); 174 gfp |= __GFP_NORETRY;
188 }
189 175
190 /* Don't allow mapping to span multiple Bar entries. The hardware guys 176 ret = swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
191 won't guarantee that DMA across boards work */
192 if (unlikely((physical >> 22) != ((physical + size - 1) >> 22)))
193 panic("dma_map_single: "
194 "Requested memory spans more than one Bar1 entry\n");
195 177
196 if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG) 178 mb();
197 start_index = 31;
198 else if (unlikely(dma_mask < (1ul << 27)))
199 start_index = (dma_mask >> 22);
200 else
201 start_index = 31;
202
203 /* Only one processor can access the Bar register at once */
204 raw_spin_lock_irqsave(&bar1_lock, flags);
205
206 /* Look through Bar1 for existing mapping that will work */
207 for (index = start_index; index >= 0; index--) {
208 if ((bar1_state[index].address_bits == physical >> 22) &&
209 (bar1_state[index].ref_count)) {
210 /* An existing mapping will work, use it */
211 bar1_state[index].ref_count++;
212 if (unlikely(bar1_state[index].ref_count < 0))
213 panic("dma_map_single: "
214 "Bar1[%d] reference count overflowed\n",
215 (int) index);
216 result = (index << 22) | (physical & ((1 << 22) - 1));
217 /* Large BAR1 is offset at 2GB */
218 if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG)
219 result += 2ul << 30;
220 goto done_unlock;
221 }
222 }
223 179
224 /* No existing mappings, look for a free entry */ 180 return ret;
225 for (index = start_index; index >= 0; index--) { 181}
226 if (unlikely(bar1_state[index].ref_count == 0)) {
227 union cvmx_pci_bar1_indexx bar1_index;
228 /* We have a free entry, use it */
229 bar1_state[index].ref_count = 1;
230 bar1_state[index].address_bits = physical >> 22;
231 bar1_index.u32 = 0;
232 /* Address bits[35:22] sent to L2C */
233 bar1_index.s.addr_idx = physical >> 22;
234 /* Don't put PCI accesses in L2. */
235 bar1_index.s.ca = 1;
236 /* Endian Swap Mode */
237 bar1_index.s.end_swp = 1;
238 /* Set '1' when the selected address range is valid. */
239 bar1_index.s.addr_v = 1;
240 octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index),
241 bar1_index.u32);
242 /* An existing mapping will work, use it */
243 result = (index << 22) | (physical & ((1 << 22) - 1));
244 /* Large BAR1 is offset at 2GB */
245 if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG)
246 result += 2ul << 30;
247 goto done_unlock;
248 }
249 }
250 182
251 pr_err("dma_map_single: " 183static void octeon_dma_free_coherent(struct device *dev, size_t size,
252 "Can't find empty BAR1 index for physical mapping 0x%llx\n", 184 void *vaddr, dma_addr_t dma_handle)
253 (unsigned long long) physical); 185{
186 int order = get_order(size);
254 187
255done_unlock: 188 if (dma_release_from_coherent(dev, order, vaddr))
256 raw_spin_unlock_irqrestore(&bar1_lock, flags); 189 return;
257done: 190
258 pr_debug("dma_map_single 0x%llx->0x%llx\n", physical, result); 191 swiotlb_free_coherent(dev, size, vaddr, dma_handle);
259 return result;
260#endif
261} 192}
262 193
263void octeon_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr) 194static dma_addr_t octeon_unity_phys_to_dma(struct device *dev, phys_addr_t paddr)
264{ 195{
265#ifndef CONFIG_PCI 196 return paddr;
266 /* 197}
267 * Without PCI/PCIe this function can be called for Octeon internal
268 * devices such as USB. These devices all support 64bit addressing.
269 */
270 return;
271#else
272 unsigned long flags;
273 uint64_t index;
274 198
199static phys_addr_t octeon_unity_dma_to_phys(struct device *dev, dma_addr_t daddr)
200{
201 return daddr;
202}
203
204struct octeon_dma_map_ops {
205 struct dma_map_ops dma_map_ops;
206 dma_addr_t (*phys_to_dma)(struct device *dev, phys_addr_t paddr);
207 phys_addr_t (*dma_to_phys)(struct device *dev, dma_addr_t daddr);
208};
209
210dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
211{
212 struct octeon_dma_map_ops *ops = container_of(get_dma_ops(dev),
213 struct octeon_dma_map_ops,
214 dma_map_ops);
215
216 return ops->phys_to_dma(dev, paddr);
217}
218EXPORT_SYMBOL(phys_to_dma);
219
220phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
221{
222 struct octeon_dma_map_ops *ops = container_of(get_dma_ops(dev),
223 struct octeon_dma_map_ops,
224 dma_map_ops);
225
226 return ops->dma_to_phys(dev, daddr);
227}
228EXPORT_SYMBOL(dma_to_phys);
229
230static struct octeon_dma_map_ops octeon_linear_dma_map_ops = {
231 .dma_map_ops = {
232 .alloc_coherent = octeon_dma_alloc_coherent,
233 .free_coherent = octeon_dma_free_coherent,
234 .map_page = octeon_dma_map_page,
235 .unmap_page = swiotlb_unmap_page,
236 .map_sg = octeon_dma_map_sg,
237 .unmap_sg = swiotlb_unmap_sg_attrs,
238 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
239 .sync_single_for_device = octeon_dma_sync_single_for_device,
240 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
241 .sync_sg_for_device = octeon_dma_sync_sg_for_device,
242 .mapping_error = swiotlb_dma_mapping_error,
243 .dma_supported = swiotlb_dma_supported
244 },
245 .phys_to_dma = octeon_unity_phys_to_dma,
246 .dma_to_phys = octeon_unity_dma_to_phys
247};
248
249char *octeon_swiotlb;
250
251void __init plat_swiotlb_setup(void)
252{
253 int i;
254 phys_t max_addr;
255 phys_t addr_size;
256 size_t swiotlbsize;
257 unsigned long swiotlb_nslabs;
258
259 max_addr = 0;
260 addr_size = 0;
261
262 for (i = 0 ; i < boot_mem_map.nr_map; i++) {
263 struct boot_mem_map_entry *e = &boot_mem_map.map[i];
264 if (e->type != BOOT_MEM_RAM)
265 continue;
266
267 /* These addresses map low for PCI. */
268 if (e->addr > 0x410000000ull)
269 continue;
270
271 addr_size += e->size;
272
273 if (max_addr < e->addr + e->size)
274 max_addr = e->addr + e->size;
275
276 }
277
278 swiotlbsize = PAGE_SIZE;
279
280#ifdef CONFIG_PCI
275 /* 281 /*
276 * Platform devices, such as the internal USB, skip all 282 * For OCTEON_DMA_BAR_TYPE_SMALL, size the iotlb at 1/4 memory
277 * translation and use Octeon physical addresses directly. 283 * size to a maximum of 64MB
278 */ 284 */
279 if (dev->bus == &platform_bus_type) 285 if (OCTEON_IS_MODEL(OCTEON_CN31XX)
280 return; 286 || OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2)) {
287 swiotlbsize = addr_size / 4;
288 if (swiotlbsize > 64 * (1<<20))
289 swiotlbsize = 64 * (1<<20);
290 } else if (max_addr > 0xf0000000ul) {
291 /*
292 * Otherwise only allocate a big iotlb if there is
293 * memory past the BAR1 hole.
294 */
295 swiotlbsize = 64 * (1<<20);
296 }
297#endif
298 swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT;
299 swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE);
300 swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT;
301
302 octeon_swiotlb = alloc_bootmem_low_pages(swiotlbsize);
281 303
304 swiotlb_init_with_tbl(octeon_swiotlb, swiotlb_nslabs, 1);
305
306 mips_dma_map_ops = &octeon_linear_dma_map_ops.dma_map_ops;
307}
308
309#ifdef CONFIG_PCI
310static struct octeon_dma_map_ops _octeon_pci_dma_map_ops = {
311 .dma_map_ops = {
312 .alloc_coherent = octeon_dma_alloc_coherent,
313 .free_coherent = octeon_dma_free_coherent,
314 .map_page = octeon_dma_map_page,
315 .unmap_page = swiotlb_unmap_page,
316 .map_sg = octeon_dma_map_sg,
317 .unmap_sg = swiotlb_unmap_sg_attrs,
318 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
319 .sync_single_for_device = octeon_dma_sync_single_for_device,
320 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
321 .sync_sg_for_device = octeon_dma_sync_sg_for_device,
322 .mapping_error = swiotlb_dma_mapping_error,
323 .dma_supported = swiotlb_dma_supported
324 },
325};
326
327struct dma_map_ops *octeon_pci_dma_map_ops;
328
329void __init octeon_pci_dma_init(void)
330{
282 switch (octeon_dma_bar_type) { 331 switch (octeon_dma_bar_type) {
283 case OCTEON_DMA_BAR_TYPE_PCIE: 332 case OCTEON_DMA_BAR_TYPE_PCIE:
284 /* Nothing to do, all mappings are static */ 333 _octeon_pci_dma_map_ops.phys_to_dma = octeon_gen1_phys_to_dma;
285 goto done; 334 _octeon_pci_dma_map_ops.dma_to_phys = octeon_gen1_dma_to_phys;
286 335 break;
287 case OCTEON_DMA_BAR_TYPE_BIG: 336 case OCTEON_DMA_BAR_TYPE_BIG:
288#ifdef CONFIG_64BIT 337 _octeon_pci_dma_map_ops.phys_to_dma = octeon_big_phys_to_dma;
289 /* Nothing to do for addresses using BAR2 */ 338 _octeon_pci_dma_map_ops.dma_to_phys = octeon_big_dma_to_phys;
290 if (dma_addr >= BAR2_PCI_ADDRESS)
291 goto done;
292#endif
293 if (unlikely(dma_addr < (4ul << 10)))
294 panic("dma_unmap_single: Unexpect DMA address 0x%llx\n",
295 dma_addr);
296 else if (dma_addr < (2ul << 30))
297 /* Nothing to do for addresses using BAR0 */
298 goto done;
299 else if (dma_addr < (2ul << 30) + (128ul << 20))
300 /* Need to unmap, fall through */
301 index = (dma_addr - (2ul << 30)) >> 22;
302 else if (dma_addr <
303 (4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20))
304 goto done; /* Nothing to do for the rest of BAR1 */
305 else
306 panic("dma_unmap_single: Unexpect DMA address 0x%llx\n",
307 dma_addr);
308 /* Continued below switch statement */
309 break; 339 break;
310
311 case OCTEON_DMA_BAR_TYPE_SMALL: 340 case OCTEON_DMA_BAR_TYPE_SMALL:
312#ifdef CONFIG_64BIT 341 _octeon_pci_dma_map_ops.phys_to_dma = octeon_small_phys_to_dma;
313 /* Nothing to do for addresses using BAR2 */ 342 _octeon_pci_dma_map_ops.dma_to_phys = octeon_small_dma_to_phys;
314 if (dma_addr >= BAR2_PCI_ADDRESS)
315 goto done;
316#endif
317 index = dma_addr >> 22;
318 /* Continued below switch statement */
319 break; 343 break;
320
321 default: 344 default:
322 panic("dma_unmap_single: Invalid octeon_dma_bar_type\n"); 345 BUG();
323 } 346 }
324 347 octeon_pci_dma_map_ops = &_octeon_pci_dma_map_ops.dma_map_ops;
325 if (unlikely(index > 31))
326 panic("dma_unmap_single: "
327 "Attempt to unmap an invalid address (0x%llx)\n",
328 dma_addr);
329
330 raw_spin_lock_irqsave(&bar1_lock, flags);
331 bar1_state[index].ref_count--;
332 if (bar1_state[index].ref_count == 0)
333 octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index), 0);
334 else if (unlikely(bar1_state[index].ref_count < 0))
335 panic("dma_unmap_single: Bar1[%u] reference count < 0\n",
336 (int) index);
337 raw_spin_unlock_irqrestore(&bar1_lock, flags);
338done:
339 pr_debug("dma_unmap_single 0x%llx\n", dma_addr);
340 return;
341#endif
342} 348}
349#endif /* CONFIG_PCI */
diff --git a/arch/mips/cavium-octeon/executive/cvmx-l2c.c b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
index 6abe56f1e097..d38246e33ddb 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-l2c.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -26,8 +26,8 @@
26 ***********************license end**************************************/ 26 ***********************license end**************************************/
27 27
28/* 28/*
29 * Implementation of the Level 2 Cache (L2C) control, measurement, and 29 * Implementation of the Level 2 Cache (L2C) control,
30 * debugging facilities. 30 * measurement, and debugging facilities.
31 */ 31 */
32 32
33#include <asm/octeon/cvmx.h> 33#include <asm/octeon/cvmx.h>
@@ -42,13 +42,7 @@
42 * if multiple applications or operating systems are running, then it 42 * if multiple applications or operating systems are running, then it
43 * is up to the user program to coordinate between them. 43 * is up to the user program to coordinate between them.
44 */ 44 */
45static cvmx_spinlock_t cvmx_l2c_spinlock; 45cvmx_spinlock_t cvmx_l2c_spinlock;
46
47static inline int l2_size_half(void)
48{
49 uint64_t val = cvmx_read_csr(CVMX_L2D_FUS3);
50 return !!(val & (1ull << 34));
51}
52 46
53int cvmx_l2c_get_core_way_partition(uint32_t core) 47int cvmx_l2c_get_core_way_partition(uint32_t core)
54{ 48{
@@ -58,6 +52,9 @@ int cvmx_l2c_get_core_way_partition(uint32_t core)
58 if (core >= cvmx_octeon_num_cores()) 52 if (core >= cvmx_octeon_num_cores())
59 return -1; 53 return -1;
60 54
55 if (OCTEON_IS_MODEL(OCTEON_CN63XX))
56 return cvmx_read_csr(CVMX_L2C_WPAR_PPX(core)) & 0xffff;
57
61 /* 58 /*
62 * Use the lower two bits of the coreNumber to determine the 59 * Use the lower two bits of the coreNumber to determine the
63 * bit offset of the UMSK[] field in the L2C_SPAR register. 60 * bit offset of the UMSK[] field in the L2C_SPAR register.
@@ -71,17 +68,13 @@ int cvmx_l2c_get_core_way_partition(uint32_t core)
71 68
72 switch (core & 0xC) { 69 switch (core & 0xC) {
73 case 0x0: 70 case 0x0:
74 return (cvmx_read_csr(CVMX_L2C_SPAR0) & (0xFF << field)) >> 71 return (cvmx_read_csr(CVMX_L2C_SPAR0) & (0xFF << field)) >> field;
75 field;
76 case 0x4: 72 case 0x4:
77 return (cvmx_read_csr(CVMX_L2C_SPAR1) & (0xFF << field)) >> 73 return (cvmx_read_csr(CVMX_L2C_SPAR1) & (0xFF << field)) >> field;
78 field;
79 case 0x8: 74 case 0x8:
80 return (cvmx_read_csr(CVMX_L2C_SPAR2) & (0xFF << field)) >> 75 return (cvmx_read_csr(CVMX_L2C_SPAR2) & (0xFF << field)) >> field;
81 field;
82 case 0xC: 76 case 0xC:
83 return (cvmx_read_csr(CVMX_L2C_SPAR3) & (0xFF << field)) >> 77 return (cvmx_read_csr(CVMX_L2C_SPAR3) & (0xFF << field)) >> field;
84 field;
85 } 78 }
86 return 0; 79 return 0;
87} 80}
@@ -95,48 +88,50 @@ int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask)
95 88
96 mask &= valid_mask; 89 mask &= valid_mask;
97 90
98 /* A UMSK setting which blocks all L2C Ways is an error. */ 91 /* A UMSK setting which blocks all L2C Ways is an error on some chips */
99 if (mask == valid_mask) 92 if (mask == valid_mask && !OCTEON_IS_MODEL(OCTEON_CN63XX))
100 return -1; 93 return -1;
101 94
102 /* Validate the core number */ 95 /* Validate the core number */
103 if (core >= cvmx_octeon_num_cores()) 96 if (core >= cvmx_octeon_num_cores())
104 return -1; 97 return -1;
105 98
106 /* Check to make sure current mask & new mask don't block all ways */ 99 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
107 if (((mask | cvmx_l2c_get_core_way_partition(core)) & valid_mask) == 100 cvmx_write_csr(CVMX_L2C_WPAR_PPX(core), mask);
108 valid_mask) 101 return 0;
109 return -1; 102 }
110 103
111 /* Use the lower two bits of core to determine the bit offset of the 104 /*
105 * Use the lower two bits of core to determine the bit offset of the
112 * UMSK[] field in the L2C_SPAR register. 106 * UMSK[] field in the L2C_SPAR register.
113 */ 107 */
114 field = (core & 0x3) * 8; 108 field = (core & 0x3) * 8;
115 109
116 /* Assign the new mask setting to the UMSK[] field in the appropriate 110 /*
111 * Assign the new mask setting to the UMSK[] field in the appropriate
117 * L2C_SPAR register based on the core_num. 112 * L2C_SPAR register based on the core_num.
118 * 113 *
119 */ 114 */
120 switch (core & 0xC) { 115 switch (core & 0xC) {
121 case 0x0: 116 case 0x0:
122 cvmx_write_csr(CVMX_L2C_SPAR0, 117 cvmx_write_csr(CVMX_L2C_SPAR0,
123 (cvmx_read_csr(CVMX_L2C_SPAR0) & 118 (cvmx_read_csr(CVMX_L2C_SPAR0) & ~(0xFF << field)) |
124 ~(0xFF << field)) | mask << field); 119 mask << field);
125 break; 120 break;
126 case 0x4: 121 case 0x4:
127 cvmx_write_csr(CVMX_L2C_SPAR1, 122 cvmx_write_csr(CVMX_L2C_SPAR1,
128 (cvmx_read_csr(CVMX_L2C_SPAR1) & 123 (cvmx_read_csr(CVMX_L2C_SPAR1) & ~(0xFF << field)) |
129 ~(0xFF << field)) | mask << field); 124 mask << field);
130 break; 125 break;
131 case 0x8: 126 case 0x8:
132 cvmx_write_csr(CVMX_L2C_SPAR2, 127 cvmx_write_csr(CVMX_L2C_SPAR2,
133 (cvmx_read_csr(CVMX_L2C_SPAR2) & 128 (cvmx_read_csr(CVMX_L2C_SPAR2) & ~(0xFF << field)) |
134 ~(0xFF << field)) | mask << field); 129 mask << field);
135 break; 130 break;
136 case 0xC: 131 case 0xC:
137 cvmx_write_csr(CVMX_L2C_SPAR3, 132 cvmx_write_csr(CVMX_L2C_SPAR3,
138 (cvmx_read_csr(CVMX_L2C_SPAR3) & 133 (cvmx_read_csr(CVMX_L2C_SPAR3) & ~(0xFF << field)) |
139 ~(0xFF << field)) | mask << field); 134 mask << field);
140 break; 135 break;
141 } 136 }
142 return 0; 137 return 0;
@@ -146,84 +141,137 @@ int cvmx_l2c_set_hw_way_partition(uint32_t mask)
146{ 141{
147 uint32_t valid_mask; 142 uint32_t valid_mask;
148 143
149 valid_mask = 0xff; 144 valid_mask = (0x1 << cvmx_l2c_get_num_assoc()) - 1;
150
151 if (OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN38XX)) {
152 if (l2_size_half())
153 valid_mask = 0xf;
154 } else if (l2_size_half())
155 valid_mask = 0x3;
156
157 mask &= valid_mask; 145 mask &= valid_mask;
158 146
159 /* A UMSK setting which blocks all L2C Ways is an error. */ 147 /* A UMSK setting which blocks all L2C Ways is an error on some chips */
160 if (mask == valid_mask) 148 if (mask == valid_mask && !OCTEON_IS_MODEL(OCTEON_CN63XX))
161 return -1;
162 /* Check to make sure current mask & new mask don't block all ways */
163 if (((mask | cvmx_l2c_get_hw_way_partition()) & valid_mask) ==
164 valid_mask)
165 return -1; 149 return -1;
166 150
167 cvmx_write_csr(CVMX_L2C_SPAR4, 151 if (OCTEON_IS_MODEL(OCTEON_CN63XX))
168 (cvmx_read_csr(CVMX_L2C_SPAR4) & ~0xFF) | mask); 152 cvmx_write_csr(CVMX_L2C_WPAR_IOBX(0), mask);
153 else
154 cvmx_write_csr(CVMX_L2C_SPAR4,
155 (cvmx_read_csr(CVMX_L2C_SPAR4) & ~0xFF) | mask);
169 return 0; 156 return 0;
170} 157}
171 158
172int cvmx_l2c_get_hw_way_partition(void) 159int cvmx_l2c_get_hw_way_partition(void)
173{ 160{
174 return cvmx_read_csr(CVMX_L2C_SPAR4) & (0xFF); 161 if (OCTEON_IS_MODEL(OCTEON_CN63XX))
162 return cvmx_read_csr(CVMX_L2C_WPAR_IOBX(0)) & 0xffff;
163 else
164 return cvmx_read_csr(CVMX_L2C_SPAR4) & (0xFF);
175} 165}
176 166
177void cvmx_l2c_config_perf(uint32_t counter, enum cvmx_l2c_event event, 167void cvmx_l2c_config_perf(uint32_t counter, enum cvmx_l2c_event event,
178 uint32_t clear_on_read) 168 uint32_t clear_on_read)
179{ 169{
180 union cvmx_l2c_pfctl pfctl; 170 if (OCTEON_IS_MODEL(OCTEON_CN5XXX) || OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
171 union cvmx_l2c_pfctl pfctl;
181 172
182 pfctl.u64 = cvmx_read_csr(CVMX_L2C_PFCTL); 173 pfctl.u64 = cvmx_read_csr(CVMX_L2C_PFCTL);
183 174
184 switch (counter) { 175 switch (counter) {
185 case 0: 176 case 0:
186 pfctl.s.cnt0sel = event; 177 pfctl.s.cnt0sel = event;
187 pfctl.s.cnt0ena = 1; 178 pfctl.s.cnt0ena = 1;
188 if (!cvmx_octeon_is_pass1())
189 pfctl.s.cnt0rdclr = clear_on_read; 179 pfctl.s.cnt0rdclr = clear_on_read;
190 break; 180 break;
191 case 1: 181 case 1:
192 pfctl.s.cnt1sel = event; 182 pfctl.s.cnt1sel = event;
193 pfctl.s.cnt1ena = 1; 183 pfctl.s.cnt1ena = 1;
194 if (!cvmx_octeon_is_pass1())
195 pfctl.s.cnt1rdclr = clear_on_read; 184 pfctl.s.cnt1rdclr = clear_on_read;
196 break; 185 break;
197 case 2: 186 case 2:
198 pfctl.s.cnt2sel = event; 187 pfctl.s.cnt2sel = event;
199 pfctl.s.cnt2ena = 1; 188 pfctl.s.cnt2ena = 1;
200 if (!cvmx_octeon_is_pass1())
201 pfctl.s.cnt2rdclr = clear_on_read; 189 pfctl.s.cnt2rdclr = clear_on_read;
202 break; 190 break;
203 case 3: 191 case 3:
204 default: 192 default:
205 pfctl.s.cnt3sel = event; 193 pfctl.s.cnt3sel = event;
206 pfctl.s.cnt3ena = 1; 194 pfctl.s.cnt3ena = 1;
207 if (!cvmx_octeon_is_pass1())
208 pfctl.s.cnt3rdclr = clear_on_read; 195 pfctl.s.cnt3rdclr = clear_on_read;
209 break; 196 break;
210 } 197 }
211 198
212 cvmx_write_csr(CVMX_L2C_PFCTL, pfctl.u64); 199 cvmx_write_csr(CVMX_L2C_PFCTL, pfctl.u64);
200 } else {
201 union cvmx_l2c_tadx_prf l2c_tadx_prf;
202 int tad;
203
204 cvmx_dprintf("L2C performance counter events are different for this chip, mapping 'event' to cvmx_l2c_tad_event_t\n");
205 if (clear_on_read)
206 cvmx_dprintf("L2C counters don't support clear on read for this chip\n");
207
208 l2c_tadx_prf.u64 = cvmx_read_csr(CVMX_L2C_TADX_PRF(0));
209
210 switch (counter) {
211 case 0:
212 l2c_tadx_prf.s.cnt0sel = event;
213 break;
214 case 1:
215 l2c_tadx_prf.s.cnt1sel = event;
216 break;
217 case 2:
218 l2c_tadx_prf.s.cnt2sel = event;
219 break;
220 default:
221 case 3:
222 l2c_tadx_prf.s.cnt3sel = event;
223 break;
224 }
225 for (tad = 0; tad < CVMX_L2C_TADS; tad++)
226 cvmx_write_csr(CVMX_L2C_TADX_PRF(tad),
227 l2c_tadx_prf.u64);
228 }
213} 229}
214 230
215uint64_t cvmx_l2c_read_perf(uint32_t counter) 231uint64_t cvmx_l2c_read_perf(uint32_t counter)
216{ 232{
217 switch (counter) { 233 switch (counter) {
218 case 0: 234 case 0:
219 return cvmx_read_csr(CVMX_L2C_PFC0); 235 if (OCTEON_IS_MODEL(OCTEON_CN5XXX) || OCTEON_IS_MODEL(OCTEON_CN3XXX))
236 return cvmx_read_csr(CVMX_L2C_PFC0);
237 else {
238 uint64_t counter = 0;
239 int tad;
240 for (tad = 0; tad < CVMX_L2C_TADS; tad++)
241 counter += cvmx_read_csr(CVMX_L2C_TADX_PFC0(tad));
242 return counter;
243 }
220 case 1: 244 case 1:
221 return cvmx_read_csr(CVMX_L2C_PFC1); 245 if (OCTEON_IS_MODEL(OCTEON_CN5XXX) || OCTEON_IS_MODEL(OCTEON_CN3XXX))
246 return cvmx_read_csr(CVMX_L2C_PFC1);
247 else {
248 uint64_t counter = 0;
249 int tad;
250 for (tad = 0; tad < CVMX_L2C_TADS; tad++)
251 counter += cvmx_read_csr(CVMX_L2C_TADX_PFC1(tad));
252 return counter;
253 }
222 case 2: 254 case 2:
223 return cvmx_read_csr(CVMX_L2C_PFC2); 255 if (OCTEON_IS_MODEL(OCTEON_CN5XXX) || OCTEON_IS_MODEL(OCTEON_CN3XXX))
256 return cvmx_read_csr(CVMX_L2C_PFC2);
257 else {
258 uint64_t counter = 0;
259 int tad;
260 for (tad = 0; tad < CVMX_L2C_TADS; tad++)
261 counter += cvmx_read_csr(CVMX_L2C_TADX_PFC2(tad));
262 return counter;
263 }
224 case 3: 264 case 3:
225 default: 265 default:
226 return cvmx_read_csr(CVMX_L2C_PFC3); 266 if (OCTEON_IS_MODEL(OCTEON_CN5XXX) || OCTEON_IS_MODEL(OCTEON_CN3XXX))
267 return cvmx_read_csr(CVMX_L2C_PFC3);
268 else {
269 uint64_t counter = 0;
270 int tad;
271 for (tad = 0; tad < CVMX_L2C_TADS; tad++)
272 counter += cvmx_read_csr(CVMX_L2C_TADX_PFC3(tad));
273 return counter;
274 }
227 } 275 }
228} 276}
229 277
@@ -240,7 +288,7 @@ static void fault_in(uint64_t addr, int len)
240 volatile char dummy; 288 volatile char dummy;
241 /* 289 /*
242 * Adjust addr and length so we get all cache lines even for 290 * Adjust addr and length so we get all cache lines even for
243 * small ranges spanning two cache lines 291 * small ranges spanning two cache lines.
244 */ 292 */
245 len += addr & CVMX_CACHE_LINE_MASK; 293 len += addr & CVMX_CACHE_LINE_MASK;
246 addr &= ~CVMX_CACHE_LINE_MASK; 294 addr &= ~CVMX_CACHE_LINE_MASK;
@@ -259,67 +307,100 @@ static void fault_in(uint64_t addr, int len)
259 307
260int cvmx_l2c_lock_line(uint64_t addr) 308int cvmx_l2c_lock_line(uint64_t addr)
261{ 309{
262 int retval = 0; 310 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
263 union cvmx_l2c_dbg l2cdbg; 311 int shift = CVMX_L2C_TAG_ADDR_ALIAS_SHIFT;
264 union cvmx_l2c_lckbase lckbase; 312 uint64_t assoc = cvmx_l2c_get_num_assoc();
265 union cvmx_l2c_lckoff lckoff; 313 uint64_t tag = addr >> shift;
266 union cvmx_l2t_err l2t_err; 314 uint64_t index = CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, cvmx_l2c_address_to_index(addr) << CVMX_L2C_IDX_ADDR_SHIFT);
267 l2cdbg.u64 = 0; 315 uint64_t way;
268 lckbase.u64 = 0; 316 union cvmx_l2c_tadx_tag l2c_tadx_tag;
269 lckoff.u64 = 0; 317
270 318 CVMX_CACHE_LCKL2(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, addr), 0);
271 cvmx_spinlock_lock(&cvmx_l2c_spinlock); 319
272 320 /* Make sure we were able to lock the line */
273 /* Clear l2t error bits if set */ 321 for (way = 0; way < assoc; way++) {
274 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR); 322 CVMX_CACHE_LTGL2I(index | (way << shift), 0);
275 l2t_err.s.lckerr = 1; 323 /* make sure CVMX_L2C_TADX_TAG is updated */
276 l2t_err.s.lckerr2 = 1; 324 CVMX_SYNC;
277 cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64); 325 l2c_tadx_tag.u64 = cvmx_read_csr(CVMX_L2C_TADX_TAG(0));
326 if (l2c_tadx_tag.s.valid && l2c_tadx_tag.s.tag == tag)
327 break;
328 }
278 329
279 addr &= ~CVMX_CACHE_LINE_MASK; 330 /* Check if a valid line is found */
331 if (way >= assoc) {
332 /* cvmx_dprintf("ERROR: cvmx_l2c_lock_line: line not found for locking at 0x%llx address\n", (unsigned long long)addr); */
333 return -1;
334 }
280 335
281 /* Set this core as debug core */ 336 /* Check if lock bit is not set */
282 l2cdbg.s.ppnum = cvmx_get_core_num(); 337 if (!l2c_tadx_tag.s.lock) {
283 CVMX_SYNC; 338 /* cvmx_dprintf("ERROR: cvmx_l2c_lock_line: Not able to lock at 0x%llx address\n", (unsigned long long)addr); */
284 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64); 339 return -1;
285 cvmx_read_csr(CVMX_L2C_DBG); 340 }
286 341 return way;
287 lckoff.s.lck_offset = 0; /* Only lock 1 line at a time */
288 cvmx_write_csr(CVMX_L2C_LCKOFF, lckoff.u64);
289 cvmx_read_csr(CVMX_L2C_LCKOFF);
290
291 if (((union cvmx_l2c_cfg) (cvmx_read_csr(CVMX_L2C_CFG))).s.idxalias) {
292 int alias_shift =
293 CVMX_L2C_IDX_ADDR_SHIFT + 2 * CVMX_L2_SET_BITS - 1;
294 uint64_t addr_tmp =
295 addr ^ (addr & ((1 << alias_shift) - 1)) >>
296 CVMX_L2_SET_BITS;
297 lckbase.s.lck_base = addr_tmp >> 7;
298 } else { 342 } else {
299 lckbase.s.lck_base = addr >> 7; 343 int retval = 0;
300 } 344 union cvmx_l2c_dbg l2cdbg;
345 union cvmx_l2c_lckbase lckbase;
346 union cvmx_l2c_lckoff lckoff;
347 union cvmx_l2t_err l2t_err;
301 348
302 lckbase.s.lck_ena = 1; 349 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
303 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64);
304 cvmx_read_csr(CVMX_L2C_LCKBASE); /* Make sure it gets there */
305 350
306 fault_in(addr, CVMX_CACHE_LINE_SIZE); 351 l2cdbg.u64 = 0;
352 lckbase.u64 = 0;
353 lckoff.u64 = 0;
307 354
308 lckbase.s.lck_ena = 0; 355 /* Clear l2t error bits if set */
309 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64); 356 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
310 cvmx_read_csr(CVMX_L2C_LCKBASE); /* Make sure it gets there */ 357 l2t_err.s.lckerr = 1;
358 l2t_err.s.lckerr2 = 1;
359 cvmx_write_csr(CVMX_L2T_ERR, l2t_err.u64);
311 360
312 /* Stop being debug core */ 361 addr &= ~CVMX_CACHE_LINE_MASK;
313 cvmx_write_csr(CVMX_L2C_DBG, 0);
314 cvmx_read_csr(CVMX_L2C_DBG);
315 362
316 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR); 363 /* Set this core as debug core */
317 if (l2t_err.s.lckerr || l2t_err.s.lckerr2) 364 l2cdbg.s.ppnum = cvmx_get_core_num();
318 retval = 1; /* We were unable to lock the line */ 365 CVMX_SYNC;
366 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64);
367 cvmx_read_csr(CVMX_L2C_DBG);
368
369 lckoff.s.lck_offset = 0; /* Only lock 1 line at a time */
370 cvmx_write_csr(CVMX_L2C_LCKOFF, lckoff.u64);
371 cvmx_read_csr(CVMX_L2C_LCKOFF);
372
373 if (((union cvmx_l2c_cfg)(cvmx_read_csr(CVMX_L2C_CFG))).s.idxalias) {
374 int alias_shift = CVMX_L2C_IDX_ADDR_SHIFT + 2 * CVMX_L2_SET_BITS - 1;
375 uint64_t addr_tmp = addr ^ (addr & ((1 << alias_shift) - 1)) >> CVMX_L2_SET_BITS;
376 lckbase.s.lck_base = addr_tmp >> 7;
377 } else {
378 lckbase.s.lck_base = addr >> 7;
379 }
319 380
320 cvmx_spinlock_unlock(&cvmx_l2c_spinlock); 381 lckbase.s.lck_ena = 1;
382 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64);
383 /* Make sure it gets there */
384 cvmx_read_csr(CVMX_L2C_LCKBASE);
321 385
322 return retval; 386 fault_in(addr, CVMX_CACHE_LINE_SIZE);
387
388 lckbase.s.lck_ena = 0;
389 cvmx_write_csr(CVMX_L2C_LCKBASE, lckbase.u64);
390 /* Make sure it gets there */
391 cvmx_read_csr(CVMX_L2C_LCKBASE);
392
393 /* Stop being debug core */
394 cvmx_write_csr(CVMX_L2C_DBG, 0);
395 cvmx_read_csr(CVMX_L2C_DBG);
396
397 l2t_err.u64 = cvmx_read_csr(CVMX_L2T_ERR);
398 if (l2t_err.s.lckerr || l2t_err.s.lckerr2)
399 retval = 1; /* We were unable to lock the line */
400
401 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
402 return retval;
403 }
323} 404}
324 405
325int cvmx_l2c_lock_mem_region(uint64_t start, uint64_t len) 406int cvmx_l2c_lock_mem_region(uint64_t start, uint64_t len)
@@ -336,7 +417,6 @@ int cvmx_l2c_lock_mem_region(uint64_t start, uint64_t len)
336 start += CVMX_CACHE_LINE_SIZE; 417 start += CVMX_CACHE_LINE_SIZE;
337 len -= CVMX_CACHE_LINE_SIZE; 418 len -= CVMX_CACHE_LINE_SIZE;
338 } 419 }
339
340 return retval; 420 return retval;
341} 421}
342 422
@@ -344,80 +424,73 @@ void cvmx_l2c_flush(void)
344{ 424{
345 uint64_t assoc, set; 425 uint64_t assoc, set;
346 uint64_t n_assoc, n_set; 426 uint64_t n_assoc, n_set;
347 union cvmx_l2c_dbg l2cdbg;
348
349 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
350 427
351 l2cdbg.u64 = 0; 428 n_set = cvmx_l2c_get_num_sets();
352 if (!OCTEON_IS_MODEL(OCTEON_CN30XX)) 429 n_assoc = cvmx_l2c_get_num_assoc();
353 l2cdbg.s.ppnum = cvmx_get_core_num(); 430
354 l2cdbg.s.finv = 1; 431 if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
355 n_set = CVMX_L2_SETS; 432 uint64_t address;
356 n_assoc = l2_size_half() ? (CVMX_L2_ASSOC / 2) : CVMX_L2_ASSOC; 433 /* These may look like constants, but they aren't... */
357 for (set = 0; set < n_set; set++) { 434 int assoc_shift = CVMX_L2C_TAG_ADDR_ALIAS_SHIFT;
358 for (assoc = 0; assoc < n_assoc; assoc++) { 435 int set_shift = CVMX_L2C_IDX_ADDR_SHIFT;
359 l2cdbg.s.set = assoc; 436 for (set = 0; set < n_set; set++) {
360 /* Enter debug mode, and make sure all other 437 for (assoc = 0; assoc < n_assoc; assoc++) {
361 ** writes complete before we enter debug 438 address = CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,
362 ** mode */ 439 (assoc << assoc_shift) | (set << set_shift));
363 CVMX_SYNCW; 440 CVMX_CACHE_WBIL2I(address, 0);
364 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64); 441 }
365 cvmx_read_csr(CVMX_L2C_DBG);
366
367 CVMX_PREPARE_FOR_STORE(CVMX_ADD_SEG
368 (CVMX_MIPS_SPACE_XKPHYS,
369 set * CVMX_CACHE_LINE_SIZE), 0);
370 CVMX_SYNCW; /* Push STF out to L2 */
371 /* Exit debug mode */
372 CVMX_SYNC;
373 cvmx_write_csr(CVMX_L2C_DBG, 0);
374 cvmx_read_csr(CVMX_L2C_DBG);
375 } 442 }
443 } else {
444 for (set = 0; set < n_set; set++)
445 for (assoc = 0; assoc < n_assoc; assoc++)
446 cvmx_l2c_flush_line(assoc, set);
376 } 447 }
377
378 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
379} 448}
380 449
450
381int cvmx_l2c_unlock_line(uint64_t address) 451int cvmx_l2c_unlock_line(uint64_t address)
382{ 452{
383 int assoc;
384 union cvmx_l2c_tag tag;
385 union cvmx_l2c_dbg l2cdbg;
386 uint32_t tag_addr;
387 453
388 uint32_t index = cvmx_l2c_address_to_index(address); 454 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
455 int assoc;
456 union cvmx_l2c_tag tag;
457 uint32_t tag_addr;
458 uint32_t index = cvmx_l2c_address_to_index(address);
459
460 tag_addr = ((address >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) & ((1 << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) - 1));
461
462 /*
463 * For 63XX, we can flush a line by using the physical
464 * address directly, so finding the cache line used by
465 * the address is only required to provide the proper
466 * return value for the function.
467 */
468 for (assoc = 0; assoc < CVMX_L2_ASSOC; assoc++) {
469 tag = cvmx_l2c_get_tag(assoc, index);
470
471 if (tag.s.V && (tag.s.addr == tag_addr)) {
472 CVMX_CACHE_WBIL2(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, address), 0);
473 return tag.s.L;
474 }
475 }
476 } else {
477 int assoc;
478 union cvmx_l2c_tag tag;
479 uint32_t tag_addr;
389 480
390 cvmx_spinlock_lock(&cvmx_l2c_spinlock); 481 uint32_t index = cvmx_l2c_address_to_index(address);
391 /* Compute portion of address that is stored in tag */
392 tag_addr =
393 ((address >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) &
394 ((1 << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) - 1));
395 for (assoc = 0; assoc < CVMX_L2_ASSOC; assoc++) {
396 tag = cvmx_get_l2c_tag(assoc, index);
397 482
398 if (tag.s.V && (tag.s.addr == tag_addr)) { 483 /* Compute portion of address that is stored in tag */
399 l2cdbg.u64 = 0; 484 tag_addr = ((address >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) & ((1 << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) - 1));
400 l2cdbg.s.ppnum = cvmx_get_core_num(); 485 for (assoc = 0; assoc < CVMX_L2_ASSOC; assoc++) {
401 l2cdbg.s.set = assoc; 486 tag = cvmx_l2c_get_tag(assoc, index);
402 l2cdbg.s.finv = 1;
403 487
404 CVMX_SYNC; 488 if (tag.s.V && (tag.s.addr == tag_addr)) {
405 /* Enter debug mode */ 489 cvmx_l2c_flush_line(assoc, index);
406 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64); 490 return tag.s.L;
407 cvmx_read_csr(CVMX_L2C_DBG); 491 }
408
409 CVMX_PREPARE_FOR_STORE(CVMX_ADD_SEG
410 (CVMX_MIPS_SPACE_XKPHYS,
411 address), 0);
412 CVMX_SYNC;
413 /* Exit debug mode */
414 cvmx_write_csr(CVMX_L2C_DBG, 0);
415 cvmx_read_csr(CVMX_L2C_DBG);
416 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
417 return tag.s.L;
418 } 492 }
419 } 493 }
420 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
421 return 0; 494 return 0;
422} 495}
423 496
@@ -445,48 +518,49 @@ union __cvmx_l2c_tag {
445 uint64_t u64; 518 uint64_t u64;
446 struct cvmx_l2c_tag_cn50xx { 519 struct cvmx_l2c_tag_cn50xx {
447 uint64_t reserved:40; 520 uint64_t reserved:40;
448 uint64_t V:1; /* Line valid */ 521 uint64_t V:1; /* Line valid */
449 uint64_t D:1; /* Line dirty */ 522 uint64_t D:1; /* Line dirty */
450 uint64_t L:1; /* Line locked */ 523 uint64_t L:1; /* Line locked */
451 uint64_t U:1; /* Use, LRU eviction */ 524 uint64_t U:1; /* Use, LRU eviction */
452 uint64_t addr:20; /* Phys mem addr (33..14) */ 525 uint64_t addr:20; /* Phys mem addr (33..14) */
453 } cn50xx; 526 } cn50xx;
454 struct cvmx_l2c_tag_cn30xx { 527 struct cvmx_l2c_tag_cn30xx {
455 uint64_t reserved:41; 528 uint64_t reserved:41;
456 uint64_t V:1; /* Line valid */ 529 uint64_t V:1; /* Line valid */
457 uint64_t D:1; /* Line dirty */ 530 uint64_t D:1; /* Line dirty */
458 uint64_t L:1; /* Line locked */ 531 uint64_t L:1; /* Line locked */
459 uint64_t U:1; /* Use, LRU eviction */ 532 uint64_t U:1; /* Use, LRU eviction */
460 uint64_t addr:19; /* Phys mem addr (33..15) */ 533 uint64_t addr:19; /* Phys mem addr (33..15) */
461 } cn30xx; 534 } cn30xx;
462 struct cvmx_l2c_tag_cn31xx { 535 struct cvmx_l2c_tag_cn31xx {
463 uint64_t reserved:42; 536 uint64_t reserved:42;
464 uint64_t V:1; /* Line valid */ 537 uint64_t V:1; /* Line valid */
465 uint64_t D:1; /* Line dirty */ 538 uint64_t D:1; /* Line dirty */
466 uint64_t L:1; /* Line locked */ 539 uint64_t L:1; /* Line locked */
467 uint64_t U:1; /* Use, LRU eviction */ 540 uint64_t U:1; /* Use, LRU eviction */
468 uint64_t addr:18; /* Phys mem addr (33..16) */ 541 uint64_t addr:18; /* Phys mem addr (33..16) */
469 } cn31xx; 542 } cn31xx;
470 struct cvmx_l2c_tag_cn38xx { 543 struct cvmx_l2c_tag_cn38xx {
471 uint64_t reserved:43; 544 uint64_t reserved:43;
472 uint64_t V:1; /* Line valid */ 545 uint64_t V:1; /* Line valid */
473 uint64_t D:1; /* Line dirty */ 546 uint64_t D:1; /* Line dirty */
474 uint64_t L:1; /* Line locked */ 547 uint64_t L:1; /* Line locked */
475 uint64_t U:1; /* Use, LRU eviction */ 548 uint64_t U:1; /* Use, LRU eviction */
476 uint64_t addr:17; /* Phys mem addr (33..17) */ 549 uint64_t addr:17; /* Phys mem addr (33..17) */
477 } cn38xx; 550 } cn38xx;
478 struct cvmx_l2c_tag_cn58xx { 551 struct cvmx_l2c_tag_cn58xx {
479 uint64_t reserved:44; 552 uint64_t reserved:44;
480 uint64_t V:1; /* Line valid */ 553 uint64_t V:1; /* Line valid */
481 uint64_t D:1; /* Line dirty */ 554 uint64_t D:1; /* Line dirty */
482 uint64_t L:1; /* Line locked */ 555 uint64_t L:1; /* Line locked */
483 uint64_t U:1; /* Use, LRU eviction */ 556 uint64_t U:1; /* Use, LRU eviction */
484 uint64_t addr:16; /* Phys mem addr (33..18) */ 557 uint64_t addr:16; /* Phys mem addr (33..18) */
485 } cn58xx; 558 } cn58xx;
486 struct cvmx_l2c_tag_cn58xx cn56xx; /* 2048 sets */ 559 struct cvmx_l2c_tag_cn58xx cn56xx; /* 2048 sets */
487 struct cvmx_l2c_tag_cn31xx cn52xx; /* 512 sets */ 560 struct cvmx_l2c_tag_cn31xx cn52xx; /* 512 sets */
488}; 561};
489 562
563
490/** 564/**
491 * @INTERNAL 565 * @INTERNAL
492 * Function to read a L2C tag. This code make the current core 566 * Function to read a L2C tag. This code make the current core
@@ -503,7 +577,7 @@ union __cvmx_l2c_tag {
503static union __cvmx_l2c_tag __read_l2_tag(uint64_t assoc, uint64_t index) 577static union __cvmx_l2c_tag __read_l2_tag(uint64_t assoc, uint64_t index)
504{ 578{
505 579
506 uint64_t debug_tag_addr = (((1ULL << 63) | (index << 7)) + 96); 580 uint64_t debug_tag_addr = CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS, (index << 7) + 96);
507 uint64_t core = cvmx_get_core_num(); 581 uint64_t core = cvmx_get_core_num();
508 union __cvmx_l2c_tag tag_val; 582 union __cvmx_l2c_tag tag_val;
509 uint64_t dbg_addr = CVMX_L2C_DBG; 583 uint64_t dbg_addr = CVMX_L2C_DBG;
@@ -512,12 +586,15 @@ static union __cvmx_l2c_tag __read_l2_tag(uint64_t assoc, uint64_t index)
512 union cvmx_l2c_dbg debug_val; 586 union cvmx_l2c_dbg debug_val;
513 debug_val.u64 = 0; 587 debug_val.u64 = 0;
514 /* 588 /*
515 * For low core count parts, the core number is always small enough 589 * For low core count parts, the core number is always small
516 * to stay in the correct field and not set any reserved bits. 590 * enough to stay in the correct field and not set any
591 * reserved bits.
517 */ 592 */
518 debug_val.s.ppnum = core; 593 debug_val.s.ppnum = core;
519 debug_val.s.l2t = 1; 594 debug_val.s.l2t = 1;
520 debug_val.s.set = assoc; 595 debug_val.s.set = assoc;
596
597 local_irq_save(flags);
521 /* 598 /*
522 * Make sure core is quiet (no prefetches, etc.) before 599 * Make sure core is quiet (no prefetches, etc.) before
523 * entering debug mode. 600 * entering debug mode.
@@ -526,112 +603,139 @@ static union __cvmx_l2c_tag __read_l2_tag(uint64_t assoc, uint64_t index)
526 /* Flush L1 to make sure debug load misses L1 */ 603 /* Flush L1 to make sure debug load misses L1 */
527 CVMX_DCACHE_INVALIDATE; 604 CVMX_DCACHE_INVALIDATE;
528 605
529 local_irq_save(flags);
530
531 /* 606 /*
532 * The following must be done in assembly as when in debug 607 * The following must be done in assembly as when in debug
533 * mode all data loads from L2 return special debug data, not 608 * mode all data loads from L2 return special debug data, not
534 * normal memory contents. Also, interrupts must be 609 * normal memory contents. Also, interrupts must be disabled,
535 * disabled, since if an interrupt occurs while in debug mode 610 * since if an interrupt occurs while in debug mode the ISR
536 * the ISR will get debug data from all its memory reads 611 * will get debug data from all its memory * reads instead of
537 * instead of the contents of memory 612 * the contents of memory.
538 */ 613 */
539 614
540 asm volatile (".set push \n" 615 asm volatile (
541 " .set mips64 \n" 616 ".set push\n\t"
542 " .set noreorder \n" 617 ".set mips64\n\t"
543 /* Enter debug mode, wait for store */ 618 ".set noreorder\n\t"
544 " sd %[dbg_val], 0(%[dbg_addr]) \n" 619 "sd %[dbg_val], 0(%[dbg_addr])\n\t" /* Enter debug mode, wait for store */
545 " ld $0, 0(%[dbg_addr]) \n" 620 "ld $0, 0(%[dbg_addr])\n\t"
546 /* Read L2C tag data */ 621 "ld %[tag_val], 0(%[tag_addr])\n\t" /* Read L2C tag data */
547 " ld %[tag_val], 0(%[tag_addr]) \n" 622 "sd $0, 0(%[dbg_addr])\n\t" /* Exit debug mode, wait for store */
548 /* Exit debug mode, wait for store */ 623 "ld $0, 0(%[dbg_addr])\n\t"
549 " sd $0, 0(%[dbg_addr]) \n" 624 "cache 9, 0($0)\n\t" /* Invalidate dcache to discard debug data */
550 " ld $0, 0(%[dbg_addr]) \n" 625 ".set pop"
551 /* Invalidate dcache to discard debug data */ 626 : [tag_val] "=r" (tag_val)
552 " cache 9, 0($0) \n" 627 : [dbg_addr] "r" (dbg_addr), [dbg_val] "r" (debug_val), [tag_addr] "r" (debug_tag_addr)
553 " .set pop" : 628 : "memory");
554 [tag_val] "=r"(tag_val.u64) : [dbg_addr] "r"(dbg_addr),
555 [dbg_val] "r"(debug_val.u64),
556 [tag_addr] "r"(debug_tag_addr) : "memory");
557 629
558 local_irq_restore(flags); 630 local_irq_restore(flags);
559 return tag_val;
560 631
632 return tag_val;
561} 633}
562 634
635
563union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index) 636union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index)
564{ 637{
565 union __cvmx_l2c_tag tmp_tag;
566 union cvmx_l2c_tag tag; 638 union cvmx_l2c_tag tag;
567 tag.u64 = 0; 639 tag.u64 = 0;
568 640
569 if ((int)association >= cvmx_l2c_get_num_assoc()) { 641 if ((int)association >= cvmx_l2c_get_num_assoc()) {
570 cvmx_dprintf 642 cvmx_dprintf("ERROR: cvmx_l2c_get_tag association out of range\n");
571 ("ERROR: cvmx_get_l2c_tag association out of range\n");
572 return tag; 643 return tag;
573 } 644 }
574 if ((int)index >= cvmx_l2c_get_num_sets()) { 645 if ((int)index >= cvmx_l2c_get_num_sets()) {
575 cvmx_dprintf("ERROR: cvmx_get_l2c_tag " 646 cvmx_dprintf("ERROR: cvmx_l2c_get_tag index out of range (arg: %d, max: %d)\n",
576 "index out of range (arg: %d, max: %d\n", 647 (int)index, cvmx_l2c_get_num_sets());
577 index, cvmx_l2c_get_num_sets());
578 return tag; 648 return tag;
579 } 649 }
580 /* __read_l2_tag is intended for internal use only */ 650 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
581 tmp_tag = __read_l2_tag(association, index); 651 union cvmx_l2c_tadx_tag l2c_tadx_tag;
582 652 uint64_t address = CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,
583 /* 653 (association << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) |
584 * Convert all tag structure types to generic version, as it 654 (index << CVMX_L2C_IDX_ADDR_SHIFT));
585 * can represent all models. 655 /*
586 */ 656 * Use L2 cache Index load tag cache instruction, as
587 if (OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX)) { 657 * hardware loads the virtual tag for the L2 cache
588 tag.s.V = tmp_tag.cn58xx.V; 658 * block with the contents of L2C_TAD0_TAG
589 tag.s.D = tmp_tag.cn58xx.D; 659 * register.
590 tag.s.L = tmp_tag.cn58xx.L; 660 */
591 tag.s.U = tmp_tag.cn58xx.U; 661 CVMX_CACHE_LTGL2I(address, 0);
592 tag.s.addr = tmp_tag.cn58xx.addr; 662 CVMX_SYNC; /* make sure CVMX_L2C_TADX_TAG is updated */
593 } else if (OCTEON_IS_MODEL(OCTEON_CN38XX)) { 663 l2c_tadx_tag.u64 = cvmx_read_csr(CVMX_L2C_TADX_TAG(0));
594 tag.s.V = tmp_tag.cn38xx.V; 664
595 tag.s.D = tmp_tag.cn38xx.D; 665 tag.s.V = l2c_tadx_tag.s.valid;
596 tag.s.L = tmp_tag.cn38xx.L; 666 tag.s.D = l2c_tadx_tag.s.dirty;
597 tag.s.U = tmp_tag.cn38xx.U; 667 tag.s.L = l2c_tadx_tag.s.lock;
598 tag.s.addr = tmp_tag.cn38xx.addr; 668 tag.s.U = l2c_tadx_tag.s.use;
599 } else if (OCTEON_IS_MODEL(OCTEON_CN31XX) 669 tag.s.addr = l2c_tadx_tag.s.tag;
600 || OCTEON_IS_MODEL(OCTEON_CN52XX)) {
601 tag.s.V = tmp_tag.cn31xx.V;
602 tag.s.D = tmp_tag.cn31xx.D;
603 tag.s.L = tmp_tag.cn31xx.L;
604 tag.s.U = tmp_tag.cn31xx.U;
605 tag.s.addr = tmp_tag.cn31xx.addr;
606 } else if (OCTEON_IS_MODEL(OCTEON_CN30XX)) {
607 tag.s.V = tmp_tag.cn30xx.V;
608 tag.s.D = tmp_tag.cn30xx.D;
609 tag.s.L = tmp_tag.cn30xx.L;
610 tag.s.U = tmp_tag.cn30xx.U;
611 tag.s.addr = tmp_tag.cn30xx.addr;
612 } else if (OCTEON_IS_MODEL(OCTEON_CN50XX)) {
613 tag.s.V = tmp_tag.cn50xx.V;
614 tag.s.D = tmp_tag.cn50xx.D;
615 tag.s.L = tmp_tag.cn50xx.L;
616 tag.s.U = tmp_tag.cn50xx.U;
617 tag.s.addr = tmp_tag.cn50xx.addr;
618 } else { 670 } else {
619 cvmx_dprintf("Unsupported OCTEON Model in %s\n", __func__); 671 union __cvmx_l2c_tag tmp_tag;
672 /* __read_l2_tag is intended for internal use only */
673 tmp_tag = __read_l2_tag(association, index);
674
675 /*
676 * Convert all tag structure types to generic version,
677 * as it can represent all models.
678 */
679 if (OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX)) {
680 tag.s.V = tmp_tag.cn58xx.V;
681 tag.s.D = tmp_tag.cn58xx.D;
682 tag.s.L = tmp_tag.cn58xx.L;
683 tag.s.U = tmp_tag.cn58xx.U;
684 tag.s.addr = tmp_tag.cn58xx.addr;
685 } else if (OCTEON_IS_MODEL(OCTEON_CN38XX)) {
686 tag.s.V = tmp_tag.cn38xx.V;
687 tag.s.D = tmp_tag.cn38xx.D;
688 tag.s.L = tmp_tag.cn38xx.L;
689 tag.s.U = tmp_tag.cn38xx.U;
690 tag.s.addr = tmp_tag.cn38xx.addr;
691 } else if (OCTEON_IS_MODEL(OCTEON_CN31XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) {
692 tag.s.V = tmp_tag.cn31xx.V;
693 tag.s.D = tmp_tag.cn31xx.D;
694 tag.s.L = tmp_tag.cn31xx.L;
695 tag.s.U = tmp_tag.cn31xx.U;
696 tag.s.addr = tmp_tag.cn31xx.addr;
697 } else if (OCTEON_IS_MODEL(OCTEON_CN30XX)) {
698 tag.s.V = tmp_tag.cn30xx.V;
699 tag.s.D = tmp_tag.cn30xx.D;
700 tag.s.L = tmp_tag.cn30xx.L;
701 tag.s.U = tmp_tag.cn30xx.U;
702 tag.s.addr = tmp_tag.cn30xx.addr;
703 } else if (OCTEON_IS_MODEL(OCTEON_CN50XX)) {
704 tag.s.V = tmp_tag.cn50xx.V;
705 tag.s.D = tmp_tag.cn50xx.D;
706 tag.s.L = tmp_tag.cn50xx.L;
707 tag.s.U = tmp_tag.cn50xx.U;
708 tag.s.addr = tmp_tag.cn50xx.addr;
709 } else {
710 cvmx_dprintf("Unsupported OCTEON Model in %s\n", __func__);
711 }
620 } 712 }
621
622 return tag; 713 return tag;
623} 714}
624 715
625uint32_t cvmx_l2c_address_to_index(uint64_t addr) 716uint32_t cvmx_l2c_address_to_index(uint64_t addr)
626{ 717{
627 uint64_t idx = addr >> CVMX_L2C_IDX_ADDR_SHIFT; 718 uint64_t idx = addr >> CVMX_L2C_IDX_ADDR_SHIFT;
628 union cvmx_l2c_cfg l2c_cfg; 719 int indxalias = 0;
629 l2c_cfg.u64 = cvmx_read_csr(CVMX_L2C_CFG);
630 720
631 if (l2c_cfg.s.idxalias) { 721 if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
632 idx ^= 722 union cvmx_l2c_ctl l2c_ctl;
633 ((addr & CVMX_L2C_ALIAS_MASK) >> 723 l2c_ctl.u64 = cvmx_read_csr(CVMX_L2C_CTL);
634 CVMX_L2C_TAG_ADDR_ALIAS_SHIFT); 724 indxalias = !l2c_ctl.s.disidxalias;
725 } else {
726 union cvmx_l2c_cfg l2c_cfg;
727 l2c_cfg.u64 = cvmx_read_csr(CVMX_L2C_CFG);
728 indxalias = l2c_cfg.s.idxalias;
729 }
730
731 if (indxalias) {
732 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
733 uint32_t a_14_12 = (idx / (CVMX_L2C_MEMBANK_SELECT_SIZE/(1<<CVMX_L2C_IDX_ADDR_SHIFT))) & 0x7;
734 idx ^= idx / cvmx_l2c_get_num_sets();
735 idx ^= a_14_12;
736 } else {
737 idx ^= ((addr & CVMX_L2C_ALIAS_MASK) >> CVMX_L2C_TAG_ADDR_ALIAS_SHIFT);
738 }
635 } 739 }
636 idx &= CVMX_L2C_IDX_MASK; 740 idx &= CVMX_L2C_IDX_MASK;
637 return idx; 741 return idx;
@@ -652,10 +756,9 @@ int cvmx_l2c_get_set_bits(void)
652 int l2_set_bits; 756 int l2_set_bits;
653 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN58XX)) 757 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN58XX))
654 l2_set_bits = 11; /* 2048 sets */ 758 l2_set_bits = 11; /* 2048 sets */
655 else if (OCTEON_IS_MODEL(OCTEON_CN38XX)) 759 else if (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN63XX))
656 l2_set_bits = 10; /* 1024 sets */ 760 l2_set_bits = 10; /* 1024 sets */
657 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) 761 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
658 || OCTEON_IS_MODEL(OCTEON_CN52XX))
659 l2_set_bits = 9; /* 512 sets */ 762 l2_set_bits = 9; /* 512 sets */
660 else if (OCTEON_IS_MODEL(OCTEON_CN30XX)) 763 else if (OCTEON_IS_MODEL(OCTEON_CN30XX))
661 l2_set_bits = 8; /* 256 sets */ 764 l2_set_bits = 8; /* 256 sets */
@@ -666,7 +769,6 @@ int cvmx_l2c_get_set_bits(void)
666 l2_set_bits = 11; /* 2048 sets */ 769 l2_set_bits = 11; /* 2048 sets */
667 } 770 }
668 return l2_set_bits; 771 return l2_set_bits;
669
670} 772}
671 773
672/* Return the number of sets in the L2 Cache */ 774/* Return the number of sets in the L2 Cache */
@@ -682,8 +784,11 @@ int cvmx_l2c_get_num_assoc(void)
682 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || 784 if (OCTEON_IS_MODEL(OCTEON_CN56XX) ||
683 OCTEON_IS_MODEL(OCTEON_CN52XX) || 785 OCTEON_IS_MODEL(OCTEON_CN52XX) ||
684 OCTEON_IS_MODEL(OCTEON_CN58XX) || 786 OCTEON_IS_MODEL(OCTEON_CN58XX) ||
685 OCTEON_IS_MODEL(OCTEON_CN50XX) || OCTEON_IS_MODEL(OCTEON_CN38XX)) 787 OCTEON_IS_MODEL(OCTEON_CN50XX) ||
788 OCTEON_IS_MODEL(OCTEON_CN38XX))
686 l2_assoc = 8; 789 l2_assoc = 8;
790 else if (OCTEON_IS_MODEL(OCTEON_CN63XX))
791 l2_assoc = 16;
687 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) || 792 else if (OCTEON_IS_MODEL(OCTEON_CN31XX) ||
688 OCTEON_IS_MODEL(OCTEON_CN30XX)) 793 OCTEON_IS_MODEL(OCTEON_CN30XX))
689 l2_assoc = 4; 794 l2_assoc = 4;
@@ -693,11 +798,42 @@ int cvmx_l2c_get_num_assoc(void)
693 } 798 }
694 799
695 /* Check to see if part of the cache is disabled */ 800 /* Check to see if part of the cache is disabled */
696 if (cvmx_fuse_read(265)) 801 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
697 l2_assoc = l2_assoc >> 2; 802 union cvmx_mio_fus_dat3 mio_fus_dat3;
698 else if (cvmx_fuse_read(264)) 803
699 l2_assoc = l2_assoc >> 1; 804 mio_fus_dat3.u64 = cvmx_read_csr(CVMX_MIO_FUS_DAT3);
700 805 /*
806 * cvmx_mio_fus_dat3.s.l2c_crip fuses map as follows
807 * <2> will be not used for 63xx
808 * <1> disables 1/2 ways
809 * <0> disables 1/4 ways
810 * They are cumulative, so for 63xx:
811 * <1> <0>
812 * 0 0 16-way 2MB cache
813 * 0 1 12-way 1.5MB cache
814 * 1 0 8-way 1MB cache
815 * 1 1 4-way 512KB cache
816 */
817
818 if (mio_fus_dat3.s.l2c_crip == 3)
819 l2_assoc = 4;
820 else if (mio_fus_dat3.s.l2c_crip == 2)
821 l2_assoc = 8;
822 else if (mio_fus_dat3.s.l2c_crip == 1)
823 l2_assoc = 12;
824 } else {
825 union cvmx_l2d_fus3 val;
826 val.u64 = cvmx_read_csr(CVMX_L2D_FUS3);
827 /*
828 * Using shifts here, as bit position names are
829 * different for each model but they all mean the
830 * same.
831 */
832 if ((val.u64 >> 35) & 0x1)
833 l2_assoc = l2_assoc >> 2;
834 else if ((val.u64 >> 34) & 0x1)
835 l2_assoc = l2_assoc >> 1;
836 }
701 return l2_assoc; 837 return l2_assoc;
702} 838}
703 839
@@ -711,24 +847,54 @@ int cvmx_l2c_get_num_assoc(void)
711 */ 847 */
712void cvmx_l2c_flush_line(uint32_t assoc, uint32_t index) 848void cvmx_l2c_flush_line(uint32_t assoc, uint32_t index)
713{ 849{
714 union cvmx_l2c_dbg l2cdbg; 850 /* Check the range of the index. */
851 if (index > (uint32_t)cvmx_l2c_get_num_sets()) {
852 cvmx_dprintf("ERROR: cvmx_l2c_flush_line index out of range.\n");
853 return;
854 }
715 855
716 l2cdbg.u64 = 0; 856 /* Check the range of association. */
717 l2cdbg.s.ppnum = cvmx_get_core_num(); 857 if (assoc > (uint32_t)cvmx_l2c_get_num_assoc()) {
718 l2cdbg.s.finv = 1; 858 cvmx_dprintf("ERROR: cvmx_l2c_flush_line association out of range.\n");
859 return;
860 }
719 861
720 l2cdbg.s.set = assoc; 862 if (OCTEON_IS_MODEL(OCTEON_CN63XX)) {
721 /* 863 uint64_t address;
722 * Enter debug mode, and make sure all other writes complete 864 /* Create the address based on index and association.
723 * before we enter debug mode. 865 * Bits<20:17> select the way of the cache block involved in
724 */ 866 * the operation
725 asm volatile ("sync" : : : "memory"); 867 * Bits<16:7> of the effect address select the index
726 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64); 868 */
727 cvmx_read_csr(CVMX_L2C_DBG); 869 address = CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,
728 870 (assoc << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) |
729 CVMX_PREPARE_FOR_STORE(((1ULL << 63) + (index) * 128), 0); 871 (index << CVMX_L2C_IDX_ADDR_SHIFT));
730 /* Exit debug mode */ 872 CVMX_CACHE_WBIL2I(address, 0);
731 asm volatile ("sync" : : : "memory"); 873 } else {
732 cvmx_write_csr(CVMX_L2C_DBG, 0); 874 union cvmx_l2c_dbg l2cdbg;
733 cvmx_read_csr(CVMX_L2C_DBG); 875
876 l2cdbg.u64 = 0;
877 if (!OCTEON_IS_MODEL(OCTEON_CN30XX))
878 l2cdbg.s.ppnum = cvmx_get_core_num();
879 l2cdbg.s.finv = 1;
880
881 l2cdbg.s.set = assoc;
882 cvmx_spinlock_lock(&cvmx_l2c_spinlock);
883 /*
884 * Enter debug mode, and make sure all other writes
885 * complete before we enter debug mode
886 */
887 CVMX_SYNC;
888 cvmx_write_csr(CVMX_L2C_DBG, l2cdbg.u64);
889 cvmx_read_csr(CVMX_L2C_DBG);
890
891 CVMX_PREPARE_FOR_STORE(CVMX_ADD_SEG(CVMX_MIPS_SPACE_XKPHYS,
892 index * CVMX_CACHE_LINE_SIZE),
893 0);
894 /* Exit debug mode */
895 CVMX_SYNC;
896 cvmx_write_csr(CVMX_L2C_DBG, 0);
897 cvmx_read_csr(CVMX_L2C_DBG);
898 cvmx_spinlock_unlock(&cvmx_l2c_spinlock);
899 }
734} 900}
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 62ac30eef5e8..cecaf62aef32 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -3,13 +3,15 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2004-2009 Cavium Networks 6 * Copyright (C) 2004-2010 Cavium Networks
7 * Copyright (C) 2008 Wind River Systems 7 * Copyright (C) 2008 Wind River Systems
8 */ 8 */
9 9
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <linux/i2c.h> 12#include <linux/i2c.h>
13#include <linux/usb.h>
14#include <linux/dma-mapping.h>
13#include <linux/module.h> 15#include <linux/module.h>
14#include <linux/platform_device.h> 16#include <linux/platform_device.h>
15 17
@@ -198,7 +200,7 @@ static int __init octeon_i2c_device_init(void)
198 num_ports = 1; 200 num_ports = 1;
199 201
200 for (port = 0; port < num_ports; port++) { 202 for (port = 0; port < num_ports; port++) {
201 octeon_i2c_data[port].sys_freq = octeon_get_clock_rate(); 203 octeon_i2c_data[port].sys_freq = octeon_get_io_clock_rate();
202 /*FIXME: should be examined. At the moment is set for 100Khz */ 204 /*FIXME: should be examined. At the moment is set for 100Khz */
203 octeon_i2c_data[port].i2c_freq = 100000; 205 octeon_i2c_data[port].i2c_freq = 100000;
204 206
@@ -301,6 +303,10 @@ static int __init octeon_mgmt_device_init(void)
301 ret = -ENOMEM; 303 ret = -ENOMEM;
302 goto out; 304 goto out;
303 } 305 }
306 /* No DMA restrictions */
307 pd->dev.coherent_dma_mask = DMA_BIT_MASK(64);
308 pd->dev.dma_mask = &pd->dev.coherent_dma_mask;
309
304 switch (port) { 310 switch (port) {
305 case 0: 311 case 0:
306 mgmt_port_resource.start = OCTEON_IRQ_MII0; 312 mgmt_port_resource.start = OCTEON_IRQ_MII0;
@@ -332,6 +338,108 @@ out:
332} 338}
333device_initcall(octeon_mgmt_device_init); 339device_initcall(octeon_mgmt_device_init);
334 340
341#ifdef CONFIG_USB
342
343static int __init octeon_ehci_device_init(void)
344{
345 struct platform_device *pd;
346 int ret = 0;
347
348 struct resource usb_resources[] = {
349 {
350 .flags = IORESOURCE_MEM,
351 }, {
352 .flags = IORESOURCE_IRQ,
353 }
354 };
355
356 /* Only Octeon2 has ehci/ohci */
357 if (!OCTEON_IS_MODEL(OCTEON_CN63XX))
358 return 0;
359
360 if (octeon_is_simulation() || usb_disabled())
361 return 0; /* No USB in the simulator. */
362
363 pd = platform_device_alloc("octeon-ehci", 0);
364 if (!pd) {
365 ret = -ENOMEM;
366 goto out;
367 }
368
369 usb_resources[0].start = 0x00016F0000000000ULL;
370 usb_resources[0].end = usb_resources[0].start + 0x100;
371
372 usb_resources[1].start = OCTEON_IRQ_USB0;
373 usb_resources[1].end = OCTEON_IRQ_USB0;
374
375 ret = platform_device_add_resources(pd, usb_resources,
376 ARRAY_SIZE(usb_resources));
377 if (ret)
378 goto fail;
379
380 ret = platform_device_add(pd);
381 if (ret)
382 goto fail;
383
384 return ret;
385fail:
386 platform_device_put(pd);
387out:
388 return ret;
389}
390device_initcall(octeon_ehci_device_init);
391
392static int __init octeon_ohci_device_init(void)
393{
394 struct platform_device *pd;
395 int ret = 0;
396
397 struct resource usb_resources[] = {
398 {
399 .flags = IORESOURCE_MEM,
400 }, {
401 .flags = IORESOURCE_IRQ,
402 }
403 };
404
405 /* Only Octeon2 has ehci/ohci */
406 if (!OCTEON_IS_MODEL(OCTEON_CN63XX))
407 return 0;
408
409 if (octeon_is_simulation() || usb_disabled())
410 return 0; /* No USB in the simulator. */
411
412 pd = platform_device_alloc("octeon-ohci", 0);
413 if (!pd) {
414 ret = -ENOMEM;
415 goto out;
416 }
417
418 usb_resources[0].start = 0x00016F0000000400ULL;
419 usb_resources[0].end = usb_resources[0].start + 0x100;
420
421 usb_resources[1].start = OCTEON_IRQ_USB0;
422 usb_resources[1].end = OCTEON_IRQ_USB0;
423
424 ret = platform_device_add_resources(pd, usb_resources,
425 ARRAY_SIZE(usb_resources));
426 if (ret)
427 goto fail;
428
429 ret = platform_device_add(pd);
430 if (ret)
431 goto fail;
432
433 return ret;
434fail:
435 platform_device_put(pd);
436out:
437 return ret;
438}
439device_initcall(octeon_ohci_device_init);
440
441#endif /* CONFIG_USB */
442
335MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>"); 443MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
336MODULE_LICENSE("GPL"); 444MODULE_LICENSE("GPL");
337MODULE_DESCRIPTION("Platform driver for Octeon SOC"); 445MODULE_DESCRIPTION("Platform driver for Octeon SOC");
diff --git a/arch/mips/cavium-octeon/serial.c b/arch/mips/cavium-octeon/serial.c
index 12dbf533b77d..057f0ae88c99 100644
--- a/arch/mips/cavium-octeon/serial.c
+++ b/arch/mips/cavium-octeon/serial.c
@@ -66,7 +66,7 @@ static void __init octeon_uart_set_common(struct plat_serial8250_port *p)
66 /* Make simulator output fast*/ 66 /* Make simulator output fast*/
67 p->uartclk = 115200 * 16; 67 p->uartclk = 115200 * 16;
68 else 68 else
69 p->uartclk = mips_hpt_frequency; 69 p->uartclk = octeon_get_io_clock_rate();
70 p->serial_in = octeon_serial_in; 70 p->serial_in = octeon_serial_in;
71 p->serial_out = octeon_serial_out; 71 p->serial_out = octeon_serial_out;
72} 72}
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 69197cb6c7ea..b0c3686c96dd 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -33,6 +33,7 @@
33 33
34#include <asm/octeon/octeon.h> 34#include <asm/octeon/octeon.h>
35#include <asm/octeon/pci-octeon.h> 35#include <asm/octeon/pci-octeon.h>
36#include <asm/octeon/cvmx-mio-defs.h>
36 37
37#ifdef CONFIG_CAVIUM_DECODE_RSL 38#ifdef CONFIG_CAVIUM_DECODE_RSL
38extern void cvmx_interrupt_rsl_decode(void); 39extern void cvmx_interrupt_rsl_decode(void);
@@ -96,12 +97,21 @@ int octeon_is_pci_host(void)
96 */ 97 */
97uint64_t octeon_get_clock_rate(void) 98uint64_t octeon_get_clock_rate(void)
98{ 99{
99 if (octeon_is_simulation()) 100 struct cvmx_sysinfo *sysinfo = cvmx_sysinfo_get();
100 octeon_bootinfo->eclock_hz = 6000000; 101
101 return octeon_bootinfo->eclock_hz; 102 return sysinfo->cpu_clock_hz;
102} 103}
103EXPORT_SYMBOL(octeon_get_clock_rate); 104EXPORT_SYMBOL(octeon_get_clock_rate);
104 105
106static u64 octeon_io_clock_rate;
107
108u64 octeon_get_io_clock_rate(void)
109{
110 return octeon_io_clock_rate;
111}
112EXPORT_SYMBOL(octeon_get_io_clock_rate);
113
114
105/** 115/**
106 * Write to the LCD display connected to the bootbus. This display 116 * Write to the LCD display connected to the bootbus. This display
107 * exists on most Cavium evaluation boards. If it doesn't exist, then 117 * exists on most Cavium evaluation boards. If it doesn't exist, then
@@ -346,8 +356,18 @@ void octeon_user_io_init(void)
346 cvmmemctl.s.wbfltime = 0; 356 cvmmemctl.s.wbfltime = 0;
347 /* R/W If set, do not put Istream in the L2 cache. */ 357 /* R/W If set, do not put Istream in the L2 cache. */
348 cvmmemctl.s.istrnol2 = 0; 358 cvmmemctl.s.istrnol2 = 0;
349 /* R/W The write buffer threshold. */ 359
350 cvmmemctl.s.wbthresh = 10; 360 /*
361 * R/W The write buffer threshold. As per erratum Core-14752
362 * for CN63XX, a sc/scd might fail if the write buffer is
363 * full. Lowering WBTHRESH greatly lowers the chances of the
364 * write buffer ever being full and triggering the erratum.
365 */
366 if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X))
367 cvmmemctl.s.wbthresh = 4;
368 else
369 cvmmemctl.s.wbthresh = 10;
370
351 /* R/W If set, CVMSEG is available for loads/stores in 371 /* R/W If set, CVMSEG is available for loads/stores in
352 * kernel/debug mode. */ 372 * kernel/debug mode. */
353#if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0 373#if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
@@ -365,14 +385,13 @@ void octeon_user_io_init(void)
365 * is max legal value. */ 385 * is max legal value. */
366 cvmmemctl.s.lmemsz = CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE; 386 cvmmemctl.s.lmemsz = CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE;
367 387
388 write_c0_cvmmemctl(cvmmemctl.u64);
368 389
369 if (smp_processor_id() == 0) 390 if (smp_processor_id() == 0)
370 pr_notice("CVMSEG size: %d cache lines (%d bytes)\n", 391 pr_notice("CVMSEG size: %d cache lines (%d bytes)\n",
371 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE, 392 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE,
372 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE * 128); 393 CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE * 128);
373 394
374 write_c0_cvmmemctl(cvmmemctl.u64);
375
376 /* Move the performance counter interrupts to IRQ 6 */ 395 /* Move the performance counter interrupts to IRQ 6 */
377 cvmctl = read_c0_cvmctl(); 396 cvmctl = read_c0_cvmctl();
378 cvmctl &= ~(7 << 7); 397 cvmctl &= ~(7 << 7);
@@ -416,6 +435,41 @@ void __init prom_init(void)
416 cvmx_phys_to_ptr(octeon_boot_desc_ptr->cvmx_desc_vaddr); 435 cvmx_phys_to_ptr(octeon_boot_desc_ptr->cvmx_desc_vaddr);
417 cvmx_bootmem_init(cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr)); 436 cvmx_bootmem_init(cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr));
418 437
438 sysinfo = cvmx_sysinfo_get();
439 memset(sysinfo, 0, sizeof(*sysinfo));
440 sysinfo->system_dram_size = octeon_bootinfo->dram_size << 20;
441 sysinfo->phy_mem_desc_ptr =
442 cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr);
443 sysinfo->core_mask = octeon_bootinfo->core_mask;
444 sysinfo->exception_base_addr = octeon_bootinfo->exception_base_addr;
445 sysinfo->cpu_clock_hz = octeon_bootinfo->eclock_hz;
446 sysinfo->dram_data_rate_hz = octeon_bootinfo->dclock_hz * 2;
447 sysinfo->board_type = octeon_bootinfo->board_type;
448 sysinfo->board_rev_major = octeon_bootinfo->board_rev_major;
449 sysinfo->board_rev_minor = octeon_bootinfo->board_rev_minor;
450 memcpy(sysinfo->mac_addr_base, octeon_bootinfo->mac_addr_base,
451 sizeof(sysinfo->mac_addr_base));
452 sysinfo->mac_addr_count = octeon_bootinfo->mac_addr_count;
453 memcpy(sysinfo->board_serial_number,
454 octeon_bootinfo->board_serial_number,
455 sizeof(sysinfo->board_serial_number));
456 sysinfo->compact_flash_common_base_addr =
457 octeon_bootinfo->compact_flash_common_base_addr;
458 sysinfo->compact_flash_attribute_base_addr =
459 octeon_bootinfo->compact_flash_attribute_base_addr;
460 sysinfo->led_display_base_addr = octeon_bootinfo->led_display_base_addr;
461 sysinfo->dfa_ref_clock_hz = octeon_bootinfo->dfa_ref_clock_hz;
462 sysinfo->bootloader_config_flags = octeon_bootinfo->config_flags;
463
464 if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
465 /* I/O clock runs at a different rate than the CPU. */
466 union cvmx_mio_rst_boot rst_boot;
467 rst_boot.u64 = cvmx_read_csr(CVMX_MIO_RST_BOOT);
468 octeon_io_clock_rate = 50000000 * rst_boot.s.pnr_mul;
469 } else {
470 octeon_io_clock_rate = sysinfo->cpu_clock_hz;
471 }
472
419 /* 473 /*
420 * Only enable the LED controller if we're running on a CN38XX, CN58XX, 474 * Only enable the LED controller if we're running on a CN38XX, CN58XX,
421 * or CN56XX. The CN30XX and CN31XX don't have an LED controller. 475 * or CN56XX. The CN30XX and CN31XX don't have an LED controller.
@@ -479,33 +533,6 @@ void __init prom_init(void)
479 } 533 }
480#endif 534#endif
481 535
482 sysinfo = cvmx_sysinfo_get();
483 memset(sysinfo, 0, sizeof(*sysinfo));
484 sysinfo->system_dram_size = octeon_bootinfo->dram_size << 20;
485 sysinfo->phy_mem_desc_ptr =
486 cvmx_phys_to_ptr(octeon_bootinfo->phy_mem_desc_addr);
487 sysinfo->core_mask = octeon_bootinfo->core_mask;
488 sysinfo->exception_base_addr = octeon_bootinfo->exception_base_addr;
489 sysinfo->cpu_clock_hz = octeon_bootinfo->eclock_hz;
490 sysinfo->dram_data_rate_hz = octeon_bootinfo->dclock_hz * 2;
491 sysinfo->board_type = octeon_bootinfo->board_type;
492 sysinfo->board_rev_major = octeon_bootinfo->board_rev_major;
493 sysinfo->board_rev_minor = octeon_bootinfo->board_rev_minor;
494 memcpy(sysinfo->mac_addr_base, octeon_bootinfo->mac_addr_base,
495 sizeof(sysinfo->mac_addr_base));
496 sysinfo->mac_addr_count = octeon_bootinfo->mac_addr_count;
497 memcpy(sysinfo->board_serial_number,
498 octeon_bootinfo->board_serial_number,
499 sizeof(sysinfo->board_serial_number));
500 sysinfo->compact_flash_common_base_addr =
501 octeon_bootinfo->compact_flash_common_base_addr;
502 sysinfo->compact_flash_attribute_base_addr =
503 octeon_bootinfo->compact_flash_attribute_base_addr;
504 sysinfo->led_display_base_addr = octeon_bootinfo->led_display_base_addr;
505 sysinfo->dfa_ref_clock_hz = octeon_bootinfo->dfa_ref_clock_hz;
506 sysinfo->bootloader_config_flags = octeon_bootinfo->config_flags;
507
508
509 octeon_check_cpu_bist(); 536 octeon_check_cpu_bist();
510 537
511 octeon_uart = octeon_get_boot_uart(); 538 octeon_uart = octeon_get_boot_uart();
@@ -740,6 +767,31 @@ EXPORT_SYMBOL(prom_putchar);
740 767
741void prom_free_prom_memory(void) 768void prom_free_prom_memory(void)
742{ 769{
770 if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X)) {
771 /* Check for presence of Core-14449 fix. */
772 u32 insn;
773 u32 *foo;
774
775 foo = &insn;
776
777 asm volatile("# before" : : : "memory");
778 prefetch(foo);
779 asm volatile(
780 ".set push\n\t"
781 ".set noreorder\n\t"
782 "bal 1f\n\t"
783 "nop\n"
784 "1:\tlw %0,-12($31)\n\t"
785 ".set pop\n\t"
786 : "=r" (insn) : : "$31", "memory");
787
788 if ((insn >> 26) != 0x33)
789 panic("No PREF instruction at Core-14449 probe point.\n");
790
791 if (((insn >> 16) & 0x1f) != 28)
792 panic("Core-14449 WAR not in place (%04x).\n"
793 "Please build kernel with proper options (CONFIG_CAVIUM_CN63XXP1).\n", insn);
794 }
743#ifdef CONFIG_CAVIUM_DECODE_RSL 795#ifdef CONFIG_CAVIUM_DECODE_RSL
744 cvmx_interrupt_rsl_enable(); 796 cvmx_interrupt_rsl_enable();
745 797
diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
index 47d87da379f9..4a02fe891ab6 100644
--- a/arch/mips/include/asm/atomic.h
+++ b/arch/mips/include/asm/atomic.h
@@ -64,18 +64,16 @@ static __inline__ void atomic_add(int i, atomic_t * v)
64 } else if (kernel_uses_llsc) { 64 } else if (kernel_uses_llsc) {
65 int temp; 65 int temp;
66 66
67 __asm__ __volatile__( 67 do {
68 " .set mips3 \n" 68 __asm__ __volatile__(
69 "1: ll %0, %1 # atomic_add \n" 69 " .set mips3 \n"
70 " addu %0, %2 \n" 70 " ll %0, %1 # atomic_add \n"
71 " sc %0, %1 \n" 71 " addu %0, %2 \n"
72 " beqz %0, 2f \n" 72 " sc %0, %1 \n"
73 " .subsection 2 \n" 73 " .set mips0 \n"
74 "2: b 1b \n" 74 : "=&r" (temp), "=m" (v->counter)
75 " .previous \n" 75 : "Ir" (i), "m" (v->counter));
76 " .set mips0 \n" 76 } while (unlikely(!temp));
77 : "=&r" (temp), "=m" (v->counter)
78 : "Ir" (i), "m" (v->counter));
79 } else { 77 } else {
80 unsigned long flags; 78 unsigned long flags;
81 79
@@ -109,18 +107,16 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
109 } else if (kernel_uses_llsc) { 107 } else if (kernel_uses_llsc) {
110 int temp; 108 int temp;
111 109
112 __asm__ __volatile__( 110 do {
113 " .set mips3 \n" 111 __asm__ __volatile__(
114 "1: ll %0, %1 # atomic_sub \n" 112 " .set mips3 \n"
115 " subu %0, %2 \n" 113 " ll %0, %1 # atomic_sub \n"
116 " sc %0, %1 \n" 114 " subu %0, %2 \n"
117 " beqz %0, 2f \n" 115 " sc %0, %1 \n"
118 " .subsection 2 \n" 116 " .set mips0 \n"
119 "2: b 1b \n" 117 : "=&r" (temp), "=m" (v->counter)
120 " .previous \n" 118 : "Ir" (i), "m" (v->counter));
121 " .set mips0 \n" 119 } while (unlikely(!temp));
122 : "=&r" (temp), "=m" (v->counter)
123 : "Ir" (i), "m" (v->counter));
124 } else { 120 } else {
125 unsigned long flags; 121 unsigned long flags;
126 122
@@ -156,20 +152,19 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
156 } else if (kernel_uses_llsc) { 152 } else if (kernel_uses_llsc) {
157 int temp; 153 int temp;
158 154
159 __asm__ __volatile__( 155 do {
160 " .set mips3 \n" 156 __asm__ __volatile__(
161 "1: ll %1, %2 # atomic_add_return \n" 157 " .set mips3 \n"
162 " addu %0, %1, %3 \n" 158 " ll %1, %2 # atomic_add_return \n"
163 " sc %0, %2 \n" 159 " addu %0, %1, %3 \n"
164 " beqz %0, 2f \n" 160 " sc %0, %2 \n"
165 " addu %0, %1, %3 \n" 161 " .set mips0 \n"
166 " .subsection 2 \n" 162 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
167 "2: b 1b \n" 163 : "Ir" (i), "m" (v->counter)
168 " .previous \n" 164 : "memory");
169 " .set mips0 \n" 165 } while (unlikely(!result));
170 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 166
171 : "Ir" (i), "m" (v->counter) 167 result = temp + i;
172 : "memory");
173 } else { 168 } else {
174 unsigned long flags; 169 unsigned long flags;
175 170
@@ -205,23 +200,24 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
205 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 200 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
206 : "Ir" (i), "m" (v->counter) 201 : "Ir" (i), "m" (v->counter)
207 : "memory"); 202 : "memory");
203
204 result = temp - i;
208 } else if (kernel_uses_llsc) { 205 } else if (kernel_uses_llsc) {
209 int temp; 206 int temp;
210 207
211 __asm__ __volatile__( 208 do {
212 " .set mips3 \n" 209 __asm__ __volatile__(
213 "1: ll %1, %2 # atomic_sub_return \n" 210 " .set mips3 \n"
214 " subu %0, %1, %3 \n" 211 " ll %1, %2 # atomic_sub_return \n"
215 " sc %0, %2 \n" 212 " subu %0, %1, %3 \n"
216 " beqz %0, 2f \n" 213 " sc %0, %2 \n"
217 " subu %0, %1, %3 \n" 214 " .set mips0 \n"
218 " .subsection 2 \n" 215 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
219 "2: b 1b \n" 216 : "Ir" (i), "m" (v->counter)
220 " .previous \n" 217 : "memory");
221 " .set mips0 \n" 218 } while (unlikely(!result));
222 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 219
223 : "Ir" (i), "m" (v->counter) 220 result = temp - i;
224 : "memory");
225 } else { 221 } else {
226 unsigned long flags; 222 unsigned long flags;
227 223
@@ -279,12 +275,9 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
279 " bltz %0, 1f \n" 275 " bltz %0, 1f \n"
280 " sc %0, %2 \n" 276 " sc %0, %2 \n"
281 " .set noreorder \n" 277 " .set noreorder \n"
282 " beqz %0, 2f \n" 278 " beqz %0, 1b \n"
283 " subu %0, %1, %3 \n" 279 " subu %0, %1, %3 \n"
284 " .set reorder \n" 280 " .set reorder \n"
285 " .subsection 2 \n"
286 "2: b 1b \n"
287 " .previous \n"
288 "1: \n" 281 "1: \n"
289 " .set mips0 \n" 282 " .set mips0 \n"
290 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 283 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
@@ -443,18 +436,16 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
443 } else if (kernel_uses_llsc) { 436 } else if (kernel_uses_llsc) {
444 long temp; 437 long temp;
445 438
446 __asm__ __volatile__( 439 do {
447 " .set mips3 \n" 440 __asm__ __volatile__(
448 "1: lld %0, %1 # atomic64_add \n" 441 " .set mips3 \n"
449 " daddu %0, %2 \n" 442 " lld %0, %1 # atomic64_add \n"
450 " scd %0, %1 \n" 443 " daddu %0, %2 \n"
451 " beqz %0, 2f \n" 444 " scd %0, %1 \n"
452 " .subsection 2 \n" 445 " .set mips0 \n"
453 "2: b 1b \n" 446 : "=&r" (temp), "=m" (v->counter)
454 " .previous \n" 447 : "Ir" (i), "m" (v->counter));
455 " .set mips0 \n" 448 } while (unlikely(!temp));
456 : "=&r" (temp), "=m" (v->counter)
457 : "Ir" (i), "m" (v->counter));
458 } else { 449 } else {
459 unsigned long flags; 450 unsigned long flags;
460 451
@@ -488,18 +479,16 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
488 } else if (kernel_uses_llsc) { 479 } else if (kernel_uses_llsc) {
489 long temp; 480 long temp;
490 481
491 __asm__ __volatile__( 482 do {
492 " .set mips3 \n" 483 __asm__ __volatile__(
493 "1: lld %0, %1 # atomic64_sub \n" 484 " .set mips3 \n"
494 " dsubu %0, %2 \n" 485 " lld %0, %1 # atomic64_sub \n"
495 " scd %0, %1 \n" 486 " dsubu %0, %2 \n"
496 " beqz %0, 2f \n" 487 " scd %0, %1 \n"
497 " .subsection 2 \n" 488 " .set mips0 \n"
498 "2: b 1b \n" 489 : "=&r" (temp), "=m" (v->counter)
499 " .previous \n" 490 : "Ir" (i), "m" (v->counter));
500 " .set mips0 \n" 491 } while (unlikely(!temp));
501 : "=&r" (temp), "=m" (v->counter)
502 : "Ir" (i), "m" (v->counter));
503 } else { 492 } else {
504 unsigned long flags; 493 unsigned long flags;
505 494
@@ -535,20 +524,19 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
535 } else if (kernel_uses_llsc) { 524 } else if (kernel_uses_llsc) {
536 long temp; 525 long temp;
537 526
538 __asm__ __volatile__( 527 do {
539 " .set mips3 \n" 528 __asm__ __volatile__(
540 "1: lld %1, %2 # atomic64_add_return \n" 529 " .set mips3 \n"
541 " daddu %0, %1, %3 \n" 530 " lld %1, %2 # atomic64_add_return \n"
542 " scd %0, %2 \n" 531 " daddu %0, %1, %3 \n"
543 " beqz %0, 2f \n" 532 " scd %0, %2 \n"
544 " daddu %0, %1, %3 \n" 533 " .set mips0 \n"
545 " .subsection 2 \n" 534 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
546 "2: b 1b \n" 535 : "Ir" (i), "m" (v->counter)
547 " .previous \n" 536 : "memory");
548 " .set mips0 \n" 537 } while (unlikely(!result));
549 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 538
550 : "Ir" (i), "m" (v->counter) 539 result = temp + i;
551 : "memory");
552 } else { 540 } else {
553 unsigned long flags; 541 unsigned long flags;
554 542
@@ -587,20 +575,19 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
587 } else if (kernel_uses_llsc) { 575 } else if (kernel_uses_llsc) {
588 long temp; 576 long temp;
589 577
590 __asm__ __volatile__( 578 do {
591 " .set mips3 \n" 579 __asm__ __volatile__(
592 "1: lld %1, %2 # atomic64_sub_return \n" 580 " .set mips3 \n"
593 " dsubu %0, %1, %3 \n" 581 " lld %1, %2 # atomic64_sub_return \n"
594 " scd %0, %2 \n" 582 " dsubu %0, %1, %3 \n"
595 " beqz %0, 2f \n" 583 " scd %0, %2 \n"
596 " dsubu %0, %1, %3 \n" 584 " .set mips0 \n"
597 " .subsection 2 \n" 585 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
598 "2: b 1b \n" 586 : "Ir" (i), "m" (v->counter)
599 " .previous \n" 587 : "memory");
600 " .set mips0 \n" 588 } while (unlikely(!result));
601 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 589
602 : "Ir" (i), "m" (v->counter) 590 result = temp - i;
603 : "memory");
604 } else { 591 } else {
605 unsigned long flags; 592 unsigned long flags;
606 593
@@ -658,12 +645,9 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
658 " bltz %0, 1f \n" 645 " bltz %0, 1f \n"
659 " scd %0, %2 \n" 646 " scd %0, %2 \n"
660 " .set noreorder \n" 647 " .set noreorder \n"
661 " beqz %0, 2f \n" 648 " beqz %0, 1b \n"
662 " dsubu %0, %1, %3 \n" 649 " dsubu %0, %1, %3 \n"
663 " .set reorder \n" 650 " .set reorder \n"
664 " .subsection 2 \n"
665 "2: b 1b \n"
666 " .previous \n"
667 "1: \n" 651 "1: \n"
668 " .set mips0 \n" 652 " .set mips0 \n"
669 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 653 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index b0ce7ca2851f..50b4ef288c53 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -73,30 +73,26 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
73 : "ir" (1UL << bit), "m" (*m)); 73 : "ir" (1UL << bit), "m" (*m));
74#ifdef CONFIG_CPU_MIPSR2 74#ifdef CONFIG_CPU_MIPSR2
75 } else if (kernel_uses_llsc && __builtin_constant_p(bit)) { 75 } else if (kernel_uses_llsc && __builtin_constant_p(bit)) {
76 __asm__ __volatile__( 76 do {
77 "1: " __LL "%0, %1 # set_bit \n" 77 __asm__ __volatile__(
78 " " __INS "%0, %4, %2, 1 \n" 78 " " __LL "%0, %1 # set_bit \n"
79 " " __SC "%0, %1 \n" 79 " " __INS "%0, %3, %2, 1 \n"
80 " beqz %0, 2f \n" 80 " " __SC "%0, %1 \n"
81 " .subsection 2 \n" 81 : "=&r" (temp), "+m" (*m)
82 "2: b 1b \n" 82 : "ir" (bit), "r" (~0));
83 " .previous \n" 83 } while (unlikely(!temp));
84 : "=&r" (temp), "=m" (*m)
85 : "ir" (bit), "m" (*m), "r" (~0));
86#endif /* CONFIG_CPU_MIPSR2 */ 84#endif /* CONFIG_CPU_MIPSR2 */
87 } else if (kernel_uses_llsc) { 85 } else if (kernel_uses_llsc) {
88 __asm__ __volatile__( 86 do {
89 " .set mips3 \n" 87 __asm__ __volatile__(
90 "1: " __LL "%0, %1 # set_bit \n" 88 " .set mips3 \n"
91 " or %0, %2 \n" 89 " " __LL "%0, %1 # set_bit \n"
92 " " __SC "%0, %1 \n" 90 " or %0, %2 \n"
93 " beqz %0, 2f \n" 91 " " __SC "%0, %1 \n"
94 " .subsection 2 \n" 92 " .set mips0 \n"
95 "2: b 1b \n" 93 : "=&r" (temp), "+m" (*m)
96 " .previous \n" 94 : "ir" (1UL << bit));
97 " .set mips0 \n" 95 } while (unlikely(!temp));
98 : "=&r" (temp), "=m" (*m)
99 : "ir" (1UL << bit), "m" (*m));
100 } else { 96 } else {
101 volatile unsigned long *a = addr; 97 volatile unsigned long *a = addr;
102 unsigned long mask; 98 unsigned long mask;
@@ -134,34 +130,30 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
134 " " __SC "%0, %1 \n" 130 " " __SC "%0, %1 \n"
135 " beqzl %0, 1b \n" 131 " beqzl %0, 1b \n"
136 " .set mips0 \n" 132 " .set mips0 \n"
137 : "=&r" (temp), "=m" (*m) 133 : "=&r" (temp), "+m" (*m)
138 : "ir" (~(1UL << bit)), "m" (*m)); 134 : "ir" (~(1UL << bit)));
139#ifdef CONFIG_CPU_MIPSR2 135#ifdef CONFIG_CPU_MIPSR2
140 } else if (kernel_uses_llsc && __builtin_constant_p(bit)) { 136 } else if (kernel_uses_llsc && __builtin_constant_p(bit)) {
141 __asm__ __volatile__( 137 do {
142 "1: " __LL "%0, %1 # clear_bit \n" 138 __asm__ __volatile__(
143 " " __INS "%0, $0, %2, 1 \n" 139 " " __LL "%0, %1 # clear_bit \n"
144 " " __SC "%0, %1 \n" 140 " " __INS "%0, $0, %2, 1 \n"
145 " beqz %0, 2f \n" 141 " " __SC "%0, %1 \n"
146 " .subsection 2 \n" 142 : "=&r" (temp), "+m" (*m)
147 "2: b 1b \n" 143 : "ir" (bit));
148 " .previous \n" 144 } while (unlikely(!temp));
149 : "=&r" (temp), "=m" (*m)
150 : "ir" (bit), "m" (*m));
151#endif /* CONFIG_CPU_MIPSR2 */ 145#endif /* CONFIG_CPU_MIPSR2 */
152 } else if (kernel_uses_llsc) { 146 } else if (kernel_uses_llsc) {
153 __asm__ __volatile__( 147 do {
154 " .set mips3 \n" 148 __asm__ __volatile__(
155 "1: " __LL "%0, %1 # clear_bit \n" 149 " .set mips3 \n"
156 " and %0, %2 \n" 150 " " __LL "%0, %1 # clear_bit \n"
157 " " __SC "%0, %1 \n" 151 " and %0, %2 \n"
158 " beqz %0, 2f \n" 152 " " __SC "%0, %1 \n"
159 " .subsection 2 \n" 153 " .set mips0 \n"
160 "2: b 1b \n" 154 : "=&r" (temp), "+m" (*m)
161 " .previous \n" 155 : "ir" (~(1UL << bit)));
162 " .set mips0 \n" 156 } while (unlikely(!temp));
163 : "=&r" (temp), "=m" (*m)
164 : "ir" (~(1UL << bit)), "m" (*m));
165 } else { 157 } else {
166 volatile unsigned long *a = addr; 158 volatile unsigned long *a = addr;
167 unsigned long mask; 159 unsigned long mask;
@@ -213,24 +205,22 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
213 " " __SC "%0, %1 \n" 205 " " __SC "%0, %1 \n"
214 " beqzl %0, 1b \n" 206 " beqzl %0, 1b \n"
215 " .set mips0 \n" 207 " .set mips0 \n"
216 : "=&r" (temp), "=m" (*m) 208 : "=&r" (temp), "+m" (*m)
217 : "ir" (1UL << bit), "m" (*m)); 209 : "ir" (1UL << bit));
218 } else if (kernel_uses_llsc) { 210 } else if (kernel_uses_llsc) {
219 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 211 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
220 unsigned long temp; 212 unsigned long temp;
221 213
222 __asm__ __volatile__( 214 do {
223 " .set mips3 \n" 215 __asm__ __volatile__(
224 "1: " __LL "%0, %1 # change_bit \n" 216 " .set mips3 \n"
225 " xor %0, %2 \n" 217 " " __LL "%0, %1 # change_bit \n"
226 " " __SC "%0, %1 \n" 218 " xor %0, %2 \n"
227 " beqz %0, 2f \n" 219 " " __SC "%0, %1 \n"
228 " .subsection 2 \n" 220 " .set mips0 \n"
229 "2: b 1b \n" 221 : "=&r" (temp), "+m" (*m)
230 " .previous \n" 222 : "ir" (1UL << bit));
231 " .set mips0 \n" 223 } while (unlikely(!temp));
232 : "=&r" (temp), "=m" (*m)
233 : "ir" (1UL << bit), "m" (*m));
234 } else { 224 } else {
235 volatile unsigned long *a = addr; 225 volatile unsigned long *a = addr;
236 unsigned long mask; 226 unsigned long mask;
@@ -272,30 +262,26 @@ static inline int test_and_set_bit(unsigned long nr,
272 " beqzl %2, 1b \n" 262 " beqzl %2, 1b \n"
273 " and %2, %0, %3 \n" 263 " and %2, %0, %3 \n"
274 " .set mips0 \n" 264 " .set mips0 \n"
275 : "=&r" (temp), "=m" (*m), "=&r" (res) 265 : "=&r" (temp), "+m" (*m), "=&r" (res)
276 : "r" (1UL << bit), "m" (*m) 266 : "r" (1UL << bit)
277 : "memory"); 267 : "memory");
278 } else if (kernel_uses_llsc) { 268 } else if (kernel_uses_llsc) {
279 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 269 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
280 unsigned long temp; 270 unsigned long temp;
281 271
282 __asm__ __volatile__( 272 do {
283 " .set push \n" 273 __asm__ __volatile__(
284 " .set noreorder \n" 274 " .set mips3 \n"
285 " .set mips3 \n" 275 " " __LL "%0, %1 # test_and_set_bit \n"
286 "1: " __LL "%0, %1 # test_and_set_bit \n" 276 " or %2, %0, %3 \n"
287 " or %2, %0, %3 \n" 277 " " __SC "%2, %1 \n"
288 " " __SC "%2, %1 \n" 278 " .set mips0 \n"
289 " beqz %2, 2f \n" 279 : "=&r" (temp), "+m" (*m), "=&r" (res)
290 " and %2, %0, %3 \n" 280 : "r" (1UL << bit)
291 " .subsection 2 \n" 281 : "memory");
292 "2: b 1b \n" 282 } while (unlikely(!res));
293 " nop \n" 283
294 " .previous \n" 284 res = temp & (1UL << bit);
295 " .set pop \n"
296 : "=&r" (temp), "=m" (*m), "=&r" (res)
297 : "r" (1UL << bit), "m" (*m)
298 : "memory");
299 } else { 285 } else {
300 volatile unsigned long *a = addr; 286 volatile unsigned long *a = addr;
301 unsigned long mask; 287 unsigned long mask;
@@ -340,30 +326,26 @@ static inline int test_and_set_bit_lock(unsigned long nr,
340 " beqzl %2, 1b \n" 326 " beqzl %2, 1b \n"
341 " and %2, %0, %3 \n" 327 " and %2, %0, %3 \n"
342 " .set mips0 \n" 328 " .set mips0 \n"
343 : "=&r" (temp), "=m" (*m), "=&r" (res) 329 : "=&r" (temp), "+m" (*m), "=&r" (res)
344 : "r" (1UL << bit), "m" (*m) 330 : "r" (1UL << bit)
345 : "memory"); 331 : "memory");
346 } else if (kernel_uses_llsc) { 332 } else if (kernel_uses_llsc) {
347 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 333 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
348 unsigned long temp; 334 unsigned long temp;
349 335
350 __asm__ __volatile__( 336 do {
351 " .set push \n" 337 __asm__ __volatile__(
352 " .set noreorder \n" 338 " .set mips3 \n"
353 " .set mips3 \n" 339 " " __LL "%0, %1 # test_and_set_bit \n"
354 "1: " __LL "%0, %1 # test_and_set_bit \n" 340 " or %2, %0, %3 \n"
355 " or %2, %0, %3 \n" 341 " " __SC "%2, %1 \n"
356 " " __SC "%2, %1 \n" 342 " .set mips0 \n"
357 " beqz %2, 2f \n" 343 : "=&r" (temp), "+m" (*m), "=&r" (res)
358 " and %2, %0, %3 \n" 344 : "r" (1UL << bit)
359 " .subsection 2 \n" 345 : "memory");
360 "2: b 1b \n" 346 } while (unlikely(!res));
361 " nop \n" 347
362 " .previous \n" 348 res = temp & (1UL << bit);
363 " .set pop \n"
364 : "=&r" (temp), "=m" (*m), "=&r" (res)
365 : "r" (1UL << bit), "m" (*m)
366 : "memory");
367 } else { 349 } else {
368 volatile unsigned long *a = addr; 350 volatile unsigned long *a = addr;
369 unsigned long mask; 351 unsigned long mask;
@@ -410,49 +392,43 @@ static inline int test_and_clear_bit(unsigned long nr,
410 " beqzl %2, 1b \n" 392 " beqzl %2, 1b \n"
411 " and %2, %0, %3 \n" 393 " and %2, %0, %3 \n"
412 " .set mips0 \n" 394 " .set mips0 \n"
413 : "=&r" (temp), "=m" (*m), "=&r" (res) 395 : "=&r" (temp), "+m" (*m), "=&r" (res)
414 : "r" (1UL << bit), "m" (*m) 396 : "r" (1UL << bit)
415 : "memory"); 397 : "memory");
416#ifdef CONFIG_CPU_MIPSR2 398#ifdef CONFIG_CPU_MIPSR2
417 } else if (kernel_uses_llsc && __builtin_constant_p(nr)) { 399 } else if (kernel_uses_llsc && __builtin_constant_p(nr)) {
418 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 400 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
419 unsigned long temp; 401 unsigned long temp;
420 402
421 __asm__ __volatile__( 403 do {
422 "1: " __LL "%0, %1 # test_and_clear_bit \n" 404 __asm__ __volatile__(
423 " " __EXT "%2, %0, %3, 1 \n" 405 " " __LL "%0, %1 # test_and_clear_bit \n"
424 " " __INS "%0, $0, %3, 1 \n" 406 " " __EXT "%2, %0, %3, 1 \n"
425 " " __SC "%0, %1 \n" 407 " " __INS "%0, $0, %3, 1 \n"
426 " beqz %0, 2f \n" 408 " " __SC "%0, %1 \n"
427 " .subsection 2 \n" 409 : "=&r" (temp), "+m" (*m), "=&r" (res)
428 "2: b 1b \n" 410 : "ir" (bit)
429 " .previous \n" 411 : "memory");
430 : "=&r" (temp), "=m" (*m), "=&r" (res) 412 } while (unlikely(!temp));
431 : "ir" (bit), "m" (*m)
432 : "memory");
433#endif 413#endif
434 } else if (kernel_uses_llsc) { 414 } else if (kernel_uses_llsc) {
435 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 415 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
436 unsigned long temp; 416 unsigned long temp;
437 417
438 __asm__ __volatile__( 418 do {
439 " .set push \n" 419 __asm__ __volatile__(
440 " .set noreorder \n" 420 " .set mips3 \n"
441 " .set mips3 \n" 421 " " __LL "%0, %1 # test_and_clear_bit \n"
442 "1: " __LL "%0, %1 # test_and_clear_bit \n" 422 " or %2, %0, %3 \n"
443 " or %2, %0, %3 \n" 423 " xor %2, %3 \n"
444 " xor %2, %3 \n" 424 " " __SC "%2, %1 \n"
445 " " __SC "%2, %1 \n" 425 " .set mips0 \n"
446 " beqz %2, 2f \n" 426 : "=&r" (temp), "+m" (*m), "=&r" (res)
447 " and %2, %0, %3 \n" 427 : "r" (1UL << bit)
448 " .subsection 2 \n" 428 : "memory");
449 "2: b 1b \n" 429 } while (unlikely(!res));
450 " nop \n" 430
451 " .previous \n" 431 res = temp & (1UL << bit);
452 " .set pop \n"
453 : "=&r" (temp), "=m" (*m), "=&r" (res)
454 : "r" (1UL << bit), "m" (*m)
455 : "memory");
456 } else { 432 } else {
457 volatile unsigned long *a = addr; 433 volatile unsigned long *a = addr;
458 unsigned long mask; 434 unsigned long mask;
@@ -499,30 +475,26 @@ static inline int test_and_change_bit(unsigned long nr,
499 " beqzl %2, 1b \n" 475 " beqzl %2, 1b \n"
500 " and %2, %0, %3 \n" 476 " and %2, %0, %3 \n"
501 " .set mips0 \n" 477 " .set mips0 \n"
502 : "=&r" (temp), "=m" (*m), "=&r" (res) 478 : "=&r" (temp), "+m" (*m), "=&r" (res)
503 : "r" (1UL << bit), "m" (*m) 479 : "r" (1UL << bit)
504 : "memory"); 480 : "memory");
505 } else if (kernel_uses_llsc) { 481 } else if (kernel_uses_llsc) {
506 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 482 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
507 unsigned long temp; 483 unsigned long temp;
508 484
509 __asm__ __volatile__( 485 do {
510 " .set push \n" 486 __asm__ __volatile__(
511 " .set noreorder \n" 487 " .set mips3 \n"
512 " .set mips3 \n" 488 " " __LL "%0, %1 # test_and_change_bit \n"
513 "1: " __LL "%0, %1 # test_and_change_bit \n" 489 " xor %2, %0, %3 \n"
514 " xor %2, %0, %3 \n" 490 " " __SC "\t%2, %1 \n"
515 " " __SC "\t%2, %1 \n" 491 " .set mips0 \n"
516 " beqz %2, 2f \n" 492 : "=&r" (temp), "+m" (*m), "=&r" (res)
517 " and %2, %0, %3 \n" 493 : "r" (1UL << bit)
518 " .subsection 2 \n" 494 : "memory");
519 "2: b 1b \n" 495 } while (unlikely(!res));
520 " nop \n" 496
521 " .previous \n" 497 res = temp & (1UL << bit);
522 " .set pop \n"
523 : "=&r" (temp), "=m" (*m), "=&r" (res)
524 : "r" (1UL << bit), "m" (*m)
525 : "memory");
526 } else { 498 } else {
527 volatile unsigned long *a = addr; 499 volatile unsigned long *a = addr;
528 unsigned long mask; 500 unsigned long mask;
diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index 15a8ef0707c6..35cd1bab69c3 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -125,4 +125,16 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
125 */ 125 */
126extern void plat_mem_setup(void); 126extern void plat_mem_setup(void);
127 127
128#ifdef CONFIG_SWIOTLB
129/*
130 * Optional platform hook to call swiotlb_setup().
131 */
132extern void plat_swiotlb_setup(void);
133
134#else
135
136static inline void plat_swiotlb_setup(void) {}
137
138#endif /* CONFIG_SWIOTLB */
139
128#endif /* _ASM_BOOTINFO_H */ 140#endif /* _ASM_BOOTINFO_H */
diff --git a/arch/mips/include/asm/cmpxchg.h b/arch/mips/include/asm/cmpxchg.h
index 2d28017e95d0..d8d1c2805ac7 100644
--- a/arch/mips/include/asm/cmpxchg.h
+++ b/arch/mips/include/asm/cmpxchg.h
@@ -44,12 +44,9 @@
44 " move $1, %z4 \n" \ 44 " move $1, %z4 \n" \
45 " .set mips3 \n" \ 45 " .set mips3 \n" \
46 " " st " $1, %1 \n" \ 46 " " st " $1, %1 \n" \
47 " beqz $1, 3f \n" \ 47 " beqz $1, 1b \n" \
48 "2: \n" \
49 " .subsection 2 \n" \
50 "3: b 1b \n" \
51 " .previous \n" \
52 " .set pop \n" \ 48 " .set pop \n" \
49 "2: \n" \
53 : "=&r" (__ret), "=R" (*m) \ 50 : "=&r" (__ret), "=R" (*m) \
54 : "R" (*m), "Jr" (old), "Jr" (new) \ 51 : "R" (*m), "Jr" (old), "Jr" (new) \
55 : "memory"); \ 52 : "memory"); \
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index b201a8f5b127..06d59dcbe243 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -111,14 +111,16 @@
111 * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM 111 * These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
112 */ 112 */
113 113
114#define PRID_IMP_BCM4710 0x4000 114#define PRID_IMP_BMIPS4KC 0x4000
115#define PRID_IMP_BCM3302 0x9000 115#define PRID_IMP_BMIPS32 0x8000
116#define PRID_IMP_BCM6338 0x9000 116#define PRID_IMP_BMIPS3300 0x9000
117#define PRID_IMP_BCM6345 0x8000 117#define PRID_IMP_BMIPS3300_ALT 0x9100
118#define PRID_IMP_BCM6348 0x9100 118#define PRID_IMP_BMIPS3300_BUG 0x0000
119#define PRID_IMP_BCM4350 0xA000 119#define PRID_IMP_BMIPS43XX 0xa000
120#define PRID_REV_BCM6358 0x0010 120#define PRID_IMP_BMIPS5000 0x5a00
121#define PRID_REV_BCM6368 0x0030 121
122#define PRID_REV_BMIPS4380_LO 0x0040
123#define PRID_REV_BMIPS4380_HI 0x006f
122 124
123/* 125/*
124 * These are the PRID's for when 23:16 == PRID_COMP_CAVIUM 126 * These are the PRID's for when 23:16 == PRID_COMP_CAVIUM
@@ -131,6 +133,7 @@
131#define PRID_IMP_CAVIUM_CN56XX 0x0400 133#define PRID_IMP_CAVIUM_CN56XX 0x0400
132#define PRID_IMP_CAVIUM_CN50XX 0x0600 134#define PRID_IMP_CAVIUM_CN50XX 0x0600
133#define PRID_IMP_CAVIUM_CN52XX 0x0700 135#define PRID_IMP_CAVIUM_CN52XX 0x0700
136#define PRID_IMP_CAVIUM_CN63XX 0x9000
134 137
135/* 138/*
136 * These are the PRID's for when 23:16 == PRID_COMP_INGENIC 139 * These are the PRID's for when 23:16 == PRID_COMP_INGENIC
@@ -223,15 +226,14 @@ enum cpu_type_enum {
223 * MIPS32 class processors 226 * MIPS32 class processors
224 */ 227 */
225 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K, 228 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
226 CPU_ALCHEMY, CPU_PR4450, CPU_BCM3302, CPU_BCM4710, 229 CPU_ALCHEMY, CPU_PR4450, CPU_BMIPS32, CPU_BMIPS3300, CPU_BMIPS4350,
227 CPU_BCM6338, CPU_BCM6345, CPU_BCM6348, CPU_BCM6358, 230 CPU_BMIPS4380, CPU_BMIPS5000, CPU_JZRISC,
228 CPU_JZRISC,
229 231
230 /* 232 /*
231 * MIPS64 class processors 233 * MIPS64 class processors
232 */ 234 */
233 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2, 235 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
234 CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, 236 CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, CPU_CAVIUM_OCTEON2,
235 237
236 CPU_LAST 238 CPU_LAST
237}; 239};
diff --git a/arch/mips/include/asm/device.h b/arch/mips/include/asm/device.h
index 06746c5e8099..c94fafba9e62 100644
--- a/arch/mips/include/asm/device.h
+++ b/arch/mips/include/asm/device.h
@@ -3,4 +3,17 @@
3 * 3 *
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6#include <asm-generic/device.h> 6#ifndef _ASM_MIPS_DEVICE_H
7#define _ASM_MIPS_DEVICE_H
8
9struct dma_map_ops;
10
11struct dev_archdata {
12 /* DMA operations on that device */
13 struct dma_map_ops *dma_ops;
14};
15
16struct pdev_archdata {
17};
18
19#endif /* _ASM_MIPS_DEVICE_H*/
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index 18fbf7af8e93..655f849bd08d 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -5,51 +5,41 @@
5#include <asm/cache.h> 5#include <asm/cache.h>
6#include <asm-generic/dma-coherent.h> 6#include <asm-generic/dma-coherent.h>
7 7
8void *dma_alloc_noncoherent(struct device *dev, size_t size, 8#include <dma-coherence.h>
9 dma_addr_t *dma_handle, gfp_t flag);
10 9
11void dma_free_noncoherent(struct device *dev, size_t size, 10extern struct dma_map_ops *mips_dma_map_ops;
12 void *vaddr, dma_addr_t dma_handle);
13 11
14void *dma_alloc_coherent(struct device *dev, size_t size, 12static inline struct dma_map_ops *get_dma_ops(struct device *dev)
15 dma_addr_t *dma_handle, gfp_t flag); 13{
14 if (dev && dev->archdata.dma_ops)
15 return dev->archdata.dma_ops;
16 else
17 return mips_dma_map_ops;
18}
16 19
17void dma_free_coherent(struct device *dev, size_t size, 20static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
18 void *vaddr, dma_addr_t dma_handle); 21{
22 if (!dev->dma_mask)
23 return 0;
19 24
20extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 25 return addr + size <= *dev->dma_mask;
21 enum dma_data_direction direction); 26}
22extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 27
23 size_t size, enum dma_data_direction direction); 28static inline void dma_mark_clean(void *addr, size_t size) {}
24extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 29
25 enum dma_data_direction direction); 30#include <asm-generic/dma-mapping-common.h>
26extern dma_addr_t dma_map_page(struct device *dev, struct page *page, 31
27 unsigned long offset, size_t size, enum dma_data_direction direction); 32static inline int dma_supported(struct device *dev, u64 mask)
28
29static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
30 size_t size, enum dma_data_direction direction)
31{ 33{
32 dma_unmap_single(dev, dma_address, size, direction); 34 struct dma_map_ops *ops = get_dma_ops(dev);
35 return ops->dma_supported(dev, mask);
33} 36}
34 37
35extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 38static inline int dma_mapping_error(struct device *dev, u64 mask)
36 int nhwentries, enum dma_data_direction direction); 39{
37extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, 40 struct dma_map_ops *ops = get_dma_ops(dev);
38 size_t size, enum dma_data_direction direction); 41 return ops->mapping_error(dev, mask);
39extern void dma_sync_single_for_device(struct device *dev, 42}
40 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction);
41extern void dma_sync_single_range_for_cpu(struct device *dev,
42 dma_addr_t dma_handle, unsigned long offset, size_t size,
43 enum dma_data_direction direction);
44extern void dma_sync_single_range_for_device(struct device *dev,
45 dma_addr_t dma_handle, unsigned long offset, size_t size,
46 enum dma_data_direction direction);
47extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
48 int nelems, enum dma_data_direction direction);
49extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
50 int nelems, enum dma_data_direction direction);
51extern int dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
52extern int dma_supported(struct device *dev, u64 mask);
53 43
54static inline int 44static inline int
55dma_set_mask(struct device *dev, u64 mask) 45dma_set_mask(struct device *dev, u64 mask)
@@ -65,4 +55,34 @@ dma_set_mask(struct device *dev, u64 mask)
65extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 55extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
66 enum dma_data_direction direction); 56 enum dma_data_direction direction);
67 57
58static inline void *dma_alloc_coherent(struct device *dev, size_t size,
59 dma_addr_t *dma_handle, gfp_t gfp)
60{
61 void *ret;
62 struct dma_map_ops *ops = get_dma_ops(dev);
63
64 ret = ops->alloc_coherent(dev, size, dma_handle, gfp);
65
66 debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
67
68 return ret;
69}
70
71static inline void dma_free_coherent(struct device *dev, size_t size,
72 void *vaddr, dma_addr_t dma_handle)
73{
74 struct dma_map_ops *ops = get_dma_ops(dev);
75
76 ops->free_coherent(dev, size, vaddr, dma_handle);
77
78 debug_dma_free_coherent(dev, size, vaddr, dma_handle);
79}
80
81
82void *dma_alloc_noncoherent(struct device *dev, size_t size,
83 dma_addr_t *dma_handle, gfp_t flag);
84
85void dma_free_noncoherent(struct device *dev, size_t size,
86 void *vaddr, dma_addr_t dma_handle);
87
68#endif /* _ASM_DMA_MAPPING_H */ 88#endif /* _ASM_DMA_MAPPING_H */
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
index 1353c81065d1..2d47da62d5a7 100644
--- a/arch/mips/include/asm/dma.h
+++ b/arch/mips/include/asm/dma.h
@@ -91,7 +91,10 @@
91#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000) 91#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
92#endif 92#endif
93#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS)) 93#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
94
95#ifndef MAX_DMA32_PFN
94#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT)) 96#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
97#endif
95 98
96/* 8237 DMA controllers */ 99/* 8237 DMA controllers */
97#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ 100#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
diff --git a/arch/mips/include/asm/highmem.h b/arch/mips/include/asm/highmem.h
index 75753ca73bfd..77e644082a3b 100644
--- a/arch/mips/include/asm/highmem.h
+++ b/arch/mips/include/asm/highmem.h
@@ -45,18 +45,12 @@ extern pte_t *pkmap_page_table;
45extern void * kmap_high(struct page *page); 45extern void * kmap_high(struct page *page);
46extern void kunmap_high(struct page *page); 46extern void kunmap_high(struct page *page);
47 47
48extern void *__kmap(struct page *page); 48extern void *kmap(struct page *page);
49extern void __kunmap(struct page *page); 49extern void kunmap(struct page *page);
50extern void *__kmap_atomic(struct page *page, enum km_type type); 50extern void *__kmap_atomic(struct page *page);
51extern void __kunmap_atomic_notypecheck(void *kvaddr, enum km_type type); 51extern void __kunmap_atomic(void *kvaddr);
52extern void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); 52extern void *kmap_atomic_pfn(unsigned long pfn);
53extern struct page *__kmap_atomic_to_page(void *ptr); 53extern struct page *kmap_atomic_to_page(void *ptr);
54
55#define kmap __kmap
56#define kunmap __kunmap
57#define kmap_atomic __kmap_atomic
58#define kunmap_atomic_notypecheck __kunmap_atomic_notypecheck
59#define kmap_atomic_to_page __kmap_atomic_to_page
60 54
61#define flush_cache_kmaps() flush_cache_all() 55#define flush_cache_kmaps() flush_cache_all()
62 56
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/local.h b/arch/mips/include/asm/local.h
index bdcdef02d147..fffc8307a80a 100644
--- a/arch/mips/include/asm/local.h
+++ b/arch/mips/include/asm/local.h
@@ -117,7 +117,7 @@ static __inline__ long local_sub_return(long i, local_t * l)
117 117
118#define local_cmpxchg(l, o, n) \ 118#define local_cmpxchg(l, o, n) \
119 ((long)cmpxchg_local(&((l)->a.counter), (o), (n))) 119 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
120#define local_xchg(l, n) (xchg_local(&((l)->a.counter), (n))) 120#define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
121 121
122/** 122/**
123 * local_add_unless - add unless the number is a given value 123 * local_add_unless - add unless the number is a given value
diff --git a/arch/mips/include/asm/mach-ar7/ar7.h b/arch/mips/include/asm/mach-ar7/ar7.h
index 483ffea9ecb1..7919d76186bf 100644
--- a/arch/mips/include/asm/mach-ar7/ar7.h
+++ b/arch/mips/include/asm/mach-ar7/ar7.h
@@ -39,6 +39,7 @@
39#define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00) 39#define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00)
40#define AR7_REGS_USB (AR7_REGS_BASE + 0x1200) 40#define AR7_REGS_USB (AR7_REGS_BASE + 0x1200)
41#define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600) 41#define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600)
42#define AR7_REGS_PINSEL (AR7_REGS_BASE + 0x160C)
42#define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800) 43#define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800)
43#define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00) 44#define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00)
44#define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00) 45#define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00)
@@ -50,6 +51,14 @@
50#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00) 51#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00)
51#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00) 52#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00)
52 53
54/* Titan registers */
55#define TITAN_REGS_ESWITCH_BASE (0x08640000)
56#define TITAN_REGS_MAC0 (TITAN_REGS_ESWITCH_BASE)
57#define TITAN_REGS_MAC1 (TITAN_REGS_ESWITCH_BASE + 0x0800)
58#define TITAN_REGS_MDIO (TITAN_REGS_ESWITCH_BASE + 0x02000)
59#define TITAN_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1c00)
60#define TITAN_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1300)
61
53#define AR7_RESET_PERIPHERAL 0x0 62#define AR7_RESET_PERIPHERAL 0x0
54#define AR7_RESET_SOFTWARE 0x4 63#define AR7_RESET_SOFTWARE 0x4
55#define AR7_RESET_STATUS 0x8 64#define AR7_RESET_STATUS 0x8
@@ -59,15 +68,30 @@
59#define AR7_RESET_BIT_MDIO 22 68#define AR7_RESET_BIT_MDIO 22
60#define AR7_RESET_BIT_EPHY 26 69#define AR7_RESET_BIT_EPHY 26
61 70
71#define TITAN_RESET_BIT_EPHY1 28
72
62/* GPIO control registers */ 73/* GPIO control registers */
63#define AR7_GPIO_INPUT 0x0 74#define AR7_GPIO_INPUT 0x0
64#define AR7_GPIO_OUTPUT 0x4 75#define AR7_GPIO_OUTPUT 0x4
65#define AR7_GPIO_DIR 0x8 76#define AR7_GPIO_DIR 0x8
66#define AR7_GPIO_ENABLE 0xc 77#define AR7_GPIO_ENABLE 0xc
78#define TITAN_GPIO_INPUT_0 0x0
79#define TITAN_GPIO_INPUT_1 0x4
80#define TITAN_GPIO_OUTPUT_0 0x8
81#define TITAN_GPIO_OUTPUT_1 0xc
82#define TITAN_GPIO_DIR_0 0x10
83#define TITAN_GPIO_DIR_1 0x14
84#define TITAN_GPIO_ENBL_0 0x18
85#define TITAN_GPIO_ENBL_1 0x1c
67 86
68#define AR7_CHIP_7100 0x18 87#define AR7_CHIP_7100 0x18
69#define AR7_CHIP_7200 0x2b 88#define AR7_CHIP_7200 0x2b
70#define AR7_CHIP_7300 0x05 89#define AR7_CHIP_7300 0x05
90#define AR7_CHIP_TITAN 0x07
91#define TITAN_CHIP_1050 0x0f
92#define TITAN_CHIP_1055 0x0e
93#define TITAN_CHIP_1056 0x0d
94#define TITAN_CHIP_1060 0x07
71 95
72/* Interrupts */ 96/* Interrupts */
73#define AR7_IRQ_UART0 15 97#define AR7_IRQ_UART0 15
@@ -95,14 +119,29 @@ struct plat_dsl_data {
95 119
96extern int ar7_cpu_clock, ar7_bus_clock, ar7_dsp_clock; 120extern int ar7_cpu_clock, ar7_bus_clock, ar7_dsp_clock;
97 121
122static inline int ar7_is_titan(void)
123{
124 return (readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x24)) & 0xffff) ==
125 AR7_CHIP_TITAN;
126}
127
98static inline u16 ar7_chip_id(void) 128static inline u16 ar7_chip_id(void)
99{ 129{
100 return readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x14)) & 0xffff; 130 return ar7_is_titan() ? AR7_CHIP_TITAN : (readl((void *)
131 KSEG1ADDR(AR7_REGS_GPIO + 0x14)) & 0xffff);
132}
133
134static inline u16 titan_chip_id(void)
135{
136 unsigned int val = readl((void *)KSEG1ADDR(AR7_REGS_GPIO +
137 TITAN_GPIO_INPUT_1));
138 return ((val >> 12) & 0x0f);
101} 139}
102 140
103static inline u8 ar7_chip_rev(void) 141static inline u8 ar7_chip_rev(void)
104{ 142{
105 return (readl((void *)KSEG1ADDR(AR7_REGS_GPIO + 0x14)) >> 16) & 0xff; 143 return (readl((void *)KSEG1ADDR(AR7_REGS_GPIO + (ar7_is_titan() ? 0x24 :
144 0x14))) >> 16) & 0xff;
106} 145}
107 146
108struct clk { 147struct clk {
@@ -161,4 +200,8 @@ static inline void ar7_device_off(u32 bit)
161 msleep(20); 200 msleep(20);
162} 201}
163 202
203int __init ar7_gpio_init(void);
204
205int __init ar7_gpio_init(void);
206
164#endif /* __AR7_H__ */ 207#endif /* __AR7_H__ */
diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h
index abc317c0372e..c177cd1eed25 100644
--- a/arch/mips/include/asm/mach-ar7/gpio.h
+++ b/arch/mips/include/asm/mach-ar7/gpio.h
@@ -22,7 +22,8 @@
22#include <asm/mach-ar7/ar7.h> 22#include <asm/mach-ar7/ar7.h>
23 23
24#define AR7_GPIO_MAX 32 24#define AR7_GPIO_MAX 32
25#define NR_BUILTIN_GPIO AR7_GPIO_MAX 25#define TITAN_GPIO_MAX 51
26#define NR_BUILTIN_GPIO TITAN_GPIO_MAX
26 27
27#define gpio_to_irq(gpio) -1 28#define gpio_to_irq(gpio) -1
28 29
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h b/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h
new file mode 100644
index 000000000000..5325084d5c48
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm963xx_tag.h
@@ -0,0 +1,97 @@
1#ifndef __BCM963XX_TAG_H
2#define __BCM963XX_TAG_H
3
4#define TAGVER_LEN 4 /* Length of Tag Version */
5#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */
6#define SIG1_LEN 20 /* Company Signature 1 Length */
7#define SIG2_LEN 14 /* Company Signature 2 Lenght */
8#define BOARDID_LEN 16 /* Length of BoardId */
9#define ENDIANFLAG_LEN 2 /* Endian Flag Length */
10#define CHIPID_LEN 6 /* Chip Id Length */
11#define IMAGE_LEN 10 /* Length of Length Field */
12#define ADDRESS_LEN 12 /* Length of Address field */
13#define DUALFLAG_LEN 2 /* Dual Image flag Length */
14#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */
15#define RSASIG_LEN 20 /* Length of RSA Signature in tag */
16#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */
17#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */
18#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */
19#define CRC_LEN 4 /* Length of CRC in bytes */
20#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */
21
22#define NUM_PIRELLI 2
23#define IMAGETAG_CRC_START 0xFFFFFFFF
24
25#define PIRELLI_BOARDS { \
26 "AGPF-S0", \
27 "DWV-S0", \
28}
29
30/*
31 * The broadcom firmware assumes the rootfs starts the image,
32 * therefore uses the rootfs start (flash_image_address)
33 * to determine where to flash the image. Since we have the kernel first
34 * we have to give it the kernel address, but the crc uses the length
35 * associated with this address (root_length), which is added to the kernel
36 * length (kernel_length) to determine the length of image to flash and thus
37 * needs to be rootfs + deadcode (jffs2 EOF marker)
38*/
39
40struct bcm_tag {
41 /* 0-3: Version of the image tag */
42 char tag_version[TAGVER_LEN];
43 /* 4-23: Company Line 1 */
44 char sig_1[SIG1_LEN];
45 /* 24-37: Company Line 2 */
46 char sig_2[SIG2_LEN];
47 /* 38-43: Chip this image is for */
48 char chip_id[CHIPID_LEN];
49 /* 44-59: Board name */
50 char board_id[BOARDID_LEN];
51 /* 60-61: Map endianness -- 1 BE 0 LE */
52 char big_endian[ENDIANFLAG_LEN];
53 /* 62-71: Total length of image */
54 char total_length[IMAGE_LEN];
55 /* 72-83: Address in memory of CFE */
56 char cfe__address[ADDRESS_LEN];
57 /* 84-93: Size of CFE */
58 char cfe_length[IMAGE_LEN];
59 /* 94-105: Address in memory of image start
60 * (kernel for OpenWRT, rootfs for stock firmware)
61 */
62 char flash_image_start[ADDRESS_LEN];
63 /* 106-115: Size of rootfs */
64 char root_length[IMAGE_LEN];
65 /* 116-127: Address in memory of kernel */
66 char kernel_address[ADDRESS_LEN];
67 /* 128-137: Size of kernel */
68 char kernel_length[IMAGE_LEN];
69 /* 138-139: Unused at the moment */
70 char dual_image[DUALFLAG_LEN];
71 /* 140-141: Unused at the moment */
72 char inactive_flag[INACTIVEFLAG_LEN];
73 /* 142-161: RSA Signature (not used; some vendors may use this) */
74 char rsa_signature[RSASIG_LEN];
75 /* 162-191: Compilation and related information (not used in OpenWrt) */
76 char information1[TAGINFO1_LEN];
77 /* 192-195: Version flash layout */
78 char flash_layout_ver[FLASHLAYOUTVER_LEN];
79 /* 196-199: kernel+rootfs CRC32 */
80 char fskernel_crc[CRC_LEN];
81 /* 200-215: Unused except on Alice Gate where is is information */
82 char information2[TAGINFO2_LEN];
83 /* 216-219: CRC32 of image less imagetag (kernel for Alice Gate) */
84 char image_crc[CRC_LEN];
85 /* 220-223: CRC32 of rootfs partition */
86 char rootfs_crc[CRC_LEN];
87 /* 224-227: CRC32 of kernel partition */
88 char kernel_crc[CRC_LEN];
89 /* 228-235: Unused at present */
90 char reserved1[8];
91 /* 236-239: CRC32 of header excluding tagVersion */
92 char header_crc[CRC_LEN];
93 /* 240-255: Unused at present */
94 char reserved2[16];
95};
96
97#endif /* __BCM63XX_TAG_H */
diff --git a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
index b952fc7215e2..0d5a42b5f47a 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
@@ -59,7 +59,7 @@
59#define cpu_has_veic 0 59#define cpu_has_veic 0
60#define cpu_hwrena_impl_bits 0xc0000000 60#define cpu_hwrena_impl_bits 0xc0000000
61 61
62#define kernel_uses_smartmips_rixi (cpu_data[0].cputype == CPU_CAVIUM_OCTEON_PLUS) 62#define kernel_uses_smartmips_rixi (cpu_data[0].cputype != CPU_CAVIUM_OCTEON)
63 63
64#define ARCH_HAS_IRQ_PER_CPU 1 64#define ARCH_HAS_IRQ_PER_CPU 1
65#define ARCH_HAS_SPINLOCK_PREFETCH 1 65#define ARCH_HAS_SPINLOCK_PREFETCH 1
@@ -81,4 +81,10 @@ static inline int octeon_has_saa(void)
81 return id >= 0x000d0300; 81 return id >= 0x000d0300;
82} 82}
83 83
84/*
85 * The last 256MB are reserved for device to device mappings and the
86 * BAR1 hole.
87 */
88#define MAX_DMA32_PFN (((1ULL << 32) - (1ULL << 28)) >> PAGE_SHIFT)
89
84#endif 90#endif
diff --git a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
index 17d579471ec4..be8fb4240cec 100644
--- a/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
+++ b/arch/mips/include/asm/mach-cavium-octeon/dma-coherence.h
@@ -15,41 +15,40 @@
15 15
16struct device; 16struct device;
17 17
18dma_addr_t octeon_map_dma_mem(struct device *, void *, size_t); 18extern void octeon_pci_dma_init(void);
19void octeon_unmap_dma_mem(struct device *, dma_addr_t);
20 19
21static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, 20static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
22 size_t size) 21 size_t size)
23{ 22{
24 return octeon_map_dma_mem(dev, addr, size); 23 BUG();
25} 24}
26 25
27static inline dma_addr_t plat_map_dma_mem_page(struct device *dev, 26static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
28 struct page *page) 27 struct page *page)
29{ 28{
30 return octeon_map_dma_mem(dev, page_address(page), PAGE_SIZE); 29 BUG();
31} 30}
32 31
33static inline unsigned long plat_dma_addr_to_phys(struct device *dev, 32static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
34 dma_addr_t dma_addr) 33 dma_addr_t dma_addr)
35{ 34{
36 return dma_addr; 35 BUG();
37} 36}
38 37
39static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, 38static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
40 size_t size, enum dma_data_direction direction) 39 size_t size, enum dma_data_direction direction)
41{ 40{
42 octeon_unmap_dma_mem(dev, dma_addr); 41 BUG();
43} 42}
44 43
45static inline int plat_dma_supported(struct device *dev, u64 mask) 44static inline int plat_dma_supported(struct device *dev, u64 mask)
46{ 45{
47 return 1; 46 BUG();
48} 47}
49 48
50static inline void plat_extra_sync_for_device(struct device *dev) 49static inline void plat_extra_sync_for_device(struct device *dev)
51{ 50{
52 mb(); 51 BUG();
53} 52}
54 53
55static inline int plat_device_is_coherent(struct device *dev) 54static inline int plat_device_is_coherent(struct device *dev)
@@ -60,7 +59,14 @@ static inline int plat_device_is_coherent(struct device *dev)
60static inline int plat_dma_mapping_error(struct device *dev, 59static inline int plat_dma_mapping_error(struct device *dev,
61 dma_addr_t dma_addr) 60 dma_addr_t dma_addr)
62{ 61{
63 return dma_addr == -1; 62 BUG();
64} 63}
65 64
65dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr);
66phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr);
67
68struct dma_map_ops;
69extern struct dma_map_ops *octeon_pci_dma_map_ops;
70extern char *octeon_swiotlb;
71
66#endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */ 72#endif /* __ASM_MACH_CAVIUM_OCTEON_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-ip27/dma-coherence.h b/arch/mips/include/asm/mach-ip27/dma-coherence.h
index d3d04018a858..016d0989b141 100644
--- a/arch/mips/include/asm/mach-ip27/dma-coherence.h
+++ b/arch/mips/include/asm/mach-ip27/dma-coherence.h
@@ -26,14 +26,15 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
26 return pa; 26 return pa;
27} 27}
28 28
29static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) 29static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
30 struct page *page)
30{ 31{
31 dma_addr_t pa = dev_to_baddr(dev, page_to_phys(page)); 32 dma_addr_t pa = dev_to_baddr(dev, page_to_phys(page));
32 33
33 return pa; 34 return pa;
34} 35}
35 36
36static unsigned long plat_dma_addr_to_phys(struct device *dev, 37static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
37 dma_addr_t dma_addr) 38 dma_addr_t dma_addr)
38{ 39{
39 return dma_addr & ~(0xffUL << 56); 40 return dma_addr & ~(0xffUL << 56);
diff --git a/arch/mips/include/asm/mach-ip32/dma-coherence.h b/arch/mips/include/asm/mach-ip32/dma-coherence.h
index 37855955b313..c8fb5aacf50a 100644
--- a/arch/mips/include/asm/mach-ip32/dma-coherence.h
+++ b/arch/mips/include/asm/mach-ip32/dma-coherence.h
@@ -37,7 +37,8 @@ static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
37 return pa; 37 return pa;
38} 38}
39 39
40static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) 40static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
41 struct page *page)
41{ 42{
42 dma_addr_t pa; 43 dma_addr_t pa;
43 44
@@ -50,7 +51,7 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
50} 51}
51 52
52/* This is almost certainly wrong but it's what dma-ip32.c used to use */ 53/* This is almost certainly wrong but it's what dma-ip32.c used to use */
53static unsigned long plat_dma_addr_to_phys(struct device *dev, 54static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
54 dma_addr_t dma_addr) 55 dma_addr_t dma_addr)
55{ 56{
56 unsigned long addr = dma_addr & RAM_OFFSET_MASK; 57 unsigned long addr = dma_addr & RAM_OFFSET_MASK;
diff --git a/arch/mips/include/asm/mach-jazz/dma-coherence.h b/arch/mips/include/asm/mach-jazz/dma-coherence.h
index f93aee59454a..302101b54acb 100644
--- a/arch/mips/include/asm/mach-jazz/dma-coherence.h
+++ b/arch/mips/include/asm/mach-jazz/dma-coherence.h
@@ -12,23 +12,24 @@
12 12
13struct device; 13struct device;
14 14
15static dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size) 15static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
16{ 16{
17 return vdma_alloc(virt_to_phys(addr), size); 17 return vdma_alloc(virt_to_phys(addr), size);
18} 18}
19 19
20static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page) 20static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
21 struct page *page)
21{ 22{
22 return vdma_alloc(page_to_phys(page), PAGE_SIZE); 23 return vdma_alloc(page_to_phys(page), PAGE_SIZE);
23} 24}
24 25
25static unsigned long plat_dma_addr_to_phys(struct device *dev, 26static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
26 dma_addr_t dma_addr) 27 dma_addr_t dma_addr)
27{ 28{
28 return vdma_log2phys(dma_addr); 29 return vdma_log2phys(dma_addr);
29} 30}
30 31
31static void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr, 32static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
32 size_t size, enum dma_data_direction direction) 33 size_t size, enum dma_data_direction direction)
33{ 34{
34 vdma_free(dma_addr); 35 vdma_free(dma_addr);
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 335474c155f6..4d9870975382 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1040,6 +1040,12 @@ do { \
1040#define read_c0_dtaglo() __read_32bit_c0_register($28, 2) 1040#define read_c0_dtaglo() __read_32bit_c0_register($28, 2)
1041#define write_c0_dtaglo(val) __write_32bit_c0_register($28, 2, val) 1041#define write_c0_dtaglo(val) __write_32bit_c0_register($28, 2, val)
1042 1042
1043#define read_c0_ddatalo() __read_32bit_c0_register($28, 3)
1044#define write_c0_ddatalo(val) __write_32bit_c0_register($28, 3, val)
1045
1046#define read_c0_staglo() __read_32bit_c0_register($28, 4)
1047#define write_c0_staglo(val) __write_32bit_c0_register($28, 4, val)
1048
1043#define read_c0_taghi() __read_32bit_c0_register($29, 0) 1049#define read_c0_taghi() __read_32bit_c0_register($29, 0)
1044#define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val) 1050#define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val)
1045 1051
@@ -1082,6 +1088,51 @@ do { \
1082#define read_octeon_c0_dcacheerr() __read_64bit_c0_register($27, 1) 1088#define read_octeon_c0_dcacheerr() __read_64bit_c0_register($27, 1)
1083#define write_octeon_c0_dcacheerr(val) __write_64bit_c0_register($27, 1, val) 1089#define write_octeon_c0_dcacheerr(val) __write_64bit_c0_register($27, 1, val)
1084 1090
1091/* BMIPS3300 */
1092#define read_c0_brcm_config_0() __read_32bit_c0_register($22, 0)
1093#define write_c0_brcm_config_0(val) __write_32bit_c0_register($22, 0, val)
1094
1095#define read_c0_brcm_bus_pll() __read_32bit_c0_register($22, 4)
1096#define write_c0_brcm_bus_pll(val) __write_32bit_c0_register($22, 4, val)
1097
1098#define read_c0_brcm_reset() __read_32bit_c0_register($22, 5)
1099#define write_c0_brcm_reset(val) __write_32bit_c0_register($22, 5, val)
1100
1101/* BMIPS4380 */
1102#define read_c0_brcm_cmt_intr() __read_32bit_c0_register($22, 1)
1103#define write_c0_brcm_cmt_intr(val) __write_32bit_c0_register($22, 1, val)
1104
1105#define read_c0_brcm_cmt_ctrl() __read_32bit_c0_register($22, 2)
1106#define write_c0_brcm_cmt_ctrl(val) __write_32bit_c0_register($22, 2, val)
1107
1108#define read_c0_brcm_cmt_local() __read_32bit_c0_register($22, 3)
1109#define write_c0_brcm_cmt_local(val) __write_32bit_c0_register($22, 3, val)
1110
1111#define read_c0_brcm_config_1() __read_32bit_c0_register($22, 5)
1112#define write_c0_brcm_config_1(val) __write_32bit_c0_register($22, 5, val)
1113
1114#define read_c0_brcm_cbr() __read_32bit_c0_register($22, 6)
1115#define write_c0_brcm_cbr(val) __write_32bit_c0_register($22, 6, val)
1116
1117/* BMIPS5000 */
1118#define read_c0_brcm_config() __read_32bit_c0_register($22, 0)
1119#define write_c0_brcm_config(val) __write_32bit_c0_register($22, 0, val)
1120
1121#define read_c0_brcm_mode() __read_32bit_c0_register($22, 1)
1122#define write_c0_brcm_mode(val) __write_32bit_c0_register($22, 1, val)
1123
1124#define read_c0_brcm_action() __read_32bit_c0_register($22, 2)
1125#define write_c0_brcm_action(val) __write_32bit_c0_register($22, 2, val)
1126
1127#define read_c0_brcm_edsp() __read_32bit_c0_register($22, 3)
1128#define write_c0_brcm_edsp(val) __write_32bit_c0_register($22, 3, val)
1129
1130#define read_c0_brcm_bootvec() __read_32bit_c0_register($22, 4)
1131#define write_c0_brcm_bootvec(val) __write_32bit_c0_register($22, 4, val)
1132
1133#define read_c0_brcm_sleepcount() __read_32bit_c0_register($22, 7)
1134#define write_c0_brcm_sleepcount(val) __write_32bit_c0_register($22, 7, val)
1135
1085/* 1136/*
1086 * Macros to access the floating point coprocessor control registers 1137 * Macros to access the floating point coprocessor control registers
1087 */ 1138 */
diff --git a/arch/mips/include/asm/octeon/cvmx-agl-defs.h b/arch/mips/include/asm/octeon/cvmx-agl-defs.h
index ec94b9ab7be1..30d68f2365e0 100644
--- a/arch/mips/include/asm/octeon/cvmx-agl-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-agl-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,148 +28,80 @@
28#ifndef __CVMX_AGL_DEFS_H__ 28#ifndef __CVMX_AGL_DEFS_H__
29#define __CVMX_AGL_DEFS_H__ 29#define __CVMX_AGL_DEFS_H__
30 30
31#define CVMX_AGL_GMX_BAD_REG \ 31#define CVMX_AGL_GMX_BAD_REG (CVMX_ADD_IO_SEG(0x00011800E0000518ull))
32 CVMX_ADD_IO_SEG(0x00011800E0000518ull) 32#define CVMX_AGL_GMX_BIST (CVMX_ADD_IO_SEG(0x00011800E0000400ull))
33#define CVMX_AGL_GMX_BIST \ 33#define CVMX_AGL_GMX_DRV_CTL (CVMX_ADD_IO_SEG(0x00011800E00007F0ull))
34 CVMX_ADD_IO_SEG(0x00011800E0000400ull) 34#define CVMX_AGL_GMX_INF_MODE (CVMX_ADD_IO_SEG(0x00011800E00007F8ull))
35#define CVMX_AGL_GMX_DRV_CTL \ 35#define CVMX_AGL_GMX_PRTX_CFG(offset) (CVMX_ADD_IO_SEG(0x00011800E0000010ull) + ((offset) & 1) * 2048)
36 CVMX_ADD_IO_SEG(0x00011800E00007F0ull) 36#define CVMX_AGL_GMX_RXX_ADR_CAM0(offset) (CVMX_ADD_IO_SEG(0x00011800E0000180ull) + ((offset) & 1) * 2048)
37#define CVMX_AGL_GMX_INF_MODE \ 37#define CVMX_AGL_GMX_RXX_ADR_CAM1(offset) (CVMX_ADD_IO_SEG(0x00011800E0000188ull) + ((offset) & 1) * 2048)
38 CVMX_ADD_IO_SEG(0x00011800E00007F8ull) 38#define CVMX_AGL_GMX_RXX_ADR_CAM2(offset) (CVMX_ADD_IO_SEG(0x00011800E0000190ull) + ((offset) & 1) * 2048)
39#define CVMX_AGL_GMX_PRTX_CFG(offset) \ 39#define CVMX_AGL_GMX_RXX_ADR_CAM3(offset) (CVMX_ADD_IO_SEG(0x00011800E0000198ull) + ((offset) & 1) * 2048)
40 CVMX_ADD_IO_SEG(0x00011800E0000010ull + (((offset) & 1) * 2048)) 40#define CVMX_AGL_GMX_RXX_ADR_CAM4(offset) (CVMX_ADD_IO_SEG(0x00011800E00001A0ull) + ((offset) & 1) * 2048)
41#define CVMX_AGL_GMX_RXX_ADR_CAM0(offset) \ 41#define CVMX_AGL_GMX_RXX_ADR_CAM5(offset) (CVMX_ADD_IO_SEG(0x00011800E00001A8ull) + ((offset) & 1) * 2048)
42 CVMX_ADD_IO_SEG(0x00011800E0000180ull + (((offset) & 1) * 2048)) 42#define CVMX_AGL_GMX_RXX_ADR_CAM_EN(offset) (CVMX_ADD_IO_SEG(0x00011800E0000108ull) + ((offset) & 1) * 2048)
43#define CVMX_AGL_GMX_RXX_ADR_CAM1(offset) \ 43#define CVMX_AGL_GMX_RXX_ADR_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000100ull) + ((offset) & 1) * 2048)
44 CVMX_ADD_IO_SEG(0x00011800E0000188ull + (((offset) & 1) * 2048)) 44#define CVMX_AGL_GMX_RXX_DECISION(offset) (CVMX_ADD_IO_SEG(0x00011800E0000040ull) + ((offset) & 1) * 2048)
45#define CVMX_AGL_GMX_RXX_ADR_CAM2(offset) \ 45#define CVMX_AGL_GMX_RXX_FRM_CHK(offset) (CVMX_ADD_IO_SEG(0x00011800E0000020ull) + ((offset) & 1) * 2048)
46 CVMX_ADD_IO_SEG(0x00011800E0000190ull + (((offset) & 1) * 2048)) 46#define CVMX_AGL_GMX_RXX_FRM_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000018ull) + ((offset) & 1) * 2048)
47#define CVMX_AGL_GMX_RXX_ADR_CAM3(offset) \ 47#define CVMX_AGL_GMX_RXX_FRM_MAX(offset) (CVMX_ADD_IO_SEG(0x00011800E0000030ull) + ((offset) & 1) * 2048)
48 CVMX_ADD_IO_SEG(0x00011800E0000198ull + (((offset) & 1) * 2048)) 48#define CVMX_AGL_GMX_RXX_FRM_MIN(offset) (CVMX_ADD_IO_SEG(0x00011800E0000028ull) + ((offset) & 1) * 2048)
49#define CVMX_AGL_GMX_RXX_ADR_CAM4(offset) \ 49#define CVMX_AGL_GMX_RXX_IFG(offset) (CVMX_ADD_IO_SEG(0x00011800E0000058ull) + ((offset) & 1) * 2048)
50 CVMX_ADD_IO_SEG(0x00011800E00001A0ull + (((offset) & 1) * 2048)) 50#define CVMX_AGL_GMX_RXX_INT_EN(offset) (CVMX_ADD_IO_SEG(0x00011800E0000008ull) + ((offset) & 1) * 2048)
51#define CVMX_AGL_GMX_RXX_ADR_CAM5(offset) \ 51#define CVMX_AGL_GMX_RXX_INT_REG(offset) (CVMX_ADD_IO_SEG(0x00011800E0000000ull) + ((offset) & 1) * 2048)
52 CVMX_ADD_IO_SEG(0x00011800E00001A8ull + (((offset) & 1) * 2048)) 52#define CVMX_AGL_GMX_RXX_JABBER(offset) (CVMX_ADD_IO_SEG(0x00011800E0000038ull) + ((offset) & 1) * 2048)
53#define CVMX_AGL_GMX_RXX_ADR_CAM_EN(offset) \ 53#define CVMX_AGL_GMX_RXX_PAUSE_DROP_TIME(offset) (CVMX_ADD_IO_SEG(0x00011800E0000068ull) + ((offset) & 1) * 2048)
54 CVMX_ADD_IO_SEG(0x00011800E0000108ull + (((offset) & 1) * 2048)) 54#define CVMX_AGL_GMX_RXX_RX_INBND(offset) (CVMX_ADD_IO_SEG(0x00011800E0000060ull) + ((offset) & 1) * 2048)
55#define CVMX_AGL_GMX_RXX_ADR_CTL(offset) \ 55#define CVMX_AGL_GMX_RXX_STATS_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000050ull) + ((offset) & 1) * 2048)
56 CVMX_ADD_IO_SEG(0x00011800E0000100ull + (((offset) & 1) * 2048)) 56#define CVMX_AGL_GMX_RXX_STATS_OCTS(offset) (CVMX_ADD_IO_SEG(0x00011800E0000088ull) + ((offset) & 1) * 2048)
57#define CVMX_AGL_GMX_RXX_DECISION(offset) \ 57#define CVMX_AGL_GMX_RXX_STATS_OCTS_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000098ull) + ((offset) & 1) * 2048)
58 CVMX_ADD_IO_SEG(0x00011800E0000040ull + (((offset) & 1) * 2048)) 58#define CVMX_AGL_GMX_RXX_STATS_OCTS_DMAC(offset) (CVMX_ADD_IO_SEG(0x00011800E00000A8ull) + ((offset) & 1) * 2048)
59#define CVMX_AGL_GMX_RXX_FRM_CHK(offset) \ 59#define CVMX_AGL_GMX_RXX_STATS_OCTS_DRP(offset) (CVMX_ADD_IO_SEG(0x00011800E00000B8ull) + ((offset) & 1) * 2048)
60 CVMX_ADD_IO_SEG(0x00011800E0000020ull + (((offset) & 1) * 2048)) 60#define CVMX_AGL_GMX_RXX_STATS_PKTS(offset) (CVMX_ADD_IO_SEG(0x00011800E0000080ull) + ((offset) & 1) * 2048)
61#define CVMX_AGL_GMX_RXX_FRM_CTL(offset) \ 61#define CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(offset) (CVMX_ADD_IO_SEG(0x00011800E00000C0ull) + ((offset) & 1) * 2048)
62 CVMX_ADD_IO_SEG(0x00011800E0000018ull + (((offset) & 1) * 2048)) 62#define CVMX_AGL_GMX_RXX_STATS_PKTS_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000090ull) + ((offset) & 1) * 2048)
63#define CVMX_AGL_GMX_RXX_FRM_MAX(offset) \ 63#define CVMX_AGL_GMX_RXX_STATS_PKTS_DMAC(offset) (CVMX_ADD_IO_SEG(0x00011800E00000A0ull) + ((offset) & 1) * 2048)
64 CVMX_ADD_IO_SEG(0x00011800E0000030ull + (((offset) & 1) * 2048)) 64#define CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(offset) (CVMX_ADD_IO_SEG(0x00011800E00000B0ull) + ((offset) & 1) * 2048)
65#define CVMX_AGL_GMX_RXX_FRM_MIN(offset) \ 65#define CVMX_AGL_GMX_RXX_UDD_SKP(offset) (CVMX_ADD_IO_SEG(0x00011800E0000048ull) + ((offset) & 1) * 2048)
66 CVMX_ADD_IO_SEG(0x00011800E0000028ull + (((offset) & 1) * 2048)) 66#define CVMX_AGL_GMX_RX_BP_DROPX(offset) (CVMX_ADD_IO_SEG(0x00011800E0000420ull) + ((offset) & 1) * 8)
67#define CVMX_AGL_GMX_RXX_IFG(offset) \ 67#define CVMX_AGL_GMX_RX_BP_OFFX(offset) (CVMX_ADD_IO_SEG(0x00011800E0000460ull) + ((offset) & 1) * 8)
68 CVMX_ADD_IO_SEG(0x00011800E0000058ull + (((offset) & 1) * 2048)) 68#define CVMX_AGL_GMX_RX_BP_ONX(offset) (CVMX_ADD_IO_SEG(0x00011800E0000440ull) + ((offset) & 1) * 8)
69#define CVMX_AGL_GMX_RXX_INT_EN(offset) \ 69#define CVMX_AGL_GMX_RX_PRT_INFO (CVMX_ADD_IO_SEG(0x00011800E00004E8ull))
70 CVMX_ADD_IO_SEG(0x00011800E0000008ull + (((offset) & 1) * 2048)) 70#define CVMX_AGL_GMX_RX_TX_STATUS (CVMX_ADD_IO_SEG(0x00011800E00007E8ull))
71#define CVMX_AGL_GMX_RXX_INT_REG(offset) \ 71#define CVMX_AGL_GMX_SMACX(offset) (CVMX_ADD_IO_SEG(0x00011800E0000230ull) + ((offset) & 1) * 2048)
72 CVMX_ADD_IO_SEG(0x00011800E0000000ull + (((offset) & 1) * 2048)) 72#define CVMX_AGL_GMX_STAT_BP (CVMX_ADD_IO_SEG(0x00011800E0000520ull))
73#define CVMX_AGL_GMX_RXX_JABBER(offset) \ 73#define CVMX_AGL_GMX_TXX_APPEND(offset) (CVMX_ADD_IO_SEG(0x00011800E0000218ull) + ((offset) & 1) * 2048)
74 CVMX_ADD_IO_SEG(0x00011800E0000038ull + (((offset) & 1) * 2048)) 74#define CVMX_AGL_GMX_TXX_CLK(offset) (CVMX_ADD_IO_SEG(0x00011800E0000208ull) + ((offset) & 1) * 2048)
75#define CVMX_AGL_GMX_RXX_PAUSE_DROP_TIME(offset) \ 75#define CVMX_AGL_GMX_TXX_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000270ull) + ((offset) & 1) * 2048)
76 CVMX_ADD_IO_SEG(0x00011800E0000068ull + (((offset) & 1) * 2048)) 76#define CVMX_AGL_GMX_TXX_MIN_PKT(offset) (CVMX_ADD_IO_SEG(0x00011800E0000240ull) + ((offset) & 1) * 2048)
77#define CVMX_AGL_GMX_RXX_STATS_CTL(offset) \ 77#define CVMX_AGL_GMX_TXX_PAUSE_PKT_INTERVAL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000248ull) + ((offset) & 1) * 2048)
78 CVMX_ADD_IO_SEG(0x00011800E0000050ull + (((offset) & 1) * 2048)) 78#define CVMX_AGL_GMX_TXX_PAUSE_PKT_TIME(offset) (CVMX_ADD_IO_SEG(0x00011800E0000238ull) + ((offset) & 1) * 2048)
79#define CVMX_AGL_GMX_RXX_STATS_OCTS(offset) \ 79#define CVMX_AGL_GMX_TXX_PAUSE_TOGO(offset) (CVMX_ADD_IO_SEG(0x00011800E0000258ull) + ((offset) & 1) * 2048)
80 CVMX_ADD_IO_SEG(0x00011800E0000088ull + (((offset) & 1) * 2048)) 80#define CVMX_AGL_GMX_TXX_PAUSE_ZERO(offset) (CVMX_ADD_IO_SEG(0x00011800E0000260ull) + ((offset) & 1) * 2048)
81#define CVMX_AGL_GMX_RXX_STATS_OCTS_CTL(offset) \ 81#define CVMX_AGL_GMX_TXX_SOFT_PAUSE(offset) (CVMX_ADD_IO_SEG(0x00011800E0000250ull) + ((offset) & 1) * 2048)
82 CVMX_ADD_IO_SEG(0x00011800E0000098ull + (((offset) & 1) * 2048)) 82#define CVMX_AGL_GMX_TXX_STAT0(offset) (CVMX_ADD_IO_SEG(0x00011800E0000280ull) + ((offset) & 1) * 2048)
83#define CVMX_AGL_GMX_RXX_STATS_OCTS_DMAC(offset) \ 83#define CVMX_AGL_GMX_TXX_STAT1(offset) (CVMX_ADD_IO_SEG(0x00011800E0000288ull) + ((offset) & 1) * 2048)
84 CVMX_ADD_IO_SEG(0x00011800E00000A8ull + (((offset) & 1) * 2048)) 84#define CVMX_AGL_GMX_TXX_STAT2(offset) (CVMX_ADD_IO_SEG(0x00011800E0000290ull) + ((offset) & 1) * 2048)
85#define CVMX_AGL_GMX_RXX_STATS_OCTS_DRP(offset) \ 85#define CVMX_AGL_GMX_TXX_STAT3(offset) (CVMX_ADD_IO_SEG(0x00011800E0000298ull) + ((offset) & 1) * 2048)
86 CVMX_ADD_IO_SEG(0x00011800E00000B8ull + (((offset) & 1) * 2048)) 86#define CVMX_AGL_GMX_TXX_STAT4(offset) (CVMX_ADD_IO_SEG(0x00011800E00002A0ull) + ((offset) & 1) * 2048)
87#define CVMX_AGL_GMX_RXX_STATS_PKTS(offset) \ 87#define CVMX_AGL_GMX_TXX_STAT5(offset) (CVMX_ADD_IO_SEG(0x00011800E00002A8ull) + ((offset) & 1) * 2048)
88 CVMX_ADD_IO_SEG(0x00011800E0000080ull + (((offset) & 1) * 2048)) 88#define CVMX_AGL_GMX_TXX_STAT6(offset) (CVMX_ADD_IO_SEG(0x00011800E00002B0ull) + ((offset) & 1) * 2048)
89#define CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(offset) \ 89#define CVMX_AGL_GMX_TXX_STAT7(offset) (CVMX_ADD_IO_SEG(0x00011800E00002B8ull) + ((offset) & 1) * 2048)
90 CVMX_ADD_IO_SEG(0x00011800E00000C0ull + (((offset) & 1) * 2048)) 90#define CVMX_AGL_GMX_TXX_STAT8(offset) (CVMX_ADD_IO_SEG(0x00011800E00002C0ull) + ((offset) & 1) * 2048)
91#define CVMX_AGL_GMX_RXX_STATS_PKTS_CTL(offset) \ 91#define CVMX_AGL_GMX_TXX_STAT9(offset) (CVMX_ADD_IO_SEG(0x00011800E00002C8ull) + ((offset) & 1) * 2048)
92 CVMX_ADD_IO_SEG(0x00011800E0000090ull + (((offset) & 1) * 2048)) 92#define CVMX_AGL_GMX_TXX_STATS_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0000268ull) + ((offset) & 1) * 2048)
93#define CVMX_AGL_GMX_RXX_STATS_PKTS_DMAC(offset) \ 93#define CVMX_AGL_GMX_TXX_THRESH(offset) (CVMX_ADD_IO_SEG(0x00011800E0000210ull) + ((offset) & 1) * 2048)
94 CVMX_ADD_IO_SEG(0x00011800E00000A0ull + (((offset) & 1) * 2048)) 94#define CVMX_AGL_GMX_TX_BP (CVMX_ADD_IO_SEG(0x00011800E00004D0ull))
95#define CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(offset) \ 95#define CVMX_AGL_GMX_TX_COL_ATTEMPT (CVMX_ADD_IO_SEG(0x00011800E0000498ull))
96 CVMX_ADD_IO_SEG(0x00011800E00000B0ull + (((offset) & 1) * 2048)) 96#define CVMX_AGL_GMX_TX_IFG (CVMX_ADD_IO_SEG(0x00011800E0000488ull))
97#define CVMX_AGL_GMX_RXX_UDD_SKP(offset) \ 97#define CVMX_AGL_GMX_TX_INT_EN (CVMX_ADD_IO_SEG(0x00011800E0000508ull))
98 CVMX_ADD_IO_SEG(0x00011800E0000048ull + (((offset) & 1) * 2048)) 98#define CVMX_AGL_GMX_TX_INT_REG (CVMX_ADD_IO_SEG(0x00011800E0000500ull))
99#define CVMX_AGL_GMX_RX_BP_DROPX(offset) \ 99#define CVMX_AGL_GMX_TX_JAM (CVMX_ADD_IO_SEG(0x00011800E0000490ull))
100 CVMX_ADD_IO_SEG(0x00011800E0000420ull + (((offset) & 1) * 8)) 100#define CVMX_AGL_GMX_TX_LFSR (CVMX_ADD_IO_SEG(0x00011800E00004F8ull))
101#define CVMX_AGL_GMX_RX_BP_OFFX(offset) \ 101#define CVMX_AGL_GMX_TX_OVR_BP (CVMX_ADD_IO_SEG(0x00011800E00004C8ull))
102 CVMX_ADD_IO_SEG(0x00011800E0000460ull + (((offset) & 1) * 8)) 102#define CVMX_AGL_GMX_TX_PAUSE_PKT_DMAC (CVMX_ADD_IO_SEG(0x00011800E00004A0ull))
103#define CVMX_AGL_GMX_RX_BP_ONX(offset) \ 103#define CVMX_AGL_GMX_TX_PAUSE_PKT_TYPE (CVMX_ADD_IO_SEG(0x00011800E00004A8ull))
104 CVMX_ADD_IO_SEG(0x00011800E0000440ull + (((offset) & 1) * 8)) 104#define CVMX_AGL_PRTX_CTL(offset) (CVMX_ADD_IO_SEG(0x00011800E0002000ull) + ((offset) & 1) * 8)
105#define CVMX_AGL_GMX_RX_PRT_INFO \
106 CVMX_ADD_IO_SEG(0x00011800E00004E8ull)
107#define CVMX_AGL_GMX_RX_TX_STATUS \
108 CVMX_ADD_IO_SEG(0x00011800E00007E8ull)
109#define CVMX_AGL_GMX_SMACX(offset) \
110 CVMX_ADD_IO_SEG(0x00011800E0000230ull + (((offset) & 1) * 2048))
111#define CVMX_AGL_GMX_STAT_BP \
112 CVMX_ADD_IO_SEG(0x00011800E0000520ull)
113#define CVMX_AGL_GMX_TXX_APPEND(offset) \
114 CVMX_ADD_IO_SEG(0x00011800E0000218ull + (((offset) & 1) * 2048))
115#define CVMX_AGL_GMX_TXX_CTL(offset) \
116 CVMX_ADD_IO_SEG(0x00011800E0000270ull + (((offset) & 1) * 2048))
117#define CVMX_AGL_GMX_TXX_MIN_PKT(offset) \
118 CVMX_ADD_IO_SEG(0x00011800E0000240ull + (((offset) & 1) * 2048))
119#define CVMX_AGL_GMX_TXX_PAUSE_PKT_INTERVAL(offset) \
120 CVMX_ADD_IO_SEG(0x00011800E0000248ull + (((offset) & 1) * 2048))
121#define CVMX_AGL_GMX_TXX_PAUSE_PKT_TIME(offset) \
122 CVMX_ADD_IO_SEG(0x00011800E0000238ull + (((offset) & 1) * 2048))
123#define CVMX_AGL_GMX_TXX_PAUSE_TOGO(offset) \
124 CVMX_ADD_IO_SEG(0x00011800E0000258ull + (((offset) & 1) * 2048))
125#define CVMX_AGL_GMX_TXX_PAUSE_ZERO(offset) \
126 CVMX_ADD_IO_SEG(0x00011800E0000260ull + (((offset) & 1) * 2048))
127#define CVMX_AGL_GMX_TXX_SOFT_PAUSE(offset) \
128 CVMX_ADD_IO_SEG(0x00011800E0000250ull + (((offset) & 1) * 2048))
129#define CVMX_AGL_GMX_TXX_STAT0(offset) \
130 CVMX_ADD_IO_SEG(0x00011800E0000280ull + (((offset) & 1) * 2048))
131#define CVMX_AGL_GMX_TXX_STAT1(offset) \
132 CVMX_ADD_IO_SEG(0x00011800E0000288ull + (((offset) & 1) * 2048))
133#define CVMX_AGL_GMX_TXX_STAT2(offset) \
134 CVMX_ADD_IO_SEG(0x00011800E0000290ull + (((offset) & 1) * 2048))
135#define CVMX_AGL_GMX_TXX_STAT3(offset) \
136 CVMX_ADD_IO_SEG(0x00011800E0000298ull + (((offset) & 1) * 2048))
137#define CVMX_AGL_GMX_TXX_STAT4(offset) \
138 CVMX_ADD_IO_SEG(0x00011800E00002A0ull + (((offset) & 1) * 2048))
139#define CVMX_AGL_GMX_TXX_STAT5(offset) \
140 CVMX_ADD_IO_SEG(0x00011800E00002A8ull + (((offset) & 1) * 2048))
141#define CVMX_AGL_GMX_TXX_STAT6(offset) \
142 CVMX_ADD_IO_SEG(0x00011800E00002B0ull + (((offset) & 1) * 2048))
143#define CVMX_AGL_GMX_TXX_STAT7(offset) \
144 CVMX_ADD_IO_SEG(0x00011800E00002B8ull + (((offset) & 1) * 2048))
145#define CVMX_AGL_GMX_TXX_STAT8(offset) \
146 CVMX_ADD_IO_SEG(0x00011800E00002C0ull + (((offset) & 1) * 2048))
147#define CVMX_AGL_GMX_TXX_STAT9(offset) \
148 CVMX_ADD_IO_SEG(0x00011800E00002C8ull + (((offset) & 1) * 2048))
149#define CVMX_AGL_GMX_TXX_STATS_CTL(offset) \
150 CVMX_ADD_IO_SEG(0x00011800E0000268ull + (((offset) & 1) * 2048))
151#define CVMX_AGL_GMX_TXX_THRESH(offset) \
152 CVMX_ADD_IO_SEG(0x00011800E0000210ull + (((offset) & 1) * 2048))
153#define CVMX_AGL_GMX_TX_BP \
154 CVMX_ADD_IO_SEG(0x00011800E00004D0ull)
155#define CVMX_AGL_GMX_TX_COL_ATTEMPT \
156 CVMX_ADD_IO_SEG(0x00011800E0000498ull)
157#define CVMX_AGL_GMX_TX_IFG \
158 CVMX_ADD_IO_SEG(0x00011800E0000488ull)
159#define CVMX_AGL_GMX_TX_INT_EN \
160 CVMX_ADD_IO_SEG(0x00011800E0000508ull)
161#define CVMX_AGL_GMX_TX_INT_REG \
162 CVMX_ADD_IO_SEG(0x00011800E0000500ull)
163#define CVMX_AGL_GMX_TX_JAM \
164 CVMX_ADD_IO_SEG(0x00011800E0000490ull)
165#define CVMX_AGL_GMX_TX_LFSR \
166 CVMX_ADD_IO_SEG(0x00011800E00004F8ull)
167#define CVMX_AGL_GMX_TX_OVR_BP \
168 CVMX_ADD_IO_SEG(0x00011800E00004C8ull)
169#define CVMX_AGL_GMX_TX_PAUSE_PKT_DMAC \
170 CVMX_ADD_IO_SEG(0x00011800E00004A0ull)
171#define CVMX_AGL_GMX_TX_PAUSE_PKT_TYPE \
172 CVMX_ADD_IO_SEG(0x00011800E00004A8ull)
173 105
174union cvmx_agl_gmx_bad_reg { 106union cvmx_agl_gmx_bad_reg {
175 uint64_t u64; 107 uint64_t u64;
@@ -183,14 +115,29 @@ union cvmx_agl_gmx_bad_reg {
183 uint64_t ovrflw:1; 115 uint64_t ovrflw:1;
184 uint64_t reserved_27_31:5; 116 uint64_t reserved_27_31:5;
185 uint64_t statovr:1; 117 uint64_t statovr:1;
118 uint64_t reserved_24_25:2;
119 uint64_t loststat:2;
120 uint64_t reserved_4_21:18;
121 uint64_t out_ovr:2;
122 uint64_t reserved_0_1:2;
123 } s;
124 struct cvmx_agl_gmx_bad_reg_cn52xx {
125 uint64_t reserved_38_63:26;
126 uint64_t txpsh1:1;
127 uint64_t txpop1:1;
128 uint64_t ovrflw1:1;
129 uint64_t txpsh:1;
130 uint64_t txpop:1;
131 uint64_t ovrflw:1;
132 uint64_t reserved_27_31:5;
133 uint64_t statovr:1;
186 uint64_t reserved_23_25:3; 134 uint64_t reserved_23_25:3;
187 uint64_t loststat:1; 135 uint64_t loststat:1;
188 uint64_t reserved_4_21:18; 136 uint64_t reserved_4_21:18;
189 uint64_t out_ovr:2; 137 uint64_t out_ovr:2;
190 uint64_t reserved_0_1:2; 138 uint64_t reserved_0_1:2;
191 } s; 139 } cn52xx;
192 struct cvmx_agl_gmx_bad_reg_s cn52xx; 140 struct cvmx_agl_gmx_bad_reg_cn52xx cn52xxp1;
193 struct cvmx_agl_gmx_bad_reg_s cn52xxp1;
194 struct cvmx_agl_gmx_bad_reg_cn56xx { 141 struct cvmx_agl_gmx_bad_reg_cn56xx {
195 uint64_t reserved_35_63:29; 142 uint64_t reserved_35_63:29;
196 uint64_t txpsh:1; 143 uint64_t txpsh:1;
@@ -205,18 +152,25 @@ union cvmx_agl_gmx_bad_reg {
205 uint64_t reserved_0_1:2; 152 uint64_t reserved_0_1:2;
206 } cn56xx; 153 } cn56xx;
207 struct cvmx_agl_gmx_bad_reg_cn56xx cn56xxp1; 154 struct cvmx_agl_gmx_bad_reg_cn56xx cn56xxp1;
155 struct cvmx_agl_gmx_bad_reg_s cn63xx;
156 struct cvmx_agl_gmx_bad_reg_s cn63xxp1;
208}; 157};
209 158
210union cvmx_agl_gmx_bist { 159union cvmx_agl_gmx_bist {
211 uint64_t u64; 160 uint64_t u64;
212 struct cvmx_agl_gmx_bist_s { 161 struct cvmx_agl_gmx_bist_s {
162 uint64_t reserved_25_63:39;
163 uint64_t status:25;
164 } s;
165 struct cvmx_agl_gmx_bist_cn52xx {
213 uint64_t reserved_10_63:54; 166 uint64_t reserved_10_63:54;
214 uint64_t status:10; 167 uint64_t status:10;
215 } s; 168 } cn52xx;
216 struct cvmx_agl_gmx_bist_s cn52xx; 169 struct cvmx_agl_gmx_bist_cn52xx cn52xxp1;
217 struct cvmx_agl_gmx_bist_s cn52xxp1; 170 struct cvmx_agl_gmx_bist_cn52xx cn56xx;
218 struct cvmx_agl_gmx_bist_s cn56xx; 171 struct cvmx_agl_gmx_bist_cn52xx cn56xxp1;
219 struct cvmx_agl_gmx_bist_s cn56xxp1; 172 struct cvmx_agl_gmx_bist_s cn63xx;
173 struct cvmx_agl_gmx_bist_s cn63xxp1;
220}; 174};
221 175
222union cvmx_agl_gmx_drv_ctl { 176union cvmx_agl_gmx_drv_ctl {
@@ -264,7 +218,13 @@ union cvmx_agl_gmx_inf_mode {
264union cvmx_agl_gmx_prtx_cfg { 218union cvmx_agl_gmx_prtx_cfg {
265 uint64_t u64; 219 uint64_t u64;
266 struct cvmx_agl_gmx_prtx_cfg_s { 220 struct cvmx_agl_gmx_prtx_cfg_s {
267 uint64_t reserved_6_63:58; 221 uint64_t reserved_14_63:50;
222 uint64_t tx_idle:1;
223 uint64_t rx_idle:1;
224 uint64_t reserved_9_11:3;
225 uint64_t speed_msb:1;
226 uint64_t reserved_7_7:1;
227 uint64_t burst:1;
268 uint64_t tx_en:1; 228 uint64_t tx_en:1;
269 uint64_t rx_en:1; 229 uint64_t rx_en:1;
270 uint64_t slottime:1; 230 uint64_t slottime:1;
@@ -272,10 +232,20 @@ union cvmx_agl_gmx_prtx_cfg {
272 uint64_t speed:1; 232 uint64_t speed:1;
273 uint64_t en:1; 233 uint64_t en:1;
274 } s; 234 } s;
275 struct cvmx_agl_gmx_prtx_cfg_s cn52xx; 235 struct cvmx_agl_gmx_prtx_cfg_cn52xx {
276 struct cvmx_agl_gmx_prtx_cfg_s cn52xxp1; 236 uint64_t reserved_6_63:58;
277 struct cvmx_agl_gmx_prtx_cfg_s cn56xx; 237 uint64_t tx_en:1;
278 struct cvmx_agl_gmx_prtx_cfg_s cn56xxp1; 238 uint64_t rx_en:1;
239 uint64_t slottime:1;
240 uint64_t duplex:1;
241 uint64_t speed:1;
242 uint64_t en:1;
243 } cn52xx;
244 struct cvmx_agl_gmx_prtx_cfg_cn52xx cn52xxp1;
245 struct cvmx_agl_gmx_prtx_cfg_cn52xx cn56xx;
246 struct cvmx_agl_gmx_prtx_cfg_cn52xx cn56xxp1;
247 struct cvmx_agl_gmx_prtx_cfg_s cn63xx;
248 struct cvmx_agl_gmx_prtx_cfg_s cn63xxp1;
279}; 249};
280 250
281union cvmx_agl_gmx_rxx_adr_cam0 { 251union cvmx_agl_gmx_rxx_adr_cam0 {
@@ -287,6 +257,8 @@ union cvmx_agl_gmx_rxx_adr_cam0 {
287 struct cvmx_agl_gmx_rxx_adr_cam0_s cn52xxp1; 257 struct cvmx_agl_gmx_rxx_adr_cam0_s cn52xxp1;
288 struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xx; 258 struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xx;
289 struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xxp1; 259 struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xxp1;
260 struct cvmx_agl_gmx_rxx_adr_cam0_s cn63xx;
261 struct cvmx_agl_gmx_rxx_adr_cam0_s cn63xxp1;
290}; 262};
291 263
292union cvmx_agl_gmx_rxx_adr_cam1 { 264union cvmx_agl_gmx_rxx_adr_cam1 {
@@ -298,6 +270,8 @@ union cvmx_agl_gmx_rxx_adr_cam1 {
298 struct cvmx_agl_gmx_rxx_adr_cam1_s cn52xxp1; 270 struct cvmx_agl_gmx_rxx_adr_cam1_s cn52xxp1;
299 struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xx; 271 struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xx;
300 struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xxp1; 272 struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xxp1;
273 struct cvmx_agl_gmx_rxx_adr_cam1_s cn63xx;
274 struct cvmx_agl_gmx_rxx_adr_cam1_s cn63xxp1;
301}; 275};
302 276
303union cvmx_agl_gmx_rxx_adr_cam2 { 277union cvmx_agl_gmx_rxx_adr_cam2 {
@@ -309,6 +283,8 @@ union cvmx_agl_gmx_rxx_adr_cam2 {
309 struct cvmx_agl_gmx_rxx_adr_cam2_s cn52xxp1; 283 struct cvmx_agl_gmx_rxx_adr_cam2_s cn52xxp1;
310 struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xx; 284 struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xx;
311 struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xxp1; 285 struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xxp1;
286 struct cvmx_agl_gmx_rxx_adr_cam2_s cn63xx;
287 struct cvmx_agl_gmx_rxx_adr_cam2_s cn63xxp1;
312}; 288};
313 289
314union cvmx_agl_gmx_rxx_adr_cam3 { 290union cvmx_agl_gmx_rxx_adr_cam3 {
@@ -320,6 +296,8 @@ union cvmx_agl_gmx_rxx_adr_cam3 {
320 struct cvmx_agl_gmx_rxx_adr_cam3_s cn52xxp1; 296 struct cvmx_agl_gmx_rxx_adr_cam3_s cn52xxp1;
321 struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xx; 297 struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xx;
322 struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xxp1; 298 struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xxp1;
299 struct cvmx_agl_gmx_rxx_adr_cam3_s cn63xx;
300 struct cvmx_agl_gmx_rxx_adr_cam3_s cn63xxp1;
323}; 301};
324 302
325union cvmx_agl_gmx_rxx_adr_cam4 { 303union cvmx_agl_gmx_rxx_adr_cam4 {
@@ -331,6 +309,8 @@ union cvmx_agl_gmx_rxx_adr_cam4 {
331 struct cvmx_agl_gmx_rxx_adr_cam4_s cn52xxp1; 309 struct cvmx_agl_gmx_rxx_adr_cam4_s cn52xxp1;
332 struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xx; 310 struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xx;
333 struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xxp1; 311 struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xxp1;
312 struct cvmx_agl_gmx_rxx_adr_cam4_s cn63xx;
313 struct cvmx_agl_gmx_rxx_adr_cam4_s cn63xxp1;
334}; 314};
335 315
336union cvmx_agl_gmx_rxx_adr_cam5 { 316union cvmx_agl_gmx_rxx_adr_cam5 {
@@ -342,6 +322,8 @@ union cvmx_agl_gmx_rxx_adr_cam5 {
342 struct cvmx_agl_gmx_rxx_adr_cam5_s cn52xxp1; 322 struct cvmx_agl_gmx_rxx_adr_cam5_s cn52xxp1;
343 struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xx; 323 struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xx;
344 struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xxp1; 324 struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xxp1;
325 struct cvmx_agl_gmx_rxx_adr_cam5_s cn63xx;
326 struct cvmx_agl_gmx_rxx_adr_cam5_s cn63xxp1;
345}; 327};
346 328
347union cvmx_agl_gmx_rxx_adr_cam_en { 329union cvmx_agl_gmx_rxx_adr_cam_en {
@@ -354,6 +336,8 @@ union cvmx_agl_gmx_rxx_adr_cam_en {
354 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn52xxp1; 336 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn52xxp1;
355 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xx; 337 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xx;
356 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xxp1; 338 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xxp1;
339 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn63xx;
340 struct cvmx_agl_gmx_rxx_adr_cam_en_s cn63xxp1;
357}; 341};
358 342
359union cvmx_agl_gmx_rxx_adr_ctl { 343union cvmx_agl_gmx_rxx_adr_ctl {
@@ -368,6 +352,8 @@ union cvmx_agl_gmx_rxx_adr_ctl {
368 struct cvmx_agl_gmx_rxx_adr_ctl_s cn52xxp1; 352 struct cvmx_agl_gmx_rxx_adr_ctl_s cn52xxp1;
369 struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xx; 353 struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xx;
370 struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xxp1; 354 struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xxp1;
355 struct cvmx_agl_gmx_rxx_adr_ctl_s cn63xx;
356 struct cvmx_agl_gmx_rxx_adr_ctl_s cn63xxp1;
371}; 357};
372 358
373union cvmx_agl_gmx_rxx_decision { 359union cvmx_agl_gmx_rxx_decision {
@@ -380,11 +366,26 @@ union cvmx_agl_gmx_rxx_decision {
380 struct cvmx_agl_gmx_rxx_decision_s cn52xxp1; 366 struct cvmx_agl_gmx_rxx_decision_s cn52xxp1;
381 struct cvmx_agl_gmx_rxx_decision_s cn56xx; 367 struct cvmx_agl_gmx_rxx_decision_s cn56xx;
382 struct cvmx_agl_gmx_rxx_decision_s cn56xxp1; 368 struct cvmx_agl_gmx_rxx_decision_s cn56xxp1;
369 struct cvmx_agl_gmx_rxx_decision_s cn63xx;
370 struct cvmx_agl_gmx_rxx_decision_s cn63xxp1;
383}; 371};
384 372
385union cvmx_agl_gmx_rxx_frm_chk { 373union cvmx_agl_gmx_rxx_frm_chk {
386 uint64_t u64; 374 uint64_t u64;
387 struct cvmx_agl_gmx_rxx_frm_chk_s { 375 struct cvmx_agl_gmx_rxx_frm_chk_s {
376 uint64_t reserved_10_63:54;
377 uint64_t niberr:1;
378 uint64_t skperr:1;
379 uint64_t rcverr:1;
380 uint64_t lenerr:1;
381 uint64_t alnerr:1;
382 uint64_t fcserr:1;
383 uint64_t jabber:1;
384 uint64_t maxerr:1;
385 uint64_t carext:1;
386 uint64_t minerr:1;
387 } s;
388 struct cvmx_agl_gmx_rxx_frm_chk_cn52xx {
388 uint64_t reserved_9_63:55; 389 uint64_t reserved_9_63:55;
389 uint64_t skperr:1; 390 uint64_t skperr:1;
390 uint64_t rcverr:1; 391 uint64_t rcverr:1;
@@ -395,17 +396,21 @@ union cvmx_agl_gmx_rxx_frm_chk {
395 uint64_t maxerr:1; 396 uint64_t maxerr:1;
396 uint64_t reserved_1_1:1; 397 uint64_t reserved_1_1:1;
397 uint64_t minerr:1; 398 uint64_t minerr:1;
398 } s; 399 } cn52xx;
399 struct cvmx_agl_gmx_rxx_frm_chk_s cn52xx; 400 struct cvmx_agl_gmx_rxx_frm_chk_cn52xx cn52xxp1;
400 struct cvmx_agl_gmx_rxx_frm_chk_s cn52xxp1; 401 struct cvmx_agl_gmx_rxx_frm_chk_cn52xx cn56xx;
401 struct cvmx_agl_gmx_rxx_frm_chk_s cn56xx; 402 struct cvmx_agl_gmx_rxx_frm_chk_cn52xx cn56xxp1;
402 struct cvmx_agl_gmx_rxx_frm_chk_s cn56xxp1; 403 struct cvmx_agl_gmx_rxx_frm_chk_s cn63xx;
404 struct cvmx_agl_gmx_rxx_frm_chk_s cn63xxp1;
403}; 405};
404 406
405union cvmx_agl_gmx_rxx_frm_ctl { 407union cvmx_agl_gmx_rxx_frm_ctl {
406 uint64_t u64; 408 uint64_t u64;
407 struct cvmx_agl_gmx_rxx_frm_ctl_s { 409 struct cvmx_agl_gmx_rxx_frm_ctl_s {
408 uint64_t reserved_10_63:54; 410 uint64_t reserved_13_63:51;
411 uint64_t ptp_mode:1;
412 uint64_t reserved_11_11:1;
413 uint64_t null_dis:1;
409 uint64_t pre_align:1; 414 uint64_t pre_align:1;
410 uint64_t pad_len:1; 415 uint64_t pad_len:1;
411 uint64_t vlan_len:1; 416 uint64_t vlan_len:1;
@@ -417,10 +422,24 @@ union cvmx_agl_gmx_rxx_frm_ctl {
417 uint64_t pre_strp:1; 422 uint64_t pre_strp:1;
418 uint64_t pre_chk:1; 423 uint64_t pre_chk:1;
419 } s; 424 } s;
420 struct cvmx_agl_gmx_rxx_frm_ctl_s cn52xx; 425 struct cvmx_agl_gmx_rxx_frm_ctl_cn52xx {
421 struct cvmx_agl_gmx_rxx_frm_ctl_s cn52xxp1; 426 uint64_t reserved_10_63:54;
422 struct cvmx_agl_gmx_rxx_frm_ctl_s cn56xx; 427 uint64_t pre_align:1;
423 struct cvmx_agl_gmx_rxx_frm_ctl_s cn56xxp1; 428 uint64_t pad_len:1;
429 uint64_t vlan_len:1;
430 uint64_t pre_free:1;
431 uint64_t ctl_smac:1;
432 uint64_t ctl_mcst:1;
433 uint64_t ctl_bck:1;
434 uint64_t ctl_drp:1;
435 uint64_t pre_strp:1;
436 uint64_t pre_chk:1;
437 } cn52xx;
438 struct cvmx_agl_gmx_rxx_frm_ctl_cn52xx cn52xxp1;
439 struct cvmx_agl_gmx_rxx_frm_ctl_cn52xx cn56xx;
440 struct cvmx_agl_gmx_rxx_frm_ctl_cn52xx cn56xxp1;
441 struct cvmx_agl_gmx_rxx_frm_ctl_s cn63xx;
442 struct cvmx_agl_gmx_rxx_frm_ctl_s cn63xxp1;
424}; 443};
425 444
426union cvmx_agl_gmx_rxx_frm_max { 445union cvmx_agl_gmx_rxx_frm_max {
@@ -433,6 +452,8 @@ union cvmx_agl_gmx_rxx_frm_max {
433 struct cvmx_agl_gmx_rxx_frm_max_s cn52xxp1; 452 struct cvmx_agl_gmx_rxx_frm_max_s cn52xxp1;
434 struct cvmx_agl_gmx_rxx_frm_max_s cn56xx; 453 struct cvmx_agl_gmx_rxx_frm_max_s cn56xx;
435 struct cvmx_agl_gmx_rxx_frm_max_s cn56xxp1; 454 struct cvmx_agl_gmx_rxx_frm_max_s cn56xxp1;
455 struct cvmx_agl_gmx_rxx_frm_max_s cn63xx;
456 struct cvmx_agl_gmx_rxx_frm_max_s cn63xxp1;
436}; 457};
437 458
438union cvmx_agl_gmx_rxx_frm_min { 459union cvmx_agl_gmx_rxx_frm_min {
@@ -445,6 +466,8 @@ union cvmx_agl_gmx_rxx_frm_min {
445 struct cvmx_agl_gmx_rxx_frm_min_s cn52xxp1; 466 struct cvmx_agl_gmx_rxx_frm_min_s cn52xxp1;
446 struct cvmx_agl_gmx_rxx_frm_min_s cn56xx; 467 struct cvmx_agl_gmx_rxx_frm_min_s cn56xx;
447 struct cvmx_agl_gmx_rxx_frm_min_s cn56xxp1; 468 struct cvmx_agl_gmx_rxx_frm_min_s cn56xxp1;
469 struct cvmx_agl_gmx_rxx_frm_min_s cn63xx;
470 struct cvmx_agl_gmx_rxx_frm_min_s cn63xxp1;
448}; 471};
449 472
450union cvmx_agl_gmx_rxx_ifg { 473union cvmx_agl_gmx_rxx_ifg {
@@ -457,6 +480,8 @@ union cvmx_agl_gmx_rxx_ifg {
457 struct cvmx_agl_gmx_rxx_ifg_s cn52xxp1; 480 struct cvmx_agl_gmx_rxx_ifg_s cn52xxp1;
458 struct cvmx_agl_gmx_rxx_ifg_s cn56xx; 481 struct cvmx_agl_gmx_rxx_ifg_s cn56xx;
459 struct cvmx_agl_gmx_rxx_ifg_s cn56xxp1; 482 struct cvmx_agl_gmx_rxx_ifg_s cn56xxp1;
483 struct cvmx_agl_gmx_rxx_ifg_s cn63xx;
484 struct cvmx_agl_gmx_rxx_ifg_s cn63xxp1;
460}; 485};
461 486
462union cvmx_agl_gmx_rxx_int_en { 487union cvmx_agl_gmx_rxx_int_en {
@@ -464,6 +489,29 @@ union cvmx_agl_gmx_rxx_int_en {
464 struct cvmx_agl_gmx_rxx_int_en_s { 489 struct cvmx_agl_gmx_rxx_int_en_s {
465 uint64_t reserved_20_63:44; 490 uint64_t reserved_20_63:44;
466 uint64_t pause_drp:1; 491 uint64_t pause_drp:1;
492 uint64_t phy_dupx:1;
493 uint64_t phy_spd:1;
494 uint64_t phy_link:1;
495 uint64_t ifgerr:1;
496 uint64_t coldet:1;
497 uint64_t falerr:1;
498 uint64_t rsverr:1;
499 uint64_t pcterr:1;
500 uint64_t ovrerr:1;
501 uint64_t niberr:1;
502 uint64_t skperr:1;
503 uint64_t rcverr:1;
504 uint64_t lenerr:1;
505 uint64_t alnerr:1;
506 uint64_t fcserr:1;
507 uint64_t jabber:1;
508 uint64_t maxerr:1;
509 uint64_t carext:1;
510 uint64_t minerr:1;
511 } s;
512 struct cvmx_agl_gmx_rxx_int_en_cn52xx {
513 uint64_t reserved_20_63:44;
514 uint64_t pause_drp:1;
467 uint64_t reserved_16_18:3; 515 uint64_t reserved_16_18:3;
468 uint64_t ifgerr:1; 516 uint64_t ifgerr:1;
469 uint64_t coldet:1; 517 uint64_t coldet:1;
@@ -481,11 +529,12 @@ union cvmx_agl_gmx_rxx_int_en {
481 uint64_t maxerr:1; 529 uint64_t maxerr:1;
482 uint64_t reserved_1_1:1; 530 uint64_t reserved_1_1:1;
483 uint64_t minerr:1; 531 uint64_t minerr:1;
484 } s; 532 } cn52xx;
485 struct cvmx_agl_gmx_rxx_int_en_s cn52xx; 533 struct cvmx_agl_gmx_rxx_int_en_cn52xx cn52xxp1;
486 struct cvmx_agl_gmx_rxx_int_en_s cn52xxp1; 534 struct cvmx_agl_gmx_rxx_int_en_cn52xx cn56xx;
487 struct cvmx_agl_gmx_rxx_int_en_s cn56xx; 535 struct cvmx_agl_gmx_rxx_int_en_cn52xx cn56xxp1;
488 struct cvmx_agl_gmx_rxx_int_en_s cn56xxp1; 536 struct cvmx_agl_gmx_rxx_int_en_s cn63xx;
537 struct cvmx_agl_gmx_rxx_int_en_s cn63xxp1;
489}; 538};
490 539
491union cvmx_agl_gmx_rxx_int_reg { 540union cvmx_agl_gmx_rxx_int_reg {
@@ -493,6 +542,29 @@ union cvmx_agl_gmx_rxx_int_reg {
493 struct cvmx_agl_gmx_rxx_int_reg_s { 542 struct cvmx_agl_gmx_rxx_int_reg_s {
494 uint64_t reserved_20_63:44; 543 uint64_t reserved_20_63:44;
495 uint64_t pause_drp:1; 544 uint64_t pause_drp:1;
545 uint64_t phy_dupx:1;
546 uint64_t phy_spd:1;
547 uint64_t phy_link:1;
548 uint64_t ifgerr:1;
549 uint64_t coldet:1;
550 uint64_t falerr:1;
551 uint64_t rsverr:1;
552 uint64_t pcterr:1;
553 uint64_t ovrerr:1;
554 uint64_t niberr:1;
555 uint64_t skperr:1;
556 uint64_t rcverr:1;
557 uint64_t lenerr:1;
558 uint64_t alnerr:1;
559 uint64_t fcserr:1;
560 uint64_t jabber:1;
561 uint64_t maxerr:1;
562 uint64_t carext:1;
563 uint64_t minerr:1;
564 } s;
565 struct cvmx_agl_gmx_rxx_int_reg_cn52xx {
566 uint64_t reserved_20_63:44;
567 uint64_t pause_drp:1;
496 uint64_t reserved_16_18:3; 568 uint64_t reserved_16_18:3;
497 uint64_t ifgerr:1; 569 uint64_t ifgerr:1;
498 uint64_t coldet:1; 570 uint64_t coldet:1;
@@ -510,11 +582,12 @@ union cvmx_agl_gmx_rxx_int_reg {
510 uint64_t maxerr:1; 582 uint64_t maxerr:1;
511 uint64_t reserved_1_1:1; 583 uint64_t reserved_1_1:1;
512 uint64_t minerr:1; 584 uint64_t minerr:1;
513 } s; 585 } cn52xx;
514 struct cvmx_agl_gmx_rxx_int_reg_s cn52xx; 586 struct cvmx_agl_gmx_rxx_int_reg_cn52xx cn52xxp1;
515 struct cvmx_agl_gmx_rxx_int_reg_s cn52xxp1; 587 struct cvmx_agl_gmx_rxx_int_reg_cn52xx cn56xx;
516 struct cvmx_agl_gmx_rxx_int_reg_s cn56xx; 588 struct cvmx_agl_gmx_rxx_int_reg_cn52xx cn56xxp1;
517 struct cvmx_agl_gmx_rxx_int_reg_s cn56xxp1; 589 struct cvmx_agl_gmx_rxx_int_reg_s cn63xx;
590 struct cvmx_agl_gmx_rxx_int_reg_s cn63xxp1;
518}; 591};
519 592
520union cvmx_agl_gmx_rxx_jabber { 593union cvmx_agl_gmx_rxx_jabber {
@@ -527,6 +600,8 @@ union cvmx_agl_gmx_rxx_jabber {
527 struct cvmx_agl_gmx_rxx_jabber_s cn52xxp1; 600 struct cvmx_agl_gmx_rxx_jabber_s cn52xxp1;
528 struct cvmx_agl_gmx_rxx_jabber_s cn56xx; 601 struct cvmx_agl_gmx_rxx_jabber_s cn56xx;
529 struct cvmx_agl_gmx_rxx_jabber_s cn56xxp1; 602 struct cvmx_agl_gmx_rxx_jabber_s cn56xxp1;
603 struct cvmx_agl_gmx_rxx_jabber_s cn63xx;
604 struct cvmx_agl_gmx_rxx_jabber_s cn63xxp1;
530}; 605};
531 606
532union cvmx_agl_gmx_rxx_pause_drop_time { 607union cvmx_agl_gmx_rxx_pause_drop_time {
@@ -539,6 +614,20 @@ union cvmx_agl_gmx_rxx_pause_drop_time {
539 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn52xxp1; 614 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn52xxp1;
540 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xx; 615 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xx;
541 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xxp1; 616 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xxp1;
617 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn63xx;
618 struct cvmx_agl_gmx_rxx_pause_drop_time_s cn63xxp1;
619};
620
621union cvmx_agl_gmx_rxx_rx_inbnd {
622 uint64_t u64;
623 struct cvmx_agl_gmx_rxx_rx_inbnd_s {
624 uint64_t reserved_4_63:60;
625 uint64_t duplex:1;
626 uint64_t speed:2;
627 uint64_t status:1;
628 } s;
629 struct cvmx_agl_gmx_rxx_rx_inbnd_s cn63xx;
630 struct cvmx_agl_gmx_rxx_rx_inbnd_s cn63xxp1;
542}; 631};
543 632
544union cvmx_agl_gmx_rxx_stats_ctl { 633union cvmx_agl_gmx_rxx_stats_ctl {
@@ -551,6 +640,8 @@ union cvmx_agl_gmx_rxx_stats_ctl {
551 struct cvmx_agl_gmx_rxx_stats_ctl_s cn52xxp1; 640 struct cvmx_agl_gmx_rxx_stats_ctl_s cn52xxp1;
552 struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xx; 641 struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xx;
553 struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xxp1; 642 struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xxp1;
643 struct cvmx_agl_gmx_rxx_stats_ctl_s cn63xx;
644 struct cvmx_agl_gmx_rxx_stats_ctl_s cn63xxp1;
554}; 645};
555 646
556union cvmx_agl_gmx_rxx_stats_octs { 647union cvmx_agl_gmx_rxx_stats_octs {
@@ -563,6 +654,8 @@ union cvmx_agl_gmx_rxx_stats_octs {
563 struct cvmx_agl_gmx_rxx_stats_octs_s cn52xxp1; 654 struct cvmx_agl_gmx_rxx_stats_octs_s cn52xxp1;
564 struct cvmx_agl_gmx_rxx_stats_octs_s cn56xx; 655 struct cvmx_agl_gmx_rxx_stats_octs_s cn56xx;
565 struct cvmx_agl_gmx_rxx_stats_octs_s cn56xxp1; 656 struct cvmx_agl_gmx_rxx_stats_octs_s cn56xxp1;
657 struct cvmx_agl_gmx_rxx_stats_octs_s cn63xx;
658 struct cvmx_agl_gmx_rxx_stats_octs_s cn63xxp1;
566}; 659};
567 660
568union cvmx_agl_gmx_rxx_stats_octs_ctl { 661union cvmx_agl_gmx_rxx_stats_octs_ctl {
@@ -575,6 +668,8 @@ union cvmx_agl_gmx_rxx_stats_octs_ctl {
575 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn52xxp1; 668 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn52xxp1;
576 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xx; 669 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xx;
577 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xxp1; 670 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xxp1;
671 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn63xx;
672 struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn63xxp1;
578}; 673};
579 674
580union cvmx_agl_gmx_rxx_stats_octs_dmac { 675union cvmx_agl_gmx_rxx_stats_octs_dmac {
@@ -587,6 +682,8 @@ union cvmx_agl_gmx_rxx_stats_octs_dmac {
587 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn52xxp1; 682 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn52xxp1;
588 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xx; 683 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xx;
589 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xxp1; 684 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xxp1;
685 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn63xx;
686 struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn63xxp1;
590}; 687};
591 688
592union cvmx_agl_gmx_rxx_stats_octs_drp { 689union cvmx_agl_gmx_rxx_stats_octs_drp {
@@ -599,6 +696,8 @@ union cvmx_agl_gmx_rxx_stats_octs_drp {
599 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn52xxp1; 696 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn52xxp1;
600 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xx; 697 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xx;
601 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xxp1; 698 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xxp1;
699 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn63xx;
700 struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn63xxp1;
602}; 701};
603 702
604union cvmx_agl_gmx_rxx_stats_pkts { 703union cvmx_agl_gmx_rxx_stats_pkts {
@@ -611,6 +710,8 @@ union cvmx_agl_gmx_rxx_stats_pkts {
611 struct cvmx_agl_gmx_rxx_stats_pkts_s cn52xxp1; 710 struct cvmx_agl_gmx_rxx_stats_pkts_s cn52xxp1;
612 struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xx; 711 struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xx;
613 struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xxp1; 712 struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xxp1;
713 struct cvmx_agl_gmx_rxx_stats_pkts_s cn63xx;
714 struct cvmx_agl_gmx_rxx_stats_pkts_s cn63xxp1;
614}; 715};
615 716
616union cvmx_agl_gmx_rxx_stats_pkts_bad { 717union cvmx_agl_gmx_rxx_stats_pkts_bad {
@@ -623,6 +724,8 @@ union cvmx_agl_gmx_rxx_stats_pkts_bad {
623 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn52xxp1; 724 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn52xxp1;
624 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xx; 725 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xx;
625 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xxp1; 726 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xxp1;
727 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn63xx;
728 struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn63xxp1;
626}; 729};
627 730
628union cvmx_agl_gmx_rxx_stats_pkts_ctl { 731union cvmx_agl_gmx_rxx_stats_pkts_ctl {
@@ -635,6 +738,8 @@ union cvmx_agl_gmx_rxx_stats_pkts_ctl {
635 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn52xxp1; 738 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn52xxp1;
636 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xx; 739 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xx;
637 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xxp1; 740 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xxp1;
741 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn63xx;
742 struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn63xxp1;
638}; 743};
639 744
640union cvmx_agl_gmx_rxx_stats_pkts_dmac { 745union cvmx_agl_gmx_rxx_stats_pkts_dmac {
@@ -647,6 +752,8 @@ union cvmx_agl_gmx_rxx_stats_pkts_dmac {
647 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn52xxp1; 752 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn52xxp1;
648 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xx; 753 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xx;
649 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xxp1; 754 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xxp1;
755 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn63xx;
756 struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn63xxp1;
650}; 757};
651 758
652union cvmx_agl_gmx_rxx_stats_pkts_drp { 759union cvmx_agl_gmx_rxx_stats_pkts_drp {
@@ -659,6 +766,8 @@ union cvmx_agl_gmx_rxx_stats_pkts_drp {
659 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn52xxp1; 766 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn52xxp1;
660 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xx; 767 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xx;
661 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xxp1; 768 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xxp1;
769 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn63xx;
770 struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn63xxp1;
662}; 771};
663 772
664union cvmx_agl_gmx_rxx_udd_skp { 773union cvmx_agl_gmx_rxx_udd_skp {
@@ -673,6 +782,8 @@ union cvmx_agl_gmx_rxx_udd_skp {
673 struct cvmx_agl_gmx_rxx_udd_skp_s cn52xxp1; 782 struct cvmx_agl_gmx_rxx_udd_skp_s cn52xxp1;
674 struct cvmx_agl_gmx_rxx_udd_skp_s cn56xx; 783 struct cvmx_agl_gmx_rxx_udd_skp_s cn56xx;
675 struct cvmx_agl_gmx_rxx_udd_skp_s cn56xxp1; 784 struct cvmx_agl_gmx_rxx_udd_skp_s cn56xxp1;
785 struct cvmx_agl_gmx_rxx_udd_skp_s cn63xx;
786 struct cvmx_agl_gmx_rxx_udd_skp_s cn63xxp1;
676}; 787};
677 788
678union cvmx_agl_gmx_rx_bp_dropx { 789union cvmx_agl_gmx_rx_bp_dropx {
@@ -685,6 +796,8 @@ union cvmx_agl_gmx_rx_bp_dropx {
685 struct cvmx_agl_gmx_rx_bp_dropx_s cn52xxp1; 796 struct cvmx_agl_gmx_rx_bp_dropx_s cn52xxp1;
686 struct cvmx_agl_gmx_rx_bp_dropx_s cn56xx; 797 struct cvmx_agl_gmx_rx_bp_dropx_s cn56xx;
687 struct cvmx_agl_gmx_rx_bp_dropx_s cn56xxp1; 798 struct cvmx_agl_gmx_rx_bp_dropx_s cn56xxp1;
799 struct cvmx_agl_gmx_rx_bp_dropx_s cn63xx;
800 struct cvmx_agl_gmx_rx_bp_dropx_s cn63xxp1;
688}; 801};
689 802
690union cvmx_agl_gmx_rx_bp_offx { 803union cvmx_agl_gmx_rx_bp_offx {
@@ -697,6 +810,8 @@ union cvmx_agl_gmx_rx_bp_offx {
697 struct cvmx_agl_gmx_rx_bp_offx_s cn52xxp1; 810 struct cvmx_agl_gmx_rx_bp_offx_s cn52xxp1;
698 struct cvmx_agl_gmx_rx_bp_offx_s cn56xx; 811 struct cvmx_agl_gmx_rx_bp_offx_s cn56xx;
699 struct cvmx_agl_gmx_rx_bp_offx_s cn56xxp1; 812 struct cvmx_agl_gmx_rx_bp_offx_s cn56xxp1;
813 struct cvmx_agl_gmx_rx_bp_offx_s cn63xx;
814 struct cvmx_agl_gmx_rx_bp_offx_s cn63xxp1;
700}; 815};
701 816
702union cvmx_agl_gmx_rx_bp_onx { 817union cvmx_agl_gmx_rx_bp_onx {
@@ -709,6 +824,8 @@ union cvmx_agl_gmx_rx_bp_onx {
709 struct cvmx_agl_gmx_rx_bp_onx_s cn52xxp1; 824 struct cvmx_agl_gmx_rx_bp_onx_s cn52xxp1;
710 struct cvmx_agl_gmx_rx_bp_onx_s cn56xx; 825 struct cvmx_agl_gmx_rx_bp_onx_s cn56xx;
711 struct cvmx_agl_gmx_rx_bp_onx_s cn56xxp1; 826 struct cvmx_agl_gmx_rx_bp_onx_s cn56xxp1;
827 struct cvmx_agl_gmx_rx_bp_onx_s cn63xx;
828 struct cvmx_agl_gmx_rx_bp_onx_s cn63xxp1;
712}; 829};
713 830
714union cvmx_agl_gmx_rx_prt_info { 831union cvmx_agl_gmx_rx_prt_info {
@@ -728,6 +845,8 @@ union cvmx_agl_gmx_rx_prt_info {
728 uint64_t commit:1; 845 uint64_t commit:1;
729 } cn56xx; 846 } cn56xx;
730 struct cvmx_agl_gmx_rx_prt_info_cn56xx cn56xxp1; 847 struct cvmx_agl_gmx_rx_prt_info_cn56xx cn56xxp1;
848 struct cvmx_agl_gmx_rx_prt_info_s cn63xx;
849 struct cvmx_agl_gmx_rx_prt_info_s cn63xxp1;
731}; 850};
732 851
733union cvmx_agl_gmx_rx_tx_status { 852union cvmx_agl_gmx_rx_tx_status {
@@ -747,6 +866,8 @@ union cvmx_agl_gmx_rx_tx_status {
747 uint64_t rx:1; 866 uint64_t rx:1;
748 } cn56xx; 867 } cn56xx;
749 struct cvmx_agl_gmx_rx_tx_status_cn56xx cn56xxp1; 868 struct cvmx_agl_gmx_rx_tx_status_cn56xx cn56xxp1;
869 struct cvmx_agl_gmx_rx_tx_status_s cn63xx;
870 struct cvmx_agl_gmx_rx_tx_status_s cn63xxp1;
750}; 871};
751 872
752union cvmx_agl_gmx_smacx { 873union cvmx_agl_gmx_smacx {
@@ -759,6 +880,8 @@ union cvmx_agl_gmx_smacx {
759 struct cvmx_agl_gmx_smacx_s cn52xxp1; 880 struct cvmx_agl_gmx_smacx_s cn52xxp1;
760 struct cvmx_agl_gmx_smacx_s cn56xx; 881 struct cvmx_agl_gmx_smacx_s cn56xx;
761 struct cvmx_agl_gmx_smacx_s cn56xxp1; 882 struct cvmx_agl_gmx_smacx_s cn56xxp1;
883 struct cvmx_agl_gmx_smacx_s cn63xx;
884 struct cvmx_agl_gmx_smacx_s cn63xxp1;
762}; 885};
763 886
764union cvmx_agl_gmx_stat_bp { 887union cvmx_agl_gmx_stat_bp {
@@ -772,6 +895,8 @@ union cvmx_agl_gmx_stat_bp {
772 struct cvmx_agl_gmx_stat_bp_s cn52xxp1; 895 struct cvmx_agl_gmx_stat_bp_s cn52xxp1;
773 struct cvmx_agl_gmx_stat_bp_s cn56xx; 896 struct cvmx_agl_gmx_stat_bp_s cn56xx;
774 struct cvmx_agl_gmx_stat_bp_s cn56xxp1; 897 struct cvmx_agl_gmx_stat_bp_s cn56xxp1;
898 struct cvmx_agl_gmx_stat_bp_s cn63xx;
899 struct cvmx_agl_gmx_stat_bp_s cn63xxp1;
775}; 900};
776 901
777union cvmx_agl_gmx_txx_append { 902union cvmx_agl_gmx_txx_append {
@@ -787,6 +912,18 @@ union cvmx_agl_gmx_txx_append {
787 struct cvmx_agl_gmx_txx_append_s cn52xxp1; 912 struct cvmx_agl_gmx_txx_append_s cn52xxp1;
788 struct cvmx_agl_gmx_txx_append_s cn56xx; 913 struct cvmx_agl_gmx_txx_append_s cn56xx;
789 struct cvmx_agl_gmx_txx_append_s cn56xxp1; 914 struct cvmx_agl_gmx_txx_append_s cn56xxp1;
915 struct cvmx_agl_gmx_txx_append_s cn63xx;
916 struct cvmx_agl_gmx_txx_append_s cn63xxp1;
917};
918
919union cvmx_agl_gmx_txx_clk {
920 uint64_t u64;
921 struct cvmx_agl_gmx_txx_clk_s {
922 uint64_t reserved_6_63:58;
923 uint64_t clk_cnt:6;
924 } s;
925 struct cvmx_agl_gmx_txx_clk_s cn63xx;
926 struct cvmx_agl_gmx_txx_clk_s cn63xxp1;
790}; 927};
791 928
792union cvmx_agl_gmx_txx_ctl { 929union cvmx_agl_gmx_txx_ctl {
@@ -800,6 +937,8 @@ union cvmx_agl_gmx_txx_ctl {
800 struct cvmx_agl_gmx_txx_ctl_s cn52xxp1; 937 struct cvmx_agl_gmx_txx_ctl_s cn52xxp1;
801 struct cvmx_agl_gmx_txx_ctl_s cn56xx; 938 struct cvmx_agl_gmx_txx_ctl_s cn56xx;
802 struct cvmx_agl_gmx_txx_ctl_s cn56xxp1; 939 struct cvmx_agl_gmx_txx_ctl_s cn56xxp1;
940 struct cvmx_agl_gmx_txx_ctl_s cn63xx;
941 struct cvmx_agl_gmx_txx_ctl_s cn63xxp1;
803}; 942};
804 943
805union cvmx_agl_gmx_txx_min_pkt { 944union cvmx_agl_gmx_txx_min_pkt {
@@ -812,6 +951,8 @@ union cvmx_agl_gmx_txx_min_pkt {
812 struct cvmx_agl_gmx_txx_min_pkt_s cn52xxp1; 951 struct cvmx_agl_gmx_txx_min_pkt_s cn52xxp1;
813 struct cvmx_agl_gmx_txx_min_pkt_s cn56xx; 952 struct cvmx_agl_gmx_txx_min_pkt_s cn56xx;
814 struct cvmx_agl_gmx_txx_min_pkt_s cn56xxp1; 953 struct cvmx_agl_gmx_txx_min_pkt_s cn56xxp1;
954 struct cvmx_agl_gmx_txx_min_pkt_s cn63xx;
955 struct cvmx_agl_gmx_txx_min_pkt_s cn63xxp1;
815}; 956};
816 957
817union cvmx_agl_gmx_txx_pause_pkt_interval { 958union cvmx_agl_gmx_txx_pause_pkt_interval {
@@ -824,6 +965,8 @@ union cvmx_agl_gmx_txx_pause_pkt_interval {
824 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn52xxp1; 965 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn52xxp1;
825 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xx; 966 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xx;
826 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xxp1; 967 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xxp1;
968 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn63xx;
969 struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn63xxp1;
827}; 970};
828 971
829union cvmx_agl_gmx_txx_pause_pkt_time { 972union cvmx_agl_gmx_txx_pause_pkt_time {
@@ -836,6 +979,8 @@ union cvmx_agl_gmx_txx_pause_pkt_time {
836 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn52xxp1; 979 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn52xxp1;
837 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xx; 980 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xx;
838 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xxp1; 981 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xxp1;
982 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn63xx;
983 struct cvmx_agl_gmx_txx_pause_pkt_time_s cn63xxp1;
839}; 984};
840 985
841union cvmx_agl_gmx_txx_pause_togo { 986union cvmx_agl_gmx_txx_pause_togo {
@@ -848,6 +993,8 @@ union cvmx_agl_gmx_txx_pause_togo {
848 struct cvmx_agl_gmx_txx_pause_togo_s cn52xxp1; 993 struct cvmx_agl_gmx_txx_pause_togo_s cn52xxp1;
849 struct cvmx_agl_gmx_txx_pause_togo_s cn56xx; 994 struct cvmx_agl_gmx_txx_pause_togo_s cn56xx;
850 struct cvmx_agl_gmx_txx_pause_togo_s cn56xxp1; 995 struct cvmx_agl_gmx_txx_pause_togo_s cn56xxp1;
996 struct cvmx_agl_gmx_txx_pause_togo_s cn63xx;
997 struct cvmx_agl_gmx_txx_pause_togo_s cn63xxp1;
851}; 998};
852 999
853union cvmx_agl_gmx_txx_pause_zero { 1000union cvmx_agl_gmx_txx_pause_zero {
@@ -860,6 +1007,8 @@ union cvmx_agl_gmx_txx_pause_zero {
860 struct cvmx_agl_gmx_txx_pause_zero_s cn52xxp1; 1007 struct cvmx_agl_gmx_txx_pause_zero_s cn52xxp1;
861 struct cvmx_agl_gmx_txx_pause_zero_s cn56xx; 1008 struct cvmx_agl_gmx_txx_pause_zero_s cn56xx;
862 struct cvmx_agl_gmx_txx_pause_zero_s cn56xxp1; 1009 struct cvmx_agl_gmx_txx_pause_zero_s cn56xxp1;
1010 struct cvmx_agl_gmx_txx_pause_zero_s cn63xx;
1011 struct cvmx_agl_gmx_txx_pause_zero_s cn63xxp1;
863}; 1012};
864 1013
865union cvmx_agl_gmx_txx_soft_pause { 1014union cvmx_agl_gmx_txx_soft_pause {
@@ -872,6 +1021,8 @@ union cvmx_agl_gmx_txx_soft_pause {
872 struct cvmx_agl_gmx_txx_soft_pause_s cn52xxp1; 1021 struct cvmx_agl_gmx_txx_soft_pause_s cn52xxp1;
873 struct cvmx_agl_gmx_txx_soft_pause_s cn56xx; 1022 struct cvmx_agl_gmx_txx_soft_pause_s cn56xx;
874 struct cvmx_agl_gmx_txx_soft_pause_s cn56xxp1; 1023 struct cvmx_agl_gmx_txx_soft_pause_s cn56xxp1;
1024 struct cvmx_agl_gmx_txx_soft_pause_s cn63xx;
1025 struct cvmx_agl_gmx_txx_soft_pause_s cn63xxp1;
875}; 1026};
876 1027
877union cvmx_agl_gmx_txx_stat0 { 1028union cvmx_agl_gmx_txx_stat0 {
@@ -884,6 +1035,8 @@ union cvmx_agl_gmx_txx_stat0 {
884 struct cvmx_agl_gmx_txx_stat0_s cn52xxp1; 1035 struct cvmx_agl_gmx_txx_stat0_s cn52xxp1;
885 struct cvmx_agl_gmx_txx_stat0_s cn56xx; 1036 struct cvmx_agl_gmx_txx_stat0_s cn56xx;
886 struct cvmx_agl_gmx_txx_stat0_s cn56xxp1; 1037 struct cvmx_agl_gmx_txx_stat0_s cn56xxp1;
1038 struct cvmx_agl_gmx_txx_stat0_s cn63xx;
1039 struct cvmx_agl_gmx_txx_stat0_s cn63xxp1;
887}; 1040};
888 1041
889union cvmx_agl_gmx_txx_stat1 { 1042union cvmx_agl_gmx_txx_stat1 {
@@ -896,6 +1049,8 @@ union cvmx_agl_gmx_txx_stat1 {
896 struct cvmx_agl_gmx_txx_stat1_s cn52xxp1; 1049 struct cvmx_agl_gmx_txx_stat1_s cn52xxp1;
897 struct cvmx_agl_gmx_txx_stat1_s cn56xx; 1050 struct cvmx_agl_gmx_txx_stat1_s cn56xx;
898 struct cvmx_agl_gmx_txx_stat1_s cn56xxp1; 1051 struct cvmx_agl_gmx_txx_stat1_s cn56xxp1;
1052 struct cvmx_agl_gmx_txx_stat1_s cn63xx;
1053 struct cvmx_agl_gmx_txx_stat1_s cn63xxp1;
899}; 1054};
900 1055
901union cvmx_agl_gmx_txx_stat2 { 1056union cvmx_agl_gmx_txx_stat2 {
@@ -908,6 +1063,8 @@ union cvmx_agl_gmx_txx_stat2 {
908 struct cvmx_agl_gmx_txx_stat2_s cn52xxp1; 1063 struct cvmx_agl_gmx_txx_stat2_s cn52xxp1;
909 struct cvmx_agl_gmx_txx_stat2_s cn56xx; 1064 struct cvmx_agl_gmx_txx_stat2_s cn56xx;
910 struct cvmx_agl_gmx_txx_stat2_s cn56xxp1; 1065 struct cvmx_agl_gmx_txx_stat2_s cn56xxp1;
1066 struct cvmx_agl_gmx_txx_stat2_s cn63xx;
1067 struct cvmx_agl_gmx_txx_stat2_s cn63xxp1;
911}; 1068};
912 1069
913union cvmx_agl_gmx_txx_stat3 { 1070union cvmx_agl_gmx_txx_stat3 {
@@ -920,6 +1077,8 @@ union cvmx_agl_gmx_txx_stat3 {
920 struct cvmx_agl_gmx_txx_stat3_s cn52xxp1; 1077 struct cvmx_agl_gmx_txx_stat3_s cn52xxp1;
921 struct cvmx_agl_gmx_txx_stat3_s cn56xx; 1078 struct cvmx_agl_gmx_txx_stat3_s cn56xx;
922 struct cvmx_agl_gmx_txx_stat3_s cn56xxp1; 1079 struct cvmx_agl_gmx_txx_stat3_s cn56xxp1;
1080 struct cvmx_agl_gmx_txx_stat3_s cn63xx;
1081 struct cvmx_agl_gmx_txx_stat3_s cn63xxp1;
923}; 1082};
924 1083
925union cvmx_agl_gmx_txx_stat4 { 1084union cvmx_agl_gmx_txx_stat4 {
@@ -932,6 +1091,8 @@ union cvmx_agl_gmx_txx_stat4 {
932 struct cvmx_agl_gmx_txx_stat4_s cn52xxp1; 1091 struct cvmx_agl_gmx_txx_stat4_s cn52xxp1;
933 struct cvmx_agl_gmx_txx_stat4_s cn56xx; 1092 struct cvmx_agl_gmx_txx_stat4_s cn56xx;
934 struct cvmx_agl_gmx_txx_stat4_s cn56xxp1; 1093 struct cvmx_agl_gmx_txx_stat4_s cn56xxp1;
1094 struct cvmx_agl_gmx_txx_stat4_s cn63xx;
1095 struct cvmx_agl_gmx_txx_stat4_s cn63xxp1;
935}; 1096};
936 1097
937union cvmx_agl_gmx_txx_stat5 { 1098union cvmx_agl_gmx_txx_stat5 {
@@ -944,6 +1105,8 @@ union cvmx_agl_gmx_txx_stat5 {
944 struct cvmx_agl_gmx_txx_stat5_s cn52xxp1; 1105 struct cvmx_agl_gmx_txx_stat5_s cn52xxp1;
945 struct cvmx_agl_gmx_txx_stat5_s cn56xx; 1106 struct cvmx_agl_gmx_txx_stat5_s cn56xx;
946 struct cvmx_agl_gmx_txx_stat5_s cn56xxp1; 1107 struct cvmx_agl_gmx_txx_stat5_s cn56xxp1;
1108 struct cvmx_agl_gmx_txx_stat5_s cn63xx;
1109 struct cvmx_agl_gmx_txx_stat5_s cn63xxp1;
947}; 1110};
948 1111
949union cvmx_agl_gmx_txx_stat6 { 1112union cvmx_agl_gmx_txx_stat6 {
@@ -956,6 +1119,8 @@ union cvmx_agl_gmx_txx_stat6 {
956 struct cvmx_agl_gmx_txx_stat6_s cn52xxp1; 1119 struct cvmx_agl_gmx_txx_stat6_s cn52xxp1;
957 struct cvmx_agl_gmx_txx_stat6_s cn56xx; 1120 struct cvmx_agl_gmx_txx_stat6_s cn56xx;
958 struct cvmx_agl_gmx_txx_stat6_s cn56xxp1; 1121 struct cvmx_agl_gmx_txx_stat6_s cn56xxp1;
1122 struct cvmx_agl_gmx_txx_stat6_s cn63xx;
1123 struct cvmx_agl_gmx_txx_stat6_s cn63xxp1;
959}; 1124};
960 1125
961union cvmx_agl_gmx_txx_stat7 { 1126union cvmx_agl_gmx_txx_stat7 {
@@ -968,6 +1133,8 @@ union cvmx_agl_gmx_txx_stat7 {
968 struct cvmx_agl_gmx_txx_stat7_s cn52xxp1; 1133 struct cvmx_agl_gmx_txx_stat7_s cn52xxp1;
969 struct cvmx_agl_gmx_txx_stat7_s cn56xx; 1134 struct cvmx_agl_gmx_txx_stat7_s cn56xx;
970 struct cvmx_agl_gmx_txx_stat7_s cn56xxp1; 1135 struct cvmx_agl_gmx_txx_stat7_s cn56xxp1;
1136 struct cvmx_agl_gmx_txx_stat7_s cn63xx;
1137 struct cvmx_agl_gmx_txx_stat7_s cn63xxp1;
971}; 1138};
972 1139
973union cvmx_agl_gmx_txx_stat8 { 1140union cvmx_agl_gmx_txx_stat8 {
@@ -980,6 +1147,8 @@ union cvmx_agl_gmx_txx_stat8 {
980 struct cvmx_agl_gmx_txx_stat8_s cn52xxp1; 1147 struct cvmx_agl_gmx_txx_stat8_s cn52xxp1;
981 struct cvmx_agl_gmx_txx_stat8_s cn56xx; 1148 struct cvmx_agl_gmx_txx_stat8_s cn56xx;
982 struct cvmx_agl_gmx_txx_stat8_s cn56xxp1; 1149 struct cvmx_agl_gmx_txx_stat8_s cn56xxp1;
1150 struct cvmx_agl_gmx_txx_stat8_s cn63xx;
1151 struct cvmx_agl_gmx_txx_stat8_s cn63xxp1;
983}; 1152};
984 1153
985union cvmx_agl_gmx_txx_stat9 { 1154union cvmx_agl_gmx_txx_stat9 {
@@ -992,6 +1161,8 @@ union cvmx_agl_gmx_txx_stat9 {
992 struct cvmx_agl_gmx_txx_stat9_s cn52xxp1; 1161 struct cvmx_agl_gmx_txx_stat9_s cn52xxp1;
993 struct cvmx_agl_gmx_txx_stat9_s cn56xx; 1162 struct cvmx_agl_gmx_txx_stat9_s cn56xx;
994 struct cvmx_agl_gmx_txx_stat9_s cn56xxp1; 1163 struct cvmx_agl_gmx_txx_stat9_s cn56xxp1;
1164 struct cvmx_agl_gmx_txx_stat9_s cn63xx;
1165 struct cvmx_agl_gmx_txx_stat9_s cn63xxp1;
995}; 1166};
996 1167
997union cvmx_agl_gmx_txx_stats_ctl { 1168union cvmx_agl_gmx_txx_stats_ctl {
@@ -1004,6 +1175,8 @@ union cvmx_agl_gmx_txx_stats_ctl {
1004 struct cvmx_agl_gmx_txx_stats_ctl_s cn52xxp1; 1175 struct cvmx_agl_gmx_txx_stats_ctl_s cn52xxp1;
1005 struct cvmx_agl_gmx_txx_stats_ctl_s cn56xx; 1176 struct cvmx_agl_gmx_txx_stats_ctl_s cn56xx;
1006 struct cvmx_agl_gmx_txx_stats_ctl_s cn56xxp1; 1177 struct cvmx_agl_gmx_txx_stats_ctl_s cn56xxp1;
1178 struct cvmx_agl_gmx_txx_stats_ctl_s cn63xx;
1179 struct cvmx_agl_gmx_txx_stats_ctl_s cn63xxp1;
1007}; 1180};
1008 1181
1009union cvmx_agl_gmx_txx_thresh { 1182union cvmx_agl_gmx_txx_thresh {
@@ -1016,6 +1189,8 @@ union cvmx_agl_gmx_txx_thresh {
1016 struct cvmx_agl_gmx_txx_thresh_s cn52xxp1; 1189 struct cvmx_agl_gmx_txx_thresh_s cn52xxp1;
1017 struct cvmx_agl_gmx_txx_thresh_s cn56xx; 1190 struct cvmx_agl_gmx_txx_thresh_s cn56xx;
1018 struct cvmx_agl_gmx_txx_thresh_s cn56xxp1; 1191 struct cvmx_agl_gmx_txx_thresh_s cn56xxp1;
1192 struct cvmx_agl_gmx_txx_thresh_s cn63xx;
1193 struct cvmx_agl_gmx_txx_thresh_s cn63xxp1;
1019}; 1194};
1020 1195
1021union cvmx_agl_gmx_tx_bp { 1196union cvmx_agl_gmx_tx_bp {
@@ -1031,6 +1206,8 @@ union cvmx_agl_gmx_tx_bp {
1031 uint64_t bp:1; 1206 uint64_t bp:1;
1032 } cn56xx; 1207 } cn56xx;
1033 struct cvmx_agl_gmx_tx_bp_cn56xx cn56xxp1; 1208 struct cvmx_agl_gmx_tx_bp_cn56xx cn56xxp1;
1209 struct cvmx_agl_gmx_tx_bp_s cn63xx;
1210 struct cvmx_agl_gmx_tx_bp_s cn63xxp1;
1034}; 1211};
1035 1212
1036union cvmx_agl_gmx_tx_col_attempt { 1213union cvmx_agl_gmx_tx_col_attempt {
@@ -1043,6 +1220,8 @@ union cvmx_agl_gmx_tx_col_attempt {
1043 struct cvmx_agl_gmx_tx_col_attempt_s cn52xxp1; 1220 struct cvmx_agl_gmx_tx_col_attempt_s cn52xxp1;
1044 struct cvmx_agl_gmx_tx_col_attempt_s cn56xx; 1221 struct cvmx_agl_gmx_tx_col_attempt_s cn56xx;
1045 struct cvmx_agl_gmx_tx_col_attempt_s cn56xxp1; 1222 struct cvmx_agl_gmx_tx_col_attempt_s cn56xxp1;
1223 struct cvmx_agl_gmx_tx_col_attempt_s cn63xx;
1224 struct cvmx_agl_gmx_tx_col_attempt_s cn63xxp1;
1046}; 1225};
1047 1226
1048union cvmx_agl_gmx_tx_ifg { 1227union cvmx_agl_gmx_tx_ifg {
@@ -1056,12 +1235,16 @@ union cvmx_agl_gmx_tx_ifg {
1056 struct cvmx_agl_gmx_tx_ifg_s cn52xxp1; 1235 struct cvmx_agl_gmx_tx_ifg_s cn52xxp1;
1057 struct cvmx_agl_gmx_tx_ifg_s cn56xx; 1236 struct cvmx_agl_gmx_tx_ifg_s cn56xx;
1058 struct cvmx_agl_gmx_tx_ifg_s cn56xxp1; 1237 struct cvmx_agl_gmx_tx_ifg_s cn56xxp1;
1238 struct cvmx_agl_gmx_tx_ifg_s cn63xx;
1239 struct cvmx_agl_gmx_tx_ifg_s cn63xxp1;
1059}; 1240};
1060 1241
1061union cvmx_agl_gmx_tx_int_en { 1242union cvmx_agl_gmx_tx_int_en {
1062 uint64_t u64; 1243 uint64_t u64;
1063 struct cvmx_agl_gmx_tx_int_en_s { 1244 struct cvmx_agl_gmx_tx_int_en_s {
1064 uint64_t reserved_18_63:46; 1245 uint64_t reserved_22_63:42;
1246 uint64_t ptp_lost:2;
1247 uint64_t reserved_18_19:2;
1065 uint64_t late_col:2; 1248 uint64_t late_col:2;
1066 uint64_t reserved_14_15:2; 1249 uint64_t reserved_14_15:2;
1067 uint64_t xsdef:2; 1250 uint64_t xsdef:2;
@@ -1072,8 +1255,19 @@ union cvmx_agl_gmx_tx_int_en {
1072 uint64_t reserved_1_1:1; 1255 uint64_t reserved_1_1:1;
1073 uint64_t pko_nxa:1; 1256 uint64_t pko_nxa:1;
1074 } s; 1257 } s;
1075 struct cvmx_agl_gmx_tx_int_en_s cn52xx; 1258 struct cvmx_agl_gmx_tx_int_en_cn52xx {
1076 struct cvmx_agl_gmx_tx_int_en_s cn52xxp1; 1259 uint64_t reserved_18_63:46;
1260 uint64_t late_col:2;
1261 uint64_t reserved_14_15:2;
1262 uint64_t xsdef:2;
1263 uint64_t reserved_10_11:2;
1264 uint64_t xscol:2;
1265 uint64_t reserved_4_7:4;
1266 uint64_t undflw:2;
1267 uint64_t reserved_1_1:1;
1268 uint64_t pko_nxa:1;
1269 } cn52xx;
1270 struct cvmx_agl_gmx_tx_int_en_cn52xx cn52xxp1;
1077 struct cvmx_agl_gmx_tx_int_en_cn56xx { 1271 struct cvmx_agl_gmx_tx_int_en_cn56xx {
1078 uint64_t reserved_17_63:47; 1272 uint64_t reserved_17_63:47;
1079 uint64_t late_col:1; 1273 uint64_t late_col:1;
@@ -1087,12 +1281,16 @@ union cvmx_agl_gmx_tx_int_en {
1087 uint64_t pko_nxa:1; 1281 uint64_t pko_nxa:1;
1088 } cn56xx; 1282 } cn56xx;
1089 struct cvmx_agl_gmx_tx_int_en_cn56xx cn56xxp1; 1283 struct cvmx_agl_gmx_tx_int_en_cn56xx cn56xxp1;
1284 struct cvmx_agl_gmx_tx_int_en_s cn63xx;
1285 struct cvmx_agl_gmx_tx_int_en_s cn63xxp1;
1090}; 1286};
1091 1287
1092union cvmx_agl_gmx_tx_int_reg { 1288union cvmx_agl_gmx_tx_int_reg {
1093 uint64_t u64; 1289 uint64_t u64;
1094 struct cvmx_agl_gmx_tx_int_reg_s { 1290 struct cvmx_agl_gmx_tx_int_reg_s {
1095 uint64_t reserved_18_63:46; 1291 uint64_t reserved_22_63:42;
1292 uint64_t ptp_lost:2;
1293 uint64_t reserved_18_19:2;
1096 uint64_t late_col:2; 1294 uint64_t late_col:2;
1097 uint64_t reserved_14_15:2; 1295 uint64_t reserved_14_15:2;
1098 uint64_t xsdef:2; 1296 uint64_t xsdef:2;
@@ -1103,8 +1301,19 @@ union cvmx_agl_gmx_tx_int_reg {
1103 uint64_t reserved_1_1:1; 1301 uint64_t reserved_1_1:1;
1104 uint64_t pko_nxa:1; 1302 uint64_t pko_nxa:1;
1105 } s; 1303 } s;
1106 struct cvmx_agl_gmx_tx_int_reg_s cn52xx; 1304 struct cvmx_agl_gmx_tx_int_reg_cn52xx {
1107 struct cvmx_agl_gmx_tx_int_reg_s cn52xxp1; 1305 uint64_t reserved_18_63:46;
1306 uint64_t late_col:2;
1307 uint64_t reserved_14_15:2;
1308 uint64_t xsdef:2;
1309 uint64_t reserved_10_11:2;
1310 uint64_t xscol:2;
1311 uint64_t reserved_4_7:4;
1312 uint64_t undflw:2;
1313 uint64_t reserved_1_1:1;
1314 uint64_t pko_nxa:1;
1315 } cn52xx;
1316 struct cvmx_agl_gmx_tx_int_reg_cn52xx cn52xxp1;
1108 struct cvmx_agl_gmx_tx_int_reg_cn56xx { 1317 struct cvmx_agl_gmx_tx_int_reg_cn56xx {
1109 uint64_t reserved_17_63:47; 1318 uint64_t reserved_17_63:47;
1110 uint64_t late_col:1; 1319 uint64_t late_col:1;
@@ -1118,6 +1327,8 @@ union cvmx_agl_gmx_tx_int_reg {
1118 uint64_t pko_nxa:1; 1327 uint64_t pko_nxa:1;
1119 } cn56xx; 1328 } cn56xx;
1120 struct cvmx_agl_gmx_tx_int_reg_cn56xx cn56xxp1; 1329 struct cvmx_agl_gmx_tx_int_reg_cn56xx cn56xxp1;
1330 struct cvmx_agl_gmx_tx_int_reg_s cn63xx;
1331 struct cvmx_agl_gmx_tx_int_reg_s cn63xxp1;
1121}; 1332};
1122 1333
1123union cvmx_agl_gmx_tx_jam { 1334union cvmx_agl_gmx_tx_jam {
@@ -1130,6 +1341,8 @@ union cvmx_agl_gmx_tx_jam {
1130 struct cvmx_agl_gmx_tx_jam_s cn52xxp1; 1341 struct cvmx_agl_gmx_tx_jam_s cn52xxp1;
1131 struct cvmx_agl_gmx_tx_jam_s cn56xx; 1342 struct cvmx_agl_gmx_tx_jam_s cn56xx;
1132 struct cvmx_agl_gmx_tx_jam_s cn56xxp1; 1343 struct cvmx_agl_gmx_tx_jam_s cn56xxp1;
1344 struct cvmx_agl_gmx_tx_jam_s cn63xx;
1345 struct cvmx_agl_gmx_tx_jam_s cn63xxp1;
1133}; 1346};
1134 1347
1135union cvmx_agl_gmx_tx_lfsr { 1348union cvmx_agl_gmx_tx_lfsr {
@@ -1142,6 +1355,8 @@ union cvmx_agl_gmx_tx_lfsr {
1142 struct cvmx_agl_gmx_tx_lfsr_s cn52xxp1; 1355 struct cvmx_agl_gmx_tx_lfsr_s cn52xxp1;
1143 struct cvmx_agl_gmx_tx_lfsr_s cn56xx; 1356 struct cvmx_agl_gmx_tx_lfsr_s cn56xx;
1144 struct cvmx_agl_gmx_tx_lfsr_s cn56xxp1; 1357 struct cvmx_agl_gmx_tx_lfsr_s cn56xxp1;
1358 struct cvmx_agl_gmx_tx_lfsr_s cn63xx;
1359 struct cvmx_agl_gmx_tx_lfsr_s cn63xxp1;
1145}; 1360};
1146 1361
1147union cvmx_agl_gmx_tx_ovr_bp { 1362union cvmx_agl_gmx_tx_ovr_bp {
@@ -1165,6 +1380,8 @@ union cvmx_agl_gmx_tx_ovr_bp {
1165 uint64_t ign_full:1; 1380 uint64_t ign_full:1;
1166 } cn56xx; 1381 } cn56xx;
1167 struct cvmx_agl_gmx_tx_ovr_bp_cn56xx cn56xxp1; 1382 struct cvmx_agl_gmx_tx_ovr_bp_cn56xx cn56xxp1;
1383 struct cvmx_agl_gmx_tx_ovr_bp_s cn63xx;
1384 struct cvmx_agl_gmx_tx_ovr_bp_s cn63xxp1;
1168}; 1385};
1169 1386
1170union cvmx_agl_gmx_tx_pause_pkt_dmac { 1387union cvmx_agl_gmx_tx_pause_pkt_dmac {
@@ -1177,6 +1394,8 @@ union cvmx_agl_gmx_tx_pause_pkt_dmac {
1177 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn52xxp1; 1394 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn52xxp1;
1178 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xx; 1395 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xx;
1179 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xxp1; 1396 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xxp1;
1397 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn63xx;
1398 struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn63xxp1;
1180}; 1399};
1181 1400
1182union cvmx_agl_gmx_tx_pause_pkt_type { 1401union cvmx_agl_gmx_tx_pause_pkt_type {
@@ -1189,6 +1408,39 @@ union cvmx_agl_gmx_tx_pause_pkt_type {
1189 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn52xxp1; 1408 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn52xxp1;
1190 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xx; 1409 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xx;
1191 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xxp1; 1410 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xxp1;
1411 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn63xx;
1412 struct cvmx_agl_gmx_tx_pause_pkt_type_s cn63xxp1;
1413};
1414
1415union cvmx_agl_prtx_ctl {
1416 uint64_t u64;
1417 struct cvmx_agl_prtx_ctl_s {
1418 uint64_t drv_byp:1;
1419 uint64_t reserved_62_62:1;
1420 uint64_t cmp_pctl:6;
1421 uint64_t reserved_54_55:2;
1422 uint64_t cmp_nctl:6;
1423 uint64_t reserved_46_47:2;
1424 uint64_t drv_pctl:6;
1425 uint64_t reserved_38_39:2;
1426 uint64_t drv_nctl:6;
1427 uint64_t reserved_29_31:3;
1428 uint64_t clk_set:5;
1429 uint64_t clkrx_byp:1;
1430 uint64_t reserved_21_22:2;
1431 uint64_t clkrx_set:5;
1432 uint64_t clktx_byp:1;
1433 uint64_t reserved_13_14:2;
1434 uint64_t clktx_set:5;
1435 uint64_t reserved_5_7:3;
1436 uint64_t dllrst:1;
1437 uint64_t comp:1;
1438 uint64_t enable:1;
1439 uint64_t clkrst:1;
1440 uint64_t mode:1;
1441 } s;
1442 struct cvmx_agl_prtx_ctl_s cn63xx;
1443 struct cvmx_agl_prtx_ctl_s cn63xxp1;
1192}; 1444};
1193 1445
1194#endif 1446#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-asm.h b/arch/mips/include/asm/octeon/cvmx-asm.h
index b21d3fc1ef91..5de5de95311b 100644
--- a/arch/mips/include/asm/octeon/cvmx-asm.h
+++ b/arch/mips/include/asm/octeon/cvmx-asm.h
@@ -114,6 +114,17 @@
114#define CVMX_DCACHE_INVALIDATE \ 114#define CVMX_DCACHE_INVALIDATE \
115 { CVMX_SYNC; asm volatile ("cache 9, 0($0)" : : ); } 115 { CVMX_SYNC; asm volatile ("cache 9, 0($0)" : : ); }
116 116
117#define CVMX_CACHE(op, address, offset) \
118 asm volatile ("cache " CVMX_TMP_STR(op) ", " CVMX_TMP_STR(offset) "(%[rbase])" \
119 : : [rbase] "d" (address) )
120/* fetch and lock the state. */
121#define CVMX_CACHE_LCKL2(address, offset) CVMX_CACHE(31, address, offset)
122/* unlock the state. */
123#define CVMX_CACHE_WBIL2(address, offset) CVMX_CACHE(23, address, offset)
124/* invalidate the cache block and clear the USED bits for the block */
125#define CVMX_CACHE_WBIL2I(address, offset) CVMX_CACHE(3, address, offset)
126/* load virtual tag and data for the L2 cache block into L2C_TAD0_TAG register */
127#define CVMX_CACHE_LTGL2I(address, offset) CVMX_CACHE(7, address, offset)
117 128
118#define CVMX_POP(result, input) \ 129#define CVMX_POP(result, input) \
119 asm ("pop %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) 130 asm ("pop %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input))
diff --git a/arch/mips/include/asm/octeon/cvmx-ciu-defs.h b/arch/mips/include/asm/octeon/cvmx-ciu-defs.h
index f8f05b7764b7..27cead370411 100644
--- a/arch/mips/include/asm/octeon/cvmx-ciu-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-ciu-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,87 +28,61 @@
28#ifndef __CVMX_CIU_DEFS_H__ 28#ifndef __CVMX_CIU_DEFS_H__
29#define __CVMX_CIU_DEFS_H__ 29#define __CVMX_CIU_DEFS_H__
30 30
31#define CVMX_CIU_BIST \ 31#define CVMX_CIU_BIST (CVMX_ADD_IO_SEG(0x0001070000000730ull))
32 CVMX_ADD_IO_SEG(0x0001070000000730ull) 32#define CVMX_CIU_BLOCK_INT (CVMX_ADD_IO_SEG(0x00010700000007C0ull))
33#define CVMX_CIU_DINT \ 33#define CVMX_CIU_DINT (CVMX_ADD_IO_SEG(0x0001070000000720ull))
34 CVMX_ADD_IO_SEG(0x0001070000000720ull) 34#define CVMX_CIU_FUSE (CVMX_ADD_IO_SEG(0x0001070000000728ull))
35#define CVMX_CIU_FUSE \ 35#define CVMX_CIU_GSTOP (CVMX_ADD_IO_SEG(0x0001070000000710ull))
36 CVMX_ADD_IO_SEG(0x0001070000000728ull) 36#define CVMX_CIU_INT33_SUM0 (CVMX_ADD_IO_SEG(0x0001070000000110ull))
37#define CVMX_CIU_GSTOP \ 37#define CVMX_CIU_INTX_EN0(offset) (CVMX_ADD_IO_SEG(0x0001070000000200ull) + ((offset) & 63) * 16)
38 CVMX_ADD_IO_SEG(0x0001070000000710ull) 38#define CVMX_CIU_INTX_EN0_W1C(offset) (CVMX_ADD_IO_SEG(0x0001070000002200ull) + ((offset) & 63) * 16)
39#define CVMX_CIU_INTX_EN0(offset) \ 39#define CVMX_CIU_INTX_EN0_W1S(offset) (CVMX_ADD_IO_SEG(0x0001070000006200ull) + ((offset) & 63) * 16)
40 CVMX_ADD_IO_SEG(0x0001070000000200ull + (((offset) & 63) * 16)) 40#define CVMX_CIU_INTX_EN1(offset) (CVMX_ADD_IO_SEG(0x0001070000000208ull) + ((offset) & 63) * 16)
41#define CVMX_CIU_INTX_EN0_W1C(offset) \ 41#define CVMX_CIU_INTX_EN1_W1C(offset) (CVMX_ADD_IO_SEG(0x0001070000002208ull) + ((offset) & 63) * 16)
42 CVMX_ADD_IO_SEG(0x0001070000002200ull + (((offset) & 63) * 16)) 42#define CVMX_CIU_INTX_EN1_W1S(offset) (CVMX_ADD_IO_SEG(0x0001070000006208ull) + ((offset) & 63) * 16)
43#define CVMX_CIU_INTX_EN0_W1S(offset) \ 43#define CVMX_CIU_INTX_EN4_0(offset) (CVMX_ADD_IO_SEG(0x0001070000000C80ull) + ((offset) & 15) * 16)
44 CVMX_ADD_IO_SEG(0x0001070000006200ull + (((offset) & 63) * 16)) 44#define CVMX_CIU_INTX_EN4_0_W1C(offset) (CVMX_ADD_IO_SEG(0x0001070000002C80ull) + ((offset) & 15) * 16)
45#define CVMX_CIU_INTX_EN1(offset) \ 45#define CVMX_CIU_INTX_EN4_0_W1S(offset) (CVMX_ADD_IO_SEG(0x0001070000006C80ull) + ((offset) & 15) * 16)
46 CVMX_ADD_IO_SEG(0x0001070000000208ull + (((offset) & 63) * 16)) 46#define CVMX_CIU_INTX_EN4_1(offset) (CVMX_ADD_IO_SEG(0x0001070000000C88ull) + ((offset) & 15) * 16)
47#define CVMX_CIU_INTX_EN1_W1C(offset) \ 47#define CVMX_CIU_INTX_EN4_1_W1C(offset) (CVMX_ADD_IO_SEG(0x0001070000002C88ull) + ((offset) & 15) * 16)
48 CVMX_ADD_IO_SEG(0x0001070000002208ull + (((offset) & 63) * 16)) 48#define CVMX_CIU_INTX_EN4_1_W1S(offset) (CVMX_ADD_IO_SEG(0x0001070000006C88ull) + ((offset) & 15) * 16)
49#define CVMX_CIU_INTX_EN1_W1S(offset) \ 49#define CVMX_CIU_INTX_SUM0(offset) (CVMX_ADD_IO_SEG(0x0001070000000000ull) + ((offset) & 63) * 8)
50 CVMX_ADD_IO_SEG(0x0001070000006208ull + (((offset) & 63) * 16)) 50#define CVMX_CIU_INTX_SUM4(offset) (CVMX_ADD_IO_SEG(0x0001070000000C00ull) + ((offset) & 15) * 8)
51#define CVMX_CIU_INTX_EN4_0(offset) \ 51#define CVMX_CIU_INT_DBG_SEL (CVMX_ADD_IO_SEG(0x00010700000007D0ull))
52 CVMX_ADD_IO_SEG(0x0001070000000C80ull + (((offset) & 15) * 16)) 52#define CVMX_CIU_INT_SUM1 (CVMX_ADD_IO_SEG(0x0001070000000108ull))
53#define CVMX_CIU_INTX_EN4_0_W1C(offset) \ 53#define CVMX_CIU_MBOX_CLRX(offset) (CVMX_ADD_IO_SEG(0x0001070000000680ull) + ((offset) & 15) * 8)
54 CVMX_ADD_IO_SEG(0x0001070000002C80ull + (((offset) & 15) * 16)) 54#define CVMX_CIU_MBOX_SETX(offset) (CVMX_ADD_IO_SEG(0x0001070000000600ull) + ((offset) & 15) * 8)
55#define CVMX_CIU_INTX_EN4_0_W1S(offset) \ 55#define CVMX_CIU_NMI (CVMX_ADD_IO_SEG(0x0001070000000718ull))
56 CVMX_ADD_IO_SEG(0x0001070000006C80ull + (((offset) & 15) * 16)) 56#define CVMX_CIU_PCI_INTA (CVMX_ADD_IO_SEG(0x0001070000000750ull))
57#define CVMX_CIU_INTX_EN4_1(offset) \ 57#define CVMX_CIU_PP_DBG (CVMX_ADD_IO_SEG(0x0001070000000708ull))
58 CVMX_ADD_IO_SEG(0x0001070000000C88ull + (((offset) & 15) * 16)) 58#define CVMX_CIU_PP_POKEX(offset) (CVMX_ADD_IO_SEG(0x0001070000000580ull) + ((offset) & 15) * 8)
59#define CVMX_CIU_INTX_EN4_1_W1C(offset) \ 59#define CVMX_CIU_PP_RST (CVMX_ADD_IO_SEG(0x0001070000000700ull))
60 CVMX_ADD_IO_SEG(0x0001070000002C88ull + (((offset) & 15) * 16)) 60#define CVMX_CIU_QLM0 (CVMX_ADD_IO_SEG(0x0001070000000780ull))
61#define CVMX_CIU_INTX_EN4_1_W1S(offset) \ 61#define CVMX_CIU_QLM1 (CVMX_ADD_IO_SEG(0x0001070000000788ull))
62 CVMX_ADD_IO_SEG(0x0001070000006C88ull + (((offset) & 15) * 16)) 62#define CVMX_CIU_QLM2 (CVMX_ADD_IO_SEG(0x0001070000000790ull))
63#define CVMX_CIU_INTX_SUM0(offset) \ 63#define CVMX_CIU_QLM_DCOK (CVMX_ADD_IO_SEG(0x0001070000000760ull))
64 CVMX_ADD_IO_SEG(0x0001070000000000ull + (((offset) & 63) * 8)) 64#define CVMX_CIU_QLM_JTGC (CVMX_ADD_IO_SEG(0x0001070000000768ull))
65#define CVMX_CIU_INTX_SUM4(offset) \ 65#define CVMX_CIU_QLM_JTGD (CVMX_ADD_IO_SEG(0x0001070000000770ull))
66 CVMX_ADD_IO_SEG(0x0001070000000C00ull + (((offset) & 15) * 8)) 66#define CVMX_CIU_SOFT_BIST (CVMX_ADD_IO_SEG(0x0001070000000738ull))
67#define CVMX_CIU_INT_SUM1 \ 67#define CVMX_CIU_SOFT_PRST (CVMX_ADD_IO_SEG(0x0001070000000748ull))
68 CVMX_ADD_IO_SEG(0x0001070000000108ull) 68#define CVMX_CIU_SOFT_PRST1 (CVMX_ADD_IO_SEG(0x0001070000000758ull))
69#define CVMX_CIU_MBOX_CLRX(offset) \ 69#define CVMX_CIU_SOFT_RST (CVMX_ADD_IO_SEG(0x0001070000000740ull))
70 CVMX_ADD_IO_SEG(0x0001070000000680ull + (((offset) & 15) * 8)) 70#define CVMX_CIU_TIMX(offset) (CVMX_ADD_IO_SEG(0x0001070000000480ull) + ((offset) & 3) * 8)
71#define CVMX_CIU_MBOX_SETX(offset) \ 71#define CVMX_CIU_WDOGX(offset) (CVMX_ADD_IO_SEG(0x0001070000000500ull) + ((offset) & 15) * 8)
72 CVMX_ADD_IO_SEG(0x0001070000000600ull + (((offset) & 15) * 8))
73#define CVMX_CIU_NMI \
74 CVMX_ADD_IO_SEG(0x0001070000000718ull)
75#define CVMX_CIU_PCI_INTA \
76 CVMX_ADD_IO_SEG(0x0001070000000750ull)
77#define CVMX_CIU_PP_DBG \
78 CVMX_ADD_IO_SEG(0x0001070000000708ull)
79#define CVMX_CIU_PP_POKEX(offset) \
80 CVMX_ADD_IO_SEG(0x0001070000000580ull + (((offset) & 15) * 8))
81#define CVMX_CIU_PP_RST \
82 CVMX_ADD_IO_SEG(0x0001070000000700ull)
83#define CVMX_CIU_QLM_DCOK \
84 CVMX_ADD_IO_SEG(0x0001070000000760ull)
85#define CVMX_CIU_QLM_JTGC \
86 CVMX_ADD_IO_SEG(0x0001070000000768ull)
87#define CVMX_CIU_QLM_JTGD \
88 CVMX_ADD_IO_SEG(0x0001070000000770ull)
89#define CVMX_CIU_SOFT_BIST \
90 CVMX_ADD_IO_SEG(0x0001070000000738ull)
91#define CVMX_CIU_SOFT_PRST \
92 CVMX_ADD_IO_SEG(0x0001070000000748ull)
93#define CVMX_CIU_SOFT_PRST1 \
94 CVMX_ADD_IO_SEG(0x0001070000000758ull)
95#define CVMX_CIU_SOFT_RST \
96 CVMX_ADD_IO_SEG(0x0001070000000740ull)
97#define CVMX_CIU_TIMX(offset) \
98 CVMX_ADD_IO_SEG(0x0001070000000480ull + (((offset) & 3) * 8))
99#define CVMX_CIU_WDOGX(offset) \
100 CVMX_ADD_IO_SEG(0x0001070000000500ull + (((offset) & 15) * 8))
101 72
102union cvmx_ciu_bist { 73union cvmx_ciu_bist {
103 uint64_t u64; 74 uint64_t u64;
104 struct cvmx_ciu_bist_s { 75 struct cvmx_ciu_bist_s {
76 uint64_t reserved_5_63:59;
77 uint64_t bist:5;
78 } s;
79 struct cvmx_ciu_bist_cn30xx {
105 uint64_t reserved_4_63:60; 80 uint64_t reserved_4_63:60;
106 uint64_t bist:4; 81 uint64_t bist:4;
107 } s; 82 } cn30xx;
108 struct cvmx_ciu_bist_s cn30xx; 83 struct cvmx_ciu_bist_cn30xx cn31xx;
109 struct cvmx_ciu_bist_s cn31xx; 84 struct cvmx_ciu_bist_cn30xx cn38xx;
110 struct cvmx_ciu_bist_s cn38xx; 85 struct cvmx_ciu_bist_cn30xx cn38xxp2;
111 struct cvmx_ciu_bist_s cn38xxp2;
112 struct cvmx_ciu_bist_cn50xx { 86 struct cvmx_ciu_bist_cn50xx {
113 uint64_t reserved_2_63:62; 87 uint64_t reserved_2_63:62;
114 uint64_t bist:2; 88 uint64_t bist:2;
@@ -118,10 +92,57 @@ union cvmx_ciu_bist {
118 uint64_t bist:3; 92 uint64_t bist:3;
119 } cn52xx; 93 } cn52xx;
120 struct cvmx_ciu_bist_cn52xx cn52xxp1; 94 struct cvmx_ciu_bist_cn52xx cn52xxp1;
121 struct cvmx_ciu_bist_s cn56xx; 95 struct cvmx_ciu_bist_cn30xx cn56xx;
122 struct cvmx_ciu_bist_s cn56xxp1; 96 struct cvmx_ciu_bist_cn30xx cn56xxp1;
123 struct cvmx_ciu_bist_s cn58xx; 97 struct cvmx_ciu_bist_cn30xx cn58xx;
124 struct cvmx_ciu_bist_s cn58xxp1; 98 struct cvmx_ciu_bist_cn30xx cn58xxp1;
99 struct cvmx_ciu_bist_s cn63xx;
100 struct cvmx_ciu_bist_s cn63xxp1;
101};
102
103union cvmx_ciu_block_int {
104 uint64_t u64;
105 struct cvmx_ciu_block_int_s {
106 uint64_t reserved_43_63:21;
107 uint64_t ptp:1;
108 uint64_t dpi:1;
109 uint64_t dfm:1;
110 uint64_t reserved_34_39:6;
111 uint64_t srio1:1;
112 uint64_t srio0:1;
113 uint64_t reserved_31_31:1;
114 uint64_t iob:1;
115 uint64_t reserved_29_29:1;
116 uint64_t agl:1;
117 uint64_t reserved_27_27:1;
118 uint64_t pem1:1;
119 uint64_t pem0:1;
120 uint64_t reserved_23_24:2;
121 uint64_t asxpcs0:1;
122 uint64_t reserved_21_21:1;
123 uint64_t pip:1;
124 uint64_t reserved_18_19:2;
125 uint64_t lmc0:1;
126 uint64_t l2c:1;
127 uint64_t reserved_15_15:1;
128 uint64_t rad:1;
129 uint64_t usb:1;
130 uint64_t pow:1;
131 uint64_t tim:1;
132 uint64_t pko:1;
133 uint64_t ipd:1;
134 uint64_t reserved_8_8:1;
135 uint64_t zip:1;
136 uint64_t dfa:1;
137 uint64_t fpa:1;
138 uint64_t key:1;
139 uint64_t sli:1;
140 uint64_t reserved_2_2:1;
141 uint64_t gmx0:1;
142 uint64_t mio:1;
143 } s;
144 struct cvmx_ciu_block_int_s cn63xx;
145 struct cvmx_ciu_block_int_s cn63xxp1;
125}; 146};
126 147
127union cvmx_ciu_dint { 148union cvmx_ciu_dint {
@@ -153,6 +174,11 @@ union cvmx_ciu_dint {
153 struct cvmx_ciu_dint_cn56xx cn56xxp1; 174 struct cvmx_ciu_dint_cn56xx cn56xxp1;
154 struct cvmx_ciu_dint_s cn58xx; 175 struct cvmx_ciu_dint_s cn58xx;
155 struct cvmx_ciu_dint_s cn58xxp1; 176 struct cvmx_ciu_dint_s cn58xxp1;
177 struct cvmx_ciu_dint_cn63xx {
178 uint64_t reserved_6_63:58;
179 uint64_t dint:6;
180 } cn63xx;
181 struct cvmx_ciu_dint_cn63xx cn63xxp1;
156}; 182};
157 183
158union cvmx_ciu_fuse { 184union cvmx_ciu_fuse {
@@ -184,6 +210,11 @@ union cvmx_ciu_fuse {
184 struct cvmx_ciu_fuse_cn56xx cn56xxp1; 210 struct cvmx_ciu_fuse_cn56xx cn56xxp1;
185 struct cvmx_ciu_fuse_s cn58xx; 211 struct cvmx_ciu_fuse_s cn58xx;
186 struct cvmx_ciu_fuse_s cn58xxp1; 212 struct cvmx_ciu_fuse_s cn58xxp1;
213 struct cvmx_ciu_fuse_cn63xx {
214 uint64_t reserved_6_63:58;
215 uint64_t fuse:6;
216 } cn63xx;
217 struct cvmx_ciu_fuse_cn63xx cn63xxp1;
187}; 218};
188 219
189union cvmx_ciu_gstop { 220union cvmx_ciu_gstop {
@@ -203,6 +234,8 @@ union cvmx_ciu_gstop {
203 struct cvmx_ciu_gstop_s cn56xxp1; 234 struct cvmx_ciu_gstop_s cn56xxp1;
204 struct cvmx_ciu_gstop_s cn58xx; 235 struct cvmx_ciu_gstop_s cn58xx;
205 struct cvmx_ciu_gstop_s cn58xxp1; 236 struct cvmx_ciu_gstop_s cn58xxp1;
237 struct cvmx_ciu_gstop_s cn63xx;
238 struct cvmx_ciu_gstop_s cn63xxp1;
206}; 239};
207 240
208union cvmx_ciu_intx_en0 { 241union cvmx_ciu_intx_en0 {
@@ -343,6 +376,8 @@ union cvmx_ciu_intx_en0 {
343 struct cvmx_ciu_intx_en0_cn56xx cn56xxp1; 376 struct cvmx_ciu_intx_en0_cn56xx cn56xxp1;
344 struct cvmx_ciu_intx_en0_cn38xx cn58xx; 377 struct cvmx_ciu_intx_en0_cn38xx cn58xx;
345 struct cvmx_ciu_intx_en0_cn38xx cn58xxp1; 378 struct cvmx_ciu_intx_en0_cn38xx cn58xxp1;
379 struct cvmx_ciu_intx_en0_cn52xx cn63xx;
380 struct cvmx_ciu_intx_en0_cn52xx cn63xxp1;
346}; 381};
347 382
348union cvmx_ciu_intx_en0_w1c { 383union cvmx_ciu_intx_en0_w1c {
@@ -412,6 +447,8 @@ union cvmx_ciu_intx_en0_w1c {
412 uint64_t gpio:16; 447 uint64_t gpio:16;
413 uint64_t workq:16; 448 uint64_t workq:16;
414 } cn58xx; 449 } cn58xx;
450 struct cvmx_ciu_intx_en0_w1c_cn52xx cn63xx;
451 struct cvmx_ciu_intx_en0_w1c_cn52xx cn63xxp1;
415}; 452};
416 453
417union cvmx_ciu_intx_en0_w1s { 454union cvmx_ciu_intx_en0_w1s {
@@ -481,12 +518,42 @@ union cvmx_ciu_intx_en0_w1s {
481 uint64_t gpio:16; 518 uint64_t gpio:16;
482 uint64_t workq:16; 519 uint64_t workq:16;
483 } cn58xx; 520 } cn58xx;
521 struct cvmx_ciu_intx_en0_w1s_cn52xx cn63xx;
522 struct cvmx_ciu_intx_en0_w1s_cn52xx cn63xxp1;
484}; 523};
485 524
486union cvmx_ciu_intx_en1 { 525union cvmx_ciu_intx_en1 {
487 uint64_t u64; 526 uint64_t u64;
488 struct cvmx_ciu_intx_en1_s { 527 struct cvmx_ciu_intx_en1_s {
489 uint64_t reserved_20_63:44; 528 uint64_t rst:1;
529 uint64_t reserved_57_62:6;
530 uint64_t dfm:1;
531 uint64_t reserved_53_55:3;
532 uint64_t lmc0:1;
533 uint64_t srio1:1;
534 uint64_t srio0:1;
535 uint64_t pem1:1;
536 uint64_t pem0:1;
537 uint64_t ptp:1;
538 uint64_t agl:1;
539 uint64_t reserved_37_45:9;
540 uint64_t agx0:1;
541 uint64_t dpi:1;
542 uint64_t sli:1;
543 uint64_t usb:1;
544 uint64_t dfa:1;
545 uint64_t key:1;
546 uint64_t rad:1;
547 uint64_t tim:1;
548 uint64_t zip:1;
549 uint64_t pko:1;
550 uint64_t pip:1;
551 uint64_t ipd:1;
552 uint64_t l2c:1;
553 uint64_t pow:1;
554 uint64_t fpa:1;
555 uint64_t iob:1;
556 uint64_t mio:1;
490 uint64_t nand:1; 557 uint64_t nand:1;
491 uint64_t mii1:1; 558 uint64_t mii1:1;
492 uint64_t usb1:1; 559 uint64_t usb1:1;
@@ -531,12 +598,76 @@ union cvmx_ciu_intx_en1 {
531 struct cvmx_ciu_intx_en1_cn56xx cn56xxp1; 598 struct cvmx_ciu_intx_en1_cn56xx cn56xxp1;
532 struct cvmx_ciu_intx_en1_cn38xx cn58xx; 599 struct cvmx_ciu_intx_en1_cn38xx cn58xx;
533 struct cvmx_ciu_intx_en1_cn38xx cn58xxp1; 600 struct cvmx_ciu_intx_en1_cn38xx cn58xxp1;
601 struct cvmx_ciu_intx_en1_cn63xx {
602 uint64_t rst:1;
603 uint64_t reserved_57_62:6;
604 uint64_t dfm:1;
605 uint64_t reserved_53_55:3;
606 uint64_t lmc0:1;
607 uint64_t srio1:1;
608 uint64_t srio0:1;
609 uint64_t pem1:1;
610 uint64_t pem0:1;
611 uint64_t ptp:1;
612 uint64_t agl:1;
613 uint64_t reserved_37_45:9;
614 uint64_t agx0:1;
615 uint64_t dpi:1;
616 uint64_t sli:1;
617 uint64_t usb:1;
618 uint64_t dfa:1;
619 uint64_t key:1;
620 uint64_t rad:1;
621 uint64_t tim:1;
622 uint64_t zip:1;
623 uint64_t pko:1;
624 uint64_t pip:1;
625 uint64_t ipd:1;
626 uint64_t l2c:1;
627 uint64_t pow:1;
628 uint64_t fpa:1;
629 uint64_t iob:1;
630 uint64_t mio:1;
631 uint64_t nand:1;
632 uint64_t mii1:1;
633 uint64_t reserved_6_17:12;
634 uint64_t wdog:6;
635 } cn63xx;
636 struct cvmx_ciu_intx_en1_cn63xx cn63xxp1;
534}; 637};
535 638
536union cvmx_ciu_intx_en1_w1c { 639union cvmx_ciu_intx_en1_w1c {
537 uint64_t u64; 640 uint64_t u64;
538 struct cvmx_ciu_intx_en1_w1c_s { 641 struct cvmx_ciu_intx_en1_w1c_s {
539 uint64_t reserved_20_63:44; 642 uint64_t rst:1;
643 uint64_t reserved_57_62:6;
644 uint64_t dfm:1;
645 uint64_t reserved_53_55:3;
646 uint64_t lmc0:1;
647 uint64_t srio1:1;
648 uint64_t srio0:1;
649 uint64_t pem1:1;
650 uint64_t pem0:1;
651 uint64_t ptp:1;
652 uint64_t agl:1;
653 uint64_t reserved_37_45:9;
654 uint64_t agx0:1;
655 uint64_t dpi:1;
656 uint64_t sli:1;
657 uint64_t usb:1;
658 uint64_t dfa:1;
659 uint64_t key:1;
660 uint64_t rad:1;
661 uint64_t tim:1;
662 uint64_t zip:1;
663 uint64_t pko:1;
664 uint64_t pip:1;
665 uint64_t ipd:1;
666 uint64_t l2c:1;
667 uint64_t pow:1;
668 uint64_t fpa:1;
669 uint64_t iob:1;
670 uint64_t mio:1;
540 uint64_t nand:1; 671 uint64_t nand:1;
541 uint64_t mii1:1; 672 uint64_t mii1:1;
542 uint64_t usb1:1; 673 uint64_t usb1:1;
@@ -560,12 +691,76 @@ union cvmx_ciu_intx_en1_w1c {
560 uint64_t reserved_16_63:48; 691 uint64_t reserved_16_63:48;
561 uint64_t wdog:16; 692 uint64_t wdog:16;
562 } cn58xx; 693 } cn58xx;
694 struct cvmx_ciu_intx_en1_w1c_cn63xx {
695 uint64_t rst:1;
696 uint64_t reserved_57_62:6;
697 uint64_t dfm:1;
698 uint64_t reserved_53_55:3;
699 uint64_t lmc0:1;
700 uint64_t srio1:1;
701 uint64_t srio0:1;
702 uint64_t pem1:1;
703 uint64_t pem0:1;
704 uint64_t ptp:1;
705 uint64_t agl:1;
706 uint64_t reserved_37_45:9;
707 uint64_t agx0:1;
708 uint64_t dpi:1;
709 uint64_t sli:1;
710 uint64_t usb:1;
711 uint64_t dfa:1;
712 uint64_t key:1;
713 uint64_t rad:1;
714 uint64_t tim:1;
715 uint64_t zip:1;
716 uint64_t pko:1;
717 uint64_t pip:1;
718 uint64_t ipd:1;
719 uint64_t l2c:1;
720 uint64_t pow:1;
721 uint64_t fpa:1;
722 uint64_t iob:1;
723 uint64_t mio:1;
724 uint64_t nand:1;
725 uint64_t mii1:1;
726 uint64_t reserved_6_17:12;
727 uint64_t wdog:6;
728 } cn63xx;
729 struct cvmx_ciu_intx_en1_w1c_cn63xx cn63xxp1;
563}; 730};
564 731
565union cvmx_ciu_intx_en1_w1s { 732union cvmx_ciu_intx_en1_w1s {
566 uint64_t u64; 733 uint64_t u64;
567 struct cvmx_ciu_intx_en1_w1s_s { 734 struct cvmx_ciu_intx_en1_w1s_s {
568 uint64_t reserved_20_63:44; 735 uint64_t rst:1;
736 uint64_t reserved_57_62:6;
737 uint64_t dfm:1;
738 uint64_t reserved_53_55:3;
739 uint64_t lmc0:1;
740 uint64_t srio1:1;
741 uint64_t srio0:1;
742 uint64_t pem1:1;
743 uint64_t pem0:1;
744 uint64_t ptp:1;
745 uint64_t agl:1;
746 uint64_t reserved_37_45:9;
747 uint64_t agx0:1;
748 uint64_t dpi:1;
749 uint64_t sli:1;
750 uint64_t usb:1;
751 uint64_t dfa:1;
752 uint64_t key:1;
753 uint64_t rad:1;
754 uint64_t tim:1;
755 uint64_t zip:1;
756 uint64_t pko:1;
757 uint64_t pip:1;
758 uint64_t ipd:1;
759 uint64_t l2c:1;
760 uint64_t pow:1;
761 uint64_t fpa:1;
762 uint64_t iob:1;
763 uint64_t mio:1;
569 uint64_t nand:1; 764 uint64_t nand:1;
570 uint64_t mii1:1; 765 uint64_t mii1:1;
571 uint64_t usb1:1; 766 uint64_t usb1:1;
@@ -589,6 +784,42 @@ union cvmx_ciu_intx_en1_w1s {
589 uint64_t reserved_16_63:48; 784 uint64_t reserved_16_63:48;
590 uint64_t wdog:16; 785 uint64_t wdog:16;
591 } cn58xx; 786 } cn58xx;
787 struct cvmx_ciu_intx_en1_w1s_cn63xx {
788 uint64_t rst:1;
789 uint64_t reserved_57_62:6;
790 uint64_t dfm:1;
791 uint64_t reserved_53_55:3;
792 uint64_t lmc0:1;
793 uint64_t srio1:1;
794 uint64_t srio0:1;
795 uint64_t pem1:1;
796 uint64_t pem0:1;
797 uint64_t ptp:1;
798 uint64_t agl:1;
799 uint64_t reserved_37_45:9;
800 uint64_t agx0:1;
801 uint64_t dpi:1;
802 uint64_t sli:1;
803 uint64_t usb:1;
804 uint64_t dfa:1;
805 uint64_t key:1;
806 uint64_t rad:1;
807 uint64_t tim:1;
808 uint64_t zip:1;
809 uint64_t pko:1;
810 uint64_t pip:1;
811 uint64_t ipd:1;
812 uint64_t l2c:1;
813 uint64_t pow:1;
814 uint64_t fpa:1;
815 uint64_t iob:1;
816 uint64_t mio:1;
817 uint64_t nand:1;
818 uint64_t mii1:1;
819 uint64_t reserved_6_17:12;
820 uint64_t wdog:6;
821 } cn63xx;
822 struct cvmx_ciu_intx_en1_w1s_cn63xx cn63xxp1;
592}; 823};
593 824
594union cvmx_ciu_intx_en4_0 { 825union cvmx_ciu_intx_en4_0 {
@@ -705,6 +936,8 @@ union cvmx_ciu_intx_en4_0 {
705 uint64_t workq:16; 936 uint64_t workq:16;
706 } cn58xx; 937 } cn58xx;
707 struct cvmx_ciu_intx_en4_0_cn58xx cn58xxp1; 938 struct cvmx_ciu_intx_en4_0_cn58xx cn58xxp1;
939 struct cvmx_ciu_intx_en4_0_cn52xx cn63xx;
940 struct cvmx_ciu_intx_en4_0_cn52xx cn63xxp1;
708}; 941};
709 942
710union cvmx_ciu_intx_en4_0_w1c { 943union cvmx_ciu_intx_en4_0_w1c {
@@ -774,6 +1007,8 @@ union cvmx_ciu_intx_en4_0_w1c {
774 uint64_t gpio:16; 1007 uint64_t gpio:16;
775 uint64_t workq:16; 1008 uint64_t workq:16;
776 } cn58xx; 1009 } cn58xx;
1010 struct cvmx_ciu_intx_en4_0_w1c_cn52xx cn63xx;
1011 struct cvmx_ciu_intx_en4_0_w1c_cn52xx cn63xxp1;
777}; 1012};
778 1013
779union cvmx_ciu_intx_en4_0_w1s { 1014union cvmx_ciu_intx_en4_0_w1s {
@@ -843,12 +1078,42 @@ union cvmx_ciu_intx_en4_0_w1s {
843 uint64_t gpio:16; 1078 uint64_t gpio:16;
844 uint64_t workq:16; 1079 uint64_t workq:16;
845 } cn58xx; 1080 } cn58xx;
1081 struct cvmx_ciu_intx_en4_0_w1s_cn52xx cn63xx;
1082 struct cvmx_ciu_intx_en4_0_w1s_cn52xx cn63xxp1;
846}; 1083};
847 1084
848union cvmx_ciu_intx_en4_1 { 1085union cvmx_ciu_intx_en4_1 {
849 uint64_t u64; 1086 uint64_t u64;
850 struct cvmx_ciu_intx_en4_1_s { 1087 struct cvmx_ciu_intx_en4_1_s {
851 uint64_t reserved_20_63:44; 1088 uint64_t rst:1;
1089 uint64_t reserved_57_62:6;
1090 uint64_t dfm:1;
1091 uint64_t reserved_53_55:3;
1092 uint64_t lmc0:1;
1093 uint64_t srio1:1;
1094 uint64_t srio0:1;
1095 uint64_t pem1:1;
1096 uint64_t pem0:1;
1097 uint64_t ptp:1;
1098 uint64_t agl:1;
1099 uint64_t reserved_37_45:9;
1100 uint64_t agx0:1;
1101 uint64_t dpi:1;
1102 uint64_t sli:1;
1103 uint64_t usb:1;
1104 uint64_t dfa:1;
1105 uint64_t key:1;
1106 uint64_t rad:1;
1107 uint64_t tim:1;
1108 uint64_t zip:1;
1109 uint64_t pko:1;
1110 uint64_t pip:1;
1111 uint64_t ipd:1;
1112 uint64_t l2c:1;
1113 uint64_t pow:1;
1114 uint64_t fpa:1;
1115 uint64_t iob:1;
1116 uint64_t mio:1;
852 uint64_t nand:1; 1117 uint64_t nand:1;
853 uint64_t mii1:1; 1118 uint64_t mii1:1;
854 uint64_t usb1:1; 1119 uint64_t usb1:1;
@@ -886,12 +1151,76 @@ union cvmx_ciu_intx_en4_1 {
886 uint64_t wdog:16; 1151 uint64_t wdog:16;
887 } cn58xx; 1152 } cn58xx;
888 struct cvmx_ciu_intx_en4_1_cn58xx cn58xxp1; 1153 struct cvmx_ciu_intx_en4_1_cn58xx cn58xxp1;
1154 struct cvmx_ciu_intx_en4_1_cn63xx {
1155 uint64_t rst:1;
1156 uint64_t reserved_57_62:6;
1157 uint64_t dfm:1;
1158 uint64_t reserved_53_55:3;
1159 uint64_t lmc0:1;
1160 uint64_t srio1:1;
1161 uint64_t srio0:1;
1162 uint64_t pem1:1;
1163 uint64_t pem0:1;
1164 uint64_t ptp:1;
1165 uint64_t agl:1;
1166 uint64_t reserved_37_45:9;
1167 uint64_t agx0:1;
1168 uint64_t dpi:1;
1169 uint64_t sli:1;
1170 uint64_t usb:1;
1171 uint64_t dfa:1;
1172 uint64_t key:1;
1173 uint64_t rad:1;
1174 uint64_t tim:1;
1175 uint64_t zip:1;
1176 uint64_t pko:1;
1177 uint64_t pip:1;
1178 uint64_t ipd:1;
1179 uint64_t l2c:1;
1180 uint64_t pow:1;
1181 uint64_t fpa:1;
1182 uint64_t iob:1;
1183 uint64_t mio:1;
1184 uint64_t nand:1;
1185 uint64_t mii1:1;
1186 uint64_t reserved_6_17:12;
1187 uint64_t wdog:6;
1188 } cn63xx;
1189 struct cvmx_ciu_intx_en4_1_cn63xx cn63xxp1;
889}; 1190};
890 1191
891union cvmx_ciu_intx_en4_1_w1c { 1192union cvmx_ciu_intx_en4_1_w1c {
892 uint64_t u64; 1193 uint64_t u64;
893 struct cvmx_ciu_intx_en4_1_w1c_s { 1194 struct cvmx_ciu_intx_en4_1_w1c_s {
894 uint64_t reserved_20_63:44; 1195 uint64_t rst:1;
1196 uint64_t reserved_57_62:6;
1197 uint64_t dfm:1;
1198 uint64_t reserved_53_55:3;
1199 uint64_t lmc0:1;
1200 uint64_t srio1:1;
1201 uint64_t srio0:1;
1202 uint64_t pem1:1;
1203 uint64_t pem0:1;
1204 uint64_t ptp:1;
1205 uint64_t agl:1;
1206 uint64_t reserved_37_45:9;
1207 uint64_t agx0:1;
1208 uint64_t dpi:1;
1209 uint64_t sli:1;
1210 uint64_t usb:1;
1211 uint64_t dfa:1;
1212 uint64_t key:1;
1213 uint64_t rad:1;
1214 uint64_t tim:1;
1215 uint64_t zip:1;
1216 uint64_t pko:1;
1217 uint64_t pip:1;
1218 uint64_t ipd:1;
1219 uint64_t l2c:1;
1220 uint64_t pow:1;
1221 uint64_t fpa:1;
1222 uint64_t iob:1;
1223 uint64_t mio:1;
895 uint64_t nand:1; 1224 uint64_t nand:1;
896 uint64_t mii1:1; 1225 uint64_t mii1:1;
897 uint64_t usb1:1; 1226 uint64_t usb1:1;
@@ -915,12 +1244,76 @@ union cvmx_ciu_intx_en4_1_w1c {
915 uint64_t reserved_16_63:48; 1244 uint64_t reserved_16_63:48;
916 uint64_t wdog:16; 1245 uint64_t wdog:16;
917 } cn58xx; 1246 } cn58xx;
1247 struct cvmx_ciu_intx_en4_1_w1c_cn63xx {
1248 uint64_t rst:1;
1249 uint64_t reserved_57_62:6;
1250 uint64_t dfm:1;
1251 uint64_t reserved_53_55:3;
1252 uint64_t lmc0:1;
1253 uint64_t srio1:1;
1254 uint64_t srio0:1;
1255 uint64_t pem1:1;
1256 uint64_t pem0:1;
1257 uint64_t ptp:1;
1258 uint64_t agl:1;
1259 uint64_t reserved_37_45:9;
1260 uint64_t agx0:1;
1261 uint64_t dpi:1;
1262 uint64_t sli:1;
1263 uint64_t usb:1;
1264 uint64_t dfa:1;
1265 uint64_t key:1;
1266 uint64_t rad:1;
1267 uint64_t tim:1;
1268 uint64_t zip:1;
1269 uint64_t pko:1;
1270 uint64_t pip:1;
1271 uint64_t ipd:1;
1272 uint64_t l2c:1;
1273 uint64_t pow:1;
1274 uint64_t fpa:1;
1275 uint64_t iob:1;
1276 uint64_t mio:1;
1277 uint64_t nand:1;
1278 uint64_t mii1:1;
1279 uint64_t reserved_6_17:12;
1280 uint64_t wdog:6;
1281 } cn63xx;
1282 struct cvmx_ciu_intx_en4_1_w1c_cn63xx cn63xxp1;
918}; 1283};
919 1284
920union cvmx_ciu_intx_en4_1_w1s { 1285union cvmx_ciu_intx_en4_1_w1s {
921 uint64_t u64; 1286 uint64_t u64;
922 struct cvmx_ciu_intx_en4_1_w1s_s { 1287 struct cvmx_ciu_intx_en4_1_w1s_s {
923 uint64_t reserved_20_63:44; 1288 uint64_t rst:1;
1289 uint64_t reserved_57_62:6;
1290 uint64_t dfm:1;
1291 uint64_t reserved_53_55:3;
1292 uint64_t lmc0:1;
1293 uint64_t srio1:1;
1294 uint64_t srio0:1;
1295 uint64_t pem1:1;
1296 uint64_t pem0:1;
1297 uint64_t ptp:1;
1298 uint64_t agl:1;
1299 uint64_t reserved_37_45:9;
1300 uint64_t agx0:1;
1301 uint64_t dpi:1;
1302 uint64_t sli:1;
1303 uint64_t usb:1;
1304 uint64_t dfa:1;
1305 uint64_t key:1;
1306 uint64_t rad:1;
1307 uint64_t tim:1;
1308 uint64_t zip:1;
1309 uint64_t pko:1;
1310 uint64_t pip:1;
1311 uint64_t ipd:1;
1312 uint64_t l2c:1;
1313 uint64_t pow:1;
1314 uint64_t fpa:1;
1315 uint64_t iob:1;
1316 uint64_t mio:1;
924 uint64_t nand:1; 1317 uint64_t nand:1;
925 uint64_t mii1:1; 1318 uint64_t mii1:1;
926 uint64_t usb1:1; 1319 uint64_t usb1:1;
@@ -944,6 +1337,42 @@ union cvmx_ciu_intx_en4_1_w1s {
944 uint64_t reserved_16_63:48; 1337 uint64_t reserved_16_63:48;
945 uint64_t wdog:16; 1338 uint64_t wdog:16;
946 } cn58xx; 1339 } cn58xx;
1340 struct cvmx_ciu_intx_en4_1_w1s_cn63xx {
1341 uint64_t rst:1;
1342 uint64_t reserved_57_62:6;
1343 uint64_t dfm:1;
1344 uint64_t reserved_53_55:3;
1345 uint64_t lmc0:1;
1346 uint64_t srio1:1;
1347 uint64_t srio0:1;
1348 uint64_t pem1:1;
1349 uint64_t pem0:1;
1350 uint64_t ptp:1;
1351 uint64_t agl:1;
1352 uint64_t reserved_37_45:9;
1353 uint64_t agx0:1;
1354 uint64_t dpi:1;
1355 uint64_t sli:1;
1356 uint64_t usb:1;
1357 uint64_t dfa:1;
1358 uint64_t key:1;
1359 uint64_t rad:1;
1360 uint64_t tim:1;
1361 uint64_t zip:1;
1362 uint64_t pko:1;
1363 uint64_t pip:1;
1364 uint64_t ipd:1;
1365 uint64_t l2c:1;
1366 uint64_t pow:1;
1367 uint64_t fpa:1;
1368 uint64_t iob:1;
1369 uint64_t mio:1;
1370 uint64_t nand:1;
1371 uint64_t mii1:1;
1372 uint64_t reserved_6_17:12;
1373 uint64_t wdog:6;
1374 } cn63xx;
1375 struct cvmx_ciu_intx_en4_1_w1s_cn63xx cn63xxp1;
947}; 1376};
948 1377
949union cvmx_ciu_intx_sum0 { 1378union cvmx_ciu_intx_sum0 {
@@ -1084,6 +1513,8 @@ union cvmx_ciu_intx_sum0 {
1084 struct cvmx_ciu_intx_sum0_cn56xx cn56xxp1; 1513 struct cvmx_ciu_intx_sum0_cn56xx cn56xxp1;
1085 struct cvmx_ciu_intx_sum0_cn38xx cn58xx; 1514 struct cvmx_ciu_intx_sum0_cn38xx cn58xx;
1086 struct cvmx_ciu_intx_sum0_cn38xx cn58xxp1; 1515 struct cvmx_ciu_intx_sum0_cn38xx cn58xxp1;
1516 struct cvmx_ciu_intx_sum0_cn52xx cn63xx;
1517 struct cvmx_ciu_intx_sum0_cn52xx cn63xxp1;
1087}; 1518};
1088 1519
1089union cvmx_ciu_intx_sum4 { 1520union cvmx_ciu_intx_sum4 {
@@ -1200,12 +1631,85 @@ union cvmx_ciu_intx_sum4 {
1200 uint64_t workq:16; 1631 uint64_t workq:16;
1201 } cn58xx; 1632 } cn58xx;
1202 struct cvmx_ciu_intx_sum4_cn58xx cn58xxp1; 1633 struct cvmx_ciu_intx_sum4_cn58xx cn58xxp1;
1634 struct cvmx_ciu_intx_sum4_cn52xx cn63xx;
1635 struct cvmx_ciu_intx_sum4_cn52xx cn63xxp1;
1636};
1637
1638union cvmx_ciu_int33_sum0 {
1639 uint64_t u64;
1640 struct cvmx_ciu_int33_sum0_s {
1641 uint64_t bootdma:1;
1642 uint64_t mii:1;
1643 uint64_t ipdppthr:1;
1644 uint64_t powiq:1;
1645 uint64_t twsi2:1;
1646 uint64_t reserved_57_58:2;
1647 uint64_t usb:1;
1648 uint64_t timer:4;
1649 uint64_t reserved_51_51:1;
1650 uint64_t ipd_drp:1;
1651 uint64_t reserved_49_49:1;
1652 uint64_t gmx_drp:1;
1653 uint64_t trace:1;
1654 uint64_t rml:1;
1655 uint64_t twsi:1;
1656 uint64_t wdog_sum:1;
1657 uint64_t pci_msi:4;
1658 uint64_t pci_int:4;
1659 uint64_t uart:2;
1660 uint64_t mbox:2;
1661 uint64_t gpio:16;
1662 uint64_t workq:16;
1663 } s;
1664 struct cvmx_ciu_int33_sum0_s cn63xx;
1665 struct cvmx_ciu_int33_sum0_s cn63xxp1;
1666};
1667
1668union cvmx_ciu_int_dbg_sel {
1669 uint64_t u64;
1670 struct cvmx_ciu_int_dbg_sel_s {
1671 uint64_t reserved_19_63:45;
1672 uint64_t sel:3;
1673 uint64_t reserved_10_15:6;
1674 uint64_t irq:2;
1675 uint64_t reserved_3_7:5;
1676 uint64_t pp:3;
1677 } s;
1678 struct cvmx_ciu_int_dbg_sel_s cn63xx;
1203}; 1679};
1204 1680
1205union cvmx_ciu_int_sum1 { 1681union cvmx_ciu_int_sum1 {
1206 uint64_t u64; 1682 uint64_t u64;
1207 struct cvmx_ciu_int_sum1_s { 1683 struct cvmx_ciu_int_sum1_s {
1208 uint64_t reserved_20_63:44; 1684 uint64_t rst:1;
1685 uint64_t reserved_57_62:6;
1686 uint64_t dfm:1;
1687 uint64_t reserved_53_55:3;
1688 uint64_t lmc0:1;
1689 uint64_t srio1:1;
1690 uint64_t srio0:1;
1691 uint64_t pem1:1;
1692 uint64_t pem0:1;
1693 uint64_t ptp:1;
1694 uint64_t agl:1;
1695 uint64_t reserved_37_45:9;
1696 uint64_t agx0:1;
1697 uint64_t dpi:1;
1698 uint64_t sli:1;
1699 uint64_t usb:1;
1700 uint64_t dfa:1;
1701 uint64_t key:1;
1702 uint64_t rad:1;
1703 uint64_t tim:1;
1704 uint64_t zip:1;
1705 uint64_t pko:1;
1706 uint64_t pip:1;
1707 uint64_t ipd:1;
1708 uint64_t l2c:1;
1709 uint64_t pow:1;
1710 uint64_t fpa:1;
1711 uint64_t iob:1;
1712 uint64_t mio:1;
1209 uint64_t nand:1; 1713 uint64_t nand:1;
1210 uint64_t mii1:1; 1714 uint64_t mii1:1;
1211 uint64_t usb1:1; 1715 uint64_t usb1:1;
@@ -1250,6 +1754,42 @@ union cvmx_ciu_int_sum1 {
1250 struct cvmx_ciu_int_sum1_cn56xx cn56xxp1; 1754 struct cvmx_ciu_int_sum1_cn56xx cn56xxp1;
1251 struct cvmx_ciu_int_sum1_cn38xx cn58xx; 1755 struct cvmx_ciu_int_sum1_cn38xx cn58xx;
1252 struct cvmx_ciu_int_sum1_cn38xx cn58xxp1; 1756 struct cvmx_ciu_int_sum1_cn38xx cn58xxp1;
1757 struct cvmx_ciu_int_sum1_cn63xx {
1758 uint64_t rst:1;
1759 uint64_t reserved_57_62:6;
1760 uint64_t dfm:1;
1761 uint64_t reserved_53_55:3;
1762 uint64_t lmc0:1;
1763 uint64_t srio1:1;
1764 uint64_t srio0:1;
1765 uint64_t pem1:1;
1766 uint64_t pem0:1;
1767 uint64_t ptp:1;
1768 uint64_t agl:1;
1769 uint64_t reserved_37_45:9;
1770 uint64_t agx0:1;
1771 uint64_t dpi:1;
1772 uint64_t sli:1;
1773 uint64_t usb:1;
1774 uint64_t dfa:1;
1775 uint64_t key:1;
1776 uint64_t rad:1;
1777 uint64_t tim:1;
1778 uint64_t zip:1;
1779 uint64_t pko:1;
1780 uint64_t pip:1;
1781 uint64_t ipd:1;
1782 uint64_t l2c:1;
1783 uint64_t pow:1;
1784 uint64_t fpa:1;
1785 uint64_t iob:1;
1786 uint64_t mio:1;
1787 uint64_t nand:1;
1788 uint64_t mii1:1;
1789 uint64_t reserved_6_17:12;
1790 uint64_t wdog:6;
1791 } cn63xx;
1792 struct cvmx_ciu_int_sum1_cn63xx cn63xxp1;
1253}; 1793};
1254 1794
1255union cvmx_ciu_mbox_clrx { 1795union cvmx_ciu_mbox_clrx {
@@ -1269,6 +1809,8 @@ union cvmx_ciu_mbox_clrx {
1269 struct cvmx_ciu_mbox_clrx_s cn56xxp1; 1809 struct cvmx_ciu_mbox_clrx_s cn56xxp1;
1270 struct cvmx_ciu_mbox_clrx_s cn58xx; 1810 struct cvmx_ciu_mbox_clrx_s cn58xx;
1271 struct cvmx_ciu_mbox_clrx_s cn58xxp1; 1811 struct cvmx_ciu_mbox_clrx_s cn58xxp1;
1812 struct cvmx_ciu_mbox_clrx_s cn63xx;
1813 struct cvmx_ciu_mbox_clrx_s cn63xxp1;
1272}; 1814};
1273 1815
1274union cvmx_ciu_mbox_setx { 1816union cvmx_ciu_mbox_setx {
@@ -1288,6 +1830,8 @@ union cvmx_ciu_mbox_setx {
1288 struct cvmx_ciu_mbox_setx_s cn56xxp1; 1830 struct cvmx_ciu_mbox_setx_s cn56xxp1;
1289 struct cvmx_ciu_mbox_setx_s cn58xx; 1831 struct cvmx_ciu_mbox_setx_s cn58xx;
1290 struct cvmx_ciu_mbox_setx_s cn58xxp1; 1832 struct cvmx_ciu_mbox_setx_s cn58xxp1;
1833 struct cvmx_ciu_mbox_setx_s cn63xx;
1834 struct cvmx_ciu_mbox_setx_s cn63xxp1;
1291}; 1835};
1292 1836
1293union cvmx_ciu_nmi { 1837union cvmx_ciu_nmi {
@@ -1319,6 +1863,11 @@ union cvmx_ciu_nmi {
1319 struct cvmx_ciu_nmi_cn56xx cn56xxp1; 1863 struct cvmx_ciu_nmi_cn56xx cn56xxp1;
1320 struct cvmx_ciu_nmi_s cn58xx; 1864 struct cvmx_ciu_nmi_s cn58xx;
1321 struct cvmx_ciu_nmi_s cn58xxp1; 1865 struct cvmx_ciu_nmi_s cn58xxp1;
1866 struct cvmx_ciu_nmi_cn63xx {
1867 uint64_t reserved_6_63:58;
1868 uint64_t nmi:6;
1869 } cn63xx;
1870 struct cvmx_ciu_nmi_cn63xx cn63xxp1;
1322}; 1871};
1323 1872
1324union cvmx_ciu_pci_inta { 1873union cvmx_ciu_pci_inta {
@@ -1338,6 +1887,8 @@ union cvmx_ciu_pci_inta {
1338 struct cvmx_ciu_pci_inta_s cn56xxp1; 1887 struct cvmx_ciu_pci_inta_s cn56xxp1;
1339 struct cvmx_ciu_pci_inta_s cn58xx; 1888 struct cvmx_ciu_pci_inta_s cn58xx;
1340 struct cvmx_ciu_pci_inta_s cn58xxp1; 1889 struct cvmx_ciu_pci_inta_s cn58xxp1;
1890 struct cvmx_ciu_pci_inta_s cn63xx;
1891 struct cvmx_ciu_pci_inta_s cn63xxp1;
1341}; 1892};
1342 1893
1343union cvmx_ciu_pp_dbg { 1894union cvmx_ciu_pp_dbg {
@@ -1369,12 +1920,17 @@ union cvmx_ciu_pp_dbg {
1369 struct cvmx_ciu_pp_dbg_cn56xx cn56xxp1; 1920 struct cvmx_ciu_pp_dbg_cn56xx cn56xxp1;
1370 struct cvmx_ciu_pp_dbg_s cn58xx; 1921 struct cvmx_ciu_pp_dbg_s cn58xx;
1371 struct cvmx_ciu_pp_dbg_s cn58xxp1; 1922 struct cvmx_ciu_pp_dbg_s cn58xxp1;
1923 struct cvmx_ciu_pp_dbg_cn63xx {
1924 uint64_t reserved_6_63:58;
1925 uint64_t ppdbg:6;
1926 } cn63xx;
1927 struct cvmx_ciu_pp_dbg_cn63xx cn63xxp1;
1372}; 1928};
1373 1929
1374union cvmx_ciu_pp_pokex { 1930union cvmx_ciu_pp_pokex {
1375 uint64_t u64; 1931 uint64_t u64;
1376 struct cvmx_ciu_pp_pokex_s { 1932 struct cvmx_ciu_pp_pokex_s {
1377 uint64_t reserved_0_63:64; 1933 uint64_t poke:64;
1378 } s; 1934 } s;
1379 struct cvmx_ciu_pp_pokex_s cn30xx; 1935 struct cvmx_ciu_pp_pokex_s cn30xx;
1380 struct cvmx_ciu_pp_pokex_s cn31xx; 1936 struct cvmx_ciu_pp_pokex_s cn31xx;
@@ -1387,6 +1943,8 @@ union cvmx_ciu_pp_pokex {
1387 struct cvmx_ciu_pp_pokex_s cn56xxp1; 1943 struct cvmx_ciu_pp_pokex_s cn56xxp1;
1388 struct cvmx_ciu_pp_pokex_s cn58xx; 1944 struct cvmx_ciu_pp_pokex_s cn58xx;
1389 struct cvmx_ciu_pp_pokex_s cn58xxp1; 1945 struct cvmx_ciu_pp_pokex_s cn58xxp1;
1946 struct cvmx_ciu_pp_pokex_s cn63xx;
1947 struct cvmx_ciu_pp_pokex_s cn63xxp1;
1390}; 1948};
1391 1949
1392union cvmx_ciu_pp_rst { 1950union cvmx_ciu_pp_rst {
@@ -1422,6 +1980,97 @@ union cvmx_ciu_pp_rst {
1422 struct cvmx_ciu_pp_rst_cn56xx cn56xxp1; 1980 struct cvmx_ciu_pp_rst_cn56xx cn56xxp1;
1423 struct cvmx_ciu_pp_rst_s cn58xx; 1981 struct cvmx_ciu_pp_rst_s cn58xx;
1424 struct cvmx_ciu_pp_rst_s cn58xxp1; 1982 struct cvmx_ciu_pp_rst_s cn58xxp1;
1983 struct cvmx_ciu_pp_rst_cn63xx {
1984 uint64_t reserved_6_63:58;
1985 uint64_t rst:5;
1986 uint64_t rst0:1;
1987 } cn63xx;
1988 struct cvmx_ciu_pp_rst_cn63xx cn63xxp1;
1989};
1990
1991union cvmx_ciu_qlm0 {
1992 uint64_t u64;
1993 struct cvmx_ciu_qlm0_s {
1994 uint64_t g2bypass:1;
1995 uint64_t reserved_53_62:10;
1996 uint64_t g2deemph:5;
1997 uint64_t reserved_45_47:3;
1998 uint64_t g2margin:5;
1999 uint64_t reserved_32_39:8;
2000 uint64_t txbypass:1;
2001 uint64_t reserved_21_30:10;
2002 uint64_t txdeemph:5;
2003 uint64_t reserved_13_15:3;
2004 uint64_t txmargin:5;
2005 uint64_t reserved_4_7:4;
2006 uint64_t lane_en:4;
2007 } s;
2008 struct cvmx_ciu_qlm0_s cn63xx;
2009 struct cvmx_ciu_qlm0_cn63xxp1 {
2010 uint64_t reserved_32_63:32;
2011 uint64_t txbypass:1;
2012 uint64_t reserved_20_30:11;
2013 uint64_t txdeemph:4;
2014 uint64_t reserved_13_15:3;
2015 uint64_t txmargin:5;
2016 uint64_t reserved_4_7:4;
2017 uint64_t lane_en:4;
2018 } cn63xxp1;
2019};
2020
2021union cvmx_ciu_qlm1 {
2022 uint64_t u64;
2023 struct cvmx_ciu_qlm1_s {
2024 uint64_t g2bypass:1;
2025 uint64_t reserved_53_62:10;
2026 uint64_t g2deemph:5;
2027 uint64_t reserved_45_47:3;
2028 uint64_t g2margin:5;
2029 uint64_t reserved_32_39:8;
2030 uint64_t txbypass:1;
2031 uint64_t reserved_21_30:10;
2032 uint64_t txdeemph:5;
2033 uint64_t reserved_13_15:3;
2034 uint64_t txmargin:5;
2035 uint64_t reserved_4_7:4;
2036 uint64_t lane_en:4;
2037 } s;
2038 struct cvmx_ciu_qlm1_s cn63xx;
2039 struct cvmx_ciu_qlm1_cn63xxp1 {
2040 uint64_t reserved_32_63:32;
2041 uint64_t txbypass:1;
2042 uint64_t reserved_20_30:11;
2043 uint64_t txdeemph:4;
2044 uint64_t reserved_13_15:3;
2045 uint64_t txmargin:5;
2046 uint64_t reserved_4_7:4;
2047 uint64_t lane_en:4;
2048 } cn63xxp1;
2049};
2050
2051union cvmx_ciu_qlm2 {
2052 uint64_t u64;
2053 struct cvmx_ciu_qlm2_s {
2054 uint64_t reserved_32_63:32;
2055 uint64_t txbypass:1;
2056 uint64_t reserved_21_30:10;
2057 uint64_t txdeemph:5;
2058 uint64_t reserved_13_15:3;
2059 uint64_t txmargin:5;
2060 uint64_t reserved_4_7:4;
2061 uint64_t lane_en:4;
2062 } s;
2063 struct cvmx_ciu_qlm2_s cn63xx;
2064 struct cvmx_ciu_qlm2_cn63xxp1 {
2065 uint64_t reserved_32_63:32;
2066 uint64_t txbypass:1;
2067 uint64_t reserved_20_30:11;
2068 uint64_t txdeemph:4;
2069 uint64_t reserved_13_15:3;
2070 uint64_t txmargin:5;
2071 uint64_t reserved_4_7:4;
2072 uint64_t lane_en:4;
2073 } cn63xxp1;
1425}; 2074};
1426 2075
1427union cvmx_ciu_qlm_dcok { 2076union cvmx_ciu_qlm_dcok {
@@ -1459,6 +2108,15 @@ union cvmx_ciu_qlm_jtgc {
1459 struct cvmx_ciu_qlm_jtgc_cn52xx cn52xxp1; 2108 struct cvmx_ciu_qlm_jtgc_cn52xx cn52xxp1;
1460 struct cvmx_ciu_qlm_jtgc_s cn56xx; 2109 struct cvmx_ciu_qlm_jtgc_s cn56xx;
1461 struct cvmx_ciu_qlm_jtgc_s cn56xxp1; 2110 struct cvmx_ciu_qlm_jtgc_s cn56xxp1;
2111 struct cvmx_ciu_qlm_jtgc_cn63xx {
2112 uint64_t reserved_11_63:53;
2113 uint64_t clk_div:3;
2114 uint64_t reserved_6_7:2;
2115 uint64_t mux_sel:2;
2116 uint64_t reserved_3_3:1;
2117 uint64_t bypass:3;
2118 } cn63xx;
2119 struct cvmx_ciu_qlm_jtgc_cn63xx cn63xxp1;
1462}; 2120};
1463 2121
1464union cvmx_ciu_qlm_jtgd { 2122union cvmx_ciu_qlm_jtgd {
@@ -1493,6 +2151,17 @@ union cvmx_ciu_qlm_jtgd {
1493 uint64_t shft_cnt:5; 2151 uint64_t shft_cnt:5;
1494 uint64_t shft_reg:32; 2152 uint64_t shft_reg:32;
1495 } cn56xxp1; 2153 } cn56xxp1;
2154 struct cvmx_ciu_qlm_jtgd_cn63xx {
2155 uint64_t capture:1;
2156 uint64_t shift:1;
2157 uint64_t update:1;
2158 uint64_t reserved_43_60:18;
2159 uint64_t select:3;
2160 uint64_t reserved_37_39:3;
2161 uint64_t shft_cnt:5;
2162 uint64_t shft_reg:32;
2163 } cn63xx;
2164 struct cvmx_ciu_qlm_jtgd_cn63xx cn63xxp1;
1496}; 2165};
1497 2166
1498union cvmx_ciu_soft_bist { 2167union cvmx_ciu_soft_bist {
@@ -1512,6 +2181,8 @@ union cvmx_ciu_soft_bist {
1512 struct cvmx_ciu_soft_bist_s cn56xxp1; 2181 struct cvmx_ciu_soft_bist_s cn56xxp1;
1513 struct cvmx_ciu_soft_bist_s cn58xx; 2182 struct cvmx_ciu_soft_bist_s cn58xx;
1514 struct cvmx_ciu_soft_bist_s cn58xxp1; 2183 struct cvmx_ciu_soft_bist_s cn58xxp1;
2184 struct cvmx_ciu_soft_bist_s cn63xx;
2185 struct cvmx_ciu_soft_bist_s cn63xxp1;
1515}; 2186};
1516 2187
1517union cvmx_ciu_soft_prst { 2188union cvmx_ciu_soft_prst {
@@ -1536,6 +2207,8 @@ union cvmx_ciu_soft_prst {
1536 struct cvmx_ciu_soft_prst_cn52xx cn56xxp1; 2207 struct cvmx_ciu_soft_prst_cn52xx cn56xxp1;
1537 struct cvmx_ciu_soft_prst_s cn58xx; 2208 struct cvmx_ciu_soft_prst_s cn58xx;
1538 struct cvmx_ciu_soft_prst_s cn58xxp1; 2209 struct cvmx_ciu_soft_prst_s cn58xxp1;
2210 struct cvmx_ciu_soft_prst_cn52xx cn63xx;
2211 struct cvmx_ciu_soft_prst_cn52xx cn63xxp1;
1539}; 2212};
1540 2213
1541union cvmx_ciu_soft_prst1 { 2214union cvmx_ciu_soft_prst1 {
@@ -1548,6 +2221,8 @@ union cvmx_ciu_soft_prst1 {
1548 struct cvmx_ciu_soft_prst1_s cn52xxp1; 2221 struct cvmx_ciu_soft_prst1_s cn52xxp1;
1549 struct cvmx_ciu_soft_prst1_s cn56xx; 2222 struct cvmx_ciu_soft_prst1_s cn56xx;
1550 struct cvmx_ciu_soft_prst1_s cn56xxp1; 2223 struct cvmx_ciu_soft_prst1_s cn56xxp1;
2224 struct cvmx_ciu_soft_prst1_s cn63xx;
2225 struct cvmx_ciu_soft_prst1_s cn63xxp1;
1551}; 2226};
1552 2227
1553union cvmx_ciu_soft_rst { 2228union cvmx_ciu_soft_rst {
@@ -1567,6 +2242,8 @@ union cvmx_ciu_soft_rst {
1567 struct cvmx_ciu_soft_rst_s cn56xxp1; 2242 struct cvmx_ciu_soft_rst_s cn56xxp1;
1568 struct cvmx_ciu_soft_rst_s cn58xx; 2243 struct cvmx_ciu_soft_rst_s cn58xx;
1569 struct cvmx_ciu_soft_rst_s cn58xxp1; 2244 struct cvmx_ciu_soft_rst_s cn58xxp1;
2245 struct cvmx_ciu_soft_rst_s cn63xx;
2246 struct cvmx_ciu_soft_rst_s cn63xxp1;
1570}; 2247};
1571 2248
1572union cvmx_ciu_timx { 2249union cvmx_ciu_timx {
@@ -1587,6 +2264,8 @@ union cvmx_ciu_timx {
1587 struct cvmx_ciu_timx_s cn56xxp1; 2264 struct cvmx_ciu_timx_s cn56xxp1;
1588 struct cvmx_ciu_timx_s cn58xx; 2265 struct cvmx_ciu_timx_s cn58xx;
1589 struct cvmx_ciu_timx_s cn58xxp1; 2266 struct cvmx_ciu_timx_s cn58xxp1;
2267 struct cvmx_ciu_timx_s cn63xx;
2268 struct cvmx_ciu_timx_s cn63xxp1;
1590}; 2269};
1591 2270
1592union cvmx_ciu_wdogx { 2271union cvmx_ciu_wdogx {
@@ -1611,6 +2290,8 @@ union cvmx_ciu_wdogx {
1611 struct cvmx_ciu_wdogx_s cn56xxp1; 2290 struct cvmx_ciu_wdogx_s cn56xxp1;
1612 struct cvmx_ciu_wdogx_s cn58xx; 2291 struct cvmx_ciu_wdogx_s cn58xx;
1613 struct cvmx_ciu_wdogx_s cn58xxp1; 2292 struct cvmx_ciu_wdogx_s cn58xxp1;
2293 struct cvmx_ciu_wdogx_s cn63xx;
2294 struct cvmx_ciu_wdogx_s cn63xxp1;
1614}; 2295};
1615 2296
1616#endif 2297#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-gpio-defs.h b/arch/mips/include/asm/octeon/cvmx-gpio-defs.h
index 5fdd6ba48a05..395564e8d1f0 100644
--- a/arch/mips/include/asm/octeon/cvmx-gpio-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-gpio-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,29 +28,22 @@
28#ifndef __CVMX_GPIO_DEFS_H__ 28#ifndef __CVMX_GPIO_DEFS_H__
29#define __CVMX_GPIO_DEFS_H__ 29#define __CVMX_GPIO_DEFS_H__
30 30
31#define CVMX_GPIO_BIT_CFGX(offset) \ 31#define CVMX_GPIO_BIT_CFGX(offset) (CVMX_ADD_IO_SEG(0x0001070000000800ull) + ((offset) & 15) * 8)
32 CVMX_ADD_IO_SEG(0x0001070000000800ull + (((offset) & 15) * 8)) 32#define CVMX_GPIO_BOOT_ENA (CVMX_ADD_IO_SEG(0x00010700000008A8ull))
33#define CVMX_GPIO_BOOT_ENA \ 33#define CVMX_GPIO_CLK_GENX(offset) (CVMX_ADD_IO_SEG(0x00010700000008C0ull) + ((offset) & 3) * 8)
34 CVMX_ADD_IO_SEG(0x00010700000008A8ull) 34#define CVMX_GPIO_CLK_QLMX(offset) (CVMX_ADD_IO_SEG(0x00010700000008E0ull) + ((offset) & 1) * 8)
35#define CVMX_GPIO_CLK_GENX(offset) \ 35#define CVMX_GPIO_DBG_ENA (CVMX_ADD_IO_SEG(0x00010700000008A0ull))
36 CVMX_ADD_IO_SEG(0x00010700000008C0ull + (((offset) & 3) * 8)) 36#define CVMX_GPIO_INT_CLR (CVMX_ADD_IO_SEG(0x0001070000000898ull))
37#define CVMX_GPIO_DBG_ENA \ 37#define CVMX_GPIO_RX_DAT (CVMX_ADD_IO_SEG(0x0001070000000880ull))
38 CVMX_ADD_IO_SEG(0x00010700000008A0ull) 38#define CVMX_GPIO_TX_CLR (CVMX_ADD_IO_SEG(0x0001070000000890ull))
39#define CVMX_GPIO_INT_CLR \ 39#define CVMX_GPIO_TX_SET (CVMX_ADD_IO_SEG(0x0001070000000888ull))
40 CVMX_ADD_IO_SEG(0x0001070000000898ull) 40#define CVMX_GPIO_XBIT_CFGX(offset) (CVMX_ADD_IO_SEG(0x0001070000000900ull) + ((offset) & 31) * 8 - 8*16)
41#define CVMX_GPIO_RX_DAT \
42 CVMX_ADD_IO_SEG(0x0001070000000880ull)
43#define CVMX_GPIO_TX_CLR \
44 CVMX_ADD_IO_SEG(0x0001070000000890ull)
45#define CVMX_GPIO_TX_SET \
46 CVMX_ADD_IO_SEG(0x0001070000000888ull)
47#define CVMX_GPIO_XBIT_CFGX(offset) \
48 CVMX_ADD_IO_SEG(0x0001070000000900ull + (((offset) & 31) * 8) - 8 * 16)
49 41
50union cvmx_gpio_bit_cfgx { 42union cvmx_gpio_bit_cfgx {
51 uint64_t u64; 43 uint64_t u64;
52 struct cvmx_gpio_bit_cfgx_s { 44 struct cvmx_gpio_bit_cfgx_s {
53 uint64_t reserved_15_63:49; 45 uint64_t reserved_17_63:47;
46 uint64_t synce_sel:2;
54 uint64_t clk_gen:1; 47 uint64_t clk_gen:1;
55 uint64_t clk_sel:2; 48 uint64_t clk_sel:2;
56 uint64_t fil_sel:4; 49 uint64_t fil_sel:4;
@@ -73,12 +66,24 @@ union cvmx_gpio_bit_cfgx {
73 struct cvmx_gpio_bit_cfgx_cn30xx cn38xx; 66 struct cvmx_gpio_bit_cfgx_cn30xx cn38xx;
74 struct cvmx_gpio_bit_cfgx_cn30xx cn38xxp2; 67 struct cvmx_gpio_bit_cfgx_cn30xx cn38xxp2;
75 struct cvmx_gpio_bit_cfgx_cn30xx cn50xx; 68 struct cvmx_gpio_bit_cfgx_cn30xx cn50xx;
76 struct cvmx_gpio_bit_cfgx_s cn52xx; 69 struct cvmx_gpio_bit_cfgx_cn52xx {
77 struct cvmx_gpio_bit_cfgx_s cn52xxp1; 70 uint64_t reserved_15_63:49;
78 struct cvmx_gpio_bit_cfgx_s cn56xx; 71 uint64_t clk_gen:1;
79 struct cvmx_gpio_bit_cfgx_s cn56xxp1; 72 uint64_t clk_sel:2;
73 uint64_t fil_sel:4;
74 uint64_t fil_cnt:4;
75 uint64_t int_type:1;
76 uint64_t int_en:1;
77 uint64_t rx_xor:1;
78 uint64_t tx_oe:1;
79 } cn52xx;
80 struct cvmx_gpio_bit_cfgx_cn52xx cn52xxp1;
81 struct cvmx_gpio_bit_cfgx_cn52xx cn56xx;
82 struct cvmx_gpio_bit_cfgx_cn52xx cn56xxp1;
80 struct cvmx_gpio_bit_cfgx_cn30xx cn58xx; 83 struct cvmx_gpio_bit_cfgx_cn30xx cn58xx;
81 struct cvmx_gpio_bit_cfgx_cn30xx cn58xxp1; 84 struct cvmx_gpio_bit_cfgx_cn30xx cn58xxp1;
85 struct cvmx_gpio_bit_cfgx_s cn63xx;
86 struct cvmx_gpio_bit_cfgx_s cn63xxp1;
82}; 87};
83 88
84union cvmx_gpio_boot_ena { 89union cvmx_gpio_boot_ena {
@@ -103,6 +108,19 @@ union cvmx_gpio_clk_genx {
103 struct cvmx_gpio_clk_genx_s cn52xxp1; 108 struct cvmx_gpio_clk_genx_s cn52xxp1;
104 struct cvmx_gpio_clk_genx_s cn56xx; 109 struct cvmx_gpio_clk_genx_s cn56xx;
105 struct cvmx_gpio_clk_genx_s cn56xxp1; 110 struct cvmx_gpio_clk_genx_s cn56xxp1;
111 struct cvmx_gpio_clk_genx_s cn63xx;
112 struct cvmx_gpio_clk_genx_s cn63xxp1;
113};
114
115union cvmx_gpio_clk_qlmx {
116 uint64_t u64;
117 struct cvmx_gpio_clk_qlmx_s {
118 uint64_t reserved_3_63:61;
119 uint64_t div:1;
120 uint64_t lane_sel:2;
121 } s;
122 struct cvmx_gpio_clk_qlmx_s cn63xx;
123 struct cvmx_gpio_clk_qlmx_s cn63xxp1;
106}; 124};
107 125
108union cvmx_gpio_dbg_ena { 126union cvmx_gpio_dbg_ena {
@@ -133,6 +151,8 @@ union cvmx_gpio_int_clr {
133 struct cvmx_gpio_int_clr_s cn56xxp1; 151 struct cvmx_gpio_int_clr_s cn56xxp1;
134 struct cvmx_gpio_int_clr_s cn58xx; 152 struct cvmx_gpio_int_clr_s cn58xx;
135 struct cvmx_gpio_int_clr_s cn58xxp1; 153 struct cvmx_gpio_int_clr_s cn58xxp1;
154 struct cvmx_gpio_int_clr_s cn63xx;
155 struct cvmx_gpio_int_clr_s cn63xxp1;
136}; 156};
137 157
138union cvmx_gpio_rx_dat { 158union cvmx_gpio_rx_dat {
@@ -155,6 +175,8 @@ union cvmx_gpio_rx_dat {
155 struct cvmx_gpio_rx_dat_cn38xx cn56xxp1; 175 struct cvmx_gpio_rx_dat_cn38xx cn56xxp1;
156 struct cvmx_gpio_rx_dat_cn38xx cn58xx; 176 struct cvmx_gpio_rx_dat_cn38xx cn58xx;
157 struct cvmx_gpio_rx_dat_cn38xx cn58xxp1; 177 struct cvmx_gpio_rx_dat_cn38xx cn58xxp1;
178 struct cvmx_gpio_rx_dat_cn38xx cn63xx;
179 struct cvmx_gpio_rx_dat_cn38xx cn63xxp1;
158}; 180};
159 181
160union cvmx_gpio_tx_clr { 182union cvmx_gpio_tx_clr {
@@ -177,6 +199,8 @@ union cvmx_gpio_tx_clr {
177 struct cvmx_gpio_tx_clr_cn38xx cn56xxp1; 199 struct cvmx_gpio_tx_clr_cn38xx cn56xxp1;
178 struct cvmx_gpio_tx_clr_cn38xx cn58xx; 200 struct cvmx_gpio_tx_clr_cn38xx cn58xx;
179 struct cvmx_gpio_tx_clr_cn38xx cn58xxp1; 201 struct cvmx_gpio_tx_clr_cn38xx cn58xxp1;
202 struct cvmx_gpio_tx_clr_cn38xx cn63xx;
203 struct cvmx_gpio_tx_clr_cn38xx cn63xxp1;
180}; 204};
181 205
182union cvmx_gpio_tx_set { 206union cvmx_gpio_tx_set {
@@ -199,6 +223,8 @@ union cvmx_gpio_tx_set {
199 struct cvmx_gpio_tx_set_cn38xx cn56xxp1; 223 struct cvmx_gpio_tx_set_cn38xx cn56xxp1;
200 struct cvmx_gpio_tx_set_cn38xx cn58xx; 224 struct cvmx_gpio_tx_set_cn38xx cn58xx;
201 struct cvmx_gpio_tx_set_cn38xx cn58xxp1; 225 struct cvmx_gpio_tx_set_cn38xx cn58xxp1;
226 struct cvmx_gpio_tx_set_cn38xx cn63xx;
227 struct cvmx_gpio_tx_set_cn38xx cn63xxp1;
202}; 228};
203 229
204union cvmx_gpio_xbit_cfgx { 230union cvmx_gpio_xbit_cfgx {
diff --git a/arch/mips/include/asm/octeon/cvmx-iob-defs.h b/arch/mips/include/asm/octeon/cvmx-iob-defs.h
index 0ee36baec500..d7d856c2483d 100644
--- a/arch/mips/include/asm/octeon/cvmx-iob-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-iob-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,55 +28,39 @@
28#ifndef __CVMX_IOB_DEFS_H__ 28#ifndef __CVMX_IOB_DEFS_H__
29#define __CVMX_IOB_DEFS_H__ 29#define __CVMX_IOB_DEFS_H__
30 30
31#define CVMX_IOB_BIST_STATUS \ 31#define CVMX_IOB_BIST_STATUS (CVMX_ADD_IO_SEG(0x00011800F00007F8ull))
32 CVMX_ADD_IO_SEG(0x00011800F00007F8ull) 32#define CVMX_IOB_CTL_STATUS (CVMX_ADD_IO_SEG(0x00011800F0000050ull))
33#define CVMX_IOB_CTL_STATUS \ 33#define CVMX_IOB_DWB_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000028ull))
34 CVMX_ADD_IO_SEG(0x00011800F0000050ull) 34#define CVMX_IOB_FAU_TIMEOUT (CVMX_ADD_IO_SEG(0x00011800F0000000ull))
35#define CVMX_IOB_DWB_PRI_CNT \ 35#define CVMX_IOB_I2C_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000010ull))
36 CVMX_ADD_IO_SEG(0x00011800F0000028ull) 36#define CVMX_IOB_INB_CONTROL_MATCH (CVMX_ADD_IO_SEG(0x00011800F0000078ull))
37#define CVMX_IOB_FAU_TIMEOUT \ 37#define CVMX_IOB_INB_CONTROL_MATCH_ENB (CVMX_ADD_IO_SEG(0x00011800F0000088ull))
38 CVMX_ADD_IO_SEG(0x00011800F0000000ull) 38#define CVMX_IOB_INB_DATA_MATCH (CVMX_ADD_IO_SEG(0x00011800F0000070ull))
39#define CVMX_IOB_I2C_PRI_CNT \ 39#define CVMX_IOB_INB_DATA_MATCH_ENB (CVMX_ADD_IO_SEG(0x00011800F0000080ull))
40 CVMX_ADD_IO_SEG(0x00011800F0000010ull) 40#define CVMX_IOB_INT_ENB (CVMX_ADD_IO_SEG(0x00011800F0000060ull))
41#define CVMX_IOB_INB_CONTROL_MATCH \ 41#define CVMX_IOB_INT_SUM (CVMX_ADD_IO_SEG(0x00011800F0000058ull))
42 CVMX_ADD_IO_SEG(0x00011800F0000078ull) 42#define CVMX_IOB_N2C_L2C_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000020ull))
43#define CVMX_IOB_INB_CONTROL_MATCH_ENB \ 43#define CVMX_IOB_N2C_RSP_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000008ull))
44 CVMX_ADD_IO_SEG(0x00011800F0000088ull) 44#define CVMX_IOB_OUTB_COM_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000040ull))
45#define CVMX_IOB_INB_DATA_MATCH \ 45#define CVMX_IOB_OUTB_CONTROL_MATCH (CVMX_ADD_IO_SEG(0x00011800F0000098ull))
46 CVMX_ADD_IO_SEG(0x00011800F0000070ull) 46#define CVMX_IOB_OUTB_CONTROL_MATCH_ENB (CVMX_ADD_IO_SEG(0x00011800F00000A8ull))
47#define CVMX_IOB_INB_DATA_MATCH_ENB \ 47#define CVMX_IOB_OUTB_DATA_MATCH (CVMX_ADD_IO_SEG(0x00011800F0000090ull))
48 CVMX_ADD_IO_SEG(0x00011800F0000080ull) 48#define CVMX_IOB_OUTB_DATA_MATCH_ENB (CVMX_ADD_IO_SEG(0x00011800F00000A0ull))
49#define CVMX_IOB_INT_ENB \ 49#define CVMX_IOB_OUTB_FPA_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000048ull))
50 CVMX_ADD_IO_SEG(0x00011800F0000060ull) 50#define CVMX_IOB_OUTB_REQ_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000038ull))
51#define CVMX_IOB_INT_SUM \ 51#define CVMX_IOB_P2C_REQ_PRI_CNT (CVMX_ADD_IO_SEG(0x00011800F0000018ull))
52 CVMX_ADD_IO_SEG(0x00011800F0000058ull) 52#define CVMX_IOB_PKT_ERR (CVMX_ADD_IO_SEG(0x00011800F0000068ull))
53#define CVMX_IOB_N2C_L2C_PRI_CNT \ 53#define CVMX_IOB_TO_CMB_CREDITS (CVMX_ADD_IO_SEG(0x00011800F00000B0ull))
54 CVMX_ADD_IO_SEG(0x00011800F0000020ull)
55#define CVMX_IOB_N2C_RSP_PRI_CNT \
56 CVMX_ADD_IO_SEG(0x00011800F0000008ull)
57#define CVMX_IOB_OUTB_COM_PRI_CNT \
58 CVMX_ADD_IO_SEG(0x00011800F0000040ull)
59#define CVMX_IOB_OUTB_CONTROL_MATCH \
60 CVMX_ADD_IO_SEG(0x00011800F0000098ull)
61#define CVMX_IOB_OUTB_CONTROL_MATCH_ENB \
62 CVMX_ADD_IO_SEG(0x00011800F00000A8ull)
63#define CVMX_IOB_OUTB_DATA_MATCH \
64 CVMX_ADD_IO_SEG(0x00011800F0000090ull)
65#define CVMX_IOB_OUTB_DATA_MATCH_ENB \
66 CVMX_ADD_IO_SEG(0x00011800F00000A0ull)
67#define CVMX_IOB_OUTB_FPA_PRI_CNT \
68 CVMX_ADD_IO_SEG(0x00011800F0000048ull)
69#define CVMX_IOB_OUTB_REQ_PRI_CNT \
70 CVMX_ADD_IO_SEG(0x00011800F0000038ull)
71#define CVMX_IOB_P2C_REQ_PRI_CNT \
72 CVMX_ADD_IO_SEG(0x00011800F0000018ull)
73#define CVMX_IOB_PKT_ERR \
74 CVMX_ADD_IO_SEG(0x00011800F0000068ull)
75 54
76union cvmx_iob_bist_status { 55union cvmx_iob_bist_status {
77 uint64_t u64; 56 uint64_t u64;
78 struct cvmx_iob_bist_status_s { 57 struct cvmx_iob_bist_status_s {
79 uint64_t reserved_18_63:46; 58 uint64_t reserved_23_63:41;
59 uint64_t xmdfif:1;
60 uint64_t xmcfif:1;
61 uint64_t iorfif:1;
62 uint64_t rsdfif:1;
63 uint64_t iocfif:1;
80 uint64_t icnrcb:1; 64 uint64_t icnrcb:1;
81 uint64_t icr0:1; 65 uint64_t icr0:1;
82 uint64_t icr1:1; 66 uint64_t icr1:1;
@@ -96,40 +80,81 @@ union cvmx_iob_bist_status {
96 uint64_t ibd:1; 80 uint64_t ibd:1;
97 uint64_t icd:1; 81 uint64_t icd:1;
98 } s; 82 } s;
99 struct cvmx_iob_bist_status_s cn30xx; 83 struct cvmx_iob_bist_status_cn30xx {
100 struct cvmx_iob_bist_status_s cn31xx; 84 uint64_t reserved_18_63:46;
101 struct cvmx_iob_bist_status_s cn38xx; 85 uint64_t icnrcb:1;
102 struct cvmx_iob_bist_status_s cn38xxp2; 86 uint64_t icr0:1;
103 struct cvmx_iob_bist_status_s cn50xx; 87 uint64_t icr1:1;
104 struct cvmx_iob_bist_status_s cn52xx; 88 uint64_t icnr1:1;
105 struct cvmx_iob_bist_status_s cn52xxp1; 89 uint64_t icnr0:1;
106 struct cvmx_iob_bist_status_s cn56xx; 90 uint64_t ibdr0:1;
107 struct cvmx_iob_bist_status_s cn56xxp1; 91 uint64_t ibdr1:1;
108 struct cvmx_iob_bist_status_s cn58xx; 92 uint64_t ibr0:1;
109 struct cvmx_iob_bist_status_s cn58xxp1; 93 uint64_t ibr1:1;
94 uint64_t icnrt:1;
95 uint64_t ibrq0:1;
96 uint64_t ibrq1:1;
97 uint64_t icrn0:1;
98 uint64_t icrn1:1;
99 uint64_t icrp0:1;
100 uint64_t icrp1:1;
101 uint64_t ibd:1;
102 uint64_t icd:1;
103 } cn30xx;
104 struct cvmx_iob_bist_status_cn30xx cn31xx;
105 struct cvmx_iob_bist_status_cn30xx cn38xx;
106 struct cvmx_iob_bist_status_cn30xx cn38xxp2;
107 struct cvmx_iob_bist_status_cn30xx cn50xx;
108 struct cvmx_iob_bist_status_cn30xx cn52xx;
109 struct cvmx_iob_bist_status_cn30xx cn52xxp1;
110 struct cvmx_iob_bist_status_cn30xx cn56xx;
111 struct cvmx_iob_bist_status_cn30xx cn56xxp1;
112 struct cvmx_iob_bist_status_cn30xx cn58xx;
113 struct cvmx_iob_bist_status_cn30xx cn58xxp1;
114 struct cvmx_iob_bist_status_s cn63xx;
115 struct cvmx_iob_bist_status_s cn63xxp1;
110}; 116};
111 117
112union cvmx_iob_ctl_status { 118union cvmx_iob_ctl_status {
113 uint64_t u64; 119 uint64_t u64;
114 struct cvmx_iob_ctl_status_s { 120 struct cvmx_iob_ctl_status_s {
115 uint64_t reserved_5_63:59; 121 uint64_t reserved_10_63:54;
122 uint64_t xmc_per:4;
123 uint64_t rr_mode:1;
116 uint64_t outb_mat:1; 124 uint64_t outb_mat:1;
117 uint64_t inb_mat:1; 125 uint64_t inb_mat:1;
118 uint64_t pko_enb:1; 126 uint64_t pko_enb:1;
119 uint64_t dwb_enb:1; 127 uint64_t dwb_enb:1;
120 uint64_t fau_end:1; 128 uint64_t fau_end:1;
121 } s; 129 } s;
122 struct cvmx_iob_ctl_status_s cn30xx; 130 struct cvmx_iob_ctl_status_cn30xx {
123 struct cvmx_iob_ctl_status_s cn31xx; 131 uint64_t reserved_5_63:59;
124 struct cvmx_iob_ctl_status_s cn38xx; 132 uint64_t outb_mat:1;
125 struct cvmx_iob_ctl_status_s cn38xxp2; 133 uint64_t inb_mat:1;
126 struct cvmx_iob_ctl_status_s cn50xx; 134 uint64_t pko_enb:1;
127 struct cvmx_iob_ctl_status_s cn52xx; 135 uint64_t dwb_enb:1;
128 struct cvmx_iob_ctl_status_s cn52xxp1; 136 uint64_t fau_end:1;
129 struct cvmx_iob_ctl_status_s cn56xx; 137 } cn30xx;
130 struct cvmx_iob_ctl_status_s cn56xxp1; 138 struct cvmx_iob_ctl_status_cn30xx cn31xx;
131 struct cvmx_iob_ctl_status_s cn58xx; 139 struct cvmx_iob_ctl_status_cn30xx cn38xx;
132 struct cvmx_iob_ctl_status_s cn58xxp1; 140 struct cvmx_iob_ctl_status_cn30xx cn38xxp2;
141 struct cvmx_iob_ctl_status_cn30xx cn50xx;
142 struct cvmx_iob_ctl_status_cn52xx {
143 uint64_t reserved_6_63:58;
144 uint64_t rr_mode:1;
145 uint64_t outb_mat:1;
146 uint64_t inb_mat:1;
147 uint64_t pko_enb:1;
148 uint64_t dwb_enb:1;
149 uint64_t fau_end:1;
150 } cn52xx;
151 struct cvmx_iob_ctl_status_cn30xx cn52xxp1;
152 struct cvmx_iob_ctl_status_cn30xx cn56xx;
153 struct cvmx_iob_ctl_status_cn30xx cn56xxp1;
154 struct cvmx_iob_ctl_status_cn30xx cn58xx;
155 struct cvmx_iob_ctl_status_cn30xx cn58xxp1;
156 struct cvmx_iob_ctl_status_s cn63xx;
157 struct cvmx_iob_ctl_status_s cn63xxp1;
133}; 158};
134 159
135union cvmx_iob_dwb_pri_cnt { 160union cvmx_iob_dwb_pri_cnt {
@@ -147,6 +172,8 @@ union cvmx_iob_dwb_pri_cnt {
147 struct cvmx_iob_dwb_pri_cnt_s cn56xxp1; 172 struct cvmx_iob_dwb_pri_cnt_s cn56xxp1;
148 struct cvmx_iob_dwb_pri_cnt_s cn58xx; 173 struct cvmx_iob_dwb_pri_cnt_s cn58xx;
149 struct cvmx_iob_dwb_pri_cnt_s cn58xxp1; 174 struct cvmx_iob_dwb_pri_cnt_s cn58xxp1;
175 struct cvmx_iob_dwb_pri_cnt_s cn63xx;
176 struct cvmx_iob_dwb_pri_cnt_s cn63xxp1;
150}; 177};
151 178
152union cvmx_iob_fau_timeout { 179union cvmx_iob_fau_timeout {
@@ -167,6 +194,8 @@ union cvmx_iob_fau_timeout {
167 struct cvmx_iob_fau_timeout_s cn56xxp1; 194 struct cvmx_iob_fau_timeout_s cn56xxp1;
168 struct cvmx_iob_fau_timeout_s cn58xx; 195 struct cvmx_iob_fau_timeout_s cn58xx;
169 struct cvmx_iob_fau_timeout_s cn58xxp1; 196 struct cvmx_iob_fau_timeout_s cn58xxp1;
197 struct cvmx_iob_fau_timeout_s cn63xx;
198 struct cvmx_iob_fau_timeout_s cn63xxp1;
170}; 199};
171 200
172union cvmx_iob_i2c_pri_cnt { 201union cvmx_iob_i2c_pri_cnt {
@@ -184,6 +213,8 @@ union cvmx_iob_i2c_pri_cnt {
184 struct cvmx_iob_i2c_pri_cnt_s cn56xxp1; 213 struct cvmx_iob_i2c_pri_cnt_s cn56xxp1;
185 struct cvmx_iob_i2c_pri_cnt_s cn58xx; 214 struct cvmx_iob_i2c_pri_cnt_s cn58xx;
186 struct cvmx_iob_i2c_pri_cnt_s cn58xxp1; 215 struct cvmx_iob_i2c_pri_cnt_s cn58xxp1;
216 struct cvmx_iob_i2c_pri_cnt_s cn63xx;
217 struct cvmx_iob_i2c_pri_cnt_s cn63xxp1;
187}; 218};
188 219
189union cvmx_iob_inb_control_match { 220union cvmx_iob_inb_control_match {
@@ -206,6 +237,8 @@ union cvmx_iob_inb_control_match {
206 struct cvmx_iob_inb_control_match_s cn56xxp1; 237 struct cvmx_iob_inb_control_match_s cn56xxp1;
207 struct cvmx_iob_inb_control_match_s cn58xx; 238 struct cvmx_iob_inb_control_match_s cn58xx;
208 struct cvmx_iob_inb_control_match_s cn58xxp1; 239 struct cvmx_iob_inb_control_match_s cn58xxp1;
240 struct cvmx_iob_inb_control_match_s cn63xx;
241 struct cvmx_iob_inb_control_match_s cn63xxp1;
209}; 242};
210 243
211union cvmx_iob_inb_control_match_enb { 244union cvmx_iob_inb_control_match_enb {
@@ -228,6 +261,8 @@ union cvmx_iob_inb_control_match_enb {
228 struct cvmx_iob_inb_control_match_enb_s cn56xxp1; 261 struct cvmx_iob_inb_control_match_enb_s cn56xxp1;
229 struct cvmx_iob_inb_control_match_enb_s cn58xx; 262 struct cvmx_iob_inb_control_match_enb_s cn58xx;
230 struct cvmx_iob_inb_control_match_enb_s cn58xxp1; 263 struct cvmx_iob_inb_control_match_enb_s cn58xxp1;
264 struct cvmx_iob_inb_control_match_enb_s cn63xx;
265 struct cvmx_iob_inb_control_match_enb_s cn63xxp1;
231}; 266};
232 267
233union cvmx_iob_inb_data_match { 268union cvmx_iob_inb_data_match {
@@ -246,6 +281,8 @@ union cvmx_iob_inb_data_match {
246 struct cvmx_iob_inb_data_match_s cn56xxp1; 281 struct cvmx_iob_inb_data_match_s cn56xxp1;
247 struct cvmx_iob_inb_data_match_s cn58xx; 282 struct cvmx_iob_inb_data_match_s cn58xx;
248 struct cvmx_iob_inb_data_match_s cn58xxp1; 283 struct cvmx_iob_inb_data_match_s cn58xxp1;
284 struct cvmx_iob_inb_data_match_s cn63xx;
285 struct cvmx_iob_inb_data_match_s cn63xxp1;
249}; 286};
250 287
251union cvmx_iob_inb_data_match_enb { 288union cvmx_iob_inb_data_match_enb {
@@ -264,6 +301,8 @@ union cvmx_iob_inb_data_match_enb {
264 struct cvmx_iob_inb_data_match_enb_s cn56xxp1; 301 struct cvmx_iob_inb_data_match_enb_s cn56xxp1;
265 struct cvmx_iob_inb_data_match_enb_s cn58xx; 302 struct cvmx_iob_inb_data_match_enb_s cn58xx;
266 struct cvmx_iob_inb_data_match_enb_s cn58xxp1; 303 struct cvmx_iob_inb_data_match_enb_s cn58xxp1;
304 struct cvmx_iob_inb_data_match_enb_s cn63xx;
305 struct cvmx_iob_inb_data_match_enb_s cn63xxp1;
267}; 306};
268 307
269union cvmx_iob_int_enb { 308union cvmx_iob_int_enb {
@@ -294,6 +333,8 @@ union cvmx_iob_int_enb {
294 struct cvmx_iob_int_enb_s cn56xxp1; 333 struct cvmx_iob_int_enb_s cn56xxp1;
295 struct cvmx_iob_int_enb_s cn58xx; 334 struct cvmx_iob_int_enb_s cn58xx;
296 struct cvmx_iob_int_enb_s cn58xxp1; 335 struct cvmx_iob_int_enb_s cn58xxp1;
336 struct cvmx_iob_int_enb_s cn63xx;
337 struct cvmx_iob_int_enb_s cn63xxp1;
297}; 338};
298 339
299union cvmx_iob_int_sum { 340union cvmx_iob_int_sum {
@@ -324,6 +365,8 @@ union cvmx_iob_int_sum {
324 struct cvmx_iob_int_sum_s cn56xxp1; 365 struct cvmx_iob_int_sum_s cn56xxp1;
325 struct cvmx_iob_int_sum_s cn58xx; 366 struct cvmx_iob_int_sum_s cn58xx;
326 struct cvmx_iob_int_sum_s cn58xxp1; 367 struct cvmx_iob_int_sum_s cn58xxp1;
368 struct cvmx_iob_int_sum_s cn63xx;
369 struct cvmx_iob_int_sum_s cn63xxp1;
327}; 370};
328 371
329union cvmx_iob_n2c_l2c_pri_cnt { 372union cvmx_iob_n2c_l2c_pri_cnt {
@@ -341,6 +384,8 @@ union cvmx_iob_n2c_l2c_pri_cnt {
341 struct cvmx_iob_n2c_l2c_pri_cnt_s cn56xxp1; 384 struct cvmx_iob_n2c_l2c_pri_cnt_s cn56xxp1;
342 struct cvmx_iob_n2c_l2c_pri_cnt_s cn58xx; 385 struct cvmx_iob_n2c_l2c_pri_cnt_s cn58xx;
343 struct cvmx_iob_n2c_l2c_pri_cnt_s cn58xxp1; 386 struct cvmx_iob_n2c_l2c_pri_cnt_s cn58xxp1;
387 struct cvmx_iob_n2c_l2c_pri_cnt_s cn63xx;
388 struct cvmx_iob_n2c_l2c_pri_cnt_s cn63xxp1;
344}; 389};
345 390
346union cvmx_iob_n2c_rsp_pri_cnt { 391union cvmx_iob_n2c_rsp_pri_cnt {
@@ -358,6 +403,8 @@ union cvmx_iob_n2c_rsp_pri_cnt {
358 struct cvmx_iob_n2c_rsp_pri_cnt_s cn56xxp1; 403 struct cvmx_iob_n2c_rsp_pri_cnt_s cn56xxp1;
359 struct cvmx_iob_n2c_rsp_pri_cnt_s cn58xx; 404 struct cvmx_iob_n2c_rsp_pri_cnt_s cn58xx;
360 struct cvmx_iob_n2c_rsp_pri_cnt_s cn58xxp1; 405 struct cvmx_iob_n2c_rsp_pri_cnt_s cn58xxp1;
406 struct cvmx_iob_n2c_rsp_pri_cnt_s cn63xx;
407 struct cvmx_iob_n2c_rsp_pri_cnt_s cn63xxp1;
361}; 408};
362 409
363union cvmx_iob_outb_com_pri_cnt { 410union cvmx_iob_outb_com_pri_cnt {
@@ -375,6 +422,8 @@ union cvmx_iob_outb_com_pri_cnt {
375 struct cvmx_iob_outb_com_pri_cnt_s cn56xxp1; 422 struct cvmx_iob_outb_com_pri_cnt_s cn56xxp1;
376 struct cvmx_iob_outb_com_pri_cnt_s cn58xx; 423 struct cvmx_iob_outb_com_pri_cnt_s cn58xx;
377 struct cvmx_iob_outb_com_pri_cnt_s cn58xxp1; 424 struct cvmx_iob_outb_com_pri_cnt_s cn58xxp1;
425 struct cvmx_iob_outb_com_pri_cnt_s cn63xx;
426 struct cvmx_iob_outb_com_pri_cnt_s cn63xxp1;
378}; 427};
379 428
380union cvmx_iob_outb_control_match { 429union cvmx_iob_outb_control_match {
@@ -397,6 +446,8 @@ union cvmx_iob_outb_control_match {
397 struct cvmx_iob_outb_control_match_s cn56xxp1; 446 struct cvmx_iob_outb_control_match_s cn56xxp1;
398 struct cvmx_iob_outb_control_match_s cn58xx; 447 struct cvmx_iob_outb_control_match_s cn58xx;
399 struct cvmx_iob_outb_control_match_s cn58xxp1; 448 struct cvmx_iob_outb_control_match_s cn58xxp1;
449 struct cvmx_iob_outb_control_match_s cn63xx;
450 struct cvmx_iob_outb_control_match_s cn63xxp1;
400}; 451};
401 452
402union cvmx_iob_outb_control_match_enb { 453union cvmx_iob_outb_control_match_enb {
@@ -419,6 +470,8 @@ union cvmx_iob_outb_control_match_enb {
419 struct cvmx_iob_outb_control_match_enb_s cn56xxp1; 470 struct cvmx_iob_outb_control_match_enb_s cn56xxp1;
420 struct cvmx_iob_outb_control_match_enb_s cn58xx; 471 struct cvmx_iob_outb_control_match_enb_s cn58xx;
421 struct cvmx_iob_outb_control_match_enb_s cn58xxp1; 472 struct cvmx_iob_outb_control_match_enb_s cn58xxp1;
473 struct cvmx_iob_outb_control_match_enb_s cn63xx;
474 struct cvmx_iob_outb_control_match_enb_s cn63xxp1;
422}; 475};
423 476
424union cvmx_iob_outb_data_match { 477union cvmx_iob_outb_data_match {
@@ -437,6 +490,8 @@ union cvmx_iob_outb_data_match {
437 struct cvmx_iob_outb_data_match_s cn56xxp1; 490 struct cvmx_iob_outb_data_match_s cn56xxp1;
438 struct cvmx_iob_outb_data_match_s cn58xx; 491 struct cvmx_iob_outb_data_match_s cn58xx;
439 struct cvmx_iob_outb_data_match_s cn58xxp1; 492 struct cvmx_iob_outb_data_match_s cn58xxp1;
493 struct cvmx_iob_outb_data_match_s cn63xx;
494 struct cvmx_iob_outb_data_match_s cn63xxp1;
440}; 495};
441 496
442union cvmx_iob_outb_data_match_enb { 497union cvmx_iob_outb_data_match_enb {
@@ -455,6 +510,8 @@ union cvmx_iob_outb_data_match_enb {
455 struct cvmx_iob_outb_data_match_enb_s cn56xxp1; 510 struct cvmx_iob_outb_data_match_enb_s cn56xxp1;
456 struct cvmx_iob_outb_data_match_enb_s cn58xx; 511 struct cvmx_iob_outb_data_match_enb_s cn58xx;
457 struct cvmx_iob_outb_data_match_enb_s cn58xxp1; 512 struct cvmx_iob_outb_data_match_enb_s cn58xxp1;
513 struct cvmx_iob_outb_data_match_enb_s cn63xx;
514 struct cvmx_iob_outb_data_match_enb_s cn63xxp1;
458}; 515};
459 516
460union cvmx_iob_outb_fpa_pri_cnt { 517union cvmx_iob_outb_fpa_pri_cnt {
@@ -472,6 +529,8 @@ union cvmx_iob_outb_fpa_pri_cnt {
472 struct cvmx_iob_outb_fpa_pri_cnt_s cn56xxp1; 529 struct cvmx_iob_outb_fpa_pri_cnt_s cn56xxp1;
473 struct cvmx_iob_outb_fpa_pri_cnt_s cn58xx; 530 struct cvmx_iob_outb_fpa_pri_cnt_s cn58xx;
474 struct cvmx_iob_outb_fpa_pri_cnt_s cn58xxp1; 531 struct cvmx_iob_outb_fpa_pri_cnt_s cn58xxp1;
532 struct cvmx_iob_outb_fpa_pri_cnt_s cn63xx;
533 struct cvmx_iob_outb_fpa_pri_cnt_s cn63xxp1;
475}; 534};
476 535
477union cvmx_iob_outb_req_pri_cnt { 536union cvmx_iob_outb_req_pri_cnt {
@@ -489,6 +548,8 @@ union cvmx_iob_outb_req_pri_cnt {
489 struct cvmx_iob_outb_req_pri_cnt_s cn56xxp1; 548 struct cvmx_iob_outb_req_pri_cnt_s cn56xxp1;
490 struct cvmx_iob_outb_req_pri_cnt_s cn58xx; 549 struct cvmx_iob_outb_req_pri_cnt_s cn58xx;
491 struct cvmx_iob_outb_req_pri_cnt_s cn58xxp1; 550 struct cvmx_iob_outb_req_pri_cnt_s cn58xxp1;
551 struct cvmx_iob_outb_req_pri_cnt_s cn63xx;
552 struct cvmx_iob_outb_req_pri_cnt_s cn63xxp1;
492}; 553};
493 554
494union cvmx_iob_p2c_req_pri_cnt { 555union cvmx_iob_p2c_req_pri_cnt {
@@ -506,25 +567,46 @@ union cvmx_iob_p2c_req_pri_cnt {
506 struct cvmx_iob_p2c_req_pri_cnt_s cn56xxp1; 567 struct cvmx_iob_p2c_req_pri_cnt_s cn56xxp1;
507 struct cvmx_iob_p2c_req_pri_cnt_s cn58xx; 568 struct cvmx_iob_p2c_req_pri_cnt_s cn58xx;
508 struct cvmx_iob_p2c_req_pri_cnt_s cn58xxp1; 569 struct cvmx_iob_p2c_req_pri_cnt_s cn58xxp1;
570 struct cvmx_iob_p2c_req_pri_cnt_s cn63xx;
571 struct cvmx_iob_p2c_req_pri_cnt_s cn63xxp1;
509}; 572};
510 573
511union cvmx_iob_pkt_err { 574union cvmx_iob_pkt_err {
512 uint64_t u64; 575 uint64_t u64;
513 struct cvmx_iob_pkt_err_s { 576 struct cvmx_iob_pkt_err_s {
577 uint64_t reserved_12_63:52;
578 uint64_t vport:6;
579 uint64_t port:6;
580 } s;
581 struct cvmx_iob_pkt_err_cn30xx {
514 uint64_t reserved_6_63:58; 582 uint64_t reserved_6_63:58;
515 uint64_t port:6; 583 uint64_t port:6;
584 } cn30xx;
585 struct cvmx_iob_pkt_err_cn30xx cn31xx;
586 struct cvmx_iob_pkt_err_cn30xx cn38xx;
587 struct cvmx_iob_pkt_err_cn30xx cn38xxp2;
588 struct cvmx_iob_pkt_err_cn30xx cn50xx;
589 struct cvmx_iob_pkt_err_cn30xx cn52xx;
590 struct cvmx_iob_pkt_err_cn30xx cn52xxp1;
591 struct cvmx_iob_pkt_err_cn30xx cn56xx;
592 struct cvmx_iob_pkt_err_cn30xx cn56xxp1;
593 struct cvmx_iob_pkt_err_cn30xx cn58xx;
594 struct cvmx_iob_pkt_err_cn30xx cn58xxp1;
595 struct cvmx_iob_pkt_err_s cn63xx;
596 struct cvmx_iob_pkt_err_s cn63xxp1;
597};
598
599union cvmx_iob_to_cmb_credits {
600 uint64_t u64;
601 struct cvmx_iob_to_cmb_credits_s {
602 uint64_t reserved_9_63:55;
603 uint64_t pko_rd:3;
604 uint64_t ncb_rd:3;
605 uint64_t ncb_wr:3;
516 } s; 606 } s;
517 struct cvmx_iob_pkt_err_s cn30xx; 607 struct cvmx_iob_to_cmb_credits_s cn52xx;
518 struct cvmx_iob_pkt_err_s cn31xx; 608 struct cvmx_iob_to_cmb_credits_s cn63xx;
519 struct cvmx_iob_pkt_err_s cn38xx; 609 struct cvmx_iob_to_cmb_credits_s cn63xxp1;
520 struct cvmx_iob_pkt_err_s cn38xxp2;
521 struct cvmx_iob_pkt_err_s cn50xx;
522 struct cvmx_iob_pkt_err_s cn52xx;
523 struct cvmx_iob_pkt_err_s cn52xxp1;
524 struct cvmx_iob_pkt_err_s cn56xx;
525 struct cvmx_iob_pkt_err_s cn56xxp1;
526 struct cvmx_iob_pkt_err_s cn58xx;
527 struct cvmx_iob_pkt_err_s cn58xxp1;
528}; 610};
529 611
530#endif 612#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-ipd-defs.h b/arch/mips/include/asm/octeon/cvmx-ipd-defs.h
index f8b8fc657d2c..e0a5bfe88d04 100644
--- a/arch/mips/include/asm/octeon/cvmx-ipd-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-ipd-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,104 +28,57 @@
28#ifndef __CVMX_IPD_DEFS_H__ 28#ifndef __CVMX_IPD_DEFS_H__
29#define __CVMX_IPD_DEFS_H__ 29#define __CVMX_IPD_DEFS_H__
30 30
31#define CVMX_IPD_1ST_MBUFF_SKIP \ 31#define CVMX_IPD_1ST_MBUFF_SKIP (CVMX_ADD_IO_SEG(0x00014F0000000000ull))
32 CVMX_ADD_IO_SEG(0x00014F0000000000ull) 32#define CVMX_IPD_1st_NEXT_PTR_BACK (CVMX_ADD_IO_SEG(0x00014F0000000150ull))
33#define CVMX_IPD_1st_NEXT_PTR_BACK \ 33#define CVMX_IPD_2nd_NEXT_PTR_BACK (CVMX_ADD_IO_SEG(0x00014F0000000158ull))
34 CVMX_ADD_IO_SEG(0x00014F0000000150ull) 34#define CVMX_IPD_BIST_STATUS (CVMX_ADD_IO_SEG(0x00014F00000007F8ull))
35#define CVMX_IPD_2nd_NEXT_PTR_BACK \ 35#define CVMX_IPD_BP_PRT_RED_END (CVMX_ADD_IO_SEG(0x00014F0000000328ull))
36 CVMX_ADD_IO_SEG(0x00014F0000000158ull) 36#define CVMX_IPD_CLK_COUNT (CVMX_ADD_IO_SEG(0x00014F0000000338ull))
37#define CVMX_IPD_BIST_STATUS \ 37#define CVMX_IPD_CTL_STATUS (CVMX_ADD_IO_SEG(0x00014F0000000018ull))
38 CVMX_ADD_IO_SEG(0x00014F00000007F8ull) 38#define CVMX_IPD_INT_ENB (CVMX_ADD_IO_SEG(0x00014F0000000160ull))
39#define CVMX_IPD_BP_PRT_RED_END \ 39#define CVMX_IPD_INT_SUM (CVMX_ADD_IO_SEG(0x00014F0000000168ull))
40 CVMX_ADD_IO_SEG(0x00014F0000000328ull) 40#define CVMX_IPD_NOT_1ST_MBUFF_SKIP (CVMX_ADD_IO_SEG(0x00014F0000000008ull))
41#define CVMX_IPD_CLK_COUNT \ 41#define CVMX_IPD_PACKET_MBUFF_SIZE (CVMX_ADD_IO_SEG(0x00014F0000000010ull))
42 CVMX_ADD_IO_SEG(0x00014F0000000338ull) 42#define CVMX_IPD_PKT_PTR_VALID (CVMX_ADD_IO_SEG(0x00014F0000000358ull))
43#define CVMX_IPD_CTL_STATUS \ 43#define CVMX_IPD_PORTX_BP_PAGE_CNT(offset) (CVMX_ADD_IO_SEG(0x00014F0000000028ull) + ((offset) & 63) * 8)
44 CVMX_ADD_IO_SEG(0x00014F0000000018ull) 44#define CVMX_IPD_PORTX_BP_PAGE_CNT2(offset) (CVMX_ADD_IO_SEG(0x00014F0000000368ull) + ((offset) & 63) * 8 - 8*36)
45#define CVMX_IPD_INT_ENB \ 45#define CVMX_IPD_PORTX_BP_PAGE_CNT3(offset) (CVMX_ADD_IO_SEG(0x00014F00000003D0ull) + ((offset) & 63) * 8 - 8*40)
46 CVMX_ADD_IO_SEG(0x00014F0000000160ull) 46#define CVMX_IPD_PORT_BP_COUNTERS2_PAIRX(offset) (CVMX_ADD_IO_SEG(0x00014F0000000388ull) + ((offset) & 63) * 8 - 8*36)
47#define CVMX_IPD_INT_SUM \ 47#define CVMX_IPD_PORT_BP_COUNTERS3_PAIRX(offset) (CVMX_ADD_IO_SEG(0x00014F00000003B0ull) + ((offset) & 63) * 8 - 8*40)
48 CVMX_ADD_IO_SEG(0x00014F0000000168ull) 48#define CVMX_IPD_PORT_BP_COUNTERS_PAIRX(offset) (CVMX_ADD_IO_SEG(0x00014F00000001B8ull) + ((offset) & 63) * 8)
49#define CVMX_IPD_NOT_1ST_MBUFF_SKIP \ 49#define CVMX_IPD_PORT_QOS_INTX(offset) (CVMX_ADD_IO_SEG(0x00014F0000000808ull) + ((offset) & 7) * 8)
50 CVMX_ADD_IO_SEG(0x00014F0000000008ull) 50#define CVMX_IPD_PORT_QOS_INT_ENBX(offset) (CVMX_ADD_IO_SEG(0x00014F0000000848ull) + ((offset) & 7) * 8)
51#define CVMX_IPD_PACKET_MBUFF_SIZE \ 51#define CVMX_IPD_PORT_QOS_X_CNT(offset) (CVMX_ADD_IO_SEG(0x00014F0000000888ull) + ((offset) & 511) * 8)
52 CVMX_ADD_IO_SEG(0x00014F0000000010ull) 52#define CVMX_IPD_PRC_HOLD_PTR_FIFO_CTL (CVMX_ADD_IO_SEG(0x00014F0000000348ull))
53#define CVMX_IPD_PKT_PTR_VALID \ 53#define CVMX_IPD_PRC_PORT_PTR_FIFO_CTL (CVMX_ADD_IO_SEG(0x00014F0000000350ull))
54 CVMX_ADD_IO_SEG(0x00014F0000000358ull) 54#define CVMX_IPD_PTR_COUNT (CVMX_ADD_IO_SEG(0x00014F0000000320ull))
55#define CVMX_IPD_PORTX_BP_PAGE_CNT(offset) \ 55#define CVMX_IPD_PWP_PTR_FIFO_CTL (CVMX_ADD_IO_SEG(0x00014F0000000340ull))
56 CVMX_ADD_IO_SEG(0x00014F0000000028ull + (((offset) & 63) * 8)) 56#define CVMX_IPD_QOS0_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(0)
57#define CVMX_IPD_PORTX_BP_PAGE_CNT2(offset) \ 57#define CVMX_IPD_QOS1_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(1)
58 CVMX_ADD_IO_SEG(0x00014F0000000368ull + (((offset) & 63) * 8) - 8 * 36) 58#define CVMX_IPD_QOS2_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(2)
59#define CVMX_IPD_PORT_BP_COUNTERS2_PAIRX(offset) \ 59#define CVMX_IPD_QOS3_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(3)
60 CVMX_ADD_IO_SEG(0x00014F0000000388ull + (((offset) & 63) * 8) - 8 * 36) 60#define CVMX_IPD_QOS4_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(4)
61#define CVMX_IPD_PORT_BP_COUNTERS_PAIRX(offset) \ 61#define CVMX_IPD_QOS5_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(5)
62 CVMX_ADD_IO_SEG(0x00014F00000001B8ull + (((offset) & 63) * 8)) 62#define CVMX_IPD_QOS6_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(6)
63#define CVMX_IPD_PORT_QOS_INTX(offset) \ 63#define CVMX_IPD_QOS7_RED_MARKS CVMX_IPD_QOSX_RED_MARKS(7)
64 CVMX_ADD_IO_SEG(0x00014F0000000808ull + (((offset) & 7) * 8)) 64#define CVMX_IPD_QOSX_RED_MARKS(offset) (CVMX_ADD_IO_SEG(0x00014F0000000178ull) + ((offset) & 7) * 8)
65#define CVMX_IPD_PORT_QOS_INT_ENBX(offset) \ 65#define CVMX_IPD_QUE0_FREE_PAGE_CNT (CVMX_ADD_IO_SEG(0x00014F0000000330ull))
66 CVMX_ADD_IO_SEG(0x00014F0000000848ull + (((offset) & 7) * 8)) 66#define CVMX_IPD_RED_PORT_ENABLE (CVMX_ADD_IO_SEG(0x00014F00000002D8ull))
67#define CVMX_IPD_PORT_QOS_X_CNT(offset) \ 67#define CVMX_IPD_RED_PORT_ENABLE2 (CVMX_ADD_IO_SEG(0x00014F00000003A8ull))
68 CVMX_ADD_IO_SEG(0x00014F0000000888ull + (((offset) & 511) * 8)) 68#define CVMX_IPD_RED_QUE0_PARAM CVMX_IPD_RED_QUEX_PARAM(0)
69#define CVMX_IPD_PRC_HOLD_PTR_FIFO_CTL \ 69#define CVMX_IPD_RED_QUE1_PARAM CVMX_IPD_RED_QUEX_PARAM(1)
70 CVMX_ADD_IO_SEG(0x00014F0000000348ull) 70#define CVMX_IPD_RED_QUE2_PARAM CVMX_IPD_RED_QUEX_PARAM(2)
71#define CVMX_IPD_PRC_PORT_PTR_FIFO_CTL \ 71#define CVMX_IPD_RED_QUE3_PARAM CVMX_IPD_RED_QUEX_PARAM(3)
72 CVMX_ADD_IO_SEG(0x00014F0000000350ull) 72#define CVMX_IPD_RED_QUE4_PARAM CVMX_IPD_RED_QUEX_PARAM(4)
73#define CVMX_IPD_PTR_COUNT \ 73#define CVMX_IPD_RED_QUE5_PARAM CVMX_IPD_RED_QUEX_PARAM(5)
74 CVMX_ADD_IO_SEG(0x00014F0000000320ull) 74#define CVMX_IPD_RED_QUE6_PARAM CVMX_IPD_RED_QUEX_PARAM(6)
75#define CVMX_IPD_PWP_PTR_FIFO_CTL \ 75#define CVMX_IPD_RED_QUE7_PARAM CVMX_IPD_RED_QUEX_PARAM(7)
76 CVMX_ADD_IO_SEG(0x00014F0000000340ull) 76#define CVMX_IPD_RED_QUEX_PARAM(offset) (CVMX_ADD_IO_SEG(0x00014F00000002E0ull) + ((offset) & 7) * 8)
77#define CVMX_IPD_QOS0_RED_MARKS \ 77#define CVMX_IPD_SUB_PORT_BP_PAGE_CNT (CVMX_ADD_IO_SEG(0x00014F0000000148ull))
78 CVMX_ADD_IO_SEG(0x00014F0000000178ull) 78#define CVMX_IPD_SUB_PORT_FCS (CVMX_ADD_IO_SEG(0x00014F0000000170ull))
79#define CVMX_IPD_QOS1_RED_MARKS \ 79#define CVMX_IPD_SUB_PORT_QOS_CNT (CVMX_ADD_IO_SEG(0x00014F0000000800ull))
80 CVMX_ADD_IO_SEG(0x00014F0000000180ull) 80#define CVMX_IPD_WQE_FPA_QUEUE (CVMX_ADD_IO_SEG(0x00014F0000000020ull))
81#define CVMX_IPD_QOS2_RED_MARKS \ 81#define CVMX_IPD_WQE_PTR_VALID (CVMX_ADD_IO_SEG(0x00014F0000000360ull))
82 CVMX_ADD_IO_SEG(0x00014F0000000188ull)
83#define CVMX_IPD_QOS3_RED_MARKS \
84 CVMX_ADD_IO_SEG(0x00014F0000000190ull)
85#define CVMX_IPD_QOS4_RED_MARKS \
86 CVMX_ADD_IO_SEG(0x00014F0000000198ull)
87#define CVMX_IPD_QOS5_RED_MARKS \
88 CVMX_ADD_IO_SEG(0x00014F00000001A0ull)
89#define CVMX_IPD_QOS6_RED_MARKS \
90 CVMX_ADD_IO_SEG(0x00014F00000001A8ull)
91#define CVMX_IPD_QOS7_RED_MARKS \
92 CVMX_ADD_IO_SEG(0x00014F00000001B0ull)
93#define CVMX_IPD_QOSX_RED_MARKS(offset) \
94 CVMX_ADD_IO_SEG(0x00014F0000000178ull + (((offset) & 7) * 8))
95#define CVMX_IPD_QUE0_FREE_PAGE_CNT \
96 CVMX_ADD_IO_SEG(0x00014F0000000330ull)
97#define CVMX_IPD_RED_PORT_ENABLE \
98 CVMX_ADD_IO_SEG(0x00014F00000002D8ull)
99#define CVMX_IPD_RED_PORT_ENABLE2 \
100 CVMX_ADD_IO_SEG(0x00014F00000003A8ull)
101#define CVMX_IPD_RED_QUE0_PARAM \
102 CVMX_ADD_IO_SEG(0x00014F00000002E0ull)
103#define CVMX_IPD_RED_QUE1_PARAM \
104 CVMX_ADD_IO_SEG(0x00014F00000002E8ull)
105#define CVMX_IPD_RED_QUE2_PARAM \
106 CVMX_ADD_IO_SEG(0x00014F00000002F0ull)
107#define CVMX_IPD_RED_QUE3_PARAM \
108 CVMX_ADD_IO_SEG(0x00014F00000002F8ull)
109#define CVMX_IPD_RED_QUE4_PARAM \
110 CVMX_ADD_IO_SEG(0x00014F0000000300ull)
111#define CVMX_IPD_RED_QUE5_PARAM \
112 CVMX_ADD_IO_SEG(0x00014F0000000308ull)
113#define CVMX_IPD_RED_QUE6_PARAM \
114 CVMX_ADD_IO_SEG(0x00014F0000000310ull)
115#define CVMX_IPD_RED_QUE7_PARAM \
116 CVMX_ADD_IO_SEG(0x00014F0000000318ull)
117#define CVMX_IPD_RED_QUEX_PARAM(offset) \
118 CVMX_ADD_IO_SEG(0x00014F00000002E0ull + (((offset) & 7) * 8))
119#define CVMX_IPD_SUB_PORT_BP_PAGE_CNT \
120 CVMX_ADD_IO_SEG(0x00014F0000000148ull)
121#define CVMX_IPD_SUB_PORT_FCS \
122 CVMX_ADD_IO_SEG(0x00014F0000000170ull)
123#define CVMX_IPD_SUB_PORT_QOS_CNT \
124 CVMX_ADD_IO_SEG(0x00014F0000000800ull)
125#define CVMX_IPD_WQE_FPA_QUEUE \
126 CVMX_ADD_IO_SEG(0x00014F0000000020ull)
127#define CVMX_IPD_WQE_PTR_VALID \
128 CVMX_ADD_IO_SEG(0x00014F0000000360ull)
129 82
130union cvmx_ipd_1st_mbuff_skip { 83union cvmx_ipd_1st_mbuff_skip {
131 uint64_t u64; 84 uint64_t u64;
@@ -144,6 +97,8 @@ union cvmx_ipd_1st_mbuff_skip {
144 struct cvmx_ipd_1st_mbuff_skip_s cn56xxp1; 97 struct cvmx_ipd_1st_mbuff_skip_s cn56xxp1;
145 struct cvmx_ipd_1st_mbuff_skip_s cn58xx; 98 struct cvmx_ipd_1st_mbuff_skip_s cn58xx;
146 struct cvmx_ipd_1st_mbuff_skip_s cn58xxp1; 99 struct cvmx_ipd_1st_mbuff_skip_s cn58xxp1;
100 struct cvmx_ipd_1st_mbuff_skip_s cn63xx;
101 struct cvmx_ipd_1st_mbuff_skip_s cn63xxp1;
147}; 102};
148 103
149union cvmx_ipd_1st_next_ptr_back { 104union cvmx_ipd_1st_next_ptr_back {
@@ -163,6 +118,8 @@ union cvmx_ipd_1st_next_ptr_back {
163 struct cvmx_ipd_1st_next_ptr_back_s cn56xxp1; 118 struct cvmx_ipd_1st_next_ptr_back_s cn56xxp1;
164 struct cvmx_ipd_1st_next_ptr_back_s cn58xx; 119 struct cvmx_ipd_1st_next_ptr_back_s cn58xx;
165 struct cvmx_ipd_1st_next_ptr_back_s cn58xxp1; 120 struct cvmx_ipd_1st_next_ptr_back_s cn58xxp1;
121 struct cvmx_ipd_1st_next_ptr_back_s cn63xx;
122 struct cvmx_ipd_1st_next_ptr_back_s cn63xxp1;
166}; 123};
167 124
168union cvmx_ipd_2nd_next_ptr_back { 125union cvmx_ipd_2nd_next_ptr_back {
@@ -182,6 +139,8 @@ union cvmx_ipd_2nd_next_ptr_back {
182 struct cvmx_ipd_2nd_next_ptr_back_s cn56xxp1; 139 struct cvmx_ipd_2nd_next_ptr_back_s cn56xxp1;
183 struct cvmx_ipd_2nd_next_ptr_back_s cn58xx; 140 struct cvmx_ipd_2nd_next_ptr_back_s cn58xx;
184 struct cvmx_ipd_2nd_next_ptr_back_s cn58xxp1; 141 struct cvmx_ipd_2nd_next_ptr_back_s cn58xxp1;
142 struct cvmx_ipd_2nd_next_ptr_back_s cn63xx;
143 struct cvmx_ipd_2nd_next_ptr_back_s cn63xxp1;
185}; 144};
186 145
187union cvmx_ipd_bist_status { 146union cvmx_ipd_bist_status {
@@ -236,13 +195,15 @@ union cvmx_ipd_bist_status {
236 struct cvmx_ipd_bist_status_s cn56xxp1; 195 struct cvmx_ipd_bist_status_s cn56xxp1;
237 struct cvmx_ipd_bist_status_cn30xx cn58xx; 196 struct cvmx_ipd_bist_status_cn30xx cn58xx;
238 struct cvmx_ipd_bist_status_cn30xx cn58xxp1; 197 struct cvmx_ipd_bist_status_cn30xx cn58xxp1;
198 struct cvmx_ipd_bist_status_s cn63xx;
199 struct cvmx_ipd_bist_status_s cn63xxp1;
239}; 200};
240 201
241union cvmx_ipd_bp_prt_red_end { 202union cvmx_ipd_bp_prt_red_end {
242 uint64_t u64; 203 uint64_t u64;
243 struct cvmx_ipd_bp_prt_red_end_s { 204 struct cvmx_ipd_bp_prt_red_end_s {
244 uint64_t reserved_40_63:24; 205 uint64_t reserved_44_63:20;
245 uint64_t prt_enb:40; 206 uint64_t prt_enb:44;
246 } s; 207 } s;
247 struct cvmx_ipd_bp_prt_red_end_cn30xx { 208 struct cvmx_ipd_bp_prt_red_end_cn30xx {
248 uint64_t reserved_36_63:28; 209 uint64_t reserved_36_63:28;
@@ -252,12 +213,17 @@ union cvmx_ipd_bp_prt_red_end {
252 struct cvmx_ipd_bp_prt_red_end_cn30xx cn38xx; 213 struct cvmx_ipd_bp_prt_red_end_cn30xx cn38xx;
253 struct cvmx_ipd_bp_prt_red_end_cn30xx cn38xxp2; 214 struct cvmx_ipd_bp_prt_red_end_cn30xx cn38xxp2;
254 struct cvmx_ipd_bp_prt_red_end_cn30xx cn50xx; 215 struct cvmx_ipd_bp_prt_red_end_cn30xx cn50xx;
255 struct cvmx_ipd_bp_prt_red_end_s cn52xx; 216 struct cvmx_ipd_bp_prt_red_end_cn52xx {
256 struct cvmx_ipd_bp_prt_red_end_s cn52xxp1; 217 uint64_t reserved_40_63:24;
257 struct cvmx_ipd_bp_prt_red_end_s cn56xx; 218 uint64_t prt_enb:40;
258 struct cvmx_ipd_bp_prt_red_end_s cn56xxp1; 219 } cn52xx;
220 struct cvmx_ipd_bp_prt_red_end_cn52xx cn52xxp1;
221 struct cvmx_ipd_bp_prt_red_end_cn52xx cn56xx;
222 struct cvmx_ipd_bp_prt_red_end_cn52xx cn56xxp1;
259 struct cvmx_ipd_bp_prt_red_end_cn30xx cn58xx; 223 struct cvmx_ipd_bp_prt_red_end_cn30xx cn58xx;
260 struct cvmx_ipd_bp_prt_red_end_cn30xx cn58xxp1; 224 struct cvmx_ipd_bp_prt_red_end_cn30xx cn58xxp1;
225 struct cvmx_ipd_bp_prt_red_end_s cn63xx;
226 struct cvmx_ipd_bp_prt_red_end_s cn63xxp1;
261}; 227};
262 228
263union cvmx_ipd_clk_count { 229union cvmx_ipd_clk_count {
@@ -276,12 +242,17 @@ union cvmx_ipd_clk_count {
276 struct cvmx_ipd_clk_count_s cn56xxp1; 242 struct cvmx_ipd_clk_count_s cn56xxp1;
277 struct cvmx_ipd_clk_count_s cn58xx; 243 struct cvmx_ipd_clk_count_s cn58xx;
278 struct cvmx_ipd_clk_count_s cn58xxp1; 244 struct cvmx_ipd_clk_count_s cn58xxp1;
245 struct cvmx_ipd_clk_count_s cn63xx;
246 struct cvmx_ipd_clk_count_s cn63xxp1;
279}; 247};
280 248
281union cvmx_ipd_ctl_status { 249union cvmx_ipd_ctl_status {
282 uint64_t u64; 250 uint64_t u64;
283 struct cvmx_ipd_ctl_status_s { 251 struct cvmx_ipd_ctl_status_s {
284 uint64_t reserved_15_63:49; 252 uint64_t reserved_18_63:46;
253 uint64_t use_sop:1;
254 uint64_t rst_done:1;
255 uint64_t clken:1;
285 uint64_t no_wptr:1; 256 uint64_t no_wptr:1;
286 uint64_t pq_apkt:1; 257 uint64_t pq_apkt:1;
287 uint64_t pq_nabuf:1; 258 uint64_t pq_nabuf:1;
@@ -322,11 +293,27 @@ union cvmx_ipd_ctl_status {
322 uint64_t opc_mode:2; 293 uint64_t opc_mode:2;
323 uint64_t ipd_en:1; 294 uint64_t ipd_en:1;
324 } cn38xxp2; 295 } cn38xxp2;
325 struct cvmx_ipd_ctl_status_s cn50xx; 296 struct cvmx_ipd_ctl_status_cn50xx {
326 struct cvmx_ipd_ctl_status_s cn52xx; 297 uint64_t reserved_15_63:49;
327 struct cvmx_ipd_ctl_status_s cn52xxp1; 298 uint64_t no_wptr:1;
328 struct cvmx_ipd_ctl_status_s cn56xx; 299 uint64_t pq_apkt:1;
329 struct cvmx_ipd_ctl_status_s cn56xxp1; 300 uint64_t pq_nabuf:1;
301 uint64_t ipd_full:1;
302 uint64_t pkt_off:1;
303 uint64_t len_m8:1;
304 uint64_t reset:1;
305 uint64_t addpkt:1;
306 uint64_t naddbuf:1;
307 uint64_t pkt_lend:1;
308 uint64_t wqe_lend:1;
309 uint64_t pbp_en:1;
310 uint64_t opc_mode:2;
311 uint64_t ipd_en:1;
312 } cn50xx;
313 struct cvmx_ipd_ctl_status_cn50xx cn52xx;
314 struct cvmx_ipd_ctl_status_cn50xx cn52xxp1;
315 struct cvmx_ipd_ctl_status_cn50xx cn56xx;
316 struct cvmx_ipd_ctl_status_cn50xx cn56xxp1;
330 struct cvmx_ipd_ctl_status_cn58xx { 317 struct cvmx_ipd_ctl_status_cn58xx {
331 uint64_t reserved_12_63:52; 318 uint64_t reserved_12_63:52;
332 uint64_t ipd_full:1; 319 uint64_t ipd_full:1;
@@ -342,6 +329,25 @@ union cvmx_ipd_ctl_status {
342 uint64_t ipd_en:1; 329 uint64_t ipd_en:1;
343 } cn58xx; 330 } cn58xx;
344 struct cvmx_ipd_ctl_status_cn58xx cn58xxp1; 331 struct cvmx_ipd_ctl_status_cn58xx cn58xxp1;
332 struct cvmx_ipd_ctl_status_s cn63xx;
333 struct cvmx_ipd_ctl_status_cn63xxp1 {
334 uint64_t reserved_16_63:48;
335 uint64_t clken:1;
336 uint64_t no_wptr:1;
337 uint64_t pq_apkt:1;
338 uint64_t pq_nabuf:1;
339 uint64_t ipd_full:1;
340 uint64_t pkt_off:1;
341 uint64_t len_m8:1;
342 uint64_t reset:1;
343 uint64_t addpkt:1;
344 uint64_t naddbuf:1;
345 uint64_t pkt_lend:1;
346 uint64_t wqe_lend:1;
347 uint64_t pbp_en:1;
348 uint64_t opc_mode:2;
349 uint64_t ipd_en:1;
350 } cn63xxp1;
345}; 351};
346 352
347union cvmx_ipd_int_enb { 353union cvmx_ipd_int_enb {
@@ -391,6 +397,8 @@ union cvmx_ipd_int_enb {
391 struct cvmx_ipd_int_enb_s cn56xxp1; 397 struct cvmx_ipd_int_enb_s cn56xxp1;
392 struct cvmx_ipd_int_enb_cn38xx cn58xx; 398 struct cvmx_ipd_int_enb_cn38xx cn58xx;
393 struct cvmx_ipd_int_enb_cn38xx cn58xxp1; 399 struct cvmx_ipd_int_enb_cn38xx cn58xxp1;
400 struct cvmx_ipd_int_enb_s cn63xx;
401 struct cvmx_ipd_int_enb_s cn63xxp1;
394}; 402};
395 403
396union cvmx_ipd_int_sum { 404union cvmx_ipd_int_sum {
@@ -440,6 +448,8 @@ union cvmx_ipd_int_sum {
440 struct cvmx_ipd_int_sum_s cn56xxp1; 448 struct cvmx_ipd_int_sum_s cn56xxp1;
441 struct cvmx_ipd_int_sum_cn38xx cn58xx; 449 struct cvmx_ipd_int_sum_cn38xx cn58xx;
442 struct cvmx_ipd_int_sum_cn38xx cn58xxp1; 450 struct cvmx_ipd_int_sum_cn38xx cn58xxp1;
451 struct cvmx_ipd_int_sum_s cn63xx;
452 struct cvmx_ipd_int_sum_s cn63xxp1;
443}; 453};
444 454
445union cvmx_ipd_not_1st_mbuff_skip { 455union cvmx_ipd_not_1st_mbuff_skip {
@@ -459,6 +469,8 @@ union cvmx_ipd_not_1st_mbuff_skip {
459 struct cvmx_ipd_not_1st_mbuff_skip_s cn56xxp1; 469 struct cvmx_ipd_not_1st_mbuff_skip_s cn56xxp1;
460 struct cvmx_ipd_not_1st_mbuff_skip_s cn58xx; 470 struct cvmx_ipd_not_1st_mbuff_skip_s cn58xx;
461 struct cvmx_ipd_not_1st_mbuff_skip_s cn58xxp1; 471 struct cvmx_ipd_not_1st_mbuff_skip_s cn58xxp1;
472 struct cvmx_ipd_not_1st_mbuff_skip_s cn63xx;
473 struct cvmx_ipd_not_1st_mbuff_skip_s cn63xxp1;
462}; 474};
463 475
464union cvmx_ipd_packet_mbuff_size { 476union cvmx_ipd_packet_mbuff_size {
@@ -478,6 +490,8 @@ union cvmx_ipd_packet_mbuff_size {
478 struct cvmx_ipd_packet_mbuff_size_s cn56xxp1; 490 struct cvmx_ipd_packet_mbuff_size_s cn56xxp1;
479 struct cvmx_ipd_packet_mbuff_size_s cn58xx; 491 struct cvmx_ipd_packet_mbuff_size_s cn58xx;
480 struct cvmx_ipd_packet_mbuff_size_s cn58xxp1; 492 struct cvmx_ipd_packet_mbuff_size_s cn58xxp1;
493 struct cvmx_ipd_packet_mbuff_size_s cn63xx;
494 struct cvmx_ipd_packet_mbuff_size_s cn63xxp1;
481}; 495};
482 496
483union cvmx_ipd_pkt_ptr_valid { 497union cvmx_ipd_pkt_ptr_valid {
@@ -496,6 +510,8 @@ union cvmx_ipd_pkt_ptr_valid {
496 struct cvmx_ipd_pkt_ptr_valid_s cn56xxp1; 510 struct cvmx_ipd_pkt_ptr_valid_s cn56xxp1;
497 struct cvmx_ipd_pkt_ptr_valid_s cn58xx; 511 struct cvmx_ipd_pkt_ptr_valid_s cn58xx;
498 struct cvmx_ipd_pkt_ptr_valid_s cn58xxp1; 512 struct cvmx_ipd_pkt_ptr_valid_s cn58xxp1;
513 struct cvmx_ipd_pkt_ptr_valid_s cn63xx;
514 struct cvmx_ipd_pkt_ptr_valid_s cn63xxp1;
499}; 515};
500 516
501union cvmx_ipd_portx_bp_page_cnt { 517union cvmx_ipd_portx_bp_page_cnt {
@@ -516,6 +532,8 @@ union cvmx_ipd_portx_bp_page_cnt {
516 struct cvmx_ipd_portx_bp_page_cnt_s cn56xxp1; 532 struct cvmx_ipd_portx_bp_page_cnt_s cn56xxp1;
517 struct cvmx_ipd_portx_bp_page_cnt_s cn58xx; 533 struct cvmx_ipd_portx_bp_page_cnt_s cn58xx;
518 struct cvmx_ipd_portx_bp_page_cnt_s cn58xxp1; 534 struct cvmx_ipd_portx_bp_page_cnt_s cn58xxp1;
535 struct cvmx_ipd_portx_bp_page_cnt_s cn63xx;
536 struct cvmx_ipd_portx_bp_page_cnt_s cn63xxp1;
519}; 537};
520 538
521union cvmx_ipd_portx_bp_page_cnt2 { 539union cvmx_ipd_portx_bp_page_cnt2 {
@@ -529,6 +547,19 @@ union cvmx_ipd_portx_bp_page_cnt2 {
529 struct cvmx_ipd_portx_bp_page_cnt2_s cn52xxp1; 547 struct cvmx_ipd_portx_bp_page_cnt2_s cn52xxp1;
530 struct cvmx_ipd_portx_bp_page_cnt2_s cn56xx; 548 struct cvmx_ipd_portx_bp_page_cnt2_s cn56xx;
531 struct cvmx_ipd_portx_bp_page_cnt2_s cn56xxp1; 549 struct cvmx_ipd_portx_bp_page_cnt2_s cn56xxp1;
550 struct cvmx_ipd_portx_bp_page_cnt2_s cn63xx;
551 struct cvmx_ipd_portx_bp_page_cnt2_s cn63xxp1;
552};
553
554union cvmx_ipd_portx_bp_page_cnt3 {
555 uint64_t u64;
556 struct cvmx_ipd_portx_bp_page_cnt3_s {
557 uint64_t reserved_18_63:46;
558 uint64_t bp_enb:1;
559 uint64_t page_cnt:17;
560 } s;
561 struct cvmx_ipd_portx_bp_page_cnt3_s cn63xx;
562 struct cvmx_ipd_portx_bp_page_cnt3_s cn63xxp1;
532}; 563};
533 564
534union cvmx_ipd_port_bp_counters2_pairx { 565union cvmx_ipd_port_bp_counters2_pairx {
@@ -541,6 +572,18 @@ union cvmx_ipd_port_bp_counters2_pairx {
541 struct cvmx_ipd_port_bp_counters2_pairx_s cn52xxp1; 572 struct cvmx_ipd_port_bp_counters2_pairx_s cn52xxp1;
542 struct cvmx_ipd_port_bp_counters2_pairx_s cn56xx; 573 struct cvmx_ipd_port_bp_counters2_pairx_s cn56xx;
543 struct cvmx_ipd_port_bp_counters2_pairx_s cn56xxp1; 574 struct cvmx_ipd_port_bp_counters2_pairx_s cn56xxp1;
575 struct cvmx_ipd_port_bp_counters2_pairx_s cn63xx;
576 struct cvmx_ipd_port_bp_counters2_pairx_s cn63xxp1;
577};
578
579union cvmx_ipd_port_bp_counters3_pairx {
580 uint64_t u64;
581 struct cvmx_ipd_port_bp_counters3_pairx_s {
582 uint64_t reserved_25_63:39;
583 uint64_t cnt_val:25;
584 } s;
585 struct cvmx_ipd_port_bp_counters3_pairx_s cn63xx;
586 struct cvmx_ipd_port_bp_counters3_pairx_s cn63xxp1;
544}; 587};
545 588
546union cvmx_ipd_port_bp_counters_pairx { 589union cvmx_ipd_port_bp_counters_pairx {
@@ -560,6 +603,8 @@ union cvmx_ipd_port_bp_counters_pairx {
560 struct cvmx_ipd_port_bp_counters_pairx_s cn56xxp1; 603 struct cvmx_ipd_port_bp_counters_pairx_s cn56xxp1;
561 struct cvmx_ipd_port_bp_counters_pairx_s cn58xx; 604 struct cvmx_ipd_port_bp_counters_pairx_s cn58xx;
562 struct cvmx_ipd_port_bp_counters_pairx_s cn58xxp1; 605 struct cvmx_ipd_port_bp_counters_pairx_s cn58xxp1;
606 struct cvmx_ipd_port_bp_counters_pairx_s cn63xx;
607 struct cvmx_ipd_port_bp_counters_pairx_s cn63xxp1;
563}; 608};
564 609
565union cvmx_ipd_port_qos_x_cnt { 610union cvmx_ipd_port_qos_x_cnt {
@@ -572,6 +617,8 @@ union cvmx_ipd_port_qos_x_cnt {
572 struct cvmx_ipd_port_qos_x_cnt_s cn52xxp1; 617 struct cvmx_ipd_port_qos_x_cnt_s cn52xxp1;
573 struct cvmx_ipd_port_qos_x_cnt_s cn56xx; 618 struct cvmx_ipd_port_qos_x_cnt_s cn56xx;
574 struct cvmx_ipd_port_qos_x_cnt_s cn56xxp1; 619 struct cvmx_ipd_port_qos_x_cnt_s cn56xxp1;
620 struct cvmx_ipd_port_qos_x_cnt_s cn63xx;
621 struct cvmx_ipd_port_qos_x_cnt_s cn63xxp1;
575}; 622};
576 623
577union cvmx_ipd_port_qos_intx { 624union cvmx_ipd_port_qos_intx {
@@ -583,6 +630,8 @@ union cvmx_ipd_port_qos_intx {
583 struct cvmx_ipd_port_qos_intx_s cn52xxp1; 630 struct cvmx_ipd_port_qos_intx_s cn52xxp1;
584 struct cvmx_ipd_port_qos_intx_s cn56xx; 631 struct cvmx_ipd_port_qos_intx_s cn56xx;
585 struct cvmx_ipd_port_qos_intx_s cn56xxp1; 632 struct cvmx_ipd_port_qos_intx_s cn56xxp1;
633 struct cvmx_ipd_port_qos_intx_s cn63xx;
634 struct cvmx_ipd_port_qos_intx_s cn63xxp1;
586}; 635};
587 636
588union cvmx_ipd_port_qos_int_enbx { 637union cvmx_ipd_port_qos_int_enbx {
@@ -594,6 +643,8 @@ union cvmx_ipd_port_qos_int_enbx {
594 struct cvmx_ipd_port_qos_int_enbx_s cn52xxp1; 643 struct cvmx_ipd_port_qos_int_enbx_s cn52xxp1;
595 struct cvmx_ipd_port_qos_int_enbx_s cn56xx; 644 struct cvmx_ipd_port_qos_int_enbx_s cn56xx;
596 struct cvmx_ipd_port_qos_int_enbx_s cn56xxp1; 645 struct cvmx_ipd_port_qos_int_enbx_s cn56xxp1;
646 struct cvmx_ipd_port_qos_int_enbx_s cn63xx;
647 struct cvmx_ipd_port_qos_int_enbx_s cn63xxp1;
597}; 648};
598 649
599union cvmx_ipd_prc_hold_ptr_fifo_ctl { 650union cvmx_ipd_prc_hold_ptr_fifo_ctl {
@@ -616,6 +667,8 @@ union cvmx_ipd_prc_hold_ptr_fifo_ctl {
616 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn56xxp1; 667 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn56xxp1;
617 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn58xx; 668 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn58xx;
618 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn58xxp1; 669 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn58xxp1;
670 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn63xx;
671 struct cvmx_ipd_prc_hold_ptr_fifo_ctl_s cn63xxp1;
619}; 672};
620 673
621union cvmx_ipd_prc_port_ptr_fifo_ctl { 674union cvmx_ipd_prc_port_ptr_fifo_ctl {
@@ -637,6 +690,8 @@ union cvmx_ipd_prc_port_ptr_fifo_ctl {
637 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn56xxp1; 690 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn56xxp1;
638 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn58xx; 691 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn58xx;
639 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn58xxp1; 692 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn58xxp1;
693 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn63xx;
694 struct cvmx_ipd_prc_port_ptr_fifo_ctl_s cn63xxp1;
640}; 695};
641 696
642union cvmx_ipd_ptr_count { 697union cvmx_ipd_ptr_count {
@@ -660,6 +715,8 @@ union cvmx_ipd_ptr_count {
660 struct cvmx_ipd_ptr_count_s cn56xxp1; 715 struct cvmx_ipd_ptr_count_s cn56xxp1;
661 struct cvmx_ipd_ptr_count_s cn58xx; 716 struct cvmx_ipd_ptr_count_s cn58xx;
662 struct cvmx_ipd_ptr_count_s cn58xxp1; 717 struct cvmx_ipd_ptr_count_s cn58xxp1;
718 struct cvmx_ipd_ptr_count_s cn63xx;
719 struct cvmx_ipd_ptr_count_s cn63xxp1;
663}; 720};
664 721
665union cvmx_ipd_pwp_ptr_fifo_ctl { 722union cvmx_ipd_pwp_ptr_fifo_ctl {
@@ -683,6 +740,8 @@ union cvmx_ipd_pwp_ptr_fifo_ctl {
683 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn56xxp1; 740 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn56xxp1;
684 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn58xx; 741 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn58xx;
685 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn58xxp1; 742 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn58xxp1;
743 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn63xx;
744 struct cvmx_ipd_pwp_ptr_fifo_ctl_s cn63xxp1;
686}; 745};
687 746
688union cvmx_ipd_qosx_red_marks { 747union cvmx_ipd_qosx_red_marks {
@@ -702,6 +761,8 @@ union cvmx_ipd_qosx_red_marks {
702 struct cvmx_ipd_qosx_red_marks_s cn56xxp1; 761 struct cvmx_ipd_qosx_red_marks_s cn56xxp1;
703 struct cvmx_ipd_qosx_red_marks_s cn58xx; 762 struct cvmx_ipd_qosx_red_marks_s cn58xx;
704 struct cvmx_ipd_qosx_red_marks_s cn58xxp1; 763 struct cvmx_ipd_qosx_red_marks_s cn58xxp1;
764 struct cvmx_ipd_qosx_red_marks_s cn63xx;
765 struct cvmx_ipd_qosx_red_marks_s cn63xxp1;
705}; 766};
706 767
707union cvmx_ipd_que0_free_page_cnt { 768union cvmx_ipd_que0_free_page_cnt {
@@ -721,6 +782,8 @@ union cvmx_ipd_que0_free_page_cnt {
721 struct cvmx_ipd_que0_free_page_cnt_s cn56xxp1; 782 struct cvmx_ipd_que0_free_page_cnt_s cn56xxp1;
722 struct cvmx_ipd_que0_free_page_cnt_s cn58xx; 783 struct cvmx_ipd_que0_free_page_cnt_s cn58xx;
723 struct cvmx_ipd_que0_free_page_cnt_s cn58xxp1; 784 struct cvmx_ipd_que0_free_page_cnt_s cn58xxp1;
785 struct cvmx_ipd_que0_free_page_cnt_s cn63xx;
786 struct cvmx_ipd_que0_free_page_cnt_s cn63xxp1;
724}; 787};
725 788
726union cvmx_ipd_red_port_enable { 789union cvmx_ipd_red_port_enable {
@@ -741,18 +804,25 @@ union cvmx_ipd_red_port_enable {
741 struct cvmx_ipd_red_port_enable_s cn56xxp1; 804 struct cvmx_ipd_red_port_enable_s cn56xxp1;
742 struct cvmx_ipd_red_port_enable_s cn58xx; 805 struct cvmx_ipd_red_port_enable_s cn58xx;
743 struct cvmx_ipd_red_port_enable_s cn58xxp1; 806 struct cvmx_ipd_red_port_enable_s cn58xxp1;
807 struct cvmx_ipd_red_port_enable_s cn63xx;
808 struct cvmx_ipd_red_port_enable_s cn63xxp1;
744}; 809};
745 810
746union cvmx_ipd_red_port_enable2 { 811union cvmx_ipd_red_port_enable2 {
747 uint64_t u64; 812 uint64_t u64;
748 struct cvmx_ipd_red_port_enable2_s { 813 struct cvmx_ipd_red_port_enable2_s {
814 uint64_t reserved_8_63:56;
815 uint64_t prt_enb:8;
816 } s;
817 struct cvmx_ipd_red_port_enable2_cn52xx {
749 uint64_t reserved_4_63:60; 818 uint64_t reserved_4_63:60;
750 uint64_t prt_enb:4; 819 uint64_t prt_enb:4;
751 } s; 820 } cn52xx;
752 struct cvmx_ipd_red_port_enable2_s cn52xx; 821 struct cvmx_ipd_red_port_enable2_cn52xx cn52xxp1;
753 struct cvmx_ipd_red_port_enable2_s cn52xxp1; 822 struct cvmx_ipd_red_port_enable2_cn52xx cn56xx;
754 struct cvmx_ipd_red_port_enable2_s cn56xx; 823 struct cvmx_ipd_red_port_enable2_cn52xx cn56xxp1;
755 struct cvmx_ipd_red_port_enable2_s cn56xxp1; 824 struct cvmx_ipd_red_port_enable2_s cn63xx;
825 struct cvmx_ipd_red_port_enable2_s cn63xxp1;
756}; 826};
757 827
758union cvmx_ipd_red_quex_param { 828union cvmx_ipd_red_quex_param {
@@ -775,6 +845,8 @@ union cvmx_ipd_red_quex_param {
775 struct cvmx_ipd_red_quex_param_s cn56xxp1; 845 struct cvmx_ipd_red_quex_param_s cn56xxp1;
776 struct cvmx_ipd_red_quex_param_s cn58xx; 846 struct cvmx_ipd_red_quex_param_s cn58xx;
777 struct cvmx_ipd_red_quex_param_s cn58xxp1; 847 struct cvmx_ipd_red_quex_param_s cn58xxp1;
848 struct cvmx_ipd_red_quex_param_s cn63xx;
849 struct cvmx_ipd_red_quex_param_s cn63xxp1;
778}; 850};
779 851
780union cvmx_ipd_sub_port_bp_page_cnt { 852union cvmx_ipd_sub_port_bp_page_cnt {
@@ -795,6 +867,8 @@ union cvmx_ipd_sub_port_bp_page_cnt {
795 struct cvmx_ipd_sub_port_bp_page_cnt_s cn56xxp1; 867 struct cvmx_ipd_sub_port_bp_page_cnt_s cn56xxp1;
796 struct cvmx_ipd_sub_port_bp_page_cnt_s cn58xx; 868 struct cvmx_ipd_sub_port_bp_page_cnt_s cn58xx;
797 struct cvmx_ipd_sub_port_bp_page_cnt_s cn58xxp1; 869 struct cvmx_ipd_sub_port_bp_page_cnt_s cn58xxp1;
870 struct cvmx_ipd_sub_port_bp_page_cnt_s cn63xx;
871 struct cvmx_ipd_sub_port_bp_page_cnt_s cn63xxp1;
798}; 872};
799 873
800union cvmx_ipd_sub_port_fcs { 874union cvmx_ipd_sub_port_fcs {
@@ -822,6 +896,8 @@ union cvmx_ipd_sub_port_fcs {
822 struct cvmx_ipd_sub_port_fcs_s cn56xxp1; 896 struct cvmx_ipd_sub_port_fcs_s cn56xxp1;
823 struct cvmx_ipd_sub_port_fcs_cn38xx cn58xx; 897 struct cvmx_ipd_sub_port_fcs_cn38xx cn58xx;
824 struct cvmx_ipd_sub_port_fcs_cn38xx cn58xxp1; 898 struct cvmx_ipd_sub_port_fcs_cn38xx cn58xxp1;
899 struct cvmx_ipd_sub_port_fcs_s cn63xx;
900 struct cvmx_ipd_sub_port_fcs_s cn63xxp1;
825}; 901};
826 902
827union cvmx_ipd_sub_port_qos_cnt { 903union cvmx_ipd_sub_port_qos_cnt {
@@ -835,6 +911,8 @@ union cvmx_ipd_sub_port_qos_cnt {
835 struct cvmx_ipd_sub_port_qos_cnt_s cn52xxp1; 911 struct cvmx_ipd_sub_port_qos_cnt_s cn52xxp1;
836 struct cvmx_ipd_sub_port_qos_cnt_s cn56xx; 912 struct cvmx_ipd_sub_port_qos_cnt_s cn56xx;
837 struct cvmx_ipd_sub_port_qos_cnt_s cn56xxp1; 913 struct cvmx_ipd_sub_port_qos_cnt_s cn56xxp1;
914 struct cvmx_ipd_sub_port_qos_cnt_s cn63xx;
915 struct cvmx_ipd_sub_port_qos_cnt_s cn63xxp1;
838}; 916};
839 917
840union cvmx_ipd_wqe_fpa_queue { 918union cvmx_ipd_wqe_fpa_queue {
@@ -854,6 +932,8 @@ union cvmx_ipd_wqe_fpa_queue {
854 struct cvmx_ipd_wqe_fpa_queue_s cn56xxp1; 932 struct cvmx_ipd_wqe_fpa_queue_s cn56xxp1;
855 struct cvmx_ipd_wqe_fpa_queue_s cn58xx; 933 struct cvmx_ipd_wqe_fpa_queue_s cn58xx;
856 struct cvmx_ipd_wqe_fpa_queue_s cn58xxp1; 934 struct cvmx_ipd_wqe_fpa_queue_s cn58xxp1;
935 struct cvmx_ipd_wqe_fpa_queue_s cn63xx;
936 struct cvmx_ipd_wqe_fpa_queue_s cn63xxp1;
857}; 937};
858 938
859union cvmx_ipd_wqe_ptr_valid { 939union cvmx_ipd_wqe_ptr_valid {
@@ -872,6 +952,8 @@ union cvmx_ipd_wqe_ptr_valid {
872 struct cvmx_ipd_wqe_ptr_valid_s cn56xxp1; 952 struct cvmx_ipd_wqe_ptr_valid_s cn56xxp1;
873 struct cvmx_ipd_wqe_ptr_valid_s cn58xx; 953 struct cvmx_ipd_wqe_ptr_valid_s cn58xx;
874 struct cvmx_ipd_wqe_ptr_valid_s cn58xxp1; 954 struct cvmx_ipd_wqe_ptr_valid_s cn58xxp1;
955 struct cvmx_ipd_wqe_ptr_valid_s cn63xx;
956 struct cvmx_ipd_wqe_ptr_valid_s cn63xxp1;
875}; 957};
876 958
877#endif 959#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-l2c-defs.h b/arch/mips/include/asm/octeon/cvmx-l2c-defs.h
index 337583842b51..7a50a0beb472 100644
--- a/arch/mips/include/asm/octeon/cvmx-l2c-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-l2c-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,70 +28,113 @@
28#ifndef __CVMX_L2C_DEFS_H__ 28#ifndef __CVMX_L2C_DEFS_H__
29#define __CVMX_L2C_DEFS_H__ 29#define __CVMX_L2C_DEFS_H__
30 30
31#define CVMX_L2C_BST0 \ 31#define CVMX_L2C_BIG_CTL (CVMX_ADD_IO_SEG(0x0001180080800030ull))
32 CVMX_ADD_IO_SEG(0x00011800800007F8ull) 32#define CVMX_L2C_BST (CVMX_ADD_IO_SEG(0x00011800808007F8ull))
33#define CVMX_L2C_BST1 \ 33#define CVMX_L2C_BST0 (CVMX_ADD_IO_SEG(0x00011800800007F8ull))
34 CVMX_ADD_IO_SEG(0x00011800800007F0ull) 34#define CVMX_L2C_BST1 (CVMX_ADD_IO_SEG(0x00011800800007F0ull))
35#define CVMX_L2C_BST2 \ 35#define CVMX_L2C_BST2 (CVMX_ADD_IO_SEG(0x00011800800007E8ull))
36 CVMX_ADD_IO_SEG(0x00011800800007E8ull) 36#define CVMX_L2C_BST_MEMX(block_id) (CVMX_ADD_IO_SEG(0x0001180080C007F8ull))
37#define CVMX_L2C_CFG \ 37#define CVMX_L2C_BST_TDTX(block_id) (CVMX_ADD_IO_SEG(0x0001180080A007F0ull))
38 CVMX_ADD_IO_SEG(0x0001180080000000ull) 38#define CVMX_L2C_BST_TTGX(block_id) (CVMX_ADD_IO_SEG(0x0001180080A007F8ull))
39#define CVMX_L2C_DBG \ 39#define CVMX_L2C_CFG (CVMX_ADD_IO_SEG(0x0001180080000000ull))
40 CVMX_ADD_IO_SEG(0x0001180080000030ull) 40#define CVMX_L2C_COP0_MAPX(offset) (CVMX_ADD_IO_SEG(0x0001180080940000ull) + ((offset) & 16383) * 8)
41#define CVMX_L2C_DUT \ 41#define CVMX_L2C_CTL (CVMX_ADD_IO_SEG(0x0001180080800000ull))
42 CVMX_ADD_IO_SEG(0x0001180080000050ull) 42#define CVMX_L2C_DBG (CVMX_ADD_IO_SEG(0x0001180080000030ull))
43#define CVMX_L2C_GRPWRR0 \ 43#define CVMX_L2C_DUT (CVMX_ADD_IO_SEG(0x0001180080000050ull))
44 CVMX_ADD_IO_SEG(0x00011800800000C8ull) 44#define CVMX_L2C_DUT_MAPX(offset) (CVMX_ADD_IO_SEG(0x0001180080E00000ull) + ((offset) & 2047) * 8)
45#define CVMX_L2C_GRPWRR1 \ 45#define CVMX_L2C_ERR_TDTX(block_id) (CVMX_ADD_IO_SEG(0x0001180080A007E0ull))
46 CVMX_ADD_IO_SEG(0x00011800800000D0ull) 46#define CVMX_L2C_ERR_TTGX(block_id) (CVMX_ADD_IO_SEG(0x0001180080A007E8ull))
47#define CVMX_L2C_INT_EN \ 47#define CVMX_L2C_ERR_VBFX(block_id) (CVMX_ADD_IO_SEG(0x0001180080C007F0ull))
48 CVMX_ADD_IO_SEG(0x0001180080000100ull) 48#define CVMX_L2C_ERR_XMC (CVMX_ADD_IO_SEG(0x00011800808007D8ull))
49#define CVMX_L2C_INT_STAT \ 49#define CVMX_L2C_GRPWRR0 (CVMX_ADD_IO_SEG(0x00011800800000C8ull))
50 CVMX_ADD_IO_SEG(0x00011800800000F8ull) 50#define CVMX_L2C_GRPWRR1 (CVMX_ADD_IO_SEG(0x00011800800000D0ull))
51#define CVMX_L2C_LCKBASE \ 51#define CVMX_L2C_INT_EN (CVMX_ADD_IO_SEG(0x0001180080000100ull))
52 CVMX_ADD_IO_SEG(0x0001180080000058ull) 52#define CVMX_L2C_INT_ENA (CVMX_ADD_IO_SEG(0x0001180080800020ull))
53#define CVMX_L2C_LCKOFF \ 53#define CVMX_L2C_INT_REG (CVMX_ADD_IO_SEG(0x0001180080800018ull))
54 CVMX_ADD_IO_SEG(0x0001180080000060ull) 54#define CVMX_L2C_INT_STAT (CVMX_ADD_IO_SEG(0x00011800800000F8ull))
55#define CVMX_L2C_LFB0 \ 55#define CVMX_L2C_IOCX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800420ull))
56 CVMX_ADD_IO_SEG(0x0001180080000038ull) 56#define CVMX_L2C_IORX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800428ull))
57#define CVMX_L2C_LFB1 \ 57#define CVMX_L2C_LCKBASE (CVMX_ADD_IO_SEG(0x0001180080000058ull))
58 CVMX_ADD_IO_SEG(0x0001180080000040ull) 58#define CVMX_L2C_LCKOFF (CVMX_ADD_IO_SEG(0x0001180080000060ull))
59#define CVMX_L2C_LFB2 \ 59#define CVMX_L2C_LFB0 (CVMX_ADD_IO_SEG(0x0001180080000038ull))
60 CVMX_ADD_IO_SEG(0x0001180080000048ull) 60#define CVMX_L2C_LFB1 (CVMX_ADD_IO_SEG(0x0001180080000040ull))
61#define CVMX_L2C_LFB3 \ 61#define CVMX_L2C_LFB2 (CVMX_ADD_IO_SEG(0x0001180080000048ull))
62 CVMX_ADD_IO_SEG(0x00011800800000B8ull) 62#define CVMX_L2C_LFB3 (CVMX_ADD_IO_SEG(0x00011800800000B8ull))
63#define CVMX_L2C_OOB \ 63#define CVMX_L2C_OOB (CVMX_ADD_IO_SEG(0x00011800800000D8ull))
64 CVMX_ADD_IO_SEG(0x00011800800000D8ull) 64#define CVMX_L2C_OOB1 (CVMX_ADD_IO_SEG(0x00011800800000E0ull))
65#define CVMX_L2C_OOB1 \ 65#define CVMX_L2C_OOB2 (CVMX_ADD_IO_SEG(0x00011800800000E8ull))
66 CVMX_ADD_IO_SEG(0x00011800800000E0ull) 66#define CVMX_L2C_OOB3 (CVMX_ADD_IO_SEG(0x00011800800000F0ull))
67#define CVMX_L2C_OOB2 \ 67#define CVMX_L2C_PFC0 CVMX_L2C_PFCX(0)
68 CVMX_ADD_IO_SEG(0x00011800800000E8ull) 68#define CVMX_L2C_PFC1 CVMX_L2C_PFCX(1)
69#define CVMX_L2C_OOB3 \ 69#define CVMX_L2C_PFC2 CVMX_L2C_PFCX(2)
70 CVMX_ADD_IO_SEG(0x00011800800000F0ull) 70#define CVMX_L2C_PFC3 CVMX_L2C_PFCX(3)
71#define CVMX_L2C_PFC0 \ 71#define CVMX_L2C_PFCTL (CVMX_ADD_IO_SEG(0x0001180080000090ull))
72 CVMX_ADD_IO_SEG(0x0001180080000098ull) 72#define CVMX_L2C_PFCX(offset) (CVMX_ADD_IO_SEG(0x0001180080000098ull) + ((offset) & 3) * 8)
73#define CVMX_L2C_PFC1 \ 73#define CVMX_L2C_PPGRP (CVMX_ADD_IO_SEG(0x00011800800000C0ull))
74 CVMX_ADD_IO_SEG(0x00011800800000A0ull) 74#define CVMX_L2C_QOS_IOBX(block_id) (CVMX_ADD_IO_SEG(0x0001180080880200ull))
75#define CVMX_L2C_PFC2 \ 75#define CVMX_L2C_QOS_PPX(offset) (CVMX_ADD_IO_SEG(0x0001180080880000ull) + ((offset) & 7) * 8)
76 CVMX_ADD_IO_SEG(0x00011800800000A8ull) 76#define CVMX_L2C_QOS_WGT (CVMX_ADD_IO_SEG(0x0001180080800008ull))
77#define CVMX_L2C_PFC3 \ 77#define CVMX_L2C_RSCX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800410ull))
78 CVMX_ADD_IO_SEG(0x00011800800000B0ull) 78#define CVMX_L2C_RSDX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800418ull))
79#define CVMX_L2C_PFCTL \ 79#define CVMX_L2C_SPAR0 (CVMX_ADD_IO_SEG(0x0001180080000068ull))
80 CVMX_ADD_IO_SEG(0x0001180080000090ull) 80#define CVMX_L2C_SPAR1 (CVMX_ADD_IO_SEG(0x0001180080000070ull))
81#define CVMX_L2C_PFCX(offset) \ 81#define CVMX_L2C_SPAR2 (CVMX_ADD_IO_SEG(0x0001180080000078ull))
82 CVMX_ADD_IO_SEG(0x0001180080000098ull + (((offset) & 3) * 8)) 82#define CVMX_L2C_SPAR3 (CVMX_ADD_IO_SEG(0x0001180080000080ull))
83#define CVMX_L2C_PPGRP \ 83#define CVMX_L2C_SPAR4 (CVMX_ADD_IO_SEG(0x0001180080000088ull))
84 CVMX_ADD_IO_SEG(0x00011800800000C0ull) 84#define CVMX_L2C_TADX_ECC0(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00018ull))
85#define CVMX_L2C_SPAR0 \ 85#define CVMX_L2C_TADX_ECC1(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00020ull))
86 CVMX_ADD_IO_SEG(0x0001180080000068ull) 86#define CVMX_L2C_TADX_IEN(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00000ull))
87#define CVMX_L2C_SPAR1 \ 87#define CVMX_L2C_TADX_INT(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00028ull))
88 CVMX_ADD_IO_SEG(0x0001180080000070ull) 88#define CVMX_L2C_TADX_PFC0(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00400ull))
89#define CVMX_L2C_SPAR2 \ 89#define CVMX_L2C_TADX_PFC1(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00408ull))
90 CVMX_ADD_IO_SEG(0x0001180080000078ull) 90#define CVMX_L2C_TADX_PFC2(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00410ull))
91#define CVMX_L2C_SPAR3 \ 91#define CVMX_L2C_TADX_PFC3(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00418ull))
92 CVMX_ADD_IO_SEG(0x0001180080000080ull) 92#define CVMX_L2C_TADX_PRF(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00008ull))
93#define CVMX_L2C_SPAR4 \ 93#define CVMX_L2C_TADX_TAG(block_id) (CVMX_ADD_IO_SEG(0x0001180080A00010ull))
94 CVMX_ADD_IO_SEG(0x0001180080000088ull) 94#define CVMX_L2C_VER_ID (CVMX_ADD_IO_SEG(0x00011800808007E0ull))
95#define CVMX_L2C_VER_IOB (CVMX_ADD_IO_SEG(0x00011800808007F0ull))
96#define CVMX_L2C_VER_MSC (CVMX_ADD_IO_SEG(0x00011800808007D0ull))
97#define CVMX_L2C_VER_PP (CVMX_ADD_IO_SEG(0x00011800808007E8ull))
98#define CVMX_L2C_VIRTID_IOBX(block_id) (CVMX_ADD_IO_SEG(0x00011800808C0200ull))
99#define CVMX_L2C_VIRTID_PPX(offset) (CVMX_ADD_IO_SEG(0x00011800808C0000ull) + ((offset) & 7) * 8)
100#define CVMX_L2C_VRT_CTL (CVMX_ADD_IO_SEG(0x0001180080800010ull))
101#define CVMX_L2C_VRT_MEMX(offset) (CVMX_ADD_IO_SEG(0x0001180080900000ull) + ((offset) & 1023) * 8)
102#define CVMX_L2C_WPAR_IOBX(block_id) (CVMX_ADD_IO_SEG(0x0001180080840200ull))
103#define CVMX_L2C_WPAR_PPX(offset) (CVMX_ADD_IO_SEG(0x0001180080840000ull) + ((offset) & 7) * 8)
104#define CVMX_L2C_XMCX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800400ull))
105#define CVMX_L2C_XMC_CMD (CVMX_ADD_IO_SEG(0x0001180080800028ull))
106#define CVMX_L2C_XMDX_PFC(block_id) (CVMX_ADD_IO_SEG(0x0001180080800408ull))
107
108union cvmx_l2c_big_ctl {
109 uint64_t u64;
110 struct cvmx_l2c_big_ctl_s {
111 uint64_t reserved_8_63:56;
112 uint64_t maxdram:4;
113 uint64_t reserved_1_3:3;
114 uint64_t disable:1;
115 } s;
116 struct cvmx_l2c_big_ctl_s cn63xx;
117};
118
119union cvmx_l2c_bst {
120 uint64_t u64;
121 struct cvmx_l2c_bst_s {
122 uint64_t reserved_38_63:26;
123 uint64_t dutfl:6;
124 uint64_t reserved_17_31:15;
125 uint64_t ioccmdfl:1;
126 uint64_t reserved_13_15:3;
127 uint64_t iocdatfl:1;
128 uint64_t reserved_9_11:3;
129 uint64_t dutresfl:1;
130 uint64_t reserved_5_7:3;
131 uint64_t vrtfl:1;
132 uint64_t reserved_1_3:3;
133 uint64_t tdffl:1;
134 } s;
135 struct cvmx_l2c_bst_s cn63xx;
136 struct cvmx_l2c_bst_s cn63xxp1;
137};
95 138
96union cvmx_l2c_bst0 { 139union cvmx_l2c_bst0 {
97 uint64_t u64; 140 uint64_t u64;
@@ -253,6 +296,48 @@ union cvmx_l2c_bst2 {
253 struct cvmx_l2c_bst2_cn56xx cn58xxp1; 296 struct cvmx_l2c_bst2_cn56xx cn58xxp1;
254}; 297};
255 298
299union cvmx_l2c_bst_memx {
300 uint64_t u64;
301 struct cvmx_l2c_bst_memx_s {
302 uint64_t start_bist:1;
303 uint64_t clear_bist:1;
304 uint64_t reserved_5_61:57;
305 uint64_t rdffl:1;
306 uint64_t vbffl:4;
307 } s;
308 struct cvmx_l2c_bst_memx_s cn63xx;
309 struct cvmx_l2c_bst_memx_s cn63xxp1;
310};
311
312union cvmx_l2c_bst_tdtx {
313 uint64_t u64;
314 struct cvmx_l2c_bst_tdtx_s {
315 uint64_t reserved_32_63:32;
316 uint64_t fbfrspfl:8;
317 uint64_t sbffl:8;
318 uint64_t fbffl:8;
319 uint64_t l2dfl:8;
320 } s;
321 struct cvmx_l2c_bst_tdtx_s cn63xx;
322 struct cvmx_l2c_bst_tdtx_cn63xxp1 {
323 uint64_t reserved_24_63:40;
324 uint64_t sbffl:8;
325 uint64_t fbffl:8;
326 uint64_t l2dfl:8;
327 } cn63xxp1;
328};
329
330union cvmx_l2c_bst_ttgx {
331 uint64_t u64;
332 struct cvmx_l2c_bst_ttgx_s {
333 uint64_t reserved_17_63:47;
334 uint64_t lrufl:1;
335 uint64_t tagfl:16;
336 } s;
337 struct cvmx_l2c_bst_ttgx_s cn63xx;
338 struct cvmx_l2c_bst_ttgx_s cn63xxp1;
339};
340
256union cvmx_l2c_cfg { 341union cvmx_l2c_cfg {
257 uint64_t u64; 342 uint64_t u64;
258 struct cvmx_l2c_cfg_s { 343 struct cvmx_l2c_cfg_s {
@@ -333,6 +418,49 @@ union cvmx_l2c_cfg {
333 } cn58xxp1; 418 } cn58xxp1;
334}; 419};
335 420
421union cvmx_l2c_cop0_mapx {
422 uint64_t u64;
423 struct cvmx_l2c_cop0_mapx_s {
424 uint64_t data:64;
425 } s;
426 struct cvmx_l2c_cop0_mapx_s cn63xx;
427 struct cvmx_l2c_cop0_mapx_s cn63xxp1;
428};
429
430union cvmx_l2c_ctl {
431 uint64_t u64;
432 struct cvmx_l2c_ctl_s {
433 uint64_t reserved_28_63:36;
434 uint64_t disstgl2i:1;
435 uint64_t l2dfsbe:1;
436 uint64_t l2dfdbe:1;
437 uint64_t discclk:1;
438 uint64_t maxvab:4;
439 uint64_t maxlfb:4;
440 uint64_t rsp_arb_mode:1;
441 uint64_t xmc_arb_mode:1;
442 uint64_t ef_ena:1;
443 uint64_t ef_cnt:7;
444 uint64_t vab_thresh:4;
445 uint64_t disecc:1;
446 uint64_t disidxalias:1;
447 } s;
448 struct cvmx_l2c_ctl_s cn63xx;
449 struct cvmx_l2c_ctl_cn63xxp1 {
450 uint64_t reserved_25_63:39;
451 uint64_t discclk:1;
452 uint64_t maxvab:4;
453 uint64_t maxlfb:4;
454 uint64_t rsp_arb_mode:1;
455 uint64_t xmc_arb_mode:1;
456 uint64_t ef_ena:1;
457 uint64_t ef_cnt:7;
458 uint64_t vab_thresh:4;
459 uint64_t disecc:1;
460 uint64_t disidxalias:1;
461 } cn63xxp1;
462};
463
336union cvmx_l2c_dbg { 464union cvmx_l2c_dbg {
337 uint64_t u64; 465 uint64_t u64;
338 struct cvmx_l2c_dbg_s { 466 struct cvmx_l2c_dbg_s {
@@ -349,7 +477,9 @@ union cvmx_l2c_dbg {
349 uint64_t reserved_13_63:51; 477 uint64_t reserved_13_63:51;
350 uint64_t lfb_enum:2; 478 uint64_t lfb_enum:2;
351 uint64_t lfb_dmp:1; 479 uint64_t lfb_dmp:1;
352 uint64_t reserved_5_9:5; 480 uint64_t reserved_7_9:3;
481 uint64_t ppnum:1;
482 uint64_t reserved_5_5:1;
353 uint64_t set:2; 483 uint64_t set:2;
354 uint64_t finv:1; 484 uint64_t finv:1;
355 uint64_t l2d:1; 485 uint64_t l2d:1;
@@ -420,6 +550,79 @@ union cvmx_l2c_dut {
420 struct cvmx_l2c_dut_s cn58xxp1; 550 struct cvmx_l2c_dut_s cn58xxp1;
421}; 551};
422 552
553union cvmx_l2c_dut_mapx {
554 uint64_t u64;
555 struct cvmx_l2c_dut_mapx_s {
556 uint64_t reserved_38_63:26;
557 uint64_t tag:28;
558 uint64_t reserved_1_9:9;
559 uint64_t valid:1;
560 } s;
561 struct cvmx_l2c_dut_mapx_s cn63xx;
562 struct cvmx_l2c_dut_mapx_s cn63xxp1;
563};
564
565union cvmx_l2c_err_tdtx {
566 uint64_t u64;
567 struct cvmx_l2c_err_tdtx_s {
568 uint64_t dbe:1;
569 uint64_t sbe:1;
570 uint64_t vdbe:1;
571 uint64_t vsbe:1;
572 uint64_t syn:10;
573 uint64_t reserved_21_49:29;
574 uint64_t wayidx:17;
575 uint64_t reserved_2_3:2;
576 uint64_t type:2;
577 } s;
578 struct cvmx_l2c_err_tdtx_s cn63xx;
579 struct cvmx_l2c_err_tdtx_s cn63xxp1;
580};
581
582union cvmx_l2c_err_ttgx {
583 uint64_t u64;
584 struct cvmx_l2c_err_ttgx_s {
585 uint64_t dbe:1;
586 uint64_t sbe:1;
587 uint64_t noway:1;
588 uint64_t reserved_56_60:5;
589 uint64_t syn:6;
590 uint64_t reserved_21_49:29;
591 uint64_t wayidx:14;
592 uint64_t reserved_2_6:5;
593 uint64_t type:2;
594 } s;
595 struct cvmx_l2c_err_ttgx_s cn63xx;
596 struct cvmx_l2c_err_ttgx_s cn63xxp1;
597};
598
599union cvmx_l2c_err_vbfx {
600 uint64_t u64;
601 struct cvmx_l2c_err_vbfx_s {
602 uint64_t reserved_62_63:2;
603 uint64_t vdbe:1;
604 uint64_t vsbe:1;
605 uint64_t vsyn:10;
606 uint64_t reserved_2_49:48;
607 uint64_t type:2;
608 } s;
609 struct cvmx_l2c_err_vbfx_s cn63xx;
610 struct cvmx_l2c_err_vbfx_s cn63xxp1;
611};
612
613union cvmx_l2c_err_xmc {
614 uint64_t u64;
615 struct cvmx_l2c_err_xmc_s {
616 uint64_t cmd:6;
617 uint64_t reserved_52_57:6;
618 uint64_t sid:4;
619 uint64_t reserved_38_47:10;
620 uint64_t addr:38;
621 } s;
622 struct cvmx_l2c_err_xmc_s cn63xx;
623 struct cvmx_l2c_err_xmc_s cn63xxp1;
624};
625
423union cvmx_l2c_grpwrr0 { 626union cvmx_l2c_grpwrr0 {
424 uint64_t u64; 627 uint64_t u64;
425 struct cvmx_l2c_grpwrr0_s { 628 struct cvmx_l2c_grpwrr0_s {
@@ -464,6 +667,60 @@ union cvmx_l2c_int_en {
464 struct cvmx_l2c_int_en_s cn56xxp1; 667 struct cvmx_l2c_int_en_s cn56xxp1;
465}; 668};
466 669
670union cvmx_l2c_int_ena {
671 uint64_t u64;
672 struct cvmx_l2c_int_ena_s {
673 uint64_t reserved_8_63:56;
674 uint64_t bigrd:1;
675 uint64_t bigwr:1;
676 uint64_t vrtpe:1;
677 uint64_t vrtadrng:1;
678 uint64_t vrtidrng:1;
679 uint64_t vrtwr:1;
680 uint64_t holewr:1;
681 uint64_t holerd:1;
682 } s;
683 struct cvmx_l2c_int_ena_s cn63xx;
684 struct cvmx_l2c_int_ena_cn63xxp1 {
685 uint64_t reserved_6_63:58;
686 uint64_t vrtpe:1;
687 uint64_t vrtadrng:1;
688 uint64_t vrtidrng:1;
689 uint64_t vrtwr:1;
690 uint64_t holewr:1;
691 uint64_t holerd:1;
692 } cn63xxp1;
693};
694
695union cvmx_l2c_int_reg {
696 uint64_t u64;
697 struct cvmx_l2c_int_reg_s {
698 uint64_t reserved_17_63:47;
699 uint64_t tad0:1;
700 uint64_t reserved_8_15:8;
701 uint64_t bigrd:1;
702 uint64_t bigwr:1;
703 uint64_t vrtpe:1;
704 uint64_t vrtadrng:1;
705 uint64_t vrtidrng:1;
706 uint64_t vrtwr:1;
707 uint64_t holewr:1;
708 uint64_t holerd:1;
709 } s;
710 struct cvmx_l2c_int_reg_s cn63xx;
711 struct cvmx_l2c_int_reg_cn63xxp1 {
712 uint64_t reserved_17_63:47;
713 uint64_t tad0:1;
714 uint64_t reserved_6_15:10;
715 uint64_t vrtpe:1;
716 uint64_t vrtadrng:1;
717 uint64_t vrtidrng:1;
718 uint64_t vrtwr:1;
719 uint64_t holewr:1;
720 uint64_t holerd:1;
721 } cn63xxp1;
722};
723
467union cvmx_l2c_int_stat { 724union cvmx_l2c_int_stat {
468 uint64_t u64; 725 uint64_t u64;
469 struct cvmx_l2c_int_stat_s { 726 struct cvmx_l2c_int_stat_s {
@@ -484,6 +741,24 @@ union cvmx_l2c_int_stat {
484 struct cvmx_l2c_int_stat_s cn56xxp1; 741 struct cvmx_l2c_int_stat_s cn56xxp1;
485}; 742};
486 743
744union cvmx_l2c_iocx_pfc {
745 uint64_t u64;
746 struct cvmx_l2c_iocx_pfc_s {
747 uint64_t count:64;
748 } s;
749 struct cvmx_l2c_iocx_pfc_s cn63xx;
750 struct cvmx_l2c_iocx_pfc_s cn63xxp1;
751};
752
753union cvmx_l2c_iorx_pfc {
754 uint64_t u64;
755 struct cvmx_l2c_iorx_pfc_s {
756 uint64_t count:64;
757 } s;
758 struct cvmx_l2c_iorx_pfc_s cn63xx;
759 struct cvmx_l2c_iorx_pfc_s cn63xxp1;
760};
761
487union cvmx_l2c_lckbase { 762union cvmx_l2c_lckbase {
488 uint64_t u64; 763 uint64_t u64;
489 struct cvmx_l2c_lckbase_s { 764 struct cvmx_l2c_lckbase_s {
@@ -855,6 +1130,59 @@ union cvmx_l2c_ppgrp {
855 struct cvmx_l2c_ppgrp_s cn56xxp1; 1130 struct cvmx_l2c_ppgrp_s cn56xxp1;
856}; 1131};
857 1132
1133union cvmx_l2c_qos_iobx {
1134 uint64_t u64;
1135 struct cvmx_l2c_qos_iobx_s {
1136 uint64_t reserved_6_63:58;
1137 uint64_t dwblvl:2;
1138 uint64_t reserved_2_3:2;
1139 uint64_t lvl:2;
1140 } s;
1141 struct cvmx_l2c_qos_iobx_s cn63xx;
1142 struct cvmx_l2c_qos_iobx_s cn63xxp1;
1143};
1144
1145union cvmx_l2c_qos_ppx {
1146 uint64_t u64;
1147 struct cvmx_l2c_qos_ppx_s {
1148 uint64_t reserved_2_63:62;
1149 uint64_t lvl:2;
1150 } s;
1151 struct cvmx_l2c_qos_ppx_s cn63xx;
1152 struct cvmx_l2c_qos_ppx_s cn63xxp1;
1153};
1154
1155union cvmx_l2c_qos_wgt {
1156 uint64_t u64;
1157 struct cvmx_l2c_qos_wgt_s {
1158 uint64_t reserved_32_63:32;
1159 uint64_t wgt3:8;
1160 uint64_t wgt2:8;
1161 uint64_t wgt1:8;
1162 uint64_t wgt0:8;
1163 } s;
1164 struct cvmx_l2c_qos_wgt_s cn63xx;
1165 struct cvmx_l2c_qos_wgt_s cn63xxp1;
1166};
1167
1168union cvmx_l2c_rscx_pfc {
1169 uint64_t u64;
1170 struct cvmx_l2c_rscx_pfc_s {
1171 uint64_t count:64;
1172 } s;
1173 struct cvmx_l2c_rscx_pfc_s cn63xx;
1174 struct cvmx_l2c_rscx_pfc_s cn63xxp1;
1175};
1176
1177union cvmx_l2c_rsdx_pfc {
1178 uint64_t u64;
1179 struct cvmx_l2c_rsdx_pfc_s {
1180 uint64_t count:64;
1181 } s;
1182 struct cvmx_l2c_rsdx_pfc_s cn63xx;
1183 struct cvmx_l2c_rsdx_pfc_s cn63xxp1;
1184};
1185
858union cvmx_l2c_spar0 { 1186union cvmx_l2c_spar0 {
859 uint64_t u64; 1187 uint64_t u64;
860 struct cvmx_l2c_spar0_s { 1188 struct cvmx_l2c_spar0_s {
@@ -960,4 +1288,282 @@ union cvmx_l2c_spar4 {
960 struct cvmx_l2c_spar4_s cn58xxp1; 1288 struct cvmx_l2c_spar4_s cn58xxp1;
961}; 1289};
962 1290
1291union cvmx_l2c_tadx_ecc0 {
1292 uint64_t u64;
1293 struct cvmx_l2c_tadx_ecc0_s {
1294 uint64_t reserved_58_63:6;
1295 uint64_t ow3ecc:10;
1296 uint64_t reserved_42_47:6;
1297 uint64_t ow2ecc:10;
1298 uint64_t reserved_26_31:6;
1299 uint64_t ow1ecc:10;
1300 uint64_t reserved_10_15:6;
1301 uint64_t ow0ecc:10;
1302 } s;
1303 struct cvmx_l2c_tadx_ecc0_s cn63xx;
1304 struct cvmx_l2c_tadx_ecc0_s cn63xxp1;
1305};
1306
1307union cvmx_l2c_tadx_ecc1 {
1308 uint64_t u64;
1309 struct cvmx_l2c_tadx_ecc1_s {
1310 uint64_t reserved_58_63:6;
1311 uint64_t ow7ecc:10;
1312 uint64_t reserved_42_47:6;
1313 uint64_t ow6ecc:10;
1314 uint64_t reserved_26_31:6;
1315 uint64_t ow5ecc:10;
1316 uint64_t reserved_10_15:6;
1317 uint64_t ow4ecc:10;
1318 } s;
1319 struct cvmx_l2c_tadx_ecc1_s cn63xx;
1320 struct cvmx_l2c_tadx_ecc1_s cn63xxp1;
1321};
1322
1323union cvmx_l2c_tadx_ien {
1324 uint64_t u64;
1325 struct cvmx_l2c_tadx_ien_s {
1326 uint64_t reserved_9_63:55;
1327 uint64_t wrdislmc:1;
1328 uint64_t rddislmc:1;
1329 uint64_t noway:1;
1330 uint64_t vbfdbe:1;
1331 uint64_t vbfsbe:1;
1332 uint64_t tagdbe:1;
1333 uint64_t tagsbe:1;
1334 uint64_t l2ddbe:1;
1335 uint64_t l2dsbe:1;
1336 } s;
1337 struct cvmx_l2c_tadx_ien_s cn63xx;
1338 struct cvmx_l2c_tadx_ien_cn63xxp1 {
1339 uint64_t reserved_7_63:57;
1340 uint64_t noway:1;
1341 uint64_t vbfdbe:1;
1342 uint64_t vbfsbe:1;
1343 uint64_t tagdbe:1;
1344 uint64_t tagsbe:1;
1345 uint64_t l2ddbe:1;
1346 uint64_t l2dsbe:1;
1347 } cn63xxp1;
1348};
1349
1350union cvmx_l2c_tadx_int {
1351 uint64_t u64;
1352 struct cvmx_l2c_tadx_int_s {
1353 uint64_t reserved_9_63:55;
1354 uint64_t wrdislmc:1;
1355 uint64_t rddislmc:1;
1356 uint64_t noway:1;
1357 uint64_t vbfdbe:1;
1358 uint64_t vbfsbe:1;
1359 uint64_t tagdbe:1;
1360 uint64_t tagsbe:1;
1361 uint64_t l2ddbe:1;
1362 uint64_t l2dsbe:1;
1363 } s;
1364 struct cvmx_l2c_tadx_int_s cn63xx;
1365};
1366
1367union cvmx_l2c_tadx_pfc0 {
1368 uint64_t u64;
1369 struct cvmx_l2c_tadx_pfc0_s {
1370 uint64_t count:64;
1371 } s;
1372 struct cvmx_l2c_tadx_pfc0_s cn63xx;
1373 struct cvmx_l2c_tadx_pfc0_s cn63xxp1;
1374};
1375
1376union cvmx_l2c_tadx_pfc1 {
1377 uint64_t u64;
1378 struct cvmx_l2c_tadx_pfc1_s {
1379 uint64_t count:64;
1380 } s;
1381 struct cvmx_l2c_tadx_pfc1_s cn63xx;
1382 struct cvmx_l2c_tadx_pfc1_s cn63xxp1;
1383};
1384
1385union cvmx_l2c_tadx_pfc2 {
1386 uint64_t u64;
1387 struct cvmx_l2c_tadx_pfc2_s {
1388 uint64_t count:64;
1389 } s;
1390 struct cvmx_l2c_tadx_pfc2_s cn63xx;
1391 struct cvmx_l2c_tadx_pfc2_s cn63xxp1;
1392};
1393
1394union cvmx_l2c_tadx_pfc3 {
1395 uint64_t u64;
1396 struct cvmx_l2c_tadx_pfc3_s {
1397 uint64_t count:64;
1398 } s;
1399 struct cvmx_l2c_tadx_pfc3_s cn63xx;
1400 struct cvmx_l2c_tadx_pfc3_s cn63xxp1;
1401};
1402
1403union cvmx_l2c_tadx_prf {
1404 uint64_t u64;
1405 struct cvmx_l2c_tadx_prf_s {
1406 uint64_t reserved_32_63:32;
1407 uint64_t cnt3sel:8;
1408 uint64_t cnt2sel:8;
1409 uint64_t cnt1sel:8;
1410 uint64_t cnt0sel:8;
1411 } s;
1412 struct cvmx_l2c_tadx_prf_s cn63xx;
1413 struct cvmx_l2c_tadx_prf_s cn63xxp1;
1414};
1415
1416union cvmx_l2c_tadx_tag {
1417 uint64_t u64;
1418 struct cvmx_l2c_tadx_tag_s {
1419 uint64_t reserved_46_63:18;
1420 uint64_t ecc:6;
1421 uint64_t reserved_36_39:4;
1422 uint64_t tag:19;
1423 uint64_t reserved_4_16:13;
1424 uint64_t use:1;
1425 uint64_t valid:1;
1426 uint64_t dirty:1;
1427 uint64_t lock:1;
1428 } s;
1429 struct cvmx_l2c_tadx_tag_s cn63xx;
1430 struct cvmx_l2c_tadx_tag_s cn63xxp1;
1431};
1432
1433union cvmx_l2c_ver_id {
1434 uint64_t u64;
1435 struct cvmx_l2c_ver_id_s {
1436 uint64_t mask:64;
1437 } s;
1438 struct cvmx_l2c_ver_id_s cn63xx;
1439 struct cvmx_l2c_ver_id_s cn63xxp1;
1440};
1441
1442union cvmx_l2c_ver_iob {
1443 uint64_t u64;
1444 struct cvmx_l2c_ver_iob_s {
1445 uint64_t reserved_1_63:63;
1446 uint64_t mask:1;
1447 } s;
1448 struct cvmx_l2c_ver_iob_s cn63xx;
1449 struct cvmx_l2c_ver_iob_s cn63xxp1;
1450};
1451
1452union cvmx_l2c_ver_msc {
1453 uint64_t u64;
1454 struct cvmx_l2c_ver_msc_s {
1455 uint64_t reserved_2_63:62;
1456 uint64_t invl2:1;
1457 uint64_t dwb:1;
1458 } s;
1459 struct cvmx_l2c_ver_msc_s cn63xx;
1460};
1461
1462union cvmx_l2c_ver_pp {
1463 uint64_t u64;
1464 struct cvmx_l2c_ver_pp_s {
1465 uint64_t reserved_6_63:58;
1466 uint64_t mask:6;
1467 } s;
1468 struct cvmx_l2c_ver_pp_s cn63xx;
1469 struct cvmx_l2c_ver_pp_s cn63xxp1;
1470};
1471
1472union cvmx_l2c_virtid_iobx {
1473 uint64_t u64;
1474 struct cvmx_l2c_virtid_iobx_s {
1475 uint64_t reserved_14_63:50;
1476 uint64_t dwbid:6;
1477 uint64_t reserved_6_7:2;
1478 uint64_t id:6;
1479 } s;
1480 struct cvmx_l2c_virtid_iobx_s cn63xx;
1481 struct cvmx_l2c_virtid_iobx_s cn63xxp1;
1482};
1483
1484union cvmx_l2c_virtid_ppx {
1485 uint64_t u64;
1486 struct cvmx_l2c_virtid_ppx_s {
1487 uint64_t reserved_6_63:58;
1488 uint64_t id:6;
1489 } s;
1490 struct cvmx_l2c_virtid_ppx_s cn63xx;
1491 struct cvmx_l2c_virtid_ppx_s cn63xxp1;
1492};
1493
1494union cvmx_l2c_vrt_ctl {
1495 uint64_t u64;
1496 struct cvmx_l2c_vrt_ctl_s {
1497 uint64_t reserved_9_63:55;
1498 uint64_t ooberr:1;
1499 uint64_t reserved_7_7:1;
1500 uint64_t memsz:3;
1501 uint64_t numid:3;
1502 uint64_t enable:1;
1503 } s;
1504 struct cvmx_l2c_vrt_ctl_s cn63xx;
1505 struct cvmx_l2c_vrt_ctl_s cn63xxp1;
1506};
1507
1508union cvmx_l2c_vrt_memx {
1509 uint64_t u64;
1510 struct cvmx_l2c_vrt_memx_s {
1511 uint64_t reserved_36_63:28;
1512 uint64_t parity:4;
1513 uint64_t data:32;
1514 } s;
1515 struct cvmx_l2c_vrt_memx_s cn63xx;
1516 struct cvmx_l2c_vrt_memx_s cn63xxp1;
1517};
1518
1519union cvmx_l2c_wpar_iobx {
1520 uint64_t u64;
1521 struct cvmx_l2c_wpar_iobx_s {
1522 uint64_t reserved_16_63:48;
1523 uint64_t mask:16;
1524 } s;
1525 struct cvmx_l2c_wpar_iobx_s cn63xx;
1526 struct cvmx_l2c_wpar_iobx_s cn63xxp1;
1527};
1528
1529union cvmx_l2c_wpar_ppx {
1530 uint64_t u64;
1531 struct cvmx_l2c_wpar_ppx_s {
1532 uint64_t reserved_16_63:48;
1533 uint64_t mask:16;
1534 } s;
1535 struct cvmx_l2c_wpar_ppx_s cn63xx;
1536 struct cvmx_l2c_wpar_ppx_s cn63xxp1;
1537};
1538
1539union cvmx_l2c_xmcx_pfc {
1540 uint64_t u64;
1541 struct cvmx_l2c_xmcx_pfc_s {
1542 uint64_t count:64;
1543 } s;
1544 struct cvmx_l2c_xmcx_pfc_s cn63xx;
1545 struct cvmx_l2c_xmcx_pfc_s cn63xxp1;
1546};
1547
1548union cvmx_l2c_xmc_cmd {
1549 uint64_t u64;
1550 struct cvmx_l2c_xmc_cmd_s {
1551 uint64_t inuse:1;
1552 uint64_t cmd:6;
1553 uint64_t reserved_38_56:19;
1554 uint64_t addr:38;
1555 } s;
1556 struct cvmx_l2c_xmc_cmd_s cn63xx;
1557 struct cvmx_l2c_xmc_cmd_s cn63xxp1;
1558};
1559
1560union cvmx_l2c_xmdx_pfc {
1561 uint64_t u64;
1562 struct cvmx_l2c_xmdx_pfc_s {
1563 uint64_t count:64;
1564 } s;
1565 struct cvmx_l2c_xmdx_pfc_s cn63xx;
1566 struct cvmx_l2c_xmdx_pfc_s cn63xxp1;
1567};
1568
963#endif 1569#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-l2c.h b/arch/mips/include/asm/octeon/cvmx-l2c.h
index 2a8c0902ea50..0b32c5b118e2 100644
--- a/arch/mips/include/asm/octeon/cvmx-l2c.h
+++ b/arch/mips/include/asm/octeon/cvmx-l2c.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -26,7 +26,6 @@
26 ***********************license end**************************************/ 26 ***********************license end**************************************/
27 27
28/* 28/*
29 *
30 * Interface to the Level 2 Cache (L2C) control, measurement, and debugging 29 * Interface to the Level 2 Cache (L2C) control, measurement, and debugging
31 * facilities. 30 * facilities.
32 */ 31 */
@@ -34,93 +33,126 @@
34#ifndef __CVMX_L2C_H__ 33#ifndef __CVMX_L2C_H__
35#define __CVMX_L2C_H__ 34#define __CVMX_L2C_H__
36 35
37/* Deprecated macro, use function */ 36#define CVMX_L2_ASSOC cvmx_l2c_get_num_assoc() /* Deprecated macro, use function */
38#define CVMX_L2_ASSOC cvmx_l2c_get_num_assoc() 37#define CVMX_L2_SET_BITS cvmx_l2c_get_set_bits() /* Deprecated macro, use function */
39 38#define CVMX_L2_SETS cvmx_l2c_get_num_sets() /* Deprecated macro, use function */
40/* Deprecated macro, use function */
41#define CVMX_L2_SET_BITS cvmx_l2c_get_set_bits()
42 39
43/* Deprecated macro, use function */
44#define CVMX_L2_SETS cvmx_l2c_get_num_sets()
45 40
46#define CVMX_L2C_IDX_ADDR_SHIFT 7 /* based on 128 byte cache line size */ 41#define CVMX_L2C_IDX_ADDR_SHIFT 7 /* based on 128 byte cache line size */
47#define CVMX_L2C_IDX_MASK (cvmx_l2c_get_num_sets() - 1) 42#define CVMX_L2C_IDX_MASK (cvmx_l2c_get_num_sets() - 1)
48 43
49/* Defines for index aliasing computations */ 44/* Defines for index aliasing computations */
50#define CVMX_L2C_TAG_ADDR_ALIAS_SHIFT \ 45#define CVMX_L2C_TAG_ADDR_ALIAS_SHIFT (CVMX_L2C_IDX_ADDR_SHIFT + cvmx_l2c_get_set_bits())
51 (CVMX_L2C_IDX_ADDR_SHIFT + cvmx_l2c_get_set_bits()) 46#define CVMX_L2C_ALIAS_MASK (CVMX_L2C_IDX_MASK << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT)
47#define CVMX_L2C_MEMBANK_SELECT_SIZE 4096
52 48
53#define CVMX_L2C_ALIAS_MASK \ 49/* Defines for Virtualizations, valid only from Octeon II onwards. */
54 (CVMX_L2C_IDX_MASK << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT) 50#define CVMX_L2C_VRT_MAX_VIRTID_ALLOWED ((OCTEON_IS_MODEL(OCTEON_CN63XX)) ? 64 : 0)
51#define CVMX_L2C_VRT_MAX_MEMSZ_ALLOWED ((OCTEON_IS_MODEL(OCTEON_CN63XX)) ? 32 : 0)
55 52
56union cvmx_l2c_tag { 53union cvmx_l2c_tag {
57 uint64_t u64; 54 uint64_t u64;
58 struct { 55 struct {
59 uint64_t reserved:28; 56 uint64_t reserved:28;
60 uint64_t V:1; /* Line valid */ 57 uint64_t V:1; /* Line valid */
61 uint64_t D:1; /* Line dirty */ 58 uint64_t D:1; /* Line dirty */
62 uint64_t L:1; /* Line locked */ 59 uint64_t L:1; /* Line locked */
63 uint64_t U:1; /* Use, LRU eviction */ 60 uint64_t U:1; /* Use, LRU eviction */
64 uint64_t addr:32; /* Phys mem (not all bits valid) */ 61 uint64_t addr:32; /* Phys mem (not all bits valid) */
65 } s; 62 } s;
66}; 63};
67 64
65/* Number of L2C Tag-and-data sections (TADs) that are connected to LMC. */
66#define CVMX_L2C_TADS 1
67
68 /* L2C Performance Counter events. */ 68 /* L2C Performance Counter events. */
69enum cvmx_l2c_event { 69enum cvmx_l2c_event {
70 CVMX_L2C_EVENT_CYCLES = 0, 70 CVMX_L2C_EVENT_CYCLES = 0,
71 CVMX_L2C_EVENT_INSTRUCTION_MISS = 1, 71 CVMX_L2C_EVENT_INSTRUCTION_MISS = 1,
72 CVMX_L2C_EVENT_INSTRUCTION_HIT = 2, 72 CVMX_L2C_EVENT_INSTRUCTION_HIT = 2,
73 CVMX_L2C_EVENT_DATA_MISS = 3, 73 CVMX_L2C_EVENT_DATA_MISS = 3,
74 CVMX_L2C_EVENT_DATA_HIT = 4, 74 CVMX_L2C_EVENT_DATA_HIT = 4,
75 CVMX_L2C_EVENT_MISS = 5, 75 CVMX_L2C_EVENT_MISS = 5,
76 CVMX_L2C_EVENT_HIT = 6, 76 CVMX_L2C_EVENT_HIT = 6,
77 CVMX_L2C_EVENT_VICTIM_HIT = 7, 77 CVMX_L2C_EVENT_VICTIM_HIT = 7,
78 CVMX_L2C_EVENT_INDEX_CONFLICT = 8, 78 CVMX_L2C_EVENT_INDEX_CONFLICT = 8,
79 CVMX_L2C_EVENT_TAG_PROBE = 9, 79 CVMX_L2C_EVENT_TAG_PROBE = 9,
80 CVMX_L2C_EVENT_TAG_UPDATE = 10, 80 CVMX_L2C_EVENT_TAG_UPDATE = 10,
81 CVMX_L2C_EVENT_TAG_COMPLETE = 11, 81 CVMX_L2C_EVENT_TAG_COMPLETE = 11,
82 CVMX_L2C_EVENT_TAG_DIRTY = 12, 82 CVMX_L2C_EVENT_TAG_DIRTY = 12,
83 CVMX_L2C_EVENT_DATA_STORE_NOP = 13, 83 CVMX_L2C_EVENT_DATA_STORE_NOP = 13,
84 CVMX_L2C_EVENT_DATA_STORE_READ = 14, 84 CVMX_L2C_EVENT_DATA_STORE_READ = 14,
85 CVMX_L2C_EVENT_DATA_STORE_WRITE = 15, 85 CVMX_L2C_EVENT_DATA_STORE_WRITE = 15,
86 CVMX_L2C_EVENT_FILL_DATA_VALID = 16, 86 CVMX_L2C_EVENT_FILL_DATA_VALID = 16,
87 CVMX_L2C_EVENT_WRITE_REQUEST = 17, 87 CVMX_L2C_EVENT_WRITE_REQUEST = 17,
88 CVMX_L2C_EVENT_READ_REQUEST = 18, 88 CVMX_L2C_EVENT_READ_REQUEST = 18,
89 CVMX_L2C_EVENT_WRITE_DATA_VALID = 19, 89 CVMX_L2C_EVENT_WRITE_DATA_VALID = 19,
90 CVMX_L2C_EVENT_XMC_NOP = 20, 90 CVMX_L2C_EVENT_XMC_NOP = 20,
91 CVMX_L2C_EVENT_XMC_LDT = 21, 91 CVMX_L2C_EVENT_XMC_LDT = 21,
92 CVMX_L2C_EVENT_XMC_LDI = 22, 92 CVMX_L2C_EVENT_XMC_LDI = 22,
93 CVMX_L2C_EVENT_XMC_LDD = 23, 93 CVMX_L2C_EVENT_XMC_LDD = 23,
94 CVMX_L2C_EVENT_XMC_STF = 24, 94 CVMX_L2C_EVENT_XMC_STF = 24,
95 CVMX_L2C_EVENT_XMC_STT = 25, 95 CVMX_L2C_EVENT_XMC_STT = 25,
96 CVMX_L2C_EVENT_XMC_STP = 26, 96 CVMX_L2C_EVENT_XMC_STP = 26,
97 CVMX_L2C_EVENT_XMC_STC = 27, 97 CVMX_L2C_EVENT_XMC_STC = 27,
98 CVMX_L2C_EVENT_XMC_DWB = 28, 98 CVMX_L2C_EVENT_XMC_DWB = 28,
99 CVMX_L2C_EVENT_XMC_PL2 = 29, 99 CVMX_L2C_EVENT_XMC_PL2 = 29,
100 CVMX_L2C_EVENT_XMC_PSL1 = 30, 100 CVMX_L2C_EVENT_XMC_PSL1 = 30,
101 CVMX_L2C_EVENT_XMC_IOBLD = 31, 101 CVMX_L2C_EVENT_XMC_IOBLD = 31,
102 CVMX_L2C_EVENT_XMC_IOBST = 32, 102 CVMX_L2C_EVENT_XMC_IOBST = 32,
103 CVMX_L2C_EVENT_XMC_IOBDMA = 33, 103 CVMX_L2C_EVENT_XMC_IOBDMA = 33,
104 CVMX_L2C_EVENT_XMC_IOBRSP = 34, 104 CVMX_L2C_EVENT_XMC_IOBRSP = 34,
105 CVMX_L2C_EVENT_XMC_BUS_VALID = 35, 105 CVMX_L2C_EVENT_XMC_BUS_VALID = 35,
106 CVMX_L2C_EVENT_XMC_MEM_DATA = 36, 106 CVMX_L2C_EVENT_XMC_MEM_DATA = 36,
107 CVMX_L2C_EVENT_XMC_REFL_DATA = 37, 107 CVMX_L2C_EVENT_XMC_REFL_DATA = 37,
108 CVMX_L2C_EVENT_XMC_IOBRSP_DATA = 38, 108 CVMX_L2C_EVENT_XMC_IOBRSP_DATA = 38,
109 CVMX_L2C_EVENT_RSC_NOP = 39, 109 CVMX_L2C_EVENT_RSC_NOP = 39,
110 CVMX_L2C_EVENT_RSC_STDN = 40, 110 CVMX_L2C_EVENT_RSC_STDN = 40,
111 CVMX_L2C_EVENT_RSC_FILL = 41, 111 CVMX_L2C_EVENT_RSC_FILL = 41,
112 CVMX_L2C_EVENT_RSC_REFL = 42, 112 CVMX_L2C_EVENT_RSC_REFL = 42,
113 CVMX_L2C_EVENT_RSC_STIN = 43, 113 CVMX_L2C_EVENT_RSC_STIN = 43,
114 CVMX_L2C_EVENT_RSC_SCIN = 44, 114 CVMX_L2C_EVENT_RSC_SCIN = 44,
115 CVMX_L2C_EVENT_RSC_SCFL = 45, 115 CVMX_L2C_EVENT_RSC_SCFL = 45,
116 CVMX_L2C_EVENT_RSC_SCDN = 46, 116 CVMX_L2C_EVENT_RSC_SCDN = 46,
117 CVMX_L2C_EVENT_RSC_DATA_VALID = 47, 117 CVMX_L2C_EVENT_RSC_DATA_VALID = 47,
118 CVMX_L2C_EVENT_RSC_VALID_FILL = 48, 118 CVMX_L2C_EVENT_RSC_VALID_FILL = 48,
119 CVMX_L2C_EVENT_RSC_VALID_STRSP = 49, 119 CVMX_L2C_EVENT_RSC_VALID_STRSP = 49,
120 CVMX_L2C_EVENT_RSC_VALID_REFL = 50, 120 CVMX_L2C_EVENT_RSC_VALID_REFL = 50,
121 CVMX_L2C_EVENT_LRF_REQ = 51, 121 CVMX_L2C_EVENT_LRF_REQ = 51,
122 CVMX_L2C_EVENT_DT_RD_ALLOC = 52, 122 CVMX_L2C_EVENT_DT_RD_ALLOC = 52,
123 CVMX_L2C_EVENT_DT_WR_INVAL = 53 123 CVMX_L2C_EVENT_DT_WR_INVAL = 53,
124 CVMX_L2C_EVENT_MAX
125};
126
127/* L2C Performance Counter events for Octeon2. */
128enum cvmx_l2c_tad_event {
129 CVMX_L2C_TAD_EVENT_NONE = 0,
130 CVMX_L2C_TAD_EVENT_TAG_HIT = 1,
131 CVMX_L2C_TAD_EVENT_TAG_MISS = 2,
132 CVMX_L2C_TAD_EVENT_TAG_NOALLOC = 3,
133 CVMX_L2C_TAD_EVENT_TAG_VICTIM = 4,
134 CVMX_L2C_TAD_EVENT_SC_FAIL = 5,
135 CVMX_L2C_TAD_EVENT_SC_PASS = 6,
136 CVMX_L2C_TAD_EVENT_LFB_VALID = 7,
137 CVMX_L2C_TAD_EVENT_LFB_WAIT_LFB = 8,
138 CVMX_L2C_TAD_EVENT_LFB_WAIT_VAB = 9,
139 CVMX_L2C_TAD_EVENT_QUAD0_INDEX = 128,
140 CVMX_L2C_TAD_EVENT_QUAD0_READ = 129,
141 CVMX_L2C_TAD_EVENT_QUAD0_BANK = 130,
142 CVMX_L2C_TAD_EVENT_QUAD0_WDAT = 131,
143 CVMX_L2C_TAD_EVENT_QUAD1_INDEX = 144,
144 CVMX_L2C_TAD_EVENT_QUAD1_READ = 145,
145 CVMX_L2C_TAD_EVENT_QUAD1_BANK = 146,
146 CVMX_L2C_TAD_EVENT_QUAD1_WDAT = 147,
147 CVMX_L2C_TAD_EVENT_QUAD2_INDEX = 160,
148 CVMX_L2C_TAD_EVENT_QUAD2_READ = 161,
149 CVMX_L2C_TAD_EVENT_QUAD2_BANK = 162,
150 CVMX_L2C_TAD_EVENT_QUAD2_WDAT = 163,
151 CVMX_L2C_TAD_EVENT_QUAD3_INDEX = 176,
152 CVMX_L2C_TAD_EVENT_QUAD3_READ = 177,
153 CVMX_L2C_TAD_EVENT_QUAD3_BANK = 178,
154 CVMX_L2C_TAD_EVENT_QUAD3_WDAT = 179,
155 CVMX_L2C_TAD_EVENT_MAX
124}; 156};
125 157
126/** 158/**
@@ -132,10 +164,10 @@ enum cvmx_l2c_event {
132 * @clear_on_read: When asserted, any read of the performance counter 164 * @clear_on_read: When asserted, any read of the performance counter
133 * clears the counter. 165 * clears the counter.
134 * 166 *
135 * The routine does not clear the counter. 167 * @note The routine does not clear the counter.
136 */ 168 */
137void cvmx_l2c_config_perf(uint32_t counter, 169void cvmx_l2c_config_perf(uint32_t counter, enum cvmx_l2c_event event, uint32_t clear_on_read);
138 enum cvmx_l2c_event event, uint32_t clear_on_read); 170
139/** 171/**
140 * Read the given L2 Cache performance counter. The counter must be configured 172 * Read the given L2 Cache performance counter. The counter must be configured
141 * before reading, but this routine does not enforce this requirement. 173 * before reading, but this routine does not enforce this requirement.
@@ -160,18 +192,18 @@ int cvmx_l2c_get_core_way_partition(uint32_t core);
160/** 192/**
161 * Partitions the L2 cache for a core 193 * Partitions the L2 cache for a core
162 * 194 *
163 * @core: The core that the partitioning applies to. 195 * @core: The core that the partitioning applies to.
196 * @mask: The partitioning of the ways expressed as a binary
197 * mask. A 0 bit allows the core to evict cache lines from
198 * a way, while a 1 bit blocks the core from evicting any
199 * lines from that way. There must be at least one allowed
200 * way (0 bit) in the mask.
164 * 201 *
165 * @mask: The partitioning of the ways expressed as a binary mask. A 0 202
166 * bit allows the core to evict cache lines from a way, while a 203 * @note If any ways are blocked for all cores and the HW blocks, then
167 * 1 bit blocks the core from evicting any lines from that 204 * those ways will never have any cache lines evicted from them.
168 * way. There must be at least one allowed way (0 bit) in the 205 * All cores and the hardware blocks are free to read from all
169 * mask. 206 * ways regardless of the partitioning.
170 *
171 * If any ways are blocked for all cores and the HW blocks, then those
172 * ways will never have any cache lines evicted from them. All cores
173 * and the hardware blocks are free to read from all ways regardless
174 * of the partitioning.
175 */ 207 */
176int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask); 208int cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask);
177 209
@@ -187,19 +219,21 @@ int cvmx_l2c_get_hw_way_partition(void);
187/** 219/**
188 * Partitions the L2 cache for the hardware blocks. 220 * Partitions the L2 cache for the hardware blocks.
189 * 221 *
190 * @mask: The partitioning of the ways expressed as a binary mask. A 0 222 * @mask: The partitioning of the ways expressed as a binary
191 * bit allows the core to evict cache lines from a way, while a 223 * mask. A 0 bit allows the core to evict cache lines from
192 * 1 bit blocks the core from evicting any lines from that 224 * a way, while a 1 bit blocks the core from evicting any
193 * way. There must be at least one allowed way (0 bit) in the 225 * lines from that way. There must be at least one allowed
194 * mask. 226 * way (0 bit) in the mask.
195 * 227 *
196 * If any ways are blocked for all cores and the HW blocks, then those 228
197 * ways will never have any cache lines evicted from them. All cores 229 * @note If any ways are blocked for all cores and the HW blocks, then
198 * and the hardware blocks are free to read from all ways regardless 230 * those ways will never have any cache lines evicted from them.
199 * of the partitioning. 231 * All cores and the hardware blocks are free to read from all
232 * ways regardless of the partitioning.
200 */ 233 */
201int cvmx_l2c_set_hw_way_partition(uint32_t mask); 234int cvmx_l2c_set_hw_way_partition(uint32_t mask);
202 235
236
203/** 237/**
204 * Locks a line in the L2 cache at the specified physical address 238 * Locks a line in the L2 cache at the specified physical address
205 * 239 *
@@ -263,13 +297,14 @@ int cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len);
263 */ 297 */
264union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index); 298union cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index);
265 299
266/* Wrapper around deprecated old function name */ 300/* Wrapper providing a deprecated old function name */
267static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, 301static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, uint32_t index) __attribute__((deprecated));
268 uint32_t index) 302static inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association, uint32_t index)
269{ 303{
270 return cvmx_l2c_get_tag(association, index); 304 return cvmx_l2c_get_tag(association, index);
271} 305}
272 306
307
273/** 308/**
274 * Returns the cache index for a given physical address 309 * Returns the cache index for a given physical address
275 * 310 *
diff --git a/arch/mips/include/asm/octeon/cvmx-l2d-defs.h b/arch/mips/include/asm/octeon/cvmx-l2d-defs.h
index d7102d455e1b..60543e0e77fc 100644
--- a/arch/mips/include/asm/octeon/cvmx-l2d-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-l2d-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,30 +28,18 @@
28#ifndef __CVMX_L2D_DEFS_H__ 28#ifndef __CVMX_L2D_DEFS_H__
29#define __CVMX_L2D_DEFS_H__ 29#define __CVMX_L2D_DEFS_H__
30 30
31#define CVMX_L2D_BST0 \ 31#define CVMX_L2D_BST0 (CVMX_ADD_IO_SEG(0x0001180080000780ull))
32 CVMX_ADD_IO_SEG(0x0001180080000780ull) 32#define CVMX_L2D_BST1 (CVMX_ADD_IO_SEG(0x0001180080000788ull))
33#define CVMX_L2D_BST1 \ 33#define CVMX_L2D_BST2 (CVMX_ADD_IO_SEG(0x0001180080000790ull))
34 CVMX_ADD_IO_SEG(0x0001180080000788ull) 34#define CVMX_L2D_BST3 (CVMX_ADD_IO_SEG(0x0001180080000798ull))
35#define CVMX_L2D_BST2 \ 35#define CVMX_L2D_ERR (CVMX_ADD_IO_SEG(0x0001180080000010ull))
36 CVMX_ADD_IO_SEG(0x0001180080000790ull) 36#define CVMX_L2D_FADR (CVMX_ADD_IO_SEG(0x0001180080000018ull))
37#define CVMX_L2D_BST3 \ 37#define CVMX_L2D_FSYN0 (CVMX_ADD_IO_SEG(0x0001180080000020ull))
38 CVMX_ADD_IO_SEG(0x0001180080000798ull) 38#define CVMX_L2D_FSYN1 (CVMX_ADD_IO_SEG(0x0001180080000028ull))
39#define CVMX_L2D_ERR \ 39#define CVMX_L2D_FUS0 (CVMX_ADD_IO_SEG(0x00011800800007A0ull))
40 CVMX_ADD_IO_SEG(0x0001180080000010ull) 40#define CVMX_L2D_FUS1 (CVMX_ADD_IO_SEG(0x00011800800007A8ull))
41#define CVMX_L2D_FADR \ 41#define CVMX_L2D_FUS2 (CVMX_ADD_IO_SEG(0x00011800800007B0ull))
42 CVMX_ADD_IO_SEG(0x0001180080000018ull) 42#define CVMX_L2D_FUS3 (CVMX_ADD_IO_SEG(0x00011800800007B8ull))
43#define CVMX_L2D_FSYN0 \
44 CVMX_ADD_IO_SEG(0x0001180080000020ull)
45#define CVMX_L2D_FSYN1 \
46 CVMX_ADD_IO_SEG(0x0001180080000028ull)
47#define CVMX_L2D_FUS0 \
48 CVMX_ADD_IO_SEG(0x00011800800007A0ull)
49#define CVMX_L2D_FUS1 \
50 CVMX_ADD_IO_SEG(0x00011800800007A8ull)
51#define CVMX_L2D_FUS2 \
52 CVMX_ADD_IO_SEG(0x00011800800007B0ull)
53#define CVMX_L2D_FUS3 \
54 CVMX_ADD_IO_SEG(0x00011800800007B8ull)
55 43
56union cvmx_l2d_bst0 { 44union cvmx_l2d_bst0 {
57 uint64_t u64; 45 uint64_t u64;
diff --git a/arch/mips/include/asm/octeon/cvmx-l2t-defs.h b/arch/mips/include/asm/octeon/cvmx-l2t-defs.h
index 2639a3f5ffc2..873968f55eeb 100644
--- a/arch/mips/include/asm/octeon/cvmx-l2t-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-l2t-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,8 +28,7 @@
28#ifndef __CVMX_L2T_DEFS_H__ 28#ifndef __CVMX_L2T_DEFS_H__
29#define __CVMX_L2T_DEFS_H__ 29#define __CVMX_L2T_DEFS_H__
30 30
31#define CVMX_L2T_ERR \ 31#define CVMX_L2T_ERR (CVMX_ADD_IO_SEG(0x0001180080000008ull))
32 CVMX_ADD_IO_SEG(0x0001180080000008ull)
33 32
34union cvmx_l2t_err { 33union cvmx_l2t_err {
35 uint64_t u64; 34 uint64_t u64;
diff --git a/arch/mips/include/asm/octeon/cvmx-led-defs.h b/arch/mips/include/asm/octeon/cvmx-led-defs.h
index 16f174a4dadf..e25173bb8bb7 100644
--- a/arch/mips/include/asm/octeon/cvmx-led-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-led-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,32 +28,19 @@
28#ifndef __CVMX_LED_DEFS_H__ 28#ifndef __CVMX_LED_DEFS_H__
29#define __CVMX_LED_DEFS_H__ 29#define __CVMX_LED_DEFS_H__
30 30
31#define CVMX_LED_BLINK \ 31#define CVMX_LED_BLINK (CVMX_ADD_IO_SEG(0x0001180000001A48ull))
32 CVMX_ADD_IO_SEG(0x0001180000001A48ull) 32#define CVMX_LED_CLK_PHASE (CVMX_ADD_IO_SEG(0x0001180000001A08ull))
33#define CVMX_LED_CLK_PHASE \ 33#define CVMX_LED_CYLON (CVMX_ADD_IO_SEG(0x0001180000001AF8ull))
34 CVMX_ADD_IO_SEG(0x0001180000001A08ull) 34#define CVMX_LED_DBG (CVMX_ADD_IO_SEG(0x0001180000001A18ull))
35#define CVMX_LED_CYLON \ 35#define CVMX_LED_EN (CVMX_ADD_IO_SEG(0x0001180000001A00ull))
36 CVMX_ADD_IO_SEG(0x0001180000001AF8ull) 36#define CVMX_LED_POLARITY (CVMX_ADD_IO_SEG(0x0001180000001A50ull))
37#define CVMX_LED_DBG \ 37#define CVMX_LED_PRT (CVMX_ADD_IO_SEG(0x0001180000001A10ull))
38 CVMX_ADD_IO_SEG(0x0001180000001A18ull) 38#define CVMX_LED_PRT_FMT (CVMX_ADD_IO_SEG(0x0001180000001A30ull))
39#define CVMX_LED_EN \ 39#define CVMX_LED_PRT_STATUSX(offset) (CVMX_ADD_IO_SEG(0x0001180000001A80ull) + ((offset) & 7) * 8)
40 CVMX_ADD_IO_SEG(0x0001180000001A00ull) 40#define CVMX_LED_UDD_CNTX(offset) (CVMX_ADD_IO_SEG(0x0001180000001A20ull) + ((offset) & 1) * 8)
41#define CVMX_LED_POLARITY \ 41#define CVMX_LED_UDD_DATX(offset) (CVMX_ADD_IO_SEG(0x0001180000001A38ull) + ((offset) & 1) * 8)
42 CVMX_ADD_IO_SEG(0x0001180000001A50ull) 42#define CVMX_LED_UDD_DAT_CLRX(offset) (CVMX_ADD_IO_SEG(0x0001180000001AC8ull) + ((offset) & 1) * 16)
43#define CVMX_LED_PRT \ 43#define CVMX_LED_UDD_DAT_SETX(offset) (CVMX_ADD_IO_SEG(0x0001180000001AC0ull) + ((offset) & 1) * 16)
44 CVMX_ADD_IO_SEG(0x0001180000001A10ull)
45#define CVMX_LED_PRT_FMT \
46 CVMX_ADD_IO_SEG(0x0001180000001A30ull)
47#define CVMX_LED_PRT_STATUSX(offset) \
48 CVMX_ADD_IO_SEG(0x0001180000001A80ull + (((offset) & 7) * 8))
49#define CVMX_LED_UDD_CNTX(offset) \
50 CVMX_ADD_IO_SEG(0x0001180000001A20ull + (((offset) & 1) * 8))
51#define CVMX_LED_UDD_DATX(offset) \
52 CVMX_ADD_IO_SEG(0x0001180000001A38ull + (((offset) & 1) * 8))
53#define CVMX_LED_UDD_DAT_CLRX(offset) \
54 CVMX_ADD_IO_SEG(0x0001180000001AC8ull + (((offset) & 1) * 16))
55#define CVMX_LED_UDD_DAT_SETX(offset) \
56 CVMX_ADD_IO_SEG(0x0001180000001AC0ull + (((offset) & 1) * 16))
57 44
58union cvmx_led_blink { 45union cvmx_led_blink {
59 uint64_t u64; 46 uint64_t u64;
diff --git a/arch/mips/include/asm/octeon/cvmx-mio-defs.h b/arch/mips/include/asm/octeon/cvmx-mio-defs.h
index 6555f0530988..52b14a333ad4 100644
--- a/arch/mips/include/asm/octeon/cvmx-mio-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-mio-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,191 +28,117 @@
28#ifndef __CVMX_MIO_DEFS_H__ 28#ifndef __CVMX_MIO_DEFS_H__
29#define __CVMX_MIO_DEFS_H__ 29#define __CVMX_MIO_DEFS_H__
30 30
31#define CVMX_MIO_BOOT_BIST_STAT \ 31#define CVMX_MIO_BOOT_BIST_STAT (CVMX_ADD_IO_SEG(0x00011800000000F8ull))
32 CVMX_ADD_IO_SEG(0x00011800000000F8ull) 32#define CVMX_MIO_BOOT_COMP (CVMX_ADD_IO_SEG(0x00011800000000B8ull))
33#define CVMX_MIO_BOOT_COMP \ 33#define CVMX_MIO_BOOT_DMA_CFGX(offset) (CVMX_ADD_IO_SEG(0x0001180000000100ull) + ((offset) & 3) * 8)
34 CVMX_ADD_IO_SEG(0x00011800000000B8ull) 34#define CVMX_MIO_BOOT_DMA_INTX(offset) (CVMX_ADD_IO_SEG(0x0001180000000138ull) + ((offset) & 3) * 8)
35#define CVMX_MIO_BOOT_DMA_CFGX(offset) \ 35#define CVMX_MIO_BOOT_DMA_INT_ENX(offset) (CVMX_ADD_IO_SEG(0x0001180000000150ull) + ((offset) & 3) * 8)
36 CVMX_ADD_IO_SEG(0x0001180000000100ull + (((offset) & 3) * 8)) 36#define CVMX_MIO_BOOT_DMA_TIMX(offset) (CVMX_ADD_IO_SEG(0x0001180000000120ull) + ((offset) & 3) * 8)
37#define CVMX_MIO_BOOT_DMA_INTX(offset) \ 37#define CVMX_MIO_BOOT_ERR (CVMX_ADD_IO_SEG(0x00011800000000A0ull))
38 CVMX_ADD_IO_SEG(0x0001180000000138ull + (((offset) & 3) * 8)) 38#define CVMX_MIO_BOOT_INT (CVMX_ADD_IO_SEG(0x00011800000000A8ull))
39#define CVMX_MIO_BOOT_DMA_INT_ENX(offset) \ 39#define CVMX_MIO_BOOT_LOC_ADR (CVMX_ADD_IO_SEG(0x0001180000000090ull))
40 CVMX_ADD_IO_SEG(0x0001180000000150ull + (((offset) & 3) * 8)) 40#define CVMX_MIO_BOOT_LOC_CFGX(offset) (CVMX_ADD_IO_SEG(0x0001180000000080ull) + ((offset) & 1) * 8)
41#define CVMX_MIO_BOOT_DMA_TIMX(offset) \ 41#define CVMX_MIO_BOOT_LOC_DAT (CVMX_ADD_IO_SEG(0x0001180000000098ull))
42 CVMX_ADD_IO_SEG(0x0001180000000120ull + (((offset) & 3) * 8)) 42#define CVMX_MIO_BOOT_PIN_DEFS (CVMX_ADD_IO_SEG(0x00011800000000C0ull))
43#define CVMX_MIO_BOOT_ERR \ 43#define CVMX_MIO_BOOT_REG_CFGX(offset) (CVMX_ADD_IO_SEG(0x0001180000000000ull) + ((offset) & 7) * 8)
44 CVMX_ADD_IO_SEG(0x00011800000000A0ull) 44#define CVMX_MIO_BOOT_REG_TIMX(offset) (CVMX_ADD_IO_SEG(0x0001180000000040ull) + ((offset) & 7) * 8)
45#define CVMX_MIO_BOOT_INT \ 45#define CVMX_MIO_BOOT_THR (CVMX_ADD_IO_SEG(0x00011800000000B0ull))
46 CVMX_ADD_IO_SEG(0x00011800000000A8ull) 46#define CVMX_MIO_FUS_BNK_DATX(offset) (CVMX_ADD_IO_SEG(0x0001180000001520ull) + ((offset) & 3) * 8)
47#define CVMX_MIO_BOOT_LOC_ADR \ 47#define CVMX_MIO_FUS_DAT0 (CVMX_ADD_IO_SEG(0x0001180000001400ull))
48 CVMX_ADD_IO_SEG(0x0001180000000090ull) 48#define CVMX_MIO_FUS_DAT1 (CVMX_ADD_IO_SEG(0x0001180000001408ull))
49#define CVMX_MIO_BOOT_LOC_CFGX(offset) \ 49#define CVMX_MIO_FUS_DAT2 (CVMX_ADD_IO_SEG(0x0001180000001410ull))
50 CVMX_ADD_IO_SEG(0x0001180000000080ull + (((offset) & 1) * 8)) 50#define CVMX_MIO_FUS_DAT3 (CVMX_ADD_IO_SEG(0x0001180000001418ull))
51#define CVMX_MIO_BOOT_LOC_DAT \ 51#define CVMX_MIO_FUS_EMA (CVMX_ADD_IO_SEG(0x0001180000001550ull))
52 CVMX_ADD_IO_SEG(0x0001180000000098ull) 52#define CVMX_MIO_FUS_PDF (CVMX_ADD_IO_SEG(0x0001180000001420ull))
53#define CVMX_MIO_BOOT_PIN_DEFS \ 53#define CVMX_MIO_FUS_PLL (CVMX_ADD_IO_SEG(0x0001180000001580ull))
54 CVMX_ADD_IO_SEG(0x00011800000000C0ull) 54#define CVMX_MIO_FUS_PROG (CVMX_ADD_IO_SEG(0x0001180000001510ull))
55#define CVMX_MIO_BOOT_REG_CFGX(offset) \ 55#define CVMX_MIO_FUS_PROG_TIMES (CVMX_ADD_IO_SEG(0x0001180000001518ull))
56 CVMX_ADD_IO_SEG(0x0001180000000000ull + (((offset) & 7) * 8)) 56#define CVMX_MIO_FUS_RCMD (CVMX_ADD_IO_SEG(0x0001180000001500ull))
57#define CVMX_MIO_BOOT_REG_TIMX(offset) \ 57#define CVMX_MIO_FUS_READ_TIMES (CVMX_ADD_IO_SEG(0x0001180000001570ull))
58 CVMX_ADD_IO_SEG(0x0001180000000040ull + (((offset) & 7) * 8)) 58#define CVMX_MIO_FUS_REPAIR_RES0 (CVMX_ADD_IO_SEG(0x0001180000001558ull))
59#define CVMX_MIO_BOOT_THR \ 59#define CVMX_MIO_FUS_REPAIR_RES1 (CVMX_ADD_IO_SEG(0x0001180000001560ull))
60 CVMX_ADD_IO_SEG(0x00011800000000B0ull) 60#define CVMX_MIO_FUS_REPAIR_RES2 (CVMX_ADD_IO_SEG(0x0001180000001568ull))
61#define CVMX_MIO_FUS_BNK_DATX(offset) \ 61#define CVMX_MIO_FUS_SPR_REPAIR_RES (CVMX_ADD_IO_SEG(0x0001180000001548ull))
62 CVMX_ADD_IO_SEG(0x0001180000001520ull + (((offset) & 3) * 8)) 62#define CVMX_MIO_FUS_SPR_REPAIR_SUM (CVMX_ADD_IO_SEG(0x0001180000001540ull))
63#define CVMX_MIO_FUS_DAT0 \ 63#define CVMX_MIO_FUS_UNLOCK (CVMX_ADD_IO_SEG(0x0001180000001578ull))
64 CVMX_ADD_IO_SEG(0x0001180000001400ull) 64#define CVMX_MIO_FUS_WADR (CVMX_ADD_IO_SEG(0x0001180000001508ull))
65#define CVMX_MIO_FUS_DAT1 \ 65#define CVMX_MIO_GPIO_COMP (CVMX_ADD_IO_SEG(0x00011800000000C8ull))
66 CVMX_ADD_IO_SEG(0x0001180000001408ull) 66#define CVMX_MIO_NDF_DMA_CFG (CVMX_ADD_IO_SEG(0x0001180000000168ull))
67#define CVMX_MIO_FUS_DAT2 \ 67#define CVMX_MIO_NDF_DMA_INT (CVMX_ADD_IO_SEG(0x0001180000000170ull))
68 CVMX_ADD_IO_SEG(0x0001180000001410ull) 68#define CVMX_MIO_NDF_DMA_INT_EN (CVMX_ADD_IO_SEG(0x0001180000000178ull))
69#define CVMX_MIO_FUS_DAT3 \ 69#define CVMX_MIO_PLL_CTL (CVMX_ADD_IO_SEG(0x0001180000001448ull))
70 CVMX_ADD_IO_SEG(0x0001180000001418ull) 70#define CVMX_MIO_PLL_SETTING (CVMX_ADD_IO_SEG(0x0001180000001440ull))
71#define CVMX_MIO_FUS_EMA \ 71#define CVMX_MIO_PTP_CLOCK_CFG (CVMX_ADD_IO_SEG(0x0001070000000F00ull))
72 CVMX_ADD_IO_SEG(0x0001180000001550ull) 72#define CVMX_MIO_PTP_CLOCK_COMP (CVMX_ADD_IO_SEG(0x0001070000000F18ull))
73#define CVMX_MIO_FUS_PDF \ 73#define CVMX_MIO_PTP_CLOCK_HI (CVMX_ADD_IO_SEG(0x0001070000000F10ull))
74 CVMX_ADD_IO_SEG(0x0001180000001420ull) 74#define CVMX_MIO_PTP_CLOCK_LO (CVMX_ADD_IO_SEG(0x0001070000000F08ull))
75#define CVMX_MIO_FUS_PLL \ 75#define CVMX_MIO_PTP_EVT_CNT (CVMX_ADD_IO_SEG(0x0001070000000F28ull))
76 CVMX_ADD_IO_SEG(0x0001180000001580ull) 76#define CVMX_MIO_PTP_TIMESTAMP (CVMX_ADD_IO_SEG(0x0001070000000F20ull))
77#define CVMX_MIO_FUS_PROG \ 77#define CVMX_MIO_RST_BOOT (CVMX_ADD_IO_SEG(0x0001180000001600ull))
78 CVMX_ADD_IO_SEG(0x0001180000001510ull) 78#define CVMX_MIO_RST_CFG (CVMX_ADD_IO_SEG(0x0001180000001610ull))
79#define CVMX_MIO_FUS_PROG_TIMES \ 79#define CVMX_MIO_RST_CTLX(offset) (CVMX_ADD_IO_SEG(0x0001180000001618ull) + ((offset) & 1) * 8)
80 CVMX_ADD_IO_SEG(0x0001180000001518ull) 80#define CVMX_MIO_RST_DELAY (CVMX_ADD_IO_SEG(0x0001180000001608ull))
81#define CVMX_MIO_FUS_RCMD \ 81#define CVMX_MIO_RST_INT (CVMX_ADD_IO_SEG(0x0001180000001628ull))
82 CVMX_ADD_IO_SEG(0x0001180000001500ull) 82#define CVMX_MIO_RST_INT_EN (CVMX_ADD_IO_SEG(0x0001180000001630ull))
83#define CVMX_MIO_FUS_SPR_REPAIR_RES \ 83#define CVMX_MIO_TWSX_INT(offset) (CVMX_ADD_IO_SEG(0x0001180000001010ull) + ((offset) & 1) * 512)
84 CVMX_ADD_IO_SEG(0x0001180000001548ull) 84#define CVMX_MIO_TWSX_SW_TWSI(offset) (CVMX_ADD_IO_SEG(0x0001180000001000ull) + ((offset) & 1) * 512)
85#define CVMX_MIO_FUS_SPR_REPAIR_SUM \ 85#define CVMX_MIO_TWSX_SW_TWSI_EXT(offset) (CVMX_ADD_IO_SEG(0x0001180000001018ull) + ((offset) & 1) * 512)
86 CVMX_ADD_IO_SEG(0x0001180000001540ull) 86#define CVMX_MIO_TWSX_TWSI_SW(offset) (CVMX_ADD_IO_SEG(0x0001180000001008ull) + ((offset) & 1) * 512)
87#define CVMX_MIO_FUS_UNLOCK \ 87#define CVMX_MIO_UART2_DLH (CVMX_ADD_IO_SEG(0x0001180000000488ull))
88 CVMX_ADD_IO_SEG(0x0001180000001578ull) 88#define CVMX_MIO_UART2_DLL (CVMX_ADD_IO_SEG(0x0001180000000480ull))
89#define CVMX_MIO_FUS_WADR \ 89#define CVMX_MIO_UART2_FAR (CVMX_ADD_IO_SEG(0x0001180000000520ull))
90 CVMX_ADD_IO_SEG(0x0001180000001508ull) 90#define CVMX_MIO_UART2_FCR (CVMX_ADD_IO_SEG(0x0001180000000450ull))
91#define CVMX_MIO_NDF_DMA_CFG \ 91#define CVMX_MIO_UART2_HTX (CVMX_ADD_IO_SEG(0x0001180000000708ull))
92 CVMX_ADD_IO_SEG(0x0001180000000168ull) 92#define CVMX_MIO_UART2_IER (CVMX_ADD_IO_SEG(0x0001180000000408ull))
93#define CVMX_MIO_NDF_DMA_INT \ 93#define CVMX_MIO_UART2_IIR (CVMX_ADD_IO_SEG(0x0001180000000410ull))
94 CVMX_ADD_IO_SEG(0x0001180000000170ull) 94#define CVMX_MIO_UART2_LCR (CVMX_ADD_IO_SEG(0x0001180000000418ull))
95#define CVMX_MIO_NDF_DMA_INT_EN \ 95#define CVMX_MIO_UART2_LSR (CVMX_ADD_IO_SEG(0x0001180000000428ull))
96 CVMX_ADD_IO_SEG(0x0001180000000178ull) 96#define CVMX_MIO_UART2_MCR (CVMX_ADD_IO_SEG(0x0001180000000420ull))
97#define CVMX_MIO_PLL_CTL \ 97#define CVMX_MIO_UART2_MSR (CVMX_ADD_IO_SEG(0x0001180000000430ull))
98 CVMX_ADD_IO_SEG(0x0001180000001448ull) 98#define CVMX_MIO_UART2_RBR (CVMX_ADD_IO_SEG(0x0001180000000400ull))
99#define CVMX_MIO_PLL_SETTING \ 99#define CVMX_MIO_UART2_RFL (CVMX_ADD_IO_SEG(0x0001180000000608ull))
100 CVMX_ADD_IO_SEG(0x0001180000001440ull) 100#define CVMX_MIO_UART2_RFW (CVMX_ADD_IO_SEG(0x0001180000000530ull))
101#define CVMX_MIO_TWSX_INT(offset) \ 101#define CVMX_MIO_UART2_SBCR (CVMX_ADD_IO_SEG(0x0001180000000620ull))
102 CVMX_ADD_IO_SEG(0x0001180000001010ull + (((offset) & 1) * 512)) 102#define CVMX_MIO_UART2_SCR (CVMX_ADD_IO_SEG(0x0001180000000438ull))
103#define CVMX_MIO_TWSX_SW_TWSI(offset) \ 103#define CVMX_MIO_UART2_SFE (CVMX_ADD_IO_SEG(0x0001180000000630ull))
104 CVMX_ADD_IO_SEG(0x0001180000001000ull + (((offset) & 1) * 512)) 104#define CVMX_MIO_UART2_SRR (CVMX_ADD_IO_SEG(0x0001180000000610ull))
105#define CVMX_MIO_TWSX_SW_TWSI_EXT(offset) \ 105#define CVMX_MIO_UART2_SRT (CVMX_ADD_IO_SEG(0x0001180000000638ull))
106 CVMX_ADD_IO_SEG(0x0001180000001018ull + (((offset) & 1) * 512)) 106#define CVMX_MIO_UART2_SRTS (CVMX_ADD_IO_SEG(0x0001180000000618ull))
107#define CVMX_MIO_TWSX_TWSI_SW(offset) \ 107#define CVMX_MIO_UART2_STT (CVMX_ADD_IO_SEG(0x0001180000000700ull))
108 CVMX_ADD_IO_SEG(0x0001180000001008ull + (((offset) & 1) * 512)) 108#define CVMX_MIO_UART2_TFL (CVMX_ADD_IO_SEG(0x0001180000000600ull))
109#define CVMX_MIO_UART2_DLH \ 109#define CVMX_MIO_UART2_TFR (CVMX_ADD_IO_SEG(0x0001180000000528ull))
110 CVMX_ADD_IO_SEG(0x0001180000000488ull) 110#define CVMX_MIO_UART2_THR (CVMX_ADD_IO_SEG(0x0001180000000440ull))
111#define CVMX_MIO_UART2_DLL \ 111#define CVMX_MIO_UART2_USR (CVMX_ADD_IO_SEG(0x0001180000000538ull))
112 CVMX_ADD_IO_SEG(0x0001180000000480ull) 112#define CVMX_MIO_UARTX_DLH(offset) (CVMX_ADD_IO_SEG(0x0001180000000888ull) + ((offset) & 1) * 1024)
113#define CVMX_MIO_UART2_FAR \ 113#define CVMX_MIO_UARTX_DLL(offset) (CVMX_ADD_IO_SEG(0x0001180000000880ull) + ((offset) & 1) * 1024)
114 CVMX_ADD_IO_SEG(0x0001180000000520ull) 114#define CVMX_MIO_UARTX_FAR(offset) (CVMX_ADD_IO_SEG(0x0001180000000920ull) + ((offset) & 1) * 1024)
115#define CVMX_MIO_UART2_FCR \ 115#define CVMX_MIO_UARTX_FCR(offset) (CVMX_ADD_IO_SEG(0x0001180000000850ull) + ((offset) & 1) * 1024)
116 CVMX_ADD_IO_SEG(0x0001180000000450ull) 116#define CVMX_MIO_UARTX_HTX(offset) (CVMX_ADD_IO_SEG(0x0001180000000B08ull) + ((offset) & 1) * 1024)
117#define CVMX_MIO_UART2_HTX \ 117#define CVMX_MIO_UARTX_IER(offset) (CVMX_ADD_IO_SEG(0x0001180000000808ull) + ((offset) & 1) * 1024)
118 CVMX_ADD_IO_SEG(0x0001180000000708ull) 118#define CVMX_MIO_UARTX_IIR(offset) (CVMX_ADD_IO_SEG(0x0001180000000810ull) + ((offset) & 1) * 1024)
119#define CVMX_MIO_UART2_IER \ 119#define CVMX_MIO_UARTX_LCR(offset) (CVMX_ADD_IO_SEG(0x0001180000000818ull) + ((offset) & 1) * 1024)
120 CVMX_ADD_IO_SEG(0x0001180000000408ull) 120#define CVMX_MIO_UARTX_LSR(offset) (CVMX_ADD_IO_SEG(0x0001180000000828ull) + ((offset) & 1) * 1024)
121#define CVMX_MIO_UART2_IIR \ 121#define CVMX_MIO_UARTX_MCR(offset) (CVMX_ADD_IO_SEG(0x0001180000000820ull) + ((offset) & 1) * 1024)
122 CVMX_ADD_IO_SEG(0x0001180000000410ull) 122#define CVMX_MIO_UARTX_MSR(offset) (CVMX_ADD_IO_SEG(0x0001180000000830ull) + ((offset) & 1) * 1024)
123#define CVMX_MIO_UART2_LCR \ 123#define CVMX_MIO_UARTX_RBR(offset) (CVMX_ADD_IO_SEG(0x0001180000000800ull) + ((offset) & 1) * 1024)
124 CVMX_ADD_IO_SEG(0x0001180000000418ull) 124#define CVMX_MIO_UARTX_RFL(offset) (CVMX_ADD_IO_SEG(0x0001180000000A08ull) + ((offset) & 1) * 1024)
125#define CVMX_MIO_UART2_LSR \ 125#define CVMX_MIO_UARTX_RFW(offset) (CVMX_ADD_IO_SEG(0x0001180000000930ull) + ((offset) & 1) * 1024)
126 CVMX_ADD_IO_SEG(0x0001180000000428ull) 126#define CVMX_MIO_UARTX_SBCR(offset) (CVMX_ADD_IO_SEG(0x0001180000000A20ull) + ((offset) & 1) * 1024)
127#define CVMX_MIO_UART2_MCR \ 127#define CVMX_MIO_UARTX_SCR(offset) (CVMX_ADD_IO_SEG(0x0001180000000838ull) + ((offset) & 1) * 1024)
128 CVMX_ADD_IO_SEG(0x0001180000000420ull) 128#define CVMX_MIO_UARTX_SFE(offset) (CVMX_ADD_IO_SEG(0x0001180000000A30ull) + ((offset) & 1) * 1024)
129#define CVMX_MIO_UART2_MSR \ 129#define CVMX_MIO_UARTX_SRR(offset) (CVMX_ADD_IO_SEG(0x0001180000000A10ull) + ((offset) & 1) * 1024)
130 CVMX_ADD_IO_SEG(0x0001180000000430ull) 130#define CVMX_MIO_UARTX_SRT(offset) (CVMX_ADD_IO_SEG(0x0001180000000A38ull) + ((offset) & 1) * 1024)
131#define CVMX_MIO_UART2_RBR \ 131#define CVMX_MIO_UARTX_SRTS(offset) (CVMX_ADD_IO_SEG(0x0001180000000A18ull) + ((offset) & 1) * 1024)
132 CVMX_ADD_IO_SEG(0x0001180000000400ull) 132#define CVMX_MIO_UARTX_STT(offset) (CVMX_ADD_IO_SEG(0x0001180000000B00ull) + ((offset) & 1) * 1024)
133#define CVMX_MIO_UART2_RFL \ 133#define CVMX_MIO_UARTX_TFL(offset) (CVMX_ADD_IO_SEG(0x0001180000000A00ull) + ((offset) & 1) * 1024)
134 CVMX_ADD_IO_SEG(0x0001180000000608ull) 134#define CVMX_MIO_UARTX_TFR(offset) (CVMX_ADD_IO_SEG(0x0001180000000928ull) + ((offset) & 1) * 1024)
135#define CVMX_MIO_UART2_RFW \ 135#define CVMX_MIO_UARTX_THR(offset) (CVMX_ADD_IO_SEG(0x0001180000000840ull) + ((offset) & 1) * 1024)
136 CVMX_ADD_IO_SEG(0x0001180000000530ull) 136#define CVMX_MIO_UARTX_USR(offset) (CVMX_ADD_IO_SEG(0x0001180000000938ull) + ((offset) & 1) * 1024)
137#define CVMX_MIO_UART2_SBCR \
138 CVMX_ADD_IO_SEG(0x0001180000000620ull)
139#define CVMX_MIO_UART2_SCR \
140 CVMX_ADD_IO_SEG(0x0001180000000438ull)
141#define CVMX_MIO_UART2_SFE \
142 CVMX_ADD_IO_SEG(0x0001180000000630ull)
143#define CVMX_MIO_UART2_SRR \
144 CVMX_ADD_IO_SEG(0x0001180000000610ull)
145#define CVMX_MIO_UART2_SRT \
146 CVMX_ADD_IO_SEG(0x0001180000000638ull)
147#define CVMX_MIO_UART2_SRTS \
148 CVMX_ADD_IO_SEG(0x0001180000000618ull)
149#define CVMX_MIO_UART2_STT \
150 CVMX_ADD_IO_SEG(0x0001180000000700ull)
151#define CVMX_MIO_UART2_TFL \
152 CVMX_ADD_IO_SEG(0x0001180000000600ull)
153#define CVMX_MIO_UART2_TFR \
154 CVMX_ADD_IO_SEG(0x0001180000000528ull)
155#define CVMX_MIO_UART2_THR \
156 CVMX_ADD_IO_SEG(0x0001180000000440ull)
157#define CVMX_MIO_UART2_USR \
158 CVMX_ADD_IO_SEG(0x0001180000000538ull)
159#define CVMX_MIO_UARTX_DLH(offset) \
160 CVMX_ADD_IO_SEG(0x0001180000000888ull + (((offset) & 1) * 1024))
161#define CVMX_MIO_UARTX_DLL(offset) \
162 CVMX_ADD_IO_SEG(0x0001180000000880ull + (((offset) & 1) * 1024))
163#define CVMX_MIO_UARTX_FAR(offset) \
164 CVMX_ADD_IO_SEG(0x0001180000000920ull + (((offset) & 1) * 1024))
165#define CVMX_MIO_UARTX_FCR(offset) \
166 CVMX_ADD_IO_SEG(0x0001180000000850ull + (((offset) & 1) * 1024))
167#define CVMX_MIO_UARTX_HTX(offset) \
168 CVMX_ADD_IO_SEG(0x0001180000000B08ull + (((offset) & 1) * 1024))
169#define CVMX_MIO_UARTX_IER(offset) \
170 CVMX_ADD_IO_SEG(0x0001180000000808ull + (((offset) & 1) * 1024))
171#define CVMX_MIO_UARTX_IIR(offset) \
172 CVMX_ADD_IO_SEG(0x0001180000000810ull + (((offset) & 1) * 1024))
173#define CVMX_MIO_UARTX_LCR(offset) \
174 CVMX_ADD_IO_SEG(0x0001180000000818ull + (((offset) & 1) * 1024))
175#define CVMX_MIO_UARTX_LSR(offset) \
176 CVMX_ADD_IO_SEG(0x0001180000000828ull + (((offset) & 1) * 1024))
177#define CVMX_MIO_UARTX_MCR(offset) \
178 CVMX_ADD_IO_SEG(0x0001180000000820ull + (((offset) & 1) * 1024))
179#define CVMX_MIO_UARTX_MSR(offset) \
180 CVMX_ADD_IO_SEG(0x0001180000000830ull + (((offset) & 1) * 1024))
181#define CVMX_MIO_UARTX_RBR(offset) \
182 CVMX_ADD_IO_SEG(0x0001180000000800ull + (((offset) & 1) * 1024))
183#define CVMX_MIO_UARTX_RFL(offset) \
184 CVMX_ADD_IO_SEG(0x0001180000000A08ull + (((offset) & 1) * 1024))
185#define CVMX_MIO_UARTX_RFW(offset) \
186 CVMX_ADD_IO_SEG(0x0001180000000930ull + (((offset) & 1) * 1024))
187#define CVMX_MIO_UARTX_SBCR(offset) \
188 CVMX_ADD_IO_SEG(0x0001180000000A20ull + (((offset) & 1) * 1024))
189#define CVMX_MIO_UARTX_SCR(offset) \
190 CVMX_ADD_IO_SEG(0x0001180000000838ull + (((offset) & 1) * 1024))
191#define CVMX_MIO_UARTX_SFE(offset) \
192 CVMX_ADD_IO_SEG(0x0001180000000A30ull + (((offset) & 1) * 1024))
193#define CVMX_MIO_UARTX_SRR(offset) \
194 CVMX_ADD_IO_SEG(0x0001180000000A10ull + (((offset) & 1) * 1024))
195#define CVMX_MIO_UARTX_SRT(offset) \
196 CVMX_ADD_IO_SEG(0x0001180000000A38ull + (((offset) & 1) * 1024))
197#define CVMX_MIO_UARTX_SRTS(offset) \
198 CVMX_ADD_IO_SEG(0x0001180000000A18ull + (((offset) & 1) * 1024))
199#define CVMX_MIO_UARTX_STT(offset) \
200 CVMX_ADD_IO_SEG(0x0001180000000B00ull + (((offset) & 1) * 1024))
201#define CVMX_MIO_UARTX_TFL(offset) \
202 CVMX_ADD_IO_SEG(0x0001180000000A00ull + (((offset) & 1) * 1024))
203#define CVMX_MIO_UARTX_TFR(offset) \
204 CVMX_ADD_IO_SEG(0x0001180000000928ull + (((offset) & 1) * 1024))
205#define CVMX_MIO_UARTX_THR(offset) \
206 CVMX_ADD_IO_SEG(0x0001180000000840ull + (((offset) & 1) * 1024))
207#define CVMX_MIO_UARTX_USR(offset) \
208 CVMX_ADD_IO_SEG(0x0001180000000938ull + (((offset) & 1) * 1024))
209 137
210union cvmx_mio_boot_bist_stat { 138union cvmx_mio_boot_bist_stat {
211 uint64_t u64; 139 uint64_t u64;
212 struct cvmx_mio_boot_bist_stat_s { 140 struct cvmx_mio_boot_bist_stat_s {
213 uint64_t reserved_2_63:62; 141 uint64_t reserved_0_63:64;
214 uint64_t loc:1;
215 uint64_t ncbi:1;
216 } s; 142 } s;
217 struct cvmx_mio_boot_bist_stat_cn30xx { 143 struct cvmx_mio_boot_bist_stat_cn30xx {
218 uint64_t reserved_4_63:60; 144 uint64_t reserved_4_63:60;
@@ -257,20 +183,33 @@ union cvmx_mio_boot_bist_stat {
257 struct cvmx_mio_boot_bist_stat_cn52xxp1 cn56xxp1; 183 struct cvmx_mio_boot_bist_stat_cn52xxp1 cn56xxp1;
258 struct cvmx_mio_boot_bist_stat_cn38xx cn58xx; 184 struct cvmx_mio_boot_bist_stat_cn38xx cn58xx;
259 struct cvmx_mio_boot_bist_stat_cn38xx cn58xxp1; 185 struct cvmx_mio_boot_bist_stat_cn38xx cn58xxp1;
186 struct cvmx_mio_boot_bist_stat_cn63xx {
187 uint64_t reserved_9_63:55;
188 uint64_t stat:9;
189 } cn63xx;
190 struct cvmx_mio_boot_bist_stat_cn63xx cn63xxp1;
260}; 191};
261 192
262union cvmx_mio_boot_comp { 193union cvmx_mio_boot_comp {
263 uint64_t u64; 194 uint64_t u64;
264 struct cvmx_mio_boot_comp_s { 195 struct cvmx_mio_boot_comp_s {
196 uint64_t reserved_0_63:64;
197 } s;
198 struct cvmx_mio_boot_comp_cn50xx {
265 uint64_t reserved_10_63:54; 199 uint64_t reserved_10_63:54;
266 uint64_t pctl:5; 200 uint64_t pctl:5;
267 uint64_t nctl:5; 201 uint64_t nctl:5;
268 } s; 202 } cn50xx;
269 struct cvmx_mio_boot_comp_s cn50xx; 203 struct cvmx_mio_boot_comp_cn50xx cn52xx;
270 struct cvmx_mio_boot_comp_s cn52xx; 204 struct cvmx_mio_boot_comp_cn50xx cn52xxp1;
271 struct cvmx_mio_boot_comp_s cn52xxp1; 205 struct cvmx_mio_boot_comp_cn50xx cn56xx;
272 struct cvmx_mio_boot_comp_s cn56xx; 206 struct cvmx_mio_boot_comp_cn50xx cn56xxp1;
273 struct cvmx_mio_boot_comp_s cn56xxp1; 207 struct cvmx_mio_boot_comp_cn63xx {
208 uint64_t reserved_12_63:52;
209 uint64_t pctl:6;
210 uint64_t nctl:6;
211 } cn63xx;
212 struct cvmx_mio_boot_comp_cn63xx cn63xxp1;
274}; 213};
275 214
276union cvmx_mio_boot_dma_cfgx { 215union cvmx_mio_boot_dma_cfgx {
@@ -291,6 +230,8 @@ union cvmx_mio_boot_dma_cfgx {
291 struct cvmx_mio_boot_dma_cfgx_s cn52xxp1; 230 struct cvmx_mio_boot_dma_cfgx_s cn52xxp1;
292 struct cvmx_mio_boot_dma_cfgx_s cn56xx; 231 struct cvmx_mio_boot_dma_cfgx_s cn56xx;
293 struct cvmx_mio_boot_dma_cfgx_s cn56xxp1; 232 struct cvmx_mio_boot_dma_cfgx_s cn56xxp1;
233 struct cvmx_mio_boot_dma_cfgx_s cn63xx;
234 struct cvmx_mio_boot_dma_cfgx_s cn63xxp1;
294}; 235};
295 236
296union cvmx_mio_boot_dma_intx { 237union cvmx_mio_boot_dma_intx {
@@ -304,6 +245,8 @@ union cvmx_mio_boot_dma_intx {
304 struct cvmx_mio_boot_dma_intx_s cn52xxp1; 245 struct cvmx_mio_boot_dma_intx_s cn52xxp1;
305 struct cvmx_mio_boot_dma_intx_s cn56xx; 246 struct cvmx_mio_boot_dma_intx_s cn56xx;
306 struct cvmx_mio_boot_dma_intx_s cn56xxp1; 247 struct cvmx_mio_boot_dma_intx_s cn56xxp1;
248 struct cvmx_mio_boot_dma_intx_s cn63xx;
249 struct cvmx_mio_boot_dma_intx_s cn63xxp1;
307}; 250};
308 251
309union cvmx_mio_boot_dma_int_enx { 252union cvmx_mio_boot_dma_int_enx {
@@ -317,6 +260,8 @@ union cvmx_mio_boot_dma_int_enx {
317 struct cvmx_mio_boot_dma_int_enx_s cn52xxp1; 260 struct cvmx_mio_boot_dma_int_enx_s cn52xxp1;
318 struct cvmx_mio_boot_dma_int_enx_s cn56xx; 261 struct cvmx_mio_boot_dma_int_enx_s cn56xx;
319 struct cvmx_mio_boot_dma_int_enx_s cn56xxp1; 262 struct cvmx_mio_boot_dma_int_enx_s cn56xxp1;
263 struct cvmx_mio_boot_dma_int_enx_s cn63xx;
264 struct cvmx_mio_boot_dma_int_enx_s cn63xxp1;
320}; 265};
321 266
322union cvmx_mio_boot_dma_timx { 267union cvmx_mio_boot_dma_timx {
@@ -342,6 +287,8 @@ union cvmx_mio_boot_dma_timx {
342 struct cvmx_mio_boot_dma_timx_s cn52xxp1; 287 struct cvmx_mio_boot_dma_timx_s cn52xxp1;
343 struct cvmx_mio_boot_dma_timx_s cn56xx; 288 struct cvmx_mio_boot_dma_timx_s cn56xx;
344 struct cvmx_mio_boot_dma_timx_s cn56xxp1; 289 struct cvmx_mio_boot_dma_timx_s cn56xxp1;
290 struct cvmx_mio_boot_dma_timx_s cn63xx;
291 struct cvmx_mio_boot_dma_timx_s cn63xxp1;
345}; 292};
346 293
347union cvmx_mio_boot_err { 294union cvmx_mio_boot_err {
@@ -362,6 +309,8 @@ union cvmx_mio_boot_err {
362 struct cvmx_mio_boot_err_s cn56xxp1; 309 struct cvmx_mio_boot_err_s cn56xxp1;
363 struct cvmx_mio_boot_err_s cn58xx; 310 struct cvmx_mio_boot_err_s cn58xx;
364 struct cvmx_mio_boot_err_s cn58xxp1; 311 struct cvmx_mio_boot_err_s cn58xxp1;
312 struct cvmx_mio_boot_err_s cn63xx;
313 struct cvmx_mio_boot_err_s cn63xxp1;
365}; 314};
366 315
367union cvmx_mio_boot_int { 316union cvmx_mio_boot_int {
@@ -382,6 +331,8 @@ union cvmx_mio_boot_int {
382 struct cvmx_mio_boot_int_s cn56xxp1; 331 struct cvmx_mio_boot_int_s cn56xxp1;
383 struct cvmx_mio_boot_int_s cn58xx; 332 struct cvmx_mio_boot_int_s cn58xx;
384 struct cvmx_mio_boot_int_s cn58xxp1; 333 struct cvmx_mio_boot_int_s cn58xxp1;
334 struct cvmx_mio_boot_int_s cn63xx;
335 struct cvmx_mio_boot_int_s cn63xxp1;
385}; 336};
386 337
387union cvmx_mio_boot_loc_adr { 338union cvmx_mio_boot_loc_adr {
@@ -402,6 +353,8 @@ union cvmx_mio_boot_loc_adr {
402 struct cvmx_mio_boot_loc_adr_s cn56xxp1; 353 struct cvmx_mio_boot_loc_adr_s cn56xxp1;
403 struct cvmx_mio_boot_loc_adr_s cn58xx; 354 struct cvmx_mio_boot_loc_adr_s cn58xx;
404 struct cvmx_mio_boot_loc_adr_s cn58xxp1; 355 struct cvmx_mio_boot_loc_adr_s cn58xxp1;
356 struct cvmx_mio_boot_loc_adr_s cn63xx;
357 struct cvmx_mio_boot_loc_adr_s cn63xxp1;
405}; 358};
406 359
407union cvmx_mio_boot_loc_cfgx { 360union cvmx_mio_boot_loc_cfgx {
@@ -424,6 +377,8 @@ union cvmx_mio_boot_loc_cfgx {
424 struct cvmx_mio_boot_loc_cfgx_s cn56xxp1; 377 struct cvmx_mio_boot_loc_cfgx_s cn56xxp1;
425 struct cvmx_mio_boot_loc_cfgx_s cn58xx; 378 struct cvmx_mio_boot_loc_cfgx_s cn58xx;
426 struct cvmx_mio_boot_loc_cfgx_s cn58xxp1; 379 struct cvmx_mio_boot_loc_cfgx_s cn58xxp1;
380 struct cvmx_mio_boot_loc_cfgx_s cn63xx;
381 struct cvmx_mio_boot_loc_cfgx_s cn63xxp1;
427}; 382};
428 383
429union cvmx_mio_boot_loc_dat { 384union cvmx_mio_boot_loc_dat {
@@ -442,6 +397,8 @@ union cvmx_mio_boot_loc_dat {
442 struct cvmx_mio_boot_loc_dat_s cn56xxp1; 397 struct cvmx_mio_boot_loc_dat_s cn56xxp1;
443 struct cvmx_mio_boot_loc_dat_s cn58xx; 398 struct cvmx_mio_boot_loc_dat_s cn58xx;
444 struct cvmx_mio_boot_loc_dat_s cn58xxp1; 399 struct cvmx_mio_boot_loc_dat_s cn58xxp1;
400 struct cvmx_mio_boot_loc_dat_s cn63xx;
401 struct cvmx_mio_boot_loc_dat_s cn63xxp1;
445}; 402};
446 403
447union cvmx_mio_boot_pin_defs { 404union cvmx_mio_boot_pin_defs {
@@ -478,6 +435,8 @@ union cvmx_mio_boot_pin_defs {
478 uint64_t term:2; 435 uint64_t term:2;
479 uint64_t reserved_0_8:9; 436 uint64_t reserved_0_8:9;
480 } cn56xx; 437 } cn56xx;
438 struct cvmx_mio_boot_pin_defs_cn52xx cn63xx;
439 struct cvmx_mio_boot_pin_defs_cn52xx cn63xxp1;
481}; 440};
482 441
483union cvmx_mio_boot_reg_cfgx { 442union cvmx_mio_boot_reg_cfgx {
@@ -539,6 +498,8 @@ union cvmx_mio_boot_reg_cfgx {
539 struct cvmx_mio_boot_reg_cfgx_s cn56xxp1; 498 struct cvmx_mio_boot_reg_cfgx_s cn56xxp1;
540 struct cvmx_mio_boot_reg_cfgx_cn30xx cn58xx; 499 struct cvmx_mio_boot_reg_cfgx_cn30xx cn58xx;
541 struct cvmx_mio_boot_reg_cfgx_cn30xx cn58xxp1; 500 struct cvmx_mio_boot_reg_cfgx_cn30xx cn58xxp1;
501 struct cvmx_mio_boot_reg_cfgx_s cn63xx;
502 struct cvmx_mio_boot_reg_cfgx_s cn63xxp1;
542}; 503};
543 504
544union cvmx_mio_boot_reg_timx { 505union cvmx_mio_boot_reg_timx {
@@ -583,6 +544,8 @@ union cvmx_mio_boot_reg_timx {
583 struct cvmx_mio_boot_reg_timx_s cn56xxp1; 544 struct cvmx_mio_boot_reg_timx_s cn56xxp1;
584 struct cvmx_mio_boot_reg_timx_s cn58xx; 545 struct cvmx_mio_boot_reg_timx_s cn58xx;
585 struct cvmx_mio_boot_reg_timx_s cn58xxp1; 546 struct cvmx_mio_boot_reg_timx_s cn58xxp1;
547 struct cvmx_mio_boot_reg_timx_s cn63xx;
548 struct cvmx_mio_boot_reg_timx_s cn63xxp1;
586}; 549};
587 550
588union cvmx_mio_boot_thr { 551union cvmx_mio_boot_thr {
@@ -611,6 +574,8 @@ union cvmx_mio_boot_thr {
611 struct cvmx_mio_boot_thr_s cn56xxp1; 574 struct cvmx_mio_boot_thr_s cn56xxp1;
612 struct cvmx_mio_boot_thr_cn30xx cn58xx; 575 struct cvmx_mio_boot_thr_cn30xx cn58xx;
613 struct cvmx_mio_boot_thr_cn30xx cn58xxp1; 576 struct cvmx_mio_boot_thr_cn30xx cn58xxp1;
577 struct cvmx_mio_boot_thr_s cn63xx;
578 struct cvmx_mio_boot_thr_s cn63xxp1;
614}; 579};
615 580
616union cvmx_mio_fus_bnk_datx { 581union cvmx_mio_fus_bnk_datx {
@@ -625,6 +590,8 @@ union cvmx_mio_fus_bnk_datx {
625 struct cvmx_mio_fus_bnk_datx_s cn56xxp1; 590 struct cvmx_mio_fus_bnk_datx_s cn56xxp1;
626 struct cvmx_mio_fus_bnk_datx_s cn58xx; 591 struct cvmx_mio_fus_bnk_datx_s cn58xx;
627 struct cvmx_mio_fus_bnk_datx_s cn58xxp1; 592 struct cvmx_mio_fus_bnk_datx_s cn58xxp1;
593 struct cvmx_mio_fus_bnk_datx_s cn63xx;
594 struct cvmx_mio_fus_bnk_datx_s cn63xxp1;
628}; 595};
629 596
630union cvmx_mio_fus_dat0 { 597union cvmx_mio_fus_dat0 {
@@ -644,6 +611,8 @@ union cvmx_mio_fus_dat0 {
644 struct cvmx_mio_fus_dat0_s cn56xxp1; 611 struct cvmx_mio_fus_dat0_s cn56xxp1;
645 struct cvmx_mio_fus_dat0_s cn58xx; 612 struct cvmx_mio_fus_dat0_s cn58xx;
646 struct cvmx_mio_fus_dat0_s cn58xxp1; 613 struct cvmx_mio_fus_dat0_s cn58xxp1;
614 struct cvmx_mio_fus_dat0_s cn63xx;
615 struct cvmx_mio_fus_dat0_s cn63xxp1;
647}; 616};
648 617
649union cvmx_mio_fus_dat1 { 618union cvmx_mio_fus_dat1 {
@@ -663,12 +632,15 @@ union cvmx_mio_fus_dat1 {
663 struct cvmx_mio_fus_dat1_s cn56xxp1; 632 struct cvmx_mio_fus_dat1_s cn56xxp1;
664 struct cvmx_mio_fus_dat1_s cn58xx; 633 struct cvmx_mio_fus_dat1_s cn58xx;
665 struct cvmx_mio_fus_dat1_s cn58xxp1; 634 struct cvmx_mio_fus_dat1_s cn58xxp1;
635 struct cvmx_mio_fus_dat1_s cn63xx;
636 struct cvmx_mio_fus_dat1_s cn63xxp1;
666}; 637};
667 638
668union cvmx_mio_fus_dat2 { 639union cvmx_mio_fus_dat2 {
669 uint64_t u64; 640 uint64_t u64;
670 struct cvmx_mio_fus_dat2_s { 641 struct cvmx_mio_fus_dat2_s {
671 uint64_t reserved_34_63:30; 642 uint64_t reserved_35_63:29;
643 uint64_t dorm_crypto:1;
672 uint64_t fus318:1; 644 uint64_t fus318:1;
673 uint64_t raid_en:1; 645 uint64_t raid_en:1;
674 uint64_t reserved_30_31:2; 646 uint64_t reserved_30_31:2;
@@ -775,14 +747,38 @@ union cvmx_mio_fus_dat2 {
775 uint64_t pp_dis:16; 747 uint64_t pp_dis:16;
776 } cn58xx; 748 } cn58xx;
777 struct cvmx_mio_fus_dat2_cn58xx cn58xxp1; 749 struct cvmx_mio_fus_dat2_cn58xx cn58xxp1;
750 struct cvmx_mio_fus_dat2_cn63xx {
751 uint64_t reserved_35_63:29;
752 uint64_t dorm_crypto:1;
753 uint64_t fus318:1;
754 uint64_t raid_en:1;
755 uint64_t reserved_29_31:3;
756 uint64_t nodfa_cp2:1;
757 uint64_t nomul:1;
758 uint64_t nocrypto:1;
759 uint64_t reserved_24_25:2;
760 uint64_t chip_id:8;
761 uint64_t reserved_6_15:10;
762 uint64_t pp_dis:6;
763 } cn63xx;
764 struct cvmx_mio_fus_dat2_cn63xx cn63xxp1;
778}; 765};
779 766
780union cvmx_mio_fus_dat3 { 767union cvmx_mio_fus_dat3 {
781 uint64_t u64; 768 uint64_t u64;
782 struct cvmx_mio_fus_dat3_s { 769 struct cvmx_mio_fus_dat3_s {
783 uint64_t reserved_32_63:32; 770 uint64_t reserved_58_63:6;
771 uint64_t pll_ctl:10;
772 uint64_t dfa_info_dte:3;
773 uint64_t dfa_info_clm:4;
774 uint64_t reserved_40_40:1;
775 uint64_t ema:2;
776 uint64_t efus_lck_rsv:1;
777 uint64_t efus_lck_man:1;
778 uint64_t pll_half_dis:1;
779 uint64_t l2c_crip:3;
784 uint64_t pll_div4:1; 780 uint64_t pll_div4:1;
785 uint64_t zip_crip:2; 781 uint64_t reserved_29_30:2;
786 uint64_t bar2_en:1; 782 uint64_t bar2_en:1;
787 uint64_t efus_lck:1; 783 uint64_t efus_lck:1;
788 uint64_t efus_ign:1; 784 uint64_t efus_ign:1;
@@ -801,7 +797,17 @@ union cvmx_mio_fus_dat3 {
801 uint64_t nodfa_dte:1; 797 uint64_t nodfa_dte:1;
802 uint64_t icache:24; 798 uint64_t icache:24;
803 } cn30xx; 799 } cn30xx;
804 struct cvmx_mio_fus_dat3_s cn31xx; 800 struct cvmx_mio_fus_dat3_cn31xx {
801 uint64_t reserved_32_63:32;
802 uint64_t pll_div4:1;
803 uint64_t zip_crip:2;
804 uint64_t bar2_en:1;
805 uint64_t efus_lck:1;
806 uint64_t efus_ign:1;
807 uint64_t nozip:1;
808 uint64_t nodfa_dte:1;
809 uint64_t icache:24;
810 } cn31xx;
805 struct cvmx_mio_fus_dat3_cn38xx { 811 struct cvmx_mio_fus_dat3_cn38xx {
806 uint64_t reserved_31_63:33; 812 uint64_t reserved_31_63:33;
807 uint64_t zip_crip:2; 813 uint64_t zip_crip:2;
@@ -828,6 +834,27 @@ union cvmx_mio_fus_dat3 {
828 struct cvmx_mio_fus_dat3_cn38xx cn56xxp1; 834 struct cvmx_mio_fus_dat3_cn38xx cn56xxp1;
829 struct cvmx_mio_fus_dat3_cn38xx cn58xx; 835 struct cvmx_mio_fus_dat3_cn38xx cn58xx;
830 struct cvmx_mio_fus_dat3_cn38xx cn58xxp1; 836 struct cvmx_mio_fus_dat3_cn38xx cn58xxp1;
837 struct cvmx_mio_fus_dat3_cn63xx {
838 uint64_t reserved_58_63:6;
839 uint64_t pll_ctl:10;
840 uint64_t dfa_info_dte:3;
841 uint64_t dfa_info_clm:4;
842 uint64_t reserved_40_40:1;
843 uint64_t ema:2;
844 uint64_t efus_lck_rsv:1;
845 uint64_t efus_lck_man:1;
846 uint64_t pll_half_dis:1;
847 uint64_t l2c_crip:3;
848 uint64_t reserved_31_31:1;
849 uint64_t zip_info:2;
850 uint64_t bar2_en:1;
851 uint64_t efus_lck:1;
852 uint64_t efus_ign:1;
853 uint64_t nozip:1;
854 uint64_t nodfa_dte:1;
855 uint64_t reserved_0_23:24;
856 } cn63xx;
857 struct cvmx_mio_fus_dat3_cn63xx cn63xxp1;
831}; 858};
832 859
833union cvmx_mio_fus_ema { 860union cvmx_mio_fus_ema {
@@ -848,6 +875,8 @@ union cvmx_mio_fus_ema {
848 uint64_t ema:2; 875 uint64_t ema:2;
849 } cn58xx; 876 } cn58xx;
850 struct cvmx_mio_fus_ema_cn58xx cn58xxp1; 877 struct cvmx_mio_fus_ema_cn58xx cn58xxp1;
878 struct cvmx_mio_fus_ema_s cn63xx;
879 struct cvmx_mio_fus_ema_s cn63xxp1;
851}; 880};
852 881
853union cvmx_mio_fus_pdf { 882union cvmx_mio_fus_pdf {
@@ -861,60 +890,96 @@ union cvmx_mio_fus_pdf {
861 struct cvmx_mio_fus_pdf_s cn56xx; 890 struct cvmx_mio_fus_pdf_s cn56xx;
862 struct cvmx_mio_fus_pdf_s cn56xxp1; 891 struct cvmx_mio_fus_pdf_s cn56xxp1;
863 struct cvmx_mio_fus_pdf_s cn58xx; 892 struct cvmx_mio_fus_pdf_s cn58xx;
893 struct cvmx_mio_fus_pdf_s cn63xx;
894 struct cvmx_mio_fus_pdf_s cn63xxp1;
864}; 895};
865 896
866union cvmx_mio_fus_pll { 897union cvmx_mio_fus_pll {
867 uint64_t u64; 898 uint64_t u64;
868 struct cvmx_mio_fus_pll_s { 899 struct cvmx_mio_fus_pll_s {
869 uint64_t reserved_2_63:62; 900 uint64_t reserved_8_63:56;
901 uint64_t c_cout_rst:1;
902 uint64_t c_cout_sel:2;
903 uint64_t pnr_cout_rst:1;
904 uint64_t pnr_cout_sel:2;
870 uint64_t rfslip:1; 905 uint64_t rfslip:1;
871 uint64_t fbslip:1; 906 uint64_t fbslip:1;
872 } s; 907 } s;
873 struct cvmx_mio_fus_pll_s cn50xx; 908 struct cvmx_mio_fus_pll_cn50xx {
874 struct cvmx_mio_fus_pll_s cn52xx; 909 uint64_t reserved_2_63:62;
875 struct cvmx_mio_fus_pll_s cn52xxp1; 910 uint64_t rfslip:1;
876 struct cvmx_mio_fus_pll_s cn56xx; 911 uint64_t fbslip:1;
877 struct cvmx_mio_fus_pll_s cn56xxp1; 912 } cn50xx;
878 struct cvmx_mio_fus_pll_s cn58xx; 913 struct cvmx_mio_fus_pll_cn50xx cn52xx;
879 struct cvmx_mio_fus_pll_s cn58xxp1; 914 struct cvmx_mio_fus_pll_cn50xx cn52xxp1;
915 struct cvmx_mio_fus_pll_cn50xx cn56xx;
916 struct cvmx_mio_fus_pll_cn50xx cn56xxp1;
917 struct cvmx_mio_fus_pll_cn50xx cn58xx;
918 struct cvmx_mio_fus_pll_cn50xx cn58xxp1;
919 struct cvmx_mio_fus_pll_s cn63xx;
920 struct cvmx_mio_fus_pll_s cn63xxp1;
880}; 921};
881 922
882union cvmx_mio_fus_prog { 923union cvmx_mio_fus_prog {
883 uint64_t u64; 924 uint64_t u64;
884 struct cvmx_mio_fus_prog_s { 925 struct cvmx_mio_fus_prog_s {
885 uint64_t reserved_1_63:63; 926 uint64_t reserved_2_63:62;
927 uint64_t soft:1;
886 uint64_t prog:1; 928 uint64_t prog:1;
887 } s; 929 } s;
888 struct cvmx_mio_fus_prog_s cn30xx; 930 struct cvmx_mio_fus_prog_cn30xx {
889 struct cvmx_mio_fus_prog_s cn31xx; 931 uint64_t reserved_1_63:63;
890 struct cvmx_mio_fus_prog_s cn38xx; 932 uint64_t prog:1;
891 struct cvmx_mio_fus_prog_s cn38xxp2; 933 } cn30xx;
892 struct cvmx_mio_fus_prog_s cn50xx; 934 struct cvmx_mio_fus_prog_cn30xx cn31xx;
893 struct cvmx_mio_fus_prog_s cn52xx; 935 struct cvmx_mio_fus_prog_cn30xx cn38xx;
894 struct cvmx_mio_fus_prog_s cn52xxp1; 936 struct cvmx_mio_fus_prog_cn30xx cn38xxp2;
895 struct cvmx_mio_fus_prog_s cn56xx; 937 struct cvmx_mio_fus_prog_cn30xx cn50xx;
896 struct cvmx_mio_fus_prog_s cn56xxp1; 938 struct cvmx_mio_fus_prog_cn30xx cn52xx;
897 struct cvmx_mio_fus_prog_s cn58xx; 939 struct cvmx_mio_fus_prog_cn30xx cn52xxp1;
898 struct cvmx_mio_fus_prog_s cn58xxp1; 940 struct cvmx_mio_fus_prog_cn30xx cn56xx;
941 struct cvmx_mio_fus_prog_cn30xx cn56xxp1;
942 struct cvmx_mio_fus_prog_cn30xx cn58xx;
943 struct cvmx_mio_fus_prog_cn30xx cn58xxp1;
944 struct cvmx_mio_fus_prog_s cn63xx;
945 struct cvmx_mio_fus_prog_s cn63xxp1;
899}; 946};
900 947
901union cvmx_mio_fus_prog_times { 948union cvmx_mio_fus_prog_times {
902 uint64_t u64; 949 uint64_t u64;
903 struct cvmx_mio_fus_prog_times_s { 950 struct cvmx_mio_fus_prog_times_s {
951 uint64_t reserved_35_63:29;
952 uint64_t vgate_pin:1;
953 uint64_t fsrc_pin:1;
954 uint64_t prog_pin:1;
955 uint64_t reserved_6_31:26;
956 uint64_t setup:6;
957 } s;
958 struct cvmx_mio_fus_prog_times_cn50xx {
904 uint64_t reserved_33_63:31; 959 uint64_t reserved_33_63:31;
905 uint64_t prog_pin:1; 960 uint64_t prog_pin:1;
906 uint64_t out:8; 961 uint64_t out:8;
907 uint64_t sclk_lo:4; 962 uint64_t sclk_lo:4;
908 uint64_t sclk_hi:12; 963 uint64_t sclk_hi:12;
909 uint64_t setup:8; 964 uint64_t setup:8;
910 } s; 965 } cn50xx;
911 struct cvmx_mio_fus_prog_times_s cn50xx; 966 struct cvmx_mio_fus_prog_times_cn50xx cn52xx;
912 struct cvmx_mio_fus_prog_times_s cn52xx; 967 struct cvmx_mio_fus_prog_times_cn50xx cn52xxp1;
913 struct cvmx_mio_fus_prog_times_s cn52xxp1; 968 struct cvmx_mio_fus_prog_times_cn50xx cn56xx;
914 struct cvmx_mio_fus_prog_times_s cn56xx; 969 struct cvmx_mio_fus_prog_times_cn50xx cn56xxp1;
915 struct cvmx_mio_fus_prog_times_s cn56xxp1; 970 struct cvmx_mio_fus_prog_times_cn50xx cn58xx;
916 struct cvmx_mio_fus_prog_times_s cn58xx; 971 struct cvmx_mio_fus_prog_times_cn50xx cn58xxp1;
917 struct cvmx_mio_fus_prog_times_s cn58xxp1; 972 struct cvmx_mio_fus_prog_times_cn63xx {
973 uint64_t reserved_35_63:29;
974 uint64_t vgate_pin:1;
975 uint64_t fsrc_pin:1;
976 uint64_t prog_pin:1;
977 uint64_t out:7;
978 uint64_t sclk_lo:4;
979 uint64_t sclk_hi:15;
980 uint64_t setup:6;
981 } cn63xx;
982 struct cvmx_mio_fus_prog_times_cn63xx cn63xxp1;
918}; 983};
919 984
920union cvmx_mio_fus_rcmd { 985union cvmx_mio_fus_rcmd {
@@ -948,6 +1013,57 @@ union cvmx_mio_fus_rcmd {
948 struct cvmx_mio_fus_rcmd_s cn56xxp1; 1013 struct cvmx_mio_fus_rcmd_s cn56xxp1;
949 struct cvmx_mio_fus_rcmd_cn30xx cn58xx; 1014 struct cvmx_mio_fus_rcmd_cn30xx cn58xx;
950 struct cvmx_mio_fus_rcmd_cn30xx cn58xxp1; 1015 struct cvmx_mio_fus_rcmd_cn30xx cn58xxp1;
1016 struct cvmx_mio_fus_rcmd_s cn63xx;
1017 struct cvmx_mio_fus_rcmd_s cn63xxp1;
1018};
1019
1020union cvmx_mio_fus_read_times {
1021 uint64_t u64;
1022 struct cvmx_mio_fus_read_times_s {
1023 uint64_t reserved_26_63:38;
1024 uint64_t sch:4;
1025 uint64_t fsh:4;
1026 uint64_t prh:4;
1027 uint64_t sdh:4;
1028 uint64_t setup:10;
1029 } s;
1030 struct cvmx_mio_fus_read_times_s cn63xx;
1031 struct cvmx_mio_fus_read_times_s cn63xxp1;
1032};
1033
1034union cvmx_mio_fus_repair_res0 {
1035 uint64_t u64;
1036 struct cvmx_mio_fus_repair_res0_s {
1037 uint64_t reserved_55_63:9;
1038 uint64_t too_many:1;
1039 uint64_t repair2:18;
1040 uint64_t repair1:18;
1041 uint64_t repair0:18;
1042 } s;
1043 struct cvmx_mio_fus_repair_res0_s cn63xx;
1044 struct cvmx_mio_fus_repair_res0_s cn63xxp1;
1045};
1046
1047union cvmx_mio_fus_repair_res1 {
1048 uint64_t u64;
1049 struct cvmx_mio_fus_repair_res1_s {
1050 uint64_t reserved_54_63:10;
1051 uint64_t repair5:18;
1052 uint64_t repair4:18;
1053 uint64_t repair3:18;
1054 } s;
1055 struct cvmx_mio_fus_repair_res1_s cn63xx;
1056 struct cvmx_mio_fus_repair_res1_s cn63xxp1;
1057};
1058
1059union cvmx_mio_fus_repair_res2 {
1060 uint64_t u64;
1061 struct cvmx_mio_fus_repair_res2_s {
1062 uint64_t reserved_18_63:46;
1063 uint64_t repair6:18;
1064 } s;
1065 struct cvmx_mio_fus_repair_res2_s cn63xx;
1066 struct cvmx_mio_fus_repair_res2_s cn63xxp1;
951}; 1067};
952 1068
953union cvmx_mio_fus_spr_repair_res { 1069union cvmx_mio_fus_spr_repair_res {
@@ -968,6 +1084,8 @@ union cvmx_mio_fus_spr_repair_res {
968 struct cvmx_mio_fus_spr_repair_res_s cn56xxp1; 1084 struct cvmx_mio_fus_spr_repair_res_s cn56xxp1;
969 struct cvmx_mio_fus_spr_repair_res_s cn58xx; 1085 struct cvmx_mio_fus_spr_repair_res_s cn58xx;
970 struct cvmx_mio_fus_spr_repair_res_s cn58xxp1; 1086 struct cvmx_mio_fus_spr_repair_res_s cn58xxp1;
1087 struct cvmx_mio_fus_spr_repair_res_s cn63xx;
1088 struct cvmx_mio_fus_spr_repair_res_s cn63xxp1;
971}; 1089};
972 1090
973union cvmx_mio_fus_spr_repair_sum { 1091union cvmx_mio_fus_spr_repair_sum {
@@ -986,6 +1104,8 @@ union cvmx_mio_fus_spr_repair_sum {
986 struct cvmx_mio_fus_spr_repair_sum_s cn56xxp1; 1104 struct cvmx_mio_fus_spr_repair_sum_s cn56xxp1;
987 struct cvmx_mio_fus_spr_repair_sum_s cn58xx; 1105 struct cvmx_mio_fus_spr_repair_sum_s cn58xx;
988 struct cvmx_mio_fus_spr_repair_sum_s cn58xxp1; 1106 struct cvmx_mio_fus_spr_repair_sum_s cn58xxp1;
1107 struct cvmx_mio_fus_spr_repair_sum_s cn63xx;
1108 struct cvmx_mio_fus_spr_repair_sum_s cn63xxp1;
989}; 1109};
990 1110
991union cvmx_mio_fus_unlock { 1111union cvmx_mio_fus_unlock {
@@ -1021,6 +1141,22 @@ union cvmx_mio_fus_wadr {
1021 struct cvmx_mio_fus_wadr_cn52xx cn56xxp1; 1141 struct cvmx_mio_fus_wadr_cn52xx cn56xxp1;
1022 struct cvmx_mio_fus_wadr_cn50xx cn58xx; 1142 struct cvmx_mio_fus_wadr_cn50xx cn58xx;
1023 struct cvmx_mio_fus_wadr_cn50xx cn58xxp1; 1143 struct cvmx_mio_fus_wadr_cn50xx cn58xxp1;
1144 struct cvmx_mio_fus_wadr_cn63xx {
1145 uint64_t reserved_4_63:60;
1146 uint64_t addr:4;
1147 } cn63xx;
1148 struct cvmx_mio_fus_wadr_cn63xx cn63xxp1;
1149};
1150
1151union cvmx_mio_gpio_comp {
1152 uint64_t u64;
1153 struct cvmx_mio_gpio_comp_s {
1154 uint64_t reserved_12_63:52;
1155 uint64_t pctl:6;
1156 uint64_t nctl:6;
1157 } s;
1158 struct cvmx_mio_gpio_comp_s cn63xx;
1159 struct cvmx_mio_gpio_comp_s cn63xxp1;
1024}; 1160};
1025 1161
1026union cvmx_mio_ndf_dma_cfg { 1162union cvmx_mio_ndf_dma_cfg {
@@ -1038,6 +1174,8 @@ union cvmx_mio_ndf_dma_cfg {
1038 uint64_t adr:36; 1174 uint64_t adr:36;
1039 } s; 1175 } s;
1040 struct cvmx_mio_ndf_dma_cfg_s cn52xx; 1176 struct cvmx_mio_ndf_dma_cfg_s cn52xx;
1177 struct cvmx_mio_ndf_dma_cfg_s cn63xx;
1178 struct cvmx_mio_ndf_dma_cfg_s cn63xxp1;
1041}; 1179};
1042 1180
1043union cvmx_mio_ndf_dma_int { 1181union cvmx_mio_ndf_dma_int {
@@ -1047,6 +1185,8 @@ union cvmx_mio_ndf_dma_int {
1047 uint64_t done:1; 1185 uint64_t done:1;
1048 } s; 1186 } s;
1049 struct cvmx_mio_ndf_dma_int_s cn52xx; 1187 struct cvmx_mio_ndf_dma_int_s cn52xx;
1188 struct cvmx_mio_ndf_dma_int_s cn63xx;
1189 struct cvmx_mio_ndf_dma_int_s cn63xxp1;
1050}; 1190};
1051 1191
1052union cvmx_mio_ndf_dma_int_en { 1192union cvmx_mio_ndf_dma_int_en {
@@ -1056,6 +1196,8 @@ union cvmx_mio_ndf_dma_int_en {
1056 uint64_t done:1; 1196 uint64_t done:1;
1057 } s; 1197 } s;
1058 struct cvmx_mio_ndf_dma_int_en_s cn52xx; 1198 struct cvmx_mio_ndf_dma_int_en_s cn52xx;
1199 struct cvmx_mio_ndf_dma_int_en_s cn63xx;
1200 struct cvmx_mio_ndf_dma_int_en_s cn63xxp1;
1059}; 1201};
1060 1202
1061union cvmx_mio_pll_ctl { 1203union cvmx_mio_pll_ctl {
@@ -1078,6 +1220,173 @@ union cvmx_mio_pll_setting {
1078 struct cvmx_mio_pll_setting_s cn31xx; 1220 struct cvmx_mio_pll_setting_s cn31xx;
1079}; 1221};
1080 1222
1223union cvmx_mio_ptp_clock_cfg {
1224 uint64_t u64;
1225 struct cvmx_mio_ptp_clock_cfg_s {
1226 uint64_t reserved_24_63:40;
1227 uint64_t evcnt_in:6;
1228 uint64_t evcnt_edge:1;
1229 uint64_t evcnt_en:1;
1230 uint64_t tstmp_in:6;
1231 uint64_t tstmp_edge:1;
1232 uint64_t tstmp_en:1;
1233 uint64_t ext_clk_in:6;
1234 uint64_t ext_clk_en:1;
1235 uint64_t ptp_en:1;
1236 } s;
1237 struct cvmx_mio_ptp_clock_cfg_s cn63xx;
1238 struct cvmx_mio_ptp_clock_cfg_s cn63xxp1;
1239};
1240
1241union cvmx_mio_ptp_clock_comp {
1242 uint64_t u64;
1243 struct cvmx_mio_ptp_clock_comp_s {
1244 uint64_t nanosec:32;
1245 uint64_t frnanosec:32;
1246 } s;
1247 struct cvmx_mio_ptp_clock_comp_s cn63xx;
1248 struct cvmx_mio_ptp_clock_comp_s cn63xxp1;
1249};
1250
1251union cvmx_mio_ptp_clock_hi {
1252 uint64_t u64;
1253 struct cvmx_mio_ptp_clock_hi_s {
1254 uint64_t nanosec:64;
1255 } s;
1256 struct cvmx_mio_ptp_clock_hi_s cn63xx;
1257 struct cvmx_mio_ptp_clock_hi_s cn63xxp1;
1258};
1259
1260union cvmx_mio_ptp_clock_lo {
1261 uint64_t u64;
1262 struct cvmx_mio_ptp_clock_lo_s {
1263 uint64_t reserved_32_63:32;
1264 uint64_t frnanosec:32;
1265 } s;
1266 struct cvmx_mio_ptp_clock_lo_s cn63xx;
1267 struct cvmx_mio_ptp_clock_lo_s cn63xxp1;
1268};
1269
1270union cvmx_mio_ptp_evt_cnt {
1271 uint64_t u64;
1272 struct cvmx_mio_ptp_evt_cnt_s {
1273 uint64_t cntr:64;
1274 } s;
1275 struct cvmx_mio_ptp_evt_cnt_s cn63xx;
1276 struct cvmx_mio_ptp_evt_cnt_s cn63xxp1;
1277};
1278
1279union cvmx_mio_ptp_timestamp {
1280 uint64_t u64;
1281 struct cvmx_mio_ptp_timestamp_s {
1282 uint64_t nanosec:64;
1283 } s;
1284 struct cvmx_mio_ptp_timestamp_s cn63xx;
1285 struct cvmx_mio_ptp_timestamp_s cn63xxp1;
1286};
1287
1288union cvmx_mio_rst_boot {
1289 uint64_t u64;
1290 struct cvmx_mio_rst_boot_s {
1291 uint64_t reserved_36_63:28;
1292 uint64_t c_mul:6;
1293 uint64_t pnr_mul:6;
1294 uint64_t qlm2_spd:4;
1295 uint64_t qlm1_spd:4;
1296 uint64_t qlm0_spd:4;
1297 uint64_t lboot:10;
1298 uint64_t rboot:1;
1299 uint64_t rboot_pin:1;
1300 } s;
1301 struct cvmx_mio_rst_boot_s cn63xx;
1302 struct cvmx_mio_rst_boot_s cn63xxp1;
1303};
1304
1305union cvmx_mio_rst_cfg {
1306 uint64_t u64;
1307 struct cvmx_mio_rst_cfg_s {
1308 uint64_t bist_delay:58;
1309 uint64_t reserved_3_5:3;
1310 uint64_t cntl_clr_bist:1;
1311 uint64_t warm_clr_bist:1;
1312 uint64_t soft_clr_bist:1;
1313 } s;
1314 struct cvmx_mio_rst_cfg_s cn63xx;
1315 struct cvmx_mio_rst_cfg_cn63xxp1 {
1316 uint64_t bist_delay:58;
1317 uint64_t reserved_2_5:4;
1318 uint64_t warm_clr_bist:1;
1319 uint64_t soft_clr_bist:1;
1320 } cn63xxp1;
1321};
1322
1323union cvmx_mio_rst_ctlx {
1324 uint64_t u64;
1325 struct cvmx_mio_rst_ctlx_s {
1326 uint64_t reserved_10_63:54;
1327 uint64_t prst_link:1;
1328 uint64_t rst_done:1;
1329 uint64_t rst_link:1;
1330 uint64_t host_mode:1;
1331 uint64_t prtmode:2;
1332 uint64_t rst_drv:1;
1333 uint64_t rst_rcv:1;
1334 uint64_t rst_chip:1;
1335 uint64_t rst_val:1;
1336 } s;
1337 struct cvmx_mio_rst_ctlx_s cn63xx;
1338 struct cvmx_mio_rst_ctlx_cn63xxp1 {
1339 uint64_t reserved_9_63:55;
1340 uint64_t rst_done:1;
1341 uint64_t rst_link:1;
1342 uint64_t host_mode:1;
1343 uint64_t prtmode:2;
1344 uint64_t rst_drv:1;
1345 uint64_t rst_rcv:1;
1346 uint64_t rst_chip:1;
1347 uint64_t rst_val:1;
1348 } cn63xxp1;
1349};
1350
1351union cvmx_mio_rst_delay {
1352 uint64_t u64;
1353 struct cvmx_mio_rst_delay_s {
1354 uint64_t reserved_32_63:32;
1355 uint64_t soft_rst_dly:16;
1356 uint64_t warm_rst_dly:16;
1357 } s;
1358 struct cvmx_mio_rst_delay_s cn63xx;
1359 struct cvmx_mio_rst_delay_s cn63xxp1;
1360};
1361
1362union cvmx_mio_rst_int {
1363 uint64_t u64;
1364 struct cvmx_mio_rst_int_s {
1365 uint64_t reserved_10_63:54;
1366 uint64_t perst1:1;
1367 uint64_t perst0:1;
1368 uint64_t reserved_2_7:6;
1369 uint64_t rst_link1:1;
1370 uint64_t rst_link0:1;
1371 } s;
1372 struct cvmx_mio_rst_int_s cn63xx;
1373 struct cvmx_mio_rst_int_s cn63xxp1;
1374};
1375
1376union cvmx_mio_rst_int_en {
1377 uint64_t u64;
1378 struct cvmx_mio_rst_int_en_s {
1379 uint64_t reserved_10_63:54;
1380 uint64_t perst1:1;
1381 uint64_t perst0:1;
1382 uint64_t reserved_2_7:6;
1383 uint64_t rst_link1:1;
1384 uint64_t rst_link0:1;
1385 } s;
1386 struct cvmx_mio_rst_int_en_s cn63xx;
1387 struct cvmx_mio_rst_int_en_s cn63xxp1;
1388};
1389
1081union cvmx_mio_twsx_int { 1390union cvmx_mio_twsx_int {
1082 uint64_t u64; 1391 uint64_t u64;
1083 struct cvmx_mio_twsx_int_s { 1392 struct cvmx_mio_twsx_int_s {
@@ -1115,6 +1424,8 @@ union cvmx_mio_twsx_int {
1115 struct cvmx_mio_twsx_int_s cn56xxp1; 1424 struct cvmx_mio_twsx_int_s cn56xxp1;
1116 struct cvmx_mio_twsx_int_s cn58xx; 1425 struct cvmx_mio_twsx_int_s cn58xx;
1117 struct cvmx_mio_twsx_int_s cn58xxp1; 1426 struct cvmx_mio_twsx_int_s cn58xxp1;
1427 struct cvmx_mio_twsx_int_s cn63xx;
1428 struct cvmx_mio_twsx_int_s cn63xxp1;
1118}; 1429};
1119 1430
1120union cvmx_mio_twsx_sw_twsi { 1431union cvmx_mio_twsx_sw_twsi {
@@ -1144,6 +1455,8 @@ union cvmx_mio_twsx_sw_twsi {
1144 struct cvmx_mio_twsx_sw_twsi_s cn56xxp1; 1455 struct cvmx_mio_twsx_sw_twsi_s cn56xxp1;
1145 struct cvmx_mio_twsx_sw_twsi_s cn58xx; 1456 struct cvmx_mio_twsx_sw_twsi_s cn58xx;
1146 struct cvmx_mio_twsx_sw_twsi_s cn58xxp1; 1457 struct cvmx_mio_twsx_sw_twsi_s cn58xxp1;
1458 struct cvmx_mio_twsx_sw_twsi_s cn63xx;
1459 struct cvmx_mio_twsx_sw_twsi_s cn63xxp1;
1147}; 1460};
1148 1461
1149union cvmx_mio_twsx_sw_twsi_ext { 1462union cvmx_mio_twsx_sw_twsi_ext {
@@ -1164,6 +1477,8 @@ union cvmx_mio_twsx_sw_twsi_ext {
1164 struct cvmx_mio_twsx_sw_twsi_ext_s cn56xxp1; 1477 struct cvmx_mio_twsx_sw_twsi_ext_s cn56xxp1;
1165 struct cvmx_mio_twsx_sw_twsi_ext_s cn58xx; 1478 struct cvmx_mio_twsx_sw_twsi_ext_s cn58xx;
1166 struct cvmx_mio_twsx_sw_twsi_ext_s cn58xxp1; 1479 struct cvmx_mio_twsx_sw_twsi_ext_s cn58xxp1;
1480 struct cvmx_mio_twsx_sw_twsi_ext_s cn63xx;
1481 struct cvmx_mio_twsx_sw_twsi_ext_s cn63xxp1;
1167}; 1482};
1168 1483
1169union cvmx_mio_twsx_twsi_sw { 1484union cvmx_mio_twsx_twsi_sw {
@@ -1184,6 +1499,8 @@ union cvmx_mio_twsx_twsi_sw {
1184 struct cvmx_mio_twsx_twsi_sw_s cn56xxp1; 1499 struct cvmx_mio_twsx_twsi_sw_s cn56xxp1;
1185 struct cvmx_mio_twsx_twsi_sw_s cn58xx; 1500 struct cvmx_mio_twsx_twsi_sw_s cn58xx;
1186 struct cvmx_mio_twsx_twsi_sw_s cn58xxp1; 1501 struct cvmx_mio_twsx_twsi_sw_s cn58xxp1;
1502 struct cvmx_mio_twsx_twsi_sw_s cn63xx;
1503 struct cvmx_mio_twsx_twsi_sw_s cn63xxp1;
1187}; 1504};
1188 1505
1189union cvmx_mio_uartx_dlh { 1506union cvmx_mio_uartx_dlh {
@@ -1203,6 +1520,8 @@ union cvmx_mio_uartx_dlh {
1203 struct cvmx_mio_uartx_dlh_s cn56xxp1; 1520 struct cvmx_mio_uartx_dlh_s cn56xxp1;
1204 struct cvmx_mio_uartx_dlh_s cn58xx; 1521 struct cvmx_mio_uartx_dlh_s cn58xx;
1205 struct cvmx_mio_uartx_dlh_s cn58xxp1; 1522 struct cvmx_mio_uartx_dlh_s cn58xxp1;
1523 struct cvmx_mio_uartx_dlh_s cn63xx;
1524 struct cvmx_mio_uartx_dlh_s cn63xxp1;
1206}; 1525};
1207 1526
1208union cvmx_mio_uartx_dll { 1527union cvmx_mio_uartx_dll {
@@ -1222,6 +1541,8 @@ union cvmx_mio_uartx_dll {
1222 struct cvmx_mio_uartx_dll_s cn56xxp1; 1541 struct cvmx_mio_uartx_dll_s cn56xxp1;
1223 struct cvmx_mio_uartx_dll_s cn58xx; 1542 struct cvmx_mio_uartx_dll_s cn58xx;
1224 struct cvmx_mio_uartx_dll_s cn58xxp1; 1543 struct cvmx_mio_uartx_dll_s cn58xxp1;
1544 struct cvmx_mio_uartx_dll_s cn63xx;
1545 struct cvmx_mio_uartx_dll_s cn63xxp1;
1225}; 1546};
1226 1547
1227union cvmx_mio_uartx_far { 1548union cvmx_mio_uartx_far {
@@ -1241,6 +1562,8 @@ union cvmx_mio_uartx_far {
1241 struct cvmx_mio_uartx_far_s cn56xxp1; 1562 struct cvmx_mio_uartx_far_s cn56xxp1;
1242 struct cvmx_mio_uartx_far_s cn58xx; 1563 struct cvmx_mio_uartx_far_s cn58xx;
1243 struct cvmx_mio_uartx_far_s cn58xxp1; 1564 struct cvmx_mio_uartx_far_s cn58xxp1;
1565 struct cvmx_mio_uartx_far_s cn63xx;
1566 struct cvmx_mio_uartx_far_s cn63xxp1;
1244}; 1567};
1245 1568
1246union cvmx_mio_uartx_fcr { 1569union cvmx_mio_uartx_fcr {
@@ -1265,6 +1588,8 @@ union cvmx_mio_uartx_fcr {
1265 struct cvmx_mio_uartx_fcr_s cn56xxp1; 1588 struct cvmx_mio_uartx_fcr_s cn56xxp1;
1266 struct cvmx_mio_uartx_fcr_s cn58xx; 1589 struct cvmx_mio_uartx_fcr_s cn58xx;
1267 struct cvmx_mio_uartx_fcr_s cn58xxp1; 1590 struct cvmx_mio_uartx_fcr_s cn58xxp1;
1591 struct cvmx_mio_uartx_fcr_s cn63xx;
1592 struct cvmx_mio_uartx_fcr_s cn63xxp1;
1268}; 1593};
1269 1594
1270union cvmx_mio_uartx_htx { 1595union cvmx_mio_uartx_htx {
@@ -1284,6 +1609,8 @@ union cvmx_mio_uartx_htx {
1284 struct cvmx_mio_uartx_htx_s cn56xxp1; 1609 struct cvmx_mio_uartx_htx_s cn56xxp1;
1285 struct cvmx_mio_uartx_htx_s cn58xx; 1610 struct cvmx_mio_uartx_htx_s cn58xx;
1286 struct cvmx_mio_uartx_htx_s cn58xxp1; 1611 struct cvmx_mio_uartx_htx_s cn58xxp1;
1612 struct cvmx_mio_uartx_htx_s cn63xx;
1613 struct cvmx_mio_uartx_htx_s cn63xxp1;
1287}; 1614};
1288 1615
1289union cvmx_mio_uartx_ier { 1616union cvmx_mio_uartx_ier {
@@ -1308,6 +1635,8 @@ union cvmx_mio_uartx_ier {
1308 struct cvmx_mio_uartx_ier_s cn56xxp1; 1635 struct cvmx_mio_uartx_ier_s cn56xxp1;
1309 struct cvmx_mio_uartx_ier_s cn58xx; 1636 struct cvmx_mio_uartx_ier_s cn58xx;
1310 struct cvmx_mio_uartx_ier_s cn58xxp1; 1637 struct cvmx_mio_uartx_ier_s cn58xxp1;
1638 struct cvmx_mio_uartx_ier_s cn63xx;
1639 struct cvmx_mio_uartx_ier_s cn63xxp1;
1311}; 1640};
1312 1641
1313union cvmx_mio_uartx_iir { 1642union cvmx_mio_uartx_iir {
@@ -1329,6 +1658,8 @@ union cvmx_mio_uartx_iir {
1329 struct cvmx_mio_uartx_iir_s cn56xxp1; 1658 struct cvmx_mio_uartx_iir_s cn56xxp1;
1330 struct cvmx_mio_uartx_iir_s cn58xx; 1659 struct cvmx_mio_uartx_iir_s cn58xx;
1331 struct cvmx_mio_uartx_iir_s cn58xxp1; 1660 struct cvmx_mio_uartx_iir_s cn58xxp1;
1661 struct cvmx_mio_uartx_iir_s cn63xx;
1662 struct cvmx_mio_uartx_iir_s cn63xxp1;
1332}; 1663};
1333 1664
1334union cvmx_mio_uartx_lcr { 1665union cvmx_mio_uartx_lcr {
@@ -1354,6 +1685,8 @@ union cvmx_mio_uartx_lcr {
1354 struct cvmx_mio_uartx_lcr_s cn56xxp1; 1685 struct cvmx_mio_uartx_lcr_s cn56xxp1;
1355 struct cvmx_mio_uartx_lcr_s cn58xx; 1686 struct cvmx_mio_uartx_lcr_s cn58xx;
1356 struct cvmx_mio_uartx_lcr_s cn58xxp1; 1687 struct cvmx_mio_uartx_lcr_s cn58xxp1;
1688 struct cvmx_mio_uartx_lcr_s cn63xx;
1689 struct cvmx_mio_uartx_lcr_s cn63xxp1;
1357}; 1690};
1358 1691
1359union cvmx_mio_uartx_lsr { 1692union cvmx_mio_uartx_lsr {
@@ -1380,6 +1713,8 @@ union cvmx_mio_uartx_lsr {
1380 struct cvmx_mio_uartx_lsr_s cn56xxp1; 1713 struct cvmx_mio_uartx_lsr_s cn56xxp1;
1381 struct cvmx_mio_uartx_lsr_s cn58xx; 1714 struct cvmx_mio_uartx_lsr_s cn58xx;
1382 struct cvmx_mio_uartx_lsr_s cn58xxp1; 1715 struct cvmx_mio_uartx_lsr_s cn58xxp1;
1716 struct cvmx_mio_uartx_lsr_s cn63xx;
1717 struct cvmx_mio_uartx_lsr_s cn63xxp1;
1383}; 1718};
1384 1719
1385union cvmx_mio_uartx_mcr { 1720union cvmx_mio_uartx_mcr {
@@ -1404,6 +1739,8 @@ union cvmx_mio_uartx_mcr {
1404 struct cvmx_mio_uartx_mcr_s cn56xxp1; 1739 struct cvmx_mio_uartx_mcr_s cn56xxp1;
1405 struct cvmx_mio_uartx_mcr_s cn58xx; 1740 struct cvmx_mio_uartx_mcr_s cn58xx;
1406 struct cvmx_mio_uartx_mcr_s cn58xxp1; 1741 struct cvmx_mio_uartx_mcr_s cn58xxp1;
1742 struct cvmx_mio_uartx_mcr_s cn63xx;
1743 struct cvmx_mio_uartx_mcr_s cn63xxp1;
1407}; 1744};
1408 1745
1409union cvmx_mio_uartx_msr { 1746union cvmx_mio_uartx_msr {
@@ -1430,6 +1767,8 @@ union cvmx_mio_uartx_msr {
1430 struct cvmx_mio_uartx_msr_s cn56xxp1; 1767 struct cvmx_mio_uartx_msr_s cn56xxp1;
1431 struct cvmx_mio_uartx_msr_s cn58xx; 1768 struct cvmx_mio_uartx_msr_s cn58xx;
1432 struct cvmx_mio_uartx_msr_s cn58xxp1; 1769 struct cvmx_mio_uartx_msr_s cn58xxp1;
1770 struct cvmx_mio_uartx_msr_s cn63xx;
1771 struct cvmx_mio_uartx_msr_s cn63xxp1;
1433}; 1772};
1434 1773
1435union cvmx_mio_uartx_rbr { 1774union cvmx_mio_uartx_rbr {
@@ -1449,6 +1788,8 @@ union cvmx_mio_uartx_rbr {
1449 struct cvmx_mio_uartx_rbr_s cn56xxp1; 1788 struct cvmx_mio_uartx_rbr_s cn56xxp1;
1450 struct cvmx_mio_uartx_rbr_s cn58xx; 1789 struct cvmx_mio_uartx_rbr_s cn58xx;
1451 struct cvmx_mio_uartx_rbr_s cn58xxp1; 1790 struct cvmx_mio_uartx_rbr_s cn58xxp1;
1791 struct cvmx_mio_uartx_rbr_s cn63xx;
1792 struct cvmx_mio_uartx_rbr_s cn63xxp1;
1452}; 1793};
1453 1794
1454union cvmx_mio_uartx_rfl { 1795union cvmx_mio_uartx_rfl {
@@ -1468,6 +1809,8 @@ union cvmx_mio_uartx_rfl {
1468 struct cvmx_mio_uartx_rfl_s cn56xxp1; 1809 struct cvmx_mio_uartx_rfl_s cn56xxp1;
1469 struct cvmx_mio_uartx_rfl_s cn58xx; 1810 struct cvmx_mio_uartx_rfl_s cn58xx;
1470 struct cvmx_mio_uartx_rfl_s cn58xxp1; 1811 struct cvmx_mio_uartx_rfl_s cn58xxp1;
1812 struct cvmx_mio_uartx_rfl_s cn63xx;
1813 struct cvmx_mio_uartx_rfl_s cn63xxp1;
1471}; 1814};
1472 1815
1473union cvmx_mio_uartx_rfw { 1816union cvmx_mio_uartx_rfw {
@@ -1489,6 +1832,8 @@ union cvmx_mio_uartx_rfw {
1489 struct cvmx_mio_uartx_rfw_s cn56xxp1; 1832 struct cvmx_mio_uartx_rfw_s cn56xxp1;
1490 struct cvmx_mio_uartx_rfw_s cn58xx; 1833 struct cvmx_mio_uartx_rfw_s cn58xx;
1491 struct cvmx_mio_uartx_rfw_s cn58xxp1; 1834 struct cvmx_mio_uartx_rfw_s cn58xxp1;
1835 struct cvmx_mio_uartx_rfw_s cn63xx;
1836 struct cvmx_mio_uartx_rfw_s cn63xxp1;
1492}; 1837};
1493 1838
1494union cvmx_mio_uartx_sbcr { 1839union cvmx_mio_uartx_sbcr {
@@ -1508,6 +1853,8 @@ union cvmx_mio_uartx_sbcr {
1508 struct cvmx_mio_uartx_sbcr_s cn56xxp1; 1853 struct cvmx_mio_uartx_sbcr_s cn56xxp1;
1509 struct cvmx_mio_uartx_sbcr_s cn58xx; 1854 struct cvmx_mio_uartx_sbcr_s cn58xx;
1510 struct cvmx_mio_uartx_sbcr_s cn58xxp1; 1855 struct cvmx_mio_uartx_sbcr_s cn58xxp1;
1856 struct cvmx_mio_uartx_sbcr_s cn63xx;
1857 struct cvmx_mio_uartx_sbcr_s cn63xxp1;
1511}; 1858};
1512 1859
1513union cvmx_mio_uartx_scr { 1860union cvmx_mio_uartx_scr {
@@ -1527,6 +1874,8 @@ union cvmx_mio_uartx_scr {
1527 struct cvmx_mio_uartx_scr_s cn56xxp1; 1874 struct cvmx_mio_uartx_scr_s cn56xxp1;
1528 struct cvmx_mio_uartx_scr_s cn58xx; 1875 struct cvmx_mio_uartx_scr_s cn58xx;
1529 struct cvmx_mio_uartx_scr_s cn58xxp1; 1876 struct cvmx_mio_uartx_scr_s cn58xxp1;
1877 struct cvmx_mio_uartx_scr_s cn63xx;
1878 struct cvmx_mio_uartx_scr_s cn63xxp1;
1530}; 1879};
1531 1880
1532union cvmx_mio_uartx_sfe { 1881union cvmx_mio_uartx_sfe {
@@ -1546,6 +1895,8 @@ union cvmx_mio_uartx_sfe {
1546 struct cvmx_mio_uartx_sfe_s cn56xxp1; 1895 struct cvmx_mio_uartx_sfe_s cn56xxp1;
1547 struct cvmx_mio_uartx_sfe_s cn58xx; 1896 struct cvmx_mio_uartx_sfe_s cn58xx;
1548 struct cvmx_mio_uartx_sfe_s cn58xxp1; 1897 struct cvmx_mio_uartx_sfe_s cn58xxp1;
1898 struct cvmx_mio_uartx_sfe_s cn63xx;
1899 struct cvmx_mio_uartx_sfe_s cn63xxp1;
1549}; 1900};
1550 1901
1551union cvmx_mio_uartx_srr { 1902union cvmx_mio_uartx_srr {
@@ -1567,6 +1918,8 @@ union cvmx_mio_uartx_srr {
1567 struct cvmx_mio_uartx_srr_s cn56xxp1; 1918 struct cvmx_mio_uartx_srr_s cn56xxp1;
1568 struct cvmx_mio_uartx_srr_s cn58xx; 1919 struct cvmx_mio_uartx_srr_s cn58xx;
1569 struct cvmx_mio_uartx_srr_s cn58xxp1; 1920 struct cvmx_mio_uartx_srr_s cn58xxp1;
1921 struct cvmx_mio_uartx_srr_s cn63xx;
1922 struct cvmx_mio_uartx_srr_s cn63xxp1;
1570}; 1923};
1571 1924
1572union cvmx_mio_uartx_srt { 1925union cvmx_mio_uartx_srt {
@@ -1586,6 +1939,8 @@ union cvmx_mio_uartx_srt {
1586 struct cvmx_mio_uartx_srt_s cn56xxp1; 1939 struct cvmx_mio_uartx_srt_s cn56xxp1;
1587 struct cvmx_mio_uartx_srt_s cn58xx; 1940 struct cvmx_mio_uartx_srt_s cn58xx;
1588 struct cvmx_mio_uartx_srt_s cn58xxp1; 1941 struct cvmx_mio_uartx_srt_s cn58xxp1;
1942 struct cvmx_mio_uartx_srt_s cn63xx;
1943 struct cvmx_mio_uartx_srt_s cn63xxp1;
1589}; 1944};
1590 1945
1591union cvmx_mio_uartx_srts { 1946union cvmx_mio_uartx_srts {
@@ -1605,6 +1960,8 @@ union cvmx_mio_uartx_srts {
1605 struct cvmx_mio_uartx_srts_s cn56xxp1; 1960 struct cvmx_mio_uartx_srts_s cn56xxp1;
1606 struct cvmx_mio_uartx_srts_s cn58xx; 1961 struct cvmx_mio_uartx_srts_s cn58xx;
1607 struct cvmx_mio_uartx_srts_s cn58xxp1; 1962 struct cvmx_mio_uartx_srts_s cn58xxp1;
1963 struct cvmx_mio_uartx_srts_s cn63xx;
1964 struct cvmx_mio_uartx_srts_s cn63xxp1;
1608}; 1965};
1609 1966
1610union cvmx_mio_uartx_stt { 1967union cvmx_mio_uartx_stt {
@@ -1624,6 +1981,8 @@ union cvmx_mio_uartx_stt {
1624 struct cvmx_mio_uartx_stt_s cn56xxp1; 1981 struct cvmx_mio_uartx_stt_s cn56xxp1;
1625 struct cvmx_mio_uartx_stt_s cn58xx; 1982 struct cvmx_mio_uartx_stt_s cn58xx;
1626 struct cvmx_mio_uartx_stt_s cn58xxp1; 1983 struct cvmx_mio_uartx_stt_s cn58xxp1;
1984 struct cvmx_mio_uartx_stt_s cn63xx;
1985 struct cvmx_mio_uartx_stt_s cn63xxp1;
1627}; 1986};
1628 1987
1629union cvmx_mio_uartx_tfl { 1988union cvmx_mio_uartx_tfl {
@@ -1643,6 +2002,8 @@ union cvmx_mio_uartx_tfl {
1643 struct cvmx_mio_uartx_tfl_s cn56xxp1; 2002 struct cvmx_mio_uartx_tfl_s cn56xxp1;
1644 struct cvmx_mio_uartx_tfl_s cn58xx; 2003 struct cvmx_mio_uartx_tfl_s cn58xx;
1645 struct cvmx_mio_uartx_tfl_s cn58xxp1; 2004 struct cvmx_mio_uartx_tfl_s cn58xxp1;
2005 struct cvmx_mio_uartx_tfl_s cn63xx;
2006 struct cvmx_mio_uartx_tfl_s cn63xxp1;
1646}; 2007};
1647 2008
1648union cvmx_mio_uartx_tfr { 2009union cvmx_mio_uartx_tfr {
@@ -1662,6 +2023,8 @@ union cvmx_mio_uartx_tfr {
1662 struct cvmx_mio_uartx_tfr_s cn56xxp1; 2023 struct cvmx_mio_uartx_tfr_s cn56xxp1;
1663 struct cvmx_mio_uartx_tfr_s cn58xx; 2024 struct cvmx_mio_uartx_tfr_s cn58xx;
1664 struct cvmx_mio_uartx_tfr_s cn58xxp1; 2025 struct cvmx_mio_uartx_tfr_s cn58xxp1;
2026 struct cvmx_mio_uartx_tfr_s cn63xx;
2027 struct cvmx_mio_uartx_tfr_s cn63xxp1;
1665}; 2028};
1666 2029
1667union cvmx_mio_uartx_thr { 2030union cvmx_mio_uartx_thr {
@@ -1681,6 +2044,8 @@ union cvmx_mio_uartx_thr {
1681 struct cvmx_mio_uartx_thr_s cn56xxp1; 2044 struct cvmx_mio_uartx_thr_s cn56xxp1;
1682 struct cvmx_mio_uartx_thr_s cn58xx; 2045 struct cvmx_mio_uartx_thr_s cn58xx;
1683 struct cvmx_mio_uartx_thr_s cn58xxp1; 2046 struct cvmx_mio_uartx_thr_s cn58xxp1;
2047 struct cvmx_mio_uartx_thr_s cn63xx;
2048 struct cvmx_mio_uartx_thr_s cn63xxp1;
1684}; 2049};
1685 2050
1686union cvmx_mio_uartx_usr { 2051union cvmx_mio_uartx_usr {
@@ -1704,6 +2069,8 @@ union cvmx_mio_uartx_usr {
1704 struct cvmx_mio_uartx_usr_s cn56xxp1; 2069 struct cvmx_mio_uartx_usr_s cn56xxp1;
1705 struct cvmx_mio_uartx_usr_s cn58xx; 2070 struct cvmx_mio_uartx_usr_s cn58xx;
1706 struct cvmx_mio_uartx_usr_s cn58xxp1; 2071 struct cvmx_mio_uartx_usr_s cn58xxp1;
2072 struct cvmx_mio_uartx_usr_s cn63xx;
2073 struct cvmx_mio_uartx_usr_s cn63xxp1;
1707}; 2074};
1708 2075
1709union cvmx_mio_uart2_dlh { 2076union cvmx_mio_uart2_dlh {
diff --git a/arch/mips/include/asm/octeon/cvmx-mixx-defs.h b/arch/mips/include/asm/octeon/cvmx-mixx-defs.h
index dab6dca492f9..7057c447e69e 100644
--- a/arch/mips/include/asm/octeon/cvmx-mixx-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-mixx-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,52 +28,52 @@
28#ifndef __CVMX_MIXX_DEFS_H__ 28#ifndef __CVMX_MIXX_DEFS_H__
29#define __CVMX_MIXX_DEFS_H__ 29#define __CVMX_MIXX_DEFS_H__
30 30
31#define CVMX_MIXX_BIST(offset) \ 31#define CVMX_MIXX_BIST(offset) (CVMX_ADD_IO_SEG(0x0001070000100078ull) + ((offset) & 1) * 2048)
32 CVMX_ADD_IO_SEG(0x0001070000100078ull + (((offset) & 1) * 2048)) 32#define CVMX_MIXX_CTL(offset) (CVMX_ADD_IO_SEG(0x0001070000100020ull) + ((offset) & 1) * 2048)
33#define CVMX_MIXX_CTL(offset) \ 33#define CVMX_MIXX_INTENA(offset) (CVMX_ADD_IO_SEG(0x0001070000100050ull) + ((offset) & 1) * 2048)
34 CVMX_ADD_IO_SEG(0x0001070000100020ull + (((offset) & 1) * 2048)) 34#define CVMX_MIXX_IRCNT(offset) (CVMX_ADD_IO_SEG(0x0001070000100030ull) + ((offset) & 1) * 2048)
35#define CVMX_MIXX_INTENA(offset) \ 35#define CVMX_MIXX_IRHWM(offset) (CVMX_ADD_IO_SEG(0x0001070000100028ull) + ((offset) & 1) * 2048)
36 CVMX_ADD_IO_SEG(0x0001070000100050ull + (((offset) & 1) * 2048)) 36#define CVMX_MIXX_IRING1(offset) (CVMX_ADD_IO_SEG(0x0001070000100010ull) + ((offset) & 1) * 2048)
37#define CVMX_MIXX_IRCNT(offset) \ 37#define CVMX_MIXX_IRING2(offset) (CVMX_ADD_IO_SEG(0x0001070000100018ull) + ((offset) & 1) * 2048)
38 CVMX_ADD_IO_SEG(0x0001070000100030ull + (((offset) & 1) * 2048)) 38#define CVMX_MIXX_ISR(offset) (CVMX_ADD_IO_SEG(0x0001070000100048ull) + ((offset) & 1) * 2048)
39#define CVMX_MIXX_IRHWM(offset) \ 39#define CVMX_MIXX_ORCNT(offset) (CVMX_ADD_IO_SEG(0x0001070000100040ull) + ((offset) & 1) * 2048)
40 CVMX_ADD_IO_SEG(0x0001070000100028ull + (((offset) & 1) * 2048)) 40#define CVMX_MIXX_ORHWM(offset) (CVMX_ADD_IO_SEG(0x0001070000100038ull) + ((offset) & 1) * 2048)
41#define CVMX_MIXX_IRING1(offset) \ 41#define CVMX_MIXX_ORING1(offset) (CVMX_ADD_IO_SEG(0x0001070000100000ull) + ((offset) & 1) * 2048)
42 CVMX_ADD_IO_SEG(0x0001070000100010ull + (((offset) & 1) * 2048)) 42#define CVMX_MIXX_ORING2(offset) (CVMX_ADD_IO_SEG(0x0001070000100008ull) + ((offset) & 1) * 2048)
43#define CVMX_MIXX_IRING2(offset) \ 43#define CVMX_MIXX_REMCNT(offset) (CVMX_ADD_IO_SEG(0x0001070000100058ull) + ((offset) & 1) * 2048)
44 CVMX_ADD_IO_SEG(0x0001070000100018ull + (((offset) & 1) * 2048)) 44#define CVMX_MIXX_TSCTL(offset) (CVMX_ADD_IO_SEG(0x0001070000100068ull) + ((offset) & 1) * 2048)
45#define CVMX_MIXX_ISR(offset) \ 45#define CVMX_MIXX_TSTAMP(offset) (CVMX_ADD_IO_SEG(0x0001070000100060ull) + ((offset) & 1) * 2048)
46 CVMX_ADD_IO_SEG(0x0001070000100048ull + (((offset) & 1) * 2048))
47#define CVMX_MIXX_ORCNT(offset) \
48 CVMX_ADD_IO_SEG(0x0001070000100040ull + (((offset) & 1) * 2048))
49#define CVMX_MIXX_ORHWM(offset) \
50 CVMX_ADD_IO_SEG(0x0001070000100038ull + (((offset) & 1) * 2048))
51#define CVMX_MIXX_ORING1(offset) \
52 CVMX_ADD_IO_SEG(0x0001070000100000ull + (((offset) & 1) * 2048))
53#define CVMX_MIXX_ORING2(offset) \
54 CVMX_ADD_IO_SEG(0x0001070000100008ull + (((offset) & 1) * 2048))
55#define CVMX_MIXX_REMCNT(offset) \
56 CVMX_ADD_IO_SEG(0x0001070000100058ull + (((offset) & 1) * 2048))
57 46
58union cvmx_mixx_bist { 47union cvmx_mixx_bist {
59 uint64_t u64; 48 uint64_t u64;
60 struct cvmx_mixx_bist_s { 49 struct cvmx_mixx_bist_s {
61 uint64_t reserved_4_63:60; 50 uint64_t reserved_6_63:58;
51 uint64_t opfdat:1;
52 uint64_t mrgdat:1;
62 uint64_t mrqdat:1; 53 uint64_t mrqdat:1;
63 uint64_t ipfdat:1; 54 uint64_t ipfdat:1;
64 uint64_t irfdat:1; 55 uint64_t irfdat:1;
65 uint64_t orfdat:1; 56 uint64_t orfdat:1;
66 } s; 57 } s;
67 struct cvmx_mixx_bist_s cn52xx; 58 struct cvmx_mixx_bist_cn52xx {
68 struct cvmx_mixx_bist_s cn52xxp1; 59 uint64_t reserved_4_63:60;
69 struct cvmx_mixx_bist_s cn56xx; 60 uint64_t mrqdat:1;
70 struct cvmx_mixx_bist_s cn56xxp1; 61 uint64_t ipfdat:1;
62 uint64_t irfdat:1;
63 uint64_t orfdat:1;
64 } cn52xx;
65 struct cvmx_mixx_bist_cn52xx cn52xxp1;
66 struct cvmx_mixx_bist_cn52xx cn56xx;
67 struct cvmx_mixx_bist_cn52xx cn56xxp1;
68 struct cvmx_mixx_bist_s cn63xx;
69 struct cvmx_mixx_bist_s cn63xxp1;
71}; 70};
72 71
73union cvmx_mixx_ctl { 72union cvmx_mixx_ctl {
74 uint64_t u64; 73 uint64_t u64;
75 struct cvmx_mixx_ctl_s { 74 struct cvmx_mixx_ctl_s {
76 uint64_t reserved_8_63:56; 75 uint64_t reserved_12_63:52;
76 uint64_t ts_thresh:4;
77 uint64_t crc_strip:1; 77 uint64_t crc_strip:1;
78 uint64_t busy:1; 78 uint64_t busy:1;
79 uint64_t en:1; 79 uint64_t en:1;
@@ -82,16 +82,28 @@ union cvmx_mixx_ctl {
82 uint64_t nbtarb:1; 82 uint64_t nbtarb:1;
83 uint64_t mrq_hwm:2; 83 uint64_t mrq_hwm:2;
84 } s; 84 } s;
85 struct cvmx_mixx_ctl_s cn52xx; 85 struct cvmx_mixx_ctl_cn52xx {
86 struct cvmx_mixx_ctl_s cn52xxp1; 86 uint64_t reserved_8_63:56;
87 struct cvmx_mixx_ctl_s cn56xx; 87 uint64_t crc_strip:1;
88 struct cvmx_mixx_ctl_s cn56xxp1; 88 uint64_t busy:1;
89 uint64_t en:1;
90 uint64_t reset:1;
91 uint64_t lendian:1;
92 uint64_t nbtarb:1;
93 uint64_t mrq_hwm:2;
94 } cn52xx;
95 struct cvmx_mixx_ctl_cn52xx cn52xxp1;
96 struct cvmx_mixx_ctl_cn52xx cn56xx;
97 struct cvmx_mixx_ctl_cn52xx cn56xxp1;
98 struct cvmx_mixx_ctl_s cn63xx;
99 struct cvmx_mixx_ctl_s cn63xxp1;
89}; 100};
90 101
91union cvmx_mixx_intena { 102union cvmx_mixx_intena {
92 uint64_t u64; 103 uint64_t u64;
93 struct cvmx_mixx_intena_s { 104 struct cvmx_mixx_intena_s {
94 uint64_t reserved_7_63:57; 105 uint64_t reserved_8_63:56;
106 uint64_t tsena:1;
95 uint64_t orunena:1; 107 uint64_t orunena:1;
96 uint64_t irunena:1; 108 uint64_t irunena:1;
97 uint64_t data_drpena:1; 109 uint64_t data_drpena:1;
@@ -100,10 +112,21 @@ union cvmx_mixx_intena {
100 uint64_t ivfena:1; 112 uint64_t ivfena:1;
101 uint64_t ovfena:1; 113 uint64_t ovfena:1;
102 } s; 114 } s;
103 struct cvmx_mixx_intena_s cn52xx; 115 struct cvmx_mixx_intena_cn52xx {
104 struct cvmx_mixx_intena_s cn52xxp1; 116 uint64_t reserved_7_63:57;
105 struct cvmx_mixx_intena_s cn56xx; 117 uint64_t orunena:1;
106 struct cvmx_mixx_intena_s cn56xxp1; 118 uint64_t irunena:1;
119 uint64_t data_drpena:1;
120 uint64_t ithena:1;
121 uint64_t othena:1;
122 uint64_t ivfena:1;
123 uint64_t ovfena:1;
124 } cn52xx;
125 struct cvmx_mixx_intena_cn52xx cn52xxp1;
126 struct cvmx_mixx_intena_cn52xx cn56xx;
127 struct cvmx_mixx_intena_cn52xx cn56xxp1;
128 struct cvmx_mixx_intena_s cn63xx;
129 struct cvmx_mixx_intena_s cn63xxp1;
107}; 130};
108 131
109union cvmx_mixx_ircnt { 132union cvmx_mixx_ircnt {
@@ -116,6 +139,8 @@ union cvmx_mixx_ircnt {
116 struct cvmx_mixx_ircnt_s cn52xxp1; 139 struct cvmx_mixx_ircnt_s cn52xxp1;
117 struct cvmx_mixx_ircnt_s cn56xx; 140 struct cvmx_mixx_ircnt_s cn56xx;
118 struct cvmx_mixx_ircnt_s cn56xxp1; 141 struct cvmx_mixx_ircnt_s cn56xxp1;
142 struct cvmx_mixx_ircnt_s cn63xx;
143 struct cvmx_mixx_ircnt_s cn63xxp1;
119}; 144};
120 145
121union cvmx_mixx_irhwm { 146union cvmx_mixx_irhwm {
@@ -129,6 +154,8 @@ union cvmx_mixx_irhwm {
129 struct cvmx_mixx_irhwm_s cn52xxp1; 154 struct cvmx_mixx_irhwm_s cn52xxp1;
130 struct cvmx_mixx_irhwm_s cn56xx; 155 struct cvmx_mixx_irhwm_s cn56xx;
131 struct cvmx_mixx_irhwm_s cn56xxp1; 156 struct cvmx_mixx_irhwm_s cn56xxp1;
157 struct cvmx_mixx_irhwm_s cn63xx;
158 struct cvmx_mixx_irhwm_s cn63xxp1;
132}; 159};
133 160
134union cvmx_mixx_iring1 { 161union cvmx_mixx_iring1 {
@@ -136,14 +163,21 @@ union cvmx_mixx_iring1 {
136 struct cvmx_mixx_iring1_s { 163 struct cvmx_mixx_iring1_s {
137 uint64_t reserved_60_63:4; 164 uint64_t reserved_60_63:4;
138 uint64_t isize:20; 165 uint64_t isize:20;
166 uint64_t ibase:37;
167 uint64_t reserved_0_2:3;
168 } s;
169 struct cvmx_mixx_iring1_cn52xx {
170 uint64_t reserved_60_63:4;
171 uint64_t isize:20;
139 uint64_t reserved_36_39:4; 172 uint64_t reserved_36_39:4;
140 uint64_t ibase:33; 173 uint64_t ibase:33;
141 uint64_t reserved_0_2:3; 174 uint64_t reserved_0_2:3;
142 } s; 175 } cn52xx;
143 struct cvmx_mixx_iring1_s cn52xx; 176 struct cvmx_mixx_iring1_cn52xx cn52xxp1;
144 struct cvmx_mixx_iring1_s cn52xxp1; 177 struct cvmx_mixx_iring1_cn52xx cn56xx;
145 struct cvmx_mixx_iring1_s cn56xx; 178 struct cvmx_mixx_iring1_cn52xx cn56xxp1;
146 struct cvmx_mixx_iring1_s cn56xxp1; 179 struct cvmx_mixx_iring1_s cn63xx;
180 struct cvmx_mixx_iring1_s cn63xxp1;
147}; 181};
148 182
149union cvmx_mixx_iring2 { 183union cvmx_mixx_iring2 {
@@ -158,12 +192,15 @@ union cvmx_mixx_iring2 {
158 struct cvmx_mixx_iring2_s cn52xxp1; 192 struct cvmx_mixx_iring2_s cn52xxp1;
159 struct cvmx_mixx_iring2_s cn56xx; 193 struct cvmx_mixx_iring2_s cn56xx;
160 struct cvmx_mixx_iring2_s cn56xxp1; 194 struct cvmx_mixx_iring2_s cn56xxp1;
195 struct cvmx_mixx_iring2_s cn63xx;
196 struct cvmx_mixx_iring2_s cn63xxp1;
161}; 197};
162 198
163union cvmx_mixx_isr { 199union cvmx_mixx_isr {
164 uint64_t u64; 200 uint64_t u64;
165 struct cvmx_mixx_isr_s { 201 struct cvmx_mixx_isr_s {
166 uint64_t reserved_7_63:57; 202 uint64_t reserved_8_63:56;
203 uint64_t ts:1;
167 uint64_t orun:1; 204 uint64_t orun:1;
168 uint64_t irun:1; 205 uint64_t irun:1;
169 uint64_t data_drp:1; 206 uint64_t data_drp:1;
@@ -172,10 +209,21 @@ union cvmx_mixx_isr {
172 uint64_t idblovf:1; 209 uint64_t idblovf:1;
173 uint64_t odblovf:1; 210 uint64_t odblovf:1;
174 } s; 211 } s;
175 struct cvmx_mixx_isr_s cn52xx; 212 struct cvmx_mixx_isr_cn52xx {
176 struct cvmx_mixx_isr_s cn52xxp1; 213 uint64_t reserved_7_63:57;
177 struct cvmx_mixx_isr_s cn56xx; 214 uint64_t orun:1;
178 struct cvmx_mixx_isr_s cn56xxp1; 215 uint64_t irun:1;
216 uint64_t data_drp:1;
217 uint64_t irthresh:1;
218 uint64_t orthresh:1;
219 uint64_t idblovf:1;
220 uint64_t odblovf:1;
221 } cn52xx;
222 struct cvmx_mixx_isr_cn52xx cn52xxp1;
223 struct cvmx_mixx_isr_cn52xx cn56xx;
224 struct cvmx_mixx_isr_cn52xx cn56xxp1;
225 struct cvmx_mixx_isr_s cn63xx;
226 struct cvmx_mixx_isr_s cn63xxp1;
179}; 227};
180 228
181union cvmx_mixx_orcnt { 229union cvmx_mixx_orcnt {
@@ -188,6 +236,8 @@ union cvmx_mixx_orcnt {
188 struct cvmx_mixx_orcnt_s cn52xxp1; 236 struct cvmx_mixx_orcnt_s cn52xxp1;
189 struct cvmx_mixx_orcnt_s cn56xx; 237 struct cvmx_mixx_orcnt_s cn56xx;
190 struct cvmx_mixx_orcnt_s cn56xxp1; 238 struct cvmx_mixx_orcnt_s cn56xxp1;
239 struct cvmx_mixx_orcnt_s cn63xx;
240 struct cvmx_mixx_orcnt_s cn63xxp1;
191}; 241};
192 242
193union cvmx_mixx_orhwm { 243union cvmx_mixx_orhwm {
@@ -200,6 +250,8 @@ union cvmx_mixx_orhwm {
200 struct cvmx_mixx_orhwm_s cn52xxp1; 250 struct cvmx_mixx_orhwm_s cn52xxp1;
201 struct cvmx_mixx_orhwm_s cn56xx; 251 struct cvmx_mixx_orhwm_s cn56xx;
202 struct cvmx_mixx_orhwm_s cn56xxp1; 252 struct cvmx_mixx_orhwm_s cn56xxp1;
253 struct cvmx_mixx_orhwm_s cn63xx;
254 struct cvmx_mixx_orhwm_s cn63xxp1;
203}; 255};
204 256
205union cvmx_mixx_oring1 { 257union cvmx_mixx_oring1 {
@@ -207,14 +259,21 @@ union cvmx_mixx_oring1 {
207 struct cvmx_mixx_oring1_s { 259 struct cvmx_mixx_oring1_s {
208 uint64_t reserved_60_63:4; 260 uint64_t reserved_60_63:4;
209 uint64_t osize:20; 261 uint64_t osize:20;
262 uint64_t obase:37;
263 uint64_t reserved_0_2:3;
264 } s;
265 struct cvmx_mixx_oring1_cn52xx {
266 uint64_t reserved_60_63:4;
267 uint64_t osize:20;
210 uint64_t reserved_36_39:4; 268 uint64_t reserved_36_39:4;
211 uint64_t obase:33; 269 uint64_t obase:33;
212 uint64_t reserved_0_2:3; 270 uint64_t reserved_0_2:3;
213 } s; 271 } cn52xx;
214 struct cvmx_mixx_oring1_s cn52xx; 272 struct cvmx_mixx_oring1_cn52xx cn52xxp1;
215 struct cvmx_mixx_oring1_s cn52xxp1; 273 struct cvmx_mixx_oring1_cn52xx cn56xx;
216 struct cvmx_mixx_oring1_s cn56xx; 274 struct cvmx_mixx_oring1_cn52xx cn56xxp1;
217 struct cvmx_mixx_oring1_s cn56xxp1; 275 struct cvmx_mixx_oring1_s cn63xx;
276 struct cvmx_mixx_oring1_s cn63xxp1;
218}; 277};
219 278
220union cvmx_mixx_oring2 { 279union cvmx_mixx_oring2 {
@@ -229,6 +288,8 @@ union cvmx_mixx_oring2 {
229 struct cvmx_mixx_oring2_s cn52xxp1; 288 struct cvmx_mixx_oring2_s cn52xxp1;
230 struct cvmx_mixx_oring2_s cn56xx; 289 struct cvmx_mixx_oring2_s cn56xx;
231 struct cvmx_mixx_oring2_s cn56xxp1; 290 struct cvmx_mixx_oring2_s cn56xxp1;
291 struct cvmx_mixx_oring2_s cn63xx;
292 struct cvmx_mixx_oring2_s cn63xxp1;
232}; 293};
233 294
234union cvmx_mixx_remcnt { 295union cvmx_mixx_remcnt {
@@ -243,6 +304,31 @@ union cvmx_mixx_remcnt {
243 struct cvmx_mixx_remcnt_s cn52xxp1; 304 struct cvmx_mixx_remcnt_s cn52xxp1;
244 struct cvmx_mixx_remcnt_s cn56xx; 305 struct cvmx_mixx_remcnt_s cn56xx;
245 struct cvmx_mixx_remcnt_s cn56xxp1; 306 struct cvmx_mixx_remcnt_s cn56xxp1;
307 struct cvmx_mixx_remcnt_s cn63xx;
308 struct cvmx_mixx_remcnt_s cn63xxp1;
309};
310
311union cvmx_mixx_tsctl {
312 uint64_t u64;
313 struct cvmx_mixx_tsctl_s {
314 uint64_t reserved_21_63:43;
315 uint64_t tsavl:5;
316 uint64_t reserved_13_15:3;
317 uint64_t tstot:5;
318 uint64_t reserved_5_7:3;
319 uint64_t tscnt:5;
320 } s;
321 struct cvmx_mixx_tsctl_s cn63xx;
322 struct cvmx_mixx_tsctl_s cn63xxp1;
323};
324
325union cvmx_mixx_tstamp {
326 uint64_t u64;
327 struct cvmx_mixx_tstamp_s {
328 uint64_t tstamp:64;
329 } s;
330 struct cvmx_mixx_tstamp_s cn63xx;
331 struct cvmx_mixx_tstamp_s cn63xxp1;
246}; 332};
247 333
248#endif 334#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-npei-defs.h b/arch/mips/include/asm/octeon/cvmx-npei-defs.h
index 4b347bb8ce80..9899a9d2ba72 100644
--- a/arch/mips/include/asm/octeon/cvmx-npei-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-npei-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,206 +28,114 @@
28#ifndef __CVMX_NPEI_DEFS_H__ 28#ifndef __CVMX_NPEI_DEFS_H__
29#define __CVMX_NPEI_DEFS_H__ 29#define __CVMX_NPEI_DEFS_H__
30 30
31#define CVMX_NPEI_BAR1_INDEXX(offset) \ 31#define CVMX_NPEI_BAR1_INDEXX(offset) (0x0000000000000000ull + ((offset) & 31) * 16)
32 (0x0000000000000000ull + (((offset) & 31) * 16)) 32#define CVMX_NPEI_BIST_STATUS (0x0000000000000580ull)
33#define CVMX_NPEI_BIST_STATUS \ 33#define CVMX_NPEI_BIST_STATUS2 (0x0000000000000680ull)
34 (0x0000000000000580ull) 34#define CVMX_NPEI_CTL_PORT0 (0x0000000000000250ull)
35#define CVMX_NPEI_BIST_STATUS2 \ 35#define CVMX_NPEI_CTL_PORT1 (0x0000000000000260ull)
36 (0x0000000000000680ull) 36#define CVMX_NPEI_CTL_STATUS (0x0000000000000570ull)
37#define CVMX_NPEI_CTL_PORT0 \ 37#define CVMX_NPEI_CTL_STATUS2 (0x0000000000003C00ull)
38 (0x0000000000000250ull) 38#define CVMX_NPEI_DATA_OUT_CNT (0x00000000000005F0ull)
39#define CVMX_NPEI_CTL_PORT1 \ 39#define CVMX_NPEI_DBG_DATA (0x0000000000000510ull)
40 (0x0000000000000260ull) 40#define CVMX_NPEI_DBG_SELECT (0x0000000000000500ull)
41#define CVMX_NPEI_CTL_STATUS \ 41#define CVMX_NPEI_DMA0_INT_LEVEL (0x00000000000005C0ull)
42 (0x0000000000000570ull) 42#define CVMX_NPEI_DMA1_INT_LEVEL (0x00000000000005D0ull)
43#define CVMX_NPEI_CTL_STATUS2 \ 43#define CVMX_NPEI_DMAX_COUNTS(offset) (0x0000000000000450ull + ((offset) & 7) * 16)
44 (0x0000000000003C00ull) 44#define CVMX_NPEI_DMAX_DBELL(offset) (0x00000000000003B0ull + ((offset) & 7) * 16)
45#define CVMX_NPEI_DATA_OUT_CNT \ 45#define CVMX_NPEI_DMAX_IBUFF_SADDR(offset) (0x0000000000000400ull + ((offset) & 7) * 16)
46 (0x00000000000005F0ull) 46#define CVMX_NPEI_DMAX_NADDR(offset) (0x00000000000004A0ull + ((offset) & 7) * 16)
47#define CVMX_NPEI_DBG_DATA \ 47#define CVMX_NPEI_DMA_CNTS (0x00000000000005E0ull)
48 (0x0000000000000510ull) 48#define CVMX_NPEI_DMA_CONTROL (0x00000000000003A0ull)
49#define CVMX_NPEI_DBG_SELECT \ 49#define CVMX_NPEI_DMA_PCIE_REQ_NUM (0x00000000000005B0ull)
50 (0x0000000000000500ull) 50#define CVMX_NPEI_DMA_STATE1 (0x00000000000006C0ull)
51#define CVMX_NPEI_DMA0_INT_LEVEL \ 51#define CVMX_NPEI_DMA_STATE1_P1 (0x0000000000000680ull)
52 (0x00000000000005C0ull) 52#define CVMX_NPEI_DMA_STATE2 (0x00000000000006D0ull)
53#define CVMX_NPEI_DMA1_INT_LEVEL \ 53#define CVMX_NPEI_DMA_STATE2_P1 (0x0000000000000690ull)
54 (0x00000000000005D0ull) 54#define CVMX_NPEI_DMA_STATE3_P1 (0x00000000000006A0ull)
55#define CVMX_NPEI_DMAX_COUNTS(offset) \ 55#define CVMX_NPEI_DMA_STATE4_P1 (0x00000000000006B0ull)
56 (0x0000000000000450ull + (((offset) & 7) * 16)) 56#define CVMX_NPEI_DMA_STATE5_P1 (0x00000000000006C0ull)
57#define CVMX_NPEI_DMAX_DBELL(offset) \ 57#define CVMX_NPEI_INT_A_ENB (0x0000000000000560ull)
58 (0x00000000000003B0ull + (((offset) & 7) * 16)) 58#define CVMX_NPEI_INT_A_ENB2 (0x0000000000003CE0ull)
59#define CVMX_NPEI_DMAX_IBUFF_SADDR(offset) \ 59#define CVMX_NPEI_INT_A_SUM (0x0000000000000550ull)
60 (0x0000000000000400ull + (((offset) & 7) * 16)) 60#define CVMX_NPEI_INT_ENB (0x0000000000000540ull)
61#define CVMX_NPEI_DMAX_NADDR(offset) \ 61#define CVMX_NPEI_INT_ENB2 (0x0000000000003CD0ull)
62 (0x00000000000004A0ull + (((offset) & 7) * 16)) 62#define CVMX_NPEI_INT_INFO (0x0000000000000590ull)
63#define CVMX_NPEI_DMA_CNTS \ 63#define CVMX_NPEI_INT_SUM (0x0000000000000530ull)
64 (0x00000000000005E0ull) 64#define CVMX_NPEI_INT_SUM2 (0x0000000000003CC0ull)
65#define CVMX_NPEI_DMA_CONTROL \ 65#define CVMX_NPEI_LAST_WIN_RDATA0 (0x0000000000000600ull)
66 (0x00000000000003A0ull) 66#define CVMX_NPEI_LAST_WIN_RDATA1 (0x0000000000000610ull)
67#define CVMX_NPEI_INT_A_ENB \ 67#define CVMX_NPEI_MEM_ACCESS_CTL (0x00000000000004F0ull)
68 (0x0000000000000560ull) 68#define CVMX_NPEI_MEM_ACCESS_SUBIDX(offset) (0x0000000000000340ull + ((offset) & 31) * 16 - 16*12)
69#define CVMX_NPEI_INT_A_ENB2 \ 69#define CVMX_NPEI_MSI_ENB0 (0x0000000000003C50ull)
70 (0x0000000000003CE0ull) 70#define CVMX_NPEI_MSI_ENB1 (0x0000000000003C60ull)
71#define CVMX_NPEI_INT_A_SUM \ 71#define CVMX_NPEI_MSI_ENB2 (0x0000000000003C70ull)
72 (0x0000000000000550ull) 72#define CVMX_NPEI_MSI_ENB3 (0x0000000000003C80ull)
73#define CVMX_NPEI_INT_ENB \ 73#define CVMX_NPEI_MSI_RCV0 (0x0000000000003C10ull)
74 (0x0000000000000540ull) 74#define CVMX_NPEI_MSI_RCV1 (0x0000000000003C20ull)
75#define CVMX_NPEI_INT_ENB2 \ 75#define CVMX_NPEI_MSI_RCV2 (0x0000000000003C30ull)
76 (0x0000000000003CD0ull) 76#define CVMX_NPEI_MSI_RCV3 (0x0000000000003C40ull)
77#define CVMX_NPEI_INT_INFO \ 77#define CVMX_NPEI_MSI_RD_MAP (0x0000000000003CA0ull)
78 (0x0000000000000590ull) 78#define CVMX_NPEI_MSI_W1C_ENB0 (0x0000000000003CF0ull)
79#define CVMX_NPEI_INT_SUM \ 79#define CVMX_NPEI_MSI_W1C_ENB1 (0x0000000000003D00ull)
80 (0x0000000000000530ull) 80#define CVMX_NPEI_MSI_W1C_ENB2 (0x0000000000003D10ull)
81#define CVMX_NPEI_INT_SUM2 \ 81#define CVMX_NPEI_MSI_W1C_ENB3 (0x0000000000003D20ull)
82 (0x0000000000003CC0ull) 82#define CVMX_NPEI_MSI_W1S_ENB0 (0x0000000000003D30ull)
83#define CVMX_NPEI_LAST_WIN_RDATA0 \ 83#define CVMX_NPEI_MSI_W1S_ENB1 (0x0000000000003D40ull)
84 (0x0000000000000600ull) 84#define CVMX_NPEI_MSI_W1S_ENB2 (0x0000000000003D50ull)
85#define CVMX_NPEI_LAST_WIN_RDATA1 \ 85#define CVMX_NPEI_MSI_W1S_ENB3 (0x0000000000003D60ull)
86 (0x0000000000000610ull) 86#define CVMX_NPEI_MSI_WR_MAP (0x0000000000003C90ull)
87#define CVMX_NPEI_MEM_ACCESS_CTL \ 87#define CVMX_NPEI_PCIE_CREDIT_CNT (0x0000000000003D70ull)
88 (0x00000000000004F0ull) 88#define CVMX_NPEI_PCIE_MSI_RCV (0x0000000000003CB0ull)
89#define CVMX_NPEI_MEM_ACCESS_SUBIDX(offset) \ 89#define CVMX_NPEI_PCIE_MSI_RCV_B1 (0x0000000000000650ull)
90 (0x0000000000000340ull + (((offset) & 31) * 16) - 16 * 12) 90#define CVMX_NPEI_PCIE_MSI_RCV_B2 (0x0000000000000660ull)
91#define CVMX_NPEI_MSI_ENB0 \ 91#define CVMX_NPEI_PCIE_MSI_RCV_B3 (0x0000000000000670ull)
92 (0x0000000000003C50ull) 92#define CVMX_NPEI_PKTX_CNTS(offset) (0x0000000000002400ull + ((offset) & 31) * 16)
93#define CVMX_NPEI_MSI_ENB1 \ 93#define CVMX_NPEI_PKTX_INSTR_BADDR(offset) (0x0000000000002800ull + ((offset) & 31) * 16)
94 (0x0000000000003C60ull) 94#define CVMX_NPEI_PKTX_INSTR_BAOFF_DBELL(offset) (0x0000000000002C00ull + ((offset) & 31) * 16)
95#define CVMX_NPEI_MSI_ENB2 \ 95#define CVMX_NPEI_PKTX_INSTR_FIFO_RSIZE(offset) (0x0000000000003000ull + ((offset) & 31) * 16)
96 (0x0000000000003C70ull) 96#define CVMX_NPEI_PKTX_INSTR_HEADER(offset) (0x0000000000003400ull + ((offset) & 31) * 16)
97#define CVMX_NPEI_MSI_ENB3 \ 97#define CVMX_NPEI_PKTX_IN_BP(offset) (0x0000000000003800ull + ((offset) & 31) * 16)
98 (0x0000000000003C80ull) 98#define CVMX_NPEI_PKTX_SLIST_BADDR(offset) (0x0000000000001400ull + ((offset) & 31) * 16)
99#define CVMX_NPEI_MSI_RCV0 \ 99#define CVMX_NPEI_PKTX_SLIST_BAOFF_DBELL(offset) (0x0000000000001800ull + ((offset) & 31) * 16)
100 (0x0000000000003C10ull) 100#define CVMX_NPEI_PKTX_SLIST_FIFO_RSIZE(offset) (0x0000000000001C00ull + ((offset) & 31) * 16)
101#define CVMX_NPEI_MSI_RCV1 \ 101#define CVMX_NPEI_PKT_CNT_INT (0x0000000000001110ull)
102 (0x0000000000003C20ull) 102#define CVMX_NPEI_PKT_CNT_INT_ENB (0x0000000000001130ull)
103#define CVMX_NPEI_MSI_RCV2 \ 103#define CVMX_NPEI_PKT_DATA_OUT_ES (0x00000000000010B0ull)
104 (0x0000000000003C30ull) 104#define CVMX_NPEI_PKT_DATA_OUT_NS (0x00000000000010A0ull)
105#define CVMX_NPEI_MSI_RCV3 \ 105#define CVMX_NPEI_PKT_DATA_OUT_ROR (0x0000000000001090ull)
106 (0x0000000000003C40ull) 106#define CVMX_NPEI_PKT_DPADDR (0x0000000000001080ull)
107#define CVMX_NPEI_MSI_RD_MAP \ 107#define CVMX_NPEI_PKT_INPUT_CONTROL (0x0000000000001150ull)
108 (0x0000000000003CA0ull) 108#define CVMX_NPEI_PKT_INSTR_ENB (0x0000000000001000ull)
109#define CVMX_NPEI_MSI_W1C_ENB0 \ 109#define CVMX_NPEI_PKT_INSTR_RD_SIZE (0x0000000000001190ull)
110 (0x0000000000003CF0ull) 110#define CVMX_NPEI_PKT_INSTR_SIZE (0x0000000000001020ull)
111#define CVMX_NPEI_MSI_W1C_ENB1 \ 111#define CVMX_NPEI_PKT_INT_LEVELS (0x0000000000001100ull)
112 (0x0000000000003D00ull) 112#define CVMX_NPEI_PKT_IN_BP (0x00000000000006B0ull)
113#define CVMX_NPEI_MSI_W1C_ENB2 \ 113#define CVMX_NPEI_PKT_IN_DONEX_CNTS(offset) (0x0000000000002000ull + ((offset) & 31) * 16)
114 (0x0000000000003D10ull) 114#define CVMX_NPEI_PKT_IN_INSTR_COUNTS (0x00000000000006A0ull)
115#define CVMX_NPEI_MSI_W1C_ENB3 \ 115#define CVMX_NPEI_PKT_IN_PCIE_PORT (0x00000000000011A0ull)
116 (0x0000000000003D20ull) 116#define CVMX_NPEI_PKT_IPTR (0x0000000000001070ull)
117#define CVMX_NPEI_MSI_W1S_ENB0 \ 117#define CVMX_NPEI_PKT_OUTPUT_WMARK (0x0000000000001160ull)
118 (0x0000000000003D30ull) 118#define CVMX_NPEI_PKT_OUT_BMODE (0x00000000000010D0ull)
119#define CVMX_NPEI_MSI_W1S_ENB1 \ 119#define CVMX_NPEI_PKT_OUT_ENB (0x0000000000001010ull)
120 (0x0000000000003D40ull) 120#define CVMX_NPEI_PKT_PCIE_PORT (0x00000000000010E0ull)
121#define CVMX_NPEI_MSI_W1S_ENB2 \ 121#define CVMX_NPEI_PKT_PORT_IN_RST (0x0000000000000690ull)
122 (0x0000000000003D50ull) 122#define CVMX_NPEI_PKT_SLIST_ES (0x0000000000001050ull)
123#define CVMX_NPEI_MSI_W1S_ENB3 \ 123#define CVMX_NPEI_PKT_SLIST_ID_SIZE (0x0000000000001180ull)
124 (0x0000000000003D60ull) 124#define CVMX_NPEI_PKT_SLIST_NS (0x0000000000001040ull)
125#define CVMX_NPEI_MSI_WR_MAP \ 125#define CVMX_NPEI_PKT_SLIST_ROR (0x0000000000001030ull)
126 (0x0000000000003C90ull) 126#define CVMX_NPEI_PKT_TIME_INT (0x0000000000001120ull)
127#define CVMX_NPEI_PCIE_CREDIT_CNT \ 127#define CVMX_NPEI_PKT_TIME_INT_ENB (0x0000000000001140ull)
128 (0x0000000000003D70ull) 128#define CVMX_NPEI_RSL_INT_BLOCKS (0x0000000000000520ull)
129#define CVMX_NPEI_PCIE_MSI_RCV \ 129#define CVMX_NPEI_SCRATCH_1 (0x0000000000000270ull)
130 (0x0000000000003CB0ull) 130#define CVMX_NPEI_STATE1 (0x0000000000000620ull)
131#define CVMX_NPEI_PCIE_MSI_RCV_B1 \ 131#define CVMX_NPEI_STATE2 (0x0000000000000630ull)
132 (0x0000000000000650ull) 132#define CVMX_NPEI_STATE3 (0x0000000000000640ull)
133#define CVMX_NPEI_PCIE_MSI_RCV_B2 \ 133#define CVMX_NPEI_WINDOW_CTL (0x0000000000000380ull)
134 (0x0000000000000660ull) 134#define CVMX_NPEI_WIN_RD_ADDR (0x0000000000000210ull)
135#define CVMX_NPEI_PCIE_MSI_RCV_B3 \ 135#define CVMX_NPEI_WIN_RD_DATA (0x0000000000000240ull)
136 (0x0000000000000670ull) 136#define CVMX_NPEI_WIN_WR_ADDR (0x0000000000000200ull)
137#define CVMX_NPEI_PKTX_CNTS(offset) \ 137#define CVMX_NPEI_WIN_WR_DATA (0x0000000000000220ull)
138 (0x0000000000002400ull + (((offset) & 31) * 16)) 138#define CVMX_NPEI_WIN_WR_MASK (0x0000000000000230ull)
139#define CVMX_NPEI_PKTX_INSTR_BADDR(offset) \
140 (0x0000000000002800ull + (((offset) & 31) * 16))
141#define CVMX_NPEI_PKTX_INSTR_BAOFF_DBELL(offset) \
142 (0x0000000000002C00ull + (((offset) & 31) * 16))
143#define CVMX_NPEI_PKTX_INSTR_FIFO_RSIZE(offset) \
144 (0x0000000000003000ull + (((offset) & 31) * 16))
145#define CVMX_NPEI_PKTX_INSTR_HEADER(offset) \
146 (0x0000000000003400ull + (((offset) & 31) * 16))
147#define CVMX_NPEI_PKTX_IN_BP(offset) \
148 (0x0000000000003800ull + (((offset) & 31) * 16))
149#define CVMX_NPEI_PKTX_SLIST_BADDR(offset) \
150 (0x0000000000001400ull + (((offset) & 31) * 16))
151#define CVMX_NPEI_PKTX_SLIST_BAOFF_DBELL(offset) \
152 (0x0000000000001800ull + (((offset) & 31) * 16))
153#define CVMX_NPEI_PKTX_SLIST_FIFO_RSIZE(offset) \
154 (0x0000000000001C00ull + (((offset) & 31) * 16))
155#define CVMX_NPEI_PKT_CNT_INT \
156 (0x0000000000001110ull)
157#define CVMX_NPEI_PKT_CNT_INT_ENB \
158 (0x0000000000001130ull)
159#define CVMX_NPEI_PKT_DATA_OUT_ES \
160 (0x00000000000010B0ull)
161#define CVMX_NPEI_PKT_DATA_OUT_NS \
162 (0x00000000000010A0ull)
163#define CVMX_NPEI_PKT_DATA_OUT_ROR \
164 (0x0000000000001090ull)
165#define CVMX_NPEI_PKT_DPADDR \
166 (0x0000000000001080ull)
167#define CVMX_NPEI_PKT_INPUT_CONTROL \
168 (0x0000000000001150ull)
169#define CVMX_NPEI_PKT_INSTR_ENB \
170 (0x0000000000001000ull)
171#define CVMX_NPEI_PKT_INSTR_RD_SIZE \
172 (0x0000000000001190ull)
173#define CVMX_NPEI_PKT_INSTR_SIZE \
174 (0x0000000000001020ull)
175#define CVMX_NPEI_PKT_INT_LEVELS \
176 (0x0000000000001100ull)
177#define CVMX_NPEI_PKT_IN_BP \
178 (0x00000000000006B0ull)
179#define CVMX_NPEI_PKT_IN_DONEX_CNTS(offset) \
180 (0x0000000000002000ull + (((offset) & 31) * 16))
181#define CVMX_NPEI_PKT_IN_INSTR_COUNTS \
182 (0x00000000000006A0ull)
183#define CVMX_NPEI_PKT_IN_PCIE_PORT \
184 (0x00000000000011A0ull)
185#define CVMX_NPEI_PKT_IPTR \
186 (0x0000000000001070ull)
187#define CVMX_NPEI_PKT_OUTPUT_WMARK \
188 (0x0000000000001160ull)
189#define CVMX_NPEI_PKT_OUT_BMODE \
190 (0x00000000000010D0ull)
191#define CVMX_NPEI_PKT_OUT_ENB \
192 (0x0000000000001010ull)
193#define CVMX_NPEI_PKT_PCIE_PORT \
194 (0x00000000000010E0ull)
195#define CVMX_NPEI_PKT_PORT_IN_RST \
196 (0x0000000000000690ull)
197#define CVMX_NPEI_PKT_SLIST_ES \
198 (0x0000000000001050ull)
199#define CVMX_NPEI_PKT_SLIST_ID_SIZE \
200 (0x0000000000001180ull)
201#define CVMX_NPEI_PKT_SLIST_NS \
202 (0x0000000000001040ull)
203#define CVMX_NPEI_PKT_SLIST_ROR \
204 (0x0000000000001030ull)
205#define CVMX_NPEI_PKT_TIME_INT \
206 (0x0000000000001120ull)
207#define CVMX_NPEI_PKT_TIME_INT_ENB \
208 (0x0000000000001140ull)
209#define CVMX_NPEI_RSL_INT_BLOCKS \
210 (0x0000000000000520ull)
211#define CVMX_NPEI_SCRATCH_1 \
212 (0x0000000000000270ull)
213#define CVMX_NPEI_STATE1 \
214 (0x0000000000000620ull)
215#define CVMX_NPEI_STATE2 \
216 (0x0000000000000630ull)
217#define CVMX_NPEI_STATE3 \
218 (0x0000000000000640ull)
219#define CVMX_NPEI_WINDOW_CTL \
220 (0x0000000000000380ull)
221#define CVMX_NPEI_WIN_RD_ADDR \
222 (0x0000000000000210ull)
223#define CVMX_NPEI_WIN_RD_DATA \
224 (0x0000000000000240ull)
225#define CVMX_NPEI_WIN_WR_ADDR \
226 (0x0000000000000200ull)
227#define CVMX_NPEI_WIN_WR_DATA \
228 (0x0000000000000220ull)
229#define CVMX_NPEI_WIN_WR_MASK \
230 (0x0000000000000230ull)
231 139
232union cvmx_npei_bar1_indexx { 140union cvmx_npei_bar1_indexx {
233 uint32_t u32; 141 uint32_t u32;
@@ -248,9 +156,7 @@ union cvmx_npei_bist_status {
248 uint64_t u64; 156 uint64_t u64;
249 struct cvmx_npei_bist_status_s { 157 struct cvmx_npei_bist_status_s {
250 uint64_t pkt_rdf:1; 158 uint64_t pkt_rdf:1;
251 uint64_t pkt_pmem:1; 159 uint64_t reserved_60_62:3;
252 uint64_t pkt_p1:1;
253 uint64_t reserved_60_60:1;
254 uint64_t pcr_gim:1; 160 uint64_t pcr_gim:1;
255 uint64_t pkt_pif:1; 161 uint64_t pkt_pif:1;
256 uint64_t pcsr_int:1; 162 uint64_t pcsr_int:1;
@@ -301,9 +207,7 @@ union cvmx_npei_bist_status {
301 } s; 207 } s;
302 struct cvmx_npei_bist_status_cn52xx { 208 struct cvmx_npei_bist_status_cn52xx {
303 uint64_t pkt_rdf:1; 209 uint64_t pkt_rdf:1;
304 uint64_t pkt_pmem:1; 210 uint64_t reserved_60_62:3;
305 uint64_t pkt_p1:1;
306 uint64_t reserved_60_60:1;
307 uint64_t pcr_gim:1; 211 uint64_t pcr_gim:1;
308 uint64_t pkt_pif:1; 212 uint64_t pkt_pif:1;
309 uint64_t pcsr_int:1; 213 uint64_t pcsr_int:1;
@@ -410,66 +314,7 @@ union cvmx_npei_bist_status {
410 uint64_t msi:1; 314 uint64_t msi:1;
411 uint64_t ncb_cmd:1; 315 uint64_t ncb_cmd:1;
412 } cn52xxp1; 316 } cn52xxp1;
413 struct cvmx_npei_bist_status_cn56xx { 317 struct cvmx_npei_bist_status_cn52xx cn56xx;
414 uint64_t pkt_rdf:1;
415 uint64_t reserved_60_62:3;
416 uint64_t pcr_gim:1;
417 uint64_t pkt_pif:1;
418 uint64_t pcsr_int:1;
419 uint64_t pcsr_im:1;
420 uint64_t pcsr_cnt:1;
421 uint64_t pcsr_id:1;
422 uint64_t pcsr_sl:1;
423 uint64_t pkt_imem:1;
424 uint64_t pkt_pfm:1;
425 uint64_t pkt_pof:1;
426 uint64_t reserved_48_49:2;
427 uint64_t pkt_pop0:1;
428 uint64_t pkt_pop1:1;
429 uint64_t d0_mem:1;
430 uint64_t d1_mem:1;
431 uint64_t d2_mem:1;
432 uint64_t d3_mem:1;
433 uint64_t d4_mem:1;
434 uint64_t ds_mem:1;
435 uint64_t reserved_36_39:4;
436 uint64_t d0_pst:1;
437 uint64_t d1_pst:1;
438 uint64_t d2_pst:1;
439 uint64_t d3_pst:1;
440 uint64_t d4_pst:1;
441 uint64_t n2p0_c:1;
442 uint64_t n2p0_o:1;
443 uint64_t n2p1_c:1;
444 uint64_t n2p1_o:1;
445 uint64_t cpl_p0:1;
446 uint64_t cpl_p1:1;
447 uint64_t p2n1_po:1;
448 uint64_t p2n1_no:1;
449 uint64_t p2n1_co:1;
450 uint64_t p2n0_po:1;
451 uint64_t p2n0_no:1;
452 uint64_t p2n0_co:1;
453 uint64_t p2n0_c0:1;
454 uint64_t p2n0_c1:1;
455 uint64_t p2n0_n:1;
456 uint64_t p2n0_p0:1;
457 uint64_t p2n0_p1:1;
458 uint64_t p2n1_c0:1;
459 uint64_t p2n1_c1:1;
460 uint64_t p2n1_n:1;
461 uint64_t p2n1_p0:1;
462 uint64_t p2n1_p1:1;
463 uint64_t csm0:1;
464 uint64_t csm1:1;
465 uint64_t dif0:1;
466 uint64_t dif1:1;
467 uint64_t dif2:1;
468 uint64_t dif3:1;
469 uint64_t dif4:1;
470 uint64_t msi:1;
471 uint64_t ncb_cmd:1;
472 } cn56xx;
473 struct cvmx_npei_bist_status_cn56xxp1 { 318 struct cvmx_npei_bist_status_cn56xxp1 {
474 uint64_t reserved_58_63:6; 319 uint64_t reserved_58_63:6;
475 uint64_t pcsr_int:1; 320 uint64_t pcsr_int:1;
@@ -536,7 +381,16 @@ union cvmx_npei_bist_status {
536union cvmx_npei_bist_status2 { 381union cvmx_npei_bist_status2 {
537 uint64_t u64; 382 uint64_t u64;
538 struct cvmx_npei_bist_status2_s { 383 struct cvmx_npei_bist_status2_s {
539 uint64_t reserved_5_63:59; 384 uint64_t reserved_14_63:50;
385 uint64_t prd_tag:1;
386 uint64_t prd_st0:1;
387 uint64_t prd_st1:1;
388 uint64_t prd_err:1;
389 uint64_t nrd_st:1;
390 uint64_t nwe_st:1;
391 uint64_t nwe_wr0:1;
392 uint64_t nwe_wr1:1;
393 uint64_t pkt_rd:1;
540 uint64_t psc_p0:1; 394 uint64_t psc_p0:1;
541 uint64_t psc_p1:1; 395 uint64_t psc_p1:1;
542 uint64_t pkt_gd:1; 396 uint64_t pkt_gd:1;
@@ -630,8 +484,7 @@ union cvmx_npei_ctl_status {
630 } cn52xxp1; 484 } cn52xxp1;
631 struct cvmx_npei_ctl_status_s cn56xx; 485 struct cvmx_npei_ctl_status_s cn56xx;
632 struct cvmx_npei_ctl_status_cn56xxp1 { 486 struct cvmx_npei_ctl_status_cn56xxp1 {
633 uint64_t reserved_16_63:48; 487 uint64_t reserved_15_63:49;
634 uint64_t ring_en:1;
635 uint64_t lnk_rst:1; 488 uint64_t lnk_rst:1;
636 uint64_t arb:1; 489 uint64_t arb:1;
637 uint64_t pkt_bp:4; 490 uint64_t pkt_bp:4;
@@ -756,14 +609,14 @@ union cvmx_npei_dmax_ibuff_saddr {
756 uint64_t saddr:29; 609 uint64_t saddr:29;
757 uint64_t reserved_0_6:7; 610 uint64_t reserved_0_6:7;
758 } s; 611 } s;
759 struct cvmx_npei_dmax_ibuff_saddr_cn52xx { 612 struct cvmx_npei_dmax_ibuff_saddr_s cn52xx;
613 struct cvmx_npei_dmax_ibuff_saddr_cn52xxp1 {
760 uint64_t reserved_36_63:28; 614 uint64_t reserved_36_63:28;
761 uint64_t saddr:29; 615 uint64_t saddr:29;
762 uint64_t reserved_0_6:7; 616 uint64_t reserved_0_6:7;
763 } cn52xx; 617 } cn52xxp1;
764 struct cvmx_npei_dmax_ibuff_saddr_cn52xx cn52xxp1;
765 struct cvmx_npei_dmax_ibuff_saddr_s cn56xx; 618 struct cvmx_npei_dmax_ibuff_saddr_s cn56xx;
766 struct cvmx_npei_dmax_ibuff_saddr_cn52xx cn56xxp1; 619 struct cvmx_npei_dmax_ibuff_saddr_cn52xxp1 cn56xxp1;
767}; 620};
768 621
769union cvmx_npei_dmax_naddr { 622union cvmx_npei_dmax_naddr {
@@ -817,7 +670,8 @@ union cvmx_npei_dma_cnts {
817union cvmx_npei_dma_control { 670union cvmx_npei_dma_control {
818 uint64_t u64; 671 uint64_t u64;
819 struct cvmx_npei_dma_control_s { 672 struct cvmx_npei_dma_control_s {
820 uint64_t reserved_39_63:25; 673 uint64_t reserved_40_63:24;
674 uint64_t p_32b_m:1;
821 uint64_t dma4_enb:1; 675 uint64_t dma4_enb:1;
822 uint64_t dma3_enb:1; 676 uint64_t dma3_enb:1;
823 uint64_t dma2_enb:1; 677 uint64_t dma2_enb:1;
@@ -853,7 +707,161 @@ union cvmx_npei_dma_control {
853 uint64_t csize:14; 707 uint64_t csize:14;
854 } cn52xxp1; 708 } cn52xxp1;
855 struct cvmx_npei_dma_control_s cn56xx; 709 struct cvmx_npei_dma_control_s cn56xx;
856 struct cvmx_npei_dma_control_s cn56xxp1; 710 struct cvmx_npei_dma_control_cn56xxp1 {
711 uint64_t reserved_39_63:25;
712 uint64_t dma4_enb:1;
713 uint64_t dma3_enb:1;
714 uint64_t dma2_enb:1;
715 uint64_t dma1_enb:1;
716 uint64_t dma0_enb:1;
717 uint64_t b0_lend:1;
718 uint64_t dwb_denb:1;
719 uint64_t dwb_ichk:9;
720 uint64_t fpa_que:3;
721 uint64_t o_add1:1;
722 uint64_t o_ro:1;
723 uint64_t o_ns:1;
724 uint64_t o_es:2;
725 uint64_t o_mode:1;
726 uint64_t csize:14;
727 } cn56xxp1;
728};
729
730union cvmx_npei_dma_pcie_req_num {
731 uint64_t u64;
732 struct cvmx_npei_dma_pcie_req_num_s {
733 uint64_t dma_arb:1;
734 uint64_t reserved_53_62:10;
735 uint64_t pkt_cnt:5;
736 uint64_t reserved_45_47:3;
737 uint64_t dma4_cnt:5;
738 uint64_t reserved_37_39:3;
739 uint64_t dma3_cnt:5;
740 uint64_t reserved_29_31:3;
741 uint64_t dma2_cnt:5;
742 uint64_t reserved_21_23:3;
743 uint64_t dma1_cnt:5;
744 uint64_t reserved_13_15:3;
745 uint64_t dma0_cnt:5;
746 uint64_t reserved_5_7:3;
747 uint64_t dma_cnt:5;
748 } s;
749 struct cvmx_npei_dma_pcie_req_num_s cn52xx;
750 struct cvmx_npei_dma_pcie_req_num_s cn56xx;
751};
752
753union cvmx_npei_dma_state1 {
754 uint64_t u64;
755 struct cvmx_npei_dma_state1_s {
756 uint64_t reserved_40_63:24;
757 uint64_t d4_dwe:8;
758 uint64_t d3_dwe:8;
759 uint64_t d2_dwe:8;
760 uint64_t d1_dwe:8;
761 uint64_t d0_dwe:8;
762 } s;
763 struct cvmx_npei_dma_state1_s cn52xx;
764};
765
766union cvmx_npei_dma_state1_p1 {
767 uint64_t u64;
768 struct cvmx_npei_dma_state1_p1_s {
769 uint64_t reserved_60_63:4;
770 uint64_t d0_difst:7;
771 uint64_t d1_difst:7;
772 uint64_t d2_difst:7;
773 uint64_t d3_difst:7;
774 uint64_t d4_difst:7;
775 uint64_t d0_reqst:5;
776 uint64_t d1_reqst:5;
777 uint64_t d2_reqst:5;
778 uint64_t d3_reqst:5;
779 uint64_t d4_reqst:5;
780 } s;
781 struct cvmx_npei_dma_state1_p1_cn52xxp1 {
782 uint64_t reserved_60_63:4;
783 uint64_t d0_difst:7;
784 uint64_t d1_difst:7;
785 uint64_t d2_difst:7;
786 uint64_t d3_difst:7;
787 uint64_t reserved_25_31:7;
788 uint64_t d0_reqst:5;
789 uint64_t d1_reqst:5;
790 uint64_t d2_reqst:5;
791 uint64_t d3_reqst:5;
792 uint64_t reserved_0_4:5;
793 } cn52xxp1;
794 struct cvmx_npei_dma_state1_p1_s cn56xxp1;
795};
796
797union cvmx_npei_dma_state2 {
798 uint64_t u64;
799 struct cvmx_npei_dma_state2_s {
800 uint64_t reserved_28_63:36;
801 uint64_t ndwe:4;
802 uint64_t reserved_21_23:3;
803 uint64_t ndre:5;
804 uint64_t reserved_10_15:6;
805 uint64_t prd:10;
806 } s;
807 struct cvmx_npei_dma_state2_s cn52xx;
808};
809
810union cvmx_npei_dma_state2_p1 {
811 uint64_t u64;
812 struct cvmx_npei_dma_state2_p1_s {
813 uint64_t reserved_45_63:19;
814 uint64_t d0_dffst:9;
815 uint64_t d1_dffst:9;
816 uint64_t d2_dffst:9;
817 uint64_t d3_dffst:9;
818 uint64_t d4_dffst:9;
819 } s;
820 struct cvmx_npei_dma_state2_p1_cn52xxp1 {
821 uint64_t reserved_45_63:19;
822 uint64_t d0_dffst:9;
823 uint64_t d1_dffst:9;
824 uint64_t d2_dffst:9;
825 uint64_t d3_dffst:9;
826 uint64_t reserved_0_8:9;
827 } cn52xxp1;
828 struct cvmx_npei_dma_state2_p1_s cn56xxp1;
829};
830
831union cvmx_npei_dma_state3_p1 {
832 uint64_t u64;
833 struct cvmx_npei_dma_state3_p1_s {
834 uint64_t reserved_60_63:4;
835 uint64_t d0_drest:15;
836 uint64_t d1_drest:15;
837 uint64_t d2_drest:15;
838 uint64_t d3_drest:15;
839 } s;
840 struct cvmx_npei_dma_state3_p1_s cn52xxp1;
841 struct cvmx_npei_dma_state3_p1_s cn56xxp1;
842};
843
844union cvmx_npei_dma_state4_p1 {
845 uint64_t u64;
846 struct cvmx_npei_dma_state4_p1_s {
847 uint64_t reserved_52_63:12;
848 uint64_t d0_dwest:13;
849 uint64_t d1_dwest:13;
850 uint64_t d2_dwest:13;
851 uint64_t d3_dwest:13;
852 } s;
853 struct cvmx_npei_dma_state4_p1_s cn52xxp1;
854 struct cvmx_npei_dma_state4_p1_s cn56xxp1;
855};
856
857union cvmx_npei_dma_state5_p1 {
858 uint64_t u64;
859 struct cvmx_npei_dma_state5_p1_s {
860 uint64_t reserved_28_63:36;
861 uint64_t d4_drest:15;
862 uint64_t d4_dwest:13;
863 } s;
864 struct cvmx_npei_dma_state5_p1_s cn56xxp1;
857}; 865};
858 866
859union cvmx_npei_int_a_enb { 867union cvmx_npei_int_a_enb {
@@ -871,17 +879,7 @@ union cvmx_npei_int_a_enb {
871 uint64_t dma1_cpl:1; 879 uint64_t dma1_cpl:1;
872 uint64_t dma0_cpl:1; 880 uint64_t dma0_cpl:1;
873 } s; 881 } s;
874 struct cvmx_npei_int_a_enb_cn52xx { 882 struct cvmx_npei_int_a_enb_s cn52xx;
875 uint64_t reserved_8_63:56;
876 uint64_t p1_rdlk:1;
877 uint64_t p0_rdlk:1;
878 uint64_t pgl_err:1;
879 uint64_t pdi_err:1;
880 uint64_t pop_err:1;
881 uint64_t pins_err:1;
882 uint64_t dma1_cpl:1;
883 uint64_t dma0_cpl:1;
884 } cn52xx;
885 struct cvmx_npei_int_a_enb_cn52xxp1 { 883 struct cvmx_npei_int_a_enb_cn52xxp1 {
886 uint64_t reserved_2_63:62; 884 uint64_t reserved_2_63:62;
887 uint64_t dma1_cpl:1; 885 uint64_t dma1_cpl:1;
@@ -905,16 +903,7 @@ union cvmx_npei_int_a_enb2 {
905 uint64_t dma1_cpl:1; 903 uint64_t dma1_cpl:1;
906 uint64_t dma0_cpl:1; 904 uint64_t dma0_cpl:1;
907 } s; 905 } s;
908 struct cvmx_npei_int_a_enb2_cn52xx { 906 struct cvmx_npei_int_a_enb2_s cn52xx;
909 uint64_t reserved_8_63:56;
910 uint64_t p1_rdlk:1;
911 uint64_t p0_rdlk:1;
912 uint64_t pgl_err:1;
913 uint64_t pdi_err:1;
914 uint64_t pop_err:1;
915 uint64_t pins_err:1;
916 uint64_t reserved_0_1:2;
917 } cn52xx;
918 struct cvmx_npei_int_a_enb2_cn52xxp1 { 907 struct cvmx_npei_int_a_enb2_cn52xxp1 {
919 uint64_t reserved_2_63:62; 908 uint64_t reserved_2_63:62;
920 uint64_t dma1_cpl:1; 909 uint64_t dma1_cpl:1;
@@ -938,17 +927,7 @@ union cvmx_npei_int_a_sum {
938 uint64_t dma1_cpl:1; 927 uint64_t dma1_cpl:1;
939 uint64_t dma0_cpl:1; 928 uint64_t dma0_cpl:1;
940 } s; 929 } s;
941 struct cvmx_npei_int_a_sum_cn52xx { 930 struct cvmx_npei_int_a_sum_s cn52xx;
942 uint64_t reserved_8_63:56;
943 uint64_t p1_rdlk:1;
944 uint64_t p0_rdlk:1;
945 uint64_t pgl_err:1;
946 uint64_t pdi_err:1;
947 uint64_t pop_err:1;
948 uint64_t pins_err:1;
949 uint64_t dma1_cpl:1;
950 uint64_t dma0_cpl:1;
951 } cn52xx;
952 struct cvmx_npei_int_a_sum_cn52xxp1 { 931 struct cvmx_npei_int_a_sum_cn52xxp1 {
953 uint64_t reserved_2_63:62; 932 uint64_t reserved_2_63:62;
954 uint64_t dma1_cpl:1; 933 uint64_t dma1_cpl:1;
@@ -1550,10 +1529,7 @@ union cvmx_npei_int_sum {
1550 uint64_t c0_se:1; 1529 uint64_t c0_se:1;
1551 uint64_t reserved_20_20:1; 1530 uint64_t reserved_20_20:1;
1552 uint64_t c0_aeri:1; 1531 uint64_t c0_aeri:1;
1553 uint64_t ptime:1; 1532 uint64_t reserved_15_18:4;
1554 uint64_t pcnt:1;
1555 uint64_t pidbof:1;
1556 uint64_t psldbof:1;
1557 uint64_t dtime1:1; 1533 uint64_t dtime1:1;
1558 uint64_t dtime0:1; 1534 uint64_t dtime0:1;
1559 uint64_t dcnt1:1; 1535 uint64_t dcnt1:1;
@@ -1959,7 +1935,6 @@ union cvmx_npei_pktx_cnts {
1959 } s; 1935 } s;
1960 struct cvmx_npei_pktx_cnts_s cn52xx; 1936 struct cvmx_npei_pktx_cnts_s cn52xx;
1961 struct cvmx_npei_pktx_cnts_s cn56xx; 1937 struct cvmx_npei_pktx_cnts_s cn56xx;
1962 struct cvmx_npei_pktx_cnts_s cn56xxp1;
1963}; 1938};
1964 1939
1965union cvmx_npei_pktx_in_bp { 1940union cvmx_npei_pktx_in_bp {
@@ -1970,7 +1945,6 @@ union cvmx_npei_pktx_in_bp {
1970 } s; 1945 } s;
1971 struct cvmx_npei_pktx_in_bp_s cn52xx; 1946 struct cvmx_npei_pktx_in_bp_s cn52xx;
1972 struct cvmx_npei_pktx_in_bp_s cn56xx; 1947 struct cvmx_npei_pktx_in_bp_s cn56xx;
1973 struct cvmx_npei_pktx_in_bp_s cn56xxp1;
1974}; 1948};
1975 1949
1976union cvmx_npei_pktx_instr_baddr { 1950union cvmx_npei_pktx_instr_baddr {
@@ -1981,7 +1955,6 @@ union cvmx_npei_pktx_instr_baddr {
1981 } s; 1955 } s;
1982 struct cvmx_npei_pktx_instr_baddr_s cn52xx; 1956 struct cvmx_npei_pktx_instr_baddr_s cn52xx;
1983 struct cvmx_npei_pktx_instr_baddr_s cn56xx; 1957 struct cvmx_npei_pktx_instr_baddr_s cn56xx;
1984 struct cvmx_npei_pktx_instr_baddr_s cn56xxp1;
1985}; 1958};
1986 1959
1987union cvmx_npei_pktx_instr_baoff_dbell { 1960union cvmx_npei_pktx_instr_baoff_dbell {
@@ -1992,7 +1965,6 @@ union cvmx_npei_pktx_instr_baoff_dbell {
1992 } s; 1965 } s;
1993 struct cvmx_npei_pktx_instr_baoff_dbell_s cn52xx; 1966 struct cvmx_npei_pktx_instr_baoff_dbell_s cn52xx;
1994 struct cvmx_npei_pktx_instr_baoff_dbell_s cn56xx; 1967 struct cvmx_npei_pktx_instr_baoff_dbell_s cn56xx;
1995 struct cvmx_npei_pktx_instr_baoff_dbell_s cn56xxp1;
1996}; 1968};
1997 1969
1998union cvmx_npei_pktx_instr_fifo_rsize { 1970union cvmx_npei_pktx_instr_fifo_rsize {
@@ -2006,7 +1978,6 @@ union cvmx_npei_pktx_instr_fifo_rsize {
2006 } s; 1978 } s;
2007 struct cvmx_npei_pktx_instr_fifo_rsize_s cn52xx; 1979 struct cvmx_npei_pktx_instr_fifo_rsize_s cn52xx;
2008 struct cvmx_npei_pktx_instr_fifo_rsize_s cn56xx; 1980 struct cvmx_npei_pktx_instr_fifo_rsize_s cn56xx;
2009 struct cvmx_npei_pktx_instr_fifo_rsize_s cn56xxp1;
2010}; 1981};
2011 1982
2012union cvmx_npei_pktx_instr_header { 1983union cvmx_npei_pktx_instr_header {
@@ -2014,21 +1985,20 @@ union cvmx_npei_pktx_instr_header {
2014 struct cvmx_npei_pktx_instr_header_s { 1985 struct cvmx_npei_pktx_instr_header_s {
2015 uint64_t reserved_44_63:20; 1986 uint64_t reserved_44_63:20;
2016 uint64_t pbp:1; 1987 uint64_t pbp:1;
2017 uint64_t rsv_f:5; 1988 uint64_t reserved_38_42:5;
2018 uint64_t rparmode:2; 1989 uint64_t rparmode:2;
2019 uint64_t rsv_e:1; 1990 uint64_t reserved_35_35:1;
2020 uint64_t rskp_len:7; 1991 uint64_t rskp_len:7;
2021 uint64_t rsv_d:6; 1992 uint64_t reserved_22_27:6;
2022 uint64_t use_ihdr:1; 1993 uint64_t use_ihdr:1;
2023 uint64_t rsv_c:5; 1994 uint64_t reserved_16_20:5;
2024 uint64_t par_mode:2; 1995 uint64_t par_mode:2;
2025 uint64_t rsv_b:1; 1996 uint64_t reserved_13_13:1;
2026 uint64_t skp_len:7; 1997 uint64_t skp_len:7;
2027 uint64_t rsv_a:6; 1998 uint64_t reserved_0_5:6;
2028 } s; 1999 } s;
2029 struct cvmx_npei_pktx_instr_header_s cn52xx; 2000 struct cvmx_npei_pktx_instr_header_s cn52xx;
2030 struct cvmx_npei_pktx_instr_header_s cn56xx; 2001 struct cvmx_npei_pktx_instr_header_s cn56xx;
2031 struct cvmx_npei_pktx_instr_header_s cn56xxp1;
2032}; 2002};
2033 2003
2034union cvmx_npei_pktx_slist_baddr { 2004union cvmx_npei_pktx_slist_baddr {
@@ -2039,7 +2009,6 @@ union cvmx_npei_pktx_slist_baddr {
2039 } s; 2009 } s;
2040 struct cvmx_npei_pktx_slist_baddr_s cn52xx; 2010 struct cvmx_npei_pktx_slist_baddr_s cn52xx;
2041 struct cvmx_npei_pktx_slist_baddr_s cn56xx; 2011 struct cvmx_npei_pktx_slist_baddr_s cn56xx;
2042 struct cvmx_npei_pktx_slist_baddr_s cn56xxp1;
2043}; 2012};
2044 2013
2045union cvmx_npei_pktx_slist_baoff_dbell { 2014union cvmx_npei_pktx_slist_baoff_dbell {
@@ -2050,7 +2019,6 @@ union cvmx_npei_pktx_slist_baoff_dbell {
2050 } s; 2019 } s;
2051 struct cvmx_npei_pktx_slist_baoff_dbell_s cn52xx; 2020 struct cvmx_npei_pktx_slist_baoff_dbell_s cn52xx;
2052 struct cvmx_npei_pktx_slist_baoff_dbell_s cn56xx; 2021 struct cvmx_npei_pktx_slist_baoff_dbell_s cn56xx;
2053 struct cvmx_npei_pktx_slist_baoff_dbell_s cn56xxp1;
2054}; 2022};
2055 2023
2056union cvmx_npei_pktx_slist_fifo_rsize { 2024union cvmx_npei_pktx_slist_fifo_rsize {
@@ -2061,7 +2029,6 @@ union cvmx_npei_pktx_slist_fifo_rsize {
2061 } s; 2029 } s;
2062 struct cvmx_npei_pktx_slist_fifo_rsize_s cn52xx; 2030 struct cvmx_npei_pktx_slist_fifo_rsize_s cn52xx;
2063 struct cvmx_npei_pktx_slist_fifo_rsize_s cn56xx; 2031 struct cvmx_npei_pktx_slist_fifo_rsize_s cn56xx;
2064 struct cvmx_npei_pktx_slist_fifo_rsize_s cn56xxp1;
2065}; 2032};
2066 2033
2067union cvmx_npei_pkt_cnt_int { 2034union cvmx_npei_pkt_cnt_int {
@@ -2072,7 +2039,6 @@ union cvmx_npei_pkt_cnt_int {
2072 } s; 2039 } s;
2073 struct cvmx_npei_pkt_cnt_int_s cn52xx; 2040 struct cvmx_npei_pkt_cnt_int_s cn52xx;
2074 struct cvmx_npei_pkt_cnt_int_s cn56xx; 2041 struct cvmx_npei_pkt_cnt_int_s cn56xx;
2075 struct cvmx_npei_pkt_cnt_int_s cn56xxp1;
2076}; 2042};
2077 2043
2078union cvmx_npei_pkt_cnt_int_enb { 2044union cvmx_npei_pkt_cnt_int_enb {
@@ -2083,7 +2049,6 @@ union cvmx_npei_pkt_cnt_int_enb {
2083 } s; 2049 } s;
2084 struct cvmx_npei_pkt_cnt_int_enb_s cn52xx; 2050 struct cvmx_npei_pkt_cnt_int_enb_s cn52xx;
2085 struct cvmx_npei_pkt_cnt_int_enb_s cn56xx; 2051 struct cvmx_npei_pkt_cnt_int_enb_s cn56xx;
2086 struct cvmx_npei_pkt_cnt_int_enb_s cn56xxp1;
2087}; 2052};
2088 2053
2089union cvmx_npei_pkt_data_out_es { 2054union cvmx_npei_pkt_data_out_es {
@@ -2093,7 +2058,6 @@ union cvmx_npei_pkt_data_out_es {
2093 } s; 2058 } s;
2094 struct cvmx_npei_pkt_data_out_es_s cn52xx; 2059 struct cvmx_npei_pkt_data_out_es_s cn52xx;
2095 struct cvmx_npei_pkt_data_out_es_s cn56xx; 2060 struct cvmx_npei_pkt_data_out_es_s cn56xx;
2096 struct cvmx_npei_pkt_data_out_es_s cn56xxp1;
2097}; 2061};
2098 2062
2099union cvmx_npei_pkt_data_out_ns { 2063union cvmx_npei_pkt_data_out_ns {
@@ -2104,7 +2068,6 @@ union cvmx_npei_pkt_data_out_ns {
2104 } s; 2068 } s;
2105 struct cvmx_npei_pkt_data_out_ns_s cn52xx; 2069 struct cvmx_npei_pkt_data_out_ns_s cn52xx;
2106 struct cvmx_npei_pkt_data_out_ns_s cn56xx; 2070 struct cvmx_npei_pkt_data_out_ns_s cn56xx;
2107 struct cvmx_npei_pkt_data_out_ns_s cn56xxp1;
2108}; 2071};
2109 2072
2110union cvmx_npei_pkt_data_out_ror { 2073union cvmx_npei_pkt_data_out_ror {
@@ -2115,7 +2078,6 @@ union cvmx_npei_pkt_data_out_ror {
2115 } s; 2078 } s;
2116 struct cvmx_npei_pkt_data_out_ror_s cn52xx; 2079 struct cvmx_npei_pkt_data_out_ror_s cn52xx;
2117 struct cvmx_npei_pkt_data_out_ror_s cn56xx; 2080 struct cvmx_npei_pkt_data_out_ror_s cn56xx;
2118 struct cvmx_npei_pkt_data_out_ror_s cn56xxp1;
2119}; 2081};
2120 2082
2121union cvmx_npei_pkt_dpaddr { 2083union cvmx_npei_pkt_dpaddr {
@@ -2126,7 +2088,6 @@ union cvmx_npei_pkt_dpaddr {
2126 } s; 2088 } s;
2127 struct cvmx_npei_pkt_dpaddr_s cn52xx; 2089 struct cvmx_npei_pkt_dpaddr_s cn52xx;
2128 struct cvmx_npei_pkt_dpaddr_s cn56xx; 2090 struct cvmx_npei_pkt_dpaddr_s cn56xx;
2129 struct cvmx_npei_pkt_dpaddr_s cn56xxp1;
2130}; 2091};
2131 2092
2132union cvmx_npei_pkt_in_bp { 2093union cvmx_npei_pkt_in_bp {
@@ -2135,6 +2096,7 @@ union cvmx_npei_pkt_in_bp {
2135 uint64_t reserved_32_63:32; 2096 uint64_t reserved_32_63:32;
2136 uint64_t bp:32; 2097 uint64_t bp:32;
2137 } s; 2098 } s;
2099 struct cvmx_npei_pkt_in_bp_s cn52xx;
2138 struct cvmx_npei_pkt_in_bp_s cn56xx; 2100 struct cvmx_npei_pkt_in_bp_s cn56xx;
2139}; 2101};
2140 2102
@@ -2146,7 +2108,6 @@ union cvmx_npei_pkt_in_donex_cnts {
2146 } s; 2108 } s;
2147 struct cvmx_npei_pkt_in_donex_cnts_s cn52xx; 2109 struct cvmx_npei_pkt_in_donex_cnts_s cn52xx;
2148 struct cvmx_npei_pkt_in_donex_cnts_s cn56xx; 2110 struct cvmx_npei_pkt_in_donex_cnts_s cn56xx;
2149 struct cvmx_npei_pkt_in_donex_cnts_s cn56xxp1;
2150}; 2111};
2151 2112
2152union cvmx_npei_pkt_in_instr_counts { 2113union cvmx_npei_pkt_in_instr_counts {
@@ -2184,7 +2145,6 @@ union cvmx_npei_pkt_input_control {
2184 } s; 2145 } s;
2185 struct cvmx_npei_pkt_input_control_s cn52xx; 2146 struct cvmx_npei_pkt_input_control_s cn52xx;
2186 struct cvmx_npei_pkt_input_control_s cn56xx; 2147 struct cvmx_npei_pkt_input_control_s cn56xx;
2187 struct cvmx_npei_pkt_input_control_s cn56xxp1;
2188}; 2148};
2189 2149
2190union cvmx_npei_pkt_instr_enb { 2150union cvmx_npei_pkt_instr_enb {
@@ -2195,7 +2155,6 @@ union cvmx_npei_pkt_instr_enb {
2195 } s; 2155 } s;
2196 struct cvmx_npei_pkt_instr_enb_s cn52xx; 2156 struct cvmx_npei_pkt_instr_enb_s cn52xx;
2197 struct cvmx_npei_pkt_instr_enb_s cn56xx; 2157 struct cvmx_npei_pkt_instr_enb_s cn56xx;
2198 struct cvmx_npei_pkt_instr_enb_s cn56xxp1;
2199}; 2158};
2200 2159
2201union cvmx_npei_pkt_instr_rd_size { 2160union cvmx_npei_pkt_instr_rd_size {
@@ -2215,7 +2174,6 @@ union cvmx_npei_pkt_instr_size {
2215 } s; 2174 } s;
2216 struct cvmx_npei_pkt_instr_size_s cn52xx; 2175 struct cvmx_npei_pkt_instr_size_s cn52xx;
2217 struct cvmx_npei_pkt_instr_size_s cn56xx; 2176 struct cvmx_npei_pkt_instr_size_s cn56xx;
2218 struct cvmx_npei_pkt_instr_size_s cn56xxp1;
2219}; 2177};
2220 2178
2221union cvmx_npei_pkt_int_levels { 2179union cvmx_npei_pkt_int_levels {
@@ -2227,7 +2185,6 @@ union cvmx_npei_pkt_int_levels {
2227 } s; 2185 } s;
2228 struct cvmx_npei_pkt_int_levels_s cn52xx; 2186 struct cvmx_npei_pkt_int_levels_s cn52xx;
2229 struct cvmx_npei_pkt_int_levels_s cn56xx; 2187 struct cvmx_npei_pkt_int_levels_s cn56xx;
2230 struct cvmx_npei_pkt_int_levels_s cn56xxp1;
2231}; 2188};
2232 2189
2233union cvmx_npei_pkt_iptr { 2190union cvmx_npei_pkt_iptr {
@@ -2238,7 +2195,6 @@ union cvmx_npei_pkt_iptr {
2238 } s; 2195 } s;
2239 struct cvmx_npei_pkt_iptr_s cn52xx; 2196 struct cvmx_npei_pkt_iptr_s cn52xx;
2240 struct cvmx_npei_pkt_iptr_s cn56xx; 2197 struct cvmx_npei_pkt_iptr_s cn56xx;
2241 struct cvmx_npei_pkt_iptr_s cn56xxp1;
2242}; 2198};
2243 2199
2244union cvmx_npei_pkt_out_bmode { 2200union cvmx_npei_pkt_out_bmode {
@@ -2249,7 +2205,6 @@ union cvmx_npei_pkt_out_bmode {
2249 } s; 2205 } s;
2250 struct cvmx_npei_pkt_out_bmode_s cn52xx; 2206 struct cvmx_npei_pkt_out_bmode_s cn52xx;
2251 struct cvmx_npei_pkt_out_bmode_s cn56xx; 2207 struct cvmx_npei_pkt_out_bmode_s cn56xx;
2252 struct cvmx_npei_pkt_out_bmode_s cn56xxp1;
2253}; 2208};
2254 2209
2255union cvmx_npei_pkt_out_enb { 2210union cvmx_npei_pkt_out_enb {
@@ -2260,7 +2215,6 @@ union cvmx_npei_pkt_out_enb {
2260 } s; 2215 } s;
2261 struct cvmx_npei_pkt_out_enb_s cn52xx; 2216 struct cvmx_npei_pkt_out_enb_s cn52xx;
2262 struct cvmx_npei_pkt_out_enb_s cn56xx; 2217 struct cvmx_npei_pkt_out_enb_s cn56xx;
2263 struct cvmx_npei_pkt_out_enb_s cn56xxp1;
2264}; 2218};
2265 2219
2266union cvmx_npei_pkt_output_wmark { 2220union cvmx_npei_pkt_output_wmark {
@@ -2280,7 +2234,6 @@ union cvmx_npei_pkt_pcie_port {
2280 } s; 2234 } s;
2281 struct cvmx_npei_pkt_pcie_port_s cn52xx; 2235 struct cvmx_npei_pkt_pcie_port_s cn52xx;
2282 struct cvmx_npei_pkt_pcie_port_s cn56xx; 2236 struct cvmx_npei_pkt_pcie_port_s cn56xx;
2283 struct cvmx_npei_pkt_pcie_port_s cn56xxp1;
2284}; 2237};
2285 2238
2286union cvmx_npei_pkt_port_in_rst { 2239union cvmx_npei_pkt_port_in_rst {
@@ -2300,7 +2253,6 @@ union cvmx_npei_pkt_slist_es {
2300 } s; 2253 } s;
2301 struct cvmx_npei_pkt_slist_es_s cn52xx; 2254 struct cvmx_npei_pkt_slist_es_s cn52xx;
2302 struct cvmx_npei_pkt_slist_es_s cn56xx; 2255 struct cvmx_npei_pkt_slist_es_s cn56xx;
2303 struct cvmx_npei_pkt_slist_es_s cn56xxp1;
2304}; 2256};
2305 2257
2306union cvmx_npei_pkt_slist_id_size { 2258union cvmx_npei_pkt_slist_id_size {
@@ -2312,7 +2264,6 @@ union cvmx_npei_pkt_slist_id_size {
2312 } s; 2264 } s;
2313 struct cvmx_npei_pkt_slist_id_size_s cn52xx; 2265 struct cvmx_npei_pkt_slist_id_size_s cn52xx;
2314 struct cvmx_npei_pkt_slist_id_size_s cn56xx; 2266 struct cvmx_npei_pkt_slist_id_size_s cn56xx;
2315 struct cvmx_npei_pkt_slist_id_size_s cn56xxp1;
2316}; 2267};
2317 2268
2318union cvmx_npei_pkt_slist_ns { 2269union cvmx_npei_pkt_slist_ns {
@@ -2323,7 +2274,6 @@ union cvmx_npei_pkt_slist_ns {
2323 } s; 2274 } s;
2324 struct cvmx_npei_pkt_slist_ns_s cn52xx; 2275 struct cvmx_npei_pkt_slist_ns_s cn52xx;
2325 struct cvmx_npei_pkt_slist_ns_s cn56xx; 2276 struct cvmx_npei_pkt_slist_ns_s cn56xx;
2326 struct cvmx_npei_pkt_slist_ns_s cn56xxp1;
2327}; 2277};
2328 2278
2329union cvmx_npei_pkt_slist_ror { 2279union cvmx_npei_pkt_slist_ror {
@@ -2334,7 +2284,6 @@ union cvmx_npei_pkt_slist_ror {
2334 } s; 2284 } s;
2335 struct cvmx_npei_pkt_slist_ror_s cn52xx; 2285 struct cvmx_npei_pkt_slist_ror_s cn52xx;
2336 struct cvmx_npei_pkt_slist_ror_s cn56xx; 2286 struct cvmx_npei_pkt_slist_ror_s cn56xx;
2337 struct cvmx_npei_pkt_slist_ror_s cn56xxp1;
2338}; 2287};
2339 2288
2340union cvmx_npei_pkt_time_int { 2289union cvmx_npei_pkt_time_int {
@@ -2345,7 +2294,6 @@ union cvmx_npei_pkt_time_int {
2345 } s; 2294 } s;
2346 struct cvmx_npei_pkt_time_int_s cn52xx; 2295 struct cvmx_npei_pkt_time_int_s cn52xx;
2347 struct cvmx_npei_pkt_time_int_s cn56xx; 2296 struct cvmx_npei_pkt_time_int_s cn56xx;
2348 struct cvmx_npei_pkt_time_int_s cn56xxp1;
2349}; 2297};
2350 2298
2351union cvmx_npei_pkt_time_int_enb { 2299union cvmx_npei_pkt_time_int_enb {
@@ -2356,7 +2304,6 @@ union cvmx_npei_pkt_time_int_enb {
2356 } s; 2304 } s;
2357 struct cvmx_npei_pkt_time_int_enb_s cn52xx; 2305 struct cvmx_npei_pkt_time_int_enb_s cn52xx;
2358 struct cvmx_npei_pkt_time_int_enb_s cn56xx; 2306 struct cvmx_npei_pkt_time_int_enb_s cn56xx;
2359 struct cvmx_npei_pkt_time_int_enb_s cn56xxp1;
2360}; 2307};
2361 2308
2362union cvmx_npei_rsl_int_blocks { 2309union cvmx_npei_rsl_int_blocks {
@@ -2371,7 +2318,8 @@ union cvmx_npei_rsl_int_blocks {
2371 uint64_t asxpcs0:1; 2318 uint64_t asxpcs0:1;
2372 uint64_t reserved_21_21:1; 2319 uint64_t reserved_21_21:1;
2373 uint64_t pip:1; 2320 uint64_t pip:1;
2374 uint64_t reserved_18_19:2; 2321 uint64_t spx1:1;
2322 uint64_t spx0:1;
2375 uint64_t lmc0:1; 2323 uint64_t lmc0:1;
2376 uint64_t l2c:1; 2324 uint64_t l2c:1;
2377 uint64_t usb1:1; 2325 uint64_t usb1:1;
@@ -2383,7 +2331,7 @@ union cvmx_npei_rsl_int_blocks {
2383 uint64_t ipd:1; 2331 uint64_t ipd:1;
2384 uint64_t reserved_8_8:1; 2332 uint64_t reserved_8_8:1;
2385 uint64_t zip:1; 2333 uint64_t zip:1;
2386 uint64_t reserved_6_6:1; 2334 uint64_t dfa:1;
2387 uint64_t fpa:1; 2335 uint64_t fpa:1;
2388 uint64_t key:1; 2336 uint64_t key:1;
2389 uint64_t npei:1; 2337 uint64_t npei:1;
@@ -2393,37 +2341,8 @@ union cvmx_npei_rsl_int_blocks {
2393 } s; 2341 } s;
2394 struct cvmx_npei_rsl_int_blocks_s cn52xx; 2342 struct cvmx_npei_rsl_int_blocks_s cn52xx;
2395 struct cvmx_npei_rsl_int_blocks_s cn52xxp1; 2343 struct cvmx_npei_rsl_int_blocks_s cn52xxp1;
2396 struct cvmx_npei_rsl_int_blocks_cn56xx { 2344 struct cvmx_npei_rsl_int_blocks_s cn56xx;
2397 uint64_t reserved_31_63:33; 2345 struct cvmx_npei_rsl_int_blocks_s cn56xxp1;
2398 uint64_t iob:1;
2399 uint64_t lmc1:1;
2400 uint64_t agl:1;
2401 uint64_t reserved_24_27:4;
2402 uint64_t asxpcs1:1;
2403 uint64_t asxpcs0:1;
2404 uint64_t reserved_21_21:1;
2405 uint64_t pip:1;
2406 uint64_t reserved_18_19:2;
2407 uint64_t lmc0:1;
2408 uint64_t l2c:1;
2409 uint64_t reserved_15_15:1;
2410 uint64_t rad:1;
2411 uint64_t usb:1;
2412 uint64_t pow:1;
2413 uint64_t tim:1;
2414 uint64_t pko:1;
2415 uint64_t ipd:1;
2416 uint64_t reserved_8_8:1;
2417 uint64_t zip:1;
2418 uint64_t reserved_6_6:1;
2419 uint64_t fpa:1;
2420 uint64_t key:1;
2421 uint64_t npei:1;
2422 uint64_t gmx1:1;
2423 uint64_t gmx0:1;
2424 uint64_t mio:1;
2425 } cn56xx;
2426 struct cvmx_npei_rsl_int_blocks_cn56xx cn56xxp1;
2427}; 2346};
2428 2347
2429union cvmx_npei_scratch_1 { 2348union cvmx_npei_scratch_1 {
diff --git a/arch/mips/include/asm/octeon/cvmx-npi-defs.h b/arch/mips/include/asm/octeon/cvmx-npi-defs.h
index 4e03cd8561e3..f089c780060f 100644
--- a/arch/mips/include/asm/octeon/cvmx-npi-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-npi-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,246 +28,126 @@
28#ifndef __CVMX_NPI_DEFS_H__ 28#ifndef __CVMX_NPI_DEFS_H__
29#define __CVMX_NPI_DEFS_H__ 29#define __CVMX_NPI_DEFS_H__
30 30
31#define CVMX_NPI_BASE_ADDR_INPUT0 \ 31#define CVMX_NPI_BASE_ADDR_INPUT0 CVMX_NPI_BASE_ADDR_INPUTX(0)
32 CVMX_ADD_IO_SEG(0x00011F0000000070ull) 32#define CVMX_NPI_BASE_ADDR_INPUT1 CVMX_NPI_BASE_ADDR_INPUTX(1)
33#define CVMX_NPI_BASE_ADDR_INPUT1 \ 33#define CVMX_NPI_BASE_ADDR_INPUT2 CVMX_NPI_BASE_ADDR_INPUTX(2)
34 CVMX_ADD_IO_SEG(0x00011F0000000080ull) 34#define CVMX_NPI_BASE_ADDR_INPUT3 CVMX_NPI_BASE_ADDR_INPUTX(3)
35#define CVMX_NPI_BASE_ADDR_INPUT2 \ 35#define CVMX_NPI_BASE_ADDR_INPUTX(offset) (CVMX_ADD_IO_SEG(0x00011F0000000070ull) + ((offset) & 3) * 16)
36 CVMX_ADD_IO_SEG(0x00011F0000000090ull) 36#define CVMX_NPI_BASE_ADDR_OUTPUT0 CVMX_NPI_BASE_ADDR_OUTPUTX(0)
37#define CVMX_NPI_BASE_ADDR_INPUT3 \ 37#define CVMX_NPI_BASE_ADDR_OUTPUT1 CVMX_NPI_BASE_ADDR_OUTPUTX(1)
38 CVMX_ADD_IO_SEG(0x00011F00000000A0ull) 38#define CVMX_NPI_BASE_ADDR_OUTPUT2 CVMX_NPI_BASE_ADDR_OUTPUTX(2)
39#define CVMX_NPI_BASE_ADDR_INPUTX(offset) \ 39#define CVMX_NPI_BASE_ADDR_OUTPUT3 CVMX_NPI_BASE_ADDR_OUTPUTX(3)
40 CVMX_ADD_IO_SEG(0x00011F0000000070ull + (((offset) & 3) * 16)) 40#define CVMX_NPI_BASE_ADDR_OUTPUTX(offset) (CVMX_ADD_IO_SEG(0x00011F00000000B8ull) + ((offset) & 3) * 8)
41#define CVMX_NPI_BASE_ADDR_OUTPUT0 \ 41#define CVMX_NPI_BIST_STATUS (CVMX_ADD_IO_SEG(0x00011F00000003F8ull))
42 CVMX_ADD_IO_SEG(0x00011F00000000B8ull) 42#define CVMX_NPI_BUFF_SIZE_OUTPUT0 CVMX_NPI_BUFF_SIZE_OUTPUTX(0)
43#define CVMX_NPI_BASE_ADDR_OUTPUT1 \ 43#define CVMX_NPI_BUFF_SIZE_OUTPUT1 CVMX_NPI_BUFF_SIZE_OUTPUTX(1)
44 CVMX_ADD_IO_SEG(0x00011F00000000C0ull) 44#define CVMX_NPI_BUFF_SIZE_OUTPUT2 CVMX_NPI_BUFF_SIZE_OUTPUTX(2)
45#define CVMX_NPI_BASE_ADDR_OUTPUT2 \ 45#define CVMX_NPI_BUFF_SIZE_OUTPUT3 CVMX_NPI_BUFF_SIZE_OUTPUTX(3)
46 CVMX_ADD_IO_SEG(0x00011F00000000C8ull) 46#define CVMX_NPI_BUFF_SIZE_OUTPUTX(offset) (CVMX_ADD_IO_SEG(0x00011F00000000E0ull) + ((offset) & 3) * 8)
47#define CVMX_NPI_BASE_ADDR_OUTPUT3 \ 47#define CVMX_NPI_COMP_CTL (CVMX_ADD_IO_SEG(0x00011F0000000218ull))
48 CVMX_ADD_IO_SEG(0x00011F00000000D0ull) 48#define CVMX_NPI_CTL_STATUS (CVMX_ADD_IO_SEG(0x00011F0000000010ull))
49#define CVMX_NPI_BASE_ADDR_OUTPUTX(offset) \ 49#define CVMX_NPI_DBG_SELECT (CVMX_ADD_IO_SEG(0x00011F0000000008ull))
50 CVMX_ADD_IO_SEG(0x00011F00000000B8ull + (((offset) & 3) * 8)) 50#define CVMX_NPI_DMA_CONTROL (CVMX_ADD_IO_SEG(0x00011F0000000128ull))
51#define CVMX_NPI_BIST_STATUS \ 51#define CVMX_NPI_DMA_HIGHP_COUNTS (CVMX_ADD_IO_SEG(0x00011F0000000148ull))
52 CVMX_ADD_IO_SEG(0x00011F00000003F8ull) 52#define CVMX_NPI_DMA_HIGHP_NADDR (CVMX_ADD_IO_SEG(0x00011F0000000158ull))
53#define CVMX_NPI_BUFF_SIZE_OUTPUT0 \ 53#define CVMX_NPI_DMA_LOWP_COUNTS (CVMX_ADD_IO_SEG(0x00011F0000000140ull))
54 CVMX_ADD_IO_SEG(0x00011F00000000E0ull) 54#define CVMX_NPI_DMA_LOWP_NADDR (CVMX_ADD_IO_SEG(0x00011F0000000150ull))
55#define CVMX_NPI_BUFF_SIZE_OUTPUT1 \ 55#define CVMX_NPI_HIGHP_DBELL (CVMX_ADD_IO_SEG(0x00011F0000000120ull))
56 CVMX_ADD_IO_SEG(0x00011F00000000E8ull) 56#define CVMX_NPI_HIGHP_IBUFF_SADDR (CVMX_ADD_IO_SEG(0x00011F0000000110ull))
57#define CVMX_NPI_BUFF_SIZE_OUTPUT2 \ 57#define CVMX_NPI_INPUT_CONTROL (CVMX_ADD_IO_SEG(0x00011F0000000138ull))
58 CVMX_ADD_IO_SEG(0x00011F00000000F0ull) 58#define CVMX_NPI_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000000020ull))
59#define CVMX_NPI_BUFF_SIZE_OUTPUT3 \ 59#define CVMX_NPI_INT_SUM (CVMX_ADD_IO_SEG(0x00011F0000000018ull))
60 CVMX_ADD_IO_SEG(0x00011F00000000F8ull) 60#define CVMX_NPI_LOWP_DBELL (CVMX_ADD_IO_SEG(0x00011F0000000118ull))
61#define CVMX_NPI_BUFF_SIZE_OUTPUTX(offset) \ 61#define CVMX_NPI_LOWP_IBUFF_SADDR (CVMX_ADD_IO_SEG(0x00011F0000000108ull))
62 CVMX_ADD_IO_SEG(0x00011F00000000E0ull + (((offset) & 3) * 8)) 62#define CVMX_NPI_MEM_ACCESS_SUBID3 CVMX_NPI_MEM_ACCESS_SUBIDX(3)
63#define CVMX_NPI_COMP_CTL \ 63#define CVMX_NPI_MEM_ACCESS_SUBID4 CVMX_NPI_MEM_ACCESS_SUBIDX(4)
64 CVMX_ADD_IO_SEG(0x00011F0000000218ull) 64#define CVMX_NPI_MEM_ACCESS_SUBID5 CVMX_NPI_MEM_ACCESS_SUBIDX(5)
65#define CVMX_NPI_CTL_STATUS \ 65#define CVMX_NPI_MEM_ACCESS_SUBID6 CVMX_NPI_MEM_ACCESS_SUBIDX(6)
66 CVMX_ADD_IO_SEG(0x00011F0000000010ull) 66#define CVMX_NPI_MEM_ACCESS_SUBIDX(offset) (CVMX_ADD_IO_SEG(0x00011F0000000028ull) + ((offset) & 7) * 8 - 8*3)
67#define CVMX_NPI_DBG_SELECT \ 67#define CVMX_NPI_MSI_RCV (0x0000000000000190ull)
68 CVMX_ADD_IO_SEG(0x00011F0000000008ull) 68#define CVMX_NPI_NPI_MSI_RCV (CVMX_ADD_IO_SEG(0x00011F0000001190ull))
69#define CVMX_NPI_DMA_CONTROL \ 69#define CVMX_NPI_NUM_DESC_OUTPUT0 CVMX_NPI_NUM_DESC_OUTPUTX(0)
70 CVMX_ADD_IO_SEG(0x00011F0000000128ull) 70#define CVMX_NPI_NUM_DESC_OUTPUT1 CVMX_NPI_NUM_DESC_OUTPUTX(1)
71#define CVMX_NPI_DMA_HIGHP_COUNTS \ 71#define CVMX_NPI_NUM_DESC_OUTPUT2 CVMX_NPI_NUM_DESC_OUTPUTX(2)
72 CVMX_ADD_IO_SEG(0x00011F0000000148ull) 72#define CVMX_NPI_NUM_DESC_OUTPUT3 CVMX_NPI_NUM_DESC_OUTPUTX(3)
73#define CVMX_NPI_DMA_HIGHP_NADDR \ 73#define CVMX_NPI_NUM_DESC_OUTPUTX(offset) (CVMX_ADD_IO_SEG(0x00011F0000000050ull) + ((offset) & 3) * 8)
74 CVMX_ADD_IO_SEG(0x00011F0000000158ull) 74#define CVMX_NPI_OUTPUT_CONTROL (CVMX_ADD_IO_SEG(0x00011F0000000100ull))
75#define CVMX_NPI_DMA_LOWP_COUNTS \ 75#define CVMX_NPI_P0_DBPAIR_ADDR CVMX_NPI_PX_DBPAIR_ADDR(0)
76 CVMX_ADD_IO_SEG(0x00011F0000000140ull) 76#define CVMX_NPI_P0_INSTR_ADDR CVMX_NPI_PX_INSTR_ADDR(0)
77#define CVMX_NPI_DMA_LOWP_NADDR \ 77#define CVMX_NPI_P0_INSTR_CNTS CVMX_NPI_PX_INSTR_CNTS(0)
78 CVMX_ADD_IO_SEG(0x00011F0000000150ull) 78#define CVMX_NPI_P0_PAIR_CNTS CVMX_NPI_PX_PAIR_CNTS(0)
79#define CVMX_NPI_HIGHP_DBELL \ 79#define CVMX_NPI_P1_DBPAIR_ADDR CVMX_NPI_PX_DBPAIR_ADDR(1)
80 CVMX_ADD_IO_SEG(0x00011F0000000120ull) 80#define CVMX_NPI_P1_INSTR_ADDR CVMX_NPI_PX_INSTR_ADDR(1)
81#define CVMX_NPI_HIGHP_IBUFF_SADDR \ 81#define CVMX_NPI_P1_INSTR_CNTS CVMX_NPI_PX_INSTR_CNTS(1)
82 CVMX_ADD_IO_SEG(0x00011F0000000110ull) 82#define CVMX_NPI_P1_PAIR_CNTS CVMX_NPI_PX_PAIR_CNTS(1)
83#define CVMX_NPI_INPUT_CONTROL \ 83#define CVMX_NPI_P2_DBPAIR_ADDR CVMX_NPI_PX_DBPAIR_ADDR(2)
84 CVMX_ADD_IO_SEG(0x00011F0000000138ull) 84#define CVMX_NPI_P2_INSTR_ADDR CVMX_NPI_PX_INSTR_ADDR(2)
85#define CVMX_NPI_INT_ENB \ 85#define CVMX_NPI_P2_INSTR_CNTS CVMX_NPI_PX_INSTR_CNTS(2)
86 CVMX_ADD_IO_SEG(0x00011F0000000020ull) 86#define CVMX_NPI_P2_PAIR_CNTS CVMX_NPI_PX_PAIR_CNTS(2)
87#define CVMX_NPI_INT_SUM \ 87#define CVMX_NPI_P3_DBPAIR_ADDR CVMX_NPI_PX_DBPAIR_ADDR(3)
88 CVMX_ADD_IO_SEG(0x00011F0000000018ull) 88#define CVMX_NPI_P3_INSTR_ADDR CVMX_NPI_PX_INSTR_ADDR(3)
89#define CVMX_NPI_LOWP_DBELL \ 89#define CVMX_NPI_P3_INSTR_CNTS CVMX_NPI_PX_INSTR_CNTS(3)
90 CVMX_ADD_IO_SEG(0x00011F0000000118ull) 90#define CVMX_NPI_P3_PAIR_CNTS CVMX_NPI_PX_PAIR_CNTS(3)
91#define CVMX_NPI_LOWP_IBUFF_SADDR \ 91#define CVMX_NPI_PCI_BAR1_INDEXX(offset) (CVMX_ADD_IO_SEG(0x00011F0000001100ull) + ((offset) & 31) * 4)
92 CVMX_ADD_IO_SEG(0x00011F0000000108ull) 92#define CVMX_NPI_PCI_BIST_REG (CVMX_ADD_IO_SEG(0x00011F00000011C0ull))
93#define CVMX_NPI_MEM_ACCESS_SUBID3 \ 93#define CVMX_NPI_PCI_BURST_SIZE (CVMX_ADD_IO_SEG(0x00011F00000000D8ull))
94 CVMX_ADD_IO_SEG(0x00011F0000000028ull) 94#define CVMX_NPI_PCI_CFG00 (CVMX_ADD_IO_SEG(0x00011F0000001800ull))
95#define CVMX_NPI_MEM_ACCESS_SUBID4 \ 95#define CVMX_NPI_PCI_CFG01 (CVMX_ADD_IO_SEG(0x00011F0000001804ull))
96 CVMX_ADD_IO_SEG(0x00011F0000000030ull) 96#define CVMX_NPI_PCI_CFG02 (CVMX_ADD_IO_SEG(0x00011F0000001808ull))
97#define CVMX_NPI_MEM_ACCESS_SUBID5 \ 97#define CVMX_NPI_PCI_CFG03 (CVMX_ADD_IO_SEG(0x00011F000000180Cull))
98 CVMX_ADD_IO_SEG(0x00011F0000000038ull) 98#define CVMX_NPI_PCI_CFG04 (CVMX_ADD_IO_SEG(0x00011F0000001810ull))
99#define CVMX_NPI_MEM_ACCESS_SUBID6 \ 99#define CVMX_NPI_PCI_CFG05 (CVMX_ADD_IO_SEG(0x00011F0000001814ull))
100 CVMX_ADD_IO_SEG(0x00011F0000000040ull) 100#define CVMX_NPI_PCI_CFG06 (CVMX_ADD_IO_SEG(0x00011F0000001818ull))
101#define CVMX_NPI_MEM_ACCESS_SUBIDX(offset) \ 101#define CVMX_NPI_PCI_CFG07 (CVMX_ADD_IO_SEG(0x00011F000000181Cull))
102 CVMX_ADD_IO_SEG(0x00011F0000000028ull + (((offset) & 7) * 8) - 8 * 3) 102#define CVMX_NPI_PCI_CFG08 (CVMX_ADD_IO_SEG(0x00011F0000001820ull))
103#define CVMX_NPI_MSI_RCV \ 103#define CVMX_NPI_PCI_CFG09 (CVMX_ADD_IO_SEG(0x00011F0000001824ull))
104 (0x0000000000000190ull) 104#define CVMX_NPI_PCI_CFG10 (CVMX_ADD_IO_SEG(0x00011F0000001828ull))
105#define CVMX_NPI_NPI_MSI_RCV \ 105#define CVMX_NPI_PCI_CFG11 (CVMX_ADD_IO_SEG(0x00011F000000182Cull))
106 CVMX_ADD_IO_SEG(0x00011F0000001190ull) 106#define CVMX_NPI_PCI_CFG12 (CVMX_ADD_IO_SEG(0x00011F0000001830ull))
107#define CVMX_NPI_NUM_DESC_OUTPUT0 \ 107#define CVMX_NPI_PCI_CFG13 (CVMX_ADD_IO_SEG(0x00011F0000001834ull))
108 CVMX_ADD_IO_SEG(0x00011F0000000050ull) 108#define CVMX_NPI_PCI_CFG15 (CVMX_ADD_IO_SEG(0x00011F000000183Cull))
109#define CVMX_NPI_NUM_DESC_OUTPUT1 \ 109#define CVMX_NPI_PCI_CFG16 (CVMX_ADD_IO_SEG(0x00011F0000001840ull))
110 CVMX_ADD_IO_SEG(0x00011F0000000058ull) 110#define CVMX_NPI_PCI_CFG17 (CVMX_ADD_IO_SEG(0x00011F0000001844ull))
111#define CVMX_NPI_NUM_DESC_OUTPUT2 \ 111#define CVMX_NPI_PCI_CFG18 (CVMX_ADD_IO_SEG(0x00011F0000001848ull))
112 CVMX_ADD_IO_SEG(0x00011F0000000060ull) 112#define CVMX_NPI_PCI_CFG19 (CVMX_ADD_IO_SEG(0x00011F000000184Cull))
113#define CVMX_NPI_NUM_DESC_OUTPUT3 \ 113#define CVMX_NPI_PCI_CFG20 (CVMX_ADD_IO_SEG(0x00011F0000001850ull))
114 CVMX_ADD_IO_SEG(0x00011F0000000068ull) 114#define CVMX_NPI_PCI_CFG21 (CVMX_ADD_IO_SEG(0x00011F0000001854ull))
115#define CVMX_NPI_NUM_DESC_OUTPUTX(offset) \ 115#define CVMX_NPI_PCI_CFG22 (CVMX_ADD_IO_SEG(0x00011F0000001858ull))
116 CVMX_ADD_IO_SEG(0x00011F0000000050ull + (((offset) & 3) * 8)) 116#define CVMX_NPI_PCI_CFG56 (CVMX_ADD_IO_SEG(0x00011F00000018E0ull))
117#define CVMX_NPI_OUTPUT_CONTROL \ 117#define CVMX_NPI_PCI_CFG57 (CVMX_ADD_IO_SEG(0x00011F00000018E4ull))
118 CVMX_ADD_IO_SEG(0x00011F0000000100ull) 118#define CVMX_NPI_PCI_CFG58 (CVMX_ADD_IO_SEG(0x00011F00000018E8ull))
119#define CVMX_NPI_P0_DBPAIR_ADDR \ 119#define CVMX_NPI_PCI_CFG59 (CVMX_ADD_IO_SEG(0x00011F00000018ECull))
120 CVMX_ADD_IO_SEG(0x00011F0000000180ull) 120#define CVMX_NPI_PCI_CFG60 (CVMX_ADD_IO_SEG(0x00011F00000018F0ull))
121#define CVMX_NPI_P0_INSTR_ADDR \ 121#define CVMX_NPI_PCI_CFG61 (CVMX_ADD_IO_SEG(0x00011F00000018F4ull))
122 CVMX_ADD_IO_SEG(0x00011F00000001C0ull) 122#define CVMX_NPI_PCI_CFG62 (CVMX_ADD_IO_SEG(0x00011F00000018F8ull))
123#define CVMX_NPI_P0_INSTR_CNTS \ 123#define CVMX_NPI_PCI_CFG63 (CVMX_ADD_IO_SEG(0x00011F00000018FCull))
124 CVMX_ADD_IO_SEG(0x00011F00000001A0ull) 124#define CVMX_NPI_PCI_CNT_REG (CVMX_ADD_IO_SEG(0x00011F00000011B8ull))
125#define CVMX_NPI_P0_PAIR_CNTS \ 125#define CVMX_NPI_PCI_CTL_STATUS_2 (CVMX_ADD_IO_SEG(0x00011F000000118Cull))
126 CVMX_ADD_IO_SEG(0x00011F0000000160ull) 126#define CVMX_NPI_PCI_INT_ARB_CFG (CVMX_ADD_IO_SEG(0x00011F0000000130ull))
127#define CVMX_NPI_P1_DBPAIR_ADDR \ 127#define CVMX_NPI_PCI_INT_ENB2 (CVMX_ADD_IO_SEG(0x00011F00000011A0ull))
128 CVMX_ADD_IO_SEG(0x00011F0000000188ull) 128#define CVMX_NPI_PCI_INT_SUM2 (CVMX_ADD_IO_SEG(0x00011F0000001198ull))
129#define CVMX_NPI_P1_INSTR_ADDR \ 129#define CVMX_NPI_PCI_READ_CMD (CVMX_ADD_IO_SEG(0x00011F0000000048ull))
130 CVMX_ADD_IO_SEG(0x00011F00000001C8ull) 130#define CVMX_NPI_PCI_READ_CMD_6 (CVMX_ADD_IO_SEG(0x00011F0000001180ull))
131#define CVMX_NPI_P1_INSTR_CNTS \ 131#define CVMX_NPI_PCI_READ_CMD_C (CVMX_ADD_IO_SEG(0x00011F0000001184ull))
132 CVMX_ADD_IO_SEG(0x00011F00000001A8ull) 132#define CVMX_NPI_PCI_READ_CMD_E (CVMX_ADD_IO_SEG(0x00011F0000001188ull))
133#define CVMX_NPI_P1_PAIR_CNTS \ 133#define CVMX_NPI_PCI_SCM_REG (CVMX_ADD_IO_SEG(0x00011F00000011A8ull))
134 CVMX_ADD_IO_SEG(0x00011F0000000168ull) 134#define CVMX_NPI_PCI_TSR_REG (CVMX_ADD_IO_SEG(0x00011F00000011B0ull))
135#define CVMX_NPI_P2_DBPAIR_ADDR \ 135#define CVMX_NPI_PORT32_INSTR_HDR (CVMX_ADD_IO_SEG(0x00011F00000001F8ull))
136 CVMX_ADD_IO_SEG(0x00011F0000000190ull) 136#define CVMX_NPI_PORT33_INSTR_HDR (CVMX_ADD_IO_SEG(0x00011F0000000200ull))
137#define CVMX_NPI_P2_INSTR_ADDR \ 137#define CVMX_NPI_PORT34_INSTR_HDR (CVMX_ADD_IO_SEG(0x00011F0000000208ull))
138 CVMX_ADD_IO_SEG(0x00011F00000001D0ull) 138#define CVMX_NPI_PORT35_INSTR_HDR (CVMX_ADD_IO_SEG(0x00011F0000000210ull))
139#define CVMX_NPI_P2_INSTR_CNTS \ 139#define CVMX_NPI_PORT_BP_CONTROL (CVMX_ADD_IO_SEG(0x00011F00000001F0ull))
140 CVMX_ADD_IO_SEG(0x00011F00000001B0ull) 140#define CVMX_NPI_PX_DBPAIR_ADDR(offset) (CVMX_ADD_IO_SEG(0x00011F0000000180ull) + ((offset) & 3) * 8)
141#define CVMX_NPI_P2_PAIR_CNTS \ 141#define CVMX_NPI_PX_INSTR_ADDR(offset) (CVMX_ADD_IO_SEG(0x00011F00000001C0ull) + ((offset) & 3) * 8)
142 CVMX_ADD_IO_SEG(0x00011F0000000170ull) 142#define CVMX_NPI_PX_INSTR_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F00000001A0ull) + ((offset) & 3) * 8)
143#define CVMX_NPI_P3_DBPAIR_ADDR \ 143#define CVMX_NPI_PX_PAIR_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F0000000160ull) + ((offset) & 3) * 8)
144 CVMX_ADD_IO_SEG(0x00011F0000000198ull) 144#define CVMX_NPI_RSL_INT_BLOCKS (CVMX_ADD_IO_SEG(0x00011F0000000000ull))
145#define CVMX_NPI_P3_INSTR_ADDR \ 145#define CVMX_NPI_SIZE_INPUT0 CVMX_NPI_SIZE_INPUTX(0)
146 CVMX_ADD_IO_SEG(0x00011F00000001D8ull) 146#define CVMX_NPI_SIZE_INPUT1 CVMX_NPI_SIZE_INPUTX(1)
147#define CVMX_NPI_P3_INSTR_CNTS \ 147#define CVMX_NPI_SIZE_INPUT2 CVMX_NPI_SIZE_INPUTX(2)
148 CVMX_ADD_IO_SEG(0x00011F00000001B8ull) 148#define CVMX_NPI_SIZE_INPUT3 CVMX_NPI_SIZE_INPUTX(3)
149#define CVMX_NPI_P3_PAIR_CNTS \ 149#define CVMX_NPI_SIZE_INPUTX(offset) (CVMX_ADD_IO_SEG(0x00011F0000000078ull) + ((offset) & 3) * 16)
150 CVMX_ADD_IO_SEG(0x00011F0000000178ull) 150#define CVMX_NPI_WIN_READ_TO (CVMX_ADD_IO_SEG(0x00011F00000001E0ull))
151#define CVMX_NPI_PCI_BAR1_INDEXX(offset) \
152 CVMX_ADD_IO_SEG(0x00011F0000001100ull + (((offset) & 31) * 4))
153#define CVMX_NPI_PCI_BIST_REG \
154 CVMX_ADD_IO_SEG(0x00011F00000011C0ull)
155#define CVMX_NPI_PCI_BURST_SIZE \
156 CVMX_ADD_IO_SEG(0x00011F00000000D8ull)
157#define CVMX_NPI_PCI_CFG00 \
158 CVMX_ADD_IO_SEG(0x00011F0000001800ull)
159#define CVMX_NPI_PCI_CFG01 \
160 CVMX_ADD_IO_SEG(0x00011F0000001804ull)
161#define CVMX_NPI_PCI_CFG02 \
162 CVMX_ADD_IO_SEG(0x00011F0000001808ull)
163#define CVMX_NPI_PCI_CFG03 \
164 CVMX_ADD_IO_SEG(0x00011F000000180Cull)
165#define CVMX_NPI_PCI_CFG04 \
166 CVMX_ADD_IO_SEG(0x00011F0000001810ull)
167#define CVMX_NPI_PCI_CFG05 \
168 CVMX_ADD_IO_SEG(0x00011F0000001814ull)
169#define CVMX_NPI_PCI_CFG06 \
170 CVMX_ADD_IO_SEG(0x00011F0000001818ull)
171#define CVMX_NPI_PCI_CFG07 \
172 CVMX_ADD_IO_SEG(0x00011F000000181Cull)
173#define CVMX_NPI_PCI_CFG08 \
174 CVMX_ADD_IO_SEG(0x00011F0000001820ull)
175#define CVMX_NPI_PCI_CFG09 \
176 CVMX_ADD_IO_SEG(0x00011F0000001824ull)
177#define CVMX_NPI_PCI_CFG10 \
178 CVMX_ADD_IO_SEG(0x00011F0000001828ull)
179#define CVMX_NPI_PCI_CFG11 \
180 CVMX_ADD_IO_SEG(0x00011F000000182Cull)
181#define CVMX_NPI_PCI_CFG12 \
182 CVMX_ADD_IO_SEG(0x00011F0000001830ull)
183#define CVMX_NPI_PCI_CFG13 \
184 CVMX_ADD_IO_SEG(0x00011F0000001834ull)
185#define CVMX_NPI_PCI_CFG15 \
186 CVMX_ADD_IO_SEG(0x00011F000000183Cull)
187#define CVMX_NPI_PCI_CFG16 \
188 CVMX_ADD_IO_SEG(0x00011F0000001840ull)
189#define CVMX_NPI_PCI_CFG17 \
190 CVMX_ADD_IO_SEG(0x00011F0000001844ull)
191#define CVMX_NPI_PCI_CFG18 \
192 CVMX_ADD_IO_SEG(0x00011F0000001848ull)
193#define CVMX_NPI_PCI_CFG19 \
194 CVMX_ADD_IO_SEG(0x00011F000000184Cull)
195#define CVMX_NPI_PCI_CFG20 \
196 CVMX_ADD_IO_SEG(0x00011F0000001850ull)
197#define CVMX_NPI_PCI_CFG21 \
198 CVMX_ADD_IO_SEG(0x00011F0000001854ull)
199#define CVMX_NPI_PCI_CFG22 \
200 CVMX_ADD_IO_SEG(0x00011F0000001858ull)
201#define CVMX_NPI_PCI_CFG56 \
202 CVMX_ADD_IO_SEG(0x00011F00000018E0ull)
203#define CVMX_NPI_PCI_CFG57 \
204 CVMX_ADD_IO_SEG(0x00011F00000018E4ull)
205#define CVMX_NPI_PCI_CFG58 \
206 CVMX_ADD_IO_SEG(0x00011F00000018E8ull)
207#define CVMX_NPI_PCI_CFG59 \
208 CVMX_ADD_IO_SEG(0x00011F00000018ECull)
209#define CVMX_NPI_PCI_CFG60 \
210 CVMX_ADD_IO_SEG(0x00011F00000018F0ull)
211#define CVMX_NPI_PCI_CFG61 \
212 CVMX_ADD_IO_SEG(0x00011F00000018F4ull)
213#define CVMX_NPI_PCI_CFG62 \
214 CVMX_ADD_IO_SEG(0x00011F00000018F8ull)
215#define CVMX_NPI_PCI_CFG63 \
216 CVMX_ADD_IO_SEG(0x00011F00000018FCull)
217#define CVMX_NPI_PCI_CNT_REG \
218 CVMX_ADD_IO_SEG(0x00011F00000011B8ull)
219#define CVMX_NPI_PCI_CTL_STATUS_2 \
220 CVMX_ADD_IO_SEG(0x00011F000000118Cull)
221#define CVMX_NPI_PCI_INT_ARB_CFG \
222 CVMX_ADD_IO_SEG(0x00011F0000000130ull)
223#define CVMX_NPI_PCI_INT_ENB2 \
224 CVMX_ADD_IO_SEG(0x00011F00000011A0ull)
225#define CVMX_NPI_PCI_INT_SUM2 \
226 CVMX_ADD_IO_SEG(0x00011F0000001198ull)
227#define CVMX_NPI_PCI_READ_CMD \
228 CVMX_ADD_IO_SEG(0x00011F0000000048ull)
229#define CVMX_NPI_PCI_READ_CMD_6 \
230 CVMX_ADD_IO_SEG(0x00011F0000001180ull)
231#define CVMX_NPI_PCI_READ_CMD_C \
232 CVMX_ADD_IO_SEG(0x00011F0000001184ull)
233#define CVMX_NPI_PCI_READ_CMD_E \
234 CVMX_ADD_IO_SEG(0x00011F0000001188ull)
235#define CVMX_NPI_PCI_SCM_REG \
236 CVMX_ADD_IO_SEG(0x00011F00000011A8ull)
237#define CVMX_NPI_PCI_TSR_REG \
238 CVMX_ADD_IO_SEG(0x00011F00000011B0ull)
239#define CVMX_NPI_PORT32_INSTR_HDR \
240 CVMX_ADD_IO_SEG(0x00011F00000001F8ull)
241#define CVMX_NPI_PORT33_INSTR_HDR \
242 CVMX_ADD_IO_SEG(0x00011F0000000200ull)
243#define CVMX_NPI_PORT34_INSTR_HDR \
244 CVMX_ADD_IO_SEG(0x00011F0000000208ull)
245#define CVMX_NPI_PORT35_INSTR_HDR \
246 CVMX_ADD_IO_SEG(0x00011F0000000210ull)
247#define CVMX_NPI_PORT_BP_CONTROL \
248 CVMX_ADD_IO_SEG(0x00011F00000001F0ull)
249#define CVMX_NPI_PX_DBPAIR_ADDR(offset) \
250 CVMX_ADD_IO_SEG(0x00011F0000000180ull + (((offset) & 3) * 8))
251#define CVMX_NPI_PX_INSTR_ADDR(offset) \
252 CVMX_ADD_IO_SEG(0x00011F00000001C0ull + (((offset) & 3) * 8))
253#define CVMX_NPI_PX_INSTR_CNTS(offset) \
254 CVMX_ADD_IO_SEG(0x00011F00000001A0ull + (((offset) & 3) * 8))
255#define CVMX_NPI_PX_PAIR_CNTS(offset) \
256 CVMX_ADD_IO_SEG(0x00011F0000000160ull + (((offset) & 3) * 8))
257#define CVMX_NPI_RSL_INT_BLOCKS \
258 CVMX_ADD_IO_SEG(0x00011F0000000000ull)
259#define CVMX_NPI_SIZE_INPUT0 \
260 CVMX_ADD_IO_SEG(0x00011F0000000078ull)
261#define CVMX_NPI_SIZE_INPUT1 \
262 CVMX_ADD_IO_SEG(0x00011F0000000088ull)
263#define CVMX_NPI_SIZE_INPUT2 \
264 CVMX_ADD_IO_SEG(0x00011F0000000098ull)
265#define CVMX_NPI_SIZE_INPUT3 \
266 CVMX_ADD_IO_SEG(0x00011F00000000A8ull)
267#define CVMX_NPI_SIZE_INPUTX(offset) \
268 CVMX_ADD_IO_SEG(0x00011F0000000078ull + (((offset) & 3) * 16))
269#define CVMX_NPI_WIN_READ_TO \
270 CVMX_ADD_IO_SEG(0x00011F00000001E0ull)
271 151
272union cvmx_npi_base_addr_inputx { 152union cvmx_npi_base_addr_inputx {
273 uint64_t u64; 153 uint64_t u64;
diff --git a/arch/mips/include/asm/octeon/cvmx-pci-defs.h b/arch/mips/include/asm/octeon/cvmx-pci-defs.h
index 90f8d6535753..6ff6d9d357ba 100644
--- a/arch/mips/include/asm/octeon/cvmx-pci-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-pci-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,184 +28,91 @@
28#ifndef __CVMX_PCI_DEFS_H__ 28#ifndef __CVMX_PCI_DEFS_H__
29#define __CVMX_PCI_DEFS_H__ 29#define __CVMX_PCI_DEFS_H__
30 30
31#define CVMX_PCI_BAR1_INDEXX(offset) \ 31#define CVMX_PCI_BAR1_INDEXX(offset) (0x0000000000000100ull + ((offset) & 31) * 4)
32 (0x0000000000000100ull + (((offset) & 31) * 4)) 32#define CVMX_PCI_BIST_REG (0x00000000000001C0ull)
33#define CVMX_PCI_BIST_REG \ 33#define CVMX_PCI_CFG00 (0x0000000000000000ull)
34 (0x00000000000001C0ull) 34#define CVMX_PCI_CFG01 (0x0000000000000004ull)
35#define CVMX_PCI_CFG00 \ 35#define CVMX_PCI_CFG02 (0x0000000000000008ull)
36 (0x0000000000000000ull) 36#define CVMX_PCI_CFG03 (0x000000000000000Cull)
37#define CVMX_PCI_CFG01 \ 37#define CVMX_PCI_CFG04 (0x0000000000000010ull)
38 (0x0000000000000004ull) 38#define CVMX_PCI_CFG05 (0x0000000000000014ull)
39#define CVMX_PCI_CFG02 \ 39#define CVMX_PCI_CFG06 (0x0000000000000018ull)
40 (0x0000000000000008ull) 40#define CVMX_PCI_CFG07 (0x000000000000001Cull)
41#define CVMX_PCI_CFG03 \ 41#define CVMX_PCI_CFG08 (0x0000000000000020ull)
42 (0x000000000000000Cull) 42#define CVMX_PCI_CFG09 (0x0000000000000024ull)
43#define CVMX_PCI_CFG04 \ 43#define CVMX_PCI_CFG10 (0x0000000000000028ull)
44 (0x0000000000000010ull) 44#define CVMX_PCI_CFG11 (0x000000000000002Cull)
45#define CVMX_PCI_CFG05 \ 45#define CVMX_PCI_CFG12 (0x0000000000000030ull)
46 (0x0000000000000014ull) 46#define CVMX_PCI_CFG13 (0x0000000000000034ull)
47#define CVMX_PCI_CFG06 \ 47#define CVMX_PCI_CFG15 (0x000000000000003Cull)
48 (0x0000000000000018ull) 48#define CVMX_PCI_CFG16 (0x0000000000000040ull)
49#define CVMX_PCI_CFG07 \ 49#define CVMX_PCI_CFG17 (0x0000000000000044ull)
50 (0x000000000000001Cull) 50#define CVMX_PCI_CFG18 (0x0000000000000048ull)
51#define CVMX_PCI_CFG08 \ 51#define CVMX_PCI_CFG19 (0x000000000000004Cull)
52 (0x0000000000000020ull) 52#define CVMX_PCI_CFG20 (0x0000000000000050ull)
53#define CVMX_PCI_CFG09 \ 53#define CVMX_PCI_CFG21 (0x0000000000000054ull)
54 (0x0000000000000024ull) 54#define CVMX_PCI_CFG22 (0x0000000000000058ull)
55#define CVMX_PCI_CFG10 \ 55#define CVMX_PCI_CFG56 (0x00000000000000E0ull)
56 (0x0000000000000028ull) 56#define CVMX_PCI_CFG57 (0x00000000000000E4ull)
57#define CVMX_PCI_CFG11 \ 57#define CVMX_PCI_CFG58 (0x00000000000000E8ull)
58 (0x000000000000002Cull) 58#define CVMX_PCI_CFG59 (0x00000000000000ECull)
59#define CVMX_PCI_CFG12 \ 59#define CVMX_PCI_CFG60 (0x00000000000000F0ull)
60 (0x0000000000000030ull) 60#define CVMX_PCI_CFG61 (0x00000000000000F4ull)
61#define CVMX_PCI_CFG13 \ 61#define CVMX_PCI_CFG62 (0x00000000000000F8ull)
62 (0x0000000000000034ull) 62#define CVMX_PCI_CFG63 (0x00000000000000FCull)
63#define CVMX_PCI_CFG15 \ 63#define CVMX_PCI_CNT_REG (0x00000000000001B8ull)
64 (0x000000000000003Cull) 64#define CVMX_PCI_CTL_STATUS_2 (0x000000000000018Cull)
65#define CVMX_PCI_CFG16 \ 65#define CVMX_PCI_DBELL_X(offset) (0x0000000000000080ull + ((offset) & 3) * 8)
66 (0x0000000000000040ull) 66#define CVMX_PCI_DMA_CNT0 CVMX_PCI_DMA_CNTX(0)
67#define CVMX_PCI_CFG17 \ 67#define CVMX_PCI_DMA_CNT1 CVMX_PCI_DMA_CNTX(1)
68 (0x0000000000000044ull) 68#define CVMX_PCI_DMA_CNTX(offset) (0x00000000000000A0ull + ((offset) & 1) * 8)
69#define CVMX_PCI_CFG18 \ 69#define CVMX_PCI_DMA_INT_LEV0 CVMX_PCI_DMA_INT_LEVX(0)
70 (0x0000000000000048ull) 70#define CVMX_PCI_DMA_INT_LEV1 CVMX_PCI_DMA_INT_LEVX(1)
71#define CVMX_PCI_CFG19 \ 71#define CVMX_PCI_DMA_INT_LEVX(offset) (0x00000000000000A4ull + ((offset) & 1) * 8)
72 (0x000000000000004Cull) 72#define CVMX_PCI_DMA_TIME0 CVMX_PCI_DMA_TIMEX(0)
73#define CVMX_PCI_CFG20 \ 73#define CVMX_PCI_DMA_TIME1 CVMX_PCI_DMA_TIMEX(1)
74 (0x0000000000000050ull) 74#define CVMX_PCI_DMA_TIMEX(offset) (0x00000000000000B0ull + ((offset) & 1) * 4)
75#define CVMX_PCI_CFG21 \ 75#define CVMX_PCI_INSTR_COUNT0 CVMX_PCI_INSTR_COUNTX(0)
76 (0x0000000000000054ull) 76#define CVMX_PCI_INSTR_COUNT1 CVMX_PCI_INSTR_COUNTX(1)
77#define CVMX_PCI_CFG22 \ 77#define CVMX_PCI_INSTR_COUNT2 CVMX_PCI_INSTR_COUNTX(2)
78 (0x0000000000000058ull) 78#define CVMX_PCI_INSTR_COUNT3 CVMX_PCI_INSTR_COUNTX(3)
79#define CVMX_PCI_CFG56 \ 79#define CVMX_PCI_INSTR_COUNTX(offset) (0x0000000000000084ull + ((offset) & 3) * 8)
80 (0x00000000000000E0ull) 80#define CVMX_PCI_INT_ENB (0x0000000000000038ull)
81#define CVMX_PCI_CFG57 \ 81#define CVMX_PCI_INT_ENB2 (0x00000000000001A0ull)
82 (0x00000000000000E4ull) 82#define CVMX_PCI_INT_SUM (0x0000000000000030ull)
83#define CVMX_PCI_CFG58 \ 83#define CVMX_PCI_INT_SUM2 (0x0000000000000198ull)
84 (0x00000000000000E8ull) 84#define CVMX_PCI_MSI_RCV (0x00000000000000F0ull)
85#define CVMX_PCI_CFG59 \ 85#define CVMX_PCI_PKTS_SENT0 CVMX_PCI_PKTS_SENTX(0)
86 (0x00000000000000ECull) 86#define CVMX_PCI_PKTS_SENT1 CVMX_PCI_PKTS_SENTX(1)
87#define CVMX_PCI_CFG60 \ 87#define CVMX_PCI_PKTS_SENT2 CVMX_PCI_PKTS_SENTX(2)
88 (0x00000000000000F0ull) 88#define CVMX_PCI_PKTS_SENT3 CVMX_PCI_PKTS_SENTX(3)
89#define CVMX_PCI_CFG61 \ 89#define CVMX_PCI_PKTS_SENTX(offset) (0x0000000000000040ull + ((offset) & 3) * 16)
90 (0x00000000000000F4ull) 90#define CVMX_PCI_PKTS_SENT_INT_LEV0 CVMX_PCI_PKTS_SENT_INT_LEVX(0)
91#define CVMX_PCI_CFG62 \ 91#define CVMX_PCI_PKTS_SENT_INT_LEV1 CVMX_PCI_PKTS_SENT_INT_LEVX(1)
92 (0x00000000000000F8ull) 92#define CVMX_PCI_PKTS_SENT_INT_LEV2 CVMX_PCI_PKTS_SENT_INT_LEVX(2)
93#define CVMX_PCI_CFG63 \ 93#define CVMX_PCI_PKTS_SENT_INT_LEV3 CVMX_PCI_PKTS_SENT_INT_LEVX(3)
94 (0x00000000000000FCull) 94#define CVMX_PCI_PKTS_SENT_INT_LEVX(offset) (0x0000000000000048ull + ((offset) & 3) * 16)
95#define CVMX_PCI_CNT_REG \ 95#define CVMX_PCI_PKTS_SENT_TIME0 CVMX_PCI_PKTS_SENT_TIMEX(0)
96 (0x00000000000001B8ull) 96#define CVMX_PCI_PKTS_SENT_TIME1 CVMX_PCI_PKTS_SENT_TIMEX(1)
97#define CVMX_PCI_CTL_STATUS_2 \ 97#define CVMX_PCI_PKTS_SENT_TIME2 CVMX_PCI_PKTS_SENT_TIMEX(2)
98 (0x000000000000018Cull) 98#define CVMX_PCI_PKTS_SENT_TIME3 CVMX_PCI_PKTS_SENT_TIMEX(3)
99#define CVMX_PCI_DBELL_0 \ 99#define CVMX_PCI_PKTS_SENT_TIMEX(offset) (0x000000000000004Cull + ((offset) & 3) * 16)
100 (0x0000000000000080ull) 100#define CVMX_PCI_PKT_CREDITS0 CVMX_PCI_PKT_CREDITSX(0)
101#define CVMX_PCI_DBELL_1 \ 101#define CVMX_PCI_PKT_CREDITS1 CVMX_PCI_PKT_CREDITSX(1)
102 (0x0000000000000088ull) 102#define CVMX_PCI_PKT_CREDITS2 CVMX_PCI_PKT_CREDITSX(2)
103#define CVMX_PCI_DBELL_2 \ 103#define CVMX_PCI_PKT_CREDITS3 CVMX_PCI_PKT_CREDITSX(3)
104 (0x0000000000000090ull) 104#define CVMX_PCI_PKT_CREDITSX(offset) (0x0000000000000044ull + ((offset) & 3) * 16)
105#define CVMX_PCI_DBELL_3 \ 105#define CVMX_PCI_READ_CMD_6 (0x0000000000000180ull)
106 (0x0000000000000098ull) 106#define CVMX_PCI_READ_CMD_C (0x0000000000000184ull)
107#define CVMX_PCI_DBELL_X(offset) \ 107#define CVMX_PCI_READ_CMD_E (0x0000000000000188ull)
108 (0x0000000000000080ull + (((offset) & 3) * 8)) 108#define CVMX_PCI_READ_TIMEOUT (CVMX_ADD_IO_SEG(0x00011F00000000B0ull))
109#define CVMX_PCI_DMA_CNT0 \ 109#define CVMX_PCI_SCM_REG (0x00000000000001A8ull)
110 (0x00000000000000A0ull) 110#define CVMX_PCI_TSR_REG (0x00000000000001B0ull)
111#define CVMX_PCI_DMA_CNT1 \ 111#define CVMX_PCI_WIN_RD_ADDR (0x0000000000000008ull)
112 (0x00000000000000A8ull) 112#define CVMX_PCI_WIN_RD_DATA (0x0000000000000020ull)
113#define CVMX_PCI_DMA_CNTX(offset) \ 113#define CVMX_PCI_WIN_WR_ADDR (0x0000000000000000ull)
114 (0x00000000000000A0ull + (((offset) & 1) * 8)) 114#define CVMX_PCI_WIN_WR_DATA (0x0000000000000010ull)
115#define CVMX_PCI_DMA_INT_LEV0 \ 115#define CVMX_PCI_WIN_WR_MASK (0x0000000000000018ull)
116 (0x00000000000000A4ull)
117#define CVMX_PCI_DMA_INT_LEV1 \
118 (0x00000000000000ACull)
119#define CVMX_PCI_DMA_INT_LEVX(offset) \
120 (0x00000000000000A4ull + (((offset) & 1) * 8))
121#define CVMX_PCI_DMA_TIME0 \
122 (0x00000000000000B0ull)
123#define CVMX_PCI_DMA_TIME1 \
124 (0x00000000000000B4ull)
125#define CVMX_PCI_DMA_TIMEX(offset) \
126 (0x00000000000000B0ull + (((offset) & 1) * 4))
127#define CVMX_PCI_INSTR_COUNT0 \
128 (0x0000000000000084ull)
129#define CVMX_PCI_INSTR_COUNT1 \
130 (0x000000000000008Cull)
131#define CVMX_PCI_INSTR_COUNT2 \
132 (0x0000000000000094ull)
133#define CVMX_PCI_INSTR_COUNT3 \
134 (0x000000000000009Cull)
135#define CVMX_PCI_INSTR_COUNTX(offset) \
136 (0x0000000000000084ull + (((offset) & 3) * 8))
137#define CVMX_PCI_INT_ENB \
138 (0x0000000000000038ull)
139#define CVMX_PCI_INT_ENB2 \
140 (0x00000000000001A0ull)
141#define CVMX_PCI_INT_SUM \
142 (0x0000000000000030ull)
143#define CVMX_PCI_INT_SUM2 \
144 (0x0000000000000198ull)
145#define CVMX_PCI_MSI_RCV \
146 (0x00000000000000F0ull)
147#define CVMX_PCI_PKTS_SENT0 \
148 (0x0000000000000040ull)
149#define CVMX_PCI_PKTS_SENT1 \
150 (0x0000000000000050ull)
151#define CVMX_PCI_PKTS_SENT2 \
152 (0x0000000000000060ull)
153#define CVMX_PCI_PKTS_SENT3 \
154 (0x0000000000000070ull)
155#define CVMX_PCI_PKTS_SENTX(offset) \
156 (0x0000000000000040ull + (((offset) & 3) * 16))
157#define CVMX_PCI_PKTS_SENT_INT_LEV0 \
158 (0x0000000000000048ull)
159#define CVMX_PCI_PKTS_SENT_INT_LEV1 \
160 (0x0000000000000058ull)
161#define CVMX_PCI_PKTS_SENT_INT_LEV2 \
162 (0x0000000000000068ull)
163#define CVMX_PCI_PKTS_SENT_INT_LEV3 \
164 (0x0000000000000078ull)
165#define CVMX_PCI_PKTS_SENT_INT_LEVX(offset) \
166 (0x0000000000000048ull + (((offset) & 3) * 16))
167#define CVMX_PCI_PKTS_SENT_TIME0 \
168 (0x000000000000004Cull)
169#define CVMX_PCI_PKTS_SENT_TIME1 \
170 (0x000000000000005Cull)
171#define CVMX_PCI_PKTS_SENT_TIME2 \
172 (0x000000000000006Cull)
173#define CVMX_PCI_PKTS_SENT_TIME3 \
174 (0x000000000000007Cull)
175#define CVMX_PCI_PKTS_SENT_TIMEX(offset) \
176 (0x000000000000004Cull + (((offset) & 3) * 16))
177#define CVMX_PCI_PKT_CREDITS0 \
178 (0x0000000000000044ull)
179#define CVMX_PCI_PKT_CREDITS1 \
180 (0x0000000000000054ull)
181#define CVMX_PCI_PKT_CREDITS2 \
182 (0x0000000000000064ull)
183#define CVMX_PCI_PKT_CREDITS3 \
184 (0x0000000000000074ull)
185#define CVMX_PCI_PKT_CREDITSX(offset) \
186 (0x0000000000000044ull + (((offset) & 3) * 16))
187#define CVMX_PCI_READ_CMD_6 \
188 (0x0000000000000180ull)
189#define CVMX_PCI_READ_CMD_C \
190 (0x0000000000000184ull)
191#define CVMX_PCI_READ_CMD_E \
192 (0x0000000000000188ull)
193#define CVMX_PCI_READ_TIMEOUT \
194 CVMX_ADD_IO_SEG(0x00011F00000000B0ull)
195#define CVMX_PCI_SCM_REG \
196 (0x00000000000001A8ull)
197#define CVMX_PCI_TSR_REG \
198 (0x00000000000001B0ull)
199#define CVMX_PCI_WIN_RD_ADDR \
200 (0x0000000000000008ull)
201#define CVMX_PCI_WIN_RD_DATA \
202 (0x0000000000000020ull)
203#define CVMX_PCI_WIN_WR_ADDR \
204 (0x0000000000000000ull)
205#define CVMX_PCI_WIN_WR_DATA \
206 (0x0000000000000010ull)
207#define CVMX_PCI_WIN_WR_MASK \
208 (0x0000000000000018ull)
209 116
210union cvmx_pci_bar1_indexx { 117union cvmx_pci_bar1_indexx {
211 uint32_t u32; 118 uint32_t u32;
diff --git a/arch/mips/include/asm/octeon/cvmx-pciercx-defs.h b/arch/mips/include/asm/octeon/cvmx-pciercx-defs.h
index 75574c918942..f8cb88902efb 100644
--- a/arch/mips/include/asm/octeon/cvmx-pciercx-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-pciercx-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,158 +28,83 @@
28#ifndef __CVMX_PCIERCX_DEFS_H__ 28#ifndef __CVMX_PCIERCX_DEFS_H__
29#define __CVMX_PCIERCX_DEFS_H__ 29#define __CVMX_PCIERCX_DEFS_H__
30 30
31#define CVMX_PCIERCX_CFG000(offset) \ 31#define CVMX_PCIERCX_CFG000(block_id) (0x0000000000000000ull)
32 (0x0000000000000000ull + (((offset) & 1) * 0)) 32#define CVMX_PCIERCX_CFG001(block_id) (0x0000000000000004ull)
33#define CVMX_PCIERCX_CFG001(offset) \ 33#define CVMX_PCIERCX_CFG002(block_id) (0x0000000000000008ull)
34 (0x0000000000000004ull + (((offset) & 1) * 0)) 34#define CVMX_PCIERCX_CFG003(block_id) (0x000000000000000Cull)
35#define CVMX_PCIERCX_CFG002(offset) \ 35#define CVMX_PCIERCX_CFG004(block_id) (0x0000000000000010ull)
36 (0x0000000000000008ull + (((offset) & 1) * 0)) 36#define CVMX_PCIERCX_CFG005(block_id) (0x0000000000000014ull)
37#define CVMX_PCIERCX_CFG003(offset) \ 37#define CVMX_PCIERCX_CFG006(block_id) (0x0000000000000018ull)
38 (0x000000000000000Cull + (((offset) & 1) * 0)) 38#define CVMX_PCIERCX_CFG007(block_id) (0x000000000000001Cull)
39#define CVMX_PCIERCX_CFG004(offset) \ 39#define CVMX_PCIERCX_CFG008(block_id) (0x0000000000000020ull)
40 (0x0000000000000010ull + (((offset) & 1) * 0)) 40#define CVMX_PCIERCX_CFG009(block_id) (0x0000000000000024ull)
41#define CVMX_PCIERCX_CFG005(offset) \ 41#define CVMX_PCIERCX_CFG010(block_id) (0x0000000000000028ull)
42 (0x0000000000000014ull + (((offset) & 1) * 0)) 42#define CVMX_PCIERCX_CFG011(block_id) (0x000000000000002Cull)
43#define CVMX_PCIERCX_CFG006(offset) \ 43#define CVMX_PCIERCX_CFG012(block_id) (0x0000000000000030ull)
44 (0x0000000000000018ull + (((offset) & 1) * 0)) 44#define CVMX_PCIERCX_CFG013(block_id) (0x0000000000000034ull)
45#define CVMX_PCIERCX_CFG007(offset) \ 45#define CVMX_PCIERCX_CFG014(block_id) (0x0000000000000038ull)
46 (0x000000000000001Cull + (((offset) & 1) * 0)) 46#define CVMX_PCIERCX_CFG015(block_id) (0x000000000000003Cull)
47#define CVMX_PCIERCX_CFG008(offset) \ 47#define CVMX_PCIERCX_CFG016(block_id) (0x0000000000000040ull)
48 (0x0000000000000020ull + (((offset) & 1) * 0)) 48#define CVMX_PCIERCX_CFG017(block_id) (0x0000000000000044ull)
49#define CVMX_PCIERCX_CFG009(offset) \ 49#define CVMX_PCIERCX_CFG020(block_id) (0x0000000000000050ull)
50 (0x0000000000000024ull + (((offset) & 1) * 0)) 50#define CVMX_PCIERCX_CFG021(block_id) (0x0000000000000054ull)
51#define CVMX_PCIERCX_CFG010(offset) \ 51#define CVMX_PCIERCX_CFG022(block_id) (0x0000000000000058ull)
52 (0x0000000000000028ull + (((offset) & 1) * 0)) 52#define CVMX_PCIERCX_CFG023(block_id) (0x000000000000005Cull)
53#define CVMX_PCIERCX_CFG011(offset) \ 53#define CVMX_PCIERCX_CFG028(block_id) (0x0000000000000070ull)
54 (0x000000000000002Cull + (((offset) & 1) * 0)) 54#define CVMX_PCIERCX_CFG029(block_id) (0x0000000000000074ull)
55#define CVMX_PCIERCX_CFG012(offset) \ 55#define CVMX_PCIERCX_CFG030(block_id) (0x0000000000000078ull)
56 (0x0000000000000030ull + (((offset) & 1) * 0)) 56#define CVMX_PCIERCX_CFG031(block_id) (0x000000000000007Cull)
57#define CVMX_PCIERCX_CFG013(offset) \ 57#define CVMX_PCIERCX_CFG032(block_id) (0x0000000000000080ull)
58 (0x0000000000000034ull + (((offset) & 1) * 0)) 58#define CVMX_PCIERCX_CFG033(block_id) (0x0000000000000084ull)
59#define CVMX_PCIERCX_CFG014(offset) \ 59#define CVMX_PCIERCX_CFG034(block_id) (0x0000000000000088ull)
60 (0x0000000000000038ull + (((offset) & 1) * 0)) 60#define CVMX_PCIERCX_CFG035(block_id) (0x000000000000008Cull)
61#define CVMX_PCIERCX_CFG015(offset) \ 61#define CVMX_PCIERCX_CFG036(block_id) (0x0000000000000090ull)
62 (0x000000000000003Cull + (((offset) & 1) * 0)) 62#define CVMX_PCIERCX_CFG037(block_id) (0x0000000000000094ull)
63#define CVMX_PCIERCX_CFG016(offset) \ 63#define CVMX_PCIERCX_CFG038(block_id) (0x0000000000000098ull)
64 (0x0000000000000040ull + (((offset) & 1) * 0)) 64#define CVMX_PCIERCX_CFG039(block_id) (0x000000000000009Cull)
65#define CVMX_PCIERCX_CFG017(offset) \ 65#define CVMX_PCIERCX_CFG040(block_id) (0x00000000000000A0ull)
66 (0x0000000000000044ull + (((offset) & 1) * 0)) 66#define CVMX_PCIERCX_CFG041(block_id) (0x00000000000000A4ull)
67#define CVMX_PCIERCX_CFG020(offset) \ 67#define CVMX_PCIERCX_CFG042(block_id) (0x00000000000000A8ull)
68 (0x0000000000000050ull + (((offset) & 1) * 0)) 68#define CVMX_PCIERCX_CFG064(block_id) (0x0000000000000100ull)
69#define CVMX_PCIERCX_CFG021(offset) \ 69#define CVMX_PCIERCX_CFG065(block_id) (0x0000000000000104ull)
70 (0x0000000000000054ull + (((offset) & 1) * 0)) 70#define CVMX_PCIERCX_CFG066(block_id) (0x0000000000000108ull)
71#define CVMX_PCIERCX_CFG022(offset) \ 71#define CVMX_PCIERCX_CFG067(block_id) (0x000000000000010Cull)
72 (0x0000000000000058ull + (((offset) & 1) * 0)) 72#define CVMX_PCIERCX_CFG068(block_id) (0x0000000000000110ull)
73#define CVMX_PCIERCX_CFG023(offset) \ 73#define CVMX_PCIERCX_CFG069(block_id) (0x0000000000000114ull)
74 (0x000000000000005Cull + (((offset) & 1) * 0)) 74#define CVMX_PCIERCX_CFG070(block_id) (0x0000000000000118ull)
75#define CVMX_PCIERCX_CFG028(offset) \ 75#define CVMX_PCIERCX_CFG071(block_id) (0x000000000000011Cull)
76 (0x0000000000000070ull + (((offset) & 1) * 0)) 76#define CVMX_PCIERCX_CFG072(block_id) (0x0000000000000120ull)
77#define CVMX_PCIERCX_CFG029(offset) \ 77#define CVMX_PCIERCX_CFG073(block_id) (0x0000000000000124ull)
78 (0x0000000000000074ull + (((offset) & 1) * 0)) 78#define CVMX_PCIERCX_CFG074(block_id) (0x0000000000000128ull)
79#define CVMX_PCIERCX_CFG030(offset) \ 79#define CVMX_PCIERCX_CFG075(block_id) (0x000000000000012Cull)
80 (0x0000000000000078ull + (((offset) & 1) * 0)) 80#define CVMX_PCIERCX_CFG076(block_id) (0x0000000000000130ull)
81#define CVMX_PCIERCX_CFG031(offset) \ 81#define CVMX_PCIERCX_CFG077(block_id) (0x0000000000000134ull)
82 (0x000000000000007Cull + (((offset) & 1) * 0)) 82#define CVMX_PCIERCX_CFG448(block_id) (0x0000000000000700ull)
83#define CVMX_PCIERCX_CFG032(offset) \ 83#define CVMX_PCIERCX_CFG449(block_id) (0x0000000000000704ull)
84 (0x0000000000000080ull + (((offset) & 1) * 0)) 84#define CVMX_PCIERCX_CFG450(block_id) (0x0000000000000708ull)
85#define CVMX_PCIERCX_CFG033(offset) \ 85#define CVMX_PCIERCX_CFG451(block_id) (0x000000000000070Cull)
86 (0x0000000000000084ull + (((offset) & 1) * 0)) 86#define CVMX_PCIERCX_CFG452(block_id) (0x0000000000000710ull)
87#define CVMX_PCIERCX_CFG034(offset) \ 87#define CVMX_PCIERCX_CFG453(block_id) (0x0000000000000714ull)
88 (0x0000000000000088ull + (((offset) & 1) * 0)) 88#define CVMX_PCIERCX_CFG454(block_id) (0x0000000000000718ull)
89#define CVMX_PCIERCX_CFG035(offset) \ 89#define CVMX_PCIERCX_CFG455(block_id) (0x000000000000071Cull)
90 (0x000000000000008Cull + (((offset) & 1) * 0)) 90#define CVMX_PCIERCX_CFG456(block_id) (0x0000000000000720ull)
91#define CVMX_PCIERCX_CFG036(offset) \ 91#define CVMX_PCIERCX_CFG458(block_id) (0x0000000000000728ull)
92 (0x0000000000000090ull + (((offset) & 1) * 0)) 92#define CVMX_PCIERCX_CFG459(block_id) (0x000000000000072Cull)
93#define CVMX_PCIERCX_CFG037(offset) \ 93#define CVMX_PCIERCX_CFG460(block_id) (0x0000000000000730ull)
94 (0x0000000000000094ull + (((offset) & 1) * 0)) 94#define CVMX_PCIERCX_CFG461(block_id) (0x0000000000000734ull)
95#define CVMX_PCIERCX_CFG038(offset) \ 95#define CVMX_PCIERCX_CFG462(block_id) (0x0000000000000738ull)
96 (0x0000000000000098ull + (((offset) & 1) * 0)) 96#define CVMX_PCIERCX_CFG463(block_id) (0x000000000000073Cull)
97#define CVMX_PCIERCX_CFG039(offset) \ 97#define CVMX_PCIERCX_CFG464(block_id) (0x0000000000000740ull)
98 (0x000000000000009Cull + (((offset) & 1) * 0)) 98#define CVMX_PCIERCX_CFG465(block_id) (0x0000000000000744ull)
99#define CVMX_PCIERCX_CFG040(offset) \ 99#define CVMX_PCIERCX_CFG466(block_id) (0x0000000000000748ull)
100 (0x00000000000000A0ull + (((offset) & 1) * 0)) 100#define CVMX_PCIERCX_CFG467(block_id) (0x000000000000074Cull)
101#define CVMX_PCIERCX_CFG041(offset) \ 101#define CVMX_PCIERCX_CFG468(block_id) (0x0000000000000750ull)
102 (0x00000000000000A4ull + (((offset) & 1) * 0)) 102#define CVMX_PCIERCX_CFG490(block_id) (0x00000000000007A8ull)
103#define CVMX_PCIERCX_CFG042(offset) \ 103#define CVMX_PCIERCX_CFG491(block_id) (0x00000000000007ACull)
104 (0x00000000000000A8ull + (((offset) & 1) * 0)) 104#define CVMX_PCIERCX_CFG492(block_id) (0x00000000000007B0ull)
105#define CVMX_PCIERCX_CFG064(offset) \ 105#define CVMX_PCIERCX_CFG515(block_id) (0x000000000000080Cull)
106 (0x0000000000000100ull + (((offset) & 1) * 0)) 106#define CVMX_PCIERCX_CFG516(block_id) (0x0000000000000810ull)
107#define CVMX_PCIERCX_CFG065(offset) \ 107#define CVMX_PCIERCX_CFG517(block_id) (0x0000000000000814ull)
108 (0x0000000000000104ull + (((offset) & 1) * 0))
109#define CVMX_PCIERCX_CFG066(offset) \
110 (0x0000000000000108ull + (((offset) & 1) * 0))
111#define CVMX_PCIERCX_CFG067(offset) \
112 (0x000000000000010Cull + (((offset) & 1) * 0))
113#define CVMX_PCIERCX_CFG068(offset) \
114 (0x0000000000000110ull + (((offset) & 1) * 0))
115#define CVMX_PCIERCX_CFG069(offset) \
116 (0x0000000000000114ull + (((offset) & 1) * 0))
117#define CVMX_PCIERCX_CFG070(offset) \
118 (0x0000000000000118ull + (((offset) & 1) * 0))
119#define CVMX_PCIERCX_CFG071(offset) \
120 (0x000000000000011Cull + (((offset) & 1) * 0))
121#define CVMX_PCIERCX_CFG072(offset) \
122 (0x0000000000000120ull + (((offset) & 1) * 0))
123#define CVMX_PCIERCX_CFG073(offset) \
124 (0x0000000000000124ull + (((offset) & 1) * 0))
125#define CVMX_PCIERCX_CFG074(offset) \
126 (0x0000000000000128ull + (((offset) & 1) * 0))
127#define CVMX_PCIERCX_CFG075(offset) \
128 (0x000000000000012Cull + (((offset) & 1) * 0))
129#define CVMX_PCIERCX_CFG076(offset) \
130 (0x0000000000000130ull + (((offset) & 1) * 0))
131#define CVMX_PCIERCX_CFG077(offset) \
132 (0x0000000000000134ull + (((offset) & 1) * 0))
133#define CVMX_PCIERCX_CFG448(offset) \
134 (0x0000000000000700ull + (((offset) & 1) * 0))
135#define CVMX_PCIERCX_CFG449(offset) \
136 (0x0000000000000704ull + (((offset) & 1) * 0))
137#define CVMX_PCIERCX_CFG450(offset) \
138 (0x0000000000000708ull + (((offset) & 1) * 0))
139#define CVMX_PCIERCX_CFG451(offset) \
140 (0x000000000000070Cull + (((offset) & 1) * 0))
141#define CVMX_PCIERCX_CFG452(offset) \
142 (0x0000000000000710ull + (((offset) & 1) * 0))
143#define CVMX_PCIERCX_CFG453(offset) \
144 (0x0000000000000714ull + (((offset) & 1) * 0))
145#define CVMX_PCIERCX_CFG454(offset) \
146 (0x0000000000000718ull + (((offset) & 1) * 0))
147#define CVMX_PCIERCX_CFG455(offset) \
148 (0x000000000000071Cull + (((offset) & 1) * 0))
149#define CVMX_PCIERCX_CFG456(offset) \
150 (0x0000000000000720ull + (((offset) & 1) * 0))
151#define CVMX_PCIERCX_CFG458(offset) \
152 (0x0000000000000728ull + (((offset) & 1) * 0))
153#define CVMX_PCIERCX_CFG459(offset) \
154 (0x000000000000072Cull + (((offset) & 1) * 0))
155#define CVMX_PCIERCX_CFG460(offset) \
156 (0x0000000000000730ull + (((offset) & 1) * 0))
157#define CVMX_PCIERCX_CFG461(offset) \
158 (0x0000000000000734ull + (((offset) & 1) * 0))
159#define CVMX_PCIERCX_CFG462(offset) \
160 (0x0000000000000738ull + (((offset) & 1) * 0))
161#define CVMX_PCIERCX_CFG463(offset) \
162 (0x000000000000073Cull + (((offset) & 1) * 0))
163#define CVMX_PCIERCX_CFG464(offset) \
164 (0x0000000000000740ull + (((offset) & 1) * 0))
165#define CVMX_PCIERCX_CFG465(offset) \
166 (0x0000000000000744ull + (((offset) & 1) * 0))
167#define CVMX_PCIERCX_CFG466(offset) \
168 (0x0000000000000748ull + (((offset) & 1) * 0))
169#define CVMX_PCIERCX_CFG467(offset) \
170 (0x000000000000074Cull + (((offset) & 1) * 0))
171#define CVMX_PCIERCX_CFG468(offset) \
172 (0x0000000000000750ull + (((offset) & 1) * 0))
173#define CVMX_PCIERCX_CFG490(offset) \
174 (0x00000000000007A8ull + (((offset) & 1) * 0))
175#define CVMX_PCIERCX_CFG491(offset) \
176 (0x00000000000007ACull + (((offset) & 1) * 0))
177#define CVMX_PCIERCX_CFG492(offset) \
178 (0x00000000000007B0ull + (((offset) & 1) * 0))
179#define CVMX_PCIERCX_CFG516(offset) \
180 (0x0000000000000810ull + (((offset) & 1) * 0))
181#define CVMX_PCIERCX_CFG517(offset) \
182 (0x0000000000000814ull + (((offset) & 1) * 0))
183 108
184union cvmx_pciercx_cfg000 { 109union cvmx_pciercx_cfg000 {
185 uint32_t u32; 110 uint32_t u32;
@@ -191,6 +116,8 @@ union cvmx_pciercx_cfg000 {
191 struct cvmx_pciercx_cfg000_s cn52xxp1; 116 struct cvmx_pciercx_cfg000_s cn52xxp1;
192 struct cvmx_pciercx_cfg000_s cn56xx; 117 struct cvmx_pciercx_cfg000_s cn56xx;
193 struct cvmx_pciercx_cfg000_s cn56xxp1; 118 struct cvmx_pciercx_cfg000_s cn56xxp1;
119 struct cvmx_pciercx_cfg000_s cn63xx;
120 struct cvmx_pciercx_cfg000_s cn63xxp1;
194}; 121};
195 122
196union cvmx_pciercx_cfg001 { 123union cvmx_pciercx_cfg001 {
@@ -225,6 +152,8 @@ union cvmx_pciercx_cfg001 {
225 struct cvmx_pciercx_cfg001_s cn52xxp1; 152 struct cvmx_pciercx_cfg001_s cn52xxp1;
226 struct cvmx_pciercx_cfg001_s cn56xx; 153 struct cvmx_pciercx_cfg001_s cn56xx;
227 struct cvmx_pciercx_cfg001_s cn56xxp1; 154 struct cvmx_pciercx_cfg001_s cn56xxp1;
155 struct cvmx_pciercx_cfg001_s cn63xx;
156 struct cvmx_pciercx_cfg001_s cn63xxp1;
228}; 157};
229 158
230union cvmx_pciercx_cfg002 { 159union cvmx_pciercx_cfg002 {
@@ -239,6 +168,8 @@ union cvmx_pciercx_cfg002 {
239 struct cvmx_pciercx_cfg002_s cn52xxp1; 168 struct cvmx_pciercx_cfg002_s cn52xxp1;
240 struct cvmx_pciercx_cfg002_s cn56xx; 169 struct cvmx_pciercx_cfg002_s cn56xx;
241 struct cvmx_pciercx_cfg002_s cn56xxp1; 170 struct cvmx_pciercx_cfg002_s cn56xxp1;
171 struct cvmx_pciercx_cfg002_s cn63xx;
172 struct cvmx_pciercx_cfg002_s cn63xxp1;
242}; 173};
243 174
244union cvmx_pciercx_cfg003 { 175union cvmx_pciercx_cfg003 {
@@ -254,6 +185,8 @@ union cvmx_pciercx_cfg003 {
254 struct cvmx_pciercx_cfg003_s cn52xxp1; 185 struct cvmx_pciercx_cfg003_s cn52xxp1;
255 struct cvmx_pciercx_cfg003_s cn56xx; 186 struct cvmx_pciercx_cfg003_s cn56xx;
256 struct cvmx_pciercx_cfg003_s cn56xxp1; 187 struct cvmx_pciercx_cfg003_s cn56xxp1;
188 struct cvmx_pciercx_cfg003_s cn63xx;
189 struct cvmx_pciercx_cfg003_s cn63xxp1;
257}; 190};
258 191
259union cvmx_pciercx_cfg004 { 192union cvmx_pciercx_cfg004 {
@@ -265,6 +198,8 @@ union cvmx_pciercx_cfg004 {
265 struct cvmx_pciercx_cfg004_s cn52xxp1; 198 struct cvmx_pciercx_cfg004_s cn52xxp1;
266 struct cvmx_pciercx_cfg004_s cn56xx; 199 struct cvmx_pciercx_cfg004_s cn56xx;
267 struct cvmx_pciercx_cfg004_s cn56xxp1; 200 struct cvmx_pciercx_cfg004_s cn56xxp1;
201 struct cvmx_pciercx_cfg004_s cn63xx;
202 struct cvmx_pciercx_cfg004_s cn63xxp1;
268}; 203};
269 204
270union cvmx_pciercx_cfg005 { 205union cvmx_pciercx_cfg005 {
@@ -276,6 +211,8 @@ union cvmx_pciercx_cfg005 {
276 struct cvmx_pciercx_cfg005_s cn52xxp1; 211 struct cvmx_pciercx_cfg005_s cn52xxp1;
277 struct cvmx_pciercx_cfg005_s cn56xx; 212 struct cvmx_pciercx_cfg005_s cn56xx;
278 struct cvmx_pciercx_cfg005_s cn56xxp1; 213 struct cvmx_pciercx_cfg005_s cn56xxp1;
214 struct cvmx_pciercx_cfg005_s cn63xx;
215 struct cvmx_pciercx_cfg005_s cn63xxp1;
279}; 216};
280 217
281union cvmx_pciercx_cfg006 { 218union cvmx_pciercx_cfg006 {
@@ -290,6 +227,8 @@ union cvmx_pciercx_cfg006 {
290 struct cvmx_pciercx_cfg006_s cn52xxp1; 227 struct cvmx_pciercx_cfg006_s cn52xxp1;
291 struct cvmx_pciercx_cfg006_s cn56xx; 228 struct cvmx_pciercx_cfg006_s cn56xx;
292 struct cvmx_pciercx_cfg006_s cn56xxp1; 229 struct cvmx_pciercx_cfg006_s cn56xxp1;
230 struct cvmx_pciercx_cfg006_s cn63xx;
231 struct cvmx_pciercx_cfg006_s cn63xxp1;
293}; 232};
294 233
295union cvmx_pciercx_cfg007 { 234union cvmx_pciercx_cfg007 {
@@ -317,6 +256,8 @@ union cvmx_pciercx_cfg007 {
317 struct cvmx_pciercx_cfg007_s cn52xxp1; 256 struct cvmx_pciercx_cfg007_s cn52xxp1;
318 struct cvmx_pciercx_cfg007_s cn56xx; 257 struct cvmx_pciercx_cfg007_s cn56xx;
319 struct cvmx_pciercx_cfg007_s cn56xxp1; 258 struct cvmx_pciercx_cfg007_s cn56xxp1;
259 struct cvmx_pciercx_cfg007_s cn63xx;
260 struct cvmx_pciercx_cfg007_s cn63xxp1;
320}; 261};
321 262
322union cvmx_pciercx_cfg008 { 263union cvmx_pciercx_cfg008 {
@@ -331,6 +272,8 @@ union cvmx_pciercx_cfg008 {
331 struct cvmx_pciercx_cfg008_s cn52xxp1; 272 struct cvmx_pciercx_cfg008_s cn52xxp1;
332 struct cvmx_pciercx_cfg008_s cn56xx; 273 struct cvmx_pciercx_cfg008_s cn56xx;
333 struct cvmx_pciercx_cfg008_s cn56xxp1; 274 struct cvmx_pciercx_cfg008_s cn56xxp1;
275 struct cvmx_pciercx_cfg008_s cn63xx;
276 struct cvmx_pciercx_cfg008_s cn63xxp1;
334}; 277};
335 278
336union cvmx_pciercx_cfg009 { 279union cvmx_pciercx_cfg009 {
@@ -347,6 +290,8 @@ union cvmx_pciercx_cfg009 {
347 struct cvmx_pciercx_cfg009_s cn52xxp1; 290 struct cvmx_pciercx_cfg009_s cn52xxp1;
348 struct cvmx_pciercx_cfg009_s cn56xx; 291 struct cvmx_pciercx_cfg009_s cn56xx;
349 struct cvmx_pciercx_cfg009_s cn56xxp1; 292 struct cvmx_pciercx_cfg009_s cn56xxp1;
293 struct cvmx_pciercx_cfg009_s cn63xx;
294 struct cvmx_pciercx_cfg009_s cn63xxp1;
350}; 295};
351 296
352union cvmx_pciercx_cfg010 { 297union cvmx_pciercx_cfg010 {
@@ -358,6 +303,8 @@ union cvmx_pciercx_cfg010 {
358 struct cvmx_pciercx_cfg010_s cn52xxp1; 303 struct cvmx_pciercx_cfg010_s cn52xxp1;
359 struct cvmx_pciercx_cfg010_s cn56xx; 304 struct cvmx_pciercx_cfg010_s cn56xx;
360 struct cvmx_pciercx_cfg010_s cn56xxp1; 305 struct cvmx_pciercx_cfg010_s cn56xxp1;
306 struct cvmx_pciercx_cfg010_s cn63xx;
307 struct cvmx_pciercx_cfg010_s cn63xxp1;
361}; 308};
362 309
363union cvmx_pciercx_cfg011 { 310union cvmx_pciercx_cfg011 {
@@ -369,6 +316,8 @@ union cvmx_pciercx_cfg011 {
369 struct cvmx_pciercx_cfg011_s cn52xxp1; 316 struct cvmx_pciercx_cfg011_s cn52xxp1;
370 struct cvmx_pciercx_cfg011_s cn56xx; 317 struct cvmx_pciercx_cfg011_s cn56xx;
371 struct cvmx_pciercx_cfg011_s cn56xxp1; 318 struct cvmx_pciercx_cfg011_s cn56xxp1;
319 struct cvmx_pciercx_cfg011_s cn63xx;
320 struct cvmx_pciercx_cfg011_s cn63xxp1;
372}; 321};
373 322
374union cvmx_pciercx_cfg012 { 323union cvmx_pciercx_cfg012 {
@@ -381,6 +330,8 @@ union cvmx_pciercx_cfg012 {
381 struct cvmx_pciercx_cfg012_s cn52xxp1; 330 struct cvmx_pciercx_cfg012_s cn52xxp1;
382 struct cvmx_pciercx_cfg012_s cn56xx; 331 struct cvmx_pciercx_cfg012_s cn56xx;
383 struct cvmx_pciercx_cfg012_s cn56xxp1; 332 struct cvmx_pciercx_cfg012_s cn56xxp1;
333 struct cvmx_pciercx_cfg012_s cn63xx;
334 struct cvmx_pciercx_cfg012_s cn63xxp1;
384}; 335};
385 336
386union cvmx_pciercx_cfg013 { 337union cvmx_pciercx_cfg013 {
@@ -393,6 +344,8 @@ union cvmx_pciercx_cfg013 {
393 struct cvmx_pciercx_cfg013_s cn52xxp1; 344 struct cvmx_pciercx_cfg013_s cn52xxp1;
394 struct cvmx_pciercx_cfg013_s cn56xx; 345 struct cvmx_pciercx_cfg013_s cn56xx;
395 struct cvmx_pciercx_cfg013_s cn56xxp1; 346 struct cvmx_pciercx_cfg013_s cn56xxp1;
347 struct cvmx_pciercx_cfg013_s cn63xx;
348 struct cvmx_pciercx_cfg013_s cn63xxp1;
396}; 349};
397 350
398union cvmx_pciercx_cfg014 { 351union cvmx_pciercx_cfg014 {
@@ -404,6 +357,8 @@ union cvmx_pciercx_cfg014 {
404 struct cvmx_pciercx_cfg014_s cn52xxp1; 357 struct cvmx_pciercx_cfg014_s cn52xxp1;
405 struct cvmx_pciercx_cfg014_s cn56xx; 358 struct cvmx_pciercx_cfg014_s cn56xx;
406 struct cvmx_pciercx_cfg014_s cn56xxp1; 359 struct cvmx_pciercx_cfg014_s cn56xxp1;
360 struct cvmx_pciercx_cfg014_s cn63xx;
361 struct cvmx_pciercx_cfg014_s cn63xxp1;
407}; 362};
408 363
409union cvmx_pciercx_cfg015 { 364union cvmx_pciercx_cfg015 {
@@ -429,6 +384,8 @@ union cvmx_pciercx_cfg015 {
429 struct cvmx_pciercx_cfg015_s cn52xxp1; 384 struct cvmx_pciercx_cfg015_s cn52xxp1;
430 struct cvmx_pciercx_cfg015_s cn56xx; 385 struct cvmx_pciercx_cfg015_s cn56xx;
431 struct cvmx_pciercx_cfg015_s cn56xxp1; 386 struct cvmx_pciercx_cfg015_s cn56xxp1;
387 struct cvmx_pciercx_cfg015_s cn63xx;
388 struct cvmx_pciercx_cfg015_s cn63xxp1;
432}; 389};
433 390
434union cvmx_pciercx_cfg016 { 391union cvmx_pciercx_cfg016 {
@@ -449,6 +406,8 @@ union cvmx_pciercx_cfg016 {
449 struct cvmx_pciercx_cfg016_s cn52xxp1; 406 struct cvmx_pciercx_cfg016_s cn52xxp1;
450 struct cvmx_pciercx_cfg016_s cn56xx; 407 struct cvmx_pciercx_cfg016_s cn56xx;
451 struct cvmx_pciercx_cfg016_s cn56xxp1; 408 struct cvmx_pciercx_cfg016_s cn56xxp1;
409 struct cvmx_pciercx_cfg016_s cn63xx;
410 struct cvmx_pciercx_cfg016_s cn63xxp1;
452}; 411};
453 412
454union cvmx_pciercx_cfg017 { 413union cvmx_pciercx_cfg017 {
@@ -471,6 +430,8 @@ union cvmx_pciercx_cfg017 {
471 struct cvmx_pciercx_cfg017_s cn52xxp1; 430 struct cvmx_pciercx_cfg017_s cn52xxp1;
472 struct cvmx_pciercx_cfg017_s cn56xx; 431 struct cvmx_pciercx_cfg017_s cn56xx;
473 struct cvmx_pciercx_cfg017_s cn56xxp1; 432 struct cvmx_pciercx_cfg017_s cn56xxp1;
433 struct cvmx_pciercx_cfg017_s cn63xx;
434 struct cvmx_pciercx_cfg017_s cn63xxp1;
474}; 435};
475 436
476union cvmx_pciercx_cfg020 { 437union cvmx_pciercx_cfg020 {
@@ -488,6 +449,8 @@ union cvmx_pciercx_cfg020 {
488 struct cvmx_pciercx_cfg020_s cn52xxp1; 449 struct cvmx_pciercx_cfg020_s cn52xxp1;
489 struct cvmx_pciercx_cfg020_s cn56xx; 450 struct cvmx_pciercx_cfg020_s cn56xx;
490 struct cvmx_pciercx_cfg020_s cn56xxp1; 451 struct cvmx_pciercx_cfg020_s cn56xxp1;
452 struct cvmx_pciercx_cfg020_s cn63xx;
453 struct cvmx_pciercx_cfg020_s cn63xxp1;
491}; 454};
492 455
493union cvmx_pciercx_cfg021 { 456union cvmx_pciercx_cfg021 {
@@ -500,6 +463,8 @@ union cvmx_pciercx_cfg021 {
500 struct cvmx_pciercx_cfg021_s cn52xxp1; 463 struct cvmx_pciercx_cfg021_s cn52xxp1;
501 struct cvmx_pciercx_cfg021_s cn56xx; 464 struct cvmx_pciercx_cfg021_s cn56xx;
502 struct cvmx_pciercx_cfg021_s cn56xxp1; 465 struct cvmx_pciercx_cfg021_s cn56xxp1;
466 struct cvmx_pciercx_cfg021_s cn63xx;
467 struct cvmx_pciercx_cfg021_s cn63xxp1;
503}; 468};
504 469
505union cvmx_pciercx_cfg022 { 470union cvmx_pciercx_cfg022 {
@@ -511,6 +476,8 @@ union cvmx_pciercx_cfg022 {
511 struct cvmx_pciercx_cfg022_s cn52xxp1; 476 struct cvmx_pciercx_cfg022_s cn52xxp1;
512 struct cvmx_pciercx_cfg022_s cn56xx; 477 struct cvmx_pciercx_cfg022_s cn56xx;
513 struct cvmx_pciercx_cfg022_s cn56xxp1; 478 struct cvmx_pciercx_cfg022_s cn56xxp1;
479 struct cvmx_pciercx_cfg022_s cn63xx;
480 struct cvmx_pciercx_cfg022_s cn63xxp1;
514}; 481};
515 482
516union cvmx_pciercx_cfg023 { 483union cvmx_pciercx_cfg023 {
@@ -523,6 +490,8 @@ union cvmx_pciercx_cfg023 {
523 struct cvmx_pciercx_cfg023_s cn52xxp1; 490 struct cvmx_pciercx_cfg023_s cn52xxp1;
524 struct cvmx_pciercx_cfg023_s cn56xx; 491 struct cvmx_pciercx_cfg023_s cn56xx;
525 struct cvmx_pciercx_cfg023_s cn56xxp1; 492 struct cvmx_pciercx_cfg023_s cn56xxp1;
493 struct cvmx_pciercx_cfg023_s cn63xx;
494 struct cvmx_pciercx_cfg023_s cn63xxp1;
526}; 495};
527 496
528union cvmx_pciercx_cfg028 { 497union cvmx_pciercx_cfg028 {
@@ -540,6 +509,8 @@ union cvmx_pciercx_cfg028 {
540 struct cvmx_pciercx_cfg028_s cn52xxp1; 509 struct cvmx_pciercx_cfg028_s cn52xxp1;
541 struct cvmx_pciercx_cfg028_s cn56xx; 510 struct cvmx_pciercx_cfg028_s cn56xx;
542 struct cvmx_pciercx_cfg028_s cn56xxp1; 511 struct cvmx_pciercx_cfg028_s cn56xxp1;
512 struct cvmx_pciercx_cfg028_s cn63xx;
513 struct cvmx_pciercx_cfg028_s cn63xxp1;
543}; 514};
544 515
545union cvmx_pciercx_cfg029 { 516union cvmx_pciercx_cfg029 {
@@ -561,6 +532,8 @@ union cvmx_pciercx_cfg029 {
561 struct cvmx_pciercx_cfg029_s cn52xxp1; 532 struct cvmx_pciercx_cfg029_s cn52xxp1;
562 struct cvmx_pciercx_cfg029_s cn56xx; 533 struct cvmx_pciercx_cfg029_s cn56xx;
563 struct cvmx_pciercx_cfg029_s cn56xxp1; 534 struct cvmx_pciercx_cfg029_s cn56xxp1;
535 struct cvmx_pciercx_cfg029_s cn63xx;
536 struct cvmx_pciercx_cfg029_s cn63xxp1;
564}; 537};
565 538
566union cvmx_pciercx_cfg030 { 539union cvmx_pciercx_cfg030 {
@@ -590,6 +563,8 @@ union cvmx_pciercx_cfg030 {
590 struct cvmx_pciercx_cfg030_s cn52xxp1; 563 struct cvmx_pciercx_cfg030_s cn52xxp1;
591 struct cvmx_pciercx_cfg030_s cn56xx; 564 struct cvmx_pciercx_cfg030_s cn56xx;
592 struct cvmx_pciercx_cfg030_s cn56xxp1; 565 struct cvmx_pciercx_cfg030_s cn56xxp1;
566 struct cvmx_pciercx_cfg030_s cn63xx;
567 struct cvmx_pciercx_cfg030_s cn63xxp1;
593}; 568};
594 569
595union cvmx_pciercx_cfg031 { 570union cvmx_pciercx_cfg031 {
@@ -611,6 +586,8 @@ union cvmx_pciercx_cfg031 {
611 struct cvmx_pciercx_cfg031_s cn52xxp1; 586 struct cvmx_pciercx_cfg031_s cn52xxp1;
612 struct cvmx_pciercx_cfg031_s cn56xx; 587 struct cvmx_pciercx_cfg031_s cn56xx;
613 struct cvmx_pciercx_cfg031_s cn56xxp1; 588 struct cvmx_pciercx_cfg031_s cn56xxp1;
589 struct cvmx_pciercx_cfg031_s cn63xx;
590 struct cvmx_pciercx_cfg031_s cn63xxp1;
614}; 591};
615 592
616union cvmx_pciercx_cfg032 { 593union cvmx_pciercx_cfg032 {
@@ -641,6 +618,8 @@ union cvmx_pciercx_cfg032 {
641 struct cvmx_pciercx_cfg032_s cn52xxp1; 618 struct cvmx_pciercx_cfg032_s cn52xxp1;
642 struct cvmx_pciercx_cfg032_s cn56xx; 619 struct cvmx_pciercx_cfg032_s cn56xx;
643 struct cvmx_pciercx_cfg032_s cn56xxp1; 620 struct cvmx_pciercx_cfg032_s cn56xxp1;
621 struct cvmx_pciercx_cfg032_s cn63xx;
622 struct cvmx_pciercx_cfg032_s cn63xxp1;
644}; 623};
645 624
646union cvmx_pciercx_cfg033 { 625union cvmx_pciercx_cfg033 {
@@ -663,6 +642,8 @@ union cvmx_pciercx_cfg033 {
663 struct cvmx_pciercx_cfg033_s cn52xxp1; 642 struct cvmx_pciercx_cfg033_s cn52xxp1;
664 struct cvmx_pciercx_cfg033_s cn56xx; 643 struct cvmx_pciercx_cfg033_s cn56xx;
665 struct cvmx_pciercx_cfg033_s cn56xxp1; 644 struct cvmx_pciercx_cfg033_s cn56xxp1;
645 struct cvmx_pciercx_cfg033_s cn63xx;
646 struct cvmx_pciercx_cfg033_s cn63xxp1;
666}; 647};
667 648
668union cvmx_pciercx_cfg034 { 649union cvmx_pciercx_cfg034 {
@@ -695,6 +676,8 @@ union cvmx_pciercx_cfg034 {
695 struct cvmx_pciercx_cfg034_s cn52xxp1; 676 struct cvmx_pciercx_cfg034_s cn52xxp1;
696 struct cvmx_pciercx_cfg034_s cn56xx; 677 struct cvmx_pciercx_cfg034_s cn56xx;
697 struct cvmx_pciercx_cfg034_s cn56xxp1; 678 struct cvmx_pciercx_cfg034_s cn56xxp1;
679 struct cvmx_pciercx_cfg034_s cn63xx;
680 struct cvmx_pciercx_cfg034_s cn63xxp1;
698}; 681};
699 682
700union cvmx_pciercx_cfg035 { 683union cvmx_pciercx_cfg035 {
@@ -713,6 +696,8 @@ union cvmx_pciercx_cfg035 {
713 struct cvmx_pciercx_cfg035_s cn52xxp1; 696 struct cvmx_pciercx_cfg035_s cn52xxp1;
714 struct cvmx_pciercx_cfg035_s cn56xx; 697 struct cvmx_pciercx_cfg035_s cn56xx;
715 struct cvmx_pciercx_cfg035_s cn56xxp1; 698 struct cvmx_pciercx_cfg035_s cn56xxp1;
699 struct cvmx_pciercx_cfg035_s cn63xx;
700 struct cvmx_pciercx_cfg035_s cn63xxp1;
716}; 701};
717 702
718union cvmx_pciercx_cfg036 { 703union cvmx_pciercx_cfg036 {
@@ -727,6 +712,8 @@ union cvmx_pciercx_cfg036 {
727 struct cvmx_pciercx_cfg036_s cn52xxp1; 712 struct cvmx_pciercx_cfg036_s cn52xxp1;
728 struct cvmx_pciercx_cfg036_s cn56xx; 713 struct cvmx_pciercx_cfg036_s cn56xx;
729 struct cvmx_pciercx_cfg036_s cn56xxp1; 714 struct cvmx_pciercx_cfg036_s cn56xxp1;
715 struct cvmx_pciercx_cfg036_s cn63xx;
716 struct cvmx_pciercx_cfg036_s cn63xxp1;
730}; 717};
731 718
732union cvmx_pciercx_cfg037 { 719union cvmx_pciercx_cfg037 {
@@ -740,6 +727,8 @@ union cvmx_pciercx_cfg037 {
740 struct cvmx_pciercx_cfg037_s cn52xxp1; 727 struct cvmx_pciercx_cfg037_s cn52xxp1;
741 struct cvmx_pciercx_cfg037_s cn56xx; 728 struct cvmx_pciercx_cfg037_s cn56xx;
742 struct cvmx_pciercx_cfg037_s cn56xxp1; 729 struct cvmx_pciercx_cfg037_s cn56xxp1;
730 struct cvmx_pciercx_cfg037_s cn63xx;
731 struct cvmx_pciercx_cfg037_s cn63xxp1;
743}; 732};
744 733
745union cvmx_pciercx_cfg038 { 734union cvmx_pciercx_cfg038 {
@@ -753,28 +742,51 @@ union cvmx_pciercx_cfg038 {
753 struct cvmx_pciercx_cfg038_s cn52xxp1; 742 struct cvmx_pciercx_cfg038_s cn52xxp1;
754 struct cvmx_pciercx_cfg038_s cn56xx; 743 struct cvmx_pciercx_cfg038_s cn56xx;
755 struct cvmx_pciercx_cfg038_s cn56xxp1; 744 struct cvmx_pciercx_cfg038_s cn56xxp1;
745 struct cvmx_pciercx_cfg038_s cn63xx;
746 struct cvmx_pciercx_cfg038_s cn63xxp1;
756}; 747};
757 748
758union cvmx_pciercx_cfg039 { 749union cvmx_pciercx_cfg039 {
759 uint32_t u32; 750 uint32_t u32;
760 struct cvmx_pciercx_cfg039_s { 751 struct cvmx_pciercx_cfg039_s {
761 uint32_t reserved_0_31:32; 752 uint32_t reserved_9_31:23;
753 uint32_t cls:1;
754 uint32_t slsv:7;
755 uint32_t reserved_0_0:1;
762 } s; 756 } s;
763 struct cvmx_pciercx_cfg039_s cn52xx; 757 struct cvmx_pciercx_cfg039_cn52xx {
764 struct cvmx_pciercx_cfg039_s cn52xxp1; 758 uint32_t reserved_0_31:32;
765 struct cvmx_pciercx_cfg039_s cn56xx; 759 } cn52xx;
766 struct cvmx_pciercx_cfg039_s cn56xxp1; 760 struct cvmx_pciercx_cfg039_cn52xx cn52xxp1;
761 struct cvmx_pciercx_cfg039_cn52xx cn56xx;
762 struct cvmx_pciercx_cfg039_cn52xx cn56xxp1;
763 struct cvmx_pciercx_cfg039_s cn63xx;
764 struct cvmx_pciercx_cfg039_cn52xx cn63xxp1;
767}; 765};
768 766
769union cvmx_pciercx_cfg040 { 767union cvmx_pciercx_cfg040 {
770 uint32_t u32; 768 uint32_t u32;
771 struct cvmx_pciercx_cfg040_s { 769 struct cvmx_pciercx_cfg040_s {
770 uint32_t reserved_17_31:15;
771 uint32_t cdl:1;
772 uint32_t reserved_13_15:3;
773 uint32_t cde:1;
774 uint32_t csos:1;
775 uint32_t emc:1;
776 uint32_t tm:3;
777 uint32_t sde:1;
778 uint32_t hasd:1;
779 uint32_t ec:1;
780 uint32_t tls:4;
781 } s;
782 struct cvmx_pciercx_cfg040_cn52xx {
772 uint32_t reserved_0_31:32; 783 uint32_t reserved_0_31:32;
773 } s; 784 } cn52xx;
774 struct cvmx_pciercx_cfg040_s cn52xx; 785 struct cvmx_pciercx_cfg040_cn52xx cn52xxp1;
775 struct cvmx_pciercx_cfg040_s cn52xxp1; 786 struct cvmx_pciercx_cfg040_cn52xx cn56xx;
776 struct cvmx_pciercx_cfg040_s cn56xx; 787 struct cvmx_pciercx_cfg040_cn52xx cn56xxp1;
777 struct cvmx_pciercx_cfg040_s cn56xxp1; 788 struct cvmx_pciercx_cfg040_s cn63xx;
789 struct cvmx_pciercx_cfg040_s cn63xxp1;
778}; 790};
779 791
780union cvmx_pciercx_cfg041 { 792union cvmx_pciercx_cfg041 {
@@ -786,6 +798,8 @@ union cvmx_pciercx_cfg041 {
786 struct cvmx_pciercx_cfg041_s cn52xxp1; 798 struct cvmx_pciercx_cfg041_s cn52xxp1;
787 struct cvmx_pciercx_cfg041_s cn56xx; 799 struct cvmx_pciercx_cfg041_s cn56xx;
788 struct cvmx_pciercx_cfg041_s cn56xxp1; 800 struct cvmx_pciercx_cfg041_s cn56xxp1;
801 struct cvmx_pciercx_cfg041_s cn63xx;
802 struct cvmx_pciercx_cfg041_s cn63xxp1;
789}; 803};
790 804
791union cvmx_pciercx_cfg042 { 805union cvmx_pciercx_cfg042 {
@@ -797,6 +811,8 @@ union cvmx_pciercx_cfg042 {
797 struct cvmx_pciercx_cfg042_s cn52xxp1; 811 struct cvmx_pciercx_cfg042_s cn52xxp1;
798 struct cvmx_pciercx_cfg042_s cn56xx; 812 struct cvmx_pciercx_cfg042_s cn56xx;
799 struct cvmx_pciercx_cfg042_s cn56xxp1; 813 struct cvmx_pciercx_cfg042_s cn56xxp1;
814 struct cvmx_pciercx_cfg042_s cn63xx;
815 struct cvmx_pciercx_cfg042_s cn63xxp1;
800}; 816};
801 817
802union cvmx_pciercx_cfg064 { 818union cvmx_pciercx_cfg064 {
@@ -810,6 +826,8 @@ union cvmx_pciercx_cfg064 {
810 struct cvmx_pciercx_cfg064_s cn52xxp1; 826 struct cvmx_pciercx_cfg064_s cn52xxp1;
811 struct cvmx_pciercx_cfg064_s cn56xx; 827 struct cvmx_pciercx_cfg064_s cn56xx;
812 struct cvmx_pciercx_cfg064_s cn56xxp1; 828 struct cvmx_pciercx_cfg064_s cn56xxp1;
829 struct cvmx_pciercx_cfg064_s cn63xx;
830 struct cvmx_pciercx_cfg064_s cn63xxp1;
813}; 831};
814 832
815union cvmx_pciercx_cfg065 { 833union cvmx_pciercx_cfg065 {
@@ -834,6 +852,8 @@ union cvmx_pciercx_cfg065 {
834 struct cvmx_pciercx_cfg065_s cn52xxp1; 852 struct cvmx_pciercx_cfg065_s cn52xxp1;
835 struct cvmx_pciercx_cfg065_s cn56xx; 853 struct cvmx_pciercx_cfg065_s cn56xx;
836 struct cvmx_pciercx_cfg065_s cn56xxp1; 854 struct cvmx_pciercx_cfg065_s cn56xxp1;
855 struct cvmx_pciercx_cfg065_s cn63xx;
856 struct cvmx_pciercx_cfg065_s cn63xxp1;
837}; 857};
838 858
839union cvmx_pciercx_cfg066 { 859union cvmx_pciercx_cfg066 {
@@ -858,6 +878,8 @@ union cvmx_pciercx_cfg066 {
858 struct cvmx_pciercx_cfg066_s cn52xxp1; 878 struct cvmx_pciercx_cfg066_s cn52xxp1;
859 struct cvmx_pciercx_cfg066_s cn56xx; 879 struct cvmx_pciercx_cfg066_s cn56xx;
860 struct cvmx_pciercx_cfg066_s cn56xxp1; 880 struct cvmx_pciercx_cfg066_s cn56xxp1;
881 struct cvmx_pciercx_cfg066_s cn63xx;
882 struct cvmx_pciercx_cfg066_s cn63xxp1;
861}; 883};
862 884
863union cvmx_pciercx_cfg067 { 885union cvmx_pciercx_cfg067 {
@@ -882,6 +904,8 @@ union cvmx_pciercx_cfg067 {
882 struct cvmx_pciercx_cfg067_s cn52xxp1; 904 struct cvmx_pciercx_cfg067_s cn52xxp1;
883 struct cvmx_pciercx_cfg067_s cn56xx; 905 struct cvmx_pciercx_cfg067_s cn56xx;
884 struct cvmx_pciercx_cfg067_s cn56xxp1; 906 struct cvmx_pciercx_cfg067_s cn56xxp1;
907 struct cvmx_pciercx_cfg067_s cn63xx;
908 struct cvmx_pciercx_cfg067_s cn63xxp1;
885}; 909};
886 910
887union cvmx_pciercx_cfg068 { 911union cvmx_pciercx_cfg068 {
@@ -901,6 +925,8 @@ union cvmx_pciercx_cfg068 {
901 struct cvmx_pciercx_cfg068_s cn52xxp1; 925 struct cvmx_pciercx_cfg068_s cn52xxp1;
902 struct cvmx_pciercx_cfg068_s cn56xx; 926 struct cvmx_pciercx_cfg068_s cn56xx;
903 struct cvmx_pciercx_cfg068_s cn56xxp1; 927 struct cvmx_pciercx_cfg068_s cn56xxp1;
928 struct cvmx_pciercx_cfg068_s cn63xx;
929 struct cvmx_pciercx_cfg068_s cn63xxp1;
904}; 930};
905 931
906union cvmx_pciercx_cfg069 { 932union cvmx_pciercx_cfg069 {
@@ -920,6 +946,8 @@ union cvmx_pciercx_cfg069 {
920 struct cvmx_pciercx_cfg069_s cn52xxp1; 946 struct cvmx_pciercx_cfg069_s cn52xxp1;
921 struct cvmx_pciercx_cfg069_s cn56xx; 947 struct cvmx_pciercx_cfg069_s cn56xx;
922 struct cvmx_pciercx_cfg069_s cn56xxp1; 948 struct cvmx_pciercx_cfg069_s cn56xxp1;
949 struct cvmx_pciercx_cfg069_s cn63xx;
950 struct cvmx_pciercx_cfg069_s cn63xxp1;
923}; 951};
924 952
925union cvmx_pciercx_cfg070 { 953union cvmx_pciercx_cfg070 {
@@ -936,6 +964,8 @@ union cvmx_pciercx_cfg070 {
936 struct cvmx_pciercx_cfg070_s cn52xxp1; 964 struct cvmx_pciercx_cfg070_s cn52xxp1;
937 struct cvmx_pciercx_cfg070_s cn56xx; 965 struct cvmx_pciercx_cfg070_s cn56xx;
938 struct cvmx_pciercx_cfg070_s cn56xxp1; 966 struct cvmx_pciercx_cfg070_s cn56xxp1;
967 struct cvmx_pciercx_cfg070_s cn63xx;
968 struct cvmx_pciercx_cfg070_s cn63xxp1;
939}; 969};
940 970
941union cvmx_pciercx_cfg071 { 971union cvmx_pciercx_cfg071 {
@@ -947,6 +977,8 @@ union cvmx_pciercx_cfg071 {
947 struct cvmx_pciercx_cfg071_s cn52xxp1; 977 struct cvmx_pciercx_cfg071_s cn52xxp1;
948 struct cvmx_pciercx_cfg071_s cn56xx; 978 struct cvmx_pciercx_cfg071_s cn56xx;
949 struct cvmx_pciercx_cfg071_s cn56xxp1; 979 struct cvmx_pciercx_cfg071_s cn56xxp1;
980 struct cvmx_pciercx_cfg071_s cn63xx;
981 struct cvmx_pciercx_cfg071_s cn63xxp1;
950}; 982};
951 983
952union cvmx_pciercx_cfg072 { 984union cvmx_pciercx_cfg072 {
@@ -958,6 +990,8 @@ union cvmx_pciercx_cfg072 {
958 struct cvmx_pciercx_cfg072_s cn52xxp1; 990 struct cvmx_pciercx_cfg072_s cn52xxp1;
959 struct cvmx_pciercx_cfg072_s cn56xx; 991 struct cvmx_pciercx_cfg072_s cn56xx;
960 struct cvmx_pciercx_cfg072_s cn56xxp1; 992 struct cvmx_pciercx_cfg072_s cn56xxp1;
993 struct cvmx_pciercx_cfg072_s cn63xx;
994 struct cvmx_pciercx_cfg072_s cn63xxp1;
961}; 995};
962 996
963union cvmx_pciercx_cfg073 { 997union cvmx_pciercx_cfg073 {
@@ -969,6 +1003,8 @@ union cvmx_pciercx_cfg073 {
969 struct cvmx_pciercx_cfg073_s cn52xxp1; 1003 struct cvmx_pciercx_cfg073_s cn52xxp1;
970 struct cvmx_pciercx_cfg073_s cn56xx; 1004 struct cvmx_pciercx_cfg073_s cn56xx;
971 struct cvmx_pciercx_cfg073_s cn56xxp1; 1005 struct cvmx_pciercx_cfg073_s cn56xxp1;
1006 struct cvmx_pciercx_cfg073_s cn63xx;
1007 struct cvmx_pciercx_cfg073_s cn63xxp1;
972}; 1008};
973 1009
974union cvmx_pciercx_cfg074 { 1010union cvmx_pciercx_cfg074 {
@@ -980,6 +1016,8 @@ union cvmx_pciercx_cfg074 {
980 struct cvmx_pciercx_cfg074_s cn52xxp1; 1016 struct cvmx_pciercx_cfg074_s cn52xxp1;
981 struct cvmx_pciercx_cfg074_s cn56xx; 1017 struct cvmx_pciercx_cfg074_s cn56xx;
982 struct cvmx_pciercx_cfg074_s cn56xxp1; 1018 struct cvmx_pciercx_cfg074_s cn56xxp1;
1019 struct cvmx_pciercx_cfg074_s cn63xx;
1020 struct cvmx_pciercx_cfg074_s cn63xxp1;
983}; 1021};
984 1022
985union cvmx_pciercx_cfg075 { 1023union cvmx_pciercx_cfg075 {
@@ -994,6 +1032,8 @@ union cvmx_pciercx_cfg075 {
994 struct cvmx_pciercx_cfg075_s cn52xxp1; 1032 struct cvmx_pciercx_cfg075_s cn52xxp1;
995 struct cvmx_pciercx_cfg075_s cn56xx; 1033 struct cvmx_pciercx_cfg075_s cn56xx;
996 struct cvmx_pciercx_cfg075_s cn56xxp1; 1034 struct cvmx_pciercx_cfg075_s cn56xxp1;
1035 struct cvmx_pciercx_cfg075_s cn63xx;
1036 struct cvmx_pciercx_cfg075_s cn63xxp1;
997}; 1037};
998 1038
999union cvmx_pciercx_cfg076 { 1039union cvmx_pciercx_cfg076 {
@@ -1013,6 +1053,8 @@ union cvmx_pciercx_cfg076 {
1013 struct cvmx_pciercx_cfg076_s cn52xxp1; 1053 struct cvmx_pciercx_cfg076_s cn52xxp1;
1014 struct cvmx_pciercx_cfg076_s cn56xx; 1054 struct cvmx_pciercx_cfg076_s cn56xx;
1015 struct cvmx_pciercx_cfg076_s cn56xxp1; 1055 struct cvmx_pciercx_cfg076_s cn56xxp1;
1056 struct cvmx_pciercx_cfg076_s cn63xx;
1057 struct cvmx_pciercx_cfg076_s cn63xxp1;
1016}; 1058};
1017 1059
1018union cvmx_pciercx_cfg077 { 1060union cvmx_pciercx_cfg077 {
@@ -1025,6 +1067,8 @@ union cvmx_pciercx_cfg077 {
1025 struct cvmx_pciercx_cfg077_s cn52xxp1; 1067 struct cvmx_pciercx_cfg077_s cn52xxp1;
1026 struct cvmx_pciercx_cfg077_s cn56xx; 1068 struct cvmx_pciercx_cfg077_s cn56xx;
1027 struct cvmx_pciercx_cfg077_s cn56xxp1; 1069 struct cvmx_pciercx_cfg077_s cn56xxp1;
1070 struct cvmx_pciercx_cfg077_s cn63xx;
1071 struct cvmx_pciercx_cfg077_s cn63xxp1;
1028}; 1072};
1029 1073
1030union cvmx_pciercx_cfg448 { 1074union cvmx_pciercx_cfg448 {
@@ -1037,6 +1081,8 @@ union cvmx_pciercx_cfg448 {
1037 struct cvmx_pciercx_cfg448_s cn52xxp1; 1081 struct cvmx_pciercx_cfg448_s cn52xxp1;
1038 struct cvmx_pciercx_cfg448_s cn56xx; 1082 struct cvmx_pciercx_cfg448_s cn56xx;
1039 struct cvmx_pciercx_cfg448_s cn56xxp1; 1083 struct cvmx_pciercx_cfg448_s cn56xxp1;
1084 struct cvmx_pciercx_cfg448_s cn63xx;
1085 struct cvmx_pciercx_cfg448_s cn63xxp1;
1040}; 1086};
1041 1087
1042union cvmx_pciercx_cfg449 { 1088union cvmx_pciercx_cfg449 {
@@ -1048,6 +1094,8 @@ union cvmx_pciercx_cfg449 {
1048 struct cvmx_pciercx_cfg449_s cn52xxp1; 1094 struct cvmx_pciercx_cfg449_s cn52xxp1;
1049 struct cvmx_pciercx_cfg449_s cn56xx; 1095 struct cvmx_pciercx_cfg449_s cn56xx;
1050 struct cvmx_pciercx_cfg449_s cn56xxp1; 1096 struct cvmx_pciercx_cfg449_s cn56xxp1;
1097 struct cvmx_pciercx_cfg449_s cn63xx;
1098 struct cvmx_pciercx_cfg449_s cn63xxp1;
1051}; 1099};
1052 1100
1053union cvmx_pciercx_cfg450 { 1101union cvmx_pciercx_cfg450 {
@@ -1064,6 +1112,8 @@ union cvmx_pciercx_cfg450 {
1064 struct cvmx_pciercx_cfg450_s cn52xxp1; 1112 struct cvmx_pciercx_cfg450_s cn52xxp1;
1065 struct cvmx_pciercx_cfg450_s cn56xx; 1113 struct cvmx_pciercx_cfg450_s cn56xx;
1066 struct cvmx_pciercx_cfg450_s cn56xxp1; 1114 struct cvmx_pciercx_cfg450_s cn56xxp1;
1115 struct cvmx_pciercx_cfg450_s cn63xx;
1116 struct cvmx_pciercx_cfg450_s cn63xxp1;
1067}; 1117};
1068 1118
1069union cvmx_pciercx_cfg451 { 1119union cvmx_pciercx_cfg451 {
@@ -1080,6 +1130,8 @@ union cvmx_pciercx_cfg451 {
1080 struct cvmx_pciercx_cfg451_s cn52xxp1; 1130 struct cvmx_pciercx_cfg451_s cn52xxp1;
1081 struct cvmx_pciercx_cfg451_s cn56xx; 1131 struct cvmx_pciercx_cfg451_s cn56xx;
1082 struct cvmx_pciercx_cfg451_s cn56xxp1; 1132 struct cvmx_pciercx_cfg451_s cn56xxp1;
1133 struct cvmx_pciercx_cfg451_s cn63xx;
1134 struct cvmx_pciercx_cfg451_s cn63xxp1;
1083}; 1135};
1084 1136
1085union cvmx_pciercx_cfg452 { 1137union cvmx_pciercx_cfg452 {
@@ -1103,6 +1155,8 @@ union cvmx_pciercx_cfg452 {
1103 struct cvmx_pciercx_cfg452_s cn52xxp1; 1155 struct cvmx_pciercx_cfg452_s cn52xxp1;
1104 struct cvmx_pciercx_cfg452_s cn56xx; 1156 struct cvmx_pciercx_cfg452_s cn56xx;
1105 struct cvmx_pciercx_cfg452_s cn56xxp1; 1157 struct cvmx_pciercx_cfg452_s cn56xxp1;
1158 struct cvmx_pciercx_cfg452_s cn63xx;
1159 struct cvmx_pciercx_cfg452_s cn63xxp1;
1106}; 1160};
1107 1161
1108union cvmx_pciercx_cfg453 { 1162union cvmx_pciercx_cfg453 {
@@ -1118,6 +1172,8 @@ union cvmx_pciercx_cfg453 {
1118 struct cvmx_pciercx_cfg453_s cn52xxp1; 1172 struct cvmx_pciercx_cfg453_s cn52xxp1;
1119 struct cvmx_pciercx_cfg453_s cn56xx; 1173 struct cvmx_pciercx_cfg453_s cn56xx;
1120 struct cvmx_pciercx_cfg453_s cn56xxp1; 1174 struct cvmx_pciercx_cfg453_s cn56xxp1;
1175 struct cvmx_pciercx_cfg453_s cn63xx;
1176 struct cvmx_pciercx_cfg453_s cn63xxp1;
1121}; 1177};
1122 1178
1123union cvmx_pciercx_cfg454 { 1179union cvmx_pciercx_cfg454 {
@@ -1136,6 +1192,8 @@ union cvmx_pciercx_cfg454 {
1136 struct cvmx_pciercx_cfg454_s cn52xxp1; 1192 struct cvmx_pciercx_cfg454_s cn52xxp1;
1137 struct cvmx_pciercx_cfg454_s cn56xx; 1193 struct cvmx_pciercx_cfg454_s cn56xx;
1138 struct cvmx_pciercx_cfg454_s cn56xxp1; 1194 struct cvmx_pciercx_cfg454_s cn56xxp1;
1195 struct cvmx_pciercx_cfg454_s cn63xx;
1196 struct cvmx_pciercx_cfg454_s cn63xxp1;
1139}; 1197};
1140 1198
1141union cvmx_pciercx_cfg455 { 1199union cvmx_pciercx_cfg455 {
@@ -1165,6 +1223,8 @@ union cvmx_pciercx_cfg455 {
1165 struct cvmx_pciercx_cfg455_s cn52xxp1; 1223 struct cvmx_pciercx_cfg455_s cn52xxp1;
1166 struct cvmx_pciercx_cfg455_s cn56xx; 1224 struct cvmx_pciercx_cfg455_s cn56xx;
1167 struct cvmx_pciercx_cfg455_s cn56xxp1; 1225 struct cvmx_pciercx_cfg455_s cn56xxp1;
1226 struct cvmx_pciercx_cfg455_s cn63xx;
1227 struct cvmx_pciercx_cfg455_s cn63xxp1;
1168}; 1228};
1169 1229
1170union cvmx_pciercx_cfg456 { 1230union cvmx_pciercx_cfg456 {
@@ -1178,6 +1238,8 @@ union cvmx_pciercx_cfg456 {
1178 struct cvmx_pciercx_cfg456_s cn52xxp1; 1238 struct cvmx_pciercx_cfg456_s cn52xxp1;
1179 struct cvmx_pciercx_cfg456_s cn56xx; 1239 struct cvmx_pciercx_cfg456_s cn56xx;
1180 struct cvmx_pciercx_cfg456_s cn56xxp1; 1240 struct cvmx_pciercx_cfg456_s cn56xxp1;
1241 struct cvmx_pciercx_cfg456_s cn63xx;
1242 struct cvmx_pciercx_cfg456_s cn63xxp1;
1181}; 1243};
1182 1244
1183union cvmx_pciercx_cfg458 { 1245union cvmx_pciercx_cfg458 {
@@ -1189,6 +1251,8 @@ union cvmx_pciercx_cfg458 {
1189 struct cvmx_pciercx_cfg458_s cn52xxp1; 1251 struct cvmx_pciercx_cfg458_s cn52xxp1;
1190 struct cvmx_pciercx_cfg458_s cn56xx; 1252 struct cvmx_pciercx_cfg458_s cn56xx;
1191 struct cvmx_pciercx_cfg458_s cn56xxp1; 1253 struct cvmx_pciercx_cfg458_s cn56xxp1;
1254 struct cvmx_pciercx_cfg458_s cn63xx;
1255 struct cvmx_pciercx_cfg458_s cn63xxp1;
1192}; 1256};
1193 1257
1194union cvmx_pciercx_cfg459 { 1258union cvmx_pciercx_cfg459 {
@@ -1200,6 +1264,8 @@ union cvmx_pciercx_cfg459 {
1200 struct cvmx_pciercx_cfg459_s cn52xxp1; 1264 struct cvmx_pciercx_cfg459_s cn52xxp1;
1201 struct cvmx_pciercx_cfg459_s cn56xx; 1265 struct cvmx_pciercx_cfg459_s cn56xx;
1202 struct cvmx_pciercx_cfg459_s cn56xxp1; 1266 struct cvmx_pciercx_cfg459_s cn56xxp1;
1267 struct cvmx_pciercx_cfg459_s cn63xx;
1268 struct cvmx_pciercx_cfg459_s cn63xxp1;
1203}; 1269};
1204 1270
1205union cvmx_pciercx_cfg460 { 1271union cvmx_pciercx_cfg460 {
@@ -1213,6 +1279,8 @@ union cvmx_pciercx_cfg460 {
1213 struct cvmx_pciercx_cfg460_s cn52xxp1; 1279 struct cvmx_pciercx_cfg460_s cn52xxp1;
1214 struct cvmx_pciercx_cfg460_s cn56xx; 1280 struct cvmx_pciercx_cfg460_s cn56xx;
1215 struct cvmx_pciercx_cfg460_s cn56xxp1; 1281 struct cvmx_pciercx_cfg460_s cn56xxp1;
1282 struct cvmx_pciercx_cfg460_s cn63xx;
1283 struct cvmx_pciercx_cfg460_s cn63xxp1;
1216}; 1284};
1217 1285
1218union cvmx_pciercx_cfg461 { 1286union cvmx_pciercx_cfg461 {
@@ -1226,6 +1294,8 @@ union cvmx_pciercx_cfg461 {
1226 struct cvmx_pciercx_cfg461_s cn52xxp1; 1294 struct cvmx_pciercx_cfg461_s cn52xxp1;
1227 struct cvmx_pciercx_cfg461_s cn56xx; 1295 struct cvmx_pciercx_cfg461_s cn56xx;
1228 struct cvmx_pciercx_cfg461_s cn56xxp1; 1296 struct cvmx_pciercx_cfg461_s cn56xxp1;
1297 struct cvmx_pciercx_cfg461_s cn63xx;
1298 struct cvmx_pciercx_cfg461_s cn63xxp1;
1229}; 1299};
1230 1300
1231union cvmx_pciercx_cfg462 { 1301union cvmx_pciercx_cfg462 {
@@ -1239,6 +1309,8 @@ union cvmx_pciercx_cfg462 {
1239 struct cvmx_pciercx_cfg462_s cn52xxp1; 1309 struct cvmx_pciercx_cfg462_s cn52xxp1;
1240 struct cvmx_pciercx_cfg462_s cn56xx; 1310 struct cvmx_pciercx_cfg462_s cn56xx;
1241 struct cvmx_pciercx_cfg462_s cn56xxp1; 1311 struct cvmx_pciercx_cfg462_s cn56xxp1;
1312 struct cvmx_pciercx_cfg462_s cn63xx;
1313 struct cvmx_pciercx_cfg462_s cn63xxp1;
1242}; 1314};
1243 1315
1244union cvmx_pciercx_cfg463 { 1316union cvmx_pciercx_cfg463 {
@@ -1253,6 +1325,8 @@ union cvmx_pciercx_cfg463 {
1253 struct cvmx_pciercx_cfg463_s cn52xxp1; 1325 struct cvmx_pciercx_cfg463_s cn52xxp1;
1254 struct cvmx_pciercx_cfg463_s cn56xx; 1326 struct cvmx_pciercx_cfg463_s cn56xx;
1255 struct cvmx_pciercx_cfg463_s cn56xxp1; 1327 struct cvmx_pciercx_cfg463_s cn56xxp1;
1328 struct cvmx_pciercx_cfg463_s cn63xx;
1329 struct cvmx_pciercx_cfg463_s cn63xxp1;
1256}; 1330};
1257 1331
1258union cvmx_pciercx_cfg464 { 1332union cvmx_pciercx_cfg464 {
@@ -1267,6 +1341,8 @@ union cvmx_pciercx_cfg464 {
1267 struct cvmx_pciercx_cfg464_s cn52xxp1; 1341 struct cvmx_pciercx_cfg464_s cn52xxp1;
1268 struct cvmx_pciercx_cfg464_s cn56xx; 1342 struct cvmx_pciercx_cfg464_s cn56xx;
1269 struct cvmx_pciercx_cfg464_s cn56xxp1; 1343 struct cvmx_pciercx_cfg464_s cn56xxp1;
1344 struct cvmx_pciercx_cfg464_s cn63xx;
1345 struct cvmx_pciercx_cfg464_s cn63xxp1;
1270}; 1346};
1271 1347
1272union cvmx_pciercx_cfg465 { 1348union cvmx_pciercx_cfg465 {
@@ -1281,6 +1357,8 @@ union cvmx_pciercx_cfg465 {
1281 struct cvmx_pciercx_cfg465_s cn52xxp1; 1357 struct cvmx_pciercx_cfg465_s cn52xxp1;
1282 struct cvmx_pciercx_cfg465_s cn56xx; 1358 struct cvmx_pciercx_cfg465_s cn56xx;
1283 struct cvmx_pciercx_cfg465_s cn56xxp1; 1359 struct cvmx_pciercx_cfg465_s cn56xxp1;
1360 struct cvmx_pciercx_cfg465_s cn63xx;
1361 struct cvmx_pciercx_cfg465_s cn63xxp1;
1284}; 1362};
1285 1363
1286union cvmx_pciercx_cfg466 { 1364union cvmx_pciercx_cfg466 {
@@ -1298,6 +1376,8 @@ union cvmx_pciercx_cfg466 {
1298 struct cvmx_pciercx_cfg466_s cn52xxp1; 1376 struct cvmx_pciercx_cfg466_s cn52xxp1;
1299 struct cvmx_pciercx_cfg466_s cn56xx; 1377 struct cvmx_pciercx_cfg466_s cn56xx;
1300 struct cvmx_pciercx_cfg466_s cn56xxp1; 1378 struct cvmx_pciercx_cfg466_s cn56xxp1;
1379 struct cvmx_pciercx_cfg466_s cn63xx;
1380 struct cvmx_pciercx_cfg466_s cn63xxp1;
1301}; 1381};
1302 1382
1303union cvmx_pciercx_cfg467 { 1383union cvmx_pciercx_cfg467 {
@@ -1313,6 +1393,8 @@ union cvmx_pciercx_cfg467 {
1313 struct cvmx_pciercx_cfg467_s cn52xxp1; 1393 struct cvmx_pciercx_cfg467_s cn52xxp1;
1314 struct cvmx_pciercx_cfg467_s cn56xx; 1394 struct cvmx_pciercx_cfg467_s cn56xx;
1315 struct cvmx_pciercx_cfg467_s cn56xxp1; 1395 struct cvmx_pciercx_cfg467_s cn56xxp1;
1396 struct cvmx_pciercx_cfg467_s cn63xx;
1397 struct cvmx_pciercx_cfg467_s cn63xxp1;
1316}; 1398};
1317 1399
1318union cvmx_pciercx_cfg468 { 1400union cvmx_pciercx_cfg468 {
@@ -1328,6 +1410,8 @@ union cvmx_pciercx_cfg468 {
1328 struct cvmx_pciercx_cfg468_s cn52xxp1; 1410 struct cvmx_pciercx_cfg468_s cn52xxp1;
1329 struct cvmx_pciercx_cfg468_s cn56xx; 1411 struct cvmx_pciercx_cfg468_s cn56xx;
1330 struct cvmx_pciercx_cfg468_s cn56xxp1; 1412 struct cvmx_pciercx_cfg468_s cn56xxp1;
1413 struct cvmx_pciercx_cfg468_s cn63xx;
1414 struct cvmx_pciercx_cfg468_s cn63xxp1;
1331}; 1415};
1332 1416
1333union cvmx_pciercx_cfg490 { 1417union cvmx_pciercx_cfg490 {
@@ -1342,6 +1426,8 @@ union cvmx_pciercx_cfg490 {
1342 struct cvmx_pciercx_cfg490_s cn52xxp1; 1426 struct cvmx_pciercx_cfg490_s cn52xxp1;
1343 struct cvmx_pciercx_cfg490_s cn56xx; 1427 struct cvmx_pciercx_cfg490_s cn56xx;
1344 struct cvmx_pciercx_cfg490_s cn56xxp1; 1428 struct cvmx_pciercx_cfg490_s cn56xxp1;
1429 struct cvmx_pciercx_cfg490_s cn63xx;
1430 struct cvmx_pciercx_cfg490_s cn63xxp1;
1345}; 1431};
1346 1432
1347union cvmx_pciercx_cfg491 { 1433union cvmx_pciercx_cfg491 {
@@ -1356,6 +1442,8 @@ union cvmx_pciercx_cfg491 {
1356 struct cvmx_pciercx_cfg491_s cn52xxp1; 1442 struct cvmx_pciercx_cfg491_s cn52xxp1;
1357 struct cvmx_pciercx_cfg491_s cn56xx; 1443 struct cvmx_pciercx_cfg491_s cn56xx;
1358 struct cvmx_pciercx_cfg491_s cn56xxp1; 1444 struct cvmx_pciercx_cfg491_s cn56xxp1;
1445 struct cvmx_pciercx_cfg491_s cn63xx;
1446 struct cvmx_pciercx_cfg491_s cn63xxp1;
1359}; 1447};
1360 1448
1361union cvmx_pciercx_cfg492 { 1449union cvmx_pciercx_cfg492 {
@@ -1370,6 +1458,23 @@ union cvmx_pciercx_cfg492 {
1370 struct cvmx_pciercx_cfg492_s cn52xxp1; 1458 struct cvmx_pciercx_cfg492_s cn52xxp1;
1371 struct cvmx_pciercx_cfg492_s cn56xx; 1459 struct cvmx_pciercx_cfg492_s cn56xx;
1372 struct cvmx_pciercx_cfg492_s cn56xxp1; 1460 struct cvmx_pciercx_cfg492_s cn56xxp1;
1461 struct cvmx_pciercx_cfg492_s cn63xx;
1462 struct cvmx_pciercx_cfg492_s cn63xxp1;
1463};
1464
1465union cvmx_pciercx_cfg515 {
1466 uint32_t u32;
1467 struct cvmx_pciercx_cfg515_s {
1468 uint32_t reserved_21_31:11;
1469 uint32_t s_d_e:1;
1470 uint32_t ctcrb:1;
1471 uint32_t cpyts:1;
1472 uint32_t dsc:1;
1473 uint32_t le:9;
1474 uint32_t n_fts:8;
1475 } s;
1476 struct cvmx_pciercx_cfg515_s cn63xx;
1477 struct cvmx_pciercx_cfg515_s cn63xxp1;
1373}; 1478};
1374 1479
1375union cvmx_pciercx_cfg516 { 1480union cvmx_pciercx_cfg516 {
@@ -1381,6 +1486,8 @@ union cvmx_pciercx_cfg516 {
1381 struct cvmx_pciercx_cfg516_s cn52xxp1; 1486 struct cvmx_pciercx_cfg516_s cn52xxp1;
1382 struct cvmx_pciercx_cfg516_s cn56xx; 1487 struct cvmx_pciercx_cfg516_s cn56xx;
1383 struct cvmx_pciercx_cfg516_s cn56xxp1; 1488 struct cvmx_pciercx_cfg516_s cn56xxp1;
1489 struct cvmx_pciercx_cfg516_s cn63xx;
1490 struct cvmx_pciercx_cfg516_s cn63xxp1;
1384}; 1491};
1385 1492
1386union cvmx_pciercx_cfg517 { 1493union cvmx_pciercx_cfg517 {
@@ -1392,6 +1499,8 @@ union cvmx_pciercx_cfg517 {
1392 struct cvmx_pciercx_cfg517_s cn52xxp1; 1499 struct cvmx_pciercx_cfg517_s cn52xxp1;
1393 struct cvmx_pciercx_cfg517_s cn56xx; 1500 struct cvmx_pciercx_cfg517_s cn56xx;
1394 struct cvmx_pciercx_cfg517_s cn56xxp1; 1501 struct cvmx_pciercx_cfg517_s cn56xxp1;
1502 struct cvmx_pciercx_cfg517_s cn63xx;
1503 struct cvmx_pciercx_cfg517_s cn63xxp1;
1395}; 1504};
1396 1505
1397#endif 1506#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-pescx-defs.h b/arch/mips/include/asm/octeon/cvmx-pescx-defs.h
index f40cfaf84454..aef84851a94c 100644
--- a/arch/mips/include/asm/octeon/cvmx-pescx-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-pescx-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,38 +28,22 @@
28#ifndef __CVMX_PESCX_DEFS_H__ 28#ifndef __CVMX_PESCX_DEFS_H__
29#define __CVMX_PESCX_DEFS_H__ 29#define __CVMX_PESCX_DEFS_H__
30 30
31#define CVMX_PESCX_BIST_STATUS(block_id) \ 31#define CVMX_PESCX_BIST_STATUS(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000018ull) + ((block_id) & 1) * 0x8000000ull)
32 CVMX_ADD_IO_SEG(0x00011800C8000018ull + (((block_id) & 1) * 0x8000000ull)) 32#define CVMX_PESCX_BIST_STATUS2(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000418ull) + ((block_id) & 1) * 0x8000000ull)
33#define CVMX_PESCX_BIST_STATUS2(block_id) \ 33#define CVMX_PESCX_CFG_RD(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000030ull) + ((block_id) & 1) * 0x8000000ull)
34 CVMX_ADD_IO_SEG(0x00011800C8000418ull + (((block_id) & 1) * 0x8000000ull)) 34#define CVMX_PESCX_CFG_WR(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000028ull) + ((block_id) & 1) * 0x8000000ull)
35#define CVMX_PESCX_CFG_RD(block_id) \ 35#define CVMX_PESCX_CPL_LUT_VALID(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000098ull) + ((block_id) & 1) * 0x8000000ull)
36 CVMX_ADD_IO_SEG(0x00011800C8000030ull + (((block_id) & 1) * 0x8000000ull)) 36#define CVMX_PESCX_CTL_STATUS(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000000ull) + ((block_id) & 1) * 0x8000000ull)
37#define CVMX_PESCX_CFG_WR(block_id) \ 37#define CVMX_PESCX_CTL_STATUS2(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000400ull) + ((block_id) & 1) * 0x8000000ull)
38 CVMX_ADD_IO_SEG(0x00011800C8000028ull + (((block_id) & 1) * 0x8000000ull)) 38#define CVMX_PESCX_DBG_INFO(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000008ull) + ((block_id) & 1) * 0x8000000ull)
39#define CVMX_PESCX_CPL_LUT_VALID(block_id) \ 39#define CVMX_PESCX_DBG_INFO_EN(block_id) (CVMX_ADD_IO_SEG(0x00011800C80000A0ull) + ((block_id) & 1) * 0x8000000ull)
40 CVMX_ADD_IO_SEG(0x00011800C8000098ull + (((block_id) & 1) * 0x8000000ull)) 40#define CVMX_PESCX_DIAG_STATUS(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000020ull) + ((block_id) & 1) * 0x8000000ull)
41#define CVMX_PESCX_CTL_STATUS(block_id) \ 41#define CVMX_PESCX_P2N_BAR0_START(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000080ull) + ((block_id) & 1) * 0x8000000ull)
42 CVMX_ADD_IO_SEG(0x00011800C8000000ull + (((block_id) & 1) * 0x8000000ull)) 42#define CVMX_PESCX_P2N_BAR1_START(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000088ull) + ((block_id) & 1) * 0x8000000ull)
43#define CVMX_PESCX_CTL_STATUS2(block_id) \ 43#define CVMX_PESCX_P2N_BAR2_START(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000090ull) + ((block_id) & 1) * 0x8000000ull)
44 CVMX_ADD_IO_SEG(0x00011800C8000400ull + (((block_id) & 1) * 0x8000000ull)) 44#define CVMX_PESCX_P2P_BARX_END(offset, block_id) (CVMX_ADD_IO_SEG(0x00011800C8000048ull) + (((offset) & 3) + ((block_id) & 1) * 0x800000ull) * 16)
45#define CVMX_PESCX_DBG_INFO(block_id) \ 45#define CVMX_PESCX_P2P_BARX_START(offset, block_id) (CVMX_ADD_IO_SEG(0x00011800C8000040ull) + (((offset) & 3) + ((block_id) & 1) * 0x800000ull) * 16)
46 CVMX_ADD_IO_SEG(0x00011800C8000008ull + (((block_id) & 1) * 0x8000000ull)) 46#define CVMX_PESCX_TLP_CREDITS(block_id) (CVMX_ADD_IO_SEG(0x00011800C8000038ull) + ((block_id) & 1) * 0x8000000ull)
47#define CVMX_PESCX_DBG_INFO_EN(block_id) \
48 CVMX_ADD_IO_SEG(0x00011800C80000A0ull + (((block_id) & 1) * 0x8000000ull))
49#define CVMX_PESCX_DIAG_STATUS(block_id) \
50 CVMX_ADD_IO_SEG(0x00011800C8000020ull + (((block_id) & 1) * 0x8000000ull))
51#define CVMX_PESCX_P2N_BAR0_START(block_id) \
52 CVMX_ADD_IO_SEG(0x00011800C8000080ull + (((block_id) & 1) * 0x8000000ull))
53#define CVMX_PESCX_P2N_BAR1_START(block_id) \
54 CVMX_ADD_IO_SEG(0x00011800C8000088ull + (((block_id) & 1) * 0x8000000ull))
55#define CVMX_PESCX_P2N_BAR2_START(block_id) \
56 CVMX_ADD_IO_SEG(0x00011800C8000090ull + (((block_id) & 1) * 0x8000000ull))
57#define CVMX_PESCX_P2P_BARX_END(offset, block_id) \
58 CVMX_ADD_IO_SEG(0x00011800C8000048ull + (((offset) & 3) * 16) + (((block_id) & 1) * 0x8000000ull))
59#define CVMX_PESCX_P2P_BARX_START(offset, block_id) \
60 CVMX_ADD_IO_SEG(0x00011800C8000040ull + (((offset) & 3) * 16) + (((block_id) & 1) * 0x8000000ull))
61#define CVMX_PESCX_TLP_CREDITS(block_id) \
62 CVMX_ADD_IO_SEG(0x00011800C8000038ull + (((block_id) & 1) * 0x8000000ull))
63 47
64union cvmx_pescx_bist_status { 48union cvmx_pescx_bist_status {
65 uint64_t u64; 49 uint64_t u64;
diff --git a/arch/mips/include/asm/octeon/cvmx-pexp-defs.h b/arch/mips/include/asm/octeon/cvmx-pexp-defs.h
index 5ea5dc571b54..5ab8679d89af 100644
--- a/arch/mips/include/asm/octeon/cvmx-pexp-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-pexp-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -35,195 +35,191 @@
35#ifndef __CVMX_PEXP_DEFS_H__ 35#ifndef __CVMX_PEXP_DEFS_H__
36#define __CVMX_PEXP_DEFS_H__ 36#define __CVMX_PEXP_DEFS_H__
37 37
38#define CVMX_PEXP_NPEI_BAR1_INDEXX(offset) \ 38#define CVMX_PEXP_NPEI_BAR1_INDEXX(offset) (CVMX_ADD_IO_SEG(0x00011F0000008000ull) + ((offset) & 31) * 16)
39 CVMX_ADD_IO_SEG(0x00011F0000008000ull + (((offset) & 31) * 16)) 39#define CVMX_PEXP_NPEI_BIST_STATUS (CVMX_ADD_IO_SEG(0x00011F0000008580ull))
40#define CVMX_PEXP_NPEI_BIST_STATUS \ 40#define CVMX_PEXP_NPEI_BIST_STATUS2 (CVMX_ADD_IO_SEG(0x00011F0000008680ull))
41 CVMX_ADD_IO_SEG(0x00011F0000008580ull) 41#define CVMX_PEXP_NPEI_CTL_PORT0 (CVMX_ADD_IO_SEG(0x00011F0000008250ull))
42#define CVMX_PEXP_NPEI_BIST_STATUS2 \ 42#define CVMX_PEXP_NPEI_CTL_PORT1 (CVMX_ADD_IO_SEG(0x00011F0000008260ull))
43 CVMX_ADD_IO_SEG(0x00011F0000008680ull) 43#define CVMX_PEXP_NPEI_CTL_STATUS (CVMX_ADD_IO_SEG(0x00011F0000008570ull))
44#define CVMX_PEXP_NPEI_CTL_PORT0 \ 44#define CVMX_PEXP_NPEI_CTL_STATUS2 (CVMX_ADD_IO_SEG(0x00011F000000BC00ull))
45 CVMX_ADD_IO_SEG(0x00011F0000008250ull) 45#define CVMX_PEXP_NPEI_DATA_OUT_CNT (CVMX_ADD_IO_SEG(0x00011F00000085F0ull))
46#define CVMX_PEXP_NPEI_CTL_PORT1 \ 46#define CVMX_PEXP_NPEI_DBG_DATA (CVMX_ADD_IO_SEG(0x00011F0000008510ull))
47 CVMX_ADD_IO_SEG(0x00011F0000008260ull) 47#define CVMX_PEXP_NPEI_DBG_SELECT (CVMX_ADD_IO_SEG(0x00011F0000008500ull))
48#define CVMX_PEXP_NPEI_CTL_STATUS \ 48#define CVMX_PEXP_NPEI_DMA0_INT_LEVEL (CVMX_ADD_IO_SEG(0x00011F00000085C0ull))
49 CVMX_ADD_IO_SEG(0x00011F0000008570ull) 49#define CVMX_PEXP_NPEI_DMA1_INT_LEVEL (CVMX_ADD_IO_SEG(0x00011F00000085D0ull))
50#define CVMX_PEXP_NPEI_CTL_STATUS2 \ 50#define CVMX_PEXP_NPEI_DMAX_COUNTS(offset) (CVMX_ADD_IO_SEG(0x00011F0000008450ull) + ((offset) & 7) * 16)
51 CVMX_ADD_IO_SEG(0x00011F000000BC00ull) 51#define CVMX_PEXP_NPEI_DMAX_DBELL(offset) (CVMX_ADD_IO_SEG(0x00011F00000083B0ull) + ((offset) & 7) * 16)
52#define CVMX_PEXP_NPEI_DATA_OUT_CNT \ 52#define CVMX_PEXP_NPEI_DMAX_IBUFF_SADDR(offset) (CVMX_ADD_IO_SEG(0x00011F0000008400ull) + ((offset) & 7) * 16)
53 CVMX_ADD_IO_SEG(0x00011F00000085F0ull) 53#define CVMX_PEXP_NPEI_DMAX_NADDR(offset) (CVMX_ADD_IO_SEG(0x00011F00000084A0ull) + ((offset) & 7) * 16)
54#define CVMX_PEXP_NPEI_DBG_DATA \ 54#define CVMX_PEXP_NPEI_DMA_CNTS (CVMX_ADD_IO_SEG(0x00011F00000085E0ull))
55 CVMX_ADD_IO_SEG(0x00011F0000008510ull) 55#define CVMX_PEXP_NPEI_DMA_CONTROL (CVMX_ADD_IO_SEG(0x00011F00000083A0ull))
56#define CVMX_PEXP_NPEI_DBG_SELECT \ 56#define CVMX_PEXP_NPEI_DMA_PCIE_REQ_NUM (CVMX_ADD_IO_SEG(0x00011F00000085B0ull))
57 CVMX_ADD_IO_SEG(0x00011F0000008500ull) 57#define CVMX_PEXP_NPEI_DMA_STATE1 (CVMX_ADD_IO_SEG(0x00011F00000086C0ull))
58#define CVMX_PEXP_NPEI_DMA0_INT_LEVEL \ 58#define CVMX_PEXP_NPEI_DMA_STATE1_P1 (CVMX_ADD_IO_SEG(0x00011F0000008680ull))
59 CVMX_ADD_IO_SEG(0x00011F00000085C0ull) 59#define CVMX_PEXP_NPEI_DMA_STATE2 (CVMX_ADD_IO_SEG(0x00011F00000086D0ull))
60#define CVMX_PEXP_NPEI_DMA1_INT_LEVEL \ 60#define CVMX_PEXP_NPEI_DMA_STATE2_P1 (CVMX_ADD_IO_SEG(0x00011F0000008690ull))
61 CVMX_ADD_IO_SEG(0x00011F00000085D0ull) 61#define CVMX_PEXP_NPEI_DMA_STATE3_P1 (CVMX_ADD_IO_SEG(0x00011F00000086A0ull))
62#define CVMX_PEXP_NPEI_DMAX_COUNTS(offset) \ 62#define CVMX_PEXP_NPEI_DMA_STATE4_P1 (CVMX_ADD_IO_SEG(0x00011F00000086B0ull))
63 CVMX_ADD_IO_SEG(0x00011F0000008450ull + (((offset) & 7) * 16)) 63#define CVMX_PEXP_NPEI_DMA_STATE5_P1 (CVMX_ADD_IO_SEG(0x00011F00000086C0ull))
64#define CVMX_PEXP_NPEI_DMAX_DBELL(offset) \ 64#define CVMX_PEXP_NPEI_INT_A_ENB (CVMX_ADD_IO_SEG(0x00011F0000008560ull))
65 CVMX_ADD_IO_SEG(0x00011F00000083B0ull + (((offset) & 7) * 16)) 65#define CVMX_PEXP_NPEI_INT_A_ENB2 (CVMX_ADD_IO_SEG(0x00011F000000BCE0ull))
66#define CVMX_PEXP_NPEI_DMAX_IBUFF_SADDR(offset) \ 66#define CVMX_PEXP_NPEI_INT_A_SUM (CVMX_ADD_IO_SEG(0x00011F0000008550ull))
67 CVMX_ADD_IO_SEG(0x00011F0000008400ull + (((offset) & 7) * 16)) 67#define CVMX_PEXP_NPEI_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000008540ull))
68#define CVMX_PEXP_NPEI_DMAX_NADDR(offset) \ 68#define CVMX_PEXP_NPEI_INT_ENB2 (CVMX_ADD_IO_SEG(0x00011F000000BCD0ull))
69 CVMX_ADD_IO_SEG(0x00011F00000084A0ull + (((offset) & 7) * 16)) 69#define CVMX_PEXP_NPEI_INT_INFO (CVMX_ADD_IO_SEG(0x00011F0000008590ull))
70#define CVMX_PEXP_NPEI_DMA_CNTS \ 70#define CVMX_PEXP_NPEI_INT_SUM (CVMX_ADD_IO_SEG(0x00011F0000008530ull))
71 CVMX_ADD_IO_SEG(0x00011F00000085E0ull) 71#define CVMX_PEXP_NPEI_INT_SUM2 (CVMX_ADD_IO_SEG(0x00011F000000BCC0ull))
72#define CVMX_PEXP_NPEI_DMA_CONTROL \ 72#define CVMX_PEXP_NPEI_LAST_WIN_RDATA0 (CVMX_ADD_IO_SEG(0x00011F0000008600ull))
73 CVMX_ADD_IO_SEG(0x00011F00000083A0ull) 73#define CVMX_PEXP_NPEI_LAST_WIN_RDATA1 (CVMX_ADD_IO_SEG(0x00011F0000008610ull))
74#define CVMX_PEXP_NPEI_INT_A_ENB \ 74#define CVMX_PEXP_NPEI_MEM_ACCESS_CTL (CVMX_ADD_IO_SEG(0x00011F00000084F0ull))
75 CVMX_ADD_IO_SEG(0x00011F0000008560ull) 75#define CVMX_PEXP_NPEI_MEM_ACCESS_SUBIDX(offset) (CVMX_ADD_IO_SEG(0x00011F0000008280ull) + ((offset) & 31) * 16 - 16*12)
76#define CVMX_PEXP_NPEI_INT_A_ENB2 \ 76#define CVMX_PEXP_NPEI_MSI_ENB0 (CVMX_ADD_IO_SEG(0x00011F000000BC50ull))
77 CVMX_ADD_IO_SEG(0x00011F000000BCE0ull) 77#define CVMX_PEXP_NPEI_MSI_ENB1 (CVMX_ADD_IO_SEG(0x00011F000000BC60ull))
78#define CVMX_PEXP_NPEI_INT_A_SUM \ 78#define CVMX_PEXP_NPEI_MSI_ENB2 (CVMX_ADD_IO_SEG(0x00011F000000BC70ull))
79 CVMX_ADD_IO_SEG(0x00011F0000008550ull) 79#define CVMX_PEXP_NPEI_MSI_ENB3 (CVMX_ADD_IO_SEG(0x00011F000000BC80ull))
80#define CVMX_PEXP_NPEI_INT_ENB \ 80#define CVMX_PEXP_NPEI_MSI_RCV0 (CVMX_ADD_IO_SEG(0x00011F000000BC10ull))
81 CVMX_ADD_IO_SEG(0x00011F0000008540ull) 81#define CVMX_PEXP_NPEI_MSI_RCV1 (CVMX_ADD_IO_SEG(0x00011F000000BC20ull))
82#define CVMX_PEXP_NPEI_INT_ENB2 \ 82#define CVMX_PEXP_NPEI_MSI_RCV2 (CVMX_ADD_IO_SEG(0x00011F000000BC30ull))
83 CVMX_ADD_IO_SEG(0x00011F000000BCD0ull) 83#define CVMX_PEXP_NPEI_MSI_RCV3 (CVMX_ADD_IO_SEG(0x00011F000000BC40ull))
84#define CVMX_PEXP_NPEI_INT_INFO \ 84#define CVMX_PEXP_NPEI_MSI_RD_MAP (CVMX_ADD_IO_SEG(0x00011F000000BCA0ull))
85 CVMX_ADD_IO_SEG(0x00011F0000008590ull) 85#define CVMX_PEXP_NPEI_MSI_W1C_ENB0 (CVMX_ADD_IO_SEG(0x00011F000000BCF0ull))
86#define CVMX_PEXP_NPEI_INT_SUM \ 86#define CVMX_PEXP_NPEI_MSI_W1C_ENB1 (CVMX_ADD_IO_SEG(0x00011F000000BD00ull))
87 CVMX_ADD_IO_SEG(0x00011F0000008530ull) 87#define CVMX_PEXP_NPEI_MSI_W1C_ENB2 (CVMX_ADD_IO_SEG(0x00011F000000BD10ull))
88#define CVMX_PEXP_NPEI_INT_SUM2 \ 88#define CVMX_PEXP_NPEI_MSI_W1C_ENB3 (CVMX_ADD_IO_SEG(0x00011F000000BD20ull))
89 CVMX_ADD_IO_SEG(0x00011F000000BCC0ull) 89#define CVMX_PEXP_NPEI_MSI_W1S_ENB0 (CVMX_ADD_IO_SEG(0x00011F000000BD30ull))
90#define CVMX_PEXP_NPEI_LAST_WIN_RDATA0 \ 90#define CVMX_PEXP_NPEI_MSI_W1S_ENB1 (CVMX_ADD_IO_SEG(0x00011F000000BD40ull))
91 CVMX_ADD_IO_SEG(0x00011F0000008600ull) 91#define CVMX_PEXP_NPEI_MSI_W1S_ENB2 (CVMX_ADD_IO_SEG(0x00011F000000BD50ull))
92#define CVMX_PEXP_NPEI_LAST_WIN_RDATA1 \ 92#define CVMX_PEXP_NPEI_MSI_W1S_ENB3 (CVMX_ADD_IO_SEG(0x00011F000000BD60ull))
93 CVMX_ADD_IO_SEG(0x00011F0000008610ull) 93#define CVMX_PEXP_NPEI_MSI_WR_MAP (CVMX_ADD_IO_SEG(0x00011F000000BC90ull))
94#define CVMX_PEXP_NPEI_MEM_ACCESS_CTL \ 94#define CVMX_PEXP_NPEI_PCIE_CREDIT_CNT (CVMX_ADD_IO_SEG(0x00011F000000BD70ull))
95 CVMX_ADD_IO_SEG(0x00011F00000084F0ull) 95#define CVMX_PEXP_NPEI_PCIE_MSI_RCV (CVMX_ADD_IO_SEG(0x00011F000000BCB0ull))
96#define CVMX_PEXP_NPEI_MEM_ACCESS_SUBIDX(offset) \ 96#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B1 (CVMX_ADD_IO_SEG(0x00011F0000008650ull))
97 CVMX_ADD_IO_SEG(0x00011F0000008280ull + (((offset) & 31) * 16) - 16 * 12) 97#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B2 (CVMX_ADD_IO_SEG(0x00011F0000008660ull))
98#define CVMX_PEXP_NPEI_MSI_ENB0 \ 98#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B3 (CVMX_ADD_IO_SEG(0x00011F0000008670ull))
99 CVMX_ADD_IO_SEG(0x00011F000000BC50ull) 99#define CVMX_PEXP_NPEI_PKTX_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F000000A400ull) + ((offset) & 31) * 16)
100#define CVMX_PEXP_NPEI_MSI_ENB1 \ 100#define CVMX_PEXP_NPEI_PKTX_INSTR_BADDR(offset) (CVMX_ADD_IO_SEG(0x00011F000000A800ull) + ((offset) & 31) * 16)
101 CVMX_ADD_IO_SEG(0x00011F000000BC60ull) 101#define CVMX_PEXP_NPEI_PKTX_INSTR_BAOFF_DBELL(offset) (CVMX_ADD_IO_SEG(0x00011F000000AC00ull) + ((offset) & 31) * 16)
102#define CVMX_PEXP_NPEI_MSI_ENB2 \ 102#define CVMX_PEXP_NPEI_PKTX_INSTR_FIFO_RSIZE(offset) (CVMX_ADD_IO_SEG(0x00011F000000B000ull) + ((offset) & 31) * 16)
103 CVMX_ADD_IO_SEG(0x00011F000000BC70ull) 103#define CVMX_PEXP_NPEI_PKTX_INSTR_HEADER(offset) (CVMX_ADD_IO_SEG(0x00011F000000B400ull) + ((offset) & 31) * 16)
104#define CVMX_PEXP_NPEI_MSI_ENB3 \ 104#define CVMX_PEXP_NPEI_PKTX_IN_BP(offset) (CVMX_ADD_IO_SEG(0x00011F000000B800ull) + ((offset) & 31) * 16)
105 CVMX_ADD_IO_SEG(0x00011F000000BC80ull) 105#define CVMX_PEXP_NPEI_PKTX_SLIST_BADDR(offset) (CVMX_ADD_IO_SEG(0x00011F0000009400ull) + ((offset) & 31) * 16)
106#define CVMX_PEXP_NPEI_MSI_RCV0 \ 106#define CVMX_PEXP_NPEI_PKTX_SLIST_BAOFF_DBELL(offset) (CVMX_ADD_IO_SEG(0x00011F0000009800ull) + ((offset) & 31) * 16)
107 CVMX_ADD_IO_SEG(0x00011F000000BC10ull) 107#define CVMX_PEXP_NPEI_PKTX_SLIST_FIFO_RSIZE(offset) (CVMX_ADD_IO_SEG(0x00011F0000009C00ull) + ((offset) & 31) * 16)
108#define CVMX_PEXP_NPEI_MSI_RCV1 \ 108#define CVMX_PEXP_NPEI_PKT_CNT_INT (CVMX_ADD_IO_SEG(0x00011F0000009110ull))
109 CVMX_ADD_IO_SEG(0x00011F000000BC20ull) 109#define CVMX_PEXP_NPEI_PKT_CNT_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000009130ull))
110#define CVMX_PEXP_NPEI_MSI_RCV2 \ 110#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ES (CVMX_ADD_IO_SEG(0x00011F00000090B0ull))
111 CVMX_ADD_IO_SEG(0x00011F000000BC30ull) 111#define CVMX_PEXP_NPEI_PKT_DATA_OUT_NS (CVMX_ADD_IO_SEG(0x00011F00000090A0ull))
112#define CVMX_PEXP_NPEI_MSI_RCV3 \ 112#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ROR (CVMX_ADD_IO_SEG(0x00011F0000009090ull))
113 CVMX_ADD_IO_SEG(0x00011F000000BC40ull) 113#define CVMX_PEXP_NPEI_PKT_DPADDR (CVMX_ADD_IO_SEG(0x00011F0000009080ull))
114#define CVMX_PEXP_NPEI_MSI_RD_MAP \ 114#define CVMX_PEXP_NPEI_PKT_INPUT_CONTROL (CVMX_ADD_IO_SEG(0x00011F0000009150ull))
115 CVMX_ADD_IO_SEG(0x00011F000000BCA0ull) 115#define CVMX_PEXP_NPEI_PKT_INSTR_ENB (CVMX_ADD_IO_SEG(0x00011F0000009000ull))
116#define CVMX_PEXP_NPEI_MSI_W1C_ENB0 \ 116#define CVMX_PEXP_NPEI_PKT_INSTR_RD_SIZE (CVMX_ADD_IO_SEG(0x00011F0000009190ull))
117 CVMX_ADD_IO_SEG(0x00011F000000BCF0ull) 117#define CVMX_PEXP_NPEI_PKT_INSTR_SIZE (CVMX_ADD_IO_SEG(0x00011F0000009020ull))
118#define CVMX_PEXP_NPEI_MSI_W1C_ENB1 \ 118#define CVMX_PEXP_NPEI_PKT_INT_LEVELS (CVMX_ADD_IO_SEG(0x00011F0000009100ull))
119 CVMX_ADD_IO_SEG(0x00011F000000BD00ull) 119#define CVMX_PEXP_NPEI_PKT_IN_BP (CVMX_ADD_IO_SEG(0x00011F00000086B0ull))
120#define CVMX_PEXP_NPEI_MSI_W1C_ENB2 \ 120#define CVMX_PEXP_NPEI_PKT_IN_DONEX_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F000000A000ull) + ((offset) & 31) * 16)
121 CVMX_ADD_IO_SEG(0x00011F000000BD10ull) 121#define CVMX_PEXP_NPEI_PKT_IN_INSTR_COUNTS (CVMX_ADD_IO_SEG(0x00011F00000086A0ull))
122#define CVMX_PEXP_NPEI_MSI_W1C_ENB3 \ 122#define CVMX_PEXP_NPEI_PKT_IN_PCIE_PORT (CVMX_ADD_IO_SEG(0x00011F00000091A0ull))
123 CVMX_ADD_IO_SEG(0x00011F000000BD20ull) 123#define CVMX_PEXP_NPEI_PKT_IPTR (CVMX_ADD_IO_SEG(0x00011F0000009070ull))
124#define CVMX_PEXP_NPEI_MSI_W1S_ENB0 \ 124#define CVMX_PEXP_NPEI_PKT_OUTPUT_WMARK (CVMX_ADD_IO_SEG(0x00011F0000009160ull))
125 CVMX_ADD_IO_SEG(0x00011F000000BD30ull) 125#define CVMX_PEXP_NPEI_PKT_OUT_BMODE (CVMX_ADD_IO_SEG(0x00011F00000090D0ull))
126#define CVMX_PEXP_NPEI_MSI_W1S_ENB1 \ 126#define CVMX_PEXP_NPEI_PKT_OUT_ENB (CVMX_ADD_IO_SEG(0x00011F0000009010ull))
127 CVMX_ADD_IO_SEG(0x00011F000000BD40ull) 127#define CVMX_PEXP_NPEI_PKT_PCIE_PORT (CVMX_ADD_IO_SEG(0x00011F00000090E0ull))
128#define CVMX_PEXP_NPEI_MSI_W1S_ENB2 \ 128#define CVMX_PEXP_NPEI_PKT_PORT_IN_RST (CVMX_ADD_IO_SEG(0x00011F0000008690ull))
129 CVMX_ADD_IO_SEG(0x00011F000000BD50ull) 129#define CVMX_PEXP_NPEI_PKT_SLIST_ES (CVMX_ADD_IO_SEG(0x00011F0000009050ull))
130#define CVMX_PEXP_NPEI_MSI_W1S_ENB3 \ 130#define CVMX_PEXP_NPEI_PKT_SLIST_ID_SIZE (CVMX_ADD_IO_SEG(0x00011F0000009180ull))
131 CVMX_ADD_IO_SEG(0x00011F000000BD60ull) 131#define CVMX_PEXP_NPEI_PKT_SLIST_NS (CVMX_ADD_IO_SEG(0x00011F0000009040ull))
132#define CVMX_PEXP_NPEI_MSI_WR_MAP \ 132#define CVMX_PEXP_NPEI_PKT_SLIST_ROR (CVMX_ADD_IO_SEG(0x00011F0000009030ull))
133 CVMX_ADD_IO_SEG(0x00011F000000BC90ull) 133#define CVMX_PEXP_NPEI_PKT_TIME_INT (CVMX_ADD_IO_SEG(0x00011F0000009120ull))
134#define CVMX_PEXP_NPEI_PCIE_CREDIT_CNT \ 134#define CVMX_PEXP_NPEI_PKT_TIME_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000009140ull))
135 CVMX_ADD_IO_SEG(0x00011F000000BD70ull) 135#define CVMX_PEXP_NPEI_RSL_INT_BLOCKS (CVMX_ADD_IO_SEG(0x00011F0000008520ull))
136#define CVMX_PEXP_NPEI_PCIE_MSI_RCV \ 136#define CVMX_PEXP_NPEI_SCRATCH_1 (CVMX_ADD_IO_SEG(0x00011F0000008270ull))
137 CVMX_ADD_IO_SEG(0x00011F000000BCB0ull) 137#define CVMX_PEXP_NPEI_STATE1 (CVMX_ADD_IO_SEG(0x00011F0000008620ull))
138#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B1 \ 138#define CVMX_PEXP_NPEI_STATE2 (CVMX_ADD_IO_SEG(0x00011F0000008630ull))
139 CVMX_ADD_IO_SEG(0x00011F0000008650ull) 139#define CVMX_PEXP_NPEI_STATE3 (CVMX_ADD_IO_SEG(0x00011F0000008640ull))
140#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B2 \ 140#define CVMX_PEXP_NPEI_WINDOW_CTL (CVMX_ADD_IO_SEG(0x00011F0000008380ull))
141 CVMX_ADD_IO_SEG(0x00011F0000008660ull) 141#define CVMX_PEXP_SLI_BIST_STATUS (CVMX_ADD_IO_SEG(0x00011F0000010580ull))
142#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B3 \ 142#define CVMX_PEXP_SLI_CTL_PORTX(offset) (CVMX_ADD_IO_SEG(0x00011F0000010050ull) + ((offset) & 1) * 16)
143 CVMX_ADD_IO_SEG(0x00011F0000008670ull) 143#define CVMX_PEXP_SLI_CTL_STATUS (CVMX_ADD_IO_SEG(0x00011F0000010570ull))
144#define CVMX_PEXP_NPEI_PKTX_CNTS(offset) \ 144#define CVMX_PEXP_SLI_DATA_OUT_CNT (CVMX_ADD_IO_SEG(0x00011F00000105F0ull))
145 CVMX_ADD_IO_SEG(0x00011F000000A400ull + (((offset) & 31) * 16)) 145#define CVMX_PEXP_SLI_DBG_DATA (CVMX_ADD_IO_SEG(0x00011F0000010310ull))
146#define CVMX_PEXP_NPEI_PKTX_INSTR_BADDR(offset) \ 146#define CVMX_PEXP_SLI_DBG_SELECT (CVMX_ADD_IO_SEG(0x00011F0000010300ull))
147 CVMX_ADD_IO_SEG(0x00011F000000A800ull + (((offset) & 31) * 16)) 147#define CVMX_PEXP_SLI_DMAX_CNT(offset) (CVMX_ADD_IO_SEG(0x00011F0000010400ull) + ((offset) & 1) * 16)
148#define CVMX_PEXP_NPEI_PKTX_INSTR_BAOFF_DBELL(offset) \ 148#define CVMX_PEXP_SLI_DMAX_INT_LEVEL(offset) (CVMX_ADD_IO_SEG(0x00011F00000103E0ull) + ((offset) & 1) * 16)
149 CVMX_ADD_IO_SEG(0x00011F000000AC00ull + (((offset) & 31) * 16)) 149#define CVMX_PEXP_SLI_DMAX_TIM(offset) (CVMX_ADD_IO_SEG(0x00011F0000010420ull) + ((offset) & 1) * 16)
150#define CVMX_PEXP_NPEI_PKTX_INSTR_FIFO_RSIZE(offset) \ 150#define CVMX_PEXP_SLI_INT_ENB_CIU (CVMX_ADD_IO_SEG(0x00011F0000013CD0ull))
151 CVMX_ADD_IO_SEG(0x00011F000000B000ull + (((offset) & 31) * 16)) 151#define CVMX_PEXP_SLI_INT_ENB_PORTX(offset) (CVMX_ADD_IO_SEG(0x00011F0000010340ull) + ((offset) & 1) * 16)
152#define CVMX_PEXP_NPEI_PKTX_INSTR_HEADER(offset) \ 152#define CVMX_PEXP_SLI_INT_SUM (CVMX_ADD_IO_SEG(0x00011F0000010330ull))
153 CVMX_ADD_IO_SEG(0x00011F000000B400ull + (((offset) & 31) * 16)) 153#define CVMX_PEXP_SLI_LAST_WIN_RDATA0 (CVMX_ADD_IO_SEG(0x00011F0000010600ull))
154#define CVMX_PEXP_NPEI_PKTX_IN_BP(offset) \ 154#define CVMX_PEXP_SLI_LAST_WIN_RDATA1 (CVMX_ADD_IO_SEG(0x00011F0000010610ull))
155 CVMX_ADD_IO_SEG(0x00011F000000B800ull + (((offset) & 31) * 16)) 155#define CVMX_PEXP_SLI_MAC_CREDIT_CNT (CVMX_ADD_IO_SEG(0x00011F0000013D70ull))
156#define CVMX_PEXP_NPEI_PKTX_SLIST_BADDR(offset) \ 156#define CVMX_PEXP_SLI_MEM_ACCESS_CTL (CVMX_ADD_IO_SEG(0x00011F00000102F0ull))
157 CVMX_ADD_IO_SEG(0x00011F0000009400ull + (((offset) & 31) * 16)) 157#define CVMX_PEXP_SLI_MEM_ACCESS_SUBIDX(offset) (CVMX_ADD_IO_SEG(0x00011F00000100E0ull) + ((offset) & 31) * 16 - 16*12)
158#define CVMX_PEXP_NPEI_PKTX_SLIST_BAOFF_DBELL(offset) \ 158#define CVMX_PEXP_SLI_MSI_ENB0 (CVMX_ADD_IO_SEG(0x00011F0000013C50ull))
159 CVMX_ADD_IO_SEG(0x00011F0000009800ull + (((offset) & 31) * 16)) 159#define CVMX_PEXP_SLI_MSI_ENB1 (CVMX_ADD_IO_SEG(0x00011F0000013C60ull))
160#define CVMX_PEXP_NPEI_PKTX_SLIST_FIFO_RSIZE(offset) \ 160#define CVMX_PEXP_SLI_MSI_ENB2 (CVMX_ADD_IO_SEG(0x00011F0000013C70ull))
161 CVMX_ADD_IO_SEG(0x00011F0000009C00ull + (((offset) & 31) * 16)) 161#define CVMX_PEXP_SLI_MSI_ENB3 (CVMX_ADD_IO_SEG(0x00011F0000013C80ull))
162#define CVMX_PEXP_NPEI_PKT_CNT_INT \ 162#define CVMX_PEXP_SLI_MSI_RCV0 (CVMX_ADD_IO_SEG(0x00011F0000013C10ull))
163 CVMX_ADD_IO_SEG(0x00011F0000009110ull) 163#define CVMX_PEXP_SLI_MSI_RCV1 (CVMX_ADD_IO_SEG(0x00011F0000013C20ull))
164#define CVMX_PEXP_NPEI_PKT_CNT_INT_ENB \ 164#define CVMX_PEXP_SLI_MSI_RCV2 (CVMX_ADD_IO_SEG(0x00011F0000013C30ull))
165 CVMX_ADD_IO_SEG(0x00011F0000009130ull) 165#define CVMX_PEXP_SLI_MSI_RCV3 (CVMX_ADD_IO_SEG(0x00011F0000013C40ull))
166#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ES \ 166#define CVMX_PEXP_SLI_MSI_RD_MAP (CVMX_ADD_IO_SEG(0x00011F0000013CA0ull))
167 CVMX_ADD_IO_SEG(0x00011F00000090B0ull) 167#define CVMX_PEXP_SLI_MSI_W1C_ENB0 (CVMX_ADD_IO_SEG(0x00011F0000013CF0ull))
168#define CVMX_PEXP_NPEI_PKT_DATA_OUT_NS \ 168#define CVMX_PEXP_SLI_MSI_W1C_ENB1 (CVMX_ADD_IO_SEG(0x00011F0000013D00ull))
169 CVMX_ADD_IO_SEG(0x00011F00000090A0ull) 169#define CVMX_PEXP_SLI_MSI_W1C_ENB2 (CVMX_ADD_IO_SEG(0x00011F0000013D10ull))
170#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ROR \ 170#define CVMX_PEXP_SLI_MSI_W1C_ENB3 (CVMX_ADD_IO_SEG(0x00011F0000013D20ull))
171 CVMX_ADD_IO_SEG(0x00011F0000009090ull) 171#define CVMX_PEXP_SLI_MSI_W1S_ENB0 (CVMX_ADD_IO_SEG(0x00011F0000013D30ull))
172#define CVMX_PEXP_NPEI_PKT_DPADDR \ 172#define CVMX_PEXP_SLI_MSI_W1S_ENB1 (CVMX_ADD_IO_SEG(0x00011F0000013D40ull))
173 CVMX_ADD_IO_SEG(0x00011F0000009080ull) 173#define CVMX_PEXP_SLI_MSI_W1S_ENB2 (CVMX_ADD_IO_SEG(0x00011F0000013D50ull))
174#define CVMX_PEXP_NPEI_PKT_INPUT_CONTROL \ 174#define CVMX_PEXP_SLI_MSI_W1S_ENB3 (CVMX_ADD_IO_SEG(0x00011F0000013D60ull))
175 CVMX_ADD_IO_SEG(0x00011F0000009150ull) 175#define CVMX_PEXP_SLI_MSI_WR_MAP (CVMX_ADD_IO_SEG(0x00011F0000013C90ull))
176#define CVMX_PEXP_NPEI_PKT_INSTR_ENB \ 176#define CVMX_PEXP_SLI_PCIE_MSI_RCV (CVMX_ADD_IO_SEG(0x00011F0000013CB0ull))
177 CVMX_ADD_IO_SEG(0x00011F0000009000ull) 177#define CVMX_PEXP_SLI_PCIE_MSI_RCV_B1 (CVMX_ADD_IO_SEG(0x00011F0000010650ull))
178#define CVMX_PEXP_NPEI_PKT_INSTR_RD_SIZE \ 178#define CVMX_PEXP_SLI_PCIE_MSI_RCV_B2 (CVMX_ADD_IO_SEG(0x00011F0000010660ull))
179 CVMX_ADD_IO_SEG(0x00011F0000009190ull) 179#define CVMX_PEXP_SLI_PCIE_MSI_RCV_B3 (CVMX_ADD_IO_SEG(0x00011F0000010670ull))
180#define CVMX_PEXP_NPEI_PKT_INSTR_SIZE \ 180#define CVMX_PEXP_SLI_PKTX_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F0000012400ull) + ((offset) & 31) * 16)
181 CVMX_ADD_IO_SEG(0x00011F0000009020ull) 181#define CVMX_PEXP_SLI_PKTX_INSTR_BADDR(offset) (CVMX_ADD_IO_SEG(0x00011F0000012800ull) + ((offset) & 31) * 16)
182#define CVMX_PEXP_NPEI_PKT_INT_LEVELS \ 182#define CVMX_PEXP_SLI_PKTX_INSTR_BAOFF_DBELL(offset) (CVMX_ADD_IO_SEG(0x00011F0000012C00ull) + ((offset) & 31) * 16)
183 CVMX_ADD_IO_SEG(0x00011F0000009100ull) 183#define CVMX_PEXP_SLI_PKTX_INSTR_FIFO_RSIZE(offset) (CVMX_ADD_IO_SEG(0x00011F0000013000ull) + ((offset) & 31) * 16)
184#define CVMX_PEXP_NPEI_PKT_IN_BP \ 184#define CVMX_PEXP_SLI_PKTX_INSTR_HEADER(offset) (CVMX_ADD_IO_SEG(0x00011F0000013400ull) + ((offset) & 31) * 16)
185 CVMX_ADD_IO_SEG(0x00011F00000086B0ull) 185#define CVMX_PEXP_SLI_PKTX_IN_BP(offset) (CVMX_ADD_IO_SEG(0x00011F0000013800ull) + ((offset) & 31) * 16)
186#define CVMX_PEXP_NPEI_PKT_IN_DONEX_CNTS(offset) \ 186#define CVMX_PEXP_SLI_PKTX_OUT_SIZE(offset) (CVMX_ADD_IO_SEG(0x00011F0000010C00ull) + ((offset) & 31) * 16)
187 CVMX_ADD_IO_SEG(0x00011F000000A000ull + (((offset) & 31) * 16)) 187#define CVMX_PEXP_SLI_PKTX_SLIST_BADDR(offset) (CVMX_ADD_IO_SEG(0x00011F0000011400ull) + ((offset) & 31) * 16)
188#define CVMX_PEXP_NPEI_PKT_IN_INSTR_COUNTS \ 188#define CVMX_PEXP_SLI_PKTX_SLIST_BAOFF_DBELL(offset) (CVMX_ADD_IO_SEG(0x00011F0000011800ull) + ((offset) & 31) * 16)
189 CVMX_ADD_IO_SEG(0x00011F00000086A0ull) 189#define CVMX_PEXP_SLI_PKTX_SLIST_FIFO_RSIZE(offset) (CVMX_ADD_IO_SEG(0x00011F0000011C00ull) + ((offset) & 31) * 16)
190#define CVMX_PEXP_NPEI_PKT_IN_PCIE_PORT \ 190#define CVMX_PEXP_SLI_PKT_CNT_INT (CVMX_ADD_IO_SEG(0x00011F0000011130ull))
191 CVMX_ADD_IO_SEG(0x00011F00000091A0ull) 191#define CVMX_PEXP_SLI_PKT_CNT_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000011150ull))
192#define CVMX_PEXP_NPEI_PKT_IPTR \ 192#define CVMX_PEXP_SLI_PKT_CTL (CVMX_ADD_IO_SEG(0x00011F0000011220ull))
193 CVMX_ADD_IO_SEG(0x00011F0000009070ull) 193#define CVMX_PEXP_SLI_PKT_DATA_OUT_ES (CVMX_ADD_IO_SEG(0x00011F00000110B0ull))
194#define CVMX_PEXP_NPEI_PKT_OUTPUT_WMARK \ 194#define CVMX_PEXP_SLI_PKT_DATA_OUT_NS (CVMX_ADD_IO_SEG(0x00011F00000110A0ull))
195 CVMX_ADD_IO_SEG(0x00011F0000009160ull) 195#define CVMX_PEXP_SLI_PKT_DATA_OUT_ROR (CVMX_ADD_IO_SEG(0x00011F0000011090ull))
196#define CVMX_PEXP_NPEI_PKT_OUT_BMODE \ 196#define CVMX_PEXP_SLI_PKT_DPADDR (CVMX_ADD_IO_SEG(0x00011F0000011080ull))
197 CVMX_ADD_IO_SEG(0x00011F00000090D0ull) 197#define CVMX_PEXP_SLI_PKT_INPUT_CONTROL (CVMX_ADD_IO_SEG(0x00011F0000011170ull))
198#define CVMX_PEXP_NPEI_PKT_OUT_ENB \ 198#define CVMX_PEXP_SLI_PKT_INSTR_ENB (CVMX_ADD_IO_SEG(0x00011F0000011000ull))
199 CVMX_ADD_IO_SEG(0x00011F0000009010ull) 199#define CVMX_PEXP_SLI_PKT_INSTR_RD_SIZE (CVMX_ADD_IO_SEG(0x00011F00000111A0ull))
200#define CVMX_PEXP_NPEI_PKT_PCIE_PORT \ 200#define CVMX_PEXP_SLI_PKT_INSTR_SIZE (CVMX_ADD_IO_SEG(0x00011F0000011020ull))
201 CVMX_ADD_IO_SEG(0x00011F00000090E0ull) 201#define CVMX_PEXP_SLI_PKT_INT_LEVELS (CVMX_ADD_IO_SEG(0x00011F0000011120ull))
202#define CVMX_PEXP_NPEI_PKT_PORT_IN_RST \ 202#define CVMX_PEXP_SLI_PKT_IN_BP (CVMX_ADD_IO_SEG(0x00011F0000011210ull))
203 CVMX_ADD_IO_SEG(0x00011F0000008690ull) 203#define CVMX_PEXP_SLI_PKT_IN_DONEX_CNTS(offset) (CVMX_ADD_IO_SEG(0x00011F0000012000ull) + ((offset) & 31) * 16)
204#define CVMX_PEXP_NPEI_PKT_SLIST_ES \ 204#define CVMX_PEXP_SLI_PKT_IN_INSTR_COUNTS (CVMX_ADD_IO_SEG(0x00011F0000011200ull))
205 CVMX_ADD_IO_SEG(0x00011F0000009050ull) 205#define CVMX_PEXP_SLI_PKT_IN_PCIE_PORT (CVMX_ADD_IO_SEG(0x00011F00000111B0ull))
206#define CVMX_PEXP_NPEI_PKT_SLIST_ID_SIZE \ 206#define CVMX_PEXP_SLI_PKT_IPTR (CVMX_ADD_IO_SEG(0x00011F0000011070ull))
207 CVMX_ADD_IO_SEG(0x00011F0000009180ull) 207#define CVMX_PEXP_SLI_PKT_OUTPUT_WMARK (CVMX_ADD_IO_SEG(0x00011F0000011180ull))
208#define CVMX_PEXP_NPEI_PKT_SLIST_NS \ 208#define CVMX_PEXP_SLI_PKT_OUT_BMODE (CVMX_ADD_IO_SEG(0x00011F00000110D0ull))
209 CVMX_ADD_IO_SEG(0x00011F0000009040ull) 209#define CVMX_PEXP_SLI_PKT_OUT_ENB (CVMX_ADD_IO_SEG(0x00011F0000011010ull))
210#define CVMX_PEXP_NPEI_PKT_SLIST_ROR \ 210#define CVMX_PEXP_SLI_PKT_PCIE_PORT (CVMX_ADD_IO_SEG(0x00011F00000110E0ull))
211 CVMX_ADD_IO_SEG(0x00011F0000009030ull) 211#define CVMX_PEXP_SLI_PKT_PORT_IN_RST (CVMX_ADD_IO_SEG(0x00011F00000111F0ull))
212#define CVMX_PEXP_NPEI_PKT_TIME_INT \ 212#define CVMX_PEXP_SLI_PKT_SLIST_ES (CVMX_ADD_IO_SEG(0x00011F0000011050ull))
213 CVMX_ADD_IO_SEG(0x00011F0000009120ull) 213#define CVMX_PEXP_SLI_PKT_SLIST_NS (CVMX_ADD_IO_SEG(0x00011F0000011040ull))
214#define CVMX_PEXP_NPEI_PKT_TIME_INT_ENB \ 214#define CVMX_PEXP_SLI_PKT_SLIST_ROR (CVMX_ADD_IO_SEG(0x00011F0000011030ull))
215 CVMX_ADD_IO_SEG(0x00011F0000009140ull) 215#define CVMX_PEXP_SLI_PKT_TIME_INT (CVMX_ADD_IO_SEG(0x00011F0000011140ull))
216#define CVMX_PEXP_NPEI_RSL_INT_BLOCKS \ 216#define CVMX_PEXP_SLI_PKT_TIME_INT_ENB (CVMX_ADD_IO_SEG(0x00011F0000011160ull))
217 CVMX_ADD_IO_SEG(0x00011F0000008520ull) 217#define CVMX_PEXP_SLI_S2M_PORTX_CTL(offset) (CVMX_ADD_IO_SEG(0x00011F0000013D80ull) + ((offset) & 1) * 16)
218#define CVMX_PEXP_NPEI_SCRATCH_1 \ 218#define CVMX_PEXP_SLI_SCRATCH_1 (CVMX_ADD_IO_SEG(0x00011F00000103C0ull))
219 CVMX_ADD_IO_SEG(0x00011F0000008270ull) 219#define CVMX_PEXP_SLI_SCRATCH_2 (CVMX_ADD_IO_SEG(0x00011F00000103D0ull))
220#define CVMX_PEXP_NPEI_STATE1 \ 220#define CVMX_PEXP_SLI_STATE1 (CVMX_ADD_IO_SEG(0x00011F0000010620ull))
221 CVMX_ADD_IO_SEG(0x00011F0000008620ull) 221#define CVMX_PEXP_SLI_STATE2 (CVMX_ADD_IO_SEG(0x00011F0000010630ull))
222#define CVMX_PEXP_NPEI_STATE2 \ 222#define CVMX_PEXP_SLI_STATE3 (CVMX_ADD_IO_SEG(0x00011F0000010640ull))
223 CVMX_ADD_IO_SEG(0x00011F0000008630ull) 223#define CVMX_PEXP_SLI_WINDOW_CTL (CVMX_ADD_IO_SEG(0x00011F00000102E0ull))
224#define CVMX_PEXP_NPEI_STATE3 \
225 CVMX_ADD_IO_SEG(0x00011F0000008640ull)
226#define CVMX_PEXP_NPEI_WINDOW_CTL \
227 CVMX_ADD_IO_SEG(0x00011F0000008380ull)
228 224
229#endif 225#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-pow-defs.h b/arch/mips/include/asm/octeon/cvmx-pow-defs.h
index 2d82e24be51c..39fd75b03f77 100644
--- a/arch/mips/include/asm/octeon/cvmx-pow-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-pow-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,52 +28,29 @@
28#ifndef __CVMX_POW_DEFS_H__ 28#ifndef __CVMX_POW_DEFS_H__
29#define __CVMX_POW_DEFS_H__ 29#define __CVMX_POW_DEFS_H__
30 30
31#define CVMX_POW_BIST_STAT \ 31#define CVMX_POW_BIST_STAT (CVMX_ADD_IO_SEG(0x00016700000003F8ull))
32 CVMX_ADD_IO_SEG(0x00016700000003F8ull) 32#define CVMX_POW_DS_PC (CVMX_ADD_IO_SEG(0x0001670000000398ull))
33#define CVMX_POW_DS_PC \ 33#define CVMX_POW_ECC_ERR (CVMX_ADD_IO_SEG(0x0001670000000218ull))
34 CVMX_ADD_IO_SEG(0x0001670000000398ull) 34#define CVMX_POW_INT_CTL (CVMX_ADD_IO_SEG(0x0001670000000220ull))
35#define CVMX_POW_ECC_ERR \ 35#define CVMX_POW_IQ_CNTX(offset) (CVMX_ADD_IO_SEG(0x0001670000000340ull) + ((offset) & 7) * 8)
36 CVMX_ADD_IO_SEG(0x0001670000000218ull) 36#define CVMX_POW_IQ_COM_CNT (CVMX_ADD_IO_SEG(0x0001670000000388ull))
37#define CVMX_POW_INT_CTL \ 37#define CVMX_POW_IQ_INT (CVMX_ADD_IO_SEG(0x0001670000000238ull))
38 CVMX_ADD_IO_SEG(0x0001670000000220ull) 38#define CVMX_POW_IQ_INT_EN (CVMX_ADD_IO_SEG(0x0001670000000240ull))
39#define CVMX_POW_IQ_CNTX(offset) \ 39#define CVMX_POW_IQ_THRX(offset) (CVMX_ADD_IO_SEG(0x00016700000003A0ull) + ((offset) & 7) * 8)
40 CVMX_ADD_IO_SEG(0x0001670000000340ull + (((offset) & 7) * 8)) 40#define CVMX_POW_NOS_CNT (CVMX_ADD_IO_SEG(0x0001670000000228ull))
41#define CVMX_POW_IQ_COM_CNT \ 41#define CVMX_POW_NW_TIM (CVMX_ADD_IO_SEG(0x0001670000000210ull))
42 CVMX_ADD_IO_SEG(0x0001670000000388ull) 42#define CVMX_POW_PF_RST_MSK (CVMX_ADD_IO_SEG(0x0001670000000230ull))
43#define CVMX_POW_IQ_INT \ 43#define CVMX_POW_PP_GRP_MSKX(offset) (CVMX_ADD_IO_SEG(0x0001670000000000ull) + ((offset) & 15) * 8)
44 CVMX_ADD_IO_SEG(0x0001670000000238ull) 44#define CVMX_POW_QOS_RNDX(offset) (CVMX_ADD_IO_SEG(0x00016700000001C0ull) + ((offset) & 7) * 8)
45#define CVMX_POW_IQ_INT_EN \ 45#define CVMX_POW_QOS_THRX(offset) (CVMX_ADD_IO_SEG(0x0001670000000180ull) + ((offset) & 7) * 8)
46 CVMX_ADD_IO_SEG(0x0001670000000240ull) 46#define CVMX_POW_TS_PC (CVMX_ADD_IO_SEG(0x0001670000000390ull))
47#define CVMX_POW_IQ_THRX(offset) \ 47#define CVMX_POW_WA_COM_PC (CVMX_ADD_IO_SEG(0x0001670000000380ull))
48 CVMX_ADD_IO_SEG(0x00016700000003A0ull + (((offset) & 7) * 8)) 48#define CVMX_POW_WA_PCX(offset) (CVMX_ADD_IO_SEG(0x0001670000000300ull) + ((offset) & 7) * 8)
49#define CVMX_POW_NOS_CNT \ 49#define CVMX_POW_WQ_INT (CVMX_ADD_IO_SEG(0x0001670000000200ull))
50 CVMX_ADD_IO_SEG(0x0001670000000228ull) 50#define CVMX_POW_WQ_INT_CNTX(offset) (CVMX_ADD_IO_SEG(0x0001670000000100ull) + ((offset) & 15) * 8)
51#define CVMX_POW_NW_TIM \ 51#define CVMX_POW_WQ_INT_PC (CVMX_ADD_IO_SEG(0x0001670000000208ull))
52 CVMX_ADD_IO_SEG(0x0001670000000210ull) 52#define CVMX_POW_WQ_INT_THRX(offset) (CVMX_ADD_IO_SEG(0x0001670000000080ull) + ((offset) & 15) * 8)
53#define CVMX_POW_PF_RST_MSK \ 53#define CVMX_POW_WS_PCX(offset) (CVMX_ADD_IO_SEG(0x0001670000000280ull) + ((offset) & 15) * 8)
54 CVMX_ADD_IO_SEG(0x0001670000000230ull)
55#define CVMX_POW_PP_GRP_MSKX(offset) \
56 CVMX_ADD_IO_SEG(0x0001670000000000ull + (((offset) & 15) * 8))
57#define CVMX_POW_QOS_RNDX(offset) \
58 CVMX_ADD_IO_SEG(0x00016700000001C0ull + (((offset) & 7) * 8))
59#define CVMX_POW_QOS_THRX(offset) \
60 CVMX_ADD_IO_SEG(0x0001670000000180ull + (((offset) & 7) * 8))
61#define CVMX_POW_TS_PC \
62 CVMX_ADD_IO_SEG(0x0001670000000390ull)
63#define CVMX_POW_WA_COM_PC \
64 CVMX_ADD_IO_SEG(0x0001670000000380ull)
65#define CVMX_POW_WA_PCX(offset) \
66 CVMX_ADD_IO_SEG(0x0001670000000300ull + (((offset) & 7) * 8))
67#define CVMX_POW_WQ_INT \
68 CVMX_ADD_IO_SEG(0x0001670000000200ull)
69#define CVMX_POW_WQ_INT_CNTX(offset) \
70 CVMX_ADD_IO_SEG(0x0001670000000100ull + (((offset) & 15) * 8))
71#define CVMX_POW_WQ_INT_PC \
72 CVMX_ADD_IO_SEG(0x0001670000000208ull)
73#define CVMX_POW_WQ_INT_THRX(offset) \
74 CVMX_ADD_IO_SEG(0x0001670000000080ull + (((offset) & 15) * 8))
75#define CVMX_POW_WS_PCX(offset) \
76 CVMX_ADD_IO_SEG(0x0001670000000280ull + (((offset) & 15) * 8))
77 54
78union cvmx_pow_bist_stat { 55union cvmx_pow_bist_stat {
79 uint64_t u64; 56 uint64_t u64;
@@ -160,6 +137,19 @@ union cvmx_pow_bist_stat {
160 struct cvmx_pow_bist_stat_cn56xx cn56xxp1; 137 struct cvmx_pow_bist_stat_cn56xx cn56xxp1;
161 struct cvmx_pow_bist_stat_cn38xx cn58xx; 138 struct cvmx_pow_bist_stat_cn38xx cn58xx;
162 struct cvmx_pow_bist_stat_cn38xx cn58xxp1; 139 struct cvmx_pow_bist_stat_cn38xx cn58xxp1;
140 struct cvmx_pow_bist_stat_cn63xx {
141 uint64_t reserved_22_63:42;
142 uint64_t pp:6;
143 uint64_t reserved_12_15:4;
144 uint64_t cam:1;
145 uint64_t nbr:3;
146 uint64_t nbt:4;
147 uint64_t index:1;
148 uint64_t fidx:1;
149 uint64_t pend:1;
150 uint64_t adr:1;
151 } cn63xx;
152 struct cvmx_pow_bist_stat_cn63xx cn63xxp1;
163}; 153};
164 154
165union cvmx_pow_ds_pc { 155union cvmx_pow_ds_pc {
@@ -179,6 +169,8 @@ union cvmx_pow_ds_pc {
179 struct cvmx_pow_ds_pc_s cn56xxp1; 169 struct cvmx_pow_ds_pc_s cn56xxp1;
180 struct cvmx_pow_ds_pc_s cn58xx; 170 struct cvmx_pow_ds_pc_s cn58xx;
181 struct cvmx_pow_ds_pc_s cn58xxp1; 171 struct cvmx_pow_ds_pc_s cn58xxp1;
172 struct cvmx_pow_ds_pc_s cn63xx;
173 struct cvmx_pow_ds_pc_s cn63xxp1;
182}; 174};
183 175
184union cvmx_pow_ecc_err { 176union cvmx_pow_ecc_err {
@@ -219,6 +211,8 @@ union cvmx_pow_ecc_err {
219 struct cvmx_pow_ecc_err_s cn56xxp1; 211 struct cvmx_pow_ecc_err_s cn56xxp1;
220 struct cvmx_pow_ecc_err_s cn58xx; 212 struct cvmx_pow_ecc_err_s cn58xx;
221 struct cvmx_pow_ecc_err_s cn58xxp1; 213 struct cvmx_pow_ecc_err_s cn58xxp1;
214 struct cvmx_pow_ecc_err_s cn63xx;
215 struct cvmx_pow_ecc_err_s cn63xxp1;
222}; 216};
223 217
224union cvmx_pow_int_ctl { 218union cvmx_pow_int_ctl {
@@ -239,6 +233,8 @@ union cvmx_pow_int_ctl {
239 struct cvmx_pow_int_ctl_s cn56xxp1; 233 struct cvmx_pow_int_ctl_s cn56xxp1;
240 struct cvmx_pow_int_ctl_s cn58xx; 234 struct cvmx_pow_int_ctl_s cn58xx;
241 struct cvmx_pow_int_ctl_s cn58xxp1; 235 struct cvmx_pow_int_ctl_s cn58xxp1;
236 struct cvmx_pow_int_ctl_s cn63xx;
237 struct cvmx_pow_int_ctl_s cn63xxp1;
242}; 238};
243 239
244union cvmx_pow_iq_cntx { 240union cvmx_pow_iq_cntx {
@@ -258,6 +254,8 @@ union cvmx_pow_iq_cntx {
258 struct cvmx_pow_iq_cntx_s cn56xxp1; 254 struct cvmx_pow_iq_cntx_s cn56xxp1;
259 struct cvmx_pow_iq_cntx_s cn58xx; 255 struct cvmx_pow_iq_cntx_s cn58xx;
260 struct cvmx_pow_iq_cntx_s cn58xxp1; 256 struct cvmx_pow_iq_cntx_s cn58xxp1;
257 struct cvmx_pow_iq_cntx_s cn63xx;
258 struct cvmx_pow_iq_cntx_s cn63xxp1;
261}; 259};
262 260
263union cvmx_pow_iq_com_cnt { 261union cvmx_pow_iq_com_cnt {
@@ -277,6 +275,8 @@ union cvmx_pow_iq_com_cnt {
277 struct cvmx_pow_iq_com_cnt_s cn56xxp1; 275 struct cvmx_pow_iq_com_cnt_s cn56xxp1;
278 struct cvmx_pow_iq_com_cnt_s cn58xx; 276 struct cvmx_pow_iq_com_cnt_s cn58xx;
279 struct cvmx_pow_iq_com_cnt_s cn58xxp1; 277 struct cvmx_pow_iq_com_cnt_s cn58xxp1;
278 struct cvmx_pow_iq_com_cnt_s cn63xx;
279 struct cvmx_pow_iq_com_cnt_s cn63xxp1;
280}; 280};
281 281
282union cvmx_pow_iq_int { 282union cvmx_pow_iq_int {
@@ -289,6 +289,8 @@ union cvmx_pow_iq_int {
289 struct cvmx_pow_iq_int_s cn52xxp1; 289 struct cvmx_pow_iq_int_s cn52xxp1;
290 struct cvmx_pow_iq_int_s cn56xx; 290 struct cvmx_pow_iq_int_s cn56xx;
291 struct cvmx_pow_iq_int_s cn56xxp1; 291 struct cvmx_pow_iq_int_s cn56xxp1;
292 struct cvmx_pow_iq_int_s cn63xx;
293 struct cvmx_pow_iq_int_s cn63xxp1;
292}; 294};
293 295
294union cvmx_pow_iq_int_en { 296union cvmx_pow_iq_int_en {
@@ -301,6 +303,8 @@ union cvmx_pow_iq_int_en {
301 struct cvmx_pow_iq_int_en_s cn52xxp1; 303 struct cvmx_pow_iq_int_en_s cn52xxp1;
302 struct cvmx_pow_iq_int_en_s cn56xx; 304 struct cvmx_pow_iq_int_en_s cn56xx;
303 struct cvmx_pow_iq_int_en_s cn56xxp1; 305 struct cvmx_pow_iq_int_en_s cn56xxp1;
306 struct cvmx_pow_iq_int_en_s cn63xx;
307 struct cvmx_pow_iq_int_en_s cn63xxp1;
304}; 308};
305 309
306union cvmx_pow_iq_thrx { 310union cvmx_pow_iq_thrx {
@@ -313,6 +317,8 @@ union cvmx_pow_iq_thrx {
313 struct cvmx_pow_iq_thrx_s cn52xxp1; 317 struct cvmx_pow_iq_thrx_s cn52xxp1;
314 struct cvmx_pow_iq_thrx_s cn56xx; 318 struct cvmx_pow_iq_thrx_s cn56xx;
315 struct cvmx_pow_iq_thrx_s cn56xxp1; 319 struct cvmx_pow_iq_thrx_s cn56xxp1;
320 struct cvmx_pow_iq_thrx_s cn63xx;
321 struct cvmx_pow_iq_thrx_s cn63xxp1;
316}; 322};
317 323
318union cvmx_pow_nos_cnt { 324union cvmx_pow_nos_cnt {
@@ -341,6 +347,11 @@ union cvmx_pow_nos_cnt {
341 struct cvmx_pow_nos_cnt_s cn56xxp1; 347 struct cvmx_pow_nos_cnt_s cn56xxp1;
342 struct cvmx_pow_nos_cnt_s cn58xx; 348 struct cvmx_pow_nos_cnt_s cn58xx;
343 struct cvmx_pow_nos_cnt_s cn58xxp1; 349 struct cvmx_pow_nos_cnt_s cn58xxp1;
350 struct cvmx_pow_nos_cnt_cn63xx {
351 uint64_t reserved_11_63:53;
352 uint64_t nos_cnt:11;
353 } cn63xx;
354 struct cvmx_pow_nos_cnt_cn63xx cn63xxp1;
344}; 355};
345 356
346union cvmx_pow_nw_tim { 357union cvmx_pow_nw_tim {
@@ -360,6 +371,8 @@ union cvmx_pow_nw_tim {
360 struct cvmx_pow_nw_tim_s cn56xxp1; 371 struct cvmx_pow_nw_tim_s cn56xxp1;
361 struct cvmx_pow_nw_tim_s cn58xx; 372 struct cvmx_pow_nw_tim_s cn58xx;
362 struct cvmx_pow_nw_tim_s cn58xxp1; 373 struct cvmx_pow_nw_tim_s cn58xxp1;
374 struct cvmx_pow_nw_tim_s cn63xx;
375 struct cvmx_pow_nw_tim_s cn63xxp1;
363}; 376};
364 377
365union cvmx_pow_pf_rst_msk { 378union cvmx_pow_pf_rst_msk {
@@ -375,6 +388,8 @@ union cvmx_pow_pf_rst_msk {
375 struct cvmx_pow_pf_rst_msk_s cn56xxp1; 388 struct cvmx_pow_pf_rst_msk_s cn56xxp1;
376 struct cvmx_pow_pf_rst_msk_s cn58xx; 389 struct cvmx_pow_pf_rst_msk_s cn58xx;
377 struct cvmx_pow_pf_rst_msk_s cn58xxp1; 390 struct cvmx_pow_pf_rst_msk_s cn58xxp1;
391 struct cvmx_pow_pf_rst_msk_s cn63xx;
392 struct cvmx_pow_pf_rst_msk_s cn63xxp1;
378}; 393};
379 394
380union cvmx_pow_pp_grp_mskx { 395union cvmx_pow_pp_grp_mskx {
@@ -405,6 +420,8 @@ union cvmx_pow_pp_grp_mskx {
405 struct cvmx_pow_pp_grp_mskx_s cn56xxp1; 420 struct cvmx_pow_pp_grp_mskx_s cn56xxp1;
406 struct cvmx_pow_pp_grp_mskx_s cn58xx; 421 struct cvmx_pow_pp_grp_mskx_s cn58xx;
407 struct cvmx_pow_pp_grp_mskx_s cn58xxp1; 422 struct cvmx_pow_pp_grp_mskx_s cn58xxp1;
423 struct cvmx_pow_pp_grp_mskx_s cn63xx;
424 struct cvmx_pow_pp_grp_mskx_s cn63xxp1;
408}; 425};
409 426
410union cvmx_pow_qos_rndx { 427union cvmx_pow_qos_rndx {
@@ -427,6 +444,8 @@ union cvmx_pow_qos_rndx {
427 struct cvmx_pow_qos_rndx_s cn56xxp1; 444 struct cvmx_pow_qos_rndx_s cn56xxp1;
428 struct cvmx_pow_qos_rndx_s cn58xx; 445 struct cvmx_pow_qos_rndx_s cn58xx;
429 struct cvmx_pow_qos_rndx_s cn58xxp1; 446 struct cvmx_pow_qos_rndx_s cn58xxp1;
447 struct cvmx_pow_qos_rndx_s cn63xx;
448 struct cvmx_pow_qos_rndx_s cn63xxp1;
430}; 449};
431 450
432union cvmx_pow_qos_thrx { 451union cvmx_pow_qos_thrx {
@@ -485,6 +504,19 @@ union cvmx_pow_qos_thrx {
485 struct cvmx_pow_qos_thrx_s cn56xxp1; 504 struct cvmx_pow_qos_thrx_s cn56xxp1;
486 struct cvmx_pow_qos_thrx_s cn58xx; 505 struct cvmx_pow_qos_thrx_s cn58xx;
487 struct cvmx_pow_qos_thrx_s cn58xxp1; 506 struct cvmx_pow_qos_thrx_s cn58xxp1;
507 struct cvmx_pow_qos_thrx_cn63xx {
508 uint64_t reserved_59_63:5;
509 uint64_t des_cnt:11;
510 uint64_t reserved_47_47:1;
511 uint64_t buf_cnt:11;
512 uint64_t reserved_35_35:1;
513 uint64_t free_cnt:11;
514 uint64_t reserved_22_23:2;
515 uint64_t max_thr:10;
516 uint64_t reserved_10_11:2;
517 uint64_t min_thr:10;
518 } cn63xx;
519 struct cvmx_pow_qos_thrx_cn63xx cn63xxp1;
488}; 520};
489 521
490union cvmx_pow_ts_pc { 522union cvmx_pow_ts_pc {
@@ -504,6 +536,8 @@ union cvmx_pow_ts_pc {
504 struct cvmx_pow_ts_pc_s cn56xxp1; 536 struct cvmx_pow_ts_pc_s cn56xxp1;
505 struct cvmx_pow_ts_pc_s cn58xx; 537 struct cvmx_pow_ts_pc_s cn58xx;
506 struct cvmx_pow_ts_pc_s cn58xxp1; 538 struct cvmx_pow_ts_pc_s cn58xxp1;
539 struct cvmx_pow_ts_pc_s cn63xx;
540 struct cvmx_pow_ts_pc_s cn63xxp1;
507}; 541};
508 542
509union cvmx_pow_wa_com_pc { 543union cvmx_pow_wa_com_pc {
@@ -523,6 +557,8 @@ union cvmx_pow_wa_com_pc {
523 struct cvmx_pow_wa_com_pc_s cn56xxp1; 557 struct cvmx_pow_wa_com_pc_s cn56xxp1;
524 struct cvmx_pow_wa_com_pc_s cn58xx; 558 struct cvmx_pow_wa_com_pc_s cn58xx;
525 struct cvmx_pow_wa_com_pc_s cn58xxp1; 559 struct cvmx_pow_wa_com_pc_s cn58xxp1;
560 struct cvmx_pow_wa_com_pc_s cn63xx;
561 struct cvmx_pow_wa_com_pc_s cn63xxp1;
526}; 562};
527 563
528union cvmx_pow_wa_pcx { 564union cvmx_pow_wa_pcx {
@@ -542,6 +578,8 @@ union cvmx_pow_wa_pcx {
542 struct cvmx_pow_wa_pcx_s cn56xxp1; 578 struct cvmx_pow_wa_pcx_s cn56xxp1;
543 struct cvmx_pow_wa_pcx_s cn58xx; 579 struct cvmx_pow_wa_pcx_s cn58xx;
544 struct cvmx_pow_wa_pcx_s cn58xxp1; 580 struct cvmx_pow_wa_pcx_s cn58xxp1;
581 struct cvmx_pow_wa_pcx_s cn63xx;
582 struct cvmx_pow_wa_pcx_s cn63xxp1;
545}; 583};
546 584
547union cvmx_pow_wq_int { 585union cvmx_pow_wq_int {
@@ -562,6 +600,8 @@ union cvmx_pow_wq_int {
562 struct cvmx_pow_wq_int_s cn56xxp1; 600 struct cvmx_pow_wq_int_s cn56xxp1;
563 struct cvmx_pow_wq_int_s cn58xx; 601 struct cvmx_pow_wq_int_s cn58xx;
564 struct cvmx_pow_wq_int_s cn58xxp1; 602 struct cvmx_pow_wq_int_s cn58xxp1;
603 struct cvmx_pow_wq_int_s cn63xx;
604 struct cvmx_pow_wq_int_s cn63xxp1;
565}; 605};
566 606
567union cvmx_pow_wq_int_cntx { 607union cvmx_pow_wq_int_cntx {
@@ -604,6 +644,15 @@ union cvmx_pow_wq_int_cntx {
604 struct cvmx_pow_wq_int_cntx_s cn56xxp1; 644 struct cvmx_pow_wq_int_cntx_s cn56xxp1;
605 struct cvmx_pow_wq_int_cntx_s cn58xx; 645 struct cvmx_pow_wq_int_cntx_s cn58xx;
606 struct cvmx_pow_wq_int_cntx_s cn58xxp1; 646 struct cvmx_pow_wq_int_cntx_s cn58xxp1;
647 struct cvmx_pow_wq_int_cntx_cn63xx {
648 uint64_t reserved_28_63:36;
649 uint64_t tc_cnt:4;
650 uint64_t reserved_23_23:1;
651 uint64_t ds_cnt:11;
652 uint64_t reserved_11_11:1;
653 uint64_t iq_cnt:11;
654 } cn63xx;
655 struct cvmx_pow_wq_int_cntx_cn63xx cn63xxp1;
607}; 656};
608 657
609union cvmx_pow_wq_int_pc { 658union cvmx_pow_wq_int_pc {
@@ -626,6 +675,8 @@ union cvmx_pow_wq_int_pc {
626 struct cvmx_pow_wq_int_pc_s cn56xxp1; 675 struct cvmx_pow_wq_int_pc_s cn56xxp1;
627 struct cvmx_pow_wq_int_pc_s cn58xx; 676 struct cvmx_pow_wq_int_pc_s cn58xx;
628 struct cvmx_pow_wq_int_pc_s cn58xxp1; 677 struct cvmx_pow_wq_int_pc_s cn58xxp1;
678 struct cvmx_pow_wq_int_pc_s cn63xx;
679 struct cvmx_pow_wq_int_pc_s cn63xxp1;
629}; 680};
630 681
631union cvmx_pow_wq_int_thrx { 682union cvmx_pow_wq_int_thrx {
@@ -674,6 +725,16 @@ union cvmx_pow_wq_int_thrx {
674 struct cvmx_pow_wq_int_thrx_s cn56xxp1; 725 struct cvmx_pow_wq_int_thrx_s cn56xxp1;
675 struct cvmx_pow_wq_int_thrx_s cn58xx; 726 struct cvmx_pow_wq_int_thrx_s cn58xx;
676 struct cvmx_pow_wq_int_thrx_s cn58xxp1; 727 struct cvmx_pow_wq_int_thrx_s cn58xxp1;
728 struct cvmx_pow_wq_int_thrx_cn63xx {
729 uint64_t reserved_29_63:35;
730 uint64_t tc_en:1;
731 uint64_t tc_thr:4;
732 uint64_t reserved_22_23:2;
733 uint64_t ds_thr:10;
734 uint64_t reserved_10_11:2;
735 uint64_t iq_thr:10;
736 } cn63xx;
737 struct cvmx_pow_wq_int_thrx_cn63xx cn63xxp1;
677}; 738};
678 739
679union cvmx_pow_ws_pcx { 740union cvmx_pow_ws_pcx {
@@ -693,6 +754,8 @@ union cvmx_pow_ws_pcx {
693 struct cvmx_pow_ws_pcx_s cn56xxp1; 754 struct cvmx_pow_ws_pcx_s cn56xxp1;
694 struct cvmx_pow_ws_pcx_s cn58xx; 755 struct cvmx_pow_ws_pcx_s cn58xx;
695 struct cvmx_pow_ws_pcx_s cn58xxp1; 756 struct cvmx_pow_ws_pcx_s cn58xxp1;
757 struct cvmx_pow_ws_pcx_s cn63xx;
758 struct cvmx_pow_ws_pcx_s cn63xxp1;
696}; 759};
697 760
698#endif 761#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-rnm-defs.h b/arch/mips/include/asm/octeon/cvmx-rnm-defs.h
index 4586958c97be..c45da1f35ea7 100644
--- a/arch/mips/include/asm/octeon/cvmx-rnm-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-rnm-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -30,10 +30,11 @@
30 30
31#include <linux/types.h> 31#include <linux/types.h>
32 32
33#define CVMX_RNM_BIST_STATUS \ 33#define CVMX_RNM_BIST_STATUS (CVMX_ADD_IO_SEG(0x0001180040000008ull))
34 CVMX_ADD_IO_SEG(0x0001180040000008ull) 34#define CVMX_RNM_CTL_STATUS (CVMX_ADD_IO_SEG(0x0001180040000000ull))
35#define CVMX_RNM_CTL_STATUS \ 35#define CVMX_RNM_EER_DBG (CVMX_ADD_IO_SEG(0x0001180040000018ull))
36 CVMX_ADD_IO_SEG(0x0001180040000000ull) 36#define CVMX_RNM_EER_KEY (CVMX_ADD_IO_SEG(0x0001180040000010ull))
37#define CVMX_RNM_SERIAL_NUM (CVMX_ADD_IO_SEG(0x0001180040000020ull))
37 38
38union cvmx_rnm_bist_status { 39union cvmx_rnm_bist_status {
39 uint64_t u64; 40 uint64_t u64;
@@ -53,12 +54,16 @@ union cvmx_rnm_bist_status {
53 struct cvmx_rnm_bist_status_s cn56xxp1; 54 struct cvmx_rnm_bist_status_s cn56xxp1;
54 struct cvmx_rnm_bist_status_s cn58xx; 55 struct cvmx_rnm_bist_status_s cn58xx;
55 struct cvmx_rnm_bist_status_s cn58xxp1; 56 struct cvmx_rnm_bist_status_s cn58xxp1;
57 struct cvmx_rnm_bist_status_s cn63xx;
58 struct cvmx_rnm_bist_status_s cn63xxp1;
56}; 59};
57 60
58union cvmx_rnm_ctl_status { 61union cvmx_rnm_ctl_status {
59 uint64_t u64; 62 uint64_t u64;
60 struct cvmx_rnm_ctl_status_s { 63 struct cvmx_rnm_ctl_status_s {
61 uint64_t reserved_9_63:55; 64 uint64_t reserved_11_63:53;
65 uint64_t eer_lck:1;
66 uint64_t eer_val:1;
62 uint64_t ent_sel:4; 67 uint64_t ent_sel:4;
63 uint64_t exp_ent:1; 68 uint64_t exp_ent:1;
64 uint64_t rng_rst:1; 69 uint64_t rng_rst:1;
@@ -76,13 +81,49 @@ union cvmx_rnm_ctl_status {
76 struct cvmx_rnm_ctl_status_cn30xx cn31xx; 81 struct cvmx_rnm_ctl_status_cn30xx cn31xx;
77 struct cvmx_rnm_ctl_status_cn30xx cn38xx; 82 struct cvmx_rnm_ctl_status_cn30xx cn38xx;
78 struct cvmx_rnm_ctl_status_cn30xx cn38xxp2; 83 struct cvmx_rnm_ctl_status_cn30xx cn38xxp2;
79 struct cvmx_rnm_ctl_status_s cn50xx; 84 struct cvmx_rnm_ctl_status_cn50xx {
80 struct cvmx_rnm_ctl_status_s cn52xx; 85 uint64_t reserved_9_63:55;
81 struct cvmx_rnm_ctl_status_s cn52xxp1; 86 uint64_t ent_sel:4;
82 struct cvmx_rnm_ctl_status_s cn56xx; 87 uint64_t exp_ent:1;
83 struct cvmx_rnm_ctl_status_s cn56xxp1; 88 uint64_t rng_rst:1;
84 struct cvmx_rnm_ctl_status_s cn58xx; 89 uint64_t rnm_rst:1;
85 struct cvmx_rnm_ctl_status_s cn58xxp1; 90 uint64_t rng_en:1;
91 uint64_t ent_en:1;
92 } cn50xx;
93 struct cvmx_rnm_ctl_status_cn50xx cn52xx;
94 struct cvmx_rnm_ctl_status_cn50xx cn52xxp1;
95 struct cvmx_rnm_ctl_status_cn50xx cn56xx;
96 struct cvmx_rnm_ctl_status_cn50xx cn56xxp1;
97 struct cvmx_rnm_ctl_status_cn50xx cn58xx;
98 struct cvmx_rnm_ctl_status_cn50xx cn58xxp1;
99 struct cvmx_rnm_ctl_status_s cn63xx;
100 struct cvmx_rnm_ctl_status_s cn63xxp1;
101};
102
103union cvmx_rnm_eer_dbg {
104 uint64_t u64;
105 struct cvmx_rnm_eer_dbg_s {
106 uint64_t dat:64;
107 } s;
108 struct cvmx_rnm_eer_dbg_s cn63xx;
109 struct cvmx_rnm_eer_dbg_s cn63xxp1;
110};
111
112union cvmx_rnm_eer_key {
113 uint64_t u64;
114 struct cvmx_rnm_eer_key_s {
115 uint64_t key:64;
116 } s;
117 struct cvmx_rnm_eer_key_s cn63xx;
118 struct cvmx_rnm_eer_key_s cn63xxp1;
119};
120
121union cvmx_rnm_serial_num {
122 uint64_t u64;
123 struct cvmx_rnm_serial_num_s {
124 uint64_t dat:64;
125 } s;
126 struct cvmx_rnm_serial_num_s cn63xx;
86}; 127};
87 128
88#endif 129#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-smix-defs.h b/arch/mips/include/asm/octeon/cvmx-smix-defs.h
index 9ae45fcbe3e3..4f3c0666e94a 100644
--- a/arch/mips/include/asm/octeon/cvmx-smix-defs.h
+++ b/arch/mips/include/asm/octeon/cvmx-smix-defs.h
@@ -4,7 +4,7 @@
4 * Contact: support@caviumnetworks.com 4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK 5 * This file is part of the OCTEON SDK
6 * 6 *
7 * Copyright (c) 2003-2008 Cavium Networks 7 * Copyright (c) 2003-2010 Cavium Networks
8 * 8 *
9 * This file is free software; you can redistribute it and/or modify 9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as 10 * it under the terms of the GNU General Public License, Version 2, as
@@ -28,16 +28,11 @@
28#ifndef __CVMX_SMIX_DEFS_H__ 28#ifndef __CVMX_SMIX_DEFS_H__
29#define __CVMX_SMIX_DEFS_H__ 29#define __CVMX_SMIX_DEFS_H__
30 30
31#define CVMX_SMIX_CLK(offset) \ 31#define CVMX_SMIX_CLK(offset) (CVMX_ADD_IO_SEG(0x0001180000001818ull) + ((offset) & 1) * 256)
32 CVMX_ADD_IO_SEG(0x0001180000001818ull + (((offset) & 1) * 256)) 32#define CVMX_SMIX_CMD(offset) (CVMX_ADD_IO_SEG(0x0001180000001800ull) + ((offset) & 1) * 256)
33#define CVMX_SMIX_CMD(offset) \ 33#define CVMX_SMIX_EN(offset) (CVMX_ADD_IO_SEG(0x0001180000001820ull) + ((offset) & 1) * 256)
34 CVMX_ADD_IO_SEG(0x0001180000001800ull + (((offset) & 1) * 256)) 34#define CVMX_SMIX_RD_DAT(offset) (CVMX_ADD_IO_SEG(0x0001180000001810ull) + ((offset) & 1) * 256)
35#define CVMX_SMIX_EN(offset) \ 35#define CVMX_SMIX_WR_DAT(offset) (CVMX_ADD_IO_SEG(0x0001180000001808ull) + ((offset) & 1) * 256)
36 CVMX_ADD_IO_SEG(0x0001180000001820ull + (((offset) & 1) * 256))
37#define CVMX_SMIX_RD_DAT(offset) \
38 CVMX_ADD_IO_SEG(0x0001180000001810ull + (((offset) & 1) * 256))
39#define CVMX_SMIX_WR_DAT(offset) \
40 CVMX_ADD_IO_SEG(0x0001180000001808ull + (((offset) & 1) * 256))
41 36
42union cvmx_smix_clk { 37union cvmx_smix_clk {
43 uint64_t u64; 38 uint64_t u64;
@@ -56,7 +51,8 @@ union cvmx_smix_clk {
56 struct cvmx_smix_clk_cn30xx { 51 struct cvmx_smix_clk_cn30xx {
57 uint64_t reserved_21_63:43; 52 uint64_t reserved_21_63:43;
58 uint64_t sample_hi:5; 53 uint64_t sample_hi:5;
59 uint64_t reserved_14_15:2; 54 uint64_t sample_mode:1;
55 uint64_t reserved_14_14:1;
60 uint64_t clk_idle:1; 56 uint64_t clk_idle:1;
61 uint64_t preamble:1; 57 uint64_t preamble:1;
62 uint64_t sample:4; 58 uint64_t sample:4;
@@ -65,23 +61,15 @@ union cvmx_smix_clk {
65 struct cvmx_smix_clk_cn30xx cn31xx; 61 struct cvmx_smix_clk_cn30xx cn31xx;
66 struct cvmx_smix_clk_cn30xx cn38xx; 62 struct cvmx_smix_clk_cn30xx cn38xx;
67 struct cvmx_smix_clk_cn30xx cn38xxp2; 63 struct cvmx_smix_clk_cn30xx cn38xxp2;
68 struct cvmx_smix_clk_cn50xx { 64 struct cvmx_smix_clk_s cn50xx;
69 uint64_t reserved_25_63:39;
70 uint64_t mode:1;
71 uint64_t reserved_21_23:3;
72 uint64_t sample_hi:5;
73 uint64_t reserved_14_15:2;
74 uint64_t clk_idle:1;
75 uint64_t preamble:1;
76 uint64_t sample:4;
77 uint64_t phase:8;
78 } cn50xx;
79 struct cvmx_smix_clk_s cn52xx; 65 struct cvmx_smix_clk_s cn52xx;
80 struct cvmx_smix_clk_cn50xx cn52xxp1; 66 struct cvmx_smix_clk_s cn52xxp1;
81 struct cvmx_smix_clk_s cn56xx; 67 struct cvmx_smix_clk_s cn56xx;
82 struct cvmx_smix_clk_cn50xx cn56xxp1; 68 struct cvmx_smix_clk_s cn56xxp1;
83 struct cvmx_smix_clk_cn30xx cn58xx; 69 struct cvmx_smix_clk_cn30xx cn58xx;
84 struct cvmx_smix_clk_cn30xx cn58xxp1; 70 struct cvmx_smix_clk_cn30xx cn58xxp1;
71 struct cvmx_smix_clk_s cn63xx;
72 struct cvmx_smix_clk_s cn63xxp1;
85}; 73};
86 74
87union cvmx_smix_cmd { 75union cvmx_smix_cmd {
@@ -112,6 +100,8 @@ union cvmx_smix_cmd {
112 struct cvmx_smix_cmd_s cn56xxp1; 100 struct cvmx_smix_cmd_s cn56xxp1;
113 struct cvmx_smix_cmd_cn30xx cn58xx; 101 struct cvmx_smix_cmd_cn30xx cn58xx;
114 struct cvmx_smix_cmd_cn30xx cn58xxp1; 102 struct cvmx_smix_cmd_cn30xx cn58xxp1;
103 struct cvmx_smix_cmd_s cn63xx;
104 struct cvmx_smix_cmd_s cn63xxp1;
115}; 105};
116 106
117union cvmx_smix_en { 107union cvmx_smix_en {
@@ -131,6 +121,8 @@ union cvmx_smix_en {
131 struct cvmx_smix_en_s cn56xxp1; 121 struct cvmx_smix_en_s cn56xxp1;
132 struct cvmx_smix_en_s cn58xx; 122 struct cvmx_smix_en_s cn58xx;
133 struct cvmx_smix_en_s cn58xxp1; 123 struct cvmx_smix_en_s cn58xxp1;
124 struct cvmx_smix_en_s cn63xx;
125 struct cvmx_smix_en_s cn63xxp1;
134}; 126};
135 127
136union cvmx_smix_rd_dat { 128union cvmx_smix_rd_dat {
@@ -152,6 +144,8 @@ union cvmx_smix_rd_dat {
152 struct cvmx_smix_rd_dat_s cn56xxp1; 144 struct cvmx_smix_rd_dat_s cn56xxp1;
153 struct cvmx_smix_rd_dat_s cn58xx; 145 struct cvmx_smix_rd_dat_s cn58xx;
154 struct cvmx_smix_rd_dat_s cn58xxp1; 146 struct cvmx_smix_rd_dat_s cn58xxp1;
147 struct cvmx_smix_rd_dat_s cn63xx;
148 struct cvmx_smix_rd_dat_s cn63xxp1;
155}; 149};
156 150
157union cvmx_smix_wr_dat { 151union cvmx_smix_wr_dat {
@@ -173,6 +167,8 @@ union cvmx_smix_wr_dat {
173 struct cvmx_smix_wr_dat_s cn56xxp1; 167 struct cvmx_smix_wr_dat_s cn56xxp1;
174 struct cvmx_smix_wr_dat_s cn58xx; 168 struct cvmx_smix_wr_dat_s cn58xx;
175 struct cvmx_smix_wr_dat_s cn58xxp1; 169 struct cvmx_smix_wr_dat_s cn58xxp1;
170 struct cvmx_smix_wr_dat_s cn63xx;
171 struct cvmx_smix_wr_dat_s cn63xxp1;
176}; 172};
177 173
178#endif 174#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-uctlx-defs.h b/arch/mips/include/asm/octeon/cvmx-uctlx-defs.h
new file mode 100644
index 000000000000..594f1b68cd62
--- /dev/null
+++ b/arch/mips/include/asm/octeon/cvmx-uctlx-defs.h
@@ -0,0 +1,261 @@
1/***********************license start***************
2 * Author: Cavium Networks
3 *
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
6 *
7 * Copyright (c) 2003-2010 Cavium Networks
8 *
9 * This file 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 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
23 *
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
27
28#ifndef __CVMX_UCTLX_TYPEDEFS_H__
29#define __CVMX_UCTLX_TYPEDEFS_H__
30
31#define CVMX_UCTLX_BIST_STATUS(block_id) (CVMX_ADD_IO_SEG(0x000118006F0000A0ull))
32#define CVMX_UCTLX_CLK_RST_CTL(block_id) (CVMX_ADD_IO_SEG(0x000118006F000000ull))
33#define CVMX_UCTLX_EHCI_CTL(block_id) (CVMX_ADD_IO_SEG(0x000118006F000080ull))
34#define CVMX_UCTLX_EHCI_FLA(block_id) (CVMX_ADD_IO_SEG(0x000118006F0000A8ull))
35#define CVMX_UCTLX_ERTO_CTL(block_id) (CVMX_ADD_IO_SEG(0x000118006F000090ull))
36#define CVMX_UCTLX_IF_ENA(block_id) (CVMX_ADD_IO_SEG(0x000118006F000030ull))
37#define CVMX_UCTLX_INT_ENA(block_id) (CVMX_ADD_IO_SEG(0x000118006F000028ull))
38#define CVMX_UCTLX_INT_REG(block_id) (CVMX_ADD_IO_SEG(0x000118006F000020ull))
39#define CVMX_UCTLX_OHCI_CTL(block_id) (CVMX_ADD_IO_SEG(0x000118006F000088ull))
40#define CVMX_UCTLX_ORTO_CTL(block_id) (CVMX_ADD_IO_SEG(0x000118006F000098ull))
41#define CVMX_UCTLX_PPAF_WM(block_id) (CVMX_ADD_IO_SEG(0x000118006F000038ull))
42#define CVMX_UCTLX_UPHY_CTL_STATUS(block_id) (CVMX_ADD_IO_SEG(0x000118006F000008ull))
43#define CVMX_UCTLX_UPHY_PORTX_CTL_STATUS(offset, block_id) (CVMX_ADD_IO_SEG(0x000118006F000010ull) + (((offset) & 1) + ((block_id) & 0) * 0x0ull) * 8)
44
45union cvmx_uctlx_bist_status {
46 uint64_t u64;
47 struct cvmx_uctlx_bist_status_s {
48 uint64_t reserved_6_63:58;
49 uint64_t data_bis:1;
50 uint64_t desc_bis:1;
51 uint64_t erbm_bis:1;
52 uint64_t orbm_bis:1;
53 uint64_t wrbm_bis:1;
54 uint64_t ppaf_bis:1;
55 } s;
56 struct cvmx_uctlx_bist_status_s cn63xx;
57 struct cvmx_uctlx_bist_status_s cn63xxp1;
58};
59
60union cvmx_uctlx_clk_rst_ctl {
61 uint64_t u64;
62 struct cvmx_uctlx_clk_rst_ctl_s {
63 uint64_t reserved_25_63:39;
64 uint64_t clear_bist:1;
65 uint64_t start_bist:1;
66 uint64_t ehci_sm:1;
67 uint64_t ohci_clkcktrst:1;
68 uint64_t ohci_sm:1;
69 uint64_t ohci_susp_lgcy:1;
70 uint64_t app_start_clk:1;
71 uint64_t o_clkdiv_rst:1;
72 uint64_t h_clkdiv_byp:1;
73 uint64_t h_clkdiv_rst:1;
74 uint64_t h_clkdiv_en:1;
75 uint64_t o_clkdiv_en:1;
76 uint64_t h_div:4;
77 uint64_t p_refclk_sel:2;
78 uint64_t p_refclk_div:2;
79 uint64_t reserved_4_4:1;
80 uint64_t p_com_on:1;
81 uint64_t p_por:1;
82 uint64_t p_prst:1;
83 uint64_t hrst:1;
84 } s;
85 struct cvmx_uctlx_clk_rst_ctl_s cn63xx;
86 struct cvmx_uctlx_clk_rst_ctl_s cn63xxp1;
87};
88
89union cvmx_uctlx_ehci_ctl {
90 uint64_t u64;
91 struct cvmx_uctlx_ehci_ctl_s {
92 uint64_t reserved_20_63:44;
93 uint64_t desc_rbm:1;
94 uint64_t reg_nb:1;
95 uint64_t l2c_dc:1;
96 uint64_t l2c_bc:1;
97 uint64_t l2c_0pag:1;
98 uint64_t l2c_stt:1;
99 uint64_t l2c_buff_emod:2;
100 uint64_t l2c_desc_emod:2;
101 uint64_t inv_reg_a2:1;
102 uint64_t ehci_64b_addr_en:1;
103 uint64_t l2c_addr_msb:8;
104 } s;
105 struct cvmx_uctlx_ehci_ctl_s cn63xx;
106 struct cvmx_uctlx_ehci_ctl_s cn63xxp1;
107};
108
109union cvmx_uctlx_ehci_fla {
110 uint64_t u64;
111 struct cvmx_uctlx_ehci_fla_s {
112 uint64_t reserved_6_63:58;
113 uint64_t fla:6;
114 } s;
115 struct cvmx_uctlx_ehci_fla_s cn63xx;
116 struct cvmx_uctlx_ehci_fla_s cn63xxp1;
117};
118
119union cvmx_uctlx_erto_ctl {
120 uint64_t u64;
121 struct cvmx_uctlx_erto_ctl_s {
122 uint64_t reserved_32_63:32;
123 uint64_t to_val:27;
124 uint64_t reserved_0_4:5;
125 } s;
126 struct cvmx_uctlx_erto_ctl_s cn63xx;
127 struct cvmx_uctlx_erto_ctl_s cn63xxp1;
128};
129
130union cvmx_uctlx_if_ena {
131 uint64_t u64;
132 struct cvmx_uctlx_if_ena_s {
133 uint64_t reserved_1_63:63;
134 uint64_t en:1;
135 } s;
136 struct cvmx_uctlx_if_ena_s cn63xx;
137 struct cvmx_uctlx_if_ena_s cn63xxp1;
138};
139
140union cvmx_uctlx_int_ena {
141 uint64_t u64;
142 struct cvmx_uctlx_int_ena_s {
143 uint64_t reserved_8_63:56;
144 uint64_t ec_ovf_e:1;
145 uint64_t oc_ovf_e:1;
146 uint64_t wb_pop_e:1;
147 uint64_t wb_psh_f:1;
148 uint64_t cf_psh_f:1;
149 uint64_t or_psh_f:1;
150 uint64_t er_psh_f:1;
151 uint64_t pp_psh_f:1;
152 } s;
153 struct cvmx_uctlx_int_ena_s cn63xx;
154 struct cvmx_uctlx_int_ena_s cn63xxp1;
155};
156
157union cvmx_uctlx_int_reg {
158 uint64_t u64;
159 struct cvmx_uctlx_int_reg_s {
160 uint64_t reserved_8_63:56;
161 uint64_t ec_ovf_e:1;
162 uint64_t oc_ovf_e:1;
163 uint64_t wb_pop_e:1;
164 uint64_t wb_psh_f:1;
165 uint64_t cf_psh_f:1;
166 uint64_t or_psh_f:1;
167 uint64_t er_psh_f:1;
168 uint64_t pp_psh_f:1;
169 } s;
170 struct cvmx_uctlx_int_reg_s cn63xx;
171 struct cvmx_uctlx_int_reg_s cn63xxp1;
172};
173
174union cvmx_uctlx_ohci_ctl {
175 uint64_t u64;
176 struct cvmx_uctlx_ohci_ctl_s {
177 uint64_t reserved_19_63:45;
178 uint64_t reg_nb:1;
179 uint64_t l2c_dc:1;
180 uint64_t l2c_bc:1;
181 uint64_t l2c_0pag:1;
182 uint64_t l2c_stt:1;
183 uint64_t l2c_buff_emod:2;
184 uint64_t l2c_desc_emod:2;
185 uint64_t inv_reg_a2:1;
186 uint64_t reserved_8_8:1;
187 uint64_t l2c_addr_msb:8;
188 } s;
189 struct cvmx_uctlx_ohci_ctl_s cn63xx;
190 struct cvmx_uctlx_ohci_ctl_s cn63xxp1;
191};
192
193union cvmx_uctlx_orto_ctl {
194 uint64_t u64;
195 struct cvmx_uctlx_orto_ctl_s {
196 uint64_t reserved_32_63:32;
197 uint64_t to_val:24;
198 uint64_t reserved_0_7:8;
199 } s;
200 struct cvmx_uctlx_orto_ctl_s cn63xx;
201 struct cvmx_uctlx_orto_ctl_s cn63xxp1;
202};
203
204union cvmx_uctlx_ppaf_wm {
205 uint64_t u64;
206 struct cvmx_uctlx_ppaf_wm_s {
207 uint64_t reserved_5_63:59;
208 uint64_t wm:5;
209 } s;
210 struct cvmx_uctlx_ppaf_wm_s cn63xx;
211 struct cvmx_uctlx_ppaf_wm_s cn63xxp1;
212};
213
214union cvmx_uctlx_uphy_ctl_status {
215 uint64_t u64;
216 struct cvmx_uctlx_uphy_ctl_status_s {
217 uint64_t reserved_10_63:54;
218 uint64_t bist_done:1;
219 uint64_t bist_err:1;
220 uint64_t hsbist:1;
221 uint64_t fsbist:1;
222 uint64_t lsbist:1;
223 uint64_t siddq:1;
224 uint64_t vtest_en:1;
225 uint64_t uphy_bist:1;
226 uint64_t bist_en:1;
227 uint64_t ate_reset:1;
228 } s;
229 struct cvmx_uctlx_uphy_ctl_status_s cn63xx;
230 struct cvmx_uctlx_uphy_ctl_status_s cn63xxp1;
231};
232
233union cvmx_uctlx_uphy_portx_ctl_status {
234 uint64_t u64;
235 struct cvmx_uctlx_uphy_portx_ctl_status_s {
236 uint64_t reserved_43_63:21;
237 uint64_t tdata_out:4;
238 uint64_t txbiststuffenh:1;
239 uint64_t txbiststuffen:1;
240 uint64_t dmpulldown:1;
241 uint64_t dppulldown:1;
242 uint64_t vbusvldext:1;
243 uint64_t portreset:1;
244 uint64_t txhsvxtune:2;
245 uint64_t txvreftune:4;
246 uint64_t txrisetune:1;
247 uint64_t txpreemphasistune:1;
248 uint64_t txfslstune:4;
249 uint64_t sqrxtune:3;
250 uint64_t compdistune:3;
251 uint64_t loop_en:1;
252 uint64_t tclk:1;
253 uint64_t tdata_sel:1;
254 uint64_t taddr_in:4;
255 uint64_t tdata_in:8;
256 } s;
257 struct cvmx_uctlx_uphy_portx_ctl_status_s cn63xx;
258 struct cvmx_uctlx_uphy_portx_ctl_status_s cn63xxp1;
259};
260
261#endif
diff --git a/arch/mips/include/asm/octeon/octeon-model.h b/arch/mips/include/asm/octeon/octeon-model.h
index cf50336eca2e..700f88e31cad 100644
--- a/arch/mips/include/asm/octeon/octeon-model.h
+++ b/arch/mips/include/asm/octeon/octeon-model.h
@@ -35,14 +35,6 @@
35#ifndef __OCTEON_MODEL_H__ 35#ifndef __OCTEON_MODEL_H__
36#define __OCTEON_MODEL_H__ 36#define __OCTEON_MODEL_H__
37 37
38/* NOTE: These must match what is checked in common-config.mk */
39/* Defines to represent the different versions of Octeon. */
40
41/*
42 * IMPORTANT: When the default pass is updated for an Octeon Model,
43 * the corresponding change must also be made in the oct-sim script.
44 */
45
46/* 38/*
47 * The defines below should be used with the OCTEON_IS_MODEL() macro 39 * The defines below should be used with the OCTEON_IS_MODEL() macro
48 * to determine what model of chip the software is running on. Models 40 * to determine what model of chip the software is running on. Models
@@ -71,6 +63,21 @@
71#define OM_IGNORE_MINOR_REVISION 0x08000000 63#define OM_IGNORE_MINOR_REVISION 0x08000000
72#define OM_FLAG_MASK 0xff000000 64#define OM_FLAG_MASK 0xff000000
73 65
66#define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000 /* Match all cn5XXX Octeon models. */
67#define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000 /* Match all cn6XXX Octeon models. */
68
69/*
70 * CN6XXX models with new revision encoding
71 */
72#define OCTEON_CN63XX_PASS1_0 0x000d9000
73#define OCTEON_CN63XX_PASS1_1 0x000d9001
74#define OCTEON_CN63XX_PASS1_2 0x000d9002
75#define OCTEON_CN63XX_PASS2_0 0x000d9008
76
77#define OCTEON_CN63XX (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
78#define OCTEON_CN63XX_PASS1_X (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
79#define OCTEON_CN63XX_PASS2_X (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
80
74/* 81/*
75 * CN5XXX models with new revision encoding 82 * CN5XXX models with new revision encoding
76 */ 83 */
@@ -189,6 +196,9 @@
189 | OM_MATCH_PREVIOUS_MODELS \ 196 | OM_MATCH_PREVIOUS_MODELS \
190 | OM_IGNORE_REVISION) 197 | OM_IGNORE_REVISION)
191 198
199#define OCTEON_CN5XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
200#define OCTEON_CN6XXX (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
201
192/* The revision byte (low byte) has two different encodings. 202/* The revision byte (low byte) has two different encodings.
193 * CN3XXX: 203 * CN3XXX:
194 * 204 *
@@ -222,6 +232,7 @@
222 | OCTEON_58XX_MODEL_MASK) 232 | OCTEON_58XX_MODEL_MASK)
223#define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK \ 233#define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK \
224 & 0x00fffff8) 234 & 0x00fffff8)
235#define OCTEON_5XXX_MODEL_MASK 0x00ff0fc0
225 236
226#define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z))) 237#define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
227 238
@@ -273,6 +284,15 @@ static inline int __OCTEON_IS_MODEL_COMPILE__(uint32_t arg_model,
273 __OCTEON_MATCH_MASK__((chip_model), (arg_model), 284 __OCTEON_MATCH_MASK__((chip_model), (arg_model),
274 OCTEON_58XX_MODEL_REV_MASK)) 285 OCTEON_58XX_MODEL_REV_MASK))
275 return 1; 286 return 1;
287
288 if (((arg_model & OM_MATCH_5XXX_FAMILY_MODELS) == OM_MATCH_5XXX_FAMILY_MODELS) &&
289 ((chip_model) >= OCTEON_CN58XX_PASS1_0) && ((chip_model) < OCTEON_CN63XX_PASS1_0))
290 return 1;
291
292 if (((arg_model & OM_MATCH_6XXX_FAMILY_MODELS) == OM_MATCH_6XXX_FAMILY_MODELS) &&
293 ((chip_model) >= OCTEON_CN63XX_PASS1_0))
294 return 1;
295
276 if ((arg_model & OM_MATCH_PREVIOUS_MODELS) && 296 if ((arg_model & OM_MATCH_PREVIOUS_MODELS) &&
277 ((chip_model & OCTEON_58XX_MODEL_MASK) < 297 ((chip_model & OCTEON_58XX_MODEL_MASK) <
278 (arg_model & OCTEON_58XX_MODEL_MASK))) 298 (arg_model & OCTEON_58XX_MODEL_MASK)))
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h
index 917a6c413b1a..6b34afd0d4e7 100644
--- a/arch/mips/include/asm/octeon/octeon.h
+++ b/arch/mips/include/asm/octeon/octeon.h
@@ -35,6 +35,7 @@ extern int octeon_is_simulation(void);
35extern int octeon_is_pci_host(void); 35extern int octeon_is_pci_host(void);
36extern int octeon_usb_is_ref_clk(void); 36extern int octeon_usb_is_ref_clk(void);
37extern uint64_t octeon_get_clock_rate(void); 37extern uint64_t octeon_get_clock_rate(void);
38extern u64 octeon_get_io_clock_rate(void);
38extern const char *octeon_board_type_string(void); 39extern const char *octeon_board_type_string(void);
39extern const char *octeon_get_pci_interrupts(void); 40extern const char *octeon_get_pci_interrupts(void);
40extern int octeon_get_southbridge_interrupt(void); 41extern int octeon_get_southbridge_interrupt(void);
diff --git a/arch/mips/include/asm/octeon/pci-octeon.h b/arch/mips/include/asm/octeon/pci-octeon.h
index ece78043acf6..fba2ba200f58 100644
--- a/arch/mips/include/asm/octeon/pci-octeon.h
+++ b/arch/mips/include/asm/octeon/pci-octeon.h
@@ -36,6 +36,16 @@ extern int (*octeon_pcibios_map_irq)(const struct pci_dev *dev,
36 u8 slot, u8 pin); 36 u8 slot, u8 pin);
37 37
38/* 38/*
39 * For PCI (not PCIe) the BAR2 base address.
40 */
41#define OCTEON_BAR2_PCI_ADDRESS 0x8000000000ull
42
43/*
44 * For PCI (not PCIe) the base of the memory mapped by BAR1
45 */
46extern u64 octeon_bar1_pci_phys;
47
48/*
39 * The following defines are used when octeon_dma_bar_type = 49 * The following defines are used when octeon_dma_bar_type =
40 * OCTEON_DMA_BAR_TYPE_BIG 50 * OCTEON_DMA_BAR_TYPE_BIG
41 */ 51 */
diff --git a/arch/mips/include/asm/pci/bridge.h b/arch/mips/include/asm/pci/bridge.h
index 5f4b9d4e4114..f1f508e4f971 100644
--- a/arch/mips/include/asm/pci/bridge.h
+++ b/arch/mips/include/asm/pci/bridge.h
@@ -839,7 +839,7 @@ struct bridge_controller {
839 nasid_t nasid; 839 nasid_t nasid;
840 unsigned int widget_id; 840 unsigned int widget_id;
841 unsigned int irq_cpu; 841 unsigned int irq_cpu;
842 dma64_addr_t baddr; 842 u64 baddr;
843 unsigned int pci_int[8]; 843 unsigned int pci_int[8];
844}; 844};
845 845
diff --git a/arch/mips/include/asm/perf_event.h b/arch/mips/include/asm/perf_event.h
new file mode 100644
index 000000000000..e00007cf8162
--- /dev/null
+++ b/arch/mips/include/asm/perf_event.h
@@ -0,0 +1,25 @@
1/*
2 * linux/arch/mips/include/asm/perf_event.h
3 *
4 * Copyright (C) 2010 MIPS Technologies, Inc.
5 * Author: Deng-Cheng Zhu
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
12#ifndef __MIPS_PERF_EVENT_H__
13#define __MIPS_PERF_EVENT_H__
14
15/*
16 * MIPS performance counters do not raise NMI upon overflow, a regular
17 * interrupt will be signaled. Hence we can do the pending perf event
18 * work at the tail of the irq handler.
19 */
20static inline void
21set_perf_event_pending(void)
22{
23}
24
25#endif /* __MIPS_PERF_EVENT_H__ */
diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h
index ae90412556d0..8a153d2fa62a 100644
--- a/arch/mips/include/asm/pgtable-32.h
+++ b/arch/mips/include/asm/pgtable-32.h
@@ -154,10 +154,7 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
154 154
155#define pte_offset_map(dir, address) \ 155#define pte_offset_map(dir, address) \
156 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 156 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
157#define pte_offset_map_nested(dir, address) \
158 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
159#define pte_unmap(pte) ((void)(pte)) 157#define pte_unmap(pte) ((void)(pte))
160#define pte_unmap_nested(pte) ((void)(pte))
161 158
162#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) 159#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
163 160
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 1be4b0fa30da..55908fd56b1f 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -113,10 +113,10 @@
113#endif 113#endif
114#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t)) 114#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
115 115
116#if PGDIR_SIZE >= TASK_SIZE 116#if PGDIR_SIZE >= TASK_SIZE64
117#define USER_PTRS_PER_PGD (1) 117#define USER_PTRS_PER_PGD (1)
118#else 118#else
119#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) 119#define USER_PTRS_PER_PGD (TASK_SIZE64 / PGDIR_SIZE)
120#endif 120#endif
121#define FIRST_USER_ADDRESS 0UL 121#define FIRST_USER_ADDRESS 0UL
122 122
@@ -257,10 +257,7 @@ static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
257 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 257 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
258#define pte_offset_map(dir, address) \ 258#define pte_offset_map(dir, address) \
259 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 259 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
260#define pte_offset_map_nested(dir, address) \
261 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
262#define pte_unmap(pte) ((void)(pte)) 260#define pte_unmap(pte) ((void)(pte))
263#define pte_unmap_nested(pte) ((void)(pte))
264 261
265/* 262/*
266 * Initialize a new pgd / pmd table with invalid pointers. 263 * Initialize a new pgd / pmd table with invalid pointers.
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 0d629bb93cbe..ead6928fa6b8 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -50,13 +50,10 @@ extern unsigned int vced_count, vcei_count;
50 * so don't change it unless you know what you are doing. 50 * so don't change it unless you know what you are doing.
51 */ 51 */
52#define TASK_SIZE 0x7fff8000UL 52#define TASK_SIZE 0x7fff8000UL
53#define STACK_TOP ((TASK_SIZE & PAGE_MASK) - SPECIAL_PAGES_SIZE)
54 53
55/* 54#ifdef __KERNEL__
56 * This decides where the kernel will search for a free chunk of vm 55#define STACK_TOP_MAX TASK_SIZE
57 * space during mmap's. 56#endif
58 */
59#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~(PAGE_SIZE))
60 57
61#define TASK_IS_32BIT_ADDR 1 58#define TASK_IS_32BIT_ADDR 1
62 59
@@ -71,28 +68,29 @@ extern unsigned int vced_count, vcei_count;
71 * 8192EB ... 68 * 8192EB ...
72 */ 69 */
73#define TASK_SIZE32 0x7fff8000UL 70#define TASK_SIZE32 0x7fff8000UL
74#define TASK_SIZE 0x10000000000UL 71#define TASK_SIZE64 0x10000000000UL
75#define STACK_TOP \ 72#define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
76 (((test_thread_flag(TIF_32BIT_ADDR) ? \ 73
77 TASK_SIZE32 : TASK_SIZE) & PAGE_MASK) - SPECIAL_PAGES_SIZE) 74#ifdef __KERNEL__
75#define STACK_TOP_MAX TASK_SIZE64
76#endif
77
78 78
79/*
80 * This decides where the kernel will search for a free chunk of vm
81 * space during mmap's.
82 */
83#define TASK_UNMAPPED_BASE \
84 (test_thread_flag(TIF_32BIT_ADDR) ? \
85 PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
86#define TASK_SIZE_OF(tsk) \ 79#define TASK_SIZE_OF(tsk) \
87 (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE) 80 (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
88 81
89#define TASK_IS_32BIT_ADDR test_thread_flag(TIF_32BIT_ADDR) 82#define TASK_IS_32BIT_ADDR test_thread_flag(TIF_32BIT_ADDR)
90 83
91#endif 84#endif
92 85
93#ifdef __KERNEL__ 86#define STACK_TOP ((TASK_SIZE & PAGE_MASK) - SPECIAL_PAGES_SIZE)
94#define STACK_TOP_MAX TASK_SIZE 87
95#endif 88/*
89 * This decides where the kernel will search for a free chunk of vm
90 * space during mmap's.
91 */
92#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
93
96 94
97#define NUM_FPU_REGS 32 95#define NUM_FPU_REGS 32
98 96
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/system.h b/arch/mips/include/asm/system.h
index bb937ccfba1e..6018c80ce37a 100644
--- a/arch/mips/include/asm/system.h
+++ b/arch/mips/include/asm/system.h
@@ -115,21 +115,19 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
115 } else if (kernel_uses_llsc) { 115 } else if (kernel_uses_llsc) {
116 unsigned long dummy; 116 unsigned long dummy;
117 117
118 __asm__ __volatile__( 118 do {
119 " .set mips3 \n" 119 __asm__ __volatile__(
120 "1: ll %0, %3 # xchg_u32 \n" 120 " .set mips3 \n"
121 " .set mips0 \n" 121 " ll %0, %3 # xchg_u32 \n"
122 " move %2, %z4 \n" 122 " .set mips0 \n"
123 " .set mips3 \n" 123 " move %2, %z4 \n"
124 " sc %2, %1 \n" 124 " .set mips3 \n"
125 " beqz %2, 2f \n" 125 " sc %2, %1 \n"
126 " .subsection 2 \n" 126 " .set mips0 \n"
127 "2: b 1b \n" 127 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
128 " .previous \n" 128 : "R" (*m), "Jr" (val)
129 " .set mips0 \n" 129 : "memory");
130 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 130 } while (unlikely(!dummy));
131 : "R" (*m), "Jr" (val)
132 : "memory");
133 } else { 131 } else {
134 unsigned long flags; 132 unsigned long flags;
135 133
@@ -167,19 +165,17 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
167 } else if (kernel_uses_llsc) { 165 } else if (kernel_uses_llsc) {
168 unsigned long dummy; 166 unsigned long dummy;
169 167
170 __asm__ __volatile__( 168 do {
171 " .set mips3 \n" 169 __asm__ __volatile__(
172 "1: lld %0, %3 # xchg_u64 \n" 170 " .set mips3 \n"
173 " move %2, %z4 \n" 171 " lld %0, %3 # xchg_u64 \n"
174 " scd %2, %1 \n" 172 " move %2, %z4 \n"
175 " beqz %2, 2f \n" 173 " scd %2, %1 \n"
176 " .subsection 2 \n" 174 " .set mips0 \n"
177 "2: b 1b \n" 175 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
178 " .previous \n" 176 : "R" (*m), "Jr" (val)
179 " .set mips0 \n" 177 : "memory");
180 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 178 } while (unlikely(!dummy));
181 : "R" (*m), "Jr" (val)
182 : "memory");
183 } else { 179 } else {
184 unsigned long flags; 180 unsigned long flags;
185 181
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 70df9c0d3c5b..d309556cacf8 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -83,6 +83,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
83#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 83#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
84#define THREAD_MASK (THREAD_SIZE - 1UL) 84#define THREAD_MASK (THREAD_SIZE - 1UL)
85 85
86#define STACK_WARN (THREAD_SIZE / 8)
87
86#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR 88#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
87 89
88#ifdef CONFIG_DEBUG_STACK_USAGE 90#ifdef CONFIG_DEBUG_STACK_USAGE
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index c2d53c18fd36..653a412c036c 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -35,7 +35,9 @@
35 35
36#ifdef CONFIG_64BIT 36#ifdef CONFIG_64BIT
37 37
38#define __UA_LIMIT (- TASK_SIZE) 38extern u64 __ua_limit;
39
40#define __UA_LIMIT __ua_limit
39 41
40#define __UA_ADDR ".dword" 42#define __UA_ADDR ".dword"
41#define __UA_LA "dla" 43#define __UA_LA "dla"
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 06f848299785..22b2e0e38617 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -96,10 +96,14 @@ 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
102 104
103obj-$(CONFIG_MIPS_CPUFREQ) += cpufreq/ 105obj-$(CONFIG_MIPS_CPUFREQ) += cpufreq/
104 106
107obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o
108
105CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS) 109CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index b1b304ea2128..71620e19827a 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -25,6 +25,8 @@
25#include <asm/system.h> 25#include <asm/system.h>
26#include <asm/watch.h> 26#include <asm/watch.h>
27#include <asm/spram.h> 27#include <asm/spram.h>
28#include <asm/uaccess.h>
29
28/* 30/*
29 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover, 31 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
30 * the implementation of the "wait" feature differs between CPU families. This 32 * the implementation of the "wait" feature differs between CPU families. This
@@ -181,12 +183,13 @@ void __init check_wait(void)
181 case CPU_5KC: 183 case CPU_5KC:
182 case CPU_25KF: 184 case CPU_25KF:
183 case CPU_PR4450: 185 case CPU_PR4450:
184 case CPU_BCM3302: 186 case CPU_BMIPS3300:
185 case CPU_BCM6338: 187 case CPU_BMIPS4350:
186 case CPU_BCM6348: 188 case CPU_BMIPS4380:
187 case CPU_BCM6358: 189 case CPU_BMIPS5000:
188 case CPU_CAVIUM_OCTEON: 190 case CPU_CAVIUM_OCTEON:
189 case CPU_CAVIUM_OCTEON_PLUS: 191 case CPU_CAVIUM_OCTEON_PLUS:
192 case CPU_CAVIUM_OCTEON2:
190 case CPU_JZRISC: 193 case CPU_JZRISC:
191 cpu_wait = r4k_wait; 194 cpu_wait = r4k_wait;
192 break; 195 break;
@@ -902,33 +905,37 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
902{ 905{
903 decode_configs(c); 906 decode_configs(c);
904 switch (c->processor_id & 0xff00) { 907 switch (c->processor_id & 0xff00) {
905 case PRID_IMP_BCM3302: 908 case PRID_IMP_BMIPS32:
906 /* same as PRID_IMP_BCM6338 */ 909 c->cputype = CPU_BMIPS32;
907 c->cputype = CPU_BCM3302; 910 __cpu_name[cpu] = "Broadcom BMIPS32";
908 __cpu_name[cpu] = "Broadcom BCM3302"; 911 break;
909 break; 912 case PRID_IMP_BMIPS3300:
910 case PRID_IMP_BCM4710: 913 case PRID_IMP_BMIPS3300_ALT:
911 c->cputype = CPU_BCM4710; 914 case PRID_IMP_BMIPS3300_BUG:
912 __cpu_name[cpu] = "Broadcom BCM4710"; 915 c->cputype = CPU_BMIPS3300;
913 break; 916 __cpu_name[cpu] = "Broadcom BMIPS3300";
914 case PRID_IMP_BCM6345: 917 break;
915 c->cputype = CPU_BCM6345; 918 case PRID_IMP_BMIPS43XX: {
916 __cpu_name[cpu] = "Broadcom BCM6345"; 919 int rev = c->processor_id & 0xff;
920
921 if (rev >= PRID_REV_BMIPS4380_LO &&
922 rev <= PRID_REV_BMIPS4380_HI) {
923 c->cputype = CPU_BMIPS4380;
924 __cpu_name[cpu] = "Broadcom BMIPS4380";
925 } else {
926 c->cputype = CPU_BMIPS4350;
927 __cpu_name[cpu] = "Broadcom BMIPS4350";
928 }
917 break; 929 break;
918 case PRID_IMP_BCM6348: 930 }
919 c->cputype = CPU_BCM6348; 931 case PRID_IMP_BMIPS5000:
920 __cpu_name[cpu] = "Broadcom BCM6348"; 932 c->cputype = CPU_BMIPS5000;
933 __cpu_name[cpu] = "Broadcom BMIPS5000";
934 c->options |= MIPS_CPU_ULRI;
921 break; 935 break;
922 case PRID_IMP_BCM4350: 936 case PRID_IMP_BMIPS4KC:
923 switch (c->processor_id & 0xf0) { 937 c->cputype = CPU_4KC;
924 case PRID_REV_BCM6358: 938 __cpu_name[cpu] = "MIPS 4Kc";
925 c->cputype = CPU_BCM6358;
926 __cpu_name[cpu] = "Broadcom BCM6358";
927 break;
928 default:
929 c->cputype = CPU_UNKNOWN;
930 break;
931 }
932 break; 939 break;
933 } 940 }
934} 941}
@@ -953,6 +960,12 @@ platform:
953 if (cpu == 0) 960 if (cpu == 0)
954 __elf_platform = "octeon"; 961 __elf_platform = "octeon";
955 break; 962 break;
963 case PRID_IMP_CAVIUM_CN63XX:
964 c->cputype = CPU_CAVIUM_OCTEON2;
965 __cpu_name[cpu] = "Cavium Octeon II";
966 if (cpu == 0)
967 __elf_platform = "octeon2";
968 break;
956 default: 969 default:
957 printk(KERN_INFO "Unknown Octeon chip!\n"); 970 printk(KERN_INFO "Unknown Octeon chip!\n");
958 c->cputype = CPU_UNKNOWN; 971 c->cputype = CPU_UNKNOWN;
@@ -976,6 +989,12 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
976 } 989 }
977} 990}
978 991
992#ifdef CONFIG_64BIT
993/* For use by uaccess.h */
994u64 __ua_limit;
995EXPORT_SYMBOL(__ua_limit);
996#endif
997
979const char *__cpu_name[NR_CPUS]; 998const char *__cpu_name[NR_CPUS];
980const char *__elf_platform; 999const char *__elf_platform;
981 1000
@@ -1053,6 +1072,11 @@ __cpuinit void cpu_probe(void)
1053 c->srsets = 1; 1072 c->srsets = 1;
1054 1073
1055 cpu_probe_vmbits(c); 1074 cpu_probe_vmbits(c);
1075
1076#ifdef CONFIG_64BIT
1077 if (cpu == 0)
1078 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1079#endif
1056} 1080}
1057 1081
1058__cpuinit void cpu_report(void) 1082__cpuinit void cpu_report(void)
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index c6345f579a8a..4f93db58a79e 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -151,6 +151,29 @@ void __init init_IRQ(void)
151#endif 151#endif
152} 152}
153 153
154#ifdef DEBUG_STACKOVERFLOW
155static inline void check_stack_overflow(void)
156{
157 unsigned long sp;
158
159 __asm__ __volatile__("move %0, $sp" : "=r" (sp));
160 sp &= THREAD_MASK;
161
162 /*
163 * Check for stack overflow: is there less than STACK_WARN free?
164 * STACK_WARN is defined as 1/8 of THREAD_SIZE by default.
165 */
166 if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
167 printk("do_IRQ: stack overflow: %ld\n",
168 sp - sizeof(struct thread_info));
169 dump_stack();
170 }
171}
172#else
173static inline void check_stack_overflow(void) {}
174#endif
175
176
154/* 177/*
155 * do_IRQ handles all normal device IRQ's (the special 178 * do_IRQ handles all normal device IRQ's (the special
156 * SMP cross-CPU interrupts have their own specific 179 * SMP cross-CPU interrupts have their own specific
@@ -159,6 +182,7 @@ void __init init_IRQ(void)
159void __irq_entry do_IRQ(unsigned int irq) 182void __irq_entry do_IRQ(unsigned int irq)
160{ 183{
161 irq_enter(); 184 irq_enter();
185 check_stack_overflow();
162 __DO_IRQ_SMTC_HOOK(irq); 186 __DO_IRQ_SMTC_HOOK(irq);
163 generic_handle_irq(irq); 187 generic_handle_irq(irq);
164 irq_exit(); 188 irq_exit();
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index 9a526ba6f257..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) 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/perf_event.c b/arch/mips/kernel/perf_event.c
new file mode 100644
index 000000000000..2b7f3f703b83
--- /dev/null
+++ b/arch/mips/kernel/perf_event.c
@@ -0,0 +1,601 @@
1/*
2 * Linux performance counter support for MIPS.
3 *
4 * Copyright (C) 2010 MIPS Technologies, Inc.
5 * Author: Deng-Cheng Zhu
6 *
7 * This code is based on the implementation for ARM, which is in turn
8 * based on the sparc64 perf event code and the x86 code. Performance
9 * counter access is based on the MIPS Oprofile code. And the callchain
10 * support references the code of MIPS stacktrace.c.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/cpumask.h>
18#include <linux/interrupt.h>
19#include <linux/smp.h>
20#include <linux/kernel.h>
21#include <linux/perf_event.h>
22#include <linux/uaccess.h>
23
24#include <asm/irq.h>
25#include <asm/irq_regs.h>
26#include <asm/stacktrace.h>
27#include <asm/time.h> /* For perf_irq */
28
29/* These are for 32bit counters. For 64bit ones, define them accordingly. */
30#define MAX_PERIOD ((1ULL << 32) - 1)
31#define VALID_COUNT 0x7fffffff
32#define TOTAL_BITS 32
33#define HIGHEST_BIT 31
34
35#define MIPS_MAX_HWEVENTS 4
36
37struct cpu_hw_events {
38 /* Array of events on this cpu. */
39 struct perf_event *events[MIPS_MAX_HWEVENTS];
40
41 /*
42 * Set the bit (indexed by the counter number) when the counter
43 * is used for an event.
44 */
45 unsigned long used_mask[BITS_TO_LONGS(MIPS_MAX_HWEVENTS)];
46
47 /*
48 * The borrowed MSB for the performance counter. A MIPS performance
49 * counter uses its bit 31 (for 32bit counters) or bit 63 (for 64bit
50 * counters) as a factor of determining whether a counter overflow
51 * should be signaled. So here we use a separate MSB for each
52 * counter to make things easy.
53 */
54 unsigned long msbs[BITS_TO_LONGS(MIPS_MAX_HWEVENTS)];
55
56 /*
57 * Software copy of the control register for each performance counter.
58 * MIPS CPUs vary in performance counters. They use this differently,
59 * and even may not use it.
60 */
61 unsigned int saved_ctrl[MIPS_MAX_HWEVENTS];
62};
63DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
64 .saved_ctrl = {0},
65};
66
67/* The description of MIPS performance events. */
68struct mips_perf_event {
69 unsigned int event_id;
70 /*
71 * MIPS performance counters are indexed starting from 0.
72 * CNTR_EVEN indicates the indexes of the counters to be used are
73 * even numbers.
74 */
75 unsigned int cntr_mask;
76 #define CNTR_EVEN 0x55555555
77 #define CNTR_ODD 0xaaaaaaaa
78#ifdef CONFIG_MIPS_MT_SMP
79 enum {
80 T = 0,
81 V = 1,
82 P = 2,
83 } range;
84#else
85 #define T
86 #define V
87 #define P
88#endif
89};
90
91static struct mips_perf_event raw_event;
92static DEFINE_MUTEX(raw_event_mutex);
93
94#define UNSUPPORTED_PERF_EVENT_ID 0xffffffff
95#define C(x) PERF_COUNT_HW_CACHE_##x
96
97struct mips_pmu {
98 const char *name;
99 int irq;
100 irqreturn_t (*handle_irq)(int irq, void *dev);
101 int (*handle_shared_irq)(void);
102 void (*start)(void);
103 void (*stop)(void);
104 int (*alloc_counter)(struct cpu_hw_events *cpuc,
105 struct hw_perf_event *hwc);
106 u64 (*read_counter)(unsigned int idx);
107 void (*write_counter)(unsigned int idx, u64 val);
108 void (*enable_event)(struct hw_perf_event *evt, int idx);
109 void (*disable_event)(int idx);
110 const struct mips_perf_event *(*map_raw_event)(u64 config);
111 const struct mips_perf_event (*general_event_map)[PERF_COUNT_HW_MAX];
112 const struct mips_perf_event (*cache_event_map)
113 [PERF_COUNT_HW_CACHE_MAX]
114 [PERF_COUNT_HW_CACHE_OP_MAX]
115 [PERF_COUNT_HW_CACHE_RESULT_MAX];
116 unsigned int num_counters;
117};
118
119static const struct mips_pmu *mipspmu;
120
121static int
122mipspmu_event_set_period(struct perf_event *event,
123 struct hw_perf_event *hwc,
124 int idx)
125{
126 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
127 s64 left = local64_read(&hwc->period_left);
128 s64 period = hwc->sample_period;
129 int ret = 0;
130 u64 uleft;
131 unsigned long flags;
132
133 if (unlikely(left <= -period)) {
134 left = period;
135 local64_set(&hwc->period_left, left);
136 hwc->last_period = period;
137 ret = 1;
138 }
139
140 if (unlikely(left <= 0)) {
141 left += period;
142 local64_set(&hwc->period_left, left);
143 hwc->last_period = period;
144 ret = 1;
145 }
146
147 if (left > (s64)MAX_PERIOD)
148 left = MAX_PERIOD;
149
150 local64_set(&hwc->prev_count, (u64)-left);
151
152 local_irq_save(flags);
153 uleft = (u64)(-left) & MAX_PERIOD;
154 uleft > VALID_COUNT ?
155 set_bit(idx, cpuc->msbs) : clear_bit(idx, cpuc->msbs);
156 mipspmu->write_counter(idx, (u64)(-left) & VALID_COUNT);
157 local_irq_restore(flags);
158
159 perf_event_update_userpage(event);
160
161 return ret;
162}
163
164static int mipspmu_enable(struct perf_event *event)
165{
166 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
167 struct hw_perf_event *hwc = &event->hw;
168 int idx;
169 int err = 0;
170
171 /* To look for a free counter for this event. */
172 idx = mipspmu->alloc_counter(cpuc, hwc);
173 if (idx < 0) {
174 err = idx;
175 goto out;
176 }
177
178 /*
179 * If there is an event in the counter we are going to use then
180 * make sure it is disabled.
181 */
182 event->hw.idx = idx;
183 mipspmu->disable_event(idx);
184 cpuc->events[idx] = event;
185
186 /* Set the period for the event. */
187 mipspmu_event_set_period(event, hwc, idx);
188
189 /* Enable the event. */
190 mipspmu->enable_event(hwc, idx);
191
192 /* Propagate our changes to the userspace mapping. */
193 perf_event_update_userpage(event);
194
195out:
196 return err;
197}
198
199static void mipspmu_event_update(struct perf_event *event,
200 struct hw_perf_event *hwc,
201 int idx)
202{
203 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
204 unsigned long flags;
205 int shift = 64 - TOTAL_BITS;
206 s64 prev_raw_count, new_raw_count;
207 s64 delta;
208
209again:
210 prev_raw_count = local64_read(&hwc->prev_count);
211 local_irq_save(flags);
212 /* Make the counter value be a "real" one. */
213 new_raw_count = mipspmu->read_counter(idx);
214 if (new_raw_count & (test_bit(idx, cpuc->msbs) << HIGHEST_BIT)) {
215 new_raw_count &= VALID_COUNT;
216 clear_bit(idx, cpuc->msbs);
217 } else
218 new_raw_count |= (test_bit(idx, cpuc->msbs) << HIGHEST_BIT);
219 local_irq_restore(flags);
220
221 if (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
222 new_raw_count) != prev_raw_count)
223 goto again;
224
225 delta = (new_raw_count << shift) - (prev_raw_count << shift);
226 delta >>= shift;
227
228 local64_add(delta, &event->count);
229 local64_sub(delta, &hwc->period_left);
230
231 return;
232}
233
234static void mipspmu_disable(struct perf_event *event)
235{
236 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
237 struct hw_perf_event *hwc = &event->hw;
238 int idx = hwc->idx;
239
240
241 WARN_ON(idx < 0 || idx >= mipspmu->num_counters);
242
243 /* We are working on a local event. */
244 mipspmu->disable_event(idx);
245
246 barrier();
247
248 mipspmu_event_update(event, hwc, idx);
249 cpuc->events[idx] = NULL;
250 clear_bit(idx, cpuc->used_mask);
251
252 perf_event_update_userpage(event);
253}
254
255static void mipspmu_unthrottle(struct perf_event *event)
256{
257 struct hw_perf_event *hwc = &event->hw;
258
259 mipspmu->enable_event(hwc, hwc->idx);
260}
261
262static void mipspmu_read(struct perf_event *event)
263{
264 struct hw_perf_event *hwc = &event->hw;
265
266 /* Don't read disabled counters! */
267 if (hwc->idx < 0)
268 return;
269
270 mipspmu_event_update(event, hwc, hwc->idx);
271}
272
273static struct pmu pmu = {
274 .enable = mipspmu_enable,
275 .disable = mipspmu_disable,
276 .unthrottle = mipspmu_unthrottle,
277 .read = mipspmu_read,
278};
279
280static atomic_t active_events = ATOMIC_INIT(0);
281static DEFINE_MUTEX(pmu_reserve_mutex);
282static int (*save_perf_irq)(void);
283
284static int mipspmu_get_irq(void)
285{
286 int err;
287
288 if (mipspmu->irq >= 0) {
289 /* Request my own irq handler. */
290 err = request_irq(mipspmu->irq, mipspmu->handle_irq,
291 IRQF_DISABLED | IRQF_NOBALANCING,
292 "mips_perf_pmu", NULL);
293 if (err) {
294 pr_warning("Unable to request IRQ%d for MIPS "
295 "performance counters!\n", mipspmu->irq);
296 }
297 } else if (cp0_perfcount_irq < 0) {
298 /*
299 * We are sharing the irq number with the timer interrupt.
300 */
301 save_perf_irq = perf_irq;
302 perf_irq = mipspmu->handle_shared_irq;
303 err = 0;
304 } else {
305 pr_warning("The platform hasn't properly defined its "
306 "interrupt controller.\n");
307 err = -ENOENT;
308 }
309
310 return err;
311}
312
313static void mipspmu_free_irq(void)
314{
315 if (mipspmu->irq >= 0)
316 free_irq(mipspmu->irq, NULL);
317 else if (cp0_perfcount_irq < 0)
318 perf_irq = save_perf_irq;
319}
320
321static inline unsigned int
322mipspmu_perf_event_encode(const struct mips_perf_event *pev)
323{
324/*
325 * Top 8 bits for range, next 16 bits for cntr_mask, lowest 8 bits for
326 * event_id.
327 */
328#ifdef CONFIG_MIPS_MT_SMP
329 return ((unsigned int)pev->range << 24) |
330 (pev->cntr_mask & 0xffff00) |
331 (pev->event_id & 0xff);
332#else
333 return (pev->cntr_mask & 0xffff00) |
334 (pev->event_id & 0xff);
335#endif
336}
337
338static const struct mips_perf_event *
339mipspmu_map_general_event(int idx)
340{
341 const struct mips_perf_event *pev;
342
343 pev = ((*mipspmu->general_event_map)[idx].event_id ==
344 UNSUPPORTED_PERF_EVENT_ID ? ERR_PTR(-EOPNOTSUPP) :
345 &(*mipspmu->general_event_map)[idx]);
346
347 return pev;
348}
349
350static const struct mips_perf_event *
351mipspmu_map_cache_event(u64 config)
352{
353 unsigned int cache_type, cache_op, cache_result;
354 const struct mips_perf_event *pev;
355
356 cache_type = (config >> 0) & 0xff;
357 if (cache_type >= PERF_COUNT_HW_CACHE_MAX)
358 return ERR_PTR(-EINVAL);
359
360 cache_op = (config >> 8) & 0xff;
361 if (cache_op >= PERF_COUNT_HW_CACHE_OP_MAX)
362 return ERR_PTR(-EINVAL);
363
364 cache_result = (config >> 16) & 0xff;
365 if (cache_result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
366 return ERR_PTR(-EINVAL);
367
368 pev = &((*mipspmu->cache_event_map)
369 [cache_type]
370 [cache_op]
371 [cache_result]);
372
373 if (pev->event_id == UNSUPPORTED_PERF_EVENT_ID)
374 return ERR_PTR(-EOPNOTSUPP);
375
376 return pev;
377
378}
379
380static int validate_event(struct cpu_hw_events *cpuc,
381 struct perf_event *event)
382{
383 struct hw_perf_event fake_hwc = event->hw;
384
385 if (event->pmu && event->pmu != &pmu)
386 return 0;
387
388 return mipspmu->alloc_counter(cpuc, &fake_hwc) >= 0;
389}
390
391static int validate_group(struct perf_event *event)
392{
393 struct perf_event *sibling, *leader = event->group_leader;
394 struct cpu_hw_events fake_cpuc;
395
396 memset(&fake_cpuc, 0, sizeof(fake_cpuc));
397
398 if (!validate_event(&fake_cpuc, leader))
399 return -ENOSPC;
400
401 list_for_each_entry(sibling, &leader->sibling_list, group_entry) {
402 if (!validate_event(&fake_cpuc, sibling))
403 return -ENOSPC;
404 }
405
406 if (!validate_event(&fake_cpuc, event))
407 return -ENOSPC;
408
409 return 0;
410}
411
412/*
413 * mipsxx/rm9000/loongson2 have different performance counters, they have
414 * specific low-level init routines.
415 */
416static void reset_counters(void *arg);
417static int __hw_perf_event_init(struct perf_event *event);
418
419static void hw_perf_event_destroy(struct perf_event *event)
420{
421 if (atomic_dec_and_mutex_lock(&active_events,
422 &pmu_reserve_mutex)) {
423 /*
424 * We must not call the destroy function with interrupts
425 * disabled.
426 */
427 on_each_cpu(reset_counters,
428 (void *)(long)mipspmu->num_counters, 1);
429 mipspmu_free_irq();
430 mutex_unlock(&pmu_reserve_mutex);
431 }
432}
433
434const struct pmu *hw_perf_event_init(struct perf_event *event)
435{
436 int err = 0;
437
438 if (!mipspmu || event->cpu >= nr_cpumask_bits ||
439 (event->cpu >= 0 && !cpu_online(event->cpu)))
440 return ERR_PTR(-ENODEV);
441
442 if (!atomic_inc_not_zero(&active_events)) {
443 if (atomic_read(&active_events) > MIPS_MAX_HWEVENTS) {
444 atomic_dec(&active_events);
445 return ERR_PTR(-ENOSPC);
446 }
447
448 mutex_lock(&pmu_reserve_mutex);
449 if (atomic_read(&active_events) == 0)
450 err = mipspmu_get_irq();
451
452 if (!err)
453 atomic_inc(&active_events);
454 mutex_unlock(&pmu_reserve_mutex);
455 }
456
457 if (err)
458 return ERR_PTR(err);
459
460 err = __hw_perf_event_init(event);
461 if (err)
462 hw_perf_event_destroy(event);
463
464 return err ? ERR_PTR(err) : &pmu;
465}
466
467void hw_perf_enable(void)
468{
469 if (mipspmu)
470 mipspmu->start();
471}
472
473void hw_perf_disable(void)
474{
475 if (mipspmu)
476 mipspmu->stop();
477}
478
479/* This is needed by specific irq handlers in perf_event_*.c */
480static void
481handle_associated_event(struct cpu_hw_events *cpuc,
482 int idx, struct perf_sample_data *data, struct pt_regs *regs)
483{
484 struct perf_event *event = cpuc->events[idx];
485 struct hw_perf_event *hwc = &event->hw;
486
487 mipspmu_event_update(event, hwc, idx);
488 data->period = event->hw.last_period;
489 if (!mipspmu_event_set_period(event, hwc, idx))
490 return;
491
492 if (perf_event_overflow(event, 0, data, regs))
493 mipspmu->disable_event(idx);
494}
495
496#include "perf_event_mipsxx.c"
497
498/* Callchain handling code. */
499static inline void
500callchain_store(struct perf_callchain_entry *entry,
501 u64 ip)
502{
503 if (entry->nr < PERF_MAX_STACK_DEPTH)
504 entry->ip[entry->nr++] = ip;
505}
506
507/*
508 * Leave userspace callchain empty for now. When we find a way to trace
509 * the user stack callchains, we add here.
510 */
511static void
512perf_callchain_user(struct pt_regs *regs,
513 struct perf_callchain_entry *entry)
514{
515}
516
517static void save_raw_perf_callchain(struct perf_callchain_entry *entry,
518 unsigned long reg29)
519{
520 unsigned long *sp = (unsigned long *)reg29;
521 unsigned long addr;
522
523 while (!kstack_end(sp)) {
524 addr = *sp++;
525 if (__kernel_text_address(addr)) {
526 callchain_store(entry, addr);
527 if (entry->nr >= PERF_MAX_STACK_DEPTH)
528 break;
529 }
530 }
531}
532
533static void
534perf_callchain_kernel(struct pt_regs *regs,
535 struct perf_callchain_entry *entry)
536{
537 unsigned long sp = regs->regs[29];
538#ifdef CONFIG_KALLSYMS
539 unsigned long ra = regs->regs[31];
540 unsigned long pc = regs->cp0_epc;
541
542 callchain_store(entry, PERF_CONTEXT_KERNEL);
543 if (raw_show_trace || !__kernel_text_address(pc)) {
544 unsigned long stack_page =
545 (unsigned long)task_stack_page(current);
546 if (stack_page && sp >= stack_page &&
547 sp <= stack_page + THREAD_SIZE - 32)
548 save_raw_perf_callchain(entry, sp);
549 return;
550 }
551 do {
552 callchain_store(entry, pc);
553 if (entry->nr >= PERF_MAX_STACK_DEPTH)
554 break;
555 pc = unwind_stack(current, &sp, pc, &ra);
556 } while (pc);
557#else
558 callchain_store(entry, PERF_CONTEXT_KERNEL);
559 save_raw_perf_callchain(entry, sp);
560#endif
561}
562
563static void
564perf_do_callchain(struct pt_regs *regs,
565 struct perf_callchain_entry *entry)
566{
567 int is_user;
568
569 if (!regs)
570 return;
571
572 is_user = user_mode(regs);
573
574 if (!current || !current->pid)
575 return;
576
577 if (is_user && current->state != TASK_RUNNING)
578 return;
579
580 if (!is_user) {
581 perf_callchain_kernel(regs, entry);
582 if (current->mm)
583 regs = task_pt_regs(current);
584 else
585 regs = NULL;
586 }
587 if (regs)
588 perf_callchain_user(regs, entry);
589}
590
591static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_irq_entry);
592
593struct perf_callchain_entry *
594perf_callchain(struct pt_regs *regs)
595{
596 struct perf_callchain_entry *entry = &__get_cpu_var(pmc_irq_entry);
597
598 entry->nr = 0;
599 perf_do_callchain(regs, entry);
600 return entry;
601}
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c
new file mode 100644
index 000000000000..5c7c6fc07565
--- /dev/null
+++ b/arch/mips/kernel/perf_event_mipsxx.c
@@ -0,0 +1,1052 @@
1#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) || \
2 defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_SB1)
3
4#define M_CONFIG1_PC (1 << 4)
5
6#define M_PERFCTL_EXL (1UL << 0)
7#define M_PERFCTL_KERNEL (1UL << 1)
8#define M_PERFCTL_SUPERVISOR (1UL << 2)
9#define M_PERFCTL_USER (1UL << 3)
10#define M_PERFCTL_INTERRUPT_ENABLE (1UL << 4)
11#define M_PERFCTL_EVENT(event) (((event) & 0x3ff) << 5)
12#define M_PERFCTL_VPEID(vpe) ((vpe) << 16)
13#define M_PERFCTL_MT_EN(filter) ((filter) << 20)
14#define M_TC_EN_ALL M_PERFCTL_MT_EN(0)
15#define M_TC_EN_VPE M_PERFCTL_MT_EN(1)
16#define M_TC_EN_TC M_PERFCTL_MT_EN(2)
17#define M_PERFCTL_TCID(tcid) ((tcid) << 22)
18#define M_PERFCTL_WIDE (1UL << 30)
19#define M_PERFCTL_MORE (1UL << 31)
20
21#define M_PERFCTL_COUNT_EVENT_WHENEVER (M_PERFCTL_EXL | \
22 M_PERFCTL_KERNEL | \
23 M_PERFCTL_USER | \
24 M_PERFCTL_SUPERVISOR | \
25 M_PERFCTL_INTERRUPT_ENABLE)
26
27#ifdef CONFIG_MIPS_MT_SMP
28#define M_PERFCTL_CONFIG_MASK 0x3fff801f
29#else
30#define M_PERFCTL_CONFIG_MASK 0x1f
31#endif
32#define M_PERFCTL_EVENT_MASK 0xfe0
33
34#define M_COUNTER_OVERFLOW (1UL << 31)
35
36#ifdef CONFIG_MIPS_MT_SMP
37static int cpu_has_mipsmt_pertccounters;
38
39/*
40 * FIXME: For VSMP, vpe_id() is redefined for Perf-events, because
41 * cpu_data[cpuid].vpe_id reports 0 for _both_ CPUs.
42 */
43#if defined(CONFIG_HW_PERF_EVENTS)
44#define vpe_id() (cpu_has_mipsmt_pertccounters ? \
45 0 : smp_processor_id())
46#else
47#define vpe_id() (cpu_has_mipsmt_pertccounters ? \
48 0 : cpu_data[smp_processor_id()].vpe_id)
49#endif
50
51/* Copied from op_model_mipsxx.c */
52static inline unsigned int vpe_shift(void)
53{
54 if (num_possible_cpus() > 1)
55 return 1;
56
57 return 0;
58}
59#else /* !CONFIG_MIPS_MT_SMP */
60#define vpe_id() 0
61
62static inline unsigned int vpe_shift(void)
63{
64 return 0;
65}
66#endif /* CONFIG_MIPS_MT_SMP */
67
68static inline unsigned int
69counters_total_to_per_cpu(unsigned int counters)
70{
71 return counters >> vpe_shift();
72}
73
74static inline unsigned int
75counters_per_cpu_to_total(unsigned int counters)
76{
77 return counters << vpe_shift();
78}
79
80#define __define_perf_accessors(r, n, np) \
81 \
82static inline unsigned int r_c0_ ## r ## n(void) \
83{ \
84 unsigned int cpu = vpe_id(); \
85 \
86 switch (cpu) { \
87 case 0: \
88 return read_c0_ ## r ## n(); \
89 case 1: \
90 return read_c0_ ## r ## np(); \
91 default: \
92 BUG(); \
93 } \
94 return 0; \
95} \
96 \
97static inline void w_c0_ ## r ## n(unsigned int value) \
98{ \
99 unsigned int cpu = vpe_id(); \
100 \
101 switch (cpu) { \
102 case 0: \
103 write_c0_ ## r ## n(value); \
104 return; \
105 case 1: \
106 write_c0_ ## r ## np(value); \
107 return; \
108 default: \
109 BUG(); \
110 } \
111 return; \
112} \
113
114__define_perf_accessors(perfcntr, 0, 2)
115__define_perf_accessors(perfcntr, 1, 3)
116__define_perf_accessors(perfcntr, 2, 0)
117__define_perf_accessors(perfcntr, 3, 1)
118
119__define_perf_accessors(perfctrl, 0, 2)
120__define_perf_accessors(perfctrl, 1, 3)
121__define_perf_accessors(perfctrl, 2, 0)
122__define_perf_accessors(perfctrl, 3, 1)
123
124static inline int __n_counters(void)
125{
126 if (!(read_c0_config1() & M_CONFIG1_PC))
127 return 0;
128 if (!(read_c0_perfctrl0() & M_PERFCTL_MORE))
129 return 1;
130 if (!(read_c0_perfctrl1() & M_PERFCTL_MORE))
131 return 2;
132 if (!(read_c0_perfctrl2() & M_PERFCTL_MORE))
133 return 3;
134
135 return 4;
136}
137
138static inline int n_counters(void)
139{
140 int counters;
141
142 switch (current_cpu_type()) {
143 case CPU_R10000:
144 counters = 2;
145 break;
146
147 case CPU_R12000:
148 case CPU_R14000:
149 counters = 4;
150 break;
151
152 default:
153 counters = __n_counters();
154 }
155
156 return counters;
157}
158
159static void reset_counters(void *arg)
160{
161 int counters = (int)(long)arg;
162 switch (counters) {
163 case 4:
164 w_c0_perfctrl3(0);
165 w_c0_perfcntr3(0);
166 case 3:
167 w_c0_perfctrl2(0);
168 w_c0_perfcntr2(0);
169 case 2:
170 w_c0_perfctrl1(0);
171 w_c0_perfcntr1(0);
172 case 1:
173 w_c0_perfctrl0(0);
174 w_c0_perfcntr0(0);
175 }
176}
177
178static inline u64
179mipsxx_pmu_read_counter(unsigned int idx)
180{
181 switch (idx) {
182 case 0:
183 return r_c0_perfcntr0();
184 case 1:
185 return r_c0_perfcntr1();
186 case 2:
187 return r_c0_perfcntr2();
188 case 3:
189 return r_c0_perfcntr3();
190 default:
191 WARN_ONCE(1, "Invalid performance counter number (%d)\n", idx);
192 return 0;
193 }
194}
195
196static inline void
197mipsxx_pmu_write_counter(unsigned int idx, u64 val)
198{
199 switch (idx) {
200 case 0:
201 w_c0_perfcntr0(val);
202 return;
203 case 1:
204 w_c0_perfcntr1(val);
205 return;
206 case 2:
207 w_c0_perfcntr2(val);
208 return;
209 case 3:
210 w_c0_perfcntr3(val);
211 return;
212 }
213}
214
215static inline unsigned int
216mipsxx_pmu_read_control(unsigned int idx)
217{
218 switch (idx) {
219 case 0:
220 return r_c0_perfctrl0();
221 case 1:
222 return r_c0_perfctrl1();
223 case 2:
224 return r_c0_perfctrl2();
225 case 3:
226 return r_c0_perfctrl3();
227 default:
228 WARN_ONCE(1, "Invalid performance counter number (%d)\n", idx);
229 return 0;
230 }
231}
232
233static inline void
234mipsxx_pmu_write_control(unsigned int idx, unsigned int val)
235{
236 switch (idx) {
237 case 0:
238 w_c0_perfctrl0(val);
239 return;
240 case 1:
241 w_c0_perfctrl1(val);
242 return;
243 case 2:
244 w_c0_perfctrl2(val);
245 return;
246 case 3:
247 w_c0_perfctrl3(val);
248 return;
249 }
250}
251
252#ifdef CONFIG_MIPS_MT_SMP
253static DEFINE_RWLOCK(pmuint_rwlock);
254#endif
255
256/* 24K/34K/1004K cores can share the same event map. */
257static const struct mips_perf_event mipsxxcore_event_map
258 [PERF_COUNT_HW_MAX] = {
259 [PERF_COUNT_HW_CPU_CYCLES] = { 0x00, CNTR_EVEN | CNTR_ODD, P },
260 [PERF_COUNT_HW_INSTRUCTIONS] = { 0x01, CNTR_EVEN | CNTR_ODD, T },
261 [PERF_COUNT_HW_CACHE_REFERENCES] = { UNSUPPORTED_PERF_EVENT_ID },
262 [PERF_COUNT_HW_CACHE_MISSES] = { UNSUPPORTED_PERF_EVENT_ID },
263 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = { 0x02, CNTR_EVEN, T },
264 [PERF_COUNT_HW_BRANCH_MISSES] = { 0x02, CNTR_ODD, T },
265 [PERF_COUNT_HW_BUS_CYCLES] = { UNSUPPORTED_PERF_EVENT_ID },
266};
267
268/* 74K core has different branch event code. */
269static const struct mips_perf_event mipsxx74Kcore_event_map
270 [PERF_COUNT_HW_MAX] = {
271 [PERF_COUNT_HW_CPU_CYCLES] = { 0x00, CNTR_EVEN | CNTR_ODD, P },
272 [PERF_COUNT_HW_INSTRUCTIONS] = { 0x01, CNTR_EVEN | CNTR_ODD, T },
273 [PERF_COUNT_HW_CACHE_REFERENCES] = { UNSUPPORTED_PERF_EVENT_ID },
274 [PERF_COUNT_HW_CACHE_MISSES] = { UNSUPPORTED_PERF_EVENT_ID },
275 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = { 0x27, CNTR_EVEN, T },
276 [PERF_COUNT_HW_BRANCH_MISSES] = { 0x27, CNTR_ODD, T },
277 [PERF_COUNT_HW_BUS_CYCLES] = { UNSUPPORTED_PERF_EVENT_ID },
278};
279
280/* 24K/34K/1004K cores can share the same cache event map. */
281static const struct mips_perf_event mipsxxcore_cache_map
282 [PERF_COUNT_HW_CACHE_MAX]
283 [PERF_COUNT_HW_CACHE_OP_MAX]
284 [PERF_COUNT_HW_CACHE_RESULT_MAX] = {
285[C(L1D)] = {
286 /*
287 * Like some other architectures (e.g. ARM), the performance
288 * counters don't differentiate between read and write
289 * accesses/misses, so this isn't strictly correct, but it's the
290 * best we can do. Writes and reads get combined.
291 */
292 [C(OP_READ)] = {
293 [C(RESULT_ACCESS)] = { 0x0a, CNTR_EVEN, T },
294 [C(RESULT_MISS)] = { 0x0b, CNTR_EVEN | CNTR_ODD, T },
295 },
296 [C(OP_WRITE)] = {
297 [C(RESULT_ACCESS)] = { 0x0a, CNTR_EVEN, T },
298 [C(RESULT_MISS)] = { 0x0b, CNTR_EVEN | CNTR_ODD, T },
299 },
300 [C(OP_PREFETCH)] = {
301 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
302 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
303 },
304},
305[C(L1I)] = {
306 [C(OP_READ)] = {
307 [C(RESULT_ACCESS)] = { 0x09, CNTR_EVEN, T },
308 [C(RESULT_MISS)] = { 0x09, CNTR_ODD, T },
309 },
310 [C(OP_WRITE)] = {
311 [C(RESULT_ACCESS)] = { 0x09, CNTR_EVEN, T },
312 [C(RESULT_MISS)] = { 0x09, CNTR_ODD, T },
313 },
314 [C(OP_PREFETCH)] = {
315 [C(RESULT_ACCESS)] = { 0x14, CNTR_EVEN, T },
316 /*
317 * Note that MIPS has only "hit" events countable for
318 * the prefetch operation.
319 */
320 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
321 },
322},
323[C(LL)] = {
324 [C(OP_READ)] = {
325 [C(RESULT_ACCESS)] = { 0x15, CNTR_ODD, P },
326 [C(RESULT_MISS)] = { 0x16, CNTR_EVEN, P },
327 },
328 [C(OP_WRITE)] = {
329 [C(RESULT_ACCESS)] = { 0x15, CNTR_ODD, P },
330 [C(RESULT_MISS)] = { 0x16, CNTR_EVEN, P },
331 },
332 [C(OP_PREFETCH)] = {
333 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
334 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
335 },
336},
337[C(DTLB)] = {
338 [C(OP_READ)] = {
339 [C(RESULT_ACCESS)] = { 0x06, CNTR_EVEN, T },
340 [C(RESULT_MISS)] = { 0x06, CNTR_ODD, T },
341 },
342 [C(OP_WRITE)] = {
343 [C(RESULT_ACCESS)] = { 0x06, CNTR_EVEN, T },
344 [C(RESULT_MISS)] = { 0x06, CNTR_ODD, T },
345 },
346 [C(OP_PREFETCH)] = {
347 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
348 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
349 },
350},
351[C(ITLB)] = {
352 [C(OP_READ)] = {
353 [C(RESULT_ACCESS)] = { 0x05, CNTR_EVEN, T },
354 [C(RESULT_MISS)] = { 0x05, CNTR_ODD, T },
355 },
356 [C(OP_WRITE)] = {
357 [C(RESULT_ACCESS)] = { 0x05, CNTR_EVEN, T },
358 [C(RESULT_MISS)] = { 0x05, CNTR_ODD, T },
359 },
360 [C(OP_PREFETCH)] = {
361 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
362 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
363 },
364},
365[C(BPU)] = {
366 /* Using the same code for *HW_BRANCH* */
367 [C(OP_READ)] = {
368 [C(RESULT_ACCESS)] = { 0x02, CNTR_EVEN, T },
369 [C(RESULT_MISS)] = { 0x02, CNTR_ODD, T },
370 },
371 [C(OP_WRITE)] = {
372 [C(RESULT_ACCESS)] = { 0x02, CNTR_EVEN, T },
373 [C(RESULT_MISS)] = { 0x02, CNTR_ODD, T },
374 },
375 [C(OP_PREFETCH)] = {
376 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
377 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
378 },
379},
380};
381
382/* 74K core has completely different cache event map. */
383static const struct mips_perf_event mipsxx74Kcore_cache_map
384 [PERF_COUNT_HW_CACHE_MAX]
385 [PERF_COUNT_HW_CACHE_OP_MAX]
386 [PERF_COUNT_HW_CACHE_RESULT_MAX] = {
387[C(L1D)] = {
388 /*
389 * Like some other architectures (e.g. ARM), the performance
390 * counters don't differentiate between read and write
391 * accesses/misses, so this isn't strictly correct, but it's the
392 * best we can do. Writes and reads get combined.
393 */
394 [C(OP_READ)] = {
395 [C(RESULT_ACCESS)] = { 0x17, CNTR_ODD, T },
396 [C(RESULT_MISS)] = { 0x18, CNTR_ODD, T },
397 },
398 [C(OP_WRITE)] = {
399 [C(RESULT_ACCESS)] = { 0x17, CNTR_ODD, T },
400 [C(RESULT_MISS)] = { 0x18, CNTR_ODD, T },
401 },
402 [C(OP_PREFETCH)] = {
403 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
404 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
405 },
406},
407[C(L1I)] = {
408 [C(OP_READ)] = {
409 [C(RESULT_ACCESS)] = { 0x06, CNTR_EVEN, T },
410 [C(RESULT_MISS)] = { 0x06, CNTR_ODD, T },
411 },
412 [C(OP_WRITE)] = {
413 [C(RESULT_ACCESS)] = { 0x06, CNTR_EVEN, T },
414 [C(RESULT_MISS)] = { 0x06, CNTR_ODD, T },
415 },
416 [C(OP_PREFETCH)] = {
417 [C(RESULT_ACCESS)] = { 0x34, CNTR_EVEN, T },
418 /*
419 * Note that MIPS has only "hit" events countable for
420 * the prefetch operation.
421 */
422 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
423 },
424},
425[C(LL)] = {
426 [C(OP_READ)] = {
427 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P },
428 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN | CNTR_ODD, P },
429 },
430 [C(OP_WRITE)] = {
431 [C(RESULT_ACCESS)] = { 0x1c, CNTR_ODD, P },
432 [C(RESULT_MISS)] = { 0x1d, CNTR_EVEN | CNTR_ODD, P },
433 },
434 [C(OP_PREFETCH)] = {
435 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
436 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
437 },
438},
439[C(DTLB)] = {
440 /* 74K core does not have specific DTLB events. */
441 [C(OP_READ)] = {
442 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
443 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
444 },
445 [C(OP_WRITE)] = {
446 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
447 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
448 },
449 [C(OP_PREFETCH)] = {
450 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
451 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
452 },
453},
454[C(ITLB)] = {
455 [C(OP_READ)] = {
456 [C(RESULT_ACCESS)] = { 0x04, CNTR_EVEN, T },
457 [C(RESULT_MISS)] = { 0x04, CNTR_ODD, T },
458 },
459 [C(OP_WRITE)] = {
460 [C(RESULT_ACCESS)] = { 0x04, CNTR_EVEN, T },
461 [C(RESULT_MISS)] = { 0x04, CNTR_ODD, T },
462 },
463 [C(OP_PREFETCH)] = {
464 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
465 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
466 },
467},
468[C(BPU)] = {
469 /* Using the same code for *HW_BRANCH* */
470 [C(OP_READ)] = {
471 [C(RESULT_ACCESS)] = { 0x27, CNTR_EVEN, T },
472 [C(RESULT_MISS)] = { 0x27, CNTR_ODD, T },
473 },
474 [C(OP_WRITE)] = {
475 [C(RESULT_ACCESS)] = { 0x27, CNTR_EVEN, T },
476 [C(RESULT_MISS)] = { 0x27, CNTR_ODD, T },
477 },
478 [C(OP_PREFETCH)] = {
479 [C(RESULT_ACCESS)] = { UNSUPPORTED_PERF_EVENT_ID },
480 [C(RESULT_MISS)] = { UNSUPPORTED_PERF_EVENT_ID },
481 },
482},
483};
484
485#ifdef CONFIG_MIPS_MT_SMP
486static void
487check_and_calc_range(struct perf_event *event,
488 const struct mips_perf_event *pev)
489{
490 struct hw_perf_event *hwc = &event->hw;
491
492 if (event->cpu >= 0) {
493 if (pev->range > V) {
494 /*
495 * The user selected an event that is processor
496 * wide, while expecting it to be VPE wide.
497 */
498 hwc->config_base |= M_TC_EN_ALL;
499 } else {
500 /*
501 * FIXME: cpu_data[event->cpu].vpe_id reports 0
502 * for both CPUs.
503 */
504 hwc->config_base |= M_PERFCTL_VPEID(event->cpu);
505 hwc->config_base |= M_TC_EN_VPE;
506 }
507 } else
508 hwc->config_base |= M_TC_EN_ALL;
509}
510#else
511static void
512check_and_calc_range(struct perf_event *event,
513 const struct mips_perf_event *pev)
514{
515}
516#endif
517
518static int __hw_perf_event_init(struct perf_event *event)
519{
520 struct perf_event_attr *attr = &event->attr;
521 struct hw_perf_event *hwc = &event->hw;
522 const struct mips_perf_event *pev;
523 int err;
524
525 /* Returning MIPS event descriptor for generic perf event. */
526 if (PERF_TYPE_HARDWARE == event->attr.type) {
527 if (event->attr.config >= PERF_COUNT_HW_MAX)
528 return -EINVAL;
529 pev = mipspmu_map_general_event(event->attr.config);
530 } else if (PERF_TYPE_HW_CACHE == event->attr.type) {
531 pev = mipspmu_map_cache_event(event->attr.config);
532 } else if (PERF_TYPE_RAW == event->attr.type) {
533 /* We are working on the global raw event. */
534 mutex_lock(&raw_event_mutex);
535 pev = mipspmu->map_raw_event(event->attr.config);
536 } else {
537 /* The event type is not (yet) supported. */
538 return -EOPNOTSUPP;
539 }
540
541 if (IS_ERR(pev)) {
542 if (PERF_TYPE_RAW == event->attr.type)
543 mutex_unlock(&raw_event_mutex);
544 return PTR_ERR(pev);
545 }
546
547 /*
548 * We allow max flexibility on how each individual counter shared
549 * by the single CPU operates (the mode exclusion and the range).
550 */
551 hwc->config_base = M_PERFCTL_INTERRUPT_ENABLE;
552
553 /* Calculate range bits and validate it. */
554 if (num_possible_cpus() > 1)
555 check_and_calc_range(event, pev);
556
557 hwc->event_base = mipspmu_perf_event_encode(pev);
558 if (PERF_TYPE_RAW == event->attr.type)
559 mutex_unlock(&raw_event_mutex);
560
561 if (!attr->exclude_user)
562 hwc->config_base |= M_PERFCTL_USER;
563 if (!attr->exclude_kernel) {
564 hwc->config_base |= M_PERFCTL_KERNEL;
565 /* MIPS kernel mode: KSU == 00b || EXL == 1 || ERL == 1 */
566 hwc->config_base |= M_PERFCTL_EXL;
567 }
568 if (!attr->exclude_hv)
569 hwc->config_base |= M_PERFCTL_SUPERVISOR;
570
571 hwc->config_base &= M_PERFCTL_CONFIG_MASK;
572 /*
573 * The event can belong to another cpu. We do not assign a local
574 * counter for it for now.
575 */
576 hwc->idx = -1;
577 hwc->config = 0;
578
579 if (!hwc->sample_period) {
580 hwc->sample_period = MAX_PERIOD;
581 hwc->last_period = hwc->sample_period;
582 local64_set(&hwc->period_left, hwc->sample_period);
583 }
584
585 err = 0;
586 if (event->group_leader != event) {
587 err = validate_group(event);
588 if (err)
589 return -EINVAL;
590 }
591
592 event->destroy = hw_perf_event_destroy;
593
594 return err;
595}
596
597static void pause_local_counters(void)
598{
599 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
600 int counters = mipspmu->num_counters;
601 unsigned long flags;
602
603 local_irq_save(flags);
604 switch (counters) {
605 case 4:
606 cpuc->saved_ctrl[3] = r_c0_perfctrl3();
607 w_c0_perfctrl3(cpuc->saved_ctrl[3] &
608 ~M_PERFCTL_COUNT_EVENT_WHENEVER);
609 case 3:
610 cpuc->saved_ctrl[2] = r_c0_perfctrl2();
611 w_c0_perfctrl2(cpuc->saved_ctrl[2] &
612 ~M_PERFCTL_COUNT_EVENT_WHENEVER);
613 case 2:
614 cpuc->saved_ctrl[1] = r_c0_perfctrl1();
615 w_c0_perfctrl1(cpuc->saved_ctrl[1] &
616 ~M_PERFCTL_COUNT_EVENT_WHENEVER);
617 case 1:
618 cpuc->saved_ctrl[0] = r_c0_perfctrl0();
619 w_c0_perfctrl0(cpuc->saved_ctrl[0] &
620 ~M_PERFCTL_COUNT_EVENT_WHENEVER);
621 }
622 local_irq_restore(flags);
623}
624
625static void resume_local_counters(void)
626{
627 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
628 int counters = mipspmu->num_counters;
629 unsigned long flags;
630
631 local_irq_save(flags);
632 switch (counters) {
633 case 4:
634 w_c0_perfctrl3(cpuc->saved_ctrl[3]);
635 case 3:
636 w_c0_perfctrl2(cpuc->saved_ctrl[2]);
637 case 2:
638 w_c0_perfctrl1(cpuc->saved_ctrl[1]);
639 case 1:
640 w_c0_perfctrl0(cpuc->saved_ctrl[0]);
641 }
642 local_irq_restore(flags);
643}
644
645static int mipsxx_pmu_handle_shared_irq(void)
646{
647 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
648 struct perf_sample_data data;
649 unsigned int counters = mipspmu->num_counters;
650 unsigned int counter;
651 int handled = IRQ_NONE;
652 struct pt_regs *regs;
653
654 if (cpu_has_mips_r2 && !(read_c0_cause() & (1 << 26)))
655 return handled;
656
657 /*
658 * First we pause the local counters, so that when we are locked
659 * here, the counters are all paused. When it gets locked due to
660 * perf_disable(), the timer interrupt handler will be delayed.
661 *
662 * See also mipsxx_pmu_start().
663 */
664 pause_local_counters();
665#ifdef CONFIG_MIPS_MT_SMP
666 read_lock(&pmuint_rwlock);
667#endif
668
669 regs = get_irq_regs();
670
671 perf_sample_data_init(&data, 0);
672
673 switch (counters) {
674#define HANDLE_COUNTER(n) \
675 case n + 1: \
676 if (test_bit(n, cpuc->used_mask)) { \
677 counter = r_c0_perfcntr ## n(); \
678 if (counter & M_COUNTER_OVERFLOW) { \
679 w_c0_perfcntr ## n(counter & \
680 VALID_COUNT); \
681 if (test_and_change_bit(n, cpuc->msbs)) \
682 handle_associated_event(cpuc, \
683 n, &data, regs); \
684 handled = IRQ_HANDLED; \
685 } \
686 }
687 HANDLE_COUNTER(3)
688 HANDLE_COUNTER(2)
689 HANDLE_COUNTER(1)
690 HANDLE_COUNTER(0)
691 }
692
693 /*
694 * Do all the work for the pending perf events. We can do this
695 * in here because the performance counter interrupt is a regular
696 * interrupt, not NMI.
697 */
698 if (handled == IRQ_HANDLED)
699 perf_event_do_pending();
700
701#ifdef CONFIG_MIPS_MT_SMP
702 read_unlock(&pmuint_rwlock);
703#endif
704 resume_local_counters();
705 return handled;
706}
707
708static irqreturn_t
709mipsxx_pmu_handle_irq(int irq, void *dev)
710{
711 return mipsxx_pmu_handle_shared_irq();
712}
713
714static void mipsxx_pmu_start(void)
715{
716#ifdef CONFIG_MIPS_MT_SMP
717 write_unlock(&pmuint_rwlock);
718#endif
719 resume_local_counters();
720}
721
722/*
723 * MIPS performance counters can be per-TC. The control registers can
724 * not be directly accessed accross CPUs. Hence if we want to do global
725 * control, we need cross CPU calls. on_each_cpu() can help us, but we
726 * can not make sure this function is called with interrupts enabled. So
727 * here we pause local counters and then grab a rwlock and leave the
728 * counters on other CPUs alone. If any counter interrupt raises while
729 * we own the write lock, simply pause local counters on that CPU and
730 * spin in the handler. Also we know we won't be switched to another
731 * CPU after pausing local counters and before grabbing the lock.
732 */
733static void mipsxx_pmu_stop(void)
734{
735 pause_local_counters();
736#ifdef CONFIG_MIPS_MT_SMP
737 write_lock(&pmuint_rwlock);
738#endif
739}
740
741static int
742mipsxx_pmu_alloc_counter(struct cpu_hw_events *cpuc,
743 struct hw_perf_event *hwc)
744{
745 int i;
746
747 /*
748 * We only need to care the counter mask. The range has been
749 * checked definitely.
750 */
751 unsigned long cntr_mask = (hwc->event_base >> 8) & 0xffff;
752
753 for (i = mipspmu->num_counters - 1; i >= 0; i--) {
754 /*
755 * Note that some MIPS perf events can be counted by both
756 * even and odd counters, wheresas many other are only by
757 * even _or_ odd counters. This introduces an issue that
758 * when the former kind of event takes the counter the
759 * latter kind of event wants to use, then the "counter
760 * allocation" for the latter event will fail. In fact if
761 * they can be dynamically swapped, they both feel happy.
762 * But here we leave this issue alone for now.
763 */
764 if (test_bit(i, &cntr_mask) &&
765 !test_and_set_bit(i, cpuc->used_mask))
766 return i;
767 }
768
769 return -EAGAIN;
770}
771
772static void
773mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)
774{
775 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
776 unsigned long flags;
777
778 WARN_ON(idx < 0 || idx >= mipspmu->num_counters);
779
780 local_irq_save(flags);
781 cpuc->saved_ctrl[idx] = M_PERFCTL_EVENT(evt->event_base & 0xff) |
782 (evt->config_base & M_PERFCTL_CONFIG_MASK) |
783 /* Make sure interrupt enabled. */
784 M_PERFCTL_INTERRUPT_ENABLE;
785 /*
786 * We do not actually let the counter run. Leave it until start().
787 */
788 local_irq_restore(flags);
789}
790
791static void
792mipsxx_pmu_disable_event(int idx)
793{
794 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
795 unsigned long flags;
796
797 WARN_ON(idx < 0 || idx >= mipspmu->num_counters);
798
799 local_irq_save(flags);
800 cpuc->saved_ctrl[idx] = mipsxx_pmu_read_control(idx) &
801 ~M_PERFCTL_COUNT_EVENT_WHENEVER;
802 mipsxx_pmu_write_control(idx, cpuc->saved_ctrl[idx]);
803 local_irq_restore(flags);
804}
805
806/* 24K */
807#define IS_UNSUPPORTED_24K_EVENT(r, b) \
808 ((b) == 12 || (r) == 151 || (r) == 152 || (b) == 26 || \
809 (b) == 27 || (r) == 28 || (r) == 158 || (b) == 31 || \
810 (b) == 32 || (b) == 34 || (b) == 36 || (r) == 168 || \
811 (r) == 172 || (b) == 47 || ((b) >= 56 && (b) <= 63) || \
812 ((b) >= 68 && (b) <= 127))
813#define IS_BOTH_COUNTERS_24K_EVENT(b) \
814 ((b) == 0 || (b) == 1 || (b) == 11)
815
816/* 34K */
817#define IS_UNSUPPORTED_34K_EVENT(r, b) \
818 ((b) == 12 || (r) == 27 || (r) == 158 || (b) == 36 || \
819 (b) == 38 || (r) == 175 || ((b) >= 56 && (b) <= 63) || \
820 ((b) >= 68 && (b) <= 127))
821#define IS_BOTH_COUNTERS_34K_EVENT(b) \
822 ((b) == 0 || (b) == 1 || (b) == 11)
823#ifdef CONFIG_MIPS_MT_SMP
824#define IS_RANGE_P_34K_EVENT(r, b) \
825 ((b) == 0 || (r) == 18 || (b) == 21 || (b) == 22 || \
826 (b) == 25 || (b) == 39 || (r) == 44 || (r) == 174 || \
827 (r) == 176 || ((b) >= 50 && (b) <= 55) || \
828 ((b) >= 64 && (b) <= 67))
829#define IS_RANGE_V_34K_EVENT(r) ((r) == 47)
830#endif
831
832/* 74K */
833#define IS_UNSUPPORTED_74K_EVENT(r, b) \
834 ((r) == 5 || ((r) >= 135 && (r) <= 137) || \
835 ((b) >= 10 && (b) <= 12) || (b) == 22 || (b) == 27 || \
836 (b) == 33 || (b) == 34 || ((b) >= 47 && (b) <= 49) || \
837 (r) == 178 || (b) == 55 || (b) == 57 || (b) == 60 || \
838 (b) == 61 || (r) == 62 || (r) == 191 || \
839 ((b) >= 64 && (b) <= 127))
840#define IS_BOTH_COUNTERS_74K_EVENT(b) \
841 ((b) == 0 || (b) == 1)
842
843/* 1004K */
844#define IS_UNSUPPORTED_1004K_EVENT(r, b) \
845 ((b) == 12 || (r) == 27 || (r) == 158 || (b) == 38 || \
846 (r) == 175 || (b) == 63 || ((b) >= 68 && (b) <= 127))
847#define IS_BOTH_COUNTERS_1004K_EVENT(b) \
848 ((b) == 0 || (b) == 1 || (b) == 11)
849#ifdef CONFIG_MIPS_MT_SMP
850#define IS_RANGE_P_1004K_EVENT(r, b) \
851 ((b) == 0 || (r) == 18 || (b) == 21 || (b) == 22 || \
852 (b) == 25 || (b) == 36 || (b) == 39 || (r) == 44 || \
853 (r) == 174 || (r) == 176 || ((b) >= 50 && (b) <= 59) || \
854 (r) == 188 || (b) == 61 || (b) == 62 || \
855 ((b) >= 64 && (b) <= 67))
856#define IS_RANGE_V_1004K_EVENT(r) ((r) == 47)
857#endif
858
859/*
860 * User can use 0-255 raw events, where 0-127 for the events of even
861 * counters, and 128-255 for odd counters. Note that bit 7 is used to
862 * indicate the parity. So, for example, when user wants to take the
863 * Event Num of 15 for odd counters (by referring to the user manual),
864 * then 128 needs to be added to 15 as the input for the event config,
865 * i.e., 143 (0x8F) to be used.
866 */
867static const struct mips_perf_event *
868mipsxx_pmu_map_raw_event(u64 config)
869{
870 unsigned int raw_id = config & 0xff;
871 unsigned int base_id = raw_id & 0x7f;
872
873 switch (current_cpu_type()) {
874 case CPU_24K:
875 if (IS_UNSUPPORTED_24K_EVENT(raw_id, base_id))
876 return ERR_PTR(-EOPNOTSUPP);
877 raw_event.event_id = base_id;
878 if (IS_BOTH_COUNTERS_24K_EVENT(base_id))
879 raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD;
880 else
881 raw_event.cntr_mask =
882 raw_id > 127 ? CNTR_ODD : CNTR_EVEN;
883#ifdef CONFIG_MIPS_MT_SMP
884 /*
885 * This is actually doing nothing. Non-multithreading
886 * CPUs will not check and calculate the range.
887 */
888 raw_event.range = P;
889#endif
890 break;
891 case CPU_34K:
892 if (IS_UNSUPPORTED_34K_EVENT(raw_id, base_id))
893 return ERR_PTR(-EOPNOTSUPP);
894 raw_event.event_id = base_id;
895 if (IS_BOTH_COUNTERS_34K_EVENT(base_id))
896 raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD;
897 else
898 raw_event.cntr_mask =
899 raw_id > 127 ? CNTR_ODD : CNTR_EVEN;
900#ifdef CONFIG_MIPS_MT_SMP
901 if (IS_RANGE_P_34K_EVENT(raw_id, base_id))
902 raw_event.range = P;
903 else if (unlikely(IS_RANGE_V_34K_EVENT(raw_id)))
904 raw_event.range = V;
905 else
906 raw_event.range = T;
907#endif
908 break;
909 case CPU_74K:
910 if (IS_UNSUPPORTED_74K_EVENT(raw_id, base_id))
911 return ERR_PTR(-EOPNOTSUPP);
912 raw_event.event_id = base_id;
913 if (IS_BOTH_COUNTERS_74K_EVENT(base_id))
914 raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD;
915 else
916 raw_event.cntr_mask =
917 raw_id > 127 ? CNTR_ODD : CNTR_EVEN;
918#ifdef CONFIG_MIPS_MT_SMP
919 raw_event.range = P;
920#endif
921 break;
922 case CPU_1004K:
923 if (IS_UNSUPPORTED_1004K_EVENT(raw_id, base_id))
924 return ERR_PTR(-EOPNOTSUPP);
925 raw_event.event_id = base_id;
926 if (IS_BOTH_COUNTERS_1004K_EVENT(base_id))
927 raw_event.cntr_mask = CNTR_EVEN | CNTR_ODD;
928 else
929 raw_event.cntr_mask =
930 raw_id > 127 ? CNTR_ODD : CNTR_EVEN;
931#ifdef CONFIG_MIPS_MT_SMP
932 if (IS_RANGE_P_1004K_EVENT(raw_id, base_id))
933 raw_event.range = P;
934 else if (unlikely(IS_RANGE_V_1004K_EVENT(raw_id)))
935 raw_event.range = V;
936 else
937 raw_event.range = T;
938#endif
939 break;
940 }
941
942 return &raw_event;
943}
944
945static struct mips_pmu mipsxxcore_pmu = {
946 .handle_irq = mipsxx_pmu_handle_irq,
947 .handle_shared_irq = mipsxx_pmu_handle_shared_irq,
948 .start = mipsxx_pmu_start,
949 .stop = mipsxx_pmu_stop,
950 .alloc_counter = mipsxx_pmu_alloc_counter,
951 .read_counter = mipsxx_pmu_read_counter,
952 .write_counter = mipsxx_pmu_write_counter,
953 .enable_event = mipsxx_pmu_enable_event,
954 .disable_event = mipsxx_pmu_disable_event,
955 .map_raw_event = mipsxx_pmu_map_raw_event,
956 .general_event_map = &mipsxxcore_event_map,
957 .cache_event_map = &mipsxxcore_cache_map,
958};
959
960static struct mips_pmu mipsxx74Kcore_pmu = {
961 .handle_irq = mipsxx_pmu_handle_irq,
962 .handle_shared_irq = mipsxx_pmu_handle_shared_irq,
963 .start = mipsxx_pmu_start,
964 .stop = mipsxx_pmu_stop,
965 .alloc_counter = mipsxx_pmu_alloc_counter,
966 .read_counter = mipsxx_pmu_read_counter,
967 .write_counter = mipsxx_pmu_write_counter,
968 .enable_event = mipsxx_pmu_enable_event,
969 .disable_event = mipsxx_pmu_disable_event,
970 .map_raw_event = mipsxx_pmu_map_raw_event,
971 .general_event_map = &mipsxx74Kcore_event_map,
972 .cache_event_map = &mipsxx74Kcore_cache_map,
973};
974
975static int __init
976init_hw_perf_events(void)
977{
978 int counters, irq;
979
980 pr_info("Performance counters: ");
981
982 counters = n_counters();
983 if (counters == 0) {
984 pr_cont("No available PMU.\n");
985 return -ENODEV;
986 }
987
988#ifdef CONFIG_MIPS_MT_SMP
989 cpu_has_mipsmt_pertccounters = read_c0_config7() & (1<<19);
990 if (!cpu_has_mipsmt_pertccounters)
991 counters = counters_total_to_per_cpu(counters);
992#endif
993
994#ifdef MSC01E_INT_BASE
995 if (cpu_has_veic) {
996 /*
997 * Using platform specific interrupt controller defines.
998 */
999 irq = MSC01E_INT_BASE + MSC01E_INT_PERFCTR;
1000 } else {
1001#endif
1002 if (cp0_perfcount_irq >= 0)
1003 irq = MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;
1004 else
1005 irq = -1;
1006#ifdef MSC01E_INT_BASE
1007 }
1008#endif
1009
1010 on_each_cpu(reset_counters, (void *)(long)counters, 1);
1011
1012 switch (current_cpu_type()) {
1013 case CPU_24K:
1014 mipsxxcore_pmu.name = "mips/24K";
1015 mipsxxcore_pmu.num_counters = counters;
1016 mipsxxcore_pmu.irq = irq;
1017 mipspmu = &mipsxxcore_pmu;
1018 break;
1019 case CPU_34K:
1020 mipsxxcore_pmu.name = "mips/34K";
1021 mipsxxcore_pmu.num_counters = counters;
1022 mipsxxcore_pmu.irq = irq;
1023 mipspmu = &mipsxxcore_pmu;
1024 break;
1025 case CPU_74K:
1026 mipsxx74Kcore_pmu.name = "mips/74K";
1027 mipsxx74Kcore_pmu.num_counters = counters;
1028 mipsxx74Kcore_pmu.irq = irq;
1029 mipspmu = &mipsxx74Kcore_pmu;
1030 break;
1031 case CPU_1004K:
1032 mipsxxcore_pmu.name = "mips/1004K";
1033 mipsxxcore_pmu.num_counters = counters;
1034 mipsxxcore_pmu.irq = irq;
1035 mipspmu = &mipsxxcore_pmu;
1036 break;
1037 default:
1038 pr_cont("Either hardware does not support performance "
1039 "counters, or not yet implemented.\n");
1040 return -ENODEV;
1041 }
1042
1043 if (mipspmu)
1044 pr_cont("%s PMU enabled, %d counters available to each "
1045 "CPU, irq %d%s\n", mipspmu->name, counters, irq,
1046 irq < 0 ? " (share with timer interrupt)" : "");
1047
1048 return 0;
1049}
1050arch_initcall(init_hw_perf_events);
1051
1052#endif /* defined(CONFIG_CPU_MIPS32)... */
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 c8777333e198..d21c388c0116 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -255,9 +255,13 @@ int ptrace_set_watch_regs(struct task_struct *child,
255 return 0; 255 return 0;
256} 256}
257 257
258long arch_ptrace(struct task_struct *child, long request, long addr, long data) 258long arch_ptrace(struct task_struct *child, long request,
259 unsigned long addr, unsigned long data)
259{ 260{
260 int ret; 261 int ret;
262 void __user *addrp = (void __user *) addr;
263 void __user *datavp = (void __user *) data;
264 unsigned long __user *datalp = (void __user *) data;
261 265
262 switch (request) { 266 switch (request) {
263 /* when I and D space are separate, these will need to be fixed. */ 267 /* when I and D space are separate, these will need to be fixed. */
@@ -386,7 +390,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
386 ret = -EIO; 390 ret = -EIO;
387 goto out; 391 goto out;
388 } 392 }
389 ret = put_user(tmp, (unsigned long __user *) data); 393 ret = put_user(tmp, datalp);
390 break; 394 break;
391 } 395 }
392 396
@@ -478,34 +482,31 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
478 } 482 }
479 483
480 case PTRACE_GETREGS: 484 case PTRACE_GETREGS:
481 ret = ptrace_getregs(child, (__s64 __user *) data); 485 ret = ptrace_getregs(child, datavp);
482 break; 486 break;
483 487
484 case PTRACE_SETREGS: 488 case PTRACE_SETREGS:
485 ret = ptrace_setregs(child, (__s64 __user *) data); 489 ret = ptrace_setregs(child, datavp);
486 break; 490 break;
487 491
488 case PTRACE_GETFPREGS: 492 case PTRACE_GETFPREGS:
489 ret = ptrace_getfpregs(child, (__u32 __user *) data); 493 ret = ptrace_getfpregs(child, datavp);
490 break; 494 break;
491 495
492 case PTRACE_SETFPREGS: 496 case PTRACE_SETFPREGS:
493 ret = ptrace_setfpregs(child, (__u32 __user *) data); 497 ret = ptrace_setfpregs(child, datavp);
494 break; 498 break;
495 499
496 case PTRACE_GET_THREAD_AREA: 500 case PTRACE_GET_THREAD_AREA:
497 ret = put_user(task_thread_info(child)->tp_value, 501 ret = put_user(task_thread_info(child)->tp_value, datalp);
498 (unsigned long __user *) data);
499 break; 502 break;
500 503
501 case PTRACE_GET_WATCH_REGS: 504 case PTRACE_GET_WATCH_REGS:
502 ret = ptrace_get_watch_regs(child, 505 ret = ptrace_get_watch_regs(child, addrp);
503 (struct pt_watch_regs __user *) addr);
504 break; 506 break;
505 507
506 case PTRACE_SET_WATCH_REGS: 508 case PTRACE_SET_WATCH_REGS:
507 ret = ptrace_set_watch_regs(child, 509 ret = ptrace_set_watch_regs(child, addrp);
508 (struct pt_watch_regs __user *) addr);
509 break; 510 break;
510 511
511 default: 512 default:
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/setup.c b/arch/mips/kernel/setup.c
index 85aef3fc6716..acd3f2c49c06 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,7 +488,9 @@ 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();
493 plat_swiotlb_setup();
491 paging_init(); 494 paging_init();
492} 495}
493 496
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index d053bf4759e4..8e9fbe75894e 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -29,6 +29,7 @@
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#include <linux/irq.h>
32#include <linux/perf_event.h>
32 33
33#include <asm/bootinfo.h> 34#include <asm/bootinfo.h>
34#include <asm/branch.h> 35#include <asm/branch.h>
@@ -576,10 +577,16 @@ static inline int simulate_sc(struct pt_regs *regs, unsigned int opcode)
576 */ 577 */
577static int simulate_llsc(struct pt_regs *regs, unsigned int opcode) 578static int simulate_llsc(struct pt_regs *regs, unsigned int opcode)
578{ 579{
579 if ((opcode & OPCODE) == LL) 580 if ((opcode & OPCODE) == LL) {
581 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
582 1, 0, regs, 0);
580 return simulate_ll(regs, opcode); 583 return simulate_ll(regs, opcode);
581 if ((opcode & OPCODE) == SC) 584 }
585 if ((opcode & OPCODE) == SC) {
586 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
587 1, 0, regs, 0);
582 return simulate_sc(regs, opcode); 588 return simulate_sc(regs, opcode);
589 }
583 590
584 return -1; /* Must be something else ... */ 591 return -1; /* Must be something else ... */
585} 592}
@@ -595,6 +602,8 @@ static int simulate_rdhwr(struct pt_regs *regs, unsigned int opcode)
595 if ((opcode & OPCODE) == SPEC3 && (opcode & FUNC) == RDHWR) { 602 if ((opcode & OPCODE) == SPEC3 && (opcode & FUNC) == RDHWR) {
596 int rd = (opcode & RD) >> 11; 603 int rd = (opcode & RD) >> 11;
597 int rt = (opcode & RT) >> 16; 604 int rt = (opcode & RT) >> 16;
605 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
606 1, 0, regs, 0);
598 switch (rd) { 607 switch (rd) {
599 case 0: /* CPU number */ 608 case 0: /* CPU number */
600 regs->regs[rt] = smp_processor_id(); 609 regs->regs[rt] = smp_processor_id();
@@ -630,8 +639,11 @@ static int simulate_rdhwr(struct pt_regs *regs, unsigned int opcode)
630 639
631static int simulate_sync(struct pt_regs *regs, unsigned int opcode) 640static int simulate_sync(struct pt_regs *regs, unsigned int opcode)
632{ 641{
633 if ((opcode & OPCODE) == SPEC0 && (opcode & FUNC) == SYNC) 642 if ((opcode & OPCODE) == SPEC0 && (opcode & FUNC) == SYNC) {
643 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
644 1, 0, regs, 0);
634 return 0; 645 return 0;
646 }
635 647
636 return -1; /* Must be something else ... */ 648 return -1; /* Must be something else ... */
637} 649}
@@ -1469,6 +1481,7 @@ void __cpuinit per_cpu_trap_init(void)
1469{ 1481{
1470 unsigned int cpu = smp_processor_id(); 1482 unsigned int cpu = smp_processor_id();
1471 unsigned int status_set = ST0_CU0; 1483 unsigned int status_set = ST0_CU0;
1484 unsigned int hwrena = cpu_hwrena_impl_bits;
1472#ifdef CONFIG_MIPS_MT_SMTC 1485#ifdef CONFIG_MIPS_MT_SMTC
1473 int secondaryTC = 0; 1486 int secondaryTC = 0;
1474 int bootTC = (cpu == 0); 1487 int bootTC = (cpu == 0);
@@ -1501,14 +1514,14 @@ void __cpuinit per_cpu_trap_init(void)
1501 change_c0_status(ST0_CU|ST0_MX|ST0_RE|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX, 1514 change_c0_status(ST0_CU|ST0_MX|ST0_RE|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX,
1502 status_set); 1515 status_set);
1503 1516
1504 if (cpu_has_mips_r2) { 1517 if (cpu_has_mips_r2)
1505 unsigned int enable = 0x0000000f | cpu_hwrena_impl_bits; 1518 hwrena |= 0x0000000f;
1506 1519
1507 if (!noulri && cpu_has_userlocal) 1520 if (!noulri && cpu_has_userlocal)
1508 enable |= (1 << 29); 1521 hwrena |= (1 << 29);
1509 1522
1510 write_c0_hwrena(enable); 1523 if (hwrena)
1511 } 1524 write_c0_hwrena(hwrena);
1512 1525
1513#ifdef CONFIG_MIPS_MT_SMTC 1526#ifdef CONFIG_MIPS_MT_SMTC
1514 if (!secondaryTC) { 1527 if (!secondaryTC) {
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 33d5a5ce4a29..cfea1adfa153 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -78,6 +78,8 @@
78#include <linux/smp.h> 78#include <linux/smp.h>
79#include <linux/sched.h> 79#include <linux/sched.h>
80#include <linux/debugfs.h> 80#include <linux/debugfs.h>
81#include <linux/perf_event.h>
82
81#include <asm/asm.h> 83#include <asm/asm.h>
82#include <asm/branch.h> 84#include <asm/branch.h>
83#include <asm/byteorder.h> 85#include <asm/byteorder.h>
@@ -109,6 +111,9 @@ static void emulate_load_store_insn(struct pt_regs *regs,
109 unsigned long value; 111 unsigned long value;
110 unsigned int res; 112 unsigned int res;
111 113
114 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
115 1, 0, regs, 0);
116
112 /* 117 /*
113 * This load never faults. 118 * This load never faults.
114 */ 119 */
@@ -511,6 +516,8 @@ asmlinkage void do_ade(struct pt_regs *regs)
511 unsigned int __user *pc; 516 unsigned int __user *pc;
512 mm_segment_t seg; 517 mm_segment_t seg;
513 518
519 perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS,
520 1, 0, regs, regs->cp0_badvaddr);
514 /* 521 /*
515 * Did we catch a fault trying to load an instruction? 522 * Did we catch a fault trying to load an instruction?
516 * Or are we running in MIPS16 mode? 523 * Or are we running in MIPS16 mode?
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/loongson/Kconfig b/arch/mips/loongson/Kconfig
index c97ca69b94e0..6e1b77fec7ea 100644
--- a/arch/mips/loongson/Kconfig
+++ b/arch/mips/loongson/Kconfig
@@ -20,7 +20,6 @@ config LEMOTE_FULOONG2E
20 select SYS_SUPPORTS_LITTLE_ENDIAN 20 select SYS_SUPPORTS_LITTLE_ENDIAN
21 select SYS_SUPPORTS_HIGHMEM 21 select SYS_SUPPORTS_HIGHMEM
22 select SYS_HAS_EARLY_PRINTK 22 select SYS_HAS_EARLY_PRINTK
23 select GENERIC_HARDIRQS_NO__DO_IRQ
24 select GENERIC_ISA_DMA_SUPPORT_BROKEN 23 select GENERIC_ISA_DMA_SUPPORT_BROKEN
25 select CPU_HAS_WB 24 select CPU_HAS_WB
26 select LOONGSON_MC146818 25 select LOONGSON_MC146818
@@ -40,7 +39,6 @@ config LEMOTE_MACH2F
40 select CS5536 39 select CS5536
41 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER 40 select CSRC_R4K if ! MIPS_EXTERNAL_TIMER
42 select DMA_NONCOHERENT 41 select DMA_NONCOHERENT
43 select GENERIC_HARDIRQS_NO__DO_IRQ
44 select GENERIC_ISA_DMA_SUPPORT_BROKEN 42 select GENERIC_ISA_DMA_SUPPORT_BROKEN
45 select HW_HAS_PCI 43 select HW_HAS_PCI
46 select I8259 44 select I8259
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 47842b7d26ae..b2ad1b0910ff 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.
@@ -37,6 +36,7 @@
37#include <linux/sched.h> 36#include <linux/sched.h>
38#include <linux/module.h> 37#include <linux/module.h>
39#include <linux/debugfs.h> 38#include <linux/debugfs.h>
39#include <linux/perf_event.h>
40 40
41#include <asm/inst.h> 41#include <asm/inst.h>
42#include <asm/bootinfo.h> 42#include <asm/bootinfo.h>
@@ -259,6 +259,8 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
259 } 259 }
260 260
261 emul: 261 emul:
262 perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS,
263 1, 0, xcp, 0);
262 MIPS_FPU_EMU_INC_STATS(emulated); 264 MIPS_FPU_EMU_INC_STATS(emulated);
263 switch (MIPSInst_OPCODE(ir)) { 265 switch (MIPSInst_OPCODE(ir)) {
264 case ldc1_op:{ 266 case ldc1_op:{
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/c-octeon.c b/arch/mips/mm/c-octeon.c
index 0f9c488044d1..16c4d256b76f 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -181,10 +181,10 @@ static void __cpuinit probe_octeon(void)
181 unsigned int config1; 181 unsigned int config1;
182 struct cpuinfo_mips *c = &current_cpu_data; 182 struct cpuinfo_mips *c = &current_cpu_data;
183 183
184 config1 = read_c0_config1();
184 switch (c->cputype) { 185 switch (c->cputype) {
185 case CPU_CAVIUM_OCTEON: 186 case CPU_CAVIUM_OCTEON:
186 case CPU_CAVIUM_OCTEON_PLUS: 187 case CPU_CAVIUM_OCTEON_PLUS:
187 config1 = read_c0_config1();
188 c->icache.linesz = 2 << ((config1 >> 19) & 7); 188 c->icache.linesz = 2 << ((config1 >> 19) & 7);
189 c->icache.sets = 64 << ((config1 >> 22) & 7); 189 c->icache.sets = 64 << ((config1 >> 22) & 7);
190 c->icache.ways = 1 + ((config1 >> 16) & 7); 190 c->icache.ways = 1 + ((config1 >> 16) & 7);
@@ -204,6 +204,20 @@ static void __cpuinit probe_octeon(void)
204 c->options |= MIPS_CPU_PREFETCH; 204 c->options |= MIPS_CPU_PREFETCH;
205 break; 205 break;
206 206
207 case CPU_CAVIUM_OCTEON2:
208 c->icache.linesz = 2 << ((config1 >> 19) & 7);
209 c->icache.sets = 8;
210 c->icache.ways = 37;
211 c->icache.flags |= MIPS_CACHE_VTAG;
212 icache_size = c->icache.sets * c->icache.ways * c->icache.linesz;
213
214 c->dcache.linesz = 128;
215 c->dcache.ways = 32;
216 c->dcache.sets = 8;
217 dcache_size = c->dcache.sets * c->dcache.ways * c->dcache.linesz;
218 c->options |= MIPS_CPU_PREFETCH;
219 break;
220
207 default: 221 default:
208 panic("Unsupported Cavium Networks CPU type\n"); 222 panic("Unsupported Cavium Networks CPU type\n");
209 break; 223 break;
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 6721ee2b1e8b..b4923a75cb4b 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -42,14 +42,14 @@
42 * o collapses to normal function call on UP kernels 42 * o collapses to normal function call on UP kernels
43 * o collapses to normal function call on systems with a single shared 43 * o collapses to normal function call on systems with a single shared
44 * primary cache. 44 * primary cache.
45 * o doesn't disable interrupts on the local CPU
45 */ 46 */
46static inline void r4k_on_each_cpu(void (*func) (void *info), void *info, 47static inline void r4k_on_each_cpu(void (*func) (void *info), void *info)
47 int wait)
48{ 48{
49 preempt_disable(); 49 preempt_disable();
50 50
51#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC) 51#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
52 smp_call_function(func, info, wait); 52 smp_call_function(func, info, 1);
53#endif 53#endif
54 func(info); 54 func(info);
55 preempt_enable(); 55 preempt_enable();
@@ -363,7 +363,7 @@ static inline void local_r4k___flush_cache_all(void * args)
363 363
364static void r4k___flush_cache_all(void) 364static void r4k___flush_cache_all(void)
365{ 365{
366 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1); 366 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL);
367} 367}
368 368
369static inline int has_valid_asid(const struct mm_struct *mm) 369static inline int has_valid_asid(const struct mm_struct *mm)
@@ -410,7 +410,7 @@ static void r4k_flush_cache_range(struct vm_area_struct *vma,
410 int exec = vma->vm_flags & VM_EXEC; 410 int exec = vma->vm_flags & VM_EXEC;
411 411
412 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) 412 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
413 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1); 413 r4k_on_each_cpu(local_r4k_flush_cache_range, vma);
414} 414}
415 415
416static inline void local_r4k_flush_cache_mm(void * args) 416static inline void local_r4k_flush_cache_mm(void * args)
@@ -442,7 +442,7 @@ static void r4k_flush_cache_mm(struct mm_struct *mm)
442 if (!cpu_has_dc_aliases) 442 if (!cpu_has_dc_aliases)
443 return; 443 return;
444 444
445 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1); 445 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm);
446} 446}
447 447
448struct flush_cache_page_args { 448struct flush_cache_page_args {
@@ -534,7 +534,7 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma,
534 args.addr = addr; 534 args.addr = addr;
535 args.pfn = pfn; 535 args.pfn = pfn;
536 536
537 r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1); 537 r4k_on_each_cpu(local_r4k_flush_cache_page, &args);
538} 538}
539 539
540static inline void local_r4k_flush_data_cache_page(void * addr) 540static inline void local_r4k_flush_data_cache_page(void * addr)
@@ -547,8 +547,7 @@ static void r4k_flush_data_cache_page(unsigned long addr)
547 if (in_atomic()) 547 if (in_atomic())
548 local_r4k_flush_data_cache_page((void *)addr); 548 local_r4k_flush_data_cache_page((void *)addr);
549 else 549 else
550 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 550 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr);
551 1);
552} 551}
553 552
554struct flush_icache_range_args { 553struct flush_icache_range_args {
@@ -589,7 +588,7 @@ static void r4k_flush_icache_range(unsigned long start, unsigned long end)
589 args.start = start; 588 args.start = start;
590 args.end = end; 589 args.end = end;
591 590
592 r4k_on_each_cpu(local_r4k_flush_icache_range_ipi, &args, 1); 591 r4k_on_each_cpu(local_r4k_flush_icache_range_ipi, &args);
593 instruction_hazard(); 592 instruction_hazard();
594} 593}
595 594
@@ -710,7 +709,7 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
710 709
711static void r4k_flush_cache_sigtramp(unsigned long addr) 710static void r4k_flush_cache_sigtramp(unsigned long addr)
712{ 711{
713 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1); 712 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr);
714} 713}
715 714
716static void r4k_flush_icache_all(void) 715static void r4k_flush_icache_all(void)
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index 469d4019f795..4fc1a0fbe007 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -95,10 +95,9 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
95 95
96 return ret; 96 return ret;
97} 97}
98
99EXPORT_SYMBOL(dma_alloc_noncoherent); 98EXPORT_SYMBOL(dma_alloc_noncoherent);
100 99
101void *dma_alloc_coherent(struct device *dev, size_t size, 100static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
102 dma_addr_t * dma_handle, gfp_t gfp) 101 dma_addr_t * dma_handle, gfp_t gfp)
103{ 102{
104 void *ret; 103 void *ret;
@@ -123,7 +122,6 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
123 return ret; 122 return ret;
124} 123}
125 124
126EXPORT_SYMBOL(dma_alloc_coherent);
127 125
128void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr, 126void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
129 dma_addr_t dma_handle) 127 dma_addr_t dma_handle)
@@ -131,10 +129,9 @@ void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
131 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL); 129 plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
132 free_pages((unsigned long) vaddr, get_order(size)); 130 free_pages((unsigned long) vaddr, get_order(size));
133} 131}
134
135EXPORT_SYMBOL(dma_free_noncoherent); 132EXPORT_SYMBOL(dma_free_noncoherent);
136 133
137void dma_free_coherent(struct device *dev, size_t size, void *vaddr, 134static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
138 dma_addr_t dma_handle) 135 dma_addr_t dma_handle)
139{ 136{
140 unsigned long addr = (unsigned long) vaddr; 137 unsigned long addr = (unsigned long) vaddr;
@@ -151,8 +148,6 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
151 free_pages(addr, get_order(size)); 148 free_pages(addr, get_order(size));
152} 149}
153 150
154EXPORT_SYMBOL(dma_free_coherent);
155
156static inline void __dma_sync(unsigned long addr, size_t size, 151static inline void __dma_sync(unsigned long addr, size_t size,
157 enum dma_data_direction direction) 152 enum dma_data_direction direction)
158{ 153{
@@ -174,21 +169,8 @@ static inline void __dma_sync(unsigned long addr, size_t size,
174 } 169 }
175} 170}
176 171
177dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, 172static void mips_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
178 enum dma_data_direction direction) 173 size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
179{
180 unsigned long addr = (unsigned long) ptr;
181
182 if (!plat_device_is_coherent(dev))
183 __dma_sync(addr, size, direction);
184
185 return plat_map_dma_mem(dev, ptr, size);
186}
187
188EXPORT_SYMBOL(dma_map_single);
189
190void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
191 enum dma_data_direction direction)
192{ 174{
193 if (cpu_is_noncoherent_r10000(dev)) 175 if (cpu_is_noncoherent_r10000(dev))
194 __dma_sync(dma_addr_to_virt(dev, dma_addr), size, 176 __dma_sync(dma_addr_to_virt(dev, dma_addr), size,
@@ -197,15 +179,11 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
197 plat_unmap_dma_mem(dev, dma_addr, size, direction); 179 plat_unmap_dma_mem(dev, dma_addr, size, direction);
198} 180}
199 181
200EXPORT_SYMBOL(dma_unmap_single); 182static int mips_dma_map_sg(struct device *dev, struct scatterlist *sg,
201 183 int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
202int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
203 enum dma_data_direction direction)
204{ 184{
205 int i; 185 int i;
206 186
207 BUG_ON(direction == DMA_NONE);
208
209 for (i = 0; i < nents; i++, sg++) { 187 for (i = 0; i < nents; i++, sg++) {
210 unsigned long addr; 188 unsigned long addr;
211 189
@@ -219,33 +197,27 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
219 return nents; 197 return nents;
220} 198}
221 199
222EXPORT_SYMBOL(dma_map_sg); 200static dma_addr_t mips_dma_map_page(struct device *dev, struct page *page,
223 201 unsigned long offset, size_t size, enum dma_data_direction direction,
224dma_addr_t dma_map_page(struct device *dev, struct page *page, 202 struct dma_attrs *attrs)
225 unsigned long offset, size_t size, enum dma_data_direction direction)
226{ 203{
227 BUG_ON(direction == DMA_NONE); 204 unsigned long addr;
228 205
229 if (!plat_device_is_coherent(dev)) { 206 addr = (unsigned long) page_address(page) + offset;
230 unsigned long addr;
231 207
232 addr = (unsigned long) page_address(page) + offset; 208 if (!plat_device_is_coherent(dev))
233 __dma_sync(addr, size, direction); 209 __dma_sync(addr, size, direction);
234 }
235 210
236 return plat_map_dma_mem_page(dev, page) + offset; 211 return plat_map_dma_mem(dev, (void *)addr, size);
237} 212}
238 213
239EXPORT_SYMBOL(dma_map_page); 214static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
240 215 int nhwentries, enum dma_data_direction direction,
241void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, 216 struct dma_attrs *attrs)
242 enum dma_data_direction direction)
243{ 217{
244 unsigned long addr; 218 unsigned long addr;
245 int i; 219 int i;
246 220
247 BUG_ON(direction == DMA_NONE);
248
249 for (i = 0; i < nhwentries; i++, sg++) { 221 for (i = 0; i < nhwentries; i++, sg++) {
250 if (!plat_device_is_coherent(dev) && 222 if (!plat_device_is_coherent(dev) &&
251 direction != DMA_TO_DEVICE) { 223 direction != DMA_TO_DEVICE) {
@@ -257,13 +229,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
257 } 229 }
258} 230}
259 231
260EXPORT_SYMBOL(dma_unmap_sg); 232static void mips_dma_sync_single_for_cpu(struct device *dev,
261 233 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
262void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
263 size_t size, enum dma_data_direction direction)
264{ 234{
265 BUG_ON(direction == DMA_NONE);
266
267 if (cpu_is_noncoherent_r10000(dev)) { 235 if (cpu_is_noncoherent_r10000(dev)) {
268 unsigned long addr; 236 unsigned long addr;
269 237
@@ -272,13 +240,9 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
272 } 240 }
273} 241}
274 242
275EXPORT_SYMBOL(dma_sync_single_for_cpu); 243static void mips_dma_sync_single_for_device(struct device *dev,
276 244 dma_addr_t dma_handle, size_t size, enum dma_data_direction direction)
277void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
278 size_t size, enum dma_data_direction direction)
279{ 245{
280 BUG_ON(direction == DMA_NONE);
281
282 plat_extra_sync_for_device(dev); 246 plat_extra_sync_for_device(dev);
283 if (!plat_device_is_coherent(dev)) { 247 if (!plat_device_is_coherent(dev)) {
284 unsigned long addr; 248 unsigned long addr;
@@ -288,46 +252,11 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
288 } 252 }
289} 253}
290 254
291EXPORT_SYMBOL(dma_sync_single_for_device); 255static void mips_dma_sync_sg_for_cpu(struct device *dev,
292 256 struct scatterlist *sg, int nelems, enum dma_data_direction direction)
293void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
294 unsigned long offset, size_t size, enum dma_data_direction direction)
295{
296 BUG_ON(direction == DMA_NONE);
297
298 if (cpu_is_noncoherent_r10000(dev)) {
299 unsigned long addr;
300
301 addr = dma_addr_to_virt(dev, dma_handle);
302 __dma_sync(addr + offset, size, direction);
303 }
304}
305
306EXPORT_SYMBOL(dma_sync_single_range_for_cpu);
307
308void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
309 unsigned long offset, size_t size, enum dma_data_direction direction)
310{
311 BUG_ON(direction == DMA_NONE);
312
313 plat_extra_sync_for_device(dev);
314 if (!plat_device_is_coherent(dev)) {
315 unsigned long addr;
316
317 addr = dma_addr_to_virt(dev, dma_handle);
318 __dma_sync(addr + offset, size, direction);
319 }
320}
321
322EXPORT_SYMBOL(dma_sync_single_range_for_device);
323
324void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
325 enum dma_data_direction direction)
326{ 257{
327 int i; 258 int i;
328 259
329 BUG_ON(direction == DMA_NONE);
330
331 /* Make sure that gcc doesn't leave the empty loop body. */ 260 /* Make sure that gcc doesn't leave the empty loop body. */
332 for (i = 0; i < nelems; i++, sg++) { 261 for (i = 0; i < nelems; i++, sg++) {
333 if (cpu_is_noncoherent_r10000(dev)) 262 if (cpu_is_noncoherent_r10000(dev))
@@ -336,15 +265,11 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
336 } 265 }
337} 266}
338 267
339EXPORT_SYMBOL(dma_sync_sg_for_cpu); 268static void mips_dma_sync_sg_for_device(struct device *dev,
340 269 struct scatterlist *sg, int nelems, enum dma_data_direction direction)
341void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
342 enum dma_data_direction direction)
343{ 270{
344 int i; 271 int i;
345 272
346 BUG_ON(direction == DMA_NONE);
347
348 /* Make sure that gcc doesn't leave the empty loop body. */ 273 /* Make sure that gcc doesn't leave the empty loop body. */
349 for (i = 0; i < nelems; i++, sg++) { 274 for (i = 0; i < nelems; i++, sg++) {
350 if (!plat_device_is_coherent(dev)) 275 if (!plat_device_is_coherent(dev))
@@ -353,24 +278,18 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele
353 } 278 }
354} 279}
355 280
356EXPORT_SYMBOL(dma_sync_sg_for_device); 281int mips_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
357
358int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
359{ 282{
360 return plat_dma_mapping_error(dev, dma_addr); 283 return plat_dma_mapping_error(dev, dma_addr);
361} 284}
362 285
363EXPORT_SYMBOL(dma_mapping_error); 286int mips_dma_supported(struct device *dev, u64 mask)
364
365int dma_supported(struct device *dev, u64 mask)
366{ 287{
367 return plat_dma_supported(dev, mask); 288 return plat_dma_supported(dev, mask);
368} 289}
369 290
370EXPORT_SYMBOL(dma_supported); 291void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size,
371 292 enum dma_data_direction direction)
372void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
373 enum dma_data_direction direction)
374{ 293{
375 BUG_ON(direction == DMA_NONE); 294 BUG_ON(direction == DMA_NONE);
376 295
@@ -379,4 +298,30 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
379 __dma_sync((unsigned long)vaddr, size, direction); 298 __dma_sync((unsigned long)vaddr, size, direction);
380} 299}
381 300
382EXPORT_SYMBOL(dma_cache_sync); 301static struct dma_map_ops mips_default_dma_map_ops = {
302 .alloc_coherent = mips_dma_alloc_coherent,
303 .free_coherent = mips_dma_free_coherent,
304 .map_page = mips_dma_map_page,
305 .unmap_page = mips_dma_unmap_page,
306 .map_sg = mips_dma_map_sg,
307 .unmap_sg = mips_dma_unmap_sg,
308 .sync_single_for_cpu = mips_dma_sync_single_for_cpu,
309 .sync_single_for_device = mips_dma_sync_single_for_device,
310 .sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
311 .sync_sg_for_device = mips_dma_sync_sg_for_device,
312 .mapping_error = mips_dma_mapping_error,
313 .dma_supported = mips_dma_supported
314};
315
316struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
317EXPORT_SYMBOL(mips_dma_map_ops);
318
319#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
320
321static int __init mips_dma_init(void)
322{
323 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
324
325 return 0;
326}
327fs_initcall(mips_dma_init);
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 783ad0065fdf..137ee76a0045 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -18,6 +18,7 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kprobes.h> 20#include <linux/kprobes.h>
21#include <linux/perf_event.h>
21 22
22#include <asm/branch.h> 23#include <asm/branch.h>
23#include <asm/mmu_context.h> 24#include <asm/mmu_context.h>
@@ -144,6 +145,7 @@ good_area:
144 * the fault. 145 * the fault.
145 */ 146 */
146 fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); 147 fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0);
148 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address);
147 if (unlikely(fault & VM_FAULT_ERROR)) { 149 if (unlikely(fault & VM_FAULT_ERROR)) {
148 if (fault & VM_FAULT_OOM) 150 if (fault & VM_FAULT_OOM)
149 goto out_of_memory; 151 goto out_of_memory;
@@ -151,10 +153,15 @@ good_area:
151 goto do_sigbus; 153 goto do_sigbus;
152 BUG(); 154 BUG();
153 } 155 }
154 if (fault & VM_FAULT_MAJOR) 156 if (fault & VM_FAULT_MAJOR) {
157 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
158 1, 0, regs, address);
155 tsk->maj_flt++; 159 tsk->maj_flt++;
156 else 160 } else {
161 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
162 1, 0, regs, address);
157 tsk->min_flt++; 163 tsk->min_flt++;
164 }
158 165
159 up_read(&mm->mmap_sem); 166 up_read(&mm->mmap_sem);
160 return; 167 return;
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
index 6a2b1bf9ef11..3634c7ea06ac 100644
--- a/arch/mips/mm/highmem.c
+++ b/arch/mips/mm/highmem.c
@@ -9,7 +9,7 @@ static pte_t *kmap_pte;
9 9
10unsigned long highstart_pfn, highend_pfn; 10unsigned long highstart_pfn, highend_pfn;
11 11
12void *__kmap(struct page *page) 12void *kmap(struct page *page)
13{ 13{
14 void *addr; 14 void *addr;
15 15
@@ -21,16 +21,16 @@ void *__kmap(struct page *page)
21 21
22 return addr; 22 return addr;
23} 23}
24EXPORT_SYMBOL(__kmap); 24EXPORT_SYMBOL(kmap);
25 25
26void __kunmap(struct page *page) 26void kunmap(struct page *page)
27{ 27{
28 BUG_ON(in_interrupt()); 28 BUG_ON(in_interrupt());
29 if (!PageHighMem(page)) 29 if (!PageHighMem(page))
30 return; 30 return;
31 kunmap_high(page); 31 kunmap_high(page);
32} 32}
33EXPORT_SYMBOL(__kunmap); 33EXPORT_SYMBOL(kunmap);
34 34
35/* 35/*
36 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because 36 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because
@@ -41,17 +41,17 @@ EXPORT_SYMBOL(__kunmap);
41 * kmaps are appropriate for short, tight code paths only. 41 * kmaps are appropriate for short, tight code paths only.
42 */ 42 */
43 43
44void *__kmap_atomic(struct page *page, enum km_type type) 44void *__kmap_atomic(struct page *page)
45{ 45{
46 enum fixed_addresses idx;
47 unsigned long vaddr; 46 unsigned long vaddr;
47 int idx, type;
48 48
49 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 49 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
50 pagefault_disable(); 50 pagefault_disable();
51 if (!PageHighMem(page)) 51 if (!PageHighMem(page))
52 return page_address(page); 52 return page_address(page);
53 53
54 debug_kmap_atomic(type); 54 type = kmap_atomic_idx_push();
55 idx = type + KM_TYPE_NR*smp_processor_id(); 55 idx = type + KM_TYPE_NR*smp_processor_id();
56 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 56 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
57#ifdef CONFIG_DEBUG_HIGHMEM 57#ifdef CONFIG_DEBUG_HIGHMEM
@@ -64,43 +64,48 @@ void *__kmap_atomic(struct page *page, enum km_type type)
64} 64}
65EXPORT_SYMBOL(__kmap_atomic); 65EXPORT_SYMBOL(__kmap_atomic);
66 66
67void __kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 67void __kunmap_atomic(void *kvaddr)
68{ 68{
69#ifdef CONFIG_DEBUG_HIGHMEM
70 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 69 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
71 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 70 int type;
72 71
73 if (vaddr < FIXADDR_START) { // FIXME 72 if (vaddr < FIXADDR_START) { // FIXME
74 pagefault_enable(); 73 pagefault_enable();
75 return; 74 return;
76 } 75 }
77 76
78 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 77 type = kmap_atomic_idx();
78#ifdef CONFIG_DEBUG_HIGHMEM
79 {
80 int idx = type + KM_TYPE_NR * smp_processor_id();
79 81
80 /* 82 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
81 * force other mappings to Oops if they'll try to access
82 * this pte without first remap it
83 */
84 pte_clear(&init_mm, vaddr, kmap_pte-idx);
85 local_flush_tlb_one(vaddr);
86#endif
87 83
84 /*
85 * force other mappings to Oops if they'll try to access
86 * this pte without first remap it
87 */
88 pte_clear(&init_mm, vaddr, kmap_pte-idx);
89 local_flush_tlb_one(vaddr);
90 }
91#endif
92 kmap_atomic_idx_pop();
88 pagefault_enable(); 93 pagefault_enable();
89} 94}
90EXPORT_SYMBOL(__kunmap_atomic_notypecheck); 95EXPORT_SYMBOL(__kunmap_atomic);
91 96
92/* 97/*
93 * This is the same as kmap_atomic() but can map memory that doesn't 98 * This is the same as kmap_atomic() but can map memory that doesn't
94 * have a struct page associated with it. 99 * have a struct page associated with it.
95 */ 100 */
96void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) 101void *kmap_atomic_pfn(unsigned long pfn)
97{ 102{
98 enum fixed_addresses idx;
99 unsigned long vaddr; 103 unsigned long vaddr;
104 int idx, type;
100 105
101 pagefault_disable(); 106 pagefault_disable();
102 107
103 debug_kmap_atomic(type); 108 type = kmap_atomic_idx_push();
104 idx = type + KM_TYPE_NR*smp_processor_id(); 109 idx = type + KM_TYPE_NR*smp_processor_id();
105 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 110 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
106 set_pte(kmap_pte-idx, pfn_pte(pfn, PAGE_KERNEL)); 111 set_pte(kmap_pte-idx, pfn_pte(pfn, PAGE_KERNEL));
@@ -109,7 +114,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
109 return (void*) vaddr; 114 return (void*) vaddr;
110} 115}
111 116
112struct page *__kmap_atomic_to_page(void *ptr) 117struct page *kmap_atomic_to_page(void *ptr)
113{ 118{
114 unsigned long idx, vaddr = (unsigned long)ptr; 119 unsigned long idx, vaddr = (unsigned long)ptr;
115 pte_t *pte; 120 pte_t *pte;
diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index 5ab5fa8c1d82..505fecad4684 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -57,6 +57,34 @@ static struct bcache_ops mips_sc_ops = {
57 .bc_inv = mips_sc_inv 57 .bc_inv = mips_sc_inv
58}; 58};
59 59
60/*
61 * Check if the L2 cache controller is activated on a particular platform.
62 * MTI's L2 controller and the L2 cache controller of Broadcom's BMIPS
63 * cores both use c0_config2's bit 12 as "L2 Bypass" bit, that is the
64 * cache being disabled. However there is no guarantee for this to be
65 * true on all platforms. In an act of stupidity the spec defined bits
66 * 12..15 as implementation defined so below function will eventually have
67 * to be replaced by a platform specific probe.
68 */
69static inline int mips_sc_is_activated(struct cpuinfo_mips *c)
70{
71 /* Check the bypass bit (L2B) */
72 switch (c->cputype) {
73 case CPU_34K:
74 case CPU_74K:
75 case CPU_1004K:
76 case CPU_BMIPS5000:
77 if (config2 & (1 << 12))
78 return 0;
79 }
80
81 tmp = (config2 >> 4) & 0x0f;
82 if (0 < tmp && tmp <= 7)
83 c->scache.linesz = 2 << tmp;
84 else
85 return 0;
86}
87
60static inline int __init mips_sc_probe(void) 88static inline int __init mips_sc_probe(void)
61{ 89{
62 struct cpuinfo_mips *c = &current_cpu_data; 90 struct cpuinfo_mips *c = &current_cpu_data;
@@ -79,10 +107,8 @@ static inline int __init mips_sc_probe(void)
79 return 0; 107 return 0;
80 108
81 config2 = read_c0_config2(); 109 config2 = read_c0_config2();
82 tmp = (config2 >> 4) & 0x0f; 110
83 if (0 < tmp && tmp <= 7) 111 if (!mips_sc_is_activated(c))
84 c->scache.linesz = 2 << tmp;
85 else
86 return 0; 112 return 0;
87 113
88 tmp = (config2 >> 8) & 0x0f; 114 tmp = (config2 >> 8) & 0x0f;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 4510e61883eb..93816f3bca67 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -338,13 +338,12 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
338 case CPU_4KSC: 338 case CPU_4KSC:
339 case CPU_20KC: 339 case CPU_20KC:
340 case CPU_25KF: 340 case CPU_25KF:
341 case CPU_BCM3302: 341 case CPU_BMIPS32:
342 case CPU_BCM4710: 342 case CPU_BMIPS3300:
343 case CPU_BMIPS4350:
344 case CPU_BMIPS4380:
345 case CPU_BMIPS5000:
343 case CPU_LOONGSON2: 346 case CPU_LOONGSON2:
344 case CPU_BCM6338:
345 case CPU_BCM6345:
346 case CPU_BCM6348:
347 case CPU_BCM6358:
348 case CPU_R5500: 347 case CPU_R5500:
349 if (m4kc_tlbp_war()) 348 if (m4kc_tlbp_war())
350 uasm_i_nop(p); 349 uasm_i_nop(p);
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index d2647a4e012b..23afdebc8e5c 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -405,7 +405,6 @@ I_u1u2u3(_mfc0)
405I_u1u2u3(_mtc0) 405I_u1u2u3(_mtc0)
406I_u2u1u3(_ori) 406I_u2u1u3(_ori)
407I_u3u1u2(_or) 407I_u3u1u2(_or)
408I_u2s3u1(_pref)
409I_0(_rfe) 408I_0(_rfe)
410I_u2s3u1(_sc) 409I_u2s3u1(_sc)
411I_u2s3u1(_scd) 410I_u2s3u1(_scd)
@@ -427,6 +426,25 @@ I_u1(_syscall);
427I_u1u2s3(_bbit0); 426I_u1u2s3(_bbit0);
428I_u1u2s3(_bbit1); 427I_u1u2s3(_bbit1);
429 428
429#ifdef CONFIG_CPU_CAVIUM_OCTEON
430#include <asm/octeon/octeon.h>
431void __uasminit uasm_i_pref(u32 **buf, unsigned int a, signed int b,
432 unsigned int c)
433{
434 if (OCTEON_IS_MODEL(OCTEON_CN63XX_PASS1_X) && a <= 24 && a != 5)
435 /*
436 * As per erratum Core-14449, replace prefetches 0-4,
437 * 6-24 with 'pref 28'.
438 */
439 build_insn(buf, insn_pref, c, 28, b);
440 else
441 build_insn(buf, insn_pref, c, a, b);
442}
443UASM_EXPORT_SYMBOL(uasm_i_pref);
444#else
445I_u2s3u1(_pref)
446#endif
447
430/* Handle labels. */ 448/* Handle labels. */
431void __uasminit uasm_build_label(struct uasm_label **lab, u32 *addr, int lid) 449void __uasminit uasm_build_label(struct uasm_label **lab, u32 *addr, int lid)
432{ 450{
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/pci-octeon.c b/arch/mips/pci/pci-octeon.c
index d248b707eff3..2d74fc9ae3ba 100644
--- a/arch/mips/pci/pci-octeon.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -11,6 +11,7 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/time.h> 12#include <linux/time.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/swiotlb.h>
14 15
15#include <asm/time.h> 16#include <asm/time.h>
16 17
@@ -19,6 +20,8 @@
19#include <asm/octeon/cvmx-pci-defs.h> 20#include <asm/octeon/cvmx-pci-defs.h>
20#include <asm/octeon/pci-octeon.h> 21#include <asm/octeon/pci-octeon.h>
21 22
23#include <dma-coherence.h>
24
22#define USE_OCTEON_INTERNAL_ARBITER 25#define USE_OCTEON_INTERNAL_ARBITER
23 26
24/* 27/*
@@ -32,6 +35,8 @@
32/* Octeon't PCI controller uses did=3, subdid=3 for PCI memory. */ 35/* Octeon't PCI controller uses did=3, subdid=3 for PCI memory. */
33#define OCTEON_PCI_MEMSPACE_OFFSET (0x00011b0000000000ull) 36#define OCTEON_PCI_MEMSPACE_OFFSET (0x00011b0000000000ull)
34 37
38u64 octeon_bar1_pci_phys;
39
35/** 40/**
36 * This is the bit decoding used for the Octeon PCI controller addresses 41 * This is the bit decoding used for the Octeon PCI controller addresses
37 */ 42 */
@@ -170,6 +175,8 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
170 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig); 175 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
171 } 176 }
172 177
178 dev->dev.archdata.dma_ops = octeon_pci_dma_map_ops;
179
173 return 0; 180 return 0;
174} 181}
175 182
@@ -618,12 +625,10 @@ static int __init octeon_pci_setup(void)
618 * before the readl()'s below. We don't want BAR2 overlapping 625 * before the readl()'s below. We don't want BAR2 overlapping
619 * with BAR0/BAR1 during these reads. 626 * with BAR0/BAR1 during these reads.
620 */ 627 */
621 octeon_npi_write32(CVMX_NPI_PCI_CFG08, 0); 628 octeon_npi_write32(CVMX_NPI_PCI_CFG08,
622 octeon_npi_write32(CVMX_NPI_PCI_CFG09, 0x80); 629 (u32)(OCTEON_BAR2_PCI_ADDRESS & 0xffffffffull));
623 630 octeon_npi_write32(CVMX_NPI_PCI_CFG09,
624 /* Disable the BAR1 movable mappings */ 631 (u32)(OCTEON_BAR2_PCI_ADDRESS >> 32));
625 for (index = 0; index < 32; index++)
626 octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index), 0);
627 632
628 if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG) { 633 if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG) {
629 /* Remap the Octeon BAR 0 to 0-2GB */ 634 /* Remap the Octeon BAR 0 to 0-2GB */
@@ -637,6 +642,25 @@ static int __init octeon_pci_setup(void)
637 octeon_npi_write32(CVMX_NPI_PCI_CFG06, 2ul << 30); 642 octeon_npi_write32(CVMX_NPI_PCI_CFG06, 2ul << 30);
638 octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0); 643 octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0);
639 644
645 /* BAR1 movable mappings set for identity mapping */
646 octeon_bar1_pci_phys = 0x80000000ull;
647 for (index = 0; index < 32; index++) {
648 union cvmx_pci_bar1_indexx bar1_index;
649
650 bar1_index.u32 = 0;
651 /* Address bits[35:22] sent to L2C */
652 bar1_index.s.addr_idx =
653 (octeon_bar1_pci_phys >> 22) + index;
654 /* Don't put PCI accesses in L2. */
655 bar1_index.s.ca = 1;
656 /* Endian Swap Mode */
657 bar1_index.s.end_swp = 1;
658 /* Set '1' when the selected address range is valid. */
659 bar1_index.s.addr_v = 1;
660 octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index),
661 bar1_index.u32);
662 }
663
640 /* Devices go after BAR1 */ 664 /* Devices go after BAR1 */
641 octeon_pci_mem_resource.start = 665 octeon_pci_mem_resource.start =
642 OCTEON_PCI_MEMSPACE_OFFSET + (4ul << 30) - 666 OCTEON_PCI_MEMSPACE_OFFSET + (4ul << 30) -
@@ -652,6 +676,27 @@ static int __init octeon_pci_setup(void)
652 octeon_npi_write32(CVMX_NPI_PCI_CFG06, 0); 676 octeon_npi_write32(CVMX_NPI_PCI_CFG06, 0);
653 octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0); 677 octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0);
654 678
679 /* BAR1 movable regions contiguous to cover the swiotlb */
680 octeon_bar1_pci_phys =
681 virt_to_phys(octeon_swiotlb) & ~((1ull << 22) - 1);
682
683 for (index = 0; index < 32; index++) {
684 union cvmx_pci_bar1_indexx bar1_index;
685
686 bar1_index.u32 = 0;
687 /* Address bits[35:22] sent to L2C */
688 bar1_index.s.addr_idx =
689 (octeon_bar1_pci_phys >> 22) + index;
690 /* Don't put PCI accesses in L2. */
691 bar1_index.s.ca = 1;
692 /* Endian Swap Mode */
693 bar1_index.s.end_swp = 1;
694 /* Set '1' when the selected address range is valid. */
695 bar1_index.s.addr_v = 1;
696 octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index),
697 bar1_index.u32);
698 }
699
655 /* Devices go after BAR0 */ 700 /* Devices go after BAR0 */
656 octeon_pci_mem_resource.start = 701 octeon_pci_mem_resource.start =
657 OCTEON_PCI_MEMSPACE_OFFSET + (128ul << 20) + 702 OCTEON_PCI_MEMSPACE_OFFSET + (128ul << 20) +
@@ -667,6 +712,9 @@ static int __init octeon_pci_setup(void)
667 * was setup properly. 712 * was setup properly.
668 */ 713 */
669 cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1); 714 cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1);
715
716 octeon_pci_dma_init();
717
670 return 0; 718 return 0;
671} 719}
672 720
diff --git a/arch/mips/pci/pcie-octeon.c b/arch/mips/pci/pcie-octeon.c
index 861361e0c9af..385f035b24e4 100644
--- a/arch/mips/pci/pcie-octeon.c
+++ b/arch/mips/pci/pcie-octeon.c
@@ -75,6 +75,8 @@ union cvmx_pcie_address {
75 } mem; 75 } mem;
76}; 76};
77 77
78#include <dma-coherence.h>
79
78/** 80/**
79 * Return the Core virtual base address for PCIe IO access. IOs are 81 * Return the Core virtual base address for PCIe IO access. IOs are
80 * read/written as an offset from this address. 82 * read/written as an offset from this address.
@@ -1391,6 +1393,9 @@ static int __init octeon_pcie_setup(void)
1391 cvmx_pcie_get_io_size(1) - 1; 1393 cvmx_pcie_get_io_size(1) - 1;
1392 register_pci_controller(&octeon_pcie1_controller); 1394 register_pci_controller(&octeon_pcie1_controller);
1393 } 1395 }
1396
1397 octeon_pci_dma_init();
1398
1394 return 0; 1399 return 0;
1395} 1400}
1396 1401
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/mn10300/Kconfig b/arch/mn10300/Kconfig
index 7c2a2f7f8dc1..41ba38513c89 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -1,16 +1,20 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux Kernel Configuration"
7
8config MN10300 1config MN10300
9 def_bool y 2 def_bool y
10 select HAVE_OPROFILE 3 select HAVE_OPROFILE
11 4
12config AM33 5config AM33_2
13 def_bool y 6 def_bool n
7
8config AM33_3
9 def_bool n
10
11config AM34_2
12 def_bool n
13 select MN10300_HAS_ATOMIC_OPS_UNIT
14 select MN10300_HAS_CACHE_SNOOP
15
16config ERRATUM_NEED_TO_RELOAD_MMUCTR
17 def_bool y if AM33_3 || AM34_2
14 18
15config MMU 19config MMU
16 def_bool y 20 def_bool y
@@ -37,7 +41,7 @@ config GENERIC_CALIBRATE_DELAY
37 def_bool y 41 def_bool y
38 42
39config GENERIC_CMOS_UPDATE 43config GENERIC_CMOS_UPDATE
40 def_bool y 44 def_bool n
41 45
42config GENERIC_FIND_NEXT_BIT 46config GENERIC_FIND_NEXT_BIT
43 def_bool y 47 def_bool y
@@ -45,6 +49,27 @@ config GENERIC_FIND_NEXT_BIT
45config GENERIC_HWEIGHT 49config GENERIC_HWEIGHT
46 def_bool y 50 def_bool y
47 51
52config GENERIC_TIME
53 def_bool y
54
55config GENERIC_CLOCKEVENTS
56 def_bool y
57
58config GENERIC_CLOCKEVENTS_BUILD
59 def_bool y
60 depends on GENERIC_CLOCKEVENTS
61
62config GENERIC_CLOCKEVENTS_BROADCAST
63 bool
64
65config CEVT_MN10300
66 def_bool y
67 depends on GENERIC_CLOCKEVENTS
68
69config CSRC_MN10300
70 def_bool y
71 depends on GENERIC_TIME
72
48config GENERIC_BUG 73config GENERIC_BUG
49 def_bool y 74 def_bool y
50 75
@@ -61,18 +86,12 @@ config GENERIC_HARDIRQS
61config HOTPLUG_CPU 86config HOTPLUG_CPU
62 def_bool n 87 def_bool n
63 88
64config HZ
65 int
66 default 1000
67
68mainmenu "Matsushita MN10300/AM33 Kernel Configuration"
69
70source "init/Kconfig" 89source "init/Kconfig"
71 90
72source "kernel/Kconfig.freezer" 91source "kernel/Kconfig.freezer"
73 92
74 93
75menu "Matsushita MN10300 system setup" 94menu "Panasonic MN10300 system setup"
76 95
77choice 96choice
78 prompt "Unit type" 97 prompt "Unit type"
@@ -87,6 +106,10 @@ config MN10300_UNIT_ASB2303
87config MN10300_UNIT_ASB2305 106config MN10300_UNIT_ASB2305
88 bool "ASB2305" 107 bool "ASB2305"
89 108
109config MN10300_UNIT_ASB2364
110 bool "ASB2364"
111 select SMSC911X_ARCH_HOOKS if SMSC911X
112
90endchoice 113endchoice
91 114
92choice 115choice
@@ -99,57 +122,51 @@ choice
99config MN10300_PROC_MN103E010 122config MN10300_PROC_MN103E010
100 bool "MN103E010" 123 bool "MN103E010"
101 depends on MN10300_UNIT_ASB2303 || MN10300_UNIT_ASB2305 124 depends on MN10300_UNIT_ASB2303 || MN10300_UNIT_ASB2305
125 select AM33_2
126 select MN10300_PROC_HAS_TTYSM0
127 select MN10300_PROC_HAS_TTYSM1
128 select MN10300_PROC_HAS_TTYSM2
129
130config MN10300_PROC_MN2WS0050
131 bool "MN2WS0050"
132 depends on MN10300_UNIT_ASB2364
133 select AM34_2
102 select MN10300_PROC_HAS_TTYSM0 134 select MN10300_PROC_HAS_TTYSM0
103 select MN10300_PROC_HAS_TTYSM1 135 select MN10300_PROC_HAS_TTYSM1
104 select MN10300_PROC_HAS_TTYSM2 136 select MN10300_PROC_HAS_TTYSM2
105 137
106endchoice 138endchoice
107 139
108choice 140config MN10300_HAS_ATOMIC_OPS_UNIT
109 prompt "Processor core support" 141 def_bool n
110 default MN10300_CPU_AM33V2
111 help 142 help
112 This option specifies the processor core for which the kernel will be 143 This should be enabled if the processor has an atomic ops unit
113 compiled. It affects the instruction set used. 144 capable of doing LL/SC equivalent operations.
114
115config MN10300_CPU_AM33V2
116 bool "AM33v2"
117
118endchoice
119 145
120config FPU 146config FPU
121 bool "FPU present" 147 bool "FPU present"
122 default y 148 default y
123 depends on MN10300_PROC_MN103E010 149 depends on MN10300_PROC_MN103E010 || MN10300_PROC_MN2WS0050
124 150
125choice 151config LAZY_SAVE_FPU
126 prompt "CPU Caching mode" 152 bool "Save FPU state lazily"
127 default MN10300_CACHE_WBACK 153 default y
154 depends on FPU && !SMP
128 help 155 help
129 This option determines the caching mode for the kernel. 156 Enable this to be lazy in the saving of the FPU state to the owning
157 task's thread struct. This is useful if most tasks on the system
158 don't use the FPU as only those tasks that use it will pass it
159 between them, and the state needn't be saved for a task that isn't
160 using it.
130 161
131 Write-Back caching mode involves the all reads and writes causing 162 This can't be so easily used on SMP as the process that owns the FPU
132 the affected cacheline to be read into the cache first before being 163 state on a CPU may be currently running on another CPU, so for the
133 operated upon. Memory is not then updated by a write until the cache 164 moment, it is disabled.
134 is filled and a cacheline needs to be displaced from the cache to
135 make room. Only at that point is it written back.
136 165
137 Write-Through caching only fetches cachelines from memory on a 166source "arch/mn10300/mm/Kconfig.cache"
138 read. Writes always get written directly to memory. If the affected
139 cacheline is also in cache, it will be updated too.
140 167
141 The final option is to turn of caching entirely. 168config MN10300_TLB_USE_PIDR
142 169 def_bool y
143config MN10300_CACHE_WBACK
144 bool "Write-Back"
145
146config MN10300_CACHE_WTHRU
147 bool "Write-Through"
148
149config MN10300_CACHE_DISABLED
150 bool "Disabled"
151
152endchoice
153 170
154menu "Memory layout options" 171menu "Memory layout options"
155 172
@@ -170,24 +187,55 @@ config KERNEL_TEXT_ADDRESS
170 187
171config KERNEL_ZIMAGE_BASE_ADDRESS 188config KERNEL_ZIMAGE_BASE_ADDRESS
172 hex "Base address of compressed vmlinux image" 189 hex "Base address of compressed vmlinux image"
173 default "0x90700000" 190 default "0x50700000"
191
192config BOOT_STACK_OFFSET
193 hex
194 default "0xF00" if SMP
195 default "0xFF0" if !SMP
174 196
197config BOOT_STACK_SIZE
198 hex
199 depends on SMP
200 default "0x100"
175endmenu 201endmenu
176 202
177config PREEMPT 203config SMP
178 bool "Preemptible Kernel" 204 bool "Symmetric multi-processing support"
179 help 205 default y
180 This option reduces the latency of the kernel when reacting to 206 depends on MN10300_PROC_MN2WS0038 || MN10300_PROC_MN2WS0050
181 real-time or interactive events by allowing a low priority process to 207 ---help---
182 be preempted even if it is in kernel mode executing a system call. 208 This enables support for systems with more than one CPU. If you have
183 This allows applications to run more reliably even when the system is 209 a system with only one CPU, like most personal computers, say N. If
184 under load. 210 you have a system with more than one CPU, say Y.
185 211
186 Say Y here if you are building a kernel for a desktop, embedded 212 If you say N here, the kernel will run on single and multiprocessor
187 or real-time system. Say N if you are unsure. 213 machines, but will use only one CPU of a multiprocessor machine. If
214 you say Y here, the kernel will run on many, but not all,
215 singleprocessor machines. On a singleprocessor machine, the kernel
216 will run faster if you say N here.
217
218 See also <file:Documentation/i386/IO-APIC.txt>,
219 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
220 <http://www.tldp.org/docs.html#howto>.
221
222 If you don't know what to do here, say N.
223
224config NR_CPUS
225 int
226 depends on SMP
227 default "2"
228
229config USE_GENERIC_SMP_HELPERS
230 bool
231 depends on SMP
232 default y
233
234source "kernel/Kconfig.preempt"
188 235
189config MN10300_CURRENT_IN_E2 236config MN10300_CURRENT_IN_E2
190 bool "Hold current task address in E2 register" 237 bool "Hold current task address in E2 register"
238 depends on !SMP
191 default y 239 default y
192 help 240 help
193 This option removes the E2/R2 register from the set available to gcc 241 This option removes the E2/R2 register from the set available to gcc
@@ -209,12 +257,15 @@ config MN10300_USING_JTAG
209 suppresses the use of certain hardware debugging features, such as 257 suppresses the use of certain hardware debugging features, such as
210 single-stepping, which are taken over completely by the JTAG unit. 258 single-stepping, which are taken over completely by the JTAG unit.
211 259
260source "kernel/Kconfig.hz"
261source "kernel/time/Kconfig"
262
212config MN10300_RTC 263config MN10300_RTC
213 bool "Using MN10300 RTC" 264 bool "Using MN10300 RTC"
214 depends on MN10300_PROC_MN103E010 265 depends on MN10300_PROC_MN103E010 || MN10300_PROC_MN2WS0050
266 select GENERIC_CMOS_UPDATE
215 default n 267 default n
216 help 268 help
217
218 This option enables support for the RTC, thus enabling time to be 269 This option enables support for the RTC, thus enabling time to be
219 tracked, even when system is powered down. This is available on-chip 270 tracked, even when system is powered down. This is available on-chip
220 on the MN103E010. 271 on the MN103E010.
@@ -306,14 +357,23 @@ config MN10300_TTYSM1
306 357
307choice 358choice
308 prompt "Select the timer to supply the clock for SIF1" 359 prompt "Select the timer to supply the clock for SIF1"
309 default MN10300_TTYSM0_TIMER9 360 default MN10300_TTYSM1_TIMER12 \
361 if !(AM33_2 || AM33_3)
362 default MN10300_TTYSM1_TIMER9 \
363 if AM33_2 || AM33_3
310 depends on MN10300_TTYSM1 364 depends on MN10300_TTYSM1
311 365
366config MN10300_TTYSM1_TIMER12
367 bool "Use timer 12 (16-bit)"
368 depends on !(AM33_2 || AM33_3)
369
312config MN10300_TTYSM1_TIMER9 370config MN10300_TTYSM1_TIMER9
313 bool "Use timer 9 (16-bit)" 371 bool "Use timer 9 (16-bit)"
372 depends on AM33_2 || AM33_3
314 373
315config MN10300_TTYSM1_TIMER3 374config MN10300_TTYSM1_TIMER3
316 bool "Use timer 3 (8-bit)" 375 bool "Use timer 3 (8-bit)"
376 depends on AM33_2 || AM33_3
317 377
318endchoice 378endchoice
319 379
@@ -328,17 +388,107 @@ config MN10300_TTYSM2
328 388
329choice 389choice
330 prompt "Select the timer to supply the clock for SIF2" 390 prompt "Select the timer to supply the clock for SIF2"
331 default MN10300_TTYSM0_TIMER10 391 default MN10300_TTYSM2_TIMER3 \
392 if !(AM33_2 || AM33_3)
393 default MN10300_TTYSM2_TIMER10 \
394 if AM33_2 || AM33_3
332 depends on MN10300_TTYSM2 395 depends on MN10300_TTYSM2
333 396
397config MN10300_TTYSM2_TIMER9
398 bool "Use timer 9 (16-bit)"
399 depends on !(AM33_2 || AM33_3)
400
401config MN10300_TTYSM2_TIMER1
402 bool "Use timer 1 (8-bit)"
403 depends on !(AM33_2 || AM33_3)
404
405config MN10300_TTYSM2_TIMER3
406 bool "Use timer 3 (8-bit)"
407 depends on !(AM33_2 || AM33_3)
408
334config MN10300_TTYSM2_TIMER10 409config MN10300_TTYSM2_TIMER10
335 bool "Use timer 10 (16-bit)" 410 bool "Use timer 10 (16-bit)"
411 depends on AM33_2 || AM33_3
336 412
337endchoice 413endchoice
338 414
339config MN10300_TTYSM2_CTS 415config MN10300_TTYSM2_CTS
340 bool "Enable the use of the CTS line /dev/ttySM2" 416 bool "Enable the use of the CTS line /dev/ttySM2"
341 depends on MN10300_TTYSM2 417 depends on MN10300_TTYSM2 && AM33_2
418
419endmenu
420
421menu "Interrupt request priority options"
422
423comment "[!] NOTE: A lower number/level indicates a higher priority (0 is highest, 6 is lowest)"
424
425comment "____Non-maskable interrupt levels____"
426comment "The following must be set to a higher priority than local_irq_disable() and on-chip serial"
427
428config GDBSTUB_IRQ_LEVEL
429 int "GDBSTUB interrupt priority"
430 depends on GDBSTUB
431 range 0 1 if LINUX_CLI_LEVEL = 2
432 range 0 2 if LINUX_CLI_LEVEL = 3
433 range 0 3 if LINUX_CLI_LEVEL = 4
434 range 0 4 if LINUX_CLI_LEVEL = 5
435 range 0 5 if LINUX_CLI_LEVEL = 6
436 default 0
437
438comment "The following must be set to a higher priority than local_irq_disable()"
439
440config MN10300_SERIAL_IRQ_LEVEL
441 int "MN10300 on-chip serial interrupt priority"
442 depends on MN10300_TTYSM
443 range 1 1 if LINUX_CLI_LEVEL = 2
444 range 1 2 if LINUX_CLI_LEVEL = 3
445 range 1 3 if LINUX_CLI_LEVEL = 4
446 range 1 4 if LINUX_CLI_LEVEL = 5
447 range 1 5 if LINUX_CLI_LEVEL = 6
448 default 1
449
450comment "-"
451comment "____Maskable interrupt levels____"
452
453config LINUX_CLI_LEVEL
454 int "The highest interrupt priority excluded by local_irq_disable() (2-6)"
455 range 2 6
456 default 2
457 help
458 local_irq_disable() doesn't actually disable maskable interrupts -
459 what it does is restrict the levels of interrupt which are permitted
460 (a lower level indicates a higher priority) by lowering the value in
461 EPSW.IM from 7. Any interrupt is permitted for which the level is
462 lower than EPSW.IM.
463
464 Certain interrupts, such as GDBSTUB and virtual MN10300 on-chip
465 serial DMA interrupts are allowed to interrupt normal disabled
466 sections.
467
468comment "The following must be set to a equal to or lower priority than LINUX_CLI_LEVEL"
469
470config TIMER_IRQ_LEVEL
471 int "Kernel timer interrupt priority"
472 range LINUX_CLI_LEVEL 6
473 default 4
474
475config PCI_IRQ_LEVEL
476 int "PCI interrupt priority"
477 depends on PCI
478 range LINUX_CLI_LEVEL 6
479 default 5
480
481config ETHERNET_IRQ_LEVEL
482 int "Ethernet interrupt priority"
483 depends on SMC91X || SMC911X || SMSC911X
484 range LINUX_CLI_LEVEL 6
485 default 6
486
487config EXT_SERIAL_IRQ_LEVEL
488 int "External serial port interrupt priority"
489 depends on SERIAL_8250
490 range LINUX_CLI_LEVEL 6
491 default 6
342 492
343endmenu 493endmenu
344 494
diff --git a/arch/mn10300/Makefile b/arch/mn10300/Makefile
index ac5c6bdb2f05..7120282bf0d8 100644
--- a/arch/mn10300/Makefile
+++ b/arch/mn10300/Makefile
@@ -36,6 +36,9 @@ endif
36ifeq ($(CONFIG_MN10300_PROC_MN103E010),y) 36ifeq ($(CONFIG_MN10300_PROC_MN103E010),y)
37PROCESSOR := mn103e010 37PROCESSOR := mn103e010
38endif 38endif
39ifeq ($(CONFIG_MN10300_PROC_MN2WS0050),y)
40PROCESSOR := mn2ws0050
41endif
39 42
40ifeq ($(CONFIG_MN10300_UNIT_ASB2303),y) 43ifeq ($(CONFIG_MN10300_UNIT_ASB2303),y)
41UNIT := asb2303 44UNIT := asb2303
@@ -43,6 +46,9 @@ endif
43ifeq ($(CONFIG_MN10300_UNIT_ASB2305),y) 46ifeq ($(CONFIG_MN10300_UNIT_ASB2305),y)
44UNIT := asb2305 47UNIT := asb2305
45endif 48endif
49ifeq ($(CONFIG_MN10300_UNIT_ASB2364),y)
50UNIT := asb2364
51endif
46 52
47 53
48head-y := arch/mn10300/kernel/head.o arch/mn10300/kernel/init_task.o 54head-y := arch/mn10300/kernel/head.o arch/mn10300/kernel/init_task.o
diff --git a/arch/mn10300/boot/compressed/head.S b/arch/mn10300/boot/compressed/head.S
index 502e1eb56709..7b50345b9e84 100644
--- a/arch/mn10300/boot/compressed/head.S
+++ b/arch/mn10300/boot/compressed/head.S
@@ -14,10 +14,29 @@
14 14
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <asm/cpu-regs.h> 16#include <asm/cpu-regs.h>
17#include <asm/cache.h>
18#ifdef CONFIG_SMP
19#include <proc/smp-regs.h>
20#endif
17 21
18 .globl startup_32 22 .globl startup_32
19startup_32: 23startup_32:
20 # first save off parameters from bootloader 24#ifdef CONFIG_SMP
25 #
26 # Secondary CPUs jump directly to the kernel entry point
27 #
28 # Must save primary CPU's D0-D2 registers as they hold boot parameters
29 #
30 mov (CPUID), d3
31 and CPUID_MASK,d3
32 beq startup_primary
33 mov CONFIG_KERNEL_TEXT_ADDRESS,a0
34 jmp (a0)
35
36startup_primary:
37#endif /* CONFIG_SMP */
38
39 # first save parameters from bootloader
21 mov param_save_area,a0 40 mov param_save_area,a0
22 mov d0,(a0) 41 mov d0,(a0)
23 mov d1,(4,a0) 42 mov d1,(4,a0)
@@ -37,8 +56,15 @@ startup_32:
37 mov (a0),d0 56 mov (a0),d0
38 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy 57 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
39 lne 58 lne
40 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD,d0 # writethru dcache 59
60#ifdef CONFIG_MN10300_CACHE_ENABLED
61#ifdef CONFIG_MN10300_CACHE_WBACK
62 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
63#else
64 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
65#endif /* WBACK */
41 movhu d0,(a0) # enable 66 movhu d0,(a0) # enable
67#endif /* !ENABLED */
42 68
43 # clear the BSS area 69 # clear the BSS area
44 mov __bss_start,a0 70 mov __bss_start,a0
@@ -54,6 +80,9 @@ bssclear_end:
54 80
55 # decompress the kernel 81 # decompress the kernel
56 call decompress_kernel[],0 82 call decompress_kernel[],0
83#ifdef CONFIG_MN10300_CACHE_WBACK
84 call mn10300_dcache_flush_inv[],0
85#endif
57 86
58 # disable caches again 87 # disable caches again
59 mov CHCTR,a0 88 mov CHCTR,a0
@@ -69,10 +98,46 @@ bssclear_end:
69 mov (4,a0),d1 98 mov (4,a0),d1
70 mov (8,a0),d2 99 mov (8,a0),d2
71 100
101 # jump to the kernel proper entry point
72 mov a3,sp 102 mov a3,sp
73 mov CONFIG_KERNEL_TEXT_ADDRESS,a0 103 mov CONFIG_KERNEL_TEXT_ADDRESS,a0
74 jmp (a0) 104 jmp (a0)
75 105
106
107###############################################################################
108#
109# Cache flush routines
110#
111###############################################################################
112#ifdef CONFIG_MN10300_CACHE_WBACK
113mn10300_dcache_flush_inv:
114 movhu (CHCTR),d0
115 btst CHCTR_DCEN,d0
116 beq mn10300_dcache_flush_inv_end
117
118 mov L1_CACHE_NENTRIES,d1
119 clr a1
120
121mn10300_dcache_flush_inv_loop:
122 mov (DCACHE_PURGE_WAY0(0),a1),d0 # unconditional purge
123 mov (DCACHE_PURGE_WAY1(0),a1),d0 # unconditional purge
124 mov (DCACHE_PURGE_WAY2(0),a1),d0 # unconditional purge
125 mov (DCACHE_PURGE_WAY3(0),a1),d0 # unconditional purge
126
127 add L1_CACHE_BYTES,a1
128 add -1,d1
129 bne mn10300_dcache_flush_inv_loop
130
131mn10300_dcache_flush_inv_end:
132 ret [],0
133#endif /* CONFIG_MN10300_CACHE_WBACK */
134
135
136###############################################################################
137#
138# Data areas
139#
140###############################################################################
76 .data 141 .data
77 .align 4 142 .align 4
78param_save_area: 143param_save_area:
diff --git a/arch/mn10300/configs/asb2303_defconfig b/arch/mn10300/configs/asb2303_defconfig
index d80dfcb2c902..3f749b69ca71 100644
--- a/arch/mn10300/configs/asb2303_defconfig
+++ b/arch/mn10300/configs/asb2303_defconfig
@@ -12,6 +12,8 @@ CONFIG_SLAB=y
12CONFIG_PROFILING=y 12CONFIG_PROFILING=y
13# CONFIG_BLOCK is not set 13# CONFIG_BLOCK is not set
14CONFIG_PREEMPT=y 14CONFIG_PREEMPT=y
15CONFIG_NO_HZ=y
16CONFIG_HIGH_RES_TIMERS=y
15CONFIG_MN10300_RTC=y 17CONFIG_MN10300_RTC=y
16CONFIG_MN10300_TTYSM_CONSOLE=y 18CONFIG_MN10300_TTYSM_CONSOLE=y
17CONFIG_MN10300_TTYSM0=y 19CONFIG_MN10300_TTYSM0=y
diff --git a/arch/mn10300/configs/asb2364_defconfig b/arch/mn10300/configs/asb2364_defconfig
new file mode 100644
index 000000000000..83ce2f27b12a
--- /dev/null
+++ b/arch/mn10300/configs/asb2364_defconfig
@@ -0,0 +1,98 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y
4CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_TASKSTATS=y
6CONFIG_TASK_DELAY_ACCT=y
7CONFIG_TASK_XACCT=y
8CONFIG_TASK_IO_ACCOUNTING=y
9CONFIG_LOG_BUF_SHIFT=14
10CONFIG_CGROUPS=y
11CONFIG_CGROUP_NS=y
12CONFIG_CGROUP_FREEZER=y
13CONFIG_CGROUP_DEVICE=y
14CONFIG_CGROUP_CPUACCT=y
15CONFIG_RESOURCE_COUNTERS=y
16CONFIG_RELAY=y
17# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
18CONFIG_EMBEDDED=y
19# CONFIG_KALLSYMS is not set
20# CONFIG_VM_EVENT_COUNTERS is not set
21CONFIG_SLAB=y
22CONFIG_PROFILING=y
23CONFIG_MODULES=y
24CONFIG_MODULE_UNLOAD=y
25# CONFIG_BLOCK is not set
26CONFIG_MN10300_UNIT_ASB2364=y
27CONFIG_PREEMPT=y
28# CONFIG_MN10300_USING_JTAG is not set
29CONFIG_NO_HZ=y
30CONFIG_HIGH_RES_TIMERS=y
31CONFIG_MN10300_TTYSM_CONSOLE=y
32CONFIG_MN10300_TTYSM0=y
33CONFIG_MN10300_TTYSM0_TIMER2=y
34CONFIG_MN10300_TTYSM1=y
35CONFIG_NET=y
36CONFIG_PACKET=y
37CONFIG_UNIX=y
38CONFIG_INET=y
39CONFIG_IP_MULTICAST=y
40CONFIG_IP_PNP=y
41CONFIG_IP_PNP_BOOTP=y
42# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
43# CONFIG_INET_XFRM_MODE_TUNNEL is not set
44# CONFIG_INET_XFRM_MODE_BEET is not set
45# CONFIG_INET_LRO is not set
46# CONFIG_INET_DIAG is not set
47CONFIG_IPV6=y
48# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
49# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
50# CONFIG_INET6_XFRM_MODE_BEET is not set
51# CONFIG_FIRMWARE_IN_KERNEL is not set
52CONFIG_CONNECTOR=y
53CONFIG_MTD=y
54CONFIG_MTD_DEBUG=y
55CONFIG_MTD_PARTITIONS=y
56CONFIG_MTD_REDBOOT_PARTS=y
57CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
58CONFIG_MTD_CHAR=y
59CONFIG_MTD_CFI=y
60CONFIG_MTD_JEDECPROBE=y
61CONFIG_MTD_CFI_ADV_OPTIONS=y
62CONFIG_MTD_CFI_GEOMETRY=y
63CONFIG_MTD_CFI_I4=y
64CONFIG_MTD_CFI_AMDSTD=y
65CONFIG_MTD_PHYSMAP=y
66CONFIG_NETDEVICES=y
67CONFIG_NET_ETHERNET=y
68CONFIG_SMSC911X=y
69# CONFIG_NETDEV_1000 is not set
70# CONFIG_NETDEV_10000 is not set
71# CONFIG_INPUT_MOUSEDEV is not set
72# CONFIG_INPUT_KEYBOARD is not set
73# CONFIG_INPUT_MOUSE is not set
74# CONFIG_SERIO is not set
75# CONFIG_VT is not set
76CONFIG_SERIAL_8250=y
77CONFIG_SERIAL_8250_CONSOLE=y
78CONFIG_SERIAL_8250_EXTENDED=y
79CONFIG_SERIAL_8250_SHARE_IRQ=y
80# CONFIG_HW_RANDOM is not set
81# CONFIG_HWMON is not set
82# CONFIG_HID_SUPPORT is not set
83# CONFIG_USB_SUPPORT is not set
84CONFIG_PROC_KCORE=y
85# CONFIG_PROC_PAGE_MONITOR is not set
86CONFIG_TMPFS=y
87CONFIG_TMPFS_POSIX_ACL=y
88CONFIG_JFFS2_FS=y
89CONFIG_NFS_FS=y
90CONFIG_NFS_V3=y
91CONFIG_ROOT_NFS=y
92CONFIG_MAGIC_SYSRQ=y
93CONFIG_STRIP_ASM_SYMS=y
94CONFIG_DEBUG_KERNEL=y
95CONFIG_DETECT_HUNG_TASK=y
96# CONFIG_DEBUG_BUGVERBOSE is not set
97CONFIG_DEBUG_INFO=y
98# CONFIG_RCU_CPU_STALL_DETECTOR is not set
diff --git a/arch/mn10300/include/asm/atomic.h b/arch/mn10300/include/asm/atomic.h
index f0cc1f84a72f..92d2f9298e38 100644
--- a/arch/mn10300/include/asm/atomic.h
+++ b/arch/mn10300/include/asm/atomic.h
@@ -1 +1,351 @@
1/* MN10300 Atomic counter operations
2 *
3 * Copyright (C) 2007 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#ifndef _ASM_ATOMIC_H
12#define _ASM_ATOMIC_H
13
14#include <asm/irqflags.h>
15
16#ifndef __ASSEMBLY__
17
18#ifdef CONFIG_SMP
19#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
20static inline
21unsigned long __xchg(volatile unsigned long *m, unsigned long val)
22{
23 unsigned long status;
24 unsigned long oldval;
25
26 asm volatile(
27 "1: mov %4,(_AAR,%3) \n"
28 " mov (_ADR,%3),%1 \n"
29 " mov %5,(_ADR,%3) \n"
30 " mov (_ADR,%3),%0 \n" /* flush */
31 " mov (_ASR,%3),%0 \n"
32 " or %0,%0 \n"
33 " bne 1b \n"
34 : "=&r"(status), "=&r"(oldval), "=m"(*m)
35 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(m), "r"(val)
36 : "memory", "cc");
37
38 return oldval;
39}
40
41static inline unsigned long __cmpxchg(volatile unsigned long *m,
42 unsigned long old, unsigned long new)
43{
44 unsigned long status;
45 unsigned long oldval;
46
47 asm volatile(
48 "1: mov %4,(_AAR,%3) \n"
49 " mov (_ADR,%3),%1 \n"
50 " cmp %5,%1 \n"
51 " bne 2f \n"
52 " mov %6,(_ADR,%3) \n"
53 "2: mov (_ADR,%3),%0 \n" /* flush */
54 " mov (_ASR,%3),%0 \n"
55 " or %0,%0 \n"
56 " bne 1b \n"
57 : "=&r"(status), "=&r"(oldval), "=m"(*m)
58 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(m),
59 "r"(old), "r"(new)
60 : "memory", "cc");
61
62 return oldval;
63}
64#else /* CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT */
65#error "No SMP atomic operation support!"
66#endif /* CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT */
67
68#else /* CONFIG_SMP */
69
70/*
71 * Emulate xchg for non-SMP MN10300
72 */
73struct __xchg_dummy { unsigned long a[100]; };
74#define __xg(x) ((struct __xchg_dummy *)(x))
75
76static inline
77unsigned long __xchg(volatile unsigned long *m, unsigned long val)
78{
79 unsigned long oldval;
80 unsigned long flags;
81
82 flags = arch_local_cli_save();
83 oldval = *m;
84 *m = val;
85 arch_local_irq_restore(flags);
86 return oldval;
87}
88
89/*
90 * Emulate cmpxchg for non-SMP MN10300
91 */
92static inline unsigned long __cmpxchg(volatile unsigned long *m,
93 unsigned long old, unsigned long new)
94{
95 unsigned long oldval;
96 unsigned long flags;
97
98 flags = arch_local_cli_save();
99 oldval = *m;
100 if (oldval == old)
101 *m = new;
102 arch_local_irq_restore(flags);
103 return oldval;
104}
105
106#endif /* CONFIG_SMP */
107
108#define xchg(ptr, v) \
109 ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr), \
110 (unsigned long)(v)))
111
112#define cmpxchg(ptr, o, n) \
113 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
114 (unsigned long)(o), \
115 (unsigned long)(n)))
116
117#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
118#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
119
120#endif /* !__ASSEMBLY__ */
121
122#ifndef CONFIG_SMP
1#include <asm-generic/atomic.h> 123#include <asm-generic/atomic.h>
124#else
125
126/*
127 * Atomic operations that C can't guarantee us. Useful for
128 * resource counting etc..
129 */
130
131#define ATOMIC_INIT(i) { (i) }
132
133#ifdef __KERNEL__
134
135/**
136 * atomic_read - read atomic variable
137 * @v: pointer of type atomic_t
138 *
139 * Atomically reads the value of @v. Note that the guaranteed
140 * useful range of an atomic_t is only 24 bits.
141 */
142#define atomic_read(v) ((v)->counter)
143
144/**
145 * atomic_set - set atomic variable
146 * @v: pointer of type atomic_t
147 * @i: required value
148 *
149 * Atomically sets the value of @v to @i. Note that the guaranteed
150 * useful range of an atomic_t is only 24 bits.
151 */
152#define atomic_set(v, i) (((v)->counter) = (i))
153
154/**
155 * atomic_add_return - add integer to atomic variable
156 * @i: integer value to add
157 * @v: pointer of type atomic_t
158 *
159 * Atomically adds @i to @v and returns the result
160 * Note that the guaranteed useful range of an atomic_t is only 24 bits.
161 */
162static inline int atomic_add_return(int i, atomic_t *v)
163{
164 int retval;
165#ifdef CONFIG_SMP
166 int status;
167
168 asm volatile(
169 "1: mov %4,(_AAR,%3) \n"
170 " mov (_ADR,%3),%1 \n"
171 " add %5,%1 \n"
172 " mov %1,(_ADR,%3) \n"
173 " mov (_ADR,%3),%0 \n" /* flush */
174 " mov (_ASR,%3),%0 \n"
175 " or %0,%0 \n"
176 " bne 1b \n"
177 : "=&r"(status), "=&r"(retval), "=m"(v->counter)
178 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(&v->counter), "r"(i)
179 : "memory", "cc");
180
181#else
182 unsigned long flags;
183
184 flags = arch_local_cli_save();
185 retval = v->counter;
186 retval += i;
187 v->counter = retval;
188 arch_local_irq_restore(flags);
189#endif
190 return retval;
191}
192
193/**
194 * atomic_sub_return - subtract integer from atomic variable
195 * @i: integer value to subtract
196 * @v: pointer of type atomic_t
197 *
198 * Atomically subtracts @i from @v and returns the result
199 * Note that the guaranteed useful range of an atomic_t is only 24 bits.
200 */
201static inline int atomic_sub_return(int i, atomic_t *v)
202{
203 int retval;
204#ifdef CONFIG_SMP
205 int status;
206
207 asm volatile(
208 "1: mov %4,(_AAR,%3) \n"
209 " mov (_ADR,%3),%1 \n"
210 " sub %5,%1 \n"
211 " mov %1,(_ADR,%3) \n"
212 " mov (_ADR,%3),%0 \n" /* flush */
213 " mov (_ASR,%3),%0 \n"
214 " or %0,%0 \n"
215 " bne 1b \n"
216 : "=&r"(status), "=&r"(retval), "=m"(v->counter)
217 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(&v->counter), "r"(i)
218 : "memory", "cc");
219
220#else
221 unsigned long flags;
222 flags = arch_local_cli_save();
223 retval = v->counter;
224 retval -= i;
225 v->counter = retval;
226 arch_local_irq_restore(flags);
227#endif
228 return retval;
229}
230
231static inline int atomic_add_negative(int i, atomic_t *v)
232{
233 return atomic_add_return(i, v) < 0;
234}
235
236static inline void atomic_add(int i, atomic_t *v)
237{
238 atomic_add_return(i, v);
239}
240
241static inline void atomic_sub(int i, atomic_t *v)
242{
243 atomic_sub_return(i, v);
244}
245
246static inline void atomic_inc(atomic_t *v)
247{
248 atomic_add_return(1, v);
249}
250
251static inline void atomic_dec(atomic_t *v)
252{
253 atomic_sub_return(1, v);
254}
255
256#define atomic_dec_return(v) atomic_sub_return(1, (v))
257#define atomic_inc_return(v) atomic_add_return(1, (v))
258
259#define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
260#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
261#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
262
263#define atomic_add_unless(v, a, u) \
264({ \
265 int c, old; \
266 c = atomic_read(v); \
267 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
268 c = old; \
269 c != (u); \
270})
271
272#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
273
274/**
275 * atomic_clear_mask - Atomically clear bits in memory
276 * @mask: Mask of the bits to be cleared
277 * @v: pointer to word in memory
278 *
279 * Atomically clears the bits set in mask from the memory word specified.
280 */
281static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
282{
283#ifdef CONFIG_SMP
284 int status;
285
286 asm volatile(
287 "1: mov %3,(_AAR,%2) \n"
288 " mov (_ADR,%2),%0 \n"
289 " and %4,%0 \n"
290 " mov %0,(_ADR,%2) \n"
291 " mov (_ADR,%2),%0 \n" /* flush */
292 " mov (_ASR,%2),%0 \n"
293 " or %0,%0 \n"
294 " bne 1b \n"
295 : "=&r"(status), "=m"(*addr)
296 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(addr), "r"(~mask)
297 : "memory", "cc");
298#else
299 unsigned long flags;
300
301 mask = ~mask;
302 flags = arch_local_cli_save();
303 *addr &= mask;
304 arch_local_irq_restore(flags);
305#endif
306}
307
308/**
309 * atomic_set_mask - Atomically set bits in memory
310 * @mask: Mask of the bits to be set
311 * @v: pointer to word in memory
312 *
313 * Atomically sets the bits set in mask from the memory word specified.
314 */
315static inline void atomic_set_mask(unsigned long mask, unsigned long *addr)
316{
317#ifdef CONFIG_SMP
318 int status;
319
320 asm volatile(
321 "1: mov %3,(_AAR,%2) \n"
322 " mov (_ADR,%2),%0 \n"
323 " or %4,%0 \n"
324 " mov %0,(_ADR,%2) \n"
325 " mov (_ADR,%2),%0 \n" /* flush */
326 " mov (_ASR,%2),%0 \n"
327 " or %0,%0 \n"
328 " bne 1b \n"
329 : "=&r"(status), "=m"(*addr)
330 : "a"(ATOMIC_OPS_BASE_ADDR), "r"(addr), "r"(mask)
331 : "memory", "cc");
332#else
333 unsigned long flags;
334
335 flags = arch_local_cli_save();
336 *addr |= mask;
337 arch_local_irq_restore(flags);
338#endif
339}
340
341/* Atomic operations are already serializing on MN10300??? */
342#define smp_mb__before_atomic_dec() barrier()
343#define smp_mb__after_atomic_dec() barrier()
344#define smp_mb__before_atomic_inc() barrier()
345#define smp_mb__after_atomic_inc() barrier()
346
347#include <asm-generic/atomic-long.h>
348
349#endif /* __KERNEL__ */
350#endif /* CONFIG_SMP */
351#endif /* _ASM_ATOMIC_H */
diff --git a/arch/mn10300/include/asm/bitops.h b/arch/mn10300/include/asm/bitops.h
index 3f50e9661076..3b8a868188f5 100644
--- a/arch/mn10300/include/asm/bitops.h
+++ b/arch/mn10300/include/asm/bitops.h
@@ -57,7 +57,7 @@
57#define clear_bit(nr, addr) ___clear_bit((nr), (addr)) 57#define clear_bit(nr, addr) ___clear_bit((nr), (addr))
58 58
59 59
60static inline void __clear_bit(int nr, volatile void *addr) 60static inline void __clear_bit(unsigned long nr, volatile void *addr)
61{ 61{
62 unsigned int *a = (unsigned int *) addr; 62 unsigned int *a = (unsigned int *) addr;
63 int mask; 63 int mask;
@@ -70,15 +70,15 @@ static inline void __clear_bit(int nr, volatile void *addr)
70/* 70/*
71 * test bit 71 * test bit
72 */ 72 */
73static inline int test_bit(int nr, const volatile void *addr) 73static inline int test_bit(unsigned long nr, const volatile void *addr)
74{ 74{
75 return 1UL & (((const unsigned int *) addr)[nr >> 5] >> (nr & 31)); 75 return 1UL & (((const volatile unsigned int *) addr)[nr >> 5] >> (nr & 31));
76} 76}
77 77
78/* 78/*
79 * change bit 79 * change bit
80 */ 80 */
81static inline void __change_bit(int nr, volatile void *addr) 81static inline void __change_bit(unsigned long nr, volatile void *addr)
82{ 82{
83 int mask; 83 int mask;
84 unsigned int *a = (unsigned int *) addr; 84 unsigned int *a = (unsigned int *) addr;
@@ -88,7 +88,7 @@ static inline void __change_bit(int nr, volatile void *addr)
88 *a ^= mask; 88 *a ^= mask;
89} 89}
90 90
91extern void change_bit(int nr, volatile void *addr); 91extern void change_bit(unsigned long nr, volatile void *addr);
92 92
93/* 93/*
94 * test and set bit 94 * test and set bit
@@ -135,7 +135,7 @@ extern void change_bit(int nr, volatile void *addr);
135/* 135/*
136 * test and change bit 136 * test and change bit
137 */ 137 */
138static inline int __test_and_change_bit(int nr, volatile void *addr) 138static inline int __test_and_change_bit(unsigned long nr, volatile void *addr)
139{ 139{
140 int mask, retval; 140 int mask, retval;
141 unsigned int *a = (unsigned int *)addr; 141 unsigned int *a = (unsigned int *)addr;
@@ -148,7 +148,7 @@ static inline int __test_and_change_bit(int nr, volatile void *addr)
148 return retval; 148 return retval;
149} 149}
150 150
151extern int test_and_change_bit(int nr, volatile void *addr); 151extern int test_and_change_bit(unsigned long nr, volatile void *addr);
152 152
153#include <asm-generic/bitops/lock.h> 153#include <asm-generic/bitops/lock.h>
154 154
diff --git a/arch/mn10300/include/asm/cache.h b/arch/mn10300/include/asm/cache.h
index 781bf613366d..f29cde2cfc91 100644
--- a/arch/mn10300/include/asm/cache.h
+++ b/arch/mn10300/include/asm/cache.h
@@ -43,14 +43,18 @@
43 43
44/* instruction cache access registers */ 44/* instruction cache access registers */
45#define ICACHE_DATA(WAY, ENTRY, OFF) \ 45#define ICACHE_DATA(WAY, ENTRY, OFF) \
46 __SYSREG(0xc8000000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10 + (OFF) * 4, u32) 46 __SYSREG(0xc8000000 + (WAY) * L1_CACHE_WAYDISP + \
47 (ENTRY) * L1_CACHE_BYTES + (OFF) * 4, u32)
47#define ICACHE_TAG(WAY, ENTRY) \ 48#define ICACHE_TAG(WAY, ENTRY) \
48 __SYSREG(0xc8100000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10, u32) 49 __SYSREG(0xc8100000 + (WAY) * L1_CACHE_WAYDISP + \
50 (ENTRY) * L1_CACHE_BYTES, u32)
49 51
50/* instruction cache access registers */ 52/* data cache access registers */
51#define DCACHE_DATA(WAY, ENTRY, OFF) \ 53#define DCACHE_DATA(WAY, ENTRY, OFF) \
52 __SYSREG(0xc8200000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10 + (OFF) * 4, u32) 54 __SYSREG(0xc8200000 + (WAY) * L1_CACHE_WAYDISP + \
55 (ENTRY) * L1_CACHE_BYTES + (OFF) * 4, u32)
53#define DCACHE_TAG(WAY, ENTRY) \ 56#define DCACHE_TAG(WAY, ENTRY) \
54 __SYSREG(0xc8300000 + (WAY) * L1_CACHE_WAYDISP + (ENTRY) * 0x10, u32) 57 __SYSREG(0xc8300000 + (WAY) * L1_CACHE_WAYDISP + \
58 (ENTRY) * L1_CACHE_BYTES, u32)
55 59
56#endif /* _ASM_CACHE_H */ 60#endif /* _ASM_CACHE_H */
diff --git a/arch/mn10300/include/asm/cacheflush.h b/arch/mn10300/include/asm/cacheflush.h
index 29e692f7f030..faed90240ded 100644
--- a/arch/mn10300/include/asm/cacheflush.h
+++ b/arch/mn10300/include/asm/cacheflush.h
@@ -17,66 +17,55 @@
17#include <linux/mm.h> 17#include <linux/mm.h>
18 18
19/* 19/*
20 * virtually-indexed cache management (our cache is physically indexed) 20 * Primitive routines
21 */ 21 */
22#define flush_cache_all() do {} while (0) 22#ifdef CONFIG_MN10300_CACHE_ENABLED
23#define flush_cache_mm(mm) do {} while (0) 23extern void mn10300_local_icache_inv(void);
24#define flush_cache_dup_mm(mm) do {} while (0) 24extern void mn10300_local_icache_inv_page(unsigned long start);
25#define flush_cache_range(mm, start, end) do {} while (0) 25extern void mn10300_local_icache_inv_range(unsigned long start, unsigned long end);
26#define flush_cache_page(vma, vmaddr, pfn) do {} while (0) 26extern void mn10300_local_icache_inv_range2(unsigned long start, unsigned long size);
27#define flush_cache_vmap(start, end) do {} while (0) 27extern void mn10300_local_dcache_inv(void);
28#define flush_cache_vunmap(start, end) do {} while (0) 28extern void mn10300_local_dcache_inv_page(unsigned long start);
29#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 29extern void mn10300_local_dcache_inv_range(unsigned long start, unsigned long end);
30#define flush_dcache_page(page) do {} while (0) 30extern void mn10300_local_dcache_inv_range2(unsigned long start, unsigned long size);
31#define flush_dcache_mmap_lock(mapping) do {} while (0)
32#define flush_dcache_mmap_unlock(mapping) do {} while (0)
33
34/*
35 * physically-indexed cache management
36 */
37#ifndef CONFIG_MN10300_CACHE_DISABLED
38
39extern void flush_icache_range(unsigned long start, unsigned long end);
40extern void flush_icache_page(struct vm_area_struct *vma, struct page *pg);
41
42#else
43
44#define flush_icache_range(start, end) do {} while (0)
45#define flush_icache_page(vma, pg) do {} while (0)
46
47#endif
48
49#define flush_icache_user_range(vma, pg, adr, len) \
50 flush_icache_range(adr, adr + len)
51
52#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
53 do { \
54 memcpy(dst, src, len); \
55 flush_icache_page(vma, page); \
56 } while (0)
57
58#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
59 memcpy(dst, src, len)
60
61/*
62 * primitive routines
63 */
64#ifndef CONFIG_MN10300_CACHE_DISABLED
65extern void mn10300_icache_inv(void); 31extern void mn10300_icache_inv(void);
32extern void mn10300_icache_inv_page(unsigned long start);
33extern void mn10300_icache_inv_range(unsigned long start, unsigned long end);
34extern void mn10300_icache_inv_range2(unsigned long start, unsigned long size);
66extern void mn10300_dcache_inv(void); 35extern void mn10300_dcache_inv(void);
67extern void mn10300_dcache_inv_page(unsigned start); 36extern void mn10300_dcache_inv_page(unsigned long start);
68extern void mn10300_dcache_inv_range(unsigned start, unsigned end); 37extern void mn10300_dcache_inv_range(unsigned long start, unsigned long end);
69extern void mn10300_dcache_inv_range2(unsigned start, unsigned size); 38extern void mn10300_dcache_inv_range2(unsigned long start, unsigned long size);
70#ifdef CONFIG_MN10300_CACHE_WBACK 39#ifdef CONFIG_MN10300_CACHE_WBACK
40extern void mn10300_local_dcache_flush(void);
41extern void mn10300_local_dcache_flush_page(unsigned long start);
42extern void mn10300_local_dcache_flush_range(unsigned long start, unsigned long end);
43extern void mn10300_local_dcache_flush_range2(unsigned long start, unsigned long size);
44extern void mn10300_local_dcache_flush_inv(void);
45extern void mn10300_local_dcache_flush_inv_page(unsigned long start);
46extern void mn10300_local_dcache_flush_inv_range(unsigned long start, unsigned long end);
47extern void mn10300_local_dcache_flush_inv_range2(unsigned long start, unsigned long size);
71extern void mn10300_dcache_flush(void); 48extern void mn10300_dcache_flush(void);
72extern void mn10300_dcache_flush_page(unsigned start); 49extern void mn10300_dcache_flush_page(unsigned long start);
73extern void mn10300_dcache_flush_range(unsigned start, unsigned end); 50extern void mn10300_dcache_flush_range(unsigned long start, unsigned long end);
74extern void mn10300_dcache_flush_range2(unsigned start, unsigned size); 51extern void mn10300_dcache_flush_range2(unsigned long start, unsigned long size);
75extern void mn10300_dcache_flush_inv(void); 52extern void mn10300_dcache_flush_inv(void);
76extern void mn10300_dcache_flush_inv_page(unsigned start); 53extern void mn10300_dcache_flush_inv_page(unsigned long start);
77extern void mn10300_dcache_flush_inv_range(unsigned start, unsigned end); 54extern void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end);
78extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size); 55extern void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size);
79#else 56#else
57#define mn10300_local_dcache_flush() do {} while (0)
58#define mn10300_local_dcache_flush_page(start) do {} while (0)
59#define mn10300_local_dcache_flush_range(start, end) do {} while (0)
60#define mn10300_local_dcache_flush_range2(start, size) do {} while (0)
61#define mn10300_local_dcache_flush_inv() \
62 mn10300_local_dcache_inv()
63#define mn10300_local_dcache_flush_inv_page(start) \
64 mn10300_local_dcache_inv_page(start)
65#define mn10300_local_dcache_flush_inv_range(start, end) \
66 mn10300_local_dcache_inv_range(start, end)
67#define mn10300_local_dcache_flush_inv_range2(start, size) \
68 mn10300_local_dcache_inv_range2(start, size)
80#define mn10300_dcache_flush() do {} while (0) 69#define mn10300_dcache_flush() do {} while (0)
81#define mn10300_dcache_flush_page(start) do {} while (0) 70#define mn10300_dcache_flush_page(start) do {} while (0)
82#define mn10300_dcache_flush_range(start, end) do {} while (0) 71#define mn10300_dcache_flush_range(start, end) do {} while (0)
@@ -90,7 +79,26 @@ extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size);
90 mn10300_dcache_inv_range2((start), (size)) 79 mn10300_dcache_inv_range2((start), (size))
91#endif /* CONFIG_MN10300_CACHE_WBACK */ 80#endif /* CONFIG_MN10300_CACHE_WBACK */
92#else 81#else
82#define mn10300_local_icache_inv() do {} while (0)
83#define mn10300_local_icache_inv_page(start) do {} while (0)
84#define mn10300_local_icache_inv_range(start, end) do {} while (0)
85#define mn10300_local_icache_inv_range2(start, size) do {} while (0)
86#define mn10300_local_dcache_inv() do {} while (0)
87#define mn10300_local_dcache_inv_page(start) do {} while (0)
88#define mn10300_local_dcache_inv_range(start, end) do {} while (0)
89#define mn10300_local_dcache_inv_range2(start, size) do {} while (0)
90#define mn10300_local_dcache_flush() do {} while (0)
91#define mn10300_local_dcache_flush_inv_page(start) do {} while (0)
92#define mn10300_local_dcache_flush_inv() do {} while (0)
93#define mn10300_local_dcache_flush_inv_range(start, end)do {} while (0)
94#define mn10300_local_dcache_flush_inv_range2(start, size) do {} while (0)
95#define mn10300_local_dcache_flush_page(start) do {} while (0)
96#define mn10300_local_dcache_flush_range(start, end) do {} while (0)
97#define mn10300_local_dcache_flush_range2(start, size) do {} while (0)
93#define mn10300_icache_inv() do {} while (0) 98#define mn10300_icache_inv() do {} while (0)
99#define mn10300_icache_inv_page(start) do {} while (0)
100#define mn10300_icache_inv_range(start, end) do {} while (0)
101#define mn10300_icache_inv_range2(start, size) do {} while (0)
94#define mn10300_dcache_inv() do {} while (0) 102#define mn10300_dcache_inv() do {} while (0)
95#define mn10300_dcache_inv_page(start) do {} while (0) 103#define mn10300_dcache_inv_page(start) do {} while (0)
96#define mn10300_dcache_inv_range(start, end) do {} while (0) 104#define mn10300_dcache_inv_range(start, end) do {} while (0)
@@ -103,10 +111,56 @@ extern void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size);
103#define mn10300_dcache_flush_page(start) do {} while (0) 111#define mn10300_dcache_flush_page(start) do {} while (0)
104#define mn10300_dcache_flush_range(start, end) do {} while (0) 112#define mn10300_dcache_flush_range(start, end) do {} while (0)
105#define mn10300_dcache_flush_range2(start, size) do {} while (0) 113#define mn10300_dcache_flush_range2(start, size) do {} while (0)
106#endif /* CONFIG_MN10300_CACHE_DISABLED */ 114#endif /* CONFIG_MN10300_CACHE_ENABLED */
115
116/*
117 * Virtually-indexed cache management (our cache is physically indexed)
118 */
119#define flush_cache_all() do {} while (0)
120#define flush_cache_mm(mm) do {} while (0)
121#define flush_cache_dup_mm(mm) do {} while (0)
122#define flush_cache_range(mm, start, end) do {} while (0)
123#define flush_cache_page(vma, vmaddr, pfn) do {} while (0)
124#define flush_cache_vmap(start, end) do {} while (0)
125#define flush_cache_vunmap(start, end) do {} while (0)
126#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
127#define flush_dcache_page(page) do {} while (0)
128#define flush_dcache_mmap_lock(mapping) do {} while (0)
129#define flush_dcache_mmap_unlock(mapping) do {} while (0)
130
131/*
132 * Physically-indexed cache management
133 */
134#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE)
135extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
136extern void flush_icache_range(unsigned long start, unsigned long end);
137#elif defined(CONFIG_MN10300_CACHE_INV_ICACHE)
138static inline void flush_icache_page(struct vm_area_struct *vma,
139 struct page *page)
140{
141 mn10300_icache_inv_page(page_to_phys(page));
142}
143extern void flush_icache_range(unsigned long start, unsigned long end);
144#else
145#define flush_icache_range(start, end) do {} while (0)
146#define flush_icache_page(vma, pg) do {} while (0)
147#endif
148
149
150#define flush_icache_user_range(vma, pg, adr, len) \
151 flush_icache_range(adr, adr + len)
152
153#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
154 do { \
155 memcpy(dst, src, len); \
156 flush_icache_page(vma, page); \
157 } while (0)
158
159#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
160 memcpy(dst, src, len)
107 161
108/* 162/*
109 * internal debugging function 163 * Internal debugging function
110 */ 164 */
111#ifdef CONFIG_DEBUG_PAGEALLOC 165#ifdef CONFIG_DEBUG_PAGEALLOC
112extern void kernel_map_pages(struct page *page, int numpages, int enable); 166extern void kernel_map_pages(struct page *page, int numpages, int enable);
diff --git a/arch/mn10300/include/asm/cpu-regs.h b/arch/mn10300/include/asm/cpu-regs.h
index 757e9b5388ea..90ed4a365c97 100644
--- a/arch/mn10300/include/asm/cpu-regs.h
+++ b/arch/mn10300/include/asm/cpu-regs.h
@@ -15,7 +15,6 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#endif 16#endif
17 17
18#ifdef CONFIG_MN10300_CPU_AM33V2
19/* we tell the compiler to pretend to be AM33 so that it doesn't try and use 18/* we tell the compiler to pretend to be AM33 so that it doesn't try and use
20 * the FP regs, but tell the assembler that we're actually allowed AM33v2 19 * the FP regs, but tell the assembler that we're actually allowed AM33v2
21 * instructions */ 20 * instructions */
@@ -24,7 +23,6 @@ asm(" .am33_2\n");
24#else 23#else
25.am33_2 24.am33_2
26#endif 25#endif
27#endif
28 26
29#ifdef __KERNEL__ 27#ifdef __KERNEL__
30 28
@@ -58,6 +56,9 @@ asm(" .am33_2\n");
58#define EPSW_nAR 0x00040000 /* register bank control */ 56#define EPSW_nAR 0x00040000 /* register bank control */
59#define EPSW_ML 0x00080000 /* monitor level */ 57#define EPSW_ML 0x00080000 /* monitor level */
60#define EPSW_FE 0x00100000 /* FPU enable */ 58#define EPSW_FE 0x00100000 /* FPU enable */
59#define EPSW_IM_SHIFT 8 /* EPSW_IM_SHIFT determines the interrupt mode */
60
61#define NUM2EPSW_IM(num) ((num) << EPSW_IM_SHIFT)
61 62
62/* FPU registers */ 63/* FPU registers */
63#define FPCR_EF_I 0x00000001 /* inexact result FPU exception flag */ 64#define FPCR_EF_I 0x00000001 /* inexact result FPU exception flag */
@@ -99,9 +100,11 @@ asm(" .am33_2\n");
99#define CPUREV __SYSREGC(0xc0000050, u32) /* CPU revision register */ 100#define CPUREV __SYSREGC(0xc0000050, u32) /* CPU revision register */
100#define CPUREV_TYPE 0x0000000f /* CPU type */ 101#define CPUREV_TYPE 0x0000000f /* CPU type */
101#define CPUREV_TYPE_S 0 102#define CPUREV_TYPE_S 0
102#define CPUREV_TYPE_AM33V1 0x00000000 /* - AM33 V1 core, AM33/1.00 arch */ 103#define CPUREV_TYPE_AM33_1 0x00000000 /* - AM33-1 core, AM33/1.00 arch */
103#define CPUREV_TYPE_AM33V2 0x00000001 /* - AM33 V2 core, AM33/2.00 arch */ 104#define CPUREV_TYPE_AM33_2 0x00000001 /* - AM33-2 core, AM33/2.00 arch */
104#define CPUREV_TYPE_AM34V1 0x00000002 /* - AM34 V1 core, AM33/2.00 arch */ 105#define CPUREV_TYPE_AM34_1 0x00000002 /* - AM34-1 core, AM33/2.00 arch */
106#define CPUREV_TYPE_AM33_3 0x00000003 /* - AM33-3 core, AM33/2.00 arch */
107#define CPUREV_TYPE_AM34_2 0x00000004 /* - AM34-2 core, AM33/3.00 arch */
105#define CPUREV_REVISION 0x000000f0 /* CPU revision */ 108#define CPUREV_REVISION 0x000000f0 /* CPU revision */
106#define CPUREV_REVISION_S 4 109#define CPUREV_REVISION_S 4
107#define CPUREV_ICWAY 0x00000f00 /* number of instruction cache ways */ 110#define CPUREV_ICWAY 0x00000f00 /* number of instruction cache ways */
@@ -180,6 +183,21 @@ asm(" .am33_2\n");
180#define CHCTR_ICWMD 0x0f00 /* instruction cache way mode */ 183#define CHCTR_ICWMD 0x0f00 /* instruction cache way mode */
181#define CHCTR_DCWMD 0xf000 /* data cache way mode */ 184#define CHCTR_DCWMD 0xf000 /* data cache way mode */
182 185
186#ifdef CONFIG_AM34_2
187#define ICIVCR __SYSREG(0xc0000c00, u32) /* icache area invalidate control */
188#define ICIVCR_ICIVBSY 0x00000008 /* icache area invalidate busy */
189#define ICIVCR_ICI 0x00000001 /* icache area invalidate */
190
191#define ICIVMR __SYSREG(0xc0000c04, u32) /* icache area invalidate mask */
192
193#define DCPGCR __SYSREG(0xc0000c10, u32) /* data cache area purge control */
194#define DCPGCR_DCPGBSY 0x00000008 /* data cache area purge busy */
195#define DCPGCR_DCP 0x00000002 /* data cache area purge */
196#define DCPGCR_DCI 0x00000001 /* data cache area invalidate */
197
198#define DCPGMR __SYSREG(0xc0000c14, u32) /* data cache area purge mask */
199#endif /* CONFIG_AM34_2 */
200
183/* MMU control registers */ 201/* MMU control registers */
184#define MMUCTR __SYSREG(0xc0000090, u32) /* MMU control register */ 202#define MMUCTR __SYSREG(0xc0000090, u32) /* MMU control register */
185#define MMUCTR_IRP 0x0000003f /* instruction TLB replace pointer */ 203#define MMUCTR_IRP 0x0000003f /* instruction TLB replace pointer */
@@ -203,6 +221,9 @@ asm(" .am33_2\n");
203#define MMUCTR_DTL_LOCK0_3 0x03000000 /* - entry 0-3 locked */ 221#define MMUCTR_DTL_LOCK0_3 0x03000000 /* - entry 0-3 locked */
204#define MMUCTR_DTL_LOCK0_7 0x04000000 /* - entry 0-7 locked */ 222#define MMUCTR_DTL_LOCK0_7 0x04000000 /* - entry 0-7 locked */
205#define MMUCTR_DTL_LOCK0_15 0x05000000 /* - entry 0-15 locked */ 223#define MMUCTR_DTL_LOCK0_15 0x05000000 /* - entry 0-15 locked */
224#ifdef CONFIG_AM34_2
225#define MMUCTR_WTE 0x80000000 /* write-through cache TLB entry bit enable */
226#endif
206 227
207#define PIDR __SYSREG(0xc0000094, u16) /* PID register */ 228#define PIDR __SYSREG(0xc0000094, u16) /* PID register */
208#define PIDR_PID 0x00ff /* process identifier */ 229#define PIDR_PID 0x00ff /* process identifier */
@@ -231,14 +252,6 @@ asm(" .am33_2\n");
231#define xPTEL_PS_4Mb 0x00000c00 /* - 4Mb page */ 252#define xPTEL_PS_4Mb 0x00000c00 /* - 4Mb page */
232#define xPTEL_PPN 0xfffff006 /* physical page number */ 253#define xPTEL_PPN 0xfffff006 /* physical page number */
233 254
234#define xPTEL_V_BIT 0 /* bit numbers corresponding to above masks */
235#define xPTEL_UNUSED1_BIT 1
236#define xPTEL_UNUSED2_BIT 2
237#define xPTEL_C_BIT 3
238#define xPTEL_PV_BIT 4
239#define xPTEL_D_BIT 5
240#define xPTEL_G_BIT 9
241
242#define IPTEU __SYSREG(0xc00000a4, u32) /* instruction TLB virtual addr */ 255#define IPTEU __SYSREG(0xc00000a4, u32) /* instruction TLB virtual addr */
243#define DPTEU __SYSREG(0xc00000b4, u32) /* data TLB virtual addr */ 256#define DPTEU __SYSREG(0xc00000b4, u32) /* data TLB virtual addr */
244#define xPTEU_VPN 0xfffffc00 /* virtual page number */ 257#define xPTEU_VPN 0xfffffc00 /* virtual page number */
@@ -262,7 +275,16 @@ asm(" .am33_2\n");
262#define xPTEL2_PS_128Kb 0x00000100 /* - 128Kb page */ 275#define xPTEL2_PS_128Kb 0x00000100 /* - 128Kb page */
263#define xPTEL2_PS_1Kb 0x00000200 /* - 1Kb page */ 276#define xPTEL2_PS_1Kb 0x00000200 /* - 1Kb page */
264#define xPTEL2_PS_4Mb 0x00000300 /* - 4Mb page */ 277#define xPTEL2_PS_4Mb 0x00000300 /* - 4Mb page */
265#define xPTEL2_PPN 0xfffffc00 /* physical page number */ 278#define xPTEL2_CWT 0x00000400 /* cacheable write-through */
279#define xPTEL2_UNUSED1 0x00000800 /* unused bit (broadcast mask) */
280#define xPTEL2_PPN 0xfffff000 /* physical page number */
281
282#define xPTEL2_V_BIT 0 /* bit numbers corresponding to above masks */
283#define xPTEL2_C_BIT 1
284#define xPTEL2_PV_BIT 2
285#define xPTEL2_D_BIT 3
286#define xPTEL2_G_BIT 7
287#define xPTEL2_UNUSED1_BIT 11
266 288
267#define MMUFCR __SYSREGC(0xc000009c, u32) /* MMU exception cause */ 289#define MMUFCR __SYSREGC(0xc000009c, u32) /* MMU exception cause */
268#define MMUFCR_IFC __SYSREGC(0xc000009c, u16) /* MMU instruction excep cause */ 290#define MMUFCR_IFC __SYSREGC(0xc000009c, u16) /* MMU instruction excep cause */
@@ -285,6 +307,47 @@ asm(" .am33_2\n");
285#define MMUFCR_xFC_PR_RWK_RWU 0x01c0 /* - R/W kernel and R/W user */ 307#define MMUFCR_xFC_PR_RWK_RWU 0x01c0 /* - R/W kernel and R/W user */
286#define MMUFCR_xFC_ILLADDR 0x0200 /* illegal address excep flag */ 308#define MMUFCR_xFC_ILLADDR 0x0200 /* illegal address excep flag */
287 309
310#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
311/* atomic operation registers */
312#define AAR __SYSREG(0xc0000a00, u32) /* cacheable address */
313#define AAR2 __SYSREG(0xc0000a04, u32) /* uncacheable address */
314#define ADR __SYSREG(0xc0000a08, u32) /* data */
315#define ASR __SYSREG(0xc0000a0c, u32) /* status */
316#define AARU __SYSREG(0xd400aa00, u32) /* user address */
317#define ADRU __SYSREG(0xd400aa08, u32) /* user data */
318#define ASRU __SYSREG(0xd400aa0c, u32) /* user status */
319
320#define ASR_RW 0x00000008 /* read */
321#define ASR_BW 0x00000004 /* bus error */
322#define ASR_IW 0x00000002 /* interrupt */
323#define ASR_LW 0x00000001 /* bus lock */
324
325#define ASRU_RW ASR_RW /* read */
326#define ASRU_BW ASR_BW /* bus error */
327#define ASRU_IW ASR_IW /* interrupt */
328#define ASRU_LW ASR_LW /* bus lock */
329
330/* in inline ASM, we stick the base pointer in to a reg and use offsets from
331 * it */
332#define ATOMIC_OPS_BASE_ADDR 0xc0000a00
333#ifndef __ASSEMBLY__
334asm(
335 "_AAR = 0\n"
336 "_AAR2 = 4\n"
337 "_ADR = 8\n"
338 "_ASR = 12\n");
339#else
340#define _AAR 0
341#define _AAR2 4
342#define _ADR 8
343#define _ASR 12
344#endif
345
346/* physical page address for userspace atomic operations registers */
347#define USER_ATOMIC_OPS_PAGE_ADDR 0xd400a000
348
349#endif /* CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT */
350
288#endif /* __KERNEL__ */ 351#endif /* __KERNEL__ */
289 352
290#endif /* _ASM_CPU_REGS_H */ 353#endif /* _ASM_CPU_REGS_H */
diff --git a/arch/mn10300/include/asm/dmactl-regs.h b/arch/mn10300/include/asm/dmactl-regs.h
index 58a199da0f4a..80337b339c90 100644
--- a/arch/mn10300/include/asm/dmactl-regs.h
+++ b/arch/mn10300/include/asm/dmactl-regs.h
@@ -11,91 +11,6 @@
11#ifndef _ASM_DMACTL_REGS_H 11#ifndef _ASM_DMACTL_REGS_H
12#define _ASM_DMACTL_REGS_H 12#define _ASM_DMACTL_REGS_H
13 13
14#include <asm/cpu-regs.h> 14#include <proc/dmactl-regs.h>
15
16#ifdef __KERNEL__
17
18/* DMA registers */
19#define DMxCTR(N) __SYSREG(0xd2000000 + ((N) * 0x100), u32) /* control reg */
20#define DMxCTR_BG 0x0000001f /* transfer request source */
21#define DMxCTR_BG_SOFT 0x00000000 /* - software source */
22#define DMxCTR_BG_SC0TX 0x00000002 /* - serial port 0 transmission */
23#define DMxCTR_BG_SC0RX 0x00000003 /* - serial port 0 reception */
24#define DMxCTR_BG_SC1TX 0x00000004 /* - serial port 1 transmission */
25#define DMxCTR_BG_SC1RX 0x00000005 /* - serial port 1 reception */
26#define DMxCTR_BG_SC2TX 0x00000006 /* - serial port 2 transmission */
27#define DMxCTR_BG_SC2RX 0x00000007 /* - serial port 2 reception */
28#define DMxCTR_BG_TM0UFLOW 0x00000008 /* - timer 0 underflow */
29#define DMxCTR_BG_TM1UFLOW 0x00000009 /* - timer 1 underflow */
30#define DMxCTR_BG_TM2UFLOW 0x0000000a /* - timer 2 underflow */
31#define DMxCTR_BG_TM3UFLOW 0x0000000b /* - timer 3 underflow */
32#define DMxCTR_BG_TM6ACMPCAP 0x0000000c /* - timer 6A compare/capture */
33#define DMxCTR_BG_AFE 0x0000000d /* - analogue front-end interrupt source */
34#define DMxCTR_BG_ADC 0x0000000e /* - A/D conversion end interrupt source */
35#define DMxCTR_BG_IRDA 0x0000000f /* - IrDA interrupt source */
36#define DMxCTR_BG_RTC 0x00000010 /* - RTC interrupt source */
37#define DMxCTR_BG_XIRQ0 0x00000011 /* - XIRQ0 pin interrupt source */
38#define DMxCTR_BG_XIRQ1 0x00000012 /* - XIRQ1 pin interrupt source */
39#define DMxCTR_BG_XDMR0 0x00000013 /* - external request 0 source (XDMR0 pin) */
40#define DMxCTR_BG_XDMR1 0x00000014 /* - external request 1 source (XDMR1 pin) */
41#define DMxCTR_SAM 0x000000e0 /* DMA transfer src addr mode */
42#define DMxCTR_SAM_INCR 0x00000000 /* - increment */
43#define DMxCTR_SAM_DECR 0x00000020 /* - decrement */
44#define DMxCTR_SAM_FIXED 0x00000040 /* - fixed */
45#define DMxCTR_DAM 0x00000000 /* DMA transfer dest addr mode */
46#define DMxCTR_DAM_INCR 0x00000000 /* - increment */
47#define DMxCTR_DAM_DECR 0x00000100 /* - decrement */
48#define DMxCTR_DAM_FIXED 0x00000200 /* - fixed */
49#define DMxCTR_TM 0x00001800 /* DMA transfer mode */
50#define DMxCTR_TM_BATCH 0x00000000 /* - batch transfer */
51#define DMxCTR_TM_INTERM 0x00001000 /* - intermittent transfer */
52#define DMxCTR_UT 0x00006000 /* DMA transfer unit */
53#define DMxCTR_UT_1 0x00000000 /* - 1 byte */
54#define DMxCTR_UT_2 0x00002000 /* - 2 byte */
55#define DMxCTR_UT_4 0x00004000 /* - 4 byte */
56#define DMxCTR_UT_16 0x00006000 /* - 16 byte */
57#define DMxCTR_TEN 0x00010000 /* DMA channel transfer enable */
58#define DMxCTR_RQM 0x00060000 /* external request input source mode */
59#define DMxCTR_RQM_FALLEDGE 0x00000000 /* - falling edge */
60#define DMxCTR_RQM_RISEEDGE 0x00020000 /* - rising edge */
61#define DMxCTR_RQM_LOLEVEL 0x00040000 /* - low level */
62#define DMxCTR_RQM_HILEVEL 0x00060000 /* - high level */
63#define DMxCTR_RQF 0x01000000 /* DMA transfer request flag */
64#define DMxCTR_XEND 0x80000000 /* DMA transfer end flag */
65
66#define DMxSRC(N) __SYSREG(0xd2000004 + ((N) * 0x100), u32) /* control reg */
67
68#define DMxDST(N) __SYSREG(0xd2000008 + ((N) * 0x100), u32) /* src addr reg */
69
70#define DMxSIZ(N) __SYSREG(0xd200000c + ((N) * 0x100), u32) /* dest addr reg */
71#define DMxSIZ_CT 0x000fffff /* number of bytes to transfer */
72
73#define DMxCYC(N) __SYSREG(0xd2000010 + ((N) * 0x100), u32) /* intermittent
74 * size reg */
75#define DMxCYC_CYC 0x000000ff /* number of interrmittent transfers -1 */
76
77#define DM0IRQ 16 /* DMA channel 0 complete IRQ */
78#define DM1IRQ 17 /* DMA channel 1 complete IRQ */
79#define DM2IRQ 18 /* DMA channel 2 complete IRQ */
80#define DM3IRQ 19 /* DMA channel 3 complete IRQ */
81
82#define DM0ICR GxICR(DM0IRQ) /* DMA channel 0 complete intr ctrl reg */
83#define DM1ICR GxICR(DM0IR1) /* DMA channel 1 complete intr ctrl reg */
84#define DM2ICR GxICR(DM0IR2) /* DMA channel 2 complete intr ctrl reg */
85#define DM3ICR GxICR(DM0IR3) /* DMA channel 3 complete intr ctrl reg */
86
87#ifndef __ASSEMBLY__
88
89struct mn10300_dmactl_regs {
90 u32 ctr;
91 const void *src;
92 void *dst;
93 u32 siz;
94 u32 cyc;
95} __attribute__((aligned(0x100)));
96
97#endif /* __ASSEMBLY__ */
98
99#endif /* __KERNEL__ */
100 15
101#endif /* _ASM_DMACTL_REGS_H */ 16#endif /* _ASM_DMACTL_REGS_H */
diff --git a/arch/mn10300/include/asm/elf.h b/arch/mn10300/include/asm/elf.h
index e5fa97cd9a14..8157c9267f42 100644
--- a/arch/mn10300/include/asm/elf.h
+++ b/arch/mn10300/include/asm/elf.h
@@ -32,6 +32,12 @@
32#define R_MN10300_ALIGN 34 /* Alignment requirement. */ 32#define R_MN10300_ALIGN 34 /* Alignment requirement. */
33 33
34/* 34/*
35 * AM33/AM34 HW Capabilities
36 */
37#define HWCAP_MN10300_ATOMIC_OP_UNIT 1 /* Has AM34 Atomic Operations */
38
39
40/*
35 * ELF register definitions.. 41 * ELF register definitions..
36 */ 42 */
37typedef unsigned long elf_greg_t; 43typedef unsigned long elf_greg_t;
@@ -47,8 +53,6 @@ typedef struct {
47 u_int32_t fpcr; 53 u_int32_t fpcr;
48} elf_fpregset_t; 54} elf_fpregset_t;
49 55
50extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
51
52/* 56/*
53 * This is used to ensure we don't load something for the wrong architecture 57 * This is used to ensure we don't load something for the wrong architecture
54 */ 58 */
@@ -130,7 +134,11 @@ do { \
130 * instruction set this CPU supports. This could be done in user space, 134 * instruction set this CPU supports. This could be done in user space,
131 * but it's not easy, and we've already done it here. 135 * but it's not easy, and we've already done it here.
132 */ 136 */
137#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
138#define ELF_HWCAP (HWCAP_MN10300_ATOMIC_OP_UNIT)
139#else
133#define ELF_HWCAP (0) 140#define ELF_HWCAP (0)
141#endif
134 142
135/* 143/*
136 * This yields a string that ld.so will use to load implementation 144 * This yields a string that ld.so will use to load implementation
diff --git a/arch/mn10300/include/asm/exceptions.h b/arch/mn10300/include/asm/exceptions.h
index fa16466ef3f9..ca3e20508c77 100644
--- a/arch/mn10300/include/asm/exceptions.h
+++ b/arch/mn10300/include/asm/exceptions.h
@@ -15,8 +15,8 @@
15 15
16/* 16/*
17 * define the breakpoint instruction opcode to use 17 * define the breakpoint instruction opcode to use
18 * - note that the JTAG unit steals 0xFF, so we want to avoid that if we can 18 * - note that the JTAG unit steals 0xFF, so you can't use JTAG and GDBSTUB at
19 * (can use 0xF7) 19 * the same time.
20 */ 20 */
21#define GDBSTUB_BKPT 0xFF 21#define GDBSTUB_BKPT 0xFF
22 22
@@ -90,7 +90,6 @@ enum exception_code {
90 90
91extern void __set_intr_stub(enum exception_code code, void *handler); 91extern void __set_intr_stub(enum exception_code code, void *handler);
92extern void set_intr_stub(enum exception_code code, void *handler); 92extern void set_intr_stub(enum exception_code code, void *handler);
93extern void set_jtag_stub(enum exception_code code, void *handler);
94 93
95struct pt_regs; 94struct pt_regs;
96 95
@@ -102,7 +101,6 @@ extern asmlinkage void dtlb_aerror(void);
102extern asmlinkage void raw_bus_error(void); 101extern asmlinkage void raw_bus_error(void);
103extern asmlinkage void double_fault(void); 102extern asmlinkage void double_fault(void);
104extern asmlinkage int system_call(struct pt_regs *); 103extern asmlinkage int system_call(struct pt_regs *);
105extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code);
106extern asmlinkage void nmi(struct pt_regs *, enum exception_code); 104extern asmlinkage void nmi(struct pt_regs *, enum exception_code);
107extern asmlinkage void uninitialised_exception(struct pt_regs *, 105extern asmlinkage void uninitialised_exception(struct pt_regs *,
108 enum exception_code); 106 enum exception_code);
@@ -116,6 +114,8 @@ extern void die(const char *, struct pt_regs *, enum exception_code)
116 114
117extern int die_if_no_fixup(const char *, struct pt_regs *, enum exception_code); 115extern int die_if_no_fixup(const char *, struct pt_regs *, enum exception_code);
118 116
117#define NUM2EXCEP_IRQ_LEVEL(num) (EXCEP_IRQ_LEVEL0 + (num) * 8)
118
119#endif /* __ASSEMBLY__ */ 119#endif /* __ASSEMBLY__ */
120 120
121#endif /* _ASM_EXCEPTIONS_H */ 121#endif /* _ASM_EXCEPTIONS_H */
diff --git a/arch/mn10300/include/asm/fpu.h b/arch/mn10300/include/asm/fpu.h
index 64a2b83a7a6a..b7625de8eade 100644
--- a/arch/mn10300/include/asm/fpu.h
+++ b/arch/mn10300/include/asm/fpu.h
@@ -12,74 +12,125 @@
12#ifndef _ASM_FPU_H 12#ifndef _ASM_FPU_H
13#define _ASM_FPU_H 13#define _ASM_FPU_H
14 14
15#include <asm/processor.h> 15#ifndef __ASSEMBLY__
16
17#include <linux/sched.h>
18#include <asm/exceptions.h>
16#include <asm/sigcontext.h> 19#include <asm/sigcontext.h>
17#include <asm/user.h>
18 20
19#ifdef __KERNEL__ 21#ifdef __KERNEL__
20 22
21/* the task that owns the FPU state */ 23extern asmlinkage void fpu_disabled(void);
24
25#ifdef CONFIG_FPU
26
27#ifdef CONFIG_LAZY_SAVE_FPU
28/* the task that currently owns the FPU state */
22extern struct task_struct *fpu_state_owner; 29extern struct task_struct *fpu_state_owner;
30#endif
23 31
24#define set_using_fpu(tsk) \ 32#if (THREAD_USING_FPU & ~0xff)
25do { \ 33#error THREAD_USING_FPU must be smaller than 0x100.
26 (tsk)->thread.fpu_flags |= THREAD_USING_FPU; \ 34#endif
27} while (0)
28 35
29#define clear_using_fpu(tsk) \ 36static inline void set_using_fpu(struct task_struct *tsk)
30do { \ 37{
31 (tsk)->thread.fpu_flags &= ~THREAD_USING_FPU; \ 38 asm volatile(
32} while (0) 39 "bset %0,(0,%1)"
40 :
41 : "i"(THREAD_USING_FPU), "a"(&tsk->thread.fpu_flags)
42 : "memory", "cc");
43}
33 44
34#define is_using_fpu(tsk) ((tsk)->thread.fpu_flags & THREAD_USING_FPU) 45static inline void clear_using_fpu(struct task_struct *tsk)
46{
47 asm volatile(
48 "bclr %0,(0,%1)"
49 :
50 : "i"(THREAD_USING_FPU), "a"(&tsk->thread.fpu_flags)
51 : "memory", "cc");
52}
35 53
36#define unlazy_fpu(tsk) \ 54#define is_using_fpu(tsk) ((tsk)->thread.fpu_flags & THREAD_USING_FPU)
37do { \
38 preempt_disable(); \
39 if (fpu_state_owner == (tsk)) \
40 fpu_save(&tsk->thread.fpu_state); \
41 preempt_enable(); \
42} while (0)
43
44#define exit_fpu() \
45do { \
46 struct task_struct *__tsk = current; \
47 preempt_disable(); \
48 if (fpu_state_owner == __tsk) \
49 fpu_state_owner = NULL; \
50 preempt_enable(); \
51} while (0)
52
53#define flush_fpu() \
54do { \
55 struct task_struct *__tsk = current; \
56 preempt_disable(); \
57 if (fpu_state_owner == __tsk) { \
58 fpu_state_owner = NULL; \
59 __tsk->thread.uregs->epsw &= ~EPSW_FE; \
60 } \
61 preempt_enable(); \
62 clear_using_fpu(__tsk); \
63} while (0)
64 55
65extern asmlinkage void fpu_init_state(void);
66extern asmlinkage void fpu_kill_state(struct task_struct *); 56extern asmlinkage void fpu_kill_state(struct task_struct *);
67extern asmlinkage void fpu_disabled(struct pt_regs *, enum exception_code);
68extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code); 57extern asmlinkage void fpu_exception(struct pt_regs *, enum exception_code);
69 58extern asmlinkage void fpu_invalid_op(struct pt_regs *, enum exception_code);
70#ifdef CONFIG_FPU 59extern asmlinkage void fpu_init_state(void);
71extern asmlinkage void fpu_save(struct fpu_state_struct *); 60extern asmlinkage void fpu_save(struct fpu_state_struct *);
72extern asmlinkage void fpu_restore(struct fpu_state_struct *);
73#else
74#define fpu_save(a)
75#define fpu_restore(a)
76#endif /* CONFIG_FPU */
77
78/*
79 * signal frame handlers
80 */
81extern int fpu_setup_sigcontext(struct fpucontext *buf); 61extern int fpu_setup_sigcontext(struct fpucontext *buf);
82extern int fpu_restore_sigcontext(struct fpucontext *buf); 62extern int fpu_restore_sigcontext(struct fpucontext *buf);
83 63
64static inline void unlazy_fpu(struct task_struct *tsk)
65{
66 preempt_disable();
67#ifndef CONFIG_LAZY_SAVE_FPU
68 if (tsk->thread.fpu_flags & THREAD_HAS_FPU) {
69 fpu_save(&tsk->thread.fpu_state);
70 tsk->thread.fpu_flags &= ~THREAD_HAS_FPU;
71 tsk->thread.uregs->epsw &= ~EPSW_FE;
72 }
73#else
74 if (fpu_state_owner == tsk)
75 fpu_save(&tsk->thread.fpu_state);
76#endif
77 preempt_enable();
78}
79
80static inline void exit_fpu(void)
81{
82#ifdef CONFIG_LAZY_SAVE_FPU
83 struct task_struct *tsk = current;
84
85 preempt_disable();
86 if (fpu_state_owner == tsk)
87 fpu_state_owner = NULL;
88 preempt_enable();
89#endif
90}
91
92static inline void flush_fpu(void)
93{
94 struct task_struct *tsk = current;
95
96 preempt_disable();
97#ifndef CONFIG_LAZY_SAVE_FPU
98 if (tsk->thread.fpu_flags & THREAD_HAS_FPU) {
99 tsk->thread.fpu_flags &= ~THREAD_HAS_FPU;
100 tsk->thread.uregs->epsw &= ~EPSW_FE;
101 }
102#else
103 if (fpu_state_owner == tsk) {
104 fpu_state_owner = NULL;
105 tsk->thread.uregs->epsw &= ~EPSW_FE;
106 }
107#endif
108 preempt_enable();
109 clear_using_fpu(tsk);
110}
111
112#else /* CONFIG_FPU */
113
114extern asmlinkage
115void unexpected_fpu_exception(struct pt_regs *, enum exception_code);
116#define fpu_invalid_op unexpected_fpu_exception
117#define fpu_exception unexpected_fpu_exception
118
119struct task_struct;
120struct fpu_state_struct;
121static inline bool is_using_fpu(struct task_struct *tsk) { return false; }
122static inline void set_using_fpu(struct task_struct *tsk) {}
123static inline void clear_using_fpu(struct task_struct *tsk) {}
124static inline void fpu_init_state(void) {}
125static inline void fpu_save(struct fpu_state_struct *s) {}
126static inline void fpu_kill_state(struct task_struct *tsk) {}
127static inline void unlazy_fpu(struct task_struct *tsk) {}
128static inline void exit_fpu(void) {}
129static inline void flush_fpu(void) {}
130static inline int fpu_setup_sigcontext(struct fpucontext *buf) { return 0; }
131static inline int fpu_restore_sigcontext(struct fpucontext *buf) { return 0; }
132#endif /* CONFIG_FPU */
133
84#endif /* __KERNEL__ */ 134#endif /* __KERNEL__ */
135#endif /* !__ASSEMBLY__ */
85#endif /* _ASM_FPU_H */ 136#endif /* _ASM_FPU_H */
diff --git a/arch/mn10300/include/asm/frame.inc b/arch/mn10300/include/asm/frame.inc
index 5b1949bdf039..2ee58e3eb6b3 100644
--- a/arch/mn10300/include/asm/frame.inc
+++ b/arch/mn10300/include/asm/frame.inc
@@ -18,6 +18,7 @@
18#ifndef __ASM_OFFSETS_H__ 18#ifndef __ASM_OFFSETS_H__
19#include <asm/asm-offsets.h> 19#include <asm/asm-offsets.h>
20#endif 20#endif
21#include <asm/thread_info.h>
21 22
22#define pi break 23#define pi break
23 24
@@ -37,11 +38,15 @@
37 movm [d2,d3,a2,a3,exreg0,exreg1,exother],(sp) 38 movm [d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
38 mov sp,fp # FRAME pointer in A3 39 mov sp,fp # FRAME pointer in A3
39 add -12,sp # allow for calls to be made 40 add -12,sp # allow for calls to be made
40 mov (__frame),a1
41 mov a1,(REG_NEXT,fp)
42 mov fp,(__frame)
43 41
44 and ~EPSW_FE,epsw # disable the FPU inside the kernel 42 # push the exception frame onto the front of the list
43 GET_THREAD_INFO a1
44 mov (TI_frame,a1),a0
45 mov a0,(REG_NEXT,fp)
46 mov fp,(TI_frame,a1)
47
48 # disable the FPU inside the kernel
49 and ~EPSW_FE,epsw
45 50
46 # we may be holding current in E2 51 # we may be holding current in E2
47#ifdef CONFIG_MN10300_CURRENT_IN_E2 52#ifdef CONFIG_MN10300_CURRENT_IN_E2
@@ -57,10 +62,11 @@
57.macro RESTORE_ALL 62.macro RESTORE_ALL
58 # peel back the stack to the calling frame 63 # peel back the stack to the calling frame
59 # - this permits execve() to discard extra frames due to kernel syscalls 64 # - this permits execve() to discard extra frames due to kernel syscalls
60 mov (__frame),fp 65 GET_THREAD_INFO a0
66 mov (TI_frame,a0),fp
61 mov fp,sp 67 mov fp,sp
62 mov (REG_NEXT,fp),d0 # userspace has regs->next == 0 68 mov (REG_NEXT,fp),d0
63 mov d0,(__frame) 69 mov d0,(TI_frame,a0) # userspace has regs->next == 0
64 70
65#ifndef CONFIG_MN10300_USING_JTAG 71#ifndef CONFIG_MN10300_USING_JTAG
66 mov (REG_EPSW,fp),d0 72 mov (REG_EPSW,fp),d0
diff --git a/arch/mn10300/include/asm/gdb-stub.h b/arch/mn10300/include/asm/gdb-stub.h
index 41ed26763964..f5495ad82b77 100644
--- a/arch/mn10300/include/asm/gdb-stub.h
+++ b/arch/mn10300/include/asm/gdb-stub.h
@@ -110,7 +110,7 @@ extern asmlinkage void gdbstub_exception(struct pt_regs *, enum exception_code);
110extern asmlinkage void __gdbstub_bug_trap(void); 110extern asmlinkage void __gdbstub_bug_trap(void);
111extern asmlinkage void __gdbstub_pause(void); 111extern asmlinkage void __gdbstub_pause(void);
112 112
113#ifndef CONFIG_MN10300_CACHE_DISABLED 113#ifdef CONFIG_MN10300_CACHE_ENABLED
114extern asmlinkage void gdbstub_purge_cache(void); 114extern asmlinkage void gdbstub_purge_cache(void);
115#else 115#else
116#define gdbstub_purge_cache() do {} while (0) 116#define gdbstub_purge_cache() do {} while (0)
diff --git a/arch/mn10300/include/asm/hardirq.h b/arch/mn10300/include/asm/hardirq.h
index 54d950117674..0000d650b55f 100644
--- a/arch/mn10300/include/asm/hardirq.h
+++ b/arch/mn10300/include/asm/hardirq.h
@@ -19,9 +19,10 @@
19/* assembly code in softirq.h is sensitive to the offsets of these fields */ 19/* assembly code in softirq.h is sensitive to the offsets of these fields */
20typedef struct { 20typedef struct {
21 unsigned int __softirq_pending; 21 unsigned int __softirq_pending;
22 unsigned long idle_timestamp; 22#ifdef CONFIG_MN10300_WD_TIMER
23 unsigned int __nmi_count; /* arch dependent */ 23 unsigned int __nmi_count; /* arch dependent */
24 unsigned int __irq_count; /* arch dependent */ 24 unsigned int __irq_count; /* arch dependent */
25#endif
25} ____cacheline_aligned irq_cpustat_t; 26} ____cacheline_aligned irq_cpustat_t;
26 27
27#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 28#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
diff --git a/arch/mn10300/include/asm/highmem.h b/arch/mn10300/include/asm/highmem.h
index b0b187a29b88..bfe2d88604d9 100644
--- a/arch/mn10300/include/asm/highmem.h
+++ b/arch/mn10300/include/asm/highmem.h
@@ -70,15 +70,16 @@ static inline void kunmap(struct page *page)
70 * be used in IRQ contexts, so in some (very limited) cases we need 70 * be used in IRQ contexts, so in some (very limited) cases we need
71 * it. 71 * it.
72 */ 72 */
73static inline unsigned long kmap_atomic(struct page *page, enum km_type type) 73static inline unsigned long __kmap_atomic(struct page *page)
74{ 74{
75 enum fixed_addresses idx;
76 unsigned long vaddr; 75 unsigned long vaddr;
76 int idx, type;
77 77
78 pagefault_disable();
78 if (page < highmem_start_page) 79 if (page < highmem_start_page)
79 return page_address(page); 80 return page_address(page);
80 81
81 debug_kmap_atomic(type); 82 type = kmap_atomic_idx_push();
82 idx = type + KM_TYPE_NR * smp_processor_id(); 83 idx = type + KM_TYPE_NR * smp_processor_id();
83 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 84 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
84#if HIGHMEM_DEBUG 85#if HIGHMEM_DEBUG
@@ -86,31 +87,42 @@ static inline unsigned long kmap_atomic(struct page *page, enum km_type type)
86 BUG(); 87 BUG();
87#endif 88#endif
88 set_pte(kmap_pte - idx, mk_pte(page, kmap_prot)); 89 set_pte(kmap_pte - idx, mk_pte(page, kmap_prot));
89 __flush_tlb_one(vaddr); 90 local_flush_tlb_one(vaddr);
90 91
91 return vaddr; 92 return vaddr;
92} 93}
93 94
94static inline void kunmap_atomic_notypecheck(unsigned long vaddr, enum km_type type) 95static inline void __kunmap_atomic(unsigned long vaddr)
95{ 96{
96#if HIGHMEM_DEBUG 97 int type;
97 enum fixed_addresses idx = type + KM_TYPE_NR * smp_processor_id();
98 98
99 if (vaddr < FIXADDR_START) /* FIXME */ 99 if (vaddr < FIXADDR_START) { /* FIXME */
100 pagefault_enable();
100 return; 101 return;
102 }
101 103
102 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)) 104 type = kmap_atomic_idx();
103 BUG();
104 105
105 /* 106#if HIGHMEM_DEBUG
106 * force other mappings to Oops if they'll try to access 107 {
107 * this pte without first remap it 108 unsigned int idx;
108 */ 109 idx = type + KM_TYPE_NR * smp_processor_id();
109 pte_clear(kmap_pte - idx); 110
110 __flush_tlb_one(vaddr); 111 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx))
112 BUG();
113
114 /*
115 * force other mappings to Oops if they'll try to access
116 * this pte without first remap it
117 */
118 pte_clear(kmap_pte - idx);
119 local_flush_tlb_one(vaddr);
120 }
111#endif 121#endif
112}
113 122
123 kmap_atomic_idx_pop();
124 pagefault_enable();
125}
114#endif /* __KERNEL__ */ 126#endif /* __KERNEL__ */
115 127
116#endif /* _ASM_HIGHMEM_H */ 128#endif /* _ASM_HIGHMEM_H */
diff --git a/arch/mn10300/include/asm/intctl-regs.h b/arch/mn10300/include/asm/intctl-regs.h
index ba544c796c5a..585b708c2bc0 100644
--- a/arch/mn10300/include/asm/intctl-regs.h
+++ b/arch/mn10300/include/asm/intctl-regs.h
@@ -15,24 +15,19 @@
15 15
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17 17
18/* interrupt controller registers */ 18/*
19#define GxICR(X) __SYSREG(0xd4000000 + (X) * 4, u16) /* group irq ctrl regs */ 19 * Interrupt controller registers
20 20 * - Registers 64-191 are at addresses offset from the main array
21#define IAGR __SYSREG(0xd4000100, u16) /* intr acceptance group reg */ 21 */
22#define IAGR_GN 0x00fc /* group number register 22#define GxICR(X) \
23 * (documentation _has_ to be wrong) 23 __SYSREG(0xd4000000 + (X) * 4 + \
24 */ 24 (((X) >= 64) && ((X) < 192)) * 0xf00, u16)
25 25
26#define EXTMD __SYSREG(0xd4000200, u16) /* external pin intr spec reg */ 26#define GxICR_u8(X) \
27#define GET_XIRQ_TRIGGER(X) ((EXTMD >> ((X) * 2)) & 3) 27 __SYSREG(0xd4000000 + (X) * 4 + \
28 (((X) >= 64) && ((X) < 192)) * 0xf00, u8)
28 29
29#define SET_XIRQ_TRIGGER(X,Y) \ 30#include <proc/intctl-regs.h>
30do { \
31 u16 x = EXTMD; \
32 x &= ~(3 << ((X) * 2)); \
33 x |= ((Y) & 3) << ((X) * 2); \
34 EXTMD = x; \
35} while (0)
36 31
37#define XIRQ_TRIGGER_LOWLEVEL 0 32#define XIRQ_TRIGGER_LOWLEVEL 0
38#define XIRQ_TRIGGER_HILEVEL 1 33#define XIRQ_TRIGGER_HILEVEL 1
@@ -59,10 +54,18 @@ do { \
59#define GxICR_LEVEL_5 0x5000 /* - level 5 */ 54#define GxICR_LEVEL_5 0x5000 /* - level 5 */
60#define GxICR_LEVEL_6 0x6000 /* - level 6 */ 55#define GxICR_LEVEL_6 0x6000 /* - level 6 */
61#define GxICR_LEVEL_SHIFT 12 56#define GxICR_LEVEL_SHIFT 12
57#define GxICR_NMI 0x8000 /* nmi request flag */
58
59#define NUM2GxICR_LEVEL(num) ((num) << GxICR_LEVEL_SHIFT)
62 60
63#ifndef __ASSEMBLY__ 61#ifndef __ASSEMBLY__
64extern void set_intr_level(int irq, u16 level); 62extern void set_intr_level(int irq, u16 level);
65extern void set_intr_postackable(int irq); 63extern void mn10300_intc_set_level(unsigned int irq, unsigned int level);
64extern void mn10300_intc_clear(unsigned int irq);
65extern void mn10300_intc_set(unsigned int irq);
66extern void mn10300_intc_enable(unsigned int irq);
67extern void mn10300_intc_disable(unsigned int irq);
68extern void mn10300_set_lateack_irq_type(int irq);
66#endif 69#endif
67 70
68/* external interrupts */ 71/* external interrupts */
diff --git a/arch/mn10300/include/asm/io.h b/arch/mn10300/include/asm/io.h
index c1a4119e6497..787255da744e 100644
--- a/arch/mn10300/include/asm/io.h
+++ b/arch/mn10300/include/asm/io.h
@@ -206,6 +206,19 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
206#define iowrite32_rep(p, src, count) \ 206#define iowrite32_rep(p, src, count) \
207 outsl((unsigned long) (p), (src), (count)) 207 outsl((unsigned long) (p), (src), (count))
208 208
209#define readsb(p, dst, count) \
210 insb((unsigned long) (p), (dst), (count))
211#define readsw(p, dst, count) \
212 insw((unsigned long) (p), (dst), (count))
213#define readsl(p, dst, count) \
214 insl((unsigned long) (p), (dst), (count))
215
216#define writesb(p, src, count) \
217 outsb((unsigned long) (p), (src), (count))
218#define writesw(p, src, count) \
219 outsw((unsigned long) (p), (src), (count))
220#define writesl(p, src, count) \
221 outsl((unsigned long) (p), (src), (count))
209 222
210#define IO_SPACE_LIMIT 0xffffffff 223#define IO_SPACE_LIMIT 0xffffffff
211 224
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/irq.h b/arch/mn10300/include/asm/irq.h
index 25c045d16d1c..1a73fb3f60c6 100644
--- a/arch/mn10300/include/asm/irq.h
+++ b/arch/mn10300/include/asm/irq.h
@@ -21,8 +21,16 @@
21/* this number is used when no interrupt has been assigned */ 21/* this number is used when no interrupt has been assigned */
22#define NO_IRQ INT_MAX 22#define NO_IRQ INT_MAX
23 23
24/* hardware irq numbers */ 24/*
25#define NR_IRQS GxICR_NUM_IRQS 25 * hardware irq numbers
26 * - the ASB2364 has an FPGA with an IRQ multiplexer on it
27 */
28#ifdef CONFIG_MN10300_UNIT_ASB2364
29#include <unit/irq.h>
30#else
31#define NR_CPU_IRQS GxICR_NUM_IRQS
32#define NR_IRQS NR_CPU_IRQS
33#endif
26 34
27/* external hardware irq numbers */ 35/* external hardware irq numbers */
28#define NR_XIRQS GxICR_NUM_XIRQS 36#define NR_XIRQS GxICR_NUM_XIRQS
diff --git a/arch/mn10300/include/asm/irq_regs.h b/arch/mn10300/include/asm/irq_regs.h
index a848cd232eb4..97d0cb5af807 100644
--- a/arch/mn10300/include/asm/irq_regs.h
+++ b/arch/mn10300/include/asm/irq_regs.h
@@ -18,7 +18,11 @@
18#define ARCH_HAS_OWN_IRQ_REGS 18#define ARCH_HAS_OWN_IRQ_REGS
19 19
20#ifndef __ASSEMBLY__ 20#ifndef __ASSEMBLY__
21#define get_irq_regs() (__frame) 21static inline __attribute__((const))
22struct pt_regs *get_irq_regs(void)
23{
24 return current_frame();
25}
22#endif 26#endif
23 27
24#endif /* _ASM_IRQ_REGS_H */ 28#endif /* _ASM_IRQ_REGS_H */
diff --git a/arch/mn10300/include/asm/irqflags.h b/arch/mn10300/include/asm/irqflags.h
index 5e529a117cb2..7a7ae12c7119 100644
--- a/arch/mn10300/include/asm/irqflags.h
+++ b/arch/mn10300/include/asm/irqflags.h
@@ -13,6 +13,9 @@
13#define _ASM_IRQFLAGS_H 13#define _ASM_IRQFLAGS_H
14 14
15#include <asm/cpu-regs.h> 15#include <asm/cpu-regs.h>
16#ifndef __ASSEMBLY__
17#include <linux/smp.h>
18#endif
16 19
17/* 20/*
18 * interrupt control 21 * interrupt control
@@ -23,11 +26,7 @@
23 * - level 6 - timer interrupt 26 * - level 6 - timer interrupt
24 * - "enabled": run in IM7 27 * - "enabled": run in IM7
25 */ 28 */
26#ifdef CONFIG_MN10300_TTYSM 29#define MN10300_CLI_LEVEL (CONFIG_LINUX_CLI_LEVEL << EPSW_IM_SHIFT)
27#define MN10300_CLI_LEVEL EPSW_IM_2
28#else
29#define MN10300_CLI_LEVEL EPSW_IM_1
30#endif
31 30
32#ifndef __ASSEMBLY__ 31#ifndef __ASSEMBLY__
33 32
@@ -64,11 +63,12 @@ static inline unsigned long arch_local_irq_save(void)
64/* 63/*
65 * we make sure arch_irq_enable() doesn't cause priority inversion 64 * we make sure arch_irq_enable() doesn't cause priority inversion
66 */ 65 */
67extern unsigned long __mn10300_irq_enabled_epsw; 66extern unsigned long __mn10300_irq_enabled_epsw[];
68 67
69static inline void arch_local_irq_enable(void) 68static inline void arch_local_irq_enable(void)
70{ 69{
71 unsigned long tmp; 70 unsigned long tmp;
71 int cpu = raw_smp_processor_id();
72 72
73 asm volatile( 73 asm volatile(
74 " mov epsw,%0 \n" 74 " mov epsw,%0 \n"
@@ -76,8 +76,8 @@ static inline void arch_local_irq_enable(void)
76 " or %2,%0 \n" 76 " or %2,%0 \n"
77 " mov %0,epsw \n" 77 " mov %0,epsw \n"
78 : "=&d"(tmp) 78 : "=&d"(tmp)
79 : "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw) 79 : "i"(~EPSW_IM), "r"(__mn10300_irq_enabled_epsw[cpu])
80 : "memory"); 80 : "memory", "cc");
81} 81}
82 82
83static inline void arch_local_irq_restore(unsigned long flags) 83static inline void arch_local_irq_restore(unsigned long flags)
@@ -94,7 +94,7 @@ static inline void arch_local_irq_restore(unsigned long flags)
94 94
95static inline bool arch_irqs_disabled_flags(unsigned long flags) 95static inline bool arch_irqs_disabled_flags(unsigned long flags)
96{ 96{
97 return (flags & EPSW_IM) <= MN10300_CLI_LEVEL; 97 return (flags & (EPSW_IE | EPSW_IM)) != (EPSW_IE | EPSW_IM_7);
98} 98}
99 99
100static inline bool arch_irqs_disabled(void) 100static inline bool arch_irqs_disabled(void)
@@ -109,6 +109,9 @@ static inline bool arch_irqs_disabled(void)
109 */ 109 */
110static inline void arch_safe_halt(void) 110static inline void arch_safe_halt(void)
111{ 111{
112#ifdef CONFIG_SMP
113 arch_local_irq_enable();
114#else
112 asm volatile( 115 asm volatile(
113 " or %0,epsw \n" 116 " or %0,epsw \n"
114 " nop \n" 117 " nop \n"
@@ -117,7 +120,97 @@ static inline void arch_safe_halt(void)
117 : 120 :
118 : "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP) 121 : "i"(EPSW_IE|EPSW_IM), "n"(&CPUM), "i"(CPUM_SLEEP)
119 : "cc"); 122 : "cc");
123#endif
120} 124}
121 125
126#define __sleep_cpu() \
127do { \
128 asm volatile( \
129 " bset %1,(%0)\n" \
130 "1: btst %1,(%0)\n" \
131 " bne 1b\n" \
132 : \
133 : "i"(&CPUM), "i"(CPUM_SLEEP) \
134 : "cc" \
135 ); \
136} while (0)
137
138static inline void arch_local_cli(void)
139{
140 asm volatile(
141 " and %0,epsw \n"
142 " nop \n"
143 " nop \n"
144 " nop \n"
145 :
146 : "i"(~EPSW_IE)
147 : "memory"
148 );
149}
150
151static inline unsigned long arch_local_cli_save(void)
152{
153 unsigned long flags = arch_local_save_flags();
154 arch_local_cli();
155 return flags;
156}
157
158static inline void arch_local_sti(void)
159{
160 asm volatile(
161 " or %0,epsw \n"
162 :
163 : "i"(EPSW_IE)
164 : "memory");
165}
166
167static inline void arch_local_change_intr_mask_level(unsigned long level)
168{
169 asm volatile(
170 " and %0,epsw \n"
171 " or %1,epsw \n"
172 :
173 : "i"(~EPSW_IM), "i"(EPSW_IE | level)
174 : "cc", "memory");
175}
176
177#else /* !__ASSEMBLY__ */
178
179#define LOCAL_SAVE_FLAGS(reg) \
180 mov epsw,reg
181
182#define LOCAL_IRQ_DISABLE \
183 and ~EPSW_IM,epsw; \
184 or EPSW_IE|MN10300_CLI_LEVEL,epsw; \
185 nop; \
186 nop; \
187 nop
188
189#define LOCAL_IRQ_ENABLE \
190 or EPSW_IE|EPSW_IM_7,epsw
191
192#define LOCAL_IRQ_RESTORE(reg) \
193 mov reg,epsw
194
195#define LOCAL_CLI_SAVE(reg) \
196 mov epsw,reg; \
197 and ~EPSW_IE,epsw; \
198 nop; \
199 nop; \
200 nop
201
202#define LOCAL_CLI \
203 and ~EPSW_IE,epsw; \
204 nop; \
205 nop; \
206 nop
207
208#define LOCAL_STI \
209 or EPSW_IE,epsw
210
211#define LOCAL_CHANGE_INTR_MASK_LEVEL(level) \
212 and ~EPSW_IM,epsw; \
213 or EPSW_IE|(level),epsw
214
122#endif /* __ASSEMBLY__ */ 215#endif /* __ASSEMBLY__ */
123#endif /* _ASM_IRQFLAGS_H */ 216#endif /* _ASM_IRQFLAGS_H */
diff --git a/arch/mn10300/include/asm/mmu_context.h b/arch/mn10300/include/asm/mmu_context.h
index cb294c244de3..c8f6c82672ad 100644
--- a/arch/mn10300/include/asm/mmu_context.h
+++ b/arch/mn10300/include/asm/mmu_context.h
@@ -27,28 +27,38 @@
27#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
28#include <asm-generic/mm_hooks.h> 28#include <asm-generic/mm_hooks.h>
29 29
30#define MMU_CONTEXT_TLBPID_NR 256
30#define MMU_CONTEXT_TLBPID_MASK 0x000000ffUL 31#define MMU_CONTEXT_TLBPID_MASK 0x000000ffUL
31#define MMU_CONTEXT_VERSION_MASK 0xffffff00UL 32#define MMU_CONTEXT_VERSION_MASK 0xffffff00UL
32#define MMU_CONTEXT_FIRST_VERSION 0x00000100UL 33#define MMU_CONTEXT_FIRST_VERSION 0x00000100UL
33#define MMU_NO_CONTEXT 0x00000000UL 34#define MMU_NO_CONTEXT 0x00000000UL
34 35#define MMU_CONTEXT_TLBPID_LOCK_NR 0
35extern unsigned long mmu_context_cache[NR_CPUS];
36#define mm_context(mm) (mm->context.tlbpid[smp_processor_id()])
37 36
38#define enter_lazy_tlb(mm, tsk) do {} while (0) 37#define enter_lazy_tlb(mm, tsk) do {} while (0)
39 38
39static inline void cpu_ran_vm(int cpu, struct mm_struct *mm)
40{
40#ifdef CONFIG_SMP 41#ifdef CONFIG_SMP
41#define cpu_ran_vm(cpu, mm) \ 42 cpumask_set_cpu(cpu, mm_cpumask(mm));
42 cpumask_set_cpu((cpu), mm_cpumask(mm)) 43#endif
43#define cpu_maybe_ran_vm(cpu, mm) \ 44}
44 cpumask_test_and_set_cpu((cpu), mm_cpumask(mm)) 45
46static inline bool cpu_maybe_ran_vm(int cpu, struct mm_struct *mm)
47{
48#ifdef CONFIG_SMP
49 return cpumask_test_and_set_cpu(cpu, mm_cpumask(mm));
45#else 50#else
46#define cpu_ran_vm(cpu, mm) do {} while (0) 51 return true;
47#define cpu_maybe_ran_vm(cpu, mm) true 52#endif
48#endif /* CONFIG_SMP */ 53}
49 54
50/* 55#ifdef CONFIG_MN10300_TLB_USE_PIDR
51 * allocate an MMU context 56extern unsigned long mmu_context_cache[NR_CPUS];
57#define mm_context(mm) (mm->context.tlbpid[smp_processor_id()])
58
59/**
60 * allocate_mmu_context - Allocate storage for the arch-specific MMU data
61 * @mm: The userspace VM context being set up
52 */ 62 */
53static inline unsigned long allocate_mmu_context(struct mm_struct *mm) 63static inline unsigned long allocate_mmu_context(struct mm_struct *mm)
54{ 64{
@@ -58,7 +68,7 @@ static inline unsigned long allocate_mmu_context(struct mm_struct *mm)
58 if (!(mc & MMU_CONTEXT_TLBPID_MASK)) { 68 if (!(mc & MMU_CONTEXT_TLBPID_MASK)) {
59 /* we exhausted the TLB PIDs of this version on this CPU, so we 69 /* we exhausted the TLB PIDs of this version on this CPU, so we
60 * flush this CPU's TLB in its entirety and start new cycle */ 70 * flush this CPU's TLB in its entirety and start new cycle */
61 flush_tlb_all(); 71 local_flush_tlb_all();
62 72
63 /* fix the TLB version if needed (we avoid version #0 so as to 73 /* fix the TLB version if needed (we avoid version #0 so as to
64 * distingush MMU_NO_CONTEXT) */ 74 * distingush MMU_NO_CONTEXT) */
@@ -101,22 +111,34 @@ static inline int init_new_context(struct task_struct *tsk,
101} 111}
102 112
103/* 113/*
104 * destroy context related info for an mm_struct that is about to be put to
105 * rest
106 */
107#define destroy_context(mm) do { } while (0)
108
109/*
110 * after we have set current->mm to a new value, this activates the context for 114 * after we have set current->mm to a new value, this activates the context for
111 * the new mm so we see the new mappings. 115 * the new mm so we see the new mappings.
112 */ 116 */
113static inline void activate_context(struct mm_struct *mm, int cpu) 117static inline void activate_context(struct mm_struct *mm)
114{ 118{
115 PIDR = get_mmu_context(mm) & MMU_CONTEXT_TLBPID_MASK; 119 PIDR = get_mmu_context(mm) & MMU_CONTEXT_TLBPID_MASK;
116} 120}
121#else /* CONFIG_MN10300_TLB_USE_PIDR */
117 122
118/* 123#define init_new_context(tsk, mm) (0)
119 * change between virtual memory sets 124#define activate_context(mm) local_flush_tlb()
125
126#endif /* CONFIG_MN10300_TLB_USE_PIDR */
127
128/**
129 * destroy_context - Destroy mm context information
130 * @mm: The MM being destroyed.
131 *
132 * Destroy context related info for an mm_struct that is about to be put to
133 * rest
134 */
135#define destroy_context(mm) do {} while (0)
136
137/**
138 * switch_mm - Change between userspace virtual memory contexts
139 * @prev: The outgoing MM context.
140 * @next: The incoming MM context.
141 * @tsk: The incoming task.
120 */ 142 */
121static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 143static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
122 struct task_struct *tsk) 144 struct task_struct *tsk)
@@ -124,11 +146,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
124 int cpu = smp_processor_id(); 146 int cpu = smp_processor_id();
125 147
126 if (prev != next) { 148 if (prev != next) {
149#ifdef CONFIG_SMP
150 per_cpu(cpu_tlbstate, cpu).active_mm = next;
151#endif
127 cpu_ran_vm(cpu, next); 152 cpu_ran_vm(cpu, next);
128 activate_context(next, cpu);
129 PTBR = (unsigned long) next->pgd; 153 PTBR = (unsigned long) next->pgd;
130 } else if (!cpu_maybe_ran_vm(cpu, next)) { 154 activate_context(next);
131 activate_context(next, cpu);
132 } 155 }
133} 156}
134 157
diff --git a/arch/mn10300/include/asm/pgalloc.h b/arch/mn10300/include/asm/pgalloc.h
index a19f11327cd8..146bacf193ea 100644
--- a/arch/mn10300/include/asm/pgalloc.h
+++ b/arch/mn10300/include/asm/pgalloc.h
@@ -11,7 +11,6 @@
11#ifndef _ASM_PGALLOC_H 11#ifndef _ASM_PGALLOC_H
12#define _ASM_PGALLOC_H 12#define _ASM_PGALLOC_H
13 13
14#include <asm/processor.h>
15#include <asm/page.h> 14#include <asm/page.h>
16#include <linux/threads.h> 15#include <linux/threads.h>
17#include <linux/mm.h> /* for struct page */ 16#include <linux/mm.h> /* for struct page */
diff --git a/arch/mn10300/include/asm/pgtable.h b/arch/mn10300/include/asm/pgtable.h
index 16d88577f3e0..a1e894b5f65b 100644
--- a/arch/mn10300/include/asm/pgtable.h
+++ b/arch/mn10300/include/asm/pgtable.h
@@ -90,46 +90,58 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
90 * The vmalloc() routines also leaves a hole of 4kB between each vmalloced 90 * The vmalloc() routines also leaves a hole of 4kB between each vmalloced
91 * area to catch addressing errors. 91 * area to catch addressing errors.
92 */ 92 */
93#ifndef __ASSEMBLY__
94#define VMALLOC_OFFSET (8UL * 1024 * 1024)
95#define VMALLOC_START (0x70000000UL)
96#define VMALLOC_END (0x7C000000UL)
97#else
93#define VMALLOC_OFFSET (8 * 1024 * 1024) 98#define VMALLOC_OFFSET (8 * 1024 * 1024)
94#define VMALLOC_START (0x70000000) 99#define VMALLOC_START (0x70000000)
95#define VMALLOC_END (0x7C000000) 100#define VMALLOC_END (0x7C000000)
101#endif
96 102
97#ifndef __ASSEMBLY__ 103#ifndef __ASSEMBLY__
98extern pte_t kernel_vmalloc_ptes[(VMALLOC_END - VMALLOC_START) / PAGE_SIZE]; 104extern pte_t kernel_vmalloc_ptes[(VMALLOC_END - VMALLOC_START) / PAGE_SIZE];
99#endif 105#endif
100 106
101/* IPTEL/DPTEL bit assignments */ 107/* IPTEL2/DPTEL2 bit assignments */
102#define _PAGE_BIT_VALID xPTEL_V_BIT 108#define _PAGE_BIT_VALID xPTEL2_V_BIT
103#define _PAGE_BIT_ACCESSED xPTEL_UNUSED1_BIT /* mustn't be loaded into IPTEL/DPTEL */ 109#define _PAGE_BIT_CACHE xPTEL2_C_BIT
104#define _PAGE_BIT_NX xPTEL_UNUSED2_BIT /* mustn't be loaded into IPTEL/DPTEL */ 110#define _PAGE_BIT_PRESENT xPTEL2_PV_BIT
105#define _PAGE_BIT_CACHE xPTEL_C_BIT 111#define _PAGE_BIT_DIRTY xPTEL2_D_BIT
106#define _PAGE_BIT_PRESENT xPTEL_PV_BIT 112#define _PAGE_BIT_GLOBAL xPTEL2_G_BIT
107#define _PAGE_BIT_DIRTY xPTEL_D_BIT 113#define _PAGE_BIT_ACCESSED xPTEL2_UNUSED1_BIT /* mustn't be loaded into IPTEL2/DPTEL2 */
108#define _PAGE_BIT_GLOBAL xPTEL_G_BIT 114
109 115#define _PAGE_VALID xPTEL2_V
110#define _PAGE_VALID xPTEL_V 116#define _PAGE_CACHE xPTEL2_C
111#define _PAGE_ACCESSED xPTEL_UNUSED1 117#define _PAGE_PRESENT xPTEL2_PV
112#define _PAGE_NX xPTEL_UNUSED2 /* no-execute bit */ 118#define _PAGE_DIRTY xPTEL2_D
113#define _PAGE_CACHE xPTEL_C 119#define _PAGE_PROT xPTEL2_PR
114#define _PAGE_PRESENT xPTEL_PV 120#define _PAGE_PROT_RKNU xPTEL2_PR_ROK
115#define _PAGE_DIRTY xPTEL_D 121#define _PAGE_PROT_WKNU xPTEL2_PR_RWK
116#define _PAGE_PROT xPTEL_PR 122#define _PAGE_PROT_RKRU xPTEL2_PR_ROK_ROU
117#define _PAGE_PROT_RKNU xPTEL_PR_ROK 123#define _PAGE_PROT_WKRU xPTEL2_PR_RWK_ROU
118#define _PAGE_PROT_WKNU xPTEL_PR_RWK 124#define _PAGE_PROT_WKWU xPTEL2_PR_RWK_RWU
119#define _PAGE_PROT_RKRU xPTEL_PR_ROK_ROU 125#define _PAGE_GLOBAL xPTEL2_G
120#define _PAGE_PROT_WKRU xPTEL_PR_RWK_ROU 126#define _PAGE_PS_MASK xPTEL2_PS
121#define _PAGE_PROT_WKWU xPTEL_PR_RWK_RWU 127#define _PAGE_PS_4Kb xPTEL2_PS_4Kb
122#define _PAGE_GLOBAL xPTEL_G 128#define _PAGE_PS_128Kb xPTEL2_PS_128Kb
123#define _PAGE_PSE xPTEL_PS_4Mb /* 4MB page */ 129#define _PAGE_PS_1Kb xPTEL2_PS_1Kb
124 130#define _PAGE_PS_4Mb xPTEL2_PS_4Mb
125#define _PAGE_FILE xPTEL_UNUSED1_BIT /* set:pagecache unset:swap */ 131#define _PAGE_PSE xPTEL2_PS_4Mb /* 4MB page */
126 132#define _PAGE_CACHE_WT xPTEL2_CWT
127#define __PAGE_PROT_UWAUX 0x040 133#define _PAGE_ACCESSED xPTEL2_UNUSED1
128#define __PAGE_PROT_USER 0x080 134#define _PAGE_NX 0 /* no-execute bit */
129#define __PAGE_PROT_WRITE 0x100 135
136/* If _PAGE_VALID is clear, we use these: */
137#define _PAGE_FILE xPTEL2_C /* set:pagecache unset:swap */
138#define _PAGE_PROTNONE 0x000 /* If not present */
139
140#define __PAGE_PROT_UWAUX 0x010
141#define __PAGE_PROT_USER 0x020
142#define __PAGE_PROT_WRITE 0x040
130 143
131#define _PAGE_PRESENTV (_PAGE_PRESENT|_PAGE_VALID) 144#define _PAGE_PRESENTV (_PAGE_PRESENT|_PAGE_VALID)
132#define _PAGE_PROTNONE 0x000 /* If not present */
133 145
134#ifndef __ASSEMBLY__ 146#ifndef __ASSEMBLY__
135 147
@@ -170,6 +182,9 @@ extern pte_t kernel_vmalloc_ptes[(VMALLOC_END - VMALLOC_START) / PAGE_SIZE];
170#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE) 182#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE)
171#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC) 183#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC)
172 184
185#define __PAGE_USERIO (__PAGE_KERNEL_BASE | _PAGE_PROT_WKWU | _PAGE_NX)
186#define PAGE_USERIO __pgprot(__PAGE_USERIO)
187
173/* 188/*
174 * Whilst the MN10300 can do page protection for execute (given separate data 189 * Whilst the MN10300 can do page protection for execute (given separate data
175 * and insn TLBs), we are not supporting it at the moment. Write permission, 190 * and insn TLBs), we are not supporting it at the moment. Write permission,
@@ -323,11 +338,7 @@ static inline int pte_exec_kernel(pte_t pte)
323 return 1; 338 return 1;
324} 339}
325 340
326/* 341#define PTE_FILE_MAX_BITS 30
327 * Bits 0 and 1 are taken, split up the 29 bits of offset
328 * into this range:
329 */
330#define PTE_FILE_MAX_BITS 29
331 342
332#define pte_to_pgoff(pte) (pte_val(pte) >> 2) 343#define pte_to_pgoff(pte) (pte_val(pte) >> 2)
333#define pgoff_to_pte(off) __pte((off) << 2 | _PAGE_FILE) 344#define pgoff_to_pte(off) __pte((off) << 2 | _PAGE_FILE)
@@ -373,8 +384,13 @@ static inline void ptep_mkdirty(pte_t *ptep)
373 * Macro to mark a page protection value as "uncacheable". On processors which 384 * Macro to mark a page protection value as "uncacheable". On processors which
374 * do not support it, this is a no-op. 385 * do not support it, this is a no-op.
375 */ 386 */
376#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) | _PAGE_CACHE) 387#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) & ~_PAGE_CACHE)
377 388
389/*
390 * Macro to mark a page protection value as "Write-Through".
391 * On processors which do not support it, this is a no-op.
392 */
393#define pgprot_through(prot) __pgprot(pgprot_val(prot) | _PAGE_CACHE_WT)
378 394
379/* 395/*
380 * Conversion functions: convert a page and protection to a page entry, 396 * Conversion functions: convert a page and protection to a page entry,
@@ -457,9 +473,7 @@ static inline int set_kernel_exec(unsigned long vaddr, int enable)
457 473
458#define pte_offset_map(dir, address) \ 474#define pte_offset_map(dir, address) \
459 ((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address)) 475 ((pte_t *) page_address(pmd_page(*(dir))) + pte_index(address))
460#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
461#define pte_unmap(pte) do {} while (0) 476#define pte_unmap(pte) do {} while (0)
462#define pte_unmap_nested(pte) do {} while (0)
463 477
464/* 478/*
465 * The MN10300 has external MMU info in the form of a TLB: this is adapted from 479 * The MN10300 has external MMU info in the form of a TLB: this is adapted from
diff --git a/arch/mn10300/include/asm/processor.h b/arch/mn10300/include/asm/processor.h
index f7d4b0d285e8..4c1b5cc14c19 100644
--- a/arch/mn10300/include/asm/processor.h
+++ b/arch/mn10300/include/asm/processor.h
@@ -13,10 +13,13 @@
13#ifndef _ASM_PROCESSOR_H 13#ifndef _ASM_PROCESSOR_H
14#define _ASM_PROCESSOR_H 14#define _ASM_PROCESSOR_H
15 15
16#include <linux/threads.h>
17#include <linux/thread_info.h>
16#include <asm/page.h> 18#include <asm/page.h>
17#include <asm/ptrace.h> 19#include <asm/ptrace.h>
18#include <asm/cpu-regs.h> 20#include <asm/cpu-regs.h>
19#include <linux/threads.h> 21#include <asm/uaccess.h>
22#include <asm/current.h>
20 23
21/* Forward declaration, a strange C thing */ 24/* Forward declaration, a strange C thing */
22struct task_struct; 25struct task_struct;
@@ -33,6 +36,8 @@ struct mm_struct;
33 __pc; \ 36 __pc; \
34}) 37})
35 38
39extern void get_mem_info(unsigned long *mem_base, unsigned long *mem_size);
40
36extern void show_registers(struct pt_regs *regs); 41extern void show_registers(struct pt_regs *regs);
37 42
38/* 43/*
@@ -43,17 +48,22 @@ extern void show_registers(struct pt_regs *regs);
43 48
44struct mn10300_cpuinfo { 49struct mn10300_cpuinfo {
45 int type; 50 int type;
46 unsigned long loops_per_sec; 51 unsigned long loops_per_jiffy;
47 char hard_math; 52 char hard_math;
48 unsigned long *pgd_quick;
49 unsigned long *pte_quick;
50 unsigned long pgtable_cache_sz;
51}; 53};
52 54
53extern struct mn10300_cpuinfo boot_cpu_data; 55extern struct mn10300_cpuinfo boot_cpu_data;
54 56
57#ifdef CONFIG_SMP
58#if CONFIG_NR_CPUS < 2 || CONFIG_NR_CPUS > 8
59# error Sorry, NR_CPUS should be 2 to 8
60#endif
61extern struct mn10300_cpuinfo cpu_data[];
62#define current_cpu_data cpu_data[smp_processor_id()]
63#else /* CONFIG_SMP */
55#define cpu_data &boot_cpu_data 64#define cpu_data &boot_cpu_data
56#define current_cpu_data boot_cpu_data 65#define current_cpu_data boot_cpu_data
66#endif /* CONFIG_SMP */
57 67
58extern void identify_cpu(struct mn10300_cpuinfo *); 68extern void identify_cpu(struct mn10300_cpuinfo *);
59extern void print_cpu_info(struct mn10300_cpuinfo *); 69extern void print_cpu_info(struct mn10300_cpuinfo *);
@@ -76,10 +86,6 @@ extern void dodgy_tsc(void);
76 */ 86 */
77#define TASK_UNMAPPED_BASE 0x30000000 87#define TASK_UNMAPPED_BASE 0x30000000
78 88
79typedef struct {
80 unsigned long seg;
81} mm_segment_t;
82
83struct fpu_state_struct { 89struct fpu_state_struct {
84 unsigned long fs[32]; /* fpu registers */ 90 unsigned long fs[32]; /* fpu registers */
85 unsigned long fpcr; /* fpu control register */ 91 unsigned long fpcr; /* fpu control register */
@@ -92,20 +98,19 @@ struct thread_struct {
92 unsigned long a3; /* kernel FP */ 98 unsigned long a3; /* kernel FP */
93 unsigned long wchan; 99 unsigned long wchan;
94 unsigned long usp; 100 unsigned long usp;
95 struct pt_regs *__frame;
96 unsigned long fpu_flags; 101 unsigned long fpu_flags;
97#define THREAD_USING_FPU 0x00000001 /* T if this task is using the FPU */ 102#define THREAD_USING_FPU 0x00000001 /* T if this task is using the FPU */
103#define THREAD_HAS_FPU 0x00000002 /* T if this task owns the FPU right now */
98 struct fpu_state_struct fpu_state; 104 struct fpu_state_struct fpu_state;
99}; 105};
100 106
101#define INIT_THREAD \ 107#define INIT_THREAD \
102{ \ 108{ \
103 .uregs = init_uregs, \ 109 .uregs = init_uregs, \
104 .pc = 0, \ 110 .pc = 0, \
105 .sp = 0, \ 111 .sp = 0, \
106 .a3 = 0, \ 112 .a3 = 0, \
107 .wchan = 0, \ 113 .wchan = 0, \
108 .__frame = NULL, \
109} 114}
110 115
111#define INIT_MMAP \ 116#define INIT_MMAP \
@@ -117,13 +122,20 @@ struct thread_struct {
117 * - need to discard the frame stacked by the kernel thread invoking the execve 122 * - need to discard the frame stacked by the kernel thread invoking the execve
118 * syscall (see RESTORE_ALL macro) 123 * syscall (see RESTORE_ALL macro)
119 */ 124 */
120#define start_thread(regs, new_pc, new_sp) do { \ 125static inline void start_thread(struct pt_regs *regs,
121 set_fs(USER_DS); \ 126 unsigned long new_pc, unsigned long new_sp)
122 __frame = current->thread.uregs; \ 127{
123 __frame->epsw = EPSW_nSL | EPSW_IE | EPSW_IM; \ 128 struct thread_info *ti = current_thread_info();
124 __frame->pc = new_pc; \ 129 struct pt_regs *frame0;
125 __frame->sp = new_sp; \ 130 set_fs(USER_DS);
126} while (0) 131
132 frame0 = thread_info_to_uregs(ti);
133 frame0->epsw = EPSW_nSL | EPSW_IE | EPSW_IM;
134 frame0->pc = new_pc;
135 frame0->sp = new_sp;
136 ti->frame = frame0;
137}
138
127 139
128/* Free all resources held by a thread. */ 140/* Free all resources held by a thread. */
129extern void release_thread(struct task_struct *); 141extern void release_thread(struct task_struct *);
@@ -157,7 +169,7 @@ unsigned long get_wchan(struct task_struct *p);
157 169
158static inline void prefetch(const void *x) 170static inline void prefetch(const void *x)
159{ 171{
160#ifndef CONFIG_MN10300_CACHE_DISABLED 172#ifdef CONFIG_MN10300_CACHE_ENABLED
161#ifdef CONFIG_MN10300_PROC_MN103E010 173#ifdef CONFIG_MN10300_PROC_MN103E010
162 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x)); 174 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
163#else 175#else
@@ -168,7 +180,7 @@ static inline void prefetch(const void *x)
168 180
169static inline void prefetchw(const void *x) 181static inline void prefetchw(const void *x)
170{ 182{
171#ifndef CONFIG_MN10300_CACHE_DISABLED 183#ifdef CONFIG_MN10300_CACHE_ENABLED
172#ifdef CONFIG_MN10300_PROC_MN103E010 184#ifdef CONFIG_MN10300_PROC_MN103E010
173 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x)); 185 asm volatile ("nop; nop; dcpf (%0)" : : "r"(x));
174#else 186#else
diff --git a/arch/mn10300/include/asm/ptrace.h b/arch/mn10300/include/asm/ptrace.h
index 7c2e911052b6..b6961811d445 100644
--- a/arch/mn10300/include/asm/ptrace.h
+++ b/arch/mn10300/include/asm/ptrace.h
@@ -40,7 +40,6 @@
40#define PT_PC 26 40#define PT_PC 26
41#define NR_PTREGS 27 41#define NR_PTREGS 27
42 42
43#ifndef __ASSEMBLY__
44/* 43/*
45 * This defines the way registers are stored in the event of an exception 44 * This defines the way registers are stored in the event of an exception
46 * - the strange order is due to the MOVM instruction 45 * - the strange order is due to the MOVM instruction
@@ -75,7 +74,6 @@ struct pt_regs {
75 unsigned long epsw; 74 unsigned long epsw;
76 unsigned long pc; 75 unsigned long pc;
77}; 76};
78#endif
79 77
80/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ 78/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
81#define PTRACE_GETREGS 12 79#define PTRACE_GETREGS 12
@@ -86,12 +84,7 @@ struct pt_regs {
86/* options set using PTRACE_SETOPTIONS */ 84/* options set using PTRACE_SETOPTIONS */
87#define PTRACE_O_TRACESYSGOOD 0x00000001 85#define PTRACE_O_TRACESYSGOOD 0x00000001
88 86
89#if defined(__KERNEL__) 87#ifdef __KERNEL__
90
91extern struct pt_regs *__frame; /* current frame pointer */
92
93#if !defined(__ASSEMBLY__)
94struct task_struct;
95 88
96#define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL) 89#define user_mode(regs) (((regs)->epsw & EPSW_nSL) == EPSW_nSL)
97#define instruction_pointer(regs) ((regs)->pc) 90#define instruction_pointer(regs) ((regs)->pc)
@@ -100,9 +93,7 @@ extern void show_regs(struct pt_regs *);
100 93
101#define arch_has_single_step() (1) 94#define arch_has_single_step() (1)
102 95
103#endif /* !__ASSEMBLY */
104
105#define profile_pc(regs) ((regs)->pc) 96#define profile_pc(regs) ((regs)->pc)
106 97
107#endif /* __KERNEL__ */ 98#endif /* __KERNEL__ */
108#endif /* _ASM_PTRACE_H */ 99#endif /* _ASM_PTRACE_H */
diff --git a/arch/mn10300/include/asm/reset-regs.h b/arch/mn10300/include/asm/reset-regs.h
index 174523d50132..10c7502a113f 100644
--- a/arch/mn10300/include/asm/reset-regs.h
+++ b/arch/mn10300/include/asm/reset-regs.h
@@ -50,7 +50,7 @@ static inline void mn10300_proc_hard_reset(void)
50 RSTCTR |= RSTCTR_CHIPRST; 50 RSTCTR |= RSTCTR_CHIPRST;
51} 51}
52 52
53extern unsigned int watchdog_alert_counter; 53extern unsigned int watchdog_alert_counter[];
54 54
55extern void watchdog_go(void); 55extern void watchdog_go(void);
56extern asmlinkage void watchdog_handler(void); 56extern asmlinkage void watchdog_handler(void);
diff --git a/arch/mn10300/include/asm/rtc.h b/arch/mn10300/include/asm/rtc.h
index c295194cc703..6c14bb1d0d9b 100644
--- a/arch/mn10300/include/asm/rtc.h
+++ b/arch/mn10300/include/asm/rtc.h
@@ -15,25 +15,14 @@
15 15
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18extern void check_rtc_time(void);
19extern void __init calibrate_clock(void); 18extern void __init calibrate_clock(void);
20extern unsigned long __init get_initial_rtc_time(void);
21 19
22#else /* !CONFIG_MN10300_RTC */ 20#else /* !CONFIG_MN10300_RTC */
23 21
24static inline void check_rtc_time(void)
25{
26}
27
28static inline void calibrate_clock(void) 22static inline void calibrate_clock(void)
29{ 23{
30} 24}
31 25
32static inline unsigned long get_initial_rtc_time(void)
33{
34 return 0;
35}
36
37#endif /* !CONFIG_MN10300_RTC */ 26#endif /* !CONFIG_MN10300_RTC */
38 27
39#include <asm-generic/rtc.h> 28#include <asm-generic/rtc.h>
diff --git a/arch/mn10300/include/asm/rwlock.h b/arch/mn10300/include/asm/rwlock.h
new file mode 100644
index 000000000000..6d594d4a0e10
--- /dev/null
+++ b/arch/mn10300/include/asm/rwlock.h
@@ -0,0 +1,125 @@
1/*
2 * Helpers used by both rw spinlocks and rw semaphores.
3 *
4 * Based in part on code from semaphore.h and
5 * spinlock.h Copyright 1996 Linus Torvalds.
6 *
7 * Copyright 1999 Red Hat, Inc.
8 *
9 * Written by Benjamin LaHaise.
10 *
11 * Modified by Matsushita Electric Industrial Co., Ltd.
12 * Modifications:
13 * 13-Nov-2006 MEI Temporarily delete lock functions for SMP support.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
18 * any later version.
19 */
20#ifndef _ASM_RWLOCK_H
21#define _ASM_RWLOCK_H
22
23#define RW_LOCK_BIAS 0x01000000
24
25#ifndef CONFIG_SMP
26
27typedef struct { unsigned long a[100]; } __dummy_lock_t;
28#define __dummy_lock(lock) (*(__dummy_lock_t *)(lock))
29
30#define RW_LOCK_BIAS_STR "0x01000000"
31
32#define __build_read_lock_ptr(rw, helper) \
33 do { \
34 asm volatile( \
35 " mov (%0),d3 \n" \
36 " sub 1,d3 \n" \
37 " mov d3,(%0) \n" \
38 " blt 1f \n" \
39 " bra 2f \n" \
40 "1: jmp 3f \n" \
41 "2: \n" \
42 " .section .text.lock,\"ax\" \n" \
43 "3: call "helper"[],0 \n" \
44 " jmp 2b \n" \
45 " .previous" \
46 : \
47 : "d" (rw) \
48 : "memory", "d3", "cc"); \
49 } while (0)
50
51#define __build_read_lock_const(rw, helper) \
52 do { \
53 asm volatile( \
54 " mov (%0),d3 \n" \
55 " sub 1,d3 \n" \
56 " mov d3,(%0) \n" \
57 " blt 1f \n" \
58 " bra 2f \n" \
59 "1: jmp 3f \n" \
60 "2: \n" \
61 " .section .text.lock,\"ax\" \n" \
62 "3: call "helper"[],0 \n" \
63 " jmp 2b \n" \
64 " .previous" \
65 : \
66 : "d" (rw) \
67 : "memory", "d3", "cc"); \
68 } while (0)
69
70#define __build_read_lock(rw, helper) \
71 do { \
72 if (__builtin_constant_p(rw)) \
73 __build_read_lock_const(rw, helper); \
74 else \
75 __build_read_lock_ptr(rw, helper); \
76 } while (0)
77
78#define __build_write_lock_ptr(rw, helper) \
79 do { \
80 asm volatile( \
81 " mov (%0),d3 \n" \
82 " sub 1,d3 \n" \
83 " mov d3,(%0) \n" \
84 " blt 1f \n" \
85 " bra 2f \n" \
86 "1: jmp 3f \n" \
87 "2: \n" \
88 " .section .text.lock,\"ax\" \n" \
89 "3: call "helper"[],0 \n" \
90 " jmp 2b \n" \
91 " .previous" \
92 : \
93 : "d" (rw) \
94 : "memory", "d3", "cc"); \
95 } while (0)
96
97#define __build_write_lock_const(rw, helper) \
98 do { \
99 asm volatile( \
100 " mov (%0),d3 \n" \
101 " sub 1,d3 \n" \
102 " mov d3,(%0) \n" \
103 " blt 1f \n" \
104 " bra 2f \n" \
105 "1: jmp 3f \n" \
106 "2: \n" \
107 " .section .text.lock,\"ax\" \n" \
108 "3: call "helper"[],0 \n" \
109 " jmp 2b \n" \
110 " .previous" \
111 : \
112 : "d" (rw) \
113 : "memory", "d3", "cc"); \
114 } while (0)
115
116#define __build_write_lock(rw, helper) \
117 do { \
118 if (__builtin_constant_p(rw)) \
119 __build_write_lock_const(rw, helper); \
120 else \
121 __build_write_lock_ptr(rw, helper); \
122 } while (0)
123
124#endif /* CONFIG_SMP */
125#endif /* _ASM_RWLOCK_H */
diff --git a/arch/mn10300/include/asm/serial-regs.h b/arch/mn10300/include/asm/serial-regs.h
index 6498469e93ac..8320cda32f5a 100644
--- a/arch/mn10300/include/asm/serial-regs.h
+++ b/arch/mn10300/include/asm/serial-regs.h
@@ -20,18 +20,25 @@
20/* serial port 0 */ 20/* serial port 0 */
21#define SC0CTR __SYSREG(0xd4002000, u16) /* control reg */ 21#define SC0CTR __SYSREG(0xd4002000, u16) /* control reg */
22#define SC01CTR_CK 0x0007 /* clock source select */ 22#define SC01CTR_CK 0x0007 /* clock source select */
23#define SC0CTR_CK_TM8UFLOW_8 0x0000 /* - 1/8 timer 8 underflow (serial port 0 only) */
24#define SC1CTR_CK_TM9UFLOW_8 0x0000 /* - 1/8 timer 9 underflow (serial port 1 only) */
25#define SC01CTR_CK_IOCLK_8 0x0001 /* - 1/8 IOCLK */ 23#define SC01CTR_CK_IOCLK_8 0x0001 /* - 1/8 IOCLK */
26#define SC01CTR_CK_IOCLK_32 0x0002 /* - 1/32 IOCLK */ 24#define SC01CTR_CK_IOCLK_32 0x0002 /* - 1/32 IOCLK */
25#define SC01CTR_CK_EXTERN_8 0x0006 /* - 1/8 external closk */
26#define SC01CTR_CK_EXTERN 0x0007 /* - external closk */
27#if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
28#define SC0CTR_CK_TM8UFLOW_8 0x0000 /* - 1/8 timer 8 underflow (serial port 0 only) */
27#define SC0CTR_CK_TM2UFLOW_2 0x0003 /* - 1/2 timer 2 underflow (serial port 0 only) */ 29#define SC0CTR_CK_TM2UFLOW_2 0x0003 /* - 1/2 timer 2 underflow (serial port 0 only) */
28#define SC1CTR_CK_TM3UFLOW_2 0x0003 /* - 1/2 timer 3 underflow (serial port 1 only) */ 30#define SC0CTR_CK_TM0UFLOW_8 0x0004 /* - 1/8 timer 0 underflow (serial port 0 only) */
29#define SC0CTR_CK_TM0UFLOW_8 0x0004 /* - 1/8 timer 1 underflow (serial port 0 only) */
30#define SC1CTR_CK_TM1UFLOW_8 0x0004 /* - 1/8 timer 2 underflow (serial port 1 only) */
31#define SC0CTR_CK_TM2UFLOW_8 0x0005 /* - 1/8 timer 2 underflow (serial port 0 only) */ 31#define SC0CTR_CK_TM2UFLOW_8 0x0005 /* - 1/8 timer 2 underflow (serial port 0 only) */
32#define SC1CTR_CK_TM9UFLOW_8 0x0000 /* - 1/8 timer 9 underflow (serial port 1 only) */
33#define SC1CTR_CK_TM3UFLOW_2 0x0003 /* - 1/2 timer 3 underflow (serial port 1 only) */
34#define SC1CTR_CK_TM1UFLOW_8 0x0004 /* - 1/8 timer 1 underflow (serial port 1 only) */
32#define SC1CTR_CK_TM3UFLOW_8 0x0005 /* - 1/8 timer 3 underflow (serial port 1 only) */ 35#define SC1CTR_CK_TM3UFLOW_8 0x0005 /* - 1/8 timer 3 underflow (serial port 1 only) */
33#define SC01CTR_CK_EXTERN_8 0x0006 /* - 1/8 external closk */ 36#else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
34#define SC01CTR_CK_EXTERN 0x0007 /* - external closk */ 37#define SC0CTR_CK_TM8UFLOW_8 0x0000 /* - 1/8 timer 8 underflow (serial port 0 only) */
38#define SC0CTR_CK_TM0UFLOW_8 0x0004 /* - 1/8 timer 0 underflow (serial port 0 only) */
39#define SC0CTR_CK_TM2UFLOW_8 0x0005 /* - 1/8 timer 2 underflow (serial port 0 only) */
40#define SC1CTR_CK_TM12UFLOW_8 0x0000 /* - 1/8 timer 12 underflow (serial port 1 only) */
41#endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
35#define SC01CTR_STB 0x0008 /* stop bit select */ 42#define SC01CTR_STB 0x0008 /* stop bit select */
36#define SC01CTR_STB_1BIT 0x0000 /* - 1 stop bit */ 43#define SC01CTR_STB_1BIT 0x0000 /* - 1 stop bit */
37#define SC01CTR_STB_2BIT 0x0008 /* - 2 stop bits */ 44#define SC01CTR_STB_2BIT 0x0008 /* - 2 stop bits */
@@ -100,11 +107,23 @@
100 107
101/* serial port 2 */ 108/* serial port 2 */
102#define SC2CTR __SYSREG(0xd4002020, u16) /* control reg */ 109#define SC2CTR __SYSREG(0xd4002020, u16) /* control reg */
110#ifdef CONFIG_AM33_2
103#define SC2CTR_CK 0x0003 /* clock source select */ 111#define SC2CTR_CK 0x0003 /* clock source select */
104#define SC2CTR_CK_TM10UFLOW 0x0000 /* - timer 10 underflow */ 112#define SC2CTR_CK_TM10UFLOW 0x0000 /* - timer 10 underflow */
105#define SC2CTR_CK_TM2UFLOW 0x0001 /* - timer 2 underflow */ 113#define SC2CTR_CK_TM2UFLOW 0x0001 /* - timer 2 underflow */
106#define SC2CTR_CK_EXTERN 0x0002 /* - external closk */ 114#define SC2CTR_CK_EXTERN 0x0002 /* - external closk */
107#define SC2CTR_CK_TM3UFLOW 0x0003 /* - timer 3 underflow */ 115#define SC2CTR_CK_TM3UFLOW 0x0003 /* - timer 3 underflow */
116#else /* CONFIG_AM33_2 */
117#define SC2CTR_CK 0x0007 /* clock source select */
118#define SC2CTR_CK_TM9UFLOW_8 0x0000 /* - 1/8 timer 9 underflow */
119#define SC2CTR_CK_IOCLK_8 0x0001 /* - 1/8 IOCLK */
120#define SC2CTR_CK_IOCLK_32 0x0002 /* - 1/32 IOCLK */
121#define SC2CTR_CK_TM3UFLOW_2 0x0003 /* - 1/2 timer 3 underflow */
122#define SC2CTR_CK_TM1UFLOW_8 0x0004 /* - 1/8 timer 1 underflow */
123#define SC2CTR_CK_TM3UFLOW_8 0x0005 /* - 1/8 timer 3 underflow */
124#define SC2CTR_CK_EXTERN_8 0x0006 /* - 1/8 external closk */
125#define SC2CTR_CK_EXTERN 0x0007 /* - external closk */
126#endif /* CONFIG_AM33_2 */
108#define SC2CTR_STB 0x0008 /* stop bit select */ 127#define SC2CTR_STB 0x0008 /* stop bit select */
109#define SC2CTR_STB_1BIT 0x0000 /* - 1 stop bit */ 128#define SC2CTR_STB_1BIT 0x0000 /* - 1 stop bit */
110#define SC2CTR_STB_2BIT 0x0008 /* - 2 stop bits */ 129#define SC2CTR_STB_2BIT 0x0008 /* - 2 stop bits */
@@ -134,9 +153,14 @@
134#define SC2ICR_RES 0x04 /* receive error select */ 153#define SC2ICR_RES 0x04 /* receive error select */
135#define SC2ICR_RI 0x01 /* receive interrupt cause */ 154#define SC2ICR_RI 0x01 /* receive interrupt cause */
136 155
137#define SC2TXB __SYSREG(0xd4002018, u8) /* transmit buffer reg */ 156#define SC2TXB __SYSREG(0xd4002028, u8) /* transmit buffer reg */
138#define SC2RXB __SYSREG(0xd4002019, u8) /* receive buffer reg */ 157#define SC2RXB __SYSREG(0xd4002029, u8) /* receive buffer reg */
139#define SC2STR __SYSREG(0xd400201c, u8) /* status reg */ 158
159#ifdef CONFIG_AM33_2
160#define SC2STR __SYSREG(0xd400202c, u8) /* status reg */
161#else /* CONFIG_AM33_2 */
162#define SC2STR __SYSREG(0xd400202c, u16) /* status reg */
163#endif /* CONFIG_AM33_2 */
140#define SC2STR_OEF 0x0001 /* overrun error found */ 164#define SC2STR_OEF 0x0001 /* overrun error found */
141#define SC2STR_PEF 0x0002 /* parity error found */ 165#define SC2STR_PEF 0x0002 /* parity error found */
142#define SC2STR_FEF 0x0004 /* framing error found */ 166#define SC2STR_FEF 0x0004 /* framing error found */
@@ -146,10 +170,17 @@
146#define SC2STR_RXF 0x0040 /* receive status */ 170#define SC2STR_RXF 0x0040 /* receive status */
147#define SC2STR_TXF 0x0080 /* transmit status */ 171#define SC2STR_TXF 0x0080 /* transmit status */
148 172
173#ifdef CONFIG_AM33_2
149#define SC2TIM __SYSREG(0xd400202d, u8) /* status reg */ 174#define SC2TIM __SYSREG(0xd400202d, u8) /* status reg */
175#endif
150 176
177#ifdef CONFIG_AM33_2
151#define SC2RXIRQ 24 /* serial 2 Receive IRQ */ 178#define SC2RXIRQ 24 /* serial 2 Receive IRQ */
152#define SC2TXIRQ 25 /* serial 2 Transmit IRQ */ 179#define SC2TXIRQ 25 /* serial 2 Transmit IRQ */
180#else /* CONFIG_AM33_2 */
181#define SC2RXIRQ 68 /* serial 2 Receive IRQ */
182#define SC2TXIRQ 69 /* serial 2 Transmit IRQ */
183#endif /* CONFIG_AM33_2 */
153 184
154#define SC2RXICR GxICR(SC2RXIRQ) /* serial 2 receive intr ctrl reg */ 185#define SC2RXICR GxICR(SC2RXIRQ) /* serial 2 receive intr ctrl reg */
155#define SC2TXICR GxICR(SC2TXIRQ) /* serial 2 transmit intr ctrl reg */ 186#define SC2TXICR GxICR(SC2TXIRQ) /* serial 2 transmit intr ctrl reg */
diff --git a/arch/mn10300/include/asm/serial.h b/arch/mn10300/include/asm/serial.h
index a29445cddd6f..23a799293599 100644
--- a/arch/mn10300/include/asm/serial.h
+++ b/arch/mn10300/include/asm/serial.h
@@ -9,10 +9,8 @@
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11 11
12/* 12#ifndef _ASM_SERIAL_H
13 * The ASB2305 has an 18.432 MHz clock the UART 13#define _ASM_SERIAL_H
14 */
15#define BASE_BAUD (18432000 / 16)
16 14
17/* Standard COM flags (except for COM4, because of the 8514 problem) */ 15/* Standard COM flags (except for COM4, because of the 8514 problem) */
18#ifdef CONFIG_SERIAL_DETECT_IRQ 16#ifdef CONFIG_SERIAL_DETECT_IRQ
@@ -34,3 +32,5 @@
34#endif 32#endif
35 33
36#include <unit/serial.h> 34#include <unit/serial.h>
35
36#endif /* _ASM_SERIAL_H */
diff --git a/arch/mn10300/include/asm/smp.h b/arch/mn10300/include/asm/smp.h
index 4eb8c61b7dab..a3930e43a958 100644
--- a/arch/mn10300/include/asm/smp.h
+++ b/arch/mn10300/include/asm/smp.h
@@ -3,6 +3,16 @@
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * Modified by Matsushita Electric Industrial Co., Ltd.
7 * Modifications:
8 * 13-Nov-2006 MEI Define IPI-IRQ number and add inline/macro function
9 * for SMP support.
10 * 22-Jan-2007 MEI Add the define related to SMP_BOOT_IRQ.
11 * 23-Feb-2007 MEI Add the define related to SMP icahce invalidate.
12 * 23-Jun-2008 MEI Delete INTC_IPI.
13 * 22-Jul-2008 MEI Add smp_nmi_call_function and related defines.
14 * 04-Aug-2008 MEI Delete USE_DOIRQ_CACHE_IPI.
15 *
6 * This program is free software; you can redistribute it and/or 16 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence 17 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version 18 * as published by the Free Software Foundation; either version
@@ -11,8 +21,85 @@
11#ifndef _ASM_SMP_H 21#ifndef _ASM_SMP_H
12#define _ASM_SMP_H 22#define _ASM_SMP_H
13 23
14#ifdef CONFIG_SMP 24#ifndef __ASSEMBLY__
15#error SMP not yet supported for MN10300 25#include <linux/threads.h>
26#include <linux/cpumask.h>
16#endif 27#endif
17 28
29#ifdef CONFIG_SMP
30#include <proc/smp-regs.h>
31
32#define RESCHEDULE_IPI 63
33#define CALL_FUNC_SINGLE_IPI 192
34#define LOCAL_TIMER_IPI 193
35#define FLUSH_CACHE_IPI 194
36#define CALL_FUNCTION_NMI_IPI 195
37#define GDB_NMI_IPI 196
38
39#define SMP_BOOT_IRQ 195
40
41#define RESCHEDULE_GxICR_LV GxICR_LEVEL_6
42#define CALL_FUNCTION_GxICR_LV GxICR_LEVEL_4
43#define LOCAL_TIMER_GxICR_LV GxICR_LEVEL_4
44#define FLUSH_CACHE_GxICR_LV GxICR_LEVEL_0
45#define SMP_BOOT_GxICR_LV GxICR_LEVEL_0
46
47#define TIME_OUT_COUNT_BOOT_IPI 100
48#define DELAY_TIME_BOOT_IPI 75000
49
50
51#ifndef __ASSEMBLY__
52
53/**
54 * raw_smp_processor_id - Determine the raw CPU ID of the CPU running it
55 *
56 * What we really want to do is to use the CPUID hardware CPU register to get
57 * this information, but accesses to that aren't cached, and run at system bus
58 * speed, not CPU speed. A copy of this value is, however, stored in the
59 * thread_info struct, and that can be cached.
60 *
61 * An alternate way of dealing with this could be to use the EPSW.S bits to
62 * cache this information for systems with up to four CPUs.
63 */
64#if 0
65#define raw_smp_processor_id() (CPUID)
66#else
67#define raw_smp_processor_id() (current_thread_info()->cpu)
18#endif 68#endif
69
70static inline int cpu_logical_map(int cpu)
71{
72 return cpu;
73}
74
75static inline int cpu_number_map(int cpu)
76{
77 return cpu;
78}
79
80
81extern cpumask_t cpu_boot_map;
82
83extern void smp_init_cpus(void);
84extern void smp_cache_interrupt(void);
85extern void send_IPI_allbutself(int irq);
86extern int smp_nmi_call_function(smp_call_func_t func, void *info, int wait);
87
88extern void arch_send_call_function_single_ipi(int cpu);
89extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
90
91#ifdef CONFIG_HOTPLUG_CPU
92extern int __cpu_disable(void);
93extern void __cpu_die(unsigned int cpu);
94#endif /* CONFIG_HOTPLUG_CPU */
95
96#endif /* __ASSEMBLY__ */
97#else /* CONFIG_SMP */
98#ifndef __ASSEMBLY__
99
100static inline void smp_init_cpus(void) {}
101
102#endif /* __ASSEMBLY__ */
103#endif /* CONFIG_SMP */
104
105#endif /* _ASM_SMP_H */
diff --git a/arch/mn10300/include/asm/smsc911x.h b/arch/mn10300/include/asm/smsc911x.h
new file mode 100644
index 000000000000..2fcd1080322b
--- /dev/null
+++ b/arch/mn10300/include/asm/smsc911x.h
@@ -0,0 +1 @@
#include <unit/smsc911x.h>
diff --git a/arch/mn10300/include/asm/spinlock.h b/arch/mn10300/include/asm/spinlock.h
index 4bf9c8b169e0..93429154e898 100644
--- a/arch/mn10300/include/asm/spinlock.h
+++ b/arch/mn10300/include/asm/spinlock.h
@@ -11,6 +11,183 @@
11#ifndef _ASM_SPINLOCK_H 11#ifndef _ASM_SPINLOCK_H
12#define _ASM_SPINLOCK_H 12#define _ASM_SPINLOCK_H
13 13
14#error SMP spinlocks not implemented for MN10300 14#include <asm/atomic.h>
15#include <asm/rwlock.h>
16#include <asm/page.h>
15 17
18/*
19 * Simple spin lock operations. There are two variants, one clears IRQ's
20 * on the local processor, one does not.
21 *
22 * We make no fairness assumptions. They have a cost.
23 */
24
25#define arch_spin_is_locked(x) (*(volatile signed char *)(&(x)->slock) != 0)
26#define arch_spin_unlock_wait(x) do { barrier(); } while (arch_spin_is_locked(x))
27
28static inline void arch_spin_unlock(arch_spinlock_t *lock)
29{
30 asm volatile(
31 " bclr 1,(0,%0) \n"
32 :
33 : "a"(&lock->slock)
34 : "memory", "cc");
35}
36
37static inline int arch_spin_trylock(arch_spinlock_t *lock)
38{
39 int ret;
40
41 asm volatile(
42 " mov 1,%0 \n"
43 " bset %0,(%1) \n"
44 " bne 1f \n"
45 " clr %0 \n"
46 "1: xor 1,%0 \n"
47 : "=d"(ret)
48 : "a"(&lock->slock)
49 : "memory", "cc");
50
51 return ret;
52}
53
54static inline void arch_spin_lock(arch_spinlock_t *lock)
55{
56 asm volatile(
57 "1: bset 1,(0,%0) \n"
58 " bne 1b \n"
59 :
60 : "a"(&lock->slock)
61 : "memory", "cc");
62}
63
64static inline void arch_spin_lock_flags(arch_spinlock_t *lock,
65 unsigned long flags)
66{
67 int temp;
68
69 asm volatile(
70 "1: bset 1,(0,%2) \n"
71 " beq 3f \n"
72 " mov %1,epsw \n"
73 "2: mov (0,%2),%0 \n"
74 " or %0,%0 \n"
75 " bne 2b \n"
76 " mov %3,%0 \n"
77 " mov %0,epsw \n"
78 " nop \n"
79 " nop \n"
80 " bra 1b\n"
81 "3: \n"
82 : "=&d" (temp)
83 : "d" (flags), "a"(&lock->slock), "i"(EPSW_IE | MN10300_CLI_LEVEL)
84 : "memory", "cc");
85}
86
87#ifdef __KERNEL__
88
89/*
90 * Read-write spinlocks, allowing multiple readers
91 * but only one writer.
92 *
93 * NOTE! it is quite common to have readers in interrupts
94 * but no interrupt writers. For those circumstances we
95 * can "mix" irq-safe locks - any writer needs to get a
96 * irq-safe write-lock, but readers can get non-irqsafe
97 * read-locks.
98 */
99
100/**
101 * read_can_lock - would read_trylock() succeed?
102 * @lock: the rwlock in question.
103 */
104#define arch_read_can_lock(x) ((int)(x)->lock > 0)
105
106/**
107 * write_can_lock - would write_trylock() succeed?
108 * @lock: the rwlock in question.
109 */
110#define arch_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS)
111
112/*
113 * On mn10300, we implement read-write locks as a 32-bit counter
114 * with the high bit (sign) being the "contended" bit.
115 */
116static inline void arch_read_lock(arch_rwlock_t *rw)
117{
118#if 0 //def CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
119 __build_read_lock(rw, "__read_lock_failed");
120#else
121 {
122 atomic_t *count = (atomic_t *)rw;
123 while (atomic_dec_return(count) < 0)
124 atomic_inc(count);
125 }
126#endif
127}
128
129static inline void arch_write_lock(arch_rwlock_t *rw)
130{
131#if 0 //def CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
132 __build_write_lock(rw, "__write_lock_failed");
133#else
134 {
135 atomic_t *count = (atomic_t *)rw;
136 while (!atomic_sub_and_test(RW_LOCK_BIAS, count))
137 atomic_add(RW_LOCK_BIAS, count);
138 }
139#endif
140}
141
142static inline void arch_read_unlock(arch_rwlock_t *rw)
143{
144#if 0 //def CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
145 __build_read_unlock(rw);
146#else
147 {
148 atomic_t *count = (atomic_t *)rw;
149 atomic_inc(count);
150 }
151#endif
152}
153
154static inline void arch_write_unlock(arch_rwlock_t *rw)
155{
156#if 0 //def CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
157 __build_write_unlock(rw);
158#else
159 {
160 atomic_t *count = (atomic_t *)rw;
161 atomic_add(RW_LOCK_BIAS, count);
162 }
163#endif
164}
165
166static inline int arch_read_trylock(arch_rwlock_t *lock)
167{
168 atomic_t *count = (atomic_t *)lock;
169 atomic_dec(count);
170 if (atomic_read(count) >= 0)
171 return 1;
172 atomic_inc(count);
173 return 0;
174}
175
176static inline int arch_write_trylock(arch_rwlock_t *lock)
177{
178 atomic_t *count = (atomic_t *)lock;
179 if (atomic_sub_and_test(RW_LOCK_BIAS, count))
180 return 1;
181 atomic_add(RW_LOCK_BIAS, count);
182 return 0;
183}
184
185#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
186#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
187
188#define _raw_spin_relax(lock) cpu_relax()
189#define _raw_read_relax(lock) cpu_relax()
190#define _raw_write_relax(lock) cpu_relax()
191
192#endif /* __KERNEL__ */
16#endif /* _ASM_SPINLOCK_H */ 193#endif /* _ASM_SPINLOCK_H */
diff --git a/arch/mn10300/include/asm/spinlock_types.h b/arch/mn10300/include/asm/spinlock_types.h
new file mode 100644
index 000000000000..653dc519b405
--- /dev/null
+++ b/arch/mn10300/include/asm/spinlock_types.h
@@ -0,0 +1,20 @@
1#ifndef _ASM_SPINLOCK_TYPES_H
2#define _ASM_SPINLOCK_TYPES_H
3
4#ifndef __LINUX_SPINLOCK_TYPES_H
5# error "please don't include this file directly"
6#endif
7
8typedef struct arch_spinlock {
9 unsigned int slock;
10} arch_spinlock_t;
11
12#define __ARCH_SPIN_LOCK_UNLOCKED { 0 }
13
14typedef struct {
15 unsigned int lock;
16} arch_rwlock_t;
17
18#define __ARCH_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
19
20#endif /* _ASM_SPINLOCK_TYPES_H */
diff --git a/arch/mn10300/include/asm/system.h b/arch/mn10300/include/asm/system.h
index 9f7c7e17c01e..8ff3e5aaca41 100644
--- a/arch/mn10300/include/asm/system.h
+++ b/arch/mn10300/include/asm/system.h
@@ -12,12 +12,29 @@
12#define _ASM_SYSTEM_H 12#define _ASM_SYSTEM_H
13 13
14#include <asm/cpu-regs.h> 14#include <asm/cpu-regs.h>
15#include <asm/intctl-regs.h>
15 16
16#ifdef __KERNEL__ 17#ifdef __KERNEL__
17#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
18 19
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/irqflags.h> 21#include <linux/irqflags.h>
22#include <asm/atomic.h>
23
24#if !defined(CONFIG_LAZY_SAVE_FPU)
25struct fpu_state_struct;
26extern asmlinkage void fpu_save(struct fpu_state_struct *);
27#define switch_fpu(prev, next) \
28 do { \
29 if ((prev)->thread.fpu_flags & THREAD_HAS_FPU) { \
30 (prev)->thread.fpu_flags &= ~THREAD_HAS_FPU; \
31 (prev)->thread.uregs->epsw &= ~EPSW_FE; \
32 fpu_save(&(prev)->thread.fpu_state); \
33 } \
34 } while (0)
35#else
36#define switch_fpu(prev, next) do {} while (0)
37#endif
21 38
22struct task_struct; 39struct task_struct;
23struct thread_struct; 40struct thread_struct;
@@ -30,6 +47,7 @@ struct task_struct *__switch_to(struct thread_struct *prev,
30/* context switching is now performed out-of-line in switch_to.S */ 47/* context switching is now performed out-of-line in switch_to.S */
31#define switch_to(prev, next, last) \ 48#define switch_to(prev, next, last) \
32do { \ 49do { \
50 switch_fpu(prev, next); \
33 current->thread.wchan = (u_long) __builtin_return_address(0); \ 51 current->thread.wchan = (u_long) __builtin_return_address(0); \
34 (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \ 52 (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \
35 mb(); \ 53 mb(); \
@@ -40,8 +58,6 @@ do { \
40 58
41#define nop() asm volatile ("nop") 59#define nop() asm volatile ("nop")
42 60
43#endif /* !__ASSEMBLY__ */
44
45/* 61/*
46 * Force strict CPU ordering. 62 * Force strict CPU ordering.
47 * And yes, this is required on UP too when we're talking 63 * And yes, this is required on UP too when we're talking
@@ -68,64 +84,19 @@ do { \
68#define smp_mb() mb() 84#define smp_mb() mb()
69#define smp_rmb() rmb() 85#define smp_rmb() rmb()
70#define smp_wmb() wmb() 86#define smp_wmb() wmb()
71#else 87#define set_mb(var, value) do { xchg(&var, value); } while (0)
88#else /* CONFIG_SMP */
72#define smp_mb() barrier() 89#define smp_mb() barrier()
73#define smp_rmb() barrier() 90#define smp_rmb() barrier()
74#define smp_wmb() barrier() 91#define smp_wmb() barrier()
75#endif
76
77#define set_mb(var, value) do { var = value; mb(); } while (0) 92#define set_mb(var, value) do { var = value; mb(); } while (0)
93#endif /* CONFIG_SMP */
94
78#define set_wmb(var, value) do { var = value; wmb(); } while (0) 95#define set_wmb(var, value) do { var = value; wmb(); } while (0)
79 96
80#define read_barrier_depends() do {} while (0) 97#define read_barrier_depends() do {} while (0)
81#define smp_read_barrier_depends() do {} while (0) 98#define smp_read_barrier_depends() do {} while (0)
82 99
83/*****************************************************************************/
84/*
85 * MN10300 doesn't actually have an exchange instruction
86 */
87#ifndef __ASSEMBLY__
88
89struct __xchg_dummy { unsigned long a[100]; };
90#define __xg(x) ((struct __xchg_dummy *)(x))
91
92static inline
93unsigned long __xchg(volatile unsigned long *m, unsigned long val)
94{
95 unsigned long retval;
96 unsigned long flags;
97
98 local_irq_save(flags);
99 retval = *m;
100 *m = val;
101 local_irq_restore(flags);
102 return retval;
103}
104
105#define xchg(ptr, v) \
106 ((__typeof__(*(ptr))) __xchg((unsigned long *)(ptr), \
107 (unsigned long)(v)))
108
109static inline unsigned long __cmpxchg(volatile unsigned long *m,
110 unsigned long old, unsigned long new)
111{
112 unsigned long retval;
113 unsigned long flags;
114
115 local_irq_save(flags);
116 retval = *m;
117 if (retval == old)
118 *m = new;
119 local_irq_restore(flags);
120 return retval;
121}
122
123#define cmpxchg(ptr, o, n) \
124 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
125 (unsigned long)(o), \
126 (unsigned long)(n)))
127
128#endif /* !__ASSEMBLY__ */ 100#endif /* !__ASSEMBLY__ */
129
130#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
131#endif /* _ASM_SYSTEM_H */ 102#endif /* _ASM_SYSTEM_H */
diff --git a/arch/mn10300/include/asm/thread_info.h b/arch/mn10300/include/asm/thread_info.h
index 2001cb657a95..aa07a4a5d794 100644
--- a/arch/mn10300/include/asm/thread_info.h
+++ b/arch/mn10300/include/asm/thread_info.h
@@ -16,10 +16,6 @@
16 16
17#include <asm/page.h> 17#include <asm/page.h>
18 18
19#ifndef __ASSEMBLY__
20#include <asm/processor.h>
21#endif
22
23#define PREEMPT_ACTIVE 0x10000000 19#define PREEMPT_ACTIVE 0x10000000
24 20
25#ifdef CONFIG_4KSTACKS 21#ifdef CONFIG_4KSTACKS
@@ -38,10 +34,14 @@
38 * must also be changed 34 * must also be changed
39 */ 35 */
40#ifndef __ASSEMBLY__ 36#ifndef __ASSEMBLY__
37typedef struct {
38 unsigned long seg;
39} mm_segment_t;
41 40
42struct thread_info { 41struct thread_info {
43 struct task_struct *task; /* main task structure */ 42 struct task_struct *task; /* main task structure */
44 struct exec_domain *exec_domain; /* execution domain */ 43 struct exec_domain *exec_domain; /* execution domain */
44 struct pt_regs *frame; /* current exception frame */
45 unsigned long flags; /* low level flags */ 45 unsigned long flags; /* low level flags */
46 __u32 cpu; /* current CPU */ 46 __u32 cpu; /* current CPU */
47 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 47 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
@@ -55,6 +55,10 @@ struct thread_info {
55 __u8 supervisor_stack[0]; 55 __u8 supervisor_stack[0];
56}; 56};
57 57
58#define thread_info_to_uregs(ti) \
59 ((struct pt_regs *) \
60 ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
61
58#else /* !__ASSEMBLY__ */ 62#else /* !__ASSEMBLY__ */
59 63
60#ifndef __ASM_OFFSETS_H__ 64#ifndef __ASM_OFFSETS_H__
@@ -102,6 +106,12 @@ struct thread_info *current_thread_info(void)
102 return ti; 106 return ti;
103} 107}
104 108
109static inline __attribute__((const))
110struct pt_regs *current_frame(void)
111{
112 return current_thread_info()->frame;
113}
114
105/* how to get the current stack pointer from C */ 115/* how to get the current stack pointer from C */
106static inline unsigned long current_stack_pointer(void) 116static inline unsigned long current_stack_pointer(void)
107{ 117{
diff --git a/arch/mn10300/include/asm/timer-regs.h b/arch/mn10300/include/asm/timer-regs.h
index 1d883b7f94ab..c634977caf66 100644
--- a/arch/mn10300/include/asm/timer-regs.h
+++ b/arch/mn10300/include/asm/timer-regs.h
@@ -17,21 +17,27 @@
17 17
18#ifdef __KERNEL__ 18#ifdef __KERNEL__
19 19
20/* timer prescalar control */ 20/*
21 * Timer prescalar control
22 */
21#define TMPSCNT __SYSREG(0xd4003071, u8) /* timer prescaler control */ 23#define TMPSCNT __SYSREG(0xd4003071, u8) /* timer prescaler control */
22#define TMPSCNT_ENABLE 0x80 /* timer prescaler enable */ 24#define TMPSCNT_ENABLE 0x80 /* timer prescaler enable */
23#define TMPSCNT_DISABLE 0x00 /* timer prescaler disable */ 25#define TMPSCNT_DISABLE 0x00 /* timer prescaler disable */
24 26
25/* 8 bit timers */ 27/*
28 * 8-bit timers
29 */
26#define TM0MD __SYSREG(0xd4003000, u8) /* timer 0 mode register */ 30#define TM0MD __SYSREG(0xd4003000, u8) /* timer 0 mode register */
27#define TM0MD_SRC 0x07 /* timer source */ 31#define TM0MD_SRC 0x07 /* timer source */
28#define TM0MD_SRC_IOCLK 0x00 /* - IOCLK */ 32#define TM0MD_SRC_IOCLK 0x00 /* - IOCLK */
29#define TM0MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */ 33#define TM0MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
30#define TM0MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */ 34#define TM0MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
31#define TM0MD_SRC_TM2IO 0x03 /* - TM2IO pin input */
32#define TM0MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 35#define TM0MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
33#define TM0MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 36#define TM0MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
37#if defined(CONFIG_AM33_2)
38#define TM0MD_SRC_TM2IO 0x03 /* - TM2IO pin input */
34#define TM0MD_SRC_TM0IO 0x07 /* - TM0IO pin input */ 39#define TM0MD_SRC_TM0IO 0x07 /* - TM0IO pin input */
40#endif /* CONFIG_AM33_2 */
35#define TM0MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 41#define TM0MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
36#define TM0MD_COUNT_ENABLE 0x80 /* timer count enable */ 42#define TM0MD_COUNT_ENABLE 0x80 /* timer count enable */
37 43
@@ -43,7 +49,9 @@
43#define TM1MD_SRC_TM0CASCADE 0x03 /* - cascade with timer 0 */ 49#define TM1MD_SRC_TM0CASCADE 0x03 /* - cascade with timer 0 */
44#define TM1MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 50#define TM1MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
45#define TM1MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 51#define TM1MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
52#if defined(CONFIG_AM33_2)
46#define TM1MD_SRC_TM1IO 0x07 /* - TM1IO pin input */ 53#define TM1MD_SRC_TM1IO 0x07 /* - TM1IO pin input */
54#endif /* CONFIG_AM33_2 */
47#define TM1MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 55#define TM1MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
48#define TM1MD_COUNT_ENABLE 0x80 /* timer count enable */ 56#define TM1MD_COUNT_ENABLE 0x80 /* timer count enable */
49 57
@@ -55,7 +63,9 @@
55#define TM2MD_SRC_TM1CASCADE 0x03 /* - cascade with timer 1 */ 63#define TM2MD_SRC_TM1CASCADE 0x03 /* - cascade with timer 1 */
56#define TM2MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 64#define TM2MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
57#define TM2MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 65#define TM2MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
66#if defined(CONFIG_AM33_2)
58#define TM2MD_SRC_TM2IO 0x07 /* - TM2IO pin input */ 67#define TM2MD_SRC_TM2IO 0x07 /* - TM2IO pin input */
68#endif /* CONFIG_AM33_2 */
59#define TM2MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 69#define TM2MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
60#define TM2MD_COUNT_ENABLE 0x80 /* timer count enable */ 70#define TM2MD_COUNT_ENABLE 0x80 /* timer count enable */
61 71
@@ -64,11 +74,13 @@
64#define TM3MD_SRC_IOCLK 0x00 /* - IOCLK */ 74#define TM3MD_SRC_IOCLK 0x00 /* - IOCLK */
65#define TM3MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */ 75#define TM3MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
66#define TM3MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */ 76#define TM3MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
67#define TM3MD_SRC_TM1CASCADE 0x03 /* - cascade with timer 2 */ 77#define TM3MD_SRC_TM2CASCADE 0x03 /* - cascade with timer 2 */
68#define TM3MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 78#define TM3MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
69#define TM3MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 79#define TM3MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
70#define TM3MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 80#define TM3MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
81#if defined(CONFIG_AM33_2)
71#define TM3MD_SRC_TM3IO 0x07 /* - TM3IO pin input */ 82#define TM3MD_SRC_TM3IO 0x07 /* - TM3IO pin input */
83#endif /* CONFIG_AM33_2 */
72#define TM3MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 84#define TM3MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
73#define TM3MD_COUNT_ENABLE 0x80 /* timer count enable */ 85#define TM3MD_COUNT_ENABLE 0x80 /* timer count enable */
74 86
@@ -96,7 +108,9 @@
96#define TM2ICR GxICR(TM2IRQ) /* timer 2 uflow intr ctrl reg */ 108#define TM2ICR GxICR(TM2IRQ) /* timer 2 uflow intr ctrl reg */
97#define TM3ICR GxICR(TM3IRQ) /* timer 3 uflow intr ctrl reg */ 109#define TM3ICR GxICR(TM3IRQ) /* timer 3 uflow intr ctrl reg */
98 110
99/* 16-bit timers 4,5 & 7-11 */ 111/*
112 * 16-bit timers 4,5 & 7-15
113 */
100#define TM4MD __SYSREG(0xd4003080, u8) /* timer 4 mode register */ 114#define TM4MD __SYSREG(0xd4003080, u8) /* timer 4 mode register */
101#define TM4MD_SRC 0x07 /* timer source */ 115#define TM4MD_SRC 0x07 /* timer source */
102#define TM4MD_SRC_IOCLK 0x00 /* - IOCLK */ 116#define TM4MD_SRC_IOCLK 0x00 /* - IOCLK */
@@ -105,7 +119,9 @@
105#define TM4MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 119#define TM4MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
106#define TM4MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 120#define TM4MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
107#define TM4MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 121#define TM4MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
122#if defined(CONFIG_AM33_2)
108#define TM4MD_SRC_TM4IO 0x07 /* - TM4IO pin input */ 123#define TM4MD_SRC_TM4IO 0x07 /* - TM4IO pin input */
124#endif /* CONFIG_AM33_2 */
109#define TM4MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 125#define TM4MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
110#define TM4MD_COUNT_ENABLE 0x80 /* timer count enable */ 126#define TM4MD_COUNT_ENABLE 0x80 /* timer count enable */
111 127
@@ -118,7 +134,11 @@
118#define TM5MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 134#define TM5MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
119#define TM5MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 135#define TM5MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
120#define TM5MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 136#define TM5MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
137#if defined(CONFIG_AM33_2)
121#define TM5MD_SRC_TM5IO 0x07 /* - TM5IO pin input */ 138#define TM5MD_SRC_TM5IO 0x07 /* - TM5IO pin input */
139#else /* !CONFIG_AM33_2 */
140#define TM5MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
141#endif /* CONFIG_AM33_2 */
122#define TM5MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 142#define TM5MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
123#define TM5MD_COUNT_ENABLE 0x80 /* timer count enable */ 143#define TM5MD_COUNT_ENABLE 0x80 /* timer count enable */
124 144
@@ -130,7 +150,9 @@
130#define TM7MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 150#define TM7MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
131#define TM7MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 151#define TM7MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
132#define TM7MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 152#define TM7MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
153#if defined(CONFIG_AM33_2)
133#define TM7MD_SRC_TM7IO 0x07 /* - TM7IO pin input */ 154#define TM7MD_SRC_TM7IO 0x07 /* - TM7IO pin input */
155#endif /* CONFIG_AM33_2 */
134#define TM7MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 156#define TM7MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
135#define TM7MD_COUNT_ENABLE 0x80 /* timer count enable */ 157#define TM7MD_COUNT_ENABLE 0x80 /* timer count enable */
136 158
@@ -143,7 +165,11 @@
143#define TM8MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 165#define TM8MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
144#define TM8MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 166#define TM8MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
145#define TM8MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 167#define TM8MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
168#if defined(CONFIG_AM33_2)
146#define TM8MD_SRC_TM8IO 0x07 /* - TM8IO pin input */ 169#define TM8MD_SRC_TM8IO 0x07 /* - TM8IO pin input */
170#else /* !CONFIG_AM33_2 */
171#define TM8MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
172#endif /* CONFIG_AM33_2 */
147#define TM8MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 173#define TM8MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
148#define TM8MD_COUNT_ENABLE 0x80 /* timer count enable */ 174#define TM8MD_COUNT_ENABLE 0x80 /* timer count enable */
149 175
@@ -156,7 +182,11 @@
156#define TM9MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 182#define TM9MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
157#define TM9MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 183#define TM9MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
158#define TM9MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 184#define TM9MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
185#if defined(CONFIG_AM33_2)
159#define TM9MD_SRC_TM9IO 0x07 /* - TM9IO pin input */ 186#define TM9MD_SRC_TM9IO 0x07 /* - TM9IO pin input */
187#else /* !CONFIG_AM33_2 */
188#define TM9MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
189#endif /* CONFIG_AM33_2 */
160#define TM9MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 190#define TM9MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
161#define TM9MD_COUNT_ENABLE 0x80 /* timer count enable */ 191#define TM9MD_COUNT_ENABLE 0x80 /* timer count enable */
162 192
@@ -169,7 +199,11 @@
169#define TM10MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 199#define TM10MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
170#define TM10MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 200#define TM10MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
171#define TM10MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 201#define TM10MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
202#if defined(CONFIG_AM33_2)
172#define TM10MD_SRC_TM10IO 0x07 /* - TM10IO pin input */ 203#define TM10MD_SRC_TM10IO 0x07 /* - TM10IO pin input */
204#else /* !CONFIG_AM33_2 */
205#define TM10MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
206#endif /* CONFIG_AM33_2 */
173#define TM10MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 207#define TM10MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
174#define TM10MD_COUNT_ENABLE 0x80 /* timer count enable */ 208#define TM10MD_COUNT_ENABLE 0x80 /* timer count enable */
175 209
@@ -178,32 +212,101 @@
178#define TM11MD_SRC_IOCLK 0x00 /* - IOCLK */ 212#define TM11MD_SRC_IOCLK 0x00 /* - IOCLK */
179#define TM11MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */ 213#define TM11MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
180#define TM11MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */ 214#define TM11MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
181#define TM11MD_SRC_TM7CASCADE 0x03 /* - cascade with timer 7 */
182#define TM11MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */ 215#define TM11MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
183#define TM11MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */ 216#define TM11MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
184#define TM11MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */ 217#define TM11MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
218#if defined(CONFIG_AM33_2)
185#define TM11MD_SRC_TM11IO 0x07 /* - TM11IO pin input */ 219#define TM11MD_SRC_TM11IO 0x07 /* - TM11IO pin input */
220#else /* !CONFIG_AM33_2 */
221#define TM11MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
222#endif /* CONFIG_AM33_2 */
186#define TM11MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */ 223#define TM11MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
187#define TM11MD_COUNT_ENABLE 0x80 /* timer count enable */ 224#define TM11MD_COUNT_ENABLE 0x80 /* timer count enable */
188 225
226#if defined(CONFIG_AM34_2)
227#define TM12MD __SYSREG(0xd4003180, u8) /* timer 11 mode register */
228#define TM12MD_SRC 0x07 /* timer source */
229#define TM12MD_SRC_IOCLK 0x00 /* - IOCLK */
230#define TM12MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
231#define TM12MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
232#define TM12MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
233#define TM12MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
234#define TM12MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
235#define TM12MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
236#define TM12MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
237#define TM12MD_COUNT_ENABLE 0x80 /* timer count enable */
238
239#define TM13MD __SYSREG(0xd4003182, u8) /* timer 11 mode register */
240#define TM13MD_SRC 0x07 /* timer source */
241#define TM13MD_SRC_IOCLK 0x00 /* - IOCLK */
242#define TM13MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
243#define TM13MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
244#define TM13MD_SRC_TM12CASCADE 0x03 /* - cascade with timer 12 */
245#define TM13MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
246#define TM13MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
247#define TM13MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
248#define TM13MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
249#define TM13MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
250#define TM13MD_COUNT_ENABLE 0x80 /* timer count enable */
251
252#define TM14MD __SYSREG(0xd4003184, u8) /* timer 11 mode register */
253#define TM14MD_SRC 0x07 /* timer source */
254#define TM14MD_SRC_IOCLK 0x00 /* - IOCLK */
255#define TM14MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
256#define TM14MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
257#define TM14MD_SRC_TM13CASCADE 0x03 /* - cascade with timer 13 */
258#define TM14MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
259#define TM14MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
260#define TM14MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
261#define TM14MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
262#define TM14MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
263#define TM14MD_COUNT_ENABLE 0x80 /* timer count enable */
264
265#define TM15MD __SYSREG(0xd4003186, u8) /* timer 11 mode register */
266#define TM15MD_SRC 0x07 /* timer source */
267#define TM15MD_SRC_IOCLK 0x00 /* - IOCLK */
268#define TM15MD_SRC_IOCLK_8 0x01 /* - 1/8 IOCLK */
269#define TM15MD_SRC_IOCLK_32 0x02 /* - 1/32 IOCLK */
270#define TM15MD_SRC_TM0UFLOW 0x04 /* - timer 0 underflow */
271#define TM15MD_SRC_TM1UFLOW 0x05 /* - timer 1 underflow */
272#define TM15MD_SRC_TM2UFLOW 0x06 /* - timer 2 underflow */
273#define TM15MD_SRC_TM7UFLOW 0x07 /* - timer 7 underflow */
274#define TM15MD_INIT_COUNTER 0x40 /* initialize TMnBC = TMnBR */
275#define TM15MD_COUNT_ENABLE 0x80 /* timer count enable */
276#endif /* CONFIG_AM34_2 */
277
278
189#define TM4BR __SYSREG(0xd4003090, u16) /* timer 4 base register */ 279#define TM4BR __SYSREG(0xd4003090, u16) /* timer 4 base register */
190#define TM5BR __SYSREG(0xd4003092, u16) /* timer 5 base register */ 280#define TM5BR __SYSREG(0xd4003092, u16) /* timer 5 base register */
281#define TM45BR __SYSREG(0xd4003090, u32) /* timer 4:5 base register */
191#define TM7BR __SYSREG(0xd4003096, u16) /* timer 7 base register */ 282#define TM7BR __SYSREG(0xd4003096, u16) /* timer 7 base register */
192#define TM8BR __SYSREG(0xd4003098, u16) /* timer 8 base register */ 283#define TM8BR __SYSREG(0xd4003098, u16) /* timer 8 base register */
193#define TM9BR __SYSREG(0xd400309a, u16) /* timer 9 base register */ 284#define TM9BR __SYSREG(0xd400309a, u16) /* timer 9 base register */
285#define TM89BR __SYSREG(0xd4003098, u32) /* timer 8:9 base register */
194#define TM10BR __SYSREG(0xd400309c, u16) /* timer 10 base register */ 286#define TM10BR __SYSREG(0xd400309c, u16) /* timer 10 base register */
195#define TM11BR __SYSREG(0xd400309e, u16) /* timer 11 base register */ 287#define TM11BR __SYSREG(0xd400309e, u16) /* timer 11 base register */
196#define TM45BR __SYSREG(0xd4003090, u32) /* timer 4:5 base register */ 288#if defined(CONFIG_AM34_2)
289#define TM12BR __SYSREG(0xd4003190, u16) /* timer 12 base register */
290#define TM13BR __SYSREG(0xd4003192, u16) /* timer 13 base register */
291#define TM14BR __SYSREG(0xd4003194, u16) /* timer 14 base register */
292#define TM15BR __SYSREG(0xd4003196, u16) /* timer 15 base register */
293#endif /* CONFIG_AM34_2 */
197 294
198#define TM4BC __SYSREG(0xd40030a0, u16) /* timer 4 binary counter */ 295#define TM4BC __SYSREG(0xd40030a0, u16) /* timer 4 binary counter */
199#define TM5BC __SYSREG(0xd40030a2, u16) /* timer 5 binary counter */ 296#define TM5BC __SYSREG(0xd40030a2, u16) /* timer 5 binary counter */
200#define TM45BC __SYSREG(0xd40030a0, u32) /* timer 4:5 binary counter */ 297#define TM45BC __SYSREG(0xd40030a0, u32) /* timer 4:5 binary counter */
201
202#define TM7BC __SYSREG(0xd40030a6, u16) /* timer 7 binary counter */ 298#define TM7BC __SYSREG(0xd40030a6, u16) /* timer 7 binary counter */
203#define TM8BC __SYSREG(0xd40030a8, u16) /* timer 8 binary counter */ 299#define TM8BC __SYSREG(0xd40030a8, u16) /* timer 8 binary counter */
204#define TM9BC __SYSREG(0xd40030aa, u16) /* timer 9 binary counter */ 300#define TM9BC __SYSREG(0xd40030aa, u16) /* timer 9 binary counter */
301#define TM89BC __SYSREG(0xd40030a8, u32) /* timer 8:9 binary counter */
205#define TM10BC __SYSREG(0xd40030ac, u16) /* timer 10 binary counter */ 302#define TM10BC __SYSREG(0xd40030ac, u16) /* timer 10 binary counter */
206#define TM11BC __SYSREG(0xd40030ae, u16) /* timer 11 binary counter */ 303#define TM11BC __SYSREG(0xd40030ae, u16) /* timer 11 binary counter */
304#if defined(CONFIG_AM34_2)
305#define TM12BC __SYSREG(0xd40031a0, u16) /* timer 12 binary counter */
306#define TM13BC __SYSREG(0xd40031a2, u16) /* timer 13 binary counter */
307#define TM14BC __SYSREG(0xd40031a4, u16) /* timer 14 binary counter */
308#define TM15BC __SYSREG(0xd40031a6, u16) /* timer 15 binary counter */
309#endif /* CONFIG_AM34_2 */
207 310
208#define TM4IRQ 6 /* timer 4 IRQ */ 311#define TM4IRQ 6 /* timer 4 IRQ */
209#define TM5IRQ 7 /* timer 5 IRQ */ 312#define TM5IRQ 7 /* timer 5 IRQ */
@@ -212,6 +315,12 @@
212#define TM9IRQ 13 /* timer 9 IRQ */ 315#define TM9IRQ 13 /* timer 9 IRQ */
213#define TM10IRQ 14 /* timer 10 IRQ */ 316#define TM10IRQ 14 /* timer 10 IRQ */
214#define TM11IRQ 15 /* timer 11 IRQ */ 317#define TM11IRQ 15 /* timer 11 IRQ */
318#if defined(CONFIG_AM34_2)
319#define TM12IRQ 64 /* timer 12 IRQ */
320#define TM13IRQ 65 /* timer 13 IRQ */
321#define TM14IRQ 66 /* timer 14 IRQ */
322#define TM15IRQ 67 /* timer 15 IRQ */
323#endif /* CONFIG_AM34_2 */
215 324
216#define TM4ICR GxICR(TM4IRQ) /* timer 4 uflow intr ctrl reg */ 325#define TM4ICR GxICR(TM4IRQ) /* timer 4 uflow intr ctrl reg */
217#define TM5ICR GxICR(TM5IRQ) /* timer 5 uflow intr ctrl reg */ 326#define TM5ICR GxICR(TM5IRQ) /* timer 5 uflow intr ctrl reg */
@@ -220,8 +329,16 @@
220#define TM9ICR GxICR(TM9IRQ) /* timer 9 uflow intr ctrl reg */ 329#define TM9ICR GxICR(TM9IRQ) /* timer 9 uflow intr ctrl reg */
221#define TM10ICR GxICR(TM10IRQ) /* timer 10 uflow intr ctrl reg */ 330#define TM10ICR GxICR(TM10IRQ) /* timer 10 uflow intr ctrl reg */
222#define TM11ICR GxICR(TM11IRQ) /* timer 11 uflow intr ctrl reg */ 331#define TM11ICR GxICR(TM11IRQ) /* timer 11 uflow intr ctrl reg */
223 332#if defined(CONFIG_AM34_2)
224/* 16-bit timer 6 */ 333#define TM12ICR GxICR(TM12IRQ) /* timer 12 uflow intr ctrl reg */
334#define TM13ICR GxICR(TM13IRQ) /* timer 13 uflow intr ctrl reg */
335#define TM14ICR GxICR(TM14IRQ) /* timer 14 uflow intr ctrl reg */
336#define TM15ICR GxICR(TM15IRQ) /* timer 15 uflow intr ctrl reg */
337#endif /* CONFIG_AM34_2 */
338
339/*
340 * 16-bit timer 6
341 */
225#define TM6MD __SYSREG(0xd4003084, u16) /* timer6 mode register */ 342#define TM6MD __SYSREG(0xd4003084, u16) /* timer6 mode register */
226#define TM6MD_SRC 0x0007 /* timer source */ 343#define TM6MD_SRC 0x0007 /* timer source */
227#define TM6MD_SRC_IOCLK 0x0000 /* - IOCLK */ 344#define TM6MD_SRC_IOCLK 0x0000 /* - IOCLK */
@@ -229,10 +346,14 @@
229#define TM6MD_SRC_IOCLK_32 0x0002 /* - 1/32 IOCLK */ 346#define TM6MD_SRC_IOCLK_32 0x0002 /* - 1/32 IOCLK */
230#define TM6MD_SRC_TM0UFLOW 0x0004 /* - timer 0 underflow */ 347#define TM6MD_SRC_TM0UFLOW 0x0004 /* - timer 0 underflow */
231#define TM6MD_SRC_TM1UFLOW 0x0005 /* - timer 1 underflow */ 348#define TM6MD_SRC_TM1UFLOW 0x0005 /* - timer 1 underflow */
232#define TM6MD_SRC_TM6IOB_BOTH 0x0006 /* - TM6IOB pin input (both edges) */ 349#define TM6MD_SRC_TM2UFLOW 0x0006 /* - timer 2 underflow */
350#if defined(CONFIG_AM33_2)
351/* #define TM6MD_SRC_TM6IOB_BOTH 0x0006 */ /* - TM6IOB pin input (both edges) */
233#define TM6MD_SRC_TM6IOB_SINGLE 0x0007 /* - TM6IOB pin input (single edge) */ 352#define TM6MD_SRC_TM6IOB_SINGLE 0x0007 /* - TM6IOB pin input (single edge) */
234#define TM6MD_CLR_ENABLE 0x0010 /* clear count enable */ 353#endif /* CONFIG_AM33_2 */
235#define TM6MD_ONESHOT_ENABLE 0x0040 /* oneshot count */ 354#define TM6MD_ONESHOT_ENABLE 0x0040 /* oneshot count */
355#define TM6MD_CLR_ENABLE 0x0010 /* clear count enable */
356#if defined(CONFIG_AM33_2)
236#define TM6MD_TRIG_ENABLE 0x0080 /* TM6IOB pin trigger enable */ 357#define TM6MD_TRIG_ENABLE 0x0080 /* TM6IOB pin trigger enable */
237#define TM6MD_PWM 0x3800 /* PWM output mode */ 358#define TM6MD_PWM 0x3800 /* PWM output mode */
238#define TM6MD_PWM_DIS 0x0000 /* - disabled */ 359#define TM6MD_PWM_DIS 0x0000 /* - disabled */
@@ -240,10 +361,15 @@
240#define TM6MD_PWM_11BIT 0x1800 /* - 11 bits mode */ 361#define TM6MD_PWM_11BIT 0x1800 /* - 11 bits mode */
241#define TM6MD_PWM_12BIT 0x3000 /* - 12 bits mode */ 362#define TM6MD_PWM_12BIT 0x3000 /* - 12 bits mode */
242#define TM6MD_PWM_14BIT 0x3800 /* - 14 bits mode */ 363#define TM6MD_PWM_14BIT 0x3800 /* - 14 bits mode */
364#endif /* CONFIG_AM33_2 */
365
243#define TM6MD_INIT_COUNTER 0x4000 /* initialize TMnBC to zero */ 366#define TM6MD_INIT_COUNTER 0x4000 /* initialize TMnBC to zero */
244#define TM6MD_COUNT_ENABLE 0x8000 /* timer count enable */ 367#define TM6MD_COUNT_ENABLE 0x8000 /* timer count enable */
245 368
246#define TM6MDA __SYSREG(0xd40030b4, u8) /* timer6 cmp/cap A mode reg */ 369#define TM6MDA __SYSREG(0xd40030b4, u8) /* timer6 cmp/cap A mode reg */
370#define TM6MDA_MODE_CMP_SINGLE 0x00 /* - compare, single buffer mode */
371#define TM6MDA_MODE_CMP_DOUBLE 0x40 /* - compare, double buffer mode */
372#if defined(CONFIG_AM33_2)
247#define TM6MDA_OUT 0x07 /* output select */ 373#define TM6MDA_OUT 0x07 /* output select */
248#define TM6MDA_OUT_SETA_RESETB 0x00 /* - set at match A, reset at match B */ 374#define TM6MDA_OUT_SETA_RESETB 0x00 /* - set at match A, reset at match B */
249#define TM6MDA_OUT_SETA_RESETOV 0x01 /* - set at match A, reset at overflow */ 375#define TM6MDA_OUT_SETA_RESETOV 0x01 /* - set at match A, reset at overflow */
@@ -251,30 +377,35 @@
251#define TM6MDA_OUT_RESETA 0x03 /* - reset at match A */ 377#define TM6MDA_OUT_RESETA 0x03 /* - reset at match A */
252#define TM6MDA_OUT_TOGGLE 0x04 /* - toggle on match A */ 378#define TM6MDA_OUT_TOGGLE 0x04 /* - toggle on match A */
253#define TM6MDA_MODE 0xc0 /* compare A register mode */ 379#define TM6MDA_MODE 0xc0 /* compare A register mode */
254#define TM6MDA_MODE_CMP_SINGLE 0x00 /* - compare, single buffer mode */
255#define TM6MDA_MODE_CMP_DOUBLE 0x40 /* - compare, double buffer mode */
256#define TM6MDA_MODE_CAP_S_EDGE 0x80 /* - capture, single edge mode */ 380#define TM6MDA_MODE_CAP_S_EDGE 0x80 /* - capture, single edge mode */
257#define TM6MDA_MODE_CAP_D_EDGE 0xc0 /* - capture, double edge mode */ 381#define TM6MDA_MODE_CAP_D_EDGE 0xc0 /* - capture, double edge mode */
258#define TM6MDA_EDGE 0x20 /* compare A edge select */ 382#define TM6MDA_EDGE 0x20 /* compare A edge select */
259#define TM6MDA_EDGE_FALLING 0x00 /* capture on falling edge */ 383#define TM6MDA_EDGE_FALLING 0x00 /* capture on falling edge */
260#define TM6MDA_EDGE_RISING 0x20 /* capture on rising edge */ 384#define TM6MDA_EDGE_RISING 0x20 /* capture on rising edge */
261#define TM6MDA_CAPTURE_ENABLE 0x10 /* capture enable */ 385#define TM6MDA_CAPTURE_ENABLE 0x10 /* capture enable */
386#else /* !CONFIG_AM33_2 */
387#define TM6MDA_MODE 0x40 /* compare A register mode */
388#endif /* CONFIG_AM33_2 */
262 389
263#define TM6MDB __SYSREG(0xd40030b5, u8) /* timer6 cmp/cap B mode reg */ 390#define TM6MDB __SYSREG(0xd40030b5, u8) /* timer6 cmp/cap B mode reg */
391#define TM6MDB_MODE_CMP_SINGLE 0x00 /* - compare, single buffer mode */
392#define TM6MDB_MODE_CMP_DOUBLE 0x40 /* - compare, double buffer mode */
393#if defined(CONFIG_AM33_2)
264#define TM6MDB_OUT 0x07 /* output select */ 394#define TM6MDB_OUT 0x07 /* output select */
265#define TM6MDB_OUT_SETB_RESETA 0x00 /* - set at match B, reset at match A */ 395#define TM6MDB_OUT_SETB_RESETA 0x00 /* - set at match B, reset at match A */
266#define TM6MDB_OUT_SETB_RESETOV 0x01 /* - set at match B */ 396#define TM6MDB_OUT_SETB_RESETOV 0x01 /* - set at match B */
267#define TM6MDB_OUT_RESETB 0x03 /* - reset at match B */ 397#define TM6MDB_OUT_RESETB 0x03 /* - reset at match B */
268#define TM6MDB_OUT_TOGGLE 0x04 /* - toggle on match B */ 398#define TM6MDB_OUT_TOGGLE 0x04 /* - toggle on match B */
269#define TM6MDB_MODE 0xc0 /* compare B register mode */ 399#define TM6MDB_MODE 0xc0 /* compare B register mode */
270#define TM6MDB_MODE_CMP_SINGLE 0x00 /* - compare, single buffer mode */
271#define TM6MDB_MODE_CMP_DOUBLE 0x40 /* - compare, double buffer mode */
272#define TM6MDB_MODE_CAP_S_EDGE 0x80 /* - capture, single edge mode */ 400#define TM6MDB_MODE_CAP_S_EDGE 0x80 /* - capture, single edge mode */
273#define TM6MDB_MODE_CAP_D_EDGE 0xc0 /* - capture, double edge mode */ 401#define TM6MDB_MODE_CAP_D_EDGE 0xc0 /* - capture, double edge mode */
274#define TM6MDB_EDGE 0x20 /* compare B edge select */ 402#define TM6MDB_EDGE 0x20 /* compare B edge select */
275#define TM6MDB_EDGE_FALLING 0x00 /* capture on falling edge */ 403#define TM6MDB_EDGE_FALLING 0x00 /* capture on falling edge */
276#define TM6MDB_EDGE_RISING 0x20 /* capture on rising edge */ 404#define TM6MDB_EDGE_RISING 0x20 /* capture on rising edge */
277#define TM6MDB_CAPTURE_ENABLE 0x10 /* capture enable */ 405#define TM6MDB_CAPTURE_ENABLE 0x10 /* capture enable */
406#else /* !CONFIG_AM33_2 */
407#define TM6MDB_MODE 0x40 /* compare B register mode */
408#endif /* CONFIG_AM33_2 */
278 409
279#define TM6CA __SYSREG(0xd40030c4, u16) /* timer6 cmp/capture reg A */ 410#define TM6CA __SYSREG(0xd40030c4, u16) /* timer6 cmp/capture reg A */
280#define TM6CB __SYSREG(0xd40030d4, u16) /* timer6 cmp/capture reg B */ 411#define TM6CB __SYSREG(0xd40030d4, u16) /* timer6 cmp/capture reg B */
@@ -288,6 +419,34 @@
288#define TM6AICR GxICR(TM6AIRQ) /* timer 6A intr control reg */ 419#define TM6AICR GxICR(TM6AIRQ) /* timer 6A intr control reg */
289#define TM6BICR GxICR(TM6BIRQ) /* timer 6B intr control reg */ 420#define TM6BICR GxICR(TM6BIRQ) /* timer 6B intr control reg */
290 421
422#if defined(CONFIG_AM34_2)
423/*
424 * MTM: OS Tick-Timer
425 */
426#define TMTMD __SYSREG(0xd4004100, u8) /* Tick Timer mode register */
427#define TMTMD_TMTLDE 0x40 /* initialize TMTBC = TMTBR */
428#define TMTMD_TMTCNE 0x80 /* timer count enable */
429
430#define TMTBR __SYSREG(0xd4004110, u32) /* Tick Timer mode reg */
431#define TMTBC __SYSREG(0xd4004120, u32) /* Tick Timer mode reg */
432
433/*
434 * MTM: OS Timestamp-Timer
435 */
436#define TMSMD __SYSREG(0xd4004140, u8) /* Tick Timer mode register */
437#define TMSMD_TMSLDE 0x40 /* initialize TMSBC = TMSBR */
438#define TMSMD_TMSCNE 0x80 /* timer count enable */
439
440#define TMSBR __SYSREG(0xd4004150, u32) /* Tick Timer mode register */
441#define TMSBC __SYSREG(0xd4004160, u32) /* Tick Timer mode register */
442
443#define TMTIRQ 119 /* OS Tick timer IRQ */
444#define TMSIRQ 120 /* Timestamp timer IRQ */
445
446#define TMTICR GxICR(TMTIRQ) /* OS Tick timer uflow intr ctrl reg */
447#define TMSICR GxICR(TMSIRQ) /* Timestamp timer uflow intr ctrl reg */
448#endif /* CONFIG_AM34_2 */
449
291#endif /* __KERNEL__ */ 450#endif /* __KERNEL__ */
292 451
293#endif /* _ASM_TIMER_REGS_H */ 452#endif /* _ASM_TIMER_REGS_H */
diff --git a/arch/mn10300/include/asm/timex.h b/arch/mn10300/include/asm/timex.h
index 8d031f9e117d..bd4e90dfe6c2 100644
--- a/arch/mn10300/include/asm/timex.h
+++ b/arch/mn10300/include/asm/timex.h
@@ -16,18 +16,30 @@
16 16
17#define TICK_SIZE (tick_nsec / 1000) 17#define TICK_SIZE (tick_nsec / 1000)
18 18
19#define CLOCK_TICK_RATE 1193180 /* Underlying HZ - this should probably be set 19#define CLOCK_TICK_RATE MN10300_JCCLK /* Underlying HZ */
20 * to something appropriate, but what? */
21
22extern cycles_t cacheflush_time;
23 20
24#ifdef __KERNEL__ 21#ifdef __KERNEL__
25 22
23extern cycles_t cacheflush_time;
24
26static inline cycles_t get_cycles(void) 25static inline cycles_t get_cycles(void)
27{ 26{
28 return read_timestamp_counter(); 27 return read_timestamp_counter();
29} 28}
30 29
30extern int init_clockevents(void);
31extern int init_clocksource(void);
32
33static inline void setup_jiffies_interrupt(int irq,
34 struct irqaction *action)
35{
36 u16 tmp;
37 setup_irq(irq, action);
38 set_intr_level(irq, NUM2GxICR_LEVEL(CONFIG_TIMER_IRQ_LEVEL));
39 GxICR(irq) |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST;
40 tmp = GxICR(irq);
41}
42
31#endif /* __KERNEL__ */ 43#endif /* __KERNEL__ */
32 44
33#endif /* _ASM_TIMEX_H */ 45#endif /* _ASM_TIMEX_H */
diff --git a/arch/mn10300/include/asm/tlbflush.h b/arch/mn10300/include/asm/tlbflush.h
index 1a7e29281c5d..efddd6e1adea 100644
--- a/arch/mn10300/include/asm/tlbflush.h
+++ b/arch/mn10300/include/asm/tlbflush.h
@@ -11,24 +11,78 @@
11#ifndef _ASM_TLBFLUSH_H 11#ifndef _ASM_TLBFLUSH_H
12#define _ASM_TLBFLUSH_H 12#define _ASM_TLBFLUSH_H
13 13
14#include <linux/mm.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
15 16
16#define __flush_tlb() \ 17struct tlb_state {
17do { \ 18 struct mm_struct *active_mm;
18 int w; \ 19 int state;
19 __asm__ __volatile__ \ 20};
20 (" mov %1,%0 \n" \ 21DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate);
21 " or %2,%0 \n" \
22 " mov %0,%1 \n" \
23 : "=d"(w) \
24 : "m"(MMUCTR), "i"(MMUCTR_IIV|MMUCTR_DIV) \
25 : "cc", "memory" \
26 ); \
27} while (0)
28 22
29#define __flush_tlb_all() __flush_tlb() 23/**
30#define __flush_tlb_one(addr) __flush_tlb() 24 * local_flush_tlb - Flush the current MM's entries from the local CPU's TLBs
25 */
26static inline void local_flush_tlb(void)
27{
28 int w;
29 asm volatile(
30 " mov %1,%0 \n"
31 " or %2,%0 \n"
32 " mov %0,%1 \n"
33 : "=d"(w)
34 : "m"(MMUCTR), "i"(MMUCTR_IIV|MMUCTR_DIV)
35 : "cc", "memory");
36}
37
38/**
39 * local_flush_tlb_all - Flush all entries from the local CPU's TLBs
40 */
41static inline void local_flush_tlb_all(void)
42{
43 local_flush_tlb();
44}
31 45
46/**
47 * local_flush_tlb_one - Flush one entry from the local CPU's TLBs
48 */
49static inline void local_flush_tlb_one(unsigned long addr)
50{
51 local_flush_tlb();
52}
53
54/**
55 * local_flush_tlb_page - Flush a page's entry from the local CPU's TLBs
56 * @mm: The MM to flush for
57 * @addr: The address of the target page in RAM (not its page struct)
58 */
59static inline
60void local_flush_tlb_page(struct mm_struct *mm, unsigned long addr)
61{
62 unsigned long pteu, flags, cnx;
63
64 addr &= PAGE_MASK;
65
66 local_irq_save(flags);
67
68 cnx = 1;
69#ifdef CONFIG_MN10300_TLB_USE_PIDR
70 cnx = mm->context.tlbpid[smp_processor_id()];
71#endif
72 if (cnx) {
73 pteu = addr;
74#ifdef CONFIG_MN10300_TLB_USE_PIDR
75 pteu |= cnx & xPTEU_PID;
76#endif
77 IPTEU = pteu;
78 DPTEU = pteu;
79 if (IPTEL & xPTEL_V)
80 IPTEL = 0;
81 if (DPTEL & xPTEL_V)
82 DPTEL = 0;
83 }
84 local_irq_restore(flags);
85}
32 86
33/* 87/*
34 * TLB flushing: 88 * TLB flushing:
@@ -40,41 +94,61 @@ do { \
40 * - flush_tlb_range(mm, start, end) flushes a range of pages 94 * - flush_tlb_range(mm, start, end) flushes a range of pages
41 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables 95 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
42 */ 96 */
43#define flush_tlb_all() \ 97#ifdef CONFIG_SMP
44do { \ 98
45 preempt_disable(); \ 99#include <asm/smp.h>
46 __flush_tlb_all(); \ 100
47 preempt_enable(); \ 101extern void flush_tlb_all(void);
48} while (0) 102extern void flush_tlb_current_task(void);
49 103extern void flush_tlb_mm(struct mm_struct *);
50#define flush_tlb_mm(mm) \ 104extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
51do { \ 105
52 preempt_disable(); \ 106#define flush_tlb() flush_tlb_current_task()
53 __flush_tlb_all(); \ 107
54 preempt_enable(); \ 108static inline void flush_tlb_range(struct vm_area_struct *vma,
55} while (0) 109 unsigned long start, unsigned long end)
56 110{
57#define flush_tlb_range(vma, start, end) \ 111 flush_tlb_mm(vma->vm_mm);
58do { \ 112}
59 unsigned long __s __attribute__((unused)) = (start); \ 113
60 unsigned long __e __attribute__((unused)) = (end); \ 114#else /* CONFIG_SMP */
61 preempt_disable(); \ 115
62 __flush_tlb_all(); \ 116static inline void flush_tlb_all(void)
63 preempt_enable(); \ 117{
64} while (0) 118 preempt_disable();
65 119 local_flush_tlb_all();
66 120 preempt_enable();
67#define __flush_tlb_global() flush_tlb_all() 121}
68#define flush_tlb() flush_tlb_all() 122
69#define flush_tlb_kernel_range(start, end) \ 123static inline void flush_tlb_mm(struct mm_struct *mm)
70do { \ 124{
71 unsigned long __s __attribute__((unused)) = (start); \ 125 preempt_disable();
72 unsigned long __e __attribute__((unused)) = (end); \ 126 local_flush_tlb_all();
73 flush_tlb_all(); \ 127 preempt_enable();
74} while (0) 128}
75 129
76extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr); 130static inline void flush_tlb_range(struct vm_area_struct *vma,
77 131 unsigned long start, unsigned long end)
78#define flush_tlb_pgtables(mm, start, end) do {} while (0) 132{
133 preempt_disable();
134 local_flush_tlb_all();
135 preempt_enable();
136}
137
138#define flush_tlb_page(vma, addr) local_flush_tlb_page((vma)->vm_mm, addr)
139#define flush_tlb() flush_tlb_all()
140
141#endif /* CONFIG_SMP */
142
143static inline void flush_tlb_kernel_range(unsigned long start,
144 unsigned long end)
145{
146 flush_tlb_all();
147}
148
149static inline void flush_tlb_pgtables(struct mm_struct *mm,
150 unsigned long start, unsigned long end)
151{
152}
79 153
80#endif /* _ASM_TLBFLUSH_H */ 154#endif /* _ASM_TLBFLUSH_H */
diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h
index 197a7af3dd8a..679dee0bbd08 100644
--- a/arch/mn10300/include/asm/uaccess.h
+++ b/arch/mn10300/include/asm/uaccess.h
@@ -14,9 +14,8 @@
14/* 14/*
15 * User space memory access functions 15 * User space memory access functions
16 */ 16 */
17#include <linux/sched.h> 17#include <linux/thread_info.h>
18#include <asm/page.h> 18#include <asm/page.h>
19#include <asm/pgtable.h>
20#include <asm/errno.h> 19#include <asm/errno.h>
21 20
22#define VERIFY_READ 0 21#define VERIFY_READ 0
@@ -29,7 +28,6 @@
29 * 28 *
30 * For historical reasons, these macros are grossly misnamed. 29 * For historical reasons, these macros are grossly misnamed.
31 */ 30 */
32
33#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 31#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
34 32
35#define KERNEL_XDS MAKE_MM_SEG(0xBFFFFFFF) 33#define KERNEL_XDS MAKE_MM_SEG(0xBFFFFFFF)
@@ -377,7 +375,7 @@ unsigned long __generic_copy_to_user_nocheck(void *to, const void *from,
377 375
378 376
379#if 0 377#if 0
380#error don't use - these macros don't increment to & from pointers 378#error "don't use - these macros don't increment to & from pointers"
381/* Optimize just a little bit when we know the size of the move. */ 379/* Optimize just a little bit when we know the size of the move. */
382#define __constant_copy_user(to, from, size) \ 380#define __constant_copy_user(to, from, size) \
383do { \ 381do { \
diff --git a/arch/mn10300/kernel/Makefile b/arch/mn10300/kernel/Makefile
index 23f2ab67574c..8f5f1e81baf5 100644
--- a/arch/mn10300/kernel/Makefile
+++ b/arch/mn10300/kernel/Makefile
@@ -3,13 +3,16 @@
3# 3#
4extra-y := head.o init_task.o vmlinux.lds 4extra-y := head.o init_task.o vmlinux.lds
5 5
6obj-y := process.o signal.o entry.o fpu.o traps.o irq.o \ 6fpu-obj-y := fpu-nofpu.o fpu-nofpu-low.o
7fpu-obj-$(CONFIG_FPU) := fpu.o fpu-low.o
8
9obj-y := process.o signal.o entry.o traps.o irq.o \
7 ptrace.o setup.o time.o sys_mn10300.o io.o kthread.o \ 10 ptrace.o setup.o time.o sys_mn10300.o io.o kthread.o \
8 switch_to.o mn10300_ksyms.o kernel_execve.o 11 switch_to.o mn10300_ksyms.o kernel_execve.o $(fpu-obj-y)
9 12
10obj-$(CONFIG_MN10300_WD_TIMER) += mn10300-watchdog.o mn10300-watchdog-low.o 13obj-$(CONFIG_SMP) += smp.o smp-low.o
11 14
12obj-$(CONFIG_FPU) += fpu-low.o 15obj-$(CONFIG_MN10300_WD_TIMER) += mn10300-watchdog.o mn10300-watchdog-low.o
13 16
14obj-$(CONFIG_MN10300_TTYSM) += mn10300-serial.o mn10300-serial-low.o \ 17obj-$(CONFIG_MN10300_TTYSM) += mn10300-serial.o mn10300-serial-low.o \
15 mn10300-debug.o 18 mn10300-debug.o
@@ -17,7 +20,7 @@ obj-$(CONFIG_GDBSTUB) += gdb-stub.o gdb-low.o
17obj-$(CONFIG_GDBSTUB_ON_TTYSx) += gdb-io-serial.o gdb-io-serial-low.o 20obj-$(CONFIG_GDBSTUB_ON_TTYSx) += gdb-io-serial.o gdb-io-serial-low.o
18obj-$(CONFIG_GDBSTUB_ON_TTYSMx) += gdb-io-ttysm.o gdb-io-ttysm-low.o 21obj-$(CONFIG_GDBSTUB_ON_TTYSMx) += gdb-io-ttysm.o gdb-io-ttysm-low.o
19 22
20ifneq ($(CONFIG_MN10300_CACHE_DISABLED),y) 23ifeq ($(CONFIG_MN10300_CACHE_ENABLED),y)
21obj-$(CONFIG_GDBSTUB) += gdb-cache.o 24obj-$(CONFIG_GDBSTUB) += gdb-cache.o
22endif 25endif
23 26
@@ -25,3 +28,5 @@ obj-$(CONFIG_MN10300_RTC) += rtc.o
25obj-$(CONFIG_PROFILE) += profile.o profile-low.o 28obj-$(CONFIG_PROFILE) += profile.o profile-low.o
26obj-$(CONFIG_MODULES) += module.o 29obj-$(CONFIG_MODULES) += module.o
27obj-$(CONFIG_KPROBES) += kprobes.o 30obj-$(CONFIG_KPROBES) += kprobes.o
31obj-$(CONFIG_CSRC_MN10300) += csrc-mn10300.o
32obj-$(CONFIG_CEVT_MN10300) += cevt-mn10300.o
diff --git a/arch/mn10300/kernel/asm-offsets.c b/arch/mn10300/kernel/asm-offsets.c
index 02dc7e461fef..96f24fab7de6 100644
--- a/arch/mn10300/kernel/asm-offsets.c
+++ b/arch/mn10300/kernel/asm-offsets.c
@@ -23,6 +23,7 @@ void foo(void)
23 23
24 OFFSET(TI_task, thread_info, task); 24 OFFSET(TI_task, thread_info, task);
25 OFFSET(TI_exec_domain, thread_info, exec_domain); 25 OFFSET(TI_exec_domain, thread_info, exec_domain);
26 OFFSET(TI_frame, thread_info, frame);
26 OFFSET(TI_flags, thread_info, flags); 27 OFFSET(TI_flags, thread_info, flags);
27 OFFSET(TI_cpu, thread_info, cpu); 28 OFFSET(TI_cpu, thread_info, cpu);
28 OFFSET(TI_preempt_count, thread_info, preempt_count); 29 OFFSET(TI_preempt_count, thread_info, preempt_count);
@@ -66,7 +67,15 @@ void foo(void)
66 OFFSET(THREAD_SP, thread_struct, sp); 67 OFFSET(THREAD_SP, thread_struct, sp);
67 OFFSET(THREAD_A3, thread_struct, a3); 68 OFFSET(THREAD_A3, thread_struct, a3);
68 OFFSET(THREAD_USP, thread_struct, usp); 69 OFFSET(THREAD_USP, thread_struct, usp);
69 OFFSET(THREAD_FRAME, thread_struct, __frame); 70#ifdef CONFIG_FPU
71 OFFSET(THREAD_FPU_FLAGS, thread_struct, fpu_flags);
72 OFFSET(THREAD_FPU_STATE, thread_struct, fpu_state);
73 DEFINE(__THREAD_USING_FPU, THREAD_USING_FPU);
74 DEFINE(__THREAD_HAS_FPU, THREAD_HAS_FPU);
75#endif /* CONFIG_FPU */
76 BLANK();
77
78 OFFSET(TASK_THREAD, task_struct, thread);
70 BLANK(); 79 BLANK();
71 80
72 DEFINE(CLONE_VM_asm, CLONE_VM); 81 DEFINE(CLONE_VM_asm, CLONE_VM);
diff --git a/arch/mn10300/kernel/cevt-mn10300.c b/arch/mn10300/kernel/cevt-mn10300.c
new file mode 100644
index 000000000000..d4cb535bf786
--- /dev/null
+++ b/arch/mn10300/kernel/cevt-mn10300.c
@@ -0,0 +1,131 @@
1/* MN10300 clockevents
2 *
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by Mark Salter (msalter@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#include <linux/clockchips.h>
12#include <linux/interrupt.h>
13#include <linux/percpu.h>
14#include <linux/smp.h>
15#include <asm/timex.h>
16#include "internal.h"
17
18#ifdef CONFIG_SMP
19#if (CONFIG_NR_CPUS > 2) && !defined(CONFIG_GEENERIC_CLOCKEVENTS_BROADCAST)
20#error "This doesn't scale well! Need per-core local timers."
21#endif
22#else /* CONFIG_SMP */
23#define stop_jiffies_counter1()
24#define reload_jiffies_counter1(x)
25#define TMJC1IRQ TMJCIRQ
26#endif
27
28
29static int next_event(unsigned long delta,
30 struct clock_event_device *evt)
31{
32 unsigned int cpu = smp_processor_id();
33
34 if (cpu == 0) {
35 stop_jiffies_counter();
36 reload_jiffies_counter(delta - 1);
37 } else {
38 stop_jiffies_counter1();
39 reload_jiffies_counter1(delta - 1);
40 }
41 return 0;
42}
43
44static void set_clock_mode(enum clock_event_mode mode,
45 struct clock_event_device *evt)
46{
47 /* Nothing to do ... */
48}
49
50static DEFINE_PER_CPU(struct clock_event_device, mn10300_clockevent_device);
51static DEFINE_PER_CPU(struct irqaction, timer_irq);
52
53static irqreturn_t timer_interrupt(int irq, void *dev_id)
54{
55 struct clock_event_device *cd;
56 unsigned int cpu = smp_processor_id();
57
58 if (cpu == 0)
59 stop_jiffies_counter();
60 else
61 stop_jiffies_counter1();
62
63 cd = &per_cpu(mn10300_clockevent_device, cpu);
64 cd->event_handler(cd);
65
66 return IRQ_HANDLED;
67}
68
69static void event_handler(struct clock_event_device *dev)
70{
71}
72
73int __init init_clockevents(void)
74{
75 struct clock_event_device *cd;
76 struct irqaction *iact;
77 unsigned int cpu = smp_processor_id();
78
79 cd = &per_cpu(mn10300_clockevent_device, cpu);
80
81 if (cpu == 0) {
82 stop_jiffies_counter();
83 cd->irq = TMJCIRQ;
84 } else {
85 stop_jiffies_counter1();
86 cd->irq = TMJC1IRQ;
87 }
88
89 cd->name = "Timestamp";
90 cd->features = CLOCK_EVT_FEAT_ONESHOT;
91
92 /* Calculate the min / max delta */
93 clockevent_set_clock(cd, MN10300_JCCLK);
94
95 cd->max_delta_ns = clockevent_delta2ns(TMJCBR_MAX, cd);
96 cd->min_delta_ns = clockevent_delta2ns(100, cd);
97
98 cd->rating = 200;
99 cd->cpumask = cpumask_of(smp_processor_id());
100 cd->set_mode = set_clock_mode;
101 cd->event_handler = event_handler;
102 cd->set_next_event = next_event;
103
104 iact = &per_cpu(timer_irq, cpu);
105 iact->flags = IRQF_DISABLED | IRQF_SHARED | IRQF_TIMER;
106 iact->handler = timer_interrupt;
107
108 clockevents_register_device(cd);
109
110#if defined(CONFIG_SMP) && !defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
111 /* setup timer irq affinity so it only runs on this cpu */
112 {
113 struct irq_desc *desc;
114 desc = irq_to_desc(cd->irq);
115 cpumask_copy(desc->affinity, cpumask_of(cpu));
116 iact->flags |= IRQF_NOBALANCING;
117 }
118#endif
119
120 if (cpu == 0) {
121 reload_jiffies_counter(MN10300_JC_PER_HZ - 1);
122 iact->name = "CPU0 Timer";
123 } else {
124 reload_jiffies_counter1(MN10300_JC_PER_HZ - 1);
125 iact->name = "CPU1 Timer";
126 }
127
128 setup_jiffies_interrupt(cd->irq, iact);
129
130 return 0;
131}
diff --git a/arch/mn10300/kernel/csrc-mn10300.c b/arch/mn10300/kernel/csrc-mn10300.c
new file mode 100644
index 000000000000..ba2f0c4d6e01
--- /dev/null
+++ b/arch/mn10300/kernel/csrc-mn10300.c
@@ -0,0 +1,35 @@
1/* MN10300 clocksource
2 *
3 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by Mark Salter (msalter@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#include <linux/clocksource.h>
12#include <linux/init.h>
13#include <asm/timex.h>
14#include "internal.h"
15
16static cycle_t mn10300_read(struct clocksource *cs)
17{
18 return read_timestamp_counter();
19}
20
21static struct clocksource clocksource_mn10300 = {
22 .name = "TSC",
23 .rating = 200,
24 .read = mn10300_read,
25 .mask = CLOCKSOURCE_MASK(32),
26 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
27};
28
29int __init init_clocksource(void)
30{
31 startup_timestamp_counter();
32 clocksource_set_clock(&clocksource_mn10300, MN10300_TSCCLK);
33 clocksource_register(&clocksource_mn10300);
34 return 0;
35}
diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
index 3d394b4eefba..f00b9bafcd3e 100644
--- a/arch/mn10300/kernel/entry.S
+++ b/arch/mn10300/kernel/entry.S
@@ -28,25 +28,17 @@
28#include <asm/asm-offsets.h> 28#include <asm/asm-offsets.h>
29#include <asm/frame.inc> 29#include <asm/frame.inc>
30 30
31#if defined(CONFIG_SMP) && defined(CONFIG_GDBSTUB)
32#include <asm/gdb-stub.h>
33#endif /* CONFIG_SMP && CONFIG_GDBSTUB */
34
31#ifdef CONFIG_PREEMPT 35#ifdef CONFIG_PREEMPT
32#define preempt_stop __cli 36#define preempt_stop LOCAL_IRQ_DISABLE
33#else 37#else
34#define preempt_stop 38#define preempt_stop
35#define resume_kernel restore_all 39#define resume_kernel restore_all
36#endif 40#endif
37 41
38 .macro __cli
39 and ~EPSW_IM,epsw
40 or EPSW_IE|MN10300_CLI_LEVEL,epsw
41 nop
42 nop
43 nop
44 .endm
45 .macro __sti
46 or EPSW_IE|EPSW_IM_7,epsw
47 .endm
48
49
50 .am33_2 42 .am33_2
51 43
52############################################################################### 44###############################################################################
@@ -88,7 +80,7 @@ syscall_call:
88syscall_exit: 80syscall_exit:
89 # make sure we don't miss an interrupt setting need_resched or 81 # make sure we don't miss an interrupt setting need_resched or
90 # sigpending between sampling and the rti 82 # sigpending between sampling and the rti
91 __cli 83 LOCAL_IRQ_DISABLE
92 mov (TI_flags,a2),d2 84 mov (TI_flags,a2),d2
93 btst _TIF_ALLWORK_MASK,d2 85 btst _TIF_ALLWORK_MASK,d2
94 bne syscall_exit_work 86 bne syscall_exit_work
@@ -105,7 +97,7 @@ restore_all:
105syscall_exit_work: 97syscall_exit_work:
106 btst _TIF_SYSCALL_TRACE,d2 98 btst _TIF_SYSCALL_TRACE,d2
107 beq work_pending 99 beq work_pending
108 __sti # could let syscall_trace_exit() call 100 LOCAL_IRQ_ENABLE # could let syscall_trace_exit() call
109 # schedule() instead 101 # schedule() instead
110 mov fp,d0 102 mov fp,d0
111 call syscall_trace_exit[],0 # do_syscall_trace(regs) 103 call syscall_trace_exit[],0 # do_syscall_trace(regs)
@@ -121,7 +113,7 @@ work_resched:
121 113
122 # make sure we don't miss an interrupt setting need_resched or 114 # make sure we don't miss an interrupt setting need_resched or
123 # sigpending between sampling and the rti 115 # sigpending between sampling and the rti
124 __cli 116 LOCAL_IRQ_DISABLE
125 117
126 # is there any work to be done other than syscall tracing? 118 # is there any work to be done other than syscall tracing?
127 mov (TI_flags,a2),d2 119 mov (TI_flags,a2),d2
@@ -168,7 +160,7 @@ ret_from_intr:
168ENTRY(resume_userspace) 160ENTRY(resume_userspace)
169 # make sure we don't miss an interrupt setting need_resched or 161 # make sure we don't miss an interrupt setting need_resched or
170 # sigpending between sampling and the rti 162 # sigpending between sampling and the rti
171 __cli 163 LOCAL_IRQ_DISABLE
172 164
173 # is there any work to be done on int/exception return? 165 # is there any work to be done on int/exception return?
174 mov (TI_flags,a2),d2 166 mov (TI_flags,a2),d2
@@ -178,7 +170,7 @@ ENTRY(resume_userspace)
178 170
179#ifdef CONFIG_PREEMPT 171#ifdef CONFIG_PREEMPT
180ENTRY(resume_kernel) 172ENTRY(resume_kernel)
181 __cli 173 LOCAL_IRQ_DISABLE
182 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ? 174 mov (TI_preempt_count,a2),d0 # non-zero preempt_count ?
183 cmp 0,d0 175 cmp 0,d0
184 bne restore_all 176 bne restore_all
@@ -216,31 +208,6 @@ ENTRY(irq_handler)
216 208
217############################################################################### 209###############################################################################
218# 210#
219# Monitor Signal handler entry point
220#
221###############################################################################
222ENTRY(monitor_signal)
223 movbu (0xae000001),d1
224 cmp 1,d1
225 beq monsignal
226 ret [],0
227
228monsignal:
229 or EPSW_NMID,epsw
230 mov d0,a0
231 mov a0,sp
232 mov (REG_EPSW,fp),d1
233 and ~EPSW_nSL,d1
234 mov d1,(REG_EPSW,fp)
235 movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
236 mov (sp),a1
237 mov a1,usp
238 movm (sp),[other]
239 add 4,sp
240here: jmp 0x8e000008-here+0x8e000008
241
242###############################################################################
243#
244# Double Fault handler entry point 211# Double Fault handler entry point
245# - note that there will not be a stack, D0/A0 will hold EPSW/PC as were 212# - note that there will not be a stack, D0/A0 will hold EPSW/PC as were
246# 213#
@@ -276,6 +243,10 @@ double_fault_loop:
276ENTRY(raw_bus_error) 243ENTRY(raw_bus_error)
277 add -4,sp 244 add -4,sp
278 mov d0,(sp) 245 mov d0,(sp)
246#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
247 mov (MMUCTR),d0
248 mov d0,(MMUCTR)
249#endif
279 mov (BCBERR),d0 # what 250 mov (BCBERR),d0 # what
280 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error 251 btst BCBERR_BEMR_DMA,d0 # see if it was an external bus error
281 beq __common_exception_aux # it wasn't 252 beq __common_exception_aux # it wasn't
@@ -302,11 +273,88 @@ ENTRY(nmi_handler)
302 add -4,sp 273 add -4,sp
303 mov d0,(sp) 274 mov d0,(sp)
304 mov (TBR),d0 275 mov (TBR),d0
276
277#ifdef CONFIG_SMP
278 add -4,sp
279 mov d0,(sp) # save d0(TBR)
280 movhu (NMIAGR),d0
281 and NMIAGR_GN,d0
282 lsr 0x2,d0
283 cmp CALL_FUNCTION_NMI_IPI,d0
284 bne 5f # if not call function, jump
285
286 # function call nmi ipi
287 add 4,sp # no need to store TBR
288 mov GxICR_DETECT,d0 # clear NMI request
289 movbu d0,(GxICR(CALL_FUNCTION_NMI_IPI))
290 movhu (GxICR(CALL_FUNCTION_NMI_IPI)),d0
291 and ~EPSW_NMID,epsw # enable NMI
292
293 mov (sp),d0 # restore d0
294 SAVE_ALL
295 call smp_nmi_call_function_interrupt[],0
296 RESTORE_ALL
297
2985:
299#ifdef CONFIG_GDBSTUB
300 cmp GDB_NMI_IPI,d0
301 bne 3f # if not gdb nmi ipi, jump
302
303 # gdb nmi ipi
304 add 4,sp # no need to store TBR
305 mov GxICR_DETECT,d0 # clear NMI
306 movbu d0,(GxICR(GDB_NMI_IPI))
307 movhu (GxICR(GDB_NMI_IPI)),d0
308 and ~EPSW_NMID,epsw # enable NMI
309#ifdef CONFIG_MN10300_CACHE_ENABLED
310 mov (gdbstub_nmi_opr_type),d0
311 cmp GDBSTUB_NMI_CACHE_PURGE,d0
312 bne 4f # if not gdb cache purge, jump
313
314 # gdb cache purge nmi ipi
315 add -20,sp
316 mov d1,(4,sp)
317 mov a0,(8,sp)
318 mov a1,(12,sp)
319 mov mdr,d0
320 mov d0,(16,sp)
321 call gdbstub_local_purge_cache[],0
322 mov 0x1,d0
323 mov (CPUID),d1
324 asl d1,d0
325 mov gdbstub_nmi_cpumask,a0
326 bclr d0,(a0)
327 mov (4,sp),d1
328 mov (8,sp),a0
329 mov (12,sp),a1
330 mov (16,sp),d0
331 mov d0,mdr
332 add 20,sp
333 mov (sp),d0
334 add 4,sp
335 rti
3364:
337#endif /* CONFIG_MN10300_CACHE_ENABLED */
338 # gdb wait nmi ipi
339 mov (sp),d0
340 SAVE_ALL
341 call gdbstub_nmi_wait[],0
342 RESTORE_ALL
3433:
344#endif /* CONFIG_GDBSTUB */
345 mov (sp),d0 # restore TBR to d0
346 add 4,sp
347#endif /* CONFIG_SMP */
348
305 bra __common_exception_nonmi 349 bra __common_exception_nonmi
306 350
307ENTRY(__common_exception) 351ENTRY(__common_exception)
308 add -4,sp 352 add -4,sp
309 mov d0,(sp) 353 mov d0,(sp)
354#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
355 mov (MMUCTR),d0
356 mov d0,(MMUCTR)
357#endif
310 358
311__common_exception_aux: 359__common_exception_aux:
312 mov (TBR),d0 360 mov (TBR),d0
@@ -331,15 +379,21 @@ __common_exception_nonmi:
331 mov d0,(REG_ORIG_D0,fp) 379 mov d0,(REG_ORIG_D0,fp)
332 380
333#ifdef CONFIG_GDBSTUB 381#ifdef CONFIG_GDBSTUB
382#ifdef CONFIG_SMP
383 call gdbstub_busy_check[],0
384 and d0,d0 # check return value
385 beq 2f
386#else /* CONFIG_SMP */
334 btst 0x01,(gdbstub_busy) 387 btst 0x01,(gdbstub_busy)
335 beq 2f 388 beq 2f
389#endif /* CONFIG_SMP */
336 and ~EPSW_IE,epsw 390 and ~EPSW_IE,epsw
337 mov fp,d0 391 mov fp,d0
338 mov a2,d1 392 mov a2,d1
339 call gdbstub_exception[],0 # gdbstub itself caused an exception 393 call gdbstub_exception[],0 # gdbstub itself caused an exception
340 bra restore_all 394 bra restore_all
3412: 3952:
342#endif 396#endif /* CONFIG_GDBSTUB */
343 397
344 mov fp,d0 # arg 0: stacked register file 398 mov fp,d0 # arg 0: stacked register file
345 mov a2,d1 # arg 1: exception number 399 mov a2,d1 # arg 1: exception number
@@ -374,11 +428,7 @@ ENTRY(set_excp_vector)
374 add exception_table,d0 428 add exception_table,d0
375 mov d1,(d0) 429 mov d1,(d0)
376 mov 4,d1 430 mov 4,d1
377#if defined(CONFIG_MN10300_CACHE_WBACK)
378 jmp mn10300_dcache_flush_inv_range2
379#else
380 ret [],0 431 ret [],0
381#endif
382 432
383############################################################################### 433###############################################################################
384# 434#
diff --git a/arch/mn10300/kernel/fpu-low.S b/arch/mn10300/kernel/fpu-low.S
index 96cfd47e68d5..78df25cfae29 100644
--- a/arch/mn10300/kernel/fpu-low.S
+++ b/arch/mn10300/kernel/fpu-low.S
@@ -8,25 +8,14 @@
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11#include <linux/linkage.h>
11#include <asm/cpu-regs.h> 12#include <asm/cpu-regs.h>
13#include <asm/smp.h>
14#include <asm/thread_info.h>
15#include <asm/asm-offsets.h>
16#include <asm/frame.inc>
12 17
13############################################################################### 18.macro FPU_INIT_STATE_ALL
14#
15# void fpu_init_state(void)
16# - initialise the FPU
17#
18###############################################################################
19 .globl fpu_init_state
20 .type fpu_init_state,@function
21fpu_init_state:
22 mov epsw,d0
23 or EPSW_FE,epsw
24
25#ifdef CONFIG_MN10300_PROC_MN103E010
26 nop
27 nop
28 nop
29#endif
30 fmov 0,fs0 19 fmov 0,fs0
31 fmov fs0,fs1 20 fmov fs0,fs1
32 fmov fs0,fs2 21 fmov fs0,fs2
@@ -60,7 +49,100 @@ fpu_init_state:
60 fmov fs0,fs30 49 fmov fs0,fs30
61 fmov fs0,fs31 50 fmov fs0,fs31
62 fmov FPCR_INIT,fpcr 51 fmov FPCR_INIT,fpcr
52.endm
53
54.macro FPU_SAVE_ALL areg,dreg
55 fmov fs0,(\areg+)
56 fmov fs1,(\areg+)
57 fmov fs2,(\areg+)
58 fmov fs3,(\areg+)
59 fmov fs4,(\areg+)
60 fmov fs5,(\areg+)
61 fmov fs6,(\areg+)
62 fmov fs7,(\areg+)
63 fmov fs8,(\areg+)
64 fmov fs9,(\areg+)
65 fmov fs10,(\areg+)
66 fmov fs11,(\areg+)
67 fmov fs12,(\areg+)
68 fmov fs13,(\areg+)
69 fmov fs14,(\areg+)
70 fmov fs15,(\areg+)
71 fmov fs16,(\areg+)
72 fmov fs17,(\areg+)
73 fmov fs18,(\areg+)
74 fmov fs19,(\areg+)
75 fmov fs20,(\areg+)
76 fmov fs21,(\areg+)
77 fmov fs22,(\areg+)
78 fmov fs23,(\areg+)
79 fmov fs24,(\areg+)
80 fmov fs25,(\areg+)
81 fmov fs26,(\areg+)
82 fmov fs27,(\areg+)
83 fmov fs28,(\areg+)
84 fmov fs29,(\areg+)
85 fmov fs30,(\areg+)
86 fmov fs31,(\areg+)
87 fmov fpcr,\dreg
88 mov \dreg,(\areg)
89.endm
90
91.macro FPU_RESTORE_ALL areg,dreg
92 fmov (\areg+),fs0
93 fmov (\areg+),fs1
94 fmov (\areg+),fs2
95 fmov (\areg+),fs3
96 fmov (\areg+),fs4
97 fmov (\areg+),fs5
98 fmov (\areg+),fs6
99 fmov (\areg+),fs7
100 fmov (\areg+),fs8
101 fmov (\areg+),fs9
102 fmov (\areg+),fs10
103 fmov (\areg+),fs11
104 fmov (\areg+),fs12
105 fmov (\areg+),fs13
106 fmov (\areg+),fs14
107 fmov (\areg+),fs15
108 fmov (\areg+),fs16
109 fmov (\areg+),fs17
110 fmov (\areg+),fs18
111 fmov (\areg+),fs19
112 fmov (\areg+),fs20
113 fmov (\areg+),fs21
114 fmov (\areg+),fs22
115 fmov (\areg+),fs23
116 fmov (\areg+),fs24
117 fmov (\areg+),fs25
118 fmov (\areg+),fs26
119 fmov (\areg+),fs27
120 fmov (\areg+),fs28
121 fmov (\areg+),fs29
122 fmov (\areg+),fs30
123 fmov (\areg+),fs31
124 mov (\areg),\dreg
125 fmov \dreg,fpcr
126.endm
63 127
128###############################################################################
129#
130# void fpu_init_state(void)
131# - initialise the FPU
132#
133###############################################################################
134 .globl fpu_init_state
135 .type fpu_init_state,@function
136fpu_init_state:
137 mov epsw,d0
138 or EPSW_FE,epsw
139
140#ifdef CONFIG_MN10300_PROC_MN103E010
141 nop
142 nop
143 nop
144#endif
145 FPU_INIT_STATE_ALL
64#ifdef CONFIG_MN10300_PROC_MN103E010 146#ifdef CONFIG_MN10300_PROC_MN103E010
65 nop 147 nop
66 nop 148 nop
@@ -89,40 +171,7 @@ fpu_save:
89 nop 171 nop
90#endif 172#endif
91 mov d0,a0 173 mov d0,a0
92 fmov fs0,(a0+) 174 FPU_SAVE_ALL a0,d0
93 fmov fs1,(a0+)
94 fmov fs2,(a0+)
95 fmov fs3,(a0+)
96 fmov fs4,(a0+)
97 fmov fs5,(a0+)
98 fmov fs6,(a0+)
99 fmov fs7,(a0+)
100 fmov fs8,(a0+)
101 fmov fs9,(a0+)
102 fmov fs10,(a0+)
103 fmov fs11,(a0+)
104 fmov fs12,(a0+)
105 fmov fs13,(a0+)
106 fmov fs14,(a0+)
107 fmov fs15,(a0+)
108 fmov fs16,(a0+)
109 fmov fs17,(a0+)
110 fmov fs18,(a0+)
111 fmov fs19,(a0+)
112 fmov fs20,(a0+)
113 fmov fs21,(a0+)
114 fmov fs22,(a0+)
115 fmov fs23,(a0+)
116 fmov fs24,(a0+)
117 fmov fs25,(a0+)
118 fmov fs26,(a0+)
119 fmov fs27,(a0+)
120 fmov fs28,(a0+)
121 fmov fs29,(a0+)
122 fmov fs30,(a0+)
123 fmov fs31,(a0+)
124 fmov fpcr,d0
125 mov d0,(a0)
126#ifdef CONFIG_MN10300_PROC_MN103E010 175#ifdef CONFIG_MN10300_PROC_MN103E010
127 nop 176 nop
128 nop 177 nop
@@ -135,63 +184,75 @@ fpu_save:
135 184
136############################################################################### 185###############################################################################
137# 186#
138# void fpu_restore(struct fpu_state_struct *) 187# void fpu_disabled(void)
139# - restore the fpu state 188# - handle an exception due to the FPU being disabled
140# - note that an FPU Operational exception might occur during this process 189# when CONFIG_FPU is enabled
141# 190#
142############################################################################### 191###############################################################################
143 .globl fpu_restore 192 .type fpu_disabled,@function
144 .type fpu_restore,@function 193 .globl fpu_disabled
145fpu_restore: 194fpu_disabled:
146 mov epsw,d1 195 or EPSW_nAR|EPSW_FE,epsw
147 or EPSW_FE,epsw /* enable the FPU so we can access it */
148
149#ifdef CONFIG_MN10300_PROC_MN103E010
150 nop 196 nop
151 nop 197 nop
152#endif
153 mov d0,a0
154 fmov (a0+),fs0
155 fmov (a0+),fs1
156 fmov (a0+),fs2
157 fmov (a0+),fs3
158 fmov (a0+),fs4
159 fmov (a0+),fs5
160 fmov (a0+),fs6
161 fmov (a0+),fs7
162 fmov (a0+),fs8
163 fmov (a0+),fs9
164 fmov (a0+),fs10
165 fmov (a0+),fs11
166 fmov (a0+),fs12
167 fmov (a0+),fs13
168 fmov (a0+),fs14
169 fmov (a0+),fs15
170 fmov (a0+),fs16
171 fmov (a0+),fs17
172 fmov (a0+),fs18
173 fmov (a0+),fs19
174 fmov (a0+),fs20
175 fmov (a0+),fs21
176 fmov (a0+),fs22
177 fmov (a0+),fs23
178 fmov (a0+),fs24
179 fmov (a0+),fs25
180 fmov (a0+),fs26
181 fmov (a0+),fs27
182 fmov (a0+),fs28
183 fmov (a0+),fs29
184 fmov (a0+),fs30
185 fmov (a0+),fs31
186 mov (a0),d0
187 fmov d0,fpcr
188#ifdef CONFIG_MN10300_PROC_MN103E010
189 nop 198 nop
199
200 mov sp,a1
201 mov (a1),d1 /* get epsw of user context */
202 and ~(THREAD_SIZE-1),a1 /* a1: (thread_info *ti) */
203 mov (TI_task,a1),a2 /* a2: (task_struct *tsk) */
204 btst EPSW_nSL,d1
205 beq fpu_used_in_kernel
206
207 or EPSW_FE,d1
208 mov d1,(sp)
209 mov (TASK_THREAD+THREAD_FPU_FLAGS,a2),d1
210#ifndef CONFIG_LAZY_SAVE_FPU
211 or __THREAD_HAS_FPU,d1
212 mov d1,(TASK_THREAD+THREAD_FPU_FLAGS,a2)
213#else /* !CONFIG_LAZY_SAVE_FPU */
214 mov (fpu_state_owner),a0
215 cmp 0,a0
216 beq fpu_regs_save_end
217
218 mov (TASK_THREAD+THREAD_UREGS,a0),a1
219 add TASK_THREAD+THREAD_FPU_STATE,a0
220 FPU_SAVE_ALL a0,d0
221
222 mov (REG_EPSW,a1),d0
223 and ~EPSW_FE,d0
224 mov d0,(REG_EPSW,a1)
225
226fpu_regs_save_end:
227 mov a2,(fpu_state_owner)
228#endif /* !CONFIG_LAZY_SAVE_FPU */
229
230 btst __THREAD_USING_FPU,d1
231 beq fpu_regs_init
232 add TASK_THREAD+THREAD_FPU_STATE,a2
233 FPU_RESTORE_ALL a2,d0
234 rti
235
236fpu_regs_init:
237 FPU_INIT_STATE_ALL
238 add TASK_THREAD+THREAD_FPU_FLAGS,a2
239 bset __THREAD_USING_FPU,(0,a2)
240 rti
241
242fpu_used_in_kernel:
243 and ~(EPSW_nAR|EPSW_FE),epsw
190 nop 244 nop
191 nop 245 nop
192#endif
193 246
194 mov d1,epsw 247 add -4,sp
195 ret [],0 248 SAVE_ALL
249 mov -1,d0
250 mov d0,(REG_ORIG_D0,fp)
251
252 and ~EPSW_NMID,epsw
253
254 mov fp,d0
255 call fpu_disabled_in_kernel[],0
256 jmp ret_from_exception
196 257
197 .size fpu_restore,.-fpu_restore 258 .size fpu_disabled,.-fpu_disabled
diff --git a/arch/mn10300/kernel/fpu-nofpu-low.S b/arch/mn10300/kernel/fpu-nofpu-low.S
new file mode 100644
index 000000000000..7ea087a549f4
--- /dev/null
+++ b/arch/mn10300/kernel/fpu-nofpu-low.S
@@ -0,0 +1,39 @@
1/* MN10300 Low level FPU management operations
2 *
3 * Copyright (C) 2007 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#include <linux/linkage.h>
12#include <asm/cpu-regs.h>
13#include <asm/smp.h>
14#include <asm/thread_info.h>
15#include <asm/asm-offsets.h>
16#include <asm/frame.inc>
17
18###############################################################################
19#
20# void fpu_disabled(void)
21# - handle an exception due to the FPU being disabled
22# when CONFIG_FPU is disabled
23#
24###############################################################################
25 .type fpu_disabled,@function
26 .globl fpu_disabled
27fpu_disabled:
28 add -4,sp
29 SAVE_ALL
30 mov -1,d0
31 mov d0,(REG_ORIG_D0,fp)
32
33 and ~EPSW_NMID,epsw
34
35 mov fp,d0
36 call unexpected_fpu_exception[],0
37 jmp ret_from_exception
38
39 .size fpu_disabled,.-fpu_disabled
diff --git a/arch/mn10300/kernel/fpu-nofpu.c b/arch/mn10300/kernel/fpu-nofpu.c
new file mode 100644
index 000000000000..31c765b92c5d
--- /dev/null
+++ b/arch/mn10300/kernel/fpu-nofpu.c
@@ -0,0 +1,30 @@
1/* MN10300 FPU management
2 *
3 * Copyright (C) 2007 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#include <asm/fpu.h>
12
13/*
14 * handle an FPU operational exception
15 * - there's a possibility that if the FPU is asynchronous, the signal might
16 * be meant for a process other than the current one
17 */
18asmlinkage
19void unexpected_fpu_exception(struct pt_regs *regs, enum exception_code code)
20{
21 panic("An FPU exception was received, but there's no FPU enabled.");
22}
23
24/*
25 * fill in the FPU structure for a core dump
26 */
27int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpreg)
28{
29 return 0; /* not valid */
30}
diff --git a/arch/mn10300/kernel/fpu.c b/arch/mn10300/kernel/fpu.c
index e705f25ad5ff..5f9c3fa19a85 100644
--- a/arch/mn10300/kernel/fpu.c
+++ b/arch/mn10300/kernel/fpu.c
@@ -12,56 +12,19 @@
12#include <asm/fpu.h> 12#include <asm/fpu.h>
13#include <asm/elf.h> 13#include <asm/elf.h>
14#include <asm/exceptions.h> 14#include <asm/exceptions.h>
15#include <asm/system.h>
15 16
17#ifdef CONFIG_LAZY_SAVE_FPU
16struct task_struct *fpu_state_owner; 18struct task_struct *fpu_state_owner;
19#endif
17 20
18/* 21/*
19 * handle an exception due to the FPU being disabled 22 * error functions in FPU disabled exception
20 */ 23 */
21asmlinkage void fpu_disabled(struct pt_regs *regs, enum exception_code code) 24asmlinkage void fpu_disabled_in_kernel(struct pt_regs *regs)
22{ 25{
23 struct task_struct *tsk = current; 26 die_if_no_fixup("An FPU Disabled exception happened in kernel space\n",
24 27 regs, EXCEP_FPU_DISABLED);
25 if (!user_mode(regs))
26 die_if_no_fixup("An FPU Disabled exception happened in"
27 " kernel space\n",
28 regs, code);
29
30#ifdef CONFIG_FPU
31 preempt_disable();
32
33 /* transfer the last process's FPU state to memory */
34 if (fpu_state_owner) {
35 fpu_save(&fpu_state_owner->thread.fpu_state);
36 fpu_state_owner->thread.uregs->epsw &= ~EPSW_FE;
37 }
38
39 /* the current process now owns the FPU state */
40 fpu_state_owner = tsk;
41 regs->epsw |= EPSW_FE;
42
43 /* load the FPU with the current process's FPU state or invent a new
44 * clean one if the process doesn't have one */
45 if (is_using_fpu(tsk)) {
46 fpu_restore(&tsk->thread.fpu_state);
47 } else {
48 fpu_init_state();
49 set_using_fpu(tsk);
50 }
51
52 preempt_enable();
53#else
54 {
55 siginfo_t info;
56
57 info.si_signo = SIGFPE;
58 info.si_errno = 0;
59 info.si_addr = (void *) tsk->thread.uregs->pc;
60 info.si_code = FPE_FLTINV;
61
62 force_sig_info(SIGFPE, &info, tsk);
63 }
64#endif /* CONFIG_FPU */
65} 28}
66 29
67/* 30/*
@@ -71,15 +34,16 @@ asmlinkage void fpu_disabled(struct pt_regs *regs, enum exception_code code)
71 */ 34 */
72asmlinkage void fpu_exception(struct pt_regs *regs, enum exception_code code) 35asmlinkage void fpu_exception(struct pt_regs *regs, enum exception_code code)
73{ 36{
74 struct task_struct *tsk = fpu_state_owner; 37 struct task_struct *tsk = current;
75 siginfo_t info; 38 siginfo_t info;
39 u32 fpcr;
76 40
77 if (!user_mode(regs)) 41 if (!user_mode(regs))
78 die_if_no_fixup("An FPU Operation exception happened in" 42 die_if_no_fixup("An FPU Operation exception happened in"
79 " kernel space\n", 43 " kernel space\n",
80 regs, code); 44 regs, code);
81 45
82 if (!tsk) 46 if (!is_using_fpu(tsk))
83 die_if_no_fixup("An FPU Operation exception happened," 47 die_if_no_fixup("An FPU Operation exception happened,"
84 " but the FPU is not in use", 48 " but the FPU is not in use",
85 regs, code); 49 regs, code);
@@ -89,48 +53,45 @@ asmlinkage void fpu_exception(struct pt_regs *regs, enum exception_code code)
89 info.si_addr = (void *) tsk->thread.uregs->pc; 53 info.si_addr = (void *) tsk->thread.uregs->pc;
90 info.si_code = FPE_FLTINV; 54 info.si_code = FPE_FLTINV;
91 55
92#ifdef CONFIG_FPU 56 unlazy_fpu(tsk);
93 {
94 u32 fpcr;
95 57
96 /* get FPCR (we need to enable the FPU whilst we do this) */ 58 fpcr = tsk->thread.fpu_state.fpcr;
97 asm volatile(" or %1,epsw \n" 59
98#ifdef CONFIG_MN10300_PROC_MN103E010 60 if (fpcr & FPCR_EC_Z)
99 " nop \n" 61 info.si_code = FPE_FLTDIV;
100 " nop \n" 62 else if (fpcr & FPCR_EC_O)
101 " nop \n" 63 info.si_code = FPE_FLTOVF;
102#endif 64 else if (fpcr & FPCR_EC_U)
103 " fmov fpcr,%0 \n" 65 info.si_code = FPE_FLTUND;
104#ifdef CONFIG_MN10300_PROC_MN103E010 66 else if (fpcr & FPCR_EC_I)
105 " nop \n" 67 info.si_code = FPE_FLTRES;
106 " nop \n"
107 " nop \n"
108#endif
109 " and %2,epsw \n"
110 : "=&d"(fpcr)
111 : "i"(EPSW_FE), "i"(~EPSW_FE)
112 );
113
114 if (fpcr & FPCR_EC_Z)
115 info.si_code = FPE_FLTDIV;
116 else if (fpcr & FPCR_EC_O)
117 info.si_code = FPE_FLTOVF;
118 else if (fpcr & FPCR_EC_U)
119 info.si_code = FPE_FLTUND;
120 else if (fpcr & FPCR_EC_I)
121 info.si_code = FPE_FLTRES;
122 }
123#endif
124 68
125 force_sig_info(SIGFPE, &info, tsk); 69 force_sig_info(SIGFPE, &info, tsk);
126} 70}
127 71
128/* 72/*
73 * handle an FPU invalid_op exception
74 * - Derived from DO_EINFO() macro in arch/mn10300/kernel/traps.c
75 */
76asmlinkage void fpu_invalid_op(struct pt_regs *regs, enum exception_code code)
77{
78 siginfo_t info;
79
80 if (!user_mode(regs))
81 die_if_no_fixup("FPU invalid opcode", regs, code);
82
83 info.si_signo = SIGILL;
84 info.si_errno = 0;
85 info.si_code = ILL_COPROC;
86 info.si_addr = (void *) regs->pc;
87 force_sig_info(info.si_signo, &info, current);
88}
89
90/*
129 * save the FPU state to a signal context 91 * save the FPU state to a signal context
130 */ 92 */
131int fpu_setup_sigcontext(struct fpucontext *fpucontext) 93int fpu_setup_sigcontext(struct fpucontext *fpucontext)
132{ 94{
133#ifdef CONFIG_FPU
134 struct task_struct *tsk = current; 95 struct task_struct *tsk = current;
135 96
136 if (!is_using_fpu(tsk)) 97 if (!is_using_fpu(tsk))
@@ -142,11 +103,19 @@ int fpu_setup_sigcontext(struct fpucontext *fpucontext)
142 */ 103 */
143 preempt_disable(); 104 preempt_disable();
144 105
106#ifndef CONFIG_LAZY_SAVE_FPU
107 if (tsk->thread.fpu_flags & THREAD_HAS_FPU) {
108 fpu_save(&tsk->thread.fpu_state);
109 tsk->thread.uregs->epsw &= ~EPSW_FE;
110 tsk->thread.fpu_flags &= ~THREAD_HAS_FPU;
111 }
112#else /* !CONFIG_LAZY_SAVE_FPU */
145 if (fpu_state_owner == tsk) { 113 if (fpu_state_owner == tsk) {
146 fpu_save(&tsk->thread.fpu_state); 114 fpu_save(&tsk->thread.fpu_state);
147 fpu_state_owner->thread.uregs->epsw &= ~EPSW_FE; 115 fpu_state_owner->thread.uregs->epsw &= ~EPSW_FE;
148 fpu_state_owner = NULL; 116 fpu_state_owner = NULL;
149 } 117 }
118#endif /* !CONFIG_LAZY_SAVE_FPU */
150 119
151 preempt_enable(); 120 preempt_enable();
152 121
@@ -161,9 +130,6 @@ int fpu_setup_sigcontext(struct fpucontext *fpucontext)
161 return -1; 130 return -1;
162 131
163 return 1; 132 return 1;
164#else
165 return 0;
166#endif
167} 133}
168 134
169/* 135/*
@@ -171,17 +137,23 @@ int fpu_setup_sigcontext(struct fpucontext *fpucontext)
171 */ 137 */
172void fpu_kill_state(struct task_struct *tsk) 138void fpu_kill_state(struct task_struct *tsk)
173{ 139{
174#ifdef CONFIG_FPU
175 /* disown anything left in the FPU */ 140 /* disown anything left in the FPU */
176 preempt_disable(); 141 preempt_disable();
177 142
143#ifndef CONFIG_LAZY_SAVE_FPU
144 if (tsk->thread.fpu_flags & THREAD_HAS_FPU) {
145 tsk->thread.uregs->epsw &= ~EPSW_FE;
146 tsk->thread.fpu_flags &= ~THREAD_HAS_FPU;
147 }
148#else /* !CONFIG_LAZY_SAVE_FPU */
178 if (fpu_state_owner == tsk) { 149 if (fpu_state_owner == tsk) {
179 fpu_state_owner->thread.uregs->epsw &= ~EPSW_FE; 150 fpu_state_owner->thread.uregs->epsw &= ~EPSW_FE;
180 fpu_state_owner = NULL; 151 fpu_state_owner = NULL;
181 } 152 }
153#endif /* !CONFIG_LAZY_SAVE_FPU */
182 154
183 preempt_enable(); 155 preempt_enable();
184#endif 156
185 /* we no longer have a valid current FPU state */ 157 /* we no longer have a valid current FPU state */
186 clear_using_fpu(tsk); 158 clear_using_fpu(tsk);
187} 159}
@@ -195,8 +167,7 @@ int fpu_restore_sigcontext(struct fpucontext *fpucontext)
195 int ret; 167 int ret;
196 168
197 /* load up the old FPU state */ 169 /* load up the old FPU state */
198 ret = copy_from_user(&tsk->thread.fpu_state, 170 ret = copy_from_user(&tsk->thread.fpu_state, fpucontext,
199 fpucontext,
200 min(sizeof(struct fpu_state_struct), 171 min(sizeof(struct fpu_state_struct),
201 sizeof(struct fpucontext))); 172 sizeof(struct fpucontext)));
202 if (!ret) 173 if (!ret)
diff --git a/arch/mn10300/kernel/gdb-io-serial-low.S b/arch/mn10300/kernel/gdb-io-serial-low.S
index 4998b24f5d3a..b1d0152e96cb 100644
--- a/arch/mn10300/kernel/gdb-io-serial-low.S
+++ b/arch/mn10300/kernel/gdb-io-serial-low.S
@@ -18,6 +18,7 @@
18#include <asm/thread_info.h> 18#include <asm/thread_info.h>
19#include <asm/frame.inc> 19#include <asm/frame.inc>
20#include <asm/intctl-regs.h> 20#include <asm/intctl-regs.h>
21#include <asm/irqflags.h>
21#include <unit/serial.h> 22#include <unit/serial.h>
22 23
23 .text 24 .text
@@ -69,7 +70,7 @@ gdbstub_io_rx_overflow:
69 bra gdbstub_io_rx_done 70 bra gdbstub_io_rx_done
70 71
71gdbstub_io_rx_enter: 72gdbstub_io_rx_enter:
72 or EPSW_IE|EPSW_IM_1,epsw 73 LOCAL_CHANGE_INTR_MASK_LEVEL(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL+1))
73 add -4,sp 74 add -4,sp
74 SAVE_ALL 75 SAVE_ALL
75 76
@@ -80,7 +81,7 @@ gdbstub_io_rx_enter:
80 mov fp,d0 81 mov fp,d0
81 call gdbstub_rx_irq[],0 # gdbstub_rx_irq(regs,excep) 82 call gdbstub_rx_irq[],0 # gdbstub_rx_irq(regs,excep)
82 83
83 and ~EPSW_IE,epsw 84 LOCAL_CLI
84 bclr 0x01,(gdbstub_busy) 85 bclr 0x01,(gdbstub_busy)
85 86
86 .globl gdbstub_return 87 .globl gdbstub_return
diff --git a/arch/mn10300/kernel/gdb-io-serial.c b/arch/mn10300/kernel/gdb-io-serial.c
index ae663dc717e9..0d5d63c91dc3 100644
--- a/arch/mn10300/kernel/gdb-io-serial.c
+++ b/arch/mn10300/kernel/gdb-io-serial.c
@@ -23,6 +23,7 @@
23#include <asm/exceptions.h> 23#include <asm/exceptions.h>
24#include <asm/serial-regs.h> 24#include <asm/serial-regs.h>
25#include <unit/serial.h> 25#include <unit/serial.h>
26#include <asm/smp.h>
26 27
27/* 28/*
28 * initialise the GDB stub 29 * initialise the GDB stub
@@ -45,22 +46,34 @@ void gdbstub_io_init(void)
45 XIRQxICR(GDBPORT_SERIAL_IRQ) = 0; 46 XIRQxICR(GDBPORT_SERIAL_IRQ) = 0;
46 tmp = XIRQxICR(GDBPORT_SERIAL_IRQ); 47 tmp = XIRQxICR(GDBPORT_SERIAL_IRQ);
47 48
49#if CONFIG_GDBSTUB_IRQ_LEVEL == 0
48 IVAR0 = EXCEP_IRQ_LEVEL0; 50 IVAR0 = EXCEP_IRQ_LEVEL0;
49 set_intr_stub(EXCEP_IRQ_LEVEL0, gdbstub_io_rx_handler); 51#elif CONFIG_GDBSTUB_IRQ_LEVEL == 1
52 IVAR1 = EXCEP_IRQ_LEVEL1;
53#elif CONFIG_GDBSTUB_IRQ_LEVEL == 2
54 IVAR2 = EXCEP_IRQ_LEVEL2;
55#elif CONFIG_GDBSTUB_IRQ_LEVEL == 3
56 IVAR3 = EXCEP_IRQ_LEVEL3;
57#elif CONFIG_GDBSTUB_IRQ_LEVEL == 4
58 IVAR4 = EXCEP_IRQ_LEVEL4;
59#elif CONFIG_GDBSTUB_IRQ_LEVEL == 5
60 IVAR5 = EXCEP_IRQ_LEVEL5;
61#else
62#error "Unknown irq level for gdbstub."
63#endif
64
65 set_intr_stub(NUM2EXCEP_IRQ_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL),
66 gdbstub_io_rx_handler);
50 67
51 XIRQxICR(GDBPORT_SERIAL_IRQ) &= ~GxICR_REQUEST; 68 XIRQxICR(GDBPORT_SERIAL_IRQ) &= ~GxICR_REQUEST;
52 XIRQxICR(GDBPORT_SERIAL_IRQ) = GxICR_ENABLE | GxICR_LEVEL_0; 69 XIRQxICR(GDBPORT_SERIAL_IRQ) =
70 GxICR_ENABLE | NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL);
53 tmp = XIRQxICR(GDBPORT_SERIAL_IRQ); 71 tmp = XIRQxICR(GDBPORT_SERIAL_IRQ);
54 72
55 GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI; 73 GDBPORT_SERIAL_IER = UART_IER_RDI | UART_IER_RLSI;
56 74
57 /* permit level 0 IRQs to take place */ 75 /* permit level 0 IRQs to take place */
58 asm volatile( 76 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
59 " and %0,epsw \n"
60 " or %1,epsw \n"
61 :
62 : "i"(~EPSW_IM), "i"(EPSW_IE | EPSW_IM_1)
63 );
64} 77}
65 78
66/* 79/*
@@ -87,6 +100,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
87{ 100{
88 unsigned ix; 101 unsigned ix;
89 u8 ch, st; 102 u8 ch, st;
103#if defined(CONFIG_MN10300_WD_TIMER)
104 int cpu;
105#endif
90 106
91 *_ch = 0xff; 107 *_ch = 0xff;
92 108
@@ -104,8 +120,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
104 if (nonblock) 120 if (nonblock)
105 return -EAGAIN; 121 return -EAGAIN;
106#ifdef CONFIG_MN10300_WD_TIMER 122#ifdef CONFIG_MN10300_WD_TIMER
107 watchdog_alert_counter = 0; 123 for (cpu = 0; cpu < NR_CPUS; cpu++)
108#endif /* CONFIG_MN10300_WD_TIMER */ 124 watchdog_alert_counter[cpu] = 0;
125#endif
109 goto try_again; 126 goto try_again;
110 } 127 }
111 128
diff --git a/arch/mn10300/kernel/gdb-io-ttysm.c b/arch/mn10300/kernel/gdb-io-ttysm.c
index a560bbc3137d..97dfda23342c 100644
--- a/arch/mn10300/kernel/gdb-io-ttysm.c
+++ b/arch/mn10300/kernel/gdb-io-ttysm.c
@@ -58,9 +58,12 @@ void __init gdbstub_io_init(void)
58 gdbstub_io_set_baud(115200); 58 gdbstub_io_set_baud(115200);
59 59
60 /* we want to get serial receive interrupts */ 60 /* we want to get serial receive interrupts */
61 set_intr_level(gdbstub_port->rx_irq, GxICR_LEVEL_0); 61 set_intr_level(gdbstub_port->rx_irq,
62 set_intr_level(gdbstub_port->tx_irq, GxICR_LEVEL_0); 62 NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL));
63 set_intr_stub(EXCEP_IRQ_LEVEL0, gdbstub_io_rx_handler); 63 set_intr_level(gdbstub_port->tx_irq,
64 NUM2GxICR_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL));
65 set_intr_stub(NUM2EXCEP_IRQ_LEVEL(CONFIG_GDBSTUB_IRQ_LEVEL),
66 gdbstub_io_rx_handler);
64 67
65 *gdbstub_port->rx_icr |= GxICR_ENABLE; 68 *gdbstub_port->rx_icr |= GxICR_ENABLE;
66 tmp = *gdbstub_port->rx_icr; 69 tmp = *gdbstub_port->rx_icr;
@@ -84,12 +87,7 @@ void __init gdbstub_io_init(void)
84 tmp = *gdbstub_port->_control; 87 tmp = *gdbstub_port->_control;
85 88
86 /* permit level 0 IRQs only */ 89 /* permit level 0 IRQs only */
87 asm volatile( 90 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
88 " and %0,epsw \n"
89 " or %1,epsw \n"
90 :
91 : "i"(~EPSW_IM), "i"(EPSW_IE|EPSW_IM_1)
92 );
93} 91}
94 92
95/* 93/*
@@ -184,6 +182,9 @@ int gdbstub_io_rx_char(unsigned char *_ch, int nonblock)
184{ 182{
185 unsigned ix; 183 unsigned ix;
186 u8 ch, st; 184 u8 ch, st;
185#if defined(CONFIG_MN10300_WD_TIMER)
186 int cpu;
187#endif
187 188
188 *_ch = 0xff; 189 *_ch = 0xff;
189 190
@@ -201,8 +202,9 @@ try_again:
201 if (nonblock) 202 if (nonblock)
202 return -EAGAIN; 203 return -EAGAIN;
203#ifdef CONFIG_MN10300_WD_TIMER 204#ifdef CONFIG_MN10300_WD_TIMER
204 watchdog_alert_counter = 0; 205 for (cpu = 0; cpu < NR_CPUS; cpu++)
205#endif /* CONFIG_MN10300_WD_TIMER */ 206 watchdog_alert_counter[cpu] = 0;
207#endif
206 goto try_again; 208 goto try_again;
207 } 209 }
208 210
diff --git a/arch/mn10300/kernel/gdb-stub.c b/arch/mn10300/kernel/gdb-stub.c
index 41b11706c8ed..a5fc3f05309b 100644
--- a/arch/mn10300/kernel/gdb-stub.c
+++ b/arch/mn10300/kernel/gdb-stub.c
@@ -440,15 +440,11 @@ static const unsigned char gdbstub_insn_sizes[256] =
440 440
441static int __gdbstub_mark_bp(u8 *addr, int ix) 441static int __gdbstub_mark_bp(u8 *addr, int ix)
442{ 442{
443 if (addr < (u8 *) 0x70000000UL) 443 /* vmalloc area */
444 return 0; 444 if (((u8 *) VMALLOC_START <= addr) && (addr < (u8 *) VMALLOC_END))
445 /* 70000000-7fffffff: vmalloc area */
446 if (addr < (u8 *) 0x80000000UL)
447 goto okay; 445 goto okay;
448 if (addr < (u8 *) 0x8c000000UL) 446 /* SRAM, SDRAM */
449 return 0; 447 if (((u8 *) 0x80000000UL <= addr) && (addr < (u8 *) 0xa0000000UL))
450 /* 8c000000-93ffffff: SRAM, SDRAM */
451 if (addr < (u8 *) 0x94000000UL)
452 goto okay; 448 goto okay;
453 return 0; 449 return 0;
454 450
@@ -1197,9 +1193,8 @@ static int gdbstub(struct pt_regs *regs, enum exception_code excep)
1197 mn10300_set_gdbleds(1); 1193 mn10300_set_gdbleds(1);
1198 1194
1199 asm volatile("mov mdr,%0" : "=d"(mdr)); 1195 asm volatile("mov mdr,%0" : "=d"(mdr));
1200 asm volatile("mov epsw,%0" : "=d"(epsw)); 1196 local_save_flags(epsw);
1201 asm volatile("mov %0,epsw" 1197 local_change_intr_mask_level(NUM2EPSW_IM(CONFIG_GDBSTUB_IRQ_LEVEL + 1));
1202 :: "d"((epsw & ~EPSW_IM) | EPSW_IE | EPSW_IM_1));
1203 1198
1204 gdbstub_store_fpu(); 1199 gdbstub_store_fpu();
1205 1200
diff --git a/arch/mn10300/kernel/head.S b/arch/mn10300/kernel/head.S
index 14f27f3bfaf4..73e00fc78072 100644
--- a/arch/mn10300/kernel/head.S
+++ b/arch/mn10300/kernel/head.S
@@ -19,6 +19,12 @@
19#include <asm/frame.inc> 19#include <asm/frame.inc>
20#include <asm/param.h> 20#include <asm/param.h>
21#include <unit/serial.h> 21#include <unit/serial.h>
22#ifdef CONFIG_SMP
23#include <asm/smp.h>
24#include <asm/intctl-regs.h>
25#include <asm/cpu-regs.h>
26#include <proc/smp-regs.h>
27#endif /* CONFIG_SMP */
22 28
23 __HEAD 29 __HEAD
24 30
@@ -30,17 +36,51 @@
30 .globl _start 36 .globl _start
31 .type _start,@function 37 .type _start,@function
32_start: 38_start:
39#ifdef CONFIG_SMP
40 #
41 # If this is a secondary CPU (AP), then deal with that elsewhere
42 #
43 mov (CPUID),d3
44 and CPUID_MASK,d3
45 bne startup_secondary
46
47 #
48 # We're dealing with the primary CPU (BP) here, then.
49 # Keep BP's D0,D1,D2 register for boot check.
50 #
51
52 # Set up the Boot IPI for each secondary CPU
53 mov 0x1,a0
54loop_set_secondary_icr:
55 mov a0,a1
56 asl CROSS_ICR_CPU_SHIFT,a1
57 add CROSS_GxICR(SMP_BOOT_IRQ,0),a1
58 movhu (a1),d3
59 or GxICR_ENABLE|GxICR_LEVEL_0,d3
60 movhu d3,(a1)
61 movhu (a1),d3 # flush
62 inc a0
63 cmp NR_CPUS,a0
64 bne loop_set_secondary_icr
65#endif /* CONFIG_SMP */
66
33 # save commandline pointer 67 # save commandline pointer
34 mov d0,a3 68 mov d0,a3
35 69
36 # preload the PGD pointer register 70 # preload the PGD pointer register
37 mov swapper_pg_dir,d0 71 mov swapper_pg_dir,d0
38 mov d0,(PTBR) 72 mov d0,(PTBR)
73 clr d0
74 movbu d0,(PIDR)
39 75
40 # turn on the TLBs 76 # turn on the TLBs
41 mov MMUCTR_IIV|MMUCTR_DIV,d0 77 mov MMUCTR_IIV|MMUCTR_DIV,d0
42 mov d0,(MMUCTR) 78 mov d0,(MMUCTR)
79#ifdef CONFIG_AM34_2
80 mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE|MMUCTR_WTE,d0
81#else
43 mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0 82 mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0
83#endif
44 mov d0,(MMUCTR) 84 mov d0,(MMUCTR)
45 85
46 # turn on AM33v2 exception handling mode and set the trap table base 86 # turn on AM33v2 exception handling mode and set the trap table base
@@ -51,6 +91,11 @@ _start:
51 mov d0,(TBR) 91 mov d0,(TBR)
52 92
53 # invalidate and enable both of the caches 93 # invalidate and enable both of the caches
94#ifdef CONFIG_SMP
95 mov ECHCTR,a0
96 clr d0
97 mov d0,(a0)
98#endif
54 mov CHCTR,a0 99 mov CHCTR,a0
55 clr d0 100 clr d0
56 movhu d0,(a0) # turn off first 101 movhu d0,(a0) # turn off first
@@ -61,18 +106,18 @@ _start:
61 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy 106 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
62 lne 107 lne
63 108
64#ifndef CONFIG_MN10300_CACHE_DISABLED 109#ifdef CONFIG_MN10300_CACHE_ENABLED
65#ifdef CONFIG_MN10300_CACHE_WBACK 110#ifdef CONFIG_MN10300_CACHE_WBACK
66#ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC 111#ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC
67 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0 112 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
68#else 113#else
69 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0 114 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0
70#endif /* CACHE_DISABLED */ 115#endif /* NOWRALLOC */
71#else 116#else
72 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0 117 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
73#endif /* WBACK */ 118#endif /* WBACK */
74 movhu d0,(a0) # enable 119 movhu d0,(a0) # enable
75#endif /* NOWRALLOC */ 120#endif /* ENABLED */
76 121
77 # turn on RTS on the debug serial port if applicable 122 # turn on RTS on the debug serial port if applicable
78#ifdef CONFIG_MN10300_UNIT_ASB2305 123#ifdef CONFIG_MN10300_UNIT_ASB2305
@@ -206,6 +251,44 @@ __no_parameters:
206 call processor_init[],0 251 call processor_init[],0
207 call unit_init[],0 252 call unit_init[],0
208 253
254#ifdef CONFIG_SMP
255 # mark the primary CPU in cpu_boot_map
256 mov cpu_boot_map,a0
257 mov 0x1,d0
258 mov d0,(a0)
259
260 # signal each secondary CPU to begin booting
261 mov 0x1,d2 # CPU ID
262
263loop_request_boot_secondary:
264 mov d2,a0
265 # send SMP_BOOT_IPI to secondary CPU
266 asl CROSS_ICR_CPU_SHIFT,a0
267 add CROSS_GxICR(SMP_BOOT_IRQ,0),a0
268 movhu (a0),d0
269 or GxICR_REQUEST|GxICR_DETECT,d0
270 movhu d0,(a0)
271 movhu (a0),d0 # flush
272
273 # wait up to 100ms for AP's IPI to be received
274 clr d3
275wait_on_secondary_boot:
276 mov DELAY_TIME_BOOT_IPI,d0
277 call __delay[],0
278 inc d3
279 mov cpu_boot_map,a0
280 mov (a0),d0
281 lsr d2,d0
282 btst 0x1,d0
283 bne 1f
284 cmp TIME_OUT_COUNT_BOOT_IPI,d3
285 bne wait_on_secondary_boot
2861:
287 inc d2
288 cmp NR_CPUS,d2
289 bne loop_request_boot_secondary
290#endif /* CONFIG_SMP */
291
209#ifdef CONFIG_GDBSTUB 292#ifdef CONFIG_GDBSTUB
210 call gdbstub_init[],0 293 call gdbstub_init[],0
211 294
@@ -217,7 +300,118 @@ __gdbstub_pause:
217#endif 300#endif
218 301
219 jmp start_kernel 302 jmp start_kernel
220 .size _start, _start-. 303 .size _start,.-_start
304
305###############################################################################
306#
307# Secondary CPU boot point
308#
309###############################################################################
310#ifdef CONFIG_SMP
311startup_secondary:
312 # preload the PGD pointer register
313 mov swapper_pg_dir,d0
314 mov d0,(PTBR)
315 clr d0
316 movbu d0,(PIDR)
317
318 # turn on the TLBs
319 mov MMUCTR_IIV|MMUCTR_DIV,d0
320 mov d0,(MMUCTR)
321#ifdef CONFIG_AM34_2
322 mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE|MMUCTR_WTE,d0
323#else
324 mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0
325#endif
326 mov d0,(MMUCTR)
327
328 # turn on AM33v2 exception handling mode and set the trap table base
329 movhu (CPUP),d0
330 or CPUP_EXM_AM33V2,d0
331 movhu d0,(CPUP)
332
333 # set the interrupt vector table
334 mov CONFIG_INTERRUPT_VECTOR_BASE,d0
335 mov d0,(TBR)
336
337 # invalidate and enable both of the caches
338 mov ECHCTR,a0
339 clr d0
340 mov d0,(a0)
341 mov CHCTR,a0
342 clr d0
343 movhu d0,(a0) # turn off first
344 mov CHCTR_ICINV|CHCTR_DCINV,d0
345 movhu d0,(a0)
346 setlb
347 mov (a0),d0
348 btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy (use CPU loop buffer)
349 lne
350
351#ifdef CONFIG_MN10300_CACHE_ENABLED
352#ifdef CONFIG_MN10300_CACHE_WBACK
353#ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC
354 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
355#else
356 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0
357#endif /* !NOWRALLOC */
358#else
359 mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
360#endif /* WBACK */
361 movhu d0,(a0) # enable
362#endif /* ENABLED */
363
364 # Clear the boot IPI interrupt for this CPU
365 movhu (GxICR(SMP_BOOT_IRQ)),d0
366 and ~GxICR_REQUEST,d0
367 movhu d0,(GxICR(SMP_BOOT_IRQ))
368 movhu (GxICR(SMP_BOOT_IRQ)),d0 # flush
369
370 /* get stack */
371 mov CONFIG_INTERRUPT_VECTOR_BASE + CONFIG_BOOT_STACK_OFFSET,a0
372 mov (CPUID),d0
373 and CPUID_MASK,d0
374 mulu CONFIG_BOOT_STACK_SIZE,d0
375 sub d0,a0
376 mov a0,sp
377
378 # init interrupt for AP
379 call smp_prepare_cpu_init[],0
380
381 # mark this secondary CPU in cpu_boot_map
382 mov (CPUID),d0
383 mov 0x1,d1
384 asl d0,d1
385 mov cpu_boot_map,a0
386 bset d1,(a0)
387
388 or EPSW_IE|EPSW_IM_1,epsw # permit level 0 interrupts
389 nop
390 nop
391#ifdef CONFIG_MN10300_CACHE_WBACK
392 # flush the local cache if it's in writeback mode
393 call mn10300_local_dcache_flush_inv[],0
394 setlb
395 mov (CHCTR),d0
396 btst CHCTR_DCBUSY,d0 # wait till not busy (use CPU loop buffer)
397 lne
398#endif
399
400 # now sleep waiting for further instructions
401secondary_sleep:
402 mov CPUM_SLEEP,d0
403 movhu d0,(CPUM)
404 nop
405 nop
406 bra secondary_sleep
407 .size startup_secondary,.-startup_secondary
408#endif /* CONFIG_SMP */
409
410###############################################################################
411#
412#
413#
414###############################################################################
221ENTRY(__head_end) 415ENTRY(__head_end)
222 416
223/* 417/*
diff --git a/arch/mn10300/kernel/internal.h b/arch/mn10300/kernel/internal.h
index eee2eee86267..6a064ab5af07 100644
--- a/arch/mn10300/kernel/internal.h
+++ b/arch/mn10300/kernel/internal.h
@@ -9,6 +9,9 @@
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11 11
12struct clocksource;
13struct clock_event_device;
14
12/* 15/*
13 * kthread.S 16 * kthread.S
14 */ 17 */
@@ -18,3 +21,25 @@ extern int kernel_thread_helper(int);
18 * entry.S 21 * entry.S
19 */ 22 */
20extern void ret_from_fork(struct task_struct *) __attribute__((noreturn)); 23extern void ret_from_fork(struct task_struct *) __attribute__((noreturn));
24
25/*
26 * smp-low.S
27 */
28#ifdef CONFIG_SMP
29extern void mn10300_low_ipi_handler(void);
30#endif
31
32/*
33 * time.c
34 */
35extern irqreturn_t local_timer_interrupt(void);
36
37/*
38 * time.c
39 */
40#ifdef CONFIG_CEVT_MN10300
41extern void clockevent_set_clock(struct clock_event_device *, unsigned int);
42#endif
43#ifdef CONFIG_CSRC_MN10300
44extern void clocksource_set_clock(struct clocksource *, unsigned int);
45#endif
diff --git a/arch/mn10300/kernel/irq.c b/arch/mn10300/kernel/irq.c
index e2d5ed891f37..c2e44597c22b 100644
--- a/arch/mn10300/kernel/irq.c
+++ b/arch/mn10300/kernel/irq.c
@@ -12,11 +12,26 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/kernel_stat.h> 13#include <linux/kernel_stat.h>
14#include <linux/seq_file.h> 14#include <linux/seq_file.h>
15#include <linux/cpumask.h>
15#include <asm/setup.h> 16#include <asm/setup.h>
17#include <asm/serial-regs.h>
16 18
17unsigned long __mn10300_irq_enabled_epsw = EPSW_IE | EPSW_IM_7; 19unsigned long __mn10300_irq_enabled_epsw[NR_CPUS] __cacheline_aligned_in_smp = {
20 [0 ... NR_CPUS - 1] = EPSW_IE | EPSW_IM_7
21};
18EXPORT_SYMBOL(__mn10300_irq_enabled_epsw); 22EXPORT_SYMBOL(__mn10300_irq_enabled_epsw);
19 23
24#ifdef CONFIG_SMP
25static char irq_affinity_online[NR_IRQS] = {
26 [0 ... NR_IRQS - 1] = 0
27};
28
29#define NR_IRQ_WORDS ((NR_IRQS + 31) / 32)
30static unsigned long irq_affinity_request[NR_IRQ_WORDS] = {
31 [0 ... NR_IRQ_WORDS - 1] = 0
32};
33#endif /* CONFIG_SMP */
34
20atomic_t irq_err_count; 35atomic_t irq_err_count;
21 36
22/* 37/*
@@ -24,30 +39,67 @@ atomic_t irq_err_count;
24 */ 39 */
25static void mn10300_cpupic_ack(unsigned int irq) 40static void mn10300_cpupic_ack(unsigned int irq)
26{ 41{
42 unsigned long flags;
27 u16 tmp; 43 u16 tmp;
28 *(volatile u8 *) &GxICR(irq) = GxICR_DETECT; 44
45 flags = arch_local_cli_save();
46 GxICR_u8(irq) = GxICR_DETECT;
29 tmp = GxICR(irq); 47 tmp = GxICR(irq);
48 arch_local_irq_restore(flags);
30} 49}
31 50
32static void mn10300_cpupic_mask(unsigned int irq) 51static void __mask_and_set_icr(unsigned int irq,
52 unsigned int mask, unsigned int set)
33{ 53{
34 u16 tmp = GxICR(irq); 54 unsigned long flags;
35 GxICR(irq) = (tmp & GxICR_LEVEL); 55 u16 tmp;
56
57 flags = arch_local_cli_save();
58 tmp = GxICR(irq);
59 GxICR(irq) = (tmp & mask) | set;
36 tmp = GxICR(irq); 60 tmp = GxICR(irq);
61 arch_local_irq_restore(flags);
62}
63
64static void mn10300_cpupic_mask(unsigned int irq)
65{
66 __mask_and_set_icr(irq, GxICR_LEVEL, 0);
37} 67}
38 68
39static void mn10300_cpupic_mask_ack(unsigned int irq) 69static void mn10300_cpupic_mask_ack(unsigned int irq)
40{ 70{
41 u16 tmp = GxICR(irq); 71#ifdef CONFIG_SMP
42 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_DETECT; 72 unsigned long flags;
43 tmp = GxICR(irq); 73 u16 tmp;
74
75 flags = arch_local_cli_save();
76
77 if (!test_and_clear_bit(irq, irq_affinity_request)) {
78 tmp = GxICR(irq);
79 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_DETECT;
80 tmp = GxICR(irq);
81 } else {
82 u16 tmp2;
83 tmp = GxICR(irq);
84 GxICR(irq) = (tmp & GxICR_LEVEL);
85 tmp2 = GxICR(irq);
86
87 irq_affinity_online[irq] =
88 any_online_cpu(*irq_desc[irq].affinity);
89 CROSS_GxICR(irq, irq_affinity_online[irq]) =
90 (tmp & (GxICR_LEVEL | GxICR_ENABLE)) | GxICR_DETECT;
91 tmp = CROSS_GxICR(irq, irq_affinity_online[irq]);
92 }
93
94 arch_local_irq_restore(flags);
95#else /* CONFIG_SMP */
96 __mask_and_set_icr(irq, GxICR_LEVEL, GxICR_DETECT);
97#endif /* CONFIG_SMP */
44} 98}
45 99
46static void mn10300_cpupic_unmask(unsigned int irq) 100static void mn10300_cpupic_unmask(unsigned int irq)
47{ 101{
48 u16 tmp = GxICR(irq); 102 __mask_and_set_icr(irq, GxICR_LEVEL, GxICR_ENABLE);
49 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE;
50 tmp = GxICR(irq);
51} 103}
52 104
53static void mn10300_cpupic_unmask_clear(unsigned int irq) 105static void mn10300_cpupic_unmask_clear(unsigned int irq)
@@ -56,11 +108,89 @@ static void mn10300_cpupic_unmask_clear(unsigned int irq)
56 * device has ceased to assert its interrupt line and the interrupt 108 * device has ceased to assert its interrupt line and the interrupt
57 * channel has been disabled in the PIC, so for level-triggered 109 * channel has been disabled in the PIC, so for level-triggered
58 * interrupts we need to clear the request bit when we re-enable */ 110 * interrupts we need to clear the request bit when we re-enable */
59 u16 tmp = GxICR(irq); 111#ifdef CONFIG_SMP
60 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT; 112 unsigned long flags;
61 tmp = GxICR(irq); 113 u16 tmp;
114
115 flags = arch_local_cli_save();
116
117 if (!test_and_clear_bit(irq, irq_affinity_request)) {
118 tmp = GxICR(irq);
119 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT;
120 tmp = GxICR(irq);
121 } else {
122 tmp = GxICR(irq);
123
124 irq_affinity_online[irq] = any_online_cpu(*irq_desc[irq].affinity);
125 CROSS_GxICR(irq, irq_affinity_online[irq]) = (tmp & GxICR_LEVEL) | GxICR_ENABLE | GxICR_DETECT;
126 tmp = CROSS_GxICR(irq, irq_affinity_online[irq]);
127 }
128
129 arch_local_irq_restore(flags);
130#else /* CONFIG_SMP */
131 __mask_and_set_icr(irq, GxICR_LEVEL, GxICR_ENABLE | GxICR_DETECT);
132#endif /* CONFIG_SMP */
62} 133}
63 134
135#ifdef CONFIG_SMP
136static int
137mn10300_cpupic_setaffinity(unsigned int irq, const struct cpumask *mask)
138{
139 unsigned long flags;
140 int err;
141
142 flags = arch_local_cli_save();
143
144 /* check irq no */
145 switch (irq) {
146 case TMJCIRQ:
147 case RESCHEDULE_IPI:
148 case CALL_FUNC_SINGLE_IPI:
149 case LOCAL_TIMER_IPI:
150 case FLUSH_CACHE_IPI:
151 case CALL_FUNCTION_NMI_IPI:
152 case GDB_NMI_IPI:
153#ifdef CONFIG_MN10300_TTYSM0
154 case SC0RXIRQ:
155 case SC0TXIRQ:
156#ifdef CONFIG_MN10300_TTYSM0_TIMER8
157 case TM8IRQ:
158#elif CONFIG_MN10300_TTYSM0_TIMER2
159 case TM2IRQ:
160#endif /* CONFIG_MN10300_TTYSM0_TIMER8 */
161#endif /* CONFIG_MN10300_TTYSM0 */
162
163#ifdef CONFIG_MN10300_TTYSM1
164 case SC1RXIRQ:
165 case SC1TXIRQ:
166#ifdef CONFIG_MN10300_TTYSM1_TIMER12
167 case TM12IRQ:
168#elif CONFIG_MN10300_TTYSM1_TIMER9
169 case TM9IRQ:
170#elif CONFIG_MN10300_TTYSM1_TIMER3
171 case TM3IRQ:
172#endif /* CONFIG_MN10300_TTYSM1_TIMER12 */
173#endif /* CONFIG_MN10300_TTYSM1 */
174
175#ifdef CONFIG_MN10300_TTYSM2
176 case SC2RXIRQ:
177 case SC2TXIRQ:
178 case TM10IRQ:
179#endif /* CONFIG_MN10300_TTYSM2 */
180 err = -1;
181 break;
182
183 default:
184 set_bit(irq, irq_affinity_request);
185 err = 0;
186 break;
187 }
188
189 arch_local_irq_restore(flags);
190 return err;
191}
192#endif /* CONFIG_SMP */
193
64/* 194/*
65 * MN10300 PIC level-triggered IRQ handling. 195 * MN10300 PIC level-triggered IRQ handling.
66 * 196 *
@@ -79,6 +209,9 @@ static struct irq_chip mn10300_cpu_pic_level = {
79 .mask = mn10300_cpupic_mask, 209 .mask = mn10300_cpupic_mask,
80 .mask_ack = mn10300_cpupic_mask, 210 .mask_ack = mn10300_cpupic_mask,
81 .unmask = mn10300_cpupic_unmask_clear, 211 .unmask = mn10300_cpupic_unmask_clear,
212#ifdef CONFIG_SMP
213 .set_affinity = mn10300_cpupic_setaffinity,
214#endif
82}; 215};
83 216
84/* 217/*
@@ -94,6 +227,9 @@ static struct irq_chip mn10300_cpu_pic_edge = {
94 .mask = mn10300_cpupic_mask, 227 .mask = mn10300_cpupic_mask,
95 .mask_ack = mn10300_cpupic_mask_ack, 228 .mask_ack = mn10300_cpupic_mask_ack,
96 .unmask = mn10300_cpupic_unmask, 229 .unmask = mn10300_cpupic_unmask,
230#ifdef CONFIG_SMP
231 .set_affinity = mn10300_cpupic_setaffinity,
232#endif
97}; 233};
98 234
99/* 235/*
@@ -111,14 +247,34 @@ void ack_bad_irq(int irq)
111 */ 247 */
112void set_intr_level(int irq, u16 level) 248void set_intr_level(int irq, u16 level)
113{ 249{
114 u16 tmp; 250 BUG_ON(in_interrupt());
115 251
116 if (in_interrupt()) 252 __mask_and_set_icr(irq, GxICR_ENABLE, level);
117 BUG(); 253}
118 254
119 tmp = GxICR(irq); 255void mn10300_intc_set_level(unsigned int irq, unsigned int level)
120 GxICR(irq) = (tmp & GxICR_ENABLE) | level; 256{
121 tmp = GxICR(irq); 257 set_intr_level(irq, NUM2GxICR_LEVEL(level) & GxICR_LEVEL);
258}
259
260void mn10300_intc_clear(unsigned int irq)
261{
262 __mask_and_set_icr(irq, GxICR_LEVEL | GxICR_ENABLE, GxICR_DETECT);
263}
264
265void mn10300_intc_set(unsigned int irq)
266{
267 __mask_and_set_icr(irq, 0, GxICR_REQUEST | GxICR_DETECT);
268}
269
270void mn10300_intc_enable(unsigned int irq)
271{
272 mn10300_cpupic_unmask(irq);
273}
274
275void mn10300_intc_disable(unsigned int irq)
276{
277 mn10300_cpupic_mask(irq);
122} 278}
123 279
124/* 280/*
@@ -126,7 +282,7 @@ void set_intr_level(int irq, u16 level)
126 * than before 282 * than before
127 * - see Documentation/mn10300/features.txt 283 * - see Documentation/mn10300/features.txt
128 */ 284 */
129void set_intr_postackable(int irq) 285void mn10300_set_lateack_irq_type(int irq)
130{ 286{
131 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_level, 287 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_level,
132 handle_level_irq); 288 handle_level_irq);
@@ -147,6 +303,7 @@ void __init init_IRQ(void)
147 * interrupts */ 303 * interrupts */
148 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_edge, 304 set_irq_chip_and_handler(irq, &mn10300_cpu_pic_edge,
149 handle_level_irq); 305 handle_level_irq);
306
150 unit_init_IRQ(); 307 unit_init_IRQ();
151} 308}
152 309
@@ -156,20 +313,22 @@ void __init init_IRQ(void)
156asmlinkage void do_IRQ(void) 313asmlinkage void do_IRQ(void)
157{ 314{
158 unsigned long sp, epsw, irq_disabled_epsw, old_irq_enabled_epsw; 315 unsigned long sp, epsw, irq_disabled_epsw, old_irq_enabled_epsw;
316 unsigned int cpu_id = smp_processor_id();
159 int irq; 317 int irq;
160 318
161 sp = current_stack_pointer(); 319 sp = current_stack_pointer();
162 if (sp - (sp & ~(THREAD_SIZE - 1)) < STACK_WARN) 320 BUG_ON(sp - (sp & ~(THREAD_SIZE - 1)) < STACK_WARN);
163 BUG();
164 321
165 /* make sure local_irq_enable() doesn't muck up the interrupt priority 322 /* make sure local_irq_enable() doesn't muck up the interrupt priority
166 * setting in EPSW */ 323 * setting in EPSW */
167 old_irq_enabled_epsw = __mn10300_irq_enabled_epsw; 324 old_irq_enabled_epsw = __mn10300_irq_enabled_epsw[cpu_id];
168 local_save_flags(epsw); 325 local_save_flags(epsw);
169 __mn10300_irq_enabled_epsw = EPSW_IE | (EPSW_IM & epsw); 326 __mn10300_irq_enabled_epsw[cpu_id] = EPSW_IE | (EPSW_IM & epsw);
170 irq_disabled_epsw = EPSW_IE | MN10300_CLI_LEVEL; 327 irq_disabled_epsw = EPSW_IE | MN10300_CLI_LEVEL;
171 328
172 __IRQ_STAT(smp_processor_id(), __irq_count)++; 329#ifdef CONFIG_MN10300_WD_TIMER
330 __IRQ_STAT(cpu_id, __irq_count)++;
331#endif
173 332
174 irq_enter(); 333 irq_enter();
175 334
@@ -189,7 +348,7 @@ asmlinkage void do_IRQ(void)
189 local_irq_restore(epsw); 348 local_irq_restore(epsw);
190 } 349 }
191 350
192 __mn10300_irq_enabled_epsw = old_irq_enabled_epsw; 351 __mn10300_irq_enabled_epsw[cpu_id] = old_irq_enabled_epsw;
193 352
194 irq_exit(); 353 irq_exit();
195} 354}
@@ -222,9 +381,16 @@ int show_interrupts(struct seq_file *p, void *v)
222 seq_printf(p, "%3d: ", i); 381 seq_printf(p, "%3d: ", i);
223 for_each_present_cpu(cpu) 382 for_each_present_cpu(cpu)
224 seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu)); 383 seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu));
225 seq_printf(p, " %14s.%u", irq_desc[i].chip->name, 384
226 (GxICR(i) & GxICR_LEVEL) >> 385 if (i < NR_CPU_IRQS)
227 GxICR_LEVEL_SHIFT); 386 seq_printf(p, " %14s.%u",
387 irq_desc[i].chip->name,
388 (GxICR(i) & GxICR_LEVEL) >>
389 GxICR_LEVEL_SHIFT);
390 else
391 seq_printf(p, " %14s",
392 irq_desc[i].chip->name);
393
228 seq_printf(p, " %s", action->name); 394 seq_printf(p, " %s", action->name);
229 395
230 for (action = action->next; 396 for (action = action->next;
@@ -240,11 +406,13 @@ int show_interrupts(struct seq_file *p, void *v)
240 406
241 /* polish off with NMI and error counters */ 407 /* polish off with NMI and error counters */
242 case NR_IRQS: 408 case NR_IRQS:
409#ifdef CONFIG_MN10300_WD_TIMER
243 seq_printf(p, "NMI: "); 410 seq_printf(p, "NMI: ");
244 for (j = 0; j < NR_CPUS; j++) 411 for (j = 0; j < NR_CPUS; j++)
245 if (cpu_online(j)) 412 if (cpu_online(j))
246 seq_printf(p, "%10u ", nmi_count(j)); 413 seq_printf(p, "%10u ", nmi_count(j));
247 seq_putc(p, '\n'); 414 seq_putc(p, '\n');
415#endif
248 416
249 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); 417 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
250 break; 418 break;
@@ -252,3 +420,51 @@ int show_interrupts(struct seq_file *p, void *v)
252 420
253 return 0; 421 return 0;
254} 422}
423
424#ifdef CONFIG_HOTPLUG_CPU
425void migrate_irqs(void)
426{
427 irq_desc_t *desc;
428 int irq;
429 unsigned int self, new;
430 unsigned long flags;
431
432 self = smp_processor_id();
433 for (irq = 0; irq < NR_IRQS; irq++) {
434 desc = irq_desc + irq;
435
436 if (desc->status == IRQ_PER_CPU)
437 continue;
438
439 if (cpu_isset(self, irq_desc[irq].affinity) &&
440 !cpus_intersects(irq_affinity[irq], cpu_online_map)) {
441 int cpu_id;
442 cpu_id = first_cpu(cpu_online_map);
443 cpu_set(cpu_id, irq_desc[irq].affinity);
444 }
445 /* We need to operate irq_affinity_online atomically. */
446 arch_local_cli_save(flags);
447 if (irq_affinity_online[irq] == self) {
448 u16 x, tmp;
449
450 x = GxICR(irq);
451 GxICR(irq) = x & GxICR_LEVEL;
452 tmp = GxICR(irq);
453
454 new = any_online_cpu(irq_desc[irq].affinity);
455 irq_affinity_online[irq] = new;
456
457 CROSS_GxICR(irq, new) =
458 (x & GxICR_LEVEL) | GxICR_DETECT;
459 tmp = CROSS_GxICR(irq, new);
460
461 x &= GxICR_LEVEL | GxICR_ENABLE;
462 if (GxICR(irq) & GxICR_REQUEST) {
463 x |= GxICR_REQUEST | GxICR_DETECT;
464 CROSS_GxICR(irq, new) = x;
465 tmp = CROSS_GxICR(irq, new);
466 }
467 arch_local_irq_restore(flags);
468 }
469}
470#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/mn10300/kernel/kprobes.c b/arch/mn10300/kernel/kprobes.c
index 67e6389d625a..0311a7fcea16 100644
--- a/arch/mn10300/kernel/kprobes.c
+++ b/arch/mn10300/kernel/kprobes.c
@@ -377,8 +377,10 @@ void __kprobes arch_arm_kprobe(struct kprobe *p)
377 377
378void __kprobes arch_disarm_kprobe(struct kprobe *p) 378void __kprobes arch_disarm_kprobe(struct kprobe *p)
379{ 379{
380#ifndef CONFIG_MN10300_CACHE_SNOOP
380 mn10300_dcache_flush(); 381 mn10300_dcache_flush();
381 mn10300_icache_inv(); 382 mn10300_icache_inv();
383#endif
382} 384}
383 385
384void arch_remove_kprobe(struct kprobe *p) 386void arch_remove_kprobe(struct kprobe *p)
@@ -390,8 +392,10 @@ void __kprobes disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
390{ 392{
391 *p->addr = p->opcode; 393 *p->addr = p->opcode;
392 regs->pc = (unsigned long) p->addr; 394 regs->pc = (unsigned long) p->addr;
395#ifndef CONFIG_MN10300_CACHE_SNOOP
393 mn10300_dcache_flush(); 396 mn10300_dcache_flush();
394 mn10300_icache_inv(); 397 mn10300_icache_inv();
398#endif
395} 399}
396 400
397static inline 401static inline
diff --git a/arch/mn10300/kernel/mn10300-serial-low.S b/arch/mn10300/kernel/mn10300-serial-low.S
index 66702d256610..dfc1b6f2fa9a 100644
--- a/arch/mn10300/kernel/mn10300-serial-low.S
+++ b/arch/mn10300/kernel/mn10300-serial-low.S
@@ -39,7 +39,7 @@
39############################################################################### 39###############################################################################
40 .balign L1_CACHE_BYTES 40 .balign L1_CACHE_BYTES
41ENTRY(mn10300_serial_vdma_interrupt) 41ENTRY(mn10300_serial_vdma_interrupt)
42 or EPSW_IE,psw # permit overriding by 42# or EPSW_IE,psw # permit overriding by
43 # debugging interrupts 43 # debugging interrupts
44 movm [d2,d3,a2,a3,exreg0],(sp) 44 movm [d2,d3,a2,a3,exreg0],(sp)
45 45
@@ -164,7 +164,7 @@ mnsc_vdma_tx_noint:
164 rti 164 rti
165 165
166mnsc_vdma_tx_empty: 166mnsc_vdma_tx_empty:
167 mov +(GxICR_LEVEL_1|GxICR_DETECT),d2 167 mov +(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2
168 movhu d2,(e3) # disable the interrupt 168 movhu d2,(e3) # disable the interrupt
169 movhu (e3),d2 # flush 169 movhu (e3),d2 # flush
170 170
@@ -175,7 +175,7 @@ mnsc_vdma_tx_break:
175 movhu (SCxCTR,e2),d2 # turn on break mode 175 movhu (SCxCTR,e2),d2 # turn on break mode
176 or SC01CTR_BKE,d2 176 or SC01CTR_BKE,d2
177 movhu d2,(SCxCTR,e2) 177 movhu d2,(SCxCTR,e2)
178 mov +(GxICR_LEVEL_1|GxICR_DETECT),d2 178 mov +(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2
179 movhu d2,(e3) # disable transmit interrupts on this 179 movhu d2,(e3) # disable transmit interrupts on this
180 # channel 180 # channel
181 movhu (e3),d2 # flush 181 movhu (e3),d2 # flush
diff --git a/arch/mn10300/kernel/mn10300-serial.c b/arch/mn10300/kernel/mn10300-serial.c
index db509dd80565..996384dba45d 100644
--- a/arch/mn10300/kernel/mn10300-serial.c
+++ b/arch/mn10300/kernel/mn10300-serial.c
@@ -44,6 +44,11 @@ static const char serial_revdate[] = "2007-11-06";
44#include <unit/timex.h> 44#include <unit/timex.h>
45#include "mn10300-serial.h" 45#include "mn10300-serial.h"
46 46
47#ifdef CONFIG_SMP
48#undef GxICR
49#define GxICR(X) CROSS_GxICR(X, 0)
50#endif /* CONFIG_SMP */
51
47#define kenter(FMT, ...) \ 52#define kenter(FMT, ...) \
48 printk(KERN_DEBUG "-->%s(" FMT ")\n", __func__, ##__VA_ARGS__) 53 printk(KERN_DEBUG "-->%s(" FMT ")\n", __func__, ##__VA_ARGS__)
49#define _enter(FMT, ...) \ 54#define _enter(FMT, ...) \
@@ -57,6 +62,11 @@ static const char serial_revdate[] = "2007-11-06";
57#define _proto(FMT, ...) \ 62#define _proto(FMT, ...) \
58 no_printk(KERN_DEBUG "### MNSERIAL " FMT " ###\n", ##__VA_ARGS__) 63 no_printk(KERN_DEBUG "### MNSERIAL " FMT " ###\n", ##__VA_ARGS__)
59 64
65#ifndef CODMSB
66/* c_cflag bit meaning */
67#define CODMSB 004000000000 /* change Transfer bit-order */
68#endif
69
60#define NR_UARTS 3 70#define NR_UARTS 3
61 71
62#ifdef CONFIG_MN10300_TTYSM_CONSOLE 72#ifdef CONFIG_MN10300_TTYSM_CONSOLE
@@ -152,26 +162,35 @@ struct mn10300_serial_port mn10300_serial_port_sif0 = {
152 .name = "ttySM0", 162 .name = "ttySM0",
153 ._iobase = &SC0CTR, 163 ._iobase = &SC0CTR,
154 ._control = &SC0CTR, 164 ._control = &SC0CTR,
155 ._status = (volatile u8 *) &SC0STR, 165 ._status = (volatile u8 *)&SC0STR,
156 ._intr = &SC0ICR, 166 ._intr = &SC0ICR,
157 ._rxb = &SC0RXB, 167 ._rxb = &SC0RXB,
158 ._txb = &SC0TXB, 168 ._txb = &SC0TXB,
159 .rx_name = "ttySM0:Rx", 169 .rx_name = "ttySM0:Rx",
160 .tx_name = "ttySM0:Tx", 170 .tx_name = "ttySM0:Tx",
161#ifdef CONFIG_MN10300_TTYSM0_TIMER8 171#if defined(CONFIG_MN10300_TTYSM0_TIMER8)
162 .tm_name = "ttySM0:Timer8", 172 .tm_name = "ttySM0:Timer8",
163 ._tmxmd = &TM8MD, 173 ._tmxmd = &TM8MD,
164 ._tmxbr = &TM8BR, 174 ._tmxbr = &TM8BR,
165 ._tmicr = &TM8ICR, 175 ._tmicr = &TM8ICR,
166 .tm_irq = TM8IRQ, 176 .tm_irq = TM8IRQ,
167 .div_timer = MNSCx_DIV_TIMER_16BIT, 177 .div_timer = MNSCx_DIV_TIMER_16BIT,
168#else /* CONFIG_MN10300_TTYSM0_TIMER2 */ 178#elif defined(CONFIG_MN10300_TTYSM0_TIMER0)
179 .tm_name = "ttySM0:Timer0",
180 ._tmxmd = &TM0MD,
181 ._tmxbr = (volatile u16 *)&TM0BR,
182 ._tmicr = &TM0ICR,
183 .tm_irq = TM0IRQ,
184 .div_timer = MNSCx_DIV_TIMER_8BIT,
185#elif defined(CONFIG_MN10300_TTYSM0_TIMER2)
169 .tm_name = "ttySM0:Timer2", 186 .tm_name = "ttySM0:Timer2",
170 ._tmxmd = &TM2MD, 187 ._tmxmd = &TM2MD,
171 ._tmxbr = (volatile u16 *) &TM2BR, 188 ._tmxbr = (volatile u16 *)&TM2BR,
172 ._tmicr = &TM2ICR, 189 ._tmicr = &TM2ICR,
173 .tm_irq = TM2IRQ, 190 .tm_irq = TM2IRQ,
174 .div_timer = MNSCx_DIV_TIMER_8BIT, 191 .div_timer = MNSCx_DIV_TIMER_8BIT,
192#else
193#error "Unknown config for ttySM0"
175#endif 194#endif
176 .rx_irq = SC0RXIRQ, 195 .rx_irq = SC0RXIRQ,
177 .tx_irq = SC0TXIRQ, 196 .tx_irq = SC0TXIRQ,
@@ -205,26 +224,35 @@ struct mn10300_serial_port mn10300_serial_port_sif1 = {
205 .name = "ttySM1", 224 .name = "ttySM1",
206 ._iobase = &SC1CTR, 225 ._iobase = &SC1CTR,
207 ._control = &SC1CTR, 226 ._control = &SC1CTR,
208 ._status = (volatile u8 *) &SC1STR, 227 ._status = (volatile u8 *)&SC1STR,
209 ._intr = &SC1ICR, 228 ._intr = &SC1ICR,
210 ._rxb = &SC1RXB, 229 ._rxb = &SC1RXB,
211 ._txb = &SC1TXB, 230 ._txb = &SC1TXB,
212 .rx_name = "ttySM1:Rx", 231 .rx_name = "ttySM1:Rx",
213 .tx_name = "ttySM1:Tx", 232 .tx_name = "ttySM1:Tx",
214#ifdef CONFIG_MN10300_TTYSM1_TIMER9 233#if defined(CONFIG_MN10300_TTYSM1_TIMER9)
215 .tm_name = "ttySM1:Timer9", 234 .tm_name = "ttySM1:Timer9",
216 ._tmxmd = &TM9MD, 235 ._tmxmd = &TM9MD,
217 ._tmxbr = &TM9BR, 236 ._tmxbr = &TM9BR,
218 ._tmicr = &TM9ICR, 237 ._tmicr = &TM9ICR,
219 .tm_irq = TM9IRQ, 238 .tm_irq = TM9IRQ,
220 .div_timer = MNSCx_DIV_TIMER_16BIT, 239 .div_timer = MNSCx_DIV_TIMER_16BIT,
221#else /* CONFIG_MN10300_TTYSM1_TIMER3 */ 240#elif defined(CONFIG_MN10300_TTYSM1_TIMER3)
222 .tm_name = "ttySM1:Timer3", 241 .tm_name = "ttySM1:Timer3",
223 ._tmxmd = &TM3MD, 242 ._tmxmd = &TM3MD,
224 ._tmxbr = (volatile u16 *) &TM3BR, 243 ._tmxbr = (volatile u16 *)&TM3BR,
225 ._tmicr = &TM3ICR, 244 ._tmicr = &TM3ICR,
226 .tm_irq = TM3IRQ, 245 .tm_irq = TM3IRQ,
227 .div_timer = MNSCx_DIV_TIMER_8BIT, 246 .div_timer = MNSCx_DIV_TIMER_8BIT,
247#elif defined(CONFIG_MN10300_TTYSM1_TIMER12)
248 .tm_name = "ttySM1/Timer12",
249 ._tmxmd = &TM12MD,
250 ._tmxbr = &TM12BR,
251 ._tmicr = &TM12ICR,
252 .tm_irq = TM12IRQ,
253 .div_timer = MNSCx_DIV_TIMER_16BIT,
254#else
255#error "Unknown config for ttySM1"
228#endif 256#endif
229 .rx_irq = SC1RXIRQ, 257 .rx_irq = SC1RXIRQ,
230 .tx_irq = SC1TXIRQ, 258 .tx_irq = SC1TXIRQ,
@@ -260,20 +288,45 @@ struct mn10300_serial_port mn10300_serial_port_sif2 = {
260 .uart.lock = 288 .uart.lock =
261 __SPIN_LOCK_UNLOCKED(mn10300_serial_port_sif2.uart.lock), 289 __SPIN_LOCK_UNLOCKED(mn10300_serial_port_sif2.uart.lock),
262 .name = "ttySM2", 290 .name = "ttySM2",
263 .rx_name = "ttySM2:Rx",
264 .tx_name = "ttySM2:Tx",
265 .tm_name = "ttySM2:Timer10",
266 ._iobase = &SC2CTR, 291 ._iobase = &SC2CTR,
267 ._control = &SC2CTR, 292 ._control = &SC2CTR,
268 ._status = &SC2STR, 293 ._status = (volatile u8 *)&SC2STR,
269 ._intr = &SC2ICR, 294 ._intr = &SC2ICR,
270 ._rxb = &SC2RXB, 295 ._rxb = &SC2RXB,
271 ._txb = &SC2TXB, 296 ._txb = &SC2TXB,
297 .rx_name = "ttySM2:Rx",
298 .tx_name = "ttySM2:Tx",
299#if defined(CONFIG_MN10300_TTYSM2_TIMER10)
300 .tm_name = "ttySM2/Timer10",
272 ._tmxmd = &TM10MD, 301 ._tmxmd = &TM10MD,
273 ._tmxbr = &TM10BR, 302 ._tmxbr = &TM10BR,
274 ._tmicr = &TM10ICR, 303 ._tmicr = &TM10ICR,
275 .tm_irq = TM10IRQ, 304 .tm_irq = TM10IRQ,
276 .div_timer = MNSCx_DIV_TIMER_16BIT, 305 .div_timer = MNSCx_DIV_TIMER_16BIT,
306#elif defined(CONFIG_MN10300_TTYSM2_TIMER9)
307 .tm_name = "ttySM2/Timer9",
308 ._tmxmd = &TM9MD,
309 ._tmxbr = &TM9BR,
310 ._tmicr = &TM9ICR,
311 .tm_irq = TM9IRQ,
312 .div_timer = MNSCx_DIV_TIMER_16BIT,
313#elif defined(CONFIG_MN10300_TTYSM2_TIMER1)
314 .tm_name = "ttySM2/Timer1",
315 ._tmxmd = &TM1MD,
316 ._tmxbr = (volatile u16 *)&TM1BR,
317 ._tmicr = &TM1ICR,
318 .tm_irq = TM1IRQ,
319 .div_timer = MNSCx_DIV_TIMER_8BIT,
320#elif defined(CONFIG_MN10300_TTYSM2_TIMER3)
321 .tm_name = "ttySM2/Timer3",
322 ._tmxmd = &TM3MD,
323 ._tmxbr = (volatile u16 *)&TM3BR,
324 ._tmicr = &TM3ICR,
325 .tm_irq = TM3IRQ,
326 .div_timer = MNSCx_DIV_TIMER_8BIT,
327#else
328#error "Unknown config for ttySM2"
329#endif
277 .rx_irq = SC2RXIRQ, 330 .rx_irq = SC2RXIRQ,
278 .tx_irq = SC2TXIRQ, 331 .tx_irq = SC2TXIRQ,
279 .rx_icr = &GxICR(SC2RXIRQ), 332 .rx_icr = &GxICR(SC2RXIRQ),
@@ -322,9 +375,13 @@ struct mn10300_serial_port *mn10300_serial_ports[NR_UARTS + 1] = {
322 */ 375 */
323static void mn10300_serial_mask_ack(unsigned int irq) 376static void mn10300_serial_mask_ack(unsigned int irq)
324{ 377{
378 unsigned long flags;
325 u16 tmp; 379 u16 tmp;
380
381 flags = arch_local_cli_save();
326 GxICR(irq) = GxICR_LEVEL_6; 382 GxICR(irq) = GxICR_LEVEL_6;
327 tmp = GxICR(irq); /* flush write buffer */ 383 tmp = GxICR(irq); /* flush write buffer */
384 arch_local_irq_restore(flags);
328} 385}
329 386
330static void mn10300_serial_nop(unsigned int irq) 387static void mn10300_serial_nop(unsigned int irq)
@@ -348,23 +405,36 @@ struct mn10300_serial_int mn10300_serial_int_tbl[NR_IRQS];
348 405
349static void mn10300_serial_dis_tx_intr(struct mn10300_serial_port *port) 406static void mn10300_serial_dis_tx_intr(struct mn10300_serial_port *port)
350{ 407{
408 unsigned long flags;
351 u16 x; 409 u16 x;
352 *port->tx_icr = GxICR_LEVEL_1 | GxICR_DETECT; 410
411 flags = arch_local_cli_save();
412 *port->tx_icr = NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL);
353 x = *port->tx_icr; 413 x = *port->tx_icr;
414 arch_local_irq_restore(flags);
354} 415}
355 416
356static void mn10300_serial_en_tx_intr(struct mn10300_serial_port *port) 417static void mn10300_serial_en_tx_intr(struct mn10300_serial_port *port)
357{ 418{
419 unsigned long flags;
358 u16 x; 420 u16 x;
359 *port->tx_icr = GxICR_LEVEL_1 | GxICR_ENABLE; 421
422 flags = arch_local_cli_save();
423 *port->tx_icr =
424 NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL) | GxICR_ENABLE;
360 x = *port->tx_icr; 425 x = *port->tx_icr;
426 arch_local_irq_restore(flags);
361} 427}
362 428
363static void mn10300_serial_dis_rx_intr(struct mn10300_serial_port *port) 429static void mn10300_serial_dis_rx_intr(struct mn10300_serial_port *port)
364{ 430{
431 unsigned long flags;
365 u16 x; 432 u16 x;
366 *port->rx_icr = GxICR_LEVEL_1 | GxICR_DETECT; 433
434 flags = arch_local_cli_save();
435 *port->rx_icr = NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL);
367 x = *port->rx_icr; 436 x = *port->rx_icr;
437 arch_local_irq_restore(flags);
368} 438}
369 439
370/* 440/*
@@ -650,7 +720,7 @@ static unsigned int mn10300_serial_tx_empty(struct uart_port *_port)
650static void mn10300_serial_set_mctrl(struct uart_port *_port, 720static void mn10300_serial_set_mctrl(struct uart_port *_port,
651 unsigned int mctrl) 721 unsigned int mctrl)
652{ 722{
653 struct mn10300_serial_port *port = 723 struct mn10300_serial_port *port __attribute__ ((unused)) =
654 container_of(_port, struct mn10300_serial_port, uart); 724 container_of(_port, struct mn10300_serial_port, uart);
655 725
656 _enter("%s,%x", port->name, mctrl); 726 _enter("%s,%x", port->name, mctrl);
@@ -706,6 +776,7 @@ static void mn10300_serial_start_tx(struct uart_port *_port)
706 UART_XMIT_SIZE)); 776 UART_XMIT_SIZE));
707 777
708 /* kick the virtual DMA controller */ 778 /* kick the virtual DMA controller */
779 arch_local_cli();
709 x = *port->tx_icr; 780 x = *port->tx_icr;
710 x |= GxICR_ENABLE; 781 x |= GxICR_ENABLE;
711 782
@@ -716,10 +787,14 @@ static void mn10300_serial_start_tx(struct uart_port *_port)
716 787
717 _debug("CTR=%04hx ICR=%02hx STR=%04x TMD=%02hx TBR=%04hx ICR=%04hx", 788 _debug("CTR=%04hx ICR=%02hx STR=%04x TMD=%02hx TBR=%04hx ICR=%04hx",
718 *port->_control, *port->_intr, *port->_status, 789 *port->_control, *port->_intr, *port->_status,
719 *port->_tmxmd, *port->_tmxbr, *port->tx_icr); 790 *port->_tmxmd,
791 (port->div_timer == MNSCx_DIV_TIMER_8BIT) ?
792 *(volatile u8 *)port->_tmxbr : *port->_tmxbr,
793 *port->tx_icr);
720 794
721 *port->tx_icr = x; 795 *port->tx_icr = x;
722 x = *port->tx_icr; 796 x = *port->tx_icr;
797 arch_local_sti();
723} 798}
724 799
725/* 800/*
@@ -842,8 +917,10 @@ static int mn10300_serial_startup(struct uart_port *_port)
842 pint->port = port; 917 pint->port = port;
843 pint->vdma = mn10300_serial_vdma_tx_handler; 918 pint->vdma = mn10300_serial_vdma_tx_handler;
844 919
845 set_intr_level(port->rx_irq, GxICR_LEVEL_1); 920 set_intr_level(port->rx_irq,
846 set_intr_level(port->tx_irq, GxICR_LEVEL_1); 921 NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL));
922 set_intr_level(port->tx_irq,
923 NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL));
847 set_irq_chip(port->tm_irq, &mn10300_serial_pic); 924 set_irq_chip(port->tm_irq, &mn10300_serial_pic);
848 925
849 if (request_irq(port->rx_irq, mn10300_serial_interrupt, 926 if (request_irq(port->rx_irq, mn10300_serial_interrupt,
@@ -876,6 +953,7 @@ error:
876 */ 953 */
877static void mn10300_serial_shutdown(struct uart_port *_port) 954static void mn10300_serial_shutdown(struct uart_port *_port)
878{ 955{
956 u16 x;
879 struct mn10300_serial_port *port = 957 struct mn10300_serial_port *port =
880 container_of(_port, struct mn10300_serial_port, uart); 958 container_of(_port, struct mn10300_serial_port, uart);
881 959
@@ -897,8 +975,12 @@ static void mn10300_serial_shutdown(struct uart_port *_port)
897 free_irq(port->rx_irq, port); 975 free_irq(port->rx_irq, port);
898 free_irq(port->tx_irq, port); 976 free_irq(port->tx_irq, port);
899 977
900 *port->rx_icr = GxICR_LEVEL_1; 978 arch_local_cli();
901 *port->tx_icr = GxICR_LEVEL_1; 979 *port->rx_icr = NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL);
980 x = *port->rx_icr;
981 *port->tx_icr = NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL);
982 x = *port->tx_icr;
983 arch_local_sti();
902} 984}
903 985
904/* 986/*
@@ -947,11 +1029,66 @@ static void mn10300_serial_change_speed(struct mn10300_serial_port *port,
947 /* Determine divisor based on baud rate */ 1029 /* Determine divisor based on baud rate */
948 battempt = 0; 1030 battempt = 0;
949 1031
950 if (div_timer == MNSCx_DIV_TIMER_16BIT) 1032 switch (port->uart.line) {
951 scxctr |= SC0CTR_CK_TM8UFLOW_8; /* ( == SC1CTR_CK_TM9UFLOW_8 1033#ifdef CONFIG_MN10300_TTYSM0
952 * == SC2CTR_CK_TM10UFLOW) */ 1034 case 0: /* ttySM0 */
953 else if (div_timer == MNSCx_DIV_TIMER_8BIT) 1035#if defined(CONFIG_MN10300_TTYSM0_TIMER8)
1036 scxctr |= SC0CTR_CK_TM8UFLOW_8;
1037#elif defined(CONFIG_MN10300_TTYSM0_TIMER0)
1038 scxctr |= SC0CTR_CK_TM0UFLOW_8;
1039#elif defined(CONFIG_MN10300_TTYSM0_TIMER2)
954 scxctr |= SC0CTR_CK_TM2UFLOW_8; 1040 scxctr |= SC0CTR_CK_TM2UFLOW_8;
1041#else
1042#error "Unknown config for ttySM0"
1043#endif
1044 break;
1045#endif /* CONFIG_MN10300_TTYSM0 */
1046
1047#ifdef CONFIG_MN10300_TTYSM1
1048 case 1: /* ttySM1 */
1049#if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
1050#if defined(CONFIG_MN10300_TTYSM1_TIMER9)
1051 scxctr |= SC1CTR_CK_TM9UFLOW_8;
1052#elif defined(CONFIG_MN10300_TTYSM1_TIMER3)
1053 scxctr |= SC1CTR_CK_TM3UFLOW_8;
1054#else
1055#error "Unknown config for ttySM1"
1056#endif
1057#else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
1058#if defined(CONFIG_MN10300_TTYSM1_TIMER12)
1059 scxctr |= SC1CTR_CK_TM12UFLOW_8;
1060#else
1061#error "Unknown config for ttySM1"
1062#endif
1063#endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
1064 break;
1065#endif /* CONFIG_MN10300_TTYSM1 */
1066
1067#ifdef CONFIG_MN10300_TTYSM2
1068 case 2: /* ttySM2 */
1069#if defined(CONFIG_AM33_2)
1070#if defined(CONFIG_MN10300_TTYSM2_TIMER10)
1071 scxctr |= SC2CTR_CK_TM10UFLOW;
1072#else
1073#error "Unknown config for ttySM2"
1074#endif
1075#else /* CONFIG_AM33_2 */
1076#if defined(CONFIG_MN10300_TTYSM2_TIMER9)
1077 scxctr |= SC2CTR_CK_TM9UFLOW_8;
1078#elif defined(CONFIG_MN10300_TTYSM2_TIMER1)
1079 scxctr |= SC2CTR_CK_TM1UFLOW_8;
1080#elif defined(CONFIG_MN10300_TTYSM2_TIMER3)
1081 scxctr |= SC2CTR_CK_TM3UFLOW_8;
1082#else
1083#error "Unknown config for ttySM2"
1084#endif
1085#endif /* CONFIG_AM33_2 */
1086 break;
1087#endif /* CONFIG_MN10300_TTYSM2 */
1088
1089 default:
1090 break;
1091 }
955 1092
956try_alternative: 1093try_alternative:
957 baud = uart_get_baud_rate(&port->uart, new, old, 0, 1094 baud = uart_get_baud_rate(&port->uart, new, old, 0,
@@ -1195,6 +1332,12 @@ static void mn10300_serial_set_termios(struct uart_port *_port,
1195 ctr &= ~SC2CTR_TWE; 1332 ctr &= ~SC2CTR_TWE;
1196 *port->_control = ctr; 1333 *port->_control = ctr;
1197 } 1334 }
1335
1336 /* change Transfer bit-order (LSB/MSB) */
1337 if (new->c_cflag & CODMSB)
1338 *port->_control |= SC01CTR_OD_MSBFIRST; /* MSB MODE */
1339 else
1340 *port->_control &= ~SC01CTR_OD_MSBFIRST; /* LSB MODE */
1198} 1341}
1199 1342
1200/* 1343/*
@@ -1302,11 +1445,16 @@ static int __init mn10300_serial_init(void)
1302 printk(KERN_INFO "%s version %s (%s)\n", 1445 printk(KERN_INFO "%s version %s (%s)\n",
1303 serial_name, serial_version, serial_revdate); 1446 serial_name, serial_version, serial_revdate);
1304 1447
1305#ifdef CONFIG_MN10300_TTYSM2 1448#if defined(CONFIG_MN10300_TTYSM2) && defined(CONFIG_AM33_2)
1306 SC2TIM = 8; /* make the baud base of timer 2 IOCLK/8 */ 1449 {
1450 int tmp;
1451 SC2TIM = 8; /* make the baud base of timer 2 IOCLK/8 */
1452 tmp = SC2TIM;
1453 }
1307#endif 1454#endif
1308 1455
1309 set_intr_stub(EXCEP_IRQ_LEVEL1, mn10300_serial_vdma_interrupt); 1456 set_intr_stub(NUM2EXCEP_IRQ_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL),
1457 mn10300_serial_vdma_interrupt);
1310 1458
1311 ret = uart_register_driver(&mn10300_serial_driver); 1459 ret = uart_register_driver(&mn10300_serial_driver);
1312 if (!ret) { 1460 if (!ret) {
@@ -1366,9 +1514,11 @@ static void mn10300_serial_console_write(struct console *co,
1366 port = mn10300_serial_ports[co->index]; 1514 port = mn10300_serial_ports[co->index];
1367 1515
1368 /* firstly hijack the serial port from the "virtual DMA" controller */ 1516 /* firstly hijack the serial port from the "virtual DMA" controller */
1517 arch_local_cli();
1369 txicr = *port->tx_icr; 1518 txicr = *port->tx_icr;
1370 *port->tx_icr = GxICR_LEVEL_1; 1519 *port->tx_icr = NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL);
1371 tmp = *port->tx_icr; 1520 tmp = *port->tx_icr;
1521 arch_local_sti();
1372 1522
1373 /* the transmitter may be disabled */ 1523 /* the transmitter may be disabled */
1374 scxctr = *port->_control; 1524 scxctr = *port->_control;
@@ -1422,8 +1572,10 @@ static void mn10300_serial_console_write(struct console *co,
1422 if (!(scxctr & SC01CTR_TXE)) 1572 if (!(scxctr & SC01CTR_TXE))
1423 *port->_control = scxctr; 1573 *port->_control = scxctr;
1424 1574
1575 arch_local_cli();
1425 *port->tx_icr = txicr; 1576 *port->tx_icr = txicr;
1426 tmp = *port->tx_icr; 1577 tmp = *port->tx_icr;
1578 arch_local_sti();
1427} 1579}
1428 1580
1429/* 1581/*
diff --git a/arch/mn10300/kernel/mn10300-watchdog-low.S b/arch/mn10300/kernel/mn10300-watchdog-low.S
index 996244745cca..f2f5c9cfaabd 100644
--- a/arch/mn10300/kernel/mn10300-watchdog-low.S
+++ b/arch/mn10300/kernel/mn10300-watchdog-low.S
@@ -16,6 +16,7 @@
16#include <asm/intctl-regs.h> 16#include <asm/intctl-regs.h>
17#include <asm/timer-regs.h> 17#include <asm/timer-regs.h>
18#include <asm/frame.inc> 18#include <asm/frame.inc>
19#include <linux/threads.h>
19 20
20 .text 21 .text
21 22
@@ -53,7 +54,13 @@ watchdog_handler:
53 .type touch_nmi_watchdog,@function 54 .type touch_nmi_watchdog,@function
54touch_nmi_watchdog: 55touch_nmi_watchdog:
55 clr d0 56 clr d0
56 mov d0,(watchdog_alert_counter) 57 clr d1
58 mov watchdog_alert_counter, a0
59 setlb
60 mov d0, (a0+)
61 inc d1
62 cmp NR_CPUS, d1
63 lne
57 ret [],0 64 ret [],0
58 65
59 .size touch_nmi_watchdog,.-touch_nmi_watchdog 66 .size touch_nmi_watchdog,.-touch_nmi_watchdog
diff --git a/arch/mn10300/kernel/mn10300-watchdog.c b/arch/mn10300/kernel/mn10300-watchdog.c
index f362d9d138f1..c5e12bfd9fcd 100644
--- a/arch/mn10300/kernel/mn10300-watchdog.c
+++ b/arch/mn10300/kernel/mn10300-watchdog.c
@@ -30,7 +30,7 @@
30static DEFINE_SPINLOCK(watchdog_print_lock); 30static DEFINE_SPINLOCK(watchdog_print_lock);
31static unsigned int watchdog; 31static unsigned int watchdog;
32static unsigned int watchdog_hz = 1; 32static unsigned int watchdog_hz = 1;
33unsigned int watchdog_alert_counter; 33unsigned int watchdog_alert_counter[NR_CPUS];
34 34
35EXPORT_SYMBOL(touch_nmi_watchdog); 35EXPORT_SYMBOL(touch_nmi_watchdog);
36 36
@@ -39,9 +39,6 @@ EXPORT_SYMBOL(touch_nmi_watchdog);
39 * is to check its timer makes IRQ counts. If they are not 39 * is to check its timer makes IRQ counts. If they are not
40 * changing then that CPU has some problem. 40 * changing then that CPU has some problem.
41 * 41 *
42 * as these watchdog NMI IRQs are generated on every CPU, we only
43 * have to check the current processor.
44 *
45 * since NMIs dont listen to _any_ locks, we have to be extremely 42 * since NMIs dont listen to _any_ locks, we have to be extremely
46 * careful not to rely on unsafe variables. The printk might lock 43 * careful not to rely on unsafe variables. The printk might lock
47 * up though, so we have to break up any console locks first ... 44 * up though, so we have to break up any console locks first ...
@@ -69,8 +66,8 @@ int __init check_watchdog(void)
69 66
70 printk(KERN_INFO "OK.\n"); 67 printk(KERN_INFO "OK.\n");
71 68
72 /* now that we know it works we can reduce NMI frequency to 69 /* now that we know it works we can reduce NMI frequency to something
73 * something more reasonable; makes a difference in some configs 70 * more reasonable; makes a difference in some configs
74 */ 71 */
75 watchdog_hz = 1; 72 watchdog_hz = 1;
76 73
@@ -121,15 +118,22 @@ void __init watchdog_go(void)
121 } 118 }
122} 119}
123 120
121#ifdef CONFIG_SMP
122static void watchdog_dump_register(void *dummy)
123{
124 printk(KERN_ERR "--- Register Dump (CPU%d) ---\n", CPUID);
125 show_registers(current_frame());
126}
127#endif
128
124asmlinkage 129asmlinkage
125void watchdog_interrupt(struct pt_regs *regs, enum exception_code excep) 130void watchdog_interrupt(struct pt_regs *regs, enum exception_code excep)
126{ 131{
127
128 /* 132 /*
129 * Since current-> is always on the stack, and we always switch 133 * Since current-> is always on the stack, and we always switch
130 * the stack NMI-atomically, it's safe to use smp_processor_id(). 134 * the stack NMI-atomically, it's safe to use smp_processor_id().
131 */ 135 */
132 int sum, cpu = smp_processor_id(); 136 int sum, cpu;
133 int irq = NMIIRQ; 137 int irq = NMIIRQ;
134 u8 wdt, tmp; 138 u8 wdt, tmp;
135 139
@@ -138,43 +142,61 @@ void watchdog_interrupt(struct pt_regs *regs, enum exception_code excep)
138 tmp = WDCTR; 142 tmp = WDCTR;
139 NMICR = NMICR_WDIF; 143 NMICR = NMICR_WDIF;
140 144
141 nmi_count(cpu)++; 145 nmi_count(smp_processor_id())++;
142 kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq)); 146 kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
143 sum = irq_stat[cpu].__irq_count; 147
144 148 for_each_online_cpu(cpu) {
145 if (last_irq_sums[cpu] == sum) { 149
146 /* 150 sum = irq_stat[cpu].__irq_count;
147 * Ayiee, looks like this CPU is stuck ... 151
148 * wait a few IRQs (5 seconds) before doing the oops ... 152 if ((last_irq_sums[cpu] == sum)
149 */ 153#if defined(CONFIG_GDBSTUB) && defined(CONFIG_SMP)
150 watchdog_alert_counter++; 154 && !(CHK_GDBSTUB_BUSY()
151 if (watchdog_alert_counter == 5 * watchdog_hz) { 155 || atomic_read(&cpu_doing_single_step))
152 spin_lock(&watchdog_print_lock); 156#endif
157 ) {
153 /* 158 /*
154 * We are in trouble anyway, lets at least try 159 * Ayiee, looks like this CPU is stuck ...
155 * to get a message out. 160 * wait a few IRQs (5 seconds) before doing the oops ...
156 */ 161 */
157 bust_spinlocks(1); 162 watchdog_alert_counter[cpu]++;
158 printk(KERN_ERR 163 if (watchdog_alert_counter[cpu] == 5 * watchdog_hz) {
159 "NMI Watchdog detected LOCKUP on CPU%d," 164 spin_lock(&watchdog_print_lock);
160 " pc %08lx, registers:\n", 165 /*
161 cpu, regs->pc); 166 * We are in trouble anyway, lets at least try
162 show_registers(regs); 167 * to get a message out.
163 printk("console shuts up ...\n"); 168 */
164 console_silent(); 169 bust_spinlocks(1);
165 spin_unlock(&watchdog_print_lock); 170 printk(KERN_ERR
166 bust_spinlocks(0); 171 "NMI Watchdog detected LOCKUP on CPU%d,"
172 " pc %08lx, registers:\n",
173 cpu, regs->pc);
174#ifdef CONFIG_SMP
175 printk(KERN_ERR
176 "--- Register Dump (CPU%d) ---\n",
177 CPUID);
178#endif
179 show_registers(regs);
180#ifdef CONFIG_SMP
181 smp_nmi_call_function(watchdog_dump_register,
182 NULL, 1);
183#endif
184 printk(KERN_NOTICE "console shuts up ...\n");
185 console_silent();
186 spin_unlock(&watchdog_print_lock);
187 bust_spinlocks(0);
167#ifdef CONFIG_GDBSTUB 188#ifdef CONFIG_GDBSTUB
168 if (gdbstub_busy) 189 if (CHK_GDBSTUB_BUSY_AND_ACTIVE())
169 gdbstub_exception(regs, excep); 190 gdbstub_exception(regs, excep);
170 else 191 else
171 gdbstub_intercept(regs, excep); 192 gdbstub_intercept(regs, excep);
172#endif 193#endif
173 do_exit(SIGSEGV); 194 do_exit(SIGSEGV);
195 }
196 } else {
197 last_irq_sums[cpu] = sum;
198 watchdog_alert_counter[cpu] = 0;
174 } 199 }
175 } else {
176 last_irq_sums[cpu] = sum;
177 watchdog_alert_counter = 0;
178 } 200 }
179 201
180 WDCTR = wdt | WDCTR_WDRST; 202 WDCTR = wdt | WDCTR_WDRST;
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index f48373e2bc1c..0d0f8049a17b 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -57,6 +57,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
57void (*pm_power_off)(void); 57void (*pm_power_off)(void);
58EXPORT_SYMBOL(pm_power_off); 58EXPORT_SYMBOL(pm_power_off);
59 59
60#if !defined(CONFIG_SMP) || defined(CONFIG_HOTPLUG_CPU)
60/* 61/*
61 * we use this if we don't have any better idle routine 62 * we use this if we don't have any better idle routine
62 */ 63 */
@@ -69,6 +70,35 @@ static void default_idle(void)
69 local_irq_enable(); 70 local_irq_enable();
70} 71}
71 72
73#else /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU */
74/*
75 * On SMP it's slightly faster (but much more power-consuming!)
76 * to poll the ->work.need_resched flag instead of waiting for the
77 * cross-CPU IPI to arrive. Use this option with caution.
78 */
79static inline void poll_idle(void)
80{
81 int oldval;
82
83 local_irq_enable();
84
85 /*
86 * Deal with another CPU just having chosen a thread to
87 * run here:
88 */
89 oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
90
91 if (!oldval) {
92 set_thread_flag(TIF_POLLING_NRFLAG);
93 while (!need_resched())
94 cpu_relax();
95 clear_thread_flag(TIF_POLLING_NRFLAG);
96 } else {
97 set_need_resched();
98 }
99}
100#endif /* !CONFIG_SMP || CONFIG_HOTPLUG_CPU */
101
72/* 102/*
73 * the idle thread 103 * the idle thread
74 * - there's no useful work to be done, so just try to conserve power and have 104 * - there's no useful work to be done, so just try to conserve power and have
@@ -77,8 +107,6 @@ static void default_idle(void)
77 */ 107 */
78void cpu_idle(void) 108void cpu_idle(void)
79{ 109{
80 int cpu = smp_processor_id();
81
82 /* endless idle loop with no priority at all */ 110 /* endless idle loop with no priority at all */
83 for (;;) { 111 for (;;) {
84 while (!need_resched()) { 112 while (!need_resched()) {
@@ -86,10 +114,13 @@ void cpu_idle(void)
86 114
87 smp_rmb(); 115 smp_rmb();
88 idle = pm_idle; 116 idle = pm_idle;
89 if (!idle) 117 if (!idle) {
118#if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
119 idle = poll_idle;
120#else /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
90 idle = default_idle; 121 idle = default_idle;
91 122#endif /* CONFIG_SMP && !CONFIG_HOTPLUG_CPU */
92 irq_stat[cpu].idle_timestamp = jiffies; 123 }
93 idle(); 124 idle();
94 } 125 }
95 126
@@ -197,6 +228,7 @@ int copy_thread(unsigned long clone_flags,
197 unsigned long c_usp, unsigned long ustk_size, 228 unsigned long c_usp, unsigned long ustk_size,
198 struct task_struct *p, struct pt_regs *kregs) 229 struct task_struct *p, struct pt_regs *kregs)
199{ 230{
231 struct thread_info *ti = task_thread_info(p);
200 struct pt_regs *c_uregs, *c_kregs, *uregs; 232 struct pt_regs *c_uregs, *c_kregs, *uregs;
201 unsigned long c_ksp; 233 unsigned long c_ksp;
202 234
@@ -217,7 +249,7 @@ int copy_thread(unsigned long clone_flags,
217 249
218 /* the new TLS pointer is passed in as arg #5 to sys_clone() */ 250 /* the new TLS pointer is passed in as arg #5 to sys_clone() */
219 if (clone_flags & CLONE_SETTLS) 251 if (clone_flags & CLONE_SETTLS)
220 c_uregs->e2 = __frame->d3; 252 c_uregs->e2 = current_frame()->d3;
221 253
222 /* set up the return kernel frame if called from kernel_thread() */ 254 /* set up the return kernel frame if called from kernel_thread() */
223 c_kregs = c_uregs; 255 c_kregs = c_uregs;
@@ -235,7 +267,7 @@ int copy_thread(unsigned long clone_flags,
235 } 267 }
236 268
237 /* set up things up so the scheduler can start the new task */ 269 /* set up things up so the scheduler can start the new task */
238 p->thread.__frame = c_kregs; 270 ti->frame = c_kregs;
239 p->thread.a3 = (unsigned long) c_kregs; 271 p->thread.a3 = (unsigned long) c_kregs;
240 p->thread.sp = c_ksp; 272 p->thread.sp = c_ksp;
241 p->thread.pc = (unsigned long) ret_from_fork; 273 p->thread.pc = (unsigned long) ret_from_fork;
@@ -247,25 +279,26 @@ int copy_thread(unsigned long clone_flags,
247 279
248/* 280/*
249 * clone a process 281 * clone a process
250 * - tlsptr is retrieved by copy_thread() from __frame->d3 282 * - tlsptr is retrieved by copy_thread() from current_frame()->d3
251 */ 283 */
252asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, 284asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
253 int __user *parent_tidptr, int __user *child_tidptr, 285 int __user *parent_tidptr, int __user *child_tidptr,
254 int __user *tlsptr) 286 int __user *tlsptr)
255{ 287{
256 return do_fork(clone_flags, newsp ?: __frame->sp, __frame, 0, 288 return do_fork(clone_flags, newsp ?: current_frame()->sp,
257 parent_tidptr, child_tidptr); 289 current_frame(), 0, parent_tidptr, child_tidptr);
258} 290}
259 291
260asmlinkage long sys_fork(void) 292asmlinkage long sys_fork(void)
261{ 293{
262 return do_fork(SIGCHLD, __frame->sp, __frame, 0, NULL, NULL); 294 return do_fork(SIGCHLD, current_frame()->sp,
295 current_frame(), 0, NULL, NULL);
263} 296}
264 297
265asmlinkage long sys_vfork(void) 298asmlinkage long sys_vfork(void)
266{ 299{
267 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, __frame->sp, __frame, 300 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, current_frame()->sp,
268 0, NULL, NULL); 301 current_frame(), 0, NULL, NULL);
269} 302}
270 303
271asmlinkage long sys_execve(const char __user *name, 304asmlinkage long sys_execve(const char __user *name,
@@ -279,7 +312,7 @@ asmlinkage long sys_execve(const char __user *name,
279 error = PTR_ERR(filename); 312 error = PTR_ERR(filename);
280 if (IS_ERR(filename)) 313 if (IS_ERR(filename))
281 return error; 314 return error;
282 error = do_execve(filename, argv, envp, __frame); 315 error = do_execve(filename, argv, envp, current_frame());
283 putname(filename); 316 putname(filename);
284 return error; 317 return error;
285} 318}
diff --git a/arch/mn10300/kernel/profile.c b/arch/mn10300/kernel/profile.c
index 20d7d0306b16..4f342f75d00c 100644
--- a/arch/mn10300/kernel/profile.c
+++ b/arch/mn10300/kernel/profile.c
@@ -41,7 +41,7 @@ static __init int profile_init(void)
41 tmp = TM11ICR; 41 tmp = TM11ICR;
42 42
43 printk(KERN_INFO "Profiling initiated on timer 11, priority 0, %uHz\n", 43 printk(KERN_INFO "Profiling initiated on timer 11, priority 0, %uHz\n",
44 mn10300_ioclk / 8 / (TM11BR + 1)); 44 MN10300_IOCLK / 8 / (TM11BR + 1));
45 printk(KERN_INFO "Profile histogram stored %p-%p\n", 45 printk(KERN_INFO "Profile histogram stored %p-%p\n",
46 prof_buffer, (u8 *)(prof_buffer + prof_len) - 1); 46 prof_buffer, (u8 *)(prof_buffer + prof_len) - 1);
47 47
diff --git a/arch/mn10300/kernel/ptrace.c b/arch/mn10300/kernel/ptrace.c
index cf847dabc1bd..5c0b07e61006 100644
--- a/arch/mn10300/kernel/ptrace.c
+++ b/arch/mn10300/kernel/ptrace.c
@@ -295,31 +295,31 @@ void ptrace_disable(struct task_struct *child)
295/* 295/*
296 * handle the arch-specific side of process tracing 296 * handle the arch-specific side of process tracing
297 */ 297 */
298long arch_ptrace(struct task_struct *child, long request, long addr, long data) 298long arch_ptrace(struct task_struct *child, long request,
299 unsigned long addr, unsigned long data)
299{ 300{
300 unsigned long tmp; 301 unsigned long tmp;
301 int ret; 302 int ret;
303 unsigned long __user *datap = (unsigned long __user *) data;
302 304
303 switch (request) { 305 switch (request) {
304 /* read the word at location addr in the USER area. */ 306 /* read the word at location addr in the USER area. */
305 case PTRACE_PEEKUSR: 307 case PTRACE_PEEKUSR:
306 ret = -EIO; 308 ret = -EIO;
307 if ((addr & 3) || addr < 0 || 309 if ((addr & 3) || addr > sizeof(struct user) - 3)
308 addr > sizeof(struct user) - 3)
309 break; 310 break;
310 311
311 tmp = 0; /* Default return condition */ 312 tmp = 0; /* Default return condition */
312 if (addr < NR_PTREGS << 2) 313 if (addr < NR_PTREGS << 2)
313 tmp = get_stack_long(child, 314 tmp = get_stack_long(child,
314 ptrace_regid_to_frame[addr]); 315 ptrace_regid_to_frame[addr]);
315 ret = put_user(tmp, (unsigned long *) data); 316 ret = put_user(tmp, datap);
316 break; 317 break;
317 318
318 /* write the word at location addr in the USER area */ 319 /* write the word at location addr in the USER area */
319 case PTRACE_POKEUSR: 320 case PTRACE_POKEUSR:
320 ret = -EIO; 321 ret = -EIO;
321 if ((addr & 3) || addr < 0 || 322 if ((addr & 3) || addr > sizeof(struct user) - 3)
322 addr > sizeof(struct user) - 3)
323 break; 323 break;
324 324
325 ret = 0; 325 ret = 0;
@@ -332,25 +332,25 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
332 return copy_regset_to_user(child, &user_mn10300_native_view, 332 return copy_regset_to_user(child, &user_mn10300_native_view,
333 REGSET_GENERAL, 333 REGSET_GENERAL,
334 0, NR_PTREGS * sizeof(long), 334 0, NR_PTREGS * sizeof(long),
335 (void __user *)data); 335 datap);
336 336
337 case PTRACE_SETREGS: /* Set all integer regs in the child. */ 337 case PTRACE_SETREGS: /* Set all integer regs in the child. */
338 return copy_regset_from_user(child, &user_mn10300_native_view, 338 return copy_regset_from_user(child, &user_mn10300_native_view,
339 REGSET_GENERAL, 339 REGSET_GENERAL,
340 0, NR_PTREGS * sizeof(long), 340 0, NR_PTREGS * sizeof(long),
341 (const void __user *)data); 341 datap);
342 342
343 case PTRACE_GETFPREGS: /* Get the child FPU state. */ 343 case PTRACE_GETFPREGS: /* Get the child FPU state. */
344 return copy_regset_to_user(child, &user_mn10300_native_view, 344 return copy_regset_to_user(child, &user_mn10300_native_view,
345 REGSET_FPU, 345 REGSET_FPU,
346 0, sizeof(struct fpu_state_struct), 346 0, sizeof(struct fpu_state_struct),
347 (void __user *)data); 347 datap);
348 348
349 case PTRACE_SETFPREGS: /* Set the child FPU state. */ 349 case PTRACE_SETFPREGS: /* Set the child FPU state. */
350 return copy_regset_from_user(child, &user_mn10300_native_view, 350 return copy_regset_from_user(child, &user_mn10300_native_view,
351 REGSET_FPU, 351 REGSET_FPU,
352 0, sizeof(struct fpu_state_struct), 352 0, sizeof(struct fpu_state_struct),
353 (const void __user *)data); 353 datap);
354 354
355 default: 355 default:
356 ret = ptrace_request(child, request, addr, data); 356 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/mn10300/kernel/rtc.c b/arch/mn10300/kernel/rtc.c
index 4eef0e7224f6..e9e20f9a4dd3 100644
--- a/arch/mn10300/kernel/rtc.c
+++ b/arch/mn10300/kernel/rtc.c
@@ -20,18 +20,22 @@
20DEFINE_SPINLOCK(rtc_lock); 20DEFINE_SPINLOCK(rtc_lock);
21EXPORT_SYMBOL(rtc_lock); 21EXPORT_SYMBOL(rtc_lock);
22 22
23/* time for RTC to update itself in ioclks */ 23/*
24static unsigned long mn10300_rtc_update_period; 24 * Read the current RTC time
25 25 */
26void read_persistent_clock(struct timespec *ts) 26void read_persistent_clock(struct timespec *ts)
27{ 27{
28 struct rtc_time tm; 28 struct rtc_time tm;
29 29
30 get_rtc_time(&tm); 30 get_rtc_time(&tm);
31 31
32 ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
33 tm.tm_hour, tm.tm_min, tm.tm_sec);
34 ts->tv_nsec = 0; 32 ts->tv_nsec = 0;
33 ts->tv_sec = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday,
34 tm.tm_hour, tm.tm_min, tm.tm_sec);
35
36 /* if rtc is way off in the past, set something reasonable */
37 if (ts->tv_sec < 0)
38 ts->tv_sec = mktime(2009, 1, 1, 12, 0, 0);
35} 39}
36 40
37/* 41/*
@@ -115,39 +119,14 @@ int update_persistent_clock(struct timespec now)
115 */ 119 */
116void __init calibrate_clock(void) 120void __init calibrate_clock(void)
117{ 121{
118 unsigned long count0, counth, count1;
119 unsigned char status; 122 unsigned char status;
120 123
121 /* make sure the RTC is running and is set to operate in 24hr mode */ 124 /* make sure the RTC is running and is set to operate in 24hr mode */
122 status = RTSRC; 125 status = RTSRC;
123 RTCRB |= RTCRB_SET; 126 RTCRB |= RTCRB_SET;
124 RTCRB |= RTCRB_TM_24HR; 127 RTCRB |= RTCRB_TM_24HR;
128 RTCRB &= ~RTCRB_DM_BINARY;
125 RTCRA |= RTCRA_DVR; 129 RTCRA |= RTCRA_DVR;
126 RTCRA &= ~RTCRA_DVR; 130 RTCRA &= ~RTCRA_DVR;
127 RTCRB &= ~RTCRB_SET; 131 RTCRB &= ~RTCRB_SET;
128
129 /* work out the clock speed by counting clock cycles between ends of
130 * the RTC update cycle - track the RTC through one complete update
131 * cycle (1 second)
132 */
133 startup_timestamp_counter();
134
135 while (!(RTCRA & RTCRA_UIP)) {}
136 while ((RTCRA & RTCRA_UIP)) {}
137
138 count0 = TMTSCBC;
139
140 while (!(RTCRA & RTCRA_UIP)) {}
141
142 counth = TMTSCBC;
143
144 while ((RTCRA & RTCRA_UIP)) {}
145
146 count1 = TMTSCBC;
147
148 shutdown_timestamp_counter();
149
150 MN10300_TSCCLK = count0 - count1; /* the timers count down */
151 mn10300_rtc_update_period = counth - count1;
152 MN10300_TSC_PER_HZ = MN10300_TSCCLK / HZ;
153} 132}
diff --git a/arch/mn10300/kernel/setup.c b/arch/mn10300/kernel/setup.c
index d464affcba0e..9e7a3209a3e1 100644
--- a/arch/mn10300/kernel/setup.c
+++ b/arch/mn10300/kernel/setup.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/cpu.h>
25#include <asm/processor.h> 26#include <asm/processor.h>
26#include <linux/console.h> 27#include <linux/console.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -30,7 +31,6 @@
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/smp.h> 32#include <asm/smp.h>
32#include <proc/proc.h> 33#include <proc/proc.h>
33#include <asm/busctl-regs.h>
34#include <asm/fpu.h> 34#include <asm/fpu.h>
35#include <asm/sections.h> 35#include <asm/sections.h>
36 36
@@ -64,11 +64,13 @@ unsigned long memory_size;
64struct thread_info *__current_ti = &init_thread_union.thread_info; 64struct thread_info *__current_ti = &init_thread_union.thread_info;
65struct task_struct *__current = &init_task; 65struct task_struct *__current = &init_task;
66 66
67#define mn10300_known_cpus 3 67#define mn10300_known_cpus 5
68static const char *const mn10300_cputypes[] = { 68static const char *const mn10300_cputypes[] = {
69 "am33v1", 69 "am33-1",
70 "am33v2", 70 "am33-2",
71 "am34v1", 71 "am34-1",
72 "am33-3",
73 "am34-2",
72 "unknown" 74 "unknown"
73}; 75};
74 76
@@ -123,6 +125,7 @@ void __init setup_arch(char **cmdline_p)
123 125
124 cpu_init(); 126 cpu_init();
125 unit_setup(); 127 unit_setup();
128 smp_init_cpus();
126 parse_mem_cmdline(cmdline_p); 129 parse_mem_cmdline(cmdline_p);
127 130
128 init_mm.start_code = (unsigned long)&_text; 131 init_mm.start_code = (unsigned long)&_text;
@@ -179,57 +182,55 @@ void __init setup_arch(char **cmdline_p)
179void __init cpu_init(void) 182void __init cpu_init(void)
180{ 183{
181 unsigned long cpurev = CPUREV, type; 184 unsigned long cpurev = CPUREV, type;
182 unsigned long base, size;
183 185
184 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S; 186 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S;
185 if (type > mn10300_known_cpus) 187 if (type > mn10300_known_cpus)
186 type = mn10300_known_cpus; 188 type = mn10300_known_cpus;
187 189
188 printk(KERN_INFO "Matsushita %s, rev %ld\n", 190 printk(KERN_INFO "Panasonic %s, rev %ld\n",
189 mn10300_cputypes[type], 191 mn10300_cputypes[type],
190 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S); 192 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S);
191 193
192 /* determine the memory size and base from the memory controller regs */ 194 get_mem_info(&phys_memory_base, &memory_size);
193 memory_size = 0; 195 phys_memory_end = phys_memory_base + memory_size;
194
195 base = SDBASE(0);
196 if (base & SDBASE_CE) {
197 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
198 size = ~size + 1;
199 base &= SDBASE_CBA;
200 196
201 printk(KERN_INFO "SDRAM[0]: %luMb @%08lx\n", size >> 20, base); 197 fpu_init_state();
202 memory_size += size; 198}
203 phys_memory_base = base;
204 }
205 199
206 base = SDBASE(1); 200static struct cpu cpu_devices[NR_CPUS];
207 if (base & SDBASE_CE) {
208 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
209 size = ~size + 1;
210 base &= SDBASE_CBA;
211 201
212 printk(KERN_INFO "SDRAM[1]: %luMb @%08lx\n", size >> 20, base); 202static int __init topology_init(void)
213 memory_size += size; 203{
214 if (phys_memory_base == 0) 204 int i;
215 phys_memory_base = base;
216 }
217 205
218 phys_memory_end = phys_memory_base + memory_size; 206 for_each_present_cpu(i)
207 register_cpu(&cpu_devices[i], i);
219 208
220#ifdef CONFIG_FPU 209 return 0;
221 fpu_init_state();
222#endif
223} 210}
224 211
212subsys_initcall(topology_init);
213
225/* 214/*
226 * Get CPU information for use by the procfs. 215 * Get CPU information for use by the procfs.
227 */ 216 */
228static int show_cpuinfo(struct seq_file *m, void *v) 217static int show_cpuinfo(struct seq_file *m, void *v)
229{ 218{
219#ifdef CONFIG_SMP
220 struct mn10300_cpuinfo *c = v;
221 unsigned long cpu_id = c - cpu_data;
222 unsigned long cpurev = c->type, type, icachesz, dcachesz;
223#else /* CONFIG_SMP */
224 unsigned long cpu_id = 0;
230 unsigned long cpurev = CPUREV, type, icachesz, dcachesz; 225 unsigned long cpurev = CPUREV, type, icachesz, dcachesz;
226#endif /* CONFIG_SMP */
231 227
232 type = (CPUREV & CPUREV_TYPE) >> CPUREV_TYPE_S; 228#ifdef CONFIG_SMP
229 if (!cpu_online(cpu_id))
230 return 0;
231#endif
232
233 type = (cpurev & CPUREV_TYPE) >> CPUREV_TYPE_S;
233 if (type > mn10300_known_cpus) 234 if (type > mn10300_known_cpus)
234 type = mn10300_known_cpus; 235 type = mn10300_known_cpus;
235 236
@@ -244,13 +245,14 @@ static int show_cpuinfo(struct seq_file *m, void *v)
244 1024; 245 1024;
245 246
246 seq_printf(m, 247 seq_printf(m,
247 "processor : 0\n" 248 "processor : %ld\n"
248 "vendor_id : Matsushita\n" 249 "vendor_id : " PROCESSOR_VENDOR_NAME "\n"
249 "cpu core : %s\n" 250 "cpu core : %s\n"
250 "cpu rev : %lu\n" 251 "cpu rev : %lu\n"
251 "model name : " PROCESSOR_MODEL_NAME "\n" 252 "model name : " PROCESSOR_MODEL_NAME "\n"
252 "icache size: %lu\n" 253 "icache size: %lu\n"
253 "dcache size: %lu\n", 254 "dcache size: %lu\n",
255 cpu_id,
254 mn10300_cputypes[type], 256 mn10300_cputypes[type],
255 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S, 257 (cpurev & CPUREV_REVISION) >> CPUREV_REVISION_S,
256 icachesz, 258 icachesz,
@@ -262,8 +264,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
262 "bogomips : %lu.%02lu\n\n", 264 "bogomips : %lu.%02lu\n\n",
263 MN10300_IOCLK / 1000000, 265 MN10300_IOCLK / 1000000,
264 (MN10300_IOCLK / 10000) % 100, 266 (MN10300_IOCLK / 10000) % 100,
267#ifdef CONFIG_SMP
268 c->loops_per_jiffy / (500000 / HZ),
269 (c->loops_per_jiffy / (5000 / HZ)) % 100
270#else /* CONFIG_SMP */
265 loops_per_jiffy / (500000 / HZ), 271 loops_per_jiffy / (500000 / HZ),
266 (loops_per_jiffy / (5000 / HZ)) % 100 272 (loops_per_jiffy / (5000 / HZ)) % 100
273#endif /* CONFIG_SMP */
267 ); 274 );
268 275
269 return 0; 276 return 0;
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c
index d4de05ab7864..690f4e9507d7 100644
--- a/arch/mn10300/kernel/signal.c
+++ b/arch/mn10300/kernel/signal.c
@@ -91,7 +91,7 @@ asmlinkage long sys_sigaction(int sig,
91 */ 91 */
92asmlinkage long sys_sigaltstack(const stack_t __user *uss, stack_t *uoss) 92asmlinkage long sys_sigaltstack(const stack_t __user *uss, stack_t *uoss)
93{ 93{
94 return do_sigaltstack(uss, uoss, __frame->sp); 94 return do_sigaltstack(uss, uoss, current_frame()->sp);
95} 95}
96 96
97/* 97/*
@@ -156,10 +156,11 @@ badframe:
156 */ 156 */
157asmlinkage long sys_sigreturn(void) 157asmlinkage long sys_sigreturn(void)
158{ 158{
159 struct sigframe __user *frame = (struct sigframe __user *) __frame->sp; 159 struct sigframe __user *frame;
160 sigset_t set; 160 sigset_t set;
161 long d0; 161 long d0;
162 162
163 frame = (struct sigframe __user *) current_frame()->sp;
163 if (verify_area(VERIFY_READ, frame, sizeof(*frame))) 164 if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
164 goto badframe; 165 goto badframe;
165 if (__get_user(set.sig[0], &frame->sc.oldmask)) 166 if (__get_user(set.sig[0], &frame->sc.oldmask))
@@ -176,7 +177,7 @@ asmlinkage long sys_sigreturn(void)
176 recalc_sigpending(); 177 recalc_sigpending();
177 spin_unlock_irq(&current->sighand->siglock); 178 spin_unlock_irq(&current->sighand->siglock);
178 179
179 if (restore_sigcontext(__frame, &frame->sc, &d0)) 180 if (restore_sigcontext(current_frame(), &frame->sc, &d0))
180 goto badframe; 181 goto badframe;
181 182
182 return d0; 183 return d0;
@@ -191,11 +192,11 @@ badframe:
191 */ 192 */
192asmlinkage long sys_rt_sigreturn(void) 193asmlinkage long sys_rt_sigreturn(void)
193{ 194{
194 struct rt_sigframe __user *frame = 195 struct rt_sigframe __user *frame;
195 (struct rt_sigframe __user *) __frame->sp;
196 sigset_t set; 196 sigset_t set;
197 unsigned long d0; 197 long d0;
198 198
199 frame = (struct rt_sigframe __user *) current_frame()->sp;
199 if (verify_area(VERIFY_READ, frame, sizeof(*frame))) 200 if (verify_area(VERIFY_READ, frame, sizeof(*frame)))
200 goto badframe; 201 goto badframe;
201 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) 202 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
@@ -207,10 +208,11 @@ asmlinkage long sys_rt_sigreturn(void)
207 recalc_sigpending(); 208 recalc_sigpending();
208 spin_unlock_irq(&current->sighand->siglock); 209 spin_unlock_irq(&current->sighand->siglock);
209 210
210 if (restore_sigcontext(__frame, &frame->uc.uc_mcontext, &d0)) 211 if (restore_sigcontext(current_frame(), &frame->uc.uc_mcontext, &d0))
211 goto badframe; 212 goto badframe;
212 213
213 if (do_sigaltstack(&frame->uc.uc_stack, NULL, __frame->sp) == -EFAULT) 214 if (do_sigaltstack(&frame->uc.uc_stack, NULL, current_frame()->sp) ==
215 -EFAULT)
214 goto badframe; 216 goto badframe;
215 217
216 return d0; 218 return d0;
@@ -572,7 +574,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)
572 574
573 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 575 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
574 clear_thread_flag(TIF_NOTIFY_RESUME); 576 clear_thread_flag(TIF_NOTIFY_RESUME);
575 tracehook_notify_resume(__frame); 577 tracehook_notify_resume(current_frame());
576 if (current->replacement_session_keyring) 578 if (current->replacement_session_keyring)
577 key_replace_session_keyring(); 579 key_replace_session_keyring();
578 } 580 }
diff --git a/arch/mn10300/kernel/smp-low.S b/arch/mn10300/kernel/smp-low.S
new file mode 100644
index 000000000000..72938cefc05e
--- /dev/null
+++ b/arch/mn10300/kernel/smp-low.S
@@ -0,0 +1,97 @@
1/* SMP IPI low-level handler
2 *
3 * Copyright (C) 2006-2007 Matsushita Electric Industrial Co., Ltd.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <linux/sys.h>
14#include <linux/linkage.h>
15#include <asm/smp.h>
16#include <asm/system.h>
17#include <asm/thread_info.h>
18#include <asm/cpu-regs.h>
19#include <proc/smp-regs.h>
20#include <asm/asm-offsets.h>
21#include <asm/frame.inc>
22
23 .am33_2
24
25###############################################################################
26#
27# IPI interrupt handler
28#
29###############################################################################
30 .globl mn10300_low_ipi_handler
31mn10300_low_ipi_handler:
32 add -4,sp
33 mov d0,(sp)
34 movhu (IAGR),d0
35 and IAGR_GN,d0
36 lsr 0x2,d0
37#ifdef CONFIG_MN10300_CACHE_ENABLED
38 cmp FLUSH_CACHE_IPI,d0
39 beq mn10300_flush_cache_ipi
40#endif
41 cmp SMP_BOOT_IRQ,d0
42 beq mn10300_smp_boot_ipi
43 /* OTHERS */
44 mov (sp),d0
45 add 4,sp
46#ifdef CONFIG_GDBSTUB
47 jmp gdbstub_io_rx_handler
48#else
49 jmp end
50#endif
51
52###############################################################################
53#
54# Cache flush IPI interrupt handler
55#
56###############################################################################
57#ifdef CONFIG_MN10300_CACHE_ENABLED
58mn10300_flush_cache_ipi:
59 mov (sp),d0
60 add 4,sp
61
62 /* FLUSH_CACHE_IPI */
63 add -4,sp
64 SAVE_ALL
65 mov GxICR_DETECT,d2
66 movbu d2,(GxICR(FLUSH_CACHE_IPI)) # ACK the interrupt
67 movhu (GxICR(FLUSH_CACHE_IPI)),d2
68 call smp_cache_interrupt[],0
69 RESTORE_ALL
70 jmp end
71#endif
72
73###############################################################################
74#
75# SMP boot CPU IPI interrupt handler
76#
77###############################################################################
78mn10300_smp_boot_ipi:
79 /* clear interrupt */
80 movhu (GxICR(SMP_BOOT_IRQ)),d0
81 and ~GxICR_REQUEST,d0
82 movhu d0,(GxICR(SMP_BOOT_IRQ))
83 mov (sp),d0
84 add 4,sp
85
86 # get stack
87 mov (CPUID),a0
88 add -1,a0
89 add a0,a0
90 add a0,a0
91 mov (start_stack,a0),a0
92 mov a0,sp
93 jmp initialize_secondary
94
95
96# Jump here after RTI to suppress the icache lookahead
97end:
diff --git a/arch/mn10300/kernel/smp.c b/arch/mn10300/kernel/smp.c
new file mode 100644
index 000000000000..0dcd1c686ba8
--- /dev/null
+++ b/arch/mn10300/kernel/smp.c
@@ -0,0 +1,1152 @@
1/* SMP support routines.
2 *
3 * Copyright (C) 2006-2008 Panasonic Corporation
4 * All Rights Reserved.
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 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/interrupt.h>
17#include <linux/spinlock.h>
18#include <linux/init.h>
19#include <linux/jiffies.h>
20#include <linux/cpumask.h>
21#include <linux/err.h>
22#include <linux/kernel.h>
23#include <linux/delay.h>
24#include <linux/sched.h>
25#include <linux/profile.h>
26#include <linux/smp.h>
27#include <asm/tlbflush.h>
28#include <asm/system.h>
29#include <asm/bitops.h>
30#include <asm/processor.h>
31#include <asm/bug.h>
32#include <asm/exceptions.h>
33#include <asm/hardirq.h>
34#include <asm/fpu.h>
35#include <asm/mmu_context.h>
36#include <asm/thread_info.h>
37#include <asm/cpu-regs.h>
38#include <asm/intctl-regs.h>
39#include "internal.h"
40
41#ifdef CONFIG_HOTPLUG_CPU
42#include <linux/cpu.h>
43#include <asm/cacheflush.h>
44
45static unsigned long sleep_mode[NR_CPUS];
46
47static void run_sleep_cpu(unsigned int cpu);
48static void run_wakeup_cpu(unsigned int cpu);
49#endif /* CONFIG_HOTPLUG_CPU */
50
51/*
52 * Debug Message function
53 */
54
55#undef DEBUG_SMP
56#ifdef DEBUG_SMP
57#define Dprintk(fmt, ...) printk(KERN_DEBUG fmt, ##__VA_ARGS__)
58#else
59#define Dprintk(fmt, ...) no_printk(KERN_DEBUG fmt, ##__VA_ARGS__)
60#endif
61
62/* timeout value in msec for smp_nmi_call_function. zero is no timeout. */
63#define CALL_FUNCTION_NMI_IPI_TIMEOUT 0
64
65/*
66 * Structure and data for smp_nmi_call_function().
67 */
68struct nmi_call_data_struct {
69 smp_call_func_t func;
70 void *info;
71 cpumask_t started;
72 cpumask_t finished;
73 int wait;
74 char size_alignment[0]
75 __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
76} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
77
78static DEFINE_SPINLOCK(smp_nmi_call_lock);
79static struct nmi_call_data_struct *nmi_call_data;
80
81/*
82 * Data structures and variables
83 */
84static cpumask_t cpu_callin_map; /* Bitmask of callin CPUs */
85static cpumask_t cpu_callout_map; /* Bitmask of callout CPUs */
86cpumask_t cpu_boot_map; /* Bitmask of boot APs */
87unsigned long start_stack[NR_CPUS - 1];
88
89/*
90 * Per CPU parameters
91 */
92struct mn10300_cpuinfo cpu_data[NR_CPUS] __cacheline_aligned;
93
94static int cpucount; /* The count of boot CPUs */
95static cpumask_t smp_commenced_mask;
96cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
97
98/*
99 * Function Prototypes
100 */
101static int do_boot_cpu(int);
102static void smp_show_cpu_info(int cpu_id);
103static void smp_callin(void);
104static void smp_online(void);
105static void smp_store_cpu_info(int);
106static void smp_cpu_init(void);
107static void smp_tune_scheduling(void);
108static void send_IPI_mask(const cpumask_t *cpumask, int irq);
109static void init_ipi(void);
110
111/*
112 * IPI Initialization interrupt definitions
113 */
114static void mn10300_ipi_disable(unsigned int irq);
115static void mn10300_ipi_enable(unsigned int irq);
116static void mn10300_ipi_ack(unsigned int irq);
117static void mn10300_ipi_nop(unsigned int irq);
118
119static struct irq_chip mn10300_ipi_type = {
120 .name = "cpu_ipi",
121 .disable = mn10300_ipi_disable,
122 .enable = mn10300_ipi_enable,
123 .ack = mn10300_ipi_ack,
124 .eoi = mn10300_ipi_nop
125};
126
127static irqreturn_t smp_reschedule_interrupt(int irq, void *dev_id);
128static irqreturn_t smp_call_function_interrupt(int irq, void *dev_id);
129
130static struct irqaction reschedule_ipi = {
131 .handler = smp_reschedule_interrupt,
132 .name = "smp reschedule IPI"
133};
134static struct irqaction call_function_ipi = {
135 .handler = smp_call_function_interrupt,
136 .name = "smp call function IPI"
137};
138
139#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
140static irqreturn_t smp_ipi_timer_interrupt(int irq, void *dev_id);
141static struct irqaction local_timer_ipi = {
142 .handler = smp_ipi_timer_interrupt,
143 .flags = IRQF_DISABLED,
144 .name = "smp local timer IPI"
145};
146#endif
147
148/**
149 * init_ipi - Initialise the IPI mechanism
150 */
151static void init_ipi(void)
152{
153 unsigned long flags;
154 u16 tmp16;
155
156 /* set up the reschedule IPI */
157 set_irq_chip_and_handler(RESCHEDULE_IPI,
158 &mn10300_ipi_type, handle_percpu_irq);
159 setup_irq(RESCHEDULE_IPI, &reschedule_ipi);
160 set_intr_level(RESCHEDULE_IPI, RESCHEDULE_GxICR_LV);
161 mn10300_ipi_enable(RESCHEDULE_IPI);
162
163 /* set up the call function IPI */
164 set_irq_chip_and_handler(CALL_FUNC_SINGLE_IPI,
165 &mn10300_ipi_type, handle_percpu_irq);
166 setup_irq(CALL_FUNC_SINGLE_IPI, &call_function_ipi);
167 set_intr_level(CALL_FUNC_SINGLE_IPI, CALL_FUNCTION_GxICR_LV);
168 mn10300_ipi_enable(CALL_FUNC_SINGLE_IPI);
169
170 /* set up the local timer IPI */
171#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || \
172 defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
173 set_irq_chip_and_handler(LOCAL_TIMER_IPI,
174 &mn10300_ipi_type, handle_percpu_irq);
175 setup_irq(LOCAL_TIMER_IPI, &local_timer_ipi);
176 set_intr_level(LOCAL_TIMER_IPI, LOCAL_TIMER_GxICR_LV);
177 mn10300_ipi_enable(LOCAL_TIMER_IPI);
178#endif
179
180#ifdef CONFIG_MN10300_CACHE_ENABLED
181 /* set up the cache flush IPI */
182 flags = arch_local_cli_save();
183 __set_intr_stub(NUM2EXCEP_IRQ_LEVEL(FLUSH_CACHE_GxICR_LV),
184 mn10300_low_ipi_handler);
185 GxICR(FLUSH_CACHE_IPI) = FLUSH_CACHE_GxICR_LV | GxICR_DETECT;
186 mn10300_ipi_enable(FLUSH_CACHE_IPI);
187 arch_local_irq_restore(flags);
188#endif
189
190 /* set up the NMI call function IPI */
191 flags = arch_local_cli_save();
192 GxICR(CALL_FUNCTION_NMI_IPI) = GxICR_NMI | GxICR_ENABLE | GxICR_DETECT;
193 tmp16 = GxICR(CALL_FUNCTION_NMI_IPI);
194 arch_local_irq_restore(flags);
195
196 /* set up the SMP boot IPI */
197 flags = arch_local_cli_save();
198 __set_intr_stub(NUM2EXCEP_IRQ_LEVEL(SMP_BOOT_GxICR_LV),
199 mn10300_low_ipi_handler);
200 arch_local_irq_restore(flags);
201}
202
203/**
204 * mn10300_ipi_shutdown - Shut down handling of an IPI
205 * @irq: The IPI to be shut down.
206 */
207static void mn10300_ipi_shutdown(unsigned int irq)
208{
209 unsigned long flags;
210 u16 tmp;
211
212 flags = arch_local_cli_save();
213
214 tmp = GxICR(irq);
215 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_DETECT;
216 tmp = GxICR(irq);
217
218 arch_local_irq_restore(flags);
219}
220
221/**
222 * mn10300_ipi_enable - Enable an IPI
223 * @irq: The IPI to be enabled.
224 */
225static void mn10300_ipi_enable(unsigned int irq)
226{
227 unsigned long flags;
228 u16 tmp;
229
230 flags = arch_local_cli_save();
231
232 tmp = GxICR(irq);
233 GxICR(irq) = (tmp & GxICR_LEVEL) | GxICR_ENABLE;
234 tmp = GxICR(irq);
235
236 arch_local_irq_restore(flags);
237}
238
239/**
240 * mn10300_ipi_disable - Disable an IPI
241 * @irq: The IPI to be disabled.
242 */
243static void mn10300_ipi_disable(unsigned int irq)
244{
245 unsigned long flags;
246 u16 tmp;
247
248 flags = arch_local_cli_save();
249
250 tmp = GxICR(irq);
251 GxICR(irq) = tmp & GxICR_LEVEL;
252 tmp = GxICR(irq);
253
254 arch_local_irq_restore(flags);
255}
256
257/**
258 * mn10300_ipi_ack - Acknowledge an IPI interrupt in the PIC
259 * @irq: The IPI to be acknowledged.
260 *
261 * Clear the interrupt detection flag for the IPI on the appropriate interrupt
262 * channel in the PIC.
263 */
264static void mn10300_ipi_ack(unsigned int irq)
265{
266 unsigned long flags;
267 u16 tmp;
268
269 flags = arch_local_cli_save();
270 GxICR_u8(irq) = GxICR_DETECT;
271 tmp = GxICR(irq);
272 arch_local_irq_restore(flags);
273}
274
275/**
276 * mn10300_ipi_nop - Dummy IPI action
277 * @irq: The IPI to be acted upon.
278 */
279static void mn10300_ipi_nop(unsigned int irq)
280{
281}
282
283/**
284 * send_IPI_mask - Send IPIs to all CPUs in list
285 * @cpumask: The list of CPUs to target.
286 * @irq: The IPI request to be sent.
287 *
288 * Send the specified IPI to all the CPUs in the list, not waiting for them to
289 * finish before returning. The caller is responsible for synchronisation if
290 * that is needed.
291 */
292static void send_IPI_mask(const cpumask_t *cpumask, int irq)
293{
294 int i;
295 u16 tmp;
296
297 for (i = 0; i < NR_CPUS; i++) {
298 if (cpu_isset(i, *cpumask)) {
299 /* send IPI */
300 tmp = CROSS_GxICR(irq, i);
301 CROSS_GxICR(irq, i) =
302 tmp | GxICR_REQUEST | GxICR_DETECT;
303 tmp = CROSS_GxICR(irq, i); /* flush write buffer */
304 }
305 }
306}
307
308/**
309 * send_IPI_self - Send an IPI to this CPU.
310 * @irq: The IPI request to be sent.
311 *
312 * Send the specified IPI to the current CPU.
313 */
314void send_IPI_self(int irq)
315{
316 send_IPI_mask(cpumask_of(smp_processor_id()), irq);
317}
318
319/**
320 * send_IPI_allbutself - Send IPIs to all the other CPUs.
321 * @irq: The IPI request to be sent.
322 *
323 * Send the specified IPI to all CPUs in the system barring the current one,
324 * not waiting for them to finish before returning. The caller is responsible
325 * for synchronisation if that is needed.
326 */
327void send_IPI_allbutself(int irq)
328{
329 cpumask_t cpumask;
330
331 cpumask = cpu_online_map;
332 cpu_clear(smp_processor_id(), cpumask);
333 send_IPI_mask(&cpumask, irq);
334}
335
336void arch_send_call_function_ipi_mask(const struct cpumask *mask)
337{
338 BUG();
339 /*send_IPI_mask(mask, CALL_FUNCTION_IPI);*/
340}
341
342void arch_send_call_function_single_ipi(int cpu)
343{
344 send_IPI_mask(cpumask_of(cpu), CALL_FUNC_SINGLE_IPI);
345}
346
347/**
348 * smp_send_reschedule - Send reschedule IPI to a CPU
349 * @cpu: The CPU to target.
350 */
351void smp_send_reschedule(int cpu)
352{
353 send_IPI_mask(cpumask_of(cpu), RESCHEDULE_IPI);
354}
355
356/**
357 * smp_nmi_call_function - Send a call function NMI IPI to all CPUs
358 * @func: The function to ask to be run.
359 * @info: The context data to pass to that function.
360 * @wait: If true, wait (atomically) until function is run on all CPUs.
361 *
362 * Send a non-maskable request to all CPUs in the system, requesting them to
363 * run the specified function with the given context data, and, potentially, to
364 * wait for completion of that function on all CPUs.
365 *
366 * Returns 0 if successful, -ETIMEDOUT if we were asked to wait, but hit the
367 * timeout.
368 */
369int smp_nmi_call_function(smp_call_func_t func, void *info, int wait)
370{
371 struct nmi_call_data_struct data;
372 unsigned long flags;
373 unsigned int cnt;
374 int cpus, ret = 0;
375
376 cpus = num_online_cpus() - 1;
377 if (cpus < 1)
378 return 0;
379
380 data.func = func;
381 data.info = info;
382 data.started = cpu_online_map;
383 cpu_clear(smp_processor_id(), data.started);
384 data.wait = wait;
385 if (wait)
386 data.finished = data.started;
387
388 spin_lock_irqsave(&smp_nmi_call_lock, flags);
389 nmi_call_data = &data;
390 smp_mb();
391
392 /* Send a message to all other CPUs and wait for them to respond */
393 send_IPI_allbutself(CALL_FUNCTION_NMI_IPI);
394
395 /* Wait for response */
396 if (CALL_FUNCTION_NMI_IPI_TIMEOUT > 0) {
397 for (cnt = 0;
398 cnt < CALL_FUNCTION_NMI_IPI_TIMEOUT &&
399 !cpus_empty(data.started);
400 cnt++)
401 mdelay(1);
402
403 if (wait && cnt < CALL_FUNCTION_NMI_IPI_TIMEOUT) {
404 for (cnt = 0;
405 cnt < CALL_FUNCTION_NMI_IPI_TIMEOUT &&
406 !cpus_empty(data.finished);
407 cnt++)
408 mdelay(1);
409 }
410
411 if (cnt >= CALL_FUNCTION_NMI_IPI_TIMEOUT)
412 ret = -ETIMEDOUT;
413
414 } else {
415 /* If timeout value is zero, wait until cpumask has been
416 * cleared */
417 while (!cpus_empty(data.started))
418 barrier();
419 if (wait)
420 while (!cpus_empty(data.finished))
421 barrier();
422 }
423
424 spin_unlock_irqrestore(&smp_nmi_call_lock, flags);
425 return ret;
426}
427
428/**
429 * stop_this_cpu - Callback to stop a CPU.
430 * @unused: Callback context (ignored).
431 */
432void stop_this_cpu(void *unused)
433{
434 static volatile int stopflag;
435 unsigned long flags;
436
437#ifdef CONFIG_GDBSTUB
438 /* In case of single stepping smp_send_stop by other CPU,
439 * clear procindebug to avoid deadlock.
440 */
441 atomic_set(&procindebug[smp_processor_id()], 0);
442#endif /* CONFIG_GDBSTUB */
443
444 flags = arch_local_cli_save();
445 cpu_clear(smp_processor_id(), cpu_online_map);
446
447 while (!stopflag)
448 cpu_relax();
449
450 cpu_set(smp_processor_id(), cpu_online_map);
451 arch_local_irq_restore(flags);
452}
453
454/**
455 * smp_send_stop - Send a stop request to all CPUs.
456 */
457void smp_send_stop(void)
458{
459 smp_nmi_call_function(stop_this_cpu, NULL, 0);
460}
461
462/**
463 * smp_reschedule_interrupt - Reschedule IPI handler
464 * @irq: The interrupt number.
465 * @dev_id: The device ID.
466 *
467 * We need do nothing here, since the scheduling will be effected on our way
468 * back through entry.S.
469 *
470 * Returns IRQ_HANDLED to indicate we handled the interrupt successfully.
471 */
472static irqreturn_t smp_reschedule_interrupt(int irq, void *dev_id)
473{
474 /* do nothing */
475 return IRQ_HANDLED;
476}
477
478/**
479 * smp_call_function_interrupt - Call function IPI handler
480 * @irq: The interrupt number.
481 * @dev_id: The device ID.
482 *
483 * Returns IRQ_HANDLED to indicate we handled the interrupt successfully.
484 */
485static irqreturn_t smp_call_function_interrupt(int irq, void *dev_id)
486{
487 /* generic_smp_call_function_interrupt(); */
488 generic_smp_call_function_single_interrupt();
489 return IRQ_HANDLED;
490}
491
492/**
493 * smp_nmi_call_function_interrupt - Non-maskable call function IPI handler
494 */
495void smp_nmi_call_function_interrupt(void)
496{
497 smp_call_func_t func = nmi_call_data->func;
498 void *info = nmi_call_data->info;
499 int wait = nmi_call_data->wait;
500
501 /* Notify the initiating CPU that I've grabbed the data and am about to
502 * execute the function
503 */
504 smp_mb();
505 cpu_clear(smp_processor_id(), nmi_call_data->started);
506 (*func)(info);
507
508 if (wait) {
509 smp_mb();
510 cpu_clear(smp_processor_id(), nmi_call_data->finished);
511 }
512}
513
514#if !defined(CONFIG_GENERIC_CLOCKEVENTS) || \
515 defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
516/**
517 * smp_ipi_timer_interrupt - Local timer IPI handler
518 * @irq: The interrupt number.
519 * @dev_id: The device ID.
520 *
521 * Returns IRQ_HANDLED to indicate we handled the interrupt successfully.
522 */
523static irqreturn_t smp_ipi_timer_interrupt(int irq, void *dev_id)
524{
525 return local_timer_interrupt();
526}
527#endif
528
529void __init smp_init_cpus(void)
530{
531 int i;
532 for (i = 0; i < NR_CPUS; i++) {
533 set_cpu_possible(i, true);
534 set_cpu_present(i, true);
535 }
536}
537
538/**
539 * smp_cpu_init - Initialise AP in start_secondary.
540 *
541 * For this Application Processor, set up init_mm, initialise FPU and set
542 * interrupt level 0-6 setting.
543 */
544static void __init smp_cpu_init(void)
545{
546 unsigned long flags;
547 int cpu_id = smp_processor_id();
548 u16 tmp16;
549
550 if (test_and_set_bit(cpu_id, &cpu_initialized)) {
551 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu_id);
552 for (;;)
553 local_irq_enable();
554 }
555 printk(KERN_INFO "Initializing CPU#%d\n", cpu_id);
556
557 atomic_inc(&init_mm.mm_count);
558 current->active_mm = &init_mm;
559 BUG_ON(current->mm);
560
561 enter_lazy_tlb(&init_mm, current);
562
563 /* Force FPU initialization */
564 clear_using_fpu(current);
565
566 GxICR(CALL_FUNC_SINGLE_IPI) = CALL_FUNCTION_GxICR_LV | GxICR_DETECT;
567 mn10300_ipi_enable(CALL_FUNC_SINGLE_IPI);
568
569 GxICR(LOCAL_TIMER_IPI) = LOCAL_TIMER_GxICR_LV | GxICR_DETECT;
570 mn10300_ipi_enable(LOCAL_TIMER_IPI);
571
572 GxICR(RESCHEDULE_IPI) = RESCHEDULE_GxICR_LV | GxICR_DETECT;
573 mn10300_ipi_enable(RESCHEDULE_IPI);
574
575#ifdef CONFIG_MN10300_CACHE_ENABLED
576 GxICR(FLUSH_CACHE_IPI) = FLUSH_CACHE_GxICR_LV | GxICR_DETECT;
577 mn10300_ipi_enable(FLUSH_CACHE_IPI);
578#endif
579
580 mn10300_ipi_shutdown(SMP_BOOT_IRQ);
581
582 /* Set up the non-maskable call function IPI */
583 flags = arch_local_cli_save();
584 GxICR(CALL_FUNCTION_NMI_IPI) = GxICR_NMI | GxICR_ENABLE | GxICR_DETECT;
585 tmp16 = GxICR(CALL_FUNCTION_NMI_IPI);
586 arch_local_irq_restore(flags);
587}
588
589/**
590 * smp_prepare_cpu_init - Initialise CPU in startup_secondary
591 *
592 * Set interrupt level 0-6 setting and init ICR of gdbstub.
593 */
594void smp_prepare_cpu_init(void)
595{
596 int loop;
597
598 /* Set the interrupt vector registers */
599 IVAR0 = EXCEP_IRQ_LEVEL0;
600 IVAR1 = EXCEP_IRQ_LEVEL1;
601 IVAR2 = EXCEP_IRQ_LEVEL2;
602 IVAR3 = EXCEP_IRQ_LEVEL3;
603 IVAR4 = EXCEP_IRQ_LEVEL4;
604 IVAR5 = EXCEP_IRQ_LEVEL5;
605 IVAR6 = EXCEP_IRQ_LEVEL6;
606
607 /* Disable all interrupts and set to priority 6 (lowest) */
608 for (loop = 0; loop < GxICR_NUM_IRQS; loop++)
609 GxICR(loop) = GxICR_LEVEL_6 | GxICR_DETECT;
610
611#ifdef CONFIG_GDBSTUB
612 /* initialise GDB-stub */
613 do {
614 unsigned long flags;
615 u16 tmp16;
616
617 flags = arch_local_cli_save();
618 GxICR(GDB_NMI_IPI) = GxICR_NMI | GxICR_ENABLE | GxICR_DETECT;
619 tmp16 = GxICR(GDB_NMI_IPI);
620 arch_local_irq_restore(flags);
621 } while (0);
622#endif
623}
624
625/**
626 * start_secondary - Activate a secondary CPU (AP)
627 * @unused: Thread parameter (ignored).
628 */
629int __init start_secondary(void *unused)
630{
631 smp_cpu_init();
632 smp_callin();
633 while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
634 cpu_relax();
635
636 local_flush_tlb();
637 preempt_disable();
638 smp_online();
639
640#ifdef CONFIG_GENERIC_CLOCKEVENTS
641 init_clockevents();
642#endif
643 cpu_idle();
644 return 0;
645}
646
647/**
648 * smp_prepare_cpus - Boot up secondary CPUs (APs)
649 * @max_cpus: Maximum number of CPUs to boot.
650 *
651 * Call do_boot_cpu, and boot up APs.
652 */
653void __init smp_prepare_cpus(unsigned int max_cpus)
654{
655 int phy_id;
656
657 /* Setup boot CPU information */
658 smp_store_cpu_info(0);
659 smp_tune_scheduling();
660
661 init_ipi();
662
663 /* If SMP should be disabled, then finish */
664 if (max_cpus == 0) {
665 printk(KERN_INFO "SMP mode deactivated.\n");
666 goto smp_done;
667 }
668
669 /* Boot secondary CPUs (for which phy_id > 0) */
670 for (phy_id = 0; phy_id < NR_CPUS; phy_id++) {
671 /* Don't boot primary CPU */
672 if (max_cpus <= cpucount + 1)
673 continue;
674 if (phy_id != 0)
675 do_boot_cpu(phy_id);
676 set_cpu_possible(phy_id, true);
677 smp_show_cpu_info(phy_id);
678 }
679
680smp_done:
681 Dprintk("Boot done.\n");
682}
683
684/**
685 * smp_store_cpu_info - Save a CPU's information
686 * @cpu: The CPU to save for.
687 *
688 * Save boot_cpu_data and jiffy for the specified CPU.
689 */
690static void __init smp_store_cpu_info(int cpu)
691{
692 struct mn10300_cpuinfo *ci = &cpu_data[cpu];
693
694 *ci = boot_cpu_data;
695 ci->loops_per_jiffy = loops_per_jiffy;
696 ci->type = CPUREV;
697}
698
699/**
700 * smp_tune_scheduling - Set time slice value
701 *
702 * Nothing to do here.
703 */
704static void __init smp_tune_scheduling(void)
705{
706}
707
708/**
709 * do_boot_cpu: Boot up one CPU
710 * @phy_id: Physical ID of CPU to boot.
711 *
712 * Send an IPI to a secondary CPU to boot it. Returns 0 on success, 1
713 * otherwise.
714 */
715static int __init do_boot_cpu(int phy_id)
716{
717 struct task_struct *idle;
718 unsigned long send_status, callin_status;
719 int timeout, cpu_id;
720
721 send_status = GxICR_REQUEST;
722 callin_status = 0;
723 timeout = 0;
724 cpu_id = phy_id;
725
726 cpucount++;
727
728 /* Create idle thread for this CPU */
729 idle = fork_idle(cpu_id);
730 if (IS_ERR(idle))
731 panic("Failed fork for CPU#%d.", cpu_id);
732
733 idle->thread.pc = (unsigned long)start_secondary;
734
735 printk(KERN_NOTICE "Booting CPU#%d\n", cpu_id);
736 start_stack[cpu_id - 1] = idle->thread.sp;
737
738 task_thread_info(idle)->cpu = cpu_id;
739
740 /* Send boot IPI to AP */
741 send_IPI_mask(cpumask_of(phy_id), SMP_BOOT_IRQ);
742
743 Dprintk("Waiting for send to finish...\n");
744
745 /* Wait for AP's IPI receive in 100[ms] */
746 do {
747 udelay(1000);
748 send_status =
749 CROSS_GxICR(SMP_BOOT_IRQ, phy_id) & GxICR_REQUEST;
750 } while (send_status == GxICR_REQUEST && timeout++ < 100);
751
752 Dprintk("Waiting for cpu_callin_map.\n");
753
754 if (send_status == 0) {
755 /* Allow AP to start initializing */
756 cpu_set(cpu_id, cpu_callout_map);
757
758 /* Wait for setting cpu_callin_map */
759 timeout = 0;
760 do {
761 udelay(1000);
762 callin_status = cpu_isset(cpu_id, cpu_callin_map);
763 } while (callin_status == 0 && timeout++ < 5000);
764
765 if (callin_status == 0)
766 Dprintk("Not responding.\n");
767 } else {
768 printk(KERN_WARNING "IPI not delivered.\n");
769 }
770
771 if (send_status == GxICR_REQUEST || callin_status == 0) {
772 cpu_clear(cpu_id, cpu_callout_map);
773 cpu_clear(cpu_id, cpu_callin_map);
774 cpu_clear(cpu_id, cpu_initialized);
775 cpucount--;
776 return 1;
777 }
778 return 0;
779}
780
781/**
782 * smp_show_cpu_info - Show SMP CPU information
783 * @cpu: The CPU of interest.
784 */
785static void __init smp_show_cpu_info(int cpu)
786{
787 struct mn10300_cpuinfo *ci = &cpu_data[cpu];
788
789 printk(KERN_INFO
790 "CPU#%d : ioclk speed: %lu.%02luMHz : bogomips : %lu.%02lu\n",
791 cpu,
792 MN10300_IOCLK / 1000000,
793 (MN10300_IOCLK / 10000) % 100,
794 ci->loops_per_jiffy / (500000 / HZ),
795 (ci->loops_per_jiffy / (5000 / HZ)) % 100);
796}
797
798/**
799 * smp_callin - Set cpu_callin_map of the current CPU ID
800 */
801static void __init smp_callin(void)
802{
803 unsigned long timeout;
804 int cpu;
805
806 cpu = smp_processor_id();
807 timeout = jiffies + (2 * HZ);
808
809 if (cpu_isset(cpu, cpu_callin_map)) {
810 printk(KERN_ERR "CPU#%d already present.\n", cpu);
811 BUG();
812 }
813 Dprintk("CPU#%d waiting for CALLOUT\n", cpu);
814
815 /* Wait for AP startup 2s total */
816 while (time_before(jiffies, timeout)) {
817 if (cpu_isset(cpu, cpu_callout_map))
818 break;
819 cpu_relax();
820 }
821
822 if (!time_before(jiffies, timeout)) {
823 printk(KERN_ERR
824 "BUG: CPU#%d started up but did not get a callout!\n",
825 cpu);
826 BUG();
827 }
828
829#ifdef CONFIG_CALIBRATE_DELAY
830 calibrate_delay(); /* Get our bogomips */
831#endif
832
833 /* Save our processor parameters */
834 smp_store_cpu_info(cpu);
835
836 /* Allow the boot processor to continue */
837 cpu_set(cpu, cpu_callin_map);
838}
839
840/**
841 * smp_online - Set cpu_online_map
842 */
843static void __init smp_online(void)
844{
845 int cpu;
846
847 cpu = smp_processor_id();
848
849 local_irq_enable();
850
851 cpu_set(cpu, cpu_online_map);
852 smp_wmb();
853}
854
855/**
856 * smp_cpus_done -
857 * @max_cpus: Maximum CPU count.
858 *
859 * Do nothing.
860 */
861void __init smp_cpus_done(unsigned int max_cpus)
862{
863}
864
865/*
866 * smp_prepare_boot_cpu - Set up stuff for the boot processor.
867 *
868 * Set up the cpu_online_map, cpu_callout_map and cpu_callin_map of the boot
869 * processor (CPU 0).
870 */
871void __devinit smp_prepare_boot_cpu(void)
872{
873 cpu_set(0, cpu_callout_map);
874 cpu_set(0, cpu_callin_map);
875 current_thread_info()->cpu = 0;
876}
877
878/*
879 * initialize_secondary - Initialise a secondary CPU (Application Processor).
880 *
881 * Set SP register and jump to thread's PC address.
882 */
883void initialize_secondary(void)
884{
885 asm volatile (
886 "mov %0,sp \n"
887 "jmp (%1) \n"
888 :
889 : "a"(current->thread.sp), "a"(current->thread.pc));
890}
891
892/**
893 * __cpu_up - Set smp_commenced_mask for the nominated CPU
894 * @cpu: The target CPU.
895 */
896int __devinit __cpu_up(unsigned int cpu)
897{
898 int timeout;
899
900#ifdef CONFIG_HOTPLUG_CPU
901 if (num_online_cpus() == 1)
902 disable_hlt();
903 if (sleep_mode[cpu])
904 run_wakeup_cpu(cpu);
905#endif /* CONFIG_HOTPLUG_CPU */
906
907 cpu_set(cpu, smp_commenced_mask);
908
909 /* Wait 5s total for a response */
910 for (timeout = 0 ; timeout < 5000 ; timeout++) {
911 if (cpu_isset(cpu, cpu_online_map))
912 break;
913 udelay(1000);
914 }
915
916 BUG_ON(!cpu_isset(cpu, cpu_online_map));
917 return 0;
918}
919
920/**
921 * setup_profiling_timer - Set up the profiling timer
922 * @multiplier - The frequency multiplier to use
923 *
924 * The frequency of the profiling timer can be changed by writing a multiplier
925 * value into /proc/profile.
926 */
927int setup_profiling_timer(unsigned int multiplier)
928{
929 return -EINVAL;
930}
931
932/*
933 * CPU hotplug routines
934 */
935#ifdef CONFIG_HOTPLUG_CPU
936
937static DEFINE_PER_CPU(struct cpu, cpu_devices);
938
939static int __init topology_init(void)
940{
941 int cpu, ret;
942
943 for_each_cpu(cpu) {
944 ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu, NULL);
945 if (ret)
946 printk(KERN_WARNING
947 "topology_init: register_cpu %d failed (%d)\n",
948 cpu, ret);
949 }
950 return 0;
951}
952
953subsys_initcall(topology_init);
954
955int __cpu_disable(void)
956{
957 int cpu = smp_processor_id();
958 if (cpu == 0)
959 return -EBUSY;
960
961 migrate_irqs();
962 cpu_clear(cpu, current->active_mm->cpu_vm_mask);
963 return 0;
964}
965
966void __cpu_die(unsigned int cpu)
967{
968 run_sleep_cpu(cpu);
969
970 if (num_online_cpus() == 1)
971 enable_hlt();
972}
973
974#ifdef CONFIG_MN10300_CACHE_ENABLED
975static inline void hotplug_cpu_disable_cache(void)
976{
977 int tmp;
978 asm volatile(
979 " movhu (%1),%0 \n"
980 " and %2,%0 \n"
981 " movhu %0,(%1) \n"
982 "1: movhu (%1),%0 \n"
983 " btst %3,%0 \n"
984 " bne 1b \n"
985 : "=&r"(tmp)
986 : "a"(&CHCTR),
987 "i"(~(CHCTR_ICEN | CHCTR_DCEN)),
988 "i"(CHCTR_ICBUSY | CHCTR_DCBUSY)
989 : "memory", "cc");
990}
991
992static inline void hotplug_cpu_enable_cache(void)
993{
994 int tmp;
995 asm volatile(
996 "movhu (%1),%0 \n"
997 "or %2,%0 \n"
998 "movhu %0,(%1) \n"
999 : "=&r"(tmp)
1000 : "a"(&CHCTR),
1001 "i"(CHCTR_ICEN | CHCTR_DCEN)
1002 : "memory", "cc");
1003}
1004
1005static inline void hotplug_cpu_invalidate_cache(void)
1006{
1007 int tmp;
1008 asm volatile (
1009 "movhu (%1),%0 \n"
1010 "or %2,%0 \n"
1011 "movhu %0,(%1) \n"
1012 : "=&r"(tmp)
1013 : "a"(&CHCTR),
1014 "i"(CHCTR_ICINV | CHCTR_DCINV)
1015 : "cc");
1016}
1017
1018#else /* CONFIG_MN10300_CACHE_ENABLED */
1019#define hotplug_cpu_disable_cache() do {} while (0)
1020#define hotplug_cpu_enable_cache() do {} while (0)
1021#define hotplug_cpu_invalidate_cache() do {} while (0)
1022#endif /* CONFIG_MN10300_CACHE_ENABLED */
1023
1024/**
1025 * hotplug_cpu_nmi_call_function - Call a function on other CPUs for hotplug
1026 * @cpumask: List of target CPUs.
1027 * @func: The function to call on those CPUs.
1028 * @info: The context data for the function to be called.
1029 * @wait: Whether to wait for the calls to complete.
1030 *
1031 * Non-maskably call a function on another CPU for hotplug purposes.
1032 *
1033 * This function must be called with maskable interrupts disabled.
1034 */
1035static int hotplug_cpu_nmi_call_function(cpumask_t cpumask,
1036 smp_call_func_t func, void *info,
1037 int wait)
1038{
1039 /*
1040 * The address and the size of nmi_call_func_mask_data
1041 * need to be aligned on L1_CACHE_BYTES.
1042 */
1043 static struct nmi_call_data_struct nmi_call_func_mask_data
1044 __cacheline_aligned;
1045 unsigned long start, end;
1046
1047 start = (unsigned long)&nmi_call_func_mask_data;
1048 end = start + sizeof(struct nmi_call_data_struct);
1049
1050 nmi_call_func_mask_data.func = func;
1051 nmi_call_func_mask_data.info = info;
1052 nmi_call_func_mask_data.started = cpumask;
1053 nmi_call_func_mask_data.wait = wait;
1054 if (wait)
1055 nmi_call_func_mask_data.finished = cpumask;
1056
1057 spin_lock(&smp_nmi_call_lock);
1058 nmi_call_data = &nmi_call_func_mask_data;
1059 mn10300_local_dcache_flush_range(start, end);
1060 smp_wmb();
1061
1062 send_IPI_mask(cpumask, CALL_FUNCTION_NMI_IPI);
1063
1064 do {
1065 mn10300_local_dcache_inv_range(start, end);
1066 barrier();
1067 } while (!cpus_empty(nmi_call_func_mask_data.started));
1068
1069 if (wait) {
1070 do {
1071 mn10300_local_dcache_inv_range(start, end);
1072 barrier();
1073 } while (!cpus_empty(nmi_call_func_mask_data.finished));
1074 }
1075
1076 spin_unlock(&smp_nmi_call_lock);
1077 return 0;
1078}
1079
1080static void restart_wakeup_cpu(void)
1081{
1082 unsigned int cpu = smp_processor_id();
1083
1084 cpu_set(cpu, cpu_callin_map);
1085 local_flush_tlb();
1086 cpu_set(cpu, cpu_online_map);
1087 smp_wmb();
1088}
1089
1090static void prepare_sleep_cpu(void *unused)
1091{
1092 sleep_mode[smp_processor_id()] = 1;
1093 smp_mb();
1094 mn10300_local_dcache_flush_inv();
1095 hotplug_cpu_disable_cache();
1096 hotplug_cpu_invalidate_cache();
1097}
1098
1099/* when this function called, IE=0, NMID=0. */
1100static void sleep_cpu(void *unused)
1101{
1102 unsigned int cpu_id = smp_processor_id();
1103 /*
1104 * CALL_FUNCTION_NMI_IPI for wakeup_cpu() shall not be requested,
1105 * before this cpu goes in SLEEP mode.
1106 */
1107 do {
1108 smp_mb();
1109 __sleep_cpu();
1110 } while (sleep_mode[cpu_id]);
1111 restart_wakeup_cpu();
1112}
1113
1114static void run_sleep_cpu(unsigned int cpu)
1115{
1116 unsigned long flags;
1117 cpumask_t cpumask = cpumask_of(cpu);
1118
1119 flags = arch_local_cli_save();
1120 hotplug_cpu_nmi_call_function(cpumask, prepare_sleep_cpu, NULL, 1);
1121 hotplug_cpu_nmi_call_function(cpumask, sleep_cpu, NULL, 0);
1122 udelay(1); /* delay for the cpu to sleep. */
1123 arch_local_irq_restore(flags);
1124}
1125
1126static void wakeup_cpu(void)
1127{
1128 hotplug_cpu_invalidate_cache();
1129 hotplug_cpu_enable_cache();
1130 smp_mb();
1131 sleep_mode[smp_processor_id()] = 0;
1132}
1133
1134static void run_wakeup_cpu(unsigned int cpu)
1135{
1136 unsigned long flags;
1137
1138 flags = arch_local_cli_save();
1139#if NR_CPUS == 2
1140 mn10300_local_dcache_flush_inv();
1141#else
1142 /*
1143 * Before waking up the cpu,
1144 * all online cpus should stop and flush D-Cache for global data.
1145 */
1146#error not support NR_CPUS > 2, when CONFIG_HOTPLUG_CPU=y.
1147#endif
1148 hotplug_cpu_nmi_call_function(cpumask_of(cpu), wakeup_cpu, NULL, 1);
1149 arch_local_irq_restore(flags);
1150}
1151
1152#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/mn10300/kernel/switch_to.S b/arch/mn10300/kernel/switch_to.S
index 630aad71b946..9074d0fb8788 100644
--- a/arch/mn10300/kernel/switch_to.S
+++ b/arch/mn10300/kernel/switch_to.S
@@ -15,6 +15,9 @@
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <asm/thread_info.h> 16#include <asm/thread_info.h>
17#include <asm/cpu-regs.h> 17#include <asm/cpu-regs.h>
18#ifdef CONFIG_SMP
19#include <proc/smp-regs.h>
20#endif /* CONFIG_SMP */
18 21
19 .text 22 .text
20 23
@@ -35,8 +38,6 @@ ENTRY(__switch_to)
35 mov d1,a1 38 mov d1,a1
36 39
37 # save prev context 40 # save prev context
38 mov (__frame),d0
39 mov d0,(THREAD_FRAME,a0)
40 mov __switch_back,d0 41 mov __switch_back,d0
41 mov d0,(THREAD_PC,a0) 42 mov d0,(THREAD_PC,a0)
42 mov sp,a2 43 mov sp,a2
@@ -58,8 +59,6 @@ ENTRY(__switch_to)
58 mov a2,e2 59 mov a2,e2
59#endif 60#endif
60 61
61 mov (THREAD_FRAME,a1),a2
62 mov a2,(__frame)
63 mov (THREAD_PC,a1),a2 62 mov (THREAD_PC,a1),a2
64 mov d2,d0 # for ret_from_fork 63 mov d2,d0 # for ret_from_fork
65 mov d0,a0 # for __switch_to 64 mov d0,a0 # for __switch_to
diff --git a/arch/mn10300/kernel/time.c b/arch/mn10300/kernel/time.c
index 8f7f6d22783d..f860a340acc9 100644
--- a/arch/mn10300/kernel/time.c
+++ b/arch/mn10300/kernel/time.c
@@ -17,29 +17,18 @@
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/profile.h> 18#include <linux/profile.h>
19#include <linux/cnt32_to_63.h> 19#include <linux/cnt32_to_63.h>
20#include <linux/clocksource.h>
21#include <linux/clockchips.h>
20#include <asm/irq.h> 22#include <asm/irq.h>
21#include <asm/div64.h> 23#include <asm/div64.h>
22#include <asm/processor.h> 24#include <asm/processor.h>
23#include <asm/intctl-regs.h> 25#include <asm/intctl-regs.h>
24#include <asm/rtc.h> 26#include <asm/rtc.h>
25 27#include "internal.h"
26#ifdef CONFIG_MN10300_RTC
27unsigned long mn10300_ioclk; /* system I/O clock frequency */
28unsigned long mn10300_iobclk; /* system I/O clock frequency */
29unsigned long mn10300_tsc_per_HZ; /* number of ioclks per jiffy */
30#endif /* CONFIG_MN10300_RTC */
31 28
32static unsigned long mn10300_last_tsc; /* time-stamp counter at last time 29static unsigned long mn10300_last_tsc; /* time-stamp counter at last time
33 * interrupt occurred */ 30 * interrupt occurred */
34 31
35static irqreturn_t timer_interrupt(int irq, void *dev_id);
36
37static struct irqaction timer_irq = {
38 .handler = timer_interrupt,
39 .flags = IRQF_DISABLED | IRQF_SHARED | IRQF_TIMER,
40 .name = "timer",
41};
42
43static unsigned long sched_clock_multiplier; 32static unsigned long sched_clock_multiplier;
44 33
45/* 34/*
@@ -54,9 +43,12 @@ unsigned long long sched_clock(void)
54 unsigned long tsc, tmp; 43 unsigned long tsc, tmp;
55 unsigned product[3]; /* 96-bit intermediate value */ 44 unsigned product[3]; /* 96-bit intermediate value */
56 45
46 /* cnt32_to_63() is not safe with preemption */
47 preempt_disable();
48
57 /* read the TSC value 49 /* read the TSC value
58 */ 50 */
59 tsc = 0 - get_cycles(); /* get_cycles() counts down */ 51 tsc = get_cycles();
60 52
61 /* expand to 64-bits. 53 /* expand to 64-bits.
62 * - sched_clock() must be called once a minute or better or the 54 * - sched_clock() must be called once a minute or better or the
@@ -64,6 +56,8 @@ unsigned long long sched_clock(void)
64 */ 56 */
65 tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL; 57 tsc64.ll = cnt32_to_63(tsc) & 0x7fffffffffffffffULL;
66 58
59 preempt_enable();
60
67 /* scale the 64-bit TSC value to a nanosecond value via a 96-bit 61 /* scale the 64-bit TSC value to a nanosecond value via a 96-bit
68 * intermediate 62 * intermediate
69 */ 63 */
@@ -90,6 +84,20 @@ static void __init mn10300_sched_clock_init(void)
90 __muldiv64u(NSEC_PER_SEC, 1 << 16, MN10300_TSCCLK); 84 __muldiv64u(NSEC_PER_SEC, 1 << 16, MN10300_TSCCLK);
91} 85}
92 86
87/**
88 * local_timer_interrupt - Local timer interrupt handler
89 *
90 * Handle local timer interrupts for this CPU. They may have been propagated
91 * to this CPU from the CPU that actually gets them by way of an IPI.
92 */
93irqreturn_t local_timer_interrupt(void)
94{
95 profile_tick(CPU_PROFILING);
96 update_process_times(user_mode(get_irq_regs()));
97 return IRQ_HANDLED;
98}
99
100#ifndef CONFIG_GENERIC_TIME
93/* 101/*
94 * advance the kernel's time keeping clocks (xtime and jiffies) 102 * advance the kernel's time keeping clocks (xtime and jiffies)
95 * - we use Timer 0 & 1 cascaded as a clock to nudge us the next time 103 * - we use Timer 0 & 1 cascaded as a clock to nudge us the next time
@@ -98,27 +106,73 @@ static void __init mn10300_sched_clock_init(void)
98static irqreturn_t timer_interrupt(int irq, void *dev_id) 106static irqreturn_t timer_interrupt(int irq, void *dev_id)
99{ 107{
100 unsigned tsc, elapse; 108 unsigned tsc, elapse;
109 irqreturn_t ret;
101 110
102 write_seqlock(&xtime_lock); 111 write_seqlock(&xtime_lock);
103 112
104 while (tsc = get_cycles(), 113 while (tsc = get_cycles(),
105 elapse = mn10300_last_tsc - tsc, /* time elapsed since last 114 elapse = tsc - mn10300_last_tsc, /* time elapsed since last
106 * tick */ 115 * tick */
107 elapse > MN10300_TSC_PER_HZ 116 elapse > MN10300_TSC_PER_HZ
108 ) { 117 ) {
109 mn10300_last_tsc -= MN10300_TSC_PER_HZ; 118 mn10300_last_tsc += MN10300_TSC_PER_HZ;
110 119
111 /* advance the kernel's time tracking system */ 120 /* advance the kernel's time tracking system */
112 profile_tick(CPU_PROFILING);
113 do_timer(1); 121 do_timer(1);
114 } 122 }
115 123
116 write_sequnlock(&xtime_lock); 124 write_sequnlock(&xtime_lock);
117 125
118 update_process_times(user_mode(get_irq_regs())); 126 ret = local_timer_interrupt();
127#ifdef CONFIG_SMP
128 send_IPI_allbutself(LOCAL_TIMER_IPI);
129#endif
130 return ret;
131}
119 132
120 return IRQ_HANDLED; 133static struct irqaction timer_irq = {
134 .handler = timer_interrupt,
135 .flags = IRQF_DISABLED | IRQF_SHARED | IRQF_TIMER,
136 .name = "timer",
137};
138#endif /* CONFIG_GENERIC_TIME */
139
140#ifdef CONFIG_CSRC_MN10300
141void __init clocksource_set_clock(struct clocksource *cs, unsigned int clock)
142{
143 u64 temp;
144 u32 shift;
145
146 /* Find a shift value */
147 for (shift = 32; shift > 0; shift--) {
148 temp = (u64) NSEC_PER_SEC << shift;
149 do_div(temp, clock);
150 if ((temp >> 32) == 0)
151 break;
152 }
153 cs->shift = shift;
154 cs->mult = (u32) temp;
121} 155}
156#endif
157
158#if CONFIG_CEVT_MN10300
159void __cpuinit clockevent_set_clock(struct clock_event_device *cd,
160 unsigned int clock)
161{
162 u64 temp;
163 u32 shift;
164
165 /* Find a shift value */
166 for (shift = 32; shift > 0; shift--) {
167 temp = (u64) clock << shift;
168 do_div(temp, NSEC_PER_SEC);
169 if ((temp >> 32) == 0)
170 break;
171 }
172 cd->shift = shift;
173 cd->mult = (u32) temp;
174}
175#endif
122 176
123/* 177/*
124 * initialise the various timers used by the main part of the kernel 178 * initialise the various timers used by the main part of the kernel
@@ -131,21 +185,25 @@ void __init time_init(void)
131 */ 185 */
132 TMPSCNT |= TMPSCNT_ENABLE; 186 TMPSCNT |= TMPSCNT_ENABLE;
133 187
188#ifdef CONFIG_GENERIC_TIME
189 init_clocksource();
190#else
134 startup_timestamp_counter(); 191 startup_timestamp_counter();
192#endif
135 193
136 printk(KERN_INFO 194 printk(KERN_INFO
137 "timestamp counter I/O clock running at %lu.%02lu" 195 "timestamp counter I/O clock running at %lu.%02lu"
138 " (calibrated against RTC)\n", 196 " (calibrated against RTC)\n",
139 MN10300_TSCCLK / 1000000, (MN10300_TSCCLK / 10000) % 100); 197 MN10300_TSCCLK / 1000000, (MN10300_TSCCLK / 10000) % 100);
140 198
141 mn10300_last_tsc = TMTSCBC; 199 mn10300_last_tsc = read_timestamp_counter();
142
143 /* use timer 0 & 1 cascaded to tick at as close to HZ as possible */
144 setup_irq(TMJCIRQ, &timer_irq);
145 200
146 set_intr_level(TMJCIRQ, TMJCICR_LEVEL); 201#ifdef CONFIG_GENERIC_CLOCKEVENTS
147 202 init_clockevents();
148 startup_jiffies_counter(); 203#else
204 reload_jiffies_counter(MN10300_JC_PER_HZ - 1);
205 setup_jiffies_interrupt(TMJCIRQ, &timer_irq, CONFIG_TIMER_IRQ_LEVEL);
206#endif
149 207
150#ifdef CONFIG_MN10300_WD_TIMER 208#ifdef CONFIG_MN10300_WD_TIMER
151 /* start the watchdog timer */ 209 /* start the watchdog timer */
diff --git a/arch/mn10300/kernel/traps.c b/arch/mn10300/kernel/traps.c
index 91365adba4f5..b90c3f160c77 100644
--- a/arch/mn10300/kernel/traps.c
+++ b/arch/mn10300/kernel/traps.c
@@ -45,9 +45,6 @@
45#error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!" 45#error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!"
46#endif 46#endif
47 47
48struct pt_regs *__frame; /* current frame pointer */
49EXPORT_SYMBOL(__frame);
50
51int kstack_depth_to_print = 24; 48int kstack_depth_to_print = 24;
52 49
53spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock); 50spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock);
@@ -101,7 +98,6 @@ DO_EINFO(SIGILL, {}, "invalid opcode", invalid_op, ILL_ILLOPC);
101DO_EINFO(SIGILL, {}, "invalid ex opcode", invalid_exop, ILL_ILLOPC); 98DO_EINFO(SIGILL, {}, "invalid ex opcode", invalid_exop, ILL_ILLOPC);
102DO_EINFO(SIGBUS, {}, "invalid address", mem_error, BUS_ADRERR); 99DO_EINFO(SIGBUS, {}, "invalid address", mem_error, BUS_ADRERR);
103DO_EINFO(SIGBUS, {}, "bus error", bus_error, BUS_ADRERR); 100DO_EINFO(SIGBUS, {}, "bus error", bus_error, BUS_ADRERR);
104DO_EINFO(SIGILL, {}, "FPU invalid opcode", fpu_invalid_op, ILL_COPROC);
105 101
106DO_ERROR(SIGTRAP, 102DO_ERROR(SIGTRAP,
107#ifndef CONFIG_MN10300_USING_JTAG 103#ifndef CONFIG_MN10300_USING_JTAG
@@ -222,11 +218,14 @@ void show_registers_only(struct pt_regs *regs)
222 printk(KERN_EMERG "threadinfo=%p task=%p)\n", 218 printk(KERN_EMERG "threadinfo=%p task=%p)\n",
223 current_thread_info(), current); 219 current_thread_info(), current);
224 220
225 if ((unsigned long) current >= 0x90000000UL && 221 if ((unsigned long) current >= PAGE_OFFSET &&
226 (unsigned long) current < 0x94000000UL) 222 (unsigned long) current < (unsigned long)high_memory)
227 printk(KERN_EMERG "Process %s (pid: %d)\n", 223 printk(KERN_EMERG "Process %s (pid: %d)\n",
228 current->comm, current->pid); 224 current->comm, current->pid);
229 225
226#ifdef CONFIG_SMP
227 printk(KERN_EMERG "CPUID: %08x\n", CPUID);
228#endif
230 printk(KERN_EMERG "CPUP: %04hx\n", CPUP); 229 printk(KERN_EMERG "CPUP: %04hx\n", CPUP);
231 printk(KERN_EMERG "TBR: %08x\n", TBR); 230 printk(KERN_EMERG "TBR: %08x\n", TBR);
232 printk(KERN_EMERG "DEAR: %08x\n", DEAR); 231 printk(KERN_EMERG "DEAR: %08x\n", DEAR);
@@ -522,8 +521,12 @@ void __init set_intr_stub(enum exception_code code, void *handler)
522{ 521{
523 unsigned long addr; 522 unsigned long addr;
524 u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); 523 u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code);
524 unsigned long flags;
525 525
526 addr = (unsigned long) handler - (unsigned long) vector; 526 addr = (unsigned long) handler - (unsigned long) vector;
527
528 flags = arch_local_cli_save();
529
527 vector[0] = 0xdc; /* JMP handler */ 530 vector[0] = 0xdc; /* JMP handler */
528 vector[1] = addr; 531 vector[1] = addr;
529 vector[2] = addr >> 8; 532 vector[2] = addr >> 8;
@@ -533,30 +536,12 @@ void __init set_intr_stub(enum exception_code code, void *handler)
533 vector[6] = 0xcb; 536 vector[6] = 0xcb;
534 vector[7] = 0xcb; 537 vector[7] = 0xcb;
535 538
536 mn10300_dcache_flush_inv(); 539 arch_local_irq_restore(flags);
537 mn10300_icache_inv();
538}
539
540/*
541 * set an interrupt stub to invoke the JTAG unit and then jump to a handler
542 */
543void __init set_jtag_stub(enum exception_code code, void *handler)
544{
545 unsigned long addr;
546 u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code);
547
548 addr = (unsigned long) handler - ((unsigned long) vector + 1);
549 vector[0] = 0xff; /* PI to jump into JTAG debugger */
550 vector[1] = 0xdc; /* jmp handler */
551 vector[2] = addr;
552 vector[3] = addr >> 8;
553 vector[4] = addr >> 16;
554 vector[5] = addr >> 24;
555 vector[6] = 0xcb;
556 vector[7] = 0xcb;
557 540
541#ifndef CONFIG_MN10300_CACHE_SNOOP
558 mn10300_dcache_flush_inv(); 542 mn10300_dcache_flush_inv();
559 flush_icache_range((unsigned long) vector, (unsigned long) vector + 8); 543 mn10300_icache_inv();
544#endif
560} 545}
561 546
562/* 547/*
@@ -581,7 +566,6 @@ void __init trap_init(void)
581 set_excp_vector(EXCEP_PRIVINSACC, insn_acc_error); 566 set_excp_vector(EXCEP_PRIVINSACC, insn_acc_error);
582 set_excp_vector(EXCEP_PRIVDATACC, data_acc_error); 567 set_excp_vector(EXCEP_PRIVDATACC, data_acc_error);
583 set_excp_vector(EXCEP_DATINSACC, insn_acc_error); 568 set_excp_vector(EXCEP_DATINSACC, insn_acc_error);
584 set_excp_vector(EXCEP_FPU_DISABLED, fpu_disabled);
585 set_excp_vector(EXCEP_FPU_UNIMPINS, fpu_invalid_op); 569 set_excp_vector(EXCEP_FPU_UNIMPINS, fpu_invalid_op);
586 set_excp_vector(EXCEP_FPU_OPERATION, fpu_exception); 570 set_excp_vector(EXCEP_FPU_OPERATION, fpu_exception);
587 571
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 10549dcfb610..febbeee7f2f5 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -70,7 +70,7 @@ SECTIONS
70 .exit.text : { EXIT_TEXT; } 70 .exit.text : { EXIT_TEXT; }
71 .exit.data : { EXIT_DATA; } 71 .exit.data : { EXIT_DATA; }
72 72
73 PERCPU(32) 73 PERCPU(PAGE_SIZE)
74 . = ALIGN(PAGE_SIZE); 74 . = ALIGN(PAGE_SIZE);
75 __init_end = .; 75 __init_end = .;
76 /* freed after init ends here */ 76 /* freed after init ends here */
diff --git a/arch/mn10300/lib/bitops.c b/arch/mn10300/lib/bitops.c
index 440a7dcbf87b..a66c6cdaf442 100644
--- a/arch/mn10300/lib/bitops.c
+++ b/arch/mn10300/lib/bitops.c
@@ -15,7 +15,7 @@
15/* 15/*
16 * try flipping a bit using BSET and BCLR 16 * try flipping a bit using BSET and BCLR
17 */ 17 */
18void change_bit(int nr, volatile void *addr) 18void change_bit(unsigned long nr, volatile void *addr)
19{ 19{
20 if (test_bit(nr, addr)) 20 if (test_bit(nr, addr))
21 goto try_clear_bit; 21 goto try_clear_bit;
@@ -34,7 +34,7 @@ try_clear_bit:
34/* 34/*
35 * try flipping a bit using BSET and BCLR and returning the old value 35 * try flipping a bit using BSET and BCLR and returning the old value
36 */ 36 */
37int test_and_change_bit(int nr, volatile void *addr) 37int test_and_change_bit(unsigned long nr, volatile void *addr)
38{ 38{
39 if (test_bit(nr, addr)) 39 if (test_bit(nr, addr))
40 goto try_clear_bit; 40 goto try_clear_bit;
diff --git a/arch/mn10300/lib/delay.c b/arch/mn10300/lib/delay.c
index fdf6f710f94e..8e7ceb8ba33d 100644
--- a/arch/mn10300/lib/delay.c
+++ b/arch/mn10300/lib/delay.c
@@ -38,14 +38,14 @@ EXPORT_SYMBOL(__delay);
38 */ 38 */
39void __udelay(unsigned long usecs) 39void __udelay(unsigned long usecs)
40{ 40{
41 signed long ioclk, stop; 41 unsigned long start, stop, cnt;
42 42
43 /* usecs * CLK / 1E6 */ 43 /* usecs * CLK / 1E6 */
44 stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000); 44 stop = __muldiv64u(usecs, MN10300_TSCCLK, 1000000);
45 stop = TMTSCBC - stop; 45 start = TMTSCBC;
46 46
47 do { 47 do {
48 ioclk = TMTSCBC; 48 cnt = start - TMTSCBC;
49 } while (stop < ioclk); 49 } while (cnt < stop);
50} 50}
51EXPORT_SYMBOL(__udelay); 51EXPORT_SYMBOL(__udelay);
diff --git a/arch/mn10300/lib/do_csum.S b/arch/mn10300/lib/do_csum.S
index e138994e1667..1d27bba0cd8f 100644
--- a/arch/mn10300/lib/do_csum.S
+++ b/arch/mn10300/lib/do_csum.S
@@ -10,26 +10,25 @@
10 */ 10 */
11#include <asm/cache.h> 11#include <asm/cache.h>
12 12
13 .section .text 13 .section .text
14 .balign L1_CACHE_BYTES 14 .balign L1_CACHE_BYTES
15 15
16############################################################################### 16###############################################################################
17# 17#
18# unsigned int do_csum(const unsigned char *buff, size_t len) 18# unsigned int do_csum(const unsigned char *buff, int len)
19# 19#
20############################################################################### 20###############################################################################
21 .globl do_csum 21 .globl do_csum
22 .type do_csum,@function 22 .type do_csum,@function
23do_csum: 23do_csum:
24 movm [d2,d3],(sp) 24 movm [d2,d3],(sp)
25 mov d0,(12,sp)
26 mov d1,(16,sp)
27 mov d1,d2 # count 25 mov d1,d2 # count
28 mov d0,a0 # buff 26 mov d0,a0 # buff
27 mov a0,a1
29 clr d1 # accumulator 28 clr d1 # accumulator
30 29
31 cmp +0,d2 30 cmp +0,d2
32 beq do_csum_done # return if zero-length buffer 31 ble do_csum_done # check for zero length or negative
33 32
34 # 4-byte align the buffer pointer 33 # 4-byte align the buffer pointer
35 btst +3,a0 34 btst +3,a0
@@ -41,17 +40,15 @@ do_csum:
41 inc a0 40 inc a0
42 asl +8,d0 41 asl +8,d0
43 add d0,d1 42 add d0,d1
44 addc +0,d1
45 add -1,d2 43 add -1,d2
46do_csum_addr_not_odd:
47 44
45do_csum_addr_not_odd:
48 cmp +2,d2 46 cmp +2,d2
49 bcs do_csum_fewer_than_4 47 bcs do_csum_fewer_than_4
50 btst +2,a0 48 btst +2,a0
51 beq do_csum_now_4b_aligned 49 beq do_csum_now_4b_aligned
52 movhu (a0+),d0 50 movhu (a0+),d0
53 add d0,d1 51 add d0,d1
54 addc +0,d1
55 add -2,d2 52 add -2,d2
56 cmp +4,d2 53 cmp +4,d2
57 bcs do_csum_fewer_than_4 54 bcs do_csum_fewer_than_4
@@ -66,20 +63,20 @@ do_csum_now_4b_aligned:
66 63
67do_csum_loop: 64do_csum_loop:
68 mov (a0+),d0 65 mov (a0+),d0
69 add d0,d1
70 mov (a0+),e0 66 mov (a0+),e0
71 addc e0,d1
72 mov (a0+),e1 67 mov (a0+),e1
73 addc e1,d1
74 mov (a0+),e3 68 mov (a0+),e3
69 add d0,d1
70 addc e0,d1
71 addc e1,d1
75 addc e3,d1 72 addc e3,d1
76 mov (a0+),d0 73 mov (a0+),d0
77 addc d0,d1
78 mov (a0+),e0 74 mov (a0+),e0
79 addc e0,d1
80 mov (a0+),e1 75 mov (a0+),e1
81 addc e1,d1
82 mov (a0+),e3 76 mov (a0+),e3
77 addc d0,d1
78 addc e0,d1
79 addc e1,d1
83 addc e3,d1 80 addc e3,d1
84 addc +0,d1 81 addc +0,d1
85 82
@@ -94,12 +91,12 @@ do_csum_remainder:
94 cmp +16,d2 91 cmp +16,d2
95 bcs do_csum_fewer_than_16 92 bcs do_csum_fewer_than_16
96 mov (a0+),d0 93 mov (a0+),d0
97 add d0,d1
98 mov (a0+),e0 94 mov (a0+),e0
99 addc e0,d1
100 mov (a0+),e1 95 mov (a0+),e1
101 addc e1,d1
102 mov (a0+),e3 96 mov (a0+),e3
97 add d0,d1
98 addc e0,d1
99 addc e1,d1
103 addc e3,d1 100 addc e3,d1
104 addc +0,d1 101 addc +0,d1
105 add -16,d2 102 add -16,d2
@@ -131,9 +128,9 @@ do_csum_fewer_than_4:
131 xor_cmp d0,d0,+2,d2 128 xor_cmp d0,d0,+2,d2
132 bcs do_csum_fewer_than_2 129 bcs do_csum_fewer_than_2
133 movhu (a0+),d0 130 movhu (a0+),d0
134do_csum_fewer_than_2:
135 and +1,d2 131 and +1,d2
136 beq do_csum_add_last_bit 132 beq do_csum_add_last_bit
133do_csum_fewer_than_2:
137 movbu (a0),d3 134 movbu (a0),d3
138 add d3,d0 135 add d3,d0
139do_csum_add_last_bit: 136do_csum_add_last_bit:
@@ -142,21 +139,19 @@ do_csum_add_last_bit:
142 139
143do_csum_done: 140do_csum_done:
144 # compress the checksum down to 16 bits 141 # compress the checksum down to 16 bits
145 mov +0xffff0000,d2 142 mov +0xffff0000,d0
146 and d1,d2 143 and d1,d0
147 asl +16,d1 144 asl +16,d1
148 add d2,d1,d0 145 add d1,d0
149 addc +0xffff,d0 146 addc +0xffff,d0
150 lsr +16,d0 147 lsr +16,d0
151 148
152 # flip the halves of the word result if the buffer was oddly aligned 149 # flip the halves of the word result if the buffer was oddly aligned
153 mov (12,sp),d1 150 and +1,a1
154 and +1,d1
155 beq do_csum_not_oddly_aligned 151 beq do_csum_not_oddly_aligned
156 swaph d0,d0 # exchange bits 15:8 with 7:0 152 swaph d0,d0 # exchange bits 15:8 with 7:0
157 153
158do_csum_not_oddly_aligned: 154do_csum_not_oddly_aligned:
159 ret [d2,d3],8 155 ret [d2,d3],8
160 156
161do_csum_end: 157 .size do_csum, .-do_csum
162 .size do_csum, do_csum_end-do_csum
diff --git a/arch/mn10300/mm/Kconfig.cache b/arch/mn10300/mm/Kconfig.cache
new file mode 100644
index 000000000000..c4fd923a55a0
--- /dev/null
+++ b/arch/mn10300/mm/Kconfig.cache
@@ -0,0 +1,101 @@
1#
2# MN10300 CPU cache options
3#
4
5choice
6 prompt "CPU Caching mode"
7 default MN10300_CACHE_WBACK
8 help
9 This option determines the caching mode for the kernel.
10
11 Write-Back caching mode involves the all reads and writes causing
12 the affected cacheline to be read into the cache first before being
13 operated upon. Memory is not then updated by a write until the cache
14 is filled and a cacheline needs to be displaced from the cache to
15 make room. Only at that point is it written back.
16
17 Write-Through caching only fetches cachelines from memory on a
18 read. Writes always get written directly to memory. If the affected
19 cacheline is also in cache, it will be updated too.
20
21 The final option is to turn of caching entirely.
22
23config MN10300_CACHE_WBACK
24 bool "Write-Back"
25 help
26 The dcache operates in delayed write-back mode. It must be manually
27 flushed if writes are made that subsequently need to be executed or
28 to be DMA'd by a device.
29
30config MN10300_CACHE_WTHRU
31 bool "Write-Through"
32 help
33 The dcache operates in immediate write-through mode. Writes are
34 committed to RAM immediately in addition to being stored in the
35 cache. This means that the written data is immediately available for
36 execution or DMA.
37
38 This is not available for use with an SMP kernel if cache flushing
39 and invalidation by automatic purge register is not selected.
40
41config MN10300_CACHE_DISABLED
42 bool "Disabled"
43 help
44 The icache and dcache are disabled.
45
46endchoice
47
48config MN10300_CACHE_ENABLED
49 def_bool y if !MN10300_CACHE_DISABLED
50
51
52choice
53 prompt "CPU cache flush/invalidate method"
54 default MN10300_CACHE_MANAGE_BY_TAG if !AM34_2
55 default MN10300_CACHE_MANAGE_BY_REG if AM34_2
56 depends on MN10300_CACHE_ENABLED
57 help
58 This determines the method by which CPU cache flushing and
59 invalidation is performed.
60
61config MN10300_CACHE_MANAGE_BY_TAG
62 bool "Use the cache tag registers directly"
63 depends on !(SMP && MN10300_CACHE_WTHRU)
64
65config MN10300_CACHE_MANAGE_BY_REG
66 bool "Flush areas by way of automatic purge registers (AM34 only)"
67 depends on AM34_2
68
69endchoice
70
71config MN10300_CACHE_INV_BY_TAG
72 def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_ENABLED
73
74config MN10300_CACHE_INV_BY_REG
75 def_bool y if MN10300_CACHE_MANAGE_BY_REG && MN10300_CACHE_ENABLED
76
77config MN10300_CACHE_FLUSH_BY_TAG
78 def_bool y if MN10300_CACHE_MANAGE_BY_TAG && MN10300_CACHE_WBACK
79
80config MN10300_CACHE_FLUSH_BY_REG
81 def_bool y if MN10300_CACHE_MANAGE_BY_REG && MN10300_CACHE_WBACK
82
83
84config MN10300_HAS_CACHE_SNOOP
85 def_bool n
86
87config MN10300_CACHE_SNOOP
88 bool "Use CPU Cache Snooping"
89 depends on MN10300_CACHE_ENABLED && MN10300_HAS_CACHE_SNOOP
90 default y
91
92config MN10300_CACHE_FLUSH_ICACHE
93 def_bool y if MN10300_CACHE_WBACK && !MN10300_CACHE_SNOOP
94 help
95 Set if we need the dcache flushing before the icache is invalidated.
96
97config MN10300_CACHE_INV_ICACHE
98 def_bool y if MN10300_CACHE_WTHRU && !MN10300_CACHE_SNOOP
99 help
100 Set if we need the icache to be invalidated, even if the dcache is in
101 write-through mode and doesn't need flushing.
diff --git a/arch/mn10300/mm/Makefile b/arch/mn10300/mm/Makefile
index 1557277fbc5c..203fee23f7d7 100644
--- a/arch/mn10300/mm/Makefile
+++ b/arch/mn10300/mm/Makefile
@@ -2,11 +2,21 @@
2# Makefile for the MN10300-specific memory management code 2# Makefile for the MN10300-specific memory management code
3# 3#
4 4
5cacheflush-y := cache.o cache-mn10300.o 5cache-smp-wback-$(CONFIG_MN10300_CACHE_WBACK) := cache-smp-flush.o
6cacheflush-$(CONFIG_MN10300_CACHE_WBACK) += cache-flush-mn10300.o 6
7cacheflush-y := cache.o
8cacheflush-$(CONFIG_SMP) += cache-smp.o cache-smp-inv.o $(cache-smp-wback-y)
9cacheflush-$(CONFIG_MN10300_CACHE_INV_ICACHE) += cache-inv-icache.o
10cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_ICACHE) += cache-flush-icache.o
11cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_TAG) += cache-inv-by-tag.o
12cacheflush-$(CONFIG_MN10300_CACHE_INV_BY_REG) += cache-inv-by-reg.o
13cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_TAG) += cache-flush-by-tag.o
14cacheflush-$(CONFIG_MN10300_CACHE_FLUSH_BY_REG) += cache-flush-by-reg.o
7 15
8cacheflush-$(CONFIG_MN10300_CACHE_DISABLED) := cache-disabled.o 16cacheflush-$(CONFIG_MN10300_CACHE_DISABLED) := cache-disabled.o
9 17
10obj-y := \ 18obj-y := \
11 init.o fault.o pgtable.o extable.o tlb-mn10300.o mmu-context.o \ 19 init.o fault.o pgtable.o extable.o tlb-mn10300.o mmu-context.o \
12 misalignment.o dma-alloc.o $(cacheflush-y) 20 misalignment.o dma-alloc.o $(cacheflush-y)
21
22obj-$(CONFIG_SMP) += tlb-smp.o
diff --git a/arch/mn10300/mm/cache-flush-by-reg.S b/arch/mn10300/mm/cache-flush-by-reg.S
new file mode 100644
index 000000000000..1dcae0211671
--- /dev/null
+++ b/arch/mn10300/mm/cache-flush-by-reg.S
@@ -0,0 +1,308 @@
1/* MN10300 CPU core caching routines, using indirect regs on cache controller
2 *
3 * Copyright (C) 2007 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/sys.h>
13#include <linux/linkage.h>
14#include <asm/smp.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17#include <asm/irqflags.h>
18
19 .am33_2
20
21#ifndef CONFIG_SMP
22 .globl mn10300_dcache_flush
23 .globl mn10300_dcache_flush_page
24 .globl mn10300_dcache_flush_range
25 .globl mn10300_dcache_flush_range2
26 .globl mn10300_dcache_flush_inv
27 .globl mn10300_dcache_flush_inv_page
28 .globl mn10300_dcache_flush_inv_range
29 .globl mn10300_dcache_flush_inv_range2
30
31mn10300_dcache_flush = mn10300_local_dcache_flush
32mn10300_dcache_flush_page = mn10300_local_dcache_flush_page
33mn10300_dcache_flush_range = mn10300_local_dcache_flush_range
34mn10300_dcache_flush_range2 = mn10300_local_dcache_flush_range2
35mn10300_dcache_flush_inv = mn10300_local_dcache_flush_inv
36mn10300_dcache_flush_inv_page = mn10300_local_dcache_flush_inv_page
37mn10300_dcache_flush_inv_range = mn10300_local_dcache_flush_inv_range
38mn10300_dcache_flush_inv_range2 = mn10300_local_dcache_flush_inv_range2
39
40#endif /* !CONFIG_SMP */
41
42###############################################################################
43#
44# void mn10300_local_dcache_flush(void)
45# Flush the entire data cache back to RAM
46#
47###############################################################################
48 ALIGN
49 .globl mn10300_local_dcache_flush
50 .type mn10300_local_dcache_flush,@function
51mn10300_local_dcache_flush:
52 movhu (CHCTR),d0
53 btst CHCTR_DCEN,d0
54 beq mn10300_local_dcache_flush_end
55
56 mov DCPGCR,a0
57
58 LOCAL_CLI_SAVE(d1)
59
60 # wait for busy bit of area purge
61 setlb
62 mov (a0),d0
63 btst DCPGCR_DCPGBSY,d0
64 lne
65
66 # set mask
67 clr d0
68 mov d0,(DCPGMR)
69
70 # area purge
71 #
72 # DCPGCR = DCPGCR_DCP
73 #
74 mov DCPGCR_DCP,d0
75 mov d0,(a0)
76
77 # wait for busy bit of area purge
78 setlb
79 mov (a0),d0
80 btst DCPGCR_DCPGBSY,d0
81 lne
82
83 LOCAL_IRQ_RESTORE(d1)
84
85mn10300_local_dcache_flush_end:
86 ret [],0
87 .size mn10300_local_dcache_flush,.-mn10300_local_dcache_flush
88
89###############################################################################
90#
91# void mn10300_local_dcache_flush_page(unsigned long start)
92# void mn10300_local_dcache_flush_range(unsigned long start, unsigned long end)
93# void mn10300_local_dcache_flush_range2(unsigned long start, unsigned long size)
94# Flush a range of addresses on a page in the dcache
95#
96###############################################################################
97 ALIGN
98 .globl mn10300_local_dcache_flush_page
99 .globl mn10300_local_dcache_flush_range
100 .globl mn10300_local_dcache_flush_range2
101 .type mn10300_local_dcache_flush_page,@function
102 .type mn10300_local_dcache_flush_range,@function
103 .type mn10300_local_dcache_flush_range2,@function
104mn10300_local_dcache_flush_page:
105 and ~(PAGE_SIZE-1),d0
106 mov PAGE_SIZE,d1
107mn10300_local_dcache_flush_range2:
108 add d0,d1
109mn10300_local_dcache_flush_range:
110 movm [d2,d3,a2],(sp)
111
112 movhu (CHCTR),d2
113 btst CHCTR_DCEN,d2
114 beq mn10300_local_dcache_flush_range_end
115
116 # calculate alignsize
117 #
118 # alignsize = L1_CACHE_BYTES;
119 # for (i = (end - start - 1) / L1_CACHE_BYTES ; i > 0; i >>= 1)
120 # alignsize <<= 1;
121 # d2 = alignsize;
122 #
123 mov L1_CACHE_BYTES,d2
124 sub d0,d1,d3
125 add -1,d3
126 lsr L1_CACHE_SHIFT,d3
127 beq 2f
1281:
129 add d2,d2
130 lsr 1,d3
131 bne 1b
1322:
133 mov d1,a1 # a1 = end
134
135 LOCAL_CLI_SAVE(d3)
136 mov DCPGCR,a0
137
138 # wait for busy bit of area purge
139 setlb
140 mov (a0),d1
141 btst DCPGCR_DCPGBSY,d1
142 lne
143
144 # determine the mask
145 mov d2,d1
146 add -1,d1
147 not d1 # d1 = mask = ~(alignsize-1)
148 mov d1,(DCPGMR)
149
150 and d1,d0,a2 # a2 = mask & start
151
152dcpgloop:
153 # area purge
154 mov a2,d0
155 or DCPGCR_DCP,d0
156 mov d0,(a0) # DCPGCR = (mask & start) | DCPGCR_DCP
157
158 # wait for busy bit of area purge
159 setlb
160 mov (a0),d1
161 btst DCPGCR_DCPGBSY,d1
162 lne
163
164 # check purge of end address
165 add d2,a2 # a2 += alignsize
166 cmp a1,a2 # if (a2 < end) goto dcpgloop
167 bns dcpgloop
168
169 LOCAL_IRQ_RESTORE(d3)
170
171mn10300_local_dcache_flush_range_end:
172 ret [d2,d3,a2],12
173
174 .size mn10300_local_dcache_flush_page,.-mn10300_local_dcache_flush_page
175 .size mn10300_local_dcache_flush_range,.-mn10300_local_dcache_flush_range
176 .size mn10300_local_dcache_flush_range2,.-mn10300_local_dcache_flush_range2
177
178###############################################################################
179#
180# void mn10300_local_dcache_flush_inv(void)
181# Flush the entire data cache and invalidate all entries
182#
183###############################################################################
184 ALIGN
185 .globl mn10300_local_dcache_flush_inv
186 .type mn10300_local_dcache_flush_inv,@function
187mn10300_local_dcache_flush_inv:
188 movhu (CHCTR),d0
189 btst CHCTR_DCEN,d0
190 beq mn10300_local_dcache_flush_inv_end
191
192 mov DCPGCR,a0
193
194 LOCAL_CLI_SAVE(d1)
195
196 # wait for busy bit of area purge & invalidate
197 setlb
198 mov (a0),d0
199 btst DCPGCR_DCPGBSY,d0
200 lne
201
202 # set the mask to cover everything
203 clr d0
204 mov d0,(DCPGMR)
205
206 # area purge & invalidate
207 mov DCPGCR_DCP|DCPGCR_DCI,d0
208 mov d0,(a0)
209
210 # wait for busy bit of area purge & invalidate
211 setlb
212 mov (a0),d0
213 btst DCPGCR_DCPGBSY,d0
214 lne
215
216 LOCAL_IRQ_RESTORE(d1)
217
218mn10300_local_dcache_flush_inv_end:
219 ret [],0
220 .size mn10300_local_dcache_flush_inv,.-mn10300_local_dcache_flush_inv
221
222###############################################################################
223#
224# void mn10300_local_dcache_flush_inv_page(unsigned long start)
225# void mn10300_local_dcache_flush_inv_range(unsigned long start, unsigned long end)
226# void mn10300_local_dcache_flush_inv_range2(unsigned long start, unsigned long size)
227# Flush and invalidate a range of addresses on a page in the dcache
228#
229###############################################################################
230 ALIGN
231 .globl mn10300_local_dcache_flush_inv_page
232 .globl mn10300_local_dcache_flush_inv_range
233 .globl mn10300_local_dcache_flush_inv_range2
234 .type mn10300_local_dcache_flush_inv_page,@function
235 .type mn10300_local_dcache_flush_inv_range,@function
236 .type mn10300_local_dcache_flush_inv_range2,@function
237mn10300_local_dcache_flush_inv_page:
238 and ~(PAGE_SIZE-1),d0
239 mov PAGE_SIZE,d1
240mn10300_local_dcache_flush_inv_range2:
241 add d0,d1
242mn10300_local_dcache_flush_inv_range:
243 movm [d2,d3,a2],(sp)
244
245 movhu (CHCTR),d2
246 btst CHCTR_DCEN,d2
247 beq mn10300_local_dcache_flush_inv_range_end
248
249 # calculate alignsize
250 #
251 # alignsize = L1_CACHE_BYTES;
252 # for (i = (end - start - 1) / L1_CACHE_BYTES; i > 0; i >>= 1)
253 # alignsize <<= 1;
254 # d2 = alignsize
255 #
256 mov L1_CACHE_BYTES,d2
257 sub d0,d1,d3
258 add -1,d3
259 lsr L1_CACHE_SHIFT,d3
260 beq 2f
2611:
262 add d2,d2
263 lsr 1,d3
264 bne 1b
2652:
266 mov d1,a1 # a1 = end
267
268 LOCAL_CLI_SAVE(d3)
269 mov DCPGCR,a0
270
271 # wait for busy bit of area purge & invalidate
272 setlb
273 mov (a0),d1
274 btst DCPGCR_DCPGBSY,d1
275 lne
276
277 # set the mask
278 mov d2,d1
279 add -1,d1
280 not d1 # d1 = mask = ~(alignsize-1)
281 mov d1,(DCPGMR)
282
283 and d1,d0,a2 # a2 = mask & start
284
285dcpgivloop:
286 # area purge & invalidate
287 mov a2,d0
288 or DCPGCR_DCP|DCPGCR_DCI,d0
289 mov d0,(a0) # DCPGCR = (mask & start)|DCPGCR_DCP|DCPGCR_DCI
290
291 # wait for busy bit of area purge & invalidate
292 setlb
293 mov (a0),d1
294 btst DCPGCR_DCPGBSY,d1
295 lne
296
297 # check purge & invalidate of end address
298 add d2,a2 # a2 += alignsize
299 cmp a1,a2 # if (a2 < end) goto dcpgivloop
300 bns dcpgivloop
301
302 LOCAL_IRQ_RESTORE(d3)
303
304mn10300_local_dcache_flush_inv_range_end:
305 ret [d2,d3,a2],12
306 .size mn10300_local_dcache_flush_inv_page,.-mn10300_local_dcache_flush_inv_page
307 .size mn10300_local_dcache_flush_inv_range,.-mn10300_local_dcache_flush_inv_range
308 .size mn10300_local_dcache_flush_inv_range2,.-mn10300_local_dcache_flush_inv_range2
diff --git a/arch/mn10300/mm/cache-flush-by-tag.S b/arch/mn10300/mm/cache-flush-by-tag.S
new file mode 100644
index 000000000000..5cd6a27dd63e
--- /dev/null
+++ b/arch/mn10300/mm/cache-flush-by-tag.S
@@ -0,0 +1,251 @@
1/* MN10300 CPU core caching routines, using direct tag flushing
2 *
3 * Copyright (C) 2007 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/sys.h>
13#include <linux/linkage.h>
14#include <asm/smp.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17#include <asm/irqflags.h>
18
19 .am33_2
20
21#ifndef CONFIG_SMP
22 .globl mn10300_dcache_flush
23 .globl mn10300_dcache_flush_page
24 .globl mn10300_dcache_flush_range
25 .globl mn10300_dcache_flush_range2
26 .globl mn10300_dcache_flush_inv
27 .globl mn10300_dcache_flush_inv_page
28 .globl mn10300_dcache_flush_inv_range
29 .globl mn10300_dcache_flush_inv_range2
30
31mn10300_dcache_flush = mn10300_local_dcache_flush
32mn10300_dcache_flush_page = mn10300_local_dcache_flush_page
33mn10300_dcache_flush_range = mn10300_local_dcache_flush_range
34mn10300_dcache_flush_range2 = mn10300_local_dcache_flush_range2
35mn10300_dcache_flush_inv = mn10300_local_dcache_flush_inv
36mn10300_dcache_flush_inv_page = mn10300_local_dcache_flush_inv_page
37mn10300_dcache_flush_inv_range = mn10300_local_dcache_flush_inv_range
38mn10300_dcache_flush_inv_range2 = mn10300_local_dcache_flush_inv_range2
39
40#endif /* !CONFIG_SMP */
41
42###############################################################################
43#
44# void mn10300_local_dcache_flush(void)
45# Flush the entire data cache back to RAM
46#
47###############################################################################
48 ALIGN
49 .globl mn10300_local_dcache_flush
50 .type mn10300_local_dcache_flush,@function
51mn10300_local_dcache_flush:
52 movhu (CHCTR),d0
53 btst CHCTR_DCEN,d0
54 beq mn10300_local_dcache_flush_end
55
56 # read the addresses tagged in the cache's tag RAM and attempt to flush
57 # those addresses specifically
58 # - we rely on the hardware to filter out invalid tag entry addresses
59 mov DCACHE_TAG(0,0),a0 # dcache tag RAM access address
60 mov DCACHE_PURGE(0,0),a1 # dcache purge request address
61 mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of entries
62
63mn10300_local_dcache_flush_loop:
64 mov (a0),d0
65 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0
66 or L1_CACHE_TAG_VALID,d0 # retain valid entries in the
67 # cache
68 mov d0,(a1) # conditional purge
69
70 add L1_CACHE_BYTES,a0
71 add L1_CACHE_BYTES,a1
72 add -1,d1
73 bne mn10300_local_dcache_flush_loop
74
75mn10300_local_dcache_flush_end:
76 ret [],0
77 .size mn10300_local_dcache_flush,.-mn10300_local_dcache_flush
78
79###############################################################################
80#
81# void mn10300_local_dcache_flush_page(unsigned long start)
82# void mn10300_local_dcache_flush_range(unsigned long start, unsigned long end)
83# void mn10300_local_dcache_flush_range2(unsigned long start, unsigned long size)
84# Flush a range of addresses on a page in the dcache
85#
86###############################################################################
87 ALIGN
88 .globl mn10300_local_dcache_flush_page
89 .globl mn10300_local_dcache_flush_range
90 .globl mn10300_local_dcache_flush_range2
91 .type mn10300_local_dcache_flush_page,@function
92 .type mn10300_local_dcache_flush_range,@function
93 .type mn10300_local_dcache_flush_range2,@function
94mn10300_local_dcache_flush_page:
95 and ~(PAGE_SIZE-1),d0
96 mov PAGE_SIZE,d1
97mn10300_local_dcache_flush_range2:
98 add d0,d1
99mn10300_local_dcache_flush_range:
100 movm [d2],(sp)
101
102 movhu (CHCTR),d2
103 btst CHCTR_DCEN,d2
104 beq mn10300_local_dcache_flush_range_end
105
106 sub d0,d1,a0
107 cmp MN10300_DCACHE_FLUSH_BORDER,a0
108 ble 1f
109
110 movm (sp),[d2]
111 bra mn10300_local_dcache_flush
1121:
113
114 # round start addr down
115 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0
116 mov d0,a1
117
118 add L1_CACHE_BYTES,d1 # round end addr up
119 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
120
121 # write a request to flush all instances of an address from the cache
122 mov DCACHE_PURGE(0,0),a0
123 mov a1,d0
124 and L1_CACHE_TAG_ENTRY,d0
125 add d0,a0 # starting dcache purge control
126 # reg address
127
128 sub a1,d1
129 lsr L1_CACHE_SHIFT,d1 # total number of entries to
130 # examine
131
132 or L1_CACHE_TAG_VALID,a1 # retain valid entries in the
133 # cache
134
135mn10300_local_dcache_flush_range_loop:
136 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
137 # all ways
138
139 add L1_CACHE_BYTES,a0
140 add L1_CACHE_BYTES,a1
141 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
142 add -1,d1
143 bne mn10300_local_dcache_flush_range_loop
144
145mn10300_local_dcache_flush_range_end:
146 ret [d2],4
147
148 .size mn10300_local_dcache_flush_page,.-mn10300_local_dcache_flush_page
149 .size mn10300_local_dcache_flush_range,.-mn10300_local_dcache_flush_range
150 .size mn10300_local_dcache_flush_range2,.-mn10300_local_dcache_flush_range2
151
152###############################################################################
153#
154# void mn10300_local_dcache_flush_inv(void)
155# Flush the entire data cache and invalidate all entries
156#
157###############################################################################
158 ALIGN
159 .globl mn10300_local_dcache_flush_inv
160 .type mn10300_local_dcache_flush_inv,@function
161mn10300_local_dcache_flush_inv:
162 movhu (CHCTR),d0
163 btst CHCTR_DCEN,d0
164 beq mn10300_local_dcache_flush_inv_end
165
166 mov L1_CACHE_NENTRIES,d1
167 clr a1
168
169mn10300_local_dcache_flush_inv_loop:
170 mov (DCACHE_PURGE_WAY0(0),a1),d0 # unconditional purge
171 mov (DCACHE_PURGE_WAY1(0),a1),d0 # unconditional purge
172 mov (DCACHE_PURGE_WAY2(0),a1),d0 # unconditional purge
173 mov (DCACHE_PURGE_WAY3(0),a1),d0 # unconditional purge
174
175 add L1_CACHE_BYTES,a1
176 add -1,d1
177 bne mn10300_local_dcache_flush_inv_loop
178
179mn10300_local_dcache_flush_inv_end:
180 ret [],0
181 .size mn10300_local_dcache_flush_inv,.-mn10300_local_dcache_flush_inv
182
183###############################################################################
184#
185# void mn10300_local_dcache_flush_inv_page(unsigned long start)
186# void mn10300_local_dcache_flush_inv_range(unsigned long start, unsigned long end)
187# void mn10300_local_dcache_flush_inv_range2(unsigned long start, unsigned long size)
188# Flush and invalidate a range of addresses on a page in the dcache
189#
190###############################################################################
191 ALIGN
192 .globl mn10300_local_dcache_flush_inv_page
193 .globl mn10300_local_dcache_flush_inv_range
194 .globl mn10300_local_dcache_flush_inv_range2
195 .type mn10300_local_dcache_flush_inv_page,@function
196 .type mn10300_local_dcache_flush_inv_range,@function
197 .type mn10300_local_dcache_flush_inv_range2,@function
198mn10300_local_dcache_flush_inv_page:
199 and ~(PAGE_SIZE-1),d0
200 mov PAGE_SIZE,d1
201mn10300_local_dcache_flush_inv_range2:
202 add d0,d1
203mn10300_local_dcache_flush_inv_range:
204 movm [d2],(sp)
205
206 movhu (CHCTR),d2
207 btst CHCTR_DCEN,d2
208 beq mn10300_local_dcache_flush_inv_range_end
209
210 sub d0,d1,a0
211 cmp MN10300_DCACHE_FLUSH_INV_BORDER,a0
212 ble 1f
213
214 movm (sp),[d2]
215 bra mn10300_local_dcache_flush_inv
2161:
217
218 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0 # round start
219 # addr down
220 mov d0,a1
221
222 add L1_CACHE_BYTES,d1 # round end addr up
223 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
224
225 # write a request to flush and invalidate all instances of an address
226 # from the cache
227 mov DCACHE_PURGE(0,0),a0
228 mov a1,d0
229 and L1_CACHE_TAG_ENTRY,d0
230 add d0,a0 # starting dcache purge control
231 # reg address
232
233 sub a1,d1
234 lsr L1_CACHE_SHIFT,d1 # total number of entries to
235 # examine
236
237mn10300_local_dcache_flush_inv_range_loop:
238 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
239 # in all ways
240
241 add L1_CACHE_BYTES,a0
242 add L1_CACHE_BYTES,a1
243 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
244 add -1,d1
245 bne mn10300_local_dcache_flush_inv_range_loop
246
247mn10300_local_dcache_flush_inv_range_end:
248 ret [d2],4
249 .size mn10300_local_dcache_flush_inv_page,.-mn10300_local_dcache_flush_inv_page
250 .size mn10300_local_dcache_flush_inv_range,.-mn10300_local_dcache_flush_inv_range
251 .size mn10300_local_dcache_flush_inv_range2,.-mn10300_local_dcache_flush_inv_range2
diff --git a/arch/mn10300/mm/cache-flush-icache.c b/arch/mn10300/mm/cache-flush-icache.c
new file mode 100644
index 000000000000..fdb1a9db20f0
--- /dev/null
+++ b/arch/mn10300/mm/cache-flush-icache.c
@@ -0,0 +1,155 @@
1/* Flush dcache and invalidate icache when the dcache is in writeback mode
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#include <linux/module.h>
12#include <linux/mm.h>
13#include <asm/cacheflush.h>
14#include <asm/smp.h>
15#include "cache-smp.h"
16
17/**
18 * flush_icache_page - Flush a page from the dcache and invalidate the icache
19 * @vma: The VMA the page is part of.
20 * @page: The page to be flushed.
21 *
22 * Write a page back from the dcache and invalidate the icache so that we can
23 * run code from it that we've just written into it
24 */
25void flush_icache_page(struct vm_area_struct *vma, struct page *page)
26{
27 unsigned long start = page_to_phys(page);
28 unsigned long flags;
29
30 flags = smp_lock_cache();
31
32 mn10300_local_dcache_flush_page(start);
33 mn10300_local_icache_inv_page(start);
34
35 smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start, start + PAGE_SIZE);
36 smp_unlock_cache(flags);
37}
38EXPORT_SYMBOL(flush_icache_page);
39
40/**
41 * flush_icache_page_range - Flush dcache and invalidate icache for part of a
42 * single page
43 * @start: The starting virtual address of the page part.
44 * @end: The ending virtual address of the page part.
45 *
46 * Flush the dcache and invalidate the icache for part of a single page, as
47 * determined by the virtual addresses given. The page must be in the paged
48 * area.
49 */
50static void flush_icache_page_range(unsigned long start, unsigned long end)
51{
52 unsigned long addr, size, off;
53 struct page *page;
54 pgd_t *pgd;
55 pud_t *pud;
56 pmd_t *pmd;
57 pte_t *ppte, pte;
58
59 /* work out how much of the page to flush */
60 off = start & ~PAGE_MASK;
61 size = end - start;
62
63 /* get the physical address the page is mapped to from the page
64 * tables */
65 pgd = pgd_offset(current->mm, start);
66 if (!pgd || !pgd_val(*pgd))
67 return;
68
69 pud = pud_offset(pgd, start);
70 if (!pud || !pud_val(*pud))
71 return;
72
73 pmd = pmd_offset(pud, start);
74 if (!pmd || !pmd_val(*pmd))
75 return;
76
77 ppte = pte_offset_map(pmd, start);
78 if (!ppte)
79 return;
80 pte = *ppte;
81 pte_unmap(ppte);
82
83 if (pte_none(pte))
84 return;
85
86 page = pte_page(pte);
87 if (!page)
88 return;
89
90 addr = page_to_phys(page);
91
92 /* flush the dcache and invalidate the icache coverage on that
93 * region */
94 mn10300_local_dcache_flush_range2(addr + off, size);
95 mn10300_local_icache_inv_range2(addr + off, size);
96 smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start, end);
97}
98
99/**
100 * flush_icache_range - Globally flush dcache and invalidate icache for region
101 * @start: The starting virtual address of the region.
102 * @end: The ending virtual address of the region.
103 *
104 * This is used by the kernel to globally flush some code it has just written
105 * from the dcache back to RAM and then to globally invalidate the icache over
106 * that region so that that code can be run on all CPUs in the system.
107 */
108void flush_icache_range(unsigned long start, unsigned long end)
109{
110 unsigned long start_page, end_page;
111 unsigned long flags;
112
113 flags = smp_lock_cache();
114
115 if (end > 0x80000000UL) {
116 /* addresses above 0xa0000000 do not go through the cache */
117 if (end > 0xa0000000UL) {
118 end = 0xa0000000UL;
119 if (start >= end)
120 goto done;
121 }
122
123 /* kernel addresses between 0x80000000 and 0x9fffffff do not
124 * require page tables, so we just map such addresses
125 * directly */
126 start_page = (start >= 0x80000000UL) ? start : 0x80000000UL;
127 mn10300_local_dcache_flush_range(start_page, end);
128 mn10300_local_icache_inv_range(start_page, end);
129 smp_cache_call(SMP_IDCACHE_INV_FLUSH_RANGE, start_page, end);
130 if (start_page == start)
131 goto done;
132 end = start_page;
133 }
134
135 start_page = start & PAGE_MASK;
136 end_page = (end - 1) & PAGE_MASK;
137
138 if (start_page == end_page) {
139 /* the first and last bytes are on the same page */
140 flush_icache_page_range(start, end);
141 } else if (start_page + 1 == end_page) {
142 /* split over two virtually contiguous pages */
143 flush_icache_page_range(start, end_page);
144 flush_icache_page_range(end_page, end);
145 } else {
146 /* more than 2 pages; just flush the entire cache */
147 mn10300_dcache_flush();
148 mn10300_icache_inv();
149 smp_cache_call(SMP_IDCACHE_INV_FLUSH, 0, 0);
150 }
151
152done:
153 smp_unlock_cache(flags);
154}
155EXPORT_SYMBOL(flush_icache_range);
diff --git a/arch/mn10300/mm/cache-flush-mn10300.S b/arch/mn10300/mm/cache-flush-mn10300.S
deleted file mode 100644
index c8ed1cbac107..000000000000
--- a/arch/mn10300/mm/cache-flush-mn10300.S
+++ /dev/null
@@ -1,192 +0,0 @@
1/* MN10300 CPU core caching routines
2 *
3 * Copyright (C) 2007 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/sys.h>
13#include <linux/linkage.h>
14#include <asm/smp.h>
15#include <asm/page.h>
16#include <asm/cache.h>
17
18 .am33_2
19 .globl mn10300_dcache_flush
20 .globl mn10300_dcache_flush_page
21 .globl mn10300_dcache_flush_range
22 .globl mn10300_dcache_flush_range2
23 .globl mn10300_dcache_flush_inv
24 .globl mn10300_dcache_flush_inv_page
25 .globl mn10300_dcache_flush_inv_range
26 .globl mn10300_dcache_flush_inv_range2
27
28###############################################################################
29#
30# void mn10300_dcache_flush(void)
31# Flush the entire data cache back to RAM
32#
33###############################################################################
34 ALIGN
35mn10300_dcache_flush:
36 movhu (CHCTR),d0
37 btst CHCTR_DCEN,d0
38 beq mn10300_dcache_flush_end
39
40 # read the addresses tagged in the cache's tag RAM and attempt to flush
41 # those addresses specifically
42 # - we rely on the hardware to filter out invalid tag entry addresses
43 mov DCACHE_TAG(0,0),a0 # dcache tag RAM access address
44 mov DCACHE_PURGE(0,0),a1 # dcache purge request address
45 mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of entries
46
47mn10300_dcache_flush_loop:
48 mov (a0),d0
49 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0
50 or L1_CACHE_TAG_VALID,d0 # retain valid entries in the
51 # cache
52 mov d0,(a1) # conditional purge
53
54mn10300_dcache_flush_skip:
55 add L1_CACHE_BYTES,a0
56 add L1_CACHE_BYTES,a1
57 add -1,d1
58 bne mn10300_dcache_flush_loop
59
60mn10300_dcache_flush_end:
61 ret [],0
62
63###############################################################################
64#
65# void mn10300_dcache_flush_page(unsigned start)
66# void mn10300_dcache_flush_range(unsigned start, unsigned end)
67# void mn10300_dcache_flush_range2(unsigned start, unsigned size)
68# Flush a range of addresses on a page in the dcache
69#
70###############################################################################
71 ALIGN
72mn10300_dcache_flush_page:
73 mov PAGE_SIZE,d1
74mn10300_dcache_flush_range2:
75 add d0,d1
76mn10300_dcache_flush_range:
77 movm [d2,d3],(sp)
78
79 movhu (CHCTR),d2
80 btst CHCTR_DCEN,d2
81 beq mn10300_dcache_flush_range_end
82
83 # round start addr down
84 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0
85 mov d0,a1
86
87 add L1_CACHE_BYTES,d1 # round end addr up
88 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
89
90 # write a request to flush all instances of an address from the cache
91 mov DCACHE_PURGE(0,0),a0
92 mov a1,d0
93 and L1_CACHE_TAG_ENTRY,d0
94 add d0,a0 # starting dcache purge control
95 # reg address
96
97 sub a1,d1
98 lsr L1_CACHE_SHIFT,d1 # total number of entries to
99 # examine
100
101 or L1_CACHE_TAG_VALID,a1 # retain valid entries in the
102 # cache
103
104mn10300_dcache_flush_range_loop:
105 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
106 # all ways
107
108 add L1_CACHE_BYTES,a0
109 add L1_CACHE_BYTES,a1
110 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
111 add -1,d1
112 bne mn10300_dcache_flush_range_loop
113
114mn10300_dcache_flush_range_end:
115 ret [d2,d3],8
116
117###############################################################################
118#
119# void mn10300_dcache_flush_inv(void)
120# Flush the entire data cache and invalidate all entries
121#
122###############################################################################
123 ALIGN
124mn10300_dcache_flush_inv:
125 movhu (CHCTR),d0
126 btst CHCTR_DCEN,d0
127 beq mn10300_dcache_flush_inv_end
128
129 # hit each line in the dcache with an unconditional purge
130 mov DCACHE_PURGE(0,0),a1 # dcache purge request address
131 mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of entries
132
133mn10300_dcache_flush_inv_loop:
134 mov (a1),d0 # unconditional purge
135
136 add L1_CACHE_BYTES,a1
137 add -1,d1
138 bne mn10300_dcache_flush_inv_loop
139
140mn10300_dcache_flush_inv_end:
141 ret [],0
142
143###############################################################################
144#
145# void mn10300_dcache_flush_inv_page(unsigned start)
146# void mn10300_dcache_flush_inv_range(unsigned start, unsigned end)
147# void mn10300_dcache_flush_inv_range2(unsigned start, unsigned size)
148# Flush and invalidate a range of addresses on a page in the dcache
149#
150###############################################################################
151 ALIGN
152mn10300_dcache_flush_inv_page:
153 mov PAGE_SIZE,d1
154mn10300_dcache_flush_inv_range2:
155 add d0,d1
156mn10300_dcache_flush_inv_range:
157 movm [d2,d3],(sp)
158 movhu (CHCTR),d2
159 btst CHCTR_DCEN,d2
160 beq mn10300_dcache_flush_inv_range_end
161
162 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0 # round start
163 # addr down
164 mov d0,a1
165
166 add L1_CACHE_BYTES,d1 # round end addr up
167 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
168
169 # write a request to flush and invalidate all instances of an address
170 # from the cache
171 mov DCACHE_PURGE(0,0),a0
172 mov a1,d0
173 and L1_CACHE_TAG_ENTRY,d0
174 add d0,a0 # starting dcache purge control
175 # reg address
176
177 sub a1,d1
178 lsr L1_CACHE_SHIFT,d1 # total number of entries to
179 # examine
180
181mn10300_dcache_flush_inv_range_loop:
182 mov a1,(L1_CACHE_WAYDISP*0,a0) # conditionally purge this line
183 # in all ways
184
185 add L1_CACHE_BYTES,a0
186 add L1_CACHE_BYTES,a1
187 and ~L1_CACHE_WAYDISP,a0 # make sure way stay on way 0
188 add -1,d1
189 bne mn10300_dcache_flush_inv_range_loop
190
191mn10300_dcache_flush_inv_range_end:
192 ret [d2,d3],8
diff --git a/arch/mn10300/mm/cache-inv-by-reg.S b/arch/mn10300/mm/cache-inv-by-reg.S
new file mode 100644
index 000000000000..c8950861ed77
--- /dev/null
+++ b/arch/mn10300/mm/cache-inv-by-reg.S
@@ -0,0 +1,356 @@
1/* MN10300 CPU cache invalidation routines, using automatic purge registers
2 *
3 * Copyright (C) 2007 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#include <linux/sys.h>
12#include <linux/linkage.h>
13#include <asm/smp.h>
14#include <asm/page.h>
15#include <asm/cache.h>
16#include <asm/irqflags.h>
17#include <asm/cacheflush.h>
18
19#define mn10300_local_dcache_inv_range_intr_interval \
20 +((1 << MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL) - 1)
21
22#if mn10300_local_dcache_inv_range_intr_interval > 0xff
23#error MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL must be 8 or less
24#endif
25
26 .am33_2
27
28#ifndef CONFIG_SMP
29 .globl mn10300_icache_inv
30 .globl mn10300_icache_inv_page
31 .globl mn10300_icache_inv_range
32 .globl mn10300_icache_inv_range2
33 .globl mn10300_dcache_inv
34 .globl mn10300_dcache_inv_page
35 .globl mn10300_dcache_inv_range
36 .globl mn10300_dcache_inv_range2
37
38mn10300_icache_inv = mn10300_local_icache_inv
39mn10300_icache_inv_page = mn10300_local_icache_inv_page
40mn10300_icache_inv_range = mn10300_local_icache_inv_range
41mn10300_icache_inv_range2 = mn10300_local_icache_inv_range2
42mn10300_dcache_inv = mn10300_local_dcache_inv
43mn10300_dcache_inv_page = mn10300_local_dcache_inv_page
44mn10300_dcache_inv_range = mn10300_local_dcache_inv_range
45mn10300_dcache_inv_range2 = mn10300_local_dcache_inv_range2
46
47#endif /* !CONFIG_SMP */
48
49###############################################################################
50#
51# void mn10300_local_icache_inv(void)
52# Invalidate the entire icache
53#
54###############################################################################
55 ALIGN
56 .globl mn10300_local_icache_inv
57 .type mn10300_local_icache_inv,@function
58mn10300_local_icache_inv:
59 mov CHCTR,a0
60
61 movhu (a0),d0
62 btst CHCTR_ICEN,d0
63 beq mn10300_local_icache_inv_end
64
65 # invalidate
66 or CHCTR_ICINV,d0
67 movhu d0,(a0)
68 movhu (a0),d0
69
70mn10300_local_icache_inv_end:
71 ret [],0
72 .size mn10300_local_icache_inv,.-mn10300_local_icache_inv
73
74###############################################################################
75#
76# void mn10300_local_dcache_inv(void)
77# Invalidate the entire dcache
78#
79###############################################################################
80 ALIGN
81 .globl mn10300_local_dcache_inv
82 .type mn10300_local_dcache_inv,@function
83mn10300_local_dcache_inv:
84 mov CHCTR,a0
85
86 movhu (a0),d0
87 btst CHCTR_DCEN,d0
88 beq mn10300_local_dcache_inv_end
89
90 # invalidate
91 or CHCTR_DCINV,d0
92 movhu d0,(a0)
93 movhu (a0),d0
94
95mn10300_local_dcache_inv_end:
96 ret [],0
97 .size mn10300_local_dcache_inv,.-mn10300_local_dcache_inv
98
99###############################################################################
100#
101# void mn10300_local_dcache_inv_range(unsigned long start, unsigned long end)
102# void mn10300_local_dcache_inv_range2(unsigned long start, unsigned long size)
103# void mn10300_local_dcache_inv_page(unsigned long start)
104# Invalidate a range of addresses on a page in the dcache
105#
106###############################################################################
107 ALIGN
108 .globl mn10300_local_dcache_inv_page
109 .globl mn10300_local_dcache_inv_range
110 .globl mn10300_local_dcache_inv_range2
111 .type mn10300_local_dcache_inv_page,@function
112 .type mn10300_local_dcache_inv_range,@function
113 .type mn10300_local_dcache_inv_range2,@function
114mn10300_local_dcache_inv_page:
115 and ~(PAGE_SIZE-1),d0
116 mov PAGE_SIZE,d1
117mn10300_local_dcache_inv_range2:
118 add d0,d1
119mn10300_local_dcache_inv_range:
120 # If we are in writeback mode we check the start and end alignments,
121 # and if they're not cacheline-aligned, we must flush any bits outside
122 # the range that share cachelines with stuff inside the range
123#ifdef CONFIG_MN10300_CACHE_WBACK
124 btst ~(L1_CACHE_BYTES-1),d0
125 bne 1f
126 btst ~(L1_CACHE_BYTES-1),d1
127 beq 2f
1281:
129 bra mn10300_local_dcache_flush_inv_range
1302:
131#endif /* CONFIG_MN10300_CACHE_WBACK */
132
133 movm [d2,d3,a2],(sp)
134
135 mov CHCTR,a0
136 movhu (a0),d2
137 btst CHCTR_DCEN,d2
138 beq mn10300_local_dcache_inv_range_end
139
140 # round the addresses out to be full cachelines, unless we're in
141 # writeback mode, in which case we would be in flush and invalidate by
142 # now
143#ifndef CONFIG_MN10300_CACHE_WBACK
144 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0 # round start
145 # addr down
146
147 mov L1_CACHE_BYTES-1,d2
148 add d2,d1
149 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1 # round end addr up
150#endif /* !CONFIG_MN10300_CACHE_WBACK */
151
152 sub d0,d1,d2 # calculate the total size
153 mov d0,a2 # A2 = start address
154 mov d1,a1 # A1 = end address
155
156 LOCAL_CLI_SAVE(d3)
157
158 mov DCPGCR,a0 # make sure the purger isn't busy
159 setlb
160 mov (a0),d0
161 btst DCPGCR_DCPGBSY,d0
162 lne
163
164 # skip initial address alignment calculation if address is zero
165 mov d2,d1
166 cmp 0,a2
167 beq 1f
168
169dcivloop:
170 /* calculate alignsize
171 *
172 * alignsize = L1_CACHE_BYTES;
173 * while (! start & alignsize) {
174 * alignsize <<=1;
175 * }
176 * d1 = alignsize;
177 */
178 mov L1_CACHE_BYTES,d1
179 lsr 1,d1
180 setlb
181 add d1,d1
182 mov d1,d0
183 and a2,d0
184 leq
185
1861:
187 /* calculate invsize
188 *
189 * if (totalsize > alignsize) {
190 * invsize = alignsize;
191 * } else {
192 * invsize = totalsize;
193 * tmp = 0x80000000;
194 * while (! invsize & tmp) {
195 * tmp >>= 1;
196 * }
197 * invsize = tmp;
198 * }
199 * d1 = invsize
200 */
201 cmp d2,d1
202 bns 2f
203 mov d2,d1
204
205 mov 0x80000000,d0 # start from 31bit=1
206 setlb
207 lsr 1,d0
208 mov d0,e0
209 and d1,e0
210 leq
211 mov d0,d1
212
2132:
214 /* set mask
215 *
216 * mask = ~(invsize-1);
217 * DCPGMR = mask;
218 */
219 mov d1,d0
220 add -1,d0
221 not d0
222 mov d0,(DCPGMR)
223
224 # invalidate area
225 mov a2,d0
226 or DCPGCR_DCI,d0
227 mov d0,(a0) # DCPGCR = (mask & start) | DCPGCR_DCI
228
229 setlb # wait for the purge to complete
230 mov (a0),d0
231 btst DCPGCR_DCPGBSY,d0
232 lne
233
234 sub d1,d2 # decrease size remaining
235 add d1,a2 # increase next start address
236
237 /* check invalidating of end address
238 *
239 * a2 = a2 + invsize
240 * if (a2 < end) {
241 * goto dcivloop;
242 * } */
243 cmp a1,a2
244 bns dcivloop
245
246 LOCAL_IRQ_RESTORE(d3)
247
248mn10300_local_dcache_inv_range_end:
249 ret [d2,d3,a2],12
250 .size mn10300_local_dcache_inv_page,.-mn10300_local_dcache_inv_page
251 .size mn10300_local_dcache_inv_range,.-mn10300_local_dcache_inv_range
252 .size mn10300_local_dcache_inv_range2,.-mn10300_local_dcache_inv_range2
253
254###############################################################################
255#
256# void mn10300_local_icache_inv_page(unsigned long start)
257# void mn10300_local_icache_inv_range2(unsigned long start, unsigned long size)
258# void mn10300_local_icache_inv_range(unsigned long start, unsigned long end)
259# Invalidate a range of addresses on a page in the icache
260#
261###############################################################################
262 ALIGN
263 .globl mn10300_local_icache_inv_page
264 .globl mn10300_local_icache_inv_range
265 .globl mn10300_local_icache_inv_range2
266 .type mn10300_local_icache_inv_page,@function
267 .type mn10300_local_icache_inv_range,@function
268 .type mn10300_local_icache_inv_range2,@function
269mn10300_local_icache_inv_page:
270 and ~(PAGE_SIZE-1),d0
271 mov PAGE_SIZE,d1
272mn10300_local_icache_inv_range2:
273 add d0,d1
274mn10300_local_icache_inv_range:
275 movm [d2,d3,a2],(sp)
276
277 mov CHCTR,a0
278 movhu (a0),d2
279 btst CHCTR_ICEN,d2
280 beq mn10300_local_icache_inv_range_reg_end
281
282 /* calculate alignsize
283 *
284 * alignsize = L1_CACHE_BYTES;
285 * for (i = (end - start - 1) / L1_CACHE_BYTES ; i > 0; i >>= 1) {
286 * alignsize <<= 1;
287 * }
288 * d2 = alignsize;
289 */
290 mov L1_CACHE_BYTES,d2
291 sub d0,d1,d3
292 add -1,d3
293 lsr L1_CACHE_SHIFT,d3
294 beq 2f
2951:
296 add d2,d2
297 lsr 1,d3
298 bne 1b
2992:
300
301 /* a1 = end */
302 mov d1,a1
303
304 LOCAL_CLI_SAVE(d3)
305
306 mov ICIVCR,a0
307 /* wait for busy bit of area invalidation */
308 setlb
309 mov (a0),d1
310 btst ICIVCR_ICIVBSY,d1
311 lne
312
313 /* set mask
314 *
315 * mask = ~(alignsize-1);
316 * ICIVMR = mask;
317 */
318 mov d2,d1
319 add -1,d1
320 not d1
321 mov d1,(ICIVMR)
322 /* a2 = mask & start */
323 and d1,d0,a2
324
325icivloop:
326 /* area invalidate
327 *
328 * ICIVCR = (mask & start) | ICIVCR_ICI
329 */
330 mov a2,d0
331 or ICIVCR_ICI,d0
332 mov d0,(a0)
333
334 /* wait for busy bit of area invalidation */
335 setlb
336 mov (a0),d1
337 btst ICIVCR_ICIVBSY,d1
338 lne
339
340 /* check invalidating of end address
341 *
342 * a2 = a2 + alignsize
343 * if (a2 < end) {
344 * goto icivloop;
345 * } */
346 add d2,a2
347 cmp a1,a2
348 bns icivloop
349
350 LOCAL_IRQ_RESTORE(d3)
351
352mn10300_local_icache_inv_range_reg_end:
353 ret [d2,d3,a2],12
354 .size mn10300_local_icache_inv_page,.-mn10300_local_icache_inv_page
355 .size mn10300_local_icache_inv_range,.-mn10300_local_icache_inv_range
356 .size mn10300_local_icache_inv_range2,.-mn10300_local_icache_inv_range2
diff --git a/arch/mn10300/mm/cache-inv-by-tag.S b/arch/mn10300/mm/cache-inv-by-tag.S
new file mode 100644
index 000000000000..e9713b40c0ff
--- /dev/null
+++ b/arch/mn10300/mm/cache-inv-by-tag.S
@@ -0,0 +1,348 @@
1/* MN10300 CPU core caching routines
2 *
3 * Copyright (C) 2007 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#include <linux/sys.h>
12#include <linux/linkage.h>
13#include <asm/smp.h>
14#include <asm/page.h>
15#include <asm/cache.h>
16#include <asm/irqflags.h>
17#include <asm/cacheflush.h>
18
19#define mn10300_local_dcache_inv_range_intr_interval \
20 +((1 << MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL) - 1)
21
22#if mn10300_local_dcache_inv_range_intr_interval > 0xff
23#error MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL must be 8 or less
24#endif
25
26 .am33_2
27
28 .globl mn10300_local_icache_inv_page
29 .globl mn10300_local_icache_inv_range
30 .globl mn10300_local_icache_inv_range2
31
32mn10300_local_icache_inv_page = mn10300_local_icache_inv
33mn10300_local_icache_inv_range = mn10300_local_icache_inv
34mn10300_local_icache_inv_range2 = mn10300_local_icache_inv
35
36#ifndef CONFIG_SMP
37 .globl mn10300_icache_inv
38 .globl mn10300_icache_inv_page
39 .globl mn10300_icache_inv_range
40 .globl mn10300_icache_inv_range2
41 .globl mn10300_dcache_inv
42 .globl mn10300_dcache_inv_page
43 .globl mn10300_dcache_inv_range
44 .globl mn10300_dcache_inv_range2
45
46mn10300_icache_inv = mn10300_local_icache_inv
47mn10300_icache_inv_page = mn10300_local_icache_inv_page
48mn10300_icache_inv_range = mn10300_local_icache_inv_range
49mn10300_icache_inv_range2 = mn10300_local_icache_inv_range2
50mn10300_dcache_inv = mn10300_local_dcache_inv
51mn10300_dcache_inv_page = mn10300_local_dcache_inv_page
52mn10300_dcache_inv_range = mn10300_local_dcache_inv_range
53mn10300_dcache_inv_range2 = mn10300_local_dcache_inv_range2
54
55#endif /* !CONFIG_SMP */
56
57###############################################################################
58#
59# void mn10300_local_icache_inv(void)
60# Invalidate the entire icache
61#
62###############################################################################
63 ALIGN
64 .globl mn10300_local_icache_inv
65 .type mn10300_local_icache_inv,@function
66mn10300_local_icache_inv:
67 mov CHCTR,a0
68
69 movhu (a0),d0
70 btst CHCTR_ICEN,d0
71 beq mn10300_local_icache_inv_end
72
73#if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
74 LOCAL_CLI_SAVE(d1)
75
76 # disable the icache
77 and ~CHCTR_ICEN,d0
78 movhu d0,(a0)
79
80 # and wait for it to calm down
81 setlb
82 movhu (a0),d0
83 btst CHCTR_ICBUSY,d0
84 lne
85
86 # invalidate
87 or CHCTR_ICINV,d0
88 movhu d0,(a0)
89
90 # wait for the cache to finish
91 mov CHCTR,a0
92 setlb
93 movhu (a0),d0
94 btst CHCTR_ICBUSY,d0
95 lne
96
97 # and reenable it
98 and ~CHCTR_ICINV,d0
99 or CHCTR_ICEN,d0
100 movhu d0,(a0)
101 movhu (a0),d0
102
103 LOCAL_IRQ_RESTORE(d1)
104#else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
105 # invalidate
106 or CHCTR_ICINV,d0
107 movhu d0,(a0)
108 movhu (a0),d0
109#endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
110
111mn10300_local_icache_inv_end:
112 ret [],0
113 .size mn10300_local_icache_inv,.-mn10300_local_icache_inv
114
115###############################################################################
116#
117# void mn10300_local_dcache_inv(void)
118# Invalidate the entire dcache
119#
120###############################################################################
121 ALIGN
122 .globl mn10300_local_dcache_inv
123 .type mn10300_local_dcache_inv,@function
124mn10300_local_dcache_inv:
125 mov CHCTR,a0
126
127 movhu (a0),d0
128 btst CHCTR_DCEN,d0
129 beq mn10300_local_dcache_inv_end
130
131#if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
132 LOCAL_CLI_SAVE(d1)
133
134 # disable the dcache
135 and ~CHCTR_DCEN,d0
136 movhu d0,(a0)
137
138 # and wait for it to calm down
139 setlb
140 movhu (a0),d0
141 btst CHCTR_DCBUSY,d0
142 lne
143
144 # invalidate
145 or CHCTR_DCINV,d0
146 movhu d0,(a0)
147
148 # wait for the cache to finish
149 mov CHCTR,a0
150 setlb
151 movhu (a0),d0
152 btst CHCTR_DCBUSY,d0
153 lne
154
155 # and reenable it
156 and ~CHCTR_DCINV,d0
157 or CHCTR_DCEN,d0
158 movhu d0,(a0)
159 movhu (a0),d0
160
161 LOCAL_IRQ_RESTORE(d1)
162#else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
163 # invalidate
164 or CHCTR_DCINV,d0
165 movhu d0,(a0)
166 movhu (a0),d0
167#endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
168
169mn10300_local_dcache_inv_end:
170 ret [],0
171 .size mn10300_local_dcache_inv,.-mn10300_local_dcache_inv
172
173###############################################################################
174#
175# void mn10300_local_dcache_inv_range(unsigned long start, unsigned long end)
176# void mn10300_local_dcache_inv_range2(unsigned long start, unsigned long size)
177# void mn10300_local_dcache_inv_page(unsigned long start)
178# Invalidate a range of addresses on a page in the dcache
179#
180###############################################################################
181 ALIGN
182 .globl mn10300_local_dcache_inv_page
183 .globl mn10300_local_dcache_inv_range
184 .globl mn10300_local_dcache_inv_range2
185 .type mn10300_local_dcache_inv_page,@function
186 .type mn10300_local_dcache_inv_range,@function
187 .type mn10300_local_dcache_inv_range2,@function
188mn10300_local_dcache_inv_page:
189 and ~(PAGE_SIZE-1),d0
190 mov PAGE_SIZE,d1
191mn10300_local_dcache_inv_range2:
192 add d0,d1
193mn10300_local_dcache_inv_range:
194 # If we are in writeback mode we check the start and end alignments,
195 # and if they're not cacheline-aligned, we must flush any bits outside
196 # the range that share cachelines with stuff inside the range
197#ifdef CONFIG_MN10300_CACHE_WBACK
198 btst ~(L1_CACHE_BYTES-1),d0
199 bne 1f
200 btst ~(L1_CACHE_BYTES-1),d1
201 beq 2f
2021:
203 bra mn10300_local_dcache_flush_inv_range
2042:
205#endif /* CONFIG_MN10300_CACHE_WBACK */
206
207 movm [d2,d3,a2],(sp)
208
209 mov CHCTR,a2
210 movhu (a2),d2
211 btst CHCTR_DCEN,d2
212 beq mn10300_local_dcache_inv_range_end
213
214#ifndef CONFIG_MN10300_CACHE_WBACK
215 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0 # round start
216 # addr down
217
218 add L1_CACHE_BYTES,d1 # round end addr up
219 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
220#endif /* !CONFIG_MN10300_CACHE_WBACK */
221 mov d0,a1
222
223 clr d2 # we're going to clear tag RAM
224 # entries
225
226 # read the tags from the tag RAM, and if they indicate a valid dirty
227 # cache line then invalidate that line
228 mov DCACHE_TAG(0,0),a0
229 mov a1,d0
230 and L1_CACHE_TAG_ENTRY,d0
231 add d0,a0 # starting dcache tag RAM
232 # access address
233
234 sub a1,d1
235 lsr L1_CACHE_SHIFT,d1 # total number of entries to
236 # examine
237
238 and ~(L1_CACHE_DISPARITY-1),a1 # determine comparator base
239
240mn10300_local_dcache_inv_range_outer_loop:
241 LOCAL_CLI_SAVE(d3)
242
243 # disable the dcache
244 movhu (a2),d0
245 and ~CHCTR_DCEN,d0
246 movhu d0,(a2)
247
248 # and wait for it to calm down
249 setlb
250 movhu (a2),d0
251 btst CHCTR_DCBUSY,d0
252 lne
253
254mn10300_local_dcache_inv_range_loop:
255
256 # process the way 0 slot
257 mov (L1_CACHE_WAYDISP*0,a0),d0 # read the tag in the way 0 slot
258 btst L1_CACHE_TAG_VALID,d0
259 beq mn10300_local_dcache_inv_range_skip_0 # jump if this cacheline
260 # is not valid
261
262 xor a1,d0
263 lsr 12,d0
264 bne mn10300_local_dcache_inv_range_skip_0 # jump if not this cacheline
265
266 mov d2,(L1_CACHE_WAYDISP*0,a0) # kill the tag
267
268mn10300_local_dcache_inv_range_skip_0:
269
270 # process the way 1 slot
271 mov (L1_CACHE_WAYDISP*1,a0),d0 # read the tag in the way 1 slot
272 btst L1_CACHE_TAG_VALID,d0
273 beq mn10300_local_dcache_inv_range_skip_1 # jump if this cacheline
274 # is not valid
275
276 xor a1,d0
277 lsr 12,d0
278 bne mn10300_local_dcache_inv_range_skip_1 # jump if not this cacheline
279
280 mov d2,(L1_CACHE_WAYDISP*1,a0) # kill the tag
281
282mn10300_local_dcache_inv_range_skip_1:
283
284 # process the way 2 slot
285 mov (L1_CACHE_WAYDISP*2,a0),d0 # read the tag in the way 2 slot
286 btst L1_CACHE_TAG_VALID,d0
287 beq mn10300_local_dcache_inv_range_skip_2 # jump if this cacheline
288 # is not valid
289
290 xor a1,d0
291 lsr 12,d0
292 bne mn10300_local_dcache_inv_range_skip_2 # jump if not this cacheline
293
294 mov d2,(L1_CACHE_WAYDISP*2,a0) # kill the tag
295
296mn10300_local_dcache_inv_range_skip_2:
297
298 # process the way 3 slot
299 mov (L1_CACHE_WAYDISP*3,a0),d0 # read the tag in the way 3 slot
300 btst L1_CACHE_TAG_VALID,d0
301 beq mn10300_local_dcache_inv_range_skip_3 # jump if this cacheline
302 # is not valid
303
304 xor a1,d0
305 lsr 12,d0
306 bne mn10300_local_dcache_inv_range_skip_3 # jump if not this cacheline
307
308 mov d2,(L1_CACHE_WAYDISP*3,a0) # kill the tag
309
310mn10300_local_dcache_inv_range_skip_3:
311
312 # approx every N steps we re-enable the cache and see if there are any
313 # interrupts to be processed
314 # we also break out if we've reached the end of the loop
315 # (the bottom nibble of the count is zero in both cases)
316 add L1_CACHE_BYTES,a0
317 add L1_CACHE_BYTES,a1
318 and ~L1_CACHE_WAYDISP,a0
319 add -1,d1
320 btst mn10300_local_dcache_inv_range_intr_interval,d1
321 bne mn10300_local_dcache_inv_range_loop
322
323 # wait for the cache to finish what it's doing
324 setlb
325 movhu (a2),d0
326 btst CHCTR_DCBUSY,d0
327 lne
328
329 # and reenable it
330 or CHCTR_DCEN,d0
331 movhu d0,(a2)
332 movhu (a2),d0
333
334 # re-enable interrupts
335 # - we don't bother with delay NOPs as we'll have enough instructions
336 # before we disable interrupts again to give the interrupts a chance
337 # to happen
338 LOCAL_IRQ_RESTORE(d3)
339
340 # go around again if the counter hasn't yet reached zero
341 add 0,d1
342 bne mn10300_local_dcache_inv_range_outer_loop
343
344mn10300_local_dcache_inv_range_end:
345 ret [d2,d3,a2],12
346 .size mn10300_local_dcache_inv_page,.-mn10300_local_dcache_inv_page
347 .size mn10300_local_dcache_inv_range,.-mn10300_local_dcache_inv_range
348 .size mn10300_local_dcache_inv_range2,.-mn10300_local_dcache_inv_range2
diff --git a/arch/mn10300/mm/cache-inv-icache.c b/arch/mn10300/mm/cache-inv-icache.c
new file mode 100644
index 000000000000..a8933a60b2d4
--- /dev/null
+++ b/arch/mn10300/mm/cache-inv-icache.c
@@ -0,0 +1,129 @@
1/* Invalidate icache when dcache doesn't need invalidation as it's in
2 * write-through mode
3 *
4 * Copyright (C) 2010 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.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 Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
11 */
12#include <linux/module.h>
13#include <linux/mm.h>
14#include <asm/cacheflush.h>
15#include <asm/smp.h>
16#include "cache-smp.h"
17
18/**
19 * flush_icache_page_range - Flush dcache and invalidate icache for part of a
20 * single page
21 * @start: The starting virtual address of the page part.
22 * @end: The ending virtual address of the page part.
23 *
24 * Invalidate the icache for part of a single page, as determined by the
25 * virtual addresses given. The page must be in the paged area. The dcache is
26 * not flushed as the cache must be in write-through mode to get here.
27 */
28static void flush_icache_page_range(unsigned long start, unsigned long end)
29{
30 unsigned long addr, size, off;
31 struct page *page;
32 pgd_t *pgd;
33 pud_t *pud;
34 pmd_t *pmd;
35 pte_t *ppte, pte;
36
37 /* work out how much of the page to flush */
38 off = start & ~PAGE_MASK;
39 size = end - start;
40
41 /* get the physical address the page is mapped to from the page
42 * tables */
43 pgd = pgd_offset(current->mm, start);
44 if (!pgd || !pgd_val(*pgd))
45 return;
46
47 pud = pud_offset(pgd, start);
48 if (!pud || !pud_val(*pud))
49 return;
50
51 pmd = pmd_offset(pud, start);
52 if (!pmd || !pmd_val(*pmd))
53 return;
54
55 ppte = pte_offset_map(pmd, start);
56 if (!ppte)
57 return;
58 pte = *ppte;
59 pte_unmap(ppte);
60
61 if (pte_none(pte))
62 return;
63
64 page = pte_page(pte);
65 if (!page)
66 return;
67
68 addr = page_to_phys(page);
69
70 /* invalidate the icache coverage on that region */
71 mn10300_local_icache_inv_range2(addr + off, size);
72 smp_cache_call(SMP_ICACHE_INV_FLUSH_RANGE, start, end);
73}
74
75/**
76 * flush_icache_range - Globally flush dcache and invalidate icache for region
77 * @start: The starting virtual address of the region.
78 * @end: The ending virtual address of the region.
79 *
80 * This is used by the kernel to globally flush some code it has just written
81 * from the dcache back to RAM and then to globally invalidate the icache over
82 * that region so that that code can be run on all CPUs in the system.
83 */
84void flush_icache_range(unsigned long start, unsigned long end)
85{
86 unsigned long start_page, end_page;
87 unsigned long flags;
88
89 flags = smp_lock_cache();
90
91 if (end > 0x80000000UL) {
92 /* addresses above 0xa0000000 do not go through the cache */
93 if (end > 0xa0000000UL) {
94 end = 0xa0000000UL;
95 if (start >= end)
96 goto done;
97 }
98
99 /* kernel addresses between 0x80000000 and 0x9fffffff do not
100 * require page tables, so we just map such addresses
101 * directly */
102 start_page = (start >= 0x80000000UL) ? start : 0x80000000UL;
103 mn10300_icache_inv_range(start_page, end);
104 smp_cache_call(SMP_ICACHE_INV_FLUSH_RANGE, start, end);
105 if (start_page == start)
106 goto done;
107 end = start_page;
108 }
109
110 start_page = start & PAGE_MASK;
111 end_page = (end - 1) & PAGE_MASK;
112
113 if (start_page == end_page) {
114 /* the first and last bytes are on the same page */
115 flush_icache_page_range(start, end);
116 } else if (start_page + 1 == end_page) {
117 /* split over two virtually contiguous pages */
118 flush_icache_page_range(start, end_page);
119 flush_icache_page_range(end_page, end);
120 } else {
121 /* more than 2 pages; just flush the entire cache */
122 mn10300_local_icache_inv();
123 smp_cache_call(SMP_ICACHE_INV, 0, 0);
124 }
125
126done:
127 smp_unlock_cache(flags);
128}
129EXPORT_SYMBOL(flush_icache_range);
diff --git a/arch/mn10300/mm/cache-mn10300.S b/arch/mn10300/mm/cache-mn10300.S
deleted file mode 100644
index e839d0aedd69..000000000000
--- a/arch/mn10300/mm/cache-mn10300.S
+++ /dev/null
@@ -1,289 +0,0 @@
1/* MN10300 CPU core caching routines
2 *
3 * Copyright (C) 2007 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#include <linux/sys.h>
12#include <linux/linkage.h>
13#include <asm/smp.h>
14#include <asm/page.h>
15#include <asm/cache.h>
16
17#define mn10300_dcache_inv_range_intr_interval \
18 +((1 << MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL) - 1)
19
20#if mn10300_dcache_inv_range_intr_interval > 0xff
21#error MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL must be 8 or less
22#endif
23
24 .am33_2
25
26 .globl mn10300_icache_inv
27 .globl mn10300_dcache_inv
28 .globl mn10300_dcache_inv_range
29 .globl mn10300_dcache_inv_range2
30 .globl mn10300_dcache_inv_page
31
32###############################################################################
33#
34# void mn10300_icache_inv(void)
35# Invalidate the entire icache
36#
37###############################################################################
38 ALIGN
39mn10300_icache_inv:
40 mov CHCTR,a0
41
42 movhu (a0),d0
43 btst CHCTR_ICEN,d0
44 beq mn10300_icache_inv_end
45
46 mov epsw,d1
47 and ~EPSW_IE,epsw
48 nop
49 nop
50
51 # disable the icache
52 and ~CHCTR_ICEN,d0
53 movhu d0,(a0)
54
55 # and wait for it to calm down
56 setlb
57 movhu (a0),d0
58 btst CHCTR_ICBUSY,d0
59 lne
60
61 # invalidate
62 or CHCTR_ICINV,d0
63 movhu d0,(a0)
64
65 # wait for the cache to finish
66 mov CHCTR,a0
67 setlb
68 movhu (a0),d0
69 btst CHCTR_ICBUSY,d0
70 lne
71
72 # and reenable it
73 and ~CHCTR_ICINV,d0
74 or CHCTR_ICEN,d0
75 movhu d0,(a0)
76 movhu (a0),d0
77
78 mov d1,epsw
79
80mn10300_icache_inv_end:
81 ret [],0
82
83###############################################################################
84#
85# void mn10300_dcache_inv(void)
86# Invalidate the entire dcache
87#
88###############################################################################
89 ALIGN
90mn10300_dcache_inv:
91 mov CHCTR,a0
92
93 movhu (a0),d0
94 btst CHCTR_DCEN,d0
95 beq mn10300_dcache_inv_end
96
97 mov epsw,d1
98 and ~EPSW_IE,epsw
99 nop
100 nop
101
102 # disable the dcache
103 and ~CHCTR_DCEN,d0
104 movhu d0,(a0)
105
106 # and wait for it to calm down
107 setlb
108 movhu (a0),d0
109 btst CHCTR_DCBUSY,d0
110 lne
111
112 # invalidate
113 or CHCTR_DCINV,d0
114 movhu d0,(a0)
115
116 # wait for the cache to finish
117 mov CHCTR,a0
118 setlb
119 movhu (a0),d0
120 btst CHCTR_DCBUSY,d0
121 lne
122
123 # and reenable it
124 and ~CHCTR_DCINV,d0
125 or CHCTR_DCEN,d0
126 movhu d0,(a0)
127 movhu (a0),d0
128
129 mov d1,epsw
130
131mn10300_dcache_inv_end:
132 ret [],0
133
134###############################################################################
135#
136# void mn10300_dcache_inv_range(unsigned start, unsigned end)
137# void mn10300_dcache_inv_range2(unsigned start, unsigned size)
138# void mn10300_dcache_inv_page(unsigned start)
139# Invalidate a range of addresses on a page in the dcache
140#
141###############################################################################
142 ALIGN
143mn10300_dcache_inv_page:
144 mov PAGE_SIZE,d1
145mn10300_dcache_inv_range2:
146 add d0,d1
147mn10300_dcache_inv_range:
148 movm [d2,d3,a2],(sp)
149 mov CHCTR,a2
150
151 movhu (a2),d2
152 btst CHCTR_DCEN,d2
153 beq mn10300_dcache_inv_range_end
154
155 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0 # round start
156 # addr down
157 mov d0,a1
158
159 add L1_CACHE_BYTES,d1 # round end addr up
160 and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d1
161
162 clr d2 # we're going to clear tag ram
163 # entries
164
165 # read the tags from the tag RAM, and if they indicate a valid dirty
166 # cache line then invalidate that line
167 mov DCACHE_TAG(0,0),a0
168 mov a1,d0
169 and L1_CACHE_TAG_ENTRY,d0
170 add d0,a0 # starting dcache tag RAM
171 # access address
172
173 sub a1,d1
174 lsr L1_CACHE_SHIFT,d1 # total number of entries to
175 # examine
176
177 and ~(L1_CACHE_DISPARITY-1),a1 # determine comparator base
178
179mn10300_dcache_inv_range_outer_loop:
180 # disable interrupts
181 mov epsw,d3
182 and ~EPSW_IE,epsw
183 nop # note that reading CHCTR and
184 # AND'ing D0 occupy two delay
185 # slots after disabling
186 # interrupts
187
188 # disable the dcache
189 movhu (a2),d0
190 and ~CHCTR_DCEN,d0
191 movhu d0,(a2)
192
193 # and wait for it to calm down
194 setlb
195 movhu (a2),d0
196 btst CHCTR_DCBUSY,d0
197 lne
198
199mn10300_dcache_inv_range_loop:
200
201 # process the way 0 slot
202 mov (L1_CACHE_WAYDISP*0,a0),d0 # read the tag in the way 0 slot
203 btst L1_CACHE_TAG_VALID,d0
204 beq mn10300_dcache_inv_range_skip_0 # jump if this cacheline is not
205 # valid
206
207 xor a1,d0
208 lsr 12,d0
209 bne mn10300_dcache_inv_range_skip_0 # jump if not this cacheline
210
211 mov d2,(a0) # kill the tag
212
213mn10300_dcache_inv_range_skip_0:
214
215 # process the way 1 slot
216 mov (L1_CACHE_WAYDISP*1,a0),d0 # read the tag in the way 1 slot
217 btst L1_CACHE_TAG_VALID,d0
218 beq mn10300_dcache_inv_range_skip_1 # jump if this cacheline is not
219 # valid
220
221 xor a1,d0
222 lsr 12,d0
223 bne mn10300_dcache_inv_range_skip_1 # jump if not this cacheline
224
225 mov d2,(a0) # kill the tag
226
227mn10300_dcache_inv_range_skip_1:
228
229 # process the way 2 slot
230 mov (L1_CACHE_WAYDISP*2,a0),d0 # read the tag in the way 2 slot
231 btst L1_CACHE_TAG_VALID,d0
232 beq mn10300_dcache_inv_range_skip_2 # jump if this cacheline is not
233 # valid
234
235 xor a1,d0
236 lsr 12,d0
237 bne mn10300_dcache_inv_range_skip_2 # jump if not this cacheline
238
239 mov d2,(a0) # kill the tag
240
241mn10300_dcache_inv_range_skip_2:
242
243 # process the way 3 slot
244 mov (L1_CACHE_WAYDISP*3,a0),d0 # read the tag in the way 3 slot
245 btst L1_CACHE_TAG_VALID,d0
246 beq mn10300_dcache_inv_range_skip_3 # jump if this cacheline is not
247 # valid
248
249 xor a1,d0
250 lsr 12,d0
251 bne mn10300_dcache_inv_range_skip_3 # jump if not this cacheline
252
253 mov d2,(a0) # kill the tag
254
255mn10300_dcache_inv_range_skip_3:
256
257 # approx every N steps we re-enable the cache and see if there are any
258 # interrupts to be processed
259 # we also break out if we've reached the end of the loop
260 # (the bottom nibble of the count is zero in both cases)
261 add L1_CACHE_BYTES,a0
262 add L1_CACHE_BYTES,a1
263 add -1,d1
264 btst mn10300_dcache_inv_range_intr_interval,d1
265 bne mn10300_dcache_inv_range_loop
266
267 # wait for the cache to finish what it's doing
268 setlb
269 movhu (a2),d0
270 btst CHCTR_DCBUSY,d0
271 lne
272
273 # and reenable it
274 or CHCTR_DCEN,d0
275 movhu d0,(a2)
276 movhu (a2),d0
277
278 # re-enable interrupts
279 # - we don't bother with delay NOPs as we'll have enough instructions
280 # before we disable interrupts again to give the interrupts a chance
281 # to happen
282 mov d3,epsw
283
284 # go around again if the counter hasn't yet reached zero
285 add 0,d1
286 bne mn10300_dcache_inv_range_outer_loop
287
288mn10300_dcache_inv_range_end:
289 ret [d2,d3,a2],12
diff --git a/arch/mn10300/mm/cache-smp-flush.c b/arch/mn10300/mm/cache-smp-flush.c
new file mode 100644
index 000000000000..fd51af5eaf70
--- /dev/null
+++ b/arch/mn10300/mm/cache-smp-flush.c
@@ -0,0 +1,156 @@
1/* Functions for global dcache flush when writeback caching in SMP
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#include <linux/mm.h>
12#include <asm/cacheflush.h>
13#include "cache-smp.h"
14
15/**
16 * mn10300_dcache_flush - Globally flush data cache
17 *
18 * Flush the data cache on all CPUs.
19 */
20void mn10300_dcache_flush(void)
21{
22 unsigned long flags;
23
24 flags = smp_lock_cache();
25 mn10300_local_dcache_flush();
26 smp_cache_call(SMP_DCACHE_FLUSH, 0, 0);
27 smp_unlock_cache(flags);
28}
29
30/**
31 * mn10300_dcache_flush_page - Globally flush a page of data cache
32 * @start: The address of the page of memory to be flushed.
33 *
34 * Flush a range of addresses in the data cache on all CPUs covering
35 * the page that includes the given address.
36 */
37void mn10300_dcache_flush_page(unsigned long start)
38{
39 unsigned long flags;
40
41 start &= ~(PAGE_SIZE-1);
42
43 flags = smp_lock_cache();
44 mn10300_local_dcache_flush_page(start);
45 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + PAGE_SIZE);
46 smp_unlock_cache(flags);
47}
48
49/**
50 * mn10300_dcache_flush_range - Globally flush range of data cache
51 * @start: The start address of the region to be flushed.
52 * @end: The end address of the region to be flushed.
53 *
54 * Flush a range of addresses in the data cache on all CPUs, between start and
55 * end-1 inclusive.
56 */
57void mn10300_dcache_flush_range(unsigned long start, unsigned long end)
58{
59 unsigned long flags;
60
61 flags = smp_lock_cache();
62 mn10300_local_dcache_flush_range(start, end);
63 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, end);
64 smp_unlock_cache(flags);
65}
66
67/**
68 * mn10300_dcache_flush_range2 - Globally flush range of data cache
69 * @start: The start address of the region to be flushed.
70 * @size: The size of the region to be flushed.
71 *
72 * Flush a range of addresses in the data cache on all CPUs, between start and
73 * start+size-1 inclusive.
74 */
75void mn10300_dcache_flush_range2(unsigned long start, unsigned long size)
76{
77 unsigned long flags;
78
79 flags = smp_lock_cache();
80 mn10300_local_dcache_flush_range2(start, size);
81 smp_cache_call(SMP_DCACHE_FLUSH_RANGE, start, start + size);
82 smp_unlock_cache(flags);
83}
84
85/**
86 * mn10300_dcache_flush_inv - Globally flush and invalidate data cache
87 *
88 * Flush and invalidate the data cache on all CPUs.
89 */
90void mn10300_dcache_flush_inv(void)
91{
92 unsigned long flags;
93
94 flags = smp_lock_cache();
95 mn10300_local_dcache_flush_inv();
96 smp_cache_call(SMP_DCACHE_FLUSH_INV, 0, 0);
97 smp_unlock_cache(flags);
98}
99
100/**
101 * mn10300_dcache_flush_inv_page - Globally flush and invalidate a page of data
102 * cache
103 * @start: The address of the page of memory to be flushed and invalidated.
104 *
105 * Flush and invalidate a range of addresses in the data cache on all CPUs
106 * covering the page that includes the given address.
107 */
108void mn10300_dcache_flush_inv_page(unsigned long start)
109{
110 unsigned long flags;
111
112 start &= ~(PAGE_SIZE-1);
113
114 flags = smp_lock_cache();
115 mn10300_local_dcache_flush_inv_page(start);
116 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + PAGE_SIZE);
117 smp_unlock_cache(flags);
118}
119
120/**
121 * mn10300_dcache_flush_inv_range - Globally flush and invalidate range of data
122 * cache
123 * @start: The start address of the region to be flushed and invalidated.
124 * @end: The end address of the region to be flushed and invalidated.
125 *
126 * Flush and invalidate a range of addresses in the data cache on all CPUs,
127 * between start and end-1 inclusive.
128 */
129void mn10300_dcache_flush_inv_range(unsigned long start, unsigned long end)
130{
131 unsigned long flags;
132
133 flags = smp_lock_cache();
134 mn10300_local_dcache_flush_inv_range(start, end);
135 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, end);
136 smp_unlock_cache(flags);
137}
138
139/**
140 * mn10300_dcache_flush_inv_range2 - Globally flush and invalidate range of data
141 * cache
142 * @start: The start address of the region to be flushed and invalidated.
143 * @size: The size of the region to be flushed and invalidated.
144 *
145 * Flush and invalidate a range of addresses in the data cache on all CPUs,
146 * between start and start+size-1 inclusive.
147 */
148void mn10300_dcache_flush_inv_range2(unsigned long start, unsigned long size)
149{
150 unsigned long flags;
151
152 flags = smp_lock_cache();
153 mn10300_local_dcache_flush_inv_range2(start, size);
154 smp_cache_call(SMP_DCACHE_FLUSH_INV_RANGE, start, start + size);
155 smp_unlock_cache(flags);
156}
diff --git a/arch/mn10300/mm/cache-smp-inv.c b/arch/mn10300/mm/cache-smp-inv.c
new file mode 100644
index 000000000000..ff1787358c8e
--- /dev/null
+++ b/arch/mn10300/mm/cache-smp-inv.c
@@ -0,0 +1,153 @@
1/* Functions for global i/dcache invalidation when caching in SMP
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#include <linux/mm.h>
12#include <asm/cacheflush.h>
13#include "cache-smp.h"
14
15/**
16 * mn10300_icache_inv - Globally invalidate instruction cache
17 *
18 * Invalidate the instruction cache on all CPUs.
19 */
20void mn10300_icache_inv(void)
21{
22 unsigned long flags;
23
24 flags = smp_lock_cache();
25 mn10300_local_icache_inv();
26 smp_cache_call(SMP_ICACHE_INV, 0, 0);
27 smp_unlock_cache(flags);
28}
29
30/**
31 * mn10300_icache_inv_page - Globally invalidate a page of instruction cache
32 * @start: The address of the page of memory to be invalidated.
33 *
34 * Invalidate a range of addresses in the instruction cache on all CPUs
35 * covering the page that includes the given address.
36 */
37void mn10300_icache_inv_page(unsigned long start)
38{
39 unsigned long flags;
40
41 start &= ~(PAGE_SIZE-1);
42
43 flags = smp_lock_cache();
44 mn10300_local_icache_inv_page(start);
45 smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + PAGE_SIZE);
46 smp_unlock_cache(flags);
47}
48
49/**
50 * mn10300_icache_inv_range - Globally invalidate range of instruction cache
51 * @start: The start address of the region to be invalidated.
52 * @end: The end address of the region to be invalidated.
53 *
54 * Invalidate a range of addresses in the instruction cache on all CPUs,
55 * between start and end-1 inclusive.
56 */
57void mn10300_icache_inv_range(unsigned long start, unsigned long end)
58{
59 unsigned long flags;
60
61 flags = smp_lock_cache();
62 mn10300_local_icache_inv_range(start, end);
63 smp_cache_call(SMP_ICACHE_INV_RANGE, start, end);
64 smp_unlock_cache(flags);
65}
66
67/**
68 * mn10300_icache_inv_range2 - Globally invalidate range of instruction cache
69 * @start: The start address of the region to be invalidated.
70 * @size: The size of the region to be invalidated.
71 *
72 * Invalidate a range of addresses in the instruction cache on all CPUs,
73 * between start and start+size-1 inclusive.
74 */
75void mn10300_icache_inv_range2(unsigned long start, unsigned long size)
76{
77 unsigned long flags;
78
79 flags = smp_lock_cache();
80 mn10300_local_icache_inv_range2(start, size);
81 smp_cache_call(SMP_ICACHE_INV_RANGE, start, start + size);
82 smp_unlock_cache(flags);
83}
84
85/**
86 * mn10300_dcache_inv - Globally invalidate data cache
87 *
88 * Invalidate the data cache on all CPUs.
89 */
90void mn10300_dcache_inv(void)
91{
92 unsigned long flags;
93
94 flags = smp_lock_cache();
95 mn10300_local_dcache_inv();
96 smp_cache_call(SMP_DCACHE_INV, 0, 0);
97 smp_unlock_cache(flags);
98}
99
100/**
101 * mn10300_dcache_inv_page - Globally invalidate a page of data cache
102 * @start: The address of the page of memory to be invalidated.
103 *
104 * Invalidate a range of addresses in the data cache on all CPUs covering the
105 * page that includes the given address.
106 */
107void mn10300_dcache_inv_page(unsigned long start)
108{
109 unsigned long flags;
110
111 start &= ~(PAGE_SIZE-1);
112
113 flags = smp_lock_cache();
114 mn10300_local_dcache_inv_page(start);
115 smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + PAGE_SIZE);
116 smp_unlock_cache(flags);
117}
118
119/**
120 * mn10300_dcache_inv_range - Globally invalidate range of data cache
121 * @start: The start address of the region to be invalidated.
122 * @end: The end address of the region to be invalidated.
123 *
124 * Invalidate a range of addresses in the data cache on all CPUs, between start
125 * and end-1 inclusive.
126 */
127void mn10300_dcache_inv_range(unsigned long start, unsigned long end)
128{
129 unsigned long flags;
130
131 flags = smp_lock_cache();
132 mn10300_local_dcache_inv_range(start, end);
133 smp_cache_call(SMP_DCACHE_INV_RANGE, start, end);
134 smp_unlock_cache(flags);
135}
136
137/**
138 * mn10300_dcache_inv_range2 - Globally invalidate range of data cache
139 * @start: The start address of the region to be invalidated.
140 * @size: The size of the region to be invalidated.
141 *
142 * Invalidate a range of addresses in the data cache on all CPUs, between start
143 * and start+size-1 inclusive.
144 */
145void mn10300_dcache_inv_range2(unsigned long start, unsigned long size)
146{
147 unsigned long flags;
148
149 flags = smp_lock_cache();
150 mn10300_local_dcache_inv_range2(start, size);
151 smp_cache_call(SMP_DCACHE_INV_RANGE, start, start + size);
152 smp_unlock_cache(flags);
153}
diff --git a/arch/mn10300/mm/cache-smp.c b/arch/mn10300/mm/cache-smp.c
new file mode 100644
index 000000000000..4a6e9a4b5b27
--- /dev/null
+++ b/arch/mn10300/mm/cache-smp.c
@@ -0,0 +1,105 @@
1/* SMP global caching code
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#include <linux/module.h>
12#include <linux/mm.h>
13#include <linux/mman.h>
14#include <linux/threads.h>
15#include <linux/interrupt.h>
16#include <asm/page.h>
17#include <asm/pgtable.h>
18#include <asm/processor.h>
19#include <asm/cacheflush.h>
20#include <asm/io.h>
21#include <asm/uaccess.h>
22#include <asm/smp.h>
23#include "cache-smp.h"
24
25DEFINE_SPINLOCK(smp_cache_lock);
26static unsigned long smp_cache_mask;
27static unsigned long smp_cache_start;
28static unsigned long smp_cache_end;
29static cpumask_t smp_cache_ipi_map; /* Bitmask of cache IPI done CPUs */
30
31/**
32 * smp_cache_interrupt - Handle IPI request to flush caches.
33 *
34 * Handle a request delivered by IPI to flush the current CPU's
35 * caches. The parameters are stored in smp_cache_*.
36 */
37void smp_cache_interrupt(void)
38{
39 unsigned long opr_mask = smp_cache_mask;
40
41 switch ((enum smp_dcache_ops)(opr_mask & SMP_DCACHE_OP_MASK)) {
42 case SMP_DCACHE_NOP:
43 break;
44 case SMP_DCACHE_INV:
45 mn10300_local_dcache_inv();
46 break;
47 case SMP_DCACHE_INV_RANGE:
48 mn10300_local_dcache_inv_range(smp_cache_start, smp_cache_end);
49 break;
50 case SMP_DCACHE_FLUSH:
51 mn10300_local_dcache_flush();
52 break;
53 case SMP_DCACHE_FLUSH_RANGE:
54 mn10300_local_dcache_flush_range(smp_cache_start,
55 smp_cache_end);
56 break;
57 case SMP_DCACHE_FLUSH_INV:
58 mn10300_local_dcache_flush_inv();
59 break;
60 case SMP_DCACHE_FLUSH_INV_RANGE:
61 mn10300_local_dcache_flush_inv_range(smp_cache_start,
62 smp_cache_end);
63 break;
64 }
65
66 switch ((enum smp_icache_ops)(opr_mask & SMP_ICACHE_OP_MASK)) {
67 case SMP_ICACHE_NOP:
68 break;
69 case SMP_ICACHE_INV:
70 mn10300_local_icache_inv();
71 break;
72 case SMP_ICACHE_INV_RANGE:
73 mn10300_local_icache_inv_range(smp_cache_start, smp_cache_end);
74 break;
75 }
76
77 cpu_clear(smp_processor_id(), smp_cache_ipi_map);
78}
79
80/**
81 * smp_cache_call - Issue an IPI to request the other CPUs flush caches
82 * @opr_mask: Cache operation flags
83 * @start: Start address of request
84 * @end: End address of request
85 *
86 * Send cache flush IPI to other CPUs. This invokes smp_cache_interrupt()
87 * above on those other CPUs and then waits for them to finish.
88 *
89 * The caller must hold smp_cache_lock.
90 */
91void smp_cache_call(unsigned long opr_mask,
92 unsigned long start, unsigned long end)
93{
94 smp_cache_mask = opr_mask;
95 smp_cache_start = start;
96 smp_cache_end = end;
97 smp_cache_ipi_map = cpu_online_map;
98 cpu_clear(smp_processor_id(), smp_cache_ipi_map);
99
100 send_IPI_allbutself(FLUSH_CACHE_IPI);
101
102 while (!cpus_empty(smp_cache_ipi_map))
103 /* nothing. lockup detection does not belong here */
104 mb();
105}
diff --git a/arch/mn10300/mm/cache-smp.h b/arch/mn10300/mm/cache-smp.h
new file mode 100644
index 000000000000..cb52892aa66a
--- /dev/null
+++ b/arch/mn10300/mm/cache-smp.h
@@ -0,0 +1,69 @@
1/* SMP caching definitions
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
13/*
14 * Operation requests for smp_cache_call().
15 *
16 * One of smp_icache_ops and one of smp_dcache_ops can be OR'd together.
17 */
18enum smp_icache_ops {
19 SMP_ICACHE_NOP = 0x0000,
20 SMP_ICACHE_INV = 0x0001,
21 SMP_ICACHE_INV_RANGE = 0x0002,
22};
23#define SMP_ICACHE_OP_MASK 0x0003
24
25enum smp_dcache_ops {
26 SMP_DCACHE_NOP = 0x0000,
27 SMP_DCACHE_INV = 0x0004,
28 SMP_DCACHE_INV_RANGE = 0x0008,
29 SMP_DCACHE_FLUSH = 0x000c,
30 SMP_DCACHE_FLUSH_RANGE = 0x0010,
31 SMP_DCACHE_FLUSH_INV = 0x0014,
32 SMP_DCACHE_FLUSH_INV_RANGE = 0x0018,
33};
34#define SMP_DCACHE_OP_MASK 0x001c
35
36#define SMP_IDCACHE_INV_FLUSH (SMP_ICACHE_INV | SMP_DCACHE_FLUSH)
37#define SMP_IDCACHE_INV_FLUSH_RANGE (SMP_ICACHE_INV_RANGE | SMP_DCACHE_FLUSH_RANGE)
38
39/*
40 * cache-smp.c
41 */
42#ifdef CONFIG_SMP
43extern spinlock_t smp_cache_lock;
44
45extern void smp_cache_call(unsigned long opr_mask,
46 unsigned long addr, unsigned long end);
47
48static inline unsigned long smp_lock_cache(void)
49 __acquires(&smp_cache_lock)
50{
51 unsigned long flags;
52 spin_lock_irqsave(&smp_cache_lock, flags);
53 return flags;
54}
55
56static inline void smp_unlock_cache(unsigned long flags)
57 __releases(&smp_cache_lock)
58{
59 spin_unlock_irqrestore(&smp_cache_lock, flags);
60}
61
62#else
63static inline unsigned long smp_lock_cache(void) { return 0; }
64static inline void smp_unlock_cache(unsigned long flags) {}
65static inline void smp_cache_call(unsigned long opr_mask,
66 unsigned long addr, unsigned long end)
67{
68}
69#endif /* CONFIG_SMP */
diff --git a/arch/mn10300/mm/cache.c b/arch/mn10300/mm/cache.c
index 9261217e8d2c..0a1f0aa92ebc 100644
--- a/arch/mn10300/mm/cache.c
+++ b/arch/mn10300/mm/cache.c
@@ -18,8 +18,13 @@
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/io.h> 19#include <asm/io.h>
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include <asm/smp.h>
22#include "cache-smp.h"
21 23
22EXPORT_SYMBOL(mn10300_icache_inv); 24EXPORT_SYMBOL(mn10300_icache_inv);
25EXPORT_SYMBOL(mn10300_icache_inv_range);
26EXPORT_SYMBOL(mn10300_icache_inv_range2);
27EXPORT_SYMBOL(mn10300_icache_inv_page);
23EXPORT_SYMBOL(mn10300_dcache_inv); 28EXPORT_SYMBOL(mn10300_dcache_inv);
24EXPORT_SYMBOL(mn10300_dcache_inv_range); 29EXPORT_SYMBOL(mn10300_dcache_inv_range);
25EXPORT_SYMBOL(mn10300_dcache_inv_range2); 30EXPORT_SYMBOL(mn10300_dcache_inv_range2);
@@ -37,96 +42,6 @@ EXPORT_SYMBOL(mn10300_dcache_flush_page);
37#endif 42#endif
38 43
39/* 44/*
40 * write a page back from the dcache and invalidate the icache so that we can
41 * run code from it that we've just written into it
42 */
43void flush_icache_page(struct vm_area_struct *vma, struct page *page)
44{
45 mn10300_dcache_flush_page(page_to_phys(page));
46 mn10300_icache_inv();
47}
48EXPORT_SYMBOL(flush_icache_page);
49
50/*
51 * write some code we've just written back from the dcache and invalidate the
52 * icache so that we can run that code
53 */
54void flush_icache_range(unsigned long start, unsigned long end)
55{
56#ifdef CONFIG_MN10300_CACHE_WBACK
57 unsigned long addr, size, base, off;
58 struct page *page;
59 pgd_t *pgd;
60 pud_t *pud;
61 pmd_t *pmd;
62 pte_t *ppte, pte;
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
81 for (; start < end; start += size) {
82 /* work out how much of the page to flush */
83 off = start & (PAGE_SIZE - 1);
84
85 size = end - start;
86 if (size > PAGE_SIZE - off)
87 size = PAGE_SIZE - off;
88
89 /* get the physical address the page is mapped to from the page
90 * tables */
91 pgd = pgd_offset(current->mm, start);
92 if (!pgd || !pgd_val(*pgd))
93 continue;
94
95 pud = pud_offset(pgd, start);
96 if (!pud || !pud_val(*pud))
97 continue;
98
99 pmd = pmd_offset(pud, start);
100 if (!pmd || !pmd_val(*pmd))
101 continue;
102
103 ppte = pte_offset_map(pmd, start);
104 if (!ppte)
105 continue;
106 pte = *ppte;
107 pte_unmap(ppte);
108
109 if (pte_none(pte))
110 continue;
111
112 page = pte_page(pte);
113 if (!page)
114 continue;
115
116 addr = page_to_phys(page);
117
118 /* flush the dcache and invalidate the icache coverage on that
119 * region */
120 mn10300_dcache_flush_range2(addr + off, size);
121 }
122#endif
123
124invalidate:
125 mn10300_icache_inv();
126}
127EXPORT_SYMBOL(flush_icache_range);
128
129/*
130 * allow userspace to flush the instruction cache 45 * allow userspace to flush the instruction cache
131 */ 46 */
132asmlinkage long sys_cacheflush(unsigned long start, unsigned long end) 47asmlinkage long sys_cacheflush(unsigned long start, unsigned long end)
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index 81f153fa51b4..59c3da49d9d9 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -39,10 +39,6 @@ void bust_spinlocks(int yes)
39{ 39{
40 if (yes) { 40 if (yes) {
41 oops_in_progress = 1; 41 oops_in_progress = 1;
42#ifdef CONFIG_SMP
43 /* Many serial drivers do __global_cli() */
44 global_irq_lock = 0;
45#endif
46 } else { 42 } else {
47 int loglevel_save = console_loglevel; 43 int loglevel_save = console_loglevel;
48#ifdef CONFIG_VT 44#ifdef CONFIG_VT
@@ -100,8 +96,6 @@ static void print_pagetable_entries(pgd_t *pgdir, unsigned long address)
100} 96}
101#endif 97#endif
102 98
103asmlinkage void monitor_signal(struct pt_regs *);
104
105/* 99/*
106 * This routine handles page faults. It determines the address, 100 * This routine handles page faults. It determines the address,
107 * and the problem, and then passes it off to one of the appropriate 101 * and the problem, and then passes it off to one of the appropriate
@@ -279,7 +273,6 @@ good_area:
279 */ 273 */
280bad_area: 274bad_area:
281 up_read(&mm->mmap_sem); 275 up_read(&mm->mmap_sem);
282 monitor_signal(regs);
283 276
284 /* User mode accesses just cause a SIGSEGV */ 277 /* User mode accesses just cause a SIGSEGV */
285 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) { 278 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR) {
@@ -292,7 +285,6 @@ bad_area:
292 } 285 }
293 286
294no_context: 287no_context:
295 monitor_signal(regs);
296 /* Are we prepared to handle this kernel fault? */ 288 /* Are we prepared to handle this kernel fault? */
297 if (fixup_exception(regs)) 289 if (fixup_exception(regs))
298 return; 290 return;
@@ -338,14 +330,13 @@ no_context:
338 */ 330 */
339out_of_memory: 331out_of_memory:
340 up_read(&mm->mmap_sem); 332 up_read(&mm->mmap_sem);
341 if ((fault_code & MMUFCR_xFC_ACCESS) != MMUFCR_xFC_ACCESS_USR) 333 printk(KERN_ALERT "VM: killing process %s\n", tsk->comm);
342 goto no_context; 334 if ((fault_code & MMUFCR_xFC_ACCESS) == MMUFCR_xFC_ACCESS_USR)
343 pagefault_out_of_memory(); 335 do_exit(SIGKILL);
344 return; 336 goto no_context;
345 337
346do_sigbus: 338do_sigbus:
347 up_read(&mm->mmap_sem); 339 up_read(&mm->mmap_sem);
348 monitor_signal(regs);
349 340
350 /* 341 /*
351 * Send a sigbus, regardless of whether we were in kernel 342 * Send a sigbus, regardless of whether we were in kernel
diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index 6e6bc0e51521..48907cc3bdb7 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -41,6 +41,10 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
41 41
42unsigned long highstart_pfn, highend_pfn; 42unsigned long highstart_pfn, highend_pfn;
43 43
44#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
45static struct vm_struct user_iomap_vm;
46#endif
47
44/* 48/*
45 * set up paging 49 * set up paging
46 */ 50 */
@@ -73,7 +77,24 @@ void __init paging_init(void)
73 /* pass the memory from the bootmem allocator to the main allocator */ 77 /* pass the memory from the bootmem allocator to the main allocator */
74 free_area_init(zones_size); 78 free_area_init(zones_size);
75 79
76 __flush_tlb_all(); 80#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
81 /* The Atomic Operation Unit registers need to be mapped to userspace
82 * for all processes. The following uses vm_area_register_early() to
83 * reserve the first page of the vmalloc area and sets the pte for that
84 * page.
85 *
86 * glibc hardcodes this virtual mapping, so we're pretty much stuck with
87 * it from now on.
88 */
89 user_iomap_vm.flags = VM_USERMAP;
90 user_iomap_vm.size = 1 << PAGE_SHIFT;
91 vm_area_register_early(&user_iomap_vm, PAGE_SIZE);
92 ppte = kernel_vmalloc_ptes;
93 set_pte(ppte, pfn_pte(USER_ATOMIC_OPS_PAGE_ADDR >> PAGE_SHIFT,
94 PAGE_USERIO));
95#endif
96
97 local_flush_tlb_all();
77} 98}
78 99
79/* 100/*
@@ -84,8 +105,7 @@ void __init mem_init(void)
84 int codesize, reservedpages, datasize, initsize; 105 int codesize, reservedpages, datasize, initsize;
85 int tmp; 106 int tmp;
86 107
87 if (!mem_map) 108 BUG_ON(!mem_map);
88 BUG();
89 109
90#define START_PFN (contig_page_data.bdata->node_min_pfn) 110#define START_PFN (contig_page_data.bdata->node_min_pfn)
91#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn) 111#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn)
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c
index 6dffbf97ac26..eef989c1d0c1 100644
--- a/arch/mn10300/mm/misalignment.c
+++ b/arch/mn10300/mm/misalignment.c
@@ -449,8 +449,7 @@ found_opcode:
449 regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]); 449 regs->pc, opcode, pop->opcode, pop->params[0], pop->params[1]);
450 450
451 tmp = format_tbl[pop->format].opsz; 451 tmp = format_tbl[pop->format].opsz;
452 if (tmp > noc) 452 BUG_ON(tmp > noc); /* match was less complete than it ought to have been */
453 BUG(); /* match was less complete than it ought to have been */
454 453
455 if (tmp < noc) { 454 if (tmp < noc) {
456 tmp = noc - tmp; 455 tmp = noc - tmp;
diff --git a/arch/mn10300/mm/mmu-context.c b/arch/mn10300/mm/mmu-context.c
index 36ba02191d40..a4f7d3dcc6e6 100644
--- a/arch/mn10300/mm/mmu-context.c
+++ b/arch/mn10300/mm/mmu-context.c
@@ -13,40 +13,15 @@
13#include <asm/mmu_context.h> 13#include <asm/mmu_context.h>
14#include <asm/tlbflush.h> 14#include <asm/tlbflush.h>
15 15
16#ifdef CONFIG_MN10300_TLB_USE_PIDR
16/* 17/*
17 * list of the MMU contexts last allocated on each CPU 18 * list of the MMU contexts last allocated on each CPU
18 */ 19 */
19unsigned long mmu_context_cache[NR_CPUS] = { 20unsigned long mmu_context_cache[NR_CPUS] = {
20 [0 ... NR_CPUS - 1] = MMU_CONTEXT_FIRST_VERSION * 2 - 1, 21 [0 ... NR_CPUS - 1] =
22 MMU_CONTEXT_FIRST_VERSION * 2 - (1 - MMU_CONTEXT_TLBPID_LOCK_NR),
21}; 23};
22 24#endif /* CONFIG_MN10300_TLB_USE_PIDR */
23/*
24 * flush the specified TLB entry
25 */
26void flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
27{
28 unsigned long pteu, cnx, flags;
29
30 addr &= PAGE_MASK;
31
32 /* make sure the context doesn't migrate and defend against
33 * interference from vmalloc'd regions */
34 local_irq_save(flags);
35
36 cnx = mm_context(vma->vm_mm);
37
38 if (cnx != MMU_NO_CONTEXT) {
39 pteu = addr | (cnx & 0x000000ffUL);
40 IPTEU = pteu;
41 DPTEU = pteu;
42 if (IPTEL & xPTEL_V)
43 IPTEL = 0;
44 if (DPTEL & xPTEL_V)
45 DPTEL = 0;
46 }
47
48 local_irq_restore(flags);
49}
50 25
51/* 26/*
52 * preemptively set a TLB entry 27 * preemptively set a TLB entry
@@ -63,10 +38,16 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t *pte
63 * interference from vmalloc'd regions */ 38 * interference from vmalloc'd regions */
64 local_irq_save(flags); 39 local_irq_save(flags);
65 40
41 cnx = ~MMU_NO_CONTEXT;
42#ifdef CONFIG_MN10300_TLB_USE_PIDR
66 cnx = mm_context(vma->vm_mm); 43 cnx = mm_context(vma->vm_mm);
44#endif
67 45
68 if (cnx != MMU_NO_CONTEXT) { 46 if (cnx != MMU_NO_CONTEXT) {
69 pteu = addr | (cnx & 0x000000ffUL); 47 pteu = addr;
48#ifdef CONFIG_MN10300_TLB_USE_PIDR
49 pteu |= cnx & MMU_CONTEXT_TLBPID_MASK;
50#endif
70 if (!(pte_val(pte) & _PAGE_NX)) { 51 if (!(pte_val(pte) & _PAGE_NX)) {
71 IPTEU = pteu; 52 IPTEU = pteu;
72 if (IPTEL & xPTEL_V) 53 if (IPTEL & xPTEL_V)
diff --git a/arch/mn10300/mm/pgtable.c b/arch/mn10300/mm/pgtable.c
index 9c1624c9e4e9..450f7ba3f8f2 100644
--- a/arch/mn10300/mm/pgtable.c
+++ b/arch/mn10300/mm/pgtable.c
@@ -59,7 +59,7 @@ void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
59 * It's enough to flush this one mapping. 59 * It's enough to flush this one mapping.
60 * (PGE mappings get flushed as well) 60 * (PGE mappings get flushed as well)
61 */ 61 */
62 __flush_tlb_one(vaddr); 62 local_flush_tlb_one(vaddr);
63} 63}
64 64
65pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 65pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
diff --git a/arch/mn10300/mm/tlb-mn10300.S b/arch/mn10300/mm/tlb-mn10300.S
index 7095147dcb8b..b9940177d81b 100644
--- a/arch/mn10300/mm/tlb-mn10300.S
+++ b/arch/mn10300/mm/tlb-mn10300.S
@@ -27,7 +27,6 @@
27############################################################################### 27###############################################################################
28 .type itlb_miss,@function 28 .type itlb_miss,@function
29ENTRY(itlb_miss) 29ENTRY(itlb_miss)
30 and ~EPSW_NMID,epsw
31#ifdef CONFIG_GDBSTUB 30#ifdef CONFIG_GDBSTUB
32 movm [d2,d3,a2],(sp) 31 movm [d2,d3,a2],(sp)
33#else 32#else
@@ -38,6 +37,12 @@ ENTRY(itlb_miss)
38 nop 37 nop
39#endif 38#endif
40 39
40#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
41 mov (MMUCTR),d2
42 mov d2,(MMUCTR)
43#endif
44
45 and ~EPSW_NMID,epsw
41 mov (IPTEU),d3 46 mov (IPTEU),d3
42 mov (PTBR),a2 47 mov (PTBR),a2
43 mov d3,d2 48 mov d3,d2
@@ -56,10 +61,16 @@ ENTRY(itlb_miss)
56 btst _PAGE_VALID,d2 61 btst _PAGE_VALID,d2
57 beq itlb_miss_fault # jump if doesn't point to a page 62 beq itlb_miss_fault # jump if doesn't point to a page
58 # (might be a swap id) 63 # (might be a swap id)
64#if ((_PAGE_ACCESSED & 0xffffff00) == 0)
59 bset _PAGE_ACCESSED,(0,a2) 65 bset _PAGE_ACCESSED,(0,a2)
60 and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2 66#elif ((_PAGE_ACCESSED & 0xffff00ff) == 0)
67 bset +(_PAGE_ACCESSED >> 8),(1,a2)
68#else
69#error "_PAGE_ACCESSED value is out of range"
70#endif
71 and ~xPTEL2_UNUSED1,d2
61itlb_miss_set: 72itlb_miss_set:
62 mov d2,(IPTEL) # change the TLB 73 mov d2,(IPTEL2) # change the TLB
63#ifdef CONFIG_GDBSTUB 74#ifdef CONFIG_GDBSTUB
64 movm (sp),[d2,d3,a2] 75 movm (sp),[d2,d3,a2]
65#endif 76#endif
@@ -79,7 +90,6 @@ itlb_miss_fault:
79############################################################################### 90###############################################################################
80 .type dtlb_miss,@function 91 .type dtlb_miss,@function
81ENTRY(dtlb_miss) 92ENTRY(dtlb_miss)
82 and ~EPSW_NMID,epsw
83#ifdef CONFIG_GDBSTUB 93#ifdef CONFIG_GDBSTUB
84 movm [d2,d3,a2],(sp) 94 movm [d2,d3,a2],(sp)
85#else 95#else
@@ -90,6 +100,12 @@ ENTRY(dtlb_miss)
90 nop 100 nop
91#endif 101#endif
92 102
103#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
104 mov (MMUCTR),d2
105 mov d2,(MMUCTR)
106#endif
107
108 and ~EPSW_NMID,epsw
93 mov (DPTEU),d3 109 mov (DPTEU),d3
94 mov (PTBR),a2 110 mov (PTBR),a2
95 mov d3,d2 111 mov d3,d2
@@ -108,10 +124,16 @@ ENTRY(dtlb_miss)
108 btst _PAGE_VALID,d2 124 btst _PAGE_VALID,d2
109 beq dtlb_miss_fault # jump if doesn't point to a page 125 beq dtlb_miss_fault # jump if doesn't point to a page
110 # (might be a swap id) 126 # (might be a swap id)
127#if ((_PAGE_ACCESSED & 0xffffff00) == 0)
111 bset _PAGE_ACCESSED,(0,a2) 128 bset _PAGE_ACCESSED,(0,a2)
112 and ~(xPTEL_UNUSED1|xPTEL_UNUSED2),d2 129#elif ((_PAGE_ACCESSED & 0xffff00ff) == 0)
130 bset +(_PAGE_ACCESSED >> 8),(1,a2)
131#else
132#error "_PAGE_ACCESSED value is out of range"
133#endif
134 and ~xPTEL2_UNUSED1,d2
113dtlb_miss_set: 135dtlb_miss_set:
114 mov d2,(DPTEL) # change the TLB 136 mov d2,(DPTEL2) # change the TLB
115#ifdef CONFIG_GDBSTUB 137#ifdef CONFIG_GDBSTUB
116 movm (sp),[d2,d3,a2] 138 movm (sp),[d2,d3,a2]
117#endif 139#endif
@@ -130,9 +152,15 @@ dtlb_miss_fault:
130############################################################################### 152###############################################################################
131 .type itlb_aerror,@function 153 .type itlb_aerror,@function
132ENTRY(itlb_aerror) 154ENTRY(itlb_aerror)
133 and ~EPSW_NMID,epsw
134 add -4,sp 155 add -4,sp
135 SAVE_ALL 156 SAVE_ALL
157
158#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
159 mov (MMUCTR),d1
160 mov d1,(MMUCTR)
161#endif
162
163 and ~EPSW_NMID,epsw
136 add -4,sp # need to pass three params 164 add -4,sp # need to pass three params
137 165
138 # calculate the fault code 166 # calculate the fault code
@@ -140,15 +168,13 @@ ENTRY(itlb_aerror)
140 or 0x00010000,d1 # it's an instruction fetch 168 or 0x00010000,d1 # it's an instruction fetch
141 169
142 # determine the page address 170 # determine the page address
143 mov (IPTEU),a2 171 mov (IPTEU),d0
144 mov a2,d0
145 and PAGE_MASK,d0 172 and PAGE_MASK,d0
146 mov d0,(12,sp) 173 mov d0,(12,sp)
147 174
148 clr d0 175 clr d0
149 mov d0,(IPTEL) 176 mov d0,(IPTEL2)
150 177
151 and ~EPSW_NMID,epsw
152 or EPSW_IE,epsw 178 or EPSW_IE,epsw
153 mov fp,d0 179 mov fp,d0
154 call do_page_fault[],0 # do_page_fault(regs,code,addr 180 call do_page_fault[],0 # do_page_fault(regs,code,addr
@@ -163,10 +189,16 @@ ENTRY(itlb_aerror)
163############################################################################### 189###############################################################################
164 .type dtlb_aerror,@function 190 .type dtlb_aerror,@function
165ENTRY(dtlb_aerror) 191ENTRY(dtlb_aerror)
166 and ~EPSW_NMID,epsw
167 add -4,sp 192 add -4,sp
168 SAVE_ALL 193 SAVE_ALL
194
195#if defined(CONFIG_ERRATUM_NEED_TO_RELOAD_MMUCTR)
196 mov (MMUCTR),d1
197 mov d1,(MMUCTR)
198#endif
199
169 add -4,sp # need to pass three params 200 add -4,sp # need to pass three params
201 and ~EPSW_NMID,epsw
170 202
171 # calculate the fault code 203 # calculate the fault code
172 movhu (MMUFCR_DFC),d1 204 movhu (MMUFCR_DFC),d1
@@ -178,9 +210,8 @@ ENTRY(dtlb_aerror)
178 mov d0,(12,sp) 210 mov d0,(12,sp)
179 211
180 clr d0 212 clr d0
181 mov d0,(DPTEL) 213 mov d0,(DPTEL2)
182 214
183 and ~EPSW_NMID,epsw
184 or EPSW_IE,epsw 215 or EPSW_IE,epsw
185 mov fp,d0 216 mov fp,d0
186 call do_page_fault[],0 # do_page_fault(regs,code,addr 217 call do_page_fault[],0 # do_page_fault(regs,code,addr
diff --git a/arch/mn10300/mm/tlb-smp.c b/arch/mn10300/mm/tlb-smp.c
new file mode 100644
index 000000000000..0b6a5ad1960e
--- /dev/null
+++ b/arch/mn10300/mm/tlb-smp.c
@@ -0,0 +1,214 @@
1/* SMP TLB support routines.
2 *
3 * Copyright (C) 2006-2008 Panasonic Corporation
4 * All Rights Reserved.
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 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15#include <linux/interrupt.h>
16#include <linux/spinlock.h>
17#include <linux/init.h>
18#include <linux/jiffies.h>
19#include <linux/cpumask.h>
20#include <linux/err.h>
21#include <linux/kernel.h>
22#include <linux/delay.h>
23#include <linux/sched.h>
24#include <linux/profile.h>
25#include <linux/smp.h>
26#include <asm/tlbflush.h>
27#include <asm/system.h>
28#include <asm/bitops.h>
29#include <asm/processor.h>
30#include <asm/bug.h>
31#include <asm/exceptions.h>
32#include <asm/hardirq.h>
33#include <asm/fpu.h>
34#include <asm/mmu_context.h>
35#include <asm/thread_info.h>
36#include <asm/cpu-regs.h>
37#include <asm/intctl-regs.h>
38
39/*
40 * For flush TLB
41 */
42#define FLUSH_ALL 0xffffffff
43
44static cpumask_t flush_cpumask;
45static struct mm_struct *flush_mm;
46static unsigned long flush_va;
47static DEFINE_SPINLOCK(tlbstate_lock);
48
49DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) = {
50 &init_mm, 0
51};
52
53static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
54 unsigned long va);
55static void do_flush_tlb_all(void *info);
56
57/**
58 * smp_flush_tlb - Callback to invalidate the TLB.
59 * @unused: Callback context (ignored).
60 */
61void smp_flush_tlb(void *unused)
62{
63 unsigned long cpu_id;
64
65 cpu_id = get_cpu();
66
67 if (!cpu_isset(cpu_id, flush_cpumask))
68 /* This was a BUG() but until someone can quote me the line
69 * from the intel manual that guarantees an IPI to multiple
70 * CPUs is retried _only_ on the erroring CPUs its staying as a
71 * return
72 *
73 * BUG();
74 */
75 goto out;
76
77 if (flush_va == FLUSH_ALL)
78 local_flush_tlb();
79 else
80 local_flush_tlb_page(flush_mm, flush_va);
81
82 smp_mb__before_clear_bit();
83 cpu_clear(cpu_id, flush_cpumask);
84 smp_mb__after_clear_bit();
85out:
86 put_cpu();
87}
88
89/**
90 * flush_tlb_others - Tell the specified CPUs to invalidate their TLBs
91 * @cpumask: The list of CPUs to target.
92 * @mm: The VM context to flush from (if va!=FLUSH_ALL).
93 * @va: Virtual address to flush or FLUSH_ALL to flush everything.
94 */
95static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
96 unsigned long va)
97{
98 cpumask_t tmp;
99
100 /* A couple of sanity checks (to be removed):
101 * - mask must not be empty
102 * - current CPU must not be in mask
103 * - we do not send IPIs to as-yet unbooted CPUs.
104 */
105 BUG_ON(!mm);
106 BUG_ON(cpus_empty(cpumask));
107 BUG_ON(cpu_isset(smp_processor_id(), cpumask));
108
109 cpus_and(tmp, cpumask, cpu_online_map);
110 BUG_ON(!cpus_equal(cpumask, tmp));
111
112 /* I'm not happy about this global shared spinlock in the MM hot path,
113 * but we'll see how contended it is.
114 *
115 * Temporarily this turns IRQs off, so that lockups are detected by the
116 * NMI watchdog.
117 */
118 spin_lock(&tlbstate_lock);
119
120 flush_mm = mm;
121 flush_va = va;
122#if NR_CPUS <= BITS_PER_LONG
123 atomic_set_mask(cpumask.bits[0], &flush_cpumask.bits[0]);
124#else
125#error Not supported.
126#endif
127
128 /* FIXME: if NR_CPUS>=3, change send_IPI_mask */
129 smp_call_function(smp_flush_tlb, NULL, 1);
130
131 while (!cpus_empty(flush_cpumask))
132 /* Lockup detection does not belong here */
133 smp_mb();
134
135 flush_mm = NULL;
136 flush_va = 0;
137 spin_unlock(&tlbstate_lock);
138}
139
140/**
141 * flush_tlb_mm - Invalidate TLB of specified VM context
142 * @mm: The VM context to invalidate.
143 */
144void flush_tlb_mm(struct mm_struct *mm)
145{
146 cpumask_t cpu_mask;
147
148 preempt_disable();
149 cpu_mask = mm->cpu_vm_mask;
150 cpu_clear(smp_processor_id(), cpu_mask);
151
152 local_flush_tlb();
153 if (!cpus_empty(cpu_mask))
154 flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
155
156 preempt_enable();
157}
158
159/**
160 * flush_tlb_current_task - Invalidate TLB of current task
161 */
162void flush_tlb_current_task(void)
163{
164 struct mm_struct *mm = current->mm;
165 cpumask_t cpu_mask;
166
167 preempt_disable();
168 cpu_mask = mm->cpu_vm_mask;
169 cpu_clear(smp_processor_id(), cpu_mask);
170
171 local_flush_tlb();
172 if (!cpus_empty(cpu_mask))
173 flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
174
175 preempt_enable();
176}
177
178/**
179 * flush_tlb_page - Invalidate TLB of page
180 * @vma: The VM context to invalidate the page for.
181 * @va: The virtual address of the page to invalidate.
182 */
183void flush_tlb_page(struct vm_area_struct *vma, unsigned long va)
184{
185 struct mm_struct *mm = vma->vm_mm;
186 cpumask_t cpu_mask;
187
188 preempt_disable();
189 cpu_mask = mm->cpu_vm_mask;
190 cpu_clear(smp_processor_id(), cpu_mask);
191
192 local_flush_tlb_page(mm, va);
193 if (!cpus_empty(cpu_mask))
194 flush_tlb_others(cpu_mask, mm, va);
195
196 preempt_enable();
197}
198
199/**
200 * do_flush_tlb_all - Callback to completely invalidate a TLB
201 * @unused: Callback context (ignored).
202 */
203static void do_flush_tlb_all(void *unused)
204{
205 local_flush_tlb_all();
206}
207
208/**
209 * flush_tlb_all - Completely invalidate TLBs on all CPUs
210 */
211void flush_tlb_all(void)
212{
213 on_each_cpu(do_flush_tlb_all, 0, 1);
214}
diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
index bdc1f9a59b4c..c1528004163c 100644
--- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
+++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
@@ -30,4 +30,13 @@
30 */ 30 */
31#define MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL 4 31#define MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL 4
32 32
33/*
34 * The size of range at which it becomes more economical to just flush the
35 * whole cache rather than trying to flush the specified range.
36 */
37#define MN10300_DCACHE_FLUSH_BORDER \
38 +(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
39#define MN10300_DCACHE_FLUSH_INV_BORDER \
40 +(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
41
33#endif /* _ASM_PROC_CACHE_H */ 42#endif /* _ASM_PROC_CACHE_H */
diff --git a/arch/mn10300/proc-mn103e010/include/proc/clock.h b/arch/mn10300/proc-mn103e010/include/proc/clock.h
index aa23e147d620..704a819f1f4b 100644
--- a/arch/mn10300/proc-mn103e010/include/proc/clock.h
+++ b/arch/mn10300/proc-mn103e010/include/proc/clock.h
@@ -13,6 +13,4 @@
13 13
14#include <unit/clock.h> 14#include <unit/clock.h>
15 15
16#define MN10300_WDCLK MN10300_IOCLK
17
18#endif /* _ASM_PROC_CLOCK_H */ 16#endif /* _ASM_PROC_CLOCK_H */
diff --git a/arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h b/arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h
new file mode 100644
index 000000000000..d72d328d1f9c
--- /dev/null
+++ b/arch/mn10300/proc-mn103e010/include/proc/dmactl-regs.h
@@ -0,0 +1,102 @@
1/* MN103E010 on-board DMA controller registers
2 *
3 * Copyright (C) 2007 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_PROC_DMACTL_REGS_H
13#define _ASM_PROC_DMACTL_REGS_H
14
15#include <asm/cpu-regs.h>
16
17#ifdef __KERNEL__
18
19/* DMA registers */
20#define DMxCTR(N) __SYSREG(0xd2000000 + ((N) * 0x100), u32) /* control reg */
21#define DMxCTR_BG 0x0000001f /* transfer request source */
22#define DMxCTR_BG_SOFT 0x00000000 /* - software source */
23#define DMxCTR_BG_SC0TX 0x00000002 /* - serial port 0 transmission */
24#define DMxCTR_BG_SC0RX 0x00000003 /* - serial port 0 reception */
25#define DMxCTR_BG_SC1TX 0x00000004 /* - serial port 1 transmission */
26#define DMxCTR_BG_SC1RX 0x00000005 /* - serial port 1 reception */
27#define DMxCTR_BG_SC2TX 0x00000006 /* - serial port 2 transmission */
28#define DMxCTR_BG_SC2RX 0x00000007 /* - serial port 2 reception */
29#define DMxCTR_BG_TM0UFLOW 0x00000008 /* - timer 0 underflow */
30#define DMxCTR_BG_TM1UFLOW 0x00000009 /* - timer 1 underflow */
31#define DMxCTR_BG_TM2UFLOW 0x0000000a /* - timer 2 underflow */
32#define DMxCTR_BG_TM3UFLOW 0x0000000b /* - timer 3 underflow */
33#define DMxCTR_BG_TM6ACMPCAP 0x0000000c /* - timer 6A compare/capture */
34#define DMxCTR_BG_AFE 0x0000000d /* - analogue front-end interrupt source */
35#define DMxCTR_BG_ADC 0x0000000e /* - A/D conversion end interrupt source */
36#define DMxCTR_BG_IRDA 0x0000000f /* - IrDA interrupt source */
37#define DMxCTR_BG_RTC 0x00000010 /* - RTC interrupt source */
38#define DMxCTR_BG_XIRQ0 0x00000011 /* - XIRQ0 pin interrupt source */
39#define DMxCTR_BG_XIRQ1 0x00000012 /* - XIRQ1 pin interrupt source */
40#define DMxCTR_BG_XDMR0 0x00000013 /* - external request 0 source (XDMR0 pin) */
41#define DMxCTR_BG_XDMR1 0x00000014 /* - external request 1 source (XDMR1 pin) */
42#define DMxCTR_SAM 0x000000e0 /* DMA transfer src addr mode */
43#define DMxCTR_SAM_INCR 0x00000000 /* - increment */
44#define DMxCTR_SAM_DECR 0x00000020 /* - decrement */
45#define DMxCTR_SAM_FIXED 0x00000040 /* - fixed */
46#define DMxCTR_DAM 0x00000000 /* DMA transfer dest addr mode */
47#define DMxCTR_DAM_INCR 0x00000000 /* - increment */
48#define DMxCTR_DAM_DECR 0x00000100 /* - decrement */
49#define DMxCTR_DAM_FIXED 0x00000200 /* - fixed */
50#define DMxCTR_TM 0x00001800 /* DMA transfer mode */
51#define DMxCTR_TM_BATCH 0x00000000 /* - batch transfer */
52#define DMxCTR_TM_INTERM 0x00001000 /* - intermittent transfer */
53#define DMxCTR_UT 0x00006000 /* DMA transfer unit */
54#define DMxCTR_UT_1 0x00000000 /* - 1 byte */
55#define DMxCTR_UT_2 0x00002000 /* - 2 byte */
56#define DMxCTR_UT_4 0x00004000 /* - 4 byte */
57#define DMxCTR_UT_16 0x00006000 /* - 16 byte */
58#define DMxCTR_TEN 0x00010000 /* DMA channel transfer enable */
59#define DMxCTR_RQM 0x00060000 /* external request input source mode */
60#define DMxCTR_RQM_FALLEDGE 0x00000000 /* - falling edge */
61#define DMxCTR_RQM_RISEEDGE 0x00020000 /* - rising edge */
62#define DMxCTR_RQM_LOLEVEL 0x00040000 /* - low level */
63#define DMxCTR_RQM_HILEVEL 0x00060000 /* - high level */
64#define DMxCTR_RQF 0x01000000 /* DMA transfer request flag */
65#define DMxCTR_XEND 0x80000000 /* DMA transfer end flag */
66
67#define DMxSRC(N) __SYSREG(0xd2000004 + ((N) * 0x100), u32) /* control reg */
68
69#define DMxDST(N) __SYSREG(0xd2000008 + ((N) * 0x100), u32) /* src addr reg */
70
71#define DMxSIZ(N) __SYSREG(0xd200000c + ((N) * 0x100), u32) /* dest addr reg */
72#define DMxSIZ_CT 0x000fffff /* number of bytes to transfer */
73
74#define DMxCYC(N) __SYSREG(0xd2000010 + ((N) * 0x100), u32) /* intermittent
75 * size reg */
76#define DMxCYC_CYC 0x000000ff /* number of interrmittent transfers -1 */
77
78#define DM0IRQ 16 /* DMA channel 0 complete IRQ */
79#define DM1IRQ 17 /* DMA channel 1 complete IRQ */
80#define DM2IRQ 18 /* DMA channel 2 complete IRQ */
81#define DM3IRQ 19 /* DMA channel 3 complete IRQ */
82
83#define DM0ICR GxICR(DM0IRQ) /* DMA channel 0 complete intr ctrl reg */
84#define DM1ICR GxICR(DM0IR1) /* DMA channel 1 complete intr ctrl reg */
85#define DM2ICR GxICR(DM0IR2) /* DMA channel 2 complete intr ctrl reg */
86#define DM3ICR GxICR(DM0IR3) /* DMA channel 3 complete intr ctrl reg */
87
88#ifndef __ASSEMBLY__
89
90struct mn10300_dmactl_regs {
91 u32 ctr;
92 const void *src;
93 void *dst;
94 u32 siz;
95 u32 cyc;
96} __attribute__((aligned(0x100)));
97
98#endif /* __ASSEMBLY__ */
99
100#endif /* __KERNEL__ */
101
102#endif /* _ASM_PROC_DMACTL_REGS_H */
diff --git a/arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h b/arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h
new file mode 100644
index 000000000000..f537801a44ba
--- /dev/null
+++ b/arch/mn10300/proc-mn103e010/include/proc/intctl-regs.h
@@ -0,0 +1,29 @@
1#ifndef _ASM_PROC_INTCTL_REGS_H
2#define _ASM_PROC_INTCTL_REGS_H
3
4#ifndef _ASM_INTCTL_REGS_H
5# error "please don't include this file directly"
6#endif
7
8/* intr acceptance group reg */
9#define IAGR __SYSREG(0xd4000100, u16)
10
11/* group number register */
12#define IAGR_GN 0x00fc
13
14#define __GET_XIRQ_TRIGGER(X, Z) (((Z) >> ((X) * 2)) & 3)
15
16#define __SET_XIRQ_TRIGGER(X, Y, Z) \
17({ \
18 typeof(Z) x = (Z); \
19 x &= ~(3 << ((X) * 2)); \
20 x |= ((Y) & 3) << ((X) * 2); \
21 (Z) = x; \
22})
23
24/* external pin intr spec reg */
25#define EXTMD __SYSREG(0xd4000200, u16)
26#define GET_XIRQ_TRIGGER(X) __GET_XIRQ_TRIGGER(X, EXTMD)
27#define SET_XIRQ_TRIGGER(X, Y) __SET_XIRQ_TRIGGER(X, Y, EXTMD)
28
29#endif /* _ASM_PROC_INTCTL_REGS_H */
diff --git a/arch/mn10300/proc-mn103e010/include/proc/proc.h b/arch/mn10300/proc-mn103e010/include/proc/proc.h
index 22a2b93f70b7..39c4f8e7d2d3 100644
--- a/arch/mn10300/proc-mn103e010/include/proc/proc.h
+++ b/arch/mn10300/proc-mn103e010/include/proc/proc.h
@@ -12,7 +12,7 @@
12#ifndef _ASM_PROC_PROC_H 12#ifndef _ASM_PROC_PROC_H
13#define _ASM_PROC_PROC_H 13#define _ASM_PROC_PROC_H
14 14
15#define PROCESSOR_VENDOR_NAME "Matsushita" 15#define PROCESSOR_VENDOR_NAME "Panasonic"
16#define PROCESSOR_MODEL_NAME "mn103e010" 16#define PROCESSOR_MODEL_NAME "mn103e010"
17 17
18#endif /* _ASM_PROC_PROC_H */ 18#endif /* _ASM_PROC_PROC_H */
diff --git a/arch/mn10300/proc-mn103e010/proc-init.c b/arch/mn10300/proc-mn103e010/proc-init.c
index 9a482efafa82..27b97980dca4 100644
--- a/arch/mn10300/proc-mn103e010/proc-init.c
+++ b/arch/mn10300/proc-mn103e010/proc-init.c
@@ -9,7 +9,9 @@
9 * 2 of the Licence, or (at your option) any later version. 9 * 2 of the Licence, or (at your option) any later version.
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <asm/fpu.h>
12#include <asm/rtc.h> 13#include <asm/rtc.h>
14#include <asm/busctl-regs.h>
13 15
14/* 16/*
15 * initialise the on-silicon processor peripherals 17 * initialise the on-silicon processor peripherals
@@ -28,6 +30,7 @@ asmlinkage void __init processor_init(void)
28 __set_intr_stub(EXCEP_DAERROR, dtlb_aerror); 30 __set_intr_stub(EXCEP_DAERROR, dtlb_aerror);
29 __set_intr_stub(EXCEP_BUSERROR, raw_bus_error); 31 __set_intr_stub(EXCEP_BUSERROR, raw_bus_error);
30 __set_intr_stub(EXCEP_DOUBLE_FAULT, double_fault); 32 __set_intr_stub(EXCEP_DOUBLE_FAULT, double_fault);
33 __set_intr_stub(EXCEP_FPU_DISABLED, fpu_disabled);
31 __set_intr_stub(EXCEP_SYSCALL0, system_call); 34 __set_intr_stub(EXCEP_SYSCALL0, system_call);
32 35
33 __set_intr_stub(EXCEP_NMI, nmi_handler); 36 __set_intr_stub(EXCEP_NMI, nmi_handler);
@@ -73,3 +76,37 @@ asmlinkage void __init processor_init(void)
73 76
74 calibrate_clock(); 77 calibrate_clock();
75} 78}
79
80/*
81 * determine the memory size and base from the memory controller regs
82 */
83void __init get_mem_info(unsigned long *mem_base, unsigned long *mem_size)
84{
85 unsigned long base, size;
86
87 *mem_base = 0;
88 *mem_size = 0;
89
90 base = SDBASE(0);
91 if (base & SDBASE_CE) {
92 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
93 size = ~size + 1;
94 base &= SDBASE_CBA;
95
96 printk(KERN_INFO "SDRAM[0]: %luMb @%08lx\n", size >> 20, base);
97 *mem_size += size;
98 *mem_base = base;
99 }
100
101 base = SDBASE(1);
102 if (base & SDBASE_CE) {
103 size = (base & SDBASE_CBAM) << SDBASE_CBAM_SHIFT;
104 size = ~size + 1;
105 base &= SDBASE_CBA;
106
107 printk(KERN_INFO "SDRAM[1]: %luMb @%08lx\n", size >> 20, base);
108 *mem_size += size;
109 if (*mem_base == 0)
110 *mem_base = base;
111 }
112}
diff --git a/arch/mn10300/proc-mn2ws0050/Makefile b/arch/mn10300/proc-mn2ws0050/Makefile
new file mode 100644
index 000000000000..d4ca13309a85
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-y := proc-init.o
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
new file mode 100644
index 000000000000..cafd7b5b55b4
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
@@ -0,0 +1,48 @@
1/* Cache specification
2 *
3 * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * Modified by Matsushita Electric Industrial Co., Ltd.
7 * Modifications:
8 * 13-Nov-2006 MEI Add L1_CACHE_SHIFT_MAX definition.
9 * 29-Jul-2008 MEI Add define for MN10300_HAS_AREAPURGE_REG.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#ifndef _ASM_PROC_CACHE_H
17#define _ASM_PROC_CACHE_H
18
19/*
20 * L1 cache
21 */
22#define L1_CACHE_NWAYS 4 /* number of ways in caches */
23#define L1_CACHE_NENTRIES 128 /* number of entries in each way */
24#define L1_CACHE_BYTES 32 /* bytes per entry */
25#define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
26#define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
27
28#define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
29#define L1_CACHE_TAG_DIRTY 0x00000008 /* data cache tag dirty bit */
30#define L1_CACHE_TAG_ENTRY 0x00000fe0 /* cache tag entry address mask */
31#define L1_CACHE_TAG_ADDRESS 0xfffff000 /* cache tag line address mask */
32
33/*
34 * specification of the interval between interrupt checking intervals whilst
35 * managing the cache with the interrupts disabled
36 */
37#define MN10300_DCACHE_INV_RANGE_INTR_LOG2_INTERVAL 4
38
39/*
40 * The size of range at which it becomes more economical to just flush the
41 * whole cache rather than trying to flush the specified range.
42 */
43#define MN10300_DCACHE_FLUSH_BORDER \
44 +(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
45#define MN10300_DCACHE_FLUSH_INV_BORDER \
46 +(L1_CACHE_NWAYS * L1_CACHE_NENTRIES * L1_CACHE_BYTES)
47
48#endif /* _ASM_PROC_CACHE_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/clock.h b/arch/mn10300/proc-mn2ws0050/include/proc/clock.h
new file mode 100644
index 000000000000..fe4c0a4a53a2
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/clock.h
@@ -0,0 +1,20 @@
1/* clock.h: proc-specific clocks
2 *
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * Modified by Matsushita Electric Industrial Co., Ltd.
7 * Modifications:
8 * 23-Feb-2007 MEI Delete define for watchdog timer.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#ifndef _ASM_PROC_CLOCK_H
16#define _ASM_PROC_CLOCK_H
17
18#include <unit/clock.h>
19
20#endif /* _ASM_PROC_CLOCK_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h b/arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h
new file mode 100644
index 000000000000..4c4319e241d1
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/dmactl-regs.h
@@ -0,0 +1,103 @@
1/* MN2WS0050 on-board DMA controller registers
2 *
3 * Copyright (C) 2002 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 License
8 * version 2 as published by the Free Software Foundation.
9 */
10
11#ifndef _ASM_PROC_DMACTL_REGS_H
12#define _ASM_PROC_DMACTL_REGS_H
13
14#include <asm/cpu-regs.h>
15
16#ifdef __KERNEL__
17
18/* DMA registers */
19#define DMxCTR(N) __SYSREG(0xd4005000+(N*0x100), u32) /* control reg */
20#define DMxCTR_BG 0x0000001f /* transfer request source */
21#define DMxCTR_BG_SOFT 0x00000000 /* - software source */
22#define DMxCTR_BG_SC0TX 0x00000002 /* - serial port 0 transmission */
23#define DMxCTR_BG_SC0RX 0x00000003 /* - serial port 0 reception */
24#define DMxCTR_BG_SC1TX 0x00000004 /* - serial port 1 transmission */
25#define DMxCTR_BG_SC1RX 0x00000005 /* - serial port 1 reception */
26#define DMxCTR_BG_SC2TX 0x00000006 /* - serial port 2 transmission */
27#define DMxCTR_BG_SC2RX 0x00000007 /* - serial port 2 reception */
28#define DMxCTR_BG_TM0UFLOW 0x00000008 /* - timer 0 underflow */
29#define DMxCTR_BG_TM1UFLOW 0x00000009 /* - timer 1 underflow */
30#define DMxCTR_BG_TM2UFLOW 0x0000000a /* - timer 2 underflow */
31#define DMxCTR_BG_TM3UFLOW 0x0000000b /* - timer 3 underflow */
32#define DMxCTR_BG_TM6ACMPCAP 0x0000000c /* - timer 6A compare/capture */
33#define DMxCTR_BG_RYBY 0x0000000d /* - NAND Flash RY/BY request source */
34#define DMxCTR_BG_RMC 0x0000000e /* - remote controller output */
35#define DMxCTR_BG_XIRQ12 0x00000011 /* - XIRQ12 pin interrupt source */
36#define DMxCTR_BG_XIRQ13 0x00000012 /* - XIRQ13 pin interrupt source */
37#define DMxCTR_BG_TCK 0x00000014 /* - tick timer underflow */
38#define DMxCTR_BG_SC4TX 0x00000019 /* - serial port4 transmission */
39#define DMxCTR_BG_SC4RX 0x0000001a /* - serial port4 reception */
40#define DMxCTR_BG_SC5TX 0x0000001b /* - serial port5 transmission */
41#define DMxCTR_BG_SC5RX 0x0000001c /* - serial port5 reception */
42#define DMxCTR_BG_SC6TX 0x0000001d /* - serial port6 transmission */
43#define DMxCTR_BG_SC6RX 0x0000001e /* - serial port6 reception */
44#define DMxCTR_BG_TMSUFLOW 0x0000001f /* - timestamp timer underflow */
45#define DMxCTR_SAM 0x00000060 /* DMA transfer src addr mode */
46#define DMxCTR_SAM_INCR 0x00000000 /* - increment */
47#define DMxCTR_SAM_DECR 0x00000020 /* - decrement */
48#define DMxCTR_SAM_FIXED 0x00000040 /* - fixed */
49#define DMxCTR_DAM 0x00000300 /* DMA transfer dest addr mode */
50#define DMxCTR_DAM_INCR 0x00000000 /* - increment */
51#define DMxCTR_DAM_DECR 0x00000100 /* - decrement */
52#define DMxCTR_DAM_FIXED 0x00000200 /* - fixed */
53#define DMxCTR_UT 0x00006000 /* DMA transfer unit */
54#define DMxCTR_UT_1 0x00000000 /* - 1 byte */
55#define DMxCTR_UT_2 0x00002000 /* - 2 byte */
56#define DMxCTR_UT_4 0x00004000 /* - 4 byte */
57#define DMxCTR_UT_16 0x00006000 /* - 16 byte */
58#define DMxCTR_RRE 0x00008000 /* DMA round robin enable */
59#define DMxCTR_TEN 0x00010000 /* DMA channel transfer enable */
60#define DMxCTR_RQM 0x00060000 /* external request input source mode */
61#define DMxCTR_RQM_FALLEDGE 0x00000000 /* - falling edge */
62#define DMxCTR_RQM_RISEEDGE 0x00020000 /* - rising edge */
63#define DMxCTR_RQM_LOLEVEL 0x00040000 /* - low level */
64#define DMxCTR_RQM_HILEVEL 0x00060000 /* - high level */
65#define DMxCTR_RQF 0x01000000 /* DMA transfer request flag */
66#define DMxCTR_PERR 0x40000000 /* DMA transfer parameter error flag */
67#define DMxCTR_XEND 0x80000000 /* DMA transfer end flag */
68
69#define DMxSRC(N) __SYSREG(0xd4005004+(N*0x100), u32) /* control reg */
70
71#define DMxDST(N) __SYSREG(0xd4005008+(N*0x100), u32) /* source addr reg */
72
73#define DMxSIZ(N) __SYSREG(0xd400500c+(N*0x100), u32) /* dest addr reg */
74#define DMxSIZ_CT 0x000fffff /* number of bytes to transfer */
75
76#define DMxCYC(N) __SYSREG(0xd4005010+(N*0x100), u32) /* intermittent size reg */
77#define DMxCYC_CYC 0x000000ff /* number of interrmittent transfers -1 */
78
79#define DM0IRQ 16 /* DMA channel 0 complete IRQ */
80#define DM1IRQ 17 /* DMA channel 1 complete IRQ */
81#define DM2IRQ 18 /* DMA channel 2 complete IRQ */
82#define DM3IRQ 19 /* DMA channel 3 complete IRQ */
83
84#define DM0ICR GxICR(DM0IRQ) /* DMA channel 0 complete intr ctrl reg */
85#define DM1ICR GxICR(DM0IR1) /* DMA channel 1 complete intr ctrl reg */
86#define DM2ICR GxICR(DM0IR2) /* DMA channel 2 complete intr ctrl reg */
87#define DM3ICR GxICR(DM0IR3) /* DMA channel 3 complete intr ctrl reg */
88
89#ifndef __ASSEMBLY__
90
91struct mn10300_dmactl_regs {
92 u32 ctr;
93 const void *src;
94 void *dst;
95 u32 siz;
96 u32 cyc;
97} __attribute__((aligned(0x100)));
98
99#endif /* __ASSEMBLY__ */
100
101#endif /* __KERNEL__ */
102
103#endif /* _ASM_PROC_DMACTL_REGS_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h b/arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h
new file mode 100644
index 000000000000..a1e977273d19
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/intctl-regs.h
@@ -0,0 +1,29 @@
1#ifndef _ASM_PROC_INTCTL_REGS_H
2#define _ASM_PROC_INTCTL_REGS_H
3
4#ifndef _ASM_INTCTL_REGS_H
5# error "please don't include this file directly"
6#endif
7
8/* intr acceptance group reg */
9#define IAGR __SYSREG(0xd4000100, u16)
10
11/* group number register */
12#define IAGR_GN 0x003fc
13
14#define __GET_XIRQ_TRIGGER(X, Z) (((Z) >> ((X) * 2)) & 3)
15
16#define __SET_XIRQ_TRIGGER(X, Y, Z) \
17({ \
18 typeof(Z) x = (Z); \
19 x &= ~(3 << ((X) * 2)); \
20 x |= ((Y) & 3) << ((X) * 2); \
21 (Z) = x; \
22})
23
24/* external pin intr spec reg */
25#define EXTMD0 __SYSREG(0xd4000200, u32)
26#define GET_XIRQ_TRIGGER(X) __GET_XIRQ_TRIGGER(X, EXTMD0)
27#define SET_XIRQ_TRIGGER(X, Y) __SET_XIRQ_TRIGGER(X, Y, EXTMD0)
28
29#endif /* _ASM_PROC_INTCTL_REGS_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/irq.h b/arch/mn10300/proc-mn2ws0050/include/proc/irq.h
new file mode 100644
index 000000000000..37777a85ab6f
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/irq.h
@@ -0,0 +1,49 @@
1/* MN2WS0050 on-board interrupt controller registers
2 *
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * Modified by Matsushita Electric Industrial Co., Ltd.
7 * Modifications:
8 * 13-Nov-2006 MEI Define extended IRQ number for SMP support.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#ifndef _PROC_IRQ_H
17#define _PROC_IRQ_H
18
19#ifdef __KERNEL__
20
21#define GxICR_NUM_IRQS 163
22#ifdef CONFIG_SMP
23#define GxICR_NUM_EXT_IRQS 197
24#endif /* CONFIG_SMP */
25
26#define GxICR_NUM_XIRQS 16
27
28#define XIRQ0 34
29#define XIRQ1 35
30#define XIRQ2 36
31#define XIRQ3 37
32#define XIRQ4 38
33#define XIRQ5 39
34#define XIRQ6 40
35#define XIRQ7 41
36#define XIRQ8 42
37#define XIRQ9 43
38#define XIRQ10 44
39#define XIRQ11 45
40#define XIRQ12 46
41#define XIRQ13 47
42#define XIRQ14 48
43#define XIRQ15 49
44
45#define XIRQ2IRQ(num) (XIRQ0 + num)
46
47#endif /* __KERNEL__ */
48
49#endif /* _PROC_IRQ_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h b/arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h
new file mode 100644
index 000000000000..84448f3828b3
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/nand-regs.h
@@ -0,0 +1,120 @@
1/* NAND flash interface register definitions
2 *
3 * Copyright (C) 2008-2009 Panasonic Corporation
4 * All Rights Reserved.
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 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef _PROC_NAND_REGS_H_
17#define _PROC_NAND_REGS_H_
18
19/* command register */
20#define FCOMMAND_0 __SYSREG(0xd8f00000, u8) /* fcommand[24:31] */
21#define FCOMMAND_1 __SYSREG(0xd8f00001, u8) /* fcommand[16:23] */
22#define FCOMMAND_2 __SYSREG(0xd8f00002, u8) /* fcommand[8:15] */
23#define FCOMMAND_3 __SYSREG(0xd8f00003, u8) /* fcommand[0:7] */
24
25/* for dma 16 byte trans, use FCOMMAND2 register */
26#define FCOMMAND2_0 __SYSREG(0xd8f00110, u8) /* fcommand2[24:31] */
27#define FCOMMAND2_1 __SYSREG(0xd8f00111, u8) /* fcommand2[16:23] */
28#define FCOMMAND2_2 __SYSREG(0xd8f00112, u8) /* fcommand2[8:15] */
29#define FCOMMAND2_3 __SYSREG(0xd8f00113, u8) /* fcommand2[0:7] */
30
31#define FCOMMAND_FIEN 0x80 /* nand flash I/F enable */
32#define FCOMMAND_BW_8BIT 0x00 /* 8bit bus width */
33#define FCOMMAND_BW_16BIT 0x40 /* 16bit bus width */
34#define FCOMMAND_BLOCKSZ_SMALL 0x00 /* small block */
35#define FCOMMAND_BLOCKSZ_LARGE 0x20 /* large block */
36#define FCOMMAND_DMASTART 0x10 /* dma start */
37#define FCOMMAND_RYBY 0x08 /* ready/busy flag */
38#define FCOMMAND_RYBYINTMSK 0x04 /* mask ready/busy interrupt */
39#define FCOMMAND_XFWP 0x02 /* write protect enable */
40#define FCOMMAND_XFCE 0x01 /* flash device disable */
41#define FCOMMAND_SEQKILL 0x10 /* stop seq-read */
42#define FCOMMAND_ANUM 0x07 /* address cycle */
43#define FCOMMAND_ANUM_NONE 0x00 /* address cycle none */
44#define FCOMMAND_ANUM_1CYC 0x01 /* address cycle 1cycle */
45#define FCOMMAND_ANUM_2CYC 0x02 /* address cycle 2cycle */
46#define FCOMMAND_ANUM_3CYC 0x03 /* address cycle 3cycle */
47#define FCOMMAND_ANUM_4CYC 0x04 /* address cycle 4cycle */
48#define FCOMMAND_ANUM_5CYC 0x05 /* address cycle 5cycle */
49#define FCOMMAND_FCMD_READ0 0x00 /* read1 command */
50#define FCOMMAND_FCMD_SEQIN 0x80 /* page program 1st command */
51#define FCOMMAND_FCMD_PAGEPROG 0x10 /* page program 2nd command */
52#define FCOMMAND_FCMD_RESET 0xff /* reset command */
53#define FCOMMAND_FCMD_ERASE1 0x60 /* erase 1st command */
54#define FCOMMAND_FCMD_ERASE2 0xd0 /* erase 2nd command */
55#define FCOMMAND_FCMD_STATUS 0x70 /* read status command */
56#define FCOMMAND_FCMD_READID 0x90 /* read id command */
57#define FCOMMAND_FCMD_READOOB 0x50 /* read3 command */
58/* address register */
59#define FADD __SYSREG(0xd8f00004, u32)
60/* address register 2 */
61#define FADD2 __SYSREG(0xd8f00008, u32)
62/* error judgement register */
63#define FJUDGE __SYSREG(0xd8f0000c, u32)
64#define FJUDGE_NOERR 0x0 /* no error */
65#define FJUDGE_1BITERR 0x1 /* 1bit error in data area */
66#define FJUDGE_PARITYERR 0x2 /* parity error */
67#define FJUDGE_UNCORRECTABLE 0x3 /* uncorrectable error */
68#define FJUDGE_ERRJDG_MSK 0x3 /* mask of judgement result */
69/* 1st ECC store register */
70#define FECC11 __SYSREG(0xd8f00010, u32)
71/* 2nd ECC store register */
72#define FECC12 __SYSREG(0xd8f00014, u32)
73/* 3rd ECC store register */
74#define FECC21 __SYSREG(0xd8f00018, u32)
75/* 4th ECC store register */
76#define FECC22 __SYSREG(0xd8f0001c, u32)
77/* 5th ECC store register */
78#define FECC31 __SYSREG(0xd8f00020, u32)
79/* 6th ECC store register */
80#define FECC32 __SYSREG(0xd8f00024, u32)
81/* 7th ECC store register */
82#define FECC41 __SYSREG(0xd8f00028, u32)
83/* 8th ECC store register */
84#define FECC42 __SYSREG(0xd8f0002c, u32)
85/* data register */
86#define FDATA __SYSREG(0xd8f00030, u32)
87/* access pulse register */
88#define FPWS __SYSREG(0xd8f00100, u32)
89#define FPWS_PWS1W_2CLK 0x00000000 /* write pulse width 1clock */
90#define FPWS_PWS1W_3CLK 0x01000000 /* write pulse width 2clock */
91#define FPWS_PWS1W_4CLK 0x02000000 /* write pulse width 4clock */
92#define FPWS_PWS1W_5CLK 0x03000000 /* write pulse width 5clock */
93#define FPWS_PWS1W_6CLK 0x04000000 /* write pulse width 6clock */
94#define FPWS_PWS1W_7CLK 0x05000000 /* write pulse width 7clock */
95#define FPWS_PWS1W_8CLK 0x06000000 /* write pulse width 8clock */
96#define FPWS_PWS1R_3CLK 0x00010000 /* read pulse width 3clock */
97#define FPWS_PWS1R_4CLK 0x00020000 /* read pulse width 4clock */
98#define FPWS_PWS1R_5CLK 0x00030000 /* read pulse width 5clock */
99#define FPWS_PWS1R_6CLK 0x00040000 /* read pulse width 6clock */
100#define FPWS_PWS1R_7CLK 0x00050000 /* read pulse width 7clock */
101#define FPWS_PWS1R_8CLK 0x00060000 /* read pulse width 8clock */
102#define FPWS_PWS2W_2CLK 0x00000100 /* write pulse interval 2clock */
103#define FPWS_PWS2W_3CLK 0x00000200 /* write pulse interval 3clock */
104#define FPWS_PWS2W_4CLK 0x00000300 /* write pulse interval 4clock */
105#define FPWS_PWS2W_5CLK 0x00000400 /* write pulse interval 5clock */
106#define FPWS_PWS2W_6CLK 0x00000500 /* write pulse interval 6clock */
107#define FPWS_PWS2R_2CLK 0x00000001 /* read pulse interval 2clock */
108#define FPWS_PWS2R_3CLK 0x00000002 /* read pulse interval 3clock */
109#define FPWS_PWS2R_4CLK 0x00000003 /* read pulse interval 4clock */
110#define FPWS_PWS2R_5CLK 0x00000004 /* read pulse interval 5clock */
111#define FPWS_PWS2R_6CLK 0x00000005 /* read pulse interval 6clock */
112/* command register 2 */
113#define FCOMMAND2 __SYSREG(0xd8f00110, u32)
114/* transfer frequency register */
115#define FNUM __SYSREG(0xd8f00114, u32)
116#define FSDATA_ADDR 0xd8f00400
117/* active data register */
118#define FSDATA __SYSREG(FSDATA_ADDR, u32)
119
120#endif /* _PROC_NAND_REGS_H_ */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/proc.h b/arch/mn10300/proc-mn2ws0050/include/proc/proc.h
new file mode 100644
index 000000000000..90d5cadd05bd
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/proc.h
@@ -0,0 +1,18 @@
1/* proc.h: MN2WS0050 processor description
2 *
3 * Copyright (C) 2002 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_PROC_PROC_H
13#define _ASM_PROC_PROC_H
14
15#define PROCESSOR_VENDOR_NAME "Panasonic"
16#define PROCESSOR_MODEL_NAME "mn2ws0050"
17
18#endif /* _ASM_PROC_PROC_H */
diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h b/arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h
new file mode 100644
index 000000000000..22f277fbb4de
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/include/proc/smp-regs.h
@@ -0,0 +1,51 @@
1/* MN10300/AM33v2 Microcontroller SMP registers
2 *
3 * Copyright (C) 2006 Matsushita Electric Industrial Co., Ltd.
4 * All Rights Reserved.
5 * Created:
6 * 13-Nov-2006 MEI Add extended cache and atomic operation register
7 * for SMP support.
8 * 23-Feb-2007 MEI Add define for gdbstub SMP.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#ifndef _ASM_PROC_SMP_REGS_H
17#define _ASM_PROC_SMP_REGS_H
18
19#ifdef __KERNEL__
20
21#ifndef __ASSEMBLY__
22#include <linux/types.h>
23#endif
24#include <asm/cpu-regs.h>
25
26/*
27 * Reference to the interrupt controllers of other CPUs
28 */
29#define CROSS_ICR_CPU_SHIFT 16
30
31#define CROSS_GxICR(X, CPU) __SYSREG(0xc4000000 + (X) * 4 + \
32 ((X) >= 64 && (X) < 192) * 0xf00 + ((CPU) << CROSS_ICR_CPU_SHIFT), u16)
33#define CROSS_GxICR_u8(X, CPU) __SYSREG(0xc4000000 + (X) * 4 + \
34 (((X) >= 64) && ((X) < 192)) * 0xf00 + ((CPU) << CROSS_ICR_CPU_SHIFT), u8)
35
36/* CPU ID register */
37#define CPUID __SYSREGC(0xc0000054, u32)
38#define CPUID_MASK 0x00000007 /* CPU ID mask */
39
40/* extended cache control register */
41#define ECHCTR __SYSREG(0xc0000c20, u32)
42#define ECHCTR_IBCM 0x00000001 /* instruction cache broad cast mask */
43#define ECHCTR_DBCM 0x00000002 /* data cache broad cast mask */
44#define ECHCTR_ISPM 0x00000004 /* instruction cache snoop mask */
45#define ECHCTR_DSPM 0x00000008 /* data cache snoop mask */
46
47#define NMIAGR __SYSREG(0xd400013c, u16)
48#define NMIAGR_GN 0x03fc
49
50#endif /* __KERNEL__ */
51#endif /* _ASM_PROC_SMP_REGS_H */
diff --git a/arch/mn10300/proc-mn2ws0050/proc-init.c b/arch/mn10300/proc-mn2ws0050/proc-init.c
new file mode 100644
index 000000000000..c58249b9525a
--- /dev/null
+++ b/arch/mn10300/proc-mn2ws0050/proc-init.c
@@ -0,0 +1,134 @@
1/* MN2WS0050 processor initialisation
2 *
3 * Copyright (C) 2005 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/delay.h>
15#include <linux/interrupt.h>
16
17#include <asm/processor.h>
18#include <asm/system.h>
19#include <asm/uaccess.h>
20#include <asm/io.h>
21#include <asm/atomic.h>
22#include <asm/smp.h>
23#include <asm/pgalloc.h>
24#include <asm/busctl-regs.h>
25#include <unit/timex.h>
26#include <asm/fpu.h>
27#include <asm/rtc.h>
28
29#define MEMCONF __SYSREGC(0xdf800400, u32)
30
31/*
32 * initialise the on-silicon processor peripherals
33 */
34asmlinkage void __init processor_init(void)
35{
36 int loop;
37
38 /* set up the exception table first */
39 for (loop = 0x000; loop < 0x400; loop += 8)
40 __set_intr_stub(loop, __common_exception);
41
42 __set_intr_stub(EXCEP_ITLBMISS, itlb_miss);
43 __set_intr_stub(EXCEP_DTLBMISS, dtlb_miss);
44 __set_intr_stub(EXCEP_IAERROR, itlb_aerror);
45 __set_intr_stub(EXCEP_DAERROR, dtlb_aerror);
46 __set_intr_stub(EXCEP_BUSERROR, raw_bus_error);
47 __set_intr_stub(EXCEP_DOUBLE_FAULT, double_fault);
48 __set_intr_stub(EXCEP_FPU_DISABLED, fpu_disabled);
49 __set_intr_stub(EXCEP_SYSCALL0, system_call);
50
51 __set_intr_stub(EXCEP_NMI, nmi_handler);
52 __set_intr_stub(EXCEP_WDT, nmi_handler);
53 __set_intr_stub(EXCEP_IRQ_LEVEL0, irq_handler);
54 __set_intr_stub(EXCEP_IRQ_LEVEL1, irq_handler);
55 __set_intr_stub(EXCEP_IRQ_LEVEL2, irq_handler);
56 __set_intr_stub(EXCEP_IRQ_LEVEL3, irq_handler);
57 __set_intr_stub(EXCEP_IRQ_LEVEL4, irq_handler);
58 __set_intr_stub(EXCEP_IRQ_LEVEL5, irq_handler);
59 __set_intr_stub(EXCEP_IRQ_LEVEL6, irq_handler);
60
61 IVAR0 = EXCEP_IRQ_LEVEL0;
62 IVAR1 = EXCEP_IRQ_LEVEL1;
63 IVAR2 = EXCEP_IRQ_LEVEL2;
64 IVAR3 = EXCEP_IRQ_LEVEL3;
65 IVAR4 = EXCEP_IRQ_LEVEL4;
66 IVAR5 = EXCEP_IRQ_LEVEL5;
67 IVAR6 = EXCEP_IRQ_LEVEL6;
68
69#ifndef CONFIG_MN10300_HAS_CACHE_SNOOP
70 mn10300_dcache_flush_inv();
71 mn10300_icache_inv();
72#endif
73
74 /* disable all interrupts and set to priority 6 (lowest) */
75#ifdef CONFIG_SMP
76 for (loop = 0; loop < GxICR_NUM_IRQS; loop++)
77 GxICR(loop) = GxICR_LEVEL_6 | GxICR_DETECT;
78#else /* !CONFIG_SMP */
79 for (loop = 0; loop < NR_IRQS; loop++)
80 GxICR(loop) = GxICR_LEVEL_6 | GxICR_DETECT;
81#endif /* !CONFIG_SMP */
82
83 /* clear the timers */
84 TM0MD = 0;
85 TM1MD = 0;
86 TM2MD = 0;
87 TM3MD = 0;
88 TM4MD = 0;
89 TM5MD = 0;
90 TM6MD = 0;
91 TM6MDA = 0;
92 TM6MDB = 0;
93 TM7MD = 0;
94 TM8MD = 0;
95 TM9MD = 0;
96 TM10MD = 0;
97 TM11MD = 0;
98 TM12MD = 0;
99 TM13MD = 0;
100 TM14MD = 0;
101 TM15MD = 0;
102
103 calibrate_clock();
104}
105
106/*
107 * determine the memory size and base from the memory controller regs
108 */
109void __init get_mem_info(unsigned long *mem_base, unsigned long *mem_size)
110{
111 unsigned long memconf = MEMCONF;
112 unsigned long size = 0; /* order: MByte */
113
114 *mem_base = 0x90000000; /* fixed address */
115
116 switch (memconf & 0x00000003) {
117 case 0x01:
118 size = 256 / 8; /* 256 Mbit per chip */
119 break;
120 case 0x02:
121 size = 512 / 8; /* 512 Mbit per chip */
122 break;
123 case 0x03:
124 size = 1024 / 8; /* 1 Gbit per chip */
125 break;
126 default:
127 panic("Invalid SDRAM size");
128 break;
129 }
130
131 printk(KERN_INFO "DDR2-SDRAM: %luMB x 2 @%08lx\n", size, *mem_base);
132
133 *mem_size = (size * 2) << 20;
134}
diff --git a/arch/mn10300/unit-asb2303/include/unit/clock.h b/arch/mn10300/unit-asb2303/include/unit/clock.h
index 2a0bf79ab968..0316907a012e 100644
--- a/arch/mn10300/unit-asb2303/include/unit/clock.h
+++ b/arch/mn10300/unit-asb2303/include/unit/clock.h
@@ -14,32 +14,11 @@
14 14
15#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
16 16
17#ifdef CONFIG_MN10300_RTC
18
19extern unsigned long mn10300_ioclk; /* IOCLK (crystal speed) in HZ */
20extern unsigned long mn10300_iobclk;
21extern unsigned long mn10300_tsc_per_HZ;
22
23#define MN10300_IOCLK mn10300_ioclk
24/* If this processors has a another clock, uncomment the below. */
25/* #define MN10300_IOBCLK mn10300_iobclk */
26
27#else /* !CONFIG_MN10300_RTC */
28
29#define MN10300_IOCLK 33333333UL 17#define MN10300_IOCLK 33333333UL
30/* #define MN10300_IOBCLK 66666666UL */ 18/* #define MN10300_IOBCLK 66666666UL */
31 19
32#endif /* !CONFIG_MN10300_RTC */
33
34#define MN10300_JCCLK MN10300_IOCLK
35#define MN10300_TSCCLK MN10300_IOCLK
36
37#ifdef CONFIG_MN10300_RTC
38#define MN10300_TSC_PER_HZ mn10300_tsc_per_HZ
39#else /* !CONFIG_MN10300_RTC */
40#define MN10300_TSC_PER_HZ (MN10300_TSCCLK/HZ)
41#endif /* !CONFIG_MN10300_RTC */
42
43#endif /* !__ASSEMBLY__ */ 20#endif /* !__ASSEMBLY__ */
44 21
22#define MN10300_WDCLK MN10300_IOCLK
23
45#endif /* _ASM_UNIT_CLOCK_H */ 24#endif /* _ASM_UNIT_CLOCK_H */
diff --git a/arch/mn10300/unit-asb2303/include/unit/serial.h b/arch/mn10300/unit-asb2303/include/unit/serial.h
index 047566cd2e36..991e356bac5f 100644
--- a/arch/mn10300/unit-asb2303/include/unit/serial.h
+++ b/arch/mn10300/unit-asb2303/include/unit/serial.h
@@ -22,6 +22,11 @@
22#define SERIAL_IRQ XIRQ0 /* Dual serial (PC16552) (Hi) */ 22#define SERIAL_IRQ XIRQ0 /* Dual serial (PC16552) (Hi) */
23 23
24/* 24/*
25 * The ASB2303 has an 18.432 MHz clock the UART
26 */
27#define BASE_BAUD (18432000 / 16)
28
29/*
25 * dispose of the /dev/ttyS0 and /dev/ttyS1 serial ports 30 * dispose of the /dev/ttyS0 and /dev/ttyS1 serial ports
26 */ 31 */
27#ifndef CONFIG_GDBSTUB_ON_TTYSx 32#ifndef CONFIG_GDBSTUB_ON_TTYSx
diff --git a/arch/mn10300/unit-asb2303/include/unit/timex.h b/arch/mn10300/unit-asb2303/include/unit/timex.h
index f206b63c95b4..cc18fe7d8b90 100644
--- a/arch/mn10300/unit-asb2303/include/unit/timex.h
+++ b/arch/mn10300/unit-asb2303/include/unit/timex.h
@@ -1,6 +1,6 @@
1/* ASB2303-specific timer specifcations 1/* ASB2303-specific timer specifications
2 * 2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2007, 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -17,67 +17,72 @@
17 17
18#include <asm/timer-regs.h> 18#include <asm/timer-regs.h>
19#include <unit/clock.h> 19#include <unit/clock.h>
20#include <asm/param.h>
20 21
21/* 22/*
22 * jiffies counter specifications 23 * jiffies counter specifications
23 */ 24 */
24 25
25#define TMJCBR_MAX 0xffff 26#define TMJCBR_MAX 0xffff
26#define TMJCBC TM01BC
27
28#define TMJCMD TM01MD
29#define TMJCBR TM01BR
30#define TMJCIRQ TM1IRQ 27#define TMJCIRQ TM1IRQ
31#define TMJCICR TM1ICR 28#define TMJCICR TM1ICR
32#define TMJCICR_LEVEL GxICR_LEVEL_5
33 29
34#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
35 31
36static inline void startup_jiffies_counter(void) 32#define MN10300_SRC_IOCLK MN10300_IOCLK
33
34#ifndef HZ
35# error HZ undeclared.
36#endif /* !HZ */
37/* use as little prescaling as possible to avoid losing accuracy */
38#if (MN10300_SRC_IOCLK + HZ / 2) / HZ - 1 <= TMJCBR_MAX
39# define IOCLK_PRESCALE 1
40# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK
41# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK
42#elif (MN10300_SRC_IOCLK / 8 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
43# define IOCLK_PRESCALE 8
44# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_8
45# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_8
46#elif (MN10300_SRC_IOCLK / 32 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
47# define IOCLK_PRESCALE 32
48# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_32
49# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_32
50#else
51# error You lose.
52#endif
53
54#define MN10300_JCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
55#define MN10300_TSCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
56
57#define MN10300_JC_PER_HZ ((MN10300_JCCLK + HZ / 2) / HZ)
58#define MN10300_TSC_PER_HZ ((MN10300_TSCCLK + HZ / 2) / HZ)
59
60static inline void stop_jiffies_counter(void)
37{ 61{
38 unsigned rate; 62 u16 tmp;
39 u16 md, t16; 63 TM01MD = JC_TIMER_CLKSRC | TM1MD_SRC_TM0CASCADE << 8;
40 64 tmp = TM01MD;
41 /* use as little prescaling as possible to avoid losing accuracy */ 65}
42 md = TM0MD_SRC_IOCLK;
43 rate = MN10300_JCCLK / HZ;
44
45 if (rate > TMJCBR_MAX) {
46 md = TM0MD_SRC_IOCLK_8;
47 rate = MN10300_JCCLK / 8 / HZ;
48
49 if (rate > TMJCBR_MAX) {
50 md = TM0MD_SRC_IOCLK_32;
51 rate = MN10300_JCCLK / 32 / HZ;
52
53 if (rate > TMJCBR_MAX)
54 BUG();
55 }
56 }
57 66
58 TMJCBR = rate - 1; 67static inline void reload_jiffies_counter(u32 cnt)
59 t16 = TMJCBR; 68{
69 u32 tmp;
60 70
61 TMJCMD = 71 TM01BR = cnt;
62 md | 72 tmp = TM01BR;
63 TM1MD_SRC_TM0CASCADE << 8 |
64 TM0MD_INIT_COUNTER |
65 TM1MD_INIT_COUNTER << 8;
66 73
67 TMJCMD = 74 TM01MD = JC_TIMER_CLKSRC | \
68 md | 75 TM1MD_SRC_TM0CASCADE << 8 | \
69 TM1MD_SRC_TM0CASCADE << 8 | 76 TM0MD_INIT_COUNTER | \
70 TM0MD_COUNT_ENABLE | 77 TM1MD_INIT_COUNTER << 8;
71 TM1MD_COUNT_ENABLE << 8;
72 78
73 t16 = TMJCMD;
74 79
75 TMJCICR |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST; 80 TM01MD = JC_TIMER_CLKSRC | \
76 t16 = TMJCICR; 81 TM1MD_SRC_TM0CASCADE << 8 | \
77} 82 TM0MD_COUNT_ENABLE | \
83 TM1MD_COUNT_ENABLE << 8;
78 84
79static inline void shutdown_jiffies_counter(void) 85 tmp = TM01MD;
80{
81} 86}
82 87
83#endif /* !__ASSEMBLY__ */ 88#endif /* !__ASSEMBLY__ */
@@ -94,29 +99,39 @@ static inline void shutdown_jiffies_counter(void)
94 99
95static inline void startup_timestamp_counter(void) 100static inline void startup_timestamp_counter(void)
96{ 101{
102 u32 t32;
103
97 /* set up timer 4 & 5 cascaded as a 32-bit counter to count real time 104 /* set up timer 4 & 5 cascaded as a 32-bit counter to count real time
98 * - count down from 4Gig-1 to 0 and wrap at IOCLK rate 105 * - count down from 4Gig-1 to 0 and wrap at IOCLK rate
99 */ 106 */
100 TM45BR = TMTSCBR_MAX; 107 TM45BR = TMTSCBR_MAX;
108 t32 = TM45BR;
101 109
102 TM4MD = TM4MD_SRC_IOCLK; 110 TM4MD = TSC_TIMER_CLKSRC;
103 TM4MD |= TM4MD_INIT_COUNTER; 111 TM4MD |= TM4MD_INIT_COUNTER;
104 TM4MD &= ~TM4MD_INIT_COUNTER; 112 TM4MD &= ~TM4MD_INIT_COUNTER;
105 TM4ICR = 0; 113 TM4ICR = 0;
114 t32 = TM4ICR;
106 115
107 TM5MD = TM5MD_SRC_TM4CASCADE; 116 TM5MD = TM5MD_SRC_TM4CASCADE;
108 TM5MD |= TM5MD_INIT_COUNTER; 117 TM5MD |= TM5MD_INIT_COUNTER;
109 TM5MD &= ~TM5MD_INIT_COUNTER; 118 TM5MD &= ~TM5MD_INIT_COUNTER;
110 TM5ICR = 0; 119 TM5ICR = 0;
120 t32 = TM5ICR;
111 121
112 TM5MD |= TM5MD_COUNT_ENABLE; 122 TM5MD |= TM5MD_COUNT_ENABLE;
113 TM4MD |= TM4MD_COUNT_ENABLE; 123 TM4MD |= TM4MD_COUNT_ENABLE;
124 t32 = TM5MD;
125 t32 = TM4MD;
114} 126}
115 127
116static inline void shutdown_timestamp_counter(void) 128static inline void shutdown_timestamp_counter(void)
117{ 129{
130 u8 t8;
118 TM4MD = 0; 131 TM4MD = 0;
119 TM5MD = 0; 132 TM5MD = 0;
133 t8 = TM4MD;
134 t8 = TM5MD;
120} 135}
121 136
122/* 137/*
@@ -127,7 +142,7 @@ typedef unsigned long cycles_t;
127 142
128static inline cycles_t read_timestamp_counter(void) 143static inline cycles_t read_timestamp_counter(void)
129{ 144{
130 return (cycles_t)TMTSCBC; 145 return (cycles_t)~TMTSCBC;
131} 146}
132 147
133#endif /* !__ASSEMBLY__ */ 148#endif /* !__ASSEMBLY__ */
diff --git a/arch/mn10300/unit-asb2303/unit-init.c b/arch/mn10300/unit-asb2303/unit-init.c
index 70e8cb4ea266..834a76aa551a 100644
--- a/arch/mn10300/unit-asb2303/unit-init.c
+++ b/arch/mn10300/unit-asb2303/unit-init.c
@@ -31,6 +31,14 @@ asmlinkage void __init unit_init(void)
31 SET_XIRQ_TRIGGER(3, XIRQ_TRIGGER_HILEVEL); 31 SET_XIRQ_TRIGGER(3, XIRQ_TRIGGER_HILEVEL);
32 SET_XIRQ_TRIGGER(4, XIRQ_TRIGGER_LOWLEVEL); 32 SET_XIRQ_TRIGGER(4, XIRQ_TRIGGER_LOWLEVEL);
33 SET_XIRQ_TRIGGER(5, XIRQ_TRIGGER_LOWLEVEL); 33 SET_XIRQ_TRIGGER(5, XIRQ_TRIGGER_LOWLEVEL);
34
35#ifdef CONFIG_EXT_SERIAL_IRQ_LEVEL
36 set_intr_level(XIRQ0, NUM2GxICR_LEVEL(CONFIG_EXT_SERIAL_IRQ_LEVEL));
37#endif
38
39#ifdef CONFIG_ETHERNET_IRQ_LEVEL
40 set_intr_level(XIRQ3, NUM2GxICR_LEVEL(CONFIG_ETHERNET_IRQ_LEVEL));
41#endif
34} 42}
35 43
36/* 44/*
@@ -51,7 +59,7 @@ void __init unit_init_IRQ(void)
51 switch (GET_XIRQ_TRIGGER(extnum)) { 59 switch (GET_XIRQ_TRIGGER(extnum)) {
52 case XIRQ_TRIGGER_HILEVEL: 60 case XIRQ_TRIGGER_HILEVEL:
53 case XIRQ_TRIGGER_LOWLEVEL: 61 case XIRQ_TRIGGER_LOWLEVEL:
54 set_intr_postackable(XIRQ2IRQ(extnum)); 62 mn10300_set_lateack_irq_type(XIRQ2IRQ(extnum));
55 break; 63 break;
56 default: 64 default:
57 break; 65 break;
diff --git a/arch/mn10300/unit-asb2305/include/unit/clock.h b/arch/mn10300/unit-asb2305/include/unit/clock.h
index 67be3f2eb18e..29e3425431cf 100644
--- a/arch/mn10300/unit-asb2305/include/unit/clock.h
+++ b/arch/mn10300/unit-asb2305/include/unit/clock.h
@@ -14,32 +14,11 @@
14 14
15#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
16 16
17#ifdef CONFIG_MN10300_RTC
18
19extern unsigned long mn10300_ioclk; /* IOCLK (crystal speed) in HZ */
20extern unsigned long mn10300_iobclk;
21extern unsigned long mn10300_tsc_per_HZ;
22
23#define MN10300_IOCLK mn10300_ioclk
24/* If this processors has a another clock, uncomment the below. */
25/* #define MN10300_IOBCLK mn10300_iobclk */
26
27#else /* !CONFIG_MN10300_RTC */
28
29#define MN10300_IOCLK 33333333UL 17#define MN10300_IOCLK 33333333UL
30/* #define MN10300_IOBCLK 66666666UL */ 18/* #define MN10300_IOBCLK 66666666UL */
31 19
32#endif /* !CONFIG_MN10300_RTC */
33
34#define MN10300_JCCLK MN10300_IOCLK
35#define MN10300_TSCCLK MN10300_IOCLK
36
37#ifdef CONFIG_MN10300_RTC
38#define MN10300_TSC_PER_HZ mn10300_tsc_per_HZ
39#else /* !CONFIG_MN10300_RTC */
40#define MN10300_TSC_PER_HZ (MN10300_TSCCLK/HZ)
41#endif /* !CONFIG_MN10300_RTC */
42
43#endif /* !__ASSEMBLY__ */ 20#endif /* !__ASSEMBLY__ */
44 21
22#define MN10300_WDCLK MN10300_IOCLK
23
45#endif /* _ASM_UNIT_CLOCK_H */ 24#endif /* _ASM_UNIT_CLOCK_H */
diff --git a/arch/mn10300/unit-asb2305/include/unit/serial.h b/arch/mn10300/unit-asb2305/include/unit/serial.h
index 8086cc092cec..88c08219315f 100644
--- a/arch/mn10300/unit-asb2305/include/unit/serial.h
+++ b/arch/mn10300/unit-asb2305/include/unit/serial.h
@@ -21,6 +21,11 @@
21#define SERIAL_IRQ XIRQ0 /* Dual serial (PC16552) (Hi) */ 21#define SERIAL_IRQ XIRQ0 /* Dual serial (PC16552) (Hi) */
22 22
23/* 23/*
24 * The ASB2305 has an 18.432 MHz clock the UART
25 */
26#define BASE_BAUD (18432000 / 16)
27
28/*
24 * dispose of the /dev/ttyS0 serial port 29 * dispose of the /dev/ttyS0 serial port
25 */ 30 */
26#ifndef CONFIG_GDBSTUB_ON_TTYSx 31#ifndef CONFIG_GDBSTUB_ON_TTYSx
diff --git a/arch/mn10300/unit-asb2305/include/unit/timex.h b/arch/mn10300/unit-asb2305/include/unit/timex.h
index d1c72d59fa9f..758af30d1a16 100644
--- a/arch/mn10300/unit-asb2305/include/unit/timex.h
+++ b/arch/mn10300/unit-asb2305/include/unit/timex.h
@@ -1,6 +1,6 @@
1/* ASB2305 timer specifcations 1/* ASB2305-specific timer specifications
2 * 2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 3 * Copyright (C) 2007, 2010 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com) 4 * Written by David Howells (dhowells@redhat.com)
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
@@ -17,67 +17,72 @@
17 17
18#include <asm/timer-regs.h> 18#include <asm/timer-regs.h>
19#include <unit/clock.h> 19#include <unit/clock.h>
20#include <asm/param.h>
20 21
21/* 22/*
22 * jiffies counter specifications 23 * jiffies counter specifications
23 */ 24 */
24 25
25#define TMJCBR_MAX 0xffff 26#define TMJCBR_MAX 0xffff
26#define TMJCBC TM01BC
27
28#define TMJCMD TM01MD
29#define TMJCBR TM01BR
30#define TMJCIRQ TM1IRQ 27#define TMJCIRQ TM1IRQ
31#define TMJCICR TM1ICR 28#define TMJCICR TM1ICR
32#define TMJCICR_LEVEL GxICR_LEVEL_5
33 29
34#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
35 31
36static inline void startup_jiffies_counter(void) 32#define MN10300_SRC_IOCLK MN10300_IOCLK
33
34#ifndef HZ
35# error HZ undeclared.
36#endif /* !HZ */
37/* use as little prescaling as possible to avoid losing accuracy */
38#if (MN10300_SRC_IOCLK + HZ / 2) / HZ - 1 <= TMJCBR_MAX
39# define IOCLK_PRESCALE 1
40# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK
41# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK
42#elif (MN10300_SRC_IOCLK / 8 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
43# define IOCLK_PRESCALE 8
44# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_8
45# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_8
46#elif (MN10300_SRC_IOCLK / 32 + HZ / 2) / HZ - 1 <= TMJCBR_MAX
47# define IOCLK_PRESCALE 32
48# define JC_TIMER_CLKSRC TM0MD_SRC_IOCLK_32
49# define TSC_TIMER_CLKSRC TM4MD_SRC_IOCLK_32
50#else
51# error You lose.
52#endif
53
54#define MN10300_JCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
55#define MN10300_TSCCLK (MN10300_SRC_IOCLK / IOCLK_PRESCALE)
56
57#define MN10300_JC_PER_HZ ((MN10300_JCCLK + HZ / 2) / HZ)
58#define MN10300_TSC_PER_HZ ((MN10300_TSCCLK + HZ / 2) / HZ)
59
60static inline void stop_jiffies_counter(void)
37{ 61{
38 unsigned rate; 62 u16 tmp;
39 u16 md, t16; 63 TM01MD = JC_TIMER_CLKSRC | TM1MD_SRC_TM0CASCADE << 8;
40 64 tmp = TM01MD;
41 /* use as little prescaling as possible to avoid losing accuracy */ 65}
42 md = TM0MD_SRC_IOCLK;
43 rate = MN10300_JCCLK / HZ;
44
45 if (rate > TMJCBR_MAX) {
46 md = TM0MD_SRC_IOCLK_8;
47 rate = MN10300_JCCLK / 8 / HZ;
48
49 if (rate > TMJCBR_MAX) {
50 md = TM0MD_SRC_IOCLK_32;
51 rate = MN10300_JCCLK / 32 / HZ;
52
53 if (rate > TMJCBR_MAX)
54 BUG();
55 }
56 }
57 66
58 TMJCBR = rate - 1; 67static inline void reload_jiffies_counter(u32 cnt)
59 t16 = TMJCBR; 68{
69 u32 tmp;
60 70
61 TMJCMD = 71 TM01BR = cnt;
62 md | 72 tmp = TM01BR;
63 TM1MD_SRC_TM0CASCADE << 8 |
64 TM0MD_INIT_COUNTER |
65 TM1MD_INIT_COUNTER << 8;
66 73
67 TMJCMD = 74 TM01MD = JC_TIMER_CLKSRC | \
68 md | 75 TM1MD_SRC_TM0CASCADE << 8 | \
69 TM1MD_SRC_TM0CASCADE << 8 | 76 TM0MD_INIT_COUNTER | \
70 TM0MD_COUNT_ENABLE | 77 TM1MD_INIT_COUNTER << 8;
71 TM1MD_COUNT_ENABLE << 8;
72 78
73 t16 = TMJCMD;
74 79
75 TMJCICR |= GxICR_ENABLE | GxICR_DETECT | GxICR_REQUEST; 80 TM01MD = JC_TIMER_CLKSRC | \
76 t16 = TMJCICR; 81 TM1MD_SRC_TM0CASCADE << 8 | \
77} 82 TM0MD_COUNT_ENABLE | \
83 TM1MD_COUNT_ENABLE << 8;
78 84
79static inline void shutdown_jiffies_counter(void) 85 tmp = TM01MD;
80{
81} 86}
82 87
83#endif /* !__ASSEMBLY__ */ 88#endif /* !__ASSEMBLY__ */
@@ -94,29 +99,39 @@ static inline void shutdown_jiffies_counter(void)
94 99
95static inline void startup_timestamp_counter(void) 100static inline void startup_timestamp_counter(void)
96{ 101{
102 u32 t32;
103
97 /* set up timer 4 & 5 cascaded as a 32-bit counter to count real time 104 /* set up timer 4 & 5 cascaded as a 32-bit counter to count real time
98 * - count down from 4Gig-1 to 0 and wrap at IOCLK rate 105 * - count down from 4Gig-1 to 0 and wrap at IOCLK rate
99 */ 106 */
100 TM45BR = TMTSCBR_MAX; 107 TM45BR = TMTSCBR_MAX;
108 t32 = TM45BR;
101 109
102 TM4MD = TM4MD_SRC_IOCLK; 110 TM4MD = TSC_TIMER_CLKSRC;
103 TM4MD |= TM4MD_INIT_COUNTER; 111 TM4MD |= TM4MD_INIT_COUNTER;
104 TM4MD &= ~TM4MD_INIT_COUNTER; 112 TM4MD &= ~TM4MD_INIT_COUNTER;
105 TM4ICR = 0; 113 TM4ICR = 0;
114 t32 = TM4ICR;
106 115
107 TM5MD = TM5MD_SRC_TM4CASCADE; 116 TM5MD = TM5MD_SRC_TM4CASCADE;
108 TM5MD |= TM5MD_INIT_COUNTER; 117 TM5MD |= TM5MD_INIT_COUNTER;
109 TM5MD &= ~TM5MD_INIT_COUNTER; 118 TM5MD &= ~TM5MD_INIT_COUNTER;
110 TM5ICR = 0; 119 TM5ICR = 0;
120 t32 = TM5ICR;
111 121
112 TM5MD |= TM5MD_COUNT_ENABLE; 122 TM5MD |= TM5MD_COUNT_ENABLE;
113 TM4MD |= TM4MD_COUNT_ENABLE; 123 TM4MD |= TM4MD_COUNT_ENABLE;
124 t32 = TM5MD;
125 t32 = TM4MD;
114} 126}
115 127
116static inline void shutdown_timestamp_counter(void) 128static inline void shutdown_timestamp_counter(void)
117{ 129{
130 u8 t8;
118 TM4MD = 0; 131 TM4MD = 0;
119 TM5MD = 0; 132 TM5MD = 0;
133 t8 = TM4MD;
134 t8 = TM5MD;
120} 135}
121 136
122/* 137/*
@@ -127,7 +142,7 @@ typedef unsigned long cycles_t;
127 142
128static inline cycles_t read_timestamp_counter(void) 143static inline cycles_t read_timestamp_counter(void)
129{ 144{
130 return (cycles_t) TMTSCBC; 145 return (cycles_t)~TMTSCBC;
131} 146}
132 147
133#endif /* !__ASSEMBLY__ */ 148#endif /* !__ASSEMBLY__ */
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index 45b40ac6c464..8e6763e6f250 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -93,7 +93,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
93 struct pci_bus *bus; 93 struct pci_bus *bus;
94 struct pci_dev *dev; 94 struct pci_dev *dev;
95 int idx; 95 int idx;
96 struct resource *r, *pr; 96 struct resource *r;
97 97
98 /* Depth-First Search on bus tree */ 98 /* Depth-First Search on bus tree */
99 list_for_each_entry(bus, bus_list, node) { 99 list_for_each_entry(bus, bus_list, node) {
@@ -105,10 +105,8 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
105 r = &dev->resource[idx]; 105 r = &dev->resource[idx];
106 if (!r->flags) 106 if (!r->flags)
107 continue; 107 continue;
108 pr = pci_find_parent_resource(dev, r);
109 if (!r->start || 108 if (!r->start ||
110 !pr || 109 pci_claim_resource(dev, idx) < 0) {
111 request_resource(pr, r) < 0) {
112 printk(KERN_ERR "PCI:" 110 printk(KERN_ERR "PCI:"
113 " Cannot allocate resource" 111 " Cannot allocate resource"
114 " region %d of bridge %s\n", 112 " region %d of bridge %s\n",
@@ -131,7 +129,7 @@ static void __init pcibios_allocate_resources(int pass)
131 struct pci_dev *dev = NULL; 129 struct pci_dev *dev = NULL;
132 int idx, disabled; 130 int idx, disabled;
133 u16 command; 131 u16 command;
134 struct resource *r, *pr; 132 struct resource *r;
135 133
136 for_each_pci_dev(dev) { 134 for_each_pci_dev(dev) {
137 pci_read_config_word(dev, PCI_COMMAND, &command); 135 pci_read_config_word(dev, PCI_COMMAND, &command);
@@ -150,8 +148,7 @@ static void __init pcibios_allocate_resources(int pass)
150 " (f=%lx, d=%d, p=%d)\n", 148 " (f=%lx, d=%d, p=%d)\n",
151 pci_name(dev), r->start, r->end, r->flags, 149 pci_name(dev), r->start, r->end, r->flags,
152 disabled, pass); 150 disabled, pass);
153 pr = pci_find_parent_resource(dev, r); 151 if (pci_claim_resource(dev, idx) < 0) {
154 if (!pr || request_resource(pr, r) < 0) {
155 printk(KERN_ERR "PCI:" 152 printk(KERN_ERR "PCI:"
156 " Cannot allocate resource" 153 " Cannot allocate resource"
157 " region %d of device %s\n", 154 " region %d of device %s\n",
@@ -184,7 +181,7 @@ static void __init pcibios_allocate_resources(int pass)
184static int __init pcibios_assign_resources(void) 181static int __init pcibios_assign_resources(void)
185{ 182{
186 struct pci_dev *dev = NULL; 183 struct pci_dev *dev = NULL;
187 struct resource *r, *pr; 184 struct resource *r;
188 185
189 if (!(pci_probe & PCI_ASSIGN_ROMS)) { 186 if (!(pci_probe & PCI_ASSIGN_ROMS)) {
190 /* Try to use BIOS settings for ROMs, otherwise let 187 /* Try to use BIOS settings for ROMs, otherwise let
@@ -194,8 +191,7 @@ static int __init pcibios_assign_resources(void)
194 r = &dev->resource[PCI_ROM_RESOURCE]; 191 r = &dev->resource[PCI_ROM_RESOURCE];
195 if (!r->flags || !r->start) 192 if (!r->flags || !r->start)
196 continue; 193 continue;
197 pr = pci_find_parent_resource(dev, r); 194 if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
198 if (!pr || request_resource(pr, r) < 0) {
199 r->end -= r->start; 195 r->end -= r->start;
200 r->start = 0; 196 r->start = 0;
201 } 197 }
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 6d8720a0a599..a4954fe82094 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -503,7 +503,7 @@ asmlinkage void __init unit_pci_init(void)
503 struct pci_ops *o = &pci_direct_ampci; 503 struct pci_ops *o = &pci_direct_ampci;
504 u32 x; 504 u32 x;
505 505
506 set_intr_level(XIRQ1, GxICR_LEVEL_3); 506 set_intr_level(XIRQ1, NUM2GxICR_LEVEL(CONFIG_PCI_IRQ_LEVEL));
507 507
508 memset(&bus, 0, sizeof(bus)); 508 memset(&bus, 0, sizeof(bus));
509 509
diff --git a/arch/mn10300/unit-asb2305/unit-init.c b/arch/mn10300/unit-asb2305/unit-init.c
index a76c8e0ab90f..e1becd6b7571 100644
--- a/arch/mn10300/unit-asb2305/unit-init.c
+++ b/arch/mn10300/unit-asb2305/unit-init.c
@@ -26,8 +26,10 @@ asmlinkage void __init unit_init(void)
26{ 26{
27#ifndef CONFIG_GDBSTUB_ON_TTYSx 27#ifndef CONFIG_GDBSTUB_ON_TTYSx
28 /* set the 16550 interrupt line to level 3 if not being used for GDB */ 28 /* set the 16550 interrupt line to level 3 if not being used for GDB */
29 set_intr_level(XIRQ0, GxICR_LEVEL_3); 29#ifdef CONFIG_EXT_SERIAL_IRQ_LEVEL
30 set_intr_level(XIRQ0, NUM2GxICR_LEVEL(CONFIG_EXT_SERIAL_IRQ_LEVEL));
30#endif 31#endif
32#endif /* CONFIG_GDBSTUB_ON_TTYSx */
31} 33}
32 34
33/* 35/*
@@ -51,7 +53,7 @@ void __init unit_init_IRQ(void)
51 switch (GET_XIRQ_TRIGGER(extnum)) { 53 switch (GET_XIRQ_TRIGGER(extnum)) {
52 case XIRQ_TRIGGER_HILEVEL: 54 case XIRQ_TRIGGER_HILEVEL:
53 case XIRQ_TRIGGER_LOWLEVEL: 55 case XIRQ_TRIGGER_LOWLEVEL:
54 set_intr_postackable(XIRQ2IRQ(extnum)); 56 mn10300_set_lateack_irq_type(XIRQ2IRQ(extnum));
55 break; 57 break;
56 default: 58 default:
57 break; 59 break;
diff --git a/arch/mn10300/unit-asb2364/Makefile b/arch/mn10300/unit-asb2364/Makefile
new file mode 100644
index 000000000000..b3263ecfc4ff
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for the linux kernel.
3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8# Note 2! The CFLAGS definitions are now in the main makefile...
9
10obj-y := unit-init.o leds.o irq-fpga.o
11
12obj-$(CONFIG_SMSC911X) += smsc911x.o
diff --git a/arch/mn10300/unit-asb2364/include/unit/clock.h b/arch/mn10300/unit-asb2364/include/unit/clock.h
new file mode 100644
index 000000000000..d34ac9a7508b
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/clock.h
@@ -0,0 +1,29 @@
1/* clock.h: unit-specific clocks
2 *
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * Modified by Matsushita Electric Industrial Co., Ltd.
7 * Modifications:
8 * 23-Feb-2007 MEI Add define for watchdog timer.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#ifndef _ASM_UNIT_CLOCK_H
17#define _ASM_UNIT_CLOCK_H
18
19#ifndef __ASSEMBLY__
20
21#define MN10300_IOCLK 100000000UL /* for DDR800 */
22/*#define MN10300_IOCLK 83333333UL */ /* for DDR667 */
23#define MN10300_IOBCLK MN10300_IOCLK /* IOBCLK is equal to IOCLK */
24
25#endif /* !__ASSEMBLY__ */
26
27#define MN10300_WDCLK 27000000UL
28
29#endif /* _ASM_UNIT_CLOCK_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h b/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h
new file mode 100644
index 000000000000..7cf12054db65
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/fpga-regs.h
@@ -0,0 +1,52 @@
1/* ASB2364 FPGA registers
2 */
3
4#ifndef _ASM_UNIT_FPGA_REGS_H
5#define _ASM_UNIT_FPGA_REGS_H
6
7#include <asm/cpu-regs.h>
8
9#ifdef __KERNEL__
10
11#define ASB2364_FPGA_REG_RESET_LAN __SYSREG(0xa9001300, u16)
12#define ASB2364_FPGA_REG_RESET_UART __SYSREG(0xa9001304, u16)
13#define ASB2364_FPGA_REG_RESET_I2C __SYSREG(0xa9001308, u16)
14#define ASB2364_FPGA_REG_RESET_USB __SYSREG(0xa900130c, u16)
15#define ASB2364_FPGA_REG_RESET_AV __SYSREG(0xa9001310, u16)
16
17#define ASB2364_FPGA_REG_IRQ(X) __SYSREG(0xa9001590+((X)*4), u16)
18#define ASB2364_FPGA_REG_IRQ_LAN ASB2364_FPGA_REG_IRQ(0)
19#define ASB2364_FPGA_REG_IRQ_UART ASB2364_FPGA_REG_IRQ(1)
20#define ASB2364_FPGA_REG_IRQ_I2C ASB2364_FPGA_REG_IRQ(2)
21#define ASB2364_FPGA_REG_IRQ_USB ASB2364_FPGA_REG_IRQ(3)
22#define ASB2364_FPGA_REG_IRQ_FPGA ASB2364_FPGA_REG_IRQ(5)
23
24#define ASB2364_FPGA_REG_MASK(X) __SYSREG(0xa9001590+((X)*4), u16)
25#define ASB2364_FPGA_REG_MASK_LAN ASB2364_FPGA_REG_MASK(0)
26#define ASB2364_FPGA_REG_MASK_UART ASB2364_FPGA_REG_MASK(1)
27#define ASB2364_FPGA_REG_MASK_I2C ASB2364_FPGA_REG_MASK(2)
28#define ASB2364_FPGA_REG_MASK_USB ASB2364_FPGA_REG_MASK(3)
29#define ASB2364_FPGA_REG_MASK_FPGA ASB2364_FPGA_REG_MASK(5)
30
31#define ASB2364_FPGA_REG_CPLD5_SET1 __SYSREG(0xa9002500, u16)
32#define ASB2364_FPGA_REG_CPLD5_SET2 __SYSREG(0xa9002504, u16)
33#define ASB2364_FPGA_REG_CPLD6_SET1 __SYSREG(0xa9002600, u16)
34#define ASB2364_FPGA_REG_CPLD6_SET2 __SYSREG(0xa9002604, u16)
35#define ASB2364_FPGA_REG_CPLD7_SET1 __SYSREG(0xa9002700, u16)
36#define ASB2364_FPGA_REG_CPLD7_SET2 __SYSREG(0xa9002704, u16)
37#define ASB2364_FPGA_REG_CPLD8_SET1 __SYSREG(0xa9002800, u16)
38#define ASB2364_FPGA_REG_CPLD8_SET2 __SYSREG(0xa9002804, u16)
39#define ASB2364_FPGA_REG_CPLD9_SET1 __SYSREG(0xa9002900, u16)
40#define ASB2364_FPGA_REG_CPLD9_SET2 __SYSREG(0xa9002904, u16)
41#define ASB2364_FPGA_REG_CPLD10_SET1 __SYSREG(0xa9002a00, u16)
42#define ASB2364_FPGA_REG_CPLD10_SET2 __SYSREG(0xa9002a04, u16)
43
44#define SyncExBus() \
45 do { \
46 unsigned short w; \
47 w = *(volatile short *)0xa9000000; \
48 } while (0)
49
50#endif /* __KERNEL__ */
51
52#endif /* _ASM_UNIT_FPGA_REGS_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/irq.h b/arch/mn10300/unit-asb2364/include/unit/irq.h
new file mode 100644
index 000000000000..786148e46565
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/irq.h
@@ -0,0 +1,35 @@
1/* ASB2364 FPGA irq numbers
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#ifndef _UNIT_IRQ_H
12#define _UNIT_IRQ_H
13
14#ifndef __ASSEMBLY__
15
16#ifdef CONFIG_SMP
17#define NR_CPU_IRQS GxICR_NUM_EXT_IRQS
18#else
19#define NR_CPU_IRQS GxICR_NUM_IRQS
20#endif
21
22enum {
23 FPGA_LAN_IRQ = NR_CPU_IRQS,
24 FPGA_UART_IRQ,
25 FPGA_I2C_IRQ,
26 FPGA_USB_IRQ,
27 FPGA_RESERVED_IRQ,
28 FPGA_FPGA_IRQ,
29 NR_IRQS
30};
31
32extern void __init irq_fpga_init(void);
33
34#endif /* !__ASSEMBLY__ */
35#endif /* _UNIT_IRQ_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/leds.h b/arch/mn10300/unit-asb2364/include/unit/leds.h
new file mode 100644
index 000000000000..03a3933ad323
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/leds.h
@@ -0,0 +1,54 @@
1/* Unit-specific leds
2 *
3 * Copyright (C) 2005 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_UNIT_LEDS_H
13#define _ASM_UNIT_LEDS_H
14
15#include <asm/pio-regs.h>
16#include <asm/cpu-regs.h>
17#include <asm/exceptions.h>
18
19#define MN10300_USE_7SEGLEDS 0
20
21#define ASB2364_7SEGLEDS __SYSREG(0xA9001630, u32)
22
23/*
24 * use the 7-segment LEDs to indicate states
25 */
26
27#if MN10300_USE_7SEGLEDS
28/* flip the 7-segment LEDs between "Gdb-" and "----" */
29#define mn10300_set_gdbleds(ONOFF) \
30 do { \
31 ASB2364_7SEGLEDS = (ONOFF) ? 0x8543077f : 0x7f7f7f7f; \
32 } while (0)
33#else
34#define mn10300_set_gdbleds(ONOFF) do {} while (0)
35#endif
36
37#if MN10300_USE_7SEGLEDS
38/* indicate double-fault by displaying "db-f" on the LEDs */
39#define mn10300_set_dbfleds \
40 mov 0x43077f1d,d0 ; \
41 mov d0,(ASB2364_7SEGLEDS)
42#else
43#define mn10300_set_dbfleds
44#endif
45
46#ifndef __ASSEMBLY__
47extern void peripheral_leds_display_exception(enum exception_code);
48extern void peripheral_leds_led_chase(void);
49extern void peripheral_leds7x4_display_dec(unsigned int, unsigned int);
50extern void peripheral_leds7x4_display_hex(unsigned int, unsigned int);
51extern void debug_to_serial(const char *, int);
52#endif /* __ASSEMBLY__ */
53
54#endif /* _ASM_UNIT_LEDS_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/serial.h b/arch/mn10300/unit-asb2364/include/unit/serial.h
new file mode 100644
index 000000000000..7f048bbfdfd7
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/serial.h
@@ -0,0 +1,151 @@
1/* Unit-specific 8250 serial ports
2 *
3 * Copyright (C) 2005 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _ASM_UNIT_SERIAL_H
13#define _ASM_UNIT_SERIAL_H
14
15#include <asm/cpu-regs.h>
16#include <proc/irq.h>
17#include <unit/fpga-regs.h>
18#include <linux/serial_reg.h>
19
20#define SERIAL_PORT0_BASE_ADDRESS 0xA8200000
21
22#define SERIAL_IRQ XIRQ1 /* single serial (TL16C550C) (Lo) */
23
24/*
25 * The ASB2364 has an 12.288 MHz clock
26 * for your UART.
27 *
28 * It'd be nice if someone built a serial card with a 24.576 MHz
29 * clock, since the 16550A is capable of handling a top speed of 1.5
30 * megabits/second; but this requires the faster clock.
31 */
32#define BASE_BAUD (12288000 / 16)
33
34/*
35 * dispose of the /dev/ttyS0 and /dev/ttyS1 serial ports
36 */
37#ifndef CONFIG_GDBSTUB_ON_TTYSx
38
39#define SERIAL_PORT_DFNS \
40 { \
41 .baud_base = BASE_BAUD, \
42 .irq = SERIAL_IRQ, \
43 .flags = STD_COM_FLAGS, \
44 .iomem_base = (u8 *) SERIAL_PORT0_BASE_ADDRESS, \
45 .iomem_reg_shift = 1, \
46 .io_type = SERIAL_IO_MEM, \
47 },
48
49#ifndef __ASSEMBLY__
50
51static inline void __debug_to_serial(const char *p, int n)
52{
53}
54
55#endif /* !__ASSEMBLY__ */
56
57#else /* CONFIG_GDBSTUB_ON_TTYSx */
58
59#define SERIAL_PORT_DFNS /* stolen by gdb-stub */
60
61#if defined(CONFIG_GDBSTUB_ON_TTYS0)
62#define GDBPORT_SERIAL_RX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_RX * 4, u8)
63#define GDBPORT_SERIAL_TX __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_TX * 4, u8)
64#define GDBPORT_SERIAL_DLL __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLL * 4, u8)
65#define GDBPORT_SERIAL_DLM __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_DLM * 4, u8)
66#define GDBPORT_SERIAL_IER __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IER * 4, u8)
67#define GDBPORT_SERIAL_IIR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_IIR * 4, u8)
68#define GDBPORT_SERIAL_FCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_FCR * 4, u8)
69#define GDBPORT_SERIAL_LCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LCR * 4, u8)
70#define GDBPORT_SERIAL_MCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MCR * 4, u8)
71#define GDBPORT_SERIAL_LSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_LSR * 4, u8)
72#define GDBPORT_SERIAL_MSR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_MSR * 4, u8)
73#define GDBPORT_SERIAL_SCR __SYSREG(SERIAL_PORT0_BASE_ADDRESS + UART_SCR * 4, u8)
74#define GDBPORT_SERIAL_IRQ SERIAL_IRQ
75
76#elif defined(CONFIG_GDBSTUB_ON_TTYS1)
77#error The ASB2364 does not have a /dev/ttyS1
78#endif
79
80#ifndef __ASSEMBLY__
81
82static inline void __debug_to_serial(const char *p, int n)
83{
84 char ch;
85
86#define LSR_WAIT_FOR(STATE) \
87 do {} while (!(GDBPORT_SERIAL_LSR & UART_LSR_##STATE))
88#define FLOWCTL_QUERY(LINE) \
89 ({ GDBPORT_SERIAL_MSR & UART_MSR_##LINE; })
90#define FLOWCTL_WAIT_FOR(LINE) \
91 do {} while (!(GDBPORT_SERIAL_MSR & UART_MSR_##LINE))
92#define FLOWCTL_CLEAR(LINE) \
93 do { GDBPORT_SERIAL_MCR &= ~UART_MCR_##LINE; } while (0)
94#define FLOWCTL_SET(LINE) \
95 do { GDBPORT_SERIAL_MCR |= UART_MCR_##LINE; } while (0)
96
97 FLOWCTL_SET(DTR);
98
99 for (; n > 0; n--) {
100 LSR_WAIT_FOR(THRE);
101 FLOWCTL_WAIT_FOR(CTS);
102
103 ch = *p++;
104 if (ch == 0x0a) {
105 GDBPORT_SERIAL_TX = 0x0d;
106 LSR_WAIT_FOR(THRE);
107 FLOWCTL_WAIT_FOR(CTS);
108 }
109 GDBPORT_SERIAL_TX = ch;
110 }
111
112 FLOWCTL_CLEAR(DTR);
113}
114
115#endif /* !__ASSEMBLY__ */
116
117#endif /* CONFIG_GDBSTUB_ON_TTYSx */
118
119#define SERIAL_INITIALIZE \
120do { \
121 /* release reset */ \
122 ASB2364_FPGA_REG_RESET_UART = 0x0001; \
123 SyncExBus(); \
124} while (0)
125
126#define SERIAL_CHECK_INTERRUPT \
127do { \
128 if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) == 0x0001) { \
129 return IRQ_NONE; \
130 } \
131} while (0)
132
133#define SERIAL_CLEAR_INTERRUPT \
134do { \
135 ASB2364_FPGA_REG_IRQ_UART = 0x0001; \
136 SyncExBus(); \
137} while (0)
138
139#define SERIAL_SET_INT_MASK \
140do { \
141 ASB2364_FPGA_REG_MASK_UART = 0x0001; \
142 SyncExBus(); \
143} while (0)
144
145#define SERIAL_CLEAR_INT_MASK \
146do { \
147 ASB2364_FPGA_REG_MASK_UART = 0x0000; \
148 SyncExBus(); \
149} while (0)
150
151#endif /* _ASM_UNIT_SERIAL_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/smsc911x.h b/arch/mn10300/unit-asb2364/include/unit/smsc911x.h
new file mode 100644
index 000000000000..4c1ede535fa9
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/smsc911x.h
@@ -0,0 +1,171 @@
1/* Support for the SMSC911x NIC
2 *
3 * Copyright (C) 2006 Matsushita Electric Industrial Co., Ltd.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_UNIT_SMSC911X_H
12#define _ASM_UNIT_SMSC911X_H
13
14#include <linux/netdevice.h>
15#include <proc/irq.h>
16#include <unit/fpga-regs.h>
17
18#define MN10300_USE_EXT_EEPROM
19
20
21#define SMSC911X_BASE 0xA8000000UL
22#define SMSC911X_BASE_END 0xA8000100UL
23#define SMSC911X_IRQ FPGA_LAN_IRQ
24
25/*
26 * Allow the FPGA to be initialised by the SMSC911x driver
27 */
28#undef SMSC_INITIALIZE
29#define SMSC_INITIALIZE() \
30do { \
31 /* release reset */ \
32 ASB2364_FPGA_REG_RESET_LAN = 0x0001; \
33 SyncExBus(); \
34} while (0)
35
36#ifdef MN10300_USE_EXT_EEPROM
37#include <linux/delay.h>
38#include <unit/clock.h>
39
40#define EEPROM_ADDRESS 0xA0
41#define MAC_OFFSET 0x0008
42#define USE_IIC_CH 0 /* 0 or 1 */
43#define IIC_OFFSET (0x80000 * USE_IIC_CH)
44#define IIC_DTRM __SYSREG(0xd8400000 + IIC_OFFSET, u32)
45#define IIC_DREC __SYSREG(0xd8400004 + IIC_OFFSET, u32)
46#define IIC_MYADD __SYSREG(0xd8400008 + IIC_OFFSET, u32)
47#define IIC_CLK __SYSREG(0xd840000c + IIC_OFFSET, u32)
48#define IIC_BRST __SYSREG(0xd8400010 + IIC_OFFSET, u32)
49#define IIC_HOLD __SYSREG(0xd8400014 + IIC_OFFSET, u32)
50#define IIC_BSTS __SYSREG(0xd8400018 + IIC_OFFSET, u32)
51#define IIC_ICR __SYSREG(0xd4000080 + 4 * USE_IIC_CH, u16)
52
53#define IIC_CLK_PLS ((unsigned short)(MN10300_IOCLK / 100000 - 1))
54#define IIC_CLK_LOW ((unsigned short)(IIC_CLK_PLS / 2))
55
56#define SYS_IIC_DTRM_Bit_STA ((unsigned short)0x0400)
57#define SYS_IIC_DTRM_Bit_STO ((unsigned short)0x0200)
58#define SYS_IIC_DTRM_Bit_ACK ((unsigned short)0x0100)
59#define SYS_IIC_DTRM_Bit_DATA ((unsigned short)0x00FF)
60
61static inline void POLL_INT_REQ(volatile u16 *icr)
62{
63 unsigned long flags;
64 u16 tmp;
65
66 while (!(*icr & GxICR_REQUEST))
67 ;
68 flags = arch_local_cli_save();
69 tmp = *icr;
70 *icr = (tmp & GxICR_LEVEL) | GxICR_DETECT;
71 tmp = *icr;
72 arch_local_irq_restore(flags);
73}
74
75/*
76 * Implement the SMSC911x hook for MAC address retrieval
77 */
78#undef smsc_get_mac
79static inline int smsc_get_mac(struct net_device *dev)
80{
81 unsigned char *mac_buf = dev->dev_addr;
82 int i;
83 unsigned short value;
84 unsigned int data;
85 int mac_length = 6;
86 int check;
87 u16 orig_gicr, tmp;
88 unsigned long flags;
89
90 /* save original GnICR and clear GnICR.IE */
91 flags = arch_local_cli_save();
92 orig_gicr = IIC_ICR;
93 IIC_ICR = orig_gicr & GxICR_LEVEL;
94 tmp = IIC_ICR;
95 arch_local_irq_restore(flags);
96
97 IIC_MYADD = 0x00000008;
98 IIC_CLK = (IIC_CLK_LOW << 16) + (IIC_CLK_PLS);
99 /* bus hung recovery */
100
101 while (1) {
102 check = 0;
103 for (i = 0; i < 3; i++) {
104 if ((IIC_BSTS & 0x00000003) == 0x00000003)
105 check++;
106 udelay(3);
107 }
108
109 if (check == 3) {
110 IIC_BRST = 0x00000003;
111 break;
112 } else {
113 for (i = 0; i < 3; i++) {
114 IIC_BRST = 0x00000002;
115 udelay(8);
116 IIC_BRST = 0x00000003;
117 udelay(8);
118 }
119 }
120 }
121
122 IIC_BRST = 0x00000002;
123 IIC_BRST = 0x00000003;
124
125 value = SYS_IIC_DTRM_Bit_STA | SYS_IIC_DTRM_Bit_ACK;
126 value |= (((unsigned short)EEPROM_ADDRESS & SYS_IIC_DTRM_Bit_DATA) |
127 (unsigned short)0x0000);
128 IIC_DTRM = value;
129 POLL_INT_REQ(&IIC_ICR);
130
131 /** send offset of MAC address in EEPROM **/
132 IIC_DTRM = (unsigned char)((MAC_OFFSET & 0xFF00) >> 8);
133 POLL_INT_REQ(&IIC_ICR);
134
135 IIC_DTRM = (unsigned char)(MAC_OFFSET & 0x00FF);
136 POLL_INT_REQ(&IIC_ICR);
137
138 udelay(1000);
139
140 value = SYS_IIC_DTRM_Bit_STA;
141 value |= (((unsigned short)EEPROM_ADDRESS & SYS_IIC_DTRM_Bit_DATA) |
142 (unsigned short)0x0001);
143 IIC_DTRM = value;
144 POLL_INT_REQ(&IIC_ICR);
145
146 IIC_DTRM = 0x00000000;
147 while (mac_length > 0) {
148 POLL_INT_REQ(&IIC_ICR);
149
150 data = IIC_DREC;
151 mac_length--;
152 if (mac_length == 0)
153 value = 0x00000300; /* stop IIC bus */
154 else if (mac_length == 1)
155 value = 0x00000100; /* no ack */
156 else
157 value = 0x00000000; /* ack */
158 IIC_DTRM = value;
159 *mac_buf++ = (unsigned char)(data & 0xff);
160 }
161
162 /* restore GnICR.LV and GnICR.IE */
163 flags = arch_local_cli_save();
164 IIC_ICR = (orig_gicr & (GxICR_LEVEL | GxICR_ENABLE));
165 tmp = IIC_ICR;
166 arch_local_irq_restore(flags);
167
168 return 0;
169}
170#endif /* MN10300_USE_EXT_EEPROM */
171#endif /* _ASM_UNIT_SMSC911X_H */
diff --git a/arch/mn10300/unit-asb2364/include/unit/timex.h b/arch/mn10300/unit-asb2364/include/unit/timex.h
new file mode 100644
index 000000000000..ddb7ed010706
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/include/unit/timex.h
@@ -0,0 +1,159 @@
1/* timex.h: MN2WS0038 architecture timer specifications
2 *
3 * Copyright (C) 2002, 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_UNIT_TIMEX_H
12#define _ASM_UNIT_TIMEX_H
13
14#ifndef __ASSEMBLY__
15#include <linux/irq.h>
16#endif /* __ASSEMBLY__ */
17
18#include <asm/timer-regs.h>
19#include <unit/clock.h>
20#include <asm/param.h>
21
22/*
23 * jiffies counter specifications
24 */
25
26#define TMJCBR_MAX 0xffffff /* 24bit */
27#define TMJCIRQ TMTIRQ
28
29#ifndef __ASSEMBLY__
30
31#define MN10300_SRC_IOBCLK MN10300_IOBCLK
32
33#ifndef HZ
34# error HZ undeclared.
35#endif /* !HZ */
36
37#define MN10300_JCCLK (MN10300_SRC_IOBCLK)
38#define MN10300_TSCCLK (MN10300_SRC_IOBCLK)
39
40#define MN10300_JC_PER_HZ ((MN10300_JCCLK + HZ / 2) / HZ)
41#define MN10300_TSC_PER_HZ ((MN10300_TSCCLK + HZ / 2) / HZ)
42
43/* Check bit width of MTM interval value that sets base register */
44#if (MN10300_JC_PER_HZ - 1) > TMJCBR_MAX
45# error MTM tick timer interval value is overflow.
46#endif
47
48static inline void stop_jiffies_counter(void)
49{
50 u16 tmp;
51 TMTMD = 0;
52 tmp = TMTMD;
53}
54
55static inline void reload_jiffies_counter(u32 cnt)
56{
57 u32 tmp;
58
59 TMTBR = cnt;
60 tmp = TMTBR;
61
62 TMTMD = TMTMD_TMTLDE;
63 TMTMD = TMTMD_TMTCNE;
64 tmp = TMTMD;
65}
66
67#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_CLOCKEVENTS) && \
68 !defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
69/*
70 * If we aren't using broadcasting, each core needs its own event timer.
71 * Since CPU0 uses the tick timer which is 24-bits, we use timer 4 & 5
72 * cascaded to 32-bits for CPU1 (but only really use 24-bits to match
73 * CPU0).
74 */
75
76#define TMJC1IRQ TM5IRQ
77
78static inline void stop_jiffies_counter1(void)
79{
80 u8 tmp;
81 TM4MD = 0;
82 TM5MD = 0;
83 tmp = TM4MD;
84 tmp = TM5MD;
85}
86
87static inline void reload_jiffies_counter1(u32 cnt)
88{
89 u32 tmp;
90
91 TM45BR = cnt;
92 tmp = TM45BR;
93
94 TM4MD = TM4MD_INIT_COUNTER;
95 tmp = TM4MD;
96
97 TM5MD = TM5MD_SRC_TM4CASCADE | TM5MD_INIT_COUNTER;
98 TM5MD = TM5MD_SRC_TM4CASCADE | TM5MD_COUNT_ENABLE;
99 tmp = TM5MD;
100
101 TM4MD = TM4MD_COUNT_ENABLE;
102 tmp = TM4MD;
103}
104#endif /* CONFIG_SMP&GENERIC_CLOCKEVENTS&!GENERIC_CLOCKEVENTS_BROADCAST */
105
106#endif /* !__ASSEMBLY__ */
107
108
109/*
110 * timestamp counter specifications
111 */
112#define TMTSCBR_MAX 0xffffffff
113
114#ifndef __ASSEMBLY__
115
116/* Use 32-bit timestamp counter */
117#define TMTSCMD TMSMD
118#define TMTSCBR TMSBR
119#define TMTSCBC TMSBC
120#define TMTSCICR TMSICR
121
122static inline void startup_timestamp_counter(void)
123{
124 u32 sync;
125
126 /* set up TMS(Timestamp) 32bit timer register to count real time
127 * - count down from 4Gig-1 to 0 and wrap at IOBCLK rate
128 */
129
130 TMTSCBR = TMTSCBR_MAX;
131 sync = TMTSCBR;
132
133 TMTSCICR = 0;
134 sync = TMTSCICR;
135
136 TMTSCMD = TMTMD_TMTLDE;
137 TMTSCMD = TMTMD_TMTCNE;
138 sync = TMTSCMD;
139}
140
141static inline void shutdown_timestamp_counter(void)
142{
143 TMTSCMD = 0;
144}
145
146/*
147 * we use a cascaded pair of 16-bit down-counting timers to count I/O
148 * clock cycles for the purposes of time keeping
149 */
150typedef unsigned long cycles_t;
151
152static inline cycles_t read_timestamp_counter(void)
153{
154 return (cycles_t)~TMTSCBC;
155}
156
157#endif /* !__ASSEMBLY__ */
158
159#endif /* _ASM_UNIT_TIMEX_H */
diff --git a/arch/mn10300/unit-asb2364/irq-fpga.c b/arch/mn10300/unit-asb2364/irq-fpga.c
new file mode 100644
index 000000000000..fcf29754e4d1
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/irq-fpga.c
@@ -0,0 +1,96 @@
1/* ASB2364 FPGA interrupt multiplexing
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#include <linux/interrupt.h>
13#include <linux/init.h>
14#include <linux/irq.h>
15#include <unit/fpga-regs.h>
16
17/*
18 * FPGA PIC operations
19 */
20static void asb2364_fpga_mask(unsigned int irq)
21{
22 ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001;
23 SyncExBus();
24}
25
26static void asb2364_fpga_ack(unsigned int irq)
27{
28 ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001;
29 SyncExBus();
30}
31
32static void asb2364_fpga_mask_ack(unsigned int irq)
33{
34 ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0001;
35 SyncExBus();
36 ASB2364_FPGA_REG_IRQ(irq - NR_CPU_IRQS) = 0x0001;
37 SyncExBus();
38}
39
40static void asb2364_fpga_unmask(unsigned int irq)
41{
42 ASB2364_FPGA_REG_MASK(irq - NR_CPU_IRQS) = 0x0000;
43 SyncExBus();
44}
45
46static struct irq_chip asb2364_fpga_pic = {
47 .name = "fpga",
48 .ack = asb2364_fpga_ack,
49 .mask = asb2364_fpga_mask,
50 .mask_ack = asb2364_fpga_mask_ack,
51 .unmask = asb2364_fpga_unmask,
52};
53
54/*
55 * FPGA PIC interrupt handler
56 */
57static irqreturn_t fpga_interrupt(int irq, void *_mask)
58{
59 if ((ASB2364_FPGA_REG_IRQ_LAN & 0x0001) != 0x0001)
60 generic_handle_irq(FPGA_LAN_IRQ);
61 if ((ASB2364_FPGA_REG_IRQ_UART & 0x0001) != 0x0001)
62 generic_handle_irq(FPGA_UART_IRQ);
63 if ((ASB2364_FPGA_REG_IRQ_I2C & 0x0001) != 0x0001)
64 generic_handle_irq(FPGA_I2C_IRQ);
65 if ((ASB2364_FPGA_REG_IRQ_USB & 0x0001) != 0x0001)
66 generic_handle_irq(FPGA_USB_IRQ);
67 if ((ASB2364_FPGA_REG_IRQ_FPGA & 0x0001) != 0x0001)
68 generic_handle_irq(FPGA_FPGA_IRQ);
69
70 return IRQ_HANDLED;
71}
72
73/*
74 * Define an interrupt action for each FPGA PIC output
75 */
76static struct irqaction fpga_irq[] = {
77 [0] = {
78 .handler = fpga_interrupt,
79 .flags = IRQF_DISABLED | IRQF_SHARED,
80 .name = "fpga",
81 },
82};
83
84/*
85 * Initialise the FPGA's PIC
86 */
87void __init irq_fpga_init(void)
88{
89 int irq;
90
91 for (irq = NR_CPU_IRQS; irq < NR_IRQS; irq++)
92 set_irq_chip_and_handler(irq, &asb2364_fpga_pic, handle_level_irq);
93
94 /* the FPGA drives the XIRQ1 input on the CPU PIC */
95 setup_irq(XIRQ1, &fpga_irq[0]);
96}
diff --git a/arch/mn10300/unit-asb2364/leds.c b/arch/mn10300/unit-asb2364/leds.c
new file mode 100644
index 000000000000..1ff830c372b3
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/leds.c
@@ -0,0 +1,98 @@
1/* leds.c: ASB2364 peripheral 7seg LEDs x4 support
2 *
3 * Copyright (C) 2002 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/init.h>
15
16#include <asm/io.h>
17#include <asm/processor.h>
18#include <asm/intctl-regs.h>
19#include <asm/rtc-regs.h>
20#include <unit/leds.h>
21
22#if MN10300_USE_7SEGLEDS
23static const u8 asb2364_led_hex_tbl[16] = {
24 0x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,
25 0x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c
26};
27
28static const u32 asb2364_led_chase_tbl[6] = {
29 ~0x02020202, /* top - segA */
30 ~0x04040404, /* right top - segB */
31 ~0x08080808, /* right bottom - segC */
32 ~0x10101010, /* bottom - segD */
33 ~0x20202020, /* left bottom - segE */
34 ~0x40404040, /* left top - segF */
35};
36
37static unsigned asb2364_led_chase;
38
39void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points)
40{
41 u32 leds;
42
43 leds = asb2364_led_hex_tbl[(val/1000) % 10];
44 leds <<= 8;
45 leds |= asb2364_led_hex_tbl[(val/100) % 10];
46 leds <<= 8;
47 leds |= asb2364_led_hex_tbl[(val/10) % 10];
48 leds <<= 8;
49 leds |= asb2364_led_hex_tbl[val % 10];
50 leds |= points^0x01010101;
51
52 ASB2364_7SEGLEDS = leds;
53}
54
55void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points)
56{
57 u32 leds;
58
59 leds = asb2364_led_hex_tbl[(val/1000) % 10];
60 leds <<= 8;
61 leds |= asb2364_led_hex_tbl[(val/100) % 10];
62 leds <<= 8;
63 leds |= asb2364_led_hex_tbl[(val/10) % 10];
64 leds <<= 8;
65 leds |= asb2364_led_hex_tbl[val % 10];
66 leds |= points^0x01010101;
67
68 ASB2364_7SEGLEDS = leds;
69}
70
71/* display triple horizontal bar and exception code */
72void peripheral_leds_display_exception(enum exception_code code)
73{
74 u32 leds;
75
76 leds = asb2364_led_hex_tbl[(code/0x100) % 0x10];
77 leds <<= 8;
78 leds |= asb2364_led_hex_tbl[(code/0x10) % 0x10];
79 leds <<= 8;
80 leds |= asb2364_led_hex_tbl[code % 0x10];
81 leds |= 0x6d010101;
82
83 ASB2364_7SEGLEDS = leds;
84}
85
86void peripheral_leds_led_chase(void)
87{
88 ASB2364_7SEGLEDS = asb2364_led_chase_tbl[asb2364_led_chase];
89 asb2364_led_chase++;
90 if (asb2364_led_chase >= 6)
91 asb2364_led_chase = 0;
92}
93#else /* MN10300_USE_7SEGLEDS */
94void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points) { }
95void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points) { }
96void peripheral_leds_display_exception(enum exception_code code) { }
97void peripheral_leds_led_chase(void) { }
98#endif /* MN10300_USE_7SEGLEDS */
diff --git a/arch/mn10300/unit-asb2364/smsc911x.c b/arch/mn10300/unit-asb2364/smsc911x.c
new file mode 100644
index 000000000000..544a73e94c81
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/smsc911x.c
@@ -0,0 +1,58 @@
1/* Specification for the SMSC911x NIC
2 *
3 * Copyright (C) 2006 Matsushita Electric Industrial Co., Ltd.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/ioport.h>
17#include <linux/smsc911x.h>
18#include <unit/smsc911x.h>
19
20static struct smsc911x_platform_config smsc911x_config = {
21 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
22 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
23 .flags = SMSC911X_USE_32BIT,
24};
25
26static struct resource smsc911x_resources[] = {
27 [0] = {
28 .start = SMSC911X_BASE,
29 .end = SMSC911X_BASE_END,
30 .flags = IORESOURCE_MEM,
31 },
32 [1] = {
33 .start = SMSC911X_IRQ,
34 .end = SMSC911X_IRQ,
35 .flags = IORESOURCE_IRQ,
36 },
37};
38
39static struct platform_device smsc911x_device = {
40 .name = "smsc911x",
41 .id = 0,
42 .num_resources = ARRAY_SIZE(smsc911x_resources),
43 .resource = smsc911x_resources,
44 .dev = {
45 .platform_data = &smsc911x_config,
46 }
47};
48
49/*
50 * add platform devices
51 */
52static int __init unit_device_init(void)
53{
54 platform_device_register(&smsc911x_device);
55 return 0;
56}
57
58device_initcall(unit_device_init);
diff --git a/arch/mn10300/unit-asb2364/unit-init.c b/arch/mn10300/unit-asb2364/unit-init.c
new file mode 100644
index 000000000000..11440803db10
--- /dev/null
+++ b/arch/mn10300/unit-asb2364/unit-init.c
@@ -0,0 +1,88 @@
1/* ASB2364 initialisation
2 *
3 * Copyright (C) 2002 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/param.h>
14#include <linux/init.h>
15#include <linux/device.h>
16#include <linux/delay.h>
17
18#include <asm/io.h>
19#include <asm/setup.h>
20#include <asm/processor.h>
21#include <asm/irq.h>
22#include <asm/intctl-regs.h>
23#include <unit/fpga-regs.h>
24
25/*
26 * initialise some of the unit hardware before gdbstub is set up
27 */
28asmlinkage void __init unit_init(void)
29{
30 /* set up the external interrupts */
31
32 /* XIRQ[0]: NAND RXBY */
33 /* SET_XIRQ_TRIGGER(0, XIRQ_TRIGGER_LOWLEVEL); */
34
35 /* XIRQ[1]: LAN, UART, I2C, USB, PCI, FPGA */
36 SET_XIRQ_TRIGGER(1, XIRQ_TRIGGER_LOWLEVEL);
37
38 /* XIRQ[2]: Extend Slot 1-9 */
39 /* SET_XIRQ_TRIGGER(2, XIRQ_TRIGGER_LOWLEVEL); */
40
41#if defined(CONFIG_EXT_SERIAL_IRQ_LEVEL) && \
42 defined(CONFIG_ETHERNET_IRQ_LEVEL) && \
43 (CONFIG_EXT_SERIAL_IRQ_LEVEL != CONFIG_ETHERNET_IRQ_LEVEL)
44# error CONFIG_EXT_SERIAL_IRQ_LEVEL != CONFIG_ETHERNET_IRQ_LEVEL
45#endif
46
47#if defined(CONFIG_EXT_SERIAL_IRQ_LEVEL)
48 set_intr_level(XIRQ1, NUM2GxICR_LEVEL(CONFIG_EXT_SERIAL_IRQ_LEVEL));
49#elif defined(CONFIG_ETHERNET_IRQ_LEVEL)
50 set_intr_level(XIRQ1, NUM2GxICR_LEVEL(CONFIG_ETHERNET_IRQ_LEVEL));
51#endif
52}
53
54/*
55 * initialise the rest of the unit hardware after gdbstub is ready
56 */
57asmlinkage void __init unit_setup(void)
58{
59
60}
61
62/*
63 * initialise the external interrupts used by a unit of this type
64 */
65void __init unit_init_IRQ(void)
66{
67 unsigned int extnum;
68
69 for (extnum = 0 ; extnum < NR_XIRQS ; extnum++) {
70 switch (GET_XIRQ_TRIGGER(extnum)) {
71 /* LEVEL triggered interrupts should be made
72 * post-ACK'able as they hold their lines until
73 * serviced
74 */
75 case XIRQ_TRIGGER_HILEVEL:
76 case XIRQ_TRIGGER_LOWLEVEL:
77 mn10300_set_lateack_irq_type(XIRQ2IRQ(extnum));
78 break;
79 default:
80 break;
81 }
82 }
83
84#define IRQCTL __SYSREG(0xd5000090, u32)
85 IRQCTL |= 0x02;
86
87 irq_fpga_init();
88}
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 79a04a9394d5..0888675c98dd 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux/PA-RISC Kernel Configuration"
7
8config PARISC 1config PARISC
9 def_bool y 2 def_bool y
10 select HAVE_IDE 3 select HAVE_IDE
@@ -19,6 +12,7 @@ config PARISC
19 select HAVE_IRQ_WORK 12 select HAVE_IRQ_WORK
20 select HAVE_PERF_EVENTS 13 select HAVE_PERF_EVENTS
21 select GENERIC_ATOMIC64 if !64BIT 14 select GENERIC_ATOMIC64 if !64BIT
15 select GENERIC_HARDIRQS_NO__DO_IRQ
22 help 16 help
23 The PA-RISC microprocessor is designed by Hewlett-Packard and used 17 The PA-RISC microprocessor is designed by Hewlett-Packard and used
24 in many of their workstations & servers (HP9000 700 and 800 series, 18 in many of their workstations & servers (HP9000 700 and 800 series,
@@ -85,6 +79,9 @@ config IRQ_PER_CPU
85 bool 79 bool
86 default y 80 default y
87 81
82config GENERIC_HARDIRQS_NO__DO_IRQ
83 def_bool y
84
88# unless you want to implement ACPI on PA-RISC ... ;-) 85# unless you want to implement ACPI on PA-RISC ... ;-)
89config PM 86config PM
90 bool 87 bool
diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
index 039880e7d2c9..47f11c707b65 100644
--- a/arch/parisc/include/asm/cache.h
+++ b/arch/parisc/include/asm/cache.h
@@ -24,8 +24,6 @@
24 24
25#ifndef __ASSEMBLY__ 25#ifndef __ASSEMBLY__
26 26
27#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
28
29#define SMP_CACHE_BYTES L1_CACHE_BYTES 27#define SMP_CACHE_BYTES L1_CACHE_BYTES
30 28
31#define ARCH_DMA_MINALIGN L1_CACHE_BYTES 29#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h
index dba11aedce1b..f388a85bba11 100644
--- a/arch/parisc/include/asm/cacheflush.h
+++ b/arch/parisc/include/asm/cacheflush.h
@@ -126,20 +126,20 @@ static inline void *kmap(struct page *page)
126 126
127#define kunmap(page) kunmap_parisc(page_address(page)) 127#define kunmap(page) kunmap_parisc(page_address(page))
128 128
129static inline void *kmap_atomic(struct page *page, enum km_type idx) 129static inline void *__kmap_atomic(struct page *page)
130{ 130{
131 pagefault_disable(); 131 pagefault_disable();
132 return page_address(page); 132 return page_address(page);
133} 133}
134 134
135static inline void kunmap_atomic_notypecheck(void *addr, enum km_type idx) 135static inline void __kunmap_atomic(void *addr)
136{ 136{
137 kunmap_parisc(addr); 137 kunmap_parisc(addr);
138 pagefault_enable(); 138 pagefault_enable();
139} 139}
140 140
141#define kmap_atomic_prot(page, idx, prot) kmap_atomic(page, idx) 141#define kmap_atomic_prot(page, prot) kmap_atomic(page)
142#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx)) 142#define kmap_atomic_pfn(pfn) kmap_atomic(pfn_to_page(pfn))
143#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 143#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
144#endif 144#endif
145 145
diff --git a/arch/parisc/include/asm/irq.h b/arch/parisc/include/asm/irq.h
index dfa26b67f919..c67dccf2e31f 100644
--- a/arch/parisc/include/asm/irq.h
+++ b/arch/parisc/include/asm/irq.h
@@ -40,7 +40,7 @@ struct irq_chip;
40void no_ack_irq(unsigned int irq); 40void no_ack_irq(unsigned int irq);
41void no_end_irq(unsigned int irq); 41void no_end_irq(unsigned int irq);
42void cpu_ack_irq(unsigned int irq); 42void cpu_ack_irq(unsigned int irq);
43void cpu_end_irq(unsigned int irq); 43void cpu_eoi_irq(unsigned int irq);
44 44
45extern int txn_alloc_irq(unsigned int nbits); 45extern int txn_alloc_irq(unsigned int nbits);
46extern int txn_claim_irq(int); 46extern int txn_claim_irq(int);
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 01c15035e783..865f37a8a881 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -397,9 +397,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
397#define pte_offset_kernel(pmd, address) \ 397#define pte_offset_kernel(pmd, address) \
398 ((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address)) 398 ((pte_t *) pmd_page_vaddr(*(pmd)) + pte_index(address))
399#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address) 399#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
400#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
401#define pte_unmap(pte) do { } while (0) 400#define pte_unmap(pte) do { } while (0)
402#define pte_unmap_nested(pte) do { } while (0)
403 401
404#define pte_unmap(pte) do { } while (0) 402#define pte_unmap(pte) do { } while (0)
405#define pte_unmap_nested(pte) do { } while (0) 403#define pte_unmap_nested(pte) do { } while (0)
diff --git a/arch/parisc/include/asm/unistd.h b/arch/parisc/include/asm/unistd.h
index 1ce7d2851d90..3eb82c2a5ec3 100644
--- a/arch/parisc/include/asm/unistd.h
+++ b/arch/parisc/include/asm/unistd.h
@@ -813,8 +813,9 @@
813#define __NR_perf_event_open (__NR_Linux + 318) 813#define __NR_perf_event_open (__NR_Linux + 318)
814#define __NR_recvmmsg (__NR_Linux + 319) 814#define __NR_recvmmsg (__NR_Linux + 319)
815#define __NR_accept4 (__NR_Linux + 320) 815#define __NR_accept4 (__NR_Linux + 320)
816#define __NR_prlimit64 (__NR_Linux + 321)
816 817
817#define __NR_Linux_syscalls (__NR_accept4 + 1) 818#define __NR_Linux_syscalls (__NR_prlimit64 + 1)
818 819
819 820
820#define __IGNORE_select /* newselect */ 821#define __IGNORE_select /* newselect */
diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c
index efbcee5d2220..5024f643b3b1 100644
--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -52,7 +52,7 @@ static volatile unsigned long cpu_eiem = 0;
52*/ 52*/
53static DEFINE_PER_CPU(unsigned long, local_ack_eiem) = ~0UL; 53static DEFINE_PER_CPU(unsigned long, local_ack_eiem) = ~0UL;
54 54
55static void cpu_disable_irq(unsigned int irq) 55static void cpu_mask_irq(unsigned int irq)
56{ 56{
57 unsigned long eirr_bit = EIEM_MASK(irq); 57 unsigned long eirr_bit = EIEM_MASK(irq);
58 58
@@ -63,7 +63,7 @@ static void cpu_disable_irq(unsigned int irq)
63 * then gets disabled */ 63 * then gets disabled */
64} 64}
65 65
66static void cpu_enable_irq(unsigned int irq) 66static void cpu_unmask_irq(unsigned int irq)
67{ 67{
68 unsigned long eirr_bit = EIEM_MASK(irq); 68 unsigned long eirr_bit = EIEM_MASK(irq);
69 69
@@ -75,12 +75,6 @@ static void cpu_enable_irq(unsigned int irq)
75 smp_send_all_nop(); 75 smp_send_all_nop();
76} 76}
77 77
78static unsigned int cpu_startup_irq(unsigned int irq)
79{
80 cpu_enable_irq(irq);
81 return 0;
82}
83
84void no_ack_irq(unsigned int irq) { } 78void no_ack_irq(unsigned int irq) { }
85void no_end_irq(unsigned int irq) { } 79void no_end_irq(unsigned int irq) { }
86 80
@@ -99,7 +93,7 @@ void cpu_ack_irq(unsigned int irq)
99 mtctl(mask, 23); 93 mtctl(mask, 23);
100} 94}
101 95
102void cpu_end_irq(unsigned int irq) 96void cpu_eoi_irq(unsigned int irq)
103{ 97{
104 unsigned long mask = EIEM_MASK(irq); 98 unsigned long mask = EIEM_MASK(irq);
105 int cpu = smp_processor_id(); 99 int cpu = smp_processor_id();
@@ -146,12 +140,10 @@ static int cpu_set_affinity_irq(unsigned int irq, const struct cpumask *dest)
146 140
147static struct irq_chip cpu_interrupt_type = { 141static struct irq_chip cpu_interrupt_type = {
148 .name = "CPU", 142 .name = "CPU",
149 .startup = cpu_startup_irq, 143 .mask = cpu_mask_irq,
150 .shutdown = cpu_disable_irq, 144 .unmask = cpu_unmask_irq,
151 .enable = cpu_enable_irq,
152 .disable = cpu_disable_irq,
153 .ack = cpu_ack_irq, 145 .ack = cpu_ack_irq,
154 .end = cpu_end_irq, 146 .eoi = cpu_eoi_irq,
155#ifdef CONFIG_SMP 147#ifdef CONFIG_SMP
156 .set_affinity = cpu_set_affinity_irq, 148 .set_affinity = cpu_set_affinity_irq,
157#endif 149#endif
@@ -247,10 +239,11 @@ int cpu_claim_irq(unsigned int irq, struct irq_chip *type, void *data)
247 if (irq_desc[irq].chip != &cpu_interrupt_type) 239 if (irq_desc[irq].chip != &cpu_interrupt_type)
248 return -EBUSY; 240 return -EBUSY;
249 241
242 /* for iosapic interrupts */
250 if (type) { 243 if (type) {
251 irq_desc[irq].chip = type; 244 set_irq_chip_and_handler(irq, type, handle_level_irq);
252 irq_desc[irq].chip_data = data; 245 set_irq_chip_data(irq, data);
253 cpu_interrupt_type.enable(irq); 246 cpu_unmask_irq(irq);
254 } 247 }
255 return 0; 248 return 0;
256} 249}
@@ -368,7 +361,7 @@ void do_cpu_irq_mask(struct pt_regs *regs)
368 goto set_out; 361 goto set_out;
369 } 362 }
370#endif 363#endif
371 __do_IRQ(irq); 364 generic_handle_irq(irq);
372 365
373 out: 366 out:
374 irq_exit(); 367 irq_exit();
@@ -398,14 +391,15 @@ static void claim_cpu_irqs(void)
398{ 391{
399 int i; 392 int i;
400 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) { 393 for (i = CPU_IRQ_BASE; i <= CPU_IRQ_MAX; i++) {
401 irq_desc[i].chip = &cpu_interrupt_type; 394 set_irq_chip_and_handler(i, &cpu_interrupt_type,
395 handle_level_irq);
402 } 396 }
403 397
404 irq_desc[TIMER_IRQ].action = &timer_action; 398 set_irq_handler(TIMER_IRQ, handle_percpu_irq);
405 irq_desc[TIMER_IRQ].status = IRQ_PER_CPU; 399 setup_irq(TIMER_IRQ, &timer_action);
406#ifdef CONFIG_SMP 400#ifdef CONFIG_SMP
407 irq_desc[IPI_IRQ].action = &ipi_action; 401 set_irq_handler(IPI_IRQ, handle_percpu_irq);
408 irq_desc[IPI_IRQ].status = IRQ_PER_CPU; 402 setup_irq(IPI_IRQ, &ipi_action);
409#endif 403#endif
410} 404}
411 405
@@ -423,3 +417,4 @@ void __init init_IRQ(void)
423 set_eiem(cpu_eiem); /* EIEM : enable all external intr */ 417 set_eiem(cpu_eiem); /* EIEM : enable all external intr */
424 418
425} 419}
420
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 1ff366cb9685..66d1f17fdb94 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -12,6 +12,7 @@
12 * Copyright (C) 2001 Helge Deller <deller at parisc-linux.org> 12 * Copyright (C) 2001 Helge Deller <deller at parisc-linux.org>
13 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org> 13 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
14 * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> 14 * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org>
15 * Copyright (C) 2010 Guy Martin <gmsoft at tuxicoman.be>
15 * 16 *
16 * 17 *
17 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
@@ -31,12 +32,11 @@
31 32
32/* 33/*
33 * The PDC console is a simple console, which can be used for debugging 34 * The PDC console is a simple console, which can be used for debugging
34 * boot related problems on HP PA-RISC machines. 35 * boot related problems on HP PA-RISC machines. It is also useful when no
36 * other console works.
35 * 37 *
36 * This code uses the ROM (=PDC) based functions to read and write characters 38 * This code uses the ROM (=PDC) based functions to read and write characters
37 * from and to PDC's boot path. 39 * from and to PDC's boot path.
38 * Since all character read from that path must be polled, this code never
39 * can or will be a fully functional linux console.
40 */ 40 */
41 41
42/* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems. 42/* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems.
@@ -53,6 +53,7 @@
53#include <asm/pdc.h> /* for iodc_call() proto and friends */ 53#include <asm/pdc.h> /* for iodc_call() proto and friends */
54 54
55static DEFINE_SPINLOCK(pdc_console_lock); 55static DEFINE_SPINLOCK(pdc_console_lock);
56static struct console pdc_cons;
56 57
57static void pdc_console_write(struct console *co, const char *s, unsigned count) 58static void pdc_console_write(struct console *co, const char *s, unsigned count)
58{ 59{
@@ -85,12 +86,138 @@ static int pdc_console_setup(struct console *co, char *options)
85 86
86#if defined(CONFIG_PDC_CONSOLE) 87#if defined(CONFIG_PDC_CONSOLE)
87#include <linux/vt_kern.h> 88#include <linux/vt_kern.h>
89#include <linux/tty_flip.h>
90
91#define PDC_CONS_POLL_DELAY (30 * HZ / 1000)
92
93static struct timer_list pdc_console_timer;
94
95extern struct console * console_drivers;
96
97static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
98{
99
100 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
101
102 return 0;
103}
104
105static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
106{
107 if (!tty->count)
108 del_timer(&pdc_console_timer);
109}
110
111static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
112{
113 pdc_console_write(NULL, buf, count);
114 return count;
115}
116
117static int pdc_console_tty_write_room(struct tty_struct *tty)
118{
119 return 32768; /* no limit, no buffer used */
120}
121
122static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty)
123{
124 return 0; /* no buffer */
125}
126
127static struct tty_driver *pdc_console_tty_driver;
128
129static const struct tty_operations pdc_console_tty_ops = {
130 .open = pdc_console_tty_open,
131 .close = pdc_console_tty_close,
132 .write = pdc_console_tty_write,
133 .write_room = pdc_console_tty_write_room,
134 .chars_in_buffer = pdc_console_tty_chars_in_buffer,
135};
136
137static void pdc_console_poll(unsigned long unused)
138{
139
140 int data, count = 0;
141
142 struct tty_struct *tty = pdc_console_tty_driver->ttys[0];
143
144 if (!tty)
145 return;
146
147 while (1) {
148 data = pdc_console_poll_key(NULL);
149 if (data == -1)
150 break;
151 tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL);
152 count ++;
153 }
154
155 if (count)
156 tty_flip_buffer_push(tty);
157
158 if (tty->count && (pdc_cons.flags & CON_ENABLED))
159 mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
160}
161
162static int __init pdc_console_tty_driver_init(void)
163{
164
165 int err;
166 struct tty_driver *drv;
167
168 /* Check if the console driver is still registered.
169 * It is unregistered if the pdc console was not selected as the
170 * primary console. */
171
172 struct console *tmp = console_drivers;
173
174 for (tmp = console_drivers; tmp; tmp = tmp->next)
175 if (tmp == &pdc_cons)
176 break;
177
178 if (!tmp) {
179 printk(KERN_INFO "PDC console driver not registered anymore, not creating %s\n", pdc_cons.name);
180 return -ENODEV;
181 }
182
183 printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
184 pdc_cons.flags &= ~CON_BOOT;
185
186 drv = alloc_tty_driver(1);
187
188 if (!drv)
189 return -ENOMEM;
190
191 drv->driver_name = "pdc_cons";
192 drv->name = "ttyB";
193 drv->major = MUX_MAJOR;
194 drv->minor_start = 0;
195 drv->type = TTY_DRIVER_TYPE_SYSTEM;
196 drv->init_termios = tty_std_termios;
197 drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
198 tty_set_operations(drv, &pdc_console_tty_ops);
199
200 err = tty_register_driver(drv);
201 if (err) {
202 printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
203 return err;
204 }
205
206 pdc_console_tty_driver = drv;
207
208 /* No need to initialize the pdc_console_timer if tty isn't allocated */
209 init_timer(&pdc_console_timer);
210 pdc_console_timer.function = pdc_console_poll;
211
212 return 0;
213}
214
215module_init(pdc_console_tty_driver_init);
88 216
89static struct tty_driver * pdc_console_device (struct console *c, int *index) 217static struct tty_driver * pdc_console_device (struct console *c, int *index)
90{ 218{
91 extern struct tty_driver console_driver; 219 *index = c->index;
92 *index = c->index ? c->index-1 : fg_console; 220 return pdc_console_tty_driver;
93 return &console_driver;
94} 221}
95#else 222#else
96#define pdc_console_device NULL 223#define pdc_console_device NULL
@@ -101,7 +228,7 @@ static struct console pdc_cons = {
101 .write = pdc_console_write, 228 .write = pdc_console_write,
102 .device = pdc_console_device, 229 .device = pdc_console_device,
103 .setup = pdc_console_setup, 230 .setup = pdc_console_setup,
104 .flags = CON_BOOT | CON_PRINTBUFFER | CON_ENABLED, 231 .flags = CON_BOOT | CON_PRINTBUFFER,
105 .index = -1, 232 .index = -1,
106}; 233};
107 234
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/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index c4f49e45129d..2905b1f52d30 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -110,7 +110,8 @@ void user_enable_block_step(struct task_struct *task)
110 pa_psw(task)->l = 0; 110 pa_psw(task)->l = 0;
111} 111}
112 112
113long arch_ptrace(struct task_struct *child, long request, long addr, long data) 113long arch_ptrace(struct task_struct *child, long request,
114 unsigned long addr, unsigned long data)
114{ 115{
115 unsigned long tmp; 116 unsigned long tmp;
116 long ret = -EIO; 117 long ret = -EIO;
@@ -120,11 +121,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
120 /* Read the word at location addr in the USER area. For ptraced 121 /* Read the word at location addr in the USER area. For ptraced
121 processes, the kernel saves all regs on a syscall. */ 122 processes, the kernel saves all regs on a syscall. */
122 case PTRACE_PEEKUSR: 123 case PTRACE_PEEKUSR:
123 if ((addr & (sizeof(long)-1)) || 124 if ((addr & (sizeof(unsigned long)-1)) ||
124 (unsigned long) addr >= sizeof(struct pt_regs)) 125 addr >= sizeof(struct pt_regs))
125 break; 126 break;
126 tmp = *(unsigned long *) ((char *) task_regs(child) + addr); 127 tmp = *(unsigned long *) ((char *) task_regs(child) + addr);
127 ret = put_user(tmp, (unsigned long *) data); 128 ret = put_user(tmp, (unsigned long __user *) data);
128 break; 129 break;
129 130
130 /* Write the word at location addr in the USER area. This will need 131 /* Write the word at location addr in the USER area. This will need
@@ -151,8 +152,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
151 break; 152 break;
152 } 153 }
153 154
154 if ((addr & (sizeof(long)-1)) || 155 if ((addr & (sizeof(unsigned long)-1)) ||
155 (unsigned long) addr >= sizeof(struct pt_regs)) 156 addr >= sizeof(struct pt_regs))
156 break; 157 break;
157 if ((addr >= PT_GR1 && addr <= PT_GR31) || 158 if ((addr >= PT_GR1 && addr <= PT_GR31) ||
158 addr == PT_IAOQ0 || addr == PT_IAOQ1 || 159 addr == PT_IAOQ0 || addr == PT_IAOQ1 ||
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 3d52c978738f..74867dfdabe5 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -419,6 +419,7 @@
419 ENTRY_SAME(perf_event_open) 419 ENTRY_SAME(perf_event_open)
420 ENTRY_COMP(recvmmsg) 420 ENTRY_COMP(recvmmsg)
421 ENTRY_SAME(accept4) /* 320 */ 421 ENTRY_SAME(accept4) /* 320 */
422 ENTRY_SAME(prlimit64)
422 423
423 /* Nothing yet */ 424 /* Nothing yet */
424 425
diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c
index 92d977bb5ea8..234e3682cf09 100644
--- a/arch/parisc/kernel/unaligned.c
+++ b/arch/parisc/kernel/unaligned.c
@@ -619,15 +619,12 @@ void handle_unaligned(struct pt_regs *regs)
619 flop=1; 619 flop=1;
620 ret = emulate_std(regs, R2(regs->iir),1); 620 ret = emulate_std(regs, R2(regs->iir),1);
621 break; 621 break;
622
623#ifdef CONFIG_PA20
624 case OPCODE_LDD_L: 622 case OPCODE_LDD_L:
625 ret = emulate_ldd(regs, R2(regs->iir),0); 623 ret = emulate_ldd(regs, R2(regs->iir),0);
626 break; 624 break;
627 case OPCODE_STD_L: 625 case OPCODE_STD_L:
628 ret = emulate_std(regs, R2(regs->iir),0); 626 ret = emulate_std(regs, R2(regs->iir),0);
629 break; 627 break;
630#endif
631 } 628 }
632#endif 629#endif
633 switch (regs->iir & OPCODE3_MASK) 630 switch (regs->iir & OPCODE3_MASK)
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
index d58eac1a8288..76ed62ed785b 100644
--- a/arch/parisc/kernel/unwind.c
+++ b/arch/parisc/kernel/unwind.c
@@ -80,8 +80,11 @@ find_unwind_entry(unsigned long addr)
80 if (addr >= table->start && 80 if (addr >= table->start &&
81 addr <= table->end) 81 addr <= table->end)
82 e = find_unwind_entry_in_table(table, addr); 82 e = find_unwind_entry_in_table(table, addr);
83 if (e) 83 if (e) {
84 /* Move-to-front to exploit common traces */
85 list_move(&table->list, &unwind_tables);
84 break; 86 break;
87 }
85 } 88 }
86 89
87 return e; 90 return e;
diff --git a/arch/parisc/math-emu/Makefile b/arch/parisc/math-emu/Makefile
index 1f3f225897f5..0bd63b08a79a 100644
--- a/arch/parisc/math-emu/Makefile
+++ b/arch/parisc/math-emu/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# See arch/parisc/math-emu/README 5# See arch/parisc/math-emu/README
6EXTRA_CFLAGS += -Wno-parentheses -Wno-implicit-function-declaration \ 6ccflags-y := -Wno-parentheses -Wno-implicit-function-declaration \
7 -Wno-uninitialized -Wno-strict-prototypes -Wno-return-type \ 7 -Wno-uninitialized -Wno-strict-prototypes -Wno-return-type \
8 -Wno-implicit-int 8 -Wno-implicit-int
9 9
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4b1e521d966f..b6447190e1a2 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -1,9 +1,3 @@
1# For a description of the syntax of this configuration file,
2# see Documentation/kbuild/kconfig-language.txt.
3#
4
5mainmenu "Linux/PowerPC Kernel Configuration"
6
7source "arch/powerpc/platforms/Kconfig.cputype" 1source "arch/powerpc/platforms/Kconfig.cputype"
8 2
9config PPC32 3config PPC32
@@ -688,9 +682,12 @@ config 4xx_SOC
688 bool 682 bool
689 683
690config FSL_LBC 684config FSL_LBC
691 bool 685 bool "Freescale Local Bus support"
686 depends on FSL_SOC
692 help 687 help
693 Freescale Localbus support 688 Enables reporting of errors from the Freescale local bus
689 controller. Also contains some common code used by
690 drivers for specific local bus peripherals.
694 691
695config FSL_GTM 692config FSL_GTM
696 bool 693 bool
diff --git a/arch/powerpc/boot/dts/mpc8610_hpcd.dts b/arch/powerpc/boot/dts/mpc8610_hpcd.dts
index 9535ce68caae..83c3218cb4da 100644
--- a/arch/powerpc/boot/dts/mpc8610_hpcd.dts
+++ b/arch/powerpc/boot/dts/mpc8610_hpcd.dts
@@ -286,6 +286,7 @@
286 286
287 ssi@16100 { 287 ssi@16100 {
288 compatible = "fsl,mpc8610-ssi"; 288 compatible = "fsl,mpc8610-ssi";
289 status = "disabled";
289 cell-index = <1>; 290 cell-index = <1>;
290 reg = <0x16100 0x100>; 291 reg = <0x16100 0x100>;
291 interrupt-parent = <&mpic>; 292 interrupt-parent = <&mpic>;
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig
index c3b113b2ca31..3aeb5949cfef 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -124,6 +124,9 @@ CONFIG_I2C_CPM=m
124CONFIG_I2C_MPC=y 124CONFIG_I2C_MPC=y
125# CONFIG_HWMON is not set 125# CONFIG_HWMON is not set
126CONFIG_VIDEO_OUTPUT_CONTROL=y 126CONFIG_VIDEO_OUTPUT_CONTROL=y
127CONFIG_FB=y
128CONFIG_FB_FSL_DIU=y
129# CONFIG_VGA_CONSOLE is not set
127CONFIG_SOUND=y 130CONFIG_SOUND=y
128CONFIG_SND=y 131CONFIG_SND=y
129# CONFIG_SND_SUPPORT_OLD_API is not set 132# CONFIG_SND_SUPPORT_OLD_API is not set
diff --git a/arch/powerpc/configs/mpc85xx_smp_defconfig b/arch/powerpc/configs/mpc85xx_smp_defconfig
index a075da2ea3fb..d62c8016f4bc 100644
--- a/arch/powerpc/configs/mpc85xx_smp_defconfig
+++ b/arch/powerpc/configs/mpc85xx_smp_defconfig
@@ -126,6 +126,9 @@ CONFIG_I2C_CPM=m
126CONFIG_I2C_MPC=y 126CONFIG_I2C_MPC=y
127# CONFIG_HWMON is not set 127# CONFIG_HWMON is not set
128CONFIG_VIDEO_OUTPUT_CONTROL=y 128CONFIG_VIDEO_OUTPUT_CONTROL=y
129CONFIG_FB=y
130CONFIG_FB_FSL_DIU=y
131# CONFIG_VGA_CONSOLE is not set
129CONFIG_SOUND=y 132CONFIG_SOUND=y
130CONFIG_SND=y 133CONFIG_SND=y
131# CONFIG_SND_SUPPORT_OLD_API is not set 134# CONFIG_SND_SUPPORT_OLD_API is not set
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 8bdc6a9e5773..1cf20bdfbeca 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -124,23 +124,23 @@ static inline u64 cputime64_to_jiffies64(const cputime_t ct)
124} 124}
125 125
126/* 126/*
127 * Convert cputime <-> milliseconds 127 * Convert cputime <-> microseconds
128 */ 128 */
129extern u64 __cputime_msec_factor; 129extern u64 __cputime_msec_factor;
130 130
131static inline unsigned long cputime_to_msecs(const cputime_t ct) 131static inline unsigned long cputime_to_usecs(const cputime_t ct)
132{ 132{
133 return mulhdu(ct, __cputime_msec_factor); 133 return mulhdu(ct, __cputime_msec_factor) * USEC_PER_MSEC;
134} 134}
135 135
136static inline cputime_t msecs_to_cputime(const unsigned long ms) 136static inline cputime_t usecs_to_cputime(const unsigned long us)
137{ 137{
138 cputime_t ct; 138 cputime_t ct;
139 unsigned long sec; 139 unsigned long sec;
140 140
141 /* have to be a little careful about overflow */ 141 /* have to be a little careful about overflow */
142 ct = ms % 1000; 142 ct = us % 1000000;
143 sec = ms / 1000; 143 sec = us / 1000000;
144 if (ct) { 144 if (ct) {
145 ct *= tb_ticks_per_sec; 145 ct *= tb_ticks_per_sec;
146 do_div(ct, 1000); 146 do_div(ct, 1000);
diff --git a/arch/powerpc/include/asm/immap_86xx.h b/arch/powerpc/include/asm/fsl_guts.h
index 0f165e59c326..bebd12463ec9 100644
--- a/arch/powerpc/include/asm/immap_86xx.h
+++ b/arch/powerpc/include/asm/fsl_guts.h
@@ -1,5 +1,5 @@
1/** 1/**
2 * MPC86xx Internal Memory Map 2 * Freecale 85xx and 86xx Global Utilties register set
3 * 3 *
4 * Authors: Jeff Brown 4 * Authors: Jeff Brown
5 * Timur Tabi <timur@freescale.com> 5 * Timur Tabi <timur@freescale.com>
@@ -10,73 +10,112 @@
10 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 *
14 * This header file defines structures for various 86xx SOC devices that are
15 * used by multiple source files.
16 */ 13 */
17 14
18#ifndef __ASM_POWERPC_IMMAP_86XX_H__ 15#ifndef __ASM_POWERPC_FSL_GUTS_H__
19#define __ASM_POWERPC_IMMAP_86XX_H__ 16#define __ASM_POWERPC_FSL_GUTS_H__
20#ifdef __KERNEL__ 17#ifdef __KERNEL__
21 18
22/* Global Utility Registers */ 19/*
23struct ccsr_guts { 20 * These #ifdefs are safe because it's not possible to build a kernel that
21 * runs on e500 and e600 cores.
22 */
23
24#if !defined(CONFIG_PPC_85xx) && !defined(CONFIG_PPC_86xx)
25#error Only 85xx and 86xx SOCs are supported
26#endif
27
28/**
29 * Global Utility Registers.
30 *
31 * Not all registers defined in this structure are available on all chips, so
32 * you are expected to know whether a given register actually exists on your
33 * chip before you access it.
34 *
35 * Also, some registers are similar on different chips but have slightly
36 * different names. In these cases, one name is chosen to avoid extraneous
37 * #ifdefs.
38 */
39#ifdef CONFIG_PPC_85xx
40struct ccsr_guts_85xx {
41#else
42struct ccsr_guts_86xx {
43#endif
24 __be32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */ 44 __be32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */
25 __be32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */ 45 __be32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */
26 __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */ 46 __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */
27 __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */ 47 __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */
28 __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */ 48 __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */
29 u8 res1[0x20 - 0x14]; 49 __be32 pordevsr2; /* 0x.0014 - POR device status register 2 */
50 u8 res018[0x20 - 0x18];
30 __be32 porcir; /* 0x.0020 - POR Configuration Information Register */ 51 __be32 porcir; /* 0x.0020 - POR Configuration Information Register */
31 u8 res2[0x30 - 0x24]; 52 u8 res024[0x30 - 0x24];
32 __be32 gpiocr; /* 0x.0030 - GPIO Control Register */ 53 __be32 gpiocr; /* 0x.0030 - GPIO Control Register */
33 u8 res3[0x40 - 0x34]; 54 u8 res034[0x40 - 0x34];
34 __be32 gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */ 55 __be32 gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */
35 u8 res4[0x50 - 0x44]; 56 u8 res044[0x50 - 0x44];
36 __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */ 57 __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */
37 u8 res5[0x60 - 0x54]; 58 u8 res054[0x60 - 0x54];
38 __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */ 59 __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */
39 u8 res6[0x70 - 0x64]; 60 __be32 pmuxcr2; /* 0x.0064 - Alternate function signal multiplex control 2 */
61 __be32 dmuxcr; /* 0x.0068 - DMA Mux Control Register */
62 u8 res06c[0x70 - 0x6c];
40 __be32 devdisr; /* 0x.0070 - Device Disable Control */ 63 __be32 devdisr; /* 0x.0070 - Device Disable Control */
41 __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ 64 __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */
42 u8 res7[0x80 - 0x78]; 65 u8 res078[0x7c - 0x78];
66 __be32 pmjcr; /* 0x.007c - 4 Power Management Jog Control Register */
43 __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */ 67 __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */
44 u8 res8[0x90 - 0x84]; 68 __be32 pmrccr; /* 0x.0084 - Power Management Reset Counter Configuration Register */
69 __be32 pmpdccr; /* 0x.0088 - Power Management Power Down Counter Configuration Register */
70 __be32 pmcdr; /* 0x.008c - 4Power management clock disable register */
45 __be32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */ 71 __be32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */
46 __be32 rstrscr; /* 0x.0094 - Reset Request Status and Control Register */ 72 __be32 rstrscr; /* 0x.0094 - Reset Request Status and Control Register */
47 u8 res9[0xA0 - 0x98]; 73 __be32 ectrstcr; /* 0x.0098 - Exception reset control register */
74 __be32 autorstsr; /* 0x.009c - Automatic reset status register */
48 __be32 pvr; /* 0x.00a0 - Processor Version Register */ 75 __be32 pvr; /* 0x.00a0 - Processor Version Register */
49 __be32 svr; /* 0x.00a4 - System Version Register */ 76 __be32 svr; /* 0x.00a4 - System Version Register */
50 u8 res10[0xB0 - 0xA8]; 77 u8 res0a8[0xb0 - 0xa8];
51 __be32 rstcr; /* 0x.00b0 - Reset Control Register */ 78 __be32 rstcr; /* 0x.00b0 - Reset Control Register */
52 u8 res11[0xC0 - 0xB4]; 79 u8 res0b4[0xc0 - 0xb4];
80#ifdef CONFIG_PPC_85xx
81 __be32 iovselsr; /* 0x.00c0 - I/O voltage select status register */
82#else
53 __be32 elbcvselcr; /* 0x.00c0 - eLBC Voltage Select Ctrl Reg */ 83 __be32 elbcvselcr; /* 0x.00c0 - eLBC Voltage Select Ctrl Reg */
54 u8 res12[0x800 - 0xC4]; 84#endif
85 u8 res0c4[0x224 - 0xc4];
86 __be32 iodelay1; /* 0x.0224 - IO delay control register 1 */
87 __be32 iodelay2; /* 0x.0228 - IO delay control register 2 */
88 u8 res22c[0x800 - 0x22c];
55 __be32 clkdvdr; /* 0x.0800 - Clock Divide Register */ 89 __be32 clkdvdr; /* 0x.0800 - Clock Divide Register */
56 u8 res13[0x900 - 0x804]; 90 u8 res804[0x900 - 0x804];
57 __be32 ircr; /* 0x.0900 - Infrared Control Register */ 91 __be32 ircr; /* 0x.0900 - Infrared Control Register */
58 u8 res14[0x908 - 0x904]; 92 u8 res904[0x908 - 0x904];
59 __be32 dmacr; /* 0x.0908 - DMA Control Register */ 93 __be32 dmacr; /* 0x.0908 - DMA Control Register */
60 u8 res15[0x914 - 0x90C]; 94 u8 res90c[0x914 - 0x90c];
61 __be32 elbccr; /* 0x.0914 - eLBC Control Register */ 95 __be32 elbccr; /* 0x.0914 - eLBC Control Register */
62 u8 res16[0xB20 - 0x918]; 96 u8 res918[0xb20 - 0x918];
63 __be32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */ 97 __be32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */
64 __be32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */ 98 __be32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */
65 __be32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */ 99 __be32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */
66 u8 res17[0xE00 - 0xB2C]; 100 u8 resb2c[0xe00 - 0xb2c];
67 __be32 clkocr; /* 0x.0e00 - Clock Out Select Register */ 101 __be32 clkocr; /* 0x.0e00 - Clock Out Select Register */
68 u8 res18[0xE10 - 0xE04]; 102 u8 rese04[0xe10 - 0xe04];
69 __be32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */ 103 __be32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */
70 u8 res19[0xE20 - 0xE14]; 104 u8 rese14[0xe20 - 0xe14];
71 __be32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */ 105 __be32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */
72 u8 res20[0xF04 - 0xE24]; 106 __be32 cpfor; /* 0x.0e24 - L2 charge pump fuse override register */
107 u8 rese28[0xf04 - 0xe28];
73 __be32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */ 108 __be32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */
74 __be32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */ 109 __be32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */
75 u8 res21[0xF40 - 0xF0C]; 110 u8 resf0c[0xf2c - 0xf0c];
76 __be32 srds2cr0; /* 0x.0f40 - SerDes1 Control Register 0 */ 111 __be32 itcr; /* 0x.0f2c - Internal transaction control register */
77 __be32 srds2cr1; /* 0x.0f44 - SerDes1 Control Register 0 */ 112 u8 resf30[0xf40 - 0xf30];
113 __be32 srds2cr0; /* 0x.0f40 - SerDes2 Control Register 0 */
114 __be32 srds2cr1; /* 0x.0f44 - SerDes2 Control Register 0 */
78} __attribute__ ((packed)); 115} __attribute__ ((packed));
79 116
117#ifdef CONFIG_PPC_86xx
118
80#define CCSR_GUTS_DMACR_DEV_SSI 0 /* DMA controller/channel set to SSI */ 119#define CCSR_GUTS_DMACR_DEV_SSI 0 /* DMA controller/channel set to SSI */
81#define CCSR_GUTS_DMACR_DEV_IR 1 /* DMA controller/channel set to IR */ 120#define CCSR_GUTS_DMACR_DEV_IR 1 /* DMA controller/channel set to IR */
82 121
@@ -93,7 +132,7 @@ struct ccsr_guts {
93 * ch: The channel on the DMA controller (0, 1, 2, or 3) 132 * ch: The channel on the DMA controller (0, 1, 2, or 3)
94 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx) 133 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx)
95 */ 134 */
96static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts, 135static inline void guts_set_dmacr(struct ccsr_guts_86xx __iomem *guts,
97 unsigned int co, unsigned int ch, unsigned int device) 136 unsigned int co, unsigned int ch, unsigned int device)
98{ 137{
99 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch)); 138 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch));
@@ -129,7 +168,7 @@ static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts,
129 * ch: The channel on the DMA controller (0, 1, 2, or 3) 168 * ch: The channel on the DMA controller (0, 1, 2, or 3)
130 * value: the new value for the bit (0 or 1) 169 * value: the new value for the bit (0 or 1)
131 */ 170 */
132static inline void guts_set_pmuxcr_dma(struct ccsr_guts __iomem *guts, 171static inline void guts_set_pmuxcr_dma(struct ccsr_guts_86xx __iomem *guts,
133 unsigned int co, unsigned int ch, unsigned int value) 172 unsigned int co, unsigned int ch, unsigned int value)
134{ 173{
135 if ((ch == 0) || (ch == 3)) { 174 if ((ch == 0) || (ch == 3)) {
@@ -152,5 +191,7 @@ static inline void guts_set_pmuxcr_dma(struct ccsr_guts __iomem *guts,
152#define CCSR_GUTS_CLKDVDR_SSICLK_MASK 0x000000FF 191#define CCSR_GUTS_CLKDVDR_SSICLK_MASK 0x000000FF
153#define CCSR_GUTS_CLKDVDR_SSICLK(x) ((x) & CCSR_GUTS_CLKDVDR_SSICLK_MASK) 192#define CCSR_GUTS_CLKDVDR_SSICLK(x) ((x) & CCSR_GUTS_CLKDVDR_SSICLK_MASK)
154 193
155#endif /* __ASM_POWERPC_IMMAP_86XX_H__ */ 194#endif
156#endif /* __KERNEL__ */ 195
196#endif
197#endif
diff --git a/arch/powerpc/include/asm/fsl_lbc.h b/arch/powerpc/include/asm/fsl_lbc.h
index 1b5a21041f9b..5c1bf3466749 100644
--- a/arch/powerpc/include/asm/fsl_lbc.h
+++ b/arch/powerpc/include/asm/fsl_lbc.h
@@ -1,9 +1,10 @@
1/* Freescale Local Bus Controller 1/* Freescale Local Bus Controller
2 * 2 *
3 * Copyright (c) 2006-2007 Freescale Semiconductor 3 * Copyright © 2006-2007, 2010 Freescale Semiconductor
4 * 4 *
5 * Authors: Nick Spence <nick.spence@freescale.com>, 5 * Authors: Nick Spence <nick.spence@freescale.com>,
6 * Scott Wood <scottwood@freescale.com> 6 * Scott Wood <scottwood@freescale.com>
7 * Jack Lan <jack.lan@freescale.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * 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 * it under the terms of the GNU General Public License as published by
@@ -26,6 +27,8 @@
26#include <linux/compiler.h> 27#include <linux/compiler.h>
27#include <linux/types.h> 28#include <linux/types.h>
28#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/device.h>
31#include <linux/spinlock.h>
29 32
30struct fsl_lbc_bank { 33struct fsl_lbc_bank {
31 __be32 br; /**< Base Register */ 34 __be32 br; /**< Base Register */
@@ -125,13 +128,23 @@ struct fsl_lbc_regs {
125#define LTESR_ATMW 0x00800000 128#define LTESR_ATMW 0x00800000
126#define LTESR_ATMR 0x00400000 129#define LTESR_ATMR 0x00400000
127#define LTESR_CS 0x00080000 130#define LTESR_CS 0x00080000
131#define LTESR_UPM 0x00000002
128#define LTESR_CC 0x00000001 132#define LTESR_CC 0x00000001
129#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC) 133#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC)
134#define LTESR_MASK (LTESR_BM | LTESR_FCT | LTESR_PAR | LTESR_WP \
135 | LTESR_ATMW | LTESR_ATMR | LTESR_CS | LTESR_UPM \
136 | LTESR_CC)
137#define LTESR_CLEAR 0xFFFFFFFF
138#define LTECCR_CLEAR 0xFFFFFFFF
139#define LTESR_STATUS LTESR_MASK
140#define LTEIR_ENABLE LTESR_MASK
141#define LTEDR_ENABLE 0x00000000
130 __be32 ltedr; /**< Transfer Error Disable Register */ 142 __be32 ltedr; /**< Transfer Error Disable Register */
131 __be32 lteir; /**< Transfer Error Interrupt Register */ 143 __be32 lteir; /**< Transfer Error Interrupt Register */
132 __be32 lteatr; /**< Transfer Error Attributes Register */ 144 __be32 lteatr; /**< Transfer Error Attributes Register */
133 __be32 ltear; /**< Transfer Error Address Register */ 145 __be32 ltear; /**< Transfer Error Address Register */
134 u8 res6[0xC]; 146 __be32 lteccr; /**< Transfer Error ECC Register */
147 u8 res6[0x8];
135 __be32 lbcr; /**< Configuration Register */ 148 __be32 lbcr; /**< Configuration Register */
136#define LBCR_LDIS 0x80000000 149#define LBCR_LDIS 0x80000000
137#define LBCR_LDIS_SHIFT 31 150#define LBCR_LDIS_SHIFT 31
@@ -235,6 +248,7 @@ struct fsl_upm {
235 int width; 248 int width;
236}; 249};
237 250
251extern u32 fsl_lbc_addr(phys_addr_t addr_base);
238extern int fsl_lbc_find(phys_addr_t addr_base); 252extern int fsl_lbc_find(phys_addr_t addr_base);
239extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm); 253extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm);
240 254
@@ -265,7 +279,23 @@ static inline void fsl_upm_end_pattern(struct fsl_upm *upm)
265 cpu_relax(); 279 cpu_relax();
266} 280}
267 281
282/* overview of the fsl lbc controller */
283
284struct fsl_lbc_ctrl {
285 /* device info */
286 struct device *dev;
287 struct fsl_lbc_regs __iomem *regs;
288 int irq;
289 wait_queue_head_t irq_wait;
290 spinlock_t lock;
291 void *nand;
292
293 /* status read from LTESR by irq handler */
294 unsigned int irq_status;
295};
296
268extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, 297extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base,
269 u32 mar); 298 u32 mar);
299extern struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
270 300
271#endif /* __ASM_FSL_LBC_H */ 301#endif /* __ASM_FSL_LBC_H */
diff --git a/arch/powerpc/include/asm/fsldma.h b/arch/powerpc/include/asm/fsldma.h
deleted file mode 100644
index debc5ed96d6e..000000000000
--- a/arch/powerpc/include/asm/fsldma.h
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * Freescale MPC83XX / MPC85XX DMA Controller
3 *
4 * Copyright (c) 2009 Ira W. Snyder <iws@ovro.caltech.edu>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#ifndef __ARCH_POWERPC_ASM_FSLDMA_H__
12#define __ARCH_POWERPC_ASM_FSLDMA_H__
13
14#include <linux/slab.h>
15#include <linux/dmaengine.h>
16
17/*
18 * Definitions for the Freescale DMA controller's DMA_SLAVE implemention
19 *
20 * The Freescale DMA_SLAVE implementation was designed to handle many-to-many
21 * transfers. An example usage would be an accelerated copy between two
22 * scatterlists. Another example use would be an accelerated copy from
23 * multiple non-contiguous device buffers into a single scatterlist.
24 *
25 * A DMA_SLAVE transaction is defined by a struct fsl_dma_slave. This
26 * structure contains a list of hardware addresses that should be copied
27 * to/from the scatterlist passed into device_prep_slave_sg(). The structure
28 * also has some fields to enable hardware-specific features.
29 */
30
31/**
32 * struct fsl_dma_hw_addr
33 * @entry: linked list entry
34 * @address: the hardware address
35 * @length: length to transfer
36 *
37 * Holds a single physical hardware address / length pair for use
38 * with the DMAEngine DMA_SLAVE API.
39 */
40struct fsl_dma_hw_addr {
41 struct list_head entry;
42
43 dma_addr_t address;
44 size_t length;
45};
46
47/**
48 * struct fsl_dma_slave
49 * @addresses: a linked list of struct fsl_dma_hw_addr structures
50 * @request_count: value for DMA request count
51 * @src_loop_size: setup and enable constant source-address DMA transfers
52 * @dst_loop_size: setup and enable constant destination address DMA transfers
53 * @external_start: enable externally started DMA transfers
54 * @external_pause: enable externally paused DMA transfers
55 *
56 * Holds a list of address / length pairs for use with the DMAEngine
57 * DMA_SLAVE API implementation for the Freescale DMA controller.
58 */
59struct fsl_dma_slave {
60
61 /* List of hardware address/length pairs */
62 struct list_head addresses;
63
64 /* Support for extra controller features */
65 unsigned int request_count;
66 unsigned int src_loop_size;
67 unsigned int dst_loop_size;
68 bool external_start;
69 bool external_pause;
70};
71
72/**
73 * fsl_dma_slave_append - add an address/length pair to a struct fsl_dma_slave
74 * @slave: the &struct fsl_dma_slave to add to
75 * @address: the hardware address to add
76 * @length: the length of bytes to transfer from @address
77 *
78 * Add a hardware address/length pair to a struct fsl_dma_slave. Returns 0 on
79 * success, -ERRNO otherwise.
80 */
81static inline int fsl_dma_slave_append(struct fsl_dma_slave *slave,
82 dma_addr_t address, size_t length)
83{
84 struct fsl_dma_hw_addr *addr;
85
86 addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
87 if (!addr)
88 return -ENOMEM;
89
90 INIT_LIST_HEAD(&addr->entry);
91 addr->address = address;
92 addr->length = length;
93
94 list_add_tail(&addr->entry, &slave->addresses);
95 return 0;
96}
97
98/**
99 * fsl_dma_slave_free - free a struct fsl_dma_slave
100 * @slave: the struct fsl_dma_slave to free
101 *
102 * Free a struct fsl_dma_slave and all associated address/length pairs
103 */
104static inline void fsl_dma_slave_free(struct fsl_dma_slave *slave)
105{
106 struct fsl_dma_hw_addr *addr, *tmp;
107
108 if (slave) {
109 list_for_each_entry_safe(addr, tmp, &slave->addresses, entry) {
110 list_del(&addr->entry);
111 kfree(addr);
112 }
113
114 kfree(slave);
115 }
116}
117
118/**
119 * fsl_dma_slave_alloc - allocate a struct fsl_dma_slave
120 * @gfp: the flags to pass to kmalloc when allocating this structure
121 *
122 * Allocate a struct fsl_dma_slave for use by the DMA_SLAVE API. Returns a new
123 * struct fsl_dma_slave on success, or NULL on failure.
124 */
125static inline struct fsl_dma_slave *fsl_dma_slave_alloc(gfp_t gfp)
126{
127 struct fsl_dma_slave *slave;
128
129 slave = kzalloc(sizeof(*slave), gfp);
130 if (!slave)
131 return NULL;
132
133 INIT_LIST_HEAD(&slave->addresses);
134 return slave;
135}
136
137#endif /* __ARCH_POWERPC_ASM_FSLDMA_H__ */
diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h
index d10d64a4be38..dbc264010d0b 100644
--- a/arch/powerpc/include/asm/highmem.h
+++ b/arch/powerpc/include/asm/highmem.h
@@ -60,9 +60,8 @@ extern pte_t *pkmap_page_table;
60 60
61extern void *kmap_high(struct page *page); 61extern void *kmap_high(struct page *page);
62extern void kunmap_high(struct page *page); 62extern void kunmap_high(struct page *page);
63extern void *kmap_atomic_prot(struct page *page, enum km_type type, 63extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
64 pgprot_t prot); 64extern void __kunmap_atomic(void *kvaddr);
65extern void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type);
66 65
67static inline void *kmap(struct page *page) 66static inline void *kmap(struct page *page)
68{ 67{
@@ -80,9 +79,9 @@ static inline void kunmap(struct page *page)
80 kunmap_high(page); 79 kunmap_high(page);
81} 80}
82 81
83static inline void *kmap_atomic(struct page *page, enum km_type type) 82static inline void *__kmap_atomic(struct page *page)
84{ 83{
85 return kmap_atomic_prot(page, type, kmap_prot); 84 return kmap_atomic_prot(page, kmap_prot);
86} 85}
87 86
88static inline struct page *kmap_atomic_to_page(void *ptr) 87static inline struct page *kmap_atomic_to_page(void *ptr)
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/kgdb.h b/arch/powerpc/include/asm/kgdb.h
index edd217006d27..9db24e77b9f4 100644
--- a/arch/powerpc/include/asm/kgdb.h
+++ b/arch/powerpc/include/asm/kgdb.h
@@ -31,6 +31,7 @@ static inline void arch_kgdb_breakpoint(void)
31 asm(".long 0x7d821008"); /* twge r2, r2 */ 31 asm(".long 0x7d821008"); /* twge r2, r2 */
32} 32}
33#define CACHE_FLUSH_IS_SAFE 1 33#define CACHE_FLUSH_IS_SAFE 1
34#define DBG_MAX_REG_NUM 70
34 35
35/* The number bytes of registers we have to save depends on a few 36/* The number bytes of registers we have to save depends on a few
36 * things. For 64bit we default to not including vector registers and 37 * things. For 64bit we default to not including vector registers and
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_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/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index a7db96f2b5c3..47edde8c3556 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -308,12 +308,8 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
308#define pte_offset_kernel(dir, addr) \ 308#define pte_offset_kernel(dir, addr) \
309 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr)) 309 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
310#define pte_offset_map(dir, addr) \ 310#define pte_offset_map(dir, addr) \
311 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) 311 ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
312#define pte_offset_map_nested(dir, addr) \ 312#define pte_unmap(pte) kunmap_atomic(pte)
313 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
314
315#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
316#define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1)
317 313
318/* 314/*
319 * Encode and decode a swap entry. 315 * Encode and decode a swap entry.
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index 49865045d56f..2b09cd522d33 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -193,9 +193,7 @@
193 (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) 193 (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
194 194
195#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr)) 195#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
196#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
197#define pte_unmap(pte) do { } while(0) 196#define pte_unmap(pte) do { } while(0)
198#define pte_unmap_nested(pte) do { } while(0)
199 197
200/* to find an entry in a kernel page-table-directory */ 198/* to find an entry in a kernel page-table-directory */
201/* This now only contains the vmalloc pages */ 199/* This now only contains the vmalloc pages */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 4ed076a4db24..36c30f31ec93 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -129,6 +129,8 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),)
129obj-y += ppc_save_regs.o 129obj-y += ppc_save_regs.o
130endif 130endif
131 131
132obj-$(CONFIG_KVM_GUEST) += kvm.o kvm_emul.o
133
132# Disable GCOV in odd or sensitive code 134# Disable GCOV in odd or sensitive code
133GCOV_PROFILE_prom_init.o := n 135GCOV_PROFILE_prom_init.o := n
134GCOV_PROFILE_ftrace.o := n 136GCOV_PROFILE_ftrace.o := n
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index c3e01945ad4f..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
@@ -396,12 +396,13 @@ int main(void)
396 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 396 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack));
397 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 397 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
398 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 398 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr));
399 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.msr));
400 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4)); 399 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4));
401 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 400 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5));
402 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 401 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6));
403 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); 402 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7));
404 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));
405 406
406 /* book3s */ 407 /* book3s */
407#ifdef CONFIG_PPC_BOOK3S 408#ifdef CONFIG_PPC_BOOK3S
@@ -466,6 +467,22 @@ int main(void)
466 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); 467 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr));
467#endif /* CONFIG_PPC_BOOK3S */ 468#endif /* CONFIG_PPC_BOOK3S */
468#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
469#ifdef CONFIG_44x 486#ifdef CONFIG_44x
470 DEFINE(PGD_T_LOG2, PGD_T_LOG2); 487 DEFINE(PGD_T_LOG2, PGD_T_LOG2);
471 DEFINE(PTE_T_LOG2, PTE_T_LOG2); 488 DEFINE(PTE_T_LOG2, PTE_T_LOG2);
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 39b0c48872d2..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:
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/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/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 7f61a3ac787c..7a9db64f3f04 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -194,40 +194,6 @@ static int kgdb_dabr_match(struct pt_regs *regs)
194 ptr = (unsigned long *)ptr32; \ 194 ptr = (unsigned long *)ptr32; \
195 } while (0) 195 } while (0)
196 196
197
198void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
199{
200 unsigned long *ptr = gdb_regs;
201 int reg;
202
203 memset(gdb_regs, 0, NUMREGBYTES);
204
205 for (reg = 0; reg < 32; reg++)
206 PACK64(ptr, regs->gpr[reg]);
207
208#ifdef CONFIG_FSL_BOOKE
209#ifdef CONFIG_SPE
210 for (reg = 0; reg < 32; reg++)
211 PACK64(ptr, current->thread.evr[reg]);
212#else
213 ptr += 32;
214#endif
215#else
216 /* fp registers not used by kernel, leave zero */
217 ptr += 32 * 8 / sizeof(long);
218#endif
219
220 PACK64(ptr, regs->nip);
221 PACK64(ptr, regs->msr);
222 PACK32(ptr, regs->ccr);
223 PACK64(ptr, regs->link);
224 PACK64(ptr, regs->ctr);
225 PACK32(ptr, regs->xer);
226
227 BUG_ON((unsigned long)ptr >
228 (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
229}
230
231void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) 197void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
232{ 198{
233 struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp + 199 struct pt_regs *regs = (struct pt_regs *)(p->thread.ksp +
@@ -271,44 +237,140 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
271 (unsigned long)(((void *)gdb_regs) + NUMREGBYTES)); 237 (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
272} 238}
273 239
274#define UNPACK64(dest, ptr) do { dest = *(ptr++); } while (0) 240#define GDB_SIZEOF_REG sizeof(unsigned long)
241#define GDB_SIZEOF_REG_U32 sizeof(u32)
275 242
276#define UNPACK32(dest, ptr) do { \ 243#ifdef CONFIG_FSL_BOOKE
277 u32 *ptr32; \ 244#define GDB_SIZEOF_FLOAT_REG sizeof(unsigned long)
278 ptr32 = (u32 *)ptr; \ 245#else
279 dest = *(ptr32++); \ 246#define GDB_SIZEOF_FLOAT_REG sizeof(u64)
280 ptr = (unsigned long *)ptr32; \ 247#endif
281 } while (0)
282 248
283void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) 249struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
284{ 250{
285 unsigned long *ptr = gdb_regs; 251 { "r0", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[0]) },
286 int reg; 252 { "r1", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[1]) },
287 253 { "r2", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[2]) },
288 for (reg = 0; reg < 32; reg++) 254 { "r3", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[3]) },
289 UNPACK64(regs->gpr[reg], ptr); 255 { "r4", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[4]) },
256 { "r5", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[5]) },
257 { "r6", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[6]) },
258 { "r7", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[7]) },
259 { "r8", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[8]) },
260 { "r9", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[9]) },
261 { "r10", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[10]) },
262 { "r11", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[11]) },
263 { "r12", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[12]) },
264 { "r13", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[13]) },
265 { "r14", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[14]) },
266 { "r15", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[15]) },
267 { "r16", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[16]) },
268 { "r17", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[17]) },
269 { "r18", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[18]) },
270 { "r19", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[19]) },
271 { "r20", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[20]) },
272 { "r21", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[21]) },
273 { "r22", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[22]) },
274 { "r23", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[23]) },
275 { "r24", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[24]) },
276 { "r25", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[25]) },
277 { "r26", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[26]) },
278 { "r27", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[27]) },
279 { "r28", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[28]) },
280 { "r29", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[29]) },
281 { "r30", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[30]) },
282 { "r31", GDB_SIZEOF_REG, offsetof(struct pt_regs, gpr[31]) },
283
284 { "f0", GDB_SIZEOF_FLOAT_REG, 0 },
285 { "f1", GDB_SIZEOF_FLOAT_REG, 1 },
286 { "f2", GDB_SIZEOF_FLOAT_REG, 2 },
287 { "f3", GDB_SIZEOF_FLOAT_REG, 3 },
288 { "f4", GDB_SIZEOF_FLOAT_REG, 4 },
289 { "f5", GDB_SIZEOF_FLOAT_REG, 5 },
290 { "f6", GDB_SIZEOF_FLOAT_REG, 6 },
291 { "f7", GDB_SIZEOF_FLOAT_REG, 7 },
292 { "f8", GDB_SIZEOF_FLOAT_REG, 8 },
293 { "f9", GDB_SIZEOF_FLOAT_REG, 9 },
294 { "f10", GDB_SIZEOF_FLOAT_REG, 10 },
295 { "f11", GDB_SIZEOF_FLOAT_REG, 11 },
296 { "f12", GDB_SIZEOF_FLOAT_REG, 12 },
297 { "f13", GDB_SIZEOF_FLOAT_REG, 13 },
298 { "f14", GDB_SIZEOF_FLOAT_REG, 14 },
299 { "f15", GDB_SIZEOF_FLOAT_REG, 15 },
300 { "f16", GDB_SIZEOF_FLOAT_REG, 16 },
301 { "f17", GDB_SIZEOF_FLOAT_REG, 17 },
302 { "f18", GDB_SIZEOF_FLOAT_REG, 18 },
303 { "f19", GDB_SIZEOF_FLOAT_REG, 19 },
304 { "f20", GDB_SIZEOF_FLOAT_REG, 20 },
305 { "f21", GDB_SIZEOF_FLOAT_REG, 21 },
306 { "f22", GDB_SIZEOF_FLOAT_REG, 22 },
307 { "f23", GDB_SIZEOF_FLOAT_REG, 23 },
308 { "f24", GDB_SIZEOF_FLOAT_REG, 24 },
309 { "f25", GDB_SIZEOF_FLOAT_REG, 25 },
310 { "f26", GDB_SIZEOF_FLOAT_REG, 26 },
311 { "f27", GDB_SIZEOF_FLOAT_REG, 27 },
312 { "f28", GDB_SIZEOF_FLOAT_REG, 28 },
313 { "f29", GDB_SIZEOF_FLOAT_REG, 29 },
314 { "f30", GDB_SIZEOF_FLOAT_REG, 30 },
315 { "f31", GDB_SIZEOF_FLOAT_REG, 31 },
316
317 { "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, nip) },
318 { "msr", GDB_SIZEOF_REG, offsetof(struct pt_regs, msr) },
319 { "cr", GDB_SIZEOF_REG_U32, offsetof(struct pt_regs, ccr) },
320 { "lr", GDB_SIZEOF_REG, offsetof(struct pt_regs, link) },
321 { "ctr", GDB_SIZEOF_REG_U32, offsetof(struct pt_regs, ctr) },
322 { "xer", GDB_SIZEOF_REG, offsetof(struct pt_regs, xer) },
323};
290 324
291#ifdef CONFIG_FSL_BOOKE 325char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
292#ifdef CONFIG_SPE 326{
293 for (reg = 0; reg < 32; reg++) 327 if (regno >= DBG_MAX_REG_NUM || regno < 0)
294 UNPACK64(current->thread.evr[reg], ptr); 328 return NULL;
329
330 if (regno < 32 || regno >= 64)
331 /* First 0 -> 31 gpr registers*/
332 /* pc, msr, ls... registers 64 -> 69 */
333 memcpy(mem, (void *)regs + dbg_reg_def[regno].offset,
334 dbg_reg_def[regno].size);
335
336 if (regno >= 32 && regno < 64) {
337 /* FP registers 32 -> 63 */
338#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
339 if (current)
340 memcpy(mem, current->thread.evr[regno-32],
341 dbg_reg_def[regno].size);
295#else 342#else
296 ptr += 32; 343 /* fp registers not used by kernel, leave zero */
344 memset(mem, 0, dbg_reg_def[regno].size);
297#endif 345#endif
346 }
347
348 return dbg_reg_def[regno].name;
349}
350
351int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
352{
353 if (regno >= DBG_MAX_REG_NUM || regno < 0)
354 return -EINVAL;
355
356 if (regno < 32 || regno >= 64)
357 /* First 0 -> 31 gpr registers*/
358 /* pc, msr, ls... registers 64 -> 69 */
359 memcpy((void *)regs + dbg_reg_def[regno].offset, mem,
360 dbg_reg_def[regno].size);
361
362 if (regno >= 32 && regno < 64) {
363 /* FP registers 32 -> 63 */
364#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
365 memcpy(current->thread.evr[regno-32], mem,
366 dbg_reg_def[regno].size);
298#else 367#else
299 /* fp registers not used by kernel, leave zero */ 368 /* fp registers not used by kernel, leave zero */
300 ptr += 32 * 8 / sizeof(int); 369 return 0;
301#endif 370#endif
371 }
302 372
303 UNPACK64(regs->nip, ptr); 373 return 0;
304 UNPACK64(regs->msr, ptr);
305 UNPACK32(regs->ccr, ptr);
306 UNPACK64(regs->link, ptr);
307 UNPACK64(regs->ctr, ptr);
308 UNPACK32(regs->xer, ptr);
309
310 BUG_ON((unsigned long)ptr >
311 (unsigned long)(((void *)gdb_regs) + NUMREGBYTES));
312} 374}
313 375
314void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) 376void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
new file mode 100644
index 000000000000..b06bdae04064
--- /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#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_PPC_BOOK3S)
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 8d9e3b9cda64..16468362ad57 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -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/prom.c b/arch/powerpc/kernel/prom.c
index c3c6a8857544..9e3132db718b 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -364,10 +364,15 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
364 return 0; 364 return 0;
365} 365}
366 366
367void __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)
368{ 369{
369 unsigned long *lprop; 370 unsigned long *lprop;
370 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
371#ifdef CONFIG_PPC64 376#ifdef CONFIG_PPC64
372 /* check if iommu is forced on or off */ 377 /* check if iommu is forced on or off */
373 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)
@@ -399,6 +404,9 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)
399 if (lprop) 404 if (lprop)
400 crashk_res.end = crashk_res.start + *lprop - 1; 405 crashk_res.end = crashk_res.start + *lprop - 1;
401#endif 406#endif
407
408 /* break now */
409 return 1;
402} 410}
403 411
404#ifdef CONFIG_PPC_PSERIES 412#ifdef CONFIG_PPC_PSERIES
@@ -683,7 +691,7 @@ void __init early_init_devtree(void *params)
683 * device-tree, including the platform type, initrd location and 691 * device-tree, including the platform type, initrd location and
684 * size, TCE reserve, and more ... 692 * size, TCE reserve, and more ...
685 */ 693 */
686 of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 694 of_scan_flat_dt(early_init_dt_scan_chosen_ppc, NULL);
687 695
688 /* Scan memory nodes and rebuild MEMBLOCKs */ 696 /* Scan memory nodes and rebuild MEMBLOCKs */
689 memblock_init(); 697 memblock_init();
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 286d9783d93f..a9b32967cff6 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1406,37 +1406,42 @@ static long ppc_del_hwdebug(struct task_struct *child, long addr, long data)
1406 * Here are the old "legacy" powerpc specific getregs/setregs ptrace calls, 1406 * Here are the old "legacy" powerpc specific getregs/setregs ptrace calls,
1407 * we mark them as obsolete now, they will be removed in a future version 1407 * we mark them as obsolete now, they will be removed in a future version
1408 */ 1408 */
1409static long arch_ptrace_old(struct task_struct *child, long request, long addr, 1409static long arch_ptrace_old(struct task_struct *child, long request,
1410 long data) 1410 unsigned long addr, unsigned long data)
1411{ 1411{
1412 void __user *datavp = (void __user *) data;
1413
1412 switch (request) { 1414 switch (request) {
1413 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */ 1415 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */
1414 return copy_regset_to_user(child, &user_ppc_native_view, 1416 return copy_regset_to_user(child, &user_ppc_native_view,
1415 REGSET_GPR, 0, 32 * sizeof(long), 1417 REGSET_GPR, 0, 32 * sizeof(long),
1416 (void __user *) data); 1418 datavp);
1417 1419
1418 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */ 1420 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */
1419 return copy_regset_from_user(child, &user_ppc_native_view, 1421 return copy_regset_from_user(child, &user_ppc_native_view,
1420 REGSET_GPR, 0, 32 * sizeof(long), 1422 REGSET_GPR, 0, 32 * sizeof(long),
1421 (const void __user *) data); 1423 datavp);
1422 1424
1423 case PPC_PTRACE_GETFPREGS: /* Get FPRs 0 - 31. */ 1425 case PPC_PTRACE_GETFPREGS: /* Get FPRs 0 - 31. */
1424 return copy_regset_to_user(child, &user_ppc_native_view, 1426 return copy_regset_to_user(child, &user_ppc_native_view,
1425 REGSET_FPR, 0, 32 * sizeof(double), 1427 REGSET_FPR, 0, 32 * sizeof(double),
1426 (void __user *) data); 1428 datavp);
1427 1429
1428 case PPC_PTRACE_SETFPREGS: /* Set FPRs 0 - 31. */ 1430 case PPC_PTRACE_SETFPREGS: /* Set FPRs 0 - 31. */
1429 return copy_regset_from_user(child, &user_ppc_native_view, 1431 return copy_regset_from_user(child, &user_ppc_native_view,
1430 REGSET_FPR, 0, 32 * sizeof(double), 1432 REGSET_FPR, 0, 32 * sizeof(double),
1431 (const void __user *) data); 1433 datavp);
1432 } 1434 }
1433 1435
1434 return -EPERM; 1436 return -EPERM;
1435} 1437}
1436 1438
1437long arch_ptrace(struct task_struct *child, long request, long addr, long data) 1439long arch_ptrace(struct task_struct *child, long request,
1440 unsigned long addr, unsigned long data)
1438{ 1441{
1439 int ret = -EPERM; 1442 int ret = -EPERM;
1443 void __user *datavp = (void __user *) data;
1444 unsigned long __user *datalp = datavp;
1440 1445
1441 switch (request) { 1446 switch (request) {
1442 /* read the word at location addr in the USER area. */ 1447 /* read the word at location addr in the USER area. */
@@ -1446,11 +1451,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1446 ret = -EIO; 1451 ret = -EIO;
1447 /* convert to index and check */ 1452 /* convert to index and check */
1448#ifdef CONFIG_PPC32 1453#ifdef CONFIG_PPC32
1449 index = (unsigned long) addr >> 2; 1454 index = addr >> 2;
1450 if ((addr & 3) || (index > PT_FPSCR) 1455 if ((addr & 3) || (index > PT_FPSCR)
1451 || (child->thread.regs == NULL)) 1456 || (child->thread.regs == NULL))
1452#else 1457#else
1453 index = (unsigned long) addr >> 3; 1458 index = addr >> 3;
1454 if ((addr & 7) || (index > PT_FPSCR)) 1459 if ((addr & 7) || (index > PT_FPSCR))
1455#endif 1460#endif
1456 break; 1461 break;
@@ -1463,7 +1468,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1463 tmp = ((unsigned long *)child->thread.fpr) 1468 tmp = ((unsigned long *)child->thread.fpr)
1464 [TS_FPRWIDTH * (index - PT_FPR0)]; 1469 [TS_FPRWIDTH * (index - PT_FPR0)];
1465 } 1470 }
1466 ret = put_user(tmp,(unsigned long __user *) data); 1471 ret = put_user(tmp, datalp);
1467 break; 1472 break;
1468 } 1473 }
1469 1474
@@ -1474,11 +1479,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1474 ret = -EIO; 1479 ret = -EIO;
1475 /* convert to index and check */ 1480 /* convert to index and check */
1476#ifdef CONFIG_PPC32 1481#ifdef CONFIG_PPC32
1477 index = (unsigned long) addr >> 2; 1482 index = addr >> 2;
1478 if ((addr & 3) || (index > PT_FPSCR) 1483 if ((addr & 3) || (index > PT_FPSCR)
1479 || (child->thread.regs == NULL)) 1484 || (child->thread.regs == NULL))
1480#else 1485#else
1481 index = (unsigned long) addr >> 3; 1486 index = addr >> 3;
1482 if ((addr & 7) || (index > PT_FPSCR)) 1487 if ((addr & 7) || (index > PT_FPSCR))
1483#endif 1488#endif
1484 break; 1489 break;
@@ -1525,11 +1530,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1525 dbginfo.features = 0; 1530 dbginfo.features = 0;
1526#endif /* CONFIG_PPC_ADV_DEBUG_REGS */ 1531#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
1527 1532
1528 if (!access_ok(VERIFY_WRITE, data, 1533 if (!access_ok(VERIFY_WRITE, datavp,
1529 sizeof(struct ppc_debug_info))) 1534 sizeof(struct ppc_debug_info)))
1530 return -EFAULT; 1535 return -EFAULT;
1531 ret = __copy_to_user((struct ppc_debug_info __user *)data, 1536 ret = __copy_to_user(datavp, &dbginfo,
1532 &dbginfo, sizeof(struct ppc_debug_info)) ? 1537 sizeof(struct ppc_debug_info)) ?
1533 -EFAULT : 0; 1538 -EFAULT : 0;
1534 break; 1539 break;
1535 } 1540 }
@@ -1537,11 +1542,10 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1537 case PPC_PTRACE_SETHWDEBUG: { 1542 case PPC_PTRACE_SETHWDEBUG: {
1538 struct ppc_hw_breakpoint bp_info; 1543 struct ppc_hw_breakpoint bp_info;
1539 1544
1540 if (!access_ok(VERIFY_READ, data, 1545 if (!access_ok(VERIFY_READ, datavp,
1541 sizeof(struct ppc_hw_breakpoint))) 1546 sizeof(struct ppc_hw_breakpoint)))
1542 return -EFAULT; 1547 return -EFAULT;
1543 ret = __copy_from_user(&bp_info, 1548 ret = __copy_from_user(&bp_info, datavp,
1544 (struct ppc_hw_breakpoint __user *)data,
1545 sizeof(struct ppc_hw_breakpoint)) ? 1549 sizeof(struct ppc_hw_breakpoint)) ?
1546 -EFAULT : 0; 1550 -EFAULT : 0;
1547 if (!ret) 1551 if (!ret)
@@ -1560,11 +1564,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1560 if (addr > 0) 1564 if (addr > 0)
1561 break; 1565 break;
1562#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1566#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1563 ret = put_user(child->thread.dac1, 1567 ret = put_user(child->thread.dac1, datalp);
1564 (unsigned long __user *)data);
1565#else 1568#else
1566 ret = put_user(child->thread.dabr, 1569 ret = put_user(child->thread.dabr, datalp);
1567 (unsigned long __user *)data);
1568#endif 1570#endif
1569 break; 1571 break;
1570 } 1572 }
@@ -1580,7 +1582,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1580 return copy_regset_to_user(child, &user_ppc_native_view, 1582 return copy_regset_to_user(child, &user_ppc_native_view,
1581 REGSET_GPR, 1583 REGSET_GPR,
1582 0, sizeof(struct pt_regs), 1584 0, sizeof(struct pt_regs),
1583 (void __user *) data); 1585 datavp);
1584 1586
1585#ifdef CONFIG_PPC64 1587#ifdef CONFIG_PPC64
1586 case PTRACE_SETREGS64: 1588 case PTRACE_SETREGS64:
@@ -1589,19 +1591,19 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1589 return copy_regset_from_user(child, &user_ppc_native_view, 1591 return copy_regset_from_user(child, &user_ppc_native_view,
1590 REGSET_GPR, 1592 REGSET_GPR,
1591 0, sizeof(struct pt_regs), 1593 0, sizeof(struct pt_regs),
1592 (const void __user *) data); 1594 datavp);
1593 1595
1594 case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */ 1596 case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */
1595 return copy_regset_to_user(child, &user_ppc_native_view, 1597 return copy_regset_to_user(child, &user_ppc_native_view,
1596 REGSET_FPR, 1598 REGSET_FPR,
1597 0, sizeof(elf_fpregset_t), 1599 0, sizeof(elf_fpregset_t),
1598 (void __user *) data); 1600 datavp);
1599 1601
1600 case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */ 1602 case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */
1601 return copy_regset_from_user(child, &user_ppc_native_view, 1603 return copy_regset_from_user(child, &user_ppc_native_view,
1602 REGSET_FPR, 1604 REGSET_FPR,
1603 0, sizeof(elf_fpregset_t), 1605 0, sizeof(elf_fpregset_t),
1604 (const void __user *) data); 1606 datavp);
1605 1607
1606#ifdef CONFIG_ALTIVEC 1608#ifdef CONFIG_ALTIVEC
1607 case PTRACE_GETVRREGS: 1609 case PTRACE_GETVRREGS:
@@ -1609,40 +1611,40 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1609 REGSET_VMX, 1611 REGSET_VMX,
1610 0, (33 * sizeof(vector128) + 1612 0, (33 * sizeof(vector128) +
1611 sizeof(u32)), 1613 sizeof(u32)),
1612 (void __user *) data); 1614 datavp);
1613 1615
1614 case PTRACE_SETVRREGS: 1616 case PTRACE_SETVRREGS:
1615 return copy_regset_from_user(child, &user_ppc_native_view, 1617 return copy_regset_from_user(child, &user_ppc_native_view,
1616 REGSET_VMX, 1618 REGSET_VMX,
1617 0, (33 * sizeof(vector128) + 1619 0, (33 * sizeof(vector128) +
1618 sizeof(u32)), 1620 sizeof(u32)),
1619 (const void __user *) data); 1621 datavp);
1620#endif 1622#endif
1621#ifdef CONFIG_VSX 1623#ifdef CONFIG_VSX
1622 case PTRACE_GETVSRREGS: 1624 case PTRACE_GETVSRREGS:
1623 return copy_regset_to_user(child, &user_ppc_native_view, 1625 return copy_regset_to_user(child, &user_ppc_native_view,
1624 REGSET_VSX, 1626 REGSET_VSX,
1625 0, 32 * sizeof(double), 1627 0, 32 * sizeof(double),
1626 (void __user *) data); 1628 datavp);
1627 1629
1628 case PTRACE_SETVSRREGS: 1630 case PTRACE_SETVSRREGS:
1629 return copy_regset_from_user(child, &user_ppc_native_view, 1631 return copy_regset_from_user(child, &user_ppc_native_view,
1630 REGSET_VSX, 1632 REGSET_VSX,
1631 0, 32 * sizeof(double), 1633 0, 32 * sizeof(double),
1632 (const void __user *) data); 1634 datavp);
1633#endif 1635#endif
1634#ifdef CONFIG_SPE 1636#ifdef CONFIG_SPE
1635 case PTRACE_GETEVRREGS: 1637 case PTRACE_GETEVRREGS:
1636 /* Get the child spe register state. */ 1638 /* Get the child spe register state. */
1637 return copy_regset_to_user(child, &user_ppc_native_view, 1639 return copy_regset_to_user(child, &user_ppc_native_view,
1638 REGSET_SPE, 0, 35 * sizeof(u32), 1640 REGSET_SPE, 0, 35 * sizeof(u32),
1639 (void __user *) data); 1641 datavp);
1640 1642
1641 case PTRACE_SETEVRREGS: 1643 case PTRACE_SETEVRREGS:
1642 /* Set the child spe register state. */ 1644 /* Set the child spe register state. */
1643 return copy_regset_from_user(child, &user_ppc_native_view, 1645 return copy_regset_from_user(child, &user_ppc_native_view,
1644 REGSET_SPE, 0, 35 * sizeof(u32), 1646 REGSET_SPE, 0, 35 * sizeof(u32),
1645 (const void __user *) data); 1647 datavp);
1646#endif 1648#endif
1647 1649
1648 /* Old reverse args ptrace callss */ 1650 /* Old reverse args ptrace callss */
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/vio.c b/arch/powerpc/kernel/vio.c
index d692989a4318..441d2a722f06 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -238,9 +238,7 @@ static inline void vio_cmo_dealloc(struct vio_dev *viodev, size_t size)
238 * memory in this pool does not change. 238 * memory in this pool does not change.
239 */ 239 */
240 if (spare_needed && reserve_freed) { 240 if (spare_needed && reserve_freed) {
241 tmp = min(spare_needed, min(reserve_freed, 241 tmp = min3(spare_needed, reserve_freed, (viodev->cmo.entitled - VIO_CMO_MIN_ENT));
242 (viodev->cmo.entitled -
243 VIO_CMO_MIN_ENT)));
244 242
245 vio_cmo.spare += tmp; 243 vio_cmo.spare += tmp;
246 viodev->cmo.entitled -= tmp; 244 viodev->cmo.entitled -= tmp;
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/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 35a701f3ece4..7b0ee96c1bed 100644
--- a/arch/powerpc/kvm/book3s_paired_singles.c
+++ b/arch/powerpc/kvm/book3s_paired_singles.c
@@ -165,14 +165,15 @@ static inline void kvmppc_sync_qpr(struct kvm_vcpu *vcpu, int rt)
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
@@ -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 }
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..1cc471faac2d 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 + 4)(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..e3768ee9b595 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,8 +137,9 @@ 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
134 kvmppc_e500_tlb_uninit(vcpu_e500); 140 free_page((unsigned long)vcpu->arch.shared);
135 kvm_vcpu_uninit(vcpu); 141 kvm_vcpu_uninit(vcpu);
142 kvmppc_e500_tlb_uninit(vcpu_e500);
136 kmem_cache_free(kvm_vcpu_cache, vcpu_e500); 143 kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
137} 144}
138 145
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 b83ba581fd8e..c64fd2909bb2 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -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
@@ -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/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 72a4ad86ee91..38f756f25053 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,54 @@ 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 memset(&pvinfo, 0, sizeof(pvinfo));
621 r = kvm_vm_ioctl_get_pvinfo(&pvinfo);
622 if (copy_to_user(argp, &pvinfo, sizeof(pvinfo))) {
623 r = -EFAULT;
624 goto out;
625 }
626
627 break;
628 }
543 default: 629 default:
544 r = -ENOTTY; 630 r = -ENOTTY;
545 } 631 }
546 632
633out:
547 return r; 634 return r;
548} 635}
549 636
diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
index 46fa04f12a9b..a021f5827a33 100644
--- a/arch/powerpc/kvm/timing.c
+++ b/arch/powerpc/kvm/timing.c
@@ -35,7 +35,6 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu)
35 int i; 35 int i;
36 36
37 /* pause guest execution to avoid concurrent updates */ 37 /* pause guest execution to avoid concurrent updates */
38 local_irq_disable();
39 mutex_lock(&vcpu->mutex); 38 mutex_lock(&vcpu->mutex);
40 39
41 vcpu->arch.last_exit_type = 0xDEAD; 40 vcpu->arch.last_exit_type = 0xDEAD;
@@ -51,7 +50,6 @@ void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu)
51 vcpu->arch.timing_last_enter.tv64 = 0; 50 vcpu->arch.timing_last_enter.tv64 = 0;
52 51
53 mutex_unlock(&vcpu->mutex); 52 mutex_unlock(&vcpu->mutex);
54 local_irq_enable();
55} 53}
56 54
57static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type) 55static void add_exit_timing(struct kvm_vcpu *vcpu, u64 duration, int type)
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/mm/highmem.c b/arch/powerpc/mm/highmem.c
index 857d4173f9c6..e7450bdbe83a 100644
--- a/arch/powerpc/mm/highmem.c
+++ b/arch/powerpc/mm/highmem.c
@@ -29,17 +29,17 @@
29 * be used in IRQ contexts, so in some (very limited) cases we need 29 * be used in IRQ contexts, so in some (very limited) cases we need
30 * it. 30 * it.
31 */ 31 */
32void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot) 32void *kmap_atomic_prot(struct page *page, pgprot_t prot)
33{ 33{
34 unsigned int idx;
35 unsigned long vaddr; 34 unsigned long vaddr;
35 int idx, type;
36 36
37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
38 pagefault_disable(); 38 pagefault_disable();
39 if (!PageHighMem(page)) 39 if (!PageHighMem(page))
40 return page_address(page); 40 return page_address(page);
41 41
42 debug_kmap_atomic(type); 42 type = kmap_atomic_idx_push();
43 idx = type + KM_TYPE_NR*smp_processor_id(); 43 idx = type + KM_TYPE_NR*smp_processor_id();
44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
45#ifdef CONFIG_DEBUG_HIGHMEM 45#ifdef CONFIG_DEBUG_HIGHMEM
@@ -52,26 +52,35 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
52} 52}
53EXPORT_SYMBOL(kmap_atomic_prot); 53EXPORT_SYMBOL(kmap_atomic_prot);
54 54
55void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 55void __kunmap_atomic(void *kvaddr)
56{ 56{
57#ifdef CONFIG_DEBUG_HIGHMEM
58 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 57 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
59 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 58 int type;
60 59
61 if (vaddr < __fix_to_virt(FIX_KMAP_END)) { 60 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
62 pagefault_enable(); 61 pagefault_enable();
63 return; 62 return;
64 } 63 }
65 64
66 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx)); 65 type = kmap_atomic_idx();
67 66
68 /* 67#ifdef CONFIG_DEBUG_HIGHMEM
69 * force other mappings to Oops if they'll try to access 68 {
70 * this pte without first remap it 69 unsigned int idx;
71 */ 70
72 pte_clear(&init_mm, vaddr, kmap_pte-idx); 71 idx = type + KM_TYPE_NR * smp_processor_id();
73 local_flush_tlb_page(NULL, vaddr); 72 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
73
74 /*
75 * force other mappings to Oops if they'll try to access
76 * this pte without first remap it
77 */
78 pte_clear(&init_mm, vaddr, kmap_pte-idx);
79 local_flush_tlb_page(NULL, vaddr);
80 }
74#endif 81#endif
82
83 kmap_atomic_idx_pop();
75 pagefault_enable(); 84 pagefault_enable();
76} 85}
77EXPORT_SYMBOL(kunmap_atomic_notypecheck); 86EXPORT_SYMBOL(__kunmap_atomic);
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 2b390d19a1d1..7eb5c40c069f 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -8,7 +8,6 @@
8 * Copyright 2010 Freescale Semiconductor, Inc. 8 * Copyright 2010 Freescale Semiconductor, Inc.
9 * 9 *
10 * This file is taken from the Freescale P1022DS BSP, with modifications: 10 * This file is taken from the Freescale P1022DS BSP, with modifications:
11 * 1) No DIU support (pending rewrite of DIU code)
12 * 2) No AMP support 11 * 2) No AMP support
13 * 3) No PCI endpoint support 12 * 3) No PCI endpoint support
14 * 13 *
@@ -20,12 +19,211 @@
20#include <linux/pci.h> 19#include <linux/pci.h>
21#include <linux/of_platform.h> 20#include <linux/of_platform.h>
22#include <linux/memblock.h> 21#include <linux/memblock.h>
23 22#include <asm/div64.h>
24#include <asm/mpic.h> 23#include <asm/mpic.h>
25#include <asm/swiotlb.h> 24#include <asm/swiotlb.h>
26 25
27#include <sysdev/fsl_soc.h> 26#include <sysdev/fsl_soc.h>
28#include <sysdev/fsl_pci.h> 27#include <sysdev/fsl_pci.h>
28#include <asm/fsl_guts.h>
29
30#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
31
32/*
33 * Board-specific initialization of the DIU. This code should probably be
34 * executed when the DIU is opened, rather than in arch code, but the DIU
35 * driver does not have a mechanism for this (yet).
36 *
37 * This is especially problematic on the P1022DS because the local bus (eLBC)
38 * and the DIU video signals share the same pins, which means that enabling the
39 * DIU will disable access to NOR flash.
40 */
41
42/* DIU Pixel Clock bits of the CLKDVDR Global Utilities register */
43#define CLKDVDR_PXCKEN 0x80000000
44#define CLKDVDR_PXCKINV 0x10000000
45#define CLKDVDR_PXCKDLY 0x06000000
46#define CLKDVDR_PXCLK_MASK 0x00FF0000
47
48/* Some ngPIXIS register definitions */
49#define PX_BRDCFG1_DVIEN 0x80
50#define PX_BRDCFG1_DFPEN 0x40
51#define PX_BRDCFG1_BACKLIGHT 0x20
52#define PX_BRDCFG1_DDCEN 0x10
53
54/*
55 * DIU Area Descriptor
56 *
57 * Note that we need to byte-swap the value before it's written to the AD
58 * register. So even though the registers don't look like they're in the same
59 * bit positions as they are on the MPC8610, the same value is written to the
60 * AD register on the MPC8610 and on the P1022.
61 */
62#define AD_BYTE_F 0x10000000
63#define AD_ALPHA_C_MASK 0x0E000000
64#define AD_ALPHA_C_SHIFT 25
65#define AD_BLUE_C_MASK 0x01800000
66#define AD_BLUE_C_SHIFT 23
67#define AD_GREEN_C_MASK 0x00600000
68#define AD_GREEN_C_SHIFT 21
69#define AD_RED_C_MASK 0x00180000
70#define AD_RED_C_SHIFT 19
71#define AD_PALETTE 0x00040000
72#define AD_PIXEL_S_MASK 0x00030000
73#define AD_PIXEL_S_SHIFT 16
74#define AD_COMP_3_MASK 0x0000F000
75#define AD_COMP_3_SHIFT 12
76#define AD_COMP_2_MASK 0x00000F00
77#define AD_COMP_2_SHIFT 8
78#define AD_COMP_1_MASK 0x000000F0
79#define AD_COMP_1_SHIFT 4
80#define AD_COMP_0_MASK 0x0000000F
81#define AD_COMP_0_SHIFT 0
82
83#define MAKE_AD(alpha, red, blue, green, size, c0, c1, c2, c3) \
84 cpu_to_le32(AD_BYTE_F | (alpha << AD_ALPHA_C_SHIFT) | \
85 (blue << AD_BLUE_C_SHIFT) | (green << AD_GREEN_C_SHIFT) | \
86 (red << AD_RED_C_SHIFT) | (c3 << AD_COMP_3_SHIFT) | \
87 (c2 << AD_COMP_2_SHIFT) | (c1 << AD_COMP_1_SHIFT) | \
88 (c0 << AD_COMP_0_SHIFT) | (size << AD_PIXEL_S_SHIFT))
89
90/**
91 * p1022ds_get_pixel_format: return the Area Descriptor for a given pixel depth
92 *
93 * The Area Descriptor is a 32-bit value that determine which bits in each
94 * pixel are to be used for each color.
95 */
96static unsigned int p1022ds_get_pixel_format(unsigned int bits_per_pixel,
97 int monitor_port)
98{
99 switch (bits_per_pixel) {
100 case 32:
101 /* 0x88883316 */
102 return MAKE_AD(3, 2, 0, 1, 3, 8, 8, 8, 8);
103 case 24:
104 /* 0x88082219 */
105 return MAKE_AD(4, 0, 1, 2, 2, 0, 8, 8, 8);
106 case 16:
107 /* 0x65053118 */
108 return MAKE_AD(4, 2, 1, 0, 1, 5, 6, 5, 0);
109 default:
110 pr_err("fsl-diu: unsupported pixel depth %u\n", bits_per_pixel);
111 return 0;
112 }
113}
114
115/**
116 * p1022ds_set_gamma_table: update the gamma table, if necessary
117 *
118 * On some boards, the gamma table for some ports may need to be modified.
119 * This is not the case on the P1022DS, so we do nothing.
120*/
121static void p1022ds_set_gamma_table(int monitor_port, char *gamma_table_base)
122{
123}
124
125/**
126 * p1022ds_set_monitor_port: switch the output to a different monitor port
127 *
128 */
129static void p1022ds_set_monitor_port(int monitor_port)
130{
131 struct device_node *pixis_node;
132 u8 __iomem *brdcfg1;
133
134 pixis_node = of_find_compatible_node(NULL, NULL, "fsl,p1022ds-pixis");
135 if (!pixis_node) {
136 pr_err("p1022ds: missing ngPIXIS node\n");
137 return;
138 }
139
140 brdcfg1 = of_iomap(pixis_node, 0);
141 if (!brdcfg1) {
142 pr_err("p1022ds: could not map ngPIXIS registers\n");
143 return;
144 }
145 brdcfg1 += 9; /* BRDCFG1 is at offset 9 in the ngPIXIS */
146
147 switch (monitor_port) {
148 case 0: /* DVI */
149 /* Enable the DVI port, disable the DFP and the backlight */
150 clrsetbits_8(brdcfg1, PX_BRDCFG1_DFPEN | PX_BRDCFG1_BACKLIGHT,
151 PX_BRDCFG1_DVIEN);
152 break;
153 case 1: /* Single link LVDS */
154 /* Enable the DFP port, disable the DVI and the backlight */
155 clrsetbits_8(brdcfg1, PX_BRDCFG1_DVIEN | PX_BRDCFG1_BACKLIGHT,
156 PX_BRDCFG1_DFPEN);
157 break;
158 default:
159 pr_err("p1022ds: unsupported monitor port %i\n", monitor_port);
160 }
161}
162
163/**
164 * p1022ds_set_pixel_clock: program the DIU's clock
165 *
166 * @pixclock: the wavelength, in picoseconds, of the clock
167 */
168void p1022ds_set_pixel_clock(unsigned int pixclock)
169{
170 struct device_node *guts_np = NULL;
171 struct ccsr_guts_85xx __iomem *guts;
172 unsigned long freq;
173 u64 temp;
174 u32 pxclk;
175
176 /* Map the global utilities registers. */
177 guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts");
178 if (!guts_np) {
179 pr_err("p1022ds: missing global utilties device node\n");
180 return;
181 }
182
183 guts = of_iomap(guts_np, 0);
184 of_node_put(guts_np);
185 if (!guts) {
186 pr_err("p1022ds: could not map global utilties device\n");
187 return;
188 }
189
190 /* Convert pixclock from a wavelength to a frequency */
191 temp = 1000000000000ULL;
192 do_div(temp, pixclock);
193 freq = temp;
194
195 /* pixclk is the ratio of the platform clock to the pixel clock */
196 pxclk = DIV_ROUND_CLOSEST(fsl_get_sys_freq(), freq);
197
198 /* Disable the pixel clock, and set it to non-inverted and no delay */
199 clrbits32(&guts->clkdvdr,
200 CLKDVDR_PXCKEN | CLKDVDR_PXCKDLY | CLKDVDR_PXCLK_MASK);
201
202 /* Enable the clock and set the pxclk */
203 setbits32(&guts->clkdvdr, CLKDVDR_PXCKEN | (pxclk << 16));
204}
205
206/**
207 * p1022ds_show_monitor_port: show the current monitor
208 *
209 * This function returns a string indicating whether the current monitor is
210 * set to DVI or LVDS.
211 */
212ssize_t p1022ds_show_monitor_port(int monitor_port, char *buf)
213{
214 return sprintf(buf, "%c0 - DVI\n%c1 - Single link LVDS\n",
215 monitor_port == 0 ? '*' : ' ', monitor_port == 1 ? '*' : ' ');
216}
217
218/**
219 * p1022ds_set_sysfs_monitor_port: set the monitor port for sysfs
220 */
221int p1022ds_set_sysfs_monitor_port(int val)
222{
223 return val < 2 ? val : 0;
224}
225
226#endif
29 227
30void __init p1022_ds_pic_init(void) 228void __init p1022_ds_pic_init(void)
31{ 229{
@@ -92,6 +290,15 @@ static void __init p1022_ds_setup_arch(void)
92 } 290 }
93#endif 291#endif
94 292
293#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
294 diu_ops.get_pixel_format = p1022ds_get_pixel_format;
295 diu_ops.set_gamma_table = p1022ds_set_gamma_table;
296 diu_ops.set_monitor_port = p1022ds_set_monitor_port;
297 diu_ops.set_pixel_clock = p1022ds_set_pixel_clock;
298 diu_ops.show_monitor_port = p1022ds_show_monitor_port;
299 diu_ops.set_sysfs_monitor_port = p1022ds_set_sysfs_monitor_port;
300#endif
301
95#ifdef CONFIG_SMP 302#ifdef CONFIG_SMP
96 mpc85xx_smp_init(); 303 mpc85xx_smp_init();
97#endif 304#endif
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/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 5dec408d6703..3532b92de983 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -798,17 +798,17 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
798 return spufs_create_root(sb, data); 798 return spufs_create_root(sb, data);
799} 799}
800 800
801static int 801static struct dentry *
802spufs_get_sb(struct file_system_type *fstype, int flags, 802spufs_mount(struct file_system_type *fstype, int flags,
803 const char *name, void *data, struct vfsmount *mnt) 803 const char *name, void *data)
804{ 804{
805 return get_sb_single(fstype, flags, data, spufs_fill_super, mnt); 805 return mount_single(fstype, flags, data, spufs_fill_super);
806} 806}
807 807
808static struct file_system_type spufs_type = { 808static struct file_system_type spufs_type = {
809 .owner = THIS_MODULE, 809 .owner = THIS_MODULE,
810 .name = "spufs", 810 .name = "spufs",
811 .get_sb = spufs_get_sb, 811 .mount = spufs_mount,
812 .kill_sb = kill_litter_super, 812 .kill_sb = kill_litter_super,
813}; 813};
814 814
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/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/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
index dceb8d1a843d..4fcb5a4e60dd 100644
--- a/arch/powerpc/sysdev/fsl_lbc.c
+++ b/arch/powerpc/sysdev/fsl_lbc.c
@@ -1,9 +1,12 @@
1/* 1/*
2 * Freescale LBC and UPM routines. 2 * Freescale LBC and UPM routines.
3 * 3 *
4 * Copyright (c) 2007-2008 MontaVista Software, Inc. 4 * Copyright © 2007-2008 MontaVista Software, Inc.
5 * Copyright © 2010 Freescale Semiconductor
5 * 6 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com> 7 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
8 * Author: Jack Lan <Jack.Lan@freescale.com>
9 * Author: Roy Zang <tie-fei.zang@freescale.com>
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 as published by 12 * it under the terms of the GNU General Public License as published by
@@ -19,39 +22,37 @@
19#include <linux/types.h> 22#include <linux/types.h>
20#include <linux/io.h> 23#include <linux/io.h>
21#include <linux/of.h> 24#include <linux/of.h>
25#include <linux/slab.h>
26#include <linux/platform_device.h>
27#include <linux/interrupt.h>
28#include <linux/mod_devicetable.h>
22#include <asm/prom.h> 29#include <asm/prom.h>
23#include <asm/fsl_lbc.h> 30#include <asm/fsl_lbc.h>
24 31
25static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock); 32static spinlock_t fsl_lbc_lock = __SPIN_LOCK_UNLOCKED(fsl_lbc_lock);
26static struct fsl_lbc_regs __iomem *fsl_lbc_regs; 33struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
34EXPORT_SYMBOL(fsl_lbc_ctrl_dev);
27 35
28static char __initdata *compat_lbc[] = { 36/**
29 "fsl,pq2-localbus", 37 * fsl_lbc_addr - convert the base address
30 "fsl,pq2pro-localbus", 38 * @addr_base: base address of the memory bank
31 "fsl,pq3-localbus", 39 *
32 "fsl,elbc", 40 * This function converts a base address of lbc into the right format for the
33}; 41 * BR register. If the SOC has eLBC then it returns 32bit physical address
34 42 * else it convers a 34bit local bus physical address to correct format of
35static int __init fsl_lbc_init(void) 43 * 32bit address for BR register (Example: MPC8641).
44 */
45u32 fsl_lbc_addr(phys_addr_t addr_base)
36{ 46{
37 struct device_node *lbus; 47 struct device_node *np = fsl_lbc_ctrl_dev->dev->of_node;
38 int i; 48 u32 addr = addr_base & 0xffff8000;
39 49
40 for (i = 0; i < ARRAY_SIZE(compat_lbc); i++) { 50 if (of_device_is_compatible(np, "fsl,elbc"))
41 lbus = of_find_compatible_node(NULL, NULL, compat_lbc[i]); 51 return addr;
42 if (lbus)
43 goto found;
44 }
45 return -ENODEV;
46 52
47found: 53 return addr | ((addr_base & 0x300000000ull) >> 19);
48 fsl_lbc_regs = of_iomap(lbus, 0);
49 of_node_put(lbus);
50 if (!fsl_lbc_regs)
51 return -ENOMEM;
52 return 0;
53} 54}
54arch_initcall(fsl_lbc_init); 55EXPORT_SYMBOL(fsl_lbc_addr);
55 56
56/** 57/**
57 * fsl_lbc_find - find Localbus bank 58 * fsl_lbc_find - find Localbus bank
@@ -65,15 +66,17 @@ arch_initcall(fsl_lbc_init);
65int fsl_lbc_find(phys_addr_t addr_base) 66int fsl_lbc_find(phys_addr_t addr_base)
66{ 67{
67 int i; 68 int i;
69 struct fsl_lbc_regs __iomem *lbc;
68 70
69 if (!fsl_lbc_regs) 71 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
70 return -ENODEV; 72 return -ENODEV;
71 73
72 for (i = 0; i < ARRAY_SIZE(fsl_lbc_regs->bank); i++) { 74 lbc = fsl_lbc_ctrl_dev->regs;
73 __be32 br = in_be32(&fsl_lbc_regs->bank[i].br); 75 for (i = 0; i < ARRAY_SIZE(lbc->bank); i++) {
74 __be32 or = in_be32(&fsl_lbc_regs->bank[i].or); 76 __be32 br = in_be32(&lbc->bank[i].br);
77 __be32 or = in_be32(&lbc->bank[i].or);
75 78
76 if (br & BR_V && (br & or & BR_BA) == addr_base) 79 if (br & BR_V && (br & or & BR_BA) == fsl_lbc_addr(addr_base))
77 return i; 80 return i;
78 } 81 }
79 82
@@ -94,22 +97,27 @@ int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm)
94{ 97{
95 int bank; 98 int bank;
96 __be32 br; 99 __be32 br;
100 struct fsl_lbc_regs __iomem *lbc;
97 101
98 bank = fsl_lbc_find(addr_base); 102 bank = fsl_lbc_find(addr_base);
99 if (bank < 0) 103 if (bank < 0)
100 return bank; 104 return bank;
101 105
102 br = in_be32(&fsl_lbc_regs->bank[bank].br); 106 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
107 return -ENODEV;
108
109 lbc = fsl_lbc_ctrl_dev->regs;
110 br = in_be32(&lbc->bank[bank].br);
103 111
104 switch (br & BR_MSEL) { 112 switch (br & BR_MSEL) {
105 case BR_MS_UPMA: 113 case BR_MS_UPMA:
106 upm->mxmr = &fsl_lbc_regs->mamr; 114 upm->mxmr = &lbc->mamr;
107 break; 115 break;
108 case BR_MS_UPMB: 116 case BR_MS_UPMB:
109 upm->mxmr = &fsl_lbc_regs->mbmr; 117 upm->mxmr = &lbc->mbmr;
110 break; 118 break;
111 case BR_MS_UPMC: 119 case BR_MS_UPMC:
112 upm->mxmr = &fsl_lbc_regs->mcmr; 120 upm->mxmr = &lbc->mcmr;
113 break; 121 break;
114 default: 122 default:
115 return -EINVAL; 123 return -EINVAL;
@@ -148,9 +156,12 @@ int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
148 int ret = 0; 156 int ret = 0;
149 unsigned long flags; 157 unsigned long flags;
150 158
159 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
160 return -ENODEV;
161
151 spin_lock_irqsave(&fsl_lbc_lock, flags); 162 spin_lock_irqsave(&fsl_lbc_lock, flags);
152 163
153 out_be32(&fsl_lbc_regs->mar, mar); 164 out_be32(&fsl_lbc_ctrl_dev->regs->mar, mar);
154 165
155 switch (upm->width) { 166 switch (upm->width) {
156 case 8: 167 case 8:
@@ -172,3 +183,166 @@ int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, u32 mar)
172 return ret; 183 return ret;
173} 184}
174EXPORT_SYMBOL(fsl_upm_run_pattern); 185EXPORT_SYMBOL(fsl_upm_run_pattern);
186
187static int __devinit fsl_lbc_ctrl_init(struct fsl_lbc_ctrl *ctrl)
188{
189 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
190
191 /* clear event registers */
192 setbits32(&lbc->ltesr, LTESR_CLEAR);
193 out_be32(&lbc->lteatr, 0);
194 out_be32(&lbc->ltear, 0);
195 out_be32(&lbc->lteccr, LTECCR_CLEAR);
196 out_be32(&lbc->ltedr, LTEDR_ENABLE);
197
198 /* Enable interrupts for any detected events */
199 out_be32(&lbc->lteir, LTEIR_ENABLE);
200
201 return 0;
202}
203
204/*
205 * NOTE: This interrupt is used to report localbus events of various kinds,
206 * such as transaction errors on the chipselects.
207 */
208
209static irqreturn_t fsl_lbc_ctrl_irq(int irqno, void *data)
210{
211 struct fsl_lbc_ctrl *ctrl = data;
212 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
213 u32 status;
214
215 status = in_be32(&lbc->ltesr);
216 if (!status)
217 return IRQ_NONE;
218
219 out_be32(&lbc->ltesr, LTESR_CLEAR);
220 out_be32(&lbc->lteatr, 0);
221 out_be32(&lbc->ltear, 0);
222 ctrl->irq_status = status;
223
224 if (status & LTESR_BM)
225 dev_err(ctrl->dev, "Local bus monitor time-out: "
226 "LTESR 0x%08X\n", status);
227 if (status & LTESR_WP)
228 dev_err(ctrl->dev, "Write protect error: "
229 "LTESR 0x%08X\n", status);
230 if (status & LTESR_ATMW)
231 dev_err(ctrl->dev, "Atomic write error: "
232 "LTESR 0x%08X\n", status);
233 if (status & LTESR_ATMR)
234 dev_err(ctrl->dev, "Atomic read error: "
235 "LTESR 0x%08X\n", status);
236 if (status & LTESR_CS)
237 dev_err(ctrl->dev, "Chip select error: "
238 "LTESR 0x%08X\n", status);
239 if (status & LTESR_UPM)
240 ;
241 if (status & LTESR_FCT) {
242 dev_err(ctrl->dev, "FCM command time-out: "
243 "LTESR 0x%08X\n", status);
244 smp_wmb();
245 wake_up(&ctrl->irq_wait);
246 }
247 if (status & LTESR_PAR) {
248 dev_err(ctrl->dev, "Parity or Uncorrectable ECC error: "
249 "LTESR 0x%08X\n", status);
250 smp_wmb();
251 wake_up(&ctrl->irq_wait);
252 }
253 if (status & LTESR_CC) {
254 smp_wmb();
255 wake_up(&ctrl->irq_wait);
256 }
257 if (status & ~LTESR_MASK)
258 dev_err(ctrl->dev, "Unknown error: "
259 "LTESR 0x%08X\n", status);
260 return IRQ_HANDLED;
261}
262
263/*
264 * fsl_lbc_ctrl_probe
265 *
266 * called by device layer when it finds a device matching
267 * one our driver can handled. This code allocates all of
268 * the resources needed for the controller only. The
269 * resources for the NAND banks themselves are allocated
270 * in the chip probe function.
271*/
272
273static int __devinit fsl_lbc_ctrl_probe(struct platform_device *dev)
274{
275 int ret;
276
277 if (!dev->dev.of_node) {
278 dev_err(&dev->dev, "Device OF-Node is NULL");
279 return -EFAULT;
280 }
281
282 fsl_lbc_ctrl_dev = kzalloc(sizeof(*fsl_lbc_ctrl_dev), GFP_KERNEL);
283 if (!fsl_lbc_ctrl_dev)
284 return -ENOMEM;
285
286 dev_set_drvdata(&dev->dev, fsl_lbc_ctrl_dev);
287
288 spin_lock_init(&fsl_lbc_ctrl_dev->lock);
289 init_waitqueue_head(&fsl_lbc_ctrl_dev->irq_wait);
290
291 fsl_lbc_ctrl_dev->regs = of_iomap(dev->dev.of_node, 0);
292 if (!fsl_lbc_ctrl_dev->regs) {
293 dev_err(&dev->dev, "failed to get memory region\n");
294 ret = -ENODEV;
295 goto err;
296 }
297
298 fsl_lbc_ctrl_dev->irq = irq_of_parse_and_map(dev->dev.of_node, 0);
299 if (fsl_lbc_ctrl_dev->irq == NO_IRQ) {
300 dev_err(&dev->dev, "failed to get irq resource\n");
301 ret = -ENODEV;
302 goto err;
303 }
304
305 fsl_lbc_ctrl_dev->dev = &dev->dev;
306
307 ret = fsl_lbc_ctrl_init(fsl_lbc_ctrl_dev);
308 if (ret < 0)
309 goto err;
310
311 ret = request_irq(fsl_lbc_ctrl_dev->irq, fsl_lbc_ctrl_irq, 0,
312 "fsl-lbc", fsl_lbc_ctrl_dev);
313 if (ret != 0) {
314 dev_err(&dev->dev, "failed to install irq (%d)\n",
315 fsl_lbc_ctrl_dev->irq);
316 ret = fsl_lbc_ctrl_dev->irq;
317 goto err;
318 }
319
320 return 0;
321
322err:
323 iounmap(fsl_lbc_ctrl_dev->regs);
324 kfree(fsl_lbc_ctrl_dev);
325 return ret;
326}
327
328static const struct of_device_id fsl_lbc_match[] = {
329 { .compatible = "fsl,elbc", },
330 { .compatible = "fsl,pq3-localbus", },
331 { .compatible = "fsl,pq2-localbus", },
332 { .compatible = "fsl,pq2pro-localbus", },
333 {},
334};
335
336static struct platform_driver fsl_lbc_ctrl_driver = {
337 .driver = {
338 .name = "fsl-lbc",
339 .of_match_table = fsl_lbc_match,
340 },
341 .probe = fsl_lbc_ctrl_probe,
342};
343
344static int __init fsl_lbc_init(void)
345{
346 return platform_driver_register(&fsl_lbc_ctrl_driver);
347}
348module_init(fsl_lbc_init);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 412763672d23..9725369d432a 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -50,6 +50,7 @@
50#define RIO_ATMU_REGS_OFFSET 0x10c00 50#define RIO_ATMU_REGS_OFFSET 0x10c00
51#define RIO_P_MSG_REGS_OFFSET 0x11000 51#define RIO_P_MSG_REGS_OFFSET 0x11000
52#define RIO_S_MSG_REGS_OFFSET 0x13000 52#define RIO_S_MSG_REGS_OFFSET 0x13000
53#define RIO_GCCSR 0x13c
53#define RIO_ESCSR 0x158 54#define RIO_ESCSR 0x158
54#define RIO_CCSR 0x15c 55#define RIO_CCSR 0x15c
55#define RIO_LTLEDCSR 0x0608 56#define RIO_LTLEDCSR 0x0608
@@ -87,6 +88,9 @@
87#define RIO_IPWSR_PWD 0x00000008 88#define RIO_IPWSR_PWD 0x00000008
88#define RIO_IPWSR_PWB 0x00000004 89#define RIO_IPWSR_PWB 0x00000004
89 90
91#define RIO_EPWISR_PINT 0x80000000
92#define RIO_EPWISR_PW 0x00000001
93
90#define RIO_MSG_DESC_SIZE 32 94#define RIO_MSG_DESC_SIZE 32
91#define RIO_MSG_BUFFER_SIZE 4096 95#define RIO_MSG_BUFFER_SIZE 4096
92#define RIO_MIN_TX_RING_SIZE 2 96#define RIO_MIN_TX_RING_SIZE 2
@@ -1082,18 +1086,12 @@ fsl_rio_port_write_handler(int irq, void *dev_instance)
1082 struct rio_priv *priv = port->priv; 1086 struct rio_priv *priv = port->priv;
1083 u32 epwisr, tmp; 1087 u32 epwisr, tmp;
1084 1088
1085 ipwmr = in_be32(&priv->msg_regs->pwmr);
1086 ipwsr = in_be32(&priv->msg_regs->pwsr);
1087
1088 epwisr = in_be32(priv->regs_win + RIO_EPWISR); 1089 epwisr = in_be32(priv->regs_win + RIO_EPWISR);
1089 if (epwisr & 0x80000000) { 1090 if (!(epwisr & RIO_EPWISR_PW))
1090 tmp = in_be32(priv->regs_win + RIO_LTLEDCSR); 1091 goto pw_done;
1091 pr_info("RIO_LTLEDCSR = 0x%x\n", tmp);
1092 out_be32(priv->regs_win + RIO_LTLEDCSR, 0);
1093 }
1094 1092
1095 if (!(epwisr & 0x00000001)) 1093 ipwmr = in_be32(&priv->msg_regs->pwmr);
1096 return IRQ_HANDLED; 1094 ipwsr = in_be32(&priv->msg_regs->pwsr);
1097 1095
1098#ifdef DEBUG_PW 1096#ifdef DEBUG_PW
1099 pr_debug("PW Int->IPWMR: 0x%08x IPWSR: 0x%08x (", ipwmr, ipwsr); 1097 pr_debug("PW Int->IPWMR: 0x%08x IPWSR: 0x%08x (", ipwmr, ipwsr);
@@ -1109,20 +1107,6 @@ fsl_rio_port_write_handler(int irq, void *dev_instance)
1109 pr_debug(" PWB"); 1107 pr_debug(" PWB");
1110 pr_debug(" )\n"); 1108 pr_debug(" )\n");
1111#endif 1109#endif
1112 out_be32(&priv->msg_regs->pwsr,
1113 ipwsr & (RIO_IPWSR_TE | RIO_IPWSR_QFI | RIO_IPWSR_PWD));
1114
1115 if ((ipwmr & RIO_IPWMR_EIE) && (ipwsr & RIO_IPWSR_TE)) {
1116 priv->port_write_msg.err_count++;
1117 pr_info("RIO: Port-Write Transaction Err (%d)\n",
1118 priv->port_write_msg.err_count);
1119 }
1120 if (ipwsr & RIO_IPWSR_PWD) {
1121 priv->port_write_msg.discard_count++;
1122 pr_info("RIO: Port Discarded Port-Write Msg(s) (%d)\n",
1123 priv->port_write_msg.discard_count);
1124 }
1125
1126 /* Schedule deferred processing if PW was received */ 1110 /* Schedule deferred processing if PW was received */
1127 if (ipwsr & RIO_IPWSR_QFI) { 1111 if (ipwsr & RIO_IPWSR_QFI) {
1128 /* Save PW message (if there is room in FIFO), 1112 /* Save PW message (if there is room in FIFO),
@@ -1134,16 +1118,43 @@ fsl_rio_port_write_handler(int irq, void *dev_instance)
1134 RIO_PW_MSG_SIZE); 1118 RIO_PW_MSG_SIZE);
1135 } else { 1119 } else {
1136 priv->port_write_msg.discard_count++; 1120 priv->port_write_msg.discard_count++;
1137 pr_info("RIO: ISR Discarded Port-Write Msg(s) (%d)\n", 1121 pr_debug("RIO: ISR Discarded Port-Write Msg(s) (%d)\n",
1138 priv->port_write_msg.discard_count); 1122 priv->port_write_msg.discard_count);
1139 } 1123 }
1124 /* Clear interrupt and issue Clear Queue command. This allows
1125 * another port-write to be received.
1126 */
1127 out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_QFI);
1128 out_be32(&priv->msg_regs->pwmr, ipwmr | RIO_IPWMR_CQ);
1129
1140 schedule_work(&priv->pw_work); 1130 schedule_work(&priv->pw_work);
1141 } 1131 }
1142 1132
1143 /* Issue Clear Queue command. This allows another 1133 if ((ipwmr & RIO_IPWMR_EIE) && (ipwsr & RIO_IPWSR_TE)) {
1144 * port-write to be received. 1134 priv->port_write_msg.err_count++;
1145 */ 1135 pr_debug("RIO: Port-Write Transaction Err (%d)\n",
1146 out_be32(&priv->msg_regs->pwmr, ipwmr | RIO_IPWMR_CQ); 1136 priv->port_write_msg.err_count);
1137 /* Clear Transaction Error: port-write controller should be
1138 * disabled when clearing this error
1139 */
1140 out_be32(&priv->msg_regs->pwmr, ipwmr & ~RIO_IPWMR_PWE);
1141 out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_TE);
1142 out_be32(&priv->msg_regs->pwmr, ipwmr);
1143 }
1144
1145 if (ipwsr & RIO_IPWSR_PWD) {
1146 priv->port_write_msg.discard_count++;
1147 pr_debug("RIO: Port Discarded Port-Write Msg(s) (%d)\n",
1148 priv->port_write_msg.discard_count);
1149 out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_PWD);
1150 }
1151
1152pw_done:
1153 if (epwisr & RIO_EPWISR_PINT) {
1154 tmp = in_be32(priv->regs_win + RIO_LTLEDCSR);
1155 pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp);
1156 out_be32(priv->regs_win + RIO_LTLEDCSR, 0);
1157 }
1147 1158
1148 return IRQ_HANDLED; 1159 return IRQ_HANDLED;
1149} 1160}
@@ -1461,6 +1472,7 @@ int fsl_rio_setup(struct platform_device *dev)
1461 port->host_deviceid = fsl_rio_get_hdid(port->id); 1472 port->host_deviceid = fsl_rio_get_hdid(port->id);
1462 1473
1463 port->priv = priv; 1474 port->priv = priv;
1475 port->phys_efptr = 0x100;
1464 rio_register_mport(port); 1476 rio_register_mport(port);
1465 1477
1466 priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1); 1478 priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1);
@@ -1508,6 +1520,12 @@ int fsl_rio_setup(struct platform_device *dev)
1508 dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n", 1520 dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n",
1509 port->sys_size ? 65536 : 256); 1521 port->sys_size ? 65536 : 256);
1510 1522
1523 if (port->host_deviceid >= 0)
1524 out_be32(priv->regs_win + RIO_GCCSR, RIO_PORT_GEN_HOST |
1525 RIO_PORT_GEN_MASTER | RIO_PORT_GEN_DISCOVERED);
1526 else
1527 out_be32(priv->regs_win + RIO_GCCSR, 0x00000000);
1528
1511 priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win 1529 priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win
1512 + RIO_ATMU_REGS_OFFSET); 1530 + RIO_ATMU_REGS_OFFSET);
1513 priv->maint_atmu_regs = priv->atmu_regs + 1; 1531 priv->maint_atmu_regs = priv->atmu_regs + 1;
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 6c67d9ebf166..19e5015e039b 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -209,169 +209,6 @@ 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)
213{
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
228static int __init fsl_usb_of_init(void)
229{
230 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
287 if (!of_device_is_available(np))
288 continue;
289
290 memset(&r, 0, sizeof(r));
291 memset(&usb_data, 0, sizeof(usb_data));
292
293 ret = of_address_to_resource(np, 0, &r[0]);
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 }
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 }
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) 212#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
376static __be32 __iomem *rstcr; 213static __be32 __iomem *rstcr;
377 214
diff --git a/arch/s390/Kbuild b/arch/s390/Kbuild
new file mode 100644
index 000000000000..ae4b01060edd
--- /dev/null
+++ b/arch/s390/Kbuild
@@ -0,0 +1,6 @@
1obj-y += kernel/
2obj-y += mm/
3obj-y += crypto/
4obj-y += appldata/
5obj-y += hypfs/
6obj-y += kvm/
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 75976a141947..e0b98e71ff47 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -1,8 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6config SCHED_MC 1config SCHED_MC
7 def_bool y 2 def_bool y
8 depends on SMP 3 depends on SMP
@@ -60,6 +55,9 @@ config NO_IOMEM
60config NO_DMA 55config NO_DMA
61 def_bool y 56 def_bool y
62 57
58config ARCH_DMA_ADDR_T_64BIT
59 def_bool 64BIT
60
63config GENERIC_LOCKBREAK 61config GENERIC_LOCKBREAK
64 bool 62 bool
65 default y 63 default y
@@ -75,8 +73,6 @@ config VIRT_CPU_ACCOUNTING
75config ARCH_SUPPORTS_DEBUG_PAGEALLOC 73config ARCH_SUPPORTS_DEBUG_PAGEALLOC
76 def_bool y 74 def_bool y
77 75
78mainmenu "Linux Kernel Configuration"
79
80config S390 76config S390
81 def_bool y 77 def_bool y
82 select USE_GENERIC_SMP_HELPERS if SMP 78 select USE_GENERIC_SMP_HELPERS if SMP
@@ -84,6 +80,7 @@ config S390
84 select HAVE_FUNCTION_TRACER 80 select HAVE_FUNCTION_TRACER
85 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 81 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
86 select HAVE_FTRACE_MCOUNT_RECORD 82 select HAVE_FTRACE_MCOUNT_RECORD
83 select HAVE_C_RECORDMCOUNT
87 select HAVE_SYSCALL_TRACEPOINTS 84 select HAVE_SYSCALL_TRACEPOINTS
88 select HAVE_DYNAMIC_FTRACE 85 select HAVE_DYNAMIC_FTRACE
89 select HAVE_FUNCTION_GRAPH_TRACER 86 select HAVE_FUNCTION_GRAPH_TRACER
@@ -101,6 +98,7 @@ config S390
101 select HAVE_KERNEL_BZIP2 98 select HAVE_KERNEL_BZIP2
102 select HAVE_KERNEL_LZMA 99 select HAVE_KERNEL_LZMA
103 select HAVE_KERNEL_LZO 100 select HAVE_KERNEL_LZO
101 select HAVE_GET_USER_PAGES_FAST
104 select ARCH_INLINE_SPIN_TRYLOCK 102 select ARCH_INLINE_SPIN_TRYLOCK
105 select ARCH_INLINE_SPIN_TRYLOCK_BH 103 select ARCH_INLINE_SPIN_TRYLOCK_BH
106 select ARCH_INLINE_SPIN_LOCK 104 select ARCH_INLINE_SPIN_LOCK
@@ -147,7 +145,7 @@ source "kernel/time/Kconfig"
147config 64BIT 145config 64BIT
148 bool "64 bit kernel" 146 bool "64 bit kernel"
149 help 147 help
150 Select this option if you have a 64 bit IBM zSeries machine 148 Select this option if you have an IBM z/Architecture machine
151 and want to use the 64 bit addressing mode. 149 and want to use the 64 bit addressing mode.
152 150
153config 32BIT 151config 32BIT
@@ -199,9 +197,18 @@ config HOTPLUG_CPU
199 can be controlled through /sys/devices/system/cpu/cpu#. 197 can be controlled through /sys/devices/system/cpu/cpu#.
200 Say N if you want to disable CPU hotplug. 198 Say N if you want to disable CPU hotplug.
201 199
200config SCHED_MC
201 def_bool y
202 prompt "Multi-core scheduler support"
203 depends on SMP
204 help
205 Multi-core scheduler support improves the CPU scheduler's decision
206 making when dealing with multi-core CPU chips at a cost of slightly
207 increased overhead in some places.
208
202config SCHED_BOOK 209config SCHED_BOOK
203 bool "Book scheduler support" 210 bool "Book scheduler support"
204 depends on SMP 211 depends on SMP && SCHED_MC
205 help 212 help
206 Book scheduler support improves the CPU scheduler's decision making 213 Book scheduler support improves the CPU scheduler's decision making
207 when dealing with machines that have several books. 214 when dealing with machines that have several books.
@@ -211,7 +218,7 @@ config MATHEMU
211 depends on MARCH_G5 218 depends on MARCH_G5
212 help 219 help
213 This option is required for IEEE compliant floating point arithmetic 220 This option is required for IEEE compliant floating point arithmetic
214 on older S/390 machines. Say Y unless you know your machine doesn't 221 on older ESA/390 machines. Say Y unless you know your machine doesn't
215 need this. 222 need this.
216 223
217config COMPAT 224config COMPAT
@@ -240,8 +247,8 @@ config S390_EXEC_PROTECT
240 space programs and it also selects the addressing mode option above. 247 space programs and it also selects the addressing mode option above.
241 The kernel parameter noexec=on will enable this feature and also 248 The kernel parameter noexec=on will enable this feature and also
242 switch the addressing modes, default is disabled. Enabling this (via 249 switch the addressing modes, default is disabled. Enabling this (via
243 kernel parameter) on machines earlier than IBM System z9-109 EC/BC 250 kernel parameter) on machines earlier than IBM System z9 this will
244 will reduce system performance. 251 reduce system performance.
245 252
246comment "Code generation options" 253comment "Code generation options"
247 254
@@ -250,41 +257,46 @@ choice
250 default MARCH_G5 257 default MARCH_G5
251 258
252config MARCH_G5 259config MARCH_G5
253 bool "S/390 model G5 and G6" 260 bool "System/390 model G5 and G6"
254 depends on !64BIT 261 depends on !64BIT
255 help 262 help
256 Select this to build a 31 bit kernel that works 263 Select this to build a 31 bit kernel that works
257 on all S/390 and zSeries machines. 264 on all ESA/390 and z/Architecture machines.
258 265
259config MARCH_Z900 266config MARCH_Z900
260 bool "IBM eServer zSeries model z800 and z900" 267 bool "IBM zSeries model z800 and z900"
261 help 268 help
262 Select this to optimize for zSeries machines. This 269 Select this to enable optimizations for model z800/z900 (2064 and
263 will enable some optimizations that are not available 270 2066 series). This will enable some optimizations that are not
264 on older 31 bit only CPUs. 271 available on older ESA/390 (31 Bit) only CPUs.
265 272
266config MARCH_Z990 273config MARCH_Z990
267 bool "IBM eServer zSeries model z890 and z990" 274 bool "IBM zSeries model z890 and z990"
268 help 275 help
269 Select this enable optimizations for model z890/z990. 276 Select this to enable optimizations for model z890/z990 (2084 and
270 This will be slightly faster but does not work on 277 2086 series). The kernel will be slightly faster but will not work
271 older machines such as the z900. 278 on older machines.
272 279
273config MARCH_Z9_109 280config MARCH_Z9_109
274 bool "IBM System z9" 281 bool "IBM System z9"
275 help 282 help
276 Select this to enable optimizations for IBM System z9-109, IBM 283 Select this to enable optimizations for IBM System z9 (2094 and
277 System z9 Enterprise Class (z9 EC), and IBM System z9 Business 284 2096 series). The kernel will be slightly faster but will not work
278 Class (z9 BC). The kernel will be slightly faster but will not 285 on older machines.
279 work on older machines such as the z990, z890, z900, and z800.
280 286
281config MARCH_Z10 287config MARCH_Z10
282 bool "IBM System z10" 288 bool "IBM System z10"
283 help 289 help
284 Select this to enable optimizations for IBM System z10. The 290 Select this to enable optimizations for IBM System z10 (2097 and
285 kernel will be slightly faster but will not work on older 291 2098 series). The kernel will be slightly faster but will not work
286 machines such as the z990, z890, z900, z800, z9-109, z9-ec 292 on older machines.
287 and z9-bc. 293
294config MARCH_Z196
295 bool "IBM zEnterprise 196"
296 help
297 Select this to enable optimizations for IBM zEnterprise 196
298 (2817 series). The kernel will be slightly faster but will not work
299 on older machines.
288 300
289endchoice 301endchoice
290 302
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 0c9e6c6d2a64..d5b8a6ade525 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -40,6 +40,7 @@ cflags-$(CONFIG_MARCH_Z900) += $(call cc-option,-march=z900)
40cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990) 40cflags-$(CONFIG_MARCH_Z990) += $(call cc-option,-march=z990)
41cflags-$(CONFIG_MARCH_Z9_109) += $(call cc-option,-march=z9-109) 41cflags-$(CONFIG_MARCH_Z9_109) += $(call cc-option,-march=z9-109)
42cflags-$(CONFIG_MARCH_Z10) += $(call cc-option,-march=z10) 42cflags-$(CONFIG_MARCH_Z10) += $(call cc-option,-march=z10)
43cflags-$(CONFIG_MARCH_Z196) += $(call cc-option,-march=z196)
43 44
44#KBUILD_IMAGE is necessary for make rpm 45#KBUILD_IMAGE is necessary for make rpm
45KBUILD_IMAGE :=arch/s390/boot/image 46KBUILD_IMAGE :=arch/s390/boot/image
@@ -94,8 +95,8 @@ head-y := arch/s390/kernel/head.o
94head-y += arch/s390/kernel/$(if $(CONFIG_64BIT),head64.o,head31.o) 95head-y += arch/s390/kernel/$(if $(CONFIG_64BIT),head64.o,head31.o)
95head-y += arch/s390/kernel/init_task.o 96head-y += arch/s390/kernel/init_task.o
96 97
97core-y += arch/s390/mm/ arch/s390/kernel/ arch/s390/crypto/ \ 98# See arch/s390/Kbuild for content of core part of the kernel
98 arch/s390/appldata/ arch/s390/hypfs/ arch/s390/kvm/ 99core-y += arch/s390/
99 100
100libs-y += arch/s390/lib/ 101libs-y += arch/s390/lib/
101drivers-y += drivers/s390/ 102drivers-y += drivers/s390/
diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h
index 0ef9829f2ad6..7ee9a1b4ad9f 100644
--- a/arch/s390/crypto/crypt_s390.h
+++ b/arch/s390/crypto/crypt_s390.h
@@ -297,7 +297,7 @@ static inline int crypt_s390_func_available(int func)
297 int ret; 297 int ret;
298 298
299 /* check if CPACF facility (bit 17) is available */ 299 /* check if CPACF facility (bit 17) is available */
300 if (!(stfl() & 1ULL << (31 - 17))) 300 if (!test_facility(17))
301 return 0; 301 return 0;
302 302
303 switch (func & CRYPT_S390_OP_MASK) { 303 switch (func & CRYPT_S390_OP_MASK) {
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..cd4a81be9cf8 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)
@@ -637,18 +638,21 @@ __init int hypfs_diag_init(void)
637 pr_err("The hardware system does not support hypfs\n"); 638 pr_err("The hardware system does not support hypfs\n");
638 return -ENODATA; 639 return -ENODATA;
639 } 640 }
640 rc = diag224_get_name_table();
641 if (rc) {
642 diag204_free_buffer();
643 pr_err("The hardware system does not provide all "
644 "functions required by hypfs\n");
645 }
646 if (diag204_info_type == INFO_EXT) { 641 if (diag204_info_type == INFO_EXT) {
647 rc = hypfs_dbfs_init(); 642 rc = hypfs_dbfs_init();
648 if (rc) 643 if (rc)
649 diag204_free_buffer(); 644 return rc;
650 } 645 }
651 return rc; 646 if (MACHINE_IS_LPAR) {
647 rc = diag224_get_name_table();
648 if (rc) {
649 pr_err("The hardware system does not provide all "
650 "functions required by hypfs\n");
651 debugfs_remove(dbfs_d204_file);
652 return rc;
653 }
654 }
655 return 0;
652} 656}
653 657
654void hypfs_diag_exit(void) 658void hypfs_diag_exit(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..47cc446dab8f 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -316,10 +316,10 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
316 return 0; 316 return 0;
317} 317}
318 318
319static int hypfs_get_super(struct file_system_type *fst, int flags, 319static struct dentry *hypfs_mount(struct file_system_type *fst, int flags,
320 const char *devname, void *data, struct vfsmount *mnt) 320 const char *devname, void *data)
321{ 321{
322 return get_sb_single(fst, flags, data, hypfs_fill_super, mnt); 322 return mount_single(fst, flags, data, hypfs_fill_super);
323} 323}
324 324
325static void hypfs_kill_super(struct super_block *sb) 325static void hypfs_kill_super(struct super_block *sb)
@@ -449,12 +449,13 @@ 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 = {
455 .owner = THIS_MODULE, 456 .owner = THIS_MODULE,
456 .name = "s390_hypfs", 457 .name = "s390_hypfs",
457 .get_sb = hypfs_get_super, 458 .mount = hypfs_mount,
458 .kill_sb = hypfs_kill_super 459 .kill_sb = hypfs_kill_super
459}; 460};
460 461
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/ccwdev.h b/arch/s390/include/asm/ccwdev.h
index f3ba0fa98de6..e8501115eca8 100644
--- a/arch/s390/include/asm/ccwdev.h
+++ b/arch/s390/include/asm/ccwdev.h
@@ -92,6 +92,16 @@ struct ccw_device {
92}; 92};
93 93
94/* 94/*
95 * Possible events used by the path_event notifier.
96 */
97#define PE_NONE 0x0
98#define PE_PATH_GONE 0x1 /* A path is no longer available. */
99#define PE_PATH_AVAILABLE 0x2 /* A path has become available and
100 was successfully verified. */
101#define PE_PATHGROUP_ESTABLISHED 0x4 /* A pathgroup was reset and had
102 to be established again. */
103
104/*
95 * Possible CIO actions triggered by the unit check handler. 105 * Possible CIO actions triggered by the unit check handler.
96 */ 106 */
97enum uc_todo { 107enum uc_todo {
@@ -109,6 +119,7 @@ enum uc_todo {
109 * @set_online: called when setting device online 119 * @set_online: called when setting device online
110 * @set_offline: called when setting device offline 120 * @set_offline: called when setting device offline
111 * @notify: notify driver of device state changes 121 * @notify: notify driver of device state changes
122 * @path_event: notify driver of channel path events
112 * @shutdown: called at device shutdown 123 * @shutdown: called at device shutdown
113 * @prepare: prepare for pm state transition 124 * @prepare: prepare for pm state transition
114 * @complete: undo work done in @prepare 125 * @complete: undo work done in @prepare
@@ -127,6 +138,7 @@ struct ccw_driver {
127 int (*set_online) (struct ccw_device *); 138 int (*set_online) (struct ccw_device *);
128 int (*set_offline) (struct ccw_device *); 139 int (*set_offline) (struct ccw_device *);
129 int (*notify) (struct ccw_device *, int); 140 int (*notify) (struct ccw_device *, int);
141 void (*path_event) (struct ccw_device *, int *);
130 void (*shutdown) (struct ccw_device *); 142 void (*shutdown) (struct ccw_device *);
131 int (*prepare) (struct ccw_device *); 143 int (*prepare) (struct ccw_device *);
132 void (*complete) (struct ccw_device *); 144 void (*complete) (struct ccw_device *);
diff --git a/arch/s390/include/asm/cpu.h b/arch/s390/include/asm/cpu.h
index 471234b90574..e0b69540216f 100644
--- a/arch/s390/include/asm/cpu.h
+++ b/arch/s390/include/asm/cpu.h
@@ -20,7 +20,7 @@ struct cpuid
20 unsigned int ident : 24; 20 unsigned int ident : 24;
21 unsigned int machine : 16; 21 unsigned int machine : 16;
22 unsigned int unused : 16; 22 unsigned int unused : 16;
23} __packed; 23} __attribute__ ((packed, aligned(8)));
24 24
25#endif /* __ASSEMBLY__ */ 25#endif /* __ASSEMBLY__ */
26#endif /* _ASM_S390_CPU_H */ 26#endif /* _ASM_S390_CPU_H */
diff --git a/arch/s390/include/asm/cputime.h b/arch/s390/include/asm/cputime.h
index 8b1a52a137c5..40e2ab0fa3f0 100644
--- a/arch/s390/include/asm/cputime.h
+++ b/arch/s390/include/asm/cputime.h
@@ -73,18 +73,18 @@ cputime64_to_jiffies64(cputime64_t cputime)
73} 73}
74 74
75/* 75/*
76 * Convert cputime to milliseconds and back. 76 * Convert cputime to microseconds and back.
77 */ 77 */
78static inline unsigned int 78static inline unsigned int
79cputime_to_msecs(const cputime_t cputime) 79cputime_to_usecs(const cputime_t cputime)
80{ 80{
81 return cputime_div(cputime, 4096000); 81 return cputime_div(cputime, 4096);
82} 82}
83 83
84static inline cputime_t 84static inline cputime_t
85msecs_to_cputime(const unsigned int m) 85usecs_to_cputime(const unsigned int m)
86{ 86{
87 return (cputime_t) m * 4096000; 87 return (cputime_t) m * 4096;
88} 88}
89 89
90/* 90/*
diff --git a/arch/s390/include/asm/dasd.h b/arch/s390/include/asm/dasd.h
index 218bce81ec70..b604a9186f8e 100644
--- a/arch/s390/include/asm/dasd.h
+++ b/arch/s390/include/asm/dasd.h
@@ -217,6 +217,25 @@ typedef struct dasd_symmio_parms {
217 int rssd_result_len; 217 int rssd_result_len;
218} __attribute__ ((packed)) dasd_symmio_parms_t; 218} __attribute__ ((packed)) dasd_symmio_parms_t;
219 219
220/*
221 * Data returned by Sense Path Group ID (SNID)
222 */
223struct dasd_snid_data {
224 struct {
225 __u8 group:2;
226 __u8 reserve:2;
227 __u8 mode:1;
228 __u8 res:3;
229 } __attribute__ ((packed)) path_state;
230 __u8 pgid[11];
231} __attribute__ ((packed));
232
233struct dasd_snid_ioctl_data {
234 struct dasd_snid_data data;
235 __u8 path_mask;
236} __attribute__ ((packed));
237
238
220/******************************************************************************** 239/********************************************************************************
221 * SECTION: Definition of IOCTLs 240 * SECTION: Definition of IOCTLs
222 * 241 *
@@ -261,25 +280,10 @@ typedef struct dasd_symmio_parms {
261/* Set Attributes (cache operations) */ 280/* Set Attributes (cache operations) */
262#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t) 281#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
263 282
283/* Get Sense Path Group ID (SNID) data */
284#define BIODASDSNID _IOWR(DASD_IOCTL_LETTER, 1, struct dasd_snid_ioctl_data)
285
264#define BIODASDSYMMIO _IOWR(DASD_IOCTL_LETTER, 240, dasd_symmio_parms_t) 286#define BIODASDSYMMIO _IOWR(DASD_IOCTL_LETTER, 240, dasd_symmio_parms_t)
265 287
266#endif /* DASD_H */ 288#endif /* DASD_H */
267 289
268/*
269 * Overrides for Emacs so that we follow Linus's tabbing style.
270 * Emacs will notice this stuff at the end of the file and automatically
271 * adjust the settings for this buffer only. This must remain at the end
272 * of the file.
273 * ---------------------------------------------------------------------------
274 * Local variables:
275 * c-indent-level: 4
276 * c-brace-imaginary-offset: 0
277 * c-brace-offset: -4
278 * c-argdecl-indent: 4
279 * c-label-offset: -4
280 * c-continued-statement-offset: 4
281 * c-continued-brace-offset: 0
282 * indent-tabs-mode: nil
283 * tab-width: 8
284 * End:
285 */
diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h
index bb8343d157bc..b56403c2df28 100644
--- a/arch/s390/include/asm/hugetlb.h
+++ b/arch/s390/include/asm/hugetlb.h
@@ -37,32 +37,6 @@ static inline int prepare_hugepage_range(struct file *file,
37int arch_prepare_hugepage(struct page *page); 37int arch_prepare_hugepage(struct page *page);
38void arch_release_hugepage(struct page *page); 38void arch_release_hugepage(struct page *page);
39 39
40static inline pte_t pte_mkhuge(pte_t pte)
41{
42 /*
43 * PROT_NONE needs to be remapped from the pte type to the ste type.
44 * The HW invalid bit is also different for pte and ste. The pte
45 * invalid bit happens to be the same as the ste _SEGMENT_ENTRY_LARGE
46 * bit, so we don't have to clear it.
47 */
48 if (pte_val(pte) & _PAGE_INVALID) {
49 if (pte_val(pte) & _PAGE_SWT)
50 pte_val(pte) |= _HPAGE_TYPE_NONE;
51 pte_val(pte) |= _SEGMENT_ENTRY_INV;
52 }
53 /*
54 * Clear SW pte bits SWT and SWX, there are no SW bits in a segment
55 * table entry.
56 */
57 pte_val(pte) &= ~(_PAGE_SWT | _PAGE_SWX);
58 /*
59 * Also set the change-override bit because we don't need dirty bit
60 * tracking for hugetlbfs pages.
61 */
62 pte_val(pte) |= (_SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_CO);
63 return pte;
64}
65
66static inline pte_t huge_pte_wrprotect(pte_t pte) 40static inline pte_t huge_pte_wrprotect(pte_t pte)
67{ 41{
68 pte_val(pte) |= _PAGE_RO; 42 pte_val(pte) |= _PAGE_RO;
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/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/lowcore.h b/arch/s390/include/asm/lowcore.h
index 0f97ef2d92ac..65e172f8209d 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -150,9 +150,10 @@ struct _lowcore {
150 */ 150 */
151 __u32 ipib; /* 0x0e00 */ 151 __u32 ipib; /* 0x0e00 */
152 __u32 ipib_checksum; /* 0x0e04 */ 152 __u32 ipib_checksum; /* 0x0e04 */
153 __u8 pad_0x0e08[0x0f00-0x0e08]; /* 0x0e08 */
153 154
154 /* Align to the top 1k of prefix area */ 155 /* Extended facility list */
155 __u8 pad_0x0e08[0x1000-0x0e08]; /* 0x0e08 */ 156 __u64 stfle_fac_list[32]; /* 0x0f00 */
156} __packed; 157} __packed;
157 158
158#else /* CONFIG_32BIT */ 159#else /* CONFIG_32BIT */
@@ -285,7 +286,11 @@ struct _lowcore {
285 */ 286 */
286 __u64 ipib; /* 0x0e00 */ 287 __u64 ipib; /* 0x0e00 */
287 __u32 ipib_checksum; /* 0x0e08 */ 288 __u32 ipib_checksum; /* 0x0e08 */
288 __u8 pad_0x0e0c[0x11b8-0x0e0c]; /* 0x0e0c */ 289 __u8 pad_0x0e0c[0x0f00-0x0e0c]; /* 0x0e0c */
290
291 /* Extended facility list */
292 __u64 stfle_fac_list[32]; /* 0x0f00 */
293 __u8 pad_0x1000[0x11b8-0x1000]; /* 0x1000 */
289 294
290 /* 64 bit extparam used for pfault/diag 250: defined by architecture */ 295 /* 64 bit extparam used for pfault/diag 250: defined by architecture */
291 __u64 ext_params2; /* 0x11B8 */ 296 __u64 ext_params2; /* 0x11B8 */
diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h
index af650fb47206..a8729ea7e9ac 100644
--- a/arch/s390/include/asm/page.h
+++ b/arch/s390/include/asm/page.h
@@ -108,9 +108,13 @@ typedef pte_t *pgtable_t;
108#define __pgprot(x) ((pgprot_t) { (x) } ) 108#define __pgprot(x) ((pgprot_t) { (x) } )
109 109
110static inline void 110static inline void
111page_set_storage_key(unsigned long addr, unsigned int skey) 111page_set_storage_key(unsigned long addr, unsigned int skey, int mapped)
112{ 112{
113 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr)); 113 if (!mapped)
114 asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0"
115 : : "d" (skey), "a" (addr));
116 else
117 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr));
114} 118}
115 119
116static inline unsigned int 120static inline unsigned int
diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h
index 68940d0bad91..082eb4e50e8b 100644
--- a/arch/s390/include/asm/pgalloc.h
+++ b/arch/s390/include/asm/pgalloc.h
@@ -21,9 +21,11 @@
21 21
22unsigned long *crst_table_alloc(struct mm_struct *, int); 22unsigned long *crst_table_alloc(struct mm_struct *, int);
23void crst_table_free(struct mm_struct *, unsigned long *); 23void crst_table_free(struct mm_struct *, unsigned long *);
24void crst_table_free_rcu(struct mm_struct *, unsigned long *);
24 25
25unsigned long *page_table_alloc(struct mm_struct *); 26unsigned long *page_table_alloc(struct mm_struct *);
26void page_table_free(struct mm_struct *, unsigned long *); 27void page_table_free(struct mm_struct *, unsigned long *);
28void page_table_free_rcu(struct mm_struct *, unsigned long *);
27void disable_noexec(struct mm_struct *, struct task_struct *); 29void disable_noexec(struct mm_struct *, struct task_struct *);
28 30
29static inline void clear_table(unsigned long *s, unsigned long val, size_t n) 31static inline void clear_table(unsigned long *s, unsigned long val, size_t n)
@@ -176,4 +178,6 @@ static inline void pmd_populate(struct mm_struct *mm,
176#define pte_free_kernel(mm, pte) page_table_free(mm, (unsigned long *) pte) 178#define pte_free_kernel(mm, pte) page_table_free(mm, (unsigned long *) pte)
177#define pte_free(mm, pte) page_table_free(mm, (unsigned long *) pte) 179#define pte_free(mm, pte) page_table_free(mm, (unsigned long *) pte)
178 180
181extern void rcu_table_freelist_finish(void);
182
179#endif /* _S390_PGALLOC_H */ 183#endif /* _S390_PGALLOC_H */
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 3157441ee1da..02ace3491c51 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -38,6 +38,7 @@
38extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096))); 38extern pgd_t swapper_pg_dir[] __attribute__ ((aligned (4096)));
39extern void paging_init(void); 39extern void paging_init(void);
40extern void vmem_map_init(void); 40extern void vmem_map_init(void);
41extern void fault_init(void);
41 42
42/* 43/*
43 * The S390 doesn't have any external MMU info: the kernel page 44 * The S390 doesn't have any external MMU info: the kernel page
@@ -46,11 +47,27 @@ extern void vmem_map_init(void);
46#define update_mmu_cache(vma, address, ptep) do { } while (0) 47#define update_mmu_cache(vma, address, ptep) do { } while (0)
47 48
48/* 49/*
49 * ZERO_PAGE is a global shared page that is always zero: used 50 * ZERO_PAGE is a global shared page that is always zero; used
50 * for zero-mapped memory areas etc.. 51 * for zero-mapped memory areas etc..
51 */ 52 */
52extern char empty_zero_page[PAGE_SIZE]; 53
53#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 54extern unsigned long empty_zero_page;
55extern unsigned long zero_page_mask;
56
57#define ZERO_PAGE(vaddr) \
58 (virt_to_page((void *)(empty_zero_page + \
59 (((unsigned long)(vaddr)) &zero_page_mask))))
60
61#define is_zero_pfn is_zero_pfn
62static inline int is_zero_pfn(unsigned long pfn)
63{
64 extern unsigned long zero_pfn;
65 unsigned long offset_from_zero_pfn = pfn - zero_pfn;
66 return offset_from_zero_pfn <= (zero_page_mask >> PAGE_SHIFT);
67}
68
69#define my_zero_pfn(addr) page_to_pfn(ZERO_PAGE(addr))
70
54#endif /* !__ASSEMBLY__ */ 71#endif /* !__ASSEMBLY__ */
55 72
56/* 73/*
@@ -300,6 +317,7 @@ extern unsigned long VMALLOC_START;
300 317
301/* Bits in the segment table entry */ 318/* Bits in the segment table entry */
302#define _SEGMENT_ENTRY_ORIGIN 0x7fffffc0UL /* page table origin */ 319#define _SEGMENT_ENTRY_ORIGIN 0x7fffffc0UL /* page table origin */
320#define _SEGMENT_ENTRY_RO 0x200 /* page protection bit */
303#define _SEGMENT_ENTRY_INV 0x20 /* invalid segment table entry */ 321#define _SEGMENT_ENTRY_INV 0x20 /* invalid segment table entry */
304#define _SEGMENT_ENTRY_COMMON 0x10 /* common segment bit */ 322#define _SEGMENT_ENTRY_COMMON 0x10 /* common segment bit */
305#define _SEGMENT_ENTRY_PTL 0x0f /* page table length */ 323#define _SEGMENT_ENTRY_PTL 0x0f /* page table length */
@@ -572,7 +590,7 @@ static inline void rcp_unlock(pte_t *ptep)
572} 590}
573 591
574/* forward declaration for SetPageUptodate in page-flags.h*/ 592/* forward declaration for SetPageUptodate in page-flags.h*/
575static inline void page_clear_dirty(struct page *page); 593static inline void page_clear_dirty(struct page *page, int mapped);
576#include <linux/page-flags.h> 594#include <linux/page-flags.h>
577 595
578static inline void ptep_rcp_copy(pte_t *ptep) 596static inline void ptep_rcp_copy(pte_t *ptep)
@@ -754,6 +772,34 @@ static inline pte_t pte_mkspecial(pte_t pte)
754 return pte; 772 return pte;
755} 773}
756 774
775#ifdef CONFIG_HUGETLB_PAGE
776static inline pte_t pte_mkhuge(pte_t pte)
777{
778 /*
779 * PROT_NONE needs to be remapped from the pte type to the ste type.
780 * The HW invalid bit is also different for pte and ste. The pte
781 * invalid bit happens to be the same as the ste _SEGMENT_ENTRY_LARGE
782 * bit, so we don't have to clear it.
783 */
784 if (pte_val(pte) & _PAGE_INVALID) {
785 if (pte_val(pte) & _PAGE_SWT)
786 pte_val(pte) |= _HPAGE_TYPE_NONE;
787 pte_val(pte) |= _SEGMENT_ENTRY_INV;
788 }
789 /*
790 * Clear SW pte bits SWT and SWX, there are no SW bits in a segment
791 * table entry.
792 */
793 pte_val(pte) &= ~(_PAGE_SWT | _PAGE_SWX);
794 /*
795 * Also set the change-override bit because we don't need dirty bit
796 * tracking for hugetlbfs pages.
797 */
798 pte_val(pte) |= (_SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_CO);
799 return pte;
800}
801#endif
802
757#ifdef CONFIG_PGSTE 803#ifdef CONFIG_PGSTE
758/* 804/*
759 * Get (and clear) the user dirty bit for a PTE. 805 * Get (and clear) the user dirty bit for a PTE.
@@ -782,7 +828,7 @@ static inline int kvm_s390_test_and_clear_page_dirty(struct mm_struct *mm,
782 } 828 }
783 dirty = test_and_clear_bit_simple(KVM_UD_BIT, pgste); 829 dirty = test_and_clear_bit_simple(KVM_UD_BIT, pgste);
784 if (skey & _PAGE_CHANGED) 830 if (skey & _PAGE_CHANGED)
785 page_clear_dirty(page); 831 page_clear_dirty(page, 1);
786 rcp_unlock(ptep); 832 rcp_unlock(ptep);
787 return dirty; 833 return dirty;
788} 834}
@@ -957,9 +1003,9 @@ static inline int page_test_dirty(struct page *page)
957} 1003}
958 1004
959#define __HAVE_ARCH_PAGE_CLEAR_DIRTY 1005#define __HAVE_ARCH_PAGE_CLEAR_DIRTY
960static inline void page_clear_dirty(struct page *page) 1006static inline void page_clear_dirty(struct page *page, int mapped)
961{ 1007{
962 page_set_storage_key(page_to_phys(page), PAGE_DEFAULT_KEY); 1008 page_set_storage_key(page_to_phys(page), PAGE_DEFAULT_KEY, mapped);
963} 1009}
964 1010
965/* 1011/*
@@ -1048,9 +1094,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
1048#define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr)) 1094#define pte_offset(pmd, addr) ((pte_t *) pmd_deref(*(pmd)) + pte_index(addr))
1049#define pte_offset_kernel(pmd, address) pte_offset(pmd,address) 1095#define pte_offset_kernel(pmd, address) pte_offset(pmd,address)
1050#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address) 1096#define pte_offset_map(pmd, address) pte_offset_kernel(pmd, address)
1051#define pte_offset_map_nested(pmd, address) pte_offset_kernel(pmd, address)
1052#define pte_unmap(pte) do { } while (0) 1097#define pte_unmap(pte) do { } while (0)
1053#define pte_unmap_nested(pte) do { } while (0)
1054 1098
1055/* 1099/*
1056 * 31 bit swap entry format: 1100 * 31 bit swap entry format:
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
index 73e259834e10..8d6f87169577 100644
--- a/arch/s390/include/asm/processor.h
+++ b/arch/s390/include/asm/processor.h
@@ -82,8 +82,6 @@ struct thread_struct {
82 unsigned long prot_addr; /* address of protection-excep. */ 82 unsigned long prot_addr; /* address of protection-excep. */
83 unsigned int trap_no; 83 unsigned int trap_no;
84 per_struct per_info; 84 per_struct per_info;
85 /* Used to give failing instruction back to user for ieee exceptions */
86 unsigned long ieee_instruction_pointer;
87 /* pfault_wait is used to block the process on a pfault event */ 85 /* pfault_wait is used to block the process on a pfault event */
88 unsigned long pfault_wait; 86 unsigned long pfault_wait;
89}; 87};
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index e2c218dc68a6..d9d42b1e46fa 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -481,8 +481,7 @@ struct user_regs_struct
481 * watchpoints. This is the way intel does it. 481 * watchpoints. This is the way intel does it.
482 */ 482 */
483 per_struct per_info; 483 per_struct per_info;
484 unsigned long ieee_instruction_pointer; 484 unsigned long ieee_instruction_pointer; /* obsolete, always 0 */
485 /* Used to give failing instruction back to user for ieee exceptions */
486}; 485};
487 486
488#ifdef __KERNEL__ 487#ifdef __KERNEL__
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/s390_ext.h b/arch/s390/include/asm/s390_ext.h
index 2afc060266a2..1a9307e70842 100644
--- a/arch/s390/include/asm/s390_ext.h
+++ b/arch/s390/include/asm/s390_ext.h
@@ -12,7 +12,7 @@
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14 14
15typedef void (*ext_int_handler_t)(__u16 code); 15typedef void (*ext_int_handler_t)(unsigned int, unsigned int, unsigned long);
16 16
17typedef struct ext_int_info_t { 17typedef struct ext_int_info_t {
18 struct ext_int_info_t *next; 18 struct ext_int_info_t *next;
diff --git a/arch/s390/include/asm/scatterlist.h b/arch/s390/include/asm/scatterlist.h
index 35d786fe93ae..6d45ef6c12a7 100644
--- a/arch/s390/include/asm/scatterlist.h
+++ b/arch/s390/include/asm/scatterlist.h
@@ -1 +1,3 @@
1#include <asm-generic/scatterlist.h> 1#include <asm-generic/scatterlist.h>
2
3#define ARCH_HAS_SG_CHAIN
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index 25e831d58e1e..d5e2ef10537d 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -73,6 +73,7 @@ extern unsigned int user_mode;
73#define MACHINE_FLAG_PFMF (1UL << 11) 73#define MACHINE_FLAG_PFMF (1UL << 11)
74#define MACHINE_FLAG_LPAR (1UL << 12) 74#define MACHINE_FLAG_LPAR (1UL << 12)
75#define MACHINE_FLAG_SPP (1UL << 13) 75#define MACHINE_FLAG_SPP (1UL << 13)
76#define MACHINE_FLAG_TOPOLOGY (1UL << 14)
76 77
77#define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM) 78#define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM)
78#define MACHINE_IS_KVM (S390_lowcore.machine_flags & MACHINE_FLAG_KVM) 79#define MACHINE_IS_KVM (S390_lowcore.machine_flags & MACHINE_FLAG_KVM)
@@ -90,6 +91,7 @@ extern unsigned int user_mode;
90#define MACHINE_HAS_HPAGE (0) 91#define MACHINE_HAS_HPAGE (0)
91#define MACHINE_HAS_PFMF (0) 92#define MACHINE_HAS_PFMF (0)
92#define MACHINE_HAS_SPP (0) 93#define MACHINE_HAS_SPP (0)
94#define MACHINE_HAS_TOPOLOGY (0)
93#else /* __s390x__ */ 95#else /* __s390x__ */
94#define MACHINE_HAS_IEEE (1) 96#define MACHINE_HAS_IEEE (1)
95#define MACHINE_HAS_CSP (1) 97#define MACHINE_HAS_CSP (1)
@@ -100,6 +102,7 @@ extern unsigned int user_mode;
100#define MACHINE_HAS_HPAGE (S390_lowcore.machine_flags & MACHINE_FLAG_HPAGE) 102#define MACHINE_HAS_HPAGE (S390_lowcore.machine_flags & MACHINE_FLAG_HPAGE)
101#define MACHINE_HAS_PFMF (S390_lowcore.machine_flags & MACHINE_FLAG_PFMF) 103#define MACHINE_HAS_PFMF (S390_lowcore.machine_flags & MACHINE_FLAG_PFMF)
102#define MACHINE_HAS_SPP (S390_lowcore.machine_flags & MACHINE_FLAG_SPP) 104#define MACHINE_HAS_SPP (S390_lowcore.machine_flags & MACHINE_FLAG_SPP)
105#define MACHINE_HAS_TOPOLOGY (S390_lowcore.machine_flags & MACHINE_FLAG_TOPOLOGY)
103#endif /* __s390x__ */ 106#endif /* __s390x__ */
104 107
105#define ZFCPDUMP_HSA_SIZE (32UL<<20) 108#define ZFCPDUMP_HSA_SIZE (32UL<<20)
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
index 8429686951f9..5c0246b955d8 100644
--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -65,8 +65,6 @@ static inline void syscall_get_arguments(struct task_struct *task,
65 if (test_tsk_thread_flag(task, TIF_31BIT)) 65 if (test_tsk_thread_flag(task, TIF_31BIT))
66 mask = 0xffffffff; 66 mask = 0xffffffff;
67#endif 67#endif
68 if (i + n == 6)
69 args[--n] = regs->args[0] & mask;
70 while (n-- > 0) 68 while (n-- > 0)
71 if (i + n > 0) 69 if (i + n > 0)
72 args[n] = regs->gprs[2 + i + n] & mask; 70 args[n] = regs->gprs[2 + i + n] & mask;
@@ -80,8 +78,6 @@ static inline void syscall_set_arguments(struct task_struct *task,
80 const unsigned long *args) 78 const unsigned long *args)
81{ 79{
82 BUG_ON(i + n > 6); 80 BUG_ON(i + n > 6);
83 if (i + n == 6)
84 regs->args[0] = args[--n];
85 while (n-- > 0) 81 while (n-- > 0)
86 if (i + n > 0) 82 if (i + n > 0)
87 regs->gprs[2 + i + n] = args[n]; 83 regs->gprs[2 + i + n] = args[n];
diff --git a/arch/s390/include/asm/sysinfo.h b/arch/s390/include/asm/sysinfo.h
index 22bdb2a0ee5f..79d3d6e2e9c5 100644
--- a/arch/s390/include/asm/sysinfo.h
+++ b/arch/s390/include/asm/sysinfo.h
@@ -14,8 +14,13 @@
14#ifndef __ASM_S390_SYSINFO_H 14#ifndef __ASM_S390_SYSINFO_H
15#define __ASM_S390_SYSINFO_H 15#define __ASM_S390_SYSINFO_H
16 16
17#include <asm/bitsperlong.h>
18
17struct sysinfo_1_1_1 { 19struct sysinfo_1_1_1 {
18 char reserved_0[32]; 20 unsigned short :16;
21 unsigned char ccr;
22 unsigned char cai;
23 char reserved_0[28];
19 char manufacturer[16]; 24 char manufacturer[16];
20 char type[4]; 25 char type[4];
21 char reserved_1[12]; 26 char reserved_1[12];
@@ -104,6 +109,39 @@ struct sysinfo_3_2_2 {
104 char reserved_544[3552]; 109 char reserved_544[3552];
105}; 110};
106 111
112#define TOPOLOGY_CPU_BITS 64
113#define TOPOLOGY_NR_MAG 6
114
115struct topology_cpu {
116 unsigned char reserved0[4];
117 unsigned char :6;
118 unsigned char pp:2;
119 unsigned char reserved1;
120 unsigned short origin;
121 unsigned long mask[TOPOLOGY_CPU_BITS / BITS_PER_LONG];
122};
123
124struct topology_container {
125 unsigned char reserved[7];
126 unsigned char id;
127};
128
129union topology_entry {
130 unsigned char nl;
131 struct topology_cpu cpu;
132 struct topology_container container;
133};
134
135struct sysinfo_15_1_x {
136 unsigned char reserved0[2];
137 unsigned short length;
138 unsigned char mag[TOPOLOGY_NR_MAG];
139 unsigned char reserved1;
140 unsigned char mnest;
141 unsigned char reserved2[4];
142 union topology_entry tle[0];
143};
144
107static inline int stsi(void *sysinfo, int fc, int sel1, int sel2) 145static inline int stsi(void *sysinfo, int fc, int sel1, int sel2)
108{ 146{
109 register int r0 asm("0") = (fc << 28) | sel1; 147 register int r0 asm("0") = (fc << 28) | sel1;
diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
index 1f2ebc4afd82..3ad16dbf622e 100644
--- a/arch/s390/include/asm/system.h
+++ b/arch/s390/include/asm/system.h
@@ -85,14 +85,16 @@ static inline void restore_access_regs(unsigned int *acrs)
85 asm volatile("lam 0,15,%0" : : "Q" (*acrs)); 85 asm volatile("lam 0,15,%0" : : "Q" (*acrs));
86} 86}
87 87
88#define switch_to(prev,next,last) do { \ 88#define switch_to(prev,next,last) do { \
89 if (prev == next) \ 89 if (prev->mm) { \
90 break; \ 90 save_fp_regs(&prev->thread.fp_regs); \
91 save_fp_regs(&prev->thread.fp_regs); \ 91 save_access_regs(&prev->thread.acrs[0]); \
92 restore_fp_regs(&next->thread.fp_regs); \ 92 } \
93 save_access_regs(&prev->thread.acrs[0]); \ 93 if (next->mm) { \
94 restore_access_regs(&next->thread.acrs[0]); \ 94 restore_fp_regs(&next->thread.fp_regs); \
95 prev = __switch_to(prev,next); \ 95 restore_access_regs(&next->thread.acrs[0]); \
96 } \
97 prev = __switch_to(prev,next); \
96} while (0) 98} while (0)
97 99
98extern void account_vtime(struct task_struct *, struct task_struct *); 100extern void account_vtime(struct task_struct *, struct task_struct *);
@@ -418,30 +420,21 @@ extern void smp_ctl_clear_bit(int cr, int bit);
418 420
419#endif /* CONFIG_SMP */ 421#endif /* CONFIG_SMP */
420 422
421static inline unsigned int stfl(void) 423#define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */
422{
423 asm volatile(
424 " .insn s,0xb2b10000,0(0)\n" /* stfl */
425 "0:\n"
426 EX_TABLE(0b,0b));
427 return S390_lowcore.stfl_fac_list;
428}
429 424
430static inline int __stfle(unsigned long long *list, int doublewords) 425/*
426 * The test_facility function uses the bit odering where the MSB is bit 0.
427 * That makes it easier to query facility bits with the bit number as
428 * documented in the Principles of Operation.
429 */
430static inline int test_facility(unsigned long nr)
431{ 431{
432 typedef struct { unsigned long long _[doublewords]; } addrtype; 432 unsigned char *ptr;
433 register unsigned long __nr asm("0") = doublewords - 1;
434
435 asm volatile(".insn s,0xb2b00000,%0" /* stfle */
436 : "=m" (*(addrtype *) list), "+d" (__nr) : : "cc");
437 return __nr + 1;
438}
439 433
440static inline int stfle(unsigned long long *list, int doublewords) 434 if (nr >= MAX_FACILITY_BIT)
441{ 435 return 0;
442 if (!(stfl() & (1UL << 24))) 436 ptr = (unsigned char *) &S390_lowcore.stfle_fac_list + (nr >> 3);
443 return -EOPNOTSUPP; 437 return (*ptr & (0x80 >> (nr & 7))) != 0;
444 return __stfle(list, doublewords);
445} 438}
446 439
447static inline unsigned short stap(void) 440static inline unsigned short stap(void)
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index fd1c00d08bf5..f1f644f2240a 100644
--- a/arch/s390/include/asm/tlb.h
+++ b/arch/s390/include/asm/tlb.h
@@ -64,10 +64,9 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb,
64 if (!tlb->fullmm && (tlb->nr_ptes > 0 || tlb->nr_pxds < TLB_NR_PTRS)) 64 if (!tlb->fullmm && (tlb->nr_ptes > 0 || tlb->nr_pxds < TLB_NR_PTRS))
65 __tlb_flush_mm(tlb->mm); 65 __tlb_flush_mm(tlb->mm);
66 while (tlb->nr_ptes > 0) 66 while (tlb->nr_ptes > 0)
67 pte_free(tlb->mm, tlb->array[--tlb->nr_ptes]); 67 page_table_free_rcu(tlb->mm, tlb->array[--tlb->nr_ptes]);
68 while (tlb->nr_pxds < TLB_NR_PTRS) 68 while (tlb->nr_pxds < TLB_NR_PTRS)
69 /* pgd_free frees the pointer as region or segment table */ 69 crst_table_free_rcu(tlb->mm, tlb->array[tlb->nr_pxds++]);
70 pgd_free(tlb->mm, tlb->array[tlb->nr_pxds++]);
71} 70}
72 71
73static inline void tlb_finish_mmu(struct mmu_gather *tlb, 72static inline void tlb_finish_mmu(struct mmu_gather *tlb,
@@ -75,6 +74,8 @@ static inline void tlb_finish_mmu(struct mmu_gather *tlb,
75{ 74{
76 tlb_flush_mmu(tlb, start, end); 75 tlb_flush_mmu(tlb, start, end);
77 76
77 rcu_table_freelist_finish();
78
78 /* keep the page table cache within bounds */ 79 /* keep the page table cache within bounds */
79 check_pgt_cache(); 80 check_pgt_cache();
80 81
@@ -103,7 +104,7 @@ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
103 if (tlb->nr_ptes >= tlb->nr_pxds) 104 if (tlb->nr_ptes >= tlb->nr_pxds)
104 tlb_flush_mmu(tlb, 0, 0); 105 tlb_flush_mmu(tlb, 0, 0);
105 } else 106 } else
106 pte_free(tlb->mm, pte); 107 page_table_free(tlb->mm, (unsigned long *) pte);
107} 108}
108 109
109/* 110/*
@@ -124,7 +125,7 @@ static inline void pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
124 if (tlb->nr_ptes >= tlb->nr_pxds) 125 if (tlb->nr_ptes >= tlb->nr_pxds)
125 tlb_flush_mmu(tlb, 0, 0); 126 tlb_flush_mmu(tlb, 0, 0);
126 } else 127 } else
127 pmd_free(tlb->mm, pmd); 128 crst_table_free(tlb->mm, (unsigned long *) pmd);
128#endif 129#endif
129} 130}
130 131
@@ -146,7 +147,7 @@ static inline void pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
146 if (tlb->nr_ptes >= tlb->nr_pxds) 147 if (tlb->nr_ptes >= tlb->nr_pxds)
147 tlb_flush_mmu(tlb, 0, 0); 148 tlb_flush_mmu(tlb, 0, 0);
148 } else 149 } else
149 pud_free(tlb->mm, pud); 150 crst_table_free(tlb->mm, (unsigned long *) pud);
150#endif 151#endif
151} 152}
152 153
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index 051107a2c5e2..c5338834ddbd 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -2,6 +2,7 @@
2#define _ASM_S390_TOPOLOGY_H 2#define _ASM_S390_TOPOLOGY_H
3 3
4#include <linux/cpumask.h> 4#include <linux/cpumask.h>
5#include <asm/sysinfo.h>
5 6
6extern unsigned char cpu_core_id[NR_CPUS]; 7extern unsigned char cpu_core_id[NR_CPUS];
7extern cpumask_t cpu_core_map[NR_CPUS]; 8extern cpumask_t cpu_core_map[NR_CPUS];
@@ -32,6 +33,7 @@ static inline const struct cpumask *cpu_book_mask(unsigned int cpu)
32 33
33int topology_set_cpu_management(int fc); 34int topology_set_cpu_management(int fc);
34void topology_schedule_update(void); 35void topology_schedule_update(void);
36void store_topology(struct sysinfo_15_1_x *info);
35 37
36#define POLARIZATION_UNKNWN (-1) 38#define POLARIZATION_UNKNWN (-1)
37#define POLARIZATION_HRZ (0) 39#define POLARIZATION_HRZ (0)
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index 5232278d79ad..33982e7ce04d 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -66,9 +66,9 @@ int main(void)
66 DEFINE(__VDSO_ECTG_BASE, offsetof(struct vdso_per_cpu_data, ectg_timer_base)); 66 DEFINE(__VDSO_ECTG_BASE, offsetof(struct vdso_per_cpu_data, ectg_timer_base));
67 DEFINE(__VDSO_ECTG_USER, offsetof(struct vdso_per_cpu_data, ectg_user_time)); 67 DEFINE(__VDSO_ECTG_USER, offsetof(struct vdso_per_cpu_data, ectg_user_time));
68 /* constants used by the vdso */ 68 /* constants used by the vdso */
69 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); 69 DEFINE(__CLOCK_REALTIME, CLOCK_REALTIME);
70 DEFINE(CLOCK_MONOTONIC, CLOCK_MONOTONIC); 70 DEFINE(__CLOCK_MONOTONIC, CLOCK_MONOTONIC);
71 DEFINE(CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC); 71 DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
72 BLANK(); 72 BLANK();
73 /* constants for SIGP */ 73 /* constants for SIGP */
74 DEFINE(__SIGP_STOP, sigp_stop); 74 DEFINE(__SIGP_STOP, sigp_stop);
@@ -84,6 +84,7 @@ int main(void)
84 DEFINE(__LC_SVC_INT_CODE, offsetof(struct _lowcore, svc_code)); 84 DEFINE(__LC_SVC_INT_CODE, offsetof(struct _lowcore, svc_code));
85 DEFINE(__LC_PGM_ILC, offsetof(struct _lowcore, pgm_ilc)); 85 DEFINE(__LC_PGM_ILC, offsetof(struct _lowcore, pgm_ilc));
86 DEFINE(__LC_PGM_INT_CODE, offsetof(struct _lowcore, pgm_code)); 86 DEFINE(__LC_PGM_INT_CODE, offsetof(struct _lowcore, pgm_code));
87 DEFINE(__LC_TRANS_EXC_CODE, offsetof(struct _lowcore, trans_exc_code));
87 DEFINE(__LC_PER_ATMID, offsetof(struct _lowcore, per_perc_atmid)); 88 DEFINE(__LC_PER_ATMID, offsetof(struct _lowcore, per_perc_atmid));
88 DEFINE(__LC_PER_ADDRESS, offsetof(struct _lowcore, per_address)); 89 DEFINE(__LC_PER_ADDRESS, offsetof(struct _lowcore, per_address));
89 DEFINE(__LC_PER_ACCESS_ID, offsetof(struct _lowcore, per_access_id)); 90 DEFINE(__LC_PER_ACCESS_ID, offsetof(struct _lowcore, per_access_id));
@@ -142,10 +143,8 @@ int main(void)
142 DEFINE(__LC_GPREGS_SAVE_AREA, offsetof(struct _lowcore, gpregs_save_area)); 143 DEFINE(__LC_GPREGS_SAVE_AREA, offsetof(struct _lowcore, gpregs_save_area));
143 DEFINE(__LC_CREGS_SAVE_AREA, offsetof(struct _lowcore, cregs_save_area)); 144 DEFINE(__LC_CREGS_SAVE_AREA, offsetof(struct _lowcore, cregs_save_area));
144#ifdef CONFIG_32BIT 145#ifdef CONFIG_32BIT
145 DEFINE(__LC_PFAULT_INTPARM, offsetof(struct _lowcore, ext_params));
146 DEFINE(SAVE_AREA_BASE, offsetof(struct _lowcore, extended_save_area_addr)); 146 DEFINE(SAVE_AREA_BASE, offsetof(struct _lowcore, extended_save_area_addr));
147#else /* CONFIG_32BIT */ 147#else /* CONFIG_32BIT */
148 DEFINE(__LC_PFAULT_INTPARM, offsetof(struct _lowcore, ext_params2));
149 DEFINE(__LC_EXT_PARAMS2, offsetof(struct _lowcore, ext_params2)); 148 DEFINE(__LC_EXT_PARAMS2, offsetof(struct _lowcore, ext_params2));
150 DEFINE(SAVE_AREA_BASE, offsetof(struct _lowcore, floating_pt_save_area)); 149 DEFINE(SAVE_AREA_BASE, offsetof(struct _lowcore, floating_pt_save_area));
151 DEFINE(__LC_PASTE, offsetof(struct _lowcore, paste)); 150 DEFINE(__LC_PASTE, offsetof(struct _lowcore, paste));
diff --git a/arch/s390/kernel/compat_ptrace.h b/arch/s390/kernel/compat_ptrace.h
index 123dd660d7fb..3141025724f4 100644
--- a/arch/s390/kernel/compat_ptrace.h
+++ b/arch/s390/kernel/compat_ptrace.h
@@ -51,8 +51,7 @@ struct user_regs_struct32
51 * watchpoints. This is the way intel does it. 51 * watchpoints. This is the way intel does it.
52 */ 52 */
53 per_struct32 per_info; 53 per_struct32 per_info;
54 u32 ieee_instruction_pointer; 54 u32 ieee_instruction_pointer; /* obsolete, always 0 */
55 /* Used to give failing instruction back to user for ieee exceptions */
56}; 55};
57 56
58struct user32 { 57struct user32 {
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/dis.c b/arch/s390/kernel/dis.c
index b39b27d68b45..c83726c9fe03 100644
--- a/arch/s390/kernel/dis.c
+++ b/arch/s390/kernel/dis.c
@@ -113,7 +113,7 @@ enum {
113 INSTR_INVALID, 113 INSTR_INVALID,
114 INSTR_E, 114 INSTR_E,
115 INSTR_RIE_R0IU, INSTR_RIE_R0UU, INSTR_RIE_RRP, INSTR_RIE_RRPU, 115 INSTR_RIE_R0IU, INSTR_RIE_R0UU, INSTR_RIE_RRP, INSTR_RIE_RRPU,
116 INSTR_RIE_RRUUU, INSTR_RIE_RUPI, INSTR_RIE_RUPU, 116 INSTR_RIE_RRUUU, INSTR_RIE_RUPI, INSTR_RIE_RUPU, INSTR_RIE_RRI0,
117 INSTR_RIL_RI, INSTR_RIL_RP, INSTR_RIL_RU, INSTR_RIL_UP, 117 INSTR_RIL_RI, INSTR_RIL_RP, INSTR_RIL_RU, INSTR_RIL_UP,
118 INSTR_RIS_R0RDU, INSTR_RIS_R0UU, INSTR_RIS_RURDI, INSTR_RIS_RURDU, 118 INSTR_RIS_R0RDU, INSTR_RIS_R0UU, INSTR_RIS_RURDI, INSTR_RIS_RURDU,
119 INSTR_RI_RI, INSTR_RI_RP, INSTR_RI_RU, INSTR_RI_UP, 119 INSTR_RI_RI, INSTR_RI_RP, INSTR_RI_RU, INSTR_RI_UP,
@@ -122,13 +122,14 @@ enum {
122 INSTR_RRE_RR, INSTR_RRE_RR_OPT, 122 INSTR_RRE_RR, INSTR_RRE_RR_OPT,
123 INSTR_RRF_0UFF, INSTR_RRF_F0FF, INSTR_RRF_F0FF2, INSTR_RRF_F0FR, 123 INSTR_RRF_0UFF, INSTR_RRF_F0FF, INSTR_RRF_F0FF2, INSTR_RRF_F0FR,
124 INSTR_RRF_FFRU, INSTR_RRF_FUFF, INSTR_RRF_M0RR, INSTR_RRF_R0RR, 124 INSTR_RRF_FFRU, INSTR_RRF_FUFF, INSTR_RRF_M0RR, INSTR_RRF_R0RR,
125 INSTR_RRF_RURR, INSTR_RRF_U0FF, INSTR_RRF_U0RF, INSTR_RRF_U0RR, 125 INSTR_RRF_R0RR2, INSTR_RRF_RURR, INSTR_RRF_U0FF, INSTR_RRF_U0RF,
126 INSTR_RRF_UUFF, INSTR_RRR_F0FF, INSTR_RRS_RRRDU, 126 INSTR_RRF_U0RR, INSTR_RRF_UUFF, INSTR_RRR_F0FF, INSTR_RRS_RRRDU,
127 INSTR_RR_FF, INSTR_RR_R0, INSTR_RR_RR, INSTR_RR_U0, INSTR_RR_UR, 127 INSTR_RR_FF, INSTR_RR_R0, INSTR_RR_RR, INSTR_RR_U0, INSTR_RR_UR,
128 INSTR_RSE_CCRD, INSTR_RSE_RRRD, INSTR_RSE_RURD, 128 INSTR_RSE_CCRD, INSTR_RSE_RRRD, INSTR_RSE_RURD,
129 INSTR_RSI_RRP, 129 INSTR_RSI_RRP,
130 INSTR_RSL_R0RD, 130 INSTR_RSL_R0RD,
131 INSTR_RSY_AARD, INSTR_RSY_CCRD, INSTR_RSY_RRRD, INSTR_RSY_RURD, 131 INSTR_RSY_AARD, INSTR_RSY_CCRD, INSTR_RSY_RRRD, INSTR_RSY_RURD,
132 INSTR_RSY_RDRM,
132 INSTR_RS_AARD, INSTR_RS_CCRD, INSTR_RS_R0RD, INSTR_RS_RRRD, 133 INSTR_RS_AARD, INSTR_RS_CCRD, INSTR_RS_R0RD, INSTR_RS_RRRD,
133 INSTR_RS_RURD, 134 INSTR_RS_RURD,
134 INSTR_RXE_FRRD, INSTR_RXE_RRRD, 135 INSTR_RXE_FRRD, INSTR_RXE_RRRD,
@@ -139,7 +140,7 @@ enum {
139 INSTR_SIY_IRD, INSTR_SIY_URD, 140 INSTR_SIY_IRD, INSTR_SIY_URD,
140 INSTR_SI_URD, 141 INSTR_SI_URD,
141 INSTR_SSE_RDRD, 142 INSTR_SSE_RDRD,
142 INSTR_SSF_RRDRD, 143 INSTR_SSF_RRDRD, INSTR_SSF_RRDRD2,
143 INSTR_SS_L0RDRD, INSTR_SS_LIRDRD, INSTR_SS_LLRDRD, INSTR_SS_RRRDRD, 144 INSTR_SS_L0RDRD, INSTR_SS_LIRDRD, INSTR_SS_LLRDRD, INSTR_SS_RRRDRD,
144 INSTR_SS_RRRDRD2, INSTR_SS_RRRDRD3, 145 INSTR_SS_RRRDRD2, INSTR_SS_RRRDRD3,
145 INSTR_S_00, INSTR_S_RD, 146 INSTR_S_00, INSTR_S_RD,
@@ -152,7 +153,7 @@ struct operand {
152}; 153};
153 154
154struct insn { 155struct insn {
155 const char name[6]; 156 const char name[5];
156 unsigned char opfrag; 157 unsigned char opfrag;
157 unsigned char format; 158 unsigned char format;
158}; 159};
@@ -217,6 +218,7 @@ static const unsigned char formats[][7] = {
217 [INSTR_RIE_RRP] = { 0xff, R_8,R_12,J16_16,0,0,0 }, 218 [INSTR_RIE_RRP] = { 0xff, R_8,R_12,J16_16,0,0,0 },
218 [INSTR_RIE_RRUUU] = { 0xff, R_8,R_12,U8_16,U8_24,U8_32,0 }, 219 [INSTR_RIE_RRUUU] = { 0xff, R_8,R_12,U8_16,U8_24,U8_32,0 },
219 [INSTR_RIE_RUPI] = { 0xff, R_8,I8_32,U4_12,J16_16,0,0 }, 220 [INSTR_RIE_RUPI] = { 0xff, R_8,I8_32,U4_12,J16_16,0,0 },
221 [INSTR_RIE_RRI0] = { 0xff, R_8,R_12,I16_16,0,0,0 },
220 [INSTR_RIL_RI] = { 0x0f, R_8,I32_16,0,0,0,0 }, 222 [INSTR_RIL_RI] = { 0x0f, R_8,I32_16,0,0,0,0 },
221 [INSTR_RIL_RP] = { 0x0f, R_8,J32_16,0,0,0,0 }, 223 [INSTR_RIL_RP] = { 0x0f, R_8,J32_16,0,0,0,0 },
222 [INSTR_RIL_RU] = { 0x0f, R_8,U32_16,0,0,0,0 }, 224 [INSTR_RIL_RU] = { 0x0f, R_8,U32_16,0,0,0,0 },
@@ -248,6 +250,7 @@ static const unsigned char formats[][7] = {
248 [INSTR_RRF_FUFF] = { 0xff, F_24,F_16,F_28,U4_20,0,0 }, 250 [INSTR_RRF_FUFF] = { 0xff, F_24,F_16,F_28,U4_20,0,0 },
249 [INSTR_RRF_M0RR] = { 0xff, R_24,R_28,M_16,0,0,0 }, 251 [INSTR_RRF_M0RR] = { 0xff, R_24,R_28,M_16,0,0,0 },
250 [INSTR_RRF_R0RR] = { 0xff, R_24,R_16,R_28,0,0,0 }, 252 [INSTR_RRF_R0RR] = { 0xff, R_24,R_16,R_28,0,0,0 },
253 [INSTR_RRF_R0RR2] = { 0xff, R_24,R_28,R_16,0,0,0 },
251 [INSTR_RRF_RURR] = { 0xff, R_24,R_28,R_16,U4_20,0,0 }, 254 [INSTR_RRF_RURR] = { 0xff, R_24,R_28,R_16,U4_20,0,0 },
252 [INSTR_RRF_U0FF] = { 0xff, F_24,U4_16,F_28,0,0,0 }, 255 [INSTR_RRF_U0FF] = { 0xff, F_24,U4_16,F_28,0,0,0 },
253 [INSTR_RRF_U0RF] = { 0xff, R_24,U4_16,F_28,0,0,0 }, 256 [INSTR_RRF_U0RF] = { 0xff, R_24,U4_16,F_28,0,0,0 },
@@ -269,6 +272,7 @@ static const unsigned char formats[][7] = {
269 [INSTR_RSY_CCRD] = { 0xff, C_8,C_12,D20_20,B_16,0,0 }, 272 [INSTR_RSY_CCRD] = { 0xff, C_8,C_12,D20_20,B_16,0,0 },
270 [INSTR_RSY_RRRD] = { 0xff, R_8,R_12,D20_20,B_16,0,0 }, 273 [INSTR_RSY_RRRD] = { 0xff, R_8,R_12,D20_20,B_16,0,0 },
271 [INSTR_RSY_RURD] = { 0xff, R_8,U4_12,D20_20,B_16,0,0 }, 274 [INSTR_RSY_RURD] = { 0xff, R_8,U4_12,D20_20,B_16,0,0 },
275 [INSTR_RSY_RDRM] = { 0xff, R_8,D20_20,B_16,U4_12,0,0 },
272 [INSTR_RS_AARD] = { 0xff, A_8,A_12,D_20,B_16,0,0 }, 276 [INSTR_RS_AARD] = { 0xff, A_8,A_12,D_20,B_16,0,0 },
273 [INSTR_RS_CCRD] = { 0xff, C_8,C_12,D_20,B_16,0,0 }, 277 [INSTR_RS_CCRD] = { 0xff, C_8,C_12,D_20,B_16,0,0 },
274 [INSTR_RS_R0RD] = { 0xff, R_8,D_20,B_16,0,0,0 }, 278 [INSTR_RS_R0RD] = { 0xff, R_8,D_20,B_16,0,0,0 },
@@ -290,6 +294,7 @@ static const unsigned char formats[][7] = {
290 [INSTR_SI_URD] = { 0xff, D_20,B_16,U8_8,0,0,0 }, 294 [INSTR_SI_URD] = { 0xff, D_20,B_16,U8_8,0,0,0 },
291 [INSTR_SSE_RDRD] = { 0xff, D_20,B_16,D_36,B_32,0,0 }, 295 [INSTR_SSE_RDRD] = { 0xff, D_20,B_16,D_36,B_32,0,0 },
292 [INSTR_SSF_RRDRD] = { 0x00, D_20,B_16,D_36,B_32,R_8,0 }, 296 [INSTR_SSF_RRDRD] = { 0x00, D_20,B_16,D_36,B_32,R_8,0 },
297 [INSTR_SSF_RRDRD2]= { 0x00, R_8,D_20,B_16,D_36,B_32,0 },
293 [INSTR_SS_L0RDRD] = { 0xff, D_20,L8_8,B_16,D_36,B_32,0 }, 298 [INSTR_SS_L0RDRD] = { 0xff, D_20,L8_8,B_16,D_36,B_32,0 },
294 [INSTR_SS_LIRDRD] = { 0xff, D_20,L4_8,B_16,D_36,B_32,U4_12 }, 299 [INSTR_SS_LIRDRD] = { 0xff, D_20,L4_8,B_16,D_36,B_32,U4_12 },
295 [INSTR_SS_LLRDRD] = { 0xff, D_20,L4_8,B_16,D_36,L4_12,B_32 }, 300 [INSTR_SS_LLRDRD] = { 0xff, D_20,L4_8,B_16,D_36,L4_12,B_32 },
@@ -300,6 +305,36 @@ static const unsigned char formats[][7] = {
300 [INSTR_S_RD] = { 0xff, D_20,B_16,0,0,0,0 }, 305 [INSTR_S_RD] = { 0xff, D_20,B_16,0,0,0,0 },
301}; 306};
302 307
308enum {
309 LONG_INSN_ALGHSIK,
310 LONG_INSN_ALHSIK,
311 LONG_INSN_CLFHSI,
312 LONG_INSN_CLGFRL,
313 LONG_INSN_CLGHRL,
314 LONG_INSN_CLGHSI,
315 LONG_INSN_CLHHSI,
316 LONG_INSN_LLGFRL,
317 LONG_INSN_LLGHRL,
318 LONG_INSN_POPCNT,
319 LONG_INSN_RISBHG,
320 LONG_INSN_RISBLG,
321};
322
323static char *long_insn_name[] = {
324 [LONG_INSN_ALGHSIK] = "alghsik",
325 [LONG_INSN_ALHSIK] = "alhsik",
326 [LONG_INSN_CLFHSI] = "clfhsi",
327 [LONG_INSN_CLGFRL] = "clgfrl",
328 [LONG_INSN_CLGHRL] = "clghrl",
329 [LONG_INSN_CLGHSI] = "clghsi",
330 [LONG_INSN_CLHHSI] = "clhhsi",
331 [LONG_INSN_LLGFRL] = "llgfrl",
332 [LONG_INSN_LLGHRL] = "llghrl",
333 [LONG_INSN_POPCNT] = "popcnt",
334 [LONG_INSN_RISBHG] = "risbhg",
335 [LONG_INSN_RISBLG] = "risblk",
336};
337
303static struct insn opcode[] = { 338static struct insn opcode[] = {
304#ifdef CONFIG_64BIT 339#ifdef CONFIG_64BIT
305 { "lmd", 0xef, INSTR_SS_RRRDRD3 }, 340 { "lmd", 0xef, INSTR_SS_RRRDRD3 },
@@ -881,6 +916,35 @@ static struct insn opcode_b9[] = {
881 { "pfmf", 0xaf, INSTR_RRE_RR }, 916 { "pfmf", 0xaf, INSTR_RRE_RR },
882 { "trte", 0xbf, INSTR_RRF_M0RR }, 917 { "trte", 0xbf, INSTR_RRF_M0RR },
883 { "trtre", 0xbd, INSTR_RRF_M0RR }, 918 { "trtre", 0xbd, INSTR_RRF_M0RR },
919 { "ahhhr", 0xc8, INSTR_RRF_R0RR2 },
920 { "shhhr", 0xc9, INSTR_RRF_R0RR2 },
921 { "alhhh", 0xca, INSTR_RRF_R0RR2 },
922 { "alhhl", 0xca, INSTR_RRF_R0RR2 },
923 { "slhhh", 0xcb, INSTR_RRF_R0RR2 },
924 { "chhr ", 0xcd, INSTR_RRE_RR },
925 { "clhhr", 0xcf, INSTR_RRE_RR },
926 { "ahhlr", 0xd8, INSTR_RRF_R0RR2 },
927 { "shhlr", 0xd9, INSTR_RRF_R0RR2 },
928 { "slhhl", 0xdb, INSTR_RRF_R0RR2 },
929 { "chlr", 0xdd, INSTR_RRE_RR },
930 { "clhlr", 0xdf, INSTR_RRE_RR },
931 { { 0, LONG_INSN_POPCNT }, 0xe1, INSTR_RRE_RR },
932 { "locgr", 0xe2, INSTR_RRF_M0RR },
933 { "ngrk", 0xe4, INSTR_RRF_R0RR2 },
934 { "ogrk", 0xe6, INSTR_RRF_R0RR2 },
935 { "xgrk", 0xe7, INSTR_RRF_R0RR2 },
936 { "agrk", 0xe8, INSTR_RRF_R0RR2 },
937 { "sgrk", 0xe9, INSTR_RRF_R0RR2 },
938 { "algrk", 0xea, INSTR_RRF_R0RR2 },
939 { "slgrk", 0xeb, INSTR_RRF_R0RR2 },
940 { "locr", 0xf2, INSTR_RRF_M0RR },
941 { "nrk", 0xf4, INSTR_RRF_R0RR2 },
942 { "ork", 0xf6, INSTR_RRF_R0RR2 },
943 { "xrk", 0xf7, INSTR_RRF_R0RR2 },
944 { "ark", 0xf8, INSTR_RRF_R0RR2 },
945 { "srk", 0xf9, INSTR_RRF_R0RR2 },
946 { "alrk", 0xfa, INSTR_RRF_R0RR2 },
947 { "slrk", 0xfb, INSTR_RRF_R0RR2 },
884#endif 948#endif
885 { "kmac", 0x1e, INSTR_RRE_RR }, 949 { "kmac", 0x1e, INSTR_RRE_RR },
886 { "lrvr", 0x1f, INSTR_RRE_RR }, 950 { "lrvr", 0x1f, INSTR_RRE_RR },
@@ -949,9 +1013,9 @@ static struct insn opcode_c4[] = {
949 { "lgfrl", 0x0c, INSTR_RIL_RP }, 1013 { "lgfrl", 0x0c, INSTR_RIL_RP },
950 { "lhrl", 0x05, INSTR_RIL_RP }, 1014 { "lhrl", 0x05, INSTR_RIL_RP },
951 { "lghrl", 0x04, INSTR_RIL_RP }, 1015 { "lghrl", 0x04, INSTR_RIL_RP },
952 { "llgfrl", 0x0e, INSTR_RIL_RP }, 1016 { { 0, LONG_INSN_LLGFRL }, 0x0e, INSTR_RIL_RP },
953 { "llhrl", 0x02, INSTR_RIL_RP }, 1017 { "llhrl", 0x02, INSTR_RIL_RP },
954 { "llghrl", 0x06, INSTR_RIL_RP }, 1018 { { 0, LONG_INSN_LLGHRL }, 0x06, INSTR_RIL_RP },
955 { "strl", 0x0f, INSTR_RIL_RP }, 1019 { "strl", 0x0f, INSTR_RIL_RP },
956 { "stgrl", 0x0b, INSTR_RIL_RP }, 1020 { "stgrl", 0x0b, INSTR_RIL_RP },
957 { "sthrl", 0x07, INSTR_RIL_RP }, 1021 { "sthrl", 0x07, INSTR_RIL_RP },
@@ -968,9 +1032,9 @@ static struct insn opcode_c6[] = {
968 { "cghrl", 0x04, INSTR_RIL_RP }, 1032 { "cghrl", 0x04, INSTR_RIL_RP },
969 { "clrl", 0x0f, INSTR_RIL_RP }, 1033 { "clrl", 0x0f, INSTR_RIL_RP },
970 { "clgrl", 0x0a, INSTR_RIL_RP }, 1034 { "clgrl", 0x0a, INSTR_RIL_RP },
971 { "clgfrl", 0x0e, INSTR_RIL_RP }, 1035 { { 0, LONG_INSN_CLGFRL }, 0x0e, INSTR_RIL_RP },
972 { "clhrl", 0x07, INSTR_RIL_RP }, 1036 { "clhrl", 0x07, INSTR_RIL_RP },
973 { "clghrl", 0x06, INSTR_RIL_RP }, 1037 { { 0, LONG_INSN_CLGHRL }, 0x06, INSTR_RIL_RP },
974 { "pfdrl", 0x02, INSTR_RIL_UP }, 1038 { "pfdrl", 0x02, INSTR_RIL_UP },
975 { "exrl", 0x00, INSTR_RIL_RP }, 1039 { "exrl", 0x00, INSTR_RIL_RP },
976#endif 1040#endif
@@ -982,6 +1046,20 @@ static struct insn opcode_c8[] = {
982 { "mvcos", 0x00, INSTR_SSF_RRDRD }, 1046 { "mvcos", 0x00, INSTR_SSF_RRDRD },
983 { "ectg", 0x01, INSTR_SSF_RRDRD }, 1047 { "ectg", 0x01, INSTR_SSF_RRDRD },
984 { "csst", 0x02, INSTR_SSF_RRDRD }, 1048 { "csst", 0x02, INSTR_SSF_RRDRD },
1049 { "lpd", 0x04, INSTR_SSF_RRDRD2 },
1050 { "lpdg ", 0x05, INSTR_SSF_RRDRD2 },
1051#endif
1052 { "", 0, INSTR_INVALID }
1053};
1054
1055static struct insn opcode_cc[] = {
1056#ifdef CONFIG_64BIT
1057 { "brcth", 0x06, INSTR_RIL_RP },
1058 { "aih", 0x08, INSTR_RIL_RI },
1059 { "alsih", 0x0a, INSTR_RIL_RI },
1060 { "alsih", 0x0b, INSTR_RIL_RI },
1061 { "cih", 0x0d, INSTR_RIL_RI },
1062 { "clih ", 0x0f, INSTR_RIL_RI },
985#endif 1063#endif
986 { "", 0, INSTR_INVALID } 1064 { "", 0, INSTR_INVALID }
987}; 1065};
@@ -1063,6 +1141,16 @@ static struct insn opcode_e3[] = {
1063 { "mfy", 0x5c, INSTR_RXY_RRRD }, 1141 { "mfy", 0x5c, INSTR_RXY_RRRD },
1064 { "mhy", 0x7c, INSTR_RXY_RRRD }, 1142 { "mhy", 0x7c, INSTR_RXY_RRRD },
1065 { "pfd", 0x36, INSTR_RXY_URRD }, 1143 { "pfd", 0x36, INSTR_RXY_URRD },
1144 { "lbh", 0xc0, INSTR_RXY_RRRD },
1145 { "llch", 0xc2, INSTR_RXY_RRRD },
1146 { "stch", 0xc3, INSTR_RXY_RRRD },
1147 { "lhh", 0xc4, INSTR_RXY_RRRD },
1148 { "llhh", 0xc6, INSTR_RXY_RRRD },
1149 { "sthh", 0xc7, INSTR_RXY_RRRD },
1150 { "lfh", 0xca, INSTR_RXY_RRRD },
1151 { "stfh", 0xcb, INSTR_RXY_RRRD },
1152 { "chf", 0xcd, INSTR_RXY_RRRD },
1153 { "clhf", 0xcf, INSTR_RXY_RRRD },
1066#endif 1154#endif
1067 { "lrv", 0x1e, INSTR_RXY_RRRD }, 1155 { "lrv", 0x1e, INSTR_RXY_RRRD },
1068 { "lrvh", 0x1f, INSTR_RXY_RRRD }, 1156 { "lrvh", 0x1f, INSTR_RXY_RRRD },
@@ -1080,9 +1168,9 @@ static struct insn opcode_e5[] = {
1080 { "chhsi", 0x54, INSTR_SIL_RDI }, 1168 { "chhsi", 0x54, INSTR_SIL_RDI },
1081 { "chsi", 0x5c, INSTR_SIL_RDI }, 1169 { "chsi", 0x5c, INSTR_SIL_RDI },
1082 { "cghsi", 0x58, INSTR_SIL_RDI }, 1170 { "cghsi", 0x58, INSTR_SIL_RDI },
1083 { "clhhsi", 0x55, INSTR_SIL_RDU }, 1171 { { 0, LONG_INSN_CLHHSI }, 0x55, INSTR_SIL_RDU },
1084 { "clfhsi", 0x5d, INSTR_SIL_RDU }, 1172 { { 0, LONG_INSN_CLFHSI }, 0x5d, INSTR_SIL_RDU },
1085 { "clghsi", 0x59, INSTR_SIL_RDU }, 1173 { { 0, LONG_INSN_CLGHSI }, 0x59, INSTR_SIL_RDU },
1086 { "mvhhi", 0x44, INSTR_SIL_RDI }, 1174 { "mvhhi", 0x44, INSTR_SIL_RDI },
1087 { "mvhi", 0x4c, INSTR_SIL_RDI }, 1175 { "mvhi", 0x4c, INSTR_SIL_RDI },
1088 { "mvghi", 0x48, INSTR_SIL_RDI }, 1176 { "mvghi", 0x48, INSTR_SIL_RDI },
@@ -1137,6 +1225,24 @@ static struct insn opcode_eb[] = {
1137 { "alsi", 0x6e, INSTR_SIY_IRD }, 1225 { "alsi", 0x6e, INSTR_SIY_IRD },
1138 { "algsi", 0x7e, INSTR_SIY_IRD }, 1226 { "algsi", 0x7e, INSTR_SIY_IRD },
1139 { "ecag", 0x4c, INSTR_RSY_RRRD }, 1227 { "ecag", 0x4c, INSTR_RSY_RRRD },
1228 { "srak", 0xdc, INSTR_RSY_RRRD },
1229 { "slak", 0xdd, INSTR_RSY_RRRD },
1230 { "srlk", 0xde, INSTR_RSY_RRRD },
1231 { "sllk", 0xdf, INSTR_RSY_RRRD },
1232 { "locg", 0xe2, INSTR_RSY_RDRM },
1233 { "stocg", 0xe3, INSTR_RSY_RDRM },
1234 { "lang", 0xe4, INSTR_RSY_RRRD },
1235 { "laog", 0xe6, INSTR_RSY_RRRD },
1236 { "laxg", 0xe7, INSTR_RSY_RRRD },
1237 { "laag", 0xe8, INSTR_RSY_RRRD },
1238 { "laalg", 0xea, INSTR_RSY_RRRD },
1239 { "loc", 0xf2, INSTR_RSY_RDRM },
1240 { "stoc", 0xf3, INSTR_RSY_RDRM },
1241 { "lan", 0xf4, INSTR_RSY_RRRD },
1242 { "lao", 0xf6, INSTR_RSY_RRRD },
1243 { "lax", 0xf7, INSTR_RSY_RRRD },
1244 { "laa", 0xf8, INSTR_RSY_RRRD },
1245 { "laal", 0xfa, INSTR_RSY_RRRD },
1140#endif 1246#endif
1141 { "rll", 0x1d, INSTR_RSY_RRRD }, 1247 { "rll", 0x1d, INSTR_RSY_RRRD },
1142 { "mvclu", 0x8e, INSTR_RSY_RRRD }, 1248 { "mvclu", 0x8e, INSTR_RSY_RRRD },
@@ -1172,6 +1278,12 @@ static struct insn opcode_ec[] = {
1172 { "rxsbg", 0x57, INSTR_RIE_RRUUU }, 1278 { "rxsbg", 0x57, INSTR_RIE_RRUUU },
1173 { "rosbg", 0x56, INSTR_RIE_RRUUU }, 1279 { "rosbg", 0x56, INSTR_RIE_RRUUU },
1174 { "risbg", 0x55, INSTR_RIE_RRUUU }, 1280 { "risbg", 0x55, INSTR_RIE_RRUUU },
1281 { { 0, LONG_INSN_RISBLG }, 0x51, INSTR_RIE_RRUUU },
1282 { { 0, LONG_INSN_RISBHG }, 0x5D, INSTR_RIE_RRUUU },
1283 { "ahik", 0xd8, INSTR_RIE_RRI0 },
1284 { "aghik", 0xd9, INSTR_RIE_RRI0 },
1285 { { 0, LONG_INSN_ALHSIK }, 0xda, INSTR_RIE_RRI0 },
1286 { { 0, LONG_INSN_ALGHSIK }, 0xdb, INSTR_RIE_RRI0 },
1175#endif 1287#endif
1176 { "", 0, INSTR_INVALID } 1288 { "", 0, INSTR_INVALID }
1177}; 1289};
@@ -1321,6 +1433,9 @@ static struct insn *find_insn(unsigned char *code)
1321 case 0xc8: 1433 case 0xc8:
1322 table = opcode_c8; 1434 table = opcode_c8;
1323 break; 1435 break;
1436 case 0xcc:
1437 table = opcode_cc;
1438 break;
1324 case 0xe3: 1439 case 0xe3:
1325 table = opcode_e3; 1440 table = opcode_e3;
1326 opfrag = code[5]; 1441 opfrag = code[5];
@@ -1367,7 +1482,11 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
1367 ptr = buffer; 1482 ptr = buffer;
1368 insn = find_insn(code); 1483 insn = find_insn(code);
1369 if (insn) { 1484 if (insn) {
1370 ptr += sprintf(ptr, "%.5s\t", insn->name); 1485 if (insn->name[0] == '\0')
1486 ptr += sprintf(ptr, "%s\t",
1487 long_insn_name[(int) insn->name[1]]);
1488 else
1489 ptr += sprintf(ptr, "%.5s\t", insn->name);
1371 /* Extract the operands. */ 1490 /* Extract the operands. */
1372 separator = 0; 1491 separator = 0;
1373 for (ops = formats[insn->format] + 1, i = 0; 1492 for (ops = formats[insn->format] + 1, i = 0;
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index c00856ad4e5a..3b7e7dddc324 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -208,7 +208,8 @@ static noinline __init void init_kernel_storage_key(void)
208 end_pfn = PFN_UP(__pa(&_end)); 208 end_pfn = PFN_UP(__pa(&_end));
209 209
210 for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++) 210 for (init_pfn = 0 ; init_pfn < end_pfn; init_pfn++)
211 page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY); 211 page_set_storage_key(init_pfn << PAGE_SHIFT,
212 PAGE_DEFAULT_KEY, 0);
212} 213}
213 214
214static __initdata struct sysinfo_3_2_2 vmms __aligned(PAGE_SIZE); 215static __initdata struct sysinfo_3_2_2 vmms __aligned(PAGE_SIZE);
@@ -255,13 +256,33 @@ static noinline __init void setup_lowcore_early(void)
255 s390_base_pgm_handler_fn = early_pgm_check_handler; 256 s390_base_pgm_handler_fn = early_pgm_check_handler;
256} 257}
257 258
259static noinline __init void setup_facility_list(void)
260{
261 unsigned long nr;
262
263 S390_lowcore.stfl_fac_list = 0;
264 asm volatile(
265 " .insn s,0xb2b10000,0(0)\n" /* stfl */
266 "0:\n"
267 EX_TABLE(0b,0b) : "=m" (S390_lowcore.stfl_fac_list));
268 memcpy(&S390_lowcore.stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
269 nr = 4; /* # bytes stored by stfl */
270 if (test_facility(7)) {
271 /* More facility bits available with stfle */
272 register unsigned long reg0 asm("0") = MAX_FACILITY_BIT/64 - 1;
273 asm volatile(".insn s,0xb2b00000,%0" /* stfle */
274 : "=m" (S390_lowcore.stfle_fac_list), "+d" (reg0)
275 : : "cc");
276 nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
277 }
278 memset((char *) S390_lowcore.stfle_fac_list + nr, 0,
279 MAX_FACILITY_BIT/8 - nr);
280}
281
258static noinline __init void setup_hpage(void) 282static noinline __init void setup_hpage(void)
259{ 283{
260#ifndef CONFIG_DEBUG_PAGEALLOC 284#ifndef CONFIG_DEBUG_PAGEALLOC
261 unsigned int facilities; 285 if (!test_facility(2) || !test_facility(8))
262
263 facilities = stfl();
264 if (!(facilities & (1UL << 23)) || !(facilities & (1UL << 29)))
265 return; 286 return;
266 S390_lowcore.machine_flags |= MACHINE_FLAG_HPAGE; 287 S390_lowcore.machine_flags |= MACHINE_FLAG_HPAGE;
267 __ctl_set_bit(0, 23); 288 __ctl_set_bit(0, 23);
@@ -355,18 +376,15 @@ static __init void detect_diag44(void)
355static __init void detect_machine_facilities(void) 376static __init void detect_machine_facilities(void)
356{ 377{
357#ifdef CONFIG_64BIT 378#ifdef CONFIG_64BIT
358 unsigned int facilities; 379 if (test_facility(3))
359 unsigned long long facility_bits;
360
361 facilities = stfl();
362 if (facilities & (1 << 28))
363 S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE; 380 S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE;
364 if (facilities & (1 << 23)) 381 if (test_facility(8))
365 S390_lowcore.machine_flags |= MACHINE_FLAG_PFMF; 382 S390_lowcore.machine_flags |= MACHINE_FLAG_PFMF;
366 if (facilities & (1 << 4)) 383 if (test_facility(11))
384 S390_lowcore.machine_flags |= MACHINE_FLAG_TOPOLOGY;
385 if (test_facility(27))
367 S390_lowcore.machine_flags |= MACHINE_FLAG_MVCOS; 386 S390_lowcore.machine_flags |= MACHINE_FLAG_MVCOS;
368 if ((stfle(&facility_bits, 1) > 0) && 387 if (test_facility(40))
369 (facility_bits & (1ULL << (63 - 40))))
370 S390_lowcore.machine_flags |= MACHINE_FLAG_SPP; 388 S390_lowcore.machine_flags |= MACHINE_FLAG_SPP;
371#endif 389#endif
372} 390}
@@ -447,6 +465,7 @@ void __init startup_init(void)
447 lockdep_off(); 465 lockdep_off();
448 sort_main_extable(); 466 sort_main_extable();
449 setup_lowcore_early(); 467 setup_lowcore_early();
468 setup_facility_list();
450 detect_machine_type(); 469 detect_machine_type();
451 ipl_update_parameters(); 470 ipl_update_parameters();
452 setup_boot_command_line(); 471 setup_boot_command_line();
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index bea9ee37ac9d..1ecc337fb679 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -72,25 +72,9 @@ STACK_SIZE = 1 << STACK_SHIFT
72 l %r1,BASED(.Ltrace_irq_off_caller) 72 l %r1,BASED(.Ltrace_irq_off_caller)
73 basr %r14,%r1 73 basr %r14,%r1
74 .endm 74 .endm
75
76 .macro TRACE_IRQS_CHECK_ON
77 tm SP_PSW(%r15),0x03 # irqs enabled?
78 bz BASED(0f)
79 TRACE_IRQS_ON
800:
81 .endm
82
83 .macro TRACE_IRQS_CHECK_OFF
84 tm SP_PSW(%r15),0x03 # irqs enabled?
85 bz BASED(0f)
86 TRACE_IRQS_OFF
870:
88 .endm
89#else 75#else
90#define TRACE_IRQS_ON 76#define TRACE_IRQS_ON
91#define TRACE_IRQS_OFF 77#define TRACE_IRQS_OFF
92#define TRACE_IRQS_CHECK_ON
93#define TRACE_IRQS_CHECK_OFF
94#endif 78#endif
95 79
96#ifdef CONFIG_LOCKDEP 80#ifdef CONFIG_LOCKDEP
@@ -198,6 +182,12 @@ STACK_SIZE = 1 << STACK_SHIFT
198 lpsw \psworg # back to caller 182 lpsw \psworg # back to caller
199 .endm 183 .endm
200 184
185 .macro REENABLE_IRQS
186 mvc __SF_EMPTY(1,%r15),SP_PSW(%r15)
187 ni __SF_EMPTY(%r15),0xbf
188 ssm __SF_EMPTY(%r15)
189 .endm
190
201/* 191/*
202 * Scheduler resume function, called by switch_to 192 * Scheduler resume function, called by switch_to
203 * gpr2 = (task_struct *) prev 193 * gpr2 = (task_struct *) prev
@@ -264,12 +254,11 @@ sysc_do_svc:
264 bnl BASED(sysc_nr_ok) 254 bnl BASED(sysc_nr_ok)
265 lr %r7,%r1 # copy svc number to %r7 255 lr %r7,%r1 # copy svc number to %r7
266sysc_nr_ok: 256sysc_nr_ok:
267 mvc SP_ARGS(4,%r15),SP_R7(%r15)
268sysc_do_restart:
269 sth %r7,SP_SVCNR(%r15) 257 sth %r7,SP_SVCNR(%r15)
270 sll %r7,2 # svc number *4 258 sll %r7,2 # svc number *4
271 l %r8,BASED(.Lsysc_table) 259 l %r8,BASED(.Lsysc_table)
272 tm __TI_flags+2(%r9),_TIF_SYSCALL 260 tm __TI_flags+2(%r9),_TIF_SYSCALL
261 mvc SP_ARGS(4,%r15),SP_R7(%r15)
273 l %r8,0(%r7,%r8) # get system call addr. 262 l %r8,0(%r7,%r8) # get system call addr.
274 bnz BASED(sysc_tracesys) 263 bnz BASED(sysc_tracesys)
275 basr %r14,%r8 # call sys_xxxx 264 basr %r14,%r8 # call sys_xxxx
@@ -357,7 +346,7 @@ sysc_restart:
357 l %r7,SP_R2(%r15) # load new svc number 346 l %r7,SP_R2(%r15) # load new svc number
358 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument 347 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
359 lm %r2,%r6,SP_R2(%r15) # load svc arguments 348 lm %r2,%r6,SP_R2(%r15) # load svc arguments
360 b BASED(sysc_do_restart) # restart svc 349 b BASED(sysc_nr_ok) # restart svc
361 350
362# 351#
363# _TIF_SINGLE_STEP is set, call do_single_step 352# _TIF_SINGLE_STEP is set, call do_single_step
@@ -390,6 +379,7 @@ sysc_tracesys:
390 l %r8,0(%r7,%r8) 379 l %r8,0(%r7,%r8)
391sysc_tracego: 380sysc_tracego:
392 lm %r3,%r6,SP_R3(%r15) 381 lm %r3,%r6,SP_R3(%r15)
382 mvc SP_ARGS(4,%r15),SP_R7(%r15)
393 l %r2,SP_ORIG_R2(%r15) 383 l %r2,SP_ORIG_R2(%r15)
394 basr %r14,%r8 # call sys_xxx 384 basr %r14,%r8 # call sys_xxx
395 st %r2,SP_R2(%r15) # store return value 385 st %r2,SP_R2(%r15) # store return value
@@ -440,13 +430,11 @@ kernel_execve:
440 br %r14 430 br %r14
441 # execve succeeded. 431 # execve succeeded.
4420: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts 4320: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
443 TRACE_IRQS_OFF
444 l %r15,__LC_KERNEL_STACK # load ksp 433 l %r15,__LC_KERNEL_STACK # load ksp
445 s %r15,BASED(.Lc_spsize) # make room for registers & psw 434 s %r15,BASED(.Lc_spsize) # make room for registers & psw
446 l %r9,__LC_THREAD_INFO 435 l %r9,__LC_THREAD_INFO
447 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs 436 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
448 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) 437 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
449 TRACE_IRQS_ON
450 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 438 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
451 l %r1,BASED(.Lexecve_tail) 439 l %r1,BASED(.Lexecve_tail)
452 basr %r14,%r1 440 basr %r14,%r1
@@ -483,9 +471,10 @@ pgm_check_handler:
483 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER 471 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
484 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER 472 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
485pgm_no_vtime: 473pgm_no_vtime:
486 TRACE_IRQS_CHECK_OFF
487 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct 474 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
488 l %r3,__LC_PGM_ILC # load program interruption code 475 l %r3,__LC_PGM_ILC # load program interruption code
476 l %r4,__LC_TRANS_EXC_CODE
477 REENABLE_IRQS
489 la %r8,0x7f 478 la %r8,0x7f
490 nr %r8,%r3 479 nr %r8,%r3
491pgm_do_call: 480pgm_do_call:
@@ -495,7 +484,6 @@ pgm_do_call:
495 la %r2,SP_PTREGS(%r15) # address of register-save area 484 la %r2,SP_PTREGS(%r15) # address of register-save area
496 basr %r14,%r7 # branch to interrupt-handler 485 basr %r14,%r7 # branch to interrupt-handler
497pgm_exit: 486pgm_exit:
498 TRACE_IRQS_CHECK_ON
499 b BASED(sysc_return) 487 b BASED(sysc_return)
500 488
501# 489#
@@ -523,7 +511,6 @@ pgm_per_std:
523 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER 511 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
524 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER 512 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
525pgm_no_vtime2: 513pgm_no_vtime2:
526 TRACE_IRQS_CHECK_OFF
527 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct 514 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
528 l %r1,__TI_task(%r9) 515 l %r1,__TI_task(%r9)
529 tm SP_PSW+1(%r15),0x01 # kernel per event ? 516 tm SP_PSW+1(%r15),0x01 # kernel per event ?
@@ -533,6 +520,8 @@ pgm_no_vtime2:
533 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID 520 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
534 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP 521 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
535 l %r3,__LC_PGM_ILC # load program interruption code 522 l %r3,__LC_PGM_ILC # load program interruption code
523 l %r4,__LC_TRANS_EXC_CODE
524 REENABLE_IRQS
536 la %r8,0x7f 525 la %r8,0x7f
537 nr %r8,%r3 # clear per-event-bit and ilc 526 nr %r8,%r3 # clear per-event-bit and ilc
538 be BASED(pgm_exit2) # only per or per+check ? 527 be BASED(pgm_exit2) # only per or per+check ?
@@ -542,8 +531,6 @@ pgm_no_vtime2:
542 la %r2,SP_PTREGS(%r15) # address of register-save area 531 la %r2,SP_PTREGS(%r15) # address of register-save area
543 basr %r14,%r7 # branch to interrupt-handler 532 basr %r14,%r7 # branch to interrupt-handler
544pgm_exit2: 533pgm_exit2:
545 TRACE_IRQS_ON
546 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
547 b BASED(sysc_return) 534 b BASED(sysc_return)
548 535
549# 536#
@@ -557,13 +544,11 @@ pgm_svcper:
557 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER 544 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
558 lh %r7,0x8a # get svc number from lowcore 545 lh %r7,0x8a # get svc number from lowcore
559 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct 546 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
560 TRACE_IRQS_OFF
561 l %r8,__TI_task(%r9) 547 l %r8,__TI_task(%r9)
562 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID 548 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID
563 mvc __THREAD_per+__PER_address(4,%r8),__LC_PER_ADDRESS 549 mvc __THREAD_per+__PER_address(4,%r8),__LC_PER_ADDRESS
564 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID 550 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID
565 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP 551 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
566 TRACE_IRQS_ON
567 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 552 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
568 lm %r2,%r6,SP_R2(%r15) # load svc arguments 553 lm %r2,%r6,SP_R2(%r15) # load svc arguments
569 b BASED(sysc_do_svc) 554 b BASED(sysc_do_svc)
@@ -572,6 +557,7 @@ pgm_svcper:
572# per was called from kernel, must be kprobes 557# per was called from kernel, must be kprobes
573# 558#
574kernel_per: 559kernel_per:
560 REENABLE_IRQS
575 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check 561 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check
576 mvi SP_SVCNR+1(%r15),0xff 562 mvi SP_SVCNR+1(%r15),0xff
577 la %r2,SP_PTREGS(%r15) # address of register-save area 563 la %r2,SP_PTREGS(%r15) # address of register-save area
@@ -737,7 +723,8 @@ ext_no_vtime:
737 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct 723 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
738 TRACE_IRQS_OFF 724 TRACE_IRQS_OFF
739 la %r2,SP_PTREGS(%r15) # address of register-save area 725 la %r2,SP_PTREGS(%r15) # address of register-save area
740 lh %r3,__LC_EXT_INT_CODE # get interruption code 726 l %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
727 l %r4,__LC_EXT_PARAMS # get external parameters
741 l %r1,BASED(.Ldo_extint) 728 l %r1,BASED(.Ldo_extint)
742 basr %r14,%r1 729 basr %r14,%r1
743 b BASED(io_return) 730 b BASED(io_return)
diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h
index ff579b6bde06..95c1dfc4ef31 100644
--- a/arch/s390/kernel/entry.h
+++ b/arch/s390/kernel/entry.h
@@ -5,7 +5,7 @@
5#include <linux/signal.h> 5#include <linux/signal.h>
6#include <asm/ptrace.h> 6#include <asm/ptrace.h>
7 7
8typedef void pgm_check_handler_t(struct pt_regs *, long); 8typedef void pgm_check_handler_t(struct pt_regs *, long, unsigned long);
9extern pgm_check_handler_t *pgm_check_table[128]; 9extern pgm_check_handler_t *pgm_check_table[128];
10pgm_check_handler_t do_protection_exception; 10pgm_check_handler_t do_protection_exception;
11pgm_check_handler_t do_dat_exception; 11pgm_check_handler_t do_dat_exception;
@@ -19,7 +19,7 @@ void do_signal(struct pt_regs *regs);
19int handle_signal32(unsigned long sig, struct k_sigaction *ka, 19int handle_signal32(unsigned long sig, struct k_sigaction *ka,
20 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs); 20 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs);
21 21
22void do_extint(struct pt_regs *regs, unsigned short code); 22void do_extint(struct pt_regs *regs, unsigned int, unsigned int, unsigned long);
23int __cpuinit start_secondary(void *cpuvoid); 23int __cpuinit start_secondary(void *cpuvoid);
24void __init startup_init(void); 24void __init startup_init(void);
25void die(const char * str, struct pt_regs * regs, long err); 25void die(const char * str, struct pt_regs * regs, long err);
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 8bccec15ea90..8f3e802174db 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -79,25 +79,9 @@ _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
79 basr %r2,%r0 79 basr %r2,%r0
80 brasl %r14,trace_hardirqs_off_caller 80 brasl %r14,trace_hardirqs_off_caller
81 .endm 81 .endm
82
83 .macro TRACE_IRQS_CHECK_ON
84 tm SP_PSW(%r15),0x03 # irqs enabled?
85 jz 0f
86 TRACE_IRQS_ON
870:
88 .endm
89
90 .macro TRACE_IRQS_CHECK_OFF
91 tm SP_PSW(%r15),0x03 # irqs enabled?
92 jz 0f
93 TRACE_IRQS_OFF
940:
95 .endm
96#else 82#else
97#define TRACE_IRQS_ON 83#define TRACE_IRQS_ON
98#define TRACE_IRQS_OFF 84#define TRACE_IRQS_OFF
99#define TRACE_IRQS_CHECK_ON
100#define TRACE_IRQS_CHECK_OFF
101#endif 85#endif
102 86
103#ifdef CONFIG_LOCKDEP 87#ifdef CONFIG_LOCKDEP
@@ -207,6 +191,12 @@ _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
2070: 1910:
208 .endm 192 .endm
209 193
194 .macro REENABLE_IRQS
195 mvc __SF_EMPTY(1,%r15),SP_PSW(%r15)
196 ni __SF_EMPTY(%r15),0xbf
197 ssm __SF_EMPTY(%r15)
198 .endm
199
210/* 200/*
211 * Scheduler resume function, called by switch_to 201 * Scheduler resume function, called by switch_to
212 * gpr2 = (task_struct *) prev 202 * gpr2 = (task_struct *) prev
@@ -256,7 +246,6 @@ sysc_saveall:
256 CREATE_STACK_FRAME __LC_SAVE_AREA 246 CREATE_STACK_FRAME __LC_SAVE_AREA
257 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW 247 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW
258 mvc SP_ILC(4,%r15),__LC_SVC_ILC 248 mvc SP_ILC(4,%r15),__LC_SVC_ILC
259 stg %r7,SP_ARGS(%r15)
260 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct 249 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
261sysc_vtime: 250sysc_vtime:
262 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER 251 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
@@ -284,6 +273,7 @@ sysc_nr_ok:
284sysc_noemu: 273sysc_noemu:
285#endif 274#endif
286 tm __TI_flags+6(%r12),_TIF_SYSCALL 275 tm __TI_flags+6(%r12),_TIF_SYSCALL
276 mvc SP_ARGS(8,%r15),SP_R7(%r15)
287 lgf %r8,0(%r7,%r10) # load address of system call routine 277 lgf %r8,0(%r7,%r10) # load address of system call routine
288 jnz sysc_tracesys 278 jnz sysc_tracesys
289 basr %r14,%r8 # call sys_xxxx 279 basr %r14,%r8 # call sys_xxxx
@@ -397,6 +387,7 @@ sysc_tracesys:
397 lgf %r8,0(%r7,%r10) 387 lgf %r8,0(%r7,%r10)
398sysc_tracego: 388sysc_tracego:
399 lmg %r3,%r6,SP_R3(%r15) 389 lmg %r3,%r6,SP_R3(%r15)
390 mvc SP_ARGS(8,%r15),SP_R7(%r15)
400 lg %r2,SP_ORIG_R2(%r15) 391 lg %r2,SP_ORIG_R2(%r15)
401 basr %r14,%r8 # call sys_xxx 392 basr %r14,%r8 # call sys_xxx
402 stg %r2,SP_R2(%r15) # store return value 393 stg %r2,SP_R2(%r15) # store return value
@@ -443,14 +434,12 @@ kernel_execve:
443 br %r14 434 br %r14
444 # execve succeeded. 435 # execve succeeded.
4450: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts 4360: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
446# TRACE_IRQS_OFF
447 lg %r15,__LC_KERNEL_STACK # load ksp 437 lg %r15,__LC_KERNEL_STACK # load ksp
448 aghi %r15,-SP_SIZE # make room for registers & psw 438 aghi %r15,-SP_SIZE # make room for registers & psw
449 lg %r13,__LC_SVC_NEW_PSW+8 439 lg %r13,__LC_SVC_NEW_PSW+8
450 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs 440 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
451 lg %r12,__LC_THREAD_INFO 441 lg %r12,__LC_THREAD_INFO
452 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 442 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
453# TRACE_IRQS_ON
454 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 443 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
455 brasl %r14,execve_tail 444 brasl %r14,execve_tail
456 j sysc_return 445 j sysc_return
@@ -490,19 +479,18 @@ pgm_check_handler:
490 LAST_BREAK 479 LAST_BREAK
491pgm_no_vtime: 480pgm_no_vtime:
492 HANDLE_SIE_INTERCEPT 481 HANDLE_SIE_INTERCEPT
493 TRACE_IRQS_CHECK_OFF
494 stg %r11,SP_ARGS(%r15) 482 stg %r11,SP_ARGS(%r15)
495 lgf %r3,__LC_PGM_ILC # load program interruption code 483 lgf %r3,__LC_PGM_ILC # load program interruption code
484 lg %r4,__LC_TRANS_EXC_CODE
485 REENABLE_IRQS
496 lghi %r8,0x7f 486 lghi %r8,0x7f
497 ngr %r8,%r3 487 ngr %r8,%r3
498pgm_do_call:
499 sll %r8,3 488 sll %r8,3
500 larl %r1,pgm_check_table 489 larl %r1,pgm_check_table
501 lg %r1,0(%r8,%r1) # load address of handler routine 490 lg %r1,0(%r8,%r1) # load address of handler routine
502 la %r2,SP_PTREGS(%r15) # address of register-save area 491 la %r2,SP_PTREGS(%r15) # address of register-save area
503 basr %r14,%r1 # branch to interrupt-handler 492 basr %r14,%r1 # branch to interrupt-handler
504pgm_exit: 493pgm_exit:
505 TRACE_IRQS_CHECK_ON
506 j sysc_return 494 j sysc_return
507 495
508# 496#
@@ -533,7 +521,6 @@ pgm_per_std:
533 LAST_BREAK 521 LAST_BREAK
534pgm_no_vtime2: 522pgm_no_vtime2:
535 HANDLE_SIE_INTERCEPT 523 HANDLE_SIE_INTERCEPT
536 TRACE_IRQS_CHECK_OFF
537 lg %r1,__TI_task(%r12) 524 lg %r1,__TI_task(%r12)
538 tm SP_PSW+1(%r15),0x01 # kernel per event ? 525 tm SP_PSW+1(%r15),0x01 # kernel per event ?
539 jz kernel_per 526 jz kernel_per
@@ -542,6 +529,8 @@ pgm_no_vtime2:
542 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID 529 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
543 oi __TI_flags+7(%r12),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP 530 oi __TI_flags+7(%r12),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
544 lgf %r3,__LC_PGM_ILC # load program interruption code 531 lgf %r3,__LC_PGM_ILC # load program interruption code
532 lg %r4,__LC_TRANS_EXC_CODE
533 REENABLE_IRQS
545 lghi %r8,0x7f 534 lghi %r8,0x7f
546 ngr %r8,%r3 # clear per-event-bit and ilc 535 ngr %r8,%r3 # clear per-event-bit and ilc
547 je pgm_exit2 536 je pgm_exit2
@@ -551,8 +540,6 @@ pgm_no_vtime2:
551 la %r2,SP_PTREGS(%r15) # address of register-save area 540 la %r2,SP_PTREGS(%r15) # address of register-save area
552 basr %r14,%r1 # branch to interrupt-handler 541 basr %r14,%r1 # branch to interrupt-handler
553pgm_exit2: 542pgm_exit2:
554 TRACE_IRQS_ON
555 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
556 j sysc_return 543 j sysc_return
557 544
558# 545#
@@ -568,13 +555,11 @@ pgm_svcper:
568 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER 555 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
569 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER 556 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
570 LAST_BREAK 557 LAST_BREAK
571 TRACE_IRQS_OFF
572 lg %r8,__TI_task(%r12) 558 lg %r8,__TI_task(%r12)
573 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID 559 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID
574 mvc __THREAD_per+__PER_address(8,%r8),__LC_PER_ADDRESS 560 mvc __THREAD_per+__PER_address(8,%r8),__LC_PER_ADDRESS
575 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID 561 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID
576 oi __TI_flags+7(%r12),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP 562 oi __TI_flags+7(%r12),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
577 TRACE_IRQS_ON
578 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts 563 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
579 lmg %r2,%r6,SP_R2(%r15) # load svc arguments 564 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
580 j sysc_do_svc 565 j sysc_do_svc
@@ -583,6 +568,7 @@ pgm_svcper:
583# per was called from kernel, must be kprobes 568# per was called from kernel, must be kprobes
584# 569#
585kernel_per: 570kernel_per:
571 REENABLE_IRQS
586 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number 572 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
587 la %r2,SP_PTREGS(%r15) # address of register-save area 573 la %r2,SP_PTREGS(%r15) # address of register-save area
588 brasl %r14,do_single_step 574 brasl %r14,do_single_step
@@ -743,8 +729,11 @@ ext_int_handler:
743ext_no_vtime: 729ext_no_vtime:
744 HANDLE_SIE_INTERCEPT 730 HANDLE_SIE_INTERCEPT
745 TRACE_IRQS_OFF 731 TRACE_IRQS_OFF
732 lghi %r1,4096
746 la %r2,SP_PTREGS(%r15) # address of register-save area 733 la %r2,SP_PTREGS(%r15) # address of register-save area
747 llgh %r3,__LC_EXT_INT_CODE # get interruption code 734 llgf %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
735 llgf %r4,__LC_EXT_PARAMS # get external parameter
736 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
748 brasl %r14,do_extint 737 brasl %r14,do_extint
749 j io_return 738 j io_return
750 739
@@ -966,7 +955,6 @@ cleanup_system_call:
966 CREATE_STACK_FRAME __LC_SAVE_AREA 955 CREATE_STACK_FRAME __LC_SAVE_AREA
967 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW 956 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW
968 mvc SP_ILC(4,%r15),__LC_SVC_ILC 957 mvc SP_ILC(4,%r15),__LC_SVC_ILC
969 stg %r7,SP_ARGS(%r15)
970 mvc 8(8,%r12),__LC_THREAD_INFO 958 mvc 8(8,%r12),__LC_THREAD_INFO
971cleanup_vtime: 959cleanup_vtime:
972 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24) 960 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index db1696e210af..7061398341d5 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -488,7 +488,9 @@ startup:
488 .align 16 488 .align 16
4892: .long 0x000a0000,0x8badcccc 4892: .long 0x000a0000,0x8badcccc
490#if defined(CONFIG_64BIT) 490#if defined(CONFIG_64BIT)
491#if defined(CONFIG_MARCH_Z10) 491#if defined(CONFIG_MARCH_Z196)
492 .long 0xc100efe3, 0xf46c0000
493#elif defined(CONFIG_MARCH_Z10)
492 .long 0xc100efe3, 0xf0680000 494 .long 0xc100efe3, 0xf0680000
493#elif defined(CONFIG_MARCH_Z9_109) 495#elif defined(CONFIG_MARCH_Z9_109)
494 .long 0xc100efc3, 0x00000000 496 .long 0xc100efc3, 0x00000000
@@ -498,7 +500,9 @@ startup:
498 .long 0xc0000000, 0x00000000 500 .long 0xc0000000, 0x00000000
499#endif 501#endif
500#else 502#else
501#if defined(CONFIG_MARCH_Z10) 503#if defined(CONFIG_MARCH_Z196)
504 .long 0x8100c880, 0x00000000
505#elif defined(CONFIG_MARCH_Z10)
502 .long 0x8100c880, 0x00000000 506 .long 0x8100c880, 0x00000000
503#elif defined(CONFIG_MARCH_Z9_109) 507#elif defined(CONFIG_MARCH_Z9_109)
504 .long 0x8100c880, 0x00000000 508 .long 0x8100c880, 0x00000000
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 2a3d2bf6f083..d60fc4398516 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -316,6 +316,8 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
316 return 1; 316 return 1;
317 317
318ss_probe: 318ss_probe:
319 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
320 local_irq_disable();
319 prepare_singlestep(p, regs); 321 prepare_singlestep(p, regs);
320 kcb->kprobe_status = KPROBE_HIT_SS; 322 kcb->kprobe_status = KPROBE_HIT_SS;
321 return 1; 323 return 1;
@@ -463,6 +465,8 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
463 goto out; 465 goto out;
464 } 466 }
465 reset_current_kprobe(); 467 reset_current_kprobe();
468 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
469 local_irq_enable();
466out: 470out:
467 preempt_enable_no_resched(); 471 preempt_enable_no_resched();
468 472
@@ -502,8 +506,11 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
502 regs->psw.mask |= kcb->kprobe_saved_imask; 506 regs->psw.mask |= kcb->kprobe_saved_imask;
503 if (kcb->kprobe_status == KPROBE_REENTER) 507 if (kcb->kprobe_status == KPROBE_REENTER)
504 restore_previous_kprobe(kcb); 508 restore_previous_kprobe(kcb);
505 else 509 else {
506 reset_current_kprobe(); 510 reset_current_kprobe();
511 if (regs->psw.mask & (PSW_MASK_PER | PSW_MASK_IO))
512 local_irq_enable();
513 }
507 preempt_enable_no_resched(); 514 preempt_enable_no_resched();
508 break; 515 break;
509 case KPROBE_HIT_ACTIVE: 516 case KPROBE_HIT_ACTIVE:
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index d3a2d1c6438e..ec2e03b22ead 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -76,17 +76,17 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
76static void default_idle(void) 76static void default_idle(void)
77{ 77{
78 /* CPU is going idle. */ 78 /* CPU is going idle. */
79 local_irq_disable();
80 if (need_resched()) {
81 local_irq_enable();
82 return;
83 }
84#ifdef CONFIG_HOTPLUG_CPU 79#ifdef CONFIG_HOTPLUG_CPU
85 if (cpu_is_offline(smp_processor_id())) { 80 if (cpu_is_offline(smp_processor_id())) {
86 preempt_enable_no_resched(); 81 preempt_enable_no_resched();
87 cpu_die(); 82 cpu_die();
88 } 83 }
89#endif 84#endif
85 local_irq_disable();
86 if (need_resched()) {
87 local_irq_enable();
88 return;
89 }
90 local_mcck_disable(); 90 local_mcck_disable();
91 if (test_thread_flag(TIF_MCCK_PENDING)) { 91 if (test_thread_flag(TIF_MCCK_PENDING)) {
92 local_mcck_enable(); 92 local_mcck_enable();
diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c
index ecb2d02b02e4..644548e615c6 100644
--- a/arch/s390/kernel/processor.c
+++ b/arch/s390/kernel/processor.c
@@ -42,7 +42,7 @@ void __cpuinit print_cpu_info(void)
42 struct cpuid *id = &per_cpu(cpu_id, smp_processor_id()); 42 struct cpuid *id = &per_cpu(cpu_id, smp_processor_id());
43 43
44 pr_info("Processor %d started, address %d, identification %06X\n", 44 pr_info("Processor %d started, address %d, identification %06X\n",
45 S390_lowcore.cpu_nr, S390_lowcore.cpu_addr, id->ident); 45 S390_lowcore.cpu_nr, stap(), id->ident);
46} 46}
47 47
48/* 48/*
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 83339d33c4b1..019bb714db49 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -343,7 +343,8 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)
343 return __poke_user(child, addr, data); 343 return __poke_user(child, addr, data);
344} 344}
345 345
346long arch_ptrace(struct task_struct *child, long request, long addr, long data) 346long arch_ptrace(struct task_struct *child, long request,
347 unsigned long addr, unsigned long data)
347{ 348{
348 ptrace_area parea; 349 ptrace_area parea;
349 int copied, ret; 350 int copied, ret;
diff --git a/arch/s390/kernel/s390_ext.c b/arch/s390/kernel/s390_ext.c
index 9ce641b5291f..bd1db508e8af 100644
--- a/arch/s390/kernel/s390_ext.c
+++ b/arch/s390/kernel/s390_ext.c
@@ -113,12 +113,15 @@ int unregister_early_external_interrupt(__u16 code, ext_int_handler_t handler,
113 return 0; 113 return 0;
114} 114}
115 115
116void __irq_entry do_extint(struct pt_regs *regs, unsigned short code) 116void __irq_entry do_extint(struct pt_regs *regs, unsigned int ext_int_code,
117 unsigned int param32, unsigned long param64)
117{ 118{
119 struct pt_regs *old_regs;
120 unsigned short code;
118 ext_int_info_t *p; 121 ext_int_info_t *p;
119 int index; 122 int index;
120 struct pt_regs *old_regs;
121 123
124 code = (unsigned short) ext_int_code;
122 old_regs = set_irq_regs(regs); 125 old_regs = set_irq_regs(regs);
123 s390_idle_check(regs, S390_lowcore.int_clock, 126 s390_idle_check(regs, S390_lowcore.int_clock,
124 S390_lowcore.async_enter_timer); 127 S390_lowcore.async_enter_timer);
@@ -132,7 +135,7 @@ void __irq_entry do_extint(struct pt_regs *regs, unsigned short code)
132 index = ext_hash(code); 135 index = ext_hash(code);
133 for (p = ext_int_hash[index]; p; p = p->next) { 136 for (p = ext_int_hash[index]; p; p = p->next) {
134 if (likely(p->code == code)) 137 if (likely(p->code == code))
135 p->handler(code); 138 p->handler(ext_int_code, param32, param64);
136 } 139 }
137 irq_exit(); 140 irq_exit();
138 set_irq_regs(old_regs); 141 set_irq_regs(old_regs);
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index c8e8e1354e1d..6f6350826c81 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -409,6 +409,9 @@ setup_lowcore(void)
409 lc->current_task = (unsigned long) init_thread_union.thread_info.task; 409 lc->current_task = (unsigned long) init_thread_union.thread_info.task;
410 lc->thread_info = (unsigned long) &init_thread_union; 410 lc->thread_info = (unsigned long) &init_thread_union;
411 lc->machine_flags = S390_lowcore.machine_flags; 411 lc->machine_flags = S390_lowcore.machine_flags;
412 lc->stfl_fac_list = S390_lowcore.stfl_fac_list;
413 memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list,
414 MAX_FACILITY_BIT/8);
412#ifndef CONFIG_64BIT 415#ifndef CONFIG_64BIT
413 if (MACHINE_HAS_IEEE) { 416 if (MACHINE_HAS_IEEE) {
414 lc->extended_save_area_addr = (__u32) 417 lc->extended_save_area_addr = (__u32)
@@ -627,7 +630,8 @@ setup_memory(void)
627 add_active_range(0, start_chunk, end_chunk); 630 add_active_range(0, start_chunk, end_chunk);
628 pfn = max(start_chunk, start_pfn); 631 pfn = max(start_chunk, start_pfn);
629 for (; pfn < end_chunk; pfn++) 632 for (; pfn < end_chunk; pfn++)
630 page_set_storage_key(PFN_PHYS(pfn), PAGE_DEFAULT_KEY); 633 page_set_storage_key(PFN_PHYS(pfn),
634 PAGE_DEFAULT_KEY, 0);
631 } 635 }
632 636
633 psw_set_key(PAGE_DEFAULT_KEY); 637 psw_set_key(PAGE_DEFAULT_KEY);
@@ -674,12 +678,9 @@ setup_memory(void)
674static void __init setup_hwcaps(void) 678static void __init setup_hwcaps(void)
675{ 679{
676 static const int stfl_bits[6] = { 0, 2, 7, 17, 19, 21 }; 680 static const int stfl_bits[6] = { 0, 2, 7, 17, 19, 21 };
677 unsigned long long facility_list_extended;
678 unsigned int facility_list;
679 struct cpuid cpu_id; 681 struct cpuid cpu_id;
680 int i; 682 int i;
681 683
682 facility_list = stfl();
683 /* 684 /*
684 * The store facility list bits numbers as found in the principles 685 * The store facility list bits numbers as found in the principles
685 * of operation are numbered with bit 1UL<<31 as number 0 to 686 * of operation are numbered with bit 1UL<<31 as number 0 to
@@ -699,11 +700,10 @@ static void __init setup_hwcaps(void)
699 * HWCAP_S390_ETF3EH bit 8 (22 && 30). 700 * HWCAP_S390_ETF3EH bit 8 (22 && 30).
700 */ 701 */
701 for (i = 0; i < 6; i++) 702 for (i = 0; i < 6; i++)
702 if (facility_list & (1UL << (31 - stfl_bits[i]))) 703 if (test_facility(stfl_bits[i]))
703 elf_hwcap |= 1UL << i; 704 elf_hwcap |= 1UL << i;
704 705
705 if ((facility_list & (1UL << (31 - 22))) 706 if (test_facility(22) && test_facility(30))
706 && (facility_list & (1UL << (31 - 30))))
707 elf_hwcap |= HWCAP_S390_ETF3EH; 707 elf_hwcap |= HWCAP_S390_ETF3EH;
708 708
709 /* 709 /*
@@ -719,12 +719,8 @@ static void __init setup_hwcaps(void)
719 * translated to: 719 * translated to:
720 * HWCAP_S390_DFP bit 6 (42 && 44). 720 * HWCAP_S390_DFP bit 6 (42 && 44).
721 */ 721 */
722 if ((elf_hwcap & (1UL << 2)) && 722 if ((elf_hwcap & (1UL << 2)) && test_facility(42) && test_facility(44))
723 __stfle(&facility_list_extended, 1) > 0) { 723 elf_hwcap |= HWCAP_S390_DFP;
724 if ((facility_list_extended & (1ULL << (63 - 42)))
725 && (facility_list_extended & (1ULL << (63 - 44))))
726 elf_hwcap |= HWCAP_S390_DFP;
727 }
728 724
729 /* 725 /*
730 * Huge page support HWCAP_S390_HPAGE is bit 7. 726 * Huge page support HWCAP_S390_HPAGE is bit 7.
@@ -765,6 +761,9 @@ static void __init setup_hwcaps(void)
765 case 0x2098: 761 case 0x2098:
766 strcpy(elf_platform, "z10"); 762 strcpy(elf_platform, "z10");
767 break; 763 break;
764 case 0x2817:
765 strcpy(elf_platform, "z196");
766 break;
768 } 767 }
769} 768}
770 769
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 8127ebd59c4d..94cf510b8fe1 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -156,7 +156,8 @@ void smp_send_stop(void)
156 * cpus are handled. 156 * cpus are handled.
157 */ 157 */
158 158
159static void do_ext_call_interrupt(__u16 code) 159static void do_ext_call_interrupt(unsigned int ext_int_code,
160 unsigned int param32, unsigned long param64)
160{ 161{
161 unsigned long bits; 162 unsigned long bits;
162 163
@@ -593,6 +594,8 @@ int __cpuinit __cpu_up(unsigned int cpu)
593 cpu_lowcore->kernel_asce = S390_lowcore.kernel_asce; 594 cpu_lowcore->kernel_asce = S390_lowcore.kernel_asce;
594 cpu_lowcore->machine_flags = S390_lowcore.machine_flags; 595 cpu_lowcore->machine_flags = S390_lowcore.machine_flags;
595 cpu_lowcore->ftrace_func = S390_lowcore.ftrace_func; 596 cpu_lowcore->ftrace_func = S390_lowcore.ftrace_func;
597 memcpy(cpu_lowcore->stfle_fac_list, S390_lowcore.stfle_fac_list,
598 MAX_FACILITY_BIT/8);
596 eieio(); 599 eieio();
597 600
598 while (sigp(cpu, sigp_restart) == sigp_busy) 601 while (sigp(cpu, sigp_restart) == sigp_busy)
diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c
index a0ffc7717ed6..5c9e439bf3f6 100644
--- a/arch/s390/kernel/sysinfo.c
+++ b/arch/s390/kernel/sysinfo.c
@@ -15,6 +15,7 @@
15#include <asm/ebcdic.h> 15#include <asm/ebcdic.h>
16#include <asm/sysinfo.h> 16#include <asm/sysinfo.h>
17#include <asm/cpcmd.h> 17#include <asm/cpcmd.h>
18#include <asm/topology.h>
18 19
19/* Sigh, math-emu. Don't ask. */ 20/* Sigh, math-emu. Don't ask. */
20#include <asm/sfp-util.h> 21#include <asm/sfp-util.h>
@@ -74,6 +75,44 @@ static int stsi_1_1_1(struct sysinfo_1_1_1 *info, char *page, int len)
74 "Model Temp. Capacity: %-16.16s %08u\n", 75 "Model Temp. Capacity: %-16.16s %08u\n",
75 info->model_temp_cap, 76 info->model_temp_cap,
76 *(u32 *) info->model_temp_cap_rating); 77 *(u32 *) info->model_temp_cap_rating);
78 if (info->cai) {
79 len += sprintf(page + len,
80 "Capacity Adj. Ind.: %d\n",
81 info->cai);
82 len += sprintf(page + len, "Capacity Ch. Reason: %d\n",
83 info->ccr);
84 }
85 return len;
86}
87
88static int stsi_15_1_x(struct sysinfo_15_1_x *info, char *page, int len)
89{
90 static int max_mnest;
91 int i, rc;
92
93 len += sprintf(page + len, "\n");
94 if (!MACHINE_HAS_TOPOLOGY)
95 return len;
96 if (max_mnest) {
97 stsi(info, 15, 1, max_mnest);
98 } else {
99 for (max_mnest = 6; max_mnest > 1; max_mnest--) {
100 rc = stsi(info, 15, 1, max_mnest);
101 if (rc != -ENOSYS)
102 break;
103 }
104 }
105 len += sprintf(page + len, "CPU Topology HW: ");
106 for (i = 0; i < TOPOLOGY_NR_MAG; i++)
107 len += sprintf(page + len, " %d", info->mag[i]);
108 len += sprintf(page + len, "\n");
109#ifdef CONFIG_SCHED_MC
110 store_topology(info);
111 len += sprintf(page + len, "CPU Topology SW: ");
112 for (i = 0; i < TOPOLOGY_NR_MAG; i++)
113 len += sprintf(page + len, " %d", info->mag[i]);
114 len += sprintf(page + len, "\n");
115#endif
77 return len; 116 return len;
78} 117}
79 118
@@ -87,7 +126,6 @@ static int stsi_1_2_2(struct sysinfo_1_2_2 *info, char *page, int len)
87 ext = (struct sysinfo_1_2_2_extension *) 126 ext = (struct sysinfo_1_2_2_extension *)
88 ((unsigned long) info + info->acc_offset); 127 ((unsigned long) info + info->acc_offset);
89 128
90 len += sprintf(page + len, "\n");
91 len += sprintf(page + len, "CPUs Total: %d\n", 129 len += sprintf(page + len, "CPUs Total: %d\n",
92 info->cpus_total); 130 info->cpus_total);
93 len += sprintf(page + len, "CPUs Configured: %d\n", 131 len += sprintf(page + len, "CPUs Configured: %d\n",
@@ -217,6 +255,9 @@ static int proc_read_sysinfo(char *page, char **start,
217 len = stsi_1_1_1((struct sysinfo_1_1_1 *) info, page, len); 255 len = stsi_1_1_1((struct sysinfo_1_1_1 *) info, page, len);
218 256
219 if (level >= 1) 257 if (level >= 1)
258 len = stsi_15_1_x((struct sysinfo_15_1_x *) info, page, len);
259
260 if (level >= 1)
220 len = stsi_1_2_2((struct sysinfo_1_2_2 *) info, page, len); 261 len = stsi_1_2_2((struct sysinfo_1_2_2 *) info, page, len);
221 262
222 if (level >= 2) 263 if (level >= 2)
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 2896cac9c14a..f754a6dc4f94 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -155,7 +155,9 @@ void init_cpu_timer(void)
155 __ctl_set_bit(0, 4); 155 __ctl_set_bit(0, 4);
156} 156}
157 157
158static void clock_comparator_interrupt(__u16 code) 158static void clock_comparator_interrupt(unsigned int ext_int_code,
159 unsigned int param32,
160 unsigned long param64)
159{ 161{
160 if (S390_lowcore.clock_comparator == -1ULL) 162 if (S390_lowcore.clock_comparator == -1ULL)
161 set_clock_comparator(S390_lowcore.clock_comparator); 163 set_clock_comparator(S390_lowcore.clock_comparator);
@@ -164,14 +166,13 @@ static void clock_comparator_interrupt(__u16 code)
164static void etr_timing_alert(struct etr_irq_parm *); 166static void etr_timing_alert(struct etr_irq_parm *);
165static void stp_timing_alert(struct stp_irq_parm *); 167static void stp_timing_alert(struct stp_irq_parm *);
166 168
167static void timing_alert_interrupt(__u16 code) 169static void timing_alert_interrupt(unsigned int ext_int_code,
170 unsigned int param32, unsigned long param64)
168{ 171{
169 if (S390_lowcore.ext_params & 0x00c40000) 172 if (param32 & 0x00c40000)
170 etr_timing_alert((struct etr_irq_parm *) 173 etr_timing_alert((struct etr_irq_parm *) &param32);
171 &S390_lowcore.ext_params); 174 if (param32 & 0x00038000)
172 if (S390_lowcore.ext_params & 0x00038000) 175 stp_timing_alert((struct stp_irq_parm *) &param32);
173 stp_timing_alert((struct stp_irq_parm *)
174 &S390_lowcore.ext_params);
175} 176}
176 177
177static void etr_reset(void); 178static void etr_reset(void);
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 13559c993847..94b06c31fc8a 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -18,55 +18,20 @@
18#include <linux/cpuset.h> 18#include <linux/cpuset.h>
19#include <asm/delay.h> 19#include <asm/delay.h>
20#include <asm/s390_ext.h> 20#include <asm/s390_ext.h>
21#include <asm/sysinfo.h>
22
23#define CPU_BITS 64
24#define NR_MAG 6
25 21
26#define PTF_HORIZONTAL (0UL) 22#define PTF_HORIZONTAL (0UL)
27#define PTF_VERTICAL (1UL) 23#define PTF_VERTICAL (1UL)
28#define PTF_CHECK (2UL) 24#define PTF_CHECK (2UL)
29 25
30struct tl_cpu {
31 unsigned char reserved0[4];
32 unsigned char :6;
33 unsigned char pp:2;
34 unsigned char reserved1;
35 unsigned short origin;
36 unsigned long mask[CPU_BITS / BITS_PER_LONG];
37};
38
39struct tl_container {
40 unsigned char reserved[7];
41 unsigned char id;
42};
43
44union tl_entry {
45 unsigned char nl;
46 struct tl_cpu cpu;
47 struct tl_container container;
48};
49
50struct tl_info {
51 unsigned char reserved0[2];
52 unsigned short length;
53 unsigned char mag[NR_MAG];
54 unsigned char reserved1;
55 unsigned char mnest;
56 unsigned char reserved2[4];
57 union tl_entry tle[0];
58};
59
60struct mask_info { 26struct mask_info {
61 struct mask_info *next; 27 struct mask_info *next;
62 unsigned char id; 28 unsigned char id;
63 cpumask_t mask; 29 cpumask_t mask;
64}; 30};
65 31
66static int topology_enabled; 32static int topology_enabled = 1;
67static void topology_work_fn(struct work_struct *work); 33static void topology_work_fn(struct work_struct *work);
68static struct tl_info *tl_info; 34static struct sysinfo_15_1_x *tl_info;
69static int machine_has_topology;
70static struct timer_list topology_timer; 35static struct timer_list topology_timer;
71static void set_topology_timer(void); 36static void set_topology_timer(void);
72static DECLARE_WORK(topology_work, topology_work_fn); 37static DECLARE_WORK(topology_work, topology_work_fn);
@@ -88,8 +53,10 @@ static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
88 cpumask_t mask; 53 cpumask_t mask;
89 54
90 cpus_clear(mask); 55 cpus_clear(mask);
91 if (!topology_enabled || !machine_has_topology) 56 if (!topology_enabled || !MACHINE_HAS_TOPOLOGY) {
92 return cpu_possible_map; 57 cpumask_copy(&mask, cpumask_of(cpu));
58 return mask;
59 }
93 while (info) { 60 while (info) {
94 if (cpu_isset(cpu, info->mask)) { 61 if (cpu_isset(cpu, info->mask)) {
95 mask = info->mask; 62 mask = info->mask;
@@ -102,18 +69,18 @@ static cpumask_t cpu_group_map(struct mask_info *info, unsigned int cpu)
102 return mask; 69 return mask;
103} 70}
104 71
105static void add_cpus_to_mask(struct tl_cpu *tl_cpu, struct mask_info *book, 72static void add_cpus_to_mask(struct topology_cpu *tl_cpu,
106 struct mask_info *core) 73 struct mask_info *book, struct mask_info *core)
107{ 74{
108 unsigned int cpu; 75 unsigned int cpu;
109 76
110 for (cpu = find_first_bit(&tl_cpu->mask[0], CPU_BITS); 77 for (cpu = find_first_bit(&tl_cpu->mask[0], TOPOLOGY_CPU_BITS);
111 cpu < CPU_BITS; 78 cpu < TOPOLOGY_CPU_BITS;
112 cpu = find_next_bit(&tl_cpu->mask[0], CPU_BITS, cpu + 1)) 79 cpu = find_next_bit(&tl_cpu->mask[0], TOPOLOGY_CPU_BITS, cpu + 1))
113 { 80 {
114 unsigned int rcpu, lcpu; 81 unsigned int rcpu, lcpu;
115 82
116 rcpu = CPU_BITS - 1 - cpu + tl_cpu->origin; 83 rcpu = TOPOLOGY_CPU_BITS - 1 - cpu + tl_cpu->origin;
117 for_each_present_cpu(lcpu) { 84 for_each_present_cpu(lcpu) {
118 if (cpu_logical_map(lcpu) != rcpu) 85 if (cpu_logical_map(lcpu) != rcpu)
119 continue; 86 continue;
@@ -146,15 +113,14 @@ static void clear_masks(void)
146#endif 113#endif
147} 114}
148 115
149static union tl_entry *next_tle(union tl_entry *tle) 116static union topology_entry *next_tle(union topology_entry *tle)
150{ 117{
151 if (tle->nl) 118 if (!tle->nl)
152 return (union tl_entry *)((struct tl_container *)tle + 1); 119 return (union topology_entry *)((struct topology_cpu *)tle + 1);
153 else 120 return (union topology_entry *)((struct topology_container *)tle + 1);
154 return (union tl_entry *)((struct tl_cpu *)tle + 1);
155} 121}
156 122
157static void tl_to_cores(struct tl_info *info) 123static void tl_to_cores(struct sysinfo_15_1_x *info)
158{ 124{
159#ifdef CONFIG_SCHED_BOOK 125#ifdef CONFIG_SCHED_BOOK
160 struct mask_info *book = &book_info; 126 struct mask_info *book = &book_info;
@@ -162,13 +128,13 @@ static void tl_to_cores(struct tl_info *info)
162 struct mask_info *book = NULL; 128 struct mask_info *book = NULL;
163#endif 129#endif
164 struct mask_info *core = &core_info; 130 struct mask_info *core = &core_info;
165 union tl_entry *tle, *end; 131 union topology_entry *tle, *end;
166 132
167 133
168 spin_lock_irq(&topology_lock); 134 spin_lock_irq(&topology_lock);
169 clear_masks(); 135 clear_masks();
170 tle = info->tle; 136 tle = info->tle;
171 end = (union tl_entry *)((unsigned long)info + info->length); 137 end = (union topology_entry *)((unsigned long)info + info->length);
172 while (tle < end) { 138 while (tle < end) {
173 switch (tle->nl) { 139 switch (tle->nl) {
174#ifdef CONFIG_SCHED_BOOK 140#ifdef CONFIG_SCHED_BOOK
@@ -186,7 +152,6 @@ static void tl_to_cores(struct tl_info *info)
186 break; 152 break;
187 default: 153 default:
188 clear_masks(); 154 clear_masks();
189 machine_has_topology = 0;
190 goto out; 155 goto out;
191 } 156 }
192 tle = next_tle(tle); 157 tle = next_tle(tle);
@@ -223,7 +188,7 @@ int topology_set_cpu_management(int fc)
223 int cpu; 188 int cpu;
224 int rc; 189 int rc;
225 190
226 if (!machine_has_topology) 191 if (!MACHINE_HAS_TOPOLOGY)
227 return -EOPNOTSUPP; 192 return -EOPNOTSUPP;
228 if (fc) 193 if (fc)
229 rc = ptf(PTF_VERTICAL); 194 rc = ptf(PTF_VERTICAL);
@@ -251,7 +216,7 @@ static void update_cpu_core_map(void)
251 spin_unlock_irqrestore(&topology_lock, flags); 216 spin_unlock_irqrestore(&topology_lock, flags);
252} 217}
253 218
254static void store_topology(struct tl_info *info) 219void store_topology(struct sysinfo_15_1_x *info)
255{ 220{
256#ifdef CONFIG_SCHED_BOOK 221#ifdef CONFIG_SCHED_BOOK
257 int rc; 222 int rc;
@@ -265,11 +230,11 @@ static void store_topology(struct tl_info *info)
265 230
266int arch_update_cpu_topology(void) 231int arch_update_cpu_topology(void)
267{ 232{
268 struct tl_info *info = tl_info; 233 struct sysinfo_15_1_x *info = tl_info;
269 struct sys_device *sysdev; 234 struct sys_device *sysdev;
270 int cpu; 235 int cpu;
271 236
272 if (!machine_has_topology) { 237 if (!MACHINE_HAS_TOPOLOGY) {
273 update_cpu_core_map(); 238 update_cpu_core_map();
274 topology_update_polarization_simple(); 239 topology_update_polarization_simple();
275 return 0; 240 return 0;
@@ -311,9 +276,9 @@ static void set_topology_timer(void)
311 276
312static int __init early_parse_topology(char *p) 277static int __init early_parse_topology(char *p)
313{ 278{
314 if (strncmp(p, "on", 2)) 279 if (strncmp(p, "off", 3))
315 return 0; 280 return 0;
316 topology_enabled = 1; 281 topology_enabled = 0;
317 return 0; 282 return 0;
318} 283}
319early_param("topology", early_parse_topology); 284early_param("topology", early_parse_topology);
@@ -323,7 +288,7 @@ static int __init init_topology_update(void)
323 int rc; 288 int rc;
324 289
325 rc = 0; 290 rc = 0;
326 if (!machine_has_topology) { 291 if (!MACHINE_HAS_TOPOLOGY) {
327 topology_update_polarization_simple(); 292 topology_update_polarization_simple();
328 goto out; 293 goto out;
329 } 294 }
@@ -335,13 +300,14 @@ out:
335} 300}
336__initcall(init_topology_update); 301__initcall(init_topology_update);
337 302
338static void alloc_masks(struct tl_info *info, struct mask_info *mask, int offset) 303static void alloc_masks(struct sysinfo_15_1_x *info, struct mask_info *mask,
304 int offset)
339{ 305{
340 int i, nr_masks; 306 int i, nr_masks;
341 307
342 nr_masks = info->mag[NR_MAG - offset]; 308 nr_masks = info->mag[TOPOLOGY_NR_MAG - offset];
343 for (i = 0; i < info->mnest - offset; i++) 309 for (i = 0; i < info->mnest - offset; i++)
344 nr_masks *= info->mag[NR_MAG - offset - 1 - i]; 310 nr_masks *= info->mag[TOPOLOGY_NR_MAG - offset - 1 - i];
345 nr_masks = max(nr_masks, 1); 311 nr_masks = max(nr_masks, 1);
346 for (i = 0; i < nr_masks; i++) { 312 for (i = 0; i < nr_masks; i++) {
347 mask->next = alloc_bootmem(sizeof(struct mask_info)); 313 mask->next = alloc_bootmem(sizeof(struct mask_info));
@@ -351,21 +317,16 @@ static void alloc_masks(struct tl_info *info, struct mask_info *mask, int offset
351 317
352void __init s390_init_cpu_topology(void) 318void __init s390_init_cpu_topology(void)
353{ 319{
354 unsigned long long facility_bits; 320 struct sysinfo_15_1_x *info;
355 struct tl_info *info;
356 int i; 321 int i;
357 322
358 if (stfle(&facility_bits, 1) <= 0) 323 if (!MACHINE_HAS_TOPOLOGY)
359 return;
360 if (!(facility_bits & (1ULL << 52)) || !(facility_bits & (1ULL << 61)))
361 return; 324 return;
362 machine_has_topology = 1;
363
364 tl_info = alloc_bootmem_pages(PAGE_SIZE); 325 tl_info = alloc_bootmem_pages(PAGE_SIZE);
365 info = tl_info; 326 info = tl_info;
366 store_topology(info); 327 store_topology(info);
367 pr_info("The CPU configuration topology of the machine is:"); 328 pr_info("The CPU configuration topology of the machine is:");
368 for (i = 0; i < NR_MAG; i++) 329 for (i = 0; i < TOPOLOGY_NR_MAG; i++)
369 printk(" %d", info->mag[i]); 330 printk(" %d", info->mag[i]);
370 printk(" / %d\n", info->mnest); 331 printk(" / %d\n", info->mnest);
371 alloc_masks(info, &core_info, 2); 332 alloc_masks(info, &core_info, 2);
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 5d8f0f3d0250..70640822621a 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -329,27 +329,19 @@ int is_valid_bugaddr(unsigned long addr)
329 return 1; 329 return 1;
330} 330}
331 331
332static void __kprobes inline do_trap(long interruption_code, int signr, 332static inline void __kprobes do_trap(long pgm_int_code, int signr, char *str,
333 char *str, struct pt_regs *regs, 333 struct pt_regs *regs, siginfo_t *info)
334 siginfo_t *info)
335{ 334{
336 /* 335 if (notify_die(DIE_TRAP, str, regs, pgm_int_code,
337 * We got all needed information from the lowcore and can 336 pgm_int_code, signr) == NOTIFY_STOP)
338 * now safely switch on interrupts.
339 */
340 if (regs->psw.mask & PSW_MASK_PSTATE)
341 local_irq_enable();
342
343 if (notify_die(DIE_TRAP, str, regs, interruption_code,
344 interruption_code, signr) == NOTIFY_STOP)
345 return; 337 return;
346 338
347 if (regs->psw.mask & PSW_MASK_PSTATE) { 339 if (regs->psw.mask & PSW_MASK_PSTATE) {
348 struct task_struct *tsk = current; 340 struct task_struct *tsk = current;
349 341
350 tsk->thread.trap_no = interruption_code & 0xffff; 342 tsk->thread.trap_no = pgm_int_code & 0xffff;
351 force_sig_info(signr, info, tsk); 343 force_sig_info(signr, info, tsk);
352 report_user_fault(regs, interruption_code, signr); 344 report_user_fault(regs, pgm_int_code, signr);
353 } else { 345 } else {
354 const struct exception_table_entry *fixup; 346 const struct exception_table_entry *fixup;
355 fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN); 347 fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
@@ -361,14 +353,16 @@ static void __kprobes inline do_trap(long interruption_code, int signr,
361 btt = report_bug(regs->psw.addr & PSW_ADDR_INSN, regs); 353 btt = report_bug(regs->psw.addr & PSW_ADDR_INSN, regs);
362 if (btt == BUG_TRAP_TYPE_WARN) 354 if (btt == BUG_TRAP_TYPE_WARN)
363 return; 355 return;
364 die(str, regs, interruption_code); 356 die(str, regs, pgm_int_code);
365 } 357 }
366 } 358 }
367} 359}
368 360
369static inline void __user *get_check_address(struct pt_regs *regs) 361static inline void __user *get_psw_address(struct pt_regs *regs,
362 long pgm_int_code)
370{ 363{
371 return (void __user *)((regs->psw.addr-S390_lowcore.pgm_ilc) & PSW_ADDR_INSN); 364 return (void __user *)
365 ((regs->psw.addr - (pgm_int_code >> 16)) & PSW_ADDR_INSN);
372} 366}
373 367
374void __kprobes do_single_step(struct pt_regs *regs) 368void __kprobes do_single_step(struct pt_regs *regs)
@@ -381,57 +375,57 @@ void __kprobes do_single_step(struct pt_regs *regs)
381 force_sig(SIGTRAP, current); 375 force_sig(SIGTRAP, current);
382} 376}
383 377
384static void default_trap_handler(struct pt_regs * regs, long interruption_code) 378static void default_trap_handler(struct pt_regs *regs, long pgm_int_code,
379 unsigned long trans_exc_code)
385{ 380{
386 if (regs->psw.mask & PSW_MASK_PSTATE) { 381 if (regs->psw.mask & PSW_MASK_PSTATE) {
387 local_irq_enable(); 382 report_user_fault(regs, pgm_int_code, SIGSEGV);
388 report_user_fault(regs, interruption_code, SIGSEGV);
389 do_exit(SIGSEGV); 383 do_exit(SIGSEGV);
390 } else 384 } else
391 die("Unknown program exception", regs, interruption_code); 385 die("Unknown program exception", regs, pgm_int_code);
392} 386}
393 387
394#define DO_ERROR_INFO(signr, str, name, sicode, siaddr) \ 388#define DO_ERROR_INFO(name, signr, sicode, str) \
395static void name(struct pt_regs * regs, long interruption_code) \ 389static void name(struct pt_regs *regs, long pgm_int_code, \
390 unsigned long trans_exc_code) \
396{ \ 391{ \
397 siginfo_t info; \ 392 siginfo_t info; \
398 info.si_signo = signr; \ 393 info.si_signo = signr; \
399 info.si_errno = 0; \ 394 info.si_errno = 0; \
400 info.si_code = sicode; \ 395 info.si_code = sicode; \
401 info.si_addr = siaddr; \ 396 info.si_addr = get_psw_address(regs, pgm_int_code); \
402 do_trap(interruption_code, signr, str, regs, &info); \ 397 do_trap(pgm_int_code, signr, str, regs, &info); \
403} 398}
404 399
405DO_ERROR_INFO(SIGILL, "addressing exception", addressing_exception, 400DO_ERROR_INFO(addressing_exception, SIGILL, ILL_ILLADR,
406 ILL_ILLADR, get_check_address(regs)) 401 "addressing exception")
407DO_ERROR_INFO(SIGILL, "execute exception", execute_exception, 402DO_ERROR_INFO(execute_exception, SIGILL, ILL_ILLOPN,
408 ILL_ILLOPN, get_check_address(regs)) 403 "execute exception")
409DO_ERROR_INFO(SIGFPE, "fixpoint divide exception", divide_exception, 404DO_ERROR_INFO(divide_exception, SIGFPE, FPE_INTDIV,
410 FPE_INTDIV, get_check_address(regs)) 405 "fixpoint divide exception")
411DO_ERROR_INFO(SIGFPE, "fixpoint overflow exception", overflow_exception, 406DO_ERROR_INFO(overflow_exception, SIGFPE, FPE_INTOVF,
412 FPE_INTOVF, get_check_address(regs)) 407 "fixpoint overflow exception")
413DO_ERROR_INFO(SIGFPE, "HFP overflow exception", hfp_overflow_exception, 408DO_ERROR_INFO(hfp_overflow_exception, SIGFPE, FPE_FLTOVF,
414 FPE_FLTOVF, get_check_address(regs)) 409 "HFP overflow exception")
415DO_ERROR_INFO(SIGFPE, "HFP underflow exception", hfp_underflow_exception, 410DO_ERROR_INFO(hfp_underflow_exception, SIGFPE, FPE_FLTUND,
416 FPE_FLTUND, get_check_address(regs)) 411 "HFP underflow exception")
417DO_ERROR_INFO(SIGFPE, "HFP significance exception", hfp_significance_exception, 412DO_ERROR_INFO(hfp_significance_exception, SIGFPE, FPE_FLTRES,
418 FPE_FLTRES, get_check_address(regs)) 413 "HFP significance exception")
419DO_ERROR_INFO(SIGFPE, "HFP divide exception", hfp_divide_exception, 414DO_ERROR_INFO(hfp_divide_exception, SIGFPE, FPE_FLTDIV,
420 FPE_FLTDIV, get_check_address(regs)) 415 "HFP divide exception")
421DO_ERROR_INFO(SIGFPE, "HFP square root exception", hfp_sqrt_exception, 416DO_ERROR_INFO(hfp_sqrt_exception, SIGFPE, FPE_FLTINV,
422 FPE_FLTINV, get_check_address(regs)) 417 "HFP square root exception")
423DO_ERROR_INFO(SIGILL, "operand exception", operand_exception, 418DO_ERROR_INFO(operand_exception, SIGILL, ILL_ILLOPN,
424 ILL_ILLOPN, get_check_address(regs)) 419 "operand exception")
425DO_ERROR_INFO(SIGILL, "privileged operation", privileged_op, 420DO_ERROR_INFO(privileged_op, SIGILL, ILL_PRVOPC,
426 ILL_PRVOPC, get_check_address(regs)) 421 "privileged operation")
427DO_ERROR_INFO(SIGILL, "special operation exception", special_op_exception, 422DO_ERROR_INFO(special_op_exception, SIGILL, ILL_ILLOPN,
428 ILL_ILLOPN, get_check_address(regs)) 423 "special operation exception")
429DO_ERROR_INFO(SIGILL, "translation exception", translation_exception, 424DO_ERROR_INFO(translation_exception, SIGILL, ILL_ILLOPN,
430 ILL_ILLOPN, get_check_address(regs)) 425 "translation exception")
431 426
432static inline void 427static inline void do_fp_trap(struct pt_regs *regs, void __user *location,
433do_fp_trap(struct pt_regs *regs, void __user *location, 428 int fpc, long pgm_int_code)
434 int fpc, long interruption_code)
435{ 429{
436 siginfo_t si; 430 siginfo_t si;
437 431
@@ -453,26 +447,19 @@ do_fp_trap(struct pt_regs *regs, void __user *location,
453 else if (fpc & 0x0800) /* inexact */ 447 else if (fpc & 0x0800) /* inexact */
454 si.si_code = FPE_FLTRES; 448 si.si_code = FPE_FLTRES;
455 } 449 }
456 current->thread.ieee_instruction_pointer = (addr_t) location; 450 do_trap(pgm_int_code, SIGFPE,
457 do_trap(interruption_code, SIGFPE,
458 "floating point exception", regs, &si); 451 "floating point exception", regs, &si);
459} 452}
460 453
461static void illegal_op(struct pt_regs * regs, long interruption_code) 454static void illegal_op(struct pt_regs *regs, long pgm_int_code,
455 unsigned long trans_exc_code)
462{ 456{
463 siginfo_t info; 457 siginfo_t info;
464 __u8 opcode[6]; 458 __u8 opcode[6];
465 __u16 __user *location; 459 __u16 __user *location;
466 int signal = 0; 460 int signal = 0;
467 461
468 location = get_check_address(regs); 462 location = get_psw_address(regs, pgm_int_code);
469
470 /*
471 * We got all needed information from the lowcore and can
472 * now safely switch on interrupts.
473 */
474 if (regs->psw.mask & PSW_MASK_PSTATE)
475 local_irq_enable();
476 463
477 if (regs->psw.mask & PSW_MASK_PSTATE) { 464 if (regs->psw.mask & PSW_MASK_PSTATE) {
478 if (get_user(*((__u16 *) opcode), (__u16 __user *) location)) 465 if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
@@ -512,7 +499,7 @@ static void illegal_op(struct pt_regs * regs, long interruption_code)
512 * If we get an illegal op in kernel mode, send it through the 499 * If we get an illegal op in kernel mode, send it through the
513 * kprobes notifier. If kprobes doesn't pick it up, SIGILL 500 * kprobes notifier. If kprobes doesn't pick it up, SIGILL
514 */ 501 */
515 if (notify_die(DIE_BPT, "bpt", regs, interruption_code, 502 if (notify_die(DIE_BPT, "bpt", regs, pgm_int_code,
516 3, SIGTRAP) != NOTIFY_STOP) 503 3, SIGTRAP) != NOTIFY_STOP)
517 signal = SIGILL; 504 signal = SIGILL;
518 } 505 }
@@ -520,13 +507,13 @@ static void illegal_op(struct pt_regs * regs, long interruption_code)
520#ifdef CONFIG_MATHEMU 507#ifdef CONFIG_MATHEMU
521 if (signal == SIGFPE) 508 if (signal == SIGFPE)
522 do_fp_trap(regs, location, 509 do_fp_trap(regs, location,
523 current->thread.fp_regs.fpc, interruption_code); 510 current->thread.fp_regs.fpc, pgm_int_code);
524 else if (signal == SIGSEGV) { 511 else if (signal == SIGSEGV) {
525 info.si_signo = signal; 512 info.si_signo = signal;
526 info.si_errno = 0; 513 info.si_errno = 0;
527 info.si_code = SEGV_MAPERR; 514 info.si_code = SEGV_MAPERR;
528 info.si_addr = (void __user *) location; 515 info.si_addr = (void __user *) location;
529 do_trap(interruption_code, signal, 516 do_trap(pgm_int_code, signal,
530 "user address fault", regs, &info); 517 "user address fault", regs, &info);
531 } else 518 } else
532#endif 519#endif
@@ -535,28 +522,22 @@ static void illegal_op(struct pt_regs * regs, long interruption_code)
535 info.si_errno = 0; 522 info.si_errno = 0;
536 info.si_code = ILL_ILLOPC; 523 info.si_code = ILL_ILLOPC;
537 info.si_addr = (void __user *) location; 524 info.si_addr = (void __user *) location;
538 do_trap(interruption_code, signal, 525 do_trap(pgm_int_code, signal,
539 "illegal operation", regs, &info); 526 "illegal operation", regs, &info);
540 } 527 }
541} 528}
542 529
543 530
544#ifdef CONFIG_MATHEMU 531#ifdef CONFIG_MATHEMU
545asmlinkage void 532asmlinkage void specification_exception(struct pt_regs *regs,
546specification_exception(struct pt_regs * regs, long interruption_code) 533 long pgm_int_code,
534 unsigned long trans_exc_code)
547{ 535{
548 __u8 opcode[6]; 536 __u8 opcode[6];
549 __u16 __user *location = NULL; 537 __u16 __user *location = NULL;
550 int signal = 0; 538 int signal = 0;
551 539
552 location = (__u16 __user *) get_check_address(regs); 540 location = (__u16 __user *) get_psw_address(regs, pgm_int_code);
553
554 /*
555 * We got all needed information from the lowcore and can
556 * now safely switch on interrupts.
557 */
558 if (regs->psw.mask & PSW_MASK_PSTATE)
559 local_irq_enable();
560 541
561 if (regs->psw.mask & PSW_MASK_PSTATE) { 542 if (regs->psw.mask & PSW_MASK_PSTATE) {
562 get_user(*((__u16 *) opcode), location); 543 get_user(*((__u16 *) opcode), location);
@@ -592,35 +573,29 @@ specification_exception(struct pt_regs * regs, long interruption_code)
592 573
593 if (signal == SIGFPE) 574 if (signal == SIGFPE)
594 do_fp_trap(regs, location, 575 do_fp_trap(regs, location,
595 current->thread.fp_regs.fpc, interruption_code); 576 current->thread.fp_regs.fpc, pgm_int_code);
596 else if (signal) { 577 else if (signal) {
597 siginfo_t info; 578 siginfo_t info;
598 info.si_signo = signal; 579 info.si_signo = signal;
599 info.si_errno = 0; 580 info.si_errno = 0;
600 info.si_code = ILL_ILLOPN; 581 info.si_code = ILL_ILLOPN;
601 info.si_addr = location; 582 info.si_addr = location;
602 do_trap(interruption_code, signal, 583 do_trap(pgm_int_code, signal,
603 "specification exception", regs, &info); 584 "specification exception", regs, &info);
604 } 585 }
605} 586}
606#else 587#else
607DO_ERROR_INFO(SIGILL, "specification exception", specification_exception, 588DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN,
608 ILL_ILLOPN, get_check_address(regs)); 589 "specification exception");
609#endif 590#endif
610 591
611static void data_exception(struct pt_regs * regs, long interruption_code) 592static void data_exception(struct pt_regs *regs, long pgm_int_code,
593 unsigned long trans_exc_code)
612{ 594{
613 __u16 __user *location; 595 __u16 __user *location;
614 int signal = 0; 596 int signal = 0;
615 597
616 location = get_check_address(regs); 598 location = get_psw_address(regs, pgm_int_code);
617
618 /*
619 * We got all needed information from the lowcore and can
620 * now safely switch on interrupts.
621 */
622 if (regs->psw.mask & PSW_MASK_PSTATE)
623 local_irq_enable();
624 599
625 if (MACHINE_HAS_IEEE) 600 if (MACHINE_HAS_IEEE)
626 asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc)); 601 asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc));
@@ -686,19 +661,19 @@ static void data_exception(struct pt_regs * regs, long interruption_code)
686 signal = SIGILL; 661 signal = SIGILL;
687 if (signal == SIGFPE) 662 if (signal == SIGFPE)
688 do_fp_trap(regs, location, 663 do_fp_trap(regs, location,
689 current->thread.fp_regs.fpc, interruption_code); 664 current->thread.fp_regs.fpc, pgm_int_code);
690 else if (signal) { 665 else if (signal) {
691 siginfo_t info; 666 siginfo_t info;
692 info.si_signo = signal; 667 info.si_signo = signal;
693 info.si_errno = 0; 668 info.si_errno = 0;
694 info.si_code = ILL_ILLOPN; 669 info.si_code = ILL_ILLOPN;
695 info.si_addr = location; 670 info.si_addr = location;
696 do_trap(interruption_code, signal, 671 do_trap(pgm_int_code, signal, "data exception", regs, &info);
697 "data exception", regs, &info);
698 } 672 }
699} 673}
700 674
701static void space_switch_exception(struct pt_regs * regs, long int_code) 675static void space_switch_exception(struct pt_regs *regs, long pgm_int_code,
676 unsigned long trans_exc_code)
702{ 677{
703 siginfo_t info; 678 siginfo_t info;
704 679
@@ -709,8 +684,8 @@ static void space_switch_exception(struct pt_regs * regs, long int_code)
709 info.si_signo = SIGILL; 684 info.si_signo = SIGILL;
710 info.si_errno = 0; 685 info.si_errno = 0;
711 info.si_code = ILL_PRVOPC; 686 info.si_code = ILL_PRVOPC;
712 info.si_addr = get_check_address(regs); 687 info.si_addr = get_psw_address(regs, pgm_int_code);
713 do_trap(int_code, SIGILL, "space switch event", regs, &info); 688 do_trap(pgm_int_code, SIGILL, "space switch event", regs, &info);
714} 689}
715 690
716asmlinkage void kernel_stack_overflow(struct pt_regs * regs) 691asmlinkage void kernel_stack_overflow(struct pt_regs * regs)
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index 6b83870507d5..e3150dd2fe74 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -84,11 +84,7 @@ struct vdso_data *vdso_data = &vdso_data_store.data;
84 */ 84 */
85static void vdso_init_data(struct vdso_data *vd) 85static void vdso_init_data(struct vdso_data *vd)
86{ 86{
87 unsigned int facility_list; 87 vd->ectg_available = user_mode != HOME_SPACE_MODE && test_facility(31);
88
89 facility_list = stfl();
90 vd->ectg_available =
91 user_mode != HOME_SPACE_MODE && (facility_list & 1);
92} 88}
93 89
94#ifdef CONFIG_64BIT 90#ifdef CONFIG_64BIT
diff --git a/arch/s390/kernel/vdso32/clock_getres.S b/arch/s390/kernel/vdso32/clock_getres.S
index 9532c4e6a9d2..36aaa25d05da 100644
--- a/arch/s390/kernel/vdso32/clock_getres.S
+++ b/arch/s390/kernel/vdso32/clock_getres.S
@@ -19,9 +19,9 @@
19 .type __kernel_clock_getres,@function 19 .type __kernel_clock_getres,@function
20__kernel_clock_getres: 20__kernel_clock_getres:
21 .cfi_startproc 21 .cfi_startproc
22 chi %r2,CLOCK_REALTIME 22 chi %r2,__CLOCK_REALTIME
23 je 0f 23 je 0f
24 chi %r2,CLOCK_MONOTONIC 24 chi %r2,__CLOCK_MONOTONIC
25 jne 3f 25 jne 3f
260: ltr %r3,%r3 260: ltr %r3,%r3
27 jz 2f /* res == NULL */ 27 jz 2f /* res == NULL */
@@ -34,6 +34,6 @@ __kernel_clock_getres:
343: lhi %r1,__NR_clock_getres /* fallback to svc */ 343: lhi %r1,__NR_clock_getres /* fallback to svc */
35 svc 0 35 svc 0
36 br %r14 36 br %r14
374: .long CLOCK_REALTIME_RES 374: .long __CLOCK_REALTIME_RES
38 .cfi_endproc 38 .cfi_endproc
39 .size __kernel_clock_getres,.-__kernel_clock_getres 39 .size __kernel_clock_getres,.-__kernel_clock_getres
diff --git a/arch/s390/kernel/vdso32/clock_gettime.S b/arch/s390/kernel/vdso32/clock_gettime.S
index 969643954273..b2224e0b974c 100644
--- a/arch/s390/kernel/vdso32/clock_gettime.S
+++ b/arch/s390/kernel/vdso32/clock_gettime.S
@@ -21,9 +21,9 @@ __kernel_clock_gettime:
21 .cfi_startproc 21 .cfi_startproc
22 basr %r5,0 22 basr %r5,0
230: al %r5,21f-0b(%r5) /* get &_vdso_data */ 230: al %r5,21f-0b(%r5) /* get &_vdso_data */
24 chi %r2,CLOCK_REALTIME 24 chi %r2,__CLOCK_REALTIME
25 je 10f 25 je 10f
26 chi %r2,CLOCK_MONOTONIC 26 chi %r2,__CLOCK_MONOTONIC
27 jne 19f 27 jne 19f
28 28
29 /* CLOCK_MONOTONIC */ 29 /* CLOCK_MONOTONIC */
diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S
index 9ce8caafdb4e..176e1f75f9aa 100644
--- a/arch/s390/kernel/vdso64/clock_getres.S
+++ b/arch/s390/kernel/vdso64/clock_getres.S
@@ -19,9 +19,9 @@
19 .type __kernel_clock_getres,@function 19 .type __kernel_clock_getres,@function
20__kernel_clock_getres: 20__kernel_clock_getres:
21 .cfi_startproc 21 .cfi_startproc
22 cghi %r2,CLOCK_REALTIME 22 cghi %r2,__CLOCK_REALTIME
23 je 0f 23 je 0f
24 cghi %r2,CLOCK_MONOTONIC 24 cghi %r2,__CLOCK_MONOTONIC
25 je 0f 25 je 0f
26 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ 26 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */
27 jne 2f 27 jne 2f
@@ -39,6 +39,6 @@ __kernel_clock_getres:
392: lghi %r1,__NR_clock_getres /* fallback to svc */ 392: lghi %r1,__NR_clock_getres /* fallback to svc */
40 svc 0 40 svc 0
41 br %r14 41 br %r14
423: .quad CLOCK_REALTIME_RES 423: .quad __CLOCK_REALTIME_RES
43 .cfi_endproc 43 .cfi_endproc
44 .size __kernel_clock_getres,.-__kernel_clock_getres 44 .size __kernel_clock_getres,.-__kernel_clock_getres
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
index f40467884a03..d46c95ed5f19 100644
--- a/arch/s390/kernel/vdso64/clock_gettime.S
+++ b/arch/s390/kernel/vdso64/clock_gettime.S
@@ -20,11 +20,11 @@
20__kernel_clock_gettime: 20__kernel_clock_gettime:
21 .cfi_startproc 21 .cfi_startproc
22 larl %r5,_vdso_data 22 larl %r5,_vdso_data
23 cghi %r2,CLOCK_REALTIME 23 cghi %r2,__CLOCK_REALTIME
24 je 4f 24 je 4f
25 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ 25 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */
26 je 9f 26 je 9f
27 cghi %r2,CLOCK_MONOTONIC 27 cghi %r2,__CLOCK_MONOTONIC
28 jne 12f 28 jne 12f
29 29
30 /* CLOCK_MONOTONIC */ 30 /* CLOCK_MONOTONIC */
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 3479f1b0d4e0..56c8687b29b3 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -314,7 +314,8 @@ static void do_callbacks(struct list_head *cb_list)
314/* 314/*
315 * Handler for the virtual CPU timer. 315 * Handler for the virtual CPU timer.
316 */ 316 */
317static void do_cpu_timer_interrupt(__u16 error_code) 317static void do_cpu_timer_interrupt(unsigned int ext_int_code,
318 unsigned int param32, unsigned long param64)
318{ 319{
319 struct vtimer_queue *vq; 320 struct vtimer_queue *vq;
320 struct vtimer_list *event, *tmp; 321 struct vtimer_list *event, *tmp;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 4fe68650535c..985d825494f1 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -740,8 +740,8 @@ static int __init kvm_s390_init(void)
740 kvm_exit(); 740 kvm_exit();
741 return -ENOMEM; 741 return -ENOMEM;
742 } 742 }
743 stfle(facilities, 1); 743 memcpy(facilities, S390_lowcore.stfle_fac_list, 16);
744 facilities[0] &= 0xff00fff3f0700000ULL; 744 facilities[0] &= 0xff00fff3f47c0000ULL;
745 return 0; 745 return 0;
746} 746}
747 747
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 44205507717c..9194a4b52b22 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -154,12 +154,12 @@ static int handle_chsc(struct kvm_vcpu *vcpu)
154 154
155static int handle_stfl(struct kvm_vcpu *vcpu) 155static int handle_stfl(struct kvm_vcpu *vcpu)
156{ 156{
157 unsigned int facility_list = stfl(); 157 unsigned int facility_list;
158 int rc; 158 int rc;
159 159
160 vcpu->stat.instruction_stfl++; 160 vcpu->stat.instruction_stfl++;
161 /* only pass the facility bits, which we can handle */ 161 /* only pass the facility bits, which we can handle */
162 facility_list &= 0xff00fff3; 162 facility_list = S390_lowcore.stfl_fac_list & 0xff00fff3;
163 163
164 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list), 164 rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list),
165 &facility_list, sizeof(facility_list)); 165 &facility_list, sizeof(facility_list));
diff --git a/arch/s390/mm/Makefile b/arch/s390/mm/Makefile
index eec054484419..6fbc6f3fbdf2 100644
--- a/arch/s390/mm/Makefile
+++ b/arch/s390/mm/Makefile
@@ -3,6 +3,6 @@
3# 3#
4 4
5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o maccess.o \ 5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o maccess.o \
6 page-states.o 6 page-states.o gup.o
7obj-$(CONFIG_CMM) += cmm.o 7obj-$(CONFIG_CMM) += cmm.o
8obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 8obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index a9550dca3e4b..c66ffd8dbbb7 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -23,7 +23,10 @@
23#include <asm/pgalloc.h> 23#include <asm/pgalloc.h>
24#include <asm/diag.h> 24#include <asm/diag.h>
25 25
26static char *sender = "VMRMSVM"; 26#ifdef CONFIG_CMM_IUCV
27static char *cmm_default_sender = "VMRMSVM";
28#endif
29static char *sender;
27module_param(sender, charp, 0400); 30module_param(sender, charp, 0400);
28MODULE_PARM_DESC(sender, 31MODULE_PARM_DESC(sender,
29 "Guest name that may send SMSG messages (default VMRMSVM)"); 32 "Guest name that may send SMSG messages (default VMRMSVM)");
@@ -440,6 +443,8 @@ static int __init cmm_init(void)
440 int len = strlen(sender); 443 int len = strlen(sender);
441 while (len--) 444 while (len--)
442 sender[len] = toupper(sender[len]); 445 sender[len] = toupper(sender[len]);
446 } else {
447 sender = cmm_default_sender;
443 } 448 }
444 449
445 rc = smsg_register_callback(SMSG_PREFIX, cmm_smsg_target); 450 rc = smsg_register_callback(SMSG_PREFIX, cmm_smsg_target);
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 2505b2ea0ef1..fe5701e9efbf 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -52,6 +52,14 @@
52#define VM_FAULT_BADMAP 0x020000 52#define VM_FAULT_BADMAP 0x020000
53#define VM_FAULT_BADACCESS 0x040000 53#define VM_FAULT_BADACCESS 0x040000
54 54
55static unsigned long store_indication;
56
57void fault_init(void)
58{
59 if (test_facility(2) && test_facility(75))
60 store_indication = 0xc00;
61}
62
55static inline int notify_page_fault(struct pt_regs *regs) 63static inline int notify_page_fault(struct pt_regs *regs)
56{ 64{
57 int ret = 0; 65 int ret = 0;
@@ -199,14 +207,21 @@ static noinline void do_sigbus(struct pt_regs *regs, long int_code,
199 unsigned long trans_exc_code) 207 unsigned long trans_exc_code)
200{ 208{
201 struct task_struct *tsk = current; 209 struct task_struct *tsk = current;
210 unsigned long address;
211 struct siginfo si;
202 212
203 /* 213 /*
204 * Send a sigbus, regardless of whether we were in kernel 214 * Send a sigbus, regardless of whether we were in kernel
205 * or user mode. 215 * or user mode.
206 */ 216 */
207 tsk->thread.prot_addr = trans_exc_code & __FAIL_ADDR_MASK; 217 address = trans_exc_code & __FAIL_ADDR_MASK;
218 tsk->thread.prot_addr = address;
208 tsk->thread.trap_no = int_code; 219 tsk->thread.trap_no = int_code;
209 force_sig(SIGBUS, tsk); 220 si.si_signo = SIGBUS;
221 si.si_errno = 0;
222 si.si_code = BUS_ADRERR;
223 si.si_addr = (void __user *) address;
224 force_sig_info(SIGBUS, &si, tsk);
210} 225}
211 226
212#ifdef CONFIG_S390_EXEC_PROTECT 227#ifdef CONFIG_S390_EXEC_PROTECT
@@ -266,10 +281,11 @@ static noinline void do_fault_error(struct pt_regs *regs, long int_code,
266 if (fault & VM_FAULT_OOM) 281 if (fault & VM_FAULT_OOM)
267 pagefault_out_of_memory(); 282 pagefault_out_of_memory();
268 else if (fault & VM_FAULT_SIGBUS) { 283 else if (fault & VM_FAULT_SIGBUS) {
269 do_sigbus(regs, int_code, trans_exc_code);
270 /* Kernel mode? Handle exceptions or die */ 284 /* Kernel mode? Handle exceptions or die */
271 if (!(regs->psw.mask & PSW_MASK_PSTATE)) 285 if (!(regs->psw.mask & PSW_MASK_PSTATE))
272 do_no_context(regs, int_code, trans_exc_code); 286 do_no_context(regs, int_code, trans_exc_code);
287 else
288 do_sigbus(regs, int_code, trans_exc_code);
273 } else 289 } else
274 BUG(); 290 BUG();
275 break; 291 break;
@@ -294,7 +310,7 @@ static inline int do_exception(struct pt_regs *regs, int access,
294 struct mm_struct *mm; 310 struct mm_struct *mm;
295 struct vm_area_struct *vma; 311 struct vm_area_struct *vma;
296 unsigned long address; 312 unsigned long address;
297 int fault; 313 int fault, write;
298 314
299 if (notify_page_fault(regs)) 315 if (notify_page_fault(regs))
300 return 0; 316 return 0;
@@ -312,12 +328,6 @@ static inline int do_exception(struct pt_regs *regs, int access,
312 goto out; 328 goto out;
313 329
314 address = trans_exc_code & __FAIL_ADDR_MASK; 330 address = trans_exc_code & __FAIL_ADDR_MASK;
315 /*
316 * When we get here, the fault happened in the current
317 * task's user address space, so we can switch on the
318 * interrupts again and then search the VMAs
319 */
320 local_irq_enable();
321 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address); 331 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, address);
322 down_read(&mm->mmap_sem); 332 down_read(&mm->mmap_sem);
323 333
@@ -348,8 +358,10 @@ static inline int do_exception(struct pt_regs *regs, int access,
348 * make sure we exit gracefully rather than endlessly redo 358 * make sure we exit gracefully rather than endlessly redo
349 * the fault. 359 * the fault.
350 */ 360 */
351 fault = handle_mm_fault(mm, vma, address, 361 write = (access == VM_WRITE ||
352 (access == VM_WRITE) ? FAULT_FLAG_WRITE : 0); 362 (trans_exc_code & store_indication) == 0x400) ?
363 FAULT_FLAG_WRITE : 0;
364 fault = handle_mm_fault(mm, vma, address, write);
353 if (unlikely(fault & VM_FAULT_ERROR)) 365 if (unlikely(fault & VM_FAULT_ERROR))
354 goto out_up; 366 goto out_up;
355 367
@@ -374,20 +386,20 @@ out:
374 return fault; 386 return fault;
375} 387}
376 388
377void __kprobes do_protection_exception(struct pt_regs *regs, long int_code) 389void __kprobes do_protection_exception(struct pt_regs *regs, long pgm_int_code,
390 unsigned long trans_exc_code)
378{ 391{
379 unsigned long trans_exc_code = S390_lowcore.trans_exc_code;
380 int fault; 392 int fault;
381 393
382 /* Protection exception is supressing, decrement psw address. */ 394 /* Protection exception is supressing, decrement psw address. */
383 regs->psw.addr -= (int_code >> 16); 395 regs->psw.addr -= (pgm_int_code >> 16);
384 /* 396 /*
385 * Check for low-address protection. This needs to be treated 397 * Check for low-address protection. This needs to be treated
386 * as a special case because the translation exception code 398 * as a special case because the translation exception code
387 * field is not guaranteed to contain valid data in this case. 399 * field is not guaranteed to contain valid data in this case.
388 */ 400 */
389 if (unlikely(!(trans_exc_code & 4))) { 401 if (unlikely(!(trans_exc_code & 4))) {
390 do_low_address(regs, int_code, trans_exc_code); 402 do_low_address(regs, pgm_int_code, trans_exc_code);
391 return; 403 return;
392 } 404 }
393 fault = do_exception(regs, VM_WRITE, trans_exc_code); 405 fault = do_exception(regs, VM_WRITE, trans_exc_code);
@@ -395,9 +407,9 @@ void __kprobes do_protection_exception(struct pt_regs *regs, long int_code)
395 do_fault_error(regs, 4, trans_exc_code, fault); 407 do_fault_error(regs, 4, trans_exc_code, fault);
396} 408}
397 409
398void __kprobes do_dat_exception(struct pt_regs *regs, long int_code) 410void __kprobes do_dat_exception(struct pt_regs *regs, long pgm_int_code,
411 unsigned long trans_exc_code)
399{ 412{
400 unsigned long trans_exc_code = S390_lowcore.trans_exc_code;
401 int access, fault; 413 int access, fault;
402 414
403 access = VM_READ | VM_EXEC | VM_WRITE; 415 access = VM_READ | VM_EXEC | VM_WRITE;
@@ -408,21 +420,19 @@ void __kprobes do_dat_exception(struct pt_regs *regs, long int_code)
408#endif 420#endif
409 fault = do_exception(regs, access, trans_exc_code); 421 fault = do_exception(regs, access, trans_exc_code);
410 if (unlikely(fault)) 422 if (unlikely(fault))
411 do_fault_error(regs, int_code & 255, trans_exc_code, fault); 423 do_fault_error(regs, pgm_int_code & 255, trans_exc_code, fault);
412} 424}
413 425
414#ifdef CONFIG_64BIT 426#ifdef CONFIG_64BIT
415void __kprobes do_asce_exception(struct pt_regs *regs, long int_code) 427void __kprobes do_asce_exception(struct pt_regs *regs, long pgm_int_code,
428 unsigned long trans_exc_code)
416{ 429{
417 unsigned long trans_exc_code = S390_lowcore.trans_exc_code;
418 struct mm_struct *mm = current->mm; 430 struct mm_struct *mm = current->mm;
419 struct vm_area_struct *vma; 431 struct vm_area_struct *vma;
420 432
421 if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm)) 433 if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm))
422 goto no_context; 434 goto no_context;
423 435
424 local_irq_enable();
425
426 down_read(&mm->mmap_sem); 436 down_read(&mm->mmap_sem);
427 vma = find_vma(mm, trans_exc_code & __FAIL_ADDR_MASK); 437 vma = find_vma(mm, trans_exc_code & __FAIL_ADDR_MASK);
428 up_read(&mm->mmap_sem); 438 up_read(&mm->mmap_sem);
@@ -434,16 +444,16 @@ void __kprobes do_asce_exception(struct pt_regs *regs, long int_code)
434 444
435 /* User mode accesses just cause a SIGSEGV */ 445 /* User mode accesses just cause a SIGSEGV */
436 if (regs->psw.mask & PSW_MASK_PSTATE) { 446 if (regs->psw.mask & PSW_MASK_PSTATE) {
437 do_sigsegv(regs, int_code, SEGV_MAPERR, trans_exc_code); 447 do_sigsegv(regs, pgm_int_code, SEGV_MAPERR, trans_exc_code);
438 return; 448 return;
439 } 449 }
440 450
441no_context: 451no_context:
442 do_no_context(regs, int_code, trans_exc_code); 452 do_no_context(regs, pgm_int_code, trans_exc_code);
443} 453}
444#endif 454#endif
445 455
446int __handle_fault(unsigned long uaddr, unsigned long int_code, int write_user) 456int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
447{ 457{
448 struct pt_regs regs; 458 struct pt_regs regs;
449 int access, fault; 459 int access, fault;
@@ -454,14 +464,14 @@ int __handle_fault(unsigned long uaddr, unsigned long int_code, int write_user)
454 regs.psw.addr = (unsigned long) __builtin_return_address(0); 464 regs.psw.addr = (unsigned long) __builtin_return_address(0);
455 regs.psw.addr |= PSW_ADDR_AMODE; 465 regs.psw.addr |= PSW_ADDR_AMODE;
456 uaddr &= PAGE_MASK; 466 uaddr &= PAGE_MASK;
457 access = write_user ? VM_WRITE : VM_READ; 467 access = write ? VM_WRITE : VM_READ;
458 fault = do_exception(&regs, access, uaddr | 2); 468 fault = do_exception(&regs, access, uaddr | 2);
459 if (unlikely(fault)) { 469 if (unlikely(fault)) {
460 if (fault & VM_FAULT_OOM) { 470 if (fault & VM_FAULT_OOM) {
461 pagefault_out_of_memory(); 471 pagefault_out_of_memory();
462 fault = 0; 472 fault = 0;
463 } else if (fault & VM_FAULT_SIGBUS) 473 } else if (fault & VM_FAULT_SIGBUS)
464 do_sigbus(&regs, int_code, uaddr); 474 do_sigbus(&regs, pgm_int_code, uaddr);
465 } 475 }
466 return fault ? -EFAULT : 0; 476 return fault ? -EFAULT : 0;
467} 477}
@@ -527,7 +537,8 @@ void pfault_fini(void)
527 : : "a" (&refbk), "m" (refbk) : "cc"); 537 : : "a" (&refbk), "m" (refbk) : "cc");
528} 538}
529 539
530static void pfault_interrupt(__u16 int_code) 540static void pfault_interrupt(unsigned int ext_int_code,
541 unsigned int param32, unsigned long param64)
531{ 542{
532 struct task_struct *tsk; 543 struct task_struct *tsk;
533 __u16 subcode; 544 __u16 subcode;
@@ -538,14 +549,18 @@ static void pfault_interrupt(__u16 int_code)
538 * in the 'cpu address' field associated with the 549 * in the 'cpu address' field associated with the
539 * external interrupt. 550 * external interrupt.
540 */ 551 */
541 subcode = S390_lowcore.cpu_addr; 552 subcode = ext_int_code >> 16;
542 if ((subcode & 0xff00) != __SUBCODE_MASK) 553 if ((subcode & 0xff00) != __SUBCODE_MASK)
543 return; 554 return;
544 555
545 /* 556 /*
546 * Get the token (= address of the task structure of the affected task). 557 * Get the token (= address of the task structure of the affected task).
547 */ 558 */
548 tsk = *(struct task_struct **) __LC_PFAULT_INTPARM; 559#ifdef CONFIG_64BIT
560 tsk = *(struct task_struct **) param64;
561#else
562 tsk = *(struct task_struct **) param32;
563#endif
549 564
550 if (subcode & 0x0080) { 565 if (subcode & 0x0080) {
551 /* signal bit is set -> a page has been swapped in by VM */ 566 /* signal bit is set -> a page has been swapped in by VM */
diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
new file mode 100644
index 000000000000..38e641cdd977
--- /dev/null
+++ b/arch/s390/mm/gup.c
@@ -0,0 +1,225 @@
1/*
2 * Lockless get_user_pages_fast for s390
3 *
4 * Copyright IBM Corp. 2010
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 */
7#include <linux/sched.h>
8#include <linux/mm.h>
9#include <linux/hugetlb.h>
10#include <linux/vmstat.h>
11#include <linux/pagemap.h>
12#include <linux/rwsem.h>
13#include <asm/pgtable.h>
14
15/*
16 * The performance critical leaf functions are made noinline otherwise gcc
17 * inlines everything into a single function which results in too much
18 * register pressure.
19 */
20static inline int gup_pte_range(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
21 unsigned long end, int write, struct page **pages, int *nr)
22{
23 unsigned long mask, result;
24 pte_t *ptep, pte;
25 struct page *page;
26
27 result = write ? 0 : _PAGE_RO;
28 mask = result | _PAGE_INVALID | _PAGE_SPECIAL;
29
30 ptep = ((pte_t *) pmd_deref(pmd)) + pte_index(addr);
31 do {
32 pte = *ptep;
33 barrier();
34 if ((pte_val(pte) & mask) != result)
35 return 0;
36 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
37 page = pte_page(pte);
38 if (!page_cache_get_speculative(page))
39 return 0;
40 if (unlikely(pte_val(pte) != pte_val(*ptep))) {
41 put_page(page);
42 return 0;
43 }
44 pages[*nr] = page;
45 (*nr)++;
46
47 } while (ptep++, addr += PAGE_SIZE, addr != end);
48
49 return 1;
50}
51
52static inline int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
53 unsigned long end, int write, struct page **pages, int *nr)
54{
55 unsigned long mask, result;
56 struct page *head, *page;
57 int refs;
58
59 result = write ? 0 : _SEGMENT_ENTRY_RO;
60 mask = result | _SEGMENT_ENTRY_INV;
61 if ((pmd_val(pmd) & mask) != result)
62 return 0;
63 VM_BUG_ON(!pfn_valid(pmd_val(pmd) >> PAGE_SHIFT));
64
65 refs = 0;
66 head = pmd_page(pmd);
67 page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
68 do {
69 VM_BUG_ON(compound_head(page) != head);
70 pages[*nr] = page;
71 (*nr)++;
72 page++;
73 refs++;
74 } while (addr += PAGE_SIZE, addr != end);
75
76 if (!page_cache_add_speculative(head, refs)) {
77 *nr -= refs;
78 return 0;
79 }
80
81 if (unlikely(pmd_val(pmd) != pmd_val(*pmdp))) {
82 *nr -= refs;
83 while (refs--)
84 put_page(head);
85 }
86
87 return 1;
88}
89
90
91static inline int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr,
92 unsigned long end, int write, struct page **pages, int *nr)
93{
94 unsigned long next;
95 pmd_t *pmdp, pmd;
96
97 pmdp = (pmd_t *) pudp;
98#ifdef CONFIG_64BIT
99 if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
100 pmdp = (pmd_t *) pud_deref(pud);
101 pmdp += pmd_index(addr);
102#endif
103 do {
104 pmd = *pmdp;
105 barrier();
106 next = pmd_addr_end(addr, end);
107 if (pmd_none(pmd))
108 return 0;
109 if (unlikely(pmd_huge(pmd))) {
110 if (!gup_huge_pmd(pmdp, pmd, addr, next,
111 write, pages, nr))
112 return 0;
113 } else if (!gup_pte_range(pmdp, pmd, addr, next,
114 write, pages, nr))
115 return 0;
116 } while (pmdp++, addr = next, addr != end);
117
118 return 1;
119}
120
121static inline int gup_pud_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr,
122 unsigned long end, int write, struct page **pages, int *nr)
123{
124 unsigned long next;
125 pud_t *pudp, pud;
126
127 pudp = (pud_t *) pgdp;
128#ifdef CONFIG_64BIT
129 if ((pgd_val(pgd) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R2)
130 pudp = (pud_t *) pgd_deref(pgd);
131 pudp += pud_index(addr);
132#endif
133 do {
134 pud = *pudp;
135 barrier();
136 next = pud_addr_end(addr, end);
137 if (pud_none(pud))
138 return 0;
139 if (!gup_pmd_range(pudp, pud, addr, next, write, pages, nr))
140 return 0;
141 } while (pudp++, addr = next, addr != end);
142
143 return 1;
144}
145
146/**
147 * get_user_pages_fast() - pin user pages in memory
148 * @start: starting user address
149 * @nr_pages: number of pages from start to pin
150 * @write: whether pages will be written to
151 * @pages: array that receives pointers to the pages pinned.
152 * Should be at least nr_pages long.
153 *
154 * Attempt to pin user pages in memory without taking mm->mmap_sem.
155 * If not successful, it will fall back to taking the lock and
156 * calling get_user_pages().
157 *
158 * Returns number of pages pinned. This may be fewer than the number
159 * requested. If nr_pages is 0 or negative, returns 0. If no pages
160 * were pinned, returns -errno.
161 */
162int get_user_pages_fast(unsigned long start, int nr_pages, int write,
163 struct page **pages)
164{
165 struct mm_struct *mm = current->mm;
166 unsigned long addr, len, end;
167 unsigned long next;
168 pgd_t *pgdp, pgd;
169 int nr = 0;
170
171 start &= PAGE_MASK;
172 addr = start;
173 len = (unsigned long) nr_pages << PAGE_SHIFT;
174 end = start + len;
175 if (end < start)
176 goto slow_irqon;
177
178 /*
179 * local_irq_disable() doesn't prevent pagetable teardown, but does
180 * prevent the pagetables from being freed on s390.
181 *
182 * So long as we atomically load page table pointers versus teardown,
183 * we can follow the address down to the the page and take a ref on it.
184 */
185 local_irq_disable();
186 pgdp = pgd_offset(mm, addr);
187 do {
188 pgd = *pgdp;
189 barrier();
190 next = pgd_addr_end(addr, end);
191 if (pgd_none(pgd))
192 goto slow;
193 if (!gup_pud_range(pgdp, pgd, addr, next, write, pages, &nr))
194 goto slow;
195 } while (pgdp++, addr = next, addr != end);
196 local_irq_enable();
197
198 VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT);
199 return nr;
200
201 {
202 int ret;
203slow:
204 local_irq_enable();
205slow_irqon:
206 /* Try to get the remaining pages with get_user_pages */
207 start += nr << PAGE_SHIFT;
208 pages += nr;
209
210 down_read(&mm->mmap_sem);
211 ret = get_user_pages(current, mm, start,
212 (end - start) >> PAGE_SHIFT, write, 0, pages, NULL);
213 up_read(&mm->mmap_sem);
214
215 /* Have to be a bit careful with return values */
216 if (nr > 0) {
217 if (ret < 0)
218 ret = nr;
219 else
220 ret += nr;
221 }
222
223 return ret;
224 }
225}
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index f28c43d2f61d..639cd21f2218 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -68,7 +68,7 @@ void arch_release_hugepage(struct page *page)
68 ptep = (pte_t *) page[1].index; 68 ptep = (pte_t *) page[1].index;
69 if (!ptep) 69 if (!ptep)
70 return; 70 return;
71 pte_free(&init_mm, ptep); 71 page_table_free(&init_mm, (unsigned long *) ptep);
72 page[1].index = 0; 72 page[1].index = 0;
73} 73}
74 74
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 94b8ba2ec857..bb409332a484 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -38,13 +38,54 @@
38#include <asm/tlbflush.h> 38#include <asm/tlbflush.h>
39#include <asm/sections.h> 39#include <asm/sections.h>
40 40
41DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
42
43pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE))); 41pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((__aligned__(PAGE_SIZE)));
44 42
45char empty_zero_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); 43unsigned long empty_zero_page, zero_page_mask;
46EXPORT_SYMBOL(empty_zero_page); 44EXPORT_SYMBOL(empty_zero_page);
47 45
46static unsigned long setup_zero_pages(void)
47{
48 struct cpuid cpu_id;
49 unsigned int order;
50 unsigned long size;
51 struct page *page;
52 int i;
53
54 get_cpu_id(&cpu_id);
55 switch (cpu_id.machine) {
56 case 0x9672: /* g5 */
57 case 0x2064: /* z900 */
58 case 0x2066: /* z900 */
59 case 0x2084: /* z990 */
60 case 0x2086: /* z990 */
61 case 0x2094: /* z9-109 */
62 case 0x2096: /* z9-109 */
63 order = 0;
64 break;
65 case 0x2097: /* z10 */
66 case 0x2098: /* z10 */
67 default:
68 order = 2;
69 break;
70 }
71
72 empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
73 if (!empty_zero_page)
74 panic("Out of memory in setup_zero_pages");
75
76 page = virt_to_page((void *) empty_zero_page);
77 split_page(page, order);
78 for (i = 1 << order; i > 0; i--) {
79 SetPageReserved(page);
80 page++;
81 }
82
83 size = PAGE_SIZE << order;
84 zero_page_mask = (size - 1) & PAGE_MASK;
85
86 return 1UL << order;
87}
88
48/* 89/*
49 * paging_init() sets up the page tables 90 * paging_init() sets up the page tables
50 */ 91 */
@@ -83,6 +124,7 @@ void __init paging_init(void)
83#endif 124#endif
84 max_zone_pfns[ZONE_NORMAL] = max_low_pfn; 125 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
85 free_area_init_nodes(max_zone_pfns); 126 free_area_init_nodes(max_zone_pfns);
127 fault_init();
86} 128}
87 129
88void __init mem_init(void) 130void __init mem_init(void)
@@ -92,14 +134,12 @@ void __init mem_init(void)
92 max_mapnr = num_physpages = max_low_pfn; 134 max_mapnr = num_physpages = max_low_pfn;
93 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); 135 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
94 136
95 /* clear the zero-page */
96 memset(empty_zero_page, 0, PAGE_SIZE);
97
98 /* Setup guest page hinting */ 137 /* Setup guest page hinting */
99 cmma_init(); 138 cmma_init();
100 139
101 /* this will put all low memory onto the freelists */ 140 /* this will put all low memory onto the freelists */
102 totalram_pages += free_all_bootmem(); 141 totalram_pages += free_all_bootmem();
142 totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */
103 143
104 reservedpages = 0; 144 reservedpages = 0;
105 145
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 8d999249d357..0c719c61972e 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -15,6 +15,7 @@
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/quicklist.h> 17#include <linux/quicklist.h>
18#include <linux/rcupdate.h>
18 19
19#include <asm/system.h> 20#include <asm/system.h>
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
@@ -23,6 +24,67 @@
23#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
24#include <asm/mmu_context.h> 25#include <asm/mmu_context.h>
25 26
27struct rcu_table_freelist {
28 struct rcu_head rcu;
29 struct mm_struct *mm;
30 unsigned int pgt_index;
31 unsigned int crst_index;
32 unsigned long *table[0];
33};
34
35#define RCU_FREELIST_SIZE \
36 ((PAGE_SIZE - sizeof(struct rcu_table_freelist)) \
37 / sizeof(unsigned long))
38
39DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
40static DEFINE_PER_CPU(struct rcu_table_freelist *, rcu_table_freelist);
41
42static void __page_table_free(struct mm_struct *mm, unsigned long *table);
43static void __crst_table_free(struct mm_struct *mm, unsigned long *table);
44
45static struct rcu_table_freelist *rcu_table_freelist_get(struct mm_struct *mm)
46{
47 struct rcu_table_freelist **batchp = &__get_cpu_var(rcu_table_freelist);
48 struct rcu_table_freelist *batch = *batchp;
49
50 if (batch)
51 return batch;
52 batch = (struct rcu_table_freelist *) __get_free_page(GFP_ATOMIC);
53 if (batch) {
54 batch->mm = mm;
55 batch->pgt_index = 0;
56 batch->crst_index = RCU_FREELIST_SIZE;
57 *batchp = batch;
58 }
59 return batch;
60}
61
62static void rcu_table_freelist_callback(struct rcu_head *head)
63{
64 struct rcu_table_freelist *batch =
65 container_of(head, struct rcu_table_freelist, rcu);
66
67 while (batch->pgt_index > 0)
68 __page_table_free(batch->mm, batch->table[--batch->pgt_index]);
69 while (batch->crst_index < RCU_FREELIST_SIZE)
70 __crst_table_free(batch->mm, batch->table[batch->crst_index++]);
71 free_page((unsigned long) batch);
72}
73
74void rcu_table_freelist_finish(void)
75{
76 struct rcu_table_freelist *batch = __get_cpu_var(rcu_table_freelist);
77
78 if (!batch)
79 return;
80 call_rcu(&batch->rcu, rcu_table_freelist_callback);
81 __get_cpu_var(rcu_table_freelist) = NULL;
82}
83
84static void smp_sync(void *arg)
85{
86}
87
26#ifndef CONFIG_64BIT 88#ifndef CONFIG_64BIT
27#define ALLOC_ORDER 1 89#define ALLOC_ORDER 1
28#define TABLES_PER_PAGE 4 90#define TABLES_PER_PAGE 4
@@ -78,25 +140,55 @@ unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec)
78 } 140 }
79 page->index = page_to_phys(shadow); 141 page->index = page_to_phys(shadow);
80 } 142 }
81 spin_lock(&mm->context.list_lock); 143 spin_lock_bh(&mm->context.list_lock);
82 list_add(&page->lru, &mm->context.crst_list); 144 list_add(&page->lru, &mm->context.crst_list);
83 spin_unlock(&mm->context.list_lock); 145 spin_unlock_bh(&mm->context.list_lock);
84 return (unsigned long *) page_to_phys(page); 146 return (unsigned long *) page_to_phys(page);
85} 147}
86 148
87void crst_table_free(struct mm_struct *mm, unsigned long *table) 149static void __crst_table_free(struct mm_struct *mm, unsigned long *table)
88{ 150{
89 unsigned long *shadow = get_shadow_table(table); 151 unsigned long *shadow = get_shadow_table(table);
90 struct page *page = virt_to_page(table);
91 152
92 spin_lock(&mm->context.list_lock);
93 list_del(&page->lru);
94 spin_unlock(&mm->context.list_lock);
95 if (shadow) 153 if (shadow)
96 free_pages((unsigned long) shadow, ALLOC_ORDER); 154 free_pages((unsigned long) shadow, ALLOC_ORDER);
97 free_pages((unsigned long) table, ALLOC_ORDER); 155 free_pages((unsigned long) table, ALLOC_ORDER);
98} 156}
99 157
158void crst_table_free(struct mm_struct *mm, unsigned long *table)
159{
160 struct page *page = virt_to_page(table);
161
162 spin_lock_bh(&mm->context.list_lock);
163 list_del(&page->lru);
164 spin_unlock_bh(&mm->context.list_lock);
165 __crst_table_free(mm, table);
166}
167
168void crst_table_free_rcu(struct mm_struct *mm, unsigned long *table)
169{
170 struct rcu_table_freelist *batch;
171 struct page *page = virt_to_page(table);
172
173 spin_lock_bh(&mm->context.list_lock);
174 list_del(&page->lru);
175 spin_unlock_bh(&mm->context.list_lock);
176 if (atomic_read(&mm->mm_users) < 2 &&
177 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
178 __crst_table_free(mm, table);
179 return;
180 }
181 batch = rcu_table_freelist_get(mm);
182 if (!batch) {
183 smp_call_function(smp_sync, NULL, 1);
184 __crst_table_free(mm, table);
185 return;
186 }
187 batch->table[--batch->crst_index] = table;
188 if (batch->pgt_index >= batch->crst_index)
189 rcu_table_freelist_finish();
190}
191
100#ifdef CONFIG_64BIT 192#ifdef CONFIG_64BIT
101int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) 193int crst_table_upgrade(struct mm_struct *mm, unsigned long limit)
102{ 194{
@@ -108,7 +200,7 @@ repeat:
108 table = crst_table_alloc(mm, mm->context.noexec); 200 table = crst_table_alloc(mm, mm->context.noexec);
109 if (!table) 201 if (!table)
110 return -ENOMEM; 202 return -ENOMEM;
111 spin_lock(&mm->page_table_lock); 203 spin_lock_bh(&mm->page_table_lock);
112 if (mm->context.asce_limit < limit) { 204 if (mm->context.asce_limit < limit) {
113 pgd = (unsigned long *) mm->pgd; 205 pgd = (unsigned long *) mm->pgd;
114 if (mm->context.asce_limit <= (1UL << 31)) { 206 if (mm->context.asce_limit <= (1UL << 31)) {
@@ -130,7 +222,7 @@ repeat:
130 mm->task_size = mm->context.asce_limit; 222 mm->task_size = mm->context.asce_limit;
131 table = NULL; 223 table = NULL;
132 } 224 }
133 spin_unlock(&mm->page_table_lock); 225 spin_unlock_bh(&mm->page_table_lock);
134 if (table) 226 if (table)
135 crst_table_free(mm, table); 227 crst_table_free(mm, table);
136 if (mm->context.asce_limit < limit) 228 if (mm->context.asce_limit < limit)
@@ -182,7 +274,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
182 unsigned long bits; 274 unsigned long bits;
183 275
184 bits = (mm->context.noexec || mm->context.has_pgste) ? 3UL : 1UL; 276 bits = (mm->context.noexec || mm->context.has_pgste) ? 3UL : 1UL;
185 spin_lock(&mm->context.list_lock); 277 spin_lock_bh(&mm->context.list_lock);
186 page = NULL; 278 page = NULL;
187 if (!list_empty(&mm->context.pgtable_list)) { 279 if (!list_empty(&mm->context.pgtable_list)) {
188 page = list_first_entry(&mm->context.pgtable_list, 280 page = list_first_entry(&mm->context.pgtable_list,
@@ -191,7 +283,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
191 page = NULL; 283 page = NULL;
192 } 284 }
193 if (!page) { 285 if (!page) {
194 spin_unlock(&mm->context.list_lock); 286 spin_unlock_bh(&mm->context.list_lock);
195 page = alloc_page(GFP_KERNEL|__GFP_REPEAT); 287 page = alloc_page(GFP_KERNEL|__GFP_REPEAT);
196 if (!page) 288 if (!page)
197 return NULL; 289 return NULL;
@@ -202,7 +294,7 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
202 clear_table_pgstes(table); 294 clear_table_pgstes(table);
203 else 295 else
204 clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); 296 clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE);
205 spin_lock(&mm->context.list_lock); 297 spin_lock_bh(&mm->context.list_lock);
206 list_add(&page->lru, &mm->context.pgtable_list); 298 list_add(&page->lru, &mm->context.pgtable_list);
207 } 299 }
208 table = (unsigned long *) page_to_phys(page); 300 table = (unsigned long *) page_to_phys(page);
@@ -213,10 +305,25 @@ unsigned long *page_table_alloc(struct mm_struct *mm)
213 page->flags |= bits; 305 page->flags |= bits;
214 if ((page->flags & FRAG_MASK) == ((1UL << TABLES_PER_PAGE) - 1)) 306 if ((page->flags & FRAG_MASK) == ((1UL << TABLES_PER_PAGE) - 1))
215 list_move_tail(&page->lru, &mm->context.pgtable_list); 307 list_move_tail(&page->lru, &mm->context.pgtable_list);
216 spin_unlock(&mm->context.list_lock); 308 spin_unlock_bh(&mm->context.list_lock);
217 return table; 309 return table;
218} 310}
219 311
312static void __page_table_free(struct mm_struct *mm, unsigned long *table)
313{
314 struct page *page;
315 unsigned long bits;
316
317 bits = ((unsigned long) table) & 15;
318 table = (unsigned long *)(((unsigned long) table) ^ bits);
319 page = pfn_to_page(__pa(table) >> PAGE_SHIFT);
320 page->flags ^= bits;
321 if (!(page->flags & FRAG_MASK)) {
322 pgtable_page_dtor(page);
323 __free_page(page);
324 }
325}
326
220void page_table_free(struct mm_struct *mm, unsigned long *table) 327void page_table_free(struct mm_struct *mm, unsigned long *table)
221{ 328{
222 struct page *page; 329 struct page *page;
@@ -225,7 +332,7 @@ void page_table_free(struct mm_struct *mm, unsigned long *table)
225 bits = (mm->context.noexec || mm->context.has_pgste) ? 3UL : 1UL; 332 bits = (mm->context.noexec || mm->context.has_pgste) ? 3UL : 1UL;
226 bits <<= (__pa(table) & (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long); 333 bits <<= (__pa(table) & (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long);
227 page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 334 page = pfn_to_page(__pa(table) >> PAGE_SHIFT);
228 spin_lock(&mm->context.list_lock); 335 spin_lock_bh(&mm->context.list_lock);
229 page->flags ^= bits; 336 page->flags ^= bits;
230 if (page->flags & FRAG_MASK) { 337 if (page->flags & FRAG_MASK) {
231 /* Page now has some free pgtable fragments. */ 338 /* Page now has some free pgtable fragments. */
@@ -234,18 +341,48 @@ void page_table_free(struct mm_struct *mm, unsigned long *table)
234 } else 341 } else
235 /* All fragments of the 4K page have been freed. */ 342 /* All fragments of the 4K page have been freed. */
236 list_del(&page->lru); 343 list_del(&page->lru);
237 spin_unlock(&mm->context.list_lock); 344 spin_unlock_bh(&mm->context.list_lock);
238 if (page) { 345 if (page) {
239 pgtable_page_dtor(page); 346 pgtable_page_dtor(page);
240 __free_page(page); 347 __free_page(page);
241 } 348 }
242} 349}
243 350
351void page_table_free_rcu(struct mm_struct *mm, unsigned long *table)
352{
353 struct rcu_table_freelist *batch;
354 struct page *page;
355 unsigned long bits;
356
357 if (atomic_read(&mm->mm_users) < 2 &&
358 cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
359 page_table_free(mm, table);
360 return;
361 }
362 batch = rcu_table_freelist_get(mm);
363 if (!batch) {
364 smp_call_function(smp_sync, NULL, 1);
365 page_table_free(mm, table);
366 return;
367 }
368 bits = (mm->context.noexec || mm->context.has_pgste) ? 3UL : 1UL;
369 bits <<= (__pa(table) & (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long);
370 page = pfn_to_page(__pa(table) >> PAGE_SHIFT);
371 spin_lock_bh(&mm->context.list_lock);
372 /* Delayed freeing with rcu prevents reuse of pgtable fragments */
373 list_del_init(&page->lru);
374 spin_unlock_bh(&mm->context.list_lock);
375 table = (unsigned long *)(((unsigned long) table) | bits);
376 batch->table[batch->pgt_index++] = table;
377 if (batch->pgt_index >= batch->crst_index)
378 rcu_table_freelist_finish();
379}
380
244void disable_noexec(struct mm_struct *mm, struct task_struct *tsk) 381void disable_noexec(struct mm_struct *mm, struct task_struct *tsk)
245{ 382{
246 struct page *page; 383 struct page *page;
247 384
248 spin_lock(&mm->context.list_lock); 385 spin_lock_bh(&mm->context.list_lock);
249 /* Free shadow region and segment tables. */ 386 /* Free shadow region and segment tables. */
250 list_for_each_entry(page, &mm->context.crst_list, lru) 387 list_for_each_entry(page, &mm->context.crst_list, lru)
251 if (page->index) { 388 if (page->index) {
@@ -255,7 +392,7 @@ void disable_noexec(struct mm_struct *mm, struct task_struct *tsk)
255 /* "Free" second halves of page tables. */ 392 /* "Free" second halves of page tables. */
256 list_for_each_entry(page, &mm->context.pgtable_list, lru) 393 list_for_each_entry(page, &mm->context.pgtable_list, lru)
257 page->flags &= ~SECOND_HALVES; 394 page->flags &= ~SECOND_HALVES;
258 spin_unlock(&mm->context.list_lock); 395 spin_unlock_bh(&mm->context.list_lock);
259 mm->context.noexec = 0; 396 mm->context.noexec = 0;
260 update_mm(mm, tsk); 397 update_mm(mm, tsk);
261} 398}
@@ -312,6 +449,8 @@ int s390_enable_sie(void)
312 tsk->mm = tsk->active_mm = mm; 449 tsk->mm = tsk->active_mm = mm;
313 preempt_disable(); 450 preempt_disable();
314 update_mm(mm, tsk); 451 update_mm(mm, tsk);
452 atomic_inc(&mm->context.attach_count);
453 atomic_dec(&old_mm->context.attach_count);
315 cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); 454 cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm));
316 preempt_enable(); 455 preempt_enable();
317 task_unlock(tsk); 456 task_unlock(tsk);
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index be4a15584751..4293fdcb5398 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -1,8 +1,3 @@
1# For a description of the syntax of this configuration file,
2# see Documentation/kbuild/kconfig-language.txt.
3
4mainmenu "Linux/SCORE Kernel Configuration"
5
6menu "Machine selection" 1menu "Machine selection"
7 2
8choice 3choice
diff --git a/arch/score/include/asm/pgtable.h b/arch/score/include/asm/pgtable.h
index ccf38f06c57d..2fd469807683 100644
--- a/arch/score/include/asm/pgtable.h
+++ b/arch/score/include/asm/pgtable.h
@@ -88,10 +88,7 @@ static inline void pmd_clear(pmd_t *pmdp)
88 88
89#define pte_offset_map(dir, address) \ 89#define pte_offset_map(dir, address) \
90 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 90 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
91#define pte_offset_map_nested(dir, address) \
92 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
93#define pte_unmap(pte) ((void)(pte)) 91#define pte_unmap(pte) ((void)(pte))
94#define pte_unmap_nested(pte) ((void)(pte))
95 92
96/* 93/*
97 * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken, 94 * Bits 9(_PAGE_PRESENT) and 10(_PAGE_FILE)are taken,
diff --git a/arch/score/kernel/ptrace.c b/arch/score/kernel/ptrace.c
index 174c6422b096..55836188b217 100644
--- a/arch/score/kernel/ptrace.c
+++ b/arch/score/kernel/ptrace.c
@@ -325,7 +325,8 @@ void ptrace_disable(struct task_struct *child)
325} 325}
326 326
327long 327long
328arch_ptrace(struct task_struct *child, long request, long addr, long data) 328arch_ptrace(struct task_struct *child, long request,
329 unsigned long addr, unsigned long data)
329{ 330{
330 int ret; 331 int ret;
331 unsigned long __user *datap = (void __user *)data; 332 unsigned long __user *datap = (void __user *)data;
@@ -335,14 +336,14 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data)
335 ret = copy_regset_to_user(child, &user_score_native_view, 336 ret = copy_regset_to_user(child, &user_score_native_view,
336 REGSET_GENERAL, 337 REGSET_GENERAL,
337 0, sizeof(struct pt_regs), 338 0, sizeof(struct pt_regs),
338 (void __user *)datap); 339 datap);
339 break; 340 break;
340 341
341 case PTRACE_SETREGS: 342 case PTRACE_SETREGS:
342 ret = copy_regset_from_user(child, &user_score_native_view, 343 ret = copy_regset_from_user(child, &user_score_native_view,
343 REGSET_GENERAL, 344 REGSET_GENERAL,
344 0, sizeof(struct pt_regs), 345 0, sizeof(struct pt_regs),
345 (const void __user *)datap); 346 datap);
346 break; 347 break;
347 348
348 default: 349 default:
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 35b6879628a0..7f217b3a50a8 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -1,10 +1,3 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux/SuperH Kernel Configuration"
7
8config SUPERH 1config SUPERH
9 def_bool y 2 def_bool y
10 select EMBEDDED 3 select EMBEDDED
@@ -24,8 +17,12 @@ config SUPERH
24 select HAVE_KERNEL_LZMA 17 select HAVE_KERNEL_LZMA
25 select HAVE_KERNEL_LZO 18 select HAVE_KERNEL_LZO
26 select HAVE_SYSCALL_TRACEPOINTS 19 select HAVE_SYSCALL_TRACEPOINTS
20 select HAVE_REGS_AND_STACK_ACCESS_API
21 select HAVE_GENERIC_HARDIRQS
22 select HAVE_SPARSE_IRQ
27 select RTC_LIB 23 select RTC_LIB
28 select GENERIC_ATOMIC64 24 select GENERIC_ATOMIC64
25 select GENERIC_HARDIRQS_NO_DEPRECATED
29 help 26 help
30 The SuperH is a RISC processor targeted for use in embedded systems 27 The SuperH is a RISC processor targeted for use in embedded systems
31 and consumer electronics; it was also used in the Sega Dreamcast 28 and consumer electronics; it was also used in the Sega Dreamcast
@@ -46,8 +43,9 @@ config SUPERH32
46 select HAVE_ARCH_KGDB 43 select HAVE_ARCH_KGDB
47 select HAVE_HW_BREAKPOINT 44 select HAVE_HW_BREAKPOINT
48 select HAVE_MIXED_BREAKPOINTS_REGS 45 select HAVE_MIXED_BREAKPOINTS_REGS
49 select PERF_EVENTS if HAVE_HW_BREAKPOINT 46 select PERF_EVENTS
50 select ARCH_HIBERNATION_POSSIBLE if MMU 47 select ARCH_HIBERNATION_POSSIBLE if MMU
48 select SPARSE_IRQ
51 49
52config SUPERH64 50config SUPERH64
53 def_bool ARCH = "sh64" 51 def_bool ARCH = "sh64"
@@ -77,19 +75,9 @@ config GENERIC_FIND_NEXT_BIT
77config GENERIC_HWEIGHT 75config GENERIC_HWEIGHT
78 def_bool y 76 def_bool y
79 77
80config GENERIC_HARDIRQS
81 def_bool y
82
83config GENERIC_HARDIRQS_NO__DO_IRQ
84 def_bool y
85
86config IRQ_PER_CPU 78config IRQ_PER_CPU
87 def_bool y 79 def_bool y
88 80
89config SPARSE_IRQ
90 def_bool y
91 depends on SUPERH32
92
93config GENERIC_GPIO 81config GENERIC_GPIO
94 def_bool n 82 def_bool n
95 83
@@ -205,6 +193,7 @@ config CPU_SH2
205config CPU_SH2A 193config CPU_SH2A
206 bool 194 bool
207 select CPU_SH2 195 select CPU_SH2
196 select UNCACHED_MAPPING
208 197
209config CPU_SH3 198config CPU_SH3
210 bool 199 bool
@@ -471,6 +460,7 @@ config CPU_SUBTYPE_SHX3
471 select CPU_SH4A 460 select CPU_SH4A
472 select CPU_SHX3 461 select CPU_SHX3
473 select GENERIC_CLOCKEVENTS_BROADCAST if SMP 462 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
463 select ARCH_REQUIRE_GPIOLIB
474 464
475# SH4AL-DSP Processor Support 465# SH4AL-DSP Processor Support
476 466
@@ -575,7 +565,7 @@ config SH_CLK_CPG
575config SH_CLK_CPG_LEGACY 565config SH_CLK_CPG_LEGACY
576 depends on SH_CLK_CPG 566 depends on SH_CLK_CPG
577 def_bool y if !CPU_SUBTYPE_SH7785 && !ARCH_SHMOBILE && \ 567 def_bool y if !CPU_SUBTYPE_SH7785 && !ARCH_SHMOBILE && \
578 !CPU_SUBTYPE_SH7786 568 !CPU_SHX3 && !CPU_SUBTYPE_SH7757
579 569
580config SH_CLK_MD 570config SH_CLK_MD
581 int "CPU Mode Pin Setting" 571 int "CPU Mode Pin Setting"
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 307b3a4a790b..9c8c6e1a2a15 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -133,10 +133,7 @@ machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
133machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx 133machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
134machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast 134machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
135machdir-$(CONFIG_SH_SH03) += mach-sh03 135machdir-$(CONFIG_SH_SH03) += mach-sh03
136machdir-$(CONFIG_SH_SECUREEDGE5410) += mach-snapgear
137machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d 136machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d
138machdir-$(CONFIG_SH_7751_SYSTEMH) += mach-systemh
139machdir-$(CONFIG_SH_EDOSK7705) += mach-edosk7705
140machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander 137machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander
141machdir-$(CONFIG_SH_MIGOR) += mach-migor 138machdir-$(CONFIG_SH_MIGOR) += mach-migor
142machdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa 139machdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa
diff --git a/arch/sh/boards/Kconfig b/arch/sh/boards/Kconfig
index 07b35ca2f644..2018c7ea4c93 100644
--- a/arch/sh/boards/Kconfig
+++ b/arch/sh/boards/Kconfig
@@ -81,13 +81,6 @@ config SH_7343_SOLUTION_ENGINE
81 Select 7343 SolutionEngine if configuring for a Hitachi 81 Select 7343 SolutionEngine if configuring for a Hitachi
82 SH7343 (SH-Mobile 3AS) evaluation board. 82 SH7343 (SH-Mobile 3AS) evaluation board.
83 83
84config SH_7751_SYSTEMH
85 bool "SystemH7751R"
86 depends on CPU_SUBTYPE_SH7751R
87 help
88 Select SystemH if you are configuring for a Renesas SystemH
89 7751R evaluation board.
90
91config SH_HP6XX 84config SH_HP6XX
92 bool "HP6XX" 85 bool "HP6XX"
93 select SYS_SUPPORTS_APM_EMULATION 86 select SYS_SUPPORTS_APM_EMULATION
@@ -155,6 +148,8 @@ config SH_SDK7786
155 depends on CPU_SUBTYPE_SH7786 148 depends on CPU_SUBTYPE_SH7786
156 select SYS_SUPPORTS_PCI 149 select SYS_SUPPORTS_PCI
157 select NO_IOPORT if !PCI 150 select NO_IOPORT if !PCI
151 select ARCH_WANT_OPTIONAL_GPIOLIB
152 select HAVE_SRAM_POOL
158 help 153 help
159 Select SDK7786 if configuring for a Renesas Technology Europe 154 Select SDK7786 if configuring for a Renesas Technology Europe
160 SH7786-65nm board. 155 SH7786-65nm board.
@@ -165,6 +160,11 @@ config SH_HIGHLANDER
165 select SYS_SUPPORTS_PCI 160 select SYS_SUPPORTS_PCI
166 select IO_TRAPPED if MMU 161 select IO_TRAPPED if MMU
167 162
163config SH_SH7757LCR
164 bool "SH7757LCR"
165 depends on CPU_SUBTYPE_SH7757
166 select ARCH_REQUIRE_GPIOLIB
167
168config SH_SH7785LCR 168config SH_SH7785LCR
169 bool "SH7785LCR" 169 bool "SH7785LCR"
170 depends on CPU_SUBTYPE_SH7785 170 depends on CPU_SUBTYPE_SH7785
@@ -309,6 +309,17 @@ config SH_POLARIS
309 help 309 help
310 Select if configuring for an SMSC Polaris development board 310 Select if configuring for an SMSC Polaris development board
311 311
312config SH_SH2007
313 bool "SH-2007 board"
314 select NO_IOPORT
315 depends on CPU_SUBTYPE_SH7780
316 help
317 SH-2007 is a single-board computer based around SH7780 chip
318 intended for embedded applications.
319 It has an Ethernet interface (SMC9118), direct connected
320 Compact Flash socket, two serial ports and PC-104 bus.
321 More information at <http://sh2000.sh-linux.org>.
322
312endmenu 323endmenu
313 324
314source "arch/sh/boards/mach-r2d/Kconfig" 325source "arch/sh/boards/mach-r2d/Kconfig"
diff --git a/arch/sh/boards/Makefile b/arch/sh/boards/Makefile
index 4f90f9b7a922..be7d11d04b26 100644
--- a/arch/sh/boards/Makefile
+++ b/arch/sh/boards/Makefile
@@ -2,10 +2,14 @@
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_SECUREEDGE5410) += board-secureedge5410.o
6obj-$(CONFIG_SH_SH2007) += board-sh2007.o
5obj-$(CONFIG_SH_SH7785LCR) += board-sh7785lcr.o 7obj-$(CONFIG_SH_SH7785LCR) += board-sh7785lcr.o
6obj-$(CONFIG_SH_URQUELL) += board-urquell.o 8obj-$(CONFIG_SH_URQUELL) += board-urquell.o
7obj-$(CONFIG_SH_SHMIN) += board-shmin.o 9obj-$(CONFIG_SH_SHMIN) += board-shmin.o
10obj-$(CONFIG_SH_EDOSK7705) += board-edosk7705.o
8obj-$(CONFIG_SH_EDOSK7760) += board-edosk7760.o 11obj-$(CONFIG_SH_EDOSK7760) += board-edosk7760.o
9obj-$(CONFIG_SH_ESPT) += board-espt.o 12obj-$(CONFIG_SH_ESPT) += board-espt.o
10obj-$(CONFIG_SH_POLARIS) += board-polaris.o 13obj-$(CONFIG_SH_POLARIS) += board-polaris.o
11obj-$(CONFIG_SH_TITAN) += board-titan.o 14obj-$(CONFIG_SH_TITAN) += board-titan.o
15obj-$(CONFIG_SH_SH7757LCR) += board-sh7757lcr.o
diff --git a/arch/sh/boards/board-edosk7705.c b/arch/sh/boards/board-edosk7705.c
new file mode 100644
index 000000000000..4cb3bb74c36f
--- /dev/null
+++ b/arch/sh/boards/board-edosk7705.c
@@ -0,0 +1,78 @@
1/*
2 * arch/sh/boards/renesas/edosk7705/setup.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 * Modified for edosk7705 development
9 * board by S. Dunn, 2003.
10 */
11#include <linux/init.h>
12#include <linux/irq.h>
13#include <linux/platform_device.h>
14#include <linux/interrupt.h>
15#include <linux/smc91x.h>
16#include <asm/machvec.h>
17#include <asm/sizes.h>
18
19#define SMC_IOBASE 0xA2000000
20#define SMC_IO_OFFSET 0x300
21#define SMC_IOADDR (SMC_IOBASE + SMC_IO_OFFSET)
22
23#define ETHERNET_IRQ 0x09
24
25static void __init sh_edosk7705_init_irq(void)
26{
27 make_imask_irq(ETHERNET_IRQ);
28}
29
30/* eth initialization functions */
31static struct smc91x_platdata smc91x_info = {
32 .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL,
33};
34
35static struct resource smc91x_res[] = {
36 [0] = {
37 .start = SMC_IOADDR,
38 .end = SMC_IOADDR + SZ_32 - 1,
39 .flags = IORESOURCE_MEM,
40 },
41 [1] = {
42 .start = ETHERNET_IRQ,
43 .end = ETHERNET_IRQ,
44 .flags = IORESOURCE_IRQ ,
45 }
46};
47
48static struct platform_device smc91x_dev = {
49 .name = "smc91x",
50 .id = -1,
51 .num_resources = ARRAY_SIZE(smc91x_res),
52 .resource = smc91x_res,
53
54 .dev = {
55 .platform_data = &smc91x_info,
56 },
57};
58
59/* platform init code */
60static struct platform_device *edosk7705_devices[] __initdata = {
61 &smc91x_dev,
62};
63
64static int __init init_edosk7705_devices(void)
65{
66 return platform_add_devices(edosk7705_devices,
67 ARRAY_SIZE(edosk7705_devices));
68}
69__initcall(init_edosk7705_devices);
70
71/*
72 * The Machine Vector
73 */
74static struct sh_machine_vector mv_edosk7705 __initmv = {
75 .mv_name = "EDOSK7705",
76 .mv_nr_irqs = 80,
77 .mv_init_irq = sh_edosk7705_init_irq,
78};
diff --git a/arch/sh/boards/mach-snapgear/setup.c b/arch/sh/boards/board-secureedge5410.c
index 331745dee379..32f875e8493d 100644
--- a/arch/sh/boards/mach-snapgear/setup.c
+++ b/arch/sh/boards/board-secureedge5410.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/boards/snapgear/setup.c
3 *
4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com> 2 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
5 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> 3 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
6 * 4 *
@@ -19,18 +17,19 @@
19#include <linux/module.h> 17#include <linux/module.h>
20#include <linux/sched.h> 18#include <linux/sched.h>
21#include <asm/machvec.h> 19#include <asm/machvec.h>
22#include <mach/snapgear.h> 20#include <mach/secureedge5410.h>
23#include <asm/irq.h> 21#include <asm/irq.h>
24#include <asm/io.h> 22#include <asm/io.h>
25#include <cpu/timer.h> 23#include <cpu/timer.h>
26 24
25unsigned short secureedge5410_ioport;
26
27/* 27/*
28 * EraseConfig handling functions 28 * EraseConfig handling functions
29 */ 29 */
30
31static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id) 30static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id)
32{ 31{
33 (void)__raw_readb(0xb8000000); /* dummy read */ 32 ctrl_delay(); /* dummy read */
34 33
35 printk("SnapGear: erase switch interrupt!\n"); 34 printk("SnapGear: erase switch interrupt!\n");
36 35
@@ -39,21 +38,22 @@ static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id)
39 38
40static int __init eraseconfig_init(void) 39static int __init eraseconfig_init(void)
41{ 40{
41 unsigned int irq = evt2irq(0x240);
42
42 printk("SnapGear: EraseConfig init\n"); 43 printk("SnapGear: EraseConfig init\n");
44
43 /* Setup "EraseConfig" switch on external IRQ 0 */ 45 /* Setup "EraseConfig" switch on external IRQ 0 */
44 if (request_irq(IRL0_IRQ, eraseconfig_interrupt, IRQF_DISABLED, 46 if (request_irq(irq, eraseconfig_interrupt, IRQF_DISABLED,
45 "Erase Config", NULL)) 47 "Erase Config", NULL))
46 printk("SnapGear: failed to register IRQ%d for Reset witch\n", 48 printk("SnapGear: failed to register IRQ%d for Reset witch\n",
47 IRL0_IRQ); 49 irq);
48 else 50 else
49 printk("SnapGear: registered EraseConfig switch on IRQ%d\n", 51 printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
50 IRL0_IRQ); 52 irq);
51 return(0); 53 return 0;
52} 54}
53
54module_init(eraseconfig_init); 55module_init(eraseconfig_init);
55 56
56/****************************************************************************/
57/* 57/*
58 * Initialize IRQ setting 58 * Initialize IRQ setting
59 * 59 *
@@ -62,7 +62,6 @@ module_init(eraseconfig_init);
62 * IRL2 = eth1 62 * IRL2 = eth1
63 * IRL3 = crypto 63 * IRL3 = crypto
64 */ 64 */
65
66static void __init init_snapgear_IRQ(void) 65static void __init init_snapgear_IRQ(void)
67{ 66{
68 printk("Setup SnapGear IRQ/IPR ...\n"); 67 printk("Setup SnapGear IRQ/IPR ...\n");
@@ -76,20 +75,5 @@ static void __init init_snapgear_IRQ(void)
76static struct sh_machine_vector mv_snapgear __initmv = { 75static struct sh_machine_vector mv_snapgear __initmv = {
77 .mv_name = "SnapGear SecureEdge5410", 76 .mv_name = "SnapGear SecureEdge5410",
78 .mv_nr_irqs = 72, 77 .mv_nr_irqs = 72,
79
80 .mv_inb = snapgear_inb,
81 .mv_inw = snapgear_inw,
82 .mv_inl = snapgear_inl,
83 .mv_outb = snapgear_outb,
84 .mv_outw = snapgear_outw,
85 .mv_outl = snapgear_outl,
86
87 .mv_inb_p = snapgear_inb_p,
88 .mv_inw_p = snapgear_inw,
89 .mv_inl_p = snapgear_inl,
90 .mv_outb_p = snapgear_outb_p,
91 .mv_outw_p = snapgear_outw,
92 .mv_outl_p = snapgear_outl,
93
94 .mv_init_irq = init_snapgear_IRQ, 78 .mv_init_irq = init_snapgear_IRQ,
95}; 79};
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-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index 3da116f47f01..07ea908c510d 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -176,6 +176,21 @@ static void ap320_wvga_power_off(void *board_data)
176 __raw_writew(0, FPGA_LCDREG); 176 __raw_writew(0, FPGA_LCDREG);
177} 177}
178 178
179const static struct fb_videomode ap325rxa_lcdc_modes[] = {
180 {
181 .name = "LB070WV1",
182 .xres = 800,
183 .yres = 480,
184 .left_margin = 32,
185 .right_margin = 160,
186 .hsync_len = 8,
187 .upper_margin = 63,
188 .lower_margin = 80,
189 .vsync_len = 1,
190 .sync = 0, /* hsync and vsync are active low */
191 },
192};
193
179static struct sh_mobile_lcdc_info lcdc_info = { 194static struct sh_mobile_lcdc_info lcdc_info = {
180 .clock_source = LCDC_CLK_EXTERNAL, 195 .clock_source = LCDC_CLK_EXTERNAL,
181 .ch[0] = { 196 .ch[0] = {
@@ -183,18 +198,8 @@ static struct sh_mobile_lcdc_info lcdc_info = {
183 .bpp = 16, 198 .bpp = 16,
184 .interface_type = RGB18, 199 .interface_type = RGB18,
185 .clock_divider = 1, 200 .clock_divider = 1,
186 .lcd_cfg = { 201 .lcd_cfg = ap325rxa_lcdc_modes,
187 .name = "LB070WV1", 202 .num_cfg = ARRAY_SIZE(ap325rxa_lcdc_modes),
188 .xres = 800,
189 .yres = 480,
190 .left_margin = 32,
191 .right_margin = 160,
192 .hsync_len = 8,
193 .upper_margin = 63,
194 .lower_margin = 80,
195 .vsync_len = 1,
196 .sync = 0, /* hsync and vsync are active low */
197 },
198 .lcd_size_cfg = { /* 7.0 inch */ 203 .lcd_size_cfg = { /* 7.0 inch */
199 .width = 152, 204 .width = 152,
200 .height = 91, 205 .height = 91,
@@ -481,7 +486,6 @@ static struct soc_camera_link ov7725_link = {
481 .power = ov7725_power, 486 .power = ov7725_power,
482 .board_info = &ap325rxa_i2c_camera[0], 487 .board_info = &ap325rxa_i2c_camera[0],
483 .i2c_adapter_id = 0, 488 .i2c_adapter_id = 0,
484 .module_name = "ov772x",
485 .priv = &ov7725_info, 489 .priv = &ov7725_info,
486}; 490};
487 491
diff --git a/arch/sh/boards/mach-cayman/irq.c b/arch/sh/boards/mach-cayman/irq.c
index 1394b078db36..d7ac5af9d102 100644
--- a/arch/sh/boards/mach-cayman/irq.c
+++ b/arch/sh/boards/mach-cayman/irq.c
@@ -55,8 +55,9 @@ static struct irqaction cayman_action_pci2 = {
55 .flags = IRQF_DISABLED, 55 .flags = IRQF_DISABLED,
56}; 56};
57 57
58static void enable_cayman_irq(unsigned int irq) 58static void enable_cayman_irq(struct irq_data *data)
59{ 59{
60 unsigned int irq = data->irq;
60 unsigned long flags; 61 unsigned long flags;
61 unsigned long mask; 62 unsigned long mask;
62 unsigned int reg; 63 unsigned int reg;
@@ -72,8 +73,9 @@ static void enable_cayman_irq(unsigned int irq)
72 local_irq_restore(flags); 73 local_irq_restore(flags);
73} 74}
74 75
75void disable_cayman_irq(unsigned int irq) 76static void disable_cayman_irq(struct irq_data *data)
76{ 77{
78 unsigned int irq = data->irq;
77 unsigned long flags; 79 unsigned long flags;
78 unsigned long mask; 80 unsigned long mask;
79 unsigned int reg; 81 unsigned int reg;
@@ -89,16 +91,10 @@ void disable_cayman_irq(unsigned int irq)
89 local_irq_restore(flags); 91 local_irq_restore(flags);
90} 92}
91 93
92static void ack_cayman_irq(unsigned int irq)
93{
94 disable_cayman_irq(irq);
95}
96
97struct irq_chip cayman_irq_type = { 94struct irq_chip cayman_irq_type = {
98 .name = "Cayman-IRQ", 95 .name = "Cayman-IRQ",
99 .unmask = enable_cayman_irq, 96 .irq_unmask = enable_cayman_irq,
100 .mask = disable_cayman_irq, 97 .irq_mask = disable_cayman_irq,
101 .mask_ack = ack_cayman_irq,
102}; 98};
103 99
104int cayman_irq_demux(int evt) 100int cayman_irq_demux(int evt)
diff --git a/arch/sh/boards/mach-dreamcast/irq.c b/arch/sh/boards/mach-dreamcast/irq.c
index d932667410ab..72e7ac9549da 100644
--- a/arch/sh/boards/mach-dreamcast/irq.c
+++ b/arch/sh/boards/mach-dreamcast/irq.c
@@ -60,8 +60,9 @@
60 */ 60 */
61 61
62/* Disable the hardware event by masking its bit in its EMR */ 62/* Disable the hardware event by masking its bit in its EMR */
63static inline void disable_systemasic_irq(unsigned int irq) 63static inline void disable_systemasic_irq(struct irq_data *data)
64{ 64{
65 unsigned int irq = data->irq;
65 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 66 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
66 __u32 mask; 67 __u32 mask;
67 68
@@ -71,8 +72,9 @@ static inline void disable_systemasic_irq(unsigned int irq)
71} 72}
72 73
73/* Enable the hardware event by setting its bit in its EMR */ 74/* Enable the hardware event by setting its bit in its EMR */
74static inline void enable_systemasic_irq(unsigned int irq) 75static inline void enable_systemasic_irq(struct irq_data *data)
75{ 76{
77 unsigned int irq = data->irq;
76 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 78 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
77 __u32 mask; 79 __u32 mask;
78 80
@@ -82,18 +84,19 @@ static inline void enable_systemasic_irq(unsigned int irq)
82} 84}
83 85
84/* Acknowledge a hardware event by writing its bit back to its ESR */ 86/* Acknowledge a hardware event by writing its bit back to its ESR */
85static void mask_ack_systemasic_irq(unsigned int irq) 87static void mask_ack_systemasic_irq(struct irq_data *data)
86{ 88{
89 unsigned int irq = data->irq;
87 __u32 esr = ESR_BASE + (LEVEL(irq) << 2); 90 __u32 esr = ESR_BASE + (LEVEL(irq) << 2);
88 disable_systemasic_irq(irq); 91 disable_systemasic_irq(data);
89 outl((1 << EVENT_BIT(irq)), esr); 92 outl((1 << EVENT_BIT(irq)), esr);
90} 93}
91 94
92struct irq_chip systemasic_int = { 95struct irq_chip systemasic_int = {
93 .name = "System ASIC", 96 .name = "System ASIC",
94 .mask = disable_systemasic_irq, 97 .irq_mask = disable_systemasic_irq,
95 .mask_ack = mask_ack_systemasic_irq, 98 .irq_mask_ack = mask_ack_systemasic_irq,
96 .unmask = enable_systemasic_irq, 99 .irq_unmask = enable_systemasic_irq,
97}; 100};
98 101
99/* 102/*
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 1d7b495a7db4..2eaeb9e59585 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -231,14 +231,41 @@ static struct platform_device usb1_common_device = {
231}; 231};
232 232
233/* LCDC */ 233/* LCDC */
234const static struct fb_videomode ecovec_lcd_modes[] = {
235 {
236 .name = "Panel",
237 .xres = 800,
238 .yres = 480,
239 .left_margin = 220,
240 .right_margin = 110,
241 .hsync_len = 70,
242 .upper_margin = 20,
243 .lower_margin = 5,
244 .vsync_len = 5,
245 .sync = 0, /* hsync and vsync are active low */
246 },
247};
248
249const static struct fb_videomode ecovec_dvi_modes[] = {
250 {
251 .name = "DVI",
252 .xres = 1280,
253 .yres = 720,
254 .left_margin = 220,
255 .right_margin = 110,
256 .hsync_len = 40,
257 .upper_margin = 20,
258 .lower_margin = 5,
259 .vsync_len = 5,
260 .sync = 0, /* hsync and vsync are active low */
261 },
262};
263
234static struct sh_mobile_lcdc_info lcdc_info = { 264static struct sh_mobile_lcdc_info lcdc_info = {
235 .ch[0] = { 265 .ch[0] = {
236 .interface_type = RGB18, 266 .interface_type = RGB18,
237 .chan = LCDC_CHAN_MAINLCD, 267 .chan = LCDC_CHAN_MAINLCD,
238 .bpp = 16, 268 .bpp = 16,
239 .lcd_cfg = {
240 .sync = 0, /* hsync and vsync are active low */
241 },
242 .lcd_size_cfg = { /* 7.0 inch */ 269 .lcd_size_cfg = { /* 7.0 inch */
243 .width = 152, 270 .width = 152,
244 .height = 91, 271 .height = 91,
@@ -620,7 +647,6 @@ static struct soc_camera_link tw9910_link = {
620 .bus_id = 1, 647 .bus_id = 1,
621 .power = tw9910_power, 648 .power = tw9910_power,
622 .board_info = &i2c_camera[0], 649 .board_info = &i2c_camera[0],
623 .module_name = "tw9910",
624 .priv = &tw9910_info, 650 .priv = &tw9910_info,
625}; 651};
626 652
@@ -644,7 +670,6 @@ static struct soc_camera_link mt9t112_link1 = {
644 .power = mt9t112_power1, 670 .power = mt9t112_power1,
645 .bus_id = 0, 671 .bus_id = 0,
646 .board_info = &i2c_camera[1], 672 .board_info = &i2c_camera[1],
647 .module_name = "mt9t112",
648 .priv = &mt9t112_info1, 673 .priv = &mt9t112_info1,
649}; 674};
650 675
@@ -667,7 +692,6 @@ static struct soc_camera_link mt9t112_link2 = {
667 .power = mt9t112_power2, 692 .power = mt9t112_power2,
668 .bus_id = 1, 693 .bus_id = 1,
669 .board_info = &i2c_camera[2], 694 .board_info = &i2c_camera[2],
670 .module_name = "mt9t112",
671 .priv = &mt9t112_info2, 695 .priv = &mt9t112_info2,
672}; 696};
673 697
@@ -793,7 +817,6 @@ static struct sh_vou_pdata sh_vou_pdata = {
793 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW, 817 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
794 .board_info = &ak8813, 818 .board_info = &ak8813,
795 .i2c_adap = 0, 819 .i2c_adap = 0,
796 .module_name = "ak881x",
797}; 820};
798 821
799static struct resource sh_vou_resources[] = { 822static struct resource sh_vou_resources[] = {
@@ -1079,33 +1102,18 @@ static int __init arch_setup(void)
1079 if (gpio_get_value(GPIO_PTE6)) { 1102 if (gpio_get_value(GPIO_PTE6)) {
1080 /* DVI */ 1103 /* DVI */
1081 lcdc_info.clock_source = LCDC_CLK_EXTERNAL; 1104 lcdc_info.clock_source = LCDC_CLK_EXTERNAL;
1082 lcdc_info.ch[0].clock_divider = 1, 1105 lcdc_info.ch[0].clock_divider = 1;
1083 lcdc_info.ch[0].lcd_cfg.name = "DVI"; 1106 lcdc_info.ch[0].lcd_cfg = ecovec_dvi_modes;
1084 lcdc_info.ch[0].lcd_cfg.xres = 1280; 1107 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_dvi_modes);
1085 lcdc_info.ch[0].lcd_cfg.yres = 720;
1086 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
1087 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
1088 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
1089 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
1090 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
1091 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
1092 1108
1093 gpio_set_value(GPIO_PTA2, 1); 1109 gpio_set_value(GPIO_PTA2, 1);
1094 gpio_set_value(GPIO_PTU1, 1); 1110 gpio_set_value(GPIO_PTU1, 1);
1095 } else { 1111 } else {
1096 /* Panel */ 1112 /* Panel */
1097
1098 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL; 1113 lcdc_info.clock_source = LCDC_CLK_PERIPHERAL;
1099 lcdc_info.ch[0].clock_divider = 2, 1114 lcdc_info.ch[0].clock_divider = 2;
1100 lcdc_info.ch[0].lcd_cfg.name = "Panel"; 1115 lcdc_info.ch[0].lcd_cfg = ecovec_lcd_modes;
1101 lcdc_info.ch[0].lcd_cfg.xres = 800; 1116 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(ecovec_lcd_modes);
1102 lcdc_info.ch[0].lcd_cfg.yres = 480;
1103 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
1104 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
1105 lcdc_info.ch[0].lcd_cfg.hsync_len = 70;
1106 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
1107 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
1108 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
1109 1117
1110 gpio_set_value(GPIO_PTR1, 1); 1118 gpio_set_value(GPIO_PTR1, 1);
1111 1119
@@ -1248,14 +1256,14 @@ static int __init arch_setup(void)
1248 1256
1249 /* set SPU2 clock to 83.4 MHz */ 1257 /* set SPU2 clock to 83.4 MHz */
1250 clk = clk_get(NULL, "spu_clk"); 1258 clk = clk_get(NULL, "spu_clk");
1251 if (clk) { 1259 if (!IS_ERR(clk)) {
1252 clk_set_rate(clk, clk_round_rate(clk, 83333333)); 1260 clk_set_rate(clk, clk_round_rate(clk, 83333333));
1253 clk_put(clk); 1261 clk_put(clk);
1254 } 1262 }
1255 1263
1256 /* change parent of FSI B */ 1264 /* change parent of FSI B */
1257 clk = clk_get(NULL, "fsib_clk"); 1265 clk = clk_get(NULL, "fsib_clk");
1258 if (clk) { 1266 if (!IS_ERR(clk)) {
1259 clk_register(&fsimckb_clk); 1267 clk_register(&fsimckb_clk);
1260 clk_set_parent(clk, &fsimckb_clk); 1268 clk_set_parent(clk, &fsimckb_clk);
1261 clk_set_rate(clk, 11000); 1269 clk_set_rate(clk, 11000);
@@ -1273,7 +1281,7 @@ static int __init arch_setup(void)
1273 1281
1274 /* set VPU clock to 166 MHz */ 1282 /* set VPU clock to 166 MHz */
1275 clk = clk_get(NULL, "vpu_clk"); 1283 clk = clk_get(NULL, "vpu_clk");
1276 if (clk) { 1284 if (!IS_ERR(clk)) {
1277 clk_set_rate(clk, clk_round_rate(clk, 166000000)); 1285 clk_set_rate(clk, clk_round_rate(clk, 166000000));
1278 clk_put(clk); 1286 clk_put(clk);
1279 } 1287 }
diff --git a/arch/sh/boards/mach-edosk7705/Makefile b/arch/sh/boards/mach-edosk7705/Makefile
deleted file mode 100644
index cd54acb51499..000000000000
--- a/arch/sh/boards/mach-edosk7705/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the EDOSK7705 specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/mach-edosk7705/io.c b/arch/sh/boards/mach-edosk7705/io.c
deleted file mode 100644
index 5b9c57c43241..000000000000
--- a/arch/sh/boards/mach-edosk7705/io.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * arch/sh/boards/renesas/edosk7705/io.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
6 *
7 * I/O routines for Hitachi EDOSK7705 board.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/io.h>
14#include <mach/edosk7705.h>
15#include <asm/addrspace.h>
16
17#define SMC_IOADDR 0xA2000000
18
19/* Map the Ethernet addresses as if it is at 0x300 - 0x320 */
20static unsigned long sh_edosk7705_isa_port2addr(unsigned long port)
21{
22 /*
23 * SMC91C96 registers are 4 byte aligned rather than the
24 * usual 2 byte!
25 */
26 if (port >= 0x300 && port < 0x320)
27 return SMC_IOADDR + ((port - 0x300) * 2);
28
29 maybebadio(port);
30 return port;
31}
32
33/* Trying to read / write bytes on odd-byte boundaries to the Ethernet
34 * registers causes problems. So we bit-shift the value and read / write
35 * in 2 byte chunks. Setting the low byte to 0 does not cause problems
36 * now as odd byte writes are only made on the bit mask / interrupt
37 * register. This may not be the case in future Mar-2003 SJD
38 */
39unsigned char sh_edosk7705_inb(unsigned long port)
40{
41 if (port >= 0x300 && port < 0x320 && port & 0x01)
42 return __raw_readw(port - 1) >> 8;
43
44 return __raw_readb(sh_edosk7705_isa_port2addr(port));
45}
46
47void sh_edosk7705_outb(unsigned char value, unsigned long port)
48{
49 if (port >= 0x300 && port < 0x320 && port & 0x01) {
50 __raw_writew(((unsigned short)value << 8), port - 1);
51 return;
52 }
53
54 __raw_writeb(value, sh_edosk7705_isa_port2addr(port));
55}
56
57void sh_edosk7705_insb(unsigned long port, void *addr, unsigned long count)
58{
59 unsigned char *p = addr;
60
61 while (count--)
62 *p++ = sh_edosk7705_inb(port);
63}
64
65void sh_edosk7705_outsb(unsigned long port, const void *addr, unsigned long count)
66{
67 unsigned char *p = (unsigned char *)addr;
68
69 while (count--)
70 sh_edosk7705_outb(*p++, port);
71}
diff --git a/arch/sh/boards/mach-edosk7705/setup.c b/arch/sh/boards/mach-edosk7705/setup.c
deleted file mode 100644
index d59225e26fb9..000000000000
--- a/arch/sh/boards/mach-edosk7705/setup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * arch/sh/boards/renesas/edosk7705/setup.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 * Modified for edosk7705 development
9 * board by S. Dunn, 2003.
10 */
11#include <linux/init.h>
12#include <linux/irq.h>
13#include <asm/machvec.h>
14#include <mach/edosk7705.h>
15
16static void __init sh_edosk7705_init_irq(void)
17{
18 /* This is the Ethernet interrupt */
19 make_imask_irq(0x09);
20}
21
22/*
23 * The Machine Vector
24 */
25static struct sh_machine_vector mv_edosk7705 __initmv = {
26 .mv_name = "EDOSK7705",
27 .mv_nr_irqs = 80,
28
29 .mv_inb = sh_edosk7705_inb,
30 .mv_outb = sh_edosk7705_outb,
31
32 .mv_insb = sh_edosk7705_insb,
33 .mv_outsb = sh_edosk7705_outsb,
34
35 .mv_init_irq = sh_edosk7705_init_irq,
36};
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index 68994a163f6c..9b60eaabf8f3 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -126,6 +126,21 @@ static struct platform_device kfr2r09_sh_keysc_device = {
126 }, 126 },
127}; 127};
128 128
129const static struct fb_videomode kfr2r09_lcdc_modes[] = {
130 {
131 .name = "TX07D34VM0AAA",
132 .xres = 240,
133 .yres = 400,
134 .left_margin = 0,
135 .right_margin = 16,
136 .hsync_len = 8,
137 .upper_margin = 0,
138 .lower_margin = 1,
139 .vsync_len = 1,
140 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
141 },
142};
143
129static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = { 144static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
130 .clock_source = LCDC_CLK_BUS, 145 .clock_source = LCDC_CLK_BUS,
131 .ch[0] = { 146 .ch[0] = {
@@ -134,18 +149,8 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
134 .interface_type = SYS18, 149 .interface_type = SYS18,
135 .clock_divider = 6, 150 .clock_divider = 6,
136 .flags = LCDC_FLAGS_DWPOL, 151 .flags = LCDC_FLAGS_DWPOL,
137 .lcd_cfg = { 152 .lcd_cfg = kfr2r09_lcdc_modes,
138 .name = "TX07D34VM0AAA", 153 .num_cfg = ARRAY_SIZE(kfr2r09_lcdc_modes),
139 .xres = 240,
140 .yres = 400,
141 .left_margin = 0,
142 .right_margin = 16,
143 .hsync_len = 8,
144 .upper_margin = 0,
145 .lower_margin = 1,
146 .vsync_len = 1,
147 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
148 },
149 .lcd_size_cfg = { 154 .lcd_size_cfg = {
150 .width = 35, 155 .width = 35,
151 .height = 58, 156 .height = 58,
@@ -333,7 +338,6 @@ static struct soc_camera_link rj54n1_link = {
333 .power = camera_power, 338 .power = camera_power,
334 .board_info = &kfr2r09_i2c_camera, 339 .board_info = &kfr2r09_i2c_camera,
335 .i2c_adapter_id = 1, 340 .i2c_adapter_id = 1,
336 .module_name = "rj54n1cb0c",
337 .priv = &rj54n1_priv, 341 .priv = &rj54n1_priv,
338}; 342};
339 343
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-landisk/irq.c b/arch/sh/boards/mach-landisk/irq.c
index 96f38a4187d0..e79412a40490 100644
--- a/arch/sh/boards/mach-landisk/irq.c
+++ b/arch/sh/boards/mach-landisk/irq.c
@@ -18,25 +18,24 @@
18#include <linux/io.h> 18#include <linux/io.h>
19#include <mach-landisk/mach/iodata_landisk.h> 19#include <mach-landisk/mach/iodata_landisk.h>
20 20
21static void disable_landisk_irq(unsigned int irq) 21static void disable_landisk_irq(struct irq_data *data)
22{ 22{
23 unsigned char mask = 0xff ^ (0x01 << (irq - 5)); 23 unsigned char mask = 0xff ^ (0x01 << (data->irq - 5));
24 24
25 __raw_writeb(__raw_readb(PA_IMASK) & mask, PA_IMASK); 25 __raw_writeb(__raw_readb(PA_IMASK) & mask, PA_IMASK);
26} 26}
27 27
28static void enable_landisk_irq(unsigned int irq) 28static void enable_landisk_irq(struct irq_data *data)
29{ 29{
30 unsigned char value = (0x01 << (irq - 5)); 30 unsigned char value = (0x01 << (data->irq - 5));
31 31
32 __raw_writeb(__raw_readb(PA_IMASK) | value, PA_IMASK); 32 __raw_writeb(__raw_readb(PA_IMASK) | value, PA_IMASK);
33} 33}
34 34
35static struct irq_chip landisk_irq_chip __read_mostly = { 35static struct irq_chip landisk_irq_chip __read_mostly = {
36 .name = "LANDISK", 36 .name = "LANDISK",
37 .mask = disable_landisk_irq, 37 .irq_mask = disable_landisk_irq,
38 .unmask = enable_landisk_irq, 38 .irq_unmask = enable_landisk_irq,
39 .mask_ack = disable_landisk_irq,
40}; 39};
41 40
42/* 41/*
@@ -50,7 +49,7 @@ void __init init_landisk_IRQ(void)
50 disable_irq_nosync(i); 49 disable_irq_nosync(i);
51 set_irq_chip_and_handler_name(i, &landisk_irq_chip, 50 set_irq_chip_and_handler_name(i, &landisk_irq_chip,
52 handle_level_irq, "level"); 51 handle_level_irq, "level");
53 enable_landisk_irq(i); 52 enable_landisk_irq(irq_get_irq_data(i));
54 } 53 }
55 __raw_writeb(0x00, PA_PWRINT_CLR); 54 __raw_writeb(0x00, PA_PWRINT_CLR);
56} 55}
diff --git a/arch/sh/boards/mach-microdev/io.c b/arch/sh/boards/mach-microdev/io.c
index 2960c659020e..acdafb0c6404 100644
--- a/arch/sh/boards/mach-microdev/io.c
+++ b/arch/sh/boards/mach-microdev/io.c
@@ -54,7 +54,7 @@
54/* 54/*
55 * map I/O ports to memory-mapped addresses 55 * map I/O ports to memory-mapped addresses
56 */ 56 */
57static unsigned long microdev_isa_port2addr(unsigned long offset) 57void __iomem *microdev_ioport_map(unsigned long offset, unsigned int len)
58{ 58{
59 unsigned long result; 59 unsigned long result;
60 60
@@ -72,16 +72,6 @@ static unsigned long microdev_isa_port2addr(unsigned long offset)
72 * Configuration Registers 72 * Configuration Registers
73 */ 73 */
74 result = IO_SUPERIO_PHYS + (offset << 1); 74 result = IO_SUPERIO_PHYS + (offset << 1);
75#if 0
76 } else if (offset == KBD_DATA_REG || offset == KBD_CNTL_REG ||
77 offset == KBD_STATUS_REG) {
78 /*
79 * SMSC FDC37C93xAPM SuperIO chip
80 *
81 * PS/2 Keyboard + Mouse (ports 0x60 and 0x64).
82 */
83 result = IO_SUPERIO_PHYS + (offset << 1);
84#endif
85 } else if (((offset >= IO_IDE1_BASE) && 75 } else if (((offset >= IO_IDE1_BASE) &&
86 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) || 76 (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
87 (offset == IO_IDE1_MISC)) { 77 (offset == IO_IDE1_MISC)) {
@@ -131,237 +121,5 @@ static unsigned long microdev_isa_port2addr(unsigned long offset)
131 result = PVR; 121 result = PVR;
132 } 122 }
133 123
134 return result; 124 return (void __iomem *)result;
135}
136
137#define PORT2ADDR(x) (microdev_isa_port2addr(x))
138
139static inline void delay(void)
140{
141#if defined(CONFIG_PCI)
142 /* System board present, just make a dummy SRAM access. (CS0 will be
143 mapped to PCI memory, probably good to avoid it.) */
144 __raw_readw(0xa6800000);
145#else
146 /* CS0 will be mapped to flash, ROM etc so safe to access it. */
147 __raw_readw(0xa0000000);
148#endif
149}
150
151unsigned char microdev_inb(unsigned long port)
152{
153#ifdef CONFIG_PCI
154 if (port >= PCIBIOS_MIN_IO)
155 return microdev_pci_inb(port);
156#endif
157 return *(volatile unsigned char*)PORT2ADDR(port);
158}
159
160unsigned short microdev_inw(unsigned long port)
161{
162#ifdef CONFIG_PCI
163 if (port >= PCIBIOS_MIN_IO)
164 return microdev_pci_inw(port);
165#endif
166 return *(volatile unsigned short*)PORT2ADDR(port);
167}
168
169unsigned int microdev_inl(unsigned long port)
170{
171#ifdef CONFIG_PCI
172 if (port >= PCIBIOS_MIN_IO)
173 return microdev_pci_inl(port);
174#endif
175 return *(volatile unsigned int*)PORT2ADDR(port);
176}
177
178void microdev_outw(unsigned short b, unsigned long port)
179{
180#ifdef CONFIG_PCI
181 if (port >= PCIBIOS_MIN_IO) {
182 microdev_pci_outw(b, port);
183 return;
184 }
185#endif
186 *(volatile unsigned short*)PORT2ADDR(port) = b;
187}
188
189void microdev_outb(unsigned char b, unsigned long port)
190{
191#ifdef CONFIG_PCI
192 if (port >= PCIBIOS_MIN_IO) {
193 microdev_pci_outb(b, port);
194 return;
195 }
196#endif
197
198 /*
199 * There is a board feature with the current SH4-202 MicroDev in
200 * that the 2 byte enables (nBE0 and nBE1) are tied together (and
201 * to the Chip Select Line (Ethernet_CS)). Due to this connectivity,
202 * it is not possible to safely perform 8-bit writes to the
203 * Ethernet registers, as 16-bits will be consumed from the Data
204 * lines (corrupting the other byte). Hence, this function is
205 * written to implement 16-bit read/modify/write for all byte-wide
206 * accesses.
207 *
208 * Note: there is no problem with byte READS (even or odd).
209 *
210 * Sean McGoogan - 16th June 2003.
211 */
212 if ((port >= IO_LAN91C111_BASE) &&
213 (port < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
214 /*
215 * Then are trying to perform a byte-write to the
216 * LAN91C111. This needs special care.
217 */
218 if (port % 2 == 1) { /* is the port odd ? */
219 /* unset bit-0, i.e. make even */
220 const unsigned long evenPort = port-1;
221 unsigned short word;
222
223 /*
224 * do a 16-bit read/write to write to 'port',
225 * preserving even byte.
226 *
227 * Even addresses are bits 0-7
228 * Odd addresses are bits 8-15
229 */
230 word = microdev_inw(evenPort);
231 word = (word & 0xffu) | (b << 8);
232 microdev_outw(word, evenPort);
233 } else {
234 /* else, we are trying to do an even byte write */
235 unsigned short word;
236
237 /*
238 * do a 16-bit read/write to write to 'port',
239 * preserving odd byte.
240 *
241 * Even addresses are bits 0-7
242 * Odd addresses are bits 8-15
243 */
244 word = microdev_inw(port);
245 word = (word & 0xff00u) | (b);
246 microdev_outw(word, port);
247 }
248 } else {
249 *(volatile unsigned char*)PORT2ADDR(port) = b;
250 }
251}
252
253void microdev_outl(unsigned int b, unsigned long port)
254{
255#ifdef CONFIG_PCI
256 if (port >= PCIBIOS_MIN_IO) {
257 microdev_pci_outl(b, port);
258 return;
259 }
260#endif
261 *(volatile unsigned int*)PORT2ADDR(port) = b;
262}
263
264unsigned char microdev_inb_p(unsigned long port)
265{
266 unsigned char v = microdev_inb(port);
267 delay();
268 return v;
269}
270
271unsigned short microdev_inw_p(unsigned long port)
272{
273 unsigned short v = microdev_inw(port);
274 delay();
275 return v;
276}
277
278unsigned int microdev_inl_p(unsigned long port)
279{
280 unsigned int v = microdev_inl(port);
281 delay();
282 return v;
283}
284
285void microdev_outb_p(unsigned char b, unsigned long port)
286{
287 microdev_outb(b, port);
288 delay();
289}
290
291void microdev_outw_p(unsigned short b, unsigned long port)
292{
293 microdev_outw(b, port);
294 delay();
295}
296
297void microdev_outl_p(unsigned int b, unsigned long port)
298{
299 microdev_outl(b, port);
300 delay();
301}
302
303void microdev_insb(unsigned long port, void *buffer, unsigned long count)
304{
305 volatile unsigned char *port_addr;
306 unsigned char *buf = buffer;
307
308 port_addr = (volatile unsigned char *)PORT2ADDR(port);
309
310 while (count--)
311 *buf++ = *port_addr;
312}
313
314void microdev_insw(unsigned long port, void *buffer, unsigned long count)
315{
316 volatile unsigned short *port_addr;
317 unsigned short *buf = buffer;
318
319 port_addr = (volatile unsigned short *)PORT2ADDR(port);
320
321 while (count--)
322 *buf++ = *port_addr;
323}
324
325void microdev_insl(unsigned long port, void *buffer, unsigned long count)
326{
327 volatile unsigned long *port_addr;
328 unsigned int *buf = buffer;
329
330 port_addr = (volatile unsigned long *)PORT2ADDR(port);
331
332 while (count--)
333 *buf++ = *port_addr;
334}
335
336void microdev_outsb(unsigned long port, const void *buffer, unsigned long count)
337{
338 volatile unsigned char *port_addr;
339 const unsigned char *buf = buffer;
340
341 port_addr = (volatile unsigned char *)PORT2ADDR(port);
342
343 while (count--)
344 *port_addr = *buf++;
345}
346
347void microdev_outsw(unsigned long port, const void *buffer, unsigned long count)
348{
349 volatile unsigned short *port_addr;
350 const unsigned short *buf = buffer;
351
352 port_addr = (volatile unsigned short *)PORT2ADDR(port);
353
354 while (count--)
355 *port_addr = *buf++;
356}
357
358void microdev_outsl(unsigned long port, const void *buffer, unsigned long count)
359{
360 volatile unsigned long *port_addr;
361 const unsigned int *buf = buffer;
362
363 port_addr = (volatile unsigned long *)PORT2ADDR(port);
364
365 while (count--)
366 *port_addr = *buf++;
367} 125}
diff --git a/arch/sh/boards/mach-microdev/irq.c b/arch/sh/boards/mach-microdev/irq.c
index a26d16669aa2..c35001fd9032 100644
--- a/arch/sh/boards/mach-microdev/irq.c
+++ b/arch/sh/boards/mach-microdev/irq.c
@@ -65,19 +65,9 @@ static const struct {
65# error Inconsistancy in defining the IRQ# for primary IDE! 65# error Inconsistancy in defining the IRQ# for primary IDE!
66#endif 66#endif
67 67
68static void enable_microdev_irq(unsigned int irq); 68static void disable_microdev_irq(struct irq_data *data)
69static void disable_microdev_irq(unsigned int irq);
70static void mask_and_ack_microdev(unsigned int);
71
72static struct irq_chip microdev_irq_type = {
73 .name = "MicroDev-IRQ",
74 .unmask = enable_microdev_irq,
75 .mask = disable_microdev_irq,
76 .ack = mask_and_ack_microdev,
77};
78
79static void disable_microdev_irq(unsigned int irq)
80{ 69{
70 unsigned int irq = data->irq;
81 unsigned int fpgaIrq; 71 unsigned int fpgaIrq;
82 72
83 if (irq >= NUM_EXTERNAL_IRQS) 73 if (irq >= NUM_EXTERNAL_IRQS)
@@ -91,8 +81,9 @@ static void disable_microdev_irq(unsigned int irq)
91 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG); 81 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
92} 82}
93 83
94static void enable_microdev_irq(unsigned int irq) 84static void enable_microdev_irq(struct irq_data *data)
95{ 85{
86 unsigned int irq = data->irq;
96 unsigned long priorityReg, priorities, pri; 87 unsigned long priorityReg, priorities, pri;
97 unsigned int fpgaIrq; 88 unsigned int fpgaIrq;
98 89
@@ -116,17 +107,18 @@ static void enable_microdev_irq(unsigned int irq)
116 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG); 107 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
117} 108}
118 109
110static struct irq_chip microdev_irq_type = {
111 .name = "MicroDev-IRQ",
112 .irq_unmask = enable_microdev_irq,
113 .irq_mask = disable_microdev_irq,
114};
115
119/* This function sets the desired irq handler to be a MicroDev type */ 116/* This function sets the desired irq handler to be a MicroDev type */
120static void __init make_microdev_irq(unsigned int irq) 117static void __init make_microdev_irq(unsigned int irq)
121{ 118{
122 disable_irq_nosync(irq); 119 disable_irq_nosync(irq);
123 set_irq_chip_and_handler(irq, &microdev_irq_type, handle_level_irq); 120 set_irq_chip_and_handler(irq, &microdev_irq_type, handle_level_irq);
124 disable_microdev_irq(irq); 121 disable_microdev_irq(irq_get_irq_data(irq));
125}
126
127static void mask_and_ack_microdev(unsigned int irq)
128{
129 disable_microdev_irq(irq);
130} 122}
131 123
132extern void __init init_microdev_irq(void) 124extern void __init init_microdev_irq(void)
diff --git a/arch/sh/boards/mach-microdev/setup.c b/arch/sh/boards/mach-microdev/setup.c
index d1df2a4fb9b8..d8a747291e03 100644
--- a/arch/sh/boards/mach-microdev/setup.c
+++ b/arch/sh/boards/mach-microdev/setup.c
@@ -195,27 +195,6 @@ device_initcall(microdev_devices_setup);
195static struct sh_machine_vector mv_sh4202_microdev __initmv = { 195static struct sh_machine_vector mv_sh4202_microdev __initmv = {
196 .mv_name = "SH4-202 MicroDev", 196 .mv_name = "SH4-202 MicroDev",
197 .mv_nr_irqs = 72, 197 .mv_nr_irqs = 72,
198 198 .mv_ioport_map = microdev_ioport_map,
199 .mv_inb = microdev_inb,
200 .mv_inw = microdev_inw,
201 .mv_inl = microdev_inl,
202 .mv_outb = microdev_outb,
203 .mv_outw = microdev_outw,
204 .mv_outl = microdev_outl,
205
206 .mv_inb_p = microdev_inb_p,
207 .mv_inw_p = microdev_inw_p,
208 .mv_inl_p = microdev_inl_p,
209 .mv_outb_p = microdev_outb_p,
210 .mv_outw_p = microdev_outw_p,
211 .mv_outl_p = microdev_outl_p,
212
213 .mv_insb = microdev_insb,
214 .mv_insw = microdev_insw,
215 .mv_insl = microdev_insl,
216 .mv_outsb = microdev_outsb,
217 .mv_outsw = microdev_outsw,
218 .mv_outsl = microdev_outsl,
219
220 .mv_init_irq = init_microdev_irq, 199 .mv_init_irq = init_microdev_irq,
221}; 200};
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index 662debe4ead2..c8acfec98695 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -213,51 +213,55 @@ static struct platform_device migor_nand_flash_device = {
213 } 213 }
214}; 214};
215 215
216const static struct fb_videomode migor_lcd_modes[] = {
217 {
218#if defined(CONFIG_SH_MIGOR_RTA_WVGA)
219 .name = "LB070WV1",
220 .xres = 800,
221 .yres = 480,
222 .left_margin = 64,
223 .right_margin = 16,
224 .hsync_len = 120,
225 .sync = 0,
226#elif defined(CONFIG_SH_MIGOR_QVGA)
227 .name = "PH240320T",
228 .xres = 320,
229 .yres = 240,
230 .left_margin = 0,
231 .right_margin = 16,
232 .hsync_len = 8,
233 .sync = FB_SYNC_HOR_HIGH_ACT,
234#endif
235 .upper_margin = 1,
236 .lower_margin = 17,
237 .vsync_len = 2,
238 },
239};
240
216static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { 241static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = {
217#ifdef CONFIG_SH_MIGOR_RTA_WVGA 242#if defined(CONFIG_SH_MIGOR_RTA_WVGA)
218 .clock_source = LCDC_CLK_BUS, 243 .clock_source = LCDC_CLK_BUS,
219 .ch[0] = { 244 .ch[0] = {
220 .chan = LCDC_CHAN_MAINLCD, 245 .chan = LCDC_CHAN_MAINLCD,
221 .bpp = 16, 246 .bpp = 16,
222 .interface_type = RGB16, 247 .interface_type = RGB16,
223 .clock_divider = 2, 248 .clock_divider = 2,
224 .lcd_cfg = { 249 .lcd_cfg = migor_lcd_modes,
225 .name = "LB070WV1", 250 .num_cfg = ARRAY_SIZE(migor_lcd_modes),
226 .xres = 800,
227 .yres = 480,
228 .left_margin = 64,
229 .right_margin = 16,
230 .hsync_len = 120,
231 .upper_margin = 1,
232 .lower_margin = 17,
233 .vsync_len = 2,
234 .sync = 0,
235 },
236 .lcd_size_cfg = { /* 7.0 inch */ 251 .lcd_size_cfg = { /* 7.0 inch */
237 .width = 152, 252 .width = 152,
238 .height = 91, 253 .height = 91,
239 }, 254 },
240 } 255 }
241#endif 256#elif defined(CONFIG_SH_MIGOR_QVGA)
242#ifdef CONFIG_SH_MIGOR_QVGA
243 .clock_source = LCDC_CLK_PERIPHERAL, 257 .clock_source = LCDC_CLK_PERIPHERAL,
244 .ch[0] = { 258 .ch[0] = {
245 .chan = LCDC_CHAN_MAINLCD, 259 .chan = LCDC_CHAN_MAINLCD,
246 .bpp = 16, 260 .bpp = 16,
247 .interface_type = SYS16A, 261 .interface_type = SYS16A,
248 .clock_divider = 10, 262 .clock_divider = 10,
249 .lcd_cfg = { 263 .lcd_cfg = migor_lcd_modes,
250 .name = "PH240320T", 264 .num_cfg = ARRAY_SIZE(migor_lcd_modes),
251 .xres = 320,
252 .yres = 240,
253 .left_margin = 0,
254 .right_margin = 16,
255 .hsync_len = 8,
256 .upper_margin = 1,
257 .lower_margin = 17,
258 .vsync_len = 2,
259 .sync = FB_SYNC_HOR_HIGH_ACT,
260 },
261 .lcd_size_cfg = { /* 2.4 inch */ 265 .lcd_size_cfg = { /* 2.4 inch */
262 .width = 49, 266 .width = 49,
263 .height = 37, 267 .height = 37,
@@ -450,7 +454,6 @@ static struct soc_camera_link ov7725_link = {
450 .power = ov7725_power, 454 .power = ov7725_power,
451 .board_info = &migor_i2c_camera[0], 455 .board_info = &migor_i2c_camera[0],
452 .i2c_adapter_id = 0, 456 .i2c_adapter_id = 0,
453 .module_name = "ov772x",
454 .priv = &ov7725_info, 457 .priv = &ov7725_info,
455}; 458};
456 459
@@ -463,7 +466,6 @@ static struct soc_camera_link tw9910_link = {
463 .power = tw9910_power, 466 .power = tw9910_power,
464 .board_info = &migor_i2c_camera[1], 467 .board_info = &migor_i2c_camera[1],
465 .i2c_adapter_id = 0, 468 .i2c_adapter_id = 0,
466 .module_name = "tw9910",
467 .priv = &tw9910_info, 469 .priv = &tw9910_info,
468}; 470};
469 471
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-se/7206/Makefile b/arch/sh/boards/mach-se/7206/Makefile
index 63e7ed699f39..5c9eaa0535b9 100644
--- a/arch/sh/boards/mach-se/7206/Makefile
+++ b/arch/sh/boards/mach-se/7206/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the 7206 SolutionEngine specific parts of the kernel 2# Makefile for the 7206 SolutionEngine specific parts of the kernel
3# 3#
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o irq.o
diff --git a/arch/sh/boards/mach-se/7206/io.c b/arch/sh/boards/mach-se/7206/io.c
deleted file mode 100644
index adadc77532ee..000000000000
--- a/arch/sh/boards/mach-se/7206/io.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
2 *
3 * linux/arch/sh/boards/se/7206/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7206 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <mach-se/mach/se7206.h>
15
16
17static inline void delay(void)
18{
19 __raw_readw(0x20000000); /* P2 ROM Area */
20}
21
22/* MS7750 requires special versions of in*, out* routines, since
23 PC-like io ports are located at upper half byte of 16-bit word which
24 can be accessed only with 16-bit wide. */
25
26static inline volatile __u16 *
27port2adr(unsigned int port)
28{
29 if (port >= 0x2000 && port < 0x2020)
30 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
31 else if (port >= 0x300 && port < 0x310)
32 return (volatile __u16 *) (PA_SMSC + (port - 0x300));
33
34 return (volatile __u16 *)port;
35}
36
37unsigned char se7206_inb(unsigned long port)
38{
39 return (*port2adr(port)) & 0xff;
40}
41
42unsigned char se7206_inb_p(unsigned long port)
43{
44 unsigned long v;
45
46 v = (*port2adr(port)) & 0xff;
47 delay();
48 return v;
49}
50
51unsigned short se7206_inw(unsigned long port)
52{
53 return *port2adr(port);
54}
55
56void se7206_outb(unsigned char value, unsigned long port)
57{
58 *(port2adr(port)) = value;
59}
60
61void se7206_outb_p(unsigned char value, unsigned long port)
62{
63 *(port2adr(port)) = value;
64 delay();
65}
66
67void se7206_outw(unsigned short value, unsigned long port)
68{
69 *port2adr(port) = value;
70}
71
72void se7206_insb(unsigned long port, void *addr, unsigned long count)
73{
74 volatile __u16 *p = port2adr(port);
75 __u8 *ap = addr;
76
77 while (count--)
78 *ap++ = *p;
79}
80
81void se7206_insw(unsigned long port, void *addr, unsigned long count)
82{
83 volatile __u16 *p = port2adr(port);
84 __u16 *ap = addr;
85 while (count--)
86 *ap++ = *p;
87}
88
89void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
90{
91 volatile __u16 *p = port2adr(port);
92 const __u8 *ap = addr;
93
94 while (count--)
95 *p = *ap++;
96}
97
98void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
99{
100 volatile __u16 *p = port2adr(port);
101 const __u16 *ap = addr;
102 while (count--)
103 *p = *ap++;
104}
diff --git a/arch/sh/boards/mach-se/7206/irq.c b/arch/sh/boards/mach-se/7206/irq.c
index 8d82175d83ab..d961949600fd 100644
--- a/arch/sh/boards/mach-se/7206/irq.c
+++ b/arch/sh/boards/mach-se/7206/irq.c
@@ -25,8 +25,9 @@
25#define INTC_IPR01 0xfffe0818 25#define INTC_IPR01 0xfffe0818
26#define INTC_ICR1 0xfffe0802 26#define INTC_ICR1 0xfffe0802
27 27
28static void disable_se7206_irq(unsigned int irq) 28static void disable_se7206_irq(struct irq_data *data)
29{ 29{
30 unsigned int irq = data->irq;
30 unsigned short val; 31 unsigned short val;
31 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq))); 32 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
32 unsigned short msk0,msk1; 33 unsigned short msk0,msk1;
@@ -55,8 +56,9 @@ static void disable_se7206_irq(unsigned int irq)
55 __raw_writew(msk1, INTMSK1); 56 __raw_writew(msk1, INTMSK1);
56} 57}
57 58
58static void enable_se7206_irq(unsigned int irq) 59static void enable_se7206_irq(struct irq_data *data)
59{ 60{
61 unsigned int irq = data->irq;
60 unsigned short val; 62 unsigned short val;
61 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq))); 63 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
62 unsigned short msk0,msk1; 64 unsigned short msk0,msk1;
@@ -86,13 +88,14 @@ static void enable_se7206_irq(unsigned int irq)
86 __raw_writew(msk1, INTMSK1); 88 __raw_writew(msk1, INTMSK1);
87} 89}
88 90
89static void eoi_se7206_irq(unsigned int irq) 91static void eoi_se7206_irq(struct irq_data *data)
90{ 92{
91 unsigned short sts0,sts1; 93 unsigned short sts0,sts1;
94 unsigned int irq = data->irq;
92 struct irq_desc *desc = irq_to_desc(irq); 95 struct irq_desc *desc = irq_to_desc(irq);
93 96
94 if (!(desc->status & (IRQ_DISABLED|IRQ_INPROGRESS))) 97 if (!(desc->status & (IRQ_DISABLED|IRQ_INPROGRESS)))
95 enable_se7206_irq(irq); 98 enable_se7206_irq(data);
96 /* FPGA isr clear */ 99 /* FPGA isr clear */
97 sts0 = __raw_readw(INTSTS0); 100 sts0 = __raw_readw(INTSTS0);
98 sts1 = __raw_readw(INTSTS1); 101 sts1 = __raw_readw(INTSTS1);
@@ -115,10 +118,9 @@ static void eoi_se7206_irq(unsigned int irq)
115 118
116static struct irq_chip se7206_irq_chip __read_mostly = { 119static struct irq_chip se7206_irq_chip __read_mostly = {
117 .name = "SE7206-FPGA", 120 .name = "SE7206-FPGA",
118 .mask = disable_se7206_irq, 121 .irq_mask = disable_se7206_irq,
119 .unmask = enable_se7206_irq, 122 .irq_unmask = enable_se7206_irq,
120 .mask_ack = disable_se7206_irq, 123 .irq_eoi = eoi_se7206_irq,
121 .eoi = eoi_se7206_irq,
122}; 124};
123 125
124static void make_se7206_irq(unsigned int irq) 126static void make_se7206_irq(unsigned int irq)
@@ -126,7 +128,7 @@ static void make_se7206_irq(unsigned int irq)
126 disable_irq_nosync(irq); 128 disable_irq_nosync(irq);
127 set_irq_chip_and_handler_name(irq, &se7206_irq_chip, 129 set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
128 handle_level_irq, "level"); 130 handle_level_irq, "level");
129 disable_se7206_irq(irq); 131 disable_se7206_irq(irq_get_irq_data(irq));
130} 132}
131 133
132/* 134/*
@@ -137,11 +139,13 @@ void __init init_se7206_IRQ(void)
137 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */ 139 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
138 make_se7206_irq(IRQ1_IRQ); /* ATA */ 140 make_se7206_irq(IRQ1_IRQ); /* ATA */
139 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */ 141 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
140 __raw_writew(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */ 142
143 __raw_writew(__raw_readw(INTC_ICR1) | 0x000b, INTC_ICR); /* ICR1 */
141 144
142 /* FPGA System register setup*/ 145 /* FPGA System register setup*/
143 __raw_writew(0x0000,INTSTS0); /* Clear INTSTS0 */ 146 __raw_writew(0x0000,INTSTS0); /* Clear INTSTS0 */
144 __raw_writew(0x0000,INTSTS1); /* Clear INTSTS1 */ 147 __raw_writew(0x0000,INTSTS1); /* Clear INTSTS1 */
148
145 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */ 149 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
146 __raw_writew(0x0001,INTSEL); 150 __raw_writew(0x0001,INTSEL);
147} 151}
diff --git a/arch/sh/boards/mach-se/7206/setup.c b/arch/sh/boards/mach-se/7206/setup.c
index 8f5c65d43d1d..7f4871c71a01 100644
--- a/arch/sh/boards/mach-se/7206/setup.c
+++ b/arch/sh/boards/mach-se/7206/setup.c
@@ -86,20 +86,5 @@ __initcall(se7206_devices_setup);
86static struct sh_machine_vector mv_se __initmv = { 86static struct sh_machine_vector mv_se __initmv = {
87 .mv_name = "SolutionEngine", 87 .mv_name = "SolutionEngine",
88 .mv_nr_irqs = 256, 88 .mv_nr_irqs = 256,
89 .mv_inb = se7206_inb,
90 .mv_inw = se7206_inw,
91 .mv_outb = se7206_outb,
92 .mv_outw = se7206_outw,
93
94 .mv_inb_p = se7206_inb_p,
95 .mv_inw_p = se7206_inw,
96 .mv_outb_p = se7206_outb_p,
97 .mv_outw_p = se7206_outw,
98
99 .mv_insb = se7206_insb,
100 .mv_insw = se7206_insw,
101 .mv_outsb = se7206_outsb,
102 .mv_outsw = se7206_outsw,
103
104 .mv_init_irq = init_se7206_IRQ, 89 .mv_init_irq = init_se7206_IRQ,
105}; 90};
diff --git a/arch/sh/boards/mach-se/7343/irq.c b/arch/sh/boards/mach-se/7343/irq.c
index d4305c26e9f7..76255a19417f 100644
--- a/arch/sh/boards/mach-se/7343/irq.c
+++ b/arch/sh/boards/mach-se/7343/irq.c
@@ -18,23 +18,22 @@
18 18
19unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, }; 19unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, };
20 20
21static void disable_se7343_irq(unsigned int irq) 21static void disable_se7343_irq(struct irq_data *data)
22{ 22{
23 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 23 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24 __raw_writew(__raw_readw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK); 24 __raw_writew(__raw_readw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK);
25} 25}
26 26
27static void enable_se7343_irq(unsigned int irq) 27static void enable_se7343_irq(struct irq_data *data)
28{ 28{
29 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
30 __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK); 30 __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK);
31} 31}
32 32
33static struct irq_chip se7343_irq_chip __read_mostly = { 33static struct irq_chip se7343_irq_chip __read_mostly = {
34 .name = "SE7343-FPGA", 34 .name = "SE7343-FPGA",
35 .mask = disable_se7343_irq, 35 .irq_mask = disable_se7343_irq,
36 .unmask = enable_se7343_irq, 36 .irq_unmask = enable_se7343_irq,
37 .mask_ack = disable_se7343_irq,
38}; 37};
39 38
40static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc) 39static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-se/770x/Makefile b/arch/sh/boards/mach-se/770x/Makefile
index 8e624b06d5ea..43ea14feef51 100644
--- a/arch/sh/boards/mach-se/770x/Makefile
+++ b/arch/sh/boards/mach-se/770x/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the 770x SolutionEngine specific parts of the kernel 2# Makefile for the 770x SolutionEngine specific parts of the kernel
3# 3#
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o irq.o
diff --git a/arch/sh/boards/mach-se/770x/io.c b/arch/sh/boards/mach-se/770x/io.c
deleted file mode 100644
index 28833c8786ea..000000000000
--- a/arch/sh/boards/mach-se/770x/io.c
+++ /dev/null
@@ -1,156 +0,0 @@
1/*
2 * Copyright (C) 2000 Kazumoto Kojima
3 *
4 * I/O routine for Hitachi SolutionEngine.
5 */
6#include <linux/kernel.h>
7#include <linux/types.h>
8#include <asm/io.h>
9#include <mach-se/mach/se.h>
10
11/* MS7750 requires special versions of in*, out* routines, since
12 PC-like io ports are located at upper half byte of 16-bit word which
13 can be accessed only with 16-bit wide. */
14
15static inline volatile __u16 *
16port2adr(unsigned int port)
17{
18 if (port & 0xff000000)
19 return ( volatile __u16 *) port;
20 if (port >= 0x2000)
21 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
22 else if (port >= 0x1000)
23 return (volatile __u16 *) (PA_83902 + (port << 1));
24 else
25 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
26}
27
28static inline int
29shifted_port(unsigned long port)
30{
31 /* For IDE registers, value is not shifted */
32 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
33 return 0;
34 else
35 return 1;
36}
37
38unsigned char se_inb(unsigned long port)
39{
40 if (shifted_port(port))
41 return (*port2adr(port) >> 8);
42 else
43 return (*port2adr(port))&0xff;
44}
45
46unsigned char se_inb_p(unsigned long port)
47{
48 unsigned long v;
49
50 if (shifted_port(port))
51 v = (*port2adr(port) >> 8);
52 else
53 v = (*port2adr(port))&0xff;
54 ctrl_delay();
55 return v;
56}
57
58unsigned short se_inw(unsigned long port)
59{
60 if (port >= 0x2000)
61 return *port2adr(port);
62 else
63 maybebadio(port);
64 return 0;
65}
66
67unsigned int se_inl(unsigned long port)
68{
69 maybebadio(port);
70 return 0;
71}
72
73void se_outb(unsigned char value, unsigned long port)
74{
75 if (shifted_port(port))
76 *(port2adr(port)) = value << 8;
77 else
78 *(port2adr(port)) = value;
79}
80
81void se_outb_p(unsigned char value, unsigned long port)
82{
83 if (shifted_port(port))
84 *(port2adr(port)) = value << 8;
85 else
86 *(port2adr(port)) = value;
87 ctrl_delay();
88}
89
90void se_outw(unsigned short value, unsigned long port)
91{
92 if (port >= 0x2000)
93 *port2adr(port) = value;
94 else
95 maybebadio(port);
96}
97
98void se_outl(unsigned int value, unsigned long port)
99{
100 maybebadio(port);
101}
102
103void se_insb(unsigned long port, void *addr, unsigned long count)
104{
105 volatile __u16 *p = port2adr(port);
106 __u8 *ap = addr;
107
108 if (shifted_port(port)) {
109 while (count--)
110 *ap++ = *p >> 8;
111 } else {
112 while (count--)
113 *ap++ = *p;
114 }
115}
116
117void se_insw(unsigned long port, void *addr, unsigned long count)
118{
119 volatile __u16 *p = port2adr(port);
120 __u16 *ap = addr;
121 while (count--)
122 *ap++ = *p;
123}
124
125void se_insl(unsigned long port, void *addr, unsigned long count)
126{
127 maybebadio(port);
128}
129
130void se_outsb(unsigned long port, const void *addr, unsigned long count)
131{
132 volatile __u16 *p = port2adr(port);
133 const __u8 *ap = addr;
134
135 if (shifted_port(port)) {
136 while (count--)
137 *p = *ap++ << 8;
138 } else {
139 while (count--)
140 *p = *ap++;
141 }
142}
143
144void se_outsw(unsigned long port, const void *addr, unsigned long count)
145{
146 volatile __u16 *p = port2adr(port);
147 const __u16 *ap = addr;
148
149 while (count--)
150 *p = *ap++;
151}
152
153void se_outsl(unsigned long port, const void *addr, unsigned long count)
154{
155 maybebadio(port);
156}
diff --git a/arch/sh/boards/mach-se/770x/setup.c b/arch/sh/boards/mach-se/770x/setup.c
index 66d39d1b0901..31330c65c0ce 100644
--- a/arch/sh/boards/mach-se/770x/setup.c
+++ b/arch/sh/boards/mach-se/770x/setup.c
@@ -195,27 +195,5 @@ static struct sh_machine_vector mv_se __initmv = {
195#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) 195#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
196 .mv_nr_irqs = 104, 196 .mv_nr_irqs = 104,
197#endif 197#endif
198
199 .mv_inb = se_inb,
200 .mv_inw = se_inw,
201 .mv_inl = se_inl,
202 .mv_outb = se_outb,
203 .mv_outw = se_outw,
204 .mv_outl = se_outl,
205
206 .mv_inb_p = se_inb_p,
207 .mv_inw_p = se_inw,
208 .mv_inl_p = se_inl,
209 .mv_outb_p = se_outb_p,
210 .mv_outw_p = se_outw,
211 .mv_outl_p = se_outl,
212
213 .mv_insb = se_insb,
214 .mv_insw = se_insw,
215 .mv_insl = se_insl,
216 .mv_outsb = se_outsb,
217 .mv_outsw = se_outsw,
218 .mv_outsl = se_outsl,
219
220 .mv_init_irq = init_se_IRQ, 198 .mv_init_irq = init_se_IRQ,
221}; 199};
diff --git a/arch/sh/boards/mach-se/7722/irq.c b/arch/sh/boards/mach-se/7722/irq.c
index 61605db04ee6..c013f95628ed 100644
--- a/arch/sh/boards/mach-se/7722/irq.c
+++ b/arch/sh/boards/mach-se/7722/irq.c
@@ -18,23 +18,22 @@
18 18
19unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, }; 19unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, };
20 20
21static void disable_se7722_irq(unsigned int irq) 21static void disable_se7722_irq(struct irq_data *data)
22{ 22{
23 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 23 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24 __raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK); 24 __raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
25} 25}
26 26
27static void enable_se7722_irq(unsigned int irq) 27static void enable_se7722_irq(struct irq_data *data)
28{ 28{
29 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
30 __raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK); 30 __raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
31} 31}
32 32
33static struct irq_chip se7722_irq_chip __read_mostly = { 33static struct irq_chip se7722_irq_chip __read_mostly = {
34 .name = "SE7722-FPGA", 34 .name = "SE7722-FPGA",
35 .mask = disable_se7722_irq, 35 .irq_mask = disable_se7722_irq,
36 .unmask = enable_se7722_irq, 36 .irq_unmask = enable_se7722_irq,
37 .mask_ack = disable_se7722_irq,
38}; 37};
39 38
40static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc) 39static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-se/7724/irq.c b/arch/sh/boards/mach-se/7724/irq.c
index 0942be2daef6..5bd87c22b65b 100644
--- a/arch/sh/boards/mach-se/7724/irq.c
+++ b/arch/sh/boards/mach-se/7724/irq.c
@@ -68,25 +68,26 @@ static struct fpga_irq get_fpga_irq(unsigned int irq)
68 return set; 68 return set;
69} 69}
70 70
71static void disable_se7724_irq(unsigned int irq) 71static void disable_se7724_irq(struct irq_data *data)
72{ 72{
73 unsigned int irq = data->irq;
73 struct fpga_irq set = get_fpga_irq(fpga2irq(irq)); 74 struct fpga_irq set = get_fpga_irq(fpga2irq(irq));
74 unsigned int bit = irq - set.base; 75 unsigned int bit = irq - set.base;
75 __raw_writew(__raw_readw(set.mraddr) | 0x0001 << bit, set.mraddr); 76 __raw_writew(__raw_readw(set.mraddr) | 0x0001 << bit, set.mraddr);
76} 77}
77 78
78static void enable_se7724_irq(unsigned int irq) 79static void enable_se7724_irq(struct irq_data *data)
79{ 80{
81 unsigned int irq = data->irq;
80 struct fpga_irq set = get_fpga_irq(fpga2irq(irq)); 82 struct fpga_irq set = get_fpga_irq(fpga2irq(irq));
81 unsigned int bit = irq - set.base; 83 unsigned int bit = irq - set.base;
82 __raw_writew(__raw_readw(set.mraddr) & ~(0x0001 << bit), set.mraddr); 84 __raw_writew(__raw_readw(set.mraddr) & ~(0x0001 << bit), set.mraddr);
83} 85}
84 86
85static struct irq_chip se7724_irq_chip __read_mostly = { 87static struct irq_chip se7724_irq_chip __read_mostly = {
86 .name = "SE7724-FPGA", 88 .name = "SE7724-FPGA",
87 .mask = disable_se7724_irq, 89 .irq_mask = disable_se7724_irq,
88 .unmask = enable_se7724_irq, 90 .irq_unmask = enable_se7724_irq,
89 .mask_ack = disable_se7724_irq,
90}; 91};
91 92
92static void se7724_irq_demux(unsigned int irq, struct irq_desc *desc) 93static void se7724_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 552ebd9ba82b..c31d228fdfc6 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -144,16 +144,42 @@ static struct platform_device nor_flash_device = {
144}; 144};
145 145
146/* LCDC */ 146/* LCDC */
147const static struct fb_videomode lcdc_720p_modes[] = {
148 {
149 .name = "LB070WV1",
150 .sync = 0, /* hsync and vsync are active low */
151 .xres = 1280,
152 .yres = 720,
153 .left_margin = 220,
154 .right_margin = 110,
155 .hsync_len = 40,
156 .upper_margin = 20,
157 .lower_margin = 5,
158 .vsync_len = 5,
159 },
160};
161
162const static struct fb_videomode lcdc_vga_modes[] = {
163 {
164 .name = "LB070WV1",
165 .sync = 0, /* hsync and vsync are active low */
166 .xres = 640,
167 .yres = 480,
168 .left_margin = 105,
169 .right_margin = 50,
170 .hsync_len = 96,
171 .upper_margin = 33,
172 .lower_margin = 10,
173 .vsync_len = 2,
174 },
175};
176
147static struct sh_mobile_lcdc_info lcdc_info = { 177static struct sh_mobile_lcdc_info lcdc_info = {
148 .clock_source = LCDC_CLK_EXTERNAL, 178 .clock_source = LCDC_CLK_EXTERNAL,
149 .ch[0] = { 179 .ch[0] = {
150 .chan = LCDC_CHAN_MAINLCD, 180 .chan = LCDC_CHAN_MAINLCD,
151 .bpp = 16, 181 .bpp = 16,
152 .clock_divider = 1, 182 .clock_divider = 1,
153 .lcd_cfg = {
154 .name = "LB070WV1",
155 .sync = 0, /* hsync and vsync are active low */
156 },
157 .lcd_size_cfg = { /* 7.0 inch */ 183 .lcd_size_cfg = { /* 7.0 inch */
158 .width = 152, 184 .width = 152,
159 .height = 91, 185 .height = 91,
@@ -550,7 +576,6 @@ static struct sh_vou_pdata sh_vou_pdata = {
550 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW, 576 .flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW,
551 .board_info = &ak8813, 577 .board_info = &ak8813,
552 .i2c_adap = 0, 578 .i2c_adap = 0,
553 .module_name = "ak881x",
554}; 579};
555 580
556static struct resource sh_vou_resources[] = { 581static struct resource sh_vou_resources[] = {
@@ -909,24 +934,12 @@ static int __init devices_setup(void)
909 934
910 if (sw & SW41_B) { 935 if (sw & SW41_B) {
911 /* 720p */ 936 /* 720p */
912 lcdc_info.ch[0].lcd_cfg.xres = 1280; 937 lcdc_info.ch[0].lcd_cfg = lcdc_720p_modes;
913 lcdc_info.ch[0].lcd_cfg.yres = 720; 938 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_720p_modes);
914 lcdc_info.ch[0].lcd_cfg.left_margin = 220;
915 lcdc_info.ch[0].lcd_cfg.right_margin = 110;
916 lcdc_info.ch[0].lcd_cfg.hsync_len = 40;
917 lcdc_info.ch[0].lcd_cfg.upper_margin = 20;
918 lcdc_info.ch[0].lcd_cfg.lower_margin = 5;
919 lcdc_info.ch[0].lcd_cfg.vsync_len = 5;
920 } else { 939 } else {
921 /* VGA */ 940 /* VGA */
922 lcdc_info.ch[0].lcd_cfg.xres = 640; 941 lcdc_info.ch[0].lcd_cfg = lcdc_vga_modes;
923 lcdc_info.ch[0].lcd_cfg.yres = 480; 942 lcdc_info.ch[0].num_cfg = ARRAY_SIZE(lcdc_vga_modes);
924 lcdc_info.ch[0].lcd_cfg.left_margin = 105;
925 lcdc_info.ch[0].lcd_cfg.right_margin = 50;
926 lcdc_info.ch[0].lcd_cfg.hsync_len = 96;
927 lcdc_info.ch[0].lcd_cfg.upper_margin = 33;
928 lcdc_info.ch[0].lcd_cfg.lower_margin = 10;
929 lcdc_info.ch[0].lcd_cfg.vsync_len = 2;
930 } 943 }
931 944
932 if (sw & SW41_A) { 945 if (sw & SW41_A) {
diff --git a/arch/sh/boards/mach-se/7751/Makefile b/arch/sh/boards/mach-se/7751/Makefile
index e6f4341bfe6e..a338fd9d5039 100644
--- a/arch/sh/boards/mach-se/7751/Makefile
+++ b/arch/sh/boards/mach-se/7751/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the 7751 SolutionEngine specific parts of the kernel 2# Makefile for the 7751 SolutionEngine specific parts of the kernel
3# 3#
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o irq.o
diff --git a/arch/sh/boards/mach-se/7751/io.c b/arch/sh/boards/mach-se/7751/io.c
deleted file mode 100644
index 6e75bd4459e5..000000000000
--- a/arch/sh/boards/mach-se/7751/io.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
3 * Based largely on io_se.c.
4 *
5 * I/O routine for Hitachi 7751 SolutionEngine.
6 *
7 * Initial version only to support LAN access; some
8 * placeholder code from io_se.c left in with the
9 * expectation of later SuperIO and PCMCIA access.
10 */
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/pci.h>
14#include <asm/io.h>
15#include <mach-se/mach/se7751.h>
16#include <asm/addrspace.h>
17
18static inline volatile u16 *port2adr(unsigned int port)
19{
20 if (port >= 0x2000)
21 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
22 maybebadio((unsigned long)port);
23 return (volatile __u16*)port;
24}
25
26/*
27 * General outline: remap really low stuff [eventually] to SuperIO,
28 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
29 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
30 * should be way beyond the window, and is used w/o translation for
31 * compatibility.
32 */
33unsigned char sh7751se_inb(unsigned long port)
34{
35 if (PXSEG(port))
36 return *(volatile unsigned char *)port;
37 else
38 return (*port2adr(port)) & 0xff;
39}
40
41unsigned char sh7751se_inb_p(unsigned long port)
42{
43 unsigned char v;
44
45 if (PXSEG(port))
46 v = *(volatile unsigned char *)port;
47 else
48 v = (*port2adr(port)) & 0xff;
49 ctrl_delay();
50 return v;
51}
52
53unsigned short sh7751se_inw(unsigned long port)
54{
55 if (PXSEG(port))
56 return *(volatile unsigned short *)port;
57 else if (port >= 0x2000)
58 return *port2adr(port);
59 else
60 maybebadio(port);
61 return 0;
62}
63
64unsigned int sh7751se_inl(unsigned long port)
65{
66 if (PXSEG(port))
67 return *(volatile unsigned long *)port;
68 else if (port >= 0x2000)
69 return *port2adr(port);
70 else
71 maybebadio(port);
72 return 0;
73}
74
75void sh7751se_outb(unsigned char value, unsigned long port)
76{
77
78 if (PXSEG(port))
79 *(volatile unsigned char *)port = value;
80 else
81 *(port2adr(port)) = value;
82}
83
84void sh7751se_outb_p(unsigned char value, unsigned long port)
85{
86 if (PXSEG(port))
87 *(volatile unsigned char *)port = value;
88 else
89 *(port2adr(port)) = value;
90 ctrl_delay();
91}
92
93void sh7751se_outw(unsigned short value, unsigned long port)
94{
95 if (PXSEG(port))
96 *(volatile unsigned short *)port = value;
97 else if (port >= 0x2000)
98 *port2adr(port) = value;
99 else
100 maybebadio(port);
101}
102
103void sh7751se_outl(unsigned int value, unsigned long port)
104{
105 if (PXSEG(port))
106 *(volatile unsigned long *)port = value;
107 else
108 maybebadio(port);
109}
110
111void sh7751se_insl(unsigned long port, void *addr, unsigned long count)
112{
113 maybebadio(port);
114}
115
116void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count)
117{
118 maybebadio(port);
119}
diff --git a/arch/sh/boards/mach-se/7751/setup.c b/arch/sh/boards/mach-se/7751/setup.c
index 50572512e3e8..9fbc51beb181 100644
--- a/arch/sh/boards/mach-se/7751/setup.c
+++ b/arch/sh/boards/mach-se/7751/setup.c
@@ -56,23 +56,5 @@ __initcall(se7751_devices_setup);
56static struct sh_machine_vector mv_7751se __initmv = { 56static struct sh_machine_vector mv_7751se __initmv = {
57 .mv_name = "7751 SolutionEngine", 57 .mv_name = "7751 SolutionEngine",
58 .mv_nr_irqs = 72, 58 .mv_nr_irqs = 72,
59
60 .mv_inb = sh7751se_inb,
61 .mv_inw = sh7751se_inw,
62 .mv_inl = sh7751se_inl,
63 .mv_outb = sh7751se_outb,
64 .mv_outw = sh7751se_outw,
65 .mv_outl = sh7751se_outl,
66
67 .mv_inb_p = sh7751se_inb_p,
68 .mv_inw_p = sh7751se_inw,
69 .mv_inl_p = sh7751se_inl,
70 .mv_outb_p = sh7751se_outb_p,
71 .mv_outw_p = sh7751se_outw,
72 .mv_outl_p = sh7751se_outl,
73
74 .mv_insl = sh7751se_insl,
75 .mv_outsl = sh7751se_outsl,
76
77 .mv_init_irq = init_7751se_IRQ, 59 .mv_init_irq = init_7751se_IRQ,
78}; 60};
diff --git a/arch/sh/boards/mach-snapgear/Makefile b/arch/sh/boards/mach-snapgear/Makefile
deleted file mode 100644
index d2d2f4b6a502..000000000000
--- a/arch/sh/boards/mach-snapgear/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the SnapGear specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/mach-snapgear/io.c b/arch/sh/boards/mach-snapgear/io.c
deleted file mode 100644
index 476650e42dbc..000000000000
--- a/arch/sh/boards/mach-snapgear/io.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
3 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
4 * Based largely on io_se.c.
5 *
6 * I/O routine for Hitachi 7751 SolutionEngine.
7 *
8 * Initial version only to support LAN access; some
9 * placeholder code from io_se.c left in with the
10 * expectation of later SuperIO and PCMCIA access.
11 */
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/pci.h>
15#include <asm/io.h>
16#include <asm/addrspace.h>
17
18#ifdef CONFIG_SH_SECUREEDGE5410
19unsigned short secureedge5410_ioport;
20#endif
21
22static inline volatile __u16 *port2adr(unsigned int port)
23{
24 maybebadio((unsigned long)port);
25 return (volatile __u16*)port;
26}
27
28/*
29 * General outline: remap really low stuff [eventually] to SuperIO,
30 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
31 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
32 * should be way beyond the window, and is used w/o translation for
33 * compatibility.
34 */
35unsigned char snapgear_inb(unsigned long port)
36{
37 if (PXSEG(port))
38 return *(volatile unsigned char *)port;
39 else
40 return (*port2adr(port)) & 0xff;
41}
42
43unsigned char snapgear_inb_p(unsigned long port)
44{
45 unsigned char v;
46
47 if (PXSEG(port))
48 v = *(volatile unsigned char *)port;
49 else
50 v = (*port2adr(port))&0xff;
51 ctrl_delay();
52 return v;
53}
54
55unsigned short snapgear_inw(unsigned long port)
56{
57 if (PXSEG(port))
58 return *(volatile unsigned short *)port;
59 else if (port >= 0x2000)
60 return *port2adr(port);
61 else
62 maybebadio(port);
63 return 0;
64}
65
66unsigned int snapgear_inl(unsigned long port)
67{
68 if (PXSEG(port))
69 return *(volatile unsigned long *)port;
70 else if (port >= 0x2000)
71 return *port2adr(port);
72 else
73 maybebadio(port);
74 return 0;
75}
76
77void snapgear_outb(unsigned char value, unsigned long port)
78{
79
80 if (PXSEG(port))
81 *(volatile unsigned char *)port = value;
82 else
83 *(port2adr(port)) = value;
84}
85
86void snapgear_outb_p(unsigned char value, unsigned long port)
87{
88 if (PXSEG(port))
89 *(volatile unsigned char *)port = value;
90 else
91 *(port2adr(port)) = value;
92 ctrl_delay();
93}
94
95void snapgear_outw(unsigned short value, unsigned long port)
96{
97 if (PXSEG(port))
98 *(volatile unsigned short *)port = value;
99 else if (port >= 0x2000)
100 *port2adr(port) = value;
101 else
102 maybebadio(port);
103}
104
105void snapgear_outl(unsigned int value, unsigned long port)
106{
107 if (PXSEG(port))
108 *(volatile unsigned long *)port = value;
109 else
110 maybebadio(port);
111}
112
113void snapgear_insl(unsigned long port, void *addr, unsigned long count)
114{
115 maybebadio(port);
116}
117
118void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
119{
120 maybebadio(port);
121}
diff --git a/arch/sh/boards/mach-systemh/Makefile b/arch/sh/boards/mach-systemh/Makefile
deleted file mode 100644
index 2cc6a23d9d39..000000000000
--- a/arch/sh/boards/mach-systemh/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
1#
2# Makefile for the SystemH specific parts of the kernel
3#
4
5obj-y := setup.o irq.o io.o
6
7# XXX: This wants to be consolidated in arch/sh/drivers/pci, and more
8# importantly, with the generic sh7751_pcic_init() code. For now, we'll
9# just abuse the hell out of kbuild, because we can..
10
11obj-$(CONFIG_PCI) += pci.o
12pci-y := ../../se/7751/pci.o
13
diff --git a/arch/sh/boards/mach-systemh/io.c b/arch/sh/boards/mach-systemh/io.c
deleted file mode 100644
index 15577ff1f715..000000000000
--- a/arch/sh/boards/mach-systemh/io.c
+++ /dev/null
@@ -1,158 +0,0 @@
1/*
2 * linux/arch/sh/boards/renesas/systemh/io.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
6 *
7 * I/O routine for Hitachi 7751 Systemh.
8 */
9#include <linux/kernel.h>
10#include <linux/types.h>
11#include <linux/pci.h>
12#include <mach/systemh7751.h>
13#include <asm/addrspace.h>
14#include <asm/io.h>
15
16#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
17 of smc lan chip*/
18static inline volatile __u16 *
19port2adr(unsigned int port)
20{
21 if (port >= 0x2000)
22 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
23 maybebadio((unsigned long)port);
24 return (volatile __u16*)port;
25}
26
27/*
28 * General outline: remap really low stuff [eventually] to SuperIO,
29 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
30 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
31 * should be way beyond the window, and is used w/o translation for
32 * compatibility.
33 */
34unsigned char sh7751systemh_inb(unsigned long port)
35{
36 if (PXSEG(port))
37 return *(volatile unsigned char *)port;
38 else if (port <= 0x3F1)
39 return *(volatile unsigned char *)ETHER_IOMAP(port);
40 else
41 return (*port2adr(port))&0xff;
42}
43
44unsigned char sh7751systemh_inb_p(unsigned long port)
45{
46 unsigned char v;
47
48 if (PXSEG(port))
49 v = *(volatile unsigned char *)port;
50 else if (port <= 0x3F1)
51 v = *(volatile unsigned char *)ETHER_IOMAP(port);
52 else
53 v = (*port2adr(port))&0xff;
54 ctrl_delay();
55 return v;
56}
57
58unsigned short sh7751systemh_inw(unsigned long port)
59{
60 if (PXSEG(port))
61 return *(volatile unsigned short *)port;
62 else if (port >= 0x2000)
63 return *port2adr(port);
64 else if (port <= 0x3F1)
65 return *(volatile unsigned int *)ETHER_IOMAP(port);
66 else
67 maybebadio(port);
68 return 0;
69}
70
71unsigned int sh7751systemh_inl(unsigned long port)
72{
73 if (PXSEG(port))
74 return *(volatile unsigned long *)port;
75 else if (port >= 0x2000)
76 return *port2adr(port);
77 else if (port <= 0x3F1)
78 return *(volatile unsigned int *)ETHER_IOMAP(port);
79 else
80 maybebadio(port);
81 return 0;
82}
83
84void sh7751systemh_outb(unsigned char value, unsigned long port)
85{
86
87 if (PXSEG(port))
88 *(volatile unsigned char *)port = value;
89 else if (port <= 0x3F1)
90 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
91 else
92 *(port2adr(port)) = value;
93}
94
95void sh7751systemh_outb_p(unsigned char value, unsigned long port)
96{
97 if (PXSEG(port))
98 *(volatile unsigned char *)port = value;
99 else if (port <= 0x3F1)
100 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
101 else
102 *(port2adr(port)) = value;
103 ctrl_delay();
104}
105
106void sh7751systemh_outw(unsigned short value, unsigned long port)
107{
108 if (PXSEG(port))
109 *(volatile unsigned short *)port = value;
110 else if (port >= 0x2000)
111 *port2adr(port) = value;
112 else if (port <= 0x3F1)
113 *(volatile unsigned short *)ETHER_IOMAP(port) = value;
114 else
115 maybebadio(port);
116}
117
118void sh7751systemh_outl(unsigned int value, unsigned long port)
119{
120 if (PXSEG(port))
121 *(volatile unsigned long *)port = value;
122 else
123 maybebadio(port);
124}
125
126void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
127{
128 unsigned char *p = addr;
129 while (count--) *p++ = sh7751systemh_inb(port);
130}
131
132void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
133{
134 unsigned short *p = addr;
135 while (count--) *p++ = sh7751systemh_inw(port);
136}
137
138void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
139{
140 maybebadio(port);
141}
142
143void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
144{
145 unsigned char *p = (unsigned char*)addr;
146 while (count--) sh7751systemh_outb(*p++, port);
147}
148
149void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count)
150{
151 unsigned short *p = (unsigned short*)addr;
152 while (count--) sh7751systemh_outw(*p++, port);
153}
154
155void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
156{
157 maybebadio(port);
158}
diff --git a/arch/sh/boards/mach-systemh/irq.c b/arch/sh/boards/mach-systemh/irq.c
deleted file mode 100644
index 523aea5dc94e..000000000000
--- a/arch/sh/boards/mach-systemh/irq.c
+++ /dev/null
@@ -1,76 +0,0 @@
1/*
2 * linux/arch/sh/boards/renesas/systemh/irq.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Hitachi SystemH Support.
7 *
8 * Modified for 7751 SystemH by
9 * Jonathan Short.
10 */
11
12#include <linux/init.h>
13#include <linux/irq.h>
14#include <linux/interrupt.h>
15#include <linux/io.h>
16
17#include <mach/systemh7751.h>
18#include <asm/smc37c93x.h>
19
20/* address of external interrupt mask register
21 * address must be set prior to use these (maybe in init_XXX_irq())
22 * XXX : is it better to use .config than specifying it in code? */
23static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
24static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
25
26/* forward declaration */
27static void enable_systemh_irq(unsigned int irq);
28static void disable_systemh_irq(unsigned int irq);
29static void mask_and_ack_systemh(unsigned int);
30
31static struct irq_chip systemh_irq_type = {
32 .name = " SystemH Register",
33 .unmask = enable_systemh_irq,
34 .mask = disable_systemh_irq,
35 .ack = mask_and_ack_systemh,
36};
37
38static void disable_systemh_irq(unsigned int irq)
39{
40 if (systemh_irq_mask_register) {
41 unsigned long val, mask = 0x01 << 1;
42
43 /* Clear the "irq"th bit in the mask and set it in the request */
44 val = __raw_readl((unsigned long)systemh_irq_mask_register);
45 val &= ~mask;
46 __raw_writel(val, (unsigned long)systemh_irq_mask_register);
47
48 val = __raw_readl((unsigned long)systemh_irq_request_register);
49 val |= mask;
50 __raw_writel(val, (unsigned long)systemh_irq_request_register);
51 }
52}
53
54static void enable_systemh_irq(unsigned int irq)
55{
56 if (systemh_irq_mask_register) {
57 unsigned long val, mask = 0x01 << 1;
58
59 /* Set "irq"th bit in the mask register */
60 val = __raw_readl((unsigned long)systemh_irq_mask_register);
61 val |= mask;
62 __raw_writel(val, (unsigned long)systemh_irq_mask_register);
63 }
64}
65
66static void mask_and_ack_systemh(unsigned int irq)
67{
68 disable_systemh_irq(irq);
69}
70
71void make_systemh_irq(unsigned int irq)
72{
73 disable_irq_nosync(irq);
74 set_irq_chip_and_handler(irq, &systemh_irq_type, handle_level_irq);
75 disable_systemh_irq(irq);
76}
diff --git a/arch/sh/boards/mach-systemh/setup.c b/arch/sh/boards/mach-systemh/setup.c
deleted file mode 100644
index 219fd800a43f..000000000000
--- a/arch/sh/boards/mach-systemh/setup.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * linux/arch/sh/boards/renesas/systemh/setup.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 * Copyright (C) 2003 Paul Mundt
6 *
7 * Hitachi SystemH Support.
8 *
9 * Modified for 7751 SystemH by Jonathan Short.
10 *
11 * Rewritten for 2.6 by Paul Mundt.
12 *
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
16 */
17#include <linux/init.h>
18#include <asm/machvec.h>
19#include <mach/systemh7751.h>
20
21extern void make_systemh_irq(unsigned int irq);
22
23/*
24 * Initialize IRQ setting
25 */
26static void __init sh7751systemh_init_irq(void)
27{
28 make_systemh_irq(0xb); /* Ethernet interrupt */
29}
30
31static struct sh_machine_vector mv_7751systemh __initmv = {
32 .mv_name = "7751 SystemH",
33 .mv_nr_irqs = 72,
34
35 .mv_inb = sh7751systemh_inb,
36 .mv_inw = sh7751systemh_inw,
37 .mv_inl = sh7751systemh_inl,
38 .mv_outb = sh7751systemh_outb,
39 .mv_outw = sh7751systemh_outw,
40 .mv_outl = sh7751systemh_outl,
41
42 .mv_inb_p = sh7751systemh_inb_p,
43 .mv_inw_p = sh7751systemh_inw,
44 .mv_inl_p = sh7751systemh_inl,
45 .mv_outb_p = sh7751systemh_outb_p,
46 .mv_outw_p = sh7751systemh_outw,
47 .mv_outl_p = sh7751systemh_outl,
48
49 .mv_insb = sh7751systemh_insb,
50 .mv_insw = sh7751systemh_insw,
51 .mv_insl = sh7751systemh_insl,
52 .mv_outsb = sh7751systemh_outsb,
53 .mv_outsw = sh7751systemh_outsw,
54 .mv_outsl = sh7751systemh_outsl,
55
56 .mv_init_irq = sh7751systemh_init_irq,
57};
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..239e74066253
--- /dev/null
+++ b/arch/sh/boards/mach-x3proto/gpio.c
@@ -0,0 +1,136 @@
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_data *data = irq_get_irq_data(irq);
58 struct irq_chip *chip = irq_data_get_irq_chip(data);
59 unsigned long mask;
60 int pin;
61
62 chip->irq_mask_ack(data);
63
64 mask = __raw_readw(KEYDETR);
65
66 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS)
67 generic_handle_irq(x3proto_gpio_to_irq(NULL, pin));
68
69 chip->irq_unmask(data);
70}
71
72struct gpio_chip x3proto_gpio_chip = {
73 .label = "x3proto-gpio",
74 .direction_input = x3proto_gpio_direction_input,
75 .get = x3proto_gpio_get,
76 .to_irq = x3proto_gpio_to_irq,
77 .base = -1,
78 .ngpio = NR_BASEBOARD_GPIOS,
79};
80
81int __init x3proto_gpio_setup(void)
82{
83 int ilsel;
84 int ret, i;
85
86 ilsel = ilsel_enable(ILSEL_KEY);
87 if (unlikely(ilsel < 0))
88 return ilsel;
89
90 ret = gpiochip_add(&x3proto_gpio_chip);
91 if (unlikely(ret))
92 goto err_gpio;
93
94 for (i = 0; i < NR_BASEBOARD_GPIOS; i++) {
95 unsigned long flags;
96 int irq = create_irq();
97
98 if (unlikely(irq < 0)) {
99 ret = -EINVAL;
100 goto err_irq;
101 }
102
103 spin_lock_irqsave(&x3proto_gpio_lock, flags);
104 x3proto_gpio_irq_map[i] = irq;
105 set_irq_chip_and_handler_name(irq, &dummy_irq_chip,
106 handle_simple_irq, "gpio");
107 spin_unlock_irqrestore(&x3proto_gpio_lock, flags);
108 }
109
110 pr_info("registering '%s' support, handling GPIOs %u -> %u, "
111 "bound to IRQ %u\n",
112 x3proto_gpio_chip.label, x3proto_gpio_chip.base,
113 x3proto_gpio_chip.base + x3proto_gpio_chip.ngpio,
114 ilsel);
115
116 set_irq_chained_handler(ilsel, x3proto_gpio_irq_handler);
117 set_irq_wake(ilsel, 1);
118
119 return 0;
120
121err_irq:
122 for (; i >= 0; --i)
123 if (x3proto_gpio_irq_map[i])
124 destroy_irq(x3proto_gpio_irq_map[i]);
125
126 ret = gpiochip_remove(&x3proto_gpio_chip);
127 if (unlikely(ret))
128 pr_err("Failed deregistering GPIO\n");
129
130err_gpio:
131 synchronize_irq(ilsel);
132
133 ilsel_disable(ILSEL_KEY);
134
135 return ret;
136}
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/cchips/hd6446x/hd64461.c b/arch/sh/cchips/hd6446x/hd64461.c
index bcb31ae84a51..177a10b25cad 100644
--- a/arch/sh/cchips/hd6446x/hd64461.c
+++ b/arch/sh/cchips/hd6446x/hd64461.c
@@ -17,8 +17,9 @@
17/* This belongs in cpu specific */ 17/* This belongs in cpu specific */
18#define INTC_ICR1 0xA4140010UL 18#define INTC_ICR1 0xA4140010UL
19 19
20static void hd64461_mask_irq(unsigned int irq) 20static void hd64461_mask_irq(struct irq_data *data)
21{ 21{
22 unsigned int irq = data->irq;
22 unsigned short nimr; 23 unsigned short nimr;
23 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 24 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
24 25
@@ -27,8 +28,9 @@ static void hd64461_mask_irq(unsigned int irq)
27 __raw_writew(nimr, HD64461_NIMR); 28 __raw_writew(nimr, HD64461_NIMR);
28} 29}
29 30
30static void hd64461_unmask_irq(unsigned int irq) 31static void hd64461_unmask_irq(struct irq_data *data)
31{ 32{
33 unsigned int irq = data->irq;
32 unsigned short nimr; 34 unsigned short nimr;
33 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 35 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
34 36
@@ -37,20 +39,21 @@ static void hd64461_unmask_irq(unsigned int irq)
37 __raw_writew(nimr, HD64461_NIMR); 39 __raw_writew(nimr, HD64461_NIMR);
38} 40}
39 41
40static void hd64461_mask_and_ack_irq(unsigned int irq) 42static void hd64461_mask_and_ack_irq(struct irq_data *data)
41{ 43{
42 hd64461_mask_irq(irq); 44 hd64461_mask_irq(data);
45
43#ifdef CONFIG_HD64461_ENABLER 46#ifdef CONFIG_HD64461_ENABLER
44 if (irq == HD64461_IRQBASE + 13) 47 if (data->irq == HD64461_IRQBASE + 13)
45 __raw_writeb(0x00, HD64461_PCC1CSCR); 48 __raw_writeb(0x00, HD64461_PCC1CSCR);
46#endif 49#endif
47} 50}
48 51
49static struct irq_chip hd64461_irq_chip = { 52static struct irq_chip hd64461_irq_chip = {
50 .name = "HD64461-IRQ", 53 .name = "HD64461-IRQ",
51 .mask = hd64461_mask_irq, 54 .irq_mask = hd64461_mask_irq,
52 .mask_ack = hd64461_mask_and_ack_irq, 55 .irq_mask_ack = hd64461_mask_and_ack_irq,
53 .unmask = hd64461_unmask_irq, 56 .irq_unmask = hd64461_unmask_irq,
54}; 57};
55 58
56static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc) 59static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
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/snapgear_defconfig b/arch/sh/configs/secureedge5410_defconfig
index f38c98341f15..7eae4e59d7f0 100644
--- a/arch/sh/configs/snapgear_defconfig
+++ b/arch/sh/configs/secureedge5410_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/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/systemh_defconfig b/arch/sh/configs/systemh_defconfig
deleted file mode 100644
index 7007d00c67e0..000000000000
--- a/arch/sh/configs/systemh_defconfig
+++ /dev/null
@@ -1,29 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_LOG_BUF_SHIFT=14
3CONFIG_SYSFS_DEPRECATED_V2=y
4CONFIG_BLK_DEV_INITRD=y
5# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
6# CONFIG_SYSCTL_SYSCALL is not set
7# CONFIG_HOTPLUG is not set
8CONFIG_SLAB=y
9CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y
11# CONFIG_BLK_DEV_BSG is not set
12CONFIG_CPU_SUBTYPE_SH7751R=y
13CONFIG_MEMORY_START=0x0c000000
14CONFIG_MEMORY_SIZE=0x00400000
15CONFIG_FLATMEM_MANUAL=y
16CONFIG_SH_7751_SYSTEMH=y
17CONFIG_PREEMPT=y
18# CONFIG_STANDALONE is not set
19CONFIG_BLK_DEV_RAM=y
20CONFIG_BLK_DEV_RAM_SIZE=1024
21# CONFIG_INPUT is not set
22# CONFIG_SERIO_SERPORT is not set
23# CONFIG_VT is not set
24CONFIG_HW_RANDOM=y
25CONFIG_PROC_KCORE=y
26CONFIG_TMPFS=y
27CONFIG_CRAMFS=y
28CONFIG_ROMFS_FS=y
29# CONFIG_RCU_CPU_STALL_DETECTOR 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/addrspace.h b/arch/sh/include/asm/addrspace.h
index 446b3831c214..3d1ae2bfaa6f 100644
--- a/arch/sh/include/asm/addrspace.h
+++ b/arch/sh/include/asm/addrspace.h
@@ -44,10 +44,10 @@
44/* 44/*
45 * These will never work in 32-bit, don't even bother. 45 * These will never work in 32-bit, don't even bother.
46 */ 46 */
47#define P1SEGADDR(a) __futile_remapping_attempt 47#define P1SEGADDR(a) ({ (void)(a); BUG(); NULL; })
48#define P2SEGADDR(a) __futile_remapping_attempt 48#define P2SEGADDR(a) ({ (void)(a); BUG(); NULL; })
49#define P3SEGADDR(a) __futile_remapping_attempt 49#define P3SEGADDR(a) ({ (void)(a); BUG(); NULL; })
50#define P4SEGADDR(a) __futile_remapping_attempt 50#define P4SEGADDR(a) ({ (void)(a); BUG(); NULL; })
51#endif 51#endif
52#endif /* P1SEG */ 52#endif /* P1SEG */
53 53
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/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/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/pgtable.h b/arch/sh/include/asm/pgtable.h
index 02f77450cd8f..083ea068e819 100644
--- a/arch/sh/include/asm/pgtable.h
+++ b/arch/sh/include/asm/pgtable.h
@@ -66,7 +66,6 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
66#define PHYS_ADDR_MASK29 0x1fffffff 66#define PHYS_ADDR_MASK29 0x1fffffff
67#define PHYS_ADDR_MASK32 0xffffffff 67#define PHYS_ADDR_MASK32 0xffffffff
68 68
69#ifdef CONFIG_PMB
70static inline unsigned long phys_addr_mask(void) 69static inline unsigned long phys_addr_mask(void)
71{ 70{
72 /* Is the MMU in 29bit mode? */ 71 /* Is the MMU in 29bit mode? */
@@ -75,17 +74,6 @@ static inline unsigned long phys_addr_mask(void)
75 74
76 return PHYS_ADDR_MASK32; 75 return PHYS_ADDR_MASK32;
77} 76}
78#elif defined(CONFIG_32BIT)
79static inline unsigned long phys_addr_mask(void)
80{
81 return PHYS_ADDR_MASK32;
82}
83#else
84static inline unsigned long phys_addr_mask(void)
85{
86 return PHYS_ADDR_MASK29;
87}
88#endif
89 77
90#define PTE_PHYS_MASK (phys_addr_mask() & PAGE_MASK) 78#define PTE_PHYS_MASK (phys_addr_mask() & PAGE_MASK)
91#define PTE_FLAGS_MASK (~(PTE_PHYS_MASK) << PAGE_SHIFT) 79#define PTE_FLAGS_MASK (~(PTE_PHYS_MASK) << PAGE_SHIFT)
@@ -169,6 +157,8 @@ extern void page_table_range_init(unsigned long start, unsigned long end,
169#define HAVE_ARCH_UNMAPPED_AREA 157#define HAVE_ARCH_UNMAPPED_AREA
170#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 158#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
171 159
160#define __HAVE_ARCH_PTE_SPECIAL
161
172#include <asm-generic/pgtable.h> 162#include <asm-generic/pgtable.h>
173 163
174#endif /* __ASM_SH_PGTABLE_H */ 164#endif /* __ASM_SH_PGTABLE_H */
diff --git a/arch/sh/include/asm/pgtable_32.h b/arch/sh/include/asm/pgtable_32.h
index e172d696e52b..43528ec656ba 100644
--- a/arch/sh/include/asm/pgtable_32.h
+++ b/arch/sh/include/asm/pgtable_32.h
@@ -378,8 +378,6 @@ PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
378PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED); 378PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
379PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL); 379PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL);
380 380
381#define __HAVE_ARCH_PTE_SPECIAL
382
383/* 381/*
384 * Macro and implementation to make a page protection as uncachable. 382 * Macro and implementation to make a page protection as uncachable.
385 */ 383 */
@@ -429,10 +427,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
429#define pte_offset_kernel(dir, address) \ 427#define pte_offset_kernel(dir, address) \
430 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) 428 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
431#define pte_offset_map(dir, address) pte_offset_kernel(dir, address) 429#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
432#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
433
434#define pte_unmap(pte) do { } while (0) 430#define pte_unmap(pte) do { } while (0)
435#define pte_unmap_nested(pte) do { } while (0)
436 431
437#ifdef CONFIG_X2TLB 432#ifdef CONFIG_X2TLB
438#define pte_ERROR(e) \ 433#define pte_ERROR(e) \
diff --git a/arch/sh/include/asm/pgtable_64.h b/arch/sh/include/asm/pgtable_64.h
index 0ee46776dad6..42cb9dd52161 100644
--- a/arch/sh/include/asm/pgtable_64.h
+++ b/arch/sh/include/asm/pgtable_64.h
@@ -84,9 +84,7 @@ static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
84 ((pte_t *) ((pmd_val(*(dir))) & PAGE_MASK) + pte_index((addr))) 84 ((pte_t *) ((pmd_val(*(dir))) & PAGE_MASK) + pte_index((addr)))
85 85
86#define pte_offset_map(dir,addr) pte_offset_kernel(dir, addr) 86#define pte_offset_map(dir,addr) pte_offset_kernel(dir, addr)
87#define pte_offset_map_nested(dir,addr) pte_offset_kernel(dir, addr)
88#define pte_unmap(pte) do { } while (0) 87#define pte_unmap(pte) do { } while (0)
89#define pte_unmap_nested(pte) do { } while (0)
90 88
91#ifndef __ASSEMBLY__ 89#ifndef __ASSEMBLY__
92#define IOBASE_VADDR 0xff000000 90#define IOBASE_VADDR 0xff000000
@@ -132,6 +130,7 @@ static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
132 * anything above the PPN field. 130 * anything above the PPN field.
133 */ 131 */
134#define _PAGE_WIRED _PAGE_EXT(0x001) /* software: wire the tlb entry */ 132#define _PAGE_WIRED _PAGE_EXT(0x001) /* software: wire the tlb entry */
133#define _PAGE_SPECIAL _PAGE_EXT(0x002)
135 134
136#define _PAGE_CLEAR_FLAGS (_PAGE_PRESENT | _PAGE_FILE | _PAGE_SHARED | \ 135#define _PAGE_CLEAR_FLAGS (_PAGE_PRESENT | _PAGE_FILE | _PAGE_SHARED | \
137 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_WIRED) 136 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_WIRED)
@@ -175,7 +174,8 @@ static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
175/* Default flags for a User page */ 174/* Default flags for a User page */
176#define _PAGE_TABLE (_KERNPG_TABLE | _PAGE_USER) 175#define _PAGE_TABLE (_KERNPG_TABLE | _PAGE_USER)
177 176
178#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 177#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \
178 _PAGE_SPECIAL)
179 179
180/* 180/*
181 * We have full permissions (Read/Write/Execute/Shared). 181 * We have full permissions (Read/Write/Execute/Shared).
@@ -265,7 +265,7 @@ static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
265static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 265static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
266static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 266static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
267static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } 267static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
268static inline int pte_special(pte_t pte){ return 0; } 268static inline int pte_special(pte_t pte){ return pte_val(pte) & _PAGE_SPECIAL; }
269 269
270static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; } 270static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; }
271static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 271static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
@@ -274,8 +274,7 @@ static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) |
274static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 274static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
275static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 275static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
276static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; } 276static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
277static inline pte_t pte_mkspecial(pte_t pte) { return pte; } 277static inline pte_t pte_mkspecial(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SPECIAL)); return pte; }
278
279 278
280/* 279/*
281 * Conversion functions: convert a page and protection to a page entry. 280 * Conversion functions: convert a page and protection to a page entry.
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index 0a58cb25a658..c9e7cbc4768a 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -89,6 +89,7 @@ struct sh_cpuinfo {
89 struct task_struct *idle; 89 struct task_struct *idle;
90#endif 90#endif
91 91
92 unsigned int phys_bits;
92 unsigned long flags; 93 unsigned long flags;
93} __attribute__ ((aligned(L1_CACHE_BYTES))); 94} __attribute__ ((aligned(L1_CACHE_BYTES)));
94 95
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/system.h b/arch/sh/include/asm/system.h
index 0bd7a17d5e1a..10c8b1823a18 100644
--- a/arch/sh/include/asm/system.h
+++ b/arch/sh/include/asm/system.h
@@ -10,6 +10,7 @@
10#include <linux/compiler.h> 10#include <linux/compiler.h>
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <asm/types.h> 12#include <asm/types.h>
13#include <asm/uncached.h>
13 14
14#define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */ 15#define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */
15 16
@@ -137,11 +138,6 @@ extern unsigned int instruction_size(unsigned int insn);
137#define instruction_size(insn) (4) 138#define instruction_size(insn) (4)
138#endif 139#endif
139 140
140extern unsigned long cached_to_uncached;
141extern unsigned long uncached_size;
142
143extern struct dentry *sh_debugfs_root;
144
145void per_cpu_trap_init(void); 141void per_cpu_trap_init(void);
146void default_idle(void); 142void default_idle(void);
147void cpu_idle_wait(void); 143void cpu_idle_wait(void);
diff --git a/arch/sh/include/asm/system_32.h b/arch/sh/include/asm/system_32.h
index 51296b36770e..a4ad1cd9bc4d 100644
--- a/arch/sh/include/asm/system_32.h
+++ b/arch/sh/include/asm/system_32.h
@@ -145,42 +145,6 @@ do { \
145 __restore_dsp(prev); \ 145 __restore_dsp(prev); \
146} while (0) 146} while (0)
147 147
148/*
149 * Jump to uncached area.
150 * When handling TLB or caches, we need to do it from an uncached area.
151 */
152#define jump_to_uncached() \
153do { \
154 unsigned long __dummy; \
155 \
156 __asm__ __volatile__( \
157 "mova 1f, %0\n\t" \
158 "add %1, %0\n\t" \
159 "jmp @%0\n\t" \
160 " nop\n\t" \
161 ".balign 4\n" \
162 "1:" \
163 : "=&z" (__dummy) \
164 : "r" (cached_to_uncached)); \
165} while (0)
166
167/*
168 * Back to cached area.
169 */
170#define back_to_cached() \
171do { \
172 unsigned long __dummy; \
173 ctrl_barrier(); \
174 __asm__ __volatile__( \
175 "mov.l 1f, %0\n\t" \
176 "jmp @%0\n\t" \
177 " nop\n\t" \
178 ".balign 4\n" \
179 "1: .long 2f\n" \
180 "2:" \
181 : "=&r" (__dummy)); \
182} while (0)
183
184#ifdef CONFIG_CPU_HAS_SR_RB 148#ifdef CONFIG_CPU_HAS_SR_RB
185#define lookup_exception_vector() \ 149#define lookup_exception_vector() \
186({ \ 150({ \
@@ -212,17 +176,16 @@ static inline reg_size_t register_align(void *val)
212} 176}
213 177
214int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, 178int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
215 struct mem_access *ma, int); 179 struct mem_access *ma, int, unsigned long address);
216 180
217static inline void trigger_address_error(void) 181static inline void trigger_address_error(void)
218{ 182{
219 if (__in_29bit_mode()) 183 __asm__ __volatile__ (
220 __asm__ __volatile__ ( 184 "ldc %0, sr\n\t"
221 "ldc %0, sr\n\t" 185 "mov.l @%1, %0"
222 "mov.l @%1, %0" 186 :
223 : 187 : "r" (0x10000000), "r" (0x80000001)
224 : "r" (0x10000000), "r" (0x80000001) 188 );
225 );
226} 189}
227 190
228asmlinkage void do_address_error(struct pt_regs *regs, 191asmlinkage void do_address_error(struct pt_regs *regs,
diff --git a/arch/sh/include/asm/system_64.h b/arch/sh/include/asm/system_64.h
index 36338646dfc8..8593bc8d1a4e 100644
--- a/arch/sh/include/asm/system_64.h
+++ b/arch/sh/include/asm/system_64.h
@@ -34,9 +34,6 @@ do { \
34 &next->thread); \ 34 &next->thread); \
35} while (0) 35} while (0)
36 36
37#define jump_to_uncached() do { } while (0)
38#define back_to_cached() do { } while (0)
39
40#define __icbi(addr) __asm__ __volatile__ ( "icbi %0, 0\n\t" : : "r" (addr)) 37#define __icbi(addr) __asm__ __volatile__ ( "icbi %0, 0\n\t" : : "r" (addr))
41#define __ocbp(addr) __asm__ __volatile__ ( "ocbp %0, 0\n\t" : : "r" (addr)) 38#define __ocbp(addr) __asm__ __volatile__ ( "ocbp %0, 0\n\t" : : "r" (addr))
42#define __ocbi(addr) __asm__ __volatile__ ( "ocbi %0, 0\n\t" : : "r" (addr)) 39#define __ocbi(addr) __asm__ __volatile__ ( "ocbi %0, 0\n\t" : : "r" (addr))
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/uncached.h b/arch/sh/include/asm/uncached.h
index e3419f96626a..6f8816b79cf1 100644
--- a/arch/sh/include/asm/uncached.h
+++ b/arch/sh/include/asm/uncached.h
@@ -4,15 +4,55 @@
4#include <linux/bug.h> 4#include <linux/bug.h>
5 5
6#ifdef CONFIG_UNCACHED_MAPPING 6#ifdef CONFIG_UNCACHED_MAPPING
7extern unsigned long cached_to_uncached;
8extern unsigned long uncached_size;
7extern unsigned long uncached_start, uncached_end; 9extern unsigned long uncached_start, uncached_end;
8 10
9extern int virt_addr_uncached(unsigned long kaddr); 11extern int virt_addr_uncached(unsigned long kaddr);
10extern void uncached_init(void); 12extern void uncached_init(void);
11extern void uncached_resize(unsigned long size); 13extern void uncached_resize(unsigned long size);
14
15/*
16 * Jump to uncached area.
17 * When handling TLB or caches, we need to do it from an uncached area.
18 */
19#define jump_to_uncached() \
20do { \
21 unsigned long __dummy; \
22 \
23 __asm__ __volatile__( \
24 "mova 1f, %0\n\t" \
25 "add %1, %0\n\t" \
26 "jmp @%0\n\t" \
27 " nop\n\t" \
28 ".balign 4\n" \
29 "1:" \
30 : "=&z" (__dummy) \
31 : "r" (cached_to_uncached)); \
32} while (0)
33
34/*
35 * Back to cached area.
36 */
37#define back_to_cached() \
38do { \
39 unsigned long __dummy; \
40 ctrl_barrier(); \
41 __asm__ __volatile__( \
42 "mov.l 1f, %0\n\t" \
43 "jmp @%0\n\t" \
44 " nop\n\t" \
45 ".balign 4\n" \
46 "1: .long 2f\n" \
47 "2:" \
48 : "=&r" (__dummy)); \
49} while (0)
12#else 50#else
13#define virt_addr_uncached(kaddr) (0) 51#define virt_addr_uncached(kaddr) (0)
14#define uncached_init() do { } while (0) 52#define uncached_init() do { } while (0)
15#define uncached_resize(size) BUG() 53#define uncached_resize(size) BUG()
54#define jump_to_uncached() do { } while (0)
55#define back_to_cached() do { } while (0)
16#endif 56#endif
17 57
18#endif /* __ASM_SH_UNCACHED_H */ 58#endif /* __ASM_SH_UNCACHED_H */
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/edosk7705.h b/arch/sh/include/mach-common/mach/edosk7705.h
deleted file mode 100644
index efc43b323466..000000000000
--- a/arch/sh/include/mach-common/mach/edosk7705.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH_EDOSK7705_H
2#define __ASM_SH_EDOSK7705_H
3
4#define __IO_PREFIX sh_edosk7705
5#include <asm/io_generic.h>
6
7#endif /* __ASM_SH_EDOSK7705_H */
diff --git a/arch/sh/include/mach-common/mach/microdev.h b/arch/sh/include/mach-common/mach/microdev.h
index 1aed15856e11..dcb05fa8c164 100644
--- a/arch/sh/include/mach-common/mach/microdev.h
+++ b/arch/sh/include/mach-common/mach/microdev.h
@@ -68,13 +68,4 @@ extern void microdev_print_fpga_intc_status(void);
68#define __IO_PREFIX microdev 68#define __IO_PREFIX microdev
69#include <asm/io_generic.h> 69#include <asm/io_generic.h>
70 70
71#if defined(CONFIG_PCI)
72unsigned char microdev_pci_inb(unsigned long port);
73unsigned short microdev_pci_inw(unsigned long port);
74unsigned long microdev_pci_inl(unsigned long port);
75void microdev_pci_outb(unsigned char data, unsigned long port);
76void microdev_pci_outw(unsigned short data, unsigned long port);
77void microdev_pci_outl(unsigned long data, unsigned long port);
78#endif
79
80#endif /* __ASM_SH_MICRODEV_H */ 71#endif /* __ASM_SH_MICRODEV_H */
diff --git a/arch/sh/include/mach-common/mach/snapgear.h b/arch/sh/include/mach-common/mach/secureedge5410.h
index 042d95f51c4d..3653b9a4bacc 100644
--- a/arch/sh/include/mach-common/mach/snapgear.h
+++ b/arch/sh/include/mach-common/mach/secureedge5410.h
@@ -12,30 +12,9 @@
12#ifndef _ASM_SH_IO_SNAPGEAR_H 12#ifndef _ASM_SH_IO_SNAPGEAR_H
13#define _ASM_SH_IO_SNAPGEAR_H 13#define _ASM_SH_IO_SNAPGEAR_H
14 14
15#if defined(CONFIG_CPU_SH4)
16/*
17 * The external interrupt lines, these take up ints 0 - 15 inclusive
18 * depending on the priority for the interrupt. In fact the priority
19 * is the interrupt :-)
20 */
21
22#define IRL0_IRQ 2
23#define IRL0_PRIORITY 13
24
25#define IRL1_IRQ 5
26#define IRL1_PRIORITY 10
27
28#define IRL2_IRQ 8
29#define IRL2_PRIORITY 7
30
31#define IRL3_IRQ 11
32#define IRL3_PRIORITY 4
33#endif
34
35#define __IO_PREFIX snapgear 15#define __IO_PREFIX snapgear
36#include <asm/io_generic.h> 16#include <asm/io_generic.h>
37 17
38#ifdef CONFIG_SH_SECUREEDGE5410
39/* 18/*
40 * We need to remember what was written to the ioport as some bits 19 * We need to remember what was written to the ioport as some bits
41 * are shared with other functions and you cannot read back what was 20 * are shared with other functions and you cannot read back what was
@@ -66,6 +45,5 @@ extern unsigned short secureedge5410_ioport;
66 ((secureedge5410_ioport & ~(mask)) | ((val) & (mask))))) 45 ((secureedge5410_ioport & ~(mask)) | ((val) & (mask)))))
67#define SECUREEDGE_READ_IOPORT() \ 46#define SECUREEDGE_READ_IOPORT() \
68 ((*SECUREEDGE_IOPORT_ADDR&0x0817) | (secureedge5410_ioport&~0x0817)) 47 ((*SECUREEDGE_IOPORT_ADDR&0x0817) | (secureedge5410_ioport&~0x0817))
69#endif
70 48
71#endif /* _ASM_SH_IO_SNAPGEAR_H */ 49#endif /* _ASM_SH_IO_SNAPGEAR_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-common/mach/systemh7751.h b/arch/sh/include/mach-common/mach/systemh7751.h
deleted file mode 100644
index 4161122c84ef..000000000000
--- a/arch/sh/include/mach-common/mach/systemh7751.h
+++ /dev/null
@@ -1,71 +0,0 @@
1#ifndef __ASM_SH_SYSTEMH_7751SYSTEMH_H
2#define __ASM_SH_SYSTEMH_7751SYSTEMH_H
3
4/*
5 * linux/include/asm-sh/systemh/7751systemh.h
6 *
7 * Copyright (C) 2000 Kazumoto Kojima
8 *
9 * Hitachi SystemH support
10
11 * Modified for 7751 SystemH by
12 * Jonathan Short, 2002.
13 */
14
15/* Box specific addresses. */
16
17#define PA_ROM 0x00000000 /* EPROM */
18#define PA_ROM_SIZE 0x00400000 /* EPROM size 4M byte */
19#define PA_FROM 0x01000000 /* EPROM */
20#define PA_FROM_SIZE 0x00400000 /* EPROM size 4M byte */
21#define PA_EXT1 0x04000000
22#define PA_EXT1_SIZE 0x04000000
23#define PA_EXT2 0x08000000
24#define PA_EXT2_SIZE 0x04000000
25#define PA_SDRAM 0x0c000000
26#define PA_SDRAM_SIZE 0x04000000
27
28#define PA_EXT4 0x12000000
29#define PA_EXT4_SIZE 0x02000000
30#define PA_EXT5 0x14000000
31#define PA_EXT5_SIZE 0x04000000
32#define PA_PCIC 0x18000000 /* MR-SHPC-01 PCMCIA */
33
34#define PA_DIPSW0 0xb9000000 /* Dip switch 5,6 */
35#define PA_DIPSW1 0xb9000002 /* Dip switch 7,8 */
36#define PA_LED 0xba000000 /* LED */
37#define PA_BCR 0xbb000000 /* FPGA on the MS7751SE01 */
38
39#define PA_MRSHPC 0xb83fffe0 /* MR-SHPC-01 PCMCIA controller */
40#define PA_MRSHPC_MW1 0xb8400000 /* MR-SHPC-01 memory window base */
41#define PA_MRSHPC_MW2 0xb8500000 /* MR-SHPC-01 attribute window base */
42#define PA_MRSHPC_IO 0xb8600000 /* MR-SHPC-01 I/O window base */
43#define MRSHPC_MODE (PA_MRSHPC + 4)
44#define MRSHPC_OPTION (PA_MRSHPC + 6)
45#define MRSHPC_CSR (PA_MRSHPC + 8)
46#define MRSHPC_ISR (PA_MRSHPC + 10)
47#define MRSHPC_ICR (PA_MRSHPC + 12)
48#define MRSHPC_CPWCR (PA_MRSHPC + 14)
49#define MRSHPC_MW0CR1 (PA_MRSHPC + 16)
50#define MRSHPC_MW1CR1 (PA_MRSHPC + 18)
51#define MRSHPC_IOWCR1 (PA_MRSHPC + 20)
52#define MRSHPC_MW0CR2 (PA_MRSHPC + 22)
53#define MRSHPC_MW1CR2 (PA_MRSHPC + 24)
54#define MRSHPC_IOWCR2 (PA_MRSHPC + 26)
55#define MRSHPC_CDCR (PA_MRSHPC + 28)
56#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
57
58#define BCR_ILCRA (PA_BCR + 0)
59#define BCR_ILCRB (PA_BCR + 2)
60#define BCR_ILCRC (PA_BCR + 4)
61#define BCR_ILCRD (PA_BCR + 6)
62#define BCR_ILCRE (PA_BCR + 8)
63#define BCR_ILCRF (PA_BCR + 10)
64#define BCR_ILCRG (PA_BCR + 12)
65
66#define IRQ_79C973 13
67
68#define __IO_PREFIX sh7751systemh
69#include <asm/io_generic.h>
70
71#endif /* __ASM_SH_SYSTEMH_7751SYSTEMH_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/init.c b/arch/sh/kernel/cpu/init.c
index 97661061ff20..fac742e514ee 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -340,6 +340,8 @@ asmlinkage void __cpuinit cpu_init(void)
340 */ 340 */
341 current_cpu_data.asid_cache = NO_CONTEXT; 341 current_cpu_data.asid_cache = NO_CONTEXT;
342 342
343 current_cpu_data.phys_bits = __in_29bit_mode() ? 29 : 32;
344
343 speculative_execution_init(); 345 speculative_execution_init();
344 expmask_init(); 346 expmask_init();
345 347
diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c
index a351ed84eec5..32c825c9488e 100644
--- a/arch/sh/kernel/cpu/irq/imask.c
+++ b/arch/sh/kernel/cpu/irq/imask.c
@@ -51,16 +51,20 @@ static inline void set_interrupt_registers(int ip)
51 : "t"); 51 : "t");
52} 52}
53 53
54static void mask_imask_irq(unsigned int irq) 54static void mask_imask_irq(struct irq_data *data)
55{ 55{
56 unsigned int irq = data->irq;
57
56 clear_bit(irq, imask_mask); 58 clear_bit(irq, imask_mask);
57 if (interrupt_priority < IMASK_PRIORITY - irq) 59 if (interrupt_priority < IMASK_PRIORITY - irq)
58 interrupt_priority = IMASK_PRIORITY - irq; 60 interrupt_priority = IMASK_PRIORITY - irq;
59 set_interrupt_registers(interrupt_priority); 61 set_interrupt_registers(interrupt_priority);
60} 62}
61 63
62static void unmask_imask_irq(unsigned int irq) 64static void unmask_imask_irq(struct irq_data *data)
63{ 65{
66 unsigned int irq = data->irq;
67
64 set_bit(irq, imask_mask); 68 set_bit(irq, imask_mask);
65 interrupt_priority = IMASK_PRIORITY - 69 interrupt_priority = IMASK_PRIORITY -
66 find_first_zero_bit(imask_mask, IMASK_PRIORITY); 70 find_first_zero_bit(imask_mask, IMASK_PRIORITY);
@@ -69,9 +73,9 @@ static void unmask_imask_irq(unsigned int irq)
69 73
70static struct irq_chip imask_irq_chip = { 74static struct irq_chip imask_irq_chip = {
71 .name = "SR.IMASK", 75 .name = "SR.IMASK",
72 .mask = mask_imask_irq, 76 .irq_mask = mask_imask_irq,
73 .unmask = unmask_imask_irq, 77 .irq_unmask = unmask_imask_irq,
74 .mask_ack = mask_imask_irq, 78 .irq_mask_ack = mask_imask_irq,
75}; 79};
76 80
77void make_imask_irq(unsigned int irq) 81void make_imask_irq(unsigned int irq)
diff --git a/arch/sh/kernel/cpu/irq/intc-sh5.c b/arch/sh/kernel/cpu/irq/intc-sh5.c
index 96a239583948..5af48f8357e5 100644
--- a/arch/sh/kernel/cpu/irq/intc-sh5.c
+++ b/arch/sh/kernel/cpu/irq/intc-sh5.c
@@ -76,39 +76,11 @@ int intc_evt_to_irq[(0xE20/0x20)+1] = {
76}; 76};
77 77
78static unsigned long intc_virt; 78static unsigned long intc_virt;
79
80static unsigned int startup_intc_irq(unsigned int irq);
81static void shutdown_intc_irq(unsigned int irq);
82static void enable_intc_irq(unsigned int irq);
83static void disable_intc_irq(unsigned int irq);
84static void mask_and_ack_intc(unsigned int);
85static void end_intc_irq(unsigned int irq);
86
87static struct irq_chip intc_irq_type = {
88 .name = "INTC",
89 .startup = startup_intc_irq,
90 .shutdown = shutdown_intc_irq,
91 .enable = enable_intc_irq,
92 .disable = disable_intc_irq,
93 .ack = mask_and_ack_intc,
94 .end = end_intc_irq
95};
96
97static int irlm; /* IRL mode */ 79static int irlm; /* IRL mode */
98 80
99static unsigned int startup_intc_irq(unsigned int irq) 81static void enable_intc_irq(struct irq_data *data)
100{
101 enable_intc_irq(irq);
102 return 0; /* never anything pending */
103}
104
105static void shutdown_intc_irq(unsigned int irq)
106{
107 disable_intc_irq(irq);
108}
109
110static void enable_intc_irq(unsigned int irq)
111{ 82{
83 unsigned int irq = data->irq;
112 unsigned long reg; 84 unsigned long reg;
113 unsigned long bitmask; 85 unsigned long bitmask;
114 86
@@ -126,8 +98,9 @@ static void enable_intc_irq(unsigned int irq)
126 __raw_writel(bitmask, reg); 98 __raw_writel(bitmask, reg);
127} 99}
128 100
129static void disable_intc_irq(unsigned int irq) 101static void disable_intc_irq(struct irq_data *data)
130{ 102{
103 unsigned int irq = data->irq;
131 unsigned long reg; 104 unsigned long reg;
132 unsigned long bitmask; 105 unsigned long bitmask;
133 106
@@ -142,15 +115,11 @@ static void disable_intc_irq(unsigned int irq)
142 __raw_writel(bitmask, reg); 115 __raw_writel(bitmask, reg);
143} 116}
144 117
145static void mask_and_ack_intc(unsigned int irq) 118static struct irq_chip intc_irq_type = {
146{ 119 .name = "INTC",
147 disable_intc_irq(irq); 120 .irq_enable = enable_intc_irq,
148} 121 .irq_disable = disable_intc_irq,
149 122};
150static void end_intc_irq(unsigned int irq)
151{
152 enable_intc_irq(irq);
153}
154 123
155void __init plat_irq_setup(void) 124void __init plat_irq_setup(void)
156{ 125{
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index 9282d965a1b6..7516c35ee514 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -24,25 +24,25 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/topology.h> 25#include <linux/topology.h>
26 26
27static inline struct ipr_desc *get_ipr_desc(unsigned int irq) 27static inline struct ipr_desc *get_ipr_desc(struct irq_data *data)
28{ 28{
29 struct irq_chip *chip = get_irq_chip(irq); 29 struct irq_chip *chip = irq_data_get_irq_chip(data);
30 return container_of(chip, struct ipr_desc, chip); 30 return container_of(chip, struct ipr_desc, chip);
31} 31}
32 32
33static void disable_ipr_irq(unsigned int irq) 33static void disable_ipr_irq(struct irq_data *data)
34{ 34{
35 struct ipr_data *p = get_irq_chip_data(irq); 35 struct ipr_data *p = irq_data_get_irq_chip_data(data);
36 unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx]; 36 unsigned long addr = get_ipr_desc(data)->ipr_offsets[p->ipr_idx];
37 /* Set the priority in IPR to 0 */ 37 /* Set the priority in IPR to 0 */
38 __raw_writew(__raw_readw(addr) & (0xffff ^ (0xf << p->shift)), addr); 38 __raw_writew(__raw_readw(addr) & (0xffff ^ (0xf << p->shift)), addr);
39 (void)__raw_readw(addr); /* Read back to flush write posting */ 39 (void)__raw_readw(addr); /* Read back to flush write posting */
40} 40}
41 41
42static void enable_ipr_irq(unsigned int irq) 42static void enable_ipr_irq(struct irq_data *data)
43{ 43{
44 struct ipr_data *p = get_irq_chip_data(irq); 44 struct ipr_data *p = irq_data_get_irq_chip_data(data);
45 unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx]; 45 unsigned long addr = get_ipr_desc(data)->ipr_offsets[p->ipr_idx];
46 /* Set priority in IPR back to original value */ 46 /* Set priority in IPR back to original value */
47 __raw_writew(__raw_readw(addr) | (p->priority << p->shift), addr); 47 __raw_writew(__raw_readw(addr) | (p->priority << p->shift), addr);
48} 48}
@@ -56,19 +56,18 @@ void register_ipr_controller(struct ipr_desc *desc)
56{ 56{
57 int i; 57 int i;
58 58
59 desc->chip.mask = disable_ipr_irq; 59 desc->chip.irq_mask = disable_ipr_irq;
60 desc->chip.unmask = enable_ipr_irq; 60 desc->chip.irq_unmask = enable_ipr_irq;
61 desc->chip.mask_ack = disable_ipr_irq;
62 61
63 for (i = 0; i < desc->nr_irqs; i++) { 62 for (i = 0; i < desc->nr_irqs; i++) {
64 struct ipr_data *p = desc->ipr_data + i; 63 struct ipr_data *p = desc->ipr_data + i;
65 struct irq_desc *irq_desc; 64 int res;
66 65
67 BUG_ON(p->ipr_idx >= desc->nr_offsets); 66 BUG_ON(p->ipr_idx >= desc->nr_offsets);
68 BUG_ON(!desc->ipr_offsets[p->ipr_idx]); 67 BUG_ON(!desc->ipr_offsets[p->ipr_idx]);
69 68
70 irq_desc = irq_to_desc_alloc_node(p->irq, numa_node_id()); 69 res = irq_alloc_desc_at(p->irq, numa_node_id());
71 if (unlikely(!irq_desc)) { 70 if (unlikely(res != p->irq && res != -EEXIST)) {
72 printk(KERN_INFO "can not get irq_desc for %d\n", 71 printk(KERN_INFO "can not get irq_desc for %d\n",
73 p->irq); 72 p->irq);
74 continue; 73 continue;
@@ -78,7 +77,7 @@ void register_ipr_controller(struct ipr_desc *desc)
78 set_irq_chip_and_handler_name(p->irq, &desc->chip, 77 set_irq_chip_and_handler_name(p->irq, &desc->chip,
79 handle_level_irq, "level"); 78 handle_level_irq, "level");
80 set_irq_chip_data(p->irq, p); 79 set_irq_chip_data(p->irq, p);
81 disable_ipr_irq(p->irq); 80 disable_ipr_irq(irq_get_irq_data(p->irq));
82 } 81 }
83} 82}
84EXPORT_SYMBOL(register_ipr_controller); 83EXPORT_SYMBOL(register_ipr_controller);
diff --git a/arch/sh/kernel/cpu/sh4/perf_event.c b/arch/sh/kernel/cpu/sh4/perf_event.c
index 7f9ecc9c2d02..dbf3b4bb71fe 100644
--- a/arch/sh/kernel/cpu/sh4/perf_event.c
+++ b/arch/sh/kernel/cpu/sh4/perf_event.c
@@ -225,7 +225,7 @@ static void sh7750_pmu_enable_all(void)
225} 225}
226 226
227static struct sh_pmu sh7750_pmu = { 227static struct sh_pmu sh7750_pmu = {
228 .name = "SH7750", 228 .name = "sh7750",
229 .num_events = 2, 229 .num_events = 2,
230 .event_map = sh7750_event_map, 230 .event_map = sh7750_event_map,
231 .max_events = ARRAY_SIZE(sh7750_general_events), 231 .max_events = ARRAY_SIZE(sh7750_general_events),
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-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 2d9700c6b53a..0fe2e9329cb2 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -48,7 +48,7 @@ static struct clk r_clk = {
48 * Default rate for the root input clock, reset this with clk_set_rate() 48 * Default rate for the root input clock, reset this with clk_set_rate()
49 * from the platform code. 49 * from the platform code.
50 */ 50 */
51struct clk extal_clk = { 51static struct clk extal_clk = {
52 .rate = 33333333, 52 .rate = 33333333,
53}; 53};
54 54
@@ -111,7 +111,7 @@ static struct clk div3_clk = {
111 .parent = &pll_clk, 111 .parent = &pll_clk,
112}; 112};
113 113
114struct clk *main_clks[] = { 114static struct clk *main_clks[] = {
115 &r_clk, 115 &r_clk,
116 &extal_clk, 116 &extal_clk,
117 &fll_clk, 117 &fll_clk,
@@ -156,7 +156,7 @@ struct clk div4_clks[DIV4_NR] = {
156 156
157enum { DIV6_V, DIV6_FA, DIV6_FB, DIV6_I, DIV6_S, DIV6_NR }; 157enum { DIV6_V, DIV6_FA, DIV6_FB, DIV6_I, DIV6_S, DIV6_NR };
158 158
159struct clk div6_clks[DIV6_NR] = { 159static struct clk div6_clks[DIV6_NR] = {
160 [DIV6_V] = SH_CLK_DIV6(&div3_clk, VCLKCR, 0), 160 [DIV6_V] = SH_CLK_DIV6(&div3_clk, VCLKCR, 0),
161 [DIV6_FA] = SH_CLK_DIV6(&div3_clk, FCLKACR, 0), 161 [DIV6_FA] = SH_CLK_DIV6(&div3_clk, FCLKACR, 0),
162 [DIV6_FB] = SH_CLK_DIV6(&div3_clk, FCLKBCR, 0), 162 [DIV6_FB] = SH_CLK_DIV6(&div3_clk, FCLKBCR, 0),
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..580276525731 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)
@@ -241,7 +259,7 @@ static void sh4a_pmu_enable_all(void)
241} 259}
242 260
243static struct sh_pmu sh4a_pmu = { 261static struct sh_pmu sh4a_pmu = {
244 .name = "SH-4A", 262 .name = "sh4a",
245 .num_events = 2, 263 .num_events = 2,
246 .event_map = sh4a_event_map, 264 .event_map = sh4a_event_map,
247 .max_events = ARRAY_SIZE(sh4a_general_events), 265 .max_events = ARRAY_SIZE(sh4a_general_events),
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-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index 156ccc960015..d551ed8dea95 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -551,7 +551,7 @@ static struct resource siu_resources[] = {
551}; 551};
552 552
553static struct platform_device siu_device = { 553static struct platform_device siu_device = {
554 .name = "sh_siu", 554 .name = "siu-pcm-audio",
555 .id = -1, 555 .id = -1,
556 .dev = { 556 .dev = {
557 .platform_data = &siu_platform_data, 557 .platform_data = &siu_platform_data,
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 ae5bac39b896..68ecbe6c881a 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -56,6 +56,8 @@ int show_interrupts(struct seq_file *p, void *v)
56 int i = *(loff_t *)v, j, prec; 56 int i = *(loff_t *)v, j, prec;
57 struct irqaction *action; 57 struct irqaction *action;
58 struct irq_desc *desc; 58 struct irq_desc *desc;
59 struct irq_data *data;
60 struct irq_chip *chip;
59 61
60 if (i > nr_irqs) 62 if (i > nr_irqs)
61 return 0; 63 return 0;
@@ -77,6 +79,9 @@ int show_interrupts(struct seq_file *p, void *v)
77 if (!desc) 79 if (!desc)
78 return 0; 80 return 0;
79 81
82 data = irq_get_irq_data(i);
83 chip = irq_data_get_irq_chip(data);
84
80 raw_spin_lock_irqsave(&desc->lock, flags); 85 raw_spin_lock_irqsave(&desc->lock, flags);
81 for_each_online_cpu(j) 86 for_each_online_cpu(j)
82 any_count |= kstat_irqs_cpu(i, j); 87 any_count |= kstat_irqs_cpu(i, j);
@@ -87,7 +92,7 @@ int show_interrupts(struct seq_file *p, void *v)
87 seq_printf(p, "%*d: ", prec, i); 92 seq_printf(p, "%*d: ", prec, i);
88 for_each_online_cpu(j) 93 for_each_online_cpu(j)
89 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 94 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
90 seq_printf(p, " %14s", desc->chip->name); 95 seq_printf(p, " %14s", chip->name);
91 seq_printf(p, "-%-8s", desc->name); 96 seq_printf(p, "-%-8s", desc->name);
92 97
93 if (action) { 98 if (action) {
@@ -273,16 +278,12 @@ void __init init_IRQ(void)
273{ 278{
274 plat_irq_setup(); 279 plat_irq_setup();
275 280
276 /*
277 * Pin any of the legacy IRQ vectors that haven't already been
278 * grabbed by the platform
279 */
280 reserve_irq_legacy();
281
282 /* Perform the machine specific initialisation */ 281 /* Perform the machine specific initialisation */
283 if (sh_mv.mv_init_irq) 282 if (sh_mv.mv_init_irq)
284 sh_mv.mv_init_irq(); 283 sh_mv.mv_init_irq();
285 284
285 intc_finalize();
286
286 irq_ctx_init(smp_processor_id()); 287 irq_ctx_init(smp_processor_id());
287} 288}
288 289
@@ -295,13 +296,16 @@ int __init arch_probe_nr_irqs(void)
295#endif 296#endif
296 297
297#ifdef CONFIG_HOTPLUG_CPU 298#ifdef CONFIG_HOTPLUG_CPU
298static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu) 299static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu)
299{ 300{
301 struct irq_desc *desc = irq_to_desc(irq);
302 struct irq_chip *chip = irq_data_get_irq_chip(data);
303
300 printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n", 304 printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n",
301 irq, desc->node, cpu); 305 irq, data->node, cpu);
302 306
303 raw_spin_lock_irq(&desc->lock); 307 raw_spin_lock_irq(&desc->lock);
304 desc->chip->set_affinity(irq, cpumask_of(cpu)); 308 chip->irq_set_affinity(data, cpumask_of(cpu), false);
305 raw_spin_unlock_irq(&desc->lock); 309 raw_spin_unlock_irq(&desc->lock);
306} 310}
307 311
@@ -312,24 +316,25 @@ static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu)
312 */ 316 */
313void migrate_irqs(void) 317void migrate_irqs(void)
314{ 318{
315 struct irq_desc *desc;
316 unsigned int irq, cpu = smp_processor_id(); 319 unsigned int irq, cpu = smp_processor_id();
317 320
318 for_each_irq_desc(irq, desc) { 321 for_each_active_irq(irq) {
319 if (desc->node == cpu) { 322 struct irq_data *data = irq_get_irq_data(irq);
320 unsigned int newcpu = cpumask_any_and(desc->affinity, 323
324 if (data->node == cpu) {
325 unsigned int newcpu = cpumask_any_and(data->affinity,
321 cpu_online_mask); 326 cpu_online_mask);
322 if (newcpu >= nr_cpu_ids) { 327 if (newcpu >= nr_cpu_ids) {
323 if (printk_ratelimit()) 328 if (printk_ratelimit())
324 printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n", 329 printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n",
325 irq, cpu); 330 irq, cpu);
326 331
327 cpumask_setall(desc->affinity); 332 cpumask_setall(data->affinity);
328 newcpu = cpumask_any_and(desc->affinity, 333 newcpu = cpumask_any_and(data->affinity,
329 cpu_online_mask); 334 cpu_online_mask);
330 } 335 }
331 336
332 route_irq(desc, irq, newcpu); 337 route_irq(data, irq, newcpu);
333 } 338 }
334 } 339 }
335} 340}
diff --git a/arch/sh/kernel/irq_64.c b/arch/sh/kernel/irq_64.c
index 32365ba0e039..8fc05b997b6d 100644
--- a/arch/sh/kernel/irq_64.c
+++ b/arch/sh/kernel/irq_64.c
@@ -11,17 +11,17 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <cpu/registers.h> 12#include <cpu/registers.h>
13 13
14void notrace raw_local_irq_restore(unsigned long flags) 14void notrace arch_local_irq_restore(unsigned long flags)
15{ 15{
16 unsigned long long __dummy; 16 unsigned long long __dummy;
17 17
18 if (flags == RAW_IRQ_DISABLED) { 18 if (flags == ARCH_IRQ_DISABLED) {
19 __asm__ __volatile__ ( 19 __asm__ __volatile__ (
20 "getcon " __SR ", %0\n\t" 20 "getcon " __SR ", %0\n\t"
21 "or %0, %1, %0\n\t" 21 "or %0, %1, %0\n\t"
22 "putcon %0, " __SR "\n\t" 22 "putcon %0, " __SR "\n\t"
23 : "=&r" (__dummy) 23 : "=&r" (__dummy)
24 : "r" (RAW_IRQ_DISABLED) 24 : "r" (ARCH_IRQ_DISABLED)
25 ); 25 );
26 } else { 26 } else {
27 __asm__ __volatile__ ( 27 __asm__ __volatile__ (
@@ -29,13 +29,13 @@ void notrace raw_local_irq_restore(unsigned long flags)
29 "and %0, %1, %0\n\t" 29 "and %0, %1, %0\n\t"
30 "putcon %0, " __SR "\n\t" 30 "putcon %0, " __SR "\n\t"
31 : "=&r" (__dummy) 31 : "=&r" (__dummy)
32 : "r" (~RAW_IRQ_DISABLED) 32 : "r" (~ARCH_IRQ_DISABLED)
33 ); 33 );
34 } 34 }
35} 35}
36EXPORT_SYMBOL(raw_local_irq_restore); 36EXPORT_SYMBOL(arch_local_irq_restore);
37 37
38unsigned long notrace __raw_local_save_flags(void) 38unsigned long notrace arch_local_save_flags(void)
39{ 39{
40 unsigned long flags; 40 unsigned long flags;
41 41
@@ -43,9 +43,9 @@ unsigned long notrace __raw_local_save_flags(void)
43 "getcon " __SR ", %0\n\t" 43 "getcon " __SR ", %0\n\t"
44 "and %0, %1, %0" 44 "and %0, %1, %0"
45 : "=&r" (flags) 45 : "=&r" (flags)
46 : "r" (RAW_IRQ_DISABLED) 46 : "r" (ARCH_IRQ_DISABLED)
47 ); 47 );
48 48
49 return flags; 49 return flags;
50} 50}
51EXPORT_SYMBOL(__raw_local_save_flags); 51EXPORT_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/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..90a15d29feeb 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 */
@@ -338,9 +365,9 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
338 return &user_sh_native_view; 365 return &user_sh_native_view;
339} 366}
340 367
341long arch_ptrace(struct task_struct *child, long request, long addr, long data) 368long arch_ptrace(struct task_struct *child, long request,
369 unsigned long addr, unsigned long data)
342{ 370{
343 struct user * dummy = NULL;
344 unsigned long __user *datap = (unsigned long __user *)data; 371 unsigned long __user *datap = (unsigned long __user *)data;
345 int ret; 372 int ret;
346 373
@@ -356,17 +383,20 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
356 383
357 if (addr < sizeof(struct pt_regs)) 384 if (addr < sizeof(struct pt_regs))
358 tmp = get_stack_long(child, addr); 385 tmp = get_stack_long(child, addr);
359 else if (addr >= (long) &dummy->fpu && 386 else if (addr >= offsetof(struct user, fpu) &&
360 addr < (long) &dummy->u_fpvalid) { 387 addr < offsetof(struct user, u_fpvalid)) {
361 if (!tsk_used_math(child)) { 388 if (!tsk_used_math(child)) {
362 if (addr == (long)&dummy->fpu.fpscr) 389 if (addr == offsetof(struct user, fpu.fpscr))
363 tmp = FPSCR_INIT; 390 tmp = FPSCR_INIT;
364 else 391 else
365 tmp = 0; 392 tmp = 0;
366 } else 393 } else {
367 tmp = ((long *)child->thread.xstate) 394 unsigned long index;
368 [(addr - (long)&dummy->fpu) >> 2]; 395 index = addr - offsetof(struct user, fpu);
369 } else if (addr == (long) &dummy->u_fpvalid) 396 tmp = ((unsigned long *)child->thread.xstate)
397 [index >> 2];
398 }
399 } else if (addr == offsetof(struct user, u_fpvalid))
370 tmp = !!tsk_used_math(child); 400 tmp = !!tsk_used_math(child);
371 else if (addr == PT_TEXT_ADDR) 401 else if (addr == PT_TEXT_ADDR)
372 tmp = child->mm->start_code; 402 tmp = child->mm->start_code;
@@ -390,13 +420,15 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
390 420
391 if (addr < sizeof(struct pt_regs)) 421 if (addr < sizeof(struct pt_regs))
392 ret = put_stack_long(child, addr, data); 422 ret = put_stack_long(child, addr, data);
393 else if (addr >= (long) &dummy->fpu && 423 else if (addr >= offsetof(struct user, fpu) &&
394 addr < (long) &dummy->u_fpvalid) { 424 addr < offsetof(struct user, u_fpvalid)) {
425 unsigned long index;
426 index = addr - offsetof(struct user, fpu);
395 set_stopped_child_used_math(child); 427 set_stopped_child_used_math(child);
396 ((long *)child->thread.xstate) 428 ((unsigned long *)child->thread.xstate)
397 [(addr - (long)&dummy->fpu) >> 2] = data; 429 [index >> 2] = data;
398 ret = 0; 430 ret = 0;
399 } else if (addr == (long) &dummy->u_fpvalid) { 431 } else if (addr == offsetof(struct user, u_fpvalid)) {
400 conditional_stopped_child_used_math(data, child); 432 conditional_stopped_child_used_math(data, child);
401 ret = 0; 433 ret = 0;
402 } 434 }
@@ -406,35 +438,35 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
406 return copy_regset_to_user(child, &user_sh_native_view, 438 return copy_regset_to_user(child, &user_sh_native_view,
407 REGSET_GENERAL, 439 REGSET_GENERAL,
408 0, sizeof(struct pt_regs), 440 0, sizeof(struct pt_regs),
409 (void __user *)data); 441 datap);
410 case PTRACE_SETREGS: 442 case PTRACE_SETREGS:
411 return copy_regset_from_user(child, &user_sh_native_view, 443 return copy_regset_from_user(child, &user_sh_native_view,
412 REGSET_GENERAL, 444 REGSET_GENERAL,
413 0, sizeof(struct pt_regs), 445 0, sizeof(struct pt_regs),
414 (const void __user *)data); 446 datap);
415#ifdef CONFIG_SH_FPU 447#ifdef CONFIG_SH_FPU
416 case PTRACE_GETFPREGS: 448 case PTRACE_GETFPREGS:
417 return copy_regset_to_user(child, &user_sh_native_view, 449 return copy_regset_to_user(child, &user_sh_native_view,
418 REGSET_FPU, 450 REGSET_FPU,
419 0, sizeof(struct user_fpu_struct), 451 0, sizeof(struct user_fpu_struct),
420 (void __user *)data); 452 datap);
421 case PTRACE_SETFPREGS: 453 case PTRACE_SETFPREGS:
422 return copy_regset_from_user(child, &user_sh_native_view, 454 return copy_regset_from_user(child, &user_sh_native_view,
423 REGSET_FPU, 455 REGSET_FPU,
424 0, sizeof(struct user_fpu_struct), 456 0, sizeof(struct user_fpu_struct),
425 (const void __user *)data); 457 datap);
426#endif 458#endif
427#ifdef CONFIG_SH_DSP 459#ifdef CONFIG_SH_DSP
428 case PTRACE_GETDSPREGS: 460 case PTRACE_GETDSPREGS:
429 return copy_regset_to_user(child, &user_sh_native_view, 461 return copy_regset_to_user(child, &user_sh_native_view,
430 REGSET_DSP, 462 REGSET_DSP,
431 0, sizeof(struct pt_dspregs), 463 0, sizeof(struct pt_dspregs),
432 (void __user *)data); 464 datap);
433 case PTRACE_SETDSPREGS: 465 case PTRACE_SETDSPREGS:
434 return copy_regset_from_user(child, &user_sh_native_view, 466 return copy_regset_from_user(child, &user_sh_native_view,
435 REGSET_DSP, 467 REGSET_DSP,
436 0, sizeof(struct pt_dspregs), 468 0, sizeof(struct pt_dspregs),
437 (const void __user *)data); 469 datap);
438#endif 470#endif
439 default: 471 default:
440 ret = ptrace_request(child, request, addr, data); 472 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index 5fd644da7f02..4436eacddb15 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 */
@@ -304,9 +383,11 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
304 return &user_sh64_native_view; 383 return &user_sh64_native_view;
305} 384}
306 385
307long arch_ptrace(struct task_struct *child, long request, long addr, long data) 386long arch_ptrace(struct task_struct *child, long request,
387 unsigned long addr, unsigned long data)
308{ 388{
309 int ret; 389 int ret;
390 unsigned long __user *datap = (unsigned long __user *) data;
310 391
311 switch (request) { 392 switch (request) {
312 /* read the word at location addr in the USER area. */ 393 /* read the word at location addr in the USER area. */
@@ -321,13 +402,15 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
321 tmp = get_stack_long(child, addr); 402 tmp = get_stack_long(child, addr);
322 else if ((addr >= offsetof(struct user, fpu)) && 403 else if ((addr >= offsetof(struct user, fpu)) &&
323 (addr < offsetof(struct user, u_fpvalid))) { 404 (addr < offsetof(struct user, u_fpvalid))) {
324 tmp = get_fpu_long(child, addr - offsetof(struct user, fpu)); 405 unsigned long index;
406 index = addr - offsetof(struct user, fpu);
407 tmp = get_fpu_long(child, index);
325 } else if (addr == offsetof(struct user, u_fpvalid)) { 408 } else if (addr == offsetof(struct user, u_fpvalid)) {
326 tmp = !!tsk_used_math(child); 409 tmp = !!tsk_used_math(child);
327 } else { 410 } else {
328 break; 411 break;
329 } 412 }
330 ret = put_user(tmp, (unsigned long *)data); 413 ret = put_user(tmp, datap);
331 break; 414 break;
332 } 415 }
333 416
@@ -358,7 +441,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
358 } 441 }
359 else if ((addr >= offsetof(struct user, fpu)) && 442 else if ((addr >= offsetof(struct user, fpu)) &&
360 (addr < offsetof(struct user, u_fpvalid))) { 443 (addr < offsetof(struct user, u_fpvalid))) {
361 ret = put_fpu_long(child, addr - offsetof(struct user, fpu), data); 444 unsigned long index;
445 index = addr - offsetof(struct user, fpu);
446 ret = put_fpu_long(child, index, data);
362 } 447 }
363 break; 448 break;
364 449
@@ -366,23 +451,23 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
366 return copy_regset_to_user(child, &user_sh64_native_view, 451 return copy_regset_to_user(child, &user_sh64_native_view,
367 REGSET_GENERAL, 452 REGSET_GENERAL,
368 0, sizeof(struct pt_regs), 453 0, sizeof(struct pt_regs),
369 (void __user *)data); 454 datap);
370 case PTRACE_SETREGS: 455 case PTRACE_SETREGS:
371 return copy_regset_from_user(child, &user_sh64_native_view, 456 return copy_regset_from_user(child, &user_sh64_native_view,
372 REGSET_GENERAL, 457 REGSET_GENERAL,
373 0, sizeof(struct pt_regs), 458 0, sizeof(struct pt_regs),
374 (const void __user *)data); 459 datap);
375#ifdef CONFIG_SH_FPU 460#ifdef CONFIG_SH_FPU
376 case PTRACE_GETFPREGS: 461 case PTRACE_GETFPREGS:
377 return copy_regset_to_user(child, &user_sh64_native_view, 462 return copy_regset_to_user(child, &user_sh64_native_view,
378 REGSET_FPU, 463 REGSET_FPU,
379 0, sizeof(struct user_fpu_struct), 464 0, sizeof(struct user_fpu_struct),
380 (void __user *)data); 465 datap);
381 case PTRACE_SETFPREGS: 466 case PTRACE_SETFPREGS:
382 return copy_regset_from_user(child, &user_sh64_native_view, 467 return copy_regset_from_user(child, &user_sh64_native_view,
383 REGSET_FPU, 468 REGSET_FPU,
384 0, sizeof(struct user_fpu_struct), 469 0, sizeof(struct user_fpu_struct),
385 (const void __user *)data); 470 datap);
386#endif 471#endif
387 default: 472 default:
388 ret = ptrace_request(child, request, addr, data); 473 ret = ptrace_request(child, request, addr, data);
@@ -392,13 +477,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
392 return ret; 477 return ret;
393} 478}
394 479
395asmlinkage int sh64_ptrace(long request, long pid, long addr, long data) 480asmlinkage int sh64_ptrace(long request, long pid,
481 unsigned long addr, unsigned long data)
396{ 482{
397#define WPC_DBRMODE 0x0d104008 483#define WPC_DBRMODE 0x0d104008
398 static int first_call = 1; 484 static unsigned long first_call;
399 485
400 lock_kernel(); 486 if (!test_and_set_bit(0, &first_call)) {
401 if (first_call) {
402 /* Set WPC.DBRMODE to 0. This makes all debug events get 487 /* Set WPC.DBRMODE to 0. This makes all debug events get
403 * delivered through RESVEC, i.e. into the handlers in entry.S. 488 * delivered through RESVEC, i.e. into the handlers in entry.S.
404 * (If the kernel was downloaded using a remote gdb, WPC.DBRMODE 489 * (If the kernel was downloaded using a remote gdb, WPC.DBRMODE
@@ -408,9 +493,7 @@ asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
408 * the remote gdb.) */ 493 * the remote gdb.) */
409 printk("DBRMODE set to 0 to permit native debugging\n"); 494 printk("DBRMODE set to 0 to permit native debugging\n");
410 poke_real_address_q(WPC_DBRMODE, 0); 495 poke_real_address_q(WPC_DBRMODE, 0);
411 first_call = 0;
412 } 496 }
413 unlock_kernel();
414 497
415 return sys_ptrace(request, pid, addr, data); 498 return sys_ptrace(request, pid, addr, data);
416} 499}
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..d6b018c7ebdc 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>
@@ -42,6 +41,7 @@
42#include <asm/smp.h> 41#include <asm/smp.h>
43#include <asm/mmu_context.h> 42#include <asm/mmu_context.h>
44#include <asm/mmzone.h> 43#include <asm/mmzone.h>
44#include <asm/sparsemem.h>
45 45
46/* 46/*
47 * Initialize loops_per_jiffy as 10000000 (1000MIPS). 47 * Initialize loops_per_jiffy as 10000000 (1000MIPS).
@@ -53,6 +53,7 @@ struct sh_cpuinfo cpu_data[NR_CPUS] __read_mostly = {
53 .type = CPU_SH_NONE, 53 .type = CPU_SH_NONE,
54 .family = CPU_FAMILY_UNKNOWN, 54 .family = CPU_FAMILY_UNKNOWN,
55 .loops_per_jiffy = 10000000, 55 .loops_per_jiffy = 10000000,
56 .phys_bits = MAX_PHYSMEM_BITS,
56 }, 57 },
57}; 58};
58EXPORT_SYMBOL(cpu_data); 59EXPORT_SYMBOL(cpu_data);
@@ -136,8 +137,9 @@ void __init check_for_initrd(void)
136 goto disable; 137 goto disable;
137 } 138 }
138 139
139 if (unlikely(start < PAGE_OFFSET)) { 140 if (unlikely(start < __MEMORY_START)) {
140 pr_err("initrd start < PAGE_OFFSET\n"); 141 pr_err("initrd start (%08lx) < __MEMORY_START(%x)\n",
142 start, __MEMORY_START);
141 goto disable; 143 goto disable;
142 } 144 }
143 145
@@ -158,7 +160,7 @@ void __init check_for_initrd(void)
158 /* 160 /*
159 * Address sanitization 161 * Address sanitization
160 */ 162 */
161 initrd_start = (unsigned long)__va(__pa(start)); 163 initrd_start = (unsigned long)__va(start);
162 initrd_end = initrd_start + INITRD_SIZE; 164 initrd_end = initrd_start + INITRD_SIZE;
163 165
164 memblock_reserve(__pa(initrd_start), INITRD_SIZE); 166 memblock_reserve(__pa(initrd_start), INITRD_SIZE);
@@ -432,6 +434,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
432 if (c->flags & CPU_HAS_L2_CACHE) 434 if (c->flags & CPU_HAS_L2_CACHE)
433 show_cacheinfo(m, "scache", c->scache); 435 show_cacheinfo(m, "scache", c->scache);
434 436
437 seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits);
438
435 seq_printf(m, "bogomips\t: %lu.%02lu\n", 439 seq_printf(m, "bogomips\t: %lu.%02lu\n",
436 c->loops_per_jiffy/(500000/HZ), 440 c->loops_per_jiffy/(500000/HZ),
437 (c->loops_per_jiffy/(5000/HZ)) % 100); 441 (c->loops_per_jiffy/(5000/HZ)) % 100);
@@ -458,17 +462,3 @@ const struct seq_operations cpuinfo_op = {
458 .show = show_cpuinfo, 462 .show = show_cpuinfo,
459}; 463};
460#endif /* CONFIG_PROC_FS */ 464#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..c3e61b366493 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -79,7 +79,7 @@ config 29BIT
79 79
80config 32BIT 80config 32BIT
81 bool 81 bool
82 default y if CPU_SH5 82 default y if CPU_SH5 || !MMU
83 83
84config PMB 84config PMB
85 bool "Support 32-bit physical addressing through PMB" 85 bool "Support 32-bit physical addressing through PMB"
@@ -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..150aa326afff 100644
--- a/arch/sh/mm/Makefile
+++ b/arch/sh/mm/Makefile
@@ -15,7 +15,7 @@ cacheops-$(CONFIG_CPU_SHX3) += cache-shx3.o
15obj-y += $(cacheops-y) 15obj-y += $(cacheops-y)
16 16
17mmu-y := nommu.o extable_32.o 17mmu-y := nommu.o extable_32.o
18mmu-$(CONFIG_MMU) := extable_$(BITS).o fault_$(BITS).o \ 18mmu-$(CONFIG_MMU) := extable_$(BITS).o fault_$(BITS).o gup.o \
19 ioremap.o kmap.o pgtable.o tlbflush_$(BITS).o 19 ioremap.o kmap.o pgtable.o tlbflush_$(BITS).o
20 20
21obj-y += $(mmu-y) 21obj-y += $(mmu-y)
@@ -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..40733a952402 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.
@@ -78,21 +79,20 @@ void dma_generic_free_coherent(struct device *dev, size_t size,
78void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 79void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
79 enum dma_data_direction direction) 80 enum dma_data_direction direction)
80{ 81{
81#if defined(CONFIG_CPU_SH5) || defined(CONFIG_PMB) 82 void *addr;
82 void *p1addr = vaddr; 83
83#else 84 addr = __in_29bit_mode() ?
84 void *p1addr = (void*) P1SEGADDR((unsigned long)vaddr); 85 (void *)P1SEGADDR((unsigned long)vaddr) : vaddr;
85#endif
86 86
87 switch (direction) { 87 switch (direction) {
88 case DMA_FROM_DEVICE: /* invalidate only */ 88 case DMA_FROM_DEVICE: /* invalidate only */
89 __flush_invalidate_region(p1addr, size); 89 __flush_invalidate_region(addr, size);
90 break; 90 break;
91 case DMA_TO_DEVICE: /* writeback only */ 91 case DMA_TO_DEVICE: /* writeback only */
92 __flush_wback_region(p1addr, size); 92 __flush_wback_region(addr, size);
93 break; 93 break;
94 case DMA_BIDIRECTIONAL: /* writeback and invalidate */ 94 case DMA_BIDIRECTIONAL: /* writeback and invalidate */
95 __flush_purge_region(p1addr, size); 95 __flush_purge_region(addr, size);
96 break; 96 break;
97 default: 97 default:
98 BUG(); 98 BUG();
diff --git a/arch/sh/mm/gup.c b/arch/sh/mm/gup.c
new file mode 100644
index 000000000000..bf8daf9d9c9b
--- /dev/null
+++ b/arch/sh/mm/gup.c
@@ -0,0 +1,273 @@
1/*
2 * Lockless get_user_pages_fast for SuperH
3 *
4 * Copyright (C) 2009 - 2010 Paul Mundt
5 *
6 * Cloned from the x86 and PowerPC versions, by:
7 *
8 * Copyright (C) 2008 Nick Piggin
9 * Copyright (C) 2008 Novell Inc.
10 */
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <linux/vmstat.h>
14#include <linux/highmem.h>
15#include <asm/pgtable.h>
16
17static inline pte_t gup_get_pte(pte_t *ptep)
18{
19#ifndef CONFIG_X2TLB
20 return ACCESS_ONCE(*ptep);
21#else
22 /*
23 * With get_user_pages_fast, we walk down the pagetables without
24 * taking any locks. For this we would like to load the pointers
25 * atomically, but that is not possible with 64-bit PTEs. What
26 * we do have is the guarantee that a pte will only either go
27 * from not present to present, or present to not present or both
28 * -- it will not switch to a completely different present page
29 * without a TLB flush in between; something that we are blocking
30 * by holding interrupts off.
31 *
32 * Setting ptes from not present to present goes:
33 * ptep->pte_high = h;
34 * smp_wmb();
35 * ptep->pte_low = l;
36 *
37 * And present to not present goes:
38 * ptep->pte_low = 0;
39 * smp_wmb();
40 * ptep->pte_high = 0;
41 *
42 * We must ensure here that the load of pte_low sees l iff pte_high
43 * sees h. We load pte_high *after* loading pte_low, which ensures we
44 * don't see an older value of pte_high. *Then* we recheck pte_low,
45 * which ensures that we haven't picked up a changed pte high. We might
46 * have got rubbish values from pte_low and pte_high, but we are
47 * guaranteed that pte_low will not have the present bit set *unless*
48 * it is 'l'. And get_user_pages_fast only operates on present ptes, so
49 * we're safe.
50 *
51 * gup_get_pte should not be used or copied outside gup.c without being
52 * very careful -- it does not atomically load the pte or anything that
53 * is likely to be useful for you.
54 */
55 pte_t pte;
56
57retry:
58 pte.pte_low = ptep->pte_low;
59 smp_rmb();
60 pte.pte_high = ptep->pte_high;
61 smp_rmb();
62 if (unlikely(pte.pte_low != ptep->pte_low))
63 goto retry;
64
65 return pte;
66#endif
67}
68
69/*
70 * The performance critical leaf functions are made noinline otherwise gcc
71 * inlines everything into a single function which results in too much
72 * register pressure.
73 */
74static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
75 unsigned long end, int write, struct page **pages, int *nr)
76{
77 u64 mask, result;
78 pte_t *ptep;
79
80#ifdef CONFIG_X2TLB
81 result = _PAGE_PRESENT | _PAGE_EXT(_PAGE_EXT_KERN_READ | _PAGE_EXT_USER_READ);
82 if (write)
83 result |= _PAGE_EXT(_PAGE_EXT_KERN_WRITE | _PAGE_EXT_USER_WRITE);
84#elif defined(CONFIG_SUPERH64)
85 result = _PAGE_PRESENT | _PAGE_USER | _PAGE_READ;
86 if (write)
87 result |= _PAGE_WRITE;
88#else
89 result = _PAGE_PRESENT | _PAGE_USER;
90 if (write)
91 result |= _PAGE_RW;
92#endif
93
94 mask = result | _PAGE_SPECIAL;
95
96 ptep = pte_offset_map(&pmd, addr);
97 do {
98 pte_t pte = gup_get_pte(ptep);
99 struct page *page;
100
101 if ((pte_val(pte) & mask) != result) {
102 pte_unmap(ptep);
103 return 0;
104 }
105 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
106 page = pte_page(pte);
107 get_page(page);
108 pages[*nr] = page;
109 (*nr)++;
110
111 } while (ptep++, addr += PAGE_SIZE, addr != end);
112 pte_unmap(ptep - 1);
113
114 return 1;
115}
116
117static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
118 int write, struct page **pages, int *nr)
119{
120 unsigned long next;
121 pmd_t *pmdp;
122
123 pmdp = pmd_offset(&pud, addr);
124 do {
125 pmd_t pmd = *pmdp;
126
127 next = pmd_addr_end(addr, end);
128 if (pmd_none(pmd))
129 return 0;
130 if (!gup_pte_range(pmd, addr, next, write, pages, nr))
131 return 0;
132 } while (pmdp++, addr = next, addr != end);
133
134 return 1;
135}
136
137static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
138 int write, struct page **pages, int *nr)
139{
140 unsigned long next;
141 pud_t *pudp;
142
143 pudp = pud_offset(&pgd, addr);
144 do {
145 pud_t pud = *pudp;
146
147 next = pud_addr_end(addr, end);
148 if (pud_none(pud))
149 return 0;
150 if (!gup_pmd_range(pud, addr, next, write, pages, nr))
151 return 0;
152 } while (pudp++, addr = next, addr != end);
153
154 return 1;
155}
156
157/*
158 * Like get_user_pages_fast() except its IRQ-safe in that it won't fall
159 * back to the regular GUP.
160 */
161int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
162 struct page **pages)
163{
164 struct mm_struct *mm = current->mm;
165 unsigned long addr, len, end;
166 unsigned long next;
167 unsigned long flags;
168 pgd_t *pgdp;
169 int nr = 0;
170
171 start &= PAGE_MASK;
172 addr = start;
173 len = (unsigned long) nr_pages << PAGE_SHIFT;
174 end = start + len;
175 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
176 (void __user *)start, len)))
177 return 0;
178
179 /*
180 * This doesn't prevent pagetable teardown, but does prevent
181 * the pagetables and pages from being freed.
182 */
183 local_irq_save(flags);
184 pgdp = pgd_offset(mm, addr);
185 do {
186 pgd_t pgd = *pgdp;
187
188 next = pgd_addr_end(addr, end);
189 if (pgd_none(pgd))
190 break;
191 if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
192 break;
193 } while (pgdp++, addr = next, addr != end);
194 local_irq_restore(flags);
195
196 return nr;
197}
198
199/**
200 * get_user_pages_fast() - pin user pages in memory
201 * @start: starting user address
202 * @nr_pages: number of pages from start to pin
203 * @write: whether pages will be written to
204 * @pages: array that receives pointers to the pages pinned.
205 * Should be at least nr_pages long.
206 *
207 * Attempt to pin user pages in memory without taking mm->mmap_sem.
208 * If not successful, it will fall back to taking the lock and
209 * calling get_user_pages().
210 *
211 * Returns number of pages pinned. This may be fewer than the number
212 * requested. If nr_pages is 0 or negative, returns 0. If no pages
213 * were pinned, returns -errno.
214 */
215int get_user_pages_fast(unsigned long start, int nr_pages, int write,
216 struct page **pages)
217{
218 struct mm_struct *mm = current->mm;
219 unsigned long addr, len, end;
220 unsigned long next;
221 pgd_t *pgdp;
222 int nr = 0;
223
224 start &= PAGE_MASK;
225 addr = start;
226 len = (unsigned long) nr_pages << PAGE_SHIFT;
227
228 end = start + len;
229 if (end < start)
230 goto slow_irqon;
231
232 local_irq_disable();
233 pgdp = pgd_offset(mm, addr);
234 do {
235 pgd_t pgd = *pgdp;
236
237 next = pgd_addr_end(addr, end);
238 if (pgd_none(pgd))
239 goto slow;
240 if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
241 goto slow;
242 } while (pgdp++, addr = next, addr != end);
243 local_irq_enable();
244
245 VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT);
246 return nr;
247
248 {
249 int ret;
250
251slow:
252 local_irq_enable();
253slow_irqon:
254 /* Try to get the remaining pages with get_user_pages */
255 start += nr << PAGE_SHIFT;
256 pages += nr;
257
258 down_read(&mm->mmap_sem);
259 ret = get_user_pages(current, mm, start,
260 (end - start) >> PAGE_SHIFT, write, 0, pages, NULL);
261 up_read(&mm->mmap_sem);
262
263 /* Have to be a bit careful with return values */
264 if (nr > 0) {
265 if (ret < 0)
266 ret = nr;
267 else
268 ret += nr;
269 }
270
271 return ret;
272 }
273}
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 552bea5113f5..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;
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/mm/uncached.c b/arch/sh/mm/uncached.c
index 8a4eca551fc0..a7767da815e9 100644
--- a/arch/sh/mm/uncached.c
+++ b/arch/sh/mm/uncached.c
@@ -28,7 +28,7 @@ EXPORT_SYMBOL(virt_addr_uncached);
28 28
29void __init uncached_init(void) 29void __init uncached_init(void)
30{ 30{
31#ifdef CONFIG_29BIT 31#if defined(CONFIG_29BIT) || !defined(CONFIG_MMU)
32 uncached_start = P2SEG; 32 uncached_start = P2SEG;
33#else 33#else
34 uncached_start = memory_end; 34 uncached_start = memory_end;
diff --git a/arch/sh/oprofile/Makefile b/arch/sh/oprofile/Makefile
index e85aae73e3dc..ce3b119021e7 100644
--- a/arch/sh/oprofile/Makefile
+++ b/arch/sh/oprofile/Makefile
@@ -1,5 +1,7 @@
1obj-$(CONFIG_OPROFILE) += oprofile.o 1obj-$(CONFIG_OPROFILE) += oprofile.o
2 2
3CFLAGS_common.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
4
3DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ 5DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
4 oprof.o cpu_buffer.o buffer_sync.o \ 6 oprof.o cpu_buffer.o buffer_sync.o \
5 event_buffer.o oprofile_files.o \ 7 event_buffer.o oprofile_files.o \
diff --git a/arch/sh/oprofile/backtrace.c b/arch/sh/oprofile/backtrace.c
index 2bc74de23f08..37f3a75ea6cb 100644
--- a/arch/sh/oprofile/backtrace.c
+++ b/arch/sh/oprofile/backtrace.c
@@ -91,7 +91,7 @@ void sh_backtrace(struct pt_regs * const regs, unsigned int depth)
91 if (depth > backtrace_limit) 91 if (depth > backtrace_limit)
92 depth = backtrace_limit; 92 depth = backtrace_limit;
93 93
94 stackaddr = (unsigned long *)regs->regs[15]; 94 stackaddr = (unsigned long *)kernel_stack_pointer(regs);
95 if (!user_mode(regs)) { 95 if (!user_mode(regs)) {
96 if (depth) 96 if (depth)
97 unwind_stack(NULL, regs, stackaddr, 97 unwind_stack(NULL, regs, stackaddr,
diff --git a/arch/sh/oprofile/common.c b/arch/sh/oprofile/common.c
index e10d89376f9b..b4c2d2b946dd 100644
--- a/arch/sh/oprofile/common.c
+++ b/arch/sh/oprofile/common.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/oprofile/init.c 2 * arch/sh/oprofile/init.c
3 * 3 *
4 * Copyright (C) 2003 - 2008 Paul Mundt 4 * Copyright (C) 2003 - 2010 Paul Mundt
5 * 5 *
6 * Based on arch/mips/oprofile/common.c: 6 * Based on arch/mips/oprofile/common.c:
7 * 7 *
@@ -18,43 +18,46 @@
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 <linux/perf_event.h>
21#include <linux/slab.h>
21#include <asm/processor.h> 22#include <asm/processor.h>
22 23
23#ifdef CONFIG_HW_PERF_EVENTS
24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth); 24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
25 25
26#ifdef CONFIG_HW_PERF_EVENTS
27/*
28 * This will need to be reworked when multiple PMUs are supported.
29 */
30static char *sh_pmu_op_name;
31
26char *op_name_from_perf_id(void) 32char *op_name_from_perf_id(void)
27{ 33{
28 const char *pmu; 34 return sh_pmu_op_name;
29 char buf[20];
30 int size;
31
32 pmu = perf_pmu_name();
33 if (!pmu)
34 return NULL;
35
36 size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
37 if (size > -1 && size < sizeof(buf))
38 return buf;
39
40 return NULL;
41} 35}
42 36
43int __init oprofile_arch_init(struct oprofile_operations *ops) 37int __init oprofile_arch_init(struct oprofile_operations *ops)
44{ 38{
45 ops->backtrace = sh_backtrace; 39 ops->backtrace = sh_backtrace;
46 40
41 if (perf_num_counters() == 0)
42 return -ENODEV;
43
44 sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
45 UTS_MACHINE, perf_pmu_name());
46 if (unlikely(!sh_pmu_op_name))
47 return -ENOMEM;
48
47 return oprofile_perf_init(ops); 49 return oprofile_perf_init(ops);
48} 50}
49 51
50void __exit oprofile_arch_exit(void) 52void __exit oprofile_arch_exit(void)
51{ 53{
52 oprofile_perf_exit(); 54 oprofile_perf_exit();
55 kfree(sh_pmu_op_name);
53} 56}
54#else 57#else
55int __init oprofile_arch_init(struct oprofile_operations *ops) 58int __init oprofile_arch_init(struct oprofile_operations *ops)
56{ 59{
57 pr_info("oprofile: hardware counters not available\n"); 60 ops->backtrace = sh_backtrace;
58 return -ENODEV; 61 return -ENODEV;
59} 62}
60void __exit oprofile_arch_exit(void) {} 63void __exit oprofile_arch_exit(void) {}
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index b25aa554ee5e..0e68465e7b50 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -26,7 +26,6 @@ HD64461 HD64461
267724SE SH_7724_SOLUTION_ENGINE 267724SE SH_7724_SOLUTION_ENGINE
277751SE SH_7751_SOLUTION_ENGINE 277751SE SH_7751_SOLUTION_ENGINE
287780SE SH_7780_SOLUTION_ENGINE 287780SE SH_7780_SOLUTION_ENGINE
297751SYSTEMH SH_7751_SYSTEMH
30HP6XX SH_HP6XX 29HP6XX SH_HP6XX
31DREAMCAST SH_DREAMCAST 30DREAMCAST SH_DREAMCAST
32SNAPGEAR SH_SECUREEDGE5410 31SNAPGEAR SH_SECUREEDGE5410
@@ -52,6 +51,8 @@ MIGOR SH_MIGOR
52RSK7201 SH_RSK7201 51RSK7201 SH_RSK7201
53RSK7203 SH_RSK7203 52RSK7203 SH_RSK7203
54AP325RXA SH_AP325RXA 53AP325RXA SH_AP325RXA
54SH2007 SH_SH2007
55SH7757LCR SH_SH7757LCR
55SH7763RDP SH_SH7763RDP 56SH7763RDP SH_SH7763RDP
56SH7785LCR SH_SH7785LCR 57SH7785LCR SH_SH7785LCR
57SH7785LCR_PT SH_SH7785LCR_PT 58SH7785LCR_PT SH_SH7785LCR_PT
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 3e9d31401fb2..45d9c87d083a 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -1,9 +1,3 @@
1# For a description of the syntax of this configuration file,
2# see Documentation/kbuild/kconfig-language.txt.
3#
4
5mainmenu "Linux/SPARC Kernel Configuration"
6
7config 64BIT 1config 64BIT
8 bool "64-bit kernel" if ARCH = "sparc" 2 bool "64-bit kernel" if ARCH = "sparc"
9 default ARCH = "sparc64" 3 default ARCH = "sparc64"
@@ -19,6 +13,7 @@ config SPARC
19 bool 13 bool
20 default y 14 default y
21 select OF 15 select OF
16 select OF_PROMTREE
22 select HAVE_IDE 17 select HAVE_IDE
23 select HAVE_OPROFILE 18 select HAVE_OPROFILE
24 select HAVE_ARCH_KGDB if !SMP || SPARC64 19 select HAVE_ARCH_KGDB if !SMP || SPARC64
@@ -27,8 +22,6 @@ config SPARC
27 select RTC_CLASS 22 select RTC_CLASS
28 select RTC_DRV_M48T59 23 select RTC_DRV_M48T59
29 select HAVE_IRQ_WORK 24 select HAVE_IRQ_WORK
30 select HAVE_PERF_EVENTS
31 select PERF_USE_VMALLOC
32 select HAVE_DMA_ATTRS 25 select HAVE_DMA_ATTRS
33 select HAVE_DMA_API_DEBUG 26 select HAVE_DMA_API_DEBUG
34 select HAVE_ARCH_JUMP_LABEL 27 select HAVE_ARCH_JUMP_LABEL
@@ -55,7 +48,6 @@ config SPARC64
55 select RTC_DRV_BQ4802 48 select RTC_DRV_BQ4802
56 select RTC_DRV_SUN4V 49 select RTC_DRV_SUN4V
57 select RTC_DRV_STARFIRE 50 select RTC_DRV_STARFIRE
58 select HAVE_IRQ_WORK
59 select HAVE_PERF_EVENTS 51 select HAVE_PERF_EVENTS
60 select PERF_USE_VMALLOC 52 select PERF_USE_VMALLOC
61 53
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/highmem.h b/arch/sparc/include/asm/highmem.h
index ec23b0a87b98..3d7afbb7f4bb 100644
--- a/arch/sparc/include/asm/highmem.h
+++ b/arch/sparc/include/asm/highmem.h
@@ -70,8 +70,8 @@ static inline void kunmap(struct page *page)
70 kunmap_high(page); 70 kunmap_high(page);
71} 71}
72 72
73extern void *kmap_atomic(struct page *page, enum km_type type); 73extern void *__kmap_atomic(struct page *page);
74extern void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type); 74extern void __kunmap_atomic(void *kvaddr);
75extern struct page *kmap_atomic_to_page(void *vaddr); 75extern struct page *kmap_atomic_to_page(void *vaddr);
76 76
77#define flush_cache_kmaps() flush_cache_all() 77#define flush_cache_kmaps() flush_cache_all()
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 2889574608db..c2ced21c9dc1 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -208,6 +208,21 @@ _memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
208#define memset_io(d,c,sz) _memset_io(d,c,sz) 208#define memset_io(d,c,sz) _memset_io(d,c,sz)
209 209
210static inline void 210static inline void
211_sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
212 __kernel_size_t n)
213{
214 char *d = dst;
215
216 while (n--) {
217 char tmp = sbus_readb(src);
218 *d++ = tmp;
219 src++;
220 }
221}
222
223#define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz)
224
225static inline void
211_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) 226_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
212{ 227{
213 char *d = dst; 228 char *d = dst;
@@ -222,6 +237,22 @@ _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
222#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) 237#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
223 238
224static inline void 239static inline void
240_sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
241 __kernel_size_t n)
242{
243 const char *s = src;
244 volatile void __iomem *d = dst;
245
246 while (n--) {
247 char tmp = *s++;
248 sbus_writeb(tmp, d);
249 d++;
250 }
251}
252
253#define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz)
254
255static inline void
225_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) 256_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
226{ 257{
227 const char *s = src; 258 const char *s = src;
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index 9517d063c79c..9c8965415f0a 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -419,6 +419,21 @@ _memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
419#define memset_io(d,c,sz) _memset_io(d,c,sz) 419#define memset_io(d,c,sz) _memset_io(d,c,sz)
420 420
421static inline void 421static inline void
422_sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
423 __kernel_size_t n)
424{
425 char *d = dst;
426
427 while (n--) {
428 char tmp = sbus_readb(src);
429 *d++ = tmp;
430 src++;
431 }
432}
433
434#define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz)
435
436static inline void
422_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n) 437_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
423{ 438{
424 char *d = dst; 439 char *d = dst;
@@ -433,6 +448,22 @@ _memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
433#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz) 448#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
434 449
435static inline void 450static inline void
451_sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
452 __kernel_size_t n)
453{
454 const char *s = src;
455 volatile void __iomem *d = dst;
456
457 while (n--) {
458 char tmp = *s++;
459 sbus_writeb(tmp, d);
460 d++;
461 }
462}
463
464#define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz)
465
466static inline void
436_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n) 467_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
437{ 468{
438 const char *s = src; 469 const char *s = src;
diff --git a/arch/sparc/include/asm/jump_label.h b/arch/sparc/include/asm/jump_label.h
index 62e66d7b2fb6..427d4684e0d2 100644
--- a/arch/sparc/include/asm/jump_label.h
+++ b/arch/sparc/include/asm/jump_label.h
@@ -4,7 +4,6 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/types.h> 6#include <linux/types.h>
7#include <asm/system.h>
8 7
9#define JUMP_LABEL_NOP_SIZE 4 8#define JUMP_LABEL_NOP_SIZE 4
10 9
@@ -14,6 +13,7 @@
14 "nop\n\t" \ 13 "nop\n\t" \
15 "nop\n\t" \ 14 "nop\n\t" \
16 ".pushsection __jump_table, \"a\"\n\t"\ 15 ".pushsection __jump_table, \"a\"\n\t"\
16 ".align 4\n\t" \
17 ".word 1b, %l[" #label "], %c0\n\t" \ 17 ".word 1b, %l[" #label "], %c0\n\t" \
18 ".popsection \n\t" \ 18 ".popsection \n\t" \
19 : : "i" (key) : : label);\ 19 : : "i" (key) : : label);\
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/pci_64.h b/arch/sparc/include/asm/pci_64.h
index 5312782f0b5e..948b686ec089 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -38,7 +38,7 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
38 * types on sparc64. However, it requires that the device 38 * types on sparc64. However, it requires that the device
39 * can drive enough of the 64 bits. 39 * can drive enough of the 64 bits.
40 */ 40 */
41#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0) 41#define PCI64_REQUIRED_MASK (~(u64)0)
42#define PCI64_ADDR_BASE 0xfffc000000000000UL 42#define PCI64_ADDR_BASE 0xfffc000000000000UL
43 43
44#ifdef CONFIG_PCI 44#ifdef CONFIG_PCI
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 0ece77f47753..303bd4dc8292 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -304,10 +304,7 @@ BTFIXUPDEF_CALL(pte_t *, pte_offset_kernel, pmd_t *, unsigned long)
304 * and sun4c is guaranteed to have no highmem anyway. 304 * and sun4c is guaranteed to have no highmem anyway.
305 */ 305 */
306#define pte_offset_map(d, a) pte_offset_kernel(d,a) 306#define pte_offset_map(d, a) pte_offset_kernel(d,a)
307#define pte_offset_map_nested(d, a) pte_offset_kernel(d,a)
308
309#define pte_unmap(pte) do{}while(0) 307#define pte_unmap(pte) do{}while(0)
310#define pte_unmap_nested(pte) do{}while(0)
311 308
312/* Certain architectures need to do special things when pte's 309/* Certain architectures need to do special things when pte's
313 * within a page table are directly modified. Thus, the following 310 * within a page table are directly modified. Thus, the following
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index f5b5fa76c02d..f8dddb7045bb 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -652,9 +652,7 @@ static inline int pte_special(pte_t pte)
652 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) 652 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
653#define pte_offset_kernel pte_index 653#define pte_offset_kernel pte_index
654#define pte_offset_map pte_index 654#define pte_offset_map pte_index
655#define pte_offset_map_nested pte_index
656#define pte_unmap(pte) do { } while (0) 655#define pte_unmap(pte) do { } while (0)
657#define pte_unmap_nested(pte) do { } while (0)
658 656
659/* Actual page table PTE updates. */ 657/* Actual page table PTE updates. */
660extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig); 658extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig);
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/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 0116d8d10def..5ad6e5c5dbb3 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -365,7 +365,7 @@ static int request_fast_irq(unsigned int irq,
365 unsigned long flags; 365 unsigned long flags;
366 unsigned int cpu_irq; 366 unsigned int cpu_irq;
367 int ret; 367 int ret;
368#ifdef CONFIG_SMP 368#if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON
369 struct tt_entry *trap_table; 369 struct tt_entry *trap_table;
370 extern struct tt_entry trapbase_cpu1, trapbase_cpu2, trapbase_cpu3; 370 extern struct tt_entry trapbase_cpu1, trapbase_cpu2, trapbase_cpu3;
371#endif 371#endif
@@ -425,7 +425,7 @@ static int request_fast_irq(unsigned int irq,
425 table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_four = SPARC_NOP; 425 table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_four = SPARC_NOP;
426 426
427 INSTANTIATE(sparc_ttable) 427 INSTANTIATE(sparc_ttable)
428#ifdef CONFIG_SMP 428#if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON
429 trap_table = &trapbase_cpu1; INSTANTIATE(trap_table) 429 trap_table = &trapbase_cpu1; INSTANTIATE(trap_table)
430 trap_table = &trapbase_cpu2; INSTANTIATE(trap_table) 430 trap_table = &trapbase_cpu2; INSTANTIATE(trap_table)
431 trap_table = &trapbase_cpu3; INSTANTIATE(trap_table) 431 trap_table = &trapbase_cpu3; INSTANTIATE(trap_table)
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/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index e1656fc41ccb..7524689b03d2 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -56,8 +56,8 @@ void __init leon_configure_cache_smp(void);
56static inline unsigned long do_swap(volatile unsigned long *ptr, 56static inline unsigned long do_swap(volatile unsigned long *ptr,
57 unsigned long val) 57 unsigned long val)
58{ 58{
59 __asm__ __volatile__("swapa [%1] %2, %0\n\t" : "=&r"(val) 59 __asm__ __volatile__("swapa [%2] %3, %0\n\t" : "=&r"(val)
60 : "r"(ptr), "i"(ASI_LEON_DCACHE_MISS) 60 : "0"(val), "r"(ptr), "i"(ASI_LEON_DCACHE_MISS)
61 : "memory"); 61 : "memory");
62 return val; 62 return val;
63} 63}
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/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/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/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index e608f397e11f..27b9e93d0121 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -323,18 +323,35 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
323 return &user_sparc32_view; 323 return &user_sparc32_view;
324} 324}
325 325
326long arch_ptrace(struct task_struct *child, long request, long addr, long data) 326struct fps {
327 unsigned long regs[32];
328 unsigned long fsr;
329 unsigned long flags;
330 unsigned long extra;
331 unsigned long fpqd;
332 struct fq {
333 unsigned long *insnaddr;
334 unsigned long insn;
335 } fpq[16];
336};
337
338long arch_ptrace(struct task_struct *child, long request,
339 unsigned long addr, unsigned long data)
327{ 340{
328 unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4]; 341 unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4];
342 void __user *addr2p;
329 const struct user_regset_view *view; 343 const struct user_regset_view *view;
344 struct pt_regs __user *pregs;
345 struct fps __user *fps;
330 int ret; 346 int ret;
331 347
332 view = task_user_regset_view(current); 348 view = task_user_regset_view(current);
349 addr2p = (void __user *) addr2;
350 pregs = (struct pt_regs __user *) addr;
351 fps = (struct fps __user *) addr;
333 352
334 switch(request) { 353 switch(request) {
335 case PTRACE_GETREGS: { 354 case PTRACE_GETREGS: {
336 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
337
338 ret = copy_regset_to_user(child, view, REGSET_GENERAL, 355 ret = copy_regset_to_user(child, view, REGSET_GENERAL,
339 32 * sizeof(u32), 356 32 * sizeof(u32),
340 4 * sizeof(u32), 357 4 * sizeof(u32),
@@ -348,8 +365,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
348 } 365 }
349 366
350 case PTRACE_SETREGS: { 367 case PTRACE_SETREGS: {
351 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
352
353 ret = copy_regset_from_user(child, view, REGSET_GENERAL, 368 ret = copy_regset_from_user(child, view, REGSET_GENERAL,
354 32 * sizeof(u32), 369 32 * sizeof(u32),
355 4 * sizeof(u32), 370 4 * sizeof(u32),
@@ -363,19 +378,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
363 } 378 }
364 379
365 case PTRACE_GETFPREGS: { 380 case PTRACE_GETFPREGS: {
366 struct fps {
367 unsigned long regs[32];
368 unsigned long fsr;
369 unsigned long flags;
370 unsigned long extra;
371 unsigned long fpqd;
372 struct fq {
373 unsigned long *insnaddr;
374 unsigned long insn;
375 } fpq[16];
376 };
377 struct fps __user *fps = (struct fps __user *) addr;
378
379 ret = copy_regset_to_user(child, view, REGSET_FP, 381 ret = copy_regset_to_user(child, view, REGSET_FP,
380 0 * sizeof(u32), 382 0 * sizeof(u32),
381 32 * sizeof(u32), 383 32 * sizeof(u32),
@@ -397,19 +399,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
397 } 399 }
398 400
399 case PTRACE_SETFPREGS: { 401 case PTRACE_SETFPREGS: {
400 struct fps {
401 unsigned long regs[32];
402 unsigned long fsr;
403 unsigned long flags;
404 unsigned long extra;
405 unsigned long fpqd;
406 struct fq {
407 unsigned long *insnaddr;
408 unsigned long insn;
409 } fpq[16];
410 };
411 struct fps __user *fps = (struct fps __user *) addr;
412
413 ret = copy_regset_from_user(child, view, REGSET_FP, 402 ret = copy_regset_from_user(child, view, REGSET_FP,
414 0 * sizeof(u32), 403 0 * sizeof(u32),
415 32 * sizeof(u32), 404 32 * sizeof(u32),
@@ -424,8 +413,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
424 413
425 case PTRACE_READTEXT: 414 case PTRACE_READTEXT:
426 case PTRACE_READDATA: 415 case PTRACE_READDATA:
427 ret = ptrace_readdata(child, addr, 416 ret = ptrace_readdata(child, addr, addr2p, data);
428 (void __user *) addr2, data);
429 417
430 if (ret == data) 418 if (ret == data)
431 ret = 0; 419 ret = 0;
@@ -435,8 +423,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
435 423
436 case PTRACE_WRITETEXT: 424 case PTRACE_WRITETEXT:
437 case PTRACE_WRITEDATA: 425 case PTRACE_WRITEDATA:
438 ret = ptrace_writedata(child, (void __user *) addr2, 426 ret = ptrace_writedata(child, addr2p, addr, data);
439 addr, data);
440 427
441 if (ret == data) 428 if (ret == data)
442 ret = 0; 429 ret = 0;
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index aa90da08bf61..9ccc812bc09e 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -969,16 +969,19 @@ struct fps {
969 unsigned long fsr; 969 unsigned long fsr;
970}; 970};
971 971
972long arch_ptrace(struct task_struct *child, long request, long addr, long data) 972long arch_ptrace(struct task_struct *child, long request,
973 unsigned long addr, unsigned long data)
973{ 974{
974 const struct user_regset_view *view = task_user_regset_view(current); 975 const struct user_regset_view *view = task_user_regset_view(current);
975 unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; 976 unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4];
976 struct pt_regs __user *pregs; 977 struct pt_regs __user *pregs;
977 struct fps __user *fps; 978 struct fps __user *fps;
979 void __user *addr2p;
978 int ret; 980 int ret;
979 981
980 pregs = (struct pt_regs __user *) (unsigned long) addr; 982 pregs = (struct pt_regs __user *) addr;
981 fps = (struct fps __user *) (unsigned long) addr; 983 fps = (struct fps __user *) addr;
984 addr2p = (void __user *) addr2;
982 985
983 switch (request) { 986 switch (request) {
984 case PTRACE_PEEKUSR: 987 case PTRACE_PEEKUSR:
@@ -1029,8 +1032,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1029 1032
1030 case PTRACE_READTEXT: 1033 case PTRACE_READTEXT:
1031 case PTRACE_READDATA: 1034 case PTRACE_READDATA:
1032 ret = ptrace_readdata(child, addr, 1035 ret = ptrace_readdata(child, addr, addr2p, data);
1033 (char __user *)addr2, data);
1034 if (ret == data) 1036 if (ret == data)
1035 ret = 0; 1037 ret = 0;
1036 else if (ret >= 0) 1038 else if (ret >= 0)
@@ -1039,8 +1041,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1039 1041
1040 case PTRACE_WRITETEXT: 1042 case PTRACE_WRITETEXT:
1041 case PTRACE_WRITEDATA: 1043 case PTRACE_WRITEDATA:
1042 ret = ptrace_writedata(child, (char __user *) addr2, 1044 ret = ptrace_writedata(child, addr2p, addr, data);
1043 addr, data);
1044 if (ret == data) 1045 if (ret == data)
1045 ret = 0; 1046 ret = 0;
1046 else if (ret >= 0) 1047 else if (ret >= 0)
diff --git a/arch/sparc/kernel/rtrap_32.S b/arch/sparc/kernel/rtrap_32.S
index 4da2e1f66290..5f5f74c2c2ca 100644
--- a/arch/sparc/kernel/rtrap_32.S
+++ b/arch/sparc/kernel/rtrap_32.S
@@ -78,9 +78,9 @@ signal_p:
78 call do_notify_resume 78 call do_notify_resume
79 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr 79 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr
80 80
81 /* Fall through. */ 81 b signal_p
82 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr 82 ld [%curptr + TI_FLAGS], %g2
83 clr %l6 83
84ret_trap_continue: 84ret_trap_continue:
85 sethi %hi(PSR_SYSCALL), %g1 85 sethi %hi(PSR_SYSCALL), %g1
86 andn %t_psr, %g1, %t_psr 86 andn %t_psr, %g1, %t_psr
diff --git a/arch/sparc/kernel/rtrap_64.S b/arch/sparc/kernel/rtrap_64.S
index 090b9e9ad5e3..77f1b95e0806 100644
--- a/arch/sparc/kernel/rtrap_64.S
+++ b/arch/sparc/kernel/rtrap_64.S
@@ -34,37 +34,9 @@ __handle_preemption:
34__handle_user_windows: 34__handle_user_windows:
35 call fault_in_user_windows 35 call fault_in_user_windows
36 wrpr %g0, RTRAP_PSTATE, %pstate 36 wrpr %g0, RTRAP_PSTATE, %pstate
37 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 37 ba,pt %xcc, __handle_preemption_continue
38 /* Redo sched+sig checks */ 38 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
39 ldx [%g6 + TI_FLAGS], %l0
40 andcc %l0, _TIF_NEED_RESCHED, %g0
41
42 be,pt %xcc, 1f
43 nop
44 call schedule
45 wrpr %g0, RTRAP_PSTATE, %pstate
46 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
47 ldx [%g6 + TI_FLAGS], %l0
48
491: andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0
50 be,pt %xcc, __handle_user_windows_continue
51 nop
52 mov %l5, %o1
53 add %sp, PTREGS_OFF, %o0
54 mov %l0, %o2
55
56 call do_notify_resume
57 wrpr %g0, RTRAP_PSTATE, %pstate
58 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
59 /* Signal delivery can modify pt_regs tstate, so we must
60 * reload it.
61 */
62 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
63 sethi %hi(0xf << 20), %l4
64 and %l1, %l4, %l4
65 ba,pt %xcc, __handle_user_windows_continue
66 39
67 andn %l1, %l4, %l1
68__handle_userfpu: 40__handle_userfpu:
69 rd %fprs, %l5 41 rd %fprs, %l5
70 andcc %l5, FPRS_FEF, %g0 42 andcc %l5, FPRS_FEF, %g0
@@ -87,7 +59,7 @@ __handle_signal:
87 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 59 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
88 sethi %hi(0xf << 20), %l4 60 sethi %hi(0xf << 20), %l4
89 and %l1, %l4, %l4 61 and %l1, %l4, %l4
90 ba,pt %xcc, __handle_signal_continue 62 ba,pt %xcc, __handle_preemption_continue
91 andn %l1, %l4, %l1 63 andn %l1, %l4, %l1
92 64
93 /* When returning from a NMI (%pil==15) interrupt we want to 65 /* When returning from a NMI (%pil==15) interrupt we want to
@@ -177,11 +149,9 @@ __handle_preemption_continue:
177 bne,pn %xcc, __handle_preemption 149 bne,pn %xcc, __handle_preemption
178 andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0 150 andcc %l0, _TIF_DO_NOTIFY_RESUME_MASK, %g0
179 bne,pn %xcc, __handle_signal 151 bne,pn %xcc, __handle_signal
180__handle_signal_continue:
181 ldub [%g6 + TI_WSAVED], %o2 152 ldub [%g6 + TI_WSAVED], %o2
182 brnz,pn %o2, __handle_user_windows 153 brnz,pn %o2, __handle_user_windows
183 nop 154 nop
184__handle_user_windows_continue:
185 sethi %hi(TSTATE_PEF), %o0 155 sethi %hi(TSTATE_PEF), %o0
186 andcc %l1, %o0, %g0 156 andcc %l1, %o0, %g0
187 157
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/fault_32.c b/arch/sparc/mm/fault_32.c
index bd8601601afa..5b836f5aea90 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -539,6 +539,12 @@ do_sigbus:
539 __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address); 539 __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address);
540} 540}
541 541
542static void check_stack_aligned(unsigned long sp)
543{
544 if (sp & 0x7UL)
545 force_sig(SIGILL, current);
546}
547
542void window_overflow_fault(void) 548void window_overflow_fault(void)
543{ 549{
544 unsigned long sp; 550 unsigned long sp;
@@ -547,6 +553,8 @@ void window_overflow_fault(void)
547 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) 553 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
548 force_user_fault(sp + 0x38, 1); 554 force_user_fault(sp + 0x38, 1);
549 force_user_fault(sp, 1); 555 force_user_fault(sp, 1);
556
557 check_stack_aligned(sp);
550} 558}
551 559
552void window_underflow_fault(unsigned long sp) 560void window_underflow_fault(unsigned long sp)
@@ -554,6 +562,8 @@ void window_underflow_fault(unsigned long sp)
554 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) 562 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
555 force_user_fault(sp + 0x38, 0); 563 force_user_fault(sp + 0x38, 0);
556 force_user_fault(sp, 0); 564 force_user_fault(sp, 0);
565
566 check_stack_aligned(sp);
557} 567}
558 568
559void window_ret_fault(struct pt_regs *regs) 569void window_ret_fault(struct pt_regs *regs)
@@ -564,4 +574,6 @@ void window_ret_fault(struct pt_regs *regs)
564 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) 574 if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
565 force_user_fault(sp + 0x38, 0); 575 force_user_fault(sp + 0x38, 0);
566 force_user_fault(sp, 0); 576 force_user_fault(sp, 0);
577
578 check_stack_aligned(sp);
567} 579}
diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c
index e139e9cbf5f7..4730eac0747b 100644
--- a/arch/sparc/mm/highmem.c
+++ b/arch/sparc/mm/highmem.c
@@ -29,17 +29,17 @@
29#include <asm/tlbflush.h> 29#include <asm/tlbflush.h>
30#include <asm/fixmap.h> 30#include <asm/fixmap.h>
31 31
32void *kmap_atomic(struct page *page, enum km_type type) 32void *__kmap_atomic(struct page *page)
33{ 33{
34 unsigned long idx;
35 unsigned long vaddr; 34 unsigned long vaddr;
35 long idx, type;
36 36
37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
38 pagefault_disable(); 38 pagefault_disable();
39 if (!PageHighMem(page)) 39 if (!PageHighMem(page))
40 return page_address(page); 40 return page_address(page);
41 41
42 debug_kmap_atomic(type); 42 type = kmap_atomic_idx_push();
43 idx = type + KM_TYPE_NR*smp_processor_id(); 43 idx = type + KM_TYPE_NR*smp_processor_id();
44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
45 45
@@ -63,44 +63,52 @@ void *kmap_atomic(struct page *page, enum km_type type)
63 63
64 return (void*) vaddr; 64 return (void*) vaddr;
65} 65}
66EXPORT_SYMBOL(kmap_atomic); 66EXPORT_SYMBOL(__kmap_atomic);
67 67
68void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 68void __kunmap_atomic(void *kvaddr)
69{ 69{
70#ifdef CONFIG_DEBUG_HIGHMEM
71 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 70 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
72 unsigned long idx = type + KM_TYPE_NR*smp_processor_id(); 71 int type;
73 72
74 if (vaddr < FIXADDR_START) { // FIXME 73 if (vaddr < FIXADDR_START) { // FIXME
75 pagefault_enable(); 74 pagefault_enable();
76 return; 75 return;
77 } 76 }
78 77
79 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx)); 78 type = kmap_atomic_idx();
80 79
81/* XXX Fix - Anton */ 80#ifdef CONFIG_DEBUG_HIGHMEM
81 {
82 unsigned long idx;
83
84 idx = type + KM_TYPE_NR * smp_processor_id();
85 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx));
86
87 /* XXX Fix - Anton */
82#if 0 88#if 0
83 __flush_cache_one(vaddr); 89 __flush_cache_one(vaddr);
84#else 90#else
85 flush_cache_all(); 91 flush_cache_all();
86#endif 92#endif
87 93
88 /* 94 /*
89 * force other mappings to Oops if they'll try to access 95 * force other mappings to Oops if they'll try to access
90 * this pte without first remap it 96 * this pte without first remap it
91 */ 97 */
92 pte_clear(&init_mm, vaddr, kmap_pte-idx); 98 pte_clear(&init_mm, vaddr, kmap_pte-idx);
93/* XXX Fix - Anton */ 99 /* XXX Fix - Anton */
94#if 0 100#if 0
95 __flush_tlb_one(vaddr); 101 __flush_tlb_one(vaddr);
96#else 102#else
97 flush_tlb_all(); 103 flush_tlb_all();
98#endif 104#endif
105 }
99#endif 106#endif
100 107
108 kmap_atomic_idx_pop();
101 pagefault_enable(); 109 pagefault_enable();
102} 110}
103EXPORT_SYMBOL(kunmap_atomic_notypecheck); 111EXPORT_SYMBOL(__kunmap_atomic);
104 112
105/* We may be fed a pagetable here by ptep_to_xxx and others. */ 113/* We may be fed a pagetable here by ptep_to_xxx and others. */
106struct page *kmap_atomic_to_page(void *ptr) 114struct page *kmap_atomic_to_page(void *ptr)
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 4c2572773b55..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
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/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/Kconfig b/arch/tile/Kconfig
index 1eb308cb711a..07ec8a865c1d 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -58,6 +58,9 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING
58config ARCH_PHYS_ADDR_T_64BIT 58config ARCH_PHYS_ADDR_T_64BIT
59 def_bool y 59 def_bool y
60 60
61config ARCH_DMA_ADDR_T_64BIT
62 def_bool y
63
61config LOCKDEP_SUPPORT 64config LOCKDEP_SUPPORT
62 def_bool y 65 def_bool y
63 66
@@ -96,6 +99,7 @@ config HVC_TILE
96 99
97config TILE 100config TILE
98 def_bool y 101 def_bool y
102 select HAVE_KVM if !TILEGX
99 select GENERIC_FIND_FIRST_BIT 103 select GENERIC_FIND_FIRST_BIT
100 select GENERIC_FIND_NEXT_BIT 104 select GENERIC_FIND_NEXT_BIT
101 select USE_GENERIC_SMP_HELPERS 105 select USE_GENERIC_SMP_HELPERS
@@ -113,8 +117,6 @@ config TILE
113# config HUGETLB_PAGE_SIZE_VARIABLE 117# config HUGETLB_PAGE_SIZE_VARIABLE
114 118
115 119
116mainmenu "Linux/TILE Kernel Configuration"
117
118# Please note: TILE-Gx support is not yet finalized; this is 120# Please note: TILE-Gx support is not yet finalized; this is
119# the preliminary support. TILE-Gx drivers are only provided 121# the preliminary support. TILE-Gx drivers are only provided
120# with the alpha or beta test versions for Tilera customers. 122# with the alpha or beta test versions for Tilera customers.
@@ -236,9 +238,9 @@ choice
236 If you are not absolutely sure what you are doing, leave this 238 If you are not absolutely sure what you are doing, leave this
237 option alone! 239 option alone!
238 240
239 config VMSPLIT_375G 241 config VMSPLIT_3_75G
240 bool "3.75G/0.25G user/kernel split (no kernel networking)" 242 bool "3.75G/0.25G user/kernel split (no kernel networking)"
241 config VMSPLIT_35G 243 config VMSPLIT_3_5G
242 bool "3.5G/0.5G user/kernel split" 244 bool "3.5G/0.5G user/kernel split"
243 config VMSPLIT_3G 245 config VMSPLIT_3G
244 bool "3G/1G user/kernel split" 246 bool "3G/1G user/kernel split"
@@ -252,8 +254,8 @@ endchoice
252 254
253config PAGE_OFFSET 255config PAGE_OFFSET
254 hex 256 hex
255 default 0xF0000000 if VMSPLIT_375G 257 default 0xF0000000 if VMSPLIT_3_75G
256 default 0xE0000000 if VMSPLIT_35G 258 default 0xE0000000 if VMSPLIT_3_5G
257 default 0xB0000000 if VMSPLIT_3G_OPT 259 default 0xB0000000 if VMSPLIT_3G_OPT
258 default 0x80000000 if VMSPLIT_2G 260 default 0x80000000 if VMSPLIT_2G
259 default 0x40000000 if VMSPLIT_1G 261 default 0x40000000 if VMSPLIT_1G
@@ -314,6 +316,15 @@ config HARDWALL
314 bool "Hardwall support to allow access to user dynamic network" 316 bool "Hardwall support to allow access to user dynamic network"
315 default y 317 default y
316 318
319config KERNEL_PL
320 int "Processor protection level for kernel"
321 range 1 2
322 default "1"
323 ---help---
324 This setting determines the processor protection level the
325 kernel will be built to run at. Generally you should use
326 the default value here.
327
317endmenu # Tilera-specific configuration 328endmenu # Tilera-specific configuration
318 329
319menu "Bus options" 330menu "Bus options"
@@ -354,3 +365,5 @@ source "security/Kconfig"
354source "crypto/Kconfig" 365source "crypto/Kconfig"
355 366
356source "lib/Kconfig" 367source "lib/Kconfig"
368
369source "arch/tile/kvm/Kconfig"
diff --git a/arch/tile/Makefile b/arch/tile/Makefile
index fd8f6bb5face..17acce70569b 100644
--- a/arch/tile/Makefile
+++ b/arch/tile/Makefile
@@ -26,8 +26,9 @@ $(error Set TILERA_ROOT or CROSS_COMPILE when building $(ARCH) on $(HOST_ARCH))
26 endif 26 endif
27endif 27endif
28 28
29 29ifneq ($(CONFIG_DEBUG_EXTRA_FLAGS),"")
30KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS) 30KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS)
31endif
31 32
32LIBGCC_PATH := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 33LIBGCC_PATH := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
33 34
@@ -49,6 +50,20 @@ head-y := arch/tile/kernel/head_$(BITS).o
49libs-y += arch/tile/lib/ 50libs-y += arch/tile/lib/
50libs-y += $(LIBGCC_PATH) 51libs-y += $(LIBGCC_PATH)
51 52
52
53# See arch/tile/Kbuild for content of core part of the kernel 53# See arch/tile/Kbuild for content of core part of the kernel
54core-y += arch/tile/ 54core-y += arch/tile/
55
56core-$(CONFIG_KVM) += arch/tile/kvm/
57
58ifdef TILERA_ROOT
59INSTALL_PATH ?= $(TILERA_ROOT)/tile/boot
60endif
61
62install:
63 install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE)
64 install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
65 install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
66
67define archhelp
68 echo ' install - install kernel into $(INSTALL_PATH)'
69endef
diff --git a/arch/tile/include/arch/sim.h b/arch/tile/include/arch/sim.h
new file mode 100644
index 000000000000..74b7c1624d34
--- /dev/null
+++ b/arch/tile/include/arch/sim.h
@@ -0,0 +1,619 @@
1/*
2 * Copyright 2010 Tilera Corporation. 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, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15/**
16 * @file
17 *
18 * Provides an API for controlling the simulator at runtime.
19 */
20
21/**
22 * @addtogroup arch_sim
23 * @{
24 *
25 * An API for controlling the simulator at runtime.
26 *
27 * The simulator's behavior can be modified while it is running.
28 * For example, human-readable trace output can be enabled and disabled
29 * around code of interest.
30 *
31 * There are two ways to modify simulator behavior:
32 * programmatically, by calling various sim_* functions, and
33 * interactively, by entering commands like "sim set functional true"
34 * at the tile-monitor prompt. Typing "sim help" at that prompt provides
35 * a list of interactive commands.
36 *
37 * All interactive commands can also be executed programmatically by
38 * passing a string to the sim_command function.
39 */
40
41#ifndef __ARCH_SIM_H__
42#define __ARCH_SIM_H__
43
44#include <arch/sim_def.h>
45#include <arch/abi.h>
46
47#ifndef __ASSEMBLER__
48
49#include <arch/spr_def.h>
50
51
52/**
53 * Return true if the current program is running under a simulator,
54 * rather than on real hardware. If running on hardware, other "sim_xxx()"
55 * calls have no useful effect.
56 */
57static inline int
58sim_is_simulator(void)
59{
60 return __insn_mfspr(SPR_SIM_CONTROL) != 0;
61}
62
63
64/**
65 * Checkpoint the simulator state to a checkpoint file.
66 *
67 * The checkpoint file name is either the default or the name specified
68 * on the command line with "--checkpoint-file".
69 */
70static __inline void
71sim_checkpoint(void)
72{
73 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_CHECKPOINT);
74}
75
76
77/**
78 * Report whether or not various kinds of simulator tracing are enabled.
79 *
80 * @return The bitwise OR of these values:
81 *
82 * SIM_TRACE_CYCLES (--trace-cycles),
83 * SIM_TRACE_ROUTER (--trace-router),
84 * SIM_TRACE_REGISTER_WRITES (--trace-register-writes),
85 * SIM_TRACE_DISASM (--trace-disasm),
86 * SIM_TRACE_STALL_INFO (--trace-stall-info)
87 * SIM_TRACE_MEMORY_CONTROLLER (--trace-memory-controller)
88 * SIM_TRACE_L2_CACHE (--trace-l2)
89 * SIM_TRACE_LINES (--trace-lines)
90 */
91static __inline unsigned int
92sim_get_tracing(void)
93{
94 return __insn_mfspr(SPR_SIM_CONTROL) & SIM_TRACE_FLAG_MASK;
95}
96
97
98/**
99 * Turn on or off different kinds of simulator tracing.
100 *
101 * @param mask Either one of these special values:
102 *
103 * SIM_TRACE_NONE (turns off tracing),
104 * SIM_TRACE_ALL (turns on all possible tracing).
105 *
106 * or the bitwise OR of these values:
107 *
108 * SIM_TRACE_CYCLES (--trace-cycles),
109 * SIM_TRACE_ROUTER (--trace-router),
110 * SIM_TRACE_REGISTER_WRITES (--trace-register-writes),
111 * SIM_TRACE_DISASM (--trace-disasm),
112 * SIM_TRACE_STALL_INFO (--trace-stall-info)
113 * SIM_TRACE_MEMORY_CONTROLLER (--trace-memory-controller)
114 * SIM_TRACE_L2_CACHE (--trace-l2)
115 * SIM_TRACE_LINES (--trace-lines)
116 */
117static __inline void
118sim_set_tracing(unsigned int mask)
119{
120 __insn_mtspr(SPR_SIM_CONTROL, SIM_TRACE_SPR_ARG(mask));
121}
122
123
124/**
125 * Request dumping of different kinds of simulator state.
126 *
127 * @param mask Either this special value:
128 *
129 * SIM_DUMP_ALL (dump all known state)
130 *
131 * or the bitwise OR of these values:
132 *
133 * SIM_DUMP_REGS (the register file),
134 * SIM_DUMP_SPRS (the SPRs),
135 * SIM_DUMP_ITLB (the iTLB),
136 * SIM_DUMP_DTLB (the dTLB),
137 * SIM_DUMP_L1I (the L1 I-cache),
138 * SIM_DUMP_L1D (the L1 D-cache),
139 * SIM_DUMP_L2 (the L2 cache),
140 * SIM_DUMP_SNREGS (the switch register file),
141 * SIM_DUMP_SNITLB (the switch iTLB),
142 * SIM_DUMP_SNL1I (the switch L1 I-cache),
143 * SIM_DUMP_BACKTRACE (the current backtrace)
144 */
145static __inline void
146sim_dump(unsigned int mask)
147{
148 __insn_mtspr(SPR_SIM_CONTROL, SIM_DUMP_SPR_ARG(mask));
149}
150
151
152/**
153 * Print a string to the simulator stdout.
154 *
155 * @param str The string to be written; a newline is automatically added.
156 */
157static __inline void
158sim_print_string(const char* str)
159{
160 int i;
161 for (i = 0; str[i] != 0; i++)
162 {
163 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
164 (str[i] << _SIM_CONTROL_OPERATOR_BITS));
165 }
166 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PUTC |
167 (SIM_PUTC_FLUSH_STRING << _SIM_CONTROL_OPERATOR_BITS));
168}
169
170
171/**
172 * Execute a simulator command string.
173 *
174 * Type 'sim help' at the tile-monitor prompt to learn what commands
175 * are available. Note the use of the tile-monitor "sim" command to
176 * pass commands to the simulator.
177 *
178 * The argument to sim_command() does not include the leading "sim"
179 * prefix used at the tile-monitor prompt; for example, you might call
180 * sim_command("trace disasm").
181 */
182static __inline void
183sim_command(const char* str)
184{
185 int c;
186 do
187 {
188 c = *str++;
189 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_COMMAND |
190 (c << _SIM_CONTROL_OPERATOR_BITS));
191 }
192 while (c);
193}
194
195
196
197#ifndef __DOXYGEN__
198
199/**
200 * The underlying implementation of "_sim_syscall()".
201 *
202 * We use extra "and" instructions to ensure that all the values
203 * we are passing to the simulator are actually valid in the registers
204 * (i.e. returned from memory) prior to the SIM_CONTROL spr.
205 */
206static __inline int _sim_syscall0(int val)
207{
208 long result;
209 __asm__ __volatile__ ("mtspr SIM_CONTROL, r0"
210 : "=R00" (result) : "R00" (val));
211 return result;
212}
213
214static __inline int _sim_syscall1(int val, long arg1)
215{
216 long result;
217 __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
218 : "=R00" (result) : "R00" (val), "R01" (arg1));
219 return result;
220}
221
222static __inline int _sim_syscall2(int val, long arg1, long arg2)
223{
224 long result;
225 __asm__ __volatile__ ("{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
226 : "=R00" (result)
227 : "R00" (val), "R01" (arg1), "R02" (arg2));
228 return result;
229}
230
231/* Note that _sim_syscall3() and higher are technically at risk of
232 receiving an interrupt right before the mtspr bundle, in which case
233 the register values for arguments 3 and up may still be in flight
234 to the core from a stack frame reload. */
235
236static __inline int _sim_syscall3(int val, long arg1, long arg2, long arg3)
237{
238 long result;
239 __asm__ __volatile__ ("{ and zero, r3, r3 };"
240 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
241 : "=R00" (result)
242 : "R00" (val), "R01" (arg1), "R02" (arg2),
243 "R03" (arg3));
244 return result;
245}
246
247static __inline int _sim_syscall4(int val, long arg1, long arg2, long arg3,
248 long arg4)
249{
250 long result;
251 __asm__ __volatile__ ("{ and zero, r3, r4 };"
252 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
253 : "=R00" (result)
254 : "R00" (val), "R01" (arg1), "R02" (arg2),
255 "R03" (arg3), "R04" (arg4));
256 return result;
257}
258
259static __inline int _sim_syscall5(int val, long arg1, long arg2, long arg3,
260 long arg4, long arg5)
261{
262 long result;
263 __asm__ __volatile__ ("{ and zero, r3, r4; and zero, r5, r5 };"
264 "{ and zero, r1, r2; mtspr SIM_CONTROL, r0 }"
265 : "=R00" (result)
266 : "R00" (val), "R01" (arg1), "R02" (arg2),
267 "R03" (arg3), "R04" (arg4), "R05" (arg5));
268 return result;
269}
270
271
272/**
273 * Make a special syscall to the simulator itself, if running under
274 * simulation. This is used as the implementation of other functions
275 * and should not be used outside this file.
276 *
277 * @param syscall_num The simulator syscall number.
278 * @param nr The number of additional arguments provided.
279 *
280 * @return Varies by syscall.
281 */
282#define _sim_syscall(syscall_num, nr, args...) \
283 _sim_syscall##nr( \
284 ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS) | SIM_CONTROL_SYSCALL, args)
285
286
287/* Values for the "access_mask" parameters below. */
288#define SIM_WATCHPOINT_READ 1
289#define SIM_WATCHPOINT_WRITE 2
290#define SIM_WATCHPOINT_EXECUTE 4
291
292
293static __inline int
294sim_add_watchpoint(unsigned int process_id,
295 unsigned long address,
296 unsigned long size,
297 unsigned int access_mask,
298 unsigned long user_data)
299{
300 return _sim_syscall(SIM_SYSCALL_ADD_WATCHPOINT, 5, process_id,
301 address, size, access_mask, user_data);
302}
303
304
305static __inline int
306sim_remove_watchpoint(unsigned int process_id,
307 unsigned long address,
308 unsigned long size,
309 unsigned int access_mask,
310 unsigned long user_data)
311{
312 return _sim_syscall(SIM_SYSCALL_REMOVE_WATCHPOINT, 5, process_id,
313 address, size, access_mask, user_data);
314}
315
316
317/**
318 * Return value from sim_query_watchpoint.
319 */
320struct SimQueryWatchpointStatus
321{
322 /**
323 * 0 if a watchpoint fired, 1 if no watchpoint fired, or -1 for
324 * error (meaning a bad process_id).
325 */
326 int syscall_status;
327
328 /**
329 * The address of the watchpoint that fired (this is the address
330 * passed to sim_add_watchpoint, not an address within that range
331 * that actually triggered the watchpoint).
332 */
333 unsigned long address;
334
335 /** The arbitrary user_data installed by sim_add_watchpoint. */
336 unsigned long user_data;
337};
338
339
340static __inline struct SimQueryWatchpointStatus
341sim_query_watchpoint(unsigned int process_id)
342{
343 struct SimQueryWatchpointStatus status;
344 long val = SIM_CONTROL_SYSCALL |
345 (SIM_SYSCALL_QUERY_WATCHPOINT << _SIM_CONTROL_OPERATOR_BITS);
346 __asm__ __volatile__ ("{ and zero, r1, r1; mtspr SIM_CONTROL, r0 }"
347 : "=R00" (status.syscall_status),
348 "=R01" (status.address),
349 "=R02" (status.user_data)
350 : "R00" (val), "R01" (process_id));
351 return status;
352}
353
354
355/* On the simulator, confirm lines have been evicted everywhere. */
356static __inline void
357sim_validate_lines_evicted(unsigned long long pa, unsigned long length)
358{
359#ifdef __LP64__
360 _sim_syscall(SIM_SYSCALL_VALIDATE_LINES_EVICTED, 2, pa, length);
361#else
362 _sim_syscall(SIM_SYSCALL_VALIDATE_LINES_EVICTED, 4,
363 0 /* dummy */, (long)(pa), (long)(pa >> 32), length);
364#endif
365}
366
367
368#endif /* !__DOXYGEN__ */
369
370
371
372
373/**
374 * Modify the shaping parameters of a shim.
375 *
376 * @param shim The shim to modify. One of:
377 * SIM_CONTROL_SHAPING_GBE_0
378 * SIM_CONTROL_SHAPING_GBE_1
379 * SIM_CONTROL_SHAPING_GBE_2
380 * SIM_CONTROL_SHAPING_GBE_3
381 * SIM_CONTROL_SHAPING_XGBE_0
382 * SIM_CONTROL_SHAPING_XGBE_1
383 *
384 * @param type The type of shaping. This should be the same type of
385 * shaping that is already in place on the shim. One of:
386 * SIM_CONTROL_SHAPING_MULTIPLIER
387 * SIM_CONTROL_SHAPING_PPS
388 * SIM_CONTROL_SHAPING_BPS
389 *
390 * @param units The magnitude of the rate. One of:
391 * SIM_CONTROL_SHAPING_UNITS_SINGLE
392 * SIM_CONTROL_SHAPING_UNITS_KILO
393 * SIM_CONTROL_SHAPING_UNITS_MEGA
394 * SIM_CONTROL_SHAPING_UNITS_GIGA
395 *
396 * @param rate The rate to which to change it. This must fit in
397 * SIM_CONTROL_SHAPING_RATE_BITS bits or a warning is issued and
398 * the shaping is not changed.
399 *
400 * @return 0 if no problems were detected in the arguments to sim_set_shaping
401 * or 1 if problems were detected (for example, rate does not fit in 17 bits).
402 */
403static __inline int
404sim_set_shaping(unsigned shim,
405 unsigned type,
406 unsigned units,
407 unsigned rate)
408{
409 if ((rate & ~((1 << SIM_CONTROL_SHAPING_RATE_BITS) - 1)) != 0)
410 return 1;
411
412 __insn_mtspr(SPR_SIM_CONTROL, SIM_SHAPING_SPR_ARG(shim, type, units, rate));
413 return 0;
414}
415
416#ifdef __tilegx__
417
418/** Enable a set of mPIPE links. Pass a -1 link_mask to enable all links. */
419static __inline void
420sim_enable_mpipe_links(unsigned mpipe, unsigned long link_mask)
421{
422 __insn_mtspr(SPR_SIM_CONTROL,
423 (SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE |
424 (mpipe << 8) | (1 << 16) | ((uint_reg_t)link_mask << 32)));
425}
426
427/** Disable a set of mPIPE links. Pass a -1 link_mask to disable all links. */
428static __inline void
429sim_disable_mpipe_links(unsigned mpipe, unsigned long link_mask)
430{
431 __insn_mtspr(SPR_SIM_CONTROL,
432 (SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE |
433 (mpipe << 8) | (0 << 16) | ((uint_reg_t)link_mask << 32)));
434}
435
436#endif /* __tilegx__ */
437
438
439/*
440 * An API for changing "functional" mode.
441 */
442
443#ifndef __DOXYGEN__
444
445#define sim_enable_functional() \
446 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_ENABLE_FUNCTIONAL)
447
448#define sim_disable_functional() \
449 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_DISABLE_FUNCTIONAL)
450
451#endif /* __DOXYGEN__ */
452
453
454/*
455 * Profiler support.
456 */
457
458/**
459 * Turn profiling on for the current task.
460 *
461 * Note that this has no effect if run in an environment without
462 * profiling support (thus, the proper flags to the simulator must
463 * be supplied).
464 */
465static __inline void
466sim_profiler_enable(void)
467{
468 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_ENABLE);
469}
470
471
472/** Turn profiling off for the current task. */
473static __inline void
474sim_profiler_disable(void)
475{
476 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_DISABLE);
477}
478
479
480/**
481 * Turn profiling on or off for the current task.
482 *
483 * @param enabled If true, turns on profiling. If false, turns it off.
484 *
485 * Note that this has no effect if run in an environment without
486 * profiling support (thus, the proper flags to the simulator must
487 * be supplied).
488 */
489static __inline void
490sim_profiler_set_enabled(int enabled)
491{
492 int val =
493 enabled ? SIM_CONTROL_PROFILER_ENABLE : SIM_CONTROL_PROFILER_DISABLE;
494 __insn_mtspr(SPR_SIM_CONTROL, val);
495}
496
497
498/**
499 * Return true if and only if profiling is currently enabled
500 * for the current task.
501 *
502 * This returns false even if sim_profiler_enable() was called
503 * if the current execution environment does not support profiling.
504 */
505static __inline int
506sim_profiler_is_enabled(void)
507{
508 return ((__insn_mfspr(SPR_SIM_CONTROL) & SIM_PROFILER_ENABLED_MASK) != 0);
509}
510
511
512/**
513 * Reset profiling counters to zero for the current task.
514 *
515 * Resetting can be done while profiling is enabled. It does not affect
516 * the chip-wide profiling counters.
517 */
518static __inline void
519sim_profiler_clear(void)
520{
521 __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_PROFILER_CLEAR);
522}
523
524
525/**
526 * Enable specified chip-level profiling counters.
527 *
528 * Does not affect the per-task profiling counters.
529 *
530 * @param mask Either this special value:
531 *
532 * SIM_CHIP_ALL (enables all chip-level components).
533 *
534 * or the bitwise OR of these values:
535 *
536 * SIM_CHIP_MEMCTL (enable all memory controllers)
537 * SIM_CHIP_XAUI (enable all XAUI controllers)
538 * SIM_CHIP_MPIPE (enable all MPIPE controllers)
539 */
540static __inline void
541sim_profiler_chip_enable(unsigned int mask)
542{
543 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask));
544}
545
546
547/**
548 * Disable specified chip-level profiling counters.
549 *
550 * Does not affect the per-task profiling counters.
551 *
552 * @param mask Either this special value:
553 *
554 * SIM_CHIP_ALL (disables all chip-level components).
555 *
556 * or the bitwise OR of these values:
557 *
558 * SIM_CHIP_MEMCTL (disable all memory controllers)
559 * SIM_CHIP_XAUI (disable all XAUI controllers)
560 * SIM_CHIP_MPIPE (disable all MPIPE controllers)
561 */
562static __inline void
563sim_profiler_chip_disable(unsigned int mask)
564{
565 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask));
566}
567
568
569/**
570 * Reset specified chip-level profiling counters to zero.
571 *
572 * Does not affect the per-task profiling counters.
573 *
574 * @param mask Either this special value:
575 *
576 * SIM_CHIP_ALL (clears all chip-level components).
577 *
578 * or the bitwise OR of these values:
579 *
580 * SIM_CHIP_MEMCTL (clear all memory controllers)
581 * SIM_CHIP_XAUI (clear all XAUI controllers)
582 * SIM_CHIP_MPIPE (clear all MPIPE controllers)
583 */
584static __inline void
585sim_profiler_chip_clear(unsigned int mask)
586{
587 __insn_mtspr(SPR_SIM_CONTROL, SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask));
588}
589
590
591/*
592 * Event support.
593 */
594
595#ifndef __DOXYGEN__
596
597static __inline void
598sim_event_begin(unsigned int x)
599{
600#if defined(__tile__) && !defined(__NO_EVENT_SPR__)
601 __insn_mtspr(SPR_EVENT_BEGIN, x);
602#endif
603}
604
605static __inline void
606sim_event_end(unsigned int x)
607{
608#if defined(__tile__) && !defined(__NO_EVENT_SPR__)
609 __insn_mtspr(SPR_EVENT_END, x);
610#endif
611}
612
613#endif /* !__DOXYGEN__ */
614
615#endif /* !__ASSEMBLER__ */
616
617#endif /* !__ARCH_SIM_H__ */
618
619/** @} */
diff --git a/arch/tile/include/arch/sim_def.h b/arch/tile/include/arch/sim_def.h
index 6418fbde063e..7a17082c3773 100644
--- a/arch/tile/include/arch/sim_def.h
+++ b/arch/tile/include/arch/sim_def.h
@@ -1,477 +1,461 @@
1// Copyright 2010 Tilera Corporation. All Rights Reserved. 1/*
2// 2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3// This program is free software; you can redistribute it and/or 3 *
4// modify it under the terms of the GNU General Public License 4 * This program is free software; you can redistribute it and/or
5// as published by the Free Software Foundation, version 2. 5 * modify it under the terms of the GNU General Public License
6// 6 * as published by the Free Software Foundation, version 2.
7// This program is distributed in the hope that it will be useful, but 7 *
8// WITHOUT ANY WARRANTY; without even the implied warranty of 8 * This program is distributed in the hope that it will be useful, but
9// MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10// NON INFRINGEMENT. See the GNU General Public License for 10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11// more details. 11 * NON INFRINGEMENT. See the GNU General Public License for
12 12 * more details.
13//! @file 13 */
14//! 14
15//! Some low-level simulator definitions. 15/**
16//! 16 * @file
17 *
18 * Some low-level simulator definitions.
19 */
17 20
18#ifndef __ARCH_SIM_DEF_H__ 21#ifndef __ARCH_SIM_DEF_H__
19#define __ARCH_SIM_DEF_H__ 22#define __ARCH_SIM_DEF_H__
20 23
21 24
22//! Internal: the low bits of the SIM_CONTROL_* SPR values specify 25/**
23//! the operation to perform, and the remaining bits are 26 * Internal: the low bits of the SIM_CONTROL_* SPR values specify
24//! an operation-specific parameter (often unused). 27 * the operation to perform, and the remaining bits are
25//! 28 * an operation-specific parameter (often unused).
29 */
26#define _SIM_CONTROL_OPERATOR_BITS 8 30#define _SIM_CONTROL_OPERATOR_BITS 8
27 31
28 32
29//== Values which can be written to SPR_SIM_CONTROL. 33/*
34 * Values which can be written to SPR_SIM_CONTROL.
35 */
30 36
31//! If written to SPR_SIM_CONTROL, stops profiling. 37/** If written to SPR_SIM_CONTROL, stops profiling. */
32//!
33#define SIM_CONTROL_PROFILER_DISABLE 0 38#define SIM_CONTROL_PROFILER_DISABLE 0
34 39
35//! If written to SPR_SIM_CONTROL, starts profiling. 40/** If written to SPR_SIM_CONTROL, starts profiling. */
36//!
37#define SIM_CONTROL_PROFILER_ENABLE 1 41#define SIM_CONTROL_PROFILER_ENABLE 1
38 42
39//! If written to SPR_SIM_CONTROL, clears profiling counters. 43/** If written to SPR_SIM_CONTROL, clears profiling counters. */
40//!
41#define SIM_CONTROL_PROFILER_CLEAR 2 44#define SIM_CONTROL_PROFILER_CLEAR 2
42 45
43//! If written to SPR_SIM_CONTROL, checkpoints the simulator. 46/** If written to SPR_SIM_CONTROL, checkpoints the simulator. */
44//!
45#define SIM_CONTROL_CHECKPOINT 3 47#define SIM_CONTROL_CHECKPOINT 3
46 48
47//! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8), 49/**
48//! sets the tracing mask to the given mask. See "sim_set_tracing()". 50 * If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
49//! 51 * sets the tracing mask to the given mask. See "sim_set_tracing()".
52 */
50#define SIM_CONTROL_SET_TRACING 4 53#define SIM_CONTROL_SET_TRACING 4
51 54
52//! If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8), 55/**
53//! dumps the requested items of machine state to the log. 56 * If written to SPR_SIM_CONTROL, combined with a mask (shifted by 8),
54//! 57 * dumps the requested items of machine state to the log.
58 */
55#define SIM_CONTROL_DUMP 5 59#define SIM_CONTROL_DUMP 5
56 60
57//! If written to SPR_SIM_CONTROL, clears chip-level profiling counters. 61/** If written to SPR_SIM_CONTROL, clears chip-level profiling counters. */
58//!
59#define SIM_CONTROL_PROFILER_CHIP_CLEAR 6 62#define SIM_CONTROL_PROFILER_CHIP_CLEAR 6
60 63
61//! If written to SPR_SIM_CONTROL, disables chip-level profiling. 64/** If written to SPR_SIM_CONTROL, disables chip-level profiling. */
62//!
63#define SIM_CONTROL_PROFILER_CHIP_DISABLE 7 65#define SIM_CONTROL_PROFILER_CHIP_DISABLE 7
64 66
65//! If written to SPR_SIM_CONTROL, enables chip-level profiling. 67/** If written to SPR_SIM_CONTROL, enables chip-level profiling. */
66//!
67#define SIM_CONTROL_PROFILER_CHIP_ENABLE 8 68#define SIM_CONTROL_PROFILER_CHIP_ENABLE 8
68 69
69//! If written to SPR_SIM_CONTROL, enables chip-level functional mode 70/** If written to SPR_SIM_CONTROL, enables chip-level functional mode */
70//!
71#define SIM_CONTROL_ENABLE_FUNCTIONAL 9 71#define SIM_CONTROL_ENABLE_FUNCTIONAL 9
72 72
73//! If written to SPR_SIM_CONTROL, disables chip-level functional mode. 73/** If written to SPR_SIM_CONTROL, disables chip-level functional mode. */
74//!
75#define SIM_CONTROL_DISABLE_FUNCTIONAL 10 74#define SIM_CONTROL_DISABLE_FUNCTIONAL 10
76 75
77//! If written to SPR_SIM_CONTROL, enables chip-level functional mode. 76/**
78//! All tiles must perform this write for functional mode to be enabled. 77 * If written to SPR_SIM_CONTROL, enables chip-level functional mode.
79//! Ignored in naked boot mode unless --functional is specified. 78 * All tiles must perform this write for functional mode to be enabled.
80//! WARNING: Only the hypervisor startup code should use this! 79 * Ignored in naked boot mode unless --functional is specified.
81//! 80 * WARNING: Only the hypervisor startup code should use this!
81 */
82#define SIM_CONTROL_ENABLE_FUNCTIONAL_BARRIER 11 82#define SIM_CONTROL_ENABLE_FUNCTIONAL_BARRIER 11
83 83
84//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 84/**
85//! writes a string directly to the simulator output. Written to once for 85 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
86//! each character in the string, plus a final NUL. Instead of NUL, 86 * writes a string directly to the simulator output. Written to once for
87//! you can also use "SIM_PUTC_FLUSH_STRING" or "SIM_PUTC_FLUSH_BINARY". 87 * each character in the string, plus a final NUL. Instead of NUL,
88//! 88 * you can also use "SIM_PUTC_FLUSH_STRING" or "SIM_PUTC_FLUSH_BINARY".
89// ISSUE: Document the meaning of "newline", and the handling of NUL. 89 */
90// 90/* ISSUE: Document the meaning of "newline", and the handling of NUL. */
91#define SIM_CONTROL_PUTC 12 91#define SIM_CONTROL_PUTC 12
92 92
93//! If written to SPR_SIM_CONTROL, clears the --grind-coherence state for 93/**
94//! this core. This is intended to be used before a loop that will 94 * If written to SPR_SIM_CONTROL, clears the --grind-coherence state for
95//! invalidate the cache by loading new data and evicting all current data. 95 * this core. This is intended to be used before a loop that will
96//! Generally speaking, this API should only be used by system code. 96 * invalidate the cache by loading new data and evicting all current data.
97//! 97 * Generally speaking, this API should only be used by system code.
98 */
98#define SIM_CONTROL_GRINDER_CLEAR 13 99#define SIM_CONTROL_GRINDER_CLEAR 13
99 100
100//! If written to SPR_SIM_CONTROL, shuts down the simulator. 101/** If written to SPR_SIM_CONTROL, shuts down the simulator. */
101//!
102#define SIM_CONTROL_SHUTDOWN 14 102#define SIM_CONTROL_SHUTDOWN 14
103 103
104//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 104/**
105//! indicates that a fork syscall just created the given process. 105 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
106//! 106 * indicates that a fork syscall just created the given process.
107 */
107#define SIM_CONTROL_OS_FORK 15 108#define SIM_CONTROL_OS_FORK 15
108 109
109//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 110/**
110//! indicates that an exit syscall was just executed by the given process. 111 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
111//! 112 * indicates that an exit syscall was just executed by the given process.
113 */
112#define SIM_CONTROL_OS_EXIT 16 114#define SIM_CONTROL_OS_EXIT 16
113 115
114//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 116/**
115//! indicates that the OS just switched to the given process. 117 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
116//! 118 * indicates that the OS just switched to the given process.
119 */
117#define SIM_CONTROL_OS_SWITCH 17 120#define SIM_CONTROL_OS_SWITCH 17
118 121
119//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 122/**
120//! indicates that an exec syscall was just executed. Written to once for 123 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
121//! each character in the executable name, plus a final NUL. 124 * indicates that an exec syscall was just executed. Written to once for
122//! 125 * each character in the executable name, plus a final NUL.
126 */
123#define SIM_CONTROL_OS_EXEC 18 127#define SIM_CONTROL_OS_EXEC 18
124 128
125//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 129/**
126//! indicates that an interpreter (PT_INTERP) was loaded. Written to once 130 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
127//! for each character in "ADDR:PATH", plus a final NUL, where "ADDR" is a 131 * indicates that an interpreter (PT_INTERP) was loaded. Written to once
128//! hex load address starting with "0x", and "PATH" is the executable name. 132 * for each character in "ADDR:PATH", plus a final NUL, where "ADDR" is a
129//! 133 * hex load address starting with "0x", and "PATH" is the executable name.
134 */
130#define SIM_CONTROL_OS_INTERP 19 135#define SIM_CONTROL_OS_INTERP 19
131 136
132//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 137/**
133//! indicates that a dll was loaded. Written to once for each character 138 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
134//! in "ADDR:PATH", plus a final NUL, where "ADDR" is a hexadecimal load 139 * indicates that a dll was loaded. Written to once for each character
135//! address starting with "0x", and "PATH" is the executable name. 140 * in "ADDR:PATH", plus a final NUL, where "ADDR" is a hexadecimal load
136//! 141 * address starting with "0x", and "PATH" is the executable name.
142 */
137#define SIM_CONTROL_DLOPEN 20 143#define SIM_CONTROL_DLOPEN 20
138 144
139//! If written to SPR_SIM_CONTROL, combined with a character (shifted by 8), 145/**
140//! indicates that a dll was unloaded. Written to once for each character 146 * If written to SPR_SIM_CONTROL, combined with a character (shifted by 8),
141//! in "ADDR", plus a final NUL, where "ADDR" is a hexadecimal load 147 * indicates that a dll was unloaded. Written to once for each character
142//! address starting with "0x". 148 * in "ADDR", plus a final NUL, where "ADDR" is a hexadecimal load
143//! 149 * address starting with "0x".
150 */
144#define SIM_CONTROL_DLCLOSE 21 151#define SIM_CONTROL_DLCLOSE 21
145 152
146//! If written to SPR_SIM_CONTROL, combined with a flag (shifted by 8), 153/**
147//! indicates whether to allow data reads to remotely-cached 154 * If written to SPR_SIM_CONTROL, combined with a flag (shifted by 8),
148//! dirty cache lines to be cached locally without grinder warnings or 155 * indicates whether to allow data reads to remotely-cached
149//! assertions (used by Linux kernel fast memcpy). 156 * dirty cache lines to be cached locally without grinder warnings or
150//! 157 * assertions (used by Linux kernel fast memcpy).
158 */
151#define SIM_CONTROL_ALLOW_MULTIPLE_CACHING 22 159#define SIM_CONTROL_ALLOW_MULTIPLE_CACHING 22
152 160
153//! If written to SPR_SIM_CONTROL, enables memory tracing. 161/** If written to SPR_SIM_CONTROL, enables memory tracing. */
154//!
155#define SIM_CONTROL_ENABLE_MEM_LOGGING 23 162#define SIM_CONTROL_ENABLE_MEM_LOGGING 23
156 163
157//! If written to SPR_SIM_CONTROL, disables memory tracing. 164/** If written to SPR_SIM_CONTROL, disables memory tracing. */
158//!
159#define SIM_CONTROL_DISABLE_MEM_LOGGING 24 165#define SIM_CONTROL_DISABLE_MEM_LOGGING 24
160 166
161//! If written to SPR_SIM_CONTROL, changes the shaping parameters of one of 167/**
162//! the gbe or xgbe shims. Must specify the shim id, the type, the units, and 168 * If written to SPR_SIM_CONTROL, changes the shaping parameters of one of
163//! the rate, as defined in SIM_SHAPING_SPR_ARG. 169 * the gbe or xgbe shims. Must specify the shim id, the type, the units, and
164//! 170 * the rate, as defined in SIM_SHAPING_SPR_ARG.
171 */
165#define SIM_CONTROL_SHAPING 25 172#define SIM_CONTROL_SHAPING 25
166 173
167//! If written to SPR_SIM_CONTROL, combined with character (shifted by 8), 174/**
168//! requests that a simulator command be executed. Written to once for each 175 * If written to SPR_SIM_CONTROL, combined with character (shifted by 8),
169//! character in the command, plus a final NUL. 176 * requests that a simulator command be executed. Written to once for each
170//! 177 * character in the command, plus a final NUL.
178 */
171#define SIM_CONTROL_COMMAND 26 179#define SIM_CONTROL_COMMAND 26
172 180
173//! If written to SPR_SIM_CONTROL, indicates that the simulated system 181/**
174//! is panicking, to allow debugging via --debug-on-panic. 182 * If written to SPR_SIM_CONTROL, indicates that the simulated system
175//! 183 * is panicking, to allow debugging via --debug-on-panic.
184 */
176#define SIM_CONTROL_PANIC 27 185#define SIM_CONTROL_PANIC 27
177 186
178//! If written to SPR_SIM_CONTROL, triggers a simulator syscall. 187/**
179//! See "sim_syscall()" for more info. 188 * If written to SPR_SIM_CONTROL, triggers a simulator syscall.
180//! 189 * See "sim_syscall()" for more info.
190 */
181#define SIM_CONTROL_SYSCALL 32 191#define SIM_CONTROL_SYSCALL 32
182 192
183//! If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8), 193/**
184//! provides the pid that subsequent SIM_CONTROL_OS_FORK writes should 194 * If written to SPR_SIM_CONTROL, combined with a pid (shifted by 8),
185//! use as the pid, rather than the default previous SIM_CONTROL_OS_SWITCH. 195 * provides the pid that subsequent SIM_CONTROL_OS_FORK writes should
186//! 196 * use as the pid, rather than the default previous SIM_CONTROL_OS_SWITCH.
197 */
187#define SIM_CONTROL_OS_FORK_PARENT 33 198#define SIM_CONTROL_OS_FORK_PARENT 33
188 199
189//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 200/**
190//! (shifted by 8), clears the pending magic data section. The cleared 201 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
191//! pending magic data section and any subsequently appended magic bytes 202 * (shifted by 8), clears the pending magic data section. The cleared
192//! will only take effect when the classifier blast programmer is run. 203 * pending magic data section and any subsequently appended magic bytes
204 * will only take effect when the classifier blast programmer is run.
205 */
193#define SIM_CONTROL_CLEAR_MPIPE_MAGIC_BYTES 34 206#define SIM_CONTROL_CLEAR_MPIPE_MAGIC_BYTES 34
194 207
195//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 208/**
196//! (shifted by 8) and a byte of data (shifted by 16), appends that byte 209 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
197//! to the shim's pending magic data section. The pending magic data 210 * (shifted by 8) and a byte of data (shifted by 16), appends that byte
198//! section takes effect when the classifier blast programmer is run. 211 * to the shim's pending magic data section. The pending magic data
212 * section takes effect when the classifier blast programmer is run.
213 */
199#define SIM_CONTROL_APPEND_MPIPE_MAGIC_BYTE 35 214#define SIM_CONTROL_APPEND_MPIPE_MAGIC_BYTE 35
200 215
201//! If written to SPR_SIM_CONTROL, combined with a mPIPE shim number 216/**
202//! (shifted by 8), an enable=1/disable=0 bit (shifted by 16), and a 217 * If written to SPR_SIM_CONTROL, combined with a mPIPE shim number
203//! mask of links (shifted by 32), enable or disable the corresponding 218 * (shifted by 8), an enable=1/disable=0 bit (shifted by 16), and a
204//! mPIPE links. 219 * mask of links (shifted by 32), enable or disable the corresponding
220 * mPIPE links.
221 */
205#define SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE 36 222#define SIM_CONTROL_ENABLE_MPIPE_LINK_MAGIC_BYTE 36
206 223
207//== Syscall numbers for use with "sim_syscall()".
208 224
209//! Syscall number for sim_add_watchpoint(). 225/*
210//! 226 * Syscall numbers for use with "sim_syscall()".
227 */
228
229/** Syscall number for sim_add_watchpoint(). */
211#define SIM_SYSCALL_ADD_WATCHPOINT 2 230#define SIM_SYSCALL_ADD_WATCHPOINT 2
212 231
213//! Syscall number for sim_remove_watchpoint(). 232/** Syscall number for sim_remove_watchpoint(). */
214//!
215#define SIM_SYSCALL_REMOVE_WATCHPOINT 3 233#define SIM_SYSCALL_REMOVE_WATCHPOINT 3
216 234
217//! Syscall number for sim_query_watchpoint(). 235/** Syscall number for sim_query_watchpoint(). */
218//!
219#define SIM_SYSCALL_QUERY_WATCHPOINT 4 236#define SIM_SYSCALL_QUERY_WATCHPOINT 4
220 237
221//! Syscall number that asserts that the cache lines whose 64-bit PA 238/**
222//! is passed as the second argument to sim_syscall(), and over a 239 * Syscall number that asserts that the cache lines whose 64-bit PA
223//! range passed as the third argument, are no longer in cache. 240 * is passed as the second argument to sim_syscall(), and over a
224//! The simulator raises an error if this is not the case. 241 * range passed as the third argument, are no longer in cache.
225//! 242 * The simulator raises an error if this is not the case.
243 */
226#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5 244#define SIM_SYSCALL_VALIDATE_LINES_EVICTED 5
227 245
228 246
229//== Bit masks which can be shifted by 8, combined with 247/*
230//== SIM_CONTROL_SET_TRACING, and written to SPR_SIM_CONTROL. 248 * Bit masks which can be shifted by 8, combined with
249 * SIM_CONTROL_SET_TRACING, and written to SPR_SIM_CONTROL.
250 */
231 251
232//! @addtogroup arch_sim 252/**
233//! @{ 253 * @addtogroup arch_sim
254 * @{
255 */
234 256
235//! Enable --trace-cycle when passed to simulator_set_tracing(). 257/** Enable --trace-cycle when passed to simulator_set_tracing(). */
236//!
237#define SIM_TRACE_CYCLES 0x01 258#define SIM_TRACE_CYCLES 0x01
238 259
239//! Enable --trace-router when passed to simulator_set_tracing(). 260/** Enable --trace-router when passed to simulator_set_tracing(). */
240//!
241#define SIM_TRACE_ROUTER 0x02 261#define SIM_TRACE_ROUTER 0x02
242 262
243//! Enable --trace-register-writes when passed to simulator_set_tracing(). 263/** Enable --trace-register-writes when passed to simulator_set_tracing(). */
244//!
245#define SIM_TRACE_REGISTER_WRITES 0x04 264#define SIM_TRACE_REGISTER_WRITES 0x04
246 265
247//! Enable --trace-disasm when passed to simulator_set_tracing(). 266/** Enable --trace-disasm when passed to simulator_set_tracing(). */
248//!
249#define SIM_TRACE_DISASM 0x08 267#define SIM_TRACE_DISASM 0x08
250 268
251//! Enable --trace-stall-info when passed to simulator_set_tracing(). 269/** Enable --trace-stall-info when passed to simulator_set_tracing(). */
252//!
253#define SIM_TRACE_STALL_INFO 0x10 270#define SIM_TRACE_STALL_INFO 0x10
254 271
255//! Enable --trace-memory-controller when passed to simulator_set_tracing(). 272/** Enable --trace-memory-controller when passed to simulator_set_tracing(). */
256//!
257#define SIM_TRACE_MEMORY_CONTROLLER 0x20 273#define SIM_TRACE_MEMORY_CONTROLLER 0x20
258 274
259//! Enable --trace-l2 when passed to simulator_set_tracing(). 275/** Enable --trace-l2 when passed to simulator_set_tracing(). */
260//!
261#define SIM_TRACE_L2_CACHE 0x40 276#define SIM_TRACE_L2_CACHE 0x40
262 277
263//! Enable --trace-lines when passed to simulator_set_tracing(). 278/** Enable --trace-lines when passed to simulator_set_tracing(). */
264//!
265#define SIM_TRACE_LINES 0x80 279#define SIM_TRACE_LINES 0x80
266 280
267//! Turn off all tracing when passed to simulator_set_tracing(). 281/** Turn off all tracing when passed to simulator_set_tracing(). */
268//!
269#define SIM_TRACE_NONE 0 282#define SIM_TRACE_NONE 0
270 283
271//! Turn on all tracing when passed to simulator_set_tracing(). 284/** Turn on all tracing when passed to simulator_set_tracing(). */
272//!
273#define SIM_TRACE_ALL (-1) 285#define SIM_TRACE_ALL (-1)
274 286
275//! @} 287/** @} */
276 288
277//! Computes the value to write to SPR_SIM_CONTROL to set tracing flags. 289/** Computes the value to write to SPR_SIM_CONTROL to set tracing flags. */
278//!
279#define SIM_TRACE_SPR_ARG(mask) \ 290#define SIM_TRACE_SPR_ARG(mask) \
280 (SIM_CONTROL_SET_TRACING | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 291 (SIM_CONTROL_SET_TRACING | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
281 292
282 293
283//== Bit masks which can be shifted by 8, combined with 294/*
284//== SIM_CONTROL_DUMP, and written to SPR_SIM_CONTROL. 295 * Bit masks which can be shifted by 8, combined with
296 * SIM_CONTROL_DUMP, and written to SPR_SIM_CONTROL.
297 */
285 298
286//! @addtogroup arch_sim 299/**
287//! @{ 300 * @addtogroup arch_sim
301 * @{
302 */
288 303
289//! Dump the general-purpose registers. 304/** Dump the general-purpose registers. */
290//!
291#define SIM_DUMP_REGS 0x001 305#define SIM_DUMP_REGS 0x001
292 306
293//! Dump the SPRs. 307/** Dump the SPRs. */
294//!
295#define SIM_DUMP_SPRS 0x002 308#define SIM_DUMP_SPRS 0x002
296 309
297//! Dump the ITLB. 310/** Dump the ITLB. */
298//!
299#define SIM_DUMP_ITLB 0x004 311#define SIM_DUMP_ITLB 0x004
300 312
301//! Dump the DTLB. 313/** Dump the DTLB. */
302//!
303#define SIM_DUMP_DTLB 0x008 314#define SIM_DUMP_DTLB 0x008
304 315
305//! Dump the L1 I-cache. 316/** Dump the L1 I-cache. */
306//!
307#define SIM_DUMP_L1I 0x010 317#define SIM_DUMP_L1I 0x010
308 318
309//! Dump the L1 D-cache. 319/** Dump the L1 D-cache. */
310//!
311#define SIM_DUMP_L1D 0x020 320#define SIM_DUMP_L1D 0x020
312 321
313//! Dump the L2 cache. 322/** Dump the L2 cache. */
314//!
315#define SIM_DUMP_L2 0x040 323#define SIM_DUMP_L2 0x040
316 324
317//! Dump the switch registers. 325/** Dump the switch registers. */
318//!
319#define SIM_DUMP_SNREGS 0x080 326#define SIM_DUMP_SNREGS 0x080
320 327
321//! Dump the switch ITLB. 328/** Dump the switch ITLB. */
322//!
323#define SIM_DUMP_SNITLB 0x100 329#define SIM_DUMP_SNITLB 0x100
324 330
325//! Dump the switch L1 I-cache. 331/** Dump the switch L1 I-cache. */
326//!
327#define SIM_DUMP_SNL1I 0x200 332#define SIM_DUMP_SNL1I 0x200
328 333
329//! Dump the current backtrace. 334/** Dump the current backtrace. */
330//!
331#define SIM_DUMP_BACKTRACE 0x400 335#define SIM_DUMP_BACKTRACE 0x400
332 336
333//! Only dump valid lines in caches. 337/** Only dump valid lines in caches. */
334//!
335#define SIM_DUMP_VALID_LINES 0x800 338#define SIM_DUMP_VALID_LINES 0x800
336 339
337//! Dump everything that is dumpable. 340/** Dump everything that is dumpable. */
338//!
339#define SIM_DUMP_ALL (-1 & ~SIM_DUMP_VALID_LINES) 341#define SIM_DUMP_ALL (-1 & ~SIM_DUMP_VALID_LINES)
340 342
341// @} 343/** @} */
342 344
343//! Computes the value to write to SPR_SIM_CONTROL to dump machine state. 345/** Computes the value to write to SPR_SIM_CONTROL to dump machine state. */
344//!
345#define SIM_DUMP_SPR_ARG(mask) \ 346#define SIM_DUMP_SPR_ARG(mask) \
346 (SIM_CONTROL_DUMP | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 347 (SIM_CONTROL_DUMP | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
347 348
348 349
349//== Bit masks which can be shifted by 8, combined with 350/*
350//== SIM_CONTROL_PROFILER_CHIP_xxx, and written to SPR_SIM_CONTROL. 351 * Bit masks which can be shifted by 8, combined with
352 * SIM_CONTROL_PROFILER_CHIP_xxx, and written to SPR_SIM_CONTROL.
353 */
351 354
352//! @addtogroup arch_sim 355/**
353//! @{ 356 * @addtogroup arch_sim
357 * @{
358 */
354 359
355//! Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. 360/** Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. */
356//!
357#define SIM_CHIP_MEMCTL 0x001 361#define SIM_CHIP_MEMCTL 0x001
358 362
359//! Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. 363/** Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */
360//!
361#define SIM_CHIP_XAUI 0x002 364#define SIM_CHIP_XAUI 0x002
362 365
363//! Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. 366/** Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */
364//!
365#define SIM_CHIP_PCIE 0x004 367#define SIM_CHIP_PCIE 0x004
366 368
367//! Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. 369/** Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */
368//!
369#define SIM_CHIP_MPIPE 0x008 370#define SIM_CHIP_MPIPE 0x008
370 371
371//! Reference all chip devices. 372/** Use with with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */
372//! 373#define SIM_CHIP_TRIO 0x010
374
375/** Reference all chip devices. */
373#define SIM_CHIP_ALL (-1) 376#define SIM_CHIP_ALL (-1)
374 377
375//! @} 378/** @} */
376 379
377//! Computes the value to write to SPR_SIM_CONTROL to clear chip statistics. 380/** Computes the value to write to SPR_SIM_CONTROL to clear chip statistics. */
378//!
379#define SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask) \ 381#define SIM_PROFILER_CHIP_CLEAR_SPR_ARG(mask) \
380 (SIM_CONTROL_PROFILER_CHIP_CLEAR | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 382 (SIM_CONTROL_PROFILER_CHIP_CLEAR | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
381 383
382//! Computes the value to write to SPR_SIM_CONTROL to disable chip statistics. 384/** Computes the value to write to SPR_SIM_CONTROL to disable chip statistics.*/
383//!
384#define SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask) \ 385#define SIM_PROFILER_CHIP_DISABLE_SPR_ARG(mask) \
385 (SIM_CONTROL_PROFILER_CHIP_DISABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 386 (SIM_CONTROL_PROFILER_CHIP_DISABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
386 387
387//! Computes the value to write to SPR_SIM_CONTROL to enable chip statistics. 388/** Computes the value to write to SPR_SIM_CONTROL to enable chip statistics. */
388//!
389#define SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask) \ 389#define SIM_PROFILER_CHIP_ENABLE_SPR_ARG(mask) \
390 (SIM_CONTROL_PROFILER_CHIP_ENABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS)) 390 (SIM_CONTROL_PROFILER_CHIP_ENABLE | ((mask) << _SIM_CONTROL_OPERATOR_BITS))
391 391
392 392
393 393
394// Shim bitrate controls. 394/* Shim bitrate controls. */
395 395
396//! The number of bits used to store the shim id. 396/** The number of bits used to store the shim id. */
397//!
398#define SIM_CONTROL_SHAPING_SHIM_ID_BITS 3 397#define SIM_CONTROL_SHAPING_SHIM_ID_BITS 3
399 398
400//! @addtogroup arch_sim 399/**
401//! @{ 400 * @addtogroup arch_sim
401 * @{
402 */
402 403
403//! Change the gbe 0 bitrate. 404/** Change the gbe 0 bitrate. */
404//!
405#define SIM_CONTROL_SHAPING_GBE_0 0x0 405#define SIM_CONTROL_SHAPING_GBE_0 0x0
406 406
407//! Change the gbe 1 bitrate. 407/** Change the gbe 1 bitrate. */
408//!
409#define SIM_CONTROL_SHAPING_GBE_1 0x1 408#define SIM_CONTROL_SHAPING_GBE_1 0x1
410 409
411//! Change the gbe 2 bitrate. 410/** Change the gbe 2 bitrate. */
412//!
413#define SIM_CONTROL_SHAPING_GBE_2 0x2 411#define SIM_CONTROL_SHAPING_GBE_2 0x2
414 412
415//! Change the gbe 3 bitrate. 413/** Change the gbe 3 bitrate. */
416//!
417#define SIM_CONTROL_SHAPING_GBE_3 0x3 414#define SIM_CONTROL_SHAPING_GBE_3 0x3
418 415
419//! Change the xgbe 0 bitrate. 416/** Change the xgbe 0 bitrate. */
420//!
421#define SIM_CONTROL_SHAPING_XGBE_0 0x4 417#define SIM_CONTROL_SHAPING_XGBE_0 0x4
422 418
423//! Change the xgbe 1 bitrate. 419/** Change the xgbe 1 bitrate. */
424//!
425#define SIM_CONTROL_SHAPING_XGBE_1 0x5 420#define SIM_CONTROL_SHAPING_XGBE_1 0x5
426 421
427//! The type of shaping to do. 422/** The type of shaping to do. */
428//!
429#define SIM_CONTROL_SHAPING_TYPE_BITS 2 423#define SIM_CONTROL_SHAPING_TYPE_BITS 2
430 424
431//! Control the multiplier. 425/** Control the multiplier. */
432//!
433#define SIM_CONTROL_SHAPING_MULTIPLIER 0 426#define SIM_CONTROL_SHAPING_MULTIPLIER 0
434 427
435//! Control the PPS. 428/** Control the PPS. */
436//!
437#define SIM_CONTROL_SHAPING_PPS 1 429#define SIM_CONTROL_SHAPING_PPS 1
438 430
439//! Control the BPS. 431/** Control the BPS. */
440//!
441#define SIM_CONTROL_SHAPING_BPS 2 432#define SIM_CONTROL_SHAPING_BPS 2
442 433
443//! The number of bits for the units for the shaping parameter. 434/** The number of bits for the units for the shaping parameter. */
444//!
445#define SIM_CONTROL_SHAPING_UNITS_BITS 2 435#define SIM_CONTROL_SHAPING_UNITS_BITS 2
446 436
447//! Provide a number in single units. 437/** Provide a number in single units. */
448//!
449#define SIM_CONTROL_SHAPING_UNITS_SINGLE 0 438#define SIM_CONTROL_SHAPING_UNITS_SINGLE 0
450 439
451//! Provide a number in kilo units. 440/** Provide a number in kilo units. */
452//!
453#define SIM_CONTROL_SHAPING_UNITS_KILO 1 441#define SIM_CONTROL_SHAPING_UNITS_KILO 1
454 442
455//! Provide a number in mega units. 443/** Provide a number in mega units. */
456//!
457#define SIM_CONTROL_SHAPING_UNITS_MEGA 2 444#define SIM_CONTROL_SHAPING_UNITS_MEGA 2
458 445
459//! Provide a number in giga units. 446/** Provide a number in giga units. */
460//!
461#define SIM_CONTROL_SHAPING_UNITS_GIGA 3 447#define SIM_CONTROL_SHAPING_UNITS_GIGA 3
462 448
463// @} 449/** @} */
464 450
465//! How many bits are available for the rate. 451/** How many bits are available for the rate. */
466//!
467#define SIM_CONTROL_SHAPING_RATE_BITS \ 452#define SIM_CONTROL_SHAPING_RATE_BITS \
468 (32 - (_SIM_CONTROL_OPERATOR_BITS + \ 453 (32 - (_SIM_CONTROL_OPERATOR_BITS + \
469 SIM_CONTROL_SHAPING_SHIM_ID_BITS + \ 454 SIM_CONTROL_SHAPING_SHIM_ID_BITS + \
470 SIM_CONTROL_SHAPING_TYPE_BITS + \ 455 SIM_CONTROL_SHAPING_TYPE_BITS + \
471 SIM_CONTROL_SHAPING_UNITS_BITS)) 456 SIM_CONTROL_SHAPING_UNITS_BITS))
472 457
473//! Computes the value to write to SPR_SIM_CONTROL to change a bitrate. 458/** Computes the value to write to SPR_SIM_CONTROL to change a bitrate. */
474//!
475#define SIM_SHAPING_SPR_ARG(shim, type, units, rate) \ 459#define SIM_SHAPING_SPR_ARG(shim, type, units, rate) \
476 (SIM_CONTROL_SHAPING | \ 460 (SIM_CONTROL_SHAPING | \
477 ((shim) | \ 461 ((shim) | \
@@ -483,30 +467,36 @@
483 SIM_CONTROL_SHAPING_UNITS_BITS))) << _SIM_CONTROL_OPERATOR_BITS) 467 SIM_CONTROL_SHAPING_UNITS_BITS))) << _SIM_CONTROL_OPERATOR_BITS)
484 468
485 469
486//== Values returned when reading SPR_SIM_CONTROL. 470/*
487// ISSUE: These names should share a longer common prefix. 471 * Values returned when reading SPR_SIM_CONTROL.
472 * ISSUE: These names should share a longer common prefix.
473 */
488 474
489//! When reading SPR_SIM_CONTROL, the mask of simulator tracing bits 475/**
490//! (SIM_TRACE_xxx values). 476 * When reading SPR_SIM_CONTROL, the mask of simulator tracing bits
491//! 477 * (SIM_TRACE_xxx values).
478 */
492#define SIM_TRACE_FLAG_MASK 0xFFFF 479#define SIM_TRACE_FLAG_MASK 0xFFFF
493 480
494//! When reading SPR_SIM_CONTROL, the mask for whether profiling is enabled. 481/** When reading SPR_SIM_CONTROL, the mask for whether profiling is enabled. */
495//!
496#define SIM_PROFILER_ENABLED_MASK 0x10000 482#define SIM_PROFILER_ENABLED_MASK 0x10000
497 483
498 484
499//== Special arguments for "SIM_CONTROL_PUTC". 485/*
486 * Special arguments for "SIM_CONTROL_PUTC".
487 */
500 488
501//! Flag value for forcing a PUTC string-flush, including 489/**
502//! coordinate/cycle prefix and newline. 490 * Flag value for forcing a PUTC string-flush, including
503//! 491 * coordinate/cycle prefix and newline.
492 */
504#define SIM_PUTC_FLUSH_STRING 0x100 493#define SIM_PUTC_FLUSH_STRING 0x100
505 494
506//! Flag value for forcing a PUTC binary-data-flush, which skips the 495/**
507//! prefix and does not append a newline. 496 * Flag value for forcing a PUTC binary-data-flush, which skips the
508//! 497 * prefix and does not append a newline.
498 */
509#define SIM_PUTC_FLUSH_BINARY 0x101 499#define SIM_PUTC_FLUSH_BINARY 0x101
510 500
511 501
512#endif //__ARCH_SIM_DEF_H__ 502#endif /* __ARCH_SIM_DEF_H__ */
diff --git a/arch/tile/include/arch/spr_def.h b/arch/tile/include/arch/spr_def.h
index c8fdbd9a45e6..442fcba0d122 100644
--- a/arch/tile/include/arch/spr_def.h
+++ b/arch/tile/include/arch/spr_def.h
@@ -12,8 +12,93 @@
12 * more details. 12 * more details.
13 */ 13 */
14 14
15/*
16 * In addition to including the proper base SPR definition file, depending
17 * on machine architecture, this file defines several macros which allow
18 * kernel code to use protection-level dependent SPRs without worrying
19 * about which PL it's running at. In these macros, the PL that the SPR
20 * or interrupt number applies to is replaced by K.
21 */
22
23#if CONFIG_KERNEL_PL != 1 && CONFIG_KERNEL_PL != 2
24#error CONFIG_KERNEL_PL must be 1 or 2
25#endif
26
27/* Concatenate 4 strings. */
28#define __concat4(a, b, c, d) a ## b ## c ## d
29#define _concat4(a, b, c, d) __concat4(a, b, c, d)
30
15#ifdef __tilegx__ 31#ifdef __tilegx__
16#include <arch/spr_def_64.h> 32#include <arch/spr_def_64.h>
33
34/* TILE-Gx dependent, protection-level dependent SPRs. */
35
36#define SPR_INTERRUPT_MASK_K \
37 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL,,)
38#define SPR_INTERRUPT_MASK_SET_K \
39 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL,,)
40#define SPR_INTERRUPT_MASK_RESET_K \
41 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL,,)
42#define SPR_INTERRUPT_VECTOR_BASE_K \
43 _concat4(SPR_INTERRUPT_VECTOR_BASE_, CONFIG_KERNEL_PL,,)
44
45#define SPR_IPI_MASK_K \
46 _concat4(SPR_IPI_MASK_, CONFIG_KERNEL_PL,,)
47#define SPR_IPI_MASK_RESET_K \
48 _concat4(SPR_IPI_MASK_RESET_, CONFIG_KERNEL_PL,,)
49#define SPR_IPI_MASK_SET_K \
50 _concat4(SPR_IPI_MASK_SET_, CONFIG_KERNEL_PL,,)
51#define SPR_IPI_EVENT_K \
52 _concat4(SPR_IPI_EVENT_, CONFIG_KERNEL_PL,,)
53#define SPR_IPI_EVENT_RESET_K \
54 _concat4(SPR_IPI_EVENT_RESET_, CONFIG_KERNEL_PL,,)
55#define SPR_IPI_MASK_SET_K \
56 _concat4(SPR_IPI_MASK_SET_, CONFIG_KERNEL_PL,,)
57#define INT_IPI_K \
58 _concat4(INT_IPI_, CONFIG_KERNEL_PL,,)
59
60#define SPR_SINGLE_STEP_CONTROL_K \
61 _concat4(SPR_SINGLE_STEP_CONTROL_, CONFIG_KERNEL_PL,,)
62#define SPR_SINGLE_STEP_EN_K_K \
63 _concat4(SPR_SINGLE_STEP_EN_, CONFIG_KERNEL_PL, _, CONFIG_KERNEL_PL)
64#define INT_SINGLE_STEP_K \
65 _concat4(INT_SINGLE_STEP_, CONFIG_KERNEL_PL,,)
66
17#else 67#else
18#include <arch/spr_def_32.h> 68#include <arch/spr_def_32.h>
69
70/* TILEPro dependent, protection-level dependent SPRs. */
71
72#define SPR_INTERRUPT_MASK_K_0 \
73 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL, _0,)
74#define SPR_INTERRUPT_MASK_K_1 \
75 _concat4(SPR_INTERRUPT_MASK_, CONFIG_KERNEL_PL, _1,)
76#define SPR_INTERRUPT_MASK_SET_K_0 \
77 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL, _0,)
78#define SPR_INTERRUPT_MASK_SET_K_1 \
79 _concat4(SPR_INTERRUPT_MASK_SET_, CONFIG_KERNEL_PL, _1,)
80#define SPR_INTERRUPT_MASK_RESET_K_0 \
81 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL, _0,)
82#define SPR_INTERRUPT_MASK_RESET_K_1 \
83 _concat4(SPR_INTERRUPT_MASK_RESET_, CONFIG_KERNEL_PL, _1,)
84
19#endif 85#endif
86
87/* Generic protection-level dependent SPRs. */
88
89#define SPR_SYSTEM_SAVE_K_0 \
90 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _0,)
91#define SPR_SYSTEM_SAVE_K_1 \
92 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _1,)
93#define SPR_SYSTEM_SAVE_K_2 \
94 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _2,)
95#define SPR_SYSTEM_SAVE_K_3 \
96 _concat4(SPR_SYSTEM_SAVE_, CONFIG_KERNEL_PL, _3,)
97#define SPR_EX_CONTEXT_K_0 \
98 _concat4(SPR_EX_CONTEXT_, CONFIG_KERNEL_PL, _0,)
99#define SPR_EX_CONTEXT_K_1 \
100 _concat4(SPR_EX_CONTEXT_, CONFIG_KERNEL_PL, _1,)
101#define SPR_INTCTRL_K_STATUS \
102 _concat4(SPR_INTCTRL_, CONFIG_KERNEL_PL, _STATUS,)
103#define INT_INTCTRL_K \
104 _concat4(INT_INTCTRL_, CONFIG_KERNEL_PL,,)
diff --git a/arch/tile/include/arch/spr_def_32.h b/arch/tile/include/arch/spr_def_32.h
index b4fc06864df6..bbc1f4c924ee 100644
--- a/arch/tile/include/arch/spr_def_32.h
+++ b/arch/tile/include/arch/spr_def_32.h
@@ -56,58 +56,93 @@
56#define SPR_EX_CONTEXT_1_1__ICS_SHIFT 2 56#define SPR_EX_CONTEXT_1_1__ICS_SHIFT 2
57#define SPR_EX_CONTEXT_1_1__ICS_RMASK 0x1 57#define SPR_EX_CONTEXT_1_1__ICS_RMASK 0x1
58#define SPR_EX_CONTEXT_1_1__ICS_MASK 0x4 58#define SPR_EX_CONTEXT_1_1__ICS_MASK 0x4
59#define SPR_EX_CONTEXT_2_0 0x4605
60#define SPR_EX_CONTEXT_2_1 0x4606
61#define SPR_EX_CONTEXT_2_1__PL_SHIFT 0
62#define SPR_EX_CONTEXT_2_1__PL_RMASK 0x3
63#define SPR_EX_CONTEXT_2_1__PL_MASK 0x3
64#define SPR_EX_CONTEXT_2_1__ICS_SHIFT 2
65#define SPR_EX_CONTEXT_2_1__ICS_RMASK 0x1
66#define SPR_EX_CONTEXT_2_1__ICS_MASK 0x4
59#define SPR_FAIL 0x4e09 67#define SPR_FAIL 0x4e09
60#define SPR_INTCTRL_0_STATUS 0x4a07 68#define SPR_INTCTRL_0_STATUS 0x4a07
61#define SPR_INTCTRL_1_STATUS 0x4807 69#define SPR_INTCTRL_1_STATUS 0x4807
70#define SPR_INTCTRL_2_STATUS 0x4607
62#define SPR_INTERRUPT_CRITICAL_SECTION 0x4e0a 71#define SPR_INTERRUPT_CRITICAL_SECTION 0x4e0a
63#define SPR_INTERRUPT_MASK_0_0 0x4a08 72#define SPR_INTERRUPT_MASK_0_0 0x4a08
64#define SPR_INTERRUPT_MASK_0_1 0x4a09 73#define SPR_INTERRUPT_MASK_0_1 0x4a09
65#define SPR_INTERRUPT_MASK_1_0 0x4809 74#define SPR_INTERRUPT_MASK_1_0 0x4809
66#define SPR_INTERRUPT_MASK_1_1 0x480a 75#define SPR_INTERRUPT_MASK_1_1 0x480a
76#define SPR_INTERRUPT_MASK_2_0 0x4608
77#define SPR_INTERRUPT_MASK_2_1 0x4609
67#define SPR_INTERRUPT_MASK_RESET_0_0 0x4a0a 78#define SPR_INTERRUPT_MASK_RESET_0_0 0x4a0a
68#define SPR_INTERRUPT_MASK_RESET_0_1 0x4a0b 79#define SPR_INTERRUPT_MASK_RESET_0_1 0x4a0b
69#define SPR_INTERRUPT_MASK_RESET_1_0 0x480b 80#define SPR_INTERRUPT_MASK_RESET_1_0 0x480b
70#define SPR_INTERRUPT_MASK_RESET_1_1 0x480c 81#define SPR_INTERRUPT_MASK_RESET_1_1 0x480c
82#define SPR_INTERRUPT_MASK_RESET_2_0 0x460a
83#define SPR_INTERRUPT_MASK_RESET_2_1 0x460b
71#define SPR_INTERRUPT_MASK_SET_0_0 0x4a0c 84#define SPR_INTERRUPT_MASK_SET_0_0 0x4a0c
72#define SPR_INTERRUPT_MASK_SET_0_1 0x4a0d 85#define SPR_INTERRUPT_MASK_SET_0_1 0x4a0d
73#define SPR_INTERRUPT_MASK_SET_1_0 0x480d 86#define SPR_INTERRUPT_MASK_SET_1_0 0x480d
74#define SPR_INTERRUPT_MASK_SET_1_1 0x480e 87#define SPR_INTERRUPT_MASK_SET_1_1 0x480e
88#define SPR_INTERRUPT_MASK_SET_2_0 0x460c
89#define SPR_INTERRUPT_MASK_SET_2_1 0x460d
75#define SPR_MPL_DMA_CPL_SET_0 0x5800 90#define SPR_MPL_DMA_CPL_SET_0 0x5800
76#define SPR_MPL_DMA_CPL_SET_1 0x5801 91#define SPR_MPL_DMA_CPL_SET_1 0x5801
92#define SPR_MPL_DMA_CPL_SET_2 0x5802
77#define SPR_MPL_DMA_NOTIFY_SET_0 0x3800 93#define SPR_MPL_DMA_NOTIFY_SET_0 0x3800
78#define SPR_MPL_DMA_NOTIFY_SET_1 0x3801 94#define SPR_MPL_DMA_NOTIFY_SET_1 0x3801
95#define SPR_MPL_DMA_NOTIFY_SET_2 0x3802
79#define SPR_MPL_INTCTRL_0_SET_0 0x4a00 96#define SPR_MPL_INTCTRL_0_SET_0 0x4a00
80#define SPR_MPL_INTCTRL_0_SET_1 0x4a01 97#define SPR_MPL_INTCTRL_0_SET_1 0x4a01
98#define SPR_MPL_INTCTRL_0_SET_2 0x4a02
81#define SPR_MPL_INTCTRL_1_SET_0 0x4800 99#define SPR_MPL_INTCTRL_1_SET_0 0x4800
82#define SPR_MPL_INTCTRL_1_SET_1 0x4801 100#define SPR_MPL_INTCTRL_1_SET_1 0x4801
101#define SPR_MPL_INTCTRL_1_SET_2 0x4802
102#define SPR_MPL_INTCTRL_2_SET_0 0x4600
103#define SPR_MPL_INTCTRL_2_SET_1 0x4601
104#define SPR_MPL_INTCTRL_2_SET_2 0x4602
83#define SPR_MPL_SN_ACCESS_SET_0 0x0800 105#define SPR_MPL_SN_ACCESS_SET_0 0x0800
84#define SPR_MPL_SN_ACCESS_SET_1 0x0801 106#define SPR_MPL_SN_ACCESS_SET_1 0x0801
107#define SPR_MPL_SN_ACCESS_SET_2 0x0802
85#define SPR_MPL_SN_CPL_SET_0 0x5a00 108#define SPR_MPL_SN_CPL_SET_0 0x5a00
86#define SPR_MPL_SN_CPL_SET_1 0x5a01 109#define SPR_MPL_SN_CPL_SET_1 0x5a01
110#define SPR_MPL_SN_CPL_SET_2 0x5a02
87#define SPR_MPL_SN_FIREWALL_SET_0 0x2c00 111#define SPR_MPL_SN_FIREWALL_SET_0 0x2c00
88#define SPR_MPL_SN_FIREWALL_SET_1 0x2c01 112#define SPR_MPL_SN_FIREWALL_SET_1 0x2c01
113#define SPR_MPL_SN_FIREWALL_SET_2 0x2c02
89#define SPR_MPL_SN_NOTIFY_SET_0 0x2a00 114#define SPR_MPL_SN_NOTIFY_SET_0 0x2a00
90#define SPR_MPL_SN_NOTIFY_SET_1 0x2a01 115#define SPR_MPL_SN_NOTIFY_SET_1 0x2a01
116#define SPR_MPL_SN_NOTIFY_SET_2 0x2a02
91#define SPR_MPL_UDN_ACCESS_SET_0 0x0c00 117#define SPR_MPL_UDN_ACCESS_SET_0 0x0c00
92#define SPR_MPL_UDN_ACCESS_SET_1 0x0c01 118#define SPR_MPL_UDN_ACCESS_SET_1 0x0c01
119#define SPR_MPL_UDN_ACCESS_SET_2 0x0c02
93#define SPR_MPL_UDN_AVAIL_SET_0 0x4000 120#define SPR_MPL_UDN_AVAIL_SET_0 0x4000
94#define SPR_MPL_UDN_AVAIL_SET_1 0x4001 121#define SPR_MPL_UDN_AVAIL_SET_1 0x4001
122#define SPR_MPL_UDN_AVAIL_SET_2 0x4002
95#define SPR_MPL_UDN_CA_SET_0 0x3c00 123#define SPR_MPL_UDN_CA_SET_0 0x3c00
96#define SPR_MPL_UDN_CA_SET_1 0x3c01 124#define SPR_MPL_UDN_CA_SET_1 0x3c01
125#define SPR_MPL_UDN_CA_SET_2 0x3c02
97#define SPR_MPL_UDN_COMPLETE_SET_0 0x1400 126#define SPR_MPL_UDN_COMPLETE_SET_0 0x1400
98#define SPR_MPL_UDN_COMPLETE_SET_1 0x1401 127#define SPR_MPL_UDN_COMPLETE_SET_1 0x1401
128#define SPR_MPL_UDN_COMPLETE_SET_2 0x1402
99#define SPR_MPL_UDN_FIREWALL_SET_0 0x3000 129#define SPR_MPL_UDN_FIREWALL_SET_0 0x3000
100#define SPR_MPL_UDN_FIREWALL_SET_1 0x3001 130#define SPR_MPL_UDN_FIREWALL_SET_1 0x3001
131#define SPR_MPL_UDN_FIREWALL_SET_2 0x3002
101#define SPR_MPL_UDN_REFILL_SET_0 0x1000 132#define SPR_MPL_UDN_REFILL_SET_0 0x1000
102#define SPR_MPL_UDN_REFILL_SET_1 0x1001 133#define SPR_MPL_UDN_REFILL_SET_1 0x1001
134#define SPR_MPL_UDN_REFILL_SET_2 0x1002
103#define SPR_MPL_UDN_TIMER_SET_0 0x3600 135#define SPR_MPL_UDN_TIMER_SET_0 0x3600
104#define SPR_MPL_UDN_TIMER_SET_1 0x3601 136#define SPR_MPL_UDN_TIMER_SET_1 0x3601
137#define SPR_MPL_UDN_TIMER_SET_2 0x3602
105#define SPR_MPL_WORLD_ACCESS_SET_0 0x4e00 138#define SPR_MPL_WORLD_ACCESS_SET_0 0x4e00
106#define SPR_MPL_WORLD_ACCESS_SET_1 0x4e01 139#define SPR_MPL_WORLD_ACCESS_SET_1 0x4e01
140#define SPR_MPL_WORLD_ACCESS_SET_2 0x4e02
107#define SPR_PASS 0x4e0b 141#define SPR_PASS 0x4e0b
108#define SPR_PERF_COUNT_0 0x4205 142#define SPR_PERF_COUNT_0 0x4205
109#define SPR_PERF_COUNT_1 0x4206 143#define SPR_PERF_COUNT_1 0x4206
110#define SPR_PERF_COUNT_CTL 0x4207 144#define SPR_PERF_COUNT_CTL 0x4207
145#define SPR_PERF_COUNT_DN_CTL 0x4210
111#define SPR_PERF_COUNT_STS 0x4208 146#define SPR_PERF_COUNT_STS 0x4208
112#define SPR_PROC_STATUS 0x4f00 147#define SPR_PROC_STATUS 0x4f00
113#define SPR_SIM_CONTROL 0x4e0c 148#define SPR_SIM_CONTROL 0x4e0c
@@ -124,6 +159,10 @@
124#define SPR_SYSTEM_SAVE_1_1 0x4901 159#define SPR_SYSTEM_SAVE_1_1 0x4901
125#define SPR_SYSTEM_SAVE_1_2 0x4902 160#define SPR_SYSTEM_SAVE_1_2 0x4902
126#define SPR_SYSTEM_SAVE_1_3 0x4903 161#define SPR_SYSTEM_SAVE_1_3 0x4903
162#define SPR_SYSTEM_SAVE_2_0 0x4700
163#define SPR_SYSTEM_SAVE_2_1 0x4701
164#define SPR_SYSTEM_SAVE_2_2 0x4702
165#define SPR_SYSTEM_SAVE_2_3 0x4703
127#define SPR_TILE_COORD 0x4c17 166#define SPR_TILE_COORD 0x4c17
128#define SPR_TILE_RTF_HWM 0x4e10 167#define SPR_TILE_RTF_HWM 0x4e10
129#define SPR_TILE_TIMER_CONTROL 0x3205 168#define SPR_TILE_TIMER_CONTROL 0x3205
diff --git a/arch/tile/include/asm/backtrace.h b/arch/tile/include/asm/backtrace.h
index 758ca4619d50..f18887d82399 100644
--- a/arch/tile/include/asm/backtrace.h
+++ b/arch/tile/include/asm/backtrace.h
@@ -146,7 +146,10 @@ enum {
146 146
147 CALLER_SP_IN_R52_BASE = 4, 147 CALLER_SP_IN_R52_BASE = 4,
148 148
149 CALLER_SP_OFFSET_BASE = 8 149 CALLER_SP_OFFSET_BASE = 8,
150
151 /* Marks the entry point of certain functions. */
152 ENTRY_POINT_INFO_OP = 16
150}; 153};
151 154
152 155
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/compat.h b/arch/tile/include/asm/compat.h
index 8b60ec8b2d19..c3ae570c0a5d 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -216,15 +216,16 @@ struct compat_siginfo;
216struct compat_sigaltstack; 216struct compat_sigaltstack;
217long compat_sys_execve(const char __user *path, 217long compat_sys_execve(const char __user *path,
218 const compat_uptr_t __user *argv, 218 const compat_uptr_t __user *argv,
219 const compat_uptr_t __user *envp); 219 const compat_uptr_t __user *envp, struct pt_regs *);
220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, 220long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
221 struct compat_sigaction __user *oact, 221 struct compat_sigaction __user *oact,
222 size_t sigsetsize); 222 size_t sigsetsize);
223long compat_sys_rt_sigqueueinfo(int pid, int sig, 223long compat_sys_rt_sigqueueinfo(int pid, int sig,
224 struct compat_siginfo __user *uinfo); 224 struct compat_siginfo __user *uinfo);
225long compat_sys_rt_sigreturn(void); 225long compat_sys_rt_sigreturn(struct pt_regs *);
226long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 226long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
227 struct compat_sigaltstack __user *uoss_ptr); 227 struct compat_sigaltstack __user *uoss_ptr,
228 struct pt_regs *);
228long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); 229long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
229long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); 230long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
230long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, 231long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
@@ -255,4 +256,12 @@ long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
255/* Tilera Linux syscalls that don't have "compat" versions. */ 256/* Tilera Linux syscalls that don't have "compat" versions. */
256#define compat_sys_flush_cache sys_flush_cache 257#define compat_sys_flush_cache sys_flush_cache
257 258
259/* These are the intvec_64.S trampolines. */
260long _compat_sys_execve(const char __user *path,
261 const compat_uptr_t __user *argv,
262 const compat_uptr_t __user *envp);
263long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
264 struct compat_sigaltstack __user *uoss_ptr);
265long _compat_sys_rt_sigreturn(void);
266
258#endif /* _ASM_TILE_COMPAT_H */ 267#endif /* _ASM_TILE_COMPAT_H */
diff --git a/arch/tile/include/asm/highmem.h b/arch/tile/include/asm/highmem.h
index d155db6fa9bd..b2a6c5de79ab 100644
--- a/arch/tile/include/asm/highmem.h
+++ b/arch/tile/include/asm/highmem.h
@@ -23,7 +23,6 @@
23 23
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/threads.h> 25#include <linux/threads.h>
26#include <asm/kmap_types.h>
27#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
28#include <asm/homecache.h> 27#include <asm/homecache.h>
29 28
@@ -60,12 +59,12 @@ void *kmap_fix_kpte(struct page *page, int finished);
60/* This macro is used only in map_new_virtual() to map "page". */ 59/* This macro is used only in map_new_virtual() to map "page". */
61#define kmap_prot page_to_kpgprot(page) 60#define kmap_prot page_to_kpgprot(page)
62 61
63void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type); 62void *__kmap_atomic(struct page *page);
64void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); 63void __kunmap_atomic(void *kvaddr);
65void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); 64void *kmap_atomic_pfn(unsigned long pfn);
65void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot);
66struct page *kmap_atomic_to_page(void *ptr); 66struct page *kmap_atomic_to_page(void *ptr);
67void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot); 67void *kmap_atomic_prot(struct page *page, pgprot_t prot);
68void *kmap_atomic(struct page *page, enum km_type type);
69void kmap_atomic_fix_kpte(struct page *page, int finished); 68void kmap_atomic_fix_kpte(struct page *page, int finished);
70 69
71#define flush_cache_kmaps() do { } while (0) 70#define flush_cache_kmaps() do { } while (0)
diff --git a/arch/tile/include/asm/irqflags.h b/arch/tile/include/asm/irqflags.h
index a11d4837ee4d..641e4ff3d805 100644
--- a/arch/tile/include/asm/irqflags.h
+++ b/arch/tile/include/asm/irqflags.h
@@ -47,53 +47,53 @@
47 int __n = (n); \ 47 int __n = (n); \
48 int __mask = 1 << (__n & 0x1f); \ 48 int __mask = 1 << (__n & 0x1f); \
49 if (__n < 32) \ 49 if (__n < 32) \
50 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_0, __mask); \ 50 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_0, __mask); \
51 else \ 51 else \
52 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_1, __mask); \ 52 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_1, __mask); \
53} while (0) 53} while (0)
54#define interrupt_mask_reset(n) do { \ 54#define interrupt_mask_reset(n) do { \
55 int __n = (n); \ 55 int __n = (n); \
56 int __mask = 1 << (__n & 0x1f); \ 56 int __mask = 1 << (__n & 0x1f); \
57 if (__n < 32) \ 57 if (__n < 32) \
58 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_0, __mask); \ 58 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_0, __mask); \
59 else \ 59 else \
60 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_1, __mask); \ 60 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_1, __mask); \
61} while (0) 61} while (0)
62#define interrupt_mask_check(n) ({ \ 62#define interrupt_mask_check(n) ({ \
63 int __n = (n); \ 63 int __n = (n); \
64 (((__n < 32) ? \ 64 (((__n < 32) ? \
65 __insn_mfspr(SPR_INTERRUPT_MASK_1_0) : \ 65 __insn_mfspr(SPR_INTERRUPT_MASK_K_0) : \
66 __insn_mfspr(SPR_INTERRUPT_MASK_1_1)) \ 66 __insn_mfspr(SPR_INTERRUPT_MASK_K_1)) \
67 >> (__n & 0x1f)) & 1; \ 67 >> (__n & 0x1f)) & 1; \
68}) 68})
69#define interrupt_mask_set_mask(mask) do { \ 69#define interrupt_mask_set_mask(mask) do { \
70 unsigned long long __m = (mask); \ 70 unsigned long long __m = (mask); \
71 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_0, (unsigned long)(__m)); \ 71 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_0, (unsigned long)(__m)); \
72 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1_1, (unsigned long)(__m>>32)); \ 72 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K_1, (unsigned long)(__m>>32)); \
73} while (0) 73} while (0)
74#define interrupt_mask_reset_mask(mask) do { \ 74#define interrupt_mask_reset_mask(mask) do { \
75 unsigned long long __m = (mask); \ 75 unsigned long long __m = (mask); \
76 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_0, (unsigned long)(__m)); \ 76 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_0, (unsigned long)(__m)); \
77 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1_1, (unsigned long)(__m>>32)); \ 77 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K_1, (unsigned long)(__m>>32)); \
78} while (0) 78} while (0)
79#else 79#else
80#define interrupt_mask_set(n) \ 80#define interrupt_mask_set(n) \
81 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1, (1UL << (n))) 81 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K, (1UL << (n)))
82#define interrupt_mask_reset(n) \ 82#define interrupt_mask_reset(n) \
83 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1, (1UL << (n))) 83 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K, (1UL << (n)))
84#define interrupt_mask_check(n) \ 84#define interrupt_mask_check(n) \
85 ((__insn_mfspr(SPR_INTERRUPT_MASK_1) >> (n)) & 1) 85 ((__insn_mfspr(SPR_INTERRUPT_MASK_K) >> (n)) & 1)
86#define interrupt_mask_set_mask(mask) \ 86#define interrupt_mask_set_mask(mask) \
87 __insn_mtspr(SPR_INTERRUPT_MASK_SET_1, (mask)) 87 __insn_mtspr(SPR_INTERRUPT_MASK_SET_K, (mask))
88#define interrupt_mask_reset_mask(mask) \ 88#define interrupt_mask_reset_mask(mask) \
89 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_1, (mask)) 89 __insn_mtspr(SPR_INTERRUPT_MASK_RESET_K, (mask))
90#endif 90#endif
91 91
92/* 92/*
93 * The set of interrupts we want active if irqs are enabled. 93 * The set of interrupts we want active if irqs are enabled.
94 * Note that in particular, the tile timer interrupt comes and goes 94 * Note that in particular, the tile timer interrupt comes and goes
95 * from this set, since we have no other way to turn off the timer. 95 * from this set, since we have no other way to turn off the timer.
96 * Likewise, INTCTRL_1 is removed and re-added during device 96 * Likewise, INTCTRL_K is removed and re-added during device
97 * interrupts, as is the the hardwall UDN_FIREWALL interrupt. 97 * interrupts, as is the the hardwall UDN_FIREWALL interrupt.
98 * We use a low bit (MEM_ERROR) as our sentinel value and make sure it 98 * We use a low bit (MEM_ERROR) as our sentinel value and make sure it
99 * is always claimed as an "active interrupt" so we can query that bit 99 * is always claimed as an "active interrupt" so we can query that bit
@@ -170,14 +170,14 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
170 170
171/* Return 0 or 1 to indicate whether interrupts are currently disabled. */ 171/* Return 0 or 1 to indicate whether interrupts are currently disabled. */
172#define IRQS_DISABLED(tmp) \ 172#define IRQS_DISABLED(tmp) \
173 mfspr tmp, INTERRUPT_MASK_1; \ 173 mfspr tmp, SPR_INTERRUPT_MASK_K; \
174 andi tmp, tmp, 1 174 andi tmp, tmp, 1
175 175
176/* Load up a pointer to &interrupts_enabled_mask. */ 176/* Load up a pointer to &interrupts_enabled_mask. */
177#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \ 177#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \
178 moveli reg, hw2_last(interrupts_enabled_mask); \ 178 moveli reg, hw2_last(interrupts_enabled_mask); \
179 shl16insli reg, reg, hw1(interrupts_enabled_mask); \ 179 shl16insli reg, reg, hw1(interrupts_enabled_mask); \
180 shl16insli reg, reg, hw0(interrupts_enabled_mask); \ 180 shl16insli reg, reg, hw0(interrupts_enabled_mask); \
181 add reg, reg, tp 181 add reg, reg, tp
182 182
183/* Disable interrupts. */ 183/* Disable interrupts. */
@@ -185,18 +185,18 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
185 moveli tmp0, hw2_last(LINUX_MASKABLE_INTERRUPTS); \ 185 moveli tmp0, hw2_last(LINUX_MASKABLE_INTERRUPTS); \
186 shl16insli tmp0, tmp0, hw1(LINUX_MASKABLE_INTERRUPTS); \ 186 shl16insli tmp0, tmp0, hw1(LINUX_MASKABLE_INTERRUPTS); \
187 shl16insli tmp0, tmp0, hw0(LINUX_MASKABLE_INTERRUPTS); \ 187 shl16insli tmp0, tmp0, hw0(LINUX_MASKABLE_INTERRUPTS); \
188 mtspr INTERRUPT_MASK_SET_1, tmp0 188 mtspr SPR_INTERRUPT_MASK_SET_K, tmp0
189 189
190/* Disable ALL synchronous interrupts (used by NMI entry). */ 190/* Disable ALL synchronous interrupts (used by NMI entry). */
191#define IRQ_DISABLE_ALL(tmp) \ 191#define IRQ_DISABLE_ALL(tmp) \
192 movei tmp, -1; \ 192 movei tmp, -1; \
193 mtspr INTERRUPT_MASK_SET_1, tmp 193 mtspr SPR_INTERRUPT_MASK_SET_K, tmp
194 194
195/* Enable interrupts. */ 195/* Enable interrupts. */
196#define IRQ_ENABLE(tmp0, tmp1) \ 196#define IRQ_ENABLE(tmp0, tmp1) \
197 GET_INTERRUPTS_ENABLED_MASK_PTR(tmp0); \ 197 GET_INTERRUPTS_ENABLED_MASK_PTR(tmp0); \
198 ld tmp0, tmp0; \ 198 ld tmp0, tmp0; \
199 mtspr INTERRUPT_MASK_RESET_1, tmp0 199 mtspr SPR_INTERRUPT_MASK_RESET_K, tmp0
200 200
201#else /* !__tilegx__ */ 201#else /* !__tilegx__ */
202 202
@@ -210,14 +210,14 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
210 * (making the original code's write of the "high" mask word idempotent). 210 * (making the original code's write of the "high" mask word idempotent).
211 */ 211 */
212#define IRQS_DISABLED(tmp) \ 212#define IRQS_DISABLED(tmp) \
213 mfspr tmp, INTERRUPT_MASK_1_0; \ 213 mfspr tmp, SPR_INTERRUPT_MASK_K_0; \
214 shri tmp, tmp, INT_MEM_ERROR; \ 214 shri tmp, tmp, INT_MEM_ERROR; \
215 andi tmp, tmp, 1 215 andi tmp, tmp, 1
216 216
217/* Load up a pointer to &interrupts_enabled_mask. */ 217/* Load up a pointer to &interrupts_enabled_mask. */
218#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \ 218#define GET_INTERRUPTS_ENABLED_MASK_PTR(reg) \
219 moveli reg, lo16(interrupts_enabled_mask); \ 219 moveli reg, lo16(interrupts_enabled_mask); \
220 auli reg, reg, ha16(interrupts_enabled_mask);\ 220 auli reg, reg, ha16(interrupts_enabled_mask); \
221 add reg, reg, tp 221 add reg, reg, tp
222 222
223/* Disable interrupts. */ 223/* Disable interrupts. */
@@ -227,16 +227,16 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
227 moveli tmp1, lo16(LINUX_MASKABLE_INTERRUPTS) \ 227 moveli tmp1, lo16(LINUX_MASKABLE_INTERRUPTS) \
228 }; \ 228 }; \
229 { \ 229 { \
230 mtspr INTERRUPT_MASK_SET_1_0, tmp0; \ 230 mtspr SPR_INTERRUPT_MASK_SET_K_0, tmp0; \
231 auli tmp1, tmp1, ha16(LINUX_MASKABLE_INTERRUPTS) \ 231 auli tmp1, tmp1, ha16(LINUX_MASKABLE_INTERRUPTS) \
232 }; \ 232 }; \
233 mtspr INTERRUPT_MASK_SET_1_1, tmp1 233 mtspr SPR_INTERRUPT_MASK_SET_K_1, tmp1
234 234
235/* Disable ALL synchronous interrupts (used by NMI entry). */ 235/* Disable ALL synchronous interrupts (used by NMI entry). */
236#define IRQ_DISABLE_ALL(tmp) \ 236#define IRQ_DISABLE_ALL(tmp) \
237 movei tmp, -1; \ 237 movei tmp, -1; \
238 mtspr INTERRUPT_MASK_SET_1_0, tmp; \ 238 mtspr SPR_INTERRUPT_MASK_SET_K_0, tmp; \
239 mtspr INTERRUPT_MASK_SET_1_1, tmp 239 mtspr SPR_INTERRUPT_MASK_SET_K_1, tmp
240 240
241/* Enable interrupts. */ 241/* Enable interrupts. */
242#define IRQ_ENABLE(tmp0, tmp1) \ 242#define IRQ_ENABLE(tmp0, tmp1) \
@@ -246,8 +246,8 @@ DECLARE_PER_CPU(unsigned long long, interrupts_enabled_mask);
246 addi tmp1, tmp0, 4 \ 246 addi tmp1, tmp0, 4 \
247 }; \ 247 }; \
248 lw tmp1, tmp1; \ 248 lw tmp1, tmp1; \
249 mtspr INTERRUPT_MASK_RESET_1_0, tmp0; \ 249 mtspr SPR_INTERRUPT_MASK_RESET_K_0, tmp0; \
250 mtspr INTERRUPT_MASK_RESET_1_1, tmp1 250 mtspr SPR_INTERRUPT_MASK_RESET_K_1, tmp1
251#endif 251#endif
252 252
253/* 253/*
diff --git a/arch/tile/include/asm/kmap_types.h b/arch/tile/include/asm/kmap_types.h
index 1480106d1c05..3d0f20246260 100644
--- a/arch/tile/include/asm/kmap_types.h
+++ b/arch/tile/include/asm/kmap_types.h
@@ -16,28 +16,42 @@
16#define _ASM_TILE_KMAP_TYPES_H 16#define _ASM_TILE_KMAP_TYPES_H
17 17
18/* 18/*
19 * In TILE Linux each set of four of these uses another 16MB chunk of 19 * In 32-bit TILE Linux we have to balance the desire to have a lot of
20 * address space, given 64 tiles and 64KB pages, so we only enable 20 * nested atomic mappings with the fact that large page sizes and many
21 * ones that are required by the kernel configuration. 21 * processors chew up address space quickly. In a typical
22 * 64-processor, 64KB-page layout build, making KM_TYPE_NR one larger
23 * adds 4MB of required address-space. For now we leave KM_TYPE_NR
24 * set to depth 8.
22 */ 25 */
23enum km_type { 26enum km_type {
27 KM_TYPE_NR = 8
28};
29
30/*
31 * We provide dummy definitions of all the stray values that used to be
32 * required for kmap_atomic() and no longer are.
33 */
34enum {
24 KM_BOUNCE_READ, 35 KM_BOUNCE_READ,
25 KM_SKB_SUNRPC_DATA, 36 KM_SKB_SUNRPC_DATA,
26 KM_SKB_DATA_SOFTIRQ, 37 KM_SKB_DATA_SOFTIRQ,
27 KM_USER0, 38 KM_USER0,
28 KM_USER1, 39 KM_USER1,
29 KM_BIO_SRC_IRQ, 40 KM_BIO_SRC_IRQ,
41 KM_BIO_DST_IRQ,
42 KM_PTE0,
43 KM_PTE1,
30 KM_IRQ0, 44 KM_IRQ0,
31 KM_IRQ1, 45 KM_IRQ1,
32 KM_SOFTIRQ0, 46 KM_SOFTIRQ0,
33 KM_SOFTIRQ1, 47 KM_SOFTIRQ1,
34 KM_MEMCPY0, 48 KM_SYNC_ICACHE,
35 KM_MEMCPY1, 49 KM_SYNC_DCACHE,
36#if defined(CONFIG_HIGHPTE) 50 KM_UML_USERCOPY,
37 KM_PTE0, 51 KM_IRQ_PTE,
38 KM_PTE1, 52 KM_NMI,
39#endif 53 KM_NMI_PTE,
40 KM_TYPE_NR 54 KM_KDB
41}; 55};
42 56
43#endif /* _ASM_TILE_KMAP_TYPES_H */ 57#endif /* _ASM_TILE_KMAP_TYPES_H */
diff --git a/arch/tile/include/asm/mman.h b/arch/tile/include/asm/mman.h
index 4c6811e3e8dc..81b8fc348d63 100644
--- a/arch/tile/include/asm/mman.h
+++ b/arch/tile/include/asm/mman.h
@@ -23,6 +23,7 @@
23#define MAP_POPULATE 0x0040 /* populate (prefault) pagetables */ 23#define MAP_POPULATE 0x0040 /* populate (prefault) pagetables */
24#define MAP_NONBLOCK 0x0080 /* do not block on IO */ 24#define MAP_NONBLOCK 0x0080 /* do not block on IO */
25#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ 25#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
26#define MAP_STACK MAP_GROWSDOWN /* provide convenience alias */
26#define MAP_LOCKED 0x0200 /* pages are locked */ 27#define MAP_LOCKED 0x0200 /* pages are locked */
27#define MAP_NORESERVE 0x0400 /* don't check for reservations */ 28#define MAP_NORESERVE 0x0400 /* don't check for reservations */
28#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ 29#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
diff --git a/arch/tile/include/asm/page.h b/arch/tile/include/asm/page.h
index 7d90641cf18d..7979a45430d3 100644
--- a/arch/tile/include/asm/page.h
+++ b/arch/tile/include/asm/page.h
@@ -199,17 +199,17 @@ static inline __attribute_const__ int get_order(unsigned long size)
199 * If you want more physical memory than this then see the CONFIG_HIGHMEM 199 * If you want more physical memory than this then see the CONFIG_HIGHMEM
200 * option in the kernel configuration. 200 * option in the kernel configuration.
201 * 201 *
202 * The top two 16MB chunks in the table below (VIRT and HV) are 202 * The top 16MB chunk in the table below is unavailable to Linux. Since
203 * unavailable to Linux. Since the kernel interrupt vectors must live 203 * the kernel interrupt vectors must live at ether 0xfe000000 or 0xfd000000
204 * at 0xfd000000, we map all of the bottom of RAM at this address with 204 * (depending on whether the kernel is at PL2 or Pl1), we map all of the
205 * a huge page table entry to minimize its ITLB footprint (as well as 205 * bottom of RAM at this address with a huge page table entry to minimize
206 * at PAGE_OFFSET). The last architected requirement is that user 206 * its ITLB footprint (as well as at PAGE_OFFSET). The last architected
207 * interrupt vectors live at 0xfc000000, so we make that range of 207 * requirement is that user interrupt vectors live at 0xfc000000, so we
208 * memory available to user processes. The remaining regions are sized 208 * make that range of memory available to user processes. The remaining
209 * as shown; after the first four addresses, we show "typical" values, 209 * regions are sized as shown; the first four addresses use the PL 1
210 * since the actual addresses depend on kernel #defines. 210 * values, and after that, we show "typical" values, since the actual
211 * addresses depend on kernel #defines.
211 * 212 *
212 * MEM_VIRT_INTRPT 0xff000000
213 * MEM_HV_INTRPT 0xfe000000 213 * MEM_HV_INTRPT 0xfe000000
214 * MEM_SV_INTRPT (kernel code) 0xfd000000 214 * MEM_SV_INTRPT (kernel code) 0xfd000000
215 * MEM_USER_INTRPT (user vector) 0xfc000000 215 * MEM_USER_INTRPT (user vector) 0xfc000000
@@ -221,9 +221,14 @@ static inline __attribute_const__ int get_order(unsigned long size)
221 */ 221 */
222 222
223#define MEM_USER_INTRPT _AC(0xfc000000, UL) 223#define MEM_USER_INTRPT _AC(0xfc000000, UL)
224#if CONFIG_KERNEL_PL == 1
224#define MEM_SV_INTRPT _AC(0xfd000000, UL) 225#define MEM_SV_INTRPT _AC(0xfd000000, UL)
225#define MEM_HV_INTRPT _AC(0xfe000000, UL) 226#define MEM_HV_INTRPT _AC(0xfe000000, UL)
226#define MEM_VIRT_INTRPT _AC(0xff000000, UL) 227#else
228#define MEM_GUEST_INTRPT _AC(0xfd000000, UL)
229#define MEM_SV_INTRPT _AC(0xfe000000, UL)
230#define MEM_HV_INTRPT _AC(0xff000000, UL)
231#endif
227 232
228#define INTRPT_SIZE 0x4000 233#define INTRPT_SIZE 0x4000
229 234
diff --git a/arch/tile/include/asm/pgtable.h b/arch/tile/include/asm/pgtable.h
index b3367379d537..a6604e9485da 100644
--- a/arch/tile/include/asm/pgtable.h
+++ b/arch/tile/include/asm/pgtable.h
@@ -344,18 +344,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
344#define pgd_offset_k(address) pgd_offset(&init_mm, address) 344#define pgd_offset_k(address) pgd_offset(&init_mm, address)
345 345
346#if defined(CONFIG_HIGHPTE) 346#if defined(CONFIG_HIGHPTE)
347extern pte_t *_pte_offset_map(pmd_t *, unsigned long address, enum km_type); 347extern pte_t *pte_offset_map(pmd_t *, unsigned long address);
348#define pte_offset_map(dir, address) \ 348#define pte_unmap(pte) kunmap_atomic(pte)
349 _pte_offset_map(dir, address, KM_PTE0)
350#define pte_offset_map_nested(dir, address) \
351 _pte_offset_map(dir, address, KM_PTE1)
352#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
353#define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1)
354#else 349#else
355#define pte_offset_map(dir, address) pte_offset_kernel(dir, address) 350#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
356#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
357#define pte_unmap(pte) do { } while (0) 351#define pte_unmap(pte) do { } while (0)
358#define pte_unmap_nested(pte) do { } while (0)
359#endif 352#endif
360 353
361/* Clear a non-executable kernel PTE and flush it from the TLB. */ 354/* Clear a non-executable kernel PTE and flush it from the TLB. */
diff --git a/arch/tile/include/asm/processor.h b/arch/tile/include/asm/processor.h
index ccd5f8425688..1747ff3946b2 100644
--- a/arch/tile/include/asm/processor.h
+++ b/arch/tile/include/asm/processor.h
@@ -328,18 +328,21 @@ extern int kdata_huge;
328 * Note that assembly code assumes that USER_PL is zero. 328 * Note that assembly code assumes that USER_PL is zero.
329 */ 329 */
330#define USER_PL 0 330#define USER_PL 0
331#define KERNEL_PL 1 331#if CONFIG_KERNEL_PL == 2
332#define GUEST_PL 1
333#endif
334#define KERNEL_PL CONFIG_KERNEL_PL
332 335
333/* SYSTEM_SAVE_1_0 holds the current cpu number ORed with ksp0. */ 336/* SYSTEM_SAVE_K_0 holds the current cpu number ORed with ksp0. */
334#define CPU_LOG_MASK_VALUE 12 337#define CPU_LOG_MASK_VALUE 12
335#define CPU_MASK_VALUE ((1 << CPU_LOG_MASK_VALUE) - 1) 338#define CPU_MASK_VALUE ((1 << CPU_LOG_MASK_VALUE) - 1)
336#if CONFIG_NR_CPUS > CPU_MASK_VALUE 339#if CONFIG_NR_CPUS > CPU_MASK_VALUE
337# error Too many cpus! 340# error Too many cpus!
338#endif 341#endif
339#define raw_smp_processor_id() \ 342#define raw_smp_processor_id() \
340 ((int)__insn_mfspr(SPR_SYSTEM_SAVE_1_0) & CPU_MASK_VALUE) 343 ((int)__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & CPU_MASK_VALUE)
341#define get_current_ksp0() \ 344#define get_current_ksp0() \
342 (__insn_mfspr(SPR_SYSTEM_SAVE_1_0) & ~CPU_MASK_VALUE) 345 (__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & ~CPU_MASK_VALUE)
343#define next_current_ksp0(task) ({ \ 346#define next_current_ksp0(task) ({ \
344 unsigned long __ksp0 = task_ksp0(task); \ 347 unsigned long __ksp0 = task_ksp0(task); \
345 int __cpu = raw_smp_processor_id(); \ 348 int __cpu = raw_smp_processor_id(); \
diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h
index 4a02bb073979..ac6d343129d3 100644
--- a/arch/tile/include/asm/ptrace.h
+++ b/arch/tile/include/asm/ptrace.h
@@ -62,8 +62,8 @@ struct pt_regs {
62 pt_reg_t lr; /* aliases regs[TREG_LR] */ 62 pt_reg_t lr; /* aliases regs[TREG_LR] */
63 63
64 /* Saved special registers. */ 64 /* Saved special registers. */
65 pt_reg_t pc; /* stored in EX_CONTEXT_1_0 */ 65 pt_reg_t pc; /* stored in EX_CONTEXT_K_0 */
66 pt_reg_t ex1; /* stored in EX_CONTEXT_1_1 (PL and ICS bit) */ 66 pt_reg_t ex1; /* stored in EX_CONTEXT_K_1 (PL and ICS bit) */
67 pt_reg_t faultnum; /* fault number (INT_SWINT_1 for syscall) */ 67 pt_reg_t faultnum; /* fault number (INT_SWINT_1 for syscall) */
68 pt_reg_t orig_r0; /* r0 at syscall entry, else zero */ 68 pt_reg_t orig_r0; /* r0 at syscall entry, else zero */
69 pt_reg_t flags; /* flags (see below) */ 69 pt_reg_t flags; /* flags (see below) */
diff --git a/arch/tile/include/asm/stat.h b/arch/tile/include/asm/stat.h
index 3dc90fa92c70..b16e5db8f0e7 100644
--- a/arch/tile/include/asm/stat.h
+++ b/arch/tile/include/asm/stat.h
@@ -1 +1,4 @@
1#ifdef CONFIG_COMPAT
2#define __ARCH_WANT_STAT64 /* Used for compat_sys_stat64() etc. */
3#endif
1#include <asm-generic/stat.h> 4#include <asm-generic/stat.h>
diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h
index ce99ffefeacf..3b5507c31eae 100644
--- a/arch/tile/include/asm/syscalls.h
+++ b/arch/tile/include/asm/syscalls.h
@@ -32,8 +32,9 @@ extern void *compat_sys_call_table[];
32 32
33/* 33/*
34 * Note that by convention, any syscall which requires the current 34 * Note that by convention, any syscall which requires the current
35 * register set takes an additional "struct pt_regs *" pointer; the 35 * register set takes an additional "struct pt_regs *" pointer; a
36 * sys_xxx() function just adds the pointer and tail-calls to _sys_xxx(). 36 * _sys_xxx() trampoline in intvec*.S just sets up the pointer and
37 * jumps to sys_xxx().
37 */ 38 */
38 39
39/* kernel/sys.c */ 40/* kernel/sys.c */
@@ -43,66 +44,17 @@ long sys32_fadvise64(int fd, u32 offset_lo, u32 offset_hi,
43int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi, 44int sys32_fadvise64_64(int fd, u32 offset_lo, u32 offset_hi,
44 u32 len_lo, u32 len_hi, int advice); 45 u32 len_lo, u32 len_hi, int advice);
45long sys_flush_cache(void); 46long sys_flush_cache(void);
46long sys_mmap2(unsigned long addr, unsigned long len, 47#ifndef __tilegx__ /* No mmap() in the 32-bit kernel. */
47 unsigned long prot, unsigned long flags, 48#define sys_mmap sys_mmap
48 unsigned long fd, unsigned long pgoff);
49#ifdef __tilegx__
50long sys_mmap(unsigned long addr, unsigned long len,
51 unsigned long prot, unsigned long flags,
52 unsigned long fd, off_t pgoff);
53#endif 49#endif
54 50
55/* kernel/process.c */
56long sys_clone(unsigned long clone_flags, unsigned long newsp,
57 void __user *parent_tid, void __user *child_tid);
58long _sys_clone(unsigned long clone_flags, unsigned long newsp,
59 void __user *parent_tid, void __user *child_tid,
60 struct pt_regs *regs);
61long sys_fork(void);
62long _sys_fork(struct pt_regs *regs);
63long sys_vfork(void);
64long _sys_vfork(struct pt_regs *regs);
65long sys_execve(const char __user *filename,
66 const char __user *const __user *argv,
67 const char __user *const __user *envp);
68long _sys_execve(const char __user *filename,
69 const char __user *const __user *argv,
70 const char __user *const __user *envp, struct pt_regs *regs);
71
72/* kernel/signal.c */
73long sys_sigaltstack(const stack_t __user *, stack_t __user *);
74long _sys_sigaltstack(const stack_t __user *, stack_t __user *,
75 struct pt_regs *);
76long sys_rt_sigreturn(void);
77long _sys_rt_sigreturn(struct pt_regs *regs);
78
79/* platform-independent functions */
80long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize);
81long sys_rt_sigaction(int sig, const struct sigaction __user *act,
82 struct sigaction __user *oact, size_t sigsetsize);
83
84#ifndef __tilegx__ 51#ifndef __tilegx__
85/* mm/fault.c */ 52/* mm/fault.c */
86int sys_cmpxchg_badaddr(unsigned long address); 53long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *);
87int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 54long _sys_cmpxchg_badaddr(unsigned long address);
88#endif 55#endif
89 56
90#ifdef CONFIG_COMPAT 57#ifdef CONFIG_COMPAT
91long compat_sys_execve(const char __user *path,
92 const compat_uptr_t __user *argv,
93 const compat_uptr_t __user *envp);
94long _compat_sys_execve(const char __user *path,
95 const compat_uptr_t __user *argv,
96 const compat_uptr_t __user *envp,
97 struct pt_regs *regs);
98long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
99 struct compat_sigaltstack __user *uoss_ptr);
100long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
101 struct compat_sigaltstack __user *uoss_ptr,
102 struct pt_regs *regs);
103long compat_sys_rt_sigreturn(void);
104long _compat_sys_rt_sigreturn(struct pt_regs *regs);
105
106/* These four are not defined for 64-bit, but serve as "compat" syscalls. */ 58/* These four are not defined for 64-bit, but serve as "compat" syscalls. */
107long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg); 59long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg);
108long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf); 60long sys_fstat64(unsigned long fd, struct stat64 __user *statbuf);
@@ -110,4 +62,15 @@ long sys_truncate64(const char __user *path, loff_t length);
110long sys_ftruncate64(unsigned int fd, loff_t length); 62long sys_ftruncate64(unsigned int fd, loff_t length);
111#endif 63#endif
112 64
65/* These are the intvec*.S trampolines. */
66long _sys_sigaltstack(const stack_t __user *, stack_t __user *);
67long _sys_rt_sigreturn(void);
68long _sys_clone(unsigned long clone_flags, unsigned long newsp,
69 void __user *parent_tid, void __user *child_tid);
70long _sys_execve(const char __user *filename,
71 const char __user *const __user *argv,
72 const char __user *const __user *envp);
73
74#include <asm-generic/syscalls.h>
75
113#endif /* _ASM_TILE_SYSCALLS_H */ 76#endif /* _ASM_TILE_SYSCALLS_H */
diff --git a/arch/tile/include/asm/system.h b/arch/tile/include/asm/system.h
index f749be327ce0..5388850deeb2 100644
--- a/arch/tile/include/asm/system.h
+++ b/arch/tile/include/asm/system.h
@@ -89,6 +89,10 @@
89#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */ 89#define get_cycles_low() __insn_mfspr(SPR_CYCLE) /* just get all 64 bits */
90#endif 90#endif
91 91
92#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()
93int __mb_incoherent(void); /* Helper routine for mb_incoherent(). */
94#endif
95
92/* Fence to guarantee visibility of stores to incoherent memory. */ 96/* Fence to guarantee visibility of stores to incoherent memory. */
93static inline void 97static inline void
94mb_incoherent(void) 98mb_incoherent(void)
@@ -97,7 +101,6 @@ mb_incoherent(void)
97 101
98#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS() 102#if !CHIP_HAS_MF_WAITS_FOR_VICTIMS()
99 { 103 {
100 int __mb_incoherent(void);
101#if CHIP_HAS_TILE_WRITE_PENDING() 104#if CHIP_HAS_TILE_WRITE_PENDING()
102 const unsigned long WRITE_TIMEOUT_CYCLES = 400; 105 const unsigned long WRITE_TIMEOUT_CYCLES = 400;
103 unsigned long start = get_cycles_low(); 106 unsigned long start = get_cycles_low();
@@ -161,7 +164,7 @@ extern struct task_struct *_switch_to(struct task_struct *prev,
161/* Helper function for _switch_to(). */ 164/* Helper function for _switch_to(). */
162extern struct task_struct *__switch_to(struct task_struct *prev, 165extern struct task_struct *__switch_to(struct task_struct *prev,
163 struct task_struct *next, 166 struct task_struct *next,
164 unsigned long new_system_save_1_0); 167 unsigned long new_system_save_k_0);
165 168
166/* Address that switched-away from tasks are at. */ 169/* Address that switched-away from tasks are at. */
167extern unsigned long get_switch_to_pc(void); 170extern unsigned long get_switch_to_pc(void);
@@ -214,13 +217,6 @@ int hardwall_deactivate(struct task_struct *task);
214} while (0) 217} while (0)
215#endif 218#endif
216 219
217/* Invoke the simulator "syscall" mechanism (see arch/tile/kernel/entry.S). */
218extern int _sim_syscall(int syscall_num, ...);
219#define sim_syscall(syscall_num, ...) \
220 _sim_syscall(SIM_CONTROL_SYSCALL + \
221 ((syscall_num) << _SIM_CONTROL_OPERATOR_BITS), \
222 ## __VA_ARGS__)
223
224/* 220/*
225 * Kernel threads can check to see if they need to migrate their 221 * Kernel threads can check to see if they need to migrate their
226 * stack whenever they return from a context switch; for user 222 * stack whenever they return from a context switch; for user
diff --git a/arch/tile/include/asm/traps.h b/arch/tile/include/asm/traps.h
index 432a9c15c8a2..d06e35f57201 100644
--- a/arch/tile/include/asm/traps.h
+++ b/arch/tile/include/asm/traps.h
@@ -59,4 +59,8 @@ void do_hardwall_trap(struct pt_regs *, int fault_num);
59void do_breakpoint(struct pt_regs *, int fault_num); 59void do_breakpoint(struct pt_regs *, int fault_num);
60 60
61 61
62#ifdef __tilegx__
63void gx_singlestep_handle(struct pt_regs *, int fault_num);
64#endif
65
62#endif /* _ASM_TILE_SYSCALLS_H */ 66#endif /* _ASM_TILE_SYSCALLS_H */
diff --git a/arch/tile/include/asm/unistd.h b/arch/tile/include/asm/unistd.h
index f2e3ff485333..b35c2db71199 100644
--- a/arch/tile/include/asm/unistd.h
+++ b/arch/tile/include/asm/unistd.h
@@ -41,6 +41,7 @@ __SYSCALL(__NR_cmpxchg_badaddr, sys_cmpxchg_badaddr)
41#ifdef CONFIG_COMPAT 41#ifdef CONFIG_COMPAT
42#define __ARCH_WANT_SYS_LLSEEK 42#define __ARCH_WANT_SYS_LLSEEK
43#endif 43#endif
44#define __ARCH_WANT_SYS_NEWFSTATAT
44#endif 45#endif
45 46
46#endif /* _ASM_TILE_UNISTD_H */ 47#endif /* _ASM_TILE_UNISTD_H */
diff --git a/arch/tile/include/hv/hypervisor.h b/arch/tile/include/hv/hypervisor.h
index 9bd303a141b2..f672544cd4f9 100644
--- a/arch/tile/include/hv/hypervisor.h
+++ b/arch/tile/include/hv/hypervisor.h
@@ -1003,37 +1003,37 @@ int hv_console_write(HV_VirtAddr bytes, int len);
1003 * when these occur in a client's interrupt critical section, they must 1003 * when these occur in a client's interrupt critical section, they must
1004 * be delivered through the downcall mechanism. 1004 * be delivered through the downcall mechanism.
1005 * 1005 *
1006 * A downcall is initially delivered to the client as an INTCTRL_1 1006 * A downcall is initially delivered to the client as an INTCTRL_CL
1007 * interrupt. Upon entry to the INTCTRL_1 vector, the client must 1007 * interrupt, where CL is the client's PL. Upon entry to the INTCTRL_CL
1008 * immediately invoke the hv_downcall_dispatch service. This service 1008 * vector, the client must immediately invoke the hv_downcall_dispatch
1009 * will not return; instead it will cause one of the client's actual 1009 * service. This service will not return; instead it will cause one of
1010 * downcall-handling interrupt vectors to be entered. The EX_CONTEXT 1010 * the client's actual downcall-handling interrupt vectors to be entered.
1011 * registers in the client will be set so that when the client irets, 1011 * The EX_CONTEXT registers in the client will be set so that when the
1012 * it will return to the code which was interrupted by the INTCTRL_1 1012 * client irets, it will return to the code which was interrupted by the
1013 * interrupt. 1013 * INTCTRL_CL interrupt.
1014 * 1014 *
1015 * Under some circumstances, the firing of INTCTRL_1 can race with 1015 * Under some circumstances, the firing of INTCTRL_CL can race with
1016 * the lowering of a device interrupt. In such a case, the 1016 * the lowering of a device interrupt. In such a case, the
1017 * hv_downcall_dispatch service may issue an iret instruction instead 1017 * hv_downcall_dispatch service may issue an iret instruction instead
1018 * of entering one of the client's actual downcall-handling interrupt 1018 * of entering one of the client's actual downcall-handling interrupt
1019 * vectors. This will return execution to the location that was 1019 * vectors. This will return execution to the location that was
1020 * interrupted by INTCTRL_1. 1020 * interrupted by INTCTRL_CL.
1021 * 1021 *
1022 * Any saving of registers should be done by the actual handling 1022 * Any saving of registers should be done by the actual handling
1023 * vectors; no registers should be changed by the INTCTRL_1 handler. 1023 * vectors; no registers should be changed by the INTCTRL_CL handler.
1024 * In particular, the client should not use a jal instruction to invoke 1024 * In particular, the client should not use a jal instruction to invoke
1025 * the hv_downcall_dispatch service, as that would overwrite the client's 1025 * the hv_downcall_dispatch service, as that would overwrite the client's
1026 * lr register. Note that the hv_downcall_dispatch service may overwrite 1026 * lr register. Note that the hv_downcall_dispatch service may overwrite
1027 * one or more of the client's system save registers. 1027 * one or more of the client's system save registers.
1028 * 1028 *
1029 * The client must not modify the INTCTRL_1_STATUS SPR. The hypervisor 1029 * The client must not modify the INTCTRL_CL_STATUS SPR. The hypervisor
1030 * will set this register to cause a downcall to happen, and will clear 1030 * will set this register to cause a downcall to happen, and will clear
1031 * it when no further downcalls are pending. 1031 * it when no further downcalls are pending.
1032 * 1032 *
1033 * When a downcall vector is entered, the INTCTRL_1 interrupt will be 1033 * When a downcall vector is entered, the INTCTRL_CL interrupt will be
1034 * masked. When the client is done processing a downcall, and is ready 1034 * masked. When the client is done processing a downcall, and is ready
1035 * to accept another, it must unmask this interrupt; if more downcalls 1035 * to accept another, it must unmask this interrupt; if more downcalls
1036 * are pending, this will cause the INTCTRL_1 vector to be reentered. 1036 * are pending, this will cause the INTCTRL_CL vector to be reentered.
1037 * Currently the following interrupt vectors can be entered through a 1037 * Currently the following interrupt vectors can be entered through a
1038 * downcall: 1038 * downcall:
1039 * 1039 *
diff --git a/arch/tile/kernel/backtrace.c b/arch/tile/kernel/backtrace.c
index d3c41c1ff6bd..55a6a74974b4 100644
--- a/arch/tile/kernel/backtrace.c
+++ b/arch/tile/kernel/backtrace.c
@@ -369,6 +369,10 @@ static void find_caller_pc_and_caller_sp(CallerLocation *location,
369 /* Weird; reserved value, ignore it. */ 369 /* Weird; reserved value, ignore it. */
370 continue; 370 continue;
371 } 371 }
372 if (info_operand & ENTRY_POINT_INFO_OP) {
373 /* This info op is ignored by the backtracer. */
374 continue;
375 }
372 376
373 /* Skip info ops which are not in the 377 /* Skip info ops which are not in the
374 * "one_ago" mode we want right now. 378 * "one_ago" mode we want right now.
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index b1e06d041555..67617a05e602 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -148,14 +148,20 @@ long tile_compat_sys_msgrcv(int msqid,
148#define compat_sys_readahead sys32_readahead 148#define compat_sys_readahead sys32_readahead
149#define compat_sys_sync_file_range compat_sys_sync_file_range2 149#define compat_sys_sync_file_range compat_sys_sync_file_range2
150 150
151/* The native 64-bit "struct stat" matches the 32-bit "struct stat64". */ 151/* We leverage the "struct stat64" type for 32-bit time_t/nsec. */
152#define compat_sys_stat64 sys_newstat 152#define compat_sys_stat64 sys_stat64
153#define compat_sys_lstat64 sys_newlstat 153#define compat_sys_lstat64 sys_lstat64
154#define compat_sys_fstat64 sys_newfstat 154#define compat_sys_fstat64 sys_fstat64
155#define compat_sys_fstatat64 sys_newfstatat 155#define compat_sys_fstatat64 sys_fstatat64
156 156
157/* Pass full 64-bit values through ptrace. */ 157/* The native sys_ptrace dynamically handles compat binaries. */
158#define compat_sys_ptrace tile_compat_sys_ptrace 158#define compat_sys_ptrace sys_ptrace
159
160/* Call the trampolines to manage pt_regs where necessary. */
161#define compat_sys_execve _compat_sys_execve
162#define compat_sys_sigaltstack _compat_sys_sigaltstack
163#define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn
164#define sys_clone _sys_clone
159 165
160/* 166/*
161 * Note that we can't include <linux/unistd.h> here since the header 167 * Note that we can't include <linux/unistd.h> here since the header
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index 9c710db43f13..fb64b99959d4 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -256,9 +256,9 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
256 return err; 256 return err;
257} 257}
258 258
259long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 259long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
260 struct compat_sigaltstack __user *uoss_ptr, 260 struct compat_sigaltstack __user *uoss_ptr,
261 struct pt_regs *regs) 261 struct pt_regs *regs)
262{ 262{
263 stack_t uss, uoss; 263 stack_t uss, uoss;
264 int ret; 264 int ret;
@@ -291,7 +291,7 @@ long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
291 return ret; 291 return ret;
292} 292}
293 293
294long _compat_sys_rt_sigreturn(struct pt_regs *regs) 294long compat_sys_rt_sigreturn(struct pt_regs *regs)
295{ 295{
296 struct compat_rt_sigframe __user *frame = 296 struct compat_rt_sigframe __user *frame =
297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); 297 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp);
@@ -312,7 +312,7 @@ long _compat_sys_rt_sigreturn(struct pt_regs *regs)
312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) 312 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
313 goto badframe; 313 goto badframe;
314 314
315 if (_compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) 315 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0)
316 goto badframe; 316 goto badframe;
317 317
318 return r0; 318 return r0;
diff --git a/arch/tile/kernel/early_printk.c b/arch/tile/kernel/early_printk.c
index 2c54fd43a8a0..493a0e66d916 100644
--- a/arch/tile/kernel/early_printk.c
+++ b/arch/tile/kernel/early_printk.c
@@ -54,7 +54,7 @@ void early_printk(const char *fmt, ...)
54void early_panic(const char *fmt, ...) 54void early_panic(const char *fmt, ...)
55{ 55{
56 va_list ap; 56 va_list ap;
57 raw_local_irq_disable_all(); 57 arch_local_irq_disable_all();
58 va_start(ap, fmt); 58 va_start(ap, fmt);
59 early_printk("Kernel panic - not syncing: "); 59 early_printk("Kernel panic - not syncing: ");
60 early_vprintk(fmt, ap); 60 early_vprintk(fmt, ap);
diff --git a/arch/tile/kernel/entry.S b/arch/tile/kernel/entry.S
index 3d01383b1b0e..fd8dc42abdcb 100644
--- a/arch/tile/kernel/entry.S
+++ b/arch/tile/kernel/entry.S
@@ -15,7 +15,9 @@
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <linux/unistd.h> 16#include <linux/unistd.h>
17#include <asm/irqflags.h> 17#include <asm/irqflags.h>
18#include <asm/processor.h>
18#include <arch/abi.h> 19#include <arch/abi.h>
20#include <arch/spr_def.h>
19 21
20#ifdef __tilegx__ 22#ifdef __tilegx__
21#define bnzt bnezt 23#define bnzt bnezt
@@ -25,28 +27,6 @@ STD_ENTRY(current_text_addr)
25 { move r0, lr; jrp lr } 27 { move r0, lr; jrp lr }
26 STD_ENDPROC(current_text_addr) 28 STD_ENDPROC(current_text_addr)
27 29
28STD_ENTRY(_sim_syscall)
29 /*
30 * Wait for r0-r9 to be ready (and lr on the off chance we
31 * want the syscall to locate its caller), then make a magic
32 * simulator syscall.
33 *
34 * We carefully stall until the registers are readable in case they
35 * are the target of a slow load, etc. so that tile-sim will
36 * definitely be able to read all of them inside the magic syscall.
37 *
38 * Technically this is wrong for r3-r9 and lr, since an interrupt
39 * could come in and restore the registers with a slow load right
40 * before executing the mtspr. We may need to modify tile-sim to
41 * explicitly stall for this case, but we do not yet have
42 * a way to implement such a stall.
43 */
44 { and zero, lr, r9 ; and zero, r8, r7 }
45 { and zero, r6, r5 ; and zero, r4, r3 }
46 { and zero, r2, r1 ; mtspr SIM_CONTROL, r0 }
47 { jrp lr }
48 STD_ENDPROC(_sim_syscall)
49
50/* 30/*
51 * Implement execve(). The i386 code has a note that forking from kernel 31 * Implement execve(). The i386 code has a note that forking from kernel
52 * space results in no copy on write until the execve, so we should be 32 * space results in no copy on write until the execve, so we should be
@@ -102,7 +82,7 @@ STD_ENTRY(KBacktraceIterator_init_current)
102STD_ENTRY(cpu_idle_on_new_stack) 82STD_ENTRY(cpu_idle_on_new_stack)
103 { 83 {
104 move sp, r1 84 move sp, r1
105 mtspr SYSTEM_SAVE_1_0, r2 85 mtspr SPR_SYSTEM_SAVE_K_0, r2
106 } 86 }
107 jal free_thread_info 87 jal free_thread_info
108 j cpu_idle 88 j cpu_idle
@@ -124,15 +104,15 @@ STD_ENTRY(smp_nap)
124STD_ENTRY(_cpu_idle) 104STD_ENTRY(_cpu_idle)
125 { 105 {
126 lnk r0 106 lnk r0
127 movei r1, 1 107 movei r1, KERNEL_PL
128 } 108 }
129 { 109 {
130 addli r0, r0, _cpu_idle_nap - . 110 addli r0, r0, _cpu_idle_nap - .
131 mtspr INTERRUPT_CRITICAL_SECTION, r1 111 mtspr INTERRUPT_CRITICAL_SECTION, r1
132 } 112 }
133 IRQ_ENABLE(r2, r3) /* unmask, but still with ICS set */ 113 IRQ_ENABLE(r2, r3) /* unmask, but still with ICS set */
134 mtspr EX_CONTEXT_1_1, r1 /* PL1, ICS clear */ 114 mtspr SPR_EX_CONTEXT_K_1, r1 /* Kernel PL, ICS clear */
135 mtspr EX_CONTEXT_1_0, r0 115 mtspr SPR_EX_CONTEXT_K_0, r0
136 iret 116 iret
137 .global _cpu_idle_nap 117 .global _cpu_idle_nap
138_cpu_idle_nap: 118_cpu_idle_nap:
diff --git a/arch/tile/kernel/hardwall.c b/arch/tile/kernel/hardwall.c
index 584b965dc824..e910530436e6 100644
--- a/arch/tile/kernel/hardwall.c
+++ b/arch/tile/kernel/hardwall.c
@@ -151,12 +151,12 @@ enum direction_protect {
151 151
152static void enable_firewall_interrupts(void) 152static void enable_firewall_interrupts(void)
153{ 153{
154 raw_local_irq_unmask_now(INT_UDN_FIREWALL); 154 arch_local_irq_unmask_now(INT_UDN_FIREWALL);
155} 155}
156 156
157static void disable_firewall_interrupts(void) 157static void disable_firewall_interrupts(void)
158{ 158{
159 raw_local_irq_mask_now(INT_UDN_FIREWALL); 159 arch_local_irq_mask_now(INT_UDN_FIREWALL);
160} 160}
161 161
162/* Set up hardwall on this cpu based on the passed hardwall_info. */ 162/* Set up hardwall on this cpu based on the passed hardwall_info. */
@@ -768,6 +768,7 @@ static int hardwall_release(struct inode *inode, struct file *file)
768} 768}
769 769
770static const struct file_operations dev_hardwall_fops = { 770static const struct file_operations dev_hardwall_fops = {
771 .open = nonseekable_open,
771 .unlocked_ioctl = hardwall_ioctl, 772 .unlocked_ioctl = hardwall_ioctl,
772#ifdef CONFIG_COMPAT 773#ifdef CONFIG_COMPAT
773 .compat_ioctl = hardwall_compat_ioctl, 774 .compat_ioctl = hardwall_compat_ioctl,
diff --git a/arch/tile/kernel/head_32.S b/arch/tile/kernel/head_32.S
index 2b4f6c091701..90e7c4435693 100644
--- a/arch/tile/kernel/head_32.S
+++ b/arch/tile/kernel/head_32.S
@@ -23,6 +23,7 @@
23#include <asm/asm-offsets.h> 23#include <asm/asm-offsets.h>
24#include <hv/hypervisor.h> 24#include <hv/hypervisor.h>
25#include <arch/chip.h> 25#include <arch/chip.h>
26#include <arch/spr_def.h>
26 27
27/* 28/*
28 * This module contains the entry code for kernel images. It performs the 29 * This module contains the entry code for kernel images. It performs the
@@ -76,7 +77,7 @@ ENTRY(_start)
76 } 77 }
771: 781:
78 79
79 /* Get our processor number and save it away in SAVE_1_0. */ 80 /* Get our processor number and save it away in SAVE_K_0. */
80 jal hv_inquire_topology 81 jal hv_inquire_topology
81 mulll_uu r4, r1, r2 /* r1 == y, r2 == width */ 82 mulll_uu r4, r1, r2 /* r1 == y, r2 == width */
82 add r4, r4, r0 /* r0 == x, so r4 == cpu == y*width + x */ 83 add r4, r4, r0 /* r0 == x, so r4 == cpu == y*width + x */
@@ -124,7 +125,7 @@ ENTRY(_start)
124 lw r0, r0 125 lw r0, r0
125 lw sp, r1 126 lw sp, r1
126 or r4, sp, r4 127 or r4, sp, r4
127 mtspr SYSTEM_SAVE_1_0, r4 /* save ksp0 + cpu */ 128 mtspr SPR_SYSTEM_SAVE_K_0, r4 /* save ksp0 + cpu */
128 addi sp, sp, -STACK_TOP_DELTA 129 addi sp, sp, -STACK_TOP_DELTA
129 { 130 {
130 move lr, zero /* stop backtraces in the called function */ 131 move lr, zero /* stop backtraces in the called function */
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index 8f58bdff20d7..f5821626247f 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -32,8 +32,8 @@
32# error "No support for kernel preemption currently" 32# error "No support for kernel preemption currently"
33#endif 33#endif
34 34
35#if INT_INTCTRL_1 < 32 || INT_INTCTRL_1 >= 48 35#if INT_INTCTRL_K < 32 || INT_INTCTRL_K >= 48
36# error INT_INTCTRL_1 coded to set high interrupt mask 36# error INT_INTCTRL_K coded to set high interrupt mask
37#endif 37#endif
38 38
39#define PTREGS_PTR(reg, ptreg) addli reg, sp, C_ABI_SAVE_AREA_SIZE + (ptreg) 39#define PTREGS_PTR(reg, ptreg) addli reg, sp, C_ABI_SAVE_AREA_SIZE + (ptreg)
@@ -132,8 +132,8 @@ intvec_\vecname:
132 132
133 /* Temporarily save a register so we have somewhere to work. */ 133 /* Temporarily save a register so we have somewhere to work. */
134 134
135 mtspr SYSTEM_SAVE_1_1, r0 135 mtspr SPR_SYSTEM_SAVE_K_1, r0
136 mfspr r0, EX_CONTEXT_1_1 136 mfspr r0, SPR_EX_CONTEXT_K_1
137 137
138 /* The cmpxchg code clears sp to force us to reset it here on fault. */ 138 /* The cmpxchg code clears sp to force us to reset it here on fault. */
139 { 139 {
@@ -167,18 +167,18 @@ intvec_\vecname:
167 * The page_fault handler may be downcalled directly by the 167 * The page_fault handler may be downcalled directly by the
168 * hypervisor even when Linux is running and has ICS set. 168 * hypervisor even when Linux is running and has ICS set.
169 * 169 *
170 * In this case the contents of EX_CONTEXT_1_1 reflect the 170 * In this case the contents of EX_CONTEXT_K_1 reflect the
171 * previous fault and can't be relied on to choose whether or 171 * previous fault and can't be relied on to choose whether or
172 * not to reinitialize the stack pointer. So we add a test 172 * not to reinitialize the stack pointer. So we add a test
173 * to see whether SYSTEM_SAVE_1_2 has the high bit set, 173 * to see whether SYSTEM_SAVE_K_2 has the high bit set,
174 * and if so we don't reinitialize sp, since we must be coming 174 * and if so we don't reinitialize sp, since we must be coming
175 * from Linux. (In fact the precise case is !(val & ~1), 175 * from Linux. (In fact the precise case is !(val & ~1),
176 * but any Linux PC has to have the high bit set.) 176 * but any Linux PC has to have the high bit set.)
177 * 177 *
178 * Note that the hypervisor *always* sets SYSTEM_SAVE_1_2 for 178 * Note that the hypervisor *always* sets SYSTEM_SAVE_K_2 for
179 * any path that turns into a downcall to one of our TLB handlers. 179 * any path that turns into a downcall to one of our TLB handlers.
180 */ 180 */
181 mfspr r0, SYSTEM_SAVE_1_2 181 mfspr r0, SPR_SYSTEM_SAVE_K_2
182 { 182 {
183 blz r0, 0f /* high bit in S_S_1_2 is for a PC to use */ 183 blz r0, 0f /* high bit in S_S_1_2 is for a PC to use */
184 move r0, sp 184 move r0, sp
@@ -187,12 +187,12 @@ intvec_\vecname:
187 187
1882: 1882:
189 /* 189 /*
190 * SYSTEM_SAVE_1_0 holds the cpu number in the low bits, and 190 * SYSTEM_SAVE_K_0 holds the cpu number in the low bits, and
191 * the current stack top in the higher bits. So we recover 191 * the current stack top in the higher bits. So we recover
192 * our stack top by just masking off the low bits, then 192 * our stack top by just masking off the low bits, then
193 * point sp at the top aligned address on the actual stack page. 193 * point sp at the top aligned address on the actual stack page.
194 */ 194 */
195 mfspr r0, SYSTEM_SAVE_1_0 195 mfspr r0, SPR_SYSTEM_SAVE_K_0
196 mm r0, r0, zero, LOG2_THREAD_SIZE, 31 196 mm r0, r0, zero, LOG2_THREAD_SIZE, 31
197 197
1980: 1980:
@@ -254,7 +254,7 @@ intvec_\vecname:
254 sw sp, r3 254 sw sp, r3
255 addli sp, sp, PTREGS_OFFSET_PC - PTREGS_OFFSET_REG(3) 255 addli sp, sp, PTREGS_OFFSET_PC - PTREGS_OFFSET_REG(3)
256 } 256 }
257 mfspr r0, EX_CONTEXT_1_0 257 mfspr r0, SPR_EX_CONTEXT_K_0
258 .ifc \processing,handle_syscall 258 .ifc \processing,handle_syscall
259 /* 259 /*
260 * Bump the saved PC by one bundle so that when we return, we won't 260 * Bump the saved PC by one bundle so that when we return, we won't
@@ -267,7 +267,7 @@ intvec_\vecname:
267 sw sp, r0 267 sw sp, r0
268 addli sp, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_PC 268 addli sp, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_PC
269 } 269 }
270 mfspr r0, EX_CONTEXT_1_1 270 mfspr r0, SPR_EX_CONTEXT_K_1
271 { 271 {
272 sw sp, r0 272 sw sp, r0
273 addi sp, sp, PTREGS_OFFSET_FAULTNUM - PTREGS_OFFSET_EX1 273 addi sp, sp, PTREGS_OFFSET_FAULTNUM - PTREGS_OFFSET_EX1
@@ -289,7 +289,7 @@ intvec_\vecname:
289 .endif 289 .endif
290 addli sp, sp, PTREGS_OFFSET_REG(0) - PTREGS_OFFSET_FAULTNUM 290 addli sp, sp, PTREGS_OFFSET_REG(0) - PTREGS_OFFSET_FAULTNUM
291 } 291 }
292 mfspr r0, SYSTEM_SAVE_1_1 /* Original r0 */ 292 mfspr r0, SPR_SYSTEM_SAVE_K_1 /* Original r0 */
293 { 293 {
294 sw sp, r0 294 sw sp, r0
295 addi sp, sp, -PTREGS_OFFSET_REG(0) - 4 295 addi sp, sp, -PTREGS_OFFSET_REG(0) - 4
@@ -309,12 +309,12 @@ intvec_\vecname:
309 * See discussion below at "finish_interrupt_save". 309 * See discussion below at "finish_interrupt_save".
310 */ 310 */
311 .ifc \c_routine, do_page_fault 311 .ifc \c_routine, do_page_fault
312 mfspr r2, SYSTEM_SAVE_1_3 /* address of page fault */ 312 mfspr r2, SPR_SYSTEM_SAVE_K_3 /* address of page fault */
313 mfspr r3, SYSTEM_SAVE_1_2 /* info about page fault */ 313 mfspr r3, SPR_SYSTEM_SAVE_K_2 /* info about page fault */
314 .else 314 .else
315 .ifc \vecnum, INT_DOUBLE_FAULT 315 .ifc \vecnum, INT_DOUBLE_FAULT
316 { 316 {
317 mfspr r2, SYSTEM_SAVE_1_2 /* double fault info from HV */ 317 mfspr r2, SPR_SYSTEM_SAVE_K_2 /* double fault info from HV */
318 movei r3, 0 318 movei r3, 0
319 } 319 }
320 .else 320 .else
@@ -467,7 +467,7 @@ intvec_\vecname:
467 /* Load tp with our per-cpu offset. */ 467 /* Load tp with our per-cpu offset. */
468#ifdef CONFIG_SMP 468#ifdef CONFIG_SMP
469 { 469 {
470 mfspr r20, SYSTEM_SAVE_1_0 470 mfspr r20, SPR_SYSTEM_SAVE_K_0
471 moveli r21, lo16(__per_cpu_offset) 471 moveli r21, lo16(__per_cpu_offset)
472 } 472 }
473 { 473 {
@@ -487,7 +487,7 @@ intvec_\vecname:
487 * We load flags in r32 here so we can jump to .Lrestore_regs 487 * We load flags in r32 here so we can jump to .Lrestore_regs
488 * directly after do_page_fault_ics() if necessary. 488 * directly after do_page_fault_ics() if necessary.
489 */ 489 */
490 mfspr r32, EX_CONTEXT_1_1 490 mfspr r32, SPR_EX_CONTEXT_K_1
491 { 491 {
492 andi r32, r32, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */ 492 andi r32, r32, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
493 PTREGS_PTR(r21, PTREGS_OFFSET_FLAGS) 493 PTREGS_PTR(r21, PTREGS_OFFSET_FLAGS)
@@ -957,11 +957,11 @@ STD_ENTRY(interrupt_return)
957 pop_reg_zero r21, r3, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_PC 957 pop_reg_zero r21, r3, sp, PTREGS_OFFSET_EX1 - PTREGS_OFFSET_PC
958 pop_reg_zero lr, r4, sp, PTREGS_OFFSET_REG(52) - PTREGS_OFFSET_EX1 958 pop_reg_zero lr, r4, sp, PTREGS_OFFSET_REG(52) - PTREGS_OFFSET_EX1
959 { 959 {
960 mtspr EX_CONTEXT_1_0, r21 960 mtspr SPR_EX_CONTEXT_K_0, r21
961 move r5, zero 961 move r5, zero
962 } 962 }
963 { 963 {
964 mtspr EX_CONTEXT_1_1, lr 964 mtspr SPR_EX_CONTEXT_K_1, lr
965 andi lr, lr, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */ 965 andi lr, lr, SPR_EX_CONTEXT_1_1__PL_MASK /* mask off ICS */
966 } 966 }
967 967
@@ -1020,7 +1020,7 @@ STD_ENTRY(interrupt_return)
1020 1020
1021 /* Set r1 to errno if we are returning an error, otherwise zero. */ 1021 /* Set r1 to errno if we are returning an error, otherwise zero. */
1022 { 1022 {
1023 moveli r29, 1024 1023 moveli r29, 4096
1024 sub r1, zero, r0 1024 sub r1, zero, r0
1025 } 1025 }
1026 slt_u r29, r1, r29 1026 slt_u r29, r1, r29
@@ -1199,7 +1199,7 @@ STD_ENTRY(interrupt_return)
1199 STD_ENDPROC(interrupt_return) 1199 STD_ENDPROC(interrupt_return)
1200 1200
1201 /* 1201 /*
1202 * This interrupt variant clears the INT_INTCTRL_1 interrupt mask bit 1202 * This interrupt variant clears the INT_INTCTRL_K interrupt mask bit
1203 * before returning, so we can properly get more downcalls. 1203 * before returning, so we can properly get more downcalls.
1204 */ 1204 */
1205 .pushsection .text.handle_interrupt_downcall,"ax" 1205 .pushsection .text.handle_interrupt_downcall,"ax"
@@ -1208,11 +1208,11 @@ handle_interrupt_downcall:
1208 check_single_stepping normal, .Ldispatch_downcall 1208 check_single_stepping normal, .Ldispatch_downcall
1209.Ldispatch_downcall: 1209.Ldispatch_downcall:
1210 1210
1211 /* Clear INTCTRL_1 from the set of interrupts we ever enable. */ 1211 /* Clear INTCTRL_K from the set of interrupts we ever enable. */
1212 GET_INTERRUPTS_ENABLED_MASK_PTR(r30) 1212 GET_INTERRUPTS_ENABLED_MASK_PTR(r30)
1213 { 1213 {
1214 addi r30, r30, 4 1214 addi r30, r30, 4
1215 movei r31, INT_MASK(INT_INTCTRL_1) 1215 movei r31, INT_MASK(INT_INTCTRL_K)
1216 } 1216 }
1217 { 1217 {
1218 lw r20, r30 1218 lw r20, r30
@@ -1227,7 +1227,7 @@ handle_interrupt_downcall:
1227 } 1227 }
1228 FEEDBACK_REENTER(handle_interrupt_downcall) 1228 FEEDBACK_REENTER(handle_interrupt_downcall)
1229 1229
1230 /* Allow INTCTRL_1 to be enabled next time we enable interrupts. */ 1230 /* Allow INTCTRL_K to be enabled next time we enable interrupts. */
1231 lw r20, r30 1231 lw r20, r30
1232 or r20, r20, r31 1232 or r20, r20, r31
1233 sw r30, r20 1233 sw r30, r20
@@ -1472,7 +1472,12 @@ handle_ill:
1472 lw r26, r24 1472 lw r26, r24
1473 sw r28, r26 1473 sw r28, r26
1474 1474
1475 /* Clear TIF_SINGLESTEP */ 1475 /*
1476 * Clear TIF_SINGLESTEP to prevent recursion if we execute an ill.
1477 * The normal non-arch flow redundantly clears TIF_SINGLESTEP, but we
1478 * need to clear it here and can't really impose on all other arches.
1479 * So what's another write between friends?
1480 */
1476 GET_THREAD_INFO(r0) 1481 GET_THREAD_INFO(r0)
1477 1482
1478 addi r1, r0, THREAD_INFO_FLAGS_OFFSET 1483 addi r1, r0, THREAD_INFO_FLAGS_OFFSET
@@ -1509,7 +1514,7 @@ handle_ill:
1509/* Various stub interrupt handlers and syscall handlers */ 1514/* Various stub interrupt handlers and syscall handlers */
1510 1515
1511STD_ENTRY_LOCAL(_kernel_double_fault) 1516STD_ENTRY_LOCAL(_kernel_double_fault)
1512 mfspr r1, EX_CONTEXT_1_0 1517 mfspr r1, SPR_EX_CONTEXT_K_0
1513 move r2, lr 1518 move r2, lr
1514 move r3, sp 1519 move r3, sp
1515 move r4, r52 1520 move r4, r52
@@ -1518,34 +1523,29 @@ STD_ENTRY_LOCAL(_kernel_double_fault)
1518 STD_ENDPROC(_kernel_double_fault) 1523 STD_ENDPROC(_kernel_double_fault)
1519 1524
1520STD_ENTRY_LOCAL(bad_intr) 1525STD_ENTRY_LOCAL(bad_intr)
1521 mfspr r2, EX_CONTEXT_1_0 1526 mfspr r2, SPR_EX_CONTEXT_K_0
1522 panic "Unhandled interrupt %#x: PC %#lx" 1527 panic "Unhandled interrupt %#x: PC %#lx"
1523 STD_ENDPROC(bad_intr) 1528 STD_ENDPROC(bad_intr)
1524 1529
1525/* Put address of pt_regs in reg and jump. */ 1530/* Put address of pt_regs in reg and jump. */
1526#define PTREGS_SYSCALL(x, reg) \ 1531#define PTREGS_SYSCALL(x, reg) \
1527 STD_ENTRY(x); \ 1532 STD_ENTRY(_##x); \
1528 { \ 1533 { \
1529 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \ 1534 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
1530 j _##x \ 1535 j x \
1531 }; \ 1536 }; \
1532 STD_ENDPROC(x) 1537 STD_ENDPROC(_##x)
1533 1538
1534PTREGS_SYSCALL(sys_execve, r3) 1539PTREGS_SYSCALL(sys_execve, r3)
1535PTREGS_SYSCALL(sys_sigaltstack, r2) 1540PTREGS_SYSCALL(sys_sigaltstack, r2)
1536PTREGS_SYSCALL(sys_rt_sigreturn, r0) 1541PTREGS_SYSCALL(sys_rt_sigreturn, r0)
1542PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1)
1537 1543
1538/* Save additional callee-saves to pt_regs, put address in reg and jump. */ 1544/* Save additional callee-saves to pt_regs, put address in r4 and jump. */
1539#define PTREGS_SYSCALL_ALL_REGS(x, reg) \ 1545STD_ENTRY(_sys_clone)
1540 STD_ENTRY(x); \ 1546 push_extra_callee_saves r4
1541 push_extra_callee_saves reg; \ 1547 j sys_clone
1542 j _##x; \ 1548 STD_ENDPROC(_sys_clone)
1543 STD_ENDPROC(x)
1544
1545PTREGS_SYSCALL_ALL_REGS(sys_fork, r0)
1546PTREGS_SYSCALL_ALL_REGS(sys_vfork, r0)
1547PTREGS_SYSCALL_ALL_REGS(sys_clone, r4)
1548PTREGS_SYSCALL_ALL_REGS(sys_cmpxchg_badaddr, r1)
1549 1549
1550/* 1550/*
1551 * This entrypoint is taken for the cmpxchg and atomic_update fast 1551 * This entrypoint is taken for the cmpxchg and atomic_update fast
@@ -1558,12 +1558,14 @@ PTREGS_SYSCALL_ALL_REGS(sys_cmpxchg_badaddr, r1)
1558 * to be available to it on entry. It does not modify any callee-save 1558 * to be available to it on entry. It does not modify any callee-save
1559 * registers (including "lr"). It does not check what PL it is being 1559 * registers (including "lr"). It does not check what PL it is being
1560 * called at, so you'd better not call it other than at PL0. 1560 * called at, so you'd better not call it other than at PL0.
1561 * The <atomic.h> wrapper assumes it only clobbers r20-r29, so if
1562 * it ever is necessary to use more registers, be aware.
1561 * 1563 *
1562 * It does not use the stack, but since it might be re-interrupted by 1564 * It does not use the stack, but since it might be re-interrupted by
1563 * a page fault which would assume the stack was valid, it does 1565 * a page fault which would assume the stack was valid, it does
1564 * save/restore the stack pointer and zero it out to make sure it gets reset. 1566 * save/restore the stack pointer and zero it out to make sure it gets reset.
1565 * Since we always keep interrupts disabled, the hypervisor won't 1567 * Since we always keep interrupts disabled, the hypervisor won't
1566 * clobber our EX_CONTEXT_1_x registers, so we don't save/restore them 1568 * clobber our EX_CONTEXT_K_x registers, so we don't save/restore them
1567 * (other than to advance the PC on return). 1569 * (other than to advance the PC on return).
1568 * 1570 *
1569 * We have to manually validate the user vs kernel address range 1571 * We have to manually validate the user vs kernel address range
@@ -1769,7 +1771,7 @@ ENTRY(sys_cmpxchg)
1769 /* Do slow mtspr here so the following "mf" waits less. */ 1771 /* Do slow mtspr here so the following "mf" waits less. */
1770 { 1772 {
1771 move sp, r27 1773 move sp, r27
1772 mtspr EX_CONTEXT_1_0, r28 1774 mtspr SPR_EX_CONTEXT_K_0, r28
1773 } 1775 }
1774 mf 1776 mf
1775 1777
@@ -1788,7 +1790,7 @@ ENTRY(sys_cmpxchg)
1788 } 1790 }
1789 { 1791 {
1790 move sp, r27 1792 move sp, r27
1791 mtspr EX_CONTEXT_1_0, r28 1793 mtspr SPR_EX_CONTEXT_K_0, r28
1792 } 1794 }
1793 iret 1795 iret
1794 1796
@@ -1816,7 +1818,7 @@ ENTRY(sys_cmpxchg)
1816#endif 1818#endif
1817 1819
1818 /* Issue the slow SPR here while the tns result is in flight. */ 1820 /* Issue the slow SPR here while the tns result is in flight. */
1819 mfspr r28, EX_CONTEXT_1_0 1821 mfspr r28, SPR_EX_CONTEXT_K_0
1820 1822
1821 { 1823 {
1822 addi r28, r28, 8 /* return to the instruction after the swint1 */ 1824 addi r28, r28, 8 /* return to the instruction after the swint1 */
@@ -1904,7 +1906,7 @@ ENTRY(sys_cmpxchg)
1904.Lcmpxchg64_mismatch: 1906.Lcmpxchg64_mismatch:
1905 { 1907 {
1906 move sp, r27 1908 move sp, r27
1907 mtspr EX_CONTEXT_1_0, r28 1909 mtspr SPR_EX_CONTEXT_K_0, r28
1908 } 1910 }
1909 mf 1911 mf
1910 { 1912 {
@@ -1985,8 +1987,13 @@ int_unalign:
1985 int_hand INT_PERF_COUNT, PERF_COUNT, \ 1987 int_hand INT_PERF_COUNT, PERF_COUNT, \
1986 op_handle_perf_interrupt, handle_nmi 1988 op_handle_perf_interrupt, handle_nmi
1987 int_hand INT_INTCTRL_3, INTCTRL_3, bad_intr 1989 int_hand INT_INTCTRL_3, INTCTRL_3, bad_intr
1990#if CONFIG_KERNEL_PL == 2
1991 dc_dispatch INT_INTCTRL_2, INTCTRL_2
1992 int_hand INT_INTCTRL_1, INTCTRL_1, bad_intr
1993#else
1988 int_hand INT_INTCTRL_2, INTCTRL_2, bad_intr 1994 int_hand INT_INTCTRL_2, INTCTRL_2, bad_intr
1989 dc_dispatch INT_INTCTRL_1, INTCTRL_1 1995 dc_dispatch INT_INTCTRL_1, INTCTRL_1
1996#endif
1990 int_hand INT_INTCTRL_0, INTCTRL_0, bad_intr 1997 int_hand INT_INTCTRL_0, INTCTRL_0, bad_intr
1991 int_hand INT_MESSAGE_RCV_DWNCL, MESSAGE_RCV_DWNCL, \ 1998 int_hand INT_MESSAGE_RCV_DWNCL, MESSAGE_RCV_DWNCL, \
1992 hv_message_intr, handle_interrupt_downcall 1999 hv_message_intr, handle_interrupt_downcall
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c
index 9a27d563fc30..128805ef8f2c 100644
--- a/arch/tile/kernel/irq.c
+++ b/arch/tile/kernel/irq.c
@@ -26,7 +26,7 @@
26#define IS_HW_CLEARED 1 26#define IS_HW_CLEARED 1
27 27
28/* 28/*
29 * The set of interrupts we enable for raw_local_irq_enable(). 29 * The set of interrupts we enable for arch_local_irq_enable().
30 * This is initialized to have just a single interrupt that the kernel 30 * This is initialized to have just a single interrupt that the kernel
31 * doesn't actually use as a sentinel. During kernel init, 31 * doesn't actually use as a sentinel. During kernel init,
32 * interrupts are added as the kernel gets prepared to support them. 32 * interrupts are added as the kernel gets prepared to support them.
@@ -61,9 +61,9 @@ static DEFINE_SPINLOCK(available_irqs_lock);
61 61
62#if CHIP_HAS_IPI() 62#if CHIP_HAS_IPI()
63/* Use SPRs to manipulate device interrupts. */ 63/* Use SPRs to manipulate device interrupts. */
64#define mask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_SET_1, irq_mask) 64#define mask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_SET_K, irq_mask)
65#define unmask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_RESET_1, irq_mask) 65#define unmask_irqs(irq_mask) __insn_mtspr(SPR_IPI_MASK_RESET_K, irq_mask)
66#define clear_irqs(irq_mask) __insn_mtspr(SPR_IPI_EVENT_RESET_1, irq_mask) 66#define clear_irqs(irq_mask) __insn_mtspr(SPR_IPI_EVENT_RESET_K, irq_mask)
67#else 67#else
68/* Use HV to manipulate device interrupts. */ 68/* Use HV to manipulate device interrupts. */
69#define mask_irqs(irq_mask) hv_disable_intr(irq_mask) 69#define mask_irqs(irq_mask) hv_disable_intr(irq_mask)
@@ -89,16 +89,16 @@ void tile_dev_intr(struct pt_regs *regs, int intnum)
89 * masked by a previous interrupt. Then, mask out the ones 89 * masked by a previous interrupt. Then, mask out the ones
90 * we're going to handle. 90 * we're going to handle.
91 */ 91 */
92 unsigned long masked = __insn_mfspr(SPR_IPI_MASK_1); 92 unsigned long masked = __insn_mfspr(SPR_IPI_MASK_K);
93 original_irqs = __insn_mfspr(SPR_IPI_EVENT_1) & ~masked; 93 original_irqs = __insn_mfspr(SPR_IPI_EVENT_K) & ~masked;
94 __insn_mtspr(SPR_IPI_MASK_SET_1, original_irqs); 94 __insn_mtspr(SPR_IPI_MASK_SET_K, original_irqs);
95#else 95#else
96 /* 96 /*
97 * Hypervisor performs the equivalent of the Gx code above and 97 * Hypervisor performs the equivalent of the Gx code above and
98 * then puts the pending interrupt mask into a system save reg 98 * then puts the pending interrupt mask into a system save reg
99 * for us to find. 99 * for us to find.
100 */ 100 */
101 original_irqs = __insn_mfspr(SPR_SYSTEM_SAVE_1_3); 101 original_irqs = __insn_mfspr(SPR_SYSTEM_SAVE_K_3);
102#endif 102#endif
103 remaining_irqs = original_irqs; 103 remaining_irqs = original_irqs;
104 104
@@ -225,7 +225,7 @@ void __cpuinit setup_irq_regs(void)
225 /* Enable interrupt delivery. */ 225 /* Enable interrupt delivery. */
226 unmask_irqs(~0UL); 226 unmask_irqs(~0UL);
227#if CHIP_HAS_IPI() 227#if CHIP_HAS_IPI()
228 raw_local_irq_unmask(INT_IPI_1); 228 arch_local_irq_unmask(INT_IPI_K);
229#endif 229#endif
230} 230}
231 231
diff --git a/arch/tile/kernel/machine_kexec.c b/arch/tile/kernel/machine_kexec.c
index ba7a265d6179..0d8b9e933487 100644
--- a/arch/tile/kernel/machine_kexec.c
+++ b/arch/tile/kernel/machine_kexec.c
@@ -182,13 +182,13 @@ static void kexec_find_and_set_command_line(struct kimage *image)
182 182
183 if ((entry & IND_SOURCE)) { 183 if ((entry & IND_SOURCE)) {
184 void *va = 184 void *va =
185 kmap_atomic_pfn(entry >> PAGE_SHIFT, KM_USER0); 185 kmap_atomic_pfn(entry >> PAGE_SHIFT);
186 r = kexec_bn2cl(va); 186 r = kexec_bn2cl(va);
187 if (r) { 187 if (r) {
188 command_line = r; 188 command_line = r;
189 break; 189 break;
190 } 190 }
191 kunmap_atomic(va, KM_USER0); 191 kunmap_atomic(va);
192 } 192 }
193 } 193 }
194 194
@@ -198,7 +198,7 @@ static void kexec_find_and_set_command_line(struct kimage *image)
198 198
199 hverr = hv_set_command_line( 199 hverr = hv_set_command_line(
200 (HV_VirtAddr) command_line, strlen(command_line)); 200 (HV_VirtAddr) command_line, strlen(command_line));
201 kunmap_atomic(command_line, KM_USER0); 201 kunmap_atomic(command_line);
202 } else { 202 } else {
203 pr_info("%s: no command line found; making empty\n", 203 pr_info("%s: no command line found; making empty\n",
204 __func__); 204 __func__);
diff --git a/arch/tile/kernel/messaging.c b/arch/tile/kernel/messaging.c
index 6d23ed271d10..0858ee6b520f 100644
--- a/arch/tile/kernel/messaging.c
+++ b/arch/tile/kernel/messaging.c
@@ -34,7 +34,7 @@ void __cpuinit init_messaging(void)
34 panic("hv_register_message_state: error %d", rc); 34 panic("hv_register_message_state: error %d", rc);
35 35
36 /* Make sure downcall interrupts will be enabled. */ 36 /* Make sure downcall interrupts will be enabled. */
37 raw_local_irq_unmask(INT_INTCTRL_1); 37 arch_local_irq_unmask(INT_INTCTRL_K);
38} 38}
39 39
40void hv_message_intr(struct pt_regs *regs, int intnum) 40void hv_message_intr(struct pt_regs *regs, int intnum)
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 84c29111756c..8430f45daea6 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -214,9 +214,10 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
214 /* 214 /*
215 * Copy the callee-saved registers from the passed pt_regs struct 215 * Copy the callee-saved registers from the passed pt_regs struct
216 * into the context-switch callee-saved registers area. 216 * into the context-switch callee-saved registers area.
217 * We have to restore the callee-saved registers since we may 217 * This way when we start the interrupt-return sequence, the
218 * be cloning a userspace task with userspace register state, 218 * callee-save registers will be correctly in registers, which
219 * and we won't be unwinding the same kernel frames to restore them. 219 * is how we assume the compiler leaves them as we start doing
220 * the normal return-from-interrupt path after calling C code.
220 * Zero out the C ABI save area to mark the top of the stack. 221 * Zero out the C ABI save area to mark the top of the stack.
221 */ 222 */
222 ksp = (unsigned long) childregs; 223 ksp = (unsigned long) childregs;
@@ -304,15 +305,25 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
304/* Allow user processes to access the DMA SPRs */ 305/* Allow user processes to access the DMA SPRs */
305void grant_dma_mpls(void) 306void grant_dma_mpls(void)
306{ 307{
308#if CONFIG_KERNEL_PL == 2
309 __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
310 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
311#else
307 __insn_mtspr(SPR_MPL_DMA_CPL_SET_0, 1); 312 __insn_mtspr(SPR_MPL_DMA_CPL_SET_0, 1);
308 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_0, 1); 313 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_0, 1);
314#endif
309} 315}
310 316
311/* Forbid user processes from accessing the DMA SPRs */ 317/* Forbid user processes from accessing the DMA SPRs */
312void restrict_dma_mpls(void) 318void restrict_dma_mpls(void)
313{ 319{
320#if CONFIG_KERNEL_PL == 2
321 __insn_mtspr(SPR_MPL_DMA_CPL_SET_2, 1);
322 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_2, 1);
323#else
314 __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1); 324 __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
315 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1); 325 __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
326#endif
316} 327}
317 328
318/* Pause the DMA engine, then save off its state registers. */ 329/* Pause the DMA engine, then save off its state registers. */
@@ -523,19 +534,14 @@ struct task_struct *__sched _switch_to(struct task_struct *prev,
523 * Switch kernel SP, PC, and callee-saved registers. 534 * Switch kernel SP, PC, and callee-saved registers.
524 * In the context of the new task, return the old task pointer 535 * In the context of the new task, return the old task pointer
525 * (i.e. the task that actually called __switch_to). 536 * (i.e. the task that actually called __switch_to).
526 * Pass the value to use for SYSTEM_SAVE_1_0 when we reset our sp. 537 * Pass the value to use for SYSTEM_SAVE_K_0 when we reset our sp.
527 */ 538 */
528 return __switch_to(prev, next, next_current_ksp0(next)); 539 return __switch_to(prev, next, next_current_ksp0(next));
529} 540}
530 541
531long _sys_fork(struct pt_regs *regs) 542SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
532{ 543 void __user *, parent_tidptr, void __user *, child_tidptr,
533 return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL); 544 struct pt_regs *, regs)
534}
535
536long _sys_clone(unsigned long clone_flags, unsigned long newsp,
537 void __user *parent_tidptr, void __user *child_tidptr,
538 struct pt_regs *regs)
539{ 545{
540 if (!newsp) 546 if (!newsp)
541 newsp = regs->sp; 547 newsp = regs->sp;
@@ -543,18 +549,13 @@ long _sys_clone(unsigned long clone_flags, unsigned long newsp,
543 parent_tidptr, child_tidptr); 549 parent_tidptr, child_tidptr);
544} 550}
545 551
546long _sys_vfork(struct pt_regs *regs)
547{
548 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp,
549 regs, 0, NULL, NULL);
550}
551
552/* 552/*
553 * sys_execve() executes a new program. 553 * sys_execve() executes a new program.
554 */ 554 */
555long _sys_execve(const char __user *path, 555SYSCALL_DEFINE4(execve, const char __user *, path,
556 const char __user *const __user *argv, 556 const char __user *const __user *, argv,
557 const char __user *const __user *envp, struct pt_regs *regs) 557 const char __user *const __user *, envp,
558 struct pt_regs *, regs)
558{ 559{
559 long error; 560 long error;
560 char *filename; 561 char *filename;
@@ -570,9 +571,10 @@ out:
570} 571}
571 572
572#ifdef CONFIG_COMPAT 573#ifdef CONFIG_COMPAT
573long _compat_sys_execve(const char __user *path, 574long compat_sys_execve(const char __user *path,
574 const compat_uptr_t __user *argv, 575 const compat_uptr_t __user *argv,
575 const compat_uptr_t __user *envp, struct pt_regs *regs) 576 const compat_uptr_t __user *envp,
577 struct pt_regs *regs)
576{ 578{
577 long error; 579 long error;
578 char *filename; 580 char *filename;
diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index 7161bd03d2fd..e92e40527d6d 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -32,25 +32,6 @@ void user_disable_single_step(struct task_struct *child)
32} 32}
33 33
34/* 34/*
35 * This routine will put a word on the process's privileged stack.
36 */
37static void putreg(struct task_struct *task,
38 unsigned long addr, unsigned long value)
39{
40 unsigned int regno = addr / sizeof(unsigned long);
41 struct pt_regs *childregs = task_pt_regs(task);
42 childregs->regs[regno] = value;
43 childregs->flags |= PT_FLAGS_RESTORE_REGS;
44}
45
46static unsigned long getreg(struct task_struct *task, unsigned long addr)
47{
48 unsigned int regno = addr / sizeof(unsigned long);
49 struct pt_regs *childregs = task_pt_regs(task);
50 return childregs->regs[regno];
51}
52
53/*
54 * Called by kernel/ptrace.c when detaching.. 35 * Called by kernel/ptrace.c when detaching..
55 */ 36 */
56void ptrace_disable(struct task_struct *child) 37void ptrace_disable(struct task_struct *child)
@@ -64,61 +45,80 @@ void ptrace_disable(struct task_struct *child)
64 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 45 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
65} 46}
66 47
67long arch_ptrace(struct task_struct *child, long request, long addr, long data) 48long arch_ptrace(struct task_struct *child, long request,
49 unsigned long addr, unsigned long data)
68{ 50{
69 unsigned long __user *datap; 51 unsigned long __user *datap = (long __user __force *)data;
70 unsigned long tmp; 52 unsigned long tmp;
71 int i;
72 long ret = -EIO; 53 long ret = -EIO;
73 54 char *childreg;
74#ifdef CONFIG_COMPAT 55 struct pt_regs copyregs;
75 if (task_thread_info(current)->status & TS_COMPAT) 56 int ex1_offset;
76 data = (u32)data;
77 if (task_thread_info(child)->status & TS_COMPAT)
78 addr = (u32)addr;
79#endif
80 datap = (unsigned long __user __force *)data;
81 57
82 switch (request) { 58 switch (request) {
83 59
84 case PTRACE_PEEKUSR: /* Read register from pt_regs. */ 60 case PTRACE_PEEKUSR: /* Read register from pt_regs. */
85 if (addr & (sizeof(data)-1)) 61 if (addr >= PTREGS_SIZE)
86 break;
87 if (addr < 0 || addr >= PTREGS_SIZE)
88 break; 62 break;
89 tmp = getreg(child, addr); /* Read register */ 63 childreg = (char *)task_pt_regs(child) + addr;
90 ret = put_user(tmp, datap); 64#ifdef CONFIG_COMPAT
65 if (is_compat_task()) {
66 if (addr & (sizeof(compat_long_t)-1))
67 break;
68 ret = put_user(*(compat_long_t *)childreg,
69 (compat_long_t __user *)datap);
70 } else
71#endif
72 {
73 if (addr & (sizeof(long)-1))
74 break;
75 ret = put_user(*(long *)childreg, datap);
76 }
91 break; 77 break;
92 78
93 case PTRACE_POKEUSR: /* Write register in pt_regs. */ 79 case PTRACE_POKEUSR: /* Write register in pt_regs. */
94 if (addr & (sizeof(data)-1)) 80 if (addr >= PTREGS_SIZE)
95 break; 81 break;
96 if (addr < 0 || addr >= PTREGS_SIZE) 82 childreg = (char *)task_pt_regs(child) + addr;
97 break; 83
98 putreg(child, addr, data); /* Write register */ 84 /* Guard against overwrites of the privilege level. */
85 ex1_offset = PTREGS_OFFSET_EX1;
86#if defined(CONFIG_COMPAT) && defined(__BIG_ENDIAN)
87 if (is_compat_task()) /* point at low word */
88 ex1_offset += sizeof(compat_long_t);
89#endif
90 if (addr == ex1_offset)
91 data = PL_ICS_EX1(USER_PL, EX1_ICS(data));
92
93#ifdef CONFIG_COMPAT
94 if (is_compat_task()) {
95 if (addr & (sizeof(compat_long_t)-1))
96 break;
97 *(compat_long_t *)childreg = data;
98 } else
99#endif
100 {
101 if (addr & (sizeof(long)-1))
102 break;
103 *(long *)childreg = data;
104 }
99 ret = 0; 105 ret = 0;
100 break; 106 break;
101 107
102 case PTRACE_GETREGS: /* Get all registers from the child. */ 108 case PTRACE_GETREGS: /* Get all registers from the child. */
103 if (!access_ok(VERIFY_WRITE, datap, PTREGS_SIZE)) 109 if (copy_to_user(datap, task_pt_regs(child),
104 break; 110 sizeof(struct pt_regs)) == 0) {
105 for (i = 0; i < PTREGS_SIZE; i += sizeof(long)) { 111 ret = 0;
106 ret = __put_user(getreg(child, i), datap);
107 if (ret != 0)
108 break;
109 datap++;
110 } 112 }
111 break; 113 break;
112 114
113 case PTRACE_SETREGS: /* Set all registers in the child. */ 115 case PTRACE_SETREGS: /* Set all registers in the child. */
114 if (!access_ok(VERIFY_READ, datap, PTREGS_SIZE)) 116 if (copy_from_user(&copyregs, datap,
115 break; 117 sizeof(struct pt_regs)) == 0) {
116 for (i = 0; i < PTREGS_SIZE; i += sizeof(long)) { 118 copyregs.ex1 =
117 ret = __get_user(tmp, datap); 119 PL_ICS_EX1(USER_PL, EX1_ICS(copyregs.ex1));
118 if (ret != 0) 120 *task_pt_regs(child) = copyregs;
119 break; 121 ret = 0;
120 putreg(child, i, tmp);
121 datap++;
122 } 122 }
123 break; 123 break;
124 124
diff --git a/arch/tile/kernel/reboot.c b/arch/tile/kernel/reboot.c
index acd86d20beba..baa3d905fee2 100644
--- a/arch/tile/kernel/reboot.c
+++ b/arch/tile/kernel/reboot.c
@@ -27,7 +27,7 @@
27void machine_halt(void) 27void machine_halt(void)
28{ 28{
29 warn_early_printk(); 29 warn_early_printk();
30 raw_local_irq_disable_all(); 30 arch_local_irq_disable_all();
31 smp_send_stop(); 31 smp_send_stop();
32 hv_halt(); 32 hv_halt();
33} 33}
@@ -35,14 +35,14 @@ void machine_halt(void)
35void machine_power_off(void) 35void machine_power_off(void)
36{ 36{
37 warn_early_printk(); 37 warn_early_printk();
38 raw_local_irq_disable_all(); 38 arch_local_irq_disable_all();
39 smp_send_stop(); 39 smp_send_stop();
40 hv_power_off(); 40 hv_power_off();
41} 41}
42 42
43void machine_restart(char *cmd) 43void machine_restart(char *cmd)
44{ 44{
45 raw_local_irq_disable_all(); 45 arch_local_irq_disable_all();
46 smp_send_stop(); 46 smp_send_stop();
47 hv_restart((HV_VirtAddr) "vmlinux", (HV_VirtAddr) cmd); 47 hv_restart((HV_VirtAddr) "vmlinux", (HV_VirtAddr) cmd);
48} 48}
diff --git a/arch/tile/kernel/regs_32.S b/arch/tile/kernel/regs_32.S
index e88d6e122783..caa13101c264 100644
--- a/arch/tile/kernel/regs_32.S
+++ b/arch/tile/kernel/regs_32.S
@@ -85,7 +85,7 @@ STD_ENTRY_SECTION(__switch_to, .sched.text)
85 { 85 {
86 /* Update sp and ksp0 simultaneously to avoid backtracer warnings. */ 86 /* Update sp and ksp0 simultaneously to avoid backtracer warnings. */
87 move sp, r13 87 move sp, r13
88 mtspr SYSTEM_SAVE_1_0, r2 88 mtspr SPR_SYSTEM_SAVE_K_0, r2
89 } 89 }
90 FOR_EACH_CALLEE_SAVED_REG(LOAD_REG) 90 FOR_EACH_CALLEE_SAVED_REG(LOAD_REG)
91.L__switch_to_pc: 91.L__switch_to_pc:
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index e7d54c73d5c1..fb0b3cbeae14 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -30,8 +30,6 @@
30#include <linux/timex.h> 30#include <linux/timex.h>
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/sections.h> 32#include <asm/sections.h>
33#include <asm/sections.h>
34#include <asm/cacheflush.h>
35#include <asm/cacheflush.h> 33#include <asm/cacheflush.h>
36#include <asm/pgalloc.h> 34#include <asm/pgalloc.h>
37#include <asm/mmu_context.h> 35#include <asm/mmu_context.h>
@@ -187,11 +185,11 @@ early_param("vmalloc", parse_vmalloc);
187 185
188#ifdef CONFIG_HIGHMEM 186#ifdef CONFIG_HIGHMEM
189/* 187/*
190 * Determine for each controller where its lowmem is mapped and how 188 * Determine for each controller where its lowmem is mapped and how much of
191 * much of it is mapped there. On controller zero, the first few 189 * it is mapped there. On controller zero, the first few megabytes are
192 * megabytes are mapped at 0xfd000000 as code, so in principle we 190 * already mapped in as code at MEM_SV_INTRPT, so in principle we could
193 * could start our data mappings higher up, but for now we don't 191 * start our data mappings higher up, but for now we don't bother, to avoid
194 * bother, to avoid additional confusion. 192 * additional confusion.
195 * 193 *
196 * One question is whether, on systems with more than 768 Mb and 194 * One question is whether, on systems with more than 768 Mb and
197 * controllers of different sizes, to map in a proportionate amount of 195 * controllers of different sizes, to map in a proportionate amount of
@@ -311,7 +309,7 @@ static void __init setup_memory(void)
311#endif 309#endif
312 310
313 /* We are using a char to hold the cpu_2_node[] mapping */ 311 /* We are using a char to hold the cpu_2_node[] mapping */
314 BUG_ON(MAX_NUMNODES > 127); 312 BUILD_BUG_ON(MAX_NUMNODES > 127);
315 313
316 /* Discover the ranges of memory available to us */ 314 /* Discover the ranges of memory available to us */
317 for (i = 0; ; ++i) { 315 for (i = 0; ; ++i) {
@@ -870,11 +868,14 @@ void __cpuinit setup_cpu(int boot)
870 868
871 /* Allow asynchronous TLB interrupts. */ 869 /* Allow asynchronous TLB interrupts. */
872#if CHIP_HAS_TILE_DMA() 870#if CHIP_HAS_TILE_DMA()
873 raw_local_irq_unmask(INT_DMATLB_MISS); 871 arch_local_irq_unmask(INT_DMATLB_MISS);
874 raw_local_irq_unmask(INT_DMATLB_ACCESS); 872 arch_local_irq_unmask(INT_DMATLB_ACCESS);
875#endif 873#endif
876#if CHIP_HAS_SN_PROC() 874#if CHIP_HAS_SN_PROC()
877 raw_local_irq_unmask(INT_SNITLB_MISS); 875 arch_local_irq_unmask(INT_SNITLB_MISS);
876#endif
877#ifdef __tilegx__
878 arch_local_irq_unmask(INT_SINGLE_STEP_K);
878#endif 879#endif
879 880
880 /* 881 /*
@@ -893,11 +894,12 @@ void __cpuinit setup_cpu(int boot)
893#endif 894#endif
894 895
895 /* 896 /*
896 * Set the MPL for interrupt control 0 to user level. 897 * Set the MPL for interrupt control 0 & 1 to the corresponding
897 * This includes access to the SYSTEM_SAVE and EX_CONTEXT SPRs, 898 * values. This includes access to the SYSTEM_SAVE and EX_CONTEXT
898 * as well as the PL 0 interrupt mask. 899 * SPRs, as well as the interrupt mask.
899 */ 900 */
900 __insn_mtspr(SPR_MPL_INTCTRL_0_SET_0, 1); 901 __insn_mtspr(SPR_MPL_INTCTRL_0_SET_0, 1);
902 __insn_mtspr(SPR_MPL_INTCTRL_1_SET_1, 1);
901 903
902 /* Initialize IRQ support for this cpu. */ 904 /* Initialize IRQ support for this cpu. */
903 setup_irq_regs(); 905 setup_irq_regs();
@@ -1033,7 +1035,7 @@ static void __init validate_va(void)
1033 * In addition, make sure we CAN'T use the end of memory, since 1035 * In addition, make sure we CAN'T use the end of memory, since
1034 * we use the last chunk of each pgd for the pgd_list. 1036 * we use the last chunk of each pgd for the pgd_list.
1035 */ 1037 */
1036 int i, fc_fd_ok = 0; 1038 int i, user_kernel_ok = 0;
1037 unsigned long max_va = 0; 1039 unsigned long max_va = 0;
1038 unsigned long list_va = 1040 unsigned long list_va =
1039 ((PGD_LIST_OFFSET / sizeof(pgd_t)) << PGDIR_SHIFT); 1041 ((PGD_LIST_OFFSET / sizeof(pgd_t)) << PGDIR_SHIFT);
@@ -1044,13 +1046,13 @@ static void __init validate_va(void)
1044 break; 1046 break;
1045 if (range.start <= MEM_USER_INTRPT && 1047 if (range.start <= MEM_USER_INTRPT &&
1046 range.start + range.size >= MEM_HV_INTRPT) 1048 range.start + range.size >= MEM_HV_INTRPT)
1047 fc_fd_ok = 1; 1049 user_kernel_ok = 1;
1048 if (range.start == 0) 1050 if (range.start == 0)
1049 max_va = range.size; 1051 max_va = range.size;
1050 BUG_ON(range.start + range.size > list_va); 1052 BUG_ON(range.start + range.size > list_va);
1051 } 1053 }
1052 if (!fc_fd_ok) 1054 if (!user_kernel_ok)
1053 early_panic("Hypervisor not configured for VAs 0xfc/0xfd\n"); 1055 early_panic("Hypervisor not configured for user/kernel VAs\n");
1054 if (max_va == 0) 1056 if (max_va == 0)
1055 early_panic("Hypervisor not configured for low VAs\n"); 1057 early_panic("Hypervisor not configured for low VAs\n");
1056 if (max_va < KERNEL_HIGH_VADDR) 1058 if (max_va < KERNEL_HIGH_VADDR)
@@ -1334,6 +1336,10 @@ static void __init pcpu_fc_populate_pte(unsigned long addr)
1334 pte_t *pte; 1336 pte_t *pte;
1335 1337
1336 BUG_ON(pgd_addr_invalid(addr)); 1338 BUG_ON(pgd_addr_invalid(addr));
1339 if (addr < VMALLOC_START || addr >= VMALLOC_END)
1340 panic("PCPU addr %#lx outside vmalloc range %#lx..%#lx;"
1341 " try increasing CONFIG_VMALLOC_RESERVE\n",
1342 addr, VMALLOC_START, VMALLOC_END);
1337 1343
1338 pgd = swapper_pg_dir + pgd_index(addr); 1344 pgd = swapper_pg_dir + pgd_index(addr);
1339 pud = pud_offset(pgd, addr); 1345 pud = pud_offset(pgd, addr);
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index ce183aa1492c..687719d4abd1 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -41,8 +41,8 @@
41#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 41#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
42 42
43 43
44long _sys_sigaltstack(const stack_t __user *uss, 44SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss,
45 stack_t __user *uoss, struct pt_regs *regs) 45 stack_t __user *, uoss, struct pt_regs *, regs)
46{ 46{
47 return do_sigaltstack(uss, uoss, regs->sp); 47 return do_sigaltstack(uss, uoss, regs->sp);
48} 48}
@@ -71,6 +71,9 @@ int restore_sigcontext(struct pt_regs *regs,
71 for (i = 0; i < sizeof(struct pt_regs)/sizeof(long); ++i) 71 for (i = 0; i < sizeof(struct pt_regs)/sizeof(long); ++i)
72 err |= __get_user(regs->regs[i], &sc->gregs[i]); 72 err |= __get_user(regs->regs[i], &sc->gregs[i]);
73 73
74 /* Ensure that the PL is always set to USER_PL. */
75 regs->ex1 = PL_ICS_EX1(USER_PL, EX1_ICS(regs->ex1));
76
74 regs->faultnum = INT_SWINT_1_SIGRETURN; 77 regs->faultnum = INT_SWINT_1_SIGRETURN;
75 78
76 err |= __get_user(*pr0, &sc->gregs[0]); 79 err |= __get_user(*pr0, &sc->gregs[0]);
@@ -78,7 +81,7 @@ int restore_sigcontext(struct pt_regs *regs,
78} 81}
79 82
80/* sigreturn() returns long since it restores r0 in the interrupted code. */ 83/* sigreturn() returns long since it restores r0 in the interrupted code. */
81long _sys_rt_sigreturn(struct pt_regs *regs) 84SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)
82{ 85{
83 struct rt_sigframe __user *frame = 86 struct rt_sigframe __user *frame =
84 (struct rt_sigframe __user *)(regs->sp); 87 (struct rt_sigframe __user *)(regs->sp);
@@ -330,7 +333,7 @@ void do_signal(struct pt_regs *regs)
330 current_thread_info()->status &= ~TS_RESTORE_SIGMASK; 333 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
331 } 334 }
332 335
333 return; 336 goto done;
334 } 337 }
335 338
336 /* Did we come from a system call? */ 339 /* Did we come from a system call? */
@@ -358,4 +361,8 @@ void do_signal(struct pt_regs *regs)
358 current_thread_info()->status &= ~TS_RESTORE_SIGMASK; 361 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
359 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 362 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
360 } 363 }
364
365done:
366 /* Avoid double syscall restart if there are nested signals. */
367 regs->faultnum = INT_SWINT_1_SIGRETURN;
361} 368}
diff --git a/arch/tile/kernel/single_step.c b/arch/tile/kernel/single_step.c
index 5ec4b9c651f2..1eb3b39e36c7 100644
--- a/arch/tile/kernel/single_step.c
+++ b/arch/tile/kernel/single_step.c
@@ -15,7 +15,7 @@
15 * Derived from iLib's single-stepping code. 15 * Derived from iLib's single-stepping code.
16 */ 16 */
17 17
18#ifndef __tilegx__ /* No support for single-step yet. */ 18#ifndef __tilegx__ /* Hardware support for single step unavailable. */
19 19
20/* These functions are only used on the TILE platform */ 20/* These functions are only used on the TILE platform */
21#include <linux/slab.h> 21#include <linux/slab.h>
@@ -660,4 +660,75 @@ void single_step_once(struct pt_regs *regs)
660 regs->pc += 8; 660 regs->pc += 8;
661} 661}
662 662
663#else
664#include <linux/smp.h>
665#include <linux/ptrace.h>
666#include <arch/spr_def.h>
667
668static DEFINE_PER_CPU(unsigned long, ss_saved_pc);
669
670
671/*
672 * Called directly on the occasion of an interrupt.
673 *
674 * If the process doesn't have single step set, then we use this as an
675 * opportunity to turn single step off.
676 *
677 * It has been mentioned that we could conditionally turn off single stepping
678 * on each entry into the kernel and rely on single_step_once to turn it
679 * on for the processes that matter (as we already do), but this
680 * implementation is somewhat more efficient in that we muck with registers
681 * once on a bum interrupt rather than on every entry into the kernel.
682 *
683 * If SINGLE_STEP_CONTROL_K has CANCELED set, then an interrupt occurred,
684 * so we have to run through this process again before we can say that an
685 * instruction has executed.
686 *
687 * swint will set CANCELED, but it's a legitimate instruction. Fortunately
688 * it changes the PC. If it hasn't changed, then we know that the interrupt
689 * wasn't generated by swint and we'll need to run this process again before
690 * we can say an instruction has executed.
691 *
692 * If either CANCELED == 0 or the PC's changed, we send out SIGTRAPs and get
693 * on with our lives.
694 */
695
696void gx_singlestep_handle(struct pt_regs *regs, int fault_num)
697{
698 unsigned long *ss_pc = &__get_cpu_var(ss_saved_pc);
699 struct thread_info *info = (void *)current_thread_info();
700 int is_single_step = test_ti_thread_flag(info, TIF_SINGLESTEP);
701 unsigned long control = __insn_mfspr(SPR_SINGLE_STEP_CONTROL_K);
702
703 if (is_single_step == 0) {
704 __insn_mtspr(SPR_SINGLE_STEP_EN_K_K, 0);
705
706 } else if ((*ss_pc != regs->pc) ||
707 (!(control & SPR_SINGLE_STEP_CONTROL_1__CANCELED_MASK))) {
708
709 ptrace_notify(SIGTRAP);
710 control |= SPR_SINGLE_STEP_CONTROL_1__CANCELED_MASK;
711 control |= SPR_SINGLE_STEP_CONTROL_1__INHIBIT_MASK;
712 __insn_mtspr(SPR_SINGLE_STEP_CONTROL_K, control);
713 }
714}
715
716
717/*
718 * Called from need_singlestep. Set up the control registers and the enable
719 * register, then return back.
720 */
721
722void single_step_once(struct pt_regs *regs)
723{
724 unsigned long *ss_pc = &__get_cpu_var(ss_saved_pc);
725 unsigned long control = __insn_mfspr(SPR_SINGLE_STEP_CONTROL_K);
726
727 *ss_pc = regs->pc;
728 control |= SPR_SINGLE_STEP_CONTROL_1__CANCELED_MASK;
729 control |= SPR_SINGLE_STEP_CONTROL_1__INHIBIT_MASK;
730 __insn_mtspr(SPR_SINGLE_STEP_CONTROL_K, control);
731 __insn_mtspr(SPR_SINGLE_STEP_EN_K_K, 1 << USER_PL);
732}
733
663#endif /* !__tilegx__ */ 734#endif /* !__tilegx__ */
diff --git a/arch/tile/kernel/smp.c b/arch/tile/kernel/smp.c
index 1cb5ec79de04..9575b37a8b75 100644
--- a/arch/tile/kernel/smp.c
+++ b/arch/tile/kernel/smp.c
@@ -115,7 +115,7 @@ static void smp_start_cpu_interrupt(void)
115static void smp_stop_cpu_interrupt(void) 115static void smp_stop_cpu_interrupt(void)
116{ 116{
117 set_cpu_online(smp_processor_id(), 0); 117 set_cpu_online(smp_processor_id(), 0);
118 raw_local_irq_disable_all(); 118 arch_local_irq_disable_all();
119 for (;;) 119 for (;;)
120 asm("nap"); 120 asm("nap");
121} 121}
@@ -212,7 +212,7 @@ void __init ipi_init(void)
212 212
213 tile.x = cpu_x(cpu); 213 tile.x = cpu_x(cpu);
214 tile.y = cpu_y(cpu); 214 tile.y = cpu_y(cpu);
215 if (hv_get_ipi_pte(tile, 1, &pte) != 0) 215 if (hv_get_ipi_pte(tile, KERNEL_PL, &pte) != 0)
216 panic("Failed to initialize IPI for cpu %d\n", cpu); 216 panic("Failed to initialize IPI for cpu %d\n", cpu);
217 217
218 offset = hv_pte_get_pfn(pte) << PAGE_SHIFT; 218 offset = hv_pte_get_pfn(pte) << PAGE_SHIFT;
diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index ea2e0ce28380..0d54106be3d6 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -30,6 +30,10 @@
30#include <arch/abi.h> 30#include <arch/abi.h>
31#include <arch/interrupts.h> 31#include <arch/interrupts.h>
32 32
33#define KBT_ONGOING 0 /* Backtrace still ongoing */
34#define KBT_DONE 1 /* Backtrace cleanly completed */
35#define KBT_RUNNING 2 /* Can't run backtrace on a running task */
36#define KBT_LOOP 3 /* Backtrace entered a loop */
33 37
34/* Is address on the specified kernel stack? */ 38/* Is address on the specified kernel stack? */
35static int in_kernel_stack(struct KBacktraceIterator *kbt, VirtualAddress sp) 39static int in_kernel_stack(struct KBacktraceIterator *kbt, VirtualAddress sp)
@@ -207,11 +211,11 @@ static int KBacktraceIterator_next_item_inclusive(
207 for (;;) { 211 for (;;) {
208 do { 212 do {
209 if (!KBacktraceIterator_is_sigreturn(kbt)) 213 if (!KBacktraceIterator_is_sigreturn(kbt))
210 return 1; 214 return KBT_ONGOING;
211 } while (backtrace_next(&kbt->it)); 215 } while (backtrace_next(&kbt->it));
212 216
213 if (!KBacktraceIterator_restart(kbt)) 217 if (!KBacktraceIterator_restart(kbt))
214 return 0; 218 return KBT_DONE;
215 } 219 }
216} 220}
217 221
@@ -264,7 +268,7 @@ void KBacktraceIterator_init(struct KBacktraceIterator *kbt,
264 kbt->pgtable = NULL; 268 kbt->pgtable = NULL;
265 kbt->verbose = 0; /* override in caller if desired */ 269 kbt->verbose = 0; /* override in caller if desired */
266 kbt->profile = 0; /* override in caller if desired */ 270 kbt->profile = 0; /* override in caller if desired */
267 kbt->end = 0; 271 kbt->end = KBT_ONGOING;
268 kbt->new_context = 0; 272 kbt->new_context = 0;
269 if (is_current) { 273 if (is_current) {
270 HV_PhysAddr pgdir_pa = hv_inquire_context().page_table; 274 HV_PhysAddr pgdir_pa = hv_inquire_context().page_table;
@@ -290,7 +294,7 @@ void KBacktraceIterator_init(struct KBacktraceIterator *kbt,
290 if (regs == NULL) { 294 if (regs == NULL) {
291 if (is_current || t->state == TASK_RUNNING) { 295 if (is_current || t->state == TASK_RUNNING) {
292 /* Can't do this; we need registers */ 296 /* Can't do this; we need registers */
293 kbt->end = 1; 297 kbt->end = KBT_RUNNING;
294 return; 298 return;
295 } 299 }
296 pc = get_switch_to_pc(); 300 pc = get_switch_to_pc();
@@ -305,26 +309,29 @@ void KBacktraceIterator_init(struct KBacktraceIterator *kbt,
305 } 309 }
306 310
307 backtrace_init(&kbt->it, read_memory_func, kbt, pc, lr, sp, r52); 311 backtrace_init(&kbt->it, read_memory_func, kbt, pc, lr, sp, r52);
308 kbt->end = !KBacktraceIterator_next_item_inclusive(kbt); 312 kbt->end = KBacktraceIterator_next_item_inclusive(kbt);
309} 313}
310EXPORT_SYMBOL(KBacktraceIterator_init); 314EXPORT_SYMBOL(KBacktraceIterator_init);
311 315
312int KBacktraceIterator_end(struct KBacktraceIterator *kbt) 316int KBacktraceIterator_end(struct KBacktraceIterator *kbt)
313{ 317{
314 return kbt->end; 318 return kbt->end != KBT_ONGOING;
315} 319}
316EXPORT_SYMBOL(KBacktraceIterator_end); 320EXPORT_SYMBOL(KBacktraceIterator_end);
317 321
318void KBacktraceIterator_next(struct KBacktraceIterator *kbt) 322void KBacktraceIterator_next(struct KBacktraceIterator *kbt)
319{ 323{
324 VirtualAddress old_pc = kbt->it.pc, old_sp = kbt->it.sp;
320 kbt->new_context = 0; 325 kbt->new_context = 0;
321 if (!backtrace_next(&kbt->it) && 326 if (!backtrace_next(&kbt->it) && !KBacktraceIterator_restart(kbt)) {
322 !KBacktraceIterator_restart(kbt)) { 327 kbt->end = KBT_DONE;
323 kbt->end = 1; 328 return;
324 return; 329 }
325 } 330 kbt->end = KBacktraceIterator_next_item_inclusive(kbt);
326 331 if (old_pc == kbt->it.pc && old_sp == kbt->it.sp) {
327 kbt->end = !KBacktraceIterator_next_item_inclusive(kbt); 332 /* Trapped in a loop; give up. */
333 kbt->end = KBT_LOOP;
334 }
328} 335}
329EXPORT_SYMBOL(KBacktraceIterator_next); 336EXPORT_SYMBOL(KBacktraceIterator_next);
330 337
@@ -387,6 +394,8 @@ void tile_show_stack(struct KBacktraceIterator *kbt, int headers)
387 break; 394 break;
388 } 395 }
389 } 396 }
397 if (kbt->end == KBT_LOOP)
398 pr_err("Stack dump stopped; next frame identical to this one\n");
390 if (headers) 399 if (headers)
391 pr_err("Stack dump complete\n"); 400 pr_err("Stack dump complete\n");
392} 401}
diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c
index f0f87eab8c39..7e764669a022 100644
--- a/arch/tile/kernel/sys.c
+++ b/arch/tile/kernel/sys.c
@@ -110,6 +110,15 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
110#define sys_sync_file_range sys_sync_file_range2 110#define sys_sync_file_range sys_sync_file_range2
111#endif 111#endif
112 112
113/* Call the trampolines to manage pt_regs where necessary. */
114#define sys_execve _sys_execve
115#define sys_sigaltstack _sys_sigaltstack
116#define sys_rt_sigreturn _sys_rt_sigreturn
117#define sys_clone _sys_clone
118#ifndef __tilegx__
119#define sys_cmpxchg_badaddr _sys_cmpxchg_badaddr
120#endif
121
113/* 122/*
114 * Note that we can't include <linux/unistd.h> here since the header 123 * Note that we can't include <linux/unistd.h> here since the header
115 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well. 124 * guard will defeat us; <asm/unistd.h> checks for __SYSCALL as well.
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
index 6bed820e1421..f2e156e44692 100644
--- a/arch/tile/kernel/time.c
+++ b/arch/tile/kernel/time.c
@@ -132,7 +132,7 @@ static int tile_timer_set_next_event(unsigned long ticks,
132{ 132{
133 BUG_ON(ticks > MAX_TICK); 133 BUG_ON(ticks > MAX_TICK);
134 __insn_mtspr(SPR_TILE_TIMER_CONTROL, ticks); 134 __insn_mtspr(SPR_TILE_TIMER_CONTROL, ticks);
135 raw_local_irq_unmask_now(INT_TILE_TIMER); 135 arch_local_irq_unmask_now(INT_TILE_TIMER);
136 return 0; 136 return 0;
137} 137}
138 138
@@ -143,7 +143,7 @@ static int tile_timer_set_next_event(unsigned long ticks,
143static void tile_timer_set_mode(enum clock_event_mode mode, 143static void tile_timer_set_mode(enum clock_event_mode mode,
144 struct clock_event_device *evt) 144 struct clock_event_device *evt)
145{ 145{
146 raw_local_irq_mask_now(INT_TILE_TIMER); 146 arch_local_irq_mask_now(INT_TILE_TIMER);
147} 147}
148 148
149/* 149/*
@@ -172,7 +172,7 @@ void __cpuinit setup_tile_timer(void)
172 evt->cpumask = cpumask_of(smp_processor_id()); 172 evt->cpumask = cpumask_of(smp_processor_id());
173 173
174 /* Start out with timer not firing. */ 174 /* Start out with timer not firing. */
175 raw_local_irq_mask_now(INT_TILE_TIMER); 175 arch_local_irq_mask_now(INT_TILE_TIMER);
176 176
177 /* Register tile timer. */ 177 /* Register tile timer. */
178 clockevents_register_device(evt); 178 clockevents_register_device(evt);
@@ -188,7 +188,7 @@ void do_timer_interrupt(struct pt_regs *regs, int fault_num)
188 * Mask the timer interrupt here, since we are a oneshot timer 188 * Mask the timer interrupt here, since we are a oneshot timer
189 * and there are now by definition no events pending. 189 * and there are now by definition no events pending.
190 */ 190 */
191 raw_local_irq_mask(INT_TILE_TIMER); 191 arch_local_irq_mask(INT_TILE_TIMER);
192 192
193 /* Track time spent here in an interrupt context */ 193 /* Track time spent here in an interrupt context */
194 irq_enter(); 194 irq_enter();
diff --git a/arch/tile/kernel/traps.c b/arch/tile/kernel/traps.c
index 0f362dc2c57f..5474fc2e77e8 100644
--- a/arch/tile/kernel/traps.c
+++ b/arch/tile/kernel/traps.c
@@ -260,7 +260,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
260 address = regs->pc; 260 address = regs->pc;
261 break; 261 break;
262 case INT_UNALIGN_DATA: 262 case INT_UNALIGN_DATA:
263#ifndef __tilegx__ /* FIXME: GX: no single-step yet */ 263#ifndef __tilegx__ /* Emulated support for single step debugging */
264 if (unaligned_fixup >= 0) { 264 if (unaligned_fixup >= 0) {
265 struct single_step_state *state = 265 struct single_step_state *state =
266 current_thread_info()->step_state; 266 current_thread_info()->step_state;
@@ -278,7 +278,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
278 case INT_DOUBLE_FAULT: 278 case INT_DOUBLE_FAULT:
279 /* 279 /*
280 * For double fault, "reason" is actually passed as 280 * For double fault, "reason" is actually passed as
281 * SYSTEM_SAVE_1_2, the hypervisor's double-fault info, so 281 * SYSTEM_SAVE_K_2, the hypervisor's double-fault info, so
282 * we can provide the original fault number rather than 282 * we can provide the original fault number rather than
283 * the uninteresting "INT_DOUBLE_FAULT" so the user can 283 * the uninteresting "INT_DOUBLE_FAULT" so the user can
284 * learn what actually struck while PL0 ICS was set. 284 * learn what actually struck while PL0 ICS was set.
diff --git a/arch/tile/kvm/Kconfig b/arch/tile/kvm/Kconfig
new file mode 100644
index 000000000000..b88f9c047781
--- /dev/null
+++ b/arch/tile/kvm/Kconfig
@@ -0,0 +1,38 @@
1#
2# KVM configuration
3#
4
5source "virt/kvm/Kconfig"
6
7menuconfig VIRTUALIZATION
8 bool "Virtualization"
9 ---help---
10 Say Y here to get to see options for using your Linux host to run
11 other operating systems inside virtual machines (guests).
12 This option alone does not add any kernel code.
13
14 If you say N, all options in this submenu will be skipped and
15 disabled.
16
17if VIRTUALIZATION
18
19config KVM
20 tristate "Kernel-based Virtual Machine (KVM) support"
21 depends on HAVE_KVM && MODULES && EXPERIMENTAL
22 select PREEMPT_NOTIFIERS
23 select ANON_INODES
24 ---help---
25 Support hosting paravirtualized guest machines.
26
27 This module provides access to the hardware capabilities through
28 a character device node named /dev/kvm.
29
30 To compile this as a module, choose M here: the module
31 will be called kvm.
32
33 If unsure, say N.
34
35source drivers/vhost/Kconfig
36source drivers/virtio/Kconfig
37
38endif # VIRTUALIZATION
diff --git a/arch/tile/lib/Makefile b/arch/tile/lib/Makefile
index 746dc81ed3c4..93122d5b1558 100644
--- a/arch/tile/lib/Makefile
+++ b/arch/tile/lib/Makefile
@@ -3,8 +3,8 @@
3# 3#
4 4
5lib-y = cacheflush.o checksum.o cpumask.o delay.o \ 5lib-y = cacheflush.o checksum.o cpumask.o delay.o \
6 mb_incoherent.o uaccess.o \ 6 mb_incoherent.o uaccess.o memmove.o \
7 memcpy_$(BITS).o memchr_$(BITS).o memmove_$(BITS).o memset_$(BITS).o \ 7 memcpy_$(BITS).o memchr_$(BITS).o memset_$(BITS).o \
8 strchr_$(BITS).o strlen_$(BITS).o 8 strchr_$(BITS).o strlen_$(BITS).o
9 9
10ifeq ($(CONFIG_TILEGX),y) 10ifeq ($(CONFIG_TILEGX),y)
diff --git a/arch/tile/lib/atomic_32.c b/arch/tile/lib/atomic_32.c
index 8040b42a8eea..7a5cc706ab62 100644
--- a/arch/tile/lib/atomic_32.c
+++ b/arch/tile/lib/atomic_32.c
@@ -300,7 +300,7 @@ void __init __init_atomic_per_cpu(void)
300#else /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */ 300#else /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */
301 301
302 /* Validate power-of-two and "bigger than cpus" assumption */ 302 /* Validate power-of-two and "bigger than cpus" assumption */
303 BUG_ON(ATOMIC_HASH_SIZE & (ATOMIC_HASH_SIZE-1)); 303 BUILD_BUG_ON(ATOMIC_HASH_SIZE & (ATOMIC_HASH_SIZE-1));
304 BUG_ON(ATOMIC_HASH_SIZE < nr_cpu_ids); 304 BUG_ON(ATOMIC_HASH_SIZE < nr_cpu_ids);
305 305
306 /* 306 /*
@@ -314,17 +314,17 @@ void __init __init_atomic_per_cpu(void)
314 BUG_ON((unsigned long)atomic_locks % PAGE_SIZE != 0); 314 BUG_ON((unsigned long)atomic_locks % PAGE_SIZE != 0);
315 315
316 /* The locks must all fit on one page. */ 316 /* The locks must all fit on one page. */
317 BUG_ON(ATOMIC_HASH_SIZE * sizeof(int) > PAGE_SIZE); 317 BUILD_BUG_ON(ATOMIC_HASH_SIZE * sizeof(int) > PAGE_SIZE);
318 318
319 /* 319 /*
320 * We use the page offset of the atomic value's address as 320 * We use the page offset of the atomic value's address as
321 * an index into atomic_locks, excluding the low 3 bits. 321 * an index into atomic_locks, excluding the low 3 bits.
322 * That should not produce more indices than ATOMIC_HASH_SIZE. 322 * That should not produce more indices than ATOMIC_HASH_SIZE.
323 */ 323 */
324 BUG_ON((PAGE_SIZE >> 3) > ATOMIC_HASH_SIZE); 324 BUILD_BUG_ON((PAGE_SIZE >> 3) > ATOMIC_HASH_SIZE);
325 325
326#endif /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */ 326#endif /* ATOMIC_LOCKS_FOUND_VIA_TABLE() */
327 327
328 /* The futex code makes this assumption, so we validate it here. */ 328 /* The futex code makes this assumption, so we validate it here. */
329 BUG_ON(sizeof(atomic_t) != sizeof(int)); 329 BUILD_BUG_ON(sizeof(atomic_t) != sizeof(int));
330} 330}
diff --git a/arch/tile/lib/exports.c b/arch/tile/lib/exports.c
index ce5dbf56578f..1509c5597653 100644
--- a/arch/tile/lib/exports.c
+++ b/arch/tile/lib/exports.c
@@ -45,6 +45,9 @@ EXPORT_SYMBOL(__copy_from_user_zeroing);
45EXPORT_SYMBOL(__copy_in_user_inatomic); 45EXPORT_SYMBOL(__copy_in_user_inatomic);
46#endif 46#endif
47 47
48/* arch/tile/lib/mb_incoherent.S */
49EXPORT_SYMBOL(__mb_incoherent);
50
48/* hypervisor glue */ 51/* hypervisor glue */
49#include <hv/hypervisor.h> 52#include <hv/hypervisor.h>
50EXPORT_SYMBOL(hv_dev_open); 53EXPORT_SYMBOL(hv_dev_open);
diff --git a/arch/tile/lib/memcpy_32.S b/arch/tile/lib/memcpy_32.S
index 30c3b7ebb55d..2a419a6122db 100644
--- a/arch/tile/lib/memcpy_32.S
+++ b/arch/tile/lib/memcpy_32.S
@@ -10,14 +10,16 @@
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for 11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details. 12 * more details.
13 *
14 * This file shares the implementation of the userspace memcpy and
15 * the kernel's memcpy, copy_to_user and copy_from_user.
16 */ 13 */
17 14
18#include <arch/chip.h> 15#include <arch/chip.h>
19 16
20 17
18/*
19 * This file shares the implementation of the userspace memcpy and
20 * the kernel's memcpy, copy_to_user and copy_from_user.
21 */
22
21#include <linux/linkage.h> 23#include <linux/linkage.h>
22 24
23/* On TILE64, we wrap these functions via arch/tile/lib/memcpy_tile64.c */ 25/* On TILE64, we wrap these functions via arch/tile/lib/memcpy_tile64.c */
@@ -53,9 +55,9 @@
53 */ 55 */
54ENTRY(__copy_from_user_inatomic) 56ENTRY(__copy_from_user_inatomic)
55.type __copy_from_user_inatomic, @function 57.type __copy_from_user_inatomic, @function
56 FEEDBACK_ENTER_EXPLICIT(__copy_from_user_inatomic, \ 58 FEEDBACK_ENTER_EXPLICIT(__copy_from_user_inatomic, \
57 .text.memcpy_common, \ 59 .text.memcpy_common, \
58 .Lend_memcpy_common - __copy_from_user_inatomic) 60 .Lend_memcpy_common - __copy_from_user_inatomic)
59 { movei r29, IS_COPY_FROM_USER; j memcpy_common } 61 { movei r29, IS_COPY_FROM_USER; j memcpy_common }
60 .size __copy_from_user_inatomic, . - __copy_from_user_inatomic 62 .size __copy_from_user_inatomic, . - __copy_from_user_inatomic
61 63
@@ -64,7 +66,7 @@ ENTRY(__copy_from_user_inatomic)
64 */ 66 */
65ENTRY(__copy_from_user_zeroing) 67ENTRY(__copy_from_user_zeroing)
66.type __copy_from_user_zeroing, @function 68.type __copy_from_user_zeroing, @function
67 FEEDBACK_REENTER(__copy_from_user_inatomic) 69 FEEDBACK_REENTER(__copy_from_user_inatomic)
68 { movei r29, IS_COPY_FROM_USER_ZEROING; j memcpy_common } 70 { movei r29, IS_COPY_FROM_USER_ZEROING; j memcpy_common }
69 .size __copy_from_user_zeroing, . - __copy_from_user_zeroing 71 .size __copy_from_user_zeroing, . - __copy_from_user_zeroing
70 72
@@ -74,13 +76,13 @@ ENTRY(__copy_from_user_zeroing)
74 */ 76 */
75ENTRY(__copy_to_user_inatomic) 77ENTRY(__copy_to_user_inatomic)
76.type __copy_to_user_inatomic, @function 78.type __copy_to_user_inatomic, @function
77 FEEDBACK_REENTER(__copy_from_user_inatomic) 79 FEEDBACK_REENTER(__copy_from_user_inatomic)
78 { movei r29, IS_COPY_TO_USER; j memcpy_common } 80 { movei r29, IS_COPY_TO_USER; j memcpy_common }
79 .size __copy_to_user_inatomic, . - __copy_to_user_inatomic 81 .size __copy_to_user_inatomic, . - __copy_to_user_inatomic
80 82
81ENTRY(memcpy) 83ENTRY(memcpy)
82.type memcpy, @function 84.type memcpy, @function
83 FEEDBACK_REENTER(__copy_from_user_inatomic) 85 FEEDBACK_REENTER(__copy_from_user_inatomic)
84 { movei r29, IS_MEMCPY } 86 { movei r29, IS_MEMCPY }
85 .size memcpy, . - memcpy 87 .size memcpy, . - memcpy
86 /* Fall through */ 88 /* Fall through */
@@ -157,35 +159,35 @@ EX: { sw r0, r3; addi r0, r0, 4; addi r2, r2, -4 }
157 { addi r3, r1, 60; andi r9, r9, -64 } 159 { addi r3, r1, 60; andi r9, r9, -64 }
158 160
159#if CHIP_HAS_WH64() 161#if CHIP_HAS_WH64()
160 /* No need to prefetch dst, we'll just do the wh64 162 /* No need to prefetch dst, we'll just do the wh64
161 * right before we copy a line. 163 * right before we copy a line.
162 */ 164 */
163#endif 165#endif
164 166
165EX: { lw r5, r3; addi r3, r3, 64; movei r4, 1 } 167EX: { lw r5, r3; addi r3, r3, 64; movei r4, 1 }
166 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 168 /* Intentionally stall for a few cycles to leave L2 cache alone. */
167 { bnzt zero, .; move r27, lr } 169 { bnzt zero, .; move r27, lr }
168EX: { lw r6, r3; addi r3, r3, 64 } 170EX: { lw r6, r3; addi r3, r3, 64 }
169 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 171 /* Intentionally stall for a few cycles to leave L2 cache alone. */
170 { bnzt zero, . } 172 { bnzt zero, . }
171EX: { lw r7, r3; addi r3, r3, 64 } 173EX: { lw r7, r3; addi r3, r3, 64 }
172#if !CHIP_HAS_WH64() 174#if !CHIP_HAS_WH64()
173 /* Prefetch the dest */ 175 /* Prefetch the dest */
174 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 176 /* Intentionally stall for a few cycles to leave L2 cache alone. */
175 { bnzt zero, . } 177 { bnzt zero, . }
176 /* Use a real load to cause a TLB miss if necessary. We aren't using 178 /* Use a real load to cause a TLB miss if necessary. We aren't using
177 * r28, so this should be fine. 179 * r28, so this should be fine.
178 */ 180 */
179EX: { lw r28, r9; addi r9, r9, 64 } 181EX: { lw r28, r9; addi r9, r9, 64 }
180 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 182 /* Intentionally stall for a few cycles to leave L2 cache alone. */
181 { bnzt zero, . } 183 { bnzt zero, . }
182 { prefetch r9; addi r9, r9, 64 } 184 { prefetch r9; addi r9, r9, 64 }
183 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 185 /* Intentionally stall for a few cycles to leave L2 cache alone. */
184 { bnzt zero, . } 186 { bnzt zero, . }
185 { prefetch r9; addi r9, r9, 64 } 187 { prefetch r9; addi r9, r9, 64 }
186#endif 188#endif
187 /* Intentionally stall for a few cycles to leave L2 cache alone. */ 189 /* Intentionally stall for a few cycles to leave L2 cache alone. */
188 { bz zero, .Lbig_loop2 } 190 { bz zero, .Lbig_loop2 }
189 191
190 /* On entry to this loop: 192 /* On entry to this loop:
191 * - r0 points to the start of dst line 0 193 * - r0 points to the start of dst line 0
@@ -197,7 +199,7 @@ EX: { lw r28, r9; addi r9, r9, 64 }
197 * to some "safe" recently loaded address. 199 * to some "safe" recently loaded address.
198 * - r5 contains *(r1 + 60) [i.e. last word of source line 0] 200 * - r5 contains *(r1 + 60) [i.e. last word of source line 0]
199 * - r6 contains *(r1 + 64 + 60) [i.e. last word of source line 1] 201 * - r6 contains *(r1 + 64 + 60) [i.e. last word of source line 1]
200 * - r9 contains ((r0 + 63) & -64) 202 * - r9 contains ((r0 + 63) & -64)
201 * [start of next dst cache line.] 203 * [start of next dst cache line.]
202 */ 204 */
203 205
@@ -208,137 +210,137 @@ EX: { lw r28, r9; addi r9, r9, 64 }
208 /* Copy line 0, first stalling until r5 is ready. */ 210 /* Copy line 0, first stalling until r5 is ready. */
209EX: { move r12, r5; lw r16, r1 } 211EX: { move r12, r5; lw r16, r1 }
210 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 } 212 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 }
211 /* Prefetch several lines ahead. */ 213 /* Prefetch several lines ahead. */
212EX: { lw r5, r3; addi r3, r3, 64 } 214EX: { lw r5, r3; addi r3, r3, 64 }
213 { jal .Lcopy_line } 215 { jal .Lcopy_line }
214 216
215 /* Copy line 1, first stalling until r6 is ready. */ 217 /* Copy line 1, first stalling until r6 is ready. */
216EX: { move r12, r6; lw r16, r1 } 218EX: { move r12, r6; lw r16, r1 }
217 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 } 219 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 }
218 /* Prefetch several lines ahead. */ 220 /* Prefetch several lines ahead. */
219EX: { lw r6, r3; addi r3, r3, 64 } 221EX: { lw r6, r3; addi r3, r3, 64 }
220 { jal .Lcopy_line } 222 { jal .Lcopy_line }
221 223
222 /* Copy line 2, first stalling until r7 is ready. */ 224 /* Copy line 2, first stalling until r7 is ready. */
223EX: { move r12, r7; lw r16, r1 } 225EX: { move r12, r7; lw r16, r1 }
224 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 } 226 { bz r4, .Lcopy_8_check; slti_u r8, r2, 8 }
225 /* Prefetch several lines ahead. */ 227 /* Prefetch several lines ahead. */
226EX: { lw r7, r3; addi r3, r3, 64 } 228EX: { lw r7, r3; addi r3, r3, 64 }
227 /* Use up a caches-busy cycle by jumping back to the top of the 229 /* Use up a caches-busy cycle by jumping back to the top of the
228 * loop. Might as well get it out of the way now. 230 * loop. Might as well get it out of the way now.
229 */ 231 */
230 { j .Lbig_loop } 232 { j .Lbig_loop }
231 233
232 234
233 /* On entry: 235 /* On entry:
234 * - r0 points to the destination line. 236 * - r0 points to the destination line.
235 * - r1 points to the source line. 237 * - r1 points to the source line.
236 * - r3 is the next prefetch address. 238 * - r3 is the next prefetch address.
237 * - r9 holds the last address used for wh64. 239 * - r9 holds the last address used for wh64.
238 * - r12 = WORD_15 240 * - r12 = WORD_15
239 * - r16 = WORD_0. 241 * - r16 = WORD_0.
240 * - r17 == r1 + 16. 242 * - r17 == r1 + 16.
241 * - r27 holds saved lr to restore. 243 * - r27 holds saved lr to restore.
242 * 244 *
243 * On exit: 245 * On exit:
244 * - r0 is incremented by 64. 246 * - r0 is incremented by 64.
245 * - r1 is incremented by 64, unless that would point to a word 247 * - r1 is incremented by 64, unless that would point to a word
246 * beyond the end of the source array, in which case it is redirected 248 * beyond the end of the source array, in which case it is redirected
247 * to point to an arbitrary word already in the cache. 249 * to point to an arbitrary word already in the cache.
248 * - r2 is decremented by 64. 250 * - r2 is decremented by 64.
249 * - r3 is unchanged, unless it points to a word beyond the 251 * - r3 is unchanged, unless it points to a word beyond the
250 * end of the source array, in which case it is redirected 252 * end of the source array, in which case it is redirected
251 * to point to an arbitrary word already in the cache. 253 * to point to an arbitrary word already in the cache.
252 * Redirecting is OK since if we are that close to the end 254 * Redirecting is OK since if we are that close to the end
253 * of the array we will not come back to this subroutine 255 * of the array we will not come back to this subroutine
254 * and use the contents of the prefetched address. 256 * and use the contents of the prefetched address.
255 * - r4 is nonzero iff r2 >= 64. 257 * - r4 is nonzero iff r2 >= 64.
256 * - r9 is incremented by 64, unless it points beyond the 258 * - r9 is incremented by 64, unless it points beyond the
257 * end of the last full destination cache line, in which 259 * end of the last full destination cache line, in which
258 * case it is redirected to a "safe address" that can be 260 * case it is redirected to a "safe address" that can be
259 * clobbered (sp - 64) 261 * clobbered (sp - 64)
260 * - lr contains the value in r27. 262 * - lr contains the value in r27.
261 */ 263 */
262 264
263/* r26 unused */ 265/* r26 unused */
264 266
265.Lcopy_line: 267.Lcopy_line:
266 /* TODO: when r3 goes past the end, we would like to redirect it 268 /* TODO: when r3 goes past the end, we would like to redirect it
267 * to prefetch the last partial cache line (if any) just once, for the 269 * to prefetch the last partial cache line (if any) just once, for the
268 * benefit of the final cleanup loop. But we don't want to 270 * benefit of the final cleanup loop. But we don't want to
269 * prefetch that line more than once, or subsequent prefetches 271 * prefetch that line more than once, or subsequent prefetches
270 * will go into the RTF. But then .Lbig_loop should unconditionally 272 * will go into the RTF. But then .Lbig_loop should unconditionally
271 * branch to top of loop to execute final prefetch, and its 273 * branch to top of loop to execute final prefetch, and its
272 * nop should become a conditional branch. 274 * nop should become a conditional branch.
273 */ 275 */
274 276
275 /* We need two non-memory cycles here to cover the resources 277 /* We need two non-memory cycles here to cover the resources
276 * used by the loads initiated by the caller. 278 * used by the loads initiated by the caller.
277 */ 279 */
278 { add r15, r1, r2 } 280 { add r15, r1, r2 }
279.Lcopy_line2: 281.Lcopy_line2:
280 { slt_u r13, r3, r15; addi r17, r1, 16 } 282 { slt_u r13, r3, r15; addi r17, r1, 16 }
281 283
282 /* NOTE: this will stall for one cycle as L1 is busy. */ 284 /* NOTE: this will stall for one cycle as L1 is busy. */
283 285
284 /* Fill second L1D line. */ 286 /* Fill second L1D line. */
285EX: { lw r17, r17; addi r1, r1, 48; mvz r3, r13, r1 } /* r17 = WORD_4 */ 287EX: { lw r17, r17; addi r1, r1, 48; mvz r3, r13, r1 } /* r17 = WORD_4 */
286 288
287#if CHIP_HAS_WH64() 289#if CHIP_HAS_WH64()
288 /* Prepare destination line for writing. */ 290 /* Prepare destination line for writing. */
289EX: { wh64 r9; addi r9, r9, 64 } 291EX: { wh64 r9; addi r9, r9, 64 }
290#else 292#else
291 /* Prefetch dest line */ 293 /* Prefetch dest line */
292 { prefetch r9; addi r9, r9, 64 } 294 { prefetch r9; addi r9, r9, 64 }
293#endif 295#endif
294 /* Load seven words that are L1D hits to cover wh64 L2 usage. */ 296 /* Load seven words that are L1D hits to cover wh64 L2 usage. */
295 297
296 /* Load the three remaining words from the last L1D line, which 298 /* Load the three remaining words from the last L1D line, which
297 * we know has already filled the L1D. 299 * we know has already filled the L1D.
298 */ 300 */
299EX: { lw r4, r1; addi r1, r1, 4; addi r20, r1, 16 } /* r4 = WORD_12 */ 301EX: { lw r4, r1; addi r1, r1, 4; addi r20, r1, 16 } /* r4 = WORD_12 */
300EX: { lw r8, r1; addi r1, r1, 4; slt_u r13, r20, r15 }/* r8 = WORD_13 */ 302EX: { lw r8, r1; addi r1, r1, 4; slt_u r13, r20, r15 }/* r8 = WORD_13 */
301EX: { lw r11, r1; addi r1, r1, -52; mvz r20, r13, r1 } /* r11 = WORD_14 */ 303EX: { lw r11, r1; addi r1, r1, -52; mvz r20, r13, r1 } /* r11 = WORD_14 */
302 304
303 /* Load the three remaining words from the first L1D line, first 305 /* Load the three remaining words from the first L1D line, first
304 * stalling until it has filled by "looking at" r16. 306 * stalling until it has filled by "looking at" r16.
305 */ 307 */
306EX: { lw r13, r1; addi r1, r1, 4; move zero, r16 } /* r13 = WORD_1 */ 308EX: { lw r13, r1; addi r1, r1, 4; move zero, r16 } /* r13 = WORD_1 */
307EX: { lw r14, r1; addi r1, r1, 4 } /* r14 = WORD_2 */ 309EX: { lw r14, r1; addi r1, r1, 4 } /* r14 = WORD_2 */
308EX: { lw r15, r1; addi r1, r1, 8; addi r10, r0, 60 } /* r15 = WORD_3 */ 310EX: { lw r15, r1; addi r1, r1, 8; addi r10, r0, 60 } /* r15 = WORD_3 */
309 311
310 /* Load second word from the second L1D line, first 312 /* Load second word from the second L1D line, first
311 * stalling until it has filled by "looking at" r17. 313 * stalling until it has filled by "looking at" r17.
312 */ 314 */
313EX: { lw r19, r1; addi r1, r1, 4; move zero, r17 } /* r19 = WORD_5 */ 315EX: { lw r19, r1; addi r1, r1, 4; move zero, r17 } /* r19 = WORD_5 */
314 316
315 /* Store last word to the destination line, potentially dirtying it 317 /* Store last word to the destination line, potentially dirtying it
316 * for the first time, which keeps the L2 busy for two cycles. 318 * for the first time, which keeps the L2 busy for two cycles.
317 */ 319 */
318EX: { sw r10, r12 } /* store(WORD_15) */ 320EX: { sw r10, r12 } /* store(WORD_15) */
319 321
320 /* Use two L1D hits to cover the sw L2 access above. */ 322 /* Use two L1D hits to cover the sw L2 access above. */
321EX: { lw r10, r1; addi r1, r1, 4 } /* r10 = WORD_6 */ 323EX: { lw r10, r1; addi r1, r1, 4 } /* r10 = WORD_6 */
322EX: { lw r12, r1; addi r1, r1, 4 } /* r12 = WORD_7 */ 324EX: { lw r12, r1; addi r1, r1, 4 } /* r12 = WORD_7 */
323 325
324 /* Fill third L1D line. */ 326 /* Fill third L1D line. */
325EX: { lw r18, r1; addi r1, r1, 4 } /* r18 = WORD_8 */ 327EX: { lw r18, r1; addi r1, r1, 4 } /* r18 = WORD_8 */
326 328
327 /* Store first L1D line. */ 329 /* Store first L1D line. */
328EX: { sw r0, r16; addi r0, r0, 4; add r16, r0, r2 } /* store(WORD_0) */ 330EX: { sw r0, r16; addi r0, r0, 4; add r16, r0, r2 } /* store(WORD_0) */
329EX: { sw r0, r13; addi r0, r0, 4; andi r16, r16, -64 } /* store(WORD_1) */ 331EX: { sw r0, r13; addi r0, r0, 4; andi r16, r16, -64 } /* store(WORD_1) */
330EX: { sw r0, r14; addi r0, r0, 4; slt_u r16, r9, r16 } /* store(WORD_2) */ 332EX: { sw r0, r14; addi r0, r0, 4; slt_u r16, r9, r16 } /* store(WORD_2) */
331#if CHIP_HAS_WH64() 333#if CHIP_HAS_WH64()
332EX: { sw r0, r15; addi r0, r0, 4; addi r13, sp, -64 } /* store(WORD_3) */ 334EX: { sw r0, r15; addi r0, r0, 4; addi r13, sp, -64 } /* store(WORD_3) */
333#else 335#else
334 /* Back up the r9 to a cache line we are already storing to 336 /* Back up the r9 to a cache line we are already storing to
335 * if it gets past the end of the dest vector. Strictly speaking, 337 * if it gets past the end of the dest vector. Strictly speaking,
336 * we don't need to back up to the start of a cache line, but it's free 338 * we don't need to back up to the start of a cache line, but it's free
337 * and tidy, so why not? 339 * and tidy, so why not?
338 */ 340 */
339EX: { sw r0, r15; addi r0, r0, 4; andi r13, r0, -64 } /* store(WORD_3) */ 341EX: { sw r0, r15; addi r0, r0, 4; andi r13, r0, -64 } /* store(WORD_3) */
340#endif 342#endif
341 /* Store second L1D line. */ 343 /* Store second L1D line. */
342EX: { sw r0, r17; addi r0, r0, 4; mvz r9, r16, r13 }/* store(WORD_4) */ 344EX: { sw r0, r17; addi r0, r0, 4; mvz r9, r16, r13 }/* store(WORD_4) */
343EX: { sw r0, r19; addi r0, r0, 4 } /* store(WORD_5) */ 345EX: { sw r0, r19; addi r0, r0, 4 } /* store(WORD_5) */
344EX: { sw r0, r10; addi r0, r0, 4 } /* store(WORD_6) */ 346EX: { sw r0, r10; addi r0, r0, 4 } /* store(WORD_6) */
@@ -348,30 +350,30 @@ EX: { lw r13, r1; addi r1, r1, 4; move zero, r18 } /* r13 = WORD_9 */
348EX: { lw r14, r1; addi r1, r1, 4 } /* r14 = WORD_10 */ 350EX: { lw r14, r1; addi r1, r1, 4 } /* r14 = WORD_10 */
349EX: { lw r15, r1; move r1, r20 } /* r15 = WORD_11 */ 351EX: { lw r15, r1; move r1, r20 } /* r15 = WORD_11 */
350 352
351 /* Store third L1D line. */ 353 /* Store third L1D line. */
352EX: { sw r0, r18; addi r0, r0, 4 } /* store(WORD_8) */ 354EX: { sw r0, r18; addi r0, r0, 4 } /* store(WORD_8) */
353EX: { sw r0, r13; addi r0, r0, 4 } /* store(WORD_9) */ 355EX: { sw r0, r13; addi r0, r0, 4 } /* store(WORD_9) */
354EX: { sw r0, r14; addi r0, r0, 4 } /* store(WORD_10) */ 356EX: { sw r0, r14; addi r0, r0, 4 } /* store(WORD_10) */
355EX: { sw r0, r15; addi r0, r0, 4 } /* store(WORD_11) */ 357EX: { sw r0, r15; addi r0, r0, 4 } /* store(WORD_11) */
356 358
357 /* Store rest of fourth L1D line. */ 359 /* Store rest of fourth L1D line. */
358EX: { sw r0, r4; addi r0, r0, 4 } /* store(WORD_12) */ 360EX: { sw r0, r4; addi r0, r0, 4 } /* store(WORD_12) */
359 { 361 {
360EX: sw r0, r8 /* store(WORD_13) */ 362EX: sw r0, r8 /* store(WORD_13) */
361 addi r0, r0, 4 363 addi r0, r0, 4
362 /* Will r2 be > 64 after we subtract 64 below? */ 364 /* Will r2 be > 64 after we subtract 64 below? */
363 shri r4, r2, 7 365 shri r4, r2, 7
364 } 366 }
365 { 367 {
366EX: sw r0, r11 /* store(WORD_14) */ 368EX: sw r0, r11 /* store(WORD_14) */
367 addi r0, r0, 8 369 addi r0, r0, 8
368 /* Record 64 bytes successfully copied. */ 370 /* Record 64 bytes successfully copied. */
369 addi r2, r2, -64 371 addi r2, r2, -64
370 } 372 }
371 373
372 { jrp lr; move lr, r27 } 374 { jrp lr; move lr, r27 }
373 375
374 /* Convey to the backtrace library that the stack frame is size 376 /* Convey to the backtrace library that the stack frame is size
375 * zero, and the real return address is on the stack rather than 377 * zero, and the real return address is on the stack rather than
376 * in 'lr'. 378 * in 'lr'.
377 */ 379 */
diff --git a/arch/tile/lib/memcpy_tile64.c b/arch/tile/lib/memcpy_tile64.c
index dfedea7b266b..f7d4a6ad61e8 100644
--- a/arch/tile/lib/memcpy_tile64.c
+++ b/arch/tile/lib/memcpy_tile64.c
@@ -54,7 +54,7 @@ typedef unsigned long (*memcpy_t)(void *, const void *, unsigned long);
54 * we must run with interrupts disabled to avoid the risk of some 54 * we must run with interrupts disabled to avoid the risk of some
55 * other code seeing the incoherent data in our cache. (Recall that 55 * other code seeing the incoherent data in our cache. (Recall that
56 * our cache is indexed by PA, so even if the other code doesn't use 56 * our cache is indexed by PA, so even if the other code doesn't use
57 * our KM_MEMCPY virtual addresses, they'll still hit in cache using 57 * our kmap_atomic virtual addresses, they'll still hit in cache using
58 * the normal VAs that aren't supposed to hit in cache.) 58 * the normal VAs that aren't supposed to hit in cache.)
59 */ 59 */
60static void memcpy_multicache(void *dest, const void *source, 60static void memcpy_multicache(void *dest, const void *source,
@@ -64,6 +64,7 @@ static void memcpy_multicache(void *dest, const void *source,
64 unsigned long flags, newsrc, newdst; 64 unsigned long flags, newsrc, newdst;
65 pmd_t *pmdp; 65 pmd_t *pmdp;
66 pte_t *ptep; 66 pte_t *ptep;
67 int type0, type1;
67 int cpu = get_cpu(); 68 int cpu = get_cpu();
68 69
69 /* 70 /*
@@ -77,7 +78,8 @@ static void memcpy_multicache(void *dest, const void *source,
77 sim_allow_multiple_caching(1); 78 sim_allow_multiple_caching(1);
78 79
79 /* Set up the new dest mapping */ 80 /* Set up the new dest mapping */
80 idx = FIX_KMAP_BEGIN + (KM_TYPE_NR * cpu) + KM_MEMCPY0; 81 type0 = kmap_atomic_idx_push();
82 idx = FIX_KMAP_BEGIN + (KM_TYPE_NR * cpu) + type0;
81 newdst = __fix_to_virt(idx) + ((unsigned long)dest & (PAGE_SIZE-1)); 83 newdst = __fix_to_virt(idx) + ((unsigned long)dest & (PAGE_SIZE-1));
82 pmdp = pmd_offset(pud_offset(pgd_offset_k(newdst), newdst), newdst); 84 pmdp = pmd_offset(pud_offset(pgd_offset_k(newdst), newdst), newdst);
83 ptep = pte_offset_kernel(pmdp, newdst); 85 ptep = pte_offset_kernel(pmdp, newdst);
@@ -87,7 +89,8 @@ static void memcpy_multicache(void *dest, const void *source,
87 } 89 }
88 90
89 /* Set up the new source mapping */ 91 /* Set up the new source mapping */
90 idx += (KM_MEMCPY0 - KM_MEMCPY1); 92 type1 = kmap_atomic_idx_push();
93 idx += (type0 - type1);
91 src_pte = hv_pte_set_nc(src_pte); 94 src_pte = hv_pte_set_nc(src_pte);
92 src_pte = hv_pte_clear_writable(src_pte); /* be paranoid */ 95 src_pte = hv_pte_clear_writable(src_pte); /* be paranoid */
93 newsrc = __fix_to_virt(idx) + ((unsigned long)source & (PAGE_SIZE-1)); 96 newsrc = __fix_to_virt(idx) + ((unsigned long)source & (PAGE_SIZE-1));
@@ -119,6 +122,8 @@ static void memcpy_multicache(void *dest, const void *source,
119 * We're done: notify the simulator that all is back to normal, 122 * We're done: notify the simulator that all is back to normal,
120 * and re-enable interrupts and pre-emption. 123 * and re-enable interrupts and pre-emption.
121 */ 124 */
125 kmap_atomic_idx_pop();
126 kmap_atomic_idx_pop();
122 sim_allow_multiple_caching(0); 127 sim_allow_multiple_caching(0);
123 local_irq_restore(flags); 128 local_irq_restore(flags);
124 put_cpu(); 129 put_cpu();
diff --git a/arch/tile/lib/memmove_32.c b/arch/tile/lib/memmove.c
index fd615ae6ade7..fd615ae6ade7 100644
--- a/arch/tile/lib/memmove_32.c
+++ b/arch/tile/lib/memmove.c
diff --git a/arch/tile/lib/memset_32.c b/arch/tile/lib/memset_32.c
index d014c1fbcbc2..57dbb3a5bff8 100644
--- a/arch/tile/lib/memset_32.c
+++ b/arch/tile/lib/memset_32.c
@@ -18,6 +18,7 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#undef memset
21 22
22void *memset(void *s, int c, size_t n) 23void *memset(void *s, int c, size_t n)
23{ 24{
diff --git a/arch/tile/lib/strlen_32.c b/arch/tile/lib/strlen_32.c
index f26f88e11e4a..4974292a5534 100644
--- a/arch/tile/lib/strlen_32.c
+++ b/arch/tile/lib/strlen_32.c
@@ -16,6 +16,8 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19#undef strlen
20
19size_t strlen(const char *s) 21size_t strlen(const char *s)
20{ 22{
21 /* Get an aligned pointer. */ 23 /* Get an aligned pointer. */
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 704f3e8a4385..f295b4ac941d 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -66,10 +66,10 @@ static noinline void force_sig_info_fault(int si_signo, int si_code,
66#ifndef __tilegx__ 66#ifndef __tilegx__
67/* 67/*
68 * Synthesize the fault a PL0 process would get by doing a word-load of 68 * Synthesize the fault a PL0 process would get by doing a word-load of
69 * an unaligned address or a high kernel address. Called indirectly 69 * an unaligned address or a high kernel address.
70 * from sys_cmpxchg() in kernel/intvec.S.
71 */ 70 */
72int _sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *regs) 71SYSCALL_DEFINE2(cmpxchg_badaddr, unsigned long, address,
72 struct pt_regs *, regs)
73{ 73{
74 if (address >= PAGE_OFFSET) 74 if (address >= PAGE_OFFSET)
75 force_sig_info_fault(SIGSEGV, SEGV_MAPERR, address, 75 force_sig_info_fault(SIGSEGV, SEGV_MAPERR, address,
@@ -563,10 +563,10 @@ do_sigbus:
563/* 563/*
564 * When we take an ITLB or DTLB fault or access violation in the 564 * When we take an ITLB or DTLB fault or access violation in the
565 * supervisor while the critical section bit is set, the hypervisor is 565 * supervisor while the critical section bit is set, the hypervisor is
566 * reluctant to write new values into the EX_CONTEXT_1_x registers, 566 * reluctant to write new values into the EX_CONTEXT_K_x registers,
567 * since that might indicate we have not yet squirreled the SPR 567 * since that might indicate we have not yet squirreled the SPR
568 * contents away and can thus safely take a recursive interrupt. 568 * contents away and can thus safely take a recursive interrupt.
569 * Accordingly, the hypervisor passes us the PC via SYSTEM_SAVE_1_2. 569 * Accordingly, the hypervisor passes us the PC via SYSTEM_SAVE_K_2.
570 * 570 *
571 * Note that this routine is called before homecache_tlb_defer_enter(), 571 * Note that this routine is called before homecache_tlb_defer_enter(),
572 * which means that we can properly unlock any atomics that might 572 * which means that we can properly unlock any atomics that might
@@ -610,7 +610,7 @@ struct intvec_state do_page_fault_ics(struct pt_regs *regs, int fault_num,
610 * fault. We didn't set up a kernel stack on initial entry to 610 * fault. We didn't set up a kernel stack on initial entry to
611 * sys_cmpxchg, but instead had one set up by the fault, which 611 * sys_cmpxchg, but instead had one set up by the fault, which
612 * (because sys_cmpxchg never releases ICS) came to us via the 612 * (because sys_cmpxchg never releases ICS) came to us via the
613 * SYSTEM_SAVE_1_2 mechanism, and thus EX_CONTEXT_1_[01] are 613 * SYSTEM_SAVE_K_2 mechanism, and thus EX_CONTEXT_K_[01] are
614 * still referencing the original user code. We release the 614 * still referencing the original user code. We release the
615 * atomic lock and rewrite pt_regs so that it appears that we 615 * atomic lock and rewrite pt_regs so that it appears that we
616 * came from user-space directly, and after we finish the 616 * came from user-space directly, and after we finish the
diff --git a/arch/tile/mm/highmem.c b/arch/tile/mm/highmem.c
index 12ab137e7d4f..31dbbd9afe47 100644
--- a/arch/tile/mm/highmem.c
+++ b/arch/tile/mm/highmem.c
@@ -56,50 +56,6 @@ void kunmap(struct page *page)
56} 56}
57EXPORT_SYMBOL(kunmap); 57EXPORT_SYMBOL(kunmap);
58 58
59static void debug_kmap_atomic_prot(enum km_type type)
60{
61#ifdef CONFIG_DEBUG_HIGHMEM
62 static unsigned warn_count = 10;
63
64 if (unlikely(warn_count == 0))
65 return;
66
67 if (unlikely(in_interrupt())) {
68 if (in_irq()) {
69 if (type != KM_IRQ0 && type != KM_IRQ1 &&
70 type != KM_BIO_SRC_IRQ &&
71 /* type != KM_BIO_DST_IRQ && */
72 type != KM_BOUNCE_READ) {
73 WARN_ON(1);
74 warn_count--;
75 }
76 } else if (!irqs_disabled()) { /* softirq */
77 if (type != KM_IRQ0 && type != KM_IRQ1 &&
78 type != KM_SOFTIRQ0 && type != KM_SOFTIRQ1 &&
79 type != KM_SKB_SUNRPC_DATA &&
80 type != KM_SKB_DATA_SOFTIRQ &&
81 type != KM_BOUNCE_READ) {
82 WARN_ON(1);
83 warn_count--;
84 }
85 }
86 }
87
88 if (type == KM_IRQ0 || type == KM_IRQ1 || type == KM_BOUNCE_READ ||
89 type == KM_BIO_SRC_IRQ /* || type == KM_BIO_DST_IRQ */) {
90 if (!irqs_disabled()) {
91 WARN_ON(1);
92 warn_count--;
93 }
94 } else if (type == KM_SOFTIRQ0 || type == KM_SOFTIRQ1) {
95 if (irq_count() == 0 && !irqs_disabled()) {
96 WARN_ON(1);
97 warn_count--;
98 }
99 }
100#endif
101}
102
103/* 59/*
104 * Describe a single atomic mapping of a page on a given cpu at a 60 * Describe a single atomic mapping of a page on a given cpu at a
105 * given address, and allow it to be linked into a list. 61 * given address, and allow it to be linked into a list.
@@ -240,10 +196,10 @@ void kmap_atomic_fix_kpte(struct page *page, int finished)
240 * When holding an atomic kmap is is not legal to sleep, so atomic 196 * When holding an atomic kmap is is not legal to sleep, so atomic
241 * kmaps are appropriate for short, tight code paths only. 197 * kmaps are appropriate for short, tight code paths only.
242 */ 198 */
243void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot) 199void *kmap_atomic_prot(struct page *page, pgprot_t prot)
244{ 200{
245 enum fixed_addresses idx;
246 unsigned long vaddr; 201 unsigned long vaddr;
202 int idx, type;
247 pte_t *pte; 203 pte_t *pte;
248 204
249 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 205 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
@@ -255,8 +211,7 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
255 if (!PageHighMem(page)) 211 if (!PageHighMem(page))
256 return page_address(page); 212 return page_address(page);
257 213
258 debug_kmap_atomic_prot(type); 214 type = kmap_atomic_idx_push();
259
260 idx = type + KM_TYPE_NR*smp_processor_id(); 215 idx = type + KM_TYPE_NR*smp_processor_id();
261 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 216 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
262 pte = kmap_get_pte(vaddr); 217 pte = kmap_get_pte(vaddr);
@@ -269,28 +224,35 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
269} 224}
270EXPORT_SYMBOL(kmap_atomic_prot); 225EXPORT_SYMBOL(kmap_atomic_prot);
271 226
272void *kmap_atomic(struct page *page, enum km_type type) 227void *__kmap_atomic(struct page *page)
273{ 228{
274 /* PAGE_NONE is a magic value that tells us to check immutability. */ 229 /* PAGE_NONE is a magic value that tells us to check immutability. */
275 return kmap_atomic_prot(page, type, PAGE_NONE); 230 return kmap_atomic_prot(page, PAGE_NONE);
276} 231}
277EXPORT_SYMBOL(kmap_atomic); 232EXPORT_SYMBOL(__kmap_atomic);
278 233
279void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 234void __kunmap_atomic(void *kvaddr)
280{ 235{
281 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 236 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
282 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
283 237
284 /* 238 if (vaddr >= __fix_to_virt(FIX_KMAP_END) &&
285 * Force other mappings to Oops if they try to access this pte without 239 vaddr <= __fix_to_virt(FIX_KMAP_BEGIN)) {
286 * first remapping it. Keeping stale mappings around is a bad idea.
287 */
288 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx)) {
289 pte_t *pte = kmap_get_pte(vaddr); 240 pte_t *pte = kmap_get_pte(vaddr);
290 pte_t pteval = *pte; 241 pte_t pteval = *pte;
242 int idx, type;
243
244 type = kmap_atomic_idx();
245 idx = type + KM_TYPE_NR*smp_processor_id();
246
247 /*
248 * Force other mappings to Oops if they try to access this pte
249 * without first remapping it. Keeping stale mappings around
250 * is a bad idea.
251 */
291 BUG_ON(!pte_present(pteval) && !pte_migrating(pteval)); 252 BUG_ON(!pte_present(pteval) && !pte_migrating(pteval));
292 kmap_atomic_unregister(pte_page(pteval), vaddr); 253 kmap_atomic_unregister(pte_page(pteval), vaddr);
293 kpte_clear_flush(pte, vaddr); 254 kpte_clear_flush(pte, vaddr);
255 kmap_atomic_idx_pop();
294 } else { 256 } else {
295 /* Must be a lowmem page */ 257 /* Must be a lowmem page */
296 BUG_ON(vaddr < PAGE_OFFSET); 258 BUG_ON(vaddr < PAGE_OFFSET);
@@ -300,19 +262,19 @@ void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type)
300 arch_flush_lazy_mmu_mode(); 262 arch_flush_lazy_mmu_mode();
301 pagefault_enable(); 263 pagefault_enable();
302} 264}
303EXPORT_SYMBOL(kunmap_atomic_notypecheck); 265EXPORT_SYMBOL(__kunmap_atomic);
304 266
305/* 267/*
306 * This API is supposed to allow us to map memory without a "struct page". 268 * This API is supposed to allow us to map memory without a "struct page".
307 * Currently we don't support this, though this may change in the future. 269 * Currently we don't support this, though this may change in the future.
308 */ 270 */
309void *kmap_atomic_pfn(unsigned long pfn, enum km_type type) 271void *kmap_atomic_pfn(unsigned long pfn)
310{ 272{
311 return kmap_atomic(pfn_to_page(pfn), type); 273 return kmap_atomic(pfn_to_page(pfn));
312} 274}
313void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) 275void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
314{ 276{
315 return kmap_atomic_prot(pfn_to_page(pfn), type, prot); 277 return kmap_atomic_prot(pfn_to_page(pfn), prot);
316} 278}
317 279
318struct page *kmap_atomic_to_page(void *ptr) 280struct page *kmap_atomic_to_page(void *ptr)
diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c
index fb3b4a55cec4..d78df3a6ee15 100644
--- a/arch/tile/mm/homecache.c
+++ b/arch/tile/mm/homecache.c
@@ -37,6 +37,8 @@
37#include <asm/pgalloc.h> 37#include <asm/pgalloc.h>
38#include <asm/homecache.h> 38#include <asm/homecache.h>
39 39
40#include <arch/sim.h>
41
40#include "migrate.h" 42#include "migrate.h"
41 43
42 44
@@ -217,13 +219,6 @@ static unsigned long cache_flush_length(unsigned long length)
217 return (length >= CHIP_L2_CACHE_SIZE()) ? HV_FLUSH_EVICT_L2 : length; 219 return (length >= CHIP_L2_CACHE_SIZE()) ? HV_FLUSH_EVICT_L2 : length;
218} 220}
219 221
220/* On the simulator, confirm lines have been evicted everywhere. */
221static void validate_lines_evicted(unsigned long pfn, size_t length)
222{
223 sim_syscall(SIM_SYSCALL_VALIDATE_LINES_EVICTED,
224 (HV_PhysAddr)pfn << PAGE_SHIFT, length);
225}
226
227/* Flush a page out of whatever cache(s) it is in. */ 222/* Flush a page out of whatever cache(s) it is in. */
228void homecache_flush_cache(struct page *page, int order) 223void homecache_flush_cache(struct page *page, int order)
229{ 224{
@@ -234,7 +229,7 @@ void homecache_flush_cache(struct page *page, int order)
234 229
235 homecache_mask(page, pages, &home_mask); 230 homecache_mask(page, pages, &home_mask);
236 flush_remote(pfn, length, &home_mask, 0, 0, 0, NULL, NULL, 0); 231 flush_remote(pfn, length, &home_mask, 0, 0, 0, NULL, NULL, 0);
237 validate_lines_evicted(pfn, pages * PAGE_SIZE); 232 sim_validate_lines_evicted(PFN_PHYS(pfn), pages * PAGE_SIZE);
238} 233}
239 234
240 235
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index d89c9eacd162..0b9ce69b0ee5 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -988,8 +988,12 @@ static long __write_once initfree = 1;
988/* Select whether to free (1) or mark unusable (0) the __init pages. */ 988/* Select whether to free (1) or mark unusable (0) the __init pages. */
989static int __init set_initfree(char *str) 989static int __init set_initfree(char *str)
990{ 990{
991 strict_strtol(str, 0, &initfree); 991 long val;
992 pr_info("initfree: %s free init pages\n", initfree ? "will" : "won't"); 992 if (strict_strtol(str, 0, &val)) {
993 initfree = val;
994 pr_info("initfree: %s free init pages\n",
995 initfree ? "will" : "won't");
996 }
993 return 1; 997 return 1;
994} 998}
995__setup("initfree=", set_initfree); 999__setup("initfree=", set_initfree);
@@ -1060,7 +1064,7 @@ void free_initmem(void)
1060 1064
1061 /* 1065 /*
1062 * Free the pages mapped from 0xc0000000 that correspond to code 1066 * Free the pages mapped from 0xc0000000 that correspond to code
1063 * pages from 0xfd000000 that we won't use again after init. 1067 * pages from MEM_SV_INTRPT that we won't use again after init.
1064 */ 1068 */
1065 free_init_pages("unused kernel text", 1069 free_init_pages("unused kernel text",
1066 (unsigned long)_sinittext - text_delta, 1070 (unsigned long)_sinittext - text_delta,
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index 335c24621c41..1f5430c53d0d 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -134,9 +134,9 @@ void __set_fixmap(enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
134} 134}
135 135
136#if defined(CONFIG_HIGHPTE) 136#if defined(CONFIG_HIGHPTE)
137pte_t *_pte_offset_map(pmd_t *dir, unsigned long address, enum km_type type) 137pte_t *_pte_offset_map(pmd_t *dir, unsigned long address)
138{ 138{
139 pte_t *pte = kmap_atomic(pmd_page(*dir), type) + 139 pte_t *pte = kmap_atomic(pmd_page(*dir)) +
140 (pmd_ptfn(*dir) << HV_LOG2_PAGE_TABLE_ALIGN) & ~PAGE_MASK; 140 (pmd_ptfn(*dir) << HV_LOG2_PAGE_TABLE_ALIGN) & ~PAGE_MASK;
141 return &pte[pte_index(address)]; 141 return &pte[pte_index(address)];
142} 142}
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 7c8e277f6d34..049d048b070d 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -19,8 +19,6 @@ config MMU
19config NO_IOMEM 19config NO_IOMEM
20 def_bool y 20 def_bool y
21 21
22mainmenu "Linux/Usermode Kernel Configuration"
23
24config ISA 22config ISA
25 bool 23 bool
26 24
diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um
index ec2b8da1aba4..50d6aa20c353 100644
--- a/arch/um/Kconfig.um
+++ b/arch/um/Kconfig.um
@@ -120,6 +120,9 @@ config SMP
120 120
121 If you don't know what to do, say N. 121 If you don't know what to do, say N.
122 122
123config GENERIC_HARDIRQS_NO__DO_IRQ
124 def_bool y
125
123config NR_CPUS 126config NR_CPUS
124 int "Maximum number of CPUs (2-32)" 127 int "Maximum number of CPUs (2-32)"
125 range 2 32 128 range 2 32
@@ -147,3 +150,6 @@ config KERNEL_STACK_ORDER
147 This option determines the size of UML kernel stacks. They will 150 This option determines the size of UML kernel stacks. They will
148 be 1 << order pages. The default is OK unless you're running Valgrind 151 be 1 << order pages. The default is OK unless you're running Valgrind
149 on UML, in which case, set this to 3. 152 on UML, in which case, set this to 3.
153
154config NO_DMA
155 def_bool y
diff --git a/arch/um/defconfig b/arch/um/defconfig
index 6bd456f96f90..564f3de65b4a 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -566,7 +566,6 @@ CONFIG_CRC32=m
566# CONFIG_CRC7 is not set 566# CONFIG_CRC7 is not set
567# CONFIG_LIBCRC32C is not set 567# CONFIG_LIBCRC32C is not set
568CONFIG_PLIST=y 568CONFIG_PLIST=y
569CONFIG_HAS_DMA=y
570 569
571# 570#
572# SCSI device support 571# SCSI device support
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 63c740a85b4c..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"
@@ -63,6 +63,8 @@ static int set_mixer(char *name, int *add)
63__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); 63__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
64#endif 64#endif
65 65
66static DEFINE_MUTEX(hostaudio_mutex);
67
66/* /dev/dsp file operations */ 68/* /dev/dsp file operations */
67 69
68static ssize_t hostaudio_read(struct file *file, char __user *buffer, 70static ssize_t hostaudio_read(struct file *file, char __user *buffer,
@@ -198,9 +200,9 @@ static int hostaudio_open(struct inode *inode, struct file *file)
198 w = 1; 200 w = 1;
199 201
200 kparam_block_sysfs_write(dsp); 202 kparam_block_sysfs_write(dsp);
201 lock_kernel(); 203 mutex_lock(&hostaudio_mutex);
202 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);
203 unlock_kernel(); 205 mutex_unlock(&hostaudio_mutex);
204 kparam_unblock_sysfs_write(dsp); 206 kparam_unblock_sysfs_write(dsp);
205 207
206 if (ret < 0) { 208 if (ret < 0) {
@@ -259,9 +261,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
259 w = 1; 261 w = 1;
260 262
261 kparam_block_sysfs_write(mixer); 263 kparam_block_sysfs_write(mixer);
262 lock_kernel(); 264 mutex_lock(&hostaudio_mutex);
263 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);
264 unlock_kernel(); 266 mutex_unlock(&hostaudio_mutex);
265 kparam_unblock_sysfs_write(mixer); 267 kparam_unblock_sysfs_write(mixer);
266 268
267 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/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 9734994cba1e..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);
@@ -1101,7 +1102,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1101 struct ubd *ubd_dev = disk->private_data; 1102 struct ubd *ubd_dev = disk->private_data;
1102 int err = 0; 1103 int err = 0;
1103 1104
1104 lock_kernel(); 1105 mutex_lock(&ubd_mutex);
1105 if(ubd_dev->count == 0){ 1106 if(ubd_dev->count == 0){
1106 err = ubd_open_dev(ubd_dev); 1107 err = ubd_open_dev(ubd_dev);
1107 if(err){ 1108 if(err){
@@ -1120,7 +1121,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1120 err = -EROFS; 1121 err = -EROFS;
1121 }*/ 1122 }*/
1122out: 1123out:
1123 unlock_kernel(); 1124 mutex_unlock(&ubd_mutex);
1124 return err; 1125 return err;
1125} 1126}
1126 1127
@@ -1128,10 +1129,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode)
1128{ 1129{
1129 struct ubd *ubd_dev = disk->private_data; 1130 struct ubd *ubd_dev = disk->private_data;
1130 1131
1131 lock_kernel(); 1132 mutex_lock(&ubd_mutex);
1132 if(--ubd_dev->count == 0) 1133 if(--ubd_dev->count == 0)
1133 ubd_close_dev(ubd_dev); 1134 ubd_close_dev(ubd_dev);
1134 unlock_kernel(); 1135 mutex_unlock(&ubd_mutex);
1135 return 0; 1136 return 0;
1136} 1137}
1137 1138
diff --git a/arch/um/include/asm/dma-mapping.h b/arch/um/include/asm/dma-mapping.h
deleted file mode 100644
index 1f469e80fdd3..000000000000
--- a/arch/um/include/asm/dma-mapping.h
+++ /dev/null
@@ -1,112 +0,0 @@
1#ifndef _ASM_DMA_MAPPING_H
2#define _ASM_DMA_MAPPING_H
3
4#include <asm/scatterlist.h>
5
6static inline int
7dma_supported(struct device *dev, u64 mask)
8{
9 BUG();
10 return(0);
11}
12
13static inline int
14dma_set_mask(struct device *dev, u64 dma_mask)
15{
16 BUG();
17 return(0);
18}
19
20static inline void *
21dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
22 gfp_t flag)
23{
24 BUG();
25 return((void *) 0);
26}
27
28static inline void
29dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
30 dma_addr_t dma_handle)
31{
32 BUG();
33}
34
35static inline dma_addr_t
36dma_map_single(struct device *dev, void *cpu_addr, size_t size,
37 enum dma_data_direction direction)
38{
39 BUG();
40 return(0);
41}
42
43static inline void
44dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
45 enum dma_data_direction direction)
46{
47 BUG();
48}
49
50static inline dma_addr_t
51dma_map_page(struct device *dev, struct page *page,
52 unsigned long offset, size_t size,
53 enum dma_data_direction direction)
54{
55 BUG();
56 return(0);
57}
58
59static inline void
60dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
61 enum dma_data_direction direction)
62{
63 BUG();
64}
65
66static inline int
67dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
68 enum dma_data_direction direction)
69{
70 BUG();
71 return(0);
72}
73
74static inline void
75dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
76 enum dma_data_direction direction)
77{
78 BUG();
79}
80
81static inline void
82dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
83 enum dma_data_direction direction)
84{
85 BUG();
86}
87
88static inline void
89dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
90 enum dma_data_direction direction)
91{
92 BUG();
93}
94
95#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
96#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
97
98static inline void
99dma_cache_sync(struct device *dev, void *vaddr, size_t size,
100 enum dma_data_direction direction)
101{
102 BUG();
103}
104
105static inline int
106dma_mapping_error(struct device *dev, dma_addr_t dma_handle)
107{
108 BUG();
109 return 0;
110}
111
112#endif
diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
index a9f7251b4a8d..41474fb5eee7 100644
--- a/arch/um/include/asm/pgtable.h
+++ b/arch/um/include/asm/pgtable.h
@@ -338,9 +338,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
338 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address)) 338 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
339#define pte_offset_map(dir, address) \ 339#define pte_offset_map(dir, address) \
340 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address)) 340 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
341#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
342#define pte_unmap(pte) do { } while (0) 341#define pte_unmap(pte) do { } while (0)
343#define pte_unmap_nested(pte) do { } while (0)
344 342
345struct mm_struct; 343struct mm_struct;
346extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr); 344extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h
index 2cd899f75a3c..b7c5bab9bd77 100644
--- a/arch/um/include/asm/ptrace-generic.h
+++ b/arch/um/include/asm/ptrace-generic.h
@@ -38,8 +38,8 @@ struct pt_regs {
38 38
39struct task_struct; 39struct task_struct;
40 40
41extern long subarch_ptrace(struct task_struct *child, long request, long addr, 41extern long subarch_ptrace(struct task_struct *child, long request,
42 long data); 42 unsigned long addr, unsigned long data);
43extern unsigned long getreg(struct task_struct *child, int regno); 43extern unsigned long getreg(struct task_struct *child, int regno);
44extern int putreg(struct task_struct *child, int regno, unsigned long value); 44extern int putreg(struct task_struct *child, int regno, unsigned long value);
45extern int get_fpregs(struct user_i387_struct __user *buf, 45extern int get_fpregs(struct user_i387_struct __user *buf,
diff --git a/arch/um/include/asm/system.h b/arch/um/include/asm/system.h
index 93af1cf0907d..68a90ecd1450 100644
--- a/arch/um/include/asm/system.h
+++ b/arch/um/include/asm/system.h
@@ -8,23 +8,38 @@ extern int set_signals(int enable);
8extern void block_signals(void); 8extern void block_signals(void);
9extern void unblock_signals(void); 9extern void unblock_signals(void);
10 10
11#define local_save_flags(flags) do { typecheck(unsigned long, flags); \ 11static inline unsigned long arch_local_save_flags(void)
12 (flags) = get_signals(); } while(0) 12{
13#define local_irq_restore(flags) do { typecheck(unsigned long, flags); \ 13 return get_signals();
14 set_signals(flags); } while(0) 14}
15 15
16#define local_irq_save(flags) do { local_save_flags(flags); \ 16static inline void arch_local_irq_restore(unsigned long flags)
17 local_irq_disable(); } while(0) 17{
18 18 set_signals(flags);
19#define local_irq_enable() unblock_signals() 19}
20#define local_irq_disable() block_signals() 20
21 21static inline void arch_local_irq_enable(void)
22#define irqs_disabled() \ 22{
23({ \ 23 unblock_signals();
24 unsigned long flags; \ 24}
25 local_save_flags(flags); \ 25
26 (flags == 0); \ 26static inline void arch_local_irq_disable(void)
27}) 27{
28 block_signals();
29}
30
31static inline unsigned long arch_local_irq_save(void)
32{
33 unsigned long flags;
34 flags = arch_local_save_flags();
35 arch_local_irq_disable();
36 return flags;
37}
38
39static inline bool arch_irqs_disabled(void)
40{
41 return arch_local_save_flags() == 0;
42}
28 43
29extern void *_switch_to(void *prev, void *next, void *last); 44extern void *_switch_to(void *prev, void *next, void *last);
30#define switch_to(prev, next, last) prev = _switch_to(prev, next, last) 45#define switch_to(prev, next, last) prev = _switch_to(prev, next, last)
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 69268014dd8e..a3cab6d3ae02 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -50,8 +50,18 @@ SECTIONS
50 .rela.got : { *(.rela.got) } 50 .rela.got : { *(.rela.got) }
51 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } 51 .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
52 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } 52 .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
53 .rel.plt : { *(.rel.plt) } 53 .rel.plt : {
54 .rela.plt : { *(.rela.plt) } 54 *(.rel.plt)
55 PROVIDE_HIDDEN(__rel_iplt_start = .);
56 *(.rel.iplt)
57 PROVIDE_HIDDEN(__rel_iplt_end = .);
58 }
59 .rela.plt : {
60 *(.rela.plt)
61 PROVIDE_HIDDEN(__rela_iplt_start = .);
62 *(.rela.iplt)
63 PROVIDE_HIDDEN(__rela_iplt_end = .);
64 }
55 .init : { 65 .init : {
56 KEEP (*(.init)) 66 KEEP (*(.init))
57 } =0x90909090 67 } =0x90909090
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 a746e3037a5b..3f0ac9e0c966 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -334,7 +334,7 @@ unsigned int do_IRQ(int irq, struct uml_pt_regs *regs)
334{ 334{
335 struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)regs); 335 struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)regs);
336 irq_enter(); 336 irq_enter();
337 __do_IRQ(irq); 337 generic_handle_irq(irq);
338 irq_exit(); 338 irq_exit();
339 set_irq_regs(old_regs); 339 set_irq_regs(old_regs);
340 return 1; 340 return 1;
@@ -391,17 +391,10 @@ void __init init_IRQ(void)
391{ 391{
392 int i; 392 int i;
393 393
394 irq_desc[TIMER_IRQ].status = IRQ_DISABLED; 394 set_irq_chip_and_handler(TIMER_IRQ, &SIGVTALRM_irq_type, handle_edge_irq);
395 irq_desc[TIMER_IRQ].action = NULL; 395
396 irq_desc[TIMER_IRQ].depth = 1;
397 irq_desc[TIMER_IRQ].chip = &SIGVTALRM_irq_type;
398 enable_irq(TIMER_IRQ);
399 for (i = 1; i < NR_IRQS; i++) { 396 for (i = 1; i < NR_IRQS; i++) {
400 irq_desc[i].status = IRQ_DISABLED; 397 set_irq_chip_and_handler(i, &normal_irq_type, handle_edge_irq);
401 irq_desc[i].action = NULL;
402 irq_desc[i].depth = 1;
403 irq_desc[i].chip = &normal_irq_type;
404 enable_irq(i);
405 } 398 }
406} 399}
407 400
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index e0510496596c..701b672c1122 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -42,10 +42,12 @@ void ptrace_disable(struct task_struct *child)
42extern int peek_user(struct task_struct * child, long addr, long data); 42extern int peek_user(struct task_struct * child, long addr, long data);
43extern int poke_user(struct task_struct * child, long addr, long data); 43extern int poke_user(struct task_struct * child, long addr, long data);
44 44
45long arch_ptrace(struct task_struct *child, long request, long addr, long data) 45long arch_ptrace(struct task_struct *child, long request,
46 unsigned long addr, unsigned long data)
46{ 47{
47 int i, ret; 48 int i, ret;
48 unsigned long __user *p = (void __user *)(unsigned long)data; 49 unsigned long __user *p = (void __user *)data;
50 void __user *vp = p;
49 51
50 switch (request) { 52 switch (request) {
51 /* read word at location addr. */ 53 /* read word at location addr. */
@@ -107,24 +109,20 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
107#endif 109#endif
108#ifdef PTRACE_GETFPREGS 110#ifdef PTRACE_GETFPREGS
109 case PTRACE_GETFPREGS: /* Get the child FPU state. */ 111 case PTRACE_GETFPREGS: /* Get the child FPU state. */
110 ret = get_fpregs((struct user_i387_struct __user *) data, 112 ret = get_fpregs(vp, child);
111 child);
112 break; 113 break;
113#endif 114#endif
114#ifdef PTRACE_SETFPREGS 115#ifdef PTRACE_SETFPREGS
115 case PTRACE_SETFPREGS: /* Set the child FPU state. */ 116 case PTRACE_SETFPREGS: /* Set the child FPU state. */
116 ret = set_fpregs((struct user_i387_struct __user *) data, 117 ret = set_fpregs(vp, child);
117 child);
118 break; 118 break;
119#endif 119#endif
120 case PTRACE_GET_THREAD_AREA: 120 case PTRACE_GET_THREAD_AREA:
121 ret = ptrace_get_thread_area(child, addr, 121 ret = ptrace_get_thread_area(child, addr, vp);
122 (struct user_desc __user *) data);
123 break; 122 break;
124 123
125 case PTRACE_SET_THREAD_AREA: 124 case PTRACE_SET_THREAD_AREA:
126 ret = ptrace_set_thread_area(child, addr, 125 ret = ptrace_set_thread_area(child, addr, vp);
127 (struct user_desc __user *) data);
128 break; 126 break;
129 127
130 case PTRACE_FAULTINFO: { 128 case PTRACE_FAULTINFO: {
@@ -134,7 +132,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
134 * On i386, ptrace_faultinfo is smaller! 132 * On i386, ptrace_faultinfo is smaller!
135 */ 133 */
136 ret = copy_to_user(p, &child->thread.arch.faultinfo, 134 ret = copy_to_user(p, &child->thread.arch.faultinfo,
137 sizeof(struct ptrace_faultinfo)); 135 sizeof(struct ptrace_faultinfo)) ?
136 -EIO : 0;
138 break; 137 break;
139 } 138 }
140 139
@@ -158,7 +157,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
158#ifdef PTRACE_ARCH_PRCTL 157#ifdef PTRACE_ARCH_PRCTL
159 case PTRACE_ARCH_PRCTL: 158 case PTRACE_ARCH_PRCTL:
160 /* XXX Calls ptrace on the host - needs some SMP thinking */ 159 /* XXX Calls ptrace on the host - needs some SMP thinking */
161 ret = arch_prctl(child, data, (void *) addr); 160 ret = arch_prctl(child, data, (void __user *) addr);
162 break; 161 break;
163#endif 162#endif
164 default: 163 default:
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index ec6378550671..fbd99402d4d2 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -22,7 +22,7 @@ SECTIONS
22 _text = .; 22 _text = .;
23 _stext = .; 23 _stext = .;
24 __init_begin = .; 24 __init_begin = .;
25 INIT_TEXT_SECTION(PAGE_SIZE) 25 INIT_TEXT_SECTION(0)
26 . = ALIGN(PAGE_SIZE); 26 . = ALIGN(PAGE_SIZE);
27 27
28 .text : 28 .text :
@@ -43,6 +43,23 @@ SECTIONS
43 __syscall_stub_end = .; 43 __syscall_stub_end = .;
44 } 44 }
45 45
46 /*
47 * These are needed even in a static link, even if they wind up being empty.
48 * Newer glibc needs these __rel{,a}_iplt_{start,end} symbols.
49 */
50 .rel.plt : {
51 *(.rel.plt)
52 PROVIDE_HIDDEN(__rel_iplt_start = .);
53 *(.rel.iplt)
54 PROVIDE_HIDDEN(__rel_iplt_end = .);
55 }
56 .rela.plt : {
57 *(.rela.plt)
58 PROVIDE_HIDDEN(__rela_iplt_start = .);
59 *(.rela.iplt)
60 PROVIDE_HIDDEN(__rela_iplt_end = .);
61 }
62
46 #include "asm/common.lds.S" 63 #include "asm/common.lds.S"
47 64
48 init.data : { INIT_DATA } 65 init.data : { INIT_DATA }
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index dec5678fc17f..6e3359d6a839 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -60,7 +60,7 @@ static inline long long timeval_to_ns(const struct timeval *tv)
60long long disable_timer(void) 60long long disable_timer(void)
61{ 61{
62 struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } }); 62 struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
63 int remain, max = UM_NSEC_PER_SEC / UM_HZ; 63 long long remain, max = UM_NSEC_PER_SEC / UM_HZ;
64 64
65 if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0) 65 if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
66 printk(UM_KERN_ERR "disable_timer - setitimer failed, " 66 printk(UM_KERN_ERR "disable_timer - setitimer failed, "
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index c9b176534d65..d23b2d3ea384 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -203,8 +203,8 @@ int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
203 (unsigned long *) &fpregs); 203 (unsigned long *) &fpregs);
204} 204}
205 205
206long subarch_ptrace(struct task_struct *child, long request, long addr, 206long subarch_ptrace(struct task_struct *child, long request,
207 long data) 207 unsigned long addr, unsigned long data)
208{ 208{
209 return -EIO; 209 return -EIO;
210} 210}
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index f3458d7d1c5a..f43613643cdb 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -175,19 +175,18 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
175 return restore_fp_registers(userspace_pid[cpu], fpregs); 175 return restore_fp_registers(userspace_pid[cpu], fpregs);
176} 176}
177 177
178long subarch_ptrace(struct task_struct *child, long request, long addr, 178long subarch_ptrace(struct task_struct *child, long request,
179 long data) 179 unsigned long addr, unsigned long data)
180{ 180{
181 int ret = -EIO; 181 int ret = -EIO;
182 void __user *datap = (void __user *) data;
182 183
183 switch (request) { 184 switch (request) {
184 case PTRACE_GETFPXREGS: /* Get the child FPU state. */ 185 case PTRACE_GETFPXREGS: /* Get the child FPU state. */
185 ret = get_fpregs((struct user_i387_struct __user *) data, 186 ret = get_fpregs(datap, child);
186 child);
187 break; 187 break;
188 case PTRACE_SETFPXREGS: /* Set the child FPU state. */ 188 case PTRACE_SETFPXREGS: /* Set the child FPU state. */
189 ret = set_fpregs((struct user_i387_struct __user *) data, 189 ret = set_fpregs(datap, child);
190 child);
191 break; 190 break;
192 } 191 }
193 192
diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index ad8ec356fb36..0e103236b754 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -14,3 +14,4 @@ obj-y += crypto/
14obj-y += vdso/ 14obj-y += vdso/
15obj-$(CONFIG_IA32_EMULATION) += ia32/ 15obj-$(CONFIG_IA32_EMULATION) += ia32/
16 16
17obj-y += platform/
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index dfabfefc21c4..08993a38b119 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1,6 +1,3 @@
1# x86 configuration
2mainmenu "Linux Kernel Configuration for x86"
3
4# Select 32 or 64 bit 1# Select 32 or 64 bit
5config 64BIT 2config 64BIT
6 bool "64-bit kernel" if ARCH = "x86" 3 bool "64-bit kernel" if ARCH = "x86"
@@ -347,6 +344,7 @@ endif
347 344
348config X86_VSMP 345config X86_VSMP
349 bool "ScaleMP vSMP" 346 bool "ScaleMP vSMP"
347 select PARAVIRT_GUEST
350 select PARAVIRT 348 select PARAVIRT
351 depends on X86_64 && PCI 349 depends on X86_64 && PCI
352 depends on X86_EXTENDED_PLATFORM 350 depends on X86_EXTENDED_PLATFORM
@@ -1143,16 +1141,16 @@ config NUMA
1143comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI" 1141comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
1144 depends on X86_32 && X86_SUMMIT && (!HIGHMEM64G || !ACPI) 1142 depends on X86_32 && X86_SUMMIT && (!HIGHMEM64G || !ACPI)
1145 1143
1146config K8_NUMA 1144config AMD_NUMA
1147 def_bool y 1145 def_bool y
1148 prompt "Old style AMD Opteron NUMA detection" 1146 prompt "Old style AMD Opteron NUMA detection"
1149 depends on X86_64 && NUMA && PCI 1147 depends on X86_64 && NUMA && PCI
1150 ---help--- 1148 ---help---
1151 Enable K8 NUMA node topology detection. You should say Y here if 1149 Enable AMD NUMA node topology detection. You should say Y here if
1152 you have a multi processor AMD K8 system. This uses an old 1150 you have a multi processor AMD system. This uses an old method to
1153 method to read the NUMA configuration directly from the builtin 1151 read the NUMA configuration directly from the builtin Northbridge
1154 Northbridge of Opteron. It is recommended to use X86_64_ACPI_NUMA 1152 of Opteron. It is recommended to use X86_64_ACPI_NUMA instead,
1155 instead, which also takes priority if both are compiled in. 1153 which also takes priority if both are compiled in.
1156 1154
1157config X86_64_ACPI_NUMA 1155config X86_64_ACPI_NUMA
1158 def_bool y 1156 def_bool y
@@ -1895,6 +1893,11 @@ config PCI_OLPC
1895 def_bool y 1893 def_bool y
1896 depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY) 1894 depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY)
1897 1895
1896config PCI_XEN
1897 def_bool y
1898 depends on PCI && XEN
1899 select SWIOTLB_XEN
1900
1898config PCI_DOMAINS 1901config PCI_DOMAINS
1899 def_bool y 1902 def_bool y
1900 depends on PCI 1903 depends on PCI
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index e5bb96b10f1a..b59ee765414e 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -125,16 +125,6 @@ config DEBUG_NX_TEST
125 and the software setup of this feature. 125 and the software setup of this feature.
126 If in doubt, say "N" 126 If in doubt, say "N"
127 127
128config 4KSTACKS
129 bool "Use 4Kb for kernel stacks instead of 8Kb"
130 depends on X86_32
131 ---help---
132 If you say Y here the kernel will use a 4Kb stacksize for the
133 kernel stack attached to each process/thread. This facilitates
134 running more threads on a system and also reduces the pressure
135 on the VM subsystem for higher order allocations. This option
136 will also use IRQ stacks to compensate for the reduced stackspace.
137
138config DOUBLEFAULT 128config DOUBLEFAULT
139 default y 129 default y
140 bool "Enable doublefault exception handler" if EMBEDDED 130 bool "Enable doublefault exception handler" if EMBEDDED
diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu
index 1255d953c65d..f2ee1abb1df9 100644
--- a/arch/x86/Makefile_32.cpu
+++ b/arch/x86/Makefile_32.cpu
@@ -51,7 +51,18 @@ cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686))
51# prologue (push %ebp, mov %esp, %ebp) which breaks the function graph 51# prologue (push %ebp, mov %esp, %ebp) which breaks the function graph
52# tracer assumptions. For i686, generic, core2 this is set by the 52# tracer assumptions. For i686, generic, core2 this is set by the
53# compiler anyway 53# compiler anyway
54cflags-$(CONFIG_FUNCTION_GRAPH_TRACER) += $(call cc-option,-maccumulate-outgoing-args) 54ifeq ($(CONFIG_FUNCTION_GRAPH_TRACER), y)
55ADD_ACCUMULATE_OUTGOING_ARGS := y
56endif
57
58# Work around to a bug with asm goto with first implementations of it
59# in gcc causing gcc to mess up the push and pop of the stack in some
60# uses of asm goto.
61ifeq ($(CONFIG_JUMP_LABEL), y)
62ADD_ACCUMULATE_OUTGOING_ARGS := y
63endif
64
65cflags-$(ADD_ACCUMULATE_OUTGOING_ARGS) += $(call cc-option,-maccumulate-outgoing-args)
55 66
56# Bug fix for binutils: this option is required in order to keep 67# Bug fix for binutils: this option is required in order to keep
57# binutils from generating NOPL instructions against our will. 68# binutils from generating NOPL instructions against our will.
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/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 92091de11113..55d106b5e31b 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -93,6 +93,9 @@ extern u8 acpi_sci_flags;
93extern int acpi_sci_override_gsi; 93extern int acpi_sci_override_gsi;
94void acpi_pic_sci_set_trigger(unsigned int, u16); 94void acpi_pic_sci_set_trigger(unsigned int, u16);
95 95
96extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
97 int trigger, int polarity);
98
96static inline void disable_acpi(void) 99static inline void disable_acpi(void)
97{ 100{
98 acpi_disabled = 1; 101 acpi_disabled = 1;
diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
index c8517f81b21e..6aee50d655d1 100644
--- a/arch/x86/include/asm/amd_nb.h
+++ b/arch/x86/include/asm/amd_nb.h
@@ -3,36 +3,53 @@
3 3
4#include <linux/pci.h> 4#include <linux/pci.h>
5 5
6extern struct pci_device_id k8_nb_ids[]; 6extern struct pci_device_id amd_nb_misc_ids[];
7struct bootnode; 7struct bootnode;
8 8
9extern int early_is_k8_nb(u32 value); 9extern int early_is_amd_nb(u32 value);
10extern int cache_k8_northbridges(void); 10extern int amd_cache_northbridges(void);
11extern void k8_flush_garts(void); 11extern void amd_flush_garts(void);
12extern int k8_get_nodes(struct bootnode *nodes); 12extern int amd_get_nodes(struct bootnode *nodes);
13extern int k8_numa_init(unsigned long start_pfn, unsigned long end_pfn); 13extern int amd_numa_init(unsigned long start_pfn, unsigned long end_pfn);
14extern int k8_scan_nodes(void); 14extern int amd_scan_nodes(void);
15 15
16struct k8_northbridge_info { 16struct amd_northbridge {
17 struct pci_dev *misc;
18};
19
20struct amd_northbridge_info {
17 u16 num; 21 u16 num;
18 u8 gart_supported; 22 u64 flags;
19 struct pci_dev **nb_misc; 23 struct amd_northbridge *nb;
20}; 24};
21extern struct k8_northbridge_info k8_northbridges; 25extern struct amd_northbridge_info amd_northbridges;
26
27#define AMD_NB_GART 0x1
28#define AMD_NB_L3_INDEX_DISABLE 0x2
22 29
23#ifdef CONFIG_AMD_NB 30#ifdef CONFIG_AMD_NB
24 31
25static inline struct pci_dev *node_to_k8_nb_misc(int node) 32static inline int amd_nb_num(void)
26{ 33{
27 return (node < k8_northbridges.num) ? k8_northbridges.nb_misc[node] : NULL; 34 return amd_northbridges.num;
28} 35}
29 36
30#else 37static inline int amd_nb_has_feature(int feature)
38{
39 return ((amd_northbridges.flags & feature) == feature);
40}
31 41
32static inline struct pci_dev *node_to_k8_nb_misc(int node) 42static inline struct amd_northbridge *node_to_amd_nb(int node)
33{ 43{
34 return NULL; 44 return (node < amd_northbridges.num) ? &amd_northbridges.nb[node] : NULL;
35} 45}
46
47#else
48
49#define amd_nb_num(x) 0
50#define amd_nb_has_feature(x) false
51#define node_to_amd_nb(x) NULL
52
36#endif 53#endif
37 54
38 55
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index ad50aaae396f..cf12007796db 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -141,13 +141,13 @@ static inline void native_apic_msr_write(u32 reg, u32 v)
141 141
142static inline u32 native_apic_msr_read(u32 reg) 142static inline u32 native_apic_msr_read(u32 reg)
143{ 143{
144 u32 low, high; 144 u64 msr;
145 145
146 if (reg == APIC_DFR) 146 if (reg == APIC_DFR)
147 return -1; 147 return -1;
148 148
149 rdmsr(APIC_BASE_MSR + (reg >> 4), low, high); 149 rdmsrl(APIC_BASE_MSR + (reg >> 4), msr);
150 return low; 150 return (u32)msr;
151} 151}
152 152
153static inline void native_x2apic_wait_icr_idle(void) 153static inline void native_x2apic_wait_icr_idle(void)
@@ -181,12 +181,12 @@ extern void enable_x2apic(void);
181extern void x2apic_icr_write(u32 low, u32 id); 181extern void x2apic_icr_write(u32 low, u32 id);
182static inline int x2apic_enabled(void) 182static inline int x2apic_enabled(void)
183{ 183{
184 int msr, msr2; 184 u64 msr;
185 185
186 if (!cpu_has_x2apic) 186 if (!cpu_has_x2apic)
187 return 0; 187 return 0;
188 188
189 rdmsr(MSR_IA32_APICBASE, msr, msr2); 189 rdmsrl(MSR_IA32_APICBASE, msr);
190 if (msr & X2APIC_ENABLE) 190 if (msr & X2APIC_ENABLE)
191 return 1; 191 return 1;
192 return 0; 192 return 0;
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/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/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index b8e96a18676b..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)
diff --git a/arch/x86/include/asm/highmem.h b/arch/x86/include/asm/highmem.h
index 8caac76ac324..3bd04022fd0c 100644
--- a/arch/x86/include/asm/highmem.h
+++ b/arch/x86/include/asm/highmem.h
@@ -59,11 +59,12 @@ extern void kunmap_high(struct page *page);
59 59
60void *kmap(struct page *page); 60void *kmap(struct page *page);
61void kunmap(struct page *page); 61void kunmap(struct page *page);
62void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot); 62
63void *kmap_atomic(struct page *page, enum km_type type); 63void *kmap_atomic_prot(struct page *page, pgprot_t prot);
64void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type); 64void *__kmap_atomic(struct page *page);
65void *kmap_atomic_pfn(unsigned long pfn, enum km_type type); 65void __kunmap_atomic(void *kvaddr);
66void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); 66void *kmap_atomic_pfn(unsigned long pfn);
67void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot);
67struct page *kmap_atomic_to_page(void *ptr); 68struct page *kmap_atomic_to_page(void *ptr);
68 69
69#define flush_cache_kmaps() do { } while (0) 70#define flush_cache_kmaps() do { } while (0)
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index f0203f4791a8..072273082528 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -41,6 +41,8 @@
41#include <asm-generic/int-ll64.h> 41#include <asm-generic/int-ll64.h>
42#include <asm/page.h> 42#include <asm/page.h>
43 43
44#include <xen/xen.h>
45
44#define build_mmio_read(name, size, type, reg, barrier) \ 46#define build_mmio_read(name, size, type, reg, barrier) \
45static inline type name(const volatile void __iomem *addr) \ 47static inline type name(const volatile void __iomem *addr) \
46{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \ 48{ type ret; asm volatile("mov" size " %1,%0":reg (ret) \
@@ -351,6 +353,17 @@ extern void early_iounmap(void __iomem *addr, unsigned long size);
351extern void fixup_early_ioremap(void); 353extern void fixup_early_ioremap(void);
352extern bool is_early_ioremap_ptep(pte_t *ptep); 354extern bool is_early_ioremap_ptep(pte_t *ptep);
353 355
356#ifdef CONFIG_XEN
357struct bio_vec;
358
359extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
360 const struct bio_vec *vec2);
361
362#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
363 (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
364 (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
365#endif /* CONFIG_XEN */
366
354#define IO_SPACE_LIMIT 0xffff 367#define IO_SPACE_LIMIT 0xffff
355 368
356#endif /* _ASM_X86_IO_H */ 369#endif /* _ASM_X86_IO_H */
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index d7d46cb53e52..107f2d8c6570 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -168,6 +168,8 @@ extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
168extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 168extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
169extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries); 169extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
170 170
171extern int get_nr_irqs_gsi(void);
172
171extern void setup_ioapic_ids_from_mpc(void); 173extern void setup_ioapic_ids_from_mpc(void);
172extern void setup_ioapic_ids_from_mpc_nocheck(void); 174extern void setup_ioapic_ids_from_mpc_nocheck(void);
173 175
diff --git a/arch/x86/include/asm/iomap.h b/arch/x86/include/asm/iomap.h
index c4191b3b7056..363e33eb6ec1 100644
--- a/arch/x86/include/asm/iomap.h
+++ b/arch/x86/include/asm/iomap.h
@@ -27,10 +27,10 @@
27#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
28 28
29void __iomem * 29void __iomem *
30iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); 30iomap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot);
31 31
32void 32void
33iounmap_atomic(void __iomem *kvaddr, enum km_type type); 33iounmap_atomic(void __iomem *kvaddr);
34 34
35int 35int
36iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot); 36iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot);
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 5458380b6ef8..13b0ebaa512f 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -19,18 +19,14 @@ 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);
25# define __ARCH_HAS_DO_SOFTIRQ
26#else 24#else
27# define irq_ctx_init(cpu) do { } while (0) 25# define irq_ctx_init(cpu) do { } while (0)
28# define irq_ctx_exit(cpu) do { } while (0)
29# ifdef CONFIG_X86_64
30# define __ARCH_HAS_DO_SOFTIRQ
31# endif
32#endif 26#endif
33 27
28#define __ARCH_HAS_DO_SOFTIRQ
29
34#ifdef CONFIG_HOTPLUG_CPU 30#ifdef CONFIG_HOTPLUG_CPU
35#include <linux/cpumask.h> 31#include <linux/cpumask.h>
36extern void fixup_irqs(void); 32extern void fixup_irqs(void);
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 c52e2eb40a1e..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);
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/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/msr-index.h b/arch/x86/include/asm/msr-index.h
index 986f7790fdb2..3ea3dc487047 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -121,6 +121,7 @@
121#define MSR_AMD64_IBSDCLINAD 0xc0011038 121#define MSR_AMD64_IBSDCLINAD 0xc0011038
122#define MSR_AMD64_IBSDCPHYSAD 0xc0011039 122#define MSR_AMD64_IBSDCPHYSAD 0xc0011039
123#define MSR_AMD64_IBSCTL 0xc001103a 123#define MSR_AMD64_IBSCTL 0xc001103a
124#define MSR_AMD64_IBSBRTARGET 0xc001103b
124 125
125/* Fam 10h MSRs */ 126/* Fam 10h MSRs */
126#define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058 127#define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058
@@ -198,6 +199,7 @@
198#define MSR_IA32_TSC 0x00000010 199#define MSR_IA32_TSC 0x00000010
199#define MSR_IA32_PLATFORM_ID 0x00000017 200#define MSR_IA32_PLATFORM_ID 0x00000017
200#define MSR_IA32_EBL_CR_POWERON 0x0000002a 201#define MSR_IA32_EBL_CR_POWERON 0x0000002a
202#define MSR_EBC_FREQUENCY_ID 0x0000002c
201#define MSR_IA32_FEATURE_CONTROL 0x0000003a 203#define MSR_IA32_FEATURE_CONTROL 0x0000003a
202 204
203#define FEATURE_CONTROL_LOCKED (1<<0) 205#define FEATURE_CONTROL_LOCKED (1<<0)
diff --git a/arch/x86/include/asm/olpc.h b/arch/x86/include/asm/olpc.h
index 101229b0d8ed..42a978c0c1b3 100644
--- a/arch/x86/include/asm/olpc.h
+++ b/arch/x86/include/asm/olpc.h
@@ -89,6 +89,8 @@ extern int olpc_ec_mask_unset(uint8_t bits);
89/* EC commands */ 89/* EC commands */
90 90
91#define EC_FIRMWARE_REV 0x08 91#define EC_FIRMWARE_REV 0x08
92#define EC_WLAN_ENTER_RESET 0x35
93#define EC_WLAN_LEAVE_RESET 0x25
92 94
93/* SCI source values */ 95/* SCI source values */
94 96
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/pci.h b/arch/x86/include/asm/pci.h
index d395540ff894..ca0437c714b2 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -7,6 +7,7 @@
7#include <linux/string.h> 7#include <linux/string.h>
8#include <asm/scatterlist.h> 8#include <asm/scatterlist.h>
9#include <asm/io.h> 9#include <asm/io.h>
10#include <asm/x86_init.h>
10 11
11#ifdef __KERNEL__ 12#ifdef __KERNEL__
12 13
@@ -94,8 +95,36 @@ static inline void early_quirks(void) { }
94 95
95extern void pci_iommu_alloc(void); 96extern void pci_iommu_alloc(void);
96 97
97/* MSI arch hook */ 98#ifdef CONFIG_PCI_MSI
98#define arch_setup_msi_irqs arch_setup_msi_irqs 99/* MSI arch specific hooks */
100static inline int x86_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
101{
102 return x86_msi.setup_msi_irqs(dev, nvec, type);
103}
104
105static inline void x86_teardown_msi_irqs(struct pci_dev *dev)
106{
107 x86_msi.teardown_msi_irqs(dev);
108}
109
110static inline void x86_teardown_msi_irq(unsigned int irq)
111{
112 x86_msi.teardown_msi_irq(irq);
113}
114#define arch_setup_msi_irqs x86_setup_msi_irqs
115#define arch_teardown_msi_irqs x86_teardown_msi_irqs
116#define arch_teardown_msi_irq x86_teardown_msi_irq
117/* implemented in arch/x86/kernel/apic/io_apic. */
118int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
119void native_teardown_msi_irq(unsigned int irq);
120/* default to the implementation in drivers/lib/msi.c */
121#define HAVE_DEFAULT_MSI_TEARDOWN_IRQS
122void default_teardown_msi_irqs(struct pci_dev *dev);
123#else
124#define native_setup_msi_irqs NULL
125#define native_teardown_msi_irq NULL
126#define default_teardown_msi_irqs NULL
127#endif
99 128
100#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) 129#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
101 130
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h
index 49c7219826f9..704526734bef 100644
--- a/arch/x86/include/asm/pci_x86.h
+++ b/arch/x86/include/asm/pci_x86.h
@@ -47,6 +47,7 @@ enum pci_bf_sort_state {
47extern unsigned int pcibios_max_latency; 47extern unsigned int pcibios_max_latency;
48 48
49void pcibios_resource_survey(void); 49void pcibios_resource_survey(void);
50void pcibios_set_cache_line_size(void);
50 51
51/* pci-pc.c */ 52/* pci-pc.c */
52 53
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.h b/arch/x86/include/asm/perf_event.h
index 6e742cc4251b..550e26b1dbb3 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -111,17 +111,18 @@ union cpuid10_edx {
111#define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16) 111#define X86_PMC_IDX_FIXED_BTS (X86_PMC_IDX_FIXED + 16)
112 112
113/* IbsFetchCtl bits/masks */ 113/* IbsFetchCtl bits/masks */
114#define IBS_FETCH_RAND_EN (1ULL<<57) 114#define IBS_FETCH_RAND_EN (1ULL<<57)
115#define IBS_FETCH_VAL (1ULL<<49) 115#define IBS_FETCH_VAL (1ULL<<49)
116#define IBS_FETCH_ENABLE (1ULL<<48) 116#define IBS_FETCH_ENABLE (1ULL<<48)
117#define IBS_FETCH_CNT 0xFFFF0000ULL 117#define IBS_FETCH_CNT 0xFFFF0000ULL
118#define IBS_FETCH_MAX_CNT 0x0000FFFFULL 118#define IBS_FETCH_MAX_CNT 0x0000FFFFULL
119 119
120/* IbsOpCtl bits */ 120/* IbsOpCtl bits */
121#define IBS_OP_CNT_CTL (1ULL<<19) 121#define IBS_OP_CNT_CTL (1ULL<<19)
122#define IBS_OP_VAL (1ULL<<18) 122#define IBS_OP_VAL (1ULL<<18)
123#define IBS_OP_ENABLE (1ULL<<17) 123#define IBS_OP_ENABLE (1ULL<<17)
124#define IBS_OP_MAX_CNT 0x0000FFFFULL 124#define IBS_OP_MAX_CNT 0x0000FFFFULL
125#define IBS_OP_MAX_CNT_EXT 0x007FFFFFULL /* not a register bit mask */
125 126
126#ifdef CONFIG_PERF_EVENTS 127#ifdef CONFIG_PERF_EVENTS
127extern void init_hw_perf_events(void); 128extern void init_hw_perf_events(void);
diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
index f686f49e8b7b..0c92113c4cb6 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) { }
@@ -49,24 +49,14 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
49#endif 49#endif
50 50
51#if defined(CONFIG_HIGHPTE) 51#if defined(CONFIG_HIGHPTE)
52#define __KM_PTE \
53 (in_nmi() ? KM_NMI_PTE : \
54 in_irq() ? KM_IRQ_PTE : \
55 KM_PTE0)
56#define pte_offset_map(dir, address) \ 52#define pte_offset_map(dir, address) \
57 ((pte_t *)kmap_atomic(pmd_page(*(dir)), __KM_PTE) + \ 53 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
58 pte_index((address))) 54 pte_index((address)))
59#define pte_offset_map_nested(dir, address) \ 55#define pte_unmap(pte) kunmap_atomic((pte))
60 ((pte_t *)kmap_atomic(pmd_page(*(dir)), KM_PTE1) + \
61 pte_index((address)))
62#define pte_unmap(pte) kunmap_atomic((pte), __KM_PTE)
63#define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
64#else 56#else
65#define pte_offset_map(dir, address) \ 57#define pte_offset_map(dir, address) \
66 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address))) 58 ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
67#define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
68#define pte_unmap(pte) do { } while (0) 59#define pte_unmap(pte) do { } while (0)
69#define pte_unmap_nested(pte) do { } while (0)
70#endif 60#endif
71 61
72/* Clear a kernel PTE and flush it from the TLB */ 62/* Clear a kernel PTE and flush it from the TLB */
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index f96ac9bedf75..f86da20347f2 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -127,9 +127,7 @@ static inline int pgd_large(pgd_t pgd) { return 0; }
127 127
128/* x86-64 always has all page tables mapped. */ 128/* x86-64 always has all page tables mapped. */
129#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address)) 129#define pte_offset_map(dir, address) pte_offset_kernel((dir), (address))
130#define pte_offset_map_nested(dir, address) pte_offset_kernel((dir), (address))
131#define pte_unmap(pte) ((void)(pte))/* NOP */ 130#define pte_unmap(pte) ((void)(pte))/* NOP */
132#define pte_unmap_nested(pte) ((void)(pte)) /* NOP */
133 131
134#define update_mmu_cache(vma, address, ptep) do { } while (0) 132#define update_mmu_cache(vma, address, ptep) do { } while (0)
135 133
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/smp.h b/arch/x86/include/asm/smp.h
index 4cfc90824068..4c2f63c7fc1b 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -50,7 +50,7 @@ struct smp_ops {
50 void (*smp_prepare_cpus)(unsigned max_cpus); 50 void (*smp_prepare_cpus)(unsigned max_cpus);
51 void (*smp_cpus_done)(unsigned max_cpus); 51 void (*smp_cpus_done)(unsigned max_cpus);
52 52
53 void (*smp_send_stop)(void); 53 void (*stop_other_cpus)(int wait);
54 void (*smp_send_reschedule)(int cpu); 54 void (*smp_send_reschedule)(int cpu);
55 55
56 int (*cpu_up)(unsigned cpu); 56 int (*cpu_up)(unsigned cpu);
@@ -73,7 +73,12 @@ extern struct smp_ops smp_ops;
73 73
74static inline void smp_send_stop(void) 74static inline void smp_send_stop(void)
75{ 75{
76 smp_ops.smp_send_stop(); 76 smp_ops.stop_other_cpus(0);
77}
78
79static inline void stop_other_cpus(void)
80{
81 smp_ops.stop_other_cpus(1);
77} 82}
78 83
79static inline void smp_prepare_boot_cpu(void) 84static inline void smp_prepare_boot_cpu(void)
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/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
index bf6b88ef8eeb..e969f691cbfd 100644
--- a/arch/x86/include/asm/uv/uv_hub.h
+++ b/arch/x86/include/asm/uv/uv_hub.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * SGI UV architectural definitions 6 * SGI UV architectural definitions
7 * 7 *
8 * Copyright (C) 2007-2008 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2007-2010 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10 10
11#ifndef _ASM_X86_UV_UV_HUB_H 11#ifndef _ASM_X86_UV_UV_HUB_H
@@ -77,7 +77,8 @@
77 * 77 *
78 * 1111110000000000 78 * 1111110000000000
79 * 5432109876543210 79 * 5432109876543210
80 * pppppppppplc0cch 80 * pppppppppplc0cch Nehalem-EX
81 * ppppppppplcc0cch Westmere-EX
81 * sssssssssss 82 * sssssssssss
82 * 83 *
83 * p = pnode bits 84 * p = pnode bits
@@ -148,12 +149,25 @@ struct uv_hub_info_s {
148 unsigned char m_val; 149 unsigned char m_val;
149 unsigned char n_val; 150 unsigned char n_val;
150 struct uv_scir_s scir; 151 struct uv_scir_s scir;
152 unsigned char apic_pnode_shift;
151}; 153};
152 154
153DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info); 155DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
154#define uv_hub_info (&__get_cpu_var(__uv_hub_info)) 156#define uv_hub_info (&__get_cpu_var(__uv_hub_info))
155#define uv_cpu_hub_info(cpu) (&per_cpu(__uv_hub_info, cpu)) 157#define uv_cpu_hub_info(cpu) (&per_cpu(__uv_hub_info, cpu))
156 158
159union uvh_apicid {
160 unsigned long v;
161 struct uvh_apicid_s {
162 unsigned long local_apic_mask : 24;
163 unsigned long local_apic_shift : 5;
164 unsigned long unused1 : 3;
165 unsigned long pnode_mask : 24;
166 unsigned long pnode_shift : 5;
167 unsigned long unused2 : 3;
168 } s;
169};
170
157/* 171/*
158 * Local & Global MMR space macros. 172 * Local & Global MMR space macros.
159 * Note: macros are intended to be used ONLY by inline functions 173 * Note: macros are intended to be used ONLY by inline functions
@@ -182,6 +196,7 @@ DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
182#define UV_GLOBAL_MMR64_PNODE_BITS(p) \ 196#define UV_GLOBAL_MMR64_PNODE_BITS(p) \
183 (((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT) 197 (((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT)
184 198
199#define UVH_APICID 0x002D0E00L
185#define UV_APIC_PNODE_SHIFT 6 200#define UV_APIC_PNODE_SHIFT 6
186 201
187/* Local Bus from cpu's perspective */ 202/* Local Bus from cpu's perspective */
@@ -280,7 +295,7 @@ static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offset)
280 */ 295 */
281static inline int uv_apicid_to_pnode(int apicid) 296static inline int uv_apicid_to_pnode(int apicid)
282{ 297{
283 return (apicid >> UV_APIC_PNODE_SHIFT); 298 return (apicid >> uv_hub_info->apic_pnode_shift);
284} 299}
285 300
286/* 301/*
diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h
index b2f2d2e05cec..6d90adf4428a 100644
--- a/arch/x86/include/asm/uv/uv_mmrs.h
+++ b/arch/x86/include/asm/uv/uv_mmrs.h
@@ -806,6 +806,78 @@ union uvh_node_present_table_u {
806}; 806};
807 807
808/* ========================================================================= */ 808/* ========================================================================= */
809/* UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR */
810/* ========================================================================= */
811#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR 0x16000c8UL
812
813#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_BASE_SHFT 24
814#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_BASE_MASK 0x00000000ff000000UL
815#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_M_ALIAS_SHFT 48
816#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_M_ALIAS_MASK 0x001f000000000000UL
817#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_ENABLE_SHFT 63
818#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR_ENABLE_MASK 0x8000000000000000UL
819
820union uvh_rh_gam_alias210_overlay_config_0_mmr_u {
821 unsigned long v;
822 struct uvh_rh_gam_alias210_overlay_config_0_mmr_s {
823 unsigned long rsvd_0_23: 24; /* */
824 unsigned long base : 8; /* RW */
825 unsigned long rsvd_32_47: 16; /* */
826 unsigned long m_alias : 5; /* RW */
827 unsigned long rsvd_53_62: 10; /* */
828 unsigned long enable : 1; /* RW */
829 } s;
830};
831
832/* ========================================================================= */
833/* UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR */
834/* ========================================================================= */
835#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR 0x16000d8UL
836
837#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_BASE_SHFT 24
838#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_BASE_MASK 0x00000000ff000000UL
839#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_M_ALIAS_SHFT 48
840#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_M_ALIAS_MASK 0x001f000000000000UL
841#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_ENABLE_SHFT 63
842#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR_ENABLE_MASK 0x8000000000000000UL
843
844union uvh_rh_gam_alias210_overlay_config_1_mmr_u {
845 unsigned long v;
846 struct uvh_rh_gam_alias210_overlay_config_1_mmr_s {
847 unsigned long rsvd_0_23: 24; /* */
848 unsigned long base : 8; /* RW */
849 unsigned long rsvd_32_47: 16; /* */
850 unsigned long m_alias : 5; /* RW */
851 unsigned long rsvd_53_62: 10; /* */
852 unsigned long enable : 1; /* RW */
853 } s;
854};
855
856/* ========================================================================= */
857/* UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR */
858/* ========================================================================= */
859#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR 0x16000e8UL
860
861#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_BASE_SHFT 24
862#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_BASE_MASK 0x00000000ff000000UL
863#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_M_ALIAS_SHFT 48
864#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_M_ALIAS_MASK 0x001f000000000000UL
865#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_ENABLE_SHFT 63
866#define UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR_ENABLE_MASK 0x8000000000000000UL
867
868union uvh_rh_gam_alias210_overlay_config_2_mmr_u {
869 unsigned long v;
870 struct uvh_rh_gam_alias210_overlay_config_2_mmr_s {
871 unsigned long rsvd_0_23: 24; /* */
872 unsigned long base : 8; /* RW */
873 unsigned long rsvd_32_47: 16; /* */
874 unsigned long m_alias : 5; /* RW */
875 unsigned long rsvd_53_62: 10; /* */
876 unsigned long enable : 1; /* RW */
877 } s;
878};
879
880/* ========================================================================= */
809/* UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR */ 881/* UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR */
810/* ========================================================================= */ 882/* ========================================================================= */
811#define UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR 0x16000d0UL 883#define UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR 0x16000d0UL
@@ -857,6 +929,29 @@ union uvh_rh_gam_alias210_redirect_config_2_mmr_u {
857}; 929};
858 930
859/* ========================================================================= */ 931/* ========================================================================= */
932/* UVH_RH_GAM_CONFIG_MMR */
933/* ========================================================================= */
934#define UVH_RH_GAM_CONFIG_MMR 0x1600000UL
935
936#define UVH_RH_GAM_CONFIG_MMR_M_SKT_SHFT 0
937#define UVH_RH_GAM_CONFIG_MMR_M_SKT_MASK 0x000000000000003fUL
938#define UVH_RH_GAM_CONFIG_MMR_N_SKT_SHFT 6
939#define UVH_RH_GAM_CONFIG_MMR_N_SKT_MASK 0x00000000000003c0UL
940#define UVH_RH_GAM_CONFIG_MMR_MMIOL_CFG_SHFT 12
941#define UVH_RH_GAM_CONFIG_MMR_MMIOL_CFG_MASK 0x0000000000001000UL
942
943union uvh_rh_gam_config_mmr_u {
944 unsigned long v;
945 struct uvh_rh_gam_config_mmr_s {
946 unsigned long m_skt : 6; /* RW */
947 unsigned long n_skt : 4; /* RW */
948 unsigned long rsvd_10_11: 2; /* */
949 unsigned long mmiol_cfg : 1; /* RW */
950 unsigned long rsvd_13_63: 51; /* */
951 } s;
952};
953
954/* ========================================================================= */
860/* UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR */ 955/* UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR */
861/* ========================================================================= */ 956/* ========================================================================= */
862#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR 0x1600010UL 957#define UVH_RH_GAM_GRU_OVERLAY_CONFIG_MMR 0x1600010UL
@@ -987,97 +1082,5 @@ union uvh_rtc1_int_config_u {
987 } s; 1082 } s;
988}; 1083};
989 1084
990/* ========================================================================= */
991/* UVH_SI_ADDR_MAP_CONFIG */
992/* ========================================================================= */
993#define UVH_SI_ADDR_MAP_CONFIG 0xc80000UL
994
995#define UVH_SI_ADDR_MAP_CONFIG_M_SKT_SHFT 0
996#define UVH_SI_ADDR_MAP_CONFIG_M_SKT_MASK 0x000000000000003fUL
997#define UVH_SI_ADDR_MAP_CONFIG_N_SKT_SHFT 8
998#define UVH_SI_ADDR_MAP_CONFIG_N_SKT_MASK 0x0000000000000f00UL
999
1000union uvh_si_addr_map_config_u {
1001 unsigned long v;
1002 struct uvh_si_addr_map_config_s {
1003 unsigned long m_skt : 6; /* RW */
1004 unsigned long rsvd_6_7: 2; /* */
1005 unsigned long n_skt : 4; /* RW */
1006 unsigned long rsvd_12_63: 52; /* */
1007 } s;
1008};
1009
1010/* ========================================================================= */
1011/* UVH_SI_ALIAS0_OVERLAY_CONFIG */
1012/* ========================================================================= */
1013#define UVH_SI_ALIAS0_OVERLAY_CONFIG 0xc80008UL
1014
1015#define UVH_SI_ALIAS0_OVERLAY_CONFIG_BASE_SHFT 24
1016#define UVH_SI_ALIAS0_OVERLAY_CONFIG_BASE_MASK 0x00000000ff000000UL
1017#define UVH_SI_ALIAS0_OVERLAY_CONFIG_M_ALIAS_SHFT 48
1018#define UVH_SI_ALIAS0_OVERLAY_CONFIG_M_ALIAS_MASK 0x001f000000000000UL
1019#define UVH_SI_ALIAS0_OVERLAY_CONFIG_ENABLE_SHFT 63
1020#define UVH_SI_ALIAS0_OVERLAY_CONFIG_ENABLE_MASK 0x8000000000000000UL
1021
1022union uvh_si_alias0_overlay_config_u {
1023 unsigned long v;
1024 struct uvh_si_alias0_overlay_config_s {
1025 unsigned long rsvd_0_23: 24; /* */
1026 unsigned long base : 8; /* RW */
1027 unsigned long rsvd_32_47: 16; /* */
1028 unsigned long m_alias : 5; /* RW */
1029 unsigned long rsvd_53_62: 10; /* */
1030 unsigned long enable : 1; /* RW */
1031 } s;
1032};
1033
1034/* ========================================================================= */
1035/* UVH_SI_ALIAS1_OVERLAY_CONFIG */
1036/* ========================================================================= */
1037#define UVH_SI_ALIAS1_OVERLAY_CONFIG 0xc80010UL
1038
1039#define UVH_SI_ALIAS1_OVERLAY_CONFIG_BASE_SHFT 24
1040#define UVH_SI_ALIAS1_OVERLAY_CONFIG_BASE_MASK 0x00000000ff000000UL
1041#define UVH_SI_ALIAS1_OVERLAY_CONFIG_M_ALIAS_SHFT 48
1042#define UVH_SI_ALIAS1_OVERLAY_CONFIG_M_ALIAS_MASK 0x001f000000000000UL
1043#define UVH_SI_ALIAS1_OVERLAY_CONFIG_ENABLE_SHFT 63
1044#define UVH_SI_ALIAS1_OVERLAY_CONFIG_ENABLE_MASK 0x8000000000000000UL
1045
1046union uvh_si_alias1_overlay_config_u {
1047 unsigned long v;
1048 struct uvh_si_alias1_overlay_config_s {
1049 unsigned long rsvd_0_23: 24; /* */
1050 unsigned long base : 8; /* RW */
1051 unsigned long rsvd_32_47: 16; /* */
1052 unsigned long m_alias : 5; /* RW */
1053 unsigned long rsvd_53_62: 10; /* */
1054 unsigned long enable : 1; /* RW */
1055 } s;
1056};
1057
1058/* ========================================================================= */
1059/* UVH_SI_ALIAS2_OVERLAY_CONFIG */
1060/* ========================================================================= */
1061#define UVH_SI_ALIAS2_OVERLAY_CONFIG 0xc80018UL
1062
1063#define UVH_SI_ALIAS2_OVERLAY_CONFIG_BASE_SHFT 24
1064#define UVH_SI_ALIAS2_OVERLAY_CONFIG_BASE_MASK 0x00000000ff000000UL
1065#define UVH_SI_ALIAS2_OVERLAY_CONFIG_M_ALIAS_SHFT 48
1066#define UVH_SI_ALIAS2_OVERLAY_CONFIG_M_ALIAS_MASK 0x001f000000000000UL
1067#define UVH_SI_ALIAS2_OVERLAY_CONFIG_ENABLE_SHFT 63
1068#define UVH_SI_ALIAS2_OVERLAY_CONFIG_ENABLE_MASK 0x8000000000000000UL
1069
1070union uvh_si_alias2_overlay_config_u {
1071 unsigned long v;
1072 struct uvh_si_alias2_overlay_config_s {
1073 unsigned long rsvd_0_23: 24; /* */
1074 unsigned long base : 8; /* RW */
1075 unsigned long rsvd_32_47: 16; /* */
1076 unsigned long m_alias : 5; /* RW */
1077 unsigned long rsvd_53_62: 10; /* */
1078 unsigned long enable : 1; /* RW */
1079 } s;
1080};
1081
1082 1085
1083#endif /* _ASM_X86_UV_UV_MMRS_H */ 1086#endif /* __ASM_UV_MMRS_X86_H__ */
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index baa579c8e038..64642ad019fb 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -154,9 +154,18 @@ struct x86_platform_ops {
154 int (*i8042_detect)(void); 154 int (*i8042_detect)(void);
155}; 155};
156 156
157struct pci_dev;
158
159struct x86_msi_ops {
160 int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type);
161 void (*teardown_msi_irq)(unsigned int irq);
162 void (*teardown_msi_irqs)(struct pci_dev *dev);
163};
164
157extern struct x86_init_ops x86_init; 165extern struct x86_init_ops x86_init;
158extern struct x86_cpuinit_ops x86_cpuinit; 166extern struct x86_cpuinit_ops x86_cpuinit;
159extern struct x86_platform_ops x86_platform; 167extern struct x86_platform_ops x86_platform;
168extern struct x86_msi_ops x86_msi;
160 169
161extern void x86_init_noop(void); 170extern void x86_init_noop(void);
162extern void x86_init_uint_noop(unsigned int unused); 171extern void x86_init_uint_noop(unsigned int unused);
diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
index 7fda040a76cd..a3c28ae4025b 100644
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -200,6 +200,23 @@ extern struct { char _entry[32]; } hypercall_page[];
200 (type)__res; \ 200 (type)__res; \
201}) 201})
202 202
203static inline long
204privcmd_call(unsigned call,
205 unsigned long a1, unsigned long a2,
206 unsigned long a3, unsigned long a4,
207 unsigned long a5)
208{
209 __HYPERCALL_DECLS;
210 __HYPERCALL_5ARG(a1, a2, a3, a4, a5);
211
212 asm volatile("call *%[call]"
213 : __HYPERCALL_5PARAM
214 : [call] "a" (&hypercall_page[call])
215 : __HYPERCALL_CLOBBER5);
216
217 return (long)__res;
218}
219
203static inline int 220static inline int
204HYPERVISOR_set_trap_table(struct trap_info *table) 221HYPERVISOR_set_trap_table(struct trap_info *table)
205{ 222{
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index bf5f7d32bd08..dd8c1414b3d5 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -37,14 +37,21 @@ typedef struct xpaddr {
37 37
38 38
39extern unsigned long get_phys_to_machine(unsigned long pfn); 39extern unsigned long get_phys_to_machine(unsigned long pfn);
40extern void set_phys_to_machine(unsigned long pfn, unsigned long mfn); 40extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
41 41
42static inline unsigned long pfn_to_mfn(unsigned long pfn) 42static inline unsigned long pfn_to_mfn(unsigned long pfn)
43{ 43{
44 unsigned long mfn;
45
44 if (xen_feature(XENFEAT_auto_translated_physmap)) 46 if (xen_feature(XENFEAT_auto_translated_physmap))
45 return pfn; 47 return pfn;
46 48
47 return get_phys_to_machine(pfn) & ~FOREIGN_FRAME_BIT; 49 mfn = get_phys_to_machine(pfn);
50
51 if (mfn != INVALID_P2M_ENTRY)
52 mfn &= ~FOREIGN_FRAME_BIT;
53
54 return mfn;
48} 55}
49 56
50static inline int phys_to_machine_mapping_valid(unsigned long pfn) 57static inline int phys_to_machine_mapping_valid(unsigned long pfn)
@@ -159,6 +166,7 @@ static inline pte_t __pte_ma(pteval_t x)
159 166
160#define pgd_val_ma(x) ((x).pgd) 167#define pgd_val_ma(x) ((x).pgd)
161 168
169void xen_set_domain_pte(pte_t *ptep, pte_t pteval, unsigned domid);
162 170
163xmaddr_t arbitrary_virt_to_machine(void *address); 171xmaddr_t arbitrary_virt_to_machine(void *address);
164unsigned long arbitrary_virt_to_mfn(void *vaddr); 172unsigned long arbitrary_virt_to_mfn(void *vaddr);
diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h
new file mode 100644
index 000000000000..2329b3eaf8d3
--- /dev/null
+++ b/arch/x86/include/asm/xen/pci.h
@@ -0,0 +1,65 @@
1#ifndef _ASM_X86_XEN_PCI_H
2#define _ASM_X86_XEN_PCI_H
3
4#if defined(CONFIG_PCI_XEN)
5extern int __init pci_xen_init(void);
6extern int __init pci_xen_hvm_init(void);
7#define pci_xen 1
8#else
9#define pci_xen 0
10#define pci_xen_init (0)
11static inline int pci_xen_hvm_init(void)
12{
13 return -1;
14}
15#endif
16#if defined(CONFIG_XEN_DOM0)
17void __init xen_setup_pirqs(void);
18#else
19static inline void __init xen_setup_pirqs(void)
20{
21}
22#endif
23
24#if defined(CONFIG_PCI_MSI)
25#if defined(CONFIG_PCI_XEN)
26/* The drivers/pci/xen-pcifront.c sets this structure to
27 * its own functions.
28 */
29struct xen_pci_frontend_ops {
30 int (*enable_msi)(struct pci_dev *dev, int **vectors);
31 void (*disable_msi)(struct pci_dev *dev);
32 int (*enable_msix)(struct pci_dev *dev, int **vectors, int nvec);
33 void (*disable_msix)(struct pci_dev *dev);
34};
35
36extern struct xen_pci_frontend_ops *xen_pci_frontend;
37
38static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
39 int **vectors)
40{
41 if (xen_pci_frontend && xen_pci_frontend->enable_msi)
42 return xen_pci_frontend->enable_msi(dev, vectors);
43 return -ENODEV;
44}
45static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
46{
47 if (xen_pci_frontend && xen_pci_frontend->disable_msi)
48 xen_pci_frontend->disable_msi(dev);
49}
50static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
51 int **vectors, int nvec)
52{
53 if (xen_pci_frontend && xen_pci_frontend->enable_msix)
54 return xen_pci_frontend->enable_msix(dev, vectors, nvec);
55 return -ENODEV;
56}
57static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
58{
59 if (xen_pci_frontend && xen_pci_frontend->disable_msix)
60 xen_pci_frontend->disable_msix(dev);
61}
62#endif /* CONFIG_PCI_XEN */
63#endif /* CONFIG_PCI_MSI */
64
65#endif /* _ASM_X86_XEN_PCI_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 2c833d8c4141..9e13763b6092 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -36,7 +36,6 @@ obj-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 jump_label.o 37obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
38obj-$(CONFIG_IRQ_WORK) += irq_work.o 38obj-$(CONFIG_IRQ_WORK) += irq_work.o
39obj-$(CONFIG_X86_VISWS) += visws_quirks.o
40obj-$(CONFIG_X86_32) += probe_roms_32.o 39obj-$(CONFIG_X86_32) += probe_roms_32.o
41obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o 40obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
42obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o 41obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
@@ -58,7 +57,6 @@ obj-$(CONFIG_INTEL_TXT) += tboot.o
58obj-$(CONFIG_STACKTRACE) += stacktrace.o 57obj-$(CONFIG_STACKTRACE) += stacktrace.o
59obj-y += cpu/ 58obj-y += cpu/
60obj-y += acpi/ 59obj-y += acpi/
61obj-$(CONFIG_SFI) += sfi.o
62obj-y += reboot.o 60obj-y += reboot.o
63obj-$(CONFIG_MCA) += mca_32.o 61obj-$(CONFIG_MCA) += mca_32.o
64obj-$(CONFIG_X86_MSR) += msr.o 62obj-$(CONFIG_X86_MSR) += msr.o
@@ -82,7 +80,6 @@ obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
82obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 80obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
83obj-$(CONFIG_KPROBES) += kprobes.o 81obj-$(CONFIG_KPROBES) += kprobes.o
84obj-$(CONFIG_MODULES) += module.o 82obj-$(CONFIG_MODULES) += module.o
85obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o
86obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o 83obj-$(CONFIG_DOUBLEFAULT) += doublefault_32.o
87obj-$(CONFIG_KGDB) += kgdb.o 84obj-$(CONFIG_KGDB) += kgdb.o
88obj-$(CONFIG_VM86) += vm86_32.o 85obj-$(CONFIG_VM86) += vm86_32.o
@@ -104,14 +101,6 @@ obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o
104 101
105obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o 102obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o
106 103
107obj-$(CONFIG_SCx200) += scx200.o
108scx200-y += scx200_32.o
109
110obj-$(CONFIG_OLPC) += olpc.o
111obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o
112obj-$(CONFIG_OLPC_OPENFIRMWARE) += olpc_ofw.o
113obj-$(CONFIG_X86_MRST) += mrst.o
114
115microcode-y := microcode_core.o 104microcode-y := microcode_core.o
116microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o 105microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
117microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o 106microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o
@@ -124,7 +113,6 @@ obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
124### 113###
125# 64 bit specific files 114# 64 bit specific files
126ifeq ($(CONFIG_X86_64),y) 115ifeq ($(CONFIG_X86_64),y)
127 obj-$(CONFIG_X86_UV) += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o
128 obj-$(CONFIG_AUDIT) += audit_64.o 116 obj-$(CONFIG_AUDIT) += audit_64.o
129 117
130 obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o 118 obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index c05872aa3ce0..71232b941b6c 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -513,35 +513,62 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
513 return 0; 513 return 0;
514} 514}
515 515
516/* 516static int acpi_register_gsi_pic(struct device *dev, u32 gsi,
517 * success: return IRQ number (>=0) 517 int trigger, int polarity)
518 * failure: return < 0
519 */
520int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
521{ 518{
522 unsigned int irq;
523 unsigned int plat_gsi = gsi;
524
525#ifdef CONFIG_PCI 519#ifdef CONFIG_PCI
526 /* 520 /*
527 * Make sure all (legacy) PCI IRQs are set as level-triggered. 521 * Make sure all (legacy) PCI IRQs are set as level-triggered.
528 */ 522 */
529 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { 523 if (trigger == ACPI_LEVEL_SENSITIVE)
530 if (trigger == ACPI_LEVEL_SENSITIVE) 524 eisa_set_level_irq(gsi);
531 eisa_set_level_irq(gsi);
532 }
533#endif 525#endif
534 526
527 return gsi;
528}
529
530static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi,
531 int trigger, int polarity)
532{
535#ifdef CONFIG_X86_IO_APIC 533#ifdef CONFIG_X86_IO_APIC
536 if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) { 534 gsi = mp_register_gsi(dev, gsi, trigger, polarity);
537 plat_gsi = mp_register_gsi(dev, gsi, trigger, polarity);
538 }
539#endif 535#endif
536
537 return gsi;
538}
539
540int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
541 int trigger, int polarity) = acpi_register_gsi_pic;
542
543/*
544 * success: return IRQ number (>=0)
545 * failure: return < 0
546 */
547int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
548{
549 unsigned int irq;
550 unsigned int plat_gsi = gsi;
551
552 plat_gsi = (*__acpi_register_gsi)(dev, gsi, trigger, polarity);
540 irq = gsi_to_irq(plat_gsi); 553 irq = gsi_to_irq(plat_gsi);
541 554
542 return irq; 555 return irq;
543} 556}
544 557
558void __init acpi_set_irq_model_pic(void)
559{
560 acpi_irq_model = ACPI_IRQ_MODEL_PIC;
561 __acpi_register_gsi = acpi_register_gsi_pic;
562 acpi_ioapic = 0;
563}
564
565void __init acpi_set_irq_model_ioapic(void)
566{
567 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
568 __acpi_register_gsi = acpi_register_gsi_ioapic;
569 acpi_ioapic = 1;
570}
571
545/* 572/*
546 * ACPI based hotplug support for CPU 573 * ACPI based hotplug support for CPU
547 */ 574 */
@@ -1259,8 +1286,7 @@ static void __init acpi_process_madt(void)
1259 */ 1286 */
1260 error = acpi_parse_madt_ioapic_entries(); 1287 error = acpi_parse_madt_ioapic_entries();
1261 if (!error) { 1288 if (!error) {
1262 acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC; 1289 acpi_set_irq_model_ioapic();
1263 acpi_ioapic = 1;
1264 1290
1265 smp_found_config = 1; 1291 smp_found_config = 1;
1266 } 1292 }
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index e1252074ea40..69fd72aa5594 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -13,6 +13,10 @@
13#include <asm/segment.h> 13#include <asm/segment.h>
14#include <asm/desc.h> 14#include <asm/desc.h>
15 15
16#ifdef CONFIG_X86_32
17#include <asm/pgtable.h>
18#endif
19
16#include "realmode/wakeup.h" 20#include "realmode/wakeup.h"
17#include "sleep.h" 21#include "sleep.h"
18 22
@@ -91,7 +95,7 @@ int acpi_save_state_mem(void)
91 95
92#ifndef CONFIG_64BIT 96#ifndef CONFIG_64BIT
93 header->pmode_entry = (u32)&wakeup_pmode_return; 97 header->pmode_entry = (u32)&wakeup_pmode_return;
94 header->pmode_cr3 = (u32)(swsusp_pg_dir - __PAGE_OFFSET); 98 header->pmode_cr3 = (u32)__pa(&initial_page_table);
95 saved_magic = 0x12345678; 99 saved_magic = 0x12345678;
96#else /* CONFIG_64BIT */ 100#else /* CONFIG_64BIT */
97 header->trampoline_segment = setup_trampoline() >> 4; 101 header->trampoline_segment = setup_trampoline() >> 4;
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index a36bb90aef53..5079f24c955a 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -638,71 +638,32 @@ void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
638 atomic_set(&stop_machine_first, 1); 638 atomic_set(&stop_machine_first, 1);
639 wrote_text = 0; 639 wrote_text = 0;
640 /* Use __stop_machine() because the caller already got online_cpus. */ 640 /* Use __stop_machine() because the caller already got online_cpus. */
641 __stop_machine(stop_machine_text_poke, (void *)&tpp, NULL); 641 __stop_machine(stop_machine_text_poke, (void *)&tpp, cpu_online_mask);
642 return addr; 642 return addr;
643} 643}
644 644
645#if defined(CONFIG_DYNAMIC_FTRACE) || defined(HAVE_JUMP_LABEL) 645#if defined(CONFIG_DYNAMIC_FTRACE) || defined(HAVE_JUMP_LABEL)
646 646
647unsigned char ideal_nop5[IDEAL_NOP_SIZE_5]; 647#ifdef CONFIG_X86_64
648unsigned char ideal_nop5[5] = { 0x66, 0x66, 0x66, 0x66, 0x90 };
649#else
650unsigned char ideal_nop5[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
651#endif
648 652
649void __init arch_init_ideal_nop5(void) 653void __init arch_init_ideal_nop5(void)
650{ 654{
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 /* 655 /*
657 * There is no good nop for all x86 archs. 656 * There is no good nop for all x86 archs. This selection
658 * We will default to using the P6_NOP5, but first we 657 * algorithm should be unified with the one in find_nop_table(),
659 * will test to make sure that the nop will actually 658 * but this should be good enough for now.
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 * 659 *
668 * TODO: check the cpuid to determine the best nop. 660 * For cases other than the ones below, use the safe (as in
661 * always functional) defaults above.
669 */ 662 */
670 asm volatile ( 663#ifdef CONFIG_X86_64
671 "ftrace_test_jmp:" 664 /* Don't use these on 32 bits due to broken virtualizers */
672 "jmp ftrace_test_p6nop\n" 665 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
673 "nop\n" 666 memcpy(ideal_nop5, p6_nops[5], 5);
674 "nop\n" 667#endif
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} 668}
708#endif 669#endif
diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 8f6463d8ed0d..affacb5e0065 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -12,95 +12,116 @@
12 12
13static u32 *flush_words; 13static u32 *flush_words;
14 14
15struct pci_device_id k8_nb_ids[] = { 15struct pci_device_id amd_nb_misc_ids[] = {
16 { 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) },
17 { 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) }, 18 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_MISC) },
19 {} 19 {}
20}; 20};
21EXPORT_SYMBOL(k8_nb_ids); 21EXPORT_SYMBOL(amd_nb_misc_ids);
22 22
23struct k8_northbridge_info k8_northbridges; 23struct amd_northbridge_info amd_northbridges;
24EXPORT_SYMBOL(k8_northbridges); 24EXPORT_SYMBOL(amd_northbridges);
25 25
26static struct pci_dev *next_k8_northbridge(struct pci_dev *dev) 26static struct pci_dev *next_northbridge(struct pci_dev *dev,
27 struct pci_device_id *ids)
27{ 28{
28 do { 29 do {
29 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); 30 dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
30 if (!dev) 31 if (!dev)
31 break; 32 break;
32 } while (!pci_match_id(&k8_nb_ids[0], dev)); 33 } while (!pci_match_id(ids, dev));
33 return dev; 34 return dev;
34} 35}
35 36
36int cache_k8_northbridges(void) 37int amd_cache_northbridges(void)
37{ 38{
38 int i; 39 int i = 0;
39 struct pci_dev *dev; 40 struct amd_northbridge *nb;
41 struct pci_dev *misc;
40 42
41 if (k8_northbridges.num) 43 if (amd_nb_num())
42 return 0; 44 return 0;
43 45
44 dev = NULL; 46 misc = NULL;
45 while ((dev = next_k8_northbridge(dev)) != NULL) 47 while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL)
46 k8_northbridges.num++; 48 i++;
47 49
48 /* some CPU families (e.g. family 0x11) do not support GART */ 50 if (i == 0)
49 if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 || 51 return 0;
50 boot_cpu_data.x86 == 0x15)
51 k8_northbridges.gart_supported = 1;
52 52
53 k8_northbridges.nb_misc = kmalloc((k8_northbridges.num + 1) * 53 nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL);
54 sizeof(void *), GFP_KERNEL); 54 if (!nb)
55 if (!k8_northbridges.nb_misc)
56 return -ENOMEM; 55 return -ENOMEM;
57 56
58 if (!k8_northbridges.num) { 57 amd_northbridges.nb = nb;
59 k8_northbridges.nb_misc[0] = NULL; 58 amd_northbridges.num = i;
60 return 0;
61 }
62 59
63 if (k8_northbridges.gart_supported) { 60 misc = NULL;
64 flush_words = kmalloc(k8_northbridges.num * sizeof(u32), 61 for (i = 0; i != amd_nb_num(); i++) {
65 GFP_KERNEL); 62 node_to_amd_nb(i)->misc = misc =
66 if (!flush_words) { 63 next_northbridge(misc, amd_nb_misc_ids);
67 kfree(k8_northbridges.nb_misc); 64 }
68 return -ENOMEM; 65
69 } 66 /* some CPU families (e.g. family 0x11) do not support GART */
70 } 67 if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 ||
68 boot_cpu_data.x86 == 0x15)
69 amd_northbridges.flags |= AMD_NB_GART;
70
71 /*
72 * Some CPU families support L3 Cache Index Disable. There are some
73 * limitations because of E382 and E388 on family 0x10.
74 */
75 if (boot_cpu_data.x86 == 0x10 &&
76 boot_cpu_data.x86_model >= 0x8 &&
77 (boot_cpu_data.x86_model > 0x9 ||
78 boot_cpu_data.x86_mask >= 0x1))
79 amd_northbridges.flags |= AMD_NB_L3_INDEX_DISABLE;
71 80
72 dev = NULL;
73 i = 0;
74 while ((dev = next_k8_northbridge(dev)) != NULL) {
75 k8_northbridges.nb_misc[i] = dev;
76 if (k8_northbridges.gart_supported)
77 pci_read_config_dword(dev, 0x9c, &flush_words[i++]);
78 }
79 k8_northbridges.nb_misc[i] = NULL;
80 return 0; 81 return 0;
81} 82}
82EXPORT_SYMBOL_GPL(cache_k8_northbridges); 83EXPORT_SYMBOL_GPL(amd_cache_northbridges);
83 84
84/* Ignores subdevice/subvendor but as far as I can figure out 85/* Ignores subdevice/subvendor but as far as I can figure out
85 they're useless anyways */ 86 they're useless anyways */
86int __init early_is_k8_nb(u32 device) 87int __init early_is_amd_nb(u32 device)
87{ 88{
88 struct pci_device_id *id; 89 struct pci_device_id *id;
89 u32 vendor = device & 0xffff; 90 u32 vendor = device & 0xffff;
90 device >>= 16; 91 device >>= 16;
91 for (id = k8_nb_ids; id->vendor; id++) 92 for (id = amd_nb_misc_ids; id->vendor; id++)
92 if (vendor == id->vendor && device == id->device) 93 if (vendor == id->vendor && device == id->device)
93 return 1; 94 return 1;
94 return 0; 95 return 0;
95} 96}
96 97
97void k8_flush_garts(void) 98int amd_cache_gart(void)
99{
100 int i;
101
102 if (!amd_nb_has_feature(AMD_NB_GART))
103 return 0;
104
105 flush_words = kmalloc(amd_nb_num() * sizeof(u32), GFP_KERNEL);
106 if (!flush_words) {
107 amd_northbridges.flags &= ~AMD_NB_GART;
108 return -ENOMEM;
109 }
110
111 for (i = 0; i != amd_nb_num(); i++)
112 pci_read_config_dword(node_to_amd_nb(i)->misc, 0x9c,
113 &flush_words[i]);
114
115 return 0;
116}
117
118void amd_flush_garts(void)
98{ 119{
99 int flushed, i; 120 int flushed, i;
100 unsigned long flags; 121 unsigned long flags;
101 static DEFINE_SPINLOCK(gart_lock); 122 static DEFINE_SPINLOCK(gart_lock);
102 123
103 if (!k8_northbridges.gart_supported) 124 if (!amd_nb_has_feature(AMD_NB_GART))
104 return; 125 return;
105 126
106 /* Avoid races between AGP and IOMMU. In theory it's not needed 127 /* Avoid races between AGP and IOMMU. In theory it's not needed
@@ -109,16 +130,16 @@ void k8_flush_garts(void)
109 that it doesn't matter to serialize more. -AK */ 130 that it doesn't matter to serialize more. -AK */
110 spin_lock_irqsave(&gart_lock, flags); 131 spin_lock_irqsave(&gart_lock, flags);
111 flushed = 0; 132 flushed = 0;
112 for (i = 0; i < k8_northbridges.num; i++) { 133 for (i = 0; i < amd_nb_num(); i++) {
113 pci_write_config_dword(k8_northbridges.nb_misc[i], 0x9c, 134 pci_write_config_dword(node_to_amd_nb(i)->misc, 0x9c,
114 flush_words[i]|1); 135 flush_words[i] | 1);
115 flushed++; 136 flushed++;
116 } 137 }
117 for (i = 0; i < k8_northbridges.num; i++) { 138 for (i = 0; i < amd_nb_num(); i++) {
118 u32 w; 139 u32 w;
119 /* Make sure the hardware actually executed the flush*/ 140 /* Make sure the hardware actually executed the flush*/
120 for (;;) { 141 for (;;) {
121 pci_read_config_dword(k8_northbridges.nb_misc[i], 142 pci_read_config_dword(node_to_amd_nb(i)->misc,
122 0x9c, &w); 143 0x9c, &w);
123 if (!(w & 1)) 144 if (!(w & 1))
124 break; 145 break;
@@ -129,19 +150,23 @@ void k8_flush_garts(void)
129 if (!flushed) 150 if (!flushed)
130 printk("nothing to flush?\n"); 151 printk("nothing to flush?\n");
131} 152}
132EXPORT_SYMBOL_GPL(k8_flush_garts); 153EXPORT_SYMBOL_GPL(amd_flush_garts);
133 154
134static __init int init_k8_nbs(void) 155static __init int init_amd_nbs(void)
135{ 156{
136 int err = 0; 157 int err = 0;
137 158
138 err = cache_k8_northbridges(); 159 err = amd_cache_northbridges();
139 160
140 if (err < 0) 161 if (err < 0)
141 printk(KERN_NOTICE "K8 NB: Cannot enumerate AMD northbridges.\n"); 162 printk(KERN_NOTICE "AMD NB: Cannot enumerate AMD northbridges.\n");
163
164 if (amd_cache_gart() < 0)
165 printk(KERN_NOTICE "AMD NB: Cannot initialize GART flush words, "
166 "GART support disabled.\n");
142 167
143 return err; 168 return err;
144} 169}
145 170
146/* This has to go after the PCI subsystem */ 171/* This has to go after the PCI subsystem */
147fs_initcall(init_k8_nbs); 172fs_initcall(init_amd_nbs);
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index b3a16e8f0703..dcd7c83e1659 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -206,7 +206,7 @@ static u32 __init read_agp(int bus, int slot, int func, int cap, u32 *order)
206 * Do an PCI bus scan by hand because we're running before the PCI 206 * Do an PCI bus scan by hand because we're running before the PCI
207 * subsystem. 207 * subsystem.
208 * 208 *
209 * All K8 AGP bridges are AGPv3 compliant, so we can do this scan 209 * All AMD AGP bridges are AGPv3 compliant, so we can do this scan
210 * generically. It's probably overkill to always scan all slots because 210 * generically. It's probably overkill to always scan all slots because
211 * the AGP bridges should be always an own bus on the HT hierarchy, 211 * the AGP bridges should be always an own bus on the HT hierarchy,
212 * but do it here for future safety. 212 * but do it here for future safety.
@@ -303,7 +303,7 @@ void __init early_gart_iommu_check(void)
303 dev_limit = bus_dev_ranges[i].dev_limit; 303 dev_limit = bus_dev_ranges[i].dev_limit;
304 304
305 for (slot = dev_base; slot < dev_limit; slot++) { 305 for (slot = dev_base; slot < dev_limit; slot++) {
306 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00))) 306 if (!early_is_amd_nb(read_pci_config(bus, slot, 3, 0x00)))
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);
@@ -358,7 +358,7 @@ void __init early_gart_iommu_check(void)
358 dev_limit = bus_dev_ranges[i].dev_limit; 358 dev_limit = bus_dev_ranges[i].dev_limit;
359 359
360 for (slot = dev_base; slot < dev_limit; slot++) { 360 for (slot = dev_base; slot < dev_limit; slot++) {
361 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00))) 361 if (!early_is_amd_nb(read_pci_config(bus, slot, 3, 0x00)))
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);
@@ -400,7 +400,7 @@ int __init gart_iommu_hole_init(void)
400 dev_limit = bus_dev_ranges[i].dev_limit; 400 dev_limit = bus_dev_ranges[i].dev_limit;
401 401
402 for (slot = dev_base; slot < dev_limit; slot++) { 402 for (slot = dev_base; slot < dev_limit; slot++) {
403 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00))) 403 if (!early_is_amd_nb(read_pci_config(bus, slot, 3, 0x00)))
404 continue; 404 continue;
405 405
406 iommu_detected = 1; 406 iommu_detected = 1;
@@ -518,7 +518,7 @@ out:
518 dev_base = bus_dev_ranges[i].dev_base; 518 dev_base = bus_dev_ranges[i].dev_base;
519 dev_limit = bus_dev_ranges[i].dev_limit; 519 dev_limit = bus_dev_ranges[i].dev_limit;
520 for (slot = dev_base; slot < dev_limit; slot++) { 520 for (slot = dev_base; slot < dev_limit; slot++) {
521 if (!early_is_k8_nb(read_pci_config(bus, slot, 3, 0x00))) 521 if (!early_is_amd_nb(read_pci_config(bus, slot, 3, 0x00)))
522 continue; 522 continue;
523 523
524 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, ctl); 524 write_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL, ctl);
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 463839645f9b..c48a64510844 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -52,7 +52,6 @@
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>
56 55
57unsigned int num_processors; 56unsigned int num_processors;
58 57
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 4f026a632c95..4abf08aab3d4 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3113,7 +3113,7 @@ void destroy_irq(unsigned int irq)
3113 3113
3114 irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE); 3114 irq_set_status_flags(irq, IRQ_NOREQUEST|IRQ_NOPROBE);
3115 3115
3116 if (intr_remapping_enabled) 3116 if (irq_remapped(cfg))
3117 free_irte(irq); 3117 free_irte(irq);
3118 raw_spin_lock_irqsave(&vector_lock, flags); 3118 raw_spin_lock_irqsave(&vector_lock, flags);
3119 __clear_irq_vector(irq, cfg); 3119 __clear_irq_vector(irq, cfg);
@@ -3335,7 +3335,7 @@ static int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int irq)
3335 return 0; 3335 return 0;
3336} 3336}
3337 3337
3338int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) 3338int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
3339{ 3339{
3340 int node, ret, sub_handle, index = 0; 3340 int node, ret, sub_handle, index = 0;
3341 unsigned int irq, irq_want; 3341 unsigned int irq, irq_want;
@@ -3393,7 +3393,7 @@ error:
3393 return ret; 3393 return ret;
3394} 3394}
3395 3395
3396void arch_teardown_msi_irq(unsigned int irq) 3396void native_teardown_msi_irq(unsigned int irq)
3397{ 3397{
3398 destroy_irq(irq); 3398 destroy_irq(irq);
3399} 3399}
@@ -3654,6 +3654,11 @@ static void __init probe_nr_irqs_gsi(void)
3654 printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi); 3654 printk(KERN_DEBUG "nr_irqs_gsi: %d\n", nr_irqs_gsi);
3655} 3655}
3656 3656
3657int get_nr_irqs_gsi(void)
3658{
3659 return nr_irqs_gsi;
3660}
3661
3657#ifdef CONFIG_SPARSE_IRQ 3662#ifdef CONFIG_SPARSE_IRQ
3658int __init arch_probe_nr_irqs(void) 3663int __init arch_probe_nr_irqs(void)
3659{ 3664{
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index f744f54cb248..194539aea175 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * SGI UV APIC functions (note: not an Intel compatible APIC) 6 * SGI UV APIC functions (note: not an Intel compatible APIC)
7 * 7 *
8 * Copyright (C) 2007-2009 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (C) 2007-2010 Silicon Graphics, Inc. All rights reserved.
9 */ 9 */
10#include <linux/cpumask.h> 10#include <linux/cpumask.h>
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
@@ -41,6 +41,7 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
41 41
42static enum uv_system_type uv_system_type; 42static enum uv_system_type uv_system_type;
43static u64 gru_start_paddr, gru_end_paddr; 43static u64 gru_start_paddr, gru_end_paddr;
44static union uvh_apicid uvh_apicid;
44int uv_min_hub_revision_id; 45int uv_min_hub_revision_id;
45EXPORT_SYMBOL_GPL(uv_min_hub_revision_id); 46EXPORT_SYMBOL_GPL(uv_min_hub_revision_id);
46static DEFINE_SPINLOCK(uv_nmi_lock); 47static DEFINE_SPINLOCK(uv_nmi_lock);
@@ -70,12 +71,27 @@ static int early_get_nodeid(void)
70 return node_id.s.node_id; 71 return node_id.s.node_id;
71} 72}
72 73
74static void __init early_get_apic_pnode_shift(void)
75{
76 unsigned long *mmr;
77
78 mmr = early_ioremap(UV_LOCAL_MMR_BASE | UVH_APICID, sizeof(*mmr));
79 uvh_apicid.v = *mmr;
80 early_iounmap(mmr, sizeof(*mmr));
81 if (!uvh_apicid.v)
82 /*
83 * Old bios, use default value
84 */
85 uvh_apicid.s.pnode_shift = UV_APIC_PNODE_SHIFT;
86}
87
73static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 88static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
74{ 89{
75 int nodeid; 90 int nodeid;
76 91
77 if (!strcmp(oem_id, "SGI")) { 92 if (!strcmp(oem_id, "SGI")) {
78 nodeid = early_get_nodeid(); 93 nodeid = early_get_nodeid();
94 early_get_apic_pnode_shift();
79 x86_platform.is_untracked_pat_range = uv_is_untracked_pat_range; 95 x86_platform.is_untracked_pat_range = uv_is_untracked_pat_range;
80 x86_platform.nmi_init = uv_nmi_init; 96 x86_platform.nmi_init = uv_nmi_init;
81 if (!strcmp(oem_table_id, "UVL")) 97 if (!strcmp(oem_table_id, "UVL"))
@@ -84,7 +100,7 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
84 uv_system_type = UV_X2APIC; 100 uv_system_type = UV_X2APIC;
85 else if (!strcmp(oem_table_id, "UVH")) { 101 else if (!strcmp(oem_table_id, "UVH")) {
86 __get_cpu_var(x2apic_extra_bits) = 102 __get_cpu_var(x2apic_extra_bits) =
87 nodeid << (UV_APIC_PNODE_SHIFT - 1); 103 nodeid << (uvh_apicid.s.pnode_shift - 1);
88 uv_system_type = UV_NON_UNIQUE_APIC; 104 uv_system_type = UV_NON_UNIQUE_APIC;
89 return 1; 105 return 1;
90 } 106 }
@@ -363,14 +379,14 @@ struct redir_addr {
363#define DEST_SHIFT UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR_DEST_BASE_SHFT 379#define DEST_SHIFT UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR_DEST_BASE_SHFT
364 380
365static __initdata struct redir_addr redir_addrs[] = { 381static __initdata struct redir_addr redir_addrs[] = {
366 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR, UVH_SI_ALIAS0_OVERLAY_CONFIG}, 382 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR, UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_0_MMR},
367 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_1_MMR, UVH_SI_ALIAS1_OVERLAY_CONFIG}, 383 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_1_MMR, UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_1_MMR},
368 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_2_MMR, UVH_SI_ALIAS2_OVERLAY_CONFIG}, 384 {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_2_MMR, UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR},
369}; 385};
370 386
371static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size) 387static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size)
372{ 388{
373 union uvh_si_alias0_overlay_config_u alias; 389 union uvh_rh_gam_alias210_overlay_config_2_mmr_u alias;
374 union uvh_rh_gam_alias210_redirect_config_2_mmr_u redirect; 390 union uvh_rh_gam_alias210_redirect_config_2_mmr_u redirect;
375 int i; 391 int i;
376 392
@@ -644,7 +660,7 @@ void uv_nmi_init(void)
644 660
645void __init uv_system_init(void) 661void __init uv_system_init(void)
646{ 662{
647 union uvh_si_addr_map_config_u m_n_config; 663 union uvh_rh_gam_config_mmr_u m_n_config;
648 union uvh_node_id_u node_id; 664 union uvh_node_id_u node_id;
649 unsigned long gnode_upper, lowmem_redir_base, lowmem_redir_size; 665 unsigned long gnode_upper, lowmem_redir_base, lowmem_redir_size;
650 int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val; 666 int bytes, nid, cpu, lcpu, pnode, blade, i, j, m_val, n_val;
@@ -654,7 +670,7 @@ void __init uv_system_init(void)
654 670
655 map_low_mmrs(); 671 map_low_mmrs();
656 672
657 m_n_config.v = uv_read_local_mmr(UVH_SI_ADDR_MAP_CONFIG); 673 m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR );
658 m_val = m_n_config.s.m_skt; 674 m_val = m_n_config.s.m_skt;
659 n_val = m_n_config.s.n_skt; 675 n_val = m_n_config.s.n_skt;
660 mmr_base = 676 mmr_base =
@@ -716,6 +732,10 @@ void __init uv_system_init(void)
716 int apicid = per_cpu(x86_cpu_to_apicid, cpu); 732 int apicid = per_cpu(x86_cpu_to_apicid, cpu);
717 733
718 nid = cpu_to_node(cpu); 734 nid = cpu_to_node(cpu);
735 /*
736 * apic_pnode_shift must be set before calling uv_apicid_to_pnode();
737 */
738 uv_cpu_hub_info(cpu)->apic_pnode_shift = uvh_apicid.s.pnode_shift;
719 pnode = uv_apicid_to_pnode(apicid); 739 pnode = uv_apicid_to_pnode(apicid);
720 blade = boot_pnode_to_blade(pnode); 740 blade = boot_pnode_to_blade(pnode);
721 lcpu = uv_blade_info[blade].nr_possible_cpus; 741 lcpu = uv_blade_info[blade].nr_possible_cpus;
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/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
index cd8da247dda1..a2baafb2fe6d 100644
--- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -701,6 +701,7 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
701 per_cpu(acfreq_data, policy->cpu) = NULL; 701 per_cpu(acfreq_data, policy->cpu) = NULL;
702 acpi_processor_unregister_performance(data->acpi_data, 702 acpi_processor_unregister_performance(data->acpi_data,
703 policy->cpu); 703 policy->cpu);
704 kfree(data->freq_table);
704 kfree(data); 705 kfree(data);
705 } 706 }
706 707
diff --git a/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
index 733093d60436..141abebc4516 100644
--- a/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
+++ b/arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
@@ -393,7 +393,7 @@ static struct cpufreq_driver nforce2_driver = {
393 * Detects nForce2 A2 and C1 stepping 393 * Detects nForce2 A2 and C1 stepping
394 * 394 *
395 */ 395 */
396static unsigned int nforce2_detect_chipset(void) 396static int nforce2_detect_chipset(void)
397{ 397{
398 nforce2_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA, 398 nforce2_dev = pci_get_subsys(PCI_VENDOR_ID_NVIDIA,
399 PCI_DEVICE_ID_NVIDIA_NFORCE2, 399 PCI_DEVICE_ID_NVIDIA_NFORCE2,
diff --git a/arch/x86/kernel/cpu/cpufreq/longrun.c b/arch/x86/kernel/cpu/cpufreq/longrun.c
index fc09f142d94d..d9f51367666b 100644
--- a/arch/x86/kernel/cpu/cpufreq/longrun.c
+++ b/arch/x86/kernel/cpu/cpufreq/longrun.c
@@ -35,7 +35,7 @@ static unsigned int longrun_low_freq, longrun_high_freq;
35 * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS 35 * Reads the current LongRun policy by access to MSR_TMTA_LONGRUN_FLAGS
36 * and MSR_TMTA_LONGRUN_CTRL 36 * and MSR_TMTA_LONGRUN_CTRL
37 */ 37 */
38static void __init longrun_get_policy(struct cpufreq_policy *policy) 38static void __cpuinit longrun_get_policy(struct cpufreq_policy *policy)
39{ 39{
40 u32 msr_lo, msr_hi; 40 u32 msr_lo, msr_hi;
41 41
@@ -165,7 +165,7 @@ static unsigned int longrun_get(unsigned int cpu)
165 * TMTA rules: 165 * TMTA rules:
166 * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq) 166 * performance_pctg = (target_freq - low_freq)/(high_freq - low_freq)
167 */ 167 */
168static unsigned int __cpuinit longrun_determine_freqs(unsigned int *low_freq, 168static int __cpuinit longrun_determine_freqs(unsigned int *low_freq,
169 unsigned int *high_freq) 169 unsigned int *high_freq)
170{ 170{
171 u32 msr_lo, msr_hi; 171 u32 msr_lo, msr_hi;
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 695f17731e23..d16c2c53d6bf 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -284,9 +284,7 @@ static void __cpuinit srat_detect_node(struct cpuinfo_x86 *c)
284 /* Don't do the funky fallback heuristics the AMD version employs 284 /* Don't do the funky fallback heuristics the AMD version employs
285 for now. */ 285 for now. */
286 node = apicid_to_node[apicid]; 286 node = apicid_to_node[apicid];
287 if (node == NUMA_NO_NODE) 287 if (node == NUMA_NO_NODE || !node_online(node)) {
288 node = first_node(node_online_map);
289 else if (!node_online(node)) {
290 /* reuse the value from init_cpu_to_node() */ 288 /* reuse the value from init_cpu_to_node() */
291 node = cpu_to_node(cpu); 289 node = cpu_to_node(cpu);
292 } 290 }
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 12cd823c8d03..9ecf81f9b90f 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -149,8 +149,7 @@ union _cpuid4_leaf_ecx {
149}; 149};
150 150
151struct amd_l3_cache { 151struct amd_l3_cache {
152 struct pci_dev *dev; 152 struct amd_northbridge *nb;
153 bool can_disable;
154 unsigned indices; 153 unsigned indices;
155 u8 subcaches[4]; 154 u8 subcaches[4];
156}; 155};
@@ -311,14 +310,12 @@ struct _cache_attr {
311/* 310/*
312 * L3 cache descriptors 311 * L3 cache descriptors
313 */ 312 */
314static struct amd_l3_cache **__cpuinitdata l3_caches;
315
316static void __cpuinit amd_calc_l3_indices(struct amd_l3_cache *l3) 313static void __cpuinit amd_calc_l3_indices(struct amd_l3_cache *l3)
317{ 314{
318 unsigned int sc0, sc1, sc2, sc3; 315 unsigned int sc0, sc1, sc2, sc3;
319 u32 val = 0; 316 u32 val = 0;
320 317
321 pci_read_config_dword(l3->dev, 0x1C4, &val); 318 pci_read_config_dword(l3->nb->misc, 0x1C4, &val);
322 319
323 /* calculate subcache sizes */ 320 /* calculate subcache sizes */
324 l3->subcaches[0] = sc0 = !(val & BIT(0)); 321 l3->subcaches[0] = sc0 = !(val & BIT(0));
@@ -327,49 +324,17 @@ static void __cpuinit amd_calc_l3_indices(struct amd_l3_cache *l3)
327 l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13)); 324 l3->subcaches[3] = sc3 = !(val & BIT(12)) + !(val & BIT(13));
328 325
329 l3->indices = (max(max(max(sc0, sc1), sc2), sc3) << 10) - 1; 326 l3->indices = (max(max(max(sc0, sc1), sc2), sc3) << 10) - 1;
327 l3->indices = (max(max3(sc0, sc1, sc2), sc3) << 10) - 1;
330} 328}
331 329
332static struct amd_l3_cache * __cpuinit amd_init_l3_cache(int node) 330static void __cpuinit amd_init_l3_cache(struct _cpuid4_info_regs *this_leaf,
333{ 331 int index)
334 struct amd_l3_cache *l3;
335 struct pci_dev *dev = node_to_k8_nb_misc(node);
336
337 l3 = kzalloc(sizeof(struct amd_l3_cache), GFP_ATOMIC);
338 if (!l3) {
339 printk(KERN_WARNING "Error allocating L3 struct\n");
340 return NULL;
341 }
342
343 l3->dev = dev;
344
345 amd_calc_l3_indices(l3);
346
347 return l3;
348}
349
350static void __cpuinit amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf,
351 int index)
352{ 332{
333 static struct amd_l3_cache *__cpuinitdata l3_caches;
353 int node; 334 int node;
354 335
355 if (boot_cpu_data.x86 != 0x10) 336 /* only for L3, and not in virtualized environments */
356 return; 337 if (index < 3 || amd_nb_num() == 0)
357
358 if (index < 3)
359 return;
360
361 /* see errata #382 and #388 */
362 if (boot_cpu_data.x86_model < 0x8)
363 return;
364
365 if ((boot_cpu_data.x86_model == 0x8 ||
366 boot_cpu_data.x86_model == 0x9)
367 &&
368 boot_cpu_data.x86_mask < 0x1)
369 return;
370
371 /* not in virtualized environments */
372 if (k8_northbridges.num == 0)
373 return; 338 return;
374 339
375 /* 340 /*
@@ -377,7 +342,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. 342 * never freed but this is done only on shutdown so it doesn't matter.
378 */ 343 */
379 if (!l3_caches) { 344 if (!l3_caches) {
380 int size = k8_northbridges.num * sizeof(struct amd_l3_cache *); 345 int size = amd_nb_num() * sizeof(struct amd_l3_cache);
381 346
382 l3_caches = kzalloc(size, GFP_ATOMIC); 347 l3_caches = kzalloc(size, GFP_ATOMIC);
383 if (!l3_caches) 348 if (!l3_caches)
@@ -386,14 +351,12 @@ static void __cpuinit amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf,
386 351
387 node = amd_get_nb_id(smp_processor_id()); 352 node = amd_get_nb_id(smp_processor_id());
388 353
389 if (!l3_caches[node]) { 354 if (!l3_caches[node].nb) {
390 l3_caches[node] = amd_init_l3_cache(node); 355 l3_caches[node].nb = node_to_amd_nb(node);
391 l3_caches[node]->can_disable = true; 356 amd_calc_l3_indices(&l3_caches[node]);
392 } 357 }
393 358
394 WARN_ON(!l3_caches[node]); 359 this_leaf->l3 = &l3_caches[node];
395
396 this_leaf->l3 = l3_caches[node];
397} 360}
398 361
399/* 362/*
@@ -407,7 +370,7 @@ int amd_get_l3_disable_slot(struct amd_l3_cache *l3, unsigned slot)
407{ 370{
408 unsigned int reg = 0; 371 unsigned int reg = 0;
409 372
410 pci_read_config_dword(l3->dev, 0x1BC + slot * 4, &reg); 373 pci_read_config_dword(l3->nb->misc, 0x1BC + slot * 4, &reg);
411 374
412 /* check whether this slot is activated already */ 375 /* check whether this slot is activated already */
413 if (reg & (3UL << 30)) 376 if (reg & (3UL << 30))
@@ -421,7 +384,8 @@ static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf,
421{ 384{
422 int index; 385 int index;
423 386
424 if (!this_leaf->l3 || !this_leaf->l3->can_disable) 387 if (!this_leaf->l3 ||
388 !amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
425 return -EINVAL; 389 return -EINVAL;
426 390
427 index = amd_get_l3_disable_slot(this_leaf->l3, slot); 391 index = amd_get_l3_disable_slot(this_leaf->l3, slot);
@@ -456,7 +420,7 @@ static void amd_l3_disable_index(struct amd_l3_cache *l3, int cpu,
456 if (!l3->subcaches[i]) 420 if (!l3->subcaches[i])
457 continue; 421 continue;
458 422
459 pci_write_config_dword(l3->dev, 0x1BC + slot * 4, reg); 423 pci_write_config_dword(l3->nb->misc, 0x1BC + slot * 4, reg);
460 424
461 /* 425 /*
462 * We need to WBINVD on a core on the node containing the L3 426 * We need to WBINVD on a core on the node containing the L3
@@ -466,7 +430,7 @@ static void amd_l3_disable_index(struct amd_l3_cache *l3, int cpu,
466 wbinvd_on_cpu(cpu); 430 wbinvd_on_cpu(cpu);
467 431
468 reg |= BIT(31); 432 reg |= BIT(31);
469 pci_write_config_dword(l3->dev, 0x1BC + slot * 4, reg); 433 pci_write_config_dword(l3->nb->misc, 0x1BC + slot * 4, reg);
470 } 434 }
471} 435}
472 436
@@ -523,7 +487,8 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
523 if (!capable(CAP_SYS_ADMIN)) 487 if (!capable(CAP_SYS_ADMIN))
524 return -EPERM; 488 return -EPERM;
525 489
526 if (!this_leaf->l3 || !this_leaf->l3->can_disable) 490 if (!this_leaf->l3 ||
491 !amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
527 return -EINVAL; 492 return -EINVAL;
528 493
529 cpu = cpumask_first(to_cpumask(this_leaf->shared_cpu_map)); 494 cpu = cpumask_first(to_cpumask(this_leaf->shared_cpu_map));
@@ -544,7 +509,7 @@ static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
544#define STORE_CACHE_DISABLE(slot) \ 509#define STORE_CACHE_DISABLE(slot) \
545static ssize_t \ 510static ssize_t \
546store_cache_disable_##slot(struct _cpuid4_info *this_leaf, \ 511store_cache_disable_##slot(struct _cpuid4_info *this_leaf, \
547 const char *buf, size_t count) \ 512 const char *buf, size_t count) \
548{ \ 513{ \
549 return store_cache_disable(this_leaf, buf, count, slot); \ 514 return store_cache_disable(this_leaf, buf, count, slot); \
550} 515}
@@ -557,10 +522,7 @@ static struct _cache_attr cache_disable_1 = __ATTR(cache_disable_1, 0644,
557 show_cache_disable_1, store_cache_disable_1); 522 show_cache_disable_1, store_cache_disable_1);
558 523
559#else /* CONFIG_AMD_NB */ 524#else /* CONFIG_AMD_NB */
560static void __cpuinit 525#define amd_init_l3_cache(x, y)
561amd_check_l3_disable(struct _cpuid4_info_regs *this_leaf, int index)
562{
563};
564#endif /* CONFIG_AMD_NB */ 526#endif /* CONFIG_AMD_NB */
565 527
566static int 528static int
@@ -574,7 +536,7 @@ __cpuinit cpuid4_cache_lookup_regs(int index,
574 536
575 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { 537 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
576 amd_cpuid4(index, &eax, &ebx, &ecx); 538 amd_cpuid4(index, &eax, &ebx, &ecx);
577 amd_check_l3_disable(this_leaf, index); 539 amd_init_l3_cache(this_leaf, index);
578 } else { 540 } else {
579 cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx); 541 cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &edx);
580 } 542 }
@@ -982,30 +944,48 @@ define_one_ro(size);
982define_one_ro(shared_cpu_map); 944define_one_ro(shared_cpu_map);
983define_one_ro(shared_cpu_list); 945define_one_ro(shared_cpu_list);
984 946
985#define DEFAULT_SYSFS_CACHE_ATTRS \
986 &type.attr, \
987 &level.attr, \
988 &coherency_line_size.attr, \
989 &physical_line_partition.attr, \
990 &ways_of_associativity.attr, \
991 &number_of_sets.attr, \
992 &size.attr, \
993 &shared_cpu_map.attr, \
994 &shared_cpu_list.attr
995
996static struct attribute *default_attrs[] = { 947static struct attribute *default_attrs[] = {
997 DEFAULT_SYSFS_CACHE_ATTRS, 948 &type.attr,
949 &level.attr,
950 &coherency_line_size.attr,
951 &physical_line_partition.attr,
952 &ways_of_associativity.attr,
953 &number_of_sets.attr,
954 &size.attr,
955 &shared_cpu_map.attr,
956 &shared_cpu_list.attr,
998 NULL 957 NULL
999}; 958};
1000 959
1001static struct attribute *default_l3_attrs[] = {
1002 DEFAULT_SYSFS_CACHE_ATTRS,
1003#ifdef CONFIG_AMD_NB 960#ifdef CONFIG_AMD_NB
1004 &cache_disable_0.attr, 961static struct attribute ** __cpuinit amd_l3_attrs(void)
1005 &cache_disable_1.attr, 962{
963 static struct attribute **attrs;
964 int n;
965
966 if (attrs)
967 return attrs;
968
969 n = sizeof (default_attrs) / sizeof (struct attribute *);
970
971 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
972 n += 2;
973
974 attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
975 if (attrs == NULL)
976 return attrs = default_attrs;
977
978 for (n = 0; default_attrs[n]; n++)
979 attrs[n] = default_attrs[n];
980
981 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
982 attrs[n++] = &cache_disable_0.attr;
983 attrs[n++] = &cache_disable_1.attr;
984 }
985
986 return attrs;
987}
1006#endif 988#endif
1007 NULL
1008};
1009 989
1010static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) 990static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
1011{ 991{
@@ -1116,11 +1096,11 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
1116 1096
1117 this_leaf = CPUID4_INFO_IDX(cpu, i); 1097 this_leaf = CPUID4_INFO_IDX(cpu, i);
1118 1098
1119 if (this_leaf->l3 && this_leaf->l3->can_disable) 1099 ktype_cache.default_attrs = default_attrs;
1120 ktype_cache.default_attrs = default_l3_attrs; 1100#ifdef CONFIG_AMD_NB
1121 else 1101 if (this_leaf->l3)
1122 ktype_cache.default_attrs = default_attrs; 1102 ktype_cache.default_attrs = amd_l3_attrs();
1123 1103#endif
1124 retval = kobject_init_and_add(&(this_object->kobj), 1104 retval = kobject_init_and_add(&(this_object->kobj),
1125 &ktype_cache, 1105 &ktype_cache,
1126 per_cpu(ici_cache_kobject, cpu), 1106 per_cpu(ici_cache_kobject, cpu),
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/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index fe73c1844a9a..ed6310183efb 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -49,7 +49,6 @@ static unsigned long
49copy_from_user_nmi(void *to, const void __user *from, unsigned long n) 49copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
50{ 50{
51 unsigned long offset, addr = (unsigned long)from; 51 unsigned long offset, addr = (unsigned long)from;
52 int type = in_nmi() ? KM_NMI : KM_IRQ0;
53 unsigned long size, len = 0; 52 unsigned long size, len = 0;
54 struct page *page; 53 struct page *page;
55 void *map; 54 void *map;
@@ -63,9 +62,9 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
63 offset = addr & (PAGE_SIZE - 1); 62 offset = addr & (PAGE_SIZE - 1);
64 size = min(PAGE_SIZE - offset, n - len); 63 size = min(PAGE_SIZE - offset, n - len);
65 64
66 map = kmap_atomic(page, type); 65 map = kmap_atomic(page);
67 memcpy(to, map+offset, size); 66 memcpy(to, map+offset, size);
68 kunmap_atomic(map, type); 67 kunmap_atomic(map);
69 put_page(page); 68 put_page(page);
70 69
71 len += size; 70 len += size;
@@ -238,6 +237,7 @@ struct x86_pmu {
238 * Intel DebugStore bits 237 * Intel DebugStore bits
239 */ 238 */
240 int bts, pebs; 239 int bts, pebs;
240 int bts_active, pebs_active;
241 int pebs_record_size; 241 int pebs_record_size;
242 void (*drain_pebs)(struct pt_regs *regs); 242 void (*drain_pebs)(struct pt_regs *regs);
243 struct event_constraint *pebs_constraints; 243 struct event_constraint *pebs_constraints;
@@ -381,7 +381,7 @@ static void release_pmc_hardware(void) {}
381 381
382#endif 382#endif
383 383
384static int reserve_ds_buffers(void); 384static void reserve_ds_buffers(void);
385static void release_ds_buffers(void); 385static void release_ds_buffers(void);
386 386
387static void hw_perf_event_destroy(struct perf_event *event) 387static void hw_perf_event_destroy(struct perf_event *event)
@@ -478,7 +478,7 @@ static int x86_setup_perfctr(struct perf_event *event)
478 if ((attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) && 478 if ((attr->config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
479 (hwc->sample_period == 1)) { 479 (hwc->sample_period == 1)) {
480 /* BTS is not supported by this architecture. */ 480 /* BTS is not supported by this architecture. */
481 if (!x86_pmu.bts) 481 if (!x86_pmu.bts_active)
482 return -EOPNOTSUPP; 482 return -EOPNOTSUPP;
483 483
484 /* BTS is currently only allowed for user-mode. */ 484 /* BTS is currently only allowed for user-mode. */
@@ -497,12 +497,13 @@ static int x86_pmu_hw_config(struct perf_event *event)
497 int precise = 0; 497 int precise = 0;
498 498
499 /* Support for constant skid */ 499 /* Support for constant skid */
500 if (x86_pmu.pebs) 500 if (x86_pmu.pebs_active) {
501 precise++; 501 precise++;
502 502
503 /* Support for IP fixup */ 503 /* Support for IP fixup */
504 if (x86_pmu.lbr_nr) 504 if (x86_pmu.lbr_nr)
505 precise++; 505 precise++;
506 }
506 507
507 if (event->attr.precise_ip > precise) 508 if (event->attr.precise_ip > precise)
508 return -EOPNOTSUPP; 509 return -EOPNOTSUPP;
@@ -544,11 +545,8 @@ static int __x86_pmu_event_init(struct perf_event *event)
544 if (atomic_read(&active_events) == 0) { 545 if (atomic_read(&active_events) == 0) {
545 if (!reserve_pmc_hardware()) 546 if (!reserve_pmc_hardware())
546 err = -EBUSY; 547 err = -EBUSY;
547 else { 548 else
548 err = reserve_ds_buffers(); 549 reserve_ds_buffers();
549 if (err)
550 release_pmc_hardware();
551 }
552 } 550 }
553 if (!err) 551 if (!err)
554 atomic_inc(&active_events); 552 atomic_inc(&active_events);
diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index 46d58448c3af..e421b8cd6944 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -280,11 +280,11 @@ static struct amd_nb *amd_alloc_nb(int cpu, int nb_id)
280 struct amd_nb *nb; 280 struct amd_nb *nb;
281 int i; 281 int i;
282 282
283 nb = kmalloc(sizeof(struct amd_nb), GFP_KERNEL); 283 nb = kmalloc_node(sizeof(struct amd_nb), GFP_KERNEL | __GFP_ZERO,
284 cpu_to_node(cpu));
284 if (!nb) 285 if (!nb)
285 return NULL; 286 return NULL;
286 287
287 memset(nb, 0, sizeof(*nb));
288 nb->nb_id = nb_id; 288 nb->nb_id = nb_id;
289 289
290 /* 290 /*
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index 4977f9c400e5..b7dcd9f2b8a0 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -74,6 +74,107 @@ static void fini_debug_store_on_cpu(int cpu)
74 wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA, 0, 0); 74 wrmsr_on_cpu(cpu, MSR_IA32_DS_AREA, 0, 0);
75} 75}
76 76
77static int alloc_pebs_buffer(int cpu)
78{
79 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
80 int node = cpu_to_node(cpu);
81 int max, thresh = 1; /* always use a single PEBS record */
82 void *buffer;
83
84 if (!x86_pmu.pebs)
85 return 0;
86
87 buffer = kmalloc_node(PEBS_BUFFER_SIZE, GFP_KERNEL | __GFP_ZERO, node);
88 if (unlikely(!buffer))
89 return -ENOMEM;
90
91 max = PEBS_BUFFER_SIZE / x86_pmu.pebs_record_size;
92
93 ds->pebs_buffer_base = (u64)(unsigned long)buffer;
94 ds->pebs_index = ds->pebs_buffer_base;
95 ds->pebs_absolute_maximum = ds->pebs_buffer_base +
96 max * x86_pmu.pebs_record_size;
97
98 ds->pebs_interrupt_threshold = ds->pebs_buffer_base +
99 thresh * x86_pmu.pebs_record_size;
100
101 return 0;
102}
103
104static void release_pebs_buffer(int cpu)
105{
106 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
107
108 if (!ds || !x86_pmu.pebs)
109 return;
110
111 kfree((void *)(unsigned long)ds->pebs_buffer_base);
112 ds->pebs_buffer_base = 0;
113}
114
115static int alloc_bts_buffer(int cpu)
116{
117 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
118 int node = cpu_to_node(cpu);
119 int max, thresh;
120 void *buffer;
121
122 if (!x86_pmu.bts)
123 return 0;
124
125 buffer = kmalloc_node(BTS_BUFFER_SIZE, GFP_KERNEL | __GFP_ZERO, node);
126 if (unlikely(!buffer))
127 return -ENOMEM;
128
129 max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
130 thresh = max / 16;
131
132 ds->bts_buffer_base = (u64)(unsigned long)buffer;
133 ds->bts_index = ds->bts_buffer_base;
134 ds->bts_absolute_maximum = ds->bts_buffer_base +
135 max * BTS_RECORD_SIZE;
136 ds->bts_interrupt_threshold = ds->bts_absolute_maximum -
137 thresh * BTS_RECORD_SIZE;
138
139 return 0;
140}
141
142static void release_bts_buffer(int cpu)
143{
144 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
145
146 if (!ds || !x86_pmu.bts)
147 return;
148
149 kfree((void *)(unsigned long)ds->bts_buffer_base);
150 ds->bts_buffer_base = 0;
151}
152
153static int alloc_ds_buffer(int cpu)
154{
155 int node = cpu_to_node(cpu);
156 struct debug_store *ds;
157
158 ds = kmalloc_node(sizeof(*ds), GFP_KERNEL | __GFP_ZERO, node);
159 if (unlikely(!ds))
160 return -ENOMEM;
161
162 per_cpu(cpu_hw_events, cpu).ds = ds;
163
164 return 0;
165}
166
167static void release_ds_buffer(int cpu)
168{
169 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds;
170
171 if (!ds)
172 return;
173
174 per_cpu(cpu_hw_events, cpu).ds = NULL;
175 kfree(ds);
176}
177
77static void release_ds_buffers(void) 178static void release_ds_buffers(void)
78{ 179{
79 int cpu; 180 int cpu;
@@ -82,93 +183,77 @@ static void release_ds_buffers(void)
82 return; 183 return;
83 184
84 get_online_cpus(); 185 get_online_cpus();
85
86 for_each_online_cpu(cpu) 186 for_each_online_cpu(cpu)
87 fini_debug_store_on_cpu(cpu); 187 fini_debug_store_on_cpu(cpu);
88 188
89 for_each_possible_cpu(cpu) { 189 for_each_possible_cpu(cpu) {
90 struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds; 190 release_pebs_buffer(cpu);
91 191 release_bts_buffer(cpu);
92 if (!ds) 192 release_ds_buffer(cpu);
93 continue;
94
95 per_cpu(cpu_hw_events, cpu).ds = NULL;
96
97 kfree((void *)(unsigned long)ds->pebs_buffer_base);
98 kfree((void *)(unsigned long)ds->bts_buffer_base);
99 kfree(ds);
100 } 193 }
101
102 put_online_cpus(); 194 put_online_cpus();
103} 195}
104 196
105static int reserve_ds_buffers(void) 197static void reserve_ds_buffers(void)
106{ 198{
107 int cpu, err = 0; 199 int bts_err = 0, pebs_err = 0;
200 int cpu;
201
202 x86_pmu.bts_active = 0;
203 x86_pmu.pebs_active = 0;
108 204
109 if (!x86_pmu.bts && !x86_pmu.pebs) 205 if (!x86_pmu.bts && !x86_pmu.pebs)
110 return 0; 206 return;
207
208 if (!x86_pmu.bts)
209 bts_err = 1;
210
211 if (!x86_pmu.pebs)
212 pebs_err = 1;
111 213
112 get_online_cpus(); 214 get_online_cpus();
113 215
114 for_each_possible_cpu(cpu) { 216 for_each_possible_cpu(cpu) {
115 struct debug_store *ds; 217 if (alloc_ds_buffer(cpu)) {
116 void *buffer; 218 bts_err = 1;
117 int max, thresh; 219 pebs_err = 1;
220 }
221
222 if (!bts_err && alloc_bts_buffer(cpu))
223 bts_err = 1;
118 224
119 err = -ENOMEM; 225 if (!pebs_err && alloc_pebs_buffer(cpu))
120 ds = kzalloc(sizeof(*ds), GFP_KERNEL); 226 pebs_err = 1;
121 if (unlikely(!ds)) 227
228 if (bts_err && pebs_err)
122 break; 229 break;
123 per_cpu(cpu_hw_events, cpu).ds = ds; 230 }
124
125 if (x86_pmu.bts) {
126 buffer = kzalloc(BTS_BUFFER_SIZE, GFP_KERNEL);
127 if (unlikely(!buffer))
128 break;
129
130 max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE;
131 thresh = max / 16;
132
133 ds->bts_buffer_base = (u64)(unsigned long)buffer;
134 ds->bts_index = ds->bts_buffer_base;
135 ds->bts_absolute_maximum = ds->bts_buffer_base +
136 max * BTS_RECORD_SIZE;
137 ds->bts_interrupt_threshold = ds->bts_absolute_maximum -
138 thresh * BTS_RECORD_SIZE;
139 }
140 231
141 if (x86_pmu.pebs) { 232 if (bts_err) {
142 buffer = kzalloc(PEBS_BUFFER_SIZE, GFP_KERNEL); 233 for_each_possible_cpu(cpu)
143 if (unlikely(!buffer)) 234 release_bts_buffer(cpu);
144 break; 235 }
145
146 max = PEBS_BUFFER_SIZE / x86_pmu.pebs_record_size;
147
148 ds->pebs_buffer_base = (u64)(unsigned long)buffer;
149 ds->pebs_index = ds->pebs_buffer_base;
150 ds->pebs_absolute_maximum = ds->pebs_buffer_base +
151 max * x86_pmu.pebs_record_size;
152 /*
153 * Always use single record PEBS
154 */
155 ds->pebs_interrupt_threshold = ds->pebs_buffer_base +
156 x86_pmu.pebs_record_size;
157 }
158 236
159 err = 0; 237 if (pebs_err) {
238 for_each_possible_cpu(cpu)
239 release_pebs_buffer(cpu);
160 } 240 }
161 241
162 if (err) 242 if (bts_err && pebs_err) {
163 release_ds_buffers(); 243 for_each_possible_cpu(cpu)
164 else { 244 release_ds_buffer(cpu);
245 } else {
246 if (x86_pmu.bts && !bts_err)
247 x86_pmu.bts_active = 1;
248
249 if (x86_pmu.pebs && !pebs_err)
250 x86_pmu.pebs_active = 1;
251
165 for_each_online_cpu(cpu) 252 for_each_online_cpu(cpu)
166 init_debug_store_on_cpu(cpu); 253 init_debug_store_on_cpu(cpu);
167 } 254 }
168 255
169 put_online_cpus(); 256 put_online_cpus();
170
171 return err;
172} 257}
173 258
174/* 259/*
@@ -233,7 +318,7 @@ static int intel_pmu_drain_bts_buffer(void)
233 if (!event) 318 if (!event)
234 return 0; 319 return 0;
235 320
236 if (!ds) 321 if (!x86_pmu.bts_active)
237 return 0; 322 return 0;
238 323
239 at = (struct bts_record *)(unsigned long)ds->bts_buffer_base; 324 at = (struct bts_record *)(unsigned long)ds->bts_buffer_base;
@@ -503,7 +588,7 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs)
503 struct pebs_record_core *at, *top; 588 struct pebs_record_core *at, *top;
504 int n; 589 int n;
505 590
506 if (!ds || !x86_pmu.pebs) 591 if (!x86_pmu.pebs_active)
507 return; 592 return;
508 593
509 at = (struct pebs_record_core *)(unsigned long)ds->pebs_buffer_base; 594 at = (struct pebs_record_core *)(unsigned long)ds->pebs_buffer_base;
@@ -545,7 +630,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
545 u64 status = 0; 630 u64 status = 0;
546 int bit, n; 631 int bit, n;
547 632
548 if (!ds || !x86_pmu.pebs) 633 if (!x86_pmu.pebs_active)
549 return; 634 return;
550 635
551 at = (struct pebs_record_nhm *)(unsigned long)ds->pebs_buffer_base; 636 at = (struct pebs_record_nhm *)(unsigned long)ds->pebs_buffer_base;
@@ -630,9 +715,8 @@ static void intel_ds_init(void)
630 715
631#else /* CONFIG_CPU_SUP_INTEL */ 716#else /* CONFIG_CPU_SUP_INTEL */
632 717
633static int reserve_ds_buffers(void) 718static void reserve_ds_buffers(void)
634{ 719{
635 return 0;
636} 720}
637 721
638static void release_ds_buffers(void) 722static void release_ds_buffers(void)
diff --git a/arch/x86/kernel/crash_dump_32.c b/arch/x86/kernel/crash_dump_32.c
index 67414550c3cc..d5cd13945d5a 100644
--- a/arch/x86/kernel/crash_dump_32.c
+++ b/arch/x86/kernel/crash_dump_32.c
@@ -61,7 +61,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
61 if (!is_crashed_pfn_valid(pfn)) 61 if (!is_crashed_pfn_valid(pfn))
62 return -EFAULT; 62 return -EFAULT;
63 63
64 vaddr = kmap_atomic_pfn(pfn, KM_PTE0); 64 vaddr = kmap_atomic_pfn(pfn);
65 65
66 if (!userbuf) { 66 if (!userbuf) {
67 memcpy(buf, (vaddr + offset), csize); 67 memcpy(buf, (vaddr + offset), csize);
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 0f6376ffa2d9..1bc7f75a5bda 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -82,11 +82,11 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
82 if (kstack_end(stack)) 82 if (kstack_end(stack))
83 break; 83 break;
84 if (i && ((i % STACKSLOTS_PER_LINE) == 0)) 84 if (i && ((i % STACKSLOTS_PER_LINE) == 0))
85 printk("\n%s", log_lvl); 85 printk(KERN_CONT "\n");
86 printk(" %08lx", *stack++); 86 printk(KERN_CONT " %08lx", *stack++);
87 touch_nmi_watchdog(); 87 touch_nmi_watchdog();
88 } 88 }
89 printk("\n"); 89 printk(KERN_CONT "\n");
90 show_trace_log_lvl(task, regs, sp, bp, log_lvl); 90 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
91} 91}
92 92
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 57a21f11c791..6a340485249a 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -265,20 +265,20 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
265 if (stack >= irq_stack && stack <= irq_stack_end) { 265 if (stack >= irq_stack && stack <= irq_stack_end) {
266 if (stack == irq_stack_end) { 266 if (stack == irq_stack_end) {
267 stack = (unsigned long *) (irq_stack_end[-1]); 267 stack = (unsigned long *) (irq_stack_end[-1]);
268 printk(" <EOI> "); 268 printk(KERN_CONT " <EOI> ");
269 } 269 }
270 } else { 270 } else {
271 if (((long) stack & (THREAD_SIZE-1)) == 0) 271 if (((long) stack & (THREAD_SIZE-1)) == 0)
272 break; 272 break;
273 } 273 }
274 if (i && ((i % STACKSLOTS_PER_LINE) == 0)) 274 if (i && ((i % STACKSLOTS_PER_LINE) == 0))
275 printk("\n%s", log_lvl); 275 printk(KERN_CONT "\n");
276 printk(" %016lx", *stack++); 276 printk(KERN_CONT " %016lx", *stack++);
277 touch_nmi_watchdog(); 277 touch_nmi_watchdog();
278 } 278 }
279 preempt_enable(); 279 preempt_enable();
280 280
281 printk("\n"); 281 printk(KERN_CONT "\n");
282 show_trace_log_lvl(task, regs, sp, bp, log_lvl); 282 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
283} 283}
284 284
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 9fb188d7bc76..59e175e89599 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -382,20 +382,20 @@ sysenter_past_esp:
382 * 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
383 * we immediately enable interrupts at that point anyway. 383 * we immediately enable interrupts at that point anyway.
384 */ 384 */
385 pushl_cfi $(__USER_DS) 385 pushl_cfi $__USER_DS
386 /*CFI_REL_OFFSET ss, 0*/ 386 /*CFI_REL_OFFSET ss, 0*/
387 pushl_cfi %ebp 387 pushl_cfi %ebp
388 CFI_REL_OFFSET esp, 0 388 CFI_REL_OFFSET esp, 0
389 pushfl_cfi 389 pushfl_cfi
390 orl $X86_EFLAGS_IF, (%esp) 390 orl $X86_EFLAGS_IF, (%esp)
391 pushl_cfi $(__USER_CS) 391 pushl_cfi $__USER_CS
392 /*CFI_REL_OFFSET cs, 0*/ 392 /*CFI_REL_OFFSET cs, 0*/
393 /* 393 /*
394 * Push current_thread_info()->sysenter_return to the stack. 394 * Push current_thread_info()->sysenter_return to the stack.
395 * 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
396 * pushed above; +8 corresponds to copy_thread's esp0 setting. 396 * pushed above; +8 corresponds to copy_thread's esp0 setting.
397 */ 397 */
398 pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp) 398 pushl_cfi (TI_sysenter_return-THREAD_SIZE_asm+8+4*4)(%esp)
399 CFI_REL_OFFSET eip, 0 399 CFI_REL_OFFSET eip, 0
400 400
401 pushl_cfi %eax 401 pushl_cfi %eax
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index a7ae7fd1010f..fe2690d71c0c 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -963,22 +963,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
963 x86_platform_ipi smp_x86_platform_ipi 963 x86_platform_ipi smp_x86_platform_ipi
964 964
965#ifdef CONFIG_SMP 965#ifdef CONFIG_SMP
966apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \ 966.irpc idx, "01234567"
967 invalidate_interrupt0 smp_invalidate_interrupt 967apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
968apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \ 968 invalidate_interrupt\idx smp_invalidate_interrupt
969 invalidate_interrupt1 smp_invalidate_interrupt 969.endr
970apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \
971 invalidate_interrupt2 smp_invalidate_interrupt
972apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \
973 invalidate_interrupt3 smp_invalidate_interrupt
974apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \
975 invalidate_interrupt4 smp_invalidate_interrupt
976apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \
977 invalidate_interrupt5 smp_invalidate_interrupt
978apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \
979 invalidate_interrupt6 smp_invalidate_interrupt
980apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \
981 invalidate_interrupt7 smp_invalidate_interrupt
982#endif 970#endif
983 971
984apicinterrupt THRESHOLD_APIC_VECTOR \ 972apicinterrupt THRESHOLD_APIC_VECTOR \
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 9a6ca2392170..763310165fa0 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -18,6 +18,7 @@
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/io_apic.h> 19#include <asm/io_apic.h>
20#include <asm/bios_ebda.h> 20#include <asm/bios_ebda.h>
21#include <asm/tlbflush.h>
21 22
22static void __init i386_default_early_setup(void) 23static void __init i386_default_early_setup(void)
23{ 24{
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 efaf906daf93..ae03cab4352e 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,
@@ -722,7 +713,7 @@ static int hpet_cpuhp_notify(struct notifier_block *n,
722 713
723 switch (action & 0xf) { 714 switch (action & 0xf) {
724 case CPU_ONLINE: 715 case CPU_ONLINE:
725 INIT_DELAYED_WORK_ON_STACK(&work.work, hpet_work); 716 INIT_DELAYED_WORK_ONSTACK(&work.work, hpet_work);
726 init_completion(&work.complete); 717 init_completion(&work.complete);
727 /* FIXME: add schedule_work_on() */ 718 /* FIXME: add schedule_work_on() */
728 schedule_delayed_work_on(cpu, &work.work, 0); 719 schedule_delayed_work_on(cpu, &work.work, 0);
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 10709f29d166..96656f207751 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/uaccess.h> 18#include <linux/uaccess.h>
19#include <linux/percpu.h> 19#include <linux/percpu.h>
20#include <linux/mm.h>
20 21
21#include <asm/apic.h> 22#include <asm/apic.h>
22 23
@@ -49,21 +50,17 @@ static inline int check_stack_overflow(void) { return 0; }
49static inline void print_stack_overflow(void) { } 50static inline void print_stack_overflow(void) { }
50#endif 51#endif
51 52
52#ifdef CONFIG_4KSTACKS
53/* 53/*
54 * per-CPU IRQ handling contexts (thread information and stack) 54 * per-CPU IRQ handling contexts (thread information and stack)
55 */ 55 */
56union irq_ctx { 56union irq_ctx {
57 struct thread_info tinfo; 57 struct thread_info tinfo;
58 u32 stack[THREAD_SIZE/sizeof(u32)]; 58 u32 stack[THREAD_SIZE/sizeof(u32)];
59} __attribute__((aligned(PAGE_SIZE))); 59} __attribute__((aligned(THREAD_SIZE)));
60 60
61static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx); 61static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
62static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx); 62static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx);
63 63
64static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, hardirq_stack);
65static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, softirq_stack);
66
67static void call_on_stack(void *func, void *stack) 64static void call_on_stack(void *func, void *stack)
68{ 65{
69 asm volatile("xchgl %%ebx,%%esp \n" 66 asm volatile("xchgl %%ebx,%%esp \n"
@@ -129,7 +126,9 @@ void __cpuinit irq_ctx_init(int cpu)
129 if (per_cpu(hardirq_ctx, cpu)) 126 if (per_cpu(hardirq_ctx, cpu))
130 return; 127 return;
131 128
132 irqctx = &per_cpu(hardirq_stack, cpu); 129 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
130 THREAD_FLAGS,
131 THREAD_ORDER));
133 irqctx->tinfo.task = NULL; 132 irqctx->tinfo.task = NULL;
134 irqctx->tinfo.exec_domain = NULL; 133 irqctx->tinfo.exec_domain = NULL;
135 irqctx->tinfo.cpu = cpu; 134 irqctx->tinfo.cpu = cpu;
@@ -138,7 +137,9 @@ void __cpuinit irq_ctx_init(int cpu)
138 137
139 per_cpu(hardirq_ctx, cpu) = irqctx; 138 per_cpu(hardirq_ctx, cpu) = irqctx;
140 139
141 irqctx = &per_cpu(softirq_stack, cpu); 140 irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
141 THREAD_FLAGS,
142 THREAD_ORDER));
142 irqctx->tinfo.task = NULL; 143 irqctx->tinfo.task = NULL;
143 irqctx->tinfo.exec_domain = NULL; 144 irqctx->tinfo.exec_domain = NULL;
144 irqctx->tinfo.cpu = cpu; 145 irqctx->tinfo.cpu = cpu;
@@ -151,11 +152,6 @@ void __cpuinit irq_ctx_init(int cpu)
151 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu)); 152 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
152} 153}
153 154
154void irq_ctx_exit(int cpu)
155{
156 per_cpu(hardirq_ctx, cpu) = NULL;
157}
158
159asmlinkage void do_softirq(void) 155asmlinkage void do_softirq(void)
160{ 156{
161 unsigned long flags; 157 unsigned long flags;
@@ -187,11 +183,6 @@ asmlinkage void do_softirq(void)
187 local_irq_restore(flags); 183 local_irq_restore(flags);
188} 184}
189 185
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) 186bool handle_irq(unsigned irq, struct pt_regs *regs)
196{ 187{
197 struct irq_desc *desc; 188 struct irq_desc *desc;
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..ec592caac4b4 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -387,7 +387,7 @@ kgdb_set_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype)
387 * disable hardware debugging while it is processing gdb packets or 387 * disable hardware debugging while it is processing gdb packets or
388 * handling exception. 388 * handling exception.
389 */ 389 */
390void kgdb_disable_hw_debug(struct pt_regs *regs) 390static void kgdb_disable_hw_debug(struct pt_regs *regs)
391{ 391{
392 int i; 392 int i;
393 int cpu = raw_smp_processor_id(); 393 int cpu = raw_smp_processor_id();
@@ -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;
@@ -721,6 +724,7 @@ struct kgdb_arch arch_kgdb_ops = {
721 .flags = KGDB_HW_BREAKPOINT, 724 .flags = KGDB_HW_BREAKPOINT,
722 .set_hw_breakpoint = kgdb_set_hw_break, 725 .set_hw_breakpoint = kgdb_set_hw_break,
723 .remove_hw_breakpoint = kgdb_remove_hw_break, 726 .remove_hw_breakpoint = kgdb_remove_hw_break,
727 .disable_hw_break = kgdb_disable_hw_debug,
724 .remove_all_hw_break = kgdb_remove_all_hw_break, 728 .remove_all_hw_break = kgdb_remove_all_hw_break,
725 .correct_hw_break = kgdb_correct_hw_break, 729 .correct_hw_break = kgdb_correct_hw_break,
726}; 730};
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/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index e1af7c055c7d..ce0cb4721c9a 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -212,7 +212,7 @@ static int install_equiv_cpu_table(const u8 *buf)
212 return 0; 212 return 0;
213 } 213 }
214 214
215 equiv_cpu_table = (struct equiv_cpu_entry *) vmalloc(size); 215 equiv_cpu_table = vmalloc(size);
216 if (!equiv_cpu_table) { 216 if (!equiv_cpu_table) {
217 pr_err("failed to allocate equivalent CPU table\n"); 217 pr_err("failed to allocate equivalent CPU table\n");
218 return 0; 218 return 0;
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/mmconf-fam10h_64.c b/arch/x86/kernel/mmconf-fam10h_64.c
index 71825806cd44..6da143c2a6b8 100644
--- a/arch/x86/kernel/mmconf-fam10h_64.c
+++ b/arch/x86/kernel/mmconf-fam10h_64.c
@@ -217,13 +217,13 @@ void __cpuinit fam10h_check_enable_mmcfg(void)
217 wrmsrl(address, val); 217 wrmsrl(address, val);
218} 218}
219 219
220static int __devinit set_check_enable_amd_mmconf(const struct dmi_system_id *d) 220static int __init set_check_enable_amd_mmconf(const struct dmi_system_id *d)
221{ 221{
222 pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; 222 pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF;
223 return 0; 223 return 0;
224} 224}
225 225
226static const struct dmi_system_id __cpuinitconst mmconf_dmi_table[] = { 226static const struct dmi_system_id __initconst mmconf_dmi_table[] = {
227 { 227 {
228 .callback = set_check_enable_amd_mmconf, 228 .callback = set_check_enable_amd_mmconf,
229 .ident = "Sun Microsystems Machine", 229 .ident = "Sun Microsystems Machine",
@@ -234,7 +234,8 @@ static const struct dmi_system_id __cpuinitconst mmconf_dmi_table[] = {
234 {} 234 {}
235}; 235};
236 236
237void __cpuinit check_enable_amd_mmconf_dmi(void) 237/* Called from a __cpuinit function, but only on the BSP. */
238void __ref check_enable_amd_mmconf_dmi(void)
238{ 239{
239 dmi_check_system(mmconf_dmi_table); 240 dmi_check_system(mmconf_dmi_table);
240} 241}
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index ba0f0ca9f280..c01ffa5b9b87 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -143,7 +143,7 @@ static void flush_gart(void)
143 143
144 spin_lock_irqsave(&iommu_bitmap_lock, flags); 144 spin_lock_irqsave(&iommu_bitmap_lock, flags);
145 if (need_flush) { 145 if (need_flush) {
146 k8_flush_garts(); 146 amd_flush_garts();
147 need_flush = false; 147 need_flush = false;
148 } 148 }
149 spin_unlock_irqrestore(&iommu_bitmap_lock, flags); 149 spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
@@ -561,17 +561,17 @@ static void enable_gart_translations(void)
561{ 561{
562 int i; 562 int i;
563 563
564 if (!k8_northbridges.gart_supported) 564 if (!amd_nb_has_feature(AMD_NB_GART))
565 return; 565 return;
566 566
567 for (i = 0; i < k8_northbridges.num; i++) { 567 for (i = 0; i < amd_nb_num(); i++) {
568 struct pci_dev *dev = k8_northbridges.nb_misc[i]; 568 struct pci_dev *dev = node_to_amd_nb(i)->misc;
569 569
570 enable_gart_translation(dev, __pa(agp_gatt_table)); 570 enable_gart_translation(dev, __pa(agp_gatt_table));
571 } 571 }
572 572
573 /* Flush the GART-TLB to remove stale entries */ 573 /* Flush the GART-TLB to remove stale entries */
574 k8_flush_garts(); 574 amd_flush_garts();
575} 575}
576 576
577/* 577/*
@@ -596,13 +596,13 @@ static void gart_fixup_northbridges(struct sys_device *dev)
596 if (!fix_up_north_bridges) 596 if (!fix_up_north_bridges)
597 return; 597 return;
598 598
599 if (!k8_northbridges.gart_supported) 599 if (!amd_nb_has_feature(AMD_NB_GART))
600 return; 600 return;
601 601
602 pr_info("PCI-DMA: Restoring GART aperture settings\n"); 602 pr_info("PCI-DMA: Restoring GART aperture settings\n");
603 603
604 for (i = 0; i < k8_northbridges.num; i++) { 604 for (i = 0; i < amd_nb_num(); i++) {
605 struct pci_dev *dev = k8_northbridges.nb_misc[i]; 605 struct pci_dev *dev = node_to_amd_nb(i)->misc;
606 606
607 /* 607 /*
608 * Don't enable translations just yet. That is the next 608 * Don't enable translations just yet. That is the next
@@ -644,7 +644,7 @@ static struct sys_device device_gart = {
644 * Private Northbridge GATT initialization in case we cannot use the 644 * Private Northbridge GATT initialization in case we cannot use the
645 * AGP driver for some reason. 645 * AGP driver for some reason.
646 */ 646 */
647static __init int init_k8_gatt(struct agp_kern_info *info) 647static __init int init_amd_gatt(struct agp_kern_info *info)
648{ 648{
649 unsigned aper_size, gatt_size, new_aper_size; 649 unsigned aper_size, gatt_size, new_aper_size;
650 unsigned aper_base, new_aper_base; 650 unsigned aper_base, new_aper_base;
@@ -656,8 +656,8 @@ static __init int init_k8_gatt(struct agp_kern_info *info)
656 656
657 aper_size = aper_base = info->aper_size = 0; 657 aper_size = aper_base = info->aper_size = 0;
658 dev = NULL; 658 dev = NULL;
659 for (i = 0; i < k8_northbridges.num; i++) { 659 for (i = 0; i < amd_nb_num(); i++) {
660 dev = k8_northbridges.nb_misc[i]; 660 dev = node_to_amd_nb(i)->misc;
661 new_aper_base = read_aperture(dev, &new_aper_size); 661 new_aper_base = read_aperture(dev, &new_aper_size);
662 if (!new_aper_base) 662 if (!new_aper_base)
663 goto nommu; 663 goto nommu;
@@ -725,13 +725,13 @@ static void gart_iommu_shutdown(void)
725 if (!no_agp) 725 if (!no_agp)
726 return; 726 return;
727 727
728 if (!k8_northbridges.gart_supported) 728 if (!amd_nb_has_feature(AMD_NB_GART))
729 return; 729 return;
730 730
731 for (i = 0; i < k8_northbridges.num; i++) { 731 for (i = 0; i < amd_nb_num(); i++) {
732 u32 ctl; 732 u32 ctl;
733 733
734 dev = k8_northbridges.nb_misc[i]; 734 dev = node_to_amd_nb(i)->misc;
735 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl); 735 pci_read_config_dword(dev, AMD64_GARTAPERTURECTL, &ctl);
736 736
737 ctl &= ~GARTEN; 737 ctl &= ~GARTEN;
@@ -749,14 +749,14 @@ int __init gart_iommu_init(void)
749 unsigned long scratch; 749 unsigned long scratch;
750 long i; 750 long i;
751 751
752 if (!k8_northbridges.gart_supported) 752 if (!amd_nb_has_feature(AMD_NB_GART))
753 return 0; 753 return 0;
754 754
755#ifndef CONFIG_AGP_AMD64 755#ifndef CONFIG_AGP_AMD64
756 no_agp = 1; 756 no_agp = 1;
757#else 757#else
758 /* Makefile puts PCI initialization via subsys_initcall first. */ 758 /* Makefile puts PCI initialization via subsys_initcall first. */
759 /* Add other K8 AGP bridge drivers here */ 759 /* Add other AMD AGP bridge drivers here */
760 no_agp = no_agp || 760 no_agp = no_agp ||
761 (agp_amd64_init() < 0) || 761 (agp_amd64_init() < 0) ||
762 (agp_copy_info(agp_bridge, &info) < 0); 762 (agp_copy_info(agp_bridge, &info) < 0);
@@ -765,7 +765,7 @@ int __init gart_iommu_init(void)
765 if (no_iommu || 765 if (no_iommu ||
766 (!force_iommu && max_pfn <= MAX_DMA32_PFN) || 766 (!force_iommu && max_pfn <= MAX_DMA32_PFN) ||
767 !gart_iommu_aperture || 767 !gart_iommu_aperture ||
768 (no_agp && init_k8_gatt(&info) < 0)) { 768 (no_agp && init_amd_gatt(&info) < 0)) {
769 if (max_pfn > MAX_DMA32_PFN) { 769 if (max_pfn > MAX_DMA32_PFN) {
770 pr_warning("More than 4GB of memory but GART IOMMU not available.\n"); 770 pr_warning("More than 4GB of memory but GART IOMMU not available.\n");
771 pr_warning("falling back to iommu=soft.\n"); 771 pr_warning("falling back to iommu=soft.\n");
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 70c4872cd8aa..45892dc4b72a 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -801,7 +801,8 @@ void ptrace_disable(struct task_struct *child)
801static const struct user_regset_view user_x86_32_view; /* Initialized below. */ 801static const struct user_regset_view user_x86_32_view; /* Initialized below. */
802#endif 802#endif
803 803
804long arch_ptrace(struct task_struct *child, long request, long addr, long data) 804long arch_ptrace(struct task_struct *child, long request,
805 unsigned long addr, unsigned long data)
805{ 806{
806 int ret; 807 int ret;
807 unsigned long __user *datap = (unsigned long __user *)data; 808 unsigned long __user *datap = (unsigned long __user *)data;
@@ -812,8 +813,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
812 unsigned long tmp; 813 unsigned long tmp;
813 814
814 ret = -EIO; 815 ret = -EIO;
815 if ((addr & (sizeof(data) - 1)) || addr < 0 || 816 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
816 addr >= sizeof(struct user))
817 break; 817 break;
818 818
819 tmp = 0; /* Default return condition */ 819 tmp = 0; /* Default return condition */
@@ -830,8 +830,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
830 830
831 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 831 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
832 ret = -EIO; 832 ret = -EIO;
833 if ((addr & (sizeof(data) - 1)) || addr < 0 || 833 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
834 addr >= sizeof(struct user))
835 break; 834 break;
836 835
837 if (addr < sizeof(struct user_regs_struct)) 836 if (addr < sizeof(struct user_regs_struct))
@@ -888,17 +887,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
888 887
889#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 888#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
890 case PTRACE_GET_THREAD_AREA: 889 case PTRACE_GET_THREAD_AREA:
891 if (addr < 0) 890 if ((int) addr < 0)
892 return -EIO; 891 return -EIO;
893 ret = do_get_thread_area(child, addr, 892 ret = do_get_thread_area(child, addr,
894 (struct user_desc __user *) data); 893 (struct user_desc __user *)data);
895 break; 894 break;
896 895
897 case PTRACE_SET_THREAD_AREA: 896 case PTRACE_SET_THREAD_AREA:
898 if (addr < 0) 897 if ((int) addr < 0)
899 return -EIO; 898 return -EIO;
900 ret = do_set_thread_area(child, addr, 899 ret = do_set_thread_area(child, addr,
901 (struct user_desc __user *) data, 0); 900 (struct user_desc __user *)data, 0);
902 break; 901 break;
903#endif 902#endif
904 903
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 239427ca02af..008b91eefa18 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -41,48 +41,11 @@ void pvclock_set_flags(u8 flags)
41 valid_flags = flags; 41 valid_flags = flags;
42} 42}
43 43
44/*
45 * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction,
46 * yielding a 64-bit result.
47 */
48static inline u64 scale_delta(u64 delta, u32 mul_frac, int shift)
49{
50 u64 product;
51#ifdef __i386__
52 u32 tmp1, tmp2;
53#endif
54
55 if (shift < 0)
56 delta >>= -shift;
57 else
58 delta <<= shift;
59
60#ifdef __i386__
61 __asm__ (
62 "mul %5 ; "
63 "mov %4,%%eax ; "
64 "mov %%edx,%4 ; "
65 "mul %5 ; "
66 "xor %5,%5 ; "
67 "add %4,%%eax ; "
68 "adc %5,%%edx ; "
69 : "=A" (product), "=r" (tmp1), "=r" (tmp2)
70 : "a" ((u32)delta), "1" ((u32)(delta >> 32)), "2" (mul_frac) );
71#elif defined(__x86_64__)
72 __asm__ (
73 "mul %%rdx ; shrd $32,%%rdx,%%rax"
74 : "=a" (product) : "0" (delta), "d" ((u64)mul_frac) );
75#else
76#error implement me!
77#endif
78
79 return product;
80}
81
82static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow) 44static u64 pvclock_get_nsec_offset(struct pvclock_shadow_time *shadow)
83{ 45{
84 u64 delta = native_read_tsc() - shadow->tsc_timestamp; 46 u64 delta = native_read_tsc() - shadow->tsc_timestamp;
85 return scale_delta(delta, shadow->tsc_to_nsec_mul, shadow->tsc_shift); 47 return pvclock_scale_delta(delta, shadow->tsc_to_nsec_mul,
48 shadow->tsc_shift);
86} 49}
87 50
88/* 51/*
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 7a4cf14223ba..c495aa8d4815 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -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
@@ -641,7 +635,7 @@ void native_machine_shutdown(void)
641 /* O.K Now that I'm on the appropriate processor, 635 /* O.K Now that I'm on the appropriate processor,
642 * stop all of the others. 636 * stop all of the others.
643 */ 637 */
644 smp_send_stop(); 638 stop_other_cpus();
645#endif 639#endif
646 640
647 lapic_shutdown(); 641 lapic_shutdown();
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index b8982e0fc0c2..0afb8c7e3803 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -694,12 +694,23 @@ static u64 __init get_max_mapped(void)
694void __init setup_arch(char **cmdline_p) 694void __init setup_arch(char **cmdline_p)
695{ 695{
696 int acpi = 0; 696 int acpi = 0;
697 int k8 = 0; 697 int amd = 0;
698 unsigned long flags; 698 unsigned long flags;
699 699
700#ifdef CONFIG_X86_32 700#ifdef CONFIG_X86_32
701 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); 701 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
702 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();
703#else 714#else
704 printk(KERN_INFO "Command line: %s\n", boot_command_line); 715 printk(KERN_INFO "Command line: %s\n", boot_command_line);
705#endif 716#endif
@@ -758,6 +769,8 @@ void __init setup_arch(char **cmdline_p)
758 769
759 x86_init.oem.arch_setup(); 770 x86_init.oem.arch_setup();
760 771
772 resource_alloc_from_bottom = 0;
773 iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
761 setup_memory_map(); 774 setup_memory_map();
762 parse_setup_data(); 775 parse_setup_data();
763 /* update the e820_saved too */ 776 /* update the e820_saved too */
@@ -968,12 +981,12 @@ void __init setup_arch(char **cmdline_p)
968 acpi = acpi_numa_init(); 981 acpi = acpi_numa_init();
969#endif 982#endif
970 983
971#ifdef CONFIG_K8_NUMA 984#ifdef CONFIG_AMD_NUMA
972 if (!acpi) 985 if (!acpi)
973 k8 = !k8_numa_init(0, max_pfn); 986 amd = !amd_numa_init(0, max_pfn);
974#endif 987#endif
975 988
976 initmem_init(0, max_pfn, acpi, k8); 989 initmem_init(0, max_pfn, acpi, amd);
977 memblock_find_dma_reserve(); 990 memblock_find_dma_reserve();
978 dma32_reserve_bootmem(); 991 dma32_reserve_bootmem();
979 992
@@ -985,7 +998,12 @@ void __init setup_arch(char **cmdline_p)
985 paging_init(); 998 paging_init();
986 x86_init.paging.pagetable_setup_done(swapper_pg_dir); 999 x86_init.paging.pagetable_setup_done(swapper_pg_dir);
987 1000
988 setup_trampoline_page_table(); 1001#ifdef CONFIG_X86_32
1002 /* sync back kernel address range */
1003 clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
1004 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
1005 KERNEL_PGD_PTRS);
1006#endif
989 1007
990 tboot_probe(); 1008 tboot_probe();
991 1009
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index d801210945d6..513deac7228d 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -159,10 +159,10 @@ asmlinkage void smp_reboot_interrupt(void)
159 irq_exit(); 159 irq_exit();
160} 160}
161 161
162static void native_smp_send_stop(void) 162static void native_stop_other_cpus(int wait)
163{ 163{
164 unsigned long flags; 164 unsigned long flags;
165 unsigned long wait; 165 unsigned long timeout;
166 166
167 if (reboot_force) 167 if (reboot_force)
168 return; 168 return;
@@ -179,9 +179,12 @@ static void native_smp_send_stop(void)
179 if (num_online_cpus() > 1) { 179 if (num_online_cpus() > 1) {
180 apic->send_IPI_allbutself(REBOOT_VECTOR); 180 apic->send_IPI_allbutself(REBOOT_VECTOR);
181 181
182 /* Don't wait longer than a second */ 182 /*
183 wait = USEC_PER_SEC; 183 * Don't wait longer than a second if the caller
184 while (num_online_cpus() > 1 && wait--) 184 * didn't ask us to wait.
185 */
186 timeout = USEC_PER_SEC;
187 while (num_online_cpus() > 1 && (wait || timeout--))
185 udelay(1); 188 udelay(1);
186 } 189 }
187 190
@@ -227,7 +230,7 @@ struct smp_ops smp_ops = {
227 .smp_prepare_cpus = native_smp_prepare_cpus, 230 .smp_prepare_cpus = native_smp_prepare_cpus,
228 .smp_cpus_done = native_smp_cpus_done, 231 .smp_cpus_done = native_smp_cpus_done,
229 232
230 .smp_send_stop = native_smp_send_stop, 233 .stop_other_cpus = native_stop_other_cpus,
231 .smp_send_reschedule = native_smp_send_reschedule, 234 .smp_send_reschedule = native_smp_send_reschedule,
232 235
233 .cpu_up = native_cpu_up, 236 .cpu_up = native_cpu_up,
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index dfb50890b5b7..083e99d1b7df 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -299,22 +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 cpu_init();
315 preempt_disable();
316 smp_callin();
317
318 /* 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 */
319 barrier(); 313 barrier();
320 /* 314 /*
@@ -753,7 +747,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
753 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done), 747 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
754 }; 748 };
755 749
756 INIT_WORK_ON_STACK(&c_idle.work, do_fork_idle); 750 INIT_WORK_ONSTACK(&c_idle.work, do_fork_idle);
757 751
758 alternatives_smp_switch(1); 752 alternatives_smp_switch(1);
759 753
@@ -785,7 +779,6 @@ do_rest:
785#ifdef CONFIG_X86_32 779#ifdef CONFIG_X86_32
786 /* 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 */
787 irq_ctx_init(cpu); 781 irq_ctx_init(cpu);
788 initial_page_table = __pa(&trampoline_pg_dir);
789#else 782#else
790 clear_tsk_thread_flag(c_idle.idle, TIF_FORK); 783 clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
791 initial_gs = per_cpu_offset(cpu); 784 initial_gs = per_cpu_offset(cpu);
@@ -934,7 +927,6 @@ int __cpuinit native_cpu_up(unsigned int cpu)
934 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; 927 per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
935 928
936 err = do_boot_cpu(apicid, cpu); 929 err = do_boot_cpu(apicid, cpu);
937
938 if (err) { 930 if (err) {
939 pr_debug("do_boot_cpu failed %d\n", err); 931 pr_debug("do_boot_cpu failed %d\n", err);
940 return -EIO; 932 return -EIO;
@@ -1381,7 +1373,6 @@ void play_dead_common(void)
1381{ 1373{
1382 idle_task_exit(); 1374 idle_task_exit();
1383 reset_lazy_tlbstate(); 1375 reset_lazy_tlbstate();
1384 irq_ctx_exit(raw_smp_processor_id());
1385 c1e_remove_cpu(raw_smp_processor_id()); 1376 c1e_remove_cpu(raw_smp_processor_id());
1386 1377
1387 mb(); 1378 mb();
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index 4c3da5674e67..a375616d77f7 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/arch/x86/kernel/trampoline.c
@@ -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 d43968503dd2..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
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/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 38e2b67807e1..e03530aebfd0 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -301,7 +301,7 @@ SECTIONS
301 } 301 }
302 302
303#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP) 303#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
304 PERCPU(PAGE_SIZE) 304 PERCPU(THREAD_SIZE)
305#endif 305#endif
306 306
307 . = ALIGN(PAGE_SIZE); 307 . = ALIGN(PAGE_SIZE);
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index cd6da6bf3eca..ceb2911aa439 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -6,10 +6,12 @@
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/ioport.h> 7#include <linux/ioport.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/pci.h>
9 10
10#include <asm/bios_ebda.h> 11#include <asm/bios_ebda.h>
11#include <asm/paravirt.h> 12#include <asm/paravirt.h>
12#include <asm/pci_x86.h> 13#include <asm/pci_x86.h>
14#include <asm/pci.h>
13#include <asm/mpspec.h> 15#include <asm/mpspec.h>
14#include <asm/setup.h> 16#include <asm/setup.h>
15#include <asm/apic.h> 17#include <asm/apic.h>
@@ -99,3 +101,8 @@ struct x86_platform_ops x86_platform = {
99}; 101};
100 102
101EXPORT_SYMBOL_GPL(x86_platform); 103EXPORT_SYMBOL_GPL(x86_platform);
104struct x86_msi_ops x86_msi = {
105 .setup_msi_irqs = native_setup_msi_irqs,
106 .teardown_msi_irq = native_teardown_msi_irq,
107 .teardown_msi_irqs = default_teardown_msi_irqs,
108};
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 22b06f7660f4..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)
@@ -1151,6 +1159,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
1151 update_divide_count(apic); 1159 update_divide_count(apic);
1152 start_apic_timer(apic); 1160 start_apic_timer(apic);
1153 apic->irr_pending = true; 1161 apic->irr_pending = true;
1162 kvm_make_request(KVM_REQ_EVENT, vcpu);
1154} 1163}
1155 1164
1156void __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..fb8b376bf28c 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;
305 338
306 if (!shadow_accessed_mask || (new_spte & shadow_accessed_mask) || 339 WARN_ON(!is_rmap_spte(new_spte));
307 !is_rmap_spte(*sptep)) 340
341 new_spte |= old_spte & shadow_dirty_mask;
342
343 mask = shadow_accessed_mask;
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,35 +715,36 @@ 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}
677 722
678static void set_spte_track_bits(u64 *sptep, u64 new_spte) 723static int set_spte_track_bits(u64 *sptep, u64 new_spte)
679{ 724{
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 0;
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);
741 return 1;
696} 742}
697 743
698static void drop_spte(struct kvm *kvm, u64 *sptep, u64 new_spte) 744static void drop_spte(struct kvm *kvm, u64 *sptep, u64 new_spte)
699{ 745{
700 set_spte_track_bits(sptep, new_spte); 746 if (set_spte_track_bits(sptep, new_spte))
701 rmap_remove(kvm, sptep); 747 rmap_remove(kvm, sptep);
702} 748}
703 749
704static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte) 750static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte)
@@ -746,13 +792,6 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn)
746 } 792 }
747 spte = rmap_next(kvm, rmapp, spte); 793 spte = rmap_next(kvm, rmapp, spte);
748 } 794 }
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 795
757 /* check for huge page mappings */ 796 /* check for huge page mappings */
758 for (i = PT_DIRECTORY_LEVEL; 797 for (i = PT_DIRECTORY_LEVEL;
@@ -947,6 +986,18 @@ static int is_empty_shadow_page(u64 *spt)
947} 986}
948#endif 987#endif
949 988
989/*
990 * This value is the sum of all of the kvm instances's
991 * kvm->arch.n_used_mmu_pages values. We need a global,
992 * aggregate version in order to make the slab shrinker
993 * faster
994 */
995static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr)
996{
997 kvm->arch.n_used_mmu_pages += nr;
998 percpu_counter_add(&kvm_total_used_mmu_pages, nr);
999}
1000
950static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp) 1001static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp)
951{ 1002{
952 ASSERT(is_empty_shadow_page(sp->spt)); 1003 ASSERT(is_empty_shadow_page(sp->spt));
@@ -956,7 +1007,7 @@ static void kvm_mmu_free_page(struct kvm *kvm, struct kvm_mmu_page *sp)
956 if (!sp->role.direct) 1007 if (!sp->role.direct)
957 __free_page(virt_to_page(sp->gfns)); 1008 __free_page(virt_to_page(sp->gfns));
958 kmem_cache_free(mmu_page_header_cache, sp); 1009 kmem_cache_free(mmu_page_header_cache, sp);
959 ++kvm->arch.n_free_mmu_pages; 1010 kvm_mod_used_mmu_pages(kvm, -1);
960} 1011}
961 1012
962static unsigned kvm_page_table_hashfn(gfn_t gfn) 1013static unsigned kvm_page_table_hashfn(gfn_t gfn)
@@ -979,7 +1030,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); 1030 bitmap_zero(sp->slot_bitmap, KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS);
980 sp->multimapped = 0; 1031 sp->multimapped = 0;
981 sp->parent_pte = parent_pte; 1032 sp->parent_pte = parent_pte;
982 --vcpu->kvm->arch.n_free_mmu_pages; 1033 kvm_mod_used_mmu_pages(vcpu->kvm, +1);
983 return sp; 1034 return sp;
984} 1035}
985 1036
@@ -1403,7 +1454,8 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
1403 if (role.direct) 1454 if (role.direct)
1404 role.cr4_pae = 0; 1455 role.cr4_pae = 0;
1405 role.access = access; 1456 role.access = access;
1406 if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { 1457 if (!vcpu->arch.mmu.direct_map
1458 && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) {
1407 quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level)); 1459 quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level));
1408 quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1; 1460 quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1;
1409 role.quadrant = quadrant; 1461 role.quadrant = quadrant;
@@ -1458,6 +1510,12 @@ static void shadow_walk_init(struct kvm_shadow_walk_iterator *iterator,
1458 iterator->addr = addr; 1510 iterator->addr = addr;
1459 iterator->shadow_addr = vcpu->arch.mmu.root_hpa; 1511 iterator->shadow_addr = vcpu->arch.mmu.root_hpa;
1460 iterator->level = vcpu->arch.mmu.shadow_root_level; 1512 iterator->level = vcpu->arch.mmu.shadow_root_level;
1513
1514 if (iterator->level == PT64_ROOT_LEVEL &&
1515 vcpu->arch.mmu.root_level < PT64_ROOT_LEVEL &&
1516 !vcpu->arch.mmu.direct_map)
1517 --iterator->level;
1518
1461 if (iterator->level == PT32E_ROOT_LEVEL) { 1519 if (iterator->level == PT32E_ROOT_LEVEL) {
1462 iterator->shadow_addr 1520 iterator->shadow_addr
1463 = vcpu->arch.mmu.pae_root[(addr >> 30) & 3]; 1521 = vcpu->arch.mmu.pae_root[(addr >> 30) & 3];
@@ -1665,41 +1723,31 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
1665 1723
1666/* 1724/*
1667 * Changing the number of mmu pages allocated to the vm 1725 * 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 1726 * Note: if goal_nr_mmu_pages is too small, you will get dead lock
1669 */ 1727 */
1670void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages) 1728void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int goal_nr_mmu_pages)
1671{ 1729{
1672 int used_pages;
1673 LIST_HEAD(invalid_list); 1730 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 /* 1731 /*
1679 * If we set the number of mmu pages to be smaller be than the 1732 * 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 1733 * number of actived pages , we must to free some mmu pages before we
1681 * change the value 1734 * change the value
1682 */ 1735 */
1683 1736
1684 if (used_pages > kvm_nr_mmu_pages) { 1737 if (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages) {
1685 while (used_pages > kvm_nr_mmu_pages && 1738 while (kvm->arch.n_used_mmu_pages > goal_nr_mmu_pages &&
1686 !list_empty(&kvm->arch.active_mmu_pages)) { 1739 !list_empty(&kvm->arch.active_mmu_pages)) {
1687 struct kvm_mmu_page *page; 1740 struct kvm_mmu_page *page;
1688 1741
1689 page = container_of(kvm->arch.active_mmu_pages.prev, 1742 page = container_of(kvm->arch.active_mmu_pages.prev,
1690 struct kvm_mmu_page, link); 1743 struct kvm_mmu_page, link);
1691 used_pages -= kvm_mmu_prepare_zap_page(kvm, page, 1744 kvm_mmu_prepare_zap_page(kvm, page, &invalid_list);
1692 &invalid_list); 1745 kvm_mmu_commit_zap_page(kvm, &invalid_list);
1693 } 1746 }
1694 kvm_mmu_commit_zap_page(kvm, &invalid_list); 1747 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 } 1748 }
1698 else
1699 kvm->arch.n_free_mmu_pages += kvm_nr_mmu_pages
1700 - kvm->arch.n_alloc_mmu_pages;
1701 1749
1702 kvm->arch.n_alloc_mmu_pages = kvm_nr_mmu_pages; 1750 kvm->arch.n_max_mmu_pages = goal_nr_mmu_pages;
1703} 1751}
1704 1752
1705static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn) 1753static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn)
@@ -1709,11 +1757,11 @@ static int kvm_mmu_unprotect_page(struct kvm *kvm, gfn_t gfn)
1709 LIST_HEAD(invalid_list); 1757 LIST_HEAD(invalid_list);
1710 int r; 1758 int r;
1711 1759
1712 pgprintk("%s: looking for gfn %lx\n", __func__, gfn); 1760 pgprintk("%s: looking for gfn %llx\n", __func__, gfn);
1713 r = 0; 1761 r = 0;
1714 1762
1715 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) { 1763 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) {
1716 pgprintk("%s: gfn %lx role %x\n", __func__, gfn, 1764 pgprintk("%s: gfn %llx role %x\n", __func__, gfn,
1717 sp->role.word); 1765 sp->role.word);
1718 r = 1; 1766 r = 1;
1719 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); 1767 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
@@ -1729,7 +1777,7 @@ static void mmu_unshadow(struct kvm *kvm, gfn_t gfn)
1729 LIST_HEAD(invalid_list); 1777 LIST_HEAD(invalid_list);
1730 1778
1731 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) { 1779 for_each_gfn_indirect_valid_sp(kvm, sp, gfn, node) {
1732 pgprintk("%s: zap %lx %x\n", 1780 pgprintk("%s: zap %llx %x\n",
1733 __func__, gfn, sp->role.word); 1781 __func__, gfn, sp->role.word);
1734 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list); 1782 kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
1735 } 1783 }
@@ -1925,7 +1973,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1925 * whether the guest actually used the pte (in order to detect 1973 * whether the guest actually used the pte (in order to detect
1926 * demand paging). 1974 * demand paging).
1927 */ 1975 */
1928 spte = shadow_base_present_pte | shadow_dirty_mask; 1976 spte = shadow_base_present_pte;
1929 if (!speculative) 1977 if (!speculative)
1930 spte |= shadow_accessed_mask; 1978 spte |= shadow_accessed_mask;
1931 if (!dirty) 1979 if (!dirty)
@@ -1948,8 +1996,8 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1948 spte |= (u64)pfn << PAGE_SHIFT; 1996 spte |= (u64)pfn << PAGE_SHIFT;
1949 1997
1950 if ((pte_access & ACC_WRITE_MASK) 1998 if ((pte_access & ACC_WRITE_MASK)
1951 || (!tdp_enabled && write_fault && !is_write_protection(vcpu) 1999 || (!vcpu->arch.mmu.direct_map && write_fault
1952 && !user_fault)) { 2000 && !is_write_protection(vcpu) && !user_fault)) {
1953 2001
1954 if (level > PT_PAGE_TABLE_LEVEL && 2002 if (level > PT_PAGE_TABLE_LEVEL &&
1955 has_wrprotected_page(vcpu->kvm, gfn, level)) { 2003 has_wrprotected_page(vcpu->kvm, gfn, level)) {
@@ -1960,7 +2008,8 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1960 2008
1961 spte |= PT_WRITABLE_MASK; 2009 spte |= PT_WRITABLE_MASK;
1962 2010
1963 if (!tdp_enabled && !(pte_access & ACC_WRITE_MASK)) 2011 if (!vcpu->arch.mmu.direct_map
2012 && !(pte_access & ACC_WRITE_MASK))
1964 spte &= ~PT_USER_MASK; 2013 spte &= ~PT_USER_MASK;
1965 2014
1966 /* 2015 /*
@@ -1973,7 +2022,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1973 goto set_pte; 2022 goto set_pte;
1974 2023
1975 if (mmu_need_write_protect(vcpu, gfn, can_unsync)) { 2024 if (mmu_need_write_protect(vcpu, gfn, can_unsync)) {
1976 pgprintk("%s: found shadow page for %lx, marking ro\n", 2025 pgprintk("%s: found shadow page for %llx, marking ro\n",
1977 __func__, gfn); 2026 __func__, gfn);
1978 ret = 1; 2027 ret = 1;
1979 pte_access &= ~ACC_WRITE_MASK; 2028 pte_access &= ~ACC_WRITE_MASK;
@@ -1986,8 +2035,6 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1986 mark_page_dirty(vcpu->kvm, gfn); 2035 mark_page_dirty(vcpu->kvm, gfn);
1987 2036
1988set_pte: 2037set_pte:
1989 if (is_writable_pte(*sptep) && !is_writable_pte(spte))
1990 kvm_set_pfn_dirty(pfn);
1991 update_spte(sptep, spte); 2038 update_spte(sptep, spte);
1992done: 2039done:
1993 return ret; 2040 return ret;
@@ -2004,7 +2051,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2004 int rmap_count; 2051 int rmap_count;
2005 2052
2006 pgprintk("%s: spte %llx access %x write_fault %d" 2053 pgprintk("%s: spte %llx access %x write_fault %d"
2007 " user_fault %d gfn %lx\n", 2054 " user_fault %d gfn %llx\n",
2008 __func__, *sptep, pt_access, 2055 __func__, *sptep, pt_access,
2009 write_fault, user_fault, gfn); 2056 write_fault, user_fault, gfn);
2010 2057
@@ -2023,7 +2070,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2023 __set_spte(sptep, shadow_trap_nonpresent_pte); 2070 __set_spte(sptep, shadow_trap_nonpresent_pte);
2024 kvm_flush_remote_tlbs(vcpu->kvm); 2071 kvm_flush_remote_tlbs(vcpu->kvm);
2025 } else if (pfn != spte_to_pfn(*sptep)) { 2072 } else if (pfn != spte_to_pfn(*sptep)) {
2026 pgprintk("hfn old %lx new %lx\n", 2073 pgprintk("hfn old %llx new %llx\n",
2027 spte_to_pfn(*sptep), pfn); 2074 spte_to_pfn(*sptep), pfn);
2028 drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte); 2075 drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte);
2029 kvm_flush_remote_tlbs(vcpu->kvm); 2076 kvm_flush_remote_tlbs(vcpu->kvm);
@@ -2040,7 +2087,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2040 } 2087 }
2041 2088
2042 pgprintk("%s: setting spte %llx\n", __func__, *sptep); 2089 pgprintk("%s: setting spte %llx\n", __func__, *sptep);
2043 pgprintk("instantiating %s PTE (%s) at %ld (%llx) addr %p\n", 2090 pgprintk("instantiating %s PTE (%s) at %llx (%llx) addr %p\n",
2044 is_large_pte(*sptep)? "2MB" : "4kB", 2091 is_large_pte(*sptep)? "2MB" : "4kB",
2045 *sptep & PT_PRESENT_MASK ?"RW":"R", gfn, 2092 *sptep & PT_PRESENT_MASK ?"RW":"R", gfn,
2046 *sptep, sptep); 2093 *sptep, sptep);
@@ -2064,6 +2111,105 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
2064{ 2111{
2065} 2112}
2066 2113
2114static struct kvm_memory_slot *
2115pte_prefetch_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn, bool no_dirty_log)
2116{
2117 struct kvm_memory_slot *slot;
2118
2119 slot = gfn_to_memslot(vcpu->kvm, gfn);
2120 if (!slot || slot->flags & KVM_MEMSLOT_INVALID ||
2121 (no_dirty_log && slot->dirty_bitmap))
2122 slot = NULL;
2123
2124 return slot;
2125}
2126
2127static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn,
2128 bool no_dirty_log)
2129{
2130 struct kvm_memory_slot *slot;
2131 unsigned long hva;
2132
2133 slot = pte_prefetch_gfn_to_memslot(vcpu, gfn, no_dirty_log);
2134 if (!slot) {
2135 get_page(bad_page);
2136 return page_to_pfn(bad_page);
2137 }
2138
2139 hva = gfn_to_hva_memslot(slot, gfn);
2140
2141 return hva_to_pfn_atomic(vcpu->kvm, hva);
2142}
2143
2144static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu,
2145 struct kvm_mmu_page *sp,
2146 u64 *start, u64 *end)
2147{
2148 struct page *pages[PTE_PREFETCH_NUM];
2149 unsigned access = sp->role.access;
2150 int i, ret;
2151 gfn_t gfn;
2152
2153 gfn = kvm_mmu_page_get_gfn(sp, start - sp->spt);
2154 if (!pte_prefetch_gfn_to_memslot(vcpu, gfn, access & ACC_WRITE_MASK))
2155 return -1;
2156
2157 ret = gfn_to_page_many_atomic(vcpu->kvm, gfn, pages, end - start);
2158 if (ret <= 0)
2159 return -1;
2160
2161 for (i = 0; i < ret; i++, gfn++, start++)
2162 mmu_set_spte(vcpu, start, ACC_ALL,
2163 access, 0, 0, 1, NULL,
2164 sp->role.level, gfn,
2165 page_to_pfn(pages[i]), true, true);
2166
2167 return 0;
2168}
2169
2170static void __direct_pte_prefetch(struct kvm_vcpu *vcpu,
2171 struct kvm_mmu_page *sp, u64 *sptep)
2172{
2173 u64 *spte, *start = NULL;
2174 int i;
2175
2176 WARN_ON(!sp->role.direct);
2177
2178 i = (sptep - sp->spt) & ~(PTE_PREFETCH_NUM - 1);
2179 spte = sp->spt + i;
2180
2181 for (i = 0; i < PTE_PREFETCH_NUM; i++, spte++) {
2182 if (*spte != shadow_trap_nonpresent_pte || spte == sptep) {
2183 if (!start)
2184 continue;
2185 if (direct_pte_prefetch_many(vcpu, sp, start, spte) < 0)
2186 break;
2187 start = NULL;
2188 } else if (!start)
2189 start = spte;
2190 }
2191}
2192
2193static void direct_pte_prefetch(struct kvm_vcpu *vcpu, u64 *sptep)
2194{
2195 struct kvm_mmu_page *sp;
2196
2197 /*
2198 * Since it's no accessed bit on EPT, it's no way to
2199 * distinguish between actually accessed translations
2200 * and prefetched, so disable pte prefetch if EPT is
2201 * enabled.
2202 */
2203 if (!shadow_accessed_mask)
2204 return;
2205
2206 sp = page_header(__pa(sptep));
2207 if (sp->role.level > PT_PAGE_TABLE_LEVEL)
2208 return;
2209
2210 __direct_pte_prefetch(vcpu, sp, sptep);
2211}
2212
2067static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, 2213static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2068 int level, gfn_t gfn, pfn_t pfn) 2214 int level, gfn_t gfn, pfn_t pfn)
2069{ 2215{
@@ -2077,6 +2223,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, 2223 mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, ACC_ALL,
2078 0, write, 1, &pt_write, 2224 0, write, 1, &pt_write,
2079 level, gfn, pfn, false, true); 2225 level, gfn, pfn, false, true);
2226 direct_pte_prefetch(vcpu, iterator.sptep);
2080 ++vcpu->stat.pf_fixed; 2227 ++vcpu->stat.pf_fixed;
2081 break; 2228 break;
2082 } 2229 }
@@ -2098,28 +2245,31 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2098 __set_spte(iterator.sptep, 2245 __set_spte(iterator.sptep,
2099 __pa(sp->spt) 2246 __pa(sp->spt)
2100 | PT_PRESENT_MASK | PT_WRITABLE_MASK 2247 | PT_PRESENT_MASK | PT_WRITABLE_MASK
2101 | shadow_user_mask | shadow_x_mask); 2248 | shadow_user_mask | shadow_x_mask
2249 | shadow_accessed_mask);
2102 } 2250 }
2103 } 2251 }
2104 return pt_write; 2252 return pt_write;
2105} 2253}
2106 2254
2107static void kvm_send_hwpoison_signal(struct kvm *kvm, gfn_t gfn) 2255static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct *tsk)
2108{ 2256{
2109 char buf[1]; 2257 siginfo_t info;
2110 void __user *hva;
2111 int r;
2112 2258
2113 /* Touch the page, so send SIGBUS */ 2259 info.si_signo = SIGBUS;
2114 hva = (void __user *)gfn_to_hva(kvm, gfn); 2260 info.si_errno = 0;
2115 r = copy_from_user(buf, hva, 1); 2261 info.si_code = BUS_MCEERR_AR;
2262 info.si_addr = (void __user *)address;
2263 info.si_addr_lsb = PAGE_SHIFT;
2264
2265 send_sig_info(SIGBUS, &info, tsk);
2116} 2266}
2117 2267
2118static int kvm_handle_bad_page(struct kvm *kvm, gfn_t gfn, pfn_t pfn) 2268static int kvm_handle_bad_page(struct kvm *kvm, gfn_t gfn, pfn_t pfn)
2119{ 2269{
2120 kvm_release_pfn_clean(pfn); 2270 kvm_release_pfn_clean(pfn);
2121 if (is_hwpoison_pfn(pfn)) { 2271 if (is_hwpoison_pfn(pfn)) {
2122 kvm_send_hwpoison_signal(kvm, gfn); 2272 kvm_send_hwpoison_signal(gfn_to_hva(kvm, gfn), current);
2123 return 0; 2273 return 0;
2124 } else if (is_fault_pfn(pfn)) 2274 } else if (is_fault_pfn(pfn))
2125 return -EFAULT; 2275 return -EFAULT;
@@ -2179,7 +2329,9 @@ static void mmu_free_roots(struct kvm_vcpu *vcpu)
2179 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) 2329 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
2180 return; 2330 return;
2181 spin_lock(&vcpu->kvm->mmu_lock); 2331 spin_lock(&vcpu->kvm->mmu_lock);
2182 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2332 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL &&
2333 (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL ||
2334 vcpu->arch.mmu.direct_map)) {
2183 hpa_t root = vcpu->arch.mmu.root_hpa; 2335 hpa_t root = vcpu->arch.mmu.root_hpa;
2184 2336
2185 sp = page_header(root); 2337 sp = page_header(root);
@@ -2222,80 +2374,158 @@ static int mmu_check_root(struct kvm_vcpu *vcpu, gfn_t root_gfn)
2222 return ret; 2374 return ret;
2223} 2375}
2224 2376
2225static int mmu_alloc_roots(struct kvm_vcpu *vcpu) 2377static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu)
2226{ 2378{
2227 int i;
2228 gfn_t root_gfn;
2229 struct kvm_mmu_page *sp; 2379 struct kvm_mmu_page *sp;
2230 int direct = 0; 2380 unsigned i;
2231 u64 pdptr;
2232
2233 root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT;
2234 2381
2235 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2382 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
2383 spin_lock(&vcpu->kvm->mmu_lock);
2384 kvm_mmu_free_some_pages(vcpu);
2385 sp = kvm_mmu_get_page(vcpu, 0, 0, PT64_ROOT_LEVEL,
2386 1, ACC_ALL, NULL);
2387 ++sp->root_count;
2388 spin_unlock(&vcpu->kvm->mmu_lock);
2389 vcpu->arch.mmu.root_hpa = __pa(sp->spt);
2390 } else if (vcpu->arch.mmu.shadow_root_level == PT32E_ROOT_LEVEL) {
2391 for (i = 0; i < 4; ++i) {
2392 hpa_t root = vcpu->arch.mmu.pae_root[i];
2393
2394 ASSERT(!VALID_PAGE(root));
2395 spin_lock(&vcpu->kvm->mmu_lock);
2396 kvm_mmu_free_some_pages(vcpu);
2397 sp = kvm_mmu_get_page(vcpu, i << 30, i << 30,
2398 PT32_ROOT_LEVEL, 1, ACC_ALL,
2399 NULL);
2400 root = __pa(sp->spt);
2401 ++sp->root_count;
2402 spin_unlock(&vcpu->kvm->mmu_lock);
2403 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK;
2404 }
2405 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
2406 } else
2407 BUG();
2408
2409 return 0;
2410}
2411
2412static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu)
2413{
2414 struct kvm_mmu_page *sp;
2415 u64 pdptr, pm_mask;
2416 gfn_t root_gfn;
2417 int i;
2418
2419 root_gfn = vcpu->arch.mmu.get_cr3(vcpu) >> PAGE_SHIFT;
2420
2421 if (mmu_check_root(vcpu, root_gfn))
2422 return 1;
2423
2424 /*
2425 * Do we shadow a long mode page table? If so we need to
2426 * write-protect the guests page table root.
2427 */
2428 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
2236 hpa_t root = vcpu->arch.mmu.root_hpa; 2429 hpa_t root = vcpu->arch.mmu.root_hpa;
2237 2430
2238 ASSERT(!VALID_PAGE(root)); 2431 ASSERT(!VALID_PAGE(root));
2239 if (mmu_check_root(vcpu, root_gfn)) 2432
2240 return 1;
2241 if (tdp_enabled) {
2242 direct = 1;
2243 root_gfn = 0;
2244 }
2245 spin_lock(&vcpu->kvm->mmu_lock); 2433 spin_lock(&vcpu->kvm->mmu_lock);
2246 kvm_mmu_free_some_pages(vcpu); 2434 kvm_mmu_free_some_pages(vcpu);
2247 sp = kvm_mmu_get_page(vcpu, root_gfn, 0, 2435 sp = kvm_mmu_get_page(vcpu, root_gfn, 0, PT64_ROOT_LEVEL,
2248 PT64_ROOT_LEVEL, direct, 2436 0, ACC_ALL, NULL);
2249 ACC_ALL, NULL);
2250 root = __pa(sp->spt); 2437 root = __pa(sp->spt);
2251 ++sp->root_count; 2438 ++sp->root_count;
2252 spin_unlock(&vcpu->kvm->mmu_lock); 2439 spin_unlock(&vcpu->kvm->mmu_lock);
2253 vcpu->arch.mmu.root_hpa = root; 2440 vcpu->arch.mmu.root_hpa = root;
2254 return 0; 2441 return 0;
2255 } 2442 }
2256 direct = !is_paging(vcpu); 2443
2444 /*
2445 * We shadow a 32 bit page table. This may be a legacy 2-level
2446 * or a PAE 3-level page table. In either case we need to be aware that
2447 * the shadow page table may be a PAE or a long mode page table.
2448 */
2449 pm_mask = PT_PRESENT_MASK;
2450 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL)
2451 pm_mask |= PT_ACCESSED_MASK | PT_WRITABLE_MASK | PT_USER_MASK;
2452
2257 for (i = 0; i < 4; ++i) { 2453 for (i = 0; i < 4; ++i) {
2258 hpa_t root = vcpu->arch.mmu.pae_root[i]; 2454 hpa_t root = vcpu->arch.mmu.pae_root[i];
2259 2455
2260 ASSERT(!VALID_PAGE(root)); 2456 ASSERT(!VALID_PAGE(root));
2261 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { 2457 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) {
2262 pdptr = kvm_pdptr_read(vcpu, i); 2458 pdptr = kvm_pdptr_read_mmu(vcpu, &vcpu->arch.mmu, i);
2263 if (!is_present_gpte(pdptr)) { 2459 if (!is_present_gpte(pdptr)) {
2264 vcpu->arch.mmu.pae_root[i] = 0; 2460 vcpu->arch.mmu.pae_root[i] = 0;
2265 continue; 2461 continue;
2266 } 2462 }
2267 root_gfn = pdptr >> PAGE_SHIFT; 2463 root_gfn = pdptr >> PAGE_SHIFT;
2268 } else if (vcpu->arch.mmu.root_level == 0) 2464 if (mmu_check_root(vcpu, root_gfn))
2269 root_gfn = 0; 2465 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 } 2466 }
2276 spin_lock(&vcpu->kvm->mmu_lock); 2467 spin_lock(&vcpu->kvm->mmu_lock);
2277 kvm_mmu_free_some_pages(vcpu); 2468 kvm_mmu_free_some_pages(vcpu);
2278 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, 2469 sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30,
2279 PT32_ROOT_LEVEL, direct, 2470 PT32_ROOT_LEVEL, 0,
2280 ACC_ALL, NULL); 2471 ACC_ALL, NULL);
2281 root = __pa(sp->spt); 2472 root = __pa(sp->spt);
2282 ++sp->root_count; 2473 ++sp->root_count;
2283 spin_unlock(&vcpu->kvm->mmu_lock); 2474 spin_unlock(&vcpu->kvm->mmu_lock);
2284 2475
2285 vcpu->arch.mmu.pae_root[i] = root | PT_PRESENT_MASK; 2476 vcpu->arch.mmu.pae_root[i] = root | pm_mask;
2286 } 2477 }
2287 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root); 2478 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.pae_root);
2479
2480 /*
2481 * If we shadow a 32 bit page table with a long mode page
2482 * table we enter this path.
2483 */
2484 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) {
2485 if (vcpu->arch.mmu.lm_root == NULL) {
2486 /*
2487 * The additional page necessary for this is only
2488 * allocated on demand.
2489 */
2490
2491 u64 *lm_root;
2492
2493 lm_root = (void*)get_zeroed_page(GFP_KERNEL);
2494 if (lm_root == NULL)
2495 return 1;
2496
2497 lm_root[0] = __pa(vcpu->arch.mmu.pae_root) | pm_mask;
2498
2499 vcpu->arch.mmu.lm_root = lm_root;
2500 }
2501
2502 vcpu->arch.mmu.root_hpa = __pa(vcpu->arch.mmu.lm_root);
2503 }
2504
2288 return 0; 2505 return 0;
2289} 2506}
2290 2507
2508static int mmu_alloc_roots(struct kvm_vcpu *vcpu)
2509{
2510 if (vcpu->arch.mmu.direct_map)
2511 return mmu_alloc_direct_roots(vcpu);
2512 else
2513 return mmu_alloc_shadow_roots(vcpu);
2514}
2515
2291static void mmu_sync_roots(struct kvm_vcpu *vcpu) 2516static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2292{ 2517{
2293 int i; 2518 int i;
2294 struct kvm_mmu_page *sp; 2519 struct kvm_mmu_page *sp;
2295 2520
2521 if (vcpu->arch.mmu.direct_map)
2522 return;
2523
2296 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) 2524 if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
2297 return; 2525 return;
2298 if (vcpu->arch.mmu.shadow_root_level == PT64_ROOT_LEVEL) { 2526
2527 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_SYNC);
2528 if (vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL) {
2299 hpa_t root = vcpu->arch.mmu.root_hpa; 2529 hpa_t root = vcpu->arch.mmu.root_hpa;
2300 sp = page_header(root); 2530 sp = page_header(root);
2301 mmu_sync_children(vcpu, sp); 2531 mmu_sync_children(vcpu, sp);
@@ -2310,6 +2540,7 @@ static void mmu_sync_roots(struct kvm_vcpu *vcpu)
2310 mmu_sync_children(vcpu, sp); 2540 mmu_sync_children(vcpu, sp);
2311 } 2541 }
2312 } 2542 }
2543 trace_kvm_mmu_audit(vcpu, AUDIT_POST_SYNC);
2313} 2544}
2314 2545
2315void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) 2546void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu)
@@ -2327,6 +2558,14 @@ static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr,
2327 return vaddr; 2558 return vaddr;
2328} 2559}
2329 2560
2561static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr,
2562 u32 access, u32 *error)
2563{
2564 if (error)
2565 *error = 0;
2566 return vcpu->arch.nested_mmu.translate_gpa(vcpu, vaddr, access);
2567}
2568
2330static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, 2569static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
2331 u32 error_code) 2570 u32 error_code)
2332{ 2571{
@@ -2393,10 +2632,9 @@ static void nonpaging_free(struct kvm_vcpu *vcpu)
2393 mmu_free_roots(vcpu); 2632 mmu_free_roots(vcpu);
2394} 2633}
2395 2634
2396static int nonpaging_init_context(struct kvm_vcpu *vcpu) 2635static int nonpaging_init_context(struct kvm_vcpu *vcpu,
2636 struct kvm_mmu *context)
2397{ 2637{
2398 struct kvm_mmu *context = &vcpu->arch.mmu;
2399
2400 context->new_cr3 = nonpaging_new_cr3; 2638 context->new_cr3 = nonpaging_new_cr3;
2401 context->page_fault = nonpaging_page_fault; 2639 context->page_fault = nonpaging_page_fault;
2402 context->gva_to_gpa = nonpaging_gva_to_gpa; 2640 context->gva_to_gpa = nonpaging_gva_to_gpa;
@@ -2407,6 +2645,8 @@ static int nonpaging_init_context(struct kvm_vcpu *vcpu)
2407 context->root_level = 0; 2645 context->root_level = 0;
2408 context->shadow_root_level = PT32E_ROOT_LEVEL; 2646 context->shadow_root_level = PT32E_ROOT_LEVEL;
2409 context->root_hpa = INVALID_PAGE; 2647 context->root_hpa = INVALID_PAGE;
2648 context->direct_map = true;
2649 context->nx = false;
2410 return 0; 2650 return 0;
2411} 2651}
2412 2652
@@ -2422,11 +2662,14 @@ static void paging_new_cr3(struct kvm_vcpu *vcpu)
2422 mmu_free_roots(vcpu); 2662 mmu_free_roots(vcpu);
2423} 2663}
2424 2664
2425static void inject_page_fault(struct kvm_vcpu *vcpu, 2665static unsigned long get_cr3(struct kvm_vcpu *vcpu)
2426 u64 addr,
2427 u32 err_code)
2428{ 2666{
2429 kvm_inject_page_fault(vcpu, addr, err_code); 2667 return vcpu->arch.cr3;
2668}
2669
2670static void inject_page_fault(struct kvm_vcpu *vcpu)
2671{
2672 vcpu->arch.mmu.inject_page_fault(vcpu);
2430} 2673}
2431 2674
2432static void paging_free(struct kvm_vcpu *vcpu) 2675static void paging_free(struct kvm_vcpu *vcpu)
@@ -2434,12 +2677,12 @@ static void paging_free(struct kvm_vcpu *vcpu)
2434 nonpaging_free(vcpu); 2677 nonpaging_free(vcpu);
2435} 2678}
2436 2679
2437static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level) 2680static bool is_rsvd_bits_set(struct kvm_mmu *mmu, u64 gpte, int level)
2438{ 2681{
2439 int bit7; 2682 int bit7;
2440 2683
2441 bit7 = (gpte >> 7) & 1; 2684 bit7 = (gpte >> 7) & 1;
2442 return (gpte & vcpu->arch.mmu.rsvd_bits_mask[bit7][level-1]) != 0; 2685 return (gpte & mmu->rsvd_bits_mask[bit7][level-1]) != 0;
2443} 2686}
2444 2687
2445#define PTTYPE 64 2688#define PTTYPE 64
@@ -2450,13 +2693,14 @@ static bool is_rsvd_bits_set(struct kvm_vcpu *vcpu, u64 gpte, int level)
2450#include "paging_tmpl.h" 2693#include "paging_tmpl.h"
2451#undef PTTYPE 2694#undef PTTYPE
2452 2695
2453static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level) 2696static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
2697 struct kvm_mmu *context,
2698 int level)
2454{ 2699{
2455 struct kvm_mmu *context = &vcpu->arch.mmu;
2456 int maxphyaddr = cpuid_maxphyaddr(vcpu); 2700 int maxphyaddr = cpuid_maxphyaddr(vcpu);
2457 u64 exb_bit_rsvd = 0; 2701 u64 exb_bit_rsvd = 0;
2458 2702
2459 if (!is_nx(vcpu)) 2703 if (!context->nx)
2460 exb_bit_rsvd = rsvd_bits(63, 63); 2704 exb_bit_rsvd = rsvd_bits(63, 63);
2461 switch (level) { 2705 switch (level) {
2462 case PT32_ROOT_LEVEL: 2706 case PT32_ROOT_LEVEL:
@@ -2511,9 +2755,13 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, int level)
2511 } 2755 }
2512} 2756}
2513 2757
2514static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level) 2758static int paging64_init_context_common(struct kvm_vcpu *vcpu,
2759 struct kvm_mmu *context,
2760 int level)
2515{ 2761{
2516 struct kvm_mmu *context = &vcpu->arch.mmu; 2762 context->nx = is_nx(vcpu);
2763
2764 reset_rsvds_bits_mask(vcpu, context, level);
2517 2765
2518 ASSERT(is_pae(vcpu)); 2766 ASSERT(is_pae(vcpu));
2519 context->new_cr3 = paging_new_cr3; 2767 context->new_cr3 = paging_new_cr3;
@@ -2526,20 +2774,23 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu, int level)
2526 context->root_level = level; 2774 context->root_level = level;
2527 context->shadow_root_level = level; 2775 context->shadow_root_level = level;
2528 context->root_hpa = INVALID_PAGE; 2776 context->root_hpa = INVALID_PAGE;
2777 context->direct_map = false;
2529 return 0; 2778 return 0;
2530} 2779}
2531 2780
2532static int paging64_init_context(struct kvm_vcpu *vcpu) 2781static int paging64_init_context(struct kvm_vcpu *vcpu,
2782 struct kvm_mmu *context)
2533{ 2783{
2534 reset_rsvds_bits_mask(vcpu, PT64_ROOT_LEVEL); 2784 return paging64_init_context_common(vcpu, context, PT64_ROOT_LEVEL);
2535 return paging64_init_context_common(vcpu, PT64_ROOT_LEVEL);
2536} 2785}
2537 2786
2538static int paging32_init_context(struct kvm_vcpu *vcpu) 2787static int paging32_init_context(struct kvm_vcpu *vcpu,
2788 struct kvm_mmu *context)
2539{ 2789{
2540 struct kvm_mmu *context = &vcpu->arch.mmu; 2790 context->nx = false;
2791
2792 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL);
2541 2793
2542 reset_rsvds_bits_mask(vcpu, PT32_ROOT_LEVEL);
2543 context->new_cr3 = paging_new_cr3; 2794 context->new_cr3 = paging_new_cr3;
2544 context->page_fault = paging32_page_fault; 2795 context->page_fault = paging32_page_fault;
2545 context->gva_to_gpa = paging32_gva_to_gpa; 2796 context->gva_to_gpa = paging32_gva_to_gpa;
@@ -2550,18 +2801,19 @@ static int paging32_init_context(struct kvm_vcpu *vcpu)
2550 context->root_level = PT32_ROOT_LEVEL; 2801 context->root_level = PT32_ROOT_LEVEL;
2551 context->shadow_root_level = PT32E_ROOT_LEVEL; 2802 context->shadow_root_level = PT32E_ROOT_LEVEL;
2552 context->root_hpa = INVALID_PAGE; 2803 context->root_hpa = INVALID_PAGE;
2804 context->direct_map = false;
2553 return 0; 2805 return 0;
2554} 2806}
2555 2807
2556static int paging32E_init_context(struct kvm_vcpu *vcpu) 2808static int paging32E_init_context(struct kvm_vcpu *vcpu,
2809 struct kvm_mmu *context)
2557{ 2810{
2558 reset_rsvds_bits_mask(vcpu, PT32E_ROOT_LEVEL); 2811 return paging64_init_context_common(vcpu, context, PT32E_ROOT_LEVEL);
2559 return paging64_init_context_common(vcpu, PT32E_ROOT_LEVEL);
2560} 2812}
2561 2813
2562static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) 2814static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2563{ 2815{
2564 struct kvm_mmu *context = &vcpu->arch.mmu; 2816 struct kvm_mmu *context = vcpu->arch.walk_mmu;
2565 2817
2566 context->new_cr3 = nonpaging_new_cr3; 2818 context->new_cr3 = nonpaging_new_cr3;
2567 context->page_fault = tdp_page_fault; 2819 context->page_fault = tdp_page_fault;
@@ -2571,20 +2823,29 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2571 context->invlpg = nonpaging_invlpg; 2823 context->invlpg = nonpaging_invlpg;
2572 context->shadow_root_level = kvm_x86_ops->get_tdp_level(); 2824 context->shadow_root_level = kvm_x86_ops->get_tdp_level();
2573 context->root_hpa = INVALID_PAGE; 2825 context->root_hpa = INVALID_PAGE;
2826 context->direct_map = true;
2827 context->set_cr3 = kvm_x86_ops->set_tdp_cr3;
2828 context->get_cr3 = get_cr3;
2829 context->inject_page_fault = kvm_inject_page_fault;
2830 context->nx = is_nx(vcpu);
2574 2831
2575 if (!is_paging(vcpu)) { 2832 if (!is_paging(vcpu)) {
2833 context->nx = false;
2576 context->gva_to_gpa = nonpaging_gva_to_gpa; 2834 context->gva_to_gpa = nonpaging_gva_to_gpa;
2577 context->root_level = 0; 2835 context->root_level = 0;
2578 } else if (is_long_mode(vcpu)) { 2836 } else if (is_long_mode(vcpu)) {
2579 reset_rsvds_bits_mask(vcpu, PT64_ROOT_LEVEL); 2837 context->nx = is_nx(vcpu);
2838 reset_rsvds_bits_mask(vcpu, context, PT64_ROOT_LEVEL);
2580 context->gva_to_gpa = paging64_gva_to_gpa; 2839 context->gva_to_gpa = paging64_gva_to_gpa;
2581 context->root_level = PT64_ROOT_LEVEL; 2840 context->root_level = PT64_ROOT_LEVEL;
2582 } else if (is_pae(vcpu)) { 2841 } else if (is_pae(vcpu)) {
2583 reset_rsvds_bits_mask(vcpu, PT32E_ROOT_LEVEL); 2842 context->nx = is_nx(vcpu);
2843 reset_rsvds_bits_mask(vcpu, context, PT32E_ROOT_LEVEL);
2584 context->gva_to_gpa = paging64_gva_to_gpa; 2844 context->gva_to_gpa = paging64_gva_to_gpa;
2585 context->root_level = PT32E_ROOT_LEVEL; 2845 context->root_level = PT32E_ROOT_LEVEL;
2586 } else { 2846 } else {
2587 reset_rsvds_bits_mask(vcpu, PT32_ROOT_LEVEL); 2847 context->nx = false;
2848 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL);
2588 context->gva_to_gpa = paging32_gva_to_gpa; 2849 context->gva_to_gpa = paging32_gva_to_gpa;
2589 context->root_level = PT32_ROOT_LEVEL; 2850 context->root_level = PT32_ROOT_LEVEL;
2590 } 2851 }
@@ -2592,33 +2853,83 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2592 return 0; 2853 return 0;
2593} 2854}
2594 2855
2595static int init_kvm_softmmu(struct kvm_vcpu *vcpu) 2856int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
2596{ 2857{
2597 int r; 2858 int r;
2598
2599 ASSERT(vcpu); 2859 ASSERT(vcpu);
2600 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa)); 2860 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
2601 2861
2602 if (!is_paging(vcpu)) 2862 if (!is_paging(vcpu))
2603 r = nonpaging_init_context(vcpu); 2863 r = nonpaging_init_context(vcpu, context);
2604 else if (is_long_mode(vcpu)) 2864 else if (is_long_mode(vcpu))
2605 r = paging64_init_context(vcpu); 2865 r = paging64_init_context(vcpu, context);
2606 else if (is_pae(vcpu)) 2866 else if (is_pae(vcpu))
2607 r = paging32E_init_context(vcpu); 2867 r = paging32E_init_context(vcpu, context);
2608 else 2868 else
2609 r = paging32_init_context(vcpu); 2869 r = paging32_init_context(vcpu, context);
2610 2870
2611 vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu); 2871 vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu);
2612 vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu); 2872 vcpu->arch.mmu.base_role.cr0_wp = is_write_protection(vcpu);
2613 2873
2614 return r; 2874 return r;
2615} 2875}
2876EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu);
2877
2878static int init_kvm_softmmu(struct kvm_vcpu *vcpu)
2879{
2880 int r = kvm_init_shadow_mmu(vcpu, vcpu->arch.walk_mmu);
2881
2882 vcpu->arch.walk_mmu->set_cr3 = kvm_x86_ops->set_cr3;
2883 vcpu->arch.walk_mmu->get_cr3 = get_cr3;
2884 vcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault;
2885
2886 return r;
2887}
2888
2889static int init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
2890{
2891 struct kvm_mmu *g_context = &vcpu->arch.nested_mmu;
2892
2893 g_context->get_cr3 = get_cr3;
2894 g_context->inject_page_fault = kvm_inject_page_fault;
2895
2896 /*
2897 * Note that arch.mmu.gva_to_gpa translates l2_gva to l1_gpa. The
2898 * translation of l2_gpa to l1_gpa addresses is done using the
2899 * arch.nested_mmu.gva_to_gpa function. Basically the gva_to_gpa
2900 * functions between mmu and nested_mmu are swapped.
2901 */
2902 if (!is_paging(vcpu)) {
2903 g_context->nx = false;
2904 g_context->root_level = 0;
2905 g_context->gva_to_gpa = nonpaging_gva_to_gpa_nested;
2906 } else if (is_long_mode(vcpu)) {
2907 g_context->nx = is_nx(vcpu);
2908 reset_rsvds_bits_mask(vcpu, g_context, PT64_ROOT_LEVEL);
2909 g_context->root_level = PT64_ROOT_LEVEL;
2910 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
2911 } else if (is_pae(vcpu)) {
2912 g_context->nx = is_nx(vcpu);
2913 reset_rsvds_bits_mask(vcpu, g_context, PT32E_ROOT_LEVEL);
2914 g_context->root_level = PT32E_ROOT_LEVEL;
2915 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
2916 } else {
2917 g_context->nx = false;
2918 reset_rsvds_bits_mask(vcpu, g_context, PT32_ROOT_LEVEL);
2919 g_context->root_level = PT32_ROOT_LEVEL;
2920 g_context->gva_to_gpa = paging32_gva_to_gpa_nested;
2921 }
2922
2923 return 0;
2924}
2616 2925
2617static int init_kvm_mmu(struct kvm_vcpu *vcpu) 2926static int init_kvm_mmu(struct kvm_vcpu *vcpu)
2618{ 2927{
2619 vcpu->arch.update_pte.pfn = bad_pfn; 2928 vcpu->arch.update_pte.pfn = bad_pfn;
2620 2929
2621 if (tdp_enabled) 2930 if (mmu_is_nested(vcpu))
2931 return init_kvm_nested_mmu(vcpu);
2932 else if (tdp_enabled)
2622 return init_kvm_tdp_mmu(vcpu); 2933 return init_kvm_tdp_mmu(vcpu);
2623 else 2934 else
2624 return init_kvm_softmmu(vcpu); 2935 return init_kvm_softmmu(vcpu);
@@ -2653,7 +2964,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu)
2653 if (r) 2964 if (r)
2654 goto out; 2965 goto out;
2655 /* set_cr3() should ensure TLB has been flushed */ 2966 /* set_cr3() should ensure TLB has been flushed */
2656 kvm_x86_ops->set_cr3(vcpu, vcpu->arch.mmu.root_hpa); 2967 vcpu->arch.mmu.set_cr3(vcpu, vcpu->arch.mmu.root_hpa);
2657out: 2968out:
2658 return r; 2969 return r;
2659} 2970}
@@ -2663,6 +2974,7 @@ void kvm_mmu_unload(struct kvm_vcpu *vcpu)
2663{ 2974{
2664 mmu_free_roots(vcpu); 2975 mmu_free_roots(vcpu);
2665} 2976}
2977EXPORT_SYMBOL_GPL(kvm_mmu_unload);
2666 2978
2667static void mmu_pte_write_zap_pte(struct kvm_vcpu *vcpu, 2979static void mmu_pte_write_zap_pte(struct kvm_vcpu *vcpu,
2668 struct kvm_mmu_page *sp, 2980 struct kvm_mmu_page *sp,
@@ -2695,7 +3007,7 @@ static void mmu_pte_write_new_pte(struct kvm_vcpu *vcpu,
2695 return; 3007 return;
2696 } 3008 }
2697 3009
2698 if (is_rsvd_bits_set(vcpu, *(u64 *)new, PT_PAGE_TABLE_LEVEL)) 3010 if (is_rsvd_bits_set(&vcpu->arch.mmu, *(u64 *)new, PT_PAGE_TABLE_LEVEL))
2699 return; 3011 return;
2700 3012
2701 ++vcpu->kvm->stat.mmu_pte_updated; 3013 ++vcpu->kvm->stat.mmu_pte_updated;
@@ -2837,7 +3149,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
2837 kvm_mmu_access_page(vcpu, gfn); 3149 kvm_mmu_access_page(vcpu, gfn);
2838 kvm_mmu_free_some_pages(vcpu); 3150 kvm_mmu_free_some_pages(vcpu);
2839 ++vcpu->kvm->stat.mmu_pte_write; 3151 ++vcpu->kvm->stat.mmu_pte_write;
2840 kvm_mmu_audit(vcpu, "pre pte write"); 3152 trace_kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE);
2841 if (guest_initiated) { 3153 if (guest_initiated) {
2842 if (gfn == vcpu->arch.last_pt_write_gfn 3154 if (gfn == vcpu->arch.last_pt_write_gfn
2843 && !last_updated_pte_accessed(vcpu)) { 3155 && !last_updated_pte_accessed(vcpu)) {
@@ -2910,7 +3222,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
2910 } 3222 }
2911 mmu_pte_write_flush_tlb(vcpu, zap_page, remote_flush, local_flush); 3223 mmu_pte_write_flush_tlb(vcpu, zap_page, remote_flush, local_flush);
2912 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list); 3224 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2913 kvm_mmu_audit(vcpu, "post pte write"); 3225 trace_kvm_mmu_audit(vcpu, AUDIT_POST_PTE_WRITE);
2914 spin_unlock(&vcpu->kvm->mmu_lock); 3226 spin_unlock(&vcpu->kvm->mmu_lock);
2915 if (!is_error_pfn(vcpu->arch.update_pte.pfn)) { 3227 if (!is_error_pfn(vcpu->arch.update_pte.pfn)) {
2916 kvm_release_pfn_clean(vcpu->arch.update_pte.pfn); 3228 kvm_release_pfn_clean(vcpu->arch.update_pte.pfn);
@@ -2923,7 +3235,7 @@ int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
2923 gpa_t gpa; 3235 gpa_t gpa;
2924 int r; 3236 int r;
2925 3237
2926 if (tdp_enabled) 3238 if (vcpu->arch.mmu.direct_map)
2927 return 0; 3239 return 0;
2928 3240
2929 gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL); 3241 gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL);
@@ -2937,21 +3249,18 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page_virt);
2937 3249
2938void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu) 3250void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
2939{ 3251{
2940 int free_pages;
2941 LIST_HEAD(invalid_list); 3252 LIST_HEAD(invalid_list);
2942 3253
2943 free_pages = vcpu->kvm->arch.n_free_mmu_pages; 3254 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)) { 3255 !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
2946 struct kvm_mmu_page *sp; 3256 struct kvm_mmu_page *sp;
2947 3257
2948 sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev, 3258 sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,
2949 struct kvm_mmu_page, link); 3259 struct kvm_mmu_page, link);
2950 free_pages += kvm_mmu_prepare_zap_page(vcpu->kvm, sp, 3260 kvm_mmu_prepare_zap_page(vcpu->kvm, sp, &invalid_list);
2951 &invalid_list); 3261 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2952 ++vcpu->kvm->stat.mmu_recycled; 3262 ++vcpu->kvm->stat.mmu_recycled;
2953 } 3263 }
2954 kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
2955} 3264}
2956 3265
2957int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code) 3266int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u32 error_code)
@@ -3013,6 +3322,8 @@ EXPORT_SYMBOL_GPL(kvm_disable_tdp);
3013static void free_mmu_pages(struct kvm_vcpu *vcpu) 3322static void free_mmu_pages(struct kvm_vcpu *vcpu)
3014{ 3323{
3015 free_page((unsigned long)vcpu->arch.mmu.pae_root); 3324 free_page((unsigned long)vcpu->arch.mmu.pae_root);
3325 if (vcpu->arch.mmu.lm_root != NULL)
3326 free_page((unsigned long)vcpu->arch.mmu.lm_root);
3016} 3327}
3017 3328
3018static int alloc_mmu_pages(struct kvm_vcpu *vcpu) 3329static int alloc_mmu_pages(struct kvm_vcpu *vcpu)
@@ -3054,15 +3365,6 @@ int kvm_mmu_setup(struct kvm_vcpu *vcpu)
3054 return init_kvm_mmu(vcpu); 3365 return init_kvm_mmu(vcpu);
3055} 3366}
3056 3367
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) 3368void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
3067{ 3369{
3068 struct kvm_mmu_page *sp; 3370 struct kvm_mmu_page *sp;
@@ -3112,23 +3414,22 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
3112{ 3414{
3113 struct kvm *kvm; 3415 struct kvm *kvm;
3114 struct kvm *kvm_freed = NULL; 3416 struct kvm *kvm_freed = NULL;
3115 int cache_count = 0; 3417
3418 if (nr_to_scan == 0)
3419 goto out;
3116 3420
3117 spin_lock(&kvm_lock); 3421 spin_lock(&kvm_lock);
3118 3422
3119 list_for_each_entry(kvm, &vm_list, vm_list) { 3423 list_for_each_entry(kvm, &vm_list, vm_list) {
3120 int npages, idx, freed_pages; 3424 int idx, freed_pages;
3121 LIST_HEAD(invalid_list); 3425 LIST_HEAD(invalid_list);
3122 3426
3123 idx = srcu_read_lock(&kvm->srcu); 3427 idx = srcu_read_lock(&kvm->srcu);
3124 spin_lock(&kvm->mmu_lock); 3428 spin_lock(&kvm->mmu_lock);
3125 npages = kvm->arch.n_alloc_mmu_pages - 3429 if (!kvm_freed && nr_to_scan > 0 &&
3126 kvm->arch.n_free_mmu_pages; 3430 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, 3431 freed_pages = kvm_mmu_remove_some_alloc_mmu_pages(kvm,
3130 &invalid_list); 3432 &invalid_list);
3131 cache_count -= freed_pages;
3132 kvm_freed = kvm; 3433 kvm_freed = kvm;
3133 } 3434 }
3134 nr_to_scan--; 3435 nr_to_scan--;
@@ -3142,7 +3443,8 @@ static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
3142 3443
3143 spin_unlock(&kvm_lock); 3444 spin_unlock(&kvm_lock);
3144 3445
3145 return cache_count; 3446out:
3447 return percpu_counter_read_positive(&kvm_total_used_mmu_pages);
3146} 3448}
3147 3449
3148static struct shrinker mmu_shrinker = { 3450static struct shrinker mmu_shrinker = {
@@ -3163,6 +3465,7 @@ static void mmu_destroy_caches(void)
3163void kvm_mmu_module_exit(void) 3465void kvm_mmu_module_exit(void)
3164{ 3466{
3165 mmu_destroy_caches(); 3467 mmu_destroy_caches();
3468 percpu_counter_destroy(&kvm_total_used_mmu_pages);
3166 unregister_shrinker(&mmu_shrinker); 3469 unregister_shrinker(&mmu_shrinker);
3167} 3470}
3168 3471
@@ -3185,6 +3488,9 @@ int kvm_mmu_module_init(void)
3185 if (!mmu_page_header_cache) 3488 if (!mmu_page_header_cache)
3186 goto nomem; 3489 goto nomem;
3187 3490
3491 if (percpu_counter_init(&kvm_total_used_mmu_pages, 0))
3492 goto nomem;
3493
3188 register_shrinker(&mmu_shrinker); 3494 register_shrinker(&mmu_shrinker);
3189 3495
3190 return 0; 3496 return 0;
@@ -3355,271 +3661,18 @@ int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4])
3355} 3661}
3356EXPORT_SYMBOL_GPL(kvm_mmu_get_spte_hierarchy); 3662EXPORT_SYMBOL_GPL(kvm_mmu_get_spte_hierarchy);
3357 3663
3358#ifdef AUDIT 3664#ifdef CONFIG_KVM_MMU_AUDIT
3359 3665#include "mmu_audit.c"
3360static const char *audit_msg; 3666#else
3361 3667static 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 3668#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
3439 if (is_error_pfn(pfn)) {
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 3669
3611static void kvm_mmu_audit(struct kvm_vcpu *vcpu, const char *msg) 3670void kvm_mmu_destroy(struct kvm_vcpu *vcpu)
3612{ 3671{
3613 int olddbg = dbg; 3672 ASSERT(vcpu);
3614 3673
3615 dbg = 0; 3674 destroy_kvm_mmu(vcpu);
3616 audit_msg = msg; 3675 free_mmu_pages(vcpu);
3617 audit_rmap(vcpu); 3676 mmu_free_memory_caches(vcpu);
3618 audit_write_protection(vcpu); 3677 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} 3678}
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 8a3f9f64f86f..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;
@@ -793,7 +835,7 @@ static void init_vmcb(struct vcpu_svm *svm)
793 init_sys_seg(&save->ldtr, SEG_TYPE_LDT); 835 init_sys_seg(&save->ldtr, SEG_TYPE_LDT);
794 init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); 836 init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16);
795 837
796 save->efer = EFER_SVME; 838 svm_set_efer(&svm->vcpu, 0);
797 save->dr6 = 0xffff0ff0; 839 save->dr6 = 0xffff0ff0;
798 save->dr7 = 0x400; 840 save->dr7 = 0x400;
799 save->rflags = 2; 841 save->rflags = 2;
@@ -804,8 +846,8 @@ static void init_vmcb(struct vcpu_svm *svm)
804 * This is the guest-visible cr0 value. 846 * This is the guest-visible cr0 value.
805 * 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.
806 */ 848 */
807 svm->vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; 849 svm->vcpu.arch.cr0 = 0;
808 (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);
809 851
810 save->cr4 = X86_CR4_PAE; 852 save->cr4 = X86_CR4_PAE;
811 /* rdx = ?? */ 853 /* rdx = ?? */
@@ -901,7 +943,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
901 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; 943 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT;
902 svm->asid_generation = 0; 944 svm->asid_generation = 0;
903 init_vmcb(svm); 945 init_vmcb(svm);
904 svm->vmcb->control.tsc_offset = 0-native_read_tsc(); 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
@@ -3167,9 +3313,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3167 savesegment(gs, gs_selector); 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
@@ -3291,16 +3434,22 @@ static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root)
3291{ 3434{
3292 struct vcpu_svm *svm = to_svm(vcpu); 3435 struct vcpu_svm *svm = to_svm(vcpu);
3293 3436
3294 if (npt_enabled) {
3295 svm->vmcb->control.nested_cr3 = root;
3296 force_new_asid(vcpu);
3297 return;
3298 }
3299
3300 svm->vmcb->save.cr3 = root; 3437 svm->vmcb->save.cr3 = root;
3301 force_new_asid(vcpu); 3438 force_new_asid(vcpu);
3302} 3439}
3303 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
3304static int is_disabled(void) 3453static int is_disabled(void)
3305{ 3454{
3306 u64 vm_cr; 3455 u64 vm_cr;
@@ -3333,15 +3482,6 @@ static bool svm_cpu_has_accelerated_tpr(void)
3333 return false; 3482 return false;
3334} 3483}
3335 3484
3336static int get_npt_level(void)
3337{
3338#ifdef CONFIG_X86_64
3339 return PT64_ROOT_LEVEL;
3340#else
3341 return PT32E_ROOT_LEVEL;
3342#endif
3343}
3344
3345static 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)
3346{ 3486{
3347 return 0; 3487 return 0;
@@ -3354,12 +3494,25 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
3354static 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)
3355{ 3495{
3356 switch (func) { 3496 switch (func) {
3497 case 0x80000001:
3498 if (nested)
3499 entry->ecx |= (1 << 2); /* Set SVM bit */
3500 break;
3357 case 0x8000000A: 3501 case 0x8000000A:
3358 entry->eax = 1; /* SVM revision 1 */ 3502 entry->eax = 1; /* SVM revision 1 */
3359 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
3360 ASID emulation to nested SVM */ 3504 ASID emulation to nested SVM */
3361 entry->ecx = 0; /* Reserved */ 3505 entry->ecx = 0; /* Reserved */
3362 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;
3363 3516
3364 break; 3517 break;
3365 } 3518 }
@@ -3497,6 +3650,7 @@ static struct kvm_x86_ops svm_x86_ops = {
3497 .set_irq = svm_set_irq, 3650 .set_irq = svm_set_irq,
3498 .set_nmi = svm_inject_nmi, 3651 .set_nmi = svm_inject_nmi,
3499 .queue_exception = svm_queue_exception, 3652 .queue_exception = svm_queue_exception,
3653 .cancel_injection = svm_cancel_injection,
3500 .interrupt_allowed = svm_interrupt_allowed, 3654 .interrupt_allowed = svm_interrupt_allowed,
3501 .nmi_allowed = svm_nmi_allowed, 3655 .nmi_allowed = svm_nmi_allowed,
3502 .get_nmi_mask = svm_get_nmi_mask, 3656 .get_nmi_mask = svm_get_nmi_mask,
@@ -3519,6 +3673,11 @@ static struct kvm_x86_ops svm_x86_ops = {
3519 .set_supported_cpuid = svm_set_supported_cpuid, 3673 .set_supported_cpuid = svm_set_supported_cpuid,
3520 3674
3521 .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,
3522}; 3681};
3523 3682
3524static 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 7bddfab12013..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();
@@ -883,7 +876,6 @@ static void vmx_load_host_state(struct vcpu_vmx *vmx)
883static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 876static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
884{ 877{
885 struct vcpu_vmx *vmx = to_vmx(vcpu); 878 struct vcpu_vmx *vmx = to_vmx(vcpu);
886 u64 tsc_this, delta, new_offset;
887 u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); 879 u64 phys_addr = __pa(per_cpu(vmxarea, cpu));
888 880
889 if (!vmm_exclusive) 881 if (!vmm_exclusive)
@@ -897,37 +889,24 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
897 } 889 }
898 890
899 if (vcpu->cpu != cpu) { 891 if (vcpu->cpu != cpu) {
900 struct desc_ptr dt; 892 struct desc_ptr *gdt = &__get_cpu_var(host_gdt);
901 unsigned long sysenter_esp; 893 unsigned long sysenter_esp;
902 894
903 kvm_migrate_timers(vcpu);
904 kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 895 kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu);
905 local_irq_disable(); 896 local_irq_disable();
906 list_add(&vmx->local_vcpus_link, 897 list_add(&vmx->local_vcpus_link,
907 &per_cpu(vcpus_on_cpu, cpu)); 898 &per_cpu(vcpus_on_cpu, cpu));
908 local_irq_enable(); 899 local_irq_enable();
909 900
910 vcpu->cpu = cpu;
911 /* 901 /*
912 * 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
913 * processors. 903 * processors.
914 */ 904 */
915 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 */
916 native_store_gdt(&dt); 906 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
917 vmcs_writel(HOST_GDTR_BASE, dt.address); /* 22.2.4 */
918 907
919 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); 908 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
920 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ 909 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
921
922 /*
923 * Make sure the time stamp counter is monotonous.
924 */
925 rdtscll(tsc_this);
926 if (tsc_this < vcpu->arch.host_tsc) {
927 delta = vcpu->arch.host_tsc - tsc_this;
928 new_offset = vmcs_read64(TSC_OFFSET) + delta;
929 vmcs_write64(TSC_OFFSET, new_offset);
930 }
931 } 910 }
932} 911}
933 912
@@ -1044,16 +1023,8 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
1044 } 1023 }
1045 1024
1046 if (vmx->rmode.vm86_active) { 1025 if (vmx->rmode.vm86_active) {
1047 vmx->rmode.irq.pending = true; 1026 if (kvm_inject_realmode_interrupt(vcpu, nr) != EMULATE_DONE)
1048 vmx->rmode.irq.vector = nr; 1027 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
1049 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
1050 if (kvm_exception_is_soft(nr))
1051 vmx->rmode.irq.rip +=
1052 vmx->vcpu.arch.event_exit_inst_len;
1053 intr_info |= INTR_TYPE_SOFT_INTR;
1054 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info);
1055 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
1056 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
1057 return; 1028 return;
1058 } 1029 }
1059 1030
@@ -1149,12 +1120,17 @@ static u64 guest_read_tsc(void)
1149} 1120}
1150 1121
1151/* 1122/*
1152 * writes 'guest_tsc' into guest's timestamp counter "register" 1123 * writes 'offset' into guest's timestamp counter offset register
1153 * guest_tsc = host_tsc + tsc_offset ==> tsc_offset = guest_tsc - host_tsc
1154 */ 1124 */
1155static void guest_write_tsc(u64 guest_tsc, u64 host_tsc) 1125static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
1126{
1127 vmcs_write64(TSC_OFFSET, offset);
1128}
1129
1130static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment)
1156{ 1131{
1157 vmcs_write64(TSC_OFFSET, guest_tsc - host_tsc); 1132 u64 offset = vmcs_read64(TSC_OFFSET);
1133 vmcs_write64(TSC_OFFSET, offset + adjustment);
1158} 1134}
1159 1135
1160/* 1136/*
@@ -1227,7 +1203,6 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
1227{ 1203{
1228 struct vcpu_vmx *vmx = to_vmx(vcpu); 1204 struct vcpu_vmx *vmx = to_vmx(vcpu);
1229 struct shared_msr_entry *msr; 1205 struct shared_msr_entry *msr;
1230 u64 host_tsc;
1231 int ret = 0; 1206 int ret = 0;
1232 1207
1233 switch (msr_index) { 1208 switch (msr_index) {
@@ -1257,8 +1232,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
1257 vmcs_writel(GUEST_SYSENTER_ESP, data); 1232 vmcs_writel(GUEST_SYSENTER_ESP, data);
1258 break; 1233 break;
1259 case MSR_IA32_TSC: 1234 case MSR_IA32_TSC:
1260 rdtscll(host_tsc); 1235 kvm_write_tsc(vcpu, data);
1261 guest_write_tsc(data, host_tsc);
1262 break; 1236 break;
1263 case MSR_IA32_CR_PAT: 1237 case MSR_IA32_CR_PAT:
1264 if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) { 1238 if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
@@ -1856,20 +1830,20 @@ static void ept_load_pdptrs(struct kvm_vcpu *vcpu)
1856 return; 1830 return;
1857 1831
1858 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) { 1832 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) {
1859 vmcs_write64(GUEST_PDPTR0, vcpu->arch.pdptrs[0]); 1833 vmcs_write64(GUEST_PDPTR0, vcpu->arch.mmu.pdptrs[0]);
1860 vmcs_write64(GUEST_PDPTR1, vcpu->arch.pdptrs[1]); 1834 vmcs_write64(GUEST_PDPTR1, vcpu->arch.mmu.pdptrs[1]);
1861 vmcs_write64(GUEST_PDPTR2, vcpu->arch.pdptrs[2]); 1835 vmcs_write64(GUEST_PDPTR2, vcpu->arch.mmu.pdptrs[2]);
1862 vmcs_write64(GUEST_PDPTR3, vcpu->arch.pdptrs[3]); 1836 vmcs_write64(GUEST_PDPTR3, vcpu->arch.mmu.pdptrs[3]);
1863 } 1837 }
1864} 1838}
1865 1839
1866static void ept_save_pdptrs(struct kvm_vcpu *vcpu) 1840static void ept_save_pdptrs(struct kvm_vcpu *vcpu)
1867{ 1841{
1868 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) { 1842 if (is_paging(vcpu) && is_pae(vcpu) && !is_long_mode(vcpu)) {
1869 vcpu->arch.pdptrs[0] = vmcs_read64(GUEST_PDPTR0); 1843 vcpu->arch.mmu.pdptrs[0] = vmcs_read64(GUEST_PDPTR0);
1870 vcpu->arch.pdptrs[1] = vmcs_read64(GUEST_PDPTR1); 1844 vcpu->arch.mmu.pdptrs[1] = vmcs_read64(GUEST_PDPTR1);
1871 vcpu->arch.pdptrs[2] = vmcs_read64(GUEST_PDPTR2); 1845 vcpu->arch.mmu.pdptrs[2] = vmcs_read64(GUEST_PDPTR2);
1872 vcpu->arch.pdptrs[3] = vmcs_read64(GUEST_PDPTR3); 1846 vcpu->arch.mmu.pdptrs[3] = vmcs_read64(GUEST_PDPTR3);
1873 } 1847 }
1874 1848
1875 __set_bit(VCPU_EXREG_PDPTR, 1849 __set_bit(VCPU_EXREG_PDPTR,
@@ -2515,7 +2489,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2515{ 2489{
2516 u32 host_sysenter_cs, msr_low, msr_high; 2490 u32 host_sysenter_cs, msr_low, msr_high;
2517 u32 junk; 2491 u32 junk;
2518 u64 host_pat, tsc_this, tsc_base; 2492 u64 host_pat;
2519 unsigned long a; 2493 unsigned long a;
2520 struct desc_ptr dt; 2494 struct desc_ptr dt;
2521 int i; 2495 int i;
@@ -2656,12 +2630,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
2656 vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE; 2630 vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE;
2657 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);
2658 2632
2659 tsc_base = vmx->vcpu.kvm->arch.vm_init_tsc; 2633 kvm_write_tsc(&vmx->vcpu, 0);
2660 rdtscll(tsc_this);
2661 if (tsc_this < vmx->vcpu.kvm->arch.vm_init_tsc)
2662 tsc_base = tsc_this;
2663
2664 guest_write_tsc(0, tsc_base);
2665 2634
2666 return 0; 2635 return 0;
2667} 2636}
@@ -2834,16 +2803,8 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu)
2834 2803
2835 ++vcpu->stat.irq_injections; 2804 ++vcpu->stat.irq_injections;
2836 if (vmx->rmode.vm86_active) { 2805 if (vmx->rmode.vm86_active) {
2837 vmx->rmode.irq.pending = true; 2806 if (kvm_inject_realmode_interrupt(vcpu, irq) != EMULATE_DONE)
2838 vmx->rmode.irq.vector = irq; 2807 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
2839 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
2840 if (vcpu->arch.interrupt.soft)
2841 vmx->rmode.irq.rip +=
2842 vmx->vcpu.arch.event_exit_inst_len;
2843 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2844 irq | INTR_TYPE_SOFT_INTR | INTR_INFO_VALID_MASK);
2845 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
2846 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
2847 return; 2808 return;
2848 } 2809 }
2849 intr = irq | INTR_INFO_VALID_MASK; 2810 intr = irq | INTR_INFO_VALID_MASK;
@@ -2875,14 +2836,8 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
2875 2836
2876 ++vcpu->stat.nmi_injections; 2837 ++vcpu->stat.nmi_injections;
2877 if (vmx->rmode.vm86_active) { 2838 if (vmx->rmode.vm86_active) {
2878 vmx->rmode.irq.pending = true; 2839 if (kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR) != EMULATE_DONE)
2879 vmx->rmode.irq.vector = NMI_VECTOR; 2840 kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu);
2880 vmx->rmode.irq.rip = kvm_rip_read(vcpu);
2881 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
2882 NMI_VECTOR | INTR_TYPE_SOFT_INTR |
2883 INTR_INFO_VALID_MASK);
2884 vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, 1);
2885 kvm_rip_write(vcpu, vmx->rmode.irq.rip - 1);
2886 return; 2841 return;
2887 } 2842 }
2888 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 2843 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
@@ -3346,6 +3301,7 @@ static int handle_wrmsr(struct kvm_vcpu *vcpu)
3346 3301
3347static int handle_tpr_below_threshold(struct kvm_vcpu *vcpu) 3302static int handle_tpr_below_threshold(struct kvm_vcpu *vcpu)
3348{ 3303{
3304 kvm_make_request(KVM_REQ_EVENT, vcpu);
3349 return 1; 3305 return 1;
3350} 3306}
3351 3307
@@ -3358,6 +3314,8 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu)
3358 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING; 3314 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING;
3359 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);
3360 3316
3317 kvm_make_request(KVM_REQ_EVENT, vcpu);
3318
3361 ++vcpu->stat.irq_window_exits; 3319 ++vcpu->stat.irq_window_exits;
3362 3320
3363 /* 3321 /*
@@ -3614,6 +3572,7 @@ static int handle_nmi_window(struct kvm_vcpu *vcpu)
3614 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING; 3572 cpu_based_vm_exec_control &= ~CPU_BASED_VIRTUAL_NMI_PENDING;
3615 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);
3616 ++vcpu->stat.nmi_window_exits; 3574 ++vcpu->stat.nmi_window_exits;
3575 kvm_make_request(KVM_REQ_EVENT, vcpu);
3617 3576
3618 return 1; 3577 return 1;
3619} 3578}
@@ -3623,8 +3582,17 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
3623 struct vcpu_vmx *vmx = to_vmx(vcpu); 3582 struct vcpu_vmx *vmx = to_vmx(vcpu);
3624 enum emulation_result err = EMULATE_DONE; 3583 enum emulation_result err = EMULATE_DONE;
3625 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;
3626 3590
3627 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
3628 err = emulate_instruction(vcpu, 0, 0, 0); 3596 err = emulate_instruction(vcpu, 0, 0, 0);
3629 3597
3630 if (err == EMULATE_DO_MMIO) { 3598 if (err == EMULATE_DO_MMIO) {
@@ -3790,18 +3758,9 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr)
3790 vmcs_write32(TPR_THRESHOLD, irr); 3758 vmcs_write32(TPR_THRESHOLD, irr);
3791} 3759}
3792 3760
3793static void vmx_complete_interrupts(struct vcpu_vmx *vmx) 3761static void vmx_complete_atomic_exit(struct vcpu_vmx *vmx)
3794{ 3762{
3795 u32 exit_intr_info; 3763 u32 exit_intr_info = vmx->exit_intr_info;
3796 u32 idt_vectoring_info = vmx->idt_vectoring_info;
3797 bool unblock_nmi;
3798 u8 vector;
3799 int type;
3800 bool idtv_info_valid;
3801
3802 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
3803
3804 vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
3805 3764
3806 /* Handle machine checks before interrupts are enabled */ 3765 /* Handle machine checks before interrupts are enabled */
3807 if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY) 3766 if ((vmx->exit_reason == EXIT_REASON_MCE_DURING_VMENTRY)
@@ -3816,8 +3775,16 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3816 asm("int $2"); 3775 asm("int $2");
3817 kvm_after_handle_nmi(&vmx->vcpu); 3776 kvm_after_handle_nmi(&vmx->vcpu);
3818 } 3777 }
3778}
3819 3779
3820 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;
3821 3788
3822 if (cpu_has_virtual_nmis()) { 3789 if (cpu_has_virtual_nmis()) {
3823 unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0; 3790 unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
@@ -3839,6 +3806,18 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3839 } else if (unlikely(vmx->soft_vnmi_blocked)) 3806 } else if (unlikely(vmx->soft_vnmi_blocked))
3840 vmx->vnmi_blocked_time += 3807 vmx->vnmi_blocked_time +=
3841 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;
3842 3821
3843 vmx->vcpu.arch.nmi_injected = false; 3822 vmx->vcpu.arch.nmi_injected = false;
3844 kvm_clear_exception_queue(&vmx->vcpu); 3823 kvm_clear_exception_queue(&vmx->vcpu);
@@ -3847,6 +3826,8 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3847 if (!idtv_info_valid) 3826 if (!idtv_info_valid)
3848 return; 3827 return;
3849 3828
3829 kvm_make_request(KVM_REQ_EVENT, &vmx->vcpu);
3830
3850 vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK; 3831 vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK;
3851 type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK; 3832 type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK;
3852 3833
@@ -3863,18 +3844,18 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3863 break; 3844 break;
3864 case INTR_TYPE_SOFT_EXCEPTION: 3845 case INTR_TYPE_SOFT_EXCEPTION:
3865 vmx->vcpu.arch.event_exit_inst_len = 3846 vmx->vcpu.arch.event_exit_inst_len =
3866 vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 3847 vmcs_read32(instr_len_field);
3867 /* fall through */ 3848 /* fall through */
3868 case INTR_TYPE_HARD_EXCEPTION: 3849 case INTR_TYPE_HARD_EXCEPTION:
3869 if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) { 3850 if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) {
3870 u32 err = vmcs_read32(IDT_VECTORING_ERROR_CODE); 3851 u32 err = vmcs_read32(error_code_field);
3871 kvm_queue_exception_e(&vmx->vcpu, vector, err); 3852 kvm_queue_exception_e(&vmx->vcpu, vector, err);
3872 } else 3853 } else
3873 kvm_queue_exception(&vmx->vcpu, vector); 3854 kvm_queue_exception(&vmx->vcpu, vector);
3874 break; 3855 break;
3875 case INTR_TYPE_SOFT_INTR: 3856 case INTR_TYPE_SOFT_INTR:
3876 vmx->vcpu.arch.event_exit_inst_len = 3857 vmx->vcpu.arch.event_exit_inst_len =
3877 vmcs_read32(VM_EXIT_INSTRUCTION_LEN); 3858 vmcs_read32(instr_len_field);
3878 /* fall through */ 3859 /* fall through */
3879 case INTR_TYPE_EXT_INTR: 3860 case INTR_TYPE_EXT_INTR:
3880 kvm_queue_interrupt(&vmx->vcpu, vector, 3861 kvm_queue_interrupt(&vmx->vcpu, vector,
@@ -3885,27 +3866,21 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3885 } 3866 }
3886} 3867}
3887 3868
3888/* 3869static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
3889 * Failure to inject an interrupt should give us the information
3890 * in IDT_VECTORING_INFO_FIELD. However, if the failure occurs
3891 * when fetching the interrupt redirection bitmap in the real-mode
3892 * tss, this doesn't happen. So we do it ourselves.
3893 */
3894static void fixup_rmode_irq(struct vcpu_vmx *vmx)
3895{ 3870{
3896 vmx->rmode.irq.pending = 0; 3871 __vmx_complete_interrupts(vmx, vmx->idt_vectoring_info,
3897 if (kvm_rip_read(&vmx->vcpu) + 1 != vmx->rmode.irq.rip) 3872 VM_EXIT_INSTRUCTION_LEN,
3898 return; 3873 IDT_VECTORING_ERROR_CODE);
3899 kvm_rip_write(&vmx->vcpu, vmx->rmode.irq.rip); 3874}
3900 if (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK) { 3875
3901 vmx->idt_vectoring_info &= ~VECTORING_INFO_TYPE_MASK; 3876static void vmx_cancel_injection(struct kvm_vcpu *vcpu)
3902 vmx->idt_vectoring_info |= INTR_TYPE_EXT_INTR; 3877{
3903 return; 3878 __vmx_complete_interrupts(to_vmx(vcpu),
3904 } 3879 vmcs_read32(VM_ENTRY_INTR_INFO_FIELD),
3905 vmx->idt_vectoring_info = 3880 VM_ENTRY_INSTRUCTION_LEN,
3906 VECTORING_INFO_VALID_MASK 3881 VM_ENTRY_EXCEPTION_ERROR_CODE);
3907 | INTR_TYPE_EXT_INTR 3882
3908 | vmx->rmode.irq.vector; 3883 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0);
3909} 3884}
3910 3885
3911#ifdef CONFIG_X86_64 3886#ifdef CONFIG_X86_64
@@ -4032,7 +4007,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
4032#endif 4007#endif
4033 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)) 4008 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2))
4034 : "cc", "memory" 4009 : "cc", "memory"
4035 , R"bx", R"di", R"si" 4010 , R"ax", R"bx", R"di", R"si"
4036#ifdef CONFIG_X86_64 4011#ifdef CONFIG_X86_64
4037 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" 4012 , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
4038#endif 4013#endif
@@ -4043,12 +4018,15 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu)
4043 vcpu->arch.regs_dirty = 0; 4018 vcpu->arch.regs_dirty = 0;
4044 4019
4045 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); 4020 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
4046 if (vmx->rmode.irq.pending)
4047 fixup_rmode_irq(vmx);
4048 4021
4049 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); 4022 asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
4050 vmx->launched = 1; 4023 vmx->launched = 1;
4051 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);
4052 vmx_complete_interrupts(vmx); 4030 vmx_complete_interrupts(vmx);
4053} 4031}
4054 4032
@@ -4119,6 +4097,7 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
4119 4097
4120 cpu = get_cpu(); 4098 cpu = get_cpu();
4121 vmx_vcpu_load(&vmx->vcpu, cpu); 4099 vmx_vcpu_load(&vmx->vcpu, cpu);
4100 vmx->vcpu.cpu = cpu;
4122 err = vmx_vcpu_setup(vmx); 4101 err = vmx_vcpu_setup(vmx);
4123 vmx_vcpu_put(&vmx->vcpu); 4102 vmx_vcpu_put(&vmx->vcpu);
4124 put_cpu(); 4103 put_cpu();
@@ -4334,6 +4313,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
4334 .set_irq = vmx_inject_irq, 4313 .set_irq = vmx_inject_irq,
4335 .set_nmi = vmx_inject_nmi, 4314 .set_nmi = vmx_inject_nmi,
4336 .queue_exception = vmx_queue_exception, 4315 .queue_exception = vmx_queue_exception,
4316 .cancel_injection = vmx_cancel_injection,
4337 .interrupt_allowed = vmx_interrupt_allowed, 4317 .interrupt_allowed = vmx_interrupt_allowed,
4338 .nmi_allowed = vmx_nmi_allowed, 4318 .nmi_allowed = vmx_nmi_allowed,
4339 .get_nmi_mask = vmx_get_nmi_mask, 4319 .get_nmi_mask = vmx_get_nmi_mask,
@@ -4356,6 +4336,11 @@ static struct kvm_x86_ops vmx_x86_ops = {
4356 .set_supported_cpuid = vmx_set_supported_cpuid, 4336 .set_supported_cpuid = vmx_set_supported_cpuid,
4357 4337
4358 .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,
4359}; 4344};
4360 4345
4361static 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 6c2ecf0a806d..cdac9e592aa5 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);
949
950 pr_debug("%s: base_khz %u => %u, shift %d, mul %u\n",
951 __func__, base_khz, scaled_khz, shift, *pmultiplier);
952}
953
954static inline u64 get_kernel_ns(void)
955{
956 struct timespec ts;
890 957
891 pr_debug("%s: tsc_khz %u, tsc_shift %d, tsc_mul %u\n", 958 WARN_ON(preemptible());
892 __func__, tsc_khz, hv_clock->tsc_shift, 959 ktime_get_ts(&ts);
893 hv_clock->tsc_to_system_mul); 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;
1099
1100 /*
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 }
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 }
924 1137
925 vcpu->hv_clock.system_time = ts.tv_nsec + 1138 if (max_kernel_ns > kernel_ns)
926 (NSEC_PER_SEC * (u64)ts.tv_sec) + v->kvm->arch.kvmclock_offset; 1139 kernel_ns = max_kernel_ns;
927 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)
@@ -1995,7 +2248,7 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
1995 F(F16C); 2248 F(F16C);
1996 /* cpuid 0x80000001.ecx */ 2249 /* cpuid 0x80000001.ecx */
1997 const u32 kvm_supported_word6_x86_features = 2250 const u32 kvm_supported_word6_x86_features =
1998 F(LAHF_LM) | F(CMP_LEGACY) | F(SVM) | 0 /* ExtApicSpace */ | 2251 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
1999 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | 2252 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
2000 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(XOP) | 2253 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(XOP) |
2001 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM); 2254 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
@@ -2204,6 +2457,7 @@ static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
2204 return -ENXIO; 2457 return -ENXIO;
2205 2458
2206 kvm_queue_interrupt(vcpu, irq->irq, false); 2459 kvm_queue_interrupt(vcpu, irq->irq, false);
2460 kvm_make_request(KVM_REQ_EVENT, vcpu);
2207 2461
2208 return 0; 2462 return 0;
2209} 2463}
@@ -2306,6 +2560,7 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
2306 !kvm_exception_is_soft(vcpu->arch.exception.nr); 2560 !kvm_exception_is_soft(vcpu->arch.exception.nr);
2307 events->exception.nr = vcpu->arch.exception.nr; 2561 events->exception.nr = vcpu->arch.exception.nr;
2308 events->exception.has_error_code = vcpu->arch.exception.has_error_code; 2562 events->exception.has_error_code = vcpu->arch.exception.has_error_code;
2563 events->exception.pad = 0;
2309 events->exception.error_code = vcpu->arch.exception.error_code; 2564 events->exception.error_code = vcpu->arch.exception.error_code;
2310 2565
2311 events->interrupt.injected = 2566 events->interrupt.injected =
@@ -2319,12 +2574,14 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
2319 events->nmi.injected = vcpu->arch.nmi_injected; 2574 events->nmi.injected = vcpu->arch.nmi_injected;
2320 events->nmi.pending = vcpu->arch.nmi_pending; 2575 events->nmi.pending = vcpu->arch.nmi_pending;
2321 events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu); 2576 events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu);
2577 events->nmi.pad = 0;
2322 2578
2323 events->sipi_vector = vcpu->arch.sipi_vector; 2579 events->sipi_vector = vcpu->arch.sipi_vector;
2324 2580
2325 events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING 2581 events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING
2326 | KVM_VCPUEVENT_VALID_SIPI_VECTOR 2582 | KVM_VCPUEVENT_VALID_SIPI_VECTOR
2327 | KVM_VCPUEVENT_VALID_SHADOW); 2583 | KVM_VCPUEVENT_VALID_SHADOW);
2584 memset(&events->reserved, 0, sizeof(events->reserved));
2328} 2585}
2329 2586
2330static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, 2587static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
@@ -2357,6 +2614,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
2357 if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR) 2614 if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
2358 vcpu->arch.sipi_vector = events->sipi_vector; 2615 vcpu->arch.sipi_vector = events->sipi_vector;
2359 2616
2617 kvm_make_request(KVM_REQ_EVENT, vcpu);
2618
2360 return 0; 2619 return 0;
2361} 2620}
2362 2621
@@ -2367,6 +2626,7 @@ static void kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu,
2367 dbgregs->dr6 = vcpu->arch.dr6; 2626 dbgregs->dr6 = vcpu->arch.dr6;
2368 dbgregs->dr7 = vcpu->arch.dr7; 2627 dbgregs->dr7 = vcpu->arch.dr7;
2369 dbgregs->flags = 0; 2628 dbgregs->flags = 0;
2629 memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved));
2370} 2630}
2371 2631
2372static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu, 2632static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
@@ -2760,7 +3020,7 @@ static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm,
2760 3020
2761static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) 3021static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm)
2762{ 3022{
2763 return kvm->arch.n_alloc_mmu_pages; 3023 return kvm->arch.n_max_mmu_pages;
2764} 3024}
2765 3025
2766static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) 3026static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
@@ -2796,18 +3056,18 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
2796 r = 0; 3056 r = 0;
2797 switch (chip->chip_id) { 3057 switch (chip->chip_id) {
2798 case KVM_IRQCHIP_PIC_MASTER: 3058 case KVM_IRQCHIP_PIC_MASTER:
2799 raw_spin_lock(&pic_irqchip(kvm)->lock); 3059 spin_lock(&pic_irqchip(kvm)->lock);
2800 memcpy(&pic_irqchip(kvm)->pics[0], 3060 memcpy(&pic_irqchip(kvm)->pics[0],
2801 &chip->chip.pic, 3061 &chip->chip.pic,
2802 sizeof(struct kvm_pic_state)); 3062 sizeof(struct kvm_pic_state));
2803 raw_spin_unlock(&pic_irqchip(kvm)->lock); 3063 spin_unlock(&pic_irqchip(kvm)->lock);
2804 break; 3064 break;
2805 case KVM_IRQCHIP_PIC_SLAVE: 3065 case KVM_IRQCHIP_PIC_SLAVE:
2806 raw_spin_lock(&pic_irqchip(kvm)->lock); 3066 spin_lock(&pic_irqchip(kvm)->lock);
2807 memcpy(&pic_irqchip(kvm)->pics[1], 3067 memcpy(&pic_irqchip(kvm)->pics[1],
2808 &chip->chip.pic, 3068 &chip->chip.pic,
2809 sizeof(struct kvm_pic_state)); 3069 sizeof(struct kvm_pic_state));
2810 raw_spin_unlock(&pic_irqchip(kvm)->lock); 3070 spin_unlock(&pic_irqchip(kvm)->lock);
2811 break; 3071 break;
2812 case KVM_IRQCHIP_IOAPIC: 3072 case KVM_IRQCHIP_IOAPIC:
2813 r = kvm_set_ioapic(kvm, &chip->chip.ioapic); 3073 r = kvm_set_ioapic(kvm, &chip->chip.ioapic);
@@ -2850,6 +3110,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
2850 sizeof(ps->channels)); 3110 sizeof(ps->channels));
2851 ps->flags = kvm->arch.vpit->pit_state.flags; 3111 ps->flags = kvm->arch.vpit->pit_state.flags;
2852 mutex_unlock(&kvm->arch.vpit->pit_state.lock); 3112 mutex_unlock(&kvm->arch.vpit->pit_state.lock);
3113 memset(&ps->reserved, 0, sizeof(ps->reserved));
2853 return r; 3114 return r;
2854} 3115}
2855 3116
@@ -2913,10 +3174,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
2913 struct kvm_memslots *slots, *old_slots; 3174 struct kvm_memslots *slots, *old_slots;
2914 unsigned long *dirty_bitmap; 3175 unsigned long *dirty_bitmap;
2915 3176
2916 spin_lock(&kvm->mmu_lock);
2917 kvm_mmu_slot_remove_write_access(kvm, log->slot);
2918 spin_unlock(&kvm->mmu_lock);
2919
2920 r = -ENOMEM; 3177 r = -ENOMEM;
2921 dirty_bitmap = vmalloc(n); 3178 dirty_bitmap = vmalloc(n);
2922 if (!dirty_bitmap) 3179 if (!dirty_bitmap)
@@ -2938,6 +3195,10 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
2938 dirty_bitmap = old_slots->memslots[log->slot].dirty_bitmap; 3195 dirty_bitmap = old_slots->memslots[log->slot].dirty_bitmap;
2939 kfree(old_slots); 3196 kfree(old_slots);
2940 3197
3198 spin_lock(&kvm->mmu_lock);
3199 kvm_mmu_slot_remove_write_access(kvm, log->slot);
3200 spin_unlock(&kvm->mmu_lock);
3201
2941 r = -EFAULT; 3202 r = -EFAULT;
2942 if (copy_to_user(log->dirty_bitmap, dirty_bitmap, n)) { 3203 if (copy_to_user(log->dirty_bitmap, dirty_bitmap, n)) {
2943 vfree(dirty_bitmap); 3204 vfree(dirty_bitmap);
@@ -3201,7 +3462,6 @@ long kvm_arch_vm_ioctl(struct file *filp,
3201 break; 3462 break;
3202 } 3463 }
3203 case KVM_SET_CLOCK: { 3464 case KVM_SET_CLOCK: {
3204 struct timespec now;
3205 struct kvm_clock_data user_ns; 3465 struct kvm_clock_data user_ns;
3206 u64 now_ns; 3466 u64 now_ns;
3207 s64 delta; 3467 s64 delta;
@@ -3215,21 +3475,23 @@ long kvm_arch_vm_ioctl(struct file *filp,
3215 goto out; 3475 goto out;
3216 3476
3217 r = 0; 3477 r = 0;
3218 ktime_get_ts(&now); 3478 local_irq_disable();
3219 now_ns = timespec_to_ns(&now); 3479 now_ns = get_kernel_ns();
3220 delta = user_ns.clock - now_ns; 3480 delta = user_ns.clock - now_ns;
3481 local_irq_enable();
3221 kvm->arch.kvmclock_offset = delta; 3482 kvm->arch.kvmclock_offset = delta;
3222 break; 3483 break;
3223 } 3484 }
3224 case KVM_GET_CLOCK: { 3485 case KVM_GET_CLOCK: {
3225 struct timespec now;
3226 struct kvm_clock_data user_ns; 3486 struct kvm_clock_data user_ns;
3227 u64 now_ns; 3487 u64 now_ns;
3228 3488
3229 ktime_get_ts(&now); 3489 local_irq_disable();
3230 now_ns = timespec_to_ns(&now); 3490 now_ns = get_kernel_ns();
3231 user_ns.clock = kvm->arch.kvmclock_offset + now_ns; 3491 user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
3492 local_irq_enable();
3232 user_ns.flags = 0; 3493 user_ns.flags = 0;
3494 memset(&user_ns.pad, 0, sizeof(user_ns.pad));
3233 3495
3234 r = -EFAULT; 3496 r = -EFAULT;
3235 if (copy_to_user(argp, &user_ns, sizeof(user_ns))) 3497 if (copy_to_user(argp, &user_ns, sizeof(user_ns)))
@@ -3292,30 +3554,51 @@ void kvm_get_segment(struct kvm_vcpu *vcpu,
3292 kvm_x86_ops->get_segment(vcpu, var, seg); 3554 kvm_x86_ops->get_segment(vcpu, var, seg);
3293} 3555}
3294 3556
3557static gpa_t translate_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
3558{
3559 return gpa;
3560}
3561
3562static gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
3563{
3564 gpa_t t_gpa;
3565 u32 error;
3566
3567 BUG_ON(!mmu_is_nested(vcpu));
3568
3569 /* NPT walks are always user-walks */
3570 access |= PFERR_USER_MASK;
3571 t_gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, gpa, access, &error);
3572 if (t_gpa == UNMAPPED_GVA)
3573 vcpu->arch.fault.nested = true;
3574
3575 return t_gpa;
3576}
3577
3295gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3578gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3296{ 3579{
3297 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;
3298 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3581 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3299} 3582}
3300 3583
3301 gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3584 gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3302{ 3585{
3303 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3586 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
3304 access |= PFERR_FETCH_MASK; 3587 access |= PFERR_FETCH_MASK;
3305 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3588 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3306} 3589}
3307 3590
3308gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3591gpa_t kvm_mmu_gva_to_gpa_write(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3309{ 3592{
3310 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; 3593 u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
3311 access |= PFERR_WRITE_MASK; 3594 access |= PFERR_WRITE_MASK;
3312 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, access, error); 3595 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, error);
3313} 3596}
3314 3597
3315/* uses this to access any guest's mapped memory without checking CPL */ 3598/* uses this to access any guest's mapped memory without checking CPL */
3316gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, u32 *error) 3599gpa_t kvm_mmu_gva_to_gpa_system(struct kvm_vcpu *vcpu, gva_t gva, u32 *error)
3317{ 3600{
3318 return vcpu->arch.mmu.gva_to_gpa(vcpu, gva, 0, error); 3601 return vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, 0, error);
3319} 3602}
3320 3603
3321static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes, 3604static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
@@ -3326,7 +3609,8 @@ static int kvm_read_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
3326 int r = X86EMUL_CONTINUE; 3609 int r = X86EMUL_CONTINUE;
3327 3610
3328 while (bytes) { 3611 while (bytes) {
3329 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr, access, error); 3612 gpa_t gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr, access,
3613 error);
3330 unsigned offset = addr & (PAGE_SIZE-1); 3614 unsigned offset = addr & (PAGE_SIZE-1);
3331 unsigned toread = min(bytes, (unsigned)PAGE_SIZE - offset); 3615 unsigned toread = min(bytes, (unsigned)PAGE_SIZE - offset);
3332 int ret; 3616 int ret;
@@ -3381,8 +3665,9 @@ static int kvm_write_guest_virt_system(gva_t addr, void *val,
3381 int r = X86EMUL_CONTINUE; 3665 int r = X86EMUL_CONTINUE;
3382 3666
3383 while (bytes) { 3667 while (bytes) {
3384 gpa_t gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, addr, 3668 gpa_t gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr,
3385 PFERR_WRITE_MASK, error); 3669 PFERR_WRITE_MASK,
3670 error);
3386 unsigned offset = addr & (PAGE_SIZE-1); 3671 unsigned offset = addr & (PAGE_SIZE-1);
3387 unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset); 3672 unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset);
3388 int ret; 3673 int ret;
@@ -3624,7 +3909,7 @@ static int emulator_pio_in_emulated(int size, unsigned short port, void *val,
3624 if (vcpu->arch.pio.count) 3909 if (vcpu->arch.pio.count)
3625 goto data_avail; 3910 goto data_avail;
3626 3911
3627 trace_kvm_pio(1, port, size, 1); 3912 trace_kvm_pio(0, port, size, 1);
3628 3913
3629 vcpu->arch.pio.port = port; 3914 vcpu->arch.pio.port = port;
3630 vcpu->arch.pio.in = 1; 3915 vcpu->arch.pio.in = 1;
@@ -3652,7 +3937,7 @@ static int emulator_pio_out_emulated(int size, unsigned short port,
3652 const void *val, unsigned int count, 3937 const void *val, unsigned int count,
3653 struct kvm_vcpu *vcpu) 3938 struct kvm_vcpu *vcpu)
3654{ 3939{
3655 trace_kvm_pio(0, port, size, 1); 3940 trace_kvm_pio(1, port, size, 1);
3656 3941
3657 vcpu->arch.pio.port = port; 3942 vcpu->arch.pio.port = port;
3658 vcpu->arch.pio.in = 0; 3943 vcpu->arch.pio.in = 0;
@@ -3693,8 +3978,10 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu)
3693 return X86EMUL_CONTINUE; 3978 return X86EMUL_CONTINUE;
3694 3979
3695 if (kvm_x86_ops->has_wbinvd_exit()) { 3980 if (kvm_x86_ops->has_wbinvd_exit()) {
3981 preempt_disable();
3696 smp_call_function_many(vcpu->arch.wbinvd_dirty_mask, 3982 smp_call_function_many(vcpu->arch.wbinvd_dirty_mask,
3697 wbinvd_ipi, NULL, 1); 3983 wbinvd_ipi, NULL, 1);
3984 preempt_enable();
3698 cpumask_clear(vcpu->arch.wbinvd_dirty_mask); 3985 cpumask_clear(vcpu->arch.wbinvd_dirty_mask);
3699 } 3986 }
3700 wbinvd(); 3987 wbinvd();
@@ -3791,6 +4078,11 @@ static void emulator_get_gdt(struct desc_ptr *dt, struct kvm_vcpu *vcpu)
3791 kvm_x86_ops->get_gdt(vcpu, dt); 4078 kvm_x86_ops->get_gdt(vcpu, dt);
3792} 4079}
3793 4080
4081static void emulator_get_idt(struct desc_ptr *dt, struct kvm_vcpu *vcpu)
4082{
4083 kvm_x86_ops->get_idt(vcpu, dt);
4084}
4085
3794static unsigned long emulator_get_cached_segment_base(int seg, 4086static unsigned long emulator_get_cached_segment_base(int seg,
3795 struct kvm_vcpu *vcpu) 4087 struct kvm_vcpu *vcpu)
3796{ 4088{
@@ -3884,6 +4176,7 @@ static struct x86_emulate_ops emulate_ops = {
3884 .set_segment_selector = emulator_set_segment_selector, 4176 .set_segment_selector = emulator_set_segment_selector,
3885 .get_cached_segment_base = emulator_get_cached_segment_base, 4177 .get_cached_segment_base = emulator_get_cached_segment_base,
3886 .get_gdt = emulator_get_gdt, 4178 .get_gdt = emulator_get_gdt,
4179 .get_idt = emulator_get_idt,
3887 .get_cr = emulator_get_cr, 4180 .get_cr = emulator_get_cr,
3888 .set_cr = emulator_set_cr, 4181 .set_cr = emulator_set_cr,
3889 .cpl = emulator_get_cpl, 4182 .cpl = emulator_get_cpl,
@@ -3919,13 +4212,64 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu)
3919{ 4212{
3920 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; 4213 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
3921 if (ctxt->exception == PF_VECTOR) 4214 if (ctxt->exception == PF_VECTOR)
3922 kvm_inject_page_fault(vcpu, ctxt->cr2, ctxt->error_code); 4215 kvm_propagate_fault(vcpu);
3923 else if (ctxt->error_code_valid) 4216 else if (ctxt->error_code_valid)
3924 kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code); 4217 kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code);
3925 else 4218 else
3926 kvm_queue_exception(vcpu, ctxt->exception); 4219 kvm_queue_exception(vcpu, ctxt->exception);
3927} 4220}
3928 4221
4222static void init_emulate_ctxt(struct kvm_vcpu *vcpu)
4223{
4224 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
4225 int cs_db, cs_l;
4226
4227 cache_all_regs(vcpu);
4228
4229 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
4230
4231 vcpu->arch.emulate_ctxt.vcpu = vcpu;
4232 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
4233 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
4234 vcpu->arch.emulate_ctxt.mode =
4235 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
4236 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
4237 ? X86EMUL_MODE_VM86 : cs_l
4238 ? X86EMUL_MODE_PROT64 : cs_db
4239 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
4240 memset(c, 0, sizeof(struct decode_cache));
4241 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
4242}
4243
4244int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq)
4245{
4246 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
4247 int ret;
4248
4249 init_emulate_ctxt(vcpu);
4250
4251 vcpu->arch.emulate_ctxt.decode.op_bytes = 2;
4252 vcpu->arch.emulate_ctxt.decode.ad_bytes = 2;
4253 vcpu->arch.emulate_ctxt.decode.eip = vcpu->arch.emulate_ctxt.eip;
4254 ret = emulate_int_real(&vcpu->arch.emulate_ctxt, &emulate_ops, irq);
4255
4256 if (ret != X86EMUL_CONTINUE)
4257 return EMULATE_FAIL;
4258
4259 vcpu->arch.emulate_ctxt.eip = c->eip;
4260 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4261 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4262 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4263
4264 if (irq == NMI_VECTOR)
4265 vcpu->arch.nmi_pending = false;
4266 else
4267 vcpu->arch.interrupt.pending = false;
4268
4269 return EMULATE_DONE;
4270}
4271EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt);
4272
3929static int handle_emulation_failure(struct kvm_vcpu *vcpu) 4273static int handle_emulation_failure(struct kvm_vcpu *vcpu)
3930{ 4274{
3931 ++vcpu->stat.insn_emulation_fail; 4275 ++vcpu->stat.insn_emulation_fail;
@@ -3982,24 +4326,15 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
3982 cache_all_regs(vcpu); 4326 cache_all_regs(vcpu);
3983 4327
3984 if (!(emulation_type & EMULTYPE_NO_DECODE)) { 4328 if (!(emulation_type & EMULTYPE_NO_DECODE)) {
3985 int cs_db, cs_l; 4329 init_emulate_ctxt(vcpu);
3986 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
3987
3988 vcpu->arch.emulate_ctxt.vcpu = vcpu;
3989 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
3990 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
3991 vcpu->arch.emulate_ctxt.mode =
3992 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
3993 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
3994 ? X86EMUL_MODE_VM86 : cs_l
3995 ? X86EMUL_MODE_PROT64 : cs_db
3996 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
3997 memset(c, 0, sizeof(struct decode_cache));
3998 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
3999 vcpu->arch.emulate_ctxt.interruptibility = 0; 4330 vcpu->arch.emulate_ctxt.interruptibility = 0;
4000 vcpu->arch.emulate_ctxt.exception = -1; 4331 vcpu->arch.emulate_ctxt.exception = -1;
4332 vcpu->arch.emulate_ctxt.perm_ok = false;
4333
4334 r = x86_decode_insn(&vcpu->arch.emulate_ctxt);
4335 if (r == X86EMUL_PROPAGATE_FAULT)
4336 goto done;
4001 4337
4002 r = x86_decode_insn(&vcpu->arch.emulate_ctxt, &emulate_ops);
4003 trace_kvm_emulate_insn_start(vcpu); 4338 trace_kvm_emulate_insn_start(vcpu);
4004 4339
4005 /* Only allow emulation of specific instructions on #UD 4340 /* Only allow emulation of specific instructions on #UD
@@ -4049,41 +4384,39 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
4049 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); 4384 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
4050 4385
4051restart: 4386restart:
4052 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt, &emulate_ops); 4387 r = x86_emulate_insn(&vcpu->arch.emulate_ctxt);
4053 4388
4054 if (r) { /* emulation failed */ 4389 if (r == EMULATION_FAILED) {
4055 if (reexecute_instruction(vcpu, cr2)) 4390 if (reexecute_instruction(vcpu, cr2))
4056 return EMULATE_DONE; 4391 return EMULATE_DONE;
4057 4392
4058 return handle_emulation_failure(vcpu); 4393 return handle_emulation_failure(vcpu);
4059 } 4394 }
4060 4395
4061 toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility); 4396done:
4062 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4063 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4064 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4065
4066 if (vcpu->arch.emulate_ctxt.exception >= 0) { 4397 if (vcpu->arch.emulate_ctxt.exception >= 0) {
4067 inject_emulated_exception(vcpu); 4398 inject_emulated_exception(vcpu);
4068 return EMULATE_DONE; 4399 r = EMULATE_DONE;
4069 } 4400 } else if (vcpu->arch.pio.count) {
4070
4071 if (vcpu->arch.pio.count) {
4072 if (!vcpu->arch.pio.in) 4401 if (!vcpu->arch.pio.in)
4073 vcpu->arch.pio.count = 0; 4402 vcpu->arch.pio.count = 0;
4074 return EMULATE_DO_MMIO; 4403 r = EMULATE_DO_MMIO;
4075 } 4404 } else if (vcpu->mmio_needed) {
4076
4077 if (vcpu->mmio_needed) {
4078 if (vcpu->mmio_is_write) 4405 if (vcpu->mmio_is_write)
4079 vcpu->mmio_needed = 0; 4406 vcpu->mmio_needed = 0;
4080 return EMULATE_DO_MMIO; 4407 r = EMULATE_DO_MMIO;
4081 } 4408 } else if (r == EMULATION_RESTART)
4082
4083 if (vcpu->arch.emulate_ctxt.restart)
4084 goto restart; 4409 goto restart;
4410 else
4411 r = EMULATE_DONE;
4085 4412
4086 return EMULATE_DONE; 4413 toggle_interruptibility(vcpu, vcpu->arch.emulate_ctxt.interruptibility);
4414 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
4415 kvm_make_request(KVM_REQ_EVENT, vcpu);
4416 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
4417 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
4418
4419 return r;
4087} 4420}
4088EXPORT_SYMBOL_GPL(emulate_instruction); 4421EXPORT_SYMBOL_GPL(emulate_instruction);
4089 4422
@@ -4097,9 +4430,23 @@ int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port)
4097} 4430}
4098EXPORT_SYMBOL_GPL(kvm_fast_pio_out); 4431EXPORT_SYMBOL_GPL(kvm_fast_pio_out);
4099 4432
4100static void bounce_off(void *info) 4433static void tsc_bad(void *info)
4101{ 4434{
4102 /* nothing */ 4435 __get_cpu_var(cpu_tsc_khz) = 0;
4436}
4437
4438static void tsc_khz_changed(void *data)
4439{
4440 struct cpufreq_freqs *freq = data;
4441 unsigned long khz = 0;
4442
4443 if (data)
4444 khz = freq->new;
4445 else if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
4446 khz = cpufreq_quick_get(raw_smp_processor_id());
4447 if (!khz)
4448 khz = tsc_khz;
4449 __get_cpu_var(cpu_tsc_khz) = khz;
4103} 4450}
4104 4451
4105static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 4452static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
@@ -4110,21 +4457,60 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
4110 struct kvm_vcpu *vcpu; 4457 struct kvm_vcpu *vcpu;
4111 int i, send_ipi = 0; 4458 int i, send_ipi = 0;
4112 4459
4460 /*
4461 * We allow guests to temporarily run on slowing clocks,
4462 * provided we notify them after, or to run on accelerating
4463 * clocks, provided we notify them before. Thus time never
4464 * goes backwards.
4465 *
4466 * However, we have a problem. We can't atomically update
4467 * the frequency of a given CPU from this function; it is
4468 * merely a notifier, which can be called from any CPU.
4469 * Changing the TSC frequency at arbitrary points in time
4470 * requires a recomputation of local variables related to
4471 * the TSC for each VCPU. We must flag these local variables
4472 * to be updated and be sure the update takes place with the
4473 * new frequency before any guests proceed.
4474 *
4475 * Unfortunately, the combination of hotplug CPU and frequency
4476 * change creates an intractable locking scenario; the order
4477 * of when these callouts happen is undefined with respect to
4478 * CPU hotplug, and they can race with each other. As such,
4479 * merely setting per_cpu(cpu_tsc_khz) = X during a hotadd is
4480 * undefined; you can actually have a CPU frequency change take
4481 * place in between the computation of X and the setting of the
4482 * variable. To protect against this problem, all updates of
4483 * the per_cpu tsc_khz variable are done in an interrupt
4484 * protected IPI, and all callers wishing to update the value
4485 * must wait for a synchronous IPI to complete (which is trivial
4486 * if the caller is on the CPU already). This establishes the
4487 * necessary total order on variable updates.
4488 *
4489 * Note that because a guest time update may take place
4490 * anytime after the setting of the VCPU's request bit, the
4491 * correct TSC value must be set before the request. However,
4492 * to ensure the update actually makes it to any guest which
4493 * starts running in hardware virtualization between the set
4494 * and the acquisition of the spinlock, we must also ping the
4495 * CPU after setting the request bit.
4496 *
4497 */
4498
4113 if (val == CPUFREQ_PRECHANGE && freq->old > freq->new) 4499 if (val == CPUFREQ_PRECHANGE && freq->old > freq->new)
4114 return 0; 4500 return 0;
4115 if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new) 4501 if (val == CPUFREQ_POSTCHANGE && freq->old < freq->new)
4116 return 0; 4502 return 0;
4117 per_cpu(cpu_tsc_khz, freq->cpu) = freq->new; 4503
4504 smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
4118 4505
4119 spin_lock(&kvm_lock); 4506 spin_lock(&kvm_lock);
4120 list_for_each_entry(kvm, &vm_list, vm_list) { 4507 list_for_each_entry(kvm, &vm_list, vm_list) {
4121 kvm_for_each_vcpu(i, vcpu, kvm) { 4508 kvm_for_each_vcpu(i, vcpu, kvm) {
4122 if (vcpu->cpu != freq->cpu) 4509 if (vcpu->cpu != freq->cpu)
4123 continue; 4510 continue;
4124 if (!kvm_request_guest_time_update(vcpu)) 4511 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
4125 continue;
4126 if (vcpu->cpu != smp_processor_id()) 4512 if (vcpu->cpu != smp_processor_id())
4127 send_ipi++; 4513 send_ipi = 1;
4128 } 4514 }
4129 } 4515 }
4130 spin_unlock(&kvm_lock); 4516 spin_unlock(&kvm_lock);
@@ -4142,32 +4528,57 @@ static int kvmclock_cpufreq_notifier(struct notifier_block *nb, unsigned long va
4142 * guest context is entered kvmclock will be updated, 4528 * guest context is entered kvmclock will be updated,
4143 * so the guest will not see stale values. 4529 * so the guest will not see stale values.
4144 */ 4530 */
4145 smp_call_function_single(freq->cpu, bounce_off, NULL, 1); 4531 smp_call_function_single(freq->cpu, tsc_khz_changed, freq, 1);
4146 } 4532 }
4147 return 0; 4533 return 0;
4148} 4534}
4149 4535
4150static struct notifier_block kvmclock_cpufreq_notifier_block = { 4536static struct notifier_block kvmclock_cpufreq_notifier_block = {
4151 .notifier_call = kvmclock_cpufreq_notifier 4537 .notifier_call = kvmclock_cpufreq_notifier
4538};
4539
4540static int kvmclock_cpu_notifier(struct notifier_block *nfb,
4541 unsigned long action, void *hcpu)
4542{
4543 unsigned int cpu = (unsigned long)hcpu;
4544
4545 switch (action) {
4546 case CPU_ONLINE:
4547 case CPU_DOWN_FAILED:
4548 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
4549 break;
4550 case CPU_DOWN_PREPARE:
4551 smp_call_function_single(cpu, tsc_bad, NULL, 1);
4552 break;
4553 }
4554 return NOTIFY_OK;
4555}
4556
4557static struct notifier_block kvmclock_cpu_notifier_block = {
4558 .notifier_call = kvmclock_cpu_notifier,
4559 .priority = -INT_MAX
4152}; 4560};
4153 4561
4154static void kvm_timer_init(void) 4562static void kvm_timer_init(void)
4155{ 4563{
4156 int cpu; 4564 int cpu;
4157 4565
4566 max_tsc_khz = tsc_khz;
4567 register_hotcpu_notifier(&kvmclock_cpu_notifier_block);
4158 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) { 4568 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
4569#ifdef CONFIG_CPU_FREQ
4570 struct cpufreq_policy policy;
4571 memset(&policy, 0, sizeof(policy));
4572 cpufreq_get_policy(&policy, get_cpu());
4573 if (policy.cpuinfo.max_freq)
4574 max_tsc_khz = policy.cpuinfo.max_freq;
4575#endif
4159 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block, 4576 cpufreq_register_notifier(&kvmclock_cpufreq_notifier_block,
4160 CPUFREQ_TRANSITION_NOTIFIER); 4577 CPUFREQ_TRANSITION_NOTIFIER);
4161 for_each_online_cpu(cpu) {
4162 unsigned long khz = cpufreq_get(cpu);
4163 if (!khz)
4164 khz = tsc_khz;
4165 per_cpu(cpu_tsc_khz, cpu) = khz;
4166 }
4167 } else {
4168 for_each_possible_cpu(cpu)
4169 per_cpu(cpu_tsc_khz, cpu) = tsc_khz;
4170 } 4578 }
4579 pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz);
4580 for_each_online_cpu(cpu)
4581 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
4171} 4582}
4172 4583
4173static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu); 4584static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu);
@@ -4269,6 +4680,7 @@ void kvm_arch_exit(void)
4269 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 4680 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
4270 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, 4681 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block,
4271 CPUFREQ_TRANSITION_NOTIFIER); 4682 CPUFREQ_TRANSITION_NOTIFIER);
4683 unregister_hotcpu_notifier(&kvmclock_cpu_notifier_block);
4272 kvm_x86_ops = NULL; 4684 kvm_x86_ops = NULL;
4273 kvm_mmu_module_exit(); 4685 kvm_mmu_module_exit();
4274} 4686}
@@ -4684,8 +5096,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4684 kvm_mmu_unload(vcpu); 5096 kvm_mmu_unload(vcpu);
4685 if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu)) 5097 if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))
4686 __kvm_migrate_timers(vcpu); 5098 __kvm_migrate_timers(vcpu);
4687 if (kvm_check_request(KVM_REQ_KVMCLOCK_UPDATE, vcpu)) 5099 if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, vcpu)) {
4688 kvm_write_guest_time(vcpu); 5100 r = kvm_guest_time_update(vcpu);
5101 if (unlikely(r))
5102 goto out;
5103 }
4689 if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu)) 5104 if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu))
4690 kvm_mmu_sync_roots(vcpu); 5105 kvm_mmu_sync_roots(vcpu);
4691 if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) 5106 if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu))
@@ -4710,6 +5125,21 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4710 if (unlikely(r)) 5125 if (unlikely(r))
4711 goto out; 5126 goto out;
4712 5127
5128 if (kvm_check_request(KVM_REQ_EVENT, vcpu) || req_int_win) {
5129 inject_pending_event(vcpu);
5130
5131 /* enable NMI/IRQ window open exits if needed */
5132 if (vcpu->arch.nmi_pending)
5133 kvm_x86_ops->enable_nmi_window(vcpu);
5134 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
5135 kvm_x86_ops->enable_irq_window(vcpu);
5136
5137 if (kvm_lapic_enabled(vcpu)) {
5138 update_cr8_intercept(vcpu);
5139 kvm_lapic_sync_to_vapic(vcpu);
5140 }
5141 }
5142
4713 preempt_disable(); 5143 preempt_disable();
4714 5144
4715 kvm_x86_ops->prepare_guest_switch(vcpu); 5145 kvm_x86_ops->prepare_guest_switch(vcpu);
@@ -4728,23 +5158,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4728 smp_wmb(); 5158 smp_wmb();
4729 local_irq_enable(); 5159 local_irq_enable();
4730 preempt_enable(); 5160 preempt_enable();
5161 kvm_x86_ops->cancel_injection(vcpu);
4731 r = 1; 5162 r = 1;
4732 goto out; 5163 goto out;
4733 } 5164 }
4734 5165
4735 inject_pending_event(vcpu);
4736
4737 /* enable NMI/IRQ window open exits if needed */
4738 if (vcpu->arch.nmi_pending)
4739 kvm_x86_ops->enable_nmi_window(vcpu);
4740 else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
4741 kvm_x86_ops->enable_irq_window(vcpu);
4742
4743 if (kvm_lapic_enabled(vcpu)) {
4744 update_cr8_intercept(vcpu);
4745 kvm_lapic_sync_to_vapic(vcpu);
4746 }
4747
4748 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 5166 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
4749 5167
4750 kvm_guest_enter(); 5168 kvm_guest_enter();
@@ -4770,6 +5188,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
4770 if (hw_breakpoint_active()) 5188 if (hw_breakpoint_active())
4771 hw_breakpoint_restore(); 5189 hw_breakpoint_restore();
4772 5190
5191 kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
5192
4773 atomic_set(&vcpu->guest_mode, 0); 5193 atomic_set(&vcpu->guest_mode, 0);
4774 smp_wmb(); 5194 smp_wmb();
4775 local_irq_enable(); 5195 local_irq_enable();
@@ -4899,8 +5319,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
4899 if (!irqchip_in_kernel(vcpu->kvm)) 5319 if (!irqchip_in_kernel(vcpu->kvm))
4900 kvm_set_cr8(vcpu, kvm_run->cr8); 5320 kvm_set_cr8(vcpu, kvm_run->cr8);
4901 5321
4902 if (vcpu->arch.pio.count || vcpu->mmio_needed || 5322 if (vcpu->arch.pio.count || vcpu->mmio_needed) {
4903 vcpu->arch.emulate_ctxt.restart) {
4904 if (vcpu->mmio_needed) { 5323 if (vcpu->mmio_needed) {
4905 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); 5324 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
4906 vcpu->mmio_read_completed = 1; 5325 vcpu->mmio_read_completed = 1;
@@ -4981,6 +5400,8 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
4981 5400
4982 vcpu->arch.exception.pending = false; 5401 vcpu->arch.exception.pending = false;
4983 5402
5403 kvm_make_request(KVM_REQ_EVENT, vcpu);
5404
4984 return 0; 5405 return 0;
4985} 5406}
4986 5407
@@ -5044,6 +5465,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
5044 struct kvm_mp_state *mp_state) 5465 struct kvm_mp_state *mp_state)
5045{ 5466{
5046 vcpu->arch.mp_state = mp_state->mp_state; 5467 vcpu->arch.mp_state = mp_state->mp_state;
5468 kvm_make_request(KVM_REQ_EVENT, vcpu);
5047 return 0; 5469 return 0;
5048} 5470}
5049 5471
@@ -5051,24 +5473,11 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
5051 bool has_error_code, u32 error_code) 5473 bool has_error_code, u32 error_code)
5052{ 5474{
5053 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode; 5475 struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;
5054 int cs_db, cs_l, ret; 5476 int ret;
5055 cache_all_regs(vcpu);
5056 5477
5057 kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l); 5478 init_emulate_ctxt(vcpu);
5058 5479
5059 vcpu->arch.emulate_ctxt.vcpu = vcpu; 5480 ret = emulator_task_switch(&vcpu->arch.emulate_ctxt,
5060 vcpu->arch.emulate_ctxt.eflags = kvm_x86_ops->get_rflags(vcpu);
5061 vcpu->arch.emulate_ctxt.eip = kvm_rip_read(vcpu);
5062 vcpu->arch.emulate_ctxt.mode =
5063 (!is_protmode(vcpu)) ? X86EMUL_MODE_REAL :
5064 (vcpu->arch.emulate_ctxt.eflags & X86_EFLAGS_VM)
5065 ? X86EMUL_MODE_VM86 : cs_l
5066 ? X86EMUL_MODE_PROT64 : cs_db
5067 ? X86EMUL_MODE_PROT32 : X86EMUL_MODE_PROT16;
5068 memset(c, 0, sizeof(struct decode_cache));
5069 memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
5070
5071 ret = emulator_task_switch(&vcpu->arch.emulate_ctxt, &emulate_ops,
5072 tss_selector, reason, has_error_code, 5481 tss_selector, reason, has_error_code,
5073 error_code); 5482 error_code);
5074 5483
@@ -5078,6 +5487,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
5078 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs); 5487 memcpy(vcpu->arch.regs, c->regs, sizeof c->regs);
5079 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); 5488 kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip);
5080 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); 5489 kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags);
5490 kvm_make_request(KVM_REQ_EVENT, vcpu);
5081 return EMULATE_DONE; 5491 return EMULATE_DONE;
5082} 5492}
5083EXPORT_SYMBOL_GPL(kvm_task_switch); 5493EXPORT_SYMBOL_GPL(kvm_task_switch);
@@ -5113,7 +5523,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5113 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4; 5523 mmu_reset_needed |= kvm_read_cr4(vcpu) != sregs->cr4;
5114 kvm_x86_ops->set_cr4(vcpu, sregs->cr4); 5524 kvm_x86_ops->set_cr4(vcpu, sregs->cr4);
5115 if (!is_long_mode(vcpu) && is_pae(vcpu)) { 5525 if (!is_long_mode(vcpu) && is_pae(vcpu)) {
5116 load_pdptrs(vcpu, vcpu->arch.cr3); 5526 load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3);
5117 mmu_reset_needed = 1; 5527 mmu_reset_needed = 1;
5118 } 5528 }
5119 5529
@@ -5148,6 +5558,8 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5148 !is_protmode(vcpu)) 5558 !is_protmode(vcpu))
5149 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 5559 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
5150 5560
5561 kvm_make_request(KVM_REQ_EVENT, vcpu);
5562
5151 return 0; 5563 return 0;
5152} 5564}
5153 5565
@@ -5334,6 +5746,10 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
5334struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, 5746struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
5335 unsigned int id) 5747 unsigned int id)
5336{ 5748{
5749 if (check_tsc_unstable() && atomic_read(&kvm->online_vcpus) != 0)
5750 printk_once(KERN_WARNING
5751 "kvm: SMP vm created on host with unstable TSC; "
5752 "guest TSC will not be reliable\n");
5337 return kvm_x86_ops->vcpu_create(kvm, id); 5753 return kvm_x86_ops->vcpu_create(kvm, id);
5338} 5754}
5339 5755
@@ -5376,22 +5792,22 @@ int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu)
5376 vcpu->arch.dr6 = DR6_FIXED_1; 5792 vcpu->arch.dr6 = DR6_FIXED_1;
5377 vcpu->arch.dr7 = DR7_FIXED_1; 5793 vcpu->arch.dr7 = DR7_FIXED_1;
5378 5794
5795 kvm_make_request(KVM_REQ_EVENT, vcpu);
5796
5379 return kvm_x86_ops->vcpu_reset(vcpu); 5797 return kvm_x86_ops->vcpu_reset(vcpu);
5380} 5798}
5381 5799
5382int kvm_arch_hardware_enable(void *garbage) 5800int kvm_arch_hardware_enable(void *garbage)
5383{ 5801{
5384 /* 5802 struct kvm *kvm;
5385 * Since this may be called from a hotplug notifcation, 5803 struct kvm_vcpu *vcpu;
5386 * we can't get the CPU frequency directly. 5804 int i;
5387 */
5388 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
5389 int cpu = raw_smp_processor_id();
5390 per_cpu(cpu_tsc_khz, cpu) = 0;
5391 }
5392 5805
5393 kvm_shared_msr_cpu_online(); 5806 kvm_shared_msr_cpu_online();
5394 5807 list_for_each_entry(kvm, &vm_list, vm_list)
5808 kvm_for_each_vcpu(i, vcpu, kvm)
5809 if (vcpu->cpu == smp_processor_id())
5810 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
5395 return kvm_x86_ops->hardware_enable(garbage); 5811 return kvm_x86_ops->hardware_enable(garbage);
5396} 5812}
5397 5813
@@ -5425,7 +5841,11 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5425 BUG_ON(vcpu->kvm == NULL); 5841 BUG_ON(vcpu->kvm == NULL);
5426 kvm = vcpu->kvm; 5842 kvm = vcpu->kvm;
5427 5843
5844 vcpu->arch.emulate_ctxt.ops = &emulate_ops;
5845 vcpu->arch.walk_mmu = &vcpu->arch.mmu;
5428 vcpu->arch.mmu.root_hpa = INVALID_PAGE; 5846 vcpu->arch.mmu.root_hpa = INVALID_PAGE;
5847 vcpu->arch.mmu.translate_gpa = translate_gpa;
5848 vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa;
5429 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu)) 5849 if (!irqchip_in_kernel(kvm) || kvm_vcpu_is_bsp(vcpu))
5430 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; 5850 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
5431 else 5851 else
@@ -5438,6 +5858,9 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5438 } 5858 }
5439 vcpu->arch.pio_data = page_address(page); 5859 vcpu->arch.pio_data = page_address(page);
5440 5860
5861 if (!kvm->arch.virtual_tsc_khz)
5862 kvm_arch_set_tsc_khz(kvm, max_tsc_khz);
5863
5441 r = kvm_mmu_create(vcpu); 5864 r = kvm_mmu_create(vcpu);
5442 if (r < 0) 5865 if (r < 0)
5443 goto fail_free_pio_data; 5866 goto fail_free_pio_data;
@@ -5497,7 +5920,7 @@ struct kvm *kvm_arch_create_vm(void)
5497 /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */ 5920 /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */
5498 set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap); 5921 set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap);
5499 5922
5500 rdtscll(kvm->arch.vm_init_tsc); 5923 spin_lock_init(&kvm->arch.tsc_write_lock);
5501 5924
5502 return kvm; 5925 return kvm;
5503} 5926}
@@ -5684,6 +6107,7 @@ void kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
5684 kvm_is_linear_rip(vcpu, vcpu->arch.singlestep_rip)) 6107 kvm_is_linear_rip(vcpu, vcpu->arch.singlestep_rip))
5685 rflags |= X86_EFLAGS_TF; 6108 rflags |= X86_EFLAGS_TF;
5686 kvm_x86_ops->set_rflags(vcpu, rflags); 6109 kvm_x86_ops->set_rflags(vcpu, rflags);
6110 kvm_make_request(KVM_REQ_EVENT, vcpu);
5687} 6111}
5688EXPORT_SYMBOL_GPL(kvm_set_rflags); 6112EXPORT_SYMBOL_GPL(kvm_set_rflags);
5689 6113
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/mm/Makefile b/arch/x86/mm/Makefile
index 55543397a8a7..09df2f9a3d69 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -23,7 +23,7 @@ mmiotrace-y := kmmio.o pf_in.o mmio-mod.o
23obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o 23obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o
24 24
25obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o 25obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o
26obj-$(CONFIG_K8_NUMA) += k8topology_64.o 26obj-$(CONFIG_AMD_NUMA) += amdtopology_64.o
27obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o 27obj-$(CONFIG_ACPI_NUMA) += srat_$(BITS).o
28 28
29obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o 29obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
diff --git a/arch/x86/mm/k8topology_64.c b/arch/x86/mm/amdtopology_64.c
index 804a3b6c6e14..51fae9cfdecb 100644
--- a/arch/x86/mm/k8topology_64.c
+++ b/arch/x86/mm/amdtopology_64.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * AMD K8 NUMA support. 2 * AMD NUMA support.
3 * Discover the memory map and associated nodes. 3 * Discover the memory map and associated nodes.
4 * 4 *
5 * This version reads it directly from the K8 northbridge. 5 * This version reads it directly from the AMD northbridge.
6 * 6 *
7 * Copyright 2002,2003 Andi Kleen, SuSE Labs. 7 * Copyright 2002,2003 Andi Kleen, SuSE Labs.
8 */ 8 */
@@ -57,7 +57,7 @@ static __init void early_get_boot_cpu_id(void)
57{ 57{
58 /* 58 /*
59 * need to get the APIC ID of the BSP so can use that to 59 * need to get the APIC ID of the BSP so can use that to
60 * create apicid_to_node in k8_scan_nodes() 60 * create apicid_to_node in amd_scan_nodes()
61 */ 61 */
62#ifdef CONFIG_X86_MPPARSE 62#ifdef CONFIG_X86_MPPARSE
63 /* 63 /*
@@ -69,7 +69,7 @@ static __init void early_get_boot_cpu_id(void)
69 early_init_lapic_mapping(); 69 early_init_lapic_mapping();
70} 70}
71 71
72int __init k8_get_nodes(struct bootnode *physnodes) 72int __init amd_get_nodes(struct bootnode *physnodes)
73{ 73{
74 int i; 74 int i;
75 int ret = 0; 75 int ret = 0;
@@ -82,7 +82,7 @@ int __init k8_get_nodes(struct bootnode *physnodes)
82 return ret; 82 return ret;
83} 83}
84 84
85int __init k8_numa_init(unsigned long start_pfn, unsigned long end_pfn) 85int __init amd_numa_init(unsigned long start_pfn, unsigned long end_pfn)
86{ 86{
87 unsigned long start = PFN_PHYS(start_pfn); 87 unsigned long start = PFN_PHYS(start_pfn);
88 unsigned long end = PFN_PHYS(end_pfn); 88 unsigned long end = PFN_PHYS(end_pfn);
@@ -194,7 +194,7 @@ int __init k8_numa_init(unsigned long start_pfn, unsigned long end_pfn)
194 return 0; 194 return 0;
195} 195}
196 196
197int __init k8_scan_nodes(void) 197int __init amd_scan_nodes(void)
198{ 198{
199 unsigned int bits; 199 unsigned int bits;
200 unsigned int cores; 200 unsigned int cores;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 79b0b372d2d0..7d90ceb882a4 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -11,6 +11,7 @@
11#include <linux/kprobes.h> /* __kprobes, ... */ 11#include <linux/kprobes.h> /* __kprobes, ... */
12#include <linux/mmiotrace.h> /* kmmio_handler, ... */ 12#include <linux/mmiotrace.h> /* kmmio_handler, ... */
13#include <linux/perf_event.h> /* perf_sw_event */ 13#include <linux/perf_event.h> /* perf_sw_event */
14#include <linux/hugetlb.h> /* hstate_index_to_shift */
14 15
15#include <asm/traps.h> /* dotraplinkage, ... */ 16#include <asm/traps.h> /* dotraplinkage, ... */
16#include <asm/pgalloc.h> /* pgd_*(), ... */ 17#include <asm/pgalloc.h> /* pgd_*(), ... */
@@ -160,15 +161,20 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
160 161
161static void 162static void
162force_sig_info_fault(int si_signo, int si_code, unsigned long address, 163force_sig_info_fault(int si_signo, int si_code, unsigned long address,
163 struct task_struct *tsk) 164 struct task_struct *tsk, int fault)
164{ 165{
166 unsigned lsb = 0;
165 siginfo_t info; 167 siginfo_t info;
166 168
167 info.si_signo = si_signo; 169 info.si_signo = si_signo;
168 info.si_errno = 0; 170 info.si_errno = 0;
169 info.si_code = si_code; 171 info.si_code = si_code;
170 info.si_addr = (void __user *)address; 172 info.si_addr = (void __user *)address;
171 info.si_addr_lsb = si_code == BUS_MCEERR_AR ? PAGE_SHIFT : 0; 173 if (fault & VM_FAULT_HWPOISON_LARGE)
174 lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault));
175 if (fault & VM_FAULT_HWPOISON)
176 lsb = PAGE_SHIFT;
177 info.si_addr_lsb = lsb;
172 178
173 force_sig_info(si_signo, &info, tsk); 179 force_sig_info(si_signo, &info, tsk);
174} 180}
@@ -722,7 +728,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
722 tsk->thread.error_code = error_code | (address >= TASK_SIZE); 728 tsk->thread.error_code = error_code | (address >= TASK_SIZE);
723 tsk->thread.trap_no = 14; 729 tsk->thread.trap_no = 14;
724 730
725 force_sig_info_fault(SIGSEGV, si_code, address, tsk); 731 force_sig_info_fault(SIGSEGV, si_code, address, tsk, 0);
726 732
727 return; 733 return;
728 } 734 }
@@ -807,14 +813,14 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
807 tsk->thread.trap_no = 14; 813 tsk->thread.trap_no = 14;
808 814
809#ifdef CONFIG_MEMORY_FAILURE 815#ifdef CONFIG_MEMORY_FAILURE
810 if (fault & VM_FAULT_HWPOISON) { 816 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
811 printk(KERN_ERR 817 printk(KERN_ERR
812 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", 818 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
813 tsk->comm, tsk->pid, address); 819 tsk->comm, tsk->pid, address);
814 code = BUS_MCEERR_AR; 820 code = BUS_MCEERR_AR;
815 } 821 }
816#endif 822#endif
817 force_sig_info_fault(SIGBUS, code, address, tsk); 823 force_sig_info_fault(SIGBUS, code, address, tsk, fault);
818} 824}
819 825
820static noinline void 826static noinline void
@@ -824,7 +830,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
824 if (fault & VM_FAULT_OOM) { 830 if (fault & VM_FAULT_OOM) {
825 out_of_memory(regs, error_code, address); 831 out_of_memory(regs, error_code, address);
826 } else { 832 } else {
827 if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON)) 833 if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|
834 VM_FAULT_HWPOISON_LARGE))
828 do_sigbus(regs, error_code, address, fault); 835 do_sigbus(regs, error_code, address, fault);
829 else 836 else
830 BUG(); 837 BUG();
@@ -912,9 +919,9 @@ spurious_fault(unsigned long error_code, unsigned long address)
912int show_unhandled_signals = 1; 919int show_unhandled_signals = 1;
913 920
914static inline int 921static inline int
915access_error(unsigned long error_code, int write, struct vm_area_struct *vma) 922access_error(unsigned long error_code, struct vm_area_struct *vma)
916{ 923{
917 if (write) { 924 if (error_code & PF_WRITE) {
918 /* write, present and write, not present: */ 925 /* write, present and write, not present: */
919 if (unlikely(!(vma->vm_flags & VM_WRITE))) 926 if (unlikely(!(vma->vm_flags & VM_WRITE)))
920 return 1; 927 return 1;
@@ -949,8 +956,10 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
949 struct task_struct *tsk; 956 struct task_struct *tsk;
950 unsigned long address; 957 unsigned long address;
951 struct mm_struct *mm; 958 struct mm_struct *mm;
952 int write;
953 int fault; 959 int fault;
960 int write = error_code & PF_WRITE;
961 unsigned int flags = FAULT_FLAG_ALLOW_RETRY |
962 (write ? FAULT_FLAG_WRITE : 0);
954 963
955 tsk = current; 964 tsk = current;
956 mm = tsk->mm; 965 mm = tsk->mm;
@@ -1061,6 +1070,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
1061 bad_area_nosemaphore(regs, error_code, address); 1070 bad_area_nosemaphore(regs, error_code, address);
1062 return; 1071 return;
1063 } 1072 }
1073retry:
1064 down_read(&mm->mmap_sem); 1074 down_read(&mm->mmap_sem);
1065 } else { 1075 } else {
1066 /* 1076 /*
@@ -1104,9 +1114,7 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
1104 * we can handle it.. 1114 * we can handle it..
1105 */ 1115 */
1106good_area: 1116good_area:
1107 write = error_code & PF_WRITE; 1117 if (unlikely(access_error(error_code, vma))) {
1108
1109 if (unlikely(access_error(error_code, write, vma))) {
1110 bad_area_access_error(regs, error_code, address); 1118 bad_area_access_error(regs, error_code, address);
1111 return; 1119 return;
1112 } 1120 }
@@ -1116,21 +1124,34 @@ good_area:
1116 * make sure we exit gracefully rather than endlessly redo 1124 * make sure we exit gracefully rather than endlessly redo
1117 * the fault: 1125 * the fault:
1118 */ 1126 */
1119 fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); 1127 fault = handle_mm_fault(mm, vma, address, flags);
1120 1128
1121 if (unlikely(fault & VM_FAULT_ERROR)) { 1129 if (unlikely(fault & VM_FAULT_ERROR)) {
1122 mm_fault_error(regs, error_code, address, fault); 1130 mm_fault_error(regs, error_code, address, fault);
1123 return; 1131 return;
1124 } 1132 }
1125 1133
1126 if (fault & VM_FAULT_MAJOR) { 1134 /*
1127 tsk->maj_flt++; 1135 * Major/minor page fault accounting is only done on the
1128 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0, 1136 * initial attempt. If we go through a retry, it is extremely
1129 regs, address); 1137 * likely that the page will be found in page cache at that point.
1130 } else { 1138 */
1131 tsk->min_flt++; 1139 if (flags & FAULT_FLAG_ALLOW_RETRY) {
1132 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0, 1140 if (fault & VM_FAULT_MAJOR) {
1133 regs, address); 1141 tsk->maj_flt++;
1142 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
1143 regs, address);
1144 } else {
1145 tsk->min_flt++;
1146 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
1147 regs, address);
1148 }
1149 if (fault & VM_FAULT_RETRY) {
1150 /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
1151 * of starvation. */
1152 flags &= ~FAULT_FLAG_ALLOW_RETRY;
1153 goto retry;
1154 }
1134 } 1155 }
1135 1156
1136 check_v8086_mode(regs, address, tsk); 1157 check_v8086_mode(regs, address, tsk);
diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
index 5e8fa12ef861..b49962662101 100644
--- a/arch/x86/mm/highmem_32.c
+++ b/arch/x86/mm/highmem_32.c
@@ -9,6 +9,7 @@ void *kmap(struct page *page)
9 return page_address(page); 9 return page_address(page);
10 return kmap_high(page); 10 return kmap_high(page);
11} 11}
12EXPORT_SYMBOL(kmap);
12 13
13void kunmap(struct page *page) 14void kunmap(struct page *page)
14{ 15{
@@ -18,6 +19,7 @@ void kunmap(struct page *page)
18 return; 19 return;
19 kunmap_high(page); 20 kunmap_high(page);
20} 21}
22EXPORT_SYMBOL(kunmap);
21 23
22/* 24/*
23 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because 25 * kmap_atomic/kunmap_atomic is significantly faster than kmap/kunmap because
@@ -27,10 +29,10 @@ void kunmap(struct page *page)
27 * However when holding an atomic kmap it is not legal to sleep, so atomic 29 * However when holding an atomic kmap it is not legal to sleep, so atomic
28 * kmaps are appropriate for short, tight code paths only. 30 * kmaps are appropriate for short, tight code paths only.
29 */ 31 */
30void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot) 32void *kmap_atomic_prot(struct page *page, pgprot_t prot)
31{ 33{
32 enum fixed_addresses idx;
33 unsigned long vaddr; 34 unsigned long vaddr;
35 int idx, type;
34 36
35 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
36 pagefault_disable(); 38 pagefault_disable();
@@ -38,8 +40,7 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
38 if (!PageHighMem(page)) 40 if (!PageHighMem(page))
39 return page_address(page); 41 return page_address(page);
40 42
41 debug_kmap_atomic(type); 43 type = kmap_atomic_idx_push();
42
43 idx = type + KM_TYPE_NR*smp_processor_id(); 44 idx = type + KM_TYPE_NR*smp_processor_id();
44 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 45 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
45 BUG_ON(!pte_none(*(kmap_pte-idx))); 46 BUG_ON(!pte_none(*(kmap_pte-idx)));
@@ -47,44 +48,57 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
47 48
48 return (void *)vaddr; 49 return (void *)vaddr;
49} 50}
51EXPORT_SYMBOL(kmap_atomic_prot);
52
53void *__kmap_atomic(struct page *page)
54{
55 return kmap_atomic_prot(page, kmap_prot);
56}
57EXPORT_SYMBOL(__kmap_atomic);
50 58
51void *kmap_atomic(struct page *page, enum km_type type) 59/*
60 * This is the same as kmap_atomic() but can map memory that doesn't
61 * have a struct page associated with it.
62 */
63void *kmap_atomic_pfn(unsigned long pfn)
52{ 64{
53 return kmap_atomic_prot(page, type, kmap_prot); 65 return kmap_atomic_prot_pfn(pfn, kmap_prot);
54} 66}
67EXPORT_SYMBOL_GPL(kmap_atomic_pfn);
55 68
56void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type) 69void __kunmap_atomic(void *kvaddr)
57{ 70{
58 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 71 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
59 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 72
60 73 if (vaddr >= __fix_to_virt(FIX_KMAP_END) &&
61 /* 74 vaddr <= __fix_to_virt(FIX_KMAP_BEGIN)) {
62 * Force other mappings to Oops if they'll try to access this pte 75 int idx, type;
63 * without first remap it. Keeping stale mappings around is a bad idea 76
64 * also, in case the page changes cacheability attributes or becomes 77 type = kmap_atomic_idx();
65 * a protected page in a hypervisor. 78 idx = type + KM_TYPE_NR * smp_processor_id();
66 */ 79
67 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx)) 80#ifdef CONFIG_DEBUG_HIGHMEM
81 WARN_ON_ONCE(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
82#endif
83 /*
84 * Force other mappings to Oops if they'll try to access this
85 * pte without first remap it. Keeping stale mappings around
86 * is a bad idea also, in case the page changes cacheability
87 * attributes or becomes a protected page in a hypervisor.
88 */
68 kpte_clear_flush(kmap_pte-idx, vaddr); 89 kpte_clear_flush(kmap_pte-idx, vaddr);
69 else { 90 kmap_atomic_idx_pop();
91 }
70#ifdef CONFIG_DEBUG_HIGHMEM 92#ifdef CONFIG_DEBUG_HIGHMEM
93 else {
71 BUG_ON(vaddr < PAGE_OFFSET); 94 BUG_ON(vaddr < PAGE_OFFSET);
72 BUG_ON(vaddr >= (unsigned long)high_memory); 95 BUG_ON(vaddr >= (unsigned long)high_memory);
73#endif
74 } 96 }
97#endif
75 98
76 pagefault_enable(); 99 pagefault_enable();
77} 100}
78 101EXPORT_SYMBOL(__kunmap_atomic);
79/*
80 * This is the same as kmap_atomic() but can map memory that doesn't
81 * have a struct page associated with it.
82 */
83void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
84{
85 return kmap_atomic_prot_pfn(pfn, type, kmap_prot);
86}
87EXPORT_SYMBOL_GPL(kmap_atomic_pfn); /* temporarily in use by i915 GEM until vmap */
88 102
89struct page *kmap_atomic_to_page(void *ptr) 103struct page *kmap_atomic_to_page(void *ptr)
90{ 104{
@@ -98,12 +112,6 @@ struct page *kmap_atomic_to_page(void *ptr)
98 pte = kmap_pte - (idx - FIX_KMAP_BEGIN); 112 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
99 return pte_page(*pte); 113 return pte_page(*pte);
100} 114}
101
102EXPORT_SYMBOL(kmap);
103EXPORT_SYMBOL(kunmap);
104EXPORT_SYMBOL(kmap_atomic);
105EXPORT_SYMBOL(kunmap_atomic_notypecheck);
106EXPORT_SYMBOL(kmap_atomic_prot);
107EXPORT_SYMBOL(kmap_atomic_to_page); 115EXPORT_SYMBOL(kmap_atomic_to_page);
108 116
109void __init set_highmem_pages_init(void) 117void __init set_highmem_pages_init(void)
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 5d0a6711c282..0e969f9f401b 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -528,48 +528,6 @@ static void __init pagetable_init(void)
528 permanent_kmaps_init(pgd_base); 528 permanent_kmaps_init(pgd_base);
529} 529}
530 530
531#ifdef CONFIG_ACPI_SLEEP
532/*
533 * ACPI suspend needs this for resume, because things like the intel-agp
534 * driver might have split up a kernel 4MB mapping.
535 */
536char swsusp_pg_dir[PAGE_SIZE]
537 __attribute__ ((aligned(PAGE_SIZE)));
538
539static inline void save_pg_dir(void)
540{
541 copy_page(swsusp_pg_dir, swapper_pg_dir);
542}
543#else /* !CONFIG_ACPI_SLEEP */
544static inline void save_pg_dir(void)
545{
546}
547#endif /* !CONFIG_ACPI_SLEEP */
548
549void zap_low_mappings(bool early)
550{
551 int i;
552
553 /*
554 * Zap initial low-memory mappings.
555 *
556 * Note that "pgd_clear()" doesn't do it for
557 * us, because pgd_clear() is a no-op on i386.
558 */
559 for (i = 0; i < KERNEL_PGD_BOUNDARY; i++) {
560#ifdef CONFIG_X86_PAE
561 set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
562#else
563 set_pgd(swapper_pg_dir+i, __pgd(0));
564#endif
565 }
566
567 if (early)
568 __flush_tlb();
569 else
570 flush_tlb_all();
571}
572
573pteval_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);
574EXPORT_SYMBOL_GPL(__supported_pte_mask); 532EXPORT_SYMBOL_GPL(__supported_pte_mask);
575 533
@@ -882,9 +840,6 @@ void __init mem_init(void)
882 840
883 if (boot_cpu_data.wp_works_ok < 0) 841 if (boot_cpu_data.wp_works_ok < 0)
884 test_wp_bit(); 842 test_wp_bit();
885
886 save_pg_dir();
887 zap_low_mappings(true);
888} 843}
889 844
890#ifdef CONFIG_MEMORY_HOTPLUG 845#ifdef CONFIG_MEMORY_HOTPLUG
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 84346200e783..71a59296af80 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -51,7 +51,6 @@
51#include <asm/numa.h> 51#include <asm/numa.h>
52#include <asm/cacheflush.h> 52#include <asm/cacheflush.h>
53#include <asm/init.h> 53#include <asm/init.h>
54#include <linux/bootmem.h>
55 54
56static int __init parse_direct_gbpages_off(char *arg) 55static int __init parse_direct_gbpages_off(char *arg)
57{ 56{
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
index 72fc70cf6184..7b179b499fa3 100644
--- a/arch/x86/mm/iomap_32.c
+++ b/arch/x86/mm/iomap_32.c
@@ -48,21 +48,20 @@ int iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot)
48} 48}
49EXPORT_SYMBOL_GPL(iomap_create_wc); 49EXPORT_SYMBOL_GPL(iomap_create_wc);
50 50
51void 51void iomap_free(resource_size_t base, unsigned long size)
52iomap_free(resource_size_t base, unsigned long size)
53{ 52{
54 io_free_memtype(base, base + size); 53 io_free_memtype(base, base + size);
55} 54}
56EXPORT_SYMBOL_GPL(iomap_free); 55EXPORT_SYMBOL_GPL(iomap_free);
57 56
58void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) 57void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
59{ 58{
60 enum fixed_addresses idx;
61 unsigned long vaddr; 59 unsigned long vaddr;
60 int idx, type;
62 61
63 pagefault_disable(); 62 pagefault_disable();
64 63
65 debug_kmap_atomic(type); 64 type = kmap_atomic_idx_push();
66 idx = type + KM_TYPE_NR * smp_processor_id(); 65 idx = type + KM_TYPE_NR * smp_processor_id();
67 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 66 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
68 set_pte(kmap_pte - idx, pfn_pte(pfn, prot)); 67 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
@@ -72,10 +71,10 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
72} 71}
73 72
74/* 73/*
75 * Map 'pfn' using fixed map 'type' and protections 'prot' 74 * Map 'pfn' using protections 'prot'
76 */ 75 */
77void __iomem * 76void __iomem *
78iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) 77iomap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
79{ 78{
80 /* 79 /*
81 * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS. 80 * For non-PAT systems, promote PAGE_KERNEL_WC to PAGE_KERNEL_UC_MINUS.
@@ -86,24 +85,34 @@ iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
86 if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC)) 85 if (!pat_enabled && pgprot_val(prot) == pgprot_val(PAGE_KERNEL_WC))
87 prot = PAGE_KERNEL_UC_MINUS; 86 prot = PAGE_KERNEL_UC_MINUS;
88 87
89 return (void __force __iomem *) kmap_atomic_prot_pfn(pfn, type, prot); 88 return (void __force __iomem *) kmap_atomic_prot_pfn(pfn, prot);
90} 89}
91EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn); 90EXPORT_SYMBOL_GPL(iomap_atomic_prot_pfn);
92 91
93void 92void
94iounmap_atomic(void __iomem *kvaddr, enum km_type type) 93iounmap_atomic(void __iomem *kvaddr)
95{ 94{
96 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 95 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
97 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
98 96
99 /* 97 if (vaddr >= __fix_to_virt(FIX_KMAP_END) &&
100 * Force other mappings to Oops if they'll try to access this pte 98 vaddr <= __fix_to_virt(FIX_KMAP_BEGIN)) {
101 * without first remap it. Keeping stale mappings around is a bad idea 99 int idx, type;
102 * also, in case the page changes cacheability attributes or becomes 100
103 * a protected page in a hypervisor. 101 type = kmap_atomic_idx();
104 */ 102 idx = type + KM_TYPE_NR * smp_processor_id();
105 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx)) 103
104#ifdef CONFIG_DEBUG_HIGHMEM
105 WARN_ON_ONCE(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
106#endif
107 /*
108 * Force other mappings to Oops if they'll try to access this
109 * pte without first remap it. Keeping stale mappings around
110 * is a bad idea also, in case the page changes cacheability
111 * attributes or becomes a protected page in a hypervisor.
112 */
106 kpte_clear_flush(kmap_pte-idx, vaddr); 113 kpte_clear_flush(kmap_pte-idx, vaddr);
114 kmap_atomic_idx_pop();
115 }
107 116
108 pagefault_enable(); 117 pagefault_enable();
109} 118}
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 60f498511dd6..7762a517d69d 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -178,11 +178,8 @@ static void * __init early_node_mem(int nodeid, unsigned long start,
178 178
179 /* extend the search scope */ 179 /* extend the search scope */
180 end = max_pfn_mapped << PAGE_SHIFT; 180 end = max_pfn_mapped << PAGE_SHIFT;
181 if (end > (MAX_DMA32_PFN<<PAGE_SHIFT)) 181 start = MAX_DMA_PFN << PAGE_SHIFT;
182 start = MAX_DMA32_PFN<<PAGE_SHIFT; 182 mem = memblock_find_in_range(start, end, size, align);
183 else
184 start = MAX_DMA_PFN<<PAGE_SHIFT;
185 mem = memblock_x86_find_in_range_node(nodeid, start, end, size, align);
186 if (mem != MEMBLOCK_ERROR) 183 if (mem != MEMBLOCK_ERROR)
187 return __va(mem); 184 return __va(mem);
188 185
@@ -267,7 +264,7 @@ static struct bootnode physnodes[MAX_NUMNODES] __initdata;
267static char *cmdline __initdata; 264static char *cmdline __initdata;
268 265
269static int __init setup_physnodes(unsigned long start, unsigned long end, 266static int __init setup_physnodes(unsigned long start, unsigned long end,
270 int acpi, int k8) 267 int acpi, int amd)
271{ 268{
272 int nr_nodes = 0; 269 int nr_nodes = 0;
273 int ret = 0; 270 int ret = 0;
@@ -277,13 +274,13 @@ static int __init setup_physnodes(unsigned long start, unsigned long end,
277 if (acpi) 274 if (acpi)
278 nr_nodes = acpi_get_nodes(physnodes); 275 nr_nodes = acpi_get_nodes(physnodes);
279#endif 276#endif
280#ifdef CONFIG_K8_NUMA 277#ifdef CONFIG_AMD_NUMA
281 if (k8) 278 if (amd)
282 nr_nodes = k8_get_nodes(physnodes); 279 nr_nodes = amd_get_nodes(physnodes);
283#endif 280#endif
284 /* 281 /*
285 * Basic sanity checking on the physical node map: there may be errors 282 * Basic sanity checking on the physical node map: there may be errors
286 * if the SRAT or K8 incorrectly reported the topology or the mem= 283 * if the SRAT or AMD code incorrectly reported the topology or the mem=
287 * kernel parameter is used. 284 * kernel parameter is used.
288 */ 285 */
289 for (i = 0; i < nr_nodes; i++) { 286 for (i = 0; i < nr_nodes; i++) {
@@ -552,7 +549,7 @@ static int __init split_nodes_size_interleave(u64 addr, u64 max_addr, u64 size)
552 * numa=fake command-line option. 549 * numa=fake command-line option.
553 */ 550 */
554static int __init numa_emulation(unsigned long start_pfn, 551static int __init numa_emulation(unsigned long start_pfn,
555 unsigned long last_pfn, int acpi, int k8) 552 unsigned long last_pfn, int acpi, int amd)
556{ 553{
557 u64 addr = start_pfn << PAGE_SHIFT; 554 u64 addr = start_pfn << PAGE_SHIFT;
558 u64 max_addr = last_pfn << PAGE_SHIFT; 555 u64 max_addr = last_pfn << PAGE_SHIFT;
@@ -560,7 +557,7 @@ static int __init numa_emulation(unsigned long start_pfn,
560 int num_nodes; 557 int num_nodes;
561 int i; 558 int i;
562 559
563 num_phys_nodes = setup_physnodes(addr, max_addr, acpi, k8); 560 num_phys_nodes = setup_physnodes(addr, max_addr, acpi, amd);
564 /* 561 /*
565 * If the numa=fake command-line contains a 'M' or 'G', it represents 562 * If the numa=fake command-line contains a 'M' or 'G', it represents
566 * the fixed node size. Otherwise, if it is just a single number N, 563 * the fixed node size. Otherwise, if it is just a single number N,
@@ -605,7 +602,7 @@ static int __init numa_emulation(unsigned long start_pfn,
605#endif /* CONFIG_NUMA_EMU */ 602#endif /* CONFIG_NUMA_EMU */
606 603
607void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn, 604void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn,
608 int acpi, int k8) 605 int acpi, int amd)
609{ 606{
610 int i; 607 int i;
611 608
@@ -613,7 +610,7 @@ void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn,
613 nodes_clear(node_online_map); 610 nodes_clear(node_online_map);
614 611
615#ifdef CONFIG_NUMA_EMU 612#ifdef CONFIG_NUMA_EMU
616 if (cmdline && !numa_emulation(start_pfn, last_pfn, acpi, k8)) 613 if (cmdline && !numa_emulation(start_pfn, last_pfn, acpi, amd))
617 return; 614 return;
618 nodes_clear(node_possible_map); 615 nodes_clear(node_possible_map);
619 nodes_clear(node_online_map); 616 nodes_clear(node_online_map);
@@ -627,8 +624,8 @@ void __init initmem_init(unsigned long start_pfn, unsigned long last_pfn,
627 nodes_clear(node_online_map); 624 nodes_clear(node_online_map);
628#endif 625#endif
629 626
630#ifdef CONFIG_K8_NUMA 627#ifdef CONFIG_AMD_NUMA
631 if (!numa_off && k8 && !k8_scan_nodes()) 628 if (!numa_off && amd && !amd_scan_nodes())
632 return; 629 return;
633 nodes_clear(node_possible_map); 630 nodes_clear(node_possible_map);
634 nodes_clear(node_online_map); 631 nodes_clear(node_online_map);
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 49358481c733..12cdbb17ad18 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -251,7 +251,7 @@ static void __cpuinit calculate_tlb_offset(void)
251 } 251 }
252} 252}
253 253
254static int tlb_cpuhp_notify(struct notifier_block *n, 254static int __cpuinit tlb_cpuhp_notify(struct notifier_block *n,
255 unsigned long action, void *hcpu) 255 unsigned long action, void *hcpu)
256{ 256{
257 switch (action & 0xf) { 257 switch (action & 0xf) {
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index bd1489c3ce09..4e8baad36d37 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -726,6 +726,12 @@ int __init op_nmi_init(struct oprofile_operations *ops)
726 case 0x11: 726 case 0x11:
727 cpu_type = "x86-64/family11h"; 727 cpu_type = "x86-64/family11h";
728 break; 728 break;
729 case 0x12:
730 cpu_type = "x86-64/family12h";
731 break;
732 case 0x14:
733 cpu_type = "x86-64/family14h";
734 break;
729 default: 735 default:
730 return -ENODEV; 736 return -ENODEV;
731 } 737 }
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index 42fb46f83883..a011bcc0f943 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -48,17 +48,24 @@ static unsigned long reset_value[NUM_VIRT_COUNTERS];
48 48
49static u32 ibs_caps; 49static u32 ibs_caps;
50 50
51struct op_ibs_config { 51struct ibs_config {
52 unsigned long op_enabled; 52 unsigned long op_enabled;
53 unsigned long fetch_enabled; 53 unsigned long fetch_enabled;
54 unsigned long max_cnt_fetch; 54 unsigned long max_cnt_fetch;
55 unsigned long max_cnt_op; 55 unsigned long max_cnt_op;
56 unsigned long rand_en; 56 unsigned long rand_en;
57 unsigned long dispatched_ops; 57 unsigned long dispatched_ops;
58 unsigned long branch_target;
58}; 59};
59 60
60static struct op_ibs_config ibs_config; 61struct ibs_state {
61static u64 ibs_op_ctl; 62 u64 ibs_op_ctl;
63 int branch_target;
64 unsigned long sample_size;
65};
66
67static struct ibs_config ibs_config;
68static struct ibs_state ibs_state;
62 69
63/* 70/*
64 * IBS cpuid feature detection 71 * IBS cpuid feature detection
@@ -71,8 +78,16 @@ static u64 ibs_op_ctl;
71 * bit 0 is used to indicate the existence of IBS. 78 * bit 0 is used to indicate the existence of IBS.
72 */ 79 */
73#define IBS_CAPS_AVAIL (1U<<0) 80#define IBS_CAPS_AVAIL (1U<<0)
81#define IBS_CAPS_FETCHSAM (1U<<1)
82#define IBS_CAPS_OPSAM (1U<<2)
74#define IBS_CAPS_RDWROPCNT (1U<<3) 83#define IBS_CAPS_RDWROPCNT (1U<<3)
75#define IBS_CAPS_OPCNT (1U<<4) 84#define IBS_CAPS_OPCNT (1U<<4)
85#define IBS_CAPS_BRNTRGT (1U<<5)
86#define IBS_CAPS_OPCNTEXT (1U<<6)
87
88#define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \
89 | IBS_CAPS_FETCHSAM \
90 | IBS_CAPS_OPSAM)
76 91
77/* 92/*
78 * IBS APIC setup 93 * IBS APIC setup
@@ -99,12 +114,12 @@ static u32 get_ibs_caps(void)
99 /* check IBS cpuid feature flags */ 114 /* check IBS cpuid feature flags */
100 max_level = cpuid_eax(0x80000000); 115 max_level = cpuid_eax(0x80000000);
101 if (max_level < IBS_CPUID_FEATURES) 116 if (max_level < IBS_CPUID_FEATURES)
102 return IBS_CAPS_AVAIL; 117 return IBS_CAPS_DEFAULT;
103 118
104 ibs_caps = cpuid_eax(IBS_CPUID_FEATURES); 119 ibs_caps = cpuid_eax(IBS_CPUID_FEATURES);
105 if (!(ibs_caps & IBS_CAPS_AVAIL)) 120 if (!(ibs_caps & IBS_CAPS_AVAIL))
106 /* cpuid flags not valid */ 121 /* cpuid flags not valid */
107 return IBS_CAPS_AVAIL; 122 return IBS_CAPS_DEFAULT;
108 123
109 return ibs_caps; 124 return ibs_caps;
110} 125}
@@ -197,8 +212,8 @@ op_amd_handle_ibs(struct pt_regs * const regs,
197 rdmsrl(MSR_AMD64_IBSOPCTL, ctl); 212 rdmsrl(MSR_AMD64_IBSOPCTL, ctl);
198 if (ctl & IBS_OP_VAL) { 213 if (ctl & IBS_OP_VAL) {
199 rdmsrl(MSR_AMD64_IBSOPRIP, val); 214 rdmsrl(MSR_AMD64_IBSOPRIP, val);
200 oprofile_write_reserve(&entry, regs, val, 215 oprofile_write_reserve(&entry, regs, val, IBS_OP_CODE,
201 IBS_OP_CODE, IBS_OP_SIZE); 216 ibs_state.sample_size);
202 oprofile_add_data64(&entry, val); 217 oprofile_add_data64(&entry, val);
203 rdmsrl(MSR_AMD64_IBSOPDATA, val); 218 rdmsrl(MSR_AMD64_IBSOPDATA, val);
204 oprofile_add_data64(&entry, val); 219 oprofile_add_data64(&entry, val);
@@ -210,10 +225,14 @@ op_amd_handle_ibs(struct pt_regs * const regs,
210 oprofile_add_data64(&entry, val); 225 oprofile_add_data64(&entry, val);
211 rdmsrl(MSR_AMD64_IBSDCPHYSAD, val); 226 rdmsrl(MSR_AMD64_IBSDCPHYSAD, val);
212 oprofile_add_data64(&entry, val); 227 oprofile_add_data64(&entry, val);
228 if (ibs_state.branch_target) {
229 rdmsrl(MSR_AMD64_IBSBRTARGET, val);
230 oprofile_add_data(&entry, (unsigned long)val);
231 }
213 oprofile_write_commit(&entry); 232 oprofile_write_commit(&entry);
214 233
215 /* reenable the IRQ */ 234 /* reenable the IRQ */
216 ctl = op_amd_randomize_ibs_op(ibs_op_ctl); 235 ctl = op_amd_randomize_ibs_op(ibs_state.ibs_op_ctl);
217 wrmsrl(MSR_AMD64_IBSOPCTL, ctl); 236 wrmsrl(MSR_AMD64_IBSOPCTL, ctl);
218 } 237 }
219 } 238 }
@@ -226,21 +245,32 @@ static inline void op_amd_start_ibs(void)
226 if (!ibs_caps) 245 if (!ibs_caps)
227 return; 246 return;
228 247
248 memset(&ibs_state, 0, sizeof(ibs_state));
249
250 /*
251 * Note: Since the max count settings may out of range we
252 * write back the actual used values so that userland can read
253 * it.
254 */
255
229 if (ibs_config.fetch_enabled) { 256 if (ibs_config.fetch_enabled) {
230 val = (ibs_config.max_cnt_fetch >> 4) & IBS_FETCH_MAX_CNT; 257 val = ibs_config.max_cnt_fetch >> 4;
258 val = min(val, IBS_FETCH_MAX_CNT);
259 ibs_config.max_cnt_fetch = val << 4;
231 val |= ibs_config.rand_en ? IBS_FETCH_RAND_EN : 0; 260 val |= ibs_config.rand_en ? IBS_FETCH_RAND_EN : 0;
232 val |= IBS_FETCH_ENABLE; 261 val |= IBS_FETCH_ENABLE;
233 wrmsrl(MSR_AMD64_IBSFETCHCTL, val); 262 wrmsrl(MSR_AMD64_IBSFETCHCTL, val);
234 } 263 }
235 264
236 if (ibs_config.op_enabled) { 265 if (ibs_config.op_enabled) {
237 ibs_op_ctl = ibs_config.max_cnt_op >> 4; 266 val = ibs_config.max_cnt_op >> 4;
238 if (!(ibs_caps & IBS_CAPS_RDWROPCNT)) { 267 if (!(ibs_caps & IBS_CAPS_RDWROPCNT)) {
239 /* 268 /*
240 * IbsOpCurCnt not supported. See 269 * IbsOpCurCnt not supported. See
241 * op_amd_randomize_ibs_op() for details. 270 * op_amd_randomize_ibs_op() for details.
242 */ 271 */
243 ibs_op_ctl = clamp(ibs_op_ctl, 0x0081ULL, 0xFF80ULL); 272 val = clamp(val, 0x0081ULL, 0xFF80ULL);
273 ibs_config.max_cnt_op = val << 4;
244 } else { 274 } else {
245 /* 275 /*
246 * The start value is randomized with a 276 * The start value is randomized with a
@@ -248,13 +278,24 @@ static inline void op_amd_start_ibs(void)
248 * with the half of the randomized range. Also 278 * with the half of the randomized range. Also
249 * avoid underflows. 279 * avoid underflows.
250 */ 280 */
251 ibs_op_ctl = min(ibs_op_ctl + IBS_RANDOM_MAXCNT_OFFSET, 281 val += IBS_RANDOM_MAXCNT_OFFSET;
252 IBS_OP_MAX_CNT); 282 if (ibs_caps & IBS_CAPS_OPCNTEXT)
283 val = min(val, IBS_OP_MAX_CNT_EXT);
284 else
285 val = min(val, IBS_OP_MAX_CNT);
286 ibs_config.max_cnt_op =
287 (val - IBS_RANDOM_MAXCNT_OFFSET) << 4;
288 }
289 val = ((val & ~IBS_OP_MAX_CNT) << 4) | (val & IBS_OP_MAX_CNT);
290 val |= ibs_config.dispatched_ops ? IBS_OP_CNT_CTL : 0;
291 val |= IBS_OP_ENABLE;
292 ibs_state.ibs_op_ctl = val;
293 ibs_state.sample_size = IBS_OP_SIZE;
294 if (ibs_config.branch_target) {
295 ibs_state.branch_target = 1;
296 ibs_state.sample_size++;
253 } 297 }
254 if (ibs_caps & IBS_CAPS_OPCNT && ibs_config.dispatched_ops) 298 val = op_amd_randomize_ibs_op(ibs_state.ibs_op_ctl);
255 ibs_op_ctl |= IBS_OP_CNT_CTL;
256 ibs_op_ctl |= IBS_OP_ENABLE;
257 val = op_amd_randomize_ibs_op(ibs_op_ctl);
258 wrmsrl(MSR_AMD64_IBSOPCTL, val); 299 wrmsrl(MSR_AMD64_IBSOPCTL, val);
259 } 300 }
260} 301}
@@ -281,29 +322,25 @@ static inline int eilvt_is_available(int offset)
281 322
282static inline int ibs_eilvt_valid(void) 323static inline int ibs_eilvt_valid(void)
283{ 324{
284 u64 val;
285 int offset; 325 int offset;
326 u64 val;
286 327
287 rdmsrl(MSR_AMD64_IBSCTL, val); 328 rdmsrl(MSR_AMD64_IBSCTL, val);
329 offset = val & IBSCTL_LVT_OFFSET_MASK;
330
288 if (!(val & IBSCTL_LVT_OFFSET_VALID)) { 331 if (!(val & IBSCTL_LVT_OFFSET_VALID)) {
289 pr_err(FW_BUG "cpu %d, invalid IBS " 332 pr_err(FW_BUG "cpu %d, invalid IBS interrupt offset %d (MSR%08X=0x%016llx)\n",
290 "interrupt offset %d (MSR%08X=0x%016llx)", 333 smp_processor_id(), offset, MSR_AMD64_IBSCTL, val);
291 smp_processor_id(), offset,
292 MSR_AMD64_IBSCTL, val);
293 return 0; 334 return 0;
294 } 335 }
295 336
296 offset = val & IBSCTL_LVT_OFFSET_MASK; 337 if (!eilvt_is_available(offset)) {
297 338 pr_err(FW_BUG "cpu %d, IBS interrupt offset %d not available (MSR%08X=0x%016llx)\n",
298 if (eilvt_is_available(offset)) 339 smp_processor_id(), offset, MSR_AMD64_IBSCTL, val);
299 return !0; 340 return 0;
300 341 }
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 342
306 return 0; 343 return 1;
307} 344}
308 345
309static inline int get_ibs_offset(void) 346static inline int get_ibs_offset(void)
@@ -630,28 +667,33 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root)
630 /* model specific files */ 667 /* model specific files */
631 668
632 /* setup some reasonable defaults */ 669 /* setup some reasonable defaults */
670 memset(&ibs_config, 0, sizeof(ibs_config));
633 ibs_config.max_cnt_fetch = 250000; 671 ibs_config.max_cnt_fetch = 250000;
634 ibs_config.fetch_enabled = 0;
635 ibs_config.max_cnt_op = 250000; 672 ibs_config.max_cnt_op = 250000;
636 ibs_config.op_enabled = 0; 673
637 ibs_config.dispatched_ops = 0; 674 if (ibs_caps & IBS_CAPS_FETCHSAM) {
638 675 dir = oprofilefs_mkdir(sb, root, "ibs_fetch");
639 dir = oprofilefs_mkdir(sb, root, "ibs_fetch"); 676 oprofilefs_create_ulong(sb, dir, "enable",
640 oprofilefs_create_ulong(sb, dir, "enable", 677 &ibs_config.fetch_enabled);
641 &ibs_config.fetch_enabled); 678 oprofilefs_create_ulong(sb, dir, "max_count",
642 oprofilefs_create_ulong(sb, dir, "max_count", 679 &ibs_config.max_cnt_fetch);
643 &ibs_config.max_cnt_fetch); 680 oprofilefs_create_ulong(sb, dir, "rand_enable",
644 oprofilefs_create_ulong(sb, dir, "rand_enable", 681 &ibs_config.rand_en);
645 &ibs_config.rand_en); 682 }
646 683
647 dir = oprofilefs_mkdir(sb, root, "ibs_op"); 684 if (ibs_caps & IBS_CAPS_OPSAM) {
648 oprofilefs_create_ulong(sb, dir, "enable", 685 dir = oprofilefs_mkdir(sb, root, "ibs_op");
649 &ibs_config.op_enabled); 686 oprofilefs_create_ulong(sb, dir, "enable",
650 oprofilefs_create_ulong(sb, dir, "max_count", 687 &ibs_config.op_enabled);
651 &ibs_config.max_cnt_op); 688 oprofilefs_create_ulong(sb, dir, "max_count",
652 if (ibs_caps & IBS_CAPS_OPCNT) 689 &ibs_config.max_cnt_op);
653 oprofilefs_create_ulong(sb, dir, "dispatched_ops", 690 if (ibs_caps & IBS_CAPS_OPCNT)
654 &ibs_config.dispatched_ops); 691 oprofilefs_create_ulong(sb, dir, "dispatched_ops",
692 &ibs_config.dispatched_ops);
693 if (ibs_caps & IBS_CAPS_BRNTRGT)
694 oprofilefs_create_ulong(sb, dir, "branch_target",
695 &ibs_config.branch_target);
696 }
655 697
656 return 0; 698 return 0;
657} 699}
diff --git a/arch/x86/pci/Makefile b/arch/x86/pci/Makefile
index a0207a7fdf39..effd96e33f16 100644
--- a/arch/x86/pci/Makefile
+++ b/arch/x86/pci/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_PCI_BIOS) += pcbios.o
4obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_$(BITS).o direct.o mmconfig-shared.o 4obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_$(BITS).o direct.o mmconfig-shared.o
5obj-$(CONFIG_PCI_DIRECT) += direct.o 5obj-$(CONFIG_PCI_DIRECT) += direct.o
6obj-$(CONFIG_PCI_OLPC) += olpc.o 6obj-$(CONFIG_PCI_OLPC) += olpc.o
7obj-$(CONFIG_PCI_XEN) += xen.o
7 8
8obj-y += fixup.o 9obj-y += fixup.o
9obj-$(CONFIG_ACPI) += acpi.o 10obj-$(CONFIG_ACPI) += acpi.o
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 15466c096ba5..0972315c3860 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -138,7 +138,6 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
138 struct acpi_resource_address64 addr; 138 struct acpi_resource_address64 addr;
139 acpi_status status; 139 acpi_status status;
140 unsigned long flags; 140 unsigned long flags;
141 struct resource *root, *conflict;
142 u64 start, end; 141 u64 start, end;
143 142
144 status = resource_to_addr(acpi_res, &addr); 143 status = resource_to_addr(acpi_res, &addr);
@@ -146,12 +145,10 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
146 return AE_OK; 145 return AE_OK;
147 146
148 if (addr.resource_type == ACPI_MEMORY_RANGE) { 147 if (addr.resource_type == ACPI_MEMORY_RANGE) {
149 root = &iomem_resource;
150 flags = IORESOURCE_MEM; 148 flags = IORESOURCE_MEM;
151 if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY) 149 if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
152 flags |= IORESOURCE_PREFETCH; 150 flags |= IORESOURCE_PREFETCH;
153 } else if (addr.resource_type == ACPI_IO_RANGE) { 151 } else if (addr.resource_type == ACPI_IO_RANGE) {
154 root = &ioport_resource;
155 flags = IORESOURCE_IO; 152 flags = IORESOURCE_IO;
156 } else 153 } else
157 return AE_OK; 154 return AE_OK;
@@ -172,25 +169,90 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
172 return AE_OK; 169 return AE_OK;
173 } 170 }
174 171
175 conflict = insert_resource_conflict(root, res); 172 info->res_num++;
176 if (conflict) { 173 if (addr.translation_offset)
177 dev_err(&info->bridge->dev, 174 dev_info(&info->bridge->dev, "host bridge window %pR "
178 "address space collision: host bridge window %pR " 175 "(PCI address [%#llx-%#llx])\n",
179 "conflicts with %s %pR\n", 176 res, res->start - addr.translation_offset,
180 res, conflict->name, conflict); 177 res->end - addr.translation_offset);
181 } else { 178 else
182 pci_bus_add_resource(info->bus, res, 0); 179 dev_info(&info->bridge->dev, "host bridge window %pR\n", res);
183 info->res_num++; 180
184 if (addr.translation_offset) 181 return AE_OK;
185 dev_info(&info->bridge->dev, "host bridge window %pR " 182}
186 "(PCI address [%#llx-%#llx])\n", 183
187 res, res->start - addr.translation_offset, 184static bool resource_contains(struct resource *res, resource_size_t point)
188 res->end - addr.translation_offset); 185{
186 if (res->start <= point && point <= res->end)
187 return true;
188 return false;
189}
190
191static void coalesce_windows(struct pci_root_info *info, int type)
192{
193 int i, j;
194 struct resource *res1, *res2;
195
196 for (i = 0; i < info->res_num; i++) {
197 res1 = &info->res[i];
198 if (!(res1->flags & type))
199 continue;
200
201 for (j = i + 1; j < info->res_num; j++) {
202 res2 = &info->res[j];
203 if (!(res2->flags & type))
204 continue;
205
206 /*
207 * I don't like throwing away windows because then
208 * our resources no longer match the ACPI _CRS, but
209 * the kernel resource tree doesn't allow overlaps.
210 */
211 if (resource_contains(res1, res2->start) ||
212 resource_contains(res1, res2->end) ||
213 resource_contains(res2, res1->start) ||
214 resource_contains(res2, res1->end)) {
215 res1->start = min(res1->start, res2->start);
216 res1->end = max(res1->end, res2->end);
217 dev_info(&info->bridge->dev,
218 "host bridge window expanded to %pR; %pR ignored\n",
219 res1, res2);
220 res2->flags = 0;
221 }
222 }
223 }
224}
225
226static void add_resources(struct pci_root_info *info)
227{
228 int i;
229 struct resource *res, *root, *conflict;
230
231 if (!pci_use_crs)
232 return;
233
234 coalesce_windows(info, IORESOURCE_MEM);
235 coalesce_windows(info, IORESOURCE_IO);
236
237 for (i = 0; i < info->res_num; i++) {
238 res = &info->res[i];
239
240 if (res->flags & IORESOURCE_MEM)
241 root = &iomem_resource;
242 else if (res->flags & IORESOURCE_IO)
243 root = &ioport_resource;
189 else 244 else
190 dev_info(&info->bridge->dev, 245 continue;
191 "host bridge window %pR\n", res); 246
247 conflict = insert_resource_conflict(root, res);
248 if (conflict)
249 dev_err(&info->bridge->dev,
250 "address space collision: host bridge window %pR "
251 "conflicts with %s %pR\n",
252 res, conflict->name, conflict);
253 else
254 pci_bus_add_resource(info->bus, res, 0);
192 } 255 }
193 return AE_OK;
194} 256}
195 257
196static void 258static void
@@ -224,6 +286,7 @@ get_current_resources(struct acpi_device *device, int busnum,
224 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, 286 acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource,
225 &info); 287 &info);
226 288
289 add_resources(&info);
227 return; 290 return;
228 291
229name_alloc_fail: 292name_alloc_fail:
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index a0772af64efb..f7c8a399978c 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -421,16 +421,10 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
421 421
422 return bus; 422 return bus;
423} 423}
424 424void __init pcibios_set_cache_line_size(void)
425int __init pcibios_init(void)
426{ 425{
427 struct cpuinfo_x86 *c = &boot_cpu_data; 426 struct cpuinfo_x86 *c = &boot_cpu_data;
428 427
429 if (!raw_pci_ops) {
430 printk(KERN_WARNING "PCI: System does not support PCI\n");
431 return 0;
432 }
433
434 /* 428 /*
435 * Set PCI cacheline size to that of the CPU if the CPU has reported it. 429 * Set PCI cacheline size to that of the CPU if the CPU has reported it.
436 * (For older CPUs that don't support cpuid, we se it to 32 bytes 430 * (For older CPUs that don't support cpuid, we se it to 32 bytes
@@ -445,7 +439,16 @@ int __init pcibios_init(void)
445 pci_dfl_cache_line_size = 32 >> 2; 439 pci_dfl_cache_line_size = 32 >> 2;
446 printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n"); 440 printk(KERN_DEBUG "PCI: Unknown cacheline size. Setting to 32 bytes\n");
447 } 441 }
442}
443
444int __init pcibios_init(void)
445{
446 if (!raw_pci_ops) {
447 printk(KERN_WARNING "PCI: System does not support PCI\n");
448 return 0;
449 }
448 450
451 pcibios_set_cache_line_size();
449 pcibios_resource_survey(); 452 pcibios_resource_survey();
450 453
451 if (pci_bf_sort >= pci_force_bf) 454 if (pci_bf_sort >= pci_force_bf)
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 55253095be84..c4bb261c106e 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -65,16 +65,21 @@ pcibios_align_resource(void *data, const struct resource *res,
65 resource_size_t size, resource_size_t align) 65 resource_size_t size, resource_size_t align)
66{ 66{
67 struct pci_dev *dev = data; 67 struct pci_dev *dev = data;
68 resource_size_t start = res->start; 68 resource_size_t start = round_down(res->end - size + 1, align);
69 69
70 if (res->flags & IORESOURCE_IO) { 70 if (res->flags & IORESOURCE_IO) {
71 if (skip_isa_ioresource_align(dev)) 71
72 return start; 72 /*
73 if (start & 0x300) 73 * If we're avoiding ISA aliases, the largest contiguous I/O
74 start = (start + 0x3ff) & ~0x3ff; 74 * port space is 256 bytes. Clearing bits 9 and 10 preserves
75 * all 256-byte and smaller alignments, so the result will
76 * still be correctly aligned.
77 */
78 if (!skip_isa_ioresource_align(dev))
79 start &= ~0x300;
75 } else if (res->flags & IORESOURCE_MEM) { 80 } else if (res->flags & IORESOURCE_MEM) {
76 if (start < BIOS_END) 81 if (start < BIOS_END)
77 start = BIOS_END; 82 start = res->end; /* fail; no space */
78 } 83 }
79 return start; 84 return start;
80} 85}
@@ -311,6 +316,8 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
311 */ 316 */
312 prot |= _PAGE_CACHE_UC_MINUS; 317 prot |= _PAGE_CACHE_UC_MINUS;
313 318
319 prot |= _PAGE_IOMAP; /* creating a mapping for IO */
320
314 vma->vm_page_prot = __pgprot(prot); 321 vma->vm_page_prot = __pgprot(prot);
315 322
316 if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, 323 if (io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
index f547ee05f715..9f9bfb705cf9 100644
--- a/arch/x86/pci/irq.c
+++ b/arch/x86/pci/irq.c
@@ -584,27 +584,28 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route
584 case PCI_DEVICE_ID_INTEL_ICH9_3: 584 case PCI_DEVICE_ID_INTEL_ICH9_3:
585 case PCI_DEVICE_ID_INTEL_ICH9_4: 585 case PCI_DEVICE_ID_INTEL_ICH9_4:
586 case PCI_DEVICE_ID_INTEL_ICH9_5: 586 case PCI_DEVICE_ID_INTEL_ICH9_5:
587 case PCI_DEVICE_ID_INTEL_TOLAPAI_0: 587 case PCI_DEVICE_ID_INTEL_EP80579_0:
588 case PCI_DEVICE_ID_INTEL_ICH10_0: 588 case PCI_DEVICE_ID_INTEL_ICH10_0:
589 case PCI_DEVICE_ID_INTEL_ICH10_1: 589 case PCI_DEVICE_ID_INTEL_ICH10_1:
590 case PCI_DEVICE_ID_INTEL_ICH10_2: 590 case PCI_DEVICE_ID_INTEL_ICH10_2:
591 case PCI_DEVICE_ID_INTEL_ICH10_3: 591 case PCI_DEVICE_ID_INTEL_ICH10_3:
592 case PCI_DEVICE_ID_INTEL_PATSBURG_LPC:
592 r->name = "PIIX/ICH"; 593 r->name = "PIIX/ICH";
593 r->get = pirq_piix_get; 594 r->get = pirq_piix_get;
594 r->set = pirq_piix_set; 595 r->set = pirq_piix_set;
595 return 1; 596 return 1;
596 } 597 }
597 598
598 if ((device >= PCI_DEVICE_ID_INTEL_PCH_LPC_MIN) && 599 if ((device >= PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MIN) &&
599 (device <= PCI_DEVICE_ID_INTEL_PCH_LPC_MAX)) { 600 (device <= PCI_DEVICE_ID_INTEL_5_3400_SERIES_LPC_MAX)) {
600 r->name = "PIIX/ICH"; 601 r->name = "PIIX/ICH";
601 r->get = pirq_piix_get; 602 r->get = pirq_piix_get;
602 r->set = pirq_piix_set; 603 r->set = pirq_piix_set;
603 return 1; 604 return 1;
604 } 605 }
605 606
606 if ((device >= PCI_DEVICE_ID_INTEL_CPT_LPC_MIN) && 607 if ((device >= PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN) &&
607 (device <= PCI_DEVICE_ID_INTEL_CPT_LPC_MAX)) { 608 (device <= PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX)) {
608 r->name = "PIIX/ICH"; 609 r->name = "PIIX/ICH";
609 r->get = pirq_piix_get; 610 r->get = pirq_piix_get;
610 r->set = pirq_piix_set; 611 r->set = pirq_piix_set;
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c
index a918553ebc75..e282886616a0 100644
--- a/arch/x86/pci/mmconfig-shared.c
+++ b/arch/x86/pci/mmconfig-shared.c
@@ -65,7 +65,6 @@ static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
65 int end, u64 addr) 65 int end, u64 addr)
66{ 66{
67 struct pci_mmcfg_region *new; 67 struct pci_mmcfg_region *new;
68 int num_buses;
69 struct resource *res; 68 struct resource *res;
70 69
71 if (addr == 0) 70 if (addr == 0)
@@ -82,10 +81,9 @@ static __init struct pci_mmcfg_region *pci_mmconfig_add(int segment, int start,
82 81
83 list_add_sorted(new); 82 list_add_sorted(new);
84 83
85 num_buses = end - start + 1;
86 res = &new->res; 84 res = &new->res;
87 res->start = addr + PCI_MMCFG_BUS_OFFSET(start); 85 res->start = addr + PCI_MMCFG_BUS_OFFSET(start);
88 res->end = addr + PCI_MMCFG_BUS_OFFSET(num_buses) - 1; 86 res->end = addr + PCI_MMCFG_BUS_OFFSET(end + 1) - 1;
89 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 87 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
90 snprintf(new->name, PCI_MMCFG_RESOURCE_NAME_LEN, 88 snprintf(new->name, PCI_MMCFG_RESOURCE_NAME_LEN,
91 "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end); 89 "PCI MMCONFIG %04x [bus %02x-%02x]", segment, start, end);
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
new file mode 100644
index 000000000000..d7b5109f7a9c
--- /dev/null
+++ b/arch/x86/pci/xen.c
@@ -0,0 +1,416 @@
1/*
2 * Xen PCI Frontend Stub - puts some "dummy" functions in to the Linux
3 * x86 PCI core to support the Xen PCI Frontend
4 *
5 * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
6 */
7#include <linux/module.h>
8#include <linux/init.h>
9#include <linux/pci.h>
10#include <linux/acpi.h>
11
12#include <linux/io.h>
13#include <asm/io_apic.h>
14#include <asm/pci_x86.h>
15
16#include <asm/xen/hypervisor.h>
17
18#include <xen/features.h>
19#include <xen/events.h>
20#include <asm/xen/pci.h>
21
22#ifdef CONFIG_ACPI
23static int xen_hvm_register_pirq(u32 gsi, int triggering)
24{
25 int rc, irq;
26 struct physdev_map_pirq map_irq;
27 int shareable = 0;
28 char *name;
29
30 if (!xen_hvm_domain())
31 return -1;
32
33 map_irq.domid = DOMID_SELF;
34 map_irq.type = MAP_PIRQ_TYPE_GSI;
35 map_irq.index = gsi;
36 map_irq.pirq = -1;
37
38 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
39 if (rc) {
40 printk(KERN_WARNING "xen map irq failed %d\n", rc);
41 return -1;
42 }
43
44 if (triggering == ACPI_EDGE_SENSITIVE) {
45 shareable = 0;
46 name = "ioapic-edge";
47 } else {
48 shareable = 1;
49 name = "ioapic-level";
50 }
51
52 irq = xen_map_pirq_gsi(map_irq.pirq, gsi, shareable, name);
53
54 printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
55
56 return irq;
57}
58
59static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
60 int trigger, int polarity)
61{
62 return xen_hvm_register_pirq(gsi, trigger);
63}
64#endif
65
66#if defined(CONFIG_PCI_MSI)
67#include <linux/msi.h>
68#include <asm/msidef.h>
69
70struct xen_pci_frontend_ops *xen_pci_frontend;
71EXPORT_SYMBOL_GPL(xen_pci_frontend);
72
73static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
74 struct msi_msg *msg)
75{
76 /* We set vector == 0 to tell the hypervisor we don't care about it,
77 * but we want a pirq setup instead.
78 * We use the dest_id field to pass the pirq that we want. */
79 msg->address_hi = MSI_ADDR_BASE_HI | MSI_ADDR_EXT_DEST_ID(pirq);
80 msg->address_lo =
81 MSI_ADDR_BASE_LO |
82 MSI_ADDR_DEST_MODE_PHYSICAL |
83 MSI_ADDR_REDIRECTION_CPU |
84 MSI_ADDR_DEST_ID(pirq);
85
86 msg->data =
87 MSI_DATA_TRIGGER_EDGE |
88 MSI_DATA_LEVEL_ASSERT |
89 /* delivery mode reserved */
90 (3 << 8) |
91 MSI_DATA_VECTOR(0);
92}
93
94static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
95{
96 int irq, pirq, ret = 0;
97 struct msi_desc *msidesc;
98 struct msi_msg msg;
99
100 list_for_each_entry(msidesc, &dev->msi_list, list) {
101 xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
102 "msi-x" : "msi", &irq, &pirq);
103 if (irq < 0 || pirq < 0)
104 goto error;
105 printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq);
106 xen_msi_compose_msg(dev, pirq, &msg);
107 ret = set_irq_msi(irq, msidesc);
108 if (ret < 0)
109 goto error_while;
110 write_msi_msg(irq, &msg);
111 }
112 return 0;
113
114error_while:
115 unbind_from_irqhandler(irq, NULL);
116error:
117 if (ret == -ENODEV)
118 dev_err(&dev->dev, "Xen PCI frontend has not registered" \
119 " MSI/MSI-X support!\n");
120
121 return ret;
122}
123
124/*
125 * For MSI interrupts we have to use drivers/xen/event.s functions to
126 * allocate an irq_desc and setup the right */
127
128
129static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
130{
131 int irq, ret, i;
132 struct msi_desc *msidesc;
133 int *v;
134
135 v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
136 if (!v)
137 return -ENOMEM;
138
139 if (type == PCI_CAP_ID_MSIX)
140 ret = xen_pci_frontend_enable_msix(dev, &v, nvec);
141 else
142 ret = xen_pci_frontend_enable_msi(dev, &v);
143 if (ret)
144 goto error;
145 i = 0;
146 list_for_each_entry(msidesc, &dev->msi_list, list) {
147 irq = xen_allocate_pirq(v[i], 0, /* not sharable */
148 (type == PCI_CAP_ID_MSIX) ?
149 "pcifront-msi-x" : "pcifront-msi");
150 if (irq < 0) {
151 ret = -1;
152 goto free;
153 }
154
155 ret = set_irq_msi(irq, msidesc);
156 if (ret)
157 goto error_while;
158 i++;
159 }
160 kfree(v);
161 return 0;
162
163error_while:
164 unbind_from_irqhandler(irq, NULL);
165error:
166 if (ret == -ENODEV)
167 dev_err(&dev->dev, "Xen PCI frontend has not registered" \
168 " MSI/MSI-X support!\n");
169free:
170 kfree(v);
171 return ret;
172}
173
174static void xen_teardown_msi_irqs(struct pci_dev *dev)
175{
176 struct msi_desc *msidesc;
177
178 msidesc = list_entry(dev->msi_list.next, struct msi_desc, list);
179 if (msidesc->msi_attrib.is_msix)
180 xen_pci_frontend_disable_msix(dev);
181 else
182 xen_pci_frontend_disable_msi(dev);
183}
184
185static void xen_teardown_msi_irq(unsigned int irq)
186{
187 xen_destroy_irq(irq);
188}
189
190static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
191{
192 int irq, ret;
193 struct msi_desc *msidesc;
194
195 list_for_each_entry(msidesc, &dev->msi_list, list) {
196 irq = xen_create_msi_irq(dev, msidesc, type);
197 if (irq < 0)
198 return -1;
199
200 ret = set_irq_msi(irq, msidesc);
201 if (ret)
202 goto error;
203 }
204 return 0;
205
206error:
207 xen_destroy_irq(irq);
208 return ret;
209}
210#endif
211
212static int xen_pcifront_enable_irq(struct pci_dev *dev)
213{
214 int rc;
215 int share = 1;
216
217 dev_info(&dev->dev, "Xen PCI enabling IRQ: %d\n", dev->irq);
218
219 if (dev->irq < 0)
220 return -EINVAL;
221
222 if (dev->irq < NR_IRQS_LEGACY)
223 share = 0;
224
225 rc = xen_allocate_pirq(dev->irq, share, "pcifront");
226 if (rc < 0) {
227 dev_warn(&dev->dev, "Xen PCI IRQ: %d, failed to register:%d\n",
228 dev->irq, rc);
229 return rc;
230 }
231 return 0;
232}
233
234int __init pci_xen_init(void)
235{
236 if (!xen_pv_domain() || xen_initial_domain())
237 return -ENODEV;
238
239 printk(KERN_INFO "PCI: setting up Xen PCI frontend stub\n");
240
241 pcibios_set_cache_line_size();
242
243 pcibios_enable_irq = xen_pcifront_enable_irq;
244 pcibios_disable_irq = NULL;
245
246#ifdef CONFIG_ACPI
247 /* Keep ACPI out of the picture */
248 acpi_noirq = 1;
249#endif
250
251#ifdef CONFIG_PCI_MSI
252 x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
253 x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
254 x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
255#endif
256 return 0;
257}
258
259int __init pci_xen_hvm_init(void)
260{
261 if (!xen_feature(XENFEAT_hvm_pirqs))
262 return 0;
263
264#ifdef CONFIG_ACPI
265 /*
266 * We don't want to change the actual ACPI delivery model,
267 * just how GSIs get registered.
268 */
269 __acpi_register_gsi = acpi_register_gsi_xen_hvm;
270#endif
271
272#ifdef CONFIG_PCI_MSI
273 x86_msi.setup_msi_irqs = xen_hvm_setup_msi_irqs;
274 x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
275#endif
276 return 0;
277}
278
279#ifdef CONFIG_XEN_DOM0
280static int xen_register_pirq(u32 gsi, int triggering)
281{
282 int rc, irq;
283 struct physdev_map_pirq map_irq;
284 int shareable = 0;
285 char *name;
286
287 if (!xen_pv_domain())
288 return -1;
289
290 if (triggering == ACPI_EDGE_SENSITIVE) {
291 shareable = 0;
292 name = "ioapic-edge";
293 } else {
294 shareable = 1;
295 name = "ioapic-level";
296 }
297
298 irq = xen_allocate_pirq(gsi, shareable, name);
299
300 printk(KERN_DEBUG "xen: --> irq=%d\n", irq);
301
302 if (irq < 0)
303 goto out;
304
305 map_irq.domid = DOMID_SELF;
306 map_irq.type = MAP_PIRQ_TYPE_GSI;
307 map_irq.index = gsi;
308 map_irq.pirq = irq;
309
310 rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
311 if (rc) {
312 printk(KERN_WARNING "xen map irq failed %d\n", rc);
313 return -1;
314 }
315
316out:
317 return irq;
318}
319
320static int xen_register_gsi(u32 gsi, int triggering, int polarity)
321{
322 int rc, irq;
323 struct physdev_setup_gsi setup_gsi;
324
325 if (!xen_pv_domain())
326 return -1;
327
328 printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
329 gsi, triggering, polarity);
330
331 irq = xen_register_pirq(gsi, triggering);
332
333 setup_gsi.gsi = gsi;
334 setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
335 setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
336
337 rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi);
338 if (rc == -EEXIST)
339 printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
340 else if (rc) {
341 printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n",
342 gsi, rc);
343 }
344
345 return irq;
346}
347
348static __init void xen_setup_acpi_sci(void)
349{
350 int rc;
351 int trigger, polarity;
352 int gsi = acpi_sci_override_gsi;
353
354 if (!gsi)
355 return;
356
357 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
358 if (rc) {
359 printk(KERN_WARNING "xen: acpi_get_override_irq failed for acpi"
360 " sci, rc=%d\n", rc);
361 return;
362 }
363 trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
364 polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
365
366 printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d "
367 "polarity=%d\n", gsi, trigger, polarity);
368
369 gsi = xen_register_gsi(gsi, trigger, polarity);
370 printk(KERN_INFO "xen: acpi sci %d\n", gsi);
371
372 return;
373}
374
375static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
376 int trigger, int polarity)
377{
378 return xen_register_gsi(gsi, trigger, polarity);
379}
380
381static int __init pci_xen_initial_domain(void)
382{
383#ifdef CONFIG_PCI_MSI
384 x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
385 x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
386#endif
387 xen_setup_acpi_sci();
388 __acpi_register_gsi = acpi_register_gsi_xen;
389
390 return 0;
391}
392
393void __init xen_setup_pirqs(void)
394{
395 int irq;
396
397 pci_xen_initial_domain();
398
399 if (0 == nr_ioapics) {
400 for (irq = 0; irq < NR_IRQS_LEGACY; irq++)
401 xen_allocate_pirq(irq, 0, "xt-pic");
402 return;
403 }
404
405 /* Pre-allocate legacy irqs */
406 for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
407 int trigger, polarity;
408
409 if (acpi_get_override_irq(irq, &trigger, &polarity) == -1)
410 continue;
411
412 xen_register_pirq(irq,
413 trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE);
414 }
415}
416#endif
diff --git a/arch/x86/platform/Makefile b/arch/x86/platform/Makefile
new file mode 100644
index 000000000000..7bf70b812fa2
--- /dev/null
+++ b/arch/x86/platform/Makefile
@@ -0,0 +1,8 @@
1# Platform specific code goes here
2obj-y += efi/
3obj-y += mrst/
4obj-y += olpc/
5obj-y += scx200/
6obj-y += sfi/
7obj-y += visws/
8obj-y += uv/
diff --git a/arch/x86/platform/efi/Makefile b/arch/x86/platform/efi/Makefile
new file mode 100644
index 000000000000..73b8be0f3675
--- /dev/null
+++ b/arch/x86/platform/efi/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o
diff --git a/arch/x86/kernel/efi.c b/arch/x86/platform/efi/efi.c
index 0fe27d7c6258..0fe27d7c6258 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/platform/efi/efi.c
diff --git a/arch/x86/kernel/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 5cab48ee61a4..5cab48ee61a4 100644
--- a/arch/x86/kernel/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
diff --git a/arch/x86/kernel/efi_64.c b/arch/x86/platform/efi/efi_64.c
index ac0621a7ac3d..ac0621a7ac3d 100644
--- a/arch/x86/kernel/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
diff --git a/arch/x86/kernel/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
index fbe66e626c09..fbe66e626c09 100644
--- a/arch/x86/kernel/efi_stub_32.S
+++ b/arch/x86/platform/efi/efi_stub_32.S
diff --git a/arch/x86/kernel/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
index 4c07ccab8146..4c07ccab8146 100644
--- a/arch/x86/kernel/efi_stub_64.S
+++ b/arch/x86/platform/efi/efi_stub_64.S
diff --git a/arch/x86/platform/mrst/Makefile b/arch/x86/platform/mrst/Makefile
new file mode 100644
index 000000000000..efbbc552fa95
--- /dev/null
+++ b/arch/x86/platform/mrst/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_X86_MRST) += mrst.o
diff --git a/arch/x86/kernel/mrst.c b/arch/x86/platform/mrst/mrst.c
index 79ae68154e87..79ae68154e87 100644
--- a/arch/x86/kernel/mrst.c
+++ b/arch/x86/platform/mrst/mrst.c
diff --git a/arch/x86/platform/olpc/Makefile b/arch/x86/platform/olpc/Makefile
new file mode 100644
index 000000000000..c31b8fcb5a86
--- /dev/null
+++ b/arch/x86/platform/olpc/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_OLPC) += olpc.o
2obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o
3obj-$(CONFIG_OLPC_OPENFIRMWARE) += olpc_ofw.o
diff --git a/arch/x86/kernel/olpc-xo1.c b/arch/x86/platform/olpc/olpc-xo1.c
index f5442c03abc3..f5442c03abc3 100644
--- a/arch/x86/kernel/olpc-xo1.c
+++ b/arch/x86/platform/olpc/olpc-xo1.c
diff --git a/arch/x86/kernel/olpc.c b/arch/x86/platform/olpc/olpc.c
index edaf3fe8dc5e..edaf3fe8dc5e 100644
--- a/arch/x86/kernel/olpc.c
+++ b/arch/x86/platform/olpc/olpc.c
diff --git a/arch/x86/kernel/olpc_ofw.c b/arch/x86/platform/olpc/olpc_ofw.c
index 787320464379..787320464379 100644
--- a/arch/x86/kernel/olpc_ofw.c
+++ b/arch/x86/platform/olpc/olpc_ofw.c
diff --git a/arch/x86/platform/scx200/Makefile b/arch/x86/platform/scx200/Makefile
new file mode 100644
index 000000000000..762b4c7f4314
--- /dev/null
+++ b/arch/x86/platform/scx200/Makefile
@@ -0,0 +1,2 @@
1obj-$(CONFIG_SCx200) += scx200.o
2scx200-y += scx200_32.o
diff --git a/arch/x86/kernel/scx200_32.c b/arch/x86/platform/scx200/scx200_32.c
index 7e004acbe526..7e004acbe526 100644
--- a/arch/x86/kernel/scx200_32.c
+++ b/arch/x86/platform/scx200/scx200_32.c
diff --git a/arch/x86/platform/sfi/Makefile b/arch/x86/platform/sfi/Makefile
new file mode 100644
index 000000000000..cc5db1168a5e
--- /dev/null
+++ b/arch/x86/platform/sfi/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_SFI) += sfi.o
diff --git a/arch/x86/kernel/sfi.c b/arch/x86/platform/sfi/sfi.c
index dd4c281ffe57..dd4c281ffe57 100644
--- a/arch/x86/kernel/sfi.c
+++ b/arch/x86/platform/sfi/sfi.c
diff --git a/arch/x86/platform/uv/Makefile b/arch/x86/platform/uv/Makefile
new file mode 100644
index 000000000000..6c40995fefb8
--- /dev/null
+++ b/arch/x86/platform/uv/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_X86_UV) += tlb_uv.o bios_uv.o uv_irq.o uv_sysfs.o uv_time.o
diff --git a/arch/x86/kernel/bios_uv.c b/arch/x86/platform/uv/bios_uv.c
index 8bc57baaa9ad..8bc57baaa9ad 100644
--- a/arch/x86/kernel/bios_uv.c
+++ b/arch/x86/platform/uv/bios_uv.c
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 312ef0292815..a318194002b5 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/platform/uv/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)
@@ -1337,8 +1343,8 @@ uv_activation_descriptor_init(int node, int pnode)
1337 * each bau_desc is 64 bytes; there are 8 (UV_ITEMS_PER_DESCRIPTOR) 1343 * each bau_desc is 64 bytes; there are 8 (UV_ITEMS_PER_DESCRIPTOR)
1338 * per cpu; and up to 32 (UV_ADP_SIZE) cpu's per uvhub 1344 * per cpu; and up to 32 (UV_ADP_SIZE) cpu's per uvhub
1339 */ 1345 */
1340 bau_desc = (struct bau_desc *)kmalloc_node(sizeof(struct bau_desc)* 1346 bau_desc = kmalloc_node(sizeof(struct bau_desc) * UV_ADP_SIZE
1341 UV_ADP_SIZE*UV_ITEMS_PER_DESCRIPTOR, GFP_KERNEL, node); 1347 * UV_ITEMS_PER_DESCRIPTOR, GFP_KERNEL, node);
1342 BUG_ON(!bau_desc); 1348 BUG_ON(!bau_desc);
1343 1349
1344 pa = uv_gpa(bau_desc); /* need the real nasid*/ 1350 pa = uv_gpa(bau_desc); /* need the real nasid*/
@@ -1396,9 +1402,9 @@ uv_payload_queue_init(int node, int pnode)
1396 struct bau_payload_queue_entry *pqp_malloc; 1402 struct bau_payload_queue_entry *pqp_malloc;
1397 struct bau_control *bcp; 1403 struct bau_control *bcp;
1398 1404
1399 pqp = (struct bau_payload_queue_entry *) kmalloc_node( 1405 pqp = kmalloc_node((DEST_Q_SIZE + 1)
1400 (DEST_Q_SIZE + 1) * sizeof(struct bau_payload_queue_entry), 1406 * sizeof(struct bau_payload_queue_entry),
1401 GFP_KERNEL, node); 1407 GFP_KERNEL, node);
1402 BUG_ON(!pqp); 1408 BUG_ON(!pqp);
1403 pqp_malloc = pqp; 1409 pqp_malloc = pqp;
1404 1410
@@ -1514,8 +1520,7 @@ static void __init uv_init_per_cpu(int nuvhubs)
1514 1520
1515 timeout_us = calculate_destination_timeout(); 1521 timeout_us = calculate_destination_timeout();
1516 1522
1517 uvhub_descs = (struct uvhub_desc *) 1523 uvhub_descs = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
1518 kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
1519 memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); 1524 memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
1520 uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); 1525 uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
1521 for_each_present_cpu(cpu) { 1526 for_each_present_cpu(cpu) {
diff --git a/arch/x86/kernel/uv_irq.c b/arch/x86/platform/uv/uv_irq.c
index 7b24460917d5..7b24460917d5 100644
--- a/arch/x86/kernel/uv_irq.c
+++ b/arch/x86/platform/uv/uv_irq.c
diff --git a/arch/x86/kernel/uv_sysfs.c b/arch/x86/platform/uv/uv_sysfs.c
index 309c70fb7759..309c70fb7759 100644
--- a/arch/x86/kernel/uv_sysfs.c
+++ b/arch/x86/platform/uv/uv_sysfs.c
diff --git a/arch/x86/kernel/uv_time.c b/arch/x86/platform/uv/uv_time.c
index 56e421bc379b..56e421bc379b 100644
--- a/arch/x86/kernel/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
diff --git a/arch/x86/platform/visws/Makefile b/arch/x86/platform/visws/Makefile
new file mode 100644
index 000000000000..91bc17ab2fd5
--- /dev/null
+++ b/arch/x86/platform/visws/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_X86_VISWS) += visws_quirks.o
diff --git a/arch/x86/kernel/visws_quirks.c b/arch/x86/platform/visws/visws_quirks.c
index 3371bd053b89..3371bd053b89 100644
--- a/arch/x86/kernel/visws_quirks.c
+++ b/arch/x86/platform/visws/visws_quirks.c
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 68128a1b401a..5b54892e4bc3 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -13,21 +13,28 @@ config XEN
13 kernel to boot in a paravirtualized environment under the 13 kernel to boot in a paravirtualized environment under the
14 Xen hypervisor. 14 Xen hypervisor.
15 15
16config XEN_DOM0
17 def_bool y
18 depends on XEN && PCI_XEN && SWIOTLB_XEN
19 depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
20
21# Dummy symbol since people have come to rely on the PRIVILEGED_GUEST
22# name in tools.
23config XEN_PRIVILEGED_GUEST
24 def_bool XEN_DOM0
25
16config XEN_PVHVM 26config XEN_PVHVM
17 def_bool y 27 def_bool y
18 depends on XEN 28 depends on XEN
19 depends on X86_LOCAL_APIC 29 depends on X86_LOCAL_APIC
20 30
21config XEN_MAX_DOMAIN_MEMORY 31config XEN_MAX_DOMAIN_MEMORY
22 int "Maximum allowed size of a domain in gigabytes" 32 int
23 default 8 if X86_32 33 default 128
24 default 32 if X86_64
25 depends on XEN 34 depends on XEN
26 help 35 help
27 The pseudo-physical to machine address array is sized 36 This only affects the sizing of some bss arrays, the unused
28 according to the maximum possible memory size of a Xen 37 portions of which are freed.
29 domain. This array uses 1 page per gigabyte, so there's no
30 need to be too stingy here.
31 38
32config XEN_SAVE_RESTORE 39config XEN_SAVE_RESTORE
33 bool 40 bool
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 63b83ceebd1a..235c0f4d3861 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -46,6 +46,7 @@
46#include <asm/paravirt.h> 46#include <asm/paravirt.h>
47#include <asm/apic.h> 47#include <asm/apic.h>
48#include <asm/page.h> 48#include <asm/page.h>
49#include <asm/xen/pci.h>
49#include <asm/xen/hypercall.h> 50#include <asm/xen/hypercall.h>
50#include <asm/xen/hypervisor.h> 51#include <asm/xen/hypervisor.h>
51#include <asm/fixmap.h> 52#include <asm/fixmap.h>
@@ -59,7 +60,6 @@
59#include <asm/pgtable.h> 60#include <asm/pgtable.h>
60#include <asm/tlbflush.h> 61#include <asm/tlbflush.h>
61#include <asm/reboot.h> 62#include <asm/reboot.h>
62#include <asm/setup.h>
63#include <asm/stackprotector.h> 63#include <asm/stackprotector.h>
64#include <asm/hypervisor.h> 64#include <asm/hypervisor.h>
65 65
@@ -136,9 +136,6 @@ static void xen_vcpu_setup(int cpu)
136 info.mfn = arbitrary_virt_to_mfn(vcpup); 136 info.mfn = arbitrary_virt_to_mfn(vcpup);
137 info.offset = offset_in_page(vcpup); 137 info.offset = offset_in_page(vcpup);
138 138
139 printk(KERN_DEBUG "trying to map vcpu_info %d at %p, mfn %llx, offset %d\n",
140 cpu, vcpup, info.mfn, info.offset);
141
142 /* Check to see if the hypervisor will put the vcpu_info 139 /* Check to see if the hypervisor will put the vcpu_info
143 structure where we want it, which allows direct access via 140 structure where we want it, which allows direct access via
144 a percpu-variable. */ 141 a percpu-variable. */
@@ -152,9 +149,6 @@ static void xen_vcpu_setup(int cpu)
152 /* This cpu is using the registered vcpu info, even if 149 /* This cpu is using the registered vcpu info, even if
153 later ones fail to. */ 150 later ones fail to. */
154 per_cpu(xen_vcpu, cpu) = vcpup; 151 per_cpu(xen_vcpu, cpu) = vcpup;
155
156 printk(KERN_DEBUG "cpu %d using vcpu_info at %p\n",
157 cpu, vcpup);
158 } 152 }
159} 153}
160 154
@@ -243,6 +237,7 @@ static __init void xen_init_cpuid_mask(void)
243 cpuid_leaf1_edx_mask = 237 cpuid_leaf1_edx_mask =
244 ~((1 << X86_FEATURE_MCE) | /* disable MCE */ 238 ~((1 << X86_FEATURE_MCE) | /* disable MCE */
245 (1 << X86_FEATURE_MCA) | /* disable MCA */ 239 (1 << X86_FEATURE_MCA) | /* disable MCA */
240 (1 << X86_FEATURE_MTRR) | /* disable MTRR */
246 (1 << X86_FEATURE_ACC)); /* thermal monitoring */ 241 (1 << X86_FEATURE_ACC)); /* thermal monitoring */
247 242
248 if (!xen_initial_domain()) 243 if (!xen_initial_domain())
@@ -836,6 +831,11 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
836 Xen console noise. */ 831 Xen console noise. */
837 break; 832 break;
838 833
834 case MSR_IA32_CR_PAT:
835 if (smp_processor_id() == 0)
836 xen_set_pat(((u64)high << 32) | low);
837 break;
838
839 default: 839 default:
840 ret = native_write_msr_safe(msr, low, high); 840 ret = native_write_msr_safe(msr, low, high);
841 } 841 }
@@ -874,8 +874,6 @@ void xen_setup_vcpu_info_placement(void)
874 /* xen_vcpu_setup managed to place the vcpu_info within the 874 /* xen_vcpu_setup managed to place the vcpu_info within the
875 percpu area for all cpus, so make use of it */ 875 percpu area for all cpus, so make use of it */
876 if (have_vcpu_info_placement) { 876 if (have_vcpu_info_placement) {
877 printk(KERN_INFO "Xen: using vcpu_info placement\n");
878
879 pv_irq_ops.save_fl = __PV_IS_CALLEE_SAVE(xen_save_fl_direct); 877 pv_irq_ops.save_fl = __PV_IS_CALLEE_SAVE(xen_save_fl_direct);
880 pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(xen_restore_fl_direct); 878 pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(xen_restore_fl_direct);
881 pv_irq_ops.irq_disable = __PV_IS_CALLEE_SAVE(xen_irq_disable_direct); 879 pv_irq_ops.irq_disable = __PV_IS_CALLEE_SAVE(xen_irq_disable_direct);
@@ -1019,7 +1017,7 @@ static void xen_reboot(int reason)
1019 struct sched_shutdown r = { .reason = reason }; 1017 struct sched_shutdown r = { .reason = reason };
1020 1018
1021#ifdef CONFIG_SMP 1019#ifdef CONFIG_SMP
1022 smp_send_stop(); 1020 stop_other_cpus();
1023#endif 1021#endif
1024 1022
1025 if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r)) 1023 if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
@@ -1188,6 +1186,10 @@ asmlinkage void __init xen_start_kernel(void)
1188 1186
1189 xen_raw_console_write("mapping kernel into physical memory\n"); 1187 xen_raw_console_write("mapping kernel into physical memory\n");
1190 pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); 1188 pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages);
1189 xen_ident_map_ISA();
1190
1191 /* Allocate and initialize top and mid mfn levels for p2m structure */
1192 xen_build_mfn_list_list();
1191 1193
1192 init_mm.pgd = pgd; 1194 init_mm.pgd = pgd;
1193 1195
@@ -1223,6 +1225,8 @@ asmlinkage void __init xen_start_kernel(void)
1223 add_preferred_console("xenboot", 0, NULL); 1225 add_preferred_console("xenboot", 0, NULL);
1224 add_preferred_console("tty", 0, NULL); 1226 add_preferred_console("tty", 0, NULL);
1225 add_preferred_console("hvc", 0, NULL); 1227 add_preferred_console("hvc", 0, NULL);
1228 if (pci_xen)
1229 x86_init.pci.arch_init = pci_xen_init;
1226 } else { 1230 } else {
1227 /* Make sure ACS will be enabled */ 1231 /* Make sure ACS will be enabled */
1228 pci_request_acs(); 1232 pci_request_acs();
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index f72d18c69221..21ed8d7f75a5 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -57,6 +57,7 @@
57#include <asm/linkage.h> 57#include <asm/linkage.h>
58#include <asm/page.h> 58#include <asm/page.h>
59#include <asm/init.h> 59#include <asm/init.h>
60#include <asm/pat.h>
60 61
61#include <asm/xen/hypercall.h> 62#include <asm/xen/hypercall.h>
62#include <asm/xen/hypervisor.h> 63#include <asm/xen/hypervisor.h>
@@ -140,7 +141,8 @@ static inline void check_zero(void)
140 * large enough to allocate page table pages to allocate the rest. 141 * large enough to allocate page table pages to allocate the rest.
141 * Each page can map 2MB. 142 * Each page can map 2MB.
142 */ 143 */
143static pte_t level1_ident_pgt[PTRS_PER_PTE * 4] __page_aligned_bss; 144#define LEVEL1_IDENT_ENTRIES (PTRS_PER_PTE * 4)
145static RESERVE_BRK_ARRAY(pte_t, level1_ident_pgt, LEVEL1_IDENT_ENTRIES);
144 146
145#ifdef CONFIG_X86_64 147#ifdef CONFIG_X86_64
146/* l3 pud for userspace vsyscall mapping */ 148/* l3 pud for userspace vsyscall mapping */
@@ -171,49 +173,182 @@ DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */
171 */ 173 */
172#define USER_LIMIT ((STACK_TOP_MAX + PGDIR_SIZE - 1) & PGDIR_MASK) 174#define USER_LIMIT ((STACK_TOP_MAX + PGDIR_SIZE - 1) & PGDIR_MASK)
173 175
176/*
177 * Xen leaves the responsibility for maintaining p2m mappings to the
178 * guests themselves, but it must also access and update the p2m array
179 * during suspend/resume when all the pages are reallocated.
180 *
181 * The p2m table is logically a flat array, but we implement it as a
182 * three-level tree to allow the address space to be sparse.
183 *
184 * Xen
185 * |
186 * p2m_top p2m_top_mfn
187 * / \ / \
188 * p2m_mid p2m_mid p2m_mid_mfn p2m_mid_mfn
189 * / \ / \ / /
190 * p2m p2m p2m p2m p2m p2m p2m ...
191 *
192 * The p2m_mid_mfn pages are mapped by p2m_top_mfn_p.
193 *
194 * The p2m_top and p2m_top_mfn levels are limited to 1 page, so the
195 * maximum representable pseudo-physical address space is:
196 * P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * P2M_PER_PAGE pages
197 *
198 * P2M_PER_PAGE depends on the architecture, as a mfn is always
199 * unsigned long (8 bytes on 64-bit, 4 bytes on 32), leading to
200 * 512 and 1024 entries respectively.
201 */
202
203unsigned long xen_max_p2m_pfn __read_mostly;
174 204
175#define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) 205#define P2M_PER_PAGE (PAGE_SIZE / sizeof(unsigned long))
176#define TOP_ENTRIES (MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE) 206#define P2M_MID_PER_PAGE (PAGE_SIZE / sizeof(unsigned long *))
207#define P2M_TOP_PER_PAGE (PAGE_SIZE / sizeof(unsigned long **))
177 208
178/* Placeholder for holes in the address space */ 209#define MAX_P2M_PFN (P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * P2M_PER_PAGE)
179static unsigned long p2m_missing[P2M_ENTRIES_PER_PAGE] __page_aligned_data =
180 { [ 0 ... P2M_ENTRIES_PER_PAGE-1 ] = ~0UL };
181 210
182 /* Array of pointers to pages containing p2m entries */ 211/* Placeholders for holes in the address space */
183static unsigned long *p2m_top[TOP_ENTRIES] __page_aligned_data = 212static RESERVE_BRK_ARRAY(unsigned long, p2m_missing, P2M_PER_PAGE);
184 { [ 0 ... TOP_ENTRIES - 1] = &p2m_missing[0] }; 213static RESERVE_BRK_ARRAY(unsigned long *, p2m_mid_missing, P2M_MID_PER_PAGE);
214static RESERVE_BRK_ARRAY(unsigned long, p2m_mid_missing_mfn, P2M_MID_PER_PAGE);
185 215
186/* Arrays of p2m arrays expressed in mfns used for save/restore */ 216static RESERVE_BRK_ARRAY(unsigned long **, p2m_top, P2M_TOP_PER_PAGE);
187static unsigned long p2m_top_mfn[TOP_ENTRIES] __page_aligned_bss; 217static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn, P2M_TOP_PER_PAGE);
218static RESERVE_BRK_ARRAY(unsigned long *, p2m_top_mfn_p, P2M_TOP_PER_PAGE);
188 219
189static unsigned long p2m_top_mfn_list[TOP_ENTRIES / P2M_ENTRIES_PER_PAGE] 220RESERVE_BRK(p2m_mid, PAGE_SIZE * (MAX_DOMAIN_PAGES / (P2M_PER_PAGE * P2M_MID_PER_PAGE)));
190 __page_aligned_bss; 221RESERVE_BRK(p2m_mid_mfn, PAGE_SIZE * (MAX_DOMAIN_PAGES / (P2M_PER_PAGE * P2M_MID_PER_PAGE)));
191 222
192static inline unsigned p2m_top_index(unsigned long pfn) 223static inline unsigned p2m_top_index(unsigned long pfn)
193{ 224{
194 BUG_ON(pfn >= MAX_DOMAIN_PAGES); 225 BUG_ON(pfn >= MAX_P2M_PFN);
195 return pfn / P2M_ENTRIES_PER_PAGE; 226 return pfn / (P2M_MID_PER_PAGE * P2M_PER_PAGE);
227}
228
229static inline unsigned p2m_mid_index(unsigned long pfn)
230{
231 return (pfn / P2M_PER_PAGE) % P2M_MID_PER_PAGE;
196} 232}
197 233
198static inline unsigned p2m_index(unsigned long pfn) 234static inline unsigned p2m_index(unsigned long pfn)
199{ 235{
200 return pfn % P2M_ENTRIES_PER_PAGE; 236 return pfn % P2M_PER_PAGE;
237}
238
239static void p2m_top_init(unsigned long ***top)
240{
241 unsigned i;
242
243 for (i = 0; i < P2M_TOP_PER_PAGE; i++)
244 top[i] = p2m_mid_missing;
245}
246
247static void p2m_top_mfn_init(unsigned long *top)
248{
249 unsigned i;
250
251 for (i = 0; i < P2M_TOP_PER_PAGE; i++)
252 top[i] = virt_to_mfn(p2m_mid_missing_mfn);
201} 253}
202 254
203/* Build the parallel p2m_top_mfn structures */ 255static void p2m_top_mfn_p_init(unsigned long **top)
256{
257 unsigned i;
258
259 for (i = 0; i < P2M_TOP_PER_PAGE; i++)
260 top[i] = p2m_mid_missing_mfn;
261}
262
263static void p2m_mid_init(unsigned long **mid)
264{
265 unsigned i;
266
267 for (i = 0; i < P2M_MID_PER_PAGE; i++)
268 mid[i] = p2m_missing;
269}
270
271static void p2m_mid_mfn_init(unsigned long *mid)
272{
273 unsigned i;
274
275 for (i = 0; i < P2M_MID_PER_PAGE; i++)
276 mid[i] = virt_to_mfn(p2m_missing);
277}
278
279static void p2m_init(unsigned long *p2m)
280{
281 unsigned i;
282
283 for (i = 0; i < P2M_MID_PER_PAGE; i++)
284 p2m[i] = INVALID_P2M_ENTRY;
285}
286
287/*
288 * Build the parallel p2m_top_mfn and p2m_mid_mfn structures
289 *
290 * This is called both at boot time, and after resuming from suspend:
291 * - At boot time we're called very early, and must use extend_brk()
292 * to allocate memory.
293 *
294 * - After resume we're called from within stop_machine, but the mfn
295 * tree should alreay be completely allocated.
296 */
204void xen_build_mfn_list_list(void) 297void xen_build_mfn_list_list(void)
205{ 298{
206 unsigned pfn, idx; 299 unsigned long pfn;
207 300
208 for (pfn = 0; pfn < MAX_DOMAIN_PAGES; pfn += P2M_ENTRIES_PER_PAGE) { 301 /* Pre-initialize p2m_top_mfn to be completely missing */
209 unsigned topidx = p2m_top_index(pfn); 302 if (p2m_top_mfn == NULL) {
303 p2m_mid_missing_mfn = extend_brk(PAGE_SIZE, PAGE_SIZE);
304 p2m_mid_mfn_init(p2m_mid_missing_mfn);
210 305
211 p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]); 306 p2m_top_mfn_p = extend_brk(PAGE_SIZE, PAGE_SIZE);
307 p2m_top_mfn_p_init(p2m_top_mfn_p);
308
309 p2m_top_mfn = extend_brk(PAGE_SIZE, PAGE_SIZE);
310 p2m_top_mfn_init(p2m_top_mfn);
311 } else {
312 /* Reinitialise, mfn's all change after migration */
313 p2m_mid_mfn_init(p2m_mid_missing_mfn);
212 } 314 }
213 315
214 for (idx = 0; idx < ARRAY_SIZE(p2m_top_mfn_list); idx++) { 316 for (pfn = 0; pfn < xen_max_p2m_pfn; pfn += P2M_PER_PAGE) {
215 unsigned topidx = idx * P2M_ENTRIES_PER_PAGE; 317 unsigned topidx = p2m_top_index(pfn);
216 p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]); 318 unsigned mididx = p2m_mid_index(pfn);
319 unsigned long **mid;
320 unsigned long *mid_mfn_p;
321
322 mid = p2m_top[topidx];
323 mid_mfn_p = p2m_top_mfn_p[topidx];
324
325 /* Don't bother allocating any mfn mid levels if
326 * they're just missing, just update the stored mfn,
327 * since all could have changed over a migrate.
328 */
329 if (mid == p2m_mid_missing) {
330 BUG_ON(mididx);
331 BUG_ON(mid_mfn_p != p2m_mid_missing_mfn);
332 p2m_top_mfn[topidx] = virt_to_mfn(p2m_mid_missing_mfn);
333 pfn += (P2M_MID_PER_PAGE - 1) * P2M_PER_PAGE;
334 continue;
335 }
336
337 if (mid_mfn_p == p2m_mid_missing_mfn) {
338 /*
339 * XXX boot-time only! We should never find
340 * missing parts of the mfn tree after
341 * runtime. extend_brk() will BUG if we call
342 * it too late.
343 */
344 mid_mfn_p = extend_brk(PAGE_SIZE, PAGE_SIZE);
345 p2m_mid_mfn_init(mid_mfn_p);
346
347 p2m_top_mfn_p[topidx] = mid_mfn_p;
348 }
349
350 p2m_top_mfn[topidx] = virt_to_mfn(mid_mfn_p);
351 mid_mfn_p[mididx] = virt_to_mfn(mid[mididx]);
217 } 352 }
218} 353}
219 354
@@ -222,8 +357,8 @@ void xen_setup_mfn_list_list(void)
222 BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info); 357 BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
223 358
224 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 359 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
225 virt_to_mfn(p2m_top_mfn_list); 360 virt_to_mfn(p2m_top_mfn);
226 HYPERVISOR_shared_info->arch.max_pfn = xen_start_info->nr_pages; 361 HYPERVISOR_shared_info->arch.max_pfn = xen_max_p2m_pfn;
227} 362}
228 363
229/* Set up p2m_top to point to the domain-builder provided p2m pages */ 364/* Set up p2m_top to point to the domain-builder provided p2m pages */
@@ -231,98 +366,176 @@ void __init xen_build_dynamic_phys_to_machine(void)
231{ 366{
232 unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list; 367 unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list;
233 unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages); 368 unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages);
234 unsigned pfn; 369 unsigned long pfn;
235 370
236 for (pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { 371 xen_max_p2m_pfn = max_pfn;
372
373 p2m_missing = extend_brk(PAGE_SIZE, PAGE_SIZE);
374 p2m_init(p2m_missing);
375
376 p2m_mid_missing = extend_brk(PAGE_SIZE, PAGE_SIZE);
377 p2m_mid_init(p2m_mid_missing);
378
379 p2m_top = extend_brk(PAGE_SIZE, PAGE_SIZE);
380 p2m_top_init(p2m_top);
381
382 /*
383 * The domain builder gives us a pre-constructed p2m array in
384 * mfn_list for all the pages initially given to us, so we just
385 * need to graft that into our tree structure.
386 */
387 for (pfn = 0; pfn < max_pfn; pfn += P2M_PER_PAGE) {
237 unsigned topidx = p2m_top_index(pfn); 388 unsigned topidx = p2m_top_index(pfn);
389 unsigned mididx = p2m_mid_index(pfn);
238 390
239 p2m_top[topidx] = &mfn_list[pfn]; 391 if (p2m_top[topidx] == p2m_mid_missing) {
240 } 392 unsigned long **mid = extend_brk(PAGE_SIZE, PAGE_SIZE);
393 p2m_mid_init(mid);
394
395 p2m_top[topidx] = mid;
396 }
241 397
242 xen_build_mfn_list_list(); 398 p2m_top[topidx][mididx] = &mfn_list[pfn];
399 }
243} 400}
244 401
245unsigned long get_phys_to_machine(unsigned long pfn) 402unsigned long get_phys_to_machine(unsigned long pfn)
246{ 403{
247 unsigned topidx, idx; 404 unsigned topidx, mididx, idx;
248 405
249 if (unlikely(pfn >= MAX_DOMAIN_PAGES)) 406 if (unlikely(pfn >= MAX_P2M_PFN))
250 return INVALID_P2M_ENTRY; 407 return INVALID_P2M_ENTRY;
251 408
252 topidx = p2m_top_index(pfn); 409 topidx = p2m_top_index(pfn);
410 mididx = p2m_mid_index(pfn);
253 idx = p2m_index(pfn); 411 idx = p2m_index(pfn);
254 return p2m_top[topidx][idx]; 412
413 return p2m_top[topidx][mididx][idx];
255} 414}
256EXPORT_SYMBOL_GPL(get_phys_to_machine); 415EXPORT_SYMBOL_GPL(get_phys_to_machine);
257 416
258/* install a new p2m_top page */ 417static void *alloc_p2m_page(void)
259bool install_p2mtop_page(unsigned long pfn, unsigned long *p)
260{ 418{
261 unsigned topidx = p2m_top_index(pfn); 419 return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
262 unsigned long **pfnp, *mfnp; 420}
263 unsigned i;
264 421
265 pfnp = &p2m_top[topidx]; 422static void free_p2m_page(void *p)
266 mfnp = &p2m_top_mfn[topidx]; 423{
424 free_page((unsigned long)p);
425}
267 426
268 for (i = 0; i < P2M_ENTRIES_PER_PAGE; i++) 427/*
269 p[i] = INVALID_P2M_ENTRY; 428 * Fully allocate the p2m structure for a given pfn. We need to check
429 * that both the top and mid levels are allocated, and make sure the
430 * parallel mfn tree is kept in sync. We may race with other cpus, so
431 * the new pages are installed with cmpxchg; if we lose the race then
432 * simply free the page we allocated and use the one that's there.
433 */
434static bool alloc_p2m(unsigned long pfn)
435{
436 unsigned topidx, mididx;
437 unsigned long ***top_p, **mid;
438 unsigned long *top_mfn_p, *mid_mfn;
270 439
271 if (cmpxchg(pfnp, p2m_missing, p) == p2m_missing) { 440 topidx = p2m_top_index(pfn);
272 *mfnp = virt_to_mfn(p); 441 mididx = p2m_mid_index(pfn);
273 return true; 442
443 top_p = &p2m_top[topidx];
444 mid = *top_p;
445
446 if (mid == p2m_mid_missing) {
447 /* Mid level is missing, allocate a new one */
448 mid = alloc_p2m_page();
449 if (!mid)
450 return false;
451
452 p2m_mid_init(mid);
453
454 if (cmpxchg(top_p, p2m_mid_missing, mid) != p2m_mid_missing)
455 free_p2m_page(mid);
274 } 456 }
275 457
276 return false; 458 top_mfn_p = &p2m_top_mfn[topidx];
277} 459 mid_mfn = p2m_top_mfn_p[topidx];
278 460
279static void alloc_p2m(unsigned long pfn) 461 BUG_ON(virt_to_mfn(mid_mfn) != *top_mfn_p);
280{ 462
281 unsigned long *p; 463 if (mid_mfn == p2m_mid_missing_mfn) {
464 /* Separately check the mid mfn level */
465 unsigned long missing_mfn;
466 unsigned long mid_mfn_mfn;
467
468 mid_mfn = alloc_p2m_page();
469 if (!mid_mfn)
470 return false;
282 471
283 p = (void *)__get_free_page(GFP_KERNEL | __GFP_NOFAIL); 472 p2m_mid_mfn_init(mid_mfn);
284 BUG_ON(p == NULL); 473
474 missing_mfn = virt_to_mfn(p2m_mid_missing_mfn);
475 mid_mfn_mfn = virt_to_mfn(mid_mfn);
476 if (cmpxchg(top_mfn_p, missing_mfn, mid_mfn_mfn) != missing_mfn)
477 free_p2m_page(mid_mfn);
478 else
479 p2m_top_mfn_p[topidx] = mid_mfn;
480 }
285 481
286 if (!install_p2mtop_page(pfn, p)) 482 if (p2m_top[topidx][mididx] == p2m_missing) {
287 free_page((unsigned long)p); 483 /* p2m leaf page is missing */
484 unsigned long *p2m;
485
486 p2m = alloc_p2m_page();
487 if (!p2m)
488 return false;
489
490 p2m_init(p2m);
491
492 if (cmpxchg(&mid[mididx], p2m_missing, p2m) != p2m_missing)
493 free_p2m_page(p2m);
494 else
495 mid_mfn[mididx] = virt_to_mfn(p2m);
496 }
497
498 return true;
288} 499}
289 500
290/* Try to install p2m mapping; fail if intermediate bits missing */ 501/* Try to install p2m mapping; fail if intermediate bits missing */
291bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) 502bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
292{ 503{
293 unsigned topidx, idx; 504 unsigned topidx, mididx, idx;
294 505
295 if (unlikely(pfn >= MAX_DOMAIN_PAGES)) { 506 if (unlikely(pfn >= MAX_P2M_PFN)) {
296 BUG_ON(mfn != INVALID_P2M_ENTRY); 507 BUG_ON(mfn != INVALID_P2M_ENTRY);
297 return true; 508 return true;
298 } 509 }
299 510
300 topidx = p2m_top_index(pfn); 511 topidx = p2m_top_index(pfn);
301 if (p2m_top[topidx] == p2m_missing) { 512 mididx = p2m_mid_index(pfn);
302 if (mfn == INVALID_P2M_ENTRY)
303 return true;
304 return false;
305 }
306
307 idx = p2m_index(pfn); 513 idx = p2m_index(pfn);
308 p2m_top[topidx][idx] = mfn; 514
515 if (p2m_top[topidx][mididx] == p2m_missing)
516 return mfn == INVALID_P2M_ENTRY;
517
518 p2m_top[topidx][mididx][idx] = mfn;
309 519
310 return true; 520 return true;
311} 521}
312 522
313void set_phys_to_machine(unsigned long pfn, unsigned long mfn) 523bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
314{ 524{
315 if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) { 525 if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) {
316 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); 526 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
317 return; 527 return true;
318 } 528 }
319 529
320 if (unlikely(!__set_phys_to_machine(pfn, mfn))) { 530 if (unlikely(!__set_phys_to_machine(pfn, mfn))) {
321 alloc_p2m(pfn); 531 if (!alloc_p2m(pfn))
532 return false;
322 533
323 if (!__set_phys_to_machine(pfn, mfn)) 534 if (!__set_phys_to_machine(pfn, mfn))
324 BUG(); 535 return false;
325 } 536 }
537
538 return true;
326} 539}
327 540
328unsigned long arbitrary_virt_to_mfn(void *vaddr) 541unsigned long arbitrary_virt_to_mfn(void *vaddr)
@@ -399,7 +612,7 @@ static bool xen_iomap_pte(pte_t pte)
399 return pte_flags(pte) & _PAGE_IOMAP; 612 return pte_flags(pte) & _PAGE_IOMAP;
400} 613}
401 614
402static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval) 615void xen_set_domain_pte(pte_t *ptep, pte_t pteval, unsigned domid)
403{ 616{
404 struct multicall_space mcs; 617 struct multicall_space mcs;
405 struct mmu_update *u; 618 struct mmu_update *u;
@@ -411,10 +624,16 @@ static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval)
411 u->ptr = arbitrary_virt_to_machine(ptep).maddr; 624 u->ptr = arbitrary_virt_to_machine(ptep).maddr;
412 u->val = pte_val_ma(pteval); 625 u->val = pte_val_ma(pteval);
413 626
414 MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, DOMID_IO); 627 MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, domid);
415 628
416 xen_mc_issue(PARAVIRT_LAZY_MMU); 629 xen_mc_issue(PARAVIRT_LAZY_MMU);
417} 630}
631EXPORT_SYMBOL_GPL(xen_set_domain_pte);
632
633static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval)
634{
635 xen_set_domain_pte(ptep, pteval, DOMID_IO);
636}
418 637
419static void xen_extend_mmu_update(const struct mmu_update *update) 638static void xen_extend_mmu_update(const struct mmu_update *update)
420{ 639{
@@ -561,7 +780,20 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
561 if (val & _PAGE_PRESENT) { 780 if (val & _PAGE_PRESENT) {
562 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; 781 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
563 pteval_t flags = val & PTE_FLAGS_MASK; 782 pteval_t flags = val & PTE_FLAGS_MASK;
564 val = ((pteval_t)pfn_to_mfn(pfn) << PAGE_SHIFT) | flags; 783 unsigned long mfn = pfn_to_mfn(pfn);
784
785 /*
786 * If there's no mfn for the pfn, then just create an
787 * empty non-present pte. Unfortunately this loses
788 * information about the original pfn, so
789 * pte_mfn_to_pfn is asymmetric.
790 */
791 if (unlikely(mfn == INVALID_P2M_ENTRY)) {
792 mfn = 0;
793 flags = 0;
794 }
795
796 val = ((pteval_t)mfn << PAGE_SHIFT) | flags;
565 } 797 }
566 798
567 return val; 799 return val;
@@ -583,10 +815,18 @@ static pteval_t iomap_pte(pteval_t val)
583 815
584pteval_t xen_pte_val(pte_t pte) 816pteval_t xen_pte_val(pte_t pte)
585{ 817{
586 if (xen_initial_domain() && (pte.pte & _PAGE_IOMAP)) 818 pteval_t pteval = pte.pte;
587 return pte.pte; 819
820 /* If this is a WC pte, convert back from Xen WC to Linux WC */
821 if ((pteval & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) == _PAGE_PAT) {
822 WARN_ON(!pat_enabled);
823 pteval = (pteval & ~_PAGE_PAT) | _PAGE_PWT;
824 }
588 825
589 return pte_mfn_to_pfn(pte.pte); 826 if (xen_initial_domain() && (pteval & _PAGE_IOMAP))
827 return pteval;
828
829 return pte_mfn_to_pfn(pteval);
590} 830}
591PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); 831PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val);
592 832
@@ -596,10 +836,48 @@ pgdval_t xen_pgd_val(pgd_t pgd)
596} 836}
597PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); 837PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val);
598 838
839/*
840 * Xen's PAT setup is part of its ABI, though I assume entries 6 & 7
841 * are reserved for now, to correspond to the Intel-reserved PAT
842 * types.
843 *
844 * We expect Linux's PAT set as follows:
845 *
846 * Idx PTE flags Linux Xen Default
847 * 0 WB WB WB
848 * 1 PWT WC WT WT
849 * 2 PCD UC- UC- UC-
850 * 3 PCD PWT UC UC UC
851 * 4 PAT WB WC WB
852 * 5 PAT PWT WC WP WT
853 * 6 PAT PCD UC- UC UC-
854 * 7 PAT PCD PWT UC UC UC
855 */
856
857void xen_set_pat(u64 pat)
858{
859 /* We expect Linux to use a PAT setting of
860 * UC UC- WC WB (ignoring the PAT flag) */
861 WARN_ON(pat != 0x0007010600070106ull);
862}
863
599pte_t xen_make_pte(pteval_t pte) 864pte_t xen_make_pte(pteval_t pte)
600{ 865{
601 phys_addr_t addr = (pte & PTE_PFN_MASK); 866 phys_addr_t addr = (pte & PTE_PFN_MASK);
602 867
868 /* If Linux is trying to set a WC pte, then map to the Xen WC.
869 * If _PAGE_PAT is set, then it probably means it is really
870 * _PAGE_PSE, so avoid fiddling with the PAT mapping and hope
871 * things work out OK...
872 *
873 * (We should never see kernel mappings with _PAGE_PSE set,
874 * but we could see hugetlbfs mappings, I think.).
875 */
876 if (pat_enabled && !WARN_ON(pte & _PAGE_PAT)) {
877 if ((pte & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT)
878 pte = (pte & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT;
879 }
880
603 /* 881 /*
604 * Unprivileged domains are allowed to do IOMAPpings for 882 * Unprivileged domains are allowed to do IOMAPpings for
605 * PCI passthrough, but not map ISA space. The ISA 883 * PCI passthrough, but not map ISA space. The ISA
@@ -1697,6 +1975,7 @@ static void *m2v(phys_addr_t maddr)
1697 return __ka(m2p(maddr)); 1975 return __ka(m2p(maddr));
1698} 1976}
1699 1977
1978/* Set the page permissions on an identity-mapped pages */
1700static void set_page_prot(void *addr, pgprot_t prot) 1979static void set_page_prot(void *addr, pgprot_t prot)
1701{ 1980{
1702 unsigned long pfn = __pa(addr) >> PAGE_SHIFT; 1981 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
@@ -1712,6 +1991,9 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
1712 unsigned ident_pte; 1991 unsigned ident_pte;
1713 unsigned long pfn; 1992 unsigned long pfn;
1714 1993
1994 level1_ident_pgt = extend_brk(sizeof(pte_t) * LEVEL1_IDENT_ENTRIES,
1995 PAGE_SIZE);
1996
1715 ident_pte = 0; 1997 ident_pte = 0;
1716 pfn = 0; 1998 pfn = 0;
1717 for (pmdidx = 0; pmdidx < PTRS_PER_PMD && pfn < max_pfn; pmdidx++) { 1999 for (pmdidx = 0; pmdidx < PTRS_PER_PMD && pfn < max_pfn; pmdidx++) {
@@ -1722,7 +2004,7 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
1722 pte_page = m2v(pmd[pmdidx].pmd); 2004 pte_page = m2v(pmd[pmdidx].pmd);
1723 else { 2005 else {
1724 /* Check for free pte pages */ 2006 /* Check for free pte pages */
1725 if (ident_pte == ARRAY_SIZE(level1_ident_pgt)) 2007 if (ident_pte == LEVEL1_IDENT_ENTRIES)
1726 break; 2008 break;
1727 2009
1728 pte_page = &level1_ident_pgt[ident_pte]; 2010 pte_page = &level1_ident_pgt[ident_pte];
@@ -1837,13 +2119,15 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1837 return pgd; 2119 return pgd;
1838} 2120}
1839#else /* !CONFIG_X86_64 */ 2121#else /* !CONFIG_X86_64 */
1840static pmd_t level2_kernel_pgt[PTRS_PER_PMD] __page_aligned_bss; 2122static RESERVE_BRK_ARRAY(pmd_t, level2_kernel_pgt, PTRS_PER_PMD);
1841 2123
1842__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, 2124__init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1843 unsigned long max_pfn) 2125 unsigned long max_pfn)
1844{ 2126{
1845 pmd_t *kernel_pmd; 2127 pmd_t *kernel_pmd;
1846 2128
2129 level2_kernel_pgt = extend_brk(sizeof(pmd_t) * PTRS_PER_PMD, PAGE_SIZE);
2130
1847 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) + 2131 max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) +
1848 xen_start_info->nr_pt_frames * PAGE_SIZE + 2132 xen_start_info->nr_pt_frames * PAGE_SIZE +
1849 512*1024); 2133 512*1024);
@@ -1876,6 +2160,8 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
1876} 2160}
1877#endif /* CONFIG_X86_64 */ 2161#endif /* CONFIG_X86_64 */
1878 2162
2163static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
2164
1879static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot) 2165static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
1880{ 2166{
1881 pte_t pte; 2167 pte_t pte;
@@ -1896,15 +2182,28 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
1896#else 2182#else
1897 case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE: 2183 case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE:
1898#endif 2184#endif
1899#ifdef CONFIG_X86_LOCAL_APIC
1900 case FIX_APIC_BASE: /* maps dummy local APIC */
1901#endif
1902 case FIX_TEXT_POKE0: 2185 case FIX_TEXT_POKE0:
1903 case FIX_TEXT_POKE1: 2186 case FIX_TEXT_POKE1:
1904 /* All local page mappings */ 2187 /* All local page mappings */
1905 pte = pfn_pte(phys, prot); 2188 pte = pfn_pte(phys, prot);
1906 break; 2189 break;
1907 2190
2191#ifdef CONFIG_X86_LOCAL_APIC
2192 case FIX_APIC_BASE: /* maps dummy local APIC */
2193 pte = pfn_pte(PFN_DOWN(__pa(dummy_mapping)), PAGE_KERNEL);
2194 break;
2195#endif
2196
2197#ifdef CONFIG_X86_IO_APIC
2198 case FIX_IO_APIC_BASE_0 ... FIX_IO_APIC_BASE_END:
2199 /*
2200 * We just don't map the IO APIC - all access is via
2201 * hypercalls. Keep the address in the pte for reference.
2202 */
2203 pte = pfn_pte(PFN_DOWN(__pa(dummy_mapping)), PAGE_KERNEL);
2204 break;
2205#endif
2206
1908 case FIX_PARAVIRT_BOOTMAP: 2207 case FIX_PARAVIRT_BOOTMAP:
1909 /* This is an MFN, but it isn't an IO mapping from the 2208 /* This is an MFN, but it isn't an IO mapping from the
1910 IO domain */ 2209 IO domain */
@@ -1929,6 +2228,29 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
1929#endif 2228#endif
1930} 2229}
1931 2230
2231__init void xen_ident_map_ISA(void)
2232{
2233 unsigned long pa;
2234
2235 /*
2236 * If we're dom0, then linear map the ISA machine addresses into
2237 * the kernel's address space.
2238 */
2239 if (!xen_initial_domain())
2240 return;
2241
2242 xen_raw_printk("Xen: setup ISA identity maps\n");
2243
2244 for (pa = ISA_START_ADDRESS; pa < ISA_END_ADDRESS; pa += PAGE_SIZE) {
2245 pte_t pte = mfn_pte(PFN_DOWN(pa), PAGE_KERNEL_IO);
2246
2247 if (HYPERVISOR_update_va_mapping(PAGE_OFFSET + pa, pte, 0))
2248 BUG();
2249 }
2250
2251 xen_flush_tlb();
2252}
2253
1932static __init void xen_post_allocator_init(void) 2254static __init void xen_post_allocator_init(void)
1933{ 2255{
1934 pv_mmu_ops.set_pte = xen_set_pte; 2256 pv_mmu_ops.set_pte = xen_set_pte;
@@ -2037,6 +2359,8 @@ void __init xen_init_mmu_ops(void)
2037 pv_mmu_ops = xen_mmu_ops; 2359 pv_mmu_ops = xen_mmu_ops;
2038 2360
2039 vmap_lazy_unmap = false; 2361 vmap_lazy_unmap = false;
2362
2363 memset(dummy_mapping, 0xff, PAGE_SIZE);
2040} 2364}
2041 2365
2042/* Protected by xen_reservation_lock. */ 2366/* Protected by xen_reservation_lock. */
@@ -2269,6 +2593,72 @@ void __init xen_hvm_init_mmu_ops(void)
2269} 2593}
2270#endif 2594#endif
2271 2595
2596#define REMAP_BATCH_SIZE 16
2597
2598struct remap_data {
2599 unsigned long mfn;
2600 pgprot_t prot;
2601 struct mmu_update *mmu_update;
2602};
2603
2604static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
2605 unsigned long addr, void *data)
2606{
2607 struct remap_data *rmd = data;
2608 pte_t pte = pte_mkspecial(pfn_pte(rmd->mfn++, rmd->prot));
2609
2610 rmd->mmu_update->ptr = arbitrary_virt_to_machine(ptep).maddr;
2611 rmd->mmu_update->val = pte_val_ma(pte);
2612 rmd->mmu_update++;
2613
2614 return 0;
2615}
2616
2617int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
2618 unsigned long addr,
2619 unsigned long mfn, int nr,
2620 pgprot_t prot, unsigned domid)
2621{
2622 struct remap_data rmd;
2623 struct mmu_update mmu_update[REMAP_BATCH_SIZE];
2624 int batch;
2625 unsigned long range;
2626 int err = 0;
2627
2628 prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);
2629
2630 vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
2631
2632 rmd.mfn = mfn;
2633 rmd.prot = prot;
2634
2635 while (nr) {
2636 batch = min(REMAP_BATCH_SIZE, nr);
2637 range = (unsigned long)batch << PAGE_SHIFT;
2638
2639 rmd.mmu_update = mmu_update;
2640 err = apply_to_page_range(vma->vm_mm, addr, range,
2641 remap_area_mfn_pte_fn, &rmd);
2642 if (err)
2643 goto out;
2644
2645 err = -EFAULT;
2646 if (HYPERVISOR_mmu_update(mmu_update, batch, NULL, domid) < 0)
2647 goto out;
2648
2649 nr -= batch;
2650 addr += range;
2651 }
2652
2653 err = 0;
2654out:
2655
2656 flush_tlb_all();
2657
2658 return err;
2659}
2660EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
2661
2272#ifdef CONFIG_XEN_DEBUG_FS 2662#ifdef CONFIG_XEN_DEBUG_FS
2273 2663
2274static struct dentry *d_mmu_debug; 2664static struct dentry *d_mmu_debug;
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index fa938c4aa2f7..537bb9aab777 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -12,7 +12,6 @@ enum pt_level {
12 12
13 13
14bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn); 14bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
15bool install_p2mtop_page(unsigned long pfn, unsigned long *p);
16 15
17void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags); 16void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
18 17
diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c
index 22471001b74c..bfd0632fe65e 100644
--- a/arch/x86/xen/pci-swiotlb-xen.c
+++ b/arch/x86/xen/pci-swiotlb-xen.c
@@ -1,6 +1,7 @@
1/* Glue code to lib/swiotlb-xen.c */ 1/* Glue code to lib/swiotlb-xen.c */
2 2
3#include <linux/dma-mapping.h> 3#include <linux/dma-mapping.h>
4#include <linux/pci.h>
4#include <xen/swiotlb-xen.h> 5#include <xen/swiotlb-xen.h>
5 6
6#include <asm/xen/hypervisor.h> 7#include <asm/xen/hypervisor.h>
@@ -55,6 +56,9 @@ void __init pci_xen_swiotlb_init(void)
55 if (xen_swiotlb) { 56 if (xen_swiotlb) {
56 xen_swiotlb_init(1); 57 xen_swiotlb_init(1);
57 dma_ops = &xen_swiotlb_dma_ops; 58 dma_ops = &xen_swiotlb_dma_ops;
59
60 /* Make sure ACS will be enabled */
61 pci_request_acs();
58 } 62 }
59} 63}
60IOMMU_INIT_FINISH(pci_xen_swiotlb_detect, 64IOMMU_INIT_FINISH(pci_xen_swiotlb_detect,
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 9729c903404b..769c4b01fa32 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -18,8 +18,10 @@
18#include <asm/xen/hypervisor.h> 18#include <asm/xen/hypervisor.h>
19#include <asm/xen/hypercall.h> 19#include <asm/xen/hypercall.h>
20 20
21#include <xen/xen.h>
21#include <xen/page.h> 22#include <xen/page.h>
22#include <xen/interface/callback.h> 23#include <xen/interface/callback.h>
24#include <xen/interface/memory.h>
23#include <xen/interface/physdev.h> 25#include <xen/interface/physdev.h>
24#include <xen/interface/memory.h> 26#include <xen/interface/memory.h>
25#include <xen/features.h> 27#include <xen/features.h>
@@ -34,6 +36,39 @@ extern void xen_sysenter_target(void);
34extern void xen_syscall_target(void); 36extern void xen_syscall_target(void);
35extern void xen_syscall32_target(void); 37extern void xen_syscall32_target(void);
36 38
39/* Amount of extra memory space we add to the e820 ranges */
40phys_addr_t xen_extra_mem_start, xen_extra_mem_size;
41
42/*
43 * The maximum amount of extra memory compared to the base size. The
44 * main scaling factor is the size of struct page. At extreme ratios
45 * of base:extra, all the base memory can be filled with page
46 * structures for the extra memory, leaving no space for anything
47 * else.
48 *
49 * 10x seems like a reasonable balance between scaling flexibility and
50 * leaving a practically usable system.
51 */
52#define EXTRA_MEM_RATIO (10)
53
54static __init void xen_add_extra_mem(unsigned long pages)
55{
56 u64 size = (u64)pages * PAGE_SIZE;
57 u64 extra_start = xen_extra_mem_start + xen_extra_mem_size;
58
59 if (!pages)
60 return;
61
62 e820_add_region(extra_start, size, E820_RAM);
63 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
64
65 memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA");
66
67 xen_extra_mem_size += size;
68
69 xen_max_p2m_pfn = PFN_DOWN(extra_start + size);
70}
71
37static unsigned long __init xen_release_chunk(phys_addr_t start_addr, 72static unsigned long __init xen_release_chunk(phys_addr_t start_addr,
38 phys_addr_t end_addr) 73 phys_addr_t end_addr)
39{ 74{
@@ -83,16 +118,18 @@ static unsigned long __init xen_return_unused_memory(unsigned long max_pfn,
83 const struct e820map *e820) 118 const struct e820map *e820)
84{ 119{
85 phys_addr_t max_addr = PFN_PHYS(max_pfn); 120 phys_addr_t max_addr = PFN_PHYS(max_pfn);
86 phys_addr_t last_end = 0; 121 phys_addr_t last_end = ISA_END_ADDRESS;
87 unsigned long released = 0; 122 unsigned long released = 0;
88 int i; 123 int i;
89 124
125 /* Free any unused memory above the low 1Mbyte. */
90 for (i = 0; i < e820->nr_map && last_end < max_addr; i++) { 126 for (i = 0; i < e820->nr_map && last_end < max_addr; i++) {
91 phys_addr_t end = e820->map[i].addr; 127 phys_addr_t end = e820->map[i].addr;
92 end = min(max_addr, end); 128 end = min(max_addr, end);
93 129
94 released += xen_release_chunk(last_end, end); 130 if (last_end < end)
95 last_end = e820->map[i].addr + e820->map[i].size; 131 released += xen_release_chunk(last_end, end);
132 last_end = max(last_end, e820->map[i].addr + e820->map[i].size);
96 } 133 }
97 134
98 if (last_end < max_addr) 135 if (last_end < max_addr)
@@ -105,21 +142,75 @@ static unsigned long __init xen_return_unused_memory(unsigned long max_pfn,
105/** 142/**
106 * machine_specific_memory_setup - Hook for machine specific memory setup. 143 * machine_specific_memory_setup - Hook for machine specific memory setup.
107 **/ 144 **/
108
109char * __init xen_memory_setup(void) 145char * __init xen_memory_setup(void)
110{ 146{
147 static struct e820entry map[E820MAX] __initdata;
148
111 unsigned long max_pfn = xen_start_info->nr_pages; 149 unsigned long max_pfn = xen_start_info->nr_pages;
150 unsigned long long mem_end;
151 int rc;
152 struct xen_memory_map memmap;
153 unsigned long extra_pages = 0;
154 unsigned long extra_limit;
155 int i;
156 int op;
112 157
113 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn); 158 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
159 mem_end = PFN_PHYS(max_pfn);
160
161 memmap.nr_entries = E820MAX;
162 set_xen_guest_handle(memmap.buffer, map);
163
164 op = xen_initial_domain() ?
165 XENMEM_machine_memory_map :
166 XENMEM_memory_map;
167 rc = HYPERVISOR_memory_op(op, &memmap);
168 if (rc == -ENOSYS) {
169 BUG_ON(xen_initial_domain());
170 memmap.nr_entries = 1;
171 map[0].addr = 0ULL;
172 map[0].size = mem_end;
173 /* 8MB slack (to balance backend allocations). */
174 map[0].size += 8ULL << 20;
175 map[0].type = E820_RAM;
176 rc = 0;
177 }
178 BUG_ON(rc);
114 179
115 e820.nr_map = 0; 180 e820.nr_map = 0;
181 xen_extra_mem_start = mem_end;
182 for (i = 0; i < memmap.nr_entries; i++) {
183 unsigned long long end = map[i].addr + map[i].size;
184
185 if (map[i].type == E820_RAM) {
186 if (map[i].addr < mem_end && end > mem_end) {
187 /* Truncate region to max_mem. */
188 u64 delta = end - mem_end;
116 189
117 e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM); 190 map[i].size -= delta;
191 extra_pages += PFN_DOWN(delta);
192
193 end = mem_end;
194 }
195 }
196
197 if (end > xen_extra_mem_start)
198 xen_extra_mem_start = end;
199
200 /* If region is non-RAM or below mem_end, add what remains */
201 if ((map[i].type != E820_RAM || map[i].addr < mem_end) &&
202 map[i].size > 0)
203 e820_add_region(map[i].addr, map[i].size, map[i].type);
204 }
118 205
119 /* 206 /*
120 * Even though this is normal, usable memory under Xen, reserve 207 * In domU, the ISA region is normal, usable memory, but we
121 * ISA memory anyway because too many things think they can poke 208 * reserve ISA memory anyway because too many things poke
122 * about in there. 209 * about in there.
210 *
211 * In Dom0, the host E820 information can leave gaps in the
212 * ISA range, which would cause us to release those pages. To
213 * avoid this, we unconditionally reserve them here.
123 */ 214 */
124 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, 215 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
125 E820_RESERVED); 216 E820_RESERVED);
@@ -136,7 +227,29 @@ char * __init xen_memory_setup(void)
136 227
137 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 228 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
138 229
139 xen_return_unused_memory(xen_start_info->nr_pages, &e820); 230 extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820);
231
232 /*
233 * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
234 * factor the base size. On non-highmem systems, the base
235 * size is the full initial memory allocation; on highmem it
236 * is limited to the max size of lowmem, so that it doesn't
237 * get completely filled.
238 *
239 * In principle there could be a problem in lowmem systems if
240 * the initial memory is also very large with respect to
241 * lowmem, but we won't try to deal with that here.
242 */
243 extra_limit = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
244 max_pfn + extra_pages);
245
246 if (extra_limit >= max_pfn)
247 extra_pages = extra_limit - max_pfn;
248 else
249 extra_pages = 0;
250
251 if (!xen_initial_domain())
252 xen_add_extra_mem(extra_pages);
140 253
141 return "Xen"; 254 return "Xen";
142} 255}
@@ -261,7 +374,5 @@ void __init xen_arch_setup(void)
261 374
262 pm_idle = xen_idle; 375 pm_idle = xen_idle;
263 376
264 paravirt_disable_iospace();
265
266 fiddle_vdso(); 377 fiddle_vdso();
267} 378}
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 25f232b18a82..72a4c7959045 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -28,6 +28,7 @@
28#include <asm/xen/interface.h> 28#include <asm/xen/interface.h>
29#include <asm/xen/hypercall.h> 29#include <asm/xen/hypercall.h>
30 30
31#include <xen/xen.h>
31#include <xen/page.h> 32#include <xen/page.h>
32#include <xen/events.h> 33#include <xen/events.h>
33 34
@@ -156,11 +157,35 @@ static void __init xen_fill_possible_map(void)
156{ 157{
157 int i, rc; 158 int i, rc;
158 159
160 if (xen_initial_domain())
161 return;
162
163 for (i = 0; i < nr_cpu_ids; i++) {
164 rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
165 if (rc >= 0) {
166 num_processors++;
167 set_cpu_possible(i, true);
168 }
169 }
170}
171
172static void __init xen_filter_cpu_maps(void)
173{
174 int i, rc;
175
176 if (!xen_initial_domain())
177 return;
178
179 num_processors = 0;
180 disabled_cpus = 0;
159 for (i = 0; i < nr_cpu_ids; i++) { 181 for (i = 0; i < nr_cpu_ids; i++) {
160 rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL); 182 rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
161 if (rc >= 0) { 183 if (rc >= 0) {
162 num_processors++; 184 num_processors++;
163 set_cpu_possible(i, true); 185 set_cpu_possible(i, true);
186 } else {
187 set_cpu_possible(i, false);
188 set_cpu_present(i, false);
164 } 189 }
165 } 190 }
166} 191}
@@ -174,6 +199,7 @@ static void __init xen_smp_prepare_boot_cpu(void)
174 old memory can be recycled */ 199 old memory can be recycled */
175 make_lowmem_page_readwrite(xen_initial_gdt); 200 make_lowmem_page_readwrite(xen_initial_gdt);
176 201
202 xen_filter_cpu_maps();
177 xen_setup_vcpu_info_placement(); 203 xen_setup_vcpu_info_placement();
178} 204}
179 205
@@ -400,9 +426,9 @@ static void stop_self(void *v)
400 BUG(); 426 BUG();
401} 427}
402 428
403static void xen_smp_send_stop(void) 429static void xen_stop_other_cpus(int wait)
404{ 430{
405 smp_call_function(stop_self, NULL, 0); 431 smp_call_function(stop_self, NULL, wait);
406} 432}
407 433
408static void xen_smp_send_reschedule(int cpu) 434static void xen_smp_send_reschedule(int cpu)
@@ -470,7 +496,7 @@ static const struct smp_ops xen_smp_ops __initdata = {
470 .cpu_disable = xen_cpu_disable, 496 .cpu_disable = xen_cpu_disable,
471 .play_dead = xen_play_dead, 497 .play_dead = xen_play_dead,
472 498
473 .smp_send_stop = xen_smp_send_stop, 499 .stop_other_cpus = xen_stop_other_cpus,
474 .smp_send_reschedule = xen_smp_send_reschedule, 500 .smp_send_reschedule = xen_smp_send_reschedule,
475 501
476 .send_call_func_ipi = xen_smp_send_call_function_ipi, 502 .send_call_func_ipi = xen_smp_send_call_function_ipi,
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 7c8ab86163e9..64044747348e 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -30,6 +30,9 @@ void xen_setup_machphys_mapping(void);
30pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn); 30pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn);
31void xen_ident_map_ISA(void); 31void xen_ident_map_ISA(void);
32void xen_reserve_top(void); 32void xen_reserve_top(void);
33extern unsigned long xen_max_p2m_pfn;
34
35void xen_set_pat(u64);
33 36
34char * __init xen_memory_setup(void); 37char * __init xen_memory_setup(void);
35void __init xen_arch_setup(void); 38void __init xen_arch_setup(void);
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 0859bfd8ae93..d373d159e75e 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -1,8 +1,3 @@
1# For a description of the syntax of this configuration file,
2# see Documentation/kbuild/kconfig-language.txt.
3
4mainmenu "Linux/Xtensa Kernel Configuration"
5
6config FRAME_POINTER 1config FRAME_POINTER
7 def_bool n 2 def_bool n
8 3
diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
index 76bf35554117..b03c043ce75b 100644
--- a/arch/xtensa/include/asm/pgtable.h
+++ b/arch/xtensa/include/asm/pgtable.h
@@ -324,10 +324,7 @@ ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
324#define pte_offset_kernel(dir,addr) \ 324#define pte_offset_kernel(dir,addr) \
325 ((pte_t*) pmd_page_vaddr(*(dir)) + pte_index(addr)) 325 ((pte_t*) pmd_page_vaddr(*(dir)) + pte_index(addr))
326#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr)) 326#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr))
327#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir),(addr))
328
329#define pte_unmap(pte) do { } while (0) 327#define pte_unmap(pte) do { } while (0)
330#define pte_unmap_nested(pte) do { } while (0)
331 328
332 329
333/* 330/*
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/ptrace.c b/arch/xtensa/kernel/ptrace.c
index 9d4e1ceb3f09..c72c9473ef99 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -256,9 +256,11 @@ int ptrace_pokeusr(struct task_struct *child, long regno, long val)
256 return 0; 256 return 0;
257} 257}
258 258
259long arch_ptrace(struct task_struct *child, long request, long addr, long data) 259long arch_ptrace(struct task_struct *child, long request,
260 unsigned long addr, unsigned long data)
260{ 261{
261 int ret = -EPERM; 262 int ret = -EPERM;
263 void __user *datap = (void __user *) data;
262 264
263 switch (request) { 265 switch (request) {
264 case PTRACE_PEEKTEXT: /* read word at location addr. */ 266 case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -267,7 +269,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
267 break; 269 break;
268 270
269 case PTRACE_PEEKUSR: /* read register specified by addr. */ 271 case PTRACE_PEEKUSR: /* read register specified by addr. */
270 ret = ptrace_peekusr(child, addr, (void __user *) data); 272 ret = ptrace_peekusr(child, addr, datap);
271 break; 273 break;
272 274
273 case PTRACE_POKETEXT: /* write the word at location addr. */ 275 case PTRACE_POKETEXT: /* write the word at location addr. */
@@ -280,19 +282,19 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
280 break; 282 break;
281 283
282 case PTRACE_GETREGS: 284 case PTRACE_GETREGS:
283 ret = ptrace_getregs(child, (void __user *) data); 285 ret = ptrace_getregs(child, datap);
284 break; 286 break;
285 287
286 case PTRACE_SETREGS: 288 case PTRACE_SETREGS:
287 ret = ptrace_setregs(child, (void __user *) data); 289 ret = ptrace_setregs(child, datap);
288 break; 290 break;
289 291
290 case PTRACE_GETXTREGS: 292 case PTRACE_GETXTREGS:
291 ret = ptrace_getxregs(child, (void __user *) data); 293 ret = ptrace_getxregs(child, datap);
292 break; 294 break;
293 295
294 case PTRACE_SETXTREGS: 296 case PTRACE_SETXTREGS:
295 ret = ptrace_setxregs(child, (void __user *) data); 297 ret = ptrace_setxregs(child, datap);
296 break; 298 break;
297 299
298 default: 300 default: